diff --git a/public/index.html b/index.html similarity index 81% rename from public/index.html rename to index.html index a718a8d1c..89d375c52 100644 --- a/public/index.html +++ b/index.html @@ -2,27 +2,27 @@ - + - + - + @@ -40,6 +40,8 @@ To begin the development, run `npm start` or `yarn start`. To create a production bundle, use `npm run build` or `yarn build`. + --> + diff --git a/package-lock.json b/package-lock.json deleted file mode 100644 index b0c77ddb0..000000000 --- a/package-lock.json +++ /dev/null @@ -1,22204 +0,0 @@ -{ - "name": "hidiag", - "version": "0.1.0", - "lockfileVersion": 3, - "requires": true, - "packages": { - "": { - "name": "hidiag", - "version": "0.1.0", - "dependencies": { - "@emotion/react": "^11.11.0", - "@google/generative-ai": "^0.1.3", - "@mantine/carousel": "^6.0.11", - "@mantine/core": "^6.0.11", - "@mantine/dates": "^6.0.11", - "@mantine/dropzone": "^6.0.11", - "@mantine/form": "^6.0.11", - "@mantine/hooks": "^6.0.11", - "@mantine/modals": "^6.0.11", - "@mantine/notifications": "^6.0.11", - "@mantine/nprogress": "^6.0.11", - "@mantine/prism": "^6.0.11", - "@mantine/spotlight": "^6.0.11", - "@mantine/tiptap": "^6.0.11", - "@tabler/icons-react": "^2.20.0", - "@tensorflow/tfjs": "^4.13.0", - "@tensorflow/tfjs-node": "^1.7.4", - "@testing-library/jest-dom": "^5.16.5", - "@testing-library/react": "^13.4.0", - "@testing-library/user-event": "^13.5.0", - "@tiptap/extension-link": "^2.0.3", - "@tiptap/react": "^2.0.3", - "@tiptap/starter-kit": "^2.0.3", - "axios": "^1.4.0", - "brainjs": "^0.7.4", - "dayjs": "^1.11.7", - "embla-carousel-react": "^7.1.0", - "esdoc": "^1.1.0", - "esdoc-standard-plugin": "^1.0.0", - "express": "^4.18.2", - "https": "^1.0.0", - "https-browserify": "^1.0.0", - "localforage": "^1.10.0", - "match-sorter": "^6.3.1", - "path-browserify": "^1.0.1", - "pvtsutils": "^1.3.5", - "qrcode": "^1.5.3", - "react": "^18.2.0", - "react-dom": "^18.2.0", - "react-router-dom": "^6.11.2", - "react-scripts": "^5.0.1", - "rfc4648": "^1.5.3", - "socket.io": "^4.7.3", - "socket.io-client": "^4.7.3", - "sort-by": "^1.2.0", - "stream-browserify": "^3.0.0", - "stream-http": "^3.2.0", - "synaptic": "^1.1.4", - "url": "^0.11.0", - "use-effect-x": "^0.1.5", - "util": "^0.12.5", - "web-vitals": "^2.1.4", - "webpack": "^5.89.0" - } - }, - "node_modules/@adobe/css-tools": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/@adobe/css-tools/-/css-tools-4.2.0.tgz", - "integrity": "sha512-E09FiIft46CmH5Qnjb0wsW54/YQd69LsxeKUOWawmws1XWvyFGURnAChH0mlr7YPFR1ofwvUQfcL0J3lMxXqPA==" - }, - "node_modules/@alloc/quick-lru": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/@alloc/quick-lru/-/quick-lru-5.2.0.tgz", - "integrity": "sha512-UrcABB+4bUrFABwbluTIBErXwvbsU/V7TZWfmbgJfbkwiBuziS9gxdODUyuiecfdGQ85jglMW6juS3+z5TsKLw==", - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/@ampproject/remapping": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.2.1.tgz", - "integrity": "sha512-lFMjJTrFL3j7L9yBxwYfCq2k6qqwHyzuUl/XBnif78PWTJYyL/dfowQHWE3sp6U6ZzqWiiIZnpTMO96zhkjwtg==", - "dependencies": { - "@jridgewell/gen-mapping": "^0.3.0", - "@jridgewell/trace-mapping": "^0.3.9" - }, - "engines": { - "node": ">=6.0.0" - } - }, - "node_modules/@babel/code-frame": { - "version": "7.21.4", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.21.4.tgz", - "integrity": "sha512-LYvhNKfwWSPpocw8GI7gpK2nq3HSDuEPC/uSYaALSJu9xjsalaaYFOq0Pwt5KmVqwEbZlDu81aLXwBOmD/Fv9g==", - "dependencies": { - "@babel/highlight": "^7.18.6" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/compat-data": { - "version": "7.21.9", - "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.21.9.tgz", - "integrity": "sha512-FUGed8kfhyWvbYug/Un/VPJD41rDIgoVVcR+FuzhzOYyRz5uED+Gd3SLZml0Uw2l2aHFb7ZgdW5mGA3G2cCCnQ==", - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/core": { - "version": "7.21.8", - "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.21.8.tgz", - "integrity": "sha512-YeM22Sondbo523Sz0+CirSPnbj9bG3P0CdHcBZdqUuaeOaYEFbOLoGU7lebvGP6P5J/WE9wOn7u7C4J9HvS1xQ==", - "dependencies": { - "@ampproject/remapping": "^2.2.0", - "@babel/code-frame": "^7.21.4", - "@babel/generator": "^7.21.5", - "@babel/helper-compilation-targets": "^7.21.5", - "@babel/helper-module-transforms": "^7.21.5", - "@babel/helpers": "^7.21.5", - "@babel/parser": "^7.21.8", - "@babel/template": "^7.20.7", - "@babel/traverse": "^7.21.5", - "@babel/types": "^7.21.5", - "convert-source-map": "^1.7.0", - "debug": "^4.1.0", - "gensync": "^1.0.0-beta.2", - "json5": "^2.2.2", - "semver": "^6.3.0" - }, - "engines": { - "node": ">=6.9.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/babel" - } - }, - "node_modules/@babel/core/node_modules/semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", - "bin": { - "semver": "bin/semver.js" - } - }, - "node_modules/@babel/eslint-parser": { - "version": "7.21.8", - "resolved": "https://registry.npmjs.org/@babel/eslint-parser/-/eslint-parser-7.21.8.tgz", - "integrity": "sha512-HLhI+2q+BP3sf78mFUZNCGc10KEmoUqtUT1OCdMZsN+qr4qFeLUod62/zAnF3jNQstwyasDkZnVXwfK2Bml7MQ==", - "dependencies": { - "@nicolo-ribaudo/eslint-scope-5-internals": "5.1.1-v1", - "eslint-visitor-keys": "^2.1.0", - "semver": "^6.3.0" - }, - "engines": { - "node": "^10.13.0 || ^12.13.0 || >=14.0.0" - }, - "peerDependencies": { - "@babel/core": ">=7.11.0", - "eslint": "^7.5.0 || ^8.0.0" - } - }, - "node_modules/@babel/eslint-parser/node_modules/eslint-visitor-keys": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-2.1.0.tgz", - "integrity": "sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw==", - "engines": { - "node": ">=10" - } - }, - "node_modules/@babel/eslint-parser/node_modules/semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", - "bin": { - "semver": "bin/semver.js" - } - }, - "node_modules/@babel/generator": { - "version": "7.21.9", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.21.9.tgz", - "integrity": "sha512-F3fZga2uv09wFdEjEQIJxXALXfz0+JaOb7SabvVMmjHxeVTuGW8wgE8Vp1Hd7O+zMTYtcfEISGRzPkeiaPPsvg==", - "dependencies": { - "@babel/types": "^7.21.5", - "@jridgewell/gen-mapping": "^0.3.2", - "@jridgewell/trace-mapping": "^0.3.17", - "jsesc": "^2.5.1" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-annotate-as-pure": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.18.6.tgz", - "integrity": "sha512-duORpUiYrEpzKIop6iNbjnwKLAKnJ47csTyRACyEmWj0QdUrm5aqNJGHSSEQSUAvNW0ojX0dOmK9dZduvkfeXA==", - "dependencies": { - "@babel/types": "^7.18.6" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-builder-binary-assignment-operator-visitor": { - "version": "7.21.5", - "resolved": "https://registry.npmjs.org/@babel/helper-builder-binary-assignment-operator-visitor/-/helper-builder-binary-assignment-operator-visitor-7.21.5.tgz", - "integrity": "sha512-uNrjKztPLkUk7bpCNC0jEKDJzzkvel/W+HguzbN8krA+LPfC1CEobJEvAvGka2A/M+ViOqXdcRL0GqPUJSjx9g==", - "dependencies": { - "@babel/types": "^7.21.5" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-compilation-targets": { - "version": "7.21.5", - "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.21.5.tgz", - "integrity": "sha512-1RkbFGUKex4lvsB9yhIfWltJM5cZKUftB2eNajaDv3dCMEp49iBG0K14uH8NnX9IPux2+mK7JGEOB0jn48/J6w==", - "dependencies": { - "@babel/compat-data": "^7.21.5", - "@babel/helper-validator-option": "^7.21.0", - "browserslist": "^4.21.3", - "lru-cache": "^5.1.1", - "semver": "^6.3.0" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0" - } - }, - "node_modules/@babel/helper-compilation-targets/node_modules/semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", - "bin": { - "semver": "bin/semver.js" - } - }, - "node_modules/@babel/helper-create-class-features-plugin": { - "version": "7.21.8", - "resolved": "https://registry.npmjs.org/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.21.8.tgz", - "integrity": "sha512-+THiN8MqiH2AczyuZrnrKL6cAxFRRQDKW9h1YkBvbgKmAm6mwiacig1qT73DHIWMGo40GRnsEfN3LA+E6NtmSw==", - "dependencies": { - "@babel/helper-annotate-as-pure": "^7.18.6", - "@babel/helper-environment-visitor": "^7.21.5", - "@babel/helper-function-name": "^7.21.0", - "@babel/helper-member-expression-to-functions": "^7.21.5", - "@babel/helper-optimise-call-expression": "^7.18.6", - "@babel/helper-replace-supers": "^7.21.5", - "@babel/helper-skip-transparent-expression-wrappers": "^7.20.0", - "@babel/helper-split-export-declaration": "^7.18.6", - "semver": "^6.3.0" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0" - } - }, - "node_modules/@babel/helper-create-class-features-plugin/node_modules/semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", - "bin": { - "semver": "bin/semver.js" - } - }, - "node_modules/@babel/helper-create-regexp-features-plugin": { - "version": "7.21.8", - "resolved": "https://registry.npmjs.org/@babel/helper-create-regexp-features-plugin/-/helper-create-regexp-features-plugin-7.21.8.tgz", - "integrity": "sha512-zGuSdedkFtsFHGbexAvNuipg1hbtitDLo2XE8/uf6Y9sOQV1xsYX/2pNbtedp/X0eU1pIt+kGvaqHCowkRbS5g==", - "dependencies": { - "@babel/helper-annotate-as-pure": "^7.18.6", - "regexpu-core": "^5.3.1", - "semver": "^6.3.0" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0" - } - }, - "node_modules/@babel/helper-create-regexp-features-plugin/node_modules/semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", - "bin": { - "semver": "bin/semver.js" - } - }, - "node_modules/@babel/helper-define-polyfill-provider": { - "version": "0.3.3", - "resolved": "https://registry.npmjs.org/@babel/helper-define-polyfill-provider/-/helper-define-polyfill-provider-0.3.3.tgz", - "integrity": "sha512-z5aQKU4IzbqCC1XH0nAqfsFLMVSo22SBKUc0BxGrLkolTdPTructy0ToNnlO2zA4j9Q/7pjMZf0DSY+DSTYzww==", - "dependencies": { - "@babel/helper-compilation-targets": "^7.17.7", - "@babel/helper-plugin-utils": "^7.16.7", - "debug": "^4.1.1", - "lodash.debounce": "^4.0.8", - "resolve": "^1.14.2", - "semver": "^6.1.2" - }, - "peerDependencies": { - "@babel/core": "^7.4.0-0" - } - }, - "node_modules/@babel/helper-define-polyfill-provider/node_modules/semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", - "bin": { - "semver": "bin/semver.js" - } - }, - "node_modules/@babel/helper-environment-visitor": { - "version": "7.21.5", - "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.21.5.tgz", - "integrity": "sha512-IYl4gZ3ETsWocUWgsFZLM5i1BYx9SoemminVEXadgLBa9TdeorzgLKm8wWLA6J1N/kT3Kch8XIk1laNzYoHKvQ==", - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-function-name": { - "version": "7.21.0", - "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.21.0.tgz", - "integrity": "sha512-HfK1aMRanKHpxemaY2gqBmL04iAPOPRj7DxtNbiDOrJK+gdwkiNRVpCpUJYbUT+aZyemKN8brqTOxzCaG6ExRg==", - "dependencies": { - "@babel/template": "^7.20.7", - "@babel/types": "^7.21.0" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-hoist-variables": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.18.6.tgz", - "integrity": "sha512-UlJQPkFqFULIcyW5sbzgbkxn2FKRgwWiRexcuaR8RNJRy8+LLveqPjwZV/bwrLZCN0eUHD/x8D0heK1ozuoo6Q==", - "dependencies": { - "@babel/types": "^7.18.6" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-member-expression-to-functions": { - "version": "7.21.5", - "resolved": "https://registry.npmjs.org/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.21.5.tgz", - "integrity": "sha512-nIcGfgwpH2u4n9GG1HpStW5Ogx7x7ekiFHbjjFRKXbn5zUvqO9ZgotCO4x1aNbKn/x/xOUaXEhyNHCwtFCpxWg==", - "dependencies": { - "@babel/types": "^7.21.5" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-module-imports": { - "version": "7.21.4", - "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.21.4.tgz", - "integrity": "sha512-orajc5T2PsRYUN3ZryCEFeMDYwyw09c/pZeaQEZPH0MpKzSvn3e0uXsDBu3k03VI+9DBiRo+l22BfKTpKwa/Wg==", - "dependencies": { - "@babel/types": "^7.21.4" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-module-transforms": { - "version": "7.21.5", - "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.21.5.tgz", - "integrity": "sha512-bI2Z9zBGY2q5yMHoBvJ2a9iX3ZOAzJPm7Q8Yz6YeoUjU/Cvhmi2G4QyTNyPBqqXSgTjUxRg3L0xV45HvkNWWBw==", - "dependencies": { - "@babel/helper-environment-visitor": "^7.21.5", - "@babel/helper-module-imports": "^7.21.4", - "@babel/helper-simple-access": "^7.21.5", - "@babel/helper-split-export-declaration": "^7.18.6", - "@babel/helper-validator-identifier": "^7.19.1", - "@babel/template": "^7.20.7", - "@babel/traverse": "^7.21.5", - "@babel/types": "^7.21.5" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-optimise-call-expression": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.18.6.tgz", - "integrity": "sha512-HP59oD9/fEHQkdcbgFCnbmgH5vIQTJbxh2yf+CdM89/glUNnuzr87Q8GIjGEnOktTROemO0Pe0iPAYbqZuOUiA==", - "dependencies": { - "@babel/types": "^7.18.6" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-plugin-utils": { - "version": "7.21.5", - "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.21.5.tgz", - "integrity": "sha512-0WDaIlXKOX/3KfBK/dwP1oQGiPh6rjMkT7HIRv7i5RR2VUMwrx5ZL0dwBkKx7+SW1zwNdgjHd34IMk5ZjTeHVg==", - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-remap-async-to-generator": { - "version": "7.18.9", - "resolved": "https://registry.npmjs.org/@babel/helper-remap-async-to-generator/-/helper-remap-async-to-generator-7.18.9.tgz", - "integrity": "sha512-dI7q50YKd8BAv3VEfgg7PS7yD3Rtbi2J1XMXaalXO0W0164hYLnh8zpjRS0mte9MfVp/tltvr/cfdXPvJr1opA==", - "dependencies": { - "@babel/helper-annotate-as-pure": "^7.18.6", - "@babel/helper-environment-visitor": "^7.18.9", - "@babel/helper-wrap-function": "^7.18.9", - "@babel/types": "^7.18.9" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0" - } - }, - "node_modules/@babel/helper-replace-supers": { - "version": "7.21.5", - "resolved": "https://registry.npmjs.org/@babel/helper-replace-supers/-/helper-replace-supers-7.21.5.tgz", - "integrity": "sha512-/y7vBgsr9Idu4M6MprbOVUfH3vs7tsIfnVWv/Ml2xgwvyH6LTngdfbf5AdsKwkJy4zgy1X/kuNrEKvhhK28Yrg==", - "dependencies": { - "@babel/helper-environment-visitor": "^7.21.5", - "@babel/helper-member-expression-to-functions": "^7.21.5", - "@babel/helper-optimise-call-expression": "^7.18.6", - "@babel/template": "^7.20.7", - "@babel/traverse": "^7.21.5", - "@babel/types": "^7.21.5" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-simple-access": { - "version": "7.21.5", - "resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.21.5.tgz", - "integrity": "sha512-ENPDAMC1wAjR0uaCUwliBdiSl1KBJAVnMTzXqi64c2MG8MPR6ii4qf7bSXDqSFbr4W6W028/rf5ivoHop5/mkg==", - "dependencies": { - "@babel/types": "^7.21.5" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-skip-transparent-expression-wrappers": { - "version": "7.20.0", - "resolved": "https://registry.npmjs.org/@babel/helper-skip-transparent-expression-wrappers/-/helper-skip-transparent-expression-wrappers-7.20.0.tgz", - "integrity": "sha512-5y1JYeNKfvnT8sZcK9DVRtpTbGiomYIHviSP3OQWmDPU3DeH4a1ZlT/N2lyQ5P8egjcRaT/Y9aNqUxK0WsnIIg==", - "dependencies": { - "@babel/types": "^7.20.0" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-split-export-declaration": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.18.6.tgz", - "integrity": "sha512-bde1etTx6ZyTmobl9LLMMQsaizFVZrquTEHOqKeQESMKo4PlObf+8+JA25ZsIpZhT/WEd39+vOdLXAFG/nELpA==", - "dependencies": { - "@babel/types": "^7.18.6" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-string-parser": { - "version": "7.21.5", - "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.21.5.tgz", - "integrity": "sha512-5pTUx3hAJaZIdW99sJ6ZUUgWq/Y+Hja7TowEnLNMm1VivRgZQL3vpBY3qUACVsvw+yQU6+YgfBVmcbLaZtrA1w==", - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-validator-identifier": { - "version": "7.19.1", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.19.1.tgz", - "integrity": "sha512-awrNfaMtnHUr653GgGEs++LlAvW6w+DcPrOliSMXWCKo597CwL5Acf/wWdNkf/tfEQE3mjkeD1YOVZOUV/od1w==", - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-validator-option": { - "version": "7.21.0", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.21.0.tgz", - "integrity": "sha512-rmL/B8/f0mKS2baE9ZpyTcTavvEuWhTTW8amjzXNvYG4AwBsqTLikfXsEofsJEfKHf+HQVQbFOHy6o+4cnC/fQ==", - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-wrap-function": { - "version": "7.20.5", - "resolved": "https://registry.npmjs.org/@babel/helper-wrap-function/-/helper-wrap-function-7.20.5.tgz", - "integrity": "sha512-bYMxIWK5mh+TgXGVqAtnu5Yn1un+v8DDZtqyzKRLUzrh70Eal2O3aZ7aPYiMADO4uKlkzOiRiZ6GX5q3qxvW9Q==", - "dependencies": { - "@babel/helper-function-name": "^7.19.0", - "@babel/template": "^7.18.10", - "@babel/traverse": "^7.20.5", - "@babel/types": "^7.20.5" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helpers": { - "version": "7.21.5", - "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.21.5.tgz", - "integrity": "sha512-BSY+JSlHxOmGsPTydUkPf1MdMQ3M81x5xGCOVgWM3G8XH77sJ292Y2oqcp0CbbgxhqBuI46iUz1tT7hqP7EfgA==", - "dependencies": { - "@babel/template": "^7.20.7", - "@babel/traverse": "^7.21.5", - "@babel/types": "^7.21.5" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/highlight": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.18.6.tgz", - "integrity": "sha512-u7stbOuYjaPezCuLj29hNW1v64M2Md2qupEKP1fHc7WdOA3DgLh37suiSrZYY7haUB7iBeQZ9P1uiRF359do3g==", - "dependencies": { - "@babel/helper-validator-identifier": "^7.18.6", - "chalk": "^2.0.0", - "js-tokens": "^4.0.0" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/parser": { - "version": "7.21.9", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.21.9.tgz", - "integrity": "sha512-q5PNg/Bi1OpGgx5jYlvWZwAorZepEudDMCLtj967aeS7WMont7dUZI46M2XwcIQqvUlMxWfdLFu4S/qSxeUu5g==", - "bin": { - "parser": "bin/babel-parser.js" - }, - "engines": { - "node": ">=6.0.0" - } - }, - "node_modules/@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression/-/plugin-bugfix-safari-id-destructuring-collision-in-function-expression-7.18.6.tgz", - "integrity": "sha512-Dgxsyg54Fx1d4Nge8UnvTrED63vrwOdPmyvPzlNN/boaliRP54pm3pGzZD1SJUwrBA+Cs/xdG8kXX6Mn/RfISQ==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.18.6" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0" - } - }, - "node_modules/@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining": { - "version": "7.20.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining/-/plugin-bugfix-v8-spread-parameters-in-optional-chaining-7.20.7.tgz", - "integrity": "sha512-sbr9+wNE5aXMBBFBICk01tt7sBf2Oc9ikRFEcem/ZORup9IMUdNhW7/wVLEbbtlWOsEubJet46mHAL2C8+2jKQ==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.20.2", - "@babel/helper-skip-transparent-expression-wrappers": "^7.20.0", - "@babel/plugin-proposal-optional-chaining": "^7.20.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.13.0" - } - }, - "node_modules/@babel/plugin-proposal-async-generator-functions": { - "version": "7.20.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-async-generator-functions/-/plugin-proposal-async-generator-functions-7.20.7.tgz", - "integrity": "sha512-xMbiLsn/8RK7Wq7VeVytytS2L6qE69bXPB10YCmMdDZbKF4okCqY74pI/jJQ/8U0b/F6NrT2+14b8/P9/3AMGA==", - "dependencies": { - "@babel/helper-environment-visitor": "^7.18.9", - "@babel/helper-plugin-utils": "^7.20.2", - "@babel/helper-remap-async-to-generator": "^7.18.9", - "@babel/plugin-syntax-async-generators": "^7.8.4" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-proposal-class-properties": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-class-properties/-/plugin-proposal-class-properties-7.18.6.tgz", - "integrity": "sha512-cumfXOF0+nzZrrN8Rf0t7M+tF6sZc7vhQwYQck9q1/5w2OExlD+b4v4RpMJFaV1Z7WcDRgO6FqvxqxGlwo+RHQ==", - "dependencies": { - "@babel/helper-create-class-features-plugin": "^7.18.6", - "@babel/helper-plugin-utils": "^7.18.6" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-proposal-class-static-block": { - "version": "7.21.0", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-class-static-block/-/plugin-proposal-class-static-block-7.21.0.tgz", - "integrity": "sha512-XP5G9MWNUskFuP30IfFSEFB0Z6HzLIUcjYM4bYOPHXl7eiJ9HFv8tWj6TXTN5QODiEhDZAeI4hLok2iHFFV4hw==", - "dependencies": { - "@babel/helper-create-class-features-plugin": "^7.21.0", - "@babel/helper-plugin-utils": "^7.20.2", - "@babel/plugin-syntax-class-static-block": "^7.14.5" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.12.0" - } - }, - "node_modules/@babel/plugin-proposal-decorators": { - "version": "7.21.0", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-decorators/-/plugin-proposal-decorators-7.21.0.tgz", - "integrity": "sha512-MfgX49uRrFUTL/HvWtmx3zmpyzMMr4MTj3d527MLlr/4RTT9G/ytFFP7qet2uM2Ve03b+BkpWUpK+lRXnQ+v9w==", - "dependencies": { - "@babel/helper-create-class-features-plugin": "^7.21.0", - "@babel/helper-plugin-utils": "^7.20.2", - "@babel/helper-replace-supers": "^7.20.7", - "@babel/helper-split-export-declaration": "^7.18.6", - "@babel/plugin-syntax-decorators": "^7.21.0" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-proposal-dynamic-import": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-dynamic-import/-/plugin-proposal-dynamic-import-7.18.6.tgz", - "integrity": "sha512-1auuwmK+Rz13SJj36R+jqFPMJWyKEDd7lLSdOj4oJK0UTgGueSAtkrCvz9ewmgyU/P941Rv2fQwZJN8s6QruXw==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.18.6", - "@babel/plugin-syntax-dynamic-import": "^7.8.3" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-proposal-export-namespace-from": { - "version": "7.18.9", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-export-namespace-from/-/plugin-proposal-export-namespace-from-7.18.9.tgz", - "integrity": "sha512-k1NtHyOMvlDDFeb9G5PhUXuGj8m/wiwojgQVEhJ/fsVsMCpLyOP4h0uGEjYJKrRI+EVPlb5Jk+Gt9P97lOGwtA==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.18.9", - "@babel/plugin-syntax-export-namespace-from": "^7.8.3" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-proposal-json-strings": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-json-strings/-/plugin-proposal-json-strings-7.18.6.tgz", - "integrity": "sha512-lr1peyn9kOdbYc0xr0OdHTZ5FMqS6Di+H0Fz2I/JwMzGmzJETNeOFq2pBySw6X/KFL5EWDjlJuMsUGRFb8fQgQ==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.18.6", - "@babel/plugin-syntax-json-strings": "^7.8.3" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-proposal-logical-assignment-operators": { - "version": "7.20.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-logical-assignment-operators/-/plugin-proposal-logical-assignment-operators-7.20.7.tgz", - "integrity": "sha512-y7C7cZgpMIjWlKE5T7eJwp+tnRYM89HmRvWM5EQuB5BoHEONjmQ8lSNmBUwOyy/GFRsohJED51YBF79hE1djug==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.20.2", - "@babel/plugin-syntax-logical-assignment-operators": "^7.10.4" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-proposal-nullish-coalescing-operator": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-nullish-coalescing-operator/-/plugin-proposal-nullish-coalescing-operator-7.18.6.tgz", - "integrity": "sha512-wQxQzxYeJqHcfppzBDnm1yAY0jSRkUXR2z8RePZYrKwMKgMlE8+Z6LUno+bd6LvbGh8Gltvy74+9pIYkr+XkKA==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.18.6", - "@babel/plugin-syntax-nullish-coalescing-operator": "^7.8.3" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-proposal-numeric-separator": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-numeric-separator/-/plugin-proposal-numeric-separator-7.18.6.tgz", - "integrity": "sha512-ozlZFogPqoLm8WBr5Z8UckIoE4YQ5KESVcNudyXOR8uqIkliTEgJ3RoketfG6pmzLdeZF0H/wjE9/cCEitBl7Q==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.18.6", - "@babel/plugin-syntax-numeric-separator": "^7.10.4" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-proposal-object-rest-spread": { - "version": "7.20.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-object-rest-spread/-/plugin-proposal-object-rest-spread-7.20.7.tgz", - "integrity": "sha512-d2S98yCiLxDVmBmE8UjGcfPvNEUbA1U5q5WxaWFUGRzJSVAZqm5W6MbPct0jxnegUZ0niLeNX+IOzEs7wYg9Dg==", - "dependencies": { - "@babel/compat-data": "^7.20.5", - "@babel/helper-compilation-targets": "^7.20.7", - "@babel/helper-plugin-utils": "^7.20.2", - "@babel/plugin-syntax-object-rest-spread": "^7.8.3", - "@babel/plugin-transform-parameters": "^7.20.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-proposal-optional-catch-binding": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-optional-catch-binding/-/plugin-proposal-optional-catch-binding-7.18.6.tgz", - "integrity": "sha512-Q40HEhs9DJQyaZfUjjn6vE8Cv4GmMHCYuMGIWUnlxH6400VGxOuwWsPt4FxXxJkC/5eOzgn0z21M9gMT4MOhbw==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.18.6", - "@babel/plugin-syntax-optional-catch-binding": "^7.8.3" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-proposal-optional-chaining": { - "version": "7.21.0", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-optional-chaining/-/plugin-proposal-optional-chaining-7.21.0.tgz", - "integrity": "sha512-p4zeefM72gpmEe2fkUr/OnOXpWEf8nAgk7ZYVqqfFiyIG7oFfVZcCrU64hWn5xp4tQ9LkV4bTIa5rD0KANpKNA==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.20.2", - "@babel/helper-skip-transparent-expression-wrappers": "^7.20.0", - "@babel/plugin-syntax-optional-chaining": "^7.8.3" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-proposal-private-methods": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-private-methods/-/plugin-proposal-private-methods-7.18.6.tgz", - "integrity": "sha512-nutsvktDItsNn4rpGItSNV2sz1XwS+nfU0Rg8aCx3W3NOKVzdMjJRu0O5OkgDp3ZGICSTbgRpxZoWsxoKRvbeA==", - "dependencies": { - "@babel/helper-create-class-features-plugin": "^7.18.6", - "@babel/helper-plugin-utils": "^7.18.6" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-proposal-private-property-in-object": { - "version": "7.21.0", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-private-property-in-object/-/plugin-proposal-private-property-in-object-7.21.0.tgz", - "integrity": "sha512-ha4zfehbJjc5MmXBlHec1igel5TJXXLDDRbuJ4+XT2TJcyD9/V1919BA8gMvsdHcNMBy4WBUBiRb3nw/EQUtBw==", - "dependencies": { - "@babel/helper-annotate-as-pure": "^7.18.6", - "@babel/helper-create-class-features-plugin": "^7.21.0", - "@babel/helper-plugin-utils": "^7.20.2", - "@babel/plugin-syntax-private-property-in-object": "^7.14.5" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-proposal-unicode-property-regex": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-unicode-property-regex/-/plugin-proposal-unicode-property-regex-7.18.6.tgz", - "integrity": "sha512-2BShG/d5yoZyXZfVePH91urL5wTG6ASZU9M4o03lKK8u8UW1y08OMttBSOADTcJrnPMpvDXRG3G8fyLh4ovs8w==", - "dependencies": { - "@babel/helper-create-regexp-features-plugin": "^7.18.6", - "@babel/helper-plugin-utils": "^7.18.6" - }, - "engines": { - "node": ">=4" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-syntax-async-generators": { - "version": "7.8.4", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-async-generators/-/plugin-syntax-async-generators-7.8.4.tgz", - "integrity": "sha512-tycmZxkGfZaxhMRbXlPXuVFpdWlXpir2W4AMhSJgRKzk/eDlIXOhb2LHWoLpDF7TEHylV5zNhykX6KAgHJmTNw==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.8.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-syntax-bigint": { - "version": "7.8.3", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-bigint/-/plugin-syntax-bigint-7.8.3.tgz", - "integrity": "sha512-wnTnFlG+YxQm3vDxpGE57Pj0srRU4sHE/mDkt1qv2YJJSeUAec2ma4WLUnUPeKjyrfntVwe/N6dCXpU+zL3Npg==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.8.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-syntax-class-properties": { - "version": "7.12.13", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-class-properties/-/plugin-syntax-class-properties-7.12.13.tgz", - "integrity": "sha512-fm4idjKla0YahUNgFNLCB0qySdsoPiZP3iQE3rky0mBUtMZ23yDJ9SJdg6dXTSDnulOVqiF3Hgr9nbXvXTQZYA==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.12.13" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-syntax-class-static-block": { - "version": "7.14.5", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-class-static-block/-/plugin-syntax-class-static-block-7.14.5.tgz", - "integrity": "sha512-b+YyPmr6ldyNnM6sqYeMWE+bgJcJpO6yS4QD7ymxgH34GBPNDM/THBh8iunyvKIZztiwLH4CJZ0RxTk9emgpjw==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.14.5" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-syntax-decorators": { - "version": "7.21.0", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-decorators/-/plugin-syntax-decorators-7.21.0.tgz", - "integrity": "sha512-tIoPpGBR8UuM4++ccWN3gifhVvQu7ZizuR1fklhRJrd5ewgbkUS+0KVFeWWxELtn18NTLoW32XV7zyOgIAiz+w==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.20.2" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-syntax-dynamic-import": { - "version": "7.8.3", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-dynamic-import/-/plugin-syntax-dynamic-import-7.8.3.tgz", - "integrity": "sha512-5gdGbFon+PszYzqs83S3E5mpi7/y/8M9eC90MRTZfduQOYW76ig6SOSPNe41IG5LoP3FGBn2N0RjVDSQiS94kQ==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.8.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-syntax-export-namespace-from": { - "version": "7.8.3", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-export-namespace-from/-/plugin-syntax-export-namespace-from-7.8.3.tgz", - "integrity": "sha512-MXf5laXo6c1IbEbegDmzGPwGNTsHZmEy6QGznu5Sh2UCWvueywb2ee+CCE4zQiZstxU9BMoQO9i6zUFSY0Kj0Q==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.8.3" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-syntax-flow": { - "version": "7.21.4", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-flow/-/plugin-syntax-flow-7.21.4.tgz", - "integrity": "sha512-l9xd3N+XG4fZRxEP3vXdK6RW7vN1Uf5dxzRC/09wV86wqZ/YYQooBIGNsiRdfNR3/q2/5pPzV4B54J/9ctX5jw==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.20.2" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-syntax-import-assertions": { - "version": "7.20.0", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-import-assertions/-/plugin-syntax-import-assertions-7.20.0.tgz", - "integrity": "sha512-IUh1vakzNoWalR8ch/areW7qFopR2AEw03JlG7BbrDqmQ4X3q9uuipQwSGrUn7oGiemKjtSLDhNtQHzMHr1JdQ==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.19.0" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-syntax-import-meta": { - "version": "7.10.4", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-import-meta/-/plugin-syntax-import-meta-7.10.4.tgz", - "integrity": "sha512-Yqfm+XDx0+Prh3VSeEQCPU81yC+JWZ2pDPFSS4ZdpfZhp4MkFMaDC1UqseovEKwSUpnIL7+vK+Clp7bfh0iD7g==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.10.4" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-syntax-json-strings": { - "version": "7.8.3", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-json-strings/-/plugin-syntax-json-strings-7.8.3.tgz", - "integrity": "sha512-lY6kdGpWHvjoe2vk4WrAapEuBR69EMxZl+RoGRhrFGNYVK8mOPAW8VfbT/ZgrFbXlDNiiaxQnAtgVCZ6jv30EA==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.8.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-syntax-jsx": { - "version": "7.21.4", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-jsx/-/plugin-syntax-jsx-7.21.4.tgz", - "integrity": "sha512-5hewiLct5OKyh6PLKEYaFclcqtIgCb6bmELouxjF6up5q3Sov7rOayW4RwhbaBL0dit8rA80GNfY+UuDp2mBbQ==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.20.2" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-syntax-logical-assignment-operators": { - "version": "7.10.4", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-logical-assignment-operators/-/plugin-syntax-logical-assignment-operators-7.10.4.tgz", - "integrity": "sha512-d8waShlpFDinQ5MtvGU9xDAOzKH47+FFoney2baFIoMr952hKOLp1HR7VszoZvOsV/4+RRszNY7D17ba0te0ig==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.10.4" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-syntax-nullish-coalescing-operator": { - "version": "7.8.3", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-nullish-coalescing-operator/-/plugin-syntax-nullish-coalescing-operator-7.8.3.tgz", - "integrity": "sha512-aSff4zPII1u2QD7y+F8oDsz19ew4IGEJg9SVW+bqwpwtfFleiQDMdzA/R+UlWDzfnHFCxxleFT0PMIrR36XLNQ==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.8.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-syntax-numeric-separator": { - "version": "7.10.4", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-numeric-separator/-/plugin-syntax-numeric-separator-7.10.4.tgz", - "integrity": "sha512-9H6YdfkcK/uOnY/K7/aA2xpzaAgkQn37yzWUMRK7OaPOqOpGS1+n0H5hxT9AUw9EsSjPW8SVyMJwYRtWs3X3ug==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.10.4" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-syntax-object-rest-spread": { - "version": "7.8.3", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-object-rest-spread/-/plugin-syntax-object-rest-spread-7.8.3.tgz", - "integrity": "sha512-XoqMijGZb9y3y2XskN+P1wUGiVwWZ5JmoDRwx5+3GmEplNyVM2s2Dg8ILFQm8rWM48orGy5YpI5Bl8U1y7ydlA==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.8.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-syntax-optional-catch-binding": { - "version": "7.8.3", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-optional-catch-binding/-/plugin-syntax-optional-catch-binding-7.8.3.tgz", - "integrity": "sha512-6VPD0Pc1lpTqw0aKoeRTMiB+kWhAoT24PA+ksWSBrFtl5SIRVpZlwN3NNPQjehA2E/91FV3RjLWoVTglWcSV3Q==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.8.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-syntax-optional-chaining": { - "version": "7.8.3", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-optional-chaining/-/plugin-syntax-optional-chaining-7.8.3.tgz", - "integrity": "sha512-KoK9ErH1MBlCPxV0VANkXW2/dw4vlbGDrFgz8bmUsBGYkFRcbRwMh6cIJubdPrkxRwuGdtCk0v/wPTKbQgBjkg==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.8.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-syntax-private-property-in-object": { - "version": "7.14.5", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-private-property-in-object/-/plugin-syntax-private-property-in-object-7.14.5.tgz", - "integrity": "sha512-0wVnp9dxJ72ZUJDV27ZfbSj6iHLoytYZmh3rFcxNnvsJF3ktkzLDZPy/mA17HGsaQT3/DQsWYX1f1QGWkCoVUg==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.14.5" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-syntax-top-level-await": { - "version": "7.14.5", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-top-level-await/-/plugin-syntax-top-level-await-7.14.5.tgz", - "integrity": "sha512-hx++upLv5U1rgYfwe1xBQUhRmU41NEvpUvrp8jkrSCdvGSnM5/qdRMtylJ6PG5OFkBaHkbTAKTnd3/YyESRHFw==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.14.5" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-syntax-typescript": { - "version": "7.21.4", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.21.4.tgz", - "integrity": "sha512-xz0D39NvhQn4t4RNsHmDnnsaQizIlUkdtYvLs8La1BlfjQ6JEwxkJGeqJMW2tAXx+q6H+WFuUTXNdYVpEya0YA==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.20.2" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-arrow-functions": { - "version": "7.21.5", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-arrow-functions/-/plugin-transform-arrow-functions-7.21.5.tgz", - "integrity": "sha512-wb1mhwGOCaXHDTcsRYMKF9e5bbMgqwxtqa2Y1ifH96dXJPwbuLX9qHy3clhrxVqgMz7nyNXs8VkxdH8UBcjKqA==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.21.5" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-async-to-generator": { - "version": "7.20.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-async-to-generator/-/plugin-transform-async-to-generator-7.20.7.tgz", - "integrity": "sha512-Uo5gwHPT9vgnSXQxqGtpdufUiWp96gk7yiP4Mp5bm1QMkEmLXBO7PAGYbKoJ6DhAwiNkcHFBol/x5zZZkL/t0Q==", - "dependencies": { - "@babel/helper-module-imports": "^7.18.6", - "@babel/helper-plugin-utils": "^7.20.2", - "@babel/helper-remap-async-to-generator": "^7.18.9" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-block-scoped-functions": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-block-scoped-functions/-/plugin-transform-block-scoped-functions-7.18.6.tgz", - "integrity": "sha512-ExUcOqpPWnliRcPqves5HJcJOvHvIIWfuS4sroBUenPuMdmW+SMHDakmtS7qOo13sVppmUijqeTv7qqGsvURpQ==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.18.6" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-block-scoping": { - "version": "7.21.0", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-block-scoping/-/plugin-transform-block-scoping-7.21.0.tgz", - "integrity": "sha512-Mdrbunoh9SxwFZapeHVrwFmri16+oYotcZysSzhNIVDwIAb1UV+kvnxULSYq9J3/q5MDG+4X6w8QVgD1zhBXNQ==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.20.2" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-classes": { - "version": "7.21.0", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-classes/-/plugin-transform-classes-7.21.0.tgz", - "integrity": "sha512-RZhbYTCEUAe6ntPehC4hlslPWosNHDox+vAs4On/mCLRLfoDVHf6hVEd7kuxr1RnHwJmxFfUM3cZiZRmPxJPXQ==", - "dependencies": { - "@babel/helper-annotate-as-pure": "^7.18.6", - "@babel/helper-compilation-targets": "^7.20.7", - "@babel/helper-environment-visitor": "^7.18.9", - "@babel/helper-function-name": "^7.21.0", - "@babel/helper-optimise-call-expression": "^7.18.6", - "@babel/helper-plugin-utils": "^7.20.2", - "@babel/helper-replace-supers": "^7.20.7", - "@babel/helper-split-export-declaration": "^7.18.6", - "globals": "^11.1.0" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-computed-properties": { - "version": "7.21.5", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-computed-properties/-/plugin-transform-computed-properties-7.21.5.tgz", - "integrity": "sha512-TR653Ki3pAwxBxUe8srfF3e4Pe3FTA46uaNHYyQwIoM4oWKSoOZiDNyHJ0oIoDIUPSRQbQG7jzgVBX3FPVne1Q==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.21.5", - "@babel/template": "^7.20.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-destructuring": { - "version": "7.21.3", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-destructuring/-/plugin-transform-destructuring-7.21.3.tgz", - "integrity": "sha512-bp6hwMFzuiE4HqYEyoGJ/V2LeIWn+hLVKc4pnj++E5XQptwhtcGmSayM029d/j2X1bPKGTlsyPwAubuU22KhMA==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.20.2" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-dotall-regex": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-dotall-regex/-/plugin-transform-dotall-regex-7.18.6.tgz", - "integrity": "sha512-6S3jpun1eEbAxq7TdjLotAsl4WpQI9DxfkycRcKrjhQYzU87qpXdknpBg/e+TdcMehqGnLFi7tnFUBR02Vq6wg==", - "dependencies": { - "@babel/helper-create-regexp-features-plugin": "^7.18.6", - "@babel/helper-plugin-utils": "^7.18.6" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-duplicate-keys": { - "version": "7.18.9", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-duplicate-keys/-/plugin-transform-duplicate-keys-7.18.9.tgz", - "integrity": "sha512-d2bmXCtZXYc59/0SanQKbiWINadaJXqtvIQIzd4+hNwkWBgyCd5F/2t1kXoUdvPMrxzPvhK6EMQRROxsue+mfw==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.18.9" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-exponentiation-operator": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-exponentiation-operator/-/plugin-transform-exponentiation-operator-7.18.6.tgz", - "integrity": "sha512-wzEtc0+2c88FVR34aQmiz56dxEkxr2g8DQb/KfaFa1JYXOFVsbhvAonFN6PwVWj++fKmku8NP80plJ5Et4wqHw==", - "dependencies": { - "@babel/helper-builder-binary-assignment-operator-visitor": "^7.18.6", - "@babel/helper-plugin-utils": "^7.18.6" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-flow-strip-types": { - "version": "7.21.0", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-flow-strip-types/-/plugin-transform-flow-strip-types-7.21.0.tgz", - "integrity": "sha512-FlFA2Mj87a6sDkW4gfGrQQqwY/dLlBAyJa2dJEZ+FHXUVHBflO2wyKvg+OOEzXfrKYIa4HWl0mgmbCzt0cMb7w==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.20.2", - "@babel/plugin-syntax-flow": "^7.18.6" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-for-of": { - "version": "7.21.5", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-for-of/-/plugin-transform-for-of-7.21.5.tgz", - "integrity": "sha512-nYWpjKW/7j/I/mZkGVgHJXh4bA1sfdFnJoOXwJuj4m3Q2EraO/8ZyrkCau9P5tbHQk01RMSt6KYLCsW7730SXQ==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.21.5" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-function-name": { - "version": "7.18.9", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-function-name/-/plugin-transform-function-name-7.18.9.tgz", - "integrity": "sha512-WvIBoRPaJQ5yVHzcnJFor7oS5Ls0PYixlTYE63lCj2RtdQEl15M68FXQlxnG6wdraJIXRdR7KI+hQ7q/9QjrCQ==", - "dependencies": { - "@babel/helper-compilation-targets": "^7.18.9", - "@babel/helper-function-name": "^7.18.9", - "@babel/helper-plugin-utils": "^7.18.9" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-literals": { - "version": "7.18.9", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-literals/-/plugin-transform-literals-7.18.9.tgz", - "integrity": "sha512-IFQDSRoTPnrAIrI5zoZv73IFeZu2dhu6irxQjY9rNjTT53VmKg9fenjvoiOWOkJ6mm4jKVPtdMzBY98Fp4Z4cg==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.18.9" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-member-expression-literals": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-member-expression-literals/-/plugin-transform-member-expression-literals-7.18.6.tgz", - "integrity": "sha512-qSF1ihLGO3q+/g48k85tUjD033C29TNTVB2paCwZPVmOsjn9pClvYYrM2VeJpBY2bcNkuny0YUyTNRyRxJ54KA==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.18.6" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-modules-amd": { - "version": "7.20.11", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-amd/-/plugin-transform-modules-amd-7.20.11.tgz", - "integrity": "sha512-NuzCt5IIYOW0O30UvqktzHYR2ud5bOWbY0yaxWZ6G+aFzOMJvrs5YHNikrbdaT15+KNO31nPOy5Fim3ku6Zb5g==", - "dependencies": { - "@babel/helper-module-transforms": "^7.20.11", - "@babel/helper-plugin-utils": "^7.20.2" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-modules-commonjs": { - "version": "7.21.5", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.21.5.tgz", - "integrity": "sha512-OVryBEgKUbtqMoB7eG2rs6UFexJi6Zj6FDXx+esBLPTCxCNxAY9o+8Di7IsUGJ+AVhp5ncK0fxWUBd0/1gPhrQ==", - "dependencies": { - "@babel/helper-module-transforms": "^7.21.5", - "@babel/helper-plugin-utils": "^7.21.5", - "@babel/helper-simple-access": "^7.21.5" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-modules-systemjs": { - "version": "7.20.11", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-systemjs/-/plugin-transform-modules-systemjs-7.20.11.tgz", - "integrity": "sha512-vVu5g9BPQKSFEmvt2TA4Da5N+QVS66EX21d8uoOihC+OCpUoGvzVsXeqFdtAEfVa5BILAeFt+U7yVmLbQnAJmw==", - "dependencies": { - "@babel/helper-hoist-variables": "^7.18.6", - "@babel/helper-module-transforms": "^7.20.11", - "@babel/helper-plugin-utils": "^7.20.2", - "@babel/helper-validator-identifier": "^7.19.1" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-modules-umd": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-umd/-/plugin-transform-modules-umd-7.18.6.tgz", - "integrity": "sha512-dcegErExVeXcRqNtkRU/z8WlBLnvD4MRnHgNs3MytRO1Mn1sHRyhbcpYbVMGclAqOjdW+9cfkdZno9dFdfKLfQ==", - "dependencies": { - "@babel/helper-module-transforms": "^7.18.6", - "@babel/helper-plugin-utils": "^7.18.6" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-named-capturing-groups-regex": { - "version": "7.20.5", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-named-capturing-groups-regex/-/plugin-transform-named-capturing-groups-regex-7.20.5.tgz", - "integrity": "sha512-mOW4tTzi5iTLnw+78iEq3gr8Aoq4WNRGpmSlrogqaiCBoR1HFhpU4JkpQFOHfeYx3ReVIFWOQJS4aZBRvuZ6mA==", - "dependencies": { - "@babel/helper-create-regexp-features-plugin": "^7.20.5", - "@babel/helper-plugin-utils": "^7.20.2" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0" - } - }, - "node_modules/@babel/plugin-transform-new-target": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-new-target/-/plugin-transform-new-target-7.18.6.tgz", - "integrity": "sha512-DjwFA/9Iu3Z+vrAn+8pBUGcjhxKguSMlsFqeCKbhb9BAV756v0krzVK04CRDi/4aqmk8BsHb4a/gFcaA5joXRw==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.18.6" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-object-super": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-object-super/-/plugin-transform-object-super-7.18.6.tgz", - "integrity": "sha512-uvGz6zk+pZoS1aTZrOvrbj6Pp/kK2mp45t2B+bTDre2UgsZZ8EZLSJtUg7m/no0zOJUWgFONpB7Zv9W2tSaFlA==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.18.6", - "@babel/helper-replace-supers": "^7.18.6" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-parameters": { - "version": "7.21.3", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-parameters/-/plugin-transform-parameters-7.21.3.tgz", - "integrity": "sha512-Wxc+TvppQG9xWFYatvCGPvZ6+SIUxQ2ZdiBP+PHYMIjnPXD+uThCshaz4NZOnODAtBjjcVQQ/3OKs9LW28purQ==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.20.2" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-property-literals": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-property-literals/-/plugin-transform-property-literals-7.18.6.tgz", - "integrity": "sha512-cYcs6qlgafTud3PAzrrRNbQtfpQ8+y/+M5tKmksS9+M1ckbH6kzY8MrexEM9mcA6JDsukE19iIRvAyYl463sMg==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.18.6" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-react-constant-elements": { - "version": "7.21.3", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-react-constant-elements/-/plugin-transform-react-constant-elements-7.21.3.tgz", - "integrity": "sha512-4DVcFeWe/yDYBLp0kBmOGFJ6N2UYg7coGid1gdxb4co62dy/xISDMaYBXBVXEDhfgMk7qkbcYiGtwd5Q/hwDDQ==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.20.2" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-react-display-name": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-react-display-name/-/plugin-transform-react-display-name-7.18.6.tgz", - "integrity": "sha512-TV4sQ+T013n61uMoygyMRm+xf04Bd5oqFpv2jAEQwSZ8NwQA7zeRPg1LMVg2PWi3zWBz+CLKD+v5bcpZ/BS0aA==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.18.6" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-react-jsx": { - "version": "7.21.5", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-react-jsx/-/plugin-transform-react-jsx-7.21.5.tgz", - "integrity": "sha512-ELdlq61FpoEkHO6gFRpfj0kUgSwQTGoaEU8eMRoS8Dv3v6e7BjEAj5WMtIBRdHUeAioMhKP5HyxNzNnP+heKbA==", - "dependencies": { - "@babel/helper-annotate-as-pure": "^7.18.6", - "@babel/helper-module-imports": "^7.21.4", - "@babel/helper-plugin-utils": "^7.21.5", - "@babel/plugin-syntax-jsx": "^7.21.4", - "@babel/types": "^7.21.5" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-react-jsx-development": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-react-jsx-development/-/plugin-transform-react-jsx-development-7.18.6.tgz", - "integrity": "sha512-SA6HEjwYFKF7WDjWcMcMGUimmw/nhNRDWxr+KaLSCrkD/LMDBvWRmHAYgE1HDeF8KUuI8OAu+RT6EOtKxSW2qA==", - "dependencies": { - "@babel/plugin-transform-react-jsx": "^7.18.6" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-react-pure-annotations": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-react-pure-annotations/-/plugin-transform-react-pure-annotations-7.18.6.tgz", - "integrity": "sha512-I8VfEPg9r2TRDdvnHgPepTKvuRomzA8+u+nhY7qSI1fR2hRNebasZEETLyM5mAUr0Ku56OkXJ0I7NHJnO6cJiQ==", - "dependencies": { - "@babel/helper-annotate-as-pure": "^7.18.6", - "@babel/helper-plugin-utils": "^7.18.6" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-regenerator": { - "version": "7.21.5", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-regenerator/-/plugin-transform-regenerator-7.21.5.tgz", - "integrity": "sha512-ZoYBKDb6LyMi5yCsByQ5jmXsHAQDDYeexT1Szvlmui+lADvfSecr5Dxd/PkrTC3pAD182Fcju1VQkB4oCp9M+w==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.21.5", - "regenerator-transform": "^0.15.1" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-reserved-words": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-reserved-words/-/plugin-transform-reserved-words-7.18.6.tgz", - "integrity": "sha512-oX/4MyMoypzHjFrT1CdivfKZ+XvIPMFXwwxHp/r0Ddy2Vuomt4HDFGmft1TAY2yiTKiNSsh3kjBAzcM8kSdsjA==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.18.6" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-runtime": { - "version": "7.21.4", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-runtime/-/plugin-transform-runtime-7.21.4.tgz", - "integrity": "sha512-1J4dhrw1h1PqnNNpzwxQ2UBymJUF8KuPjAAnlLwZcGhHAIqUigFW7cdK6GHoB64ubY4qXQNYknoUeks4Wz7CUA==", - "dependencies": { - "@babel/helper-module-imports": "^7.21.4", - "@babel/helper-plugin-utils": "^7.20.2", - "babel-plugin-polyfill-corejs2": "^0.3.3", - "babel-plugin-polyfill-corejs3": "^0.6.0", - "babel-plugin-polyfill-regenerator": "^0.4.1", - "semver": "^6.3.0" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-runtime/node_modules/semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", - "bin": { - "semver": "bin/semver.js" - } - }, - "node_modules/@babel/plugin-transform-shorthand-properties": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-shorthand-properties/-/plugin-transform-shorthand-properties-7.18.6.tgz", - "integrity": "sha512-eCLXXJqv8okzg86ywZJbRn19YJHU4XUa55oz2wbHhaQVn/MM+XhukiT7SYqp/7o00dg52Rj51Ny+Ecw4oyoygw==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.18.6" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-spread": { - "version": "7.20.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-spread/-/plugin-transform-spread-7.20.7.tgz", - "integrity": "sha512-ewBbHQ+1U/VnH1fxltbJqDeWBU1oNLG8Dj11uIv3xVf7nrQu0bPGe5Rf716r7K5Qz+SqtAOVswoVunoiBtGhxw==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.20.2", - "@babel/helper-skip-transparent-expression-wrappers": "^7.20.0" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-sticky-regex": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-sticky-regex/-/plugin-transform-sticky-regex-7.18.6.tgz", - "integrity": "sha512-kfiDrDQ+PBsQDO85yj1icueWMfGfJFKN1KCkndygtu/C9+XUfydLC8Iv5UYJqRwy4zk8EcplRxEOeLyjq1gm6Q==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.18.6" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-template-literals": { - "version": "7.18.9", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-template-literals/-/plugin-transform-template-literals-7.18.9.tgz", - "integrity": "sha512-S8cOWfT82gTezpYOiVaGHrCbhlHgKhQt8XH5ES46P2XWmX92yisoZywf5km75wv5sYcXDUCLMmMxOLCtthDgMA==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.18.9" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-typeof-symbol": { - "version": "7.18.9", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-typeof-symbol/-/plugin-transform-typeof-symbol-7.18.9.tgz", - "integrity": "sha512-SRfwTtF11G2aemAZWivL7PD+C9z52v9EvMqH9BuYbabyPuKUvSWks3oCg6041pT925L4zVFqaVBeECwsmlguEw==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.18.9" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-typescript": { - "version": "7.21.3", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-typescript/-/plugin-transform-typescript-7.21.3.tgz", - "integrity": "sha512-RQxPz6Iqt8T0uw/WsJNReuBpWpBqs/n7mNo18sKLoTbMp+UrEekhH+pKSVC7gWz+DNjo9gryfV8YzCiT45RgMw==", - "dependencies": { - "@babel/helper-annotate-as-pure": "^7.18.6", - "@babel/helper-create-class-features-plugin": "^7.21.0", - "@babel/helper-plugin-utils": "^7.20.2", - "@babel/plugin-syntax-typescript": "^7.20.0" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-unicode-escapes": { - "version": "7.21.5", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-unicode-escapes/-/plugin-transform-unicode-escapes-7.21.5.tgz", - "integrity": "sha512-LYm/gTOwZqsYohlvFUe/8Tujz75LqqVC2w+2qPHLR+WyWHGCZPN1KBpJCJn+4Bk4gOkQy/IXKIge6az5MqwlOg==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.21.5" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-unicode-regex": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-unicode-regex/-/plugin-transform-unicode-regex-7.18.6.tgz", - "integrity": "sha512-gE7A6Lt7YLnNOL3Pb9BNeZvi+d8l7tcRrG4+pwJjK9hD2xX4mEvjlQW60G9EEmfXVYRPv9VRQcyegIVHCql/AA==", - "dependencies": { - "@babel/helper-create-regexp-features-plugin": "^7.18.6", - "@babel/helper-plugin-utils": "^7.18.6" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/preset-env": { - "version": "7.21.5", - "resolved": "https://registry.npmjs.org/@babel/preset-env/-/preset-env-7.21.5.tgz", - "integrity": "sha512-wH00QnTTldTbf/IefEVyChtRdw5RJvODT/Vb4Vcxq1AZvtXj6T0YeX0cAcXhI6/BdGuiP3GcNIL4OQbI2DVNxg==", - "dependencies": { - "@babel/compat-data": "^7.21.5", - "@babel/helper-compilation-targets": "^7.21.5", - "@babel/helper-plugin-utils": "^7.21.5", - "@babel/helper-validator-option": "^7.21.0", - "@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression": "^7.18.6", - "@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining": "^7.20.7", - "@babel/plugin-proposal-async-generator-functions": "^7.20.7", - "@babel/plugin-proposal-class-properties": "^7.18.6", - "@babel/plugin-proposal-class-static-block": "^7.21.0", - "@babel/plugin-proposal-dynamic-import": "^7.18.6", - "@babel/plugin-proposal-export-namespace-from": "^7.18.9", - "@babel/plugin-proposal-json-strings": "^7.18.6", - "@babel/plugin-proposal-logical-assignment-operators": "^7.20.7", - "@babel/plugin-proposal-nullish-coalescing-operator": "^7.18.6", - "@babel/plugin-proposal-numeric-separator": "^7.18.6", - "@babel/plugin-proposal-object-rest-spread": "^7.20.7", - "@babel/plugin-proposal-optional-catch-binding": "^7.18.6", - "@babel/plugin-proposal-optional-chaining": "^7.21.0", - "@babel/plugin-proposal-private-methods": "^7.18.6", - "@babel/plugin-proposal-private-property-in-object": "^7.21.0", - "@babel/plugin-proposal-unicode-property-regex": "^7.18.6", - "@babel/plugin-syntax-async-generators": "^7.8.4", - "@babel/plugin-syntax-class-properties": "^7.12.13", - "@babel/plugin-syntax-class-static-block": "^7.14.5", - "@babel/plugin-syntax-dynamic-import": "^7.8.3", - "@babel/plugin-syntax-export-namespace-from": "^7.8.3", - "@babel/plugin-syntax-import-assertions": "^7.20.0", - "@babel/plugin-syntax-import-meta": "^7.10.4", - "@babel/plugin-syntax-json-strings": "^7.8.3", - "@babel/plugin-syntax-logical-assignment-operators": "^7.10.4", - "@babel/plugin-syntax-nullish-coalescing-operator": "^7.8.3", - "@babel/plugin-syntax-numeric-separator": "^7.10.4", - "@babel/plugin-syntax-object-rest-spread": "^7.8.3", - "@babel/plugin-syntax-optional-catch-binding": "^7.8.3", - "@babel/plugin-syntax-optional-chaining": "^7.8.3", - "@babel/plugin-syntax-private-property-in-object": "^7.14.5", - "@babel/plugin-syntax-top-level-await": "^7.14.5", - "@babel/plugin-transform-arrow-functions": "^7.21.5", - "@babel/plugin-transform-async-to-generator": "^7.20.7", - "@babel/plugin-transform-block-scoped-functions": "^7.18.6", - "@babel/plugin-transform-block-scoping": "^7.21.0", - "@babel/plugin-transform-classes": "^7.21.0", - "@babel/plugin-transform-computed-properties": "^7.21.5", - "@babel/plugin-transform-destructuring": "^7.21.3", - "@babel/plugin-transform-dotall-regex": "^7.18.6", - "@babel/plugin-transform-duplicate-keys": "^7.18.9", - "@babel/plugin-transform-exponentiation-operator": "^7.18.6", - "@babel/plugin-transform-for-of": "^7.21.5", - "@babel/plugin-transform-function-name": "^7.18.9", - "@babel/plugin-transform-literals": "^7.18.9", - "@babel/plugin-transform-member-expression-literals": "^7.18.6", - "@babel/plugin-transform-modules-amd": "^7.20.11", - "@babel/plugin-transform-modules-commonjs": "^7.21.5", - "@babel/plugin-transform-modules-systemjs": "^7.20.11", - "@babel/plugin-transform-modules-umd": "^7.18.6", - "@babel/plugin-transform-named-capturing-groups-regex": "^7.20.5", - "@babel/plugin-transform-new-target": "^7.18.6", - "@babel/plugin-transform-object-super": "^7.18.6", - "@babel/plugin-transform-parameters": "^7.21.3", - "@babel/plugin-transform-property-literals": "^7.18.6", - "@babel/plugin-transform-regenerator": "^7.21.5", - "@babel/plugin-transform-reserved-words": "^7.18.6", - "@babel/plugin-transform-shorthand-properties": "^7.18.6", - "@babel/plugin-transform-spread": "^7.20.7", - "@babel/plugin-transform-sticky-regex": "^7.18.6", - "@babel/plugin-transform-template-literals": "^7.18.9", - "@babel/plugin-transform-typeof-symbol": "^7.18.9", - "@babel/plugin-transform-unicode-escapes": "^7.21.5", - "@babel/plugin-transform-unicode-regex": "^7.18.6", - "@babel/preset-modules": "^0.1.5", - "@babel/types": "^7.21.5", - "babel-plugin-polyfill-corejs2": "^0.3.3", - "babel-plugin-polyfill-corejs3": "^0.6.0", - "babel-plugin-polyfill-regenerator": "^0.4.1", - "core-js-compat": "^3.25.1", - "semver": "^6.3.0" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/preset-env/node_modules/semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", - "bin": { - "semver": "bin/semver.js" - } - }, - "node_modules/@babel/preset-modules": { - "version": "0.1.5", - "resolved": "https://registry.npmjs.org/@babel/preset-modules/-/preset-modules-0.1.5.tgz", - "integrity": "sha512-A57th6YRG7oR3cq/yt/Y84MvGgE0eJG2F1JLhKuyG+jFxEgrd/HAMJatiFtmOiZurz+0DkrvbheCLaV5f2JfjA==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.0.0", - "@babel/plugin-proposal-unicode-property-regex": "^7.4.4", - "@babel/plugin-transform-dotall-regex": "^7.4.4", - "@babel/types": "^7.4.4", - "esutils": "^2.0.2" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/preset-react": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/preset-react/-/preset-react-7.18.6.tgz", - "integrity": "sha512-zXr6atUmyYdiWRVLOZahakYmOBHtWc2WGCkP8PYTgZi0iJXDY2CN180TdrIW4OGOAdLc7TifzDIvtx6izaRIzg==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.18.6", - "@babel/helper-validator-option": "^7.18.6", - "@babel/plugin-transform-react-display-name": "^7.18.6", - "@babel/plugin-transform-react-jsx": "^7.18.6", - "@babel/plugin-transform-react-jsx-development": "^7.18.6", - "@babel/plugin-transform-react-pure-annotations": "^7.18.6" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/preset-typescript": { - "version": "7.21.5", - "resolved": "https://registry.npmjs.org/@babel/preset-typescript/-/preset-typescript-7.21.5.tgz", - "integrity": "sha512-iqe3sETat5EOrORXiQ6rWfoOg2y68Cs75B9wNxdPW4kixJxh7aXQE1KPdWLDniC24T/6dSnguF33W9j/ZZQcmA==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.21.5", - "@babel/helper-validator-option": "^7.21.0", - "@babel/plugin-syntax-jsx": "^7.21.4", - "@babel/plugin-transform-modules-commonjs": "^7.21.5", - "@babel/plugin-transform-typescript": "^7.21.3" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/regjsgen": { - "version": "0.8.0", - "resolved": "https://registry.npmjs.org/@babel/regjsgen/-/regjsgen-0.8.0.tgz", - "integrity": "sha512-x/rqGMdzj+fWZvCOYForTghzbtqPDZ5gPwaoNGHdgDfF2QA/XZbCBp4Moo5scrkAMPhB7z26XM/AaHuIJdgauA==" - }, - "node_modules/@babel/runtime": { - "version": "7.21.5", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.21.5.tgz", - "integrity": "sha512-8jI69toZqqcsnqGGqwGS4Qb1VwLOEp4hz+CXPywcvjs60u3B4Pom/U/7rm4W8tMOYEB+E9wgD0mW1l3r8qlI9Q==", - "dependencies": { - "regenerator-runtime": "^0.13.11" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/template": { - "version": "7.21.9", - "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.21.9.tgz", - "integrity": "sha512-MK0X5k8NKOuWRamiEfc3KEJiHMTkGZNUjzMipqCGDDc6ijRl/B7RGSKVGncu4Ro/HdyzzY6cmoXuKI2Gffk7vQ==", - "dependencies": { - "@babel/code-frame": "^7.21.4", - "@babel/parser": "^7.21.9", - "@babel/types": "^7.21.5" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/traverse": { - "version": "7.21.5", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.21.5.tgz", - "integrity": "sha512-AhQoI3YjWi6u/y/ntv7k48mcrCXmus0t79J9qPNlk/lAsFlCiJ047RmbfMOawySTHtywXhbXgpx/8nXMYd+oFw==", - "dependencies": { - "@babel/code-frame": "^7.21.4", - "@babel/generator": "^7.21.5", - "@babel/helper-environment-visitor": "^7.21.5", - "@babel/helper-function-name": "^7.21.0", - "@babel/helper-hoist-variables": "^7.18.6", - "@babel/helper-split-export-declaration": "^7.18.6", - "@babel/parser": "^7.21.5", - "@babel/types": "^7.21.5", - "debug": "^4.1.0", - "globals": "^11.1.0" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/types": { - "version": "7.21.5", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.21.5.tgz", - "integrity": "sha512-m4AfNvVF2mVC/F7fDEdH2El3HzUg9It/XsCxZiOTTA3m3qYfcSVSbTfM6Q9xG+hYDniZssYhlXKKUMD5m8tF4Q==", - "dependencies": { - "@babel/helper-string-parser": "^7.21.5", - "@babel/helper-validator-identifier": "^7.19.1", - "to-fast-properties": "^2.0.0" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@bcoe/v8-coverage": { - "version": "0.2.3", - "resolved": "https://registry.npmjs.org/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz", - "integrity": "sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==" - }, - "node_modules/@csstools/normalize.css": { - "version": "12.0.0", - "resolved": "https://registry.npmjs.org/@csstools/normalize.css/-/normalize.css-12.0.0.tgz", - "integrity": "sha512-M0qqxAcwCsIVfpFQSlGN5XjXWu8l5JDZN+fPt1LeW5SZexQTgnaEvgXAY+CeygRw0EeppWHi12JxESWiWrB0Sg==" - }, - "node_modules/@csstools/postcss-cascade-layers": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/@csstools/postcss-cascade-layers/-/postcss-cascade-layers-1.1.1.tgz", - "integrity": "sha512-+KdYrpKC5TgomQr2DlZF4lDEpHcoxnj5IGddYYfBWJAKfj1JtuHUIqMa+E1pJJ+z3kvDViWMqyqPlG4Ja7amQA==", - "dependencies": { - "@csstools/selector-specificity": "^2.0.2", - "postcss-selector-parser": "^6.0.10" - }, - "engines": { - "node": "^12 || ^14 || >=16" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/csstools" - }, - "peerDependencies": { - "postcss": "^8.2" - } - }, - "node_modules/@csstools/postcss-color-function": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/@csstools/postcss-color-function/-/postcss-color-function-1.1.1.tgz", - "integrity": "sha512-Bc0f62WmHdtRDjf5f3e2STwRAl89N2CLb+9iAwzrv4L2hncrbDwnQD9PCq0gtAt7pOI2leIV08HIBUd4jxD8cw==", - "dependencies": { - "@csstools/postcss-progressive-custom-properties": "^1.1.0", - "postcss-value-parser": "^4.2.0" - }, - "engines": { - "node": "^12 || ^14 || >=16" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/csstools" - }, - "peerDependencies": { - "postcss": "^8.2" - } - }, - "node_modules/@csstools/postcss-font-format-keywords": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@csstools/postcss-font-format-keywords/-/postcss-font-format-keywords-1.0.1.tgz", - "integrity": "sha512-ZgrlzuUAjXIOc2JueK0X5sZDjCtgimVp/O5CEqTcs5ShWBa6smhWYbS0x5cVc/+rycTDbjjzoP0KTDnUneZGOg==", - "dependencies": { - "postcss-value-parser": "^4.2.0" - }, - "engines": { - "node": "^12 || ^14 || >=16" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/csstools" - }, - "peerDependencies": { - "postcss": "^8.2" - } - }, - "node_modules/@csstools/postcss-hwb-function": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/@csstools/postcss-hwb-function/-/postcss-hwb-function-1.0.2.tgz", - "integrity": "sha512-YHdEru4o3Rsbjmu6vHy4UKOXZD+Rn2zmkAmLRfPet6+Jz4Ojw8cbWxe1n42VaXQhD3CQUXXTooIy8OkVbUcL+w==", - "dependencies": { - "postcss-value-parser": "^4.2.0" - }, - "engines": { - "node": "^12 || ^14 || >=16" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/csstools" - }, - "peerDependencies": { - "postcss": "^8.2" - } - }, - "node_modules/@csstools/postcss-ic-unit": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@csstools/postcss-ic-unit/-/postcss-ic-unit-1.0.1.tgz", - "integrity": "sha512-Ot1rcwRAaRHNKC9tAqoqNZhjdYBzKk1POgWfhN4uCOE47ebGcLRqXjKkApVDpjifL6u2/55ekkpnFcp+s/OZUw==", - "dependencies": { - "@csstools/postcss-progressive-custom-properties": "^1.1.0", - "postcss-value-parser": "^4.2.0" - }, - "engines": { - "node": "^12 || ^14 || >=16" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/csstools" - }, - "peerDependencies": { - "postcss": "^8.2" - } - }, - "node_modules/@csstools/postcss-is-pseudo-class": { - "version": "2.0.7", - "resolved": "https://registry.npmjs.org/@csstools/postcss-is-pseudo-class/-/postcss-is-pseudo-class-2.0.7.tgz", - "integrity": "sha512-7JPeVVZHd+jxYdULl87lvjgvWldYu+Bc62s9vD/ED6/QTGjy0jy0US/f6BG53sVMTBJ1lzKZFpYmofBN9eaRiA==", - "dependencies": { - "@csstools/selector-specificity": "^2.0.0", - "postcss-selector-parser": "^6.0.10" - }, - "engines": { - "node": "^12 || ^14 || >=16" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/csstools" - }, - "peerDependencies": { - "postcss": "^8.2" - } - }, - "node_modules/@csstools/postcss-nested-calc": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/@csstools/postcss-nested-calc/-/postcss-nested-calc-1.0.0.tgz", - "integrity": "sha512-JCsQsw1wjYwv1bJmgjKSoZNvf7R6+wuHDAbi5f/7MbFhl2d/+v+TvBTU4BJH3G1X1H87dHl0mh6TfYogbT/dJQ==", - "dependencies": { - "postcss-value-parser": "^4.2.0" - }, - "engines": { - "node": "^12 || ^14 || >=16" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/csstools" - }, - "peerDependencies": { - "postcss": "^8.2" - } - }, - "node_modules/@csstools/postcss-normalize-display-values": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@csstools/postcss-normalize-display-values/-/postcss-normalize-display-values-1.0.1.tgz", - "integrity": "sha512-jcOanIbv55OFKQ3sYeFD/T0Ti7AMXc9nM1hZWu8m/2722gOTxFg7xYu4RDLJLeZmPUVQlGzo4jhzvTUq3x4ZUw==", - "dependencies": { - "postcss-value-parser": "^4.2.0" - }, - "engines": { - "node": "^12 || ^14 || >=16" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/csstools" - }, - "peerDependencies": { - "postcss": "^8.2" - } - }, - "node_modules/@csstools/postcss-oklab-function": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/@csstools/postcss-oklab-function/-/postcss-oklab-function-1.1.1.tgz", - "integrity": "sha512-nJpJgsdA3dA9y5pgyb/UfEzE7W5Ka7u0CX0/HIMVBNWzWemdcTH3XwANECU6anWv/ao4vVNLTMxhiPNZsTK6iA==", - "dependencies": { - "@csstools/postcss-progressive-custom-properties": "^1.1.0", - "postcss-value-parser": "^4.2.0" - }, - "engines": { - "node": "^12 || ^14 || >=16" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/csstools" - }, - "peerDependencies": { - "postcss": "^8.2" - } - }, - "node_modules/@csstools/postcss-progressive-custom-properties": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/@csstools/postcss-progressive-custom-properties/-/postcss-progressive-custom-properties-1.3.0.tgz", - "integrity": "sha512-ASA9W1aIy5ygskZYuWams4BzafD12ULvSypmaLJT2jvQ8G0M3I8PRQhC0h7mG0Z3LI05+agZjqSR9+K9yaQQjA==", - "dependencies": { - "postcss-value-parser": "^4.2.0" - }, - "engines": { - "node": "^12 || ^14 || >=16" - }, - "peerDependencies": { - "postcss": "^8.3" - } - }, - "node_modules/@csstools/postcss-stepped-value-functions": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@csstools/postcss-stepped-value-functions/-/postcss-stepped-value-functions-1.0.1.tgz", - "integrity": "sha512-dz0LNoo3ijpTOQqEJLY8nyaapl6umbmDcgj4AD0lgVQ572b2eqA1iGZYTTWhrcrHztWDDRAX2DGYyw2VBjvCvQ==", - "dependencies": { - "postcss-value-parser": "^4.2.0" - }, - "engines": { - "node": "^12 || ^14 || >=16" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/csstools" - }, - "peerDependencies": { - "postcss": "^8.2" - } - }, - "node_modules/@csstools/postcss-text-decoration-shorthand": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/@csstools/postcss-text-decoration-shorthand/-/postcss-text-decoration-shorthand-1.0.0.tgz", - "integrity": "sha512-c1XwKJ2eMIWrzQenN0XbcfzckOLLJiczqy+YvfGmzoVXd7pT9FfObiSEfzs84bpE/VqfpEuAZ9tCRbZkZxxbdw==", - "dependencies": { - "postcss-value-parser": "^4.2.0" - }, - "engines": { - "node": "^12 || ^14 || >=16" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/csstools" - }, - "peerDependencies": { - "postcss": "^8.2" - } - }, - "node_modules/@csstools/postcss-trigonometric-functions": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/@csstools/postcss-trigonometric-functions/-/postcss-trigonometric-functions-1.0.2.tgz", - "integrity": "sha512-woKaLO///4bb+zZC2s80l+7cm07M7268MsyG3M0ActXXEFi6SuhvriQYcb58iiKGbjwwIU7n45iRLEHypB47Og==", - "dependencies": { - "postcss-value-parser": "^4.2.0" - }, - "engines": { - "node": "^14 || >=16" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/csstools" - }, - "peerDependencies": { - "postcss": "^8.2" - } - }, - "node_modules/@csstools/postcss-unset-value": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/@csstools/postcss-unset-value/-/postcss-unset-value-1.0.2.tgz", - "integrity": "sha512-c8J4roPBILnelAsdLr4XOAR/GsTm0GJi4XpcfvoWk3U6KiTCqiFYc63KhRMQQX35jYMp4Ao8Ij9+IZRgMfJp1g==", - "engines": { - "node": "^12 || ^14 || >=16" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/csstools" - }, - "peerDependencies": { - "postcss": "^8.2" - } - }, - "node_modules/@csstools/selector-specificity": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/@csstools/selector-specificity/-/selector-specificity-2.2.0.tgz", - "integrity": "sha512-+OJ9konv95ClSTOJCmMZqpd5+YGsB2S+x6w3E1oaM8UuR5j8nTNHYSz8c9BEPGDOCMQYIEEGlVPj/VY64iTbGw==", - "engines": { - "node": "^14 || ^16 || >=18" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/csstools" - }, - "peerDependencies": { - "postcss-selector-parser": "^6.0.10" - } - }, - "node_modules/@emotion/babel-plugin": { - "version": "11.11.0", - "resolved": "https://registry.npmjs.org/@emotion/babel-plugin/-/babel-plugin-11.11.0.tgz", - "integrity": "sha512-m4HEDZleaaCH+XgDDsPF15Ht6wTLsgDTeR3WYj9Q/k76JtWhrJjcP4+/XlG8LGT/Rol9qUfOIztXeA84ATpqPQ==", - "dependencies": { - "@babel/helper-module-imports": "^7.16.7", - "@babel/runtime": "^7.18.3", - "@emotion/hash": "^0.9.1", - "@emotion/memoize": "^0.8.1", - "@emotion/serialize": "^1.1.2", - "babel-plugin-macros": "^3.1.0", - "convert-source-map": "^1.5.0", - "escape-string-regexp": "^4.0.0", - "find-root": "^1.1.0", - "source-map": "^0.5.7", - "stylis": "4.2.0" - } - }, - "node_modules/@emotion/babel-plugin/node_modules/escape-string-regexp": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", - "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/@emotion/babel-plugin/node_modules/source-map": { - "version": "0.5.7", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", - "integrity": "sha512-LbrmJOMUSdEVxIKvdcJzQC+nQhe8FUZQTXQy6+I75skNgn3OoQ0DZA8YnFa7gp8tqtL3KPf1kmo0R5DoApeSGQ==", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/@emotion/cache": { - "version": "11.11.0", - "resolved": "https://registry.npmjs.org/@emotion/cache/-/cache-11.11.0.tgz", - "integrity": "sha512-P34z9ssTCBi3e9EI1ZsWpNHcfY1r09ZO0rZbRO2ob3ZQMnFI35jB536qoXbkdesr5EUhYi22anuEJuyxifaqAQ==", - "dependencies": { - "@emotion/memoize": "^0.8.1", - "@emotion/sheet": "^1.2.2", - "@emotion/utils": "^1.2.1", - "@emotion/weak-memoize": "^0.3.1", - "stylis": "4.2.0" - } - }, - "node_modules/@emotion/hash": { - "version": "0.9.1", - "resolved": "https://registry.npmjs.org/@emotion/hash/-/hash-0.9.1.tgz", - "integrity": "sha512-gJB6HLm5rYwSLI6PQa+X1t5CFGrv1J1TWG+sOyMCeKz2ojaj6Fnl/rZEspogG+cvqbt4AE/2eIyD2QfLKTBNlQ==" - }, - "node_modules/@emotion/memoize": { - "version": "0.8.1", - "resolved": "https://registry.npmjs.org/@emotion/memoize/-/memoize-0.8.1.tgz", - "integrity": "sha512-W2P2c/VRW1/1tLox0mVUalvnWXxavmv/Oum2aPsRcoDJuob75FC3Y8FbpfLwUegRcxINtGUMPq0tFCvYNTBXNA==" - }, - "node_modules/@emotion/react": { - "version": "11.11.0", - "resolved": "https://registry.npmjs.org/@emotion/react/-/react-11.11.0.tgz", - "integrity": "sha512-ZSK3ZJsNkwfjT3JpDAWJZlrGD81Z3ytNDsxw1LKq1o+xkmO5pnWfr6gmCC8gHEFf3nSSX/09YrG67jybNPxSUw==", - "dependencies": { - "@babel/runtime": "^7.18.3", - "@emotion/babel-plugin": "^11.11.0", - "@emotion/cache": "^11.11.0", - "@emotion/serialize": "^1.1.2", - "@emotion/use-insertion-effect-with-fallbacks": "^1.0.1", - "@emotion/utils": "^1.2.1", - "@emotion/weak-memoize": "^0.3.1", - "hoist-non-react-statics": "^3.3.1" - }, - "peerDependencies": { - "react": ">=16.8.0" - }, - "peerDependenciesMeta": { - "@types/react": { - "optional": true - } - } - }, - "node_modules/@emotion/serialize": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/@emotion/serialize/-/serialize-1.1.2.tgz", - "integrity": "sha512-zR6a/fkFP4EAcCMQtLOhIgpprZOwNmCldtpaISpvz348+DP4Mz8ZoKaGGCQpbzepNIUWbq4w6hNZkwDyKoS+HA==", - "dependencies": { - "@emotion/hash": "^0.9.1", - "@emotion/memoize": "^0.8.1", - "@emotion/unitless": "^0.8.1", - "@emotion/utils": "^1.2.1", - "csstype": "^3.0.2" - } - }, - "node_modules/@emotion/sheet": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/@emotion/sheet/-/sheet-1.2.2.tgz", - "integrity": "sha512-0QBtGvaqtWi+nx6doRwDdBIzhNdZrXUppvTM4dtZZWEGTXL/XE/yJxLMGlDT1Gt+UHH5IX1n+jkXyytE/av7OA==" - }, - "node_modules/@emotion/unitless": { - "version": "0.8.1", - "resolved": "https://registry.npmjs.org/@emotion/unitless/-/unitless-0.8.1.tgz", - "integrity": "sha512-KOEGMu6dmJZtpadb476IsZBclKvILjopjUii3V+7MnXIQCYh8W3NgNcgwo21n9LXZX6EDIKvqfjYxXebDwxKmQ==" - }, - "node_modules/@emotion/use-insertion-effect-with-fallbacks": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@emotion/use-insertion-effect-with-fallbacks/-/use-insertion-effect-with-fallbacks-1.0.1.tgz", - "integrity": "sha512-jT/qyKZ9rzLErtrjGgdkMBn2OP8wl0G3sQlBb3YPryvKHsjvINUhVaPFfP+fpBcOkmrVOVEEHQFJ7nbj2TH2gw==", - "peerDependencies": { - "react": ">=16.8.0" - } - }, - "node_modules/@emotion/utils": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@emotion/utils/-/utils-1.2.1.tgz", - "integrity": "sha512-Y2tGf3I+XVnajdItskUCn6LX+VUDmP6lTL4fcqsXAv43dnlbZiuW4MWQW38rW/BVWSE7Q/7+XQocmpnRYILUmg==" - }, - "node_modules/@emotion/weak-memoize": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/@emotion/weak-memoize/-/weak-memoize-0.3.1.tgz", - "integrity": "sha512-EsBwpc7hBUJWAsNPBmJy4hxWx12v6bshQsldrVmjxJoc3isbxhOrF2IcCpaXxfvq03NwkI7sbsOLXbYuqF/8Ww==" - }, - "node_modules/@eslint-community/eslint-utils": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz", - "integrity": "sha512-1/sA4dwrzBAyeUoQ6oxahHKmrZvsnLCg4RfxW3ZFGGmQkSNQPFNLV9CUEFQP1x9EYXHTo5p6xdhZM1Ne9p/AfA==", - "dependencies": { - "eslint-visitor-keys": "^3.3.0" - }, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "peerDependencies": { - "eslint": "^6.0.0 || ^7.0.0 || >=8.0.0" - } - }, - "node_modules/@eslint-community/regexpp": { - "version": "4.5.1", - "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.5.1.tgz", - "integrity": "sha512-Z5ba73P98O1KUYCCJTUeVpja9RcGoMdncZ6T49FCUl2lN38JtCJ+3WgIDBv0AuY4WChU5PmtJmOCTlN6FZTFKQ==", - "engines": { - "node": "^12.0.0 || ^14.0.0 || >=16.0.0" - } - }, - "node_modules/@eslint/eslintrc": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.0.3.tgz", - "integrity": "sha512-+5gy6OQfk+xx3q0d6jGZZC3f3KzAkXc/IanVxd1is/VIIziRqqt3ongQz0FiTUXqTk0c7aDB3OaFuKnuSoJicQ==", - "dependencies": { - "ajv": "^6.12.4", - "debug": "^4.3.2", - "espree": "^9.5.2", - "globals": "^13.19.0", - "ignore": "^5.2.0", - "import-fresh": "^3.2.1", - "js-yaml": "^4.1.0", - "minimatch": "^3.1.2", - "strip-json-comments": "^3.1.1" - }, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "funding": { - "url": "https://opencollective.com/eslint" - } - }, - "node_modules/@eslint/eslintrc/node_modules/argparse": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", - "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==" - }, - "node_modules/@eslint/eslintrc/node_modules/globals": { - "version": "13.20.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-13.20.0.tgz", - "integrity": "sha512-Qg5QtVkCy/kv3FUSlu4ukeZDVf9ee0iXLAUYX13gbR17bnejFTzr4iS9bY7kwCf1NztRNm1t91fjOiyx4CSwPQ==", - "dependencies": { - "type-fest": "^0.20.2" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/@eslint/eslintrc/node_modules/js-yaml": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", - "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", - "dependencies": { - "argparse": "^2.0.1" - }, - "bin": { - "js-yaml": "bin/js-yaml.js" - } - }, - "node_modules/@eslint/eslintrc/node_modules/type-fest": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", - "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/@eslint/js": { - "version": "8.41.0", - "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.41.0.tgz", - "integrity": "sha512-LxcyMGxwmTh2lY9FwHPGWOHmYFCZvbrFCBZL4FzSSsxsRPuhrYUg/49/0KDfW8tnIEaEHtfmn6+NPN+1DqaNmA==", - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - } - }, - "node_modules/@floating-ui/core": { - "version": "1.2.6", - "resolved": "https://registry.npmjs.org/@floating-ui/core/-/core-1.2.6.tgz", - "integrity": "sha512-EvYTiXet5XqweYGClEmpu3BoxmsQ4hkj3QaYA6qEnigCWffTP3vNRwBReTdrwDwo7OoJ3wM8Uoe9Uk4n+d4hfg==" - }, - "node_modules/@floating-ui/dom": { - "version": "1.2.8", - "resolved": "https://registry.npmjs.org/@floating-ui/dom/-/dom-1.2.8.tgz", - "integrity": "sha512-XLwhYV90MxiHDq6S0rzFZj00fnDM+A1R9jhSioZoMsa7G0Q0i+Q4x40ajR8FHSdYDE1bgjG45mIWe6jtv9UPmg==", - "dependencies": { - "@floating-ui/core": "^1.2.6" - } - }, - "node_modules/@floating-ui/react": { - "version": "0.19.2", - "resolved": "https://registry.npmjs.org/@floating-ui/react/-/react-0.19.2.tgz", - "integrity": "sha512-JyNk4A0Ezirq8FlXECvRtQOX/iBe5Ize0W/pLkrZjfHW9GUV7Xnq6zm6fyZuQzaHHqEnVizmvlA96e1/CkZv+w==", - "dependencies": { - "@floating-ui/react-dom": "^1.3.0", - "aria-hidden": "^1.1.3", - "tabbable": "^6.0.1" - }, - "peerDependencies": { - "react": ">=16.8.0", - "react-dom": ">=16.8.0" - } - }, - "node_modules/@floating-ui/react-dom": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/@floating-ui/react-dom/-/react-dom-1.3.0.tgz", - "integrity": "sha512-htwHm67Ji5E/pROEAr7f8IKFShuiCKHwUC/UY4vC3I5jiSvGFAYnSYiZO5MlGmads+QqvUkR9ANHEguGrDv72g==", - "dependencies": { - "@floating-ui/dom": "^1.2.1" - }, - "peerDependencies": { - "react": ">=16.8.0", - "react-dom": ">=16.8.0" - } - }, - "node_modules/@google/generative-ai": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/@google/generative-ai/-/generative-ai-0.1.3.tgz", - "integrity": "sha512-Cm4uJX1sKarpm1mje/MiOIinM7zdUUrQp/5/qGPAgznbdd/B9zup5ehT6c1qGqycFcSopTA1J1HpqHS5kJR8hQ==", - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@humanwhocodes/config-array": { - "version": "0.11.8", - "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.8.tgz", - "integrity": "sha512-UybHIJzJnR5Qc/MsD9Kr+RpO2h+/P1GhOwdiLPXK5TWk5sgTdu88bTD9UP+CKbPPh5Rni1u0GjAdYQLemG8g+g==", - "dependencies": { - "@humanwhocodes/object-schema": "^1.2.1", - "debug": "^4.1.1", - "minimatch": "^3.0.5" - }, - "engines": { - "node": ">=10.10.0" - } - }, - "node_modules/@humanwhocodes/module-importer": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz", - "integrity": "sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==", - "engines": { - "node": ">=12.22" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/nzakas" - } - }, - "node_modules/@humanwhocodes/object-schema": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz", - "integrity": "sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==" - }, - "node_modules/@istanbuljs/load-nyc-config": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz", - "integrity": "sha512-VjeHSlIzpv/NyD3N0YuHfXOPDIixcA1q2ZV98wsMqcYlPmv2n3Yb2lYP9XMElnaFVXg5A7YLTeLu6V84uQDjmQ==", - "dependencies": { - "camelcase": "^5.3.1", - "find-up": "^4.1.0", - "get-package-type": "^0.1.0", - "js-yaml": "^3.13.1", - "resolve-from": "^5.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/@istanbuljs/load-nyc-config/node_modules/camelcase": { - "version": "5.3.1", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", - "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", - "engines": { - "node": ">=6" - } - }, - "node_modules/@istanbuljs/load-nyc-config/node_modules/find-up": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", - "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", - "dependencies": { - "locate-path": "^5.0.0", - "path-exists": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/@istanbuljs/load-nyc-config/node_modules/locate-path": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", - "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", - "dependencies": { - "p-locate": "^4.1.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/@istanbuljs/load-nyc-config/node_modules/p-limit": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", - "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", - "dependencies": { - "p-try": "^2.0.0" - }, - "engines": { - "node": ">=6" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/@istanbuljs/load-nyc-config/node_modules/p-locate": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", - "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", - "dependencies": { - "p-limit": "^2.2.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/@istanbuljs/schema": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/@istanbuljs/schema/-/schema-0.1.3.tgz", - "integrity": "sha512-ZXRY4jNvVgSVQ8DL3LTcakaAtXwTVUxE81hslsyD2AtoXW/wVob10HkOJ1X/pAlcI7D+2YoZKg5do8G/w6RYgA==", - "engines": { - "node": ">=8" - } - }, - "node_modules/@jest/console": { - "version": "27.5.1", - "resolved": "https://registry.npmjs.org/@jest/console/-/console-27.5.1.tgz", - "integrity": "sha512-kZ/tNpS3NXn0mlXXXPNuDZnb4c0oZ20r4K5eemM2k30ZC3G0T02nXUvyhf5YdbXWHPEJLc9qGLxEZ216MdL+Zg==", - "dependencies": { - "@jest/types": "^27.5.1", - "@types/node": "*", - "chalk": "^4.0.0", - "jest-message-util": "^27.5.1", - "jest-util": "^27.5.1", - "slash": "^3.0.0" - }, - "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" - } - }, - "node_modules/@jest/console/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/@jest/console/node_modules/chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dependencies": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" - } - }, - "node_modules/@jest/console/node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/@jest/console/node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" - }, - "node_modules/@jest/console/node_modules/has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "engines": { - "node": ">=8" - } - }, - "node_modules/@jest/console/node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/@jest/core": { - "version": "27.5.1", - "resolved": "https://registry.npmjs.org/@jest/core/-/core-27.5.1.tgz", - "integrity": "sha512-AK6/UTrvQD0Cd24NSqmIA6rKsu0tKIxfiCducZvqxYdmMisOYAsdItspT+fQDQYARPf8XgjAFZi0ogW2agH5nQ==", - "dependencies": { - "@jest/console": "^27.5.1", - "@jest/reporters": "^27.5.1", - "@jest/test-result": "^27.5.1", - "@jest/transform": "^27.5.1", - "@jest/types": "^27.5.1", - "@types/node": "*", - "ansi-escapes": "^4.2.1", - "chalk": "^4.0.0", - "emittery": "^0.8.1", - "exit": "^0.1.2", - "graceful-fs": "^4.2.9", - "jest-changed-files": "^27.5.1", - "jest-config": "^27.5.1", - "jest-haste-map": "^27.5.1", - "jest-message-util": "^27.5.1", - "jest-regex-util": "^27.5.1", - "jest-resolve": "^27.5.1", - "jest-resolve-dependencies": "^27.5.1", - "jest-runner": "^27.5.1", - "jest-runtime": "^27.5.1", - "jest-snapshot": "^27.5.1", - "jest-util": "^27.5.1", - "jest-validate": "^27.5.1", - "jest-watcher": "^27.5.1", - "micromatch": "^4.0.4", - "rimraf": "^3.0.0", - "slash": "^3.0.0", - "strip-ansi": "^6.0.0" - }, - "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" - }, - "peerDependencies": { - "node-notifier": "^8.0.1 || ^9.0.0 || ^10.0.0" - }, - "peerDependenciesMeta": { - "node-notifier": { - "optional": true - } - } - }, - "node_modules/@jest/core/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/@jest/core/node_modules/chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dependencies": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" - } - }, - "node_modules/@jest/core/node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/@jest/core/node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" - }, - "node_modules/@jest/core/node_modules/has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "engines": { - "node": ">=8" - } - }, - "node_modules/@jest/core/node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/@jest/environment": { - "version": "27.5.1", - "resolved": "https://registry.npmjs.org/@jest/environment/-/environment-27.5.1.tgz", - "integrity": "sha512-/WQjhPJe3/ghaol/4Bq480JKXV/Rfw8nQdN7f41fM8VDHLcxKXou6QyXAh3EFr9/bVG3x74z1NWDkP87EiY8gA==", - "dependencies": { - "@jest/fake-timers": "^27.5.1", - "@jest/types": "^27.5.1", - "@types/node": "*", - "jest-mock": "^27.5.1" - }, - "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" - } - }, - "node_modules/@jest/expect-utils": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/@jest/expect-utils/-/expect-utils-29.5.0.tgz", - "integrity": "sha512-fmKzsidoXQT2KwnrwE0SQq3uj8Z763vzR8LnLBwC2qYWEFpjX8daRsk6rHUM1QvNlEW/UJXNXm59ztmJJWs2Mg==", - "dependencies": { - "jest-get-type": "^29.4.3" - }, - "engines": { - "node": "^14.15.0 || ^16.10.0 || >=18.0.0" - } - }, - "node_modules/@jest/expect-utils/node_modules/jest-get-type": { - "version": "29.4.3", - "resolved": "https://registry.npmjs.org/jest-get-type/-/jest-get-type-29.4.3.tgz", - "integrity": "sha512-J5Xez4nRRMjk8emnTpWrlkyb9pfRQQanDrvWHhsR1+VUfbwxi30eVcZFlcdGInRibU4G5LwHXpI7IRHU0CY+gg==", - "engines": { - "node": "^14.15.0 || ^16.10.0 || >=18.0.0" - } - }, - "node_modules/@jest/fake-timers": { - "version": "27.5.1", - "resolved": "https://registry.npmjs.org/@jest/fake-timers/-/fake-timers-27.5.1.tgz", - "integrity": "sha512-/aPowoolwa07k7/oM3aASneNeBGCmGQsc3ugN4u6s4C/+s5M64MFo/+djTdiwcbQlRfFElGuDXWzaWj6QgKObQ==", - "dependencies": { - "@jest/types": "^27.5.1", - "@sinonjs/fake-timers": "^8.0.1", - "@types/node": "*", - "jest-message-util": "^27.5.1", - "jest-mock": "^27.5.1", - "jest-util": "^27.5.1" - }, - "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" - } - }, - "node_modules/@jest/globals": { - "version": "27.5.1", - "resolved": "https://registry.npmjs.org/@jest/globals/-/globals-27.5.1.tgz", - "integrity": "sha512-ZEJNB41OBQQgGzgyInAv0UUfDDj3upmHydjieSxFvTRuZElrx7tXg/uVQ5hYVEwiXs3+aMsAeEc9X7xiSKCm4Q==", - "dependencies": { - "@jest/environment": "^27.5.1", - "@jest/types": "^27.5.1", - "expect": "^27.5.1" - }, - "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" - } - }, - "node_modules/@jest/reporters": { - "version": "27.5.1", - "resolved": "https://registry.npmjs.org/@jest/reporters/-/reporters-27.5.1.tgz", - "integrity": "sha512-cPXh9hWIlVJMQkVk84aIvXuBB4uQQmFqZiacloFuGiP3ah1sbCxCosidXFDfqG8+6fO1oR2dTJTlsOy4VFmUfw==", - "dependencies": { - "@bcoe/v8-coverage": "^0.2.3", - "@jest/console": "^27.5.1", - "@jest/test-result": "^27.5.1", - "@jest/transform": "^27.5.1", - "@jest/types": "^27.5.1", - "@types/node": "*", - "chalk": "^4.0.0", - "collect-v8-coverage": "^1.0.0", - "exit": "^0.1.2", - "glob": "^7.1.2", - "graceful-fs": "^4.2.9", - "istanbul-lib-coverage": "^3.0.0", - "istanbul-lib-instrument": "^5.1.0", - "istanbul-lib-report": "^3.0.0", - "istanbul-lib-source-maps": "^4.0.0", - "istanbul-reports": "^3.1.3", - "jest-haste-map": "^27.5.1", - "jest-resolve": "^27.5.1", - "jest-util": "^27.5.1", - "jest-worker": "^27.5.1", - "slash": "^3.0.0", - "source-map": "^0.6.0", - "string-length": "^4.0.1", - "terminal-link": "^2.0.0", - "v8-to-istanbul": "^8.1.0" - }, - "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" - }, - "peerDependencies": { - "node-notifier": "^8.0.1 || ^9.0.0 || ^10.0.0" - }, - "peerDependenciesMeta": { - "node-notifier": { - "optional": true - } - } - }, - "node_modules/@jest/reporters/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/@jest/reporters/node_modules/chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dependencies": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" - } - }, - "node_modules/@jest/reporters/node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/@jest/reporters/node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" - }, - "node_modules/@jest/reporters/node_modules/has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "engines": { - "node": ">=8" - } - }, - "node_modules/@jest/reporters/node_modules/source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/@jest/reporters/node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/@jest/schemas": { - "version": "28.1.3", - "resolved": "https://registry.npmjs.org/@jest/schemas/-/schemas-28.1.3.tgz", - "integrity": "sha512-/l/VWsdt/aBXgjshLWOFyFt3IVdYypu5y2Wn2rOO1un6nkqIn8SLXzgIMYXFyYsRWDyF5EthmKJMIdJvk08grg==", - "dependencies": { - "@sinclair/typebox": "^0.24.1" - }, - "engines": { - "node": "^12.13.0 || ^14.15.0 || ^16.10.0 || >=17.0.0" - } - }, - "node_modules/@jest/source-map": { - "version": "27.5.1", - "resolved": "https://registry.npmjs.org/@jest/source-map/-/source-map-27.5.1.tgz", - "integrity": "sha512-y9NIHUYF3PJRlHk98NdC/N1gl88BL08aQQgu4k4ZopQkCw9t9cV8mtl3TV8b/YCB8XaVTFrmUTAJvjsntDireg==", - "dependencies": { - "callsites": "^3.0.0", - "graceful-fs": "^4.2.9", - "source-map": "^0.6.0" - }, - "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" - } - }, - "node_modules/@jest/source-map/node_modules/source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/@jest/test-result": { - "version": "27.5.1", - "resolved": "https://registry.npmjs.org/@jest/test-result/-/test-result-27.5.1.tgz", - "integrity": "sha512-EW35l2RYFUcUQxFJz5Cv5MTOxlJIQs4I7gxzi2zVU7PJhOwfYq1MdC5nhSmYjX1gmMmLPvB3sIaC+BkcHRBfag==", - "dependencies": { - "@jest/console": "^27.5.1", - "@jest/types": "^27.5.1", - "@types/istanbul-lib-coverage": "^2.0.0", - "collect-v8-coverage": "^1.0.0" - }, - "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" - } - }, - "node_modules/@jest/test-sequencer": { - "version": "27.5.1", - "resolved": "https://registry.npmjs.org/@jest/test-sequencer/-/test-sequencer-27.5.1.tgz", - "integrity": "sha512-LCheJF7WB2+9JuCS7VB/EmGIdQuhtqjRNI9A43idHv3E4KltCTsPsLxvdaubFHSYwY/fNjMWjl6vNRhDiN7vpQ==", - "dependencies": { - "@jest/test-result": "^27.5.1", - "graceful-fs": "^4.2.9", - "jest-haste-map": "^27.5.1", - "jest-runtime": "^27.5.1" - }, - "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" - } - }, - "node_modules/@jest/transform": { - "version": "27.5.1", - "resolved": "https://registry.npmjs.org/@jest/transform/-/transform-27.5.1.tgz", - "integrity": "sha512-ipON6WtYgl/1329g5AIJVbUuEh0wZVbdpGwC99Jw4LwuoBNS95MVphU6zOeD9pDkon+LLbFL7lOQRapbB8SCHw==", - "dependencies": { - "@babel/core": "^7.1.0", - "@jest/types": "^27.5.1", - "babel-plugin-istanbul": "^6.1.1", - "chalk": "^4.0.0", - "convert-source-map": "^1.4.0", - "fast-json-stable-stringify": "^2.0.0", - "graceful-fs": "^4.2.9", - "jest-haste-map": "^27.5.1", - "jest-regex-util": "^27.5.1", - "jest-util": "^27.5.1", - "micromatch": "^4.0.4", - "pirates": "^4.0.4", - "slash": "^3.0.0", - "source-map": "^0.6.1", - "write-file-atomic": "^3.0.0" - }, - "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" - } - }, - "node_modules/@jest/transform/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/@jest/transform/node_modules/chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dependencies": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" - } - }, - "node_modules/@jest/transform/node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/@jest/transform/node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" - }, - "node_modules/@jest/transform/node_modules/has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "engines": { - "node": ">=8" - } - }, - "node_modules/@jest/transform/node_modules/source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/@jest/transform/node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/@jest/types": { - "version": "27.5.1", - "resolved": "https://registry.npmjs.org/@jest/types/-/types-27.5.1.tgz", - "integrity": "sha512-Cx46iJ9QpwQTjIdq5VJu2QTMMs3QlEjI0x1QbBP5W1+nMzyc2XmimiRR/CbX9TO0cPTeUlxWMOu8mslYsJ8DEw==", - "dependencies": { - "@types/istanbul-lib-coverage": "^2.0.0", - "@types/istanbul-reports": "^3.0.0", - "@types/node": "*", - "@types/yargs": "^16.0.0", - "chalk": "^4.0.0" - }, - "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" - } - }, - "node_modules/@jest/types/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/@jest/types/node_modules/chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dependencies": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" - } - }, - "node_modules/@jest/types/node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/@jest/types/node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" - }, - "node_modules/@jest/types/node_modules/has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "engines": { - "node": ">=8" - } - }, - "node_modules/@jest/types/node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/@jridgewell/gen-mapping": { - "version": "0.3.3", - "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.3.tgz", - "integrity": "sha512-HLhSWOLRi875zjjMG/r+Nv0oCW8umGb0BgEhyX3dDX3egwZtB8PqLnjz3yedt8R5StBrzcg4aBpnh8UA9D1BoQ==", - "dependencies": { - "@jridgewell/set-array": "^1.0.1", - "@jridgewell/sourcemap-codec": "^1.4.10", - "@jridgewell/trace-mapping": "^0.3.9" - }, - "engines": { - "node": ">=6.0.0" - } - }, - "node_modules/@jridgewell/resolve-uri": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz", - "integrity": "sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w==", - "engines": { - "node": ">=6.0.0" - } - }, - "node_modules/@jridgewell/set-array": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.1.2.tgz", - "integrity": "sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw==", - "engines": { - "node": ">=6.0.0" - } - }, - "node_modules/@jridgewell/source-map": { - "version": "0.3.3", - "resolved": "https://registry.npmjs.org/@jridgewell/source-map/-/source-map-0.3.3.tgz", - "integrity": "sha512-b+fsZXeLYi9fEULmfBrhxn4IrPlINf8fiNarzTof004v3lFdntdwa9PF7vFJqm3mg7s+ScJMxXaE3Acp1irZcg==", - "dependencies": { - "@jridgewell/gen-mapping": "^0.3.0", - "@jridgewell/trace-mapping": "^0.3.9" - } - }, - "node_modules/@jridgewell/sourcemap-codec": { - "version": "1.4.15", - "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz", - "integrity": "sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==" - }, - "node_modules/@jridgewell/trace-mapping": { - "version": "0.3.18", - "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.18.tgz", - "integrity": "sha512-w+niJYzMHdd7USdiH2U6869nqhD2nbfZXND5Yp93qIbEmnDNk7PD48o+YchRVpzMU7M6jVCbenTR7PA1FLQ9pA==", - "dependencies": { - "@jridgewell/resolve-uri": "3.1.0", - "@jridgewell/sourcemap-codec": "1.4.14" - } - }, - "node_modules/@jridgewell/trace-mapping/node_modules/@jridgewell/sourcemap-codec": { - "version": "1.4.14", - "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz", - "integrity": "sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==" - }, - "node_modules/@leichtgewicht/ip-codec": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/@leichtgewicht/ip-codec/-/ip-codec-2.0.4.tgz", - "integrity": "sha512-Hcv+nVC0kZnQ3tD9GVu5xSMR4VVYOteQIr/hwFPVEvPdlXqgGEuRjiheChHgdM+JyqdgNcmzZOX/tnl0JOiI7A==" - }, - "node_modules/@linaria/core": { - "version": "4.2.9", - "resolved": "https://registry.npmjs.org/@linaria/core/-/core-4.2.9.tgz", - "integrity": "sha512-ELcu37VNVOT/PU0L6WDIN+aLzNFyJrqoBYT0CucGOCAmODbojUMCv8oJYRbWzA3N34w1t199dN4UFdfRWFG2rg==", - "peer": true, - "dependencies": { - "@linaria/logger": "^4.0.0", - "@linaria/tags": "^4.3.4", - "@linaria/utils": "^4.3.3" - }, - "engines": { - "node": "^12.16.0 || >=13.7.0" - } - }, - "node_modules/@linaria/logger": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/@linaria/logger/-/logger-4.0.0.tgz", - "integrity": "sha512-YnBq0JlDWMEkTOK+tMo5yEVR0f5V//6qMLToGcLhTyM9g9i+IDFn51Z+5q2hLk7RdG4NBPgbcCXYi2w4RKsPeg==", - "peer": true, - "dependencies": { - "debug": "^4.1.1", - "picocolors": "^1.0.0" - }, - "engines": { - "node": "^12.16.0 || >=13.7.0" - } - }, - "node_modules/@linaria/tags": { - "version": "4.3.5", - "resolved": "https://registry.npmjs.org/@linaria/tags/-/tags-4.3.5.tgz", - "integrity": "sha512-PgaIi8Vv89YOjc6rpKL/uPg2w4k0rAwAYxcqeXqzKqsEAste5rgB8xp1/KUOG0oAOkPd3MRL6Duj+m0ZwJ3g+g==", - "peer": true, - "dependencies": { - "@babel/generator": "^7.20.4", - "@linaria/logger": "^4.0.0", - "@linaria/utils": "^4.3.4" - }, - "engines": { - "node": "^12.16.0 || >=13.7.0" - } - }, - "node_modules/@linaria/utils": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/@linaria/utils/-/utils-4.3.4.tgz", - "integrity": "sha512-vt6WJG54n+KANaqxOfzIIU7aSfFHEWFbnGLsgxL7nASHqO0zezrNA2y2Rrp80zSeTW+wSpbmDM4uJyC9UW1qoA==", - "peer": true, - "dependencies": { - "@babel/core": "^7.20.2", - "@babel/plugin-proposal-export-namespace-from": "^7.18.9", - "@babel/plugin-syntax-dynamic-import": "^7.8.3", - "@babel/plugin-transform-modules-commonjs": "^7.19.6", - "@babel/traverse": "^7.20.1", - "@babel/types": "^7.20.2", - "@linaria/logger": "^4.0.0", - "babel-merge": "^3.0.0" - }, - "engines": { - "node": "^12.16.0 || >=13.7.0" - } - }, - "node_modules/@mantine/carousel": { - "version": "6.0.11", - "resolved": "https://registry.npmjs.org/@mantine/carousel/-/carousel-6.0.11.tgz", - "integrity": "sha512-QKY0f96eFmRGsHcztp+qdPjsjx3rtXLGBzY9e5AmzBSYWRm30tZHVLISz5vcuMkJ3QtQwCAye69/hgjNYpvyPQ==", - "dependencies": { - "@mantine/utils": "6.0.11" - }, - "peerDependencies": { - "@mantine/core": "6.0.11", - "@mantine/hooks": "6.0.11", - "embla-carousel-react": "^7.0.0", - "react": ">=16.8.0" - } - }, - "node_modules/@mantine/core": { - "version": "6.0.11", - "resolved": "https://registry.npmjs.org/@mantine/core/-/core-6.0.11.tgz", - "integrity": "sha512-S8koDsh1mlezqoOST7UfNfojKR0FWFIrzN3RkxoHlD7ggawrxeCPjHqk0bfUyKBvDOa2UiDpjWVYYSUtxZqpLw==", - "dependencies": { - "@floating-ui/react": "^0.19.1", - "@mantine/styles": "6.0.11", - "@mantine/utils": "6.0.11", - "@radix-ui/react-scroll-area": "1.0.2", - "react-remove-scroll": "^2.5.5", - "react-textarea-autosize": "8.3.4" - }, - "peerDependencies": { - "@mantine/hooks": "6.0.11", - "react": ">=16.8.0", - "react-dom": ">=16.8.0" - } - }, - "node_modules/@mantine/dates": { - "version": "6.0.11", - "resolved": "https://registry.npmjs.org/@mantine/dates/-/dates-6.0.11.tgz", - "integrity": "sha512-R0+fZQoTH8ioiAiVA7RFBsO6NL4MPz3d1lin2QCi/rj3ICp/+8X+AG4jN1Uy+xtWgfPB+hjp5RJASyUa0hNqtw==", - "dependencies": { - "@mantine/utils": "6.0.11" - }, - "peerDependencies": { - "@mantine/core": "6.0.11", - "@mantine/hooks": "6.0.11", - "dayjs": ">=1.0.0", - "react": ">=16.8.0" - } - }, - "node_modules/@mantine/dropzone": { - "version": "6.0.11", - "resolved": "https://registry.npmjs.org/@mantine/dropzone/-/dropzone-6.0.11.tgz", - "integrity": "sha512-FJIbvQkcGQGhUxPyPqg8tkMfqeZJwncguT9iFWkhEaDG3gVrvO65BDxHCV3+kMC8t/bvi/J0sizQiqYCAPgfGQ==", - "dependencies": { - "@mantine/utils": "6.0.11", - "react-dropzone": "14.2.3" - }, - "peerDependencies": { - "@mantine/core": "6.0.11", - "@mantine/hooks": "6.0.11", - "react": ">=16.8.0", - "react-dom": ">=16.8.0" - } - }, - "node_modules/@mantine/form": { - "version": "6.0.11", - "resolved": "https://registry.npmjs.org/@mantine/form/-/form-6.0.11.tgz", - "integrity": "sha512-fUkUF91bHbj0rVyMbLMsUc4/ieHrmsjVSevgfDbVtR9OAA+BL8B4huqsBpiE0NI2clc2zSf/ttbVcHON8PC4qQ==", - "dependencies": { - "fast-deep-equal": "^3.1.3", - "klona": "^2.0.5" - }, - "peerDependencies": { - "react": ">=16.8.0" - } - }, - "node_modules/@mantine/hooks": { - "version": "6.0.11", - "resolved": "https://registry.npmjs.org/@mantine/hooks/-/hooks-6.0.11.tgz", - "integrity": "sha512-WM24bEqtnfPikks+92wllvHodwSBuU0tcF+IiCumyQBQTbhLWCVNHaUXYsL/bKFEZVOOwgEO4dITaxqFkdVBxA==", - "peerDependencies": { - "react": ">=16.8.0" - } - }, - "node_modules/@mantine/modals": { - "version": "6.0.11", - "resolved": "https://registry.npmjs.org/@mantine/modals/-/modals-6.0.11.tgz", - "integrity": "sha512-PNznBQt6AZELMhDuuvebYjLrNhspzuTb1L24Re8Grhe1+1LPBPrbso2fkbmDf4I7+Vg32fbPh0nO73X+KFEtsA==", - "dependencies": { - "@mantine/utils": "6.0.11" - }, - "peerDependencies": { - "@mantine/core": "6.0.11", - "@mantine/hooks": "6.0.11", - "react": ">=16.8.0", - "react-dom": ">=16.8.0" - } - }, - "node_modules/@mantine/notifications": { - "version": "6.0.11", - "resolved": "https://registry.npmjs.org/@mantine/notifications/-/notifications-6.0.11.tgz", - "integrity": "sha512-Vs0b5XQMBz/quw+388GXYcDHGh09rJfeVx92SdwIvvwdHUxE2PQ71yf0ma7ey/kJU5k2Zb9eLrOp9N+uJ1gW3A==", - "dependencies": { - "@mantine/utils": "6.0.11", - "react-transition-group": "4.4.2" - }, - "peerDependencies": { - "@mantine/core": "6.0.11", - "@mantine/hooks": "6.0.11", - "react": ">=16.8.0", - "react-dom": ">=16.8.0" - } - }, - "node_modules/@mantine/nprogress": { - "version": "6.0.11", - "resolved": "https://registry.npmjs.org/@mantine/nprogress/-/nprogress-6.0.11.tgz", - "integrity": "sha512-D0VRlw3rTYZrzQf2fqjDf81J0sblJyPj9p1PqxIpelwoJl5s+X2D6nwtCZvI6fwAY9eFDfNtPOMzYxwxVVNoUg==", - "dependencies": { - "@mantine/utils": "6.0.11" - }, - "peerDependencies": { - "@mantine/core": "6.0.11", - "@mantine/hooks": "6.0.11", - "react": ">=16.8.0", - "react-dom": ">=16.8.0" - } - }, - "node_modules/@mantine/prism": { - "version": "6.0.11", - "resolved": "https://registry.npmjs.org/@mantine/prism/-/prism-6.0.11.tgz", - "integrity": "sha512-tLIJ/sf4nGcT33RczuXrKpllSHAmTWYBIXLyTRwQR/7GA4x2zm905m4IgSiwHtjIrEf8EJy5Ug7bbcGx50drFQ==", - "dependencies": { - "@mantine/utils": "6.0.11", - "prism-react-renderer": "^1.2.1" - }, - "peerDependencies": { - "@mantine/core": "6.0.11", - "@mantine/hooks": "6.0.11", - "react": ">=16.8.0", - "react-dom": ">=16.8.0" - } - }, - "node_modules/@mantine/spotlight": { - "version": "6.0.11", - "resolved": "https://registry.npmjs.org/@mantine/spotlight/-/spotlight-6.0.11.tgz", - "integrity": "sha512-j4p4DWoH/AkDkArBXaUhLchCUkleubes2HU5s2lSGY6DIYuCoiTTt1aqFhEqrIdgdt6f3PCvYZMHX9kXV/kndg==", - "dependencies": { - "@mantine/utils": "6.0.11" - }, - "peerDependencies": { - "@mantine/core": "6.0.11", - "@mantine/hooks": "6.0.11", - "react": ">=16.8.0", - "react-dom": ">=16.8.0" - } - }, - "node_modules/@mantine/styles": { - "version": "6.0.11", - "resolved": "https://registry.npmjs.org/@mantine/styles/-/styles-6.0.11.tgz", - "integrity": "sha512-SNqDIfgs3DVUHsFQ9+5MdZ3CkNHutBCAeaBL1PxlOxhNWB0tlii61rTAwUULxhu8p9MBNMae2UvDUN+gUPvA/A==", - "dependencies": { - "clsx": "1.1.1", - "csstype": "3.0.9" - }, - "peerDependencies": { - "@emotion/react": ">=11.9.0", - "react": ">=16.8.0", - "react-dom": ">=16.8.0" - } - }, - "node_modules/@mantine/styles/node_modules/csstype": { - "version": "3.0.9", - "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.0.9.tgz", - "integrity": "sha512-rpw6JPxK6Rfg1zLOYCSwle2GFOOsnjmDYDaBwEcwoOg4qlsIVCN789VkBZDJAGi4T07gI4YSutR43t9Zz4Lzuw==" - }, - "node_modules/@mantine/tiptap": { - "version": "6.0.11", - "resolved": "https://registry.npmjs.org/@mantine/tiptap/-/tiptap-6.0.11.tgz", - "integrity": "sha512-Ti2EU785CAFZs56/HwvJXRHUjyMi/tSttWzr/9xzF+i5LLm2YN51rkeCV7NMUryHwgmzpG7MuCEPF3XhQN7h2Q==", - "dependencies": { - "@mantine/utils": "6.0.11" - }, - "peerDependencies": { - "@mantine/core": "6.0.11", - "@mantine/hooks": "6.0.11", - "@tabler/icons-react": ">=2.1.0", - "@tiptap/extension-link": "^2.0.0-beta.202", - "@tiptap/react": "^2.0.0-beta.202", - "react": ">=16.8.0" - } - }, - "node_modules/@mantine/utils": { - "version": "6.0.11", - "resolved": "https://registry.npmjs.org/@mantine/utils/-/utils-6.0.11.tgz", - "integrity": "sha512-ijkEAaKEhZCw7HSWsGMQZsvfmQKmJXmPoQ1LeEwcH3vjZalPk9pQjSPPfUdTeX9ZAv095XWmfVMiNV8+xvM0OQ==", - "peerDependencies": { - "react": ">=16.8.0" - } - }, - "node_modules/@nicolo-ribaudo/eslint-scope-5-internals": { - "version": "5.1.1-v1", - "resolved": "https://registry.npmjs.org/@nicolo-ribaudo/eslint-scope-5-internals/-/eslint-scope-5-internals-5.1.1-v1.tgz", - "integrity": "sha512-54/JRvkLIzzDWshCWfuhadfrfZVPiElY8Fcgmg1HroEly/EDSszzhBAsarCux+D/kOslTRquNzuyGSmUSTTHGg==", - "dependencies": { - "eslint-scope": "5.1.1" - } - }, - "node_modules/@nicolo-ribaudo/eslint-scope-5-internals/node_modules/eslint-scope": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz", - "integrity": "sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==", - "dependencies": { - "esrecurse": "^4.3.0", - "estraverse": "^4.1.1" - }, - "engines": { - "node": ">=8.0.0" - } - }, - "node_modules/@nicolo-ribaudo/eslint-scope-5-internals/node_modules/estraverse": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", - "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", - "engines": { - "node": ">=4.0" - } - }, - "node_modules/@nodelib/fs.scandir": { - "version": "2.1.5", - "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", - "integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==", - "dependencies": { - "@nodelib/fs.stat": "2.0.5", - "run-parallel": "^1.1.9" - }, - "engines": { - "node": ">= 8" - } - }, - "node_modules/@nodelib/fs.stat": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz", - "integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==", - "engines": { - "node": ">= 8" - } - }, - "node_modules/@nodelib/fs.walk": { - "version": "1.2.8", - "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz", - "integrity": "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==", - "dependencies": { - "@nodelib/fs.scandir": "2.1.5", - "fastq": "^1.6.0" - }, - "engines": { - "node": ">= 8" - } - }, - "node_modules/@pmmmwh/react-refresh-webpack-plugin": { - "version": "0.5.10", - "resolved": "https://registry.npmjs.org/@pmmmwh/react-refresh-webpack-plugin/-/react-refresh-webpack-plugin-0.5.10.tgz", - "integrity": "sha512-j0Ya0hCFZPd4x40qLzbhGsh9TMtdb+CJQiso+WxLOPNasohq9cc5SNUcwsZaRH6++Xh91Xkm/xHCkuIiIu0LUA==", - "dependencies": { - "ansi-html-community": "^0.0.8", - "common-path-prefix": "^3.0.0", - "core-js-pure": "^3.23.3", - "error-stack-parser": "^2.0.6", - "find-up": "^5.0.0", - "html-entities": "^2.1.0", - "loader-utils": "^2.0.4", - "schema-utils": "^3.0.0", - "source-map": "^0.7.3" - }, - "engines": { - "node": ">= 10.13" - }, - "peerDependencies": { - "@types/webpack": "4.x || 5.x", - "react-refresh": ">=0.10.0 <1.0.0", - "sockjs-client": "^1.4.0", - "type-fest": ">=0.17.0 <4.0.0", - "webpack": ">=4.43.0 <6.0.0", - "webpack-dev-server": "3.x || 4.x", - "webpack-hot-middleware": "2.x", - "webpack-plugin-serve": "0.x || 1.x" - }, - "peerDependenciesMeta": { - "@types/webpack": { - "optional": true - }, - "sockjs-client": { - "optional": true - }, - "type-fest": { - "optional": true - }, - "webpack-dev-server": { - "optional": true - }, - "webpack-hot-middleware": { - "optional": true - }, - "webpack-plugin-serve": { - "optional": true - } - } - }, - "node_modules/@popperjs/core": { - "version": "2.11.7", - "resolved": "https://registry.npmjs.org/@popperjs/core/-/core-2.11.7.tgz", - "integrity": "sha512-Cr4OjIkipTtcXKjAsm8agyleBuDHvxzeBoa1v543lbv1YaIwQjESsVcmjiWiPEbC1FIeHOG/Op9kdCmAmiS3Kw==", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/popperjs" - } - }, - "node_modules/@radix-ui/number": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/@radix-ui/number/-/number-1.0.0.tgz", - "integrity": "sha512-Ofwh/1HX69ZfJRiRBMTy7rgjAzHmwe4kW9C9Y99HTRUcYLUuVT0KESFj15rPjRgKJs20GPq8Bm5aEDJ8DuA3vA==", - "dependencies": { - "@babel/runtime": "^7.13.10" - } - }, - "node_modules/@radix-ui/primitive": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/@radix-ui/primitive/-/primitive-1.0.0.tgz", - "integrity": "sha512-3e7rn8FDMin4CgeL7Z/49smCA3rFYY3Ha2rUQ7HRWFadS5iCRw08ZgVT1LaNTCNqgvrUiyczLflrVrF0SRQtNA==", - "dependencies": { - "@babel/runtime": "^7.13.10" - } - }, - "node_modules/@radix-ui/react-compose-refs": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/@radix-ui/react-compose-refs/-/react-compose-refs-1.0.0.tgz", - "integrity": "sha512-0KaSv6sx787/hK3eF53iOkiSLwAGlFMx5lotrqD2pTjB18KbybKoEIgkNZTKC60YECDQTKGTRcDBILwZVqVKvA==", - "dependencies": { - "@babel/runtime": "^7.13.10" - }, - "peerDependencies": { - "react": "^16.8 || ^17.0 || ^18.0" - } - }, - "node_modules/@radix-ui/react-context": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/@radix-ui/react-context/-/react-context-1.0.0.tgz", - "integrity": "sha512-1pVM9RfOQ+n/N5PJK33kRSKsr1glNxomxONs5c49MliinBY6Yw2Q995qfBUUo0/Mbg05B/sGA0gkgPI7kmSHBg==", - "dependencies": { - "@babel/runtime": "^7.13.10" - }, - "peerDependencies": { - "react": "^16.8 || ^17.0 || ^18.0" - } - }, - "node_modules/@radix-ui/react-direction": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/@radix-ui/react-direction/-/react-direction-1.0.0.tgz", - "integrity": "sha512-2HV05lGUgYcA6xgLQ4BKPDmtL+QbIZYH5fCOTAOOcJ5O0QbWS3i9lKaurLzliYUDhORI2Qr3pyjhJh44lKA3rQ==", - "dependencies": { - "@babel/runtime": "^7.13.10" - }, - "peerDependencies": { - "react": "^16.8 || ^17.0 || ^18.0" - } - }, - "node_modules/@radix-ui/react-presence": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/@radix-ui/react-presence/-/react-presence-1.0.0.tgz", - "integrity": "sha512-A+6XEvN01NfVWiKu38ybawfHsBjWum42MRPnEuqPsBZ4eV7e/7K321B5VgYMPv3Xx5An6o1/l9ZuDBgmcmWK3w==", - "dependencies": { - "@babel/runtime": "^7.13.10", - "@radix-ui/react-compose-refs": "1.0.0", - "@radix-ui/react-use-layout-effect": "1.0.0" - }, - "peerDependencies": { - "react": "^16.8 || ^17.0 || ^18.0", - "react-dom": "^16.8 || ^17.0 || ^18.0" - } - }, - "node_modules/@radix-ui/react-primitive": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@radix-ui/react-primitive/-/react-primitive-1.0.1.tgz", - "integrity": "sha512-fHbmislWVkZaIdeF6GZxF0A/NH/3BjrGIYj+Ae6eTmTCr7EB0RQAAVEiqsXK6p3/JcRqVSBQoceZroj30Jj3XA==", - "dependencies": { - "@babel/runtime": "^7.13.10", - "@radix-ui/react-slot": "1.0.1" - }, - "peerDependencies": { - "react": "^16.8 || ^17.0 || ^18.0", - "react-dom": "^16.8 || ^17.0 || ^18.0" - } - }, - "node_modules/@radix-ui/react-scroll-area": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/@radix-ui/react-scroll-area/-/react-scroll-area-1.0.2.tgz", - "integrity": "sha512-k8VseTxI26kcKJaX0HPwkvlNBPTs56JRdYzcZ/vzrNUkDlvXBy8sMc7WvCpYzZkHgb+hd72VW9MqkqecGtuNgg==", - "dependencies": { - "@babel/runtime": "^7.13.10", - "@radix-ui/number": "1.0.0", - "@radix-ui/primitive": "1.0.0", - "@radix-ui/react-compose-refs": "1.0.0", - "@radix-ui/react-context": "1.0.0", - "@radix-ui/react-direction": "1.0.0", - "@radix-ui/react-presence": "1.0.0", - "@radix-ui/react-primitive": "1.0.1", - "@radix-ui/react-use-callback-ref": "1.0.0", - "@radix-ui/react-use-layout-effect": "1.0.0" - }, - "peerDependencies": { - "react": "^16.8 || ^17.0 || ^18.0", - "react-dom": "^16.8 || ^17.0 || ^18.0" - } - }, - "node_modules/@radix-ui/react-slot": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@radix-ui/react-slot/-/react-slot-1.0.1.tgz", - "integrity": "sha512-avutXAFL1ehGvAXtPquu0YK5oz6ctS474iM3vNGQIkswrVhdrS52e3uoMQBzZhNRAIE0jBnUyXWNmSjGHhCFcw==", - "dependencies": { - "@babel/runtime": "^7.13.10", - "@radix-ui/react-compose-refs": "1.0.0" - }, - "peerDependencies": { - "react": "^16.8 || ^17.0 || ^18.0" - } - }, - "node_modules/@radix-ui/react-use-callback-ref": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/@radix-ui/react-use-callback-ref/-/react-use-callback-ref-1.0.0.tgz", - "integrity": "sha512-GZtyzoHz95Rhs6S63D2t/eqvdFCm7I+yHMLVQheKM7nBD8mbZIt+ct1jz4536MDnaOGKIxynJ8eHTkVGVVkoTg==", - "dependencies": { - "@babel/runtime": "^7.13.10" - }, - "peerDependencies": { - "react": "^16.8 || ^17.0 || ^18.0" - } - }, - "node_modules/@radix-ui/react-use-layout-effect": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/@radix-ui/react-use-layout-effect/-/react-use-layout-effect-1.0.0.tgz", - "integrity": "sha512-6Tpkq+R6LOlmQb1R5NNETLG0B4YP0wc+klfXafpUCj6JGyaUc8il7/kUZ7m59rGbXGczE9Bs+iz2qloqsZBduQ==", - "dependencies": { - "@babel/runtime": "^7.13.10" - }, - "peerDependencies": { - "react": "^16.8 || ^17.0 || ^18.0" - } - }, - "node_modules/@remirror/core-constants": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/@remirror/core-constants/-/core-constants-2.0.1.tgz", - "integrity": "sha512-ZR4aihtnnT9lMbhh5DEbsriJRlukRXmLZe7HmM+6ufJNNUDoazc75UX26xbgQlNUqgAqMcUdGFAnPc1JwgAdLQ==", - "peer": true, - "dependencies": { - "@babel/runtime": "^7.21.0" - } - }, - "node_modules/@remirror/core-helpers": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/@remirror/core-helpers/-/core-helpers-2.0.3.tgz", - "integrity": "sha512-LqIPF4stGG69l9qu/FFicv9d9B+YaItzgDMC5A0CEvDQfKkGD3BfabLmfpnuWbsc06oKGdTduilgWcALLZoYLg==", - "peer": true, - "dependencies": { - "@babel/runtime": "^7.21.0", - "@linaria/core": "4.2.9", - "@remirror/core-constants": "^2.0.1", - "@remirror/types": "^1.0.1", - "@types/object.omit": "^3.0.0", - "@types/object.pick": "^1.3.2", - "@types/throttle-debounce": "^2.1.0", - "case-anything": "^2.1.10", - "dash-get": "^1.0.2", - "deepmerge": "^4.3.1", - "fast-deep-equal": "^3.1.3", - "make-error": "^1.3.6", - "object.omit": "^3.0.0", - "object.pick": "^1.3.0", - "throttle-debounce": "^3.0.1" - } - }, - "node_modules/@remirror/types": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@remirror/types/-/types-1.0.1.tgz", - "integrity": "sha512-VlZQxwGnt1jtQ18D6JqdIF+uFZo525WEqrfp9BOc3COPpK4+AWCgdnAWL+ho6imWcoINlGjR/+3b6y5C1vBVEA==", - "peer": true, - "dependencies": { - "type-fest": "^2.19.0" - } - }, - "node_modules/@remirror/types/node_modules/type-fest": { - "version": "2.19.0", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-2.19.0.tgz", - "integrity": "sha512-RAH822pAdBgcNMAfWnCBU3CFZcfZ/i1eZjwFU/dsLKumyuuP3niueg2UAukXYF0E2AAoc82ZSSf9J0WQBinzHA==", - "peer": true, - "engines": { - "node": ">=12.20" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/@remix-run/router": { - "version": "1.6.2", - "resolved": "https://registry.npmjs.org/@remix-run/router/-/router-1.6.2.tgz", - "integrity": "sha512-LzqpSrMK/3JBAVBI9u3NWtOhWNw5AMQfrUFYB0+bDHTSw17z++WJLsPsxAuK+oSddsxk4d7F/JcdDPM1M5YAhA==", - "engines": { - "node": ">=14" - } - }, - "node_modules/@rollup/plugin-babel": { - "version": "5.3.1", - "resolved": "https://registry.npmjs.org/@rollup/plugin-babel/-/plugin-babel-5.3.1.tgz", - "integrity": "sha512-WFfdLWU/xVWKeRQnKmIAQULUI7Il0gZnBIH/ZFO069wYIfPu+8zrfp/KMW0atmELoRDq8FbiP3VCss9MhCut7Q==", - "dependencies": { - "@babel/helper-module-imports": "^7.10.4", - "@rollup/pluginutils": "^3.1.0" - }, - "engines": { - "node": ">= 10.0.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0", - "@types/babel__core": "^7.1.9", - "rollup": "^1.20.0||^2.0.0" - }, - "peerDependenciesMeta": { - "@types/babel__core": { - "optional": true - } - } - }, - "node_modules/@rollup/plugin-node-resolve": { - "version": "11.2.1", - "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-11.2.1.tgz", - "integrity": "sha512-yc2n43jcqVyGE2sqV5/YCmocy9ArjVAP/BeXyTtADTBBX6V0e5UMqwO8CdQ0kzjb6zu5P1qMzsScCMRvE9OlVg==", - "dependencies": { - "@rollup/pluginutils": "^3.1.0", - "@types/resolve": "1.17.1", - "builtin-modules": "^3.1.0", - "deepmerge": "^4.2.2", - "is-module": "^1.0.0", - "resolve": "^1.19.0" - }, - "engines": { - "node": ">= 10.0.0" - }, - "peerDependencies": { - "rollup": "^1.20.0||^2.0.0" - } - }, - "node_modules/@rollup/plugin-replace": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/@rollup/plugin-replace/-/plugin-replace-2.4.2.tgz", - "integrity": "sha512-IGcu+cydlUMZ5En85jxHH4qj2hta/11BHq95iHEyb2sbgiN0eCdzvUcHw5gt9pBL5lTi4JDYJ1acCoMGpTvEZg==", - "dependencies": { - "@rollup/pluginutils": "^3.1.0", - "magic-string": "^0.25.7" - }, - "peerDependencies": { - "rollup": "^1.20.0 || ^2.0.0" - } - }, - "node_modules/@rollup/pluginutils": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-3.1.0.tgz", - "integrity": "sha512-GksZ6pr6TpIjHm8h9lSQ8pi8BE9VeubNT0OMJ3B5uZJ8pz73NPiqOtCog/x2/QzM1ENChPKxMDhiQuRHsqc+lg==", - "dependencies": { - "@types/estree": "0.0.39", - "estree-walker": "^1.0.1", - "picomatch": "^2.2.2" - }, - "engines": { - "node": ">= 8.0.0" - }, - "peerDependencies": { - "rollup": "^1.20.0||^2.0.0" - } - }, - "node_modules/@rollup/pluginutils/node_modules/@types/estree": { - "version": "0.0.39", - "resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.39.tgz", - "integrity": "sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw==" - }, - "node_modules/@rushstack/eslint-patch": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/@rushstack/eslint-patch/-/eslint-patch-1.3.0.tgz", - "integrity": "sha512-IthPJsJR85GhOkp3Hvp8zFOPK5ynKn6STyHa/WZpioK7E1aYDiBzpqQPrngc14DszIUkIrdd3k9Iu0XSzlP/1w==" - }, - "node_modules/@sinclair/typebox": { - "version": "0.24.51", - "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.24.51.tgz", - "integrity": "sha512-1P1OROm/rdubP5aFDSZQILU0vrLCJ4fvHt6EoqHEM+2D/G5MK3bIaymUKLit8Js9gbns5UyJnkP/TZROLw4tUA==" - }, - "node_modules/@sinonjs/commons": { - "version": "1.8.6", - "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-1.8.6.tgz", - "integrity": "sha512-Ky+XkAkqPZSm3NLBeUng77EBQl3cmeJhITaGHdYH8kjVB+aun3S4XBRti2zt17mtt0mIUDiNxYeoJm6drVvBJQ==", - "dependencies": { - "type-detect": "4.0.8" - } - }, - "node_modules/@sinonjs/fake-timers": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/@sinonjs/fake-timers/-/fake-timers-8.1.0.tgz", - "integrity": "sha512-OAPJUAtgeINhh/TAlUID4QTs53Njm7xzddaVlEs/SXwgtiD1tW22zAB/W1wdqfrpmikgaWQ9Fw6Ws+hsiRm5Vg==", - "dependencies": { - "@sinonjs/commons": "^1.7.0" - } - }, - "node_modules/@socket.io/component-emitter": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/@socket.io/component-emitter/-/component-emitter-3.1.0.tgz", - "integrity": "sha512-+9jVqKhRSpsc591z5vX+X5Yyw+he/HCB4iQ/RYxw35CEPaY1gnsNE43nf9n9AaYjAQrTiI/mOwKUKdUs9vf7Xg==" - }, - "node_modules/@surma/rollup-plugin-off-main-thread": { - "version": "2.2.3", - "resolved": "https://registry.npmjs.org/@surma/rollup-plugin-off-main-thread/-/rollup-plugin-off-main-thread-2.2.3.tgz", - "integrity": "sha512-lR8q/9W7hZpMWweNiAKU7NQerBnzQQLvi8qnTDU/fxItPhtZVMbPV3lbCwjhIlNBe9Bbr5V+KHshvWmVSG9cxQ==", - "dependencies": { - "ejs": "^3.1.6", - "json5": "^2.2.0", - "magic-string": "^0.25.0", - "string.prototype.matchall": "^4.0.6" - } - }, - "node_modules/@svgr/babel-plugin-add-jsx-attribute": { - "version": "5.4.0", - "resolved": "https://registry.npmjs.org/@svgr/babel-plugin-add-jsx-attribute/-/babel-plugin-add-jsx-attribute-5.4.0.tgz", - "integrity": "sha512-ZFf2gs/8/6B8PnSofI0inYXr2SDNTDScPXhN7k5EqD4aZ3gi6u+rbmZHVB8IM3wDyx8ntKACZbtXSm7oZGRqVg==", - "engines": { - "node": ">=10" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/gregberge" - } - }, - "node_modules/@svgr/babel-plugin-remove-jsx-attribute": { - "version": "5.4.0", - "resolved": "https://registry.npmjs.org/@svgr/babel-plugin-remove-jsx-attribute/-/babel-plugin-remove-jsx-attribute-5.4.0.tgz", - "integrity": "sha512-yaS4o2PgUtwLFGTKbsiAy6D0o3ugcUhWK0Z45umJ66EPWunAz9fuFw2gJuje6wqQvQWOTJvIahUwndOXb7QCPg==", - "engines": { - "node": ">=10" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/gregberge" - } - }, - "node_modules/@svgr/babel-plugin-remove-jsx-empty-expression": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/@svgr/babel-plugin-remove-jsx-empty-expression/-/babel-plugin-remove-jsx-empty-expression-5.0.1.tgz", - "integrity": "sha512-LA72+88A11ND/yFIMzyuLRSMJ+tRKeYKeQ+mR3DcAZ5I4h5CPWN9AHyUzJbWSYp/u2u0xhmgOe0+E41+GjEueA==", - "engines": { - "node": ">=10" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/gregberge" - } - }, - "node_modules/@svgr/babel-plugin-replace-jsx-attribute-value": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/@svgr/babel-plugin-replace-jsx-attribute-value/-/babel-plugin-replace-jsx-attribute-value-5.0.1.tgz", - "integrity": "sha512-PoiE6ZD2Eiy5mK+fjHqwGOS+IXX0wq/YDtNyIgOrc6ejFnxN4b13pRpiIPbtPwHEc+NT2KCjteAcq33/F1Y9KQ==", - "engines": { - "node": ">=10" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/gregberge" - } - }, - "node_modules/@svgr/babel-plugin-svg-dynamic-title": { - "version": "5.4.0", - "resolved": "https://registry.npmjs.org/@svgr/babel-plugin-svg-dynamic-title/-/babel-plugin-svg-dynamic-title-5.4.0.tgz", - "integrity": "sha512-zSOZH8PdZOpuG1ZVx/cLVePB2ibo3WPpqo7gFIjLV9a0QsuQAzJiwwqmuEdTaW2pegyBE17Uu15mOgOcgabQZg==", - "engines": { - "node": ">=10" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/gregberge" - } - }, - "node_modules/@svgr/babel-plugin-svg-em-dimensions": { - "version": "5.4.0", - "resolved": "https://registry.npmjs.org/@svgr/babel-plugin-svg-em-dimensions/-/babel-plugin-svg-em-dimensions-5.4.0.tgz", - "integrity": "sha512-cPzDbDA5oT/sPXDCUYoVXEmm3VIoAWAPT6mSPTJNbQaBNUuEKVKyGH93oDY4e42PYHRW67N5alJx/eEol20abw==", - "engines": { - "node": ">=10" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/gregberge" - } - }, - "node_modules/@svgr/babel-plugin-transform-react-native-svg": { - "version": "5.4.0", - "resolved": "https://registry.npmjs.org/@svgr/babel-plugin-transform-react-native-svg/-/babel-plugin-transform-react-native-svg-5.4.0.tgz", - "integrity": "sha512-3eYP/SaopZ41GHwXma7Rmxcv9uRslRDTY1estspeB1w1ueZWd/tPlMfEOoccYpEMZU3jD4OU7YitnXcF5hLW2Q==", - "engines": { - "node": ">=10" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/gregberge" - } - }, - "node_modules/@svgr/babel-plugin-transform-svg-component": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/@svgr/babel-plugin-transform-svg-component/-/babel-plugin-transform-svg-component-5.5.0.tgz", - "integrity": "sha512-q4jSH1UUvbrsOtlo/tKcgSeiCHRSBdXoIoqX1pgcKK/aU3JD27wmMKwGtpB8qRYUYoyXvfGxUVKchLuR5pB3rQ==", - "engines": { - "node": ">=10" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/gregberge" - } - }, - "node_modules/@svgr/babel-preset": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/@svgr/babel-preset/-/babel-preset-5.5.0.tgz", - "integrity": "sha512-4FiXBjvQ+z2j7yASeGPEi8VD/5rrGQk4Xrq3EdJmoZgz/tpqChpo5hgXDvmEauwtvOc52q8ghhZK4Oy7qph4ig==", - "dependencies": { - "@svgr/babel-plugin-add-jsx-attribute": "^5.4.0", - "@svgr/babel-plugin-remove-jsx-attribute": "^5.4.0", - "@svgr/babel-plugin-remove-jsx-empty-expression": "^5.0.1", - "@svgr/babel-plugin-replace-jsx-attribute-value": "^5.0.1", - "@svgr/babel-plugin-svg-dynamic-title": "^5.4.0", - "@svgr/babel-plugin-svg-em-dimensions": "^5.4.0", - "@svgr/babel-plugin-transform-react-native-svg": "^5.4.0", - "@svgr/babel-plugin-transform-svg-component": "^5.5.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/gregberge" - } - }, - "node_modules/@svgr/core": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/@svgr/core/-/core-5.5.0.tgz", - "integrity": "sha512-q52VOcsJPvV3jO1wkPtzTuKlvX7Y3xIcWRpCMtBF3MrteZJtBfQw/+u0B1BHy5ColpQc1/YVTrPEtSYIMNZlrQ==", - "dependencies": { - "@svgr/plugin-jsx": "^5.5.0", - "camelcase": "^6.2.0", - "cosmiconfig": "^7.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/gregberge" - } - }, - "node_modules/@svgr/hast-util-to-babel-ast": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/@svgr/hast-util-to-babel-ast/-/hast-util-to-babel-ast-5.5.0.tgz", - "integrity": "sha512-cAaR/CAiZRB8GP32N+1jocovUtvlj0+e65TB50/6Lcime+EA49m/8l+P2ko+XPJ4dw3xaPS3jOL4F2X4KWxoeQ==", - "dependencies": { - "@babel/types": "^7.12.6" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/gregberge" - } - }, - "node_modules/@svgr/plugin-jsx": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/@svgr/plugin-jsx/-/plugin-jsx-5.5.0.tgz", - "integrity": "sha512-V/wVh33j12hGh05IDg8GpIUXbjAPnTdPTKuP4VNLggnwaHMPNQNae2pRnyTAILWCQdz5GyMqtO488g7CKM8CBA==", - "dependencies": { - "@babel/core": "^7.12.3", - "@svgr/babel-preset": "^5.5.0", - "@svgr/hast-util-to-babel-ast": "^5.5.0", - "svg-parser": "^2.0.2" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/gregberge" - } - }, - "node_modules/@svgr/plugin-svgo": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/@svgr/plugin-svgo/-/plugin-svgo-5.5.0.tgz", - "integrity": "sha512-r5swKk46GuQl4RrVejVwpeeJaydoxkdwkM1mBKOgJLBUJPGaLci6ylg/IjhrRsREKDkr4kbMWdgOtbXEh0fyLQ==", - "dependencies": { - "cosmiconfig": "^7.0.0", - "deepmerge": "^4.2.2", - "svgo": "^1.2.2" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/gregberge" - } - }, - "node_modules/@svgr/webpack": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/@svgr/webpack/-/webpack-5.5.0.tgz", - "integrity": "sha512-DOBOK255wfQxguUta2INKkzPj6AIS6iafZYiYmHn6W3pHlycSRRlvWKCfLDG10fXfLWqE3DJHgRUOyJYmARa7g==", - "dependencies": { - "@babel/core": "^7.12.3", - "@babel/plugin-transform-react-constant-elements": "^7.12.1", - "@babel/preset-env": "^7.12.1", - "@babel/preset-react": "^7.12.5", - "@svgr/core": "^5.5.0", - "@svgr/plugin-jsx": "^5.5.0", - "@svgr/plugin-svgo": "^5.5.0", - "loader-utils": "^2.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/gregberge" - } - }, - "node_modules/@tabler/icons": { - "version": "2.20.0", - "resolved": "https://registry.npmjs.org/@tabler/icons/-/icons-2.20.0.tgz", - "integrity": "sha512-BsUEJoqREs8bqcrf5HfJBq6/rDvsRI3h+T+0X1o7i8LBHonsH0iAngcyL0I82YKoSy9NiVDvM3LV63zDP0nPYQ==", - "funding": { - "type": "github", - "url": "https://github.com/sponsors/codecalm" - } - }, - "node_modules/@tabler/icons-react": { - "version": "2.20.0", - "resolved": "https://registry.npmjs.org/@tabler/icons-react/-/icons-react-2.20.0.tgz", - "integrity": "sha512-r2uC0Mi3ozHD2G+IYi0A0Iy2203dbQo5EAFxn055MyIhH7U2VNsvyopTqOj+AVedy7cqR86T9zhryRUGC78WZA==", - "dependencies": { - "@tabler/icons": "2.20.0", - "prop-types": "^15.7.2" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/codecalm" - }, - "peerDependencies": { - "react": "^16.5.1 || ^17.0.0 || ^18.0.0" - } - }, - "node_modules/@tensorflow/tfjs": { - "version": "4.13.0", - "resolved": "https://registry.npmjs.org/@tensorflow/tfjs/-/tfjs-4.13.0.tgz", - "integrity": "sha512-yvjcNMt1q9CLUeOVwoNf0KyMg//fY9earGQGH91C+NcacOK4j0BJUJUqMolEJqfHIbmK2n2CIFmdvgA5epVPSA==", - "dependencies": { - "@tensorflow/tfjs-backend-cpu": "4.13.0", - "@tensorflow/tfjs-backend-webgl": "4.13.0", - "@tensorflow/tfjs-converter": "4.13.0", - "@tensorflow/tfjs-core": "4.13.0", - "@tensorflow/tfjs-data": "4.13.0", - "@tensorflow/tfjs-layers": "4.13.0", - "argparse": "^1.0.10", - "chalk": "^4.1.0", - "core-js": "3.29.1", - "regenerator-runtime": "^0.13.5", - "yargs": "^16.0.3" - }, - "bin": { - "tfjs-custom-module": "dist/tools/custom_module/cli.js" - } - }, - "node_modules/@tensorflow/tfjs-backend-cpu": { - "version": "4.13.0", - "resolved": "https://registry.npmjs.org/@tensorflow/tfjs-backend-cpu/-/tfjs-backend-cpu-4.13.0.tgz", - "integrity": "sha512-k44G+2WZShxI2ejvQdsSQcicFMNWaccsf6bkI0R7dol9t9uj73yg7JkiT0U0uuJE6XwXymJgDe+KJVprg3fAgA==", - "dependencies": { - "@types/seedrandom": "^2.4.28", - "seedrandom": "^3.0.5" - }, - "engines": { - "yarn": ">= 1.3.2" - }, - "peerDependencies": { - "@tensorflow/tfjs-core": "4.13.0" - } - }, - "node_modules/@tensorflow/tfjs-backend-webgl": { - "version": "4.13.0", - "resolved": "https://registry.npmjs.org/@tensorflow/tfjs-backend-webgl/-/tfjs-backend-webgl-4.13.0.tgz", - "integrity": "sha512-UDwn6o70GyZaVxWdGWrWYJad2tUbxqgLtGfZI19j5EmM554PVsGLd+VHOqv4XodTviawuNq/GzqSdqhqsp8f5w==", - "dependencies": { - "@tensorflow/tfjs-backend-cpu": "4.13.0", - "@types/offscreencanvas": "~2019.3.0", - "@types/seedrandom": "^2.4.28", - "seedrandom": "^3.0.5" - }, - "engines": { - "yarn": ">= 1.3.2" - }, - "peerDependencies": { - "@tensorflow/tfjs-core": "4.13.0" - } - }, - "node_modules/@tensorflow/tfjs-converter": { - "version": "4.13.0", - "resolved": "https://registry.npmjs.org/@tensorflow/tfjs-converter/-/tfjs-converter-4.13.0.tgz", - "integrity": "sha512-jA2/IigBXReZHS8Bo308HG7oVzsNPnPgSYfXneRXnxUz+WfcIPkJ6zp48KERZSPja8vOO5eNG4lsUkQpbtiyyw==", - "peerDependencies": { - "@tensorflow/tfjs-core": "4.13.0" - } - }, - "node_modules/@tensorflow/tfjs-core": { - "version": "4.13.0", - "resolved": "https://registry.npmjs.org/@tensorflow/tfjs-core/-/tfjs-core-4.13.0.tgz", - "integrity": "sha512-vvz/kHakvv5Tppp2GDTUBA2/XkNmEkManbdsFEXfwVc5+rVMPEMsRFOjsKTy/TpDRd/4wsJBA99L4F7iG2tr/Q==", - "dependencies": { - "@types/long": "^4.0.1", - "@types/offscreencanvas": "~2019.7.0", - "@types/seedrandom": "^2.4.28", - "@webgpu/types": "0.1.30", - "long": "4.0.0", - "node-fetch": "~2.6.1", - "seedrandom": "^3.0.5" - }, - "engines": { - "yarn": ">= 1.3.2" - } - }, - "node_modules/@tensorflow/tfjs-core/node_modules/@types/offscreencanvas": { - "version": "2019.7.3", - "resolved": "https://registry.npmjs.org/@types/offscreencanvas/-/offscreencanvas-2019.7.3.tgz", - "integrity": "sha512-ieXiYmgSRXUDeOntE1InxjWyvEelZGP63M+cGuquuRLuIKKT1osnkXjxev9B7d1nXSug5vpunx+gNlbVxMlC9A==" - }, - "node_modules/@tensorflow/tfjs-data": { - "version": "4.13.0", - "resolved": "https://registry.npmjs.org/@tensorflow/tfjs-data/-/tfjs-data-4.13.0.tgz", - "integrity": "sha512-8FmvzGKBH3SJ3Y+vDTF/coFxD/FMh93YRZHxevNGE+nJcs3JK0grRbjSX3AAWb2GXtz2/o30BU0YL8bW8POuUA==", - "dependencies": { - "@types/node-fetch": "^2.1.2", - "node-fetch": "~2.6.1", - "string_decoder": "^1.3.0" - }, - "peerDependencies": { - "@tensorflow/tfjs-core": "4.13.0", - "seedrandom": "^3.0.5" - } - }, - "node_modules/@tensorflow/tfjs-layers": { - "version": "4.13.0", - "resolved": "https://registry.npmjs.org/@tensorflow/tfjs-layers/-/tfjs-layers-4.13.0.tgz", - "integrity": "sha512-YoBqtVTnE71h48+f89G6ZSYZMN+QsUMccopSxQC6XscncB6Gt1KwuWfpDc2Ld5JeubmUzKLqHdEP0jXIWxssJw==", - "peerDependencies": { - "@tensorflow/tfjs-core": "4.13.0" - } - }, - "node_modules/@tensorflow/tfjs-node": { - "version": "1.7.4", - "resolved": "https://registry.npmjs.org/@tensorflow/tfjs-node/-/tfjs-node-1.7.4.tgz", - "integrity": "sha512-xcK2NMJI2eOrvDBMrT5RjJSXZPK7B/SFvoSTS+ycpoiPAooeFsDuOcj4YzsgYlSBRyVl9qKHaNn3rWhrTWwG+Q==", - "hasInstallScript": true, - "dependencies": { - "@tensorflow/tfjs": "1.7.4", - "@tensorflow/tfjs-core": "1.7.4", - "adm-zip": "^0.4.11", - "google-protobuf": "^3.9.2", - "https-proxy-agent": "^2.2.1", - "node-pre-gyp": "0.14.0", - "progress": "^2.0.0", - "rimraf": "^2.6.2", - "tar": "^4.4.6" - }, - "engines": { - "node": ">=8.11.0" - } - }, - "node_modules/@tensorflow/tfjs-node/node_modules/@tensorflow/tfjs": { - "version": "1.7.4", - "resolved": "https://registry.npmjs.org/@tensorflow/tfjs/-/tfjs-1.7.4.tgz", - "integrity": "sha512-XWGwRQ/ECEoQacd74JY/dmbLdnMpwtq3H8tls45dQ+GJ553Advir1FDo/aQt0Yr6fTimQDeiOIG4Mcb5KduP/w==", - "dependencies": { - "@tensorflow/tfjs-converter": "1.7.4", - "@tensorflow/tfjs-core": "1.7.4", - "@tensorflow/tfjs-data": "1.7.4", - "@tensorflow/tfjs-layers": "1.7.4" - } - }, - "node_modules/@tensorflow/tfjs-node/node_modules/@tensorflow/tfjs-converter": { - "version": "1.7.4", - "resolved": "https://registry.npmjs.org/@tensorflow/tfjs-converter/-/tfjs-converter-1.7.4.tgz", - "integrity": "sha512-B/Ux9I3osI0CXoESGR0Xe5C6BsEfC04+g2xn5zVaW9KEuVEnGEgnuBQxgijRFzkqTwoyLv4ptAmjyIghVARX0Q==", - "peerDependencies": { - "@tensorflow/tfjs-core": "1.7.4" - } - }, - "node_modules/@tensorflow/tfjs-node/node_modules/@tensorflow/tfjs-core": { - "version": "1.7.4", - "resolved": "https://registry.npmjs.org/@tensorflow/tfjs-core/-/tfjs-core-1.7.4.tgz", - "integrity": "sha512-3G4VKJ6nPs7iCt6gs3bjRj8chihKrYWenf63R0pm7D9MhlrVoX/tpN4LYVMGgBL7jHPxMLKdOkoAZJrn/J88HQ==", - "dependencies": { - "@types/offscreencanvas": "~2019.3.0", - "@types/seedrandom": "2.4.27", - "@types/webgl-ext": "0.0.30", - "@types/webgl2": "0.0.4", - "node-fetch": "~2.1.2", - "seedrandom": "2.4.3" - }, - "engines": { - "yarn": ">= 1.3.2" - } - }, - "node_modules/@tensorflow/tfjs-node/node_modules/@tensorflow/tfjs-core/node_modules/seedrandom": { - "version": "2.4.3", - "resolved": "https://registry.npmjs.org/seedrandom/-/seedrandom-2.4.3.tgz", - "integrity": "sha512-2CkZ9Wn2dS4mMUWQaXLsOAfGD+irMlLEeSP3cMxpGbgyOOzJGFa+MWCOMTOCMyZinHRPxyOj/S/C57li/1to6Q==" - }, - "node_modules/@tensorflow/tfjs-node/node_modules/@tensorflow/tfjs-data": { - "version": "1.7.4", - "resolved": "https://registry.npmjs.org/@tensorflow/tfjs-data/-/tfjs-data-1.7.4.tgz", - "integrity": "sha512-WFYG9wWjNDi62x6o3O20Q0XJxToCw2J4/fBEXiK/Gr0hIqVhl2oLQ1OjTWq7O08NUxM6BRzuG+ra3gWYdQUzOw==", - "dependencies": { - "@types/node-fetch": "^2.1.2", - "node-fetch": "~2.1.2" - }, - "peerDependencies": { - "@tensorflow/tfjs-core": "1.7.4", - "seedrandom": "~2.4.3" - } - }, - "node_modules/@tensorflow/tfjs-node/node_modules/@tensorflow/tfjs-layers": { - "version": "1.7.4", - "resolved": "https://registry.npmjs.org/@tensorflow/tfjs-layers/-/tfjs-layers-1.7.4.tgz", - "integrity": "sha512-5/K8Z8RBfXsucL6EaSeb3/8jB/I8oPaaXkxwKVsBPQ+u6lB6LEtSKzeiFc57nDr5OMtVaUZV+pKDNEzP0RUQlg==", - "peerDependencies": { - "@tensorflow/tfjs-core": "1.7.4" - } - }, - "node_modules/@tensorflow/tfjs-node/node_modules/@types/seedrandom": { - "version": "2.4.27", - "resolved": "https://registry.npmjs.org/@types/seedrandom/-/seedrandom-2.4.27.tgz", - "integrity": "sha512-YvMLqFak/7rt//lPBtEHv3M4sRNA+HGxrhFZ+DQs9K2IkYJbNwVIb8avtJfhDiuaUBX/AW0jnjv48FV8h3u9bQ==" - }, - "node_modules/@tensorflow/tfjs-node/node_modules/agent-base": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-4.3.0.tgz", - "integrity": "sha512-salcGninV0nPrwpGNn4VTXBb1SOuXQBiqbrNXoeizJsHrsL6ERFM2Ne3JUSBWRE6aeNJI2ROP/WEEIDUiDe3cg==", - "dependencies": { - "es6-promisify": "^5.0.0" - }, - "engines": { - "node": ">= 4.0.0" - } - }, - "node_modules/@tensorflow/tfjs-node/node_modules/debug": { - "version": "3.2.7", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", - "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", - "dependencies": { - "ms": "^2.1.1" - } - }, - "node_modules/@tensorflow/tfjs-node/node_modules/https-proxy-agent": { - "version": "2.2.4", - "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-2.2.4.tgz", - "integrity": "sha512-OmvfoQ53WLjtA9HeYP9RNrWMJzzAz1JGaSFr1nijg0PVR1JaD/xbJq1mdEIIlxGpXp9eSe/O2LgU9DJmTPd0Eg==", - "dependencies": { - "agent-base": "^4.3.0", - "debug": "^3.1.0" - }, - "engines": { - "node": ">= 4.5.0" - } - }, - "node_modules/@tensorflow/tfjs-node/node_modules/node-fetch": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.1.2.tgz", - "integrity": "sha512-IHLHYskTc2arMYsHZH82PVX8CSKT5lzb7AXeyO06QnjGDKtkv+pv3mEki6S7reB/x1QPo+YPxQRNEVgR5V/w3Q==", - "engines": { - "node": "4.x || >=6.0.0" - } - }, - "node_modules/@tensorflow/tfjs-node/node_modules/rimraf": { - "version": "2.7.1", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz", - "integrity": "sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==", - "dependencies": { - "glob": "^7.1.3" - }, - "bin": { - "rimraf": "bin.js" - } - }, - "node_modules/@tensorflow/tfjs-node/node_modules/seedrandom": { - "version": "2.4.4", - "resolved": "https://registry.npmjs.org/seedrandom/-/seedrandom-2.4.4.tgz", - "integrity": "sha512-9A+PDmgm+2du77B5i0Ip2cxOqqHjgNxnBgglxLcX78A2D6c2rTo61z4jnVABpF4cKeDMDG+cmXXvdnqse2VqMA==", - "peer": true - }, - "node_modules/@tensorflow/tfjs/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/@tensorflow/tfjs/node_modules/chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dependencies": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" - } - }, - "node_modules/@tensorflow/tfjs/node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/@tensorflow/tfjs/node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" - }, - "node_modules/@tensorflow/tfjs/node_modules/core-js": { - "version": "3.29.1", - "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.29.1.tgz", - "integrity": "sha512-+jwgnhg6cQxKYIIjGtAHq2nwUOolo9eoFZ4sHfUH09BLXBgxnH4gA0zEd+t+BO2cNB8idaBtZFcFTRjQJRJmAw==", - "hasInstallScript": true, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/core-js" - } - }, - "node_modules/@tensorflow/tfjs/node_modules/has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "engines": { - "node": ">=8" - } - }, - "node_modules/@tensorflow/tfjs/node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/@testing-library/dom": { - "version": "9.3.0", - "resolved": "https://registry.npmjs.org/@testing-library/dom/-/dom-9.3.0.tgz", - "integrity": "sha512-Dffe68pGwI6WlLRYR2I0piIkyole9cSBH5jGQKCGMRpHW5RHCqAUaqc2Kv0tUyd4dU4DLPKhJIjyKOnjv4tuUw==", - "peer": true, - "dependencies": { - "@babel/code-frame": "^7.10.4", - "@babel/runtime": "^7.12.5", - "@types/aria-query": "^5.0.1", - "aria-query": "^5.0.0", - "chalk": "^4.1.0", - "dom-accessibility-api": "^0.5.9", - "lz-string": "^1.5.0", - "pretty-format": "^27.0.2" - }, - "engines": { - "node": ">=14" - } - }, - "node_modules/@testing-library/dom/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "peer": true, - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/@testing-library/dom/node_modules/chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "peer": true, - "dependencies": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" - } - }, - "node_modules/@testing-library/dom/node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "peer": true, - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/@testing-library/dom/node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "peer": true - }, - "node_modules/@testing-library/dom/node_modules/has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "peer": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/@testing-library/dom/node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "peer": true, - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/@testing-library/jest-dom": { - "version": "5.16.5", - "resolved": "https://registry.npmjs.org/@testing-library/jest-dom/-/jest-dom-5.16.5.tgz", - "integrity": "sha512-N5ixQ2qKpi5OLYfwQmUb/5mSV9LneAcaUfp32pn4yCnpb8r/Yz0pXFPck21dIicKmi+ta5WRAknkZCfA8refMA==", - "dependencies": { - "@adobe/css-tools": "^4.0.1", - "@babel/runtime": "^7.9.2", - "@types/testing-library__jest-dom": "^5.9.1", - "aria-query": "^5.0.0", - "chalk": "^3.0.0", - "css.escape": "^1.5.1", - "dom-accessibility-api": "^0.5.6", - "lodash": "^4.17.15", - "redent": "^3.0.0" - }, - "engines": { - "node": ">=8", - "npm": ">=6", - "yarn": ">=1" - } - }, - "node_modules/@testing-library/jest-dom/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/@testing-library/jest-dom/node_modules/chalk": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-3.0.0.tgz", - "integrity": "sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg==", - "dependencies": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/@testing-library/jest-dom/node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/@testing-library/jest-dom/node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" - }, - "node_modules/@testing-library/jest-dom/node_modules/has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "engines": { - "node": ">=8" - } - }, - "node_modules/@testing-library/jest-dom/node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/@testing-library/react": { - "version": "13.4.0", - "resolved": "https://registry.npmjs.org/@testing-library/react/-/react-13.4.0.tgz", - "integrity": "sha512-sXOGON+WNTh3MLE9rve97ftaZukN3oNf2KjDy7YTx6hcTO2uuLHuCGynMDhFwGw/jYf4OJ2Qk0i4i79qMNNkyw==", - "dependencies": { - "@babel/runtime": "^7.12.5", - "@testing-library/dom": "^8.5.0", - "@types/react-dom": "^18.0.0" - }, - "engines": { - "node": ">=12" - }, - "peerDependencies": { - "react": "^18.0.0", - "react-dom": "^18.0.0" - } - }, - "node_modules/@testing-library/react/node_modules/@testing-library/dom": { - "version": "8.20.0", - "resolved": "https://registry.npmjs.org/@testing-library/dom/-/dom-8.20.0.tgz", - "integrity": "sha512-d9ULIT+a4EXLX3UU8FBjauG9NnsZHkHztXoIcTsOKoOw030fyjheN9svkTULjJxtYag9DZz5Jz5qkWZDPxTFwA==", - "dependencies": { - "@babel/code-frame": "^7.10.4", - "@babel/runtime": "^7.12.5", - "@types/aria-query": "^5.0.1", - "aria-query": "^5.0.0", - "chalk": "^4.1.0", - "dom-accessibility-api": "^0.5.9", - "lz-string": "^1.4.4", - "pretty-format": "^27.0.2" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/@testing-library/react/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/@testing-library/react/node_modules/chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dependencies": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" - } - }, - "node_modules/@testing-library/react/node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/@testing-library/react/node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" - }, - "node_modules/@testing-library/react/node_modules/has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "engines": { - "node": ">=8" - } - }, - "node_modules/@testing-library/react/node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/@testing-library/user-event": { - "version": "13.5.0", - "resolved": "https://registry.npmjs.org/@testing-library/user-event/-/user-event-13.5.0.tgz", - "integrity": "sha512-5Kwtbo3Y/NowpkbRuSepbyMFkZmHgD+vPzYB/RJ4oxt5Gj/avFFBYjhw27cqSVPVw/3a67NK1PbiIr9k4Gwmdg==", - "dependencies": { - "@babel/runtime": "^7.12.5" - }, - "engines": { - "node": ">=10", - "npm": ">=6" - }, - "peerDependencies": { - "@testing-library/dom": ">=7.21.4" - } - }, - "node_modules/@tiptap/core": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/@tiptap/core/-/core-2.0.3.tgz", - "integrity": "sha512-jLyVIWAdjjlNzrsRhSE2lVL/7N8228/1R1QtaVU85UlMIwHFAcdzhD8FeiKkqxpTnGpaDVaTy7VNEtEgaYdCyA==", - "funding": { - "type": "github", - "url": "https://github.com/sponsors/ueberdosis" - }, - "peerDependencies": { - "@tiptap/pm": "^2.0.0" - } - }, - "node_modules/@tiptap/extension-blockquote": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/@tiptap/extension-blockquote/-/extension-blockquote-2.0.3.tgz", - "integrity": "sha512-rkUcFv2iL6f86DBBHoa4XdKNG2StvkJ7tfY9GoMpT46k3nxOaMTqak9/qZOo79TWxMLYtXzoxtKIkmWsbbcj4A==", - "funding": { - "type": "github", - "url": "https://github.com/sponsors/ueberdosis" - }, - "peerDependencies": { - "@tiptap/core": "^2.0.0" - } - }, - "node_modules/@tiptap/extension-bold": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/@tiptap/extension-bold/-/extension-bold-2.0.3.tgz", - "integrity": "sha512-OGT62fMRovSSayjehumygFWTg2Qn0IDbqyMpigg/RUAsnoOI2yBZFVrdM2gk1StyoSay7gTn2MLw97IUfr7FXg==", - "funding": { - "type": "github", - "url": "https://github.com/sponsors/ueberdosis" - }, - "peerDependencies": { - "@tiptap/core": "^2.0.0" - } - }, - "node_modules/@tiptap/extension-bubble-menu": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/@tiptap/extension-bubble-menu/-/extension-bubble-menu-2.0.3.tgz", - "integrity": "sha512-lPt1ELrYCuoQrQEUukqjp9xt38EwgPUwaKHI3wwt2Rbv+C6q1gmRsK1yeO/KqCNmFxNqF2p9ZF9srOnug/RZDQ==", - "dependencies": { - "tippy.js": "^6.3.7" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/ueberdosis" - }, - "peerDependencies": { - "@tiptap/core": "^2.0.0", - "@tiptap/pm": "^2.0.0" - } - }, - "node_modules/@tiptap/extension-bullet-list": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/@tiptap/extension-bullet-list/-/extension-bullet-list-2.0.3.tgz", - "integrity": "sha512-RtaLiRvZbMTOje+FW5bn+mYogiIgNxOm065wmyLPypnTbLSeHeYkoqVSqzZeqUn+7GLnwgn1shirUe6csVE/BA==", - "funding": { - "type": "github", - "url": "https://github.com/sponsors/ueberdosis" - }, - "peerDependencies": { - "@tiptap/core": "^2.0.0" - } - }, - "node_modules/@tiptap/extension-code": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/@tiptap/extension-code/-/extension-code-2.0.3.tgz", - "integrity": "sha512-LsVCKVxgBtkstAr1FjxN8T3OjlC76a2X8ouoZpELMp+aXbjqyanCKzt+sjjUhE4H0yLFd4v+5v6UFoCv4EILiw==", - "funding": { - "type": "github", - "url": "https://github.com/sponsors/ueberdosis" - }, - "peerDependencies": { - "@tiptap/core": "^2.0.0" - } - }, - "node_modules/@tiptap/extension-code-block": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/@tiptap/extension-code-block/-/extension-code-block-2.0.3.tgz", - "integrity": "sha512-F4xMy18EwgpyY9f5Te7UuF7UwxRLptOtCq1p2c2DfxBvHDWhAjQqVqcW/sq/I/WuED7FwCnPLyyAasPiVPkLPw==", - "funding": { - "type": "github", - "url": "https://github.com/sponsors/ueberdosis" - }, - "peerDependencies": { - "@tiptap/core": "^2.0.0", - "@tiptap/pm": "^2.0.0" - } - }, - "node_modules/@tiptap/extension-document": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/@tiptap/extension-document/-/extension-document-2.0.3.tgz", - "integrity": "sha512-PsYeNQQBYIU9ayz1R11Kv/kKNPFNIV8tApJ9pxelXjzcAhkjncNUazPN/dyho60mzo+WpsmS3ceTj/gK3bCtWA==", - "funding": { - "type": "github", - "url": "https://github.com/sponsors/ueberdosis" - }, - "peerDependencies": { - "@tiptap/core": "^2.0.0" - } - }, - "node_modules/@tiptap/extension-dropcursor": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/@tiptap/extension-dropcursor/-/extension-dropcursor-2.0.3.tgz", - "integrity": "sha512-McthMrfusn6PjcaynJLheZJcXto8TaIW5iVitYh8qQrDXr31MALC/5GvWuiswmQ8bAXiWPwlLDYE/OJfwtggaw==", - "funding": { - "type": "github", - "url": "https://github.com/sponsors/ueberdosis" - }, - "peerDependencies": { - "@tiptap/core": "^2.0.0", - "@tiptap/pm": "^2.0.0" - } - }, - "node_modules/@tiptap/extension-floating-menu": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/@tiptap/extension-floating-menu/-/extension-floating-menu-2.0.3.tgz", - "integrity": "sha512-zN1vRGRvyK3pO2aHRmQSOTpl4UJraXYwKYM009n6WviYKUNm0LPGo+VD4OAtdzUhPXyccnlsTv2p6LIqFty6Bg==", - "dependencies": { - "tippy.js": "^6.3.7" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/ueberdosis" - }, - "peerDependencies": { - "@tiptap/core": "^2.0.0", - "@tiptap/pm": "^2.0.0" - } - }, - "node_modules/@tiptap/extension-gapcursor": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/@tiptap/extension-gapcursor/-/extension-gapcursor-2.0.3.tgz", - "integrity": "sha512-6I9EzzsYOyyqDvDvxIK6Rv3EXB+fHKFj8ntHO8IXmeNJ6pkhOinuXVsW6Yo7TcDYoTj4D5I2MNFAW2rIkgassw==", - "funding": { - "type": "github", - "url": "https://github.com/sponsors/ueberdosis" - }, - "peerDependencies": { - "@tiptap/core": "^2.0.0", - "@tiptap/pm": "^2.0.0" - } - }, - "node_modules/@tiptap/extension-hard-break": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/@tiptap/extension-hard-break/-/extension-hard-break-2.0.3.tgz", - "integrity": "sha512-RCln6ARn16jvKTjhkcAD5KzYXYS0xRMc0/LrHeV8TKdCd4Yd0YYHe0PU4F9gAgAfPQn7Dgt4uTVJLN11ICl8sQ==", - "funding": { - "type": "github", - "url": "https://github.com/sponsors/ueberdosis" - }, - "peerDependencies": { - "@tiptap/core": "^2.0.0" - } - }, - "node_modules/@tiptap/extension-heading": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/@tiptap/extension-heading/-/extension-heading-2.0.3.tgz", - "integrity": "sha512-f0IEv5ms6aCzL80WeZ1qLCXTkRVwbpRr1qAETjg3gG4eoJN18+lZNOJYpyZy3P92C5KwF2T3Av00eFyVLIbb8Q==", - "funding": { - "type": "github", - "url": "https://github.com/sponsors/ueberdosis" - }, - "peerDependencies": { - "@tiptap/core": "^2.0.0" - } - }, - "node_modules/@tiptap/extension-history": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/@tiptap/extension-history/-/extension-history-2.0.3.tgz", - "integrity": "sha512-00KHIcJ8kivn2ARI6NQYphv2LfllVCXViHGm0EhzDW6NQxCrriJKE3tKDcTFCu7LlC5doMpq9Z6KXdljc4oVeQ==", - "funding": { - "type": "github", - "url": "https://github.com/sponsors/ueberdosis" - }, - "peerDependencies": { - "@tiptap/core": "^2.0.0", - "@tiptap/pm": "^2.0.0" - } - }, - "node_modules/@tiptap/extension-horizontal-rule": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/@tiptap/extension-horizontal-rule/-/extension-horizontal-rule-2.0.3.tgz", - "integrity": "sha512-SZRUSh07b/M0kJHNKnfBwBMWrZBEm/E2LrK1NbluwT3DBhE+gvwiEdBxgB32zKHNxaDEXUJwUIPNC3JSbKvPUA==", - "funding": { - "type": "github", - "url": "https://github.com/sponsors/ueberdosis" - }, - "peerDependencies": { - "@tiptap/core": "^2.0.0", - "@tiptap/pm": "^2.0.0" - } - }, - "node_modules/@tiptap/extension-italic": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/@tiptap/extension-italic/-/extension-italic-2.0.3.tgz", - "integrity": "sha512-cfS5sW0gu7qf4ihwnLtW/QMTBrBEXaT0sJl3RwkhjIBg/65ywJKE5Nz9ewnQHmDeT18hvMJJ1VIb4j4ze9jj9A==", - "funding": { - "type": "github", - "url": "https://github.com/sponsors/ueberdosis" - }, - "peerDependencies": { - "@tiptap/core": "^2.0.0" - } - }, - "node_modules/@tiptap/extension-link": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/@tiptap/extension-link/-/extension-link-2.0.3.tgz", - "integrity": "sha512-H72tXQ5rkVCkAhFaf08fbEU7EBUCK0uocsqOF+4th9sOlrhfgyJtc8Jv5EXPDpxNgG5jixSqWBo0zKXQm9s9eg==", - "dependencies": { - "linkifyjs": "^4.1.0" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/ueberdosis" - }, - "peerDependencies": { - "@tiptap/core": "^2.0.0", - "@tiptap/pm": "^2.0.0" - } - }, - "node_modules/@tiptap/extension-list-item": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/@tiptap/extension-list-item/-/extension-list-item-2.0.3.tgz", - "integrity": "sha512-p7cUsk0LpM1PfdAuFE8wYBNJ3gvA0UhNGR08Lo++rt9UaCeFLSN1SXRxg97c0oa5+Ski7SrCjIJ5Ynhz0viTjQ==", - "funding": { - "type": "github", - "url": "https://github.com/sponsors/ueberdosis" - }, - "peerDependencies": { - "@tiptap/core": "^2.0.0" - } - }, - "node_modules/@tiptap/extension-ordered-list": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/@tiptap/extension-ordered-list/-/extension-ordered-list-2.0.3.tgz", - "integrity": "sha512-ZB3MpZh/GEy1zKgw7XDQF4FIwycZWNof1k9WbDZOI063Ch4qHZowhVttH2mTCELuyvTMM/o9a8CS7qMqQB48bw==", - "funding": { - "type": "github", - "url": "https://github.com/sponsors/ueberdosis" - }, - "peerDependencies": { - "@tiptap/core": "^2.0.0" - } - }, - "node_modules/@tiptap/extension-paragraph": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/@tiptap/extension-paragraph/-/extension-paragraph-2.0.3.tgz", - "integrity": "sha512-a+tKtmj4bU3GVCH1NE8VHWnhVexxX5boTVxsHIr4yGG3UoKo1c5AO7YMaeX2W5xB5iIA+BQqOPCDPEAx34dd2A==", - "funding": { - "type": "github", - "url": "https://github.com/sponsors/ueberdosis" - }, - "peerDependencies": { - "@tiptap/core": "^2.0.0" - } - }, - "node_modules/@tiptap/extension-strike": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/@tiptap/extension-strike/-/extension-strike-2.0.3.tgz", - "integrity": "sha512-RO4/EYe2iPD6ifDHORT8fF6O9tfdtnzxLGwZIKZXnEgtweH+MgoqevEzXYdS+54Wraq4TUQGNcsYhe49pv7Rlw==", - "funding": { - "type": "github", - "url": "https://github.com/sponsors/ueberdosis" - }, - "peerDependencies": { - "@tiptap/core": "^2.0.0" - } - }, - "node_modules/@tiptap/extension-text": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/@tiptap/extension-text/-/extension-text-2.0.3.tgz", - "integrity": "sha512-LvzChcTCcPSMNLUjZe/A9SHXWGDHtvk73fR7CBqAeNU0MxhBPEBI03GFQ6RzW3xX0CmDmjpZoDxFMB+hDEtW1A==", - "funding": { - "type": "github", - "url": "https://github.com/sponsors/ueberdosis" - }, - "peerDependencies": { - "@tiptap/core": "^2.0.0" - } - }, - "node_modules/@tiptap/pm": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/@tiptap/pm/-/pm-2.0.3.tgz", - "integrity": "sha512-I9dsInD89Agdm1QjFRO9dmJtU1ldVSILNPW0pEhv9wYqYVvl4HUj/JMtYNqu2jWrCHNXQcaX/WkdSdvGJtmg5g==", - "peer": true, - "dependencies": { - "prosemirror-changeset": "^2.2.0", - "prosemirror-collab": "^1.3.0", - "prosemirror-commands": "^1.3.1", - "prosemirror-dropcursor": "^1.5.0", - "prosemirror-gapcursor": "^1.3.1", - "prosemirror-history": "^1.3.0", - "prosemirror-inputrules": "^1.2.0", - "prosemirror-keymap": "^1.2.0", - "prosemirror-markdown": "^1.10.1", - "prosemirror-menu": "^1.2.1", - "prosemirror-model": "^1.18.1", - "prosemirror-schema-basic": "^1.2.0", - "prosemirror-schema-list": "^1.2.2", - "prosemirror-state": "^1.4.1", - "prosemirror-tables": "^1.3.0", - "prosemirror-trailing-node": "^2.0.2", - "prosemirror-transform": "^1.7.0", - "prosemirror-view": "^1.28.2" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/ueberdosis" - }, - "peerDependencies": { - "@tiptap/core": "^2.0.0" - } - }, - "node_modules/@tiptap/react": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/@tiptap/react/-/react-2.0.3.tgz", - "integrity": "sha512-fiAh8Lk+/NBPAR/PE4Kc/aLiBUbUYI/CpAopz8DI9eInNyV8h8LAGa9uFILJQF/TNu0tclJ4rV0sWc7Se0FZMw==", - "dependencies": { - "@tiptap/extension-bubble-menu": "^2.0.3", - "@tiptap/extension-floating-menu": "^2.0.3" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/ueberdosis" - }, - "peerDependencies": { - "@tiptap/core": "^2.0.0", - "@tiptap/pm": "^2.0.0", - "react": "^17.0.0 || ^18.0.0", - "react-dom": "^17.0.0 || ^18.0.0" - } - }, - "node_modules/@tiptap/starter-kit": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/@tiptap/starter-kit/-/starter-kit-2.0.3.tgz", - "integrity": "sha512-t4WG4w93zTpL2VxhVyJJvl3kdLF001ZrhpOuEiZqEMBMUMbM56Uiigv1CnUQpTFrjDAh3IM8hkqzAh20TYw2iQ==", - "dependencies": { - "@tiptap/core": "^2.0.3", - "@tiptap/extension-blockquote": "^2.0.3", - "@tiptap/extension-bold": "^2.0.3", - "@tiptap/extension-bullet-list": "^2.0.3", - "@tiptap/extension-code": "^2.0.3", - "@tiptap/extension-code-block": "^2.0.3", - "@tiptap/extension-document": "^2.0.3", - "@tiptap/extension-dropcursor": "^2.0.3", - "@tiptap/extension-gapcursor": "^2.0.3", - "@tiptap/extension-hard-break": "^2.0.3", - "@tiptap/extension-heading": "^2.0.3", - "@tiptap/extension-history": "^2.0.3", - "@tiptap/extension-horizontal-rule": "^2.0.3", - "@tiptap/extension-italic": "^2.0.3", - "@tiptap/extension-list-item": "^2.0.3", - "@tiptap/extension-ordered-list": "^2.0.3", - "@tiptap/extension-paragraph": "^2.0.3", - "@tiptap/extension-strike": "^2.0.3", - "@tiptap/extension-text": "^2.0.3" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/ueberdosis" - } - }, - "node_modules/@tootallnate/once": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/@tootallnate/once/-/once-1.1.2.tgz", - "integrity": "sha512-RbzJvlNzmRq5c3O09UipeuXno4tA1FE6ikOjxZK0tuxVv3412l64l5t1W5pj4+rJq9vpkm/kwiR07aZXnsKPxw==", - "engines": { - "node": ">= 6" - } - }, - "node_modules/@trysound/sax": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/@trysound/sax/-/sax-0.2.0.tgz", - "integrity": "sha512-L7z9BgrNEcYyUYtF+HaEfiS5ebkh9jXqbszz7pC0hRBPaatV0XjSD3+eHrpqFemQfgwiFF0QPIarnIihIDn7OA==", - "engines": { - "node": ">=10.13.0" - } - }, - "node_modules/@types/aria-query": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/@types/aria-query/-/aria-query-5.0.1.tgz", - "integrity": "sha512-XTIieEY+gvJ39ChLcB4If5zHtPxt3Syj5rgZR+e1ctpmK8NjPf0zFqsz4JpLJT0xla9GFDKjy8Cpu331nrmE1Q==" - }, - "node_modules/@types/babel__core": { - "version": "7.20.0", - "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.20.0.tgz", - "integrity": "sha512-+n8dL/9GWblDO0iU6eZAwEIJVr5DWigtle+Q6HLOrh/pdbXOhOtqzq8VPPE2zvNJzSKY4vH/z3iT3tn0A3ypiQ==", - "dependencies": { - "@babel/parser": "^7.20.7", - "@babel/types": "^7.20.7", - "@types/babel__generator": "*", - "@types/babel__template": "*", - "@types/babel__traverse": "*" - } - }, - "node_modules/@types/babel__generator": { - "version": "7.6.4", - "resolved": "https://registry.npmjs.org/@types/babel__generator/-/babel__generator-7.6.4.tgz", - "integrity": "sha512-tFkciB9j2K755yrTALxD44McOrk+gfpIpvC3sxHjRawj6PfnQxrse4Clq5y/Rq+G3mrBurMax/lG8Qn2t9mSsg==", - "dependencies": { - "@babel/types": "^7.0.0" - } - }, - "node_modules/@types/babel__template": { - "version": "7.4.1", - "resolved": "https://registry.npmjs.org/@types/babel__template/-/babel__template-7.4.1.tgz", - "integrity": "sha512-azBFKemX6kMg5Io+/rdGT0dkGreboUVR0Cdm3fz9QJWpaQGJRQXl7C+6hOTCZcMll7KFyEQpgbYI2lHdsS4U7g==", - "dependencies": { - "@babel/parser": "^7.1.0", - "@babel/types": "^7.0.0" - } - }, - "node_modules/@types/babel__traverse": { - "version": "7.18.5", - "resolved": "https://registry.npmjs.org/@types/babel__traverse/-/babel__traverse-7.18.5.tgz", - "integrity": "sha512-enCvTL8m/EHS/zIvJno9nE+ndYPh1/oNFzRYRmtUqJICG2VnCSBzMLW5VN2KCQU91f23tsNKR8v7VJJQMatl7Q==", - "dependencies": { - "@babel/types": "^7.3.0" - } - }, - "node_modules/@types/body-parser": { - "version": "1.19.2", - "resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.19.2.tgz", - "integrity": "sha512-ALYone6pm6QmwZoAgeyNksccT9Q4AWZQ6PvfwR37GT6r6FWUPguq6sUmNGSMV2Wr761oQoBxwGGa6DR5o1DC9g==", - "dependencies": { - "@types/connect": "*", - "@types/node": "*" - } - }, - "node_modules/@types/bonjour": { - "version": "3.5.10", - "resolved": "https://registry.npmjs.org/@types/bonjour/-/bonjour-3.5.10.tgz", - "integrity": "sha512-p7ienRMiS41Nu2/igbJxxLDWrSZ0WxM8UQgCeO9KhoVF7cOVFkrKsiDr1EsJIla8vV3oEEjGcz11jc5yimhzZw==", - "dependencies": { - "@types/node": "*" - } - }, - "node_modules/@types/connect": { - "version": "3.4.35", - "resolved": "https://registry.npmjs.org/@types/connect/-/connect-3.4.35.tgz", - "integrity": "sha512-cdeYyv4KWoEgpBISTxWvqYsVy444DOqehiF3fM3ne10AmJ62RSyNkUnxMJXHQWRQQX2eR94m5y1IZyDwBjV9FQ==", - "dependencies": { - "@types/node": "*" - } - }, - "node_modules/@types/connect-history-api-fallback": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/@types/connect-history-api-fallback/-/connect-history-api-fallback-1.5.0.tgz", - "integrity": "sha512-4x5FkPpLipqwthjPsF7ZRbOv3uoLUFkTA9G9v583qi4pACvq0uTELrB8OLUzPWUI4IJIyvM85vzkV1nyiI2Lig==", - "dependencies": { - "@types/express-serve-static-core": "*", - "@types/node": "*" - } - }, - "node_modules/@types/cookie": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/@types/cookie/-/cookie-0.4.1.tgz", - "integrity": "sha512-XW/Aa8APYr6jSVVA1y/DEIZX0/GMKLEVekNG727R8cs56ahETkRAy/3DR7+fJyh7oUgGwNQaRfXCun0+KbWY7Q==" - }, - "node_modules/@types/cors": { - "version": "2.8.17", - "resolved": "https://registry.npmjs.org/@types/cors/-/cors-2.8.17.tgz", - "integrity": "sha512-8CGDvrBj1zgo2qE+oS3pOCyYNqCPryMWY2bGfwA0dcfopWGgxs+78df0Rs3rc9THP4JkOhLsAa+15VdpAqkcUA==", - "dependencies": { - "@types/node": "*" - } - }, - "node_modules/@types/eslint": { - "version": "8.37.0", - "resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.37.0.tgz", - "integrity": "sha512-Piet7dG2JBuDIfohBngQ3rCt7MgO9xCO4xIMKxBThCq5PNRB91IjlJ10eJVwfoNtvTErmxLzwBZ7rHZtbOMmFQ==", - "dependencies": { - "@types/estree": "*", - "@types/json-schema": "*" - } - }, - "node_modules/@types/eslint-scope": { - "version": "3.7.4", - "resolved": "https://registry.npmjs.org/@types/eslint-scope/-/eslint-scope-3.7.4.tgz", - "integrity": "sha512-9K4zoImiZc3HlIp6AVUDE4CWYx22a+lhSZMYNpbjW04+YF0KWj4pJXnEMjdnFTiQibFFmElcsasJXDbdI/EPhA==", - "dependencies": { - "@types/eslint": "*", - "@types/estree": "*" - } - }, - "node_modules/@types/estree": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.1.tgz", - "integrity": "sha512-LG4opVs2ANWZ1TJoKc937iMmNstM/d0ae1vNbnBvBhqCSezgVUOzcLCqbI5elV8Vy6WKwKjaqR+zO9VKirBBCA==" - }, - "node_modules/@types/express": { - "version": "4.17.17", - "resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.17.tgz", - "integrity": "sha512-Q4FmmuLGBG58btUnfS1c1r/NQdlp3DMfGDGig8WhfpA2YRUtEkxAjkZb0yvplJGYdF1fsQ81iMDcH24sSCNC/Q==", - "dependencies": { - "@types/body-parser": "*", - "@types/express-serve-static-core": "^4.17.33", - "@types/qs": "*", - "@types/serve-static": "*" - } - }, - "node_modules/@types/express-serve-static-core": { - "version": "4.17.35", - "resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.17.35.tgz", - "integrity": "sha512-wALWQwrgiB2AWTT91CB62b6Yt0sNHpznUXeZEcnPU3DRdlDIz74x8Qg1UUYKSVFi+va5vKOLYRBI1bRKiLLKIg==", - "dependencies": { - "@types/node": "*", - "@types/qs": "*", - "@types/range-parser": "*", - "@types/send": "*" - } - }, - "node_modules/@types/graceful-fs": { - "version": "4.1.6", - "resolved": "https://registry.npmjs.org/@types/graceful-fs/-/graceful-fs-4.1.6.tgz", - "integrity": "sha512-Sig0SNORX9fdW+bQuTEovKj3uHcUL6LQKbCrrqb1X7J6/ReAbhCXRAhc+SMejhLELFj2QcyuxmUooZ4bt5ReSw==", - "dependencies": { - "@types/node": "*" - } - }, - "node_modules/@types/html-minifier-terser": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/@types/html-minifier-terser/-/html-minifier-terser-6.1.0.tgz", - "integrity": "sha512-oh/6byDPnL1zeNXFrDXFLyZjkr1MsBG667IM792caf1L2UPOOMf65NFzjUH/ltyfwjAGfs1rsX1eftK0jC/KIg==" - }, - "node_modules/@types/http-proxy": { - "version": "1.17.11", - "resolved": "https://registry.npmjs.org/@types/http-proxy/-/http-proxy-1.17.11.tgz", - "integrity": "sha512-HC8G7c1WmaF2ekqpnFq626xd3Zz0uvaqFmBJNRZCGEZCXkvSdJoNFn/8Ygbd9fKNQj8UzLdCETaI0UWPAjK7IA==", - "dependencies": { - "@types/node": "*" - } - }, - "node_modules/@types/istanbul-lib-coverage": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.4.tgz", - "integrity": "sha512-z/QT1XN4K4KYuslS23k62yDIDLwLFkzxOuMplDtObz0+y7VqJCaO2o+SPwHCvLFZh7xazvvoor2tA/hPz9ee7g==" - }, - "node_modules/@types/istanbul-lib-report": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/@types/istanbul-lib-report/-/istanbul-lib-report-3.0.0.tgz", - "integrity": "sha512-plGgXAPfVKFoYfa9NpYDAkseG+g6Jr294RqeqcqDixSbU34MZVJRi/P+7Y8GDpzkEwLaGZZOpKIEmeVZNtKsrg==", - "dependencies": { - "@types/istanbul-lib-coverage": "*" - } - }, - "node_modules/@types/istanbul-reports": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/@types/istanbul-reports/-/istanbul-reports-3.0.1.tgz", - "integrity": "sha512-c3mAZEuK0lvBp8tmuL74XRKn1+y2dcwOUpH7x4WrF6gk1GIgiluDRgMYQtw2OFcBvAJWlt6ASU3tSqxp0Uu0Aw==", - "dependencies": { - "@types/istanbul-lib-report": "*" - } - }, - "node_modules/@types/jest": { - "version": "29.5.1", - "resolved": "https://registry.npmjs.org/@types/jest/-/jest-29.5.1.tgz", - "integrity": "sha512-tEuVcHrpaixS36w7hpsfLBLpjtMRJUE09/MHXn923LOVojDwyC14cWcfc0rDs0VEfUyYmt/+iX1kxxp+gZMcaQ==", - "dependencies": { - "expect": "^29.0.0", - "pretty-format": "^29.0.0" - } - }, - "node_modules/@types/jest/node_modules/@jest/schemas": { - "version": "29.4.3", - "resolved": "https://registry.npmjs.org/@jest/schemas/-/schemas-29.4.3.tgz", - "integrity": "sha512-VLYKXQmtmuEz6IxJsrZwzG9NvtkQsWNnWMsKxqWNu3+CnfzJQhp0WDDKWLVV9hLKr0l3SLLFRqcYHjhtyuDVxg==", - "dependencies": { - "@sinclair/typebox": "^0.25.16" - }, - "engines": { - "node": "^14.15.0 || ^16.10.0 || >=18.0.0" - } - }, - "node_modules/@types/jest/node_modules/@jest/types": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/@jest/types/-/types-29.5.0.tgz", - "integrity": "sha512-qbu7kN6czmVRc3xWFQcAN03RAUamgppVUdXrvl1Wr3jlNF93o9mJbGcDWrwGB6ht44u7efB1qCFgVQmca24Uog==", - "dependencies": { - "@jest/schemas": "^29.4.3", - "@types/istanbul-lib-coverage": "^2.0.0", - "@types/istanbul-reports": "^3.0.0", - "@types/node": "*", - "@types/yargs": "^17.0.8", - "chalk": "^4.0.0" - }, - "engines": { - "node": "^14.15.0 || ^16.10.0 || >=18.0.0" - } - }, - "node_modules/@types/jest/node_modules/@sinclair/typebox": { - "version": "0.25.24", - "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.25.24.tgz", - "integrity": "sha512-XJfwUVUKDHF5ugKwIcxEgc9k8b7HbznCp6eUfWgu710hMPNIO4aw4/zB5RogDQz8nd6gyCDpU9O/m6qYEWY6yQ==" - }, - "node_modules/@types/jest/node_modules/@types/yargs": { - "version": "17.0.24", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-17.0.24.tgz", - "integrity": "sha512-6i0aC7jV6QzQB8ne1joVZ0eSFIstHsCrobmOtghM11yGlH0j43FKL2UhWdELkyps0zuf7qVTUVCCR+tgSlyLLw==", - "dependencies": { - "@types/yargs-parser": "*" - } - }, - "node_modules/@types/jest/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/@types/jest/node_modules/chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dependencies": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" - } - }, - "node_modules/@types/jest/node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/@types/jest/node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" - }, - "node_modules/@types/jest/node_modules/diff-sequences": { - "version": "29.4.3", - "resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-29.4.3.tgz", - "integrity": "sha512-ofrBgwpPhCD85kMKtE9RYFFq6OC1A89oW2vvgWZNCwxrUpRUILopY7lsYyMDSjc8g6U6aiO0Qubg6r4Wgt5ZnA==", - "engines": { - "node": "^14.15.0 || ^16.10.0 || >=18.0.0" - } - }, - "node_modules/@types/jest/node_modules/expect": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/expect/-/expect-29.5.0.tgz", - "integrity": "sha512-yM7xqUrCO2JdpFo4XpM82t+PJBFybdqoQuJLDGeDX2ij8NZzqRHyu3Hp188/JX7SWqud+7t4MUdvcgGBICMHZg==", - "dependencies": { - "@jest/expect-utils": "^29.5.0", - "jest-get-type": "^29.4.3", - "jest-matcher-utils": "^29.5.0", - "jest-message-util": "^29.5.0", - "jest-util": "^29.5.0" - }, - "engines": { - "node": "^14.15.0 || ^16.10.0 || >=18.0.0" - } - }, - "node_modules/@types/jest/node_modules/has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "engines": { - "node": ">=8" - } - }, - "node_modules/@types/jest/node_modules/jest-diff": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/jest-diff/-/jest-diff-29.5.0.tgz", - "integrity": "sha512-LtxijLLZBduXnHSniy0WMdaHjmQnt3g5sa16W4p0HqukYTTsyTW3GD1q41TyGl5YFXj/5B2U6dlh5FM1LIMgxw==", - "dependencies": { - "chalk": "^4.0.0", - "diff-sequences": "^29.4.3", - "jest-get-type": "^29.4.3", - "pretty-format": "^29.5.0" - }, - "engines": { - "node": "^14.15.0 || ^16.10.0 || >=18.0.0" - } - }, - "node_modules/@types/jest/node_modules/jest-get-type": { - "version": "29.4.3", - "resolved": "https://registry.npmjs.org/jest-get-type/-/jest-get-type-29.4.3.tgz", - "integrity": "sha512-J5Xez4nRRMjk8emnTpWrlkyb9pfRQQanDrvWHhsR1+VUfbwxi30eVcZFlcdGInRibU4G5LwHXpI7IRHU0CY+gg==", - "engines": { - "node": "^14.15.0 || ^16.10.0 || >=18.0.0" - } - }, - "node_modules/@types/jest/node_modules/jest-matcher-utils": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/jest-matcher-utils/-/jest-matcher-utils-29.5.0.tgz", - "integrity": "sha512-lecRtgm/rjIK0CQ7LPQwzCs2VwW6WAahA55YBuI+xqmhm7LAaxokSB8C97yJeYyT+HvQkH741StzpU41wohhWw==", - "dependencies": { - "chalk": "^4.0.0", - "jest-diff": "^29.5.0", - "jest-get-type": "^29.4.3", - "pretty-format": "^29.5.0" - }, - "engines": { - "node": "^14.15.0 || ^16.10.0 || >=18.0.0" - } - }, - "node_modules/@types/jest/node_modules/jest-message-util": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/jest-message-util/-/jest-message-util-29.5.0.tgz", - "integrity": "sha512-Kijeg9Dag6CKtIDA7O21zNTACqD5MD/8HfIV8pdD94vFyFuer52SigdC3IQMhab3vACxXMiFk+yMHNdbqtyTGA==", - "dependencies": { - "@babel/code-frame": "^7.12.13", - "@jest/types": "^29.5.0", - "@types/stack-utils": "^2.0.0", - "chalk": "^4.0.0", - "graceful-fs": "^4.2.9", - "micromatch": "^4.0.4", - "pretty-format": "^29.5.0", - "slash": "^3.0.0", - "stack-utils": "^2.0.3" - }, - "engines": { - "node": "^14.15.0 || ^16.10.0 || >=18.0.0" - } - }, - "node_modules/@types/jest/node_modules/jest-util": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-29.5.0.tgz", - "integrity": "sha512-RYMgG/MTadOr5t8KdhejfvUU82MxsCu5MF6KuDUHl+NuwzUt+Sm6jJWxTJVrDR1j5M/gJVCPKQEpWXY+yIQ6lQ==", - "dependencies": { - "@jest/types": "^29.5.0", - "@types/node": "*", - "chalk": "^4.0.0", - "ci-info": "^3.2.0", - "graceful-fs": "^4.2.9", - "picomatch": "^2.2.3" - }, - "engines": { - "node": "^14.15.0 || ^16.10.0 || >=18.0.0" - } - }, - "node_modules/@types/jest/node_modules/pretty-format": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-29.5.0.tgz", - "integrity": "sha512-V2mGkI31qdttvTFX7Mt4efOqHXqJWMu4/r66Xh3Z3BwZaPfPJgp6/gbwoujRpPUtfEF6AUUWx3Jim3GCw5g/Qw==", - "dependencies": { - "@jest/schemas": "^29.4.3", - "ansi-styles": "^5.0.0", - "react-is": "^18.0.0" - }, - "engines": { - "node": "^14.15.0 || ^16.10.0 || >=18.0.0" - } - }, - "node_modules/@types/jest/node_modules/pretty-format/node_modules/ansi-styles": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-5.2.0.tgz", - "integrity": "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==", - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/@types/jest/node_modules/react-is": { - "version": "18.2.0", - "resolved": "https://registry.npmjs.org/react-is/-/react-is-18.2.0.tgz", - "integrity": "sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==" - }, - "node_modules/@types/jest/node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/@types/json-schema": { - "version": "7.0.11", - "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.11.tgz", - "integrity": "sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==" - }, - "node_modules/@types/json5": { - "version": "0.0.29", - "resolved": "https://registry.npmjs.org/@types/json5/-/json5-0.0.29.tgz", - "integrity": "sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==" - }, - "node_modules/@types/long": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/@types/long/-/long-4.0.2.tgz", - "integrity": "sha512-MqTGEo5bj5t157U6fA/BiDynNkn0YknVdh48CMPkTSpFTVmvao5UQmm7uEF6xBEo7qIMAlY/JSleYaE6VOdpaA==" - }, - "node_modules/@types/mime": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/@types/mime/-/mime-1.3.2.tgz", - "integrity": "sha512-YATxVxgRqNH6nHEIsvg6k2Boc1JHI9ZbH5iWFFv/MTkchz3b1ieGDa5T0a9RznNdI0KhVbdbWSN+KWWrQZRxTw==" - }, - "node_modules/@types/node": { - "version": "20.2.3", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.2.3.tgz", - "integrity": "sha512-pg9d0yC4rVNWQzX8U7xb4olIOFuuVL9za3bzMT2pu2SU0SNEi66i2qrvhE2qt0HvkhuCaWJu7pLNOt/Pj8BIrw==" - }, - "node_modules/@types/node-fetch": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.6.9.tgz", - "integrity": "sha512-bQVlnMLFJ2d35DkPNjEPmd9ueO/rh5EiaZt2bhqiSarPjZIuIV6bPQVqcrEyvNo+AfTrRGVazle1tl597w3gfA==", - "dependencies": { - "@types/node": "*", - "form-data": "^4.0.0" - } - }, - "node_modules/@types/node-fetch/node_modules/form-data": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", - "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", - "dependencies": { - "asynckit": "^0.4.0", - "combined-stream": "^1.0.8", - "mime-types": "^2.1.12" - }, - "engines": { - "node": ">= 6" - } - }, - "node_modules/@types/object.omit": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/@types/object.omit/-/object.omit-3.0.0.tgz", - "integrity": "sha512-I27IoPpH250TUzc9FzXd0P1BV/BMJuzqD3jOz98ehf9dQqGkxlq+hO1bIqZGWqCg5bVOy0g4AUVJtnxe0klDmw==", - "peer": true - }, - "node_modules/@types/object.pick": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/@types/object.pick/-/object.pick-1.3.2.tgz", - "integrity": "sha512-sn7L+qQ6RLPdXRoiaE7bZ/Ek+o4uICma/lBFPyJEKDTPTBP1W8u0c4baj3EiS4DiqLs+Hk+KUGvMVJtAw3ePJg==", - "peer": true - }, - "node_modules/@types/offscreencanvas": { - "version": "2019.3.0", - "resolved": "https://registry.npmjs.org/@types/offscreencanvas/-/offscreencanvas-2019.3.0.tgz", - "integrity": "sha512-esIJx9bQg+QYF0ra8GnvfianIY8qWB0GBx54PK5Eps6m+xTj86KLavHv6qDhzKcu5UUOgNfJ2pWaIIV7TRUd9Q==" - }, - "node_modules/@types/parse-json": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/@types/parse-json/-/parse-json-4.0.0.tgz", - "integrity": "sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA==" - }, - "node_modules/@types/prettier": { - "version": "2.7.2", - "resolved": "https://registry.npmjs.org/@types/prettier/-/prettier-2.7.2.tgz", - "integrity": "sha512-KufADq8uQqo1pYKVIYzfKbJfBAc0sOeXqGbFaSpv8MRmC/zXgowNZmFcbngndGk922QDmOASEXUZCaY48gs4cg==" - }, - "node_modules/@types/prop-types": { - "version": "15.7.5", - "resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.5.tgz", - "integrity": "sha512-JCB8C6SnDoQf0cNycqd/35A7MjcnK+ZTqE7judS6o7utxUCg6imJg3QK2qzHKszlTjcj2cn+NwMB2i96ubpj7w==" - }, - "node_modules/@types/q": { - "version": "1.5.5", - "resolved": "https://registry.npmjs.org/@types/q/-/q-1.5.5.tgz", - "integrity": "sha512-L28j2FcJfSZOnL1WBjDYp2vUHCeIFlyYI/53EwD/rKUBQ7MtUUfbQWiyKJGpcnv4/WgrhWsFKrcPstcAt/J0tQ==" - }, - "node_modules/@types/qs": { - "version": "6.9.7", - "resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.9.7.tgz", - "integrity": "sha512-FGa1F62FT09qcrueBA6qYTrJPVDzah9a+493+o2PCXsesWHIn27G98TsSMs3WPNbZIEj4+VJf6saSFpvD+3Zsw==" - }, - "node_modules/@types/range-parser": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/@types/range-parser/-/range-parser-1.2.4.tgz", - "integrity": "sha512-EEhsLsD6UsDM1yFhAvy0Cjr6VwmpMWqFBCb9w07wVugF7w9nfajxLuVmngTIpgS6svCnm6Vaw+MZhoDCKnOfsw==" - }, - "node_modules/@types/react": { - "version": "18.2.6", - "resolved": "https://registry.npmjs.org/@types/react/-/react-18.2.6.tgz", - "integrity": "sha512-wRZClXn//zxCFW+ye/D2qY65UsYP1Fpex2YXorHc8awoNamkMZSvBxwxdYVInsHOZZd2Ppq8isnSzJL5Mpf8OA==", - "dependencies": { - "@types/prop-types": "*", - "@types/scheduler": "*", - "csstype": "^3.0.2" - } - }, - "node_modules/@types/react-dom": { - "version": "18.2.4", - "resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-18.2.4.tgz", - "integrity": "sha512-G2mHoTMTL4yoydITgOGwWdWMVd8sNgyEP85xVmMKAPUBwQWm9wBPQUmvbeF4V3WBY1P7mmL4BkjQ0SqUpf1snw==", - "dependencies": { - "@types/react": "*" - } - }, - "node_modules/@types/resolve": { - "version": "1.17.1", - "resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-1.17.1.tgz", - "integrity": "sha512-yy7HuzQhj0dhGpD8RLXSZWEkLsV9ibvxvi6EiJ3bkqLAO1RGo0WbkWQiwpRlSFymTJRz0d3k5LM3kkx8ArDbLw==", - "dependencies": { - "@types/node": "*" - } - }, - "node_modules/@types/retry": { - "version": "0.12.0", - "resolved": "https://registry.npmjs.org/@types/retry/-/retry-0.12.0.tgz", - "integrity": "sha512-wWKOClTTiizcZhXnPY4wikVAwmdYHp8q6DmC+EJUzAMsycb7HB32Kh9RN4+0gExjmPmZSAQjgURXIGATPegAvA==" - }, - "node_modules/@types/scheduler": { - "version": "0.16.3", - "resolved": "https://registry.npmjs.org/@types/scheduler/-/scheduler-0.16.3.tgz", - "integrity": "sha512-5cJ8CB4yAx7BH1oMvdU0Jh9lrEXyPkar6F9G/ERswkCuvP4KQZfZkSjcMbAICCpQTN4OuZn8tz0HiKv9TGZgrQ==" - }, - "node_modules/@types/seedrandom": { - "version": "2.4.34", - "resolved": "https://registry.npmjs.org/@types/seedrandom/-/seedrandom-2.4.34.tgz", - "integrity": "sha512-ytDiArvrn/3Xk6/vtylys5tlY6eo7Ane0hvcx++TKo6RxQXuVfW0AF/oeWqAj9dN29SyhtawuXstgmPlwNcv/A==" - }, - "node_modules/@types/semver": { - "version": "7.5.0", - "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.5.0.tgz", - "integrity": "sha512-G8hZ6XJiHnuhQKR7ZmysCeJWE08o8T0AXtk5darsCaTVsYZhhgUrq53jizaR2FvsoeCwJhlmwTjkXBY5Pn/ZHw==" - }, - "node_modules/@types/send": { - "version": "0.17.1", - "resolved": "https://registry.npmjs.org/@types/send/-/send-0.17.1.tgz", - "integrity": "sha512-Cwo8LE/0rnvX7kIIa3QHCkcuF21c05Ayb0ZfxPiv0W8VRiZiNW/WuRupHKpqqGVGf7SUA44QSOUKaEd9lIrd/Q==", - "dependencies": { - "@types/mime": "^1", - "@types/node": "*" - } - }, - "node_modules/@types/serve-index": { - "version": "1.9.1", - "resolved": "https://registry.npmjs.org/@types/serve-index/-/serve-index-1.9.1.tgz", - "integrity": "sha512-d/Hs3nWDxNL2xAczmOVZNj92YZCS6RGxfBPjKzuu/XirCgXdpKEb88dYNbrYGint6IVWLNP+yonwVAuRC0T2Dg==", - "dependencies": { - "@types/express": "*" - } - }, - "node_modules/@types/serve-static": { - "version": "1.15.1", - "resolved": "https://registry.npmjs.org/@types/serve-static/-/serve-static-1.15.1.tgz", - "integrity": "sha512-NUo5XNiAdULrJENtJXZZ3fHtfMolzZwczzBbnAeBbqBwG+LaG6YaJtuwzwGSQZ2wsCrxjEhNNjAkKigy3n8teQ==", - "dependencies": { - "@types/mime": "*", - "@types/node": "*" - } - }, - "node_modules/@types/sockjs": { - "version": "0.3.33", - "resolved": "https://registry.npmjs.org/@types/sockjs/-/sockjs-0.3.33.tgz", - "integrity": "sha512-f0KEEe05NvUnat+boPTZ0dgaLZ4SfSouXUgv5noUiefG2ajgKjmETo9ZJyuqsl7dfl2aHlLJUiki6B4ZYldiiw==", - "dependencies": { - "@types/node": "*" - } - }, - "node_modules/@types/stack-utils": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/@types/stack-utils/-/stack-utils-2.0.1.tgz", - "integrity": "sha512-Hl219/BT5fLAaz6NDkSuhzasy49dwQS/DSdu4MdggFB8zcXv7vflBI3xp7FEmkmdDkBUI2bPUNeMttp2knYdxw==" - }, - "node_modules/@types/testing-library__jest-dom": { - "version": "5.14.5", - "resolved": "https://registry.npmjs.org/@types/testing-library__jest-dom/-/testing-library__jest-dom-5.14.5.tgz", - "integrity": "sha512-SBwbxYoyPIvxHbeHxTZX2Pe/74F/tX2/D3mMvzabdeJ25bBojfW0TyB8BHrbq/9zaaKICJZjLP+8r6AeZMFCuQ==", - "dependencies": { - "@types/jest": "*" - } - }, - "node_modules/@types/throttle-debounce": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/@types/throttle-debounce/-/throttle-debounce-2.1.0.tgz", - "integrity": "sha512-5eQEtSCoESnh2FsiLTxE121IiE60hnMqcb435fShf4bpLRjEu1Eoekht23y6zXS9Ts3l+Szu3TARnTsA0GkOkQ==", - "peer": true - }, - "node_modules/@types/trusted-types": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/@types/trusted-types/-/trusted-types-2.0.3.tgz", - "integrity": "sha512-NfQ4gyz38SL8sDNrSixxU2Os1a5xcdFxipAFxYEuLUlvU2uDwS4NUpsImcf1//SlWItCVMMLiylsxbmNMToV/g==" - }, - "node_modules/@types/webgl-ext": { - "version": "0.0.30", - "resolved": "https://registry.npmjs.org/@types/webgl-ext/-/webgl-ext-0.0.30.tgz", - "integrity": "sha512-LKVgNmBxN0BbljJrVUwkxwRYqzsAEPcZOe6S2T6ZaBDIrFp0qu4FNlpc5sM1tGbXUYFgdVQIoeLk1Y1UoblyEg==" - }, - "node_modules/@types/webgl2": { - "version": "0.0.4", - "resolved": "https://registry.npmjs.org/@types/webgl2/-/webgl2-0.0.4.tgz", - "integrity": "sha512-PACt1xdErJbMUOUweSrbVM7gSIYm1vTncW2hF6Os/EeWi6TXYAYMPp+8v6rzHmypE5gHrxaxZNXgMkJVIdZpHw==" - }, - "node_modules/@types/ws": { - "version": "8.5.4", - "resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.5.4.tgz", - "integrity": "sha512-zdQDHKUgcX/zBc4GrwsE/7dVdAD8JR4EuiAXiiUhhfyIJXXb2+PrGshFyeXWQPMmmZ2XxgaqclgpIC7eTXc1mg==", - "dependencies": { - "@types/node": "*" - } - }, - "node_modules/@types/yargs": { - "version": "16.0.5", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-16.0.5.tgz", - "integrity": "sha512-AxO/ADJOBFJScHbWhq2xAhlWP24rY4aCEG/NFaMvbT3X2MgRsLjhjQwsn0Zi5zn0LG9jUhCCZMeX9Dkuw6k+vQ==", - "dependencies": { - "@types/yargs-parser": "*" - } - }, - "node_modules/@types/yargs-parser": { - "version": "21.0.0", - "resolved": "https://registry.npmjs.org/@types/yargs-parser/-/yargs-parser-21.0.0.tgz", - "integrity": "sha512-iO9ZQHkZxHn4mSakYV0vFHAVDyEOIJQrV2uZ06HxEPcx+mt8swXoZHIbaaJ2crJYFfErySgktuTZ3BeLz+XmFA==" - }, - "node_modules/@typescript-eslint/eslint-plugin": { - "version": "5.59.7", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.59.7.tgz", - "integrity": "sha512-BL+jYxUFIbuYwy+4fF86k5vdT9lT0CNJ6HtwrIvGh0PhH8s0yy5rjaKH2fDCrz5ITHy07WCzVGNvAmjJh4IJFA==", - "dependencies": { - "@eslint-community/regexpp": "^4.4.0", - "@typescript-eslint/scope-manager": "5.59.7", - "@typescript-eslint/type-utils": "5.59.7", - "@typescript-eslint/utils": "5.59.7", - "debug": "^4.3.4", - "grapheme-splitter": "^1.0.4", - "ignore": "^5.2.0", - "natural-compare-lite": "^1.4.0", - "semver": "^7.3.7", - "tsutils": "^3.21.0" - }, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - }, - "peerDependencies": { - "@typescript-eslint/parser": "^5.0.0", - "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0" - }, - "peerDependenciesMeta": { - "typescript": { - "optional": true - } - } - }, - "node_modules/@typescript-eslint/experimental-utils": { - "version": "5.59.7", - "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-5.59.7.tgz", - "integrity": "sha512-jqM0Cjfvta/sBlY1MxdXYv853/dJUC2wmUWnKoG2srwp0njNGQ6Zu/XLWoRFiLvocQbzBbpHkPFwKgC2UqyovA==", - "dependencies": { - "@typescript-eslint/utils": "5.59.7" - }, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - }, - "peerDependencies": { - "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0" - } - }, - "node_modules/@typescript-eslint/parser": { - "version": "5.59.7", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.59.7.tgz", - "integrity": "sha512-VhpsIEuq/8i5SF+mPg9jSdIwgMBBp0z9XqjiEay+81PYLJuroN+ET1hM5IhkiYMJd9MkTz8iJLt7aaGAgzWUbQ==", - "dependencies": { - "@typescript-eslint/scope-manager": "5.59.7", - "@typescript-eslint/types": "5.59.7", - "@typescript-eslint/typescript-estree": "5.59.7", - "debug": "^4.3.4" - }, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - }, - "peerDependencies": { - "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0" - }, - "peerDependenciesMeta": { - "typescript": { - "optional": true - } - } - }, - "node_modules/@typescript-eslint/scope-manager": { - "version": "5.59.7", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.59.7.tgz", - "integrity": "sha512-FL6hkYWK9zBGdxT2wWEd2W8ocXMu3K94i3gvMrjXpx+koFYdYV7KprKfirpgY34vTGzEPPuKoERpP8kD5h7vZQ==", - "dependencies": { - "@typescript-eslint/types": "5.59.7", - "@typescript-eslint/visitor-keys": "5.59.7" - }, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - } - }, - "node_modules/@typescript-eslint/type-utils": { - "version": "5.59.7", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.59.7.tgz", - "integrity": "sha512-ozuz/GILuYG7osdY5O5yg0QxXUAEoI4Go3Do5xeu+ERH9PorHBPSdvD3Tjp2NN2bNLh1NJQSsQu2TPu/Ly+HaQ==", - "dependencies": { - "@typescript-eslint/typescript-estree": "5.59.7", - "@typescript-eslint/utils": "5.59.7", - "debug": "^4.3.4", - "tsutils": "^3.21.0" - }, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - }, - "peerDependencies": { - "eslint": "*" - }, - "peerDependenciesMeta": { - "typescript": { - "optional": true - } - } - }, - "node_modules/@typescript-eslint/types": { - "version": "5.59.7", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.59.7.tgz", - "integrity": "sha512-UnVS2MRRg6p7xOSATscWkKjlf/NDKuqo5TdbWck6rIRZbmKpVNTLALzNvcjIfHBE7736kZOFc/4Z3VcZwuOM/A==", - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - } - }, - "node_modules/@typescript-eslint/typescript-estree": { - "version": "5.59.7", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.59.7.tgz", - "integrity": "sha512-4A1NtZ1I3wMN2UGDkU9HMBL+TIQfbrh4uS0WDMMpf3xMRursDbqEf1ahh6vAAe3mObt8k3ZATnezwG4pdtWuUQ==", - "dependencies": { - "@typescript-eslint/types": "5.59.7", - "@typescript-eslint/visitor-keys": "5.59.7", - "debug": "^4.3.4", - "globby": "^11.1.0", - "is-glob": "^4.0.3", - "semver": "^7.3.7", - "tsutils": "^3.21.0" - }, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - }, - "peerDependenciesMeta": { - "typescript": { - "optional": true - } - } - }, - "node_modules/@typescript-eslint/utils": { - "version": "5.59.7", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.59.7.tgz", - "integrity": "sha512-yCX9WpdQKaLufz5luG4aJbOpdXf/fjwGMcLFXZVPUz3QqLirG5QcwwnIHNf8cjLjxK4qtzTO8udUtMQSAToQnQ==", - "dependencies": { - "@eslint-community/eslint-utils": "^4.2.0", - "@types/json-schema": "^7.0.9", - "@types/semver": "^7.3.12", - "@typescript-eslint/scope-manager": "5.59.7", - "@typescript-eslint/types": "5.59.7", - "@typescript-eslint/typescript-estree": "5.59.7", - "eslint-scope": "^5.1.1", - "semver": "^7.3.7" - }, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - }, - "peerDependencies": { - "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0" - } - }, - "node_modules/@typescript-eslint/utils/node_modules/eslint-scope": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz", - "integrity": "sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==", - "dependencies": { - "esrecurse": "^4.3.0", - "estraverse": "^4.1.1" - }, - "engines": { - "node": ">=8.0.0" - } - }, - "node_modules/@typescript-eslint/utils/node_modules/estraverse": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", - "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", - "engines": { - "node": ">=4.0" - } - }, - "node_modules/@typescript-eslint/visitor-keys": { - "version": "5.59.7", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.59.7.tgz", - "integrity": "sha512-tyN+X2jvMslUszIiYbF0ZleP+RqQsFVpGrKI6e0Eet1w8WmhsAtmzaqm8oM8WJQ1ysLwhnsK/4hYHJjOgJVfQQ==", - "dependencies": { - "@typescript-eslint/types": "5.59.7", - "eslint-visitor-keys": "^3.3.0" - }, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - } - }, - "node_modules/@webassemblyjs/ast": { - "version": "1.11.6", - "resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.11.6.tgz", - "integrity": "sha512-IN1xI7PwOvLPgjcf180gC1bqn3q/QaOCwYUahIOhbYUu8KA/3tw2RT/T0Gidi1l7Hhj5D/INhJxiICObqpMu4Q==", - "dependencies": { - "@webassemblyjs/helper-numbers": "1.11.6", - "@webassemblyjs/helper-wasm-bytecode": "1.11.6" - } - }, - "node_modules/@webassemblyjs/floating-point-hex-parser": { - "version": "1.11.6", - "resolved": "https://registry.npmjs.org/@webassemblyjs/floating-point-hex-parser/-/floating-point-hex-parser-1.11.6.tgz", - "integrity": "sha512-ejAj9hfRJ2XMsNHk/v6Fu2dGS+i4UaXBXGemOfQ/JfQ6mdQg/WXtwleQRLLS4OvfDhv8rYnVwH27YJLMyYsxhw==" - }, - "node_modules/@webassemblyjs/helper-api-error": { - "version": "1.11.6", - "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-api-error/-/helper-api-error-1.11.6.tgz", - "integrity": "sha512-o0YkoP4pVu4rN8aTJgAyj9hC2Sv5UlkzCHhxqWj8butaLvnpdc2jOwh4ewE6CX0txSfLn/UYaV/pheS2Txg//Q==" - }, - "node_modules/@webassemblyjs/helper-buffer": { - "version": "1.11.6", - "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-buffer/-/helper-buffer-1.11.6.tgz", - "integrity": "sha512-z3nFzdcp1mb8nEOFFk8DrYLpHvhKC3grJD2ardfKOzmbmJvEf/tPIqCY+sNcwZIY8ZD7IkB2l7/pqhUhqm7hLA==" - }, - "node_modules/@webassemblyjs/helper-numbers": { - "version": "1.11.6", - "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-numbers/-/helper-numbers-1.11.6.tgz", - "integrity": "sha512-vUIhZ8LZoIWHBohiEObxVm6hwP034jwmc9kuq5GdHZH0wiLVLIPcMCdpJzG4C11cHoQ25TFIQj9kaVADVX7N3g==", - "dependencies": { - "@webassemblyjs/floating-point-hex-parser": "1.11.6", - "@webassemblyjs/helper-api-error": "1.11.6", - "@xtuc/long": "4.2.2" - } - }, - "node_modules/@webassemblyjs/helper-wasm-bytecode": { - "version": "1.11.6", - "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-wasm-bytecode/-/helper-wasm-bytecode-1.11.6.tgz", - "integrity": "sha512-sFFHKwcmBprO9e7Icf0+gddyWYDViL8bpPjJJl0WHxCdETktXdmtWLGVzoHbqUcY4Be1LkNfwTmXOJUFZYSJdA==" - }, - "node_modules/@webassemblyjs/helper-wasm-section": { - "version": "1.11.6", - "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-wasm-section/-/helper-wasm-section-1.11.6.tgz", - "integrity": "sha512-LPpZbSOwTpEC2cgn4hTydySy1Ke+XEu+ETXuoyvuyezHO3Kjdu90KK95Sh9xTbmjrCsUwvWwCOQQNta37VrS9g==", - "dependencies": { - "@webassemblyjs/ast": "1.11.6", - "@webassemblyjs/helper-buffer": "1.11.6", - "@webassemblyjs/helper-wasm-bytecode": "1.11.6", - "@webassemblyjs/wasm-gen": "1.11.6" - } - }, - "node_modules/@webassemblyjs/ieee754": { - "version": "1.11.6", - "resolved": "https://registry.npmjs.org/@webassemblyjs/ieee754/-/ieee754-1.11.6.tgz", - "integrity": "sha512-LM4p2csPNvbij6U1f19v6WR56QZ8JcHg3QIJTlSwzFcmx6WSORicYj6I63f9yU1kEUtrpG+kjkiIAkevHpDXrg==", - "dependencies": { - "@xtuc/ieee754": "^1.2.0" - } - }, - "node_modules/@webassemblyjs/leb128": { - "version": "1.11.6", - "resolved": "https://registry.npmjs.org/@webassemblyjs/leb128/-/leb128-1.11.6.tgz", - "integrity": "sha512-m7a0FhE67DQXgouf1tbN5XQcdWoNgaAuoULHIfGFIEVKA6tu/edls6XnIlkmS6FrXAquJRPni3ZZKjw6FSPjPQ==", - "dependencies": { - "@xtuc/long": "4.2.2" - } - }, - "node_modules/@webassemblyjs/utf8": { - "version": "1.11.6", - "resolved": "https://registry.npmjs.org/@webassemblyjs/utf8/-/utf8-1.11.6.tgz", - "integrity": "sha512-vtXf2wTQ3+up9Zsg8sa2yWiQpzSsMyXj0qViVP6xKGCUT8p8YJ6HqI7l5eCnWx1T/FYdsv07HQs2wTFbbof/RA==" - }, - "node_modules/@webassemblyjs/wasm-edit": { - "version": "1.11.6", - "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-edit/-/wasm-edit-1.11.6.tgz", - "integrity": "sha512-Ybn2I6fnfIGuCR+Faaz7YcvtBKxvoLV3Lebn1tM4o/IAJzmi9AWYIPWpyBfU8cC+JxAO57bk4+zdsTjJR+VTOw==", - "dependencies": { - "@webassemblyjs/ast": "1.11.6", - "@webassemblyjs/helper-buffer": "1.11.6", - "@webassemblyjs/helper-wasm-bytecode": "1.11.6", - "@webassemblyjs/helper-wasm-section": "1.11.6", - "@webassemblyjs/wasm-gen": "1.11.6", - "@webassemblyjs/wasm-opt": "1.11.6", - "@webassemblyjs/wasm-parser": "1.11.6", - "@webassemblyjs/wast-printer": "1.11.6" - } - }, - "node_modules/@webassemblyjs/wasm-gen": { - "version": "1.11.6", - "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-gen/-/wasm-gen-1.11.6.tgz", - "integrity": "sha512-3XOqkZP/y6B4F0PBAXvI1/bky7GryoogUtfwExeP/v7Nzwo1QLcq5oQmpKlftZLbT+ERUOAZVQjuNVak6UXjPA==", - "dependencies": { - "@webassemblyjs/ast": "1.11.6", - "@webassemblyjs/helper-wasm-bytecode": "1.11.6", - "@webassemblyjs/ieee754": "1.11.6", - "@webassemblyjs/leb128": "1.11.6", - "@webassemblyjs/utf8": "1.11.6" - } - }, - "node_modules/@webassemblyjs/wasm-opt": { - "version": "1.11.6", - "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-opt/-/wasm-opt-1.11.6.tgz", - "integrity": "sha512-cOrKuLRE7PCe6AsOVl7WasYf3wbSo4CeOk6PkrjS7g57MFfVUF9u6ysQBBODX0LdgSvQqRiGz3CXvIDKcPNy4g==", - "dependencies": { - "@webassemblyjs/ast": "1.11.6", - "@webassemblyjs/helper-buffer": "1.11.6", - "@webassemblyjs/wasm-gen": "1.11.6", - "@webassemblyjs/wasm-parser": "1.11.6" - } - }, - "node_modules/@webassemblyjs/wasm-parser": { - "version": "1.11.6", - "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-parser/-/wasm-parser-1.11.6.tgz", - "integrity": "sha512-6ZwPeGzMJM3Dqp3hCsLgESxBGtT/OeCvCZ4TA1JUPYgmhAx38tTPR9JaKy0S5H3evQpO/h2uWs2j6Yc/fjkpTQ==", - "dependencies": { - "@webassemblyjs/ast": "1.11.6", - "@webassemblyjs/helper-api-error": "1.11.6", - "@webassemblyjs/helper-wasm-bytecode": "1.11.6", - "@webassemblyjs/ieee754": "1.11.6", - "@webassemblyjs/leb128": "1.11.6", - "@webassemblyjs/utf8": "1.11.6" - } - }, - "node_modules/@webassemblyjs/wast-printer": { - "version": "1.11.6", - "resolved": "https://registry.npmjs.org/@webassemblyjs/wast-printer/-/wast-printer-1.11.6.tgz", - "integrity": "sha512-JM7AhRcE+yW2GWYaKeHL5vt4xqee5N2WcezptmgyhNS+ScggqcT1OtXykhAb13Sn5Yas0j2uv9tHgrjwvzAP4A==", - "dependencies": { - "@webassemblyjs/ast": "1.11.6", - "@xtuc/long": "4.2.2" - } - }, - "node_modules/@webgpu/types": { - "version": "0.1.30", - "resolved": "https://registry.npmjs.org/@webgpu/types/-/types-0.1.30.tgz", - "integrity": "sha512-9AXJSmL3MzY8ZL//JjudA//q+2kBRGhLBFpkdGksWIuxrMy81nFrCzj2Am+mbh8WoU6rXmv7cY5E3rdlyru2Qg==" - }, - "node_modules/@xtuc/ieee754": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@xtuc/ieee754/-/ieee754-1.2.0.tgz", - "integrity": "sha512-DX8nKgqcGwsc0eJSqYt5lwP4DH5FlHnmuWWBRy7X0NcaGR0ZtuyeESgMwTYVEtxmsNGY+qit4QYT/MIYTOTPeA==" - }, - "node_modules/@xtuc/long": { - "version": "4.2.2", - "resolved": "https://registry.npmjs.org/@xtuc/long/-/long-4.2.2.tgz", - "integrity": "sha512-NuHqBY1PB/D8xU6s/thBgOAiAP7HOYDQ32+BFZILJ8ivkUkAHQnWfn6WhL79Owj1qmUnoN/YPhktdIoucipkAQ==" - }, - "node_modules/abab": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/abab/-/abab-2.0.6.tgz", - "integrity": "sha512-j2afSsaIENvHZN2B8GOpF566vZ5WVk5opAiMTvWgaQT8DkbOqsTfvNAvHoRGU2zzP8cPoqys+xHTRDWW8L+/BA==" - }, - "node_modules/abbrev": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", - "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==" - }, - "node_modules/accepts": { - "version": "1.3.8", - "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz", - "integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==", - "dependencies": { - "mime-types": "~2.1.34", - "negotiator": "0.6.3" - }, - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/acorn": { - "version": "8.8.2", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.2.tgz", - "integrity": "sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw==", - "bin": { - "acorn": "bin/acorn" - }, - "engines": { - "node": ">=0.4.0" - } - }, - "node_modules/acorn-globals": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/acorn-globals/-/acorn-globals-6.0.0.tgz", - "integrity": "sha512-ZQl7LOWaF5ePqqcX4hLuv/bLXYQNfNWw2c0/yX/TsPRKamzHcTGQnlCjHT3TsmkOUVEPS3crCxiPfdzE/Trlhg==", - "dependencies": { - "acorn": "^7.1.1", - "acorn-walk": "^7.1.1" - } - }, - "node_modules/acorn-globals/node_modules/acorn": { - "version": "7.4.1", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.1.tgz", - "integrity": "sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A==", - "bin": { - "acorn": "bin/acorn" - }, - "engines": { - "node": ">=0.4.0" - } - }, - "node_modules/acorn-import-assertions": { - "version": "1.9.0", - "resolved": "https://registry.npmjs.org/acorn-import-assertions/-/acorn-import-assertions-1.9.0.tgz", - "integrity": "sha512-cmMwop9x+8KFhxvKrKfPYmN6/pKTYYHBqLa0DfvVZcKMJWNyWLnaqND7dx/qn66R7ewM1UX5XMaDVP5wlVTaVA==", - "peerDependencies": { - "acorn": "^8" - } - }, - "node_modules/acorn-jsx": { - "version": "5.3.2", - "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", - "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", - "peerDependencies": { - "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" - } - }, - "node_modules/acorn-walk": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-7.2.0.tgz", - "integrity": "sha512-OPdCF6GsMIP+Az+aWfAAOEt2/+iVDKE7oy6lJ098aoe59oAmK76qV6Gw60SbZ8jHuG2wH058GF4pLFbYamYrVA==", - "engines": { - "node": ">=0.4.0" - } - }, - "node_modules/address": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/address/-/address-1.2.2.tgz", - "integrity": "sha512-4B/qKCfeE/ODUaAUpSwfzazo5x29WD4r3vXiWsB7I2mSDAihwEqKO+g8GELZUQSSAo5e1XTYh3ZVfLyxBc12nA==", - "engines": { - "node": ">= 10.0.0" - } - }, - "node_modules/adjust-sourcemap-loader": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/adjust-sourcemap-loader/-/adjust-sourcemap-loader-4.0.0.tgz", - "integrity": "sha512-OXwN5b9pCUXNQHJpwwD2qP40byEmSgzj8B4ydSN0uMNYWiFmJ6x6KwUllMmfk8Rwu/HJDFR7U8ubsWBoN0Xp0A==", - "dependencies": { - "loader-utils": "^2.0.0", - "regex-parser": "^2.2.11" - }, - "engines": { - "node": ">=8.9" - } - }, - "node_modules/adm-zip": { - "version": "0.4.16", - "resolved": "https://registry.npmjs.org/adm-zip/-/adm-zip-0.4.16.tgz", - "integrity": "sha512-TFi4HBKSGfIKsK5YCkKaaFG2m4PEDyViZmEwof3MTIgzimHLto6muaHVpbrljdIvIrFZzEq/p4nafOeLcYegrg==", - "engines": { - "node": ">=0.3.0" - } - }, - "node_modules/agent-base": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", - "integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==", - "dependencies": { - "debug": "4" - }, - "engines": { - "node": ">= 6.0.0" - } - }, - "node_modules/ajv": { - "version": "6.12.6", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", - "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", - "dependencies": { - "fast-deep-equal": "^3.1.1", - "fast-json-stable-stringify": "^2.0.0", - "json-schema-traverse": "^0.4.1", - "uri-js": "^4.2.2" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/epoberezkin" - } - }, - "node_modules/ajv-formats": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ajv-formats/-/ajv-formats-2.1.1.tgz", - "integrity": "sha512-Wx0Kx52hxE7C18hkMEggYlEifqWZtYaRgouJor+WMdPnQyEK13vgEWyVNup7SoeeoLMsr4kf5h6dOW11I15MUA==", - "dependencies": { - "ajv": "^8.0.0" - }, - "peerDependencies": { - "ajv": "^8.0.0" - }, - "peerDependenciesMeta": { - "ajv": { - "optional": true - } - } - }, - "node_modules/ajv-formats/node_modules/ajv": { - "version": "8.12.0", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.12.0.tgz", - "integrity": "sha512-sRu1kpcO9yLtYxBKvqfTeh9KzZEwO3STyX1HT+4CaDzC6HpTGYhIhPIzj9XuKU7KYDwnaeh5hcOwjy1QuJzBPA==", - "dependencies": { - "fast-deep-equal": "^3.1.1", - "json-schema-traverse": "^1.0.0", - "require-from-string": "^2.0.2", - "uri-js": "^4.2.2" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/epoberezkin" - } - }, - "node_modules/ajv-formats/node_modules/json-schema-traverse": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", - "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==" - }, - "node_modules/ajv-keywords": { - "version": "3.5.2", - "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-3.5.2.tgz", - "integrity": "sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ==", - "peerDependencies": { - "ajv": "^6.9.1" - } - }, - "node_modules/ansi-escapes": { - "version": "4.3.2", - "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.3.2.tgz", - "integrity": "sha512-gKXj5ALrKWQLsYG9jlTRmR/xKluxHV+Z9QEwNIgCfM1/uwPMCuzVVnh5mwTd+OuBZcwSIMbqssNWRm1lE51QaQ==", - "dependencies": { - "type-fest": "^0.21.3" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/ansi-html-community": { - "version": "0.0.8", - "resolved": "https://registry.npmjs.org/ansi-html-community/-/ansi-html-community-0.0.8.tgz", - "integrity": "sha512-1APHAyr3+PCamwNw3bXCPp4HFLONZt/yIH0sZp0/469KWNTEy+qN5jQ3GVX6DMZ1UXAi34yVwtTeaG/HpBuuzw==", - "engines": [ - "node >= 0.8.0" - ], - "bin": { - "ansi-html": "bin/ansi-html" - } - }, - "node_modules/ansi-regex": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", - "engines": { - "node": ">=8" - } - }, - "node_modules/ansi-styles": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", - "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", - "dependencies": { - "color-convert": "^1.9.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/any-promise": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/any-promise/-/any-promise-1.3.0.tgz", - "integrity": "sha512-7UvmKalWRt1wgjL1RrGxoSJW/0QZFIegpeGvZG9kjp8vrRu55XTHbwnqq2GpXm9uLbcuhxm3IqX9OB4MZR1b2A==" - }, - "node_modules/anymatch": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", - "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", - "dependencies": { - "normalize-path": "^3.0.0", - "picomatch": "^2.0.4" - }, - "engines": { - "node": ">= 8" - } - }, - "node_modules/aproba": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/aproba/-/aproba-1.2.0.tgz", - "integrity": "sha512-Y9J6ZjXtoYh8RnXVCMOU/ttDmk1aBjunq9vO0ta5x85WDQiQfUF9sIPBITdbiiIVcBo03Hi3jMxigBtsddlXRw==" - }, - "node_modules/are-we-there-yet": { - "version": "1.1.7", - "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-1.1.7.tgz", - "integrity": "sha512-nxwy40TuMiUGqMyRHgCSWZ9FM4VAoRP4xUYSTv5ImRog+h9yISPbVH7H8fASCIzYn9wlEv4zvFL7uKDMCFQm3g==", - "dependencies": { - "delegates": "^1.0.0", - "readable-stream": "^2.0.6" - } - }, - "node_modules/are-we-there-yet/node_modules/isarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==" - }, - "node_modules/are-we-there-yet/node_modules/readable-stream": { - "version": "2.3.8", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.8.tgz", - "integrity": "sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==", - "dependencies": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" - } - }, - "node_modules/are-we-there-yet/node_modules/safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" - }, - "node_modules/are-we-there-yet/node_modules/string_decoder": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "dependencies": { - "safe-buffer": "~5.1.0" - } - }, - "node_modules/arg": { - "version": "5.0.2", - "resolved": "https://registry.npmjs.org/arg/-/arg-5.0.2.tgz", - "integrity": "sha512-PYjyFOLKQ9y57JvQ6QLo8dAgNqswh8M1RMJYdQduT6xbWSgK36P/Z/v+p888pM69jMMfS8Xd8F6I1kQ/I9HUGg==" - }, - "node_modules/argparse": { - "version": "1.0.10", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", - "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", - "dependencies": { - "sprintf-js": "~1.0.2" - } - }, - "node_modules/aria-hidden": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/aria-hidden/-/aria-hidden-1.2.3.tgz", - "integrity": "sha512-xcLxITLe2HYa1cnYnwCjkOO1PqUHQpozB8x9AR0OgWN2woOBi5kSDVxKfd0b7sb1hw5qFeJhXm9H1nu3xSfLeQ==", - "dependencies": { - "tslib": "^2.0.0" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/aria-query": { - "version": "5.1.3", - "resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.1.3.tgz", - "integrity": "sha512-R5iJ5lkuHybztUfuOAznmboyjWq8O6sqNqtK7CLOqdydi54VNbORp49mb14KbWgG1QD3JFO9hJdZ+y4KutfdOQ==", - "dependencies": { - "deep-equal": "^2.0.5" - } - }, - "node_modules/array-buffer-byte-length": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/array-buffer-byte-length/-/array-buffer-byte-length-1.0.0.tgz", - "integrity": "sha512-LPuwb2P+NrQw3XhxGc36+XSvuBPopovXYTR9Ew++Du9Yb/bx5AzBfrIsBoj0EZUifjQU+sHL21sseZ3jerWO/A==", - "dependencies": { - "call-bind": "^1.0.2", - "is-array-buffer": "^3.0.1" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/array-flatten": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-2.1.2.tgz", - "integrity": "sha512-hNfzcOV8W4NdualtqBFPyVO+54DSJuZGY9qT4pRroB6S9e3iiido2ISIC5h9R2sPJ8H3FHCIiEnsv1lPXO3KtQ==" - }, - "node_modules/array-includes": { - "version": "3.1.6", - "resolved": "https://registry.npmjs.org/array-includes/-/array-includes-3.1.6.tgz", - "integrity": "sha512-sgTbLvL6cNnw24FnbaDyjmvddQ2ML8arZsgaJhoABMoplz/4QRhtrYS+alr1BUM1Bwp6dhx8vVCBSLG+StwOFw==", - "dependencies": { - "call-bind": "^1.0.2", - "define-properties": "^1.1.4", - "es-abstract": "^1.20.4", - "get-intrinsic": "^1.1.3", - "is-string": "^1.0.7" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/array-union": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz", - "integrity": "sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==", - "engines": { - "node": ">=8" - } - }, - "node_modules/array.prototype.flat": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/array.prototype.flat/-/array.prototype.flat-1.3.1.tgz", - "integrity": "sha512-roTU0KWIOmJ4DRLmwKd19Otg0/mT3qPNt0Qb3GWW8iObuZXxrjB/pzn0R3hqpRSWg4HCwqx+0vwOnWnvlOyeIA==", - "dependencies": { - "call-bind": "^1.0.2", - "define-properties": "^1.1.4", - "es-abstract": "^1.20.4", - "es-shim-unscopables": "^1.0.0" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/array.prototype.flatmap": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/array.prototype.flatmap/-/array.prototype.flatmap-1.3.1.tgz", - "integrity": "sha512-8UGn9O1FDVvMNB0UlLv4voxRMze7+FpHyF5mSMRjWHUMlpoDViniy05870VlxhfgTnLbpuwTzvD76MTtWxB/mQ==", - "dependencies": { - "call-bind": "^1.0.2", - "define-properties": "^1.1.4", - "es-abstract": "^1.20.4", - "es-shim-unscopables": "^1.0.0" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/array.prototype.reduce": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/array.prototype.reduce/-/array.prototype.reduce-1.0.5.tgz", - "integrity": "sha512-kDdugMl7id9COE8R7MHF5jWk7Dqt/fs4Pv+JXoICnYwqpjjjbUurz6w5fT5IG6brLdJhv6/VoHB0H7oyIBXd+Q==", - "dependencies": { - "call-bind": "^1.0.2", - "define-properties": "^1.1.4", - "es-abstract": "^1.20.4", - "es-array-method-boxes-properly": "^1.0.0", - "is-string": "^1.0.7" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/array.prototype.tosorted": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/array.prototype.tosorted/-/array.prototype.tosorted-1.1.1.tgz", - "integrity": "sha512-pZYPXPRl2PqWcsUs6LOMn+1f1532nEoPTYowBtqLwAW+W8vSVhkIGnmOX1t/UQjD6YGI0vcD2B1U7ZFGQH9jnQ==", - "dependencies": { - "call-bind": "^1.0.2", - "define-properties": "^1.1.4", - "es-abstract": "^1.20.4", - "es-shim-unscopables": "^1.0.0", - "get-intrinsic": "^1.1.3" - } - }, - "node_modules/asap": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz", - "integrity": "sha512-BSHWgDSAiKs50o2Re8ppvp3seVHXSRM44cdSsT9FfNEUUZLOGWVCsiWaRPWM1Znn+mqZ1OfVZ3z3DWEzSp7hRA==" - }, - "node_modules/asn1": { - "version": "0.2.6", - "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.6.tgz", - "integrity": "sha512-ix/FxPn0MDjeyJ7i/yoHGFt/EX6LyNbxSEhPPXODPL+KB0VPk86UYfL0lMdy+KCnv+fmvIzySwaK5COwqVbWTQ==", - "optional": true, - "dependencies": { - "safer-buffer": "~2.1.0" - } - }, - "node_modules/assert-plus": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", - "integrity": "sha512-NfJ4UzBCcQGLDlQq7nHxH+tv3kyZ0hHQqF5BO6J7tNJeP5do1llPr8dZ8zHonfhAu0PHAdMkSo+8o0wxg9lZWw==", - "optional": true, - "engines": { - "node": ">=0.8" - } - }, - "node_modules/ast-types-flow": { - "version": "0.0.7", - "resolved": "https://registry.npmjs.org/ast-types-flow/-/ast-types-flow-0.0.7.tgz", - "integrity": "sha512-eBvWn1lvIApYMhzQMsu9ciLfkBY499mFZlNqG+/9WR7PVlroQw0vG30cOQQbaKz3sCEc44TAOu2ykzqXSNnwag==" - }, - "node_modules/async": { - "version": "3.2.4", - "resolved": "https://registry.npmjs.org/async/-/async-3.2.4.tgz", - "integrity": "sha512-iAB+JbDEGXhyIUavoDl9WP/Jj106Kz9DEn1DPgYw5ruDn0e3Wgi3sKFm55sASdGBNOQB8F59d9qQ7deqrHA8wQ==" - }, - "node_modules/asynckit": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" - }, - "node_modules/at-least-node": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/at-least-node/-/at-least-node-1.0.0.tgz", - "integrity": "sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg==", - "engines": { - "node": ">= 4.0.0" - } - }, - "node_modules/attr-accept": { - "version": "2.2.2", - "resolved": "https://registry.npmjs.org/attr-accept/-/attr-accept-2.2.2.tgz", - "integrity": "sha512-7prDjvt9HmqiZ0cl5CRjtS84sEyhsHP2coDkaZKRKVfCDo9s7iw7ChVmar78Gu9pC4SoR/28wFu/G5JJhTnqEg==", - "engines": { - "node": ">=4" - } - }, - "node_modules/autoprefixer": { - "version": "10.4.14", - "resolved": "https://registry.npmjs.org/autoprefixer/-/autoprefixer-10.4.14.tgz", - "integrity": "sha512-FQzyfOsTlwVzjHxKEqRIAdJx9niO6VCBCoEwax/VLSoQF29ggECcPuBqUMZ+u8jCZOPSy8b8/8KnuFbp0SaFZQ==", - "funding": [ - { - "type": "opencollective", - "url": "https://opencollective.com/postcss/" - }, - { - "type": "tidelift", - "url": "https://tidelift.com/funding/github/npm/autoprefixer" - } - ], - "dependencies": { - "browserslist": "^4.21.5", - "caniuse-lite": "^1.0.30001464", - "fraction.js": "^4.2.0", - "normalize-range": "^0.1.2", - "picocolors": "^1.0.0", - "postcss-value-parser": "^4.2.0" - }, - "bin": { - "autoprefixer": "bin/autoprefixer" - }, - "engines": { - "node": "^10 || ^12 || >=14" - }, - "peerDependencies": { - "postcss": "^8.1.0" - } - }, - "node_modules/available-typed-arrays": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/available-typed-arrays/-/available-typed-arrays-1.0.5.tgz", - "integrity": "sha512-DMD0KiN46eipeziST1LPP/STfDU0sufISXmjSgvVsoU2tqxctQeASejWcfNtxYKqETM1UxQ8sp2OrSBWpHY6sw==", - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/aws-sign2": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz", - "integrity": "sha512-08kcGqnYf/YmjoRhfxyu+CLxBjUtHLXLXX/vUfx9l2LYzG3c1m61nrpyFUZI6zeS+Li/wWMMidD9KgrqtGq3mA==", - "optional": true, - "engines": { - "node": "*" - } - }, - "node_modules/aws4": { - "version": "1.12.0", - "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.12.0.tgz", - "integrity": "sha512-NmWvPnx0F1SfrQbYwOi7OeaNGokp9XhzNioJ/CSBs8Qa4vxug81mhJEAVZwxXuBmYB5KDRfMq/F3RR0BIU7sWg==", - "optional": true - }, - "node_modules/axe-core": { - "version": "4.7.1", - "resolved": "https://registry.npmjs.org/axe-core/-/axe-core-4.7.1.tgz", - "integrity": "sha512-sCXXUhA+cljomZ3ZAwb8i1p3oOlkABzPy08ZDAoGcYuvtBPlQ1Ytde129ArXyHWDhfeewq7rlx9F+cUx2SSlkg==", - "engines": { - "node": ">=4" - } - }, - "node_modules/axios": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.4.0.tgz", - "integrity": "sha512-S4XCWMEmzvo64T9GfvQDOXgYRDJ/wsSZc7Jvdgx5u1sd0JwsuPLqb3SYmusag+edF6ziyMensPVqLTSc1PiSEA==", - "dependencies": { - "follow-redirects": "^1.15.0", - "form-data": "^4.0.0", - "proxy-from-env": "^1.1.0" - } - }, - "node_modules/axios/node_modules/form-data": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", - "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", - "dependencies": { - "asynckit": "^0.4.0", - "combined-stream": "^1.0.8", - "mime-types": "^2.1.12" - }, - "engines": { - "node": ">= 6" - } - }, - "node_modules/axobject-query": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-3.1.1.tgz", - "integrity": "sha512-goKlv8DZrK9hUh975fnHzhNIO4jUnFCfv/dszV5VwUGDFjI6vQ2VwoyjYjYNEbBE8AH87TduWP5uyDR1D+Iteg==", - "dependencies": { - "deep-equal": "^2.0.5" - } - }, - "node_modules/babel-code-frame": { - "version": "6.26.0", - "resolved": "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.26.0.tgz", - "integrity": "sha512-XqYMR2dfdGMW+hd0IUZ2PwK+fGeFkOxZJ0wY+JaQAHzt1Zx8LcvpiZD2NiGkEG8qx0CfkAOr5xt76d1e8vG90g==", - "dependencies": { - "chalk": "^1.1.3", - "esutils": "^2.0.2", - "js-tokens": "^3.0.2" - } - }, - "node_modules/babel-code-frame/node_modules/ansi-regex": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", - "integrity": "sha512-TIGnTpdo+E3+pCyAluZvtED5p5wCqLdezCyhPZzKPcxvFplEt4i+W7OONCKgeZFT3+y5NZZfOOS/Bdcanm1MYA==", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/babel-code-frame/node_modules/ansi-styles": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", - "integrity": "sha512-kmCevFghRiWM7HB5zTPULl4r9bVFSWjz62MhqizDGUrq2NWuNMQyuv4tHHoKJHs69M/MF64lEcHdYIocrdWQYA==", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/babel-code-frame/node_modules/chalk": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", - "integrity": "sha512-U3lRVLMSlsCfjqYPbLyVv11M9CPW4I728d6TCKMAOJueEeB9/8o+eSsMnxPJD+Q+K909sdESg7C+tIkoH6on1A==", - "dependencies": { - "ansi-styles": "^2.2.1", - "escape-string-regexp": "^1.0.2", - "has-ansi": "^2.0.0", - "strip-ansi": "^3.0.0", - "supports-color": "^2.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/babel-code-frame/node_modules/js-tokens": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.2.tgz", - "integrity": "sha512-RjTcuD4xjtthQkaWH7dFlH85L+QaVtSoOyGdZ3g6HFhS9dFNDfLyqgm2NFe2X6cQpeFmt0452FJjFG5UameExg==" - }, - "node_modules/babel-code-frame/node_modules/strip-ansi": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "integrity": "sha512-VhumSSbBqDTP8p2ZLKj40UjBCV4+v8bUSEpUb4KjRgWk9pbqGF4REFj6KEagidb2f/M6AzC0EmFyDNGaw9OCzg==", - "dependencies": { - "ansi-regex": "^2.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/babel-code-frame/node_modules/supports-color": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", - "integrity": "sha512-KKNVtd6pCYgPIKU4cp2733HWYCpplQhddZLBUryaAHou723x+FRzQ5Df824Fj+IyyuiQTRoub4SnIFfIcrp70g==", - "engines": { - "node": ">=0.8.0" - } - }, - "node_modules/babel-generator": { - "version": "6.26.1", - "resolved": "https://registry.npmjs.org/babel-generator/-/babel-generator-6.26.1.tgz", - "integrity": "sha512-HyfwY6ApZj7BYTcJURpM5tznulaBvyio7/0d4zFOeMPUmfxkCjHocCuoLa2SAGzBI8AREcH3eP3758F672DppA==", - "dependencies": { - "babel-messages": "^6.23.0", - "babel-runtime": "^6.26.0", - "babel-types": "^6.26.0", - "detect-indent": "^4.0.0", - "jsesc": "^1.3.0", - "lodash": "^4.17.4", - "source-map": "^0.5.7", - "trim-right": "^1.0.1" - } - }, - "node_modules/babel-generator/node_modules/jsesc": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-1.3.0.tgz", - "integrity": "sha512-Mke0DA0QjUWuJlhsE0ZPPhYiJkRap642SmI/4ztCFaUs6V2AiH1sfecc+57NgaryfAA2VR3v6O+CSjC1jZJKOA==", - "bin": { - "jsesc": "bin/jsesc" - } - }, - "node_modules/babel-generator/node_modules/source-map": { - "version": "0.5.7", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", - "integrity": "sha512-LbrmJOMUSdEVxIKvdcJzQC+nQhe8FUZQTXQy6+I75skNgn3OoQ0DZA8YnFa7gp8tqtL3KPf1kmo0R5DoApeSGQ==", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/babel-jest": { - "version": "27.5.1", - "resolved": "https://registry.npmjs.org/babel-jest/-/babel-jest-27.5.1.tgz", - "integrity": "sha512-cdQ5dXjGRd0IBRATiQ4mZGlGlRE8kJpjPOixdNRdT+m3UcNqmYWN6rK6nvtXYfY3D76cb8s/O1Ss8ea24PIwcg==", - "dependencies": { - "@jest/transform": "^27.5.1", - "@jest/types": "^27.5.1", - "@types/babel__core": "^7.1.14", - "babel-plugin-istanbul": "^6.1.1", - "babel-preset-jest": "^27.5.1", - "chalk": "^4.0.0", - "graceful-fs": "^4.2.9", - "slash": "^3.0.0" - }, - "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" - }, - "peerDependencies": { - "@babel/core": "^7.8.0" - } - }, - "node_modules/babel-jest/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/babel-jest/node_modules/chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dependencies": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" - } - }, - "node_modules/babel-jest/node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/babel-jest/node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" - }, - "node_modules/babel-jest/node_modules/has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "engines": { - "node": ">=8" - } - }, - "node_modules/babel-jest/node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/babel-loader": { - "version": "8.3.0", - "resolved": "https://registry.npmjs.org/babel-loader/-/babel-loader-8.3.0.tgz", - "integrity": "sha512-H8SvsMF+m9t15HNLMipppzkC+Y2Yq+v3SonZyU70RBL/h1gxPkH08Ot8pEE9Z4Kd+czyWJClmFS8qzIP9OZ04Q==", - "dependencies": { - "find-cache-dir": "^3.3.1", - "loader-utils": "^2.0.0", - "make-dir": "^3.1.0", - "schema-utils": "^2.6.5" - }, - "engines": { - "node": ">= 8.9" - }, - "peerDependencies": { - "@babel/core": "^7.0.0", - "webpack": ">=2" - } - }, - "node_modules/babel-loader/node_modules/schema-utils": { - "version": "2.7.1", - "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-2.7.1.tgz", - "integrity": "sha512-SHiNtMOUGWBQJwzISiVYKu82GiV4QYGePp3odlY1tuKO7gPtphAT5R/py0fA6xtbgLL/RvtJZnU9b8s0F1q0Xg==", - "dependencies": { - "@types/json-schema": "^7.0.5", - "ajv": "^6.12.4", - "ajv-keywords": "^3.5.2" - }, - "engines": { - "node": ">= 8.9.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/webpack" - } - }, - "node_modules/babel-merge": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/babel-merge/-/babel-merge-3.0.0.tgz", - "integrity": "sha512-eBOBtHnzt9xvnjpYNI5HmaPp/b2vMveE5XggzqHnQeHJ8mFIBrBv6WZEVIj5jJ2uwTItkqKo9gWzEEcBxEq0yw==", - "peer": true, - "dependencies": { - "deepmerge": "^2.2.1", - "object.omit": "^3.0.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0" - } - }, - "node_modules/babel-merge/node_modules/deepmerge": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-2.2.1.tgz", - "integrity": "sha512-R9hc1Xa/NOBi9WRVUWg19rl1UB7Tt4kuPd+thNJgFZoxXsTz7ncaPaeIm+40oSGuP33DfMb4sZt1QIGiJzC4EA==", - "peer": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/babel-messages": { - "version": "6.23.0", - "resolved": "https://registry.npmjs.org/babel-messages/-/babel-messages-6.23.0.tgz", - "integrity": "sha512-Bl3ZiA+LjqaMtNYopA9TYE9HP1tQ+E5dLxE0XrAzcIJeK2UqF0/EaqXwBn9esd4UmTfEab+P+UYQ1GnioFIb/w==", - "dependencies": { - "babel-runtime": "^6.22.0" - } - }, - "node_modules/babel-plugin-istanbul": { - "version": "6.1.1", - "resolved": "https://registry.npmjs.org/babel-plugin-istanbul/-/babel-plugin-istanbul-6.1.1.tgz", - "integrity": "sha512-Y1IQok9821cC9onCx5otgFfRm7Lm+I+wwxOx738M/WLPZ9Q42m4IG5W0FNX8WLL2gYMZo3JkuXIH2DOpWM+qwA==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.0.0", - "@istanbuljs/load-nyc-config": "^1.0.0", - "@istanbuljs/schema": "^0.1.2", - "istanbul-lib-instrument": "^5.0.4", - "test-exclude": "^6.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/babel-plugin-jest-hoist": { - "version": "27.5.1", - "resolved": "https://registry.npmjs.org/babel-plugin-jest-hoist/-/babel-plugin-jest-hoist-27.5.1.tgz", - "integrity": "sha512-50wCwD5EMNW4aRpOwtqzyZHIewTYNxLA4nhB+09d8BIssfNfzBRhkBIHiaPv1Si226TQSvp8gxAJm2iY2qs2hQ==", - "dependencies": { - "@babel/template": "^7.3.3", - "@babel/types": "^7.3.3", - "@types/babel__core": "^7.0.0", - "@types/babel__traverse": "^7.0.6" - }, - "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" - } - }, - "node_modules/babel-plugin-macros": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/babel-plugin-macros/-/babel-plugin-macros-3.1.0.tgz", - "integrity": "sha512-Cg7TFGpIr01vOQNODXOOaGz2NpCU5gl8x1qJFbb6hbZxR7XrcE2vtbAsTAbJ7/xwJtUuJEw8K8Zr/AE0LHlesg==", - "dependencies": { - "@babel/runtime": "^7.12.5", - "cosmiconfig": "^7.0.0", - "resolve": "^1.19.0" - }, - "engines": { - "node": ">=10", - "npm": ">=6" - } - }, - "node_modules/babel-plugin-named-asset-import": { - "version": "0.3.8", - "resolved": "https://registry.npmjs.org/babel-plugin-named-asset-import/-/babel-plugin-named-asset-import-0.3.8.tgz", - "integrity": "sha512-WXiAc++qo7XcJ1ZnTYGtLxmBCVbddAml3CEXgWaBzNzLNoxtQ8AiGEFDMOhot9XjTCQbvP5E77Fj9Gk924f00Q==", - "peerDependencies": { - "@babel/core": "^7.1.0" - } - }, - "node_modules/babel-plugin-polyfill-corejs2": { - "version": "0.3.3", - "resolved": "https://registry.npmjs.org/babel-plugin-polyfill-corejs2/-/babel-plugin-polyfill-corejs2-0.3.3.tgz", - "integrity": "sha512-8hOdmFYFSZhqg2C/JgLUQ+t52o5nirNwaWM2B9LWteozwIvM14VSwdsCAUET10qT+kmySAlseadmfeeSWFCy+Q==", - "dependencies": { - "@babel/compat-data": "^7.17.7", - "@babel/helper-define-polyfill-provider": "^0.3.3", - "semver": "^6.1.1" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/babel-plugin-polyfill-corejs2/node_modules/semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", - "bin": { - "semver": "bin/semver.js" - } - }, - "node_modules/babel-plugin-polyfill-corejs3": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/babel-plugin-polyfill-corejs3/-/babel-plugin-polyfill-corejs3-0.6.0.tgz", - "integrity": "sha512-+eHqR6OPcBhJOGgsIar7xoAB1GcSwVUA3XjAd7HJNzOXT4wv6/H7KIdA/Nc60cvUlDbKApmqNvD1B1bzOt4nyA==", - "dependencies": { - "@babel/helper-define-polyfill-provider": "^0.3.3", - "core-js-compat": "^3.25.1" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/babel-plugin-polyfill-regenerator": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/babel-plugin-polyfill-regenerator/-/babel-plugin-polyfill-regenerator-0.4.1.tgz", - "integrity": "sha512-NtQGmyQDXjQqQ+IzRkBVwEOz9lQ4zxAQZgoAYEtU9dJjnl1Oc98qnN7jcp+bE7O7aYzVpavXE3/VKXNzUbh7aw==", - "dependencies": { - "@babel/helper-define-polyfill-provider": "^0.3.3" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/babel-plugin-transform-react-remove-prop-types": { - "version": "0.4.24", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-react-remove-prop-types/-/babel-plugin-transform-react-remove-prop-types-0.4.24.tgz", - "integrity": "sha512-eqj0hVcJUR57/Ug2zE1Yswsw4LhuqqHhD+8v120T1cl3kjg76QwtyBrdIk4WVwK+lAhBJVYCd/v+4nc4y+8JsA==" - }, - "node_modules/babel-preset-current-node-syntax": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/babel-preset-current-node-syntax/-/babel-preset-current-node-syntax-1.0.1.tgz", - "integrity": "sha512-M7LQ0bxarkxQoN+vz5aJPsLBn77n8QgTFmo8WK0/44auK2xlCXrYcUxHFxgU7qW5Yzw/CjmLRK2uJzaCd7LvqQ==", - "dependencies": { - "@babel/plugin-syntax-async-generators": "^7.8.4", - "@babel/plugin-syntax-bigint": "^7.8.3", - "@babel/plugin-syntax-class-properties": "^7.8.3", - "@babel/plugin-syntax-import-meta": "^7.8.3", - "@babel/plugin-syntax-json-strings": "^7.8.3", - "@babel/plugin-syntax-logical-assignment-operators": "^7.8.3", - "@babel/plugin-syntax-nullish-coalescing-operator": "^7.8.3", - "@babel/plugin-syntax-numeric-separator": "^7.8.3", - "@babel/plugin-syntax-object-rest-spread": "^7.8.3", - "@babel/plugin-syntax-optional-catch-binding": "^7.8.3", - "@babel/plugin-syntax-optional-chaining": "^7.8.3", - "@babel/plugin-syntax-top-level-await": "^7.8.3" - }, - "peerDependencies": { - "@babel/core": "^7.0.0" - } - }, - "node_modules/babel-preset-jest": { - "version": "27.5.1", - "resolved": "https://registry.npmjs.org/babel-preset-jest/-/babel-preset-jest-27.5.1.tgz", - "integrity": "sha512-Nptf2FzlPCWYuJg41HBqXVT8ym6bXOevuCTbhxlUpjwtysGaIWFvDEjp4y+G7fl13FgOdjs7P/DmErqH7da0Ag==", - "dependencies": { - "babel-plugin-jest-hoist": "^27.5.1", - "babel-preset-current-node-syntax": "^1.0.0" - }, - "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0" - } - }, - "node_modules/babel-preset-react-app": { - "version": "10.0.1", - "resolved": "https://registry.npmjs.org/babel-preset-react-app/-/babel-preset-react-app-10.0.1.tgz", - "integrity": "sha512-b0D9IZ1WhhCWkrTXyFuIIgqGzSkRIH5D5AmB0bXbzYAB1OBAwHcUeyWW2LorutLWF5btNo/N7r/cIdmvvKJlYg==", - "dependencies": { - "@babel/core": "^7.16.0", - "@babel/plugin-proposal-class-properties": "^7.16.0", - "@babel/plugin-proposal-decorators": "^7.16.4", - "@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.0", - "@babel/plugin-proposal-numeric-separator": "^7.16.0", - "@babel/plugin-proposal-optional-chaining": "^7.16.0", - "@babel/plugin-proposal-private-methods": "^7.16.0", - "@babel/plugin-transform-flow-strip-types": "^7.16.0", - "@babel/plugin-transform-react-display-name": "^7.16.0", - "@babel/plugin-transform-runtime": "^7.16.4", - "@babel/preset-env": "^7.16.4", - "@babel/preset-react": "^7.16.0", - "@babel/preset-typescript": "^7.16.0", - "@babel/runtime": "^7.16.3", - "babel-plugin-macros": "^3.1.0", - "babel-plugin-transform-react-remove-prop-types": "^0.4.24" - } - }, - "node_modules/babel-runtime": { - "version": "6.26.0", - "resolved": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-6.26.0.tgz", - "integrity": "sha512-ITKNuq2wKlW1fJg9sSW52eepoYgZBggvOAHC0u/CYu/qxQ9EVzThCgR69BnSXLHjy2f7SY5zaQ4yt7H9ZVxY2g==", - "dependencies": { - "core-js": "^2.4.0", - "regenerator-runtime": "^0.11.0" - } - }, - "node_modules/babel-runtime/node_modules/core-js": { - "version": "2.6.12", - "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.6.12.tgz", - "integrity": "sha512-Kb2wC0fvsWfQrgk8HU5lW6U/Lcs8+9aaYcy4ZFc6DDlo4nZ7n70dEgE5rtR0oG6ufKDUnrwfWL1mXR5ljDatrQ==", - "deprecated": "core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.", - "hasInstallScript": true - }, - "node_modules/babel-runtime/node_modules/regenerator-runtime": { - "version": "0.11.1", - "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz", - "integrity": "sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg==" - }, - "node_modules/babel-traverse": { - "version": "6.26.0", - "resolved": "https://registry.npmjs.org/babel-traverse/-/babel-traverse-6.26.0.tgz", - "integrity": "sha512-iSxeXx7apsjCHe9c7n8VtRXGzI2Bk1rBSOJgCCjfyXb6v1aCqE1KSEpq/8SXuVN8Ka/Rh1WDTF0MDzkvTA4MIA==", - "dependencies": { - "babel-code-frame": "^6.26.0", - "babel-messages": "^6.23.0", - "babel-runtime": "^6.26.0", - "babel-types": "^6.26.0", - "babylon": "^6.18.0", - "debug": "^2.6.8", - "globals": "^9.18.0", - "invariant": "^2.2.2", - "lodash": "^4.17.4" - } - }, - "node_modules/babel-traverse/node_modules/debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "dependencies": { - "ms": "2.0.0" - } - }, - "node_modules/babel-traverse/node_modules/globals": { - "version": "9.18.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-9.18.0.tgz", - "integrity": "sha512-S0nG3CLEQiY/ILxqtztTWH/3iRRdyBLw6KMDxnKMchrtbj2OFmehVh0WUCfW3DUrIgx/qFrJPICrq4Z4sTR9UQ==", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/babel-traverse/node_modules/ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" - }, - "node_modules/babel-types": { - "version": "6.26.0", - "resolved": "https://registry.npmjs.org/babel-types/-/babel-types-6.26.0.tgz", - "integrity": "sha512-zhe3V/26rCWsEZK8kZN+HaQj5yQ1CilTObixFzKW1UWjqG7618Twz6YEsCnjfg5gBcJh02DrpCkS9h98ZqDY+g==", - "dependencies": { - "babel-runtime": "^6.26.0", - "esutils": "^2.0.2", - "lodash": "^4.17.4", - "to-fast-properties": "^1.0.3" - } - }, - "node_modules/babel-types/node_modules/to-fast-properties": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-1.0.3.tgz", - "integrity": "sha512-lxrWP8ejsq+7E3nNjwYmUBMAgjMTZoTI+sdBOpvNyijeDLa29LUn9QaoXAHv4+Z578hbmHHJKZknzxVtvo77og==", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/babylon": { - "version": "6.18.0", - "resolved": "https://registry.npmjs.org/babylon/-/babylon-6.18.0.tgz", - "integrity": "sha512-q/UEjfGJ2Cm3oKV71DJz9d25TPnq5rhBVL2Q4fA5wcC3jcrdn7+SssEybFIxwAvvP+YCsCYNKughoF33GxgycQ==", - "bin": { - "babylon": "bin/babylon.js" - } - }, - "node_modules/balanced-match": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", - "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" - }, - "node_modules/base64id": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/base64id/-/base64id-2.0.0.tgz", - "integrity": "sha512-lGe34o6EHj9y3Kts9R4ZYs/Gr+6N7MCaMlIFA3F1R2O5/m7K06AxfSeO5530PEERE6/WyEg3lsuyw4GHlPZHog==", - "engines": { - "node": "^4.5.0 || >= 5.9" - } - }, - "node_modules/batch": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/batch/-/batch-0.6.1.tgz", - "integrity": "sha512-x+VAiMRL6UPkx+kudNvxTl6hB2XNNCG2r+7wixVfIYwu/2HKRXimwQyaumLjMveWvT2Hkd/cAJw+QBMfJ/EKVw==" - }, - "node_modules/bcrypt-pbkdf": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz", - "integrity": "sha512-qeFIXtP4MSoi6NLqO12WfqARWWuCKi2Rn/9hJLEmtB5yTNr9DqFWkJRCf2qShWzPeAMRnOgCrq0sg/KLv5ES9w==", - "optional": true, - "dependencies": { - "tweetnacl": "^0.14.3" - } - }, - "node_modules/bfj": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/bfj/-/bfj-7.0.2.tgz", - "integrity": "sha512-+e/UqUzwmzJamNF50tBV6tZPTORow7gQ96iFow+8b562OdMpEK0BcJEq2OSPEDmAbSMBQ7PKZ87ubFkgxpYWgw==", - "dependencies": { - "bluebird": "^3.5.5", - "check-types": "^11.1.1", - "hoopy": "^0.1.4", - "tryer": "^1.0.1" - }, - "engines": { - "node": ">= 8.0.0" - } - }, - "node_modules/big.js": { - "version": "5.2.2", - "resolved": "https://registry.npmjs.org/big.js/-/big.js-5.2.2.tgz", - "integrity": "sha512-vyL2OymJxmarO8gxMr0mhChsO9QGwhynfuu4+MHTAW6czfq9humCB7rKpUjDd9YUiDPU4mzpyupFSvOClAwbmQ==", - "engines": { - "node": "*" - } - }, - "node_modules/binary-extensions": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", - "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==", - "engines": { - "node": ">=8" - } - }, - "node_modules/bluebird": { - "version": "3.7.2", - "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz", - "integrity": "sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg==" - }, - "node_modules/body-parser": { - "version": "1.20.1", - "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.1.tgz", - "integrity": "sha512-jWi7abTbYwajOytWCQc37VulmWiRae5RyTpaCyDcS5/lMdtwSz5lOpDE67srw/HYe35f1z3fDQw+3txg7gNtWw==", - "dependencies": { - "bytes": "3.1.2", - "content-type": "~1.0.4", - "debug": "2.6.9", - "depd": "2.0.0", - "destroy": "1.2.0", - "http-errors": "2.0.0", - "iconv-lite": "0.4.24", - "on-finished": "2.4.1", - "qs": "6.11.0", - "raw-body": "2.5.1", - "type-is": "~1.6.18", - "unpipe": "1.0.0" - }, - "engines": { - "node": ">= 0.8", - "npm": "1.2.8000 || >= 1.4.16" - } - }, - "node_modules/body-parser/node_modules/bytes": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", - "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==", - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/body-parser/node_modules/debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "dependencies": { - "ms": "2.0.0" - } - }, - "node_modules/body-parser/node_modules/iconv-lite": { - "version": "0.4.24", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", - "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", - "dependencies": { - "safer-buffer": ">= 2.1.2 < 3" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/body-parser/node_modules/ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" - }, - "node_modules/bonjour-service": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/bonjour-service/-/bonjour-service-1.1.1.tgz", - "integrity": "sha512-Z/5lQRMOG9k7W+FkeGTNjh7htqn/2LMnfOvBZ8pynNZCM9MwkQkI3zeI4oz09uWdcgmgHugVvBqxGg4VQJ5PCg==", - "dependencies": { - "array-flatten": "^2.1.2", - "dns-equal": "^1.0.0", - "fast-deep-equal": "^3.1.3", - "multicast-dns": "^7.2.5" - } - }, - "node_modules/boolbase": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz", - "integrity": "sha512-JZOSA7Mo9sNGB8+UjSgzdLtokWAky1zbztM3WRLCbZ70/3cTANmQmOdR7y2g+J0e2WXywy1yS468tY+IruqEww==" - }, - "node_modules/brace-expansion": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "dependencies": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, - "node_modules/braces": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", - "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", - "dependencies": { - "fill-range": "^7.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/brainjs": { - "version": "0.7.4", - "resolved": "https://registry.npmjs.org/brainjs/-/brainjs-0.7.4.tgz", - "integrity": "sha512-wLvuy9ZPjbzBwsDcg7Z9Ri31MXE6+TiDispBXLPp0ErbM7xxMXRPw6Q2darpj2nCPrT39kv7cWXPOls2+XIqHw==", - "dependencies": { - "inherits": "~2.0.1", - "underscore": ">=1.5.1" - } - }, - "node_modules/browser-process-hrtime": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/browser-process-hrtime/-/browser-process-hrtime-1.0.0.tgz", - "integrity": "sha512-9o5UecI3GhkpM6DrXr69PblIuWxPKk9Y0jHBRhdocZ2y7YECBFCsHm79Pr3OyR2AvjhDkabFJaDJMYRazHgsow==" - }, - "node_modules/browserslist": { - "version": "4.21.5", - "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.21.5.tgz", - "integrity": "sha512-tUkiguQGW7S3IhB7N+c2MV/HZPSCPAAiYBZXLsBhFB/PCy6ZKKsZrmBayHV9fdGV/ARIfJ14NkxKzRDjvp7L6w==", - "funding": [ - { - "type": "opencollective", - "url": "https://opencollective.com/browserslist" - }, - { - "type": "tidelift", - "url": "https://tidelift.com/funding/github/npm/browserslist" - } - ], - "dependencies": { - "caniuse-lite": "^1.0.30001449", - "electron-to-chromium": "^1.4.284", - "node-releases": "^2.0.8", - "update-browserslist-db": "^1.0.10" - }, - "bin": { - "browserslist": "cli.js" - }, - "engines": { - "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" - } - }, - "node_modules/bser": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/bser/-/bser-2.1.1.tgz", - "integrity": "sha512-gQxTNE/GAfIIrmHLUE3oJyp5FO6HRBfhjnw4/wMmA63ZGDJnWBmgY/lyQBpnDUkGmAhbSe39tx2d/iTOAfglwQ==", - "dependencies": { - "node-int64": "^0.4.0" - } - }, - "node_modules/buffer-from": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", - "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==" - }, - "node_modules/builtin-modules": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-3.3.0.tgz", - "integrity": "sha512-zhaCDicdLuWN5UbN5IMnFqNMhNfo919sH85y2/ea+5Yg9TsTkeZxpL+JLbp6cgYFS4sRLp3YV4S6yDuqVWHYOw==", - "engines": { - "node": ">=6" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/builtin-status-codes": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz", - "integrity": "sha512-HpGFw18DgFWlncDfjTa2rcQ4W88O1mC8e8yZ2AvQY5KDaktSTwo+KRf6nHK6FRI5FyRyb/5T6+TSxfP7QyGsmQ==" - }, - "node_modules/bytes": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz", - "integrity": "sha512-pMhOfFDPiv9t5jjIXkHosWmkSyQbvsgEVNkz0ERHbuLh2T/7j4Mqqpz523Fe8MVY89KC6Sh/QfS2sM+SjgFDcw==", - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/call-bind": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz", - "integrity": "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==", - "dependencies": { - "function-bind": "^1.1.1", - "get-intrinsic": "^1.0.2" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/callsites": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", - "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", - "engines": { - "node": ">=6" - } - }, - "node_modules/camel-case": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/camel-case/-/camel-case-4.1.2.tgz", - "integrity": "sha512-gxGWBrTT1JuMx6R+o5PTXMmUnhnVzLQ9SNutD4YqKtI6ap897t3tKECYla6gCWEkplXnlNybEkZg9GEGxKFCgw==", - "dependencies": { - "pascal-case": "^3.1.2", - "tslib": "^2.0.3" - } - }, - "node_modules/camelcase": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz", - "integrity": "sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==", - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/camelcase-css": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/camelcase-css/-/camelcase-css-2.0.1.tgz", - "integrity": "sha512-QOSvevhslijgYwRx6Rv7zKdMF8lbRmx+uQGx2+vDc+KI/eBnsy9kit5aj23AgGu3pa4t9AgwbnXWqS+iOY+2aA==", - "engines": { - "node": ">= 6" - } - }, - "node_modules/caniuse-api": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/caniuse-api/-/caniuse-api-3.0.0.tgz", - "integrity": "sha512-bsTwuIg/BZZK/vreVTYYbSWoe2F+71P7K5QGEX+pT250DZbfU1MQ5prOKpPR+LL6uWKK3KMwMCAS74QB3Um1uw==", - "dependencies": { - "browserslist": "^4.0.0", - "caniuse-lite": "^1.0.0", - "lodash.memoize": "^4.1.2", - "lodash.uniq": "^4.5.0" - } - }, - "node_modules/caniuse-lite": { - "version": "1.0.30001489", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001489.tgz", - "integrity": "sha512-x1mgZEXK8jHIfAxm+xgdpHpk50IN3z3q3zP261/WS+uvePxW8izXuCu6AHz0lkuYTlATDehiZ/tNyYBdSQsOUQ==", - "funding": [ - { - "type": "opencollective", - "url": "https://opencollective.com/browserslist" - }, - { - "type": "tidelift", - "url": "https://tidelift.com/funding/github/npm/caniuse-lite" - }, - { - "type": "github", - "url": "https://github.com/sponsors/ai" - } - ] - }, - "node_modules/case-anything": { - "version": "2.1.12", - "resolved": "https://registry.npmjs.org/case-anything/-/case-anything-2.1.12.tgz", - "integrity": "sha512-EKzcjF1KmtgL2aqW4Xi/aTAXBaQhbTL6StFmjzdm75cW9z6Cq0WU6DiejhbETlxY4SS3Dll5GYVxwDWc0BqEDg==", - "peer": true, - "engines": { - "node": ">=12.13" - }, - "funding": { - "url": "https://github.com/sponsors/mesqueeb" - } - }, - "node_modules/case-sensitive-paths-webpack-plugin": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/case-sensitive-paths-webpack-plugin/-/case-sensitive-paths-webpack-plugin-2.4.0.tgz", - "integrity": "sha512-roIFONhcxog0JSSWbvVAh3OocukmSgpqOH6YpMkCvav/ySIV3JKg4Dc8vYtQjYi/UxpNE36r/9v+VqTQqgkYmw==", - "engines": { - "node": ">=4" - } - }, - "node_modules/caseless": { - "version": "0.12.0", - "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", - "integrity": "sha512-4tYFyifaFfGacoiObjJegolkwSU4xQNGbVgUiNYVUxbQ2x2lUsFvY4hVgVzGiIe6WLOPqycWXA40l+PWsxthUw==", - "optional": true - }, - "node_modules/chalk": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", - "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", - "dependencies": { - "ansi-styles": "^3.2.1", - "escape-string-regexp": "^1.0.5", - "supports-color": "^5.3.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/char-regex": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/char-regex/-/char-regex-1.0.2.tgz", - "integrity": "sha512-kWWXztvZ5SBQV+eRgKFeh8q5sLuZY2+8WUIzlxWVTg+oGwY14qylx1KbKzHd8P6ZYkAg0xyIDU9JMHhyJMZ1jw==", - "engines": { - "node": ">=10" - } - }, - "node_modules/check-types": { - "version": "11.2.2", - "resolved": "https://registry.npmjs.org/check-types/-/check-types-11.2.2.tgz", - "integrity": "sha512-HBiYvXvn9Z70Z88XKjz3AEKd4HJhBXsa3j7xFnITAzoS8+q6eIGi8qDB8FKPBAjtuxjI/zFpwuiCb8oDtKOYrA==" - }, - "node_modules/cheerio": { - "version": "1.0.0-rc.2", - "resolved": "https://registry.npmjs.org/cheerio/-/cheerio-1.0.0-rc.2.tgz", - "integrity": "sha512-9LDHQy1jHc/eXMzPN6/oah9Qba4CjdKECC7YYEE/2zge/tsGwt19NQp5NFdfd5Lx6TZlyC5SXNQkG41P9r6XDg==", - "dependencies": { - "css-select": "~1.2.0", - "dom-serializer": "~0.1.0", - "entities": "~1.1.1", - "htmlparser2": "^3.9.1", - "lodash": "^4.15.0", - "parse5": "^3.0.1" - }, - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/cheerio/node_modules/css-select": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/css-select/-/css-select-1.2.0.tgz", - "integrity": "sha512-dUQOBoqdR7QwV90WysXPLXG5LO7nhYBgiWVfxF80DKPF8zx1t/pUd2FYy73emg3zrjtM6dzmYgbHKfV2rxiHQA==", - "dependencies": { - "boolbase": "~1.0.0", - "css-what": "2.1", - "domutils": "1.5.1", - "nth-check": "~1.0.1" - } - }, - "node_modules/cheerio/node_modules/css-what": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/css-what/-/css-what-2.1.3.tgz", - "integrity": "sha512-a+EPoD+uZiNfh+5fxw2nO9QwFa6nJe2Or35fGY6Ipw1R3R4AGz1d1TEZrCegvw2YTmZ0jXirGYlzxxpYSHwpEg==", - "engines": { - "node": "*" - } - }, - "node_modules/cheerio/node_modules/dom-serializer": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-0.1.1.tgz", - "integrity": "sha512-l0IU0pPzLWSHBcieZbpOKgkIn3ts3vAh7ZuFyXNwJxJXk/c4Gwj9xaTJwIDVQCXawWD0qb3IzMGH5rglQaO0XA==", - "dependencies": { - "domelementtype": "^1.3.0", - "entities": "^1.1.1" - } - }, - "node_modules/cheerio/node_modules/domelementtype": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-1.3.1.tgz", - "integrity": "sha512-BSKB+TSpMpFI/HOxCNr1O8aMOTZ8hT3pM3GQ0w/mWRmkhEDSFJkkyzz4XQsBV44BChwGkrDfMyjVD0eA2aFV3w==" - }, - "node_modules/cheerio/node_modules/domhandler": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-2.4.2.tgz", - "integrity": "sha512-JiK04h0Ht5u/80fdLMCEmV4zkNh2BcoMFBmZ/91WtYZ8qVXSKjiw7fXMgFPnHcSZgOo3XdinHvmnDUeMf5R4wA==", - "dependencies": { - "domelementtype": "1" - } - }, - "node_modules/cheerio/node_modules/domutils": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/domutils/-/domutils-1.5.1.tgz", - "integrity": "sha512-gSu5Oi/I+3wDENBsOWBiRK1eoGxcywYSqg3rR960/+EfY0CF4EX1VPkgHOZ3WiS/Jg2DtliF6BhWcHlfpYUcGw==", - "dependencies": { - "dom-serializer": "0", - "domelementtype": "1" - } - }, - "node_modules/cheerio/node_modules/entities": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/entities/-/entities-1.1.2.tgz", - "integrity": "sha512-f2LZMYl1Fzu7YSBKg+RoROelpOaNrcGmE9AZubeDfrCEia483oW4MI4VyFd5VNHIgQ/7qm1I0wUHK1eJnn2y2w==" - }, - "node_modules/cheerio/node_modules/htmlparser2": { - "version": "3.10.1", - "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-3.10.1.tgz", - "integrity": "sha512-IgieNijUMbkDovyoKObU1DUhm1iwNYE/fuifEoEHfd1oZKZDaONBSkal7Y01shxsM49R4XaMdGez3WnF9UfiCQ==", - "dependencies": { - "domelementtype": "^1.3.1", - "domhandler": "^2.3.0", - "domutils": "^1.5.1", - "entities": "^1.1.1", - "inherits": "^2.0.1", - "readable-stream": "^3.1.1" - } - }, - "node_modules/cheerio/node_modules/nth-check": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/nth-check/-/nth-check-1.0.2.tgz", - "integrity": "sha512-WeBOdju8SnzPN5vTUJYxYUxLeXpCaVP5i5e0LF8fg7WORF2Wd7wFX/pk0tYZk7s8T+J7VLy0Da6J1+wCT0AtHg==", - "dependencies": { - "boolbase": "~1.0.0" - } - }, - "node_modules/cheerio/node_modules/parse5": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/parse5/-/parse5-3.0.3.tgz", - "integrity": "sha512-rgO9Zg5LLLkfJF9E6CCmXlSE4UVceloys8JrFqCcHloC3usd/kJCyPDwH2SOlzix2j3xaP9sUX3e8+kvkuleAA==", - "dependencies": { - "@types/node": "*" - } - }, - "node_modules/chokidar": { - "version": "3.5.3", - "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz", - "integrity": "sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==", - "funding": [ - { - "type": "individual", - "url": "https://paulmillr.com/funding/" - } - ], - "dependencies": { - "anymatch": "~3.1.2", - "braces": "~3.0.2", - "glob-parent": "~5.1.2", - "is-binary-path": "~2.1.0", - "is-glob": "~4.0.1", - "normalize-path": "~3.0.0", - "readdirp": "~3.6.0" - }, - "engines": { - "node": ">= 8.10.0" - }, - "optionalDependencies": { - "fsevents": "~2.3.2" - } - }, - "node_modules/chokidar/node_modules/glob-parent": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", - "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", - "dependencies": { - "is-glob": "^4.0.1" - }, - "engines": { - "node": ">= 6" - } - }, - "node_modules/chownr": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.4.tgz", - "integrity": "sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==" - }, - "node_modules/chrome-trace-event": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/chrome-trace-event/-/chrome-trace-event-1.0.3.tgz", - "integrity": "sha512-p3KULyQg4S7NIHixdwbGX+nFHkoBiA4YQmyWtjb8XngSKV124nJmRysgAeujbUVb15vh+RvFUfCPqU7rXk+hZg==", - "engines": { - "node": ">=6.0" - } - }, - "node_modules/ci-info": { - "version": "3.8.0", - "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.8.0.tgz", - "integrity": "sha512-eXTggHWSooYhq49F2opQhuHWgzucfF2YgODK4e1566GQs5BIfP30B0oenwBJHfWxAs2fyPB1s7Mg949zLf61Yw==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/sibiraj-s" - } - ], - "engines": { - "node": ">=8" - } - }, - "node_modules/cjs-module-lexer": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/cjs-module-lexer/-/cjs-module-lexer-1.2.2.tgz", - "integrity": "sha512-cOU9usZw8/dXIXKtwa8pM0OTJQuJkxMN6w30csNRUerHfeQ5R6U3kkU/FtJeIf3M202OHfY2U8ccInBG7/xogA==" - }, - "node_modules/clean-css": { - "version": "5.3.2", - "resolved": "https://registry.npmjs.org/clean-css/-/clean-css-5.3.2.tgz", - "integrity": "sha512-JVJbM+f3d3Q704rF4bqQ5UUyTtuJ0JRKNbTKVEeujCCBoMdkEi+V+e8oktO9qGQNSvHrFTM6JZRXrUvGR1czww==", - "dependencies": { - "source-map": "~0.6.0" - }, - "engines": { - "node": ">= 10.0" - } - }, - "node_modules/clean-css/node_modules/source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/cliui": { - "version": "7.0.4", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", - "integrity": "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==", - "dependencies": { - "string-width": "^4.2.0", - "strip-ansi": "^6.0.0", - "wrap-ansi": "^7.0.0" - } - }, - "node_modules/clsx": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/clsx/-/clsx-1.1.1.tgz", - "integrity": "sha512-6/bPho624p3S2pMyvP5kKBPXnI3ufHLObBFCfgx+LkeR5lg2XYy2hqZqUf45ypD8COn2bhgGJSUE+l5dhNBieA==", - "engines": { - "node": ">=6" - } - }, - "node_modules/co": { - "version": "4.6.0", - "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", - "integrity": "sha512-QVb0dM5HvG+uaxitm8wONl7jltx8dqhfU33DcqtOZcLSVIKSDDLDi7+0LbAKiyI8hD9u42m2YxXSkMGWThaecQ==", - "engines": { - "iojs": ">= 1.0.0", - "node": ">= 0.12.0" - } - }, - "node_modules/coa": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/coa/-/coa-2.0.2.tgz", - "integrity": "sha512-q5/jG+YQnSy4nRTV4F7lPepBJZ8qBNJJDBuJdoejDyLXgmL7IEo+Le2JDZudFTFt7mrCqIRaSjws4ygRCTCAXA==", - "dependencies": { - "@types/q": "^1.5.1", - "chalk": "^2.4.1", - "q": "^1.1.2" - }, - "engines": { - "node": ">= 4.0" - } - }, - "node_modules/code-point-at": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", - "integrity": "sha512-RpAVKQA5T63xEj6/giIbUEtZwJ4UFIc3ZtvEkiaUERylqe8xb5IvqcgOurZLahv93CLKfxcw5YI+DZcUBRyLXA==", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/collect-v8-coverage": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/collect-v8-coverage/-/collect-v8-coverage-1.0.1.tgz", - "integrity": "sha512-iBPtljfCNcTKNAto0KEtDfZ3qzjJvqE3aTGZsbhjSBlorqpXJlaWWtPO35D+ZImoC3KWejX64o+yPGxhWSTzfg==" - }, - "node_modules/color-convert": { - "version": "1.9.3", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", - "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", - "dependencies": { - "color-name": "1.1.3" - } - }, - "node_modules/color-logger": { - "version": "0.0.6", - "resolved": "https://registry.npmjs.org/color-logger/-/color-logger-0.0.6.tgz", - "integrity": "sha512-0iBj3eHRYnor8EJi3oQ1kixbr7B2Sbw1InxjsYZxS+q2H+Ii69m3ARYSJeYIqmf/QRtFhWnR1v97wp8N7ABubw==" - }, - "node_modules/color-name": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", - "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==" - }, - "node_modules/colord": { - "version": "2.9.3", - "resolved": "https://registry.npmjs.org/colord/-/colord-2.9.3.tgz", - "integrity": "sha512-jeC1axXpnb0/2nn/Y1LPuLdgXBLH7aDcHu4KEKfqw3CUhX7ZpfBSlPKyqXE6btIgEzfWtrX3/tyBCaCvXvMkOw==" - }, - "node_modules/colorette": { - "version": "2.0.20", - "resolved": "https://registry.npmjs.org/colorette/-/colorette-2.0.20.tgz", - "integrity": "sha512-IfEDxwoWIjkeXL1eXcDiow4UbKjhLdq6/EuSVR9GMN7KVH3r9gQ83e73hsz1Nd1T3ijd5xv1wcWRYO+D6kCI2w==" - }, - "node_modules/combined-stream": { - "version": "1.0.8", - "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", - "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", - "dependencies": { - "delayed-stream": "~1.0.0" - }, - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/commander": { - "version": "8.3.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-8.3.0.tgz", - "integrity": "sha512-OkTL9umf+He2DZkUq8f8J9of7yL6RJKI24dVITBmNfZBmri9zYZQrKkuXiKhyfPSu8tUhnVBB1iKXevvnlR4Ww==", - "engines": { - "node": ">= 12" - } - }, - "node_modules/common-path-prefix": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/common-path-prefix/-/common-path-prefix-3.0.0.tgz", - "integrity": "sha512-QE33hToZseCH3jS0qN96O/bSh3kaw/h+Tq7ngyY9eWDUnTlTNUyqfqvCXioLe5Na5jFsL78ra/wuBU4iuEgd4w==" - }, - "node_modules/common-tags": { - "version": "1.8.2", - "resolved": "https://registry.npmjs.org/common-tags/-/common-tags-1.8.2.tgz", - "integrity": "sha512-gk/Z852D2Wtb//0I+kRFNKKE9dIIVirjoqPoA1wJU+XePVXZfGeBpk45+A1rKO4Q43prqWBNY/MiIeRLbPWUaA==", - "engines": { - "node": ">=4.0.0" - } - }, - "node_modules/commondir": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz", - "integrity": "sha512-W9pAhw0ja1Edb5GVdIF1mjZw/ASI0AlShXM83UUGe2DVr5TdAPEA1OA8m/g8zWp9x6On7gqufY+FatDbC3MDQg==" - }, - "node_modules/compressible": { - "version": "2.0.18", - "resolved": "https://registry.npmjs.org/compressible/-/compressible-2.0.18.tgz", - "integrity": "sha512-AF3r7P5dWxL8MxyITRMlORQNaOA2IkAFaTr4k7BUumjPtRpGDTZpl0Pb1XCO6JeDCBdp126Cgs9sMxqSjgYyRg==", - "dependencies": { - "mime-db": ">= 1.43.0 < 2" - }, - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/compression": { - "version": "1.7.4", - "resolved": "https://registry.npmjs.org/compression/-/compression-1.7.4.tgz", - "integrity": "sha512-jaSIDzP9pZVS4ZfQ+TzvtiWhdpFhE2RDHz8QJkpX9SIpLq88VueF5jJw6t+6CUQcAoA6t+x89MLrWAqpfDE8iQ==", - "dependencies": { - "accepts": "~1.3.5", - "bytes": "3.0.0", - "compressible": "~2.0.16", - "debug": "2.6.9", - "on-headers": "~1.0.2", - "safe-buffer": "5.1.2", - "vary": "~1.1.2" - }, - "engines": { - "node": ">= 0.8.0" - } - }, - "node_modules/compression/node_modules/debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "dependencies": { - "ms": "2.0.0" - } - }, - "node_modules/compression/node_modules/ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" - }, - "node_modules/compression/node_modules/safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" - }, - "node_modules/concat-map": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==" - }, - "node_modules/confusing-browser-globals": { - "version": "1.0.11", - "resolved": "https://registry.npmjs.org/confusing-browser-globals/-/confusing-browser-globals-1.0.11.tgz", - "integrity": "sha512-JsPKdmh8ZkmnHxDk55FZ1TqVLvEQTvoByJZRN9jzI0UjxK/QgAmsphz7PGtqgPieQZ/CQcHWXCR7ATDNhGe+YA==" - }, - "node_modules/connect-history-api-fallback": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/connect-history-api-fallback/-/connect-history-api-fallback-2.0.0.tgz", - "integrity": "sha512-U73+6lQFmfiNPrYbXqr6kZ1i1wiRqXnp2nhMsINseWXO8lDau0LGEffJ8kQi4EjLZympVgRdvqjAgiZ1tgzDDA==", - "engines": { - "node": ">=0.8" - } - }, - "node_modules/console-control-strings": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", - "integrity": "sha512-ty/fTekppD2fIwRvnZAVdeOiGd1c7YXEixbgJTNzqcxJWKQnjJ/V1bNEEE6hygpM3WjwHFUVK6HTjWSzV4a8sQ==" - }, - "node_modules/content-disposition": { - "version": "0.5.4", - "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz", - "integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==", - "dependencies": { - "safe-buffer": "5.2.1" - }, - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/content-type": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz", - "integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/convert-source-map": { - "version": "1.9.0", - "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.9.0.tgz", - "integrity": "sha512-ASFBup0Mz1uyiIjANan1jzLQami9z1PoYSZCiiYW2FczPbenXc45FZdBZLzOT+r6+iciuEModtmCti+hjaAk0A==" - }, - "node_modules/cookie": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.5.0.tgz", - "integrity": "sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw==", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/cookie-signature": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", - "integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ==" - }, - "node_modules/core-js": { - "version": "3.30.2", - "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.30.2.tgz", - "integrity": "sha512-uBJiDmwqsbJCWHAwjrx3cvjbMXP7xD72Dmsn5LOJpiRmE3WbBbN5rCqQ2Qh6Ek6/eOrjlWngEynBWo4VxerQhg==", - "hasInstallScript": true, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/core-js" - } - }, - "node_modules/core-js-compat": { - "version": "3.30.2", - "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.30.2.tgz", - "integrity": "sha512-nriW1nuJjUgvkEjIot1Spwakz52V9YkYHZAQG6A1eCgC8AA1p0zngrQEP9R0+V6hji5XilWKG1Bd0YRppmGimA==", - "dependencies": { - "browserslist": "^4.21.5" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/core-js" - } - }, - "node_modules/core-js-pure": { - "version": "3.30.2", - "resolved": "https://registry.npmjs.org/core-js-pure/-/core-js-pure-3.30.2.tgz", - "integrity": "sha512-p/npFUJXXBkCCTIlEGBdghofn00jWG6ZOtdoIXSJmAu2QBvN0IqpZXWweOytcwE6cfx8ZvVUy1vw8zxhe4Y2vg==", - "hasInstallScript": true, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/core-js" - } - }, - "node_modules/core-util-is": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", - "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==" - }, - "node_modules/cors": { - "version": "2.8.5", - "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz", - "integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==", - "dependencies": { - "object-assign": "^4", - "vary": "^1" - }, - "engines": { - "node": ">= 0.10" - } - }, - "node_modules/cosmiconfig": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-7.1.0.tgz", - "integrity": "sha512-AdmX6xUzdNASswsFtmwSt7Vj8po9IuqXm0UXz7QKPuEUmPB4XyjGfaAr2PSuELMwkRMVH1EpIkX5bTZGRB3eCA==", - "dependencies": { - "@types/parse-json": "^4.0.0", - "import-fresh": "^3.2.1", - "parse-json": "^5.0.0", - "path-type": "^4.0.0", - "yaml": "^1.10.0" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/crelt": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/crelt/-/crelt-1.0.6.tgz", - "integrity": "sha512-VQ2MBenTq1fWZUH9DJNGti7kKv6EeAuYr3cLwxUWhIu1baTaXh4Ib5W2CqHVqib4/MqbYGJqiL3Zb8GJZr3l4g==", - "peer": true - }, - "node_modules/cross-spawn": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", - "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", - "dependencies": { - "path-key": "^3.1.0", - "shebang-command": "^2.0.0", - "which": "^2.0.1" - }, - "engines": { - "node": ">= 8" - } - }, - "node_modules/crypto-random-string": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/crypto-random-string/-/crypto-random-string-2.0.0.tgz", - "integrity": "sha512-v1plID3y9r/lPhviJ1wrXpLeyUIGAZ2SHNYTEapm7/8A9nLPoyvVp3RK/EPFqn5kEznyWgYZNsRtYYIWbuG8KA==", - "engines": { - "node": ">=8" - } - }, - "node_modules/css-blank-pseudo": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/css-blank-pseudo/-/css-blank-pseudo-3.0.3.tgz", - "integrity": "sha512-VS90XWtsHGqoM0t4KpH053c4ehxZ2E6HtGI7x68YFV0pTo/QmkV/YFA+NnlvK8guxZVNWGQhVNJGC39Q8XF4OQ==", - "dependencies": { - "postcss-selector-parser": "^6.0.9" - }, - "bin": { - "css-blank-pseudo": "dist/cli.cjs" - }, - "engines": { - "node": "^12 || ^14 || >=16" - }, - "peerDependencies": { - "postcss": "^8.4" - } - }, - "node_modules/css-declaration-sorter": { - "version": "6.4.0", - "resolved": "https://registry.npmjs.org/css-declaration-sorter/-/css-declaration-sorter-6.4.0.tgz", - "integrity": "sha512-jDfsatwWMWN0MODAFuHszfjphEXfNw9JUAhmY4pLu3TyTU+ohUpsbVtbU+1MZn4a47D9kqh03i4eyOm+74+zew==", - "engines": { - "node": "^10 || ^12 || >=14" - }, - "peerDependencies": { - "postcss": "^8.0.9" - } - }, - "node_modules/css-has-pseudo": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/css-has-pseudo/-/css-has-pseudo-3.0.4.tgz", - "integrity": "sha512-Vse0xpR1K9MNlp2j5w1pgWIJtm1a8qS0JwS9goFYcImjlHEmywP9VUF05aGBXzGpDJF86QXk4L0ypBmwPhGArw==", - "dependencies": { - "postcss-selector-parser": "^6.0.9" - }, - "bin": { - "css-has-pseudo": "dist/cli.cjs" - }, - "engines": { - "node": "^12 || ^14 || >=16" - }, - "peerDependencies": { - "postcss": "^8.4" - } - }, - "node_modules/css-loader": { - "version": "6.7.4", - "resolved": "https://registry.npmjs.org/css-loader/-/css-loader-6.7.4.tgz", - "integrity": "sha512-0Y5uHtK5BswfaGJ+jrO+4pPg1msFBc0pwPIE1VqfpmVn6YbDfYfXMj8rfd7nt+4goAhJueO+H/I40VWJfcP1mQ==", - "dependencies": { - "icss-utils": "^5.1.0", - "postcss": "^8.4.21", - "postcss-modules-extract-imports": "^3.0.0", - "postcss-modules-local-by-default": "^4.0.1", - "postcss-modules-scope": "^3.0.0", - "postcss-modules-values": "^4.0.0", - "postcss-value-parser": "^4.2.0", - "semver": "^7.3.8" - }, - "engines": { - "node": ">= 12.13.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/webpack" - }, - "peerDependencies": { - "webpack": "^5.0.0" - } - }, - "node_modules/css-minimizer-webpack-plugin": { - "version": "3.4.1", - "resolved": "https://registry.npmjs.org/css-minimizer-webpack-plugin/-/css-minimizer-webpack-plugin-3.4.1.tgz", - "integrity": "sha512-1u6D71zeIfgngN2XNRJefc/hY7Ybsxd74Jm4qngIXyUEk7fss3VUzuHxLAq/R8NAba4QU9OUSaMZlbpRc7bM4Q==", - "dependencies": { - "cssnano": "^5.0.6", - "jest-worker": "^27.0.2", - "postcss": "^8.3.5", - "schema-utils": "^4.0.0", - "serialize-javascript": "^6.0.0", - "source-map": "^0.6.1" - }, - "engines": { - "node": ">= 12.13.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/webpack" - }, - "peerDependencies": { - "webpack": "^5.0.0" - }, - "peerDependenciesMeta": { - "@parcel/css": { - "optional": true - }, - "clean-css": { - "optional": true - }, - "csso": { - "optional": true - }, - "esbuild": { - "optional": true - } - } - }, - "node_modules/css-minimizer-webpack-plugin/node_modules/ajv": { - "version": "8.12.0", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.12.0.tgz", - "integrity": "sha512-sRu1kpcO9yLtYxBKvqfTeh9KzZEwO3STyX1HT+4CaDzC6HpTGYhIhPIzj9XuKU7KYDwnaeh5hcOwjy1QuJzBPA==", - "dependencies": { - "fast-deep-equal": "^3.1.1", - "json-schema-traverse": "^1.0.0", - "require-from-string": "^2.0.2", - "uri-js": "^4.2.2" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/epoberezkin" - } - }, - "node_modules/css-minimizer-webpack-plugin/node_modules/ajv-keywords": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-5.1.0.tgz", - "integrity": "sha512-YCS/JNFAUyr5vAuhk1DWm1CBxRHW9LbJ2ozWeemrIqpbsqKjHVxYPyi5GC0rjZIT5JxJ3virVTS8wk4i/Z+krw==", - "dependencies": { - "fast-deep-equal": "^3.1.3" - }, - "peerDependencies": { - "ajv": "^8.8.2" - } - }, - "node_modules/css-minimizer-webpack-plugin/node_modules/json-schema-traverse": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", - "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==" - }, - "node_modules/css-minimizer-webpack-plugin/node_modules/schema-utils": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-4.0.1.tgz", - "integrity": "sha512-lELhBAAly9NowEsX0yZBlw9ahZG+sK/1RJ21EpzdYHKEs13Vku3LJ+MIPhh4sMs0oCCeufZQEQbMekiA4vuVIQ==", - "dependencies": { - "@types/json-schema": "^7.0.9", - "ajv": "^8.9.0", - "ajv-formats": "^2.1.1", - "ajv-keywords": "^5.1.0" - }, - "engines": { - "node": ">= 12.13.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/webpack" - } - }, - "node_modules/css-minimizer-webpack-plugin/node_modules/source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/css-prefers-color-scheme": { - "version": "6.0.3", - "resolved": "https://registry.npmjs.org/css-prefers-color-scheme/-/css-prefers-color-scheme-6.0.3.tgz", - "integrity": "sha512-4BqMbZksRkJQx2zAjrokiGMd07RqOa2IxIrrN10lyBe9xhn9DEvjUK79J6jkeiv9D9hQFXKb6g1jwU62jziJZA==", - "bin": { - "css-prefers-color-scheme": "dist/cli.cjs" - }, - "engines": { - "node": "^12 || ^14 || >=16" - }, - "peerDependencies": { - "postcss": "^8.4" - } - }, - "node_modules/css-select": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/css-select/-/css-select-4.3.0.tgz", - "integrity": "sha512-wPpOYtnsVontu2mODhA19JrqWxNsfdatRKd64kmpRbQgh1KtItko5sTnEpPdpSaJszTOhEMlF/RPz28qj4HqhQ==", - "dependencies": { - "boolbase": "^1.0.0", - "css-what": "^6.0.1", - "domhandler": "^4.3.1", - "domutils": "^2.8.0", - "nth-check": "^2.0.1" - }, - "funding": { - "url": "https://github.com/sponsors/fb55" - } - }, - "node_modules/css-select-base-adapter": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/css-select-base-adapter/-/css-select-base-adapter-0.1.1.tgz", - "integrity": "sha512-jQVeeRG70QI08vSTwf1jHxp74JoZsr2XSgETae8/xC8ovSnL2WF87GTLO86Sbwdt2lK4Umg4HnnwMO4YF3Ce7w==" - }, - "node_modules/css-tree": { - "version": "1.0.0-alpha.37", - "resolved": "https://registry.npmjs.org/css-tree/-/css-tree-1.0.0-alpha.37.tgz", - "integrity": "sha512-DMxWJg0rnz7UgxKT0Q1HU/L9BeJI0M6ksor0OgqOnF+aRCDWg/N2641HmVyU9KVIu0OVVWOb2IpC9A+BJRnejg==", - "dependencies": { - "mdn-data": "2.0.4", - "source-map": "^0.6.1" - }, - "engines": { - "node": ">=8.0.0" - } - }, - "node_modules/css-tree/node_modules/source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/css-what": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/css-what/-/css-what-6.1.0.tgz", - "integrity": "sha512-HTUrgRJ7r4dsZKU6GjmpfRK1O76h97Z8MfS1G0FozR+oF2kG6Vfe8JE6zwrkbxigziPHinCJ+gCPjA9EaBDtRw==", - "engines": { - "node": ">= 6" - }, - "funding": { - "url": "https://github.com/sponsors/fb55" - } - }, - "node_modules/css.escape": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/css.escape/-/css.escape-1.5.1.tgz", - "integrity": "sha512-YUifsXXuknHlUsmlgyY0PKzgPOr7/FjCePfHNt0jxm83wHZi44VDMQ7/fGNkjY3/jV1MC+1CmZbaHzugyeRtpg==" - }, - "node_modules/cssdb": { - "version": "7.6.0", - "resolved": "https://registry.npmjs.org/cssdb/-/cssdb-7.6.0.tgz", - "integrity": "sha512-Nna7rph8V0jC6+JBY4Vk4ndErUmfJfV6NJCaZdurL0omggabiy+QB2HCQtu5c/ACLZ0I7REv7A4QyPIoYzZx0w==", - "funding": [ - { - "type": "opencollective", - "url": "https://opencollective.com/csstools" - }, - { - "type": "github", - "url": "https://github.com/sponsors/csstools" - } - ] - }, - "node_modules/cssesc": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/cssesc/-/cssesc-3.0.0.tgz", - "integrity": "sha512-/Tb/JcjK111nNScGob5MNtsntNM1aCNUDipB/TkwZFhyDrrE47SOx/18wF2bbjgc3ZzCSKW1T5nt5EbFoAz/Vg==", - "bin": { - "cssesc": "bin/cssesc" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/cssnano": { - "version": "5.1.15", - "resolved": "https://registry.npmjs.org/cssnano/-/cssnano-5.1.15.tgz", - "integrity": "sha512-j+BKgDcLDQA+eDifLx0EO4XSA56b7uut3BQFH+wbSaSTuGLuiyTa/wbRYthUXX8LC9mLg+WWKe8h+qJuwTAbHw==", - "dependencies": { - "cssnano-preset-default": "^5.2.14", - "lilconfig": "^2.0.3", - "yaml": "^1.10.2" - }, - "engines": { - "node": "^10 || ^12 || >=14.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/cssnano" - }, - "peerDependencies": { - "postcss": "^8.2.15" - } - }, - "node_modules/cssnano-preset-default": { - "version": "5.2.14", - "resolved": "https://registry.npmjs.org/cssnano-preset-default/-/cssnano-preset-default-5.2.14.tgz", - "integrity": "sha512-t0SFesj/ZV2OTylqQVOrFgEh5uanxbO6ZAdeCrNsUQ6fVuXwYTxJPNAGvGTxHbD68ldIJNec7PyYZDBrfDQ+6A==", - "dependencies": { - "css-declaration-sorter": "^6.3.1", - "cssnano-utils": "^3.1.0", - "postcss-calc": "^8.2.3", - "postcss-colormin": "^5.3.1", - "postcss-convert-values": "^5.1.3", - "postcss-discard-comments": "^5.1.2", - "postcss-discard-duplicates": "^5.1.0", - "postcss-discard-empty": "^5.1.1", - "postcss-discard-overridden": "^5.1.0", - "postcss-merge-longhand": "^5.1.7", - "postcss-merge-rules": "^5.1.4", - "postcss-minify-font-values": "^5.1.0", - "postcss-minify-gradients": "^5.1.1", - "postcss-minify-params": "^5.1.4", - "postcss-minify-selectors": "^5.2.1", - "postcss-normalize-charset": "^5.1.0", - "postcss-normalize-display-values": "^5.1.0", - "postcss-normalize-positions": "^5.1.1", - "postcss-normalize-repeat-style": "^5.1.1", - "postcss-normalize-string": "^5.1.0", - "postcss-normalize-timing-functions": "^5.1.0", - "postcss-normalize-unicode": "^5.1.1", - "postcss-normalize-url": "^5.1.0", - "postcss-normalize-whitespace": "^5.1.1", - "postcss-ordered-values": "^5.1.3", - "postcss-reduce-initial": "^5.1.2", - "postcss-reduce-transforms": "^5.1.0", - "postcss-svgo": "^5.1.0", - "postcss-unique-selectors": "^5.1.1" - }, - "engines": { - "node": "^10 || ^12 || >=14.0" - }, - "peerDependencies": { - "postcss": "^8.2.15" - } - }, - "node_modules/cssnano-utils": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/cssnano-utils/-/cssnano-utils-3.1.0.tgz", - "integrity": "sha512-JQNR19/YZhz4psLX/rQ9M83e3z2Wf/HdJbryzte4a3NSuafyp9w/I4U+hx5C2S9g41qlstH7DEWnZaaj83OuEA==", - "engines": { - "node": "^10 || ^12 || >=14.0" - }, - "peerDependencies": { - "postcss": "^8.2.15" - } - }, - "node_modules/csso": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/csso/-/csso-4.2.0.tgz", - "integrity": "sha512-wvlcdIbf6pwKEk7vHj8/Bkc0B4ylXZruLvOgs9doS5eOsOpuodOV2zJChSpkp+pRpYQLQMeF04nr3Z68Sta9jA==", - "dependencies": { - "css-tree": "^1.1.2" - }, - "engines": { - "node": ">=8.0.0" - } - }, - "node_modules/csso/node_modules/css-tree": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/css-tree/-/css-tree-1.1.3.tgz", - "integrity": "sha512-tRpdppF7TRazZrjJ6v3stzv93qxRcSsFmW6cX0Zm2NVKpxE1WV1HblnghVv9TreireHkqI/VDEsfolRF1p6y7Q==", - "dependencies": { - "mdn-data": "2.0.14", - "source-map": "^0.6.1" - }, - "engines": { - "node": ">=8.0.0" - } - }, - "node_modules/csso/node_modules/mdn-data": { - "version": "2.0.14", - "resolved": "https://registry.npmjs.org/mdn-data/-/mdn-data-2.0.14.tgz", - "integrity": "sha512-dn6wd0uw5GsdswPFfsgMp5NSB0/aDe6fK94YJV/AJDYXL6HVLWBsxeq7js7Ad+mU2K9LAlwpk6kN2D5mwCPVow==" - }, - "node_modules/csso/node_modules/source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/cssom": { - "version": "0.4.4", - "resolved": "https://registry.npmjs.org/cssom/-/cssom-0.4.4.tgz", - "integrity": "sha512-p3pvU7r1MyyqbTk+WbNJIgJjG2VmTIaB10rI93LzVPrmDJKkzKYMtxxyAvQXR/NS6otuzveI7+7BBq3SjBS2mw==" - }, - "node_modules/cssstyle": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/cssstyle/-/cssstyle-2.3.0.tgz", - "integrity": "sha512-AZL67abkUzIuvcHqk7c09cezpGNcxUxU4Ioi/05xHk4DQeTkWmGYftIE6ctU6AEt+Gn4n1lDStOtj7FKycP71A==", - "dependencies": { - "cssom": "~0.3.6" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/cssstyle/node_modules/cssom": { - "version": "0.3.8", - "resolved": "https://registry.npmjs.org/cssom/-/cssom-0.3.8.tgz", - "integrity": "sha512-b0tGHbfegbhPJpxpiBPU2sCkigAqtM9O121le6bbOlgyV+NyGyCmVfJ6QW9eRjz8CpNfWEOYBIMIGRYkLwsIYg==" - }, - "node_modules/csstype": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.2.tgz", - "integrity": "sha512-I7K1Uu0MBPzaFKg4nI5Q7Vs2t+3gWWW648spaF+Rg7pI9ds18Ugn+lvg4SHczUdKlHI5LWBXyqfS8+DufyBsgQ==" - }, - "node_modules/damerau-levenshtein": { - "version": "1.0.8", - "resolved": "https://registry.npmjs.org/damerau-levenshtein/-/damerau-levenshtein-1.0.8.tgz", - "integrity": "sha512-sdQSFB7+llfUcQHUQO3+B8ERRj0Oa4w9POWMI/puGtuf7gFywGmkaLCElnudfTiKZV+NvHqL0ifzdrI8Ro7ESA==" - }, - "node_modules/dash-get": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/dash-get/-/dash-get-1.0.2.tgz", - "integrity": "sha512-4FbVrHDwfOASx7uQVxeiCTo7ggSdYZbqs8lH+WU6ViypPlDbe9y6IP5VVUDQBv9DcnyaiPT5XT0UWHgJ64zLeQ==", - "peer": true - }, - "node_modules/dashdash": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", - "integrity": "sha512-jRFi8UDGo6j+odZiEpjazZaWqEal3w/basFjQHQEwVtZJGDpxbH1MeYluwCS8Xq5wmLJooDlMgvVarmWfGM44g==", - "optional": true, - "dependencies": { - "assert-plus": "^1.0.0" - }, - "engines": { - "node": ">=0.10" - } - }, - "node_modules/data-urls": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/data-urls/-/data-urls-2.0.0.tgz", - "integrity": "sha512-X5eWTSXO/BJmpdIKCRuKUgSCgAN0OwliVK3yPKbwIWU1Tdw5BRajxlzMidvh+gwko9AfQ9zIj52pzF91Q3YAvQ==", - "dependencies": { - "abab": "^2.0.3", - "whatwg-mimetype": "^2.3.0", - "whatwg-url": "^8.0.0" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/dayjs": { - "version": "1.11.7", - "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.7.tgz", - "integrity": "sha512-+Yw9U6YO5TQohxLcIkrXBeY73WP3ejHWVvx8XCk3gxvQDCTEmS48ZrSZCKciI7Bhl/uCMyxYtE9UqRILmFphkQ==" - }, - "node_modules/debug": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", - "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", - "dependencies": { - "ms": "2.1.2" - }, - "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } - } - }, - "node_modules/decamelize": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", - "integrity": "sha512-z2S+W9X73hAUUki+N+9Za2lBlun89zigOyGrsax+KUQ6wKW4ZoWpEYBkGhQjwAjjDCkWxhY0VKEhk8wzY7F5cA==", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/decimal.js": { - "version": "10.4.3", - "resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.4.3.tgz", - "integrity": "sha512-VBBaLc1MgL5XpzgIP7ny5Z6Nx3UrRkIViUkPUdtl9aya5amy3De1gsUUSB1g3+3sExYNjCAsAznmukyxCb1GRA==" - }, - "node_modules/dedent": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/dedent/-/dedent-0.7.0.tgz", - "integrity": "sha512-Q6fKUPqnAHAyhiUgFU7BUzLiv0kd8saH9al7tnu5Q/okj6dnupxyTgFIBjVzJATdfIAm9NAsvXNzjaKa+bxVyA==" - }, - "node_modules/deep-equal": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-2.2.1.tgz", - "integrity": "sha512-lKdkdV6EOGoVn65XaOsPdH4rMxTZOnmFyuIkMjM1i5HHCbfjC97dawgTAy0deYNfuqUqW+Q5VrVaQYtUpSd6yQ==", - "dependencies": { - "array-buffer-byte-length": "^1.0.0", - "call-bind": "^1.0.2", - "es-get-iterator": "^1.1.3", - "get-intrinsic": "^1.2.0", - "is-arguments": "^1.1.1", - "is-array-buffer": "^3.0.2", - "is-date-object": "^1.0.5", - "is-regex": "^1.1.4", - "is-shared-array-buffer": "^1.0.2", - "isarray": "^2.0.5", - "object-is": "^1.1.5", - "object-keys": "^1.1.1", - "object.assign": "^4.1.4", - "regexp.prototype.flags": "^1.5.0", - "side-channel": "^1.0.4", - "which-boxed-primitive": "^1.0.2", - "which-collection": "^1.0.1", - "which-typed-array": "^1.1.9" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/deep-extend": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.6.0.tgz", - "integrity": "sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==", - "engines": { - "node": ">=4.0.0" - } - }, - "node_modules/deep-is": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", - "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==" - }, - "node_modules/deepmerge": { - "version": "4.3.1", - "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.3.1.tgz", - "integrity": "sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/default-gateway": { - "version": "6.0.3", - "resolved": "https://registry.npmjs.org/default-gateway/-/default-gateway-6.0.3.tgz", - "integrity": "sha512-fwSOJsbbNzZ/CUFpqFBqYfYNLj1NbMPm8MMCIzHjC83iSJRBEGmDUxU+WP661BaBQImeC2yHwXtz+P/O9o+XEg==", - "dependencies": { - "execa": "^5.0.0" - }, - "engines": { - "node": ">= 10" - } - }, - "node_modules/define-lazy-prop": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/define-lazy-prop/-/define-lazy-prop-2.0.0.tgz", - "integrity": "sha512-Ds09qNh8yw3khSjiJjiUInaGX9xlqZDY7JVryGxdxV7NPeuqQfplOpQ66yJFZut3jLa5zOwkXw1g9EI2uKh4Og==", - "engines": { - "node": ">=8" - } - }, - "node_modules/define-properties": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.2.0.tgz", - "integrity": "sha512-xvqAVKGfT1+UAvPwKTVw/njhdQ8ZhXK4lI0bCIuCMrp2up9nPnaDftrLtmpTazqd1o+UY4zgzU+avtMbDP+ldA==", - "dependencies": { - "has-property-descriptors": "^1.0.0", - "object-keys": "^1.1.1" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/delayed-stream": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", - "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", - "engines": { - "node": ">=0.4.0" - } - }, - "node_modules/delegates": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz", - "integrity": "sha512-bd2L678uiWATM6m5Z1VzNCErI3jiGzt6HGY8OVICs40JQq/HALfbyNJmp0UDakEY4pMMaN0Ly5om/B1VI/+xfQ==" - }, - "node_modules/depd": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", - "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/destroy": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz", - "integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==", - "engines": { - "node": ">= 0.8", - "npm": "1.2.8000 || >= 1.4.16" - } - }, - "node_modules/detect-indent": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/detect-indent/-/detect-indent-4.0.0.tgz", - "integrity": "sha512-BDKtmHlOzwI7iRuEkhzsnPoi5ypEhWAJB5RvHWe1kMr06js3uK5B3734i3ui5Yd+wOJV1cpE4JnivPD283GU/A==", - "dependencies": { - "repeating": "^2.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/detect-libc": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-1.0.3.tgz", - "integrity": "sha512-pGjwhsmsp4kL2RTz08wcOlGN83otlqHeD/Z5T8GXZB+/YcpQ/dgo+lbU8ZsGxV0HIvqqxo9l7mqYwyYMD9bKDg==", - "bin": { - "detect-libc": "bin/detect-libc.js" - }, - "engines": { - "node": ">=0.10" - } - }, - "node_modules/detect-newline": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/detect-newline/-/detect-newline-3.1.0.tgz", - "integrity": "sha512-TLz+x/vEXm/Y7P7wn1EJFNLxYpUD4TgMosxY6fAVJUnJMbupHBOncxyWUG9OpTaH9EBD7uFI5LfEgmMOc54DsA==", - "engines": { - "node": ">=8" - } - }, - "node_modules/detect-node": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/detect-node/-/detect-node-2.1.0.tgz", - "integrity": "sha512-T0NIuQpnTvFDATNuHN5roPwSBG83rFsuO+MXXH9/3N1eFbn4wcPjttvjMLEPWJ0RGUYgQE7cGgS3tNxbqCGM7g==" - }, - "node_modules/detect-node-es": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/detect-node-es/-/detect-node-es-1.1.0.tgz", - "integrity": "sha512-ypdmJU/TbBby2Dxibuv7ZLW3Bs1QEmM7nHjEANfohJLvE0XVujisn1qPJcZxg+qDucsr+bP6fLD1rPS3AhJ7EQ==" - }, - "node_modules/detect-port-alt": { - "version": "1.1.6", - "resolved": "https://registry.npmjs.org/detect-port-alt/-/detect-port-alt-1.1.6.tgz", - "integrity": "sha512-5tQykt+LqfJFBEYaDITx7S7cR7mJ/zQmLXZ2qt5w04ainYZw6tBf9dBunMjVeVOdYVRUzUOE4HkY5J7+uttb5Q==", - "dependencies": { - "address": "^1.0.1", - "debug": "^2.6.0" - }, - "bin": { - "detect": "bin/detect-port", - "detect-port": "bin/detect-port" - }, - "engines": { - "node": ">= 4.2.1" - } - }, - "node_modules/detect-port-alt/node_modules/debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "dependencies": { - "ms": "2.0.0" - } - }, - "node_modules/detect-port-alt/node_modules/ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" - }, - "node_modules/didyoumean": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/didyoumean/-/didyoumean-1.2.2.tgz", - "integrity": "sha512-gxtyfqMg7GKyhQmb056K7M3xszy/myH8w+B4RT+QXBQsvAOdc3XymqDDPHx1BgPgsdAA5SIifona89YtRATDzw==" - }, - "node_modules/diff-sequences": { - "version": "27.5.1", - "resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-27.5.1.tgz", - "integrity": "sha512-k1gCAXAsNgLwEL+Y8Wvl+M6oEFj5bgazfZULpS5CneoPPXRaCCW7dm+q21Ky2VEE5X+VeRDBVg1Pcvvsr4TtNQ==", - "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" - } - }, - "node_modules/dijkstrajs": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/dijkstrajs/-/dijkstrajs-1.0.3.tgz", - "integrity": "sha512-qiSlmBq9+BCdCA/L46dw8Uy93mloxsPSbwnm5yrKn2vMPiy8KyAskTF6zuV/j5BMsmOGZDPs7KjU+mjb670kfA==" - }, - "node_modules/dir-glob": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz", - "integrity": "sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==", - "dependencies": { - "path-type": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/dlv": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/dlv/-/dlv-1.1.3.tgz", - "integrity": "sha512-+HlytyjlPKnIG8XuRG8WvmBP8xs8P71y+SKKS6ZXWoEgLuePxtDoUEiH7WkdePWrQ5JBpE6aoVqfZfJUQkjXwA==" - }, - "node_modules/dns-equal": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/dns-equal/-/dns-equal-1.0.0.tgz", - "integrity": "sha512-z+paD6YUQsk+AbGCEM4PrOXSss5gd66QfcVBFTKR/HpFL9jCqikS94HYwKww6fQyO7IxrIIyUu+g0Ka9tUS2Cg==" - }, - "node_modules/dns-packet": { - "version": "5.6.0", - "resolved": "https://registry.npmjs.org/dns-packet/-/dns-packet-5.6.0.tgz", - "integrity": "sha512-rza3UH1LwdHh9qyPXp8lkwpjSNk/AMD3dPytUoRoqnypDUhY0xvbdmVhWOfxO68frEfV9BU8V12Ez7ZsHGZpCQ==", - "dependencies": { - "@leichtgewicht/ip-codec": "^2.0.1" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/doctrine": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", - "integrity": "sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==", - "dependencies": { - "esutils": "^2.0.2" - }, - "engines": { - "node": ">=6.0.0" - } - }, - "node_modules/dom-accessibility-api": { - "version": "0.5.16", - "resolved": "https://registry.npmjs.org/dom-accessibility-api/-/dom-accessibility-api-0.5.16.tgz", - "integrity": "sha512-X7BJ2yElsnOJ30pZF4uIIDfBEVgF4XEBxL9Bxhy6dnrm5hkzqmsWHGTiHqRiITNhMyFLyAiWndIJP7Z1NTteDg==" - }, - "node_modules/dom-converter": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/dom-converter/-/dom-converter-0.2.0.tgz", - "integrity": "sha512-gd3ypIPfOMr9h5jIKq8E3sHOTCjeirnl0WK5ZdS1AW0Odt0b1PaWaHdJ4Qk4klv+YB9aJBS7mESXjFoDQPu6DA==", - "dependencies": { - "utila": "~0.4" - } - }, - "node_modules/dom-helpers": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/dom-helpers/-/dom-helpers-5.2.1.tgz", - "integrity": "sha512-nRCa7CK3VTrM2NmGkIy4cbK7IZlgBE/PYMn55rrXefr5xXDP0LdtfPnblFDoVdcAfslJ7or6iqAUnx0CCGIWQA==", - "dependencies": { - "@babel/runtime": "^7.8.7", - "csstype": "^3.0.2" - } - }, - "node_modules/dom-serializer": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-1.4.1.tgz", - "integrity": "sha512-VHwB3KfrcOOkelEG2ZOfxqLZdfkil8PtJi4P8N2MMXucZq2yLp75ClViUlOVwyoHEDjYU433Aq+5zWP61+RGag==", - "dependencies": { - "domelementtype": "^2.0.1", - "domhandler": "^4.2.0", - "entities": "^2.0.0" - }, - "funding": { - "url": "https://github.com/cheeriojs/dom-serializer?sponsor=1" - } - }, - "node_modules/domelementtype": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.3.0.tgz", - "integrity": "sha512-OLETBj6w0OsagBwdXnPdN0cnMfF9opN69co+7ZrbfPGrdpPVNBUj02spi6B1N7wChLQiPn4CSH/zJvXw56gmHw==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/fb55" - } - ] - }, - "node_modules/domexception": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/domexception/-/domexception-2.0.1.tgz", - "integrity": "sha512-yxJ2mFy/sibVQlu5qHjOkf9J3K6zgmCxgJ94u2EdvDOV09H+32LtRswEcUsmUWN72pVLOEnTSRaIVVzVQgS0dg==", - "dependencies": { - "webidl-conversions": "^5.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/domexception/node_modules/webidl-conversions": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-5.0.0.tgz", - "integrity": "sha512-VlZwKPCkYKxQgeSbH5EyngOmRp7Ww7I9rQLERETtf5ofd9pGeswWiOtogpEO850jziPRarreGxn5QIiTqpb2wA==", - "engines": { - "node": ">=8" - } - }, - "node_modules/domhandler": { - "version": "4.3.1", - "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-4.3.1.tgz", - "integrity": "sha512-GrwoxYN+uWlzO8uhUXRl0P+kHE4GtVPfYzVLcUxPL7KNdHKj66vvlhiweIHqYYXWlw+T8iLMp42Lm67ghw4WMQ==", - "dependencies": { - "domelementtype": "^2.2.0" - }, - "engines": { - "node": ">= 4" - }, - "funding": { - "url": "https://github.com/fb55/domhandler?sponsor=1" - } - }, - "node_modules/domutils": { - "version": "2.8.0", - "resolved": "https://registry.npmjs.org/domutils/-/domutils-2.8.0.tgz", - "integrity": "sha512-w96Cjofp72M5IIhpjgobBimYEfoPjx1Vx0BSX9P30WBdZW2WIKU0T1Bd0kz2eNZ9ikjKgHbEyKx8BB6H1L3h3A==", - "dependencies": { - "dom-serializer": "^1.0.1", - "domelementtype": "^2.2.0", - "domhandler": "^4.2.0" - }, - "funding": { - "url": "https://github.com/fb55/domutils?sponsor=1" - } - }, - "node_modules/dot-case": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/dot-case/-/dot-case-3.0.4.tgz", - "integrity": "sha512-Kv5nKlh6yRrdrGvxeJ2e5y2eRUpkUosIW4A2AS38zwSz27zu7ufDwQPi5Jhs3XAlGNetl3bmnGhQsMtkKJnj3w==", - "dependencies": { - "no-case": "^3.0.4", - "tslib": "^2.0.3" - } - }, - "node_modules/dotenv": { - "version": "10.0.0", - "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-10.0.0.tgz", - "integrity": "sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q==", - "engines": { - "node": ">=10" - } - }, - "node_modules/dotenv-expand": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/dotenv-expand/-/dotenv-expand-5.1.0.tgz", - "integrity": "sha512-YXQl1DSa4/PQyRfgrv6aoNjhasp/p4qs9FjJ4q4cQk+8m4r6k4ZSiEyytKG8f8W9gi8WsQtIObNmKd+tMzNTmA==" - }, - "node_modules/duplexer": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/duplexer/-/duplexer-0.1.2.tgz", - "integrity": "sha512-jtD6YG370ZCIi/9GTaJKQxWTZD045+4R4hTk/x1UyoqadyJ9x9CgSi1RlVDQF8U2sxLLSnFkCaMihqljHIWgMg==" - }, - "node_modules/ecc-jsbn": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz", - "integrity": "sha512-eh9O+hwRHNbG4BLTjEl3nw044CkGm5X6LoaCf7LPp7UU8Qrt47JYNi6nPX8xjW97TKGKm1ouctg0QSpZe9qrnw==", - "optional": true, - "dependencies": { - "jsbn": "~0.1.0", - "safer-buffer": "^2.1.0" - } - }, - "node_modules/ee-first": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", - "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==" - }, - "node_modules/ejs": { - "version": "3.1.9", - "resolved": "https://registry.npmjs.org/ejs/-/ejs-3.1.9.tgz", - "integrity": "sha512-rC+QVNMJWv+MtPgkt0y+0rVEIdbtxVADApW9JXrUVlzHetgcyczP/E7DJmWJ4fJCZF2cPcBk0laWO9ZHMG3DmQ==", - "dependencies": { - "jake": "^10.8.5" - }, - "bin": { - "ejs": "bin/cli.js" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/electron-to-chromium": { - "version": "1.4.403", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.403.tgz", - "integrity": "sha512-evCMqXJWmbQHdlh307peXNguqVIMmcLGrQwXiR+Qc98js8jPDeT9rse1+EF2YRjWgueuzj1r4WWLAe4/U+xjMg==" - }, - "node_modules/embla-carousel": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/embla-carousel/-/embla-carousel-7.1.0.tgz", - "integrity": "sha512-Bh8Pa8NWzgugLkf8sAGexQlBCNDFaej5BXiKgQdRJ1mUC9NWBrw9Z23YVPVGkguWoz5LMjZXXFVGCobl3UPt/Q==" - }, - "node_modules/embla-carousel-react": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/embla-carousel-react/-/embla-carousel-react-7.1.0.tgz", - "integrity": "sha512-tbYRPRZSDNd2QLNqYDcArAakGIxtUbhS7tkP0dGXktXHGgcX+3ji3VrOUTOftBiujZrMV8kRxtrRUe/1soloIQ==", - "dependencies": { - "embla-carousel": "7.1.0" - }, - "peerDependencies": { - "react": "^16.8.0 || ^17.0.1 || ^18.0.0" - } - }, - "node_modules/emittery": { - "version": "0.8.1", - "resolved": "https://registry.npmjs.org/emittery/-/emittery-0.8.1.tgz", - "integrity": "sha512-uDfvUjVrfGJJhymx/kz6prltenw1u7WrCg1oa94zYY8xxVpLLUu045LAT0dhDZdXG58/EpPL/5kA180fQ/qudg==", - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sindresorhus/emittery?sponsor=1" - } - }, - "node_modules/emoji-regex": { - "version": "9.2.2", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz", - "integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==" - }, - "node_modules/emojis-list": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/emojis-list/-/emojis-list-3.0.0.tgz", - "integrity": "sha512-/kyM18EfinwXZbno9FyUGeFh87KC8HRQBQGildHZbEuRyWFOmv1U10o9BBp8XVZDVNNuQKyIGIu5ZYAAXJ0V2Q==", - "engines": { - "node": ">= 4" - } - }, - "node_modules/encode-utf8": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/encode-utf8/-/encode-utf8-1.0.3.tgz", - "integrity": "sha512-ucAnuBEhUK4boH2HjVYG5Q2mQyPorvv0u/ocS+zhdw0S8AlHYY+GOFhP1Gio5z4icpP2ivFSvhtFjQi8+T9ppw==" - }, - "node_modules/encodeurl": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", - "integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==", - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/engine.io": { - "version": "6.5.4", - "resolved": "https://registry.npmjs.org/engine.io/-/engine.io-6.5.4.tgz", - "integrity": "sha512-KdVSDKhVKyOi+r5uEabrDLZw2qXStVvCsEB/LN3mw4WFi6Gx50jTyuxYVCwAAC0U46FdnzP/ScKRBTXb/NiEOg==", - "dependencies": { - "@types/cookie": "^0.4.1", - "@types/cors": "^2.8.12", - "@types/node": ">=10.0.0", - "accepts": "~1.3.4", - "base64id": "2.0.0", - "cookie": "~0.4.1", - "cors": "~2.8.5", - "debug": "~4.3.1", - "engine.io-parser": "~5.2.1", - "ws": "~8.11.0" - }, - "engines": { - "node": ">=10.2.0" - } - }, - "node_modules/engine.io-client": { - "version": "6.5.3", - "resolved": "https://registry.npmjs.org/engine.io-client/-/engine.io-client-6.5.3.tgz", - "integrity": "sha512-9Z0qLB0NIisTRt1DZ/8U2k12RJn8yls/nXMZLn+/N8hANT3TcYjKFKcwbw5zFQiN4NTde3TSY9zb79e1ij6j9Q==", - "dependencies": { - "@socket.io/component-emitter": "~3.1.0", - "debug": "~4.3.1", - "engine.io-parser": "~5.2.1", - "ws": "~8.11.0", - "xmlhttprequest-ssl": "~2.0.0" - } - }, - "node_modules/engine.io-client/node_modules/ws": { - "version": "8.11.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.11.0.tgz", - "integrity": "sha512-HPG3wQd9sNQoT9xHyNCXoDUa+Xw/VevmY9FoHyQ+g+rrMn4j6FB4np7Z0OhdTgjx6MgQLK7jwSy1YecU1+4Asg==", - "engines": { - "node": ">=10.0.0" - }, - "peerDependencies": { - "bufferutil": "^4.0.1", - "utf-8-validate": "^5.0.2" - }, - "peerDependenciesMeta": { - "bufferutil": { - "optional": true - }, - "utf-8-validate": { - "optional": true - } - } - }, - "node_modules/engine.io-parser": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/engine.io-parser/-/engine.io-parser-5.2.1.tgz", - "integrity": "sha512-9JktcM3u18nU9N2Lz3bWeBgxVgOKpw7yhRaoxQA3FUDZzzw+9WlA6p4G4u0RixNkg14fH7EfEc/RhpurtiROTQ==", - "engines": { - "node": ">=10.0.0" - } - }, - "node_modules/engine.io/node_modules/cookie": { - "version": "0.4.2", - "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.2.tgz", - "integrity": "sha512-aSWTXFzaKWkvHO1Ny/s+ePFpvKsPnjc551iI41v3ny/ow6tBG5Vd+FuqGNhh1LxOmVzOlGUriIlOaokOvhaStA==", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/engine.io/node_modules/ws": { - "version": "8.11.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.11.0.tgz", - "integrity": "sha512-HPG3wQd9sNQoT9xHyNCXoDUa+Xw/VevmY9FoHyQ+g+rrMn4j6FB4np7Z0OhdTgjx6MgQLK7jwSy1YecU1+4Asg==", - "engines": { - "node": ">=10.0.0" - }, - "peerDependencies": { - "bufferutil": "^4.0.1", - "utf-8-validate": "^5.0.2" - }, - "peerDependenciesMeta": { - "bufferutil": { - "optional": true - }, - "utf-8-validate": { - "optional": true - } - } - }, - "node_modules/enhanced-resolve": { - "version": "5.15.0", - "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.15.0.tgz", - "integrity": "sha512-LXYT42KJ7lpIKECr2mAXIaMldcNCh/7E0KBKOu4KSfkHmP+mZmSs+8V5gBAqisWBy0OO4W5Oyys0GO1Y8KtdKg==", - "dependencies": { - "graceful-fs": "^4.2.4", - "tapable": "^2.2.0" - }, - "engines": { - "node": ">=10.13.0" - } - }, - "node_modules/entities": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/entities/-/entities-2.2.0.tgz", - "integrity": "sha512-p92if5Nz619I0w+akJrLZH0MX0Pb5DX39XOwQTtXSdQQOaYH03S1uIQp4mhOZtAXrxq4ViO67YTiLBo2638o9A==", - "funding": { - "url": "https://github.com/fb55/entities?sponsor=1" - } - }, - "node_modules/error-ex": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", - "integrity": "sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==", - "dependencies": { - "is-arrayish": "^0.2.1" - } - }, - "node_modules/error-stack-parser": { - "version": "2.1.4", - "resolved": "https://registry.npmjs.org/error-stack-parser/-/error-stack-parser-2.1.4.tgz", - "integrity": "sha512-Sk5V6wVazPhq5MhpO+AUxJn5x7XSXGl1R93Vn7i+zS15KDVxQijejNCrz8340/2bgLBjR9GtEG8ZVKONDjcqGQ==", - "dependencies": { - "stackframe": "^1.3.4" - } - }, - "node_modules/es-abstract": { - "version": "1.21.2", - "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.21.2.tgz", - "integrity": "sha512-y/B5POM2iBnIxCiernH1G7rC9qQoM77lLIMQLuob0zhp8C56Po81+2Nj0WFKnd0pNReDTnkYryc+zhOzpEIROg==", - "dependencies": { - "array-buffer-byte-length": "^1.0.0", - "available-typed-arrays": "^1.0.5", - "call-bind": "^1.0.2", - "es-set-tostringtag": "^2.0.1", - "es-to-primitive": "^1.2.1", - "function.prototype.name": "^1.1.5", - "get-intrinsic": "^1.2.0", - "get-symbol-description": "^1.0.0", - "globalthis": "^1.0.3", - "gopd": "^1.0.1", - "has": "^1.0.3", - "has-property-descriptors": "^1.0.0", - "has-proto": "^1.0.1", - "has-symbols": "^1.0.3", - "internal-slot": "^1.0.5", - "is-array-buffer": "^3.0.2", - "is-callable": "^1.2.7", - "is-negative-zero": "^2.0.2", - "is-regex": "^1.1.4", - "is-shared-array-buffer": "^1.0.2", - "is-string": "^1.0.7", - "is-typed-array": "^1.1.10", - "is-weakref": "^1.0.2", - "object-inspect": "^1.12.3", - "object-keys": "^1.1.1", - "object.assign": "^4.1.4", - "regexp.prototype.flags": "^1.4.3", - "safe-regex-test": "^1.0.0", - "string.prototype.trim": "^1.2.7", - "string.prototype.trimend": "^1.0.6", - "string.prototype.trimstart": "^1.0.6", - "typed-array-length": "^1.0.4", - "unbox-primitive": "^1.0.2", - "which-typed-array": "^1.1.9" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/es-array-method-boxes-properly": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/es-array-method-boxes-properly/-/es-array-method-boxes-properly-1.0.0.tgz", - "integrity": "sha512-wd6JXUmyHmt8T5a2xreUwKcGPq6f1f+WwIJkijUqiGcJz1qqnZgP6XIK+QyIWU5lT7imeNxUll48bziG+TSYcA==" - }, - "node_modules/es-get-iterator": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/es-get-iterator/-/es-get-iterator-1.1.3.tgz", - "integrity": "sha512-sPZmqHBe6JIiTfN5q2pEi//TwxmAFHwj/XEuYjTuse78i8KxaqMTTzxPoFKuzRpDpTJ+0NAbpfenkmH2rePtuw==", - "dependencies": { - "call-bind": "^1.0.2", - "get-intrinsic": "^1.1.3", - "has-symbols": "^1.0.3", - "is-arguments": "^1.1.1", - "is-map": "^2.0.2", - "is-set": "^2.0.2", - "is-string": "^1.0.7", - "isarray": "^2.0.5", - "stop-iteration-iterator": "^1.0.0" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/es-module-lexer": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-1.2.1.tgz", - "integrity": "sha512-9978wrXM50Y4rTMmW5kXIC09ZdXQZqkE4mxhwkd8VbzsGkXGPgV4zWuqQJgCEzYngdo2dYDa0l8xhX4fkSwJSg==" - }, - "node_modules/es-set-tostringtag": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/es-set-tostringtag/-/es-set-tostringtag-2.0.1.tgz", - "integrity": "sha512-g3OMbtlwY3QewlqAiMLI47KywjWZoEytKr8pf6iTC8uJq5bIAH52Z9pnQ8pVL6whrCto53JZDuUIsifGeLorTg==", - "dependencies": { - "get-intrinsic": "^1.1.3", - "has": "^1.0.3", - "has-tostringtag": "^1.0.0" - }, - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/es-shim-unscopables": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/es-shim-unscopables/-/es-shim-unscopables-1.0.0.tgz", - "integrity": "sha512-Jm6GPcCdC30eMLbZ2x8z2WuRwAws3zTBBKuusffYVUrNj/GVSUAZ+xKMaUpfNDR5IbyNA5LJbaecoUVbmUcB1w==", - "dependencies": { - "has": "^1.0.3" - } - }, - "node_modules/es-to-primitive": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.1.tgz", - "integrity": "sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA==", - "dependencies": { - "is-callable": "^1.1.4", - "is-date-object": "^1.0.1", - "is-symbol": "^1.0.2" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/es6-promise": { - "version": "4.2.8", - "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.8.tgz", - "integrity": "sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w==" - }, - "node_modules/es6-promisify": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/es6-promisify/-/es6-promisify-5.0.0.tgz", - "integrity": "sha512-C+d6UdsYDk0lMebHNR4S2NybQMMngAOnOwYBQjTOiv0MkoJMP0Myw2mgpDLBcpfCmRLxyFqYhS/CfOENq4SJhQ==", - "dependencies": { - "es6-promise": "^4.0.3" - } - }, - "node_modules/escalade": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", - "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==", - "engines": { - "node": ">=6" - } - }, - "node_modules/escape-html": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", - "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==" - }, - "node_modules/escape-string-regexp": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", - "engines": { - "node": ">=0.8.0" - } - }, - "node_modules/escodegen": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-2.0.0.tgz", - "integrity": "sha512-mmHKys/C8BFUGI+MAWNcSYoORYLMdPzjrknd2Vc+bUsjN5bXcr8EhrNB+UTqfL1y3I9c4fw2ihgtMPQLBRiQxw==", - "dependencies": { - "esprima": "^4.0.1", - "estraverse": "^5.2.0", - "esutils": "^2.0.2", - "optionator": "^0.8.1" - }, - "bin": { - "escodegen": "bin/escodegen.js", - "esgenerate": "bin/esgenerate.js" - }, - "engines": { - "node": ">=6.0" - }, - "optionalDependencies": { - "source-map": "~0.6.1" - } - }, - "node_modules/escodegen/node_modules/levn": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", - "integrity": "sha512-0OO4y2iOHix2W6ujICbKIaEQXvFQHue65vUG3pb5EUomzPI90z9hsA1VsO/dbIIpC53J8gxM9Q4Oho0jrCM/yA==", - "dependencies": { - "prelude-ls": "~1.1.2", - "type-check": "~0.3.2" - }, - "engines": { - "node": ">= 0.8.0" - } - }, - "node_modules/escodegen/node_modules/optionator": { - "version": "0.8.3", - "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.3.tgz", - "integrity": "sha512-+IW9pACdk3XWmmTXG8m3upGUJst5XRGzxMRjXzAuJ1XnIFNvfhjjIuYkDvysnPQ7qzqVzLt78BCruntqRhWQbA==", - "dependencies": { - "deep-is": "~0.1.3", - "fast-levenshtein": "~2.0.6", - "levn": "~0.3.0", - "prelude-ls": "~1.1.2", - "type-check": "~0.3.2", - "word-wrap": "~1.2.3" - }, - "engines": { - "node": ">= 0.8.0" - } - }, - "node_modules/escodegen/node_modules/prelude-ls": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", - "integrity": "sha512-ESF23V4SKG6lVSGZgYNpbsiaAkdab6ZgOxe52p7+Kid3W3u3bxR4Vfd/o21dmN7jSt0IwgZ4v5MUd26FEtXE9w==", - "engines": { - "node": ">= 0.8.0" - } - }, - "node_modules/escodegen/node_modules/source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "optional": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/escodegen/node_modules/type-check": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", - "integrity": "sha512-ZCmOJdvOWDBYJlzAoFkC+Q0+bUyEOS1ltgp1MGU03fqHG+dbi9tBFU2Rd9QKiDZFAYrhPh2JUf7rZRIuHRKtOg==", - "dependencies": { - "prelude-ls": "~1.1.2" - }, - "engines": { - "node": ">= 0.8.0" - } - }, - "node_modules/esdoc": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/esdoc/-/esdoc-1.1.0.tgz", - "integrity": "sha512-vsUcp52XJkOWg9m1vDYplGZN2iDzvmjDL5M/Mp8qkoDG3p2s0yIQCIjKR5wfPBaM3eV14a6zhQNYiNTCVzPnxA==", - "dependencies": { - "babel-generator": "6.26.1", - "babel-traverse": "6.26.0", - "babylon": "6.18.0", - "cheerio": "1.0.0-rc.2", - "color-logger": "0.0.6", - "escape-html": "1.0.3", - "fs-extra": "5.0.0", - "ice-cap": "0.0.4", - "marked": "0.3.19", - "minimist": "1.2.0", - "taffydb": "2.7.3" - }, - "bin": { - "esdoc": "out/src/ESDocCLI.js" - }, - "engines": { - "node": ">= 6.0.0" - } - }, - "node_modules/esdoc-accessor-plugin": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/esdoc-accessor-plugin/-/esdoc-accessor-plugin-1.0.0.tgz", - "integrity": "sha512-s9mNmdHGOyQOaOUXNHPz38Y8clm6dR8/fa9DPGzuRYmIN+Lv0NVnpPAcHb5XrfC23/Mz3IUwD8h798f5Ai4rbA==", - "engines": { - "node": ">= 6.0.0" - } - }, - "node_modules/esdoc-brand-plugin": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/esdoc-brand-plugin/-/esdoc-brand-plugin-1.0.1.tgz", - "integrity": "sha512-Yv9j3M7qk5PSLmSeD6MbPsfIsEf8K43EdH8qZpE/GZwnJCRVmDPrZJ1cLDj/fPu6P35YqgcEaJK4E2NL/CKA7g==", - "dependencies": { - "cheerio": "0.22.0" - }, - "engines": { - "node": ">= 6.0.0" - } - }, - "node_modules/esdoc-brand-plugin/node_modules/cheerio": { - "version": "0.22.0", - "resolved": "https://registry.npmjs.org/cheerio/-/cheerio-0.22.0.tgz", - "integrity": "sha512-8/MzidM6G/TgRelkzDG13y3Y9LxBjCb+8yOEZ9+wwq5gVF2w2pV0wmHvjfT0RvuxGyR7UEuK36r+yYMbT4uKgA==", - "dependencies": { - "css-select": "~1.2.0", - "dom-serializer": "~0.1.0", - "entities": "~1.1.1", - "htmlparser2": "^3.9.1", - "lodash.assignin": "^4.0.9", - "lodash.bind": "^4.1.4", - "lodash.defaults": "^4.0.1", - "lodash.filter": "^4.4.0", - "lodash.flatten": "^4.2.0", - "lodash.foreach": "^4.3.0", - "lodash.map": "^4.4.0", - "lodash.merge": "^4.4.0", - "lodash.pick": "^4.2.1", - "lodash.reduce": "^4.4.0", - "lodash.reject": "^4.4.0", - "lodash.some": "^4.4.0" - }, - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/esdoc-brand-plugin/node_modules/css-select": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/css-select/-/css-select-1.2.0.tgz", - "integrity": "sha512-dUQOBoqdR7QwV90WysXPLXG5LO7nhYBgiWVfxF80DKPF8zx1t/pUd2FYy73emg3zrjtM6dzmYgbHKfV2rxiHQA==", - "dependencies": { - "boolbase": "~1.0.0", - "css-what": "2.1", - "domutils": "1.5.1", - "nth-check": "~1.0.1" - } - }, - "node_modules/esdoc-brand-plugin/node_modules/css-what": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/css-what/-/css-what-2.1.3.tgz", - "integrity": "sha512-a+EPoD+uZiNfh+5fxw2nO9QwFa6nJe2Or35fGY6Ipw1R3R4AGz1d1TEZrCegvw2YTmZ0jXirGYlzxxpYSHwpEg==", - "engines": { - "node": "*" - } - }, - "node_modules/esdoc-brand-plugin/node_modules/dom-serializer": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-0.1.1.tgz", - "integrity": "sha512-l0IU0pPzLWSHBcieZbpOKgkIn3ts3vAh7ZuFyXNwJxJXk/c4Gwj9xaTJwIDVQCXawWD0qb3IzMGH5rglQaO0XA==", - "dependencies": { - "domelementtype": "^1.3.0", - "entities": "^1.1.1" - } - }, - "node_modules/esdoc-brand-plugin/node_modules/domelementtype": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-1.3.1.tgz", - "integrity": "sha512-BSKB+TSpMpFI/HOxCNr1O8aMOTZ8hT3pM3GQ0w/mWRmkhEDSFJkkyzz4XQsBV44BChwGkrDfMyjVD0eA2aFV3w==" - }, - "node_modules/esdoc-brand-plugin/node_modules/domhandler": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-2.4.2.tgz", - "integrity": "sha512-JiK04h0Ht5u/80fdLMCEmV4zkNh2BcoMFBmZ/91WtYZ8qVXSKjiw7fXMgFPnHcSZgOo3XdinHvmnDUeMf5R4wA==", - "dependencies": { - "domelementtype": "1" - } - }, - "node_modules/esdoc-brand-plugin/node_modules/domutils": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/domutils/-/domutils-1.5.1.tgz", - "integrity": "sha512-gSu5Oi/I+3wDENBsOWBiRK1eoGxcywYSqg3rR960/+EfY0CF4EX1VPkgHOZ3WiS/Jg2DtliF6BhWcHlfpYUcGw==", - "dependencies": { - "dom-serializer": "0", - "domelementtype": "1" - } - }, - "node_modules/esdoc-brand-plugin/node_modules/entities": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/entities/-/entities-1.1.2.tgz", - "integrity": "sha512-f2LZMYl1Fzu7YSBKg+RoROelpOaNrcGmE9AZubeDfrCEia483oW4MI4VyFd5VNHIgQ/7qm1I0wUHK1eJnn2y2w==" - }, - "node_modules/esdoc-brand-plugin/node_modules/htmlparser2": { - "version": "3.10.1", - "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-3.10.1.tgz", - "integrity": "sha512-IgieNijUMbkDovyoKObU1DUhm1iwNYE/fuifEoEHfd1oZKZDaONBSkal7Y01shxsM49R4XaMdGez3WnF9UfiCQ==", - "dependencies": { - "domelementtype": "^1.3.1", - "domhandler": "^2.3.0", - "domutils": "^1.5.1", - "entities": "^1.1.1", - "inherits": "^2.0.1", - "readable-stream": "^3.1.1" - } - }, - "node_modules/esdoc-brand-plugin/node_modules/nth-check": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/nth-check/-/nth-check-1.0.2.tgz", - "integrity": "sha512-WeBOdju8SnzPN5vTUJYxYUxLeXpCaVP5i5e0LF8fg7WORF2Wd7wFX/pk0tYZk7s8T+J7VLy0Da6J1+wCT0AtHg==", - "dependencies": { - "boolbase": "~1.0.0" - } - }, - "node_modules/esdoc-coverage-plugin": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/esdoc-coverage-plugin/-/esdoc-coverage-plugin-1.1.0.tgz", - "integrity": "sha512-M+94/Y+eoM08V3teiJIYpJ5HF13jH4cC9LQZrjmA91mlAqCHtNzelHF9ZdWofoOFYFRNpllFsXTFsJgwVa000A==", - "engines": { - "node": ">= 6.0.0" - } - }, - "node_modules/esdoc-external-ecmascript-plugin": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/esdoc-external-ecmascript-plugin/-/esdoc-external-ecmascript-plugin-1.0.0.tgz", - "integrity": "sha512-ASj7lhfZpzI01xd4XqB4HN+zNKwnhdaN/OIp/CTnUiLIErMOeUqzV9z/dcnUUeDY3NSwPCH1pUNATVwznspmHw==", - "dependencies": { - "fs-extra": "1.0.0" - }, - "engines": { - "node": ">= 6.0.0" - } - }, - "node_modules/esdoc-external-ecmascript-plugin/node_modules/fs-extra": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-1.0.0.tgz", - "integrity": "sha512-VerQV6vEKuhDWD2HGOybV6v5I73syoc/cXAbKlgTC7M/oFVEtklWlp9QH2Ijw3IaWDOQcMkldSPa7zXy79Z/UQ==", - "dependencies": { - "graceful-fs": "^4.1.2", - "jsonfile": "^2.1.0", - "klaw": "^1.0.0" - } - }, - "node_modules/esdoc-external-ecmascript-plugin/node_modules/jsonfile": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-2.4.0.tgz", - "integrity": "sha512-PKllAqbgLgxHaj8TElYymKCAgrASebJrWpTnEkOaTowt23VKXXN0sUeriJ+eh7y6ufb/CC5ap11pz71/cM0hUw==", - "optionalDependencies": { - "graceful-fs": "^4.1.6" - } - }, - "node_modules/esdoc-integrate-manual-plugin": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/esdoc-integrate-manual-plugin/-/esdoc-integrate-manual-plugin-1.0.0.tgz", - "integrity": "sha512-+XcW8xRtuFVFadoVLIOj6kzX4uqtAEB5UoR7AA5g46StxLghZZ6RLrRQSERUTIc3VX9v47lOMKEaQvQfanv3+A==", - "engines": { - "node": ">= 6.0.0" - } - }, - "node_modules/esdoc-integrate-test-plugin": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/esdoc-integrate-test-plugin/-/esdoc-integrate-test-plugin-1.0.0.tgz", - "integrity": "sha512-WRbkbnbWnzF4RdmcoJLYZvhod7jLVUYWU2ZAojYjK+GiqSgy2yjGi7PxckeGF0LtpCuqqKat3PRdUNEMo6Nf3A==", - "engines": { - "node": ">= 6.0.0" - } - }, - "node_modules/esdoc-lint-plugin": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/esdoc-lint-plugin/-/esdoc-lint-plugin-1.0.2.tgz", - "integrity": "sha512-24AYqD2WbZI9We02I7/6dzAa7yUliRTFUaJCZAcYJMQicJT5gUrNFVaI8XmWEN/mhF3szIn1uZBNWeLul4CmNw==", - "engines": { - "node": ">= 6.0.0" - } - }, - "node_modules/esdoc-publish-html-plugin": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/esdoc-publish-html-plugin/-/esdoc-publish-html-plugin-1.1.2.tgz", - "integrity": "sha512-hG1fZmTcEp3P/Hv/qKiMdG1qSp8MjnVZMMkxL5P5ry7I2sX0HQ4P9lt2lms+90Lt0r340HHhSuVx107UL7dphg==", - "dependencies": { - "babel-generator": "6.11.4", - "cheerio": "0.22.0", - "escape-html": "1.0.3", - "fs-extra": "1.0.0", - "ice-cap": "0.0.4", - "marked": "0.3.19", - "taffydb": "2.7.2" - }, - "engines": { - "node": ">= 6.0.0" - } - }, - "node_modules/esdoc-publish-html-plugin/node_modules/babel-generator": { - "version": "6.11.4", - "resolved": "https://registry.npmjs.org/babel-generator/-/babel-generator-6.11.4.tgz", - "integrity": "sha512-JFBWXdE89s4V3E8kZroEEsnQF2A4/+55IzciGjnAATXj7HTMSum3SrW7QRYGSDLWTTQF+hhD3BmC2UFGgtM0Yw==", - "dependencies": { - "babel-messages": "^6.8.0", - "babel-runtime": "^6.9.0", - "babel-types": "^6.10.2", - "detect-indent": "^3.0.1", - "lodash": "^4.2.0", - "source-map": "^0.5.0" - } - }, - "node_modules/esdoc-publish-html-plugin/node_modules/cheerio": { - "version": "0.22.0", - "resolved": "https://registry.npmjs.org/cheerio/-/cheerio-0.22.0.tgz", - "integrity": "sha512-8/MzidM6G/TgRelkzDG13y3Y9LxBjCb+8yOEZ9+wwq5gVF2w2pV0wmHvjfT0RvuxGyR7UEuK36r+yYMbT4uKgA==", - "dependencies": { - "css-select": "~1.2.0", - "dom-serializer": "~0.1.0", - "entities": "~1.1.1", - "htmlparser2": "^3.9.1", - "lodash.assignin": "^4.0.9", - "lodash.bind": "^4.1.4", - "lodash.defaults": "^4.0.1", - "lodash.filter": "^4.4.0", - "lodash.flatten": "^4.2.0", - "lodash.foreach": "^4.3.0", - "lodash.map": "^4.4.0", - "lodash.merge": "^4.4.0", - "lodash.pick": "^4.2.1", - "lodash.reduce": "^4.4.0", - "lodash.reject": "^4.4.0", - "lodash.some": "^4.4.0" - }, - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/esdoc-publish-html-plugin/node_modules/css-select": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/css-select/-/css-select-1.2.0.tgz", - "integrity": "sha512-dUQOBoqdR7QwV90WysXPLXG5LO7nhYBgiWVfxF80DKPF8zx1t/pUd2FYy73emg3zrjtM6dzmYgbHKfV2rxiHQA==", - "dependencies": { - "boolbase": "~1.0.0", - "css-what": "2.1", - "domutils": "1.5.1", - "nth-check": "~1.0.1" - } - }, - "node_modules/esdoc-publish-html-plugin/node_modules/css-what": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/css-what/-/css-what-2.1.3.tgz", - "integrity": "sha512-a+EPoD+uZiNfh+5fxw2nO9QwFa6nJe2Or35fGY6Ipw1R3R4AGz1d1TEZrCegvw2YTmZ0jXirGYlzxxpYSHwpEg==", - "engines": { - "node": "*" - } - }, - "node_modules/esdoc-publish-html-plugin/node_modules/detect-indent": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/detect-indent/-/detect-indent-3.0.1.tgz", - "integrity": "sha512-xo3WP66SNbr1Eim85s/qyH0ZL8PQUwp86HWm0S1l8WnJ/zjT6T3w1nwNA0yOZeuvOemupEYvpvF6BIdYRuERJQ==", - "dependencies": { - "get-stdin": "^4.0.1", - "minimist": "^1.1.0", - "repeating": "^1.1.0" - }, - "bin": { - "detect-indent": "cli.js" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/esdoc-publish-html-plugin/node_modules/dom-serializer": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-0.1.1.tgz", - "integrity": "sha512-l0IU0pPzLWSHBcieZbpOKgkIn3ts3vAh7ZuFyXNwJxJXk/c4Gwj9xaTJwIDVQCXawWD0qb3IzMGH5rglQaO0XA==", - "dependencies": { - "domelementtype": "^1.3.0", - "entities": "^1.1.1" - } - }, - "node_modules/esdoc-publish-html-plugin/node_modules/domelementtype": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-1.3.1.tgz", - "integrity": "sha512-BSKB+TSpMpFI/HOxCNr1O8aMOTZ8hT3pM3GQ0w/mWRmkhEDSFJkkyzz4XQsBV44BChwGkrDfMyjVD0eA2aFV3w==" - }, - "node_modules/esdoc-publish-html-plugin/node_modules/domhandler": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-2.4.2.tgz", - "integrity": "sha512-JiK04h0Ht5u/80fdLMCEmV4zkNh2BcoMFBmZ/91WtYZ8qVXSKjiw7fXMgFPnHcSZgOo3XdinHvmnDUeMf5R4wA==", - "dependencies": { - "domelementtype": "1" - } - }, - "node_modules/esdoc-publish-html-plugin/node_modules/domutils": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/domutils/-/domutils-1.5.1.tgz", - "integrity": "sha512-gSu5Oi/I+3wDENBsOWBiRK1eoGxcywYSqg3rR960/+EfY0CF4EX1VPkgHOZ3WiS/Jg2DtliF6BhWcHlfpYUcGw==", - "dependencies": { - "dom-serializer": "0", - "domelementtype": "1" - } - }, - "node_modules/esdoc-publish-html-plugin/node_modules/entities": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/entities/-/entities-1.1.2.tgz", - "integrity": "sha512-f2LZMYl1Fzu7YSBKg+RoROelpOaNrcGmE9AZubeDfrCEia483oW4MI4VyFd5VNHIgQ/7qm1I0wUHK1eJnn2y2w==" - }, - "node_modules/esdoc-publish-html-plugin/node_modules/fs-extra": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-1.0.0.tgz", - "integrity": "sha512-VerQV6vEKuhDWD2HGOybV6v5I73syoc/cXAbKlgTC7M/oFVEtklWlp9QH2Ijw3IaWDOQcMkldSPa7zXy79Z/UQ==", - "dependencies": { - "graceful-fs": "^4.1.2", - "jsonfile": "^2.1.0", - "klaw": "^1.0.0" - } - }, - "node_modules/esdoc-publish-html-plugin/node_modules/htmlparser2": { - "version": "3.10.1", - "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-3.10.1.tgz", - "integrity": "sha512-IgieNijUMbkDovyoKObU1DUhm1iwNYE/fuifEoEHfd1oZKZDaONBSkal7Y01shxsM49R4XaMdGez3WnF9UfiCQ==", - "dependencies": { - "domelementtype": "^1.3.1", - "domhandler": "^2.3.0", - "domutils": "^1.5.1", - "entities": "^1.1.1", - "inherits": "^2.0.1", - "readable-stream": "^3.1.1" - } - }, - "node_modules/esdoc-publish-html-plugin/node_modules/jsonfile": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-2.4.0.tgz", - "integrity": "sha512-PKllAqbgLgxHaj8TElYymKCAgrASebJrWpTnEkOaTowt23VKXXN0sUeriJ+eh7y6ufb/CC5ap11pz71/cM0hUw==", - "optionalDependencies": { - "graceful-fs": "^4.1.6" - } - }, - "node_modules/esdoc-publish-html-plugin/node_modules/nth-check": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/nth-check/-/nth-check-1.0.2.tgz", - "integrity": "sha512-WeBOdju8SnzPN5vTUJYxYUxLeXpCaVP5i5e0LF8fg7WORF2Wd7wFX/pk0tYZk7s8T+J7VLy0Da6J1+wCT0AtHg==", - "dependencies": { - "boolbase": "~1.0.0" - } - }, - "node_modules/esdoc-publish-html-plugin/node_modules/repeating": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/repeating/-/repeating-1.1.3.tgz", - "integrity": "sha512-Nh30JLeMHdoI+AsQ5eblhZ7YlTsM9wiJQe/AHIunlK3KWzvXhXb36IJ7K1IOeRjIOtzMjdUHjwXUFxKJoPTSOg==", - "dependencies": { - "is-finite": "^1.0.0" - }, - "bin": { - "repeating": "cli.js" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/esdoc-publish-html-plugin/node_modules/source-map": { - "version": "0.5.7", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", - "integrity": "sha512-LbrmJOMUSdEVxIKvdcJzQC+nQhe8FUZQTXQy6+I75skNgn3OoQ0DZA8YnFa7gp8tqtL3KPf1kmo0R5DoApeSGQ==", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/esdoc-publish-html-plugin/node_modules/taffydb": { - "version": "2.7.2", - "resolved": "https://registry.npmjs.org/taffydb/-/taffydb-2.7.2.tgz", - "integrity": "sha512-R6es6/C/m1xXZckrSam4j07YKbd74437mRJ/R944S1hLG7mIl2/EQW7tQPI4XiX7jTduFzz31g7466a2BcsglQ==" - }, - "node_modules/esdoc-standard-plugin": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/esdoc-standard-plugin/-/esdoc-standard-plugin-1.0.0.tgz", - "integrity": "sha512-IDEG9NV/MF5Bi2TdKPqQ3GHfDkgqYhk2iyvBNX+XcNKYmXm9zxtXVS459WAmiTZuYpDLtDGbulQdJ1t4ud57mw==", - "dependencies": { - "esdoc-accessor-plugin": "^1.0.0", - "esdoc-brand-plugin": "^1.0.0", - "esdoc-coverage-plugin": "^1.0.0", - "esdoc-external-ecmascript-plugin": "^1.0.0", - "esdoc-integrate-manual-plugin": "^1.0.0", - "esdoc-integrate-test-plugin": "^1.0.0", - "esdoc-lint-plugin": "^1.0.0", - "esdoc-publish-html-plugin": "^1.0.0", - "esdoc-type-inference-plugin": "^1.0.0", - "esdoc-undocumented-identifier-plugin": "^1.0.0", - "esdoc-unexported-identifier-plugin": "^1.0.0" - }, - "engines": { - "node": ">= 6.0.0" - } - }, - "node_modules/esdoc-type-inference-plugin": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/esdoc-type-inference-plugin/-/esdoc-type-inference-plugin-1.0.2.tgz", - "integrity": "sha512-tMIcEHNe1uhUGA7lT1UTWc9hs2dzthnTgmqXpmeUhurk7fL2tinvoH+IVvG/sLROzwOGZQS9zW/F9KWnpMzLIQ==", - "engines": { - "node": ">= 6.0.0" - } - }, - "node_modules/esdoc-undocumented-identifier-plugin": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/esdoc-undocumented-identifier-plugin/-/esdoc-undocumented-identifier-plugin-1.0.0.tgz", - "integrity": "sha512-T0hQc0ec1+pUJPDBoJ2SxEv7uX9VD7Q9+7UAGnDZ5R2l2JYa3WY7cawyqfbMHVtLgvqH0eMBpxdfRsQvAWzj4Q==", - "engines": { - "node": ">= 6.0.0" - } - }, - "node_modules/esdoc-unexported-identifier-plugin": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/esdoc-unexported-identifier-plugin/-/esdoc-unexported-identifier-plugin-1.0.0.tgz", - "integrity": "sha512-PRdMLWHWdy9PwxzYDG2clhta9H7yHDpGCBIHxSw9R7TFK6ZYuPK1fUbURIzIxcdQhzt1PX9Cn6Cak2824K0+Ng==", - "engines": { - "node": ">= 6.0.0" - } - }, - "node_modules/esdoc/node_modules/fs-extra": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-5.0.0.tgz", - "integrity": "sha512-66Pm4RYbjzdyeuqudYqhFiNBbCIuI9kgRqLPSHIlXHidW8NIQtVdkM1yeZ4lXwuhbTETv3EUGMNHAAw6hiundQ==", - "dependencies": { - "graceful-fs": "^4.1.2", - "jsonfile": "^4.0.0", - "universalify": "^0.1.0" - } - }, - "node_modules/esdoc/node_modules/jsonfile": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", - "integrity": "sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg==", - "optionalDependencies": { - "graceful-fs": "^4.1.6" - } - }, - "node_modules/esdoc/node_modules/minimist": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha512-7Wl+Jz+IGWuSdgsQEJ4JunV0si/iMhg42MnQQG6h1R6TNeVenp4U9x5CC5v/gYqz/fENLQITAWXidNtVL0NNbw==" - }, - "node_modules/esdoc/node_modules/universalify": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", - "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==", - "engines": { - "node": ">= 4.0.0" - } - }, - "node_modules/eslint": { - "version": "8.41.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.41.0.tgz", - "integrity": "sha512-WQDQpzGBOP5IrXPo4Hc0814r4/v2rrIsB0rhT7jtunIalgg6gYXWhRMOejVO8yH21T/FGaxjmFjBMNqcIlmH1Q==", - "dependencies": { - "@eslint-community/eslint-utils": "^4.2.0", - "@eslint-community/regexpp": "^4.4.0", - "@eslint/eslintrc": "^2.0.3", - "@eslint/js": "8.41.0", - "@humanwhocodes/config-array": "^0.11.8", - "@humanwhocodes/module-importer": "^1.0.1", - "@nodelib/fs.walk": "^1.2.8", - "ajv": "^6.10.0", - "chalk": "^4.0.0", - "cross-spawn": "^7.0.2", - "debug": "^4.3.2", - "doctrine": "^3.0.0", - "escape-string-regexp": "^4.0.0", - "eslint-scope": "^7.2.0", - "eslint-visitor-keys": "^3.4.1", - "espree": "^9.5.2", - "esquery": "^1.4.2", - "esutils": "^2.0.2", - "fast-deep-equal": "^3.1.3", - "file-entry-cache": "^6.0.1", - "find-up": "^5.0.0", - "glob-parent": "^6.0.2", - "globals": "^13.19.0", - "graphemer": "^1.4.0", - "ignore": "^5.2.0", - "import-fresh": "^3.0.0", - "imurmurhash": "^0.1.4", - "is-glob": "^4.0.0", - "is-path-inside": "^3.0.3", - "js-yaml": "^4.1.0", - "json-stable-stringify-without-jsonify": "^1.0.1", - "levn": "^0.4.1", - "lodash.merge": "^4.6.2", - "minimatch": "^3.1.2", - "natural-compare": "^1.4.0", - "optionator": "^0.9.1", - "strip-ansi": "^6.0.1", - "strip-json-comments": "^3.1.0", - "text-table": "^0.2.0" - }, - "bin": { - "eslint": "bin/eslint.js" - }, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "funding": { - "url": "https://opencollective.com/eslint" - } - }, - "node_modules/eslint-config-react-app": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/eslint-config-react-app/-/eslint-config-react-app-7.0.1.tgz", - "integrity": "sha512-K6rNzvkIeHaTd8m/QEh1Zko0KI7BACWkkneSs6s9cKZC/J27X3eZR6Upt1jkmZ/4FK+XUOPPxMEN7+lbUXfSlA==", - "dependencies": { - "@babel/core": "^7.16.0", - "@babel/eslint-parser": "^7.16.3", - "@rushstack/eslint-patch": "^1.1.0", - "@typescript-eslint/eslint-plugin": "^5.5.0", - "@typescript-eslint/parser": "^5.5.0", - "babel-preset-react-app": "^10.0.1", - "confusing-browser-globals": "^1.0.11", - "eslint-plugin-flowtype": "^8.0.3", - "eslint-plugin-import": "^2.25.3", - "eslint-plugin-jest": "^25.3.0", - "eslint-plugin-jsx-a11y": "^6.5.1", - "eslint-plugin-react": "^7.27.1", - "eslint-plugin-react-hooks": "^4.3.0", - "eslint-plugin-testing-library": "^5.0.1" - }, - "engines": { - "node": ">=14.0.0" - }, - "peerDependencies": { - "eslint": "^8.0.0" - } - }, - "node_modules/eslint-import-resolver-node": { - "version": "0.3.7", - "resolved": "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.7.tgz", - "integrity": "sha512-gozW2blMLJCeFpBwugLTGyvVjNoeo1knonXAcatC6bjPBZitotxdWf7Gimr25N4c0AAOo4eOUfaG82IJPDpqCA==", - "dependencies": { - "debug": "^3.2.7", - "is-core-module": "^2.11.0", - "resolve": "^1.22.1" - } - }, - "node_modules/eslint-import-resolver-node/node_modules/debug": { - "version": "3.2.7", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", - "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", - "dependencies": { - "ms": "^2.1.1" - } - }, - "node_modules/eslint-module-utils": { - "version": "2.8.0", - "resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.8.0.tgz", - "integrity": "sha512-aWajIYfsqCKRDgUfjEXNN/JlrzauMuSEy5sbd7WXbtW3EH6A6MpwEh42c7qD+MqQo9QMJ6fWLAeIJynx0g6OAw==", - "dependencies": { - "debug": "^3.2.7" - }, - "engines": { - "node": ">=4" - }, - "peerDependenciesMeta": { - "eslint": { - "optional": true - } - } - }, - "node_modules/eslint-module-utils/node_modules/debug": { - "version": "3.2.7", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", - "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", - "dependencies": { - "ms": "^2.1.1" - } - }, - "node_modules/eslint-plugin-flowtype": { - "version": "8.0.3", - "resolved": "https://registry.npmjs.org/eslint-plugin-flowtype/-/eslint-plugin-flowtype-8.0.3.tgz", - "integrity": "sha512-dX8l6qUL6O+fYPtpNRideCFSpmWOUVx5QcaGLVqe/vlDiBSe4vYljDWDETwnyFzpl7By/WVIu6rcrniCgH9BqQ==", - "dependencies": { - "lodash": "^4.17.21", - "string-natural-compare": "^3.0.1" - }, - "engines": { - "node": ">=12.0.0" - }, - "peerDependencies": { - "@babel/plugin-syntax-flow": "^7.14.5", - "@babel/plugin-transform-react-jsx": "^7.14.9", - "eslint": "^8.1.0" - } - }, - "node_modules/eslint-plugin-import": { - "version": "2.27.5", - "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.27.5.tgz", - "integrity": "sha512-LmEt3GVofgiGuiE+ORpnvP+kAm3h6MLZJ4Q5HCyHADofsb4VzXFsRiWj3c0OFiV+3DWFh0qg3v9gcPlfc3zRow==", - "dependencies": { - "array-includes": "^3.1.6", - "array.prototype.flat": "^1.3.1", - "array.prototype.flatmap": "^1.3.1", - "debug": "^3.2.7", - "doctrine": "^2.1.0", - "eslint-import-resolver-node": "^0.3.7", - "eslint-module-utils": "^2.7.4", - "has": "^1.0.3", - "is-core-module": "^2.11.0", - "is-glob": "^4.0.3", - "minimatch": "^3.1.2", - "object.values": "^1.1.6", - "resolve": "^1.22.1", - "semver": "^6.3.0", - "tsconfig-paths": "^3.14.1" - }, - "engines": { - "node": ">=4" - }, - "peerDependencies": { - "eslint": "^2 || ^3 || ^4 || ^5 || ^6 || ^7.2.0 || ^8" - } - }, - "node_modules/eslint-plugin-import/node_modules/debug": { - "version": "3.2.7", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", - "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", - "dependencies": { - "ms": "^2.1.1" - } - }, - "node_modules/eslint-plugin-import/node_modules/doctrine": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", - "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", - "dependencies": { - "esutils": "^2.0.2" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/eslint-plugin-import/node_modules/semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", - "bin": { - "semver": "bin/semver.js" - } - }, - "node_modules/eslint-plugin-jest": { - "version": "25.7.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-25.7.0.tgz", - "integrity": "sha512-PWLUEXeeF7C9QGKqvdSbzLOiLTx+bno7/HC9eefePfEb257QFHg7ye3dh80AZVkaa/RQsBB1Q/ORQvg2X7F0NQ==", - "dependencies": { - "@typescript-eslint/experimental-utils": "^5.0.0" - }, - "engines": { - "node": "^12.13.0 || ^14.15.0 || >=16.0.0" - }, - "peerDependencies": { - "@typescript-eslint/eslint-plugin": "^4.0.0 || ^5.0.0", - "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0" - }, - "peerDependenciesMeta": { - "@typescript-eslint/eslint-plugin": { - "optional": true - }, - "jest": { - "optional": true - } - } - }, - "node_modules/eslint-plugin-jsx-a11y": { - "version": "6.7.1", - "resolved": "https://registry.npmjs.org/eslint-plugin-jsx-a11y/-/eslint-plugin-jsx-a11y-6.7.1.tgz", - "integrity": "sha512-63Bog4iIethyo8smBklORknVjB0T2dwB8Mr/hIC+fBS0uyHdYYpzM/Ed+YC8VxTjlXHEWFOdmgwcDn1U2L9VCA==", - "dependencies": { - "@babel/runtime": "^7.20.7", - "aria-query": "^5.1.3", - "array-includes": "^3.1.6", - "array.prototype.flatmap": "^1.3.1", - "ast-types-flow": "^0.0.7", - "axe-core": "^4.6.2", - "axobject-query": "^3.1.1", - "damerau-levenshtein": "^1.0.8", - "emoji-regex": "^9.2.2", - "has": "^1.0.3", - "jsx-ast-utils": "^3.3.3", - "language-tags": "=1.0.5", - "minimatch": "^3.1.2", - "object.entries": "^1.1.6", - "object.fromentries": "^2.0.6", - "semver": "^6.3.0" - }, - "engines": { - "node": ">=4.0" - }, - "peerDependencies": { - "eslint": "^3 || ^4 || ^5 || ^6 || ^7 || ^8" - } - }, - "node_modules/eslint-plugin-jsx-a11y/node_modules/semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", - "bin": { - "semver": "bin/semver.js" - } - }, - "node_modules/eslint-plugin-react": { - "version": "7.32.2", - "resolved": "https://registry.npmjs.org/eslint-plugin-react/-/eslint-plugin-react-7.32.2.tgz", - "integrity": "sha512-t2fBMa+XzonrrNkyVirzKlvn5RXzzPwRHtMvLAtVZrt8oxgnTQaYbU6SXTOO1mwQgp1y5+toMSKInnzGr0Knqg==", - "dependencies": { - "array-includes": "^3.1.6", - "array.prototype.flatmap": "^1.3.1", - "array.prototype.tosorted": "^1.1.1", - "doctrine": "^2.1.0", - "estraverse": "^5.3.0", - "jsx-ast-utils": "^2.4.1 || ^3.0.0", - "minimatch": "^3.1.2", - "object.entries": "^1.1.6", - "object.fromentries": "^2.0.6", - "object.hasown": "^1.1.2", - "object.values": "^1.1.6", - "prop-types": "^15.8.1", - "resolve": "^2.0.0-next.4", - "semver": "^6.3.0", - "string.prototype.matchall": "^4.0.8" - }, - "engines": { - "node": ">=4" - }, - "peerDependencies": { - "eslint": "^3 || ^4 || ^5 || ^6 || ^7 || ^8" - } - }, - "node_modules/eslint-plugin-react-hooks": { - "version": "4.6.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-4.6.0.tgz", - "integrity": "sha512-oFc7Itz9Qxh2x4gNHStv3BqJq54ExXmfC+a1NjAta66IAN87Wu0R/QArgIS9qKzX3dXKPI9H5crl9QchNMY9+g==", - "engines": { - "node": ">=10" - }, - "peerDependencies": { - "eslint": "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0" - } - }, - "node_modules/eslint-plugin-react/node_modules/doctrine": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", - "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", - "dependencies": { - "esutils": "^2.0.2" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/eslint-plugin-react/node_modules/resolve": { - "version": "2.0.0-next.4", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-2.0.0-next.4.tgz", - "integrity": "sha512-iMDbmAWtfU+MHpxt/I5iWI7cY6YVEZUQ3MBgPQ++XD1PELuJHIl82xBmObyP2KyQmkNB2dsqF7seoQQiAn5yDQ==", - "dependencies": { - "is-core-module": "^2.9.0", - "path-parse": "^1.0.7", - "supports-preserve-symlinks-flag": "^1.0.0" - }, - "bin": { - "resolve": "bin/resolve" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/eslint-plugin-react/node_modules/semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", - "bin": { - "semver": "bin/semver.js" - } - }, - "node_modules/eslint-plugin-testing-library": { - "version": "5.11.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-testing-library/-/eslint-plugin-testing-library-5.11.0.tgz", - "integrity": "sha512-ELY7Gefo+61OfXKlQeXNIDVVLPcvKTeiQOoMZG9TeuWa7Ln4dUNRv8JdRWBQI9Mbb427XGlVB1aa1QPZxBJM8Q==", - "dependencies": { - "@typescript-eslint/utils": "^5.58.0" - }, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0", - "npm": ">=6" - }, - "peerDependencies": { - "eslint": "^7.5.0 || ^8.0.0" - } - }, - "node_modules/eslint-scope": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.2.0.tgz", - "integrity": "sha512-DYj5deGlHBfMt15J7rdtyKNq/Nqlv5KfU4iodrQ019XESsRnwXH9KAE0y3cwtUHDo2ob7CypAnCqefh6vioWRw==", - "dependencies": { - "esrecurse": "^4.3.0", - "estraverse": "^5.2.0" - }, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "funding": { - "url": "https://opencollective.com/eslint" - } - }, - "node_modules/eslint-visitor-keys": { - "version": "3.4.1", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.1.tgz", - "integrity": "sha512-pZnmmLwYzf+kWaM/Qgrvpen51upAktaaiI01nsJD/Yr3lMOdNtq0cxkrrg16w64VtisN6okbs7Q8AfGqj4c9fA==", - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "funding": { - "url": "https://opencollective.com/eslint" - } - }, - "node_modules/eslint-webpack-plugin": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/eslint-webpack-plugin/-/eslint-webpack-plugin-3.2.0.tgz", - "integrity": "sha512-avrKcGncpPbPSUHX6B3stNGzkKFto3eL+DKM4+VyMrVnhPc3vRczVlCq3uhuFOdRvDHTVXuzwk1ZKUrqDQHQ9w==", - "dependencies": { - "@types/eslint": "^7.29.0 || ^8.4.1", - "jest-worker": "^28.0.2", - "micromatch": "^4.0.5", - "normalize-path": "^3.0.0", - "schema-utils": "^4.0.0" - }, - "engines": { - "node": ">= 12.13.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/webpack" - }, - "peerDependencies": { - "eslint": "^7.0.0 || ^8.0.0", - "webpack": "^5.0.0" - } - }, - "node_modules/eslint-webpack-plugin/node_modules/ajv": { - "version": "8.12.0", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.12.0.tgz", - "integrity": "sha512-sRu1kpcO9yLtYxBKvqfTeh9KzZEwO3STyX1HT+4CaDzC6HpTGYhIhPIzj9XuKU7KYDwnaeh5hcOwjy1QuJzBPA==", - "dependencies": { - "fast-deep-equal": "^3.1.1", - "json-schema-traverse": "^1.0.0", - "require-from-string": "^2.0.2", - "uri-js": "^4.2.2" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/epoberezkin" - } - }, - "node_modules/eslint-webpack-plugin/node_modules/ajv-keywords": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-5.1.0.tgz", - "integrity": "sha512-YCS/JNFAUyr5vAuhk1DWm1CBxRHW9LbJ2ozWeemrIqpbsqKjHVxYPyi5GC0rjZIT5JxJ3virVTS8wk4i/Z+krw==", - "dependencies": { - "fast-deep-equal": "^3.1.3" - }, - "peerDependencies": { - "ajv": "^8.8.2" - } - }, - "node_modules/eslint-webpack-plugin/node_modules/has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "engines": { - "node": ">=8" - } - }, - "node_modules/eslint-webpack-plugin/node_modules/jest-worker": { - "version": "28.1.3", - "resolved": "https://registry.npmjs.org/jest-worker/-/jest-worker-28.1.3.tgz", - "integrity": "sha512-CqRA220YV/6jCo8VWvAt1KKx6eek1VIHMPeLEbpcfSfkEeWyBNppynM/o6q+Wmw+sOhos2ml34wZbSX3G13//g==", - "dependencies": { - "@types/node": "*", - "merge-stream": "^2.0.0", - "supports-color": "^8.0.0" - }, - "engines": { - "node": "^12.13.0 || ^14.15.0 || ^16.10.0 || >=17.0.0" - } - }, - "node_modules/eslint-webpack-plugin/node_modules/json-schema-traverse": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", - "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==" - }, - "node_modules/eslint-webpack-plugin/node_modules/schema-utils": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-4.0.1.tgz", - "integrity": "sha512-lELhBAAly9NowEsX0yZBlw9ahZG+sK/1RJ21EpzdYHKEs13Vku3LJ+MIPhh4sMs0oCCeufZQEQbMekiA4vuVIQ==", - "dependencies": { - "@types/json-schema": "^7.0.9", - "ajv": "^8.9.0", - "ajv-formats": "^2.1.1", - "ajv-keywords": "^5.1.0" - }, - "engines": { - "node": ">= 12.13.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/webpack" - } - }, - "node_modules/eslint-webpack-plugin/node_modules/supports-color": { - "version": "8.1.1", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", - "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/supports-color?sponsor=1" - } - }, - "node_modules/eslint/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/eslint/node_modules/argparse": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", - "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==" - }, - "node_modules/eslint/node_modules/chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dependencies": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" - } - }, - "node_modules/eslint/node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/eslint/node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" - }, - "node_modules/eslint/node_modules/escape-string-regexp": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", - "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/eslint/node_modules/globals": { - "version": "13.20.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-13.20.0.tgz", - "integrity": "sha512-Qg5QtVkCy/kv3FUSlu4ukeZDVf9ee0iXLAUYX13gbR17bnejFTzr4iS9bY7kwCf1NztRNm1t91fjOiyx4CSwPQ==", - "dependencies": { - "type-fest": "^0.20.2" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/eslint/node_modules/has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "engines": { - "node": ">=8" - } - }, - "node_modules/eslint/node_modules/js-yaml": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", - "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", - "dependencies": { - "argparse": "^2.0.1" - }, - "bin": { - "js-yaml": "bin/js-yaml.js" - } - }, - "node_modules/eslint/node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/eslint/node_modules/type-fest": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", - "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/espree": { - "version": "9.5.2", - "resolved": "https://registry.npmjs.org/espree/-/espree-9.5.2.tgz", - "integrity": "sha512-7OASN1Wma5fum5SrNhFMAMJxOUAbhyfQ8dQ//PJaJbNw0URTPWqIghHWt1MmAANKhHZIYOHruW4Kw4ruUWOdGw==", - "dependencies": { - "acorn": "^8.8.0", - "acorn-jsx": "^5.3.2", - "eslint-visitor-keys": "^3.4.1" - }, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "funding": { - "url": "https://opencollective.com/eslint" - } - }, - "node_modules/esprima": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", - "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", - "bin": { - "esparse": "bin/esparse.js", - "esvalidate": "bin/esvalidate.js" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/esquery": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.5.0.tgz", - "integrity": "sha512-YQLXUplAwJgCydQ78IMJywZCceoqk1oH01OERdSAJc/7U2AylwjhSCLDEtqwg811idIS/9fIU5GjG73IgjKMVg==", - "dependencies": { - "estraverse": "^5.1.0" - }, - "engines": { - "node": ">=0.10" - } - }, - "node_modules/esrecurse": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz", - "integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==", - "dependencies": { - "estraverse": "^5.2.0" - }, - "engines": { - "node": ">=4.0" - } - }, - "node_modules/estraverse": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", - "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", - "engines": { - "node": ">=4.0" - } - }, - "node_modules/estree-walker": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-1.0.1.tgz", - "integrity": "sha512-1fMXF3YP4pZZVozF8j/ZLfvnR8NSIljt56UhbZ5PeeDmmGHpgpdwQt7ITlGvYaQukCvuBRMLEiKiYC+oeIg4cg==" - }, - "node_modules/esutils": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", - "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/etag": { - "version": "1.8.1", - "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", - "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/eventemitter3": { - "version": "4.0.7", - "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-4.0.7.tgz", - "integrity": "sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw==" - }, - "node_modules/events": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/events/-/events-3.3.0.tgz", - "integrity": "sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==", - "engines": { - "node": ">=0.8.x" - } - }, - "node_modules/execa": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/execa/-/execa-5.1.1.tgz", - "integrity": "sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg==", - "dependencies": { - "cross-spawn": "^7.0.3", - "get-stream": "^6.0.0", - "human-signals": "^2.1.0", - "is-stream": "^2.0.0", - "merge-stream": "^2.0.0", - "npm-run-path": "^4.0.1", - "onetime": "^5.1.2", - "signal-exit": "^3.0.3", - "strip-final-newline": "^2.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sindresorhus/execa?sponsor=1" - } - }, - "node_modules/exit": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/exit/-/exit-0.1.2.tgz", - "integrity": "sha512-Zk/eNKV2zbjpKzrsQ+n1G6poVbErQxJ0LBOJXaKZ1EViLzH+hrLu9cdXI4zw9dBQJslwBEpbQ2P1oS7nDxs6jQ==", - "engines": { - "node": ">= 0.8.0" - } - }, - "node_modules/expect": { - "version": "27.5.1", - "resolved": "https://registry.npmjs.org/expect/-/expect-27.5.1.tgz", - "integrity": "sha512-E1q5hSUG2AmYQwQJ041nvgpkODHQvB+RKlB4IYdru6uJsyFTRyZAP463M+1lINorwbqAmUggi6+WwkD8lCS/Dw==", - "dependencies": { - "@jest/types": "^27.5.1", - "jest-get-type": "^27.5.1", - "jest-matcher-utils": "^27.5.1", - "jest-message-util": "^27.5.1" - }, - "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" - } - }, - "node_modules/express": { - "version": "4.18.2", - "resolved": "https://registry.npmjs.org/express/-/express-4.18.2.tgz", - "integrity": "sha512-5/PsL6iGPdfQ/lKM1UuielYgv3BUoJfz1aUwU9vHZ+J7gyvwdQXFEBIEIaxeGf0GIcreATNyBExtalisDbuMqQ==", - "dependencies": { - "accepts": "~1.3.8", - "array-flatten": "1.1.1", - "body-parser": "1.20.1", - "content-disposition": "0.5.4", - "content-type": "~1.0.4", - "cookie": "0.5.0", - "cookie-signature": "1.0.6", - "debug": "2.6.9", - "depd": "2.0.0", - "encodeurl": "~1.0.2", - "escape-html": "~1.0.3", - "etag": "~1.8.1", - "finalhandler": "1.2.0", - "fresh": "0.5.2", - "http-errors": "2.0.0", - "merge-descriptors": "1.0.1", - "methods": "~1.1.2", - "on-finished": "2.4.1", - "parseurl": "~1.3.3", - "path-to-regexp": "0.1.7", - "proxy-addr": "~2.0.7", - "qs": "6.11.0", - "range-parser": "~1.2.1", - "safe-buffer": "5.2.1", - "send": "0.18.0", - "serve-static": "1.15.0", - "setprototypeof": "1.2.0", - "statuses": "2.0.1", - "type-is": "~1.6.18", - "utils-merge": "1.0.1", - "vary": "~1.1.2" - }, - "engines": { - "node": ">= 0.10.0" - } - }, - "node_modules/express/node_modules/array-flatten": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", - "integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==" - }, - "node_modules/express/node_modules/debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "dependencies": { - "ms": "2.0.0" - } - }, - "node_modules/express/node_modules/ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" - }, - "node_modules/extend": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", - "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==", - "optional": true - }, - "node_modules/extsprintf": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz", - "integrity": "sha512-11Ndz7Nv+mvAC1j0ktTa7fAb0vLyGGX+rMHNBYQviQDGU0Hw7lhctJANqbPhu9nV9/izT/IntTgZ7Im/9LJs9g==", - "engines": [ - "node >=0.6.0" - ], - "optional": true - }, - "node_modules/fast-deep-equal": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", - "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==" - }, - "node_modules/fast-glob": { - "version": "3.2.12", - "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.12.tgz", - "integrity": "sha512-DVj4CQIYYow0BlaelwK1pHl5n5cRSJfM60UA0zK891sVInoPri2Ekj7+e1CT3/3qxXenpI+nBBmQAcJPJgaj4w==", - "dependencies": { - "@nodelib/fs.stat": "^2.0.2", - "@nodelib/fs.walk": "^1.2.3", - "glob-parent": "^5.1.2", - "merge2": "^1.3.0", - "micromatch": "^4.0.4" - }, - "engines": { - "node": ">=8.6.0" - } - }, - "node_modules/fast-glob/node_modules/glob-parent": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", - "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", - "dependencies": { - "is-glob": "^4.0.1" - }, - "engines": { - "node": ">= 6" - } - }, - "node_modules/fast-json-stable-stringify": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", - "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==" - }, - "node_modules/fast-levenshtein": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", - "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==" - }, - "node_modules/fastq": { - "version": "1.15.0", - "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.15.0.tgz", - "integrity": "sha512-wBrocU2LCXXa+lWBt8RoIRD89Fi8OdABODa/kEnyeyjS5aZO5/GNvI5sEINADqP/h8M29UHTHUb53sUu5Ihqdw==", - "dependencies": { - "reusify": "^1.0.4" - } - }, - "node_modules/faye-websocket": { - "version": "0.11.4", - "resolved": "https://registry.npmjs.org/faye-websocket/-/faye-websocket-0.11.4.tgz", - "integrity": "sha512-CzbClwlXAuiRQAlUyfqPgvPoNKTckTPGfwZV4ZdAhVcP2lh9KUxJg2b5GkE7XbjKQ3YJnQ9z6D9ntLAlB+tP8g==", - "dependencies": { - "websocket-driver": ">=0.5.1" - }, - "engines": { - "node": ">=0.8.0" - } - }, - "node_modules/fb-watchman": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/fb-watchman/-/fb-watchman-2.0.2.tgz", - "integrity": "sha512-p5161BqbuCaSnB8jIbzQHOlpgsPmK5rJVDfDKO91Axs5NC1uu3HRQm6wt9cd9/+GtQQIO53JdGXXoyDpTAsgYA==", - "dependencies": { - "bser": "2.1.1" - } - }, - "node_modules/file-entry-cache": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.1.tgz", - "integrity": "sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg==", - "dependencies": { - "flat-cache": "^3.0.4" - }, - "engines": { - "node": "^10.12.0 || >=12.0.0" - } - }, - "node_modules/file-loader": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/file-loader/-/file-loader-6.2.0.tgz", - "integrity": "sha512-qo3glqyTa61Ytg4u73GultjHGjdRyig3tG6lPtyX/jOEJvHif9uB0/OCI2Kif6ctF3caQTW2G5gym21oAsI4pw==", - "dependencies": { - "loader-utils": "^2.0.0", - "schema-utils": "^3.0.0" - }, - "engines": { - "node": ">= 10.13.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/webpack" - }, - "peerDependencies": { - "webpack": "^4.0.0 || ^5.0.0" - } - }, - "node_modules/file-selector": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/file-selector/-/file-selector-0.6.0.tgz", - "integrity": "sha512-QlZ5yJC0VxHxQQsQhXvBaC7VRJ2uaxTf+Tfpu4Z/OcVQJVpZO+DGU0rkoVW5ce2SccxugvpBJoMvUs59iILYdw==", - "dependencies": { - "tslib": "^2.4.0" - }, - "engines": { - "node": ">= 12" - } - }, - "node_modules/filelist": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/filelist/-/filelist-1.0.4.tgz", - "integrity": "sha512-w1cEuf3S+DrLCQL7ET6kz+gmlJdbq9J7yXCSjK/OZCPA+qEN1WyF4ZAf0YYJa4/shHJra2t/d/r8SV4Ji+x+8Q==", - "dependencies": { - "minimatch": "^5.0.1" - } - }, - "node_modules/filelist/node_modules/brace-expansion": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", - "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", - "dependencies": { - "balanced-match": "^1.0.0" - } - }, - "node_modules/filelist/node_modules/minimatch": { - "version": "5.1.6", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.6.tgz", - "integrity": "sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==", - "dependencies": { - "brace-expansion": "^2.0.1" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/filesize": { - "version": "8.0.7", - "resolved": "https://registry.npmjs.org/filesize/-/filesize-8.0.7.tgz", - "integrity": "sha512-pjmC+bkIF8XI7fWaH8KxHcZL3DPybs1roSKP4rKDvy20tAWwIObE4+JIseG2byfGKhud5ZnM4YSGKBz7Sh0ndQ==", - "engines": { - "node": ">= 0.4.0" - } - }, - "node_modules/fill-range": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", - "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", - "dependencies": { - "to-regex-range": "^5.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/finalhandler": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.2.0.tgz", - "integrity": "sha512-5uXcUVftlQMFnWC9qu/svkWv3GTd2PfUhK/3PLkYNAe7FbqJMt3515HaxE6eRL74GdsriiwujiawdaB1BpEISg==", - "dependencies": { - "debug": "2.6.9", - "encodeurl": "~1.0.2", - "escape-html": "~1.0.3", - "on-finished": "2.4.1", - "parseurl": "~1.3.3", - "statuses": "2.0.1", - "unpipe": "~1.0.0" - }, - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/finalhandler/node_modules/debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "dependencies": { - "ms": "2.0.0" - } - }, - "node_modules/finalhandler/node_modules/ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" - }, - "node_modules/find-cache-dir": { - "version": "3.3.2", - "resolved": "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-3.3.2.tgz", - "integrity": "sha512-wXZV5emFEjrridIgED11OoUKLxiYjAcqot/NJdAkOhlJ+vGzwhOAfcG5OX1jP+S0PcjEn8bdMJv+g2jwQ3Onig==", - "dependencies": { - "commondir": "^1.0.1", - "make-dir": "^3.0.2", - "pkg-dir": "^4.1.0" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/avajs/find-cache-dir?sponsor=1" - } - }, - "node_modules/find-root": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/find-root/-/find-root-1.1.0.tgz", - "integrity": "sha512-NKfW6bec6GfKc0SGx1e07QZY9PE99u0Bft/0rzSD5k3sO/vwkVUpDUKVm5Gpp5Ue3YfShPFTX2070tDs5kB9Ng==" - }, - "node_modules/find-up": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", - "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", - "dependencies": { - "locate-path": "^6.0.0", - "path-exists": "^4.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/flat-cache": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-3.0.4.tgz", - "integrity": "sha512-dm9s5Pw7Jc0GvMYbshN6zchCA9RgQlzzEZX3vylR9IqFfS8XciblUXOKfW6SiuJ0e13eDYZoZV5wdrev7P3Nwg==", - "dependencies": { - "flatted": "^3.1.0", - "rimraf": "^3.0.2" - }, - "engines": { - "node": "^10.12.0 || >=12.0.0" - } - }, - "node_modules/flatted": { - "version": "3.2.7", - "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.2.7.tgz", - "integrity": "sha512-5nqDSxl8nn5BSNxyR3n4I6eDmbolI6WT+QqR547RwxQapgjQBmtktdP+HTBb/a/zLsbzERTONyUB5pefh5TtjQ==" - }, - "node_modules/follow-redirects": { - "version": "1.15.2", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz", - "integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==", - "funding": [ - { - "type": "individual", - "url": "https://github.com/sponsors/RubenVerborgh" - } - ], - "engines": { - "node": ">=4.0" - }, - "peerDependenciesMeta": { - "debug": { - "optional": true - } - } - }, - "node_modules/for-each": { - "version": "0.3.3", - "resolved": "https://registry.npmjs.org/for-each/-/for-each-0.3.3.tgz", - "integrity": "sha512-jqYfLp7mo9vIyQf8ykW2v7A+2N4QjeCeI5+Dz9XraiO1ign81wjiH7Fb9vSOWvQfNtmSa4H2RoQTrrXivdUZmw==", - "dependencies": { - "is-callable": "^1.1.3" - } - }, - "node_modules/forever-agent": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", - "integrity": "sha512-j0KLYPhm6zeac4lz3oJ3o65qvgQCcPubiyotZrXqEaG4hNagNYO8qdlUrX5vwqv9ohqeT/Z3j6+yW067yWWdUw==", - "optional": true, - "engines": { - "node": "*" - } - }, - "node_modules/fork-ts-checker-webpack-plugin": { - "version": "6.5.3", - "resolved": "https://registry.npmjs.org/fork-ts-checker-webpack-plugin/-/fork-ts-checker-webpack-plugin-6.5.3.tgz", - "integrity": "sha512-SbH/l9ikmMWycd5puHJKTkZJKddF4iRLyW3DeZ08HTI7NGyLS38MXd/KGgeWumQO7YNQbW2u/NtPT2YowbPaGQ==", - "dependencies": { - "@babel/code-frame": "^7.8.3", - "@types/json-schema": "^7.0.5", - "chalk": "^4.1.0", - "chokidar": "^3.4.2", - "cosmiconfig": "^6.0.0", - "deepmerge": "^4.2.2", - "fs-extra": "^9.0.0", - "glob": "^7.1.6", - "memfs": "^3.1.2", - "minimatch": "^3.0.4", - "schema-utils": "2.7.0", - "semver": "^7.3.2", - "tapable": "^1.0.0" - }, - "engines": { - "node": ">=10", - "yarn": ">=1.0.0" - }, - "peerDependencies": { - "eslint": ">= 6", - "typescript": ">= 2.7", - "vue-template-compiler": "*", - "webpack": ">= 4" - }, - "peerDependenciesMeta": { - "eslint": { - "optional": true - }, - "vue-template-compiler": { - "optional": true - } - } - }, - "node_modules/fork-ts-checker-webpack-plugin/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/fork-ts-checker-webpack-plugin/node_modules/chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dependencies": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" - } - }, - "node_modules/fork-ts-checker-webpack-plugin/node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/fork-ts-checker-webpack-plugin/node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" - }, - "node_modules/fork-ts-checker-webpack-plugin/node_modules/cosmiconfig": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-6.0.0.tgz", - "integrity": "sha512-xb3ZL6+L8b9JLLCx3ZdoZy4+2ECphCMo2PwqgP1tlfVq6M6YReyzBJtvWWtbDSpNr9hn96pkCiZqUcFEc+54Qg==", - "dependencies": { - "@types/parse-json": "^4.0.0", - "import-fresh": "^3.1.0", - "parse-json": "^5.0.0", - "path-type": "^4.0.0", - "yaml": "^1.7.2" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/fork-ts-checker-webpack-plugin/node_modules/fs-extra": { - "version": "9.1.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-9.1.0.tgz", - "integrity": "sha512-hcg3ZmepS30/7BSFqRvoo3DOMQu7IjqxO5nCDt+zM9XWjb33Wg7ziNT+Qvqbuc3+gWpzO02JubVyk2G4Zvo1OQ==", - "dependencies": { - "at-least-node": "^1.0.0", - "graceful-fs": "^4.2.0", - "jsonfile": "^6.0.1", - "universalify": "^2.0.0" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/fork-ts-checker-webpack-plugin/node_modules/has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "engines": { - "node": ">=8" - } - }, - "node_modules/fork-ts-checker-webpack-plugin/node_modules/schema-utils": { - "version": "2.7.0", - "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-2.7.0.tgz", - "integrity": "sha512-0ilKFI6QQF5nxDZLFn2dMjvc4hjg/Wkg7rHd3jK6/A4a1Hl9VFdQWvgB1UMGoU94pad1P/8N7fMcEnLnSiju8A==", - "dependencies": { - "@types/json-schema": "^7.0.4", - "ajv": "^6.12.2", - "ajv-keywords": "^3.4.1" - }, - "engines": { - "node": ">= 8.9.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/webpack" - } - }, - "node_modules/fork-ts-checker-webpack-plugin/node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/fork-ts-checker-webpack-plugin/node_modules/tapable": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/tapable/-/tapable-1.1.3.tgz", - "integrity": "sha512-4WK/bYZmj8xLr+HUCODHGF1ZFzsYffasLUgEiMBY4fgtltdO6B4WJtlSbPaDTLpYTcGVwM2qLnFTICEcNxs3kA==", - "engines": { - "node": ">=6" - } - }, - "node_modules/form-data": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.1.tgz", - "integrity": "sha512-RHkBKtLWUVwd7SqRIvCZMEvAMoGUp0XU+seQiZejj0COz3RI3hWP4sCv3gZWWLjJTd7rGwcsF5eKZGii0r/hbg==", - "dependencies": { - "asynckit": "^0.4.0", - "combined-stream": "^1.0.8", - "mime-types": "^2.1.12" - }, - "engines": { - "node": ">= 6" - } - }, - "node_modules/forwarded": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", - "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/fraction.js": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/fraction.js/-/fraction.js-4.2.0.tgz", - "integrity": "sha512-MhLuK+2gUcnZe8ZHlaaINnQLl0xRIGRfcGk2yl8xoQAfHrSsL3rYu6FCmBdkdbhc9EPlwyGHewaRsvwRMJtAlA==", - "engines": { - "node": "*" - }, - "funding": { - "type": "patreon", - "url": "https://www.patreon.com/infusion" - } - }, - "node_modules/fresh": { - "version": "0.5.2", - "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", - "integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/fs-extra": { - "version": "10.1.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", - "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==", - "dependencies": { - "graceful-fs": "^4.2.0", - "jsonfile": "^6.0.1", - "universalify": "^2.0.0" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/fs-minipass": { - "version": "1.2.7", - "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-1.2.7.tgz", - "integrity": "sha512-GWSSJGFy4e9GUeCcbIkED+bgAoFyj7XF1mV8rma3QW4NIqX9Kyx79N/PF61H5udOV3aY1IaMLs6pGbH71nlCTA==", - "dependencies": { - "minipass": "^2.6.0" - } - }, - "node_modules/fs-monkey": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/fs-monkey/-/fs-monkey-1.0.3.tgz", - "integrity": "sha512-cybjIfiiE+pTWicSCLFHSrXZ6EilF30oh91FDP9S2B051prEa7QWfrVTQm10/dDpswBDXZugPa1Ogu8Yh+HV0Q==" - }, - "node_modules/fs.realpath": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==" - }, - "node_modules/fsevents": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", - "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", - "hasInstallScript": true, - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": "^8.16.0 || ^10.6.0 || >=11.0.0" - } - }, - "node_modules/function-bind": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", - "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==" - }, - "node_modules/function.prototype.name": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/function.prototype.name/-/function.prototype.name-1.1.5.tgz", - "integrity": "sha512-uN7m/BzVKQnCUF/iW8jYea67v++2u7m5UgENbHRtdDVclOUP+FMPlCNdmk0h/ysGyo2tavMJEDqJAkJdRa1vMA==", - "dependencies": { - "call-bind": "^1.0.2", - "define-properties": "^1.1.3", - "es-abstract": "^1.19.0", - "functions-have-names": "^1.2.2" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/functions-have-names": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/functions-have-names/-/functions-have-names-1.2.3.tgz", - "integrity": "sha512-xckBUXyTIqT97tq2x2AMb+g163b5JFysYk0x4qxNFwbfQkmNZoiRHb6sPzI9/QV33WeuvVYBUIiD4NzNIyqaRQ==", - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/gauge": { - "version": "2.7.4", - "resolved": "https://registry.npmjs.org/gauge/-/gauge-2.7.4.tgz", - "integrity": "sha512-14x4kjc6lkD3ltw589k0NrPD6cCNTD6CWoVUNpB85+DrtONoZn+Rug6xZU5RvSC4+TZPxA5AnBibQYAvZn41Hg==", - "dependencies": { - "aproba": "^1.0.3", - "console-control-strings": "^1.0.0", - "has-unicode": "^2.0.0", - "object-assign": "^4.1.0", - "signal-exit": "^3.0.0", - "string-width": "^1.0.1", - "strip-ansi": "^3.0.1", - "wide-align": "^1.1.0" - } - }, - "node_modules/gauge/node_modules/ansi-regex": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", - "integrity": "sha512-TIGnTpdo+E3+pCyAluZvtED5p5wCqLdezCyhPZzKPcxvFplEt4i+W7OONCKgeZFT3+y5NZZfOOS/Bdcanm1MYA==", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/gauge/node_modules/is-fullwidth-code-point": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", - "integrity": "sha512-1pqUqRjkhPJ9miNq9SwMfdvi6lBJcd6eFxvfaivQhaH3SgisfiuudvFntdKOmxuee/77l+FPjKrQjWvmPjWrRw==", - "dependencies": { - "number-is-nan": "^1.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/gauge/node_modules/string-width": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", - "integrity": "sha512-0XsVpQLnVCXHJfyEs8tC0zpTVIr5PKKsQtkT29IwupnPTjtPmQ3xT/4yCREF9hYkV/3M3kzcUTSAZT6a6h81tw==", - "dependencies": { - "code-point-at": "^1.0.0", - "is-fullwidth-code-point": "^1.0.0", - "strip-ansi": "^3.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/gauge/node_modules/strip-ansi": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "integrity": "sha512-VhumSSbBqDTP8p2ZLKj40UjBCV4+v8bUSEpUb4KjRgWk9pbqGF4REFj6KEagidb2f/M6AzC0EmFyDNGaw9OCzg==", - "dependencies": { - "ansi-regex": "^2.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/gensync": { - "version": "1.0.0-beta.2", - "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz", - "integrity": "sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==", - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/get-caller-file": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", - "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", - "engines": { - "node": "6.* || 8.* || >= 10.*" - } - }, - "node_modules/get-intrinsic": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.1.tgz", - "integrity": "sha512-2DcsyfABl+gVHEfCOaTrWgyt+tb6MSEGmKq+kI5HwLbIYgjgmMcV8KQ41uaKz1xxUcn9tJtgFbQUEVcEbd0FYw==", - "dependencies": { - "function-bind": "^1.1.1", - "has": "^1.0.3", - "has-proto": "^1.0.1", - "has-symbols": "^1.0.3" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/get-nonce": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/get-nonce/-/get-nonce-1.0.1.tgz", - "integrity": "sha512-FJhYRoDaiatfEkUK8HKlicmu/3SGFD51q3itKDGoSTysQJBnfOcxU5GxnhE1E6soB76MbT0MBtnKJuXyAx+96Q==", - "engines": { - "node": ">=6" - } - }, - "node_modules/get-own-enumerable-property-symbols": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/get-own-enumerable-property-symbols/-/get-own-enumerable-property-symbols-3.0.2.tgz", - "integrity": "sha512-I0UBV/XOz1XkIJHEUDMZAbzCThU/H8DxmSfmdGcKPnVhu2VfFqr34jr9777IyaTYvxjedWhqVIilEDsCdP5G6g==" - }, - "node_modules/get-package-type": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/get-package-type/-/get-package-type-0.1.0.tgz", - "integrity": "sha512-pjzuKtY64GYfWizNAJ0fr9VqttZkNiK2iS430LtIHzjBEr6bX8Am2zm4sW4Ro5wjWW5cAlRL1qAMTcXbjNAO2Q==", - "engines": { - "node": ">=8.0.0" - } - }, - "node_modules/get-stdin": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-4.0.1.tgz", - "integrity": "sha512-F5aQMywwJ2n85s4hJPTT9RPxGmubonuB10MNYo17/xph174n2MIR33HRguhzVag10O/npM7SPk73LMZNP+FaWw==", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/get-stream": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-6.0.1.tgz", - "integrity": "sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==", - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/get-symbol-description": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/get-symbol-description/-/get-symbol-description-1.0.0.tgz", - "integrity": "sha512-2EmdH1YvIQiZpltCNgkuiUnyukzxM/R6NDJX31Ke3BG1Nq5b0S2PhX59UKi9vZpPDQVdqn+1IcaAwnzTT5vCjw==", - "dependencies": { - "call-bind": "^1.0.2", - "get-intrinsic": "^1.1.1" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/getpass": { - "version": "0.1.7", - "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", - "integrity": "sha512-0fzj9JxOLfJ+XGLhR8ze3unN0KZCgZwiSSDz168VERjK8Wl8kVSdcu2kspd4s4wtAa1y/qrVRiAA0WclVsu0ng==", - "optional": true, - "dependencies": { - "assert-plus": "^1.0.0" - } - }, - "node_modules/glob": { - "version": "7.2.3", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", - "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", - "dependencies": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.1.1", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - }, - "engines": { - "node": "*" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/glob-parent": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz", - "integrity": "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==", - "dependencies": { - "is-glob": "^4.0.3" - }, - "engines": { - "node": ">=10.13.0" - } - }, - "node_modules/glob-to-regexp": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/glob-to-regexp/-/glob-to-regexp-0.4.1.tgz", - "integrity": "sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw==" - }, - "node_modules/global-modules": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/global-modules/-/global-modules-2.0.0.tgz", - "integrity": "sha512-NGbfmJBp9x8IxyJSd1P+otYK8vonoJactOogrVfFRIAEY1ukil8RSKDz2Yo7wh1oihl51l/r6W4epkeKJHqL8A==", - "dependencies": { - "global-prefix": "^3.0.0" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/global-prefix": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/global-prefix/-/global-prefix-3.0.0.tgz", - "integrity": "sha512-awConJSVCHVGND6x3tmMaKcQvwXLhjdkmomy2W+Goaui8YPgYgXJZewhg3fWC+DlfqqQuWg8AwqjGTD2nAPVWg==", - "dependencies": { - "ini": "^1.3.5", - "kind-of": "^6.0.2", - "which": "^1.3.1" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/global-prefix/node_modules/which": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", - "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", - "dependencies": { - "isexe": "^2.0.0" - }, - "bin": { - "which": "bin/which" - } - }, - "node_modules/globals": { - "version": "11.12.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", - "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", - "engines": { - "node": ">=4" - } - }, - "node_modules/globalthis": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/globalthis/-/globalthis-1.0.3.tgz", - "integrity": "sha512-sFdI5LyBiNTHjRd7cGPWapiHWMOXKyuBNX/cWJ3NfzrZQVa8GI/8cofCl74AOVqq9W5kNmguTIzJ/1s2gyI9wA==", - "dependencies": { - "define-properties": "^1.1.3" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/globby": { - "version": "11.1.0", - "resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz", - "integrity": "sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==", - "dependencies": { - "array-union": "^2.1.0", - "dir-glob": "^3.0.1", - "fast-glob": "^3.2.9", - "ignore": "^5.2.0", - "merge2": "^1.4.1", - "slash": "^3.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/google-protobuf": { - "version": "3.21.2", - "resolved": "https://registry.npmjs.org/google-protobuf/-/google-protobuf-3.21.2.tgz", - "integrity": "sha512-3MSOYFO5U9mPGikIYCzK0SaThypfGgS6bHqrUGXG3DPHCrb+txNqeEcns1W0lkGfk0rCyNXm7xB9rMxnCiZOoA==" - }, - "node_modules/gopd": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.0.1.tgz", - "integrity": "sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==", - "dependencies": { - "get-intrinsic": "^1.1.3" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/graceful-fs": { - "version": "4.2.11", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", - "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==" - }, - "node_modules/grapheme-splitter": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/grapheme-splitter/-/grapheme-splitter-1.0.4.tgz", - "integrity": "sha512-bzh50DW9kTPM00T8y4o8vQg89Di9oLJVLW/KaOGIXJWP/iqCN6WKYkbNOF04vFLJhwcpYUh9ydh/+5vpOqV4YQ==" - }, - "node_modules/graphemer": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/graphemer/-/graphemer-1.4.0.tgz", - "integrity": "sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==" - }, - "node_modules/gzip-size": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/gzip-size/-/gzip-size-6.0.0.tgz", - "integrity": "sha512-ax7ZYomf6jqPTQ4+XCpUGyXKHk5WweS+e05MBO4/y3WJ5RkmPXNKvX+bx1behVILVwr6JSQvZAku021CHPXG3Q==", - "dependencies": { - "duplexer": "^0.1.2" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/handle-thing": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/handle-thing/-/handle-thing-2.0.1.tgz", - "integrity": "sha512-9Qn4yBxelxoh2Ow62nP+Ka/kMnOXRi8BXnRaUwezLNhqelnN49xKz4F/dPP8OYLxLxq6JDtZb2i9XznUQbNPTg==" - }, - "node_modules/har-schema": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz", - "integrity": "sha512-Oqluz6zhGX8cyRaTQlFMPw80bSJVG2x/cFb8ZPhUILGgHka9SsokCCOQgpveePerqidZOrT14ipqfJb7ILcW5Q==", - "optional": true, - "engines": { - "node": ">=4" - } - }, - "node_modules/har-validator": { - "version": "5.1.5", - "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.1.5.tgz", - "integrity": "sha512-nmT2T0lljbxdQZfspsno9hgrG3Uir6Ks5afism62poxqBM6sDnMEuPmzTq8XN0OEwqKLLdh1jQI3qyE66Nzb3w==", - "deprecated": "this library is no longer supported", - "optional": true, - "dependencies": { - "ajv": "^6.12.3", - "har-schema": "^2.0.0" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/harmony-reflect": { - "version": "1.6.2", - "resolved": "https://registry.npmjs.org/harmony-reflect/-/harmony-reflect-1.6.2.tgz", - "integrity": "sha512-HIp/n38R9kQjDEziXyDTuW3vvoxxyxjxFzXLrBr18uB47GnSt+G9D29fqrpM5ZkspMcPICud3XsBJQ4Y2URg8g==" - }, - "node_modules/has": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", - "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", - "dependencies": { - "function-bind": "^1.1.1" - }, - "engines": { - "node": ">= 0.4.0" - } - }, - "node_modules/has-ansi": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", - "integrity": "sha512-C8vBJ8DwUCx19vhm7urhTuUsr4/IyP6l4VzNQDv+ryHQObW3TTTp9yB68WpYgRe2bbaGuZ/se74IqFeVnMnLZg==", - "dependencies": { - "ansi-regex": "^2.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/has-ansi/node_modules/ansi-regex": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", - "integrity": "sha512-TIGnTpdo+E3+pCyAluZvtED5p5wCqLdezCyhPZzKPcxvFplEt4i+W7OONCKgeZFT3+y5NZZfOOS/Bdcanm1MYA==", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/has-bigints": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/has-bigints/-/has-bigints-1.0.2.tgz", - "integrity": "sha512-tSvCKtBr9lkF0Ex0aQiP9N+OpV4zi2r/Nee5VkRDbaqv35RLYMzbwQfFSZZH0kR+Rd6302UJZ2p/bJCEoR3VoQ==", - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/has-flag": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", - "engines": { - "node": ">=4" - } - }, - "node_modules/has-property-descriptors": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.0.tgz", - "integrity": "sha512-62DVLZGoiEBDHQyqG4w9xCuZ7eJEwNmJRWw2VY84Oedb7WFcA27fiEVe8oUQx9hAUJ4ekurquucTGwsyO1XGdQ==", - "dependencies": { - "get-intrinsic": "^1.1.1" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/has-proto": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/has-proto/-/has-proto-1.0.1.tgz", - "integrity": "sha512-7qE+iP+O+bgF9clE5+UoBFzE65mlBiVj3tKCrlNQ0Ogwm0BjpT/gK4SlLYDMybDh5I3TCTKnPPa0oMG7JDYrhg==", - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/has-symbols": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz", - "integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==", - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/has-tostringtag": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.0.tgz", - "integrity": "sha512-kFjcSNhnlGV1kyoGk7OXKSawH5JOb/LzUc5w9B02hOTO0dfFRjbHQKvg1d6cf3HbeUmtU9VbbV3qzZ2Teh97WQ==", - "dependencies": { - "has-symbols": "^1.0.2" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/has-unicode": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/has-unicode/-/has-unicode-2.0.1.tgz", - "integrity": "sha512-8Rf9Y83NBReMnx0gFzA8JImQACstCYWUplepDa9xprwwtmgEZUF0h/i5xSA625zB/I37EtrswSST6OXxwaaIJQ==" - }, - "node_modules/he": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", - "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", - "bin": { - "he": "bin/he" - } - }, - "node_modules/hoist-non-react-statics": { - "version": "3.3.2", - "resolved": "https://registry.npmjs.org/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz", - "integrity": "sha512-/gGivxi8JPKWNm/W0jSmzcMPpfpPLc3dY/6GxhX2hQ9iGj3aDfklV4ET7NjKpSinLpJ5vafa9iiGIEZg10SfBw==", - "dependencies": { - "react-is": "^16.7.0" - } - }, - "node_modules/hoist-non-react-statics/node_modules/react-is": { - "version": "16.13.1", - "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", - "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==" - }, - "node_modules/hoopy": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/hoopy/-/hoopy-0.1.4.tgz", - "integrity": "sha512-HRcs+2mr52W0K+x8RzcLzuPPmVIKMSv97RGHy0Ea9y/mpcaK+xTrjICA04KAHi4GRzxliNqNJEFYWHghy3rSfQ==", - "engines": { - "node": ">= 6.0.0" - } - }, - "node_modules/hpack.js": { - "version": "2.1.6", - "resolved": "https://registry.npmjs.org/hpack.js/-/hpack.js-2.1.6.tgz", - "integrity": "sha512-zJxVehUdMGIKsRaNt7apO2Gqp0BdqW5yaiGHXXmbpvxgBYVZnAql+BJb4RO5ad2MgpbZKn5G6nMnegrH1FcNYQ==", - "dependencies": { - "inherits": "^2.0.1", - "obuf": "^1.0.0", - "readable-stream": "^2.0.1", - "wbuf": "^1.1.0" - } - }, - "node_modules/hpack.js/node_modules/isarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==" - }, - "node_modules/hpack.js/node_modules/readable-stream": { - "version": "2.3.8", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.8.tgz", - "integrity": "sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==", - "dependencies": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" - } - }, - "node_modules/hpack.js/node_modules/safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" - }, - "node_modules/hpack.js/node_modules/string_decoder": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "dependencies": { - "safe-buffer": "~5.1.0" - } - }, - "node_modules/html-encoding-sniffer": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-2.0.1.tgz", - "integrity": "sha512-D5JbOMBIR/TVZkubHT+OyT2705QvogUW4IBn6nHd756OwieSF9aDYFj4dv6HHEVGYbHaLETa3WggZYWWMyy3ZQ==", - "dependencies": { - "whatwg-encoding": "^1.0.5" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/html-entities": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/html-entities/-/html-entities-2.3.3.tgz", - "integrity": "sha512-DV5Ln36z34NNTDgnz0EWGBLZENelNAtkiFA4kyNOG2tDI6Mz1uSWiq1wAKdyjnJwyDiDO7Fa2SO1CTxPXL8VxA==" - }, - "node_modules/html-escaper": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-2.0.2.tgz", - "integrity": "sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==" - }, - "node_modules/html-minifier-terser": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/html-minifier-terser/-/html-minifier-terser-6.1.0.tgz", - "integrity": "sha512-YXxSlJBZTP7RS3tWnQw74ooKa6L9b9i9QYXY21eUEvhZ3u9XLfv6OnFsQq6RxkhHygsaUMvYsZRV5rU/OVNZxw==", - "dependencies": { - "camel-case": "^4.1.2", - "clean-css": "^5.2.2", - "commander": "^8.3.0", - "he": "^1.2.0", - "param-case": "^3.0.4", - "relateurl": "^0.2.7", - "terser": "^5.10.0" - }, - "bin": { - "html-minifier-terser": "cli.js" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/html-webpack-plugin": { - "version": "5.5.1", - "resolved": "https://registry.npmjs.org/html-webpack-plugin/-/html-webpack-plugin-5.5.1.tgz", - "integrity": "sha512-cTUzZ1+NqjGEKjmVgZKLMdiFg3m9MdRXkZW2OEe69WYVi5ONLMmlnSZdXzGGMOq0C8jGDrL6EWyEDDUioHO/pA==", - "dependencies": { - "@types/html-minifier-terser": "^6.0.0", - "html-minifier-terser": "^6.0.2", - "lodash": "^4.17.21", - "pretty-error": "^4.0.0", - "tapable": "^2.0.0" - }, - "engines": { - "node": ">=10.13.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/html-webpack-plugin" - }, - "peerDependencies": { - "webpack": "^5.20.0" - } - }, - "node_modules/htmlparser2": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-6.1.0.tgz", - "integrity": "sha512-gyyPk6rgonLFEDGoeRgQNaEUvdJ4ktTmmUh/h2t7s+M8oPpIPxgNACWa+6ESR57kXstwqPiCut0V8NRpcwgU7A==", - "funding": [ - "https://github.com/fb55/htmlparser2?sponsor=1", - { - "type": "github", - "url": "https://github.com/sponsors/fb55" - } - ], - "dependencies": { - "domelementtype": "^2.0.1", - "domhandler": "^4.0.0", - "domutils": "^2.5.2", - "entities": "^2.0.0" - } - }, - "node_modules/http-deceiver": { - "version": "1.2.7", - "resolved": "https://registry.npmjs.org/http-deceiver/-/http-deceiver-1.2.7.tgz", - "integrity": "sha512-LmpOGxTfbpgtGVxJrj5k7asXHCgNZp5nLfp+hWc8QQRqtb7fUy6kRY3BO1h9ddF6yIPYUARgxGOwB42DnxIaNw==" - }, - "node_modules/http-errors": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz", - "integrity": "sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ==", - "dependencies": { - "depd": "2.0.0", - "inherits": "2.0.4", - "setprototypeof": "1.2.0", - "statuses": "2.0.1", - "toidentifier": "1.0.1" - }, - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/http-parser-js": { - "version": "0.5.8", - "resolved": "https://registry.npmjs.org/http-parser-js/-/http-parser-js-0.5.8.tgz", - "integrity": "sha512-SGeBX54F94Wgu5RH3X5jsDtf4eHyRogWX1XGT3b4HuW3tQPM4AaBzoUji/4AAJNXCEOWZ5O0DgZmJw1947gD5Q==" - }, - "node_modules/http-proxy": { - "version": "1.18.1", - "resolved": "https://registry.npmjs.org/http-proxy/-/http-proxy-1.18.1.tgz", - "integrity": "sha512-7mz/721AbnJwIVbnaSv1Cz3Am0ZLT/UBwkC92VlxhXv/k/BBQfM2fXElQNC27BVGr0uwUpplYPQM9LnaBMR5NQ==", - "dependencies": { - "eventemitter3": "^4.0.0", - "follow-redirects": "^1.0.0", - "requires-port": "^1.0.0" - }, - "engines": { - "node": ">=8.0.0" - } - }, - "node_modules/http-proxy-agent": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-4.0.1.tgz", - "integrity": "sha512-k0zdNgqWTGA6aeIRVpvfVob4fL52dTfaehylg0Y4UvSySvOq/Y+BOyPrgpUrA7HylqvU8vIZGsRuXmspskV0Tg==", - "dependencies": { - "@tootallnate/once": "1", - "agent-base": "6", - "debug": "4" - }, - "engines": { - "node": ">= 6" - } - }, - "node_modules/http-proxy-middleware": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/http-proxy-middleware/-/http-proxy-middleware-2.0.6.tgz", - "integrity": "sha512-ya/UeJ6HVBYxrgYotAZo1KvPWlgB48kUJLDePFeneHsVujFaW5WNj2NgWCAE//B1Dl02BIfYlpNgBy8Kf8Rjmw==", - "dependencies": { - "@types/http-proxy": "^1.17.8", - "http-proxy": "^1.18.1", - "is-glob": "^4.0.1", - "is-plain-obj": "^3.0.0", - "micromatch": "^4.0.2" - }, - "engines": { - "node": ">=12.0.0" - }, - "peerDependencies": { - "@types/express": "^4.17.13" - }, - "peerDependenciesMeta": { - "@types/express": { - "optional": true - } - } - }, - "node_modules/http-signature": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", - "integrity": "sha512-CAbnr6Rz4CYQkLYUtSNXxQPUH2gK8f3iWexVlsnMeD+GjlsQ0Xsy1cOX+mN3dtxYomRy21CiOzU8Uhw6OwncEQ==", - "optional": true, - "dependencies": { - "assert-plus": "^1.0.0", - "jsprim": "^1.2.2", - "sshpk": "^1.7.0" - }, - "engines": { - "node": ">=0.8", - "npm": ">=1.3.7" - } - }, - "node_modules/https": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/https/-/https-1.0.0.tgz", - "integrity": "sha512-4EC57ddXrkaF0x83Oj8sM6SLQHAWXw90Skqu2M4AEWENZ3F02dFJE/GARA8igO79tcgYqGrD7ae4f5L3um2lgg==" - }, - "node_modules/https-browserify": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/https-browserify/-/https-browserify-1.0.0.tgz", - "integrity": "sha512-J+FkSdyD+0mA0N+81tMotaRMfSL9SGi+xpD3T6YApKsc3bGSXJlfXri3VyFOeYkfLRQisDk1W+jIFFKBeUBbBg==" - }, - "node_modules/https-proxy-agent": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz", - "integrity": "sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==", - "dependencies": { - "agent-base": "6", - "debug": "4" - }, - "engines": { - "node": ">= 6" - } - }, - "node_modules/human-signals": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-2.1.0.tgz", - "integrity": "sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==", - "engines": { - "node": ">=10.17.0" - } - }, - "node_modules/ice-cap": { - "version": "0.0.4", - "resolved": "https://registry.npmjs.org/ice-cap/-/ice-cap-0.0.4.tgz", - "integrity": "sha512-39ZblYEKlqj7LHgLkUcVk7zcJp772lOVQAUhN6QyY88w8/4bn5SgDeU2020yzHosf+uKPuCFK1UQ36gyBNiraw==", - "dependencies": { - "cheerio": "0.20.0", - "color-logger": "0.0.3" - } - }, - "node_modules/ice-cap/node_modules/abab": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/abab/-/abab-1.0.4.tgz", - "integrity": "sha512-I+Wi+qiE2kUXyrRhNsWv6XsjUTBJjSoVSctKNBfLG5zG/Xe7Rjbxf13+vqYHNTwHaFU+FtSlVxOCTiMEVtPv0A==", - "deprecated": "Use your platform's native atob() and btoa() methods instead", - "optional": true - }, - "node_modules/ice-cap/node_modules/acorn": { - "version": "2.7.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-2.7.0.tgz", - "integrity": "sha512-pXK8ez/pVjqFdAgBkF1YPVRacuLQ9EXBKaKWaeh58WNfMkCmZhOZzu+NtKSPD5PHmCCHheQ5cD29qM1K4QTxIg==", - "optional": true, - "bin": { - "acorn": "bin/acorn" - }, - "engines": { - "node": ">=0.4.0" - } - }, - "node_modules/ice-cap/node_modules/acorn-globals": { - "version": "1.0.9", - "resolved": "https://registry.npmjs.org/acorn-globals/-/acorn-globals-1.0.9.tgz", - "integrity": "sha512-j3/4pkfih8W4NK22gxVSXcEonTpAHOHh0hu5BoZrKcOsW/4oBPxTi4Yk3SAj+FhC1f3+bRTkXdm4019gw1vg9g==", - "optional": true, - "dependencies": { - "acorn": "^2.1.0" - } - }, - "node_modules/ice-cap/node_modules/cheerio": { - "version": "0.20.0", - "resolved": "https://registry.npmjs.org/cheerio/-/cheerio-0.20.0.tgz", - "integrity": "sha512-e5jCTzJc28MWkrLLjB1mu3ks7rDQJLC5y/JMdQkOAEX/dmJk62rC6Xae1yvOO4xyCxLpzcth3jIZ7nypmjQ/0w==", - "dependencies": { - "css-select": "~1.2.0", - "dom-serializer": "~0.1.0", - "entities": "~1.1.1", - "htmlparser2": "~3.8.1", - "lodash": "^4.1.0" - }, - "engines": { - "node": ">= 0.6" - }, - "optionalDependencies": { - "jsdom": "^7.0.2" - } - }, - "node_modules/ice-cap/node_modules/color-logger": { - "version": "0.0.3", - "resolved": "https://registry.npmjs.org/color-logger/-/color-logger-0.0.3.tgz", - "integrity": "sha512-s4oriek7VTdSmDbS5chJhNui3uUzlk/mU39V4HnOUv0KphRXpIj73lq4wY5f8l/x+WtHUhiV+FCzsrNO1w6REA==" - }, - "node_modules/ice-cap/node_modules/css-select": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/css-select/-/css-select-1.2.0.tgz", - "integrity": "sha512-dUQOBoqdR7QwV90WysXPLXG5LO7nhYBgiWVfxF80DKPF8zx1t/pUd2FYy73emg3zrjtM6dzmYgbHKfV2rxiHQA==", - "dependencies": { - "boolbase": "~1.0.0", - "css-what": "2.1", - "domutils": "1.5.1", - "nth-check": "~1.0.1" - } - }, - "node_modules/ice-cap/node_modules/css-what": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/css-what/-/css-what-2.1.3.tgz", - "integrity": "sha512-a+EPoD+uZiNfh+5fxw2nO9QwFa6nJe2Or35fGY6Ipw1R3R4AGz1d1TEZrCegvw2YTmZ0jXirGYlzxxpYSHwpEg==", - "engines": { - "node": "*" - } - }, - "node_modules/ice-cap/node_modules/cssom": { - "version": "0.3.8", - "resolved": "https://registry.npmjs.org/cssom/-/cssom-0.3.8.tgz", - "integrity": "sha512-b0tGHbfegbhPJpxpiBPU2sCkigAqtM9O121le6bbOlgyV+NyGyCmVfJ6QW9eRjz8CpNfWEOYBIMIGRYkLwsIYg==", - "optional": true - }, - "node_modules/ice-cap/node_modules/cssstyle": { - "version": "0.2.37", - "resolved": "https://registry.npmjs.org/cssstyle/-/cssstyle-0.2.37.tgz", - "integrity": "sha512-FUpKc+1FNBsHUr9IsfSGCovr8VuGOiiuzlgCyppKBjJi2jYTOFLN3oiiNRMIvYqbFzF38mqKj4BgcevzU5/kIA==", - "optional": true, - "dependencies": { - "cssom": "0.3.x" - } - }, - "node_modules/ice-cap/node_modules/dom-serializer": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-0.1.1.tgz", - "integrity": "sha512-l0IU0pPzLWSHBcieZbpOKgkIn3ts3vAh7ZuFyXNwJxJXk/c4Gwj9xaTJwIDVQCXawWD0qb3IzMGH5rglQaO0XA==", - "dependencies": { - "domelementtype": "^1.3.0", - "entities": "^1.1.1" - } - }, - "node_modules/ice-cap/node_modules/domelementtype": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-1.3.1.tgz", - "integrity": "sha512-BSKB+TSpMpFI/HOxCNr1O8aMOTZ8hT3pM3GQ0w/mWRmkhEDSFJkkyzz4XQsBV44BChwGkrDfMyjVD0eA2aFV3w==" - }, - "node_modules/ice-cap/node_modules/domhandler": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-2.3.0.tgz", - "integrity": "sha512-q9bUwjfp7Eif8jWxxxPSykdRZAb6GkguBGSgvvCrhI9wB71W2K/Kvv4E61CF/mcCfnVJDeDWx/Vb/uAqbDj6UQ==", - "dependencies": { - "domelementtype": "1" - } - }, - "node_modules/ice-cap/node_modules/domutils": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/domutils/-/domutils-1.5.1.tgz", - "integrity": "sha512-gSu5Oi/I+3wDENBsOWBiRK1eoGxcywYSqg3rR960/+EfY0CF4EX1VPkgHOZ3WiS/Jg2DtliF6BhWcHlfpYUcGw==", - "dependencies": { - "dom-serializer": "0", - "domelementtype": "1" - } - }, - "node_modules/ice-cap/node_modules/entities": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/entities/-/entities-1.1.2.tgz", - "integrity": "sha512-f2LZMYl1Fzu7YSBKg+RoROelpOaNrcGmE9AZubeDfrCEia483oW4MI4VyFd5VNHIgQ/7qm1I0wUHK1eJnn2y2w==" - }, - "node_modules/ice-cap/node_modules/escodegen": { - "version": "1.14.3", - "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-1.14.3.tgz", - "integrity": "sha512-qFcX0XJkdg+PB3xjZZG/wKSuT1PnQWx57+TVSjIMmILd2yC/6ByYElPwJnslDsuWuSAp4AwJGumarAAmJch5Kw==", - "optional": true, - "dependencies": { - "esprima": "^4.0.1", - "estraverse": "^4.2.0", - "esutils": "^2.0.2", - "optionator": "^0.8.1" - }, - "bin": { - "escodegen": "bin/escodegen.js", - "esgenerate": "bin/esgenerate.js" - }, - "engines": { - "node": ">=4.0" - }, - "optionalDependencies": { - "source-map": "~0.6.1" - } - }, - "node_modules/ice-cap/node_modules/estraverse": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", - "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", - "optional": true, - "engines": { - "node": ">=4.0" - } - }, - "node_modules/ice-cap/node_modules/htmlparser2": { - "version": "3.8.3", - "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-3.8.3.tgz", - "integrity": "sha512-hBxEg3CYXe+rPIua8ETe7tmG3XDn9B0edOE/e9wH2nLczxzgdu0m0aNHY+5wFZiviLWLdANPJTssa92dMcXQ5Q==", - "dependencies": { - "domelementtype": "1", - "domhandler": "2.3", - "domutils": "1.5", - "entities": "1.0", - "readable-stream": "1.1" - } - }, - "node_modules/ice-cap/node_modules/htmlparser2/node_modules/entities": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/entities/-/entities-1.0.0.tgz", - "integrity": "sha512-LbLqfXgJMmy81t+7c14mnulFHJ170cM6E+0vMXR9k/ZiZwgX8i5pNgjTCX3SO4VeUsFLV+8InixoretwU+MjBQ==" - }, - "node_modules/ice-cap/node_modules/isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha512-D2S+3GLxWH+uhrNEcoh/fnmYeP8E8/zHl644d/jdA0g2uyXvy3sb0qxotE+ne0LtccHknQzWwZEzhak7oJ0COQ==" - }, - "node_modules/ice-cap/node_modules/jsdom": { - "version": "7.2.2", - "resolved": "https://registry.npmjs.org/jsdom/-/jsdom-7.2.2.tgz", - "integrity": "sha512-kYeYuos/pYp0V/V8VAoGnUc0va0UZjTjwCsldBFZNBrOi9Q5kUXrvsw6W5/lQllB7hKXBARC4HRk1Sfk4dPFtA==", - "optional": true, - "dependencies": { - "abab": "^1.0.0", - "acorn": "^2.4.0", - "acorn-globals": "^1.0.4", - "cssom": ">= 0.3.0 < 0.4.0", - "cssstyle": ">= 0.2.29 < 0.3.0", - "escodegen": "^1.6.1", - "nwmatcher": ">= 1.3.7 < 2.0.0", - "parse5": "^1.5.1", - "request": "^2.55.0", - "sax": "^1.1.4", - "symbol-tree": ">= 3.1.0 < 4.0.0", - "tough-cookie": "^2.2.0", - "webidl-conversions": "^2.0.0", - "whatwg-url-compat": "~0.6.5", - "xml-name-validator": ">= 2.0.1 < 3.0.0" - } - }, - "node_modules/ice-cap/node_modules/levn": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", - "integrity": "sha512-0OO4y2iOHix2W6ujICbKIaEQXvFQHue65vUG3pb5EUomzPI90z9hsA1VsO/dbIIpC53J8gxM9Q4Oho0jrCM/yA==", - "optional": true, - "dependencies": { - "prelude-ls": "~1.1.2", - "type-check": "~0.3.2" - }, - "engines": { - "node": ">= 0.8.0" - } - }, - "node_modules/ice-cap/node_modules/nth-check": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/nth-check/-/nth-check-1.0.2.tgz", - "integrity": "sha512-WeBOdju8SnzPN5vTUJYxYUxLeXpCaVP5i5e0LF8fg7WORF2Wd7wFX/pk0tYZk7s8T+J7VLy0Da6J1+wCT0AtHg==", - "dependencies": { - "boolbase": "~1.0.0" - } - }, - "node_modules/ice-cap/node_modules/optionator": { - "version": "0.8.3", - "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.3.tgz", - "integrity": "sha512-+IW9pACdk3XWmmTXG8m3upGUJst5XRGzxMRjXzAuJ1XnIFNvfhjjIuYkDvysnPQ7qzqVzLt78BCruntqRhWQbA==", - "optional": true, - "dependencies": { - "deep-is": "~0.1.3", - "fast-levenshtein": "~2.0.6", - "levn": "~0.3.0", - "prelude-ls": "~1.1.2", - "type-check": "~0.3.2", - "word-wrap": "~1.2.3" - }, - "engines": { - "node": ">= 0.8.0" - } - }, - "node_modules/ice-cap/node_modules/parse5": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/parse5/-/parse5-1.5.1.tgz", - "integrity": "sha512-w2jx/0tJzvgKwZa58sj2vAYq/S/K1QJfIB3cWYea/Iu1scFPDQQ3IQiVZTHWtRBwAjv2Yd7S/xeZf3XqLDb3bA==", - "optional": true - }, - "node_modules/ice-cap/node_modules/prelude-ls": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", - "integrity": "sha512-ESF23V4SKG6lVSGZgYNpbsiaAkdab6ZgOxe52p7+Kid3W3u3bxR4Vfd/o21dmN7jSt0IwgZ4v5MUd26FEtXE9w==", - "optional": true, - "engines": { - "node": ">= 0.8.0" - } - }, - "node_modules/ice-cap/node_modules/readable-stream": { - "version": "1.1.14", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", - "integrity": "sha512-+MeVjFf4L44XUkhM1eYbD8fyEsxcV81pqMSR5gblfcLCHfZvbrqy4/qYHE+/R5HoBUT11WV5O08Cr1n3YXkWVQ==", - "dependencies": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.1", - "isarray": "0.0.1", - "string_decoder": "~0.10.x" - } - }, - "node_modules/ice-cap/node_modules/source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "optional": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/ice-cap/node_modules/string_decoder": { - "version": "0.10.31", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "integrity": "sha512-ev2QzSzWPYmy9GuqfIVildA4OdcGLeFZQrq5ys6RtiuF+RQQiZWr8TZNyAcuVXyQRYfEO+MsoB/1BuQVhOJuoQ==" - }, - "node_modules/ice-cap/node_modules/tough-cookie": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.5.0.tgz", - "integrity": "sha512-nlLsUzgm1kfLXSXfRZMc1KLAugd4hqJHDTvc2hDIwS3mZAfMEuMbc03SujMF+GEcpaX/qboeycw6iO8JwVv2+g==", - "optional": true, - "dependencies": { - "psl": "^1.1.28", - "punycode": "^2.1.1" - }, - "engines": { - "node": ">=0.8" - } - }, - "node_modules/ice-cap/node_modules/type-check": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", - "integrity": "sha512-ZCmOJdvOWDBYJlzAoFkC+Q0+bUyEOS1ltgp1MGU03fqHG+dbi9tBFU2Rd9QKiDZFAYrhPh2JUf7rZRIuHRKtOg==", - "optional": true, - "dependencies": { - "prelude-ls": "~1.1.2" - }, - "engines": { - "node": ">= 0.8.0" - } - }, - "node_modules/ice-cap/node_modules/webidl-conversions": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-2.0.1.tgz", - "integrity": "sha512-OZ7I/f0sM+T28T2/OXinNGfmvjm3KKptdyQy8NPRZyLfYBn+9vt72Bfr+uQaE9OvWyxJjQ5kHFygH2wOTUb76g==", - "optional": true - }, - "node_modules/ice-cap/node_modules/xml-name-validator": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-2.0.1.tgz", - "integrity": "sha512-jRKe/iQYMyVJpzPH+3HL97Lgu5HrCfii+qSo+TfjKHtOnvbnvdVfMYrn9Q34YV81M2e5sviJlI6Ko9y+nByzvA==", - "optional": true - }, - "node_modules/iconv-lite": { - "version": "0.6.3", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", - "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", - "dependencies": { - "safer-buffer": ">= 2.1.2 < 3.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/icss-utils": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/icss-utils/-/icss-utils-5.1.0.tgz", - "integrity": "sha512-soFhflCVWLfRNOPU3iv5Z9VUdT44xFRbzjLsEzSr5AQmgqPMTHdU3PMT1Cf1ssx8fLNJDA1juftYl+PUcv3MqA==", - "engines": { - "node": "^10 || ^12 || >= 14" - }, - "peerDependencies": { - "postcss": "^8.1.0" - } - }, - "node_modules/idb": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/idb/-/idb-7.1.1.tgz", - "integrity": "sha512-gchesWBzyvGHRO9W8tzUWFDycow5gwjvFKfyV9FF32Y7F50yZMp7mP+T2mJIWFx49zicqyC4uefHM17o6xKIVQ==" - }, - "node_modules/identity-obj-proxy": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/identity-obj-proxy/-/identity-obj-proxy-3.0.0.tgz", - "integrity": "sha512-00n6YnVHKrinT9t0d9+5yZC6UBNJANpYEQvL2LlX6Ab9lnmxzIRcEmTPuyGScvl1+jKuCICX1Z0Ab1pPKKdikA==", - "dependencies": { - "harmony-reflect": "^1.4.6" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/ignore": { - "version": "5.2.4", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.4.tgz", - "integrity": "sha512-MAb38BcSbH0eHNBxn7ql2NH/kX33OkB3lZ1BNdh7ENeRChHTYsTvWrMubiIAMNS2llXEEgZ1MUOBtXChP3kaFQ==", - "engines": { - "node": ">= 4" - } - }, - "node_modules/ignore-walk": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/ignore-walk/-/ignore-walk-3.0.4.tgz", - "integrity": "sha512-PY6Ii8o1jMRA1z4F2hRkH/xN59ox43DavKvD3oDpfurRlOJyAHpifIwpbdv1n4jt4ov0jSpw3kQ4GhJnpBL6WQ==", - "dependencies": { - "minimatch": "^3.0.4" - } - }, - "node_modules/immediate": { - "version": "3.0.6", - "resolved": "https://registry.npmjs.org/immediate/-/immediate-3.0.6.tgz", - "integrity": "sha512-XXOFtyqDjNDAQxVfYxuF7g9Il/IbWmmlQg2MYKOH8ExIT1qg6xc4zyS3HaEEATgs1btfzxq15ciUiY7gjSXRGQ==" - }, - "node_modules/immer": { - "version": "9.0.21", - "resolved": "https://registry.npmjs.org/immer/-/immer-9.0.21.tgz", - "integrity": "sha512-bc4NBHqOqSfRW7POMkHd51LvClaeMXpm8dx0e8oE2GORbq5aRK7Bxl4FyzVLdGtLmvLKL7BTDBG5ACQm4HWjTA==", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/immer" - } - }, - "node_modules/import-fresh": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz", - "integrity": "sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==", - "dependencies": { - "parent-module": "^1.0.0", - "resolve-from": "^4.0.0" - }, - "engines": { - "node": ">=6" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/import-fresh/node_modules/resolve-from": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", - "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", - "engines": { - "node": ">=4" - } - }, - "node_modules/import-local": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/import-local/-/import-local-3.1.0.tgz", - "integrity": "sha512-ASB07uLtnDs1o6EHjKpX34BKYDSqnFerfTOJL2HvMqF70LnxpjkzDB8J44oT9pu4AMPkQwf8jl6szgvNd2tRIg==", - "dependencies": { - "pkg-dir": "^4.2.0", - "resolve-cwd": "^3.0.0" - }, - "bin": { - "import-local-fixture": "fixtures/cli.js" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/imurmurhash": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", - "integrity": "sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==", - "engines": { - "node": ">=0.8.19" - } - }, - "node_modules/indent-string": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-4.0.0.tgz", - "integrity": "sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg==", - "engines": { - "node": ">=8" - } - }, - "node_modules/inflight": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", - "dependencies": { - "once": "^1.3.0", - "wrappy": "1" - } - }, - "node_modules/inherits": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" - }, - "node_modules/ini": { - "version": "1.3.8", - "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.8.tgz", - "integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==" - }, - "node_modules/internal-slot": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/internal-slot/-/internal-slot-1.0.5.tgz", - "integrity": "sha512-Y+R5hJrzs52QCG2laLn4udYVnxsfny9CpOhNhUvk/SSSVyF6T27FzRbF0sroPidSu3X8oEAkOn2K804mjpt6UQ==", - "dependencies": { - "get-intrinsic": "^1.2.0", - "has": "^1.0.3", - "side-channel": "^1.0.4" - }, - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/invariant": { - "version": "2.2.4", - "resolved": "https://registry.npmjs.org/invariant/-/invariant-2.2.4.tgz", - "integrity": "sha512-phJfQVBuaJM5raOpJjSfkiD6BpbCE4Ns//LaXl6wGYtUBY83nWS6Rf9tXm2e8VaK60JEjYldbPif/A2B1C2gNA==", - "dependencies": { - "loose-envify": "^1.0.0" - } - }, - "node_modules/ipaddr.js": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-2.0.1.tgz", - "integrity": "sha512-1qTgH9NG+IIJ4yfKs2e6Pp1bZg8wbDbKHT21HrLIeYBTRLgMYKnMTPAuI3Lcs61nfx5h1xlXnbJtH1kX5/d/ng==", - "engines": { - "node": ">= 10" - } - }, - "node_modules/is-arguments": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/is-arguments/-/is-arguments-1.1.1.tgz", - "integrity": "sha512-8Q7EARjzEnKpt/PCD7e1cgUS0a6X8u5tdSiMqXhojOdoV9TsMsiO+9VLC5vAmO8N7/GmXn7yjR8qnA6bVAEzfA==", - "dependencies": { - "call-bind": "^1.0.2", - "has-tostringtag": "^1.0.0" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/is-array-buffer": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/is-array-buffer/-/is-array-buffer-3.0.2.tgz", - "integrity": "sha512-y+FyyR/w8vfIRq4eQcM1EYgSTnmHXPqaF+IgzgraytCFq5Xh8lllDVmAZolPJiZttZLeFSINPYMaEJ7/vWUa1w==", - "dependencies": { - "call-bind": "^1.0.2", - "get-intrinsic": "^1.2.0", - "is-typed-array": "^1.1.10" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/is-arrayish": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", - "integrity": "sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg==" - }, - "node_modules/is-bigint": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/is-bigint/-/is-bigint-1.0.4.tgz", - "integrity": "sha512-zB9CruMamjym81i2JZ3UMn54PKGsQzsJeo6xvN3HJJ4CAsQNB6iRutp2To77OfCNuoxspsIhzaPoO1zyCEhFOg==", - "dependencies": { - "has-bigints": "^1.0.1" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/is-binary-path": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", - "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", - "dependencies": { - "binary-extensions": "^2.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/is-boolean-object": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/is-boolean-object/-/is-boolean-object-1.1.2.tgz", - "integrity": "sha512-gDYaKHJmnj4aWxyj6YHyXVpdQawtVLHU5cb+eztPGczf6cjuTdwve5ZIEfgXqH4e57An1D1AKf8CZ3kYrQRqYA==", - "dependencies": { - "call-bind": "^1.0.2", - "has-tostringtag": "^1.0.0" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/is-callable": { - "version": "1.2.7", - "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.7.tgz", - "integrity": "sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA==", - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/is-core-module": { - "version": "2.12.1", - "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.12.1.tgz", - "integrity": "sha512-Q4ZuBAe2FUsKtyQJoQHlvP8OvBERxO3jEmy1I7hcRXcJBGGHFh/aJBswbXuS9sgrDH2QUO8ilkwNPHvHMd8clg==", - "dependencies": { - "has": "^1.0.3" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/is-date-object": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.5.tgz", - "integrity": "sha512-9YQaSxsAiSwcvS33MBk3wTCVnWK+HhF8VZR2jRxehM16QcVOdHqPn4VPHmRK4lSr38n9JriurInLcP90xsYNfQ==", - "dependencies": { - "has-tostringtag": "^1.0.0" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/is-docker": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/is-docker/-/is-docker-2.2.1.tgz", - "integrity": "sha512-F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ==", - "bin": { - "is-docker": "cli.js" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/is-extendable": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", - "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", - "peer": true, - "dependencies": { - "is-plain-object": "^2.0.4" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/is-extglob": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", - "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/is-finite": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/is-finite/-/is-finite-1.1.0.tgz", - "integrity": "sha512-cdyMtqX/BOqqNBBiKlIVkytNHm49MtMlYyn1zxzvJKWmFMlGzm+ry5BBfYyeY9YmNKbRSo/o7OX9w9ale0wg3w==", - "engines": { - "node": ">=0.10.0" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/is-fullwidth-code-point": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", - "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", - "engines": { - "node": ">=8" - } - }, - "node_modules/is-generator-fn": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/is-generator-fn/-/is-generator-fn-2.1.0.tgz", - "integrity": "sha512-cTIB4yPYL/Grw0EaSzASzg6bBy9gqCofvWN8okThAYIxKJZC+udlRAmGbM0XLeniEJSs8uEgHPGuHSe1XsOLSQ==", - "engines": { - "node": ">=6" - } - }, - "node_modules/is-generator-function": { - "version": "1.0.10", - "resolved": "https://registry.npmjs.org/is-generator-function/-/is-generator-function-1.0.10.tgz", - "integrity": "sha512-jsEjy9l3yiXEQ+PsXdmBwEPcOxaXWLspKdplFUVI9vq1iZgIekeC0L167qeu86czQaxed3q/Uzuw0swL0irL8A==", - "dependencies": { - "has-tostringtag": "^1.0.0" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/is-glob": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", - "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", - "dependencies": { - "is-extglob": "^2.1.1" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/is-map": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/is-map/-/is-map-2.0.2.tgz", - "integrity": "sha512-cOZFQQozTha1f4MxLFzlgKYPTyj26picdZTx82hbc/Xf4K/tZOOXSCkMvU4pKioRXGDLJRn0GM7Upe7kR721yg==", - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/is-module": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-module/-/is-module-1.0.0.tgz", - "integrity": "sha512-51ypPSPCoTEIN9dy5Oy+h4pShgJmPCygKfyRCISBI+JoWT/2oJvK8QPxmwv7b/p239jXrm9M1mlQbyKJ5A152g==" - }, - "node_modules/is-negative-zero": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/is-negative-zero/-/is-negative-zero-2.0.2.tgz", - "integrity": "sha512-dqJvarLawXsFbNDeJW7zAz8ItJ9cd28YufuuFzh0G8pNHjJMnY08Dv7sYX2uF5UpQOwieAeOExEYAWWfu7ZZUA==", - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/is-number": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", - "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", - "engines": { - "node": ">=0.12.0" - } - }, - "node_modules/is-number-object": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/is-number-object/-/is-number-object-1.0.7.tgz", - "integrity": "sha512-k1U0IRzLMo7ZlYIfzRu23Oh6MiIFasgpb9X76eqfFZAqwH44UI4KTBvBYIZ1dSL9ZzChTB9ShHfLkR4pdW5krQ==", - "dependencies": { - "has-tostringtag": "^1.0.0" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/is-obj": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-obj/-/is-obj-1.0.1.tgz", - "integrity": "sha512-l4RyHgRqGN4Y3+9JHVrNqO+tN0rV5My76uW5/nuO4K1b6vw5G8d/cmFjP9tRfEsdhZNt0IFdZuK/c2Vr4Nb+Qg==", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/is-path-inside": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz", - "integrity": "sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==", - "engines": { - "node": ">=8" - } - }, - "node_modules/is-plain-obj": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-3.0.0.tgz", - "integrity": "sha512-gwsOE28k+23GP1B6vFl1oVh/WOzmawBrKwo5Ev6wMKzPkaXaCDIQKzLnvsA42DRlbVTWorkgTKIviAKCWkfUwA==", - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/is-plain-object": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz", - "integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==", - "peer": true, - "dependencies": { - "isobject": "^3.0.1" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/is-potential-custom-element-name": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-potential-custom-element-name/-/is-potential-custom-element-name-1.0.1.tgz", - "integrity": "sha512-bCYeRA2rVibKZd+s2625gGnGF/t7DSqDs4dP7CrLA1m7jKWz6pps0LpYLJN8Q64HtmPKJ1hrN3nzPNKFEKOUiQ==" - }, - "node_modules/is-regex": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.1.4.tgz", - "integrity": "sha512-kvRdxDsxZjhzUX07ZnLydzS1TU/TJlTUHHY4YLL87e37oUA49DfkLqgy+VjFocowy29cKvcSiu+kIv728jTTVg==", - "dependencies": { - "call-bind": "^1.0.2", - "has-tostringtag": "^1.0.0" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/is-regexp": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-regexp/-/is-regexp-1.0.0.tgz", - "integrity": "sha512-7zjFAPO4/gwyQAAgRRmqeEeyIICSdmCqa3tsVHMdBzaXXRiqopZL4Cyghg/XulGWrtABTpbnYYzzIRffLkP4oA==", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/is-root": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/is-root/-/is-root-2.1.0.tgz", - "integrity": "sha512-AGOriNp96vNBd3HtU+RzFEc75FfR5ymiYv8E553I71SCeXBiMsVDUtdio1OEFvrPyLIQ9tVR5RxXIFe5PUFjMg==", - "engines": { - "node": ">=6" - } - }, - "node_modules/is-set": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/is-set/-/is-set-2.0.2.tgz", - "integrity": "sha512-+2cnTEZeY5z/iXGbLhPrOAaK/Mau5k5eXq9j14CpRTftq0pAJu2MwVRSZhyZWBzx3o6X795Lz6Bpb6R0GKf37g==", - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/is-shared-array-buffer": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-shared-array-buffer/-/is-shared-array-buffer-1.0.2.tgz", - "integrity": "sha512-sqN2UDu1/0y6uvXyStCOzyhAjCSlHceFoMKJW8W9EU9cvic/QdsZ0kEU93HEy3IUEFZIiH/3w+AH/UQbPHNdhA==", - "dependencies": { - "call-bind": "^1.0.2" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/is-stream": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz", - "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==", - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/is-string": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/is-string/-/is-string-1.0.7.tgz", - "integrity": "sha512-tE2UXzivje6ofPW7l23cjDOMa09gb7xlAqG6jG5ej6uPV32TlWP3NKPigtaGeHNu9fohccRYvIiZMfOOnOYUtg==", - "dependencies": { - "has-tostringtag": "^1.0.0" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/is-symbol": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.4.tgz", - "integrity": "sha512-C/CPBqKWnvdcxqIARxyOh4v1UUEOCHpgDa0WYgpKDFMszcrPcffg5uhwSgPCLD2WWxmq6isisz87tzT01tuGhg==", - "dependencies": { - "has-symbols": "^1.0.2" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/is-typed-array": { - "version": "1.1.10", - "resolved": "https://registry.npmjs.org/is-typed-array/-/is-typed-array-1.1.10.tgz", - "integrity": "sha512-PJqgEHiWZvMpaFZ3uTc8kHPM4+4ADTlDniuQL7cU/UDA0Ql7F70yGfHph3cLNe+c9toaigv+DFzTJKhc2CtO6A==", - "dependencies": { - "available-typed-arrays": "^1.0.5", - "call-bind": "^1.0.2", - "for-each": "^0.3.3", - "gopd": "^1.0.1", - "has-tostringtag": "^1.0.0" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/is-typedarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", - "integrity": "sha512-cyA56iCMHAh5CdzjJIa4aohJyeO1YbwLi3Jc35MmRU6poroFjIGZzUzupGiRPOjgHg9TLu43xbpwXk523fMxKA==" - }, - "node_modules/is-weakmap": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/is-weakmap/-/is-weakmap-2.0.1.tgz", - "integrity": "sha512-NSBR4kH5oVj1Uwvv970ruUkCV7O1mzgVFO4/rev2cLRda9Tm9HrL70ZPut4rOHgY0FNrUu9BCbXA2sdQ+x0chA==", - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/is-weakref": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-weakref/-/is-weakref-1.0.2.tgz", - "integrity": "sha512-qctsuLZmIQ0+vSSMfoVvyFe2+GSEvnmZ2ezTup1SBse9+twCCeial6EEi3Nc2KFcf6+qz2FBPnjXsk8xhKSaPQ==", - "dependencies": { - "call-bind": "^1.0.2" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/is-weakset": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/is-weakset/-/is-weakset-2.0.2.tgz", - "integrity": "sha512-t2yVvttHkQktwnNNmBQ98AhENLdPUTDTE21uPqAQ0ARwQfGeQKRVS0NNurH7bTf7RrvcVn1OOge45CnBeHCSmg==", - "dependencies": { - "call-bind": "^1.0.2", - "get-intrinsic": "^1.1.1" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/is-wsl": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-2.2.0.tgz", - "integrity": "sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==", - "dependencies": { - "is-docker": "^2.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/isarray": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.5.tgz", - "integrity": "sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw==" - }, - "node_modules/isexe": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==" - }, - "node_modules/isobject": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", - "integrity": "sha512-WhB9zCku7EGTj/HQQRz5aUQEUeoQZH2bWcltRErOpymJ4boYE6wL9Tbr23krRPSZ+C5zqNSrSw+Cc7sZZ4b7vg==", - "peer": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/isstream": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", - "integrity": "sha512-Yljz7ffyPbrLpLngrMtZ7NduUgVvi6wG9RJ9IUcyCd59YQ911PBJphODUcbOVbqYfxe1wuYf/LJ8PauMRwsM/g==", - "optional": true - }, - "node_modules/istanbul-lib-coverage": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-3.2.0.tgz", - "integrity": "sha512-eOeJ5BHCmHYvQK7xt9GkdHuzuCGS1Y6g9Gvnx3Ym33fz/HpLRYxiS0wHNr+m/MBC8B647Xt608vCDEvhl9c6Mw==", - "engines": { - "node": ">=8" - } - }, - "node_modules/istanbul-lib-instrument": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-5.2.1.tgz", - "integrity": "sha512-pzqtp31nLv/XFOzXGuvhCb8qhjmTVo5vjVk19XE4CRlSWz0KoeJ3bw9XsA7nOp9YBf4qHjwBxkDzKcME/J29Yg==", - "dependencies": { - "@babel/core": "^7.12.3", - "@babel/parser": "^7.14.7", - "@istanbuljs/schema": "^0.1.2", - "istanbul-lib-coverage": "^3.2.0", - "semver": "^6.3.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/istanbul-lib-instrument/node_modules/semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", - "bin": { - "semver": "bin/semver.js" - } - }, - "node_modules/istanbul-lib-report": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/istanbul-lib-report/-/istanbul-lib-report-3.0.0.tgz", - "integrity": "sha512-wcdi+uAKzfiGT2abPpKZ0hSU1rGQjUQnLvtY5MpQ7QCTahD3VODhcu4wcfY1YtkGaDD5yuydOLINXsfbus9ROw==", - "dependencies": { - "istanbul-lib-coverage": "^3.0.0", - "make-dir": "^3.0.0", - "supports-color": "^7.1.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/istanbul-lib-report/node_modules/has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "engines": { - "node": ">=8" - } - }, - "node_modules/istanbul-lib-report/node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/istanbul-lib-source-maps": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/istanbul-lib-source-maps/-/istanbul-lib-source-maps-4.0.1.tgz", - "integrity": "sha512-n3s8EwkdFIJCG3BPKBYvskgXGoy88ARzvegkitk60NxRdwltLOTaH7CUiMRXvwYorl0Q712iEjcWB+fK/MrWVw==", - "dependencies": { - "debug": "^4.1.1", - "istanbul-lib-coverage": "^3.0.0", - "source-map": "^0.6.1" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/istanbul-lib-source-maps/node_modules/source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/istanbul-reports": { - "version": "3.1.5", - "resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-3.1.5.tgz", - "integrity": "sha512-nUsEMa9pBt/NOHqbcbeJEgqIlY/K7rVWUX6Lql2orY5e9roQOthbR3vtY4zzf2orPELg80fnxxk9zUyPlgwD1w==", - "dependencies": { - "html-escaper": "^2.0.0", - "istanbul-lib-report": "^3.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/jake": { - "version": "10.8.6", - "resolved": "https://registry.npmjs.org/jake/-/jake-10.8.6.tgz", - "integrity": "sha512-G43Ub9IYEFfu72sua6rzooi8V8Gz2lkfk48rW20vEWCGizeaEPlKB1Kh8JIA84yQbiAEfqlPmSpGgCKKxH3rDA==", - "dependencies": { - "async": "^3.2.3", - "chalk": "^4.0.2", - "filelist": "^1.0.4", - "minimatch": "^3.1.2" - }, - "bin": { - "jake": "bin/cli.js" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/jake/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/jake/node_modules/chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dependencies": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" - } - }, - "node_modules/jake/node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/jake/node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" - }, - "node_modules/jake/node_modules/has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "engines": { - "node": ">=8" - } - }, - "node_modules/jake/node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/jest": { - "version": "27.5.1", - "resolved": "https://registry.npmjs.org/jest/-/jest-27.5.1.tgz", - "integrity": "sha512-Yn0mADZB89zTtjkPJEXwrac3LHudkQMR+Paqa8uxJHCBr9agxztUifWCyiYrjhMPBoUVBjyny0I7XH6ozDr7QQ==", - "dependencies": { - "@jest/core": "^27.5.1", - "import-local": "^3.0.2", - "jest-cli": "^27.5.1" - }, - "bin": { - "jest": "bin/jest.js" - }, - "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" - }, - "peerDependencies": { - "node-notifier": "^8.0.1 || ^9.0.0 || ^10.0.0" - }, - "peerDependenciesMeta": { - "node-notifier": { - "optional": true - } - } - }, - "node_modules/jest-changed-files": { - "version": "27.5.1", - "resolved": "https://registry.npmjs.org/jest-changed-files/-/jest-changed-files-27.5.1.tgz", - "integrity": "sha512-buBLMiByfWGCoMsLLzGUUSpAmIAGnbR2KJoMN10ziLhOLvP4e0SlypHnAel8iqQXTrcbmfEY9sSqae5sgUsTvw==", - "dependencies": { - "@jest/types": "^27.5.1", - "execa": "^5.0.0", - "throat": "^6.0.1" - }, - "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" - } - }, - "node_modules/jest-circus": { - "version": "27.5.1", - "resolved": "https://registry.npmjs.org/jest-circus/-/jest-circus-27.5.1.tgz", - "integrity": "sha512-D95R7x5UtlMA5iBYsOHFFbMD/GVA4R/Kdq15f7xYWUfWHBto9NYRsOvnSauTgdF+ogCpJ4tyKOXhUifxS65gdw==", - "dependencies": { - "@jest/environment": "^27.5.1", - "@jest/test-result": "^27.5.1", - "@jest/types": "^27.5.1", - "@types/node": "*", - "chalk": "^4.0.0", - "co": "^4.6.0", - "dedent": "^0.7.0", - "expect": "^27.5.1", - "is-generator-fn": "^2.0.0", - "jest-each": "^27.5.1", - "jest-matcher-utils": "^27.5.1", - "jest-message-util": "^27.5.1", - "jest-runtime": "^27.5.1", - "jest-snapshot": "^27.5.1", - "jest-util": "^27.5.1", - "pretty-format": "^27.5.1", - "slash": "^3.0.0", - "stack-utils": "^2.0.3", - "throat": "^6.0.1" - }, - "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" - } - }, - "node_modules/jest-circus/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/jest-circus/node_modules/chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dependencies": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" - } - }, - "node_modules/jest-circus/node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/jest-circus/node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" - }, - "node_modules/jest-circus/node_modules/has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "engines": { - "node": ">=8" - } - }, - "node_modules/jest-circus/node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/jest-cli": { - "version": "27.5.1", - "resolved": "https://registry.npmjs.org/jest-cli/-/jest-cli-27.5.1.tgz", - "integrity": "sha512-Hc6HOOwYq4/74/c62dEE3r5elx8wjYqxY0r0G/nFrLDPMFRu6RA/u8qINOIkvhxG7mMQ5EJsOGfRpI8L6eFUVw==", - "dependencies": { - "@jest/core": "^27.5.1", - "@jest/test-result": "^27.5.1", - "@jest/types": "^27.5.1", - "chalk": "^4.0.0", - "exit": "^0.1.2", - "graceful-fs": "^4.2.9", - "import-local": "^3.0.2", - "jest-config": "^27.5.1", - "jest-util": "^27.5.1", - "jest-validate": "^27.5.1", - "prompts": "^2.0.1", - "yargs": "^16.2.0" - }, - "bin": { - "jest": "bin/jest.js" - }, - "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" - }, - "peerDependencies": { - "node-notifier": "^8.0.1 || ^9.0.0 || ^10.0.0" - }, - "peerDependenciesMeta": { - "node-notifier": { - "optional": true - } - } - }, - "node_modules/jest-cli/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/jest-cli/node_modules/chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dependencies": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" - } - }, - "node_modules/jest-cli/node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/jest-cli/node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" - }, - "node_modules/jest-cli/node_modules/has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "engines": { - "node": ">=8" - } - }, - "node_modules/jest-cli/node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/jest-config": { - "version": "27.5.1", - "resolved": "https://registry.npmjs.org/jest-config/-/jest-config-27.5.1.tgz", - "integrity": "sha512-5sAsjm6tGdsVbW9ahcChPAFCk4IlkQUknH5AvKjuLTSlcO/wCZKyFdn7Rg0EkC+OGgWODEy2hDpWB1PgzH0JNA==", - "dependencies": { - "@babel/core": "^7.8.0", - "@jest/test-sequencer": "^27.5.1", - "@jest/types": "^27.5.1", - "babel-jest": "^27.5.1", - "chalk": "^4.0.0", - "ci-info": "^3.2.0", - "deepmerge": "^4.2.2", - "glob": "^7.1.1", - "graceful-fs": "^4.2.9", - "jest-circus": "^27.5.1", - "jest-environment-jsdom": "^27.5.1", - "jest-environment-node": "^27.5.1", - "jest-get-type": "^27.5.1", - "jest-jasmine2": "^27.5.1", - "jest-regex-util": "^27.5.1", - "jest-resolve": "^27.5.1", - "jest-runner": "^27.5.1", - "jest-util": "^27.5.1", - "jest-validate": "^27.5.1", - "micromatch": "^4.0.4", - "parse-json": "^5.2.0", - "pretty-format": "^27.5.1", - "slash": "^3.0.0", - "strip-json-comments": "^3.1.1" - }, - "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" - }, - "peerDependencies": { - "ts-node": ">=9.0.0" - }, - "peerDependenciesMeta": { - "ts-node": { - "optional": true - } - } - }, - "node_modules/jest-config/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/jest-config/node_modules/chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dependencies": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" - } - }, - "node_modules/jest-config/node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/jest-config/node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" - }, - "node_modules/jest-config/node_modules/has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "engines": { - "node": ">=8" - } - }, - "node_modules/jest-config/node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/jest-diff": { - "version": "27.5.1", - "resolved": "https://registry.npmjs.org/jest-diff/-/jest-diff-27.5.1.tgz", - "integrity": "sha512-m0NvkX55LDt9T4mctTEgnZk3fmEg3NRYutvMPWM/0iPnkFj2wIeF45O1718cMSOFO1vINkqmxqD8vE37uTEbqw==", - "dependencies": { - "chalk": "^4.0.0", - "diff-sequences": "^27.5.1", - "jest-get-type": "^27.5.1", - "pretty-format": "^27.5.1" - }, - "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" - } - }, - "node_modules/jest-diff/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/jest-diff/node_modules/chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dependencies": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" - } - }, - "node_modules/jest-diff/node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/jest-diff/node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" - }, - "node_modules/jest-diff/node_modules/has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "engines": { - "node": ">=8" - } - }, - "node_modules/jest-diff/node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/jest-docblock": { - "version": "27.5.1", - "resolved": "https://registry.npmjs.org/jest-docblock/-/jest-docblock-27.5.1.tgz", - "integrity": "sha512-rl7hlABeTsRYxKiUfpHrQrG4e2obOiTQWfMEH3PxPjOtdsfLQO4ReWSZaQ7DETm4xu07rl4q/h4zcKXyU0/OzQ==", - "dependencies": { - "detect-newline": "^3.0.0" - }, - "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" - } - }, - "node_modules/jest-each": { - "version": "27.5.1", - "resolved": "https://registry.npmjs.org/jest-each/-/jest-each-27.5.1.tgz", - "integrity": "sha512-1Ff6p+FbhT/bXQnEouYy00bkNSY7OUpfIcmdl8vZ31A1UUaurOLPA8a8BbJOF2RDUElwJhmeaV7LnagI+5UwNQ==", - "dependencies": { - "@jest/types": "^27.5.1", - "chalk": "^4.0.0", - "jest-get-type": "^27.5.1", - "jest-util": "^27.5.1", - "pretty-format": "^27.5.1" - }, - "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" - } - }, - "node_modules/jest-each/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/jest-each/node_modules/chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dependencies": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" - } - }, - "node_modules/jest-each/node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/jest-each/node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" - }, - "node_modules/jest-each/node_modules/has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "engines": { - "node": ">=8" - } - }, - "node_modules/jest-each/node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/jest-environment-jsdom": { - "version": "27.5.1", - "resolved": "https://registry.npmjs.org/jest-environment-jsdom/-/jest-environment-jsdom-27.5.1.tgz", - "integrity": "sha512-TFBvkTC1Hnnnrka/fUb56atfDtJ9VMZ94JkjTbggl1PEpwrYtUBKMezB3inLmWqQsXYLcMwNoDQwoBTAvFfsfw==", - "dependencies": { - "@jest/environment": "^27.5.1", - "@jest/fake-timers": "^27.5.1", - "@jest/types": "^27.5.1", - "@types/node": "*", - "jest-mock": "^27.5.1", - "jest-util": "^27.5.1", - "jsdom": "^16.6.0" - }, - "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" - } - }, - "node_modules/jest-environment-node": { - "version": "27.5.1", - "resolved": "https://registry.npmjs.org/jest-environment-node/-/jest-environment-node-27.5.1.tgz", - "integrity": "sha512-Jt4ZUnxdOsTGwSRAfKEnE6BcwsSPNOijjwifq5sDFSA2kesnXTvNqKHYgM0hDq3549Uf/KzdXNYn4wMZJPlFLw==", - "dependencies": { - "@jest/environment": "^27.5.1", - "@jest/fake-timers": "^27.5.1", - "@jest/types": "^27.5.1", - "@types/node": "*", - "jest-mock": "^27.5.1", - "jest-util": "^27.5.1" - }, - "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" - } - }, - "node_modules/jest-get-type": { - "version": "27.5.1", - "resolved": "https://registry.npmjs.org/jest-get-type/-/jest-get-type-27.5.1.tgz", - "integrity": "sha512-2KY95ksYSaK7DMBWQn6dQz3kqAf3BB64y2udeG+hv4KfSOb9qwcYQstTJc1KCbsix+wLZWZYN8t7nwX3GOBLRw==", - "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" - } - }, - "node_modules/jest-haste-map": { - "version": "27.5.1", - "resolved": "https://registry.npmjs.org/jest-haste-map/-/jest-haste-map-27.5.1.tgz", - "integrity": "sha512-7GgkZ4Fw4NFbMSDSpZwXeBiIbx+t/46nJ2QitkOjvwPYyZmqttu2TDSimMHP1EkPOi4xUZAN1doE5Vd25H4Jng==", - "dependencies": { - "@jest/types": "^27.5.1", - "@types/graceful-fs": "^4.1.2", - "@types/node": "*", - "anymatch": "^3.0.3", - "fb-watchman": "^2.0.0", - "graceful-fs": "^4.2.9", - "jest-regex-util": "^27.5.1", - "jest-serializer": "^27.5.1", - "jest-util": "^27.5.1", - "jest-worker": "^27.5.1", - "micromatch": "^4.0.4", - "walker": "^1.0.7" - }, - "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" - }, - "optionalDependencies": { - "fsevents": "^2.3.2" - } - }, - "node_modules/jest-jasmine2": { - "version": "27.5.1", - "resolved": "https://registry.npmjs.org/jest-jasmine2/-/jest-jasmine2-27.5.1.tgz", - "integrity": "sha512-jtq7VVyG8SqAorDpApwiJJImd0V2wv1xzdheGHRGyuT7gZm6gG47QEskOlzsN1PG/6WNaCo5pmwMHDf3AkG2pQ==", - "dependencies": { - "@jest/environment": "^27.5.1", - "@jest/source-map": "^27.5.1", - "@jest/test-result": "^27.5.1", - "@jest/types": "^27.5.1", - "@types/node": "*", - "chalk": "^4.0.0", - "co": "^4.6.0", - "expect": "^27.5.1", - "is-generator-fn": "^2.0.0", - "jest-each": "^27.5.1", - "jest-matcher-utils": "^27.5.1", - "jest-message-util": "^27.5.1", - "jest-runtime": "^27.5.1", - "jest-snapshot": "^27.5.1", - "jest-util": "^27.5.1", - "pretty-format": "^27.5.1", - "throat": "^6.0.1" - }, - "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" - } - }, - "node_modules/jest-jasmine2/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/jest-jasmine2/node_modules/chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dependencies": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" - } - }, - "node_modules/jest-jasmine2/node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/jest-jasmine2/node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" - }, - "node_modules/jest-jasmine2/node_modules/has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "engines": { - "node": ">=8" - } - }, - "node_modules/jest-jasmine2/node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/jest-leak-detector": { - "version": "27.5.1", - "resolved": "https://registry.npmjs.org/jest-leak-detector/-/jest-leak-detector-27.5.1.tgz", - "integrity": "sha512-POXfWAMvfU6WMUXftV4HolnJfnPOGEu10fscNCA76KBpRRhcMN2c8d3iT2pxQS3HLbA+5X4sOUPzYO2NUyIlHQ==", - "dependencies": { - "jest-get-type": "^27.5.1", - "pretty-format": "^27.5.1" - }, - "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" - } - }, - "node_modules/jest-matcher-utils": { - "version": "27.5.1", - "resolved": "https://registry.npmjs.org/jest-matcher-utils/-/jest-matcher-utils-27.5.1.tgz", - "integrity": "sha512-z2uTx/T6LBaCoNWNFWwChLBKYxTMcGBRjAt+2SbP929/Fflb9aa5LGma654Rz8z9HLxsrUaYzxE9T/EFIL/PAw==", - "dependencies": { - "chalk": "^4.0.0", - "jest-diff": "^27.5.1", - "jest-get-type": "^27.5.1", - "pretty-format": "^27.5.1" - }, - "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" - } - }, - "node_modules/jest-matcher-utils/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/jest-matcher-utils/node_modules/chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dependencies": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" - } - }, - "node_modules/jest-matcher-utils/node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/jest-matcher-utils/node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" - }, - "node_modules/jest-matcher-utils/node_modules/has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "engines": { - "node": ">=8" - } - }, - "node_modules/jest-matcher-utils/node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/jest-message-util": { - "version": "27.5.1", - "resolved": "https://registry.npmjs.org/jest-message-util/-/jest-message-util-27.5.1.tgz", - "integrity": "sha512-rMyFe1+jnyAAf+NHwTclDz0eAaLkVDdKVHHBFWsBWHnnh5YeJMNWWsv7AbFYXfK3oTqvL7VTWkhNLu1jX24D+g==", - "dependencies": { - "@babel/code-frame": "^7.12.13", - "@jest/types": "^27.5.1", - "@types/stack-utils": "^2.0.0", - "chalk": "^4.0.0", - "graceful-fs": "^4.2.9", - "micromatch": "^4.0.4", - "pretty-format": "^27.5.1", - "slash": "^3.0.0", - "stack-utils": "^2.0.3" - }, - "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" - } - }, - "node_modules/jest-message-util/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/jest-message-util/node_modules/chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dependencies": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" - } - }, - "node_modules/jest-message-util/node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/jest-message-util/node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" - }, - "node_modules/jest-message-util/node_modules/has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "engines": { - "node": ">=8" - } - }, - "node_modules/jest-message-util/node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/jest-mock": { - "version": "27.5.1", - "resolved": "https://registry.npmjs.org/jest-mock/-/jest-mock-27.5.1.tgz", - "integrity": "sha512-K4jKbY1d4ENhbrG2zuPWaQBvDly+iZ2yAW+T1fATN78hc0sInwn7wZB8XtlNnvHug5RMwV897Xm4LqmPM4e2Og==", - "dependencies": { - "@jest/types": "^27.5.1", - "@types/node": "*" - }, - "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" - } - }, - "node_modules/jest-pnp-resolver": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/jest-pnp-resolver/-/jest-pnp-resolver-1.2.3.tgz", - "integrity": "sha512-+3NpwQEnRoIBtx4fyhblQDPgJI0H1IEIkX7ShLUjPGA7TtUTvI1oiKi3SR4oBR0hQhQR80l4WAe5RrXBwWMA8w==", - "engines": { - "node": ">=6" - }, - "peerDependencies": { - "jest-resolve": "*" - }, - "peerDependenciesMeta": { - "jest-resolve": { - "optional": true - } - } - }, - "node_modules/jest-regex-util": { - "version": "27.5.1", - "resolved": "https://registry.npmjs.org/jest-regex-util/-/jest-regex-util-27.5.1.tgz", - "integrity": "sha512-4bfKq2zie+x16okqDXjXn9ql2B0dScQu+vcwe4TvFVhkVyuWLqpZrZtXxLLWoXYgn0E87I6r6GRYHF7wFZBUvg==", - "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" - } - }, - "node_modules/jest-resolve": { - "version": "27.5.1", - "resolved": "https://registry.npmjs.org/jest-resolve/-/jest-resolve-27.5.1.tgz", - "integrity": "sha512-FFDy8/9E6CV83IMbDpcjOhumAQPDyETnU2KZ1O98DwTnz8AOBsW/Xv3GySr1mOZdItLR+zDZ7I/UdTFbgSOVCw==", - "dependencies": { - "@jest/types": "^27.5.1", - "chalk": "^4.0.0", - "graceful-fs": "^4.2.9", - "jest-haste-map": "^27.5.1", - "jest-pnp-resolver": "^1.2.2", - "jest-util": "^27.5.1", - "jest-validate": "^27.5.1", - "resolve": "^1.20.0", - "resolve.exports": "^1.1.0", - "slash": "^3.0.0" - }, - "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" - } - }, - "node_modules/jest-resolve-dependencies": { - "version": "27.5.1", - "resolved": "https://registry.npmjs.org/jest-resolve-dependencies/-/jest-resolve-dependencies-27.5.1.tgz", - "integrity": "sha512-QQOOdY4PE39iawDn5rzbIePNigfe5B9Z91GDD1ae/xNDlu9kaat8QQ5EKnNmVWPV54hUdxCVwwj6YMgR2O7IOg==", - "dependencies": { - "@jest/types": "^27.5.1", - "jest-regex-util": "^27.5.1", - "jest-snapshot": "^27.5.1" - }, - "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" - } - }, - "node_modules/jest-resolve/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/jest-resolve/node_modules/chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dependencies": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" - } - }, - "node_modules/jest-resolve/node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/jest-resolve/node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" - }, - "node_modules/jest-resolve/node_modules/has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "engines": { - "node": ">=8" - } - }, - "node_modules/jest-resolve/node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/jest-runner": { - "version": "27.5.1", - "resolved": "https://registry.npmjs.org/jest-runner/-/jest-runner-27.5.1.tgz", - "integrity": "sha512-g4NPsM4mFCOwFKXO4p/H/kWGdJp9V8kURY2lX8Me2drgXqG7rrZAx5kv+5H7wtt/cdFIjhqYx1HrlqWHaOvDaQ==", - "dependencies": { - "@jest/console": "^27.5.1", - "@jest/environment": "^27.5.1", - "@jest/test-result": "^27.5.1", - "@jest/transform": "^27.5.1", - "@jest/types": "^27.5.1", - "@types/node": "*", - "chalk": "^4.0.0", - "emittery": "^0.8.1", - "graceful-fs": "^4.2.9", - "jest-docblock": "^27.5.1", - "jest-environment-jsdom": "^27.5.1", - "jest-environment-node": "^27.5.1", - "jest-haste-map": "^27.5.1", - "jest-leak-detector": "^27.5.1", - "jest-message-util": "^27.5.1", - "jest-resolve": "^27.5.1", - "jest-runtime": "^27.5.1", - "jest-util": "^27.5.1", - "jest-worker": "^27.5.1", - "source-map-support": "^0.5.6", - "throat": "^6.0.1" - }, - "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" - } - }, - "node_modules/jest-runner/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/jest-runner/node_modules/chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dependencies": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" - } - }, - "node_modules/jest-runner/node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/jest-runner/node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" - }, - "node_modules/jest-runner/node_modules/has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "engines": { - "node": ">=8" - } - }, - "node_modules/jest-runner/node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/jest-runtime": { - "version": "27.5.1", - "resolved": "https://registry.npmjs.org/jest-runtime/-/jest-runtime-27.5.1.tgz", - "integrity": "sha512-o7gxw3Gf+H2IGt8fv0RiyE1+r83FJBRruoA+FXrlHw6xEyBsU8ugA6IPfTdVyA0w8HClpbK+DGJxH59UrNMx8A==", - "dependencies": { - "@jest/environment": "^27.5.1", - "@jest/fake-timers": "^27.5.1", - "@jest/globals": "^27.5.1", - "@jest/source-map": "^27.5.1", - "@jest/test-result": "^27.5.1", - "@jest/transform": "^27.5.1", - "@jest/types": "^27.5.1", - "chalk": "^4.0.0", - "cjs-module-lexer": "^1.0.0", - "collect-v8-coverage": "^1.0.0", - "execa": "^5.0.0", - "glob": "^7.1.3", - "graceful-fs": "^4.2.9", - "jest-haste-map": "^27.5.1", - "jest-message-util": "^27.5.1", - "jest-mock": "^27.5.1", - "jest-regex-util": "^27.5.1", - "jest-resolve": "^27.5.1", - "jest-snapshot": "^27.5.1", - "jest-util": "^27.5.1", - "slash": "^3.0.0", - "strip-bom": "^4.0.0" - }, - "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" - } - }, - "node_modules/jest-runtime/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/jest-runtime/node_modules/chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dependencies": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" - } - }, - "node_modules/jest-runtime/node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/jest-runtime/node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" - }, - "node_modules/jest-runtime/node_modules/has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "engines": { - "node": ">=8" - } - }, - "node_modules/jest-runtime/node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/jest-serializer": { - "version": "27.5.1", - "resolved": "https://registry.npmjs.org/jest-serializer/-/jest-serializer-27.5.1.tgz", - "integrity": "sha512-jZCyo6iIxO1aqUxpuBlwTDMkzOAJS4a3eYz3YzgxxVQFwLeSA7Jfq5cbqCY+JLvTDrWirgusI/0KwxKMgrdf7w==", - "dependencies": { - "@types/node": "*", - "graceful-fs": "^4.2.9" - }, - "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" - } - }, - "node_modules/jest-snapshot": { - "version": "27.5.1", - "resolved": "https://registry.npmjs.org/jest-snapshot/-/jest-snapshot-27.5.1.tgz", - "integrity": "sha512-yYykXI5a0I31xX67mgeLw1DZ0bJB+gpq5IpSuCAoyDi0+BhgU/RIrL+RTzDmkNTchvDFWKP8lp+w/42Z3us5sA==", - "dependencies": { - "@babel/core": "^7.7.2", - "@babel/generator": "^7.7.2", - "@babel/plugin-syntax-typescript": "^7.7.2", - "@babel/traverse": "^7.7.2", - "@babel/types": "^7.0.0", - "@jest/transform": "^27.5.1", - "@jest/types": "^27.5.1", - "@types/babel__traverse": "^7.0.4", - "@types/prettier": "^2.1.5", - "babel-preset-current-node-syntax": "^1.0.0", - "chalk": "^4.0.0", - "expect": "^27.5.1", - "graceful-fs": "^4.2.9", - "jest-diff": "^27.5.1", - "jest-get-type": "^27.5.1", - "jest-haste-map": "^27.5.1", - "jest-matcher-utils": "^27.5.1", - "jest-message-util": "^27.5.1", - "jest-util": "^27.5.1", - "natural-compare": "^1.4.0", - "pretty-format": "^27.5.1", - "semver": "^7.3.2" - }, - "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" - } - }, - "node_modules/jest-snapshot/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/jest-snapshot/node_modules/chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dependencies": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" - } - }, - "node_modules/jest-snapshot/node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/jest-snapshot/node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" - }, - "node_modules/jest-snapshot/node_modules/has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "engines": { - "node": ">=8" - } - }, - "node_modules/jest-snapshot/node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/jest-util": { - "version": "27.5.1", - "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-27.5.1.tgz", - "integrity": "sha512-Kv2o/8jNvX1MQ0KGtw480E/w4fBCDOnH6+6DmeKi6LZUIlKA5kwY0YNdlzaWTiVgxqAqik11QyxDOKk543aKXw==", - "dependencies": { - "@jest/types": "^27.5.1", - "@types/node": "*", - "chalk": "^4.0.0", - "ci-info": "^3.2.0", - "graceful-fs": "^4.2.9", - "picomatch": "^2.2.3" - }, - "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" - } - }, - "node_modules/jest-util/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/jest-util/node_modules/chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dependencies": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" - } - }, - "node_modules/jest-util/node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/jest-util/node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" - }, - "node_modules/jest-util/node_modules/has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "engines": { - "node": ">=8" - } - }, - "node_modules/jest-util/node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/jest-validate": { - "version": "27.5.1", - "resolved": "https://registry.npmjs.org/jest-validate/-/jest-validate-27.5.1.tgz", - "integrity": "sha512-thkNli0LYTmOI1tDB3FI1S1RTp/Bqyd9pTarJwL87OIBFuqEb5Apv5EaApEudYg4g86e3CT6kM0RowkhtEnCBQ==", - "dependencies": { - "@jest/types": "^27.5.1", - "camelcase": "^6.2.0", - "chalk": "^4.0.0", - "jest-get-type": "^27.5.1", - "leven": "^3.1.0", - "pretty-format": "^27.5.1" - }, - "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" - } - }, - "node_modules/jest-validate/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/jest-validate/node_modules/chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dependencies": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" - } - }, - "node_modules/jest-validate/node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/jest-validate/node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" - }, - "node_modules/jest-validate/node_modules/has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "engines": { - "node": ">=8" - } - }, - "node_modules/jest-validate/node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/jest-watch-typeahead": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/jest-watch-typeahead/-/jest-watch-typeahead-1.1.0.tgz", - "integrity": "sha512-Va5nLSJTN7YFtC2jd+7wsoe1pNe5K4ShLux/E5iHEwlB9AxaxmggY7to9KUqKojhaJw3aXqt5WAb4jGPOolpEw==", - "dependencies": { - "ansi-escapes": "^4.3.1", - "chalk": "^4.0.0", - "jest-regex-util": "^28.0.0", - "jest-watcher": "^28.0.0", - "slash": "^4.0.0", - "string-length": "^5.0.1", - "strip-ansi": "^7.0.1" - }, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "peerDependencies": { - "jest": "^27.0.0 || ^28.0.0" - } - }, - "node_modules/jest-watch-typeahead/node_modules/@jest/console": { - "version": "28.1.3", - "resolved": "https://registry.npmjs.org/@jest/console/-/console-28.1.3.tgz", - "integrity": "sha512-QPAkP5EwKdK/bxIr6C1I4Vs0rm2nHiANzj/Z5X2JQkrZo6IqvC4ldZ9K95tF0HdidhA8Bo6egxSzUFPYKcEXLw==", - "dependencies": { - "@jest/types": "^28.1.3", - "@types/node": "*", - "chalk": "^4.0.0", - "jest-message-util": "^28.1.3", - "jest-util": "^28.1.3", - "slash": "^3.0.0" - }, - "engines": { - "node": "^12.13.0 || ^14.15.0 || ^16.10.0 || >=17.0.0" - } - }, - "node_modules/jest-watch-typeahead/node_modules/@jest/console/node_modules/slash": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", - "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", - "engines": { - "node": ">=8" - } - }, - "node_modules/jest-watch-typeahead/node_modules/@jest/test-result": { - "version": "28.1.3", - "resolved": "https://registry.npmjs.org/@jest/test-result/-/test-result-28.1.3.tgz", - "integrity": "sha512-kZAkxnSE+FqE8YjW8gNuoVkkC9I7S1qmenl8sGcDOLropASP+BkcGKwhXoyqQuGOGeYY0y/ixjrd/iERpEXHNg==", - "dependencies": { - "@jest/console": "^28.1.3", - "@jest/types": "^28.1.3", - "@types/istanbul-lib-coverage": "^2.0.0", - "collect-v8-coverage": "^1.0.0" - }, - "engines": { - "node": "^12.13.0 || ^14.15.0 || ^16.10.0 || >=17.0.0" - } - }, - "node_modules/jest-watch-typeahead/node_modules/@jest/types": { - "version": "28.1.3", - "resolved": "https://registry.npmjs.org/@jest/types/-/types-28.1.3.tgz", - "integrity": "sha512-RyjiyMUZrKz/c+zlMFO1pm70DcIlST8AeWTkoUdZevew44wcNZQHsEVOiCVtgVnlFFD82FPaXycys58cf2muVQ==", - "dependencies": { - "@jest/schemas": "^28.1.3", - "@types/istanbul-lib-coverage": "^2.0.0", - "@types/istanbul-reports": "^3.0.0", - "@types/node": "*", - "@types/yargs": "^17.0.8", - "chalk": "^4.0.0" - }, - "engines": { - "node": "^12.13.0 || ^14.15.0 || ^16.10.0 || >=17.0.0" - } - }, - "node_modules/jest-watch-typeahead/node_modules/@types/yargs": { - "version": "17.0.24", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-17.0.24.tgz", - "integrity": "sha512-6i0aC7jV6QzQB8ne1joVZ0eSFIstHsCrobmOtghM11yGlH0j43FKL2UhWdELkyps0zuf7qVTUVCCR+tgSlyLLw==", - "dependencies": { - "@types/yargs-parser": "*" - } - }, - "node_modules/jest-watch-typeahead/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/jest-watch-typeahead/node_modules/chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dependencies": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" - } - }, - "node_modules/jest-watch-typeahead/node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/jest-watch-typeahead/node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" - }, - "node_modules/jest-watch-typeahead/node_modules/emittery": { - "version": "0.10.2", - "resolved": "https://registry.npmjs.org/emittery/-/emittery-0.10.2.tgz", - "integrity": "sha512-aITqOwnLanpHLNXZJENbOgjUBeHocD+xsSJmNrjovKBW5HbSpW3d1pEls7GFQPUWXiwG9+0P4GtHfEqC/4M0Iw==", - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sindresorhus/emittery?sponsor=1" - } - }, - "node_modules/jest-watch-typeahead/node_modules/has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "engines": { - "node": ">=8" - } - }, - "node_modules/jest-watch-typeahead/node_modules/jest-message-util": { - "version": "28.1.3", - "resolved": "https://registry.npmjs.org/jest-message-util/-/jest-message-util-28.1.3.tgz", - "integrity": "sha512-PFdn9Iewbt575zKPf1286Ht9EPoJmYT7P0kY+RibeYZ2XtOr53pDLEFoTWXbd1h4JiGiWpTBC84fc8xMXQMb7g==", - "dependencies": { - "@babel/code-frame": "^7.12.13", - "@jest/types": "^28.1.3", - "@types/stack-utils": "^2.0.0", - "chalk": "^4.0.0", - "graceful-fs": "^4.2.9", - "micromatch": "^4.0.4", - "pretty-format": "^28.1.3", - "slash": "^3.0.0", - "stack-utils": "^2.0.3" - }, - "engines": { - "node": "^12.13.0 || ^14.15.0 || ^16.10.0 || >=17.0.0" - } - }, - "node_modules/jest-watch-typeahead/node_modules/jest-message-util/node_modules/slash": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", - "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", - "engines": { - "node": ">=8" - } - }, - "node_modules/jest-watch-typeahead/node_modules/jest-regex-util": { - "version": "28.0.2", - "resolved": "https://registry.npmjs.org/jest-regex-util/-/jest-regex-util-28.0.2.tgz", - "integrity": "sha512-4s0IgyNIy0y9FK+cjoVYoxamT7Zeo7MhzqRGx7YDYmaQn1wucY9rotiGkBzzcMXTtjrCAP/f7f+E0F7+fxPNdw==", - "engines": { - "node": "^12.13.0 || ^14.15.0 || ^16.10.0 || >=17.0.0" - } - }, - "node_modules/jest-watch-typeahead/node_modules/jest-util": { - "version": "28.1.3", - "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-28.1.3.tgz", - "integrity": "sha512-XdqfpHwpcSRko/C35uLYFM2emRAltIIKZiJ9eAmhjsj0CqZMa0p1ib0R5fWIqGhn1a103DebTbpqIaP1qCQ6tQ==", - "dependencies": { - "@jest/types": "^28.1.3", - "@types/node": "*", - "chalk": "^4.0.0", - "ci-info": "^3.2.0", - "graceful-fs": "^4.2.9", - "picomatch": "^2.2.3" - }, - "engines": { - "node": "^12.13.0 || ^14.15.0 || ^16.10.0 || >=17.0.0" - } - }, - "node_modules/jest-watch-typeahead/node_modules/jest-watcher": { - "version": "28.1.3", - "resolved": "https://registry.npmjs.org/jest-watcher/-/jest-watcher-28.1.3.tgz", - "integrity": "sha512-t4qcqj9hze+jviFPUN3YAtAEeFnr/azITXQEMARf5cMwKY2SMBRnCQTXLixTl20OR6mLh9KLMrgVJgJISym+1g==", - "dependencies": { - "@jest/test-result": "^28.1.3", - "@jest/types": "^28.1.3", - "@types/node": "*", - "ansi-escapes": "^4.2.1", - "chalk": "^4.0.0", - "emittery": "^0.10.2", - "jest-util": "^28.1.3", - "string-length": "^4.0.1" - }, - "engines": { - "node": "^12.13.0 || ^14.15.0 || ^16.10.0 || >=17.0.0" - } - }, - "node_modules/jest-watch-typeahead/node_modules/jest-watcher/node_modules/string-length": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/string-length/-/string-length-4.0.2.tgz", - "integrity": "sha512-+l6rNN5fYHNhZZy41RXsYptCjA2Igmq4EG7kZAYFQI1E1VTXarr6ZPXBg6eq7Y6eK4FEhY6AJlyuFIb/v/S0VQ==", - "dependencies": { - "char-regex": "^1.0.2", - "strip-ansi": "^6.0.0" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/jest-watch-typeahead/node_modules/jest-watcher/node_modules/strip-ansi": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", - "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "dependencies": { - "ansi-regex": "^5.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/jest-watch-typeahead/node_modules/pretty-format": { - "version": "28.1.3", - "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-28.1.3.tgz", - "integrity": "sha512-8gFb/To0OmxHR9+ZTb14Df2vNxdGCX8g1xWGUTqUw5TiZvcQf5sHKObd5UcPyLLyowNwDAMTF3XWOG1B6mxl1Q==", - "dependencies": { - "@jest/schemas": "^28.1.3", - "ansi-regex": "^5.0.1", - "ansi-styles": "^5.0.0", - "react-is": "^18.0.0" - }, - "engines": { - "node": "^12.13.0 || ^14.15.0 || ^16.10.0 || >=17.0.0" - } - }, - "node_modules/jest-watch-typeahead/node_modules/pretty-format/node_modules/ansi-styles": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-5.2.0.tgz", - "integrity": "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==", - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/jest-watch-typeahead/node_modules/react-is": { - "version": "18.2.0", - "resolved": "https://registry.npmjs.org/react-is/-/react-is-18.2.0.tgz", - "integrity": "sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==" - }, - "node_modules/jest-watch-typeahead/node_modules/slash": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/slash/-/slash-4.0.0.tgz", - "integrity": "sha512-3dOsAHXXUkQTpOYcoAxLIorMTp4gIQr5IW3iVb7A7lFIp0VHhnynm9izx6TssdrIcVIESAlVjtnO2K8bg+Coew==", - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/jest-watch-typeahead/node_modules/string-length": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/string-length/-/string-length-5.0.1.tgz", - "integrity": "sha512-9Ep08KAMUn0OadnVaBuRdE2l615CQ508kr0XMadjClfYpdCyvrbFp6Taebo8yyxokQ4viUd/xPPUA4FGgUa0ow==", - "dependencies": { - "char-regex": "^2.0.0", - "strip-ansi": "^7.0.1" - }, - "engines": { - "node": ">=12.20" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/jest-watch-typeahead/node_modules/string-length/node_modules/char-regex": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/char-regex/-/char-regex-2.0.1.tgz", - "integrity": "sha512-oSvEeo6ZUD7NepqAat3RqoucZ5SeqLJgOvVIwkafu6IP3V0pO38s/ypdVUmDDK6qIIHNlYHJAKX9E7R7HoKElw==", - "engines": { - "node": ">=12.20" - } - }, - "node_modules/jest-watch-typeahead/node_modules/strip-ansi": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.0.1.tgz", - "integrity": "sha512-cXNxvT8dFNRVfhVME3JAe98mkXDYN2O1l7jmcwMnOslDeESg1rF/OZMtK0nRAhiari1unG5cD4jG3rapUAkLbw==", - "dependencies": { - "ansi-regex": "^6.0.1" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/strip-ansi?sponsor=1" - } - }, - "node_modules/jest-watch-typeahead/node_modules/strip-ansi/node_modules/ansi-regex": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.0.1.tgz", - "integrity": "sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==", - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/ansi-regex?sponsor=1" - } - }, - "node_modules/jest-watch-typeahead/node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/jest-watcher": { - "version": "27.5.1", - "resolved": "https://registry.npmjs.org/jest-watcher/-/jest-watcher-27.5.1.tgz", - "integrity": "sha512-z676SuD6Z8o8qbmEGhoEUFOM1+jfEiL3DXHK/xgEiG2EyNYfFG60jluWcupY6dATjfEsKQuibReS1djInQnoVw==", - "dependencies": { - "@jest/test-result": "^27.5.1", - "@jest/types": "^27.5.1", - "@types/node": "*", - "ansi-escapes": "^4.2.1", - "chalk": "^4.0.0", - "jest-util": "^27.5.1", - "string-length": "^4.0.1" - }, - "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" - } - }, - "node_modules/jest-watcher/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/jest-watcher/node_modules/chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dependencies": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" - } - }, - "node_modules/jest-watcher/node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/jest-watcher/node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" - }, - "node_modules/jest-watcher/node_modules/has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "engines": { - "node": ">=8" - } - }, - "node_modules/jest-watcher/node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/jest-worker": { - "version": "27.5.1", - "resolved": "https://registry.npmjs.org/jest-worker/-/jest-worker-27.5.1.tgz", - "integrity": "sha512-7vuh85V5cdDofPyxn58nrPjBktZo0u9x1g8WtjQol+jZDaE+fhN+cIvTj11GndBnMnyfrUOG1sZQxCdjKh+DKg==", - "dependencies": { - "@types/node": "*", - "merge-stream": "^2.0.0", - "supports-color": "^8.0.0" - }, - "engines": { - "node": ">= 10.13.0" - } - }, - "node_modules/jest-worker/node_modules/has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "engines": { - "node": ">=8" - } - }, - "node_modules/jest-worker/node_modules/supports-color": { - "version": "8.1.1", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", - "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/supports-color?sponsor=1" - } - }, - "node_modules/jiti": { - "version": "1.18.2", - "resolved": "https://registry.npmjs.org/jiti/-/jiti-1.18.2.tgz", - "integrity": "sha512-QAdOptna2NYiSSpv0O/BwoHBSmz4YhpzJHyi+fnMRTXFjp7B8i/YG5Z8IfusxB1ufjcD2Sre1F3R+nX3fvy7gg==", - "bin": { - "jiti": "bin/jiti.js" - } - }, - "node_modules/js-tokens": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", - "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==" - }, - "node_modules/js-yaml": { - "version": "3.14.1", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", - "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", - "dependencies": { - "argparse": "^1.0.7", - "esprima": "^4.0.0" - }, - "bin": { - "js-yaml": "bin/js-yaml.js" - } - }, - "node_modules/jsbn": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", - "integrity": "sha512-UVU9dibq2JcFWxQPA6KCqj5O42VOmAY3zQUfEKxU0KpTGXwNoCjkX1e13eHNvw/xPynt6pU0rZ1htjWTNTSXsg==", - "optional": true - }, - "node_modules/jsdom": { - "version": "16.7.0", - "resolved": "https://registry.npmjs.org/jsdom/-/jsdom-16.7.0.tgz", - "integrity": "sha512-u9Smc2G1USStM+s/x1ru5Sxrl6mPYCbByG1U/hUmqaVsm4tbNyS7CicOSRyuGQYZhTu0h84qkZZQ/I+dzizSVw==", - "dependencies": { - "abab": "^2.0.5", - "acorn": "^8.2.4", - "acorn-globals": "^6.0.0", - "cssom": "^0.4.4", - "cssstyle": "^2.3.0", - "data-urls": "^2.0.0", - "decimal.js": "^10.2.1", - "domexception": "^2.0.1", - "escodegen": "^2.0.0", - "form-data": "^3.0.0", - "html-encoding-sniffer": "^2.0.1", - "http-proxy-agent": "^4.0.1", - "https-proxy-agent": "^5.0.0", - "is-potential-custom-element-name": "^1.0.1", - "nwsapi": "^2.2.0", - "parse5": "6.0.1", - "saxes": "^5.0.1", - "symbol-tree": "^3.2.4", - "tough-cookie": "^4.0.0", - "w3c-hr-time": "^1.0.2", - "w3c-xmlserializer": "^2.0.0", - "webidl-conversions": "^6.1.0", - "whatwg-encoding": "^1.0.5", - "whatwg-mimetype": "^2.3.0", - "whatwg-url": "^8.5.0", - "ws": "^7.4.6", - "xml-name-validator": "^3.0.0" - }, - "engines": { - "node": ">=10" - }, - "peerDependencies": { - "canvas": "^2.5.0" - }, - "peerDependenciesMeta": { - "canvas": { - "optional": true - } - } - }, - "node_modules/jsesc": { - "version": "2.5.2", - "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz", - "integrity": "sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==", - "bin": { - "jsesc": "bin/jsesc" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/json-parse-even-better-errors": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz", - "integrity": "sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==" - }, - "node_modules/json-schema": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.4.0.tgz", - "integrity": "sha512-es94M3nTIfsEPisRafak+HDLfHXnKBhV3vU5eqPcS3flIWqcxJWgXHXiey3YrpaNsanY5ei1VoYEbOzijuq9BA==" - }, - "node_modules/json-schema-traverse": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", - "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==" - }, - "node_modules/json-stable-stringify-without-jsonify": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", - "integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==" - }, - "node_modules/json-stringify-safe": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", - "integrity": "sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA==", - "optional": true - }, - "node_modules/json5": { - "version": "2.2.3", - "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", - "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", - "bin": { - "json5": "lib/cli.js" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/jsonfile": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz", - "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", - "dependencies": { - "universalify": "^2.0.0" - }, - "optionalDependencies": { - "graceful-fs": "^4.1.6" - } - }, - "node_modules/jsonpointer": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/jsonpointer/-/jsonpointer-5.0.1.tgz", - "integrity": "sha512-p/nXbhSEcu3pZRdkW1OfJhpsVtW1gd4Wa1fnQc9YLiTfAjn0312eMKimbdIQzuZl9aa9xUGaRlP9T/CJE/ditQ==", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/jsprim": { - "version": "1.4.2", - "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.2.tgz", - "integrity": "sha512-P2bSOMAc/ciLz6DzgjVlGJP9+BrJWu5UDGK70C2iweC5QBIeFf0ZXRvGjEj2uYgrY2MkAAhsSWHDWlFtEroZWw==", - "optional": true, - "dependencies": { - "assert-plus": "1.0.0", - "extsprintf": "1.3.0", - "json-schema": "0.4.0", - "verror": "1.10.0" - }, - "engines": { - "node": ">=0.6.0" - } - }, - "node_modules/jsx-ast-utils": { - "version": "3.3.3", - "resolved": "https://registry.npmjs.org/jsx-ast-utils/-/jsx-ast-utils-3.3.3.tgz", - "integrity": "sha512-fYQHZTZ8jSfmWZ0iyzfwiU4WDX4HpHbMCZ3gPlWYiCl3BoeOTsqKBqnTVfH2rYT7eP5c3sVbeSPHnnJOaTrWiw==", - "dependencies": { - "array-includes": "^3.1.5", - "object.assign": "^4.1.3" - }, - "engines": { - "node": ">=4.0" - } - }, - "node_modules/kind-of": { - "version": "6.0.3", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz", - "integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/klaw": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/klaw/-/klaw-1.3.1.tgz", - "integrity": "sha512-TED5xi9gGQjGpNnvRWknrwAB1eL5GciPfVFOt3Vk1OJCVDQbzuSfrF3hkUQKlsgKrG1F+0t5W0m+Fje1jIt8rw==", - "optionalDependencies": { - "graceful-fs": "^4.1.9" - } - }, - "node_modules/kleur": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/kleur/-/kleur-3.0.3.tgz", - "integrity": "sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==", - "engines": { - "node": ">=6" - } - }, - "node_modules/klona": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/klona/-/klona-2.0.6.tgz", - "integrity": "sha512-dhG34DXATL5hSxJbIexCft8FChFXtmskoZYnoPWjXQuebWYCNkVeV3KkGegCK9CP1oswI/vQibS2GY7Em/sJJA==", - "engines": { - "node": ">= 8" - } - }, - "node_modules/language-subtag-registry": { - "version": "0.3.22", - "resolved": "https://registry.npmjs.org/language-subtag-registry/-/language-subtag-registry-0.3.22.tgz", - "integrity": "sha512-tN0MCzyWnoz/4nHS6uxdlFWoUZT7ABptwKPQ52Ea7URk6vll88bWBVhodtnlfEuCcKWNGoc+uGbw1cwa9IKh/w==" - }, - "node_modules/language-tags": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/language-tags/-/language-tags-1.0.5.tgz", - "integrity": "sha512-qJhlO9cGXi6hBGKoxEG/sKZDAHD5Hnu9Hs4WbOY3pCWXDhw0N8x1NenNzm2EnNLkLkk7J2SdxAkDSbb6ftT+UQ==", - "dependencies": { - "language-subtag-registry": "~0.3.2" - } - }, - "node_modules/launch-editor": { - "version": "2.6.0", - "resolved": "https://registry.npmjs.org/launch-editor/-/launch-editor-2.6.0.tgz", - "integrity": "sha512-JpDCcQnyAAzZZaZ7vEiSqL690w7dAEyLao+KC96zBplnYbJS7TYNjvM3M7y3dGz+v7aIsJk3hllWuc0kWAjyRQ==", - "dependencies": { - "picocolors": "^1.0.0", - "shell-quote": "^1.7.3" - } - }, - "node_modules/leven": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/leven/-/leven-3.1.0.tgz", - "integrity": "sha512-qsda+H8jTaUaN/x5vzW2rzc+8Rw4TAQ/4KjB46IwK5VH+IlVeeeje/EoZRpiXvIqjFgK84QffqPztGI3VBLG1A==", - "engines": { - "node": ">=6" - } - }, - "node_modules/levn": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", - "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==", - "dependencies": { - "prelude-ls": "^1.2.1", - "type-check": "~0.4.0" - }, - "engines": { - "node": ">= 0.8.0" - } - }, - "node_modules/lie": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/lie/-/lie-3.1.1.tgz", - "integrity": "sha512-RiNhHysUjhrDQntfYSfY4MU24coXXdEOgw9WGcKHNeEwffDYbF//u87M1EWaMGzuFoSbqW0C9C6lEEhDOAswfw==", - "dependencies": { - "immediate": "~3.0.5" - } - }, - "node_modules/lilconfig": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/lilconfig/-/lilconfig-2.1.0.tgz", - "integrity": "sha512-utWOt/GHzuUxnLKxB6dk81RoOeoNeHgbrXiuGk4yyF5qlRz+iIVWu56E2fqGHFrXz0QNUhLB/8nKqvRH66JKGQ==", - "engines": { - "node": ">=10" - } - }, - "node_modules/lines-and-columns": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.2.4.tgz", - "integrity": "sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==" - }, - "node_modules/linkify-it": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-4.0.1.tgz", - "integrity": "sha512-C7bfi1UZmoj8+PQx22XyeXCuBlokoyWQL5pWSP+EI6nzRylyThouddufc2c1NDIcP9k5agmN9fLpA7VNJfIiqw==", - "peer": true, - "dependencies": { - "uc.micro": "^1.0.1" - } - }, - "node_modules/linkifyjs": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/linkifyjs/-/linkifyjs-4.1.1.tgz", - "integrity": "sha512-zFN/CTVmbcVef+WaDXT63dNzzkfRBKT1j464NJQkV7iSgJU0sLBus9W0HBwnXK13/hf168pbrx/V/bjEHOXNHA==" - }, - "node_modules/loader-runner": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/loader-runner/-/loader-runner-4.3.0.tgz", - "integrity": "sha512-3R/1M+yS3j5ou80Me59j7F9IMs4PXs3VqRrm0TU3AbKPxlmpoY1TNscJV/oGJXo8qCatFGTfDbY6W6ipGOYXfg==", - "engines": { - "node": ">=6.11.5" - } - }, - "node_modules/loader-utils": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-2.0.4.tgz", - "integrity": "sha512-xXqpXoINfFhgua9xiqD8fPFHgkoq1mmmpE92WlDbm9rNRd/EbRb+Gqf908T2DMfuHjjJlksiK2RbHVOdD/MqSw==", - "dependencies": { - "big.js": "^5.2.2", - "emojis-list": "^3.0.0", - "json5": "^2.1.2" - }, - "engines": { - "node": ">=8.9.0" - } - }, - "node_modules/localforage": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/localforage/-/localforage-1.10.0.tgz", - "integrity": "sha512-14/H1aX7hzBBmmh7sGPd+AOMkkIrHM3Z1PAyGgZigA1H1p5O5ANnMyWzvpAETtG68/dC4pC0ncy3+PPGzXZHPg==", - "dependencies": { - "lie": "3.1.1" - } - }, - "node_modules/locate-path": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", - "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", - "dependencies": { - "p-locate": "^5.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/lodash": { - "version": "4.17.21", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", - "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" - }, - "node_modules/lodash.assignin": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/lodash.assignin/-/lodash.assignin-4.2.0.tgz", - "integrity": "sha512-yX/rx6d/UTVh7sSVWVSIMjfnz95evAgDFdb1ZozC35I9mSFCkmzptOzevxjgbQUsc78NR44LVHWjsoMQXy9FDg==" - }, - "node_modules/lodash.bind": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/lodash.bind/-/lodash.bind-4.2.1.tgz", - "integrity": "sha512-lxdsn7xxlCymgLYo1gGvVrfHmkjDiyqVv62FAeF2i5ta72BipE1SLxw8hPEPLhD4/247Ijw07UQH7Hq/chT5LA==" - }, - "node_modules/lodash.debounce": { - "version": "4.0.8", - "resolved": "https://registry.npmjs.org/lodash.debounce/-/lodash.debounce-4.0.8.tgz", - "integrity": "sha512-FT1yDzDYEoYWhnSGnpE/4Kj1fLZkDFyqRb7fNt6FdYOSxlUWAtp42Eh6Wb0rGIv/m9Bgo7x4GhQbm5Ys4SG5ow==" - }, - "node_modules/lodash.defaults": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/lodash.defaults/-/lodash.defaults-4.2.0.tgz", - "integrity": "sha512-qjxPLHd3r5DnsdGacqOMU6pb/avJzdh9tFX2ymgoZE27BmjXrNy/y4LoaiTeAb+O3gL8AfpJGtqfX/ae2leYYQ==" - }, - "node_modules/lodash.filter": { - "version": "4.6.0", - "resolved": "https://registry.npmjs.org/lodash.filter/-/lodash.filter-4.6.0.tgz", - "integrity": "sha512-pXYUy7PR8BCLwX5mgJ/aNtyOvuJTdZAo9EQFUvMIYugqmJxnrYaANvTbgndOzHSCSR0wnlBBfRXJL5SbWxo3FQ==" - }, - "node_modules/lodash.flatten": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/lodash.flatten/-/lodash.flatten-4.4.0.tgz", - "integrity": "sha512-C5N2Z3DgnnKr0LOpv/hKCgKdb7ZZwafIrsesve6lmzvZIRZRGaZ/l6Q8+2W7NaT+ZwO3fFlSCzCzrDCFdJfZ4g==" - }, - "node_modules/lodash.foreach": { - "version": "4.5.0", - "resolved": "https://registry.npmjs.org/lodash.foreach/-/lodash.foreach-4.5.0.tgz", - "integrity": "sha512-aEXTF4d+m05rVOAUG3z4vZZ4xVexLKZGF0lIxuHZ1Hplpk/3B6Z1+/ICICYRLm7c41Z2xiejbkCkJoTlypoXhQ==" - }, - "node_modules/lodash.map": { - "version": "4.6.0", - "resolved": "https://registry.npmjs.org/lodash.map/-/lodash.map-4.6.0.tgz", - "integrity": "sha512-worNHGKLDetmcEYDvh2stPCrrQRkP20E4l0iIS7F8EvzMqBBi7ltvFN5m1HvTf1P7Jk1txKhvFcmYsCr8O2F1Q==" - }, - "node_modules/lodash.memoize": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-4.1.2.tgz", - "integrity": "sha512-t7j+NzmgnQzTAYXcsHYLgimltOV1MXHtlOWf6GjL9Kj8GK5FInw5JotxvbOs+IvV1/Dzo04/fCGfLVs7aXb4Ag==" - }, - "node_modules/lodash.merge": { - "version": "4.6.2", - "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", - "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==" - }, - "node_modules/lodash.pick": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/lodash.pick/-/lodash.pick-4.4.0.tgz", - "integrity": "sha512-hXt6Ul/5yWjfklSGvLQl8vM//l3FtyHZeuelpzK6mm99pNvN9yTDruNZPEJZD1oWrqo+izBmB7oUfWgcCX7s4Q==" - }, - "node_modules/lodash.reduce": { - "version": "4.6.0", - "resolved": "https://registry.npmjs.org/lodash.reduce/-/lodash.reduce-4.6.0.tgz", - "integrity": "sha512-6raRe2vxCYBhpBu+B+TtNGUzah+hQjVdu3E17wfusjyrXBka2nBS8OH/gjVZ5PvHOhWmIZTYri09Z6n/QfnNMw==" - }, - "node_modules/lodash.reject": { - "version": "4.6.0", - "resolved": "https://registry.npmjs.org/lodash.reject/-/lodash.reject-4.6.0.tgz", - "integrity": "sha512-qkTuvgEzYdyhiJBx42YPzPo71R1aEr0z79kAv7Ixg8wPFEjgRgJdUsGMG3Hf3OYSF/kHI79XhNlt+5Ar6OzwxQ==" - }, - "node_modules/lodash.some": { - "version": "4.6.0", - "resolved": "https://registry.npmjs.org/lodash.some/-/lodash.some-4.6.0.tgz", - "integrity": "sha512-j7MJE+TuT51q9ggt4fSgVqro163BEFjAt3u97IqU+JA2DkWl80nFTrowzLpZ/BnpN7rrl0JA/593NAdd8p/scQ==" - }, - "node_modules/lodash.sortby": { - "version": "4.7.0", - "resolved": "https://registry.npmjs.org/lodash.sortby/-/lodash.sortby-4.7.0.tgz", - "integrity": "sha512-HDWXG8isMntAyRF5vZ7xKuEvOhT4AhlRt/3czTSjvGUxjYCBVRQY48ViDHyfYz9VIoBkW4TMGQNapx+l3RUwdA==" - }, - "node_modules/lodash.uniq": { - "version": "4.5.0", - "resolved": "https://registry.npmjs.org/lodash.uniq/-/lodash.uniq-4.5.0.tgz", - "integrity": "sha512-xfBaXQd9ryd9dlSDvnvI0lvxfLJlYAZzXomUYzLKtUeOQvOP5piqAWuGtrhWeqaXK9hhoM/iyJc5AV+XfsX3HQ==" - }, - "node_modules/long": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/long/-/long-4.0.0.tgz", - "integrity": "sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA==" - }, - "node_modules/loose-envify": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", - "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==", - "dependencies": { - "js-tokens": "^3.0.0 || ^4.0.0" - }, - "bin": { - "loose-envify": "cli.js" - } - }, - "node_modules/lower-case": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/lower-case/-/lower-case-2.0.2.tgz", - "integrity": "sha512-7fm3l3NAF9WfN6W3JOmf5drwpVqX78JtoGJ3A6W0a6ZnldM41w2fV5D490psKFTpMds8TJse/eHLFFsNHHjHgg==", - "dependencies": { - "tslib": "^2.0.3" - } - }, - "node_modules/lru-cache": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", - "integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==", - "dependencies": { - "yallist": "^3.0.2" - } - }, - "node_modules/lz-string": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/lz-string/-/lz-string-1.5.0.tgz", - "integrity": "sha512-h5bgJWpxJNswbU7qCrV0tIKQCaS3blPDrqKWx+QxzuzL1zGUzij9XCWLrSLsJPu5t+eWA/ycetzYAO5IOMcWAQ==", - "bin": { - "lz-string": "bin/bin.js" - } - }, - "node_modules/magic-string": { - "version": "0.25.9", - "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.25.9.tgz", - "integrity": "sha512-RmF0AsMzgt25qzqqLc1+MbHmhdx0ojF2Fvs4XnOqz2ZOBXzzkEwc/dJQZCYHAn7v1jbVOjAZfK8msRn4BxO4VQ==", - "dependencies": { - "sourcemap-codec": "^1.4.8" - } - }, - "node_modules/make-dir": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", - "integrity": "sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==", - "dependencies": { - "semver": "^6.0.0" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/make-dir/node_modules/semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", - "bin": { - "semver": "bin/semver.js" - } - }, - "node_modules/make-error": { - "version": "1.3.6", - "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", - "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==", - "peer": true - }, - "node_modules/makeerror": { - "version": "1.0.12", - "resolved": "https://registry.npmjs.org/makeerror/-/makeerror-1.0.12.tgz", - "integrity": "sha512-JmqCvUhmt43madlpFzG4BQzG2Z3m6tvQDNKdClZnO3VbIudJYmxsT0FNJMeiB2+JTSlTQTSbU8QdesVmwJcmLg==", - "dependencies": { - "tmpl": "1.0.5" - } - }, - "node_modules/markdown-it": { - "version": "13.0.1", - "resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-13.0.1.tgz", - "integrity": "sha512-lTlxriVoy2criHP0JKRhO2VDG9c2ypWCsT237eDiLqi09rmbKoUetyGHq2uOIRoRS//kfoJckS0eUzzkDR+k2Q==", - "peer": true, - "dependencies": { - "argparse": "^2.0.1", - "entities": "~3.0.1", - "linkify-it": "^4.0.1", - "mdurl": "^1.0.1", - "uc.micro": "^1.0.5" - }, - "bin": { - "markdown-it": "bin/markdown-it.js" - } - }, - "node_modules/markdown-it/node_modules/argparse": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", - "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", - "peer": true - }, - "node_modules/markdown-it/node_modules/entities": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/entities/-/entities-3.0.1.tgz", - "integrity": "sha512-WiyBqoomrwMdFG1e0kqvASYfnlb0lp8M5o5Fw2OFq1hNZxxcNk8Ik0Xm7LxzBhuidnZB/UtBqVCgUz3kBOP51Q==", - "peer": true, - "engines": { - "node": ">=0.12" - }, - "funding": { - "url": "https://github.com/fb55/entities?sponsor=1" - } - }, - "node_modules/marked": { - "version": "0.3.19", - "resolved": "https://registry.npmjs.org/marked/-/marked-0.3.19.tgz", - "integrity": "sha512-ea2eGWOqNxPcXv8dyERdSr/6FmzvWwzjMxpfGB/sbMccXoct+xY+YukPD+QTUZwyvK7BZwcr4m21WBOW41pAkg==", - "bin": { - "marked": "bin/marked" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/match-sorter": { - "version": "6.3.1", - "resolved": "https://registry.npmjs.org/match-sorter/-/match-sorter-6.3.1.tgz", - "integrity": "sha512-mxybbo3pPNuA+ZuCUhm5bwNkXrJTbsk5VWbR5wiwz/GC6LIiegBGn2w3O08UG/jdbYLinw51fSQ5xNU1U3MgBw==", - "dependencies": { - "@babel/runtime": "^7.12.5", - "remove-accents": "0.4.2" - } - }, - "node_modules/mdn-data": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/mdn-data/-/mdn-data-2.0.4.tgz", - "integrity": "sha512-iV3XNKw06j5Q7mi6h+9vbx23Tv7JkjEVgKHW4pimwyDGWm0OIQntJJ+u1C6mg6mK1EaTv42XQ7w76yuzH7M2cA==" - }, - "node_modules/mdurl": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/mdurl/-/mdurl-1.0.1.tgz", - "integrity": "sha512-/sKlQJCBYVY9Ers9hqzKou4H6V5UWc/M59TH2dvkt+84itfnq7uFOMLpOiOS4ujvHP4etln18fmIxA5R5fll0g==", - "peer": true - }, - "node_modules/media-typer": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", - "integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/memfs": { - "version": "3.5.1", - "resolved": "https://registry.npmjs.org/memfs/-/memfs-3.5.1.tgz", - "integrity": "sha512-UWbFJKvj5k+nETdteFndTpYxdeTMox/ULeqX5k/dpaQJCCFmj5EeKv3dBcyO2xmkRAx2vppRu5dVG7SOtsGOzA==", - "dependencies": { - "fs-monkey": "^1.0.3" - }, - "engines": { - "node": ">= 4.0.0" - } - }, - "node_modules/merge-descriptors": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", - "integrity": "sha512-cCi6g3/Zr1iqQi6ySbseM1Xvooa98N0w31jzUYrXPX2xqObmFGHJ0tQ5u74H3mVh7wLouTseZyYIq39g8cNp1w==" - }, - "node_modules/merge-stream": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", - "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==" - }, - "node_modules/merge2": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", - "integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==", - "engines": { - "node": ">= 8" - } - }, - "node_modules/methods": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", - "integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/micromatch": { - "version": "4.0.5", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz", - "integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==", - "dependencies": { - "braces": "^3.0.2", - "picomatch": "^2.3.1" - }, - "engines": { - "node": ">=8.6" - } - }, - "node_modules/mime": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", - "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==", - "bin": { - "mime": "cli.js" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/mime-db": { - "version": "1.52.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", - "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/mime-types": { - "version": "2.1.35", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", - "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", - "dependencies": { - "mime-db": "1.52.0" - }, - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/mimic-fn": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", - "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", - "engines": { - "node": ">=6" - } - }, - "node_modules/min-indent": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/min-indent/-/min-indent-1.0.1.tgz", - "integrity": "sha512-I9jwMn07Sy/IwOj3zVkVik2JTvgpaykDZEigL6Rx6N9LbMywwUSMtxET+7lVoDLLd3O3IXwJwvuuns8UB/HeAg==", - "engines": { - "node": ">=4" - } - }, - "node_modules/mini-css-extract-plugin": { - "version": "2.7.6", - "resolved": "https://registry.npmjs.org/mini-css-extract-plugin/-/mini-css-extract-plugin-2.7.6.tgz", - "integrity": "sha512-Qk7HcgaPkGG6eD77mLvZS1nmxlao3j+9PkrT9Uc7HAE1id3F41+DdBRYRYkbyfNRGzm8/YWtzhw7nVPmwhqTQw==", - "dependencies": { - "schema-utils": "^4.0.0" - }, - "engines": { - "node": ">= 12.13.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/webpack" - }, - "peerDependencies": { - "webpack": "^5.0.0" - } - }, - "node_modules/mini-css-extract-plugin/node_modules/ajv": { - "version": "8.12.0", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.12.0.tgz", - "integrity": "sha512-sRu1kpcO9yLtYxBKvqfTeh9KzZEwO3STyX1HT+4CaDzC6HpTGYhIhPIzj9XuKU7KYDwnaeh5hcOwjy1QuJzBPA==", - "dependencies": { - "fast-deep-equal": "^3.1.1", - "json-schema-traverse": "^1.0.0", - "require-from-string": "^2.0.2", - "uri-js": "^4.2.2" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/epoberezkin" - } - }, - "node_modules/mini-css-extract-plugin/node_modules/ajv-keywords": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-5.1.0.tgz", - "integrity": "sha512-YCS/JNFAUyr5vAuhk1DWm1CBxRHW9LbJ2ozWeemrIqpbsqKjHVxYPyi5GC0rjZIT5JxJ3virVTS8wk4i/Z+krw==", - "dependencies": { - "fast-deep-equal": "^3.1.3" - }, - "peerDependencies": { - "ajv": "^8.8.2" - } - }, - "node_modules/mini-css-extract-plugin/node_modules/json-schema-traverse": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", - "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==" - }, - "node_modules/mini-css-extract-plugin/node_modules/schema-utils": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-4.0.1.tgz", - "integrity": "sha512-lELhBAAly9NowEsX0yZBlw9ahZG+sK/1RJ21EpzdYHKEs13Vku3LJ+MIPhh4sMs0oCCeufZQEQbMekiA4vuVIQ==", - "dependencies": { - "@types/json-schema": "^7.0.9", - "ajv": "^8.9.0", - "ajv-formats": "^2.1.1", - "ajv-keywords": "^5.1.0" - }, - "engines": { - "node": ">= 12.13.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/webpack" - } - }, - "node_modules/minimalistic-assert": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz", - "integrity": "sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==" - }, - "node_modules/minimatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", - "dependencies": { - "brace-expansion": "^1.1.7" - }, - "engines": { - "node": "*" - } - }, - "node_modules/minimist": { - "version": "1.2.8", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", - "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/minipass": { - "version": "2.9.0", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-2.9.0.tgz", - "integrity": "sha512-wxfUjg9WebH+CUDX/CdbRlh5SmfZiy/hpkxaRI16Y9W56Pa75sWgd/rvFilSgrauD9NyFymP/+JFV3KwzIsJeg==", - "dependencies": { - "safe-buffer": "^5.1.2", - "yallist": "^3.0.0" - } - }, - "node_modules/minizlib": { - "version": "1.3.3", - "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-1.3.3.tgz", - "integrity": "sha512-6ZYMOEnmVsdCeTJVE0W9ZD+pVnE8h9Hma/iOwwRDsdQoePpoX56/8B6z3P9VNwppJuBKNRuFDRNRqRWexT9G9Q==", - "dependencies": { - "minipass": "^2.9.0" - } - }, - "node_modules/mkdirp": { - "version": "0.5.6", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", - "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", - "dependencies": { - "minimist": "^1.2.6" - }, - "bin": { - "mkdirp": "bin/cmd.js" - } - }, - "node_modules/ms": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" - }, - "node_modules/multicast-dns": { - "version": "7.2.5", - "resolved": "https://registry.npmjs.org/multicast-dns/-/multicast-dns-7.2.5.tgz", - "integrity": "sha512-2eznPJP8z2BFLX50tf0LuODrpINqP1RVIm/CObbTcBRITQgmC/TjcREF1NeTBzIcR5XO/ukWo+YHOjBbFwIupg==", - "dependencies": { - "dns-packet": "^5.2.2", - "thunky": "^1.0.2" - }, - "bin": { - "multicast-dns": "cli.js" - } - }, - "node_modules/mz": { - "version": "2.7.0", - "resolved": "https://registry.npmjs.org/mz/-/mz-2.7.0.tgz", - "integrity": "sha512-z81GNO7nnYMEhrGh9LeymoE4+Yr0Wn5McHIZMK5cfQCl+NDX08sCZgUc9/6MHni9IWuFLm1Z3HTCXu2z9fN62Q==", - "dependencies": { - "any-promise": "^1.0.0", - "object-assign": "^4.0.1", - "thenify-all": "^1.0.0" - } - }, - "node_modules/nanoid": { - "version": "3.3.6", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.6.tgz", - "integrity": "sha512-BGcqMMJuToF7i1rt+2PWSNVnWIkGCU78jBG3RxO/bZlnZPK2Cmi2QaffxGO/2RvWi9sL+FAiRiXMgsyxQ1DIDA==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/ai" - } - ], - "bin": { - "nanoid": "bin/nanoid.cjs" - }, - "engines": { - "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" - } - }, - "node_modules/natural-compare": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", - "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==" - }, - "node_modules/natural-compare-lite": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/natural-compare-lite/-/natural-compare-lite-1.4.0.tgz", - "integrity": "sha512-Tj+HTDSJJKaZnfiuw+iaF9skdPpTo2GtEly5JHnWV/hfv2Qj/9RKsGISQtLh2ox3l5EAGw487hnBee0sIJ6v2g==" - }, - "node_modules/needle": { - "version": "2.9.1", - "resolved": "https://registry.npmjs.org/needle/-/needle-2.9.1.tgz", - "integrity": "sha512-6R9fqJ5Zcmf+uYaFgdIHmLwNldn5HbK8L5ybn7Uz+ylX/rnOsSp1AHcvQSrCaFN+qNM1wpymHqD7mVasEOlHGQ==", - "dependencies": { - "debug": "^3.2.6", - "iconv-lite": "^0.4.4", - "sax": "^1.2.4" - }, - "bin": { - "needle": "bin/needle" - }, - "engines": { - "node": ">= 4.4.x" - } - }, - "node_modules/needle/node_modules/debug": { - "version": "3.2.7", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", - "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", - "dependencies": { - "ms": "^2.1.1" - } - }, - "node_modules/needle/node_modules/iconv-lite": { - "version": "0.4.24", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", - "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", - "dependencies": { - "safer-buffer": ">= 2.1.2 < 3" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/negotiator": { - "version": "0.6.3", - "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", - "integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/neo-async": { - "version": "2.6.2", - "resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.2.tgz", - "integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==" - }, - "node_modules/no-case": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/no-case/-/no-case-3.0.4.tgz", - "integrity": "sha512-fgAN3jGAh+RoxUGZHTSOLJIqUc2wmoBwGR4tbpNAKmmovFoWq0OdRkb0VkldReO2a2iBT/OEulG9XSUc10r3zg==", - "dependencies": { - "lower-case": "^2.0.2", - "tslib": "^2.0.3" - } - }, - "node_modules/node-fetch": { - "version": "2.6.13", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.13.tgz", - "integrity": "sha512-StxNAxh15zr77QvvkmveSQ8uCQ4+v5FkvNTj0OESmiHu+VRi/gXArXtkWMElOsOUNLtUEvI4yS+rdtOHZTwlQA==", - "dependencies": { - "whatwg-url": "^5.0.0" - }, - "engines": { - "node": "4.x || >=6.0.0" - }, - "peerDependencies": { - "encoding": "^0.1.0" - }, - "peerDependenciesMeta": { - "encoding": { - "optional": true - } - } - }, - "node_modules/node-fetch/node_modules/tr46": { - "version": "0.0.3", - "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", - "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" - }, - "node_modules/node-fetch/node_modules/webidl-conversions": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", - "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==" - }, - "node_modules/node-fetch/node_modules/whatwg-url": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", - "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", - "dependencies": { - "tr46": "~0.0.3", - "webidl-conversions": "^3.0.0" - } - }, - "node_modules/node-forge": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/node-forge/-/node-forge-1.3.1.tgz", - "integrity": "sha512-dPEtOeMvF9VMcYV/1Wb8CPoVAXtp6MKMlcbAt4ddqmGqUJ6fQZFXkNZNkNlfevtNkGtaSoXf/vNNNSvgrdXwtA==", - "engines": { - "node": ">= 6.13.0" - } - }, - "node_modules/node-int64": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz", - "integrity": "sha512-O5lz91xSOeoXP6DulyHfllpq+Eg00MWitZIbtPfoSEvqIHdl5gfcY6hYzDWnj0qD5tz52PI08u9qUvSVeUBeHw==" - }, - "node_modules/node-pre-gyp": { - "version": "0.14.0", - "resolved": "https://registry.npmjs.org/node-pre-gyp/-/node-pre-gyp-0.14.0.tgz", - "integrity": "sha512-+CvDC7ZttU/sSt9rFjix/P05iS43qHCOOGzcr3Ry99bXG7VX953+vFyEuph/tfqoYu8dttBkE86JSKBO2OzcxA==", - "deprecated": "Please upgrade to @mapbox/node-pre-gyp: the non-scoped node-pre-gyp package is deprecated and only the @mapbox scoped package will recieve updates in the future", - "dependencies": { - "detect-libc": "^1.0.2", - "mkdirp": "^0.5.1", - "needle": "^2.2.1", - "nopt": "^4.0.1", - "npm-packlist": "^1.1.6", - "npmlog": "^4.0.2", - "rc": "^1.2.7", - "rimraf": "^2.6.1", - "semver": "^5.3.0", - "tar": "^4.4.2" - }, - "bin": { - "node-pre-gyp": "bin/node-pre-gyp" - } - }, - "node_modules/node-pre-gyp/node_modules/rimraf": { - "version": "2.7.1", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz", - "integrity": "sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==", - "dependencies": { - "glob": "^7.1.3" - }, - "bin": { - "rimraf": "bin.js" - } - }, - "node_modules/node-pre-gyp/node_modules/semver": { - "version": "5.7.2", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.2.tgz", - "integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==", - "bin": { - "semver": "bin/semver" - } - }, - "node_modules/node-releases": { - "version": "2.0.11", - "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.11.tgz", - "integrity": "sha512-+M0PwXeU80kRohZ3aT4J/OnR+l9/KD2nVLNNoRgFtnf+umQVFdGBAO2N8+nCnEi0xlh/Wk3zOGC+vNNx+uM79Q==" - }, - "node_modules/nopt": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/nopt/-/nopt-4.0.3.tgz", - "integrity": "sha512-CvaGwVMztSMJLOeXPrez7fyfObdZqNUK1cPAEzLHrTybIua9pMdmmPR5YwtfNftIOMv3DPUhFaxsZMNTQO20Kg==", - "dependencies": { - "abbrev": "1", - "osenv": "^0.1.4" - }, - "bin": { - "nopt": "bin/nopt.js" - } - }, - "node_modules/normalize-path": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", - "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/normalize-range": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/normalize-range/-/normalize-range-0.1.2.tgz", - "integrity": "sha512-bdok/XvKII3nUpklnV6P2hxtMNrCboOjAcyBuQnWEhO665FwrSNRxU+AqpsyvO6LgGYPspN+lu5CLtw4jPRKNA==", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/normalize-url": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/normalize-url/-/normalize-url-6.1.0.tgz", - "integrity": "sha512-DlL+XwOy3NxAQ8xuC0okPgK46iuVNAK01YN7RueYBqqFeGsBjV9XmCAzAdgt+667bCl5kPh9EqKKDwnaPG1I7A==", - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/npm-bundled": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/npm-bundled/-/npm-bundled-1.1.2.tgz", - "integrity": "sha512-x5DHup0SuyQcmL3s7Rx/YQ8sbw/Hzg0rj48eN0dV7hf5cmQq5PXIeioroH3raV1QC1yh3uTYuMThvEQF3iKgGQ==", - "dependencies": { - "npm-normalize-package-bin": "^1.0.1" - } - }, - "node_modules/npm-normalize-package-bin": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/npm-normalize-package-bin/-/npm-normalize-package-bin-1.0.1.tgz", - "integrity": "sha512-EPfafl6JL5/rU+ot6P3gRSCpPDW5VmIzX959Ob1+ySFUuuYHWHekXpwdUZcKP5C+DS4GEtdJluwBjnsNDl+fSA==" - }, - "node_modules/npm-packlist": { - "version": "1.4.8", - "resolved": "https://registry.npmjs.org/npm-packlist/-/npm-packlist-1.4.8.tgz", - "integrity": "sha512-5+AZgwru5IevF5ZdnFglB5wNlHG1AOOuw28WhUq8/8emhBmLv6jX5by4WJCh7lW0uSYZYS6DXqIsyZVIXRZU9A==", - "dependencies": { - "ignore-walk": "^3.0.1", - "npm-bundled": "^1.0.1", - "npm-normalize-package-bin": "^1.0.1" - } - }, - "node_modules/npm-run-path": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-4.0.1.tgz", - "integrity": "sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==", - "dependencies": { - "path-key": "^3.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/npmlog": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-4.1.2.tgz", - "integrity": "sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg==", - "dependencies": { - "are-we-there-yet": "~1.1.2", - "console-control-strings": "~1.1.0", - "gauge": "~2.7.3", - "set-blocking": "~2.0.0" - } - }, - "node_modules/nth-check": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/nth-check/-/nth-check-2.1.1.tgz", - "integrity": "sha512-lqjrjmaOoAnWfMmBPL+XNnynZh2+swxiX3WUE0s4yEHI6m+AwrK2UZOimIRl3X/4QctVqS8AiZjFqyOGrMXb/w==", - "dependencies": { - "boolbase": "^1.0.0" - }, - "funding": { - "url": "https://github.com/fb55/nth-check?sponsor=1" - } - }, - "node_modules/number-is-nan": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", - "integrity": "sha512-4jbtZXNAsfZbAHiiqjLPBiCl16dES1zI4Hpzzxw61Tk+loF+sBDBKx1ICKKKwIqQ7M0mFn1TmkN7euSncWgHiQ==", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/nwmatcher": { - "version": "1.4.4", - "resolved": "https://registry.npmjs.org/nwmatcher/-/nwmatcher-1.4.4.tgz", - "integrity": "sha512-3iuY4N5dhgMpCUrOVnuAdGrgxVqV2cJpM+XNccjR2DKOB1RUP0aA+wGXEiNziG/UKboFyGBIoKOaNlJxx8bciQ==", - "optional": true - }, - "node_modules/nwsapi": { - "version": "2.2.4", - "resolved": "https://registry.npmjs.org/nwsapi/-/nwsapi-2.2.4.tgz", - "integrity": "sha512-NHj4rzRo0tQdijE9ZqAx6kYDcoRwYwSYzCA8MY3JzfxlrvEU0jhnhJT9BhqhJs7I/dKcrDm6TyulaRqZPIhN5g==" - }, - "node_modules/oauth-sign": { - "version": "0.9.0", - "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", - "integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==", - "optional": true, - "engines": { - "node": "*" - } - }, - "node_modules/object-assign": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", - "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/object-hash": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/object-hash/-/object-hash-3.0.0.tgz", - "integrity": "sha512-RSn9F68PjH9HqtltsSnqYC1XXoWe9Bju5+213R98cNGttag9q9yAOTzdbsqvIa7aNm5WffBZFpWYr2aWrklWAw==", - "engines": { - "node": ">= 6" - } - }, - "node_modules/object-inspect": { - "version": "1.12.3", - "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.3.tgz", - "integrity": "sha512-geUvdk7c+eizMNUDkRpW1wJwgfOiOeHbxBR/hLXK1aT6zmVSO0jsQcs7fj6MGw89jC/cjGfLcNOrtMYtGqm81g==", - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/object-is": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/object-is/-/object-is-1.1.5.tgz", - "integrity": "sha512-3cyDsyHgtmi7I7DfSSI2LDp6SK2lwvtbg0p0R1e0RvTqF5ceGx+K2dfSjm1bKDMVCFEDAQvy+o8c6a7VujOddw==", - "dependencies": { - "call-bind": "^1.0.2", - "define-properties": "^1.1.3" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/object-keys": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", - "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==", - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/object-path": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/object-path/-/object-path-0.6.0.tgz", - "integrity": "sha512-fxrwsCFi3/p+LeLOAwo/wyRMODZxdGBtUlWRzsEpsUVrisZbEfZ21arxLGfaWfcnqb8oHPNihIb4XPE8CQPN5A==", - "engines": { - "node": ">=0.8.0" - } - }, - "node_modules/object.assign": { - "version": "4.1.4", - "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.4.tgz", - "integrity": "sha512-1mxKf0e58bvyjSCtKYY4sRe9itRk3PJpquJOjeIkz885CczcI4IvJJDLPS72oowuSh+pBxUFROpX+TU++hxhZQ==", - "dependencies": { - "call-bind": "^1.0.2", - "define-properties": "^1.1.4", - "has-symbols": "^1.0.3", - "object-keys": "^1.1.1" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/object.entries": { - "version": "1.1.6", - "resolved": "https://registry.npmjs.org/object.entries/-/object.entries-1.1.6.tgz", - "integrity": "sha512-leTPzo4Zvg3pmbQ3rDK69Rl8GQvIqMWubrkxONG9/ojtFE2rD9fjMKfSI5BxW3osRH1m6VdzmqK8oAY9aT4x5w==", - "dependencies": { - "call-bind": "^1.0.2", - "define-properties": "^1.1.4", - "es-abstract": "^1.20.4" - }, - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/object.fromentries": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/object.fromentries/-/object.fromentries-2.0.6.tgz", - "integrity": "sha512-VciD13dswC4j1Xt5394WR4MzmAQmlgN72phd/riNp9vtD7tp4QQWJ0R4wvclXcafgcYK8veHRed2W6XeGBvcfg==", - "dependencies": { - "call-bind": "^1.0.2", - "define-properties": "^1.1.4", - "es-abstract": "^1.20.4" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/object.getownpropertydescriptors": { - "version": "2.1.6", - "resolved": "https://registry.npmjs.org/object.getownpropertydescriptors/-/object.getownpropertydescriptors-2.1.6.tgz", - "integrity": "sha512-lq+61g26E/BgHv0ZTFgRvi7NMEPuAxLkFU7rukXjc/AlwH4Am5xXVnIXy3un1bg/JPbXHrixRkK1itUzzPiIjQ==", - "dependencies": { - "array.prototype.reduce": "^1.0.5", - "call-bind": "^1.0.2", - "define-properties": "^1.2.0", - "es-abstract": "^1.21.2", - "safe-array-concat": "^1.0.0" - }, - "engines": { - "node": ">= 0.8" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/object.hasown": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/object.hasown/-/object.hasown-1.1.2.tgz", - "integrity": "sha512-B5UIT3J1W+WuWIU55h0mjlwaqxiE5vYENJXIXZ4VFe05pNYrkKuK0U/6aFcb0pKywYJh7IhfoqUfKVmrJJHZHw==", - "dependencies": { - "define-properties": "^1.1.4", - "es-abstract": "^1.20.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/object.omit": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/object.omit/-/object.omit-3.0.0.tgz", - "integrity": "sha512-EO+BCv6LJfu+gBIF3ggLicFebFLN5zqzz/WWJlMFfkMyGth+oBkhxzDl0wx2W4GkLzuQs/FsSkXZb2IMWQqmBQ==", - "peer": true, - "dependencies": { - "is-extendable": "^1.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/object.pick": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/object.pick/-/object.pick-1.3.0.tgz", - "integrity": "sha512-tqa/UMy/CCoYmj+H5qc07qvSL9dqcs/WZENZ1JbtWBlATP+iVOe778gE6MSijnyCnORzDuX6hU+LA4SZ09YjFQ==", - "peer": true, - "dependencies": { - "isobject": "^3.0.1" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/object.values": { - "version": "1.1.6", - "resolved": "https://registry.npmjs.org/object.values/-/object.values-1.1.6.tgz", - "integrity": "sha512-FVVTkD1vENCsAcwNs9k6jea2uHC/X0+JcjG8YA60FN5CMaJmG95wT9jek/xX9nornqGRrBkKtzuAu2wuHpKqvw==", - "dependencies": { - "call-bind": "^1.0.2", - "define-properties": "^1.1.4", - "es-abstract": "^1.20.4" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/obuf": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/obuf/-/obuf-1.1.2.tgz", - "integrity": "sha512-PX1wu0AmAdPqOL1mWhqmlOd8kOIZQwGZw6rh7uby9fTc5lhaOWFLX3I6R1hrF9k3zUY40e6igsLGkDXK92LJNg==" - }, - "node_modules/on-finished": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", - "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==", - "dependencies": { - "ee-first": "1.1.1" - }, - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/on-headers": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/on-headers/-/on-headers-1.0.2.tgz", - "integrity": "sha512-pZAE+FJLoyITytdqK0U5s+FIpjN0JP3OzFi/u8Rx+EV5/W+JTWGXG8xFzevE7AjBfDqHv/8vL8qQsIhHnqRkrA==", - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/once": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", - "dependencies": { - "wrappy": "1" - } - }, - "node_modules/onetime": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.2.tgz", - "integrity": "sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==", - "dependencies": { - "mimic-fn": "^2.1.0" - }, - "engines": { - "node": ">=6" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/open": { - "version": "8.4.2", - "resolved": "https://registry.npmjs.org/open/-/open-8.4.2.tgz", - "integrity": "sha512-7x81NCL719oNbsq/3mh+hVrAWmFuEYUqrq/Iw3kUzH8ReypT9QQ0BLoJS7/G9k6N81XjW4qHWtjWwe/9eLy1EQ==", - "dependencies": { - "define-lazy-prop": "^2.0.0", - "is-docker": "^2.1.1", - "is-wsl": "^2.2.0" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/optionator": { - "version": "0.9.1", - "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.1.tgz", - "integrity": "sha512-74RlY5FCnhq4jRxVUPKDaRwrVNXMqsGsiW6AJw4XK8hmtm10wC0ypZBLw5IIp85NZMr91+qd1RvvENwg7jjRFw==", - "dependencies": { - "deep-is": "^0.1.3", - "fast-levenshtein": "^2.0.6", - "levn": "^0.4.1", - "prelude-ls": "^1.2.1", - "type-check": "^0.4.0", - "word-wrap": "^1.2.3" - }, - "engines": { - "node": ">= 0.8.0" - } - }, - "node_modules/orderedmap": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/orderedmap/-/orderedmap-2.1.1.tgz", - "integrity": "sha512-TvAWxi0nDe1j/rtMcWcIj94+Ffe6n7zhow33h40SKxmsmozs6dz/e+EajymfoFcHd7sxNn8yHM8839uixMOV6g==", - "peer": true - }, - "node_modules/os-homedir": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", - "integrity": "sha512-B5JU3cabzk8c67mRRd3ECmROafjYMXbuzlwtqdM8IbS8ktlTix8aFGb2bAGKrSRIlnfKwovGUUr72JUPyOb6kQ==", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/os-tmpdir": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", - "integrity": "sha512-D2FR03Vir7FIu45XBY20mTb+/ZSWB00sjU9jdQXt83gDrI4Ztz5Fs7/yy74g2N5SVQY4xY1qDr4rNddwYRVX0g==", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/osenv": { - "version": "0.1.5", - "resolved": "https://registry.npmjs.org/osenv/-/osenv-0.1.5.tgz", - "integrity": "sha512-0CWcCECdMVc2Rw3U5w9ZjqX6ga6ubk1xDVKxtBQPK7wis/0F2r9T6k4ydGYhecl7YUBxBVxhL5oisPsNxAPe2g==", - "dependencies": { - "os-homedir": "^1.0.0", - "os-tmpdir": "^1.0.0" - } - }, - "node_modules/p-limit": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", - "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", - "dependencies": { - "yocto-queue": "^0.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/p-locate": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", - "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", - "dependencies": { - "p-limit": "^3.0.2" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/p-retry": { - "version": "4.6.2", - "resolved": "https://registry.npmjs.org/p-retry/-/p-retry-4.6.2.tgz", - "integrity": "sha512-312Id396EbJdvRONlngUx0NydfrIQ5lsYu0znKVUzVvArzEIt08V1qhtyESbGVd1FGX7UKtiFp5uwKZdM8wIuQ==", - "dependencies": { - "@types/retry": "0.12.0", - "retry": "^0.13.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/p-try": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", - "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", - "engines": { - "node": ">=6" - } - }, - "node_modules/param-case": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/param-case/-/param-case-3.0.4.tgz", - "integrity": "sha512-RXlj7zCYokReqWpOPH9oYivUzLYZ5vAPIfEmCTNViosC78F8F0H9y7T7gG2M39ymgutxF5gcFEsyZQSph9Bp3A==", - "dependencies": { - "dot-case": "^3.0.4", - "tslib": "^2.0.3" - } - }, - "node_modules/parent-module": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", - "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", - "dependencies": { - "callsites": "^3.0.0" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/parse-json": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-5.2.0.tgz", - "integrity": "sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==", - "dependencies": { - "@babel/code-frame": "^7.0.0", - "error-ex": "^1.3.1", - "json-parse-even-better-errors": "^2.3.0", - "lines-and-columns": "^1.1.6" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/parse5": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/parse5/-/parse5-6.0.1.tgz", - "integrity": "sha512-Ofn/CTFzRGTTxwpNEs9PP93gXShHcTq255nzRYSKe8AkVpZY7e1fpmTfOyoIvjP5HG7Z2ZM7VS9PPhQGW2pOpw==" - }, - "node_modules/parseurl": { - "version": "1.3.3", - "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", - "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/pascal-case": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/pascal-case/-/pascal-case-3.1.2.tgz", - "integrity": "sha512-uWlGT3YSnK9x3BQJaOdcZwrnV6hPpd8jFH1/ucpiLRPh/2zCVJKS19E4GvYHvaCcACn3foXZ0cLB9Wrx1KGe5g==", - "dependencies": { - "no-case": "^3.0.4", - "tslib": "^2.0.3" - } - }, - "node_modules/path-browserify": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-1.0.1.tgz", - "integrity": "sha512-b7uo2UCUOYZcnF/3ID0lulOJi/bafxa1xPe7ZPsammBSpjSWQkjNxlt635YGS2MiR9GjvuXCtz2emr3jbsz98g==" - }, - "node_modules/path-exists": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", - "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", - "engines": { - "node": ">=8" - } - }, - "node_modules/path-is-absolute": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/path-key": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", - "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", - "engines": { - "node": ">=8" - } - }, - "node_modules/path-parse": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", - "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==" - }, - "node_modules/path-to-regexp": { - "version": "0.1.7", - "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", - "integrity": "sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ==" - }, - "node_modules/path-type": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz", - "integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==", - "engines": { - "node": ">=8" - } - }, - "node_modules/performance-now": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", - "integrity": "sha512-7EAHlyLHI56VEIdK57uwHdHKIaAGbnXPiw0yWbarQZOKaKpvUIgW0jWRVLiatnM+XXlSwsanIBH/hzGMJulMow==" - }, - "node_modules/picocolors": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz", - "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==" - }, - "node_modules/picomatch": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", - "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", - "engines": { - "node": ">=8.6" - }, - "funding": { - "url": "https://github.com/sponsors/jonschlinkert" - } - }, - "node_modules/pify": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", - "integrity": "sha512-udgsAY+fTnvv7kI7aaxbqwWNb0AHiB0qBO89PZKPkoTmGOgdbrHDKD+0B2X4uTfJ/FT1R09r9gTsjUjNJotuog==", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/pirates": { - "version": "4.0.5", - "resolved": "https://registry.npmjs.org/pirates/-/pirates-4.0.5.tgz", - "integrity": "sha512-8V9+HQPupnaXMA23c5hvl69zXvTwTzyAYasnkb0Tts4XvO4CliqONMOnvlq26rkhLC3nWDFBJf73LU1e1VZLaQ==", - "engines": { - "node": ">= 6" - } - }, - "node_modules/pkg-dir": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz", - "integrity": "sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==", - "dependencies": { - "find-up": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/pkg-dir/node_modules/find-up": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", - "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", - "dependencies": { - "locate-path": "^5.0.0", - "path-exists": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/pkg-dir/node_modules/locate-path": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", - "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", - "dependencies": { - "p-locate": "^4.1.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/pkg-dir/node_modules/p-limit": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", - "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", - "dependencies": { - "p-try": "^2.0.0" - }, - "engines": { - "node": ">=6" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/pkg-dir/node_modules/p-locate": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", - "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", - "dependencies": { - "p-limit": "^2.2.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/pkg-up": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/pkg-up/-/pkg-up-3.1.0.tgz", - "integrity": "sha512-nDywThFk1i4BQK4twPQ6TA4RT8bDY96yeuCVBWL3ePARCiEKDRSrNGbFIgUJpLp+XeIR65v8ra7WuJOFUBtkMA==", - "dependencies": { - "find-up": "^3.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/pkg-up/node_modules/find-up": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", - "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", - "dependencies": { - "locate-path": "^3.0.0" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/pkg-up/node_modules/locate-path": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", - "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", - "dependencies": { - "p-locate": "^3.0.0", - "path-exists": "^3.0.0" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/pkg-up/node_modules/p-limit": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", - "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", - "dependencies": { - "p-try": "^2.0.0" - }, - "engines": { - "node": ">=6" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/pkg-up/node_modules/p-locate": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", - "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", - "dependencies": { - "p-limit": "^2.0.0" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/pkg-up/node_modules/path-exists": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", - "integrity": "sha512-bpC7GYwiDYQ4wYLe+FA8lhRjhQCMcQGuSgGGqDkg/QerRWw9CmGRT0iSOVRSZJ29NMLZgIzqaljJ63oaL4NIJQ==", - "engines": { - "node": ">=4" - } - }, - "node_modules/pngjs": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/pngjs/-/pngjs-5.0.0.tgz", - "integrity": "sha512-40QW5YalBNfQo5yRYmiw7Yz6TKKVr3h6970B2YE+3fQpsWcrbj1PzJgxeJ19DRQjhMbKPIuMY8rFaXc8moolVw==", - "engines": { - "node": ">=10.13.0" - } - }, - "node_modules/postcss": { - "version": "8.4.23", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.23.tgz", - "integrity": "sha512-bQ3qMcpF6A/YjR55xtoTr0jGOlnPOKAIMdOWiv0EIT6HVPEaJiJB4NLljSbiHoC2RX7DN5Uvjtpbg1NPdwv1oA==", - "funding": [ - { - "type": "opencollective", - "url": "https://opencollective.com/postcss/" - }, - { - "type": "tidelift", - "url": "https://tidelift.com/funding/github/npm/postcss" - }, - { - "type": "github", - "url": "https://github.com/sponsors/ai" - } - ], - "dependencies": { - "nanoid": "^3.3.6", - "picocolors": "^1.0.0", - "source-map-js": "^1.0.2" - }, - "engines": { - "node": "^10 || ^12 || >=14" - } - }, - "node_modules/postcss-attribute-case-insensitive": { - "version": "5.0.2", - "resolved": "https://registry.npmjs.org/postcss-attribute-case-insensitive/-/postcss-attribute-case-insensitive-5.0.2.tgz", - "integrity": "sha512-XIidXV8fDr0kKt28vqki84fRK8VW8eTuIa4PChv2MqKuT6C9UjmSKzen6KaWhWEoYvwxFCa7n/tC1SZ3tyq4SQ==", - "dependencies": { - "postcss-selector-parser": "^6.0.10" - }, - "engines": { - "node": "^12 || ^14 || >=16" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/csstools" - }, - "peerDependencies": { - "postcss": "^8.2" - } - }, - "node_modules/postcss-browser-comments": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/postcss-browser-comments/-/postcss-browser-comments-4.0.0.tgz", - "integrity": "sha512-X9X9/WN3KIvY9+hNERUqX9gncsgBA25XaeR+jshHz2j8+sYyHktHw1JdKuMjeLpGktXidqDhA7b/qm1mrBDmgg==", - "engines": { - "node": ">=8" - }, - "peerDependencies": { - "browserslist": ">=4", - "postcss": ">=8" - } - }, - "node_modules/postcss-calc": { - "version": "8.2.4", - "resolved": "https://registry.npmjs.org/postcss-calc/-/postcss-calc-8.2.4.tgz", - "integrity": "sha512-SmWMSJmB8MRnnULldx0lQIyhSNvuDl9HfrZkaqqE/WHAhToYsAvDq+yAsA/kIyINDszOp3Rh0GFoNuH5Ypsm3Q==", - "dependencies": { - "postcss-selector-parser": "^6.0.9", - "postcss-value-parser": "^4.2.0" - }, - "peerDependencies": { - "postcss": "^8.2.2" - } - }, - "node_modules/postcss-clamp": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/postcss-clamp/-/postcss-clamp-4.1.0.tgz", - "integrity": "sha512-ry4b1Llo/9zz+PKC+030KUnPITTJAHeOwjfAyyB60eT0AorGLdzp52s31OsPRHRf8NchkgFoG2y6fCfn1IV1Ow==", - "dependencies": { - "postcss-value-parser": "^4.2.0" - }, - "engines": { - "node": ">=7.6.0" - }, - "peerDependencies": { - "postcss": "^8.4.6" - } - }, - "node_modules/postcss-color-functional-notation": { - "version": "4.2.4", - "resolved": "https://registry.npmjs.org/postcss-color-functional-notation/-/postcss-color-functional-notation-4.2.4.tgz", - "integrity": "sha512-2yrTAUZUab9s6CpxkxC4rVgFEVaR6/2Pipvi6qcgvnYiVqZcbDHEoBDhrXzyb7Efh2CCfHQNtcqWcIruDTIUeg==", - "dependencies": { - "postcss-value-parser": "^4.2.0" - }, - "engines": { - "node": "^12 || ^14 || >=16" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/csstools" - }, - "peerDependencies": { - "postcss": "^8.2" - } - }, - "node_modules/postcss-color-hex-alpha": { - "version": "8.0.4", - "resolved": "https://registry.npmjs.org/postcss-color-hex-alpha/-/postcss-color-hex-alpha-8.0.4.tgz", - "integrity": "sha512-nLo2DCRC9eE4w2JmuKgVA3fGL3d01kGq752pVALF68qpGLmx2Qrk91QTKkdUqqp45T1K1XV8IhQpcu1hoAQflQ==", - "dependencies": { - "postcss-value-parser": "^4.2.0" - }, - "engines": { - "node": "^12 || ^14 || >=16" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/csstools" - }, - "peerDependencies": { - "postcss": "^8.4" - } - }, - "node_modules/postcss-color-rebeccapurple": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/postcss-color-rebeccapurple/-/postcss-color-rebeccapurple-7.1.1.tgz", - "integrity": "sha512-pGxkuVEInwLHgkNxUc4sdg4g3py7zUeCQ9sMfwyHAT+Ezk8a4OaaVZ8lIY5+oNqA/BXXgLyXv0+5wHP68R79hg==", - "dependencies": { - "postcss-value-parser": "^4.2.0" - }, - "engines": { - "node": "^12 || ^14 || >=16" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/csstools" - }, - "peerDependencies": { - "postcss": "^8.2" - } - }, - "node_modules/postcss-colormin": { - "version": "5.3.1", - "resolved": "https://registry.npmjs.org/postcss-colormin/-/postcss-colormin-5.3.1.tgz", - "integrity": "sha512-UsWQG0AqTFQmpBegeLLc1+c3jIqBNB0zlDGRWR+dQ3pRKJL1oeMzyqmH3o2PIfn9MBdNrVPWhDbT769LxCTLJQ==", - "dependencies": { - "browserslist": "^4.21.4", - "caniuse-api": "^3.0.0", - "colord": "^2.9.1", - "postcss-value-parser": "^4.2.0" - }, - "engines": { - "node": "^10 || ^12 || >=14.0" - }, - "peerDependencies": { - "postcss": "^8.2.15" - } - }, - "node_modules/postcss-convert-values": { - "version": "5.1.3", - "resolved": "https://registry.npmjs.org/postcss-convert-values/-/postcss-convert-values-5.1.3.tgz", - "integrity": "sha512-82pC1xkJZtcJEfiLw6UXnXVXScgtBrjlO5CBmuDQc+dlb88ZYheFsjTn40+zBVi3DkfF7iezO0nJUPLcJK3pvA==", - "dependencies": { - "browserslist": "^4.21.4", - "postcss-value-parser": "^4.2.0" - }, - "engines": { - "node": "^10 || ^12 || >=14.0" - }, - "peerDependencies": { - "postcss": "^8.2.15" - } - }, - "node_modules/postcss-custom-media": { - "version": "8.0.2", - "resolved": "https://registry.npmjs.org/postcss-custom-media/-/postcss-custom-media-8.0.2.tgz", - "integrity": "sha512-7yi25vDAoHAkbhAzX9dHx2yc6ntS4jQvejrNcC+csQJAXjj15e7VcWfMgLqBNAbOvqi5uIa9huOVwdHbf+sKqg==", - "dependencies": { - "postcss-value-parser": "^4.2.0" - }, - "engines": { - "node": "^12 || ^14 || >=16" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/csstools" - }, - "peerDependencies": { - "postcss": "^8.3" - } - }, - "node_modules/postcss-custom-properties": { - "version": "12.1.11", - "resolved": "https://registry.npmjs.org/postcss-custom-properties/-/postcss-custom-properties-12.1.11.tgz", - "integrity": "sha512-0IDJYhgU8xDv1KY6+VgUwuQkVtmYzRwu+dMjnmdMafXYv86SWqfxkc7qdDvWS38vsjaEtv8e0vGOUQrAiMBLpQ==", - "dependencies": { - "postcss-value-parser": "^4.2.0" - }, - "engines": { - "node": "^12 || ^14 || >=16" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/csstools" - }, - "peerDependencies": { - "postcss": "^8.2" - } - }, - "node_modules/postcss-custom-selectors": { - "version": "6.0.3", - "resolved": "https://registry.npmjs.org/postcss-custom-selectors/-/postcss-custom-selectors-6.0.3.tgz", - "integrity": "sha512-fgVkmyiWDwmD3JbpCmB45SvvlCD6z9CG6Ie6Iere22W5aHea6oWa7EM2bpnv2Fj3I94L3VbtvX9KqwSi5aFzSg==", - "dependencies": { - "postcss-selector-parser": "^6.0.4" - }, - "engines": { - "node": "^12 || ^14 || >=16" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/csstools" - }, - "peerDependencies": { - "postcss": "^8.3" - } - }, - "node_modules/postcss-dir-pseudo-class": { - "version": "6.0.5", - "resolved": "https://registry.npmjs.org/postcss-dir-pseudo-class/-/postcss-dir-pseudo-class-6.0.5.tgz", - "integrity": "sha512-eqn4m70P031PF7ZQIvSgy9RSJ5uI2171O/OO/zcRNYpJbvaeKFUlar1aJ7rmgiQtbm0FSPsRewjpdS0Oew7MPA==", - "dependencies": { - "postcss-selector-parser": "^6.0.10" - }, - "engines": { - "node": "^12 || ^14 || >=16" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/csstools" - }, - "peerDependencies": { - "postcss": "^8.2" - } - }, - "node_modules/postcss-discard-comments": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/postcss-discard-comments/-/postcss-discard-comments-5.1.2.tgz", - "integrity": "sha512-+L8208OVbHVF2UQf1iDmRcbdjJkuBF6IS29yBDSiWUIzpYaAhtNl6JYnYm12FnkeCwQqF5LeklOu6rAqgfBZqQ==", - "engines": { - "node": "^10 || ^12 || >=14.0" - }, - "peerDependencies": { - "postcss": "^8.2.15" - } - }, - "node_modules/postcss-discard-duplicates": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/postcss-discard-duplicates/-/postcss-discard-duplicates-5.1.0.tgz", - "integrity": "sha512-zmX3IoSI2aoenxHV6C7plngHWWhUOV3sP1T8y2ifzxzbtnuhk1EdPwm0S1bIUNaJ2eNbWeGLEwzw8huPD67aQw==", - "engines": { - "node": "^10 || ^12 || >=14.0" - }, - "peerDependencies": { - "postcss": "^8.2.15" - } - }, - "node_modules/postcss-discard-empty": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/postcss-discard-empty/-/postcss-discard-empty-5.1.1.tgz", - "integrity": "sha512-zPz4WljiSuLWsI0ir4Mcnr4qQQ5e1Ukc3i7UfE2XcrwKK2LIPIqE5jxMRxO6GbI3cv//ztXDsXwEWT3BHOGh3A==", - "engines": { - "node": "^10 || ^12 || >=14.0" - }, - "peerDependencies": { - "postcss": "^8.2.15" - } - }, - "node_modules/postcss-discard-overridden": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/postcss-discard-overridden/-/postcss-discard-overridden-5.1.0.tgz", - "integrity": "sha512-21nOL7RqWR1kasIVdKs8HNqQJhFxLsyRfAnUDm4Fe4t4mCWL9OJiHvlHPjcd8zc5Myu89b/7wZDnOSjFgeWRtw==", - "engines": { - "node": "^10 || ^12 || >=14.0" - }, - "peerDependencies": { - "postcss": "^8.2.15" - } - }, - "node_modules/postcss-double-position-gradients": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/postcss-double-position-gradients/-/postcss-double-position-gradients-3.1.2.tgz", - "integrity": "sha512-GX+FuE/uBR6eskOK+4vkXgT6pDkexLokPaz/AbJna9s5Kzp/yl488pKPjhy0obB475ovfT1Wv8ho7U/cHNaRgQ==", - "dependencies": { - "@csstools/postcss-progressive-custom-properties": "^1.1.0", - "postcss-value-parser": "^4.2.0" - }, - "engines": { - "node": "^12 || ^14 || >=16" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/csstools" - }, - "peerDependencies": { - "postcss": "^8.2" - } - }, - "node_modules/postcss-env-function": { - "version": "4.0.6", - "resolved": "https://registry.npmjs.org/postcss-env-function/-/postcss-env-function-4.0.6.tgz", - "integrity": "sha512-kpA6FsLra+NqcFnL81TnsU+Z7orGtDTxcOhl6pwXeEq1yFPpRMkCDpHhrz8CFQDr/Wfm0jLiNQ1OsGGPjlqPwA==", - "dependencies": { - "postcss-value-parser": "^4.2.0" - }, - "engines": { - "node": "^12 || ^14 || >=16" - }, - "peerDependencies": { - "postcss": "^8.4" - } - }, - "node_modules/postcss-flexbugs-fixes": { - "version": "5.0.2", - "resolved": "https://registry.npmjs.org/postcss-flexbugs-fixes/-/postcss-flexbugs-fixes-5.0.2.tgz", - "integrity": "sha512-18f9voByak7bTktR2QgDveglpn9DTbBWPUzSOe9g0N4WR/2eSt6Vrcbf0hmspvMI6YWGywz6B9f7jzpFNJJgnQ==", - "peerDependencies": { - "postcss": "^8.1.4" - } - }, - "node_modules/postcss-focus-visible": { - "version": "6.0.4", - "resolved": "https://registry.npmjs.org/postcss-focus-visible/-/postcss-focus-visible-6.0.4.tgz", - "integrity": "sha512-QcKuUU/dgNsstIK6HELFRT5Y3lbrMLEOwG+A4s5cA+fx3A3y/JTq3X9LaOj3OC3ALH0XqyrgQIgey/MIZ8Wczw==", - "dependencies": { - "postcss-selector-parser": "^6.0.9" - }, - "engines": { - "node": "^12 || ^14 || >=16" - }, - "peerDependencies": { - "postcss": "^8.4" - } - }, - "node_modules/postcss-focus-within": { - "version": "5.0.4", - "resolved": "https://registry.npmjs.org/postcss-focus-within/-/postcss-focus-within-5.0.4.tgz", - "integrity": "sha512-vvjDN++C0mu8jz4af5d52CB184ogg/sSxAFS+oUJQq2SuCe7T5U2iIsVJtsCp2d6R4j0jr5+q3rPkBVZkXD9fQ==", - "dependencies": { - "postcss-selector-parser": "^6.0.9" - }, - "engines": { - "node": "^12 || ^14 || >=16" - }, - "peerDependencies": { - "postcss": "^8.4" - } - }, - "node_modules/postcss-font-variant": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/postcss-font-variant/-/postcss-font-variant-5.0.0.tgz", - "integrity": "sha512-1fmkBaCALD72CK2a9i468mA/+tr9/1cBxRRMXOUaZqO43oWPR5imcyPjXwuv7PXbCid4ndlP5zWhidQVVa3hmA==", - "peerDependencies": { - "postcss": "^8.1.0" - } - }, - "node_modules/postcss-gap-properties": { - "version": "3.0.5", - "resolved": "https://registry.npmjs.org/postcss-gap-properties/-/postcss-gap-properties-3.0.5.tgz", - "integrity": "sha512-IuE6gKSdoUNcvkGIqdtjtcMtZIFyXZhmFd5RUlg97iVEvp1BZKV5ngsAjCjrVy+14uhGBQl9tzmi1Qwq4kqVOg==", - "engines": { - "node": "^12 || ^14 || >=16" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/csstools" - }, - "peerDependencies": { - "postcss": "^8.2" - } - }, - "node_modules/postcss-image-set-function": { - "version": "4.0.7", - "resolved": "https://registry.npmjs.org/postcss-image-set-function/-/postcss-image-set-function-4.0.7.tgz", - "integrity": "sha512-9T2r9rsvYzm5ndsBE8WgtrMlIT7VbtTfE7b3BQnudUqnBcBo7L758oc+o+pdj/dUV0l5wjwSdjeOH2DZtfv8qw==", - "dependencies": { - "postcss-value-parser": "^4.2.0" - }, - "engines": { - "node": "^12 || ^14 || >=16" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/csstools" - }, - "peerDependencies": { - "postcss": "^8.2" - } - }, - "node_modules/postcss-import": { - "version": "15.1.0", - "resolved": "https://registry.npmjs.org/postcss-import/-/postcss-import-15.1.0.tgz", - "integrity": "sha512-hpr+J05B2FVYUAXHeK1YyI267J/dDDhMU6B6civm8hSY1jYJnBXxzKDKDswzJmtLHryrjhnDjqqp/49t8FALew==", - "dependencies": { - "postcss-value-parser": "^4.0.0", - "read-cache": "^1.0.0", - "resolve": "^1.1.7" - }, - "engines": { - "node": ">=14.0.0" - }, - "peerDependencies": { - "postcss": "^8.0.0" - } - }, - "node_modules/postcss-initial": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/postcss-initial/-/postcss-initial-4.0.1.tgz", - "integrity": "sha512-0ueD7rPqX8Pn1xJIjay0AZeIuDoF+V+VvMt/uOnn+4ezUKhZM/NokDeP6DwMNyIoYByuN/94IQnt5FEkaN59xQ==", - "peerDependencies": { - "postcss": "^8.0.0" - } - }, - "node_modules/postcss-js": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/postcss-js/-/postcss-js-4.0.1.tgz", - "integrity": "sha512-dDLF8pEO191hJMtlHFPRa8xsizHaM82MLfNkUHdUtVEV3tgTp5oj+8qbEqYM57SLfc74KSbw//4SeJma2LRVIw==", - "dependencies": { - "camelcase-css": "^2.0.1" - }, - "engines": { - "node": "^12 || ^14 || >= 16" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/postcss/" - }, - "peerDependencies": { - "postcss": "^8.4.21" - } - }, - "node_modules/postcss-lab-function": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/postcss-lab-function/-/postcss-lab-function-4.2.1.tgz", - "integrity": "sha512-xuXll4isR03CrQsmxyz92LJB2xX9n+pZJ5jE9JgcnmsCammLyKdlzrBin+25dy6wIjfhJpKBAN80gsTlCgRk2w==", - "dependencies": { - "@csstools/postcss-progressive-custom-properties": "^1.1.0", - "postcss-value-parser": "^4.2.0" - }, - "engines": { - "node": "^12 || ^14 || >=16" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/csstools" - }, - "peerDependencies": { - "postcss": "^8.2" - } - }, - "node_modules/postcss-load-config": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/postcss-load-config/-/postcss-load-config-4.0.1.tgz", - "integrity": "sha512-vEJIc8RdiBRu3oRAI0ymerOn+7rPuMvRXslTvZUKZonDHFIczxztIyJ1urxM1x9JXEikvpWWTUUqal5j/8QgvA==", - "dependencies": { - "lilconfig": "^2.0.5", - "yaml": "^2.1.1" - }, - "engines": { - "node": ">= 14" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/postcss/" - }, - "peerDependencies": { - "postcss": ">=8.0.9", - "ts-node": ">=9.0.0" - }, - "peerDependenciesMeta": { - "postcss": { - "optional": true - }, - "ts-node": { - "optional": true - } - } - }, - "node_modules/postcss-load-config/node_modules/yaml": { - "version": "2.2.2", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.2.2.tgz", - "integrity": "sha512-CBKFWExMn46Foo4cldiChEzn7S7SRV+wqiluAb6xmueD/fGyRHIhX8m14vVGgeFWjN540nKCNVj6P21eQjgTuA==", - "engines": { - "node": ">= 14" - } - }, - "node_modules/postcss-loader": { - "version": "6.2.1", - "resolved": "https://registry.npmjs.org/postcss-loader/-/postcss-loader-6.2.1.tgz", - "integrity": "sha512-WbbYpmAaKcux/P66bZ40bpWsBucjx/TTgVVzRZ9yUO8yQfVBlameJ0ZGVaPfH64hNSBh63a+ICP5nqOpBA0w+Q==", - "dependencies": { - "cosmiconfig": "^7.0.0", - "klona": "^2.0.5", - "semver": "^7.3.5" - }, - "engines": { - "node": ">= 12.13.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/webpack" - }, - "peerDependencies": { - "postcss": "^7.0.0 || ^8.0.1", - "webpack": "^5.0.0" - } - }, - "node_modules/postcss-logical": { - "version": "5.0.4", - "resolved": "https://registry.npmjs.org/postcss-logical/-/postcss-logical-5.0.4.tgz", - "integrity": "sha512-RHXxplCeLh9VjinvMrZONq7im4wjWGlRJAqmAVLXyZaXwfDWP73/oq4NdIp+OZwhQUMj0zjqDfM5Fj7qby+B4g==", - "engines": { - "node": "^12 || ^14 || >=16" - }, - "peerDependencies": { - "postcss": "^8.4" - } - }, - "node_modules/postcss-media-minmax": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/postcss-media-minmax/-/postcss-media-minmax-5.0.0.tgz", - "integrity": "sha512-yDUvFf9QdFZTuCUg0g0uNSHVlJ5X1lSzDZjPSFaiCWvjgsvu8vEVxtahPrLMinIDEEGnx6cBe6iqdx5YWz08wQ==", - "engines": { - "node": ">=10.0.0" - }, - "peerDependencies": { - "postcss": "^8.1.0" - } - }, - "node_modules/postcss-merge-longhand": { - "version": "5.1.7", - "resolved": "https://registry.npmjs.org/postcss-merge-longhand/-/postcss-merge-longhand-5.1.7.tgz", - "integrity": "sha512-YCI9gZB+PLNskrK0BB3/2OzPnGhPkBEwmwhfYk1ilBHYVAZB7/tkTHFBAnCrvBBOmeYyMYw3DMjT55SyxMBzjQ==", - "dependencies": { - "postcss-value-parser": "^4.2.0", - "stylehacks": "^5.1.1" - }, - "engines": { - "node": "^10 || ^12 || >=14.0" - }, - "peerDependencies": { - "postcss": "^8.2.15" - } - }, - "node_modules/postcss-merge-rules": { - "version": "5.1.4", - "resolved": "https://registry.npmjs.org/postcss-merge-rules/-/postcss-merge-rules-5.1.4.tgz", - "integrity": "sha512-0R2IuYpgU93y9lhVbO/OylTtKMVcHb67zjWIfCiKR9rWL3GUk1677LAqD/BcHizukdZEjT8Ru3oHRoAYoJy44g==", - "dependencies": { - "browserslist": "^4.21.4", - "caniuse-api": "^3.0.0", - "cssnano-utils": "^3.1.0", - "postcss-selector-parser": "^6.0.5" - }, - "engines": { - "node": "^10 || ^12 || >=14.0" - }, - "peerDependencies": { - "postcss": "^8.2.15" - } - }, - "node_modules/postcss-minify-font-values": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/postcss-minify-font-values/-/postcss-minify-font-values-5.1.0.tgz", - "integrity": "sha512-el3mYTgx13ZAPPirSVsHqFzl+BBBDrXvbySvPGFnQcTI4iNslrPaFq4muTkLZmKlGk4gyFAYUBMH30+HurREyA==", - "dependencies": { - "postcss-value-parser": "^4.2.0" - }, - "engines": { - "node": "^10 || ^12 || >=14.0" - }, - "peerDependencies": { - "postcss": "^8.2.15" - } - }, - "node_modules/postcss-minify-gradients": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/postcss-minify-gradients/-/postcss-minify-gradients-5.1.1.tgz", - "integrity": "sha512-VGvXMTpCEo4qHTNSa9A0a3D+dxGFZCYwR6Jokk+/3oB6flu2/PnPXAh2x7x52EkY5xlIHLm+Le8tJxe/7TNhzw==", - "dependencies": { - "colord": "^2.9.1", - "cssnano-utils": "^3.1.0", - "postcss-value-parser": "^4.2.0" - }, - "engines": { - "node": "^10 || ^12 || >=14.0" - }, - "peerDependencies": { - "postcss": "^8.2.15" - } - }, - "node_modules/postcss-minify-params": { - "version": "5.1.4", - "resolved": "https://registry.npmjs.org/postcss-minify-params/-/postcss-minify-params-5.1.4.tgz", - "integrity": "sha512-+mePA3MgdmVmv6g+30rn57USjOGSAyuxUmkfiWpzalZ8aiBkdPYjXWtHuwJGm1v5Ojy0Z0LaSYhHaLJQB0P8Jw==", - "dependencies": { - "browserslist": "^4.21.4", - "cssnano-utils": "^3.1.0", - "postcss-value-parser": "^4.2.0" - }, - "engines": { - "node": "^10 || ^12 || >=14.0" - }, - "peerDependencies": { - "postcss": "^8.2.15" - } - }, - "node_modules/postcss-minify-selectors": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/postcss-minify-selectors/-/postcss-minify-selectors-5.2.1.tgz", - "integrity": "sha512-nPJu7OjZJTsVUmPdm2TcaiohIwxP+v8ha9NehQ2ye9szv4orirRU3SDdtUmKH+10nzn0bAyOXZ0UEr7OpvLehg==", - "dependencies": { - "postcss-selector-parser": "^6.0.5" - }, - "engines": { - "node": "^10 || ^12 || >=14.0" - }, - "peerDependencies": { - "postcss": "^8.2.15" - } - }, - "node_modules/postcss-modules-extract-imports": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/postcss-modules-extract-imports/-/postcss-modules-extract-imports-3.0.0.tgz", - "integrity": "sha512-bdHleFnP3kZ4NYDhuGlVK+CMrQ/pqUm8bx/oGL93K6gVwiclvX5x0n76fYMKuIGKzlABOy13zsvqjb0f92TEXw==", - "engines": { - "node": "^10 || ^12 || >= 14" - }, - "peerDependencies": { - "postcss": "^8.1.0" - } - }, - "node_modules/postcss-modules-local-by-default": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/postcss-modules-local-by-default/-/postcss-modules-local-by-default-4.0.2.tgz", - "integrity": "sha512-mR/pcIsQhU2UgKYOPjRCSgacmjn08pyrHk+Vrm8WEKjDWgqO43vdRkzmxyZOZWiKr6Ed9gpReQHhLUGVAcn9jw==", - "dependencies": { - "icss-utils": "^5.0.0", - "postcss-selector-parser": "^6.0.2", - "postcss-value-parser": "^4.1.0" - }, - "engines": { - "node": "^10 || ^12 || >= 14" - }, - "peerDependencies": { - "postcss": "^8.1.0" - } - }, - "node_modules/postcss-modules-scope": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/postcss-modules-scope/-/postcss-modules-scope-3.0.0.tgz", - "integrity": "sha512-hncihwFA2yPath8oZ15PZqvWGkWf+XUfQgUGamS4LqoP1anQLOsOJw0vr7J7IwLpoY9fatA2qiGUGmuZL0Iqlg==", - "dependencies": { - "postcss-selector-parser": "^6.0.4" - }, - "engines": { - "node": "^10 || ^12 || >= 14" - }, - "peerDependencies": { - "postcss": "^8.1.0" - } - }, - "node_modules/postcss-modules-values": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/postcss-modules-values/-/postcss-modules-values-4.0.0.tgz", - "integrity": "sha512-RDxHkAiEGI78gS2ofyvCsu7iycRv7oqw5xMWn9iMoR0N/7mf9D50ecQqUo5BZ9Zh2vH4bCUR/ktCqbB9m8vJjQ==", - "dependencies": { - "icss-utils": "^5.0.0" - }, - "engines": { - "node": "^10 || ^12 || >= 14" - }, - "peerDependencies": { - "postcss": "^8.1.0" - } - }, - "node_modules/postcss-nested": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/postcss-nested/-/postcss-nested-6.0.1.tgz", - "integrity": "sha512-mEp4xPMi5bSWiMbsgoPfcP74lsWLHkQbZc3sY+jWYd65CUwXrUaTp0fmNpa01ZcETKlIgUdFN/MpS2xZtqL9dQ==", - "dependencies": { - "postcss-selector-parser": "^6.0.11" - }, - "engines": { - "node": ">=12.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/postcss/" - }, - "peerDependencies": { - "postcss": "^8.2.14" - } - }, - "node_modules/postcss-nesting": { - "version": "10.2.0", - "resolved": "https://registry.npmjs.org/postcss-nesting/-/postcss-nesting-10.2.0.tgz", - "integrity": "sha512-EwMkYchxiDiKUhlJGzWsD9b2zvq/r2SSubcRrgP+jujMXFzqvANLt16lJANC+5uZ6hjI7lpRmI6O8JIl+8l1KA==", - "dependencies": { - "@csstools/selector-specificity": "^2.0.0", - "postcss-selector-parser": "^6.0.10" - }, - "engines": { - "node": "^12 || ^14 || >=16" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/csstools" - }, - "peerDependencies": { - "postcss": "^8.2" - } - }, - "node_modules/postcss-normalize": { - "version": "10.0.1", - "resolved": "https://registry.npmjs.org/postcss-normalize/-/postcss-normalize-10.0.1.tgz", - "integrity": "sha512-+5w18/rDev5mqERcG3W5GZNMJa1eoYYNGo8gB7tEwaos0ajk3ZXAI4mHGcNT47NE+ZnZD1pEpUOFLvltIwmeJA==", - "dependencies": { - "@csstools/normalize.css": "*", - "postcss-browser-comments": "^4", - "sanitize.css": "*" - }, - "engines": { - "node": ">= 12" - }, - "peerDependencies": { - "browserslist": ">= 4", - "postcss": ">= 8" - } - }, - "node_modules/postcss-normalize-charset": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/postcss-normalize-charset/-/postcss-normalize-charset-5.1.0.tgz", - "integrity": "sha512-mSgUJ+pd/ldRGVx26p2wz9dNZ7ji6Pn8VWBajMXFf8jk7vUoSrZ2lt/wZR7DtlZYKesmZI680qjr2CeFF2fbUg==", - "engines": { - "node": "^10 || ^12 || >=14.0" - }, - "peerDependencies": { - "postcss": "^8.2.15" - } - }, - "node_modules/postcss-normalize-display-values": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/postcss-normalize-display-values/-/postcss-normalize-display-values-5.1.0.tgz", - "integrity": "sha512-WP4KIM4o2dazQXWmFaqMmcvsKmhdINFblgSeRgn8BJ6vxaMyaJkwAzpPpuvSIoG/rmX3M+IrRZEz2H0glrQNEA==", - "dependencies": { - "postcss-value-parser": "^4.2.0" - }, - "engines": { - "node": "^10 || ^12 || >=14.0" - }, - "peerDependencies": { - "postcss": "^8.2.15" - } - }, - "node_modules/postcss-normalize-positions": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/postcss-normalize-positions/-/postcss-normalize-positions-5.1.1.tgz", - "integrity": "sha512-6UpCb0G4eofTCQLFVuI3EVNZzBNPiIKcA1AKVka+31fTVySphr3VUgAIULBhxZkKgwLImhzMR2Bw1ORK+37INg==", - "dependencies": { - "postcss-value-parser": "^4.2.0" - }, - "engines": { - "node": "^10 || ^12 || >=14.0" - }, - "peerDependencies": { - "postcss": "^8.2.15" - } - }, - "node_modules/postcss-normalize-repeat-style": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/postcss-normalize-repeat-style/-/postcss-normalize-repeat-style-5.1.1.tgz", - "integrity": "sha512-mFpLspGWkQtBcWIRFLmewo8aC3ImN2i/J3v8YCFUwDnPu3Xz4rLohDO26lGjwNsQxB3YF0KKRwspGzE2JEuS0g==", - "dependencies": { - "postcss-value-parser": "^4.2.0" - }, - "engines": { - "node": "^10 || ^12 || >=14.0" - }, - "peerDependencies": { - "postcss": "^8.2.15" - } - }, - "node_modules/postcss-normalize-string": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/postcss-normalize-string/-/postcss-normalize-string-5.1.0.tgz", - "integrity": "sha512-oYiIJOf4T9T1N4i+abeIc7Vgm/xPCGih4bZz5Nm0/ARVJ7K6xrDlLwvwqOydvyL3RHNf8qZk6vo3aatiw/go3w==", - "dependencies": { - "postcss-value-parser": "^4.2.0" - }, - "engines": { - "node": "^10 || ^12 || >=14.0" - }, - "peerDependencies": { - "postcss": "^8.2.15" - } - }, - "node_modules/postcss-normalize-timing-functions": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/postcss-normalize-timing-functions/-/postcss-normalize-timing-functions-5.1.0.tgz", - "integrity": "sha512-DOEkzJ4SAXv5xkHl0Wa9cZLF3WCBhF3o1SKVxKQAa+0pYKlueTpCgvkFAHfk+Y64ezX9+nITGrDZeVGgITJXjg==", - "dependencies": { - "postcss-value-parser": "^4.2.0" - }, - "engines": { - "node": "^10 || ^12 || >=14.0" - }, - "peerDependencies": { - "postcss": "^8.2.15" - } - }, - "node_modules/postcss-normalize-unicode": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/postcss-normalize-unicode/-/postcss-normalize-unicode-5.1.1.tgz", - "integrity": "sha512-qnCL5jzkNUmKVhZoENp1mJiGNPcsJCs1aaRmURmeJGES23Z/ajaln+EPTD+rBeNkSryI+2WTdW+lwcVdOikrpA==", - "dependencies": { - "browserslist": "^4.21.4", - "postcss-value-parser": "^4.2.0" - }, - "engines": { - "node": "^10 || ^12 || >=14.0" - }, - "peerDependencies": { - "postcss": "^8.2.15" - } - }, - "node_modules/postcss-normalize-url": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/postcss-normalize-url/-/postcss-normalize-url-5.1.0.tgz", - "integrity": "sha512-5upGeDO+PVthOxSmds43ZeMeZfKH+/DKgGRD7TElkkyS46JXAUhMzIKiCa7BabPeIy3AQcTkXwVVN7DbqsiCew==", - "dependencies": { - "normalize-url": "^6.0.1", - "postcss-value-parser": "^4.2.0" - }, - "engines": { - "node": "^10 || ^12 || >=14.0" - }, - "peerDependencies": { - "postcss": "^8.2.15" - } - }, - "node_modules/postcss-normalize-whitespace": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/postcss-normalize-whitespace/-/postcss-normalize-whitespace-5.1.1.tgz", - "integrity": "sha512-83ZJ4t3NUDETIHTa3uEg6asWjSBYL5EdkVB0sDncx9ERzOKBVJIUeDO9RyA9Zwtig8El1d79HBp0JEi8wvGQnA==", - "dependencies": { - "postcss-value-parser": "^4.2.0" - }, - "engines": { - "node": "^10 || ^12 || >=14.0" - }, - "peerDependencies": { - "postcss": "^8.2.15" - } - }, - "node_modules/postcss-opacity-percentage": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/postcss-opacity-percentage/-/postcss-opacity-percentage-1.1.3.tgz", - "integrity": "sha512-An6Ba4pHBiDtyVpSLymUUERMo2cU7s+Obz6BTrS+gxkbnSBNKSuD0AVUc+CpBMrpVPKKfoVz0WQCX+Tnst0i4A==", - "funding": [ - { - "type": "kofi", - "url": "https://ko-fi.com/mrcgrtz" - }, - { - "type": "liberapay", - "url": "https://liberapay.com/mrcgrtz" - } - ], - "engines": { - "node": "^12 || ^14 || >=16" - }, - "peerDependencies": { - "postcss": "^8.2" - } - }, - "node_modules/postcss-ordered-values": { - "version": "5.1.3", - "resolved": "https://registry.npmjs.org/postcss-ordered-values/-/postcss-ordered-values-5.1.3.tgz", - "integrity": "sha512-9UO79VUhPwEkzbb3RNpqqghc6lcYej1aveQteWY+4POIwlqkYE21HKWaLDF6lWNuqCobEAyTovVhtI32Rbv2RQ==", - "dependencies": { - "cssnano-utils": "^3.1.0", - "postcss-value-parser": "^4.2.0" - }, - "engines": { - "node": "^10 || ^12 || >=14.0" - }, - "peerDependencies": { - "postcss": "^8.2.15" - } - }, - "node_modules/postcss-overflow-shorthand": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/postcss-overflow-shorthand/-/postcss-overflow-shorthand-3.0.4.tgz", - "integrity": "sha512-otYl/ylHK8Y9bcBnPLo3foYFLL6a6Ak+3EQBPOTR7luMYCOsiVTUk1iLvNf6tVPNGXcoL9Hoz37kpfriRIFb4A==", - "dependencies": { - "postcss-value-parser": "^4.2.0" - }, - "engines": { - "node": "^12 || ^14 || >=16" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/csstools" - }, - "peerDependencies": { - "postcss": "^8.2" - } - }, - "node_modules/postcss-page-break": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/postcss-page-break/-/postcss-page-break-3.0.4.tgz", - "integrity": "sha512-1JGu8oCjVXLa9q9rFTo4MbeeA5FMe00/9C7lN4va606Rdb+HkxXtXsmEDrIraQ11fGz/WvKWa8gMuCKkrXpTsQ==", - "peerDependencies": { - "postcss": "^8" - } - }, - "node_modules/postcss-place": { - "version": "7.0.5", - "resolved": "https://registry.npmjs.org/postcss-place/-/postcss-place-7.0.5.tgz", - "integrity": "sha512-wR8igaZROA6Z4pv0d+bvVrvGY4GVHihBCBQieXFY3kuSuMyOmEnnfFzHl/tQuqHZkfkIVBEbDvYcFfHmpSet9g==", - "dependencies": { - "postcss-value-parser": "^4.2.0" - }, - "engines": { - "node": "^12 || ^14 || >=16" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/csstools" - }, - "peerDependencies": { - "postcss": "^8.2" - } - }, - "node_modules/postcss-preset-env": { - "version": "7.8.3", - "resolved": "https://registry.npmjs.org/postcss-preset-env/-/postcss-preset-env-7.8.3.tgz", - "integrity": "sha512-T1LgRm5uEVFSEF83vHZJV2z19lHg4yJuZ6gXZZkqVsqv63nlr6zabMH3l4Pc01FQCyfWVrh2GaUeCVy9Po+Aag==", - "dependencies": { - "@csstools/postcss-cascade-layers": "^1.1.1", - "@csstools/postcss-color-function": "^1.1.1", - "@csstools/postcss-font-format-keywords": "^1.0.1", - "@csstools/postcss-hwb-function": "^1.0.2", - "@csstools/postcss-ic-unit": "^1.0.1", - "@csstools/postcss-is-pseudo-class": "^2.0.7", - "@csstools/postcss-nested-calc": "^1.0.0", - "@csstools/postcss-normalize-display-values": "^1.0.1", - "@csstools/postcss-oklab-function": "^1.1.1", - "@csstools/postcss-progressive-custom-properties": "^1.3.0", - "@csstools/postcss-stepped-value-functions": "^1.0.1", - "@csstools/postcss-text-decoration-shorthand": "^1.0.0", - "@csstools/postcss-trigonometric-functions": "^1.0.2", - "@csstools/postcss-unset-value": "^1.0.2", - "autoprefixer": "^10.4.13", - "browserslist": "^4.21.4", - "css-blank-pseudo": "^3.0.3", - "css-has-pseudo": "^3.0.4", - "css-prefers-color-scheme": "^6.0.3", - "cssdb": "^7.1.0", - "postcss-attribute-case-insensitive": "^5.0.2", - "postcss-clamp": "^4.1.0", - "postcss-color-functional-notation": "^4.2.4", - "postcss-color-hex-alpha": "^8.0.4", - "postcss-color-rebeccapurple": "^7.1.1", - "postcss-custom-media": "^8.0.2", - "postcss-custom-properties": "^12.1.10", - "postcss-custom-selectors": "^6.0.3", - "postcss-dir-pseudo-class": "^6.0.5", - "postcss-double-position-gradients": "^3.1.2", - "postcss-env-function": "^4.0.6", - "postcss-focus-visible": "^6.0.4", - "postcss-focus-within": "^5.0.4", - "postcss-font-variant": "^5.0.0", - "postcss-gap-properties": "^3.0.5", - "postcss-image-set-function": "^4.0.7", - "postcss-initial": "^4.0.1", - "postcss-lab-function": "^4.2.1", - "postcss-logical": "^5.0.4", - "postcss-media-minmax": "^5.0.0", - "postcss-nesting": "^10.2.0", - "postcss-opacity-percentage": "^1.1.2", - "postcss-overflow-shorthand": "^3.0.4", - "postcss-page-break": "^3.0.4", - "postcss-place": "^7.0.5", - "postcss-pseudo-class-any-link": "^7.1.6", - "postcss-replace-overflow-wrap": "^4.0.0", - "postcss-selector-not": "^6.0.1", - "postcss-value-parser": "^4.2.0" - }, - "engines": { - "node": "^12 || ^14 || >=16" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/csstools" - }, - "peerDependencies": { - "postcss": "^8.2" - } - }, - "node_modules/postcss-pseudo-class-any-link": { - "version": "7.1.6", - "resolved": "https://registry.npmjs.org/postcss-pseudo-class-any-link/-/postcss-pseudo-class-any-link-7.1.6.tgz", - "integrity": "sha512-9sCtZkO6f/5ML9WcTLcIyV1yz9D1rf0tWc+ulKcvV30s0iZKS/ONyETvoWsr6vnrmW+X+KmuK3gV/w5EWnT37w==", - "dependencies": { - "postcss-selector-parser": "^6.0.10" - }, - "engines": { - "node": "^12 || ^14 || >=16" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/csstools" - }, - "peerDependencies": { - "postcss": "^8.2" - } - }, - "node_modules/postcss-reduce-initial": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/postcss-reduce-initial/-/postcss-reduce-initial-5.1.2.tgz", - "integrity": "sha512-dE/y2XRaqAi6OvjzD22pjTUQ8eOfc6m/natGHgKFBK9DxFmIm69YmaRVQrGgFlEfc1HePIurY0TmDeROK05rIg==", - "dependencies": { - "browserslist": "^4.21.4", - "caniuse-api": "^3.0.0" - }, - "engines": { - "node": "^10 || ^12 || >=14.0" - }, - "peerDependencies": { - "postcss": "^8.2.15" - } - }, - "node_modules/postcss-reduce-transforms": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/postcss-reduce-transforms/-/postcss-reduce-transforms-5.1.0.tgz", - "integrity": "sha512-2fbdbmgir5AvpW9RLtdONx1QoYG2/EtqpNQbFASDlixBbAYuTcJ0dECwlqNqH7VbaUnEnh8SrxOe2sRIn24XyQ==", - "dependencies": { - "postcss-value-parser": "^4.2.0" - }, - "engines": { - "node": "^10 || ^12 || >=14.0" - }, - "peerDependencies": { - "postcss": "^8.2.15" - } - }, - "node_modules/postcss-replace-overflow-wrap": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/postcss-replace-overflow-wrap/-/postcss-replace-overflow-wrap-4.0.0.tgz", - "integrity": "sha512-KmF7SBPphT4gPPcKZc7aDkweHiKEEO8cla/GjcBK+ckKxiZslIu3C4GCRW3DNfL0o7yW7kMQu9xlZ1kXRXLXtw==", - "peerDependencies": { - "postcss": "^8.0.3" - } - }, - "node_modules/postcss-selector-not": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/postcss-selector-not/-/postcss-selector-not-6.0.1.tgz", - "integrity": "sha512-1i9affjAe9xu/y9uqWH+tD4r6/hDaXJruk8xn2x1vzxC2U3J3LKO3zJW4CyxlNhA56pADJ/djpEwpH1RClI2rQ==", - "dependencies": { - "postcss-selector-parser": "^6.0.10" - }, - "engines": { - "node": "^12 || ^14 || >=16" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/csstools" - }, - "peerDependencies": { - "postcss": "^8.2" - } - }, - "node_modules/postcss-selector-parser": { - "version": "6.0.13", - "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-6.0.13.tgz", - "integrity": "sha512-EaV1Gl4mUEV4ddhDnv/xtj7sxwrwxdetHdWUGnT4VJQf+4d05v6lHYZr8N573k5Z0BViss7BDhfWtKS3+sfAqQ==", - "dependencies": { - "cssesc": "^3.0.0", - "util-deprecate": "^1.0.2" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/postcss-svgo": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/postcss-svgo/-/postcss-svgo-5.1.0.tgz", - "integrity": "sha512-D75KsH1zm5ZrHyxPakAxJWtkyXew5qwS70v56exwvw542d9CRtTo78K0WeFxZB4G7JXKKMbEZtZayTGdIky/eA==", - "dependencies": { - "postcss-value-parser": "^4.2.0", - "svgo": "^2.7.0" - }, - "engines": { - "node": "^10 || ^12 || >=14.0" - }, - "peerDependencies": { - "postcss": "^8.2.15" - } - }, - "node_modules/postcss-svgo/node_modules/commander": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-7.2.0.tgz", - "integrity": "sha512-QrWXB+ZQSVPmIWIhtEO9H+gwHaMGYiF5ChvoJ+K9ZGHG/sVsa6yiesAD1GC/x46sET00Xlwo1u49RVVVzvcSkw==", - "engines": { - "node": ">= 10" - } - }, - "node_modules/postcss-svgo/node_modules/css-tree": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/css-tree/-/css-tree-1.1.3.tgz", - "integrity": "sha512-tRpdppF7TRazZrjJ6v3stzv93qxRcSsFmW6cX0Zm2NVKpxE1WV1HblnghVv9TreireHkqI/VDEsfolRF1p6y7Q==", - "dependencies": { - "mdn-data": "2.0.14", - "source-map": "^0.6.1" - }, - "engines": { - "node": ">=8.0.0" - } - }, - "node_modules/postcss-svgo/node_modules/mdn-data": { - "version": "2.0.14", - "resolved": "https://registry.npmjs.org/mdn-data/-/mdn-data-2.0.14.tgz", - "integrity": "sha512-dn6wd0uw5GsdswPFfsgMp5NSB0/aDe6fK94YJV/AJDYXL6HVLWBsxeq7js7Ad+mU2K9LAlwpk6kN2D5mwCPVow==" - }, - "node_modules/postcss-svgo/node_modules/source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/postcss-svgo/node_modules/svgo": { - "version": "2.8.0", - "resolved": "https://registry.npmjs.org/svgo/-/svgo-2.8.0.tgz", - "integrity": "sha512-+N/Q9kV1+F+UeWYoSiULYo4xYSDQlTgb+ayMobAXPwMnLvop7oxKMo9OzIrX5x3eS4L4f2UHhc9axXwY8DpChg==", - "dependencies": { - "@trysound/sax": "0.2.0", - "commander": "^7.2.0", - "css-select": "^4.1.3", - "css-tree": "^1.1.3", - "csso": "^4.2.0", - "picocolors": "^1.0.0", - "stable": "^0.1.8" - }, - "bin": { - "svgo": "bin/svgo" - }, - "engines": { - "node": ">=10.13.0" - } - }, - "node_modules/postcss-unique-selectors": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/postcss-unique-selectors/-/postcss-unique-selectors-5.1.1.tgz", - "integrity": "sha512-5JiODlELrz8L2HwxfPnhOWZYWDxVHWL83ufOv84NrcgipI7TaeRsatAhK4Tr2/ZiYldpK/wBvw5BD3qfaK96GA==", - "dependencies": { - "postcss-selector-parser": "^6.0.5" - }, - "engines": { - "node": "^10 || ^12 || >=14.0" - }, - "peerDependencies": { - "postcss": "^8.2.15" - } - }, - "node_modules/postcss-value-parser": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/postcss-value-parser/-/postcss-value-parser-4.2.0.tgz", - "integrity": "sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ==" - }, - "node_modules/prelude-ls": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", - "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", - "engines": { - "node": ">= 0.8.0" - } - }, - "node_modules/pretty-bytes": { - "version": "5.6.0", - "resolved": "https://registry.npmjs.org/pretty-bytes/-/pretty-bytes-5.6.0.tgz", - "integrity": "sha512-FFw039TmrBqFK8ma/7OL3sDz/VytdtJr044/QUJtH0wK9lb9jLq9tJyIxUwtQJHwar2BqtiA4iCWSwo9JLkzFg==", - "engines": { - "node": ">=6" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/pretty-error": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/pretty-error/-/pretty-error-4.0.0.tgz", - "integrity": "sha512-AoJ5YMAcXKYxKhuJGdcvse+Voc6v1RgnsR3nWcYU7q4t6z0Q6T86sv5Zq8VIRbOWWFpvdGE83LtdSMNd+6Y0xw==", - "dependencies": { - "lodash": "^4.17.20", - "renderkid": "^3.0.0" - } - }, - "node_modules/pretty-format": { - "version": "27.5.1", - "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-27.5.1.tgz", - "integrity": "sha512-Qb1gy5OrP5+zDf2Bvnzdl3jsTf1qXVMazbvCoKhtKqVs4/YK4ozX4gKQJJVyNe+cajNPn0KoC0MC3FUmaHWEmQ==", - "dependencies": { - "ansi-regex": "^5.0.1", - "ansi-styles": "^5.0.0", - "react-is": "^17.0.1" - }, - "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" - } - }, - "node_modules/pretty-format/node_modules/ansi-styles": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-5.2.0.tgz", - "integrity": "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==", - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/prism-react-renderer": { - "version": "1.3.5", - "resolved": "https://registry.npmjs.org/prism-react-renderer/-/prism-react-renderer-1.3.5.tgz", - "integrity": "sha512-IJ+MSwBWKG+SM3b2SUfdrhC+gu01QkV2KmRQgREThBfSQRoufqRfxfHUxpG1WcaFjP+kojcFyO9Qqtpgt3qLCg==", - "peerDependencies": { - "react": ">=0.14.9" - } - }, - "node_modules/process-nextick-args": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", - "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==" - }, - "node_modules/progress": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz", - "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==", - "engines": { - "node": ">=0.4.0" - } - }, - "node_modules/promise": { - "version": "8.3.0", - "resolved": "https://registry.npmjs.org/promise/-/promise-8.3.0.tgz", - "integrity": "sha512-rZPNPKTOYVNEEKFaq1HqTgOwZD+4/YHS5ukLzQCypkj+OkYx7iv0mA91lJlpPPZ8vMau3IIGj5Qlwrx+8iiSmg==", - "dependencies": { - "asap": "~2.0.6" - } - }, - "node_modules/prompts": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/prompts/-/prompts-2.4.2.tgz", - "integrity": "sha512-NxNv/kLguCA7p3jE8oL2aEBsrJWgAakBpgmgK6lpPWV+WuOmY6r2/zbAVnP+T8bQlA0nzHXSJSJW0Hq7ylaD2Q==", - "dependencies": { - "kleur": "^3.0.3", - "sisteransi": "^1.0.5" - }, - "engines": { - "node": ">= 6" - } - }, - "node_modules/prop-types": { - "version": "15.8.1", - "resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz", - "integrity": "sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==", - "dependencies": { - "loose-envify": "^1.4.0", - "object-assign": "^4.1.1", - "react-is": "^16.13.1" - } - }, - "node_modules/prop-types/node_modules/react-is": { - "version": "16.13.1", - "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", - "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==" - }, - "node_modules/prosemirror-changeset": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/prosemirror-changeset/-/prosemirror-changeset-2.2.1.tgz", - "integrity": "sha512-J7msc6wbxB4ekDFj+n9gTW/jav/p53kdlivvuppHsrZXCaQdVgRghoZbSS3kwrRyAstRVQ4/+u5k7YfLgkkQvQ==", - "peer": true, - "dependencies": { - "prosemirror-transform": "^1.0.0" - } - }, - "node_modules/prosemirror-collab": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/prosemirror-collab/-/prosemirror-collab-1.3.1.tgz", - "integrity": "sha512-4SnynYR9TTYaQVXd/ieUvsVV4PDMBzrq2xPUWutHivDuOshZXqQ5rGbZM84HEaXKbLdItse7weMGOUdDVcLKEQ==", - "peer": true, - "dependencies": { - "prosemirror-state": "^1.0.0" - } - }, - "node_modules/prosemirror-commands": { - "version": "1.5.2", - "resolved": "https://registry.npmjs.org/prosemirror-commands/-/prosemirror-commands-1.5.2.tgz", - "integrity": "sha512-hgLcPaakxH8tu6YvVAaILV2tXYsW3rAdDR8WNkeKGcgeMVQg3/TMhPdVoh7iAmfgVjZGtcOSjKiQaoeKjzd2mQ==", - "peer": true, - "dependencies": { - "prosemirror-model": "^1.0.0", - "prosemirror-state": "^1.0.0", - "prosemirror-transform": "^1.0.0" - } - }, - "node_modules/prosemirror-dropcursor": { - "version": "1.8.1", - "resolved": "https://registry.npmjs.org/prosemirror-dropcursor/-/prosemirror-dropcursor-1.8.1.tgz", - "integrity": "sha512-M30WJdJZLyXHi3N8vxN6Zh5O8ZBbQCz0gURTfPmTIBNQ5pxrdU7A58QkNqfa98YEjSAL1HUyyU34f6Pm5xBSGw==", - "peer": true, - "dependencies": { - "prosemirror-state": "^1.0.0", - "prosemirror-transform": "^1.1.0", - "prosemirror-view": "^1.1.0" - } - }, - "node_modules/prosemirror-gapcursor": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/prosemirror-gapcursor/-/prosemirror-gapcursor-1.3.2.tgz", - "integrity": "sha512-wtjswVBd2vaQRrnYZaBCbyDqr232Ed4p2QPtRIUK5FuqHYKGWkEwl08oQM4Tw7DOR0FsasARV5uJFvMZWxdNxQ==", - "peer": true, - "dependencies": { - "prosemirror-keymap": "^1.0.0", - "prosemirror-model": "^1.0.0", - "prosemirror-state": "^1.0.0", - "prosemirror-view": "^1.0.0" - } - }, - "node_modules/prosemirror-history": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/prosemirror-history/-/prosemirror-history-1.3.2.tgz", - "integrity": "sha512-/zm0XoU/N/+u7i5zepjmZAEnpvjDtzoPWW6VmKptcAnPadN/SStsBjMImdCEbb3seiNTpveziPTIrXQbHLtU1g==", - "peer": true, - "dependencies": { - "prosemirror-state": "^1.2.2", - "prosemirror-transform": "^1.0.0", - "prosemirror-view": "^1.31.0", - "rope-sequence": "^1.3.0" - } - }, - "node_modules/prosemirror-inputrules": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/prosemirror-inputrules/-/prosemirror-inputrules-1.2.1.tgz", - "integrity": "sha512-3LrWJX1+ULRh5SZvbIQlwZafOXqp1XuV21MGBu/i5xsztd+9VD15x6OtN6mdqSFI7/8Y77gYUbQ6vwwJ4mr6QQ==", - "peer": true, - "dependencies": { - "prosemirror-state": "^1.0.0", - "prosemirror-transform": "^1.0.0" - } - }, - "node_modules/prosemirror-keymap": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/prosemirror-keymap/-/prosemirror-keymap-1.2.2.tgz", - "integrity": "sha512-EAlXoksqC6Vbocqc0GtzCruZEzYgrn+iiGnNjsJsH4mrnIGex4qbLdWWNza3AW5W36ZRrlBID0eM6bdKH4OStQ==", - "peer": true, - "dependencies": { - "prosemirror-state": "^1.0.0", - "w3c-keyname": "^2.2.0" - } - }, - "node_modules/prosemirror-markdown": { - "version": "1.11.0", - "resolved": "https://registry.npmjs.org/prosemirror-markdown/-/prosemirror-markdown-1.11.0.tgz", - "integrity": "sha512-yP9mZqPRstjZhhf3yykCQNE3AijxARrHe4e7esV9A+gp4cnGOH4QvrKYPpXLHspNWyvJJ+0URH+iIvV5qP1I2Q==", - "peer": true, - "dependencies": { - "markdown-it": "^13.0.1", - "prosemirror-model": "^1.0.0" - } - }, - "node_modules/prosemirror-menu": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/prosemirror-menu/-/prosemirror-menu-1.2.2.tgz", - "integrity": "sha512-437HIWTq4F9cTX+kPfqZWWm+luJm95Aut/mLUy+9OMrOml0bmWDS26ceC6SNfb2/S94et1sZ186vLO7pDHzxSw==", - "peer": true, - "dependencies": { - "crelt": "^1.0.0", - "prosemirror-commands": "^1.0.0", - "prosemirror-history": "^1.0.0", - "prosemirror-state": "^1.0.0" - } - }, - "node_modules/prosemirror-model": { - "version": "1.19.2", - "resolved": "https://registry.npmjs.org/prosemirror-model/-/prosemirror-model-1.19.2.tgz", - "integrity": "sha512-RXl0Waiss4YtJAUY3NzKH0xkJmsZupCIccqcIFoLTIKFlKNbIvFDRl27/kQy1FP8iUAxrjRRfIVvOebnnXJgqQ==", - "peer": true, - "dependencies": { - "orderedmap": "^2.0.0" - } - }, - "node_modules/prosemirror-schema-basic": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/prosemirror-schema-basic/-/prosemirror-schema-basic-1.2.2.tgz", - "integrity": "sha512-/dT4JFEGyO7QnNTe9UaKUhjDXbTNkiWTq/N4VpKaF79bBjSExVV2NXmJpcM7z/gD7mbqNjxbmWW5nf1iNSSGnw==", - "peer": true, - "dependencies": { - "prosemirror-model": "^1.19.0" - } - }, - "node_modules/prosemirror-schema-list": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/prosemirror-schema-list/-/prosemirror-schema-list-1.2.3.tgz", - "integrity": "sha512-HD8yjDOusz7JB3oBFCaMOpEN9Z9DZttLr6tcASjnvKMc0qTyX5xgAN8YiMFFEcwyhF7WZrZ2YQkAwzsn8ICVbQ==", - "peer": true, - "dependencies": { - "prosemirror-model": "^1.0.0", - "prosemirror-state": "^1.0.0", - "prosemirror-transform": "^1.0.0" - } - }, - "node_modules/prosemirror-state": { - "version": "1.4.3", - "resolved": "https://registry.npmjs.org/prosemirror-state/-/prosemirror-state-1.4.3.tgz", - "integrity": "sha512-goFKORVbvPuAQaXhpbemJFRKJ2aixr+AZMGiquiqKxaucC6hlpHNZHWgz5R7dS4roHiwq9vDctE//CZ++o0W1Q==", - "peer": true, - "dependencies": { - "prosemirror-model": "^1.0.0", - "prosemirror-transform": "^1.0.0", - "prosemirror-view": "^1.27.0" - } - }, - "node_modules/prosemirror-tables": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/prosemirror-tables/-/prosemirror-tables-1.3.2.tgz", - "integrity": "sha512-/9JTeN6s58Zq66HXaxP6uf8PAmc7XXKZFPlOGVtLvxEd6xBP6WtzaJB9wBjiGUzwbdhdMEy7V62yuHqk/3VrnQ==", - "peer": true, - "dependencies": { - "prosemirror-keymap": "^1.1.2", - "prosemirror-model": "^1.8.1", - "prosemirror-state": "^1.3.1", - "prosemirror-transform": "^1.2.1", - "prosemirror-view": "^1.13.3" - } - }, - "node_modules/prosemirror-trailing-node": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/prosemirror-trailing-node/-/prosemirror-trailing-node-2.0.4.tgz", - "integrity": "sha512-0Yl9w7IdHkaCdqR+NE3FOucePME4OmiGcybnF1iasarEILP5U8+4xTnl53yafULjmwcg1SrSG65Hg7Zk2H2v3g==", - "peer": true, - "dependencies": { - "@babel/runtime": "^7.21.0", - "@remirror/core-constants": "^2.0.1", - "@remirror/core-helpers": "^2.0.2", - "escape-string-regexp": "^4.0.0" - }, - "peerDependencies": { - "prosemirror-model": "^1.19.0", - "prosemirror-state": "^1.4.2", - "prosemirror-view": "^1.30.2" - } - }, - "node_modules/prosemirror-trailing-node/node_modules/escape-string-regexp": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", - "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", - "peer": true, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/prosemirror-transform": { - "version": "1.7.2", - "resolved": "https://registry.npmjs.org/prosemirror-transform/-/prosemirror-transform-1.7.2.tgz", - "integrity": "sha512-b94lVUdA9NyaYRb2WuGSgb5YANiITa05dtew9eSK+KkYu64BCnU27WhJPE95gAWAnhV57CM3FabWXM23gri8Kg==", - "peer": true, - "dependencies": { - "prosemirror-model": "^1.0.0" - } - }, - "node_modules/prosemirror-view": { - "version": "1.31.3", - "resolved": "https://registry.npmjs.org/prosemirror-view/-/prosemirror-view-1.31.3.tgz", - "integrity": "sha512-UYDa8WxRFZm0xQLXiPJUVTl6H08Fn0IUVDootA7ZlQwzooqVWnBOXLovJyyTKgws1nprfsPhhlvWgt2jo4ZA6g==", - "peer": true, - "dependencies": { - "prosemirror-model": "^1.16.0", - "prosemirror-state": "^1.0.0", - "prosemirror-transform": "^1.1.0" - } - }, - "node_modules/proxy-addr": { - "version": "2.0.7", - "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", - "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==", - "dependencies": { - "forwarded": "0.2.0", - "ipaddr.js": "1.9.1" - }, - "engines": { - "node": ">= 0.10" - } - }, - "node_modules/proxy-addr/node_modules/ipaddr.js": { - "version": "1.9.1", - "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", - "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==", - "engines": { - "node": ">= 0.10" - } - }, - "node_modules/proxy-from-env": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", - "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==" - }, - "node_modules/psl": { - "version": "1.9.0", - "resolved": "https://registry.npmjs.org/psl/-/psl-1.9.0.tgz", - "integrity": "sha512-E/ZsdU4HLs/68gYzgGTkMicWTLPdAftJLfJFlLUAAKZGkStNU72sZjT66SnMDVOfOWY/YAoiD7Jxa9iHvngcag==" - }, - "node_modules/punycode": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.0.tgz", - "integrity": "sha512-rRV+zQD8tVFys26lAGR9WUuS4iUAngJScM+ZRSKtvl5tKeZ2t5bvdNFdNHBW9FWR4guGHlgmsZ1G7BSm2wTbuA==", - "engines": { - "node": ">=6" - } - }, - "node_modules/pvtsutils": { - "version": "1.3.5", - "resolved": "https://registry.npmjs.org/pvtsutils/-/pvtsutils-1.3.5.tgz", - "integrity": "sha512-ARvb14YB9Nm2Xi6nBq1ZX6dAM0FsJnuk+31aUp4TrcZEdKUlSqOqsxJHUPJDNE3qiIp+iUPEIeR6Je/tgV7zsA==", - "dependencies": { - "tslib": "^2.6.1" - } - }, - "node_modules/q": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/q/-/q-1.5.1.tgz", - "integrity": "sha512-kV/CThkXo6xyFEZUugw/+pIOywXcDbFYgSct5cT3gqlbkBE1SJdwy6UQoZvodiWF/ckQLZyDE/Bu1M6gVu5lVw==", - "engines": { - "node": ">=0.6.0", - "teleport": ">=0.2.0" - } - }, - "node_modules/qrcode": { - "version": "1.5.3", - "resolved": "https://registry.npmjs.org/qrcode/-/qrcode-1.5.3.tgz", - "integrity": "sha512-puyri6ApkEHYiVl4CFzo1tDkAZ+ATcnbJrJ6RiBM1Fhctdn/ix9MTE3hRph33omisEbC/2fcfemsseiKgBPKZg==", - "dependencies": { - "dijkstrajs": "^1.0.1", - "encode-utf8": "^1.0.3", - "pngjs": "^5.0.0", - "yargs": "^15.3.1" - }, - "bin": { - "qrcode": "bin/qrcode" - }, - "engines": { - "node": ">=10.13.0" - } - }, - "node_modules/qrcode/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/qrcode/node_modules/camelcase": { - "version": "5.3.1", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", - "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", - "engines": { - "node": ">=6" - } - }, - "node_modules/qrcode/node_modules/cliui": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-6.0.0.tgz", - "integrity": "sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ==", - "dependencies": { - "string-width": "^4.2.0", - "strip-ansi": "^6.0.0", - "wrap-ansi": "^6.2.0" - } - }, - "node_modules/qrcode/node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/qrcode/node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" - }, - "node_modules/qrcode/node_modules/find-up": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", - "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", - "dependencies": { - "locate-path": "^5.0.0", - "path-exists": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/qrcode/node_modules/locate-path": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", - "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", - "dependencies": { - "p-locate": "^4.1.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/qrcode/node_modules/p-limit": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", - "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", - "dependencies": { - "p-try": "^2.0.0" - }, - "engines": { - "node": ">=6" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/qrcode/node_modules/p-locate": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", - "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", - "dependencies": { - "p-limit": "^2.2.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/qrcode/node_modules/wrap-ansi": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz", - "integrity": "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==", - "dependencies": { - "ansi-styles": "^4.0.0", - "string-width": "^4.1.0", - "strip-ansi": "^6.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/qrcode/node_modules/y18n": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.3.tgz", - "integrity": "sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ==" - }, - "node_modules/qrcode/node_modules/yargs": { - "version": "15.4.1", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-15.4.1.tgz", - "integrity": "sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A==", - "dependencies": { - "cliui": "^6.0.0", - "decamelize": "^1.2.0", - "find-up": "^4.1.0", - "get-caller-file": "^2.0.1", - "require-directory": "^2.1.1", - "require-main-filename": "^2.0.0", - "set-blocking": "^2.0.0", - "string-width": "^4.2.0", - "which-module": "^2.0.0", - "y18n": "^4.0.0", - "yargs-parser": "^18.1.2" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/qrcode/node_modules/yargs-parser": { - "version": "18.1.3", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-18.1.3.tgz", - "integrity": "sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==", - "dependencies": { - "camelcase": "^5.0.0", - "decamelize": "^1.2.0" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/qs": { - "version": "6.11.0", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz", - "integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==", - "dependencies": { - "side-channel": "^1.0.4" - }, - "engines": { - "node": ">=0.6" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/querystring": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/querystring/-/querystring-0.2.0.tgz", - "integrity": "sha512-X/xY82scca2tau62i9mDyU9K+I+djTMUsvwf7xnUX5GLvVzgJybOJf4Y6o9Zx3oJK/LSXg5tTZBjwzqVPaPO2g==", - "deprecated": "The querystring API is considered Legacy. new code should use the URLSearchParams API instead.", - "engines": { - "node": ">=0.4.x" - } - }, - "node_modules/querystringify": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/querystringify/-/querystringify-2.2.0.tgz", - "integrity": "sha512-FIqgj2EUvTa7R50u0rGsyTftzjYmv/a3hO345bZNrqabNqjtgiDMgmo4mkUjd+nzU5oF3dClKqFIPUKybUyqoQ==" - }, - "node_modules/queue-microtask": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", - "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ] - }, - "node_modules/raf": { - "version": "3.4.1", - "resolved": "https://registry.npmjs.org/raf/-/raf-3.4.1.tgz", - "integrity": "sha512-Sq4CW4QhwOHE8ucn6J34MqtZCeWFP2aQSmrlroYgqAV1PjStIhJXxYuTgUIfkEk7zTLjmIjLmU5q+fbD1NnOJA==", - "dependencies": { - "performance-now": "^2.1.0" - } - }, - "node_modules/randombytes": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", - "integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==", - "dependencies": { - "safe-buffer": "^5.1.0" - } - }, - "node_modules/range-parser": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", - "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/raw-body": { - "version": "2.5.1", - "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.1.tgz", - "integrity": "sha512-qqJBtEyVgS0ZmPGdCFPWJ3FreoqvG4MVQln/kCgF7Olq95IbOp0/BWyMwbdtn4VTvkM8Y7khCQ2Xgk/tcrCXig==", - "dependencies": { - "bytes": "3.1.2", - "http-errors": "2.0.0", - "iconv-lite": "0.4.24", - "unpipe": "1.0.0" - }, - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/raw-body/node_modules/bytes": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", - "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==", - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/raw-body/node_modules/iconv-lite": { - "version": "0.4.24", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", - "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", - "dependencies": { - "safer-buffer": ">= 2.1.2 < 3" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/rc": { - "version": "1.2.8", - "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz", - "integrity": "sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==", - "dependencies": { - "deep-extend": "^0.6.0", - "ini": "~1.3.0", - "minimist": "^1.2.0", - "strip-json-comments": "~2.0.1" - }, - "bin": { - "rc": "cli.js" - } - }, - "node_modules/rc/node_modules/strip-json-comments": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", - "integrity": "sha512-4gB8na07fecVVkOI6Rs4e7T6NOTki5EmL7TUduTs6bu3EdnSycntVJ4re8kgZA+wx9IueI2Y11bfbgwtzuE0KQ==", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/react": { - "version": "18.2.0", - "resolved": "https://registry.npmjs.org/react/-/react-18.2.0.tgz", - "integrity": "sha512-/3IjMdb2L9QbBdWiW5e3P2/npwMBaU9mHCSCUzNln0ZCYbcfTsGbTJrU/kGemdH2IWmB2ioZ+zkxtmq6g09fGQ==", - "dependencies": { - "loose-envify": "^1.1.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/react-app-polyfill": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/react-app-polyfill/-/react-app-polyfill-3.0.0.tgz", - "integrity": "sha512-sZ41cxiU5llIB003yxxQBYrARBqe0repqPTTYBTmMqTz9szeBbE37BehCE891NZsmdZqqP+xWKdT3eo3vOzN8w==", - "dependencies": { - "core-js": "^3.19.2", - "object-assign": "^4.1.1", - "promise": "^8.1.0", - "raf": "^3.4.1", - "regenerator-runtime": "^0.13.9", - "whatwg-fetch": "^3.6.2" - }, - "engines": { - "node": ">=14" - } - }, - "node_modules/react-dev-utils": { - "version": "12.0.1", - "resolved": "https://registry.npmjs.org/react-dev-utils/-/react-dev-utils-12.0.1.tgz", - "integrity": "sha512-84Ivxmr17KjUupyqzFode6xKhjwuEJDROWKJy/BthkL7Wn6NJ8h4WE6k/exAv6ImS+0oZLRRW5j/aINMHyeGeQ==", - "dependencies": { - "@babel/code-frame": "^7.16.0", - "address": "^1.1.2", - "browserslist": "^4.18.1", - "chalk": "^4.1.2", - "cross-spawn": "^7.0.3", - "detect-port-alt": "^1.1.6", - "escape-string-regexp": "^4.0.0", - "filesize": "^8.0.6", - "find-up": "^5.0.0", - "fork-ts-checker-webpack-plugin": "^6.5.0", - "global-modules": "^2.0.0", - "globby": "^11.0.4", - "gzip-size": "^6.0.0", - "immer": "^9.0.7", - "is-root": "^2.1.0", - "loader-utils": "^3.2.0", - "open": "^8.4.0", - "pkg-up": "^3.1.0", - "prompts": "^2.4.2", - "react-error-overlay": "^6.0.11", - "recursive-readdir": "^2.2.2", - "shell-quote": "^1.7.3", - "strip-ansi": "^6.0.1", - "text-table": "^0.2.0" - }, - "engines": { - "node": ">=14" - } - }, - "node_modules/react-dev-utils/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/react-dev-utils/node_modules/chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dependencies": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" - } - }, - "node_modules/react-dev-utils/node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/react-dev-utils/node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" - }, - "node_modules/react-dev-utils/node_modules/escape-string-regexp": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", - "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/react-dev-utils/node_modules/has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "engines": { - "node": ">=8" - } - }, - "node_modules/react-dev-utils/node_modules/loader-utils": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-3.2.1.tgz", - "integrity": "sha512-ZvFw1KWS3GVyYBYb7qkmRM/WwL2TQQBxgCK62rlvm4WpVQ23Nb4tYjApUlfjrEGvOs7KHEsmyUn75OHZrJMWPw==", - "engines": { - "node": ">= 12.13.0" - } - }, - "node_modules/react-dev-utils/node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/react-dom": { - "version": "18.2.0", - "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-18.2.0.tgz", - "integrity": "sha512-6IMTriUmvsjHUjNtEDudZfuDQUoWXVxKHhlEGSk81n4YFS+r/Kl99wXiwlVXtPBtJenozv2P+hxDsw9eA7Xo6g==", - "dependencies": { - "loose-envify": "^1.1.0", - "scheduler": "^0.23.0" - }, - "peerDependencies": { - "react": "^18.2.0" - } - }, - "node_modules/react-dropzone": { - "version": "14.2.3", - "resolved": "https://registry.npmjs.org/react-dropzone/-/react-dropzone-14.2.3.tgz", - "integrity": "sha512-O3om8I+PkFKbxCukfIR3QAGftYXDZfOE2N1mr/7qebQJHs7U+/RSL/9xomJNpRg9kM5h9soQSdf0Gc7OHF5Fug==", - "dependencies": { - "attr-accept": "^2.2.2", - "file-selector": "^0.6.0", - "prop-types": "^15.8.1" - }, - "engines": { - "node": ">= 10.13" - }, - "peerDependencies": { - "react": ">= 16.8 || 18.0.0" - } - }, - "node_modules/react-error-overlay": { - "version": "6.0.11", - "resolved": "https://registry.npmjs.org/react-error-overlay/-/react-error-overlay-6.0.11.tgz", - "integrity": "sha512-/6UZ2qgEyH2aqzYZgQPxEnz33NJ2gNsnHA2o5+o4wW9bLM/JYQitNP9xPhsXwC08hMMovfGe/8retsdDsczPRg==" - }, - "node_modules/react-is": { - "version": "17.0.2", - "resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz", - "integrity": "sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==" - }, - "node_modules/react-refresh": { - "version": "0.11.0", - "resolved": "https://registry.npmjs.org/react-refresh/-/react-refresh-0.11.0.tgz", - "integrity": "sha512-F27qZr8uUqwhWZboondsPx8tnC3Ct3SxZA3V5WyEvujRyyNv0VYPhoBg1gZ8/MV5tubQp76Trw8lTv9hzRBa+A==", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/react-remove-scroll": { - "version": "2.5.6", - "resolved": "https://registry.npmjs.org/react-remove-scroll/-/react-remove-scroll-2.5.6.tgz", - "integrity": "sha512-bO856ad1uDYLefgArk559IzUNeQ6SWH4QnrevIUjH+GczV56giDfl3h0Idptf2oIKxQmd1p9BN25jleKodTALg==", - "dependencies": { - "react-remove-scroll-bar": "^2.3.4", - "react-style-singleton": "^2.2.1", - "tslib": "^2.1.0", - "use-callback-ref": "^1.3.0", - "use-sidecar": "^1.1.2" - }, - "engines": { - "node": ">=10" - }, - "peerDependencies": { - "@types/react": "^16.8.0 || ^17.0.0 || ^18.0.0", - "react": "^16.8.0 || ^17.0.0 || ^18.0.0" - }, - "peerDependenciesMeta": { - "@types/react": { - "optional": true - } - } - }, - "node_modules/react-remove-scroll-bar": { - "version": "2.3.4", - "resolved": "https://registry.npmjs.org/react-remove-scroll-bar/-/react-remove-scroll-bar-2.3.4.tgz", - "integrity": "sha512-63C4YQBUt0m6ALadE9XV56hV8BgJWDmmTPY758iIJjfQKt2nYwoUrPk0LXRXcB/yIj82T1/Ixfdpdk68LwIB0A==", - "dependencies": { - "react-style-singleton": "^2.2.1", - "tslib": "^2.0.0" - }, - "engines": { - "node": ">=10" - }, - "peerDependencies": { - "@types/react": "^16.8.0 || ^17.0.0 || ^18.0.0", - "react": "^16.8.0 || ^17.0.0 || ^18.0.0" - }, - "peerDependenciesMeta": { - "@types/react": { - "optional": true - } - } - }, - "node_modules/react-router": { - "version": "6.11.2", - "resolved": "https://registry.npmjs.org/react-router/-/react-router-6.11.2.tgz", - "integrity": "sha512-74z9xUSaSX07t3LM+pS6Un0T55ibUE/79CzfZpy5wsPDZaea1F8QkrsiyRnA2YQ7LwE/umaydzXZV80iDCPkMg==", - "dependencies": { - "@remix-run/router": "1.6.2" - }, - "engines": { - "node": ">=14" - }, - "peerDependencies": { - "react": ">=16.8" - } - }, - "node_modules/react-router-dom": { - "version": "6.11.2", - "resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-6.11.2.tgz", - "integrity": "sha512-JNbKtAeh1VSJQnH6RvBDNhxNwemRj7KxCzc5jb7zvDSKRnPWIFj9pO+eXqjM69gQJ0r46hSz1x4l9y0651DKWw==", - "dependencies": { - "@remix-run/router": "1.6.2", - "react-router": "6.11.2" - }, - "engines": { - "node": ">=14" - }, - "peerDependencies": { - "react": ">=16.8", - "react-dom": ">=16.8" - } - }, - "node_modules/react-scripts": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/react-scripts/-/react-scripts-5.0.1.tgz", - "integrity": "sha512-8VAmEm/ZAwQzJ+GOMLbBsTdDKOpuZh7RPs0UymvBR2vRk4iZWCskjbFnxqjrzoIvlNNRZ3QJFx6/qDSi6zSnaQ==", - "dependencies": { - "@babel/core": "^7.16.0", - "@pmmmwh/react-refresh-webpack-plugin": "^0.5.3", - "@svgr/webpack": "^5.5.0", - "babel-jest": "^27.4.2", - "babel-loader": "^8.2.3", - "babel-plugin-named-asset-import": "^0.3.8", - "babel-preset-react-app": "^10.0.1", - "bfj": "^7.0.2", - "browserslist": "^4.18.1", - "camelcase": "^6.2.1", - "case-sensitive-paths-webpack-plugin": "^2.4.0", - "css-loader": "^6.5.1", - "css-minimizer-webpack-plugin": "^3.2.0", - "dotenv": "^10.0.0", - "dotenv-expand": "^5.1.0", - "eslint": "^8.3.0", - "eslint-config-react-app": "^7.0.1", - "eslint-webpack-plugin": "^3.1.1", - "file-loader": "^6.2.0", - "fs-extra": "^10.0.0", - "html-webpack-plugin": "^5.5.0", - "identity-obj-proxy": "^3.0.0", - "jest": "^27.4.3", - "jest-resolve": "^27.4.2", - "jest-watch-typeahead": "^1.0.0", - "mini-css-extract-plugin": "^2.4.5", - "postcss": "^8.4.4", - "postcss-flexbugs-fixes": "^5.0.2", - "postcss-loader": "^6.2.1", - "postcss-normalize": "^10.0.1", - "postcss-preset-env": "^7.0.1", - "prompts": "^2.4.2", - "react-app-polyfill": "^3.0.0", - "react-dev-utils": "^12.0.1", - "react-refresh": "^0.11.0", - "resolve": "^1.20.0", - "resolve-url-loader": "^4.0.0", - "sass-loader": "^12.3.0", - "semver": "^7.3.5", - "source-map-loader": "^3.0.0", - "style-loader": "^3.3.1", - "tailwindcss": "^3.0.2", - "terser-webpack-plugin": "^5.2.5", - "webpack": "^5.64.4", - "webpack-dev-server": "^4.6.0", - "webpack-manifest-plugin": "^4.0.2", - "workbox-webpack-plugin": "^6.4.1" - }, - "bin": { - "react-scripts": "bin/react-scripts.js" - }, - "engines": { - "node": ">=14.0.0" - }, - "optionalDependencies": { - "fsevents": "^2.3.2" - }, - "peerDependencies": { - "react": ">= 16", - "typescript": "^3.2.1 || ^4" - }, - "peerDependenciesMeta": { - "typescript": { - "optional": true - } - } - }, - "node_modules/react-style-singleton": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/react-style-singleton/-/react-style-singleton-2.2.1.tgz", - "integrity": "sha512-ZWj0fHEMyWkHzKYUr2Bs/4zU6XLmq9HsgBURm7g5pAVfyn49DgUiNgY2d4lXRlYSiCif9YBGpQleewkcqddc7g==", - "dependencies": { - "get-nonce": "^1.0.0", - "invariant": "^2.2.4", - "tslib": "^2.0.0" - }, - "engines": { - "node": ">=10" - }, - "peerDependencies": { - "@types/react": "^16.8.0 || ^17.0.0 || ^18.0.0", - "react": "^16.8.0 || ^17.0.0 || ^18.0.0" - }, - "peerDependenciesMeta": { - "@types/react": { - "optional": true - } - } - }, - "node_modules/react-textarea-autosize": { - "version": "8.3.4", - "resolved": "https://registry.npmjs.org/react-textarea-autosize/-/react-textarea-autosize-8.3.4.tgz", - "integrity": "sha512-CdtmP8Dc19xL8/R6sWvtknD/eCXkQr30dtvC4VmGInhRsfF8X/ihXCq6+9l9qbxmKRiq407/7z5fxE7cVWQNgQ==", - "dependencies": { - "@babel/runtime": "^7.10.2", - "use-composed-ref": "^1.3.0", - "use-latest": "^1.2.1" - }, - "engines": { - "node": ">=10" - }, - "peerDependencies": { - "react": "^16.8.0 || ^17.0.0 || ^18.0.0" - } - }, - "node_modules/react-transition-group": { - "version": "4.4.2", - "resolved": "https://registry.npmjs.org/react-transition-group/-/react-transition-group-4.4.2.tgz", - "integrity": "sha512-/RNYfRAMlZwDSr6z4zNKV6xu53/e2BuaBbGhbyYIXTrmgu/bGHzmqOs7mJSJBHy9Ud+ApHx3QjrkKSp1pxvlFg==", - "dependencies": { - "@babel/runtime": "^7.5.5", - "dom-helpers": "^5.0.1", - "loose-envify": "^1.4.0", - "prop-types": "^15.6.2" - }, - "peerDependencies": { - "react": ">=16.6.0", - "react-dom": ">=16.6.0" - } - }, - "node_modules/read-cache": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/read-cache/-/read-cache-1.0.0.tgz", - "integrity": "sha512-Owdv/Ft7IjOgm/i0xvNDZ1LrRANRfew4b2prF3OWMQLxLfu3bS8FVhCsrSCMK4lR56Y9ya+AThoTpDCTxCmpRA==", - "dependencies": { - "pify": "^2.3.0" - } - }, - "node_modules/readable-stream": { - "version": "3.6.2", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", - "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", - "dependencies": { - "inherits": "^2.0.3", - "string_decoder": "^1.1.1", - "util-deprecate": "^1.0.1" - }, - "engines": { - "node": ">= 6" - } - }, - "node_modules/readdirp": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", - "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", - "dependencies": { - "picomatch": "^2.2.1" - }, - "engines": { - "node": ">=8.10.0" - } - }, - "node_modules/recursive-readdir": { - "version": "2.2.3", - "resolved": "https://registry.npmjs.org/recursive-readdir/-/recursive-readdir-2.2.3.tgz", - "integrity": "sha512-8HrF5ZsXk5FAH9dgsx3BlUer73nIhuj+9OrQwEbLTPOBzGkL1lsFCR01am+v+0m2Cmbs1nP12hLDl5FA7EszKA==", - "dependencies": { - "minimatch": "^3.0.5" - }, - "engines": { - "node": ">=6.0.0" - } - }, - "node_modules/redent": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/redent/-/redent-3.0.0.tgz", - "integrity": "sha512-6tDA8g98We0zd0GvVeMT9arEOnTw9qM03L9cJXaCjrip1OO764RDBLBfrB4cwzNGDj5OA5ioymC9GkizgWJDUg==", - "dependencies": { - "indent-string": "^4.0.0", - "strip-indent": "^3.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/regenerate": { - "version": "1.4.2", - "resolved": "https://registry.npmjs.org/regenerate/-/regenerate-1.4.2.tgz", - "integrity": "sha512-zrceR/XhGYU/d/opr2EKO7aRHUeiBI8qjtfHqADTwZd6Szfy16la6kqD0MIUs5z5hx6AaKa+PixpPrR289+I0A==" - }, - "node_modules/regenerate-unicode-properties": { - "version": "10.1.0", - "resolved": "https://registry.npmjs.org/regenerate-unicode-properties/-/regenerate-unicode-properties-10.1.0.tgz", - "integrity": "sha512-d1VudCLoIGitcU/hEg2QqvyGZQmdC0Lf8BqdOMXGFSvJP4bNV1+XqbPQeHHLD51Jh4QJJ225dlIFvY4Ly6MXmQ==", - "dependencies": { - "regenerate": "^1.4.2" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/regenerator-runtime": { - "version": "0.13.11", - "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz", - "integrity": "sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==" - }, - "node_modules/regenerator-transform": { - "version": "0.15.1", - "resolved": "https://registry.npmjs.org/regenerator-transform/-/regenerator-transform-0.15.1.tgz", - "integrity": "sha512-knzmNAcuyxV+gQCufkYcvOqX/qIIfHLv0u5x79kRxuGojfYVky1f15TzZEu2Avte8QGepvUNTnLskf8E6X6Vyg==", - "dependencies": { - "@babel/runtime": "^7.8.4" - } - }, - "node_modules/regex-parser": { - "version": "2.2.11", - "resolved": "https://registry.npmjs.org/regex-parser/-/regex-parser-2.2.11.tgz", - "integrity": "sha512-jbD/FT0+9MBU2XAZluI7w2OBs1RBi6p9M83nkoZayQXXU9e8Robt69FcZc7wU4eJD/YFTjn1JdCk3rbMJajz8Q==" - }, - "node_modules/regexp.prototype.flags": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.5.0.tgz", - "integrity": "sha512-0SutC3pNudRKgquxGoRGIz946MZVHqbNfPjBdxeOhBrdgDKlRoXmYLQN9xRbrR09ZXWeGAdPuif7egofn6v5LA==", - "dependencies": { - "call-bind": "^1.0.2", - "define-properties": "^1.2.0", - "functions-have-names": "^1.2.3" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/regexpu-core": { - "version": "5.3.2", - "resolved": "https://registry.npmjs.org/regexpu-core/-/regexpu-core-5.3.2.tgz", - "integrity": "sha512-RAM5FlZz+Lhmo7db9L298p2vHP5ZywrVXmVXpmAD9GuL5MPH6t9ROw1iA/wfHkQ76Qe7AaPF0nGuim96/IrQMQ==", - "dependencies": { - "@babel/regjsgen": "^0.8.0", - "regenerate": "^1.4.2", - "regenerate-unicode-properties": "^10.1.0", - "regjsparser": "^0.9.1", - "unicode-match-property-ecmascript": "^2.0.0", - "unicode-match-property-value-ecmascript": "^2.1.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/regjsparser": { - "version": "0.9.1", - "resolved": "https://registry.npmjs.org/regjsparser/-/regjsparser-0.9.1.tgz", - "integrity": "sha512-dQUtn90WanSNl+7mQKcXAgZxvUe7Z0SqXlgzv0za4LwiUhyzBC58yQO3liFoUgu8GiJVInAhJjkj1N0EtQ5nkQ==", - "dependencies": { - "jsesc": "~0.5.0" - }, - "bin": { - "regjsparser": "bin/parser" - } - }, - "node_modules/regjsparser/node_modules/jsesc": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-0.5.0.tgz", - "integrity": "sha512-uZz5UnB7u4T9LvwmFqXii7pZSouaRPorGs5who1Ip7VO0wxanFvBL7GkM6dTHlgX+jhBApRetaWpnDabOeTcnA==", - "bin": { - "jsesc": "bin/jsesc" - } - }, - "node_modules/relateurl": { - "version": "0.2.7", - "resolved": "https://registry.npmjs.org/relateurl/-/relateurl-0.2.7.tgz", - "integrity": "sha512-G08Dxvm4iDN3MLM0EsP62EDV9IuhXPR6blNz6Utcp7zyV3tr4HVNINt6MpaRWbxoOHT3Q7YN2P+jaHX8vUbgog==", - "engines": { - "node": ">= 0.10" - } - }, - "node_modules/remove-accents": { - "version": "0.4.2", - "resolved": "https://registry.npmjs.org/remove-accents/-/remove-accents-0.4.2.tgz", - "integrity": "sha512-7pXIJqJOq5tFgG1A2Zxti3Ht8jJF337m4sowbuHsW30ZnkQFnDzy9qBNhgzX8ZLW4+UBcXiiR7SwR6pokHsxiA==" - }, - "node_modules/renderkid": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/renderkid/-/renderkid-3.0.0.tgz", - "integrity": "sha512-q/7VIQA8lmM1hF+jn+sFSPWGlMkSAeNYcPLmDQx2zzuiDfaLrOmumR8iaUKlenFgh0XRPIUeSPlH3A+AW3Z5pg==", - "dependencies": { - "css-select": "^4.1.3", - "dom-converter": "^0.2.0", - "htmlparser2": "^6.1.0", - "lodash": "^4.17.21", - "strip-ansi": "^6.0.1" - } - }, - "node_modules/repeating": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/repeating/-/repeating-2.0.1.tgz", - "integrity": "sha512-ZqtSMuVybkISo2OWvqvm7iHSWngvdaW3IpsT9/uP8v4gMi591LY6h35wdOfvQdWCKFWZWm2Y1Opp4kV7vQKT6A==", - "dependencies": { - "is-finite": "^1.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/request": { - "version": "2.88.2", - "resolved": "https://registry.npmjs.org/request/-/request-2.88.2.tgz", - "integrity": "sha512-MsvtOrfG9ZcrOwAW+Qi+F6HbD0CWXEh9ou77uOb7FM2WPhwT7smM833PzanhJLsgXjN89Ir6V2PczXNnMpwKhw==", - "deprecated": "request has been deprecated, see https://github.com/request/request/issues/3142", - "optional": true, - "dependencies": { - "aws-sign2": "~0.7.0", - "aws4": "^1.8.0", - "caseless": "~0.12.0", - "combined-stream": "~1.0.6", - "extend": "~3.0.2", - "forever-agent": "~0.6.1", - "form-data": "~2.3.2", - "har-validator": "~5.1.3", - "http-signature": "~1.2.0", - "is-typedarray": "~1.0.0", - "isstream": "~0.1.2", - "json-stringify-safe": "~5.0.1", - "mime-types": "~2.1.19", - "oauth-sign": "~0.9.0", - "performance-now": "^2.1.0", - "qs": "~6.5.2", - "safe-buffer": "^5.1.2", - "tough-cookie": "~2.5.0", - "tunnel-agent": "^0.6.0", - "uuid": "^3.3.2" - }, - "engines": { - "node": ">= 6" - } - }, - "node_modules/request/node_modules/form-data": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.3.tgz", - "integrity": "sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ==", - "optional": true, - "dependencies": { - "asynckit": "^0.4.0", - "combined-stream": "^1.0.6", - "mime-types": "^2.1.12" - }, - "engines": { - "node": ">= 0.12" - } - }, - "node_modules/request/node_modules/qs": { - "version": "6.5.3", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.3.tgz", - "integrity": "sha512-qxXIEh4pCGfHICj1mAJQ2/2XVZkjCDTcEgfoSQxc/fYivUZxTkk7L3bDBJSoNrEzXI17oUO5Dp07ktqE5KzczA==", - "optional": true, - "engines": { - "node": ">=0.6" - } - }, - "node_modules/request/node_modules/tough-cookie": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.5.0.tgz", - "integrity": "sha512-nlLsUzgm1kfLXSXfRZMc1KLAugd4hqJHDTvc2hDIwS3mZAfMEuMbc03SujMF+GEcpaX/qboeycw6iO8JwVv2+g==", - "optional": true, - "dependencies": { - "psl": "^1.1.28", - "punycode": "^2.1.1" - }, - "engines": { - "node": ">=0.8" - } - }, - "node_modules/request/node_modules/uuid": { - "version": "3.4.0", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", - "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==", - "deprecated": "Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.", - "optional": true, - "bin": { - "uuid": "bin/uuid" - } - }, - "node_modules/require-directory": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", - "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/require-from-string": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", - "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/require-main-filename": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz", - "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==" - }, - "node_modules/requires-port": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz", - "integrity": "sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ==" - }, - "node_modules/resolve": { - "version": "1.22.2", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.2.tgz", - "integrity": "sha512-Sb+mjNHOULsBv818T40qSPeRiuWLyaGMa5ewydRLFimneixmVy2zdivRl+AF6jaYPC8ERxGDmFSiqui6SfPd+g==", - "dependencies": { - "is-core-module": "^2.11.0", - "path-parse": "^1.0.7", - "supports-preserve-symlinks-flag": "^1.0.0" - }, - "bin": { - "resolve": "bin/resolve" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/resolve-cwd": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/resolve-cwd/-/resolve-cwd-3.0.0.tgz", - "integrity": "sha512-OrZaX2Mb+rJCpH/6CpSqt9xFVpN++x01XnN2ie9g6P5/3xelLAkXWVADpdz1IHD/KFfEXyE6V0U01OQ3UO2rEg==", - "dependencies": { - "resolve-from": "^5.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/resolve-from": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz", - "integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==", - "engines": { - "node": ">=8" - } - }, - "node_modules/resolve-url-loader": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/resolve-url-loader/-/resolve-url-loader-4.0.0.tgz", - "integrity": "sha512-05VEMczVREcbtT7Bz+C+96eUO5HDNvdthIiMB34t7FcF8ehcu4wC0sSgPUubs3XW2Q3CNLJk/BJrCU9wVRymiA==", - "dependencies": { - "adjust-sourcemap-loader": "^4.0.0", - "convert-source-map": "^1.7.0", - "loader-utils": "^2.0.0", - "postcss": "^7.0.35", - "source-map": "0.6.1" - }, - "engines": { - "node": ">=8.9" - }, - "peerDependencies": { - "rework": "1.0.1", - "rework-visit": "1.0.0" - }, - "peerDependenciesMeta": { - "rework": { - "optional": true - }, - "rework-visit": { - "optional": true - } - } - }, - "node_modules/resolve-url-loader/node_modules/picocolors": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-0.2.1.tgz", - "integrity": "sha512-cMlDqaLEqfSaW8Z7N5Jw+lyIW869EzT73/F5lhtY9cLGoVxSXznfgfXMO0Z5K0o0Q2TkTXq+0KFsdnSe3jDViA==" - }, - "node_modules/resolve-url-loader/node_modules/postcss": { - "version": "7.0.39", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.39.tgz", - "integrity": "sha512-yioayjNbHn6z1/Bywyb2Y4s3yvDAeXGOyxqD+LnVOinq6Mdmd++SW2wUNVzavyyHxd6+DxzWGIuosg6P1Rj8uA==", - "dependencies": { - "picocolors": "^0.2.1", - "source-map": "^0.6.1" - }, - "engines": { - "node": ">=6.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/postcss/" - } - }, - "node_modules/resolve-url-loader/node_modules/source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/resolve.exports": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/resolve.exports/-/resolve.exports-1.1.1.tgz", - "integrity": "sha512-/NtpHNDN7jWhAaQ9BvBUYZ6YTXsRBgfqWFWP7BZBaoMJO/I3G5OFzvTuWNlZC3aPjins1F+TNrLKsGbH4rfsRQ==", - "engines": { - "node": ">=10" - } - }, - "node_modules/retry": { - "version": "0.13.1", - "resolved": "https://registry.npmjs.org/retry/-/retry-0.13.1.tgz", - "integrity": "sha512-XQBQ3I8W1Cge0Seh+6gjj03LbmRFWuoszgK9ooCpwYIrhhoO80pfq4cUkU5DkknwfOfFteRwlZ56PYOGYyFWdg==", - "engines": { - "node": ">= 4" - } - }, - "node_modules/reusify": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz", - "integrity": "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==", - "engines": { - "iojs": ">=1.0.0", - "node": ">=0.10.0" - } - }, - "node_modules/rfc4648": { - "version": "1.5.3", - "resolved": "https://registry.npmjs.org/rfc4648/-/rfc4648-1.5.3.tgz", - "integrity": "sha512-MjOWxM065+WswwnmNONOT+bD1nXzY9Km6u3kzvnx8F8/HXGZdz3T6e6vZJ8Q/RIMUSp/nxqjH3GwvJDy8ijeQQ==" - }, - "node_modules/rimraf": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", - "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", - "dependencies": { - "glob": "^7.1.3" - }, - "bin": { - "rimraf": "bin.js" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/rollup": { - "version": "2.79.1", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.79.1.tgz", - "integrity": "sha512-uKxbd0IhMZOhjAiD5oAFp7BqvkA4Dv47qpOCtaNvng4HBwdbWtdOh8f5nZNuk2rp51PMGk3bzfWu5oayNEuYnw==", - "bin": { - "rollup": "dist/bin/rollup" - }, - "engines": { - "node": ">=10.0.0" - }, - "optionalDependencies": { - "fsevents": "~2.3.2" - } - }, - "node_modules/rollup-plugin-terser": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/rollup-plugin-terser/-/rollup-plugin-terser-7.0.2.tgz", - "integrity": "sha512-w3iIaU4OxcF52UUXiZNsNeuXIMDvFrr+ZXK6bFZ0Q60qyVfq4uLptoS4bbq3paG3x216eQllFZX7zt6TIImguQ==", - "deprecated": "This package has been deprecated and is no longer maintained. Please use @rollup/plugin-terser", - "dependencies": { - "@babel/code-frame": "^7.10.4", - "jest-worker": "^26.2.1", - "serialize-javascript": "^4.0.0", - "terser": "^5.0.0" - }, - "peerDependencies": { - "rollup": "^2.0.0" - } - }, - "node_modules/rollup-plugin-terser/node_modules/has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "engines": { - "node": ">=8" - } - }, - "node_modules/rollup-plugin-terser/node_modules/jest-worker": { - "version": "26.6.2", - "resolved": "https://registry.npmjs.org/jest-worker/-/jest-worker-26.6.2.tgz", - "integrity": "sha512-KWYVV1c4i+jbMpaBC+U++4Va0cp8OisU185o73T1vo99hqi7w8tSJfUXYswwqqrjzwxa6KpRK54WhPvwf5w6PQ==", - "dependencies": { - "@types/node": "*", - "merge-stream": "^2.0.0", - "supports-color": "^7.0.0" - }, - "engines": { - "node": ">= 10.13.0" - } - }, - "node_modules/rollup-plugin-terser/node_modules/serialize-javascript": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-4.0.0.tgz", - "integrity": "sha512-GaNA54380uFefWghODBWEGisLZFj00nS5ACs6yHa9nLqlLpVLO8ChDGeKRjZnV4Nh4n0Qi7nhYZD/9fCPzEqkw==", - "dependencies": { - "randombytes": "^2.1.0" - } - }, - "node_modules/rollup-plugin-terser/node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/rope-sequence": { - "version": "1.3.4", - "resolved": "https://registry.npmjs.org/rope-sequence/-/rope-sequence-1.3.4.tgz", - "integrity": "sha512-UT5EDe2cu2E/6O4igUr5PSFs23nvvukicWHx6GnOPlHAiiYbzNuCRQCuiUdHJQcqKalLKlrYJnjY0ySGsXNQXQ==", - "peer": true - }, - "node_modules/run-parallel": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", - "integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "dependencies": { - "queue-microtask": "^1.2.2" - } - }, - "node_modules/safe-array-concat": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/safe-array-concat/-/safe-array-concat-1.0.0.tgz", - "integrity": "sha512-9dVEFruWIsnie89yym+xWTAYASdpw3CJV7Li/6zBewGf9z2i1j31rP6jnY0pHEO4QZh6N0K11bFjWmdR8UGdPQ==", - "dependencies": { - "call-bind": "^1.0.2", - "get-intrinsic": "^1.2.0", - "has-symbols": "^1.0.3", - "isarray": "^2.0.5" - }, - "engines": { - "node": ">=0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/safe-buffer": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", - "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ] - }, - "node_modules/safe-regex-test": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/safe-regex-test/-/safe-regex-test-1.0.0.tgz", - "integrity": "sha512-JBUUzyOgEwXQY1NuPtvcj/qcBDbDmEvWufhlnXZIm75DEHp+afM1r1ujJpJsV/gSM4t59tpDyPi1sd6ZaPFfsA==", - "dependencies": { - "call-bind": "^1.0.2", - "get-intrinsic": "^1.1.3", - "is-regex": "^1.1.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/safer-buffer": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", - "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" - }, - "node_modules/sanitize.css": { - "version": "13.0.0", - "resolved": "https://registry.npmjs.org/sanitize.css/-/sanitize.css-13.0.0.tgz", - "integrity": "sha512-ZRwKbh/eQ6w9vmTjkuG0Ioi3HBwPFce0O+v//ve+aOq1oeCy7jMV2qzzAlpsNuqpqCBjjriM1lbtZbF/Q8jVyA==" - }, - "node_modules/sass-loader": { - "version": "12.6.0", - "resolved": "https://registry.npmjs.org/sass-loader/-/sass-loader-12.6.0.tgz", - "integrity": "sha512-oLTaH0YCtX4cfnJZxKSLAyglED0naiYfNG1iXfU5w1LNZ+ukoA5DtyDIN5zmKVZwYNJP4KRc5Y3hkWga+7tYfA==", - "dependencies": { - "klona": "^2.0.4", - "neo-async": "^2.6.2" - }, - "engines": { - "node": ">= 12.13.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/webpack" - }, - "peerDependencies": { - "fibers": ">= 3.1.0", - "node-sass": "^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0", - "sass": "^1.3.0", - "sass-embedded": "*", - "webpack": "^5.0.0" - }, - "peerDependenciesMeta": { - "fibers": { - "optional": true - }, - "node-sass": { - "optional": true - }, - "sass": { - "optional": true - }, - "sass-embedded": { - "optional": true - } - } - }, - "node_modules/sax": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz", - "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==" - }, - "node_modules/saxes": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/saxes/-/saxes-5.0.1.tgz", - "integrity": "sha512-5LBh1Tls8c9xgGjw3QrMwETmTMVk0oFgvrFSvWx62llR2hcEInrKNZ2GZCCuuy2lvWrdl5jhbpeqc5hRYKFOcw==", - "dependencies": { - "xmlchars": "^2.2.0" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/scheduler": { - "version": "0.23.0", - "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.23.0.tgz", - "integrity": "sha512-CtuThmgHNg7zIZWAXi3AsyIzA3n4xx7aNyjwC2VJldO2LMVDhFK+63xGqq6CsJH4rTAt6/M+N4GhZiDYPx9eUw==", - "dependencies": { - "loose-envify": "^1.1.0" - } - }, - "node_modules/schema-utils": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-3.3.0.tgz", - "integrity": "sha512-pN/yOAvcC+5rQ5nERGuwrjLlYvLTbCibnZ1I7B1LaiAz9BRBlE9GMgE/eqV30P7aJQUf7Ddimy/RsbYO/GrVGg==", - "dependencies": { - "@types/json-schema": "^7.0.8", - "ajv": "^6.12.5", - "ajv-keywords": "^3.5.2" - }, - "engines": { - "node": ">= 10.13.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/webpack" - } - }, - "node_modules/seedrandom": { - "version": "3.0.5", - "resolved": "https://registry.npmjs.org/seedrandom/-/seedrandom-3.0.5.tgz", - "integrity": "sha512-8OwmbklUNzwezjGInmZ+2clQmExQPvomqjL7LFqOYqtmuxRgQYqOD3mHaU+MvZn5FLUeVxVfQjwLZW/n/JFuqg==" - }, - "node_modules/select-hose": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/select-hose/-/select-hose-2.0.0.tgz", - "integrity": "sha512-mEugaLK+YfkijB4fx0e6kImuJdCIt2LxCRcbEYPqRGCs4F2ogyfZU5IAZRdjCP8JPq2AtdNoC/Dux63d9Kiryg==" - }, - "node_modules/selfsigned": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/selfsigned/-/selfsigned-2.1.1.tgz", - "integrity": "sha512-GSL3aowiF7wa/WtSFwnUrludWFoNhftq8bUkH9pkzjpN2XSPOAYEgg6e0sS9s0rZwgJzJiQRPU18A6clnoW5wQ==", - "dependencies": { - "node-forge": "^1" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/semver": { - "version": "7.5.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.1.tgz", - "integrity": "sha512-Wvss5ivl8TMRZXXESstBA4uR5iXgEN/VC5/sOcuXdVLzcdkz4HWetIoRfG5gb5X+ij/G9rw9YoGn3QoQ8OCSpw==", - "dependencies": { - "lru-cache": "^6.0.0" - }, - "bin": { - "semver": "bin/semver.js" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/semver/node_modules/lru-cache": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", - "dependencies": { - "yallist": "^4.0.0" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/semver/node_modules/yallist": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" - }, - "node_modules/send": { - "version": "0.18.0", - "resolved": "https://registry.npmjs.org/send/-/send-0.18.0.tgz", - "integrity": "sha512-qqWzuOjSFOuqPjFe4NOsMLafToQQwBSOEpS+FwEt3A2V3vKubTquT3vmLTQpFgMXp8AlFWFuP1qKaJZOtPpVXg==", - "dependencies": { - "debug": "2.6.9", - "depd": "2.0.0", - "destroy": "1.2.0", - "encodeurl": "~1.0.2", - "escape-html": "~1.0.3", - "etag": "~1.8.1", - "fresh": "0.5.2", - "http-errors": "2.0.0", - "mime": "1.6.0", - "ms": "2.1.3", - "on-finished": "2.4.1", - "range-parser": "~1.2.1", - "statuses": "2.0.1" - }, - "engines": { - "node": ">= 0.8.0" - } - }, - "node_modules/send/node_modules/debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "dependencies": { - "ms": "2.0.0" - } - }, - "node_modules/send/node_modules/debug/node_modules/ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" - }, - "node_modules/send/node_modules/ms": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", - "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" - }, - "node_modules/serialize-javascript": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.1.tgz", - "integrity": "sha512-owoXEFjWRllis8/M1Q+Cw5k8ZH40e3zhp/ovX+Xr/vi1qj6QesbyXXViFbpNvWvPNAD62SutwEXavefrLJWj7w==", - "dependencies": { - "randombytes": "^2.1.0" - } - }, - "node_modules/serve-index": { - "version": "1.9.1", - "resolved": "https://registry.npmjs.org/serve-index/-/serve-index-1.9.1.tgz", - "integrity": "sha512-pXHfKNP4qujrtteMrSBb0rc8HJ9Ms/GrXwcUtUtD5s4ewDJI8bT3Cz2zTVRMKtri49pLx2e0Ya8ziP5Ya2pZZw==", - "dependencies": { - "accepts": "~1.3.4", - "batch": "0.6.1", - "debug": "2.6.9", - "escape-html": "~1.0.3", - "http-errors": "~1.6.2", - "mime-types": "~2.1.17", - "parseurl": "~1.3.2" - }, - "engines": { - "node": ">= 0.8.0" - } - }, - "node_modules/serve-index/node_modules/debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "dependencies": { - "ms": "2.0.0" - } - }, - "node_modules/serve-index/node_modules/depd": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", - "integrity": "sha512-7emPTl6Dpo6JRXOXjLRxck+FlLRX5847cLKEn00PLAgc3g2hTZZgr+e4c2v6QpSmLeFP3n5yUo7ft6avBK/5jQ==", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/serve-index/node_modules/http-errors": { - "version": "1.6.3", - "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.3.tgz", - "integrity": "sha512-lks+lVC8dgGyh97jxvxeYTWQFvh4uw4yC12gVl63Cg30sjPX4wuGcdkICVXDAESr6OJGjqGA8Iz5mkeN6zlD7A==", - "dependencies": { - "depd": "~1.1.2", - "inherits": "2.0.3", - "setprototypeof": "1.1.0", - "statuses": ">= 1.4.0 < 2" - }, - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/serve-index/node_modules/inherits": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "integrity": "sha512-x00IRNXNy63jwGkJmzPigoySHbaqpNuzKbBOmzK+g2OdZpQ9w+sxCN+VSB3ja7IAge2OP2qpfxTjeNcyjmW1uw==" - }, - "node_modules/serve-index/node_modules/ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" - }, - "node_modules/serve-index/node_modules/setprototypeof": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.0.tgz", - "integrity": "sha512-BvE/TwpZX4FXExxOxZyRGQQv651MSwmWKZGqvmPcRIjDqWub67kTKuIMx43cZZrS/cBBzwBcNDWoFxt2XEFIpQ==" - }, - "node_modules/serve-index/node_modules/statuses": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", - "integrity": "sha512-OpZ3zP+jT1PI7I8nemJX4AKmAX070ZkYPVWV/AaKTJl+tXCTGyVdC1a4SL8RUQYEwk/f34ZX8UTykN68FwrqAA==", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/serve-static": { - "version": "1.15.0", - "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.15.0.tgz", - "integrity": "sha512-XGuRDNjXUijsUL0vl6nSD7cwURuzEgglbOaFuZM9g3kwDXOWVTck0jLzjPzGD+TazWbboZYu52/9/XPdUgne9g==", - "dependencies": { - "encodeurl": "~1.0.2", - "escape-html": "~1.0.3", - "parseurl": "~1.3.3", - "send": "0.18.0" - }, - "engines": { - "node": ">= 0.8.0" - } - }, - "node_modules/set-blocking": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", - "integrity": "sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==" - }, - "node_modules/setprototypeof": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", - "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==" - }, - "node_modules/shebang-command": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", - "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", - "dependencies": { - "shebang-regex": "^3.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/shebang-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", - "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", - "engines": { - "node": ">=8" - } - }, - "node_modules/shell-quote": { - "version": "1.8.1", - "resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.8.1.tgz", - "integrity": "sha512-6j1W9l1iAs/4xYBI1SYOVZyFcCis9b4KCLQ8fgAGG07QvzaRLVVRQvAy85yNmmZSjYjg4MWh4gNvlPujU/5LpA==", - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/side-channel": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz", - "integrity": "sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==", - "dependencies": { - "call-bind": "^1.0.0", - "get-intrinsic": "^1.0.2", - "object-inspect": "^1.9.0" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/signal-exit": { - "version": "3.0.7", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", - "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==" - }, - "node_modules/sisteransi": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/sisteransi/-/sisteransi-1.0.5.tgz", - "integrity": "sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==" - }, - "node_modules/slash": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", - "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", - "engines": { - "node": ">=8" - } - }, - "node_modules/socket.io": { - "version": "4.7.3", - "resolved": "https://registry.npmjs.org/socket.io/-/socket.io-4.7.3.tgz", - "integrity": "sha512-SE+UIQXBQE+GPG2oszWMlsEmWtHVqw/h1VrYJGK5/MC7CH5p58N448HwIrtREcvR4jfdOJAY4ieQfxMr55qbbw==", - "dependencies": { - "accepts": "~1.3.4", - "base64id": "~2.0.0", - "cors": "~2.8.5", - "debug": "~4.3.2", - "engine.io": "~6.5.2", - "socket.io-adapter": "~2.5.2", - "socket.io-parser": "~4.2.4" - }, - "engines": { - "node": ">=10.2.0" - } - }, - "node_modules/socket.io-adapter": { - "version": "2.5.2", - "resolved": "https://registry.npmjs.org/socket.io-adapter/-/socket.io-adapter-2.5.2.tgz", - "integrity": "sha512-87C3LO/NOMc+eMcpcxUBebGjkpMDkNBS9tf7KJqcDsmL936EChtVva71Dw2q4tQcuVC+hAUy4an2NO/sYXmwRA==", - "dependencies": { - "ws": "~8.11.0" - } - }, - "node_modules/socket.io-adapter/node_modules/ws": { - "version": "8.11.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.11.0.tgz", - "integrity": "sha512-HPG3wQd9sNQoT9xHyNCXoDUa+Xw/VevmY9FoHyQ+g+rrMn4j6FB4np7Z0OhdTgjx6MgQLK7jwSy1YecU1+4Asg==", - "engines": { - "node": ">=10.0.0" - }, - "peerDependencies": { - "bufferutil": "^4.0.1", - "utf-8-validate": "^5.0.2" - }, - "peerDependenciesMeta": { - "bufferutil": { - "optional": true - }, - "utf-8-validate": { - "optional": true - } - } - }, - "node_modules/socket.io-client": { - "version": "4.7.3", - "resolved": "https://registry.npmjs.org/socket.io-client/-/socket.io-client-4.7.3.tgz", - "integrity": "sha512-nU+ywttCyBitXIl9Xe0RSEfek4LneYkJxCeNnKCuhwoH4jGXO1ipIUw/VA/+Vvv2G1MTym11fzFC0SxkrcfXDw==", - "dependencies": { - "@socket.io/component-emitter": "~3.1.0", - "debug": "~4.3.2", - "engine.io-client": "~6.5.2", - "socket.io-parser": "~4.2.4" - }, - "engines": { - "node": ">=10.0.0" - } - }, - "node_modules/socket.io-parser": { - "version": "4.2.4", - "resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-4.2.4.tgz", - "integrity": "sha512-/GbIKmo8ioc+NIWIhwdecY0ge+qVBSMdgxGygevmdHj24bsfgtCmcUUcQ5ZzcylGFHsN3k4HB4Cgkl96KVnuew==", - "dependencies": { - "@socket.io/component-emitter": "~3.1.0", - "debug": "~4.3.1" - }, - "engines": { - "node": ">=10.0.0" - } - }, - "node_modules/sockjs": { - "version": "0.3.24", - "resolved": "https://registry.npmjs.org/sockjs/-/sockjs-0.3.24.tgz", - "integrity": "sha512-GJgLTZ7vYb/JtPSSZ10hsOYIvEYsjbNU+zPdIHcUaWVNUEPivzxku31865sSSud0Da0W4lEeOPlmw93zLQchuQ==", - "dependencies": { - "faye-websocket": "^0.11.3", - "uuid": "^8.3.2", - "websocket-driver": "^0.7.4" - } - }, - "node_modules/sort-by": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/sort-by/-/sort-by-1.2.0.tgz", - "integrity": "sha512-aRyW65r3xMnf4nxJRluCg0H/woJpksU1dQxRtXYzau30sNBOmf5HACpDd9MZDhKh7ALQ5FgSOfMPwZEtUmMqcg==", - "dependencies": { - "object-path": "0.6.0" - } - }, - "node_modules/source-list-map": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/source-list-map/-/source-list-map-2.0.1.tgz", - "integrity": "sha512-qnQ7gVMxGNxsiL4lEuJwe/To8UnK7fAnmbGEEH8RpLouuKbeEm0lhbQVFIrNSuB+G7tVrAlVsZgETT5nljf+Iw==" - }, - "node_modules/source-map": { - "version": "0.7.4", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.4.tgz", - "integrity": "sha512-l3BikUxvPOcn5E74dZiq5BGsTb5yEwhaTSzccU6t4sDOH8NWJCstKO5QT2CvtFoK6F0saL7p9xHAqHOlCPJygA==", - "engines": { - "node": ">= 8" - } - }, - "node_modules/source-map-js": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.0.2.tgz", - "integrity": "sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/source-map-loader": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/source-map-loader/-/source-map-loader-3.0.2.tgz", - "integrity": "sha512-BokxPoLjyl3iOrgkWaakaxqnelAJSS+0V+De0kKIq6lyWrXuiPgYTGp6z3iHmqljKAaLXwZa+ctD8GccRJeVvg==", - "dependencies": { - "abab": "^2.0.5", - "iconv-lite": "^0.6.3", - "source-map-js": "^1.0.1" - }, - "engines": { - "node": ">= 12.13.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/webpack" - }, - "peerDependencies": { - "webpack": "^5.0.0" - } - }, - "node_modules/source-map-support": { - "version": "0.5.21", - "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz", - "integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==", - "dependencies": { - "buffer-from": "^1.0.0", - "source-map": "^0.6.0" - } - }, - "node_modules/source-map-support/node_modules/source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/sourcemap-codec": { - "version": "1.4.8", - "resolved": "https://registry.npmjs.org/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz", - "integrity": "sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA==", - "deprecated": "Please use @jridgewell/sourcemap-codec instead" - }, - "node_modules/spdy": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/spdy/-/spdy-4.0.2.tgz", - "integrity": "sha512-r46gZQZQV+Kl9oItvl1JZZqJKGr+oEkB08A6BzkiR7593/7IbtuncXHd2YoYeTsG4157ZssMu9KYvUHLcjcDoA==", - "dependencies": { - "debug": "^4.1.0", - "handle-thing": "^2.0.0", - "http-deceiver": "^1.2.7", - "select-hose": "^2.0.0", - "spdy-transport": "^3.0.0" - }, - "engines": { - "node": ">=6.0.0" - } - }, - "node_modules/spdy-transport": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/spdy-transport/-/spdy-transport-3.0.0.tgz", - "integrity": "sha512-hsLVFE5SjA6TCisWeJXFKniGGOpBgMLmerfO2aCyCU5s7nJ/rpAepqmFifv/GCbSbueEeAJJnmSQ2rKC/g8Fcw==", - "dependencies": { - "debug": "^4.1.0", - "detect-node": "^2.0.4", - "hpack.js": "^2.1.6", - "obuf": "^1.1.2", - "readable-stream": "^3.0.6", - "wbuf": "^1.7.3" - } - }, - "node_modules/sprintf-js": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", - "integrity": "sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==" - }, - "node_modules/sshpk": { - "version": "1.18.0", - "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.18.0.tgz", - "integrity": "sha512-2p2KJZTSqQ/I3+HX42EpYOa2l3f8Erv8MWKsy2I9uf4wA7yFIkXRffYdsx86y6z4vHtV8u7g+pPlr8/4ouAxsQ==", - "optional": true, - "dependencies": { - "asn1": "~0.2.3", - "assert-plus": "^1.0.0", - "bcrypt-pbkdf": "^1.0.0", - "dashdash": "^1.12.0", - "ecc-jsbn": "~0.1.1", - "getpass": "^0.1.1", - "jsbn": "~0.1.0", - "safer-buffer": "^2.0.2", - "tweetnacl": "~0.14.0" - }, - "bin": { - "sshpk-conv": "bin/sshpk-conv", - "sshpk-sign": "bin/sshpk-sign", - "sshpk-verify": "bin/sshpk-verify" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/stable": { - "version": "0.1.8", - "resolved": "https://registry.npmjs.org/stable/-/stable-0.1.8.tgz", - "integrity": "sha512-ji9qxRnOVfcuLDySj9qzhGSEFVobyt1kIOSkj1qZzYLzq7Tos/oUUWvotUPQLlrsidqsK6tBH89Bc9kL5zHA6w==", - "deprecated": "Modern JS already guarantees Array#sort() is a stable sort, so this library is deprecated. See the compatibility table on MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#browser_compatibility" - }, - "node_modules/stack-utils": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/stack-utils/-/stack-utils-2.0.6.tgz", - "integrity": "sha512-XlkWvfIm6RmsWtNJx+uqtKLS8eqFbxUg0ZzLXqY0caEy9l7hruX8IpiDnjsLavoBgqCCR71TqWO8MaXYheJ3RQ==", - "dependencies": { - "escape-string-regexp": "^2.0.0" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/stack-utils/node_modules/escape-string-regexp": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz", - "integrity": "sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==", - "engines": { - "node": ">=8" - } - }, - "node_modules/stackframe": { - "version": "1.3.4", - "resolved": "https://registry.npmjs.org/stackframe/-/stackframe-1.3.4.tgz", - "integrity": "sha512-oeVtt7eWQS+Na6F//S4kJ2K2VbRlS9D43mAlMyVpVWovy9o+jfgH8O9agzANzaiLjclA0oYzUXEM4PurhSUChw==" - }, - "node_modules/statuses": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz", - "integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==", - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/stop-iteration-iterator": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/stop-iteration-iterator/-/stop-iteration-iterator-1.0.0.tgz", - "integrity": "sha512-iCGQj+0l0HOdZ2AEeBADlsRC+vsnDsZsbdSiH1yNSjcfKM7fdpCMfqAL/dwF5BLiw/XhRft/Wax6zQbhq2BcjQ==", - "dependencies": { - "internal-slot": "^1.0.4" - }, - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/stream-browserify": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/stream-browserify/-/stream-browserify-3.0.0.tgz", - "integrity": "sha512-H73RAHsVBapbim0tU2JwwOiXUj+fikfiaoYAKHF3VJfA0pe2BCzkhAHBlLG6REzE+2WNZcxOXjK7lkso+9euLA==", - "dependencies": { - "inherits": "~2.0.4", - "readable-stream": "^3.5.0" - } - }, - "node_modules/stream-http": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/stream-http/-/stream-http-3.2.0.tgz", - "integrity": "sha512-Oq1bLqisTyK3TSCXpPbT4sdeYNdmyZJv1LxpEm2vu1ZhK89kSE5YXwZc3cWk0MagGaKriBh9mCFbVGtO+vY29A==", - "dependencies": { - "builtin-status-codes": "^3.0.0", - "inherits": "^2.0.4", - "readable-stream": "^3.6.0", - "xtend": "^4.0.2" - } - }, - "node_modules/string_decoder": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", - "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", - "dependencies": { - "safe-buffer": "~5.2.0" - } - }, - "node_modules/string-length": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/string-length/-/string-length-4.0.2.tgz", - "integrity": "sha512-+l6rNN5fYHNhZZy41RXsYptCjA2Igmq4EG7kZAYFQI1E1VTXarr6ZPXBg6eq7Y6eK4FEhY6AJlyuFIb/v/S0VQ==", - "dependencies": { - "char-regex": "^1.0.2", - "strip-ansi": "^6.0.0" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/string-natural-compare": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/string-natural-compare/-/string-natural-compare-3.0.1.tgz", - "integrity": "sha512-n3sPwynL1nwKi3WJ6AIsClwBMa0zTi54fn2oLU6ndfTSIO05xaznjSf15PcBZU6FNWbmN5Q6cxT4V5hGvB4taw==" - }, - "node_modules/string-width": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "dependencies": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/string-width/node_modules/emoji-regex": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", - "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" - }, - "node_modules/string.prototype.matchall": { - "version": "4.0.8", - "resolved": "https://registry.npmjs.org/string.prototype.matchall/-/string.prototype.matchall-4.0.8.tgz", - "integrity": "sha512-6zOCOcJ+RJAQshcTvXPHoxoQGONa3e/Lqx90wUA+wEzX78sg5Bo+1tQo4N0pohS0erG9qtCqJDjNCQBjeWVxyg==", - "dependencies": { - "call-bind": "^1.0.2", - "define-properties": "^1.1.4", - "es-abstract": "^1.20.4", - "get-intrinsic": "^1.1.3", - "has-symbols": "^1.0.3", - "internal-slot": "^1.0.3", - "regexp.prototype.flags": "^1.4.3", - "side-channel": "^1.0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/string.prototype.trim": { - "version": "1.2.7", - "resolved": "https://registry.npmjs.org/string.prototype.trim/-/string.prototype.trim-1.2.7.tgz", - "integrity": "sha512-p6TmeT1T3411M8Cgg9wBTMRtY2q9+PNy9EV1i2lIXUN/btt763oIfxwN3RR8VU6wHX8j/1CFy0L+YuThm6bgOg==", - "dependencies": { - "call-bind": "^1.0.2", - "define-properties": "^1.1.4", - "es-abstract": "^1.20.4" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/string.prototype.trimend": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/string.prototype.trimend/-/string.prototype.trimend-1.0.6.tgz", - "integrity": "sha512-JySq+4mrPf9EsDBEDYMOb/lM7XQLulwg5R/m1r0PXEFqrV0qHvl58sdTilSXtKOflCsK2E8jxf+GKC0T07RWwQ==", - "dependencies": { - "call-bind": "^1.0.2", - "define-properties": "^1.1.4", - "es-abstract": "^1.20.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/string.prototype.trimstart": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/string.prototype.trimstart/-/string.prototype.trimstart-1.0.6.tgz", - "integrity": "sha512-omqjMDaY92pbn5HOX7f9IccLA+U1tA9GvtU4JrodiXFfYB7jPzzHpRzpglLAjtUV6bB557zwClJezTqnAiYnQA==", - "dependencies": { - "call-bind": "^1.0.2", - "define-properties": "^1.1.4", - "es-abstract": "^1.20.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/stringify-object": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/stringify-object/-/stringify-object-3.3.0.tgz", - "integrity": "sha512-rHqiFh1elqCQ9WPLIC8I0Q/g/wj5J1eMkyoiD6eoQApWHP0FtlK7rqnhmabL5VUY9JQCcqwwvlOaSuutekgyrw==", - "dependencies": { - "get-own-enumerable-property-symbols": "^3.0.0", - "is-obj": "^1.0.1", - "is-regexp": "^1.0.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/strip-ansi": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", - "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "dependencies": { - "ansi-regex": "^5.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/strip-bom": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-4.0.0.tgz", - "integrity": "sha512-3xurFv5tEgii33Zi8Jtp55wEIILR9eh34FAW00PZf+JnSsTmV/ioewSgQl97JHvgjoRGwPShsWm+IdrxB35d0w==", - "engines": { - "node": ">=8" - } - }, - "node_modules/strip-comments": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/strip-comments/-/strip-comments-2.0.1.tgz", - "integrity": "sha512-ZprKx+bBLXv067WTCALv8SSz5l2+XhpYCsVtSqlMnkAXMWDq+/ekVbl1ghqP9rUHTzv6sm/DwCOiYutU/yp1fw==", - "engines": { - "node": ">=10" - } - }, - "node_modules/strip-final-newline": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-2.0.0.tgz", - "integrity": "sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==", - "engines": { - "node": ">=6" - } - }, - "node_modules/strip-indent": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/strip-indent/-/strip-indent-3.0.0.tgz", - "integrity": "sha512-laJTa3Jb+VQpaC6DseHhF7dXVqHTfJPCRDaEbid/drOhgitgYku/letMUqOXFoWV0zIIUbjpdH2t+tYj4bQMRQ==", - "dependencies": { - "min-indent": "^1.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/strip-json-comments": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", - "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/style-loader": { - "version": "3.3.3", - "resolved": "https://registry.npmjs.org/style-loader/-/style-loader-3.3.3.tgz", - "integrity": "sha512-53BiGLXAcll9maCYtZi2RCQZKa8NQQai5C4horqKyRmHj9H7QmcUyucrH+4KW/gBQbXM2AsB0axoEcFZPlfPcw==", - "engines": { - "node": ">= 12.13.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/webpack" - }, - "peerDependencies": { - "webpack": "^5.0.0" - } - }, - "node_modules/stylehacks": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/stylehacks/-/stylehacks-5.1.1.tgz", - "integrity": "sha512-sBpcd5Hx7G6seo7b1LkpttvTz7ikD0LlH5RmdcBNb6fFR0Fl7LQwHDFr300q4cwUqi+IYrFGmsIHieMBfnN/Bw==", - "dependencies": { - "browserslist": "^4.21.4", - "postcss-selector-parser": "^6.0.4" - }, - "engines": { - "node": "^10 || ^12 || >=14.0" - }, - "peerDependencies": { - "postcss": "^8.2.15" - } - }, - "node_modules/stylis": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/stylis/-/stylis-4.2.0.tgz", - "integrity": "sha512-Orov6g6BB1sDfYgzWfTHDOxamtX1bE/zo104Dh9e6fqJ3PooipYyfJ0pUmrZO2wAvO8YbEyeFrkV91XTsGMSrw==" - }, - "node_modules/sucrase": { - "version": "3.32.0", - "resolved": "https://registry.npmjs.org/sucrase/-/sucrase-3.32.0.tgz", - "integrity": "sha512-ydQOU34rpSyj2TGyz4D2p8rbktIOZ8QY9s+DGLvFU1i5pWJE8vkpruCjGCMHsdXwnD7JDcS+noSwM/a7zyNFDQ==", - "dependencies": { - "@jridgewell/gen-mapping": "^0.3.2", - "commander": "^4.0.0", - "glob": "7.1.6", - "lines-and-columns": "^1.1.6", - "mz": "^2.7.0", - "pirates": "^4.0.1", - "ts-interface-checker": "^0.1.9" - }, - "bin": { - "sucrase": "bin/sucrase", - "sucrase-node": "bin/sucrase-node" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/sucrase/node_modules/commander": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/commander/-/commander-4.1.1.tgz", - "integrity": "sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA==", - "engines": { - "node": ">= 6" - } - }, - "node_modules/sucrase/node_modules/glob": { - "version": "7.1.6", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", - "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", - "dependencies": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - }, - "engines": { - "node": "*" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/supports-color": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", - "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", - "dependencies": { - "has-flag": "^3.0.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/supports-hyperlinks": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/supports-hyperlinks/-/supports-hyperlinks-2.3.0.tgz", - "integrity": "sha512-RpsAZlpWcDwOPQA22aCH4J0t7L8JmAvsCxfOSEwm7cQs3LshN36QaTkwd70DnBOXDWGssw2eUoc8CaRWT0XunA==", - "dependencies": { - "has-flag": "^4.0.0", - "supports-color": "^7.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/supports-hyperlinks/node_modules/has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "engines": { - "node": ">=8" - } - }, - "node_modules/supports-hyperlinks/node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/supports-preserve-symlinks-flag": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", - "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/svg-parser": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/svg-parser/-/svg-parser-2.0.4.tgz", - "integrity": "sha512-e4hG1hRwoOdRb37cIMSgzNsxyzKfayW6VOflrwvR+/bzrkyxY/31WkbgnQpgtrNp1SdpJvpUAGTa/ZoiPNDuRQ==" - }, - "node_modules/svgo": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/svgo/-/svgo-1.3.2.tgz", - "integrity": "sha512-yhy/sQYxR5BkC98CY7o31VGsg014AKLEPxdfhora76l36hD9Rdy5NZA/Ocn6yayNPgSamYdtX2rFJdcv07AYVw==", - "deprecated": "This SVGO version is no longer supported. Upgrade to v2.x.x.", - "dependencies": { - "chalk": "^2.4.1", - "coa": "^2.0.2", - "css-select": "^2.0.0", - "css-select-base-adapter": "^0.1.1", - "css-tree": "1.0.0-alpha.37", - "csso": "^4.0.2", - "js-yaml": "^3.13.1", - "mkdirp": "~0.5.1", - "object.values": "^1.1.0", - "sax": "~1.2.4", - "stable": "^0.1.8", - "unquote": "~1.1.1", - "util.promisify": "~1.0.0" - }, - "bin": { - "svgo": "bin/svgo" - }, - "engines": { - "node": ">=4.0.0" - } - }, - "node_modules/svgo/node_modules/css-select": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/css-select/-/css-select-2.1.0.tgz", - "integrity": "sha512-Dqk7LQKpwLoH3VovzZnkzegqNSuAziQyNZUcrdDM401iY+R5NkGBXGmtO05/yaXQziALuPogeG0b7UAgjnTJTQ==", - "dependencies": { - "boolbase": "^1.0.0", - "css-what": "^3.2.1", - "domutils": "^1.7.0", - "nth-check": "^1.0.2" - } - }, - "node_modules/svgo/node_modules/css-what": { - "version": "3.4.2", - "resolved": "https://registry.npmjs.org/css-what/-/css-what-3.4.2.tgz", - "integrity": "sha512-ACUm3L0/jiZTqfzRM3Hi9Q8eZqd6IK37mMWPLz9PJxkLWllYeRf+EHUSHYEtFop2Eqytaq1FizFVh7XfBnXCDQ==", - "engines": { - "node": ">= 6" - }, - "funding": { - "url": "https://github.com/sponsors/fb55" - } - }, - "node_modules/svgo/node_modules/dom-serializer": { - "version": "0.2.2", - "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-0.2.2.tgz", - "integrity": "sha512-2/xPb3ORsQ42nHYiSunXkDjPLBaEj/xTwUO4B7XCZQTRk7EBtTOPaygh10YAAh2OI1Qrp6NWfpAhzswj0ydt9g==", - "dependencies": { - "domelementtype": "^2.0.1", - "entities": "^2.0.0" - } - }, - "node_modules/svgo/node_modules/domutils": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/domutils/-/domutils-1.7.0.tgz", - "integrity": "sha512-Lgd2XcJ/NjEw+7tFvfKxOzCYKZsdct5lczQ2ZaQY8Djz7pfAD3Gbp8ySJWtreII/vDlMVmxwa6pHmdxIYgttDg==", - "dependencies": { - "dom-serializer": "0", - "domelementtype": "1" - } - }, - "node_modules/svgo/node_modules/domutils/node_modules/domelementtype": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-1.3.1.tgz", - "integrity": "sha512-BSKB+TSpMpFI/HOxCNr1O8aMOTZ8hT3pM3GQ0w/mWRmkhEDSFJkkyzz4XQsBV44BChwGkrDfMyjVD0eA2aFV3w==" - }, - "node_modules/svgo/node_modules/nth-check": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/nth-check/-/nth-check-1.0.2.tgz", - "integrity": "sha512-WeBOdju8SnzPN5vTUJYxYUxLeXpCaVP5i5e0LF8fg7WORF2Wd7wFX/pk0tYZk7s8T+J7VLy0Da6J1+wCT0AtHg==", - "dependencies": { - "boolbase": "~1.0.0" - } - }, - "node_modules/symbol-tree": { - "version": "3.2.4", - "resolved": "https://registry.npmjs.org/symbol-tree/-/symbol-tree-3.2.4.tgz", - "integrity": "sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw==" - }, - "node_modules/synaptic": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/synaptic/-/synaptic-1.1.4.tgz", - "integrity": "sha512-JFtU98VDFI0uBTowgySo+UUEkc7rSVHaxx9D6dR5BK6u81G7uAxcp32Gi2SHciLpFbvJVd1Pfz7aqSNQO4EH9Q==", - "engines": { - "node": ">=4" - } - }, - "node_modules/tabbable": { - "version": "6.1.2", - "resolved": "https://registry.npmjs.org/tabbable/-/tabbable-6.1.2.tgz", - "integrity": "sha512-qCN98uP7i9z0fIS4amQ5zbGBOq+OSigYeGvPy7NDk8Y9yncqDZ9pRPgfsc2PJIVM9RrJj7GIfuRgmjoUU9zTHQ==" - }, - "node_modules/taffydb": { - "version": "2.7.3", - "resolved": "https://registry.npmjs.org/taffydb/-/taffydb-2.7.3.tgz", - "integrity": "sha512-GQ3gtYFSOAxSMN/apGtDKKkbJf+8izz5YfbGqIsUc7AMiQOapARZ76dhilRY2h39cynYxBFdafQo5HUL5vgkrg==" - }, - "node_modules/tailwindcss": { - "version": "3.3.2", - "resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-3.3.2.tgz", - "integrity": "sha512-9jPkMiIBXvPc2KywkraqsUfbfj+dHDb+JPWtSJa9MLFdrPyazI7q6WX2sUrm7R9eVR7qqv3Pas7EvQFzxKnI6w==", - "dependencies": { - "@alloc/quick-lru": "^5.2.0", - "arg": "^5.0.2", - "chokidar": "^3.5.3", - "didyoumean": "^1.2.2", - "dlv": "^1.1.3", - "fast-glob": "^3.2.12", - "glob-parent": "^6.0.2", - "is-glob": "^4.0.3", - "jiti": "^1.18.2", - "lilconfig": "^2.1.0", - "micromatch": "^4.0.5", - "normalize-path": "^3.0.0", - "object-hash": "^3.0.0", - "picocolors": "^1.0.0", - "postcss": "^8.4.23", - "postcss-import": "^15.1.0", - "postcss-js": "^4.0.1", - "postcss-load-config": "^4.0.1", - "postcss-nested": "^6.0.1", - "postcss-selector-parser": "^6.0.11", - "postcss-value-parser": "^4.2.0", - "resolve": "^1.22.2", - "sucrase": "^3.32.0" - }, - "bin": { - "tailwind": "lib/cli.js", - "tailwindcss": "lib/cli.js" - }, - "engines": { - "node": ">=14.0.0" - } - }, - "node_modules/tapable": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/tapable/-/tapable-2.2.1.tgz", - "integrity": "sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ==", - "engines": { - "node": ">=6" - } - }, - "node_modules/tar": { - "version": "4.4.19", - "resolved": "https://registry.npmjs.org/tar/-/tar-4.4.19.tgz", - "integrity": "sha512-a20gEsvHnWe0ygBY8JbxoM4w3SJdhc7ZAuxkLqh+nvNQN2IOt0B5lLgM490X5Hl8FF0dl0tOf2ewFYAlIFgzVA==", - "dependencies": { - "chownr": "^1.1.4", - "fs-minipass": "^1.2.7", - "minipass": "^2.9.0", - "minizlib": "^1.3.3", - "mkdirp": "^0.5.5", - "safe-buffer": "^5.2.1", - "yallist": "^3.1.1" - }, - "engines": { - "node": ">=4.5" - } - }, - "node_modules/temp-dir": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/temp-dir/-/temp-dir-2.0.0.tgz", - "integrity": "sha512-aoBAniQmmwtcKp/7BzsH8Cxzv8OL736p7v1ihGb5e9DJ9kTwGWHrQrVB5+lfVDzfGrdRzXch+ig7LHaY1JTOrg==", - "engines": { - "node": ">=8" - } - }, - "node_modules/tempy": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/tempy/-/tempy-0.6.0.tgz", - "integrity": "sha512-G13vtMYPT/J8A4X2SjdtBTphZlrp1gKv6hZiOjw14RCWg6GbHuQBGtjlx75xLbYV/wEc0D7G5K4rxKP/cXk8Bw==", - "dependencies": { - "is-stream": "^2.0.0", - "temp-dir": "^2.0.0", - "type-fest": "^0.16.0", - "unique-string": "^2.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/tempy/node_modules/type-fest": { - "version": "0.16.0", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.16.0.tgz", - "integrity": "sha512-eaBzG6MxNzEn9kiwvtre90cXaNLkmadMWa1zQMs3XORCXNbsH/OewwbxC5ia9dCxIxnTAsSxXJaa/p5y8DlvJg==", - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/terminal-link": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/terminal-link/-/terminal-link-2.1.1.tgz", - "integrity": "sha512-un0FmiRUQNr5PJqy9kP7c40F5BOfpGlYTrxonDChEZB7pzZxRNp/bt+ymiy9/npwXya9KH99nJ/GXFIiUkYGFQ==", - "dependencies": { - "ansi-escapes": "^4.2.1", - "supports-hyperlinks": "^2.0.0" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/terser": { - "version": "5.17.5", - "resolved": "https://registry.npmjs.org/terser/-/terser-5.17.5.tgz", - "integrity": "sha512-NqFkzBX34WExkCbk3K5urmNCpEWqMPZnwGI1pMHwqvJ/zDlXC75u3NI7BrzoR8/pryy8Abx2e1i8ChrWkhH1Hg==", - "dependencies": { - "@jridgewell/source-map": "^0.3.2", - "acorn": "^8.5.0", - "commander": "^2.20.0", - "source-map-support": "~0.5.20" - }, - "bin": { - "terser": "bin/terser" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/terser-webpack-plugin": { - "version": "5.3.9", - "resolved": "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-5.3.9.tgz", - "integrity": "sha512-ZuXsqE07EcggTWQjXUj+Aot/OMcD0bMKGgF63f7UxYcu5/AJF53aIpK1YoP5xR9l6s/Hy2b+t1AM0bLNPRuhwA==", - "dependencies": { - "@jridgewell/trace-mapping": "^0.3.17", - "jest-worker": "^27.4.5", - "schema-utils": "^3.1.1", - "serialize-javascript": "^6.0.1", - "terser": "^5.16.8" - }, - "engines": { - "node": ">= 10.13.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/webpack" - }, - "peerDependencies": { - "webpack": "^5.1.0" - }, - "peerDependenciesMeta": { - "@swc/core": { - "optional": true - }, - "esbuild": { - "optional": true - }, - "uglify-js": { - "optional": true - } - } - }, - "node_modules/terser/node_modules/commander": { - "version": "2.20.3", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", - "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==" - }, - "node_modules/test-exclude": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-6.0.0.tgz", - "integrity": "sha512-cAGWPIyOHU6zlmg88jwm7VRyXnMN7iV68OGAbYDk/Mh/xC/pzVPlQtY6ngoIH/5/tciuhGfvESU8GrHrcxD56w==", - "dependencies": { - "@istanbuljs/schema": "^0.1.2", - "glob": "^7.1.4", - "minimatch": "^3.0.4" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/text-table": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", - "integrity": "sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==" - }, - "node_modules/thenify": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/thenify/-/thenify-3.3.1.tgz", - "integrity": "sha512-RVZSIV5IG10Hk3enotrhvz0T9em6cyHBLkH/YAZuKqd8hRkKhSfCGIcP2KUY0EPxndzANBmNllzWPwak+bheSw==", - "dependencies": { - "any-promise": "^1.0.0" - } - }, - "node_modules/thenify-all": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/thenify-all/-/thenify-all-1.6.0.tgz", - "integrity": "sha512-RNxQH/qI8/t3thXJDwcstUO4zeqo64+Uy/+sNVRBx4Xn2OX+OZ9oP+iJnNFqplFra2ZUVeKCSa2oVWi3T4uVmA==", - "dependencies": { - "thenify": ">= 3.1.0 < 4" - }, - "engines": { - "node": ">=0.8" - } - }, - "node_modules/throat": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/throat/-/throat-6.0.2.tgz", - "integrity": "sha512-WKexMoJj3vEuK0yFEapj8y64V0A6xcuPuK9Gt1d0R+dzCSJc0lHqQytAbSB4cDAK0dWh4T0E2ETkoLE2WZ41OQ==" - }, - "node_modules/throttle-debounce": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/throttle-debounce/-/throttle-debounce-3.0.1.tgz", - "integrity": "sha512-dTEWWNu6JmeVXY0ZYoPuH5cRIwc0MeGbJwah9KUNYSJwommQpCzTySTpEe8Gs1J23aeWEuAobe4Ag7EHVt/LOg==", - "peer": true, - "engines": { - "node": ">=10" - } - }, - "node_modules/thunky": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/thunky/-/thunky-1.1.0.tgz", - "integrity": "sha512-eHY7nBftgThBqOyHGVN+l8gF0BucP09fMo0oO/Lb0w1OF80dJv+lDVpXG60WMQvkcxAkNybKsrEIE3ZtKGmPrA==" - }, - "node_modules/tippy.js": { - "version": "6.3.7", - "resolved": "https://registry.npmjs.org/tippy.js/-/tippy.js-6.3.7.tgz", - "integrity": "sha512-E1d3oP2emgJ9dRQZdf3Kkn0qJgI6ZLpyS5z6ZkY1DF3kaQaBsGZsndEpHwx+eC+tYM41HaSNvNtLx8tU57FzTQ==", - "dependencies": { - "@popperjs/core": "^2.9.0" - } - }, - "node_modules/tmpl": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/tmpl/-/tmpl-1.0.5.tgz", - "integrity": "sha512-3f0uOEAQwIqGuWW2MVzYg8fV/QNnc/IpuJNG837rLuczAaLVHslWHZQj4IGiEl5Hs3kkbhwL9Ab7Hrsmuj+Smw==" - }, - "node_modules/to-fast-properties": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", - "integrity": "sha512-/OaKK0xYrs3DmxRYqL/yDc+FxFUVYhDlXMhRmv3z915w2HF1tnN1omB354j8VUGO/hbRzyD6Y3sA7v7GS/ceog==", - "engines": { - "node": ">=4" - } - }, - "node_modules/to-regex-range": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", - "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", - "dependencies": { - "is-number": "^7.0.0" - }, - "engines": { - "node": ">=8.0" - } - }, - "node_modules/toidentifier": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", - "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", - "engines": { - "node": ">=0.6" - } - }, - "node_modules/tough-cookie": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-4.1.2.tgz", - "integrity": "sha512-G9fqXWoYFZgTc2z8Q5zaHy/vJMjm+WV0AkAeHxVCQiEB1b+dGvWzFW6QV07cY5jQ5gRkeid2qIkzkxUnmoQZUQ==", - "dependencies": { - "psl": "^1.1.33", - "punycode": "^2.1.1", - "universalify": "^0.2.0", - "url-parse": "^1.5.3" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/tough-cookie/node_modules/universalify": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.2.0.tgz", - "integrity": "sha512-CJ1QgKmNg3CwvAv/kOFmtnEN05f0D/cn9QntgNOQlQF9dgvVTHj3t+8JPdjqawCHk7V/KA+fbUqzZ9XWhcqPUg==", - "engines": { - "node": ">= 4.0.0" - } - }, - "node_modules/tr46": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/tr46/-/tr46-2.1.0.tgz", - "integrity": "sha512-15Ih7phfcdP5YxqiB+iDtLoaTz4Nd35+IiAv0kQ5FNKHzXgdWqPoTIqEDDJmXceQt4JZk6lVPT8lnDlPpGDppw==", - "dependencies": { - "punycode": "^2.1.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/trim-right": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/trim-right/-/trim-right-1.0.1.tgz", - "integrity": "sha512-WZGXGstmCWgeevgTL54hrCuw1dyMQIzWy7ZfqRJfSmJZBwklI15egmQytFP6bPidmw3M8d5yEowl1niq4vmqZw==", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/tryer": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/tryer/-/tryer-1.0.1.tgz", - "integrity": "sha512-c3zayb8/kWWpycWYg87P71E1S1ZL6b6IJxfb5fvsUgsf0S2MVGaDhDXXjDMpdCpfWXqptc+4mXwmiy1ypXqRAA==" - }, - "node_modules/ts-interface-checker": { - "version": "0.1.13", - "resolved": "https://registry.npmjs.org/ts-interface-checker/-/ts-interface-checker-0.1.13.tgz", - "integrity": "sha512-Y/arvbn+rrz3JCKl9C4kVNfTfSm2/mEp5FSz5EsZSANGPSlQrpRI5M4PKF+mJnE52jOO90PnPSc3Ur3bTQw0gA==" - }, - "node_modules/tsconfig-paths": { - "version": "3.14.2", - "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.14.2.tgz", - "integrity": "sha512-o/9iXgCYc5L/JxCHPe3Hvh8Q/2xm5Z+p18PESBU6Ff33695QnCHBEjcytY2q19ua7Mbl/DavtBOLq+oG0RCL+g==", - "dependencies": { - "@types/json5": "^0.0.29", - "json5": "^1.0.2", - "minimist": "^1.2.6", - "strip-bom": "^3.0.0" - } - }, - "node_modules/tsconfig-paths/node_modules/json5": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.2.tgz", - "integrity": "sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA==", - "dependencies": { - "minimist": "^1.2.0" - }, - "bin": { - "json5": "lib/cli.js" - } - }, - "node_modules/tsconfig-paths/node_modules/strip-bom": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", - "integrity": "sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==", - "engines": { - "node": ">=4" - } - }, - "node_modules/tslib": { - "version": "2.6.2", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz", - "integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==" - }, - "node_modules/tsutils": { - "version": "3.21.0", - "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.21.0.tgz", - "integrity": "sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==", - "dependencies": { - "tslib": "^1.8.1" - }, - "engines": { - "node": ">= 6" - }, - "peerDependencies": { - "typescript": ">=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta" - } - }, - "node_modules/tsutils/node_modules/tslib": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", - "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==" - }, - "node_modules/tunnel-agent": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", - "integrity": "sha512-McnNiV1l8RYeY8tBgEpuodCC1mLUdbSN+CYBL7kJsJNInOP8UjDDEwdk6Mw60vdLLrr5NHKZhMAOSrR2NZuQ+w==", - "optional": true, - "dependencies": { - "safe-buffer": "^5.0.1" - }, - "engines": { - "node": "*" - } - }, - "node_modules/tweetnacl": { - "version": "0.14.5", - "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", - "integrity": "sha512-KXXFFdAbFXY4geFIwoyNK+f5Z1b7swfXABfL7HXCmoIWMKU3dmS26672A4EeQtDzLKy7SXmfBu51JolvEKwtGA==", - "optional": true - }, - "node_modules/type-check": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", - "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", - "dependencies": { - "prelude-ls": "^1.2.1" - }, - "engines": { - "node": ">= 0.8.0" - } - }, - "node_modules/type-detect": { - "version": "4.0.8", - "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", - "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", - "engines": { - "node": ">=4" - } - }, - "node_modules/type-fest": { - "version": "0.21.3", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.21.3.tgz", - "integrity": "sha512-t0rzBq87m3fVcduHDUFhKmyyX+9eo6WQjZvf51Ea/M0Q7+T374Jp1aUiyUl0GKxp8M/OETVHSDvmkyPgvX+X2w==", - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/type-is": { - "version": "1.6.18", - "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", - "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==", - "dependencies": { - "media-typer": "0.3.0", - "mime-types": "~2.1.24" - }, - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/typed-array-length": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/typed-array-length/-/typed-array-length-1.0.4.tgz", - "integrity": "sha512-KjZypGq+I/H7HI5HlOoGHkWUUGq+Q0TPhQurLbyrVrvnKTBgzLhIJ7j6J/XTQOi0d1RjyZ0wdas8bKs2p0x3Ng==", - "dependencies": { - "call-bind": "^1.0.2", - "for-each": "^0.3.3", - "is-typed-array": "^1.1.9" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/typedarray-to-buffer": { - "version": "3.1.5", - "resolved": "https://registry.npmjs.org/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz", - "integrity": "sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q==", - "dependencies": { - "is-typedarray": "^1.0.0" - } - }, - "node_modules/typescript": { - "version": "4.9.5", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz", - "integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==", - "peer": true, - "bin": { - "tsc": "bin/tsc", - "tsserver": "bin/tsserver" - }, - "engines": { - "node": ">=4.2.0" - } - }, - "node_modules/uc.micro": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-1.0.6.tgz", - "integrity": "sha512-8Y75pvTYkLJW2hWQHXxoqRgV7qb9B+9vFEtidML+7koHUFapnVJAZ6cKs+Qjz5Aw3aZWHMC6u0wJE3At+nSGwA==", - "peer": true - }, - "node_modules/unbox-primitive": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.2.tgz", - "integrity": "sha512-61pPlCD9h51VoreyJ0BReideM3MDKMKnh6+V9L08331ipq6Q8OFXZYiqP6n/tbHx4s5I9uRhcye6BrbkizkBDw==", - "dependencies": { - "call-bind": "^1.0.2", - "has-bigints": "^1.0.2", - "has-symbols": "^1.0.3", - "which-boxed-primitive": "^1.0.2" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/underscore": { - "version": "1.13.6", - "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.13.6.tgz", - "integrity": "sha512-+A5Sja4HP1M08MaXya7p5LvjuM7K6q/2EaC0+iovj/wOcMsTzMvDFbasi/oSapiwOlt252IqsKqPjCl7huKS0A==" - }, - "node_modules/unicode-canonical-property-names-ecmascript": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-2.0.0.tgz", - "integrity": "sha512-yY5PpDlfVIU5+y/BSCxAJRBIS1Zc2dDG3Ujq+sR0U+JjUevW2JhocOF+soROYDSaAezOzOKuyyixhD6mBknSmQ==", - "engines": { - "node": ">=4" - } - }, - "node_modules/unicode-match-property-ecmascript": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/unicode-match-property-ecmascript/-/unicode-match-property-ecmascript-2.0.0.tgz", - "integrity": "sha512-5kaZCrbp5mmbz5ulBkDkbY0SsPOjKqVS35VpL9ulMPfSl0J0Xsm+9Evphv9CoIZFwre7aJoa94AY6seMKGVN5Q==", - "dependencies": { - "unicode-canonical-property-names-ecmascript": "^2.0.0", - "unicode-property-aliases-ecmascript": "^2.0.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/unicode-match-property-value-ecmascript": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/unicode-match-property-value-ecmascript/-/unicode-match-property-value-ecmascript-2.1.0.tgz", - "integrity": "sha512-qxkjQt6qjg/mYscYMC0XKRn3Rh0wFPlfxB0xkt9CfyTvpX1Ra0+rAmdX2QyAobptSEvuy4RtpPRui6XkV+8wjA==", - "engines": { - "node": ">=4" - } - }, - "node_modules/unicode-property-aliases-ecmascript": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/unicode-property-aliases-ecmascript/-/unicode-property-aliases-ecmascript-2.1.0.tgz", - "integrity": "sha512-6t3foTQI9qne+OZoVQB/8x8rk2k1eVy1gRXhV3oFQ5T6R1dqQ1xtin3XqSlx3+ATBkliTaR/hHyJBm+LVPNM8w==", - "engines": { - "node": ">=4" - } - }, - "node_modules/unique-string": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/unique-string/-/unique-string-2.0.0.tgz", - "integrity": "sha512-uNaeirEPvpZWSgzwsPGtU2zVSTrn/8L5q/IexZmH0eH6SA73CmAA5U4GwORTxQAZs95TAXLNqeLoPPNO5gZfWg==", - "dependencies": { - "crypto-random-string": "^2.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/universalify": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz", - "integrity": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==", - "engines": { - "node": ">= 10.0.0" - } - }, - "node_modules/unpipe": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", - "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==", - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/unquote": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/unquote/-/unquote-1.1.1.tgz", - "integrity": "sha512-vRCqFv6UhXpWxZPyGDh/F3ZpNv8/qo7w6iufLpQg9aKnQ71qM4B5KiI7Mia9COcjEhrO9LueHpMYjYzsWH3OIg==" - }, - "node_modules/upath": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/upath/-/upath-1.2.0.tgz", - "integrity": "sha512-aZwGpamFO61g3OlfT7OQCHqhGnW43ieH9WZeP7QxN/G/jS4jfqUkZxoryvJgVPEcrl5NL/ggHsSmLMHuH64Lhg==", - "engines": { - "node": ">=4", - "yarn": "*" - } - }, - "node_modules/update-browserslist-db": { - "version": "1.0.11", - "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.11.tgz", - "integrity": "sha512-dCwEFf0/oT85M1fHBg4F0jtLwJrutGoHSQXCh7u4o2t1drG+c0a9Flnqww6XUKSfQMPpJBRjU8d4RXB09qtvaA==", - "funding": [ - { - "type": "opencollective", - "url": "https://opencollective.com/browserslist" - }, - { - "type": "tidelift", - "url": "https://tidelift.com/funding/github/npm/browserslist" - }, - { - "type": "github", - "url": "https://github.com/sponsors/ai" - } - ], - "dependencies": { - "escalade": "^3.1.1", - "picocolors": "^1.0.0" - }, - "bin": { - "update-browserslist-db": "cli.js" - }, - "peerDependencies": { - "browserslist": ">= 4.21.0" - } - }, - "node_modules/uri-js": { - "version": "4.4.1", - "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", - "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", - "dependencies": { - "punycode": "^2.1.0" - } - }, - "node_modules/url": { - "version": "0.11.0", - "resolved": "https://registry.npmjs.org/url/-/url-0.11.0.tgz", - "integrity": "sha512-kbailJa29QrtXnxgq+DdCEGlbTeYM2eJUxsz6vjZavrCYPMIFHMKQmSKYAIuUK2i7hgPm28a8piX5NTUtM/LKQ==", - "dependencies": { - "punycode": "1.3.2", - "querystring": "0.2.0" - } - }, - "node_modules/url-parse": { - "version": "1.5.10", - "resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.5.10.tgz", - "integrity": "sha512-WypcfiRhfeUP9vvF0j6rw0J3hrWrw6iZv3+22h6iRMJ/8z1Tj6XfLP4DsUix5MhMPnXpiHDoKyoZ/bdCkwBCiQ==", - "dependencies": { - "querystringify": "^2.1.1", - "requires-port": "^1.0.0" - } - }, - "node_modules/url/node_modules/punycode": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.3.2.tgz", - "integrity": "sha512-RofWgt/7fL5wP1Y7fxE7/EmTLzQVnB0ycyibJ0OOHIlJqTNzglYFxVwETOcIoJqJmpDXJ9xImDv+Fq34F/d4Dw==" - }, - "node_modules/use-callback-ref": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/use-callback-ref/-/use-callback-ref-1.3.0.tgz", - "integrity": "sha512-3FT9PRuRdbB9HfXhEq35u4oZkvpJ5kuYbpqhCfmiZyReuRgpnhDlbr2ZEnnuS0RrJAPn6l23xjFg9kpDM+Ms7w==", - "dependencies": { - "tslib": "^2.0.0" - }, - "engines": { - "node": ">=10" - }, - "peerDependencies": { - "@types/react": "^16.8.0 || ^17.0.0 || ^18.0.0", - "react": "^16.8.0 || ^17.0.0 || ^18.0.0" - }, - "peerDependenciesMeta": { - "@types/react": { - "optional": true - } - } - }, - "node_modules/use-composed-ref": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/use-composed-ref/-/use-composed-ref-1.3.0.tgz", - "integrity": "sha512-GLMG0Jc/jiKov/3Ulid1wbv3r54K9HlMW29IWcDFPEqFkSO2nS0MuefWgMJpeHQ9YJeXDL3ZUF+P3jdXlZX/cQ==", - "peerDependencies": { - "react": "^16.8.0 || ^17.0.0 || ^18.0.0" - } - }, - "node_modules/use-effect-x": { - "version": "0.1.5", - "resolved": "https://registry.npmjs.org/use-effect-x/-/use-effect-x-0.1.5.tgz", - "integrity": "sha512-VmV7iBN8ZQEBcJ/AMtcHJIih2ko7+vbeRd+FFy+TBt49tCyDStnxeq1N0MK60faQexOTnrOIHGDO+qa3p5o6Hw==", - "peerDependencies": { - "react": ">=16" - } - }, - "node_modules/use-isomorphic-layout-effect": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/use-isomorphic-layout-effect/-/use-isomorphic-layout-effect-1.1.2.tgz", - "integrity": "sha512-49L8yCO3iGT/ZF9QttjwLF/ZD9Iwto5LnH5LmEdk/6cFmXddqi2ulF0edxTwjj+7mqvpVVGQWvbXZdn32wRSHA==", - "peerDependencies": { - "react": "^16.8.0 || ^17.0.0 || ^18.0.0" - }, - "peerDependenciesMeta": { - "@types/react": { - "optional": true - } - } - }, - "node_modules/use-latest": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/use-latest/-/use-latest-1.2.1.tgz", - "integrity": "sha512-xA+AVm/Wlg3e2P/JiItTziwS7FK92LWrDB0p+hgXloIMuVCeJJ8v6f0eeHyPZaJrM+usM1FkFfbNCrJGs8A/zw==", - "dependencies": { - "use-isomorphic-layout-effect": "^1.1.1" - }, - "peerDependencies": { - "react": "^16.8.0 || ^17.0.0 || ^18.0.0" - }, - "peerDependenciesMeta": { - "@types/react": { - "optional": true - } - } - }, - "node_modules/use-sidecar": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/use-sidecar/-/use-sidecar-1.1.2.tgz", - "integrity": "sha512-epTbsLuzZ7lPClpz2TyryBfztm7m+28DlEv2ZCQ3MDr5ssiwyOwGH/e5F9CkfWjJ1t4clvI58yF822/GUkjjhw==", - "dependencies": { - "detect-node-es": "^1.1.0", - "tslib": "^2.0.0" - }, - "engines": { - "node": ">=10" - }, - "peerDependencies": { - "@types/react": "^16.9.0 || ^17.0.0 || ^18.0.0", - "react": "^16.8.0 || ^17.0.0 || ^18.0.0" - }, - "peerDependenciesMeta": { - "@types/react": { - "optional": true - } - } - }, - "node_modules/util": { - "version": "0.12.5", - "resolved": "https://registry.npmjs.org/util/-/util-0.12.5.tgz", - "integrity": "sha512-kZf/K6hEIrWHI6XqOFUiiMa+79wE/D8Q+NCNAWclkyg3b4d2k7s0QGepNjiABc+aR3N1PAyHL7p6UcLY6LmrnA==", - "dependencies": { - "inherits": "^2.0.3", - "is-arguments": "^1.0.4", - "is-generator-function": "^1.0.7", - "is-typed-array": "^1.1.3", - "which-typed-array": "^1.1.2" - } - }, - "node_modules/util-deprecate": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==" - }, - "node_modules/util.promisify": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/util.promisify/-/util.promisify-1.0.1.tgz", - "integrity": "sha512-g9JpC/3He3bm38zsLupWryXHoEcS22YHthuPQSJdMy6KNrzIRzWqcsHzD/WUnqe45whVou4VIsPew37DoXWNrA==", - "dependencies": { - "define-properties": "^1.1.3", - "es-abstract": "^1.17.2", - "has-symbols": "^1.0.1", - "object.getownpropertydescriptors": "^2.1.0" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/utila": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/utila/-/utila-0.4.0.tgz", - "integrity": "sha512-Z0DbgELS9/L/75wZbro8xAnT50pBVFQZ+hUEueGDU5FN51YSCYM+jdxsfCiHjwNP/4LCDD0i/graKpeBnOXKRA==" - }, - "node_modules/utils-merge": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", - "integrity": "sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==", - "engines": { - "node": ">= 0.4.0" - } - }, - "node_modules/uuid": { - "version": "8.3.2", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", - "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", - "bin": { - "uuid": "dist/bin/uuid" - } - }, - "node_modules/v8-to-istanbul": { - "version": "8.1.1", - "resolved": "https://registry.npmjs.org/v8-to-istanbul/-/v8-to-istanbul-8.1.1.tgz", - "integrity": "sha512-FGtKtv3xIpR6BYhvgH8MI/y78oT7d8Au3ww4QIxymrCtZEh5b8gCw2siywE+puhEmuWKDtmfrvF5UlB298ut3w==", - "dependencies": { - "@types/istanbul-lib-coverage": "^2.0.1", - "convert-source-map": "^1.6.0", - "source-map": "^0.7.3" - }, - "engines": { - "node": ">=10.12.0" - } - }, - "node_modules/vary": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", - "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==", - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/verror": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", - "integrity": "sha512-ZZKSmDAEFOijERBLkmYfJ+vmk3w+7hOLYDNkRCuRuMJGEmqYNCNLyBBFwWKVMhfwaEF3WOd0Zlw86U/WC/+nYw==", - "engines": [ - "node >=0.6.0" - ], - "optional": true, - "dependencies": { - "assert-plus": "^1.0.0", - "core-util-is": "1.0.2", - "extsprintf": "^1.2.0" - } - }, - "node_modules/verror/node_modules/core-util-is": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "integrity": "sha512-3lqz5YjWTYnW6dlDa5TLaTCcShfar1e40rmcJVwCBJC6mWlFuj0eCHIElmG1g5kyuJ/GD+8Wn4FFCcz4gJPfaQ==", - "optional": true - }, - "node_modules/w3c-hr-time": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/w3c-hr-time/-/w3c-hr-time-1.0.2.tgz", - "integrity": "sha512-z8P5DvDNjKDoFIHK7q8r8lackT6l+jo/Ye3HOle7l9nICP9lf1Ci25fy9vHd0JOWewkIFzXIEig3TdKT7JQ5fQ==", - "deprecated": "Use your platform's native performance.now() and performance.timeOrigin.", - "dependencies": { - "browser-process-hrtime": "^1.0.0" - } - }, - "node_modules/w3c-keyname": { - "version": "2.2.7", - "resolved": "https://registry.npmjs.org/w3c-keyname/-/w3c-keyname-2.2.7.tgz", - "integrity": "sha512-XB8aa62d4rrVfoZYQaYNy3fy+z4nrfy2ooea3/0BnBzXW0tSdZ+lRgjzBZhk0La0H6h8fVyYCxx/qkQcAIuvfg==", - "peer": true - }, - "node_modules/w3c-xmlserializer": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/w3c-xmlserializer/-/w3c-xmlserializer-2.0.0.tgz", - "integrity": "sha512-4tzD0mF8iSiMiNs30BiLO3EpfGLZUT2MSX/G+o7ZywDzliWQ3OPtTZ0PTC3B3ca1UAf4cJMHB+2Bf56EriJuRA==", - "dependencies": { - "xml-name-validator": "^3.0.0" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/walker": { - "version": "1.0.8", - "resolved": "https://registry.npmjs.org/walker/-/walker-1.0.8.tgz", - "integrity": "sha512-ts/8E8l5b7kY0vlWLewOkDXMmPdLcVV4GmOQLyxuSswIJsweeFZtAsMF7k1Nszz+TYBQrlYRmzOnr398y1JemQ==", - "dependencies": { - "makeerror": "1.0.12" - } - }, - "node_modules/watchpack": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/watchpack/-/watchpack-2.4.0.tgz", - "integrity": "sha512-Lcvm7MGST/4fup+ifyKi2hjyIAwcdI4HRgtvTpIUxBRhB+RFtUh8XtDOxUfctVCnhVi+QQj49i91OyvzkJl6cg==", - "dependencies": { - "glob-to-regexp": "^0.4.1", - "graceful-fs": "^4.1.2" - }, - "engines": { - "node": ">=10.13.0" - } - }, - "node_modules/wbuf": { - "version": "1.7.3", - "resolved": "https://registry.npmjs.org/wbuf/-/wbuf-1.7.3.tgz", - "integrity": "sha512-O84QOnr0icsbFGLS0O3bI5FswxzRr8/gHwWkDlQFskhSPryQXvrTMxjxGP4+iWYoauLoBvfDpkrOauZ+0iZpDA==", - "dependencies": { - "minimalistic-assert": "^1.0.0" - } - }, - "node_modules/web-vitals": { - "version": "2.1.4", - "resolved": "https://registry.npmjs.org/web-vitals/-/web-vitals-2.1.4.tgz", - "integrity": "sha512-sVWcwhU5mX6crfI5Vd2dC4qchyTqxV8URinzt25XqVh+bHEPGH4C3NPrNionCP7Obx59wrYEbNlw4Z8sjALzZg==" - }, - "node_modules/webidl-conversions": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-6.1.0.tgz", - "integrity": "sha512-qBIvFLGiBpLjfwmYAaHPXsn+ho5xZnGvyGvsarywGNc8VyQJUMHJ8OBKGGrPER0okBeMDaan4mNBlgBROxuI8w==", - "engines": { - "node": ">=10.4" - } - }, - "node_modules/webpack": { - "version": "5.89.0", - "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.89.0.tgz", - "integrity": "sha512-qyfIC10pOr70V+jkmud8tMfajraGCZMBWJtrmuBymQKCrLTRejBI8STDp1MCyZu/QTdZSeacCQYpYNQVOzX5kw==", - "dependencies": { - "@types/eslint-scope": "^3.7.3", - "@types/estree": "^1.0.0", - "@webassemblyjs/ast": "^1.11.5", - "@webassemblyjs/wasm-edit": "^1.11.5", - "@webassemblyjs/wasm-parser": "^1.11.5", - "acorn": "^8.7.1", - "acorn-import-assertions": "^1.9.0", - "browserslist": "^4.14.5", - "chrome-trace-event": "^1.0.2", - "enhanced-resolve": "^5.15.0", - "es-module-lexer": "^1.2.1", - "eslint-scope": "5.1.1", - "events": "^3.2.0", - "glob-to-regexp": "^0.4.1", - "graceful-fs": "^4.2.9", - "json-parse-even-better-errors": "^2.3.1", - "loader-runner": "^4.2.0", - "mime-types": "^2.1.27", - "neo-async": "^2.6.2", - "schema-utils": "^3.2.0", - "tapable": "^2.1.1", - "terser-webpack-plugin": "^5.3.7", - "watchpack": "^2.4.0", - "webpack-sources": "^3.2.3" - }, - "bin": { - "webpack": "bin/webpack.js" - }, - "engines": { - "node": ">=10.13.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/webpack" - }, - "peerDependenciesMeta": { - "webpack-cli": { - "optional": true - } - } - }, - "node_modules/webpack-dev-middleware": { - "version": "5.3.3", - "resolved": "https://registry.npmjs.org/webpack-dev-middleware/-/webpack-dev-middleware-5.3.3.tgz", - "integrity": "sha512-hj5CYrY0bZLB+eTO+x/j67Pkrquiy7kWepMHmUMoPsmcUaeEnQJqFzHJOyxgWlq746/wUuA64p9ta34Kyb01pA==", - "dependencies": { - "colorette": "^2.0.10", - "memfs": "^3.4.3", - "mime-types": "^2.1.31", - "range-parser": "^1.2.1", - "schema-utils": "^4.0.0" - }, - "engines": { - "node": ">= 12.13.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/webpack" - }, - "peerDependencies": { - "webpack": "^4.0.0 || ^5.0.0" - } - }, - "node_modules/webpack-dev-middleware/node_modules/ajv": { - "version": "8.12.0", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.12.0.tgz", - "integrity": "sha512-sRu1kpcO9yLtYxBKvqfTeh9KzZEwO3STyX1HT+4CaDzC6HpTGYhIhPIzj9XuKU7KYDwnaeh5hcOwjy1QuJzBPA==", - "dependencies": { - "fast-deep-equal": "^3.1.1", - "json-schema-traverse": "^1.0.0", - "require-from-string": "^2.0.2", - "uri-js": "^4.2.2" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/epoberezkin" - } - }, - "node_modules/webpack-dev-middleware/node_modules/ajv-keywords": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-5.1.0.tgz", - "integrity": "sha512-YCS/JNFAUyr5vAuhk1DWm1CBxRHW9LbJ2ozWeemrIqpbsqKjHVxYPyi5GC0rjZIT5JxJ3virVTS8wk4i/Z+krw==", - "dependencies": { - "fast-deep-equal": "^3.1.3" - }, - "peerDependencies": { - "ajv": "^8.8.2" - } - }, - "node_modules/webpack-dev-middleware/node_modules/json-schema-traverse": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", - "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==" - }, - "node_modules/webpack-dev-middleware/node_modules/schema-utils": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-4.0.1.tgz", - "integrity": "sha512-lELhBAAly9NowEsX0yZBlw9ahZG+sK/1RJ21EpzdYHKEs13Vku3LJ+MIPhh4sMs0oCCeufZQEQbMekiA4vuVIQ==", - "dependencies": { - "@types/json-schema": "^7.0.9", - "ajv": "^8.9.0", - "ajv-formats": "^2.1.1", - "ajv-keywords": "^5.1.0" - }, - "engines": { - "node": ">= 12.13.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/webpack" - } - }, - "node_modules/webpack-dev-server": { - "version": "4.15.0", - "resolved": "https://registry.npmjs.org/webpack-dev-server/-/webpack-dev-server-4.15.0.tgz", - "integrity": "sha512-HmNB5QeSl1KpulTBQ8UT4FPrByYyaLxpJoQ0+s7EvUrMc16m0ZS1sgb1XGqzmgCPk0c9y+aaXxn11tbLzuM7NQ==", - "dependencies": { - "@types/bonjour": "^3.5.9", - "@types/connect-history-api-fallback": "^1.3.5", - "@types/express": "^4.17.13", - "@types/serve-index": "^1.9.1", - "@types/serve-static": "^1.13.10", - "@types/sockjs": "^0.3.33", - "@types/ws": "^8.5.1", - "ansi-html-community": "^0.0.8", - "bonjour-service": "^1.0.11", - "chokidar": "^3.5.3", - "colorette": "^2.0.10", - "compression": "^1.7.4", - "connect-history-api-fallback": "^2.0.0", - "default-gateway": "^6.0.3", - "express": "^4.17.3", - "graceful-fs": "^4.2.6", - "html-entities": "^2.3.2", - "http-proxy-middleware": "^2.0.3", - "ipaddr.js": "^2.0.1", - "launch-editor": "^2.6.0", - "open": "^8.0.9", - "p-retry": "^4.5.0", - "rimraf": "^3.0.2", - "schema-utils": "^4.0.0", - "selfsigned": "^2.1.1", - "serve-index": "^1.9.1", - "sockjs": "^0.3.24", - "spdy": "^4.0.2", - "webpack-dev-middleware": "^5.3.1", - "ws": "^8.13.0" - }, - "bin": { - "webpack-dev-server": "bin/webpack-dev-server.js" - }, - "engines": { - "node": ">= 12.13.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/webpack" - }, - "peerDependencies": { - "webpack": "^4.37.0 || ^5.0.0" - }, - "peerDependenciesMeta": { - "webpack": { - "optional": true - }, - "webpack-cli": { - "optional": true - } - } - }, - "node_modules/webpack-dev-server/node_modules/ajv": { - "version": "8.12.0", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.12.0.tgz", - "integrity": "sha512-sRu1kpcO9yLtYxBKvqfTeh9KzZEwO3STyX1HT+4CaDzC6HpTGYhIhPIzj9XuKU7KYDwnaeh5hcOwjy1QuJzBPA==", - "dependencies": { - "fast-deep-equal": "^3.1.1", - "json-schema-traverse": "^1.0.0", - "require-from-string": "^2.0.2", - "uri-js": "^4.2.2" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/epoberezkin" - } - }, - "node_modules/webpack-dev-server/node_modules/ajv-keywords": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-5.1.0.tgz", - "integrity": "sha512-YCS/JNFAUyr5vAuhk1DWm1CBxRHW9LbJ2ozWeemrIqpbsqKjHVxYPyi5GC0rjZIT5JxJ3virVTS8wk4i/Z+krw==", - "dependencies": { - "fast-deep-equal": "^3.1.3" - }, - "peerDependencies": { - "ajv": "^8.8.2" - } - }, - "node_modules/webpack-dev-server/node_modules/json-schema-traverse": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", - "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==" - }, - "node_modules/webpack-dev-server/node_modules/schema-utils": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-4.0.1.tgz", - "integrity": "sha512-lELhBAAly9NowEsX0yZBlw9ahZG+sK/1RJ21EpzdYHKEs13Vku3LJ+MIPhh4sMs0oCCeufZQEQbMekiA4vuVIQ==", - "dependencies": { - "@types/json-schema": "^7.0.9", - "ajv": "^8.9.0", - "ajv-formats": "^2.1.1", - "ajv-keywords": "^5.1.0" - }, - "engines": { - "node": ">= 12.13.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/webpack" - } - }, - "node_modules/webpack-dev-server/node_modules/ws": { - "version": "8.13.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.13.0.tgz", - "integrity": "sha512-x9vcZYTrFPC7aSIbj7sRCYo7L/Xb8Iy+pW0ng0wt2vCJv7M9HOMy0UoN3rr+IFC7hb7vXoqS+P9ktyLLLhO+LA==", - "engines": { - "node": ">=10.0.0" - }, - "peerDependencies": { - "bufferutil": "^4.0.1", - "utf-8-validate": ">=5.0.2" - }, - "peerDependenciesMeta": { - "bufferutil": { - "optional": true - }, - "utf-8-validate": { - "optional": true - } - } - }, - "node_modules/webpack-manifest-plugin": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/webpack-manifest-plugin/-/webpack-manifest-plugin-4.1.1.tgz", - "integrity": "sha512-YXUAwxtfKIJIKkhg03MKuiFAD72PlrqCiwdwO4VEXdRO5V0ORCNwaOwAZawPZalCbmH9kBDmXnNeQOw+BIEiow==", - "dependencies": { - "tapable": "^2.0.0", - "webpack-sources": "^2.2.0" - }, - "engines": { - "node": ">=12.22.0" - }, - "peerDependencies": { - "webpack": "^4.44.2 || ^5.47.0" - } - }, - "node_modules/webpack-manifest-plugin/node_modules/source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/webpack-manifest-plugin/node_modules/webpack-sources": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/webpack-sources/-/webpack-sources-2.3.1.tgz", - "integrity": "sha512-y9EI9AO42JjEcrTJFOYmVywVZdKVUfOvDUPsJea5GIr1JOEGFVqwlY2K098fFoIjOkDzHn2AjRvM8dsBZu+gCA==", - "dependencies": { - "source-list-map": "^2.0.1", - "source-map": "^0.6.1" - }, - "engines": { - "node": ">=10.13.0" - } - }, - "node_modules/webpack-sources": { - "version": "3.2.3", - "resolved": "https://registry.npmjs.org/webpack-sources/-/webpack-sources-3.2.3.tgz", - "integrity": "sha512-/DyMEOrDgLKKIG0fmvtz+4dUX/3Ghozwgm6iPp8KRhvn+eQf9+Q7GWxVNMk3+uCPWfdXYC4ExGBckIXdFEfH1w==", - "engines": { - "node": ">=10.13.0" - } - }, - "node_modules/webpack/node_modules/eslint-scope": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz", - "integrity": "sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==", - "dependencies": { - "esrecurse": "^4.3.0", - "estraverse": "^4.1.1" - }, - "engines": { - "node": ">=8.0.0" - } - }, - "node_modules/webpack/node_modules/estraverse": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", - "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", - "engines": { - "node": ">=4.0" - } - }, - "node_modules/websocket-driver": { - "version": "0.7.4", - "resolved": "https://registry.npmjs.org/websocket-driver/-/websocket-driver-0.7.4.tgz", - "integrity": "sha512-b17KeDIQVjvb0ssuSDF2cYXSg2iztliJ4B9WdsuB6J952qCPKmnVq4DyW5motImXHDC1cBT/1UezrJVsKw5zjg==", - "dependencies": { - "http-parser-js": ">=0.5.1", - "safe-buffer": ">=5.1.0", - "websocket-extensions": ">=0.1.1" - }, - "engines": { - "node": ">=0.8.0" - } - }, - "node_modules/websocket-extensions": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/websocket-extensions/-/websocket-extensions-0.1.4.tgz", - "integrity": "sha512-OqedPIGOfsDlo31UNwYbCFMSaO9m9G/0faIHj5/dZFDMFqPTcx6UwqyOy3COEaEOg/9VsGIpdqn62W5KhoKSpg==", - "engines": { - "node": ">=0.8.0" - } - }, - "node_modules/whatwg-encoding": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/whatwg-encoding/-/whatwg-encoding-1.0.5.tgz", - "integrity": "sha512-b5lim54JOPN9HtzvK9HFXvBma/rnfFeqsic0hSpjtDbVxR3dJKLc+KB4V6GgiGOvl7CY/KNh8rxSo9DKQrnUEw==", - "dependencies": { - "iconv-lite": "0.4.24" - } - }, - "node_modules/whatwg-encoding/node_modules/iconv-lite": { - "version": "0.4.24", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", - "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", - "dependencies": { - "safer-buffer": ">= 2.1.2 < 3" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/whatwg-fetch": { - "version": "3.6.2", - "resolved": "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-3.6.2.tgz", - "integrity": "sha512-bJlen0FcuU/0EMLrdbJ7zOnW6ITZLrZMIarMUVmdKtsGvZna8vxKYaexICWPfZ8qwf9fzNq+UEIZrnSaApt6RA==" - }, - "node_modules/whatwg-mimetype": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/whatwg-mimetype/-/whatwg-mimetype-2.3.0.tgz", - "integrity": "sha512-M4yMwr6mAnQz76TbJm914+gPpB/nCwvZbJU28cUD6dR004SAxDLOOSUaB1JDRqLtaOV/vi0IC5lEAGFgrjGv/g==" - }, - "node_modules/whatwg-url": { - "version": "8.7.0", - "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-8.7.0.tgz", - "integrity": "sha512-gAojqb/m9Q8a5IV96E3fHJM70AzCkgt4uXYX2O7EmuyOnLrViCQlsEBmF9UQIu3/aeAIp2U17rtbpZWNntQqdg==", - "dependencies": { - "lodash": "^4.7.0", - "tr46": "^2.1.0", - "webidl-conversions": "^6.1.0" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/whatwg-url-compat": { - "version": "0.6.5", - "resolved": "https://registry.npmjs.org/whatwg-url-compat/-/whatwg-url-compat-0.6.5.tgz", - "integrity": "sha512-vbg5+JVNwGtHRI3GheZGWrcUlxF9BXHbA80dLa+2XqJjlV/BK6upoi2j8dIRW9FGPUUyaMm7Hf1pTexHnsk85g==", - "optional": true, - "dependencies": { - "tr46": "~0.0.1" - } - }, - "node_modules/whatwg-url-compat/node_modules/tr46": { - "version": "0.0.3", - "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", - "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==", - "optional": true - }, - "node_modules/which": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", - "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", - "dependencies": { - "isexe": "^2.0.0" - }, - "bin": { - "node-which": "bin/node-which" - }, - "engines": { - "node": ">= 8" - } - }, - "node_modules/which-boxed-primitive": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/which-boxed-primitive/-/which-boxed-primitive-1.0.2.tgz", - "integrity": "sha512-bwZdv0AKLpplFY2KZRX6TvyuN7ojjr7lwkg6ml0roIy9YeuSr7JS372qlNW18UQYzgYK9ziGcerWqZOmEn9VNg==", - "dependencies": { - "is-bigint": "^1.0.1", - "is-boolean-object": "^1.1.0", - "is-number-object": "^1.0.4", - "is-string": "^1.0.5", - "is-symbol": "^1.0.3" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/which-collection": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/which-collection/-/which-collection-1.0.1.tgz", - "integrity": "sha512-W8xeTUwaln8i3K/cY1nGXzdnVZlidBcagyNFtBdD5kxnb4TvGKR7FfSIS3mYpwWS1QUCutfKz8IY8RjftB0+1A==", - "dependencies": { - "is-map": "^2.0.1", - "is-set": "^2.0.1", - "is-weakmap": "^2.0.1", - "is-weakset": "^2.0.1" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/which-module": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.1.tgz", - "integrity": "sha512-iBdZ57RDvnOR9AGBhML2vFZf7h8vmBjhoaZqODJBFWHVtKkDmKuHai3cx5PgVMrX5YDNp27AofYbAwctSS+vhQ==" - }, - "node_modules/which-typed-array": { - "version": "1.1.9", - "resolved": "https://registry.npmjs.org/which-typed-array/-/which-typed-array-1.1.9.tgz", - "integrity": "sha512-w9c4xkx6mPidwp7180ckYWfMmvxpjlZuIudNtDf4N/tTAUB8VJbX25qZoAsrtGuYNnGw3pa0AXgbGKRB8/EceA==", - "dependencies": { - "available-typed-arrays": "^1.0.5", - "call-bind": "^1.0.2", - "for-each": "^0.3.3", - "gopd": "^1.0.1", - "has-tostringtag": "^1.0.0", - "is-typed-array": "^1.1.10" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/wide-align": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.5.tgz", - "integrity": "sha512-eDMORYaPNZ4sQIuuYPDHdQvf4gyCF9rEEV/yPxGfwPkRodwEgiMUUXTx/dex+Me0wxx53S+NgUHaP7y3MGlDmg==", - "dependencies": { - "string-width": "^1.0.2 || 2 || 3 || 4" - } - }, - "node_modules/word-wrap": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", - "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/workbox-background-sync": { - "version": "6.5.4", - "resolved": "https://registry.npmjs.org/workbox-background-sync/-/workbox-background-sync-6.5.4.tgz", - "integrity": "sha512-0r4INQZMyPky/lj4Ou98qxcThrETucOde+7mRGJl13MPJugQNKeZQOdIJe/1AchOP23cTqHcN/YVpD6r8E6I8g==", - "dependencies": { - "idb": "^7.0.1", - "workbox-core": "6.5.4" - } - }, - "node_modules/workbox-broadcast-update": { - "version": "6.5.4", - "resolved": "https://registry.npmjs.org/workbox-broadcast-update/-/workbox-broadcast-update-6.5.4.tgz", - "integrity": "sha512-I/lBERoH1u3zyBosnpPEtcAVe5lwykx9Yg1k6f8/BGEPGaMMgZrwVrqL1uA9QZ1NGGFoyE6t9i7lBjOlDhFEEw==", - "dependencies": { - "workbox-core": "6.5.4" - } - }, - "node_modules/workbox-build": { - "version": "6.5.4", - "resolved": "https://registry.npmjs.org/workbox-build/-/workbox-build-6.5.4.tgz", - "integrity": "sha512-kgRevLXEYvUW9WS4XoziYqZ8Q9j/2ziJYEtTrjdz5/L/cTUa2XfyMP2i7c3p34lgqJ03+mTiz13SdFef2POwbA==", - "dependencies": { - "@apideck/better-ajv-errors": "^0.3.1", - "@babel/core": "^7.11.1", - "@babel/preset-env": "^7.11.0", - "@babel/runtime": "^7.11.2", - "@rollup/plugin-babel": "^5.2.0", - "@rollup/plugin-node-resolve": "^11.2.1", - "@rollup/plugin-replace": "^2.4.1", - "@surma/rollup-plugin-off-main-thread": "^2.2.3", - "ajv": "^8.6.0", - "common-tags": "^1.8.0", - "fast-json-stable-stringify": "^2.1.0", - "fs-extra": "^9.0.1", - "glob": "^7.1.6", - "lodash": "^4.17.20", - "pretty-bytes": "^5.3.0", - "rollup": "^2.43.1", - "rollup-plugin-terser": "^7.0.0", - "source-map": "^0.8.0-beta.0", - "stringify-object": "^3.3.0", - "strip-comments": "^2.0.1", - "tempy": "^0.6.0", - "upath": "^1.2.0", - "workbox-background-sync": "6.5.4", - "workbox-broadcast-update": "6.5.4", - "workbox-cacheable-response": "6.5.4", - "workbox-core": "6.5.4", - "workbox-expiration": "6.5.4", - "workbox-google-analytics": "6.5.4", - "workbox-navigation-preload": "6.5.4", - "workbox-precaching": "6.5.4", - "workbox-range-requests": "6.5.4", - "workbox-recipes": "6.5.4", - "workbox-routing": "6.5.4", - "workbox-strategies": "6.5.4", - "workbox-streams": "6.5.4", - "workbox-sw": "6.5.4", - "workbox-window": "6.5.4" - }, - "engines": { - "node": ">=10.0.0" - } - }, - "node_modules/workbox-build/node_modules/@apideck/better-ajv-errors": { - "version": "0.3.6", - "resolved": "https://registry.npmjs.org/@apideck/better-ajv-errors/-/better-ajv-errors-0.3.6.tgz", - "integrity": "sha512-P+ZygBLZtkp0qqOAJJVX4oX/sFo5JR3eBWwwuqHHhK0GIgQOKWrAfiAaWX0aArHkRWHMuggFEgAZNxVPwPZYaA==", - "dependencies": { - "json-schema": "^0.4.0", - "jsonpointer": "^5.0.0", - "leven": "^3.1.0" - }, - "engines": { - "node": ">=10" - }, - "peerDependencies": { - "ajv": ">=8" - } - }, - "node_modules/workbox-build/node_modules/ajv": { - "version": "8.12.0", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.12.0.tgz", - "integrity": "sha512-sRu1kpcO9yLtYxBKvqfTeh9KzZEwO3STyX1HT+4CaDzC6HpTGYhIhPIzj9XuKU7KYDwnaeh5hcOwjy1QuJzBPA==", - "dependencies": { - "fast-deep-equal": "^3.1.1", - "json-schema-traverse": "^1.0.0", - "require-from-string": "^2.0.2", - "uri-js": "^4.2.2" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/epoberezkin" - } - }, - "node_modules/workbox-build/node_modules/fs-extra": { - "version": "9.1.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-9.1.0.tgz", - "integrity": "sha512-hcg3ZmepS30/7BSFqRvoo3DOMQu7IjqxO5nCDt+zM9XWjb33Wg7ziNT+Qvqbuc3+gWpzO02JubVyk2G4Zvo1OQ==", - "dependencies": { - "at-least-node": "^1.0.0", - "graceful-fs": "^4.2.0", - "jsonfile": "^6.0.1", - "universalify": "^2.0.0" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/workbox-build/node_modules/json-schema-traverse": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", - "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==" - }, - "node_modules/workbox-build/node_modules/source-map": { - "version": "0.8.0-beta.0", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.8.0-beta.0.tgz", - "integrity": "sha512-2ymg6oRBpebeZi9UUNsgQ89bhx01TcTkmNTGnNO88imTmbSgy4nfujrgVEFKWpMTEGA11EDkTt7mqObTPdigIA==", - "dependencies": { - "whatwg-url": "^7.0.0" - }, - "engines": { - "node": ">= 8" - } - }, - "node_modules/workbox-build/node_modules/tr46": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/tr46/-/tr46-1.0.1.tgz", - "integrity": "sha512-dTpowEjclQ7Kgx5SdBkqRzVhERQXov8/l9Ft9dVM9fmg0W0KQSVaXX9T4i6twCPNtYiZM53lpSSUAwJbFPOHxA==", - "dependencies": { - "punycode": "^2.1.0" - } - }, - "node_modules/workbox-build/node_modules/webidl-conversions": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-4.0.2.tgz", - "integrity": "sha512-YQ+BmxuTgd6UXZW3+ICGfyqRyHXVlD5GtQr5+qjiNW7bF0cqrzX500HVXPBOvgXb5YnzDd+h0zqyv61KUD7+Sg==" - }, - "node_modules/workbox-build/node_modules/whatwg-url": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-7.1.0.tgz", - "integrity": "sha512-WUu7Rg1DroM7oQvGWfOiAK21n74Gg+T4elXEQYkOhtyLeWiJFoOGLXPKI/9gzIie9CtwVLm8wtw6YJdKyxSjeg==", - "dependencies": { - "lodash.sortby": "^4.7.0", - "tr46": "^1.0.1", - "webidl-conversions": "^4.0.2" - } - }, - "node_modules/workbox-cacheable-response": { - "version": "6.5.4", - "resolved": "https://registry.npmjs.org/workbox-cacheable-response/-/workbox-cacheable-response-6.5.4.tgz", - "integrity": "sha512-DCR9uD0Fqj8oB2TSWQEm1hbFs/85hXXoayVwFKLVuIuxwJaihBsLsp4y7J9bvZbqtPJ1KlCkmYVGQKrBU4KAug==", - "dependencies": { - "workbox-core": "6.5.4" - } - }, - "node_modules/workbox-core": { - "version": "6.5.4", - "resolved": "https://registry.npmjs.org/workbox-core/-/workbox-core-6.5.4.tgz", - "integrity": "sha512-OXYb+m9wZm8GrORlV2vBbE5EC1FKu71GGp0H4rjmxmF4/HLbMCoTFws87M3dFwgpmg0v00K++PImpNQ6J5NQ6Q==" - }, - "node_modules/workbox-expiration": { - "version": "6.5.4", - "resolved": "https://registry.npmjs.org/workbox-expiration/-/workbox-expiration-6.5.4.tgz", - "integrity": "sha512-jUP5qPOpH1nXtjGGh1fRBa1wJL2QlIb5mGpct3NzepjGG2uFFBn4iiEBiI9GUmfAFR2ApuRhDydjcRmYXddiEQ==", - "dependencies": { - "idb": "^7.0.1", - "workbox-core": "6.5.4" - } - }, - "node_modules/workbox-google-analytics": { - "version": "6.5.4", - "resolved": "https://registry.npmjs.org/workbox-google-analytics/-/workbox-google-analytics-6.5.4.tgz", - "integrity": "sha512-8AU1WuaXsD49249Wq0B2zn4a/vvFfHkpcFfqAFHNHwln3jK9QUYmzdkKXGIZl9wyKNP+RRX30vcgcyWMcZ9VAg==", - "dependencies": { - "workbox-background-sync": "6.5.4", - "workbox-core": "6.5.4", - "workbox-routing": "6.5.4", - "workbox-strategies": "6.5.4" - } - }, - "node_modules/workbox-navigation-preload": { - "version": "6.5.4", - "resolved": "https://registry.npmjs.org/workbox-navigation-preload/-/workbox-navigation-preload-6.5.4.tgz", - "integrity": "sha512-IIwf80eO3cr8h6XSQJF+Hxj26rg2RPFVUmJLUlM0+A2GzB4HFbQyKkrgD5y2d84g2IbJzP4B4j5dPBRzamHrng==", - "dependencies": { - "workbox-core": "6.5.4" - } - }, - "node_modules/workbox-precaching": { - "version": "6.5.4", - "resolved": "https://registry.npmjs.org/workbox-precaching/-/workbox-precaching-6.5.4.tgz", - "integrity": "sha512-hSMezMsW6btKnxHB4bFy2Qfwey/8SYdGWvVIKFaUm8vJ4E53JAY+U2JwLTRD8wbLWoP6OVUdFlXsTdKu9yoLTg==", - "dependencies": { - "workbox-core": "6.5.4", - "workbox-routing": "6.5.4", - "workbox-strategies": "6.5.4" - } - }, - "node_modules/workbox-range-requests": { - "version": "6.5.4", - "resolved": "https://registry.npmjs.org/workbox-range-requests/-/workbox-range-requests-6.5.4.tgz", - "integrity": "sha512-Je2qR1NXCFC8xVJ/Lux6saH6IrQGhMpDrPXWZWWS8n/RD+WZfKa6dSZwU+/QksfEadJEr/NfY+aP/CXFFK5JFg==", - "dependencies": { - "workbox-core": "6.5.4" - } - }, - "node_modules/workbox-recipes": { - "version": "6.5.4", - "resolved": "https://registry.npmjs.org/workbox-recipes/-/workbox-recipes-6.5.4.tgz", - "integrity": "sha512-QZNO8Ez708NNwzLNEXTG4QYSKQ1ochzEtRLGaq+mr2PyoEIC1xFW7MrWxrONUxBFOByksds9Z4//lKAX8tHyUA==", - "dependencies": { - "workbox-cacheable-response": "6.5.4", - "workbox-core": "6.5.4", - "workbox-expiration": "6.5.4", - "workbox-precaching": "6.5.4", - "workbox-routing": "6.5.4", - "workbox-strategies": "6.5.4" - } - }, - "node_modules/workbox-routing": { - "version": "6.5.4", - "resolved": "https://registry.npmjs.org/workbox-routing/-/workbox-routing-6.5.4.tgz", - "integrity": "sha512-apQswLsbrrOsBUWtr9Lf80F+P1sHnQdYodRo32SjiByYi36IDyL2r7BH1lJtFX8fwNHDa1QOVY74WKLLS6o5Pg==", - "dependencies": { - "workbox-core": "6.5.4" - } - }, - "node_modules/workbox-strategies": { - "version": "6.5.4", - "resolved": "https://registry.npmjs.org/workbox-strategies/-/workbox-strategies-6.5.4.tgz", - "integrity": "sha512-DEtsxhx0LIYWkJBTQolRxG4EI0setTJkqR4m7r4YpBdxtWJH1Mbg01Cj8ZjNOO8etqfA3IZaOPHUxCs8cBsKLw==", - "dependencies": { - "workbox-core": "6.5.4" - } - }, - "node_modules/workbox-streams": { - "version": "6.5.4", - "resolved": "https://registry.npmjs.org/workbox-streams/-/workbox-streams-6.5.4.tgz", - "integrity": "sha512-FXKVh87d2RFXkliAIheBojBELIPnWbQdyDvsH3t74Cwhg0fDheL1T8BqSM86hZvC0ZESLsznSYWw+Va+KVbUzg==", - "dependencies": { - "workbox-core": "6.5.4", - "workbox-routing": "6.5.4" - } - }, - "node_modules/workbox-sw": { - "version": "6.5.4", - "resolved": "https://registry.npmjs.org/workbox-sw/-/workbox-sw-6.5.4.tgz", - "integrity": "sha512-vo2RQo7DILVRoH5LjGqw3nphavEjK4Qk+FenXeUsknKn14eCNedHOXWbmnvP4ipKhlE35pvJ4yl4YYf6YsJArA==" - }, - "node_modules/workbox-webpack-plugin": { - "version": "6.5.4", - "resolved": "https://registry.npmjs.org/workbox-webpack-plugin/-/workbox-webpack-plugin-6.5.4.tgz", - "integrity": "sha512-LmWm/zoaahe0EGmMTrSLUi+BjyR3cdGEfU3fS6PN1zKFYbqAKuQ+Oy/27e4VSXsyIwAw8+QDfk1XHNGtZu9nQg==", - "dependencies": { - "fast-json-stable-stringify": "^2.1.0", - "pretty-bytes": "^5.4.1", - "upath": "^1.2.0", - "webpack-sources": "^1.4.3", - "workbox-build": "6.5.4" - }, - "engines": { - "node": ">=10.0.0" - }, - "peerDependencies": { - "webpack": "^4.4.0 || ^5.9.0" - } - }, - "node_modules/workbox-webpack-plugin/node_modules/source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/workbox-webpack-plugin/node_modules/webpack-sources": { - "version": "1.4.3", - "resolved": "https://registry.npmjs.org/webpack-sources/-/webpack-sources-1.4.3.tgz", - "integrity": "sha512-lgTS3Xhv1lCOKo7SA5TjKXMjpSM4sBjNV5+q2bqesbSPs5FjGmU6jjtBSkX9b4qW87vDIsCIlUPOEhbZrMdjeQ==", - "dependencies": { - "source-list-map": "^2.0.0", - "source-map": "~0.6.1" - } - }, - "node_modules/workbox-window": { - "version": "6.5.4", - "resolved": "https://registry.npmjs.org/workbox-window/-/workbox-window-6.5.4.tgz", - "integrity": "sha512-HnLZJDwYBE+hpG25AQBO8RUWBJRaCsI9ksQJEp3aCOFCaG5kqaToAYXFRAHxzRluM2cQbGzdQF5rjKPWPA1fug==", - "dependencies": { - "@types/trusted-types": "^2.0.2", - "workbox-core": "6.5.4" - } - }, - "node_modules/wrap-ansi": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", - "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", - "dependencies": { - "ansi-styles": "^4.0.0", - "string-width": "^4.1.0", - "strip-ansi": "^6.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/wrap-ansi?sponsor=1" - } - }, - "node_modules/wrap-ansi/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/wrap-ansi/node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/wrap-ansi/node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" - }, - "node_modules/wrappy": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==" - }, - "node_modules/write-file-atomic": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-3.0.3.tgz", - "integrity": "sha512-AvHcyZ5JnSfq3ioSyjrBkH9yW4m7Ayk8/9My/DD9onKeu/94fwrMocemO2QAJFAlnnDN+ZDS+ZjAR5ua1/PV/Q==", - "dependencies": { - "imurmurhash": "^0.1.4", - "is-typedarray": "^1.0.0", - "signal-exit": "^3.0.2", - "typedarray-to-buffer": "^3.1.5" - } - }, - "node_modules/ws": { - "version": "7.5.9", - "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.9.tgz", - "integrity": "sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q==", - "engines": { - "node": ">=8.3.0" - }, - "peerDependencies": { - "bufferutil": "^4.0.1", - "utf-8-validate": "^5.0.2" - }, - "peerDependenciesMeta": { - "bufferutil": { - "optional": true - }, - "utf-8-validate": { - "optional": true - } - } - }, - "node_modules/xml-name-validator": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-3.0.0.tgz", - "integrity": "sha512-A5CUptxDsvxKJEU3yO6DuWBSJz/qizqzJKOMIfUJHETbBw/sFaDxgd6fxm1ewUaM0jZ444Fc5vC5ROYurg/4Pw==" - }, - "node_modules/xmlchars": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/xmlchars/-/xmlchars-2.2.0.tgz", - "integrity": "sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw==" - }, - "node_modules/xmlhttprequest-ssl": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/xmlhttprequest-ssl/-/xmlhttprequest-ssl-2.0.0.tgz", - "integrity": "sha512-QKxVRxiRACQcVuQEYFsI1hhkrMlrXHPegbbd1yn9UHOmRxY+si12nQYzri3vbzt8VdTTRviqcKxcyllFas5z2A==", - "engines": { - "node": ">=0.4.0" - } - }, - "node_modules/xtend": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", - "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==", - "engines": { - "node": ">=0.4" - } - }, - "node_modules/y18n": { - "version": "5.0.8", - "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", - "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", - "engines": { - "node": ">=10" - } - }, - "node_modules/yallist": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", - "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==" - }, - "node_modules/yaml": { - "version": "1.10.2", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-1.10.2.tgz", - "integrity": "sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==", - "engines": { - "node": ">= 6" - } - }, - "node_modules/yargs": { - "version": "16.2.0", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", - "integrity": "sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==", - "dependencies": { - "cliui": "^7.0.2", - "escalade": "^3.1.1", - "get-caller-file": "^2.0.5", - "require-directory": "^2.1.1", - "string-width": "^4.2.0", - "y18n": "^5.0.5", - "yargs-parser": "^20.2.2" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/yargs-parser": { - "version": "20.2.9", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.9.tgz", - "integrity": "sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w==", - "engines": { - "node": ">=10" - } - }, - "node_modules/yocto-queue": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", - "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - } - } -} diff --git a/package.json b/package.json index c3d365d3c..ba9885641 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,7 @@ "name": "hidiag", "version": "0.1.0", "private": true, + "type": "module", "dependencies": { "@emotion/react": "^11.11.0", "@google/generative-ai": "^0.1.3", @@ -18,20 +19,16 @@ "@mantine/spotlight": "^6.0.11", "@mantine/tiptap": "^6.0.11", "@tabler/icons-react": "^2.20.0", - "@tensorflow/tfjs": "^4.13.0", - "@tensorflow/tfjs-node": "^1.7.4", "@testing-library/jest-dom": "^5.16.5", "@testing-library/react": "^13.4.0", "@testing-library/user-event": "^13.5.0", "@tiptap/extension-link": "^2.0.3", "@tiptap/react": "^2.0.3", "@tiptap/starter-kit": "^2.0.3", + "@vitejs/plugin-react": "^4.2.1", "axios": "^1.4.0", - "brainjs": "^0.7.4", "dayjs": "^1.11.7", "embla-carousel-react": "^7.1.0", - "esdoc": "^1.1.0", - "esdoc-standard-plugin": "^1.0.0", "express": "^4.18.2", "https": "^1.0.0", "https-browserify": "^1.0.0", @@ -43,7 +40,6 @@ "react": "^18.2.0", "react-dom": "^18.2.0", "react-router-dom": "^6.11.2", - "react-scripts": "^5.0.1", "rfc4648": "^1.5.3", "socket.io": "^4.7.3", "socket.io-client": "^4.7.3", @@ -54,15 +50,15 @@ "url": "^0.11.0", "use-effect-x": "^0.1.5", "util": "^0.12.5", + "vite": "^5.0.11", + "vite-tsconfig-paths": "^4.3.1", "web-vitals": "^2.1.4", "webpack": "^5.89.0" }, "scripts": { - "start": "react-scripts start", - "build": "react-scripts build", - "test": "react-scripts test", - "eject": "react-scripts eject", - "dev": "export NODE_TLS_REJECT_UNAUTHORIZED=0" + "start": "vite", + "build": "tsc && vite build", + "preview": "vite preview" }, "eslintConfig": { "extends": [ diff --git a/src/App.js b/src/App.jsx similarity index 100% rename from src/App.js rename to src/App.jsx diff --git a/src/components/AuthService.jsx b/src/components/AuthService.jsx index cb6977014..7c35f385e 100644 --- a/src/components/AuthService.jsx +++ b/src/components/AuthService.jsx @@ -124,28 +124,31 @@ function AuthService() { let hostname = form.values.Host; let tenant = form.values.Tenant; let access_token = form.values.access_token; - axios.post('https://api.bz9.net/userinfo', - { - access_token:access_token, - hostname: hostname, - tenant: tenant - },{ - headers:{ - 'Content-Type': 'application/x-www-form-urlencoded' - } - - - }).then(function(response){ - notifications.show({ - id: 'load-data', - color: 'teal', - title: 'Connected!', - message: "Successfully recieved User Info", - icon: , - autoClose: 2000 - }); - document.getElementById('resBody').innerHTML = JSON.stringify(response.data); - }) + if(hostname!=null && tenant!=null && access_token!=null){ + axios.post('https://api.bz9.net/userinfo', + { + access_token:access_token, + hostname: hostname, + tenant: tenant + },{ + headers:{ + 'Content-Type': 'application/x-www-form-urlencoded' + } + + + }).then(function(response){ + notifications.show({ + id: 'load-data', + color: 'teal', + title: 'Connected!', + message: "Successfully recieved User Info", + icon: , + autoClose: 2000 + }); + document.getElementById('resBody').innerHTML = JSON.stringify(response.data); + }) + } + }}> Get User Info @@ -197,7 +200,6 @@ function AuthService() { let password = form.values.password; let client_id = form.values.client_id; let client_secret = form.values.client_secret; - sessionStorage.setItem("hostname", hostname); sessionStorage.setItem("tenant", tenant); sessionStorage.setItem("grant_type", grant_type); diff --git a/src/components/provisiondevice.jsx b/src/components/provisiondevice.jsx index 324c943da..7d0b32925 100644 --- a/src/components/provisiondevice.jsx +++ b/src/components/provisiondevice.jsx @@ -1,5 +1,5 @@ -import { Text, TextInput, Button, JsonInput, Card, Grid, Center } from '@mantine/core'; +import {TextInput, Button, JsonInput, Card, Grid, Center } from '@mantine/core'; import axios from 'axios'; import { notifications } from '@mantine/notifications'; import { IconFaceIdError, IconFaceId, IconAlertCircle } from '@tabler/icons-react'; diff --git a/src/index.js b/src/index.jsx similarity index 93% rename from src/index.js rename to src/index.jsx index 2d3afffdc..df18f1579 100644 --- a/src/index.js +++ b/src/index.jsx @@ -1,10 +1,10 @@ import React from "react"; -import App from "./App"; +import App from "./App.jsx"; import AuthService from "./components/AuthService.jsx"; import RegisterUser from "./components/RegisterUser.jsx"; import * as ReactDOM from "react-dom/client"; -import ViewUsers from "./components/ViewUsers"; -import CreatePasswordAuth from "./components/CreatePasswordAuth"; +import ViewUsers from "./components/ViewUsers.jsx"; +import CreatePasswordAuth from "./components/CreatePasswordAuth.jsx"; import PasswordAuth from "./components/passwordauth.jsx"; import CreateOTPAuth from "./components/CreateOTPAuth.jsx"; import OTPAuth from "./components/otpAuth.jsx"; @@ -20,7 +20,6 @@ import ProvisionDevice from "./components/provisiondevice.jsx"; import ApproveOTPAuth from "./components/approveotp.jsx"; import ApprovePushAuth from "./components/approveciba.jsx"; import Dashboard from "./components/dashboad.jsx"; - import UpdateCiba from "./components/updateciba.jsx"; const router = createBrowserRouter([ { @@ -100,7 +99,7 @@ import UpdateCiba from "./components/updateciba.jsx"; ]); ReactDOM.createRoot(document.getElementById("root")).render( - + - + ); \ No newline at end of file diff --git a/tfjs-master/.bazelignore b/tfjs-master/.bazelignore deleted file mode 100644 index b0c1b5eb6..000000000 --- a/tfjs-master/.bazelignore +++ /dev/null @@ -1,20 +0,0 @@ -node_modules -tfjs/node_modules -tfjs-automl/node_modules -tfjs-backend-cpu/node_modules -tfjs-backend-nodegl/node_modules -tfjs-backend-wasm/node_modules -tfjs-backend-webgl/node_modules -tfjs-backend-webgpu/node_modules -tfjs-converter/node_modules -tfjs-core/node_modules -tfjs-data/node_modules -tfjs-inference/node_modules -tfjs-layers/node_modules -tfjs-node/node_modules -tfjs-node-gpu/node_modules -tfjs-react-native/node_modules -tfjs-tfdf/node_modules -tfjs-tflite/node_modules -tfjs-vis/node_modules -e2e/node_modules diff --git a/tfjs-master/.bazelrc b/tfjs-master/.bazelrc deleted file mode 100644 index 8da25af63..000000000 --- a/tfjs-master/.bazelrc +++ /dev/null @@ -1,98 +0,0 @@ -# Bazel will create symlinks from the workspace directory to output artifacts. -# Build results will be placed in a directory called "dist/bin" -# Other directories will be created like "dist/testlogs" -# Be aware that this will still create a bazel-out symlink in -# your project directory, which you must exclude from version control and your -# editor's search path. -build --symlink_prefix=dist/ - -# These compile flags are active no matter which build mode we are in -# (dbg vs opt). For flags specific to build mode, see cc_toolchain_config.bzl. -build --cxxopt="-std=c++17" -build --cxxopt="-fno-rtti" -build --cxxopt="-fno-exceptions" -build --cxxopt="-fomit-frame-pointer" - -# The following --define=EXECUTOR=remote will be able to be removed -# once https://github.com/bazelbuild/bazel/issues/7254 is fixed -build:rbe --define=EXECUTOR=remote - -build:rbe --jobs=100 - -# Remote cache config. Users can add credentials in their .bazelrc.user files. -build:remote --remote_cache=remotebuildexecution.googleapis.com -build:rbe --remote_executor=remotebuildexecution.googleapis.com - -# Force remote exeuctions to consider the entire run as linux -build:rbe --cpu=k8 -build:rbe --host_cpu=k8 - -# Toolchain and platform related flags -build:rbe --crosstool_top=@//remote-execution/cpp:cc_toolchain_suite -build:rbe --extra_toolchains=@//remote-execution/cpp:cc_toolchain -build:rbe --extra_execution_platforms=@//remote-execution:platform -build:rbe --host_platform=@//remote-execution:platform -build:rbe --platforms=@//remote-execution:platform - -build:remote --remote_instance_name=projects/learnjs-174218/instances/default_instance -build:remote --bes_instance_name=learnjs-174218 -build:remote --google_default_credentials -build:remote --remote_timeout=180s - -# Stream build results to the results UI -build:bes --config=remote --bes_backend="buildeventservice.googleapis.com" --bes_timeout=60s --bes_results_url="https://source.cloud.google.com/results/invocations/" -build:rbe --config=remote - -# Config for Google Cloud continuous integration that uses default credentials. -build:ci --config=bes - -# This flag is needed to prevent the bazel cache from being invalidated when -# running bazel via `yarn bazel`. -# See https://github.com/angular/angular/issues/27514. -build --incompatible_strict_action_env -run --incompatible_strict_action_env -test --incompatible_strict_action_env - -# Use a sandboxed build where available to avoid a possible issue with the rules_nodejs linker for Linux and MacOS. b/250727292 -# Remote builds are sandboxed. -# TODO: Regain Windows sandboxed build when https://github.com/bazelbuild/bazel/issues/5136 fixed. -common --enable_platform_specific_config -build:linux --spawn_strategy=dynamic,remote,sandboxed,worker,local --internal_spawn_scheduler -build:macos --spawn_strategy=remote,sandboxed,worker,local -build:windows --spawn_strategy=remote,worker,local - -# Use dynamic execution to improve remote build performance when the autoscaling -# build pool has few machines available. https://bazel.build/remote/dynamic -build:rbe --dynamic_local_strategy=sandboxed - -# Pass BrowserStack credentials -build --action_env=BROWSERSTACK_USERNAME --action_env=BROWSERSTACK_KEY -run --action_env=BROWSERSTACK_USERNAME --action_env=BROWSERSTACK_KEY -test --action_env=BROWSERSTACK_USERNAME --action_env=BROWSERSTACK_KEY - -# Make python debugging refer to the real files instead of symlinks -build --action_env=PYDEVD_RESOLVE_SYMLINKS=true -run --action_env=PYDEVD_RESOLVE_SYMLINKS=true -test --action_env=PYDEVD_RESOLVE_SYMLINKS=true - -# Platform specific DISPLAY environment variable for webgl and headless setting -# for browser tests. -test:linux --test_env=DISPLAY --test_env=XAUTHORITY=/run/user/1001/.mutter-Xwaylandauth.ONEU31 -test:macos --define DISPLAY=true -test:windows --define DISPLAY=true --//:headless=false - -# Enable debugging tests with --config=debug -run:debug --test_arg=--node_options=--inspect-brk --test_output=streamed --test_strategy=exclusive --test_timeout=36000 --nocache_test_results -test:debug --test_arg=--node_options=--inspect-brk --test_output=streamed --test_strategy=exclusive --test_timeout=36000 --nocache_test_results - -test:debugpy --test_output=streamed --test_strategy=exclusive --test_timeout=999999 --nocache_test_results -run:debugpy --test_output=streamed --test_strategy=exclusive --test_timeout=999999 --nocache_test_results - -# Load any settings specific to the current user. -# .bazelrc.user should appear in .gitignore so that settings are not shared with -# team members. This needs to be last statement in this config, as the user -# configuration should be able to overwrite flags from this file. -# See https://docs.bazel.build/versions/master/best-practices.html#bazelrc -# (Note that we use .bazelrc.user so the file appears next to .bazelrc in -# directory listing, rather than user.bazelrc as suggested in the Bazel docs). -try-import %workspace%/.bazelrc.user diff --git a/tfjs-master/.bazelversion b/tfjs-master/.bazelversion deleted file mode 100644 index e230c8396..000000000 --- a/tfjs-master/.bazelversion +++ /dev/null @@ -1 +0,0 @@ -5.3.0 \ No newline at end of file diff --git a/tfjs-master/.github/ISSUE_TEMPLATE/00-bug-issue.md b/tfjs-master/.github/ISSUE_TEMPLATE/00-bug-issue.md deleted file mode 100644 index 1d1e2c3ef..000000000 --- a/tfjs-master/.github/ISSUE_TEMPLATE/00-bug-issue.md +++ /dev/null @@ -1,34 +0,0 @@ ---- -name: Bug Issue -about: Use this template for reporting a bug -labels: 'type:bug' - ---- - -Please make sure that this is a bug. As per our -[GitHub Policy](https://github.com/tensorflow/tensorflow/blob/master/ISSUES.md), -we only address code/doc bugs, performance issues, feature requests and -build/installation issues on GitHub. tag:bug_template - -**System information** -- Have I written custom code (as opposed to using a stock example script provided in TensorFlow.js): -- OS Platform and Distribution (e.g., Linux Ubuntu 16.04): -- Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if the issue happens on mobile device: -- TensorFlow.js installed from (npm or script link): -- TensorFlow.js version (use command below): -- Browser version: -- Tensorflow.js Converter Version: - - - -**Describe the current behavior** - -**Describe the expected behavior** - -**Standalone code to reproduce the issue** -Provide a reproducible test case that is the bare minimum necessary to generate -the problem. If possible, please share a link to Colab/CodePen/any notebook. - -**Other info / logs** Include any logs or source code that would be helpful to -diagnose the problem. If including tracebacks, please include the full -traceback. Large logs and files should be attached. diff --git a/tfjs-master/.github/ISSUE_TEMPLATE/10-build-installation-issue.md b/tfjs-master/.github/ISSUE_TEMPLATE/10-build-installation-issue.md deleted file mode 100644 index e3bc77604..000000000 --- a/tfjs-master/.github/ISSUE_TEMPLATE/10-build-installation-issue.md +++ /dev/null @@ -1,24 +0,0 @@ ---- -name: Build/Installation Issue -about: Use this template for build/installation issues -labels: 'type:build/install' - ---- - -Please make sure that this is a build/installation issue. As per our [GitHub Policy](https://github.com/tensorflow/tensorflow/blob/master/ISSUES.md), we only address code/doc bugs, performance issues, feature requests and build/installation issues on GitHub. tag:build_template - -**System information** -- OS Platform and Distribution (e.g., Linux Ubuntu 16.04): -- Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if the issue happens on mobile device: -- TensorFlow.js installed from (npm or script link): -- TensorFlow.js version: -- CUDA/cuDNN version: - - -**Describe the problem** - -**Provide the exact sequence of commands / steps that you executed before running into the problem** - - -**Any other info / logs** -Include any logs or source code that would be helpful to diagnose the problem. If including tracebacks, please include the full traceback. Large logs and files should be attached. diff --git a/tfjs-master/.github/ISSUE_TEMPLATE/20-feature-request.md b/tfjs-master/.github/ISSUE_TEMPLATE/20-feature-request.md deleted file mode 100644 index a77610ee9..000000000 --- a/tfjs-master/.github/ISSUE_TEMPLATE/20-feature-request.md +++ /dev/null @@ -1,23 +0,0 @@ ---- -name: Feature Request -about: Use this template for raising a feature request -labels: 'type:feature' - ---- - -Please make sure that this is a feature request. As per our [GitHub Policy](https://github.com/tensorflow/tensorflow/blob/master/ISSUES.md), we only address code/doc bugs, performance issues, feature requests and build/installation issues on GitHub. tag:feature_template - - -**System information** -- TensorFlow.js version (you are using): -- Are you willing to contribute it (Yes/No): - - - -**Describe the feature and the current behavior/state.** - -**Will this change the current api? How?** - -**Who will benefit with this feature?** - -**Any Other info.** diff --git a/tfjs-master/.github/ISSUE_TEMPLATE/30-other-issues.md b/tfjs-master/.github/ISSUE_TEMPLATE/30-other-issues.md deleted file mode 100644 index b517d953e..000000000 --- a/tfjs-master/.github/ISSUE_TEMPLATE/30-other-issues.md +++ /dev/null @@ -1,10 +0,0 @@ ---- -name: Other Issues -about: Use this template for any other non-support related issues -labels: 'type:others' - ---- - -This template is for miscellaneous issues not covered by the other issue categories. - -For questions on how to work with TensorFlow.js, or support for problems that are not verified bugs in TensorFlow.js, please go to [StackOverflow](https://stackoverflow.com/tags/tensorflow.js). diff --git a/tfjs-master/.github/workflows/deploy-benchmark-preview.yml b/tfjs-master/.github/workflows/deploy-benchmark-preview.yml deleted file mode 100644 index 8ebd70fba..000000000 --- a/tfjs-master/.github/workflows/deploy-benchmark-preview.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: Deploy Benchmark Site to Preview Channel - -on: - pull_request: - paths: - - "e2e/benchmarks/**" - -permissions: - contents: read - -jobs: - build_and_preview: - permissions: - pull-requests: write # for FirebaseExtended/action-hosting-deploy to comment on PRs - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: FirebaseExtended/action-hosting-deploy@v0 - with: - repoToken: "${{ secrets.GITHUB_TOKEN }}" - firebaseServiceAccount: "${{ secrets.FIREBASE_SERVICE_ACCOUNT_JSTENSORFLOW }}" - expires: 30d - projectId: jstensorflow - target: tfjs-benchmarks - entryPoint: e2e/benchmarks/ diff --git a/tfjs-master/.github/workflows/deploy-benchmark-prod.yml b/tfjs-master/.github/workflows/deploy-benchmark-prod.yml deleted file mode 100644 index e9bf26627..000000000 --- a/tfjs-master/.github/workflows/deploy-benchmark-prod.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: Deploy Benchmark Site to Live - -on: - push: - branches: - - master - paths: - - "e2e/benchmarks/**" - -permissions: - contents: read - -jobs: - deploy_live_website: - permissions: - pull-requests: write # for FirebaseExtended/action-hosting-deploy to comment on PRs - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: FirebaseExtended/action-hosting-deploy@v0 - with: - repoToken: "${{ secrets.GITHUB_TOKEN }}" - firebaseServiceAccount: "${{ secrets.FIREBASE_SERVICE_ACCOUNT_JSTENSORFLOW }}" - projectId: jstensorflow - target: tfjs-benchmarks - channelId: live - entryPoint: e2e/benchmarks/ diff --git a/tfjs-master/.github/workflows/stale.yaml b/tfjs-master/.github/workflows/stale.yaml deleted file mode 100644 index c79824a42..000000000 --- a/tfjs-master/.github/workflows/stale.yaml +++ /dev/null @@ -1,66 +0,0 @@ -# Copyright 2023 The TensorFlow Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================== - -# This workflow alerts and then closes the stale issues/PRs after specific time -# You can adjust the behavior by modifying this file. -# For more information, see: -# https://github.com/actions/stale - -name: 'Close stale issues and PRs' -"on": - schedule: - - cron: "30 1 * * *" -permissions: - contents: read - issues: write - pull-requests: write -jobs: - stale: - runs-on: ubuntu-latest - steps: - - uses: 'actions/stale@v7' - with: - # Comma separated list of labels that can be assigned to issues to exclude them from being marked as stale. - exempt-issue-labels: 'override-stale' - # Comma separated list of labels that can be assigned to PRs to exclude them from being marked as stale. - exempt-pr-labels: "override-stale" - # Limit the No. of API calls in one run default value is 30. - operations-per-run: 500 - # Prevent to remove stale label when PRs or issues are updated. - remove-stale-when-updated: false - # comment on issue if not active for more then 7 days. - stale-issue-message: 'This issue has been marked stale because it has no recent activity since 7 days. It will be closed if no further activity occurs. Thank you.' - # comment on PR if not active for more then 14 days. - stale-pr-message: 'This PR has been marked stale because it has no recent activity since 14 days. It will be closed if no further activity occurs. Thank you.' - # comment on issue if stale for more then 7 days. - close-issue-message: This issue was closed due to lack of activity after being marked stale for past 7 days. - # comment on PR if stale for more then 14 days. - close-pr-message: This PR was closed due to lack of activity after being marked stale for past 14 days. - # Number of days of inactivity before an Issue Request becomes stale - days-before-issue-stale: 7 - # Number of days of inactivity before a stale Issue is closed - days-before-issue-close: 7 - # reason for closed the issue default value is not_planned - close-issue-reason: completed - # Number of days of inactivity before a stale PR is closed - days-before-pr-close: 14 - # Number of days of inactivity before an PR Request becomes stale - days-before-pr-stale: 14 - # Check for label to stale or close the issue/PR - any-of-labels: 'stat:awaiting response' - # override stale to stalled for PR - stale-pr-label: 'stale' - # override stale to stalled for Issue - stale-issue-label: "stale" \ No newline at end of file diff --git a/tfjs-master/.gitignore b/tfjs-master/.gitignore deleted file mode 100644 index b3a2ac1c2..000000000 --- a/tfjs-master/.gitignore +++ /dev/null @@ -1,78 +0,0 @@ -*.log -*.tar.gz -*.tgz -*.zip -*/diff -*/run-ci -**/*.pyc -**/bundle.js -**/.parcel-cache -**/*.js.map -.DS_Store -.idea/ -.nyc_output/ -.rpt2_cache/ -.cache/ -.yalc/ -.vscode/ipch/ -/compiled_api.js -bazel-out/ -bazel-* -build-tmp-napi-v*/ -build/ -clone/ -coverage/ -demo/train-* -deps/ -dist/ -tfjs-layers/integration_tests/tfjs2keras/test-data/ -tfjs-layers/integration/typescript/yarn.lock -e2e/integration_tests/create_save_predict_data -e2e/integration_tests/convert_predict_data -e2e/integration_tests/metadata -e2e/integration_tests/graph_model_golden_data/*.golden.json -e2e/scripts/storage -e2e/scripts/htpasswd -e2e/benchmarks/browserstack-benchmark/browsers.json -e2e/benchmarks/browserstack-benchmark/benchmark_parameters.json -e2e/benchmarks/browserstack-benchmark/benchmark_results.json -e2e/benchmarks/browserstack-benchmark/benchmark_results.js -e2e/benchmarks/browserstack-benchmark/benchmark_test_results.json -tfjs-converter/python/tensorflowjs.egg-info -tfjs-inference/binaries - -# Ignore the src, binding, scripts of tfjs-node-gpu since it is copied over when -# building. -/tfjs-node-gpu/src -/tfjs-node-gpu/binding -/tfjs-node-gpu/scripts -/tfjs-node-gpu/binding.gyp - -# This gets autogenerated during publishing of the union package. -tfjs/README.md - -lib/ -local.log -node_modules/ -npm-debug.log -package -package-lock.json -release-notes.md -tensorflow-tfjs-*.tgz -tfjs-backend-wasm/dist -tfjs-backend-wasm/wasm-out/*.js -tfjs-backend-wasm/wasm-out/*.wasm -yalc.lock -yarn-error.log -cloudbuild_generated.yml -wasm-dist/ -.firebase/ - -# e2e custom modules -e2e/custom_module/blazeface/custom_tfjs_blazeface -e2e/custom_module/dense_model/custom_tfjs -e2e/custom_module/universal_sentence_encoder/custom_tfjs - -# User-specific .bazelrc -.bazelrc.user -**/.parcel-cache diff --git a/tfjs-master/.tslint/noImportsFromDistRule.js b/tfjs-master/.tslint/noImportsFromDistRule.js deleted file mode 100644 index 11c537583..000000000 --- a/tfjs-master/.tslint/noImportsFromDistRule.js +++ /dev/null @@ -1,44 +0,0 @@ -"use strict"; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -exports.__esModule = true; -var Lint = require("tslint"); -var Rule = /** @class */ (function (_super) { - __extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.apply = function (sourceFile) { - return this.applyWithWalker(new NoImportsFromDistWalker(sourceFile, this.getOptions())); - }; - Rule.FAILURE_STRING = "importing from dist/ is prohibited. Please use public API"; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -var NoImportsFromDistWalker = /** @class */ (function (_super) { - __extends(NoImportsFromDistWalker, _super); - function NoImportsFromDistWalker() { - return _super !== null && _super.apply(this, arguments) || this; - } - NoImportsFromDistWalker.prototype.visitImportDeclaration = function (node) { - var importFrom = node.moduleSpecifier.getText(); - var reg = /@tensorflow\/tfjs[-a-z]*\/dist/; - if (importFrom.match(reg)) { - var fix = new Lint.Replacement(node.moduleSpecifier.getStart(), node.moduleSpecifier.getWidth(), importFrom.replace(/\/dist[\/]*/, '')); - this.addFailure(this.createFailure(node.moduleSpecifier.getStart(), node.moduleSpecifier.getWidth(), Rule.FAILURE_STRING, fix)); - } - _super.prototype.visitImportDeclaration.call(this, node); - }; - return NoImportsFromDistWalker; -}(Lint.RuleWalker)); diff --git a/tfjs-master/.tslint/noImportsFromDistRule.ts b/tfjs-master/.tslint/noImportsFromDistRule.ts deleted file mode 100644 index 26317e5db..000000000 --- a/tfjs-master/.tslint/noImportsFromDistRule.ts +++ /dev/null @@ -1,30 +0,0 @@ -import * as Lint from "tslint"; -import * as ts from "typescript"; - -export class Rule extends Lint.Rules.AbstractRule { - public static FAILURE_STRING = "importing from dist/ is prohibited. Please use public API"; - - public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] { - return this.applyWithWalker( - new NoImportsFromDistWalker(sourceFile, this.getOptions())); - } -} - -class NoImportsFromDistWalker extends Lint.RuleWalker { - public visitImportDeclaration(node: ts.ImportDeclaration) { - const importFrom = node.moduleSpecifier.getText(); - const reg = /@tensorflow\/tfjs[-a-z]*\/dist/; - if (importFrom.match(reg)) { - const fix = new Lint.Replacement(node.moduleSpecifier.getStart(), - node.moduleSpecifier.getWidth(), - importFrom.replace(/\/dist[\/]*/, '')); - - this.addFailure(this.createFailure(node.moduleSpecifier.getStart(), - node.moduleSpecifier.getWidth(), - Rule.FAILURE_STRING, fix)); - } - - super.visitImportDeclaration(node); - } - -} diff --git a/tfjs-master/.tslint/noImportsWithRegexRule.js b/tfjs-master/.tslint/noImportsWithRegexRule.js deleted file mode 100644 index afd3734c5..000000000 --- a/tfjs-master/.tslint/noImportsWithRegexRule.js +++ /dev/null @@ -1,46 +0,0 @@ -"use strict"; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -exports.__esModule = true; -var Lint = require("tslint"); -var Rule = /** @class */ (function (_super) { - __extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.apply = function (sourceFile) { - return this.applyWithWalker(new NoImportsWithRegexWalker(sourceFile, this.getOptions())); - }; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -var NoImportsWithRegexWalker = /** @class */ (function (_super) { - __extends(NoImportsWithRegexWalker, _super); - function NoImportsWithRegexWalker() { - return _super !== null && _super.apply(this, arguments) || this; - } - NoImportsWithRegexWalker.prototype.visitImportDeclaration = function (node) { - var options = this.getOptions(); - for (var _i = 0, options_1 = options; _i < options_1.length; _i++) { - var regStr = options_1[_i]; - var importFrom = node.moduleSpecifier.getText(); - var reg = new RegExp(regStr); - if (importFrom.match(reg)) { - this.addFailure(this.createFailure(node.moduleSpecifier.getStart(), node.moduleSpecifier.getWidth(), "importing from " + regStr + " is prohibited.")); - } - } - _super.prototype.visitImportDeclaration.call(this, node); - }; - return NoImportsWithRegexWalker; -}(Lint.RuleWalker)); diff --git a/tfjs-master/.tslint/noImportsWithRegexRule.ts b/tfjs-master/.tslint/noImportsWithRegexRule.ts deleted file mode 100644 index 3377a61ed..000000000 --- a/tfjs-master/.tslint/noImportsWithRegexRule.ts +++ /dev/null @@ -1,26 +0,0 @@ -import * as Lint from 'tslint'; -import * as ts from 'typescript'; - -export class Rule extends Lint.Rules.AbstractRule { - public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] { - return this.applyWithWalker( - new NoImportsWithRegexWalker(sourceFile, this.getOptions())); - } -} - -class NoImportsWithRegexWalker extends Lint.RuleWalker { - public visitImportDeclaration(node: ts.ImportDeclaration) { - const options = this.getOptions(); - for (const regStr of options) { - const importFrom = node.moduleSpecifier.getText(); - const reg = new RegExp(regStr); - if (importFrom.match(reg)) { - this.addFailure(this.createFailure( - node.moduleSpecifier.getStart(), node.moduleSpecifier.getWidth(), - `importing from ${regStr} is prohibited.`)); - } - } - - super.visitImportDeclaration(node); - } -} diff --git a/tfjs-master/.vscode/settings.json b/tfjs-master/.vscode/settings.json deleted file mode 100644 index 7b4c1a38d..000000000 --- a/tfjs-master/.vscode/settings.json +++ /dev/null @@ -1,149 +0,0 @@ -// Place your settings in this file to overwrite default and user settings. -{ - "search.exclude": { - "**/node_modules": true, - "**/coverage/": true, - "**/dist/": true, - "**/yarn.lock": true, - "**/.rpt2_cache/": true, - "**/.yalc/**/*": true, - "**/.cache/**/*": true, - "**/bazel-bin/**/*": true, - "**/bazel-out/**/*": true, - "**/bazel-genfiles/**/*": true, - "**/bazel-testlogs/**/*": true, - "**/bazel-tfjs*/**/*": true - }, - "files.trimTrailingWhitespace": true, - "editor.tabSize": 2, - "editor.insertSpaces": true, - "[typescript]": { - "editor.formatOnSave": true, - "editor.defaultFormatter": "xaver.clang-format" - }, - "[javascript]": { - "editor.formatOnSave": true - }, - "[cpp]": { - "editor.formatOnSave": true - }, - "emeraldwalk.runonsave": { - "commands": [ - { - "match": "(BUILD|.*bzl)", - "cmd": "yarn bazel:format && yarn bazel:lint" - } - ] - }, - "editor.defaultFormatter": "xaver.clang-format", - "editor.rulers": [80], - "clang-format.style": "Google", - "files.insertFinalNewline": true, - "editor.detectIndentation": false, - "editor.wrappingIndent": "none", - "typescript.tsdk": "node_modules/typescript/lib", - "clang-format.executable": "${workspaceRoot}/node_modules/.bin/clang-format", - "files.associations": { - "memory": "cpp", - "any": "cpp", - "array": "cpp", - "atomic": "cpp", - "strstream": "cpp", - "*.tcc": "cpp", - "bitset": "cpp", - "cctype": "cpp", - "chrono": "cpp", - "cinttypes": "cpp", - "clocale": "cpp", - "cmath": "cpp", - "codecvt": "cpp", - "complex": "cpp", - "condition_variable": "cpp", - "cstdarg": "cpp", - "cstddef": "cpp", - "cstdint": "cpp", - "cstdio": "cpp", - "cstdlib": "cpp", - "cstring": "cpp", - "ctime": "cpp", - "cwchar": "cpp", - "cwctype": "cpp", - "deque": "cpp", - "list": "cpp", - "unordered_map": "cpp", - "unordered_set": "cpp", - "vector": "cpp", - "exception": "cpp", - "algorithm": "cpp", - "filesystem": "cpp", - "functional": "cpp", - "iterator": "cpp", - "map": "cpp", - "memory_resource": "cpp", - "numeric": "cpp", - "optional": "cpp", - "random": "cpp", - "ratio": "cpp", - "regex": "cpp", - "set": "cpp", - "string": "cpp", - "string_view": "cpp", - "system_error": "cpp", - "tuple": "cpp", - "type_traits": "cpp", - "utility": "cpp", - "fstream": "cpp", - "future": "cpp", - "initializer_list": "cpp", - "iomanip": "cpp", - "iosfwd": "cpp", - "iostream": "cpp", - "istream": "cpp", - "limits": "cpp", - "mutex": "cpp", - "new": "cpp", - "ostream": "cpp", - "shared_mutex": "cpp", - "sstream": "cpp", - "stdexcept": "cpp", - "streambuf": "cpp", - "thread": "cpp", - "cfenv": "cpp", - "typeinfo": "cpp", - "valarray": "cpp", - "variant": "cpp", - "charconv": "cpp", - "__bit_reference": "cpp", - "__config": "cpp", - "__debug": "cpp", - "__errc": "cpp", - "__functional_base": "cpp", - "__hash_table": "cpp", - "__locale": "cpp", - "__mutex_base": "cpp", - "__node_handle": "cpp", - "__nullptr": "cpp", - "__split_buffer": "cpp", - "__sso_allocator": "cpp", - "__std_stream": "cpp", - "__string": "cpp", - "__threading_support": "cpp", - "__tree": "cpp", - "__tuple": "cpp", - "bit": "cpp", - "ios": "cpp", - "locale": "cpp", - "queue": "cpp", - "stack": "cpp", - "*.ipp": "cpp", - "forward_list": "cpp", - "typeindex": "cpp", - "*.inc": "cpp", - "hash_map": "cpp", - "__refstring": "cpp" - }, - "editor.formatOnSave": true, - "[json]": { - "editor.defaultFormatter": "vscode.json-language-features" - } -} diff --git a/tfjs-master/.vscode/tasks.json b/tfjs-master/.vscode/tasks.json deleted file mode 100644 index 594b0eea8..000000000 --- a/tfjs-master/.vscode/tasks.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "version": "2.0.0", - "tasks": [ - { - "command": "yarn", - "label": "lint", - "type": "shell", - "args": [ - "lint" - ], - "problemMatcher": { - "base": "$tslint5", - "owner": "tslint-type-checked", - "fileLocation": "absolute" - } - }, - { - "command": "yarn", - "label": "build", - "type": "shell", - "args": ["build", "--pretty", "false", "--noEmit"], - "problemMatcher": [ - "$tsc" - ] - } - ] - } diff --git a/tfjs-master/BAZEL_MIGRATION.md b/tfjs-master/BAZEL_MIGRATION.md deleted file mode 100644 index e4fea3219..000000000 --- a/tfjs-master/BAZEL_MIGRATION.md +++ /dev/null @@ -1,442 +0,0 @@ -# Bazel Migration - -This document details the steps to migrate a package to build with Bazel. These steps are easiest to understand with a working example, so this doc references `tfjs-core`'s setup as much as possible. Since this migration is still in progress, the steps and processes listed here may change as we improve on the process, add features to each package's build, and create tfjs-specific build functions. - -## Scope -Migrating a package to Bazel involves adding Bazel targets that build the package, running its tests, and packing the package for publishing to npm. To ease the transition to Bazel, we're incrementally transitioning packages to build with Bazel, starting with root packages (tfjs-core, tfjs-backend-cpu) and gradually expanding to leaf packages. This is different from our original approach of maintaining our current build and a new Bazel build in parallel, which ended up not working due to some changes that Bazel required to the ts sources. - -## Caveats -- Bazel will only make a dependency or file available to the build if you explicitly declare it as a dependency / input to the rule you're using. -- All Bazel builds use the root package.json, so you may have to add packages to it. As long as you use `@npm//dependency-name` in BUILD files to add dependencies, you won't need to worry about the build accidentally seeing the package's `node_modules` directory instead of the root `node_modules`. Bazel will only make the root `node_modules` directory visible to the build. - - Even though the build doesn't use the package's `node_modules`, you may have to run `yarn` within the package to get code completion to work correctly. We're looking into why this is the case. -- There may be issues with depending on explicitly pinned versions of `@tensorflow` scoped packages, which might affect some demos if they're migrated to use Bazel. We might just want to leave demos out of Bazel so they're easier to understand. - -## Steps -These steps are general guidelines for how to build a package with Bazel. They should work for most packages, but there may be some exceptions (e.g. wasm, react native). - -### Make sure all dependencies build with Bazel -A package's dependencies must be migrated before it can be migrated. Take a look at the package's issue, which can be found by checking [#5287](https://github.com/tensorflow/tfjs/issues/5287), to find its dependencies. - -### Add dependencies to the root `package.json` -Bazel (through `rules_nodejs`) uses a single root `package.json` for its npm dependencies. When converting a package to build with Bazel, dependencies in the package's `package.json` will need to be added to the root `package.json` as well. - -### Create a `BUILD.bazel` file in the package's root -Bazel looks for targets to run in `BUILD` and `BUILD.bazel` files. Use the `.bazel` extension since blaze uses `BUILD`. You may want to install an extension for your editor to get syntax highlighting. [Here's the vscode extension](https://marketplace.visualstudio.com/items?itemName=BazelBuild.vscode-bazel). - -This BUILD file will handle package-wide rules like bundling for npm. - -### Create another `BUILD.bazel` file in `src` -This BUILD file will compile the source files of the package using `ts_library` and may also define test bundles. - -### Compile the package with `ts_library` -In the `src` BUILD.bazel file, we use `ts_library` to compile the package's typescript files. [ts_library](https://bazelbuild.github.io/rules_nodejs/TypeScript.html#ts_library) is a rule provided by rules_nodejs. We wrap `ts_library` in a macro that sets some project-specific settings. - -Here's an example of how `tfjs-core` uses `ts_library` to build. - -`tfjs-core/src/BUILD.bazel` -```starlark -load("//tools:defaults.bzl", "ts_library") - -TEST_SRCS = [ - "**/*_test.ts", - "image_test_util.ts", -] - -# Compiles the majority of tfjs-core using the `@tensorflow/tfjs-core/dist` -# module name. -ts_library( - name = "tfjs-core_src_lib", - srcs = glob( - ["**/*.ts"], - exclude = TEST_SRCS + ["index.ts"], - ), - module_name = "@tensorflow/tfjs-core/dist", - deps = [ - "@npm//@types", - "@npm//jasmine-core", - "@npm//seedrandom", - ], -) - -# Compiles the `index.ts` entrypoint of tfjs-core separately from the rest of -# the sources in order to use the `@tensorflow/tfjs-core` module name instead -# of `@tensorflow/tfjs-core/dist`, -ts_library( - name = "tfjs-core_lib", - srcs = ["index.ts"], - module_name = "@tensorflow/tfjs-core", - deps = [ - ":tfjs-core_src_lib", - ], -) -``` -`ts_library` is used twice in order to have the correct `module_name` for the output files. Most files are imported relative to `@tensorflow/tfjs-core/src/`, but `index.ts`, the entrypoint of `tfjs-core`, should be importable as `@tensorflow/tfjs-core`. - -If your package imports from `dist` (e.g. `import {} from @tensorflow/tfjs-core/dist/ops/ops_for_converter`), that import likely corresponds to a rule in that packages `src/BUILD.bazel` file. Look for a rule that includes the file you're importing and has `module_name` set correctly for that import. - -### Bundle the package -This step involves bundling the compiled files from the compilation step into a single file, and the rules are added to the package's root BUILD file (instead of `src/BUILD.bazel`). In order to support different execution environments, TFJS generates several bundles for each package. We provide a `tfjs_bundle` macro to generate these bundles. - -`tfjs-core/BUILD.bazel` -```starlark -load("//tools:tfjs_bundle.bzl", "tfjs_bundle") - -tfjs_bundle( - name = "tf-core", - entry_point = "//tfjs-core/src:index.ts", - external = [ - "node-fetch", - "util", - ], - umd_name = "tf", - deps = [ - "//tfjs-core/src:tfjs-core_lib", - "//tfjs-core/src:tfjs-core_src_lib", - ], -) -``` -The `tfjs_bundle` macro generates several different bundles which are published in the package publishing step. - - -### Compile the tests with `ts_library` -In the `src/BUILD.bazel` file, we compile the tests with `ts_library`. In the case of `tfjs-core`, we actually publish the test files, since other packages use them in their tests. Therefore, it's important that we set the `module_name` to `@tensorflow/tfjs-core/dist`. If a package's tests are not published, the `module_name` can probably be omitted. In a future major version of tfjs, we may stop publishing the tests to npm. - -`tfjs-core/src/BUILD.bazel` -```starlark -load("//tools:defaults.bzl", "ts_library") - -ts_library( - name = "tfjs-core_test_lib", - srcs = glob(TEST_SRCS), - # TODO(msoulanille): Mark this as testonly once it's no longer needed in the - # npm package (for other downstream packages' tests). - module_name = "@tensorflow/tfjs-core/dist", - deps = [ - ":tfjs-core_lib", - ":tfjs-core_src_lib", - ], -) -``` - -### Update the tests entrypoint -Many packages have a `src/run_tests.ts` file (or similar) that they use for selecting which tests to run. That file defines the paths to the test files that Jasmine uses. Since Bazel outputs appearin a different location, the paths to the test files must be updated. As an example, the following paths -```ts -const coreTests = 'node_modules/@tensorflow/tfjs-core/src/tests.ts'; -const unitTests = 'src/**/*_test.ts'; -``` -would need to be updated to -```ts -const coreTests = 'tfjs-core/src/tests.js'; -const unitTests = 'the-package-name/src/**/*_test.js'; -``` -Note that `.ts` has been changed to `.js`. This is because we're no longer running node tests with `ts-node`, so the input test files are now `.js` outputs created by the `ts_library` rule that compiled the tests. - -It's also important to make sure the `nodejs_test` rule that runs the test has [`link_workspace_root = True`](https://bazelbuild.github.io/rules_nodejs/Built-ins.html#nodejs_binary-link_workspace_root). Otherwise, the test files will not be accessable at runtime. - -### Run node tests with nodejs_test -Our test setup allows fine-tuning of exactly what tests are run via `setTestEnvs` and `setupTestFilters` in `jasmine_util.ts`, which are used in a custom Jasmine entrypoint file `setup_test.ts`. This setup does not work well with [jasmine_node_test](https://bazelbuild.github.io/rules_nodejs/Jasmine.html#jasmine_node_test), which provides its own entrypoint for starting Jasmine. Instead, we use the [nodejs_test](https://bazelbuild.github.io/rules_nodejs/Built-ins.html#nodejs_test) rule. - -`tfjs-core/BUILD.bazel` -```starlark -load("@build_bazel_rules_nodejs//:index.bzl", "js_library", "nodejs_test") - -# This is necessary for tests to have acess to -# the package.json so src/version_test.ts can 'require()' it. -js_library( - name = "package_json", - srcs = [ - ":package.json", - ], -) - -nodejs_test( - name = "tfjs-core_node_test", - data = [ - ":package_json", - "//tfjs-backend-cpu/src:tfjs-backend-cpu_lib", - "//tfjs-core/src:tfjs-core_lib", - "//tfjs-core/src:tfjs-core_src_lib", - "//tfjs-core/src:tfjs-core_test_lib", - ], - entry_point = "//tfjs-core/src:test_node.ts", - link_workspace_root = True, - tags = ["ci"], -) -``` -It's important to tag tests with `ci` if you would like them to run in continuous integration. - - -### Run browser tests with karma_web_test -We use `esbuild` to bundle the tests into a single file. - -`tfjs-core/src/BUILD.bazel` -```starlark -load("//tools:defaults.bzl", "esbuild") - -esbuild( - name = "tfjs-core_test_bundle", - testonly = True, - entry_point = "setup_test.ts", - external = [ - # webworker tests call 'require('@tensorflow/tfjs')', which - # is external to the test bundle. - # Note: This is not a bazel target. It's just a string. - "@tensorflow/tfjs", - "worker_threads", - "util", - ], - sources_content = True, - deps = [ - ":tfjs-core_lib", - ":tfjs-core_test_lib", - "//tfjs-backend-cpu/src:tfjs-backend-cpu_lib", - "//tfjs-core:package_json", - ], -) -``` - -The esbuild bundle is then used in the tfjs_web_test macro, which uses [karma_web_test](https://bazelbuild.github.io/rules_nodejs/Concatjs.html#karma_web_test) to serve it to a browser to be run. Different browserstack browsers can be enabled or disabled in the `browsers` argument, and the full list of browsers is located in `tools/karma_template.conf.js`. Browserstack browser tests are automatically tagged with `ci`. - -`tfjs-core/BUILD.bazel` -```starlark -load("//tools:tfjs_web_test.bzl", "tfjs_web_test") - -tfjs_web_test( - name = "tfjs-core_test", - srcs = [ - "//tfjs-core/src:tfjs-core_test_bundle", - ], - browsers = [ - "bs_chrome_mac", - "bs_firefox_mac", - "bs_safari_mac", - "bs_ios_12", - "bs_android_10", - "win_10_chrome", - ], - static_files = [ - # Listed here so sourcemaps are served - "//tfjs-core/src:tfjs-core_test_bundle", - # For the webworker - ":tf-core.min.js", - ":tf-core.min.js.map", - "//tfjs-backend-cpu:tf-backend-cpu.min.js", - "//tfjs-backend-cpu:tf-backend-cpu.min.js.map", - ], -) -``` - -Whereas before, tests were included based on the [`karma.conf.js`](https://github.com/tensorflow/tfjs/blob/2603aac08c5e41a9c6e5b79d294c6a61800acb67/tfjs-backend-webgl/karma.conf.js#L54-L58) file, now, tests must be included in the test bundle to be run. Make sure to `import` each test file in the test bundle's entrypoint. To help with this, we provide an `enumerate_tests` Bazel rule to generate a `tests.ts` file with the required imports. - -[`tfjs-core/src/BUILD.bazel`](https://github.com/tensorflow/tfjs/blob/a32cc50dbd0dce2e6a53bb962eedc0d87a064b1e/tfjs-core/src/BUILD.bazel#L32-L48) -```starlark -load("//tools:enumerate_tests.bzl", "enumerate_tests") - -# Generates the 'tests.ts' file that imports all test entrypoints. -enumerate_tests( - name = "tests", - srcs = [":all_test_entrypoints"], # all_test_entrypoints is a filegroup - root_path = "tfjs-core/src", -) -``` - -### Update the package.json -1. Verify the entrypoints of the package.json to match the outputs generated by `tfjs_bundle` and `ts_library`. [tfjs-core/package.json](https://github.com/tensorflow/tfjs/blob/a32cc50dbd0dce2e6a53bb962eedc0d87a064b1e/tfjs-core/package.json#L6-L12) is an example. - 1. The main entrypoint should point to the node bundle, `dist/tf-package-name.node.js`. - 2. `jsnext:main` and `module` should point to the ESModule output `dist/index.js` created by `copy_ts_library_to_dist`. -2. If the package has browser tests, update the `sideEffects` field to include `.mjs` files generated by the `ts_library` under `./src` (e.g. `src/foo.mjs`). Bazel outputs directly to `src`, and although we copy those outputs to `dist` with another Bazel rule, the browser test bundles still import from `src`, so we need to mark them as sideEffects. - -### Package for npm -We use the [pkg_npm](https://bazelbuild.github.io/rules_nodejs/Built-ins.html#pkg_npm) rule to create and publish the package to npm. However, there are a few steps needed before we can declare the package. For most packages, we distribute all our compiled outputs in the `dist` directory. However, due to how `ts_library` works, it creates outputs in the same directory as the source files were compiled from (except they show up in Bazel's `dist/bin` output dir). We need to copy these from `src` to `dist` while making sure Bazel is aware of this copy (so we can still use `pkg_npm`). - -We also need to copy several other files to `dist`, such as the bundles created by `tfjs_bundle`, and we need to create [miniprogram](https://walkthechat.com/wechat-mini-programs-simple-introduction/) files for WeChat. - -To copy files, we usually use the `copy_to_dist` rule. This rule creates symlinks to all the files in `srcs` and places them in a filetree with the same structure in `dest_dir` (which defaults to `dist`). - -However, we can't just copy the output of a `ts_library`, since its default output is the `.d.ts` declaration files. We need to extract the desired ES Module `.mjs` outputs of the rule and rename them to have the `.js` extension. The `copy_ts_library_to_dist` does this rename, and it also copies the files to `dist` (including the `.d.ts` declaration files). - -```starlark -load("//tools:copy_to_dist.bzl", "copy_ts_library_to_dist") - -copy_ts_library_to_dist( - name = "copy_src_to_dist", - srcs = [ - "//tfjs-core/src:tfjs-core_lib", - "//tfjs-core/src:tfjs-core_src_lib", - "//tfjs-core/src:tfjs-core_test_lib", - ], - root = "src", # Consider 'src' to be the root directory of the copy - # (i.e. create 'dist/index.js' instead of 'dist/src/index.js') - dest_dir = "dist", # Where to copy the files to. Defaults to 'dist', so it can - # actually be omitted in this case. -) -``` - -We can also copy the bundles output from `tfjs_bundle` - -```starlark -copy_to_dist( - name = "copy_bundles", - srcs = [ - ":tf-core", - ":tf-core.node", - ":tf-core.es2017", - ":tf-core.es2017.min", - ":tf-core.fesm", - ":tf-core.fesm.min", - ":tf-core.min", - ], -) -``` - -We copy the miniprogram files as well, this time using the `copy_file` rule, which copies a single file to a destination. - -```starlark -load("@bazel_skylib//rules:copy_file.bzl", "copy_file") - -copy_file( - name = "copy_miniprogram", - src = ":tf-core.min.js", - out = "dist/miniprogram/index.js", -) - -copy_file( - name = "copy_miniprogram_map", - src = ":tf-core.min.js.map", - out = "dist/miniprogram/index.js.map", -) -``` - -Now that all the files are copied, we can declare a `pkg_npm` - -```starlark -load("@build_bazel_rules_nodejs//:index.bzl", "pkg_npm") - -pkg_npm( - name = "tfjs-core_pkg", - package_name = "@tensorflow/tfjs-core", - srcs = [ - # Add any static files the package should include here - "package.json", - "README.md", - ], - tags = ["ci"], - deps = [ - ":copy_bundles", - ":copy_miniprogram", - ":copy_miniprogram_map", - ":copy_src_to_dist", - ":copy_test_snippets", # <- This is only in core, so I've omitted its - # definition in these docs. - ], -) -``` - -Now the package can be published to npm with `bazel run //tfjs-core:tfjs-core_pkg.publish`. - - -### Configure Publishing to npm -With a `pkg_npm` rule defined, we add a script to `package.json` to run it. This script will be used by the main script that publishes the monorepo. - -```json -"scripts" { - "publish-npm": "bazel run :tfjs-core_pkg.publish" -} -``` - -Since we now use the `publish-npm` script to publish this package instead of `npm publish`, we need to make sure the release tests and release script know how to publish it. - -1. In `scripts/publish-npm.ts`, add your package's name to the `BAZEL_PACKAGES` set. -2. In `e2e/scripts/publish-tfjs-ci.sh`, add your package's name to the `BAZEL_PACKAGES` list. - -You should also add a script to build the package itself without publishing (used for the `link-package`). - -```json -"build": "bazel build :tfjs-core_pkg", -``` - -### Update Downstream `package.json` Paths - -If no packages depend on your package (i.e. no `package.json` file includes your package via a `link` dependency), then you can skip this section. - -As a core featue of its design, Bazel places outputs in a different directory than sources. Outputs are symlinked to `dist/bin/[package-name]/.....` instead of appearing in `[package-name]/dist`. Due to the different location, all downstream packages' `package.json` files need to be updated to point to the new outputs. However, due to some details of how Bazel and the Node module resolution algorithm work, we can't directly `link:` to Bazel's output. - -Instead, we maintain a `link-package` pseudopackage where we copy the Bazel outputs. This package allows for correct Node module resolution between Bazel outputs because it has its own `node_modules` folder. This package will never be published and will be removed once the migration is complete. - -#### Add the Package to `link-package` -Add your package to the `PACKAGES` list in the `build_deps.ts` script in `link-package`. For a package with npm name `@tensorflow/tfjs-foo`, the package's directory in the monorepo and the value to add to `PACKAGES` should both be `tfjs-foo`. The name of the package's `pkg_npm` target should be `tfjs-foo_pkg`. - -```typescript -const PACKAGES: ReadonlySet = new Set([ - ..., 'tfjs-foo', -]); -``` - -#### Change Downstream Dependency `package.json` Paths -Update all downstream dependencies that depend on the package to point to its location in the `link-package`. - -```json -"devDependencies": { - "@tensorflow/tfjs-core": "link:../link-package/node_modules/@tensorflow/tfjs-core", - "@tensorflow/tfjs-foo": "link:../link-package/node_modules/@tensorflow/tfjs-foo", -}, -``` - -To find downstream packages, run `grep -r --exclude=yarn.lock --exclude-dir=node_modules "link:.*tfjs-foo" .` in the root of the repository. - -#### Remove the 'build-tfjs-foo' Script from Downstream Packages -Remove the `build-tfjs-foo` script from downstream packages' package.json files. -```json -"scripts": { - "build-deps": "....... && yarn build-tfjs-foo" // <-- Remove 'yarn build-deps-foo'. - "build-tfjs-foo": "remove this script", // <-- Also remove it here. -} -``` -### Move linting to the repo-wide lint script -#### Add the new Bazel package to the [repo-wide tslint tsconfig](tsconfig_tslint.json): - -Add the path mapping: -```json -"paths": { - ..., - "@tensorflow/the-new-package": ["the-new-package/src/index.ts"], - "@tensorflow/the-new-package/dist/*": ["the-new-package/src/*"] -``` - -Also, remove the package from the `exclude` list. - -It's a good idea to test that linting is working on the package. Create a lint error in one if its files, e.g. `const x = "Hello, world!"` (note the double quotes), and then run `yarn lint` in the root of the repository. - -#### Remove the package's own TypeScript linting scripts: -Remove the `package.json` `lint` script, the `tslint.json` file, and the cloudbuild `lint` step from the package's `cloudbuild.yml` file. Remove `tslint`-related dependencies from the package's `package.json` and run `yarn` to regenerate the `yarn.lock` file. - -### Update or Remove `cloudbuild.yml` -Update the `cloudbuild.yml` to remove any steps that are now built with Bazel. These will be run by the `bazel-tests` step, which runs before other packages' steps. Any Bazel rule tagged as `ci` will be tested / build in CI. - -Note that the output paths of Bazel-created outputs will be different, so any remaining steps that now rely on Bazel outputs may need to be updated. Bazel outputs are located in `tfjs/dist/bin/...`. - -If all steps of the `cloudbuild.yml` file are handled by Bazel, it can be deleted. Do not remove the package from `tfjs/scripts/package_dependencies.json`. - -Rebuild the cloudbuild golden files by running `yarn update-cloudbuild-tests` in the root of the repository. - -### Push to Git -Before pushing to Git, run the Bazel linter by running `yarn bazel:format` and `yarn bazel:lint-fix` in the root of the repo. We run the linter in CI, so if your build is failing in CI only, incorrectly formatted files may be the reason. - -### Done! -🎉🎉🎉 - -## Notes for Reviewing PRs -* Make sure the package is added to `BAZEL_PACKAGES` in [e2e/scripts/publish-tfjs-ci.sh](https://github.com/tensorflow/tfjs/blob/master/e2e/scripts/publish-tfjs-ci.sh#L61) -* Make sure the package is added to `BAZEL_PACKAGES` in [scripts/publish-npm.ts](https://github.com/tensorflow/tfjs/blob/master/scripts/publish-npm.ts#L31) -* Make sure the package generated by `pkg_npm` has all the files it needs, e.g. the README. -* Make sure the package is added to the link-package's package.json and that downstream pakcages are updated to point to the link package's copy instead of the package's directory. -* For browser tests, it may be worth checking that all desired browser configurations will run in nightly CI. -* Make sure browser tests include all required tests. The `enumerate_tests` rule is usually necessary to make the browser actually run tests. -* Make sure as many cloudbuild steps as possible are converted to Bazel, and that those steps are removed from the cloudbuild file. -* If the build and tests are fully handled by Bazel and don't need any other cloudbuild steps, make sure the package's `cloudbuild.yml` file is removed. Do not remove the package from [scripts/package_dependencies.json](https://github.com/tensorflow/tfjs/blob/master/scripts/package_dependencies.json). -* Make sure tests are tagged with `nightly` or `ci` (`tfjs_web_test` automatically tags tests with `nightly` and `ci`). -* Make sure the main `pkg_npm` rule is tagged with `ci` or `nightly` so all parts of the build are tested. -* Make sure the `package.json` scripts are updated and that the package.json includes `@bazel/bazelisk` as a dev dependency. -* Make sure the package has a `build-npm` script and a `publish-npm` script. These are used by the release script. -* Check the generated bundle sizes and make sure they don't include any unexpected files. Check the `_stats` files for info on this. -* Make sure the package is added to the [repo-wide tslint tsconfig](tsconfig_tslint.json) and that its original lint scripts are removed. diff --git a/tfjs-master/BUILD.bazel b/tfjs-master/BUILD.bazel deleted file mode 100644 index d1c21570a..000000000 --- a/tfjs-master/BUILD.bazel +++ /dev/null @@ -1,64 +0,0 @@ -# Copyright 2021 Google LLC. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================= - -load("@npm//@bazel/concatjs:index.bzl", "ts_config") -load("//tools:tfjs_web_test.bzl", "grep_flag", "headless_flag") - -package(default_visibility = ["//visibility:public"]) - -exports_files([ - "babel.config.json", - "tsconfig.json", - "tsconfig_es5.json", - "tsconfig.test.json", - "tsconfig_base.json", - "tsconfig_ts_library.json", -]) - -ts_config( - name = "tsconfig_ts_library", - src = "tsconfig_ts_library.json", - deps = [ - ":tsconfig.json", - ":tsconfig_base.json", - ], -) - -grep_flag( - name = "grep", - build_setting_default = "", - visibility = ["//visibility:public"], -) - -headless_flag( - name = "headless", - build_setting_default = True, - visibility = ["//visibility:public"], -) - -test_suite( - name = "tests", - tests = [ - "//tfjs-backend-cpu:tests", - "//tfjs-backend-wasm:tests", - "//tfjs-backend-webgl:tests", - "//tfjs-converter:tests", - "//tfjs-core:tests", - "//tfjs-data:tests", - "//tfjs-layers:tests", - "//tfjs-tfdf:tests", - "//tfjs-tflite:tests", - ], -) diff --git a/tfjs-master/CONTRIBUTING.md b/tfjs-master/CONTRIBUTING.md deleted file mode 100644 index 3473e796c..000000000 --- a/tfjs-master/CONTRIBUTING.md +++ /dev/null @@ -1,86 +0,0 @@ -# How to Contribute - -We'd love to accept your patches and contributions to this project. There are -just a few small guidelines you need to follow. - -## Contributor License Agreement - -Contributions to this project must be accompanied by a Contributor License -Agreement. You (or your employer) retain the copyright to your contribution, -this simply gives us permission to use and redistribute your contributions as -part of the project. Head over to to see -your current agreements on file or to sign a new one. - -You generally only need to submit a CLA once, so if you've already submitted one -(even if it was for a different project), you probably don't need to do it -again. - -## Code reviews - -All submissions, including submissions by project members, require review. We -use GitHub pull requests for this purpose. Consult -[GitHub Help](https://help.github.com/articles/about-pull-requests/) for more -information on using pull requests. - -## Continuous Integration -Continuous Integration tests run for every PR that is sent against TensorFlow.js repositories. Any time you push to the branch, they will re-run. Before asking for a review, make sure that the continuous integration tests are passing. - -To see the logs from the Cloud Build CI, please join either -our [discussion](https://groups.google.com/a/tensorflow.org/forum/#!forum/tfjs) -or [announcement](https://groups.google.com/a/tensorflow.org/forum/#!forum/tfjs-announce) mailing list. - -#### Failing tests (click details for information): - -Click "Details", and then "View more details on Google Cloud Build" for information about the failure. - - - -#### Passing tests: - - - -## Filing GitHub issues - -Please follow the guidelines specified in the -[ISSUE_TEMPLATE](https://github.com/tensorflow/tfjs/tree/master/.github/ISSUE_TEMPLATE) -file. - -## Good places to start - -Consider joining the [tfjs mailing list](https://groups.google.com/a/tensorflow.org/d/forum/tfjs) -to discuss the development of TensorFlow.js. If you're working on anything -substantial it's better to discuss your design before submitting a PR. -If you're looking for tasks to work on, we also mark issues as ["good first issue"](https://github.com/tensorflow/tfjs/labels/good%20first%20issue) and ["stat:contributions welcome"](https://github.com/tensorflow/tfjs/labels/stat%3Acontributions%20welcome) - -## Adding functionality - -One way to ensure that your PR will be accepted is to add functionality that -has been requested in Github issues. If there is something you think is -important and we're missing it but does not show up in Github issues, it would -be good to file an issue there first so we can have the discussion before -sending us a PR. - -In general, we're trying to add functionality when driven by use-cases instead of -adding functionality for the sake of parity with TensorFlow python. This will -help us keep the bundle size smaller and have less to maintain especially as we -add new backends. - -### Adding an op - -When adding ops to the library and deciding whether to write a kernel -implementation in [backend.ts](/tfjs-core/src/backends/backend.ts), -be sure to check out the TensorFlow ops list [here](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/ops/ops.pbtxt). -This list shows the kernels available for the TensorFlow C API. To ensure that -we can bind to this with node.js, we should ensure that our backend.ts -interface matches ops in the TensorFlow C API. For detailed instructions on -how to add a new op, see [CONTRIBUTING_MISSING_OP.md](/CONTRIBUTING_MISSING_OP.md). - -## Code reviews - -All submissions, including submissions by project members, require review. We -use GitHub pull requests for this purpose. Consult -[GitHub Help](https://help.github.com/articles/about-pull-requests/) for more -information on using pull requests. - -We require unit tests for most code, instructions for running our unit test -suites are in the documentation. diff --git a/tfjs-master/CONTRIBUTING_MISSING_OP.md b/tfjs-master/CONTRIBUTING_MISSING_OP.md deleted file mode 100644 index 84bf3d1d7..000000000 --- a/tfjs-master/CONTRIBUTING_MISSING_OP.md +++ /dev/null @@ -1,84 +0,0 @@ -## How to Contribute a New op to TF.js Repository - -### Step 1. Add the new op to tfjs-core ops directory. -**Prerequisite** -1. The op should already be supported in [TF](https://www.tensorflow.org/api_docs/python/tf/all_symbols) api. -2. The op should not have been supported in TF.js, see [op support list](https://github.com/tensorflow/tfjs/blob/master/tfjs-converter/docs/supported_ops.md). -3. Check [here](https://docs.google.com/spreadsheets/d/1D25XtWaBrmUEErbGQB0QmNhH-xtwHo9LDl59w0TbxrI/edit#gid=0) for various ops supported in different backends. - -**Implementation Details** -1. Create a new op in `tfjs-core/ops` directory. - - The op file should have the following elements: - 1. License information. - 2. JSDoc comment. - 3. Input validations, if any. - 4. Delegate the execution to the right kernel through `ENGINE.runKernel()`. - - In addition, for the kernel delegation to work properly, in `kernel_names.ts` - file, define: - 1. kernel name. - 2. input type. - 3. attribute type. - -2. Export the op file in ops.ts in the same directory. -3. Add tests for the op in the same directory. Test file name should be the same as the op file’s name with _test suffix. -4. Exclude the test in all the backends, and add annotation “Not implemented yet.â€. See below for where to exclude the test in each backend: - -**cpu backend** - -In `run_tests.ts`, `customInclude` method, add: -``` - // Not implemented yet. - if (testName.includes(test_name)) { - return false; - } -``` - -**webgl backend** - -In `setup_test.ts`, `customInclude` method, add: -``` - // Not implemented yet. - if (testName.includes(test_name)) { - return false; - } -``` - -**node backend** - -In `run_tests.ts`, `IGNORE_LIST`, add test_name to the list. - -**Example PRs** -* [CPU and WebGL backend SparseReshape](https://github.com/tensorflow/tfjs/pull/4956) - -### Step 2. Add a new kernel in a backend. -**Implementation Details** -1. Create a new kernel in the `kernels` directory of a backend. - - The kernel file should have the following elements: - 1. License information. - 2. The kernel implementation, and export it. - 3. Export a `kernelConfig`. - -2. Register the kernel in `register_all_kernels.ts` in the corresponding backend. - -3. Remove the op from test exclusion list in the corresponding backend. For wasm - backend, add the test to the inclusion list. - -**Example PRs** -* [CPU and WebGL backend SparseReshape](https://github.com/tensorflow/tfjs/pull/4956) -* [WASM backend Round](https://github.com/tensorflow/tfjs/pull/4486) - -### Step 3. Add the op to Converter’s executor. -1. Add op mapping in the op list ts file, use your best judgement to assign an op category: `tfjs-converter/python/tensorflowjs/op_list/{corresponding_op_category}.json`. The corresponding `.ts` file will be automatically generated when converter is built. Use -the [TF C++ op api](https://www.tensorflow.org/api_docs/cc/) as reference for tfOpName, inputs, and attrs. - -2. Find the corresponding executor for the op and add the op to the switch, the [executors](https://github.com/tensorflow/tfjs/tree/master/tfjs-converter/src/operations/executors) are in `tfjs-converter/src/operations/executors`. - -3. Add a test to the corresponding executor test file. - -4. Update the supported op doc in `tfjs-converter/docs/supported_ops.md`. - -**Example PRs** -* [SparseReshape Op](https://github.com/tensorflow/tfjs/pull/4963) diff --git a/tfjs-master/DEVELOPMENT.md b/tfjs-master/DEVELOPMENT.md deleted file mode 100644 index 6e99f27d7..000000000 --- a/tfjs-master/DEVELOPMENT.md +++ /dev/null @@ -1,207 +0,0 @@ -## Development - -This repository is a monorepo that contains the following NPM packages: - -APIs: -- [TensorFlow.js Core](/tfjs-core), - a flexible low-level API for neural networks and numerical computation. -- [TensorFlow.js Layers](/tfjs-layers), - a high-level API which implements functionality similar to - [Keras](https://keras.io/). -- [TensorFlow.js Data](/tfjs-data), - a simple API to load and prepare data analogous to - [tf.data](https://www.tensorflow.org/guide/datasets). -- [TensorFlow.js Converter](/tfjs-converter), - tools to import a TensorFlow SavedModel to TensorFlow.js -- [TensorFlow.js Vis](/tfjs-vis), - in-browser visualization for TensorFlow.js models -- [TensorFlow.js AutoML](/tfjs-automl), - Set of APIs to load and run models produced by - [AutoML Edge](https://cloud.google.com/vision/automl/docs/edge-quickstart). - - -Backends/Platforms: -- [TensorFlow.js CPU Backend](/tfjs-backend-cpu), pure-JS backend for Node.js and the browser. -- [TensorFlow.js WebGL Backend](/tfjs-backend-webgl), WebGL backend for the browser. -- [TensorFlow.js WASM Backend](/tfjs-backend-wasm), WebAssembly backend for the browser. -- [TensorFlow.js WebGPU](/tfjs-backend-webgpu), WebGPU backend for the browser. -- [TensorFlow.js Node](/tfjs-node), Node.js platform via TensorFlow C++ adapter. -- [TensorFlow.js React Native](/tfjs-react-native), React Native platform via expo-gl adapter. - -#### Yarn -We use yarn, and if you are adding or removing dependencies you should use yarn -to keep the `yarn.lock` file up to date. - -#### Code editor -We recommend using [Visual Studio Code](https://code.visualstudio.com/) for -development. Make sure to install -[TSLint VSCode extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode.vscode-typescript-tslint-plugin) -and the npm [clang-format](https://github.com/angular/clang-format) `1.2.2` or later -with the -[Clang-Format VSCode extension](https://marketplace.visualstudio.com/items?itemName=xaver.clang-format) -for auto-formatting. - -#### Testing -Before submitting a pull request, make sure the code passes all the tests and is clean of lint errors: - -```bash -# Run this at the root of the repository -$ yarn lint -# cd into the package directory you want to test -$ yarn test -# You may also need to run 'yarn lint' in the directory you want to test -$ yarn lint -``` -This will install yarn dependencies, build the other TensorFlow.js packages that the package being tested depeds on, -and run the tests for the package. During development, you may want to run `yarn test-dev` instead to avoid -unnecessarily rebuilding dependencies. - -Many TensorFlow.js packages use Karma to run tests in a browser. These tests can be configured by command-line options. - -To run a subset of tests: - -```bash -$ yarn test --//:grep=multinomial -  -> ... -> Chrome 62.0.3202 (Mac OS X 10.12.6): Executed 28 of 1891 (skipped 1863) SUCCESS (6.914 secs / 0.634 secs) -``` - -By default, the tests run once and exit. To keep the karma server active, run the following: - -```bash -# For packages with only browser tests -$ yarn test-debug -# For packages with browser and node tests -$ yarn test-browser-debug -``` - -You can now connect to the server with your own browser. - -On most platforms, Karma tests will run with a headless Chrome browser. This can be overridden by setting the -`--//:headless` flag. - -```bash -# Run tests with a visible browser window. Note this does not work well with -# 'watch' modes such as 'test-dev' or 'ibazel'. -$ yarn test --//:headless=false -``` - -#### Packaging (browser and npm) - -In any of the directories the following commands build the NPM tarball: - -```bash -# Example for tfjs-core -$ yarn build-npm -# The output is located at ../dist/bin/tfjs-core/tfjs-core_pkg/ -# You can also package as a tar with -$ yarn bazel run :tfjs-core_pkg.pack -``` - -To install it locally, run `yarn add ./tensorflow-tf-core-VERSION.tgz`. - -> On Windows, use bash (available through git or WSL2) to use the scripts above. For the best experience, we recommend using [WSL2](https://docs.microsoft.com/en-us/windows/wsl/install). - -Looking to contribute, and don't know where to start? Check out our "stat:contributions welcome" [issues](https://github.com/tensorflow/tfjs/labels/stat%3Acontributions%20welcome). - -#### Developing on Windows -Developing on Windows is supported through the [Windows Subsystem for Linux (WSL)](https://docs.microsoft.com/en-us/windows/wsl/about) running Debian. - -1. Install WSL2 (if necessary) by following [Microsoft's instructions](https://docs.microsoft.com/en-us/windows/wsl/install). WSL1 has not been tested, but it may work. -2. Install Debian in WSL2. [Debian is available from the Microsoft store](https://www.microsoft.com/en-us/p/debian/9msvkqc78pk6?activetab=pivot:overviewtab). -3. Open Debian and install node and yarn with -`sudo apt update && sudo apt install nodejs && npm i -g yarn`. -If you need to reset the root debian password, you can get a root shell from command prompt with `wsl -u root`. -4. Make sure Chrome is installed on Windows. Then, find the path to `chrome.exe`. It's probably `C:\Program Files\Google\Chrome\Application\chrome.exe`. -5. Run the following to set up the `CHROME_BIN` variable, clone the `tfjs` repo, and create a custom `.bazelrc.user` config for WSL. If your `chrome.exe` is not located at the above path, you will need to change it to the correct path in the command below. -```bash -# Add yarn bin to the path -echo "export PATH=$PATH:~/.yarn/bin/" >> ~/.bashrc && -# Set CHROME_BIN. Change this if your CHROME_BIN has a different path. -echo "export CHROME_BIN=/mnt/c/Program\ Files/Google/Chrome/Application/chrome.exe" >> ~/.bashrc && -source ~/.bashrc && -# Clone tfjs. -git clone https://github.com/tensorflow/tfjs.git && -cd tfjs && -# Create the .bazelrc.user file for WSL. -echo "# Pass necessary WSL variables for running in Windows Subsystem for Linux. -# WSLENV and WSL_DISTRO_NAME are build-in variables that are needed for running -# the 'wslpath' command, which Karma uses to resolve file paths. -# DISPLAY=:0 is passed to the Chrome process to make it launch in a window -# since running Chrome headlessly from WSL does not seem to work. If you get -# this working, please send a PR updating these docs (or open an issue :). -run --test_env=CHROME_BIN --test_env=WSLENV --test_env=WSL_DISTRO_NAME --define DISPLAY=:0 -test --test_env=CHROME_BIN --test_env=WSLENV --test_env=WSL_DISTRO_NAME --define DISPLAY=:0" > .bazelrc.user && -printf "\n\nDone! Try running a browser test to verify the installation worked, e.g. 'cd tfjs-core && yarn && yarn test-browser'\n" -``` -6. To access this repo from VScode, follow [Microsoft's WSL VSCode Tutorial](https://docs.microsoft.com/en-us/windows/wsl/tutorials/wsl-vscode). - -## For repository owners: commit style guide - -When merging commits into master, it is important to follow a few conventions -so that we can automatically generate release notes and have a uniform commit -history. - -1. When you squash and merge, the default commit body will be all of the -commits on your development branch (not the PR description). These are usually -not very useful, so you should remove them, or replace them with the PR -description. - -2. Release notes are automatically generated from commits. We have introduced a -few tags which help sort commits into categories for release notes: - -- FEATURE (when new functionality / API is added) -- BREAKING (when there is API breakage) -- BUG (bug fixes) -- PERF (performance improvements) -- DEV (development flow changes) -- DOC (documentation changes) -- SECURITY (security changes) - -These tags correspond to GitHub labels which are automatically prepended to your PR description. -Please add the appropriate labels to your PR. - -A typical commit may look something like: - -``` -Subject: Add tf.toPixels. (#900) -Body: -FEATURE - -tf.toPixels is the inverse of tf.fromPixels, writing a tensor to a canvas. - -``` - -This will show up under "Features" as: -- Add tf.toPixels. (#900). Thanks, @externalcontributor. - - -You can also use multiple tags for the same commit if you want it to show up in -two sections. You can add clarifying text on the line of the tags. - -You can add clarifying messages on the line of the tag as well. - -For example: - -``` -Subject: Improvements to matMul. (#900) -Body: - -FEATURE Add transpose bits to matmul. -PERFORMANCE Improve matMul CPU speed by 100%. -``` - -This will show up under "Features" as: -- Add transpose bits to matmul (Improvements to matMul.) (#900). Thanks, @externalcontributor. - -This will also show up under "Performance" as: -- Improve matMul CPU speed by 100%. (Improvements to matMul.) (#900). Thanks, @externalcontributor. -To build **TensorFlow.js Core API** from source, we need to clone the project and prepare -the dev environment: - -```bash -$ git clone https://github.com/tensorflow/tfjs-core.git -$ cd tfjs-core -$ yarn # Installs dependencies. -``` diff --git a/tfjs-master/GALLERY.md b/tfjs-master/GALLERY.md deleted file mode 100644 index 17d104bd9..000000000 --- a/tfjs-master/GALLERY.md +++ /dev/null @@ -1,144 +0,0 @@ - -# Gallery - -Welcome to the TensorFlow.js gallery! This is a collection of TensorFlow.js projects, tutorials, videos, and more. - -Please reach out to us if you'd like to put your project on the list. - -## Demos & Applications - -- [HumanGPS: Dense Human Correspondences](https://feitongt.github.io/HumanGPS/#Live_demo) - A deep learning framework that maps each pixel to a feature space, where the feature distances reflect the geodesic distances among pixels as if they were projected onto the surface of a 3D human scan. -- [Time Series Forecasting](https://jinglescode.github.io/time-series-forecasting-tensorflowjs/) - Pull stock prices from online API, train and perform predictions using Long Short Term Memory, and predict the next value. [[demo](https://jinglescode.github.io/time-series-forecasting-tensorflowjs/)][[repo](https://github.com/jinglescode/time-series-forecasting-tensorflowjs)] -- [Textual Similarity Analysis](https://jinglescode.github.io/textual-similarity-universal-sentence-encoder/) - Group similar sentences with universal sentence encoder word embeddings [[demo](https://jinglescode.github.io/textual-similarity-universal-sentence-encoder/)][[repo](https://github.com/jinglescode/textual-similarity-universal-sentence-encoder)] -- [PoseAnimator](https://github.com/yemount/pose-animator/) - Animate any SVG character using your own body live via your webcam. Uses posenet and facemesh to create some really unique animations. -- [3D Face Doodles](https://github.com/cyrildiagne/ar-facedoodle) - What if your face was a canvas and you could paint on it in real time? Check out this experiment that does just that in real time in the browser. -- [Shaderbooth](https://shaderbooth.com/?85daa) - Experiment with WebGL Shaders + TensorFlow.js to create stunning visual effects such as shooting lasers from your eyes and more! -- [Veremin](https://github.com/vabarbosa/veremin) - Play and create music in thin air with this digital take of a Theramin instrument. [Even better when hooked up to Tesla Coils](https://www.youtube.com/watch?v=ywbNLHydgzA) -- [Man of many faces](https://twitter.com/thespite/status/1263576045577555969) - Create 3D masks of any face which you can then wear yourself. -- [Confront yourself](https://yiwenl.github.io/Sketches/exps/66/) - An artistic peice that allows you to confront yourself in this beautiful WebGL experience. -- [Virtual Tailor](https://www.youtube.com/watch?v=kFtIddNLcuM) - Get an estimate of your clothing size measurements in less than 15 seconds. -- [Paper Doll](https://github.com/bengfarrell/paperdoll) - What if you could colour in a drawing of a character and then bring the drawing to life using your own body as the controller? Well now you can. Bring drawings to life with Paper Doll. -- [Invisibility Cloak](https://github.com/jasonmayes/Real-Time-Person-Removal) - Bring your scifi movie dreams to life with this real time person removal system that runs in the browser. -- [Bring magazines to life](https://twitter.com/AlexandreDevaux/status/1254719491755433985) - Scan a magazine of a person in it and bring that person to life right infront of you using WebGL and WebXR. -- [Music Generation using Hands](https://twitter.com/prenalys/status/1250509352458268673) - turn your hands into a musical instrument using handpose. -- [Posenet2Scratch](https://github.com/champierre/posenet2scratch) Use the popular posenet model within the Scratch environment - a great way to get younger folk or those interested in using visual based editors to take their first steps. Also see [Handpose2Scratch](https://github.com/champierre/handpose2scratch) and [FaceMesh2Scratch](https://github.com/champierre/facemesh2scratch). -- [MLBlock](http://mlblock.org) A very advanced visual based edtior to explore many TensorFlow.js models and more. Combine sensors with models and see results live in your browser as you chain items together creating complex apps in minutes. -- [Touch The Dot](http://touch-the-dot.herokuapp.com/) - A game created using PoseNet which the player must hit the colored dots with the correct hand and gain as many points as possible (A webcam is a must). [library](https://github.com/OmriGM/body-pose-beat-game) by [Omri Grossman](http://github.com/OmriGM) -- [Object Tracking JS](https://cp4ms.csb.app/) - Track any object as it moves through a video with no training required. [library](https://github.com/cloud-annotations/object-tracking-js) by [Nick Bourdakos](http://github.com/bourdakos1) -- [NSFW JS](https://nsfwjs.com/) - Client-side indecent content checker. [library](https://github.com/infinitered/nsfwjs) and [blogpost](https://shift.infinite.red/avoid-nightmares-nsfw-js-ab7b176978b1) by [Gant Laborde](http://gantlaborde.com/) -- [Honkling](https://castorini.github.io/honkling/) - An in-browser keyword spotting system by Jaejun Lee, Raphael Tang, Jimmy Lin -- [TensorSpace.js](https://github.com/tensorspace-team/tensorspace) - A 3D visualization framework for neural networks, featuring interactive and intuitive display of models in the browser. Supports pre-trained models from TensorFlow, Keras, and TensorFlow.js. -- [Magenta Studio](https://magenta.tensorflow.org/studio) - A collection of music plugins built on Magenta’s open source tools and models using cutting-edge machine learning techniques for music generation. -- [Move Mirror](https://experiments.withgoogle.com/collection/ai/move-mirror/view) - An AI Experiment with Pose Estimation in the Browser using TensorFlow.js -- [Emoji Scavenger Hunt](https://emojiscavengerhunt.withgoogle.com/) - Locate the emoji we show you in the real world with your phone’s camera. -- [Semi-Conductor](https://semiconductor.withgoogle.com/) - Conduct your own orchestra in the browser by moving your arms. -- [Metacar](https://www.metacar-project.com/) - A reinforcement learning environment for self-driving cars in the browser. -- [Evolution Simulator](https://github.com/adityathebe/evolutionSimulator) - Evolution Simulator using NeuroEvolution -- [Play pong with webcam](https://ml4a.github.io/demos/tfjs/regression-pong.html) by Gene Kogan -- [Make music with PoseNet](https://ml4a.github.io/demos/tfjs/posenet-music.html) by Gene Kogan -- [Neural drum machine](https://codepen.io/teropa/pen/JLjXGK) by Tero Parviainen -- [Pose Music](https://codepen.io/teropa/pen/QxLrMp) by Tero Parviainen -- [Neural Arpeggiator](https://codepen.io/teropa/pen/ddqEwj) by Tero Parviainen -- [Neural Melody Autocompletion](https://codepen.io/teropa/pen/gvwwZL) by Tero Parviainen -- [Deep Roll](https://codepen.io/teropa/pen/zpbLOj) by Tero Parviainen -- [Latent Cycles](https://codepen.io/teropa/pen/rdoPbG) by Tero Parviainen -- [PoseNet + Pts.js](https://github.com/williamngan/pts/tree/master/demo/more/tfjs_posenet) - Visualizing pose with pts.js -- [Falling balls + DQN](http://web.sfc.keio.ac.jp/~t15704yn/falling/index.html) - A demo of a DQN agent that learns to dodge falling balls by seann999 -- [Tenori Off](https://tenori-off.glitch.me/) - An ML-powered music sequencer by Monica Dinculescu -- [Hello TensorFlow.js](https://hello-tensorflow.glitch.me/) - Polynomial Regression by Monica Dinculescu -- [Simple MNIST GAN](https://mwdchang.github.io/tfjs-gan/) by Daniel Chang -- [Complementary Color Prediction](http://stelling.cc/complementary-color-prediction/) by Roberto Stelling -- [Mars at Home](https://github.com/MarsAtHome/marsjs) - Mars@Home client for Firefox & Chrome - Labels image from Unsplash in browser -- [Nxt Word](https://github.com/rajveermalviya/language-modeling) - Next Word Predictor - by Rajveer Malviya -- [Interactive Classification](https://github.com/poloclub/interactive-classification) - Modify images and see how deep learning classifiers respond -- [Hidden Markov Model with Gaussian emissions](https://github.com/nearform/node-hidden-markov-model-tf) - A trainable Hidden Markov Model with Gaussian emissions using TensorFlow.js. Used in [Node Clinic](https://clinicjs.org/blog/clinic-doctor-just-got-more-advanced-with-tensorflow-js/) -- [Emotion Extractor](https://brendansudol.com/faces/) by Brendan Sudol -- [Aida](https://aida.dor.ai/) Named entity recognition and text classification pipeline for creating chatbots by Rodrigo Pimentel -- [GAN Lab](https://poloclub.github.io/ganlab/) - An Interactive Visualization Tool for Playing with Generative Adversarial Networks (GANs)! -- [Canvas Friends](https://www.y8.com/games/canvas_friends) - Half game, half experiment to see if software can improve the drawing and artistic skills of people. -- [High School Level Tensorflowjs](http://rocksetta.com/tensorflowjs/) - Greater than 40 demos that can be online edited made as simply as possible using single web pages. All examples use the [ - - - - - - - - - -``` - -Open up that HTML file in your browser, and the code should run! - -### via NPM - -Add TensorFlow.js to your project using yarn or npm. Note: Because -we use ES2017 syntax (such as `import`), this workflow assumes you are using a modern browser or a bundler/transpiler -to convert your code to something older browsers understand. See our -examples -to see how we use Parcel to build -our code. However, you are free to use any build tool that you prefer. - - - -```js -import * as tf from '@tensorflow/tfjs'; - -// Define a model for linear regression. -const model = tf.sequential(); -model.add(tf.layers.dense({units: 1, inputShape: [1]})); - -// Prepare the model for training: Specify the loss and the optimizer. -model.compile({loss: 'meanSquaredError', optimizer: 'sgd'}); - -// Generate some synthetic data for training. -const xs = tf.tensor2d([1, 2, 3, 4], [4, 1]); -const ys = tf.tensor2d([1, 3, 5, 7], [4, 1]); - -// Train the model using the data. -model.fit(xs, ys).then(() => { - // Use the model to do inference on a data point the model hasn't seen before: - model.predict(tf.tensor2d([5], [1, 1])).print(); -}); -``` - -See our tutorials, examples -and documentation for more details. - -## Importing pre-trained models - -We support porting pre-trained models from: -- [TensorFlow SavedModel](https://www.tensorflow.org/js/tutorials/conversion/import_saved_model) -- [Keras](https://js.tensorflow.org/tutorials/import-keras.html) - -## Various ops supported in different backends - -Please refer below : -- [TFJS Ops Matrix](https://docs.google.com/spreadsheets/d/1D25XtWaBrmUEErbGQB0QmNhH-xtwHo9LDl59w0TbxrI/edit#gid=0) - -## Find out more - -[TensorFlow.js](https://js.tensorflow.org) is a part of the -[TensorFlow](https://www.tensorflow.org) ecosystem. For more info: -- For help from the community, use the `tfjs` tag on the [TensorFlow Forum](https://discuss.tensorflow.org/tag/tfjs). -- [TensorFlow.js Website](https://js.tensorflow.org) -- [Tutorials](https://js.tensorflow.org/tutorials) -- [API reference](https://js.tensorflow.org/api/latest/) -- [TensorFlow.js Blog](https://blog.tensorflow.org/search?label=TensorFlow.js) - -Thanks, BrowserStack, for providing testing support. diff --git a/tfjs-master/WORKSPACE b/tfjs-master/WORKSPACE deleted file mode 100644 index 02d1d98a8..000000000 --- a/tfjs-master/WORKSPACE +++ /dev/null @@ -1,264 +0,0 @@ -# Copyright 2021 Google LLC. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================= - -workspace( - name = "tfjs", - managed_directories = { - "@npm": ["node_modules"], - }, -) - -load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") - -http_archive( - name = "bazel_skylib", - sha256 = "1c531376ac7e5a180e0237938a2536de0c54d93f5c278634818e0efc952dd56c", - urls = [ - "https://github.com/bazelbuild/bazel-skylib/releases/download/1.0.3/bazel-skylib-1.0.3.tar.gz", - "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.0.3/bazel-skylib-1.0.3.tar.gz", - ], -) - -load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace") - -bazel_skylib_workspace() - -http_archive( - name = "build_bazel_rules_nodejs", - sha256 = "94070eff79305be05b7699207fbac5d2608054dd53e6109f7d00d923919ff45a", - urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/5.8.2/rules_nodejs-5.8.2.tar.gz"], -) - -# Install rules_nodejs dependencies. -load("@build_bazel_rules_nodejs//:repositories.bzl", "build_bazel_rules_nodejs_dependencies") - -build_bazel_rules_nodejs_dependencies() - -load("@rules_nodejs//nodejs:repositories.bzl", "nodejs_register_toolchains") - -nodejs_register_toolchains( - name = "nodejs", - node_version = "18.13.0", -) - -# Install the yarn tool -load("@rules_nodejs//nodejs:yarn_repositories.bzl", "yarn_repositories") - -yarn_repositories( - name = "yarn", - node_repository = "nodejs", -) - -# Install yarn packages -load("@build_bazel_rules_nodejs//:index.bzl", "yarn_install") - -yarn_install( - name = "npm", - exports_directories_only = False, # Required for ts_library - package_json = "//:package.json", - package_path = "/", - symlink_node_modules = True, - yarn = "@yarn//:bin/yarn", - yarn_lock = "//:yarn.lock", -) - -# Fetch transitive Bazel dependencies of karma_web_test -http_archive( - name = "io_bazel_rules_webtesting", - sha256 = "9bb461d5ef08e850025480bab185fd269242d4e533bca75bfb748001ceb343c3", - urls = ["https://github.com/bazelbuild/rules_webtesting/releases/download/0.3.3/rules_webtesting.tar.gz"], -) - -# Set up web testing, choose browsers we can test on -load("@io_bazel_rules_webtesting//web:repositories.bzl", "web_test_repositories") - -web_test_repositories() - -load("@io_bazel_rules_webtesting//web/versioned:browsers-0.3.2.bzl", "browser_repositories") - -browser_repositories( - chromium = True, -) - -# Esbuild toolchain -load("@build_bazel_rules_nodejs//toolchains/esbuild:esbuild_repositories.bzl", "esbuild_repositories") - -esbuild_repositories(npm_repository = "npm") - -# Emscripten toolchain -http_archive( - name = "emsdk", - # TODO: Remove repo_mapping when emsdk updates to rules_nodejs 5 - repo_mapping = {"@nodejs": "@nodejs_host"}, - sha256 = "b8270749b99d8d14922d1831b93781a5560fba6f7bce65cd477fc1b6aa262535", - strip_prefix = "emsdk-3.1.28/bazel", - urls = ["https://github.com/emscripten-core/emsdk/archive/refs/tags/3.1.28.tar.gz"], -) - -load("@emsdk//:deps.bzl", emsdk_deps = "deps") - -emsdk_deps() - -load("@emsdk//:emscripten_deps.bzl", emsdk_emscripten_deps = "emscripten_deps") - -emsdk_emscripten_deps() - -load("@emsdk//:toolchains.bzl", "register_emscripten_toolchains") - -register_emscripten_toolchains() - -load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") - -# xnnpack used for fast vectorized wasm operations -git_repository( - name = "xnnpack", - commit = "5e8033a72a8d0f1c2b1f06e29137cc697c6b661d", - remote = "https://github.com/google/XNNPACK.git", - shallow_since = "1643627844 -0800", -) - -# The libraries below are transitive dependencies of XNNPACK that we need to -# explicitly enumerate here. See https://docs.bazel.build/versions/master/external.html#transitive-dependencies - -# FP16 library, used for half-precision conversions -http_archive( - name = "FP16", - build_file = "@xnnpack//third_party:FP16.BUILD", - sha256 = "0d56bb92f649ec294dbccb13e04865e3c82933b6f6735d1d7145de45da700156", - strip_prefix = "FP16-3c54eacb74f6f5e39077300c5564156c424d77ba", - urls = [ - "https://github.com/Maratyszcza/FP16/archive/3c54eacb74f6f5e39077300c5564156c424d77ba.zip", - ], -) - -# FXdiv library, used for repeated integer division by the same factor -http_archive( - name = "FXdiv", - sha256 = "ab7dfb08829bee33dca38405d647868fb214ac685e379ec7ef2bebcd234cd44d", - strip_prefix = "FXdiv-b408327ac2a15ec3e43352421954f5b1967701d1", - urls = [ - "https://github.com/Maratyszcza/FXdiv/archive/b408327ac2a15ec3e43352421954f5b1967701d1.zip", - ], -) - -# pthreadpool library, used for parallelization -http_archive( - name = "pthreadpool", - sha256 = "8461f6540ae9f777ce20d1c0d1d249e5e61c438744fb390c0c6f91940aa69ea3", - strip_prefix = "pthreadpool-545ebe9f225aec6dca49109516fac02e973a3de2", - urls = [ - "https://github.com/Maratyszcza/pthreadpool/archive/545ebe9f225aec6dca49109516fac02e973a3de2.zip", - ], -) - -# clog library, used for logging -http_archive( - name = "clog", - build_file = "@xnnpack//third_party:clog.BUILD", - sha256 = "3f2dc1970f397a0e59db72f9fca6ff144b216895c1d606f6c94a507c1e53a025", - strip_prefix = "cpuinfo-d5e37adf1406cf899d7d9ec1d317c47506ccb970", - urls = [ - "https://github.com/pytorch/cpuinfo/archive/d5e37adf1406cf899d7d9ec1d317c47506ccb970.tar.gz", - ], -) - -# cpuinfo library, used for detecting processor characteristics -http_archive( - name = "cpuinfo", - build_file = "@xnnpack//third_party:cpuinfo.BUILD", - patches = ["@xnnpack//third_party:cpuinfo.patch"], - sha256 = "a7f9a188148a1660149878f737f42783e72f33a4f842f3e362fee2c981613e53", - strip_prefix = "cpuinfo-ed8b86a253800bafdb7b25c5c399f91bff9cb1f3", - urls = [ - "https://github.com/pytorch/cpuinfo/archive/ed8b86a253800bafdb7b25c5c399f91bff9cb1f3.zip", - ], -) - -# psimd library, used for fallback 128-bit SIMD micro-kernels -http_archive( - name = "psimd", - build_file = "@xnnpack//third_party:psimd.BUILD", - sha256 = "dc615342bcbe51ca885323e51b68b90ed9bb9fa7df0f4419dbfa0297d5e837b7", - strip_prefix = "psimd-072586a71b55b7f8c584153d223e95687148a900", - urls = [ - "https://github.com/Maratyszcza/psimd/archive/072586a71b55b7f8c584153d223e95687148a900.zip", - ], -) - -git_repository( - name = "com_google_googletest", - commit = "cd17fa2abda2a2e4111cdabd62a87aea16835014", - remote = "https://github.com/google/googletest.git", - shallow_since = "1570558426 -0400", -) - -http_archive( - name = "rules_cc", - sha256 = "90d5a66950b492cbf86201cdc49c4b59796a85a4eb9fd63c07afe5f7132ea623", - strip_prefix = "rules_cc-8346df34b6593b051403b8e429db15c7f4ead937", - urls = [ - "https://github.com/bazelbuild/rules_cc/archive/8346df34b6593b051403b8e429db15c7f4ead937.zip", - ], -) - -http_archive( - name = "rules_python", - sha256 = "29a801171f7ca190c543406f9894abf2d483c206e14d6acbd695623662320097", - strip_prefix = "rules_python-0.18.1", - url = "https://github.com/bazelbuild/rules_python/releases/download/0.18.1/rules_python-0.18.1.tar.gz", -) - -load("@rules_python//python:repositories.bzl", "python_register_toolchains") - -# TODO(mattSoulanille): Change the docker so it doesn't run as root? -# https://github.com/bazelbuild/rules_python/pull/713 -# https://github.com/GoogleCloudPlatform/cloud-builders/issues/641 -python_register_toolchains( - name = "python3_8", - ignore_root_user_error = True, - # Available versions are listed in @rules_python//python:versions.bzl. - python_version = "3.8", -) - -load("@python3_8//:defs.bzl", "interpreter") -load("@rules_python//python:pip.bzl", "pip_parse") - -pip_parse( - name = "tensorflowjs_deps", - python_interpreter_target = interpreter, - requirements_lock = "@//tfjs-converter/python:requirements_lock.txt", -) - -load("@tensorflowjs_deps//:requirements.bzl", install_tfjs_deps = "install_deps") - -install_tfjs_deps() - -pip_parse( - name = "tensorflowjs_dev_deps", - python_interpreter_target = interpreter, - requirements_lock = "@//tfjs-converter/python:requirements-dev_lock.txt", -) - -load("@tensorflowjs_dev_deps//:requirements.bzl", install_tfjs_dev_deps = "install_deps") - -install_tfjs_dev_deps() - -load("//tfjs-tflite:tflite_repositories.bzl", "tflite_repositories") - -tflite_repositories() - -load("//tfjs-tfdf:tfdf_repositories.bzl", "tfdf_repositories") - -tfdf_repositories() diff --git a/tfjs-master/cloudbuild-release.yml b/tfjs-master/cloudbuild-release.yml deleted file mode 100644 index 89b4e24b9..000000000 --- a/tfjs-master/cloudbuild-release.yml +++ /dev/null @@ -1,29 +0,0 @@ -steps: - -# Install top-level deps. -- name: 'gcr.io/learnjs-174218/release' - entrypoint: 'yarn' - id: 'yarn-common' - args: ['install'] - -# Release e2e flow. -- name: 'gcr.io/learnjs-174218/release' - dir: 'e2e' - entrypoint: 'bash' - id: 'verdaccio' - args: ['./scripts/release-e2e.sh'] - env: ['BROWSERSTACK_USERNAME=deeplearnjs1', 'RELEASE=$_RELEASE'] - secretEnv: ['BROWSERSTACK_KEY'] - -secrets: -- kmsKeyName: projects/learnjs-174218/locations/global/keyRings/tfjs/cryptoKeys/enc - secretEnv: - BROWSERSTACK_KEY: CiQAkwyoIW0LcnxymzotLwaH4udVTQFBEN4AEA5CA+a3+yflL2ASPQAD8BdZnGARf78MhH5T9rQqyz9HNODwVjVIj64CTkFlUCGrP1B2HX9LXHWHLmtKutEGTeFFX9XhuBzNExA= -timeout: 7200s -logsBucket: 'gs://tfjs-build-logs' -substitutions: - _RELEASE: '' -options: - logStreamingOption: 'STREAM_ON' - machineType: 'N1_HIGHCPU_32' - substitution_option: 'ALLOW_LOOSE' diff --git a/tfjs-master/cloudbuild-verdaccio.yml b/tfjs-master/cloudbuild-verdaccio.yml deleted file mode 100644 index b95c7123c..000000000 --- a/tfjs-master/cloudbuild-verdaccio.yml +++ /dev/null @@ -1,35 +0,0 @@ -steps: -# Install top-level deps. -- name: 'gcr.io/learnjs-174218/release' - entrypoint: 'yarn' - id: 'yarn-common' - args: ['install'] - -# Run verdaccio nightly publishing tests. -- name: 'gcr.io/learnjs-174218/release' - entrypoint: 'bash' - id: 'nightly-verdaccio-test' - env: ['BROWSERSTACK_USERNAME=deeplearnjs1', 'RELEASE=true'] - secretEnv: ['BROWSERSTACK_KEY'] - waitFor: ['yarn-common'] - args: - - '-eEuo' - - 'pipefail' - - '-c' - - |- - yarn release-tfjs --dry --guess-version release --use-local-changes --force - cd /tmp/tfjs-release/tfjs/e2e/ - bash scripts/release-e2e.sh - -secrets: -- kmsKeyName: projects/learnjs-174218/locations/global/keyRings/tfjs/cryptoKeys/enc - secretEnv: - BROWSERSTACK_KEY: CiQAkwyoIW0LcnxymzotLwaH4udVTQFBEN4AEA5CA+a3+yflL2ASPQAD8BdZnGARf78MhH5T9rQqyz9HNODwVjVIj64CTkFlUCGrP1B2HX9LXHWHLmtKutEGTeFFX9XhuBzNExA= -timeout: 7200s -logsBucket: 'gs://tfjs-build-logs' -substitutions: - _NIGHTLY: '' -options: - logStreamingOption: 'STREAM_ON' - machineType: 'N1_HIGHCPU_32' - substitution_option: 'ALLOW_LOOSE' diff --git a/tfjs-master/cloudbuild.yml b/tfjs-master/cloudbuild.yml deleted file mode 100644 index a366c3834..000000000 --- a/tfjs-master/cloudbuild.yml +++ /dev/null @@ -1,34 +0,0 @@ -steps: -# Install top-level deps. -- name: 'gcr.io/learnjs-174218/release' - entrypoint: 'yarn' - id: 'yarn' - args: ['install'] - -# Generate cloudbuild_generated.yml, -# which builds and tests all affected packages. -- name: 'gcr.io/learnjs-174218/release' - entrypoint: 'yarn' - id: 'generate-cloudbuild-for-packages' - args: ['generate-cloudbuild-for-packages'] - waitFor: ['yarn'] - env: - - 'COMMIT_SHA=$COMMIT_SHA' - - 'BRANCH_NAME=$BRANCH_NAME' - - 'BASE_BRANCH=$_BASE_BRANCH' - - 'NIGHTLY=$_NIGHTLY' - -# Run the generated cloudbuild file -- name: 'gcr.io/cloud-builders/gcloud' - entrypoint: 'bash' - id: 'run-cloudbuild' - args: ['./scripts/run-build.sh'] - waitFor: ['generate-cloudbuild-for-packages'] - env: ['NIGHTLY=$_NIGHTLY'] - -# General settings. -timeout: 7200s -logsBucket: 'gs://tfjs-build-logs' -options: - logStreamingOption: 'STREAM_ON' - substitution_option: 'ALLOW_LOOSE' diff --git a/tfjs-master/dockers/release-docker/Dockerfile b/tfjs-master/dockers/release-docker/Dockerfile deleted file mode 100644 index 3f3efbdff..000000000 --- a/tfjs-master/dockers/release-docker/Dockerfile +++ /dev/null @@ -1,49 +0,0 @@ -FROM node:18.13.0-bullseye-slim - -# Install cloud-sdk -ARG CLOUD_SDK_VERSION=355.0.0 -ENV CLOUD_SDK_VERSION=$CLOUD_SDK_VERSION -ENV CLOUDSDK_PYTHON=python3 -ENV PATH "$PATH:/opt/google-cloud-sdk/bin/" -RUN apt-get update -qqy && apt-get install -qqy \ - curl \ - gcc \ - parallel \ - python \ - python-dev \ - python3 \ - python3-setuptools \ - python3-dev \ - python3-pip \ - apt-transport-https \ - lsb-release \ - openssh-client \ - git \ - gnupg \ - file \ - wget \ - unzip \ - libssl-dev \ - libffi-dev \ - zlib1g-dev \ - procps && \ - pip3 install -U crcmod && \ - export CLOUD_SDK_REPO="cloud-sdk-$(lsb_release -c -s)" && \ - echo "deb https://packages.cloud.google.com/apt $CLOUD_SDK_REPO main" > /etc/apt/sources.list.d/google-cloud-sdk.list && \ - curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - && \ - apt-get update && apt-get install -y google-cloud-sdk=${CLOUD_SDK_VERSION}-0 && \ - gcloud config set core/disable_usage_reporting true && \ - gcloud config set component_manager/disable_update_check true && \ - gcloud config set metrics/environment github_docker_image && \ - gcloud --version - -RUN git config --system credential.'https://source.developers.google.com'.helper gcloud.sh - -VOLUME ["/root/.config"] - -# Install virtualenv -RUN pip3 install virtualenv - -# Install absl -RUN pip3 install absl-py - diff --git a/tfjs-master/dockers/wasm-docker/Dockerfile b/tfjs-master/dockers/wasm-docker/Dockerfile deleted file mode 100644 index 3881adae3..000000000 --- a/tfjs-master/dockers/wasm-docker/Dockerfile +++ /dev/null @@ -1,16 +0,0 @@ - # Official emsdk docker: https://hub.docker.com/r/emscripten/emsdk -FROM emscripten/emsdk:2.0.14 - -# Install yarn -RUN npm install -g yarn - -RUN apt-get update -qqy && apt-get install -qqy \ - gcc \ - python3 \ - python3-pip \ - python \ - python-pip \ - file - -# Install absl -RUN pip3 install -U absl-py diff --git a/tfjs-master/docs/OPTIMIZATION_PURE_GPU_PIPELINE.md b/tfjs-master/docs/OPTIMIZATION_PURE_GPU_PIPELINE.md deleted file mode 100644 index a17e6e91a..000000000 --- a/tfjs-master/docs/OPTIMIZATION_PURE_GPU_PIPELINE.md +++ /dev/null @@ -1,97 +0,0 @@ -# Optimization Topic - How to write a high performance GPU pipeline -This document shows how to write a high performance GPU pipeline with TF.js. A typical ML pipeline is composed of some ML steps (e.g. taking some inputs, running a model and getting outputs) and non-ML steps (e.g. image processing, rendering, etc.). General rule of thumb is that if the whole pipeline can run on GPU without downloading any data to CPU, it is usually much faster than a fragmented pipeline that requires data transfer between CPU and GPU. This additional time for GPU to CPU and CPU to GPU sync adds to the pipeline latency. - -In the latest TF.js release (version 3.13.0), we provide a new tensor -API that allows data to stay in GPU. Our users are pretty faimilar with -`tensor.dataSync()` and `tensor.data()`, however both will download data from GPU to CPU. In the latest release, we have added `tensor.dataToGPU()`, -which returns a `GPUData` type. - -# For webgl backend -The example below shows how to get the tensor texture by calling -`dataToGPU`. Also see this [example code](https://github.com/tensorflow/tfjs-examples/tree/master/gpu-pipeline/webgl) for details. - -```javascript -// Getting the texture that holds the data on GPU. -// data has below fields: -// {texture, texShape, tensorRef} -// texture: A WebGLTexture. -// texShape: the [height, width] of the texture. -// tensorRef: the tensor associated with the texture. -// -// Here the tensor has a shape of [1, videoHeight, videoWidth, 4], -// which represents an image. In this case, we can specify the texture -// to use the image's shape as its shape. -const data = - tensor.dataToGPU({customTexShape: [videoHeight, videoWidth]}); - -// Once we have the texture, we can bind it and pass it to the downstream -// webgl processing steps to use the texture. -gl.bindTexture(gl.TEXTURE_2D, data.texture); - -// Some webgl processing steps. - -// Once all the processing is done, we can render the result on the canvas. -gl.blitFramebuffer(0, 0, videoWidth, videoHeight, 0, videoHeight, videoWidth, 0, gl.COLOR_BUFFER_BIT, gl.LINEAR); - -// Remember to dispose the texture after use, otherwise, there will be -// memory leak. -data.tensorRef.dispose(); -``` - -The texture from `dataToGPU()` has a specific format. The data is densely -packed, meaning all four channels (r, g, b, a) in a texel is used to store -data. This is how the texture with tensor shape = [2, 3, 4] looks like: - -``` - 000|001|002|003 010|011|012|013 020|021|022|023 - - 100|101|102|103 110|111|112|113 120|121|122|123 -``` - -So if a tensor's shape is `[1, height, width, 4]` or `[height, width, 4]`, the way we store the data aligns with how image is stored, therefore if the -downstream processing assumes the texture is an image, it doesn't need to -do any additional coordination conversion. Each texel is mapped to a [CSS pixel](https://developer.mozilla.org/en-US/docs/Glossary/CSS_pixel) in an image. However, if the tensor has other shapes, downstream -processing steps may need to reformat the data onto another texture. The `texShape` field has the `[height, width]` information of the texture, which can be used for transformation. - -# For webgpu backend -The example below shows how to get the tensor buffer by calling -`dataToGPU`. Also see this [example code](https://github.com/tensorflow/tfjs-examples/tree/master/gpu-pipeline/webgpu) for details. - -```javascript -// Getting the buffer that holds the data on GPU. -// data has below fields: -// {buffer, bufSize, tensorRef} -// buffer: A GPUBuffer. -// bufSize: the size of the buffer. -// tensorRef: the tensor associated with the buffer. -// -// Unlike webgl backend, There is no parameter for dataToGPU API on the webgpu -// backend, and the size of returned buffer is the same as the tensor size. -const data = tensor.dataToGPU(); - -// Once we have the buffer, we can bind it and pass it to the downstream -// webgpu processing steps to use the buffer. -const uniformBindGroup = device.createBindGroup({ - layout: pipeline.getBindGroupLayout(0), - entries: [ - { - binding: 1, - resource: { - buffer: data.buffer, - }, - }, - ... - ], -}); - -// Some webgpu processing steps. - -// Defines the mapping between resources of all GPUBindGroup objects -passEncoder.setBindGroup(0, uniformBindGroup); - -// Some webgpu processing steps. - -// Remember to dispose the buffer after use, otherwise, there will be -// memory leak. -data.tensorRef.dispose(); -``` diff --git a/tfjs-master/e2e/.npmignore b/tfjs-master/e2e/.npmignore deleted file mode 100644 index 6292b5fdb..000000000 --- a/tfjs-master/e2e/.npmignore +++ /dev/null @@ -1,27 +0,0 @@ -.babelrc -.DS_Store -.idea/ -.rpt2_cache -.travis.yml -.vscode -*.tgz -*.txt -**.yalc -**yalc.lock -cloudbuild.yml -coverage/ -demo/ -dist/**/*_test.d.ts -dist/**/*_test.js -karma.conf.js -node_modules/ -npm-debug.log -package-lock.json -package/ -rollup.config.js -scripts/ -src/**/*_test.ts -tsconfig.json -tslint.json -yarn-error.log -yarn.lock diff --git a/tfjs-master/e2e/.npmrc b/tfjs-master/e2e/.npmrc deleted file mode 100644 index 43c97e719..000000000 --- a/tfjs-master/e2e/.npmrc +++ /dev/null @@ -1 +0,0 @@ -package-lock=false diff --git a/tfjs-master/e2e/README.md b/tfjs-master/e2e/README.md deleted file mode 100644 index ac838c205..000000000 --- a/tfjs-master/e2e/README.md +++ /dev/null @@ -1,38 +0,0 @@ -# Usage - -This package contains integration and e2e tests for TensorFlow.js. - -## To run the tests in local: - -### Filter tests by tag: - -```js -export TAGS=#SMOKE,#REGRESSION,#GOLDEN -yarn test -``` - -### Filter tests by grep: - -```js -yarn test --grep cpu -``` - -## Add new tests: - -When creating new test, add at least one tag to the test description. - -Supported tags: - -- **SMOKE**: - Smoke tests should be light weight. Run in every PR and nightly - builds. Criteria for smoke test is that the test should run fast and only - test critical CUJ. -- **REGRESSION**: - Regression tests compare results across backends, previous - builds, with other platform, etc. Run in nightly builds. Need additional - steps to run in local. -- **GOLDEN**: - Golden tests validate pretrained model outputs against the prebuilt golden - outputs. Need additional steps to run in local. - -To add a new tag: Extend the TAGS list in integration_tests/util diff --git a/tfjs-master/e2e/benchmarks/SpecRunner.html b/tfjs-master/e2e/benchmarks/SpecRunner.html deleted file mode 100644 index 8e1dc4fbf..000000000 --- a/tfjs-master/e2e/benchmarks/SpecRunner.html +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - Jasmine Test - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tfjs-master/e2e/benchmarks/benchmark_util.js b/tfjs-master/e2e/benchmarks/benchmark_util.js deleted file mode 100644 index d6a9d249d..000000000 --- a/tfjs-master/e2e/benchmarks/benchmark_util.js +++ /dev/null @@ -1,708 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -/** - * This tool depends on tf-core, tf-layers, tf-converter and the backends - * (tf-backend-cpu, tf-backend-webgl or tf-backend-wasm) that you would use. - */ - -/** - * Generates a random input for `model`, based on `model.inputs`. For - * tf.GraphModel, `NamedTensorMap` input will be returned; otherwise, - * `Tensor[]` will be returned. - * - * ```js - * const model = tf.sequential( - * {layers: [tf.layers.dense({units: 1, inputShape: [3]})]}); - * const input = generateInput(model); - * const prediction = await model.predict(input); - * - * console.log(`Generated input: ${Object.values(input)}`); - * console.log(`Prediction for the generated input: ${prediction}`); - * ``` - * - * @param model The model object that is used to generated the input. - */ -function generateInput(model) { - if (model == null) { - throw new Error('The model does not exist.'); - } else if (model.inputs == null) { - throw new Error('The model.inputs cannot be found.'); - } - - const inputDefs = model.inputs.map((inputNode, inputNodeIndex) => { - // Replace -1 or null in input tensor shape. - const inputShape = inputNode.shape.map(shapeValue => { - if (shapeValue == null || shapeValue < 0) { - return 1; - } else { - return shapeValue; - } - }); - return { - shape: inputShape, - name: inputNode.name, - dtype: inputNode.dtype, - range: [0, 1000] - }; - }); - - return generateInputFromDef(inputDefs, model instanceof tf.GraphModel); -} - -/** - * Generates a random input for input definition. - * - * ```js - * const input = generateInput(inputDefs); - * - * console.log(`Generated input: ${Object.values(input)}`); - * console.log(`Prediction for the generated input: ${prediction}`); - * ``` - * - * @param inputDefs The input definition that is used to generate the input. - * @param isForGraphModel flag for whether to generate inputs for GraphModel - */ -function generateInputFromDef(inputDefs, isForGraphModel = false) { - if (inputDefs == null) { - throw new Error('The inputDef cannot be found.'); - } - - const tensorArray = []; - try { - inputDefs.forEach((inputDef, inputDefIndex) => { - const inputShape = inputDef.shape; - - // Construct the input tensor. - let inputTensor; - if (inputDef.dtype === 'float32' || inputDef.dtype === 'int32') { - // We assume a bell curve normal distribution. In this case, - // we use below approximation: - // mean ~= (min + max) / 2 - // std ~= (max - min) / 4 - // Note: for std, our approximation is based on the fact that - // 95% of the data is within the range of 2 stds above and - // below the mean. So 95% of the data falls in the range of - // 4 stds. - const min = inputDef.range[0]; - const max = inputDef.range[1]; - const mean = (min + max) / 2; - const std = (max - min) / 4; - generatedRaw = tf.randomNormal(inputShape, mean, std, inputDef.dtype); - // We clip the value to be within [min, max], because 5% of - // the data generated maybe outside of [min, max]. - inputTensor = tf.clipByValue(generatedRaw, min, max); - generatedRaw.dispose(); - } else if (inputDef.dtype === 'string') { - size = tf.util.sizeFromShape(inputDef.shape); - data = [...Array(size)].map( - () => Math.random().toString(36).substring(2, 7)); - inputTensor = tf.tensor(data, inputShape, inputDef.dtype); - } else { - throw new Error( - `The ${inputDef.dtype} dtype of '${inputDef.name}' input ` + - `at model.inputs[${inputDefIndex}] is not supported.`); - } - tensorArray.push(inputTensor); - }); - - // Return tensor map for tf.GraphModel. - if (isForGraphModel) { - const tensorMap = inputDefs.reduce((map, inputDef, i) => { - map[inputDef.name] = tensorArray[i]; - return map; - }, {}); - return tensorMap; - } - - return tensorArray; - } catch (e) { - // Dispose all input tensors when the input construction is failed. - tensorArray.forEach(tensor => { - if (tensor instanceof tf.Tensor) { - tensor.dispose(); - } - }); - throw e; - } -} - -/** - * Wrap the model's predict function (`model.predict` for tf.LayersModel - * and `model.executeAsync` for tf.GraphModel) with the input. - * - * @param model An instance of tf.GraphModel or tf.LayersModel for finding and - * wrapping the predict function. - * @param input The input tensor container for model inference. - */ -function getPredictFnForModel(model, input) { - let predict; - if (model instanceof tf.GraphModel) { - // Because there's no straightforward way to analyze whether a graph has - // dynamic op, so we try to use `execute` and, if it fails, we will fall - // back to `executeAsync`. - try { - tf.tidy(() => { - model.execute(input); - }); - predict = () => model.execute(input); - } catch (e) { - predict = async () => await model.executeAsync(input); - } - } else if (model instanceof tf.LayersModel) { - predict = () => model.predict(input); - } else { - throw new Error( - 'Predict function was not found. Please provide a tf.GraphModel or ' + - 'tf.LayersModel'); - } - return predict; -} - -/** - * Executes the predict function for `model` (`model.predict` for tf.LayersModel - * and `model.executeAsync` for tf.GraphModel) and times the inference process - * for `numRuns` rounds. Then returns a promise that resolves with information - * about the model's inference time: - * - `times`: an array of inference time for each inference - * - `averageTime`: the average time of all inferences - * - `averageTimeExclFirst`: the average time of all inferences except the - * first. - * - `minTime`: the minimum time of all inferences - * - `maxTime`: the maximum time of all inferences - * - * The inference time contains the time spent by both `predict()` and `data()` - * called by tensors in the prediction. - * - * ```js - * const modelUrl = - * 'https://tfhub.dev/google/imagenet/mobilenet_v2_140_224/classification/2'; - * const model = await tf.loadGraphModel(modelUrl, {fromTFHub: true}); - * const zeros = tf.zeros([1, 224, 224, 3]); - * const timeInfo = - * await timeModelInference(model, zeros, 2); - * - * console.log(`Elapsed time array: ${timeInfo.times}`); - * console.log(`Average time: ${timeInfo.averageTime}`); - * console.log(`Minimum time: ${timeInfo.minTime}`); - * console.log(`Maximum time: ${timeInfo.maxTime}`); - * ``` - * - * @param model An instance of tf.GraphModel or tf.LayersModel for timing the - * inference process. - * @param input The input tensor container for model inference. - * @param numRuns The number of rounds for timing the inference process. - */ -async function timeModelInference(model, input, numRuns = 1) { - const predict = getPredictFnForModel(model, input); - return timeInference(predict, numRuns); -} - -/** - * Executes `predict()` and times the inference process for `numRuns` rounds. - * Then returns a promise that resolves with information about the inference - * time: - * - `times`: an array of inference time for each inference - * - `averageTime`: the average time of all inferences - * - `averageTimeExclFirst`: the average time of all inferences except the - * first. - * - `minTime`: the minimum time of all inferences - * - `maxTime`: the maximum time of all inferences - * - * The inference time contains the time spent by both `predict()` and `data()` - * called by tensors in the prediction. - * - * ```js - * const modelUrl = - * 'https://tfhub.dev/google/imagenet/mobilenet_v2_140_224/classification/2'; - * const model = await tf.loadGraphModel(modelUrl, {fromTFHub: true}); - * const zeros = tf.zeros([1, 224, 224, 3]); - * const timeInfo = - * await timeInference(() => model.predict(zeros), 2); - * - * console.log(`Elapsed time array: ${timeInfo.times}`); - * console.log(`Average time: ${timeInfo.averageTime}`); - * console.log(`Minimum time: ${timeInfo.minTime}`); - * console.log(`Maximum time: ${timeInfo.maxTime}`); - * ``` - * - * @param predict The predict function to execute and time. - * @param numRuns The number of rounds for `predict` to execute and time. - */ -async function timeInference(predict, numRuns = 1) { - if (typeof predict !== 'function') { - throw new Error( - 'The first parameter should be a function, while ' + - `a(n) ${typeof predict} is found.`); - } - - const times = []; - for (let i = 0; i < numRuns; i++) { - const start = performance.now(); - const res = await predict(); - // Prediction from tflite backend generates in the worker thread, - // we don't post the result back to main thread to avoid unnecessary - // overhead in transferring between worker and main thread. - if (!isTflite()) { - // The prediction can be tf.Tensor|tf.Tensor[]|{[name: string]: - // tf.Tensor}. - const value = await downloadValuesFromTensorContainer(res); - } - const elapsedTime = performance.now() - start; - - tf.dispose(res); - times.push(elapsedTime); - } - - const averageTime = times.reduce((acc, curr) => acc + curr, 0) / times.length; - const averageTimeExclFirst = times.length > 1 ? - times.slice(1).reduce((acc, curr) => acc + curr, 0) / (times.length - 1) : - 'NA'; - const minTime = Math.min(...times); - const maxTime = Math.max(...times); - const timeInfo = { - times, - averageTime, - averageTimeExclFirst, - minTime, - maxTime - - }; - return timeInfo; -} - -/** - * Time one model inference with parallel compilation feature, based on the - * current backend. - * - * The inference time contains the time spent by both `predict()` and `data()` - * called by tensors in the prediction. - * - * ```js - * // Benchmark the first infernece time with parallel compilation. - * const modelUrl = - * 'https://tfhub.dev/google/imagenet/mobilenet_v2_140_224/classification/2'; - * const model = await tf.loadGraphModel(modelUrl, {fromTFHub: true}); - * const zeros = tf.zeros([1, 224, 224, 3]); - * const firstInferenceTime = - * await timeFirstInference(() => model.predict(zeros), true); - * ``` - * - * @param predict The predict function to execute and time for. - * @param parallelCompile The boolean value to indicate whether to use parallel - * compilation. This currently only has effect for WebGL backend and WebGPU - * backend. - */ -async function timeFirstInference(predict, parallelCompile = false) { - const start = performance.now(); - - // Parallel Compile - if (parallelCompile && tf.getBackend() === 'webgl') { - tf.env().set('ENGINE_COMPILE_ONLY', true); - const compileRes = predict(); - tf.env().set('ENGINE_COMPILE_ONLY', false); - await tf.backend().checkCompileCompletionAsync(); - tf.backend().getUniformLocations(); - tf.dispose(compileRes); - } else if (parallelCompile && tf.getBackend() === 'webgpu') { - tf.env().set('WEBGPU_ENGINE_COMPILE_ONLY', true); - const compileRes = predict(); - tf.env().set('WEBGPU_ENGINE_COMPILE_ONLY', false); - await tf.backend().checkCompileCompletionAsync(); - tf.dispose(compileRes); - } else if (parallelCompile && isTflite()) { - throw new Error('Parallel Compilation for TFlite is not supported.'); - } - - // First inference - let res = predict(); - if (parallelCompile && res instanceof Promise) { - throw new Error( - 'Parallel Compilation for async function is not supported.'); - } - res = await res; - await downloadValuesFromTensorContainer(res); - const elapsedTime = performance.now() - start; - - tf.dispose(res); - return elapsedTime; -} - -/** - * Downloads the values from the `tensorContainer` from any `tf.Tensor`s found - * within the `tensorContainer`. Returns a promise of `TypedArray` or - * `TypedArray[]` that resolves when the computation has finished. - * - * The values are asynchronously downloaded in parallel. - * - * @param tensorContainer The container of tensors to be downloaded. - */ -async function downloadValuesFromTensorContainer(tensorContainer) { - let valueContainer; - const readSync = tf.getBackend() === 'webgl'; - if (tensorContainer instanceof tf.Tensor) { - if (readSync) { - valueContainer = tensorContainer.dataSync(); - } else { - valueContainer = await tensorContainer.data(); - } - } else if (Array.isArray(tensorContainer)) { - // Start value downloads from all tensors. - const valuePromiseContainer = tensorContainer.map(async item => { - if (item instanceof tf.Tensor) { - if (readSync) { - return item.dataSync(); - } else { - return item.data(); - } - } - return item; - }); - // Wait until all values are downloaded. - valueContainer = await Promise.all(valuePromiseContainer); - } else if (tensorContainer != null && typeof tensorContainer === 'object') { - const valuePromiseContainer = []; - // Start value downloads from all tensors. - for (const property in tensorContainer) { - if (tensorContainer[property] instanceof tf.Tensor) { - if (readSync) { - valuePromiseContainer.push(tensorContainer[property].dataSync()); - } else { - valuePromiseContainer.push(tensorContainer[property].data()); - } - } else { - valuePromiseContainer.push(tensorContainer[property]); - } - } - // Wait until all values are downloaded. - valueContainer = await Promise.all(valuePromiseContainer); - } - return valueContainer; -} - -/** - * Executes the predict function for `model` (`model.predict` for - * tf.LayersModel and `model.executeAsync` for tf.GraphModel) and returns a - * promise that resolves with information about the memory usage: - * - `newBytes`: the number of new bytes allocated. - * - `newTensors`: the number of new tensors created. - * - `peakBytes`: the peak number of bytes allocated. - * - `kernels`: an array of kernel information objects about their input and - * output shapes, number of bytes used, number of new tensors created and kernel - * time (ms). The array is sorted by `kernelTimeMs` field in non-ascending - * order. - * - `aggregatedKernels`: an array of aggregated kernel information objects with - * `name` and `timeMs` fields. The array is sorted by `timeMs` field in - * non-ascending order. - * - * ```js - * const modelUrl = - * 'https://tfhub.dev/google/imagenet/mobilenet_v2_140_224/classification/2'; - * const model = await tf.loadGraphModel(modelUrl, {fromTFHub: true}); - * const zeros = tf.zeros([1, 224, 224, 3]); - * const profileInfo = await profileModelInference(model, zeros); - * - * console.log(`newBytes: ${profileInfo.newBytes}`); - * console.log(`newTensors: ${profileInfo.newTensors}`); - * console.log(`peakBytes: ${profileInfo.peakBytes}`); - * ``` - * - * @param model An instance of tf.GraphModel or tf.LayersModel for profiling - * memory usage in the inference process. - * @param input The input tensor container for model inference. - * @param numProfiles The number of rounds for profiling the inference process. - */ -async function profileModelInference(model, input, numProfiles = 1) { - const predict = getPredictFnForModel(model, input); - return profileInference(predict, false, numProfiles); -} - -/** - * Executes `predict()` and returns a promise that resolves with information - * about the memory usage: - * - `newBytes`: the number of new bytes allocated. - * - `newTensors`: the number of new tensors created. - * - `peakBytes`: the peak number of bytes allocated. - * - `kernels`: an array of kernel information objects about their input and - * output shapes, number of bytes used, number of new tensors created and kernel - * time (ms). The array is sorted by `kernelTimeMs` field in non-ascending - * order. - * - `aggregatedKernels`: an array of aggregated kernel information objects with - * `name` and `timeMs` fields. The array is sorted by `timeMs` field in - * non-ascending order. - * - * ```js - * const modelUrl = - * 'https://tfhub.dev/google/imagenet/mobilenet_v2_140_224/classification/2'; - * const model = await tf.loadGraphModel(modelUrl, {fromTFHub: true}); - * const zeros = tf.zeros([1, 224, 224, 3]); - * const profileInfo = await profileInference(() => - * model.predict(zeros)); - * - * console.log(`newBytes: ${profileInfo.newBytes}`); - * console.log(`newTensors: ${profileInfo.newTensors}`); - * console.log(`peakBytes: ${profileInfo.peakBytes}`); - * ``` - * - * @param predict The predict function to execute for profiling memory usage. - * @param isTflite Whether a TFLite model is being profiled or not. - * @param numProfiles The number of rounds for `predict` to execute and profile. - */ -async function profileInference(predict, isTflite = false, numProfiles = 1) { - if (typeof predict !== 'function') { - throw new Error( - 'The first parameter should be a function, while ' + - `a(n) ${typeof predict} is found.`); - } - - let kernelInfo = {}; - let kernelInfos = []; - if (isTflite) { - for (let i = 0; i < numProfiles; i++) { - await predict(); - const profileItems = await tfliteModel.getProfilingResults(); - kernelInfo.kernels = profileItems.map(item => { - return { - name: item.nodeType, - kernelTimeMs: item.nodeExecMs, - // TODO: Shapes are not supported yet. - inputShapes: [], - outputShapes: [], - }; - }); - kernelInfos.push(kernelInfo); - } - } else { - for (let i = 0; i < numProfiles; i++) { - kernelInfo = await tf.profile(async () => { - const res = await predict(); - await downloadValuesFromTensorContainer(res); - tf.dispose(res); - }); - kernelInfos.push(kernelInfo); - } - } - for (let i = 0; i < kernelInfos[0].kernels.length; i++) { - let totalTimeMs = 0; - for (let j = 0; j < kernelInfos.length; j++) { - totalTimeMs += kernelInfos[j].kernels[i].kernelTimeMs; - } - kernelInfo.kernels[i].kernelTimeMs = totalTimeMs / kernelInfos.length; - } - kernelInfo.kernels = - kernelInfo.kernels.sort((a, b) => b.kernelTimeMs - a.kernelTimeMs); - kernelInfo.aggregatedKernels = aggregateKernelTime(kernelInfo.kernels); - return kernelInfo; -} - -/** - * Aggregate kernels by name and sort the array in non-ascending order of time. - * Return an array of objects with `name` and `timeMs` fields. - * - * @param {Array} kernels An array of kernel information objects. Each - * object must include `name` (string) and `kernelTimeMs` (number) fields. - */ -function aggregateKernelTime(kernels) { - const aggregatedKernelTime = {}; - kernels.forEach(kernel => { - const oldAggregatedKernelTime = aggregatedKernelTime[kernel.name]; - if (oldAggregatedKernelTime == null) { - aggregatedKernelTime[kernel.name] = kernel.kernelTimeMs; - } else { - aggregatedKernelTime[kernel.name] = - oldAggregatedKernelTime + kernel.kernelTimeMs; - } - }); - - return Object.entries(aggregatedKernelTime) - .map(([name, timeMs]) => ({name, timeMs})) - .sort((a, b) => b.timeMs - a.timeMs); -} - -/** - * This map descripes tunable flags and theior corresponding types. - * - * The flags (keys) in the map satisfy the following two conditions: - * - Is tunable. For example, `IS_BROWSER` and `IS_CHROME` is not tunable, - * because they are fixed when running the scripts. - * - Does not depend on other flags when registering in `ENV.registerFlag()`. - * This rule aims to make the list streamlined, and, since there are - * dependencies between flags, only modifying an independent flag without - * modifying its dependents may cause inconsistency. - * (`WEBGL_RENDER_FLOAT32_CAPABLE` is an exception, because only exposing - * `WEBGL_FORCE_F16_TEXTURES` may confuse users.) - */ -const TUNABLE_FLAG_VALUE_RANGE_MAP = { - WEBGL_VERSION: [1, 2], - WASM_HAS_SIMD_SUPPORT: [true, false], - WASM_HAS_MULTITHREAD_SUPPORT: [true, false], - WEBGL_CPU_FORWARD: [true, false], - WEBGL_PACK: [true, false], - WEBGL_FORCE_F16_TEXTURES: [true, false], - WEBGL_RENDER_FLOAT32_CAPABLE: [true, false], - WEBGL_FLUSH_THRESHOLD: [-1, 0, 0.25, 0.5, 0.75, 1, 1.25, 1.5, 1.75, 2], - WEBGL_PACK_DEPTHWISECONV: [true, false], - CHECK_COMPUTATION_FOR_ERRORS: [true, false], - KEEP_INTERMEDIATE_TENSORS: [true, false], - WEBGL_USE_SHAPES_UNIFORMS: [true, false], - WEBGPU_DEFERRED_SUBMIT_BATCH_SIZE: [1, 5, 10, 15, 20, 25, 30, 35, 40] -}; - -/** - * Set environment flags for testing. - * - * This will first set tunable flags (the keys of `TUNABLE_FLAG_TYPE_MAP`). Then - * set URL parameter flags. If there are overlap, URL parameter flags will - * override tunable flags. - * - * ```js - * const flagConfig = { - * WEBGL_PACK: false, - * }; - * await setEnvFlags(flagConfig); - * - * console.log(tf.env().getBool('WEBGL_PACK')); // false - * console.log(tf.env().getBool('WEBGL_PACK_BINARY_OPERATIONS')); // false - * ``` - * - * @param flagConfig An object to store flag-value pairs. - */ -async function setEnvFlags(flagConfig) { - if (flagConfig == null) { - return true; - } else if (typeof flagConfig !== 'object') { - throw new Error( - `An object is expected, while a(n) ${typeof flagConfig} is found.`); - } - - // Check the validation of flags and values. - for (const flag in flagConfig) { - // TODO: check whether flag can be set as flagConfig[flag]. - if (!(flag in TUNABLE_FLAG_VALUE_RANGE_MAP)) { - throw new Error(`${flag} is not a tunable or valid environment flag.`); - } - if (TUNABLE_FLAG_VALUE_RANGE_MAP[flag].indexOf(flagConfig[flag]) === -1) { - throw new Error( - `${flag} value is expected to be in the range [${ - TUNABLE_FLAG_VALUE_RANGE_MAP[flag]}], while ${flagConfig[flag]}` + - ' is found.'); - } - } - - tf.env().setFlags(flagConfig); - setEnvFlagsFromUrlParameters(); - - // `WASM_HAS_SIMD_SUPPORT` and `WEBGL_VERSION` are also evaluated when - // initializing backends, not only inferring. - // TODO: The following backend rebuild logics can be implemented in `setHook` - // when registering these flags. - if ('WASM_HAS_SIMD_SUPPORT' in flagConfig) { - return await resetBackend('wasm'); - } - - if ('WEBGL_VERSION' in flagConfig) { - return await resetBackend('webgl'); - } -} - -/** - * Set flags from URL. URL should be in the format: - * ?tfjsflags=FLAG1:1,FLAG2:true. - */ -function setEnvFlagsFromUrlParameters() { - const TENSORFLOWJS_FLAGS_PREFIX = 'tfjsflags'; - const urlParams = tf.env().getQueryParams(location.search); - if (TENSORFLOWJS_FLAGS_PREFIX in urlParams) { - const keyValues = urlParams[TENSORFLOWJS_FLAGS_PREFIX].split(','); - keyValues.forEach(keyValue => { - const [key, value] = keyValue.split(':'); - try { - tf.env().set(key, parseValue(value)); - } catch (err) { - console.error(err); - } - }); - } -} - -/** - * Converted a URL parameter to a typed value, such a boolean, number, string. - */ -function parseValue(value) { - const lowerCaseValue = value.toLowerCase(); - if (lowerCaseValue === 'true' || lowerCaseValue === 'false') { - return lowerCaseValue === 'true'; - } else if (`${+ lowerCaseValue}` === lowerCaseValue) { - return +lowerCaseValue; - } else { - return value; - } -} - -/** - * Reset the target backend. - * - * @param backendName The name of the backend to be reset. - */ -async function resetBackend(backendName) { - const ENGINE = tf.engine(); - if (!(backendName in ENGINE.registryFactory)) { - throw new Error(`${backendName} backend is not registed.`); - } - - const currentBackend = tf.getBackend(); - - if (backendName in ENGINE.registry) { - const backendFactory = tf.findBackendFactory(backendName); - tf.removeBackend(backendName); - tf.registerBackend(backendName, backendFactory); - } - - if (currentBackend === backendName) { - const isSuccessful = await tf.setBackend(backendName); - if (!isSuccessful) { - showMsg(`Failed to set backend ${backendName}.`); - return false; - } - } - - return true; -} - -/** - * Get the renderer info from the WebGL backend. - */ -async function getRendererInfo() { - const curBackendName = tf.getBackend(); - let webglRenderer; - try { - let webglBackend = tf.findBackend('webgl'); - if (webglBackend == null) { - if (!(await tf.setBackend('webgl'))) { - throw new Error('Failed to initialize WebGL backend.'); - } - webglBackend = tf.backend(); - } - const gl = webglBackend.gpgpu.gl; - const dbgRenderInfo = gl.getExtension('WEBGL_debug_renderer_info'); - webglRenderer = gl.getParameter(dbgRenderInfo.UNMASKED_RENDERER_WEBGL); - } catch (e) { - webglRenderer = 'NA'; - } - await tf.setBackend(curBackendName); - return webglRenderer; -} diff --git a/tfjs-master/e2e/benchmarks/benchmark_util_test.js b/tfjs-master/e2e/benchmarks/benchmark_util_test.js deleted file mode 100644 index 9074807e1..000000000 --- a/tfjs-master/e2e/benchmarks/benchmark_util_test.js +++ /dev/null @@ -1,424 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -/** - * The unit tests in this file can be run by opening `./SpecRunner.html` in - * browser. - */ - -function sleep(timeMs) { - return new Promise(resolve => setTimeout(resolve, timeMs)); -} - -describe('benchmark_util', () => { - beforeEach(() => tf.setBackend('cpu')); - - describe('generateInput', () => { - it('LayersModel', () => { - const model = tf.sequential( - {layers: [tf.layers.dense({units: 1, inputShape: [3]})]}); - const input = generateInput(model); - expect(input.length).toEqual(1); - expect(input[0]).toBeInstanceOf(tf.Tensor); - expect(input[0].shape).toEqual([1, 3]); - }); - }); - - describe('generateInputFromDef', () => { - it('should respect int32 data range', async () => { - const inputDef = - [{shape: [1, 1, 10], dtype: 'int32', range: [0, 255], name: 'test'}]; - const input = generateInputFromDef(inputDef); - expect(input.length).toEqual(1); - expect(input[0]).toBeInstanceOf(tf.Tensor); - expect(input[0].shape).toEqual([1, 1, 10]); - expect(input[0].dtype).toEqual('int32'); - const data = await input[0].dataSync(); - expect(data.every(value => value >= 0 && value <= 255)); - }); - it('should respect flaot32 data range', async () => { - const inputDef = - [{shape: [1, 1, 10], dtype: 'float32', range: [0, 1], name: 'test'}]; - const input = generateInputFromDef(inputDef); - expect(input.length).toEqual(1); - expect(input[0]).toBeInstanceOf(tf.Tensor); - expect(input[0].shape).toEqual([1, 1, 10]); - expect(input[0].dtype).toEqual('float32'); - const data = await input[0].dataSync(); - expect(data.every(value => value >= 0 && value <= 1)); - }); - }); - - describe('profile inference time', () => { - describe('timeInference', () => { - it('throws when passing in invalid predict', async () => { - const predict = {}; - await expectAsync(timeInference(predict)).toBeRejected(); - }); - - it('does not add new tensors', async () => { - const model = tf.sequential( - {layers: [tf.layers.dense({units: 1, inputShape: [3]})]}); - const input = tf.zeros([1, 3]); - - const tensorsBefore = tf.memory().numTensors; - await timeInference(() => model.predict(input)); - expect(tf.memory().numTensors).toEqual(tensorsBefore); - - model.dispose(); - input.dispose(); - }); - }); - }); - - describe('Profile Inference', () => { - describe('profileInference', () => { - it('pass in invalid predict', async () => { - const predict = {}; - await expectAsync(profileInference(predict)).toBeRejected(); - }); - - it('check tensor leak', async () => { - const model = tf.sequential( - {layers: [tf.layers.dense({units: 1, inputShape: [3]})]}); - const input = tf.zeros([1, 3]); - - const tensorsBefore = tf.memory().numTensors; - await profileInference(() => model.predict(input)); - expect(tf.memory().numTensors).toEqual(tensorsBefore); - - model.dispose(); - input.dispose(); - }); - - it('profile all statements in async predict function', async () => { - const predict = async () => { - await sleep(1); - const x = tf.tensor1d([1, 2, 3]); - const x2 = x.square(); - x2.dispose(); - return x; - }; - - const oldTensorCount = tf.memory().numTensors; - let profileInfo = await profileInference(predict); - expect(tf.memory().numTensors).toEqual(oldTensorCount); - - // If `profileInference` cannot profile async function, it would - // fail to profile all the statements after `await sleep(1);` and the - // peak memory would be `-Infinity`. - expect(profileInfo.peakBytes).toBeGreaterThan(0); - }); - }); - }); - - describe('aggregateKernelTime', () => { - it('aggregates the kernels according to names', () => { - const kernels = [ - {name: 'testKernel1', kernelTimeMs: 1}, - {name: 'testKernel1', kernelTimeMs: 1}, - {name: 'testKernel1', kernelTimeMs: 1}, - {name: 'testKernel2', kernelTimeMs: 1}, - {name: 'testKernel2', kernelTimeMs: 1}, - ]; - - const aggregatedKernels = aggregateKernelTime(kernels); - expect(aggregatedKernels.length).toBe(2); - expect(aggregatedKernels[0].name).toBe('testKernel1'); - expect(aggregatedKernels[0].timeMs).toBe(3); - expect(aggregatedKernels[1].name).toBe('testKernel2'); - expect(aggregatedKernels[1].timeMs).toBe(2); - }); - }); - - describe('getPredictFnForModel', () => { - it('graph model with async ops uses executeAsync to run', () => { - const model = new tf.GraphModel(); - const input = tf.tensor([1]); - const oldTensorNum = tf.memory().numTensors; - spyOn(model, 'execute').and.callFake(() => { - const leakedTensor = tf.tensor([1]); - throw new Error( - 'This model has dynamic ops, ' + - 'please use model.executeAsync() instead'); - return leakedTensor; - }); - spyOn(model, 'executeAsync'); - - const wrappedPredict = getPredictFnForModel(model, input); - expect(tf.memory().numTensors).toBe(oldTensorNum); - expect(model.execute.calls.count()).toBe(1); - expect(model.execute.calls.first().args).toEqual([input]); - - wrappedPredict(); - expect(model.execute.calls.count()).toBe(1); - expect(model.executeAsync.calls.count()).toBe(1); - expect(model.executeAsync.calls.first().args).toEqual([input]); - - tf.dispose(input); - }); - - it('graph model without async ops uses execute to run', () => { - const model = new tf.GraphModel(); - const input = tf.tensor([1]); - const oldTensorNum = tf.memory().numTensors; - spyOn(model, 'execute').and.callFake(() => { - const leakedTensor = tf.tensor([1]); - }); - spyOn(model, 'executeAsync'); - - const wrappedPredict = getPredictFnForModel(model, input); - expect(tf.memory().numTensors).toBe(oldTensorNum); - expect(model.execute.calls.count()).toBe(1); - expect(model.execute.calls.first().args).toEqual([input]); - - wrappedPredict(); - expect(model.execute.calls.count()).toBe(2); - expect(model.execute.calls.argsFor(1)).toEqual([input]); - expect(model.executeAsync.calls.count()).toBe(0); - - tf.dispose(input); - }); - - it('layers model uses predict to run', () => { - const model = tf.sequential( - {layers: [tf.layers.dense({units: 1, inputShape: [1]})]}); - const input = tf.ones([1, 1]); - spyOn(model, 'predict'); - - const wrappedPredict = getPredictFnForModel(model, input); - wrappedPredict(); - - expect(model.predict.calls.count()).toBe(1); - expect(model.predict.calls.first().args).toEqual([input]); - - tf.dispose(input); - model.dispose(); - }); - - it('throws when passed in a model that is not layers or graph model', - () => { - const model = {}; - const input = []; - expect(() => getPredictFnForModel(model, input)).toThrowError(Error); - }); - }); - - describe('setEnvFlags', () => { - describe('changes nothing when setting empty config or rejecting', () => { - let originalFlags = {}; - - beforeEach(() => { - originalFlags = {...tf.env().flags}; - }); - afterAll(() => tf.env().reset()); - - it('empty config', async () => { - await setEnvFlags(); - expect(tf.env().flags).toEqual(originalFlags); - }); - - it('rejects when setting untunable flags', async () => { - const flagConfig = { - IS_BROWSER: false, - }; - expectAsync(setEnvFlags(flagConfig)) - .toBeRejectedWithError( - Error, /is not a tunable or valid environment flag./); - expect(tf.env().flags).toEqual(originalFlags); - }); - - it('rejects when setting a number flag by a boolean value', async () => { - const flagConfig = { - WEBGL_VERSION: false, - }; - expectAsync(setEnvFlags(flagConfig)).toBeRejectedWithError(Error); - expect(tf.env().flags).toEqual(originalFlags); - }); - - it('rejects when setting boolean flag by a number', async () => { - const flagConfig = { - WEBGL_PACK: 1, - }; - expectAsync(setEnvFlags(flagConfig)).toBeRejectedWithError(Error); - expect(tf.env().flags).toEqual(originalFlags); - }); - - it('rejects when setting flag value out of the range', async () => { - const outOfRangeValue = - Math.max(...TUNABLE_FLAG_VALUE_RANGE_MAP.WEBGL_VERSION) + 1; - const flagConfig = { - WEBGL_VERSION: outOfRangeValue, - }; - expectAsync(setEnvFlags(flagConfig)).toBeRejectedWithError(Error); - expect(tf.env().flags).toEqual(originalFlags); - }); - }); - - describe('reset simple flags', () => { - beforeEach(() => tf.env().reset()); - afterEach(() => tf.env().reset()); - - it('reset number type flags', async () => { - const flagConfig = { - WEBGL_VERSION: 1, - }; - await setEnvFlags(flagConfig); - expect(tf.env().getNumber('WEBGL_VERSION')).toBe(1); - }); - - it('reset boolean flags', async () => { - const flagConfig = { - WASM_HAS_SIMD_SUPPORT: false, - WEBGL_CPU_FORWARD: false, - WEBGL_PACK: false, - WEBGL_FORCE_F16_TEXTURES: false, - WEBGL_RENDER_FLOAT32_CAPABLE: false, - }; - await setEnvFlags(flagConfig); - expect(tf.env().getBool('WASM_HAS_SIMD_SUPPORT')).toBe(false); - expect(tf.env().getBool('WEBGL_CPU_FORWARD')).toBe(false); - expect(tf.env().getBool('WEBGL_PACK')).toBe(false); - expect(tf.env().getBool('WEBGL_FORCE_F16_TEXTURES')).toBe(false); - expect(tf.env().getBool('WEBGL_RENDER_FLOAT32_CAPABLE')).toBe(false); - }); - }); - - describe('reset flags related to environment initialization', () => { - beforeEach(() => tf.engine().reset()); - afterAll(() => { - tf.engine().reset(); - tf.setBackend('cpu'); - }); - - it(`set 'WEBGL_VERSION' to 2`, async () => { - if (!tf.webgl_util.isWebGLVersionEnabled(2)) { - pending( - 'Please use a browser supporting WebGL 2.0 to run this test.'); - } - const flagConfig = { - WEBGL_VERSION: 2, - }; - await setEnvFlags(flagConfig); - expect(tf.env().getBool('WEBGL_BUFFER_SUPPORTED')).toBe(true); - }); - - it(`set 'WEBGL_VERSION' to 1`, async () => { - if (!tf.webgl_util.isWebGLVersionEnabled(1)) { - pending( - 'Please use a browser supporting WebGL 1.0 to run this test.'); - } - const flagConfig = { - WEBGL_VERSION: 1, - }; - await setEnvFlags(flagConfig); - expect(tf.env().getBool('WEBGL_BUFFER_SUPPORTED')).toBe(false); - }); - - it(`reset flags when the related backend is active`, async () => { - if (!tf.webgl_util.isWebGLVersionEnabled(1)) { - pending( - 'Please use a browser supporting WebGL 1.0 to run this test.'); - } - await tf.setBackend('webgl'); - const flagConfig = { - WEBGL_VERSION: 1, - }; - await setEnvFlags(flagConfig); - expect(tf.getBackend()).toBe('webgl'); - }); - - it(`reset 'WASM_HAS_SIMD_SUPPORT' as true`, - async () => { - // TODO: add test for SIMD after SIMD implementation. - // const simdSupported = await - // env().getAsync('WASM_HAS_SIMD_SUPPORT'); - }); - - it(`reset 'WASM_HAS_SIMD_SUPPORT' as false`, async () => { - const flagConfig = { - WASM_HAS_SIMD_SUPPORT: false, - }; - await setEnvFlags(flagConfig); - expect(tf.env().getBool('WASM_HAS_SIMD_SUPPORT')).toBe(false); - }); - }); - }); - - describe('resetBackend', () => { - beforeEach(() => tf.setBackend('cpu')); - afterAll(() => tf.engine().reset()); - - it('rejects when resetting a backend that is not registed', async () => { - expectAsync(resetBackend('invalidBackendName')) - .toBeRejectedWithError( - Error, 'invalidBackendName backend is not registed.'); - }); - - it('do nothing when resetting a backend that is not created', async () => { - const testCpuBackend = 'testCpuBackend'; - tf.registerBackend(testCpuBackend, tf.findBackendFactory('cpu')); - expect(tf.engine().registry[testCpuBackend]).toBeUndefined(); - spyOn(tf, 'findBackendFactory'); - spyOn(tf, 'removeBackend'); - spyOn(tf, 'registerBackend'); - - await resetBackend(testCpuBackend); - - expect(tf.findBackendFactory.calls.count()).toBe(0); - expect(tf.removeBackend.calls.count()).toBe(0); - expect(tf.registerBackend.calls.count()).toBe(0); - tf.removeBackend(testCpuBackend); - }); - - it('reset the backend when resetting an existed backend', async () => { - await tf.ready(); - const currentBackend = tf.getBackend(); - expect(tf.engine().registry[currentBackend]).toBeDefined(); - spyOn(tf, 'findBackendFactory'); - spyOn(tf, 'removeBackend'); - spyOn(tf, 'registerBackend'); - - await resetBackend(currentBackend); - - expect(tf.findBackendFactory.calls.count()).toBe(1); - expect(tf.removeBackend.calls.count()).toBe(1); - expect(tf.registerBackend.calls.count()).toBe(1); - }); - - it('tf.setBackend is called when resetting the active backend', - async () => { - const currentBackend = tf.getBackend(); - spyOn(tf, 'setBackend'); - await resetBackend(currentBackend); - expect(tf.setBackend.calls.count()).toBe(1); - }); - - it('tf.setBackend is not called when resetting an inactive backend', - async () => { - const testCpuBackend = 'testCpuBackend'; - tf.registerBackend(testCpuBackend, tf.findBackendFactory('cpu')); - expect(tf.getBackend()).not.toBe(testCpuBackend); - spyOn(tf, 'setBackend'); - - await resetBackend(testCpuBackend); - - expect(tf.setBackend.calls.count()).toBe(0); - tf.removeBackend(testCpuBackend); - }); - }); -}); diff --git a/tfjs-master/e2e/benchmarks/browserstack-benchmark/README.md b/tfjs-master/e2e/benchmarks/browserstack-benchmark/README.md deleted file mode 100644 index d928c375b..000000000 --- a/tfjs-master/e2e/benchmarks/browserstack-benchmark/README.md +++ /dev/null @@ -1,167 +0,0 @@ -# Benchmark on multiple devices - -> :warning: To use this tool, you need to sign up for BrowserStack's [Automate](https://automate.browserstack.com/dashboard) service. - -The Multi-device benchmark tool can benchmark the performance (time, memory) of model inference on a collection of remote devices. Using this tool you will be able to: - * Select a collection of BrowserStack devices, based on the following fields: - - OS - - OS version - - Browser - - Browser version - - Device - * Select a backend: - - WASM - - WebGL - - CPU - * Set the number of rounds for model inference. - * Select a model to benchmark. - -## Usage -1. Export your access key of BrowserStack's Automate service: - ``` shell - export BROWSERSTACK_USERNAME=YOUR_USERNAME - export BROWSERSTACK_ACCESS_KEY=YOUR_ACCESS_KEY - ``` -2. Download and run the tool: - ``` shell - git clone https://github.com/tensorflow/tfjs.git - cd tfjs/e2e/benchmarks/browserstack-benchmark - yarn install - - node app.js - ``` - Then you can see `> Running socket on port: 8001` on your Command-line interface. - -3. Open http://localhost:8001/ and start to benchmark. - 3.1 If you want to benchmark code snippet. Please update [`benchmarkCodeSnippet` ](https://github.com/tensorflow/tfjs/pull/6704/files#diff-a7c2ef12f0f2bc1a6cabb45bc9850aa68d10644cd2786e6505456e5537dccadbR92)with your code snippet before running `node app.js` and select `codeSnippet` in `model name`: -
- drawing -
-4. When the benchmark is complete, you can see the benchmark results in the webpage, like: -
- drawing -
- -### Command Line Arguments -The following are supported options arguments which trigger options features: - * --benchmarks - - Runs benchmarks from a user-specified, pre-configured JSON file. - ``` shell - node app.js --benchmarks=relative_file_path.json - ``` - A pre-configuration file consists of a JSON object with the following format: - ``` - { - "benchmark": { - "model": ["model_name"], //List of one or more custom or official models to be benchmarked - "numRuns": positive_integer, - "backend": ["backend_name"] //List of one or more backends to be benchmarked - }, - "browsers": { - "local": {}, // Benchmark on your local device - "unique_identifier_laptop_or_desktop": { - "base": "BrowserStack", - "browser": "browser_name", - "browser_version": "browser_version", - "os": "os_name", - "os_version": "os_version", - "device": null - }, - "unique_identifier_mobile_device": { - "base": "BrowserStack", - "browser": "iphone_or_android", - "browser_version": null, - "os": "os_name", - "os_version": "os_version", - "device": "device_name" - } - } - } - ``` - Each model in the model list will be run on each backend in the backend list. Each model-backend combination will run on every browser. If you would like to test specific backends on specific models, the recommended method is to create multiple configuration files. - - For more examples of documentation, refer to the links below: - [List of officially supported TFJS browsers](https://github.com/tensorflow/tfjs/blob/master/e2e/benchmarks/browserstack-benchmark/browser_list.json) - [Example benchmark pre-configuration](https://github.com/tensorflow/tfjs/blob/master/e2e/benchmarks/browserstack-benchmark/preconfigured_browser.json) - * --cloud - - Runs GCP compatible version of benchmarking by blocking the local server. - ``` shell - node app.js --cloud - ``` - * --firestore - - Pushes successful benchmark results to a Firestore database. - ``` shell - node app.js --firestore - ``` - * --h, --help - - Shows help menu and all optional arguments in the shell window. - ``` shell - node app.js --h - ``` - or - ``` shell - node app.js --help - ``` - * --period - - Runs a part of models specified in `--benchmarks`'s file in a cycle and the part of models to run is determined by the date of a month. The value could be or 1~31 (representing Sunday to Saturday). This argument takes effect only if `--benchmarks` is set. - ``` shell - node app.js --period=15 - ``` - * --date - - Set the date for selecting models and this works only if `--period` is set. The value could be 1~31. If it is not declared, the date will the real date at runtime. - ``` shell - node app.js --period=15 --date=1 - ``` - * --maxBenchmarks - - Sets maximum for number of benchmarks run in parallel. Expects a positive integer. - ``` shell - node app.js --maxBenchmarks=positive_integer - ``` - * --maxTries - - Sets maximum for number of tries a given benchmark has to succeed. Expects a positive integer. - ``` shell - node app.js --maxTries=positive_integer - ``` - * --outfile - - Writes results to an accessible external file, benchmark_results.js or benchmark_results.json. Expects 'html' or 'json'. If you set it as \'html\', benchmark_results.js will be generated and you could review the benchmark results by openning benchmark_result.html file. - ``` shell - node app.js --outfile=js - ``` - * --v, --version - - Shows node version in use. - ``` shell - node app.js --v - ``` - or - ``` shell - node app.js --version - ``` - * --localBuild - - Uses local build dependencies, instead of public CDNs. (**When using localBuild targets, please make sure you have built the targets (eg. run `yarn build-individual-link-package tfjs-backend-webgl`) you need.**) - ``` shell - node app.js --localBuild=core,webgl,wasm,cpu,layers,converter,automl - ``` - * --npmVersion - - Specify the npm version of TFJS library to benchmark. By default the latest version of TFJS will be benchmarked. - ``` shell - node app.js --npmVersion=4.4.0 - ``` - -## Custom model -The custom model is supported, but is constrained by: - * A URL path to the model is required, while the model in local file system is not supported. The following URLs are examples: - - TF Hub: https://tfhub.dev/google/tfjs-model/imagenet/resnet_v2_50/feature_vector/1/default/1 - - Storage: https://storage.googleapis.com/tfjs-models/savedmodel/mobilenet_v2_1.0_224/model.json - * Currently only `tf.GraphModel` and `tf.LayersModel` are supported. - -If you want to benchmark more complex models with customized input preprocessing logic, you need to add your model with `load` and `predictFunc` methods into [`tfjs/e2e/benchmarks/model_config.js`](https://github.com/tensorflow/tfjs/blob/master/e2e/benchmarks/model_config.js), following this [example PR](https://github.com/tensorflow/tfjs/pull/3168/files). - -## About this tool -The tool contains: - * A test runner - Karma: - - [benchmark_models.js](https://github.com/tensorflow/tfjs/blob/master/e2e/benchmarks/browserstack-benchmark/benchmark_models.js) warps the all benchmark logics into a Jasmine spec. - - [browser_list.json](https://github.com/tensorflow/tfjs/blob/master/e2e/benchmarks/browserstack-benchmark/browser_list.json) lists the supported BrowserStack combinations. If you want to add more combinations or refactor this list, you can follow this [conversation](https://github.com/tensorflow/tfjs/pull/3737#issue-463759838). - * A node server. [app.js](https://github.com/tensorflow/tfjs/blob/master/e2e/benchmarks/browserstack-benchmark/app.js) runs the test runner and send the benchmark results back to the webpage. - * A webpage. - -Thanks, BrowserStack, for providing supports. diff --git a/tfjs-master/e2e/benchmarks/browserstack-benchmark/SpecRunner.html b/tfjs-master/e2e/benchmarks/browserstack-benchmark/SpecRunner.html deleted file mode 100644 index dad6b23c3..000000000 --- a/tfjs-master/e2e/benchmarks/browserstack-benchmark/SpecRunner.html +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - Jasmine Test - - - - - - - - - - - - - - - - - - - - - - diff --git a/tfjs-master/e2e/benchmarks/browserstack-benchmark/app.js b/tfjs-master/e2e/benchmarks/browserstack-benchmark/app.js deleted file mode 100644 index c1db439cd..000000000 --- a/tfjs-master/e2e/benchmarks/browserstack-benchmark/app.js +++ /dev/null @@ -1,563 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -const http = require('http'); -const socketio = require('socket.io'); -const fs = require('fs'); -const path = require('path'); -const { execFile } = require('child_process'); -const { ArgumentParser } = require('argparse'); -const { version } = require('./package.json'); -const { resolve } = require('path'); -const { - addResultToFirestore, - runFirestore, - firebaseConfig, - endFirebaseInstance -} = require('./firestore.js'); -const { PromiseQueue } = require('./promise_queue'); -const JSONStream = require('JSONStream'); - -const jsonwriter = JSONStream.stringify(); -const port = process.env.PORT || 8001; -let io; -let parser; -let cliArgs; -let db; - -function checkBrowserStackAccount() { - if (process.env.BROWSERSTACK_USERNAME == null || - process.env.BROWSERSTACK_ACCESS_KEY == null) { - throw new Error( - `Please export your BrowserStack username and access key by running` + - `the following commands in the terminal: - export BROWSERSTACK_USERNAME=YOUR_USERNAME - export BROWSERSTACK_ACCESS_KEY=YOUR_ACCESS_KEY`); - } -} - -function runServer() { - const app = http.createServer((request, response) => { - const url = request.url === '/' ? '/index.html' : request.url; - let filePath = path.join(__dirname, url); - if (!fs.existsSync(filePath)) { - filePath = path.join(__dirname, '../', url); - } - fs.readFile(filePath, (err, data) => { - if (err) { - response.writeHead(404); - response.end(JSON.stringify(err)); - return; - } - response.writeHead(200); - response.end(data); - }); - }); - app.listen(port, () => { - console.log(` > Running socket on: 127.0.0.1:${port}`); - }); - - io = socketio(app); - io.on('connection', socket => { - const availableBrowsers = require('./browser_list.json'); - socket.emit('availableBrowsers', availableBrowsers); - socket.on('run', benchmark); - }); -} - -/** - * Supplement the browser configurations and create `browsers.json` and - * `benchmark_parameters.json` configuration files for karma. - * - * @param {{browsers, benchmark}} config - */ -function setupBenchmarkEnv(config) { - // Write the map (tabId - browser setting) to `./browsers.json`. - for (const tabId in config.browsers) { - if (tabId === 'local') { - continue; - } - const browser = config.browsers[tabId]; - browser.base = 'BrowserStack'; - // For mobile devices, we would use real devices instead of emulators. - if (browser.os === 'ios' || browser.os === 'android') { - browser.real_mobile = true; - } - } - fs.writeFileSync('./browsers.json', JSON.stringify(config.browsers, null, 2)); - - // Write benchmark parameters to './benchmark_parameters.json'. - fs.writeFileSync( - './benchmark_parameters.json', JSON.stringify(config.benchmark, null, 2)); -} - -/** - * Creates and runs benchmark configurations for each model-backend pairing. - * - * @param browsers The target browsers to run benchmark. - * @param {{backend, model, numRuns, codeSnippets}} benchmarkInfo - */ -async function benchmarkAll(benchmarkInfo, browsers) { - const allResults = []; - for (backend of benchmarkInfo.backend) { - for (model of benchmarkInfo.model) { - if (model === 'codeSnippet') { - for (codeSnippetPair of benchmarkInfo.codeSnippets) { - console.log( - `\nRunning codeSnippet benchmarks over ${backend} backend...`); - const result = await benchmark({ - 'benchmark': { - 'model': model, - 'numRuns': benchmarkInfo.numRuns, - 'backend': backend, - 'codeSnippet': codeSnippetPair.codeSnippet || '', - 'setupCodeSnippetEnv': codeSnippetPair.setupCodeSnippetEnv || '' - }, - 'browsers': browsers - }); - allResults.push(result); - } - } else { - console.log( - `\nRunning ${model} model benchmarks over ${backend} backend...`); - const result = await benchmark({ - 'benchmark': { - 'model': model, - 'numRuns': benchmarkInfo.numRuns, - 'backend': backend - }, - 'browsers': browsers - }); - allResults.push(result); - } - } - } - console.log('\nAll benchmarks complete!'); - return allResults; -} - -/** - * Run model benchmark on BrowserStack. - * - * Each browser-device pairing is benchmarked in parallel. Results are sent to - * the webpage staggered as they are returned to the server. - * - * The benchmark configuration object contains two objects: - * - `browsers`: Each key-value pair represents a browser instance to be - * benchmarked. The key is a unique string id/tabId (assigned by the webpage) - * for the browser instance, while the value is the browser configuration. - * - * - `benchmark`: An object with the following properties: - * - `model`: The name of model (registed at - * 'tfjs/e2e/benchmarks/model_config.js') or `custom`. - * - modelUrl: The URL to the model description file. Only applicable when - * the `model` is `custom`. - * - `numRuns`: The number of rounds for model inference. - * - `backend`: The backend to be benchmarked on. - * - * - * @param {{browsers, benchmark}} config Benchmark configuration - * @param runOneBenchmark Function that benchmarks one browser-device pair - */ -async function benchmark(config, runOneBenchmark = getOneBenchmarkResult) { - console.log('Preparing configuration files for the test runner.\n'); - setupBenchmarkEnv(config); - if (require.main === module) { - console.log( - `Starting benchmarks using ${cliArgs.localBuild || 'cdn'} ` + - `dependencies...`); - } - - const promiseQueue = new PromiseQueue(cliArgs?.maxBenchmarks ?? 9); - const results = []; - - // Runs and gets result of each queued benchmark - let tabIndex = 1; - for (const tabId in config.browsers) { - results.push(promiseQueue.add(() => { - return runOneBenchmark(tabId, cliArgs?.maxTries, tabIndex++).then((value) => { - value.deviceInfo = config.browsers[tabId]; - value.modelInfo = config.benchmark; - return value; - }).catch(error => { - console.log( - `${tabId} ${config.benchmark.model} ${config.benchmark.backend}`, - error); - return { - error, deviceInfo: config.browsers[tabId], modelInfo: config.benchmark - } - }); - })); - } - - // Optionally written to an outfile or pushed to a database once all - // benchmarks return results - const fulfilled = await Promise.allSettled(results); - if (cliArgs?.outfile === 'html' || cliArgs?.outfile === 'json') { - for (const benchmarkResult of fulfilled) { - jsonwriter.write(benchmarkResult); - } - } - if (cliArgs?.firestore) { - await pushToFirestore(fulfilled); - } - console.log( - `\n${config.benchmark?.model} model benchmark over ${config.benchmark?.backend} backend complete.\n`); - return fulfilled; -} - -function sleep(timeMs) { - return new Promise(resolve => setTimeout(resolve, timeMs)); -} - -/** - * Gets the benchmark result of a singular browser-device pairing. - * - * If benchmarking produces an error, the given browser-device pairing is - * retried up to the specific max number of tries. Default is 3. - * - * @param tabId Indicates browser-device pairing for benchmark - * @param triesLeft Number of tries left for a benchmark to succeed - * @param tabIndex Indicates the sequential position for the browser-device - * pairing, which is used to delay initiating runner. - * @param runOneBenchmark Function that runs a singular BrowserStack - * performance test - * @param retyOneBenchmark Function that retries a singular BrowserStack - * performance test - */ -async function getOneBenchmarkResult( - tabId, triesLeft, tabIndex = 0, - runOneBenchmark = runBrowserStackBenchmark) { - // Since karma will throw out `spawn ETXTBSY` error if initiating multiple - // benchmark runners at the same time, adds delays between initiating runners - // to resolve this race condition. - const numFailed = cliArgs.maxTries - triesLeft; - // The delay increase exponentially when benchmark fails. - const delayInitiatingRunnerTimeMs = tabIndex * (3 ** numFailed) * 1000; - await sleep(delayInitiatingRunnerTimeMs); - - triesLeft--; - try { - const result = await runOneBenchmark(tabId); - console.log(`${tabId} benchmark succeeded.`); - return result; - } catch (err) { - // Retries benchmark until resolved or until no retries left - if (triesLeft > 0) { - console.log(`Retrying ${tabId} benchmark. ${triesLeft} tries left...`); - return await getOneBenchmarkResult(tabId, triesLeft, runOneBenchmark); - } else { - console.log(`${tabId} benchmark failed.`); - throw err; - } - } -} - -/** - * Run benchmark for singular browser-device combination. - * - * This function utilizes a promise that is fulfilled once the corresponding - * result is returned from BrowserStack. - * - * @param tabId Indicates browser-device pairing for benchmark - */ -function runBrowserStackBenchmark(tabId) { - return new Promise((resolve, reject) => { - const args = ['test']; - if (tabId !== 'local') { - args.push('--browserstack', `--browsers=${tabId}`); - } - if (cliArgs.localBuild) { - args.push(`--localBuild=${cliArgs.localBuild}`) - }; - if (cliArgs.npmVersion) { - args.push(`--npmVersion=${cliArgs.npmVersion}`) - }; - - const command = `yarn ${args.join(' ')}`; - console.log(`Running: ${command}`); - execFile('yarn', args, { timeout: 3e5 }, (error, stdout, stderr) => { - if (error) { - console.log(`\n${error}`); - console.log(`stdout: ${stdout}`); - if (!cliArgs.cloud) { - io.emit( - 'benchmarkComplete', - { tabId, error: `Failed to run ${command}:\n${error}` }); - } - return reject(`Failed to run ${command}:\n${error}`); - } - - const errorReg = /.*\(.*)\<\/tfjs_error\>/; - const matchedError = stdout.match(errorReg); - if (matchedError != null) { - if (!cliArgs.cloud) { - io.emit('benchmarkComplete', { tabId, error: matchedError[1] }); - } - return reject(matchedError[1]); - } - - const resultReg = /.*\(.*)\<\/tfjs_benchmark\>/; - const matchedResult = stdout.match(resultReg); - if (matchedResult != null) { - const benchmarkResult = JSON.parse(matchedResult[1]); - benchmarkResult.tabId = tabId; - if (!cliArgs.cloud) { - io.emit('benchmarkComplete', benchmarkResult) - }; - return resolve(benchmarkResult); - } - - const errorMessage = 'Did not find benchmark results from the logs ' + - 'of the benchmark test (benchmark_models.js).'; - if (!cliArgs.cloud) { - io.emit('benchmarkComplete', { error: errorMessage }) - }; - return reject(errorMessage); - }); - }); -} - -/** - * Pushes all benchmark results to Firestore. - * - * @param benchmarkResults List of all benchmark results - */ -async function pushToFirestore(benchmarkResults) { - let firestoreResults = []; - let numRejectedPromises = 0; - console.log('\Pushing results to Firestore...'); - for (result of benchmarkResults) { - if (result.status == 'fulfilled') { - firestoreResults.push( - addResultToFirestore(db, result.value.tabId, result.value)); - } else if (result.status == 'rejected') { - numRejectedPromises++; - } - } - return await Promise.allSettled(firestoreResults).then(() => { - console.log( - `Encountered ${numRejectedPromises} rejected promises that were not ` + - `added to the database.`); - }); -} - -/** Set up --help menu for file description and available optional commands */ -function setupHelpMessage() { - parser = new ArgumentParser({ - description: 'This file launches a server to connect to BrowserStack ' + - 'so that the performance of a TensorFlow model on one or more ' + - 'browsers can be benchmarked.' - }); - parser.add_argument('--benchmarks', { - help: 'run a preconfigured benchmark from a user-specified JSON', - action: 'store' - }); - parser.add_argument('--cloud', { - help: 'runs GCP compatible version of benchmarking system', - action: 'store_true' - }); - parser.add_argument('--period', { - help: 'runs a part of models specified in --benchmarks\'s file in a ' + - 'cycle and the part of models to run is determined by the date ' + - 'of a month. The value could be 1~31.', - type: 'int', - action: 'store' - }); - parser.add_argument('--date', { - help: 'set the date for selecting models and this works only if period ' + - 'is set. The value could be 1~31. If it is not set, the date would be ' + - 'the date at runtime).', - type: 'int', - action: 'store' - }); - parser.add_argument('--maxBenchmarks', { - help: 'the maximum number of benchmarks run in parallel', - type: 'int', - default: 5, - action: 'store' - }); - parser.add_argument('--maxTries', { - help: 'the maximum number of times a given benchmark is tried befor it ' + - 'officially fails', - type: 'int', - default: 3, - action: 'store' - }); - parser.add_argument('--firestore', { - help: 'Store benchmark results in Firestore database', - action: 'store_true' - }); - parser.add_argument('--outfile', { - help: 'write results to outfile. Expects \'html\' or \'json\'. ' + - 'If you set it as \'html\', benchmark_results.js will be generated ' + - 'and you could review the benchmark results by openning ' + - 'benchmark_result.html file.', - type: 'string', - action: 'store' - }); - parser.add_argument('-v', '--version', { action: 'version', version }); - parser.add_argument('--localBuild', { - help: 'local build name list, separated by comma. The name is in short ' + - 'form (in general the name without the tfjs- and backend- prefixes, ' + - 'for example webgl for tfjs-backend-webgl, core for tfjs-core). ' + - 'Example: --localBuild=webgl,core.', - type: 'string', - default: '', - action: 'store' - }); - parser.add_argument('--npmVersion', { - help: 'specify the npm version of TFJS library to benchmark.' + - 'By default the latest version of TFJS will be benchmarked' + - 'Example: --npmVersion=4.4.0.', - type: 'string', - action: 'store' - }); - cliArgs = parser.parse_args(); - console.dir(cliArgs); -} - -/** - * Get the models to benchmark for the day running the script. (All models are - * spilted to n buckets and n === period, associated with the date of the month, - * and the function returns a certain bucket.) - * - * @param models The models to schedule. - * @param period The period to run all models. - * @param date The value could be 1~31, and it determines the models to - * benchmark. By default, the date would be the date at runtime. - */ -function scheduleModels(models, period, date = new Date().getDate()) { - if (period < 1 || period > 31) { - throw new Error('--period must be an integer of 1~31.'); - } - if (date <= 0 || date > 31) { - throw new Error('--date must be an integer of 1~31.'); - } - date = (date - 1) % period; - const bucketSize = Math.ceil(models.length / period); - return models.slice(date * bucketSize, (date + 1) * bucketSize); -} - -/** - * Runs a benchmark with a preconfigured file - * - * @param file Relative filepath to preset benchmark configuration - * @param runBenchmark Function to run a benchmark configuration - */ -async function runBenchmarkFromFile(file, runBenchmark = benchmarkAll) { - console.log('Running a preconfigured benchmark...'); - const { benchmark, browsers } = file; - if (cliArgs?.period != null) { - benchmark.model = scheduleModels(benchmark.model, cliArgs.period, cliArgs.date); - console.log( - `\nWill benchmark the following models: \n\t` + - `${benchmark.model.join('\n\t')} \n`); - } else { - console.log( - `\nWill benchmark all models in '${cliArgs.benchmarks}'.\n`); - } - await runBenchmark(benchmark, browsers); -} - -async function initializeWriting() { - if (cliArgs.firestore) { - db = await runFirestore(firebaseConfig) - }; - - let file; - if (cliArgs?.outfile === 'html') { - await fs.writeFile( - './benchmark_results.js', 'const benchmarkResults = ', 'utf8', err => { - if (err) { - console.log(`Error: ${err}.`); - return reject(err); - } else { - return resolve(); - } - }); - file = fs.createWriteStream('benchmark_results.js', { 'flags': 'a' }); - } else if (cliArgs?.outfile === 'json') { - file = fs.createWriteStream('./benchmark_results.json'); - } else { - return; - } - - // Pipe the JSON data to the file. - jsonwriter.pipe(file); - console.log(`\nStart writing.`); - - // If having outfile, add a listener to Ctrl+C to finalize writing. - process.on('SIGINT', async () => { - await finalizeWriting(); - process.exit(); - }); -} - - -async function finalizeWriting() { - if (cliArgs.firestore) { - await endFirebaseInstance(); - } - - if (cliArgs?.outfile === 'html') { - jsonwriter.end(); - console.log('\nOutput written to ./benchmark_results.js.'); - } else if (cliArgs?.outfile === 'json') { - jsonwriter.end(); - console.log('\nOutput written to ./benchmark_results.json.'); - } -} - -/** Sets up the local or remote environment for benchmarking. */ -async function prebenchmarkSetup() { - checkBrowserStackAccount(); - await initializeWriting(); - - if (!cliArgs.cloud) { - runServer() - }; - - try { - if (cliArgs.benchmarks) { - const filePath = resolve(cliArgs.benchmarks); - if (fs.existsSync(filePath)) { - console.log(`\nFound file at ${filePath}`); - const config = require(filePath); - await runBenchmarkFromFile(config); - console.log('finish') - } else { - throw new Error( - `File could not be found at ${filePath}. ` + - `Please provide a valid path.`); - } - } - } finally { - finalizeWriting(); - } -} - -/* Only run this code if app.js is called from the command line */ -if (require.main === module) { - setupHelpMessage(); - prebenchmarkSetup(); -} - -exports.runBenchmarkFromFile = runBenchmarkFromFile; -exports.getOneBenchmarkResult = getOneBenchmarkResult; -exports.benchmark = benchmark; -exports.scheduleModels = scheduleModels; diff --git a/tfjs-master/e2e/benchmarks/browserstack-benchmark/app_node_test.js b/tfjs-master/e2e/benchmarks/browserstack-benchmark/app_node_test.js deleted file mode 100644 index a8abc7d4d..000000000 --- a/tfjs-master/e2e/benchmarks/browserstack-benchmark/app_node_test.js +++ /dev/null @@ -1,397 +0,0 @@ -const fs = require('fs'); -const { benchmark, write, getOneBenchmarkResult, runBenchmarkFromFile, scheduleModels } = - require('./app.js'); -const { - addResultToFirestore, - makeCompatableWithFirestore, - addGpuInfo, - getReadableDate, - formatForFirestore, - runFirestore, - firebaseConfig -} = require('./firestore.js'); -const { PromiseQueue } = require('./promise_queue.js'); - -describe('test app.js cli', () => { - const filePath = './benchmark_test_results.json'; - let config; - let mockRunOneBenchmark; - let failMockRunOneBenchmark; - let mockResults; - let mockBenchmark; - - beforeAll(() => { - // Set a longer jasmine timeout than 5 seconds - jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000000; - }); - - beforeEach(() => { - // Preset mock results and corresponding config - mockResults = { - 'iPhone_XS_1': { - timeInfo: { - times: [218.00000000000045, 216.00000000000045], - averageTime: 217.00000000000045, - averageTimeExclFirst: 216.00000000000045, - minTime: 216.00000000000045, - maxTime: 218.00000000000045 - }, - tabId: 'iPhone_XS_1' - }, - 'Samsung_Galaxy_S20_1': { - timeInfo: { - times: [428.89999999897555, 430.89999999897555], - averageTime: 429.89999999897555, - averageTimeExclFirst: 430.89999999897555, - minTime: 428.89999999897555, - maxTime: 430.89999999897555 - }, - tabId: 'Samsung_Galaxy_S20_1' - }, - 'Windows_10_1': { - timeInfo: { - times: [395.8500000001095, 397.8500000001095], - averageTime: 396.8500000001095, - averageTimeExclFirst: 397.8500000001095, - minTime: 395.8500000001095, - maxTime: 397.8500000001095 - }, - tabId: 'Windows_10_1' - }, - 'OS_X_Catalina_1': { - timeInfo: { - times: [178.19500000728294, 176.19500000728294], - averageTime: 177.19500000728294, - averageTimeExclFirst: 176.19500000728294, - minTime: 176.19500000728294, - maxTime: 178.19500000728294 - }, - tabId: 'OS_X_Catalina_1' - } - }; - config = { - benchmark: { model: 'mobilenet_v2', numRuns: 1, backend: 'wasm' }, - browsers: { - iPhone_XS_1: { - base: 'BrowserStack', - browser: 'iphone', - browser_version: 'null', - os: 'ios', - os_version: '12', - device: 'iPhone XS', - real_mobile: true - }, - Samsung_Galaxy_S20_1: { - base: 'BrowserStack', - browser: 'android', - browser_version: 'null', - os: 'android', - os_version: '10.0', - device: 'Samsung Galaxy S20', - real_mobile: true - }, - Windows_10_1: { - base: 'BrowserStack', - browser: 'chrome', - browser_version: '84.0', - os: 'Windows', - os_version: '10', - device: null - }, - OS_X_Catalina_1: { - base: 'BrowserStack', - browser: 'chrome', - browser_version: '84.0', - os: 'OS X', - os_version: 'Catalina', - device: null - } - } - }; - - // Bypasses BrowserStack with preset successful mock results - mockRunOneBenchmark = - jasmine.createSpy('mockRunOneBenchmark').and.callFake((tabId) => { - return Promise.resolve(mockResults[tabId]); - }); - - // Bypasses Browserstack with preset failed mock results - failMockRunOneBenchmark = - jasmine.createSpy('mockRunOneBenchmark').and.callFake((tabId) => { - return Promise.reject(`Error: ${tabId} failed.`); - }); - - // Before each spec, create a mock benchmark and set testing browser - // configuration this helps ensure that everything is set to the expected - // contents before the spec is run - mockBenchmark = jasmine.createSpy('mockBenchmark'); - testingConfig = require('./test_config.json'); - }) - - it('checks for outfile accuracy', async () => { - // Writes to mock results file - await write(filePath, mockResults); - - const contents = fs.readFileSync(filePath, 'utf8'); - expect(contents).toEqual(JSON.stringify(mockResults, null, 2)); - }); - - it('benchmark function benchmarks each browser-device pairing ', async () => { - // Receives list of promises from benchmark function call - const testResults = await benchmark(config, mockRunOneBenchmark); - - // Extracts value results from promises, effectively formatting - const formattedResults = {}; - for (let i = 0; i < Object.keys(config.browsers).length; i++) { - await new Promise(resolve => { - const result = testResults[i].value; - formattedResults[result.tabId] = result; - return resolve(); - }); - } - - // Expected mockRunOneBenchmark stats - expect(mockRunOneBenchmark.calls.count()) - .toEqual(Object.keys(config.browsers).length); - expect(mockRunOneBenchmark).toHaveBeenCalledWith('iPhone_XS_1', undefined); - expect(mockRunOneBenchmark) - .toHaveBeenCalledWith('Samsung_Galaxy_S20_1', undefined); - expect(mockRunOneBenchmark).toHaveBeenCalledWith('Windows_10_1', undefined); - expect(mockRunOneBenchmark) - .toHaveBeenCalledWith('OS_X_Catalina_1', undefined); - - // Expected value from promise all - expect(formattedResults).toEqual(mockResults); - }); - - it('getOneBenchmark rejects if a benchmark consistently fails', async () => { - // Expected failed mock benchmark results - await expectAsync( - getOneBenchmarkResult('iPhone_XS_1', 3, failMockRunOneBenchmark)) - .toBeRejectedWith(`Error: iPhone_XS_1 failed.`); - - // Expected mock function call stats - expect(failMockRunOneBenchmark.calls.count()).toEqual(3); - }); - - it('getOneBenchmark fulfills if a benchmark fails and then succeeds', - async () => { - /* Bypasses Browserstack with preset results. Benchmark will fail on the - * call, but succeed on the second call */ - let called = false; - const failThenSucceedMockRunOneBenchmark = - jasmine.createSpy('mockRunOneBenchmark').and.callFake((tabId) => { - if (called) { - return mockRunOneBenchmark(tabId); - } - called = true; - return failMockRunOneBenchmark(tabId); - }); - - // Gets a successful benchmark result - const succeedBenchmarkResult = await getOneBenchmarkResult( - 'iPhone_XS_1', 3, failThenSucceedMockRunOneBenchmark); - - // Expected mock function call stats - expect(failMockRunOneBenchmark.calls.count()).toEqual(1); - expect(mockRunOneBenchmark.calls.count()).toEqual(1); - - // Expected successful mock benchmark results - expect(succeedBenchmarkResult).toEqual(mockResults.iPhone_XS_1); - }); - - it('getOneBenchmark fulfills if a benchmark succeeds immediately', - async () => { - // Gets a successful benchmark result - const succeedBenchmarkResult = - await getOneBenchmarkResult('iPhone_XS_1', 3, mockRunOneBenchmark); - - // Expected mock funciton call stats - expect(mockRunOneBenchmark.calls.count()).toEqual(1); - - // Expected successful mock benchmark results - expect(succeedBenchmarkResult).toEqual(mockResults.iPhone_XS_1); - }); - - it('checks that the benchmark is being run with the correct JSON', () => { - runBenchmarkFromFile(testingConfig, mockBenchmark); - expect(mockBenchmark).toHaveBeenCalledWith(testingConfig); - }); -}); - -describe('test adding to firestore', () => { - let db; - let mockResultValue; - let mockSerialization; - let mockDate; - - beforeAll(async () => { - // Set a longer jasmine timeout than 5 seconds - jasmine.DEFAULT_TIMEOUT_INTERVAL = 1_000_000; - }); - - beforeEach(() => { - // mockResultValue is the result of a successful benchmark - mockResultValue = require('./firestore_test_value.json'); - db = jasmine.createSpyObj('firestore', ['add']); - mockSerialization = jasmine.createSpy('mockSerialization'); - mockDate = jasmine.createSpy('mockDate').and.returnValue('7/21/2021'); - }); - - it('Expects db.add to be called with formatted results', () => { - db.add.and.returnValue(Promise.resolve({ id: 123 })); - let expectedAdd = { - result: - formatForFirestore(mockResultValue, makeCompatableWithFirestore, - getReadableDate) - }; - addResultToFirestore(db, mockResultValue.tabId, mockResultValue); - expect(db.add).toHaveBeenCalledWith(expectedAdd); - }); - - it('Expects gpu info is appended to device info', () => { - addGpuInfo(mockResultValue); - expect(mockResultValue.deviceInfo.device).toEqual( - '(GPU: ANGLE (ATI Technologies Inc., AMD Radeon Pro 5300M OpenGL ' + - 'Engine, OpenGL 4.1))'); - }); - - it('Expects a date key to exist and have the correct value', () => { - let testFormat = - formatForFirestore(mockResultValue, mockSerialization, mockDate); - expect(testFormat.date).toEqual('7/21/2021'); - }); - - it('Expects serialization to cover all nested arrays', () => { - const mockSerializedResults = - formatForFirestore(mockResultValue, makeCompatableWithFirestore, - mockDate); - for (kernel of mockSerializedResults.benchmarkInfo.memoryInfo.kernels) { - expect(typeof (kernel.inputShapes)).toEqual('string'); - expect(typeof (kernel.outputShapes)).toEqual('string'); - } - }); -}); - -function sleep(n) { - return new Promise((resolve) => { - setTimeout(() => { resolve(); }, n); - }); -} - -describe('promise queue', () => { - let queue; - beforeEach(() => { - queue = new PromiseQueue(3); - jasmine.clock().install(); - }); - - afterEach(() => { - jasmine.clock().uninstall(); - }); - - it('runs a given number of functions at once', async () => { - let promises = []; - let started = [false, false, false, false, false]; - let resolved = [false, false, false, false, false]; - for (let i = 0; i < 5; i++) { - resolved[i] = false; - promises.push(queue.add(async () => { - started[i] = true; - await sleep((i + 1) * 10); - resolved[i] = true; - })); - } - - // Queue should immediately start 3 promises. - expect(started).toEqual( - [true, true, true, false, false] - ); - expect(resolved).toEqual( - [false, false, false, false, false] - ); - - // After the first promise is done, queue should start the fourth one. - jasmine.clock().tick(15); - await promises[0]; - expect(started).toEqual( - [true, true, true, true, false] - ); - expect(resolved).toEqual( - [true, false, false, false, false] - ); - - // All running promises should finish, and the last should start. - jasmine.clock().tick(1000); - await promises[1]; - await promises[2]; - await promises[3]; - expect(started).toEqual( - [true, true, true, true, true] - ); - expect(resolved).toEqual( - [true, true, true, true, false] - ); - - // The last promise should finish - jasmine.clock().tick(1000); - await promises[4]; - expect(started).toEqual( - [true, true, true, true, true] - ); - expect(resolved).toEqual( - [true, true, true, true, true] - ); - }); -}); - - -describe('schedule models', () => { - it('scheduling models works for the first day of a period', () => { - models = Array.from(Array(25).keys()); - const res = scheduleModels(models, 7, 1); - expect(res).toEqual( - [0, 1, 2, 3] - ); - }); - - it('scheduling models works for weekly period', () => { - models = Array.from(Array(25).keys()); - const res = scheduleModels(models, 7, 4); - expect(res).toEqual( - [12, 13, 14, 15] - ); - }); - - it('scheduling models works for the last day of a period', () => { - models = Array.from(Array(25).keys()); - const res = scheduleModels(models, 7, 7); - expect(res).toEqual( - [24] - ); - }); - - it('scheduling models works for half-month', () => { - models = Array.from(Array(25).keys()); - const res = scheduleModels(models, 15, 6); - expect(res).toEqual( - [10, 11] - ); - }); - - it('scheduling models works for default date', () => { - jasmine.clock().install(); - - const baseTime = new Date(2022, 12, 6); - jasmine.clock().mockDate(baseTime); - expect(new Date().getDate()).toEqual(6); - - models = Array.from(Array(25).keys()); - const res = scheduleModels(models, 15); - expect(res).toEqual( - [10, 11] - ); - - jasmine.clock().uninstall(); - }); -}); diff --git a/tfjs-master/e2e/benchmarks/browserstack-benchmark/app_test.js b/tfjs-master/e2e/benchmarks/browserstack-benchmark/app_test.js deleted file mode 100644 index 3a730e029..000000000 --- a/tfjs-master/e2e/benchmarks/browserstack-benchmark/app_test.js +++ /dev/null @@ -1,75 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -/** - * The unit tests in this file can be run by opening `./SpecRunner.html` in - * browser. - */ - -describe('benchmark multiple browsers', () => { - const browsersList = [ - { - 'os': 'OS X', - 'os_version': 'Catalina', - 'browser': 'chrome', - 'device': null, - 'browser_version': '84.0' - }, - { - 'os': 'android', - 'os_version': '9.0', - 'browser': 'android', - 'device': 'Samsung Galaxy Note 10 Plus', - 'browser_version': null, - 'real_mobile': true - }, - { - 'os': 'Windows', - 'os_version': '10', - 'browser': 'chrome', - 'device': null, - 'browser_version': '84.0', - 'real_mobile': null - } - ]; - const benchmark = {model: 'mobilenet_v2', numRuns: 1, backend: 'cpu'}; - const browsers = {}; - - beforeAll(() => { - jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000000; - - // Populate `browsers`. - for (const browserConfig of browsersList) { - const tabId = getTabId(browserConfig); - browsers[tabId] = browserConfig; - } - }); - - it('the number of received results is equal to the number of browsers', - done => { - socket.emit('run', {benchmark, browsers}); - - benchmarkResults = []; - socket.on('benchmarkComplete', benchmarkResult => { - expect(benchmarkResult.error).toBeUndefined(); - benchmarkResults.push(benchmarkResult); - if (benchmarkResults.length === browsersList.length) { - done(); - } - }); - }); -}); diff --git a/tfjs-master/e2e/benchmarks/browserstack-benchmark/benchmark_models.js b/tfjs-master/e2e/benchmarks/browserstack-benchmark/benchmark_models.js deleted file mode 100644 index 8c4216435..000000000 --- a/tfjs-master/e2e/benchmarks/browserstack-benchmark/benchmark_models.js +++ /dev/null @@ -1,147 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -/** - * The purpose of this test file is to benchmark models by a test runner, such - * as karma. To invoke this test, inlude this file to the `files` field of - * `karma.conf.js`. - * - * This file wraps the model benchmarking into a Jasmine test and the benchmark - * results will be logged to the console. - */ - -async function getEnvSummary() { - let envSummary = `${tf.getBackend()} backend`; - if (tf.getBackend() === 'webgl') { - envSummary += `, version ${tf.env().get('WEBGL_VERSION')}`; - } else if (tf.getBackend() === 'wasm') { - const hasSIMD = await tf.env().getAsync('WASM_HAS_SIMD_SUPPORT'); - envSummary += hasSIMD ? ' with SIMD' : ' without SIMD'; - } - return envSummary; -} - -async function getBenchmarkSummary(timeInfo, memoryInfo, modelName = 'model') { - if (timeInfo == null) { - throw new Error('Missing the timeInfo parameter.'); - } else if (timeInfo.times.length === 0) { - throw new Error('Missing the memoryInfo parameter.'); - } else if (memoryInfo == null) { - throw new Error('The length of timeInfo.times is at least 1.'); - } - - const numRuns = timeInfo.times.length; - const envSummary = await getEnvSummary(); - const benchmarkSummary = ` - benchmark the ${modelName} on ${envSummary} - 1st inference time: ${printTime(timeInfo.times[0])} - Subsequent average inference time (${numRuns} runs): ${printTime(timeInfo.averageTimeExclFirst)} - Best inference time: ${printTime(timeInfo.minTime)} - Peak memory: ${printMemory(memoryInfo.peakBytes)} - `; - return benchmarkSummary; -} - -const KARMA_SERVER = './base'; - -async function benchmarkModel(benchmarkParameters) { - // Load the model. - const benchmark = benchmarks[benchmarkParameters.model]; - const numRuns = benchmarkParameters.numRuns; - let model; - if (benchmarkParameters.model === 'custom') { - if (benchmarkParameters.modelUrl == null) { - throw new Error('Please provide model url for the custom model.'); - } - model = await loadModelByUrl(benchmarkParameters.modelUrl); - } else { - model = await benchmark.load(); - } - - // Benchmark. - let timeInfo; - let memoryInfo; - if (benchmark.predictFunc != null) { - const predict = benchmark.predictFunc(); - timeInfo = await timeInference(() => predict(model), numRuns); - memoryInfo = await profileInference(() => predict(model)); - } else { - const input = generateInput(model); - timeInfo = await timeModelInference(model, input, numRuns); - memoryInfo = await profileModelInference(model, input); - } - - return { timeInfo, memoryInfo }; -} - -async function benchmarkCodeSnippet(benchmarkParameters) { - let predict = null; - - const setupCodeSnippetEnv = benchmarkParameters.setupCodeSnippetEnv || ''; - const codeSnippet = benchmarkParameters.codeSnippet || '' - eval(setupCodeSnippetEnv.concat(codeSnippet)); - - if (predict == null) { - throw new Error( - 'predict function is suppoed to be defined in codeSnippet.'); - } - - // Warm up. - await timeInference(predict, 1); - - // Benchmark code snippet. - timeInfo = await timeInference(predict, benchmarkParameters.numRuns); - memoryInfo = await profileInference(predict); - - return { timeInfo, memoryInfo }; -} - -describe('BrowserStack benchmark', () => { - let benchmarkParameters; - beforeAll(async () => { - jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000000; - const response = await fetch(`${KARMA_SERVER}/benchmark_parameters.json`); - benchmarkParameters = await response.json(); - tf.env().set('SOFTWARE_WEBGL_ENABLED', true); - }); - - it(`benchmark`, async () => { - try { - // Setup benchmark environments. - const targetBackend = benchmarkParameters.backend; - await tf.setBackend(targetBackend); - - // Run benchmark and stringify results. - let resultObj; - if (benchmarkParameters.model === 'codeSnippet') { - resultObj = await benchmarkCodeSnippet(benchmarkParameters); - } else { - resultObj = await benchmarkModel(benchmarkParameters); - } - - // Get GPU hardware info. - resultObj.gpuInfo = - targetBackend === 'webgl' ? (await getRendererInfo()) : 'MISS'; - - // Report results. - console.log( - `${JSON.stringify(resultObj)}`); - } catch (error) { - console.log(`${error}`); - } - }); -}); diff --git a/tfjs-master/e2e/benchmarks/browserstack-benchmark/benchmark_results.html b/tfjs-master/e2e/benchmarks/browserstack-benchmark/benchmark_results.html deleted file mode 100644 index de8c342e8..000000000 --- a/tfjs-master/e2e/benchmarks/browserstack-benchmark/benchmark_results.html +++ /dev/null @@ -1,162 +0,0 @@ - - - - - - - diff --git a/tfjs-master/e2e/benchmarks/browserstack-benchmark/browser_list.json b/tfjs-master/e2e/benchmarks/browserstack-benchmark/browser_list.json deleted file mode 100644 index 2034de186..000000000 --- a/tfjs-master/e2e/benchmarks/browserstack-benchmark/browser_list.json +++ /dev/null @@ -1,631 +0,0 @@ -[ - { - "os": "Windows", - "os_version": "11", - "browser": "chrome", - "device": null, - "browser_version": "103.0", - "real_mobile": null - }, - { - "os": "Windows", - "os_version": "10", - "browser": "ie", - "device": null, - "browser_version": "11.0", - "real_mobile": null - }, - { - "os": "Windows", - "os_version": "11", - "browser": "edge", - "device": null, - "browser_version": "103.0", - "real_mobile": null - }, - { - "os": "Windows", - "os_version": "11", - "browser": "firefox", - "device": null, - "browser_version": "103.0", - "real_mobile": null - }, - { - "os": "OS X", - "os_version": "Monterey", - "browser": "chrome", - "device": null, - "browser_version": "103.0", - "real_mobile": null - }, - { - "os": "OS X", - "os_version": "Monterey", - "browser": "safari", - "device": null, - "browser_version": "15.3", - "real_mobile": null - }, - { - "os": "OS X", - "os_version": "Monterey", - "browser": "firefox", - "device": null, - "browser_version": "103.0", - "real_mobile": null - }, - { - "os": "ios", - "os_version": "15", - "browser": "iphone", - "device": "iPhone 13 Pro Max", - "browser_version": null, - "real_mobile": true - }, - { - "os": "ios", - "os_version": "15", - "browser": "iphone", - "device": "iPhone 13", - "browser_version": null, - "real_mobile": true - }, - { - "os": "ios", - "os_version": "14", - "browser": "iphone", - "device": "iPhone 12 Pro Max", - "browser_version": null, - "real_mobile": true - }, - { - "os": "ios", - "os_version": "14", - "browser": "iphone", - "device": "iPhone 12", - "browser_version": null, - "real_mobile": true - }, - { - "os": "ios", - "os_version": "15", - "browser": "iphone", - "device": "iPhone XS", - "browser_version": null, - "real_mobile": true - }, - { - "os": "ios", - "os_version": "14", - "browser": "iphone", - "device": "iPhone XS", - "browser_version": null, - "real_mobile": true - }, - { - "os": "ios", - "os_version": "13", - "browser": "iphone", - "device": "iPhone 11 Pro Max", - "browser_version": null, - "real_mobile": true - }, - { - "os": "ios", - "os_version": "14", - "browser": "iphone", - "device": "iPhone 11 Pro", - "browser_version": null, - "real_mobile": true - }, - { - "os": "ios", - "os_version": "14", - "browser": "iphone", - "device": "iPhone 11", - "browser_version": null, - "real_mobile": true - }, - { - "os": "ios", - "os_version": "13", - "browser": "iphone", - "device": "iPhone 8", - "browser_version": null, - "real_mobile": true - }, - { - "os": "ios", - "os_version": "13", - "browser": "iphone", - "device": "iPhone SE 2020", - "browser_version": null, - "real_mobile": true - }, - { - "os": "ios", - "os_version": "15", - "browser": "iphone", - "device": "iPhone 13", - "browser_version": null, - "real_mobile": true - },{ - "os": "ios", - "os_version": "15", - "browser": "ipad", - "device": "iPad 9th", - "browser_version": null, - "real_mobile": true - },{ - "os": "ios", - "os_version": "15", - "browser": "ipad", - "device": "iPad Air 5", - "browser_version": null, - "real_mobile": true - },{ - "os": "ios", - "os_version": "14", - "browser": "ipad", - "device": "iPad Air 4", - "browser_version": null, - "real_mobile": true - },{ - "os": "ios", - "os_version": "14", - "browser": "ipad", - "device": "iPad 8th", - "browser_version": null, - "real_mobile": true - }, - { - "os": "ios", - "os_version": "13", - "browser": "ipad", - "device": "iPad Pro 12.9 2020", - "browser_version": null, - "real_mobile": true - }, - { - "os": "ios", - "os_version": "13", - "browser": "ipad", - "device": "iPad Pro 11 2020", - "browser_version": null, - "real_mobile": true - }, - { - "os": "ios", - "os_version": "13", - "browser": "ipad", - "device": "iPad Mini 2019", - "browser_version": null, - "real_mobile": true - }, - { - "os": "ios", - "os_version": "13", - "browser": "ipad", - "device": "iPad Air 2019", - "browser_version": null, - "real_mobile": true - }, - { - "os": "ios", - "os_version": "13", - "browser": "ipad", - "device": "iPad 7th", - "browser_version": null, - "real_mobile": true - }, - { - "os": "ios", - "os_version": "12", - "browser": "iphone", - "device": "iPhone XS", - "browser_version": null, - "real_mobile": true - }, - { - "os": "ios", - "os_version": "12", - "browser": "iphone", - "device": "iPhone XS Max", - "browser_version": null, - "real_mobile": true - }, - { - "os": "ios", - "os_version": "12", - "browser": "iphone", - "device": "iPhone XR", - "browser_version": null, - "real_mobile": true - }, - { - "os": "ios", - "os_version": "12", - "browser": "iphone", - "device": "iPhone 8", - "browser_version": null, - "real_mobile": true - }, - { - "os": "ios", - "os_version": "12", - "browser": "iphone", - "device": "iPhone 8 Plus", - "browser_version": null, - "real_mobile": true - }, - { - "os": "ios", - "os_version": "12", - "browser": "iphone", - "device": "iPhone 7", - "browser_version": null, - "real_mobile": true - }, - { - "os": "ios", - "os_version": "12", - "browser": "iphone", - "device": "iPhone 6S", - "browser_version": null, - "real_mobile": true - }, - { - "os": "ios", - "os_version": "12", - "browser": "ipad", - "device": "iPad Pro 11 2018", - "browser_version": null, - "real_mobile": true - }, - { - "os": "ios", - "os_version": "12", - "browser": "ipad", - "device": "iPad Mini 2019", - "browser_version": null, - "real_mobile": true - }, - { - "os": "ios", - "os_version": "12", - "browser": "ipad", - "device": "iPad Air 2019", - "browser_version": null, - "real_mobile": true - }, - { - "os": "android", - "os_version": "12.0", - "browser": "android", - "device": "Samsung Galaxy S22 Ultra", - "browser_version": null, - "real_mobile": true - },{ - "os": "android", - "os_version": "12.0", - "browser": "android", - "device": "Samsung Galaxy S22 Plus", - "browser_version": null, - "real_mobile": true - },{ - "os": "android", - "os_version": "12.0", - "browser": "android", - "device": "Samsung Galaxy S22", - "browser_version": null, - "real_mobile": true - },{ - "os": "android", - "os_version": "12.0", - "browser": "android", - "device": "Samsung Galaxy S21", - "browser_version": null, - "real_mobile": true - },{ - "os": "android", - "os_version": "12.0", - "browser": "android", - "device": "Google Pixel 6 Pro", - "browser_version": null, - "real_mobile": true - },{ - "os": "android", - "os_version": "12.0", - "browser": "android", - "device": "Google Pixel 6", - "browser_version": null, - "real_mobile": true - },{ - "os": "android", - "os_version": "12.0", - "browser": "android", - "device": "Google Pixel 5", - "browser_version": null, - "real_mobile": true - },{ - "os": "android", - "os_version": "12.0", - "browser": "android", - "device": "Samsung Galaxy Tab S8", - "browser_version": null, - "real_mobile": true - }, - { - "os": "android", - "os_version": "11.0", - "browser": "android", - "device": "Google Pixel 5", - "browser_version": null, - "real_mobile": true - }, - { - "os": "android", - "os_version": "10.0", - "browser": "android", - "device": "Samsung Galaxy S20", - "browser_version": null, - "real_mobile": true - }, - { - "os": "android", - "os_version": "10.0", - "browser": "android", - "device": "Samsung Galaxy S20 Plus", - "browser_version": null, - "real_mobile": true - }, - { - "os": "android", - "os_version": "10.0", - "browser": "android", - "device": "Samsung Galaxy S20 Ultra", - "browser_version": null, - "real_mobile": true - }, - { - "os": "android", - "os_version": "10.0", - "browser": "android", - "device": "Samsung Galaxy A51", - "browser_version": null, - "real_mobile": true - }, - { - "os": "android", - "os_version": "10.0", - "browser": "android", - "device": "Samsung Galaxy A11", - "browser_version": null, - "real_mobile": true - }, - { - "os": "android", - "os_version": "10.0", - "browser": "android", - "device": "Google Pixel 4 XL", - "browser_version": null, - "real_mobile": true - }, - { - "os": "android", - "os_version": "10.0", - "browser": "android", - "device": "Google Pixel 4", - "browser_version": null, - "real_mobile": true - }, - { - "os": "android", - "os_version": "10.0", - "browser": "android", - "device": "Google Pixel 3", - "browser_version": null, - "real_mobile": true - }, - { - "os": "android", - "os_version": "10.0", - "browser": "android", - "device": "OnePlus 8", - "browser_version": null, - "real_mobile": true - }, - { - "os": "android", - "os_version": "10.0", - "browser": "android", - "device": "OnePlus 7T", - "browser_version": null, - "real_mobile": true - }, - { - "os": "android", - "os_version": "9.0", - "browser": "android", - "device": "Samsung Galaxy S9 Plus", - "browser_version": null, - "real_mobile": true - }, - { - "os": "android", - "os_version": "9.0", - "browser": "android", - "device": "Samsung Galaxy S8 Plus", - "browser_version": null, - "real_mobile": true - }, - { - "os": "android", - "os_version": "9.0", - "browser": "android", - "device": "Samsung Galaxy S10e", - "browser_version": null, - "real_mobile": true - }, - { - "os": "android", - "os_version": "9.0", - "browser": "android", - "device": "Samsung Galaxy S10 Plus", - "browser_version": null, - "real_mobile": true - }, - { - "os": "android", - "os_version": "9.0", - "browser": "android", - "device": "Samsung Galaxy S10", - "browser_version": null, - "real_mobile": true - }, - { - "os": "android", - "os_version": "9.0", - "browser": "android", - "device": "Samsung Galaxy Note 10 Plus", - "browser_version": null, - "real_mobile": true - }, - { - "os": "android", - "os_version": "9.0", - "browser": "android", - "device": "Samsung Galaxy Note 10", - "browser_version": null, - "real_mobile": true - }, - { - "os": "android", - "os_version": "9.0", - "browser": "android", - "device": "Samsung Galaxy A10", - "browser_version": null, - "real_mobile": true - }, - { - "os": "android", - "os_version": "9.0", - "browser": "android", - "device": "Google Pixel 3a XL", - "browser_version": null, - "real_mobile": true - }, - { - "os": "android", - "os_version": "9.0", - "browser": "android", - "device": "Google Pixel 3a", - "browser_version": null, - "real_mobile": true - }, - { - "os": "android", - "os_version": "9.0", - "browser": "android", - "device": "Google Pixel 3 XL", - "browser_version": null, - "real_mobile": true - }, - { - "os": "android", - "os_version": "9.0", - "browser": "android", - "device": "Google Pixel 3", - "browser_version": null, - "real_mobile": true - }, - { - "os": "android", - "os_version": "9.0", - "browser": "android", - "device": "Google Pixel 2", - "browser_version": null, - "real_mobile": true - }, - { - "os": "android", - "os_version": "9.0", - "browser": "android", - "device": "Motorola Moto G7 Play", - "browser_version": null, - "real_mobile": true - }, - { - "os": "android", - "os_version": "9.0", - "browser": "android", - "device": "OnePlus 7", - "browser_version": null, - "real_mobile": true - }, - { - "os": "android", - "os_version": "9.0", - "browser": "android", - "device": "OnePlus 6T", - "browser_version": null, - "real_mobile": true - }, - { - "os": "android", - "os_version": "9.0", - "browser": "android", - "device": "Xiaomi Redmi Note 8", - "browser_version": null, - "real_mobile": true - }, - { - "os": "android", - "os_version": "9.0", - "browser": "android", - "device": "Xiaomi Redmi Note 7", - "browser_version": null, - "real_mobile": true - }, - { - "os": "android", - "os_version": "9.0", - "browser": "android", - "device": "Samsung Galaxy Tab S6", - "browser_version": null, - "real_mobile": true - }, - { - "os": "android", - "os_version": "9.0", - "browser": "android", - "device": "Samsung Galaxy Tab S5e", - "browser_version": null, - "real_mobile": true - }, - { - "os": "android", - "os_version": "8.1", - "browser": "android", - "device": "Samsung Galaxy Note 9", - "browser_version": null, - "real_mobile": true - }, - { - "os": "android", - "os_version": "8.1", - "browser": "android", - "device": "Samsung Galaxy J7 Prime", - "browser_version": null, - "real_mobile": true - }, - { - "os": "android", - "os_version": "8.1", - "browser": "android", - "device": "Samsung Galaxy Tab S4", - "browser_version": null, - "real_mobile": true - } -] diff --git a/tfjs-master/e2e/benchmarks/browserstack-benchmark/cloudbuild.yml b/tfjs-master/e2e/benchmarks/browserstack-benchmark/cloudbuild.yml deleted file mode 100644 index 6be4ca333..000000000 --- a/tfjs-master/e2e/benchmarks/browserstack-benchmark/cloudbuild.yml +++ /dev/null @@ -1,33 +0,0 @@ -steps: - -# Install packages. -- name: 'gcr.io/learnjs-174218/release' - dir: 'e2e/benchmarks/browserstack-benchmark' - entrypoint: 'yarn' - id: 'yarn' - args: ['install'] - -# Run benchmarks. -- name: 'gcr.io/learnjs-174218/release' - dir: 'e2e/benchmarks/browserstack-benchmark' - entrypoint: 'yarn' - id: 'test' - args: ['run-cloud-benchmarks-half-month-cycle'] - env: ['BROWSERSTACK_USERNAME=deeplearnjs1', 'NIGHTLY=$_NIGHTLY'] - secretEnv: ['BROWSERSTACK_ACCESS_KEY', 'FIREBASE_KEY'] - waitFor: ['yarn'] - -availableSecrets: - secretManager: - - versionName: projects/834911136599/secrets/BROWSERSTACK_ACCESS_KEY/versions/latest - env: 'BROWSERSTACK_ACCESS_KEY' - - versionName: projects/834911136599/secrets/FIREBASE_KEY/versions/latest - env: 'FIREBASE_KEY' -timeout: 3600s -logsBucket: 'gs://tfjs-build-logs' -substitutions: - _NIGHTLY: '' -options: - logStreamingOption: 'STREAM_ON' - machineType: 'N1_HIGHCPU_8' - substitution_option: 'ALLOW_LOOSE' diff --git a/tfjs-master/e2e/benchmarks/browserstack-benchmark/firestore.js b/tfjs-master/e2e/benchmarks/browserstack-benchmark/firestore.js deleted file mode 100644 index a002e6216..000000000 --- a/tfjs-master/e2e/benchmarks/browserstack-benchmark/firestore.js +++ /dev/null @@ -1,156 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -const { initializeApp, deleteApp, applicationDefault, cert } = require('firebase-admin/app'); -const { getFirestore, Timestamp, FieldValue } = require('firebase-admin/firestore'); - -let app; -/** - * Initializes Firebase, signs in with secret credentials, and accesses the - * Firestore collection of results. - * - * @param firebaseConfig A configuration with Firebase credentials - */ -async function runFirestore() { - try { - app = initializeApp({ - credential: applicationDefault() - }); - const db = getFirestore(); - - console.log('\nSuccesfuly signed into Firebase.'); - return db.collection('BenchmarkResults'); - } catch (err) { - console.warn(`Failed to connect to firebase database: ${err.message}`); - throw err; - } -} - -/** - * Deletes the Firebase instance, which allows the Node.js process to finish. - */ -async function endFirebaseInstance() { - await deleteApp(app); - console.log('Exited Firebase instance.'); -} - -/** - * After being returned from Browserstack, benchmark results are stored as - * a list of fulfilled promises. - * - * As results are being iterated through, this function handles taking a result, - * serializing it, and pushing it to Firestore. - * - * @param db Reference to Firestore collection - * @param resultId ID of value added to Firestore - * @param result Individual result in a list of fulfilled promises - */ -async function addResultToFirestore(db, resultId, result) { - try { - const firestoreMap = - formatForFirestore(result, makeCompatableWithFirestore, getReadableDate); - await db.add({ result: firestoreMap }).then((ref) => { - console.log(`Added ${resultId} to Firestore with ID: ${ref.id}`); - }); - } catch (err) { - throw err; - } -} - -/** - * This functions calls other formatting functions on a benchmark result so that - * every Firestore entry is compatable and contains desired information - * - * @param result Individual result in a list of fulfilled promises - */ -function formatForFirestore( - result, makeCompatable = makeCompatableWithFirestore, - getDate = getReadableDate) { - let firestoreMap = {}; - firestoreMap.benchmarkInfo = makeCompatable(result); - firestoreMap.date = getDate(); - - return firestoreMap; -} - -/** - * This function makes the result object returned from benchmark app aligned - * with target firestore collection's schema. - * - * @param result Individual result in a list of fulfilled promises - */ -function makeCompatableWithFirestore(result) { - addGpuInfo(result); - serializeTensors(result); - return result; -} - -/** - * Append GPU info to device name. - * - * @param result Individual result in a list of fulfilled promises - */ -function addGpuInfo(result) { - const gpuInfo = result.gpuInfo; - delete result.gpuInfo; - if (gpuInfo == null || gpuInfo === 'MISS') { - return; - } - - if (result.deviceInfo.device == null) { - result.deviceInfo.device = `(GPU: ${gpuInfo})`; - } else { - result.deviceInfo.device = `${result.deviceInfo.device} (GPU: ${gpuInfo})`; - } - return result; -} - -/** - * Benchmark results contain tensors that are represented as nested arrays. - * Nested arrays are not supported on Firestore, so they are serialized - * before they are stored. - * - * @param result Individual result in a list of fulfilled promises - */ -function serializeTensors(result) { - let kernels = result.memoryInfo.kernels; - for (kernel of kernels) { - kernel.inputShapes = JSON.stringify(kernel.inputShapes); - kernel.outputShapes = JSON.stringify(kernel.outputShapes); - } - return result; -} - -/** - * Returns a human readable date so each benchmark has an associated date. - * Gets date in ISO format so that it is compatible with internal visualisation - * tool. - */ -function getReadableDate() { - const fullISODateString = new Date().toISOString(); - const dateOnly = fullISODateString.split('T')[0]; - return dateOnly; -} - -exports.addResultToFirestore = addResultToFirestore; -exports.makeCompatableWithFirestore = makeCompatableWithFirestore; -exports.addGpuInfo = addGpuInfo; -exports.serializeTensors = serializeTensors; -exports.getReadableDate = getReadableDate; -exports.formatForFirestore = formatForFirestore; -exports.runFirestore = runFirestore; -exports.endFirebaseInstance = endFirebaseInstance; diff --git a/tfjs-master/e2e/benchmarks/browserstack-benchmark/firestore_test_value.json b/tfjs-master/e2e/benchmarks/browserstack-benchmark/firestore_test_value.json deleted file mode 100644 index 32b7a4f71..000000000 --- a/tfjs-master/e2e/benchmarks/browserstack-benchmark/firestore_test_value.json +++ /dev/null @@ -1,4199 +0,0 @@ -{ - "timeInfo": { - "times": [ - 240.42999999801395 - ], - "averageTime": 240.42999999801395, - "minTime": 240.42999999801395, - "maxTime": 240.42999999801395 - }, - "memoryInfo": { - "newBytes": 0, - "newTensors": 0, - "peakBytes": 20579628, - "kernels": [ - { - "name": "fusedConv2d__op", - "bytesAdded": 4816896, - "totalBytesSnapshot": 20178220, - "tensorsAdded": 1, - "totalTensorsSnapshot": 111, - "inputShapes": [ - [ - 1, - 112, - 112, - 16 - ], - [ - 1, - 1, - 16, - 96 - ], - [ - 96 - ] - ], - "outputShapes": [ - [ - 1, - 112, - 112, - 96 - ] - ], - "kernelTimeMs": 23.860000001150183, - "extraInfo": "" - }, - { - "name": "FusedConv2D", - "bytesAdded": 4816896, - "totalBytesSnapshot": 20178220, - "tensorsAdded": 1, - "totalTensorsSnapshot": 111, - "inputShapes": [ - [ - 1, - 112, - 112, - 16 - ], - [ - 1, - 1, - 16, - 96 - ], - [ - 96 - ], - null - ], - "outputShapes": [ - [ - 1, - 112, - 112, - 96 - ] - ], - "kernelTimeMs": 17.025000001012813, - "extraInfo": "" - }, - { - "name": "fusedConv2d__op", - "bytesAdded": 1605632, - "totalBytesSnapshot": 16766252, - "tensorsAdded": 1, - "totalTensorsSnapshot": 111, - "inputShapes": [ - [ - 1, - 224, - 224, - 3 - ], - [ - 3, - 3, - 3, - 32 - ], - [ - 32 - ] - ], - "outputShapes": [ - [ - 1, - 112, - 112, - 32 - ] - ], - "kernelTimeMs": 8.620000000519212, - "extraInfo": "" - }, - { - "name": "fusedDepthwiseConv2d__op", - "bytesAdded": 1605632, - "totalBytesSnapshot": 17769772, - "tensorsAdded": 1, - "totalTensorsSnapshot": 111, - "inputShapes": [ - [ - 1, - 112, - 112, - 32 - ], - [ - 3, - 3, - 32, - 1 - ], - [ - 32 - ] - ], - "outputShapes": [ - [ - 1, - 112, - 112, - 32 - ] - ], - "kernelTimeMs": 8.200000003853347, - "extraInfo": "" - }, - { - "name": "fusedDepthwiseConv2d__op", - "bytesAdded": 1806336, - "totalBytesSnapshot": 18472236, - "tensorsAdded": 1, - "totalTensorsSnapshot": 112, - "inputShapes": [ - [ - 1, - 56, - 56, - 144 - ], - [ - 3, - 3, - 144, - 1 - ], - [ - 144 - ] - ], - "outputShapes": [ - [ - 1, - 56, - 56, - 144 - ] - ], - "kernelTimeMs": 7.769999996526167, - "extraInfo": "" - }, - { - "name": "FusedConv2D", - "bytesAdded": 1605632, - "totalBytesSnapshot": 16766252, - "tensorsAdded": 1, - "totalTensorsSnapshot": 111, - "inputShapes": [ - [ - 1, - 224, - 224, - 3 - ], - [ - 3, - 3, - 3, - 32 - ], - [ - 32 - ], - null - ], - "outputShapes": [ - [ - 1, - 112, - 112, - 32 - ] - ], - "kernelTimeMs": 7.579999997687992, - "extraInfo": "" - }, - { - "name": "fusedConv2d__op", - "bytesAdded": 1806336, - "totalBytesSnapshot": 16665900, - "tensorsAdded": 1, - "totalTensorsSnapshot": 111, - "inputShapes": [ - [ - 1, - 56, - 56, - 24 - ], - [ - 1, - 1, - 24, - 144 - ], - [ - 144 - ] - ], - "outputShapes": [ - [ - 1, - 56, - 56, - 144 - ] - ], - "kernelTimeMs": 7.515000004786998, - "extraInfo": "" - }, - { - "name": "fusedConv2d__op", - "bytesAdded": 250880, - "totalBytesSnapshot": 14872108, - "tensorsAdded": 1, - "totalTensorsSnapshot": 111, - "inputShapes": [ - [ - 1, - 7, - 7, - 320 - ], - [ - 1, - 1, - 320, - 1280 - ], - [ - 1280 - ] - ], - "outputShapes": [ - [ - 1, - 7, - 7, - 1280 - ] - ], - "kernelTimeMs": 7.265000000188593, - "extraInfo": "" - }, - { - "name": "FusedDepthwiseConv2D", - "bytesAdded": 1605632, - "totalBytesSnapshot": 17769772, - "tensorsAdded": 1, - "totalTensorsSnapshot": 111, - "inputShapes": [ - [ - 1, - 112, - 112, - 32 - ], - [ - 3, - 3, - 32, - 1 - ], - [ - 32 - ], - null - ], - "outputShapes": [ - [ - 1, - 112, - 112, - 32 - ] - ], - "kernelTimeMs": 7.149999997636769, - "extraInfo": "" - }, - { - "name": "FusedConv2D", - "bytesAdded": 250880, - "totalBytesSnapshot": 14872108, - "tensorsAdded": 1, - "totalTensorsSnapshot": 111, - "inputShapes": [ - [ - 1, - 7, - 7, - 320 - ], - [ - 1, - 1, - 320, - 1280 - ], - [ - 1280 - ], - null - ], - "outputShapes": [ - [ - 1, - 7, - 7, - 1280 - ] - ], - "kernelTimeMs": 6.990000001678709, - "extraInfo": "" - }, - { - "name": "fusedConv2d__op", - "bytesAdded": 1806336, - "totalBytesSnapshot": 16665900, - "tensorsAdded": 1, - "totalTensorsSnapshot": 111, - "inputShapes": [ - [ - 1, - 56, - 56, - 24 - ], - [ - 1, - 1, - 24, - 144 - ], - [ - 144 - ] - ], - "outputShapes": [ - [ - 1, - 56, - 56, - 144 - ] - ], - "kernelTimeMs": 6.874999999126885, - "extraInfo": "" - }, - { - "name": "fusedDepthwiseConv2d__op", - "bytesAdded": 1204224, - "totalBytesSnapshot": 20579628, - "tensorsAdded": 1, - "totalTensorsSnapshot": 111, - "inputShapes": [ - [ - 1, - 112, - 112, - 96 - ], - [ - 3, - 3, - 96, - 1 - ], - [ - 96 - ] - ], - "outputShapes": [ - [ - 1, - 56, - 56, - 96 - ] - ], - "kernelTimeMs": 6.7149999958928674, - "extraInfo": "" - }, - { - "name": "FusedDepthwiseConv2D", - "bytesAdded": 1806336, - "totalBytesSnapshot": 18472236, - "tensorsAdded": 1, - "totalTensorsSnapshot": 112, - "inputShapes": [ - [ - 1, - 56, - 56, - 144 - ], - [ - 3, - 3, - 144, - 1 - ], - [ - 144 - ], - null - ], - "outputShapes": [ - [ - 1, - 56, - 56, - 144 - ] - ], - "kernelTimeMs": 6.560000001627486, - "extraInfo": "" - }, - { - "name": "FusedConv2D", - "bytesAdded": 1806336, - "totalBytesSnapshot": 16665900, - "tensorsAdded": 1, - "totalTensorsSnapshot": 111, - "inputShapes": [ - [ - 1, - 56, - 56, - 24 - ], - [ - 1, - 1, - 24, - 144 - ], - [ - 144 - ], - null - ], - "outputShapes": [ - [ - 1, - 56, - 56, - 144 - ] - ], - "kernelTimeMs": 6.269999998039566, - "extraInfo": "" - }, - { - "name": "FusedConv2D", - "bytesAdded": 1806336, - "totalBytesSnapshot": 16665900, - "tensorsAdded": 1, - "totalTensorsSnapshot": 111, - "inputShapes": [ - [ - 1, - 56, - 56, - 24 - ], - [ - 1, - 1, - 24, - 144 - ], - [ - 144 - ], - null - ], - "outputShapes": [ - [ - 1, - 56, - 56, - 144 - ] - ], - "kernelTimeMs": 5.680000002030283, - "extraInfo": "" - }, - { - "name": "FusedDepthwiseConv2D", - "bytesAdded": 1204224, - "totalBytesSnapshot": 20579628, - "tensorsAdded": 1, - "totalTensorsSnapshot": 111, - "inputShapes": [ - [ - 1, - 112, - 112, - 96 - ], - [ - 3, - 3, - 96, - 1 - ], - [ - 96 - ], - null - ], - "outputShapes": [ - [ - 1, - 56, - 56, - 96 - ] - ], - "kernelTimeMs": 5.435000006400514, - "extraInfo": "" - }, - { - "name": "fusedConv2d__op", - "bytesAdded": 62720, - "totalBytesSnapshot": 14809388, - "tensorsAdded": 1, - "totalTensorsSnapshot": 111, - "inputShapes": [ - [ - 1, - 7, - 7, - 960 - ], - [ - 1, - 1, - 960, - 320 - ], - [ - 320 - ] - ], - "outputShapes": [ - [ - 1, - 7, - 7, - 320 - ] - ], - "kernelTimeMs": 5.164999995031394, - "extraInfo": "" - }, - { - "name": "FusedConv2D", - "bytesAdded": 62720, - "totalBytesSnapshot": 14809388, - "tensorsAdded": 1, - "totalTensorsSnapshot": 111, - "inputShapes": [ - [ - 1, - 7, - 7, - 960 - ], - [ - 1, - 1, - 960, - 320 - ], - [ - 320 - ], - null - ], - "outputShapes": [ - [ - 1, - 7, - 7, - 320 - ] - ], - "kernelTimeMs": 5.0649999975576065, - "extraInfo": "" - }, - { - "name": "fusedConv2d__op", - "bytesAdded": 451584, - "totalBytesSnapshot": 15085356, - "tensorsAdded": 1, - "totalTensorsSnapshot": 111, - "inputShapes": [ - [ - 1, - 14, - 14, - 96 - ], - [ - 1, - 1, - 96, - 576 - ], - [ - 576 - ] - ], - "outputShapes": [ - [ - 1, - 14, - 14, - 576 - ] - ], - "kernelTimeMs": 4.634999997506384, - "extraInfo": "" - }, - { - "name": "fusedConv2d__op", - "bytesAdded": 451584, - "totalBytesSnapshot": 15085356, - "tensorsAdded": 1, - "totalTensorsSnapshot": 111, - "inputShapes": [ - [ - 1, - 14, - 14, - 96 - ], - [ - 1, - 1, - 96, - 576 - ], - [ - 576 - ] - ], - "outputShapes": [ - [ - 1, - 14, - 14, - 576 - ] - ], - "kernelTimeMs": 4.309999996621627, - "extraInfo": "" - }, - { - "name": "FusedConv2D", - "bytesAdded": 451584, - "totalBytesSnapshot": 15085356, - "tensorsAdded": 1, - "totalTensorsSnapshot": 111, - "inputShapes": [ - [ - 1, - 14, - 14, - 96 - ], - [ - 1, - 1, - 96, - 576 - ], - [ - 576 - ], - null - ], - "outputShapes": [ - [ - 1, - 14, - 14, - 576 - ] - ], - "kernelTimeMs": 4.285000002710149, - "extraInfo": "" - }, - { - "name": "fusedConv2d__op", - "bytesAdded": 451584, - "totalBytesSnapshot": 15085356, - "tensorsAdded": 1, - "totalTensorsSnapshot": 111, - "inputShapes": [ - [ - 1, - 14, - 14, - 96 - ], - [ - 1, - 1, - 96, - 576 - ], - [ - 576 - ] - ], - "outputShapes": [ - [ - 1, - 14, - 14, - 576 - ] - ], - "kernelTimeMs": 4.235000000335276, - "extraInfo": "" - }, - { - "name": "fusedConv2d__op", - "bytesAdded": 301056, - "totalBytesSnapshot": 16966956, - "tensorsAdded": 1, - "totalTensorsSnapshot": 112, - "inputShapes": [ - [ - 1, - 56, - 56, - 144 - ], - [ - 1, - 1, - 144, - 24 - ], - [ - 24 - ] - ], - "outputShapes": [ - [ - 1, - 56, - 56, - 24 - ] - ], - "kernelTimeMs": 4.229999998642597, - "extraInfo": "" - }, - { - "name": "FusedConv2D", - "bytesAdded": 451584, - "totalBytesSnapshot": 15085356, - "tensorsAdded": 1, - "totalTensorsSnapshot": 111, - "inputShapes": [ - [ - 1, - 14, - 14, - 96 - ], - [ - 1, - 1, - 96, - 576 - ], - [ - 576 - ], - null - ], - "outputShapes": [ - [ - 1, - 14, - 14, - 576 - ] - ], - "kernelTimeMs": 4.000000000814907, - "extraInfo": "" - }, - { - "name": "FusedConv2D", - "bytesAdded": 451584, - "totalBytesSnapshot": 15085356, - "tensorsAdded": 1, - "totalTensorsSnapshot": 111, - "inputShapes": [ - [ - 1, - 14, - 14, - 96 - ], - [ - 1, - 1, - 96, - 576 - ], - [ - 576 - ], - null - ], - "outputShapes": [ - [ - 1, - 14, - 14, - 576 - ] - ], - "kernelTimeMs": 3.9099999994505197, - "extraInfo": "" - }, - { - "name": "fusedConv2d__op", - "bytesAdded": 301056, - "totalBytesSnapshot": 16063788, - "tensorsAdded": 1, - "totalTensorsSnapshot": 111, - "inputShapes": [ - [ - 1, - 56, - 56, - 96 - ], - [ - 1, - 1, - 96, - 24 - ], - [ - 24 - ] - ], - "outputShapes": [ - [ - 1, - 56, - 56, - 24 - ] - ], - "kernelTimeMs": 3.9000000033411197, - "extraInfo": "" - }, - { - "name": "FusedConv2D", - "bytesAdded": 301056, - "totalBytesSnapshot": 16966956, - "tensorsAdded": 1, - "totalTensorsSnapshot": 112, - "inputShapes": [ - [ - 1, - 56, - 56, - 144 - ], - [ - 1, - 1, - 144, - 24 - ], - [ - 24 - ], - null - ], - "outputShapes": [ - [ - 1, - 56, - 56, - 24 - ] - ], - "kernelTimeMs": 3.8750000021536835, - "extraInfo": "" - }, - { - "name": "fusedConv2d__op", - "bytesAdded": 75264, - "totalBytesSnapshot": 15160620, - "tensorsAdded": 1, - "totalTensorsSnapshot": 112, - "inputShapes": [ - [ - 1, - 14, - 14, - 576 - ], - [ - 1, - 1, - 576, - 96 - ], - [ - 96 - ] - ], - "outputShapes": [ - [ - 1, - 14, - 14, - 96 - ] - ], - "kernelTimeMs": 3.7599999996018596, - "extraInfo": "" - }, - { - "name": "fusedConv2d__op", - "bytesAdded": 75264, - "totalBytesSnapshot": 15160620, - "tensorsAdded": 1, - "totalTensorsSnapshot": 112, - "inputShapes": [ - [ - 1, - 14, - 14, - 576 - ], - [ - 1, - 1, - 576, - 96 - ], - [ - 96 - ] - ], - "outputShapes": [ - [ - 1, - 14, - 14, - 96 - ] - ], - "kernelTimeMs": 3.749999996216502, - "extraInfo": "" - }, - { - "name": "FusedConv2D", - "bytesAdded": 75264, - "totalBytesSnapshot": 15160620, - "tensorsAdded": 1, - "totalTensorsSnapshot": 112, - "inputShapes": [ - [ - 1, - 14, - 14, - 576 - ], - [ - 1, - 1, - 576, - 96 - ], - [ - 96 - ], - null - ], - "outputShapes": [ - [ - 1, - 14, - 14, - 96 - ] - ], - "kernelTimeMs": 3.635000000940636, - "extraInfo": "" - }, - { - "name": "FusedConv2D", - "bytesAdded": 75264, - "totalBytesSnapshot": 15160620, - "tensorsAdded": 1, - "totalTensorsSnapshot": 112, - "inputShapes": [ - [ - 1, - 14, - 14, - 576 - ], - [ - 1, - 1, - 576, - 96 - ], - [ - 96 - ], - null - ], - "outputShapes": [ - [ - 1, - 14, - 14, - 96 - ] - ], - "kernelTimeMs": 3.6249999975552782, - "extraInfo": "" - }, - { - "name": "fusedConv2d__op", - "bytesAdded": 31360, - "totalBytesSnapshot": 14809388, - "tensorsAdded": 1, - "totalTensorsSnapshot": 112, - "inputShapes": [ - [ - 1, - 7, - 7, - 960 - ], - [ - 1, - 1, - 960, - 160 - ], - [ - 160 - ] - ], - "outputShapes": [ - [ - 1, - 7, - 7, - 160 - ] - ], - "kernelTimeMs": 3.515000003972091, - "extraInfo": "" - }, - { - "name": "fusedConv2d__op", - "bytesAdded": 188160, - "totalBytesSnapshot": 14778028, - "tensorsAdded": 1, - "totalTensorsSnapshot": 111, - "inputShapes": [ - [ - 1, - 7, - 7, - 160 - ], - [ - 1, - 1, - 160, - 960 - ], - [ - 960 - ] - ], - "outputShapes": [ - [ - 1, - 7, - 7, - 960 - ] - ], - "kernelTimeMs": 3.0600000027334318, - "extraInfo": "" - }, - { - "name": "fusedConv2d__op", - "bytesAdded": 802816, - "totalBytesSnapshot": 16966956, - "tensorsAdded": 1, - "totalTensorsSnapshot": 111, - "inputShapes": [ - [ - 1, - 112, - 112, - 32 - ], - [ - 1, - 1, - 32, - 16 - ], - [ - 16 - ] - ], - "outputShapes": [ - [ - 1, - 112, - 112, - 16 - ] - ], - "kernelTimeMs": 3.059999995457474, - "extraInfo": "" - }, - { - "name": "fusedConv2d__op", - "bytesAdded": 188160, - "totalBytesSnapshot": 14778028, - "tensorsAdded": 1, - "totalTensorsSnapshot": 111, - "inputShapes": [ - [ - 1, - 7, - 7, - 160 - ], - [ - 1, - 1, - 160, - 960 - ], - [ - 960 - ] - ], - "outputShapes": [ - [ - 1, - 7, - 7, - 960 - ] - ], - "kernelTimeMs": 2.9900000008638017, - "extraInfo": "" - }, - { - "name": "FusedConv2D", - "bytesAdded": 301056, - "totalBytesSnapshot": 16063788, - "tensorsAdded": 1, - "totalTensorsSnapshot": 111, - "inputShapes": [ - [ - 1, - 56, - 56, - 96 - ], - [ - 1, - 1, - 96, - 24 - ], - [ - 24 - ], - null - ], - "outputShapes": [ - [ - 1, - 56, - 56, - 24 - ] - ], - "kernelTimeMs": 2.979999997478444, - "extraInfo": "" - }, - { - "name": "fusedConv2d__op", - "bytesAdded": 188160, - "totalBytesSnapshot": 14778028, - "tensorsAdded": 1, - "totalTensorsSnapshot": 111, - "inputShapes": [ - [ - 1, - 7, - 7, - 160 - ], - [ - 1, - 1, - 160, - 960 - ], - [ - 960 - ] - ], - "outputShapes": [ - [ - 1, - 7, - 7, - 960 - ] - ], - "kernelTimeMs": 2.9200000062701292, - "extraInfo": "" - }, - { - "name": "fusedDepthwiseConv2d__op", - "bytesAdded": 602112, - "totalBytesSnapshot": 15863084, - "tensorsAdded": 1, - "totalTensorsSnapshot": 112, - "inputShapes": [ - [ - 1, - 28, - 28, - 192 - ], - [ - 3, - 3, - 192, - 1 - ], - [ - 192 - ] - ], - "outputShapes": [ - [ - 1, - 28, - 28, - 192 - ] - ], - "kernelTimeMs": 2.905000001192093, - "extraInfo": "" - }, - { - "name": "fusedConv2d__op", - "bytesAdded": 31360, - "totalBytesSnapshot": 14809388, - "tensorsAdded": 1, - "totalTensorsSnapshot": 112, - "inputShapes": [ - [ - 1, - 7, - 7, - 960 - ], - [ - 1, - 1, - 960, - 160 - ], - [ - 160 - ] - ], - "outputShapes": [ - [ - 1, - 7, - 7, - 160 - ] - ], - "kernelTimeMs": 2.8149999998277053, - "extraInfo": "" - }, - { - "name": "FusedConv2D", - "bytesAdded": 188160, - "totalBytesSnapshot": 14778028, - "tensorsAdded": 1, - "totalTensorsSnapshot": 111, - "inputShapes": [ - [ - 1, - 7, - 7, - 160 - ], - [ - 1, - 1, - 160, - 960 - ], - [ - 960 - ], - null - ], - "outputShapes": [ - [ - 1, - 7, - 7, - 960 - ] - ], - "kernelTimeMs": 2.8149999998277053, - "extraInfo": "" - }, - { - "name": "FusedConv2D", - "bytesAdded": 188160, - "totalBytesSnapshot": 14778028, - "tensorsAdded": 1, - "totalTensorsSnapshot": 111, - "inputShapes": [ - [ - 1, - 7, - 7, - 160 - ], - [ - 1, - 1, - 160, - 960 - ], - [ - 960 - ], - null - ], - "outputShapes": [ - [ - 1, - 7, - 7, - 960 - ] - ], - "kernelTimeMs": 2.745000005234033, - "extraInfo": "" - }, - { - "name": "FusedConv2D", - "bytesAdded": 188160, - "totalBytesSnapshot": 14778028, - "tensorsAdded": 1, - "totalTensorsSnapshot": 111, - "inputShapes": [ - [ - 1, - 7, - 7, - 160 - ], - [ - 1, - 1, - 160, - 960 - ], - [ - 960 - ], - null - ], - "outputShapes": [ - [ - 1, - 7, - 7, - 960 - ] - ], - "kernelTimeMs": 2.740000003541354, - "extraInfo": "" - }, - { - "name": "FusedConv2D", - "bytesAdded": 31360, - "totalBytesSnapshot": 14809388, - "tensorsAdded": 1, - "totalTensorsSnapshot": 112, - "inputShapes": [ - [ - 1, - 7, - 7, - 960 - ], - [ - 1, - 1, - 960, - 160 - ], - [ - 160 - ], - null - ], - "outputShapes": [ - [ - 1, - 7, - 7, - 160 - ] - ], - "kernelTimeMs": 2.740000003541354, - "extraInfo": "" - }, - { - "name": "fusedConv2d__op", - "bytesAdded": 602112, - "totalBytesSnapshot": 15260972, - "tensorsAdded": 1, - "totalTensorsSnapshot": 111, - "inputShapes": [ - [ - 1, - 28, - 28, - 32 - ], - [ - 1, - 1, - 32, - 192 - ], - [ - 192 - ] - ], - "outputShapes": [ - [ - 1, - 28, - 28, - 192 - ] - ], - "kernelTimeMs": 2.6100000031874515, - "extraInfo": "" - }, - { - "name": "fusedConv2d__op", - "bytesAdded": 602112, - "totalBytesSnapshot": 15260972, - "tensorsAdded": 1, - "totalTensorsSnapshot": 111, - "inputShapes": [ - [ - 1, - 28, - 28, - 32 - ], - [ - 1, - 1, - 32, - 192 - ], - [ - 192 - ] - ], - "outputShapes": [ - [ - 1, - 28, - 28, - 192 - ] - ], - "kernelTimeMs": 2.5850000020000152, - "extraInfo": "" - }, - { - "name": "FusedConv2D", - "bytesAdded": 31360, - "totalBytesSnapshot": 14809388, - "tensorsAdded": 1, - "totalTensorsSnapshot": 112, - "inputShapes": [ - [ - 1, - 7, - 7, - 960 - ], - [ - 1, - 1, - 960, - 160 - ], - [ - 160 - ], - null - ], - "outputShapes": [ - [ - 1, - 7, - 7, - 160 - ] - ], - "kernelTimeMs": 2.5450000030105002, - "extraInfo": "" - }, - { - "name": "fusedConv2d__op", - "bytesAdded": 75264, - "totalBytesSnapshot": 14934828, - "tensorsAdded": 1, - "totalTensorsSnapshot": 111, - "inputShapes": [ - [ - 1, - 14, - 14, - 384 - ], - [ - 1, - 1, - 384, - 96 - ], - [ - 96 - ] - ], - "outputShapes": [ - [ - 1, - 14, - 14, - 96 - ] - ], - "kernelTimeMs": 2.505000004020985, - "extraInfo": "" - }, - { - "name": "FusedConv2D", - "bytesAdded": 802816, - "totalBytesSnapshot": 16966956, - "tensorsAdded": 1, - "totalTensorsSnapshot": 111, - "inputShapes": [ - [ - 1, - 112, - 112, - 32 - ], - [ - 1, - 1, - 32, - 16 - ], - [ - 16 - ], - null - ], - "outputShapes": [ - [ - 1, - 112, - 112, - 16 - ] - ], - "kernelTimeMs": 2.449999999953434, - "extraInfo": "" - }, - { - "name": "FusedConv2D", - "bytesAdded": 75264, - "totalBytesSnapshot": 14934828, - "tensorsAdded": 1, - "totalTensorsSnapshot": 111, - "inputShapes": [ - [ - 1, - 14, - 14, - 384 - ], - [ - 1, - 1, - 384, - 96 - ], - [ - 96 - ], - null - ], - "outputShapes": [ - [ - 1, - 14, - 14, - 96 - ] - ], - "kernelTimeMs": 2.40499999927124, - "extraInfo": "" - }, - { - "name": "fusedDepthwiseConv2d__op", - "bytesAdded": 602112, - "totalBytesSnapshot": 15863084, - "tensorsAdded": 1, - "totalTensorsSnapshot": 112, - "inputShapes": [ - [ - 1, - 28, - 28, - 192 - ], - [ - 3, - 3, - 192, - 1 - ], - [ - 192 - ] - ], - "outputShapes": [ - [ - 1, - 28, - 28, - 192 - ] - ], - "kernelTimeMs": 2.3050000017974526, - "extraInfo": "" - }, - { - "name": "fusedConv2d__op", - "bytesAdded": 301056, - "totalBytesSnapshot": 14909740, - "tensorsAdded": 1, - "totalTensorsSnapshot": 111, - "inputShapes": [ - [ - 1, - 14, - 14, - 64 - ], - [ - 1, - 1, - 64, - 384 - ], - [ - 384 - ] - ], - "outputShapes": [ - [ - 1, - 14, - 14, - 384 - ] - ], - "kernelTimeMs": 2.294999998412095, - "extraInfo": "" - }, - { - "name": "fusedConv2d__op", - "bytesAdded": 602112, - "totalBytesSnapshot": 15260972, - "tensorsAdded": 1, - "totalTensorsSnapshot": 111, - "inputShapes": [ - [ - 1, - 28, - 28, - 32 - ], - [ - 1, - 1, - 32, - 192 - ], - [ - 192 - ] - ], - "outputShapes": [ - [ - 1, - 28, - 28, - 192 - ] - ], - "kernelTimeMs": 2.2499999977299012, - "extraInfo": "" - }, - { - "name": "fusedConv2d__op", - "bytesAdded": 100352, - "totalBytesSnapshot": 15361324, - "tensorsAdded": 1, - "totalTensorsSnapshot": 112, - "inputShapes": [ - [ - 1, - 28, - 28, - 192 - ], - [ - 1, - 1, - 192, - 32 - ], - [ - 32 - ] - ], - "outputShapes": [ - [ - 1, - 28, - 28, - 32 - ] - ], - "kernelTimeMs": 2.2349999999278225, - "extraInfo": "" - }, - { - "name": "FusedConv2D", - "bytesAdded": 602112, - "totalBytesSnapshot": 15260972, - "tensorsAdded": 1, - "totalTensorsSnapshot": 111, - "inputShapes": [ - [ - 1, - 28, - 28, - 32 - ], - [ - 1, - 1, - 32, - 192 - ], - [ - 192 - ], - null - ], - "outputShapes": [ - [ - 1, - 28, - 28, - 192 - ] - ], - "kernelTimeMs": 2.1850000048289075, - "extraInfo": "" - }, - { - "name": "FusedConv2D", - "bytesAdded": 602112, - "totalBytesSnapshot": 15260972, - "tensorsAdded": 1, - "totalTensorsSnapshot": 111, - "inputShapes": [ - [ - 1, - 28, - 28, - 32 - ], - [ - 1, - 1, - 32, - 192 - ], - [ - 192 - ], - null - ], - "outputShapes": [ - [ - 1, - 28, - 28, - 192 - ] - ], - "kernelTimeMs": 2.1500000002561137, - "extraInfo": "" - }, - { - "name": "fusedConv2d__op", - "bytesAdded": 301056, - "totalBytesSnapshot": 14909740, - "tensorsAdded": 1, - "totalTensorsSnapshot": 111, - "inputShapes": [ - [ - 1, - 14, - 14, - 64 - ], - [ - 1, - 1, - 64, - 384 - ], - [ - 384 - ] - ], - "outputShapes": [ - [ - 1, - 14, - 14, - 384 - ] - ], - "kernelTimeMs": 2.1200000046519563, - "extraInfo": "" - }, - { - "name": "fusedConv2d__op", - "bytesAdded": 301056, - "totalBytesSnapshot": 14909740, - "tensorsAdded": 1, - "totalTensorsSnapshot": 111, - "inputShapes": [ - [ - 1, - 14, - 14, - 64 - ], - [ - 1, - 1, - 64, - 384 - ], - [ - 384 - ] - ], - "outputShapes": [ - [ - 1, - 14, - 14, - 384 - ] - ], - "kernelTimeMs": 2.1150000029592775, - "extraInfo": "" - }, - { - "name": "FusedConv2D", - "bytesAdded": 602112, - "totalBytesSnapshot": 15260972, - "tensorsAdded": 1, - "totalTensorsSnapshot": 111, - "inputShapes": [ - [ - 1, - 28, - 28, - 32 - ], - [ - 1, - 1, - 32, - 192 - ], - [ - 192 - ], - null - ], - "outputShapes": [ - [ - 1, - 28, - 28, - 192 - ] - ], - "kernelTimeMs": 2.099999997881241, - "extraInfo": "" - }, - { - "name": "FusedDepthwiseConv2D", - "bytesAdded": 602112, - "totalBytesSnapshot": 15863084, - "tensorsAdded": 1, - "totalTensorsSnapshot": 112, - "inputShapes": [ - [ - 1, - 28, - 28, - 192 - ], - [ - 3, - 3, - 192, - 1 - ], - [ - 192 - ], - null - ], - "outputShapes": [ - [ - 1, - 28, - 28, - 192 - ] - ], - "kernelTimeMs": 2.0949999961885624, - "extraInfo": "" - }, - { - "name": "fusedConv2d__op", - "bytesAdded": 301056, - "totalBytesSnapshot": 14909740, - "tensorsAdded": 1, - "totalTensorsSnapshot": 111, - "inputShapes": [ - [ - 1, - 14, - 14, - 64 - ], - [ - 1, - 1, - 64, - 384 - ], - [ - 384 - ] - ], - "outputShapes": [ - [ - 1, - 14, - 14, - 384 - ] - ], - "kernelTimeMs": 2.0750000039697625, - "extraInfo": "" - }, - { - "name": "FusedConv2D", - "bytesAdded": 301056, - "totalBytesSnapshot": 14909740, - "tensorsAdded": 1, - "totalTensorsSnapshot": 111, - "inputShapes": [ - [ - 1, - 14, - 14, - 64 - ], - [ - 1, - 1, - 64, - 384 - ], - [ - 384 - ], - null - ], - "outputShapes": [ - [ - 1, - 14, - 14, - 384 - ] - ], - "kernelTimeMs": 2.0099999965168536, - "extraInfo": "" - }, - { - "name": "fusedDepthwiseConv2d__op", - "bytesAdded": 451584, - "totalBytesSnapshot": 16816428, - "tensorsAdded": 1, - "totalTensorsSnapshot": 111, - "inputShapes": [ - [ - 1, - 56, - 56, - 144 - ], - [ - 3, - 3, - 144, - 1 - ], - [ - 144 - ] - ], - "outputShapes": [ - [ - 1, - 28, - 28, - 144 - ] - ], - "kernelTimeMs": 1.9949999987147748, - "extraInfo": "" - }, - { - "name": "FusedDepthwiseConv2D", - "bytesAdded": 602112, - "totalBytesSnapshot": 15863084, - "tensorsAdded": 1, - "totalTensorsSnapshot": 112, - "inputShapes": [ - [ - 1, - 28, - 28, - 192 - ], - [ - 3, - 3, - 192, - 1 - ], - [ - 192 - ], - null - ], - "outputShapes": [ - [ - 1, - 28, - 28, - 192 - ] - ], - "kernelTimeMs": 1.9949999987147748, - "extraInfo": "" - }, - { - "name": "FusedConv2D", - "bytesAdded": 301056, - "totalBytesSnapshot": 14909740, - "tensorsAdded": 1, - "totalTensorsSnapshot": 111, - "inputShapes": [ - [ - 1, - 14, - 14, - 64 - ], - [ - 1, - 1, - 64, - 384 - ], - [ - 384 - ], - null - ], - "outputShapes": [ - [ - 1, - 14, - 14, - 384 - ] - ], - "kernelTimeMs": 1.8899999995483086, - "extraInfo": "" - }, - { - "name": "FusedConv2D", - "bytesAdded": 301056, - "totalBytesSnapshot": 14909740, - "tensorsAdded": 1, - "totalTensorsSnapshot": 111, - "inputShapes": [ - [ - 1, - 14, - 14, - 64 - ], - [ - 1, - 1, - 64, - 384 - ], - [ - 384 - ], - null - ], - "outputShapes": [ - [ - 1, - 14, - 14, - 384 - ] - ], - "kernelTimeMs": 1.8850000051315874, - "extraInfo": "" - }, - { - "name": "FusedConv2D", - "bytesAdded": 301056, - "totalBytesSnapshot": 14909740, - "tensorsAdded": 1, - "totalTensorsSnapshot": 111, - "inputShapes": [ - [ - 1, - 14, - 14, - 64 - ], - [ - 1, - 1, - 64, - 384 - ], - [ - 384 - ], - null - ], - "outputShapes": [ - [ - 1, - 14, - 14, - 384 - ] - ], - "kernelTimeMs": 1.8449999988661148, - "extraInfo": "" - }, - { - "name": "fusedConv2d__op", - "bytesAdded": 50176, - "totalBytesSnapshot": 14959916, - "tensorsAdded": 1, - "totalTensorsSnapshot": 112, - "inputShapes": [ - [ - 1, - 14, - 14, - 384 - ], - [ - 1, - 1, - 384, - 64 - ], - [ - 64 - ] - ], - "outputShapes": [ - [ - 1, - 14, - 14, - 64 - ] - ], - "kernelTimeMs": 1.830000001064036, - "extraInfo": "" - }, - { - "name": "fusedConv2d__op", - "bytesAdded": 100352, - "totalBytesSnapshot": 15361324, - "tensorsAdded": 1, - "totalTensorsSnapshot": 112, - "inputShapes": [ - [ - 1, - 28, - 28, - 192 - ], - [ - 1, - 1, - 192, - 32 - ], - [ - 32 - ] - ], - "outputShapes": [ - [ - 1, - 28, - 28, - 32 - ] - ], - "kernelTimeMs": 1.7750000042724423, - "extraInfo": "" - }, - { - "name": "fusedConv2d__op", - "bytesAdded": 50176, - "totalBytesSnapshot": 14959916, - "tensorsAdded": 1, - "totalTensorsSnapshot": 112, - "inputShapes": [ - [ - 1, - 14, - 14, - 384 - ], - [ - 1, - 1, - 384, - 64 - ], - [ - 64 - ] - ], - "outputShapes": [ - [ - 1, - 14, - 14, - 64 - ] - ], - "kernelTimeMs": 1.7750000042724423, - "extraInfo": "" - }, - { - "name": "fusedDepthwiseConv2d__op", - "bytesAdded": 451584, - "totalBytesSnapshot": 15536940, - "tensorsAdded": 1, - "totalTensorsSnapshot": 112, - "inputShapes": [ - [ - 1, - 14, - 14, - 576 - ], - [ - 3, - 3, - 576, - 1 - ], - [ - 576 - ] - ], - "outputShapes": [ - [ - 1, - 14, - 14, - 576 - ] - ], - "kernelTimeMs": 1.7300000035902485, - "extraInfo": "" - }, - { - "name": "FusedConv2D", - "bytesAdded": 50176, - "totalBytesSnapshot": 14959916, - "tensorsAdded": 1, - "totalTensorsSnapshot": 112, - "inputShapes": [ - [ - 1, - 14, - 14, - 384 - ], - [ - 1, - 1, - 384, - 64 - ], - [ - 64 - ], - null - ], - "outputShapes": [ - [ - 1, - 14, - 14, - 64 - ] - ], - "kernelTimeMs": 1.7250000018975697, - "extraInfo": "" - }, - { - "name": "fusedConv2d__op", - "bytesAdded": 50176, - "totalBytesSnapshot": 14959916, - "tensorsAdded": 1, - "totalTensorsSnapshot": 112, - "inputShapes": [ - [ - 1, - 14, - 14, - 384 - ], - [ - 1, - 1, - 384, - 64 - ], - [ - 64 - ] - ], - "outputShapes": [ - [ - 1, - 14, - 14, - 64 - ] - ], - "kernelTimeMs": 1.7149999985122122, - "extraInfo": "" - }, - { - "name": "FusedConv2D", - "bytesAdded": 50176, - "totalBytesSnapshot": 14959916, - "tensorsAdded": 1, - "totalTensorsSnapshot": 112, - "inputShapes": [ - [ - 1, - 14, - 14, - 384 - ], - [ - 1, - 1, - 384, - 64 - ], - [ - 64 - ], - null - ], - "outputShapes": [ - [ - 1, - 14, - 14, - 64 - ] - ], - "kernelTimeMs": 1.6850000029080547, - "extraInfo": "" - }, - { - "name": "FusedConv2D", - "bytesAdded": 100352, - "totalBytesSnapshot": 15361324, - "tensorsAdded": 1, - "totalTensorsSnapshot": 112, - "inputShapes": [ - [ - 1, - 28, - 28, - 192 - ], - [ - 1, - 1, - 192, - 32 - ], - [ - 32 - ], - null - ], - "outputShapes": [ - [ - 1, - 28, - 28, - 32 - ] - ], - "kernelTimeMs": 1.640000002225861, - "extraInfo": "" - }, - { - "name": "FusedConv2D", - "bytesAdded": 100352, - "totalBytesSnapshot": 15361324, - "tensorsAdded": 1, - "totalTensorsSnapshot": 112, - "inputShapes": [ - [ - 1, - 28, - 28, - 192 - ], - [ - 1, - 1, - 192, - 32 - ], - [ - 32 - ], - null - ], - "outputShapes": [ - [ - 1, - 28, - 28, - 32 - ] - ], - "kernelTimeMs": 1.6350000005331822, - "extraInfo": "" - }, - { - "name": "fusedDepthwiseConv2d__op", - "bytesAdded": 451584, - "totalBytesSnapshot": 15536940, - "tensorsAdded": 1, - "totalTensorsSnapshot": 112, - "inputShapes": [ - [ - 1, - 14, - 14, - 576 - ], - [ - 3, - 3, - 576, - 1 - ], - [ - 576 - ] - ], - "outputShapes": [ - [ - 1, - 14, - 14, - 576 - ] - ], - "kernelTimeMs": 1.6200000027311035, - "extraInfo": "" - }, - { - "name": "FusedConv2D", - "bytesAdded": 50176, - "totalBytesSnapshot": 14959916, - "tensorsAdded": 1, - "totalTensorsSnapshot": 112, - "inputShapes": [ - [ - 1, - 14, - 14, - 384 - ], - [ - 1, - 1, - 384, - 64 - ], - [ - 64 - ], - null - ], - "outputShapes": [ - [ - 1, - 14, - 14, - 64 - ] - ], - "kernelTimeMs": 1.600000003236346, - "extraInfo": "" - }, - { - "name": "fusedConv2d__op", - "bytesAdded": 31360, - "totalBytesSnapshot": 14702764, - "tensorsAdded": 1, - "totalTensorsSnapshot": 111, - "inputShapes": [ - [ - 1, - 7, - 7, - 576 - ], - [ - 1, - 1, - 576, - 160 - ], - [ - 160 - ] - ], - "outputShapes": [ - [ - 1, - 7, - 7, - 160 - ] - ], - "kernelTimeMs": 1.600000003236346, - "extraInfo": "" - }, - { - "name": "FusedConv2D", - "bytesAdded": 31360, - "totalBytesSnapshot": 14702764, - "tensorsAdded": 1, - "totalTensorsSnapshot": 111, - "inputShapes": [ - [ - 1, - 7, - 7, - 576 - ], - [ - 1, - 1, - 576, - 160 - ], - [ - 160 - ], - null - ], - "outputShapes": [ - [ - 1, - 7, - 7, - 160 - ] - ], - "kernelTimeMs": 1.534999995783437, - "extraInfo": "" - }, - { - "name": "FusedDepthwiseConv2D", - "bytesAdded": 451584, - "totalBytesSnapshot": 16816428, - "tensorsAdded": 1, - "totalTensorsSnapshot": 111, - "inputShapes": [ - [ - 1, - 56, - 56, - 144 - ], - [ - 3, - 3, - 144, - 1 - ], - [ - 144 - ], - null - ], - "outputShapes": [ - [ - 1, - 28, - 28, - 144 - ] - ], - "kernelTimeMs": 1.4799999989918433, - "extraInfo": "" - }, - { - "name": "fusedConv2d__op", - "bytesAdded": 100352, - "totalBytesSnapshot": 15110444, - "tensorsAdded": 1, - "totalTensorsSnapshot": 111, - "inputShapes": [ - [ - 1, - 28, - 28, - 144 - ], - [ - 1, - 1, - 144, - 32 - ], - [ - 32 - ] - ], - "outputShapes": [ - [ - 1, - 28, - 28, - 32 - ] - ], - "kernelTimeMs": 1.4799999989918433, - "extraInfo": "" - }, - { - "name": "FusedDepthwiseConv2D", - "bytesAdded": 451584, - "totalBytesSnapshot": 15536940, - "tensorsAdded": 1, - "totalTensorsSnapshot": 112, - "inputShapes": [ - [ - 1, - 14, - 14, - 576 - ], - [ - 3, - 3, - 576, - 1 - ], - [ - 576 - ], - null - ], - "outputShapes": [ - [ - 1, - 14, - 14, - 576 - ] - ], - "kernelTimeMs": 1.405000002705492, - "extraInfo": "" - }, - { - "name": "FusedConv2D", - "bytesAdded": 100352, - "totalBytesSnapshot": 15110444, - "tensorsAdded": 1, - "totalTensorsSnapshot": 111, - "inputShapes": [ - [ - 1, - 28, - 28, - 144 - ], - [ - 1, - 1, - 144, - 32 - ], - [ - 32 - ], - null - ], - "outputShapes": [ - [ - 1, - 28, - 28, - 32 - ] - ], - "kernelTimeMs": 1.3249999974505045, - "extraInfo": "" - }, - { - "name": "FusedDepthwiseConv2D", - "bytesAdded": 451584, - "totalBytesSnapshot": 15536940, - "tensorsAdded": 1, - "totalTensorsSnapshot": 112, - "inputShapes": [ - [ - 1, - 14, - 14, - 576 - ], - [ - 3, - 3, - 576, - 1 - ], - [ - 576 - ], - null - ], - "outputShapes": [ - [ - 1, - 14, - 14, - 576 - ] - ], - "kernelTimeMs": 1.2600000045495108, - "extraInfo": "" - }, - { - "name": "fusedDepthwiseConv2d__op", - "bytesAdded": 301056, - "totalBytesSnapshot": 15210796, - "tensorsAdded": 1, - "totalTensorsSnapshot": 112, - "inputShapes": [ - [ - 1, - 14, - 14, - 384 - ], - [ - 3, - 3, - 384, - 1 - ], - [ - 384 - ] - ], - "outputShapes": [ - [ - 1, - 14, - 14, - 384 - ] - ], - "kernelTimeMs": 1.2500000011641532, - "extraInfo": "" - }, - { - "name": "fusedDepthwiseConv2d__op", - "bytesAdded": 301056, - "totalBytesSnapshot": 15210796, - "tensorsAdded": 1, - "totalTensorsSnapshot": 112, - "inputShapes": [ - [ - 1, - 14, - 14, - 384 - ], - [ - 3, - 3, - 384, - 1 - ], - [ - 384 - ] - ], - "outputShapes": [ - [ - 1, - 14, - 14, - 384 - ] - ], - "kernelTimeMs": 1.224999999976717, - "extraInfo": "" - }, - { - "name": "fusedDepthwiseConv2d__op", - "bytesAdded": 301056, - "totalBytesSnapshot": 15210796, - "tensorsAdded": 1, - "totalTensorsSnapshot": 112, - "inputShapes": [ - [ - 1, - 14, - 14, - 384 - ], - [ - 3, - 3, - 384, - 1 - ], - [ - 384 - ] - ], - "outputShapes": [ - [ - 1, - 14, - 14, - 384 - ] - ], - "kernelTimeMs": 1.2199999982840382, - "extraInfo": "" - }, - { - "name": "fusedDepthwiseConv2d__op", - "bytesAdded": 301056, - "totalBytesSnapshot": 15160620, - "tensorsAdded": 1, - "totalTensorsSnapshot": 111, - "inputShapes": [ - [ - 1, - 14, - 14, - 384 - ], - [ - 3, - 3, - 384, - 1 - ], - [ - 384 - ] - ], - "outputShapes": [ - [ - 1, - 14, - 14, - 384 - ] - ], - "kernelTimeMs": 1.1299999969196506, - "extraInfo": "" - }, - { - "name": "FusedDepthwiseConv2D", - "bytesAdded": 301056, - "totalBytesSnapshot": 15210796, - "tensorsAdded": 1, - "totalTensorsSnapshot": 112, - "inputShapes": [ - [ - 1, - 14, - 14, - 384 - ], - [ - 3, - 3, - 384, - 1 - ], - [ - 384 - ], - null - ], - "outputShapes": [ - [ - 1, - 14, - 14, - 384 - ] - ], - "kernelTimeMs": 1.0150000016437843, - "extraInfo": "" - }, - { - "name": "FusedDepthwiseConv2D", - "bytesAdded": 301056, - "totalBytesSnapshot": 15210796, - "tensorsAdded": 1, - "totalTensorsSnapshot": 112, - "inputShapes": [ - [ - 1, - 14, - 14, - 384 - ], - [ - 3, - 3, - 384, - 1 - ], - [ - 384 - ], - null - ], - "outputShapes": [ - [ - 1, - 14, - 14, - 384 - ] - ], - "kernelTimeMs": 1.0000000038417056, - "extraInfo": "" - }, - { - "name": "FusedDepthwiseConv2D", - "bytesAdded": 301056, - "totalBytesSnapshot": 15210796, - "tensorsAdded": 1, - "totalTensorsSnapshot": 112, - "inputShapes": [ - [ - 1, - 14, - 14, - 384 - ], - [ - 3, - 3, - 384, - 1 - ], - [ - 384 - ], - null - ], - "outputShapes": [ - [ - 1, - 14, - 14, - 384 - ] - ], - "kernelTimeMs": 0.9700000009615906, - "extraInfo": "" - }, - { - "name": "Sub", - "bytesAdded": 602112, - "totalBytesSnapshot": 15762732, - "tensorsAdded": 1, - "totalTensorsSnapshot": 111, - "inputShapes": [ - [ - 1, - 224, - 224, - 3 - ], - [] - ], - "outputShapes": [ - [ - 1, - 224, - 224, - 3 - ] - ], - "kernelTimeMs": 0.9400000053574331, - "extraInfo": "" - }, - { - "name": "Multiply", - "bytesAdded": 602112, - "totalBytesSnapshot": 15160620, - "tensorsAdded": 1, - "totalTensorsSnapshot": 110, - "inputShapes": [ - [ - 1, - 224, - 224, - 3 - ], - [] - ], - "outputShapes": [ - [ - 1, - 224, - 224, - 3 - ] - ], - "kernelTimeMs": 0.9399999980814755, - "extraInfo": "" - }, - { - "name": "fusedConv2d__op", - "bytesAdded": 50176, - "totalBytesSnapshot": 14759212, - "tensorsAdded": 1, - "totalTensorsSnapshot": 111, - "inputShapes": [ - [ - 1, - 14, - 14, - 192 - ], - [ - 1, - 1, - 192, - 64 - ], - [ - 64 - ] - ], - "outputShapes": [ - [ - 1, - 14, - 14, - 64 - ] - ], - "kernelTimeMs": 0.9149999968940392, - "extraInfo": "" - }, - { - "name": "FusedDepthwiseConv2D", - "bytesAdded": 301056, - "totalBytesSnapshot": 15160620, - "tensorsAdded": 1, - "totalTensorsSnapshot": 111, - "inputShapes": [ - [ - 1, - 14, - 14, - 384 - ], - [ - 3, - 3, - 384, - 1 - ], - [ - 384 - ], - null - ], - "outputShapes": [ - [ - 1, - 14, - 14, - 384 - ] - ], - "kernelTimeMs": 0.8950000046752393, - "extraInfo": "" - }, - { - "name": "fusedDepthwiseConv2d__op", - "bytesAdded": 188160, - "totalBytesSnapshot": 14966188, - "tensorsAdded": 1, - "totalTensorsSnapshot": 112, - "inputShapes": [ - [ - 1, - 7, - 7, - 960 - ], - [ - 3, - 3, - 960, - 1 - ], - [ - 960 - ] - ], - "outputShapes": [ - [ - 1, - 7, - 7, - 960 - ] - ], - "kernelTimeMs": 0.8349999989150092, - "extraInfo": "" - }, - { - "name": "FusedConv2D", - "bytesAdded": 50176, - "totalBytesSnapshot": 14759212, - "tensorsAdded": 1, - "totalTensorsSnapshot": 111, - "inputShapes": [ - [ - 1, - 14, - 14, - 192 - ], - [ - 1, - 1, - 192, - 64 - ], - [ - 64 - ], - null - ], - "outputShapes": [ - [ - 1, - 14, - 14, - 64 - ] - ], - "kernelTimeMs": 0.8299999972223304, - "extraInfo": "" - }, - { - "name": "fusedDepthwiseConv2d__op", - "bytesAdded": 188160, - "totalBytesSnapshot": 14934828, - "tensorsAdded": 1, - "totalTensorsSnapshot": 111, - "inputShapes": [ - [ - 1, - 7, - 7, - 960 - ], - [ - 3, - 3, - 960, - 1 - ], - [ - 960 - ] - ], - "outputShapes": [ - [ - 1, - 7, - 7, - 960 - ] - ], - "kernelTimeMs": 0.7949999999254942, - "extraInfo": "" - }, - { - "name": "fusedDepthwiseConv2d__op", - "bytesAdded": 188160, - "totalBytesSnapshot": 14966188, - "tensorsAdded": 1, - "totalTensorsSnapshot": 112, - "inputShapes": [ - [ - 1, - 7, - 7, - 960 - ], - [ - 3, - 3, - 960, - 1 - ], - [ - 960 - ] - ], - "outputShapes": [ - [ - 1, - 7, - 7, - 960 - ] - ], - "kernelTimeMs": 0.7299999997485429, - "extraInfo": "" - }, - { - "name": "fusedConv2d__op", - "bytesAdded": 4004, - "totalBytesSnapshot": 14567632, - "tensorsAdded": 1, - "totalTensorsSnapshot": 111, - "inputShapes": [ - [ - 1, - 1, - 1, - 1280 - ], - [ - 1, - 1, - 1280, - 1001 - ], - [ - 1001 - ] - ], - "outputShapes": [ - [ - 1, - 1, - 1, - 1001 - ] - ], - "kernelTimeMs": 0.6849999990663491, - "extraInfo": "" - }, - { - "name": "FusedDepthwiseConv2D", - "bytesAdded": 188160, - "totalBytesSnapshot": 14966188, - "tensorsAdded": 1, - "totalTensorsSnapshot": 112, - "inputShapes": [ - [ - 1, - 7, - 7, - 960 - ], - [ - 3, - 3, - 960, - 1 - ], - [ - 960 - ], - null - ], - "outputShapes": [ - [ - 1, - 7, - 7, - 960 - ] - ], - "kernelTimeMs": 0.6599999978789128, - "extraInfo": "" - }, - { - "name": "FusedDepthwiseConv2D", - "bytesAdded": 188160, - "totalBytesSnapshot": 14934828, - "tensorsAdded": 1, - "totalTensorsSnapshot": 111, - "inputShapes": [ - [ - 1, - 7, - 7, - 960 - ], - [ - 3, - 3, - 960, - 1 - ], - [ - 960 - ], - null - ], - "outputShapes": [ - [ - 1, - 7, - 7, - 960 - ] - ], - "kernelTimeMs": 0.6100000027799979, - "extraInfo": "" - }, - { - "name": "FusedConv2D", - "bytesAdded": 4004, - "totalBytesSnapshot": 14567632, - "tensorsAdded": 1, - "totalTensorsSnapshot": 111, - "inputShapes": [ - [ - 1, - 1, - 1, - 1280 - ], - [ - 1, - 1, - 1280, - 1001 - ], - [ - 1001 - ], - null - ], - "outputShapes": [ - [ - 1, - 1, - 1, - 1001 - ] - ], - "kernelTimeMs": 0.6100000027799979, - "extraInfo": "" - }, - { - "name": "fusedDepthwiseConv2d__op", - "bytesAdded": 150528, - "totalBytesSnapshot": 15311148, - "tensorsAdded": 1, - "totalTensorsSnapshot": 111, - "inputShapes": [ - [ - 1, - 28, - 28, - 192 - ], - [ - 3, - 3, - 192, - 1 - ], - [ - 192 - ] - ], - "outputShapes": [ - [ - 1, - 14, - 14, - 192 - ] - ], - "kernelTimeMs": 0.6099999955040403, - "extraInfo": "" - }, - { - "name": "FusedDepthwiseConv2D", - "bytesAdded": 188160, - "totalBytesSnapshot": 14966188, - "tensorsAdded": 1, - "totalTensorsSnapshot": 112, - "inputShapes": [ - [ - 1, - 7, - 7, - 960 - ], - [ - 3, - 3, - 960, - 1 - ], - [ - 960 - ], - null - ], - "outputShapes": [ - [ - 1, - 7, - 7, - 960 - ] - ], - "kernelTimeMs": 0.5500000042957254, - "extraInfo": "" - }, - { - "name": "fusedDepthwiseConv2d__op", - "bytesAdded": 112896, - "totalBytesSnapshot": 15122988, - "tensorsAdded": 1, - "totalTensorsSnapshot": 111, - "inputShapes": [ - [ - 1, - 14, - 14, - 576 - ], - [ - 3, - 3, - 576, - 1 - ], - [ - 576 - ] - ], - "outputShapes": [ - [ - 1, - 7, - 7, - 576 - ] - ], - "kernelTimeMs": 0.4800000024260953, - "extraInfo": "" - }, - { - "name": "FusedDepthwiseConv2D", - "bytesAdded": 150528, - "totalBytesSnapshot": 15311148, - "tensorsAdded": 1, - "totalTensorsSnapshot": 111, - "inputShapes": [ - [ - 1, - 28, - 28, - 192 - ], - [ - 3, - 3, - 192, - 1 - ], - [ - 192 - ], - null - ], - "outputShapes": [ - [ - 1, - 14, - 14, - 192 - ] - ], - "kernelTimeMs": 0.41000000055646524, - "extraInfo": "" - }, - { - "name": "FusedDepthwiseConv2D", - "bytesAdded": 112896, - "totalBytesSnapshot": 15122988, - "tensorsAdded": 1, - "totalTensorsSnapshot": 111, - "inputShapes": [ - [ - 1, - 14, - 14, - 576 - ], - [ - 3, - 3, - 576, - 1 - ], - [ - 576 - ], - null - ], - "outputShapes": [ - [ - 1, - 7, - 7, - 576 - ] - ], - "kernelTimeMs": 0.3599999981815927, - "extraInfo": "" - }, - { - "name": "Add", - "bytesAdded": 301056, - "totalBytesSnapshot": 15461676, - "tensorsAdded": 1, - "totalTensorsSnapshot": 112, - "inputShapes": [ - [ - 1, - 56, - 56, - 24 - ], - [ - 1, - 56, - 56, - 24 - ] - ], - "outputShapes": [ - [ - 1, - 56, - 56, - 24 - ] - ], - "kernelTimeMs": 0.18000000272877514, - "extraInfo": "" - }, - { - "name": "AvgPool", - "bytesAdded": 5120, - "totalBytesSnapshot": 14814508, - "tensorsAdded": 1, - "totalTensorsSnapshot": 111, - "inputShapes": [ - [ - 1, - 7, - 7, - 1280 - ] - ], - "outputShapes": [ - [ - 1, - 1, - 1, - 1280 - ] - ], - "kernelTimeMs": 0.1049999991664663, - "extraInfo": "" - }, - { - "name": "Add", - "bytesAdded": 100352, - "totalBytesSnapshot": 14859564, - "tensorsAdded": 1, - "totalTensorsSnapshot": 112, - "inputShapes": [ - [ - 1, - 28, - 28, - 32 - ], - [ - 1, - 28, - 28, - 32 - ] - ], - "outputShapes": [ - [ - 1, - 28, - 28, - 32 - ] - ], - "kernelTimeMs": 0.09500000305706635, - "extraInfo": "" - }, - { - "name": "Add", - "bytesAdded": 100352, - "totalBytesSnapshot": 14859564, - "tensorsAdded": 1, - "totalTensorsSnapshot": 112, - "inputShapes": [ - [ - 1, - 28, - 28, - 32 - ], - [ - 1, - 28, - 28, - 32 - ] - ], - "outputShapes": [ - [ - 1, - 28, - 28, - 32 - ] - ], - "kernelTimeMs": 0.09499999578110874, - "extraInfo": "" - }, - { - "name": "Add", - "bytesAdded": 31360, - "totalBytesSnapshot": 14652588, - "tensorsAdded": 1, - "totalTensorsSnapshot": 112, - "inputShapes": [ - [ - 1, - 7, - 7, - 160 - ], - [ - 1, - 7, - 7, - 160 - ] - ], - "outputShapes": [ - [ - 1, - 7, - 7, - 160 - ] - ], - "kernelTimeMs": 0.09499999578110874, - "extraInfo": "" - }, - { - "name": "Add", - "bytesAdded": 75264, - "totalBytesSnapshot": 14784300, - "tensorsAdded": 1, - "totalTensorsSnapshot": 112, - "inputShapes": [ - [ - 1, - 14, - 14, - 96 - ], - [ - 1, - 14, - 14, - 96 - ] - ], - "outputShapes": [ - [ - 1, - 14, - 14, - 96 - ] - ], - "kernelTimeMs": 0.07999999797903001, - "extraInfo": "" - }, - { - "name": "Add", - "bytesAdded": 50176, - "totalBytesSnapshot": 14709036, - "tensorsAdded": 1, - "totalTensorsSnapshot": 112, - "inputShapes": [ - [ - 1, - 14, - 14, - 64 - ], - [ - 1, - 14, - 14, - 64 - ] - ], - "outputShapes": [ - [ - 1, - 14, - 14, - 64 - ] - ], - "kernelTimeMs": 0.07500000356230885, - "extraInfo": "" - }, - { - "name": "Add", - "bytesAdded": 75264, - "totalBytesSnapshot": 14784300, - "tensorsAdded": 1, - "totalTensorsSnapshot": 112, - "inputShapes": [ - [ - 1, - 14, - 14, - 96 - ], - [ - 1, - 14, - 14, - 96 - ] - ], - "outputShapes": [ - [ - 1, - 14, - 14, - 96 - ] - ], - "kernelTimeMs": 0.07499999628635123, - "extraInfo": "" - }, - { - "name": "Add", - "bytesAdded": 50176, - "totalBytesSnapshot": 14709036, - "tensorsAdded": 1, - "totalTensorsSnapshot": 112, - "inputShapes": [ - [ - 1, - 14, - 14, - 64 - ], - [ - 1, - 14, - 14, - 64 - ] - ], - "outputShapes": [ - [ - 1, - 14, - 14, - 64 - ] - ], - "kernelTimeMs": 0.07000000186963007, - "extraInfo": "" - }, - { - "name": "Add", - "bytesAdded": 50176, - "totalBytesSnapshot": 14709036, - "tensorsAdded": 1, - "totalTensorsSnapshot": 112, - "inputShapes": [ - [ - 1, - 14, - 14, - 64 - ], - [ - 1, - 14, - 14, - 64 - ] - ], - "outputShapes": [ - [ - 1, - 14, - 14, - 64 - ] - ], - "kernelTimeMs": 0.06500000017695129, - "extraInfo": "" - }, - { - "name": "Add", - "bytesAdded": 31360, - "totalBytesSnapshot": 14652588, - "tensorsAdded": 1, - "totalTensorsSnapshot": 112, - "inputShapes": [ - [ - 1, - 7, - 7, - 160 - ], - [ - 1, - 7, - 7, - 160 - ] - ], - "outputShapes": [ - [ - 1, - 7, - 7, - 160 - ] - ], - "kernelTimeMs": 0.05999999848427251, - "extraInfo": "" - }, - { - "name": "Cast", - "bytesAdded": 5120, - "totalBytesSnapshot": 14819628, - "tensorsAdded": 1, - "totalTensorsSnapshot": 112, - "inputShapes": [ - [ - 1, - 1, - 1, - 1280 - ] - ], - "outputShapes": [ - [ - 1, - 1, - 1, - 1280 - ] - ], - "kernelTimeMs": 0.030000002880115062, - "extraInfo": "" - }, - { - "name": "Identity", - "bytesAdded": 4004, - "totalBytesSnapshot": 14566516, - "tensorsAdded": 1, - "totalTensorsSnapshot": 111, - "inputShapes": [ - [ - 1, - 1001 - ] - ], - "outputShapes": [ - [ - 1, - 1001 - ] - ], - "kernelTimeMs": 0.029999995604157448, - "extraInfo": "" - }, - { - "name": "Reshape", - "bytesAdded": 4004, - "totalBytesSnapshot": 14566516, - "tensorsAdded": 1, - "totalTensorsSnapshot": 111, - "inputShapes": [ - [ - 1, - 1, - 1, - 1001 - ] - ], - "outputShapes": [ - [ - 1, - 1001 - ] - ], - "kernelTimeMs": 0.019999999494757503, - "extraInfo": "" - } - ], - "kernelNames": [ - "fusedConv2d__op", - "FusedConv2D", - "fusedDepthwiseConv2d__op", - "FusedDepthwiseConv2D", - "Sub", - "Multiply", - "Add", - "AvgPool", - "Cast", - "Identity", - "Reshape" - ], - "aggregatedKernels": [ - { - "name": "fusedConv2d__op", - "timeMs": 139.04500002536224 - }, - { - "name": "FusedConv2D", - "timeMs": 120.01000002055662 - }, - { - "name": "fusedDepthwiseConv2d__op", - "timeMs": 41.514999997161794 - }, - { - "name": "FusedDepthwiseConv2D", - "timeMs": 33.85000002162997 - }, - { - "name": "Sub", - "timeMs": 0.9400000053574331 - }, - { - "name": "Multiply", - "timeMs": 0.9399999980814755 - }, - { - "name": "Add", - "timeMs": 0.8899999957066029 - }, - { - "name": "AvgPool", - "timeMs": 0.1049999991664663 - }, - { - "name": "Cast", - "timeMs": 0.030000002880115062 - }, - { - "name": "Identity", - "timeMs": 0.029999995604157448 - }, - { - "name": "Reshape", - "timeMs": 0.019999999494757503 - } - ] - }, - "deviceInfo": { - "base": "BrowserStack", - "browser": "chrome", - "browser_version": "103.0", - "device": null, - "os": "OS X", - "os_version": "Monterey" - }, - "tabId": "OS_X_Catalina_1", - "gpuInfo": "ANGLE (ATI Technologies Inc., AMD Radeon Pro 5300M OpenGL Engine, OpenGL 4.1)" -} diff --git a/tfjs-master/e2e/benchmarks/browserstack-benchmark/index.html b/tfjs-master/e2e/benchmarks/browserstack-benchmark/index.html deleted file mode 100644 index 4f6010e41..000000000 --- a/tfjs-master/e2e/benchmarks/browserstack-benchmark/index.html +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/tfjs-master/e2e/benchmarks/browserstack-benchmark/index.js b/tfjs-master/e2e/benchmarks/browserstack-benchmark/index.js deleted file mode 100644 index bf5ee9574..000000000 --- a/tfjs-master/e2e/benchmarks/browserstack-benchmark/index.js +++ /dev/null @@ -1,735 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -const TUNABLE_BROWSER_FIELDS = - ['os', 'os_version', 'browser', 'browser_version', 'device']; -const WAITING_STATUS_COLOR = '#AAAAAA'; -const COMPLETE_STATUS_COLOR = '#357edd'; -const ERROR_STATUS_COLOR = '#e8564b'; -const DISABLED_BUTTON_OPACITY = 0.8; -const ENABLED_BUTTON_OPACITY = 1; - -/** - * Helps assign unique id for visor tabs. - * @type {Object} - */ -const visorTabNameCounter = {}; - -const state = { - isVisorInitiated: false, - isDatGuiHidden: false, - - // The following `browser` and `benchmark` fields are kept updated by dat.gui. - browser: { - base: 'BrowserStack', - browser: 'chrome', - browser_version: '103.0', - os: 'OS X', - os_version: 'Monterey', - device: 'null' - }, - benchmark: { - model: 'mobilenet_v2', - modelUrl: '', - numRuns: 10, - backend: 'webgl', - setupCodeSnippetEnv: - 'const img = tf.randomUniform([1, 240, 240, 3], 0, 1000); const filter = tf.randomUniform([3, 3, 3, 3], 0, 1000);', - codeSnippet: - 'predict = () => { return tf.conv2d(img, filter, 2, \'same\');};' - }, - - /** - * An array of browser configurations, used to record the browsers to - * benchmark in this round. - * @type {!Array>} - */ - browsers: [], - - /** - * The id for the visor tab that is used to show the summary for the incoming - * round of benchmark (has not started). - * @type {string} - */ - summaryTabId: getTabId(), - - addBrowser: () => { - // Add browser config to `state.browsers` array. - state.browsers.push({ ...state.browser }); - - // Enable the benchmark button. - benchmarkButton.__li.style.pointerEvents = ''; - benchmarkButton.__li.style.opacity = ENABLED_BUTTON_OPACITY; - - // Initialize tfvis, if it is the first call. - initVisor(); - // (Re-)draw the browser list table, based on the current browsers. - drawTunableBrowserSummaryTable(state.summaryTabId, state.browsers); - }, - - removeBrowser: index => { - if (index >= state.browsers.length) { - throw new Error( - `Invalid index ${index}, while the state.browsers only ` + - `has ${state.browsers.length} items.`); - } - - // Remove the browser from the `state.browsers` array. - state.browsers.splice(index, 1); - - if (state.browsers.length === 0) { - // Disable the benchmark button. - benchmarkButton.__li.style.pointerEvents = 'none'; - benchmarkButton.__li.style.opacity = DISABLED_BUTTON_OPACITY; - } - - // Re-draw the browser list table, based on the current browsers. - drawTunableBrowserSummaryTable(state.summaryTabId, state.browsers); - }, - - clearBrowsers: () => { - state.browsers.splice(0, state.browsers.length); - - // Disable the benchmark button. - benchmarkButton.__li.style.pointerEvents = 'none'; - benchmarkButton.__li.style.opacity = DISABLED_BUTTON_OPACITY; - }, - - run: () => { - // Disable the 'Add browser' button. - addingBrowserButton.__li.style.pointerEvents = 'none'; - addingBrowserButton.__li.style.opacity = DISABLED_BUTTON_OPACITY; - - // Initialize tfvis, if it is the first call. - initVisor(); - - // Build 'tabId - browser config' map (one of benchmark config arguments). - const browserTabIdConfigMap = {}; - state.browsers.forEach(browser => { - const tabId = createTab(browser); - if (browser.device === 'null') { - browser.device = null; - } - browserTabIdConfigMap[tabId] = browser; - }); - - const benchmark = { ...state.benchmark }; - if (state.benchmark.model !== 'custom') { - delete benchmark['modelUrl']; - } - - // Send the configuration object to the server to start the benchmark. - socket.emit('run', { - summaryTabId: state.summaryTabId, - benchmark, - browsers: browserTabIdConfigMap, - }); - - // Re-draw the browser list table (untunable) with tabId. - drawUntunableBrowserSummaryTable(state.summaryTabId, browserTabIdConfigMap); - - // Prepare for the next round benchmark. - state.summaryTabId = getTabId(); - state.clearBrowsers(); - } -}; - -let socket; - -// UI controllers. -let gui; -let browserFolder; -let benchmarkButton; -let addingBrowserButton; -let browserSettingControllers = []; - -// Available BrowserStack's browsers will be collected in a tree when the array -// of available browsers is recieved in runtime. -let browserTreeRoot; - -/** - * Collect all given browsers to a tree. The field of each level is defined by - * `TUNABLE_BROWSER_FIELDS`. - * - * The tree node is implemented by Map/Object: - * - For non-leaf nodes, each node stores a map: each key is the index to a - * child node and the correspoding value is the child node. - * - For leaf nodes, each leaf node stores the full configuration for a certain - * browser. - * - * @param {Array} browsersArray An array of browser configurations. - */ -function constructBrowserTree(browsersArray) { - const browserTreeRoot = {}; - browsersArray.forEach(browser => { - let currentNode = browserTreeRoot; - - // Route through non-leaf nodes. - for (let fieldIndex = 0; fieldIndex <= TUNABLE_BROWSER_FIELDS.length - 2; - fieldIndex++) { - const fieldName = TUNABLE_BROWSER_FIELDS[fieldIndex]; - if (currentNode[browser[fieldName]] == null) { - currentNode[browser[fieldName]] = {}; - } - currentNode = currentNode[browser[fieldName]]; - } - - // Set the full configuration as the leaf node. - const leafFieldName = - TUNABLE_BROWSER_FIELDS[TUNABLE_BROWSER_FIELDS.length - 1]; - const leafFieldValue = browser[leafFieldName]; - if (currentNode[leafFieldValue] == null) { - currentNode[leafFieldValue] = browser; - } else { - console.warn( - `The browser ${browser} shares the same ` + - 'configuration with another browser.'); - } - }); - return browserTreeRoot; -} - -/** - * Once the value of a certain browser field is changed, the values and options - * of the following fields will be invalid. This function updates the following - * fields recursively and does nothing for the leaf nodes. - * - * @param {number} currentFieldIndex - * @param {string} currentFieldValue - * @param {object} currentNode - */ -function updateFollowingFields( - currentFieldIndex, currentFieldValue, currentNode) { - const nextFieldIndex = currentFieldIndex + 1; - if (nextFieldIndex === TUNABLE_BROWSER_FIELDS.length) { - return; - } - - const nextFieldName = TUNABLE_BROWSER_FIELDS[nextFieldIndex]; - const nextNode = currentNode[currentFieldValue]; - const nextFieldAvailableValues = Object.keys(nextNode); - let nextFieldValue = state.browser[nextFieldName]; - - // Update the value of the next field, if the old value is not applicable. - if (nextNode[nextFieldValue] == null) { - nextFieldValue = nextFieldAvailableValues[0]; - } - - // Update the options for the next field. - const nextFieldController = browserSettingControllers[nextFieldIndex].options( - nextFieldAvailableValues); - - // When updating options for a dat.gui controller, a new controller instacne - // will be created, so we need to bind the event again and record the new - // controller. - nextFieldController.onFinishChange(() => { - const newValue = state.browser[nextFieldName]; - updateFollowingFields(nextFieldIndex, newValue, nextNode); - }); - browserSettingControllers[nextFieldIndex] = nextFieldController; - - nextFieldController.setValue(nextFieldValue); - - if (nextFieldValue === 'null') { - nextFieldController.__li.hidden = true; - } else { - nextFieldController.__li.hidden = false; - } - - updateFollowingFields(nextFieldIndex, nextFieldValue, nextNode); -} - -/** - * This is a wrapper function of `dat.gui.GUI.add()` with: - * - Binds the `finishChange` event to update the value and options for the - * controller of its child field. - * - Hides the dropdown menu, if the field is not applicable for this browser. - * - * @param {number} fieldIndex The index of the browser field to be shown. - * @param {object} currentNode The keys of this map are available values - * for this field. - */ -function showBrowserField(fieldIndex, currentNode) { - const fieldName = TUNABLE_BROWSER_FIELDS[fieldIndex]; - const fieldController = - browserFolder.add(state.browser, fieldName, Object.keys(currentNode)); - - fieldController.onFinishChange(() => { - const newValue = state.browser[fieldName]; - updateFollowingFields(fieldIndex, newValue, currentNode); - }); - - // Null represents the field is not applicable for this browser. For example, - // `browser_version` is normally not applicable for mobile devices. - if (state.browser[fieldName] === 'null') { - fieldController.__li.hidden = true; - } - - // The controller will be used to reset options when the value of its parent - // field is changed. - browserSettingControllers.push(fieldController); -} - -/** - * Create a tunable browser list table that can be used to remove browsers. - * - * This table is shown before benchmarking. - * - * @param {string} summaryTabId The summary tab id. - * @param {Array>} browsers A list of browsers to - * benchmark. The browser object should include fields in - * `TUNABLE_BROWSER_FIELDS`. - */ -function drawTunableBrowserSummaryTable(summaryTabId, browsers) { - const headers = [...TUNABLE_BROWSER_FIELDS, '']; - const values = []; - - for (let index = 0; index < browsers.length; index++) { - const browser = browsers[index]; - const row = []; - for (const fieldName of TUNABLE_BROWSER_FIELDS) { - if (browser[fieldName] == null || browser[fieldName] === 'null') { - row.push('-'); - } else { - row.push(browser[fieldName]); - } - } - - // Whenever a browser configuration is removed, this table will be re-drawn, - // so the index (the argument for state.removeBrowser) will be re-assigned. - const removeBrowserButtonElement = - ``; - row.push(removeBrowserButtonElement); - - values.push(row); - } - - const surface = { - name: 'Browsers to benchmark', - tab: summaryTabId, - styles: { width: '100%' } - }; - tfvis.render.table(surface, { headers, values }); -} - -/** - * Create a untunable browser list table, including tab ids. The tab id will be - * used in the following charts under this summary tab. - * - * This table is shown when it is benchmarking or the benchmark is complete. - * - * @param {string} summaryTabId The summary tab id. - * @param {!Object>} browserTabIdConfigMap A map - * of ' tabId - browser' pairs. - */ -function drawUntunableBrowserSummaryTable(summaryTabId, browserTabIdConfigMap) { - const headers = ['tabId', ...TUNABLE_BROWSER_FIELDS]; - const values = []; - for (const browserTabId in browserTabIdConfigMap) { - const browser = browserTabIdConfigMap[browserTabId]; - const row = [browserTabId]; - for (const fieldName of TUNABLE_BROWSER_FIELDS) { - row.push(browser[fieldName] || '-'); - } - values.push(row); - } - - const surface = { - name: 'Browsers to benchmark', - tab: summaryTabId, - styles: { width: '100%' } - }; - tfvis.render.table(surface, { headers, values }); -} - -function initVisor() { - if (state.isVisorInitiated) { - return; - } - state.isVisorInitiated = true; - - // Bind an event to visor's 'Maximize/Minimize' button. - const visorFullScreenButton = - tfvis.visor().el.getElementsByTagName('button')[0]; - const guiCloseButton = document.getElementsByClassName('close-button')[0]; - const originalGuiWidth = gui.domElement.style.width; - - // The following two bound events are to implemet: - // - When the visor is minimized, the controlled panel is hidden; - // - When the visor is maximized, the controlled panel appears; - gui.domElement.style.width = originalGuiWidth; - visorFullScreenButton.onclick = () => { - if (state.isDatGuiHidden) { - // When opening the controll panel, recover the size. - gui.open(); - gui.domElement.style.width = originalGuiWidth; - } else { - // When closing the controll panel, narrow the size. - gui.close(); - gui.domElement.style.width = '10%'; - } - state.isDatGuiHidden = !state.isDatGuiHidden; - }; - guiCloseButton.onclick = () => { - if (state.isDatGuiHidden) { - // When opening the controll panel, recover the size. - gui.domElement.style.width = originalGuiWidth; - } else { - // When closing the controll panel, narrow the size. - gui.domElement.style.width = '10%'; - } - tfvis.visor().toggleFullScreen(); - state.isDatGuiHidden = !state.isDatGuiHidden; - }; - - // If this button (hide visor) is exposed, then too much extra logics will be - // needed to tell the full story. - const visorHideButton = tfvis.visor().el.getElementsByTagName('button')[1]; - visorHideButton.style.display = 'none'; -} - -/** - * Generate a unique id/name for the given setting. tfvis uses tab name as the - * index for the tab. - * - * @param {?Object=} browserConf An object including fields in - * `TUNABLE_BROWSER_FIELDS`. - */ -function getTabId(browserConf) { - let baseName; - if (browserConf == null) { - // The tab is a summary tab. - baseName = 'Summary'; - } else if (browserConf.os === 'android' || browserConf.os === 'ios') { - // For mobile devices. - baseName = browserConf.device; - } else { - baseName = `${browserConf.os}_${browserConf.os_version}`; - } - baseName = baseName.split(' ').join('_'); - if (visorTabNameCounter[baseName] == null) { - visorTabNameCounter[baseName] = 0; - } - visorTabNameCounter[baseName] += 1; - return `${baseName}_${visorTabNameCounter[baseName]}`; -} - -function createTab(browserConf) { - const tabId = getTabId(browserConf); - - // For tfvis, the tab name is not only a name but also the index to the tab. - drawBrowserSettingTable(tabId, browserConf); - drawBenchmarkParameterTable(tabId); - - // Add a status indicator into the tab button. - const visorTabList = document.getElementsByClassName('tf-tab'); - const curTabElement = visorTabList[visorTabList.length - 1]; - const indicatorElement = document.createElement('span'); - indicatorElement.innerHTML = '.'; - indicatorElement.style.fontSize = '20px'; - indicatorElement.id = `${tabId}-indicator`; - curTabElement.appendChild(indicatorElement); - - setTabStatus(tabId, 'WAITING'); - addLoaderElement(tabId); - return tabId; -} - -function reportBenchmarkResult(benchmarkResult) { - const tabId = benchmarkResult.tabId; - removeLoaderElement(tabId); - - if (benchmarkResult.error != null) { - setTabStatus(tabId, 'ERROR'); - // TODO: show error message under the tab. - console.log(benchmarkResult.error); - } else { - setTabStatus(tabId, 'COMPLETE'); - drawInferenceTimeLineChart(benchmarkResult); - drawBenchmarkResultSummaryTable(benchmarkResult); - // TODO: draw a table for inference kernel information. - // This will be done, when we can get kernel timing info from - // `tf.profile()`. - } -} - -/** - * Set the status for the given tab. The status can be 'WAITING', 'COMPLETE' or - * 'ERROR'. - * - * @param {string} tabId The index element id of the tab. - * @param {string} status The status to be set for the tab. - */ -function setTabStatus(tabId, status) { - const indicatorElementId = `${tabId}-indicator`; - const indicatorElement = document.getElementById(indicatorElementId); - switch (status) { - case 'WAITING': - indicatorElement.style.color = WAITING_STATUS_COLOR; - break; - case 'COMPLETE': - indicatorElement.style.color = COMPLETE_STATUS_COLOR; - break; - case 'ERROR': - indicatorElement.style.color = ERROR_STATUS_COLOR; - break; - default: - throw new Error(`Undefined status: ${status}.`); - } -} - -/** - * Add a loader element under the tab page. - * - * @param {string} tabId - */ -function addLoaderElement(tabId) { - const surface = tfvis.visor().surface( - { name: 'Benchmark Summary', tab: tabId, styles: { width: '100%' } }); - const loaderElement = document.createElement('div'); - loaderElement.className = 'loader'; - loaderElement.id = `${tabId}-loader`; - surface.drawArea.appendChild(loaderElement); -} - -/** - * Remove the loader element under the tab page. - * - * @param {string} tabId - */ -function removeLoaderElement(tabId) { - const loaderElementId = `${tabId}-loader`; - const loaderElement = document.getElementById(loaderElementId); - if (loaderElement != null) { - loaderElement.remove(); - } -} - -function drawBenchmarkResultSummaryTable(benchmarkResult) { - const headers = ['Field', 'Value']; - const values = []; - - const { timeInfo, memoryInfo, tabId } = benchmarkResult; - const timeArray = benchmarkResult.timeInfo.times; - const numRuns = timeArray.length; - - if (numRuns >= 1) { - values.push(['1st inference time', printTime(timeArray[0])]); - if (numRuns >= 2) { - values.push(['2nd inference time', printTime(timeArray[1])]); - } - values.push([ - `Average inference time (${numRuns} runs) except the first`, - printTime(timeInfo.averageTimeExclFirst) - ]); - values.push(['Best time', printTime(timeInfo.minTime)]); - values.push(['Worst time', printTime(timeInfo.maxTime)]); - } - - values.push(['Peak memory', printMemory(memoryInfo.peakBytes)]); - values.push(['Leaked tensors', memoryInfo.newTensors]); - - values.push(['Number of kernels', memoryInfo.kernels.length]); - - if ('codeSnippet' in benchmarkResult) { - values.push(['Code snippet', benchmarkResult.codeSnippet]); - } - - const surface = { - name: 'Benchmark Summary', - tab: tabId, - styles: { width: '100%' } - }; - tfvis.render.table(surface, { headers, values }); -} - -async function drawInferenceTimeLineChart(benchmarkResult) { - const inferenceTimeArray = benchmarkResult.timeInfo.times; - if (inferenceTimeArray.length <= 2) { - return; - } - - const tabId = benchmarkResult.tabId; - const values = []; - inferenceTimeArray.forEach((time, index) => { - // The first inference time is much larger than other times for webgl, - // skewing the scaling, so it is removed from the line chart. - if (index === 0) { - return; - } - values.push({ x: index + 1, y: time }); - }); - - const surface = { - name: `2nd - ${inferenceTimeArray.length}st Inference Time`, - tab: tabId, - styles: { width: '100%' } - }; - const data = { values }; - const drawOptions = - { zoomToFit: true, xLabel: '', yLabel: 'time (ms)', xType: 'ordinal' }; - - await tfvis.render.linechart(surface, data, drawOptions); - - // Whenever resize the parent div element, re-draw the chart canvas. - try { - const originalCanvasHeight = tfvis.visor() - .surface(surface) - .drawArea.getElementsByTagName('canvas')[0] - .height; - const labelElement = tfvis.visor().surface(surface).label; - - new ResizeObserver(() => { - // Keep the height of chart/canvas unchanged. - tfvis.visor() - .surface(surface) - .drawArea.getElementsByTagName('canvas')[0] - .height = originalCanvasHeight; - tfvis.render.linechart(surface, data, drawOptions); - }).observe(labelElement); - } catch (e) { - console.warn(`The browser does not support the ResizeObserver API: ${e}`); - } -} - -function drawBrowserSettingTable(tabId, browserConf) { - const headers = ['Field', 'Value']; - const values = []; - for (const fieldName of TUNABLE_BROWSER_FIELDS) { - if (browserConf[fieldName] != null && browserConf[fieldName] !== 'null') { - const row = [fieldName, browserConf[fieldName]]; - values.push(row); - } - } - const surface = { - name: 'Browser Setting', - tab: tabId, - styles: { width: '100%' } - }; - tfvis.render.table(surface, { headers, values }); -} - -function drawBenchmarkParameterTable(tabId) { - const headers = ['Field', 'Value']; - const values = []; - - for (const entry of Object.entries(state.benchmark)) { - if (entry[1] != null && entry[1] !== '') { - values.push(entry); - } - } - - const surface = { - name: 'Benchmark Parameter', - tab: tabId, - styles: { width: '100%' } - }; - tfvis.render.table(surface, { headers, values }); -} - -function showModelSelection() { - const modelFolder = gui.addFolder('Model'); - let modelUrlController = null; - - modelFolder - .add( - state.benchmark, 'model', [...Object.keys(benchmarks), 'codeSnippet']) - .name('model name') - .onChange(async model => { - if (model === 'custom') { - if (modelUrlController === null) { - modelUrlController = modelFolder.add(state.benchmark, 'modelUrl'); - modelUrlController.domElement.querySelector('input').placeholder = - 'https://your-domain.com/model-path/model.json'; - } - } else if (modelUrlController != null) { - modelFolder.remove(modelUrlController); - modelUrlController = null; - } - }); - modelFolder.open(); - return modelFolder; -} - -function showParameterSettings() { - const parameterFolder = gui.addFolder('Parameters'); - parameterFolder.add(state.benchmark, 'numRuns'); - parameterFolder.add(state.benchmark, 'backend', ['wasm', 'webgl', 'cpu']); - parameterFolder.open(); - return parameterFolder; -} - -function printTime(elapsed) { - return `${elapsed.toFixed(1)} ms`; -} - -function printMemory(bytes) { - if (bytes < 1024) { - return `${bytes} B`; - } else if (bytes < 1024 * 1024) { - return `${(bytes / 1024).toFixed(2)} KB`; - } else { - return `${(bytes / (1024 * 1024)).toFixed(2)} MB`; - } -} - -function onPageLoad() { - gui = new dat.gui.GUI({ width: 400 }); - gui.domElement.id = 'gui'; - socket = io(); - - // Once the server is connected, the server will send back all - // BrowserStack's available browsers in an array. - socket.on('availableBrowsers', availableBrowsersArray => { - if (browserTreeRoot == null) { - // Build UI folders. - showModelSelection(); - showParameterSettings(); - browserFolder = gui.addFolder('Browser'); - - // Initialize the browser tree. - browserTreeRoot = constructBrowserTree(availableBrowsersArray); - - // Show browser settings. - let currentNode = browserTreeRoot; - TUNABLE_BROWSER_FIELDS.forEach((field, index) => { - showBrowserField(index, currentNode); - currentNode = currentNode[state.browser[field]]; - }); - browserFolder.open(); - - // Enable users to benchmark. - addingBrowserButton = - browserFolder.add(state, 'addBrowser').name('Add browser'); - benchmarkButton = gui.add(state, 'run').name('Run benchmark'); - - // Disable the 'Run benchmark' button until a browser is added. - benchmarkButton.__li.style.pointerEvents = 'none'; - benchmarkButton.__li.style.opacity = DISABLED_BUTTON_OPACITY; - } - }); - - socket.on('benchmarkComplete', benchmarkResult => { - // Enable the 'Add browser' button. - addingBrowserButton.__li.style.pointerEvents = ''; - addingBrowserButton.__li.style.opacity = ENABLED_BUTTON_OPACITY; - - reportBenchmarkResult(benchmarkResult); - - // TODO: We can add a summary for the benchmark results in this round. - }); -} diff --git a/tfjs-master/e2e/benchmarks/browserstack-benchmark/index_test.js b/tfjs-master/e2e/benchmarks/browserstack-benchmark/index_test.js deleted file mode 100644 index 0d1bf91ca..000000000 --- a/tfjs-master/e2e/benchmarks/browserstack-benchmark/index_test.js +++ /dev/null @@ -1,142 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -/** - * The unit tests in this file can be run by opening `./SpecRunner.html` in - * browser. - */ - -describe('constructBrowserTree', () => { - const mac = { - base: 'BrowserStack', - browser: 'firefox', - browser_version: '70.0', - os: 'OS X', - os_version: 'High Sierra', - device: 'null' - }; - const iphoneX = { - base: 'BrowserStack', - browser: 'ios', - browser_version: 'null', - os: 'ios', - os_version: '11.0', - device: 'iPhone X' - }; - - const expectedTree = { - 'OS X': {'High Sierra': {'firefox': {'70.0': {'null': mac}}}}, - 'ios': {'11.0': {'ios': {'null': {'iPhone X': iphoneX}}}} - }; - - it('constructs a tree', () => { - const browsersArray = [mac, iphoneX]; - expect(constructBrowserTree(browsersArray)).toEqual(expectedTree); - }); - - it('warns when finding duplicate nodes', () => { - const browsersArray = [mac, iphoneX, iphoneX]; - spyOn(console, 'warn'); - expect(constructBrowserTree(browsersArray)).toEqual(expectedTree); - expect(console.warn).toHaveBeenCalled(); - }); -}); - -describe('getTabId', () => { - const mac = { - base: 'BrowserStack', - browser: 'firefox', - browser_version: '70.0', - os: 'OS X', - os_version: 'High Sierra', - device: 'null' - }; - const iphoneX = { - base: 'BrowserStack', - browser: 'ios', - browser_version: 'null', - os: 'ios', - os_version: '11.0', - device: 'iPhone X' - }; - - it('gives different names for the same browser configs', () => { - const name1 = getTabId(mac); - const name2 = getTabId(mac); - expect(name1).not.toBe(name2); - }); - - it('for mobile devices, uses device name as part of the tab name', () => { - const mobileName = getTabId(iphoneX); - expect(mobileName).toContain('iPhone_X'); - }); - - it('for desktop devices, uses OS name as part of the tab name', () => { - const desktopName = getTabId(mac); - expect(desktopName).toContain('OS_X'); - expect(desktopName).toContain('High_Sierra'); - }); - - it('assigns unique summary names for undefined config', () => { - expect(state.summaryTabId).toBe('Summary_1'); - expect(getTabId()).toBe('Summary_2'); - expect(getTabId()).toBe('Summary_3'); - }); -}); - -describe('state methods', () => { - beforeAll(() => { - this.originalInitVisor = initVisor; - this.originalDrawTunableBrowserSummaryTable = - drawTunableBrowserSummaryTable; - initVisor = jasmine.createSpy(); - drawTunableBrowserSummaryTable = jasmine.createSpy(); - }); - - beforeEach(() => { - gui = new dat.gui.GUI(); - benchmarkButton = gui.add(state, 'run').name('Run benchmark'); - }); - - afterEach(() => { - gui.destroy(); - }); - - afterAll(() => { - initVisor = this.originalInitVisor; - drawTunableBrowserSummaryTable = - this.originalDrawTunableBrowserSummaryTable; - }); - - it(`enables 'Run benchmark' button, when adding the first browser'`, () => { - state.addBrowser(); - - expect(benchmarkButton.__li.style.pointerEvents).toBe(''); - expect(benchmarkButton.__li.style.opacity) - .toBe(ENABLED_BUTTON_OPACITY.toString()); - }); - - it(`disables 'Run benchmark' button, when 'state.browsers' is empty'`, () => { - state.addBrowser(); - state.addBrowser(); - state.clearBrowsers(); - - expect(benchmarkButton.__li.style.pointerEvents).toBe('none'); - expect(benchmarkButton.__li.style.opacity) - .toBe(DISABLED_BUTTON_OPACITY.toString()); - }); -}); diff --git a/tfjs-master/e2e/benchmarks/browserstack-benchmark/karma.conf.js b/tfjs-master/e2e/benchmarks/browserstack-benchmark/karma.conf.js deleted file mode 100644 index cdff8cd25..000000000 --- a/tfjs-master/e2e/benchmarks/browserstack-benchmark/karma.conf.js +++ /dev/null @@ -1,108 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -const localRunConfig = { - reporters: ['progress'], - plugins: ['karma-jasmine', 'karma-chrome-launcher'], - browsers: ['Chrome'] -}; - -function getBrowserStackConfig() { - const browserstackConfig = { - hostname: 'bs-local.com', - plugins: ['karma-jasmine', 'karma-browserstack-launcher'], - reporters: ['progress', 'BrowserStack'], - port: 9200, - browserStack: { - username: process.env.BROWSERSTACK_USERNAME, - accessKey: process.env.BROWSERSTACK_ACCESS_KEY, - apiClientEndpoint: 'https://api.browserstack.com', - tunnelIdentifier: `e2e_browserstack_benchmark_${Date.now()}_${ - Math.floor(Math.random() * 1000)}` - }, - customLaunchers: {}, - browsers: [] - }; - - // The JSON file `./browsers.json` stores the `customLaunchers`. The key is - // tabId, while the value is specific browser setting. - const browsers = require('./browsers.json'); - browserstackConfig.customLaunchers = browsers; - return browserstackConfig; -} - -module.exports = function(config) { - let extraConfig = null; - if (config.browserstack) { - extraConfig = getBrowserStackConfig(); - } else { - extraConfig = localRunConfig; - } - - let localBuildableFiles = [ - 'tfjs-core/dist/tf-core.js', - 'tfjs-backend-cpu/dist/tf-backend-cpu.js', - 'tfjs-backend-webgl/dist/tf-backend-webgl.js', - 'tfjs-layers/dist/tf-layers.js', - 'tfjs-converter/dist/tf-converter.js', - 'tfjs-backend-wasm/dist/tf-backend-wasm.js', - 'tfjs-automl/dist/tf-automl.js', - ].map(url => { - let name = url.split('/')[0].replace('tfjs-', '').replace('backend-', ''); - if (config.localBuild?.includes(name)) { - return `../../../dist/bin/${url}`; - } else { - if (config.npmVersion){ - let version = config.npmVersion; - return `https://unpkg.com/@tensorflow/${url.replace('/', '@' + version + '/')}`; - } else { - return `https://unpkg.com/@tensorflow/${url.replace('/', '@latest/')}`; - } - } - }); - - let files = localBuildableFiles.concat([ - 'https://cdn.jsdelivr.net/npm/@tensorflow-models/universal-sentence-encoder@latest/dist/universal-sentence-encoder.min.js', - 'https://cdn.jsdelivr.net/npm/@tensorflow-models/speech-commands@latest/dist/speech-commands.min.js', - 'https://cdn.jsdelivr.net/npm/@tensorflow-models/posenet@latest/dist/posenet.min.js', - 'https://cdn.jsdelivr.net/npm/@tensorflow-models/body-pix@latest/dist/body-pix.min.js', - {pattern: './benchmark_parameters.json', included: false, served: true}, - '../util.js', '../benchmark_util.js', '../model_config.js', - 'benchmark_models.js' - ]); - - config.set({ - ...extraConfig, - frameworks: ['jasmine'], - files: files, - preprocessors: {}, - singleRun: true, - captureTimeout: 3e5, - reportSlowerThan: 500, - browserNoActivityTimeout: 1.2e5, - browserDisconnectTimeout: 1.2e5, - browserDisconnectTolerance: 0, - browserSocketTimeout: 1.2e5, - client: {jasmine: {random: false}}, - - // The following configurations are generated by karma - colors: true, - logLevel: config.LOG_INFO, - autoWatch: false, - concurrency: Infinity - }) -} diff --git a/tfjs-master/e2e/benchmarks/browserstack-benchmark/main.css b/tfjs-master/e2e/benchmarks/browserstack-benchmark/main.css deleted file mode 100644 index 586054173..000000000 --- a/tfjs-master/e2e/benchmarks/browserstack-benchmark/main.css +++ /dev/null @@ -1,58 +0,0 @@ -/** -* @license -* Copyright 2020 Google LLC. All Rights Reserved. -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* ============================================================================= -*/ - -.loader { - animation: spin 2s linear infinite; - -webkit-animation: spin 2s linear infinite; /* Safari */ - border: 5px solid #f3f3f3; - border-radius: 50%; - border-top: 5px solid #357edd; - height: 20px; - margin: auto; - width: 20px; -} - -/* Safari */ -@-webkit-keyframes spin { - 0% { -webkit-transform: rotate(0deg); } - 100% { -webkit-transform: rotate(360deg); } -} - -@keyframes spin { - 0% { transform: rotate(0deg); } - 100% { transform: rotate(360deg); } -} - -#gui { - left: 0px; - position: absolute; - top: 2px; -} - -th { - width: 50% !important; - text-align: center !important; -} - -td { - width: 50% !important; - text-align: center !important; -} - -.close-button{ - width: 100% !important; -} diff --git a/tfjs-master/e2e/benchmarks/browserstack-benchmark/package.json b/tfjs-master/e2e/benchmarks/browserstack-benchmark/package.json deleted file mode 100644 index 5f208b47b..000000000 --- a/tfjs-master/e2e/benchmarks/browserstack-benchmark/package.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "name": "@tensorflow/tfjs-benchmark", - "version": "0.0.1", - "description": "Benchmark models' and ops' performance", - "private": true, - "repository": { - "type": "git", - "url": "https://github.com/tensorflow/tfjs" - }, - "devDependencies": { - "@tensorflow/tfjs": "link:../../../tfjs", - "@tensorflow/tfjs-backend-wasm": "link:../../../link-package/node_modules/@tensorflow/tfjs-backend-wasm", - "argparse": "^2.0.1", - "firebase-admin": "^11.0.1", - "jasmine": "^3.7.0", - "karma": "^6.3.16", - "karma-browserstack-launcher": "^1.6.0", - "karma-chrome-launcher": "^3.1.0", - "karma-jasmine": "^3.3.1", - "socket.io": "~4.4.1" - }, - "staticFiles": { - "staticPath": "./node_modules/@tensorflow/tfjs-backend-wasm/dist", - "excludeGlob": [ - "**/!(*.wasm)" - ] - }, - "scripts": { - "test": "karma start", - "test-node": "jasmine app_node_test.js", - "build-all-deps": "yarn build-all-link-packages && yarn build-tfjs", - "build-tfjs": "cd ../../../tfjs && yarn && yarn build-npm", - "build-all-link-packages": "cd ../../../ && yarn && cd ./link-package && yarn build", - "build-individual-link-package": "cd ../../../ && yarn && cd ./link-package && yarn build-deps-for", - "run-cloud-benchmarks": "node app.js --benchmark='./preconfigured_browser.json' --cloud --maxBenchmarks=12 --firestore", - "run-cloud-benchmarks-half-month-cycle": "yarn run-cloud-benchmarks --period=15" - }, - "license": "Apache-2.0", - "engines": { - "yarn": ">= 1.0.0" - }, - "resolutions": { - "node-fetch": "2.6.7", - "minimist": "1.2.6" - }, - "dependencies": { - "@tensorflow/tfjs-vis": "^1.5.1", - "JSONStream": "^1.3.5" - } -} diff --git a/tfjs-master/e2e/benchmarks/browserstack-benchmark/preconfigured_browser.json b/tfjs-master/e2e/benchmarks/browserstack-benchmark/preconfigured_browser.json deleted file mode 100644 index b216c0c55..000000000 --- a/tfjs-master/e2e/benchmarks/browserstack-benchmark/preconfigured_browser.json +++ /dev/null @@ -1,151 +0,0 @@ -{ - "benchmark": { - "model": ["MobileNetV3", "MobileNetV2", "HandPoseDetector", - "HandPoseLandmark", "MoveNet-SinglePose", "MoveNet-MultiPose", - "BlazePoseDetector", "BlazePoseLandmark", "Coco-SSD", "DeepLabV3", - "FaceDetection", "FaceLandmarkDetection", "ArPortraitDepth", - "SelfieSegmentation-General", "SelfieSegmentation-Landscape", - "AutoML Image", "AutoML Object", "USE - batchsize 30", "USE - batchsize 1", - "TextToxicity", "MobileBert", "posenet", "bodypix", "speech-commands"], - "numRuns": 10, - "backend": ["webgl"] - }, - "browsers": { - "iPhone_13_Pro_Max_1": { - "base": "BrowserStack", - "os": "ios", - "os_version": "15", - "browser": "iphone", - "device": "iPhone 13 Pro Max", - "browser_version": null - }, - "iPhone_13_1": { - "base": "BrowserStack", - "os": "ios", - "os_version": "15", - "browser": "iphone", - "device": "iPhone 13", - "browser_version": null - }, - "iPhone_12_Pro_Max_1": { - "base": "BrowserStack", - "browser": "iphone", - "browser_version": null, - "os": "ios", - "os_version": "14", - "device": "iPhone 12 Pro Max" - }, - "iPhone_12_1": { - "base": "BrowserStack", - "browser": "iphone", - "browser_version": null, - "os": "ios", - "os_version": "14", - "device": "iPhone 12" - }, - "iPhone_11_Pro_Max_1": { - "base": "BrowserStack", - "browser": "iphone", - "browser_version": null, - "os": "ios", - "os_version": "14", - "device": "iPhone 11 Pro Max" - }, - "iPhone_11_1": { - "base": "BrowserStack", - "browser": "iphone", - "browser_version": null, - "os": "ios", - "os_version": "14", - "device": "iPhone 11" - }, - "iPhone_XS_1": { - "base": "BrowserStack", - "browser": "iphone", - "browser_version": null, - "os": "ios", - "os_version": "15", - "device": "iPhone XS" - }, - "Google_Pixel_6_Pro_1": { - "base": "BrowserStack", - "browser": "android", - "browser_version": null, - "os": "android", - "os_version": "12.0", - "device": "Google Pixel 6 Pro" - }, - "Google_Pixel_5_1": { - "base": "BrowserStack", - "browser": "android", - "browser_version": null, - "os": "android", - "os_version": "12.0", - "device": "Google Pixel 5" - }, - "Samsung_Galaxy_S22_Ultra_1": { - "base": "BrowserStack", - "browser": "android", - "browser_version": null, - "os": "android", - "os_version": "12.0", - "device": "Samsung Galaxy S22 Ultra" - }, - "Samsung_Galaxy_M52_1": { - "base": "BrowserStack", - "browser": "android", - "browser_version": null, - "os": "android", - "os_version": "11.0", - "device": "Samsung Galaxy M52" - }, - "Samsung_Galaxy_A52_1": { - "base": "BrowserStack", - "browser": "android", - "browser_version": null, - "os": "android", - "os_version": "11.0", - "device": "Samsung Galaxy A52" - }, - "Xiaomi_Redmi_Note_11_1": { - "base": "BrowserStack", - "browser": "android", - "browser_version": null, - "os": "android", - "os_version": "11.0", - "device": "Xiaomi Redmi Note 11" - }, - "Samsung_Galaxy_Note_20_Ultra_1": { - "base": "BrowserStack", - "browser": "android", - "browser_version": null, - "os": "android", - "os_version": "10.0", - "device": "Samsung Galaxy Note 20 Ultra" - }, - "Samsung_Galaxy_A11_1": { - "base": "BrowserStack", - "browser": "android", - "browser_version": null, - "os": "android", - "os_version": "10.0", - "device": "Samsung Galaxy A11" - }, - "Google_Pixel_4_XL_1": { - "base": "BrowserStack", - "browser": "android", - "browser_version": null, - "os": "android", - "os_version": "10.0", - "device": "Google Pixel 4 XL" - }, - "Samsung_Galaxy_S10_Plus_1": { - "base": "BrowserStack", - "browser": "android", - "browser_version": null, - "os": "android", - "os_version": "9.0", - "device": "Samsung Galaxy S10 Plus" - } - } -} diff --git a/tfjs-master/e2e/benchmarks/browserstack-benchmark/promise_queue.js b/tfjs-master/e2e/benchmarks/browserstack-benchmark/promise_queue.js deleted file mode 100644 index d8484fe52..000000000 --- a/tfjs-master/e2e/benchmarks/browserstack-benchmark/promise_queue.js +++ /dev/null @@ -1,31 +0,0 @@ -class PromiseQueue { - queue = []; - running = 0; - - constructor(concurrency = Infinity) { - this.concurrency = concurrency; - } - - add(func) { - return new Promise((resolve, reject) => { - this.queue.push(async () => { - this.running++; - try { - resolve(await func()); - } finally { - this.running--; - this.run(); - } - }); - this.run(); - }); - } - - run() { - while (this.running < this.concurrency && this.queue.length > 0) { - this.queue.shift()(); - } - } -} - -module.exports = {PromiseQueue}; diff --git a/tfjs-master/e2e/benchmarks/browserstack-benchmark/test_config.json b/tfjs-master/e2e/benchmarks/browserstack-benchmark/test_config.json deleted file mode 100644 index 7a040afad..000000000 --- a/tfjs-master/e2e/benchmarks/browserstack-benchmark/test_config.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "summaryTabId": "Summary_1", - "benchmark": { "model": "face_detector", "numRuns": 10, "backend": "wasm" }, - "browsers": { - "iPhone_12_1": { - "base": "BrowserStack", - "browser": "iphone", - "browser_version": "null", - "os": "ios", - "os_version": "14", - "device": "iPhone 12" - }, - "Google_Pixel_5_1": { - "base": "BrowserStack", - "browser": "android", - "browser_version": "null", - "os": "android", - "os_version": "11.0", - "device": "Google Pixel 5" - } - } -} diff --git a/tfjs-master/e2e/benchmarks/browserstack-benchmark/yarn.lock b/tfjs-master/e2e/benchmarks/browserstack-benchmark/yarn.lock deleted file mode 100644 index 43d9360ff..000000000 --- a/tfjs-master/e2e/benchmarks/browserstack-benchmark/yarn.lock +++ /dev/null @@ -1,3428 +0,0 @@ -# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. -# yarn lockfile v1 - - -"@babel/parser@^7.9.4": - version "7.20.3" - resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.20.3.tgz#5358cf62e380cf69efcb87a7bb922ff88bfac6e2" - integrity sha512-OP/s5a94frIPXwjzEcv5S/tpQfc6XhxYUnmWpgdqMWGgYCuErA3SzozaRAMQgSZWKeTJxht9aWAkUY+0UzvOFg== - -"@colors/colors@1.5.0": - version "1.5.0" - resolved "https://registry.yarnpkg.com/@colors/colors/-/colors-1.5.0.tgz#bb504579c1cae923e6576a4f5da43d25f97bdbd9" - integrity sha512-ooWCrlZP11i8GImSjTHYHLkvFDP48nS4+204nGb1RiX/WXYHmJA2III9/e2DWVabCESdW7hBAEzHRqUn9OUVvQ== - -"@fastify/busboy@^1.1.0": - version "1.1.0" - resolved "https://registry.yarnpkg.com/@fastify/busboy/-/busboy-1.1.0.tgz#4472f856e2bb5a9ee34ad64b93891b73b73537ca" - integrity sha512-Fv854f94v0CzIDllbY3i/0NJPNBRNLDawf3BTYVGCe9VrIIs3Wi7AFx24F9NzCxdf0wyx/x0Q9kEVnvDOPnlxA== - dependencies: - text-decoding "^1.0.0" - -"@firebase/app-types@0.8.1": - version "0.8.1" - resolved "https://registry.yarnpkg.com/@firebase/app-types/-/app-types-0.8.1.tgz#4c7f916281aed570581fc667e3eb6cc730119a95" - integrity sha512-p75Ow3QhB82kpMzmOntv866wH9eZ3b4+QbUY+8/DA5Zzdf1c8Nsk8B7kbFpzJt4wwHMdy5LTF5YUnoTc1JiWkw== - -"@firebase/auth-interop-types@0.1.7": - version "0.1.7" - resolved "https://registry.yarnpkg.com/@firebase/auth-interop-types/-/auth-interop-types-0.1.7.tgz#82c8d431779916224d2af5cef6cec2042d830f28" - integrity sha512-yA/dTveGGPcc85JP8ZE/KZqfGQyQTBCV10THdI8HTlP1GDvNrhr//J5jAt58MlsCOaO3XmC4DqScPBbtIsR/EA== - -"@firebase/component@0.5.21": - version "0.5.21" - resolved "https://registry.yarnpkg.com/@firebase/component/-/component-0.5.21.tgz#bb10add24fe2ee59a61163a469d4711d8da4002d" - integrity sha512-12MMQ/ulfygKpEJpseYMR0HunJdlsLrwx2XcEs40M18jocy2+spyzHHEwegN3x/2/BLFBjR5247Etmz0G97Qpg== - dependencies: - "@firebase/util" "1.7.3" - tslib "^2.1.0" - -"@firebase/database-compat@^0.2.6": - version "0.2.10" - resolved "https://registry.yarnpkg.com/@firebase/database-compat/-/database-compat-0.2.10.tgz#fa4440db9f41a9a05112642504c1e6557a75b8be" - integrity sha512-fK+IgUUqVKcWK/gltzDU+B1xauCOfY6vulO8lxoNTkcCGlSxuTtwsdqjGkFmgFRMYjXFWWJ6iFcJ/vXahzwCtA== - dependencies: - "@firebase/component" "0.5.21" - "@firebase/database" "0.13.10" - "@firebase/database-types" "0.9.17" - "@firebase/logger" "0.3.4" - "@firebase/util" "1.7.3" - tslib "^2.1.0" - -"@firebase/database-types@0.9.17", "@firebase/database-types@^0.9.13": - version "0.9.17" - resolved "https://registry.yarnpkg.com/@firebase/database-types/-/database-types-0.9.17.tgz#4c248052b0a9ae052ba940e4996a0bfab25dc257" - integrity sha512-YQm2tCZyxNtEnlS5qo5gd2PAYgKCy69tUKwioGhApCFThW+mIgZs7IeYeJo2M51i4LCixYUl+CvnOyAnb/c3XA== - dependencies: - "@firebase/app-types" "0.8.1" - "@firebase/util" "1.7.3" - -"@firebase/database@0.13.10": - version "0.13.10" - resolved "https://registry.yarnpkg.com/@firebase/database/-/database-0.13.10.tgz#c24e0219490b9c1fabfb7b42cb45850e145fe56d" - integrity sha512-KRucuzZ7ZHQsRdGEmhxId5jyM2yKsjsQWF9yv0dIhlxYg0D8rCVDZc/waoPKA5oV3/SEIoptF8F7R1Vfe7BCQA== - dependencies: - "@firebase/auth-interop-types" "0.1.7" - "@firebase/component" "0.5.21" - "@firebase/logger" "0.3.4" - "@firebase/util" "1.7.3" - faye-websocket "0.11.4" - tslib "^2.1.0" - -"@firebase/logger@0.3.4": - version "0.3.4" - resolved "https://registry.yarnpkg.com/@firebase/logger/-/logger-0.3.4.tgz#8822dd3e9168be93c1bce0b4ac235e3b165a6a68" - integrity sha512-hlFglGRgZEwoyClZcGLx/Wd+zoLfGmbDkFx56mQt/jJ0XMbfPqwId1kiPl0zgdWZX+D8iH+gT6GuLPFsJWgiGw== - dependencies: - tslib "^2.1.0" - -"@firebase/util@1.7.3": - version "1.7.3" - resolved "https://registry.yarnpkg.com/@firebase/util/-/util-1.7.3.tgz#e71640b6b2970b754f947235ceb10cba3f70e62c" - integrity sha512-wxNqWbqokF551WrJ9BIFouU/V5SL1oYCGx1oudcirdhadnQRFH5v1sjgGL7cUV/UsekSycygphdrF2lxBxOYKg== - dependencies: - tslib "^2.1.0" - -"@google-cloud/firestore@^6.4.0": - version "6.4.1" - resolved "https://registry.yarnpkg.com/@google-cloud/firestore/-/firestore-6.4.1.tgz#3cd32ffb10a563a9c3c91236b51e49e4cd088393" - integrity sha512-5q4sl1XCL8NH2y82KZ4WQGHDOPnrSMYq3JpIeKD5C0OCSb4MfckOTB9LeAQ3p5tlL+7UsVRHj0SyzKz27XZJjw== - dependencies: - fast-deep-equal "^3.1.1" - functional-red-black-tree "^1.0.1" - google-gax "^3.5.1" - protobufjs "^7.0.0" - -"@google-cloud/paginator@^3.0.7": - version "3.0.7" - resolved "https://registry.yarnpkg.com/@google-cloud/paginator/-/paginator-3.0.7.tgz#fb6f8e24ec841f99defaebf62c75c2e744dd419b" - integrity sha512-jJNutk0arIQhmpUUQJPJErsojqo834KcyB6X7a1mxuic8i1tKXxde8E69IZxNZawRIlZdIK2QY4WALvlK5MzYQ== - dependencies: - arrify "^2.0.0" - extend "^3.0.2" - -"@google-cloud/projectify@^3.0.0": - version "3.0.0" - resolved "https://registry.yarnpkg.com/@google-cloud/projectify/-/projectify-3.0.0.tgz#302b25f55f674854dce65c2532d98919b118a408" - integrity sha512-HRkZsNmjScY6Li8/kb70wjGlDDyLkVk3KvoEo9uIoxSjYLJasGiCch9+PqRVDOCGUFvEIqyogl+BeqILL4OJHA== - -"@google-cloud/promisify@^3.0.0": - version "3.0.1" - resolved "https://registry.yarnpkg.com/@google-cloud/promisify/-/promisify-3.0.1.tgz#8d724fb280f47d1ff99953aee0c1669b25238c2e" - integrity sha512-z1CjRjtQyBOYL+5Qr9DdYIfrdLBe746jRTYfaYU6MeXkqp7UfYs/jX16lFFVzZ7PGEJvqZNqYUEtb1mvDww4pA== - -"@google-cloud/storage@^6.5.2": - version "6.7.0" - resolved "https://registry.yarnpkg.com/@google-cloud/storage/-/storage-6.7.0.tgz#c164d70e2b485b9db52e91fcf34609e047c1eeda" - integrity sha512-iEit3dvUhGQV3pPC8aci/Y+F6K2QJ/UvcXhymj8gnO8IYQfZSZvFf361yX4BWNUlbHzanUQVQdF9RvgEM8fwpw== - dependencies: - "@google-cloud/paginator" "^3.0.7" - "@google-cloud/projectify" "^3.0.0" - "@google-cloud/promisify" "^3.0.0" - abort-controller "^3.0.0" - async-retry "^1.3.3" - compressible "^2.0.12" - duplexify "^4.0.0" - ent "^2.2.0" - extend "^3.0.2" - gaxios "^5.0.0" - google-auth-library "^8.0.1" - mime "^3.0.0" - mime-types "^2.0.8" - p-limit "^3.0.1" - retry-request "^5.0.0" - teeny-request "^8.0.0" - uuid "^8.0.0" - -"@grpc/grpc-js@~1.7.0": - version "1.7.3" - resolved "https://registry.yarnpkg.com/@grpc/grpc-js/-/grpc-js-1.7.3.tgz#f2ea79f65e31622d7f86d4b4c9ae38f13ccab99a" - integrity sha512-H9l79u4kJ2PVSxUNA08HMYAnUBLj9v6KjYQ7SQ71hOZcEXhShE/y5iQCesP8+6/Ik/7i2O0a10bPquIcYfufog== - dependencies: - "@grpc/proto-loader" "^0.7.0" - "@types/node" ">=12.12.47" - -"@grpc/proto-loader@^0.7.0": - version "0.7.3" - resolved "https://registry.yarnpkg.com/@grpc/proto-loader/-/proto-loader-0.7.3.tgz#75a6f95b51b85c5078ac7394da93850c32d36bb8" - integrity sha512-5dAvoZwna2Py3Ef96Ux9jIkp3iZ62TUsV00p3wVBPNX5K178UbNi8Q7gQVqwXT1Yq9RejIGG9G2IPEo93T6RcA== - dependencies: - "@types/long" "^4.0.1" - lodash.camelcase "^4.3.0" - long "^4.0.0" - protobufjs "^7.0.0" - yargs "^16.2.0" - -"@panva/asn1.js@^1.0.0": - version "1.0.0" - resolved "https://registry.yarnpkg.com/@panva/asn1.js/-/asn1.js-1.0.0.tgz#dd55ae7b8129e02049f009408b97c61ccf9032f6" - integrity sha512-UdkG3mLEqXgnlKsWanWcgb6dOjUzJ+XC5f+aWw30qrtjxeNUSfKX1cd5FBzOaXQumoe9nIqeZUvrRJS03HCCtw== - -"@protobufjs/aspromise@^1.1.1", "@protobufjs/aspromise@^1.1.2": - version "1.1.2" - resolved "https://registry.yarnpkg.com/@protobufjs/aspromise/-/aspromise-1.1.2.tgz#9b8b0cc663d669a7d8f6f5d0893a14d348f30fbf" - integrity sha512-j+gKExEuLmKwvz3OgROXtrJ2UG2x8Ch2YZUxahh+s1F2HZ+wAceUNLkvy6zKCPVRkU++ZWQrdxsUeQXmcg4uoQ== - -"@protobufjs/base64@^1.1.2": - version "1.1.2" - resolved "https://registry.yarnpkg.com/@protobufjs/base64/-/base64-1.1.2.tgz#4c85730e59b9a1f1f349047dbf24296034bb2735" - integrity sha512-AZkcAA5vnN/v4PDqKyMR5lx7hZttPDgClv83E//FMNhR2TMcLUhfRUBHCmSl0oi9zMgDDqRUJkSxO3wm85+XLg== - -"@protobufjs/codegen@^2.0.4": - version "2.0.4" - resolved "https://registry.yarnpkg.com/@protobufjs/codegen/-/codegen-2.0.4.tgz#7ef37f0d010fb028ad1ad59722e506d9262815cb" - integrity sha512-YyFaikqM5sH0ziFZCN3xDC7zeGaB/d0IUb9CATugHWbd1FRFwWwt4ld4OYMPWu5a3Xe01mGAULCdqhMlPl29Jg== - -"@protobufjs/eventemitter@^1.1.0": - version "1.1.0" - resolved "https://registry.yarnpkg.com/@protobufjs/eventemitter/-/eventemitter-1.1.0.tgz#355cbc98bafad5978f9ed095f397621f1d066b70" - integrity sha512-j9ednRT81vYJ9OfVuXG6ERSTdEL1xVsNgqpkxMsbIabzSo3goCjDIveeGv5d03om39ML71RdmrGNjG5SReBP/Q== - -"@protobufjs/fetch@^1.1.0": - version "1.1.0" - resolved "https://registry.yarnpkg.com/@protobufjs/fetch/-/fetch-1.1.0.tgz#ba99fb598614af65700c1619ff06d454b0d84c45" - integrity sha512-lljVXpqXebpsijW71PZaCYeIcE5on1w5DlQy5WH6GLbFryLUrBD4932W/E2BSpfRJWseIL4v/KPgBFxDOIdKpQ== - dependencies: - "@protobufjs/aspromise" "^1.1.1" - "@protobufjs/inquire" "^1.1.0" - -"@protobufjs/float@^1.0.2": - version "1.0.2" - resolved "https://registry.yarnpkg.com/@protobufjs/float/-/float-1.0.2.tgz#5e9e1abdcb73fc0a7cb8b291df78c8cbd97b87d1" - integrity sha512-Ddb+kVXlXst9d+R9PfTIxh1EdNkgoRe5tOX6t01f1lYWOvJnSPDBlG241QLzcyPdoNTsblLUdujGSE4RzrTZGQ== - -"@protobufjs/inquire@^1.1.0": - version "1.1.0" - resolved "https://registry.yarnpkg.com/@protobufjs/inquire/-/inquire-1.1.0.tgz#ff200e3e7cf2429e2dcafc1140828e8cc638f089" - integrity sha512-kdSefcPdruJiFMVSbn801t4vFK7KB/5gd2fYvrxhuJYg8ILrmn9SKSX2tZdV6V+ksulWqS7aXjBcRXl3wHoD9Q== - -"@protobufjs/path@^1.1.2": - version "1.1.2" - resolved "https://registry.yarnpkg.com/@protobufjs/path/-/path-1.1.2.tgz#6cc2b20c5c9ad6ad0dccfd21ca7673d8d7fbf68d" - integrity sha512-6JOcJ5Tm08dOHAbdR3GrvP+yUUfkjG5ePsHYczMFLq3ZmMkAD98cDgcT2iA1lJ9NVwFd4tH/iSSoe44YWkltEA== - -"@protobufjs/pool@^1.1.0": - version "1.1.0" - resolved "https://registry.yarnpkg.com/@protobufjs/pool/-/pool-1.1.0.tgz#09fd15f2d6d3abfa9b65bc366506d6ad7846ff54" - integrity sha512-0kELaGSIDBKvcgS4zkjz1PeddatrjYcmMWOlAuAPwAeccUrPHdUqo/J6LiymHHEiJT5NrF1UVwxY14f+fy4WQw== - -"@protobufjs/utf8@^1.1.0": - version "1.1.0" - resolved "https://registry.yarnpkg.com/@protobufjs/utf8/-/utf8-1.1.0.tgz#a777360b5b39a1a2e5106f8e858f2fd2d060c570" - integrity sha512-Vvn3zZrhQZkkBE8LSuW3em98c0FwgO4nxzv6OdSxPKJIEKY2bGbHn+mhGIPerzI4twdxaP8/0+06HBpwf345Lw== - -"@socket.io/base64-arraybuffer@~1.0.2": - version "1.0.2" - resolved "https://registry.yarnpkg.com/@socket.io/base64-arraybuffer/-/base64-arraybuffer-1.0.2.tgz#568d9beae00b0d835f4f8c53fd55714986492e61" - integrity sha512-dOlCBKnDw4iShaIsH/bxujKTM18+2TOAsYz+KSc11Am38H4q5Xw8Bbz97ZYdrVNM+um3p7w86Bvvmcn9q+5+eQ== - -"@tensorflow/tfjs-backend-cpu@link:../../../link-package/node_modules/@tensorflow/link-package/node_modules/@tensorflow/tfjs-backend-cpu": - version "0.0.0" - -"@tensorflow/tfjs-backend-cpu@link:../../../link-package/node_modules/@tensorflow/tfjs-backend-cpu": - version "0.0.0" - uid "" - -"@tensorflow/tfjs-backend-wasm@link:../../../link-package/node_modules/@tensorflow/tfjs-backend-wasm": - version "0.0.0" - uid "" - -"@tensorflow/tfjs-backend-webgl@link:../../../link-package/node_modules/@tensorflow/tfjs-backend-webgl": - version "0.0.0" - uid "" - -"@tensorflow/tfjs-converter@link:../../../link-package/node_modules/@tensorflow/tfjs-converter": - version "0.0.0" - uid "" - -"@tensorflow/tfjs-core@link:../../../link-package/node_modules/@tensorflow/tfjs-core": - version "0.0.0" - uid "" - -"@tensorflow/tfjs-data@link:../../../link-package/node_modules/@tensorflow/tfjs-data": - version "0.0.0" - uid "" - -"@tensorflow/tfjs-layers@link:../../../link-package/node_modules/@tensorflow/tfjs-layers": - version "0.0.0" - uid "" - -"@tensorflow/tfjs-vis@^1.5.1": - version "1.5.1" - resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-vis/-/tfjs-vis-1.5.1.tgz#e959832ee42ed99f71b073a3e6cf8bbfe136e589" - integrity sha512-oNithKiR7VZaE+xUvz6Leww4TYEPhKi8j5xnEYvT3j7brK2Njdvril7UgFtZ8EYZBdeX6XNim5Eu3/23gTQ1dA== - dependencies: - d3-format "~1.3.0" - d3-selection "~1.3.0" - glamor "~2.20.40" - preact "~8.2.9" - vega "5.20.0" - vega-embed "6.17.0" - vega-lite "4.13.1" - -"@tensorflow/tfjs@link:../../../tfjs": - version "0.0.0" - uid "" - -"@tootallnate/once@2": - version "2.0.0" - resolved "https://registry.yarnpkg.com/@tootallnate/once/-/once-2.0.0.tgz#f544a148d3ab35801c1f633a7441fd87c2e484bf" - integrity sha512-XCuKFP5PS55gnMVu3dty8KPatLqUoy/ZYzDzAGCQ8JNFCkLXzmI7vNHCR+XpbZaMWQK/vQubr7PkYq8g470J/A== - -"@types/body-parser@*": - version "1.19.2" - resolved "https://registry.yarnpkg.com/@types/body-parser/-/body-parser-1.19.2.tgz#aea2059e28b7658639081347ac4fab3de166e6f0" - integrity sha512-ALYone6pm6QmwZoAgeyNksccT9Q4AWZQ6PvfwR37GT6r6FWUPguq6sUmNGSMV2Wr761oQoBxwGGa6DR5o1DC9g== - dependencies: - "@types/connect" "*" - "@types/node" "*" - -"@types/clone@~0.1.30": - version "0.1.30" - resolved "https://registry.yarnpkg.com/@types/clone/-/clone-0.1.30.tgz#e7365648c1b42136a59c7d5040637b3b5c83b614" - integrity sha1-5zZWSMG0ITalnH1QQGN7O1yDthQ= - -"@types/component-emitter@^1.2.10": - version "1.2.11" - resolved "https://registry.yarnpkg.com/@types/component-emitter/-/component-emitter-1.2.11.tgz#50d47d42b347253817a39709fef03ce66a108506" - integrity sha512-SRXjM+tfsSlA9VuG8hGO2nft2p8zjXCK1VcC6N4NXbBbYbSia9kzCChYQajIjzIqOOOuh5Ock6MmV2oux4jDZQ== - -"@types/connect@*": - version "3.4.35" - resolved "https://registry.yarnpkg.com/@types/connect/-/connect-3.4.35.tgz#5fcf6ae445e4021d1fc2219a4873cc73a3bb2ad1" - integrity sha512-cdeYyv4KWoEgpBISTxWvqYsVy444DOqehiF3fM3ne10AmJ62RSyNkUnxMJXHQWRQQX2eR94m5y1IZyDwBjV9FQ== - dependencies: - "@types/node" "*" - -"@types/cookie@^0.4.1": - version "0.4.1" - resolved "https://registry.yarnpkg.com/@types/cookie/-/cookie-0.4.1.tgz#bfd02c1f2224567676c1545199f87c3a861d878d" - integrity sha512-XW/Aa8APYr6jSVVA1y/DEIZX0/GMKLEVekNG727R8cs56ahETkRAy/3DR7+fJyh7oUgGwNQaRfXCun0+KbWY7Q== - -"@types/cors@^2.8.12": - version "2.8.12" - resolved "https://registry.yarnpkg.com/@types/cors/-/cors-2.8.12.tgz#6b2c510a7ad7039e98e7b8d3d6598f4359e5c080" - integrity sha512-vt+kDhq/M2ayberEtJcIN/hxXy1Pk+59g2FV/ZQceeaTyCtCucjL2Q7FXlFjtWn4n15KCr1NE2lNNFhp0lEThw== - -"@types/emscripten@~0.0.34": - version "0.0.34" - resolved "https://registry.yarnpkg.com/@types/emscripten/-/emscripten-0.0.34.tgz#12b4a344274fb102ff2f6c877b37587bc3e46008" - integrity sha512-QSb9ojDincskc+uKMI0KXp8e1NALFINCrMlp8VGKGcTSxeEyRTTKyjWw75NYrCZHUsVEEEpr1tYHpbtaC++/sQ== - -"@types/estree@^0.0.50": - version "0.0.50" - resolved "https://registry.yarnpkg.com/@types/estree/-/estree-0.0.50.tgz#1e0caa9364d3fccd2931c3ed96fdbeaa5d4cca83" - integrity sha512-C6N5s2ZFtuZRj54k2/zyRhNDjJwwcViAM3Nbm8zjBpbqAdZ00mr0CFxvSKeO8Y/e03WVFLpQMdHYVfUd6SB+Hw== - -"@types/express-serve-static-core@^4.17.18": - version "4.17.31" - resolved "https://registry.yarnpkg.com/@types/express-serve-static-core/-/express-serve-static-core-4.17.31.tgz#a1139efeab4e7323834bb0226e62ac019f474b2f" - integrity sha512-DxMhY+NAsTwMMFHBTtJFNp5qiHKJ7TeqOo23zVEM9alT1Ml27Q3xcTH0xwxn7Q0BbMcVEJOs/7aQtUWupUQN3Q== - dependencies: - "@types/node" "*" - "@types/qs" "*" - "@types/range-parser" "*" - -"@types/express@^4.17.14": - version "4.17.14" - resolved "https://registry.yarnpkg.com/@types/express/-/express-4.17.14.tgz#143ea0557249bc1b3b54f15db4c81c3d4eb3569c" - integrity sha512-TEbt+vaPFQ+xpxFLFssxUDXj5cWCxZJjIcB7Yg0k0GMHGtgtQgpvx/MUQUeAkNbA9AAGrwkAsoeItdTgS7FMyg== - dependencies: - "@types/body-parser" "*" - "@types/express-serve-static-core" "^4.17.18" - "@types/qs" "*" - "@types/serve-static" "*" - -"@types/fast-json-stable-stringify@^2.0.0": - version "2.1.0" - resolved "https://registry.yarnpkg.com/@types/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz#c4d9c003d546b7ca9496ea924e9e9faca72873b4" - integrity "sha1-xNnAA9VGt8qUluqSTp6frKcoc7Q= sha512-IyNhGHu71jH1jCXTHmafuoAAdsbBON3kDh7u/UUhLmjYgN5TYB54e1R8ckTCiIevl2UuZaCsi9XRxineY5yUjw==" - dependencies: - fast-json-stable-stringify "*" - -"@types/jsonwebtoken@^8.5.9": - version "8.5.9" - resolved "https://registry.yarnpkg.com/@types/jsonwebtoken/-/jsonwebtoken-8.5.9.tgz#2c064ecb0b3128d837d2764aa0b117b0ff6e4586" - integrity sha512-272FMnFGzAVMGtu9tkr29hRL6bZj4Zs1KZNeHLnKqAvp06tAIcarTMwOh8/8bz4FmKRcMxZhZNeUAQsNLoiPhg== - dependencies: - "@types/node" "*" - -"@types/linkify-it@*": - version "3.0.2" - resolved "https://registry.yarnpkg.com/@types/linkify-it/-/linkify-it-3.0.2.tgz#fd2cd2edbaa7eaac7e7f3c1748b52a19143846c9" - integrity sha512-HZQYqbiFVWufzCwexrvh694SOim8z2d+xJl5UNamcvQFejLY/2YUtzXHYi3cHdI7PMlS8ejH2slRAOJQ32aNbA== - -"@types/long@^4.0.0", "@types/long@^4.0.1": - version "4.0.2" - resolved "https://registry.yarnpkg.com/@types/long/-/long-4.0.2.tgz#b74129719fc8d11c01868010082d483b7545591a" - integrity sha512-MqTGEo5bj5t157U6fA/BiDynNkn0YknVdh48CMPkTSpFTVmvao5UQmm7uEF6xBEo7qIMAlY/JSleYaE6VOdpaA== - -"@types/markdown-it@^12.2.3": - version "12.2.3" - resolved "https://registry.yarnpkg.com/@types/markdown-it/-/markdown-it-12.2.3.tgz#0d6f6e5e413f8daaa26522904597be3d6cd93b51" - integrity sha512-GKMHFfv3458yYy+v/N8gjufHO6MSZKCOXpZc5GXIWWy8uldwfmPn98vp81gZ5f9SVw8YYBctgfJ22a2d7AOMeQ== - dependencies: - "@types/linkify-it" "*" - "@types/mdurl" "*" - -"@types/mdurl@*": - version "1.0.2" - resolved "https://registry.yarnpkg.com/@types/mdurl/-/mdurl-1.0.2.tgz#e2ce9d83a613bacf284c7be7d491945e39e1f8e9" - integrity sha512-eC4U9MlIcu2q0KQmXszyn5Akca/0jrQmwDRgpAMJai7qBWq4amIQhZyNau4VYGtCeALvW1/NtjzJJ567aZxfKA== - -"@types/mime@*": - version "3.0.1" - resolved "https://registry.yarnpkg.com/@types/mime/-/mime-3.0.1.tgz#5f8f2bca0a5863cb69bc0b0acd88c96cb1d4ae10" - integrity sha512-Y4XFY5VJAuw0FgAqPNd6NNoV44jbq9Bz2L7Rh/J6jLTiHBSBJa9fxqQIvkIld4GsoDOcCbvzOUAbLPsSKKg+uA== - -"@types/node-fetch@^2.1.2": - version "2.6.3" - resolved "https://registry.yarnpkg.com/@types/node-fetch/-/node-fetch-2.6.3.tgz#175d977f5e24d93ad0f57602693c435c57ad7e80" - integrity sha512-ETTL1mOEdq/sxUtgtOhKjyB2Irra4cjxksvcMUR5Zr4n+PxVhsCD9WS46oPbHL3et9Zde7CNRr+WUNlcHvsX+w== - dependencies: - "@types/node" "*" - form-data "^3.0.0" - -"@types/node@*": - version "18.11.9" - resolved "https://registry.yarnpkg.com/@types/node/-/node-18.11.9.tgz#02d013de7058cea16d36168ef2fc653464cfbad4" - integrity sha512-CRpX21/kGdzjOpFsZSkcrXMGIBWMGNIHXXBVFSH+ggkftxg+XYP20TESbh+zFvFj3EQOl5byk0HTRn1IL6hbqg== - -"@types/node@>=10.0.0", "@types/node@>=12.12.47", "@types/node@>=13.7.0": - version "17.0.38" - resolved "https://registry.yarnpkg.com/@types/node/-/node-17.0.38.tgz#f8bb07c371ccb1903f3752872c89f44006132947" - integrity sha512-5jY9RhV7c0Z4Jy09G+NIDTsCZ5G0L5n+Z+p+Y7t5VJHM30bgwzSjVtlcBxqAj+6L/swIlvtOSzr8rBk/aNyV2g== - -"@types/offscreencanvas@~2019.3.0": - version "2019.3.0" - resolved "https://registry.yarnpkg.com/@types/offscreencanvas/-/offscreencanvas-2019.3.0.tgz#3336428ec7e9180cf4566dfea5da04eb586a6553" - integrity sha512-esIJx9bQg+QYF0ra8GnvfianIY8qWB0GBx54PK5Eps6m+xTj86KLavHv6qDhzKcu5UUOgNfJ2pWaIIV7TRUd9Q== - -"@types/offscreencanvas@~2019.7.0": - version "2019.7.0" - resolved "https://registry.yarnpkg.com/@types/offscreencanvas/-/offscreencanvas-2019.7.0.tgz#e4a932069db47bb3eabeb0b305502d01586fa90d" - integrity sha512-PGcyveRIpL1XIqK8eBsmRBt76eFgtzuPiSTyKHZxnGemp2yzGzWpjYKAfK3wIMiU7eH+851yEpiuP8JZerTmWg== - -"@types/qs@*": - version "6.9.7" - resolved "https://registry.yarnpkg.com/@types/qs/-/qs-6.9.7.tgz#63bb7d067db107cc1e457c303bc25d511febf6cb" - integrity sha512-FGa1F62FT09qcrueBA6qYTrJPVDzah9a+493+o2PCXsesWHIn27G98TsSMs3WPNbZIEj4+VJf6saSFpvD+3Zsw== - -"@types/range-parser@*": - version "1.2.4" - resolved "https://registry.yarnpkg.com/@types/range-parser/-/range-parser-1.2.4.tgz#cd667bcfdd025213aafb7ca5915a932590acdcdc" - integrity sha512-EEhsLsD6UsDM1yFhAvy0Cjr6VwmpMWqFBCb9w07wVugF7w9nfajxLuVmngTIpgS6svCnm6Vaw+MZhoDCKnOfsw== - -"@types/seedrandom@^2.4.28": - version "2.4.30" - resolved "https://registry.yarnpkg.com/@types/seedrandom/-/seedrandom-2.4.30.tgz#d2efe425869b84163c2d56e779dddadb9372cbfa" - integrity sha512-AnxLHewubLVzoF/A4qdxBGHCKifw8cY32iro3DQX9TPcetE95zBeVt3jnsvtvAUf1vwzMfwzp4t/L2yqPlnjkQ== - -"@types/serve-static@*": - version "1.15.0" - resolved "https://registry.yarnpkg.com/@types/serve-static/-/serve-static-1.15.0.tgz#c7930ff61afb334e121a9da780aac0d9b8f34155" - integrity sha512-z5xyF6uh8CbjAu9760KDKsH2FcDxZ2tFCsA4HIMWE6IkiYMXfVoa+4f9KX+FN0ZLsaMw1WNG2ETLA6N+/YA+cg== - dependencies: - "@types/mime" "*" - "@types/node" "*" - -"@types/webgl-ext@0.0.30": - version "0.0.30" - resolved "https://registry.yarnpkg.com/@types/webgl-ext/-/webgl-ext-0.0.30.tgz#0ce498c16a41a23d15289e0b844d945b25f0fb9d" - integrity sha512-LKVgNmBxN0BbljJrVUwkxwRYqzsAEPcZOe6S2T6ZaBDIrFp0qu4FNlpc5sM1tGbXUYFgdVQIoeLk1Y1UoblyEg== - -"@webgpu/types@0.1.21": - version "0.1.21" - resolved "https://registry.yarnpkg.com/@webgpu/types/-/types-0.1.21.tgz#b181202daec30d66ccd67264de23814cfd176d3a" - integrity sha512-pUrWq3V5PiSGFLeLxoGqReTZmiiXwY3jRkIG5sLLKjyqNxrwm/04b4nw7LSmGWJcKk59XOM/YRTUwOzo4MMlow== - -JSONStream@^1.3.5: - version "1.3.5" - resolved "https://registry.yarnpkg.com/JSONStream/-/JSONStream-1.3.5.tgz#3208c1f08d3a4d99261ab64f92302bc15e111ca0" - integrity sha512-E+iruNOY8VV9s4JEbe1aNEm6MiszPRr/UfcHMz0TQh1BXSxHK+ASV1R6W4HpjBhSeS+54PIsAMCBmwD06LLsqQ== - dependencies: - jsonparse "^1.2.0" - through ">=2.2.7 <3" - -abort-controller@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/abort-controller/-/abort-controller-3.0.0.tgz#eaf54d53b62bae4138e809ca225c8439a6efb392" - integrity sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg== - dependencies: - event-target-shim "^5.0.0" - -accepts@~1.3.4: - version "1.3.8" - resolved "https://registry.yarnpkg.com/accepts/-/accepts-1.3.8.tgz#0bf0be125b67014adcb0b0921e62db7bffe16b2e" - integrity sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw== - dependencies: - mime-types "~2.1.34" - negotiator "0.6.3" - -acorn-jsx@^5.3.2: - version "5.3.2" - resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-5.3.2.tgz#7ed5bb55908b3b2f1bc55c6af1653bada7f07937" - integrity sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ== - -acorn@^8.8.0: - version "8.8.1" - resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.8.1.tgz#0a3f9cbecc4ec3bea6f0a80b66ae8dd2da250b73" - integrity sha512-7zFpHzhnqYKrkYdUjF1HI1bzd0VygEGX8lFk4k5zVMqHEoES+P+7TKI+EvLO9WVMJ8eekdO0aDEK044xTXwPPA== - -agent-base@5: - version "5.1.1" - resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-5.1.1.tgz#e8fb3f242959db44d63be665db7a8e739537a32c" - integrity sha512-TMeqbNl2fMW0nMjTEPOwe3J/PRFP4vqeoNuQMG0HlMrtm5QxKqdvAkZ1pRBQ/ulIyDD5Yq0nJ7YbdD8ey0TO3g== - -agent-base@6: - version "6.0.2" - resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-6.0.2.tgz#49fff58577cfee3f37176feab4c22e00f86d7f77" - integrity sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ== - dependencies: - debug "4" - -agent-base@^4.3.0: - version "4.3.0" - resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-4.3.0.tgz#8165f01c436009bccad0b1d122f05ed770efc6ee" - integrity sha512-salcGninV0nPrwpGNn4VTXBb1SOuXQBiqbrNXoeizJsHrsL6ERFM2Ne3JUSBWRE6aeNJI2ROP/WEEIDUiDe3cg== - dependencies: - es6-promisify "^5.0.0" - -ansi-regex@^5.0.1: - version "5.0.1" - resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.1.tgz#082cb2c89c9fe8659a311a53bd6a4dc5301db304" - integrity sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ== - -ansi-styles@^4.0.0, ansi-styles@^4.1.0: - version "4.3.0" - resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-4.3.0.tgz#edd803628ae71c04c85ae7a0906edad34b648937" - integrity sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg== - dependencies: - color-convert "^2.0.1" - -anymatch@~3.1.2: - version "3.1.2" - resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-3.1.2.tgz#c0557c096af32f106198f4f4e2a383537e378716" - integrity sha512-P43ePfOAIupkguHUycrc4qJ9kz8ZiuOUijaETwX7THt0Y/GNK7v0aa8rY816xWjZ7rJdA5XdMcpVFTKMq+RvWg== - dependencies: - normalize-path "^3.0.0" - picomatch "^2.0.4" - -argparse@^1.0.10: - version "1.0.10" - resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911" - integrity sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg== - dependencies: - sprintf-js "~1.0.2" - -argparse@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/argparse/-/argparse-2.0.1.tgz#246f50f3ca78a3240f6c997e8a9bd1eac49e4b38" - integrity "sha1-JG9Q88p4oyQPbJl+ipvR6sSeSzg= sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==" - -array-flat-polyfill@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/array-flat-polyfill/-/array-flat-polyfill-1.0.1.tgz#1e3a4255be619dfbffbfd1d635c1cf357cd034e7" - integrity sha512-hfJmKupmQN0lwi0xG6FQ5U8Rd97RnIERplymOv/qpq8AoNKPPAnxJadjFA23FNWm88wykh9HmpLJUUwUtNU/iw== - -arrify@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/arrify/-/arrify-2.0.1.tgz#c9655e9331e0abcd588d2a7cad7e9956f66701fa" - integrity sha512-3duEwti880xqi4eAMN8AyR4a0ByT90zoYdLlevfrvU43vb0YZwZVfxOgxWrLXXXpyugL0hNZc9G6BiB5B3nUug== - -asap@~2.0.3: - version "2.0.6" - resolved "https://registry.yarnpkg.com/asap/-/asap-2.0.6.tgz#e50347611d7e690943208bbdafebcbc2fb866d46" - integrity sha1-5QNHYR1+aQlDIIu9r+vLwvuGbUY= - -async-retry@^1.3.3: - version "1.3.3" - resolved "https://registry.yarnpkg.com/async-retry/-/async-retry-1.3.3.tgz#0e7f36c04d8478e7a58bdbed80cedf977785f280" - integrity sha512-wfr/jstw9xNi/0teMHrRW7dsz3Lt5ARhYNZ2ewpadnhaIp5mbALhOAP+EAdsC7t4Z6wqsDVv9+W6gm1Dk9mEyw== - dependencies: - retry "0.13.1" - -asynckit@^0.4.0: - version "0.4.0" - resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" - integrity sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q== - -balanced-match@^1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee" - integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw== - -base64-js@^1.3.0: - version "1.5.1" - resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a" - integrity sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA== - -base64id@2.0.0, base64id@~2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/base64id/-/base64id-2.0.0.tgz#2770ac6bc47d312af97a8bf9a634342e0cd25cb6" - integrity sha512-lGe34o6EHj9y3Kts9R4ZYs/Gr+6N7MCaMlIFA3F1R2O5/m7K06AxfSeO5530PEERE6/WyEg3lsuyw4GHlPZHog== - -bignumber.js@^9.0.0: - version "9.1.0" - resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-9.1.0.tgz#8d340146107fe3a6cb8d40699643c302e8773b62" - integrity sha512-4LwHK4nfDOraBCtst+wOWIHbu1vhvAPJK8g8nROd4iuc3PSEjWif/qwbkh8jwCJz6yDBvtU4KPynETgrfh7y3A== - -binary-extensions@^2.0.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.2.0.tgz#75f502eeaf9ffde42fc98829645be4ea76bd9e2d" - integrity sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA== - -bluebird@^3.7.2: - version "3.7.2" - resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.7.2.tgz#9f229c15be272454ffa973ace0dbee79a1b0c36f" - integrity sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg== - -body-parser@^1.19.0: - version "1.19.2" - resolved "https://registry.yarnpkg.com/body-parser/-/body-parser-1.19.2.tgz#4714ccd9c157d44797b8b5607d72c0b89952f26e" - integrity sha512-SAAwOxgoCKMGs9uUAUFHygfLAyaniaoun6I8mFY9pRAJL9+Kec34aU+oIjDhTycub1jozEfEwx1W1IuOYxVSFw== - dependencies: - bytes "3.1.2" - content-type "~1.0.4" - debug "2.6.9" - depd "~1.1.2" - http-errors "1.8.1" - iconv-lite "0.4.24" - on-finished "~2.3.0" - qs "6.9.7" - raw-body "2.4.3" - type-is "~1.6.18" - -bowser@^1.7.3: - version "1.9.4" - resolved "https://registry.yarnpkg.com/bowser/-/bowser-1.9.4.tgz#890c58a2813a9d3243704334fa81b96a5c150c9a" - integrity sha512-9IdMmj2KjigRq6oWhmwv1W36pDuA4STQZ8q6YO9um+x07xgYNCD3Oou+WP/3L1HNz7iqythGet3/p4wvc8AAwQ== - -brace-expansion@^1.1.7: - version "1.1.11" - resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" - integrity sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA== - dependencies: - balanced-match "^1.0.0" - concat-map "0.0.1" - -brace-expansion@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-2.0.1.tgz#1edc459e0f0c548486ecf9fc99f2221364b9a0ae" - integrity sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA== - dependencies: - balanced-match "^1.0.0" - -braces@^3.0.2, braces@~3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107" - integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A== - dependencies: - fill-range "^7.0.1" - -browserstack-local@^1.3.7: - version "1.4.9" - resolved "https://registry.yarnpkg.com/browserstack-local/-/browserstack-local-1.4.9.tgz#5d3e405d425ee5a3ec5cba853c9a078242d944db" - integrity sha512-V+q8HQwRQFr9nd32xR66ZZ3VDWa3Kct4IMMudhKgcuD7cWrvvFARZOibx71II+Rf7P5nMQpWWxl9z/3p927nbg== - dependencies: - https-proxy-agent "^4.0.0" - is-running "^2.1.0" - ps-tree "=1.2.0" - temp-fs "^0.9.9" - -browserstack@~1.5.1: - version "1.5.3" - resolved "https://registry.yarnpkg.com/browserstack/-/browserstack-1.5.3.tgz#93ab48799a12ef99dbd074dd595410ddb196a7ac" - integrity sha512-AO+mECXsW4QcqC9bxwM29O7qWa7bJT94uBFzeb5brylIQwawuEziwq20dPYbins95GlWzOawgyDNdjYAo32EKg== - dependencies: - https-proxy-agent "^2.2.1" - -buffer-equal-constant-time@1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz#f8e71132f7ffe6e01a5c9697a4c6f3e48d5cc819" - integrity sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA== - -bytes@3.1.2: - version "3.1.2" - resolved "https://registry.yarnpkg.com/bytes/-/bytes-3.1.2.tgz#8b0beeb98605adf1b128fa4386403c009e0221a5" - integrity sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg== - -camelcase@^5.0.0: - version "5.3.1" - resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-5.3.1.tgz#e3c9b31569e106811df242f715725a1f4c494320" - integrity sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg== - -catharsis@^0.9.0: - version "0.9.0" - resolved "https://registry.yarnpkg.com/catharsis/-/catharsis-0.9.0.tgz#40382a168be0e6da308c277d3a2b3eb40c7d2121" - integrity sha512-prMTQVpcns/tzFgFVkVp6ak6RykZyWb3gu8ckUpd6YkTlacOd3DXGJjIpD4Q6zJirizvaiAjSSHlOsA+6sNh2A== - dependencies: - lodash "^4.17.15" - -chalk@^4.0.0, chalk@^4.1.0: - version "4.1.2" - resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01" - integrity sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA== - dependencies: - ansi-styles "^4.1.0" - supports-color "^7.1.0" - -chokidar@^3.5.1: - version "3.5.3" - resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.5.3.tgz#1cf37c8707b932bd1af1ae22c0432e2acd1903bd" - integrity sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw== - dependencies: - anymatch "~3.1.2" - braces "~3.0.2" - glob-parent "~5.1.2" - is-binary-path "~2.1.0" - is-glob "~4.0.1" - normalize-path "~3.0.0" - readdirp "~3.6.0" - optionalDependencies: - fsevents "~2.3.2" - -cliui@^6.0.0: - version "6.0.0" - resolved "https://registry.yarnpkg.com/cliui/-/cliui-6.0.0.tgz#511d702c0c4e41ca156d7d0e96021f23e13225b1" - integrity sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ== - dependencies: - string-width "^4.2.0" - strip-ansi "^6.0.0" - wrap-ansi "^6.2.0" - -cliui@^7.0.2: - version "7.0.4" - resolved "https://registry.yarnpkg.com/cliui/-/cliui-7.0.4.tgz#a0265ee655476fc807aea9df3df8df7783808b4f" - integrity sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ== - dependencies: - string-width "^4.2.0" - strip-ansi "^6.0.0" - wrap-ansi "^7.0.0" - -clone@~2.1.2: - version "2.1.2" - resolved "https://registry.yarnpkg.com/clone/-/clone-2.1.2.tgz#1b7f4b9f591f1e8f83670401600345a02887435f" - integrity sha1-G39Ln1kfHo+DZwQBYANFoCiHQ18= - -color-convert@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-2.0.1.tgz#72d3a68d598c9bdb3af2ad1e84f21d896abd4de3" - integrity sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ== - dependencies: - color-name "~1.1.4" - -color-name@~1.1.4: - version "1.1.4" - resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2" - integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA== - -combined-stream@^1.0.8: - version "1.0.8" - resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.8.tgz#c3d45a8b34fd730631a110a8a2520682b31d5a7f" - integrity sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg== - dependencies: - delayed-stream "~1.0.0" - -commander@2: - version "2.20.3" - resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33" - integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ== - -commander@7: - version "7.2.0" - resolved "https://registry.yarnpkg.com/commander/-/commander-7.2.0.tgz#a36cb57d0b501ce108e4d20559a150a391d97ab7" - integrity sha512-QrWXB+ZQSVPmIWIhtEO9H+gwHaMGYiF5ChvoJ+K9ZGHG/sVsa6yiesAD1GC/x46sET00Xlwo1u49RVVVzvcSkw== - -component-emitter@~1.3.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/component-emitter/-/component-emitter-1.3.0.tgz#16e4070fba8ae29b679f2215853ee181ab2eabc0" - integrity sha512-Rd3se6QB+sO1TwqZjscQrurpEPIfO0/yYnSin6Q/rD3mOutHvUrCAhJub3r90uNb+SESBuE0QYoB90YdfatsRg== - -compressible@^2.0.12: - version "2.0.18" - resolved "https://registry.yarnpkg.com/compressible/-/compressible-2.0.18.tgz#af53cca6b070d4c3c0750fbd77286a6d7cc46fba" - integrity sha512-AF3r7P5dWxL8MxyITRMlORQNaOA2IkAFaTr4k7BUumjPtRpGDTZpl0Pb1XCO6JeDCBdp126Cgs9sMxqSjgYyRg== - dependencies: - mime-db ">= 1.43.0 < 2" - -concat-map@0.0.1: - version "0.0.1" - resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" - integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s= - -connect@^3.7.0: - version "3.7.0" - resolved "https://registry.yarnpkg.com/connect/-/connect-3.7.0.tgz#5d49348910caa5e07a01800b030d0c35f20484f8" - integrity sha512-ZqRXc+tZukToSNmh5C2iWMSoV3X1YUcPbqEM4DkEG5tNQXrQUZCNVGGv3IuicnkMtPfGf3Xtp8WCXs295iQ1pQ== - dependencies: - debug "2.6.9" - finalhandler "1.1.2" - parseurl "~1.3.3" - utils-merge "1.0.1" - -content-type@~1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/content-type/-/content-type-1.0.4.tgz#e138cc75e040c727b1966fe5e5f8c9aee256fe3b" - integrity sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA== - -cookie@~0.4.1: - version "0.4.2" - resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.4.2.tgz#0e41f24de5ecf317947c82fc789e06a884824432" - integrity "sha1-DkHyTeXs8xeUfIL8eJ4GqISCRDI= sha512-aSWTXFzaKWkvHO1Ny/s+ePFpvKsPnjc551iI41v3ny/ow6tBG5Vd+FuqGNhh1LxOmVzOlGUriIlOaokOvhaStA==" - -core-js@3.29.1: - version "3.29.1" - resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.29.1.tgz#40ff3b41588b091aaed19ca1aa5cb111803fa9a6" - integrity sha512-+jwgnhg6cQxKYIIjGtAHq2nwUOolo9eoFZ4sHfUH09BLXBgxnH4gA0zEd+t+BO2cNB8idaBtZFcFTRjQJRJmAw== - -core-js@^1.0.0: - version "1.2.7" - resolved "https://registry.yarnpkg.com/core-js/-/core-js-1.2.7.tgz#652294c14651db28fa93bd2d5ff2983a4f08c636" - integrity sha1-ZSKUwUZR2yj6k70tX/KYOk8IxjY= - -cors@~2.8.5: - version "2.8.5" - resolved "https://registry.yarnpkg.com/cors/-/cors-2.8.5.tgz#eac11da51592dd86b9f06f6e7ac293b3df875d29" - integrity sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g== - dependencies: - object-assign "^4" - vary "^1" - -css-in-js-utils@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/css-in-js-utils/-/css-in-js-utils-2.0.1.tgz#3b472b398787291b47cfe3e44fecfdd9e914ba99" - integrity sha512-PJF0SpJT+WdbVVt0AOYp9C8GnuruRlL/UFW7932nLWmFLQTaWEzTBQEx7/hn4BuV+WON75iAViSUJLiU3PKbpA== - dependencies: - hyphenate-style-name "^1.0.2" - isobject "^3.0.1" - -custom-event@~1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/custom-event/-/custom-event-1.0.1.tgz#5d02a46850adf1b4a317946a3928fccb5bfd0425" - integrity sha1-XQKkaFCt8bSjF5RqOSj8y1v9BCU= - -"d3-array@1 - 2", d3-array@2, d3-array@^2.3.0, d3-array@^2.5.0, d3-array@^2.7.1: - version "2.12.1" - resolved "https://registry.yarnpkg.com/d3-array/-/d3-array-2.12.1.tgz#e20b41aafcdffdf5d50928004ececf815a465e81" - integrity sha512-B0ErZK/66mHtEsR1TkPEEkwdy+WDesimkM5gpZr5Dsg54BiTA5RXtYW5qTLIAcekaS9xfZrzBLF/OAkB3Qn1YQ== - dependencies: - internmap "^1.0.0" - -"d3-array@1 - 3", "d3-array@2 - 3", "d3-array@2.10.0 - 3", "d3-array@2.5.0 - 3", d3-array@3.1.1, d3-array@^3.1.1: - version "3.1.1" - resolved "https://registry.yarnpkg.com/d3-array/-/d3-array-3.1.1.tgz#7797eb53ead6b9083c75a45a681e93fc41bc468c" - integrity sha512-33qQ+ZoZlli19IFiQx4QEpf2CBEayMRzhlisJHSCsSUbDXv6ZishqS1x7uFVClKG4Wr7rZVHvaAttoLow6GqdQ== - dependencies: - internmap "1 - 2" - -"d3-color@1 - 2", d3-color@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/d3-color/-/d3-color-2.0.0.tgz#8d625cab42ed9b8f601a1760a389f7ea9189d62e" - integrity sha512-SPXi0TSKPD4g9tw0NMZFnR95XVgUZiBH+uUTqQuDu1OsE2zomHU7ho0FISciaPvosimixwHFl3WHLGabv6dDgQ== - -"d3-color@1 - 3", d3-color@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/d3-color/-/d3-color-3.0.1.tgz#03316e595955d1fcd39d9f3610ad41bb90194d0a" - integrity sha512-6/SlHkDOBLyQSJ1j1Ghs82OIUXpKWlR0hCsw0XrLSQhuUPuCSmLQ1QPH98vpnQxMUQM2/gfAkUEWsupVpd9JGw== - -d3-delaunay@^5.3.0: - version "5.3.0" - resolved "https://registry.yarnpkg.com/d3-delaunay/-/d3-delaunay-5.3.0.tgz#b47f05c38f854a4e7b3cea80e0bb12e57398772d" - integrity sha512-amALSrOllWVLaHTnDLHwMIiz0d1bBu9gZXd1FiLfXf8sHcX9jrcj81TVZOqD4UX7MgBZZ07c8GxzEgBpJqc74w== - dependencies: - delaunator "4" - -"d3-dispatch@1 - 2": - version "2.0.0" - resolved "https://registry.yarnpkg.com/d3-dispatch/-/d3-dispatch-2.0.0.tgz#8a18e16f76dd3fcaef42163c97b926aa9b55e7cf" - integrity sha512-S/m2VsXI7gAti2pBoLClFFTMOO1HTtT0j99AuXLoGFKO6deHDdnv6ZGTxSTTUTgO1zVcv82fCOtDjYK4EECmWA== - -d3-dsv@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/d3-dsv/-/d3-dsv-2.0.0.tgz#b37b194b6df42da513a120d913ad1be22b5fe7c5" - integrity sha512-E+Pn8UJYx9mViuIUkoc93gJGGYut6mSDKy2+XaPwccwkRGlR+LO97L2VCCRjQivTwLHkSnAJG7yo00BWY6QM+w== - dependencies: - commander "2" - iconv-lite "0.4" - rw "1" - -d3-dsv@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/d3-dsv/-/d3-dsv-3.0.1.tgz#c63af978f4d6a0d084a52a673922be2160789b73" - integrity sha512-UG6OvdI5afDIFP9w4G0mNq50dSOsXHJaRE8arAS5o9ApWnIElp8GZw1Dun8vP8OyHOZ/QJUKUJwxiiCCnUwm+Q== - dependencies: - commander "7" - iconv-lite "0.6" - rw "1" - -d3-force@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/d3-force/-/d3-force-2.1.1.tgz#f20ccbf1e6c9e80add1926f09b51f686a8bc0937" - integrity sha512-nAuHEzBqMvpFVMf9OX75d00OxvOXdxY+xECIXjW6Gv8BRrXu6gAWbv/9XKrvfJ5i5DCokDW7RYE50LRoK092ew== - dependencies: - d3-dispatch "1 - 2" - d3-quadtree "1 - 2" - d3-timer "1 - 2" - -"d3-format@1 - 2", d3-format@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/d3-format/-/d3-format-2.0.0.tgz#a10bcc0f986c372b729ba447382413aabf5b0767" - integrity sha512-Ab3S6XuE/Q+flY96HXT0jOXcM4EAClYFnRGY5zsjRGNy6qCYrQsMffs7cV5Q9xejb35zxW5hf/guKw34kvIKsA== - -"d3-format@1 - 3", d3-format@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/d3-format/-/d3-format-3.1.0.tgz#9260e23a28ea5cb109e93b21a06e24e2ebd55641" - integrity sha512-YyUI6AEuY/Wpt8KWLgZHsIU86atmikuoOmCfommt0LYHiQSPjvX2AcFc38PX0CBpr2RCyZhjex+NS/LPOv6YqA== - -d3-format@~1.3.0: - version "1.3.2" - resolved "https://registry.yarnpkg.com/d3-format/-/d3-format-1.3.2.tgz#6a96b5e31bcb98122a30863f7d92365c00603562" - integrity sha512-Z18Dprj96ExragQ0DeGi+SYPQ7pPfRMtUXtsg/ChVIKNBCzjO8XYJvRTC1usblx52lqge56V5ect+frYTQc8WQ== - -d3-geo-projection@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/d3-geo-projection/-/d3-geo-projection-3.0.0.tgz#45ad8ce756cdbfa8340b11b2988644d8e1fa42e4" - integrity sha512-1JE+filVbkEX2bT25dJdQ05iA4QHvUwev6o0nIQHOSrNlHCAKfVss/U10vEM3pA4j5v7uQoFdQ4KLbx9BlEbWA== - dependencies: - commander "2" - d3-array "1 - 2" - d3-geo "1.12.0 - 2" - resolve "^1.1.10" - -d3-geo-projection@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/d3-geo-projection/-/d3-geo-projection-4.0.0.tgz#dc229e5ead78d31869a4e87cf1f45bd2716c48ca" - integrity sha512-p0bK60CEzph1iqmnxut7d/1kyTmm3UWtPlwdkM31AU+LW+BXazd5zJdoCn7VFxNCHXRngPHRnsNn5uGjLRGndg== - dependencies: - commander "7" - d3-array "1 - 3" - d3-geo "1.12.0 - 3" - -"d3-geo@1.12.0 - 2", d3-geo@^2.0.1: - version "2.0.2" - resolved "https://registry.yarnpkg.com/d3-geo/-/d3-geo-2.0.2.tgz#c065c1b71fe8c5f1be657e5f43d9bdd010383c40" - integrity sha512-8pM1WGMLGFuhq9S+FpPURxic+gKzjluCD/CHTuUF3mXMeiCo0i6R0tO1s4+GArRFde96SLcW/kOFRjoAosPsFA== - dependencies: - d3-array "^2.5.0" - -"d3-geo@1.12.0 - 3", d3-geo@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/d3-geo/-/d3-geo-3.0.1.tgz#4f92362fd8685d93e3b1fae0fd97dc8980b1ed7e" - integrity sha512-Wt23xBych5tSy9IYAM1FR2rWIBFWa52B/oF/GYe5zbdHrg08FU8+BuI6X4PvTwPDdqdAdq04fuWJpELtsaEjeA== - dependencies: - d3-array "2.5.0 - 3" - -d3-hierarchy@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/d3-hierarchy/-/d3-hierarchy-2.0.0.tgz#dab88a58ca3e7a1bc6cab390e89667fcc6d20218" - integrity sha512-SwIdqM3HxQX2214EG9GTjgmCc/mbSx4mQBn+DuEETubhOw6/U3fmnji4uCVrmzOydMHSO1nZle5gh6HB/wdOzw== - -"d3-interpolate@1.2.0 - 2", d3-interpolate@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/d3-interpolate/-/d3-interpolate-2.0.1.tgz#98be499cfb8a3b94d4ff616900501a64abc91163" - integrity sha512-c5UhwwTs/yybcmTpAVqwSFl6vrQ8JZJoT5F7xNFK9pymv5C0Ymcc9/LIJHtYIggg/yS9YHw8i8O8tgb9pupjeQ== - dependencies: - d3-color "1 - 2" - -"d3-interpolate@1.2.0 - 3", d3-interpolate@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/d3-interpolate/-/d3-interpolate-3.0.1.tgz#3c47aa5b32c5b3dfb56ef3fd4342078a632b400d" - integrity sha512-3bYs1rOD33uo8aqJfKP3JWPAibgw8Zm2+L9vBKEHJ2Rg+viTR7o5Mmv5mZcieN+FRYaAOWX5SJATX6k1PWz72g== - dependencies: - d3-color "1 - 3" - -"d3-path@1 - 2", d3-path@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/d3-path/-/d3-path-2.0.0.tgz#55d86ac131a0548adae241eebfb56b4582dd09d8" - integrity sha512-ZwZQxKhBnv9yHaiWd6ZU4x5BtCQ7pXszEV9CU6kRgwIQVQGLMv1oiL4M+MK/n79sYzsj+gcgpPQSctJUsLN7fA== - -"d3-path@1 - 3", d3-path@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/d3-path/-/d3-path-3.0.1.tgz#f09dec0aaffd770b7995f1a399152bf93052321e" - integrity sha512-gq6gZom9AFZby0YLduxT1qmrp4xpBA1YZr19OI717WIdKE2OM5ETq5qrHLb301IgxhLwcuxvGZVLeeWc/k1I6w== - -"d3-quadtree@1 - 2": - version "2.0.0" - resolved "https://registry.yarnpkg.com/d3-quadtree/-/d3-quadtree-2.0.0.tgz#edbad045cef88701f6fee3aee8e93fb332d30f9d" - integrity sha512-b0Ed2t1UUalJpc3qXzKi+cPGxeXRr4KU9YSlocN74aTzp6R/Ud43t79yLLqxHRWZfsvWXmbDWPpoENK1K539xw== - -d3-scale@^3.2.2: - version "3.3.0" - resolved "https://registry.yarnpkg.com/d3-scale/-/d3-scale-3.3.0.tgz#28c600b29f47e5b9cd2df9749c206727966203f3" - integrity sha512-1JGp44NQCt5d1g+Yy+GeOnZP7xHo0ii8zsQp6PGzd+C1/dl0KGsp9A7Mxwp+1D1o4unbTTxVdU/ZOIEBoeZPbQ== - dependencies: - d3-array "^2.3.0" - d3-format "1 - 2" - d3-interpolate "1.2.0 - 2" - d3-time "^2.1.1" - d3-time-format "2 - 3" - -d3-scale@^4.0.2: - version "4.0.2" - resolved "https://registry.yarnpkg.com/d3-scale/-/d3-scale-4.0.2.tgz#82b38e8e8ff7080764f8dcec77bd4be393689396" - integrity sha512-GZW464g1SH7ag3Y7hXjf8RoUuAFIqklOAq3MRl4OaWabTFJY9PN/E1YklhXLh+OQ3fM9yS2nOkCoS+WLZ6kvxQ== - dependencies: - d3-array "2.10.0 - 3" - d3-format "1 - 3" - d3-interpolate "1.2.0 - 3" - d3-time "2.1.1 - 3" - d3-time-format "2 - 4" - -d3-selection@~1.3.0: - version "1.3.2" - resolved "https://registry.yarnpkg.com/d3-selection/-/d3-selection-1.3.2.tgz#6e70a9df60801c8af28ac24d10072d82cbfdf652" - integrity sha512-OoXdv1nZ7h2aKMVg3kaUFbLLK5jXUFAMLD/Tu5JA96mjf8f2a9ZUESGY+C36t8R1WFeWk/e55hy54Ml2I62CRQ== - -d3-shape@^2.0.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/d3-shape/-/d3-shape-2.1.0.tgz#3b6a82ccafbc45de55b57fcf956c584ded3b666f" - integrity sha512-PnjUqfM2PpskbSLTJvAzp2Wv4CZsnAgTfcVRTwW03QR3MkXF8Uo7B1y/lWkAsmbKwuecto++4NlsYcvYpXpTHA== - dependencies: - d3-path "1 - 2" - -d3-shape@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/d3-shape/-/d3-shape-3.1.0.tgz#c8a495652d83ea6f524e482fca57aa3f8bc32556" - integrity sha512-tGDh1Muf8kWjEDT/LswZJ8WF85yDZLvVJpYU9Nq+8+yW1Z5enxrmXOhTArlkaElU+CTn0OTVNli+/i+HP45QEQ== - dependencies: - d3-path "1 - 3" - -"d3-time-format@2 - 3", d3-time-format@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/d3-time-format/-/d3-time-format-3.0.0.tgz#df8056c83659e01f20ac5da5fdeae7c08d5f1bb6" - integrity sha512-UXJh6EKsHBTjopVqZBhFysQcoXSv/5yLONZvkQ5Kk3qbwiUYkdX17Xa1PT6U1ZWXGGfB1ey5L8dKMlFq2DO0Ag== - dependencies: - d3-time "1 - 2" - -"d3-time-format@2 - 4", d3-time-format@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/d3-time-format/-/d3-time-format-4.1.0.tgz#7ab5257a5041d11ecb4fe70a5c7d16a195bb408a" - integrity sha512-dJxPBlzC7NugB2PDLwo9Q8JiTR3M3e4/XANkreKSUxF8vvXKqm1Yfq4Q5dl8budlunRVlUUaDUgFt7eA8D6NLg== - dependencies: - d3-time "1 - 3" - -"d3-time@1 - 2", d3-time@^2.0.0, d3-time@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/d3-time/-/d3-time-2.1.1.tgz#e9d8a8a88691f4548e68ca085e5ff956724a6682" - integrity sha512-/eIQe/eR4kCQwq7yxi7z4c6qEXf2IYGcjoWB5OOQy4Tq9Uv39/947qlDcN2TLkiTzQWzvnsuYPB9TrWaNfipKQ== - dependencies: - d3-array "2" - -"d3-time@1 - 3", "d3-time@2.1.1 - 3", d3-time@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/d3-time/-/d3-time-3.0.0.tgz#65972cb98ae2d4954ef5c932e8704061335d4975" - integrity sha512-zmV3lRnlaLI08y9IMRXSDshQb5Nj77smnfpnd2LrBa/2K281Jijactokeak14QacHs/kKq0AQ121nidNYlarbQ== - dependencies: - d3-array "2 - 3" - -"d3-timer@1 - 2", d3-timer@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/d3-timer/-/d3-timer-2.0.0.tgz#055edb1d170cfe31ab2da8968deee940b56623e6" - integrity sha512-TO4VLh0/420Y/9dO3+f9abDEFYeCUr2WZRlxJvbp4HPTQcSylXNiL6yZa9FIUvV1yRiFufl1bszTCLDqv9PWNA== - -date-format@^4.0.5: - version "4.0.5" - resolved "https://registry.yarnpkg.com/date-format/-/date-format-4.0.5.tgz#ba385f89782c6cb114cf45dfa4704c6bb29fca51" - integrity sha512-zBhRiN/M0gDxUoM2xRtzTjJzSg0XEi1ofYpF84PfXeS3hN2PsGxmc7jw3DNQtFlimRbMmob5FC3G0cJq6jQQpw== - -debug@2.6.9: - version "2.6.9" - resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" - integrity sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA== - dependencies: - ms "2.0.0" - -debug@4, debug@^4.1.1, debug@^4.3.3, debug@^4.3.4, debug@~4.3.1, debug@~4.3.2: - version "4.3.4" - resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865" - integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ== - dependencies: - ms "2.1.2" - -debug@^3.1.0: - version "3.2.7" - resolved "https://registry.yarnpkg.com/debug/-/debug-3.2.7.tgz#72580b7e9145fb39b6676f9c5e5fb100b934179a" - integrity sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ== - dependencies: - ms "^2.1.1" - -decamelize@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" - integrity sha1-9lNNFRSCabIDUue+4m9QH5oZEpA= - -deep-is@~0.1.3: - version "0.1.4" - resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.4.tgz#a6f2dce612fadd2ef1f519b73551f17e85199831" - integrity sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ== - -delaunator@4: - version "4.0.1" - resolved "https://registry.yarnpkg.com/delaunator/-/delaunator-4.0.1.tgz#3d779687f57919a7a418f8ab947d3bddb6846957" - integrity sha512-WNPWi1IRKZfCt/qIDMfERkDp93+iZEmOxN2yy4Jg+Xhv8SLk2UTqqbe1sfiipn0and9QrE914/ihdx82Y/Giag== - -delayed-stream@~1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" - integrity sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ== - -depd@~1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/depd/-/depd-1.1.2.tgz#9bcd52e14c097763e749b274c4346ed2e560b5a9" - integrity sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak= - -di@^0.0.1: - version "0.0.1" - resolved "https://registry.yarnpkg.com/di/-/di-0.0.1.tgz#806649326ceaa7caa3306d75d985ea2748ba913c" - integrity sha1-gGZJMmzqp8qjMG112YXqJ0i6kTw= - -dom-serialize@^2.2.1: - version "2.2.1" - resolved "https://registry.yarnpkg.com/dom-serialize/-/dom-serialize-2.2.1.tgz#562ae8999f44be5ea3076f5419dcd59eb43ac95b" - integrity sha1-ViromZ9Evl6jB29UGdzVnrQ6yVs= - dependencies: - custom-event "~1.0.0" - ent "~2.2.0" - extend "^3.0.0" - void-elements "^2.0.0" - -duplexer@~0.1.1: - version "0.1.2" - resolved "https://registry.yarnpkg.com/duplexer/-/duplexer-0.1.2.tgz#3abe43aef3835f8ae077d136ddce0f276b0400e6" - integrity sha512-jtD6YG370ZCIi/9GTaJKQxWTZD045+4R4hTk/x1UyoqadyJ9x9CgSi1RlVDQF8U2sxLLSnFkCaMihqljHIWgMg== - -duplexify@^4.0.0: - version "4.1.2" - resolved "https://registry.yarnpkg.com/duplexify/-/duplexify-4.1.2.tgz#18b4f8d28289132fa0b9573c898d9f903f81c7b0" - integrity sha512-fz3OjcNCHmRP12MJoZMPglx8m4rrFP8rovnk4vT8Fs+aonZoCwGg10dSsQsfP/E62eZcPTMSMP6686fu9Qlqtw== - dependencies: - end-of-stream "^1.4.1" - inherits "^2.0.3" - readable-stream "^3.1.1" - stream-shift "^1.0.0" - -ecdsa-sig-formatter@1.0.11, ecdsa-sig-formatter@^1.0.11: - version "1.0.11" - resolved "https://registry.yarnpkg.com/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz#ae0f0fa2d85045ef14a817daa3ce9acd0489e5bf" - integrity sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ== - dependencies: - safe-buffer "^5.0.1" - -ee-first@1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d" - integrity sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0= - -emoji-regex@^8.0.0: - version "8.0.0" - resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37" - integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A== - -encodeurl@~1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/encodeurl/-/encodeurl-1.0.2.tgz#ad3ff4c86ec2d029322f5a02c3a9a606c95b3f59" - integrity sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k= - -end-of-stream@^1.4.1: - version "1.4.4" - resolved "https://registry.yarnpkg.com/end-of-stream/-/end-of-stream-1.4.4.tgz#5ae64a5f45057baf3626ec14da0ca5e4b2431eb0" - integrity sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q== - dependencies: - once "^1.4.0" - -engine.io-parser@~5.0.3: - version "5.0.3" - resolved "https://registry.yarnpkg.com/engine.io-parser/-/engine.io-parser-5.0.3.tgz#ca1f0d7b11e290b4bfda251803baea765ed89c09" - integrity sha512-BtQxwF27XUNnSafQLvDi0dQ8s3i6VgzSoQMJacpIcGNrlUdfHSKbgm3jmjCVvQluGzqwujQMPAoMai3oYSTurg== - dependencies: - "@socket.io/base64-arraybuffer" "~1.0.2" - -engine.io@~6.1.0: - version "6.1.3" - resolved "https://registry.yarnpkg.com/engine.io/-/engine.io-6.1.3.tgz#f156293d011d99a3df5691ac29d63737c3302e6f" - integrity sha512-rqs60YwkvWTLLnfazqgZqLa/aKo+9cueVfEi/dZ8PyGyaf8TLOxj++4QMIgeG3Gn0AhrWiFXvghsoY9L9h25GA== - dependencies: - "@types/cookie" "^0.4.1" - "@types/cors" "^2.8.12" - "@types/node" ">=10.0.0" - accepts "~1.3.4" - base64id "2.0.0" - cookie "~0.4.1" - cors "~2.8.5" - debug "~4.3.1" - engine.io-parser "~5.0.3" - ws "~8.2.3" - -ent@^2.2.0, ent@~2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/ent/-/ent-2.2.0.tgz#e964219325a21d05f44466a2f686ed6ce5f5dd1d" - integrity sha512-GHrMyVZQWvTIdDtpiEXdHZnFQKzeO09apj8Cbl4pKWy4i0Oprcq17usfDt5aO63swf0JOeMWjWQE/LzgSRuWpA== - -entities@~2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/entities/-/entities-2.1.0.tgz#992d3129cf7df6870b96c57858c249a120f8b8b5" - integrity sha512-hCx1oky9PFrJ611mf0ifBLBRW8lUUVRlFolb5gWRfIELabBlbp9xZvrqZLZAs+NxFnbfQoeGd8wDkygjg7U85w== - -es6-promise@^4.0.3: - version "4.2.8" - resolved "https://registry.yarnpkg.com/es6-promise/-/es6-promise-4.2.8.tgz#4eb21594c972bc40553d276e510539143db53e0a" - integrity sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w== - -es6-promisify@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/es6-promisify/-/es6-promisify-5.0.0.tgz#5109d62f3e56ea967c4b63505aef08291c8a5203" - integrity sha1-UQnWLz5W6pZ8S2NQWu8IKRyKUgM= - dependencies: - es6-promise "^4.0.3" - -escalade@^3.1.1: - version "3.1.1" - resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.1.1.tgz#d8cfdc7000965c5a0174b4a82eaa5c0552742e40" - integrity sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw== - -escape-html@~1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/escape-html/-/escape-html-1.0.3.tgz#0258eae4d3d0c0974de1c169188ef0051d1d1988" - integrity sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg= - -escape-string-regexp@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz#a30304e99daa32e23b2fd20f51babd07cffca344" - integrity sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w== - -escodegen@^1.13.0: - version "1.14.3" - resolved "https://registry.yarnpkg.com/escodegen/-/escodegen-1.14.3.tgz#4e7b81fba61581dc97582ed78cab7f0e8d63f503" - integrity sha512-qFcX0XJkdg+PB3xjZZG/wKSuT1PnQWx57+TVSjIMmILd2yC/6ByYElPwJnslDsuWuSAp4AwJGumarAAmJch5Kw== - dependencies: - esprima "^4.0.1" - estraverse "^4.2.0" - esutils "^2.0.2" - optionator "^0.8.1" - optionalDependencies: - source-map "~0.6.1" - -eslint-visitor-keys@^3.3.0: - version "3.3.0" - resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-3.3.0.tgz#f6480fa6b1f30efe2d1968aa8ac745b862469826" - integrity sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA== - -espree@^9.0.0: - version "9.4.1" - resolved "https://registry.yarnpkg.com/espree/-/espree-9.4.1.tgz#51d6092615567a2c2cff7833445e37c28c0065bd" - integrity sha512-XwctdmTO6SIvCzd9810yyNzIrOrqNYV9Koizx4C/mRhf9uq0o4yHoCEU/670pOxOL/MSraektvSAji79kX90Vg== - dependencies: - acorn "^8.8.0" - acorn-jsx "^5.3.2" - eslint-visitor-keys "^3.3.0" - -esprima@^4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71" - integrity sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A== - -estraverse@^4.2.0: - version "4.3.0" - resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-4.3.0.tgz#398ad3f3c5a24948be7725e83d11a7de28cdbd1d" - integrity sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw== - -estraverse@^5.1.0: - version "5.3.0" - resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-5.3.0.tgz#2eea5290702f26ab8fe5370370ff86c965d21123" - integrity sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA== - -esutils@^2.0.2: - version "2.0.3" - resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.3.tgz#74d2eb4de0b8da1293711910d50775b9b710ef64" - integrity sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g== - -event-stream@=3.3.4: - version "3.3.4" - resolved "https://registry.yarnpkg.com/event-stream/-/event-stream-3.3.4.tgz#4ab4c9a0f5a54db9338b4c34d86bfce8f4b35571" - integrity sha1-SrTJoPWlTbkzi0w02Gv86PSzVXE= - dependencies: - duplexer "~0.1.1" - from "~0" - map-stream "~0.1.0" - pause-stream "0.0.11" - split "0.3" - stream-combiner "~0.0.4" - through "~2.3.1" - -event-target-shim@^5.0.0: - version "5.0.1" - resolved "https://registry.yarnpkg.com/event-target-shim/-/event-target-shim-5.0.1.tgz#5d4d3ebdf9583d63a5333ce2deb7480ab2b05789" - integrity sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ== - -eventemitter3@^4.0.0: - version "4.0.7" - resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-4.0.7.tgz#2de9b68f6528d5644ef5c59526a1b4a07306169f" - integrity sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw== - -extend@^3.0.0, extend@^3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.2.tgz#f8b1136b4071fbd8eb140aff858b1019ec2915fa" - integrity sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g== - -fast-deep-equal@^3.1.1, fast-deep-equal@~3.1.1: - version "3.1.3" - resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525" - integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q== - -fast-json-patch@^3.0.0-1: - version "3.1.1" - resolved "https://registry.yarnpkg.com/fast-json-patch/-/fast-json-patch-3.1.1.tgz#85064ea1b1ebf97a3f7ad01e23f9337e72c66947" - integrity sha512-vf6IHUX2SBcA+5/+4883dsIjpBTqmfBjmYiWK1savxQmFk4JfBMLa7ynTYOs1Rolp/T1betJxHiGD3g1Mn8lUQ== - -fast-json-stable-stringify@*, fast-json-stable-stringify@~2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz#874bf69c6f404c2b5d99c481341399fd55892633" - integrity sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw== - -fast-levenshtein@~2.0.6: - version "2.0.6" - resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz#3d8a5c66883a16a30ca8643e851f19baa7797917" - integrity sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw== - -fast-text-encoding@^1.0.0, fast-text-encoding@^1.0.3: - version "1.0.6" - resolved "https://registry.yarnpkg.com/fast-text-encoding/-/fast-text-encoding-1.0.6.tgz#0aa25f7f638222e3396d72bf936afcf1d42d6867" - integrity sha512-VhXlQgj9ioXCqGstD37E/HBeqEGV/qOD/kmbVG8h5xKBYvM1L3lR1Zn4555cQ8GkYbJa8aJSipLPndE1k6zK2w== - -faye-websocket@0.11.4: - version "0.11.4" - resolved "https://registry.yarnpkg.com/faye-websocket/-/faye-websocket-0.11.4.tgz#7f0d9275cfdd86a1c963dc8b65fcc451edcbb1da" - integrity sha512-CzbClwlXAuiRQAlUyfqPgvPoNKTckTPGfwZV4ZdAhVcP2lh9KUxJg2b5GkE7XbjKQ3YJnQ9z6D9ntLAlB+tP8g== - dependencies: - websocket-driver ">=0.5.1" - -fbjs@^0.8.12: - version "0.8.18" - resolved "https://registry.yarnpkg.com/fbjs/-/fbjs-0.8.18.tgz#9835e0addb9aca2eff53295cd79ca1cfc7c9662a" - integrity sha512-EQaWFK+fEPSoibjNy8IxUtaFOMXcWsY0JaVrQoZR9zC8N2Ygf9iDITPWjUTVIax95b6I742JFLqASHfsag/vKA== - dependencies: - core-js "^1.0.0" - isomorphic-fetch "^2.1.1" - loose-envify "^1.0.0" - object-assign "^4.1.0" - promise "^7.1.1" - setimmediate "^1.0.5" - ua-parser-js "^0.7.30" - -fill-range@^7.0.1: - version "7.0.1" - resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.0.1.tgz#1919a6a7c75fe38b2c7c77e5198535da9acdda40" - integrity sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ== - dependencies: - to-regex-range "^5.0.1" - -finalhandler@1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/finalhandler/-/finalhandler-1.1.2.tgz#b7e7d000ffd11938d0fdb053506f6ebabe9f587d" - integrity sha512-aAWcW57uxVNrQZqFXjITpW3sIUQmHGG3qSb9mUah9MgMC4NeWhNOlNjXEYq3HjRAvL6arUviZGGJsBg6z0zsWA== - dependencies: - debug "2.6.9" - encodeurl "~1.0.2" - escape-html "~1.0.3" - on-finished "~2.3.0" - parseurl "~1.3.3" - statuses "~1.5.0" - unpipe "~1.0.0" - -find-up@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/find-up/-/find-up-4.1.0.tgz#97afe7d6cdc0bc5928584b7c8d7b16e8a9aa5d19" - integrity sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw== - dependencies: - locate-path "^5.0.0" - path-exists "^4.0.0" - -firebase-admin@^11.0.1: - version "11.2.1" - resolved "https://registry.yarnpkg.com/firebase-admin/-/firebase-admin-11.2.1.tgz#8f7cb1a208011a0e96cddc209246522b7dde2c1e" - integrity sha512-Tz1GiZXjXAWyTFjzHXvj6KKoT45FraimYCQ1tIUkXXBKSJRCNb6utnQX14EEH/M1IzTM1dEbeMOiUc1RMil1qg== - dependencies: - "@fastify/busboy" "^1.1.0" - "@firebase/database-compat" "^0.2.6" - "@firebase/database-types" "^0.9.13" - "@types/node" ">=12.12.47" - jsonwebtoken "^8.5.1" - jwks-rsa "^2.1.4" - node-forge "^1.3.1" - uuid "^9.0.0" - optionalDependencies: - "@google-cloud/firestore" "^6.4.0" - "@google-cloud/storage" "^6.5.2" - -flatted@^3.2.5: - version "3.2.5" - resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.2.5.tgz#76c8584f4fc843db64702a6bd04ab7a8bd666da3" - integrity sha512-WIWGi2L3DyTUvUrwRKgGi9TwxQMUEqPOPQBVi71R96jZXJdFskXEmf54BoZaS1kknGODoIGASGEzBUYdyMCBJg== - -follow-redirects@^1.0.0: - version "1.14.9" - resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.9.tgz#dd4ea157de7bfaf9ea9b3fbd85aa16951f78d8d7" - integrity sha512-MQDfihBQYMcyy5dhRDJUHcw7lb2Pv/TuE6xP1vyraLukNDHKbDxDNaOE3NbCAdKQApno+GPRyo1YAp89yCjK4w== - -form-data@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/form-data/-/form-data-3.0.1.tgz#ebd53791b78356a99af9a300d4282c4d5eb9755f" - integrity sha512-RHkBKtLWUVwd7SqRIvCZMEvAMoGUp0XU+seQiZejj0COz3RI3hWP4sCv3gZWWLjJTd7rGwcsF5eKZGii0r/hbg== - dependencies: - asynckit "^0.4.0" - combined-stream "^1.0.8" - mime-types "^2.1.12" - -from@~0: - version "0.1.7" - resolved "https://registry.yarnpkg.com/from/-/from-0.1.7.tgz#83c60afc58b9c56997007ed1a768b3ab303a44fe" - integrity sha1-g8YK/Fi5xWmXAH7Rp2izqzA6RP4= - -fs-extra@^10.0.1: - version "10.0.1" - resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-10.0.1.tgz#27de43b4320e833f6867cc044bfce29fdf0ef3b8" - integrity sha512-NbdoVMZso2Lsrn/QwLXOy6rm0ufY2zEOKCDzJR/0kBsb0E6qed0P3iYK+Ath3BfvXEeu4JhEtXLgILx5psUfag== - dependencies: - graceful-fs "^4.2.0" - jsonfile "^6.0.1" - universalify "^2.0.0" - -fs.realpath@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" - integrity sha1-FQStJSMVjKpA20onh8sBQRmU6k8= - -fsevents@~2.3.2: - version "2.3.2" - resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a" - integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA== - -function-bind@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d" - integrity sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A== - -functional-red-black-tree@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz#1b0ab3bd553b2a0d6399d29c0e3ea0b252078327" - integrity sha512-dsKNQNdj6xA3T+QlADDA7mOSlX0qiMINjn0cgr+eGHGsbSHzTabcIogz2+p/iqP1Xs6EP/sS2SbqH+brGTbq0g== - -gaxios@^5.0.0, gaxios@^5.0.1: - version "5.0.2" - resolved "https://registry.yarnpkg.com/gaxios/-/gaxios-5.0.2.tgz#ca3a40e851c728d31d7001c2357062d46bf966d1" - integrity sha512-TjtV2AJOZoMQqRYoy5eM8cCQogYwazWNYLQ72QB0kwa6vHHruYkGmhhyrlzbmgNHK1dNnuP2WSH81urfzyN2Og== - dependencies: - extend "^3.0.2" - https-proxy-agent "^5.0.0" - is-stream "^2.0.0" - node-fetch "^2.6.7" - -gcp-metadata@^5.0.0: - version "5.0.1" - resolved "https://registry.yarnpkg.com/gcp-metadata/-/gcp-metadata-5.0.1.tgz#8d1e785ee7fad554bc2a80c1f930c9a9518d2b00" - integrity sha512-jiRJ+Fk7e8FH68Z6TLaqwea307OktJpDjmYnU7/li6ziwvVvU2RlrCyQo5vkdeP94chm0kcSCOOszvmuaioq3g== - dependencies: - gaxios "^5.0.0" - json-bigint "^1.0.0" - -get-caller-file@^2.0.1, get-caller-file@^2.0.5: - version "2.0.5" - resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e" - integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg== - -glamor@~2.20.40: - version "2.20.40" - resolved "https://registry.yarnpkg.com/glamor/-/glamor-2.20.40.tgz#f606660357b7cf18dface731ad1a2cfa93817f05" - integrity sha512-DNXCd+c14N9QF8aAKrfl4xakPk5FdcFwmH7sD0qnC0Pr7xoZ5W9yovhUrY/dJc3psfGGXC58vqQyRtuskyUJxA== - dependencies: - fbjs "^0.8.12" - inline-style-prefixer "^3.0.6" - object-assign "^4.1.1" - prop-types "^15.5.10" - through "^2.3.8" - -glob-parent@~5.1.2: - version "5.1.2" - resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4" - integrity sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow== - dependencies: - is-glob "^4.0.1" - -glob@^7.0.5, glob@^7.1.3, glob@^7.1.6, glob@^7.1.7: - version "7.2.0" - resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.0.tgz#d15535af7732e02e948f4c41628bd910293f6023" - integrity sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q== - dependencies: - fs.realpath "^1.0.0" - inflight "^1.0.4" - inherits "2" - minimatch "^3.0.4" - once "^1.3.0" - path-is-absolute "^1.0.0" - -glob@^8.0.0: - version "8.0.3" - resolved "https://registry.yarnpkg.com/glob/-/glob-8.0.3.tgz#415c6eb2deed9e502c68fa44a272e6da6eeca42e" - integrity sha512-ull455NHSHI/Y1FqGaaYFaLGkNMMJbavMrEGFXG/PGrg6y7sutWHUHrz6gy6WEBH6akM1M414dWKCNs+IhKdiQ== - dependencies: - fs.realpath "^1.0.0" - inflight "^1.0.4" - inherits "2" - minimatch "^5.0.1" - once "^1.3.0" - -google-auth-library@^8.0.1, google-auth-library@^8.0.2: - version "8.7.0" - resolved "https://registry.yarnpkg.com/google-auth-library/-/google-auth-library-8.7.0.tgz#e36e255baba4755ce38dded4c50f896cf8515e51" - integrity sha512-1M0NG5VDIvJZEnstHbRdckLZESoJwguinwN8Dhae0j2ZKIQFIV63zxm6Fo6nM4xkgqUr2bbMtV5Dgo+Hy6oo0Q== - dependencies: - arrify "^2.0.0" - base64-js "^1.3.0" - ecdsa-sig-formatter "^1.0.11" - fast-text-encoding "^1.0.0" - gaxios "^5.0.0" - gcp-metadata "^5.0.0" - gtoken "^6.1.0" - jws "^4.0.0" - lru-cache "^6.0.0" - -google-gax@^3.5.1: - version "3.5.2" - resolved "https://registry.yarnpkg.com/google-gax/-/google-gax-3.5.2.tgz#7c3ad61dbf366a55527b803caead276668b160d8" - integrity sha512-AyP53w0gHcWlzxm+jSgqCR3Xu4Ld7EpSjhtNBnNhzwwWaIUyphH9kBGNIEH+i4UGkTUXOY29K/Re8EiAvkBRGw== - dependencies: - "@grpc/grpc-js" "~1.7.0" - "@grpc/proto-loader" "^0.7.0" - "@types/long" "^4.0.0" - abort-controller "^3.0.0" - duplexify "^4.0.0" - fast-text-encoding "^1.0.3" - google-auth-library "^8.0.2" - is-stream-ended "^0.1.4" - node-fetch "^2.6.1" - object-hash "^3.0.0" - proto3-json-serializer "^1.0.0" - protobufjs "7.1.2" - protobufjs-cli "1.0.2" - retry-request "^5.0.0" - -google-p12-pem@^4.0.0: - version "4.0.1" - resolved "https://registry.yarnpkg.com/google-p12-pem/-/google-p12-pem-4.0.1.tgz#82841798253c65b7dc2a4e5fe9df141db670172a" - integrity sha512-WPkN4yGtz05WZ5EhtlxNDWPhC4JIic6G8ePitwUWy4l+XPVYec+a0j0Ts47PDtW59y3RwAhUd9/h9ZZ63px6RQ== - dependencies: - node-forge "^1.3.1" - -graceful-fs@^4.1.6, graceful-fs@^4.2.0, graceful-fs@^4.2.6: - version "4.2.9" - resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.9.tgz#041b05df45755e587a24942279b9d113146e1c96" - integrity sha512-NtNxqUcXgpW2iMrfqSfR73Glt39K+BLwWsPs94yR63v45T0Wbej7eRmL5cWfwEgqXnmjQp3zaJTshdRW/qC2ZQ== - -graceful-fs@^4.1.9: - version "4.2.10" - resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.10.tgz#147d3a006da4ca3ce14728c7aefc287c367d7a6c" - integrity sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA== - -gtoken@^6.1.0: - version "6.1.2" - resolved "https://registry.yarnpkg.com/gtoken/-/gtoken-6.1.2.tgz#aeb7bdb019ff4c3ba3ac100bbe7b6e74dce0e8bc" - integrity sha512-4ccGpzz7YAr7lxrT2neugmXQ3hP9ho2gcaityLVkiUecAiwiy60Ii8gRbZeOsXV19fYaRjgBSshs8kXw+NKCPQ== - dependencies: - gaxios "^5.0.1" - google-p12-pem "^4.0.0" - jws "^4.0.0" - -has-flag@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b" - integrity sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ== - -has@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/has/-/has-1.0.3.tgz#722d7cbfc1f6aa8241f16dd814e011e1f41e8796" - integrity sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw== - dependencies: - function-bind "^1.1.1" - -http-errors@1.8.1: - version "1.8.1" - resolved "https://registry.yarnpkg.com/http-errors/-/http-errors-1.8.1.tgz#7c3f28577cbc8a207388455dbd62295ed07bd68c" - integrity "sha1-fD8oV3y8iiBziEVdvWIpXtB71ow= sha512-Kpk9Sm7NmI+RHhnj6OIWDI1d6fIoFAtFt9RLaTMRlg/8w49juAStsrBgp0Dp4OdxdVbRIeKhtCUvoi/RuAhO4g==" - dependencies: - depd "~1.1.2" - inherits "2.0.4" - setprototypeof "1.2.0" - statuses ">= 1.5.0 < 2" - toidentifier "1.0.1" - -http-parser-js@>=0.5.1: - version "0.5.6" - resolved "https://registry.yarnpkg.com/http-parser-js/-/http-parser-js-0.5.6.tgz#2e02406ab2df8af8a7abfba62e0da01c62b95afd" - integrity sha512-vDlkRPDJn93swjcjqMSaGSPABbIarsr1TLAui/gLDXzV5VsJNdXNzMYDyNBLQkjWQCJ1uizu8T2oDMhmGt0PRA== - -http-proxy-agent@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/http-proxy-agent/-/http-proxy-agent-5.0.0.tgz#5129800203520d434f142bc78ff3c170800f2b43" - integrity sha512-n2hY8YdoRE1i7r6M0w9DIw5GgZN0G25P8zLCRQ8rjXtTU3vsNFBI/vWK/UIeE6g5MUUz6avwAPXmL6Fy9D/90w== - dependencies: - "@tootallnate/once" "2" - agent-base "6" - debug "4" - -http-proxy@^1.18.1: - version "1.18.1" - resolved "https://registry.yarnpkg.com/http-proxy/-/http-proxy-1.18.1.tgz#401541f0534884bbf95260334e72f88ee3976549" - integrity sha512-7mz/721AbnJwIVbnaSv1Cz3Am0ZLT/UBwkC92VlxhXv/k/BBQfM2fXElQNC27BVGr0uwUpplYPQM9LnaBMR5NQ== - dependencies: - eventemitter3 "^4.0.0" - follow-redirects "^1.0.0" - requires-port "^1.0.0" - -https-proxy-agent@^2.2.1: - version "2.2.4" - resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-2.2.4.tgz#4ee7a737abd92678a293d9b34a1af4d0d08c787b" - integrity sha512-OmvfoQ53WLjtA9HeYP9RNrWMJzzAz1JGaSFr1nijg0PVR1JaD/xbJq1mdEIIlxGpXp9eSe/O2LgU9DJmTPd0Eg== - dependencies: - agent-base "^4.3.0" - debug "^3.1.0" - -https-proxy-agent@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-4.0.0.tgz#702b71fb5520a132a66de1f67541d9e62154d82b" - integrity sha512-zoDhWrkR3of1l9QAL8/scJZyLu8j/gBkcwcaQOZh7Gyh/+uJQzGVETdgT30akuwkpL8HTRfssqI3BZuV18teDg== - dependencies: - agent-base "5" - debug "4" - -https-proxy-agent@^5.0.0: - version "5.0.1" - resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz#c59ef224a04fe8b754f3db0063a25ea30d0005d6" - integrity sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA== - dependencies: - agent-base "6" - debug "4" - -hyphenate-style-name@^1.0.2: - version "1.0.4" - resolved "https://registry.yarnpkg.com/hyphenate-style-name/-/hyphenate-style-name-1.0.4.tgz#691879af8e220aea5750e8827db4ef62a54e361d" - integrity sha512-ygGZLjmXfPHj+ZWh6LwbC37l43MhfztxetbFCoYTM2VjkIUpeHgSNn7QIyVFj7YQ1Wl9Cbw5sholVJPzWvC2MQ== - -iconv-lite@0.4, iconv-lite@0.4.24: - version "0.4.24" - resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.24.tgz#2022b4b25fbddc21d2f524974a474aafe733908b" - integrity sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA== - dependencies: - safer-buffer ">= 2.1.2 < 3" - -iconv-lite@0.6: - version "0.6.3" - resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.6.3.tgz#a52f80bf38da1952eb5c681790719871a1a72501" - integrity sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw== - dependencies: - safer-buffer ">= 2.1.2 < 3.0.0" - -inflight@^1.0.4: - version "1.0.6" - resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" - integrity sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk= - dependencies: - once "^1.3.0" - wrappy "1" - -inherits@2, inherits@2.0.4, inherits@^2.0.3: - version "2.0.4" - resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" - integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== - -inline-style-prefixer@^3.0.6: - version "3.0.8" - resolved "https://registry.yarnpkg.com/inline-style-prefixer/-/inline-style-prefixer-3.0.8.tgz#8551b8e5b4d573244e66a34b04f7d32076a2b534" - integrity sha1-hVG45bTVcyROZqNLBPfTIHaitTQ= - dependencies: - bowser "^1.7.3" - css-in-js-utils "^2.0.0" - -"internmap@1 - 2": - version "2.0.3" - resolved "https://registry.yarnpkg.com/internmap/-/internmap-2.0.3.tgz#6685f23755e43c524e251d29cbc97248e3061009" - integrity sha512-5Hh7Y1wQbvY5ooGgPbDaL5iYLAPzMTUrjMulskHLH6wnv/A+1q5rgEaiuqEjB+oxGXIVZs1FF+R/KPN3ZSQYYg== - -internmap@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/internmap/-/internmap-1.0.1.tgz#0017cc8a3b99605f0302f2b198d272e015e5df95" - integrity sha512-lDB5YccMydFBtasVtxnZ3MRBHuaoE8GKsppq+EchKL2U4nK/DmEpPHNH8MZe5HkMtpSiTSOZwfN0tzYjO/lJEw== - -is-binary-path@~2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/is-binary-path/-/is-binary-path-2.1.0.tgz#ea1f7f3b80f064236e83470f86c09c254fb45b09" - integrity sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw== - dependencies: - binary-extensions "^2.0.0" - -is-core-module@^2.8.1: - version "2.8.1" - resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.8.1.tgz#f59fdfca701d5879d0a6b100a40aa1560ce27211" - integrity sha512-SdNCUs284hr40hFTFP6l0IfZ/RSrMXF3qgoRHd3/79unUTvrFO/JoXwkGm+5J/Oe3E/b5GsnG330uUNgRpu1PA== - dependencies: - has "^1.0.3" - -is-extglob@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2" - integrity sha1-qIwCU1eR8C7TfHahueqXc8gz+MI= - -is-fullwidth-code-point@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz#f116f8064fe90b3f7844a38997c0b75051269f1d" - integrity sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg== - -is-glob@^4.0.1, is-glob@~4.0.1: - version "4.0.3" - resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.3.tgz#64f61e42cbbb2eec2071a9dac0b28ba1e65d5084" - integrity sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg== - dependencies: - is-extglob "^2.1.1" - -is-number@^7.0.0: - version "7.0.0" - resolved "https://registry.yarnpkg.com/is-number/-/is-number-7.0.0.tgz#7535345b896734d5f80c4d06c50955527a14f12b" - integrity sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng== - -is-running@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/is-running/-/is-running-2.1.0.tgz#30a73ff5cc3854e4fc25490809e9f5abf8de09e0" - integrity sha1-MKc/9cw4VOT8JUkICen1q/jeCeA= - -is-stream-ended@^0.1.4: - version "0.1.4" - resolved "https://registry.yarnpkg.com/is-stream-ended/-/is-stream-ended-0.1.4.tgz#f50224e95e06bce0e356d440a4827cd35b267eda" - integrity sha512-xj0XPvmr7bQFTvirqnFr50o0hQIh6ZItDqloxt5aJrR4NQsYeSsyFQERYGCAzfindAcnKjINnwEEgLx4IqVzQw== - -is-stream@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-2.0.1.tgz#fac1e3d53b97ad5a9d0ae9cef2389f5810a5c077" - integrity sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg== - -isbinaryfile@^4.0.8: - version "4.0.8" - resolved "https://registry.yarnpkg.com/isbinaryfile/-/isbinaryfile-4.0.8.tgz#5d34b94865bd4946633ecc78a026fc76c5b11fcf" - integrity sha512-53h6XFniq77YdW+spoRrebh0mnmTxRPTlcuIArO57lmMdq4uBKFKaeTjnb92oYWrSn/LVL+LT+Hap2tFQj8V+w== - -isexe@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" - integrity sha1-6PvzdNxVb/iUehDcsFctYz8s+hA= - -isobject@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/isobject/-/isobject-3.0.1.tgz#4e431e92b11a9731636aa1f9c8d1ccbcfdab78df" - integrity sha1-TkMekrEalzFjaqH5yNHMvP2reN8= - -isomorphic-fetch@^2.1.1: - version "2.2.1" - resolved "https://registry.yarnpkg.com/isomorphic-fetch/-/isomorphic-fetch-2.2.1.tgz#611ae1acf14f5e81f729507472819fe9733558a9" - integrity sha1-YRrhrPFPXoH3KVB0coGf6XM1WKk= - dependencies: - node-fetch "^1.0.1" - whatwg-fetch ">=0.10.0" - -jasmine-core@^3.5.0, jasmine-core@~3.99.0: - version "3.99.1" - resolved "https://registry.yarnpkg.com/jasmine-core/-/jasmine-core-3.99.1.tgz#5bfa4b2d76618868bfac4c8ff08bb26fffa4120d" - integrity sha512-Hu1dmuoGcZ7AfyynN3LsfruwMbxMALMka+YtZeGoLuDEySVmVAPaonkNoBRIw/ectu8b9tVQCJNgp4a4knp+tg== - -jasmine@^3.7.0: - version "3.99.0" - resolved "https://registry.yarnpkg.com/jasmine/-/jasmine-3.99.0.tgz#7cc7aeda7ade2d57694fc818a374f778cbb4ea62" - integrity sha512-YIThBuHzaIIcjxeuLmPD40SjxkEcc8i//sGMDKCgkRMVgIwRJf5qyExtlJpQeh7pkeoBSOe6lQEdg+/9uKg9mw== - dependencies: - glob "^7.1.6" - jasmine-core "~3.99.0" - -jose@^2.0.6: - version "2.0.6" - resolved "https://registry.yarnpkg.com/jose/-/jose-2.0.6.tgz#894ba19169af339d3911be933f913dd02fc57c7c" - integrity sha512-FVoPY7SflDodE4lknJmbAHSUjLCzE2H1F6MS0RYKMQ8SR+lNccpMf8R4eqkNYyyUjR5qZReOzZo5C5YiHOCjjg== - dependencies: - "@panva/asn1.js" "^1.0.0" - -"js-tokens@^3.0.0 || ^4.0.0": - version "4.0.0" - resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" - integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ== - -js2xmlparser@^4.0.2: - version "4.0.2" - resolved "https://registry.yarnpkg.com/js2xmlparser/-/js2xmlparser-4.0.2.tgz#2a1fdf01e90585ef2ae872a01bc169c6a8d5e60a" - integrity sha512-6n4D8gLlLf1n5mNLQPRfViYzu9RATblzPEtm1SthMX1Pjao0r9YI9nw7ZIfRxQMERS87mcswrg+r/OYrPRX6jA== - dependencies: - xmlcreate "^2.0.4" - -jsdoc@^3.6.3: - version "3.6.11" - resolved "https://registry.yarnpkg.com/jsdoc/-/jsdoc-3.6.11.tgz#8bbb5747e6f579f141a5238cbad4e95e004458ce" - integrity sha512-8UCU0TYeIYD9KeLzEcAu2q8N/mx9O3phAGl32nmHlE0LpaJL71mMkP4d+QE5zWfNt50qheHtOZ0qoxVrsX5TUg== - dependencies: - "@babel/parser" "^7.9.4" - "@types/markdown-it" "^12.2.3" - bluebird "^3.7.2" - catharsis "^0.9.0" - escape-string-regexp "^2.0.0" - js2xmlparser "^4.0.2" - klaw "^3.0.0" - markdown-it "^12.3.2" - markdown-it-anchor "^8.4.1" - marked "^4.0.10" - mkdirp "^1.0.4" - requizzle "^0.2.3" - strip-json-comments "^3.1.0" - taffydb "2.6.2" - underscore "~1.13.2" - -json-bigint@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/json-bigint/-/json-bigint-1.0.0.tgz#ae547823ac0cad8398667f8cd9ef4730f5b01ff1" - integrity sha512-SiPv/8VpZuWbvLSMtTDU8hEfrZWg/mH/nV/b4o0CYbSxu1UIQPLdwKOCIyLQX+VIPO5vrLX3i8qtqFyhdPSUSQ== - dependencies: - bignumber.js "^9.0.0" - -json-stringify-pretty-compact@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/json-stringify-pretty-compact/-/json-stringify-pretty-compact-3.0.0.tgz#f71ef9d82ef16483a407869556588e91b681d9ab" - integrity sha512-Rc2suX5meI0S3bfdZuA7JMFBGkJ875ApfVyq2WHELjBiiG22My/l7/8zPpH/CfFVQHuVLd8NLR0nv6vi0BYYKA== - -json-stringify-pretty-compact@~2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/json-stringify-pretty-compact/-/json-stringify-pretty-compact-2.0.0.tgz#e77c419f52ff00c45a31f07f4c820c2433143885" - integrity sha512-WRitRfs6BGq4q8gTgOy4ek7iPFXjbra0H3PmDLKm2xnZ+Gh1HUhiKGgCZkSPNULlP7mvfu6FV/mOLhCarspADQ== - -jsonfile@^6.0.1: - version "6.1.0" - resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-6.1.0.tgz#bc55b2634793c679ec6403094eb13698a6ec0aae" - integrity sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ== - dependencies: - universalify "^2.0.0" - optionalDependencies: - graceful-fs "^4.1.6" - -jsonparse@^1.2.0: - version "1.3.1" - resolved "https://registry.yarnpkg.com/jsonparse/-/jsonparse-1.3.1.tgz#3f4dae4a91fac315f71062f8521cc239f1366280" - integrity sha512-POQXvpdL69+CluYsillJ7SUhKvytYjW9vG/GKpnf+xP8UWgYEM/RaMzHHofbALDiKbbP1W8UEYmgGl39WkPZsg== - -jsonwebtoken@^8.5.1: - version "8.5.1" - resolved "https://registry.yarnpkg.com/jsonwebtoken/-/jsonwebtoken-8.5.1.tgz#00e71e0b8df54c2121a1f26137df2280673bcc0d" - integrity sha512-XjwVfRS6jTMsqYs0EsuJ4LGxXV14zQybNd4L2r0UvbVnSF9Af8x7p5MzbJ90Ioz/9TI41/hTCvznF/loiSzn8w== - dependencies: - jws "^3.2.2" - lodash.includes "^4.3.0" - lodash.isboolean "^3.0.3" - lodash.isinteger "^4.0.4" - lodash.isnumber "^3.0.3" - lodash.isplainobject "^4.0.6" - lodash.isstring "^4.0.1" - lodash.once "^4.0.0" - ms "^2.1.1" - semver "^5.6.0" - -jwa@^1.4.1: - version "1.4.1" - resolved "https://registry.yarnpkg.com/jwa/-/jwa-1.4.1.tgz#743c32985cb9e98655530d53641b66c8645b039a" - integrity sha512-qiLX/xhEEFKUAJ6FiBMbes3w9ATzyk5W7Hvzpa/SLYdxNtng+gcurvrI7TbACjIXlsJyr05/S1oUhZrc63evQA== - dependencies: - buffer-equal-constant-time "1.0.1" - ecdsa-sig-formatter "1.0.11" - safe-buffer "^5.0.1" - -jwa@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/jwa/-/jwa-2.0.0.tgz#a7e9c3f29dae94027ebcaf49975c9345593410fc" - integrity sha512-jrZ2Qx916EA+fq9cEAeCROWPTfCwi1IVHqT2tapuqLEVVDKFDENFw1oL+MwrTvH6msKxsd1YTDVw6uKEcsrLEA== - dependencies: - buffer-equal-constant-time "1.0.1" - ecdsa-sig-formatter "1.0.11" - safe-buffer "^5.0.1" - -jwks-rsa@^2.1.4: - version "2.1.5" - resolved "https://registry.yarnpkg.com/jwks-rsa/-/jwks-rsa-2.1.5.tgz#bb7bf8c5767836bc273bf5b27870066aca39c1bb" - integrity sha512-IODtn1SwEm7n6GQZnQLY0oxKDrMh7n/jRH1MzE8mlxWMrh2NnMyOsXTebu8vJ1qCpmuTJcL4DdiE0E4h8jnwsA== - dependencies: - "@types/express" "^4.17.14" - "@types/jsonwebtoken" "^8.5.9" - debug "^4.3.4" - jose "^2.0.6" - limiter "^1.1.5" - lru-memoizer "^2.1.4" - -jws@^3.2.2: - version "3.2.2" - resolved "https://registry.yarnpkg.com/jws/-/jws-3.2.2.tgz#001099f3639468c9414000e99995fa52fb478304" - integrity sha512-YHlZCB6lMTllWDtSPHz/ZXTsi8S00usEV6v1tjq8tOUZzw7DpSDWVXjXDre6ed1w/pd495ODpHZYSdkRTsa0HA== - dependencies: - jwa "^1.4.1" - safe-buffer "^5.0.1" - -jws@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/jws/-/jws-4.0.0.tgz#2d4e8cf6a318ffaa12615e9dec7e86e6c97310f4" - integrity sha512-KDncfTmOZoOMTFG4mBlG0qUIOlc03fmzH+ru6RgYVZhPkyiy/92Owlt/8UEN+a4TXR1FQetfIpJE8ApdvdVxTg== - dependencies: - jwa "^2.0.0" - safe-buffer "^5.0.1" - -karma-browserstack-launcher@^1.6.0: - version "1.6.0" - resolved "https://registry.yarnpkg.com/karma-browserstack-launcher/-/karma-browserstack-launcher-1.6.0.tgz#2f6000647073e77ae296653b8830b279669766ef" - integrity sha512-Y/UWPdHZkHIVH2To4GWHCTzmrsB6H7PBWy6pw+TWz5sr4HW2mcE+Uj6qWgoVNxvQU1Pfn5LQQzI6EQ65p8QbiQ== - dependencies: - browserstack "~1.5.1" - browserstack-local "^1.3.7" - q "~1.5.0" - -karma-chrome-launcher@^3.1.0: - version "3.1.1" - resolved "https://registry.yarnpkg.com/karma-chrome-launcher/-/karma-chrome-launcher-3.1.1.tgz#baca9cc071b1562a1db241827257bfe5cab597ea" - integrity sha512-hsIglcq1vtboGPAN+DGCISCFOxW+ZVnIqhDQcCMqqCp+4dmJ0Qpq5QAjkbA0X2L9Mi6OBkHi2Srrbmm7pUKkzQ== - dependencies: - which "^1.2.1" - -karma-jasmine@^3.3.1: - version "3.3.1" - resolved "https://registry.yarnpkg.com/karma-jasmine/-/karma-jasmine-3.3.1.tgz#c01b1a2ec973e1531c1f6535e1d7d66b8e4275c2" - integrity "sha1-wBsaLslz4VMcH2U14dfWa45CdcI= sha512-Nxh7eX9mOQMyK0VSsMxdod+bcqrR/ikrmEiWj5M6fwuQ7oI+YEF1FckaDsWfs6TIpULm9f0fTKMjF7XcrvWyqQ==" - dependencies: - jasmine-core "^3.5.0" - -karma@^6.3.16: - version "6.3.17" - resolved "https://registry.yarnpkg.com/karma/-/karma-6.3.17.tgz#5d963fb52463b73e1b5892ecb54c8f21bb04ba1d" - integrity sha512-2TfjHwrRExC8yHoWlPBULyaLwAFmXmxQrcuFImt/JsAsSZu1uOWTZ1ZsWjqQtWpHLiatJOHL5jFjXSJIgCd01g== - dependencies: - "@colors/colors" "1.5.0" - body-parser "^1.19.0" - braces "^3.0.2" - chokidar "^3.5.1" - connect "^3.7.0" - di "^0.0.1" - dom-serialize "^2.2.1" - glob "^7.1.7" - graceful-fs "^4.2.6" - http-proxy "^1.18.1" - isbinaryfile "^4.0.8" - lodash "^4.17.21" - log4js "^6.4.1" - mime "^2.5.2" - minimatch "^3.0.4" - mkdirp "^0.5.5" - qjobs "^1.2.0" - range-parser "^1.2.1" - rimraf "^3.0.2" - socket.io "^4.2.0" - source-map "^0.6.1" - tmp "^0.2.1" - ua-parser-js "^0.7.30" - yargs "^16.1.1" - -klaw@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/klaw/-/klaw-3.0.0.tgz#b11bec9cf2492f06756d6e809ab73a2910259146" - integrity sha512-0Fo5oir+O9jnXu5EefYbVK+mHMBeEVEy2cmctR1O1NECcCkPRreJKrS6Qt/j3KC2C148Dfo9i3pCmCMsdqGr0g== - dependencies: - graceful-fs "^4.1.9" - -levn@~0.3.0: - version "0.3.0" - resolved "https://registry.yarnpkg.com/levn/-/levn-0.3.0.tgz#3b09924edf9f083c0490fdd4c0bc4421e04764ee" - integrity sha512-0OO4y2iOHix2W6ujICbKIaEQXvFQHue65vUG3pb5EUomzPI90z9hsA1VsO/dbIIpC53J8gxM9Q4Oho0jrCM/yA== - dependencies: - prelude-ls "~1.1.2" - type-check "~0.3.2" - -limiter@^1.1.5: - version "1.1.5" - resolved "https://registry.yarnpkg.com/limiter/-/limiter-1.1.5.tgz#8f92a25b3b16c6131293a0cc834b4a838a2aa7c2" - integrity sha512-FWWMIEOxz3GwUI4Ts/IvgVy6LPvoMPgjMdQ185nN6psJyBJ4yOpzqm695/h5umdLJg2vW3GR5iG11MAkR2AzJA== - -linkify-it@^3.0.1: - version "3.0.3" - resolved "https://registry.yarnpkg.com/linkify-it/-/linkify-it-3.0.3.tgz#a98baf44ce45a550efb4d49c769d07524cc2fa2e" - integrity sha512-ynTsyrFSdE5oZ/O9GEf00kPngmOfVwazR5GKDq6EYfhlpFug3J2zybX56a2PRRpc9P+FuSoGNAwjlbDs9jJBPQ== - dependencies: - uc.micro "^1.0.1" - -locate-path@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-5.0.0.tgz#1afba396afd676a6d42504d0a67a3a7eb9f62aa0" - integrity sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g== - dependencies: - p-locate "^4.1.0" - -lodash.camelcase@^4.3.0: - version "4.3.0" - resolved "https://registry.yarnpkg.com/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz#b28aa6288a2b9fc651035c7711f65ab6190331a6" - integrity "sha1-soqmKIorn8ZRA1x3EfZathkDMaY= sha512-TwuEnCnxbc3rAvhf/LbG7tJUDzhqXyFnv3dtzLOPgCG/hODL7WFnsbwktkD7yUV0RrreP/l1PALq/YSg6VvjlA==" - -lodash.clonedeep@^4.5.0: - version "4.5.0" - resolved "https://registry.yarnpkg.com/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz#e23f3f9c4f8fbdde872529c1071857a086e5ccef" - integrity sha512-H5ZhCF25riFd9uB5UCkVKo61m3S/xZk1x4wA6yp/L3RFP6Z/eHH1ymQcGLo7J3GMPfm0V/7m1tryHuGVxpqEBQ== - -lodash.includes@^4.3.0: - version "4.3.0" - resolved "https://registry.yarnpkg.com/lodash.includes/-/lodash.includes-4.3.0.tgz#60bb98a87cb923c68ca1e51325483314849f553f" - integrity sha512-W3Bx6mdkRTGtlJISOvVD/lbqjTlPPUDTMnlXZFnVwi9NKJ6tiAk6LVdlhZMm17VZisqhKcgzpO5Wz91PCt5b0w== - -lodash.isboolean@^3.0.3: - version "3.0.3" - resolved "https://registry.yarnpkg.com/lodash.isboolean/-/lodash.isboolean-3.0.3.tgz#6c2e171db2a257cd96802fd43b01b20d5f5870f6" - integrity sha512-Bz5mupy2SVbPHURB98VAcw+aHh4vRV5IPNhILUCsOzRmsTmSQ17jIuqopAentWoehktxGd9e/hbIXq980/1QJg== - -lodash.isinteger@^4.0.4: - version "4.0.4" - resolved "https://registry.yarnpkg.com/lodash.isinteger/-/lodash.isinteger-4.0.4.tgz#619c0af3d03f8b04c31f5882840b77b11cd68343" - integrity sha512-DBwtEWN2caHQ9/imiNeEA5ys1JoRtRfY3d7V9wkqtbycnAmTvRRmbHKDV4a0EYc678/dia0jrte4tjYwVBaZUA== - -lodash.isnumber@^3.0.3: - version "3.0.3" - resolved "https://registry.yarnpkg.com/lodash.isnumber/-/lodash.isnumber-3.0.3.tgz#3ce76810c5928d03352301ac287317f11c0b1ffc" - integrity sha512-QYqzpfwO3/CWf3XP+Z+tkQsfaLL/EnUlXWVkIk5FUPc4sBdTehEqZONuyRt2P67PXAk+NXmTBcc97zw9t1FQrw== - -lodash.isplainobject@^4.0.6: - version "4.0.6" - resolved "https://registry.yarnpkg.com/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz#7c526a52d89b45c45cc690b88163be0497f550cb" - integrity sha512-oSXzaWypCMHkPC3NvBEaPHf0KsA5mvPrOPgQWDsbg8n7orZ290M0BmC/jgRZ4vcJ6DTAhjrsSYgdsW/F+MFOBA== - -lodash.isstring@^4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/lodash.isstring/-/lodash.isstring-4.0.1.tgz#d527dfb5456eca7cc9bb95d5daeaf88ba54a5451" - integrity sha512-0wJxfxH1wgO3GrbuP+dTTk7op+6L41QCXbGINEmD+ny/G/eCqGzxyCsh7159S+mgDDcoarnBw6PC1PS5+wUGgw== - -lodash.once@^4.0.0: - version "4.1.1" - resolved "https://registry.yarnpkg.com/lodash.once/-/lodash.once-4.1.1.tgz#0dd3971213c7c56df880977d504c88fb471a97ac" - integrity sha512-Sb487aTOCr9drQVL8pIxOzVhafOjZN9UU54hiN8PU3uAiSV7lx1yYNpbNmex2PK6dSJoNTSJUUswT651yww3Mg== - -lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.21: - version "4.17.21" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c" - integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg== - -log4js@^6.4.1: - version "6.4.3" - resolved "https://registry.yarnpkg.com/log4js/-/log4js-6.4.3.tgz#8bddd981846873895bcc55c0961560c7214a8ad7" - integrity sha512-H/oQKcCVIhQ8zCtUh5aftdp9eRpGyVB1M5sKzAJ0i10q5jS+YXk133vtLgzT1RIoWMbIn7QD1LUto8a1hqh6gA== - dependencies: - date-format "^4.0.5" - debug "^4.3.3" - flatted "^3.2.5" - rfdc "^1.3.0" - streamroller "^3.0.5" - -long@4.0.0, long@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/long/-/long-4.0.0.tgz#9a7b71cfb7d361a194ea555241c92f7468d5bf28" - integrity sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA== - -long@^5.0.0: - version "5.2.1" - resolved "https://registry.yarnpkg.com/long/-/long-5.2.1.tgz#e27595d0083d103d2fa2c20c7699f8e0c92b897f" - integrity sha512-GKSNGeNAtw8IryjjkhZxuKB3JzlcLTwjtiQCHKvqQet81I93kXslhDQruGI/QsddO83mcDToBVy7GqGS/zYf/A== - -loose-envify@^1.0.0, loose-envify@^1.4.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.4.0.tgz#71ee51fa7be4caec1a63839f7e682d8132d30caf" - integrity sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q== - dependencies: - js-tokens "^3.0.0 || ^4.0.0" - -lru-cache@^6.0.0: - version "6.0.0" - resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-6.0.0.tgz#6d6fe6570ebd96aaf90fcad1dafa3b2566db3a94" - integrity sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA== - dependencies: - yallist "^4.0.0" - -lru-cache@~4.0.0: - version "4.0.2" - resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-4.0.2.tgz#1d17679c069cda5d040991a09dbc2c0db377e55e" - integrity sha512-uQw9OqphAGiZhkuPlpFGmdTU2tEuhxTourM/19qGJrxBPHAr/f8BT1a0i/lOclESnGatdJG/UCkP9kZB/Lh1iw== - dependencies: - pseudomap "^1.0.1" - yallist "^2.0.0" - -lru-memoizer@^2.1.4: - version "2.1.4" - resolved "https://registry.yarnpkg.com/lru-memoizer/-/lru-memoizer-2.1.4.tgz#b864d92b557f00b1eeb322156a0409cb06dafac6" - integrity sha512-IXAq50s4qwrOBrXJklY+KhgZF+5y98PDaNo0gi/v2KQBFLyWr+JyFvijZXkGKjQj/h9c0OwoE+JZbwUXce76hQ== - dependencies: - lodash.clonedeep "^4.5.0" - lru-cache "~4.0.0" - -map-stream@~0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/map-stream/-/map-stream-0.1.0.tgz#e56aa94c4c8055a16404a0674b78f215f7c8e194" - integrity sha1-5WqpTEyAVaFkBKBnS3jyFffI4ZQ= - -markdown-it-anchor@^8.4.1: - version "8.6.5" - resolved "https://registry.yarnpkg.com/markdown-it-anchor/-/markdown-it-anchor-8.6.5.tgz#30c4bc5bbff327f15ce3c429010ec7ba75e7b5f8" - integrity sha512-PI1qEHHkTNWT+X6Ip9w+paonfIQ+QZP9sCeMYi47oqhH+EsW8CrJ8J7CzV19QVOj6il8ATGbK2nTECj22ZHGvQ== - -markdown-it@^12.3.2: - version "12.3.2" - resolved "https://registry.yarnpkg.com/markdown-it/-/markdown-it-12.3.2.tgz#bf92ac92283fe983fe4de8ff8abfb5ad72cd0c90" - integrity sha512-TchMembfxfNVpHkbtriWltGWc+m3xszaRD0CZup7GFFhzIgQqxIfn3eGj1yZpfuflzPvfkt611B2Q/Bsk1YnGg== - dependencies: - argparse "^2.0.1" - entities "~2.1.0" - linkify-it "^3.0.1" - mdurl "^1.0.1" - uc.micro "^1.0.5" - -marked@^4.0.10: - version "4.2.2" - resolved "https://registry.yarnpkg.com/marked/-/marked-4.2.2.tgz#1d2075ad6cdfe42e651ac221c32d949a26c0672a" - integrity sha512-JjBTFTAvuTgANXx82a5vzK9JLSMoV6V3LBVn4Uhdso6t7vXrGx7g1Cd2r6NYSsxrYbQGFCMqBDhFHyK5q2UvcQ== - -mdurl@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/mdurl/-/mdurl-1.0.1.tgz#fe85b2ec75a59037f2adfec100fd6c601761152e" - integrity sha512-/sKlQJCBYVY9Ers9hqzKou4H6V5UWc/M59TH2dvkt+84itfnq7uFOMLpOiOS4ujvHP4etln18fmIxA5R5fll0g== - -media-typer@0.3.0: - version "0.3.0" - resolved "https://registry.yarnpkg.com/media-typer/-/media-typer-0.3.0.tgz#8710d7af0aa626f8fffa1ce00168545263255748" - integrity sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g= - -mime-db@1.52.0, "mime-db@>= 1.43.0 < 2": - version "1.52.0" - resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.52.0.tgz#bbabcdc02859f4987301c856e3387ce5ec43bf70" - integrity sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg== - -mime-types@^2.0.8, mime-types@^2.1.12, mime-types@~2.1.24, mime-types@~2.1.34: - version "2.1.35" - resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.35.tgz#381a871b62a734450660ae3deee44813f70d959a" - integrity sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw== - dependencies: - mime-db "1.52.0" - -mime@^2.5.2: - version "2.6.0" - resolved "https://registry.yarnpkg.com/mime/-/mime-2.6.0.tgz#a2a682a95cd4d0cb1d6257e28f83da7e35800367" - integrity sha512-USPkMeET31rOMiarsBNIHZKLGgvKc/LrjofAnBlOttf5ajRvqiRA8QsenbcooctK6d6Ts6aqZXBA+XbkKthiQg== - -mime@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/mime/-/mime-3.0.0.tgz#b374550dca3a0c18443b0c950a6a58f1931cf7a7" - integrity sha512-jSCU7/VB1loIWBZe14aEYHU/+1UMEHoaO7qxCOVJOw9GgH72VAWppxNcjU+x9a2k3GSIBXNKxXQFqRvvZ7vr3A== - -minimatch@^3.0.4: - version "3.1.2" - resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b" - integrity sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw== - dependencies: - brace-expansion "^1.1.7" - -minimatch@^5.0.1: - version "5.1.0" - resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-5.1.0.tgz#1717b464f4971b144f6aabe8f2d0b8e4511e09c7" - integrity sha512-9TPBGGak4nHfGZsPBohm9AWg6NoT7QTCehS3BIJABslyZbzxfV78QM2Y6+i741OPZIafFAaiiEMh5OyIrJPgtg== - dependencies: - brace-expansion "^2.0.1" - -minimist@1.2.6, minimist@^1.2.0, minimist@^1.2.5: - version "1.2.6" - resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.6.tgz#8637a5b759ea0d6e98702cfb3a9283323c93af44" - integrity sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q== - -mkdirp@^0.5.5: - version "0.5.5" - resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.5.tgz#d91cefd62d1436ca0f41620e251288d420099def" - integrity sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ== - dependencies: - minimist "^1.2.5" - -mkdirp@^1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-1.0.4.tgz#3eb5ed62622756d79a5f0e2a221dfebad75c2f7e" - integrity sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw== - -ms@2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" - integrity sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g= - -ms@2.1.2: - version "2.1.2" - resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" - integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== - -ms@^2.1.1: - version "2.1.3" - resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2" - integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA== - -negotiator@0.6.3: - version "0.6.3" - resolved "https://registry.yarnpkg.com/negotiator/-/negotiator-0.6.3.tgz#58e323a72fedc0d6f9cd4d31fe49f51479590ccd" - integrity sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg== - -node-fetch@2.6.7, node-fetch@^1.0.1, node-fetch@^2.6.1, node-fetch@^2.6.7, node-fetch@~2.6.1: - version "2.6.7" - resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.7.tgz#24de9fba827e3b4ae44dc8b20256a379160052ad" - integrity sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ== - dependencies: - whatwg-url "^5.0.0" - -node-forge@^1.3.1: - version "1.3.1" - resolved "https://registry.yarnpkg.com/node-forge/-/node-forge-1.3.1.tgz#be8da2af243b2417d5f646a770663a92b7e9ded3" - integrity sha512-dPEtOeMvF9VMcYV/1Wb8CPoVAXtp6MKMlcbAt4ddqmGqUJ6fQZFXkNZNkNlfevtNkGtaSoXf/vNNNSvgrdXwtA== - -normalize-path@^3.0.0, normalize-path@~3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-3.0.0.tgz#0dcd69ff23a1c9b11fd0978316644a0388216a65" - integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA== - -object-assign@^4, object-assign@^4.1.0, object-assign@^4.1.1: - version "4.1.1" - resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" - integrity sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM= - -object-hash@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/object-hash/-/object-hash-3.0.0.tgz#73f97f753e7baffc0e2cc9d6e079079744ac82e9" - integrity sha512-RSn9F68PjH9HqtltsSnqYC1XXoWe9Bju5+213R98cNGttag9q9yAOTzdbsqvIa7aNm5WffBZFpWYr2aWrklWAw== - -on-finished@~2.3.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/on-finished/-/on-finished-2.3.0.tgz#20f1336481b083cd75337992a16971aa2d906947" - integrity sha1-IPEzZIGwg811M3mSoWlxqi2QaUc= - dependencies: - ee-first "1.1.1" - -once@^1.3.0, once@^1.4.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" - integrity sha1-WDsap3WWHUsROsF9nFC6753Xa9E= - dependencies: - wrappy "1" - -optionator@^0.8.1: - version "0.8.3" - resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.8.3.tgz#84fa1d036fe9d3c7e21d99884b601167ec8fb495" - integrity sha512-+IW9pACdk3XWmmTXG8m3upGUJst5XRGzxMRjXzAuJ1XnIFNvfhjjIuYkDvysnPQ7qzqVzLt78BCruntqRhWQbA== - dependencies: - deep-is "~0.1.3" - fast-levenshtein "~2.0.6" - levn "~0.3.0" - prelude-ls "~1.1.2" - type-check "~0.3.2" - word-wrap "~1.2.3" - -p-limit@^2.2.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-2.3.0.tgz#3dd33c647a214fdfffd835933eb086da0dc21db1" - integrity sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w== - dependencies: - p-try "^2.0.0" - -p-limit@^3.0.1: - version "3.1.0" - resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-3.1.0.tgz#e1daccbe78d0d1388ca18c64fea38e3e57e3706b" - integrity sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ== - dependencies: - yocto-queue "^0.1.0" - -p-locate@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-4.1.0.tgz#a3428bb7088b3a60292f66919278b7c297ad4f07" - integrity sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A== - dependencies: - p-limit "^2.2.0" - -p-try@^2.0.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/p-try/-/p-try-2.2.0.tgz#cb2868540e313d61de58fafbe35ce9004d5540e6" - integrity sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ== - -parseurl@~1.3.3: - version "1.3.3" - resolved "https://registry.yarnpkg.com/parseurl/-/parseurl-1.3.3.tgz#9da19e7bee8d12dff0513ed5b76957793bc2e8d4" - integrity sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ== - -path-exists@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-4.0.0.tgz#513bdbe2d3b95d7762e8c1137efa195c6c61b5b3" - integrity sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w== - -path-is-absolute@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" - integrity sha1-F0uSaHNVNP+8es5r9TpanhtcX18= - -path-parse@^1.0.7: - version "1.0.7" - resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.7.tgz#fbc114b60ca42b30d9daf5858e4bd68bbedb6735" - integrity sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw== - -pause-stream@0.0.11: - version "0.0.11" - resolved "https://registry.yarnpkg.com/pause-stream/-/pause-stream-0.0.11.tgz#fe5a34b0cbce12b5aa6a2b403ee2e73b602f1445" - integrity sha1-/lo0sMvOErWqaitAPuLnO2AvFEU= - dependencies: - through "~2.3" - -picomatch@^2.0.4, picomatch@^2.2.1: - version "2.3.1" - resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42" - integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA== - -preact@~8.2.9: - version "8.2.9" - resolved "https://registry.yarnpkg.com/preact/-/preact-8.2.9.tgz#813ba9dd45e5d97c5ea0d6c86d375b3be711cc40" - integrity sha512-ThuGXBmJS3VsT+jIP+eQufD3L8pRw/PY3FoCys6O9Pu6aF12Pn9zAJDX99TfwRAFOCEKm/P0lwiPTbqKMJp0fA== - -prelude-ls@~1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54" - integrity sha512-ESF23V4SKG6lVSGZgYNpbsiaAkdab6ZgOxe52p7+Kid3W3u3bxR4Vfd/o21dmN7jSt0IwgZ4v5MUd26FEtXE9w== - -promise@^7.1.1: - version "7.3.1" - resolved "https://registry.yarnpkg.com/promise/-/promise-7.3.1.tgz#064b72602b18f90f29192b8b1bc418ffd1ebd3bf" - integrity sha512-nolQXZ/4L+bP/UGlkfaIujX9BKxGwmQ9OT4mOt5yvy8iK1h3wqTEJCijzGANTCCl9nWjY41juyAn2K3Q1hLLTg== - dependencies: - asap "~2.0.3" - -prop-types@^15.5.10: - version "15.8.1" - resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.8.1.tgz#67d87bf1a694f48435cf332c24af10214a3140b5" - integrity sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg== - dependencies: - loose-envify "^1.4.0" - object-assign "^4.1.1" - react-is "^16.13.1" - -proto3-json-serializer@^1.0.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/proto3-json-serializer/-/proto3-json-serializer-1.1.0.tgz#52d9c73b24d25ff925639e1e5a01ac883460149f" - integrity sha512-SjXwUWe/vANGs/mJJTbw5++7U67nwsymg7qsoPtw6GiXqw3kUy8ByojrlEdVE2efxAdKreX8WkDafxvYW95ZQg== - dependencies: - protobufjs "^7.0.0" - -protobufjs-cli@1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/protobufjs-cli/-/protobufjs-cli-1.0.2.tgz#905fc49007cf4aaf3c45d5f250eb294eedeea062" - integrity sha512-cz9Pq9p/Zs7okc6avH20W7QuyjTclwJPgqXG11jNaulfS3nbVisID8rC+prfgq0gbZE0w9LBFd1OKFF03kgFzg== - dependencies: - chalk "^4.0.0" - escodegen "^1.13.0" - espree "^9.0.0" - estraverse "^5.1.0" - glob "^8.0.0" - jsdoc "^3.6.3" - minimist "^1.2.0" - semver "^7.1.2" - tmp "^0.2.1" - uglify-js "^3.7.7" - -protobufjs@7.1.2, protobufjs@^7.0.0: - version "7.1.2" - resolved "https://registry.yarnpkg.com/protobufjs/-/protobufjs-7.1.2.tgz#a0cf6aeaf82f5625bffcf5a38b7cd2a7de05890c" - integrity sha512-4ZPTPkXCdel3+L81yw3dG6+Kq3umdWKh7Dc7GW/CpNk4SX3hK58iPCWeCyhVTDrbkNeKrYNZ7EojM5WDaEWTLQ== - dependencies: - "@protobufjs/aspromise" "^1.1.2" - "@protobufjs/base64" "^1.1.2" - "@protobufjs/codegen" "^2.0.4" - "@protobufjs/eventemitter" "^1.1.0" - "@protobufjs/fetch" "^1.1.0" - "@protobufjs/float" "^1.0.2" - "@protobufjs/inquire" "^1.1.0" - "@protobufjs/path" "^1.1.2" - "@protobufjs/pool" "^1.1.0" - "@protobufjs/utf8" "^1.1.0" - "@types/node" ">=13.7.0" - long "^5.0.0" - -ps-tree@=1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/ps-tree/-/ps-tree-1.2.0.tgz#5e7425b89508736cdd4f2224d028f7bb3f722ebd" - integrity sha512-0VnamPPYHl4uaU/nSFeZZpR21QAWRz+sRv4iW9+v/GS/J5U5iZB5BNN6J0RMoOvdx2gWM2+ZFMIm58q24e4UYA== - dependencies: - event-stream "=3.3.4" - -pseudomap@^1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/pseudomap/-/pseudomap-1.0.2.tgz#f052a28da70e618917ef0a8ac34c1ae5a68286b3" - integrity sha512-b/YwNhb8lk1Zz2+bXXpS/LK9OisiZZ1SNsSLxN1x2OXVEhW2Ckr/7mWE5vrC1ZTiJlD9g19jWszTmJsB+oEpFQ== - -q@~1.5.0: - version "1.5.1" - resolved "https://registry.yarnpkg.com/q/-/q-1.5.1.tgz#7e32f75b41381291d04611f1bf14109ac00651d7" - integrity sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc= - -qjobs@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/qjobs/-/qjobs-1.2.0.tgz#c45e9c61800bd087ef88d7e256423bdd49e5d071" - integrity sha512-8YOJEHtxpySA3fFDyCRxA+UUV+fA+rTWnuWvylOK/NCjhY+b4ocCtmu8TtsWb+mYeU+GCHf/S66KZF/AsteKHg== - -qs@6.9.7: - version "6.9.7" - resolved "https://registry.yarnpkg.com/qs/-/qs-6.9.7.tgz#4610846871485e1e048f44ae3b94033f0e675afe" - integrity sha512-IhMFgUmuNpyRfxA90umL7ByLlgRXu6tIfKPpF5TmcfRLlLCckfP/g3IQmju6jjpu+Hh8rA+2p6A27ZSPOOHdKw== - -range-parser@^1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/range-parser/-/range-parser-1.2.1.tgz#3cf37023d199e1c24d1a55b84800c2f3e6468031" - integrity sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg== - -raw-body@2.4.3: - version "2.4.3" - resolved "https://registry.yarnpkg.com/raw-body/-/raw-body-2.4.3.tgz#8f80305d11c2a0a545c2d9d89d7a0286fcead43c" - integrity sha512-UlTNLIcu0uzb4D2f4WltY6cVjLi+/jEN4lgEUj3E04tpMDpUlkBo/eSn6zou9hum2VMNpCCUone0O0WeJim07g== - dependencies: - bytes "3.1.2" - http-errors "1.8.1" - iconv-lite "0.4.24" - unpipe "1.0.0" - -react-is@^16.13.1: - version "16.13.1" - resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4" - integrity sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ== - -readable-stream@^3.1.1: - version "3.6.0" - resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-3.6.0.tgz#337bbda3adc0706bd3e024426a286d4b4b2c9198" - integrity sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA== - dependencies: - inherits "^2.0.3" - string_decoder "^1.1.1" - util-deprecate "^1.0.1" - -readdirp@~3.6.0: - version "3.6.0" - resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-3.6.0.tgz#74a370bd857116e245b29cc97340cd431a02a6c7" - integrity sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA== - dependencies: - picomatch "^2.2.1" - -regenerator-runtime@^0.13.5: - version "0.13.9" - resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.9.tgz#8925742a98ffd90814988d7566ad30ca3b263b52" - integrity sha512-p3VT+cOEgxFsRRA9X4lkI1E+k2/CtnKtU4gcxyaCUreilL/vqI6CdZ3wxVUx3UOUg+gnUOQQcRI7BmSI656MYA== - -require-directory@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42" - integrity sha1-jGStX9MNqxyXbiNE/+f3kqam30I= - -require-main-filename@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-2.0.0.tgz#d0b329ecc7cc0f61649f62215be69af54aa8989b" - integrity sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg== - -requires-port@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/requires-port/-/requires-port-1.0.0.tgz#925d2601d39ac485e091cf0da5c6e694dc3dcaff" - integrity sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8= - -requizzle@^0.2.3: - version "0.2.3" - resolved "https://registry.yarnpkg.com/requizzle/-/requizzle-0.2.3.tgz#4675c90aacafb2c036bd39ba2daa4a1cb777fded" - integrity sha512-YanoyJjykPxGHii0fZP0uUPEXpvqfBDxWV7s6GKAiiOsiqhX6vHNyW3Qzdmqp/iq/ExbhaGbVrjB4ruEVSM4GQ== - dependencies: - lodash "^4.17.14" - -resolve@^1.1.10: - version "1.22.0" - resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.22.0.tgz#5e0b8c67c15df57a89bdbabe603a002f21731198" - integrity sha512-Hhtrw0nLeSrFQ7phPp4OOcVjLPIeMnRlr5mcnVuMe7M/7eBn98A3hmFRLoFo3DLZkivSYwhRUJTyPyWAk56WLw== - dependencies: - is-core-module "^2.8.1" - path-parse "^1.0.7" - supports-preserve-symlinks-flag "^1.0.0" - -retry-request@^5.0.0: - version "5.0.2" - resolved "https://registry.yarnpkg.com/retry-request/-/retry-request-5.0.2.tgz#143d85f90c755af407fcc46b7166a4ba520e44da" - integrity sha512-wfI3pk7EE80lCIXprqh7ym48IHYdwmAAzESdbU8Q9l7pnRCk9LEhpbOTNKjz6FARLm/Bl5m+4F0ABxOkYUujSQ== - dependencies: - debug "^4.1.1" - extend "^3.0.2" - -retry@0.13.1: - version "0.13.1" - resolved "https://registry.yarnpkg.com/retry/-/retry-0.13.1.tgz#185b1587acf67919d63b357349e03537b2484658" - integrity sha512-XQBQ3I8W1Cge0Seh+6gjj03LbmRFWuoszgK9ooCpwYIrhhoO80pfq4cUkU5DkknwfOfFteRwlZ56PYOGYyFWdg== - -rfdc@^1.3.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/rfdc/-/rfdc-1.3.0.tgz#d0b7c441ab2720d05dc4cf26e01c89631d9da08b" - integrity sha512-V2hovdzFbOi77/WajaSMXk2OLm+xNIeQdMMuB7icj7bk6zi2F8GGAxigcnDFpJHbNyNcgyJDiP+8nOrY5cZGrA== - -rimraf@^3.0.0, rimraf@^3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-3.0.2.tgz#f1a5402ba6220ad52cc1282bac1ae3aa49fd061a" - integrity sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA== - dependencies: - glob "^7.1.3" - -rimraf@~2.5.2: - version "2.5.4" - resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.5.4.tgz#96800093cbf1a0c86bd95b4625467535c29dfa04" - integrity sha1-loAAk8vxoMhr2VtGJUZ1NcKd+gQ= - dependencies: - glob "^7.0.5" - -rw@1: - version "1.3.3" - resolved "https://registry.yarnpkg.com/rw/-/rw-1.3.3.tgz#3f862dfa91ab766b14885ef4d01124bfda074fb4" - integrity sha1-P4Yt+pGrdmsUiF700BEkv9oHT7Q= - -safe-buffer@>=5.1.0, safe-buffer@^5.0.1, safe-buffer@~5.2.0: - version "5.2.1" - resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" - integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== - -"safer-buffer@>= 2.1.2 < 3", "safer-buffer@>= 2.1.2 < 3.0.0": - version "2.1.2" - resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a" - integrity sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg== - -seedrandom@^3.0.5: - version "3.0.5" - resolved "https://registry.yarnpkg.com/seedrandom/-/seedrandom-3.0.5.tgz#54edc85c95222525b0c7a6f6b3543d8e0b3aa0a7" - integrity sha512-8OwmbklUNzwezjGInmZ+2clQmExQPvomqjL7LFqOYqtmuxRgQYqOD3mHaU+MvZn5FLUeVxVfQjwLZW/n/JFuqg== - -semver@^5.6.0: - version "5.7.1" - resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" - integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ== - -semver@^7.1.2: - version "7.3.8" - resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.8.tgz#07a78feafb3f7b32347d725e33de7e2a2df67798" - integrity sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A== - dependencies: - lru-cache "^6.0.0" - -semver@^7.3.5: - version "7.3.5" - resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.5.tgz#0b621c879348d8998e4b0e4be94b3f12e6018ef7" - integrity sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ== - dependencies: - lru-cache "^6.0.0" - -set-blocking@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7" - integrity sha1-BF+XgtARrppoA93TgrJDkrPYkPc= - -setimmediate@^1.0.5: - version "1.0.5" - resolved "https://registry.yarnpkg.com/setimmediate/-/setimmediate-1.0.5.tgz#290cbb232e306942d7d7ea9b83732ab7856f8285" - integrity sha1-KQy7Iy4waULX1+qbg3Mqt4VvgoU= - -setprototypeof@1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/setprototypeof/-/setprototypeof-1.2.0.tgz#66c9a24a73f9fc28cbe66b09fed3d33dcaf1b424" - integrity "sha1-ZsmiSnP5/CjL5msJ/tPTPcrxtCQ= sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==" - -socket.io-adapter@~2.3.3: - version "2.3.3" - resolved "https://registry.yarnpkg.com/socket.io-adapter/-/socket.io-adapter-2.3.3.tgz#4d6111e4d42e9f7646e365b4f578269821f13486" - integrity sha512-Qd/iwn3VskrpNO60BeRyCyr8ZWw9CPZyitW4AQwmRZ8zCiyDiL+znRnWX6tDHXnWn1sJrM1+b6Mn6wEDJJ4aYQ== - -socket.io-parser@~4.0.4: - version "4.0.5" - resolved "https://registry.yarnpkg.com/socket.io-parser/-/socket.io-parser-4.0.5.tgz#cb404382c32324cc962f27f3a44058cf6e0552df" - integrity sha512-sNjbT9dX63nqUFIOv95tTVm6elyIU4RvB1m8dOeZt+IgWwcWklFDOdmGcfo3zSiRsnR/3pJkjY5lfoGqEe4Eig== - dependencies: - "@types/component-emitter" "^1.2.10" - component-emitter "~1.3.0" - debug "~4.3.1" - -socket.io@^4.2.0, socket.io@~4.4.1: - version "4.4.1" - resolved "https://registry.yarnpkg.com/socket.io/-/socket.io-4.4.1.tgz#cd6de29e277a161d176832bb24f64ee045c56ab8" - integrity sha512-s04vrBswdQBUmuWJuuNTmXUVJhP0cVky8bBDhdkf8y0Ptsu7fKU2LuLbts9g+pdmAdyMMn8F/9Mf1/wbtUN0fg== - dependencies: - accepts "~1.3.4" - base64id "~2.0.0" - debug "~4.3.2" - engine.io "~6.1.0" - socket.io-adapter "~2.3.3" - socket.io-parser "~4.0.4" - -source-map@^0.6.1, source-map@~0.6.1: - version "0.6.1" - resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" - integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== - -split@0.3: - version "0.3.3" - resolved "https://registry.yarnpkg.com/split/-/split-0.3.3.tgz#cd0eea5e63a211dfff7eb0f091c4133e2d0dd28f" - integrity sha1-zQ7qXmOiEd//frDwkcQTPi0N0o8= - dependencies: - through "2" - -sprintf-js@~1.0.2: - version "1.0.3" - resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" - integrity sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw= - -"statuses@>= 1.5.0 < 2", statuses@~1.5.0: - version "1.5.0" - resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.5.0.tgz#161c7dac177659fd9811f43771fa99381478628c" - integrity sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow= - -stream-combiner@~0.0.4: - version "0.0.4" - resolved "https://registry.yarnpkg.com/stream-combiner/-/stream-combiner-0.0.4.tgz#4d5e433c185261dde623ca3f44c586bcf5c4ad14" - integrity sha1-TV5DPBhSYd3mI8o/RMWGvPXErRQ= - dependencies: - duplexer "~0.1.1" - -stream-events@^1.0.5: - version "1.0.5" - resolved "https://registry.yarnpkg.com/stream-events/-/stream-events-1.0.5.tgz#bbc898ec4df33a4902d892333d47da9bf1c406d5" - integrity sha512-E1GUzBSgvct8Jsb3v2X15pjzN1tYebtbLaMg+eBOUOAxgbLoSbT2NS91ckc5lJD1KfLjId+jXJRgo0qnV5Nerg== - dependencies: - stubs "^3.0.0" - -stream-shift@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/stream-shift/-/stream-shift-1.0.1.tgz#d7088281559ab2778424279b0877da3c392d5a3d" - integrity sha512-AiisoFqQ0vbGcZgQPY1cdP2I76glaVA/RauYR4G4thNFgkTqr90yXTo4LYX60Jl+sIlPNHHdGSwo01AvbKUSVQ== - -streamroller@^3.0.5: - version "3.0.5" - resolved "https://registry.yarnpkg.com/streamroller/-/streamroller-3.0.5.tgz#17e348dc2a662f9f325373549ab91d55316051ab" - integrity sha512-5uzTEUIi4OB5zy/H30kbUN/zpDNJsFUA+Z47ZL8EfrP93lcZvRLEqdbhdunEPa7CouuAzXXsHpCJ9dg90Umw7g== - dependencies: - date-format "^4.0.5" - debug "^4.3.3" - fs-extra "^10.0.1" - -string-width@^4.1.0, string-width@^4.2.0: - version "4.2.3" - resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" - integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== - dependencies: - emoji-regex "^8.0.0" - is-fullwidth-code-point "^3.0.0" - strip-ansi "^6.0.1" - -string_decoder@^1.1.1, string_decoder@^1.3.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.3.0.tgz#42f114594a46cf1a8e30b0a84f56c78c3edac21e" - integrity sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA== - dependencies: - safe-buffer "~5.2.0" - -strip-ansi@^6.0.0, strip-ansi@^6.0.1: - version "6.0.1" - resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" - integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== - dependencies: - ansi-regex "^5.0.1" - -strip-json-comments@^3.1.0: - version "3.1.1" - resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-3.1.1.tgz#31f1281b3832630434831c310c01cccda8cbe006" - integrity sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig== - -stubs@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/stubs/-/stubs-3.0.0.tgz#e8d2ba1fa9c90570303c030b6900f7d5f89abe5b" - integrity sha512-PdHt7hHUJKxvTCgbKX9C1V/ftOcjJQgz8BZwNfV5c4B6dcGqlpelTbJ999jBGZ2jYiPAwcX5dP6oBwVlBlUbxw== - -supports-color@^7.1.0: - version "7.2.0" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-7.2.0.tgz#1b7dcdcb32b8138801b3e478ba6a51caa89648da" - integrity sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw== - dependencies: - has-flag "^4.0.0" - -supports-preserve-symlinks-flag@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz#6eda4bd344a3c94aea376d4cc31bc77311039e09" - integrity sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w== - -taffydb@2.6.2: - version "2.6.2" - resolved "https://registry.yarnpkg.com/taffydb/-/taffydb-2.6.2.tgz#7cbcb64b5a141b6a2efc2c5d2c67b4e150b2a268" - integrity sha512-y3JaeRSplks6NYQuCOj3ZFMO3j60rTwbuKCvZxsAraGYH2epusatvZ0baZYA01WsGqJBq/Dl6vOrMUJqyMj8kA== - -teeny-request@^8.0.0: - version "8.0.2" - resolved "https://registry.yarnpkg.com/teeny-request/-/teeny-request-8.0.2.tgz#c06a75101cf782788ba8f9a2ed5f2ac84c1c4e15" - integrity sha512-34pe0a4zASseXZCKdeTiIZqSKA8ETHb1EwItZr01PAR3CLPojeAKgSjzeNS4373gi59hNulyDrPKEbh2zO9sCg== - dependencies: - http-proxy-agent "^5.0.0" - https-proxy-agent "^5.0.0" - node-fetch "^2.6.1" - stream-events "^1.0.5" - uuid "^9.0.0" - -temp-fs@^0.9.9: - version "0.9.9" - resolved "https://registry.yarnpkg.com/temp-fs/-/temp-fs-0.9.9.tgz#8071730437870720e9431532fe2814364f8803d7" - integrity sha1-gHFzBDeHByDpQxUy/igUNk+IA9c= - dependencies: - rimraf "~2.5.2" - -text-decoding@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/text-decoding/-/text-decoding-1.0.0.tgz#38a5692d23b5c2b12942d6e245599cb58b1bc52f" - integrity sha512-/0TJD42KDnVwKmDK6jj3xP7E2MG7SHAOG4tyTgyUCRPdHwvkquYNLEQltmdMa3owq3TkddCVcTsoctJI8VQNKA== - -through@2, "through@>=2.2.7 <3", through@^2.3.8, through@~2.3, through@~2.3.1: - version "2.3.8" - resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5" - integrity sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg== - -tmp@^0.2.1: - version "0.2.1" - resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.2.1.tgz#8457fc3037dcf4719c251367a1af6500ee1ccf14" - integrity sha512-76SUhtfqR2Ijn+xllcI5P1oyannHNHByD80W1q447gU3mp9G9PSpGdWmjUOHRDPiHYacIk66W7ubDTuPF3BEtQ== - dependencies: - rimraf "^3.0.0" - -to-regex-range@^5.0.1: - version "5.0.1" - resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-5.0.1.tgz#1648c44aae7c8d988a326018ed72f5b4dd0392e4" - integrity sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ== - dependencies: - is-number "^7.0.0" - -toidentifier@1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/toidentifier/-/toidentifier-1.0.1.tgz#3be34321a88a820ed1bd80dfaa33e479fbb8dd35" - integrity "sha1-O+NDIaiKgg7RvYDfqjPkefu43TU= sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==" - -topojson-client@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/topojson-client/-/topojson-client-3.1.0.tgz#22e8b1ed08a2b922feeb4af6f53b6ef09a467b99" - integrity sha512-605uxS6bcYxGXw9qi62XyrV6Q3xwbndjachmNxu8HWTtVPxZfEJN9fd/SZS1Q54Sn2y0TMyMxFj/cJINqGHrKw== - dependencies: - commander "2" - -tr46@~0.0.3: - version "0.0.3" - resolved "https://registry.yarnpkg.com/tr46/-/tr46-0.0.3.tgz#8184fd347dac9cdc185992f3a6622e14b9d9ab6a" - integrity sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o= - -tslib@^2.1.0: - version "2.3.1" - resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.3.1.tgz#e8a335add5ceae51aa261d32a490158ef042ef01" - integrity sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw== - -tslib@~2.0.0: - version "2.0.3" - resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.0.3.tgz#8e0741ac45fc0c226e58a17bfc3e64b9bc6ca61c" - integrity sha512-uZtkfKblCEQtZKBF6EBXVZeQNl82yqtDQdv+eck8u7tdPxjLu2/lp5/uPW+um2tpuxINHWy3GhiccY7QgEaVHQ== - -type-check@~0.3.2: - version "0.3.2" - resolved "https://registry.yarnpkg.com/type-check/-/type-check-0.3.2.tgz#5884cab512cf1d355e3fb784f30804b2b520db72" - integrity sha512-ZCmOJdvOWDBYJlzAoFkC+Q0+bUyEOS1ltgp1MGU03fqHG+dbi9tBFU2Rd9QKiDZFAYrhPh2JUf7rZRIuHRKtOg== - dependencies: - prelude-ls "~1.1.2" - -type-is@~1.6.18: - version "1.6.18" - resolved "https://registry.yarnpkg.com/type-is/-/type-is-1.6.18.tgz#4e552cd05df09467dcbc4ef739de89f2cf37c131" - integrity sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g== - dependencies: - media-typer "0.3.0" - mime-types "~2.1.24" - -ua-parser-js@^0.7.30: - version "0.7.33" - resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.33.tgz#1d04acb4ccef9293df6f70f2c3d22f3030d8b532" - integrity sha512-s8ax/CeZdK9R/56Sui0WM6y9OFREJarMRHqLB2EwkovemBxNQ+Bqu8GAsUnVcXKgphb++ghr/B2BZx4mahujPw== - -uc.micro@^1.0.1, uc.micro@^1.0.5: - version "1.0.6" - resolved "https://registry.yarnpkg.com/uc.micro/-/uc.micro-1.0.6.tgz#9c411a802a409a91fc6cf74081baba34b24499ac" - integrity sha512-8Y75pvTYkLJW2hWQHXxoqRgV7qb9B+9vFEtidML+7koHUFapnVJAZ6cKs+Qjz5Aw3aZWHMC6u0wJE3At+nSGwA== - -uglify-js@^3.7.7: - version "3.17.4" - resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.17.4.tgz#61678cf5fa3f5b7eb789bb345df29afb8257c22c" - integrity sha512-T9q82TJI9e/C1TAxYvfb16xO120tMVFZrGA3f9/P4424DNu6ypK103y0GPFVa17yotwSyZW5iYXgjYHkGrJW/g== - -underscore@~1.13.2: - version "1.13.6" - resolved "https://registry.yarnpkg.com/underscore/-/underscore-1.13.6.tgz#04786a1f589dc6c09f761fc5f45b89e935136441" - integrity sha512-+A5Sja4HP1M08MaXya7p5LvjuM7K6q/2EaC0+iovj/wOcMsTzMvDFbasi/oSapiwOlt252IqsKqPjCl7huKS0A== - -universalify@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/universalify/-/universalify-2.0.0.tgz#75a4984efedc4b08975c5aeb73f530d02df25717" - integrity sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ== - -unpipe@1.0.0, unpipe@~1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/unpipe/-/unpipe-1.0.0.tgz#b2bf4ee8514aae6165b4817829d21b2ef49904ec" - integrity sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw= - -util-deprecate@^1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" - integrity sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw== - -utils-merge@1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/utils-merge/-/utils-merge-1.0.1.tgz#9f95710f50a267947b2ccc124741c1028427e713" - integrity sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM= - -uuid@^8.0.0: - version "8.3.2" - resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2" - integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg== - -uuid@^9.0.0: - version "9.0.0" - resolved "https://registry.yarnpkg.com/uuid/-/uuid-9.0.0.tgz#592f550650024a38ceb0c562f2f6aa435761efb5" - integrity sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg== - -vary@^1: - version "1.1.2" - resolved "https://registry.yarnpkg.com/vary/-/vary-1.1.2.tgz#2299f02c6ded30d4a5961b0b9f74524a18f634fc" - integrity sha1-IpnwLG3tMNSllhsLn3RSShj2NPw= - -vega-canvas@^1.2.5: - version "1.2.6" - resolved "https://registry.yarnpkg.com/vega-canvas/-/vega-canvas-1.2.6.tgz#55e032ce9a62acd17229f6bac66d99db3d6879cd" - integrity sha512-rgeYUpslYn/amIfnuv3Sw6n4BGns94OjjZNtUc9IDji6b+K8LGS/kW+Lvay8JX/oFqtulBp8RLcHN6QjqPLA9Q== - -vega-crossfilter@~4.0.5: - version "4.0.5" - resolved "https://registry.yarnpkg.com/vega-crossfilter/-/vega-crossfilter-4.0.5.tgz#cf6a5fca60821928f976b32f22cf66cfd9cbeeae" - integrity sha512-yF+iyGP+ZxU7Tcj5yBsMfoUHTCebTALTXIkBNA99RKdaIHp1E690UaGVLZe6xde2n5WaYpho6I/I6wdAW3NXcg== - dependencies: - d3-array "^2.7.1" - vega-dataflow "^5.7.3" - vega-util "^1.15.2" - -vega-dataflow@^5.7.3, vega-dataflow@^5.7.4, vega-dataflow@~5.7.3: - version "5.7.4" - resolved "https://registry.yarnpkg.com/vega-dataflow/-/vega-dataflow-5.7.4.tgz#7cafc0a41b9d0b11dd2e34a513f8b7ca345dfd74" - integrity sha512-JGHTpUo8XGETH3b1V892we6hdjzCWB977ybycIu8DPqRoyrZuj6t1fCVImazfMgQD1LAfJlQybWP+alwKDpKig== - dependencies: - vega-format "^1.0.4" - vega-loader "^4.3.2" - vega-util "^1.16.1" - -vega-embed@6.17.0: - version "6.17.0" - resolved "https://registry.yarnpkg.com/vega-embed/-/vega-embed-6.17.0.tgz#6afe157ef31c473a799fce1d45e3878a3c80c5e2" - integrity sha512-9eiVZCrLDb/EiVCMbMYouWB/q9dOeVkL5Bh0vU6wsUpIV/bbEvS47uljuo3YSxFqkfNpJ+Qt8xvLRiYSnN4lqw== - dependencies: - fast-json-patch "^3.0.0-1" - json-stringify-pretty-compact "^3.0.0" - semver "^7.3.5" - vega-schema-url-parser "^2.1.0" - vega-themes "^2.10.0" - vega-tooltip "^0.25.1" - -vega-encode@~4.8.3: - version "4.8.3" - resolved "https://registry.yarnpkg.com/vega-encode/-/vega-encode-4.8.3.tgz#b3048fb39845d72f18d8dc302ad697f826e0ff83" - integrity sha512-JoRYtaV2Hs8spWLzTu/IjR7J9jqRmuIOEicAaWj6T9NSZrNWQzu2zF3IVsX85WnrIDIRUDaehXaFZvy9uv9RQg== - dependencies: - d3-array "^2.7.1" - d3-interpolate "^2.0.1" - vega-dataflow "^5.7.3" - vega-scale "^7.0.3" - vega-util "^1.15.2" - -vega-event-selector@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/vega-event-selector/-/vega-event-selector-3.0.0.tgz#7b855ac0c3ddb59bc5b5caa0d96dbbc9fbd33a4c" - integrity sha512-Gls93/+7tEJGE3kUuUnxrBIxtvaNeF01VIFB2Q2Of2hBIBvtHX74jcAdDtkh5UhhoYGD8Q1J30P5cqEBEwtPoQ== - -vega-event-selector@~2.0.3, vega-event-selector@~2.0.6: - version "2.0.6" - resolved "https://registry.yarnpkg.com/vega-event-selector/-/vega-event-selector-2.0.6.tgz#6beb00e066b78371dde1a0f40cb5e0bbaecfd8bc" - integrity sha512-UwCu50Sqd8kNZ1X/XgiAY+QAyQUmGFAwyDu7y0T5fs6/TPQnDo/Bo346NgSgINBEhEKOAMY1Nd/rPOk4UEm/ew== - -vega-expression@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/vega-expression/-/vega-expression-5.0.0.tgz#938f26689693a1e0d26716030cdaed43ca7abdfb" - integrity sha512-y5+c2frq0tGwJ7vYXzZcfVcIRF/QGfhf2e+bV1Z0iQs+M2lI1II1GPDdmOcMKimpoCVp/D61KUJDIGE1DSmk2w== - dependencies: - "@types/estree" "^0.0.50" - vega-util "^1.16.0" - -vega-expression@~2.6.5: - version "2.6.6" - resolved "https://registry.yarnpkg.com/vega-expression/-/vega-expression-2.6.6.tgz#ce32d548b44ae93cdfcbf190e10c14e602ef0788" - integrity sha512-zxPzXO33FawU3WQHRmHJaRreyJlyMaNMn1uuCFSouJttPkBBWB5gCrha2f5+pF3t4NMFWTnSrgCkR6mcaubnng== - dependencies: - vega-util "^1.15.0" - -vega-expression@~4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/vega-expression/-/vega-expression-4.0.1.tgz#c03e4fc68a00acac49557faa4e4ed6ac8a59c5fd" - integrity sha512-ZrDj0hP8NmrCpdLFf7Rd/xMUHGoSYsAOTaYp7uXZ2dkEH5x0uPy5laECMc8TiQvL8W+8IrN2HAWCMRthTSRe2Q== - dependencies: - vega-util "^1.16.0" - -vega-force@~4.0.7: - version "4.0.7" - resolved "https://registry.yarnpkg.com/vega-force/-/vega-force-4.0.7.tgz#6dc39ecb7889d9102661244d62fbc8d8714162ee" - integrity sha512-pyLKdwXSZ9C1dVIqdJOobvBY29rLvZjvRRTla9BU/nMwAiAGlGi6WKUFdRGdneyGe3zo2nSZDTZlZM/Z5VaQNA== - dependencies: - d3-force "^2.1.1" - vega-dataflow "^5.7.3" - vega-util "^1.15.2" - -vega-format@^1.0.4, vega-format@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/vega-format/-/vega-format-1.1.0.tgz#b9d81cf1bcf222ae5cbd94357ae70245d2c7b18d" - integrity sha512-6mgpeWw8yGdG0Zdi8aVkx5oUrpJGOpNxqazC2858RSDPvChM/jDFlgRMTYw52qk7cxU0L08ARp4BwmXaI75j0w== - dependencies: - d3-array "^3.1.1" - d3-format "^3.1.0" - d3-time-format "^4.1.0" - vega-time "^2.0.3" - vega-util "^1.15.2" - -vega-format@~1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/vega-format/-/vega-format-1.0.4.tgz#40c0c252d11128738b845ee73d8173f8064d6626" - integrity sha512-oTAeub3KWm6nKhXoYCx1q9G3K43R6/pDMXvqDlTSUtjoY7b/Gixm8iLcir5S9bPjvH40n4AcbZsPmNfL/Up77A== - dependencies: - d3-array "^2.7.1" - d3-format "^2.0.0" - d3-time-format "^3.0.0" - vega-time "^2.0.3" - vega-util "^1.15.2" - -vega-functions@^5.10.0, vega-functions@^5.12.1: - version "5.13.0" - resolved "https://registry.yarnpkg.com/vega-functions/-/vega-functions-5.13.0.tgz#c9ab8c6eedbf39f75b424cca6776b1d0b8c74b32" - integrity sha512-Mf53zNyx+c9fFqagEI0T8zc9nMlx0zozOngr8oOpG1tZDKOgwOnUgN99zQKbLHjyv+UzWrq3LYTnSLyVe0ZmhQ== - dependencies: - d3-array "^3.1.1" - d3-color "^3.0.1" - d3-geo "^3.0.1" - vega-dataflow "^5.7.3" - vega-expression "^5.0.0" - vega-scale "^7.2.0" - vega-scenegraph "^4.9.3" - vega-selections "^5.3.1" - vega-statistics "^1.7.9" - vega-time "^2.1.0" - vega-util "^1.16.0" - -vega-functions@~5.12.0: - version "5.12.1" - resolved "https://registry.yarnpkg.com/vega-functions/-/vega-functions-5.12.1.tgz#b69f9ad4cd9f777dbc942587c02261b2f4cdba2c" - integrity sha512-7cHfcjXOj27qEbh2FTzWDl7FJK4xGcMFF7+oiyqa0fp7BU/wNT5YdNV0t5kCX9WjV7mfJWACKV74usLJbyM6GA== - dependencies: - d3-array "^2.7.1" - d3-color "^2.0.0" - d3-geo "^2.0.1" - vega-dataflow "^5.7.3" - vega-expression "^5.0.0" - vega-scale "^7.1.1" - vega-scenegraph "^4.9.3" - vega-selections "^5.3.1" - vega-statistics "^1.7.9" - vega-time "^2.0.4" - vega-util "^1.16.0" - -vega-geo@~4.3.8: - version "4.3.8" - resolved "https://registry.yarnpkg.com/vega-geo/-/vega-geo-4.3.8.tgz#5629d18327bb4f3700cdf05db4aced0a43abbf4a" - integrity sha512-fsGxV96Q/QRgPqOPtMBZdI+DneIiROKTG3YDZvGn0EdV16OG5LzFhbNgLT5GPzI+kTwgLpAsucBHklexlB4kfg== - dependencies: - d3-array "^2.7.1" - d3-color "^2.0.0" - d3-geo "^2.0.1" - vega-canvas "^1.2.5" - vega-dataflow "^5.7.3" - vega-projection "^1.4.5" - vega-statistics "^1.7.9" - vega-util "^1.15.2" - -vega-hierarchy@~4.0.9: - version "4.0.9" - resolved "https://registry.yarnpkg.com/vega-hierarchy/-/vega-hierarchy-4.0.9.tgz#4b4bafbc181a14a280ecdbee8874c0db7e369f47" - integrity sha512-4XaWK6V38/QOZ+vllKKTafiwL25m8Kd+ebHmDV+Q236ONHmqc/gv82wwn9nBeXPEfPv4FyJw2SRoqa2Jol6fug== - dependencies: - d3-hierarchy "^2.0.0" - vega-dataflow "^5.7.3" - vega-util "^1.15.2" - -vega-label@~1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/vega-label/-/vega-label-1.0.0.tgz#c3bea3a608a62217ca554ecc0f7fe0395d81bd1b" - integrity sha512-hCdm2pcHgkKgxnzW9GvX5JmYNiUMlOXOibtMmBzvFBQHX3NiV9giQ5nsPiQiFbV08VxEPtM+VYXr2HyrIcq5zQ== - dependencies: - vega-canvas "^1.2.5" - vega-dataflow "^5.7.3" - vega-scenegraph "^4.9.2" - vega-util "^1.15.2" - -vega-lite@4.13.1: - version "4.13.1" - resolved "https://registry.yarnpkg.com/vega-lite/-/vega-lite-4.13.1.tgz#e9ee31c76cb93565e287a760700e432e57244064" - integrity sha512-OHZSSqVLuikoZ3idz3jIRk0UCKtVU2Lq5gaD6cLNTnJjNetoHKKdfZ023LVj4+Y9yWPz5meb+EJUsfBAGfF4Vw== - dependencies: - "@types/clone" "~0.1.30" - "@types/fast-json-stable-stringify" "^2.0.0" - array-flat-polyfill "^1.0.1" - clone "~2.1.2" - fast-deep-equal "~3.1.1" - fast-json-stable-stringify "~2.1.0" - json-stringify-pretty-compact "~2.0.0" - tslib "~2.0.0" - vega-event-selector "~2.0.3" - vega-expression "~2.6.5" - vega-util "~1.14.0" - yargs "~15.3.1" - -vega-loader@^4.3.2, vega-loader@^4.3.3, vega-loader@^4.4.0: - version "4.5.0" - resolved "https://registry.yarnpkg.com/vega-loader/-/vega-loader-4.5.0.tgz#b15acc4c8f84191f500e94d35ddfb9721ac943ad" - integrity sha512-EkAyzbx0pCYxH3v3wghGVCaKINWxHfgbQ2pYDiYv0yo8e04S8Mv/IlRGTt6BAe7cLhrk1WZ4zh20QOppnGG05w== - dependencies: - d3-dsv "^3.0.1" - node-fetch "^2.6.7" - topojson-client "^3.1.0" - vega-format "^1.1.0" - vega-util "^1.16.0" - -vega-loader@~4.4.0: - version "4.4.1" - resolved "https://registry.yarnpkg.com/vega-loader/-/vega-loader-4.4.1.tgz#8f9de46202f33659d1a2737f6e322a9fc3364275" - integrity sha512-dj65i4qlNhK0mOmjuchHgUrF5YUaWrYpx0A8kXA68lBk5Hkx8FNRztkcl07CZJ1+8V81ymEyJii9jzGbhEX0ag== - dependencies: - d3-dsv "^2.0.0" - node-fetch "^2.6.1" - topojson-client "^3.1.0" - vega-format "^1.0.4" - vega-util "^1.16.0" - -vega-parser@~6.1.3: - version "6.1.4" - resolved "https://registry.yarnpkg.com/vega-parser/-/vega-parser-6.1.4.tgz#4868e41af2c9645b6d7daeeb205cfad06b9d465c" - integrity sha512-tORdpWXiH/kkXcpNdbSVEvtaxBuuDtgYp9rBunVW9oLsjFvFXbSWlM1wvJ9ZFSaTfx6CqyTyGMiJemmr1QnTjQ== - dependencies: - vega-dataflow "^5.7.3" - vega-event-selector "^3.0.0" - vega-functions "^5.12.1" - vega-scale "^7.1.1" - vega-util "^1.16.0" - -vega-projection@^1.4.5: - version "1.5.0" - resolved "https://registry.yarnpkg.com/vega-projection/-/vega-projection-1.5.0.tgz#51c5f0455170cd35b3c5f3e653e99c3616520640" - integrity sha512-aob7qojh555x3hQWZ/tr8cIJNSWQbm6EoWTJaheZgFOY2x3cDa4Qrg3RJbGw6KwVj/IQk2p40paRzixKZ2kr+A== - dependencies: - d3-geo "^3.0.1" - d3-geo-projection "^4.0.0" - -vega-projection@~1.4.5: - version "1.4.5" - resolved "https://registry.yarnpkg.com/vega-projection/-/vega-projection-1.4.5.tgz#020cb646b4eaae535359da25f4f48eef8d324af2" - integrity sha512-85kWcPv0zrrNfxescqHtSYpRknilrS0K3CVRZc7IYQxnLtL1oma9WEbrSr1LCmDoCP5hl2Z1kKbomPXkrQX5Ag== - dependencies: - d3-geo "^2.0.1" - d3-geo-projection "^3.0.0" - -vega-regression@~1.0.9: - version "1.0.9" - resolved "https://registry.yarnpkg.com/vega-regression/-/vega-regression-1.0.9.tgz#f33da47fe457e03ad134782c11414bcef7b1da82" - integrity sha512-KSr3QbCF0vJEAWFVY2MA9X786oiJncTTr3gqRMPoaLr/Yo3f7OPKXRoUcw36RiWa0WCOEMgTYtM28iK6ZuSgaA== - dependencies: - d3-array "^2.7.1" - vega-dataflow "^5.7.3" - vega-statistics "^1.7.9" - vega-util "^1.15.2" - -vega-runtime@^6.1.3, vega-runtime@~6.1.3: - version "6.1.3" - resolved "https://registry.yarnpkg.com/vega-runtime/-/vega-runtime-6.1.3.tgz#01e18246f7a80cee034a96017ac30113b92c4034" - integrity sha512-gE+sO2IfxMUpV0RkFeQVnHdmPy3K7LjHakISZgUGsDI/ZFs9y+HhBf8KTGSL5pcZPtQsZh3GBQ0UonqL1mp9PA== - dependencies: - vega-dataflow "^5.7.3" - vega-util "^1.15.2" - -vega-scale@^7.0.3, vega-scale@^7.1.1, vega-scale@^7.2.0: - version "7.2.0" - resolved "https://registry.yarnpkg.com/vega-scale/-/vega-scale-7.2.0.tgz#9e298cc02ad340498cb56847436b19439911f0fc" - integrity sha512-QYltO/otrZHLrCGGf06Y99XtPtqWXITr6rw7rO9oL+l3d9o5RFl9sjHrVxiM7v+vGoZVWbBd5IPbFhPsXZ6+TA== - dependencies: - d3-array "^3.1.1" - d3-interpolate "^3.0.1" - d3-scale "^4.0.2" - vega-time "^2.1.0" - vega-util "^1.17.0" - -vega-scale@~7.1.1: - version "7.1.1" - resolved "https://registry.yarnpkg.com/vega-scale/-/vega-scale-7.1.1.tgz#b69a38d1980f6fc1093390f796e556be63fdc808" - integrity sha512-yE0to0prA9E5PBJ/XP77TO0BMkzyUVyt7TH5PAwj+CZT7PMsMO6ozihelRhoIiVcP0Ae/ByCEQBUQkzN5zJ0ZA== - dependencies: - d3-array "^2.7.1" - d3-interpolate "^2.0.1" - d3-scale "^3.2.2" - vega-time "^2.0.4" - vega-util "^1.15.2" - -vega-scenegraph@^4.9.2, vega-scenegraph@^4.9.3, vega-scenegraph@^4.9.4: - version "4.10.0" - resolved "https://registry.yarnpkg.com/vega-scenegraph/-/vega-scenegraph-4.10.0.tgz#232643372760ea081f2a899f640530777c2e2ba8" - integrity sha512-znUQAulNJnuXSza8+Qg1objNpXcHxP9KZwwp0XW4H/AHbzVhHEigZagb8xKDpQI1/8OSk2WZf9Bkr7CrsFC0hg== - dependencies: - d3-path "^3.0.1" - d3-shape "^3.1.0" - vega-canvas "^1.2.5" - vega-loader "^4.4.0" - vega-scale "^7.2.0" - vega-util "^1.15.2" - -vega-scenegraph@~4.9.4: - version "4.9.4" - resolved "https://registry.yarnpkg.com/vega-scenegraph/-/vega-scenegraph-4.9.4.tgz#468408c1e89703fa9d3450445daabff623de2757" - integrity sha512-QaegQzbFE2yhYLNWAmHwAuguW3yTtQrmwvfxYT8tk0g+KKodrQ5WSmNrphWXhqwtsgVSvtdZkfp2IPeumcOQJg== - dependencies: - d3-path "^2.0.0" - d3-shape "^2.0.0" - vega-canvas "^1.2.5" - vega-loader "^4.3.3" - vega-scale "^7.1.1" - vega-util "^1.15.2" - -vega-schema-url-parser@^2.1.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/vega-schema-url-parser/-/vega-schema-url-parser-2.2.0.tgz#a0d1e02915adfbfcb1fd517c8c2ebe2419985c1e" - integrity "sha1-oNHgKRWt+/yx/VF8jC6+JBmYXB4= sha512-yAtdBnfYOhECv9YC70H2gEiqfIbVkq09aaE4y/9V/ovEFmH9gPKaEgzIZqgT7PSPQjKhsNkb6jk6XvSoboxOBw==" - -vega-selections@^5.3.1: - version "5.4.0" - resolved "https://registry.yarnpkg.com/vega-selections/-/vega-selections-5.4.0.tgz#c2783897421fa39b674c015fa8f15a0023b8054e" - integrity sha512-Un3JdLDPjIpF9Dh4sw6m1c/QAcfam6m1YXHJ9vJxE/GdJ+sOrPxc7bcEU8VhOmTUN7IQUn4/1ry4JqqOVMbEhw== - dependencies: - d3-array "3.1.1" - vega-expression "^5.0.0" - vega-util "^1.16.0" - -vega-statistics@^1.7.9: - version "1.8.0" - resolved "https://registry.yarnpkg.com/vega-statistics/-/vega-statistics-1.8.0.tgz#ad66f7461473d58bc96671588981a059ffd60b59" - integrity sha512-dl+LCRS6qS4jWDme/NEdPVt5r649uB4IK6Kyr2/czmGA5JqjuFmtQ9lHQOnRu8945XLkqLf+JIQQo7vnw+nslA== - dependencies: - d3-array "^3.1.1" - -vega-statistics@~1.7.9: - version "1.7.10" - resolved "https://registry.yarnpkg.com/vega-statistics/-/vega-statistics-1.7.10.tgz#4353637402e5e96bff2ebd16bd58e2c15cac3018" - integrity sha512-QLb12gcfpDZ9K5h3TLGrlz4UXDH9wSPyg9LLfOJZacxvvJEPohacUQNrGEAVtFO9ccUCerRfH9cs25ZtHsOZrw== - dependencies: - d3-array "^2.7.1" - -vega-themes@^2.10.0: - version "2.10.0" - resolved "https://registry.yarnpkg.com/vega-themes/-/vega-themes-2.10.0.tgz#82768b14686e3fbfbdab0e77cb63e12c62b4911e" - integrity sha512-prePRUKFUFGWniuZsJOfkdb+27Gwrrm82yAlVuU+912kcknsx1DVmMSg2yF79f4jdtqnAFIGycZgxoj13SEIuQ== - -vega-time@^2.0.3, vega-time@^2.0.4, vega-time@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/vega-time/-/vega-time-2.1.0.tgz#acfbab88d7798b87ff63913b0dce2ca5eb0d46ca" - integrity sha512-Q9/l3S6Br1RPX5HZvyLD/cQ4K6K8DtpR09/1y7D66gxNorg2+HGzYZINH9nUvN3mxoXcBWg4cCUh3+JvmkDaEg== - dependencies: - d3-array "^3.1.1" - d3-time "^3.0.0" - vega-util "^1.15.2" - -vega-time@~2.0.4: - version "2.0.4" - resolved "https://registry.yarnpkg.com/vega-time/-/vega-time-2.0.4.tgz#ff308358a831de927caa44e281cdc96f0863ba08" - integrity sha512-U314UDR9+ZlWrD3KBaeH+j/c2WSMdvcZq5yJfFT0yTg1jsBKAQBYFGvl+orackD8Zx3FveHOxx3XAObaQeDX+Q== - dependencies: - d3-array "^2.7.1" - d3-time "^2.0.0" - vega-util "^1.15.2" - -vega-tooltip@^0.25.1: - version "0.25.1" - resolved "https://registry.yarnpkg.com/vega-tooltip/-/vega-tooltip-0.25.1.tgz#cb7e438438649eb46896e7bee6f54e25d25b3c09" - integrity sha512-ugGwGi2/p3OpB8N15xieuzP8DyV5DreqMWcmJ9zpWT8GlkyKtef4dGRXnvHeHQ+iJFmWrq4oZJ+kLTrdiECjAg== - dependencies: - vega-util "^1.16.0" - -vega-transforms@~4.9.3: - version "4.9.4" - resolved "https://registry.yarnpkg.com/vega-transforms/-/vega-transforms-4.9.4.tgz#5cf6b91bda9f184bbbaba63838be8e5e6a571235" - integrity sha512-JGBhm5Bf6fiGTUSB5Qr5ckw/KU9FJcSV5xIe/y4IobM/i/KNwI1i1fP45LzP4F4yZc0DMTwJod2UvFHGk9plKA== - dependencies: - d3-array "^2.7.1" - vega-dataflow "^5.7.4" - vega-statistics "^1.7.9" - vega-time "^2.0.4" - vega-util "^1.16.1" - -vega-typings@~0.20.0: - version "0.20.0" - resolved "https://registry.yarnpkg.com/vega-typings/-/vega-typings-0.20.0.tgz#aac32f45ca69d3640d205ffdd9cd94fe1d6dcc19" - integrity sha512-S+HIRN/3WYiS5zrQjJ4FDEOlvFVHLxPXMJerrnN3YZ6bxCDYo7tEvQUUuByGZ3d19GuKjgejczWS7XHvF3WjDw== - dependencies: - vega-util "^1.15.2" - -vega-util@^1.15.0, vega-util@^1.15.2, vega-util@^1.16.0, vega-util@^1.16.1, vega-util@^1.17.0: - version "1.17.0" - resolved "https://registry.yarnpkg.com/vega-util/-/vega-util-1.17.0.tgz#b72ae0baa97f943bf591f8f5bb27ceadf06834ac" - integrity sha512-HTaydZd9De3yf+8jH66zL4dXJ1d1p5OIFyoBzFiOli4IJbwkL1jrefCKz6AHDm1kYBzDJ0X4bN+CzZSCTvNk1w== - -vega-util@~1.14.0: - version "1.14.1" - resolved "https://registry.yarnpkg.com/vega-util/-/vega-util-1.14.1.tgz#0fb614277764f98738ba0b80e5cdfbe663426183" - integrity sha512-pSKJ8OCkgfgHZDTljyj+gmGltgulceWbk1BV6LWrXqp6P3J8qPA/oZA8+a93YNApYxXZ3yzIVUDOo5O27xk0jw== - -vega-util@~1.16.1: - version "1.16.1" - resolved "https://registry.yarnpkg.com/vega-util/-/vega-util-1.16.1.tgz#992bf3c3b6e145797214d99862841baea417ba39" - integrity sha512-FdgD72fmZMPJE99FxvFXth0IL4BbLA93WmBg/lvcJmfkK4Uf90WIlvGwaIUdSePIsdpkZjBPyQcHMQ8OcS8Smg== - -vega-view-transforms@~4.5.8: - version "4.5.8" - resolved "https://registry.yarnpkg.com/vega-view-transforms/-/vega-view-transforms-4.5.8.tgz#c8dc42c3c7d4aa725d40b8775180c9f23bc98f4e" - integrity sha512-966m7zbzvItBL8rwmF2nKG14rBp7q+3sLCKWeMSUrxoG+M15Smg5gWEGgwTG3A/RwzrZ7rDX5M1sRaAngRH25g== - dependencies: - vega-dataflow "^5.7.3" - vega-scenegraph "^4.9.2" - vega-util "^1.15.2" - -vega-view@~5.10.0: - version "5.10.1" - resolved "https://registry.yarnpkg.com/vega-view/-/vega-view-5.10.1.tgz#b69348bb32a9845a1bd341fdd946df98684fadc3" - integrity sha512-4xvQ5KZcgKdZx1Z7jjenCUumvlyr/j4XcHLRf9gyeFrFvvS596dVpL92V8twhV6O++DmS2+fj+rHagO8Di4nMg== - dependencies: - d3-array "^2.7.1" - d3-timer "^2.0.0" - vega-dataflow "^5.7.3" - vega-format "^1.0.4" - vega-functions "^5.10.0" - vega-runtime "^6.1.3" - vega-scenegraph "^4.9.4" - vega-util "^1.16.1" - -vega-voronoi@~4.1.5: - version "4.1.5" - resolved "https://registry.yarnpkg.com/vega-voronoi/-/vega-voronoi-4.1.5.tgz#e7af574d4c27fd9cb12d70082f12c6f59b80b445" - integrity sha512-950IkgCFLj0zG33EWLAm1hZcp+FMqWcNQliMYt+MJzOD5S4MSpZpZ7K4wp2M1Jktjw/CLKFL9n38JCI0i3UonA== - dependencies: - d3-delaunay "^5.3.0" - vega-dataflow "^5.7.3" - vega-util "^1.15.2" - -vega-wordcloud@~4.1.3: - version "4.1.3" - resolved "https://registry.yarnpkg.com/vega-wordcloud/-/vega-wordcloud-4.1.3.tgz#ce90900333f4e0d3ee706ba4f36bb0905f8b4a9f" - integrity sha512-is4zYn9FMAyp9T4SAcz2P/U/wqc0Lx3P5YtpWKCbOH02a05vHjUQrQ2TTPOuvmMfAEDCSKvbMSQIJMOE018lJA== - dependencies: - vega-canvas "^1.2.5" - vega-dataflow "^5.7.3" - vega-scale "^7.1.1" - vega-statistics "^1.7.9" - vega-util "^1.15.2" - -vega@5.20.0: - version "5.20.0" - resolved "https://registry.yarnpkg.com/vega/-/vega-5.20.0.tgz#8be803391c9441d569a72531917b69d62edb5e57" - integrity sha512-L2hDaTH2gz9DFbu7l1B8fR637HzctViuosFCo/Db5aBe93fCJ/w/oJu+vQNfQELzfm9sntkS/+A4u+39xrDCNA== - dependencies: - vega-crossfilter "~4.0.5" - vega-dataflow "~5.7.3" - vega-encode "~4.8.3" - vega-event-selector "~2.0.6" - vega-expression "~4.0.1" - vega-force "~4.0.7" - vega-format "~1.0.4" - vega-functions "~5.12.0" - vega-geo "~4.3.8" - vega-hierarchy "~4.0.9" - vega-label "~1.0.0" - vega-loader "~4.4.0" - vega-parser "~6.1.3" - vega-projection "~1.4.5" - vega-regression "~1.0.9" - vega-runtime "~6.1.3" - vega-scale "~7.1.1" - vega-scenegraph "~4.9.4" - vega-statistics "~1.7.9" - vega-time "~2.0.4" - vega-transforms "~4.9.3" - vega-typings "~0.20.0" - vega-util "~1.16.1" - vega-view "~5.10.0" - vega-view-transforms "~4.5.8" - vega-voronoi "~4.1.5" - vega-wordcloud "~4.1.3" - -void-elements@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/void-elements/-/void-elements-2.0.1.tgz#c066afb582bb1cb4128d60ea92392e94d5e9dbec" - integrity sha1-wGavtYK7HLQSjWDqkjkulNXp2+w= - -webidl-conversions@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871" - integrity sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE= - -websocket-driver@>=0.5.1: - version "0.7.4" - resolved "https://registry.yarnpkg.com/websocket-driver/-/websocket-driver-0.7.4.tgz#89ad5295bbf64b480abcba31e4953aca706f5760" - integrity sha512-b17KeDIQVjvb0ssuSDF2cYXSg2iztliJ4B9WdsuB6J952qCPKmnVq4DyW5motImXHDC1cBT/1UezrJVsKw5zjg== - dependencies: - http-parser-js ">=0.5.1" - safe-buffer ">=5.1.0" - websocket-extensions ">=0.1.1" - -websocket-extensions@>=0.1.1: - version "0.1.4" - resolved "https://registry.yarnpkg.com/websocket-extensions/-/websocket-extensions-0.1.4.tgz#7f8473bc839dfd87608adb95d7eb075211578a42" - integrity sha512-OqedPIGOfsDlo31UNwYbCFMSaO9m9G/0faIHj5/dZFDMFqPTcx6UwqyOy3COEaEOg/9VsGIpdqn62W5KhoKSpg== - -whatwg-fetch@>=0.10.0: - version "3.6.2" - resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-3.6.2.tgz#dced24f37f2624ed0281725d51d0e2e3fe677f8c" - integrity sha512-bJlen0FcuU/0EMLrdbJ7zOnW6ITZLrZMIarMUVmdKtsGvZna8vxKYaexICWPfZ8qwf9fzNq+UEIZrnSaApt6RA== - -whatwg-url@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-5.0.0.tgz#966454e8765462e37644d3626f6742ce8b70965d" - integrity sha1-lmRU6HZUYuN2RNNib2dCzotwll0= - dependencies: - tr46 "~0.0.3" - webidl-conversions "^3.0.0" - -which-module@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/which-module/-/which-module-2.0.0.tgz#d9ef07dce77b9902b8a3a8fa4b31c3e3f7e6e87a" - integrity sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho= - -which@^1.2.1: - version "1.3.1" - resolved "https://registry.yarnpkg.com/which/-/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a" - integrity sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ== - dependencies: - isexe "^2.0.0" - -word-wrap@~1.2.3: - version "1.2.3" - resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.3.tgz#610636f6b1f703891bd34771ccb17fb93b47079c" - integrity sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ== - -wrap-ansi@^6.2.0: - version "6.2.0" - resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-6.2.0.tgz#e9393ba07102e6c91a3b221478f0257cd2856e53" - integrity sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA== - dependencies: - ansi-styles "^4.0.0" - string-width "^4.1.0" - strip-ansi "^6.0.0" - -wrap-ansi@^7.0.0: - version "7.0.0" - resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" - integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== - dependencies: - ansi-styles "^4.0.0" - string-width "^4.1.0" - strip-ansi "^6.0.0" - -wrappy@1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" - integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8= - -ws@~8.2.3: - version "8.2.3" - resolved "https://registry.yarnpkg.com/ws/-/ws-8.2.3.tgz#63a56456db1b04367d0b721a0b80cae6d8becbba" - integrity sha512-wBuoj1BDpC6ZQ1B7DWQBYVLphPWkm8i9Y0/3YdHjHKHiohOJ1ws+3OccDWtH+PoC9DZD5WOTrJvNbWvjS6JWaA== - -xmlcreate@^2.0.4: - version "2.0.4" - resolved "https://registry.yarnpkg.com/xmlcreate/-/xmlcreate-2.0.4.tgz#0c5ab0f99cdd02a81065fa9cd8f8ae87624889be" - integrity sha512-nquOebG4sngPmGPICTS5EnxqhKbCmz5Ox5hsszI2T6U5qdrJizBc+0ilYSEjTSzU0yZcmvppztXe/5Al5fUwdg== - -y18n@^4.0.0: - version "4.0.3" - resolved "https://registry.yarnpkg.com/y18n/-/y18n-4.0.3.tgz#b5f259c82cd6e336921efd7bfd8bf560de9eeedf" - integrity sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ== - -y18n@^5.0.5: - version "5.0.8" - resolved "https://registry.yarnpkg.com/y18n/-/y18n-5.0.8.tgz#7f4934d0f7ca8c56f95314939ddcd2dd91ce1d55" - integrity sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA== - -yallist@^2.0.0: - version "2.1.2" - resolved "https://registry.yarnpkg.com/yallist/-/yallist-2.1.2.tgz#1c11f9218f076089a47dd512f93c6699a6a81d52" - integrity sha512-ncTzHV7NvsQZkYe1DW7cbDLm0YpzHmZF5r/iyP3ZnQtMiJ+pjzisCiMNI+Sj+xQF5pXhSHxSB3uDbsBTzY/c2A== - -yallist@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72" - integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A== - -yargs-parser@^18.1.1: - version "18.1.3" - resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-18.1.3.tgz#be68c4975c6b2abf469236b0c870362fab09a7b0" - integrity sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ== - dependencies: - camelcase "^5.0.0" - decamelize "^1.2.0" - -yargs-parser@^20.2.2: - version "20.2.9" - resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.9.tgz#2eb7dc3b0289718fc295f362753845c41a0c94ee" - integrity sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w== - -yargs@^16.0.3, yargs@^16.1.1, yargs@^16.2.0: - version "16.2.0" - resolved "https://registry.yarnpkg.com/yargs/-/yargs-16.2.0.tgz#1c82bf0f6b6a66eafce7ef30e376f49a12477f66" - integrity sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw== - dependencies: - cliui "^7.0.2" - escalade "^3.1.1" - get-caller-file "^2.0.5" - require-directory "^2.1.1" - string-width "^4.2.0" - y18n "^5.0.5" - yargs-parser "^20.2.2" - -yargs@~15.3.1: - version "15.3.1" - resolved "https://registry.yarnpkg.com/yargs/-/yargs-15.3.1.tgz#9505b472763963e54afe60148ad27a330818e98b" - integrity sha512-92O1HWEjw27sBfgmXiixJWT5hRBp2eobqXicLtPBIDBhYB+1HpwZlXmbW2luivBJHBzki+7VyCLRtAkScbTBQA== - dependencies: - cliui "^6.0.0" - decamelize "^1.2.0" - find-up "^4.1.0" - get-caller-file "^2.0.1" - require-directory "^2.1.1" - require-main-filename "^2.0.0" - set-blocking "^2.0.0" - string-width "^4.2.0" - which-module "^2.0.0" - y18n "^4.0.0" - yargs-parser "^18.1.1" - -yocto-queue@^0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b" - integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q== diff --git a/tfjs-master/e2e/benchmarks/firebase.json b/tfjs-master/e2e/benchmarks/firebase.json deleted file mode 100644 index 99c5af415..000000000 --- a/tfjs-master/e2e/benchmarks/firebase.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "hosting": { - "site": "tfjs-benchmarks", - "public": ".", - "ignore": [ - "firebase_prod.json", - "firebase_staging.json" - ], - "redirects": [{ - "source": "/", - "destination": "local-benchmark/", - "type": 301 - }], - "headers": [{ - "source": "local-benchmark/", - "headers": [ - { - "key": "Cross-Origin-Embedder-Policy", - "value": "require-corp" - }, - { - "key": "Cross-Origin-Opener-Policy", - "value": "same-origin" - } - ] - }] - } -} diff --git a/tfjs-master/e2e/benchmarks/firebase_staging.json b/tfjs-master/e2e/benchmarks/firebase_staging.json deleted file mode 100644 index ffa2eff6b..000000000 --- a/tfjs-master/e2e/benchmarks/firebase_staging.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "hosting": { - "site": "tfjs-benchmarks-staging", - "public": ".", - "ignore": [ - "firebase_prod.json", - "firebase_staging.json" - ], - "redirects": [{ - "source": "/", - "destination": "local-benchmark/", - "type": 301 - }], - "headers": [{ - "source": "local-benchmark/", - "headers": [ - { - "key": "Cross-Origin-Embedder-Policy", - "value": "require-corp" - }, - { - "key": "Cross-Origin-Opener-Policy", - "value": "same-origin" - } - ] - }] - } -} diff --git a/tfjs-master/e2e/benchmarks/local-benchmark/README.md b/tfjs-master/e2e/benchmarks/local-benchmark/README.md deleted file mode 100644 index d594593f8..000000000 --- a/tfjs-master/e2e/benchmarks/local-benchmark/README.md +++ /dev/null @@ -1,85 +0,0 @@ -# Benchmark custom models - -The `custom model` in the [local benchmark tool](https://tensorflow.github.io/tfjs/e2e/benchmarks/local-benchmark/index.html) currently only supports `tf.GraphModel` or `tf.LayersModel`. - -If you want to benchmark more complex TensorFlow.js models with customized input preprocessing logic, you need to implement `load` and `predictFunc` methods, following this [example PR](https://github.com/tensorflow/tfjs/pull/3168/files). - -## Models in local file system -If you have a TensorFlow.js model in local file system, you can benchmark it by: locally host the [local benchmark tool](https://tensorflow.github.io/tfjs/e2e/benchmarks/local-benchmark/index.html) and the model on a http server. In addition, if the online [local benchmark tool](https://tensorflow.github.io/tfjs/e2e/benchmarks/local-benchmark/index.html) is blocked by `CORS` problems when fetching custom models, this solution also works. - -### Example -You can benchmark the [MobileNet model](https://tfhub.dev/google/tfjs-model/imagenet/mobilenet_v2_130_224/classification/3/default/1) in local file system through the following steps: -1. Download the tool. -```shell -git clone https://github.com/tensorflow/tfjs.git -cd tfjs/e2e/benchmarks/ -``` -2. Download the model. -```shell -wget -O model.tar.gz "https://tfhub.dev/google/tfjs-model/imagenet/mobilenet_v2_130_224/classification/3/default/1?tfjs-format=compressed" -mkdir model -tar -xf model.tar.gz -C model/ -``` -3. Run a http server to host the model and the local benchmark tool. -``` -npx http-server -``` -4. Open http://127.0.0.1:8080/local-benchmark/ through the browser. -5. Select `custom` in the `models` field. -6. Fill `http://127.0.0.1:8080/model/model.json` into the `modelUrl` field. -7. Run benchmark. - -## Paths to custom models -The benchmark tool suopports three kinds of paths to the custom models. - -### URL -Examples: -- TF Hub: https://tfhub.dev/google/tfjs-model/imagenet/resnet_v2_50/feature_vector/1/default/1 -- Storage: https://storage.googleapis.com/tfjs-models/savedmodel/mobilenet_v2_1.0_224/model.json - - -### LocalStorage -Store the model in LocalStorage at first. Run the following codes in the browser console: -```javascript -const localStorageModel = tf.sequential( - {layers: [tf.layers.dense({units: 1, inputShape: [3]})]}); -const saveResults = await localStorageModel.save('localstorage://my-model-1'); -``` -Then use "localstorage://my-model-1" as the custom model URL. - -### IndexDB -Store the model in IndexDB at first. Run the following codes in the browser console: -```javascript -const indexDBModel = tf.sequential( - {layers: [tf.layers.dense({units: 1, inputShape: [3]})]}); -const saveResults = await indexDBModel.save('indexeddb://my-model-1'); -``` -Then use "indexeddb://my-model-1" as the custom model URL. - -### Variable input shapes -If input shapes for you model contain dynamic dimension (i.e. for mobilenet -shape = `[-1, 224, 224, 3]`), you are requires to set it to a valid shape -`[1, 224, 224, 3]` before you can perform the benchmark. -In the Inputs section you will see an input box for you to update the shape. -Once the shape is set, you can click the 'Run benchmark' button again to run -the benchmark. - -# Benchmark test -It's easy to set up a web server to host benchmarks and run against them via e2e/benchmarks/local-benchmark/index.html. You can manually specify the optional url parameters as needed. Here are the list of supported url parameters: - -* Model related parameters: - - architecture: same as architecture (only certain models has it, such as MobileNetV3 and posenet)
- benchmark: same as models
- inputSize: same as inputSizes
- inputType: same as inputTypes
- modelUrl: same as modelUrl, for custom models only
- ${InputeName}Shape: the input shape array, separated by comma, for custom models only. For example, bodypix's [graph model](https://storage.googleapis.com/tfjs-models/savedmodel/bodypix/mobilenet/float/075/model-stride16.json) has an input named sub_2, then users could add '`sub_2Shape=1,1,1,3`' in the URL to populate its shape.
- -* Environment related parameters: - - backend: same as backend
- localBuild: local build name list, separated by comma. The name is in short form (in general the name without the tfjs- and backend- prefixes, for example webgl for tfjs-backend-webgl, core for tfjs-core). Example: 'webgl,core'.
- run: same as numRuns
- task: correctness to "Test correctness" or performance to "Run benchmark"
- warmup: same as numWarmups
diff --git a/tfjs-master/e2e/benchmarks/local-benchmark/SpecRunner.html b/tfjs-master/e2e/benchmarks/local-benchmark/SpecRunner.html deleted file mode 100644 index 4a57886f9..000000000 --- a/tfjs-master/e2e/benchmarks/local-benchmark/SpecRunner.html +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - - Jasmine Test - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tfjs-master/e2e/benchmarks/local-benchmark/dump.js b/tfjs-master/e2e/benchmarks/local-benchmark/dump.js deleted file mode 100644 index eb6dfb17c..000000000 --- a/tfjs-master/e2e/benchmarks/local-benchmark/dump.js +++ /dev/null @@ -1,228 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -/** - * DUMP_LEVEL.BIGDIFF: dumping when difference is greater than the default - * epsilon. DUMP_LEVEL.ANYDIFF: dumping when difference is greater than 0. - */ -const DUMP_LEVEL = { - BIGDIFF: 0, - ANYDIFF: 1, -}; - -function compareData(data1, data2, level = DUMP_LEVEL.BIGDIFF) { - let epsilon = level == DUMP_LEVEL.ANYDIFF ? 0 : -1; - let match = true; - try { - expectObjectsClose(data1, data2, epsilon); - } catch (e) { - match = false; - } - return match; -} - -function getGraphModel(model) { - if (model instanceof tf.GraphModel) { - return model; - } else if (model.model instanceof tf.GraphModel) { - return model.model; - } else if ( - model.baseModel && model.baseModel.model instanceof tf.GraphModel) { - return model.baseModel.model; - } else { - console.warn(`Model doesn't support dump!`); - return null; - } -} - -async function getIntermediateTensorInfo(tensorsMap) { - if (!tensorsMap) { - return; - } - const jsonObject = {}; - const keysOfTensors = Object.keys(tensorsMap); - for (let i = 0; i < keysOfTensors.length; i++) { - const key = keysOfTensors[i]; - jsonObject[key] = []; - for (let j = 0; j < tensorsMap[key].length; j++) { - if (tensorsMap[key][j] == null) { - continue; - } - // For universal-sentence-encoder, its inputs are disposed by model. - try { - const data = await (tensorsMap[key][j]).data(); - jsonObject[key].push({ - value: data, - shape: tensorsMap[key][j].shape, - dtype: tensorsMap[key][j].dtype - }); - } catch (e) { - console.error(`${keysOfTensors[i]} ` + e.message); - } - } - } - return jsonObject; -} - -async function saveObjectsToFile(jsonObjects, prefix) { - let newPrefix = ''; - if (prefix !== '') { - newPrefix = `${prefix.replace(/\//g, '-')}_`; - } - const backends = Object.keys(jsonObjects); - if (Object.keys(jsonObjects[backends[0]]).length == 0) { - return; - } - for (let i = 0; i < backends.length; i++) { - const object = jsonObjects[backends[i]]; - const fileName = `${newPrefix}${backends[i]}.json`; - const a = document.createElement('a'); - const file = new Blob([JSON.stringify(object)], {type: 'application/json'}); - a.href = URL.createObjectURL(file); - a.download = fileName; - a.click(); - // This log informs tools file has been saved. - console.log(fileName); - } -} - -/** - * Create a NamedTensorMap from an output node name. - * @param outputNodeName Output node name. - * @param modelJson The parsed model.json. - * @param dumpedJson The dumped tensor infomation (including shape, dtype, - * value). - * - * @returns A NamedTensorMap. - */ -async function createNamedTensorMap(outputNodeName, modelJson, dumpedJson) { - const modelNodes = modelJson['modelTopology']['node']; - let inputs = []; - for (let i = 0; i < modelNodes.length; i++) { - if (outputNodeName === modelNodes[i].name && modelNodes[i].input) { - inputs = modelNodes[i].input; - break; - } - } - // In - // https://storage.googleapis.com/tfhub-tfjs-modules/mediapipe/tfjs-model/face_landmarks_detection/attention_mesh/1/model.json, - // some inputs are prefixed with '^'. - if (!inputs || inputs.length == 0 || inputs[0].startsWith('^')) { - return null; - } - - let tensorMap = {}; - for (let i = 0; i < inputs.length; i++) { - const key = inputs[i].split(':')[0]; - if (dumpedJson[key] == null || dumpedJson[key][0] == null) { - console.warn('Tensor ' + key + ' is null!'); - return null; - } - const tensorInfo = dumpedJson[key][0]; - const tensor = tf.tensor( - Object.values(tensorInfo.value), tensorInfo.shape, tensorInfo.dtype); - tensorMap[key] = tensor; - } - - return tensorMap; -} - -async function predictOp( - model, modelJson, dumpedJson, outputNodeName, backend) { - await tf.setBackend(backend); - const tensorMap = - await createNamedTensorMap(outputNodeName, modelJson, dumpedJson); - if (tensorMap == null) { - return null; - } - let prediction; - let savedKeepIntermediateTensors; - try { - savedKeepIntermediateTensors = - tf.env().getBool('KEEP_INTERMEDIATE_TENSORS'); - tf.env().set('KEEP_INTERMEDIATE_TENSORS', false); - } catch (e) { - console.warn(e.message); - } - try { - // TODO(#6861): Support tensor with type conversion. - prediction = await model.executeAsync(tensorMap, outputNodeName); - } catch (e) { - tf.env().set('KEEP_INTERMEDIATE_TENSORS', savedKeepIntermediateTensors); - console.warn(e.message); - return null; - } - - const predictOpObject = await getPredictionData(prediction, true); - tf.env().set('KEEP_INTERMEDIATE_TENSORS', savedKeepIntermediateTensors); - return predictOpObject; -} - -/** - * Dump the predict results of two backends and save diffs to files. - * @param model The loaded model. - * @param input The actual and expected results from different backends. - * @param prefix Used for generating dump file name. - * @param level 0, dump big diffs. 1, dump any diffs. - * @param length Used for controlling how many tensors will be dumped. -1 dump - * all. - */ -async function dump( - model, input, prefix = '', level = DUMP_LEVEL.BIGDIFF, length = 1) { - const graphModel = getGraphModel(model); - if (graphModel == null || length == 0) { - return; - } - const backends = Object.keys(input); - const actualObject = input[backends[0]]; - const expectedObject = input[backends[1]]; - const dumpActualObject = {}; - const dumpExpectedObject = {}; - const keys = Object.keys(actualObject); - prefix = `dump_${prefix}_${level}`; - let dumpCount = 0; - const modelJson = graphModel.artifacts; - for (let i = 0; i < keys.length; i++) { - const key = keys[i]; - if (compareData(actualObject[key], expectedObject[key], level)) { - continue; - } - const predictOpObject = await predictOp( - graphModel, modelJson, expectedObject, key, backends[0]); - const [actualOpObject, expectedOpObject] = predictOpObject ? - [{...predictOpObject, i}, {...expectedObject[key], i}] : - [null, null]; - if (compareData(actualOpObject, expectedOpObject, level)) { - continue; - } - if (actualOpObject && expectedOpObject) { - dumpActualObject[key] = actualOpObject; - dumpExpectedObject[key] = expectedOpObject; - dumpCount++; - } - // Break when diff count equals dumpLength to avoid downloading large file. - if (length != -1 && dumpCount == length) { - break; - } - } - const dumpData = - {[backends[0]]: dumpActualObject, [backends[1]]: dumpExpectedObject}; - await saveObjectsToFile(dumpData, prefix); - if (dumpCount) { - console.log(`Total dumped ${dumpCount} item(s).`); - } -} diff --git a/tfjs-master/e2e/benchmarks/local-benchmark/index.html b/tfjs-master/e2e/benchmarks/local-benchmark/index.html deleted file mode 100644 index b5f3be09d..000000000 --- a/tfjs-master/e2e/benchmarks/local-benchmark/index.html +++ /dev/null @@ -1,1056 +0,0 @@ - - - - - - TensorFlow.js Model Benchmark - - - - - - - - -

TensorFlow.js Model Benchmark

- -
-
-
-

-      
- - - - - - - - - - -
Parameters
TypeValue
- - - - - - - - - - - - - - - - - - - - -
Model
TypeValue
-
-
Inference times
-
-
-
- - - -
-
-
- - - - - - - - - -
Kernel
TypeTime(ms)
-
- - - - diff --git a/tfjs-master/e2e/benchmarks/local-benchmark/index.js b/tfjs-master/e2e/benchmarks/local-benchmark/index.js deleted file mode 100644 index 31b4be9d2..000000000 --- a/tfjs-master/e2e/benchmarks/local-benchmark/index.js +++ /dev/null @@ -1,239 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -const BACKEND_FLAGS_MAP = { - general: [], - cpu: [], - wasm: [ - 'WASM_HAS_SIMD_SUPPORT', - 'WASM_HAS_MULTITHREAD_SUPPORT', - 'CHECK_COMPUTATION_FOR_ERRORS', - 'KEEP_INTERMEDIATE_TENSORS', - ], - webgl: [ - 'WEBGL_VERSION', 'WEBGL_CPU_FORWARD', 'WEBGL_PACK', - 'WEBGL_FORCE_F16_TEXTURES', 'WEBGL_RENDER_FLOAT32_CAPABLE', - 'WEBGL_FLUSH_THRESHOLD', 'WEBGL_PACK_DEPTHWISECONV', - 'CHECK_COMPUTATION_FOR_ERRORS', 'WEBGL_USE_SHAPES_UNIFORMS', - 'KEEP_INTERMEDIATE_TENSORS' - ], - tflite: [], -}; -if (tf.engine().backendNames().includes('webgpu')) { - BACKEND_FLAGS_MAP['webgpu'] = - ['WEBGPU_DEFERRED_SUBMIT_BATCH_SIZE', 'KEEP_INTERMEDIATE_TENSORS']; -} - -const TUNABLE_FLAG_NAME_MAP = { - PROD: 'production mode', - WEBGL_VERSION: 'webgl version', - WASM_HAS_SIMD_SUPPORT: 'wasm SIMD', - WASM_HAS_MULTITHREAD_SUPPORT: 'wasm multithread', - WEBGL_CPU_FORWARD: 'cpu forward', - WEBGL_PACK: 'webgl pack', - WEBGL_FORCE_F16_TEXTURES: 'enforce float16', - WEBGL_RENDER_FLOAT32_CAPABLE: 'enable float32', - WEBGL_FLUSH_THRESHOLD: 'GL flush wait time(ms)', - WEBGL_PACK_DEPTHWISECONV: 'Packed depthwise Conv2d', - WEBGL_USE_SHAPES_UNIFORMS: 'Use shapes uniforms', - CHECK_COMPUTATION_FOR_ERRORS: 'Check each op result', - KEEP_INTERMEDIATE_TENSORS: 'Print intermediate tensors', -}; -if (tf.engine().backendNames().includes('webgpu')) { - TUNABLE_FLAG_NAME_MAP['WEBGPU_DEFERRED_SUBMIT_BATCH_SIZE'] = - 'deferred submit batch size'; -} - -/** - * Records each flag's default value under the runtime environment and is a - * constant in runtime. - */ -let TUNABLE_FLAG_DEFAULT_VALUE_MAP; - -/** - * Set up flag settings under the UI element of `folderController`: - * - If it is the first call, initialize the flags' default value and show flag - * settings for both the general and the given backend. - * - Else, clean up flag settings for the previous backend and show flag - * settings for the new backend. - * - * @param {dat.gui.GUI} folderController - * @param {string} backendName - */ -async function showFlagSettingsAndReturnTunableFlagControllers( - folderController, backendName) { - // Determine wether it is the first call. - if (TUNABLE_FLAG_DEFAULT_VALUE_MAP == null) { - await initDefaultValueMap(); - showBackendFlagSettingsAndReturnTunableFlagControllers( - folderController, 'general'); - } else { - // Clean up flag settings for the previous backend. - // The first constroller under the `folderController` is the backend - // setting. - const fixedSelectionCount = BACKEND_FLAGS_MAP.general.length + 1; - while (folderController.controllers.length > fixedSelectionCount) { - folderController - .controllers[folderController.controllers.length - 1].destroy(); - } - } - - // Show flag settings for the new backend and return the tunable flags - // controllers. - return showBackendFlagSettingsAndReturnTunableFlagControllers( - folderController, backendName); -} - -const stringValueMap = {}; -/** - * Show flag settings for the given backend under the UI element of - * `folderController`. - * - * @param {dat.gui.GUI} folderController - * @param {string} backendName - */ -function showBackendFlagSettingsAndReturnTunableFlagControllers( - folderController, backendName) { - const tunableFlags = BACKEND_FLAGS_MAP[backendName]; - const tunableFlagControllers = {}; - - // Remove it once we figure out how to correctly read the tensor data - // before the tensor is disposed in profiling mode. - if (backendName === 'webgpu' && - state.flags['CHECK_COMPUTATION_FOR_ERRORS'] === true) { - state.flags['CHECK_COMPUTATION_FOR_ERRORS'] = false; - state.isFlagChanged = true; - } - - for (let index = 0; index < tunableFlags.length; index++) { - const flag = tunableFlags[index]; - const flagName = TUNABLE_FLAG_NAME_MAP[flag] || flag; - - // When tunable (bool) and range (array) attributes of `flagRegistry` is - // implemented, we can apply them to here. - const flagValueRange = getTunableRange(flag); - // Heuristically consider a flag with at least two options as tunable. - if (flagValueRange.length < 2) { - console.warn( - `The ${flag} is considered as untunable, ` + - `because its value range is [${flagValueRange}].`); - continue; - } - let flagController; - if (typeof flagValueRange[0] === 'boolean') { - // Show checkbox for boolean flags. - try { - flagController = folderController.add(state.flags, flag); - } catch (ex) { - console.warn(ex.message); - continue; - } - } else { - // Show dropdown for other types of flags. - try { - flagController = - folderController.add(state.flags, flag, flagValueRange); - } catch (ex) { - console.warn(ex.message); - continue; - } - // Because dat.gui always casts dropdown option values to string, we need - // `stringValueMap` and `onFinishChange()` to recover the value type. - if (stringValueMap[flag] == null) { - stringValueMap[flag] = {}; - for (let index = 0; index < flagValueRange.length; index++) { - const realValue = flagValueRange[index]; - const stringValue = String(flagValueRange[index]); - stringValueMap[flag][stringValue] = realValue; - } - } - flagController.onFinishChange(stringValue => { - state.flags[flag] = stringValueMap[flag][stringValue]; - }); - } - flagController.name(flagName).onChange(() => { - state.isFlagChanged = true; - }); - tunableFlagControllers[flag] = flagController; - } - return tunableFlagControllers; -} - -/** - * Query all tunable flags' default value and populate `state.flags` with them. - */ -async function initDefaultValueMap() { - // Clean up the cache to query tunable flags' default values. - setEnvFlags({}); - TUNABLE_FLAG_DEFAULT_VALUE_MAP = {}; - for (const backend in BACKEND_FLAGS_MAP) { - for (let index = 0; index < BACKEND_FLAGS_MAP[backend].length; index++) { - const flag = BACKEND_FLAGS_MAP[backend][index]; - try { - TUNABLE_FLAG_DEFAULT_VALUE_MAP[flag] = await tf.env().getAsync(flag); - } catch (ex) { - console.warn(ex.message); - } - } - } - - // Initialize state.flags with tunable flags' default values. - for (const flag in TUNABLE_FLAG_DEFAULT_VALUE_MAP) { - state.flags[flag] = TUNABLE_FLAG_DEFAULT_VALUE_MAP[flag]; - } - state.isFlagChanged = false; -} - -/** - * Heuristically determine flag's value range based on flag's default value. - * - * Assume that the flag's default value has already chosen the best option for - * the runtime environment, so users can only tune the flag value downwards. - * - * For example, if the default value of `WEBGL_RENDER_FLOAT32_CAPABLE` is false, - * the tunable range is [false]; otherwise, the tunable range is [true. false]. - * - * @param {string} flag - */ -function getTunableRange(flag) { - const defaultValue = TUNABLE_FLAG_DEFAULT_VALUE_MAP[flag]; - if (flag === 'WEBGL_FORCE_F16_TEXTURES' || - flag === 'WEBGL_PACK_DEPTHWISECONV' || - flag === 'KEEP_INTERMEDIATE_TENSORS') { - return [false, true]; - } else if (flag === 'WEBGL_VERSION') { - const tunableRange = []; - for (let value = 1; value <= defaultValue; value++) { - tunableRange.push(value); - } - return tunableRange; - } else if (flag === 'WEBGL_FLUSH_THRESHOLD') { - const tunableRange = [-1]; - for (let value = 0; value <= 2; value += 0.25) { - tunableRange.push(value); - } - return tunableRange; - } else if (typeof defaultValue === 'boolean') { - return defaultValue || flag === 'WEBGL_USE_SHAPES_UNIFORMS' ? - [false, true] : - [false]; - } else if (TUNABLE_FLAG_VALUE_RANGE_MAP[flag] != null) { - return TUNABLE_FLAG_VALUE_RANGE_MAP[flag]; - } else { - return [defaultValue]; - } -} diff --git a/tfjs-master/e2e/benchmarks/local-benchmark/index_test.js b/tfjs-master/e2e/benchmarks/local-benchmark/index_test.js deleted file mode 100644 index 2ad24c77b..000000000 --- a/tfjs-master/e2e/benchmarks/local-benchmark/index_test.js +++ /dev/null @@ -1,260 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -/** - * The unit tests in this file can be run by opening `./SpecRunner.html` in - * browser. - */ - -const state = { - backend: 'wasm', - flags: {} -}; - -describe('index', () => { - describe('showFlagSettings', () => { - beforeAll(() => { - this.originalInitDefaultValueMap = initDefaultValueMap; - this.originalShowBackendFlagSettings = showBackendFlagSettings; - this.originalTUNABLE_FLAG_DEFAULT_VALUE_MAP = - TUNABLE_FLAG_DEFAULT_VALUE_MAP; - }); - - afterAll(() => { - initDefaultValueMap = this.originalInitDefaultValueMap; - showBackendFlagSettings = this.originalShowBackendFlagSettings; - TUNABLE_FLAG_DEFAULT_VALUE_MAP = - this.originalTUNABLE_FLAG_DEFAULT_VALUE_MAP; - }); - - describe('at the first call', () => { - beforeAll(() => { - // Only the backend setting is shown and the general flag settings have - // not been shown. - this.folderController = new dat.gui.GUI(); - this.folderController.add(state, 'backend', ['wasm', 'webgl', 'cpu']); - - // The flag default value map has not been initialized. - TUNABLE_FLAG_DEFAULT_VALUE_MAP = null; - - BACKEND_FLAGS_MAP.general.push('testGeneralFlag'); - }); - - afterAll(() => { - this.folderController.destroy(); - BACKEND_FLAGS_MAP.general.pop(); // Pop 'testGeneralFlag'. - }); - - it('shows general flag settings', async () => { - initDefaultValueMap = jasmine.createSpy(); - showBackendFlagSettings = jasmine.createSpy(); - - await showFlagSettings(this.folderController, 'webgl'); - - expect(showBackendFlagSettings.calls.count()).toBe(2); - expect(showBackendFlagSettings.calls.first().args).toEqual([ - this.folderController, 'general' - ]); - }); - - it('initializes default value map', async () => { - initDefaultValueMap = jasmine.createSpy(); - showBackendFlagSettings = jasmine.createSpy(); - await showFlagSettings(this.folderController, 'webgl'); - expect(initDefaultValueMap.calls.count()).toBe(1); - }); - - it('shows flag settings for the given backend', async () => { - initDefaultValueMap = jasmine.createSpy(); - showBackendFlagSettings = jasmine.createSpy(); - - await showFlagSettings(this.folderController, 'webgl'); - - expect(showBackendFlagSettings.calls.count()).toBe(2); - expect(showBackendFlagSettings.calls.argsFor(0)).toEqual([ - this.folderController, 'general' - ]); - expect(showBackendFlagSettings.calls.argsFor(1)).toEqual([ - this.folderController, 'webgl' - ]); - }); - }); - - describe('When switching the backend', () => { - beforeAll(() => { - // The flag default value map has been initialized and the state.flags - // is populated with all tunable flags. - this.originalInitDefaultValueMap(); - BACKEND_FLAGS_MAP.general.push('testGeneralFlag'); - TUNABLE_FLAG_DEFAULT_VALUE_MAP.testGeneralFlag = true; - state.flags.testGeneralFlag = true; - }); - - afterAll(() => { - BACKEND_FLAGS_MAP.general.pop(); // Pop 'testGeneralFlag'. - delete TUNABLE_FLAG_DEFAULT_VALUE_MAP['testGeneralFlag']; - delete state.flags['testGeneralFlag']; - }); - - beforeEach(() => { - // The backend setting and the general flag settings have been shown. - this.folderController = new dat.gui.GUI(); - this.folderController.add(state, 'backend', ['wasm', 'webgl', 'cpu']); - this.originalShowBackendFlagSettings(this.folderController, 'general'); - - // Flag settings for a certain backend have been shown. - this.originalShowBackendFlagSettings(this.folderController, 'webgl'); - }); - - afterEach(() => { - this.folderController.destroy(); - }); - - it('removes flag settings of the previous backend', async () => { - initDefaultValueMap = jasmine.createSpy(); - showBackendFlagSettings = jasmine.createSpy(); - spyOn(this.folderController, 'remove').and.callThrough(); - - await showFlagSettings(this.folderController, 'wasm'); - - expect(initDefaultValueMap.calls.count()).toBe(0); - expect(this.folderController.remove.calls.count()) - .toBe(BACKEND_FLAGS_MAP.webgl.length); - }); - - it('only add flag settings for the new backend', async () => { - initDefaultValueMap = jasmine.createSpy(); - showBackendFlagSettings = jasmine.createSpy(); - - await showFlagSettings(folderController, 'webgl'); - - expect(initDefaultValueMap.calls.count()).toBe(0); - expect(showBackendFlagSettings.calls.count()).toBe(1); - expect(showBackendFlagSettings.calls.first().args).toEqual([ - this.folderController, 'webgl' - ]); - }); - }); - }); - - describe('showBackendFlagSettings', () => { - beforeAll(() => { - // Assume testBackend has only one flag, testFlag. - // A DOM element is shown based on this flag's tunable range. - BACKEND_FLAGS_MAP['testBackend'] = ['testFlag']; - state.flags['testFlag'] = null; - this.originalGetTunableRange = getTunableRange; - - this.folderController = new dat.gui.GUI(); - }); - - afterAll(() => { - delete BACKEND_FLAGS_MAP['testBackend']; - delete state.flags['testFlag']; - getTunableRange = this.originalGetTunableRange; - - this.folderController.destroy(); - }); - - it('does not show DOM element for untunable flags', () => { - // The flag with only one value option is considered as untunable. - const flagValueRange = [false]; - getTunableRange = jasmine.createSpy().and.returnValue(flagValueRange); - spyOn(this.folderController, 'add'); - spyOn(console, 'warn'); - - showBackendFlagSettings(this.folderController, 'testBackend'); - - expect(this.folderController.add.calls.count()).toBe(0); - expect(console.warn.calls.count()).toBe(1); - }); - - it('shows a checkbox for a tunable boolean flag', () => { - state.flags.testFlag = true; - const flagValueRange = [true, false]; - getTunableRange = jasmine.createSpy().and.returnValue(flagValueRange); - spyOn(this.folderController, 'add').and.callThrough(); - - showBackendFlagSettings(this.folderController, 'testBackend'); - - expect(this.folderController.add.calls.count()).toBe(1); - expect(this.folderController.add.calls.first().args).toEqual([ - state.flags, 'testFlag' - ]); - expect(this.folderController.add.calls.first().returnValue.__checkbox) - .toBeDefined(); - }); - - it('shows a dropdown menu for a tunable number type flag', () => { - state.flags.testFlag = 1; - const flagValueRange = [1, 2]; - getTunableRange = jasmine.createSpy().and.returnValue(flagValueRange); - spyOn(this.folderController, 'add').and.callThrough(); - - showBackendFlagSettings(this.folderController, 'testBackend'); - - expect(this.folderController.add.calls.count()).toBe(1); - expect(this.folderController.add.calls.first().args).toEqual([ - state.flags, 'testFlag', flagValueRange - ]); - expect(this.folderController.add.calls.first().returnValue.__select) - .toBeDefined(); - }); - }); - - describe('getTunableRange', () => { - beforeAll(() => { - this.originalTUNABLE_FLAG_DEFAULT_VALUE_MAP = - TUNABLE_FLAG_DEFAULT_VALUE_MAP; - TUNABLE_FLAG_DEFAULT_VALUE_MAP = {}; - }); - - afterAll(() => { - TUNABLE_FLAG_DEFAULT_VALUE_MAP = - this.originalTUNABLE_FLAG_DEFAULT_VALUE_MAP; - }); - - it(`returns [false, true] for 'WEBGL_FORCE_F16_TEXTURES'`, () => { - const flagValueRange = getTunableRange('WEBGL_FORCE_F16_TEXTURES'); - expect(flagValueRange).toEqual([false, true]); - }); - - it(`returns [1, 2] for 'WEBGL_VERSION' if its default value is 2`, () => { - TUNABLE_FLAG_DEFAULT_VALUE_MAP.WEBGL_VERSION = 2; - const flagValueRange = getTunableRange('WEBGL_VERSION'); - expect(flagValueRange).toEqual([1, 2]); - }); - - it(`returns [1] for 'WEBGL_VERSION' if its default value is 1`, () => { - TUNABLE_FLAG_DEFAULT_VALUE_MAP.WEBGL_VERSION = 1; - const flagValueRange = getTunableRange('WEBGL_VERSION'); - expect(flagValueRange).toEqual([1]); - }); - - it('returns [false] for the flag with false as default value', () => { - TUNABLE_FLAG_DEFAULT_VALUE_MAP.testFlag = false; - const flagValueRange = getTunableRange('testFlag'); - expect(flagValueRange).toEqual([false]); - }); - - it('returns [false, true] for the flag with true as default value', () => { - TUNABLE_FLAG_DEFAULT_VALUE_MAP.testFlag = true; - const flagValueRange = getTunableRange('testFlag'); - expect(flagValueRange).toEqual([false, true]); - }); - }); -}); diff --git a/tfjs-master/e2e/benchmarks/local-benchmark/loader.js b/tfjs-master/e2e/benchmarks/local-benchmark/loader.js deleted file mode 100644 index 90f71a5b1..000000000 --- a/tfjs-master/e2e/benchmarks/local-benchmark/loader.js +++ /dev/null @@ -1,74 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// Promise is used to guarantee scripts are loaded in order. -function loadScript(url) { - return new Promise((resolve, reject) => { - const script = document.createElement('script'); - script.onload = resolve; - script.onerror = reject; - script.src = url; - if (url.startsWith('http')) { - script.crossOrigin = 'anonymous'; - } - document.body.append(script); - }) -} - -function processUrls(urls, localBuild) { - for (let i = 0; i < urls.length; i++) { - let name = - urls[i].split('/')[0].replace('tfjs-', '').replace('backend-', ''); - if (localBuild.includes(name)) { - urls[i] = `../../../dist/bin/${urls[i]}`; - } else { - urls[i] = - `https://unpkg.com/@tensorflow/${urls[i].replace('/', '@latest/')}`; - } - } -} - -async function loadTFJS(localBuild) { - let urls = [ - 'tfjs-core/dist/tf-core.js', - 'tfjs-backend-cpu/dist/tf-backend-cpu.js', - 'tfjs-backend-webgl/dist/tf-backend-webgl.js', - 'tfjs-backend-webgpu/dist/tf-backend-webgpu.js', - 'tfjs-layers/dist/tf-layers.js', - 'tfjs-converter/dist/tf-converter.js', - 'tfjs-backend-wasm/dist/tf-backend-wasm.js', - 'tfjs-automl/dist/tf-automl.js', - ]; - - processUrls(urls, localBuild); - urls = urls.concat([ - 'https://cdn.jsdelivr.net/npm/@tensorflow-models/universal-sentence-encoder', - 'https://cdn.jsdelivr.net/npm/@tensorflow-models/speech-commands', - 'https://cdn.jsdelivr.net/npm/@tensorflow-models/posenet@2', - 'https://cdn.jsdelivr.net/npm/@tensorflow-models/body-pix@2', - 'https://cdn.jsdelivr.net/npm/comlink@latest/dist/umd/comlink.js', - '../model_config.js', - '../benchmark_util.js', - './util.js', - './index.js', - './dump.js', - ]); - - for (let url of urls) { - await loadScript(url); - } -} diff --git a/tfjs-master/e2e/benchmarks/local-benchmark/main.css b/tfjs-master/e2e/benchmarks/local-benchmark/main.css deleted file mode 100644 index dd719ceb7..000000000 --- a/tfjs-master/e2e/benchmarks/local-benchmark/main.css +++ /dev/null @@ -1,168 +0,0 @@ -/** -* @license -* Copyright 2019 Google LLC. All Rights Reserved. -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* ============================================================================= -*/ - -html, -body { - box-sizing: border-box; - display: flex; - font-family: 'Roboto', sans-serif; - font-size: 13px; - flex-direction: column; - position: relative; -} - -body { - margin: 20px 100px; -} - -h2 { - margin-bottom: 30px; -} - -#kernels { - max-width: 750px; -} - -#container { - display: flex; - flex-direction: row; - flex-wrap: wrap; -} - -.box { - margin-bottom: 30px; - margin-right: 30px; -} - -.box pre { - border: 1px solid #ccc; - font-size: 10px; - margin: 0; - padding: 8px; -} - -div[id*='trendline-container'] svg { - border-bottom: 1px solid #ccc; - border-left: 1px solid #ccc; - overflow: visible; -} - -div[id*='trendline-container'] .label { - font-size: 14px; - font-weight: bold; -} - -div[id*='trendline-container'] path { - fill: none; - stroke: #222; -} - -.trendline { - margin-top: 20px; - position: relative; -} - -.trendline .yMax, -.trendline .yMin { - font-size: 11px; - position: absolute; - right: calc(100% + 6px); - white-space: nowrap; -} - -.trendline .yMin { - bottom: 0; -} - -.trendline .yMax { - top: 0; -} - -#modal-msg { - border-radius: 5px; - background-color: black; - color: white; - display: none; - left: 45%; - padding: 7px; - position: absolute; - top: 15px; - z-index: 100; -} - -.table { - border: 1px solid #ccc; - border-collapse: collapse; - border-spacing: 0; - margin-right: 30px; - margin-bottom: 30px; -} - -.table caption { - font-size: 14px; - font-weight: bold; -} - -.table tr { - border-bottom: 1px solid #ddd; -} - -.table tr:nth-child(even) { - background-color: #f1f1f1; -} - -.table th { - font-weight: bold; -} - -.table td, -th { - font-size: 13px; - padding: 8px 8px; - text-align: left; - vertical-align: top; -} - -.table td:first-child, -th:first-child { - padding-left: 16px; -} - -#gui input{ - text-align:center; -} - -#gui select { - width: 100%; -} - -#gui .display { - width: 100%; - text-align:center; -} - -#gui input[type=checkbox] { - width: 100%; -} - -#gui .dg .property-name { - width: 25%; -} - -#gui .dg .c { - width: 75%; -} diff --git a/tfjs-master/e2e/benchmarks/local-benchmark/tflite_worker.js b/tfjs-master/e2e/benchmarks/local-benchmark/tflite_worker.js deleted file mode 100644 index 0508f0acc..000000000 --- a/tfjs-master/e2e/benchmarks/local-benchmark/tflite_worker.js +++ /dev/null @@ -1,78 +0,0 @@ -/** - * @license - * Copyright 2023 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// Load scripts from jsdelivr because it correctly sets the -// "cross-origin-resource-policy" header. -importScripts('https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-core/dist/tf-core.js'); -importScripts('https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-backend-cpu/dist/tf-backend-cpu.js'); -importScripts('https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-tflite/dist/tf-tflite.js'); -importScripts('https://cdn.jsdelivr.net/npm/comlink@latest/dist/umd/comlink.js'); - -tflite.setWasmPath('https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-tflite/dist/'); - -const tfliteWorkerAPI = { - async loadTFLiteModel(modelPath, options) { - const model = await tflite.loadTFLiteModel(modelPath, options); - - const wrapped = { - inputs: model.inputs, - getProfilingResults() { - return model.getProfilingResults(); - }, - cleanUp() { - model.modelRunner.cleanUp(); - }, - async predict(inputData) { - const inputTensorArray = []; - let outputTensor; - if (!inputData[0].length) { - // Single input, move it into an arrary - inputData = [inputData]; - } - for (let i = 0; i< this.inputs.length; i++) { - const inputTensor = tf.tensor( - inputData[i], this.inputs[i].shape, this.inputs[i].dtype); - inputTensorArray.push(inputTensor); - } - outputTensor = model.predict(inputTensorArray); - if (model.outputs.length > 1) { - // Multiple outputs - let outputData = []; - for (let tensorName in outputTensor) { - outputData.push(outputTensor[tensorName].dataSync()); - } - } else { - // Single output - const outputData = outputTensor.dataSync(); - } - // dispose input and output tensors - tf.dispose(inputTensorArray); - tf.dispose(outputTensor); - // We encourage the user to process output data in the worker thread - // rather than posting output data to main thread directly, as - // this would bring much overhead if the output size is huge. - // From this perspective, we don't post output data to main thread - // in this benchmark. - return 'OK'; - } - }; - - return Comlink.proxy(wrapped); - }, -}; - -Comlink.expose(tfliteWorkerAPI); diff --git a/tfjs-master/e2e/benchmarks/local-benchmark/util.js b/tfjs-master/e2e/benchmarks/local-benchmark/util.js deleted file mode 100644 index b6eae0e67..000000000 --- a/tfjs-master/e2e/benchmarks/local-benchmark/util.js +++ /dev/null @@ -1,183 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - - -async function convertTensorToData(tensor, needInfo = false) { - const data = await tensor.data(); - - tensor.dispose(); - if (needInfo) { - return {value: data, shape: tensor.shape, dtype: tensor.dtype}; - } - return data; -} - -async function getPredictionData(output, needInfo = false) { - if (output instanceof Promise) { - output = await output; - } - - if (output instanceof tf.Tensor) { - output = [await convertTensorToData(output, needInfo)]; - } else if (Array.isArray(output)) { - for (let i = 0; i < output.length; i++) { - if (output[i] instanceof tf.Tensor) { - output[i] = await convertTensorToData(output[i], needInfo); - } - } - } else if (output != null && typeof output === 'object') { - for (const property in output) { - if (output[property] instanceof tf.Tensor) { - output[property] = - await convertTensorToData(output[property], needInfo); - } - } - } - return output; -} - -function printTime(elapsed) { - return elapsed.toFixed(1) + ' ms'; -} - -function printMemory(bytes) { - if (bytes < 1024) { - return bytes + ' B'; - } else if (bytes < 1024 * 1024) { - return (bytes / 1024).toFixed(2) + ' KB'; - } else { - return (bytes / (1024 * 1024)).toFixed(2) + ' MB'; - } -} - -function sleep(timeMs) { - return new Promise(resolve => setTimeout(resolve, timeMs)); -} - -function queryTimerIsEnabled() { - return _tfengine.ENV.getNumber( - 'WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION') > 0; -} - -function areClose( - a, e, epsilon, epsilonOfBigNumber = 0.1, relativeEpsilon = 0.01) { - if (!isFinite(a) && !isFinite(e)) { - return true; - } else if (isNaN(a) || isNaN(e)) { - return false; - } - - const absoluteError = Math.abs(a - e); - if (Math.abs(a) >= 1) { - if ((absoluteError > epsilonOfBigNumber) || - absoluteError / Math.min(Math.abs(a), Math.abs(e)) > relativeEpsilon) { - return false; - } - } else { - if (absoluteError > epsilon) { - return false; - } - } - return true; -} - -function expectObjectsPredicate(actual, expected, epsilon, predicate) { - let actualKeys = Object.getOwnPropertyNames(actual); - let expectedKeys = Object.getOwnPropertyNames(expected); - if (actualKeys.length != expectedKeys.length) { - throw new Error(`Actual length ${ - actualKeys.length} not equal Expected length ${expectedKeys.length}`); - } - for (let i = 0; i < actualKeys.length; i++) { - let key = actualKeys[i]; - let isObject = typeof (actual[key]) === 'object' && - typeof (expected[key]) === 'object'; - let isArray = tf.util.isTypedArray(actual[key]) && - tf.util.isTypedArray(expected[key]); - if (isArray) { - expectArraysClose(actual[key], expected[key], epsilon, key); - } else if (isObject) { - expectObjectsPredicate(actual[key], expected[key], epsilon, predicate); - } else { - if (!predicate(actual[key], expected[key])) { - throw new Error(`Objects differ: actual[${key}] = ${ - JSON.stringify(actual[key])}, expected[${key}] = ${ - JSON.stringify(expected[key])}!`); - } - } - } - return true; -} - -function expectObjectsClose(actual, expected, epsilon = -1) { - if (epsilon === -1) { - epsilon = tf.test_util.testEpsilon(); - } - expectObjectsPredicate( - actual, expected, epsilon, (a, b) => areClose(a, b, epsilon)); -} - -function expectArraysPredicateFuzzy(actual, expected, predicate, errorRate) { - if (tf.util.isTypedArray(actual) == false || - tf.util.isTypedArray(expected) == false) { - throw new Error(`Actual and Expected are not arrays.`); - } - - if (actual.length !== expected.length) { - throw new Error( - `Arrays have different lengths actual: ${actual.length} vs ` + - `expected: ${expected.length}.\n` + - `Actual: ${actual}.\n` + - `Expected: ${expected}.`); - } - let mismatchCount = 0; - for (let i = 0; i < expected.length; ++i) { - const a = actual[i]; - const e = expected[i]; - if (!predicate(a, e)) { - mismatchCount++; - const maxMismatch = Math.floor(errorRate * expected.length); - if (mismatchCount > maxMismatch) { - throw new Error( - `Arrays data has more than ${maxMismatch} differs from ${ - expected.length}: actual[${i}] = ${a}, expected[${i}] = ${ - e}.\n` + - `Actual: ${actual}.\n` + - `Expected: ${expected}.`); - } - } - } -} - -// TODO: support relative comparison for array. -function expectArraysClose(actual, expected, epsilon, key) { - if (epsilon === -1) { - epsilon = tf.test_util.testEpsilon(); - } - - if (key == 'data') { - // For bodypix, the value in data memeber means "1 for the pixels that are - // part of the person, and 0 otherwise". - // So for these models, we don't expect all data is exactly match. Default - // use error rate 0.001 (1/1000). - const ERROR_RATE = 0.001; - return expectArraysPredicateFuzzy( - actual, expected, (a, b) => areClose(a, b, epsilon), ERROR_RATE); - } else { - return tf.test_util.expectArraysClose(actual, expected, epsilon); - } -} diff --git a/tfjs-master/e2e/benchmarks/model_config.js b/tfjs-master/e2e/benchmarks/model_config.js deleted file mode 100644 index 995c7302a..000000000 --- a/tfjs-master/e2e/benchmarks/model_config.js +++ /dev/null @@ -1,663 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -const DEFAULT_MODEL_NAME = 'model.json'; -const TFHUB_SEARCH_PARAM = '?tfjs-format=file'; - -const sentences = [ - 'add clem burke in my playlist Pre-Party R&B Jams', - 'Add Live from Aragon Ballroom to Trapeo', - 'add Unite and Win to my night out', - 'Add track to my Digster Future Hits', - 'add the piano bar to my Cindy Wilson', - 'Add Spanish Harlem Incident to cleaning the house', - 'add The Greyest of Blue Skies in Indie Español my playlist', - 'Add the name kids in the street to the plylist New Indie Mix', - 'add album radar latino', - 'Add Tranquility to the Latin Pop Rising playlist.', - 'play something from the twenties', - 'Play The View From The Afternoon by Malese Jow on Last Fm', - 'play songs by Sammy Fain', - 'Play music from the year 1964', - 'Play the heinz strobl ep from 2016 on Groove Shark', - 'Play me Leonid Soybelman on Vimeo.', - 'Play a song from my workout playlist on Groove Shark', - 'play some Alte Kameraden music', - 'Will it be warm 1 week from now in DC', - 'what is the forecast for temperate conditions in Thailand in Lopeno', - 'Is the weather colder in Costa Rica', - 'Will it be colder in Delaware?', - '"I need to know the weather for Hamorton, TN"', - 'What will the weather be in Albania at 11:56.', - 'Is it going to hail in Mount San Jacinto State Park', - 'What\'s the forecast for Walker Bay Nature Reserve for next year ? ', - 'is it supposed to be sunny here?', - 'in California will it be cold in East Trenton Heights', - 'What is the weather like in Wallis and Futuna? What will the weather be in Romania at 4?', - 'What is the weather going to be like in Reidland New Mexico next Jun.?', - 'How cold is it in Cargray, Argentina?', - 'Is the forecast chillier in 1 hour in Mali', - 'Tell me if there will be wind in NE Will it be cloudy not far from Allenton Will there be a blizzard in AR what is the New Caledonia forecast for Bagnell on sep. the 5th Weather for apr. the thirteenth in Djibouti', - 'Can you give me the weather forecast in Tajikistan? How cold is it going to be in San Marcial, AK in one second? What will the weather be in a month from now at my current location?', - 'What is the weather like in IA in april How windy is it in Anderson Lake State Fish and Wildlife Area? Is it going to be stormy in Austin Creek State Recreation Area at 09:42?', - 'When will the weather be temperate like it is now in Stansbury Park in Tuvalu, What is the weather in neighboring OH, What\'s the weather forecast for Spain ? ', - 'Play the music Hands Up', - 'Play some twenties theme music on Google Music.', - 'How will the weather be in New Mexico around 00:09:07 am?', - 'What will the humidity be in AR in 49 weeks and a half from now', - 'Is it humid in Parc national de Killarney', - 'is it supposed to get colder here on 12/28/2019', - 'How is the forecast for OK?', - 'what is the Posey Island State Park forecast for colder temps at meal time', - 'Is it supposed to be chilly in Kuwait?', - 'Tell me if it\'ll be chilly here at 0 pm', - 'what is the forecast for colder conditions within the same area of this current place', - 'Will it hail today in West Point at 11:36:48', - 'Is it overcast in South Carolina', - 'Will the sun be out close-by Admiralty Island National Monument?', - 'What will the weather be in Wakarusa', - 'How temperate will it be here this week?', - 'what is the forecast for here at tea time', -]; - -function predictFunction(input) { - return model => model.predict(input); -} - -// Common predict function for MobileNetV3 and MobileNetV2Lite -function commonMobileNetPredictFunc() { - const input = tf.randomNormal([1, 224, 224, 3]); - const inputData = input.dataSync(); - if (typeof isTflite === 'function' && isTflite()) { - return async () => { - // Do copy from 'inputData' in each predict as its buffer - // will be detached after transferring to worker. - const input = inputData.slice(0); - return await tfliteModel.predict( - Comlink.transfer(input, [input.buffer])); - }; - } else { - return predictFunction(input); - } -} - -const benchmarks = { - 'MobileNetV3': { - type: 'GraphModel', - architectures: ['small_075', 'small_100', 'large_075', 'large_100'], - load: async (inputResolution = 224, modelArchitecture = 'small_075') => { - const url = `https://tfhub.dev/google/tfjs-model/imagenet/mobilenet_v3_${ - modelArchitecture}_224/classification/5/default/1`; - return tf.loadGraphModel(url, {fromTFHub: true}); - }, - loadTflite: async ( - enableProfiling = false, modelArchitecture = 'small_075') => { - const url = `https://tfhub.dev/google/lite-model/imagenet/mobilenet_v3_${ - modelArchitecture}_224/classification/5/metadata/1`; - return await tfliteWorkerAPI.loadTFLiteModel(url, {enableProfiling}); - }, - predictFunc: commonMobileNetPredictFunc, - }, - 'MobileNetV2': { - type: 'GraphModel', - architectures: ['050', '075', '100'], - load: async (inputResolution = 224, modelArchitecture = '050') => { - const url = `https://tfhub.dev/google/tfjs-model/imagenet/mobilenet_v2_${ - modelArchitecture}_224/classification/3/default/1`; - return tf.loadGraphModel(url, {fromTFHub: true}); - }, - predictFunc: () => { - const input = tf.randomNormal([1, 224, 224, 3]); - return predictFunction(input); - }, - }, - // Currently, for mobilenet_v2, only the architectures with alpha=100 has - // tflite model. Since users could tune the alpha for 'mobilenet_v2' tfjs - // models, while we could only provides mobilnet_v2_lite with alpha=100 on the - // tflite backend, so mibilnet_v2_lite is separated from mibilnet_v2 and fixes - // alpha=100; othwise it would confuse users. - 'MobileNetV2Lite': { - type: 'GraphModel', - load: async () => { - throw new Error(`Please set tflite as the backend to run this model.`); - }, - loadTflite: async (enableProfiling = false) => { - const url = - 'https://tfhub.dev/tensorflow/lite-model/mobilenet_v2_1.0_224/1/metadata/1'; - return await tfliteWorkerAPI.loadTFLiteModel(url, {enableProfiling}); - }, - predictFunc: commonMobileNetPredictFunc, - }, - 'HandPoseDetector': { - type: 'GraphModel', - architectures: ['lite', 'full'], - load: async (inputResolution = 192, modelArchitecture = 'lite') => { - const url = - `https://tfhub.dev/mediapipe/tfjs-model/handpose_3d/detector/${ - modelArchitecture}/1`; - return tf.loadGraphModel(url, {fromTFHub: true}); - }, - predictFunc: () => { - const input = tf.zeros([1, 192, 192, 3]); - return predictFunction(input); - }, - }, - 'HandPoseLandmark': { - type: 'GraphModel', - architectures: ['lite', 'full'], - load: async (inputResolution = 224, modelArchitecture = 'lite') => { - const url = - `https://tfhub.dev/mediapipe/tfjs-model/handpose_3d/landmark/${ - modelArchitecture}/1`; - return tf.loadGraphModel(url, {fromTFHub: true}); - }, - predictFunc: () => { - const input = tf.zeros([1, 224, 224, 3]); - return predictFunction(input); - }, - }, - 'MoveNet-SinglePose': { - type: 'GraphModel', - inputSizes: [192, 256], - load: async (inputResolution = 192) => { - const modelType = inputResolution === 192 ? 'lightning' : 'thunder'; - const url = `https://tfhub.dev/google/tfjs-model/movenet/singlepose/${ - modelType}/4`; - return tf.loadGraphModel(url, {fromTFHub: true}); - }, - predictFunc: (inputResolution = 192) => { - const input = tf.zeros([1, inputResolution, inputResolution, 3], 'int32'); - return predictFunction(input); - }, - }, - 'MoveNet-MultiPose': { - type: 'GraphModel', - load: async () => { - const url = - 'https://tfhub.dev/google/tfjs-model/movenet/multipose/lightning/1'; - return tf.loadGraphModel(url, {fromTFHub: true}); - }, - predictFunc: () => { - const input = tf.zeros([1, 256, 256, 3], 'int32'); - return predictFunction(input); - }, - }, - 'BlazePoseDetector': { - type: 'GraphModel', - load: async () => { - const url = - 'https://tfhub.dev/mediapipe/tfjs-model/blazeposedetector/1/default/1'; - return tf.loadGraphModel(url, {fromTFHub: true}); - }, - predictFunc: () => { - const input = tf.zeros([1, 224, 224, 3]); - return predictFunction(input); - }, - }, - 'BlazePoseLandmark': { - type: 'GraphModel', - architectures: ['lite', 'full', 'heavy'], - load: async (inputResolution = 256, modelArchitecture = 'lite') => { - const url = `https://tfhub.dev/mediapipe/tfjs-model/blazeposelandmark_${ - modelArchitecture}/2/default/2`; - return tf.loadGraphModel(url, {fromTFHub: true}); - }, - predictFunc: () => { - const input = tf.zeros([1, 256, 256, 3]); - return predictFunction(input); - }, - }, - 'Coco-SSD': { - type: 'GraphModel', - // The model has has the dynamic ops, so it is supposed to use executeAsync. - architectures: ['MobileNetV2', 'MobileNetV1', 'liteMobileNetV2'], - load: async (inputResolution = 227, modelArchitecture = 'MobileNetV2') => { - const tfliteBased = modelArchitecture.split('MobileNetV')[0]; - const mobileNetVersion = modelArchitecture.split('MobileNetV')[1]; - const url = `https://storage.googleapis.com/tfjs-models/savedmodel/ssd${ - tfliteBased}_mobilenet_v${mobileNetVersion}/model.json`; - return tf.loadGraphModel(url); - }, - predictFunc: () => { - const input = tf.zeros([1, 227, 227, 3], 'int32'); - return model => model.executeAsync(input); - }, - }, - 'DeepLabV3': { - type: 'GraphModel', - // TODO: Add cityscapes architecture. - // https://github.com/tensorflow/tfjs/issues/6733 - architectures: ['pascal', 'ade20k'], - load: async (inputResolution = 227, modelArchitecture = 'pascal') => { - const url = - `https://storage.googleapis.com/tfhub-tfjs-modules/tensorflow/tfjs-model/deeplab/${ - modelArchitecture}/1/quantized/2/1/model.json`; - return tf.loadGraphModel(url); - }, - predictFunc: () => { - const input = tf.zeros([1, 227, 500, 3], 'int32'); - return predictFunction(input); - }, - }, - 'FaceDetection': { - type: 'GraphModel', - inputSizes: [128, 192], - load: async (inputResolution = 128) => { - const modelSize = inputResolution === 128 ? 'short' : 'full'; - const url = `https://tfhub.dev/mediapipe/tfjs-model/face_detection/${ - modelSize}/1`; - return tf.loadGraphModel(url, {fromTFHub: true}); - }, - predictFunc: (inputResolution = 128) => { - const input = tf.zeros([1, inputResolution, inputResolution, 3]); - return predictFunction(input); - }, - }, - 'FaceLandmarkDetection': { - type: 'GraphModel', - architectures: ['attention_mesh', 'face_mesh'], - load: async ( - inputResolution = 192, modelArchitecture = 'attention_mesh') => { - const url = - `https://tfhub.dev/mediapipe/tfjs-model/face_landmarks_detection/${ - modelArchitecture}/1`; - return tf.loadGraphModel(url, {fromTFHub: true}); - }, - predictFunc: () => { - const input = tf.zeros([1, 192, 192, 3]); - return predictFunction(input); - }, - }, - 'ArPortraitDepth': { - type: 'GraphModel', - load: async () => { - const url = 'https://tfhub.dev/tensorflow/tfjs-model/ar_portrait_depth/1'; - return tf.loadGraphModel(url, {fromTFHub: true}); - }, - predictFunc: () => { - const input = tf.zeros([1, 256, 192, 3]); - return predictFunction(input); - }, - }, - 'SelfieSegmentation-General': { - type: 'GraphModel', - load: async () => { - const url = - 'https://tfhub.dev/mediapipe/tfjs-model/selfie_segmentation/general/1'; - return tf.loadGraphModel(url, {fromTFHub: true}); - }, - predictFunc: () => { - const input = tf.zeros([1, 256, 256, 3]); - return predictFunction(input); - }, - }, - 'SelfieSegmentation-Landscape': { - type: 'GraphModel', - load: async () => { - const url = - 'https://tfhub.dev/mediapipe/tfjs-model/selfie_segmentation/landscape/1'; - return tf.loadGraphModel(url, {fromTFHub: true}); - }, - predictFunc: () => { - const input = tf.zeros([1, 144, 256, 3]); - return predictFunction(input); - }, - }, - 'AutoML Image': { - type: 'GraphModel', - load: async () => { - const url = - 'https://storage.googleapis.com/tfjs-testing/tfjs-automl/img_classification/model.json'; - return tf.loadGraphModel(url); - }, - predictFunc: () => { - const zeros = tf.zeros([1, 224, 224, 3]); - return predictFunction(zeros); - } - }, - 'AutoML Object': { - type: 'GraphModel', - load: async () => { - const url = - 'https://storage.googleapis.com/tfjs-testing/tfjs-automl/object_detection/model.json'; - return tf.loadGraphModel(url); - }, - predictFunc: () => { - const OUTPUT_NODE_NAMES = - ['Postprocessor/convert_scores', 'Postprocessor/Decode/transpose_1']; - const feedDict = {ToFloat: tf.zeros([1, 224, 224, 3])}; - return model => model.executeAsync(feedDict, OUTPUT_NODE_NAMES); - } - }, - 'USE - batchsize 30': { - type: 'GraphModel', - load: async () => { - return use.load(); - }, - predictFunc: () => { - const sentences30 = sentences.slice(0, 30); - return async model => { - const res = await model.embed(sentences30); - return res; - }; - } - }, - 'USE - batchsize 1': { - type: 'GraphModel', - load: async () => { - return use.load(); - }, - predictFunc: () => { - return async model => { - const next = [sentences[0]]; - const res = await model.embed(next); - return res; - }; - } - }, - 'TextToxicity': { - type: 'GraphModel', - // The model has has the dynamic ops, so it is supposed to use executeAsync. - load: async () => { - const url = - 'https://storage.googleapis.com/tfhub-tfjs-modules/tensorflow/tfjs-model/toxicity/1/default/1/model.json'; - return tf.loadGraphModel(url); - }, - predictFunc: () => { - const indices = tf.tensor2d( - [0, 0, 0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9], [10, 2], - 'int32'); - const values = tf.randomUniform([10], 0, 1000, 'int32'); - const input = {Placeholder_1: indices, Placeholder: values}; - return model => model.executeAsync(input); - } - }, - 'MobileBert': { - type: 'GraphModel', - load: async () => { - const url = 'https://tfhub.dev/tensorflow/tfjs-model/mobilebert/1'; - return tf.loadGraphModel(url, {fromTFHub: true}); - }, - predictFunc: () => { - const batchSize = 1; - const INPUT_SIZE = 384; - const inputIds = tf.ones([batchSize, INPUT_SIZE], 'int32'); - const segmentIds = tf.ones([1, INPUT_SIZE], 'int32'); - const inputMask = tf.ones([1, INPUT_SIZE], 'int32'); - const input = { - input_ids: inputIds, - segment_ids: segmentIds, - input_mask: inputMask, - global_step: tf.scalar(1, 'int32') - }; - return predictFunction(input); - } - }, - 'posenet': { - type: 'GraphModel', - inputSizes: [128, 256, 512, 1024], - architectures: ['MobileNetV1', 'ResNet50'], - inputTypes: ['image', 'tensor'], - load: async ( - inputResolution = 128, modelArchitecture = 'MobileNetV1', - inputType = 'image') => { - let config = null; - if (modelArchitecture === 'MobileNetV1') { - config = { - architecture: modelArchitecture, - outputStride: 16, - multiplier: 0.75, - inputResolution: inputResolution, - }; - } else if (modelArchitecture === 'ResNet50') { - config = { - architecture: modelArchitecture, - outputStride: 32, - quantBytes: 2, - inputResolution: inputResolution, - }; - } - const model = await posenet.load(config); - if (inputType === 'tensor') { - model.input = tf.zeros([inputResolution, inputResolution, 3]); - } else { - model.input = await loadImage('tennis_standing.jpg'); - } - return model; - }, - predictFunc: () => { - return async model => { - return model.estimateSinglePose(model.input); - }; - } - }, - 'bodypix': { - type: 'GraphModel', - // The ratio to the default camera size [480, 640]. - inputSizes: [0.25, 0.5, 0.75, 1.0], - architectures: ['ResNet50'], - inputTypes: ['image', 'tensor'], - load: async ( - internalResolution, modelArchitecture = 'MobileNetV1', - inputType = 'image') => { - let config = { - architecture: 'ResNet50', - outputStride: 32, - quantBytes: 4, - }; - const model = await bodyPix.load(config); - if (inputType === 'tensor') { - model.input = - tf.zeros([480 * internalResolution, 640 * internalResolution, 3]); - } else { - model.input = await loadImage('tennis_standing.jpg'); - } - return model; - }, - predictFunc: (internalResolution = 0.5) => { - return async model => { - const PERSON_INFERENCE_CONFIG = { - internalResolution: internalResolution, - }; - return model.segmentPerson(model.input, PERSON_INFERENCE_CONFIG); - }; - } - }, - 'speech-commands': { - // Layer model doesn't support dump. TODO(xing.xu@intel.com): - // https://github.com/tensorflow/tfjs/issues/7010 - supportDump: false, - load: async () => { - const recognizer = speechCommands.create('BROWSER_FFT'); - await recognizer.ensureModelLoaded(); - return recognizer; - }, - predictFunc: () => { - return async (model) => { - const shape = model.modelInputShape(); - // Cannot use tf.util.sizeFromShape because shape includes null. - const mySpectrogramData = new Float32Array(shape.reduce((acc, curr) => { - if (curr == null) { - return acc; - } - return acc * curr; - }, 1)); - const x = tf.tensor4d(mySpectrogramData, [1].concat(shape.slice(1))); - return await model.recognize(x); - } - } - }, - 'custom': { - type: '', - load: async () => { - return loadModelByUrlWithState(state.modelUrl, {}, state); - }, - loadTflite: async (enableProfiling = false) => { - return await tfliteWorkerAPI.loadTFLiteModel(state.modelUrl, {enableProfiling}); - }, - predictFunc: () => { - return async (model, customInput) => { - let inferenceInput; - try { - inferenceInput = customInput || - generateInputFromDef( - state.inputs, model instanceof tf.GraphModel); - if (typeof isTflite === 'function' && isTflite()) { - const inputDataArray = []; - inferenceInput = inferenceInput instanceof - Array ? inferenceInput : [inferenceInput]; - for (let tensor of inferenceInput) { - const inputData = tensor.dataSync(); - // Do copy from 'inputData' in each predict as its buffer - // will be detached after transferring to worker. - inputDataArray.push(inputData.slice(0)); - } - - const buffer = inputDataArray.map(data => data.buffer); - return await tfliteModel.predict( - Comlink.transfer(inputDataArray, buffer)); - } else { - const predict = getPredictFnForModel(model, inferenceInput); - return await predict(); - } - } finally { - // dispose input tensors - if (!customInput && inferenceInput) { - tf.dispose(inferenceInput); - } - } - }; - }, - }, -}; - - -const imageBucket = - 'https://storage.googleapis.com/tfjs-models/assets/posenet/'; -async function loadImage(imagePath) { - const image = new Image(); - const promise = new Promise((resolve, reject) => { - image.crossOrigin = ''; - image.onload = () => { - resolve(image); - }; - }); - - image.src = `${imageBucket}${imagePath}`; - return promise; -} - -function findIOHandler(path, loadOptions = {}) { - let handler; - if (path.load != null) { - handler = path; - } else if (loadOptions.requestInit != null) { - handler = tf.io.browserHTTPRequest(path, loadOptions); - } else { - const handlers = tf.io.getLoadHandlers(path, loadOptions); - if (handlers.length === 0) { - handlers.push(tf.io.browserHTTPRequest(path, loadOptions)); - } else if (handlers.length > 1) { - throw new Error( - `Found more than one (${handlers.length}) load handlers for ` + - `URL '${[path]}'.`); - } - handler = handlers[0]; - } - return handler; -} - -async function tryAllLoadingMethods( - modelHandler, loadOptions = {}, state = {}) { - let model; - // TODO: download weights once - try { - model = await tf.loadGraphModel(modelHandler, loadOptions); - state.modelType = 'GraphModel'; - return model; - } catch (e) { - } - - try { - model = await tf.loadLayersModel(modelHandler, loadOptions); - state.modelType = 'LayersModel'; - return model; - } catch (e) { - } - - throw new Error(`Didn't find a fit loading method for this model.`); -} - -/** - * Load a graph model or a a model composed of Layer objects and record the - * model type (GraphModel or LayersModel) at `state.modelType`, given a URL to - * the model definition. - * - * @param {string} modelUrl - * @param {io.LoadOptions} loadOptions - * @param {object} state The object that is used to record the model type. - * This can be extended with more model information if needed. - */ -async function loadModelByUrlWithState(modelUrl, loadOptions = {}, state = {}) { - let model, ioHandler, modelType; - - const supportedSchemes = /^(https?|localstorage|indexeddb):\/\/.+$/; - if (!supportedSchemes.test(modelUrl)) { - throw new Error(`Please use a valid URL, such as 'https://'.`); - } - - const tfHubUrl = /^https:\/\/tfhub.dev\/.+$/; - if (loadOptions.fromTFHub || tfHubUrl.test(modelUrl)) { - if (!modelUrl.endsWith('/')) { - modelUrl = modelUrl + '/'; - } - modelUrl = `${modelUrl}${DEFAULT_MODEL_NAME}${TFHUB_SEARCH_PARAM}`; - } - - // Convert URL to IOHandler and parse the model type - try { - ioHandler = findIOHandler(modelUrl, loadOptions); - const artifacts = await ioHandler.load(); - modelType = artifacts.format; - } catch (e) { - console.error(`Failed to fetch or parse 'model.json' file.`); - throw e; - } - - // load models - try { - if (modelType === 'graph-model') { - model = await tf.loadGraphModel(ioHandler, loadOptions); - state.modelType = 'GraphModel'; - } else if (modelType === 'layers-model') { - model = await tf.loadLayersModel(ioHandler, loadOptions); - state.modelType = 'LayersModel'; - } else { - model = await tryAllLoadingMethods(ioHandler, loadOptions, state); - } - } catch (e) { - console.error('Failed to load the model.'); - throw e; - } - - return model; -} - -async function loadModelByUrl(modelUrl, loadOptions = {}) { - const state = {}; - return loadModelByUrlWithState(modelUrl, loadOptions, state); -} diff --git a/tfjs-master/e2e/benchmarks/movenet/group1-shard1of3.bin b/tfjs-master/e2e/benchmarks/movenet/group1-shard1of3.bin deleted file mode 100644 index 425cb0269..000000000 Binary files a/tfjs-master/e2e/benchmarks/movenet/group1-shard1of3.bin and /dev/null differ diff --git a/tfjs-master/e2e/benchmarks/movenet/group1-shard2of3.bin b/tfjs-master/e2e/benchmarks/movenet/group1-shard2of3.bin deleted file mode 100644 index 1d3bd642a..000000000 Binary files a/tfjs-master/e2e/benchmarks/movenet/group1-shard2of3.bin and /dev/null differ diff --git a/tfjs-master/e2e/benchmarks/movenet/group1-shard3of3.bin b/tfjs-master/e2e/benchmarks/movenet/group1-shard3of3.bin deleted file mode 100644 index 0f0cd3927..000000000 Binary files a/tfjs-master/e2e/benchmarks/movenet/group1-shard3of3.bin and /dev/null differ diff --git a/tfjs-master/e2e/benchmarks/movenet/model.json b/tfjs-master/e2e/benchmarks/movenet/model.json deleted file mode 100644 index 1f67a4e06..000000000 --- a/tfjs-master/e2e/benchmarks/movenet/model.json +++ /dev/null @@ -1 +0,0 @@ -{"format": "graph-model", "generatedBy": "2.7.0", "convertedBy": "TensorFlow.js Converter v3.7.0", "signature": {"inputs": {"input": {"name": "input:0", "dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "1"}, {"size": "320"}, {"size": "320"}, {"size": "3"}]}}}, "outputs": {"output_0": {"name": "Identity:0", "dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "1"}, {"size": "10"}, {"size": "56"}]}}}}, "modelTopology": {"node": [{"name": "StatefulPartitionedCall/map/while/loop_counter", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/map/while/maximum_iterations", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/map/Const", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/map/TensorArrayV2_2/element_shape", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "3"}]}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/map/TensorArrayV2_2/num_elements", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/map/TensorArrayUnstack/TensorListFromTensor/element_shape", "op": "Const", "attr": {"dtype": {"type": "DT_INT32"}, "value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "3"}]}}}}}, {"name": "StatefulPartitionedCall/Tile_16", "op": "Const", "attr": {"dtype": {"type": "DT_FLOAT"}, "value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "1"}, {"size": "4"}]}}}}}, {"name": "StatefulPartitionedCall/map/TensorArrayUnstack_1/TensorListFromTensor/element_shape", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "1"}]}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/map/TensorArrayV2Stack/TensorListStack/element_shape", "op": "Const", "attr": {"dtype": {"type": "DT_INT32"}, "value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "3"}]}}}}}, {"name": "StatefulPartitionedCall/ExpandDims_17/dim", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/concat_2/axis", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/Reshape_37/shape", "op": "Const", "attr": {"dtype": {"type": "DT_INT32"}, "value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "3"}]}}}}}, {"name": "StatefulPartitionedCall/mul_5", "op": "Const", "attr": {"dtype": {"type": "DT_FLOAT"}, "value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "1"}, {"size": "1"}, {"size": "4"}]}}}}}, {"name": "StatefulPartitionedCall/clip_by_value_4/Minimum/y", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/clip_by_value_4/y", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/x_2", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/Sum_4/reduction_indices", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/Maximum_2/y", "op": "Const", "attr": {"dtype": {"type": "DT_FLOAT"}, "value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {}}}}}, {"name": "StatefulPartitionedCall/strided_slice_22/stack", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "3"}]}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/strided_slice_22/stack_1", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "3"}]}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/strided_slice_22/stack_2", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "3"}]}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/strided_slice_20/stack", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "3"}]}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/strided_slice_20/stack_1", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "3"}]}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/strided_slice_20/stack_2", "op": "Const", "attr": {"dtype": {"type": "DT_INT32"}, "value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "3"}]}}}}}, {"name": "StatefulPartitionedCall/Tile_17/multiples", "op": "Const", "attr": {"dtype": {"type": "DT_INT32"}, "value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "3"}]}}}}}, {"name": "StatefulPartitionedCall/x", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/Greater_5/y", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/strided_slice_16/stack", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "4"}]}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/strided_slice_16/stack_1", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "4"}]}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/strided_slice_16/stack_2", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "4"}]}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/GreaterEqual_2/y", "op": "Const", "attr": {"dtype": {"type": "DT_FLOAT"}, "value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {}}}}}, {"name": "StatefulPartitionedCall/strided_slice_17/stack", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "4"}]}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/strided_slice_17/stack_1", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "4"}]}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/strided_slice_17/stack_2", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "4"}]}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/LessEqual/y", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/strided_slice_18/stack", "op": "Const", "attr": {"dtype": {"type": "DT_INT32"}, "value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "4"}]}}}}}, {"name": "StatefulPartitionedCall/strided_slice_18/stack_1", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "4"}]}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/strided_slice_18/stack_2", "op": "Const", "attr": {"dtype": {"type": "DT_INT32"}, "value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "4"}]}}}}}, {"name": "StatefulPartitionedCall/GreaterEqual_3/y", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/ExpandDims_16/dim", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/Tile_15/multiples", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "4"}]}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/Reshape_36", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "1"}, {"size": "1"}, {"size": "1"}, {"size": "2"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/strided_slice_19/stack", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "4"}]}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/strided_slice_19/stack_1", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "4"}]}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/strided_slice_19/stack_2", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "4"}]}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/LessEqual_1/y", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/strided_slice_12/stack", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "4"}]}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/strided_slice_12/stack_1", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "4"}]}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/strided_slice_12/stack_2", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "4"}]}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/strided_slice_13/stack", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "4"}]}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/strided_slice_13/stack_1", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "4"}]}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/strided_slice_13/stack_2", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "4"}]}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/strided_slice_14/stack", "op": "Const", "attr": {"dtype": {"type": "DT_INT32"}, "value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "4"}]}}}}}, {"name": "StatefulPartitionedCall/strided_slice_14/stack_1", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "4"}]}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/strided_slice_14/stack_2", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "4"}]}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/Reshape_32/shape", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "4"}]}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/transpose_6/perm", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "4"}]}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/strided_slice_15/stack", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "4"}]}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/strided_slice_15/stack_1", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "4"}]}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/strided_slice_15/stack_2", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "4"}]}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/Less_6/y", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/Min/reduction_indices", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/ScaleHeightWidth/mul", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/ScaleHeightWidth/mul_4", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "ConstantFolding/StatefulPartitionedCall/ScaleHeightWidth/get_center_coordinates_and_sizes/truediv_recip", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/ScaleHeightWidth/mul_2", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "ConstantFolding/StatefulPartitionedCall/ScaleHeightWidth/get_center_coordinates_and_sizes/truediv_1_recip", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/ScaleHeightWidth/mul_6", "op": "Const", "attr": {"dtype": {"type": "DT_FLOAT"}, "value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {}}}}}, {"name": "ConstantFolding/StatefulPartitionedCall/truediv_2_recip", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/clip_by_value/y", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "ConstantFolding/StatefulPartitionedCall/truediv_3_recip", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/clip_by_value_1/y", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "ConstantFolding/StatefulPartitionedCall/truediv_4_recip", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/Cast_4", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/clip_by_value_2/y", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/box_offset_0/separable_conv2d_5/separable_conv2d/ReadVariableOp", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "3"}, {"size": "3"}, {"size": "24"}, {"size": "1"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/box_offset_0/separable_conv2d_5/separable_conv2d/ReadVariableOp_1", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "1"}, {"size": "1"}, {"size": "24"}, {"size": "96"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/box_offset_0/separable_conv2d_5/BiasAdd/ReadVariableOp", "op": "Const", "attr": {"dtype": {"type": "DT_FLOAT"}, "value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "96"}]}}}}}, {"name": "StatefulPartitionedCall/box_offset_0/conv2d_6/Conv2D/ReadVariableOp", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "1"}, {"size": "1"}, {"size": "96"}, {"size": "2"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/box_offset_0/conv2d_6/BiasAdd/ReadVariableOp", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "2"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/Reshape_7/shape", "op": "Const", "attr": {"dtype": {"type": "DT_INT32"}, "value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "3"}]}}}}}, {"name": "StatefulPartitionedCall/box_scale_0/separable_conv2d_4/separable_conv2d/ReadVariableOp", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "3"}, {"size": "3"}, {"size": "24"}, {"size": "1"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/box_scale_0/separable_conv2d_4/separable_conv2d/ReadVariableOp_1", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "1"}, {"size": "1"}, {"size": "24"}, {"size": "96"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/box_scale_0/separable_conv2d_4/BiasAdd/ReadVariableOp", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "96"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/box_scale_0/conv2d_5/Conv2D/ReadVariableOp", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "1"}, {"size": "1"}, {"size": "96"}, {"size": "2"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/box_scale_0/conv2d_5/BiasAdd/ReadVariableOp", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "2"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/Reshape_3", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "10"}]}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/Reshape_4/shape", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "1"}]}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/Reshape_5/shape", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "1"}]}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/Reshape_6/shape", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "3"}]}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/Maximum/y", "op": "Const", "attr": {"dtype": {"type": "DT_FLOAT"}, "value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {}}}}}, {"name": "ConstantFolding/StatefulPartitionedCall/truediv_5_recip", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/Cast_5", "op": "Const", "attr": {"dtype": {"type": "DT_FLOAT"}, "value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {}}}}}, {"name": "StatefulPartitionedCall/clip_by_value_3/y", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/strided_slice_10/stack", "op": "Const", "attr": {"dtype": {"type": "DT_INT32"}, "value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "2"}]}}}}}, {"name": "StatefulPartitionedCall/strided_slice_10/stack_1", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "2"}]}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/strided_slice_10/stack_2", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "2"}]}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/Reshape_34/shape", "op": "Const", "attr": {"dtype": {"type": "DT_INT32"}, "value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "2"}]}}}}}, {"name": "StatefulPartitionedCall/ScaleHeightWidth/get_center_coordinates_and_sizes/transpose/perm", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "2"}]}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/Reshape_35/shape", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "3"}]}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/ExpandDims_15/dim", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/Tile_14/multiples", "op": "Const", "attr": {"dtype": {"type": "DT_INT32"}, "value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "4"}]}}}}}, {"name": "StatefulPartitionedCall/mul_12/y", "op": "Const", "attr": {"dtype": {"type": "DT_FLOAT"}, "value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {}}}}}, {"name": "StatefulPartitionedCall/Greater_4/y", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/mul_13", "op": "Const", "attr": {"dtype": {"type": "DT_FLOAT"}, "value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "1"}, {"size": "10"}, {"size": "17"}]}}}}}, {"name": "StatefulPartitionedCall/Reshape_29", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT64", "tensorShape": {"dim": [{"size": "170"}]}}}, "dtype": {"type": "DT_INT64"}}}, {"name": "StatefulPartitionedCall/Reshape_30", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT64", "tensorShape": {"dim": [{"size": "170"}]}}}, "dtype": {"type": "DT_INT64"}}}, {"name": "StatefulPartitionedCall/ExpandDims_12/dim", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/Tile_11/multiples", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "4"}]}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/Tile_6", "op": "Const", "attr": {"dtype": {"type": "DT_INT32"}, "value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "1"}, {"size": "100"}, {"size": "17"}]}}}}}, {"name": "StatefulPartitionedCall/transpose_2/perm", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "3"}]}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/GreaterEqual/y", "op": "Const", "attr": {"dtype": {"type": "DT_FLOAT"}, "value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {}}}}}, {"name": "StatefulPartitionedCall/Sum_1/reduction_indices", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/ExpandDims_8/dim", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/Tile_7/multiples", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "3"}]}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/ExpandDims_11/dim", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/Tile_10/multiples", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "4"}]}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/mul_11", "op": "Const", "attr": {"dtype": {"type": "DT_FLOAT"}, "value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "1"}, {"size": "10"}, {"size": "100"}, {"size": "17"}]}}}}}, {"name": "StatefulPartitionedCall/ExpandDims_3/dim", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/ExpandDims_4/dim", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/kpt_regress_0/separable_conv2d_7/separable_conv2d/ReadVariableOp", "op": "Const", "attr": {"dtype": {"type": "DT_FLOAT"}, "value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "3"}, {"size": "3"}, {"size": "24"}, {"size": "1"}]}}}}}, {"name": "StatefulPartitionedCall/kpt_regress_0/separable_conv2d_7/separable_conv2d/ReadVariableOp_1", "op": "Const", "attr": {"dtype": {"type": "DT_FLOAT"}, "value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "1"}, {"size": "1"}, {"size": "24"}, {"size": "96"}]}}}}}, {"name": "StatefulPartitionedCall/kpt_regress_0/separable_conv2d_7/BiasAdd/ReadVariableOp", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "96"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/kpt_regress_0/conv2d_8/Conv2D/ReadVariableOp", "op": "Const", "attr": {"dtype": {"type": "DT_FLOAT"}, "value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "1"}, {"size": "1"}, {"size": "96"}, {"size": "34"}]}}}}}, {"name": "StatefulPartitionedCall/kpt_regress_0/conv2d_8/BiasAdd/ReadVariableOp", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "34"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/strided_slice_7/stack", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "2"}]}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/strided_slice_7/stack_1", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "2"}]}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/strided_slice_7/stack_2", "op": "Const", "attr": {"dtype": {"type": "DT_INT32"}, "value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "2"}]}}}}}, {"name": "StatefulPartitionedCall/Reshape_8", "op": "Const", "attr": {"dtype": {"type": "DT_INT32"}, "value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "10"}]}}}}}, {"name": "StatefulPartitionedCall/strided_slice_8/stack", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "2"}]}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/strided_slice_8/stack_1", "op": "Const", "attr": {"dtype": {"type": "DT_INT32"}, "value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "2"}]}}}}}, {"name": "StatefulPartitionedCall/strided_slice_8/stack_2", "op": "Const", "attr": {"dtype": {"type": "DT_INT32"}, "value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "2"}]}}}}}, {"name": "StatefulPartitionedCall/Reshape_9/shape", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "1"}]}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/floordiv_1/y", "op": "Const", "attr": {"dtype": {"type": "DT_INT32"}, "value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {}}}}}, {"name": "StatefulPartitionedCall/mul_3/y", "op": "Const", "attr": {"dtype": {"type": "DT_INT32"}, "value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {}}}}}, {"name": "StatefulPartitionedCall/strided_slice_9/stack", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "2"}]}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/strided_slice_9/stack_1", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "2"}]}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/strided_slice_9/stack_2", "op": "Const", "attr": {"dtype": {"type": "DT_INT32"}, "value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "2"}]}}}}}, {"name": "StatefulPartitionedCall/Reshape_10/shape", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "1"}]}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/Reshape_11/shape", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "4"}]}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/ExpandDims_9/dim", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/Tile_8/multiples", "op": "Const", "attr": {"dtype": {"type": "DT_INT32"}, "value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "5"}]}}}}}, {"name": "StatefulPartitionedCall/kpt_offset_0/separable_conv2d_8/separable_conv2d/ReadVariableOp", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "3"}, {"size": "3"}, {"size": "24"}, {"size": "1"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/kpt_offset_0/separable_conv2d_8/separable_conv2d/ReadVariableOp_1", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "1"}, {"size": "1"}, {"size": "24"}, {"size": "96"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/kpt_offset_0/separable_conv2d_8/BiasAdd/ReadVariableOp", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "96"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/kpt_offset_0/conv2d_9/Conv2D/ReadVariableOp", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "1"}, {"size": "1"}, {"size": "96"}, {"size": "34"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/kpt_offset_0/conv2d_9/BiasAdd/ReadVariableOp", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "34"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/strided_slice_6/stack", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "2"}]}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/strided_slice_6/stack_1", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "2"}]}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/strided_slice_6/stack_2", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "2"}]}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/Reshape_17", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "1700"}]}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/Reshape_18/shape", "op": "Const", "attr": {"dtype": {"type": "DT_INT32"}, "value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "1"}]}}}}}, {"name": "StatefulPartitionedCall/floordiv_6/y", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/floordiv_4/y", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/floordiv_5/y", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/mul_8/y", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/Reshape_19/shape", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "1"}]}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/Reshape_21/shape", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "4"}]}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/Reshape_22", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "1700"}]}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/Reshape_23", "op": "Const", "attr": {"dtype": {"type": "DT_INT32"}, "value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "1700"}]}}}}}, {"name": "StatefulPartitionedCall/mul_7/x", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/kpt_heatmap_0/separable_conv2d_6/separable_conv2d/ReadVariableOp", "op": "Const", "attr": {"dtype": {"type": "DT_FLOAT"}, "value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "3"}, {"size": "3"}, {"size": "24"}, {"size": "1"}]}}}}}, {"name": "StatefulPartitionedCall/kpt_heatmap_0/separable_conv2d_6/separable_conv2d/ReadVariableOp_1", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "1"}, {"size": "1"}, {"size": "24"}, {"size": "96"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/kpt_heatmap_0/separable_conv2d_6/BiasAdd/ReadVariableOp", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "96"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/kpt_heatmap_0/conv2d_7/Conv2D/ReadVariableOp", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "1"}, {"size": "1"}, {"size": "96"}, {"size": "17"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/kpt_heatmap_0/conv2d_7/BiasAdd/ReadVariableOp", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "17"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/strided_slice_5/stack", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "2"}]}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/strided_slice_5/stack_1", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "2"}]}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/strided_slice_5/stack_2", "op": "Const", "attr": {"dtype": {"type": "DT_INT32"}, "value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "2"}]}}}}}, {"name": "StatefulPartitionedCall/Less_3/y", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/transpose/perm", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "4"}]}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/Reshape_14/shape", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "3"}]}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/TopKV2_1/k", "op": "Const", "attr": {"dtype": {"type": "DT_INT32"}, "value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {}}}}}, {"name": "StatefulPartitionedCall/strided_slice_11", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "1"}, {"size": "17"}, {"size": "1"}]}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/Reshape_16/shape", "op": "Const", "attr": {"dtype": {"type": "DT_INT32"}, "value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "2"}]}}}}}, {"name": "StatefulPartitionedCall/floordiv_7/y", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/mul_9/y", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/Reshape_24/shape", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "1"}]}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/Reshape_25/shape", "op": "Const", "attr": {"dtype": {"type": "DT_INT32"}, "value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "3"}]}}}}}, {"name": "StatefulPartitionedCall/Reshape_26/shape", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "4"}]}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/transpose_1/perm", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "4"}]}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/ExpandDims_10/dim", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/Tile_9/multiples", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "5"}]}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/Sum_2/reduction_indices", "op": "Const", "attr": {"dtype": {"type": "DT_INT32"}, "value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {}}}}}, {"name": "StatefulPartitionedCall/add_11/y", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/ArgMax/dimension", "op": "Const", "attr": {"dtype": {"type": "DT_INT32"}, "value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {}}}}}, {"name": "StatefulPartitionedCall/transpose_5/perm", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "3"}]}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/Reshape_31/shape", "op": "Const", "attr": {"dtype": {"type": "DT_INT32"}, "value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "1"}]}}}}}, {"name": "StatefulPartitionedCall/Reshape_33/shape", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "3"}]}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/transpose_7/perm", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "3"}]}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/zeros_like", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "1"}, {"size": "10"}, {"size": "17"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/zeros_like_1", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "1"}, {"size": "10"}, {"size": "17"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/Sum_5/reduction_indices", "op": "Const", "attr": {"dtype": {"type": "DT_INT32"}, "value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {}}}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/conv2d/Conv2D/ReadVariableOp", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "1"}, {"size": "1"}, {"size": "1280"}, {"size": "64"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/conv2d/BiasAdd/ReadVariableOp", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "64"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/up_sampling2d/mul", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "2"}]}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/conv2d_1/Conv2D/ReadVariableOp", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "1"}, {"size": "1"}, {"size": "64"}, {"size": "64"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/conv2d_1/BiasAdd/ReadVariableOp", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "64"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/separable_conv2d/separable_conv2d/ReadVariableOp", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "3"}, {"size": "3"}, {"size": "64"}, {"size": "1"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/up_sampling2d_1/mul", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "2"}]}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/conv2d_2/Conv2D/ReadVariableOp", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "1"}, {"size": "1"}, {"size": "32"}, {"size": "32"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/conv2d_2/BiasAdd/ReadVariableOp", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "32"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/separable_conv2d_1/separable_conv2d/ReadVariableOp", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "3"}, {"size": "3"}, {"size": "32"}, {"size": "1"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/up_sampling2d_2/mul", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "2"}]}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/ResizeImage/resize/ExpandDims/dim", "op": "Const", "attr": {"dtype": {"type": "DT_INT32"}, "value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {}}}}}, {"name": "StatefulPartitionedCall/Reshape", "op": "Const", "attr": {"dtype": {"type": "DT_FLOAT"}, "value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "1"}, {"size": "1"}, {"size": "1"}, {"size": "3"}]}}}}}, {"name": "StatefulPartitionedCall/truediv", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "1"}, {"size": "1"}, {"size": "1"}, {"size": "3"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/sub_1/y", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/conv2d_3/Conv2D/ReadVariableOp", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "1"}, {"size": "1"}, {"size": "24"}, {"size": "24"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/conv2d_3/BiasAdd/ReadVariableOp", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "24"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/separable_conv2d_2/separable_conv2d/ReadVariableOp", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "3"}, {"size": "3"}, {"size": "24"}, {"size": "1"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_0/separable_conv2d_3/separable_conv2d/ReadVariableOp", "op": "Const", "attr": {"dtype": {"type": "DT_FLOAT"}, "value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "3"}, {"size": "3"}, {"size": "24"}, {"size": "1"}]}}}}}, {"name": "StatefulPartitionedCall/center_0/separable_conv2d_3/separable_conv2d/ReadVariableOp_1", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "1"}, {"size": "1"}, {"size": "24"}, {"size": "96"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_0/separable_conv2d_3/BiasAdd/ReadVariableOp", "op": "Const", "attr": {"dtype": {"type": "DT_FLOAT"}, "value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "96"}]}}}}}, {"name": "StatefulPartitionedCall/center_0/conv2d_4/Conv2D/ReadVariableOp", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "1"}, {"size": "1"}, {"size": "96"}, {"size": "1"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_0/conv2d_4/BiasAdd/ReadVariableOp", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "1"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/Less_2/y", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/Reshape_2/shape", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "2"}]}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/TopKV2/k", "op": "Const", "attr": {"dtype": {"type": "DT_INT32"}, "value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {}}}}}, {"name": "StatefulPartitionedCall/strided_slice_23/stack", "op": "Const", "attr": {"dtype": {"type": "DT_INT32"}, "value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "3"}]}}}}}, {"name": "StatefulPartitionedCall/strided_slice_23/stack_1", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "3"}]}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/strided_slice_23/stack_2", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "3"}]}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/concat_3/axis", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "input", "op": "Placeholder", "attr": {"dtype": {"type": "DT_INT32"}, "shape": {"shape": {"dim": [{"size": "1"}, {"size": "320"}, {"size": "320"}, {"size": "3"}]}}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/Conv1/Conv2D_weights", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "3"}, {"size": "3"}, {"size": "3"}, {"size": "32"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/Conv1/Conv2D_bn_offset", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "32"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/expanded_conv_depthwise/depthwise_weights", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "3"}, {"size": "3"}, {"size": "32"}, {"size": "1"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/expanded_conv_depthwise/depthwise_bn_offset", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "32"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/expanded_conv_project/Conv2D_weights", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "1"}, {"size": "1"}, {"size": "32"}, {"size": "16"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/expanded_conv_project/Conv2D_bn_offset", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "16"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_1_expand/Conv2D_weights", "op": "Const", "attr": {"dtype": {"type": "DT_FLOAT"}, "value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "1"}, {"size": "1"}, {"size": "16"}, {"size": "96"}]}}}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_1_expand/Conv2D_bn_offset", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "96"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_1_depthwise/depthwise_weights", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "3"}, {"size": "3"}, {"size": "96"}, {"size": "1"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_1_depthwise/depthwise_bn_offset", "op": "Const", "attr": {"dtype": {"type": "DT_FLOAT"}, "value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "96"}]}}}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_1_project/Conv2D_weights", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "1"}, {"size": "1"}, {"size": "96"}, {"size": "24"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_1_project/Conv2D_bn_offset", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "24"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_2_expand/Conv2D_weights", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "1"}, {"size": "1"}, {"size": "24"}, {"size": "144"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_2_expand/Conv2D_bn_offset", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "144"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_2_depthwise/depthwise_weights", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "3"}, {"size": "3"}, {"size": "144"}, {"size": "1"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_2_depthwise/depthwise_bn_offset", "op": "Const", "attr": {"dtype": {"type": "DT_FLOAT"}, "value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "144"}]}}}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_2_project/Conv2D_weights", "op": "Const", "attr": {"dtype": {"type": "DT_FLOAT"}, "value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "1"}, {"size": "1"}, {"size": "144"}, {"size": "24"}]}}}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_2_project/Conv2D_bn_offset", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "24"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_3_expand/Conv2D_weights", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "1"}, {"size": "1"}, {"size": "24"}, {"size": "144"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_3_expand/Conv2D_bn_offset", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "144"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_3_depthwise/depthwise_weights", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "3"}, {"size": "3"}, {"size": "144"}, {"size": "1"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_3_depthwise/depthwise_bn_offset", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "144"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_3_project/Conv2D_weights", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "1"}, {"size": "1"}, {"size": "144"}, {"size": "32"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_3_project/Conv2D_bn_offset", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "32"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_4_expand/Conv2D_weights", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "1"}, {"size": "1"}, {"size": "32"}, {"size": "192"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_4_expand/Conv2D_bn_offset", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "192"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_4_depthwise/depthwise_weights", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "3"}, {"size": "3"}, {"size": "192"}, {"size": "1"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_4_depthwise/depthwise_bn_offset", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "192"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_4_project/Conv2D_weights", "op": "Const", "attr": {"dtype": {"type": "DT_FLOAT"}, "value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "1"}, {"size": "1"}, {"size": "192"}, {"size": "32"}]}}}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_4_project/Conv2D_bn_offset", "op": "Const", "attr": {"dtype": {"type": "DT_FLOAT"}, "value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "32"}]}}}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_5_expand/Conv2D_weights", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "1"}, {"size": "1"}, {"size": "32"}, {"size": "192"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_5_expand/Conv2D_bn_offset", "op": "Const", "attr": {"dtype": {"type": "DT_FLOAT"}, "value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "192"}]}}}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_5_depthwise/depthwise_weights", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "3"}, {"size": "3"}, {"size": "192"}, {"size": "1"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_5_depthwise/depthwise_bn_offset", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "192"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_5_project/Conv2D_weights", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "1"}, {"size": "1"}, {"size": "192"}, {"size": "32"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_5_project/Conv2D_bn_offset", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "32"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_6_expand/Conv2D_weights", "op": "Const", "attr": {"dtype": {"type": "DT_FLOAT"}, "value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "1"}, {"size": "1"}, {"size": "32"}, {"size": "192"}]}}}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_6_expand/Conv2D_bn_offset", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "192"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_6_depthwise/depthwise_weights", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "3"}, {"size": "3"}, {"size": "192"}, {"size": "1"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_6_depthwise/depthwise_bn_offset", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "192"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_6_project/Conv2D_weights", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "1"}, {"size": "1"}, {"size": "192"}, {"size": "64"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_6_project/Conv2D_bn_offset", "op": "Const", "attr": {"dtype": {"type": "DT_FLOAT"}, "value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "64"}]}}}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_7_expand/Conv2D_weights", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "1"}, {"size": "1"}, {"size": "64"}, {"size": "384"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_7_expand/Conv2D_bn_offset", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "384"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_7_depthwise/depthwise_weights", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "3"}, {"size": "3"}, {"size": "384"}, {"size": "1"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_7_depthwise/depthwise_bn_offset", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "384"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_7_project/Conv2D_weights", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "1"}, {"size": "1"}, {"size": "384"}, {"size": "64"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_7_project/Conv2D_bn_offset", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "64"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_8_expand/Conv2D_weights", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "1"}, {"size": "1"}, {"size": "64"}, {"size": "384"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_8_expand/Conv2D_bn_offset", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "384"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_8_depthwise/depthwise_weights", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "3"}, {"size": "3"}, {"size": "384"}, {"size": "1"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_8_depthwise/depthwise_bn_offset", "op": "Const", "attr": {"dtype": {"type": "DT_FLOAT"}, "value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "384"}]}}}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_8_project/Conv2D_weights", "op": "Const", "attr": {"dtype": {"type": "DT_FLOAT"}, "value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "1"}, {"size": "1"}, {"size": "384"}, {"size": "64"}]}}}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_8_project/Conv2D_bn_offset", "op": "Const", "attr": {"dtype": {"type": "DT_FLOAT"}, "value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "64"}]}}}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_9_expand/Conv2D_weights", "op": "Const", "attr": {"dtype": {"type": "DT_FLOAT"}, "value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "1"}, {"size": "1"}, {"size": "64"}, {"size": "384"}]}}}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_9_expand/Conv2D_bn_offset", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "384"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_9_depthwise/depthwise_weights", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "3"}, {"size": "3"}, {"size": "384"}, {"size": "1"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_9_depthwise/depthwise_bn_offset", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "384"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_9_project/Conv2D_weights", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "1"}, {"size": "1"}, {"size": "384"}, {"size": "64"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_9_project/Conv2D_bn_offset", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "64"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_10_expand/Conv2D_weights", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "1"}, {"size": "1"}, {"size": "64"}, {"size": "384"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_10_expand/Conv2D_bn_offset", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "384"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_10_depthwise/depthwise_weights", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "3"}, {"size": "3"}, {"size": "384"}, {"size": "1"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_10_depthwise/depthwise_bn_offset", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "384"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_10_project/Conv2D_weights", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "1"}, {"size": "1"}, {"size": "384"}, {"size": "96"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_10_project/Conv2D_bn_offset", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "96"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_11_expand/Conv2D_weights", "op": "Const", "attr": {"dtype": {"type": "DT_FLOAT"}, "value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "1"}, {"size": "1"}, {"size": "96"}, {"size": "576"}]}}}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_11_expand/Conv2D_bn_offset", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "576"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_11_depthwise/depthwise_weights", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "3"}, {"size": "3"}, {"size": "576"}, {"size": "1"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_11_depthwise/depthwise_bn_offset", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "576"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_11_project/Conv2D_weights", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "1"}, {"size": "1"}, {"size": "576"}, {"size": "96"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_11_project/Conv2D_bn_offset", "op": "Const", "attr": {"dtype": {"type": "DT_FLOAT"}, "value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "96"}]}}}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_12_expand/Conv2D_weights", "op": "Const", "attr": {"dtype": {"type": "DT_FLOAT"}, "value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "1"}, {"size": "1"}, {"size": "96"}, {"size": "576"}]}}}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_12_expand/Conv2D_bn_offset", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "576"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_12_depthwise/depthwise_weights", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "3"}, {"size": "3"}, {"size": "576"}, {"size": "1"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_12_depthwise/depthwise_bn_offset", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "576"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_12_project/Conv2D_weights", "op": "Const", "attr": {"dtype": {"type": "DT_FLOAT"}, "value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "1"}, {"size": "1"}, {"size": "576"}, {"size": "96"}]}}}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_12_project/Conv2D_bn_offset", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "96"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_13_expand/Conv2D_weights", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "1"}, {"size": "1"}, {"size": "96"}, {"size": "576"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_13_expand/Conv2D_bn_offset", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "576"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_13_depthwise/depthwise_weights", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "3"}, {"size": "3"}, {"size": "576"}, {"size": "1"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_13_depthwise/depthwise_bn_offset", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "576"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_13_project/Conv2D_weights", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "1"}, {"size": "1"}, {"size": "576"}, {"size": "160"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_13_project/Conv2D_bn_offset", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "160"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_14_expand/Conv2D_weights", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "1"}, {"size": "1"}, {"size": "160"}, {"size": "960"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_14_expand/Conv2D_bn_offset", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "960"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_14_depthwise/depthwise_weights", "op": "Const", "attr": {"dtype": {"type": "DT_FLOAT"}, "value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "3"}, {"size": "3"}, {"size": "960"}, {"size": "1"}]}}}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_14_depthwise/depthwise_bn_offset", "op": "Const", "attr": {"dtype": {"type": "DT_FLOAT"}, "value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "960"}]}}}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_14_project/Conv2D_weights", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "1"}, {"size": "1"}, {"size": "960"}, {"size": "160"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_14_project/Conv2D_bn_offset", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "160"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_15_expand/Conv2D_weights", "op": "Const", "attr": {"dtype": {"type": "DT_FLOAT"}, "value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "1"}, {"size": "1"}, {"size": "160"}, {"size": "960"}]}}}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_15_expand/Conv2D_bn_offset", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "960"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_15_depthwise/depthwise_weights", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "3"}, {"size": "3"}, {"size": "960"}, {"size": "1"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_15_depthwise/depthwise_bn_offset", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "960"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_15_project/Conv2D_weights", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "1"}, {"size": "1"}, {"size": "960"}, {"size": "160"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_15_project/Conv2D_bn_offset", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "160"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_16_expand/Conv2D_weights", "op": "Const", "attr": {"dtype": {"type": "DT_FLOAT"}, "value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "1"}, {"size": "1"}, {"size": "160"}, {"size": "960"}]}}}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_16_expand/Conv2D_bn_offset", "op": "Const", "attr": {"dtype": {"type": "DT_FLOAT"}, "value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "960"}]}}}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_16_depthwise/depthwise_weights", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "3"}, {"size": "3"}, {"size": "960"}, {"size": "1"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_16_depthwise/depthwise_bn_offset", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "960"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_16_project/Conv2D_weights", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "1"}, {"size": "1"}, {"size": "960"}, {"size": "320"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_16_project/Conv2D_bn_offset", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "320"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/Conv_1/Conv2D_weights", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "1"}, {"size": "1"}, {"size": "320"}, {"size": "1280"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/Conv_1/Conv2D_bn_offset", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "1280"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/separable_conv2d/separable_conv2d_weights", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "1"}, {"size": "1"}, {"size": "64"}, {"size": "32"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/separable_conv2d/separable_conv2d_bn_offset", "op": "Const", "attr": {"dtype": {"type": "DT_FLOAT"}, "value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "32"}]}}}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/separable_conv2d_1/separable_conv2d_weights", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "1"}, {"size": "1"}, {"size": "32"}, {"size": "24"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/separable_conv2d_1/separable_conv2d_bn_offset", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "24"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/separable_conv2d_2/separable_conv2d_weights", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "1"}, {"size": "1"}, {"size": "24"}, {"size": "24"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/separable_conv2d_2/separable_conv2d_bn_offset", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "24"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/map/TensorArrayV2_2", "op": "TensorListReserve", "input": ["StatefulPartitionedCall/map/TensorArrayV2_2/element_shape", "StatefulPartitionedCall/map/TensorArrayV2_2/num_elements"], "attr": {"shape_type": {"type": "DT_INT32"}, "element_dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/map/TensorArrayUnstack_1/TensorListFromTensor", "op": "TensorListFromTensor", "input": ["StatefulPartitionedCall/Tile_16", "StatefulPartitionedCall/map/TensorArrayUnstack_1/TensorListFromTensor/element_shape"], "attr": {"shape_type": {"type": "DT_INT32"}, "element_dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/Cast", "op": "Cast", "input": ["input"], "attr": {"Truncate": {"b": false}, "DstT": {"type": "DT_FLOAT"}, "SrcT": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/unstack", "op": "Unpack", "input": ["StatefulPartitionedCall/Cast"], "attr": {"T": {"type": "DT_FLOAT"}, "num": {"i": "1"}, "axis": {"i": "0"}}}, {"name": "StatefulPartitionedCall/ResizeImage/resize/ExpandDims", "op": "ExpandDims", "input": ["StatefulPartitionedCall/unstack", "StatefulPartitionedCall/ResizeImage/resize/ExpandDims/dim"], "attr": {"Tdim": {"type": "DT_INT32"}, "T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/ResizeImage/resize/Squeeze", "op": "Squeeze", "input": ["StatefulPartitionedCall/ResizeImage/resize/ExpandDims"], "attr": {"T": {"type": "DT_FLOAT"}, "squeeze_dims": {"list": {"i": ["0"]}}}}, {"name": "ConstantFolding/StatefulPartitionedCall/stack_const_axis", "op": "Const", "input": ["^StatefulPartitionedCall/ResizeImage/resize/Squeeze"], "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/stack", "op": "ExpandDims", "input": ["StatefulPartitionedCall/ResizeImage/resize/Squeeze", "ConstantFolding/StatefulPartitionedCall/stack_const_axis"], "attr": {"Tdim": {"type": "DT_INT32"}, "T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/sub", "op": "Sub", "input": ["StatefulPartitionedCall/stack", "StatefulPartitionedCall/Reshape"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/truediv_1", "op": "Mul", "input": ["StatefulPartitionedCall/sub", "StatefulPartitionedCall/truediv"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/sub_1", "op": "Sub", "input": ["StatefulPartitionedCall/truediv_1", "StatefulPartitionedCall/sub_1/y"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/Conv1_relu/Relu6", "op": "_FusedConv2D", "input": ["StatefulPartitionedCall/sub_1", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/Conv1/Conv2D_weights", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/Conv1/Conv2D_bn_offset"], "device": "/device:CPU:0", "attr": {"fused_ops": {"list": {"s": ["Qmlhc0FkZA==", "UmVsdTY="]}}, "dilations": {"list": {"i": ["1", "1", "1", "1"]}}, "T": {"type": "DT_FLOAT"}, "strides": {"list": {"i": ["1", "2", "2", "1"]}}, "data_format": {"s": "TkhXQw=="}, "explicit_paddings": {"list": {}}, "use_cudnn_on_gpu": {"b": true}, "num_args": {"i": "1"}, "epsilon": {"f": 0.0}, "padding": {"s": "U0FNRQ=="}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/expanded_conv_depthwise/depthwise", "op": "FusedDepthwiseConv2dNative", "input": ["StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/Conv1_relu/Relu6", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/expanded_conv_depthwise/depthwise_weights", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/expanded_conv_depthwise/depthwise_bn_offset"], "attr": {"T": {"type": "DT_FLOAT"}, "data_format": {"s": "TkhXQw=="}, "strides": {"list": {"i": ["1", "1", "1", "1"]}}, "explicit_paddings": {"list": {}}, "num_args": {"i": "1"}, "padding": {"s": "U0FNRQ=="}, "fused_ops": {"list": {"s": ["Qmlhc0FkZA==", "UmVsdTY="]}}, "dilations": {"list": {"i": ["1", "1", "1", "1"]}}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/expanded_conv_project_BN/FusedBatchNormV3", "op": "_FusedConv2D", "input": ["StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/expanded_conv_depthwise/depthwise", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/expanded_conv_project/Conv2D_weights", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/expanded_conv_project/Conv2D_bn_offset"], "device": "/device:CPU:0", "attr": {"T": {"type": "DT_FLOAT"}, "data_format": {"s": "TkhXQw=="}, "strides": {"list": {"i": ["1", "1", "1", "1"]}}, "explicit_paddings": {"list": {}}, "use_cudnn_on_gpu": {"b": true}, "num_args": {"i": "1"}, "epsilon": {"f": 0.0}, "padding": {"s": "U0FNRQ=="}, "fused_ops": {"list": {"s": ["Qmlhc0FkZA=="]}}, "dilations": {"list": {"i": ["1", "1", "1", "1"]}}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_1_expand_relu/Relu6", "op": "_FusedConv2D", "input": ["StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/expanded_conv_project_BN/FusedBatchNormV3", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_1_expand/Conv2D_weights", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_1_expand/Conv2D_bn_offset"], "device": "/device:CPU:0", "attr": {"dilations": {"list": {"i": ["1", "1", "1", "1"]}}, "T": {"type": "DT_FLOAT"}, "strides": {"list": {"i": ["1", "1", "1", "1"]}}, "data_format": {"s": "TkhXQw=="}, "use_cudnn_on_gpu": {"b": true}, "explicit_paddings": {"list": {}}, "num_args": {"i": "1"}, "epsilon": {"f": 0.0}, "padding": {"s": "U0FNRQ=="}, "fused_ops": {"list": {"s": ["Qmlhc0FkZA==", "UmVsdTY="]}}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_1_depthwise/depthwise", "op": "FusedDepthwiseConv2dNative", "input": ["StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_1_expand_relu/Relu6", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_1_depthwise/depthwise_weights", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_1_depthwise/depthwise_bn_offset"], "attr": {"dilations": {"list": {"i": ["1", "1", "1", "1"]}}, "T": {"type": "DT_FLOAT"}, "data_format": {"s": "TkhXQw=="}, "strides": {"list": {"i": ["1", "2", "2", "1"]}}, "explicit_paddings": {"list": {}}, "num_args": {"i": "1"}, "padding": {"s": "U0FNRQ=="}, "fused_ops": {"list": {"s": ["Qmlhc0FkZA==", "UmVsdTY="]}}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_1_project_BN/FusedBatchNormV3", "op": "_FusedConv2D", "input": ["StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_1_depthwise/depthwise", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_1_project/Conv2D_weights", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_1_project/Conv2D_bn_offset"], "device": "/device:CPU:0", "attr": {"epsilon": {"f": 0.0}, "padding": {"s": "U0FNRQ=="}, "fused_ops": {"list": {"s": ["Qmlhc0FkZA=="]}}, "dilations": {"list": {"i": ["1", "1", "1", "1"]}}, "T": {"type": "DT_FLOAT"}, "data_format": {"s": "TkhXQw=="}, "strides": {"list": {"i": ["1", "1", "1", "1"]}}, "use_cudnn_on_gpu": {"b": true}, "explicit_paddings": {"list": {}}, "num_args": {"i": "1"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_2_expand_relu/Relu6", "op": "_FusedConv2D", "input": ["StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_1_project_BN/FusedBatchNormV3", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_2_expand/Conv2D_weights", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_2_expand/Conv2D_bn_offset"], "device": "/device:CPU:0", "attr": {"T": {"type": "DT_FLOAT"}, "data_format": {"s": "TkhXQw=="}, "strides": {"list": {"i": ["1", "1", "1", "1"]}}, "use_cudnn_on_gpu": {"b": true}, "explicit_paddings": {"list": {}}, "num_args": {"i": "1"}, "epsilon": {"f": 0.0}, "padding": {"s": "U0FNRQ=="}, "fused_ops": {"list": {"s": ["Qmlhc0FkZA==", "UmVsdTY="]}}, "dilations": {"list": {"i": ["1", "1", "1", "1"]}}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_2_depthwise/depthwise", "op": "FusedDepthwiseConv2dNative", "input": ["StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_2_expand_relu/Relu6", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_2_depthwise/depthwise_weights", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_2_depthwise/depthwise_bn_offset"], "attr": {"padding": {"s": "U0FNRQ=="}, "fused_ops": {"list": {"s": ["Qmlhc0FkZA==", "UmVsdTY="]}}, "dilations": {"list": {"i": ["1", "1", "1", "1"]}}, "T": {"type": "DT_FLOAT"}, "data_format": {"s": "TkhXQw=="}, "strides": {"list": {"i": ["1", "1", "1", "1"]}}, "explicit_paddings": {"list": {}}, "num_args": {"i": "1"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_2_project_BN/FusedBatchNormV3", "op": "_FusedConv2D", "input": ["StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_2_depthwise/depthwise", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_2_project/Conv2D_weights", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_2_project/Conv2D_bn_offset"], "device": "/device:CPU:0", "attr": {"num_args": {"i": "1"}, "epsilon": {"f": 0.0}, "padding": {"s": "U0FNRQ=="}, "fused_ops": {"list": {"s": ["Qmlhc0FkZA=="]}}, "dilations": {"list": {"i": ["1", "1", "1", "1"]}}, "T": {"type": "DT_FLOAT"}, "strides": {"list": {"i": ["1", "1", "1", "1"]}}, "data_format": {"s": "TkhXQw=="}, "explicit_paddings": {"list": {}}, "use_cudnn_on_gpu": {"b": true}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_2_add/add", "op": "AddV2", "input": ["StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_1_project_BN/FusedBatchNormV3", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_2_project_BN/FusedBatchNormV3"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/conv2d_3/BiasAdd", "op": "_FusedConv2D", "input": ["StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_2_add/add", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/conv2d_3/Conv2D/ReadVariableOp", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/conv2d_3/BiasAdd/ReadVariableOp"], "device": "/device:CPU:0", "attr": {"dilations": {"list": {"i": ["1", "1", "1", "1"]}}, "T": {"type": "DT_FLOAT"}, "strides": {"list": {"i": ["1", "1", "1", "1"]}}, "data_format": {"s": "TkhXQw=="}, "explicit_paddings": {"list": {}}, "use_cudnn_on_gpu": {"b": true}, "num_args": {"i": "1"}, "epsilon": {"f": 0.0}, "padding": {"s": "U0FNRQ=="}, "fused_ops": {"list": {"s": ["Qmlhc0FkZA=="]}}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_3_expand_relu/Relu6", "op": "_FusedConv2D", "input": ["StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_2_add/add", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_3_expand/Conv2D_weights", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_3_expand/Conv2D_bn_offset"], "device": "/device:CPU:0", "attr": {"strides": {"list": {"i": ["1", "1", "1", "1"]}}, "data_format": {"s": "TkhXQw=="}, "explicit_paddings": {"list": {}}, "use_cudnn_on_gpu": {"b": true}, "num_args": {"i": "1"}, "epsilon": {"f": 0.0}, "padding": {"s": "U0FNRQ=="}, "fused_ops": {"list": {"s": ["Qmlhc0FkZA==", "UmVsdTY="]}}, "dilations": {"list": {"i": ["1", "1", "1", "1"]}}, "T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_3_depthwise/depthwise", "op": "FusedDepthwiseConv2dNative", "input": ["StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_3_expand_relu/Relu6", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_3_depthwise/depthwise_weights", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_3_depthwise/depthwise_bn_offset"], "attr": {"T": {"type": "DT_FLOAT"}, "strides": {"list": {"i": ["1", "2", "2", "1"]}}, "data_format": {"s": "TkhXQw=="}, "explicit_paddings": {"list": {}}, "num_args": {"i": "1"}, "padding": {"s": "U0FNRQ=="}, "fused_ops": {"list": {"s": ["Qmlhc0FkZA==", "UmVsdTY="]}}, "dilations": {"list": {"i": ["1", "1", "1", "1"]}}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_3_project_BN/FusedBatchNormV3", "op": "_FusedConv2D", "input": ["StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_3_depthwise/depthwise", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_3_project/Conv2D_weights", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_3_project/Conv2D_bn_offset"], "device": "/device:CPU:0", "attr": {"dilations": {"list": {"i": ["1", "1", "1", "1"]}}, "T": {"type": "DT_FLOAT"}, "strides": {"list": {"i": ["1", "1", "1", "1"]}}, "data_format": {"s": "TkhXQw=="}, "use_cudnn_on_gpu": {"b": true}, "explicit_paddings": {"list": {}}, "num_args": {"i": "1"}, "epsilon": {"f": 0.0}, "padding": {"s": "U0FNRQ=="}, "fused_ops": {"list": {"s": ["Qmlhc0FkZA=="]}}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_4_expand_relu/Relu6", "op": "_FusedConv2D", "input": ["StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_3_project_BN/FusedBatchNormV3", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_4_expand/Conv2D_weights", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_4_expand/Conv2D_bn_offset"], "device": "/device:CPU:0", "attr": {"data_format": {"s": "TkhXQw=="}, "strides": {"list": {"i": ["1", "1", "1", "1"]}}, "use_cudnn_on_gpu": {"b": true}, "explicit_paddings": {"list": {}}, "num_args": {"i": "1"}, "epsilon": {"f": 0.0}, "padding": {"s": "U0FNRQ=="}, "fused_ops": {"list": {"s": ["Qmlhc0FkZA==", "UmVsdTY="]}}, "dilations": {"list": {"i": ["1", "1", "1", "1"]}}, "T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_4_depthwise/depthwise", "op": "FusedDepthwiseConv2dNative", "input": ["StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_4_expand_relu/Relu6", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_4_depthwise/depthwise_weights", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_4_depthwise/depthwise_bn_offset"], "attr": {"num_args": {"i": "1"}, "padding": {"s": "U0FNRQ=="}, "fused_ops": {"list": {"s": ["Qmlhc0FkZA==", "UmVsdTY="]}}, "dilations": {"list": {"i": ["1", "1", "1", "1"]}}, "T": {"type": "DT_FLOAT"}, "data_format": {"s": "TkhXQw=="}, "strides": {"list": {"i": ["1", "1", "1", "1"]}}, "explicit_paddings": {"list": {}}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_4_project_BN/FusedBatchNormV3", "op": "_FusedConv2D", "input": ["StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_4_depthwise/depthwise", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_4_project/Conv2D_weights", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_4_project/Conv2D_bn_offset"], "device": "/device:CPU:0", "attr": {"num_args": {"i": "1"}, "epsilon": {"f": 0.0}, "padding": {"s": "U0FNRQ=="}, "fused_ops": {"list": {"s": ["Qmlhc0FkZA=="]}}, "dilations": {"list": {"i": ["1", "1", "1", "1"]}}, "T": {"type": "DT_FLOAT"}, "data_format": {"s": "TkhXQw=="}, "strides": {"list": {"i": ["1", "1", "1", "1"]}}, "use_cudnn_on_gpu": {"b": true}, "explicit_paddings": {"list": {}}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_4_add/add", "op": "AddV2", "input": ["StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_3_project_BN/FusedBatchNormV3", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_4_project_BN/FusedBatchNormV3"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_5_expand_relu/Relu6", "op": "_FusedConv2D", "input": ["StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_4_add/add", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_5_expand/Conv2D_weights", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_5_expand/Conv2D_bn_offset"], "device": "/device:CPU:0", "attr": {"epsilon": {"f": 0.0}, "padding": {"s": "U0FNRQ=="}, "fused_ops": {"list": {"s": ["Qmlhc0FkZA==", "UmVsdTY="]}}, "dilations": {"list": {"i": ["1", "1", "1", "1"]}}, "T": {"type": "DT_FLOAT"}, "strides": {"list": {"i": ["1", "1", "1", "1"]}}, "data_format": {"s": "TkhXQw=="}, "explicit_paddings": {"list": {}}, "use_cudnn_on_gpu": {"b": true}, "num_args": {"i": "1"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_5_depthwise/depthwise", "op": "FusedDepthwiseConv2dNative", "input": ["StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_5_expand_relu/Relu6", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_5_depthwise/depthwise_weights", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_5_depthwise/depthwise_bn_offset"], "attr": {"dilations": {"list": {"i": ["1", "1", "1", "1"]}}, "T": {"type": "DT_FLOAT"}, "strides": {"list": {"i": ["1", "1", "1", "1"]}}, "data_format": {"s": "TkhXQw=="}, "explicit_paddings": {"list": {}}, "num_args": {"i": "1"}, "padding": {"s": "U0FNRQ=="}, "fused_ops": {"list": {"s": ["Qmlhc0FkZA==", "UmVsdTY="]}}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_5_project_BN/FusedBatchNormV3", "op": "_FusedConv2D", "input": ["StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_5_depthwise/depthwise", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_5_project/Conv2D_weights", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_5_project/Conv2D_bn_offset"], "device": "/device:CPU:0", "attr": {"dilations": {"list": {"i": ["1", "1", "1", "1"]}}, "T": {"type": "DT_FLOAT"}, "data_format": {"s": "TkhXQw=="}, "strides": {"list": {"i": ["1", "1", "1", "1"]}}, "explicit_paddings": {"list": {}}, "use_cudnn_on_gpu": {"b": true}, "num_args": {"i": "1"}, "epsilon": {"f": 0.0}, "padding": {"s": "U0FNRQ=="}, "fused_ops": {"list": {"s": ["Qmlhc0FkZA=="]}}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_5_add/add", "op": "AddV2", "input": ["StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_4_add/add", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_5_project_BN/FusedBatchNormV3"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/conv2d_2/BiasAdd", "op": "_FusedConv2D", "input": ["StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_5_add/add", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/conv2d_2/Conv2D/ReadVariableOp", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/conv2d_2/BiasAdd/ReadVariableOp"], "device": "/device:CPU:0", "attr": {"dilations": {"list": {"i": ["1", "1", "1", "1"]}}, "T": {"type": "DT_FLOAT"}, "data_format": {"s": "TkhXQw=="}, "strides": {"list": {"i": ["1", "1", "1", "1"]}}, "explicit_paddings": {"list": {}}, "use_cudnn_on_gpu": {"b": true}, "num_args": {"i": "1"}, "epsilon": {"f": 0.0}, "padding": {"s": "U0FNRQ=="}, "fused_ops": {"list": {"s": ["Qmlhc0FkZA=="]}}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_6_expand_relu/Relu6", "op": "_FusedConv2D", "input": ["StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_5_add/add", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_6_expand/Conv2D_weights", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_6_expand/Conv2D_bn_offset"], "device": "/device:CPU:0", "attr": {"dilations": {"list": {"i": ["1", "1", "1", "1"]}}, "T": {"type": "DT_FLOAT"}, "data_format": {"s": "TkhXQw=="}, "strides": {"list": {"i": ["1", "1", "1", "1"]}}, "explicit_paddings": {"list": {}}, "use_cudnn_on_gpu": {"b": true}, "num_args": {"i": "1"}, "epsilon": {"f": 0.0}, "padding": {"s": "U0FNRQ=="}, "fused_ops": {"list": {"s": ["Qmlhc0FkZA==", "UmVsdTY="]}}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_6_depthwise/depthwise", "op": "FusedDepthwiseConv2dNative", "input": ["StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_6_expand_relu/Relu6", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_6_depthwise/depthwise_weights", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_6_depthwise/depthwise_bn_offset"], "attr": {"data_format": {"s": "TkhXQw=="}, "strides": {"list": {"i": ["1", "2", "2", "1"]}}, "explicit_paddings": {"list": {}}, "num_args": {"i": "1"}, "padding": {"s": "U0FNRQ=="}, "fused_ops": {"list": {"s": ["Qmlhc0FkZA==", "UmVsdTY="]}}, "dilations": {"list": {"i": ["1", "1", "1", "1"]}}, "T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_6_project_BN/FusedBatchNormV3", "op": "_FusedConv2D", "input": ["StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_6_depthwise/depthwise", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_6_project/Conv2D_weights", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_6_project/Conv2D_bn_offset"], "device": "/device:CPU:0", "attr": {"data_format": {"s": "TkhXQw=="}, "strides": {"list": {"i": ["1", "1", "1", "1"]}}, "explicit_paddings": {"list": {}}, "use_cudnn_on_gpu": {"b": true}, "num_args": {"i": "1"}, "epsilon": {"f": 0.0}, "padding": {"s": "U0FNRQ=="}, "fused_ops": {"list": {"s": ["Qmlhc0FkZA=="]}}, "dilations": {"list": {"i": ["1", "1", "1", "1"]}}, "T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_7_expand_relu/Relu6", "op": "_FusedConv2D", "input": ["StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_6_project_BN/FusedBatchNormV3", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_7_expand/Conv2D_weights", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_7_expand/Conv2D_bn_offset"], "device": "/device:CPU:0", "attr": {"num_args": {"i": "1"}, "epsilon": {"f": 0.0}, "padding": {"s": "U0FNRQ=="}, "fused_ops": {"list": {"s": ["Qmlhc0FkZA==", "UmVsdTY="]}}, "dilations": {"list": {"i": ["1", "1", "1", "1"]}}, "T": {"type": "DT_FLOAT"}, "data_format": {"s": "TkhXQw=="}, "strides": {"list": {"i": ["1", "1", "1", "1"]}}, "use_cudnn_on_gpu": {"b": true}, "explicit_paddings": {"list": {}}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_7_depthwise/depthwise", "op": "FusedDepthwiseConv2dNative", "input": ["StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_7_expand_relu/Relu6", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_7_depthwise/depthwise_weights", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_7_depthwise/depthwise_bn_offset"], "attr": {"dilations": {"list": {"i": ["1", "1", "1", "1"]}}, "T": {"type": "DT_FLOAT"}, "data_format": {"s": "TkhXQw=="}, "strides": {"list": {"i": ["1", "1", "1", "1"]}}, "explicit_paddings": {"list": {}}, "num_args": {"i": "1"}, "padding": {"s": "U0FNRQ=="}, "fused_ops": {"list": {"s": ["Qmlhc0FkZA==", "UmVsdTY="]}}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_7_project_BN/FusedBatchNormV3", "op": "_FusedConv2D", "input": ["StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_7_depthwise/depthwise", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_7_project/Conv2D_weights", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_7_project/Conv2D_bn_offset"], "device": "/device:CPU:0", "attr": {"dilations": {"list": {"i": ["1", "1", "1", "1"]}}, "T": {"type": "DT_FLOAT"}, "strides": {"list": {"i": ["1", "1", "1", "1"]}}, "data_format": {"s": "TkhXQw=="}, "explicit_paddings": {"list": {}}, "use_cudnn_on_gpu": {"b": true}, "num_args": {"i": "1"}, "epsilon": {"f": 0.0}, "padding": {"s": "U0FNRQ=="}, "fused_ops": {"list": {"s": ["Qmlhc0FkZA=="]}}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_7_add/add", "op": "AddV2", "input": ["StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_6_project_BN/FusedBatchNormV3", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_7_project_BN/FusedBatchNormV3"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_8_expand_relu/Relu6", "op": "_FusedConv2D", "input": ["StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_7_add/add", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_8_expand/Conv2D_weights", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_8_expand/Conv2D_bn_offset"], "device": "/device:CPU:0", "attr": {"T": {"type": "DT_FLOAT"}, "strides": {"list": {"i": ["1", "1", "1", "1"]}}, "data_format": {"s": "TkhXQw=="}, "use_cudnn_on_gpu": {"b": true}, "explicit_paddings": {"list": {}}, "num_args": {"i": "1"}, "epsilon": {"f": 0.0}, "padding": {"s": "U0FNRQ=="}, "fused_ops": {"list": {"s": ["Qmlhc0FkZA==", "UmVsdTY="]}}, "dilations": {"list": {"i": ["1", "1", "1", "1"]}}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_8_depthwise/depthwise", "op": "FusedDepthwiseConv2dNative", "input": ["StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_8_expand_relu/Relu6", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_8_depthwise/depthwise_weights", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_8_depthwise/depthwise_bn_offset"], "attr": {"T": {"type": "DT_FLOAT"}, "data_format": {"s": "TkhXQw=="}, "strides": {"list": {"i": ["1", "1", "1", "1"]}}, "explicit_paddings": {"list": {}}, "num_args": {"i": "1"}, "padding": {"s": "U0FNRQ=="}, "fused_ops": {"list": {"s": ["Qmlhc0FkZA==", "UmVsdTY="]}}, "dilations": {"list": {"i": ["1", "1", "1", "1"]}}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_8_project_BN/FusedBatchNormV3", "op": "_FusedConv2D", "input": ["StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_8_depthwise/depthwise", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_8_project/Conv2D_weights", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_8_project/Conv2D_bn_offset"], "device": "/device:CPU:0", "attr": {"dilations": {"list": {"i": ["1", "1", "1", "1"]}}, "T": {"type": "DT_FLOAT"}, "data_format": {"s": "TkhXQw=="}, "strides": {"list": {"i": ["1", "1", "1", "1"]}}, "explicit_paddings": {"list": {}}, "use_cudnn_on_gpu": {"b": true}, "num_args": {"i": "1"}, "epsilon": {"f": 0.0}, "padding": {"s": "U0FNRQ=="}, "fused_ops": {"list": {"s": ["Qmlhc0FkZA=="]}}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_8_add/add", "op": "AddV2", "input": ["StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_7_add/add", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_8_project_BN/FusedBatchNormV3"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_9_expand_relu/Relu6", "op": "_FusedConv2D", "input": ["StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_8_add/add", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_9_expand/Conv2D_weights", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_9_expand/Conv2D_bn_offset"], "device": "/device:CPU:0", "attr": {"data_format": {"s": "TkhXQw=="}, "strides": {"list": {"i": ["1", "1", "1", "1"]}}, "explicit_paddings": {"list": {}}, "use_cudnn_on_gpu": {"b": true}, "num_args": {"i": "1"}, "epsilon": {"f": 0.0}, "padding": {"s": "U0FNRQ=="}, "fused_ops": {"list": {"s": ["Qmlhc0FkZA==", "UmVsdTY="]}}, "dilations": {"list": {"i": ["1", "1", "1", "1"]}}, "T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_9_depthwise/depthwise", "op": "FusedDepthwiseConv2dNative", "input": ["StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_9_expand_relu/Relu6", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_9_depthwise/depthwise_weights", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_9_depthwise/depthwise_bn_offset"], "attr": {"fused_ops": {"list": {"s": ["Qmlhc0FkZA==", "UmVsdTY="]}}, "dilations": {"list": {"i": ["1", "1", "1", "1"]}}, "T": {"type": "DT_FLOAT"}, "strides": {"list": {"i": ["1", "1", "1", "1"]}}, "data_format": {"s": "TkhXQw=="}, "explicit_paddings": {"list": {}}, "num_args": {"i": "1"}, "padding": {"s": "U0FNRQ=="}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_9_project_BN/FusedBatchNormV3", "op": "_FusedConv2D", "input": ["StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_9_depthwise/depthwise", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_9_project/Conv2D_weights", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_9_project/Conv2D_bn_offset"], "device": "/device:CPU:0", "attr": {"dilations": {"list": {"i": ["1", "1", "1", "1"]}}, "T": {"type": "DT_FLOAT"}, "strides": {"list": {"i": ["1", "1", "1", "1"]}}, "data_format": {"s": "TkhXQw=="}, "explicit_paddings": {"list": {}}, "use_cudnn_on_gpu": {"b": true}, "num_args": {"i": "1"}, "epsilon": {"f": 0.0}, "padding": {"s": "U0FNRQ=="}, "fused_ops": {"list": {"s": ["Qmlhc0FkZA=="]}}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_9_add/add", "op": "AddV2", "input": ["StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_8_add/add", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_9_project_BN/FusedBatchNormV3"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/conv2d_1/BiasAdd", "op": "_FusedConv2D", "input": ["StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_9_add/add", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/conv2d_1/Conv2D/ReadVariableOp", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/conv2d_1/BiasAdd/ReadVariableOp"], "device": "/device:CPU:0", "attr": {"fused_ops": {"list": {"s": ["Qmlhc0FkZA=="]}}, "dilations": {"list": {"i": ["1", "1", "1", "1"]}}, "T": {"type": "DT_FLOAT"}, "data_format": {"s": "TkhXQw=="}, "strides": {"list": {"i": ["1", "1", "1", "1"]}}, "use_cudnn_on_gpu": {"b": true}, "explicit_paddings": {"list": {}}, "num_args": {"i": "1"}, "epsilon": {"f": 0.0}, "padding": {"s": "U0FNRQ=="}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_10_expand_relu/Relu6", "op": "_FusedConv2D", "input": ["StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_9_add/add", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_10_expand/Conv2D_weights", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_10_expand/Conv2D_bn_offset"], "device": "/device:CPU:0", "attr": {"num_args": {"i": "1"}, "epsilon": {"f": 0.0}, "padding": {"s": "U0FNRQ=="}, "fused_ops": {"list": {"s": ["Qmlhc0FkZA==", "UmVsdTY="]}}, "dilations": {"list": {"i": ["1", "1", "1", "1"]}}, "T": {"type": "DT_FLOAT"}, "data_format": {"s": "TkhXQw=="}, "strides": {"list": {"i": ["1", "1", "1", "1"]}}, "use_cudnn_on_gpu": {"b": true}, "explicit_paddings": {"list": {}}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_10_depthwise/depthwise", "op": "FusedDepthwiseConv2dNative", "input": ["StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_10_expand_relu/Relu6", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_10_depthwise/depthwise_weights", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_10_depthwise/depthwise_bn_offset"], "attr": {"dilations": {"list": {"i": ["1", "1", "1", "1"]}}, "T": {"type": "DT_FLOAT"}, "data_format": {"s": "TkhXQw=="}, "strides": {"list": {"i": ["1", "1", "1", "1"]}}, "explicit_paddings": {"list": {}}, "num_args": {"i": "1"}, "padding": {"s": "U0FNRQ=="}, "fused_ops": {"list": {"s": ["Qmlhc0FkZA==", "UmVsdTY="]}}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_10_project_BN/FusedBatchNormV3", "op": "_FusedConv2D", "input": ["StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_10_depthwise/depthwise", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_10_project/Conv2D_weights", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_10_project/Conv2D_bn_offset"], "device": "/device:CPU:0", "attr": {"fused_ops": {"list": {"s": ["Qmlhc0FkZA=="]}}, "dilations": {"list": {"i": ["1", "1", "1", "1"]}}, "T": {"type": "DT_FLOAT"}, "strides": {"list": {"i": ["1", "1", "1", "1"]}}, "data_format": {"s": "TkhXQw=="}, "use_cudnn_on_gpu": {"b": true}, "explicit_paddings": {"list": {}}, "num_args": {"i": "1"}, "epsilon": {"f": 0.0}, "padding": {"s": "U0FNRQ=="}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_11_expand_relu/Relu6", "op": "_FusedConv2D", "input": ["StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_10_project_BN/FusedBatchNormV3", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_11_expand/Conv2D_weights", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_11_expand/Conv2D_bn_offset"], "device": "/device:CPU:0", "attr": {"dilations": {"list": {"i": ["1", "1", "1", "1"]}}, "T": {"type": "DT_FLOAT"}, "strides": {"list": {"i": ["1", "1", "1", "1"]}}, "data_format": {"s": "TkhXQw=="}, "use_cudnn_on_gpu": {"b": true}, "explicit_paddings": {"list": {}}, "num_args": {"i": "1"}, "epsilon": {"f": 0.0}, "padding": {"s": "U0FNRQ=="}, "fused_ops": {"list": {"s": ["Qmlhc0FkZA==", "UmVsdTY="]}}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_11_depthwise/depthwise", "op": "FusedDepthwiseConv2dNative", "input": ["StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_11_expand_relu/Relu6", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_11_depthwise/depthwise_weights", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_11_depthwise/depthwise_bn_offset"], "attr": {"num_args": {"i": "1"}, "padding": {"s": "U0FNRQ=="}, "fused_ops": {"list": {"s": ["Qmlhc0FkZA==", "UmVsdTY="]}}, "dilations": {"list": {"i": ["1", "1", "1", "1"]}}, "T": {"type": "DT_FLOAT"}, "strides": {"list": {"i": ["1", "1", "1", "1"]}}, "data_format": {"s": "TkhXQw=="}, "explicit_paddings": {"list": {}}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_11_project_BN/FusedBatchNormV3", "op": "_FusedConv2D", "input": ["StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_11_depthwise/depthwise", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_11_project/Conv2D_weights", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_11_project/Conv2D_bn_offset"], "device": "/device:CPU:0", "attr": {"dilations": {"list": {"i": ["1", "1", "1", "1"]}}, "T": {"type": "DT_FLOAT"}, "strides": {"list": {"i": ["1", "1", "1", "1"]}}, "data_format": {"s": "TkhXQw=="}, "use_cudnn_on_gpu": {"b": true}, "explicit_paddings": {"list": {}}, "num_args": {"i": "1"}, "epsilon": {"f": 0.0}, "padding": {"s": "U0FNRQ=="}, "fused_ops": {"list": {"s": ["Qmlhc0FkZA=="]}}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_11_add/add", "op": "AddV2", "input": ["StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_10_project_BN/FusedBatchNormV3", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_11_project_BN/FusedBatchNormV3"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_12_expand_relu/Relu6", "op": "_FusedConv2D", "input": ["StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_11_add/add", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_12_expand/Conv2D_weights", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_12_expand/Conv2D_bn_offset"], "device": "/device:CPU:0", "attr": {"dilations": {"list": {"i": ["1", "1", "1", "1"]}}, "T": {"type": "DT_FLOAT"}, "data_format": {"s": "TkhXQw=="}, "strides": {"list": {"i": ["1", "1", "1", "1"]}}, "explicit_paddings": {"list": {}}, "use_cudnn_on_gpu": {"b": true}, "num_args": {"i": "1"}, "epsilon": {"f": 0.0}, "padding": {"s": "U0FNRQ=="}, "fused_ops": {"list": {"s": ["Qmlhc0FkZA==", "UmVsdTY="]}}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_12_depthwise/depthwise", "op": "FusedDepthwiseConv2dNative", "input": ["StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_12_expand_relu/Relu6", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_12_depthwise/depthwise_weights", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_12_depthwise/depthwise_bn_offset"], "attr": {"dilations": {"list": {"i": ["1", "1", "1", "1"]}}, "T": {"type": "DT_FLOAT"}, "data_format": {"s": "TkhXQw=="}, "strides": {"list": {"i": ["1", "1", "1", "1"]}}, "explicit_paddings": {"list": {}}, "num_args": {"i": "1"}, "padding": {"s": "U0FNRQ=="}, "fused_ops": {"list": {"s": ["Qmlhc0FkZA==", "UmVsdTY="]}}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_12_project_BN/FusedBatchNormV3", "op": "_FusedConv2D", "input": ["StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_12_depthwise/depthwise", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_12_project/Conv2D_weights", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_12_project/Conv2D_bn_offset"], "device": "/device:CPU:0", "attr": {"T": {"type": "DT_FLOAT"}, "data_format": {"s": "TkhXQw=="}, "strides": {"list": {"i": ["1", "1", "1", "1"]}}, "use_cudnn_on_gpu": {"b": true}, "explicit_paddings": {"list": {}}, "num_args": {"i": "1"}, "epsilon": {"f": 0.0}, "padding": {"s": "U0FNRQ=="}, "fused_ops": {"list": {"s": ["Qmlhc0FkZA=="]}}, "dilations": {"list": {"i": ["1", "1", "1", "1"]}}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_12_add/add", "op": "AddV2", "input": ["StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_11_add/add", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_12_project_BN/FusedBatchNormV3"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_13_expand_relu/Relu6", "op": "_FusedConv2D", "input": ["StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_12_add/add", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_13_expand/Conv2D_weights", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_13_expand/Conv2D_bn_offset"], "device": "/device:CPU:0", "attr": {"T": {"type": "DT_FLOAT"}, "data_format": {"s": "TkhXQw=="}, "strides": {"list": {"i": ["1", "1", "1", "1"]}}, "explicit_paddings": {"list": {}}, "use_cudnn_on_gpu": {"b": true}, "num_args": {"i": "1"}, "epsilon": {"f": 0.0}, "padding": {"s": "U0FNRQ=="}, "fused_ops": {"list": {"s": ["Qmlhc0FkZA==", "UmVsdTY="]}}, "dilations": {"list": {"i": ["1", "1", "1", "1"]}}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_13_depthwise/depthwise", "op": "FusedDepthwiseConv2dNative", "input": ["StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_13_expand_relu/Relu6", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_13_depthwise/depthwise_weights", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_13_depthwise/depthwise_bn_offset"], "attr": {"dilations": {"list": {"i": ["1", "1", "1", "1"]}}, "T": {"type": "DT_FLOAT"}, "strides": {"list": {"i": ["1", "2", "2", "1"]}}, "data_format": {"s": "TkhXQw=="}, "explicit_paddings": {"list": {}}, "num_args": {"i": "1"}, "padding": {"s": "U0FNRQ=="}, "fused_ops": {"list": {"s": ["Qmlhc0FkZA==", "UmVsdTY="]}}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_13_project_BN/FusedBatchNormV3", "op": "_FusedConv2D", "input": ["StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_13_depthwise/depthwise", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_13_project/Conv2D_weights", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_13_project/Conv2D_bn_offset"], "device": "/device:CPU:0", "attr": {"T": {"type": "DT_FLOAT"}, "data_format": {"s": "TkhXQw=="}, "strides": {"list": {"i": ["1", "1", "1", "1"]}}, "use_cudnn_on_gpu": {"b": true}, "explicit_paddings": {"list": {}}, "num_args": {"i": "1"}, "epsilon": {"f": 0.0}, "padding": {"s": "U0FNRQ=="}, "fused_ops": {"list": {"s": ["Qmlhc0FkZA=="]}}, "dilations": {"list": {"i": ["1", "1", "1", "1"]}}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_14_expand_relu/Relu6", "op": "_FusedConv2D", "input": ["StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_13_project_BN/FusedBatchNormV3", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_14_expand/Conv2D_weights", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_14_expand/Conv2D_bn_offset"], "device": "/device:CPU:0", "attr": {"T": {"type": "DT_FLOAT"}, "strides": {"list": {"i": ["1", "1", "1", "1"]}}, "data_format": {"s": "TkhXQw=="}, "explicit_paddings": {"list": {}}, "use_cudnn_on_gpu": {"b": true}, "num_args": {"i": "1"}, "epsilon": {"f": 0.0}, "padding": {"s": "U0FNRQ=="}, "fused_ops": {"list": {"s": ["Qmlhc0FkZA==", "UmVsdTY="]}}, "dilations": {"list": {"i": ["1", "1", "1", "1"]}}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_14_depthwise/depthwise", "op": "FusedDepthwiseConv2dNative", "input": ["StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_14_expand_relu/Relu6", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_14_depthwise/depthwise_weights", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_14_depthwise/depthwise_bn_offset"], "attr": {"dilations": {"list": {"i": ["1", "1", "1", "1"]}}, "T": {"type": "DT_FLOAT"}, "strides": {"list": {"i": ["1", "1", "1", "1"]}}, "data_format": {"s": "TkhXQw=="}, "explicit_paddings": {"list": {}}, "num_args": {"i": "1"}, "padding": {"s": "U0FNRQ=="}, "fused_ops": {"list": {"s": ["Qmlhc0FkZA==", "UmVsdTY="]}}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_14_project_BN/FusedBatchNormV3", "op": "_FusedConv2D", "input": ["StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_14_depthwise/depthwise", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_14_project/Conv2D_weights", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_14_project/Conv2D_bn_offset"], "device": "/device:CPU:0", "attr": {"fused_ops": {"list": {"s": ["Qmlhc0FkZA=="]}}, "dilations": {"list": {"i": ["1", "1", "1", "1"]}}, "T": {"type": "DT_FLOAT"}, "strides": {"list": {"i": ["1", "1", "1", "1"]}}, "data_format": {"s": "TkhXQw=="}, "explicit_paddings": {"list": {}}, "use_cudnn_on_gpu": {"b": true}, "num_args": {"i": "1"}, "epsilon": {"f": 0.0}, "padding": {"s": "U0FNRQ=="}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_14_add/add", "op": "AddV2", "input": ["StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_13_project_BN/FusedBatchNormV3", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_14_project_BN/FusedBatchNormV3"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_15_expand_relu/Relu6", "op": "_FusedConv2D", "input": ["StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_14_add/add", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_15_expand/Conv2D_weights", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_15_expand/Conv2D_bn_offset"], "device": "/device:CPU:0", "attr": {"T": {"type": "DT_FLOAT"}, "data_format": {"s": "TkhXQw=="}, "strides": {"list": {"i": ["1", "1", "1", "1"]}}, "explicit_paddings": {"list": {}}, "use_cudnn_on_gpu": {"b": true}, "num_args": {"i": "1"}, "epsilon": {"f": 0.0}, "padding": {"s": "U0FNRQ=="}, "fused_ops": {"list": {"s": ["Qmlhc0FkZA==", "UmVsdTY="]}}, "dilations": {"list": {"i": ["1", "1", "1", "1"]}}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_15_depthwise/depthwise", "op": "FusedDepthwiseConv2dNative", "input": ["StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_15_expand_relu/Relu6", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_15_depthwise/depthwise_weights", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_15_depthwise/depthwise_bn_offset"], "attr": {"num_args": {"i": "1"}, "padding": {"s": "U0FNRQ=="}, "fused_ops": {"list": {"s": ["Qmlhc0FkZA==", "UmVsdTY="]}}, "dilations": {"list": {"i": ["1", "1", "1", "1"]}}, "T": {"type": "DT_FLOAT"}, "data_format": {"s": "TkhXQw=="}, "strides": {"list": {"i": ["1", "1", "1", "1"]}}, "explicit_paddings": {"list": {}}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_15_project_BN/FusedBatchNormV3", "op": "_FusedConv2D", "input": ["StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_15_depthwise/depthwise", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_15_project/Conv2D_weights", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_15_project/Conv2D_bn_offset"], "device": "/device:CPU:0", "attr": {"dilations": {"list": {"i": ["1", "1", "1", "1"]}}, "T": {"type": "DT_FLOAT"}, "strides": {"list": {"i": ["1", "1", "1", "1"]}}, "data_format": {"s": "TkhXQw=="}, "explicit_paddings": {"list": {}}, "use_cudnn_on_gpu": {"b": true}, "num_args": {"i": "1"}, "epsilon": {"f": 0.0}, "padding": {"s": "U0FNRQ=="}, "fused_ops": {"list": {"s": ["Qmlhc0FkZA=="]}}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_15_add/add", "op": "AddV2", "input": ["StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_14_add/add", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_15_project_BN/FusedBatchNormV3"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_16_expand_relu/Relu6", "op": "_FusedConv2D", "input": ["StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_15_add/add", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_16_expand/Conv2D_weights", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_16_expand/Conv2D_bn_offset"], "device": "/device:CPU:0", "attr": {"dilations": {"list": {"i": ["1", "1", "1", "1"]}}, "T": {"type": "DT_FLOAT"}, "strides": {"list": {"i": ["1", "1", "1", "1"]}}, "data_format": {"s": "TkhXQw=="}, "use_cudnn_on_gpu": {"b": true}, "explicit_paddings": {"list": {}}, "num_args": {"i": "1"}, "epsilon": {"f": 0.0}, "padding": {"s": "U0FNRQ=="}, "fused_ops": {"list": {"s": ["Qmlhc0FkZA==", "UmVsdTY="]}}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_16_depthwise/depthwise", "op": "FusedDepthwiseConv2dNative", "input": ["StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_16_expand_relu/Relu6", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_16_depthwise/depthwise_weights", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_16_depthwise/depthwise_bn_offset"], "attr": {"num_args": {"i": "1"}, "padding": {"s": "U0FNRQ=="}, "fused_ops": {"list": {"s": ["Qmlhc0FkZA==", "UmVsdTY="]}}, "dilations": {"list": {"i": ["1", "1", "1", "1"]}}, "T": {"type": "DT_FLOAT"}, "strides": {"list": {"i": ["1", "1", "1", "1"]}}, "data_format": {"s": "TkhXQw=="}, "explicit_paddings": {"list": {}}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_16_project_BN/FusedBatchNormV3", "op": "_FusedConv2D", "input": ["StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_16_depthwise/depthwise", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_16_project/Conv2D_weights", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_16_project/Conv2D_bn_offset"], "device": "/device:CPU:0", "attr": {"data_format": {"s": "TkhXQw=="}, "strides": {"list": {"i": ["1", "1", "1", "1"]}}, "use_cudnn_on_gpu": {"b": true}, "explicit_paddings": {"list": {}}, "num_args": {"i": "1"}, "epsilon": {"f": 0.0}, "padding": {"s": "U0FNRQ=="}, "fused_ops": {"list": {"s": ["Qmlhc0FkZA=="]}}, "dilations": {"list": {"i": ["1", "1", "1", "1"]}}, "T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/out_relu/Relu6", "op": "_FusedConv2D", "input": ["StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_16_project_BN/FusedBatchNormV3", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/Conv_1/Conv2D_weights", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/Conv_1/Conv2D_bn_offset"], "device": "/device:CPU:0", "attr": {"T": {"type": "DT_FLOAT"}, "strides": {"list": {"i": ["1", "1", "1", "1"]}}, "data_format": {"s": "TkhXQw=="}, "use_cudnn_on_gpu": {"b": true}, "explicit_paddings": {"list": {}}, "num_args": {"i": "1"}, "epsilon": {"f": 0.0}, "padding": {"s": "U0FNRQ=="}, "fused_ops": {"list": {"s": ["Qmlhc0FkZA==", "UmVsdTY="]}}, "dilations": {"list": {"i": ["1", "1", "1", "1"]}}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/conv2d/BiasAdd", "op": "_FusedConv2D", "input": ["StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/out_relu/Relu6", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/conv2d/Conv2D/ReadVariableOp", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/conv2d/BiasAdd/ReadVariableOp"], "device": "/device:CPU:0", "attr": {"dilations": {"list": {"i": ["1", "1", "1", "1"]}}, "T": {"type": "DT_FLOAT"}, "data_format": {"s": "TkhXQw=="}, "strides": {"list": {"i": ["1", "1", "1", "1"]}}, "explicit_paddings": {"list": {}}, "use_cudnn_on_gpu": {"b": true}, "num_args": {"i": "1"}, "epsilon": {"f": 0.0}, "padding": {"s": "U0FNRQ=="}, "fused_ops": {"list": {"s": ["Qmlhc0FkZA=="]}}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/up_sampling2d/resize/ResizeNearestNeighbor", "op": "ResizeNearestNeighbor", "input": ["StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/conv2d/BiasAdd", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/up_sampling2d/mul"], "attr": {"align_corners": {"b": false}, "half_pixel_centers": {"b": true}, "T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/tf.__operators__.add/AddV2", "op": "AddV2", "input": ["StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/up_sampling2d/resize/ResizeNearestNeighbor", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/conv2d_1/BiasAdd"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/separable_conv2d/separable_conv2d/depthwise", "op": "DepthwiseConv2dNative", "input": ["StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/tf.__operators__.add/AddV2", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/separable_conv2d/separable_conv2d/ReadVariableOp"], "attr": {"padding": {"s": "U0FNRQ=="}, "dilations": {"list": {"i": ["1", "1", "1", "1"]}}, "T": {"type": "DT_FLOAT"}, "data_format": {"s": "TkhXQw=="}, "strides": {"list": {"i": ["1", "1", "1", "1"]}}, "explicit_paddings": {"list": {}}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/re_lu/Relu", "op": "_FusedConv2D", "input": ["StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/separable_conv2d/separable_conv2d/depthwise", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/separable_conv2d/separable_conv2d_weights", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/separable_conv2d/separable_conv2d_bn_offset"], "device": "/device:CPU:0", "attr": {"epsilon": {"f": 0.0}, "padding": {"s": "VkFMSUQ="}, "fused_ops": {"list": {"s": ["Qmlhc0FkZA==", "UmVsdQ=="]}}, "dilations": {"list": {"i": ["1", "1", "1", "1"]}}, "T": {"type": "DT_FLOAT"}, "strides": {"list": {"i": ["1", "1", "1", "1"]}}, "data_format": {"s": "TkhXQw=="}, "explicit_paddings": {"list": {}}, "use_cudnn_on_gpu": {"b": true}, "num_args": {"i": "1"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/up_sampling2d_1/resize/ResizeNearestNeighbor", "op": "ResizeNearestNeighbor", "input": ["StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/re_lu/Relu", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/up_sampling2d_1/mul"], "attr": {"align_corners": {"b": false}, "half_pixel_centers": {"b": true}, "T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/tf.__operators__.add_1/AddV2", "op": "AddV2", "input": ["StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/up_sampling2d_1/resize/ResizeNearestNeighbor", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/conv2d_2/BiasAdd"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/separable_conv2d_1/separable_conv2d/depthwise", "op": "DepthwiseConv2dNative", "input": ["StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/tf.__operators__.add_1/AddV2", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/separable_conv2d_1/separable_conv2d/ReadVariableOp"], "attr": {"dilations": {"list": {"i": ["1", "1", "1", "1"]}}, "T": {"type": "DT_FLOAT"}, "data_format": {"s": "TkhXQw=="}, "strides": {"list": {"i": ["1", "1", "1", "1"]}}, "explicit_paddings": {"list": {}}, "padding": {"s": "U0FNRQ=="}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/re_lu_1/Relu", "op": "_FusedConv2D", "input": ["StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/separable_conv2d_1/separable_conv2d/depthwise", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/separable_conv2d_1/separable_conv2d_weights", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/separable_conv2d_1/separable_conv2d_bn_offset"], "device": "/device:CPU:0", "attr": {"num_args": {"i": "1"}, "epsilon": {"f": 0.0}, "padding": {"s": "VkFMSUQ="}, "fused_ops": {"list": {"s": ["Qmlhc0FkZA==", "UmVsdQ=="]}}, "dilations": {"list": {"i": ["1", "1", "1", "1"]}}, "T": {"type": "DT_FLOAT"}, "strides": {"list": {"i": ["1", "1", "1", "1"]}}, "data_format": {"s": "TkhXQw=="}, "use_cudnn_on_gpu": {"b": true}, "explicit_paddings": {"list": {}}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/up_sampling2d_2/resize/ResizeNearestNeighbor", "op": "ResizeNearestNeighbor", "input": ["StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/re_lu_1/Relu", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/up_sampling2d_2/mul"], "attr": {"T": {"type": "DT_FLOAT"}, "align_corners": {"b": false}, "half_pixel_centers": {"b": true}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/tf.__operators__.add_2/AddV2", "op": "AddV2", "input": ["StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/up_sampling2d_2/resize/ResizeNearestNeighbor", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/conv2d_3/BiasAdd"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/separable_conv2d_2/separable_conv2d/depthwise", "op": "DepthwiseConv2dNative", "input": ["StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/tf.__operators__.add_2/AddV2", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/separable_conv2d_2/separable_conv2d/ReadVariableOp"], "attr": {"dilations": {"list": {"i": ["1", "1", "1", "1"]}}, "T": {"type": "DT_FLOAT"}, "data_format": {"s": "TkhXQw=="}, "strides": {"list": {"i": ["1", "1", "1", "1"]}}, "explicit_paddings": {"list": {}}, "padding": {"s": "U0FNRQ=="}}}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/re_lu_2/Relu", "op": "_FusedConv2D", "input": ["StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/separable_conv2d_2/separable_conv2d/depthwise", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/separable_conv2d_2/separable_conv2d_weights", "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/separable_conv2d_2/separable_conv2d_bn_offset"], "device": "/device:CPU:0", "attr": {"dilations": {"list": {"i": ["1", "1", "1", "1"]}}, "T": {"type": "DT_FLOAT"}, "strides": {"list": {"i": ["1", "1", "1", "1"]}}, "data_format": {"s": "TkhXQw=="}, "use_cudnn_on_gpu": {"b": true}, "explicit_paddings": {"list": {}}, "num_args": {"i": "1"}, "epsilon": {"f": 0.0}, "padding": {"s": "VkFMSUQ="}, "fused_ops": {"list": {"s": ["Qmlhc0FkZA==", "UmVsdQ=="]}}}}, {"name": "StatefulPartitionedCall/box_offset_0/separable_conv2d_5/separable_conv2d/depthwise", "op": "DepthwiseConv2dNative", "input": ["StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/re_lu_2/Relu", "StatefulPartitionedCall/box_offset_0/separable_conv2d_5/separable_conv2d/ReadVariableOp"], "attr": {"dilations": {"list": {"i": ["1", "1", "1", "1"]}}, "T": {"type": "DT_FLOAT"}, "data_format": {"s": "TkhXQw=="}, "strides": {"list": {"i": ["1", "1", "1", "1"]}}, "explicit_paddings": {"list": {}}, "padding": {"s": "U0FNRQ=="}}}, {"name": "StatefulPartitionedCall/box_scale_0/separable_conv2d_4/separable_conv2d/depthwise", "op": "DepthwiseConv2dNative", "input": ["StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/re_lu_2/Relu", "StatefulPartitionedCall/box_scale_0/separable_conv2d_4/separable_conv2d/ReadVariableOp"], "attr": {"padding": {"s": "U0FNRQ=="}, "dilations": {"list": {"i": ["1", "1", "1", "1"]}}, "T": {"type": "DT_FLOAT"}, "data_format": {"s": "TkhXQw=="}, "strides": {"list": {"i": ["1", "1", "1", "1"]}}, "explicit_paddings": {"list": {}}}}, {"name": "StatefulPartitionedCall/kpt_regress_0/separable_conv2d_7/separable_conv2d/depthwise", "op": "DepthwiseConv2dNative", "input": ["StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/re_lu_2/Relu", "StatefulPartitionedCall/kpt_regress_0/separable_conv2d_7/separable_conv2d/ReadVariableOp"], "attr": {"dilations": {"list": {"i": ["1", "1", "1", "1"]}}, "T": {"type": "DT_FLOAT"}, "data_format": {"s": "TkhXQw=="}, "strides": {"list": {"i": ["1", "1", "1", "1"]}}, "explicit_paddings": {"list": {}}, "padding": {"s": "U0FNRQ=="}}}, {"name": "StatefulPartitionedCall/kpt_offset_0/separable_conv2d_8/separable_conv2d/depthwise", "op": "DepthwiseConv2dNative", "input": ["StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/re_lu_2/Relu", "StatefulPartitionedCall/kpt_offset_0/separable_conv2d_8/separable_conv2d/ReadVariableOp"], "attr": {"dilations": {"list": {"i": ["1", "1", "1", "1"]}}, "T": {"type": "DT_FLOAT"}, "data_format": {"s": "TkhXQw=="}, "strides": {"list": {"i": ["1", "1", "1", "1"]}}, "explicit_paddings": {"list": {}}, "padding": {"s": "U0FNRQ=="}}}, {"name": "StatefulPartitionedCall/kpt_heatmap_0/separable_conv2d_6/separable_conv2d/depthwise", "op": "DepthwiseConv2dNative", "input": ["StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/re_lu_2/Relu", "StatefulPartitionedCall/kpt_heatmap_0/separable_conv2d_6/separable_conv2d/ReadVariableOp"], "attr": {"dilations": {"list": {"i": ["1", "1", "1", "1"]}}, "T": {"type": "DT_FLOAT"}, "data_format": {"s": "TkhXQw=="}, "strides": {"list": {"i": ["1", "1", "1", "1"]}}, "explicit_paddings": {"list": {}}, "padding": {"s": "U0FNRQ=="}}}, {"name": "StatefulPartitionedCall/center_0/separable_conv2d_3/separable_conv2d/depthwise", "op": "DepthwiseConv2dNative", "input": ["StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/re_lu_2/Relu", "StatefulPartitionedCall/center_0/separable_conv2d_3/separable_conv2d/ReadVariableOp"], "attr": {"dilations": {"list": {"i": ["1", "1", "1", "1"]}}, "T": {"type": "DT_FLOAT"}, "data_format": {"s": "TkhXQw=="}, "strides": {"list": {"i": ["1", "1", "1", "1"]}}, "explicit_paddings": {"list": {}}, "padding": {"s": "U0FNRQ=="}}}, {"name": "StatefulPartitionedCall/box_offset_0/re_lu_5/Relu", "op": "_FusedConv2D", "input": ["StatefulPartitionedCall/box_offset_0/separable_conv2d_5/separable_conv2d/depthwise", "StatefulPartitionedCall/box_offset_0/separable_conv2d_5/separable_conv2d/ReadVariableOp_1", "StatefulPartitionedCall/box_offset_0/separable_conv2d_5/BiasAdd/ReadVariableOp"], "device": "/device:CPU:0", "attr": {"epsilon": {"f": 0.0}, "padding": {"s": "VkFMSUQ="}, "fused_ops": {"list": {"s": ["Qmlhc0FkZA==", "UmVsdQ=="]}}, "dilations": {"list": {"i": ["1", "1", "1", "1"]}}, "T": {"type": "DT_FLOAT"}, "strides": {"list": {"i": ["1", "1", "1", "1"]}}, "data_format": {"s": "TkhXQw=="}, "explicit_paddings": {"list": {}}, "use_cudnn_on_gpu": {"b": true}, "num_args": {"i": "1"}}}, {"name": "StatefulPartitionedCall/box_scale_0/re_lu_4/Relu", "op": "_FusedConv2D", "input": ["StatefulPartitionedCall/box_scale_0/separable_conv2d_4/separable_conv2d/depthwise", "StatefulPartitionedCall/box_scale_0/separable_conv2d_4/separable_conv2d/ReadVariableOp_1", "StatefulPartitionedCall/box_scale_0/separable_conv2d_4/BiasAdd/ReadVariableOp"], "device": "/device:CPU:0", "attr": {"fused_ops": {"list": {"s": ["Qmlhc0FkZA==", "UmVsdQ=="]}}, "dilations": {"list": {"i": ["1", "1", "1", "1"]}}, "T": {"type": "DT_FLOAT"}, "strides": {"list": {"i": ["1", "1", "1", "1"]}}, "data_format": {"s": "TkhXQw=="}, "use_cudnn_on_gpu": {"b": true}, "explicit_paddings": {"list": {}}, "num_args": {"i": "1"}, "epsilon": {"f": 0.0}, "padding": {"s": "VkFMSUQ="}}}, {"name": "StatefulPartitionedCall/kpt_regress_0/re_lu_7/Relu", "op": "_FusedConv2D", "input": ["StatefulPartitionedCall/kpt_regress_0/separable_conv2d_7/separable_conv2d/depthwise", "StatefulPartitionedCall/kpt_regress_0/separable_conv2d_7/separable_conv2d/ReadVariableOp_1", "StatefulPartitionedCall/kpt_regress_0/separable_conv2d_7/BiasAdd/ReadVariableOp"], "device": "/device:CPU:0", "attr": {"dilations": {"list": {"i": ["1", "1", "1", "1"]}}, "T": {"type": "DT_FLOAT"}, "strides": {"list": {"i": ["1", "1", "1", "1"]}}, "data_format": {"s": "TkhXQw=="}, "use_cudnn_on_gpu": {"b": true}, "explicit_paddings": {"list": {}}, "num_args": {"i": "1"}, "epsilon": {"f": 0.0}, "padding": {"s": "VkFMSUQ="}, "fused_ops": {"list": {"s": ["Qmlhc0FkZA==", "UmVsdQ=="]}}}}, {"name": "StatefulPartitionedCall/kpt_offset_0/re_lu_8/Relu", "op": "_FusedConv2D", "input": ["StatefulPartitionedCall/kpt_offset_0/separable_conv2d_8/separable_conv2d/depthwise", "StatefulPartitionedCall/kpt_offset_0/separable_conv2d_8/separable_conv2d/ReadVariableOp_1", "StatefulPartitionedCall/kpt_offset_0/separable_conv2d_8/BiasAdd/ReadVariableOp"], "device": "/device:CPU:0", "attr": {"fused_ops": {"list": {"s": ["Qmlhc0FkZA==", "UmVsdQ=="]}}, "dilations": {"list": {"i": ["1", "1", "1", "1"]}}, "T": {"type": "DT_FLOAT"}, "data_format": {"s": "TkhXQw=="}, "strides": {"list": {"i": ["1", "1", "1", "1"]}}, "explicit_paddings": {"list": {}}, "use_cudnn_on_gpu": {"b": true}, "num_args": {"i": "1"}, "epsilon": {"f": 0.0}, "padding": {"s": "VkFMSUQ="}}}, {"name": "StatefulPartitionedCall/kpt_heatmap_0/re_lu_6/Relu", "op": "_FusedConv2D", "input": ["StatefulPartitionedCall/kpt_heatmap_0/separable_conv2d_6/separable_conv2d/depthwise", "StatefulPartitionedCall/kpt_heatmap_0/separable_conv2d_6/separable_conv2d/ReadVariableOp_1", "StatefulPartitionedCall/kpt_heatmap_0/separable_conv2d_6/BiasAdd/ReadVariableOp"], "device": "/device:CPU:0", "attr": {"dilations": {"list": {"i": ["1", "1", "1", "1"]}}, "T": {"type": "DT_FLOAT"}, "strides": {"list": {"i": ["1", "1", "1", "1"]}}, "data_format": {"s": "TkhXQw=="}, "use_cudnn_on_gpu": {"b": true}, "explicit_paddings": {"list": {}}, "num_args": {"i": "1"}, "epsilon": {"f": 0.0}, "padding": {"s": "VkFMSUQ="}, "fused_ops": {"list": {"s": ["Qmlhc0FkZA==", "UmVsdQ=="]}}}}, {"name": "StatefulPartitionedCall/center_0/re_lu_3/Relu", "op": "_FusedConv2D", "input": ["StatefulPartitionedCall/center_0/separable_conv2d_3/separable_conv2d/depthwise", "StatefulPartitionedCall/center_0/separable_conv2d_3/separable_conv2d/ReadVariableOp_1", "StatefulPartitionedCall/center_0/separable_conv2d_3/BiasAdd/ReadVariableOp"], "device": "/device:CPU:0", "attr": {"dilations": {"list": {"i": ["1", "1", "1", "1"]}}, "T": {"type": "DT_FLOAT"}, "strides": {"list": {"i": ["1", "1", "1", "1"]}}, "data_format": {"s": "TkhXQw=="}, "use_cudnn_on_gpu": {"b": true}, "explicit_paddings": {"list": {}}, "num_args": {"i": "1"}, "epsilon": {"f": 0.0}, "padding": {"s": "VkFMSUQ="}, "fused_ops": {"list": {"s": ["Qmlhc0FkZA==", "UmVsdQ=="]}}}}, {"name": "StatefulPartitionedCall/box_offset_0/conv2d_6/BiasAdd", "op": "_FusedConv2D", "input": ["StatefulPartitionedCall/box_offset_0/re_lu_5/Relu", "StatefulPartitionedCall/box_offset_0/conv2d_6/Conv2D/ReadVariableOp", "StatefulPartitionedCall/box_offset_0/conv2d_6/BiasAdd/ReadVariableOp"], "device": "/device:CPU:0", "attr": {"dilations": {"list": {"i": ["1", "1", "1", "1"]}}, "T": {"type": "DT_FLOAT"}, "data_format": {"s": "TkhXQw=="}, "strides": {"list": {"i": ["1", "1", "1", "1"]}}, "explicit_paddings": {"list": {}}, "use_cudnn_on_gpu": {"b": true}, "num_args": {"i": "1"}, "epsilon": {"f": 0.0}, "padding": {"s": "VkFMSUQ="}, "fused_ops": {"list": {"s": ["Qmlhc0FkZA=="]}}}}, {"name": "StatefulPartitionedCall/box_scale_0/conv2d_5/BiasAdd", "op": "_FusedConv2D", "input": ["StatefulPartitionedCall/box_scale_0/re_lu_4/Relu", "StatefulPartitionedCall/box_scale_0/conv2d_5/Conv2D/ReadVariableOp", "StatefulPartitionedCall/box_scale_0/conv2d_5/BiasAdd/ReadVariableOp"], "device": "/device:CPU:0", "attr": {"dilations": {"list": {"i": ["1", "1", "1", "1"]}}, "T": {"type": "DT_FLOAT"}, "strides": {"list": {"i": ["1", "1", "1", "1"]}}, "data_format": {"s": "TkhXQw=="}, "explicit_paddings": {"list": {}}, "use_cudnn_on_gpu": {"b": true}, "num_args": {"i": "1"}, "epsilon": {"f": 0.0}, "padding": {"s": "VkFMSUQ="}, "fused_ops": {"list": {"s": ["Qmlhc0FkZA=="]}}}}, {"name": "StatefulPartitionedCall/kpt_regress_0/conv2d_8/BiasAdd", "op": "_FusedConv2D", "input": ["StatefulPartitionedCall/kpt_regress_0/re_lu_7/Relu", "StatefulPartitionedCall/kpt_regress_0/conv2d_8/Conv2D/ReadVariableOp", "StatefulPartitionedCall/kpt_regress_0/conv2d_8/BiasAdd/ReadVariableOp"], "device": "/device:CPU:0", "attr": {"dilations": {"list": {"i": ["1", "1", "1", "1"]}}, "T": {"type": "DT_FLOAT"}, "data_format": {"s": "TkhXQw=="}, "strides": {"list": {"i": ["1", "1", "1", "1"]}}, "explicit_paddings": {"list": {}}, "use_cudnn_on_gpu": {"b": true}, "num_args": {"i": "1"}, "epsilon": {"f": 0.0}, "padding": {"s": "VkFMSUQ="}, "fused_ops": {"list": {"s": ["Qmlhc0FkZA=="]}}}}, {"name": "StatefulPartitionedCall/kpt_offset_0/conv2d_9/BiasAdd", "op": "_FusedConv2D", "input": ["StatefulPartitionedCall/kpt_offset_0/re_lu_8/Relu", "StatefulPartitionedCall/kpt_offset_0/conv2d_9/Conv2D/ReadVariableOp", "StatefulPartitionedCall/kpt_offset_0/conv2d_9/BiasAdd/ReadVariableOp"], "device": "/device:CPU:0", "attr": {"fused_ops": {"list": {"s": ["Qmlhc0FkZA=="]}}, "dilations": {"list": {"i": ["1", "1", "1", "1"]}}, "T": {"type": "DT_FLOAT"}, "strides": {"list": {"i": ["1", "1", "1", "1"]}}, "data_format": {"s": "TkhXQw=="}, "use_cudnn_on_gpu": {"b": true}, "explicit_paddings": {"list": {}}, "num_args": {"i": "1"}, "epsilon": {"f": 0.0}, "padding": {"s": "VkFMSUQ="}}}, {"name": "StatefulPartitionedCall/kpt_heatmap_0/conv2d_7/BiasAdd", "op": "_FusedConv2D", "input": ["StatefulPartitionedCall/kpt_heatmap_0/re_lu_6/Relu", "StatefulPartitionedCall/kpt_heatmap_0/conv2d_7/Conv2D/ReadVariableOp", "StatefulPartitionedCall/kpt_heatmap_0/conv2d_7/BiasAdd/ReadVariableOp"], "device": "/device:CPU:0", "attr": {"dilations": {"list": {"i": ["1", "1", "1", "1"]}}, "T": {"type": "DT_FLOAT"}, "data_format": {"s": "TkhXQw=="}, "strides": {"list": {"i": ["1", "1", "1", "1"]}}, "use_cudnn_on_gpu": {"b": true}, "explicit_paddings": {"list": {}}, "num_args": {"i": "1"}, "epsilon": {"f": 0.0}, "padding": {"s": "VkFMSUQ="}, "fused_ops": {"list": {"s": ["Qmlhc0FkZA=="]}}}}, {"name": "StatefulPartitionedCall/center_0/conv2d_4/BiasAdd", "op": "_FusedConv2D", "input": ["StatefulPartitionedCall/center_0/re_lu_3/Relu", "StatefulPartitionedCall/center_0/conv2d_4/Conv2D/ReadVariableOp", "StatefulPartitionedCall/center_0/conv2d_4/BiasAdd/ReadVariableOp"], "device": "/device:CPU:0", "attr": {"dilations": {"list": {"i": ["1", "1", "1", "1"]}}, "T": {"type": "DT_FLOAT"}, "data_format": {"s": "TkhXQw=="}, "strides": {"list": {"i": ["1", "1", "1", "1"]}}, "use_cudnn_on_gpu": {"b": true}, "explicit_paddings": {"list": {}}, "num_args": {"i": "1"}, "epsilon": {"f": 0.0}, "padding": {"s": "VkFMSUQ="}, "fused_ops": {"list": {"s": ["Qmlhc0FkZA=="]}}}}, {"name": "StatefulPartitionedCall/strided_slice_7", "op": "StridedSlice", "input": ["StatefulPartitionedCall/kpt_regress_0/conv2d_8/BiasAdd", "StatefulPartitionedCall/strided_slice_7/stack", "StatefulPartitionedCall/strided_slice_7/stack_1", "StatefulPartitionedCall/strided_slice_7/stack_2"], "attr": {"shrink_axis_mask": {"i": "0"}, "begin_mask": {"i": "0"}, "ellipsis_mask": {"i": "2"}, "new_axis_mask": {"i": "0"}, "end_mask": {"i": "0"}, "Index": {"type": "DT_INT32"}, "T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/strided_slice_6", "op": "StridedSlice", "input": ["StatefulPartitionedCall/kpt_offset_0/conv2d_9/BiasAdd", "StatefulPartitionedCall/strided_slice_6/stack", "StatefulPartitionedCall/strided_slice_6/stack_1", "StatefulPartitionedCall/strided_slice_6/stack_2"], "attr": {"shrink_axis_mask": {"i": "0"}, "begin_mask": {"i": "0"}, "ellipsis_mask": {"i": "2"}, "new_axis_mask": {"i": "0"}, "end_mask": {"i": "0"}, "T": {"type": "DT_FLOAT"}, "Index": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/strided_slice_5", "op": "StridedSlice", "input": ["StatefulPartitionedCall/kpt_heatmap_0/conv2d_7/BiasAdd", "StatefulPartitionedCall/strided_slice_5/stack", "StatefulPartitionedCall/strided_slice_5/stack_1", "StatefulPartitionedCall/strided_slice_5/stack_2"], "attr": {"end_mask": {"i": "0"}, "Index": {"type": "DT_INT32"}, "T": {"type": "DT_FLOAT"}, "shrink_axis_mask": {"i": "0"}, "ellipsis_mask": {"i": "2"}, "begin_mask": {"i": "0"}, "new_axis_mask": {"i": "0"}}}, {"name": "StatefulPartitionedCall/Sigmoid", "op": "Sigmoid", "input": ["StatefulPartitionedCall/center_0/conv2d_4/BiasAdd"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/Sigmoid_1", "op": "Sigmoid", "input": ["StatefulPartitionedCall/strided_slice_5"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/MaxPool", "op": "MaxPool", "input": ["StatefulPartitionedCall/Sigmoid"], "attr": {"ksize": {"list": {"i": ["1", "3", "3", "1"]}}, "padding": {"s": "U0FNRQ=="}, "T": {"type": "DT_FLOAT"}, "strides": {"list": {"i": ["1", "1", "1", "1"]}}, "data_format": {"s": "TkhXQw=="}, "explicit_paddings": {"list": {}}}}, {"name": "StatefulPartitionedCall/MaxPool_1", "op": "MaxPool", "input": ["StatefulPartitionedCall/Sigmoid_1"], "attr": {"T": {"type": "DT_FLOAT"}, "data_format": {"s": "TkhXQw=="}, "strides": {"list": {"i": ["1", "1", "1", "1"]}}, "explicit_paddings": {"list": {}}, "ksize": {"list": {"i": ["1", "5", "5", "1"]}}, "padding": {"s": "U0FNRQ=="}}}, {"name": "StatefulPartitionedCall/sub_2", "op": "Sub", "input": ["StatefulPartitionedCall/Sigmoid", "StatefulPartitionedCall/MaxPool"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/sub_7", "op": "Sub", "input": ["StatefulPartitionedCall/Sigmoid_1", "StatefulPartitionedCall/MaxPool_1"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/Abs", "op": "Abs", "input": ["StatefulPartitionedCall/sub_2"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/Abs_1", "op": "Abs", "input": ["StatefulPartitionedCall/sub_7"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/Less_2", "op": "Less", "input": ["StatefulPartitionedCall/Abs", "StatefulPartitionedCall/Less_2/y"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/Less_3", "op": "Less", "input": ["StatefulPartitionedCall/Abs_1", "StatefulPartitionedCall/Less_3/y"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/Cast_3", "op": "Cast", "input": ["StatefulPartitionedCall/Less_2"], "attr": {"SrcT": {"type": "DT_BOOL"}, "Truncate": {"b": false}, "DstT": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/Cast_11", "op": "Cast", "input": ["StatefulPartitionedCall/Less_3"], "attr": {"SrcT": {"type": "DT_BOOL"}, "Truncate": {"b": false}, "DstT": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/mul_2", "op": "Mul", "input": ["StatefulPartitionedCall/Sigmoid", "StatefulPartitionedCall/Cast_3"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/mul_6", "op": "Mul", "input": ["StatefulPartitionedCall/Sigmoid_1", "StatefulPartitionedCall/Cast_11"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/Reshape_2", "op": "Reshape", "input": ["StatefulPartitionedCall/mul_2", "StatefulPartitionedCall/Reshape_2/shape"], "attr": {"T": {"type": "DT_FLOAT"}, "Tshape": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/transpose", "op": "Transpose", "input": ["StatefulPartitionedCall/mul_6", "StatefulPartitionedCall/transpose/perm"], "attr": {"Tperm": {"type": "DT_INT32"}, "T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/TopKV2", "op": "TopKV2", "input": ["StatefulPartitionedCall/Reshape_2", "StatefulPartitionedCall/TopKV2/k"], "attr": {"T": {"type": "DT_FLOAT"}, "sorted": {"b": true}}}, {"name": "StatefulPartitionedCall/Reshape_14", "op": "Reshape", "input": ["StatefulPartitionedCall/transpose", "StatefulPartitionedCall/Reshape_14/shape"], "attr": {"T": {"type": "DT_FLOAT"}, "Tshape": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/strided_slice_22", "op": "StridedSlice", "input": ["StatefulPartitionedCall/TopKV2", "StatefulPartitionedCall/strided_slice_22/stack", "StatefulPartitionedCall/strided_slice_22/stack_1", "StatefulPartitionedCall/strided_slice_22/stack_2"], "attr": {"T": {"type": "DT_FLOAT"}, "Index": {"type": "DT_INT32"}, "shrink_axis_mask": {"i": "0"}, "ellipsis_mask": {"i": "0"}, "begin_mask": {"i": "3"}, "new_axis_mask": {"i": "4"}, "end_mask": {"i": "3"}}}, {"name": "StatefulPartitionedCall/sub_4", "op": "Sub", "input": ["StatefulPartitionedCall/TopKV2:1", "StatefulPartitionedCall/TopKV2:1"], "attr": {"T": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/floordiv_1", "op": "FloorDiv", "input": ["StatefulPartitionedCall/TopKV2:1", "StatefulPartitionedCall/floordiv_1/y"], "attr": {"T": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/TopKV2_1", "op": "TopKV2", "input": ["StatefulPartitionedCall/Reshape_14", "StatefulPartitionedCall/TopKV2_1/k"], "attr": {"T": {"type": "DT_FLOAT"}, "sorted": {"b": true}}}, {"name": "StatefulPartitionedCall/Equal_2", "op": "Equal", "input": ["StatefulPartitionedCall/sub_4", "StatefulPartitionedCall/x_2"], "attr": {"T": {"type": "DT_INT32"}, "incompatible_shape_error": {"b": false}}}, {"name": "StatefulPartitionedCall/strided_slice_20", "op": "StridedSlice", "input": ["StatefulPartitionedCall/sub_4", "StatefulPartitionedCall/strided_slice_20/stack", "StatefulPartitionedCall/strided_slice_20/stack_1", "StatefulPartitionedCall/strided_slice_20/stack_2"], "attr": {"shrink_axis_mask": {"i": "0"}, "ellipsis_mask": {"i": "0"}, "begin_mask": {"i": "3"}, "new_axis_mask": {"i": "4"}, "end_mask": {"i": "3"}, "T": {"type": "DT_INT32"}, "Index": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/Cast_6", "op": "Cast", "input": ["StatefulPartitionedCall/floordiv_1"], "attr": {"SrcT": {"type": "DT_INT32"}, "Truncate": {"b": false}, "DstT": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/Reshape_4", "op": "Reshape", "input": ["StatefulPartitionedCall/floordiv_1", "StatefulPartitionedCall/Reshape_4/shape"], "attr": {"T": {"type": "DT_INT32"}, "Tshape": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/strided_slice_8", "op": "StridedSlice", "input": ["StatefulPartitionedCall/floordiv_1", "StatefulPartitionedCall/strided_slice_8/stack", "StatefulPartitionedCall/strided_slice_8/stack_1", "StatefulPartitionedCall/strided_slice_8/stack_2"], "attr": {"shrink_axis_mask": {"i": "0"}, "ellipsis_mask": {"i": "2"}, "begin_mask": {"i": "0"}, "new_axis_mask": {"i": "0"}, "end_mask": {"i": "0"}, "T": {"type": "DT_INT32"}, "Index": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/mul_3", "op": "Mul", "input": ["StatefulPartitionedCall/floordiv_1", "StatefulPartitionedCall/mul_3/y"], "attr": {"T": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/transpose_2", "op": "Transpose", "input": ["StatefulPartitionedCall/TopKV2_1", "StatefulPartitionedCall/transpose_2/perm"], "attr": {"Tperm": {"type": "DT_INT32"}, "T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/mul_7", "op": "Mul", "input": ["StatefulPartitionedCall/mul_7/x", "StatefulPartitionedCall/TopKV2_1:1"], "attr": {"T": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/Tile_17", "op": "Tile", "input": ["StatefulPartitionedCall/strided_slice_20", "StatefulPartitionedCall/Tile_17/multiples"], "attr": {"Tmultiples": {"type": "DT_INT32"}, "T": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/ExpandDims_3", "op": "ExpandDims", "input": ["StatefulPartitionedCall/strided_slice_8", "StatefulPartitionedCall/ExpandDims_3/dim"], "attr": {"Tdim": {"type": "DT_INT32"}, "T": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/Reshape_9", "op": "Reshape", "input": ["StatefulPartitionedCall/strided_slice_8", "StatefulPartitionedCall/Reshape_9/shape"], "attr": {"T": {"type": "DT_INT32"}, "Tshape": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/sub_3", "op": "Sub", "input": ["StatefulPartitionedCall/TopKV2:1", "StatefulPartitionedCall/mul_3"], "attr": {"T": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/ExpandDims_12", "op": "ExpandDims", "input": ["StatefulPartitionedCall/transpose_2", "StatefulPartitionedCall/ExpandDims_12/dim"], "attr": {"Tdim": {"type": "DT_INT32"}, "T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/GreaterEqual", "op": "GreaterEqual", "input": ["StatefulPartitionedCall/transpose_2", "StatefulPartitionedCall/GreaterEqual/y"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/add_8", "op": "AddV2", "input": ["StatefulPartitionedCall/mul_7", "StatefulPartitionedCall/strided_slice_11"], "attr": {"T": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/Equal", "op": "Equal", "input": ["StatefulPartitionedCall/Tile_17", "StatefulPartitionedCall/x"], "attr": {"incompatible_shape_error": {"b": false}, "T": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/Cast_9", "op": "Cast", "input": ["StatefulPartitionedCall/ExpandDims_3"], "attr": {"SrcT": {"type": "DT_INT32"}, "Truncate": {"b": false}, "DstT": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/Cast_7", "op": "Cast", "input": ["StatefulPartitionedCall/sub_3"], "attr": {"SrcT": {"type": "DT_INT32"}, "Truncate": {"b": false}, "DstT": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/Reshape_5", "op": "Reshape", "input": ["StatefulPartitionedCall/sub_3", "StatefulPartitionedCall/Reshape_5/shape"], "attr": {"T": {"type": "DT_INT32"}, "Tshape": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/strided_slice_9", "op": "StridedSlice", "input": ["StatefulPartitionedCall/sub_3", "StatefulPartitionedCall/strided_slice_9/stack", "StatefulPartitionedCall/strided_slice_9/stack_1", "StatefulPartitionedCall/strided_slice_9/stack_2"], "attr": {"shrink_axis_mask": {"i": "0"}, "begin_mask": {"i": "0"}, "ellipsis_mask": {"i": "2"}, "new_axis_mask": {"i": "0"}, "end_mask": {"i": "0"}, "T": {"type": "DT_INT32"}, "Index": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/Tile_11", "op": "Tile", "input": ["StatefulPartitionedCall/ExpandDims_12", "StatefulPartitionedCall/Tile_11/multiples"], "attr": {"T": {"type": "DT_FLOAT"}, "Tmultiples": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/ToInt32_1", "op": "Cast", "input": ["StatefulPartitionedCall/GreaterEqual"], "attr": {"SrcT": {"type": "DT_BOOL"}, "Truncate": {"b": false}, "DstT": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/Reshape_16", "op": "Reshape", "input": ["StatefulPartitionedCall/add_8", "StatefulPartitionedCall/Reshape_16/shape"], "attr": {"T": {"type": "DT_INT32"}, "Tshape": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/Cast_22", "op": "Cast", "input": ["StatefulPartitionedCall/Equal"], "attr": {"SrcT": {"type": "DT_BOOL"}, "Truncate": {"b": false}, "DstT": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/stack_3", "op": "Pack", "input": ["StatefulPartitionedCall/Reshape_3", "StatefulPartitionedCall/Reshape_4", "StatefulPartitionedCall/Reshape_5"], "attr": {"N": {"i": "3"}, "T": {"type": "DT_INT32"}, "axis": {"i": "1"}}}, {"name": "StatefulPartitionedCall/ExpandDims_4", "op": "ExpandDims", "input": ["StatefulPartitionedCall/strided_slice_9", "StatefulPartitionedCall/ExpandDims_4/dim"], "attr": {"T": {"type": "DT_INT32"}, "Tdim": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/Reshape_10", "op": "Reshape", "input": ["StatefulPartitionedCall/strided_slice_9", "StatefulPartitionedCall/Reshape_10/shape"], "attr": {"T": {"type": "DT_INT32"}, "Tshape": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/Sum_1", "op": "Sum", "input": ["StatefulPartitionedCall/ToInt32_1", "StatefulPartitionedCall/Sum_1/reduction_indices"], "attr": {"T": {"type": "DT_INT32"}, "Tidx": {"type": "DT_INT32"}, "keep_dims": {"b": false}}}, {"name": "StatefulPartitionedCall/floordiv_6", "op": "FloorDiv", "input": ["StatefulPartitionedCall/Reshape_16", "StatefulPartitionedCall/floordiv_6/y"], "attr": {"T": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/floordiv_4", "op": "FloorDiv", "input": ["StatefulPartitionedCall/Reshape_16", "StatefulPartitionedCall/floordiv_4/y"], "attr": {"T": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/floordiv_7", "op": "FloorDiv", "input": ["StatefulPartitionedCall/Reshape_16", "StatefulPartitionedCall/floordiv_7/y"], "attr": {"T": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/mul_16", "op": "Mul", "input": ["StatefulPartitionedCall/strided_slice_22", "StatefulPartitionedCall/Cast_22"], "attr": {"_grappler_ArithmeticOptimizer_MinimizeBroadcasts": {"b": true}, "T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/GatherNd_1", "op": "GatherNd", "input": ["StatefulPartitionedCall/box_offset_0/conv2d_6/BiasAdd", "StatefulPartitionedCall/stack_3"], "attr": {"Tindices": {"type": "DT_INT32"}, "Tparams": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/GatherNd", "op": "GatherNd", "input": ["StatefulPartitionedCall/box_scale_0/conv2d_5/BiasAdd", "StatefulPartitionedCall/stack_3"], "attr": {"Tindices": {"type": "DT_INT32"}, "Tparams": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/Cast_10", "op": "Cast", "input": ["StatefulPartitionedCall/ExpandDims_4"], "attr": {"SrcT": {"type": "DT_INT32"}, "Truncate": {"b": false}, "DstT": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/stack_5", "op": "Pack", "input": ["StatefulPartitionedCall/Reshape_8", "StatefulPartitionedCall/Reshape_9", "StatefulPartitionedCall/Reshape_10"], "attr": {"T": {"type": "DT_INT32"}, "axis": {"i": "1"}, "N": {"i": "3"}}}, {"name": "StatefulPartitionedCall/ExpandDims_8", "op": "ExpandDims", "input": ["StatefulPartitionedCall/Sum_1", "StatefulPartitionedCall/ExpandDims_8/dim"], "attr": {"T": {"type": "DT_INT32"}, "Tdim": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/floordiv_5", "op": "FloorDiv", "input": ["StatefulPartitionedCall/floordiv_4", "StatefulPartitionedCall/floordiv_5/y"], "attr": {"T": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/mul_9", "op": "Mul", "input": ["StatefulPartitionedCall/floordiv_7", "StatefulPartitionedCall/mul_9/y"], "attr": {"T": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/Reshape_7", "op": "Reshape", "input": ["StatefulPartitionedCall/GatherNd_1", "StatefulPartitionedCall/Reshape_7/shape"], "attr": {"T": {"type": "DT_FLOAT"}, "Tshape": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/Reshape_6", "op": "Reshape", "input": ["StatefulPartitionedCall/GatherNd", "StatefulPartitionedCall/Reshape_6/shape"], "attr": {"T": {"type": "DT_FLOAT"}, "Tshape": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/GatherNd_2", "op": "GatherNd", "input": ["StatefulPartitionedCall/strided_slice_7", "StatefulPartitionedCall/stack_5"], "attr": {"Tparams": {"type": "DT_FLOAT"}, "Tindices": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/Tile_7", "op": "Tile", "input": ["StatefulPartitionedCall/ExpandDims_8", "StatefulPartitionedCall/Tile_7/multiples"], "attr": {"Tmultiples": {"type": "DT_INT32"}, "T": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/Cast_12", "op": "Cast", "input": ["StatefulPartitionedCall/floordiv_5"], "attr": {"SrcT": {"type": "DT_INT32"}, "Truncate": {"b": false}, "DstT": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/Reshape_18", "op": "Reshape", "input": ["StatefulPartitionedCall/floordiv_5", "StatefulPartitionedCall/Reshape_18/shape"], "attr": {"T": {"type": "DT_INT32"}, "Tshape": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/mul_8", "op": "Mul", "input": ["StatefulPartitionedCall/floordiv_5", "StatefulPartitionedCall/mul_8/y"], "attr": {"T": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/sub_9", "op": "Sub", "input": ["StatefulPartitionedCall/Reshape_16", "StatefulPartitionedCall/mul_9"], "attr": {"T": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/unstack_2", "op": "Unpack", "input": ["StatefulPartitionedCall/Reshape_7"], "attr": {"T": {"type": "DT_FLOAT"}, "num": {"i": "2"}, "axis": {"i": "2"}}}, {"name": "StatefulPartitionedCall/Maximum", "op": "Maximum", "input": ["StatefulPartitionedCall/Reshape_6", "StatefulPartitionedCall/Maximum/y"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/Reshape_11", "op": "Reshape", "input": ["StatefulPartitionedCall/GatherNd_2", "StatefulPartitionedCall/Reshape_11/shape"], "attr": {"T": {"type": "DT_FLOAT"}, "Tshape": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/GreaterEqual_1", "op": "GreaterEqual", "input": ["StatefulPartitionedCall/Tile_6", "StatefulPartitionedCall/Tile_7"], "attr": {"T": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/sub_8", "op": "Sub", "input": ["StatefulPartitionedCall/floordiv_6", "StatefulPartitionedCall/mul_8"], "attr": {"T": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/Reshape_24", "op": "Reshape", "input": ["StatefulPartitionedCall/sub_9", "StatefulPartitionedCall/Reshape_24/shape"], "attr": {"T": {"type": "DT_INT32"}, "Tshape": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/add", "op": "AddV2", "input": ["StatefulPartitionedCall/Cast_6", "StatefulPartitionedCall/unstack_2"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/add_1", "op": "AddV2", "input": ["StatefulPartitionedCall/Cast_7", "StatefulPartitionedCall/unstack_2:1"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/unstack_1", "op": "Unpack", "input": ["StatefulPartitionedCall/Maximum"], "attr": {"T": {"type": "DT_FLOAT"}, "num": {"i": "2"}, "axis": {"i": "2"}}}, {"name": "StatefulPartitionedCall/unstack_3", "op": "Unpack", "input": ["StatefulPartitionedCall/Reshape_11"], "attr": {"T": {"type": "DT_FLOAT"}, "num": {"i": "2"}, "axis": {"i": "3"}}}, {"name": "StatefulPartitionedCall/ExpandDims_11", "op": "ExpandDims", "input": ["StatefulPartitionedCall/GreaterEqual_1", "StatefulPartitionedCall/ExpandDims_11/dim"], "attr": {"Tdim": {"type": "DT_INT32"}, "T": {"type": "DT_BOOL"}}}, {"name": "StatefulPartitionedCall/Cast_13", "op": "Cast", "input": ["StatefulPartitionedCall/sub_8"], "attr": {"Truncate": {"b": false}, "DstT": {"type": "DT_FLOAT"}, "SrcT": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/Reshape_19", "op": "Reshape", "input": ["StatefulPartitionedCall/sub_8", "StatefulPartitionedCall/Reshape_19/shape"], "attr": {"T": {"type": "DT_INT32"}, "Tshape": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/stack_8", "op": "Pack", "input": ["StatefulPartitionedCall/Reshape_22", "StatefulPartitionedCall/Reshape_23", "StatefulPartitionedCall/Reshape_24"], "attr": {"T": {"type": "DT_INT32"}, "axis": {"i": "1"}, "N": {"i": "3"}}}, {"name": "StatefulPartitionedCall/truediv_2", "op": "Mul", "input": ["StatefulPartitionedCall/unstack_1", "ConstantFolding/StatefulPartitionedCall/truediv_2_recip"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/truediv_4", "op": "Mul", "input": ["StatefulPartitionedCall/unstack_1", "ConstantFolding/StatefulPartitionedCall/truediv_4_recip"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/truediv_3", "op": "Mul", "input": ["StatefulPartitionedCall/unstack_1:1", "ConstantFolding/StatefulPartitionedCall/truediv_3_recip"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/truediv_5", "op": "Mul", "input": ["StatefulPartitionedCall/unstack_1:1", "ConstantFolding/StatefulPartitionedCall/truediv_5_recip"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/add_6", "op": "AddV2", "input": ["StatefulPartitionedCall/Cast_9", "StatefulPartitionedCall/unstack_3"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/add_7", "op": "AddV2", "input": ["StatefulPartitionedCall/Cast_10", "StatefulPartitionedCall/unstack_3:1"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/Tile_10", "op": "Tile", "input": ["StatefulPartitionedCall/ExpandDims_11", "StatefulPartitionedCall/Tile_10/multiples"], "attr": {"Tmultiples": {"type": "DT_INT32"}, "T": {"type": "DT_BOOL"}}}, {"name": "StatefulPartitionedCall/stack_7", "op": "Pack", "input": ["StatefulPartitionedCall/Reshape_17", "StatefulPartitionedCall/Reshape_18", "StatefulPartitionedCall/Reshape_19"], "attr": {"T": {"type": "DT_INT32"}, "axis": {"i": "1"}, "N": {"i": "3"}}}, {"name": "StatefulPartitionedCall/sub_5", "op": "Sub", "input": ["StatefulPartitionedCall/add", "StatefulPartitionedCall/truediv_2"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/ArithmeticOptimizer/AddOpsRewrite_add_3", "op": "AddN", "input": ["StatefulPartitionedCall/Cast_6", "StatefulPartitionedCall/unstack_2", "StatefulPartitionedCall/truediv_4"], "attr": {"T": {"type": "DT_FLOAT"}, "N": {"i": "3"}, "_grappler_ArithmeticOptimizer_AddOpsRewriteStage": {"b": true}}}, {"name": "StatefulPartitionedCall/sub_6", "op": "Sub", "input": ["StatefulPartitionedCall/add_1", "StatefulPartitionedCall/truediv_3"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/ArithmeticOptimizer/AddOpsRewrite_add_5", "op": "AddN", "input": ["StatefulPartitionedCall/Cast_7", "StatefulPartitionedCall/unstack_2:1", "StatefulPartitionedCall/truediv_5"], "attr": {"N": {"i": "3"}, "_grappler_ArithmeticOptimizer_AddOpsRewriteStage": {"b": true}, "T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/stack_6", "op": "Pack", "input": ["StatefulPartitionedCall/add_6", "StatefulPartitionedCall/add_7"], "attr": {"N": {"i": "2"}, "T": {"type": "DT_FLOAT"}, "axis": {"i": "3"}}}, {"name": "StatefulPartitionedCall/GatherNd_3", "op": "GatherNd", "input": ["StatefulPartitionedCall/strided_slice_6", "StatefulPartitionedCall/stack_7"], "attr": {"Tindices": {"type": "DT_INT32"}, "Tparams": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/clip_by_value/Minimum", "op": "Minimum", "input": ["StatefulPartitionedCall/sub_5", "StatefulPartitionedCall/Cast_4"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/clip_by_value_2/Minimum", "op": "Minimum", "input": ["StatefulPartitionedCall/ArithmeticOptimizer/AddOpsRewrite_add_3", "StatefulPartitionedCall/Cast_4"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/clip_by_value_1/Minimum", "op": "Minimum", "input": ["StatefulPartitionedCall/sub_6", "StatefulPartitionedCall/Cast_5"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/clip_by_value_3/Minimum", "op": "Minimum", "input": ["StatefulPartitionedCall/ArithmeticOptimizer/AddOpsRewrite_add_5", "StatefulPartitionedCall/Cast_5"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/ExpandDims_9", "op": "ExpandDims", "input": ["StatefulPartitionedCall/stack_6", "StatefulPartitionedCall/ExpandDims_9/dim"], "attr": {"Tdim": {"type": "DT_INT32"}, "T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/Reshape_21", "op": "Reshape", "input": ["StatefulPartitionedCall/GatherNd_3", "StatefulPartitionedCall/Reshape_21/shape"], "attr": {"T": {"type": "DT_FLOAT"}, "Tshape": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/clip_by_value", "op": "Maximum", "input": ["StatefulPartitionedCall/clip_by_value/Minimum", "StatefulPartitionedCall/clip_by_value/y"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/clip_by_value_2", "op": "Maximum", "input": ["StatefulPartitionedCall/clip_by_value_2/Minimum", "StatefulPartitionedCall/clip_by_value_2/y"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/clip_by_value_1", "op": "Maximum", "input": ["StatefulPartitionedCall/clip_by_value_1/Minimum", "StatefulPartitionedCall/clip_by_value_1/y"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/clip_by_value_3", "op": "Maximum", "input": ["StatefulPartitionedCall/clip_by_value_3/Minimum", "StatefulPartitionedCall/clip_by_value_3/y"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/Tile_8", "op": "Tile", "input": ["StatefulPartitionedCall/ExpandDims_9", "StatefulPartitionedCall/Tile_8/multiples"], "attr": {"Tmultiples": {"type": "DT_INT32"}, "T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/GatherNd_4", "op": "GatherNd", "input": ["StatefulPartitionedCall/Reshape_21", "StatefulPartitionedCall/stack_8"], "attr": {"Tindices": {"type": "DT_INT32"}, "Tparams": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/stack_4", "op": "Pack", "input": ["StatefulPartitionedCall/clip_by_value", "StatefulPartitionedCall/clip_by_value_1", "StatefulPartitionedCall/clip_by_value_2", "StatefulPartitionedCall/clip_by_value_3"], "attr": {"N": {"i": "4"}, "T": {"type": "DT_FLOAT"}, "axis": {"i": "2"}}}, {"name": "StatefulPartitionedCall/Reshape_25", "op": "Reshape", "input": ["StatefulPartitionedCall/GatherNd_4", "StatefulPartitionedCall/Reshape_25/shape"], "attr": {"T": {"type": "DT_FLOAT"}, "Tshape": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/truediv_6", "op": "Mul", "input": ["StatefulPartitionedCall/stack_4", "StatefulPartitionedCall/mul_5"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/strided_slice_10", "op": "StridedSlice", "input": ["StatefulPartitionedCall/stack_4", "StatefulPartitionedCall/strided_slice_10/stack", "StatefulPartitionedCall/strided_slice_10/stack_1", "StatefulPartitionedCall/strided_slice_10/stack_2"], "attr": {"T": {"type": "DT_FLOAT"}, "Index": {"type": "DT_INT32"}, "shrink_axis_mask": {"i": "0"}, "ellipsis_mask": {"i": "2"}, "begin_mask": {"i": "0"}, "new_axis_mask": {"i": "0"}, "end_mask": {"i": "0"}}}, {"name": "StatefulPartitionedCall/unstack_4", "op": "Unpack", "input": ["StatefulPartitionedCall/Reshape_25"], "attr": {"T": {"type": "DT_FLOAT"}, "num": {"i": "2"}, "axis": {"i": "2"}}}, {"name": "StatefulPartitionedCall/clip_by_value_4/Minimum", "op": "Minimum", "input": ["StatefulPartitionedCall/truediv_6", "StatefulPartitionedCall/clip_by_value_4/Minimum/y"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/Reshape_34", "op": "Reshape", "input": ["StatefulPartitionedCall/strided_slice_10", "StatefulPartitionedCall/Reshape_34/shape"], "attr": {"T": {"type": "DT_FLOAT"}, "Tshape": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/add_9", "op": "AddV2", "input": ["StatefulPartitionedCall/Cast_12", "StatefulPartitionedCall/unstack_4"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/add_10", "op": "AddV2", "input": ["StatefulPartitionedCall/Cast_13", "StatefulPartitionedCall/unstack_4:1"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/clip_by_value_4", "op": "Maximum", "input": ["StatefulPartitionedCall/clip_by_value_4/Minimum", "StatefulPartitionedCall/clip_by_value_4/y"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/ScaleHeightWidth/get_center_coordinates_and_sizes/transpose", "op": "Transpose", "input": ["StatefulPartitionedCall/Reshape_34", "StatefulPartitionedCall/ScaleHeightWidth/get_center_coordinates_and_sizes/transpose/perm"], "attr": {"T": {"type": "DT_FLOAT"}, "Tperm": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/stack_9", "op": "Pack", "input": ["StatefulPartitionedCall/add_9", "StatefulPartitionedCall/add_10"], "attr": {"T": {"type": "DT_FLOAT"}, "axis": {"i": "2"}, "N": {"i": "2"}}}, {"name": "StatefulPartitionedCall/ScaleHeightWidth/get_center_coordinates_and_sizes/unstack", "op": "Unpack", "input": ["StatefulPartitionedCall/ScaleHeightWidth/get_center_coordinates_and_sizes/transpose"], "attr": {"T": {"type": "DT_FLOAT"}, "num": {"i": "4"}, "axis": {"i": "0"}}}, {"name": "StatefulPartitionedCall/Reshape_26", "op": "Reshape", "input": ["StatefulPartitionedCall/stack_9", "StatefulPartitionedCall/Reshape_26/shape"], "attr": {"T": {"type": "DT_FLOAT"}, "Tshape": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/ScaleHeightWidth/get_center_coordinates_and_sizes/sub_1", "op": "Sub", "input": ["StatefulPartitionedCall/ScaleHeightWidth/get_center_coordinates_and_sizes/unstack:2", "StatefulPartitionedCall/ScaleHeightWidth/get_center_coordinates_and_sizes/unstack"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/ScaleHeightWidth/get_center_coordinates_and_sizes/sub", "op": "Sub", "input": ["StatefulPartitionedCall/ScaleHeightWidth/get_center_coordinates_and_sizes/unstack:3", "StatefulPartitionedCall/ScaleHeightWidth/get_center_coordinates_and_sizes/unstack:1"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/transpose_1", "op": "Transpose", "input": ["StatefulPartitionedCall/Reshape_26", "StatefulPartitionedCall/transpose_1/perm"], "attr": {"Tperm": {"type": "DT_INT32"}, "T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/ScaleHeightWidth/mul_1", "op": "Mul", "input": ["StatefulPartitionedCall/ScaleHeightWidth/mul", "StatefulPartitionedCall/ScaleHeightWidth/get_center_coordinates_and_sizes/sub_1"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/ScaleHeightWidth/get_center_coordinates_and_sizes/truediv", "op": "Mul", "input": ["StatefulPartitionedCall/ScaleHeightWidth/get_center_coordinates_and_sizes/sub_1", "ConstantFolding/StatefulPartitionedCall/ScaleHeightWidth/get_center_coordinates_and_sizes/truediv_recip"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/ScaleHeightWidth/mul_3", "op": "Mul", "input": ["StatefulPartitionedCall/ScaleHeightWidth/mul_2", "StatefulPartitionedCall/ScaleHeightWidth/get_center_coordinates_and_sizes/sub_1"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/ScaleHeightWidth/mul_5", "op": "Mul", "input": ["StatefulPartitionedCall/ScaleHeightWidth/mul_4", "StatefulPartitionedCall/ScaleHeightWidth/get_center_coordinates_and_sizes/sub"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/ScaleHeightWidth/get_center_coordinates_and_sizes/truediv_1", "op": "Mul", "input": ["StatefulPartitionedCall/ScaleHeightWidth/get_center_coordinates_and_sizes/sub", "ConstantFolding/StatefulPartitionedCall/ScaleHeightWidth/get_center_coordinates_and_sizes/truediv_1_recip"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/ScaleHeightWidth/mul_7", "op": "Mul", "input": ["StatefulPartitionedCall/ScaleHeightWidth/mul_6", "StatefulPartitionedCall/ScaleHeightWidth/get_center_coordinates_and_sizes/sub"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/ExpandDims_10", "op": "ExpandDims", "input": ["StatefulPartitionedCall/transpose_1", "StatefulPartitionedCall/ExpandDims_10/dim"], "attr": {"Tdim": {"type": "DT_INT32"}, "T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/ScaleHeightWidth/get_center_coordinates_and_sizes/add", "op": "AddV2", "input": ["StatefulPartitionedCall/ScaleHeightWidth/get_center_coordinates_and_sizes/unstack", "StatefulPartitionedCall/ScaleHeightWidth/get_center_coordinates_and_sizes/truediv"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/ScaleHeightWidth/get_center_coordinates_and_sizes/add_1", "op": "AddV2", "input": ["StatefulPartitionedCall/ScaleHeightWidth/get_center_coordinates_and_sizes/unstack:1", "StatefulPartitionedCall/ScaleHeightWidth/get_center_coordinates_and_sizes/truediv_1"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/Tile_9", "op": "Tile", "input": ["StatefulPartitionedCall/ExpandDims_10", "StatefulPartitionedCall/Tile_9/multiples"], "attr": {"Tmultiples": {"type": "DT_INT32"}, "T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/ScaleHeightWidth/sub", "op": "Sub", "input": ["StatefulPartitionedCall/ScaleHeightWidth/get_center_coordinates_and_sizes/add", "StatefulPartitionedCall/ScaleHeightWidth/mul_1"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/ScaleHeightWidth/add", "op": "AddV2", "input": ["StatefulPartitionedCall/ScaleHeightWidth/get_center_coordinates_and_sizes/add", "StatefulPartitionedCall/ScaleHeightWidth/mul_3"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/ScaleHeightWidth/sub_1", "op": "Sub", "input": ["StatefulPartitionedCall/ScaleHeightWidth/get_center_coordinates_and_sizes/add_1", "StatefulPartitionedCall/ScaleHeightWidth/mul_5"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/ScaleHeightWidth/add_1", "op": "AddV2", "input": ["StatefulPartitionedCall/ScaleHeightWidth/get_center_coordinates_and_sizes/add_1", "StatefulPartitionedCall/ScaleHeightWidth/mul_7"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/sub_10", "op": "SquaredDifference", "input": ["StatefulPartitionedCall/Tile_8", "StatefulPartitionedCall/Tile_9"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/ScaleHeightWidth/stack", "op": "Pack", "input": ["StatefulPartitionedCall/ScaleHeightWidth/sub", "StatefulPartitionedCall/ScaleHeightWidth/sub_1", "StatefulPartitionedCall/ScaleHeightWidth/add", "StatefulPartitionedCall/ScaleHeightWidth/add_1"], "attr": {"N": {"i": "4"}, "T": {"type": "DT_FLOAT"}, "axis": {"i": "1"}}}, {"name": "StatefulPartitionedCall/Sum_2", "op": "Sum", "input": ["StatefulPartitionedCall/sub_10", "StatefulPartitionedCall/Sum_2/reduction_indices"], "attr": {"T": {"type": "DT_FLOAT"}, "Tidx": {"type": "DT_INT32"}, "keep_dims": {"b": false}}}, {"name": "StatefulPartitionedCall/Reshape_35", "op": "Reshape", "input": ["StatefulPartitionedCall/ScaleHeightWidth/stack", "StatefulPartitionedCall/Reshape_35/shape"], "attr": {"T": {"type": "DT_FLOAT"}, "Tshape": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/Sqrt", "op": "Sqrt", "input": ["StatefulPartitionedCall/Sum_2"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/ExpandDims_15", "op": "ExpandDims", "input": ["StatefulPartitionedCall/Reshape_35", "StatefulPartitionedCall/ExpandDims_15/dim"], "attr": {"T": {"type": "DT_FLOAT"}, "Tdim": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/Select", "op": "Select", "input": ["StatefulPartitionedCall/Tile_10", "StatefulPartitionedCall/mul_11", "StatefulPartitionedCall/Sqrt"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/Tile_14", "op": "Tile", "input": ["StatefulPartitionedCall/ExpandDims_15", "StatefulPartitionedCall/Tile_14/multiples"], "attr": {"Tmultiples": {"type": "DT_INT32"}, "T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/Min", "op": "Min", "input": ["StatefulPartitionedCall/Select", "StatefulPartitionedCall/Min/reduction_indices"], "attr": {"Tidx": {"type": "DT_INT32"}, "keep_dims": {"b": false}, "T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/add_11", "op": "AddV2", "input": ["StatefulPartitionedCall/Select", "StatefulPartitionedCall/add_11/y"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/unstack_5", "op": "Unpack", "input": ["StatefulPartitionedCall/Tile_14"], "attr": {"T": {"type": "DT_FLOAT"}, "num": {"i": "4"}, "axis": {"i": "3"}}}, {"name": "StatefulPartitionedCall/truediv_7", "op": "RealDiv", "input": ["StatefulPartitionedCall/Tile_11", "StatefulPartitionedCall/add_11"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/sub_11", "op": "Sub", "input": ["StatefulPartitionedCall/unstack_5:2", "StatefulPartitionedCall/unstack_5"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/sub_12", "op": "Sub", "input": ["StatefulPartitionedCall/unstack_5:3", "StatefulPartitionedCall/unstack_5:1"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/ArgMax", "op": "ArgMax", "input": ["StatefulPartitionedCall/truediv_7", "StatefulPartitionedCall/ArgMax/dimension"], "attr": {"T": {"type": "DT_FLOAT"}, "output_type": {"type": "DT_INT64"}, "Tidx": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/Maximum_1", "op": "Maximum", "input": ["StatefulPartitionedCall/sub_11", "StatefulPartitionedCall/sub_12"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/transpose_5", "op": "Transpose", "input": ["StatefulPartitionedCall/ArgMax", "StatefulPartitionedCall/transpose_5/perm"], "attr": {"T": {"type": "DT_INT64"}, "Tperm": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/mul_12", "op": "Mul", "input": ["StatefulPartitionedCall/Maximum_1", "StatefulPartitionedCall/mul_12/y"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/Reshape_31", "op": "Reshape", "input": ["StatefulPartitionedCall/transpose_5", "StatefulPartitionedCall/Reshape_31/shape"], "attr": {"T": {"type": "DT_INT64"}, "Tshape": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/Greater_3", "op": "Greater", "input": ["StatefulPartitionedCall/Min", "StatefulPartitionedCall/mul_12"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/stack_10", "op": "Pack", "input": ["StatefulPartitionedCall/Reshape_29", "StatefulPartitionedCall/Reshape_30", "StatefulPartitionedCall/Reshape_31"], "attr": {"T": {"type": "DT_INT64"}, "axis": {"i": "1"}, "N": {"i": "3"}}}, {"name": "StatefulPartitionedCall/Cast_19", "op": "Cast", "input": ["StatefulPartitionedCall/Greater_3"], "attr": {"SrcT": {"type": "DT_BOOL"}, "Truncate": {"b": false}, "DstT": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/GatherNd_5", "op": "GatherNd", "input": ["StatefulPartitionedCall/Reshape_26", "StatefulPartitionedCall/stack_10"], "attr": {"Tindices": {"type": "DT_INT64"}, "Tparams": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/GatherNd_6", "op": "GatherNd", "input": ["StatefulPartitionedCall/TopKV2_1", "StatefulPartitionedCall/stack_10"], "attr": {"Tindices": {"type": "DT_INT64"}, "Tparams": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/Reshape_32", "op": "Reshape", "input": ["StatefulPartitionedCall/GatherNd_5", "StatefulPartitionedCall/Reshape_32/shape"], "attr": {"T": {"type": "DT_FLOAT"}, "Tshape": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/Reshape_33", "op": "Reshape", "input": ["StatefulPartitionedCall/GatherNd_6", "StatefulPartitionedCall/Reshape_33/shape"], "attr": {"T": {"type": "DT_FLOAT"}, "Tshape": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/transpose_6", "op": "Transpose", "input": ["StatefulPartitionedCall/Reshape_32", "StatefulPartitionedCall/transpose_6/perm"], "attr": {"T": {"type": "DT_FLOAT"}, "Tperm": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/transpose_7", "op": "Transpose", "input": ["StatefulPartitionedCall/Reshape_33", "StatefulPartitionedCall/transpose_7/perm"], "attr": {"Tperm": {"type": "DT_INT32"}, "T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/strided_slice_12", "op": "StridedSlice", "input": ["StatefulPartitionedCall/transpose_6", "StatefulPartitionedCall/strided_slice_12/stack", "StatefulPartitionedCall/strided_slice_12/stack_1", "StatefulPartitionedCall/strided_slice_12/stack_2"], "attr": {"end_mask": {"i": "7"}, "Index": {"type": "DT_INT32"}, "T": {"type": "DT_FLOAT"}, "shrink_axis_mask": {"i": "8"}, "begin_mask": {"i": "7"}, "ellipsis_mask": {"i": "0"}, "new_axis_mask": {"i": "0"}}}, {"name": "StatefulPartitionedCall/strided_slice_13", "op": "StridedSlice", "input": ["StatefulPartitionedCall/transpose_6", "StatefulPartitionedCall/strided_slice_13/stack", "StatefulPartitionedCall/strided_slice_13/stack_1", "StatefulPartitionedCall/strided_slice_13/stack_2"], "attr": {"begin_mask": {"i": "7"}, "ellipsis_mask": {"i": "0"}, "new_axis_mask": {"i": "0"}, "end_mask": {"i": "7"}, "Index": {"type": "DT_INT32"}, "T": {"type": "DT_FLOAT"}, "shrink_axis_mask": {"i": "8"}}}, {"name": "StatefulPartitionedCall/strided_slice_14", "op": "StridedSlice", "input": ["StatefulPartitionedCall/transpose_6", "StatefulPartitionedCall/strided_slice_14/stack", "StatefulPartitionedCall/strided_slice_14/stack_1", "StatefulPartitionedCall/strided_slice_14/stack_2"], "attr": {"Index": {"type": "DT_INT32"}, "T": {"type": "DT_FLOAT"}, "shrink_axis_mask": {"i": "8"}, "ellipsis_mask": {"i": "0"}, "begin_mask": {"i": "7"}, "new_axis_mask": {"i": "0"}, "end_mask": {"i": "7"}}}, {"name": "StatefulPartitionedCall/strided_slice_15", "op": "StridedSlice", "input": ["StatefulPartitionedCall/transpose_6", "StatefulPartitionedCall/strided_slice_15/stack", "StatefulPartitionedCall/strided_slice_15/stack_1", "StatefulPartitionedCall/strided_slice_15/stack_2"], "attr": {"Index": {"type": "DT_INT32"}, "T": {"type": "DT_FLOAT"}, "shrink_axis_mask": {"i": "8"}, "begin_mask": {"i": "7"}, "ellipsis_mask": {"i": "0"}, "new_axis_mask": {"i": "0"}, "end_mask": {"i": "7"}}}, {"name": "StatefulPartitionedCall/Less_6", "op": "Less", "input": ["StatefulPartitionedCall/transpose_7", "StatefulPartitionedCall/Less_6/y"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/Less_4", "op": "Less", "input": ["StatefulPartitionedCall/strided_slice_12", "StatefulPartitionedCall/unstack_5"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/Greater_1", "op": "Greater", "input": ["StatefulPartitionedCall/strided_slice_13", "StatefulPartitionedCall/unstack_5:2"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/Less_5", "op": "Less", "input": ["StatefulPartitionedCall/strided_slice_14", "StatefulPartitionedCall/unstack_5:1"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/Greater_2", "op": "Greater", "input": ["StatefulPartitionedCall/strided_slice_15", "StatefulPartitionedCall/unstack_5:3"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/Cast_18", "op": "Cast", "input": ["StatefulPartitionedCall/Less_6"], "attr": {"SrcT": {"type": "DT_BOOL"}, "Truncate": {"b": false}, "DstT": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/Cast_14", "op": "Cast", "input": ["StatefulPartitionedCall/Less_4"], "attr": {"Truncate": {"b": false}, "DstT": {"type": "DT_INT32"}, "SrcT": {"type": "DT_BOOL"}}}, {"name": "StatefulPartitionedCall/Cast_15", "op": "Cast", "input": ["StatefulPartitionedCall/Greater_1"], "attr": {"Truncate": {"b": false}, "DstT": {"type": "DT_INT32"}, "SrcT": {"type": "DT_BOOL"}}}, {"name": "StatefulPartitionedCall/Cast_16", "op": "Cast", "input": ["StatefulPartitionedCall/Less_5"], "attr": {"SrcT": {"type": "DT_BOOL"}, "Truncate": {"b": false}, "DstT": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/Cast_17", "op": "Cast", "input": ["StatefulPartitionedCall/Greater_2"], "attr": {"Truncate": {"b": false}, "DstT": {"type": "DT_INT32"}, "SrcT": {"type": "DT_BOOL"}}}, {"name": "StatefulPartitionedCall/ArithmeticOptimizer/AddOpsRewrite_add_16", "op": "AddN", "input": ["StatefulPartitionedCall/Cast_14", "StatefulPartitionedCall/Cast_15", "StatefulPartitionedCall/Cast_16", "StatefulPartitionedCall/Cast_17", "StatefulPartitionedCall/Cast_18", "StatefulPartitionedCall/Cast_19"], "attr": {"_grappler_ArithmeticOptimizer_AddOpsRewriteStage": {"b": true}, "T": {"type": "DT_INT32"}, "N": {"i": "6"}}}, {"name": "StatefulPartitionedCall/Greater_4", "op": "Greater", "input": ["StatefulPartitionedCall/ArithmeticOptimizer/AddOpsRewrite_add_16", "StatefulPartitionedCall/Greater_4/y"], "attr": {"T": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/ExpandDims_16", "op": "ExpandDims", "input": ["StatefulPartitionedCall/Greater_4", "StatefulPartitionedCall/ExpandDims_16/dim"], "attr": {"Tdim": {"type": "DT_INT32"}, "T": {"type": "DT_BOOL"}}}, {"name": "StatefulPartitionedCall/Select_2", "op": "Select", "input": ["StatefulPartitionedCall/Greater_4", "StatefulPartitionedCall/mul_13", "StatefulPartitionedCall/transpose_7"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/Tile_15", "op": "Tile", "input": ["StatefulPartitionedCall/ExpandDims_16", "StatefulPartitionedCall/Tile_15/multiples"], "attr": {"Tmultiples": {"type": "DT_INT32"}, "T": {"type": "DT_BOOL"}}}, {"name": "StatefulPartitionedCall/Select_1", "op": "Select", "input": ["StatefulPartitionedCall/Tile_15", "StatefulPartitionedCall/stack_6", "StatefulPartitionedCall/transpose_6"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/mul_14", "op": "Mul", "input": ["StatefulPartitionedCall/Select_1", "StatefulPartitionedCall/Reshape_36"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/map/TensorArrayUnstack/TensorListFromTensor", "op": "TensorListFromTensor", "input": ["StatefulPartitionedCall/mul_14", "StatefulPartitionedCall/map/TensorArrayUnstack/TensorListFromTensor/element_shape"], "attr": {"shape_type": {"type": "DT_INT32"}, "element_dtype": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/strided_slice_16", "op": "StridedSlice", "input": ["StatefulPartitionedCall/mul_14", "StatefulPartitionedCall/strided_slice_16/stack", "StatefulPartitionedCall/strided_slice_16/stack_1", "StatefulPartitionedCall/strided_slice_16/stack_2"], "attr": {"T": {"type": "DT_FLOAT"}, "Index": {"type": "DT_INT32"}, "shrink_axis_mask": {"i": "8"}, "begin_mask": {"i": "7"}, "ellipsis_mask": {"i": "0"}, "new_axis_mask": {"i": "0"}, "end_mask": {"i": "7"}}}, {"name": "StatefulPartitionedCall/strided_slice_17", "op": "StridedSlice", "input": ["StatefulPartitionedCall/mul_14", "StatefulPartitionedCall/strided_slice_17/stack", "StatefulPartitionedCall/strided_slice_17/stack_1", "StatefulPartitionedCall/strided_slice_17/stack_2"], "attr": {"Index": {"type": "DT_INT32"}, "T": {"type": "DT_FLOAT"}, "shrink_axis_mask": {"i": "8"}, "ellipsis_mask": {"i": "0"}, "begin_mask": {"i": "7"}, "new_axis_mask": {"i": "0"}, "end_mask": {"i": "7"}}}, {"name": "StatefulPartitionedCall/strided_slice_18", "op": "StridedSlice", "input": ["StatefulPartitionedCall/mul_14", "StatefulPartitionedCall/strided_slice_18/stack", "StatefulPartitionedCall/strided_slice_18/stack_1", "StatefulPartitionedCall/strided_slice_18/stack_2"], "attr": {"begin_mask": {"i": "7"}, "ellipsis_mask": {"i": "0"}, "new_axis_mask": {"i": "0"}, "end_mask": {"i": "7"}, "T": {"type": "DT_FLOAT"}, "Index": {"type": "DT_INT32"}, "shrink_axis_mask": {"i": "8"}}}, {"name": "StatefulPartitionedCall/strided_slice_19", "op": "StridedSlice", "input": ["StatefulPartitionedCall/mul_14", "StatefulPartitionedCall/strided_slice_19/stack", "StatefulPartitionedCall/strided_slice_19/stack_1", "StatefulPartitionedCall/strided_slice_19/stack_2"], "attr": {"shrink_axis_mask": {"i": "8"}, "ellipsis_mask": {"i": "0"}, "begin_mask": {"i": "7"}, "new_axis_mask": {"i": "0"}, "end_mask": {"i": "7"}, "T": {"type": "DT_FLOAT"}, "Index": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/map/while", "op": "StatelessWhile", "input": ["StatefulPartitionedCall/map/while/loop_counter", "StatefulPartitionedCall/map/while/maximum_iterations", "StatefulPartitionedCall/map/Const", "StatefulPartitionedCall/map/TensorArrayV2_2", "StatefulPartitionedCall/map/TensorArrayUnstack/TensorListFromTensor", "StatefulPartitionedCall/map/TensorArrayUnstack_1/TensorListFromTensor"], "attr": {"_stateful_parallelism": {"b": false}, "body": {"func": {"name": "__inference_map_while_body_10122_30691"}}, "output_shapes": {"list": {"shape": [{}, {}, {}, {}, {}, {}]}}, "T": {"list": {"type": ["DT_INT32", "DT_INT32", "DT_INT32", "DT_VARIANT", "DT_VARIANT", "DT_VARIANT"]}}, "_lower_using_switch_merge": {"b": false}, "_read_only_resource_inputs": {"list": {}}, "parallel_iterations": {"i": "10"}, "cond": {"func": {"name": "__inference_map_while_cond_10121_3503"}}, "_num_original_outputs": {"i": "6"}}}, {"name": "StatefulPartitionedCall/GreaterEqual_2", "op": "GreaterEqual", "input": ["StatefulPartitionedCall/strided_slice_16", "StatefulPartitionedCall/GreaterEqual_2/y"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/LessEqual", "op": "LessEqual", "input": ["StatefulPartitionedCall/strided_slice_17", "StatefulPartitionedCall/LessEqual/y"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/GreaterEqual_3", "op": "GreaterEqual", "input": ["StatefulPartitionedCall/strided_slice_18", "StatefulPartitionedCall/GreaterEqual_3/y"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/LessEqual_1", "op": "LessEqual", "input": ["StatefulPartitionedCall/strided_slice_19", "StatefulPartitionedCall/LessEqual_1/y"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/map/TensorArrayV2Stack/TensorListStack", "op": "TensorListStack", "input": ["StatefulPartitionedCall/map/while:3", "StatefulPartitionedCall/map/TensorArrayV2Stack/TensorListStack/element_shape"], "attr": {"element_dtype": {"type": "DT_FLOAT"}, "num_elements": {"i": "1"}}}, {"name": "StatefulPartitionedCall/LogicalAnd", "op": "LogicalAnd", "input": ["StatefulPartitionedCall/GreaterEqual_2", "StatefulPartitionedCall/LessEqual"]}, {"name": "StatefulPartitionedCall/LogicalAnd_1", "op": "LogicalAnd", "input": ["StatefulPartitionedCall/GreaterEqual_3", "StatefulPartitionedCall/LessEqual_1"]}, {"name": "StatefulPartitionedCall/LogicalAnd_2", "op": "LogicalAnd", "input": ["StatefulPartitionedCall/LogicalAnd", "StatefulPartitionedCall/LogicalAnd_1"]}, {"name": "StatefulPartitionedCall/Select_3", "op": "Select", "input": ["StatefulPartitionedCall/LogicalAnd_2", "StatefulPartitionedCall/Select_2", "StatefulPartitionedCall/zeros_like"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/ExpandDims_17", "op": "ExpandDims", "input": ["StatefulPartitionedCall/Select_3", "StatefulPartitionedCall/ExpandDims_17/dim"], "attr": {"Tdim": {"type": "DT_INT32"}, "T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/Greater_5", "op": "Greater", "input": ["StatefulPartitionedCall/Select_3", "StatefulPartitionedCall/Greater_5/y"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/concat_2", "op": "ConcatV2", "input": ["StatefulPartitionedCall/map/TensorArrayV2Stack/TensorListStack", "StatefulPartitionedCall/ExpandDims_17", "StatefulPartitionedCall/concat_2/axis"], "attr": {"N": {"i": "2"}, "Tidx": {"type": "DT_INT32"}, "T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/Cast_23", "op": "Cast", "input": ["StatefulPartitionedCall/Greater_5"], "attr": {"Truncate": {"b": false}, "DstT": {"type": "DT_FLOAT"}, "SrcT": {"type": "DT_BOOL"}}}, {"name": "StatefulPartitionedCall/Select_4", "op": "Select", "input": ["StatefulPartitionedCall/Greater_5", "StatefulPartitionedCall/Select_3", "StatefulPartitionedCall/zeros_like_1"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/Reshape_37", "op": "Reshape", "input": ["StatefulPartitionedCall/concat_2", "StatefulPartitionedCall/Reshape_37/shape"], "attr": {"T": {"type": "DT_FLOAT"}, "Tshape": {"type": "DT_INT32"}}}, {"name": "StatefulPartitionedCall/mul_15", "op": "Mul", "input": ["StatefulPartitionedCall/Cast_22", "StatefulPartitionedCall/Cast_23"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/mul_17", "op": "Mul", "input": ["StatefulPartitionedCall/mul_16", "StatefulPartitionedCall/Select_4"], "attr": {"T": {"type": "DT_FLOAT"}, "_grappler_ArithmeticOptimizer_MinimizeBroadcasts": {"b": true}}}, {"name": "StatefulPartitionedCall/Sum_4", "op": "Sum", "input": ["StatefulPartitionedCall/mul_15", "StatefulPartitionedCall/Sum_4/reduction_indices"], "attr": {"Tidx": {"type": "DT_INT32"}, "keep_dims": {"b": false}, "T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/Sum_5", "op": "Sum", "input": ["StatefulPartitionedCall/mul_17", "StatefulPartitionedCall/Sum_5/reduction_indices"], "attr": {"Tidx": {"type": "DT_INT32"}, "keep_dims": {"b": false}, "T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/Maximum_2", "op": "Maximum", "input": ["StatefulPartitionedCall/Sum_4", "StatefulPartitionedCall/Maximum_2/y"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/truediv_10", "op": "Reciprocal", "input": ["StatefulPartitionedCall/Maximum_2"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/mul_18", "op": "Mul", "input": ["StatefulPartitionedCall/truediv_10", "StatefulPartitionedCall/Sum_5"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/Select_5", "op": "Select", "input": ["StatefulPartitionedCall/Equal_2", "StatefulPartitionedCall/mul_18", "StatefulPartitionedCall/TopKV2"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "StatefulPartitionedCall/strided_slice_23", "op": "StridedSlice", "input": ["StatefulPartitionedCall/Select_5", "StatefulPartitionedCall/strided_slice_23/stack", "StatefulPartitionedCall/strided_slice_23/stack_1", "StatefulPartitionedCall/strided_slice_23/stack_2"], "attr": {"T": {"type": "DT_FLOAT"}, "Index": {"type": "DT_INT32"}, "shrink_axis_mask": {"i": "0"}, "ellipsis_mask": {"i": "0"}, "begin_mask": {"i": "3"}, "new_axis_mask": {"i": "4"}, "end_mask": {"i": "3"}}}, {"name": "StatefulPartitionedCall/concat_3", "op": "ConcatV2", "input": ["StatefulPartitionedCall/Reshape_37", "StatefulPartitionedCall/clip_by_value_4", "StatefulPartitionedCall/strided_slice_23", "StatefulPartitionedCall/concat_3/axis"], "attr": {"Tidx": {"type": "DT_INT32"}, "T": {"type": "DT_FLOAT"}, "N": {"i": "3"}}}, {"name": "Identity", "op": "Identity", "input": ["StatefulPartitionedCall/concat_3"], "attr": {"T": {"type": "DT_FLOAT"}}}], "library": {"function": [{"signature": {"name": "__inference_map_while_body_10122_30691", "inputArg": [{"name": "map_while_map_while_loop_counter", "type": "DT_INT32"}, {"name": "map_while_map_while_maximum_iterations", "type": "DT_INT32"}, {"name": "map_while_placeholder", "type": "DT_INT32"}, {"name": "map_while_placeholder_1", "type": "DT_VARIANT"}, {"name": "map_while_tensorarrayv2read_tensorlistgetitem_map_tensorarrayunstack_tensorlistfromtensor_0", "type": "DT_VARIANT"}, {"name": "map_while_tensorarrayv2read_1_tensorlistgetitem_map_tensorarrayunstack_1_tensorlistfromtensor_0", "type": "DT_VARIANT"}], "outputArg": [{"name": "map_while_identity", "type": "DT_INT32"}, {"name": "map_while_identity_1", "type": "DT_INT32"}, {"name": "map_while_identity_2", "type": "DT_INT32"}, {"name": "map_while_identity_3", "type": "DT_VARIANT"}, {"name": "map_while_tensorarrayv2read_tensorlistgetitem_map_tensorarrayunstack_tensorlistfromtensor", "type": "DT_VARIANT"}, {"name": "map_while_tensorarrayv2read_1_tensorlistgetitem_map_tensorarrayunstack_1_tensorlistfromtensor", "type": "DT_VARIANT"}]}, "nodeDef": [{"name": "__inference_map_while_body_10122_30691/map/while/add/y", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "__inference_map_while_body_10122_30691/map/while/ClipToWindow/split/split_dim", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "__inference_map_while_body_10122_30691/map/while/TensorArrayV2Read/TensorListGetItem/element_shape", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "3"}]}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "__inference_map_while_body_10122_30691/map/while/TensorArrayV2Read_1/TensorListGetItem/element_shape", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "1"}]}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "__inference_map_while_body_10122_30691/map/while/ClipToWindow/concat/axis", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "__inference_map_while_body_10122_30691/map/while/add_1/y", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "map/while/add", "op": "AddV2", "input": ["map_while_placeholder", "__inference_map_while_body_10122_30691/map/while/add/y:output:0"], "attr": {"T": {"type": "DT_INT32"}}}, {"name": "map/while/TensorArrayV2Read/TensorListGetItem", "op": "TensorListGetItem", "input": ["map_while_tensorarrayv2read_tensorlistgetitem_map_tensorarrayunstack_tensorlistfromtensor_0", "map_while_placeholder", "__inference_map_while_body_10122_30691/map/while/TensorArrayV2Read/TensorListGetItem/element_shape:output:0"], "attr": {"element_dtype": {"type": "DT_FLOAT"}}}, {"name": "map/while/TensorArrayV2Read_1/TensorListGetItem", "op": "TensorListGetItem", "input": ["map_while_tensorarrayv2read_1_tensorlistgetitem_map_tensorarrayunstack_1_tensorlistfromtensor_0", "map_while_placeholder", "__inference_map_while_body_10122_30691/map/while/TensorArrayV2Read_1/TensorListGetItem/element_shape:output:0"], "attr": {"element_dtype": {"type": "DT_FLOAT"}}}, {"name": "map/while/add_1", "op": "AddV2", "input": ["map_while_map_while_loop_counter", "__inference_map_while_body_10122_30691/map/while/add_1/y:output:0"], "attr": {"T": {"type": "DT_INT32"}}}, {"name": "map/while/ClipToWindow/split", "op": "Split", "input": ["__inference_map_while_body_10122_30691/map/while/ClipToWindow/split/split_dim:output:0", "map/while/TensorArrayV2Read/TensorListGetItem:item:0"], "attr": {"T": {"type": "DT_FLOAT"}, "num_split": {"i": "2"}}}, {"name": "map/while/ClipToWindow/unstack", "op": "Unpack", "input": ["map/while/TensorArrayV2Read_1/TensorListGetItem:item:0"], "attr": {"T": {"type": "DT_FLOAT"}, "num": {"i": "4"}, "axis": {"i": "0"}}}, {"name": "map/while/ClipToWindow/Minimum", "op": "Minimum", "input": ["map/while/ClipToWindow/split:output:0", "map/while/ClipToWindow/unstack:output:2"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "map/while/ClipToWindow/Minimum_1", "op": "Minimum", "input": ["map/while/ClipToWindow/split:output:1", "map/while/ClipToWindow/unstack:output:3"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "map/while/ClipToWindow/Maximum", "op": "Maximum", "input": ["map/while/ClipToWindow/Minimum:z:0", "map/while/ClipToWindow/unstack:output:0"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "map/while/ClipToWindow/Maximum_1", "op": "Maximum", "input": ["map/while/ClipToWindow/Minimum_1:z:0", "map/while/ClipToWindow/unstack:output:1"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "map/while/ClipToWindow/concat", "op": "ConcatV2", "input": ["map/while/ClipToWindow/Maximum:z:0", "map/while/ClipToWindow/Maximum_1:z:0", "__inference_map_while_body_10122_30691/map/while/ClipToWindow/concat/axis:output:0"], "attr": {"T": {"type": "DT_FLOAT"}, "N": {"i": "2"}, "Tidx": {"type": "DT_INT32"}}}, {"name": "map/while/TensorArrayV2Write/TensorListSetItem", "op": "TensorListSetItem", "input": ["map_while_placeholder_1", "map_while_placeholder", "map/while/ClipToWindow/concat:output:0"], "attr": {"element_dtype": {"type": "DT_FLOAT"}}}], "ret": {"map_while_identity": "map/while/add_1:z:0", "map_while_identity_1": "map_while_map_while_maximum_iterations", "map_while_identity_2": "map/while/add:z:0", "map_while_tensorarrayv2read_tensorlistgetitem_map_tensorarrayunstack_tensorlistfromtensor": "map_while_tensorarrayv2read_tensorlistgetitem_map_tensorarrayunstack_tensorlistfromtensor_0", "map_while_identity_3": "map/while/TensorArrayV2Write/TensorListSetItem:output_handle:0", "map_while_tensorarrayv2read_1_tensorlistgetitem_map_tensorarrayunstack_1_tensorlistfromtensor": "map_while_tensorarrayv2read_1_tensorlistgetitem_map_tensorarrayunstack_1_tensorlistfromtensor_0"}, "attr": {"_construction_context": {"s": "a0VhZ2VyUnVudGltZQ=="}}, "argAttr": {"0": {"attr": {"_output_shapes": {"list": {"shape": [{}]}}}}, "1": {"attr": {"_output_shapes": {"list": {"shape": [{}]}}}}, "2": {"attr": {"_output_shapes": {"list": {"shape": [{}]}}}}, "3": {"attr": {"_output_shapes": {"list": {"shape": [{}]}}}}, "4": {"attr": {"_output_shapes": {"list": {"shape": [{}]}}}}, "5": {"attr": {"_output_shapes": {"list": {"shape": [{}]}}}}}}, {"signature": {"name": "__inference_map_while_cond_10121_3503", "inputArg": [{"name": "map_while_map_while_loop_counter", "type": "DT_INT32"}, {"name": "map_while_map_while_maximum_iterations", "type": "DT_INT32"}, {"name": "map_while_placeholder", "type": "DT_INT32"}, {"name": "map_while_placeholder_1", "type": "DT_VARIANT"}, {"name": "map_while_map_while_cond_10121___redundant_placeholder0", "type": "DT_VARIANT"}, {"name": "map_while_map_while_cond_10121___redundant_placeholder1", "type": "DT_VARIANT"}], "outputArg": [{"name": "map_while_identity", "type": "DT_BOOL"}]}, "nodeDef": [{"name": "__inference_map_while_cond_10121_3503/map/while/Less/y", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "map/while/Less_1", "op": "Less", "input": ["map_while_map_while_loop_counter", "map_while_map_while_maximum_iterations"], "attr": {"T": {"type": "DT_INT32"}}}, {"name": "map/while/Less", "op": "Less", "input": ["map_while_placeholder", "__inference_map_while_cond_10121_3503/map/while/Less/y:output:0"], "attr": {"T": {"type": "DT_INT32"}}}, {"name": "map/while/LogicalAnd", "op": "LogicalAnd", "input": ["map/while/Less_1:z:0", "map/while/Less:z:0"]}], "ret": {"map_while_identity": "map/while/LogicalAnd:z:0"}, "attr": {"_construction_context": {"s": "a0VhZ2VyUnVudGltZQ=="}}, "argAttr": {"0": {"attr": {"_output_shapes": {"list": {"shape": [{}]}}}}, "1": {"attr": {"_output_shapes": {"list": {"shape": [{}]}}}}, "2": {"attr": {"_output_shapes": {"list": {"shape": [{}]}}}}, "3": {"attr": {"_output_shapes": {"list": {"shape": [{}]}}}}, "4": {"attr": {"_output_shapes": {"list": {"shape": [{"unknownRank": true}]}}}}, "5": {"attr": {"_output_shapes": {"list": {"shape": [{"unknownRank": true}]}}}}}}]}, "versions": {"producer": 716, "minConsumer": 12}}, "weightsManifest": [{"paths": ["group1-shard1of3.bin", "group1-shard2of3.bin", "group1-shard3of3.bin"], "weights": [{"name": "StatefulPartitionedCall/map/while/loop_counter", "shape": [], "dtype": "int32"}, {"name": "StatefulPartitionedCall/map/while/maximum_iterations", "shape": [], "dtype": "int32"}, {"name": "StatefulPartitionedCall/map/Const", "shape": [], "dtype": "int32"}, {"name": "StatefulPartitionedCall/map/TensorArrayV2_2/element_shape", "shape": [3], "dtype": "int32"}, {"name": "StatefulPartitionedCall/map/TensorArrayV2_2/num_elements", "shape": [], "dtype": "int32"}, {"name": "StatefulPartitionedCall/map/TensorArrayUnstack/TensorListFromTensor/element_shape", "shape": [3], "dtype": "int32"}, {"name": "StatefulPartitionedCall/Tile_16", "shape": [1, 4], "dtype": "float32"}, {"name": "StatefulPartitionedCall/map/TensorArrayUnstack_1/TensorListFromTensor/element_shape", "shape": [1], "dtype": "int32"}, {"name": "StatefulPartitionedCall/map/TensorArrayV2Stack/TensorListStack/element_shape", "shape": [3], "dtype": "int32"}, {"name": "StatefulPartitionedCall/ExpandDims_17/dim", "shape": [], "dtype": "int32"}, {"name": "StatefulPartitionedCall/concat_2/axis", "shape": [], "dtype": "int32"}, {"name": "StatefulPartitionedCall/Reshape_37/shape", "shape": [3], "dtype": "int32"}, {"name": "StatefulPartitionedCall/mul_5", "shape": [1, 1, 4], "dtype": "float32"}, {"name": "StatefulPartitionedCall/clip_by_value_4/Minimum/y", "shape": [], "dtype": "float32"}, {"name": "StatefulPartitionedCall/clip_by_value_4/y", "shape": [], "dtype": "float32"}, {"name": "StatefulPartitionedCall/x_2", "shape": [], "dtype": "int32"}, {"name": "StatefulPartitionedCall/Sum_4/reduction_indices", "shape": [], "dtype": "int32"}, {"name": "StatefulPartitionedCall/Maximum_2/y", "shape": [], "dtype": "float32"}, {"name": "StatefulPartitionedCall/strided_slice_22/stack", "shape": [3], "dtype": "int32"}, {"name": "StatefulPartitionedCall/strided_slice_22/stack_1", "shape": [3], "dtype": "int32"}, {"name": "StatefulPartitionedCall/strided_slice_22/stack_2", "shape": [3], "dtype": "int32"}, {"name": "StatefulPartitionedCall/strided_slice_20/stack", "shape": [3], "dtype": "int32"}, {"name": "StatefulPartitionedCall/strided_slice_20/stack_1", "shape": [3], "dtype": "int32"}, {"name": "StatefulPartitionedCall/strided_slice_20/stack_2", "shape": [3], "dtype": "int32"}, {"name": "StatefulPartitionedCall/Tile_17/multiples", "shape": [3], "dtype": "int32"}, {"name": "StatefulPartitionedCall/x", "shape": [], "dtype": "int32"}, {"name": "StatefulPartitionedCall/Greater_5/y", "shape": [], "dtype": "float32"}, {"name": "StatefulPartitionedCall/strided_slice_16/stack", "shape": [4], "dtype": "int32"}, {"name": "StatefulPartitionedCall/strided_slice_16/stack_1", "shape": [4], "dtype": "int32"}, {"name": "StatefulPartitionedCall/strided_slice_16/stack_2", "shape": [4], "dtype": "int32"}, {"name": "StatefulPartitionedCall/GreaterEqual_2/y", "shape": [], "dtype": "float32"}, {"name": "StatefulPartitionedCall/strided_slice_17/stack", "shape": [4], "dtype": "int32"}, {"name": "StatefulPartitionedCall/strided_slice_17/stack_1", "shape": [4], "dtype": "int32"}, {"name": "StatefulPartitionedCall/strided_slice_17/stack_2", "shape": [4], "dtype": "int32"}, {"name": "StatefulPartitionedCall/LessEqual/y", "shape": [], "dtype": "float32"}, {"name": "StatefulPartitionedCall/strided_slice_18/stack", "shape": [4], "dtype": "int32"}, {"name": "StatefulPartitionedCall/strided_slice_18/stack_1", "shape": [4], "dtype": "int32"}, {"name": "StatefulPartitionedCall/strided_slice_18/stack_2", "shape": [4], "dtype": "int32"}, {"name": "StatefulPartitionedCall/GreaterEqual_3/y", "shape": [], "dtype": "float32"}, {"name": "StatefulPartitionedCall/ExpandDims_16/dim", "shape": [], "dtype": "int32"}, {"name": "StatefulPartitionedCall/Tile_15/multiples", "shape": [4], "dtype": "int32"}, {"name": "StatefulPartitionedCall/Reshape_36", "shape": [1, 1, 1, 2], "dtype": "float32"}, {"name": "StatefulPartitionedCall/strided_slice_19/stack", "shape": [4], "dtype": "int32"}, {"name": "StatefulPartitionedCall/strided_slice_19/stack_1", "shape": [4], "dtype": "int32"}, {"name": "StatefulPartitionedCall/strided_slice_19/stack_2", "shape": [4], "dtype": "int32"}, {"name": "StatefulPartitionedCall/LessEqual_1/y", "shape": [], "dtype": "float32"}, {"name": "StatefulPartitionedCall/strided_slice_12/stack", "shape": [4], "dtype": "int32"}, {"name": "StatefulPartitionedCall/strided_slice_12/stack_1", "shape": [4], "dtype": "int32"}, {"name": "StatefulPartitionedCall/strided_slice_12/stack_2", "shape": [4], "dtype": "int32"}, {"name": "StatefulPartitionedCall/strided_slice_13/stack", "shape": [4], "dtype": "int32"}, {"name": "StatefulPartitionedCall/strided_slice_13/stack_1", "shape": [4], "dtype": "int32"}, {"name": "StatefulPartitionedCall/strided_slice_13/stack_2", "shape": [4], "dtype": "int32"}, {"name": "StatefulPartitionedCall/strided_slice_14/stack", "shape": [4], "dtype": "int32"}, {"name": "StatefulPartitionedCall/strided_slice_14/stack_1", "shape": [4], "dtype": "int32"}, {"name": "StatefulPartitionedCall/strided_slice_14/stack_2", "shape": [4], "dtype": "int32"}, {"name": "StatefulPartitionedCall/Reshape_32/shape", "shape": [4], "dtype": "int32"}, {"name": "StatefulPartitionedCall/transpose_6/perm", "shape": [4], "dtype": "int32"}, {"name": "StatefulPartitionedCall/strided_slice_15/stack", "shape": [4], "dtype": "int32"}, {"name": "StatefulPartitionedCall/strided_slice_15/stack_1", "shape": [4], "dtype": "int32"}, {"name": "StatefulPartitionedCall/strided_slice_15/stack_2", "shape": [4], "dtype": "int32"}, {"name": "StatefulPartitionedCall/Less_6/y", "shape": [], "dtype": "float32"}, {"name": "StatefulPartitionedCall/Min/reduction_indices", "shape": [], "dtype": "int32"}, {"name": "StatefulPartitionedCall/ScaleHeightWidth/mul", "shape": [], "dtype": "float32"}, {"name": "StatefulPartitionedCall/ScaleHeightWidth/mul_4", "shape": [], "dtype": "float32"}, {"name": "ConstantFolding/StatefulPartitionedCall/ScaleHeightWidth/get_center_coordinates_and_sizes/truediv_recip", "shape": [], "dtype": "float32"}, {"name": "StatefulPartitionedCall/ScaleHeightWidth/mul_2", "shape": [], "dtype": "float32"}, {"name": "ConstantFolding/StatefulPartitionedCall/ScaleHeightWidth/get_center_coordinates_and_sizes/truediv_1_recip", "shape": [], "dtype": "float32"}, {"name": "StatefulPartitionedCall/ScaleHeightWidth/mul_6", "shape": [], "dtype": "float32"}, {"name": "ConstantFolding/StatefulPartitionedCall/truediv_2_recip", "shape": [], "dtype": "float32"}, {"name": "StatefulPartitionedCall/clip_by_value/y", "shape": [], "dtype": "float32"}, {"name": "ConstantFolding/StatefulPartitionedCall/truediv_3_recip", "shape": [], "dtype": "float32"}, {"name": "StatefulPartitionedCall/clip_by_value_1/y", "shape": [], "dtype": "float32"}, {"name": "ConstantFolding/StatefulPartitionedCall/truediv_4_recip", "shape": [], "dtype": "float32"}, {"name": "StatefulPartitionedCall/Cast_4", "shape": [], "dtype": "float32"}, {"name": "StatefulPartitionedCall/clip_by_value_2/y", "shape": [], "dtype": "float32"}, {"name": "StatefulPartitionedCall/box_offset_0/separable_conv2d_5/separable_conv2d/ReadVariableOp", "shape": [3, 3, 24, 1], "dtype": "float32"}, {"name": "StatefulPartitionedCall/box_offset_0/separable_conv2d_5/separable_conv2d/ReadVariableOp_1", "shape": [1, 1, 24, 96], "dtype": "float32"}, {"name": "StatefulPartitionedCall/box_offset_0/separable_conv2d_5/BiasAdd/ReadVariableOp", "shape": [96], "dtype": "float32"}, {"name": "StatefulPartitionedCall/box_offset_0/conv2d_6/Conv2D/ReadVariableOp", "shape": [1, 1, 96, 2], "dtype": "float32"}, {"name": "StatefulPartitionedCall/box_offset_0/conv2d_6/BiasAdd/ReadVariableOp", "shape": [2], "dtype": "float32"}, {"name": "StatefulPartitionedCall/Reshape_7/shape", "shape": [3], "dtype": "int32"}, {"name": "StatefulPartitionedCall/box_scale_0/separable_conv2d_4/separable_conv2d/ReadVariableOp", "shape": [3, 3, 24, 1], "dtype": "float32"}, {"name": "StatefulPartitionedCall/box_scale_0/separable_conv2d_4/separable_conv2d/ReadVariableOp_1", "shape": [1, 1, 24, 96], "dtype": "float32"}, {"name": "StatefulPartitionedCall/box_scale_0/separable_conv2d_4/BiasAdd/ReadVariableOp", "shape": [96], "dtype": "float32"}, {"name": "StatefulPartitionedCall/box_scale_0/conv2d_5/Conv2D/ReadVariableOp", "shape": [1, 1, 96, 2], "dtype": "float32"}, {"name": "StatefulPartitionedCall/box_scale_0/conv2d_5/BiasAdd/ReadVariableOp", "shape": [2], "dtype": "float32"}, {"name": "StatefulPartitionedCall/Reshape_3", "shape": [10], "dtype": "int32"}, {"name": "StatefulPartitionedCall/Reshape_4/shape", "shape": [1], "dtype": "int32"}, {"name": "StatefulPartitionedCall/Reshape_5/shape", "shape": [1], "dtype": "int32"}, {"name": "StatefulPartitionedCall/Reshape_6/shape", "shape": [3], "dtype": "int32"}, {"name": "StatefulPartitionedCall/Maximum/y", "shape": [], "dtype": "float32"}, {"name": "ConstantFolding/StatefulPartitionedCall/truediv_5_recip", "shape": [], "dtype": "float32"}, {"name": "StatefulPartitionedCall/Cast_5", "shape": [], "dtype": "float32"}, {"name": "StatefulPartitionedCall/clip_by_value_3/y", "shape": [], "dtype": "float32"}, {"name": "StatefulPartitionedCall/strided_slice_10/stack", "shape": [2], "dtype": "int32"}, {"name": "StatefulPartitionedCall/strided_slice_10/stack_1", "shape": [2], "dtype": "int32"}, {"name": "StatefulPartitionedCall/strided_slice_10/stack_2", "shape": [2], "dtype": "int32"}, {"name": "StatefulPartitionedCall/Reshape_34/shape", "shape": [2], "dtype": "int32"}, {"name": "StatefulPartitionedCall/ScaleHeightWidth/get_center_coordinates_and_sizes/transpose/perm", "shape": [2], "dtype": "int32"}, {"name": "StatefulPartitionedCall/Reshape_35/shape", "shape": [3], "dtype": "int32"}, {"name": "StatefulPartitionedCall/ExpandDims_15/dim", "shape": [], "dtype": "int32"}, {"name": "StatefulPartitionedCall/Tile_14/multiples", "shape": [4], "dtype": "int32"}, {"name": "StatefulPartitionedCall/mul_12/y", "shape": [], "dtype": "float32"}, {"name": "StatefulPartitionedCall/Greater_4/y", "shape": [], "dtype": "int32"}, {"name": "StatefulPartitionedCall/mul_13", "shape": [1, 10, 17], "dtype": "float32"}, {"name": "StatefulPartitionedCall/Reshape_29", "shape": [170], "dtype": "int32"}, {"name": "StatefulPartitionedCall/Reshape_30", "shape": [170], "dtype": "int32"}, {"name": "StatefulPartitionedCall/ExpandDims_12/dim", "shape": [], "dtype": "int32"}, {"name": "StatefulPartitionedCall/Tile_11/multiples", "shape": [4], "dtype": "int32"}, {"name": "StatefulPartitionedCall/Tile_6", "shape": [1, 100, 17], "dtype": "int32"}, {"name": "StatefulPartitionedCall/transpose_2/perm", "shape": [3], "dtype": "int32"}, {"name": "StatefulPartitionedCall/GreaterEqual/y", "shape": [], "dtype": "float32"}, {"name": "StatefulPartitionedCall/Sum_1/reduction_indices", "shape": [], "dtype": "int32"}, {"name": "StatefulPartitionedCall/ExpandDims_8/dim", "shape": [], "dtype": "int32"}, {"name": "StatefulPartitionedCall/Tile_7/multiples", "shape": [3], "dtype": "int32"}, {"name": "StatefulPartitionedCall/ExpandDims_11/dim", "shape": [], "dtype": "int32"}, {"name": "StatefulPartitionedCall/Tile_10/multiples", "shape": [4], "dtype": "int32"}, {"name": "StatefulPartitionedCall/mul_11", "shape": [1, 10, 100, 17], "dtype": "float32"}, {"name": "StatefulPartitionedCall/ExpandDims_3/dim", "shape": [], "dtype": "int32"}, {"name": "StatefulPartitionedCall/ExpandDims_4/dim", "shape": [], "dtype": "int32"}, {"name": "StatefulPartitionedCall/kpt_regress_0/separable_conv2d_7/separable_conv2d/ReadVariableOp", "shape": [3, 3, 24, 1], "dtype": "float32"}, {"name": "StatefulPartitionedCall/kpt_regress_0/separable_conv2d_7/separable_conv2d/ReadVariableOp_1", "shape": [1, 1, 24, 96], "dtype": "float32"}, {"name": "StatefulPartitionedCall/kpt_regress_0/separable_conv2d_7/BiasAdd/ReadVariableOp", "shape": [96], "dtype": "float32"}, {"name": "StatefulPartitionedCall/kpt_regress_0/conv2d_8/Conv2D/ReadVariableOp", "shape": [1, 1, 96, 34], "dtype": "float32"}, {"name": "StatefulPartitionedCall/kpt_regress_0/conv2d_8/BiasAdd/ReadVariableOp", "shape": [34], "dtype": "float32"}, {"name": "StatefulPartitionedCall/strided_slice_7/stack", "shape": [2], "dtype": "int32"}, {"name": "StatefulPartitionedCall/strided_slice_7/stack_1", "shape": [2], "dtype": "int32"}, {"name": "StatefulPartitionedCall/strided_slice_7/stack_2", "shape": [2], "dtype": "int32"}, {"name": "StatefulPartitionedCall/Reshape_8", "shape": [10], "dtype": "int32"}, {"name": "StatefulPartitionedCall/strided_slice_8/stack", "shape": [2], "dtype": "int32"}, {"name": "StatefulPartitionedCall/strided_slice_8/stack_1", "shape": [2], "dtype": "int32"}, {"name": "StatefulPartitionedCall/strided_slice_8/stack_2", "shape": [2], "dtype": "int32"}, {"name": "StatefulPartitionedCall/Reshape_9/shape", "shape": [1], "dtype": "int32"}, {"name": "StatefulPartitionedCall/floordiv_1/y", "shape": [], "dtype": "int32"}, {"name": "StatefulPartitionedCall/mul_3/y", "shape": [], "dtype": "int32"}, {"name": "StatefulPartitionedCall/strided_slice_9/stack", "shape": [2], "dtype": "int32"}, {"name": "StatefulPartitionedCall/strided_slice_9/stack_1", "shape": [2], "dtype": "int32"}, {"name": "StatefulPartitionedCall/strided_slice_9/stack_2", "shape": [2], "dtype": "int32"}, {"name": "StatefulPartitionedCall/Reshape_10/shape", "shape": [1], "dtype": "int32"}, {"name": "StatefulPartitionedCall/Reshape_11/shape", "shape": [4], "dtype": "int32"}, {"name": "StatefulPartitionedCall/ExpandDims_9/dim", "shape": [], "dtype": "int32"}, {"name": "StatefulPartitionedCall/Tile_8/multiples", "shape": [5], "dtype": "int32"}, {"name": "StatefulPartitionedCall/kpt_offset_0/separable_conv2d_8/separable_conv2d/ReadVariableOp", "shape": [3, 3, 24, 1], "dtype": "float32"}, {"name": "StatefulPartitionedCall/kpt_offset_0/separable_conv2d_8/separable_conv2d/ReadVariableOp_1", "shape": [1, 1, 24, 96], "dtype": "float32"}, {"name": "StatefulPartitionedCall/kpt_offset_0/separable_conv2d_8/BiasAdd/ReadVariableOp", "shape": [96], "dtype": "float32"}, {"name": "StatefulPartitionedCall/kpt_offset_0/conv2d_9/Conv2D/ReadVariableOp", "shape": [1, 1, 96, 34], "dtype": "float32"}, {"name": "StatefulPartitionedCall/kpt_offset_0/conv2d_9/BiasAdd/ReadVariableOp", "shape": [34], "dtype": "float32"}, {"name": "StatefulPartitionedCall/strided_slice_6/stack", "shape": [2], "dtype": "int32"}, {"name": "StatefulPartitionedCall/strided_slice_6/stack_1", "shape": [2], "dtype": "int32"}, {"name": "StatefulPartitionedCall/strided_slice_6/stack_2", "shape": [2], "dtype": "int32"}, {"name": "StatefulPartitionedCall/Reshape_17", "shape": [1700], "dtype": "int32"}, {"name": "StatefulPartitionedCall/Reshape_18/shape", "shape": [1], "dtype": "int32"}, {"name": "StatefulPartitionedCall/floordiv_6/y", "shape": [], "dtype": "int32"}, {"name": "StatefulPartitionedCall/floordiv_4/y", "shape": [], "dtype": "int32"}, {"name": "StatefulPartitionedCall/floordiv_5/y", "shape": [], "dtype": "int32"}, {"name": "StatefulPartitionedCall/mul_8/y", "shape": [], "dtype": "int32"}, {"name": "StatefulPartitionedCall/Reshape_19/shape", "shape": [1], "dtype": "int32"}, {"name": "StatefulPartitionedCall/Reshape_21/shape", "shape": [4], "dtype": "int32"}, {"name": "StatefulPartitionedCall/Reshape_22", "shape": [1700], "dtype": "int32"}, {"name": "StatefulPartitionedCall/Reshape_23", "shape": [1700], "dtype": "int32"}, {"name": "StatefulPartitionedCall/mul_7/x", "shape": [], "dtype": "int32"}, {"name": "StatefulPartitionedCall/kpt_heatmap_0/separable_conv2d_6/separable_conv2d/ReadVariableOp", "shape": [3, 3, 24, 1], "dtype": "float32"}, {"name": "StatefulPartitionedCall/kpt_heatmap_0/separable_conv2d_6/separable_conv2d/ReadVariableOp_1", "shape": [1, 1, 24, 96], "dtype": "float32"}, {"name": "StatefulPartitionedCall/kpt_heatmap_0/separable_conv2d_6/BiasAdd/ReadVariableOp", "shape": [96], "dtype": "float32"}, {"name": "StatefulPartitionedCall/kpt_heatmap_0/conv2d_7/Conv2D/ReadVariableOp", "shape": [1, 1, 96, 17], "dtype": "float32"}, {"name": "StatefulPartitionedCall/kpt_heatmap_0/conv2d_7/BiasAdd/ReadVariableOp", "shape": [17], "dtype": "float32"}, {"name": "StatefulPartitionedCall/strided_slice_5/stack", "shape": [2], "dtype": "int32"}, {"name": "StatefulPartitionedCall/strided_slice_5/stack_1", "shape": [2], "dtype": "int32"}, {"name": "StatefulPartitionedCall/strided_slice_5/stack_2", "shape": [2], "dtype": "int32"}, {"name": "StatefulPartitionedCall/Less_3/y", "shape": [], "dtype": "float32"}, {"name": "StatefulPartitionedCall/transpose/perm", "shape": [4], "dtype": "int32"}, {"name": "StatefulPartitionedCall/Reshape_14/shape", "shape": [3], "dtype": "int32"}, {"name": "StatefulPartitionedCall/TopKV2_1/k", "shape": [], "dtype": "int32"}, {"name": "StatefulPartitionedCall/strided_slice_11", "shape": [1, 17, 1], "dtype": "int32"}, {"name": "StatefulPartitionedCall/Reshape_16/shape", "shape": [2], "dtype": "int32"}, {"name": "StatefulPartitionedCall/floordiv_7/y", "shape": [], "dtype": "int32"}, {"name": "StatefulPartitionedCall/mul_9/y", "shape": [], "dtype": "int32"}, {"name": "StatefulPartitionedCall/Reshape_24/shape", "shape": [1], "dtype": "int32"}, {"name": "StatefulPartitionedCall/Reshape_25/shape", "shape": [3], "dtype": "int32"}, {"name": "StatefulPartitionedCall/Reshape_26/shape", "shape": [4], "dtype": "int32"}, {"name": "StatefulPartitionedCall/transpose_1/perm", "shape": [4], "dtype": "int32"}, {"name": "StatefulPartitionedCall/ExpandDims_10/dim", "shape": [], "dtype": "int32"}, {"name": "StatefulPartitionedCall/Tile_9/multiples", "shape": [5], "dtype": "int32"}, {"name": "StatefulPartitionedCall/Sum_2/reduction_indices", "shape": [], "dtype": "int32"}, {"name": "StatefulPartitionedCall/add_11/y", "shape": [], "dtype": "float32"}, {"name": "StatefulPartitionedCall/ArgMax/dimension", "shape": [], "dtype": "int32"}, {"name": "StatefulPartitionedCall/transpose_5/perm", "shape": [3], "dtype": "int32"}, {"name": "StatefulPartitionedCall/Reshape_31/shape", "shape": [1], "dtype": "int32"}, {"name": "StatefulPartitionedCall/Reshape_33/shape", "shape": [3], "dtype": "int32"}, {"name": "StatefulPartitionedCall/transpose_7/perm", "shape": [3], "dtype": "int32"}, {"name": "StatefulPartitionedCall/zeros_like", "shape": [1, 10, 17], "dtype": "float32"}, {"name": "StatefulPartitionedCall/zeros_like_1", "shape": [1, 10, 17], "dtype": "float32"}, {"name": "StatefulPartitionedCall/Sum_5/reduction_indices", "shape": [], "dtype": "int32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/conv2d/Conv2D/ReadVariableOp", "shape": [1, 1, 1280, 64], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/conv2d/BiasAdd/ReadVariableOp", "shape": [64], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/up_sampling2d/mul", "shape": [2], "dtype": "int32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/conv2d_1/Conv2D/ReadVariableOp", "shape": [1, 1, 64, 64], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/conv2d_1/BiasAdd/ReadVariableOp", "shape": [64], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/separable_conv2d/separable_conv2d/ReadVariableOp", "shape": [3, 3, 64, 1], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/up_sampling2d_1/mul", "shape": [2], "dtype": "int32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/conv2d_2/Conv2D/ReadVariableOp", "shape": [1, 1, 32, 32], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/conv2d_2/BiasAdd/ReadVariableOp", "shape": [32], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/separable_conv2d_1/separable_conv2d/ReadVariableOp", "shape": [3, 3, 32, 1], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/up_sampling2d_2/mul", "shape": [2], "dtype": "int32"}, {"name": "StatefulPartitionedCall/ResizeImage/resize/ExpandDims/dim", "shape": [], "dtype": "int32"}, {"name": "StatefulPartitionedCall/Reshape", "shape": [1, 1, 1, 3], "dtype": "float32"}, {"name": "StatefulPartitionedCall/truediv", "shape": [1, 1, 1, 3], "dtype": "float32"}, {"name": "StatefulPartitionedCall/sub_1/y", "shape": [], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/conv2d_3/Conv2D/ReadVariableOp", "shape": [1, 1, 24, 24], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/conv2d_3/BiasAdd/ReadVariableOp", "shape": [24], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/separable_conv2d_2/separable_conv2d/ReadVariableOp", "shape": [3, 3, 24, 1], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_0/separable_conv2d_3/separable_conv2d/ReadVariableOp", "shape": [3, 3, 24, 1], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_0/separable_conv2d_3/separable_conv2d/ReadVariableOp_1", "shape": [1, 1, 24, 96], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_0/separable_conv2d_3/BiasAdd/ReadVariableOp", "shape": [96], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_0/conv2d_4/Conv2D/ReadVariableOp", "shape": [1, 1, 96, 1], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_0/conv2d_4/BiasAdd/ReadVariableOp", "shape": [1], "dtype": "float32"}, {"name": "StatefulPartitionedCall/Less_2/y", "shape": [], "dtype": "float32"}, {"name": "StatefulPartitionedCall/Reshape_2/shape", "shape": [2], "dtype": "int32"}, {"name": "StatefulPartitionedCall/TopKV2/k", "shape": [], "dtype": "int32"}, {"name": "StatefulPartitionedCall/strided_slice_23/stack", "shape": [3], "dtype": "int32"}, {"name": "StatefulPartitionedCall/strided_slice_23/stack_1", "shape": [3], "dtype": "int32"}, {"name": "StatefulPartitionedCall/strided_slice_23/stack_2", "shape": [3], "dtype": "int32"}, {"name": "StatefulPartitionedCall/concat_3/axis", "shape": [], "dtype": "int32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/Conv1/Conv2D_weights", "shape": [3, 3, 3, 32], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/Conv1/Conv2D_bn_offset", "shape": [32], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/expanded_conv_depthwise/depthwise_weights", "shape": [3, 3, 32, 1], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/expanded_conv_depthwise/depthwise_bn_offset", "shape": [32], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/expanded_conv_project/Conv2D_weights", "shape": [1, 1, 32, 16], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/expanded_conv_project/Conv2D_bn_offset", "shape": [16], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_1_expand/Conv2D_weights", "shape": [1, 1, 16, 96], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_1_expand/Conv2D_bn_offset", "shape": [96], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_1_depthwise/depthwise_weights", "shape": [3, 3, 96, 1], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_1_depthwise/depthwise_bn_offset", "shape": [96], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_1_project/Conv2D_weights", "shape": [1, 1, 96, 24], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_1_project/Conv2D_bn_offset", "shape": [24], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_2_expand/Conv2D_weights", "shape": [1, 1, 24, 144], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_2_expand/Conv2D_bn_offset", "shape": [144], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_2_depthwise/depthwise_weights", "shape": [3, 3, 144, 1], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_2_depthwise/depthwise_bn_offset", "shape": [144], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_2_project/Conv2D_weights", "shape": [1, 1, 144, 24], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_2_project/Conv2D_bn_offset", "shape": [24], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_3_expand/Conv2D_weights", "shape": [1, 1, 24, 144], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_3_expand/Conv2D_bn_offset", "shape": [144], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_3_depthwise/depthwise_weights", "shape": [3, 3, 144, 1], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_3_depthwise/depthwise_bn_offset", "shape": [144], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_3_project/Conv2D_weights", "shape": [1, 1, 144, 32], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_3_project/Conv2D_bn_offset", "shape": [32], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_4_expand/Conv2D_weights", "shape": [1, 1, 32, 192], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_4_expand/Conv2D_bn_offset", "shape": [192], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_4_depthwise/depthwise_weights", "shape": [3, 3, 192, 1], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_4_depthwise/depthwise_bn_offset", "shape": [192], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_4_project/Conv2D_weights", "shape": [1, 1, 192, 32], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_4_project/Conv2D_bn_offset", "shape": [32], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_5_expand/Conv2D_weights", "shape": [1, 1, 32, 192], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_5_expand/Conv2D_bn_offset", "shape": [192], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_5_depthwise/depthwise_weights", "shape": [3, 3, 192, 1], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_5_depthwise/depthwise_bn_offset", "shape": [192], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_5_project/Conv2D_weights", "shape": [1, 1, 192, 32], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_5_project/Conv2D_bn_offset", "shape": [32], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_6_expand/Conv2D_weights", "shape": [1, 1, 32, 192], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_6_expand/Conv2D_bn_offset", "shape": [192], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_6_depthwise/depthwise_weights", "shape": [3, 3, 192, 1], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_6_depthwise/depthwise_bn_offset", "shape": [192], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_6_project/Conv2D_weights", "shape": [1, 1, 192, 64], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_6_project/Conv2D_bn_offset", "shape": [64], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_7_expand/Conv2D_weights", "shape": [1, 1, 64, 384], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_7_expand/Conv2D_bn_offset", "shape": [384], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_7_depthwise/depthwise_weights", "shape": [3, 3, 384, 1], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_7_depthwise/depthwise_bn_offset", "shape": [384], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_7_project/Conv2D_weights", "shape": [1, 1, 384, 64], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_7_project/Conv2D_bn_offset", "shape": [64], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_8_expand/Conv2D_weights", "shape": [1, 1, 64, 384], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_8_expand/Conv2D_bn_offset", "shape": [384], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_8_depthwise/depthwise_weights", "shape": [3, 3, 384, 1], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_8_depthwise/depthwise_bn_offset", "shape": [384], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_8_project/Conv2D_weights", "shape": [1, 1, 384, 64], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_8_project/Conv2D_bn_offset", "shape": [64], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_9_expand/Conv2D_weights", "shape": [1, 1, 64, 384], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_9_expand/Conv2D_bn_offset", "shape": [384], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_9_depthwise/depthwise_weights", "shape": [3, 3, 384, 1], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_9_depthwise/depthwise_bn_offset", "shape": [384], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_9_project/Conv2D_weights", "shape": [1, 1, 384, 64], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_9_project/Conv2D_bn_offset", "shape": [64], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_10_expand/Conv2D_weights", "shape": [1, 1, 64, 384], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_10_expand/Conv2D_bn_offset", "shape": [384], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_10_depthwise/depthwise_weights", "shape": [3, 3, 384, 1], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_10_depthwise/depthwise_bn_offset", "shape": [384], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_10_project/Conv2D_weights", "shape": [1, 1, 384, 96], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_10_project/Conv2D_bn_offset", "shape": [96], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_11_expand/Conv2D_weights", "shape": [1, 1, 96, 576], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_11_expand/Conv2D_bn_offset", "shape": [576], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_11_depthwise/depthwise_weights", "shape": [3, 3, 576, 1], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_11_depthwise/depthwise_bn_offset", "shape": [576], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_11_project/Conv2D_weights", "shape": [1, 1, 576, 96], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_11_project/Conv2D_bn_offset", "shape": [96], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_12_expand/Conv2D_weights", "shape": [1, 1, 96, 576], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_12_expand/Conv2D_bn_offset", "shape": [576], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_12_depthwise/depthwise_weights", "shape": [3, 3, 576, 1], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_12_depthwise/depthwise_bn_offset", "shape": [576], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_12_project/Conv2D_weights", "shape": [1, 1, 576, 96], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_12_project/Conv2D_bn_offset", "shape": [96], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_13_expand/Conv2D_weights", "shape": [1, 1, 96, 576], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_13_expand/Conv2D_bn_offset", "shape": [576], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_13_depthwise/depthwise_weights", "shape": [3, 3, 576, 1], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_13_depthwise/depthwise_bn_offset", "shape": [576], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_13_project/Conv2D_weights", "shape": [1, 1, 576, 160], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_13_project/Conv2D_bn_offset", "shape": [160], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_14_expand/Conv2D_weights", "shape": [1, 1, 160, 960], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_14_expand/Conv2D_bn_offset", "shape": [960], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_14_depthwise/depthwise_weights", "shape": [3, 3, 960, 1], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_14_depthwise/depthwise_bn_offset", "shape": [960], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_14_project/Conv2D_weights", "shape": [1, 1, 960, 160], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_14_project/Conv2D_bn_offset", "shape": [160], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_15_expand/Conv2D_weights", "shape": [1, 1, 160, 960], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_15_expand/Conv2D_bn_offset", "shape": [960], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_15_depthwise/depthwise_weights", "shape": [3, 3, 960, 1], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_15_depthwise/depthwise_bn_offset", "shape": [960], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_15_project/Conv2D_weights", "shape": [1, 1, 960, 160], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_15_project/Conv2D_bn_offset", "shape": [160], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_16_expand/Conv2D_weights", "shape": [1, 1, 160, 960], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_16_expand/Conv2D_bn_offset", "shape": [960], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_16_depthwise/depthwise_weights", "shape": [3, 3, 960, 1], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_16_depthwise/depthwise_bn_offset", "shape": [960], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_16_project/Conv2D_weights", "shape": [1, 1, 960, 320], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/block_16_project/Conv2D_bn_offset", "shape": [320], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/Conv_1/Conv2D_weights", "shape": [1, 1, 320, 1280], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/model/Conv_1/Conv2D_bn_offset", "shape": [1280], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/separable_conv2d/separable_conv2d_weights", "shape": [1, 1, 64, 32], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/separable_conv2d/separable_conv2d_bn_offset", "shape": [32], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/separable_conv2d_1/separable_conv2d_weights", "shape": [1, 1, 32, 24], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/separable_conv2d_1/separable_conv2d_bn_offset", "shape": [24], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/separable_conv2d_2/separable_conv2d_weights", "shape": [1, 1, 24, 24], "dtype": "float32"}, {"name": "StatefulPartitionedCall/center_net_mobile_net_v2fpn_feature_extractor/model_1/separable_conv2d_2/separable_conv2d_bn_offset", "shape": [24], "dtype": "float32"}, {"name": "ConstantFolding/StatefulPartitionedCall/stack_const_axis", "shape": [], "dtype": "int32"}, {"name": "__inference_map_while_body_10122_30691/map/while/add/y", "shape": [], "dtype": "int32"}, {"name": "__inference_map_while_body_10122_30691/map/while/ClipToWindow/split/split_dim", "shape": [], "dtype": "int32"}, {"name": "__inference_map_while_body_10122_30691/map/while/TensorArrayV2Read/TensorListGetItem/element_shape", "shape": [3], "dtype": "int32"}, {"name": "__inference_map_while_body_10122_30691/map/while/TensorArrayV2Read_1/TensorListGetItem/element_shape", "shape": [1], "dtype": "int32"}, {"name": "__inference_map_while_body_10122_30691/map/while/ClipToWindow/concat/axis", "shape": [], "dtype": "int32"}, {"name": "__inference_map_while_body_10122_30691/map/while/add_1/y", "shape": [], "dtype": "int32"}, {"name": "__inference_map_while_cond_10121_3503/map/while/Less/y", "shape": [], "dtype": "int32"}]}]} \ No newline at end of file diff --git a/tfjs-master/e2e/cloudbuild.yml b/tfjs-master/e2e/cloudbuild.yml deleted file mode 100644 index d5c7ad388..000000000 --- a/tfjs-master/e2e/cloudbuild.yml +++ /dev/null @@ -1,46 +0,0 @@ -steps: - -# Install packages. -- name: 'gcr.io/learnjs-174218/release' - dir: 'e2e' - entrypoint: 'yarn' - id: 'yarn' - args: ['install'] - -# Build deps. -- name: 'gcr.io/learnjs-174218/release' - dir: 'e2e' - entrypoint: 'yarn' - id: 'build-deps' - args: ['build-deps-ci'] - env: ['NIGHTLY=$_NIGHTLY'] - -# Fetch graph model golden data from public TFJS gcp bucket. -- name: 'gcr.io/learnjs-174218/release' - dir: 'e2e' - entrypoint: 'yarn' - id: 'fetch-graph-model-golden-data' - args: ['fetch-graph-model-golden-data-ci'] - -# Test. -- name: 'gcr.io/learnjs-174218/release' - dir: 'e2e' - entrypoint: 'yarn' - id: 'test' - args: ['test-ci'] - env: ['BROWSERSTACK_USERNAME=deeplearnjs1', 'NIGHTLY=$_NIGHTLY'] - secretEnv: ['BROWSERSTACK_KEY'] - waitFor: ['yarn', 'build-deps', 'fetch-graph-model-golden-data'] - -secrets: -- kmsKeyName: projects/learnjs-174218/locations/global/keyRings/tfjs/cryptoKeys/enc - secretEnv: - BROWSERSTACK_KEY: CiQAkwyoIW0LcnxymzotLwaH4udVTQFBEN4AEA5CA+a3+yflL2ASPQAD8BdZnGARf78MhH5T9rQqyz9HNODwVjVIj64CTkFlUCGrP1B2HX9LXHWHLmtKutEGTeFFX9XhuBzNExA= -timeout: 7200s -logsBucket: 'gs://tfjs-build-logs' -substitutions: - _NIGHTLY: '' -options: - logStreamingOption: 'STREAM_ON' - machineType: 'N1_HIGHCPU_8' - substitution_option: 'ALLOW_LOOSE' diff --git a/tfjs-master/e2e/custom_module/blazeface/app.js b/tfjs-master/e2e/custom_module/blazeface/app.js deleted file mode 100644 index ab283433d..000000000 --- a/tfjs-master/e2e/custom_module/blazeface/app.js +++ /dev/null @@ -1,93 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import '@tensorflow/tfjs-core/dist/public/chained_ops/to_float'; -import '@tensorflow/tfjs-core/dist/public/chained_ops/expand_dims'; -import '@tensorflow/tfjs-core/dist/public/chained_ops/resize_bilinear'; -import '@tensorflow/tfjs-core/dist/public/chained_ops/squeeze'; -import '@tensorflow/tfjs-core/dist/public/chained_ops/reshape'; -import '@tensorflow/tfjs-core/dist/public/chained_ops/div'; - -import * as blazeface from '@tensorflow-models/blazeface'; -import * as tf from '@tensorflow/tfjs'; -import {setWasmPaths} from '@tensorflow/tfjs-backend-wasm/dist/backend_wasm'; - -import wasmSimdPath from './node_modules/@tensorflow/tfjs-backend-wasm/dist/tfjs-backend-wasm-simd.wasm'; -import wasmSimdThreadedPath from './node_modules/@tensorflow/tfjs-backend-wasm/dist/tfjs-backend-wasm-threaded-simd.wasm'; -import wasmPath from './node_modules/@tensorflow/tfjs-backend-wasm/dist/tfjs-backend-wasm.wasm'; - -setWasmPaths({ - 'tfjs-backend-wasm.wasm': wasmPath, - 'tfjs-backend-wasm-simd.wasm': wasmSimdPath, - 'tfjs-backend-wasm-threaded-simd.wasm': wasmSimdThreadedPath -}); - -import {STUBBED_IMAGE_VALS} from './test_data'; - -async function main() { - tf.setBackend('wasm'); - tf.env().set('WASM_HAS_SIMD_SUPPORT', false); - tf.env().set('WASM_HAS_MULTITHREAD_SUPPORT', false); - self.postMessage({msg: true, payload: 'in worker main function'}); - await tf.ready(); - - const backend = tf.getBackend(); - self.postMessage({msg: true, payload: `'${backend}' backend ready`}); - - const registeredKernels = tf.getKernelsForBackend(backend) - // Debug messsage with info about the registered kernels. - self.postMessage({ - msg: true, - payload: { - numKernels: registeredKernels.length, - kernelNames: registeredKernels.map(k => k.kernelName), - backend, - } - }); - - const model = await blazeface.load(); - - self.postMessage({msg: true, payload: `model loaded`}); - - let predictions; - try { - const input = tf.tensor3d(STUBBED_IMAGE_VALS, [128, 128, 3]); - predictions = await model.estimateFaces(input, false /*returnTensors*/); - input.dispose(); - } catch (e) { - self.postMessage({error: true, payload: {e}}); - } - - // send the final result of the test. - self.postMessage({ - result: true, - payload: { - numKernels: registeredKernels.length, - kernelNames: registeredKernels.map(k => k.kernelName), - backend, - predictions: predictions - } - }); -} - -self.addEventListener('message', function(e) { - try { - main(); - } catch (e) { - self.postMessage({error: true, payload: e}); - } -}, false); diff --git a/tfjs-master/e2e/custom_module/blazeface/app_tfjs_config.json b/tfjs-master/e2e/custom_module/blazeface/app_tfjs_config.json deleted file mode 100644 index 8df1edb77..000000000 --- a/tfjs-master/e2e/custom_module/blazeface/app_tfjs_config.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "kernels": [ - "Cast", - "ExpandDims", - "Reshape", - "ResizeBilinear", - "RealDiv", - "Sub", - "Multiply", - "FusedConv2D", - "fusedConv2d__op", - "DepthwiseConv2dNative", - "Add", - "Relu", - "PadV2", - "Pack", - "MaxPool", - "Slice", - "StridedSlice", - "Concat", - "Identity", - "Sigmoid", - "NonMaxSuppressionV3" - ], - "backends": [ - "wasm" - ], - "models": [ - "./model.json" - ], - "outputPath": "./custom_tfjs_blazeface", - "forwardModeOnly": true -} diff --git a/tfjs-master/e2e/custom_module/blazeface/build.sh b/tfjs-master/e2e/custom_module/blazeface/build.sh deleted file mode 100644 index bd12790c0..000000000 --- a/tfjs-master/e2e/custom_module/blazeface/build.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env bash - -# Copyright 2023 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================== - -set -e - -yarn --mutex network -# Ensure that we test against freshly generated custom modules. -rm -f ./custom_tfjs_blazeface/*.js -echo "npm version $(npm --version)" -yarn make-custom-tfjs-modules -# TODO(yassogba) once blazeface kernels are modularized in cpu -# switch the config to cpu and also run and test rollup bundle. -parallel ::: "yarn webpack:full" "yarn webpack:custom" diff --git a/tfjs-master/e2e/custom_module/blazeface/model.json b/tfjs-master/e2e/custom_module/blazeface/model.json deleted file mode 100644 index 1f1aa5625..000000000 --- a/tfjs-master/e2e/custom_module/blazeface/model.json +++ /dev/null @@ -1,5474 +0,0 @@ -{ - "format": "graph-model", - "generatedBy": "1.15.0", - "convertedBy": "TensorFlow.js Converter v1.3.2", - "signature": { - "inputs": { - "input:0": { - "name": "input:0", - "dtype": "DT_FLOAT", - "tensorShape": { - "dim": [ - { - "size": "-1" - }, - { - "size": "128" - }, - { - "size": "128" - }, - { - "size": "3" - } - ] - } - } - }, - "outputs": { - "Identity:0": { - "name": "Identity:0", - "dtype": "DT_FLOAT", - "tensorShape": { - "dim": [ - { - "size": "-1" - }, - { - "size": "-1" - }, - { - "size": "17" - } - ] - } - } - } - }, - "modelTopology": { - "node": [ - { - "name": "input", - "op": "Placeholder", - "attr": { - "dtype": { - "type": "DT_FLOAT" - }, - "shape": { - "shape": { - "dim": [ - { - "size": "-1" - }, - { - "size": "128" - }, - { - "size": "128" - }, - { - "size": "3" - } - ] - } - } - } - }, - { - "name": "StatefulPartitionedCall/model/conv2d/Conv2D_weights", - "op": "Const", - "attr": { - "value": { - "tensor": { - "dtype": "DT_FLOAT", - "tensorShape": { - "dim": [ - { - "size": "5" - }, - { - "size": "5" - }, - { - "size": "3" - }, - { - "size": "24" - } - ] - } - } - }, - "dtype": { - "type": "DT_FLOAT" - } - } - }, - { - "name": "StatefulPartitionedCall/model/conv2d_16/Conv2D_weights", - "op": "Const", - "attr": { - "dtype": { - "type": "DT_FLOAT" - }, - "value": { - "tensor": { - "dtype": "DT_FLOAT", - "tensorShape": { - "dim": [ - { - "size": "1" - }, - { - "size": "1" - }, - { - "size": "96" - }, - { - "size": "96" - } - ] - } - } - } - } - }, - { - "name": "StatefulPartitionedCall/model/conv2d/Conv2D_bn_offset", - "op": "Const", - "attr": { - "value": { - "tensor": { - "dtype": "DT_FLOAT", - "tensorShape": { - "dim": [ - { - "size": "24" - } - ] - } - } - }, - "dtype": { - "type": "DT_FLOAT" - } - } - }, - { - "name": "StatefulPartitionedCall/model/conv2d_1/Conv2D_weights", - "op": "Const", - "attr": { - "value": { - "tensor": { - "dtype": "DT_FLOAT", - "tensorShape": { - "dim": [ - { - "size": "1" - }, - { - "size": "1" - }, - { - "size": "24" - }, - { - "size": "24" - } - ] - } - } - }, - "dtype": { - "type": "DT_FLOAT" - } - } - }, - { - "name": "StatefulPartitionedCall/model/conv2d_16/Conv2D_bn_offset", - "op": "Const", - "attr": { - "value": { - "tensor": { - "dtype": "DT_FLOAT", - "tensorShape": { - "dim": [ - { - "size": "96" - } - ] - } - } - }, - "dtype": { - "type": "DT_FLOAT" - } - } - }, - { - "name": "StatefulPartitionedCall/model/conv2d_1/Conv2D_bn_offset", - "op": "Const", - "attr": { - "value": { - "tensor": { - "dtype": "DT_FLOAT", - "tensorShape": { - "dim": [ - { - "size": "24" - } - ] - } - } - }, - "dtype": { - "type": "DT_FLOAT" - } - } - }, - { - "name": "StatefulPartitionedCall/model/conv2d_2/Conv2D_weights", - "op": "Const", - "attr": { - "value": { - "tensor": { - "dtype": "DT_FLOAT", - "tensorShape": { - "dim": [ - { - "size": "1" - }, - { - "size": "1" - }, - { - "size": "24" - }, - { - "size": "28" - } - ] - } - } - }, - "dtype": { - "type": "DT_FLOAT" - } - } - }, - { - "name": "StatefulPartitionedCall/model/conv2d_2/Conv2D_bn_offset", - "op": "Const", - "attr": { - "value": { - "tensor": { - "dtype": "DT_FLOAT", - "tensorShape": { - "dim": [ - { - "size": "28" - } - ] - } - } - }, - "dtype": { - "type": "DT_FLOAT" - } - } - }, - { - "name": "StatefulPartitionedCall/model/conv2d_3/Conv2D_weights", - "op": "Const", - "attr": { - "value": { - "tensor": { - "dtype": "DT_FLOAT", - "tensorShape": { - "dim": [ - { - "size": "1" - }, - { - "size": "1" - }, - { - "size": "28" - }, - { - "size": "32" - } - ] - } - } - }, - "dtype": { - "type": "DT_FLOAT" - } - } - }, - { - "name": "StatefulPartitionedCall/model/conv2d_3/Conv2D_bn_offset", - "op": "Const", - "attr": { - "value": { - "tensor": { - "dtype": "DT_FLOAT", - "tensorShape": { - "dim": [ - { - "size": "32" - } - ] - } - } - }, - "dtype": { - "type": "DT_FLOAT" - } - } - }, - { - "name": "StatefulPartitionedCall/model/conv2d_4/Conv2D_weights", - "op": "Const", - "attr": { - "dtype": { - "type": "DT_FLOAT" - }, - "value": { - "tensor": { - "dtype": "DT_FLOAT", - "tensorShape": { - "dim": [ - { - "size": "1" - }, - { - "size": "1" - }, - { - "size": "32" - }, - { - "size": "36" - } - ] - } - } - } - } - }, - { - "name": "StatefulPartitionedCall/model/conv2d_4/Conv2D_bn_offset", - "op": "Const", - "attr": { - "value": { - "tensor": { - "dtype": "DT_FLOAT", - "tensorShape": { - "dim": [ - { - "size": "36" - } - ] - } - } - }, - "dtype": { - "type": "DT_FLOAT" - } - } - }, - { - "name": "StatefulPartitionedCall/model/conv2d_5/Conv2D_weights", - "op": "Const", - "attr": { - "value": { - "tensor": { - "dtype": "DT_FLOAT", - "tensorShape": { - "dim": [ - { - "size": "1" - }, - { - "size": "1" - }, - { - "size": "36" - }, - { - "size": "42" - } - ] - } - } - }, - "dtype": { - "type": "DT_FLOAT" - } - } - }, - { - "name": "StatefulPartitionedCall/model/conv2d_5/Conv2D_bn_offset", - "op": "Const", - "attr": { - "value": { - "tensor": { - "dtype": "DT_FLOAT", - "tensorShape": { - "dim": [ - { - "size": "42" - } - ] - } - } - }, - "dtype": { - "type": "DT_FLOAT" - } - } - }, - { - "name": "StatefulPartitionedCall/model/conv2d_6/Conv2D_weights", - "op": "Const", - "attr": { - "value": { - "tensor": { - "dtype": "DT_FLOAT", - "tensorShape": { - "dim": [ - { - "size": "1" - }, - { - "size": "1" - }, - { - "size": "42" - }, - { - "size": "48" - } - ] - } - } - }, - "dtype": { - "type": "DT_FLOAT" - } - } - }, - { - "name": "StatefulPartitionedCall/model/conv2d_6/Conv2D_bn_offset", - "op": "Const", - "attr": { - "value": { - "tensor": { - "dtype": "DT_FLOAT", - "tensorShape": { - "dim": [ - { - "size": "48" - } - ] - } - } - }, - "dtype": { - "type": "DT_FLOAT" - } - } - }, - { - "name": "StatefulPartitionedCall/model/conv2d_7/Conv2D_weights", - "op": "Const", - "attr": { - "value": { - "tensor": { - "dtype": "DT_FLOAT", - "tensorShape": { - "dim": [ - { - "size": "1" - }, - { - "size": "1" - }, - { - "size": "48" - }, - { - "size": "56" - } - ] - } - } - }, - "dtype": { - "type": "DT_FLOAT" - } - } - }, - { - "name": "StatefulPartitionedCall/model/conv2d_7/Conv2D_bn_offset", - "op": "Const", - "attr": { - "value": { - "tensor": { - "dtype": "DT_FLOAT", - "tensorShape": { - "dim": [ - { - "size": "56" - } - ] - } - } - }, - "dtype": { - "type": "DT_FLOAT" - } - } - }, - { - "name": "StatefulPartitionedCall/model/conv2d_8/Conv2D_weights", - "op": "Const", - "attr": { - "dtype": { - "type": "DT_FLOAT" - }, - "value": { - "tensor": { - "dtype": "DT_FLOAT", - "tensorShape": { - "dim": [ - { - "size": "1" - }, - { - "size": "1" - }, - { - "size": "56" - }, - { - "size": "64" - } - ] - } - } - } - } - }, - { - "name": "StatefulPartitionedCall/model/conv2d_8/Conv2D_bn_offset", - "op": "Const", - "attr": { - "dtype": { - "type": "DT_FLOAT" - }, - "value": { - "tensor": { - "dtype": "DT_FLOAT", - "tensorShape": { - "dim": [ - { - "size": "64" - } - ] - } - } - } - } - }, - { - "name": "StatefulPartitionedCall/model/conv2d_9/Conv2D_weights", - "op": "Const", - "attr": { - "value": { - "tensor": { - "dtype": "DT_FLOAT", - "tensorShape": { - "dim": [ - { - "size": "1" - }, - { - "size": "1" - }, - { - "size": "64" - }, - { - "size": "72" - } - ] - } - } - }, - "dtype": { - "type": "DT_FLOAT" - } - } - }, - { - "name": "StatefulPartitionedCall/model/conv2d_9/Conv2D_bn_offset", - "op": "Const", - "attr": { - "value": { - "tensor": { - "dtype": "DT_FLOAT", - "tensorShape": { - "dim": [ - { - "size": "72" - } - ] - } - } - }, - "dtype": { - "type": "DT_FLOAT" - } - } - }, - { - "name": "StatefulPartitionedCall/model/conv2d_10/Conv2D_weights", - "op": "Const", - "attr": { - "value": { - "tensor": { - "dtype": "DT_FLOAT", - "tensorShape": { - "dim": [ - { - "size": "1" - }, - { - "size": "1" - }, - { - "size": "72" - }, - { - "size": "80" - } - ] - } - } - }, - "dtype": { - "type": "DT_FLOAT" - } - } - }, - { - "name": "StatefulPartitionedCall/model/conv2d_10/Conv2D_bn_offset", - "op": "Const", - "attr": { - "value": { - "tensor": { - "dtype": "DT_FLOAT", - "tensorShape": { - "dim": [ - { - "size": "80" - } - ] - } - } - }, - "dtype": { - "type": "DT_FLOAT" - } - } - }, - { - "name": "StatefulPartitionedCall/model/conv2d_11/Conv2D_weights", - "op": "Const", - "attr": { - "value": { - "tensor": { - "dtype": "DT_FLOAT", - "tensorShape": { - "dim": [ - { - "size": "1" - }, - { - "size": "1" - }, - { - "size": "80" - }, - { - "size": "88" - } - ] - } - } - }, - "dtype": { - "type": "DT_FLOAT" - } - } - }, - { - "name": "StatefulPartitionedCall/model/conv2d_11/Conv2D_bn_offset", - "op": "Const", - "attr": { - "value": { - "tensor": { - "dtype": "DT_FLOAT", - "tensorShape": { - "dim": [ - { - "size": "88" - } - ] - } - } - }, - "dtype": { - "type": "DT_FLOAT" - } - } - }, - { - "name": "StatefulPartitionedCall/model/conv2d_12/Conv2D_weights", - "op": "Const", - "attr": { - "value": { - "tensor": { - "dtype": "DT_FLOAT", - "tensorShape": { - "dim": [ - { - "size": "1" - }, - { - "size": "1" - }, - { - "size": "88" - }, - { - "size": "96" - } - ] - } - } - }, - "dtype": { - "type": "DT_FLOAT" - } - } - }, - { - "name": "StatefulPartitionedCall/model/conv2d_12/Conv2D_bn_offset", - "op": "Const", - "attr": { - "dtype": { - "type": "DT_FLOAT" - }, - "value": { - "tensor": { - "dtype": "DT_FLOAT", - "tensorShape": { - "dim": [ - { - "size": "96" - } - ] - } - } - } - } - }, - { - "name": "StatefulPartitionedCall/model/conv2d_13/Conv2D_weights", - "op": "Const", - "attr": { - "value": { - "tensor": { - "dtype": "DT_FLOAT", - "tensorShape": { - "dim": [ - { - "size": "1" - }, - { - "size": "1" - }, - { - "size": "96" - }, - { - "size": "96" - } - ] - } - } - }, - "dtype": { - "type": "DT_FLOAT" - } - } - }, - { - "name": "StatefulPartitionedCall/model/conv2d_13/Conv2D_bn_offset", - "op": "Const", - "attr": { - "value": { - "tensor": { - "dtype": "DT_FLOAT", - "tensorShape": { - "dim": [ - { - "size": "96" - } - ] - } - } - }, - "dtype": { - "type": "DT_FLOAT" - } - } - }, - { - "name": "StatefulPartitionedCall/model/conv2d_14/Conv2D_weights", - "op": "Const", - "attr": { - "value": { - "tensor": { - "dtype": "DT_FLOAT", - "tensorShape": { - "dim": [ - { - "size": "1" - }, - { - "size": "1" - }, - { - "size": "96" - }, - { - "size": "96" - } - ] - } - } - }, - "dtype": { - "type": "DT_FLOAT" - } - } - }, - { - "name": "StatefulPartitionedCall/model/conv2d_14/Conv2D_bn_offset", - "op": "Const", - "attr": { - "value": { - "tensor": { - "dtype": "DT_FLOAT", - "tensorShape": { - "dim": [ - { - "size": "96" - } - ] - } - } - }, - "dtype": { - "type": "DT_FLOAT" - } - } - }, - { - "name": "StatefulPartitionedCall/model/conv2d_15/Conv2D_weights", - "op": "Const", - "attr": { - "value": { - "tensor": { - "dtype": "DT_FLOAT", - "tensorShape": { - "dim": [ - { - "size": "1" - }, - { - "size": "1" - }, - { - "size": "96" - }, - { - "size": "96" - } - ] - } - } - }, - "dtype": { - "type": "DT_FLOAT" - } - } - }, - { - "name": "StatefulPartitionedCall/model/conv2d_15/Conv2D_bn_offset", - "op": "Const", - "attr": { - "value": { - "tensor": { - "dtype": "DT_FLOAT", - "tensorShape": { - "dim": [ - { - "size": "96" - } - ] - } - } - }, - "dtype": { - "type": "DT_FLOAT" - } - } - }, - { - "name": "StatefulPartitionedCall/model/depthwise_conv2d/depthwise/ReadVariableOp", - "op": "Const", - "input": [ - "^input" - ], - "attr": { - "value": { - "tensor": { - "dtype": "DT_FLOAT", - "tensorShape": { - "dim": [ - { - "size": "3" - }, - { - "size": "3" - }, - { - "size": "24" - }, - { - "size": "1" - } - ] - } - } - }, - "dtype": { - "type": "DT_FLOAT" - } - } - }, - { - "name": "StatefulPartitionedCall/model/channel_padding/Pad/paddings", - "op": "Const", - "input": [ - "^input" - ], - "attr": { - "value": { - "tensor": { - "dtype": "DT_INT32", - "tensorShape": { - "dim": [ - { - "size": "4" - }, - { - "size": "2" - } - ] - } - } - }, - "dtype": { - "type": "DT_INT32" - } - } - }, - { - "name": "StatefulPartitionedCall/model/depthwise_conv2d_1/depthwise/ReadVariableOp", - "op": "Const", - "input": [ - "^input" - ], - "attr": { - "dtype": { - "type": "DT_FLOAT" - }, - "value": { - "tensor": { - "dtype": "DT_FLOAT", - "tensorShape": { - "dim": [ - { - "size": "3" - }, - { - "size": "3" - }, - { - "size": "24" - }, - { - "size": "1" - } - ] - } - } - } - } - }, - { - "name": "StatefulPartitionedCall/model/depthwise_conv2d_2/depthwise/ReadVariableOp", - "op": "Const", - "input": [ - "^input" - ], - "attr": { - "value": { - "tensor": { - "dtype": "DT_FLOAT", - "tensorShape": { - "dim": [ - { - "size": "3" - }, - { - "size": "3" - }, - { - "size": "28" - }, - { - "size": "1" - } - ] - } - } - }, - "dtype": { - "type": "DT_FLOAT" - } - } - }, - { - "name": "StatefulPartitionedCall/model/depthwise_conv2d_3/depthwise/ReadVariableOp", - "op": "Const", - "input": [ - "^input" - ], - "attr": { - "dtype": { - "type": "DT_FLOAT" - }, - "value": { - "tensor": { - "dtype": "DT_FLOAT", - "tensorShape": { - "dim": [ - { - "size": "3" - }, - { - "size": "3" - }, - { - "size": "32" - }, - { - "size": "1" - } - ] - } - } - } - } - }, - { - "name": "StatefulPartitionedCall/model/channel_padding_3/Pad/paddings", - "op": "Const", - "input": [ - "^input" - ], - "attr": { - "value": { - "tensor": { - "dtype": "DT_INT32", - "tensorShape": { - "dim": [ - { - "size": "4" - }, - { - "size": "2" - } - ] - } - } - }, - "dtype": { - "type": "DT_INT32" - } - } - }, - { - "name": "StatefulPartitionedCall/model/depthwise_conv2d_4/depthwise/ReadVariableOp", - "op": "Const", - "input": [ - "^input" - ], - "attr": { - "value": { - "tensor": { - "dtype": "DT_FLOAT", - "tensorShape": { - "dim": [ - { - "size": "3" - }, - { - "size": "3" - }, - { - "size": "36" - }, - { - "size": "1" - } - ] - } - } - }, - "dtype": { - "type": "DT_FLOAT" - } - } - }, - { - "name": "StatefulPartitionedCall/model/depthwise_conv2d_5/depthwise/ReadVariableOp", - "op": "Const", - "input": [ - "^input" - ], - "attr": { - "value": { - "tensor": { - "dtype": "DT_FLOAT", - "tensorShape": { - "dim": [ - { - "size": "3" - }, - { - "size": "3" - }, - { - "size": "42" - }, - { - "size": "1" - } - ] - } - } - }, - "dtype": { - "type": "DT_FLOAT" - } - } - }, - { - "name": "StatefulPartitionedCall/model/channel_padding_5/Pad/paddings", - "op": "Const", - "input": [ - "^input" - ], - "attr": { - "value": { - "tensor": { - "dtype": "DT_INT32", - "tensorShape": { - "dim": [ - { - "size": "4" - }, - { - "size": "2" - } - ] - } - } - }, - "dtype": { - "type": "DT_INT32" - } - } - }, - { - "name": "StatefulPartitionedCall/model/depthwise_conv2d_6/depthwise/ReadVariableOp", - "op": "Const", - "input": [ - "^input" - ], - "attr": { - "dtype": { - "type": "DT_FLOAT" - }, - "value": { - "tensor": { - "dtype": "DT_FLOAT", - "tensorShape": { - "dim": [ - { - "size": "3" - }, - { - "size": "3" - }, - { - "size": "48" - }, - { - "size": "1" - } - ] - } - } - } - } - }, - { - "name": "StatefulPartitionedCall/model/depthwise_conv2d_7/depthwise/ReadVariableOp", - "op": "Const", - "input": [ - "^input" - ], - "attr": { - "value": { - "tensor": { - "dtype": "DT_FLOAT", - "tensorShape": { - "dim": [ - { - "size": "3" - }, - { - "size": "3" - }, - { - "size": "56" - }, - { - "size": "1" - } - ] - } - } - }, - "dtype": { - "type": "DT_FLOAT" - } - } - }, - { - "name": "StatefulPartitionedCall/model/depthwise_conv2d_8/depthwise/ReadVariableOp", - "op": "Const", - "input": [ - "^input" - ], - "attr": { - "dtype": { - "type": "DT_FLOAT" - }, - "value": { - "tensor": { - "dtype": "DT_FLOAT", - "tensorShape": { - "dim": [ - { - "size": "3" - }, - { - "size": "3" - }, - { - "size": "64" - }, - { - "size": "1" - } - ] - } - } - } - } - }, - { - "name": "StatefulPartitionedCall/model/depthwise_conv2d_9/depthwise/ReadVariableOp", - "op": "Const", - "input": [ - "^input" - ], - "attr": { - "dtype": { - "type": "DT_FLOAT" - }, - "value": { - "tensor": { - "dtype": "DT_FLOAT", - "tensorShape": { - "dim": [ - { - "size": "3" - }, - { - "size": "3" - }, - { - "size": "72" - }, - { - "size": "1" - } - ] - } - } - } - } - }, - { - "name": "StatefulPartitionedCall/model/depthwise_conv2d_10/depthwise/ReadVariableOp", - "op": "Const", - "input": [ - "^input" - ], - "attr": { - "dtype": { - "type": "DT_FLOAT" - }, - "value": { - "tensor": { - "dtype": "DT_FLOAT", - "tensorShape": { - "dim": [ - { - "size": "3" - }, - { - "size": "3" - }, - { - "size": "80" - }, - { - "size": "1" - } - ] - } - } - } - } - }, - { - "name": "StatefulPartitionedCall/model/classificator_8/Conv2D/ReadVariableOp", - "op": "Const", - "input": [ - "^input" - ], - "attr": { - "value": { - "tensor": { - "dtype": "DT_FLOAT", - "tensorShape": { - "dim": [ - { - "size": "1" - }, - { - "size": "1" - }, - { - "size": "88" - }, - { - "size": "2" - } - ] - } - } - }, - "dtype": { - "type": "DT_FLOAT" - } - } - }, - { - "name": "StatefulPartitionedCall/model/classificator_8/BiasAdd/ReadVariableOp", - "op": "Const", - "input": [ - "^input" - ], - "attr": { - "dtype": { - "type": "DT_FLOAT" - }, - "value": { - "tensor": { - "dtype": "DT_FLOAT", - "tensorShape": { - "dim": [ - { - "size": "2" - } - ] - } - } - } - } - }, - { - "name": "StatefulPartitionedCall/model/reshape/strided_slice/stack", - "op": "Const", - "input": [ - "^input" - ], - "attr": { - "dtype": { - "type": "DT_INT32" - }, - "value": { - "tensor": { - "dtype": "DT_INT32", - "tensorShape": { - "dim": [ - { - "size": "1" - } - ] - } - } - } - } - }, - { - "name": "StatefulPartitionedCall/model/reshape/strided_slice/stack_1", - "op": "Const", - "input": [ - "^input" - ], - "attr": { - "value": { - "tensor": { - "dtype": "DT_INT32", - "tensorShape": { - "dim": [ - { - "size": "1" - } - ] - } - } - }, - "dtype": { - "type": "DT_INT32" - } - } - }, - { - "name": "StatefulPartitionedCall/model/reshape/Reshape/shape/1", - "op": "Const", - "input": [ - "^input" - ], - "attr": { - "value": { - "tensor": { - "dtype": "DT_INT32", - "tensorShape": {} - } - }, - "dtype": { - "type": "DT_INT32" - } - } - }, - { - "name": "StatefulPartitionedCall/model/reshape/Reshape/shape/2", - "op": "Const", - "input": [ - "^input" - ], - "attr": { - "value": { - "tensor": { - "dtype": "DT_INT32", - "tensorShape": {} - } - }, - "dtype": { - "type": "DT_INT32" - } - } - }, - { - "name": "StatefulPartitionedCall/model/depthwise_conv2d_11/depthwise/ReadVariableOp", - "op": "Const", - "input": [ - "^input" - ], - "attr": { - "value": { - "tensor": { - "dtype": "DT_FLOAT", - "tensorShape": { - "dim": [ - { - "size": "3" - }, - { - "size": "3" - }, - { - "size": "88" - }, - { - "size": "1" - } - ] - } - } - }, - "dtype": { - "type": "DT_FLOAT" - } - } - }, - { - "name": "StatefulPartitionedCall/model/depthwise_conv2d_12/depthwise/ReadVariableOp", - "op": "Const", - "input": [ - "^input" - ], - "attr": { - "value": { - "tensor": { - "dtype": "DT_FLOAT", - "tensorShape": { - "dim": [ - { - "size": "3" - }, - { - "size": "3" - }, - { - "size": "96" - }, - { - "size": "1" - } - ] - } - } - }, - "dtype": { - "type": "DT_FLOAT" - } - } - }, - { - "name": "StatefulPartitionedCall/model/depthwise_conv2d_13/depthwise/ReadVariableOp", - "op": "Const", - "input": [ - "^input" - ], - "attr": { - "value": { - "tensor": { - "dtype": "DT_FLOAT", - "tensorShape": { - "dim": [ - { - "size": "3" - }, - { - "size": "3" - }, - { - "size": "96" - }, - { - "size": "1" - } - ] - } - } - }, - "dtype": { - "type": "DT_FLOAT" - } - } - }, - { - "name": "StatefulPartitionedCall/model/depthwise_conv2d_14/depthwise/ReadVariableOp", - "op": "Const", - "input": [ - "^input" - ], - "attr": { - "dtype": { - "type": "DT_FLOAT" - }, - "value": { - "tensor": { - "dtype": "DT_FLOAT", - "tensorShape": { - "dim": [ - { - "size": "3" - }, - { - "size": "3" - }, - { - "size": "96" - }, - { - "size": "1" - } - ] - } - } - } - } - }, - { - "name": "StatefulPartitionedCall/model/depthwise_conv2d_15/depthwise/ReadVariableOp", - "op": "Const", - "input": [ - "^input" - ], - "attr": { - "value": { - "tensor": { - "dtype": "DT_FLOAT", - "tensorShape": { - "dim": [ - { - "size": "3" - }, - { - "size": "3" - }, - { - "size": "96" - }, - { - "size": "1" - } - ] - } - } - }, - "dtype": { - "type": "DT_FLOAT" - } - } - }, - { - "name": "StatefulPartitionedCall/model/classificator_16/Conv2D/ReadVariableOp", - "op": "Const", - "input": [ - "^input" - ], - "attr": { - "value": { - "tensor": { - "dtype": "DT_FLOAT", - "tensorShape": { - "dim": [ - { - "size": "1" - }, - { - "size": "1" - }, - { - "size": "96" - }, - { - "size": "6" - } - ] - } - } - }, - "dtype": { - "type": "DT_FLOAT" - } - } - }, - { - "name": "StatefulPartitionedCall/model/classificator_16/BiasAdd/ReadVariableOp", - "op": "Const", - "input": [ - "^input" - ], - "attr": { - "value": { - "tensor": { - "dtype": "DT_FLOAT", - "tensorShape": { - "dim": [ - { - "size": "6" - } - ] - } - } - }, - "dtype": { - "type": "DT_FLOAT" - } - } - }, - { - "name": "StatefulPartitionedCall/model/regressor_8/Conv2D/ReadVariableOp", - "op": "Const", - "input": [ - "^input" - ], - "attr": { - "dtype": { - "type": "DT_FLOAT" - }, - "value": { - "tensor": { - "dtype": "DT_FLOAT", - "tensorShape": { - "dim": [ - { - "size": "1" - }, - { - "size": "1" - }, - { - "size": "88" - }, - { - "size": "32" - } - ] - } - } - } - } - }, - { - "name": "StatefulPartitionedCall/model/regressor_8/BiasAdd/ReadVariableOp", - "op": "Const", - "input": [ - "^input" - ], - "attr": { - "value": { - "tensor": { - "dtype": "DT_FLOAT", - "tensorShape": { - "dim": [ - { - "size": "32" - } - ] - } - } - }, - "dtype": { - "type": "DT_FLOAT" - } - } - }, - { - "name": "StatefulPartitionedCall/model/reshape_1/Reshape/shape/2", - "op": "Const", - "input": [ - "^input" - ], - "attr": { - "value": { - "tensor": { - "dtype": "DT_INT32", - "tensorShape": {} - } - }, - "dtype": { - "type": "DT_INT32" - } - } - }, - { - "name": "StatefulPartitionedCall/model/regressor_16/Conv2D/ReadVariableOp", - "op": "Const", - "input": [ - "^input" - ], - "attr": { - "dtype": { - "type": "DT_FLOAT" - }, - "value": { - "tensor": { - "dtype": "DT_FLOAT", - "tensorShape": { - "dim": [ - { - "size": "1" - }, - { - "size": "1" - }, - { - "size": "96" - }, - { - "size": "96" - } - ] - } - } - } - } - }, - { - "name": "StatefulPartitionedCall/model/regressor_16/BiasAdd/ReadVariableOp", - "op": "Const", - "input": [ - "^input" - ], - "attr": { - "dtype": { - "type": "DT_FLOAT" - }, - "value": { - "tensor": { - "dtype": "DT_FLOAT", - "tensorShape": { - "dim": [ - { - "size": "96" - } - ] - } - } - } - } - }, - { - "name": "StatefulPartitionedCall/model/objects/concat/axis", - "op": "Const", - "input": [ - "^input" - ], - "attr": { - "value": { - "tensor": { - "dtype": "DT_INT32", - "tensorShape": {} - } - }, - "dtype": { - "type": "DT_INT32" - } - } - }, - { - "name": "StatefulPartitionedCall/model/activation/Relu", - "op": "_FusedConv2D", - "input": [ - "input", - "StatefulPartitionedCall/model/conv2d/Conv2D_weights", - "StatefulPartitionedCall/model/conv2d/Conv2D_bn_offset" - ], - "device": "/device:CPU:0", - "attr": { - "num_args": { - "i": "1" - }, - "epsilon": { - "f": 0 - }, - "padding": { - "s": "U0FNRQ==" - }, - "fused_ops": { - "list": { - "s": [ - "Qmlhc0FkZA==", - "UmVsdQ==" - ] - } - }, - "dilations": { - "list": { - "i": [ - "1", - "1", - "1", - "1" - ] - } - }, - "T": { - "type": "DT_FLOAT" - }, - "strides": { - "list": { - "i": [ - "1", - "2", - "2", - "1" - ] - } - }, - "data_format": { - "s": "TkhXQw==" - }, - "explicit_paddings": { - "list": {} - }, - "use_cudnn_on_gpu": { - "b": true - } - } - }, - { - "name": "StatefulPartitionedCall/model/depthwise_conv2d/depthwise", - "op": "DepthwiseConv2dNative", - "input": [ - "StatefulPartitionedCall/model/activation/Relu", - "StatefulPartitionedCall/model/depthwise_conv2d/depthwise/ReadVariableOp" - ], - "attr": { - "data_format": { - "s": "TkhXQw==" - }, - "strides": { - "list": { - "i": [ - "1", - "1", - "1", - "1" - ] - } - }, - "dilations": { - "list": { - "i": [ - "1", - "1", - "1", - "1" - ] - } - }, - "padding": { - "s": "U0FNRQ==" - }, - "T": { - "type": "DT_FLOAT" - } - } - }, - { - "name": "StatefulPartitionedCall/model/batch_normalization_v1_1/FusedBatchNormV3", - "op": "_FusedConv2D", - "input": [ - "StatefulPartitionedCall/model/depthwise_conv2d/depthwise", - "StatefulPartitionedCall/model/conv2d_1/Conv2D_weights", - "StatefulPartitionedCall/model/conv2d_1/Conv2D_bn_offset" - ], - "device": "/device:CPU:0", - "attr": { - "dilations": { - "list": { - "i": [ - "1", - "1", - "1", - "1" - ] - } - }, - "T": { - "type": "DT_FLOAT" - }, - "strides": { - "list": { - "i": [ - "1", - "1", - "1", - "1" - ] - } - }, - "data_format": { - "s": "TkhXQw==" - }, - "explicit_paddings": { - "list": {} - }, - "use_cudnn_on_gpu": { - "b": true - }, - "num_args": { - "i": "1" - }, - "epsilon": { - "f": 0 - }, - "padding": { - "s": "VkFMSUQ=" - }, - "fused_ops": { - "list": { - "s": [ - "Qmlhc0FkZA==" - ] - } - } - } - }, - { - "name": "StatefulPartitionedCall/model/add/add", - "op": "AddV2", - "input": [ - "StatefulPartitionedCall/model/activation/Relu", - "StatefulPartitionedCall/model/batch_normalization_v1_1/FusedBatchNormV3" - ], - "attr": { - "T": { - "type": "DT_FLOAT" - } - } - }, - { - "name": "StatefulPartitionedCall/model/activation_1/Relu", - "op": "Relu", - "input": [ - "StatefulPartitionedCall/model/add/add" - ], - "attr": { - "T": { - "type": "DT_FLOAT" - } - } - }, - { - "name": "StatefulPartitionedCall/model/channel_padding/Pad", - "op": "Pad", - "input": [ - "StatefulPartitionedCall/model/activation_1/Relu", - "StatefulPartitionedCall/model/channel_padding/Pad/paddings" - ], - "attr": { - "Tpaddings": { - "type": "DT_INT32" - }, - "T": { - "type": "DT_FLOAT" - } - } - }, - { - "name": "StatefulPartitionedCall/model/depthwise_conv2d_1/depthwise", - "op": "DepthwiseConv2dNative", - "input": [ - "StatefulPartitionedCall/model/activation_1/Relu", - "StatefulPartitionedCall/model/depthwise_conv2d_1/depthwise/ReadVariableOp" - ], - "attr": { - "T": { - "type": "DT_FLOAT" - }, - "data_format": { - "s": "TkhXQw==" - }, - "strides": { - "list": { - "i": [ - "1", - "1", - "1", - "1" - ] - } - }, - "padding": { - "s": "U0FNRQ==" - }, - "dilations": { - "list": { - "i": [ - "1", - "1", - "1", - "1" - ] - } - } - } - }, - { - "name": "StatefulPartitionedCall/model/batch_normalization_v1_2/FusedBatchNormV3", - "op": "_FusedConv2D", - "input": [ - "StatefulPartitionedCall/model/depthwise_conv2d_1/depthwise", - "StatefulPartitionedCall/model/conv2d_2/Conv2D_weights", - "StatefulPartitionedCall/model/conv2d_2/Conv2D_bn_offset" - ], - "device": "/device:CPU:0", - "attr": { - "dilations": { - "list": { - "i": [ - "1", - "1", - "1", - "1" - ] - } - }, - "T": { - "type": "DT_FLOAT" - }, - "data_format": { - "s": "TkhXQw==" - }, - "strides": { - "list": { - "i": [ - "1", - "1", - "1", - "1" - ] - } - }, - "use_cudnn_on_gpu": { - "b": true - }, - "explicit_paddings": { - "list": {} - }, - "num_args": { - "i": "1" - }, - "epsilon": { - "f": 0 - }, - "padding": { - "s": "VkFMSUQ=" - }, - "fused_ops": { - "list": { - "s": [ - "Qmlhc0FkZA==" - ] - } - } - } - }, - { - "name": "StatefulPartitionedCall/model/add_1/add", - "op": "AddV2", - "input": [ - "StatefulPartitionedCall/model/batch_normalization_v1_2/FusedBatchNormV3", - "StatefulPartitionedCall/model/channel_padding/Pad" - ], - "attr": { - "T": { - "type": "DT_FLOAT" - } - } - }, - { - "name": "StatefulPartitionedCall/model/activation_2/Relu", - "op": "Relu", - "input": [ - "StatefulPartitionedCall/model/add_1/add" - ], - "attr": { - "T": { - "type": "DT_FLOAT" - } - } - }, - { - "name": "StatefulPartitionedCall/model/max_pooling2d/MaxPool", - "op": "MaxPool", - "input": [ - "StatefulPartitionedCall/model/activation_2/Relu" - ], - "attr": { - "ksize": { - "list": { - "i": [ - "1", - "2", - "2", - "1" - ] - } - }, - "padding": { - "s": "U0FNRQ==" - }, - "T": { - "type": "DT_FLOAT" - }, - "strides": { - "list": { - "i": [ - "1", - "2", - "2", - "1" - ] - } - }, - "data_format": { - "s": "TkhXQw==" - } - } - }, - { - "name": "StatefulPartitionedCall/model/depthwise_conv2d_2/depthwise", - "op": "DepthwiseConv2dNative", - "input": [ - "StatefulPartitionedCall/model/activation_2/Relu", - "StatefulPartitionedCall/model/depthwise_conv2d_2/depthwise/ReadVariableOp" - ], - "attr": { - "padding": { - "s": "U0FNRQ==" - }, - "dilations": { - "list": { - "i": [ - "1", - "1", - "1", - "1" - ] - } - }, - "T": { - "type": "DT_FLOAT" - }, - "data_format": { - "s": "TkhXQw==" - }, - "strides": { - "list": { - "i": [ - "1", - "2", - "2", - "1" - ] - } - } - } - }, - { - "name": "StatefulPartitionedCall/model/channel_padding_1/Pad", - "op": "Pad", - "input": [ - "StatefulPartitionedCall/model/max_pooling2d/MaxPool", - "StatefulPartitionedCall/model/channel_padding/Pad/paddings" - ], - "attr": { - "T": { - "type": "DT_FLOAT" - }, - "Tpaddings": { - "type": "DT_INT32" - } - } - }, - { - "name": "StatefulPartitionedCall/model/batch_normalization_v1_3/FusedBatchNormV3", - "op": "_FusedConv2D", - "input": [ - "StatefulPartitionedCall/model/depthwise_conv2d_2/depthwise", - "StatefulPartitionedCall/model/conv2d_3/Conv2D_weights", - "StatefulPartitionedCall/model/conv2d_3/Conv2D_bn_offset" - ], - "device": "/device:CPU:0", - "attr": { - "num_args": { - "i": "1" - }, - "epsilon": { - "f": 0 - }, - "padding": { - "s": "VkFMSUQ=" - }, - "fused_ops": { - "list": { - "s": [ - "Qmlhc0FkZA==" - ] - } - }, - "dilations": { - "list": { - "i": [ - "1", - "1", - "1", - "1" - ] - } - }, - "T": { - "type": "DT_FLOAT" - }, - "strides": { - "list": { - "i": [ - "1", - "1", - "1", - "1" - ] - } - }, - "data_format": { - "s": "TkhXQw==" - }, - "explicit_paddings": { - "list": {} - }, - "use_cudnn_on_gpu": { - "b": true - } - } - }, - { - "name": "StatefulPartitionedCall/model/add_2/add", - "op": "AddV2", - "input": [ - "StatefulPartitionedCall/model/batch_normalization_v1_3/FusedBatchNormV3", - "StatefulPartitionedCall/model/channel_padding_1/Pad" - ], - "attr": { - "T": { - "type": "DT_FLOAT" - } - } - }, - { - "name": "StatefulPartitionedCall/model/activation_3/Relu", - "op": "Relu", - "input": [ - "StatefulPartitionedCall/model/add_2/add" - ], - "attr": { - "T": { - "type": "DT_FLOAT" - } - } - }, - { - "name": "StatefulPartitionedCall/model/channel_padding_2/Pad", - "op": "Pad", - "input": [ - "StatefulPartitionedCall/model/activation_3/Relu", - "StatefulPartitionedCall/model/channel_padding/Pad/paddings" - ], - "attr": { - "T": { - "type": "DT_FLOAT" - }, - "Tpaddings": { - "type": "DT_INT32" - } - } - }, - { - "name": "StatefulPartitionedCall/model/depthwise_conv2d_3/depthwise", - "op": "DepthwiseConv2dNative", - "input": [ - "StatefulPartitionedCall/model/activation_3/Relu", - "StatefulPartitionedCall/model/depthwise_conv2d_3/depthwise/ReadVariableOp" - ], - "attr": { - "data_format": { - "s": "TkhXQw==" - }, - "strides": { - "list": { - "i": [ - "1", - "1", - "1", - "1" - ] - } - }, - "padding": { - "s": "U0FNRQ==" - }, - "dilations": { - "list": { - "i": [ - "1", - "1", - "1", - "1" - ] - } - }, - "T": { - "type": "DT_FLOAT" - } - } - }, - { - "name": "StatefulPartitionedCall/model/batch_normalization_v1_4/FusedBatchNormV3", - "op": "_FusedConv2D", - "input": [ - "StatefulPartitionedCall/model/depthwise_conv2d_3/depthwise", - "StatefulPartitionedCall/model/conv2d_4/Conv2D_weights", - "StatefulPartitionedCall/model/conv2d_4/Conv2D_bn_offset" - ], - "device": "/device:CPU:0", - "attr": { - "fused_ops": { - "list": { - "s": [ - "Qmlhc0FkZA==" - ] - } - }, - "dilations": { - "list": { - "i": [ - "1", - "1", - "1", - "1" - ] - } - }, - "T": { - "type": "DT_FLOAT" - }, - "data_format": { - "s": "TkhXQw==" - }, - "strides": { - "list": { - "i": [ - "1", - "1", - "1", - "1" - ] - } - }, - "explicit_paddings": { - "list": {} - }, - "use_cudnn_on_gpu": { - "b": true - }, - "num_args": { - "i": "1" - }, - "epsilon": { - "f": 0 - }, - "padding": { - "s": "VkFMSUQ=" - } - } - }, - { - "name": "StatefulPartitionedCall/model/add_3/add", - "op": "AddV2", - "input": [ - "StatefulPartitionedCall/model/batch_normalization_v1_4/FusedBatchNormV3", - "StatefulPartitionedCall/model/channel_padding_2/Pad" - ], - "attr": { - "T": { - "type": "DT_FLOAT" - } - } - }, - { - "name": "StatefulPartitionedCall/model/activation_4/Relu", - "op": "Relu", - "input": [ - "StatefulPartitionedCall/model/add_3/add" - ], - "attr": { - "T": { - "type": "DT_FLOAT" - } - } - }, - { - "name": "StatefulPartitionedCall/model/channel_padding_3/Pad", - "op": "Pad", - "input": [ - "StatefulPartitionedCall/model/activation_4/Relu", - "StatefulPartitionedCall/model/channel_padding_3/Pad/paddings" - ], - "attr": { - "T": { - "type": "DT_FLOAT" - }, - "Tpaddings": { - "type": "DT_INT32" - } - } - }, - { - "name": "StatefulPartitionedCall/model/depthwise_conv2d_4/depthwise", - "op": "DepthwiseConv2dNative", - "input": [ - "StatefulPartitionedCall/model/activation_4/Relu", - "StatefulPartitionedCall/model/depthwise_conv2d_4/depthwise/ReadVariableOp" - ], - "attr": { - "dilations": { - "list": { - "i": [ - "1", - "1", - "1", - "1" - ] - } - }, - "padding": { - "s": "U0FNRQ==" - }, - "T": { - "type": "DT_FLOAT" - }, - "strides": { - "list": { - "i": [ - "1", - "1", - "1", - "1" - ] - } - }, - "data_format": { - "s": "TkhXQw==" - } - } - }, - { - "name": "StatefulPartitionedCall/model/batch_normalization_v1_5/FusedBatchNormV3", - "op": "_FusedConv2D", - "input": [ - "StatefulPartitionedCall/model/depthwise_conv2d_4/depthwise", - "StatefulPartitionedCall/model/conv2d_5/Conv2D_weights", - "StatefulPartitionedCall/model/conv2d_5/Conv2D_bn_offset" - ], - "device": "/device:CPU:0", - "attr": { - "data_format": { - "s": "TkhXQw==" - }, - "strides": { - "list": { - "i": [ - "1", - "1", - "1", - "1" - ] - } - }, - "explicit_paddings": { - "list": {} - }, - "use_cudnn_on_gpu": { - "b": true - }, - "num_args": { - "i": "1" - }, - "epsilon": { - "f": 0 - }, - "padding": { - "s": "VkFMSUQ=" - }, - "fused_ops": { - "list": { - "s": [ - "Qmlhc0FkZA==" - ] - } - }, - "dilations": { - "list": { - "i": [ - "1", - "1", - "1", - "1" - ] - } - }, - "T": { - "type": "DT_FLOAT" - } - } - }, - { - "name": "StatefulPartitionedCall/model/add_4/add", - "op": "AddV2", - "input": [ - "StatefulPartitionedCall/model/batch_normalization_v1_5/FusedBatchNormV3", - "StatefulPartitionedCall/model/channel_padding_3/Pad" - ], - "attr": { - "T": { - "type": "DT_FLOAT" - } - } - }, - { - "name": "StatefulPartitionedCall/model/activation_5/Relu", - "op": "Relu", - "input": [ - "StatefulPartitionedCall/model/add_4/add" - ], - "attr": { - "T": { - "type": "DT_FLOAT" - } - } - }, - { - "name": "StatefulPartitionedCall/model/max_pooling2d_1/MaxPool", - "op": "MaxPool", - "input": [ - "StatefulPartitionedCall/model/activation_5/Relu" - ], - "attr": { - "T": { - "type": "DT_FLOAT" - }, - "data_format": { - "s": "TkhXQw==" - }, - "strides": { - "list": { - "i": [ - "1", - "2", - "2", - "1" - ] - } - }, - "ksize": { - "list": { - "i": [ - "1", - "2", - "2", - "1" - ] - } - }, - "padding": { - "s": "U0FNRQ==" - } - } - }, - { - "name": "StatefulPartitionedCall/model/depthwise_conv2d_5/depthwise", - "op": "DepthwiseConv2dNative", - "input": [ - "StatefulPartitionedCall/model/activation_5/Relu", - "StatefulPartitionedCall/model/depthwise_conv2d_5/depthwise/ReadVariableOp" - ], - "attr": { - "strides": { - "list": { - "i": [ - "1", - "2", - "2", - "1" - ] - } - }, - "data_format": { - "s": "TkhXQw==" - }, - "dilations": { - "list": { - "i": [ - "1", - "1", - "1", - "1" - ] - } - }, - "padding": { - "s": "U0FNRQ==" - }, - "T": { - "type": "DT_FLOAT" - } - } - }, - { - "name": "StatefulPartitionedCall/model/channel_padding_4/Pad", - "op": "Pad", - "input": [ - "StatefulPartitionedCall/model/max_pooling2d_1/MaxPool", - "StatefulPartitionedCall/model/channel_padding_3/Pad/paddings" - ], - "attr": { - "Tpaddings": { - "type": "DT_INT32" - }, - "T": { - "type": "DT_FLOAT" - } - } - }, - { - "name": "StatefulPartitionedCall/model/batch_normalization_v1_6/FusedBatchNormV3", - "op": "_FusedConv2D", - "input": [ - "StatefulPartitionedCall/model/depthwise_conv2d_5/depthwise", - "StatefulPartitionedCall/model/conv2d_6/Conv2D_weights", - "StatefulPartitionedCall/model/conv2d_6/Conv2D_bn_offset" - ], - "device": "/device:CPU:0", - "attr": { - "num_args": { - "i": "1" - }, - "epsilon": { - "f": 0 - }, - "padding": { - "s": "VkFMSUQ=" - }, - "fused_ops": { - "list": { - "s": [ - "Qmlhc0FkZA==" - ] - } - }, - "dilations": { - "list": { - "i": [ - "1", - "1", - "1", - "1" - ] - } - }, - "T": { - "type": "DT_FLOAT" - }, - "data_format": { - "s": "TkhXQw==" - }, - "strides": { - "list": { - "i": [ - "1", - "1", - "1", - "1" - ] - } - }, - "use_cudnn_on_gpu": { - "b": true - }, - "explicit_paddings": { - "list": {} - } - } - }, - { - "name": "StatefulPartitionedCall/model/add_5/add", - "op": "AddV2", - "input": [ - "StatefulPartitionedCall/model/batch_normalization_v1_6/FusedBatchNormV3", - "StatefulPartitionedCall/model/channel_padding_4/Pad" - ], - "attr": { - "T": { - "type": "DT_FLOAT" - } - } - }, - { - "name": "StatefulPartitionedCall/model/activation_6/Relu", - "op": "Relu", - "input": [ - "StatefulPartitionedCall/model/add_5/add" - ], - "attr": { - "T": { - "type": "DT_FLOAT" - } - } - }, - { - "name": "StatefulPartitionedCall/model/channel_padding_5/Pad", - "op": "Pad", - "input": [ - "StatefulPartitionedCall/model/activation_6/Relu", - "StatefulPartitionedCall/model/channel_padding_5/Pad/paddings" - ], - "attr": { - "T": { - "type": "DT_FLOAT" - }, - "Tpaddings": { - "type": "DT_INT32" - } - } - }, - { - "name": "StatefulPartitionedCall/model/depthwise_conv2d_6/depthwise", - "op": "DepthwiseConv2dNative", - "input": [ - "StatefulPartitionedCall/model/activation_6/Relu", - "StatefulPartitionedCall/model/depthwise_conv2d_6/depthwise/ReadVariableOp" - ], - "attr": { - "padding": { - "s": "U0FNRQ==" - }, - "dilations": { - "list": { - "i": [ - "1", - "1", - "1", - "1" - ] - } - }, - "T": { - "type": "DT_FLOAT" - }, - "strides": { - "list": { - "i": [ - "1", - "1", - "1", - "1" - ] - } - }, - "data_format": { - "s": "TkhXQw==" - } - } - }, - { - "name": "StatefulPartitionedCall/model/batch_normalization_v1_7/FusedBatchNormV3", - "op": "_FusedConv2D", - "input": [ - "StatefulPartitionedCall/model/depthwise_conv2d_6/depthwise", - "StatefulPartitionedCall/model/conv2d_7/Conv2D_weights", - "StatefulPartitionedCall/model/conv2d_7/Conv2D_bn_offset" - ], - "device": "/device:CPU:0", - "attr": { - "dilations": { - "list": { - "i": [ - "1", - "1", - "1", - "1" - ] - } - }, - "T": { - "type": "DT_FLOAT" - }, - "data_format": { - "s": "TkhXQw==" - }, - "strides": { - "list": { - "i": [ - "1", - "1", - "1", - "1" - ] - } - }, - "explicit_paddings": { - "list": {} - }, - "use_cudnn_on_gpu": { - "b": true - }, - "num_args": { - "i": "1" - }, - "epsilon": { - "f": 0 - }, - "padding": { - "s": "VkFMSUQ=" - }, - "fused_ops": { - "list": { - "s": [ - "Qmlhc0FkZA==" - ] - } - } - } - }, - { - "name": "StatefulPartitionedCall/model/add_6/add", - "op": "AddV2", - "input": [ - "StatefulPartitionedCall/model/batch_normalization_v1_7/FusedBatchNormV3", - "StatefulPartitionedCall/model/channel_padding_5/Pad" - ], - "attr": { - "T": { - "type": "DT_FLOAT" - } - } - }, - { - "name": "StatefulPartitionedCall/model/activation_7/Relu", - "op": "Relu", - "input": [ - "StatefulPartitionedCall/model/add_6/add" - ], - "attr": { - "T": { - "type": "DT_FLOAT" - } - } - }, - { - "name": "StatefulPartitionedCall/model/channel_padding_6/Pad", - "op": "Pad", - "input": [ - "StatefulPartitionedCall/model/activation_7/Relu", - "StatefulPartitionedCall/model/channel_padding_5/Pad/paddings" - ], - "attr": { - "T": { - "type": "DT_FLOAT" - }, - "Tpaddings": { - "type": "DT_INT32" - } - } - }, - { - "name": "StatefulPartitionedCall/model/depthwise_conv2d_7/depthwise", - "op": "DepthwiseConv2dNative", - "input": [ - "StatefulPartitionedCall/model/activation_7/Relu", - "StatefulPartitionedCall/model/depthwise_conv2d_7/depthwise/ReadVariableOp" - ], - "attr": { - "dilations": { - "list": { - "i": [ - "1", - "1", - "1", - "1" - ] - } - }, - "padding": { - "s": "U0FNRQ==" - }, - "T": { - "type": "DT_FLOAT" - }, - "data_format": { - "s": "TkhXQw==" - }, - "strides": { - "list": { - "i": [ - "1", - "1", - "1", - "1" - ] - } - } - } - }, - { - "name": "StatefulPartitionedCall/model/batch_normalization_v1_8/FusedBatchNormV3", - "op": "_FusedConv2D", - "input": [ - "StatefulPartitionedCall/model/depthwise_conv2d_7/depthwise", - "StatefulPartitionedCall/model/conv2d_8/Conv2D_weights", - "StatefulPartitionedCall/model/conv2d_8/Conv2D_bn_offset" - ], - "device": "/device:CPU:0", - "attr": { - "fused_ops": { - "list": { - "s": [ - "Qmlhc0FkZA==" - ] - } - }, - "dilations": { - "list": { - "i": [ - "1", - "1", - "1", - "1" - ] - } - }, - "T": { - "type": "DT_FLOAT" - }, - "strides": { - "list": { - "i": [ - "1", - "1", - "1", - "1" - ] - } - }, - "data_format": { - "s": "TkhXQw==" - }, - "explicit_paddings": { - "list": {} - }, - "use_cudnn_on_gpu": { - "b": true - }, - "num_args": { - "i": "1" - }, - "epsilon": { - "f": 0 - }, - "padding": { - "s": "VkFMSUQ=" - } - } - }, - { - "name": "StatefulPartitionedCall/model/add_7/add", - "op": "AddV2", - "input": [ - "StatefulPartitionedCall/model/batch_normalization_v1_8/FusedBatchNormV3", - "StatefulPartitionedCall/model/channel_padding_6/Pad" - ], - "attr": { - "T": { - "type": "DT_FLOAT" - } - } - }, - { - "name": "StatefulPartitionedCall/model/activation_8/Relu", - "op": "Relu", - "input": [ - "StatefulPartitionedCall/model/add_7/add" - ], - "attr": { - "T": { - "type": "DT_FLOAT" - } - } - }, - { - "name": "StatefulPartitionedCall/model/channel_padding_7/Pad", - "op": "Pad", - "input": [ - "StatefulPartitionedCall/model/activation_8/Relu", - "StatefulPartitionedCall/model/channel_padding_5/Pad/paddings" - ], - "attr": { - "T": { - "type": "DT_FLOAT" - }, - "Tpaddings": { - "type": "DT_INT32" - } - } - }, - { - "name": "StatefulPartitionedCall/model/depthwise_conv2d_8/depthwise", - "op": "DepthwiseConv2dNative", - "input": [ - "StatefulPartitionedCall/model/activation_8/Relu", - "StatefulPartitionedCall/model/depthwise_conv2d_8/depthwise/ReadVariableOp" - ], - "attr": { - "strides": { - "list": { - "i": [ - "1", - "1", - "1", - "1" - ] - } - }, - "data_format": { - "s": "TkhXQw==" - }, - "dilations": { - "list": { - "i": [ - "1", - "1", - "1", - "1" - ] - } - }, - "padding": { - "s": "U0FNRQ==" - }, - "T": { - "type": "DT_FLOAT" - } - } - }, - { - "name": "StatefulPartitionedCall/model/batch_normalization_v1_9/FusedBatchNormV3", - "op": "_FusedConv2D", - "input": [ - "StatefulPartitionedCall/model/depthwise_conv2d_8/depthwise", - "StatefulPartitionedCall/model/conv2d_9/Conv2D_weights", - "StatefulPartitionedCall/model/conv2d_9/Conv2D_bn_offset" - ], - "device": "/device:CPU:0", - "attr": { - "fused_ops": { - "list": { - "s": [ - "Qmlhc0FkZA==" - ] - } - }, - "dilations": { - "list": { - "i": [ - "1", - "1", - "1", - "1" - ] - } - }, - "T": { - "type": "DT_FLOAT" - }, - "strides": { - "list": { - "i": [ - "1", - "1", - "1", - "1" - ] - } - }, - "data_format": { - "s": "TkhXQw==" - }, - "use_cudnn_on_gpu": { - "b": true - }, - "explicit_paddings": { - "list": {} - }, - "num_args": { - "i": "1" - }, - "epsilon": { - "f": 0 - }, - "padding": { - "s": "VkFMSUQ=" - } - } - }, - { - "name": "StatefulPartitionedCall/model/add_8/add", - "op": "AddV2", - "input": [ - "StatefulPartitionedCall/model/batch_normalization_v1_9/FusedBatchNormV3", - "StatefulPartitionedCall/model/channel_padding_7/Pad" - ], - "attr": { - "T": { - "type": "DT_FLOAT" - } - } - }, - { - "name": "StatefulPartitionedCall/model/activation_9/Relu", - "op": "Relu", - "input": [ - "StatefulPartitionedCall/model/add_8/add" - ], - "attr": { - "T": { - "type": "DT_FLOAT" - } - } - }, - { - "name": "StatefulPartitionedCall/model/channel_padding_8/Pad", - "op": "Pad", - "input": [ - "StatefulPartitionedCall/model/activation_9/Relu", - "StatefulPartitionedCall/model/channel_padding_5/Pad/paddings" - ], - "attr": { - "T": { - "type": "DT_FLOAT" - }, - "Tpaddings": { - "type": "DT_INT32" - } - } - }, - { - "name": "StatefulPartitionedCall/model/depthwise_conv2d_9/depthwise", - "op": "DepthwiseConv2dNative", - "input": [ - "StatefulPartitionedCall/model/activation_9/Relu", - "StatefulPartitionedCall/model/depthwise_conv2d_9/depthwise/ReadVariableOp" - ], - "attr": { - "dilations": { - "list": { - "i": [ - "1", - "1", - "1", - "1" - ] - } - }, - "padding": { - "s": "U0FNRQ==" - }, - "T": { - "type": "DT_FLOAT" - }, - "data_format": { - "s": "TkhXQw==" - }, - "strides": { - "list": { - "i": [ - "1", - "1", - "1", - "1" - ] - } - } - } - }, - { - "name": "StatefulPartitionedCall/model/batch_normalization_v1_10/FusedBatchNormV3", - "op": "_FusedConv2D", - "input": [ - "StatefulPartitionedCall/model/depthwise_conv2d_9/depthwise", - "StatefulPartitionedCall/model/conv2d_10/Conv2D_weights", - "StatefulPartitionedCall/model/conv2d_10/Conv2D_bn_offset" - ], - "device": "/device:CPU:0", - "attr": { - "data_format": { - "s": "TkhXQw==" - }, - "strides": { - "list": { - "i": [ - "1", - "1", - "1", - "1" - ] - } - }, - "use_cudnn_on_gpu": { - "b": true - }, - "explicit_paddings": { - "list": {} - }, - "num_args": { - "i": "1" - }, - "epsilon": { - "f": 0 - }, - "padding": { - "s": "VkFMSUQ=" - }, - "fused_ops": { - "list": { - "s": [ - "Qmlhc0FkZA==" - ] - } - }, - "dilations": { - "list": { - "i": [ - "1", - "1", - "1", - "1" - ] - } - }, - "T": { - "type": "DT_FLOAT" - } - } - }, - { - "name": "StatefulPartitionedCall/model/add_9/add", - "op": "AddV2", - "input": [ - "StatefulPartitionedCall/model/batch_normalization_v1_10/FusedBatchNormV3", - "StatefulPartitionedCall/model/channel_padding_8/Pad" - ], - "attr": { - "T": { - "type": "DT_FLOAT" - } - } - }, - { - "name": "StatefulPartitionedCall/model/activation_10/Relu", - "op": "Relu", - "input": [ - "StatefulPartitionedCall/model/add_9/add" - ], - "attr": { - "T": { - "type": "DT_FLOAT" - } - } - }, - { - "name": "StatefulPartitionedCall/model/channel_padding_9/Pad", - "op": "Pad", - "input": [ - "StatefulPartitionedCall/model/activation_10/Relu", - "StatefulPartitionedCall/model/channel_padding_5/Pad/paddings" - ], - "attr": { - "Tpaddings": { - "type": "DT_INT32" - }, - "T": { - "type": "DT_FLOAT" - } - } - }, - { - "name": "StatefulPartitionedCall/model/depthwise_conv2d_10/depthwise", - "op": "DepthwiseConv2dNative", - "input": [ - "StatefulPartitionedCall/model/activation_10/Relu", - "StatefulPartitionedCall/model/depthwise_conv2d_10/depthwise/ReadVariableOp" - ], - "attr": { - "padding": { - "s": "U0FNRQ==" - }, - "dilations": { - "list": { - "i": [ - "1", - "1", - "1", - "1" - ] - } - }, - "T": { - "type": "DT_FLOAT" - }, - "strides": { - "list": { - "i": [ - "1", - "1", - "1", - "1" - ] - } - }, - "data_format": { - "s": "TkhXQw==" - } - } - }, - { - "name": "StatefulPartitionedCall/model/batch_normalization_v1_11/FusedBatchNormV3", - "op": "_FusedConv2D", - "input": [ - "StatefulPartitionedCall/model/depthwise_conv2d_10/depthwise", - "StatefulPartitionedCall/model/conv2d_11/Conv2D_weights", - "StatefulPartitionedCall/model/conv2d_11/Conv2D_bn_offset" - ], - "device": "/device:CPU:0", - "attr": { - "dilations": { - "list": { - "i": [ - "1", - "1", - "1", - "1" - ] - } - }, - "T": { - "type": "DT_FLOAT" - }, - "strides": { - "list": { - "i": [ - "1", - "1", - "1", - "1" - ] - } - }, - "data_format": { - "s": "TkhXQw==" - }, - "explicit_paddings": { - "list": {} - }, - "use_cudnn_on_gpu": { - "b": true - }, - "num_args": { - "i": "1" - }, - "epsilon": { - "f": 0 - }, - "padding": { - "s": "VkFMSUQ=" - }, - "fused_ops": { - "list": { - "s": [ - "Qmlhc0FkZA==" - ] - } - } - } - }, - { - "name": "StatefulPartitionedCall/model/add_10/add", - "op": "AddV2", - "input": [ - "StatefulPartitionedCall/model/batch_normalization_v1_11/FusedBatchNormV3", - "StatefulPartitionedCall/model/channel_padding_9/Pad" - ], - "attr": { - "T": { - "type": "DT_FLOAT" - } - } - }, - { - "name": "StatefulPartitionedCall/model/activation_11/Relu", - "op": "Relu", - "input": [ - "StatefulPartitionedCall/model/add_10/add" - ], - "attr": { - "T": { - "type": "DT_FLOAT" - } - } - }, - { - "name": "StatefulPartitionedCall/model/max_pooling2d_2/MaxPool", - "op": "MaxPool", - "input": [ - "StatefulPartitionedCall/model/activation_11/Relu" - ], - "attr": { - "ksize": { - "list": { - "i": [ - "1", - "2", - "2", - "1" - ] - } - }, - "padding": { - "s": "U0FNRQ==" - }, - "T": { - "type": "DT_FLOAT" - }, - "strides": { - "list": { - "i": [ - "1", - "2", - "2", - "1" - ] - } - }, - "data_format": { - "s": "TkhXQw==" - } - } - }, - { - "name": "StatefulPartitionedCall/model/classificator_8/BiasAdd", - "op": "_FusedConv2D", - "input": [ - "StatefulPartitionedCall/model/activation_11/Relu", - "StatefulPartitionedCall/model/classificator_8/Conv2D/ReadVariableOp", - "StatefulPartitionedCall/model/classificator_8/BiasAdd/ReadVariableOp" - ], - "device": "/device:CPU:0", - "attr": { - "data_format": { - "s": "TkhXQw==" - }, - "strides": { - "list": { - "i": [ - "1", - "1", - "1", - "1" - ] - } - }, - "use_cudnn_on_gpu": { - "b": true - }, - "explicit_paddings": { - "list": {} - }, - "num_args": { - "i": "1" - }, - "epsilon": { - "f": 0 - }, - "padding": { - "s": "U0FNRQ==" - }, - "fused_ops": { - "list": { - "s": [ - "Qmlhc0FkZA==" - ] - } - }, - "dilations": { - "list": { - "i": [ - "1", - "1", - "1", - "1" - ] - } - }, - "T": { - "type": "DT_FLOAT" - } - } - }, - { - "name": "StatefulPartitionedCall/model/depthwise_conv2d_11/depthwise", - "op": "DepthwiseConv2dNative", - "input": [ - "StatefulPartitionedCall/model/activation_11/Relu", - "StatefulPartitionedCall/model/depthwise_conv2d_11/depthwise/ReadVariableOp" - ], - "attr": { - "padding": { - "s": "U0FNRQ==" - }, - "dilations": { - "list": { - "i": [ - "1", - "1", - "1", - "1" - ] - } - }, - "T": { - "type": "DT_FLOAT" - }, - "data_format": { - "s": "TkhXQw==" - }, - "strides": { - "list": { - "i": [ - "1", - "2", - "2", - "1" - ] - } - } - } - }, - { - "name": "StatefulPartitionedCall/model/regressor_8/BiasAdd", - "op": "_FusedConv2D", - "input": [ - "StatefulPartitionedCall/model/activation_11/Relu", - "StatefulPartitionedCall/model/regressor_8/Conv2D/ReadVariableOp", - "StatefulPartitionedCall/model/regressor_8/BiasAdd/ReadVariableOp" - ], - "device": "/device:CPU:0", - "attr": { - "dilations": { - "list": { - "i": [ - "1", - "1", - "1", - "1" - ] - } - }, - "T": { - "type": "DT_FLOAT" - }, - "data_format": { - "s": "TkhXQw==" - }, - "strides": { - "list": { - "i": [ - "1", - "1", - "1", - "1" - ] - } - }, - "use_cudnn_on_gpu": { - "b": true - }, - "explicit_paddings": { - "list": {} - }, - "num_args": { - "i": "1" - }, - "epsilon": { - "f": 0 - }, - "padding": { - "s": "U0FNRQ==" - }, - "fused_ops": { - "list": { - "s": [ - "Qmlhc0FkZA==" - ] - } - } - } - }, - { - "name": "StatefulPartitionedCall/model/channel_padding_10/Pad", - "op": "Pad", - "input": [ - "StatefulPartitionedCall/model/max_pooling2d_2/MaxPool", - "StatefulPartitionedCall/model/channel_padding_5/Pad/paddings" - ], - "attr": { - "Tpaddings": { - "type": "DT_INT32" - }, - "T": { - "type": "DT_FLOAT" - } - } - }, - { - "name": "StatefulPartitionedCall/model/reshape/Shape", - "op": "Shape", - "input": [ - "StatefulPartitionedCall/model/classificator_8/BiasAdd" - ], - "attr": { - "T": { - "type": "DT_FLOAT" - }, - "out_type": { - "type": "DT_INT32" - } - } - }, - { - "name": "StatefulPartitionedCall/model/batch_normalization_v1_12/FusedBatchNormV3", - "op": "_FusedConv2D", - "input": [ - "StatefulPartitionedCall/model/depthwise_conv2d_11/depthwise", - "StatefulPartitionedCall/model/conv2d_12/Conv2D_weights", - "StatefulPartitionedCall/model/conv2d_12/Conv2D_bn_offset" - ], - "device": "/device:CPU:0", - "attr": { - "dilations": { - "list": { - "i": [ - "1", - "1", - "1", - "1" - ] - } - }, - "T": { - "type": "DT_FLOAT" - }, - "data_format": { - "s": "TkhXQw==" - }, - "strides": { - "list": { - "i": [ - "1", - "1", - "1", - "1" - ] - } - }, - "explicit_paddings": { - "list": {} - }, - "use_cudnn_on_gpu": { - "b": true - }, - "num_args": { - "i": "1" - }, - "epsilon": { - "f": 0 - }, - "padding": { - "s": "VkFMSUQ=" - }, - "fused_ops": { - "list": { - "s": [ - "Qmlhc0FkZA==" - ] - } - } - } - }, - { - "name": "StatefulPartitionedCall/model/reshape_1/Shape", - "op": "Shape", - "input": [ - "StatefulPartitionedCall/model/regressor_8/BiasAdd" - ], - "attr": { - "T": { - "type": "DT_FLOAT" - }, - "out_type": { - "type": "DT_INT32" - } - } - }, - { - "name": "StatefulPartitionedCall/model/reshape/strided_slice", - "op": "StridedSlice", - "input": [ - "StatefulPartitionedCall/model/reshape/Shape", - "StatefulPartitionedCall/model/reshape/strided_slice/stack", - "StatefulPartitionedCall/model/reshape/strided_slice/stack_1", - "StatefulPartitionedCall/model/reshape/strided_slice/stack_1" - ], - "attr": { - "T": { - "type": "DT_INT32" - }, - "Index": { - "type": "DT_INT32" - }, - "shrink_axis_mask": { - "i": "1" - }, - "begin_mask": { - "i": "0" - }, - "ellipsis_mask": { - "i": "0" - }, - "new_axis_mask": { - "i": "0" - }, - "end_mask": { - "i": "0" - } - } - }, - { - "name": "StatefulPartitionedCall/model/add_11/add", - "op": "AddV2", - "input": [ - "StatefulPartitionedCall/model/batch_normalization_v1_12/FusedBatchNormV3", - "StatefulPartitionedCall/model/channel_padding_10/Pad" - ], - "attr": { - "T": { - "type": "DT_FLOAT" - } - } - }, - { - "name": "StatefulPartitionedCall/model/reshape_1/strided_slice", - "op": "StridedSlice", - "input": [ - "StatefulPartitionedCall/model/reshape_1/Shape", - "StatefulPartitionedCall/model/reshape/strided_slice/stack", - "StatefulPartitionedCall/model/reshape/strided_slice/stack_1", - "StatefulPartitionedCall/model/reshape/strided_slice/stack_1" - ], - "attr": { - "shrink_axis_mask": { - "i": "1" - }, - "begin_mask": { - "i": "0" - }, - "ellipsis_mask": { - "i": "0" - }, - "new_axis_mask": { - "i": "0" - }, - "end_mask": { - "i": "0" - }, - "T": { - "type": "DT_INT32" - }, - "Index": { - "type": "DT_INT32" - } - } - }, - { - "name": "StatefulPartitionedCall/model/reshape/Reshape/shape", - "op": "Pack", - "input": [ - "StatefulPartitionedCall/model/reshape/strided_slice", - "StatefulPartitionedCall/model/reshape/Reshape/shape/1", - "StatefulPartitionedCall/model/reshape/Reshape/shape/2" - ], - "attr": { - "T": { - "type": "DT_INT32" - }, - "axis": { - "i": "0" - }, - "N": { - "i": "3" - } - } - }, - { - "name": "StatefulPartitionedCall/model/activation_12/Relu", - "op": "Relu", - "input": [ - "StatefulPartitionedCall/model/add_11/add" - ], - "attr": { - "T": { - "type": "DT_FLOAT" - } - } - }, - { - "name": "StatefulPartitionedCall/model/reshape_1/Reshape/shape", - "op": "Pack", - "input": [ - "StatefulPartitionedCall/model/reshape_1/strided_slice", - "StatefulPartitionedCall/model/reshape/Reshape/shape/1", - "StatefulPartitionedCall/model/reshape_1/Reshape/shape/2" - ], - "attr": { - "T": { - "type": "DT_INT32" - }, - "axis": { - "i": "0" - }, - "N": { - "i": "3" - } - } - }, - { - "name": "StatefulPartitionedCall/model/reshape/Reshape", - "op": "Reshape", - "input": [ - "StatefulPartitionedCall/model/classificator_8/BiasAdd", - "StatefulPartitionedCall/model/reshape/Reshape/shape" - ], - "attr": { - "T": { - "type": "DT_FLOAT" - }, - "Tshape": { - "type": "DT_INT32" - } - } - }, - { - "name": "StatefulPartitionedCall/model/depthwise_conv2d_12/depthwise", - "op": "DepthwiseConv2dNative", - "input": [ - "StatefulPartitionedCall/model/activation_12/Relu", - "StatefulPartitionedCall/model/depthwise_conv2d_12/depthwise/ReadVariableOp" - ], - "attr": { - "data_format": { - "s": "TkhXQw==" - }, - "strides": { - "list": { - "i": [ - "1", - "1", - "1", - "1" - ] - } - }, - "padding": { - "s": "U0FNRQ==" - }, - "dilations": { - "list": { - "i": [ - "1", - "1", - "1", - "1" - ] - } - }, - "T": { - "type": "DT_FLOAT" - } - } - }, - { - "name": "StatefulPartitionedCall/model/reshape_1/Reshape", - "op": "Reshape", - "input": [ - "StatefulPartitionedCall/model/regressor_8/BiasAdd", - "StatefulPartitionedCall/model/reshape_1/Reshape/shape" - ], - "attr": { - "T": { - "type": "DT_FLOAT" - }, - "Tshape": { - "type": "DT_INT32" - } - } - }, - { - "name": "StatefulPartitionedCall/model/batch_normalization_v1_13/FusedBatchNormV3", - "op": "_FusedConv2D", - "input": [ - "StatefulPartitionedCall/model/depthwise_conv2d_12/depthwise", - "StatefulPartitionedCall/model/conv2d_13/Conv2D_weights", - "StatefulPartitionedCall/model/conv2d_13/Conv2D_bn_offset" - ], - "device": "/device:CPU:0", - "attr": { - "epsilon": { - "f": 0 - }, - "padding": { - "s": "VkFMSUQ=" - }, - "fused_ops": { - "list": { - "s": [ - "Qmlhc0FkZA==" - ] - } - }, - "dilations": { - "list": { - "i": [ - "1", - "1", - "1", - "1" - ] - } - }, - "T": { - "type": "DT_FLOAT" - }, - "data_format": { - "s": "TkhXQw==" - }, - "strides": { - "list": { - "i": [ - "1", - "1", - "1", - "1" - ] - } - }, - "use_cudnn_on_gpu": { - "b": true - }, - "explicit_paddings": { - "list": {} - }, - "num_args": { - "i": "1" - } - } - }, - { - "name": "StatefulPartitionedCall/model/add_12/add", - "op": "AddV2", - "input": [ - "StatefulPartitionedCall/model/activation_12/Relu", - "StatefulPartitionedCall/model/batch_normalization_v1_13/FusedBatchNormV3" - ], - "attr": { - "T": { - "type": "DT_FLOAT" - } - } - }, - { - "name": "StatefulPartitionedCall/model/activation_13/Relu", - "op": "Relu", - "input": [ - "StatefulPartitionedCall/model/add_12/add" - ], - "attr": { - "T": { - "type": "DT_FLOAT" - } - } - }, - { - "name": "StatefulPartitionedCall/model/depthwise_conv2d_13/depthwise", - "op": "DepthwiseConv2dNative", - "input": [ - "StatefulPartitionedCall/model/activation_13/Relu", - "StatefulPartitionedCall/model/depthwise_conv2d_13/depthwise/ReadVariableOp" - ], - "attr": { - "dilations": { - "list": { - "i": [ - "1", - "1", - "1", - "1" - ] - } - }, - "padding": { - "s": "U0FNRQ==" - }, - "T": { - "type": "DT_FLOAT" - }, - "strides": { - "list": { - "i": [ - "1", - "1", - "1", - "1" - ] - } - }, - "data_format": { - "s": "TkhXQw==" - } - } - }, - { - "name": "StatefulPartitionedCall/model/batch_normalization_v1_14/FusedBatchNormV3", - "op": "_FusedConv2D", - "input": [ - "StatefulPartitionedCall/model/depthwise_conv2d_13/depthwise", - "StatefulPartitionedCall/model/conv2d_14/Conv2D_weights", - "StatefulPartitionedCall/model/conv2d_14/Conv2D_bn_offset" - ], - "device": "/device:CPU:0", - "attr": { - "T": { - "type": "DT_FLOAT" - }, - "data_format": { - "s": "TkhXQw==" - }, - "strides": { - "list": { - "i": [ - "1", - "1", - "1", - "1" - ] - } - }, - "explicit_paddings": { - "list": {} - }, - "use_cudnn_on_gpu": { - "b": true - }, - "num_args": { - "i": "1" - }, - "epsilon": { - "f": 0 - }, - "padding": { - "s": "VkFMSUQ=" - }, - "fused_ops": { - "list": { - "s": [ - "Qmlhc0FkZA==" - ] - } - }, - "dilations": { - "list": { - "i": [ - "1", - "1", - "1", - "1" - ] - } - } - } - }, - { - "name": "StatefulPartitionedCall/model/add_13/add", - "op": "AddV2", - "input": [ - "StatefulPartitionedCall/model/activation_13/Relu", - "StatefulPartitionedCall/model/batch_normalization_v1_14/FusedBatchNormV3" - ], - "attr": { - "T": { - "type": "DT_FLOAT" - } - } - }, - { - "name": "StatefulPartitionedCall/model/activation_14/Relu", - "op": "Relu", - "input": [ - "StatefulPartitionedCall/model/add_13/add" - ], - "attr": { - "T": { - "type": "DT_FLOAT" - } - } - }, - { - "name": "StatefulPartitionedCall/model/depthwise_conv2d_14/depthwise", - "op": "DepthwiseConv2dNative", - "input": [ - "StatefulPartitionedCall/model/activation_14/Relu", - "StatefulPartitionedCall/model/depthwise_conv2d_14/depthwise/ReadVariableOp" - ], - "attr": { - "T": { - "type": "DT_FLOAT" - }, - "strides": { - "list": { - "i": [ - "1", - "1", - "1", - "1" - ] - } - }, - "data_format": { - "s": "TkhXQw==" - }, - "padding": { - "s": "U0FNRQ==" - }, - "dilations": { - "list": { - "i": [ - "1", - "1", - "1", - "1" - ] - } - } - } - }, - { - "name": "StatefulPartitionedCall/model/batch_normalization_v1_15/FusedBatchNormV3", - "op": "_FusedConv2D", - "input": [ - "StatefulPartitionedCall/model/depthwise_conv2d_14/depthwise", - "StatefulPartitionedCall/model/conv2d_15/Conv2D_weights", - "StatefulPartitionedCall/model/conv2d_15/Conv2D_bn_offset" - ], - "device": "/device:CPU:0", - "attr": { - "dilations": { - "list": { - "i": [ - "1", - "1", - "1", - "1" - ] - } - }, - "T": { - "type": "DT_FLOAT" - }, - "data_format": { - "s": "TkhXQw==" - }, - "strides": { - "list": { - "i": [ - "1", - "1", - "1", - "1" - ] - } - }, - "use_cudnn_on_gpu": { - "b": true - }, - "explicit_paddings": { - "list": {} - }, - "num_args": { - "i": "1" - }, - "epsilon": { - "f": 0 - }, - "padding": { - "s": "VkFMSUQ=" - }, - "fused_ops": { - "list": { - "s": [ - "Qmlhc0FkZA==" - ] - } - } - } - }, - { - "name": "StatefulPartitionedCall/model/add_14/add", - "op": "AddV2", - "input": [ - "StatefulPartitionedCall/model/activation_14/Relu", - "StatefulPartitionedCall/model/batch_normalization_v1_15/FusedBatchNormV3" - ], - "attr": { - "T": { - "type": "DT_FLOAT" - } - } - }, - { - "name": "StatefulPartitionedCall/model/activation_15/Relu", - "op": "Relu", - "input": [ - "StatefulPartitionedCall/model/add_14/add" - ], - "attr": { - "T": { - "type": "DT_FLOAT" - } - } - }, - { - "name": "StatefulPartitionedCall/model/depthwise_conv2d_15/depthwise", - "op": "DepthwiseConv2dNative", - "input": [ - "StatefulPartitionedCall/model/activation_15/Relu", - "StatefulPartitionedCall/model/depthwise_conv2d_15/depthwise/ReadVariableOp" - ], - "attr": { - "dilations": { - "list": { - "i": [ - "1", - "1", - "1", - "1" - ] - } - }, - "padding": { - "s": "U0FNRQ==" - }, - "T": { - "type": "DT_FLOAT" - }, - "data_format": { - "s": "TkhXQw==" - }, - "strides": { - "list": { - "i": [ - "1", - "1", - "1", - "1" - ] - } - } - } - }, - { - "name": "StatefulPartitionedCall/model/batch_normalization_v1_16/FusedBatchNormV3", - "op": "_FusedConv2D", - "input": [ - "StatefulPartitionedCall/model/depthwise_conv2d_15/depthwise", - "StatefulPartitionedCall/model/conv2d_16/Conv2D_weights", - "StatefulPartitionedCall/model/conv2d_16/Conv2D_bn_offset" - ], - "device": "/device:CPU:0", - "attr": { - "dilations": { - "list": { - "i": [ - "1", - "1", - "1", - "1" - ] - } - }, - "T": { - "type": "DT_FLOAT" - }, - "data_format": { - "s": "TkhXQw==" - }, - "strides": { - "list": { - "i": [ - "1", - "1", - "1", - "1" - ] - } - }, - "explicit_paddings": { - "list": {} - }, - "use_cudnn_on_gpu": { - "b": true - }, - "num_args": { - "i": "1" - }, - "epsilon": { - "f": 0 - }, - "padding": { - "s": "VkFMSUQ=" - }, - "fused_ops": { - "list": { - "s": [ - "Qmlhc0FkZA==" - ] - } - } - } - }, - { - "name": "StatefulPartitionedCall/model/add_15/add", - "op": "AddV2", - "input": [ - "StatefulPartitionedCall/model/activation_15/Relu", - "StatefulPartitionedCall/model/batch_normalization_v1_16/FusedBatchNormV3" - ], - "attr": { - "T": { - "type": "DT_FLOAT" - } - } - }, - { - "name": "StatefulPartitionedCall/model/activation_16/Relu", - "op": "Relu", - "input": [ - "StatefulPartitionedCall/model/add_15/add" - ], - "attr": { - "T": { - "type": "DT_FLOAT" - } - } - }, - { - "name": "StatefulPartitionedCall/model/classificator_16/BiasAdd", - "op": "_FusedConv2D", - "input": [ - "StatefulPartitionedCall/model/activation_16/Relu", - "StatefulPartitionedCall/model/classificator_16/Conv2D/ReadVariableOp", - "StatefulPartitionedCall/model/classificator_16/BiasAdd/ReadVariableOp" - ], - "device": "/device:CPU:0", - "attr": { - "num_args": { - "i": "1" - }, - "epsilon": { - "f": 0 - }, - "padding": { - "s": "U0FNRQ==" - }, - "fused_ops": { - "list": { - "s": [ - "Qmlhc0FkZA==" - ] - } - }, - "dilations": { - "list": { - "i": [ - "1", - "1", - "1", - "1" - ] - } - }, - "T": { - "type": "DT_FLOAT" - }, - "data_format": { - "s": "TkhXQw==" - }, - "strides": { - "list": { - "i": [ - "1", - "1", - "1", - "1" - ] - } - }, - "use_cudnn_on_gpu": { - "b": true - }, - "explicit_paddings": { - "list": {} - } - } - }, - { - "name": "StatefulPartitionedCall/model/regressor_16/BiasAdd", - "op": "_FusedConv2D", - "input": [ - "StatefulPartitionedCall/model/activation_16/Relu", - "StatefulPartitionedCall/model/regressor_16/Conv2D/ReadVariableOp", - "StatefulPartitionedCall/model/regressor_16/BiasAdd/ReadVariableOp" - ], - "device": "/device:CPU:0", - "attr": { - "fused_ops": { - "list": { - "s": [ - "Qmlhc0FkZA==" - ] - } - }, - "dilations": { - "list": { - "i": [ - "1", - "1", - "1", - "1" - ] - } - }, - "T": { - "type": "DT_FLOAT" - }, - "strides": { - "list": { - "i": [ - "1", - "1", - "1", - "1" - ] - } - }, - "data_format": { - "s": "TkhXQw==" - }, - "use_cudnn_on_gpu": { - "b": true - }, - "explicit_paddings": { - "list": {} - }, - "num_args": { - "i": "1" - }, - "epsilon": { - "f": 0 - }, - "padding": { - "s": "U0FNRQ==" - } - } - }, - { - "name": "StatefulPartitionedCall/model/reshape_2/Shape", - "op": "Shape", - "input": [ - "StatefulPartitionedCall/model/classificator_16/BiasAdd" - ], - "attr": { - "T": { - "type": "DT_FLOAT" - }, - "out_type": { - "type": "DT_INT32" - } - } - }, - { - "name": "StatefulPartitionedCall/model/reshape_3/Shape", - "op": "Shape", - "input": [ - "StatefulPartitionedCall/model/regressor_16/BiasAdd" - ], - "attr": { - "T": { - "type": "DT_FLOAT" - }, - "out_type": { - "type": "DT_INT32" - } - } - }, - { - "name": "StatefulPartitionedCall/model/reshape_2/strided_slice", - "op": "StridedSlice", - "input": [ - "StatefulPartitionedCall/model/reshape_2/Shape", - "StatefulPartitionedCall/model/reshape/strided_slice/stack", - "StatefulPartitionedCall/model/reshape/strided_slice/stack_1", - "StatefulPartitionedCall/model/reshape/strided_slice/stack_1" - ], - "attr": { - "shrink_axis_mask": { - "i": "1" - }, - "begin_mask": { - "i": "0" - }, - "ellipsis_mask": { - "i": "0" - }, - "new_axis_mask": { - "i": "0" - }, - "end_mask": { - "i": "0" - }, - "Index": { - "type": "DT_INT32" - }, - "T": { - "type": "DT_INT32" - } - } - }, - { - "name": "StatefulPartitionedCall/model/reshape_3/strided_slice", - "op": "StridedSlice", - "input": [ - "StatefulPartitionedCall/model/reshape_3/Shape", - "StatefulPartitionedCall/model/reshape/strided_slice/stack", - "StatefulPartitionedCall/model/reshape/strided_slice/stack_1", - "StatefulPartitionedCall/model/reshape/strided_slice/stack_1" - ], - "attr": { - "T": { - "type": "DT_INT32" - }, - "Index": { - "type": "DT_INT32" - }, - "shrink_axis_mask": { - "i": "1" - }, - "ellipsis_mask": { - "i": "0" - }, - "begin_mask": { - "i": "0" - }, - "new_axis_mask": { - "i": "0" - }, - "end_mask": { - "i": "0" - } - } - }, - { - "name": "StatefulPartitionedCall/model/reshape_2/Reshape/shape", - "op": "Pack", - "input": [ - "StatefulPartitionedCall/model/reshape_2/strided_slice", - "StatefulPartitionedCall/model/reshape/Reshape/shape/1", - "StatefulPartitionedCall/model/reshape/Reshape/shape/2" - ], - "attr": { - "T": { - "type": "DT_INT32" - }, - "axis": { - "i": "0" - }, - "N": { - "i": "3" - } - } - }, - { - "name": "StatefulPartitionedCall/model/reshape_3/Reshape/shape", - "op": "Pack", - "input": [ - "StatefulPartitionedCall/model/reshape_3/strided_slice", - "StatefulPartitionedCall/model/reshape/Reshape/shape/1", - "StatefulPartitionedCall/model/reshape_1/Reshape/shape/2" - ], - "attr": { - "T": { - "type": "DT_INT32" - }, - "axis": { - "i": "0" - }, - "N": { - "i": "3" - } - } - }, - { - "name": "StatefulPartitionedCall/model/reshape_2/Reshape", - "op": "Reshape", - "input": [ - "StatefulPartitionedCall/model/classificator_16/BiasAdd", - "StatefulPartitionedCall/model/reshape_2/Reshape/shape" - ], - "attr": { - "T": { - "type": "DT_FLOAT" - }, - "Tshape": { - "type": "DT_INT32" - } - } - }, - { - "name": "StatefulPartitionedCall/model/reshape_3/Reshape", - "op": "Reshape", - "input": [ - "StatefulPartitionedCall/model/regressor_16/BiasAdd", - "StatefulPartitionedCall/model/reshape_3/Reshape/shape" - ], - "attr": { - "T": { - "type": "DT_FLOAT" - }, - "Tshape": { - "type": "DT_INT32" - } - } - }, - { - "name": "StatefulPartitionedCall/model/classificators/concat", - "op": "ConcatV2", - "input": [ - "StatefulPartitionedCall/model/reshape/Reshape", - "StatefulPartitionedCall/model/reshape_2/Reshape", - "StatefulPartitionedCall/model/reshape/Reshape/shape/2" - ], - "attr": { - "Tidx": { - "type": "DT_INT32" - }, - "T": { - "type": "DT_FLOAT" - }, - "N": { - "i": "2" - } - } - }, - { - "name": "StatefulPartitionedCall/model/regressors/concat", - "op": "ConcatV2", - "input": [ - "StatefulPartitionedCall/model/reshape_1/Reshape", - "StatefulPartitionedCall/model/reshape_3/Reshape", - "StatefulPartitionedCall/model/reshape/Reshape/shape/2" - ], - "attr": { - "Tidx": { - "type": "DT_INT32" - }, - "T": { - "type": "DT_FLOAT" - }, - "N": { - "i": "2" - } - } - }, - { - "name": "StatefulPartitionedCall/model/objects/concat", - "op": "ConcatV2", - "input": [ - "StatefulPartitionedCall/model/classificators/concat", - "StatefulPartitionedCall/model/regressors/concat", - "StatefulPartitionedCall/model/objects/concat/axis" - ], - "attr": { - "T": { - "type": "DT_FLOAT" - }, - "N": { - "i": "2" - }, - "Tidx": { - "type": "DT_INT32" - } - } - }, - { - "name": "Identity", - "op": "Identity", - "input": [ - "StatefulPartitionedCall/model/objects/concat" - ], - "attr": { - "T": { - "type": "DT_FLOAT" - } - } - } - ], - "versions": { - "producer": 134, - "minConsumer": 12 - } - }, - "weightsManifest": [ - { - "paths": [ - "group1-shard1of1.bin" - ], - "weights": [ - { - "name": "StatefulPartitionedCall/model/conv2d/Conv2D_weights", - "shape": [ - 5, - 5, - 3, - 24 - ], - "dtype": "float32" - }, - { - "name": "StatefulPartitionedCall/model/conv2d_16/Conv2D_weights", - "shape": [ - 1, - 1, - 96, - 96 - ], - "dtype": "float32" - }, - { - "name": "StatefulPartitionedCall/model/conv2d/Conv2D_bn_offset", - "shape": [ - 24 - ], - "dtype": "float32" - }, - { - "name": "StatefulPartitionedCall/model/conv2d_1/Conv2D_weights", - "shape": [ - 1, - 1, - 24, - 24 - ], - "dtype": "float32" - }, - { - "name": "StatefulPartitionedCall/model/conv2d_16/Conv2D_bn_offset", - "shape": [ - 96 - ], - "dtype": "float32" - }, - { - "name": "StatefulPartitionedCall/model/conv2d_1/Conv2D_bn_offset", - "shape": [ - 24 - ], - "dtype": "float32" - }, - { - "name": "StatefulPartitionedCall/model/conv2d_2/Conv2D_weights", - "shape": [ - 1, - 1, - 24, - 28 - ], - "dtype": "float32" - }, - { - "name": "StatefulPartitionedCall/model/conv2d_2/Conv2D_bn_offset", - "shape": [ - 28 - ], - "dtype": "float32" - }, - { - "name": "StatefulPartitionedCall/model/conv2d_3/Conv2D_weights", - "shape": [ - 1, - 1, - 28, - 32 - ], - "dtype": "float32" - }, - { - "name": "StatefulPartitionedCall/model/conv2d_3/Conv2D_bn_offset", - "shape": [ - 32 - ], - "dtype": "float32" - }, - { - "name": "StatefulPartitionedCall/model/conv2d_4/Conv2D_weights", - "shape": [ - 1, - 1, - 32, - 36 - ], - "dtype": "float32" - }, - { - "name": "StatefulPartitionedCall/model/conv2d_4/Conv2D_bn_offset", - "shape": [ - 36 - ], - "dtype": "float32" - }, - { - "name": "StatefulPartitionedCall/model/conv2d_5/Conv2D_weights", - "shape": [ - 1, - 1, - 36, - 42 - ], - "dtype": "float32" - }, - { - "name": "StatefulPartitionedCall/model/conv2d_5/Conv2D_bn_offset", - "shape": [ - 42 - ], - "dtype": "float32" - }, - { - "name": "StatefulPartitionedCall/model/conv2d_6/Conv2D_weights", - "shape": [ - 1, - 1, - 42, - 48 - ], - "dtype": "float32" - }, - { - "name": "StatefulPartitionedCall/model/conv2d_6/Conv2D_bn_offset", - "shape": [ - 48 - ], - "dtype": "float32" - }, - { - "name": "StatefulPartitionedCall/model/conv2d_7/Conv2D_weights", - "shape": [ - 1, - 1, - 48, - 56 - ], - "dtype": "float32" - }, - { - "name": "StatefulPartitionedCall/model/conv2d_7/Conv2D_bn_offset", - "shape": [ - 56 - ], - "dtype": "float32" - }, - { - "name": "StatefulPartitionedCall/model/conv2d_8/Conv2D_weights", - "shape": [ - 1, - 1, - 56, - 64 - ], - "dtype": "float32" - }, - { - "name": "StatefulPartitionedCall/model/conv2d_8/Conv2D_bn_offset", - "shape": [ - 64 - ], - "dtype": "float32" - }, - { - "name": "StatefulPartitionedCall/model/conv2d_9/Conv2D_weights", - "shape": [ - 1, - 1, - 64, - 72 - ], - "dtype": "float32" - }, - { - "name": "StatefulPartitionedCall/model/conv2d_9/Conv2D_bn_offset", - "shape": [ - 72 - ], - "dtype": "float32" - }, - { - "name": "StatefulPartitionedCall/model/conv2d_10/Conv2D_weights", - "shape": [ - 1, - 1, - 72, - 80 - ], - "dtype": "float32" - }, - { - "name": "StatefulPartitionedCall/model/conv2d_10/Conv2D_bn_offset", - "shape": [ - 80 - ], - "dtype": "float32" - }, - { - "name": "StatefulPartitionedCall/model/conv2d_11/Conv2D_weights", - "shape": [ - 1, - 1, - 80, - 88 - ], - "dtype": "float32" - }, - { - "name": "StatefulPartitionedCall/model/conv2d_11/Conv2D_bn_offset", - "shape": [ - 88 - ], - "dtype": "float32" - }, - { - "name": "StatefulPartitionedCall/model/conv2d_12/Conv2D_weights", - "shape": [ - 1, - 1, - 88, - 96 - ], - "dtype": "float32" - }, - { - "name": "StatefulPartitionedCall/model/conv2d_12/Conv2D_bn_offset", - "shape": [ - 96 - ], - "dtype": "float32" - }, - { - "name": "StatefulPartitionedCall/model/conv2d_13/Conv2D_weights", - "shape": [ - 1, - 1, - 96, - 96 - ], - "dtype": "float32" - }, - { - "name": "StatefulPartitionedCall/model/conv2d_13/Conv2D_bn_offset", - "shape": [ - 96 - ], - "dtype": "float32" - }, - { - "name": "StatefulPartitionedCall/model/conv2d_14/Conv2D_weights", - "shape": [ - 1, - 1, - 96, - 96 - ], - "dtype": "float32" - }, - { - "name": "StatefulPartitionedCall/model/conv2d_14/Conv2D_bn_offset", - "shape": [ - 96 - ], - "dtype": "float32" - }, - { - "name": "StatefulPartitionedCall/model/conv2d_15/Conv2D_weights", - "shape": [ - 1, - 1, - 96, - 96 - ], - "dtype": "float32" - }, - { - "name": "StatefulPartitionedCall/model/conv2d_15/Conv2D_bn_offset", - "shape": [ - 96 - ], - "dtype": "float32" - }, - { - "name": "StatefulPartitionedCall/model/depthwise_conv2d/depthwise/ReadVariableOp", - "shape": [ - 3, - 3, - 24, - 1 - ], - "dtype": "float32" - }, - { - "name": "StatefulPartitionedCall/model/channel_padding/Pad/paddings", - "shape": [ - 4, - 2 - ], - "dtype": "int32" - }, - { - "name": "StatefulPartitionedCall/model/depthwise_conv2d_1/depthwise/ReadVariableOp", - "shape": [ - 3, - 3, - 24, - 1 - ], - "dtype": "float32" - }, - { - "name": "StatefulPartitionedCall/model/depthwise_conv2d_2/depthwise/ReadVariableOp", - "shape": [ - 3, - 3, - 28, - 1 - ], - "dtype": "float32" - }, - { - "name": "StatefulPartitionedCall/model/depthwise_conv2d_3/depthwise/ReadVariableOp", - "shape": [ - 3, - 3, - 32, - 1 - ], - "dtype": "float32" - }, - { - "name": "StatefulPartitionedCall/model/channel_padding_3/Pad/paddings", - "shape": [ - 4, - 2 - ], - "dtype": "int32" - }, - { - "name": "StatefulPartitionedCall/model/depthwise_conv2d_4/depthwise/ReadVariableOp", - "shape": [ - 3, - 3, - 36, - 1 - ], - "dtype": "float32" - }, - { - "name": "StatefulPartitionedCall/model/depthwise_conv2d_5/depthwise/ReadVariableOp", - "shape": [ - 3, - 3, - 42, - 1 - ], - "dtype": "float32" - }, - { - "name": "StatefulPartitionedCall/model/channel_padding_5/Pad/paddings", - "shape": [ - 4, - 2 - ], - "dtype": "int32" - }, - { - "name": "StatefulPartitionedCall/model/depthwise_conv2d_6/depthwise/ReadVariableOp", - "shape": [ - 3, - 3, - 48, - 1 - ], - "dtype": "float32" - }, - { - "name": "StatefulPartitionedCall/model/depthwise_conv2d_7/depthwise/ReadVariableOp", - "shape": [ - 3, - 3, - 56, - 1 - ], - "dtype": "float32" - }, - { - "name": "StatefulPartitionedCall/model/depthwise_conv2d_8/depthwise/ReadVariableOp", - "shape": [ - 3, - 3, - 64, - 1 - ], - "dtype": "float32" - }, - { - "name": "StatefulPartitionedCall/model/depthwise_conv2d_9/depthwise/ReadVariableOp", - "shape": [ - 3, - 3, - 72, - 1 - ], - "dtype": "float32" - }, - { - "name": "StatefulPartitionedCall/model/depthwise_conv2d_10/depthwise/ReadVariableOp", - "shape": [ - 3, - 3, - 80, - 1 - ], - "dtype": "float32" - }, - { - "name": "StatefulPartitionedCall/model/classificator_8/Conv2D/ReadVariableOp", - "shape": [ - 1, - 1, - 88, - 2 - ], - "dtype": "float32" - }, - { - "name": "StatefulPartitionedCall/model/classificator_8/BiasAdd/ReadVariableOp", - "shape": [ - 2 - ], - "dtype": "float32" - }, - { - "name": "StatefulPartitionedCall/model/reshape/strided_slice/stack", - "shape": [ - 1 - ], - "dtype": "int32" - }, - { - "name": "StatefulPartitionedCall/model/reshape/strided_slice/stack_1", - "shape": [ - 1 - ], - "dtype": "int32" - }, - { - "name": "StatefulPartitionedCall/model/reshape/Reshape/shape/1", - "shape": [], - "dtype": "int32" - }, - { - "name": "StatefulPartitionedCall/model/reshape/Reshape/shape/2", - "shape": [], - "dtype": "int32" - }, - { - "name": "StatefulPartitionedCall/model/depthwise_conv2d_11/depthwise/ReadVariableOp", - "shape": [ - 3, - 3, - 88, - 1 - ], - "dtype": "float32" - }, - { - "name": "StatefulPartitionedCall/model/depthwise_conv2d_12/depthwise/ReadVariableOp", - "shape": [ - 3, - 3, - 96, - 1 - ], - "dtype": "float32" - }, - { - "name": "StatefulPartitionedCall/model/depthwise_conv2d_13/depthwise/ReadVariableOp", - "shape": [ - 3, - 3, - 96, - 1 - ], - "dtype": "float32" - }, - { - "name": "StatefulPartitionedCall/model/depthwise_conv2d_14/depthwise/ReadVariableOp", - "shape": [ - 3, - 3, - 96, - 1 - ], - "dtype": "float32" - }, - { - "name": "StatefulPartitionedCall/model/depthwise_conv2d_15/depthwise/ReadVariableOp", - "shape": [ - 3, - 3, - 96, - 1 - ], - "dtype": "float32" - }, - { - "name": "StatefulPartitionedCall/model/classificator_16/Conv2D/ReadVariableOp", - "shape": [ - 1, - 1, - 96, - 6 - ], - "dtype": "float32" - }, - { - "name": "StatefulPartitionedCall/model/classificator_16/BiasAdd/ReadVariableOp", - "shape": [ - 6 - ], - "dtype": "float32" - }, - { - "name": "StatefulPartitionedCall/model/regressor_8/Conv2D/ReadVariableOp", - "shape": [ - 1, - 1, - 88, - 32 - ], - "dtype": "float32" - }, - { - "name": "StatefulPartitionedCall/model/regressor_8/BiasAdd/ReadVariableOp", - "shape": [ - 32 - ], - "dtype": "float32" - }, - { - "name": "StatefulPartitionedCall/model/reshape_1/Reshape/shape/2", - "shape": [], - "dtype": "int32" - }, - { - "name": "StatefulPartitionedCall/model/regressor_16/Conv2D/ReadVariableOp", - "shape": [ - 1, - 1, - 96, - 96 - ], - "dtype": "float32" - }, - { - "name": "StatefulPartitionedCall/model/regressor_16/BiasAdd/ReadVariableOp", - "shape": [ - 96 - ], - "dtype": "float32" - }, - { - "name": "StatefulPartitionedCall/model/objects/concat/axis", - "shape": [], - "dtype": "int32" - } - ] - } - ] -} diff --git a/tfjs-master/e2e/custom_module/blazeface/package.json b/tfjs-master/e2e/custom_module/blazeface/package.json deleted file mode 100644 index 29b94249f..000000000 --- a/tfjs-master/e2e/custom_module/blazeface/package.json +++ /dev/null @@ -1,37 +0,0 @@ -{ - "name": "blazeface-treeshake", - "version": "1.0.0", - "description": "", - "main": "app.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1", - "make-custom-tfjs-modules": "node ./node_modules/@tensorflow/tfjs/dist/tools/custom_module/cli.js --config app_tfjs_config.json", - "rollup:full": "rollup -c", - "rollup:custom": "rollup -c --useCustomTfjs", - "webpack:full": "webpack", - "webpack:custom": "webpack --env useCustomTfjs" - }, - "dependencies": { - "@tensorflow-models/blazeface": "^0.0.5", - "@tensorflow/tfjs": "link:../../../tfjs", - "@tensorflow/tfjs-backend-wasm": "link:../../../link-package/node_modules/@tensorflow/tfjs-backend-wasm" - }, - "devDependencies": { - "@rollup/plugin-alias": "^3.1.1", - "@rollup/plugin-commonjs": "^14.0.0", - "@rollup/plugin-node-resolve": "^8.4.0", - "file-loader": "^6.1.0", - "rollup": "^2.23.0", - "rollup-plugin-commonjs": "^10.1.0", - "rollup-plugin-node-resolve": "^5.2.0", - "rollup-plugin-terser": "^6.1.0", - "rollup-plugin-visualizer": "^4.0.4", - "terser-webpack-plugin": "^4.2.1", - "webpack": "^5.76.0", - "webpack-cli": "^4.2.0" - }, - "resolutions": { - "node-fetch": "2.6.7", - "minimist": "1.2.6" - } -} diff --git a/tfjs-master/e2e/custom_module/blazeface/rollup.config.js b/tfjs-master/e2e/custom_module/blazeface/rollup.config.js deleted file mode 100644 index 9d6dde593..000000000 --- a/tfjs-master/e2e/custom_module/blazeface/rollup.config.js +++ /dev/null @@ -1,100 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import alias from '@rollup/plugin-alias'; -import commonjs from '@rollup/plugin-commonjs'; -import resolve from '@rollup/plugin-node-resolve'; -import * as path from 'path'; -import {terser} from 'rollup-plugin-terser'; -import visualizer from 'rollup-plugin-visualizer'; - - -const sourcemap = false; - -function getPlugins(options) { - let plugins = []; - - if (options.useCustomTfjs) { - plugins.push( - // replace top level imports to tfjs-core with custom import. - // after v3 is out we still need to do this in converter. - alias({ - entries: [ - { - find: /@tensorflow\/tfjs$/, - replacement: path.resolve(__dirname, options.customTfjsPath), - }, - { - find: /@tensorflow\/tfjs-core$/, - replacement: path.resolve(__dirname, options.customTfjsCorePath), - }, - { - find: '@tensorflow/tfjs-core/dist/ops/ops_for_converter', - replacement: path.resolve(__dirname, options.customOpsPath), - }, - ], - })); - } - - plugins = [ - ...plugins, - resolve({browser: true, dedupe: ['seedrandom']}), - commonjs({include: ['node_modules/**']}), - terser({output: {comments: false}}), - ]; - - if (options.visualize) { - plugins.push(visualizer({sourcemap, filename: options.visPath})); - } - - return plugins; -} - - -module.exports = (cmdOptions) => { - const {useCustomTfjs, visualize} = cmdOptions; - // remove custom command line options from being passed onto rollup. - delete cmdOptions.useCustomTfjs; - delete cmdOptions.visualize; - - const bundles = []; - const outputPath = useCustomTfjs ? 'dist/custom' : 'dist/full'; - - bundles.push( - { - input: 'app.js', - output: { - file: `${outputPath}/app_rollup.js`, - sourcemap, - format: 'umd', - }, - plugins: [ - ...getPlugins({ - useCustomTfjs: useCustomTfjs, - customTfjsPath: './custom_tfjs_blazeface/custom_tfjs.js', - customTfjsCorePath: './custom_tfjs_blazeface/custom_tfjs_core.js', - customOpsPath: - './custom_tfjs_blazeface/custom_ops_for_converter.js', - visualize: visualize, - visPath: `${outputPath}/app_rollup.js.html`, - }), - ], - }, - ); - - return bundles; -}; diff --git a/tfjs-master/e2e/custom_module/blazeface/test_data.js b/tfjs-master/e2e/custom_module/blazeface/test_data.js deleted file mode 100644 index 11be44fc1..000000000 --- a/tfjs-master/e2e/custom_module/blazeface/test_data.js +++ /dev/null @@ -1,3296 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -export const STUBBED_IMAGE_VALS = [ - 178, 179, 183, 151, 152, 156, 121, 122, 126, 106, 107, 111, 63, 62, 67, - 5, 4, 9, 17, 17, 19, 13, 13, 15, 19, 19, 21, 13, 13, 15, - 18, 16, 17, 23, 21, 22, 20, 18, 19, 15, 13, 14, 16, 15, 13, - 19, 15, 12, 33, 23, 21, 54, 43, 39, 56, 43, 37, 63, 50, 44, - 83, 68, 61, 55, 40, 33, 58, 41, 33, 77, 60, 52, 56, 39, 31, - 52, 35, 27, 61, 44, 36, 60, 43, 35, 53, 36, 28, 69, 52, 44, - 78, 63, 56, 62, 48, 39, 30, 11, 4, 48, 31, 23, 57, 42, 37, - 46, 35, 31, 38, 26, 26, 39, 29, 27, 46, 32, 29, 47, 32, 25, - 40, 20, 11, 57, 35, 22, 50, 26, 14, 60, 38, 25, 85, 67, 57, - 56, 41, 34, 30, 19, 17, 63, 55, 53, 40, 31, 32, 12, 4, 2, - 16, 6, 4, 20, 7, 1, 21, 6, 0, 18, 1, 0, 26, 9, 1, - 24, 10, 1, 28, 13, 8, 32, 19, 13, 37, 26, 22, 27, 16, 12, - 18, 7, 1, 28, 17, 11, 36, 21, 14, 47, 32, 25, 34, 20, 11, - 39, 25, 16, 48, 31, 21, 20, 3, 0, 62, 42, 31, 58, 38, 27, - 68, 44, 32, 73, 49, 37, 73, 47, 34, 80, 54, 41, 65, 37, 25, - 51, 23, 11, 56, 26, 16, 70, 40, 30, 84, 54, 44, 78, 51, 40, - 70, 47, 39, 44, 26, 16, 55, 38, 30, 63, 46, 38, 60, 45, 38, - 22, 7, 0, 26, 13, 7, 31, 18, 12, 22, 9, 3, 23, 10, 4, - 38, 23, 16, 29, 15, 6, 58, 39, 32, 70, 52, 42, 68, 48, 37, - 84, 70, 61, 65, 60, 57, 82, 82, 82, 77, 77, 79, 72, 72, 74, - 63, 64, 69, 59, 60, 65, 47, 50, 57, 58, 61, 68, 56, 56, 64, - 56, 56, 64, 55, 56, 61, 55, 56, 61, 56, 55, 60, 57, 57, 59, - 59, 57, 60, 59, 57, 58, 58, 57, 62, 57, 56, 61, 56, 55, 60, - 55, 54, 59, 55, 54, 59, 55, 54, 59, 55, 54, 59, 55, 54, 59, - 54, 53, 58, 53, 52, 57, 53, 52, 57, 54, 53, 58, 55, 54, 59, - 55, 54, 59, 54, 53, 58, 54, 53, 58, 193, 194, 198, 162, 163, 167, - 127, 128, 132, 114, 115, 119, 81, 80, 85, 25, 24, 29, 15, 15, 17, - 12, 12, 14, 11, 11, 13, 23, 23, 23, 16, 14, 15, 10, 8, 9, - 22, 20, 21, 19, 18, 16, 14, 13, 11, 30, 25, 22, 29, 19, 17, - 29, 18, 12, 65, 52, 46, 84, 71, 63, 74, 59, 52, 27, 13, 4, - 56, 39, 31, 54, 37, 29, 45, 28, 20, 60, 43, 35, 73, 56, 48, - 68, 51, 43, 67, 50, 42, 82, 65, 57, 61, 46, 39, 11, 0, 0, - 64, 47, 39, 57, 40, 32, 46, 31, 26, 38, 27, 25, 39, 29, 28, - 46, 36, 34, 51, 40, 36, 56, 41, 34, 61, 41, 32, 65, 43, 32, - 59, 35, 23, 71, 49, 36, 71, 53, 43, 50, 35, 28, 45, 34, 32, - 44, 34, 33, 32, 23, 24, 15, 7, 5, 14, 3, 1, 15, 2, 0, - 15, 0, 0, 18, 1, 0, 28, 11, 3, 32, 18, 9, 36, 21, 16, - 30, 17, 11, 33, 22, 18, 42, 31, 27, 33, 22, 16, 16, 5, 0, - 53, 38, 31, 34, 19, 12, 25, 11, 2, 47, 30, 20, 42, 25, 15, - 61, 43, 31, 67, 47, 36, 64, 42, 29, 77, 53, 41, 76, 52, 40, - 82, 56, 43, 59, 33, 20, 50, 22, 10, 67, 39, 27, 76, 46, 36, - 75, 45, 35, 80, 50, 40, 72, 45, 34, 54, 32, 21, 36, 18, 8, - 59, 40, 33, 47, 30, 22, 56, 41, 34, 38, 23, 16, 18, 5, 0, - 29, 16, 10, 12, 0, 0, 36, 23, 15, 32, 17, 10, 43, 26, 18, - 55, 37, 27, 68, 50, 38, 70, 50, 39, 85, 68, 60, 86, 81, 77, - 70, 70, 70, 75, 75, 75, 86, 86, 88, 70, 69, 74, 57, 58, 63, - 55, 56, 61, 56, 56, 64, 55, 55, 63, 56, 56, 64, 57, 58, 63, - 58, 59, 64, 59, 58, 63, 58, 57, 62, 58, 56, 59, 57, 55, 58, - 57, 56, 61, 57, 56, 61, 56, 55, 60, 55, 54, 59, 55, 54, 59, - 54, 53, 58, 55, 54, 59, 55, 54, 59, 54, 53, 58, 54, 53, 58, - 53, 52, 57, 53, 52, 57, 54, 53, 58, 54, 53, 58, 53, 52, 57, - 52, 51, 56, 199, 202, 207, 171, 174, 179, 134, 137, 142, 120, 123, 128, - 96, 97, 101, 44, 45, 49, 8, 8, 10, 13, 13, 15, 16, 14, 15, - 20, 18, 19, 24, 20, 21, 21, 17, 16, 19, 15, 14, 26, 22, 21, - 29, 25, 24, 27, 19, 16, 38, 27, 23, 51, 38, 32, 72, 57, 52, - 78, 63, 56, 63, 46, 39, 35, 18, 10, 55, 36, 29, 46, 28, 18, - 36, 18, 8, 47, 29, 19, 44, 27, 19, 60, 43, 35, 81, 66, 59, - 60, 45, 38, 41, 26, 19, 65, 50, 43, 70, 53, 46, 50, 35, 28, - 36, 22, 19, 39, 28, 26, 45, 35, 34, 46, 36, 34, 45, 34, 30, - 50, 35, 30, 62, 43, 36, 58, 38, 27, 69, 47, 34, 94, 74, 63, - 75, 57, 47, 50, 35, 28, 49, 38, 34, 13, 3, 1, 22, 14, 12, - 22, 14, 11, 16, 5, 1, 15, 2, 0, 15, 0, 0, 27, 10, 2, - 39, 22, 14, 51, 37, 28, 43, 28, 23, 40, 27, 21, 33, 22, 18, - 51, 40, 36, 47, 36, 32, 26, 15, 9, 53, 38, 31, 25, 10, 3, - 40, 23, 15, 58, 40, 30, 54, 36, 26, 81, 61, 50, 69, 47, 36, - 74, 50, 38, 86, 62, 50, 80, 54, 41, 76, 48, 36, 80, 52, 40, - 70, 42, 30, 78, 50, 38, 95, 67, 55, 88, 60, 48, 76, 48, 37, - 70, 43, 32, 35, 13, 2, 34, 16, 4, 53, 35, 25, 37, 20, 12, - 53, 38, 31, 42, 27, 20, 17, 4, 0, 20, 7, 1, 24, 9, 2, - 15, 0, 0, 52, 35, 28, 71, 54, 46, 73, 55, 45, 63, 43, 32, - 75, 53, 42, 72, 55, 45, 70, 63, 57, 80, 79, 77, 87, 86, 84, - 79, 79, 79, 78, 78, 80, 65, 64, 69, 57, 56, 62, 54, 55, 60, - 55, 56, 61, 56, 57, 62, 57, 58, 63, 57, 58, 63, 58, 57, 62, - 57, 56, 61, 57, 57, 59, 56, 56, 58, 56, 55, 60, 56, 55, 60, - 55, 54, 59, 55, 54, 59, 54, 53, 58, 54, 53, 58, 54, 53, 58, - 54, 53, 58, 54, 53, 58, 54, 53, 58, 53, 52, 57, 53, 52, 57, - 53, 52, 57, 52, 51, 56, 51, 50, 55, 50, 49, 54, 198, 201, 206, - 178, 181, 186, 145, 148, 153, 127, 130, 135, 105, 106, 111, 60, 61, 65, - 6, 6, 8, 17, 17, 19, 14, 12, 13, 8, 7, 5, 19, 15, 14, - 25, 21, 20, 23, 19, 18, 39, 34, 31, 53, 48, 45, 47, 37, 35, - 82, 69, 63, 91, 76, 69, 80, 65, 58, 77, 60, 52, 52, 35, 27, - 53, 36, 26, 35, 17, 7, 31, 13, 3, 34, 16, 6, 41, 23, 13, - 62, 45, 37, 69, 52, 44, 55, 40, 33, 62, 47, 40, 75, 60, 53, - 70, 55, 48, 33, 18, 11, 27, 12, 7, 28, 17, 15, 38, 28, 26, - 43, 35, 33, 40, 30, 28, 41, 30, 28, 50, 35, 30, 64, 45, 38, - 64, 44, 35, 81, 59, 48, 92, 72, 61, 61, 42, 35, 35, 20, 13, - 35, 24, 20, 17, 7, 5, 14, 4, 3, 33, 23, 21, 26, 12, 9, - 25, 10, 3, 28, 11, 3, 43, 26, 18, 55, 38, 30, 71, 57, 48, - 46, 31, 26, 56, 43, 37, 42, 31, 27, 54, 43, 39, 52, 41, 37, - 47, 36, 32, 32, 19, 13, 30, 15, 8, 56, 38, 28, 63, 43, 32, - 78, 58, 47, 70, 48, 35, 73, 49, 37, 84, 60, 48, 87, 61, 48, - 75, 49, 36, 74, 46, 34, 82, 54, 42, 91, 63, 51, 89, 61, 49, - 74, 46, 34, 73, 47, 34, 73, 45, 34, 41, 14, 3, 28, 6, 0, - 37, 19, 7, 41, 23, 13, 43, 26, 18, 49, 34, 27, 28, 13, 6, - 25, 12, 6, 12, 0, 0, 20, 5, 0, 25, 10, 3, 59, 42, 34, - 57, 39, 29, 94, 74, 63, 85, 66, 52, 50, 28, 15, 80, 62, 52, - 45, 36, 29, 76, 73, 68, 91, 87, 84, 74, 73, 71, 81, 79, 80, - 68, 66, 69, 57, 56, 61, 55, 54, 60, 57, 56, 62, 56, 57, 62, - 55, 56, 61, 54, 55, 60, 55, 54, 59, 56, 55, 60, 57, 57, 59, - 58, 58, 60, 55, 54, 59, 55, 54, 59, 55, 54, 59, 54, 53, 58, - 54, 53, 58, 54, 53, 58, 54, 53, 58, 54, 53, 58, 54, 53, 58, - 53, 52, 57, 52, 51, 56, 52, 51, 56, 52, 51, 56, 52, 51, 56, - 51, 50, 55, 49, 48, 53, 200, 205, 211, 185, 190, 196, 155, 160, 166, - 132, 137, 141, 113, 116, 121, 78, 79, 83, 17, 17, 19, 18, 18, 20, - 18, 16, 17, 21, 17, 16, 17, 11, 11, 21, 16, 13, 36, 31, 28, - 48, 40, 37, 55, 47, 44, 67, 56, 52, 87, 72, 65, 78, 61, 53, - 85, 68, 60, 88, 70, 60, 56, 38, 28, 60, 42, 32, 27, 7, 0, - 33, 13, 2, 55, 37, 27, 69, 51, 41, 78, 61, 53, 67, 50, 42, - 61, 46, 39, 85, 70, 63, 79, 66, 60, 37, 24, 18, 35, 22, 16, - 36, 25, 21, 42, 31, 29, 43, 33, 32, 39, 31, 29, 38, 28, 26, - 47, 36, 34, 60, 47, 41, 61, 44, 37, 79, 61, 51, 93, 73, 64, - 73, 53, 44, 48, 29, 22, 31, 16, 9, 16, 2, 0, 21, 12, 7, - 8, 0, 0, 39, 30, 25, 33, 20, 14, 34, 19, 12, 41, 24, 16, - 56, 38, 28, 66, 49, 41, 78, 64, 55, 50, 35, 30, 58, 45, 39, - 57, 46, 42, 65, 55, 53, 51, 40, 36, 37, 26, 22, 32, 19, 13, - 46, 31, 24, 59, 41, 31, 71, 49, 38, 85, 63, 52, 68, 44, 32, - 80, 56, 44, 81, 55, 42, 81, 53, 41, 75, 47, 35, 79, 51, 39, - 92, 64, 52, 81, 55, 42, 77, 51, 38, 75, 48, 37, 49, 25, 13, - 34, 7, 0, 32, 8, 0, 32, 12, 3, 30, 12, 2, 40, 21, 14, - 54, 37, 29, 41, 26, 19, 18, 3, 0, 28, 15, 9, 14, 1, 0, - 17, 2, 0, 39, 24, 17, 38, 21, 13, 37, 19, 9, 51, 31, 20, - 102, 80, 67, 59, 35, 23, 71, 51, 40, 56, 46, 37, 43, 36, 28, - 64, 57, 51, 80, 75, 71, 84, 78, 78, 64, 60, 61, 61, 59, 62, - 55, 54, 59, 55, 54, 59, 55, 54, 59, 55, 54, 60, 55, 54, 60, - 56, 55, 60, 56, 55, 60, 56, 56, 58, 56, 56, 58, 54, 53, 58, - 54, 53, 58, 54, 53, 58, 54, 53, 58, 54, 53, 58, 54, 53, 58, - 53, 52, 57, 53, 52, 57, 52, 51, 56, 51, 50, 55, 51, 50, 55, - 51, 50, 55, 52, 51, 56, 52, 51, 56, 51, 50, 55, 50, 49, 54, - 203, 208, 214, 190, 195, 201, 164, 169, 175, 135, 140, 146, 120, 123, 128, - 93, 97, 100, 37, 36, 41, 12, 12, 12, 23, 19, 20, 20, 16, 15, - 29, 24, 21, 41, 33, 30, 44, 36, 33, 50, 41, 36, 57, 48, 43, - 60, 47, 41, 47, 30, 22, 64, 46, 36, 88, 70, 60, 71, 53, 43, - 66, 48, 38, 59, 41, 31, 35, 15, 4, 58, 38, 27, 83, 65, 55, - 74, 56, 46, 53, 36, 28, 68, 51, 43, 92, 77, 70, 63, 50, 42, - 30, 17, 11, 43, 32, 28, 37, 26, 22, 40, 30, 28, 43, 33, 32, - 39, 29, 28, 33, 25, 23, 37, 27, 25, 49, 38, 36, 62, 49, 43, - 65, 48, 41, 80, 61, 54, 80, 61, 54, 47, 28, 21, 51, 34, 27, - 55, 40, 33, 17, 4, 0, 8, 0, 0, 8, 0, 0, 40, 29, 25, - 39, 24, 19, 42, 25, 17, 52, 33, 26, 62, 44, 34, 73, 56, 48, - 76, 61, 54, 57, 42, 37, 44, 33, 29, 69, 58, 56, 78, 68, 66, - 51, 40, 36, 10, 0, 0, 56, 43, 37, 61, 46, 39, 76, 56, 47, - 89, 67, 56, 71, 47, 37, 78, 54, 42, 78, 51, 40, 65, 39, 26, - 77, 49, 37, 82, 54, 42, 87, 59, 47, 80, 54, 41, 82, 56, 43, - 80, 56, 44, 52, 28, 16, 29, 7, 0, 34, 12, 1, 28, 8, 0, - 37, 19, 9, 22, 5, 0, 47, 30, 22, 52, 38, 29, 30, 15, 8, - 21, 8, 0, 25, 12, 6, 21, 8, 2, 27, 14, 8, 22, 7, 0, - 21, 4, 0, 35, 17, 7, 17, 0, 0, 63, 41, 28, 77, 55, 42, - 35, 16, 2, 71, 59, 47, 38, 29, 20, 32, 23, 16, 58, 51, 45, - 85, 77, 75, 72, 66, 66, 59, 55, 56, 55, 53, 56, 55, 53, 56, - 55, 54, 59, 57, 56, 62, 58, 57, 63, 58, 57, 62, 56, 55, 60, - 54, 54, 56, 52, 52, 54, 53, 52, 57, 53, 52, 57, 53, 52, 57, - 54, 53, 58, 53, 52, 57, 53, 52, 57, 53, 52, 57, 53, 52, 57, - 51, 50, 55, 50, 49, 54, 50, 49, 54, 50, 49, 54, 51, 50, 55, - 51, 50, 55, 50, 49, 54, 49, 48, 53, 198, 205, 213, 190, 197, 205, - 173, 180, 186, 141, 146, 152, 123, 126, 131, 103, 107, 110, 60, 59, 64, - 11, 11, 11, 18, 14, 15, 15, 11, 10, 43, 38, 35, 59, 51, 48, - 44, 35, 30, 54, 43, 37, 69, 58, 52, 56, 41, 34, 43, 25, 15, - 82, 62, 51, 84, 64, 53, 57, 37, 26, 66, 46, 35, 54, 34, 23, - 40, 20, 9, 62, 42, 31, 74, 56, 46, 52, 34, 24, 62, 45, 37, - 82, 65, 57, 61, 46, 39, 29, 16, 10, 20, 6, 3, 20, 9, 5, - 14, 4, 3, 17, 9, 7, 22, 14, 12, 24, 16, 14, 25, 15, 14, - 31, 21, 19, 46, 35, 33, 61, 48, 42, 75, 60, 53, 65, 48, 40, - 54, 37, 29, 37, 20, 12, 49, 32, 25, 64, 49, 42, 37, 24, 18, - 10, 0, 0, 17, 3, 0, 44, 30, 27, 44, 29, 24, 49, 32, 24, - 65, 46, 39, 70, 52, 42, 85, 68, 60, 79, 64, 57, 60, 45, 40, - 35, 24, 20, 74, 63, 61, 71, 61, 59, 49, 38, 34, 21, 10, 6, - 72, 59, 53, 74, 57, 50, 94, 74, 65, 88, 66, 55, 58, 34, 24, - 76, 52, 42, 64, 37, 28, 62, 35, 24, 74, 47, 36, 75, 48, 37, - 70, 43, 32, 82, 55, 44, 70, 46, 34, 56, 34, 23, 43, 21, 10, - 27, 7, 0, 27, 9, 0, 34, 16, 6, 31, 14, 6, 32, 15, 7, - 49, 32, 25, 44, 29, 22, 25, 10, 5, 24, 11, 5, 27, 13, 10, - 19, 8, 4, 20, 9, 5, 20, 7, 1, 21, 6, 0, 24, 7, 0, - 34, 16, 6, 25, 5, 0, 51, 31, 20, 24, 6, 0, 61, 47, 34, - 56, 44, 32, 32, 19, 10, 36, 26, 17, 69, 60, 55, 79, 71, 68, - 59, 53, 53, 58, 54, 55, 60, 58, 61, 60, 58, 61, 58, 57, 62, - 58, 57, 62, 56, 55, 60, 55, 54, 59, 53, 52, 57, 52, 51, 56, - 52, 51, 56, 52, 51, 56, 53, 52, 57, 53, 52, 57, 53, 52, 57, - 53, 52, 57, 53, 52, 57, 52, 51, 56, 50, 49, 54, 49, 48, 53, - 49, 48, 53, 48, 47, 52, 49, 48, 53, 48, 47, 52, 47, 46, 51, - 46, 45, 50, 190, 199, 206, 192, 201, 208, 186, 193, 199, 148, 155, 161, - 126, 129, 134, 108, 112, 115, 79, 79, 81, 19, 17, 18, 31, 27, 26, - 46, 41, 38, 59, 51, 48, 52, 43, 38, 42, 31, 25, 46, 36, 27, - 55, 42, 34, 54, 40, 31, 66, 48, 38, 76, 56, 45, 63, 43, 32, - 75, 55, 44, 61, 41, 30, 51, 31, 20, 53, 33, 22, 55, 35, 24, - 45, 27, 17, 53, 35, 25, 69, 52, 44, 56, 41, 34, 22, 9, 3, - 16, 5, 0, 29, 18, 14, 23, 13, 11, 30, 22, 20, 30, 21, 22, - 32, 24, 22, 32, 22, 21, 26, 16, 15, 27, 16, 14, 42, 28, 25, - 59, 46, 40, 61, 46, 41, 44, 29, 22, 53, 38, 31, 65, 50, 43, - 54, 39, 32, 50, 35, 28, 40, 27, 21, 10, 0, 0, 26, 12, 9, - 48, 35, 29, 52, 35, 28, 55, 38, 30, 76, 57, 50, 80, 62, 52, - 99, 82, 74, 88, 73, 66, 58, 43, 38, 38, 24, 21, 75, 64, 62, - 52, 41, 39, 46, 35, 31, 59, 46, 40, 71, 56, 49, 80, 63, 55, - 93, 73, 66, 62, 39, 31, 54, 29, 22, 62, 38, 28, 56, 29, 20, - 75, 48, 39, 70, 43, 34, 56, 29, 18, 79, 52, 41, 67, 43, 31, - 53, 29, 19, 50, 28, 17, 44, 24, 15, 37, 19, 9, 38, 21, 11, - 32, 15, 5, 22, 5, 0, 50, 36, 27, 41, 26, 19, 37, 24, 18, - 24, 11, 5, 18, 7, 3, 33, 22, 18, 12, 3, 0, 15, 4, 2, - 13, 2, 0, 33, 20, 14, 30, 15, 8, 22, 5, 0, 25, 8, 0, - 44, 26, 16, 25, 7, 0, 53, 37, 24, 54, 40, 27, 46, 32, 21, - 45, 32, 23, 44, 33, 27, 69, 60, 55, 70, 62, 60, 60, 54, 54, - 69, 65, 66, 64, 62, 65, 59, 57, 62, 54, 53, 58, 52, 51, 56, - 52, 51, 56, 54, 53, 58, 55, 54, 59, 52, 51, 56, 52, 51, 56, - 53, 52, 57, 53, 52, 57, 53, 52, 57, 53, 52, 57, 52, 51, 56, - 52, 51, 56, 50, 49, 54, 49, 48, 53, 48, 47, 52, 47, 46, 51, - 47, 46, 51, 46, 45, 50, 45, 44, 49, 43, 42, 47, 188, 197, 204, - 195, 204, 211, 186, 193, 199, 160, 167, 173, 136, 139, 144, 124, 128, 131, - 94, 94, 96, 32, 30, 31, 39, 35, 34, 68, 63, 60, 54, 44, 42, - 36, 25, 21, 41, 30, 24, 48, 35, 27, 52, 37, 30, 49, 32, 24, - 72, 54, 44, 65, 45, 34, 50, 30, 19, 56, 36, 25, 47, 27, 16, - 45, 25, 14, 68, 48, 37, 56, 36, 25, 51, 33, 23, 65, 47, 37, - 66, 49, 41, 35, 20, 13, 31, 18, 12, 33, 22, 18, 36, 25, 23, - 22, 12, 10, 22, 14, 12, 14, 5, 6, 7, 0, 0, 7, 0, 0, - 19, 8, 6, 41, 27, 24, 54, 40, 37, 53, 38, 33, 32, 19, 13, - 31, 18, 12, 55, 42, 36, 78, 63, 58, 72, 57, 52, 54, 39, 34, - 37, 22, 15, 25, 10, 3, 46, 33, 27, 48, 35, 29, 51, 34, 27, - 65, 48, 40, 96, 77, 70, 89, 71, 61, 86, 69, 61, 78, 63, 56, - 46, 31, 26, 34, 20, 17, 57, 46, 44, 38, 27, 25, 54, 40, 37, - 74, 59, 54, 65, 48, 41, 85, 66, 59, 74, 54, 47, 28, 8, 0, - 51, 28, 20, 43, 20, 12, 68, 43, 36, 61, 37, 27, 51, 24, 15, - 85, 58, 49, 63, 36, 27, 54, 30, 20, 35, 11, 1, 35, 13, 2, - 37, 17, 8, 39, 21, 11, 42, 25, 17, 21, 7, 0, 42, 27, 20, - 43, 28, 21, 29, 14, 9, 20, 7, 1, 11, 0, 0, 24, 14, 12, - 23, 13, 11, 20, 12, 9, 30, 20, 19, 30, 20, 18, 25, 15, 13, - 18, 7, 3, 19, 6, 0, 27, 12, 5, 33, 16, 9, 31, 14, 4, - 45, 29, 16, 59, 43, 30, 33, 16, 6, 44, 30, 21, 41, 30, 24, - 61, 52, 47, 70, 62, 60, 69, 63, 63, 70, 66, 67, 65, 63, 66, - 58, 56, 61, 52, 50, 55, 51, 50, 55, 54, 53, 58, 55, 54, 59, - 54, 53, 58, 52, 51, 56, 52, 51, 56, 51, 50, 55, 51, 50, 55, - 52, 51, 56, 51, 50, 55, 50, 49, 54, 49, 48, 53, 49, 48, 53, - 48, 47, 52, 47, 46, 51, 47, 46, 51, 47, 46, 51, 45, 44, 49, - 43, 42, 47, 41, 40, 45, 195, 204, 211, 202, 211, 216, 198, 205, 211, - 178, 183, 187, 150, 154, 157, 135, 136, 138, 108, 108, 110, 58, 57, 55, - 35, 29, 29, 39, 31, 28, 41, 31, 29, 48, 37, 31, 46, 33, 27, - 48, 35, 27, 60, 46, 37, 51, 34, 26, 58, 40, 30, 62, 42, 31, - 54, 34, 23, 56, 36, 25, 58, 38, 27, 66, 46, 35, 74, 54, 43, - 52, 34, 22, 53, 35, 25, 77, 60, 52, 45, 30, 23, 37, 24, 18, - 26, 15, 11, 16, 5, 1, 14, 4, 2, 18, 8, 6, 12, 3, 4, - 23, 14, 15, 14, 4, 3, 14, 3, 1, 40, 26, 23, 46, 31, 26, - 32, 17, 12, 32, 17, 12, 31, 18, 12, 54, 41, 35, 65, 52, 46, - 73, 60, 54, 74, 59, 54, 61, 46, 41, 35, 20, 13, 41, 26, 19, - 59, 46, 40, 56, 43, 37, 65, 48, 41, 75, 58, 51, 104, 85, 78, - 92, 74, 64, 67, 50, 42, 59, 44, 37, 27, 12, 7, 31, 17, 14, - 49, 38, 36, 23, 9, 6, 50, 35, 30, 59, 42, 35, 71, 52, 45, - 66, 46, 39, 36, 16, 9, 43, 23, 14, 44, 21, 13, 41, 18, 10, - 53, 28, 21, 45, 18, 9, 65, 38, 29, 70, 42, 31, 49, 21, 10, - 53, 26, 15, 52, 28, 16, 49, 27, 14, 38, 18, 7, 37, 19, 7, - 42, 25, 15, 37, 20, 10, 40, 23, 15, 34, 19, 12, 25, 10, 3, - 24, 11, 5, 31, 20, 16, 42, 32, 30, 34, 24, 22, 19, 11, 9, - 18, 10, 8, 23, 15, 13, 21, 11, 9, 13, 3, 1, 16, 5, 1, - 30, 17, 11, 34, 19, 14, 29, 15, 6, 38, 22, 9, 58, 40, 26, - 41, 25, 12, 52, 38, 29, 44, 31, 23, 54, 43, 39, 64, 54, 52, - 68, 62, 62, 71, 65, 67, 68, 63, 67, 60, 58, 63, 54, 52, 57, - 52, 51, 56, 53, 52, 57, 53, 52, 57, 51, 50, 55, 51, 50, 55, - 50, 49, 54, 49, 48, 53, 49, 48, 53, 50, 49, 54, 50, 49, 54, - 49, 48, 53, 47, 46, 51, 47, 46, 51, 46, 45, 50, 45, 44, 49, - 45, 44, 49, 44, 43, 48, 42, 41, 46, 40, 39, 44, 38, 37, 42, - 203, 210, 216, 210, 217, 223, 211, 216, 222, 196, 201, 205, 166, 170, 173, - 142, 143, 145, 120, 120, 122, 86, 85, 83, 44, 38, 38, 28, 20, 17, - 27, 17, 15, 46, 35, 29, 48, 35, 29, 47, 32, 25, 61, 44, 36, - 62, 45, 37, 59, 41, 31, 64, 46, 36, 64, 46, 36, 61, 43, 33, - 63, 45, 35, 67, 49, 39, 65, 47, 37, 54, 36, 26, 92, 73, 66, - 69, 52, 44, 22, 7, 0, 20, 7, 1, 20, 9, 5, 16, 5, 1, - 7, 0, 0, 10, 0, 0, 15, 6, 7, 39, 31, 29, 42, 31, 29, - 38, 24, 21, 44, 29, 22, 39, 22, 15, 25, 8, 1, 27, 12, 5, - 37, 24, 18, 83, 69, 66, 77, 66, 62, 62, 51, 47, 76, 62, 59, - 70, 55, 50, 37, 22, 15, 60, 45, 38, 65, 52, 46, 64, 51, 45, - 79, 62, 55, 83, 66, 59, 105, 86, 79, 83, 64, 57, 44, 27, 20, - 42, 27, 20, 16, 1, 0, 33, 19, 16, 36, 22, 19, 15, 1, 0, - 37, 22, 15, 36, 19, 11, 59, 39, 30, 39, 19, 10, 28, 8, 0, - 53, 33, 24, 34, 11, 3, 41, 17, 7, 52, 25, 16, 50, 22, 11, - 71, 41, 31, 50, 20, 9, 54, 24, 13, 58, 28, 17, 68, 40, 28, - 60, 34, 21, 45, 21, 9, 44, 22, 9, 42, 23, 9, 42, 24, 12, - 33, 15, 5, 35, 18, 10, 39, 22, 14, 36, 21, 14, 41, 28, 22, - 39, 28, 24, 35, 25, 23, 25, 15, 13, 15, 7, 5, 18, 10, 8, - 13, 3, 1, 7, 0, 0, 16, 5, 1, 34, 23, 17, 38, 25, 19, - 29, 15, 6, 43, 27, 14, 61, 43, 29, 41, 25, 12, 39, 25, 14, - 31, 18, 10, 47, 36, 32, 65, 55, 53, 72, 66, 66, 67, 61, 63, - 64, 59, 63, 58, 56, 61, 54, 52, 57, 52, 51, 56, 53, 52, 57, - 51, 50, 55, 49, 48, 53, 48, 47, 52, 48, 47, 52, 47, 46, 51, - 47, 46, 51, 47, 46, 51, 47, 46, 51, 46, 45, 50, 45, 44, 49, - 45, 44, 49, 44, 43, 48, 42, 41, 46, 41, 40, 45, 40, 39, 44, - 38, 37, 42, 35, 34, 39, 33, 32, 37, 210, 217, 223, 215, 223, 226, - 219, 224, 228, 211, 216, 219, 182, 186, 189, 150, 151, 153, 128, 128, 128, - 106, 102, 101, 55, 50, 47, 40, 32, 29, 25, 14, 10, 33, 22, 16, - 50, 35, 30, 46, 31, 24, 48, 31, 23, 62, 45, 37, 64, 47, 39, - 62, 44, 34, 67, 49, 39, 68, 50, 40, 63, 45, 35, 54, 36, 26, - 56, 38, 28, 75, 58, 48, 85, 68, 60, 25, 10, 3, 27, 14, 8, - 11, 0, 0, 8, 0, 0, 8, 0, 0, 9, 0, 0, 15, 5, 3, - 8, 0, 0, 21, 11, 10, 42, 28, 25, 42, 27, 22, 29, 12, 4, - 30, 12, 2, 32, 13, 6, 21, 4, 0, 56, 41, 36, 99, 85, 82, - 87, 76, 74, 52, 41, 39, 80, 66, 63, 78, 65, 59, 49, 34, 29, - 70, 55, 50, 61, 47, 44, 69, 55, 52, 76, 61, 56, 79, 62, 55, - 90, 71, 65, 58, 39, 32, 30, 13, 6, 35, 20, 13, 17, 2, 0, - 35, 21, 18, 23, 9, 6, 24, 9, 4, 29, 12, 5, 28, 10, 0, - 41, 19, 8, 30, 8, 0, 39, 17, 6, 42, 20, 9, 29, 7, 0, - 42, 15, 4, 52, 24, 12, 60, 30, 19, 57, 23, 11, 50, 17, 2, - 65, 32, 17, 69, 36, 21, 87, 55, 40, 79, 50, 34, 64, 37, 20, - 60, 34, 17, 46, 23, 7, 45, 24, 7, 45, 23, 10, 35, 15, 4, - 34, 14, 5, 31, 13, 3, 44, 27, 19, 36, 23, 15, 27, 13, 10, - 9, 0, 0, 14, 4, 2, 13, 3, 1, 10, 0, 0, 14, 3, 0, - 28, 17, 13, 43, 30, 24, 38, 25, 19, 25, 11, 2, 41, 25, 12, - 61, 43, 29, 46, 30, 17, 42, 28, 17, 42, 29, 21, 59, 48, 44, - 64, 54, 52, 56, 50, 50, 60, 54, 56, 57, 52, 56, 53, 51, 56, - 52, 50, 55, 52, 51, 56, 52, 51, 56, 50, 49, 54, 48, 47, 52, - 47, 46, 51, 46, 45, 50, 45, 44, 49, 45, 44, 49, 45, 44, 49, - 45, 44, 49, 44, 43, 48, 43, 42, 47, 44, 43, 48, 42, 41, 46, - 40, 39, 44, 38, 37, 42, 36, 35, 40, 34, 33, 38, 31, 30, 35, - 29, 28, 33, 216, 224, 227, 221, 229, 232, 225, 230, 234, 224, 229, 232, - 201, 205, 208, 165, 166, 168, 139, 139, 139, 119, 115, 114, 58, 53, 50, - 44, 36, 33, 30, 19, 15, 30, 19, 13, 45, 30, 25, 48, 33, 26, - 45, 28, 21, 50, 33, 26, 56, 39, 32, 50, 33, 25, 56, 39, 31, - 61, 44, 36, 57, 40, 32, 49, 32, 24, 60, 43, 35, 93, 76, 68, - 59, 42, 35, 11, 0, 0, 23, 10, 4, 20, 7, 1, 20, 9, 5, - 32, 21, 17, 26, 16, 14, 15, 5, 3, 10, 0, 0, 8, 0, 0, - 21, 6, 1, 32, 15, 8, 38, 18, 9, 50, 30, 19, 45, 25, 16, - 18, 0, 0, 66, 51, 46, 86, 72, 69, 76, 65, 63, 36, 26, 24, - 77, 66, 62, 86, 73, 67, 68, 53, 48, 76, 61, 56, 61, 47, 44, - 70, 56, 53, 58, 43, 38, 59, 44, 37, 66, 49, 42, 31, 14, 7, - 28, 11, 4, 28, 13, 6, 17, 2, 0, 30, 16, 13, 26, 11, 6, - 24, 9, 2, 29, 10, 3, 35, 15, 6, 40, 16, 4, 35, 11, 0, - 43, 19, 7, 40, 17, 3, 43, 17, 4, 54, 26, 12, 55, 23, 8, - 63, 30, 15, 57, 20, 4, 76, 39, 21, 75, 36, 19, 84, 47, 28, - 112, 75, 56, 110, 75, 55, 94, 59, 39, 81, 49, 28, 64, 33, 13, - 59, 31, 10, 44, 18, 1, 49, 26, 10, 61, 38, 24, 52, 30, 17, - 43, 23, 12, 25, 8, 0, 32, 15, 8, 35, 20, 13, 20, 7, 1, - 19, 8, 4, 26, 15, 11, 40, 27, 21, 46, 33, 27, 43, 28, 21, - 33, 18, 11, 28, 11, 3, 54, 36, 24, 62, 44, 30, 53, 37, 24, - 54, 40, 31, 57, 44, 36, 63, 52, 48, 61, 51, 49, 57, 51, 51, - 56, 50, 52, 53, 48, 52, 50, 48, 53, 51, 49, 54, 51, 50, 55, - 51, 50, 55, 49, 49, 51, 48, 48, 50, 46, 45, 50, 45, 44, 49, - 44, 43, 48, 44, 43, 48, 44, 43, 48, 44, 43, 48, 43, 42, 47, - 41, 40, 45, 43, 42, 47, 41, 40, 45, 38, 37, 42, 36, 35, 40, - 33, 32, 37, 30, 29, 34, 27, 26, 31, 25, 24, 29, 216, 224, 227, - 224, 232, 235, 228, 233, 236, 231, 235, 238, 216, 217, 219, 181, 181, 181, - 150, 149, 147, 127, 123, 120, 74, 69, 66, 41, 33, 30, 36, 25, 21, - 35, 24, 20, 32, 17, 12, 47, 32, 25, 58, 41, 34, 48, 31, 24, - 46, 31, 24, 45, 30, 23, 46, 31, 24, 50, 33, 25, 48, 31, 23, - 50, 33, 25, 61, 44, 36, 71, 54, 46, 22, 7, 0, 42, 27, 20, - 44, 31, 25, 52, 39, 33, 34, 23, 19, 33, 22, 18, 39, 29, 27, - 43, 33, 31, 40, 30, 28, 41, 30, 26, 34, 19, 12, 36, 17, 10, - 58, 36, 25, 69, 47, 34, 56, 34, 23, 37, 18, 11, 56, 41, 36, - 49, 38, 36, 41, 31, 30, 16, 6, 5, 68, 57, 55, 91, 77, 74, - 77, 62, 57, 81, 66, 61, 65, 51, 48, 64, 53, 51, 39, 24, 21, - 39, 24, 19, 46, 29, 22, 19, 2, 0, 30, 13, 6, 19, 4, 0, - 15, 0, 0, 26, 12, 9, 35, 20, 15, 17, 0, 0, 32, 12, 5, - 41, 19, 8, 49, 22, 11, 40, 14, 1, 47, 21, 6, 56, 30, 15, - 52, 25, 8, 64, 33, 15, 63, 27, 11, 69, 32, 13, 79, 38, 20, - 93, 52, 32, 109, 67, 45, 111, 69, 47, 125, 83, 61, 125, 84, 62, - 117, 76, 54, 107, 69, 46, 92, 56, 32, 82, 47, 25, 66, 35, 15, - 60, 31, 13, 62, 35, 18, 64, 38, 23, 64, 41, 27, 53, 33, 22, - 50, 32, 22, 48, 31, 23, 48, 33, 26, 48, 33, 26, 52, 37, 30, - 56, 41, 34, 48, 33, 26, 37, 20, 12, 35, 18, 10, 43, 25, 15, - 67, 49, 37, 57, 41, 28, 50, 36, 25, 59, 46, 37, 60, 47, 41, - 49, 40, 35, 54, 44, 43, 71, 65, 65, 58, 52, 54, 54, 49, 53, - 50, 48, 53, 51, 49, 54, 50, 49, 54, 49, 48, 53, 47, 47, 49, - 47, 47, 49, 45, 44, 49, 45, 44, 49, 44, 43, 48, 44, 43, 48, - 44, 43, 48, 43, 42, 47, 42, 41, 46, 40, 39, 44, 41, 40, 45, - 38, 37, 42, 35, 34, 39, 33, 32, 37, 30, 29, 34, 27, 26, 31, - 24, 23, 28, 22, 21, 26, 216, 221, 224, 227, 232, 235, 230, 234, 237, - 231, 235, 238, 221, 222, 224, 189, 189, 189, 156, 155, 153, 130, 126, 123, - 95, 90, 87, 49, 41, 38, 42, 31, 27, 40, 29, 25, 31, 16, 11, - 41, 26, 21, 53, 36, 29, 52, 35, 28, 50, 35, 30, 54, 41, 35, - 48, 35, 29, 49, 34, 27, 44, 29, 22, 47, 32, 25, 59, 44, 37, - 44, 29, 22, 33, 18, 11, 54, 39, 32, 39, 26, 20, 46, 33, 27, - 39, 28, 24, 42, 32, 30, 50, 40, 38, 42, 32, 30, 53, 42, 38, - 65, 52, 46, 65, 48, 40, 56, 36, 27, 60, 36, 24, 66, 42, 30, - 64, 42, 29, 59, 39, 30, 54, 39, 34, 35, 24, 22, 16, 6, 5, - 9, 0, 0, 56, 45, 43, 88, 74, 71, 64, 49, 44, 76, 61, 56, - 61, 47, 44, 50, 39, 37, 32, 17, 14, 28, 13, 8, 32, 15, 8, - 19, 2, 0, 30, 15, 10, 18, 3, 0, 21, 6, 3, 32, 17, 14, - 37, 19, 15, 25, 8, 0, 39, 19, 10, 47, 23, 11, 57, 29, 17, - 51, 23, 9, 61, 34, 17, 70, 41, 23, 65, 34, 14, 71, 39, 18, - 83, 46, 27, 100, 59, 37, 112, 67, 46, 117, 71, 48, 147, 99, 76, - 142, 94, 71, 139, 92, 66, 143, 97, 71, 142, 98, 71, 135, 94, 66, - 129, 88, 60, 114, 74, 48, 80, 44, 20, 73, 41, 20, 71, 40, 20, - 75, 46, 28, 68, 41, 24, 60, 37, 23, 58, 36, 23, 63, 43, 32, - 70, 52, 42, 64, 47, 39, 59, 42, 34, 53, 36, 28, 43, 26, 18, - 38, 20, 10, 45, 27, 17, 57, 39, 27, 54, 36, 24, 47, 31, 18, - 50, 36, 25, 62, 49, 40, 64, 51, 45, 48, 39, 34, 48, 38, 37, - 66, 60, 60, 60, 54, 56, 55, 50, 54, 49, 47, 52, 49, 47, 52, - 48, 47, 52, 46, 45, 50, 45, 45, 47, 45, 45, 47, 45, 44, 49, - 44, 43, 48, 43, 42, 47, 43, 42, 47, 43, 42, 47, 42, 41, 46, - 41, 40, 45, 39, 38, 43, 38, 37, 42, 35, 34, 39, 32, 31, 36, - 29, 28, 33, 26, 25, 30, 23, 22, 27, 20, 19, 24, 19, 18, 23, - 216, 221, 224, 231, 236, 239, 232, 236, 239, 233, 234, 236, 223, 223, 223, - 194, 193, 191, 161, 157, 156, 132, 127, 124, 104, 96, 93, 64, 55, 50, - 47, 36, 32, 47, 34, 28, 43, 30, 24, 33, 18, 13, 26, 11, 4, - 42, 27, 20, 54, 41, 35, 60, 47, 41, 55, 42, 36, 59, 46, 40, - 50, 35, 28, 50, 35, 28, 67, 52, 45, 46, 31, 24, 46, 31, 24, - 40, 25, 18, 54, 39, 32, 45, 32, 26, 43, 30, 24, 51, 40, 36, - 68, 54, 51, 48, 37, 33, 41, 30, 26, 54, 41, 35, 81, 64, 57, - 81, 63, 53, 63, 41, 30, 71, 49, 36, 85, 63, 52, 69, 51, 41, - 72, 57, 50, 51, 37, 34, 15, 4, 2, 14, 4, 3, 50, 39, 37, - 82, 68, 65, 42, 27, 22, 64, 49, 44, 49, 35, 34, 37, 26, 24, - 34, 20, 19, 25, 10, 7, 22, 7, 2, 19, 4, 0, 31, 16, 9, - 22, 7, 0, 32, 15, 8, 42, 25, 18, 31, 12, 5, 48, 28, 17, - 51, 27, 15, 59, 31, 17, 65, 36, 20, 75, 42, 25, 86, 54, 33, - 88, 53, 31, 98, 62, 40, 99, 61, 38, 119, 78, 56, 147, 102, 79, - 152, 106, 82, 167, 119, 96, 153, 103, 78, 161, 111, 86, 163, 113, 88, - 173, 126, 98, 168, 121, 95, 157, 111, 85, 159, 113, 87, 146, 102, 77, - 118, 78, 53, 97, 61, 37, 77, 42, 20, 85, 53, 32, 85, 54, 36, - 84, 57, 40, 72, 46, 33, 68, 46, 33, 60, 40, 29, 53, 35, 25, - 46, 28, 18, 44, 26, 16, 45, 27, 17, 49, 31, 21, 53, 35, 23, - 57, 39, 27, 54, 36, 24, 48, 32, 19, 47, 30, 20, 45, 31, 22, - 52, 39, 33, 53, 43, 41, 58, 50, 48, 70, 64, 64, 59, 54, 58, - 51, 49, 52, 47, 45, 50, 46, 45, 50, 46, 45, 50, 45, 44, 49, - 44, 44, 46, 45, 45, 47, 44, 43, 48, 44, 43, 48, 43, 42, 47, - 42, 41, 46, 42, 41, 46, 41, 40, 45, 40, 39, 44, 39, 38, 43, - 35, 34, 39, 33, 32, 37, 29, 28, 33, 26, 25, 30, 23, 22, 27, - 21, 20, 25, 18, 17, 22, 16, 15, 20, 217, 220, 225, 222, 226, 229, - 235, 236, 240, 236, 237, 239, 212, 212, 212, 212, 211, 209, 156, 151, 148, - 120, 112, 109, 98, 90, 87, 67, 58, 53, 54, 43, 39, 45, 32, 26, - 39, 26, 20, 50, 37, 29, 51, 38, 30, 42, 29, 21, 44, 31, 25, - 42, 29, 23, 50, 35, 30, 55, 40, 35, 45, 28, 21, 60, 43, 36, - 61, 44, 36, 64, 47, 39, 62, 45, 37, 72, 55, 47, 68, 51, 43, - 75, 58, 50, 70, 53, 45, 63, 46, 38, 73, 54, 47, 59, 42, 35, - 67, 54, 48, 59, 46, 40, 83, 68, 63, 93, 76, 69, 92, 73, 66, - 81, 62, 55, 115, 96, 89, 103, 86, 78, 76, 59, 52, 53, 38, 33, - 16, 2, 0, 15, 1, 0, 45, 31, 30, 69, 55, 54, 25, 11, 8, - 47, 33, 32, 39, 27, 27, 17, 5, 5, 31, 20, 18, 33, 19, 16, - 15, 2, 0, 22, 7, 0, 32, 18, 9, 40, 23, 13, 40, 22, 10, - 53, 31, 18, 61, 38, 24, 65, 38, 21, 75, 44, 26, 90, 57, 38, - 103, 68, 48, 108, 70, 49, 116, 74, 50, 126, 82, 57, 137, 93, 68, - 145, 101, 76, 154, 108, 84, 166, 120, 96, 182, 135, 109, 194, 147, 121, - 185, 137, 114, 182, 134, 111, 183, 135, 112, 189, 142, 116, 191, 143, 120, - 185, 137, 114, 177, 129, 106, 170, 124, 101, 150, 108, 86, 129, 88, 66, - 104, 66, 45, 88, 53, 33, 80, 47, 30, 75, 46, 30, 74, 46, 32, - 75, 49, 36, 73, 51, 38, 47, 27, 16, 64, 44, 33, 60, 40, 29, - 43, 25, 13, 52, 34, 22, 50, 32, 20, 44, 26, 14, 52, 33, 19, - 61, 41, 30, 55, 37, 27, 33, 16, 8, 42, 29, 23, 51, 42, 37, - 49, 44, 41, 76, 72, 71, 60, 58, 61, 48, 48, 50, 44, 43, 48, - 44, 45, 49, 42, 43, 45, 41, 42, 44, 42, 43, 45, 42, 43, 45, - 42, 43, 45, 42, 43, 45, 41, 42, 44, 41, 42, 44, 40, 41, 43, - 39, 40, 42, 37, 37, 39, 35, 35, 37, 31, 31, 33, 29, 29, 31, - 26, 26, 28, 23, 23, 25, 20, 20, 22, 17, 17, 19, 16, 14, 17, - 14, 12, 15, 215, 218, 223, 213, 217, 220, 231, 232, 236, 230, 232, 231, - 227, 225, 226, 206, 202, 199, 120, 115, 112, 114, 106, 103, 96, 87, 82, - 66, 57, 52, 55, 42, 36, 45, 32, 26, 42, 29, 21, 48, 35, 27, - 48, 35, 27, 46, 33, 25, 47, 34, 28, 54, 41, 35, 53, 38, 33, - 35, 20, 15, 55, 38, 31, 82, 65, 58, 62, 45, 37, 66, 49, 41, - 67, 48, 41, 65, 46, 39, 62, 43, 36, 66, 48, 38, 58, 39, 32, - 76, 58, 48, 98, 79, 72, 64, 47, 39, 64, 49, 42, 55, 42, 36, - 56, 41, 36, 86, 71, 66, 98, 81, 74, 106, 89, 82, 124, 107, 100, - 137, 120, 113, 107, 90, 83, 65, 48, 41, 25, 10, 5, 11, 0, 0, - 38, 23, 20, 42, 28, 27, 14, 0, 0, 40, 26, 25, 24, 10, 10, - 20, 8, 8, 36, 22, 21, 37, 23, 20, 27, 14, 8, 25, 11, 2, - 33, 16, 6, 55, 37, 23, 59, 37, 23, 70, 44, 29, 84, 55, 37, - 96, 65, 45, 107, 72, 50, 119, 83, 59, 131, 93, 70, 141, 99, 75, - 156, 110, 84, 165, 118, 90, 176, 129, 101, 184, 137, 109, 188, 141, 115, - 190, 143, 117, 191, 144, 118, 192, 145, 119, 199, 151, 128, 198, 150, 127, - 199, 151, 128, 204, 156, 133, 205, 157, 134, 199, 151, 128, 191, 143, 121, - 186, 140, 117, 170, 125, 104, 156, 114, 92, 130, 89, 69, 101, 64, 45, - 87, 52, 33, 82, 51, 33, 74, 45, 29, 62, 36, 21, 67, 44, 30, - 80, 58, 45, 37, 17, 6, 52, 32, 21, 64, 46, 34, 31, 13, 1, - 41, 25, 12, 50, 32, 20, 55, 36, 22, 58, 39, 25, 64, 44, 35, - 45, 28, 20, 35, 22, 14, 37, 28, 23, 43, 38, 35, 72, 68, 67, - 62, 60, 63, 46, 46, 48, 39, 40, 44, 42, 43, 47, 40, 41, 43, - 38, 39, 41, 39, 40, 42, 40, 41, 43, 40, 41, 43, 40, 41, 43, - 39, 40, 42, 39, 40, 42, 38, 39, 41, 36, 37, 39, 35, 35, 37, - 33, 33, 35, 29, 29, 31, 27, 27, 29, 24, 24, 26, 21, 21, 23, - 19, 19, 21, 16, 16, 18, 15, 13, 16, 13, 11, 14, 209, 212, 217, - 206, 210, 213, 225, 226, 230, 221, 223, 222, 203, 201, 202, 174, 170, 167, - 107, 102, 99, 83, 75, 72, 70, 61, 56, 60, 51, 46, 61, 48, 42, - 53, 40, 34, 42, 29, 21, 37, 24, 16, 37, 24, 16, 49, 36, 28, - 54, 39, 32, 44, 29, 22, 40, 25, 18, 59, 44, 37, 78, 61, 54, - 71, 54, 47, 64, 47, 40, 43, 26, 19, 18, 1, 0, 44, 27, 20, - 46, 29, 22, 50, 33, 25, 60, 43, 36, 77, 60, 52, 99, 82, 75, - 95, 80, 73, 49, 36, 30, 73, 60, 54, 38, 23, 18, 50, 35, 30, - 81, 64, 57, 97, 80, 73, 105, 88, 81, 129, 112, 105, 121, 104, 97, - 74, 57, 50, 45, 28, 21, 12, 0, 0, 33, 18, 13, 26, 11, 8, - 13, 0, 0, 32, 18, 15, 28, 14, 11, 14, 0, 0, 32, 17, 12, - 47, 32, 25, 40, 26, 17, 42, 25, 15, 49, 29, 18, 55, 33, 19, - 86, 60, 45, 95, 68, 49, 112, 81, 61, 127, 95, 74, 141, 105, 81, - 154, 117, 91, 174, 134, 109, 191, 149, 124, 195, 149, 123, 198, 151, 123, - 201, 154, 128, 205, 158, 132, 207, 160, 134, 207, 160, 134, 204, 157, 131, - 202, 155, 129, 209, 161, 138, 210, 162, 139, 213, 165, 142, 216, 168, 145, - 215, 167, 144, 210, 162, 139, 203, 155, 132, 198, 152, 128, 184, 139, 116, - 173, 131, 109, 149, 108, 88, 121, 83, 64, 103, 66, 48, 91, 58, 41, - 78, 46, 31, 62, 34, 20, 63, 37, 24, 82, 60, 47, 46, 26, 15, - 25, 5, 0, 56, 38, 26, 69, 51, 39, 58, 40, 28, 61, 43, 31, - 62, 43, 29, 55, 36, 22, 67, 47, 38, 56, 39, 31, 33, 20, 12, - 28, 19, 14, 41, 33, 31, 69, 65, 64, 65, 63, 66, 45, 45, 47, - 35, 36, 38, 39, 40, 42, 38, 39, 41, 35, 36, 38, 36, 37, 39, - 38, 39, 41, 37, 38, 40, 37, 38, 40, 36, 37, 39, 35, 36, 38, - 36, 36, 38, 34, 34, 36, 32, 32, 34, 30, 30, 32, 27, 27, 29, - 25, 25, 27, 22, 22, 24, 19, 19, 21, 17, 17, 19, 15, 15, 17, - 13, 11, 14, 12, 10, 13, 195, 198, 203, 211, 215, 218, 217, 218, 222, - 221, 223, 222, 195, 193, 194, 145, 141, 138, 105, 100, 97, 57, 49, 46, - 48, 39, 34, 49, 40, 35, 54, 41, 35, 48, 35, 29, 42, 29, 21, - 39, 26, 18, 39, 26, 18, 54, 41, 33, 56, 41, 34, 30, 15, 8, - 66, 51, 44, 81, 66, 59, 80, 63, 56, 59, 42, 35, 41, 24, 17, - 44, 27, 20, 59, 42, 35, 72, 57, 50, 59, 44, 37, 52, 37, 30, - 55, 40, 33, 54, 39, 32, 81, 66, 61, 116, 103, 97, 86, 73, 67, - 48, 35, 29, 61, 46, 41, 14, 0, 0, 41, 24, 17, 91, 74, 67, - 48, 31, 24, 86, 69, 61, 92, 75, 68, 68, 51, 43, 59, 42, 35, - 28, 11, 4, 37, 20, 13, 29, 14, 9, 21, 6, 1, 27, 12, 7, - 30, 15, 8, 37, 20, 12, 34, 17, 9, 46, 29, 19, 70, 52, 40, - 62, 43, 29, 52, 30, 16, 75, 49, 32, 94, 67, 48, 119, 88, 68, - 151, 119, 98, 177, 141, 119, 187, 150, 124, 192, 152, 126, 200, 158, 133, - 208, 164, 137, 215, 168, 142, 213, 166, 138, 210, 163, 137, 209, 162, 136, - 210, 163, 137, 212, 165, 139, 212, 165, 139, 212, 165, 139, 212, 164, 141, - 214, 166, 143, 218, 170, 147, 220, 172, 149, 217, 169, 146, 212, 164, 141, - 207, 159, 136, 204, 156, 133, 196, 150, 127, 182, 137, 114, 162, 120, 98, - 143, 105, 84, 124, 87, 68, 100, 67, 48, 83, 51, 36, 72, 44, 30, - 55, 29, 14, 78, 55, 41, 114, 92, 79, 55, 35, 24, 26, 6, 0, - 65, 47, 35, 63, 45, 33, 67, 49, 37, 70, 48, 35, 56, 36, 25, - 62, 42, 33, 55, 38, 30, 40, 27, 19, 30, 21, 16, 38, 30, 28, - 73, 69, 68, 69, 67, 68, 45, 45, 47, 32, 33, 35, 36, 37, 39, - 36, 37, 39, 33, 34, 36, 34, 35, 37, 36, 37, 39, 34, 35, 37, - 33, 34, 36, 32, 33, 35, 32, 33, 35, 32, 32, 34, 31, 31, 33, - 28, 28, 30, 27, 27, 29, 24, 24, 26, 22, 22, 24, 20, 20, 22, - 17, 17, 19, 15, 15, 17, 14, 14, 16, 12, 10, 13, 11, 9, 12, - 183, 186, 191, 216, 220, 223, 214, 215, 219, 229, 231, 230, 228, 226, 227, - 159, 155, 152, 97, 92, 89, 62, 54, 51, 52, 43, 38, 42, 33, 28, - 38, 25, 19, 33, 20, 14, 43, 30, 22, 52, 39, 31, 48, 35, 27, - 53, 38, 31, 47, 30, 22, 81, 64, 56, 82, 65, 57, 76, 59, 51, - 71, 57, 48, 41, 27, 18, 55, 40, 33, 59, 44, 37, 57, 42, 37, - 39, 26, 20, 35, 22, 16, 43, 30, 24, 36, 23, 17, 39, 26, 20, - 69, 55, 52, 91, 78, 72, 123, 110, 104, 40, 27, 21, 48, 33, 28, - 27, 12, 7, 32, 15, 8, 72, 55, 48, 43, 24, 17, 45, 27, 17, - 49, 30, 23, 49, 31, 21, 57, 38, 31, 45, 28, 20, 42, 25, 17, - 37, 20, 13, 25, 8, 1, 29, 12, 4, 42, 24, 14, 47, 29, 17, - 64, 44, 33, 79, 60, 46, 78, 56, 42, 77, 54, 38, 95, 69, 52, - 112, 84, 63, 130, 99, 78, 161, 126, 104, 191, 155, 131, 207, 167, 142, - 209, 167, 142, 212, 168, 141, 214, 168, 142, 215, 168, 142, 218, 171, 145, - 220, 170, 145, 220, 170, 145, 219, 169, 144, 218, 168, 143, 217, 167, 142, - 215, 165, 140, 214, 164, 139, 217, 167, 144, 220, 170, 147, 223, 173, 150, - 223, 173, 150, 220, 170, 147, 216, 166, 143, 213, 163, 140, 208, 160, 137, - 206, 160, 137, 195, 150, 127, 179, 137, 115, 163, 122, 102, 140, 102, 83, - 114, 79, 60, 92, 59, 42, 79, 50, 34, 60, 32, 18, 64, 41, 27, - 109, 87, 74, 109, 90, 76, 50, 31, 17, 40, 21, 7, 69, 51, 39, - 64, 46, 34, 69, 47, 36, 59, 39, 28, 57, 37, 28, 48, 31, 23, - 43, 30, 22, 29, 20, 15, 31, 23, 20, 76, 72, 71, 69, 67, 68, - 45, 45, 45, 30, 31, 33, 32, 33, 35, 32, 33, 35, 30, 31, 33, - 30, 31, 33, 32, 33, 35, 31, 32, 34, 30, 31, 33, 30, 30, 32, - 29, 29, 31, 29, 29, 31, 27, 27, 29, 25, 25, 27, 24, 24, 26, - 22, 22, 24, 20, 20, 22, 18, 18, 20, 16, 16, 18, 15, 13, 16, - 14, 12, 15, 12, 10, 13, 10, 8, 11, 179, 182, 187, 206, 210, 213, - 224, 225, 229, 228, 230, 229, 235, 233, 234, 205, 201, 198, 117, 112, 109, - 67, 59, 56, 59, 50, 45, 43, 34, 29, 40, 27, 21, 37, 24, 18, - 41, 28, 20, 47, 34, 26, 41, 28, 20, 40, 26, 17, 69, 52, 42, - 83, 65, 55, 91, 73, 63, 66, 49, 41, 61, 44, 36, 67, 53, 44, - 61, 46, 39, 57, 44, 36, 38, 25, 19, 33, 22, 16, 37, 26, 20, - 40, 29, 23, 32, 21, 17, 27, 16, 12, 34, 23, 19, 43, 32, 28, - 83, 70, 64, 81, 68, 62, 21, 6, 1, 39, 24, 17, 42, 25, 18, - 42, 23, 16, 58, 40, 30, 29, 11, 1, 32, 12, 3, 36, 18, 6, - 46, 26, 15, 56, 38, 26, 52, 34, 24, 47, 29, 19, 32, 14, 4, - 44, 26, 14, 52, 30, 17, 81, 60, 43, 89, 66, 50, 98, 75, 57, - 117, 91, 74, 117, 90, 71, 134, 106, 85, 171, 139, 118, 187, 152, 130, - 205, 167, 144, 217, 177, 152, 213, 171, 146, 211, 165, 139, 216, 169, 141, - 223, 173, 146, 224, 174, 147, 217, 167, 142, 219, 169, 144, 219, 169, 144, - 219, 169, 144, 218, 168, 143, 217, 167, 142, 217, 167, 142, 219, 169, 144, - 220, 170, 147, 223, 173, 150, 225, 175, 152, 223, 173, 150, 221, 171, 148, - 219, 169, 146, 216, 166, 143, 211, 163, 140, 207, 161, 138, 205, 160, 137, - 194, 149, 128, 170, 128, 106, 145, 107, 86, 126, 89, 70, 101, 68, 49, - 81, 50, 32, 80, 53, 36, 48, 22, 7, 50, 27, 13, 106, 84, 71, - 99, 77, 64, 67, 48, 34, 85, 65, 54, 75, 55, 44, 60, 40, 29, - 60, 40, 31, 55, 36, 29, 41, 24, 17, 37, 24, 18, 22, 13, 8, - 20, 12, 9, 67, 62, 59, 69, 65, 66, 46, 44, 45, 31, 31, 33, - 28, 29, 31, 27, 28, 30, 26, 27, 29, 27, 28, 30, 26, 27, 29, - 28, 29, 31, 27, 28, 30, 26, 26, 28, 26, 26, 28, 25, 25, 27, - 24, 24, 26, 22, 22, 24, 20, 20, 22, 20, 20, 22, 18, 18, 20, - 16, 16, 18, 14, 14, 16, 14, 12, 15, 12, 10, 13, 11, 9, 12, - 9, 7, 10, 165, 168, 173, 200, 204, 207, 228, 229, 233, 224, 226, 225, - 224, 222, 223, 228, 224, 221, 138, 133, 130, 59, 51, 48, 67, 58, 53, - 44, 35, 30, 45, 32, 26, 45, 32, 26, 35, 22, 14, 31, 18, 10, - 33, 20, 12, 43, 29, 20, 85, 67, 57, 86, 68, 56, 75, 57, 45, - 81, 64, 54, 67, 50, 42, 62, 48, 39, 63, 48, 41, 23, 10, 2, - 26, 13, 7, 41, 30, 26, 49, 38, 34, 38, 29, 24, 24, 15, 10, - 13, 4, 0, 16, 6, 4, 36, 25, 21, 37, 24, 18, 77, 62, 55, - 56, 39, 32, 34, 17, 10, 37, 18, 11, 47, 29, 19, 47, 27, 18, - 41, 21, 10, 37, 15, 4, 37, 18, 4, 40, 18, 5, 53, 34, 20, - 65, 46, 32, 67, 48, 34, 55, 36, 22, 67, 45, 31, 81, 55, 38, - 92, 65, 46, 105, 76, 58, 127, 99, 78, 145, 114, 94, 163, 132, 111, - 191, 159, 136, 199, 163, 139, 211, 174, 148, 221, 179, 154, 228, 184, 157, - 229, 184, 155, 230, 180, 153, 228, 179, 149, 225, 174, 145, 221, 170, 141, - 220, 170, 145, 219, 169, 146, 217, 167, 144, 215, 165, 142, 215, 165, 142, - 218, 168, 145, 222, 172, 149, 225, 175, 152, 223, 173, 150, 225, 175, 152, - 224, 174, 151, 222, 172, 149, 221, 171, 148, 220, 170, 147, 218, 168, 145, - 212, 164, 141, 208, 162, 138, 208, 164, 139, 198, 153, 130, 175, 133, 111, - 152, 111, 91, 131, 93, 74, 108, 73, 54, 88, 55, 38, 85, 56, 40, - 66, 38, 24, 57, 31, 16, 90, 67, 53, 99, 77, 64, 76, 57, 43, - 79, 60, 46, 84, 64, 53, 57, 37, 26, 52, 32, 23, 51, 32, 25, - 38, 21, 14, 30, 17, 11, 20, 9, 5, 15, 5, 3, 43, 38, 35, - 66, 62, 63, 47, 45, 46, 32, 32, 34, 26, 26, 28, 22, 23, 25, - 24, 25, 27, 26, 27, 29, 22, 23, 25, 26, 26, 28, 25, 25, 27, - 23, 23, 25, 22, 22, 24, 21, 21, 23, 20, 20, 22, 19, 19, 21, - 17, 17, 19, 18, 16, 19, 16, 14, 17, 14, 12, 15, 13, 11, 14, - 12, 10, 13, 11, 9, 12, 9, 7, 10, 8, 6, 9, 142, 145, 150, - 209, 213, 216, 219, 220, 224, 228, 230, 229, 237, 235, 236, 221, 217, 214, - 125, 120, 117, 56, 48, 45, 83, 74, 69, 43, 34, 29, 36, 23, 17, - 38, 25, 19, 29, 16, 8, 29, 16, 8, 44, 31, 23, 63, 49, 40, - 78, 60, 50, 102, 82, 71, 91, 71, 60, 82, 64, 52, 67, 50, 42, - 56, 42, 33, 31, 16, 9, 12, 0, 0, 31, 20, 14, 36, 25, 21, - 67, 58, 53, 69, 60, 55, 30, 21, 16, 14, 5, 0, 21, 12, 7, - 22, 11, 7, 35, 20, 13, 45, 28, 20, 81, 62, 55, 49, 30, 23, - 39, 19, 10, 48, 28, 17, 64, 42, 31, 48, 24, 12, 40, 17, 3, - 44, 21, 7, 39, 16, 0, 45, 22, 6, 75, 52, 36, 90, 67, 51, - 81, 60, 43, 81, 58, 40, 93, 65, 44, 109, 78, 57, 115, 83, 60, - 138, 106, 83, 169, 134, 112, 192, 156, 132, 214, 177, 151, 218, 178, 152, - 224, 182, 157, 222, 178, 151, 222, 177, 148, 228, 181, 151, 235, 184, 155, - 234, 183, 154, 234, 181, 150, 232, 181, 152, 228, 176, 152, 226, 176, 153, - 224, 174, 151, 223, 173, 150, 223, 173, 150, 224, 174, 151, 225, 175, 152, - 225, 175, 152, 226, 176, 153, 227, 177, 154, 225, 175, 152, 222, 172, 149, - 221, 171, 148, 222, 172, 149, 220, 170, 147, 216, 166, 143, 218, 170, 147, - 211, 165, 141, 201, 155, 132, 186, 141, 118, 161, 119, 97, 133, 92, 72, - 108, 71, 52, 97, 62, 43, 75, 44, 26, 89, 60, 44, 79, 52, 35, - 96, 70, 55, 91, 68, 54, 61, 39, 26, 74, 52, 39, 73, 53, 42, - 59, 39, 30, 42, 24, 14, 43, 26, 18, 34, 19, 12, 28, 13, 8, - 23, 12, 8, 15, 5, 3, 22, 17, 14, 65, 61, 60, 49, 47, 48, - 35, 33, 36, 26, 26, 28, 22, 22, 24, 25, 26, 28, 26, 27, 29, - 20, 21, 23, 24, 24, 26, 23, 23, 25, 21, 21, 23, 20, 20, 22, - 19, 19, 21, 18, 18, 20, 17, 17, 19, 15, 15, 17, 16, 14, 17, - 15, 13, 16, 13, 11, 14, 11, 9, 12, 11, 9, 12, 10, 8, 11, - 8, 6, 9, 7, 5, 8, 90, 93, 98, 184, 188, 191, 220, 221, 225, - 225, 227, 226, 235, 233, 234, 216, 212, 209, 196, 191, 188, 135, 127, 124, - 25, 16, 11, 41, 32, 27, 33, 20, 14, 30, 17, 11, 43, 30, 22, - 38, 25, 17, 42, 29, 21, 64, 50, 41, 87, 67, 56, 108, 89, 75, - 88, 68, 57, 77, 59, 47, 65, 48, 40, 43, 29, 20, 19, 4, 0, - 21, 8, 0, 55, 44, 38, 38, 27, 21, 26, 15, 11, 55, 44, 40, - 51, 40, 34, 14, 3, 0, 20, 9, 3, 37, 24, 18, 53, 36, 28, - 46, 28, 18, 59, 39, 30, 75, 55, 44, 52, 30, 17, 57, 34, 20, - 97, 71, 58, 79, 53, 38, 59, 32, 15, 58, 31, 14, 51, 24, 7, - 50, 23, 6, 63, 36, 19, 77, 50, 33, 85, 58, 41, 92, 63, 45, - 123, 91, 68, 134, 100, 75, 147, 111, 87, 169, 133, 107, 196, 159, 133, - 215, 175, 149, 222, 180, 155, 228, 184, 157, 227, 181, 155, 229, 182, 154, - 233, 183, 156, 235, 184, 155, 236, 185, 156, 237, 184, 153, 235, 182, 151, - 232, 181, 152, 233, 181, 157, 230, 180, 157, 228, 178, 155, 227, 177, 154, - 227, 177, 154, 227, 177, 154, 227, 177, 154, 226, 176, 153, 228, 178, 155, - 226, 176, 153, 224, 174, 151, 224, 174, 151, 224, 174, 151, 223, 173, 150, - 220, 170, 147, 217, 167, 144, 214, 166, 143, 212, 166, 142, 212, 166, 142, - 202, 157, 134, 177, 135, 113, 154, 113, 93, 131, 93, 72, 113, 76, 57, - 89, 56, 37, 92, 61, 43, 93, 66, 49, 103, 77, 62, 107, 84, 70, - 64, 42, 28, 42, 20, 7, 51, 31, 20, 48, 28, 19, 48, 29, 22, - 42, 25, 18, 31, 16, 9, 26, 11, 6, 23, 12, 8, 20, 10, 8, - 12, 7, 4, 45, 41, 40, 57, 56, 54, 40, 38, 39, 23, 23, 23, - 27, 27, 29, 24, 24, 26, 19, 19, 21, 24, 24, 26, 21, 21, 21, - 19, 19, 19, 18, 18, 18, 17, 17, 17, 16, 16, 16, 15, 15, 15, - 14, 14, 14, 13, 13, 13, 13, 11, 12, 12, 10, 11, 10, 8, 9, - 9, 7, 8, 7, 5, 6, 7, 5, 6, 7, 5, 6, 7, 5, 6, - 90, 93, 98, 92, 96, 99, 192, 193, 197, 212, 214, 213, 210, 208, 209, - 214, 210, 207, 189, 184, 181, 124, 116, 113, 18, 9, 4, 33, 24, 19, - 36, 23, 17, 35, 22, 16, 47, 34, 26, 42, 29, 21, 41, 28, 20, - 66, 52, 43, 100, 80, 69, 111, 89, 76, 101, 81, 70, 80, 62, 52, - 64, 45, 38, 34, 17, 9, 36, 21, 14, 48, 35, 27, 68, 55, 49, - 60, 47, 41, 15, 2, 0, 15, 2, 0, 40, 27, 21, 31, 18, 10, - 29, 14, 7, 41, 24, 16, 61, 41, 32, 82, 60, 49, 77, 53, 41, - 80, 56, 44, 82, 56, 43, 75, 49, 34, 100, 71, 55, 117, 88, 72, - 115, 84, 66, 101, 70, 50, 74, 43, 23, 57, 26, 6, 62, 31, 11, - 77, 46, 26, 91, 60, 40, 103, 71, 50, 126, 90, 66, 148, 111, 84, - 173, 133, 108, 195, 155, 129, 215, 173, 148, 227, 183, 158, 231, 185, 159, - 234, 188, 162, 233, 186, 158, 235, 185, 158, 237, 186, 157, 238, 187, 158, - 240, 186, 158, 239, 186, 155, 238, 184, 156, 235, 184, 155, 234, 184, 159, - 233, 183, 160, 232, 182, 159, 232, 182, 159, 231, 181, 158, 229, 179, 156, - 227, 177, 154, 225, 175, 152, 226, 176, 153, 226, 176, 153, 225, 175, 152, - 225, 175, 152, 224, 174, 151, 222, 172, 149, 219, 169, 146, 218, 168, 145, - 217, 169, 146, 217, 169, 146, 218, 170, 147, 209, 163, 139, 188, 143, 120, - 164, 122, 100, 141, 100, 78, 119, 81, 60, 100, 65, 45, 94, 61, 42, - 90, 61, 43, 83, 56, 39, 99, 73, 58, 61, 38, 24, 42, 18, 6, - 28, 6, 0, 39, 21, 11, 42, 23, 16, 45, 28, 21, 40, 25, 18, - 29, 14, 11, 15, 4, 0, 12, 2, 0, 15, 7, 4, 27, 22, 19, - 50, 46, 45, 43, 39, 40, 22, 20, 21, 22, 22, 24, 23, 23, 25, - 20, 20, 22, 21, 21, 23, 19, 19, 19, 18, 18, 18, 16, 16, 16, - 15, 15, 15, 14, 14, 14, 13, 13, 13, 12, 12, 12, 11, 11, 11, - 11, 9, 10, 11, 9, 10, 9, 7, 8, 8, 6, 7, 8, 6, 7, - 8, 6, 7, 8, 6, 7, 8, 6, 7, 128, 131, 136, 96, 100, 103, - 70, 71, 75, 126, 128, 127, 148, 146, 147, 156, 152, 149, 95, 90, 87, - 6, 0, 0, 30, 21, 16, 35, 26, 21, 42, 29, 23, 37, 24, 18, - 43, 30, 22, 43, 30, 22, 43, 30, 22, 76, 62, 53, 108, 88, 77, - 106, 84, 71, 113, 93, 82, 89, 71, 61, 65, 46, 39, 22, 5, 0, - 40, 25, 18, 47, 32, 25, 62, 47, 40, 60, 45, 38, 33, 18, 11, - 26, 11, 4, 37, 20, 12, 40, 23, 15, 45, 27, 17, 36, 16, 5, - 64, 42, 29, 99, 76, 62, 100, 74, 59, 114, 86, 72, 135, 106, 90, - 120, 91, 73, 124, 91, 72, 145, 112, 93, 149, 114, 94, 150, 115, 95, - 140, 103, 84, 121, 84, 65, 110, 73, 54, 106, 69, 50, 111, 74, 55, - 123, 85, 64, 146, 106, 81, 178, 137, 109, 208, 164, 139, 222, 178, 151, - 230, 184, 158, 232, 186, 160, 232, 185, 159, 236, 186, 161, 239, 189, 162, - 240, 189, 162, 240, 189, 162, 240, 189, 162, 239, 188, 161, 238, 187, 158, - 238, 187, 160, 237, 186, 159, 237, 187, 164, 235, 187, 165, 235, 187, 165, - 234, 186, 164, 233, 185, 163, 230, 182, 160, 226, 178, 156, 223, 175, 153, - 221, 173, 150, 223, 175, 152, 224, 176, 153, 223, 175, 152, 221, 173, 150, - 218, 170, 147, 216, 168, 145, 216, 168, 145, 216, 166, 141, 214, 167, 141, - 216, 168, 145, 211, 165, 141, 195, 149, 125, 175, 130, 107, 149, 107, 85, - 126, 85, 65, 115, 78, 59, 95, 60, 41, 81, 50, 32, 61, 32, 16, - 78, 52, 37, 47, 24, 8, 54, 31, 17, 47, 25, 12, 25, 6, 0, - 21, 4, 0, 29, 12, 5, 40, 25, 18, 40, 25, 22, 24, 13, 9, - 17, 7, 5, 20, 12, 9, 16, 11, 8, 46, 42, 41, 50, 46, 47, - 26, 24, 25, 18, 18, 18, 22, 22, 22, 19, 19, 21, 16, 16, 18, - 17, 17, 17, 15, 15, 15, 13, 13, 13, 12, 12, 12, 13, 11, 12, - 12, 10, 11, 10, 8, 9, 9, 7, 8, 10, 8, 9, 9, 7, 8, - 9, 7, 8, 8, 6, 7, 8, 6, 7, 8, 6, 7, 11, 7, 8, - 11, 7, 8, 130, 133, 138, 145, 149, 152, 166, 167, 171, 143, 145, 144, - 140, 138, 139, 129, 125, 122, 65, 60, 57, 37, 29, 26, 40, 31, 26, - 35, 26, 21, 47, 34, 28, 38, 25, 19, 37, 24, 16, 43, 30, 22, - 47, 34, 26, 84, 70, 61, 111, 91, 80, 99, 77, 66, 109, 89, 80, - 94, 74, 65, 61, 42, 35, 23, 6, 0, 41, 24, 17, 33, 18, 11, - 51, 34, 27, 53, 36, 29, 47, 30, 22, 45, 26, 19, 39, 19, 10, - 39, 19, 8, 54, 32, 19, 54, 31, 17, 64, 38, 23, 82, 55, 38, - 100, 71, 53, 135, 106, 88, 166, 135, 115, 168, 135, 116, 170, 135, 115, - 170, 134, 112, 167, 129, 108, 175, 137, 114, 174, 133, 111, 161, 120, 98, - 148, 107, 85, 140, 99, 77, 143, 102, 80, 155, 113, 91, 183, 139, 114, - 211, 165, 139, 230, 184, 158, 234, 187, 161, 234, 187, 161, 236, 186, 161, - 236, 186, 161, 236, 186, 161, 242, 190, 166, 241, 190, 163, 240, 188, 164, - 240, 189, 162, 239, 187, 163, 238, 188, 161, 239, 187, 163, 238, 188, 163, - 237, 189, 167, 236, 188, 166, 236, 188, 166, 235, 187, 165, 234, 186, 164, - 231, 183, 161, 227, 179, 157, 224, 176, 154, 221, 173, 150, 222, 174, 151, - 223, 175, 152, 223, 175, 152, 222, 174, 151, 219, 171, 148, 217, 169, 146, - 216, 168, 145, 220, 170, 145, 219, 169, 144, 219, 171, 148, 218, 170, 147, - 208, 160, 137, 192, 146, 122, 168, 123, 100, 141, 100, 78, 118, 80, 59, - 89, 54, 34, 83, 50, 31, 86, 57, 39, 99, 72, 55, 53, 27, 12, - 55, 32, 18, 52, 30, 17, 34, 15, 8, 27, 10, 3, 30, 13, 6, - 40, 25, 20, 40, 26, 23, 26, 12, 9, 15, 4, 2, 15, 5, 3, - 16, 8, 6, 41, 36, 33, 54, 50, 49, 35, 31, 32, 20, 18, 19, - 21, 21, 21, 18, 18, 20, 15, 15, 17, 15, 15, 15, 13, 13, 13, - 11, 11, 11, 10, 10, 10, 11, 9, 10, 10, 8, 9, 8, 6, 7, - 7, 5, 6, 8, 6, 7, 8, 6, 7, 8, 6, 7, 8, 6, 7, - 8, 6, 7, 8, 6, 7, 11, 7, 8, 11, 7, 8, 131, 134, 139, - 151, 155, 158, 197, 198, 202, 233, 235, 234, 227, 225, 226, 141, 137, 134, - 7, 2, 0, 44, 36, 33, 34, 25, 20, 27, 18, 13, 44, 31, 25, - 39, 26, 20, 36, 23, 15, 44, 31, 23, 49, 36, 28, 80, 66, 57, - 106, 86, 77, 93, 71, 60, 90, 70, 61, 84, 64, 55, 45, 26, 19, - 30, 11, 4, 47, 28, 22, 40, 23, 16, 38, 19, 12, 58, 39, 32, - 52, 32, 23, 52, 30, 19, 67, 43, 31, 62, 36, 23, 58, 30, 16, - 72, 45, 28, 69, 40, 22, 73, 45, 24, 94, 63, 43, 135, 103, 82, - 172, 137, 115, 196, 160, 138, 211, 173, 150, 209, 169, 144, 213, 171, 147, - 211, 169, 145, 204, 159, 136, 199, 154, 131, 202, 157, 134, 201, 156, 133, - 200, 154, 131, 203, 157, 134, 212, 166, 142, 230, 183, 157, 237, 190, 164, - 236, 186, 161, 237, 187, 162, 242, 190, 166, 241, 189, 165, 240, 188, 164, - 241, 189, 165, 240, 188, 164, 239, 189, 166, 238, 188, 163, 238, 188, 165, - 237, 190, 164, 239, 189, 166, 238, 190, 167, 237, 189, 167, 235, 188, 168, - 233, 187, 164, 232, 186, 163, 231, 185, 162, 230, 184, 161, 228, 182, 159, - 226, 180, 157, 224, 178, 154, 223, 177, 153, 222, 176, 152, 223, 177, 153, - 224, 178, 154, 223, 177, 153, 219, 173, 149, 217, 169, 146, 221, 171, 146, - 219, 169, 144, 219, 169, 144, 216, 169, 143, 210, 163, 137, 199, 153, 129, - 178, 133, 110, 151, 109, 87, 135, 94, 72, 101, 65, 43, 87, 52, 33, - 111, 80, 62, 116, 87, 71, 62, 36, 21, 44, 21, 7, 35, 13, 0, - 39, 20, 13, 38, 20, 16, 38, 23, 18, 39, 24, 19, 30, 16, 13, - 20, 6, 3, 15, 4, 2, 19, 9, 7, 15, 7, 5, 28, 23, 20, - 47, 43, 42, 38, 34, 33, 21, 19, 20, 20, 18, 19, 15, 15, 17, - 16, 16, 18, 13, 13, 13, 11, 11, 11, 11, 9, 10, 10, 8, 9, - 9, 7, 8, 9, 7, 8, 8, 6, 7, 7, 5, 6, 7, 5, 6, - 7, 5, 6, 7, 5, 6, 7, 5, 6, 10, 6, 7, 10, 6, 7, - 11, 7, 8, 11, 7, 8, 141, 144, 149, 137, 141, 144, 176, 177, 181, - 211, 213, 212, 200, 198, 199, 122, 118, 115, 103, 98, 95, 6, 0, 0, - 39, 30, 25, 29, 20, 15, 41, 28, 22, 36, 23, 17, 30, 17, 9, - 41, 28, 20, 53, 40, 32, 73, 59, 50, 84, 64, 55, 77, 55, 44, - 65, 45, 36, 67, 47, 38, 29, 10, 3, 27, 8, 1, 38, 19, 13, - 42, 23, 17, 35, 16, 9, 57, 37, 28, 62, 40, 29, 59, 35, 23, - 71, 43, 31, 74, 45, 31, 72, 40, 25, 75, 44, 26, 90, 59, 38, - 114, 82, 59, 134, 102, 79, 162, 127, 105, 198, 162, 138, 215, 178, 152, - 223, 181, 157, 233, 189, 164, 227, 183, 158, 227, 181, 157, 223, 175, 152, - 223, 175, 152, 227, 179, 156, 224, 176, 153, 219, 171, 149, 220, 172, 149, - 230, 180, 155, 238, 188, 163, 237, 187, 162, 233, 183, 158, 238, 186, 162, - 241, 189, 165, 238, 186, 162, 235, 183, 159, 240, 188, 166, 240, 188, 166, - 239, 189, 166, 239, 189, 166, 237, 189, 166, 238, 190, 167, 239, 191, 169, - 238, 192, 169, 235, 188, 168, 234, 187, 167, 232, 186, 163, 230, 184, 161, - 230, 184, 161, 230, 184, 161, 229, 183, 160, 228, 182, 159, 228, 182, 158, - 226, 180, 156, 224, 178, 154, 225, 179, 155, 227, 181, 157, 227, 181, 157, - 223, 177, 153, 220, 174, 150, 219, 169, 144, 216, 166, 141, 215, 165, 140, - 213, 163, 138, 207, 160, 134, 200, 153, 127, 181, 135, 111, 155, 113, 89, - 142, 101, 79, 118, 82, 60, 89, 54, 34, 99, 68, 48, 96, 67, 49, - 52, 25, 8, 44, 18, 3, 39, 17, 4, 30, 11, 4, 29, 11, 7, - 26, 11, 6, 25, 10, 5, 23, 9, 6, 23, 9, 6, 23, 12, 10, - 24, 14, 12, 22, 12, 11, 20, 15, 12, 45, 39, 39, 41, 37, 36, - 20, 18, 19, 17, 15, 16, 11, 11, 13, 14, 14, 16, 11, 11, 11, - 10, 10, 10, 9, 7, 8, 9, 7, 8, 9, 7, 8, 8, 6, 7, - 7, 5, 6, 7, 5, 6, 7, 5, 6, 7, 5, 6, 7, 5, 6, - 7, 5, 6, 10, 6, 7, 10, 6, 7, 10, 6, 7, 10, 6, 7, - 144, 147, 152, 149, 153, 156, 173, 174, 178, 217, 219, 218, 163, 161, 162, - 153, 149, 146, 112, 107, 104, 12, 4, 1, 43, 34, 29, 34, 25, 20, - 37, 24, 18, 32, 19, 13, 25, 12, 4, 37, 24, 16, 57, 44, 36, - 64, 50, 41, 64, 44, 35, 57, 34, 26, 38, 18, 11, 48, 28, 21, - 26, 7, 1, 22, 3, 0, 26, 7, 1, 37, 18, 12, 54, 34, 27, - 60, 37, 29, 70, 43, 32, 66, 38, 26, 67, 35, 20, 86, 53, 36, - 106, 71, 52, 109, 74, 54, 135, 100, 78, 172, 138, 113, 197, 161, 137, - 208, 171, 145, 229, 189, 164, 232, 190, 165, 226, 182, 157, 237, 191, 165, - 237, 190, 164, 238, 191, 165, 235, 185, 160, 231, 181, 156, 231, 181, 156, - 228, 178, 153, 231, 181, 158, 241, 191, 168, 239, 187, 163, 242, 190, 166, - 238, 186, 162, 235, 183, 159, 241, 186, 165, 240, 185, 164, 236, 181, 160, - 235, 180, 159, 239, 187, 166, 239, 187, 166, 238, 187, 166, 239, 188, 167, - 237, 189, 167, 237, 191, 168, 237, 190, 170, 236, 191, 170, 234, 189, 168, - 232, 187, 166, 231, 186, 165, 230, 185, 164, 230, 185, 162, 229, 184, 161, - 229, 184, 161, 228, 183, 160, 227, 183, 158, 226, 182, 157, 225, 181, 156, - 224, 180, 155, 225, 181, 156, 225, 181, 156, 224, 180, 153, 223, 177, 151, - 223, 173, 148, 222, 170, 146, 220, 170, 145, 218, 168, 143, 214, 167, 141, - 211, 164, 138, 194, 148, 124, 171, 126, 103, 138, 96, 74, 129, 91, 70, - 106, 69, 50, 100, 67, 48, 98, 67, 49, 43, 16, 0, 42, 16, 1, - 42, 18, 6, 32, 13, 6, 25, 7, 3, 17, 2, 0, 17, 2, 0, - 19, 5, 2, 21, 7, 4, 17, 6, 4, 14, 4, 2, 25, 15, 14, - 18, 13, 10, 46, 40, 40, 42, 38, 37, 19, 17, 18, 16, 14, 15, - 9, 9, 11, 10, 10, 12, 9, 9, 9, 8, 8, 8, 8, 6, 7, - 8, 6, 7, 8, 6, 7, 8, 6, 7, 7, 5, 6, 7, 5, 6, - 7, 5, 6, 7, 5, 6, 9, 5, 6, 9, 5, 6, 9, 5, 6, - 9, 5, 6, 9, 5, 6, 8, 4, 5, 148, 151, 156, 145, 148, 153, - 165, 169, 172, 213, 214, 216, 139, 139, 139, 178, 174, 171, 112, 107, 104, - 53, 45, 42, 31, 22, 17, 28, 17, 13, 32, 19, 13, 34, 21, 15, - 28, 15, 9, 38, 25, 17, 57, 44, 38, 52, 37, 30, 60, 43, 36, - 43, 24, 18, 19, 0, 0, 33, 14, 8, 31, 12, 6, 26, 7, 0, - 30, 10, 3, 47, 27, 18, 68, 44, 34, 83, 57, 44, 87, 58, 44, - 95, 63, 48, 122, 89, 70, 135, 100, 80, 137, 101, 79, 158, 120, 97, - 178, 142, 116, 206, 169, 143, 229, 189, 164, 227, 187, 161, 227, 185, 160, - 235, 191, 166, 237, 191, 165, 243, 196, 170, 240, 190, 165, 241, 191, 166, - 241, 189, 165, 244, 192, 170, 248, 198, 175, 244, 194, 171, 240, 190, 167, - 243, 193, 170, 241, 191, 168, 243, 193, 170, 241, 189, 167, 239, 187, 165, - 242, 190, 168, 243, 188, 167, 241, 186, 165, 244, 189, 168, 237, 185, 163, - 238, 186, 164, 237, 187, 164, 236, 188, 165, 236, 188, 166, 235, 189, 166, - 234, 189, 166, 234, 189, 166, 234, 189, 166, 233, 188, 165, 232, 187, 166, - 231, 186, 163, 231, 186, 163, 230, 185, 162, 229, 184, 161, 228, 183, 160, - 225, 181, 156, 225, 181, 156, 226, 180, 156, 224, 180, 155, 223, 177, 153, - 222, 178, 153, 224, 178, 152, 226, 179, 153, 222, 170, 146, 221, 169, 145, - 220, 170, 145, 218, 171, 145, 217, 170, 144, 215, 169, 145, 201, 155, 131, - 179, 133, 110, 163, 118, 95, 148, 106, 84, 121, 80, 60, 108, 71, 53, - 113, 81, 66, 45, 17, 3, 41, 18, 4, 36, 17, 3, 27, 8, 1, - 23, 6, 0, 21, 6, 1, 22, 9, 3, 17, 6, 2, 13, 3, 1, - 16, 5, 3, 23, 9, 8, 21, 7, 6, 17, 3, 2, 47, 37, 36, - 40, 36, 33, 15, 15, 15, 14, 16, 15, 11, 10, 15, 10, 10, 12, - 8, 8, 8, 7, 7, 7, 7, 5, 6, 7, 5, 6, 7, 5, 6, - 8, 6, 7, 9, 5, 6, 7, 5, 6, 8, 6, 7, 8, 6, 7, - 8, 6, 7, 10, 6, 7, 9, 5, 6, 8, 4, 5, 8, 4, 5, - 7, 3, 4, 151, 156, 162, 154, 159, 163, 157, 161, 164, 194, 195, 197, - 146, 146, 146, 156, 152, 149, 160, 155, 152, 62, 52, 50, 20, 9, 5, - 35, 22, 16, 38, 25, 19, 32, 19, 13, 34, 21, 15, 44, 31, 25, - 48, 34, 31, 46, 32, 29, 46, 32, 29, 23, 9, 6, 22, 7, 4, - 23, 8, 3, 28, 9, 3, 24, 4, 0, 30, 8, 0, 66, 43, 29, - 98, 70, 56, 101, 72, 54, 118, 85, 66, 145, 110, 88, 164, 128, 104, - 167, 130, 104, 179, 139, 114, 200, 160, 134, 216, 175, 147, 227, 186, 158, - 237, 193, 166, 235, 191, 164, 233, 187, 161, 235, 188, 162, 237, 189, 166, - 239, 189, 166, 240, 190, 167, 241, 191, 168, 244, 194, 171, 246, 195, 174, - 245, 197, 175, 244, 196, 174, 243, 195, 173, 242, 194, 174, 240, 192, 172, - 239, 191, 171, 240, 189, 168, 239, 188, 167, 238, 188, 165, 238, 186, 164, - 237, 185, 161, 236, 184, 160, 236, 184, 160, 238, 186, 162, 239, 189, 164, - 236, 189, 163, 234, 186, 163, 231, 185, 161, 232, 188, 163, 233, 189, 164, - 230, 188, 163, 230, 188, 163, 231, 186, 163, 229, 184, 161, 228, 183, 160, - 227, 182, 159, 227, 181, 158, 227, 181, 158, 227, 181, 158, 226, 180, 157, - 226, 178, 155, 225, 179, 155, 226, 179, 153, 225, 179, 153, 225, 178, 152, - 227, 177, 152, 226, 172, 146, 223, 169, 145, 217, 167, 142, 213, 165, 142, - 214, 168, 144, 213, 167, 144, 206, 160, 137, 199, 151, 129, 186, 135, 114, - 159, 111, 91, 144, 97, 79, 122, 80, 64, 114, 81, 66, 67, 41, 28, - 27, 9, 0, 35, 18, 8, 28, 10, 0, 28, 9, 2, 26, 11, 4, - 18, 7, 3, 13, 8, 4, 13, 9, 6, 11, 1, 0, 23, 5, 5, - 28, 2, 3, 26, 0, 1, 51, 33, 31, 46, 38, 35, 19, 24, 20, - 12, 18, 18, 2, 5, 10, 7, 8, 13, 5, 7, 6, 2, 4, 3, - 3, 3, 3, 8, 6, 9, 12, 7, 11, 11, 6, 10, 9, 3, 7, - 8, 4, 5, 6, 4, 5, 6, 5, 3, 5, 4, 2, 5, 4, 2, - 7, 3, 4, 8, 4, 5, 10, 4, 8, 11, 5, 9, 147, 154, 160, - 150, 158, 161, 155, 158, 163, 189, 190, 192, 155, 155, 155, 109, 105, 102, - 176, 171, 168, 75, 66, 61, 10, 0, 0, 34, 21, 15, 41, 28, 22, - 41, 28, 22, 46, 32, 29, 39, 25, 22, 34, 20, 17, 47, 33, 30, - 46, 35, 33, 22, 11, 9, 20, 6, 3, 23, 8, 3, 31, 12, 6, - 30, 10, 1, 37, 13, 1, 74, 48, 33, 99, 70, 52, 121, 89, 68, - 144, 108, 86, 162, 125, 99, 175, 135, 110, 182, 142, 116, 197, 156, 128, - 216, 175, 147, 230, 186, 159, 235, 191, 164, 239, 193, 167, 235, 189, 163, - 235, 188, 162, 239, 192, 166, 243, 193, 170, 242, 192, 169, 240, 190, 167, - 242, 192, 169, 244, 193, 172, 244, 196, 174, 244, 197, 177, 244, 197, 177, - 244, 197, 177, 243, 196, 176, 242, 193, 176, 240, 191, 174, 237, 189, 169, - 235, 187, 165, 235, 184, 163, 235, 185, 162, 237, 185, 161, 238, 186, 162, - 236, 185, 158, 238, 187, 160, 238, 188, 161, 237, 187, 160, 232, 185, 159, - 231, 185, 159, 232, 186, 160, 233, 189, 162, 230, 186, 159, 230, 186, 159, - 230, 186, 161, 229, 185, 160, 229, 183, 159, 228, 182, 159, 228, 182, 159, - 228, 180, 158, 228, 180, 158, 226, 178, 155, 224, 176, 153, 225, 178, 152, - 227, 180, 154, 228, 181, 155, 227, 180, 154, 227, 177, 150, 230, 174, 149, - 227, 171, 146, 219, 169, 144, 215, 167, 144, 215, 169, 146, 215, 169, 146, - 212, 164, 142, 209, 159, 136, 202, 147, 127, 185, 130, 110, 164, 113, 94, - 135, 89, 73, 122, 86, 72, 81, 53, 41, 15, 0, 0, 32, 18, 7, - 35, 17, 7, 24, 6, 0, 29, 12, 5, 17, 6, 2, 10, 6, 3, - 15, 11, 10, 13, 3, 2, 29, 9, 10, 36, 4, 5, 34, 0, 0, - 64, 36, 33, 54, 36, 32, 17, 14, 9, 0, 0, 0, 16, 14, 17, - 5, 3, 8, 3, 5, 4, 6, 8, 5, 7, 7, 9, 5, 3, 6, - 6, 0, 6, 8, 1, 8, 10, 4, 8, 10, 6, 7, 6, 4, 5, - 5, 4, 2, 4, 5, 0, 4, 5, 0, 5, 3, 4, 8, 4, 5, - 10, 3, 10, 11, 4, 11, 152, 159, 165, 156, 164, 167, 157, 160, 165, - 180, 181, 183, 174, 174, 174, 87, 83, 80, 136, 131, 128, 51, 42, 37, - 15, 4, 0, 37, 24, 18, 38, 25, 19, 39, 26, 20, 46, 32, 29, - 31, 17, 14, 28, 14, 11, 57, 43, 40, 40, 29, 27, 19, 8, 6, - 15, 1, 0, 18, 3, 0, 31, 12, 5, 34, 14, 3, 42, 18, 6, - 82, 54, 40, 109, 78, 60, 131, 99, 78, 147, 111, 89, 152, 115, 89, - 166, 126, 101, 188, 148, 122, 214, 173, 145, 234, 193, 165, 237, 193, 166, - 239, 195, 170, 238, 194, 169, 235, 191, 166, 238, 192, 168, 241, 195, 171, - 242, 194, 172, 239, 191, 169, 242, 194, 172, 243, 195, 173, 243, 195, 173, - 244, 196, 174, 244, 197, 177, 244, 197, 177, 242, 197, 176, 243, 196, 176, - 243, 194, 177, 241, 192, 175, 239, 191, 171, 236, 188, 166, 237, 186, 165, - 236, 186, 163, 238, 186, 162, 238, 186, 162, 236, 185, 158, 236, 185, 158, - 236, 186, 159, 234, 184, 157, 230, 183, 157, 230, 183, 157, 232, 185, 159, - 233, 187, 161, 230, 184, 158, 230, 185, 156, 231, 185, 159, 231, 185, 159, - 232, 185, 159, 231, 183, 160, 230, 182, 159, 231, 181, 158, 232, 182, 159, - 230, 180, 157, 229, 179, 156, 229, 179, 154, 231, 181, 156, 233, 183, 156, - 232, 182, 155, 231, 180, 153, 231, 175, 150, 229, 173, 148, 220, 168, 144, - 213, 166, 140, 210, 164, 140, 211, 165, 141, 212, 162, 139, 210, 158, 134, - 209, 152, 132, 201, 144, 124, 182, 127, 107, 148, 99, 82, 131, 92, 75, - 96, 64, 49, 17, 0, 0, 36, 18, 6, 31, 14, 4, 21, 4, 0, - 38, 19, 15, 35, 17, 17, 20, 10, 9, 22, 14, 12, 20, 9, 7, - 33, 14, 10, 24, 0, 0, 68, 28, 26, 153, 114, 109, 179, 146, 139, - 126, 103, 97, 50, 33, 26, 19, 1, 0, 17, 5, 5, 1, 0, 0, - 0, 2, 0, 3, 3, 5, 6, 4, 7, 9, 2, 9, 7, 0, 7, - 6, 1, 5, 8, 4, 5, 5, 3, 4, 5, 4, 2, 4, 5, 0, - 4, 5, 0, 6, 4, 5, 7, 5, 6, 10, 5, 11, 11, 6, 12, - 156, 163, 169, 166, 174, 177, 167, 170, 175, 173, 174, 176, 184, 184, 184, - 122, 118, 117, 69, 64, 61, 29, 20, 15, 30, 19, 15, 37, 24, 18, - 31, 18, 12, 31, 18, 12, 37, 23, 20, 30, 16, 13, 33, 19, 16, - 57, 43, 40, 30, 19, 17, 16, 2, 1, 14, 0, 0, 17, 0, 0, - 32, 12, 5, 38, 16, 5, 47, 20, 9, 87, 59, 45, 116, 85, 67, - 139, 104, 84, 155, 117, 96, 164, 126, 103, 187, 147, 122, 210, 170, 144, - 225, 183, 158, 230, 188, 163, 235, 193, 168, 238, 193, 170, 239, 194, 171, - 239, 194, 171, 241, 195, 172, 242, 196, 173, 241, 193, 171, 236, 188, 166, - 247, 199, 177, 246, 198, 176, 245, 197, 175, 243, 197, 174, 242, 195, 175, - 241, 194, 174, 240, 195, 174, 239, 194, 173, 240, 193, 175, 241, 193, 173, - 241, 193, 173, 241, 193, 171, 241, 191, 168, 239, 189, 166, 237, 185, 161, - 236, 184, 160, 235, 184, 157, 235, 184, 157, 233, 183, 156, 232, 182, 155, - 230, 180, 155, 229, 182, 156, 233, 183, 158, 232, 185, 159, 233, 183, 156, - 232, 185, 157, 235, 185, 158, 234, 187, 159, 235, 185, 160, 234, 184, 159, - 233, 183, 160, 232, 182, 159, 233, 183, 160, 233, 183, 160, 233, 183, 158, - 231, 181, 156, 231, 181, 154, 232, 182, 155, 232, 182, 155, 232, 181, 154, - 232, 176, 149, 231, 175, 150, 223, 171, 147, 216, 166, 141, 211, 163, 140, - 211, 163, 140, 213, 161, 137, 214, 160, 136, 208, 150, 128, 206, 148, 126, - 192, 135, 115, 159, 108, 87, 135, 92, 73, 94, 59, 40, 25, 0, 0, - 33, 14, 0, 25, 8, 0, 25, 8, 1, 44, 20, 18, 41, 19, 21, - 20, 4, 5, 16, 4, 4, 21, 10, 6, 24, 5, 0, 53, 18, 12, - 157, 112, 106, 207, 157, 150, 213, 164, 157, 204, 164, 156, 157, 120, 112, - 39, 6, 1, 22, 0, 0, 16, 8, 5, 0, 0, 0, 1, 0, 0, - 10, 5, 9, 12, 7, 13, 5, 0, 6, 3, 0, 2, 6, 4, 5, - 5, 3, 4, 5, 4, 2, 4, 5, 0, 5, 5, 3, 7, 5, 6, - 8, 6, 7, 11, 6, 12, 12, 7, 13, 157, 164, 170, 166, 174, 177, - 179, 182, 187, 175, 176, 178, 184, 184, 184, 173, 169, 168, 59, 54, 51, - 38, 29, 24, 39, 28, 24, 30, 17, 11, 28, 15, 9, 33, 20, 14, - 35, 22, 16, 37, 24, 18, 39, 25, 22, 37, 23, 20, 24, 10, 9, - 17, 3, 2, 17, 2, 0, 19, 2, 0, 33, 13, 6, 40, 16, 6, - 49, 21, 9, 92, 63, 47, 123, 90, 73, 143, 108, 88, 161, 123, 102, - 179, 138, 116, 204, 162, 138, 223, 181, 156, 232, 188, 163, 230, 188, 163, - 235, 193, 171, 238, 196, 174, 240, 198, 176, 240, 198, 176, 243, 198, 177, - 242, 197, 176, 242, 195, 175, 239, 192, 172, 246, 199, 179, 246, 199, 179, - 244, 197, 177, 243, 196, 176, 241, 194, 174, 239, 194, 173, 238, 193, 172, - 238, 193, 172, 239, 192, 172, 239, 192, 172, 240, 192, 172, 240, 192, 170, - 241, 191, 168, 238, 188, 165, 237, 185, 161, 235, 183, 159, 234, 183, 156, - 234, 183, 156, 233, 182, 155, 231, 180, 153, 231, 179, 155, 230, 180, 155, - 233, 181, 157, 233, 183, 156, 235, 184, 155, 235, 186, 156, 236, 185, 156, - 236, 187, 157, 236, 185, 158, 235, 184, 157, 233, 181, 157, 232, 180, 156, - 229, 179, 154, 233, 183, 158, 234, 184, 159, 232, 182, 157, 229, 179, 154, - 230, 180, 155, 231, 181, 154, 231, 180, 153, 227, 173, 147, 227, 173, 147, - 221, 169, 145, 215, 165, 140, 209, 161, 138, 209, 161, 138, 211, 159, 135, - 212, 158, 132, 211, 153, 129, 208, 150, 126, 201, 143, 119, 173, 118, 97, - 140, 93, 73, 86, 45, 27, 45, 12, 0, 35, 9, 0, 34, 16, 4, - 40, 23, 16, 46, 18, 17, 45, 16, 20, 24, 2, 5, 17, 1, 1, - 27, 16, 10, 15, 0, 0, 118, 81, 73, 206, 153, 145, 219, 156, 147, - 177, 110, 101, 146, 86, 76, 199, 142, 133, 153, 100, 92, 30, 0, 0, - 28, 13, 8, 10, 9, 5, 7, 3, 4, 6, 2, 3, 5, 0, 4, - 1, 0, 2, 3, 1, 4, 8, 6, 7, 5, 3, 4, 5, 5, 3, - 5, 5, 3, 6, 6, 4, 7, 7, 7, 9, 9, 9, 11, 9, 14, - 11, 9, 14, 165, 172, 178, 161, 168, 174, 178, 181, 186, 186, 187, 191, - 192, 192, 194, 200, 196, 195, 85, 80, 77, 27, 18, 13, 44, 33, 29, - 29, 16, 10, 28, 15, 9, 34, 21, 15, 32, 19, 13, 39, 26, 20, - 39, 25, 22, 22, 8, 5, 18, 4, 3, 18, 3, 0, 21, 3, 0, - 20, 1, 0, 36, 13, 7, 41, 17, 7, 49, 19, 8, 95, 63, 48, - 120, 84, 68, 143, 106, 87, 168, 127, 107, 184, 143, 121, 204, 162, 138, - 221, 179, 155, 233, 188, 165, 238, 196, 172, 239, 198, 178, 241, 200, 180, - 244, 201, 184, 243, 200, 181, 243, 200, 181, 245, 200, 179, 246, 201, 182, - 247, 202, 181, 244, 197, 177, 244, 197, 177, 243, 196, 176, 242, 195, 175, - 240, 195, 174, 239, 194, 173, 239, 194, 173, 238, 193, 172, 240, 193, 173, - 238, 191, 171, 237, 189, 167, 235, 187, 165, 236, 186, 163, 236, 186, 163, - 237, 185, 161, 238, 186, 162, 235, 184, 157, 234, 183, 156, 233, 182, 155, - 232, 181, 154, 232, 180, 156, 232, 180, 156, 233, 181, 157, 234, 183, 156, - 235, 184, 155, 235, 184, 153, 236, 185, 156, 236, 185, 156, 235, 184, 157, - 233, 183, 158, 233, 181, 157, 231, 181, 158, 228, 178, 155, 232, 184, 161, - 236, 186, 163, 231, 183, 160, 231, 181, 158, 230, 183, 157, 231, 181, 156, - 229, 179, 154, 227, 175, 151, 226, 174, 150, 221, 171, 146, 213, 165, 142, - 210, 162, 139, 208, 160, 137, 209, 157, 133, 209, 155, 129, 211, 153, 129, - 211, 151, 125, 206, 148, 124, 186, 130, 107, 152, 101, 80, 93, 48, 27, - 70, 32, 13, 51, 22, 4, 35, 16, 2, 39, 20, 13, 41, 11, 11, - 44, 14, 16, 32, 10, 12, 26, 10, 10, 29, 16, 10, 15, 0, 0, - 119, 79, 71, 216, 159, 148, 208, 138, 128, 164, 87, 77, 150, 78, 66, - 179, 109, 99, 209, 140, 133, 108, 58, 51, 15, 0, 0, 13, 8, 4, - 14, 10, 9, 5, 1, 2, 1, 0, 2, 5, 3, 6, 8, 6, 9, - 4, 4, 6, 5, 5, 5, 6, 6, 4, 7, 7, 5, 8, 8, 6, - 9, 9, 9, 10, 10, 10, 11, 10, 15, 11, 10, 15, 170, 177, 185, - 163, 170, 176, 174, 177, 182, 191, 192, 196, 196, 196, 198, 194, 190, 189, - 90, 85, 82, 11, 2, 0, 45, 34, 30, 36, 23, 17, 32, 19, 13, - 34, 21, 15, 33, 20, 14, 32, 19, 13, 28, 15, 9, 18, 5, 0, - 16, 1, 0, 17, 2, 0, 20, 2, 0, 20, 0, 0, 40, 15, 8, - 48, 21, 10, 56, 24, 11, 100, 67, 50, 125, 88, 70, 162, 124, 105, - 198, 157, 137, 215, 173, 151, 227, 182, 161, 233, 188, 165, 235, 190, 167, - 235, 193, 171, 241, 200, 182, 241, 203, 184, 244, 202, 186, 246, 205, 187, - 246, 205, 187, 246, 203, 184, 246, 203, 186, 247, 204, 185, 242, 197, 178, - 242, 197, 178, 242, 197, 176, 242, 197, 176, 241, 196, 175, 240, 195, 174, - 239, 194, 171, 238, 193, 170, 240, 194, 171, 238, 192, 169, 235, 189, 166, - 233, 187, 164, 233, 185, 162, 234, 186, 163, 237, 187, 162, 238, 188, 163, - 236, 184, 160, 235, 183, 159, 237, 183, 159, 236, 182, 158, 237, 183, 159, - 237, 183, 159, 237, 183, 159, 236, 182, 156, 236, 185, 156, 236, 185, 156, - 235, 185, 158, 235, 185, 158, 235, 185, 160, 233, 186, 160, 235, 185, 162, - 233, 185, 163, 230, 182, 160, 232, 186, 163, 234, 186, 164, 230, 184, 161, - 230, 182, 160, 230, 184, 161, 226, 178, 156, 219, 171, 148, 218, 170, 147, - 217, 169, 146, 213, 165, 142, 208, 162, 139, 208, 162, 139, 210, 162, 140, - 213, 161, 139, 213, 159, 135, 208, 150, 126, 209, 151, 127, 207, 149, 125, - 194, 138, 115, 167, 115, 93, 117, 70, 50, 85, 42, 23, 81, 46, 27, - 47, 21, 8, 38, 15, 7, 46, 16, 14, 39, 9, 9, 28, 7, 6, - 24, 9, 6, 17, 4, 0, 27, 5, 0, 121, 78, 69, 178, 118, 108, - 187, 113, 104, 188, 108, 97, 188, 110, 98, 178, 100, 90, 217, 138, 131, - 173, 112, 107, 22, 0, 0, 13, 5, 2, 12, 7, 4, 7, 3, 2, - 5, 3, 4, 7, 7, 9, 7, 7, 9, 3, 3, 5, 7, 7, 7, - 7, 7, 7, 8, 8, 6, 9, 9, 7, 10, 10, 10, 11, 11, 11, - 11, 10, 15, 11, 12, 16, 164, 171, 179, 170, 177, 183, 175, 178, 185, - 189, 190, 194, 188, 188, 190, 177, 173, 172, 77, 72, 69, 23, 14, 9, - 37, 26, 22, 40, 27, 21, 38, 25, 19, 40, 27, 21, 41, 28, 22, - 27, 14, 8, 14, 1, 0, 15, 2, 0, 16, 1, 0, 20, 2, 0, - 21, 2, 0, 21, 1, 0, 45, 20, 13, 57, 29, 18, 64, 32, 19, - 110, 74, 58, 158, 119, 102, 195, 154, 134, 222, 180, 158, 225, 183, 161, - 230, 185, 164, 235, 190, 169, 237, 192, 171, 234, 192, 170, 239, 198, 180, - 239, 200, 183, 245, 203, 187, 249, 207, 191, 250, 208, 192, 247, 206, 188, - 244, 201, 184, 242, 199, 182, 242, 199, 180, 242, 199, 180, 243, 198, 177, - 242, 197, 176, 241, 196, 175, 239, 194, 173, 238, 193, 170, 237, 192, 169, - 238, 192, 169, 238, 192, 169, 237, 191, 168, 237, 191, 168, 237, 189, 166, - 236, 188, 165, 238, 188, 165, 238, 188, 163, 237, 185, 163, 237, 185, 161, - 238, 184, 160, 238, 184, 160, 239, 185, 161, 239, 185, 161, 238, 184, 160, - 237, 183, 159, 237, 186, 159, 236, 186, 159, 236, 186, 161, 235, 188, 162, - 235, 187, 164, 235, 189, 165, 235, 189, 166, 235, 188, 168, 229, 184, 165, - 230, 185, 166, 228, 183, 164, 225, 180, 161, 225, 180, 161, 225, 180, 161, - 217, 172, 151, 207, 160, 140, 186, 140, 117, 186, 140, 117, 185, 138, 118, - 185, 140, 119, 192, 145, 127, 200, 153, 133, 206, 155, 134, 207, 155, 133, - 207, 151, 128, 211, 155, 132, 207, 151, 128, 197, 143, 119, 176, 124, 102, - 137, 89, 69, 86, 41, 22, 98, 59, 42, 87, 55, 40, 64, 36, 25, - 72, 41, 36, 44, 16, 12, 22, 4, 0, 23, 10, 4, 18, 3, 0, - 63, 39, 29, 111, 67, 58, 170, 110, 100, 198, 125, 116, 198, 120, 110, - 201, 124, 114, 202, 124, 114, 203, 118, 115, 199, 131, 128, 62, 31, 28, - 24, 13, 9, 7, 0, 0, 8, 3, 0, 9, 7, 8, 5, 5, 7, - 3, 4, 6, 9, 10, 12, 8, 8, 8, 8, 8, 8, 9, 9, 7, - 10, 10, 8, 11, 11, 11, 11, 11, 13, 11, 12, 16, 11, 12, 16, - 172, 179, 187, 161, 168, 174, 182, 185, 192, 185, 186, 190, 184, 184, 186, - 148, 144, 143, 80, 75, 72, 25, 16, 11, 37, 26, 22, 43, 30, 24, - 44, 31, 23, 42, 29, 21, 37, 24, 16, 26, 13, 5, 20, 7, 1, - 23, 10, 4, 19, 4, 1, 24, 6, 2, 21, 2, 0, 45, 22, 14, - 54, 27, 18, 67, 37, 26, 78, 45, 30, 150, 115, 96, 198, 160, 141, - 213, 172, 152, 224, 182, 160, 227, 185, 163, 230, 185, 164, 234, 189, 168, - 236, 194, 172, 236, 193, 174, 239, 197, 181, 240, 201, 186, 244, 205, 190, - 246, 207, 190, 246, 207, 190, 244, 205, 188, 244, 203, 185, 243, 202, 184, - 239, 198, 178, 238, 197, 177, 239, 197, 175, 238, 196, 174, 240, 195, 174, - 239, 194, 173, 239, 194, 171, 238, 193, 170, 239, 193, 170, 237, 191, 168, - 236, 190, 167, 236, 190, 167, 238, 192, 169, 239, 193, 170, 240, 192, 170, - 239, 191, 168, 239, 188, 167, 240, 190, 167, 240, 188, 166, 238, 186, 164, - 238, 183, 162, 237, 182, 161, 239, 184, 163, 239, 187, 165, 234, 184, 161, - 238, 190, 167, 241, 193, 171, 234, 188, 165, 237, 192, 171, 238, 193, 172, - 227, 184, 165, 234, 191, 172, 233, 192, 174, 225, 184, 166, 225, 182, 165, - 225, 182, 165, 219, 176, 159, 214, 171, 154, 196, 153, 136, 170, 124, 108, - 171, 126, 107, 164, 119, 98, 154, 109, 90, 145, 102, 83, 149, 103, 87, - 164, 118, 102, 190, 141, 124, 212, 161, 142, 210, 158, 137, 203, 148, 127, - 205, 150, 129, 203, 151, 129, 194, 143, 122, 182, 134, 114, 150, 103, 85, - 101, 58, 41, 87, 50, 32, 82, 49, 34, 84, 54, 43, 60, 36, 26, - 33, 19, 10, 28, 18, 9, 14, 0, 0, 63, 36, 29, 94, 47, 41, - 170, 110, 102, 216, 149, 140, 205, 135, 125, 169, 99, 91, 226, 151, 145, - 209, 123, 124, 211, 139, 140, 117, 82, 78, 14, 0, 0, 21, 10, 8, - 9, 4, 1, 5, 3, 4, 6, 6, 6, 6, 7, 9, 10, 11, 13, - 10, 10, 10, 11, 11, 11, 12, 11, 9, 12, 11, 9, 12, 12, 12, - 12, 12, 14, 11, 12, 16, 10, 14, 17, 162, 169, 177, 178, 185, 193, - 170, 173, 180, 185, 186, 190, 188, 188, 190, 125, 121, 120, 73, 68, 65, - 54, 45, 40, 34, 23, 19, 37, 24, 18, 41, 28, 20, 48, 35, 27, - 47, 34, 26, 36, 23, 15, 32, 19, 13, 38, 25, 19, 35, 17, 15, - 34, 16, 12, 33, 12, 7, 37, 14, 6, 64, 37, 28, 71, 41, 30, - 105, 72, 57, 167, 130, 112, 204, 166, 147, 217, 176, 156, 228, 186, 164, - 230, 188, 166, 232, 187, 166, 232, 190, 168, 234, 191, 172, 233, 192, 174, - 234, 195, 178, 239, 200, 185, 244, 205, 190, 245, 206, 191, 244, 205, 188, - 242, 203, 186, 243, 202, 184, 243, 202, 184, 239, 198, 178, 239, 198, 178, - 239, 197, 175, 238, 196, 174, 240, 195, 174, 239, 194, 173, 238, 193, 170, - 238, 193, 170, 239, 193, 170, 238, 192, 169, 236, 190, 167, 236, 190, 167, - 237, 191, 168, 238, 192, 169, 239, 191, 169, 238, 190, 168, 236, 188, 168, - 238, 187, 166, 238, 187, 166, 238, 186, 164, 237, 185, 163, 239, 184, 163, - 240, 185, 164, 239, 187, 166, 245, 197, 175, 233, 186, 166, 229, 182, 162, - 236, 191, 172, 240, 197, 178, 232, 191, 173, 224, 182, 166, 227, 188, 171, - 222, 183, 166, 215, 176, 159, 216, 177, 162, 215, 173, 157, 196, 154, 140, - 179, 137, 121, 173, 130, 114, 168, 125, 109, 154, 111, 94, 141, 98, 79, - 138, 95, 78, 145, 102, 85, 140, 97, 81, 132, 86, 71, 144, 97, 81, - 168, 119, 102, 186, 135, 116, 194, 143, 122, 208, 158, 135, 207, 157, 134, - 201, 150, 129, 207, 159, 139, 203, 154, 137, 177, 130, 112, 142, 99, 80, - 88, 50, 31, 65, 33, 18, 63, 40, 26, 30, 18, 6, 35, 25, 15, - 33, 16, 8, 27, 0, 0, 110, 61, 56, 170, 109, 104, 219, 156, 147, - 235, 171, 162, 174, 110, 101, 151, 80, 76, 174, 89, 92, 220, 145, 149, - 148, 108, 106, 17, 0, 0, 35, 21, 18, 12, 4, 2, 11, 10, 8, - 8, 10, 9, 6, 7, 9, 7, 11, 12, 11, 11, 11, 11, 11, 11, - 12, 11, 9, 12, 10, 11, 13, 11, 14, 12, 12, 14, 11, 12, 16, - 10, 14, 17, 159, 166, 176, 171, 178, 186, 177, 180, 187, 184, 185, 190, - 195, 195, 197, 148, 144, 143, 57, 52, 49, 43, 34, 29, 40, 29, 25, - 38, 25, 19, 36, 23, 15, 37, 24, 16, 36, 23, 15, 33, 20, 12, - 33, 20, 12, 37, 24, 16, 37, 19, 15, 38, 21, 14, 33, 13, 6, - 29, 7, 0, 59, 32, 21, 67, 38, 24, 120, 84, 68, 175, 138, 120, - 209, 171, 152, 222, 181, 161, 232, 190, 168, 233, 191, 169, 233, 190, 171, - 234, 191, 172, 234, 191, 174, 232, 191, 173, 232, 193, 176, 237, 198, 183, - 242, 203, 186, 243, 204, 187, 240, 201, 184, 238, 199, 182, 239, 201, 182, - 241, 203, 184, 239, 198, 178, 239, 198, 178, 239, 196, 177, 238, 195, 176, - 239, 194, 173, 238, 193, 172, 239, 192, 172, 239, 192, 172, 239, 193, 170, - 238, 192, 169, 236, 190, 167, 236, 190, 167, 236, 189, 169, 237, 190, 170, - 237, 190, 170, 236, 189, 169, 235, 188, 170, 236, 188, 168, 236, 188, 168, - 238, 187, 166, 238, 187, 166, 239, 187, 166, 239, 187, 166, 238, 187, 166, - 232, 185, 167, 236, 191, 172, 237, 192, 173, 235, 192, 175, 229, 187, 171, - 225, 186, 169, 229, 190, 175, 222, 185, 169, 209, 172, 156, 184, 147, 131, - 160, 122, 109, 143, 104, 89, 131, 89, 77, 130, 88, 74, 140, 96, 83, - 147, 104, 88, 144, 103, 85, 128, 87, 69, 128, 85, 69, 148, 105, 89, - 160, 114, 101, 156, 110, 95, 167, 119, 105, 188, 141, 125, 197, 149, 129, - 186, 138, 116, 191, 143, 120, 203, 155, 132, 203, 155, 133, 205, 157, 137, - 207, 158, 141, 202, 154, 134, 181, 133, 111, 141, 99, 77, 92, 57, 38, - 80, 54, 37, 33, 20, 4, 29, 17, 5, 25, 6, 0, 77, 44, 39, - 160, 109, 106, 174, 113, 110, 205, 145, 137, 232, 172, 164, 205, 146, 138, - 160, 92, 89, 177, 97, 100, 221, 149, 152, 174, 133, 131, 15, 0, 0, - 36, 21, 16, 10, 0, 0, 14, 10, 9, 10, 12, 11, 8, 9, 11, - 8, 12, 13, 11, 11, 11, 11, 11, 11, 12, 10, 11, 13, 11, 12, - 13, 11, 14, 12, 12, 14, 12, 13, 17, 10, 14, 17, 160, 167, 177, - 166, 173, 181, 187, 190, 199, 188, 189, 194, 199, 199, 201, 195, 191, 190, - 98, 93, 90, 55, 46, 41, 32, 21, 17, 31, 18, 12, 30, 17, 9, - 32, 19, 11, 35, 22, 14, 39, 26, 18, 36, 23, 15, 27, 14, 6, - 28, 13, 8, 38, 21, 14, 23, 4, 0, 32, 10, 0, 46, 19, 8, - 57, 28, 14, 116, 80, 64, 175, 138, 119, 213, 172, 152, 223, 182, 162, - 232, 190, 168, 235, 193, 171, 234, 191, 172, 233, 192, 172, 234, 193, 175, - 233, 191, 175, 232, 193, 176, 235, 196, 179, 237, 198, 181, 238, 199, 182, - 237, 198, 181, 237, 198, 181, 239, 201, 182, 241, 203, 184, 239, 198, 178, - 238, 197, 177, 238, 195, 176, 237, 194, 175, 238, 193, 172, 238, 193, 172, - 238, 191, 171, 238, 191, 171, 238, 192, 169, 237, 191, 168, 237, 191, 168, - 236, 190, 167, 236, 189, 169, 237, 190, 170, 237, 190, 172, 236, 191, 172, - 238, 191, 173, 238, 191, 173, 238, 191, 173, 239, 191, 171, 239, 191, 171, - 240, 189, 168, 240, 189, 168, 239, 188, 169, 232, 185, 167, 234, 188, 172, - 231, 188, 171, 233, 191, 175, 229, 187, 173, 223, 184, 169, 207, 169, 156, - 172, 134, 121, 136, 98, 85, 119, 81, 68, 96, 58, 45, 85, 45, 33, - 99, 57, 45, 124, 80, 67, 137, 93, 80, 136, 93, 77, 135, 92, 75, - 148, 105, 88, 170, 124, 108, 186, 140, 125, 191, 143, 131, 191, 143, 129, - 198, 150, 136, 209, 162, 146, 215, 168, 148, 192, 146, 123, 187, 139, 116, - 202, 154, 131, 209, 161, 139, 208, 160, 138, 207, 156, 137, 203, 152, 133, - 197, 147, 122, 177, 131, 107, 114, 76, 55, 89, 60, 42, 53, 36, 20, - 31, 15, 2, 17, 0, 0, 115, 80, 74, 191, 137, 135, 196, 135, 132, - 225, 162, 155, 228, 168, 160, 231, 171, 163, 202, 137, 133, 187, 108, 111, - 221, 149, 152, 194, 150, 147, 21, 0, 0, 25, 7, 3, 13, 2, 0, - 11, 7, 6, 10, 12, 11, 11, 12, 14, 8, 9, 11, 11, 11, 11, - 12, 10, 11, 14, 10, 11, 15, 11, 12, 13, 11, 14, 12, 12, 14, - 12, 13, 17, 10, 14, 17, 153, 160, 170, 180, 187, 195, 183, 186, 195, - 195, 196, 201, 202, 201, 206, 204, 200, 201, 164, 159, 156, 122, 113, 108, - 61, 50, 46, 42, 29, 23, 29, 16, 8, 30, 17, 9, 32, 19, 11, - 37, 24, 16, 38, 25, 17, 33, 20, 12, 27, 12, 5, 35, 18, 11, - 24, 5, 0, 35, 13, 2, 43, 17, 4, 52, 23, 7, 117, 82, 63, - 185, 148, 129, 215, 174, 154, 222, 181, 159, 231, 189, 167, 234, 192, 170, - 233, 192, 172, 232, 191, 173, 233, 191, 175, 231, 192, 175, 234, 195, 178, - 233, 195, 176, 233, 195, 176, 233, 195, 176, 235, 197, 178, 237, 199, 180, - 238, 200, 181, 239, 201, 182, 239, 198, 178, 238, 197, 177, 238, 195, 176, - 238, 193, 174, 239, 192, 172, 238, 191, 171, 239, 191, 171, 240, 192, 172, - 237, 190, 170, 237, 190, 170, 237, 190, 170, 237, 190, 170, 237, 192, 173, - 237, 192, 173, 238, 192, 176, 237, 194, 177, 241, 195, 179, 241, 195, 179, - 241, 195, 179, 241, 194, 176, 239, 192, 174, 239, 191, 171, 238, 190, 170, - 237, 189, 169, 237, 190, 172, 229, 183, 167, 230, 187, 171, 231, 189, 173, - 208, 166, 152, 170, 131, 116, 138, 101, 85, 111, 74, 58, 84, 47, 31, - 90, 53, 37, 93, 54, 39, 101, 59, 45, 123, 79, 66, 152, 106, 91, - 167, 121, 106, 171, 125, 109, 177, 132, 113, 180, 133, 115, 181, 132, 117, - 181, 132, 117, 189, 137, 124, 199, 147, 134, 207, 155, 141, 207, 158, 141, - 216, 168, 148, 214, 166, 144, 209, 161, 138, 201, 154, 128, 203, 153, 130, - 212, 161, 140, 213, 160, 142, 204, 152, 131, 202, 152, 125, 179, 132, 104, - 138, 96, 74, 110, 75, 56, 82, 56, 43, 33, 11, 0, 20, 0, 0, - 81, 44, 36, 168, 115, 111, 214, 149, 145, 240, 173, 165, 237, 168, 161, - 242, 178, 169, 229, 160, 153, 197, 119, 117, 218, 148, 148, 212, 167, 162, - 52, 23, 17, 17, 0, 0, 26, 15, 11, 10, 6, 3, 8, 10, 9, - 12, 13, 15, 5, 6, 8, 11, 11, 13, 12, 10, 13, 16, 10, 12, - 16, 10, 12, 15, 10, 14, 13, 13, 15, 12, 13, 17, 10, 13, 18, - 148, 155, 165, 178, 185, 193, 188, 191, 200, 200, 201, 206, 210, 209, 214, - 199, 195, 196, 158, 153, 150, 130, 121, 116, 88, 77, 73, 50, 37, 31, - 30, 17, 9, 35, 22, 14, 32, 19, 11, 26, 13, 5, 29, 16, 8, - 33, 20, 12, 29, 14, 7, 26, 9, 1, 27, 8, 1, 29, 7, 0, - 46, 20, 7, 54, 25, 9, 127, 92, 73, 195, 159, 137, 214, 176, 155, - 222, 181, 159, 229, 187, 165, 231, 190, 168, 231, 190, 172, 231, 190, 172, - 229, 190, 173, 230, 191, 174, 235, 197, 178, 233, 195, 176, 231, 193, 174, - 232, 194, 175, 235, 197, 178, 237, 199, 180, 238, 200, 181, 237, 199, 180, - 239, 198, 178, 238, 197, 177, 240, 195, 176, 239, 194, 175, 239, 192, 172, - 239, 192, 172, 241, 193, 173, 241, 193, 173, 239, 191, 171, 239, 192, 172, - 239, 192, 172, 239, 192, 172, 238, 193, 174, 237, 194, 175, 239, 196, 179, - 240, 197, 180, 241, 198, 181, 242, 199, 182, 243, 197, 181, 240, 194, 178, - 237, 190, 174, 234, 187, 169, 233, 186, 168, 233, 186, 168, 229, 182, 166, - 224, 178, 162, 222, 176, 161, 191, 148, 132, 145, 103, 89, 109, 70, 55, - 90, 51, 36, 90, 53, 37, 97, 60, 44, 114, 75, 60, 136, 94, 80, - 159, 116, 100, 180, 134, 119, 190, 143, 127, 196, 149, 133, 206, 157, 140, - 197, 149, 129, 190, 142, 122, 190, 139, 122, 197, 144, 130, 207, 151, 138, - 206, 153, 139, 201, 148, 132, 196, 145, 126, 226, 175, 154, 225, 177, 154, - 218, 171, 145, 204, 157, 131, 200, 150, 125, 203, 151, 129, 206, 151, 131, - 204, 149, 128, 202, 153, 123, 194, 147, 119, 166, 118, 96, 121, 78, 61, - 105, 71, 59, 33, 5, 0, 38, 9, 1, 44, 7, 0, 144, 89, 84, - 227, 160, 154, 236, 163, 156, 231, 157, 148, 234, 161, 152, 238, 165, 156, - 230, 151, 146, 219, 150, 145, 218, 171, 165, 81, 50, 45, 17, 0, 0, - 36, 22, 19, 10, 6, 3, 8, 10, 7, 13, 14, 16, 7, 8, 10, - 11, 11, 13, 14, 9, 13, 18, 9, 12, 16, 10, 12, 15, 10, 14, - 13, 13, 15, 12, 13, 18, 10, 13, 18, 144, 151, 161, 167, 174, 182, - 198, 201, 210, 203, 204, 209, 216, 215, 220, 212, 208, 209, 145, 140, 137, - 67, 58, 53, 59, 48, 44, 34, 21, 15, 32, 19, 11, 45, 32, 24, - 41, 28, 20, 32, 19, 11, 30, 17, 9, 25, 12, 4, 30, 15, 8, - 22, 5, 0, 24, 5, 0, 28, 6, 0, 48, 22, 9, 73, 44, 28, - 133, 100, 81, 198, 162, 140, 214, 176, 155, 221, 180, 158, 226, 185, 163, - 230, 189, 167, 231, 190, 172, 230, 192, 173, 231, 192, 175, 233, 194, 177, - 235, 194, 176, 235, 194, 174, 234, 196, 175, 235, 197, 176, 236, 198, 177, - 237, 199, 178, 236, 198, 177, 236, 198, 177, 240, 199, 179, 239, 198, 178, - 241, 196, 177, 240, 195, 176, 240, 193, 173, 242, 194, 174, 245, 194, 175, - 243, 195, 175, 241, 193, 173, 242, 194, 174, 242, 195, 177, 241, 194, 176, - 240, 194, 178, 238, 195, 178, 240, 197, 181, 241, 199, 183, 241, 199, 183, - 242, 200, 184, 242, 199, 183, 236, 193, 176, 230, 184, 168, 225, 180, 161, - 225, 180, 161, 228, 181, 163, 221, 174, 158, 196, 150, 134, 175, 129, 113, - 129, 86, 69, 107, 65, 49, 105, 66, 49, 92, 53, 36, 105, 66, 49, - 125, 86, 69, 153, 111, 95, 183, 140, 124, 209, 163, 147, 225, 178, 162, - 220, 171, 154, 210, 159, 142, 208, 157, 138, 208, 156, 134, 208, 156, 134, - 211, 156, 136, 208, 152, 135, 201, 143, 129, 199, 141, 127, 211, 155, 140, - 226, 173, 155, 227, 177, 154, 223, 173, 148, 215, 168, 140, 215, 165, 138, - 213, 162, 135, 206, 152, 128, 206, 149, 129, 213, 159, 135, 205, 156, 126, - 204, 154, 127, 174, 119, 99, 122, 70, 56, 111, 68, 59, 60, 26, 16, - 32, 2, 0, 51, 14, 5, 145, 90, 83, 210, 141, 134, 227, 148, 141, - 225, 143, 132, 213, 133, 122, 223, 145, 133, 239, 161, 151, 226, 158, 149, - 214, 165, 158, 99, 66, 59, 18, 0, 0, 36, 21, 16, 12, 7, 4, - 10, 12, 9, 10, 11, 13, 12, 13, 15, 12, 10, 13, 15, 10, 14, - 18, 9, 12, 18, 9, 12, 17, 11, 15, 14, 12, 15, 12, 13, 18, - 10, 13, 18, 138, 145, 155, 174, 181, 189, 195, 200, 206, 205, 208, 213, - 213, 212, 217, 225, 223, 224, 189, 185, 184, 27, 19, 16, 56, 47, 42, - 40, 29, 23, 34, 23, 17, 32, 19, 11, 25, 12, 4, 32, 19, 11, - 40, 25, 18, 30, 15, 8, 32, 17, 10, 25, 10, 3, 21, 2, 0, - 36, 16, 5, 47, 24, 10, 99, 70, 54, 137, 104, 85, 199, 163, 141, - 215, 174, 154, 219, 177, 155, 225, 183, 161, 230, 188, 166, 232, 191, 171, - 234, 193, 175, 234, 195, 178, 237, 199, 180, 233, 192, 174, 235, 194, 174, - 237, 199, 178, 238, 200, 179, 238, 200, 179, 236, 198, 177, 235, 197, 176, - 237, 196, 176, 240, 199, 179, 241, 198, 179, 241, 196, 177, 241, 196, 177, - 242, 195, 177, 243, 194, 177, 244, 195, 178, 245, 196, 179, 242, 195, 175, - 243, 196, 176, 244, 197, 179, 242, 197, 178, 239, 196, 179, 239, 196, 179, - 239, 197, 181, 241, 199, 183, 240, 198, 184, 242, 199, 183, 241, 198, 182, - 235, 189, 173, 227, 180, 164, 221, 174, 156, 221, 174, 156, 224, 177, 159, - 199, 153, 137, 161, 115, 99, 145, 100, 81, 115, 70, 51, 108, 62, 46, - 111, 68, 51, 104, 61, 44, 144, 101, 84, 172, 129, 112, 203, 160, 143, - 220, 174, 158, 216, 170, 154, 215, 168, 152, 211, 162, 147, 203, 154, 139, - 204, 153, 136, 197, 145, 124, 192, 140, 119, 192, 137, 117, 199, 143, 126, - 213, 155, 141, 224, 167, 150, 226, 170, 153, 224, 172, 151, 216, 164, 142, - 225, 175, 150, 226, 176, 149, 217, 168, 138, 209, 158, 131, 205, 151, 127, - 204, 148, 125, 206, 152, 128, 200, 150, 123, 196, 149, 121, 194, 139, 119, - 151, 98, 82, 100, 54, 41, 86, 46, 36, 28, 0, 0, 97, 57, 47, - 153, 99, 89, 144, 77, 68, 183, 104, 97, 212, 130, 119, 215, 133, 121, - 220, 141, 128, 231, 151, 140, 232, 162, 152, 216, 163, 155, 111, 74, 66, - 22, 0, 0, 30, 19, 17, 13, 9, 8, 11, 11, 11, 6, 8, 7, - 13, 15, 14, 11, 11, 13, 13, 11, 14, 18, 9, 12, 18, 9, 12, - 16, 12, 13, 14, 12, 15, 13, 12, 17, 13, 14, 18, 136, 143, 151, - 171, 178, 184, 188, 193, 199, 211, 214, 219, 219, 223, 226, 222, 223, 225, - 214, 214, 214, 161, 157, 156, 14, 9, 6, 43, 35, 32, 36, 27, 22, - 31, 20, 14, 41, 28, 20, 36, 21, 14, 31, 14, 6, 39, 22, 15, - 32, 19, 11, 24, 11, 3, 32, 18, 9, 30, 12, 0, 51, 29, 15, - 103, 76, 59, 148, 115, 96, 193, 157, 135, 213, 170, 151, 220, 175, 154, - 229, 182, 162, 232, 185, 165, 231, 186, 167, 234, 191, 172, 237, 196, 178, - 231, 193, 174, 234, 196, 177, 235, 197, 178, 236, 198, 179, 237, 199, 180, - 240, 199, 181, 240, 199, 181, 242, 201, 183, 244, 201, 184, 239, 196, 179, - 248, 205, 188, 248, 202, 186, 244, 198, 182, 247, 201, 185, 244, 198, 182, - 240, 194, 178, 247, 201, 185, 249, 204, 185, 244, 199, 178, 243, 198, 179, - 245, 202, 183, 245, 202, 185, 241, 198, 181, 240, 197, 181, 243, 200, 184, - 237, 194, 178, 238, 192, 177, 239, 191, 177, 235, 186, 171, 228, 176, 162, - 224, 173, 156, 217, 164, 148, 201, 153, 133, 167, 124, 105, 142, 101, 81, - 142, 97, 76, 126, 79, 59, 122, 74, 52, 144, 93, 72, 157, 106, 85, - 180, 129, 108, 207, 159, 139, 217, 170, 150, 212, 166, 150, 195, 149, 134, - 192, 146, 133, 184, 137, 127, 181, 134, 126, 183, 135, 125, 175, 126, 112, - 175, 126, 109, 174, 125, 108, 178, 127, 110, 189, 136, 120, 204, 151, 133, - 216, 164, 143, 221, 169, 147, 221, 169, 145, 217, 165, 141, 219, 168, 141, - 227, 176, 149, 229, 175, 151, 220, 166, 142, 208, 154, 130, 201, 149, 125, - 198, 148, 123, 199, 151, 128, 191, 140, 119, 161, 113, 93, 106, 59, 43, - 92, 46, 31, 36, 0, 0, 115, 67, 55, 141, 84, 73, 123, 60, 51, - 183, 113, 105, 207, 133, 124, 204, 126, 116, 216, 136, 125, 234, 152, 141, - 233, 156, 146, 220, 160, 149, 118, 78, 70, 13, 0, 0, 30, 25, 29, - 7, 5, 10, 10, 9, 14, 8, 8, 6, 9, 11, 8, 11, 15, 14, - 12, 14, 13, 16, 11, 15, 16, 10, 12, 13, 12, 10, 13, 12, 10, - 14, 12, 15, 15, 13, 16, 126, 133, 139, 166, 173, 179, 198, 203, 207, - 214, 219, 223, 212, 216, 219, 216, 220, 221, 225, 226, 228, 199, 199, 199, - 101, 100, 98, 9, 5, 2, 6, 0, 0, 47, 38, 33, 33, 20, 14, - 24, 9, 2, 44, 27, 20, 46, 29, 22, 30, 17, 11, 19, 9, 0, - 31, 17, 8, 31, 15, 2, 62, 40, 26, 97, 71, 54, 145, 112, 93, - 180, 144, 122, 210, 165, 146, 217, 170, 150, 226, 178, 158, 231, 183, 163, - 233, 186, 168, 235, 192, 173, 237, 196, 178, 230, 192, 173, 232, 191, 173, - 234, 193, 175, 237, 196, 178, 241, 200, 182, 243, 202, 184, 244, 203, 185, - 243, 202, 184, 243, 202, 184, 243, 200, 183, 246, 203, 186, 242, 199, 182, - 241, 198, 181, 245, 202, 186, 242, 199, 183, 241, 198, 182, 250, 207, 190, - 242, 199, 180, 241, 199, 177, 242, 199, 180, 244, 201, 182, 241, 198, 181, - 235, 192, 175, 233, 190, 173, 235, 192, 175, 237, 191, 176, 236, 189, 173, - 237, 188, 173, 232, 183, 166, 225, 172, 156, 216, 163, 145, 203, 147, 130, - 182, 131, 112, 154, 109, 90, 143, 101, 79, 145, 100, 77, 142, 94, 72, - 152, 102, 79, 166, 114, 92, 178, 123, 102, 201, 149, 127, 190, 139, 118, - 180, 133, 113, 178, 132, 116, 208, 165, 149, 199, 155, 144, 196, 153, 144, - 191, 148, 141, 190, 146, 137, 196, 150, 137, 187, 139, 125, 179, 132, 116, - 184, 135, 118, 196, 145, 128, 205, 154, 133, 211, 159, 138, 215, 163, 141, - 208, 154, 130, 218, 164, 140, 234, 180, 154, 243, 189, 163, 239, 185, 161, - 224, 170, 146, 207, 155, 131, 200, 148, 124, 200, 150, 127, 198, 150, 127, - 190, 144, 121, 173, 127, 104, 123, 76, 58, 87, 40, 22, 73, 24, 10, - 134, 82, 69, 169, 112, 101, 147, 87, 77, 172, 108, 98, 193, 123, 113, - 207, 133, 124, 212, 134, 124, 220, 138, 127, 246, 169, 159, 224, 160, 148, - 116, 72, 63, 11, 0, 0, 26, 25, 31, 9, 6, 15, 13, 11, 16, - 10, 10, 8, 10, 12, 7, 7, 13, 9, 8, 12, 11, 13, 11, 14, - 15, 11, 12, 14, 13, 11, 13, 13, 11, 14, 12, 13, 16, 11, 15, - 132, 137, 143, 158, 163, 169, 194, 199, 203, 210, 215, 219, 212, 216, 219, - 221, 225, 226, 229, 230, 232, 220, 220, 220, 185, 184, 182, 155, 151, 148, - 95, 87, 84, 38, 29, 24, 42, 31, 27, 58, 45, 39, 46, 31, 26, - 34, 19, 14, 24, 11, 5, 27, 17, 8, 41, 27, 18, 42, 26, 13, - 74, 52, 38, 98, 72, 55, 151, 118, 99, 173, 137, 115, 204, 159, 140, - 213, 166, 146, 223, 175, 155, 228, 180, 160, 232, 185, 167, 235, 192, 173, - 236, 195, 177, 232, 191, 173, 232, 189, 170, 235, 190, 171, 235, 192, 173, - 239, 196, 177, 243, 200, 183, 244, 203, 185, 243, 201, 185, 240, 201, 184, - 241, 199, 183, 241, 202, 185, 241, 202, 185, 244, 205, 188, 247, 206, 188, - 239, 198, 180, 234, 193, 175, 239, 198, 178, 234, 192, 170, 239, 194, 171, - 243, 198, 177, 243, 198, 177, 239, 194, 175, 235, 190, 171, 234, 189, 170, - 235, 190, 171, 236, 189, 173, 233, 186, 168, 233, 184, 167, 229, 181, 161, - 224, 171, 153, 216, 164, 143, 202, 147, 127, 180, 128, 107, 158, 110, 90, - 158, 111, 91, 159, 111, 89, 155, 104, 83, 158, 106, 85, 173, 118, 98, - 167, 115, 94, 148, 97, 78, 165, 117, 97, 198, 153, 134, 214, 171, 154, - 178, 139, 122, 156, 116, 104, 132, 92, 82, 105, 65, 55, 111, 68, 59, - 106, 60, 47, 83, 35, 21, 76, 27, 12, 105, 56, 39, 153, 102, 85, - 185, 134, 113, 197, 145, 124, 199, 147, 125, 217, 163, 139, 229, 175, 151, - 241, 187, 163, 245, 191, 167, 239, 185, 161, 226, 172, 148, 211, 157, 133, - 199, 147, 123, 198, 148, 125, 196, 148, 125, 190, 142, 120, 185, 137, 115, - 143, 96, 78, 89, 42, 24, 79, 30, 16, 164, 112, 99, 176, 122, 110, - 188, 130, 119, 200, 138, 127, 198, 130, 119, 200, 127, 118, 217, 140, 130, - 223, 143, 132, 243, 166, 156, 224, 160, 148, 111, 67, 58, 11, 0, 0, - 24, 22, 27, 11, 6, 13, 12, 10, 13, 9, 10, 5, 9, 12, 5, - 7, 12, 8, 7, 11, 10, 13, 11, 14, 15, 11, 12, 13, 13, 11, - 12, 12, 10, 13, 11, 12, 12, 10, 13, 135, 140, 146, 147, 152, 158, - 186, 191, 195, 209, 214, 218, 218, 222, 225, 228, 232, 235, 227, 228, 230, - 223, 225, 224, 215, 215, 215, 221, 220, 218, 245, 240, 237, 202, 194, 191, - 81, 71, 69, 12, 1, 0, 35, 21, 18, 24, 10, 7, 18, 7, 1, - 42, 32, 23, 53, 39, 30, 59, 43, 30, 80, 58, 44, 101, 75, 58, - 153, 122, 102, 167, 131, 109, 198, 153, 134, 213, 166, 146, 225, 174, 155, - 225, 177, 157, 230, 183, 165, 232, 189, 170, 233, 192, 172, 234, 193, 173, - 239, 192, 174, 237, 190, 172, 235, 188, 170, 236, 191, 172, 238, 195, 178, - 241, 199, 183, 240, 201, 184, 238, 201, 185, 238, 201, 185, 242, 205, 189, - 244, 207, 189, 244, 207, 189, 242, 205, 186, 237, 199, 180, 232, 194, 175, - 233, 192, 172, 231, 186, 165, 233, 188, 165, 236, 189, 169, 235, 190, 169, - 233, 188, 167, 234, 189, 170, 235, 190, 171, 237, 192, 173, 236, 189, 171, - 233, 186, 166, 231, 183, 163, 228, 177, 156, 223, 171, 150, 218, 166, 145, - 210, 155, 135, 195, 140, 120, 176, 124, 103, 181, 129, 108, 162, 110, 89, - 158, 103, 83, 159, 104, 84, 139, 83, 66, 146, 93, 75, 182, 133, 116, - 189, 143, 127, 172, 131, 113, 139, 100, 83, 91, 54, 38, 42, 5, 0, - 82, 44, 31, 53, 13, 1, 78, 36, 24, 137, 91, 76, 130, 83, 67, - 133, 84, 69, 152, 103, 86, 178, 127, 108, 198, 147, 128, 214, 162, 141, - 223, 171, 149, 234, 179, 158, 237, 183, 159, 237, 183, 159, 236, 182, 158, - 235, 181, 157, 231, 177, 153, 215, 161, 137, 197, 145, 121, 193, 143, 120, - 198, 150, 127, 189, 141, 119, 190, 142, 120, 160, 113, 95, 108, 61, 43, - 56, 7, 0, 175, 123, 110, 204, 150, 138, 204, 146, 135, 219, 157, 146, - 234, 168, 156, 209, 139, 129, 206, 132, 121, 219, 143, 130, 242, 168, 155, - 226, 163, 148, 115, 68, 58, 13, 0, 0, 23, 21, 26, 12, 7, 14, - 14, 9, 13, 11, 10, 6, 9, 12, 5, 8, 13, 9, 8, 12, 11, - 14, 9, 13, 15, 11, 12, 12, 12, 10, 10, 12, 9, 12, 10, 13, - 11, 9, 12, 128, 133, 139, 138, 143, 149, 186, 191, 195, 212, 217, 221, - 219, 224, 227, 227, 232, 235, 227, 231, 232, 237, 239, 238, 236, 236, 236, - 236, 235, 233, 247, 246, 244, 232, 228, 225, 109, 104, 101, 8, 0, 0, - 41, 31, 29, 19, 9, 7, 18, 7, 3, 41, 31, 22, 44, 30, 21, - 75, 59, 46, 84, 65, 50, 101, 75, 58, 137, 106, 86, 153, 117, 95, - 192, 147, 128, 214, 167, 147, 227, 176, 155, 224, 176, 154, 226, 179, 159, - 229, 184, 163, 231, 189, 167, 238, 196, 174, 244, 196, 176, 243, 192, 173, - 239, 190, 173, 239, 192, 176, 239, 196, 180, 241, 199, 185, 239, 202, 186, - 237, 201, 187, 234, 201, 186, 237, 204, 189, 238, 205, 188, 234, 199, 180, - 230, 195, 175, 233, 196, 177, 234, 198, 176, 233, 192, 172, 234, 189, 168, - 233, 187, 164, 231, 183, 161, 228, 182, 159, 228, 182, 159, 230, 183, 163, - 233, 186, 166, 235, 188, 168, 239, 191, 171, 236, 188, 166, 234, 183, 162, - 227, 176, 155, 219, 167, 146, 215, 163, 141, 209, 154, 133, 197, 142, 121, - 189, 132, 112, 172, 115, 96, 162, 105, 86, 157, 100, 81, 139, 83, 66, - 143, 90, 74, 172, 120, 106, 178, 131, 115, 143, 100, 84, 63, 24, 7, - 83, 46, 30, 100, 64, 48, 51, 15, 0, 53, 16, 0, 108, 69, 54, - 150, 108, 94, 180, 132, 118, 188, 139, 124, 199, 147, 133, 205, 154, 137, - 212, 159, 141, 219, 166, 148, 226, 171, 151, 229, 174, 153, 232, 175, 155, - 234, 177, 157, 234, 177, 157, 234, 177, 157, 237, 182, 161, 236, 181, 160, - 220, 165, 144, 198, 146, 124, 191, 141, 118, 201, 151, 128, 190, 142, 120, - 191, 143, 121, 175, 126, 109, 128, 79, 62, 57, 8, 0, 136, 84, 70, - 208, 155, 141, 210, 154, 141, 218, 158, 147, 238, 174, 162, 216, 148, 137, - 201, 131, 119, 213, 141, 127, 233, 164, 149, 229, 166, 151, 129, 82, 72, - 15, 0, 0, 27, 22, 26, 15, 8, 15, 15, 11, 12, 12, 11, 6, - 11, 12, 4, 7, 12, 8, 7, 11, 10, 13, 8, 12, 13, 8, 12, - 11, 11, 11, 11, 13, 10, 14, 12, 15, 15, 13, 18, 126, 131, 137, - 133, 138, 144, 177, 182, 186, 208, 213, 217, 216, 221, 224, 224, 229, 232, - 228, 232, 235, 239, 243, 244, 234, 235, 237, 227, 227, 227, 233, 233, 233, - 244, 243, 241, 128, 124, 123, 3, 0, 0, 37, 31, 31, 21, 13, 11, - 15, 6, 1, 21, 11, 2, 21, 8, 0, 78, 62, 49, 90, 71, 56, - 97, 74, 56, 119, 88, 68, 143, 106, 87, 182, 139, 120, 212, 165, 145, - 225, 177, 155, 224, 173, 152, 225, 177, 157, 226, 181, 160, 229, 187, 165, - 241, 196, 173, 243, 195, 173, 245, 194, 173, 244, 196, 176, 245, 199, 183, - 244, 202, 186, 241, 203, 190, 238, 202, 188, 234, 200, 188, 239, 207, 194, - 235, 203, 190, 233, 200, 185, 227, 194, 177, 224, 189, 170, 227, 190, 171, - 228, 192, 170, 223, 182, 160, 231, 185, 162, 227, 179, 157, 224, 176, 154, - 226, 178, 156, 227, 179, 157, 226, 180, 157, 229, 181, 159, 233, 185, 163, - 237, 189, 167, 235, 187, 165, 236, 185, 164, 230, 180, 157, 221, 169, 147, - 215, 163, 139, 208, 154, 130, 196, 142, 118, 188, 131, 111, 171, 113, 93, - 161, 102, 84, 142, 85, 68, 137, 81, 66, 171, 119, 105, 174, 125, 111, - 120, 76, 63, 188, 146, 132, 195, 158, 142, 95, 59, 43, 72, 36, 20, - 87, 51, 35, 132, 95, 79, 165, 123, 107, 195, 152, 136, 205, 158, 142, - 206, 157, 142, 208, 157, 140, 210, 159, 142, 218, 165, 147, 226, 173, 155, - 227, 172, 152, 221, 166, 146, 230, 173, 154, 234, 177, 157, 236, 179, 159, - 234, 177, 157, 233, 178, 157, 231, 176, 155, 221, 166, 145, 209, 154, 133, - 192, 140, 118, 195, 145, 122, 190, 139, 118, 189, 141, 119, 182, 134, 114, - 136, 87, 70, 90, 41, 26, 85, 36, 21, 157, 105, 91, 202, 149, 135, - 215, 157, 145, 219, 160, 146, 211, 148, 133, 197, 129, 116, 208, 139, 124, - 229, 162, 146, 226, 164, 149, 146, 100, 87, 13, 0, 0, 26, 21, 25, - 14, 7, 14, 13, 7, 9, 12, 9, 4, 10, 11, 3, 6, 11, 7, - 8, 10, 9, 13, 8, 14, 15, 10, 14, 15, 15, 15, 17, 19, 18, - 20, 20, 22, 23, 21, 26, 127, 130, 135, 129, 132, 137, 162, 167, 171, - 199, 204, 208, 216, 221, 225, 223, 228, 231, 227, 232, 235, 231, 235, 236, - 233, 237, 238, 238, 239, 241, 246, 247, 249, 245, 245, 245, 129, 129, 129, - 1, 0, 0, 35, 31, 32, 15, 10, 7, 13, 6, 0, 11, 1, 0, - 15, 2, 0, 62, 48, 37, 78, 60, 46, 85, 62, 46, 107, 76, 58, - 134, 97, 78, 172, 129, 110, 206, 159, 139, 221, 173, 151, 221, 170, 149, - 225, 177, 155, 228, 182, 159, 229, 184, 161, 239, 194, 171, 244, 196, 174, - 245, 197, 175, 244, 199, 178, 243, 200, 183, 240, 201, 186, 235, 199, 185, - 231, 197, 185, 228, 196, 185, 226, 196, 185, 205, 173, 160, 191, 158, 143, - 190, 154, 138, 186, 149, 131, 188, 150, 131, 193, 152, 132, 190, 148, 126, - 196, 150, 127, 195, 147, 125, 202, 154, 132, 216, 168, 146, 223, 175, 153, - 223, 175, 153, 229, 178, 157, 237, 187, 164, 240, 190, 167, 238, 188, 165, - 238, 186, 164, 233, 181, 157, 226, 174, 150, 221, 169, 145, 215, 161, 137, - 201, 147, 121, 185, 129, 106, 184, 127, 107, 153, 96, 77, 140, 83, 66, - 172, 119, 105, 161, 112, 98, 130, 82, 72, 162, 120, 108, 211, 171, 159, - 202, 166, 152, 157, 121, 107, 156, 120, 104, 182, 143, 128, 189, 147, 131, - 216, 170, 154, 198, 151, 135, 201, 152, 135, 208, 157, 140, 214, 161, 145, - 214, 161, 145, 216, 160, 143, 219, 163, 146, 231, 174, 157, 241, 184, 165, - 237, 180, 161, 239, 182, 163, 237, 180, 161, 233, 176, 157, 229, 174, 154, - 227, 172, 152, 222, 167, 147, 216, 161, 141, 195, 143, 121, 189, 139, 116, - 188, 137, 116, 192, 141, 120, 181, 133, 113, 146, 98, 78, 114, 65, 48, - 95, 46, 29, 137, 85, 71, 183, 130, 116, 210, 154, 139, 223, 165, 151, - 212, 150, 135, 179, 116, 101, 208, 142, 128, 241, 175, 161, 222, 161, 143, - 163, 117, 104, 13, 0, 0, 26, 21, 25, 12, 5, 12, 12, 6, 8, - 12, 9, 4, 11, 11, 3, 12, 14, 11, 13, 15, 14, 19, 14, 20, - 23, 18, 22, 23, 25, 24, 26, 28, 27, 30, 29, 34, 32, 31, 37, - 118, 121, 126, 125, 128, 133, 157, 162, 166, 199, 204, 208, 217, 222, 226, - 223, 228, 232, 231, 236, 239, 232, 237, 240, 243, 247, 248, 217, 221, 222, - 233, 234, 236, 244, 245, 247, 133, 133, 135, 4, 4, 4, 32, 30, 31, - 12, 8, 7, 15, 7, 4, 16, 7, 0, 22, 12, 3, 43, 31, 19, - 57, 39, 27, 66, 45, 28, 95, 66, 50, 121, 86, 67, 164, 123, 103, - 199, 154, 133, 216, 168, 148, 219, 168, 147, 227, 179, 157, 229, 183, 160, - 229, 184, 161, 237, 192, 169, 244, 199, 176, 244, 199, 176, 241, 198, 179, - 235, 197, 178, 230, 194, 178, 226, 193, 178, 224, 192, 181, 221, 191, 180, - 187, 157, 146, 144, 112, 101, 113, 79, 67, 110, 74, 58, 112, 73, 56, - 120, 79, 61, 135, 92, 73, 145, 100, 79, 152, 105, 85, 157, 109, 87, - 176, 128, 106, 203, 155, 133, 219, 168, 147, 220, 169, 148, 227, 177, 154, - 240, 190, 167, 245, 195, 172, 240, 190, 167, 237, 185, 161, 232, 180, 156, - 227, 175, 151, 225, 173, 149, 219, 165, 139, 204, 150, 124, 190, 136, 112, - 159, 104, 83, 156, 101, 81, 168, 115, 99, 183, 131, 117, 160, 110, 99, - 131, 84, 74, 163, 120, 111, 182, 144, 133, 190, 152, 141, 203, 165, 152, - 208, 169, 154, 204, 161, 145, 206, 160, 144, 207, 156, 139, 209, 158, 141, - 211, 160, 143, 209, 158, 141, 215, 162, 146, 225, 172, 156, 232, 176, 159, - 229, 173, 156, 231, 174, 157, 237, 180, 163, 238, 181, 164, 237, 180, 161, - 236, 179, 160, 236, 179, 160, 236, 179, 160, 231, 176, 156, 223, 168, 148, - 216, 161, 141, 200, 148, 126, 190, 138, 116, 191, 139, 118, 197, 146, 125, - 181, 130, 111, 160, 112, 92, 115, 66, 49, 143, 94, 77, 153, 101, 87, - 192, 140, 126, 221, 168, 152, 218, 162, 147, 193, 134, 118, 188, 126, 111, - 235, 172, 157, 231, 168, 153, 220, 161, 143, 175, 131, 118, 13, 0, 0, - 30, 26, 27, 15, 8, 15, 15, 9, 11, 16, 13, 8, 16, 16, 8, - 17, 19, 16, 19, 20, 22, 27, 22, 28, 31, 26, 30, 31, 33, 32, - 32, 36, 35, 36, 37, 41, 38, 37, 43, 116, 119, 124, 125, 128, 133, - 150, 155, 159, 187, 192, 196, 214, 219, 223, 224, 229, 233, 226, 234, 236, - 231, 239, 241, 237, 242, 245, 230, 235, 238, 228, 232, 235, 236, 240, 241, - 183, 184, 186, 45, 46, 48, 2, 2, 4, 27, 25, 26, 14, 9, 6, - 7, 0, 0, 24, 15, 8, 30, 20, 10, 33, 16, 6, 59, 40, 25, - 82, 54, 40, 109, 76, 59, 154, 116, 97, 201, 158, 139, 218, 171, 151, - 218, 170, 150, 221, 173, 151, 233, 187, 164, 226, 181, 158, 231, 189, 165, - 235, 195, 170, 236, 198, 175, 228, 192, 170, 231, 196, 177, 220, 187, 170, - 200, 168, 153, 177, 147, 136, 143, 113, 102, 97, 65, 54, 98, 66, 55, - 99, 63, 51, 90, 52, 39, 95, 53, 39, 88, 42, 26, 102, 55, 37, - 124, 77, 57, 144, 96, 76, 155, 107, 87, 169, 121, 101, 186, 138, 118, - 209, 158, 137, 209, 158, 137, 231, 179, 157, 230, 178, 156, 240, 188, 166, - 245, 193, 171, 247, 193, 169, 242, 188, 164, 237, 183, 159, 232, 178, 154, - 220, 166, 142, 206, 152, 128, 183, 131, 107, 162, 110, 88, 155, 104, 83, - 183, 132, 115, 183, 134, 120, 142, 94, 82, 160, 116, 105, 185, 142, 133, - 203, 163, 155, 202, 162, 152, 203, 161, 149, 206, 162, 149, 208, 161, 145, - 208, 157, 140, 209, 152, 135, 209, 152, 135, 208, 155, 137, 215, 162, 144, - 225, 169, 152, 229, 173, 156, 234, 176, 162, 238, 180, 166, 241, 182, 168, - 242, 183, 169, 240, 181, 167, 239, 180, 164, 237, 178, 162, 234, 177, 160, - 230, 173, 156, 225, 168, 151, 218, 162, 145, 214, 159, 139, 202, 147, 126, - 191, 139, 117, 190, 138, 117, 187, 136, 115, 185, 134, 115, 163, 112, 93, - 115, 67, 47, 143, 95, 75, 177, 126, 109, 217, 166, 149, 208, 155, 139, - 200, 144, 129, 220, 163, 146, 223, 164, 148, 234, 175, 159, 208, 149, 133, - 227, 168, 150, 186, 142, 129, 16, 0, 0, 25, 23, 24, 12, 7, 13, - 24, 20, 21, 26, 23, 18, 24, 23, 18, 27, 29, 28, 30, 31, 33, - 36, 31, 37, 38, 33, 39, 35, 36, 38, 37, 41, 42, 45, 46, 50, - 50, 51, 56, 115, 118, 123, 121, 124, 129, 143, 148, 152, 178, 183, 187, - 207, 212, 216, 221, 226, 230, 225, 233, 235, 230, 238, 240, 233, 238, 241, - 235, 240, 243, 221, 225, 228, 228, 232, 235, 243, 244, 246, 180, 181, 183, - 87, 87, 89, 1, 0, 0, 19, 14, 11, 15, 7, 4, 6, 0, 0, - 10, 1, 0, 33, 19, 8, 56, 38, 24, 86, 60, 47, 91, 59, 44, - 142, 105, 87, 201, 158, 141, 219, 172, 154, 215, 167, 147, 221, 173, 151, - 227, 181, 158, 227, 182, 159, 236, 194, 170, 234, 196, 173, 215, 180, 158, - 206, 171, 151, 204, 171, 152, 176, 143, 126, 132, 100, 85, 115, 83, 70, - 112, 80, 69, 107, 75, 64, 104, 70, 58, 106, 68, 57, 112, 72, 60, - 127, 83, 70, 127, 81, 66, 135, 88, 72, 149, 100, 83, 157, 108, 91, - 160, 112, 92, 171, 122, 105, 183, 135, 115, 205, 154, 135, 208, 157, 136, - 225, 173, 152, 228, 176, 154, 242, 190, 168, 245, 193, 171, 247, 193, 169, - 242, 188, 164, 239, 185, 161, 234, 180, 156, 221, 167, 143, 204, 152, 128, - 189, 139, 114, 183, 135, 112, 177, 129, 107, 195, 146, 129, 200, 152, 138, - 185, 139, 126, 200, 156, 145, 206, 163, 154, 195, 152, 143, 192, 149, 140, - 192, 148, 137, 196, 148, 136, 200, 147, 133, 203, 146, 129, 207, 146, 128, - 209, 148, 130, 221, 164, 147, 224, 168, 151, 228, 172, 155, 230, 174, 157, - 234, 176, 162, 237, 179, 165, 240, 181, 167, 239, 180, 166, 239, 180, 166, - 238, 179, 165, 236, 177, 163, 234, 175, 159, 230, 173, 156, 225, 168, 151, - 217, 161, 144, 213, 157, 140, 204, 149, 129, 194, 139, 118, 188, 136, 115, - 185, 133, 112, 181, 130, 111, 161, 110, 91, 116, 65, 46, 138, 90, 70, - 203, 152, 135, 198, 147, 130, 167, 114, 98, 206, 150, 135, 236, 179, 162, - 241, 184, 167, 228, 169, 153, 218, 159, 143, 236, 179, 162, 179, 137, 123, - 16, 1, 0, 21, 19, 22, 31, 29, 34, 29, 24, 28, 24, 20, 17, - 32, 31, 26, 31, 33, 32, 34, 35, 39, 43, 38, 45, 47, 42, 48, - 47, 48, 50, 50, 54, 55, 58, 59, 63, 63, 64, 69, 115, 118, 125, - 118, 121, 128, 134, 139, 143, 166, 171, 175, 198, 203, 207, 217, 222, 226, - 223, 231, 233, 228, 236, 238, 232, 237, 240, 243, 248, 251, 228, 234, 234, - 223, 227, 228, 248, 249, 251, 243, 244, 246, 190, 191, 193, 104, 104, 104, - 39, 35, 34, 15, 10, 6, 19, 14, 8, 13, 6, 0, 23, 10, 1, - 48, 32, 19, 66, 44, 31, 92, 63, 49, 127, 91, 75, 196, 155, 137, - 220, 175, 156, 213, 166, 146, 219, 173, 150, 220, 174, 151, 229, 185, 160, - 231, 189, 165, 201, 165, 143, 189, 157, 136, 184, 152, 131, 161, 128, 109, - 126, 93, 76, 105, 72, 57, 105, 72, 57, 118, 84, 72, 125, 89, 77, - 130, 92, 81, 142, 102, 92, 160, 118, 106, 170, 126, 113, 173, 127, 114, - 172, 124, 110, 173, 125, 111, 177, 130, 114, 168, 121, 103, 171, 124, 108, - 170, 123, 105, 182, 134, 114, 197, 146, 125, 218, 166, 145, 236, 184, 163, - 245, 190, 169, 248, 193, 172, 247, 192, 171, 243, 188, 167, 241, 186, 165, - 237, 182, 161, 223, 168, 147, 205, 153, 131, 189, 141, 118, 197, 151, 128, - 195, 148, 128, 211, 164, 146, 215, 168, 152, 210, 162, 150, 206, 160, 147, - 191, 147, 136, 195, 151, 140, 197, 151, 138, 200, 152, 140, 205, 156, 142, - 215, 159, 144, 220, 161, 145, 228, 165, 148, 232, 169, 152, 229, 170, 152, - 229, 172, 153, 230, 173, 156, 231, 174, 157, 235, 176, 162, 239, 180, 166, - 242, 180, 167, 241, 179, 166, 240, 178, 167, 238, 176, 163, 234, 175, 161, - 232, 173, 159, 228, 170, 156, 223, 165, 151, 216, 158, 144, 212, 155, 138, - 205, 150, 130, 195, 140, 120, 187, 135, 114, 183, 131, 110, 180, 128, 107, - 162, 111, 90, 123, 72, 53, 145, 94, 75, 219, 166, 148, 202, 149, 131, - 179, 123, 106, 223, 167, 150, 245, 188, 171, 247, 190, 173, 228, 169, 153, - 233, 176, 159, 235, 179, 162, 178, 138, 126, 10, 0, 0, 24, 23, 28, - 42, 39, 46, 31, 29, 34, 30, 29, 25, 40, 41, 36, 41, 42, 44, - 45, 46, 50, 56, 51, 58, 62, 57, 63, 62, 63, 65, 65, 69, 70, - 72, 73, 78, 76, 76, 84, 117, 120, 127, 117, 120, 127, 128, 133, 137, - 156, 161, 165, 189, 194, 198, 212, 217, 221, 221, 229, 231, 224, 232, 234, - 233, 238, 241, 235, 241, 241, 229, 235, 235, 229, 233, 234, 240, 241, 243, - 249, 250, 252, 242, 243, 245, 206, 206, 206, 72, 71, 69, 3, 0, 0, - 23, 20, 15, 10, 5, 0, 25, 15, 6, 26, 12, 1, 61, 41, 30, - 70, 44, 29, 111, 75, 61, 176, 137, 120, 217, 171, 155, 214, 167, 149, - 216, 169, 149, 219, 174, 151, 234, 189, 166, 209, 169, 144, 168, 131, 112, - 163, 128, 109, 161, 126, 107, 134, 98, 82, 123, 87, 71, 146, 110, 94, - 159, 123, 107, 169, 133, 119, 165, 127, 114, 185, 145, 133, 195, 155, 143, - 196, 154, 142, 191, 147, 136, 189, 145, 134, 167, 123, 112, 140, 96, 83, - 130, 87, 71, 132, 86, 71, 152, 106, 91, 159, 112, 96, 168, 121, 103, - 184, 136, 116, 198, 147, 128, 220, 168, 147, 241, 186, 166, 247, 192, 171, - 248, 193, 173, 245, 190, 169, 242, 187, 167, 238, 183, 162, 226, 171, 151, - 210, 158, 137, 201, 153, 131, 199, 153, 130, 189, 142, 122, 208, 159, 142, - 212, 163, 148, 218, 169, 155, 217, 169, 155, 216, 168, 154, 217, 169, 155, - 218, 170, 156, 221, 172, 158, 226, 174, 160, 229, 173, 158, 230, 171, 155, - 232, 169, 152, 234, 171, 154, 229, 170, 152, 229, 172, 153, 230, 173, 156, - 231, 174, 157, 237, 178, 164, 242, 183, 169, 245, 183, 170, 243, 181, 168, - 241, 179, 168, 238, 176, 165, 232, 172, 161, 229, 170, 156, 225, 167, 153, - 220, 162, 148, 213, 155, 141, 208, 151, 134, 204, 148, 131, 197, 142, 122, - 188, 136, 115, 184, 132, 111, 180, 128, 107, 170, 118, 97, 142, 91, 72, - 163, 112, 93, 209, 156, 138, 221, 168, 150, 228, 172, 155, 234, 178, 161, - 243, 186, 169, 244, 187, 170, 241, 182, 166, 241, 184, 167, 226, 175, 158, - 173, 137, 125, 7, 0, 0, 38, 39, 44, 38, 37, 45, 38, 35, 42, - 49, 48, 46, 49, 50, 45, 56, 57, 59, 59, 60, 64, 69, 64, 71, - 74, 69, 75, 73, 74, 76, 73, 77, 78, 77, 78, 83, 78, 78, 86, - 116, 121, 127, 115, 120, 126, 123, 128, 134, 148, 153, 159, 180, 185, 189, - 207, 212, 216, 219, 227, 229, 223, 231, 233, 230, 236, 236, 233, 239, 239, - 232, 236, 237, 228, 232, 231, 231, 233, 232, 249, 251, 250, 249, 249, 249, - 220, 220, 218, 157, 157, 157, 1, 0, 0, 43, 42, 38, 5, 2, 0, - 16, 7, 0, 22, 9, 0, 49, 31, 21, 73, 50, 36, 97, 63, 51, - 151, 114, 98, 207, 164, 147, 215, 170, 151, 212, 167, 146, 221, 176, 153, - 228, 183, 160, 175, 134, 112, 140, 103, 85, 122, 85, 69, 123, 86, 70, - 126, 89, 73, 144, 105, 90, 174, 135, 120, 189, 150, 135, 202, 163, 148, - 215, 176, 161, 215, 175, 163, 211, 171, 159, 198, 158, 146, 176, 136, 124, - 150, 110, 100, 141, 101, 91, 146, 106, 96, 155, 115, 103, 151, 109, 95, - 158, 114, 101, 159, 113, 98, 166, 119, 103, 187, 138, 121, 197, 146, 129, - 216, 163, 145, 235, 179, 162, 244, 189, 169, 250, 193, 176, 247, 190, 171, - 243, 186, 169, 239, 182, 163, 230, 173, 156, 219, 163, 146, 207, 156, 137, - 200, 152, 132, 192, 141, 124, 207, 156, 139, 210, 157, 141, 218, 165, 151, - 221, 169, 155, 227, 175, 161, 215, 166, 151, 215, 166, 151, 217, 168, 153, - 222, 171, 154, 224, 168, 151, 223, 166, 149, 225, 164, 146, 227, 166, 148, - 232, 173, 155, 233, 174, 156, 234, 175, 159, 236, 177, 161, 242, 180, 167, - 245, 183, 170, 244, 182, 171, 241, 179, 168, 241, 178, 169, 237, 175, 164, - 230, 170, 159, 226, 166, 155, 223, 163, 152, 218, 158, 147, 210, 152, 138, - 205, 148, 131, 201, 145, 128, 199, 144, 124, 193, 138, 118, 188, 133, 113, - 181, 129, 108, 177, 125, 104, 162, 110, 89, 186, 134, 113, 205, 150, 130, - 229, 174, 154, 242, 185, 168, 235, 178, 161, 237, 180, 163, 244, 187, 170, - 248, 189, 173, 239, 183, 168, 226, 177, 162, 144, 110, 100, 18, 9, 10, - 47, 52, 58, 42, 42, 52, 52, 51, 59, 59, 59, 59, 59, 61, 58, - 64, 68, 71, 69, 70, 75, 76, 70, 80, 78, 73, 80, 75, 76, 80, - 72, 76, 79, 72, 73, 78, 71, 71, 79, 114, 119, 125, 113, 118, 124, - 119, 124, 130, 138, 143, 149, 169, 174, 178, 199, 204, 208, 215, 223, 225, - 222, 230, 232, 224, 230, 230, 234, 240, 240, 235, 239, 238, 227, 231, 230, - 222, 224, 223, 245, 247, 244, 251, 251, 249, 236, 236, 234, 165, 165, 165, - 3, 3, 3, 1, 0, 0, 23, 20, 15, 21, 14, 8, 35, 25, 16, - 28, 11, 1, 64, 40, 28, 89, 57, 44, 130, 93, 77, 193, 151, 135, - 213, 170, 153, 209, 164, 145, 218, 173, 152, 201, 159, 135, 142, 101, 81, - 113, 74, 59, 113, 73, 61, 131, 89, 77, 147, 105, 93, 162, 118, 105, - 182, 139, 123, 200, 157, 141, 214, 171, 155, 216, 174, 158, 209, 167, 153, - 192, 153, 138, 172, 134, 121, 179, 143, 131, 162, 128, 118, 151, 117, 107, - 145, 111, 101, 138, 100, 89, 140, 100, 88, 146, 104, 92, 161, 117, 104, - 182, 136, 121, 209, 162, 146, 210, 161, 146, 211, 160, 143, 229, 173, 158, - 240, 184, 167, 249, 192, 175, 247, 190, 173, 242, 185, 168, 239, 182, 165, - 232, 175, 158, 223, 167, 150, 206, 153, 135, 206, 155, 136, 205, 152, 136, - 209, 153, 138, 210, 152, 138, 213, 157, 142, 211, 155, 140, 206, 153, 137, - 209, 158, 141, 210, 159, 140, 213, 162, 145, 216, 165, 146, 220, 167, 149, - 224, 168, 151, 230, 173, 154, 236, 177, 159, 239, 180, 162, 241, 182, 164, - 242, 183, 167, 241, 182, 166, 243, 181, 168, 243, 181, 168, 241, 179, 168, - 237, 175, 164, 240, 177, 168, 236, 173, 164, 229, 169, 158, 226, 166, 155, - 223, 163, 152, 218, 158, 147, 209, 151, 137, 203, 145, 131, 199, 143, 126, - 200, 145, 125, 194, 139, 119, 190, 135, 115, 180, 128, 107, 180, 128, 107, - 175, 123, 102, 197, 145, 124, 213, 158, 138, 227, 172, 152, 228, 171, 154, - 239, 182, 165, 232, 175, 158, 232, 175, 158, 236, 177, 161, 235, 179, 164, - 215, 167, 153, 99, 69, 59, 48, 42, 44, 50, 57, 65, 57, 59, 71, - 67, 67, 75, 60, 60, 60, 67, 69, 66, 65, 69, 72, 66, 69, 74, - 74, 68, 78, 74, 69, 76, 70, 71, 75, 66, 70, 73, 65, 66, 71, - 63, 63, 71, 114, 119, 125, 113, 118, 124, 115, 120, 126, 128, 133, 139, - 154, 159, 163, 186, 191, 195, 209, 214, 217, 219, 224, 227, 219, 225, 225, - 225, 231, 231, 228, 232, 231, 233, 237, 236, 232, 234, 231, 251, 251, 249, - 253, 252, 250, 249, 249, 247, 242, 242, 242, 153, 155, 154, 13, 13, 11, - 13, 12, 8, 20, 15, 11, 21, 12, 5, 43, 26, 18, 39, 17, 6, - 73, 43, 32, 106, 70, 56, 171, 132, 117, 206, 165, 147, 209, 166, 147, - 211, 169, 147, 173, 131, 107, 136, 93, 74, 135, 93, 81, 155, 112, 103, - 174, 130, 121, 187, 140, 130, 192, 144, 132, 204, 156, 142, 217, 171, 156, - 214, 168, 152, 199, 156, 139, 182, 140, 124, 176, 137, 122, 158, 122, 108, - 140, 108, 95, 63, 33, 22, 57, 29, 18, 100, 70, 60, 170, 133, 124, - 169, 129, 119, 148, 108, 96, 153, 111, 97, 171, 125, 112, 207, 159, 145, - 221, 172, 157, 219, 168, 151, 226, 170, 155, 237, 181, 166, 246, 188, 174, - 245, 187, 173, 242, 184, 170, 240, 182, 168, 233, 175, 161, 224, 166, 152, - 217, 161, 146, 213, 157, 142, 212, 154, 140, 205, 147, 133, 211, 152, 136, - 218, 159, 143, 224, 165, 149, 226, 169, 152, 226, 173, 155, 225, 174, 153, - 226, 175, 156, 227, 176, 155, 227, 176, 155, 228, 176, 155, 233, 178, 158, - 238, 183, 163, 243, 185, 165, 245, 187, 167, 248, 187, 169, 245, 183, 168, - 243, 181, 168, 241, 179, 166, 239, 175, 165, 237, 173, 163, 236, 173, 164, - 234, 171, 162, 231, 168, 159, 231, 168, 159, 227, 167, 156, 221, 161, 150, - 210, 152, 140, 202, 144, 130, 197, 141, 124, 200, 145, 125, 194, 139, 119, - 191, 136, 116, 183, 128, 108, 185, 130, 110, 183, 128, 108, 200, 145, 125, - 220, 165, 145, 229, 174, 154, 227, 170, 153, 237, 180, 163, 231, 172, 156, - 213, 154, 138, 226, 164, 149, 217, 161, 146, 161, 113, 99, 77, 48, 40, - 67, 62, 66, 52, 61, 70, 62, 66, 77, 65, 68, 77, 60, 61, 63, - 65, 67, 66, 61, 65, 68, 61, 64, 69, 67, 61, 71, 67, 62, 69, - 62, 63, 67, 59, 63, 66, 59, 60, 65, 57, 57, 65, 116, 119, 126, - 114, 119, 125, 115, 118, 125, 121, 126, 132, 144, 149, 153, 175, 180, 184, - 201, 206, 210, 213, 218, 221, 216, 221, 224, 228, 234, 234, 233, 237, 238, - 231, 235, 234, 223, 225, 224, 240, 240, 238, 247, 247, 245, 255, 255, 253, - 253, 255, 254, 249, 251, 250, 173, 173, 173, 0, 0, 0, 24, 25, 20, - 30, 27, 22, 43, 30, 24, 40, 20, 13, 51, 21, 11, 82, 48, 36, - 149, 112, 96, 196, 157, 140, 214, 171, 152, 212, 169, 150, 158, 120, 97, - 148, 110, 91, 182, 140, 126, 188, 144, 133, 188, 141, 131, 204, 156, 144, - 216, 167, 153, 218, 169, 154, 215, 168, 152, 189, 143, 127, 176, 134, 118, - 177, 138, 121, 134, 98, 82, 55, 22, 7, 82, 50, 37, 95, 65, 54, - 113, 83, 72, 111, 79, 68, 194, 156, 147, 197, 157, 147, 170, 128, 116, - 165, 123, 109, 173, 127, 114, 206, 158, 144, 228, 179, 164, 225, 173, 159, - 223, 170, 154, 235, 179, 164, 244, 186, 172, 244, 186, 172, 242, 184, 170, - 241, 183, 169, 233, 175, 161, 223, 165, 151, 220, 162, 148, 210, 152, 138, - 215, 157, 143, 215, 156, 142, 224, 165, 149, 219, 160, 144, 223, 164, 148, - 227, 170, 153, 228, 173, 153, 228, 176, 155, 231, 180, 159, 234, 183, 162, - 235, 183, 162, 233, 181, 160, 237, 182, 162, 240, 185, 165, 240, 183, 164, - 244, 185, 167, 245, 186, 170, 244, 182, 167, 241, 179, 166, 240, 178, 165, - 240, 176, 166, 238, 174, 164, 233, 170, 161, 232, 169, 160, 232, 169, 160, - 234, 171, 162, 231, 171, 160, 224, 164, 153, 212, 154, 142, 202, 144, 132, - 196, 140, 123, 199, 144, 124, 193, 138, 118, 192, 137, 117, 184, 129, 109, - 188, 133, 112, 186, 131, 110, 199, 144, 123, 218, 163, 143, 227, 175, 154, - 230, 177, 161, 219, 166, 150, 229, 176, 162, 199, 145, 133, 221, 167, 155, - 186, 138, 128, 92, 55, 47, 73, 52, 49, 68, 66, 71, 58, 65, 73, - 55, 57, 69, 59, 59, 67, 65, 66, 68, 58, 60, 59, 57, 61, 64, - 59, 60, 65, 60, 57, 64, 60, 57, 64, 57, 58, 62, 56, 57, 61, - 55, 56, 61, 53, 54, 59, 113, 113, 121, 117, 120, 127, 118, 118, 126, - 115, 118, 125, 131, 134, 141, 159, 162, 169, 187, 192, 198, 208, 213, 217, - 214, 219, 223, 217, 222, 225, 228, 232, 233, 232, 236, 235, 229, 231, 230, - 231, 233, 230, 245, 247, 244, 254, 255, 253, 251, 255, 253, 243, 249, 245, - 215, 215, 215, 1, 1, 3, 9, 18, 17, 15, 19, 18, 32, 23, 24, - 29, 9, 8, 47, 18, 14, 53, 20, 11, 122, 89, 74, 185, 148, 130, - 202, 159, 143, 201, 160, 142, 161, 130, 110, 161, 133, 112, 191, 154, 136, - 200, 158, 142, 190, 142, 128, 205, 156, 141, 213, 160, 146, 203, 151, 137, - 179, 132, 116, 168, 125, 109, 173, 136, 120, 84, 51, 36, 70, 41, 27, - 120, 91, 77, 102, 70, 57, 63, 27, 13, 79, 39, 27, 106, 64, 52, - 171, 127, 116, 179, 135, 124, 178, 134, 121, 187, 141, 128, 215, 169, 156, - 233, 185, 171, 228, 179, 164, 221, 169, 155, 221, 168, 154, 237, 184, 170, - 243, 187, 172, 241, 185, 170, 244, 187, 170, 239, 182, 165, 228, 171, 154, - 227, 170, 153, 221, 164, 147, 219, 162, 145, 215, 158, 141, 215, 158, 141, - 217, 160, 143, 220, 164, 147, 223, 167, 150, 225, 169, 152, 226, 173, 155, - 227, 174, 156, 229, 176, 158, 231, 178, 160, 233, 177, 160, 235, 179, 162, - 239, 182, 165, 242, 185, 168, 240, 182, 168, 244, 186, 172, 245, 187, 173, - 243, 184, 170, 241, 181, 170, 240, 180, 169, 241, 179, 168, 238, 176, 165, - 237, 175, 164, 237, 175, 164, 237, 175, 164, 237, 175, 164, 235, 175, 165, - 228, 168, 158, 213, 155, 144, 199, 143, 130, 194, 141, 125, 191, 138, 120, - 188, 136, 115, 185, 133, 112, 186, 131, 110, 187, 133, 109, 189, 135, 111, - 190, 136, 112, 199, 147, 125, 212, 161, 142, 209, 162, 146, 201, 155, 142, - 187, 143, 134, 154, 111, 105, 186, 145, 143, 153, 119, 118, 31, 13, 13, - 66, 57, 60, 68, 67, 73, 52, 52, 60, 58, 58, 66, 59, 58, 64, - 51, 50, 55, 58, 58, 60, 56, 57, 61, 56, 55, 60, 55, 54, 59, - 53, 52, 57, 50, 50, 52, 46, 46, 48, 43, 42, 47, 41, 40, 45, - 113, 113, 121, 118, 118, 126, 116, 116, 124, 115, 115, 123, 125, 128, 135, - 147, 150, 157, 175, 180, 186, 200, 205, 211, 210, 215, 219, 214, 219, 222, - 225, 229, 232, 232, 236, 237, 231, 233, 232, 231, 233, 232, 242, 244, 241, - 251, 255, 252, 243, 253, 245, 251, 255, 253, 242, 238, 239, 96, 91, 95, - 0, 2, 3, 17, 21, 22, 15, 9, 11, 33, 19, 18, 40, 16, 12, - 59, 30, 22, 94, 65, 51, 172, 136, 120, 198, 154, 141, 206, 164, 148, - 181, 152, 134, 196, 169, 148, 202, 167, 147, 191, 150, 130, 211, 164, 146, - 201, 150, 133, 211, 158, 142, 202, 149, 133, 152, 103, 88, 168, 125, 109, - 94, 58, 44, 126, 94, 81, 106, 78, 66, 79, 50, 36, 67, 34, 19, - 84, 45, 30, 145, 99, 84, 181, 133, 119, 195, 147, 133, 194, 148, 135, - 194, 148, 135, 201, 155, 140, 217, 169, 155, 225, 177, 163, 226, 177, 162, - 227, 175, 161, 221, 168, 154, 235, 182, 166, 241, 185, 170, 239, 183, 168, - 243, 186, 169, 239, 182, 165, 230, 173, 156, 229, 172, 155, 221, 162, 146, - 220, 161, 145, 218, 161, 144, 217, 160, 143, 217, 161, 144, 218, 162, 145, - 218, 165, 147, 219, 166, 148, 222, 169, 151, 224, 171, 153, 231, 175, 158, - 234, 178, 161, 236, 179, 162, 237, 180, 163, 239, 180, 164, 240, 183, 166, - 245, 187, 173, 244, 188, 175, 244, 186, 174, 241, 183, 171, 241, 181, 170, - 243, 183, 172, 246, 184, 173, 244, 182, 171, 241, 179, 168, 240, 178, 167, - 239, 177, 166, 239, 177, 166, 235, 175, 165, 229, 169, 159, 215, 157, 146, - 203, 145, 133, 194, 141, 127, 191, 138, 122, 187, 134, 116, 186, 131, 111, - 187, 132, 111, 187, 133, 109, 188, 134, 110, 186, 134, 110, 174, 123, 102, - 153, 106, 88, 146, 104, 90, 137, 99, 88, 109, 74, 68, 74, 43, 41, - 93, 63, 65, 84, 62, 65, 50, 41, 46, 62, 61, 67, 58, 57, 63, - 49, 48, 54, 57, 56, 62, 58, 57, 63, 51, 50, 55, 56, 55, 60, - 48, 47, 52, 47, 46, 51, 45, 45, 47, 42, 42, 44, 39, 39, 41, - 36, 36, 38, 34, 34, 36, 33, 33, 35, 115, 115, 123, 117, 117, 125, - 114, 117, 124, 114, 117, 124, 120, 123, 130, 133, 136, 143, 160, 165, 171, - 190, 195, 201, 206, 211, 215, 210, 215, 218, 222, 226, 229, 231, 235, 236, - 231, 235, 234, 228, 232, 231, 237, 239, 236, 247, 252, 248, 251, 255, 253, - 253, 255, 252, 251, 242, 243, 164, 152, 154, 7, 0, 0, 29, 23, 23, - 14, 9, 6, 19, 10, 5, 39, 24, 17, 69, 49, 40, 80, 54, 41, - 155, 119, 107, 201, 157, 144, 201, 157, 144, 193, 160, 141, 210, 179, 159, - 212, 175, 156, 220, 177, 158, 216, 167, 150, 230, 179, 160, 217, 164, 146, - 177, 124, 108, 174, 125, 110, 107, 61, 46, 79, 41, 28, 155, 122, 107, - 147, 118, 104, 134, 102, 89, 156, 120, 106, 181, 139, 125, 215, 169, 153, - 220, 173, 157, 213, 165, 151, 199, 151, 137, 198, 150, 136, 213, 165, 151, - 225, 176, 162, 228, 179, 164, 228, 176, 162, 224, 172, 158, 222, 169, 153, - 232, 179, 163, 238, 182, 167, 238, 182, 165, 241, 184, 167, 238, 181, 164, - 233, 176, 159, 231, 174, 157, 223, 166, 149, 221, 164, 147, 220, 163, 146, - 217, 160, 143, 216, 160, 143, 217, 161, 144, 217, 164, 146, 219, 166, 148, - 221, 168, 150, 225, 172, 154, 231, 175, 158, 235, 179, 162, 239, 182, 165, - 240, 183, 166, 243, 184, 168, 242, 185, 168, 242, 184, 170, 243, 187, 172, - 245, 187, 173, 246, 188, 174, 248, 189, 175, 249, 190, 176, 249, 187, 174, - 245, 183, 170, 243, 181, 170, 242, 180, 169, 239, 177, 166, 237, 175, 164, - 233, 173, 162, 228, 168, 157, 217, 157, 146, 206, 148, 136, 197, 141, 128, - 193, 137, 124, 188, 132, 117, 187, 131, 114, 189, 134, 114, 190, 135, 114, - 187, 135, 113, 184, 133, 112, 158, 111, 93, 73, 32, 14, 31, 0, 0, - 45, 15, 5, 65, 37, 33, 75, 54, 51, 74, 54, 55, 62, 47, 50, - 58, 53, 57, 55, 54, 59, 51, 50, 55, 51, 50, 55, 55, 54, 59, - 50, 49, 54, 42, 41, 46, 43, 42, 47, 40, 40, 42, 38, 38, 40, - 36, 36, 38, 34, 34, 36, 32, 32, 34, 31, 31, 33, 30, 30, 30, - 30, 30, 30, 117, 117, 125, 117, 117, 125, 115, 118, 125, 118, 121, 128, - 120, 123, 130, 125, 128, 135, 149, 154, 160, 183, 188, 194, 202, 207, 211, - 207, 212, 216, 217, 221, 224, 228, 232, 233, 232, 236, 235, 227, 231, 230, - 233, 235, 232, 243, 248, 244, 247, 253, 249, 250, 250, 248, 255, 249, 249, - 203, 183, 185, 22, 0, 2, 41, 23, 21, 24, 15, 8, 18, 11, 1, - 31, 24, 14, 62, 50, 38, 74, 50, 40, 122, 88, 78, 198, 154, 143, - 197, 153, 140, 206, 169, 151, 220, 183, 164, 225, 184, 164, 224, 179, 158, - 234, 186, 166, 238, 185, 167, 211, 155, 138, 181, 125, 108, 161, 110, 93, - 93, 46, 30, 152, 113, 98, 176, 140, 126, 181, 148, 133, 200, 167, 152, - 212, 173, 158, 208, 165, 149, 218, 169, 152, 210, 161, 144, 208, 159, 144, - 194, 146, 132, 200, 152, 138, 220, 171, 156, 228, 179, 164, 230, 181, 166, - 229, 177, 163, 221, 170, 153, 222, 169, 153, 229, 176, 160, 237, 181, 164, - 238, 182, 165, 240, 183, 166, 238, 181, 164, 234, 177, 160, 231, 174, 157, - 227, 170, 153, 225, 168, 151, 220, 163, 146, 215, 158, 141, 212, 156, 139, - 215, 159, 142, 218, 165, 147, 222, 169, 151, 231, 178, 160, 233, 180, 162, - 237, 181, 164, 238, 182, 165, 241, 184, 167, 243, 186, 169, 246, 187, 171, - 246, 187, 171, 244, 186, 172, 245, 189, 174, 247, 189, 175, 247, 189, 175, - 248, 189, 175, 246, 187, 173, 244, 182, 169, 242, 180, 167, 240, 178, 167, - 238, 176, 165, 234, 172, 161, 231, 169, 158, 229, 167, 156, 222, 162, 151, - 214, 154, 143, 205, 145, 134, 199, 141, 130, 193, 135, 124, 188, 130, 118, - 189, 131, 117, 193, 136, 119, 194, 139, 119, 189, 138, 117, 183, 136, 116, - 166, 123, 106, 96, 59, 43, 49, 20, 6, 62, 38, 28, 55, 38, 31, - 61, 50, 48, 56, 47, 48, 54, 50, 51, 49, 47, 50, 44, 43, 48, - 45, 44, 49, 47, 46, 51, 42, 41, 46, 35, 34, 39, 32, 31, 36, - 33, 33, 35, 32, 32, 34, 32, 32, 34, 31, 31, 33, 31, 31, 33, - 31, 31, 33, 31, 31, 33, 31, 31, 31, 32, 32, 32, 119, 119, 127, - 117, 117, 125, 115, 118, 125, 121, 124, 131, 121, 124, 131, 121, 124, 131, - 143, 148, 154, 177, 182, 188, 199, 204, 208, 206, 211, 215, 214, 218, 221, - 223, 227, 228, 231, 235, 234, 228, 232, 231, 230, 232, 231, 239, 243, 242, - 240, 246, 244, 255, 255, 253, 255, 245, 245, 224, 194, 194, 55, 19, 19, - 76, 45, 42, 38, 24, 13, 13, 9, 0, 26, 27, 13, 53, 49, 37, - 71, 51, 42, 97, 64, 57, 169, 129, 121, 197, 153, 140, 211, 169, 153, - 226, 183, 164, 234, 191, 172, 228, 181, 161, 242, 191, 172, 225, 173, 152, - 210, 155, 135, 197, 142, 122, 153, 100, 82, 177, 128, 111, 222, 179, 163, - 208, 169, 154, 215, 178, 162, 219, 180, 165, 212, 170, 154, 212, 166, 150, - 215, 164, 145, 211, 158, 140, 199, 150, 135, 201, 152, 137, 215, 166, 151, - 228, 176, 162, 225, 173, 159, 226, 175, 158, 230, 177, 161, 226, 173, 157, - 224, 168, 153, 229, 173, 156, 237, 180, 163, 240, 183, 166, 240, 183, 164, - 238, 181, 162, 235, 178, 159, 230, 173, 154, 228, 171, 152, 225, 168, 149, - 219, 164, 144, 213, 158, 138, 211, 156, 136, 211, 156, 136, 214, 159, 139, - 217, 162, 142, 231, 176, 156, 233, 178, 158, 236, 179, 160, 236, 179, 160, - 238, 181, 162, 240, 183, 164, 241, 182, 164, 238, 179, 163, 245, 187, 173, - 244, 186, 172, 243, 184, 170, 241, 182, 168, 240, 178, 165, 238, 176, 163, - 237, 175, 162, 238, 176, 163, 235, 171, 159, 233, 169, 157, 229, 165, 153, - 224, 162, 149, 222, 160, 147, 219, 157, 144, 211, 149, 136, 204, 142, 131, - 198, 138, 128, 192, 132, 122, 188, 128, 117, 189, 130, 116, 194, 137, 120, - 197, 141, 124, 193, 142, 123, 186, 141, 122, 162, 123, 106, 97, 65, 50, - 26, 2, 0, 53, 36, 28, 49, 40, 35, 48, 47, 45, 41, 45, 46, - 36, 40, 43, 39, 40, 42, 36, 36, 38, 36, 36, 38, 33, 33, 35, - 26, 26, 28, 26, 26, 28, 31, 31, 33, 30, 30, 32, 28, 28, 30, - 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, - 29, 29, 29, 28, 28, 28, 119, 119, 127, 116, 116, 124, 115, 118, 125, - 122, 125, 132, 123, 126, 133, 121, 124, 131, 138, 143, 149, 169, 174, 180, - 194, 199, 203, 206, 211, 215, 212, 216, 219, 219, 223, 226, 229, 233, 234, - 228, 232, 231, 227, 229, 228, 232, 236, 235, 242, 246, 245, 253, 252, 250, - 255, 242, 241, 210, 176, 174, 101, 53, 51, 94, 51, 45, 57, 33, 21, - 14, 5, 0, 19, 20, 6, 47, 43, 32, 70, 51, 45, 96, 67, 61, - 132, 98, 89, 193, 153, 141, 207, 161, 145, 223, 176, 156, 230, 183, 163, - 236, 190, 167, 221, 170, 149, 221, 166, 145, 213, 156, 136, 209, 152, 132, - 206, 151, 131, 225, 174, 155, 216, 170, 154, 215, 172, 156, 223, 181, 165, - 215, 172, 156, 217, 171, 155, 223, 174, 157, 209, 157, 136, 208, 153, 133, - 216, 165, 148, 220, 168, 154, 227, 175, 161, 228, 176, 162, 227, 176, 159, - 229, 178, 161, 231, 178, 162, 225, 172, 156, 225, 169, 152, 227, 171, 154, - 236, 179, 162, 241, 184, 167, 239, 182, 163, 238, 181, 162, 237, 180, 161, - 231, 174, 155, 227, 170, 151, 225, 168, 149, 220, 165, 145, 216, 161, 141, - 213, 158, 138, 210, 155, 135, 207, 152, 132, 205, 150, 130, 208, 153, 133, - 213, 158, 138, 219, 162, 143, 221, 164, 145, 225, 168, 149, 229, 172, 153, - 229, 170, 152, 224, 165, 147, 221, 164, 147, 222, 164, 150, 226, 167, 153, - 231, 172, 158, 235, 173, 160, 234, 172, 159, 232, 170, 157, 232, 170, 157, - 229, 165, 153, 228, 164, 152, 225, 161, 149, 221, 158, 143, 218, 156, 143, - 216, 154, 139, 209, 147, 134, 203, 141, 128, 197, 135, 124, 192, 130, 119, - 188, 126, 115, 190, 128, 115, 195, 136, 120, 198, 142, 125, 196, 145, 128, - 190, 144, 128, 178, 141, 123, 116, 87, 71, 18, 0, 0, 42, 32, 23, - 41, 38, 33, 28, 32, 31, 31, 41, 42, 34, 44, 46, 29, 33, 34, - 29, 29, 31, 29, 29, 31, 27, 27, 29, 26, 26, 28, 30, 30, 32, - 30, 30, 32, 25, 25, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, - 28, 28, 28, 27, 27, 27, 26, 26, 26, 24, 24, 24, 23, 23, 23, - 120, 120, 128, 116, 116, 124, 115, 118, 125, 122, 125, 132, 124, 129, 135, - 120, 125, 131, 134, 139, 145, 159, 164, 170, 188, 193, 199, 206, 211, 215, - 211, 216, 219, 214, 219, 222, 228, 232, 233, 230, 234, 235, 225, 227, 226, - 225, 229, 228, 233, 237, 238, 247, 246, 244, 255, 250, 248, 214, 179, 175, - 132, 79, 73, 90, 35, 28, 68, 32, 18, 33, 11, 0, 11, 1, 0, - 35, 25, 16, 68, 47, 44, 97, 69, 66, 102, 73, 65, 172, 138, 126, - 208, 162, 146, 222, 174, 154, 226, 178, 158, 222, 174, 152, 225, 173, 152, - 219, 164, 143, 214, 157, 137, 230, 173, 153, 234, 179, 159, 222, 169, 151, - 223, 174, 159, 231, 184, 168, 234, 188, 172, 226, 179, 163, 220, 171, 154, - 217, 166, 147, 217, 162, 142, 227, 172, 152, 233, 180, 164, 233, 180, 164, - 228, 175, 159, 228, 175, 159, 235, 182, 166, 238, 185, 169, 233, 177, 160, - 227, 171, 154, 226, 170, 153, 225, 169, 152, 234, 177, 158, 240, 183, 164, - 238, 181, 162, 239, 182, 163, 240, 183, 164, 234, 177, 158, 229, 174, 154, - 226, 171, 151, 222, 167, 147, 221, 166, 146, 219, 164, 144, 215, 160, 140, - 209, 154, 134, 204, 149, 129, 199, 144, 124, 203, 148, 128, 205, 148, 129, - 206, 149, 130, 210, 151, 133, 216, 157, 139, 216, 157, 139, 212, 153, 135, - 198, 139, 123, 196, 137, 121, 199, 140, 124, 210, 151, 135, 222, 160, 145, - 227, 165, 150, 226, 164, 149, 225, 163, 148, 225, 162, 147, 225, 162, 147, - 223, 160, 145, 220, 157, 140, 219, 156, 141, 216, 153, 136, 210, 147, 132, - 204, 141, 126, 196, 134, 121, 192, 130, 117, 188, 126, 113, 190, 128, 113, - 194, 135, 119, 199, 142, 123, 198, 147, 128, 194, 149, 130, 181, 144, 126, - 131, 102, 86, 24, 4, 0, 36, 26, 17, 38, 39, 33, 22, 31, 28, - 14, 28, 29, 11, 22, 24, 23, 27, 28, 26, 26, 26, 27, 27, 27, - 28, 28, 28, 30, 30, 30, 29, 29, 29, 26, 26, 26, 23, 23, 23, - 27, 27, 27, 26, 26, 26, 25, 25, 25, 24, 24, 24, 22, 22, 22, - 21, 21, 21, 20, 20, 20, 19, 19, 19, 122, 122, 130, 118, 118, 126, - 115, 118, 125, 122, 125, 132, 125, 130, 136, 121, 126, 132, 131, 136, 142, - 153, 158, 164, 184, 189, 195, 205, 210, 216, 211, 216, 220, 212, 217, 220, - 228, 232, 235, 230, 234, 235, 222, 223, 225, 219, 223, 224, 233, 238, 241, - 245, 245, 245, 255, 245, 239, 238, 208, 200, 159, 104, 97, 121, 61, 51, - 73, 24, 10, 36, 0, 0, 33, 9, 0, 43, 23, 16, 74, 48, 47, - 87, 62, 58, 76, 54, 43, 134, 106, 92, 200, 157, 140, 213, 162, 143, - 229, 181, 161, 239, 188, 167, 237, 185, 163, 234, 179, 158, 244, 188, 165, - 235, 178, 158, 241, 186, 166, 237, 181, 164, 242, 191, 174, 231, 179, 165, - 220, 171, 156, 225, 176, 159, 223, 172, 155, 225, 173, 152, 241, 184, 164, - 236, 179, 159, 231, 175, 158, 234, 181, 165, 231, 178, 162, 232, 179, 163, - 239, 186, 170, 236, 183, 167, 231, 175, 158, 233, 177, 160, 227, 171, 154, - 223, 167, 150, 232, 175, 156, 239, 182, 163, 237, 180, 161, 239, 182, 163, - 242, 185, 166, 235, 180, 160, 234, 179, 159, 230, 175, 155, 225, 170, 150, - 223, 168, 148, 223, 168, 148, 222, 167, 147, 217, 162, 142, 212, 157, 137, - 215, 160, 140, 214, 159, 139, 209, 152, 133, 201, 144, 125, 201, 142, 124, - 206, 147, 129, 207, 148, 130, 204, 145, 127, 199, 140, 124, 187, 128, 112, - 178, 119, 103, 183, 124, 108, 200, 138, 123, 212, 150, 135, 220, 158, 143, - 223, 161, 146, 222, 159, 144, 223, 160, 145, 222, 159, 142, 220, 157, 140, - 219, 156, 139, 216, 153, 136, 210, 147, 130, 204, 141, 124, 198, 136, 121, - 193, 131, 116, 190, 128, 113, 191, 130, 112, 195, 136, 118, 200, 143, 123, - 201, 149, 128, 198, 151, 131, 187, 149, 130, 151, 122, 106, 45, 23, 10, - 26, 16, 6, 26, 25, 20, 23, 29, 27, 19, 31, 31, 20, 31, 33, - 25, 29, 30, 28, 28, 28, 26, 26, 26, 24, 24, 24, 24, 24, 24, - 20, 20, 20, 23, 23, 23, 32, 32, 32, 22, 22, 22, 21, 21, 21, - 19, 19, 19, 17, 17, 17, 16, 16, 16, 16, 16, 16, 15, 15, 15, - 15, 15, 15, 120, 123, 128, 118, 121, 126, 112, 115, 122, 118, 121, 128, - 129, 134, 140, 129, 134, 140, 128, 135, 141, 141, 148, 154, 176, 183, 189, - 197, 204, 210, 206, 211, 215, 211, 216, 219, 220, 224, 227, 224, 228, 229, - 225, 229, 230, 217, 221, 222, 224, 229, 232, 245, 249, 248, 251, 248, 239, - 249, 227, 216, 199, 149, 138, 168, 104, 94, 142, 80, 69, 89, 35, 25, - 31, 0, 0, 28, 0, 0, 60, 29, 27, 77, 52, 47, 86, 70, 57, - 103, 82, 65, 179, 137, 121, 207, 159, 139, 230, 182, 162, 235, 184, 163, - 243, 191, 169, 241, 189, 167, 242, 187, 166, 244, 189, 168, 244, 187, 168, - 246, 190, 173, 233, 177, 162, 233, 180, 166, 235, 182, 168, 237, 184, 168, - 238, 182, 167, 237, 180, 161, 234, 177, 157, 232, 175, 155, 232, 176, 159, - 235, 179, 162, 238, 182, 165, 239, 183, 166, 239, 183, 166, 237, 181, 164, - 233, 177, 160, 231, 175, 158, 224, 168, 151, 228, 172, 155, 233, 177, 160, - 238, 182, 165, 240, 184, 167, 241, 185, 168, 240, 184, 167, 239, 183, 166, - 240, 184, 167, 231, 178, 160, 231, 178, 160, 231, 178, 160, 228, 172, 155, - 226, 170, 153, 223, 167, 150, 213, 157, 140, 213, 156, 139, 216, 159, 142, - 218, 159, 143, 216, 157, 141, 174, 115, 99, 190, 131, 115, 202, 143, 127, - 200, 141, 125, 204, 145, 129, 208, 149, 133, 204, 145, 129, 189, 130, 114, - 176, 117, 101, 178, 119, 103, 193, 134, 118, 207, 148, 132, 217, 156, 138, - 217, 156, 138, 226, 165, 147, 216, 155, 137, 214, 151, 134, 223, 160, 143, - 214, 151, 133, 204, 143, 125, 196, 137, 119, 192, 133, 115, 189, 131, 111, - 192, 134, 112, 200, 139, 118, 202, 144, 122, 201, 146, 125, 194, 146, 124, - 194, 151, 132, 166, 133, 114, 72, 46, 33, 24, 10, 0, 32, 27, 21, - 21, 23, 20, 18, 27, 26, 19, 27, 29, 26, 27, 29, 26, 26, 26, - 25, 25, 25, 23, 23, 23, 22, 22, 22, 21, 21, 21, 21, 21, 21, - 20, 20, 20, 16, 16, 16, 17, 17, 17, 17, 17, 17, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 18, 18, 18, 19, 19, 19, 120, 123, 128, - 119, 122, 127, 114, 117, 124, 117, 120, 127, 126, 131, 137, 128, 133, 139, - 127, 134, 140, 136, 143, 149, 166, 173, 179, 191, 198, 204, 203, 208, 212, - 208, 213, 217, 216, 220, 223, 221, 225, 228, 224, 228, 229, 215, 220, 223, - 220, 225, 229, 234, 240, 240, 240, 243, 234, 255, 246, 233, 228, 184, 173, - 182, 119, 110, 176, 106, 98, 156, 87, 82, 132, 71, 70, 98, 48, 47, - 39, 0, 0, 76, 49, 42, 90, 74, 61, 91, 72, 55, 150, 113, 95, - 217, 170, 152, 225, 176, 159, 235, 187, 167, 244, 193, 172, 242, 190, 168, - 241, 189, 167, 247, 192, 172, 245, 190, 170, 245, 188, 171, 245, 189, 176, - 242, 186, 173, 237, 181, 168, 233, 175, 163, 231, 173, 159, 230, 173, 154, - 231, 173, 153, 231, 174, 154, 237, 180, 163, 238, 182, 165, 237, 181, 164, - 235, 179, 162, 235, 179, 162, 236, 180, 163, 234, 178, 161, 231, 175, 158, - 223, 167, 150, 227, 171, 154, 232, 176, 159, 236, 180, 163, 238, 182, 165, - 238, 182, 165, 239, 183, 166, 237, 184, 166, 232, 179, 161, 242, 189, 171, - 234, 181, 163, 229, 176, 158, 237, 181, 164, 227, 171, 154, 218, 162, 145, - 230, 174, 157, 215, 158, 141, 221, 164, 147, 219, 160, 144, 212, 153, 137, - 179, 120, 104, 200, 141, 125, 210, 151, 135, 207, 148, 132, 207, 148, 132, - 213, 154, 138, 217, 158, 142, 212, 153, 137, 201, 142, 126, 188, 129, 113, - 175, 116, 100, 165, 106, 90, 184, 125, 107, 187, 126, 108, 209, 148, 130, - 222, 161, 143, 224, 161, 144, 222, 159, 142, 211, 148, 130, 208, 147, 128, - 201, 144, 124, 195, 138, 118, 191, 133, 111, 190, 132, 108, 197, 137, 113, - 203, 143, 119, 203, 147, 124, 202, 150, 128, 198, 151, 131, 185, 147, 128, - 105, 76, 62, 15, 0, 0, 38, 27, 21, 28, 24, 21, 25, 27, 26, - 20, 24, 25, 20, 22, 21, 21, 21, 21, 20, 20, 20, 19, 19, 19, - 18, 18, 18, 18, 18, 18, 17, 17, 17, 17, 17, 17, 16, 16, 16, - 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, - 21, 21, 21, 22, 22, 22, 120, 123, 128, 121, 124, 129, 115, 120, 126, - 114, 119, 125, 122, 127, 133, 126, 131, 137, 125, 132, 140, 129, 136, 144, - 154, 161, 167, 184, 191, 197, 200, 205, 209, 205, 210, 214, 212, 217, 220, - 218, 223, 226, 224, 228, 231, 217, 222, 225, 219, 224, 228, 226, 235, 234, - 232, 239, 231, 255, 254, 242, 250, 218, 207, 192, 138, 128, 186, 113, 107, - 182, 102, 101, 188, 112, 112, 196, 130, 131, 139, 91, 87, 46, 13, 6, - 88, 69, 55, 94, 73, 56, 130, 94, 78, 183, 140, 124, 217, 170, 152, - 234, 186, 166, 241, 193, 173, 240, 189, 168, 242, 191, 170, 246, 194, 173, - 246, 190, 173, 242, 186, 171, 245, 187, 175, 240, 182, 171, 234, 176, 165, - 230, 170, 159, 229, 170, 156, 231, 172, 156, 235, 176, 158, 237, 180, 160, - 244, 187, 170, 243, 187, 172, 239, 183, 168, 234, 178, 163, 235, 179, 164, - 239, 183, 168, 238, 182, 167, 232, 176, 161, 220, 167, 151, 225, 172, 156, - 231, 178, 162, 236, 183, 167, 237, 184, 168, 238, 185, 169, 240, 187, 171, - 242, 189, 173, 233, 180, 164, 235, 184, 167, 241, 190, 173, 231, 178, 162, - 222, 166, 151, 235, 179, 164, 232, 174, 160, 195, 137, 123, 204, 145, 131, - 215, 156, 142, 208, 149, 135, 200, 141, 127, 181, 122, 108, 201, 142, 128, - 206, 147, 133, 203, 144, 130, 216, 157, 143, 217, 158, 144, 215, 156, 142, - 213, 154, 140, 210, 153, 136, 206, 149, 132, 199, 142, 125, 192, 135, 118, - 177, 120, 101, 171, 112, 94, 183, 124, 106, 197, 138, 120, 211, 150, 132, - 218, 157, 139, 210, 149, 130, 200, 142, 122, 202, 147, 126, 197, 143, 119, - 192, 136, 113, 191, 133, 109, 196, 136, 112, 201, 141, 115, 205, 145, 121, - 204, 148, 125, 198, 147, 126, 194, 151, 134, 142, 109, 94, 18, 0, 0, - 41, 26, 19, 30, 22, 19, 19, 18, 16, 20, 20, 20, 17, 17, 17, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 17, 17, 17, 17, 17, 19, 18, 18, 20, 20, 20, 22, - 21, 21, 23, 22, 22, 24, 24, 24, 26, 26, 26, 28, 28, 28, 30, - 120, 123, 128, 122, 125, 130, 117, 122, 128, 114, 119, 125, 118, 123, 129, - 124, 129, 135, 125, 132, 140, 124, 131, 139, 142, 149, 155, 176, 183, 189, - 195, 200, 206, 201, 206, 210, 208, 213, 217, 215, 220, 223, 223, 227, 230, - 218, 222, 225, 216, 221, 225, 222, 231, 230, 231, 241, 233, 244, 244, 234, - 255, 236, 225, 214, 170, 161, 181, 112, 107, 162, 81, 80, 187, 103, 103, - 236, 160, 160, 217, 159, 155, 98, 55, 46, 46, 16, 5, 92, 66, 51, - 93, 60, 45, 155, 116, 101, 209, 163, 147, 230, 183, 165, 235, 186, 169, - 236, 188, 168, 241, 193, 173, 243, 192, 173, 242, 189, 173, 241, 185, 172, - 236, 178, 167, 234, 176, 165, 234, 174, 164, 233, 173, 163, 234, 174, 163, - 237, 178, 162, 241, 182, 164, 242, 185, 166, 243, 187, 170, 243, 187, 172, - 239, 183, 168, 235, 179, 164, 239, 183, 168, 245, 189, 174, 239, 183, 168, - 226, 173, 157, 218, 165, 149, 224, 171, 155, 232, 179, 163, 237, 184, 168, - 238, 185, 169, 238, 187, 170, 240, 187, 171, 240, 189, 172, 241, 190, 173, - 236, 185, 168, 227, 176, 159, 231, 180, 163, 239, 183, 168, 224, 168, 153, - 199, 141, 127, 187, 129, 115, 197, 138, 124, 199, 140, 126, 183, 124, 110, - 173, 114, 100, 169, 110, 96, 191, 132, 118, 201, 142, 128, 209, 150, 136, - 216, 157, 143, 218, 159, 145, 219, 160, 146, 214, 156, 142, 211, 153, 139, - 209, 152, 135, 208, 151, 134, 207, 150, 133, 197, 140, 123, 195, 138, 119, - 192, 133, 115, 186, 127, 109, 197, 136, 118, 220, 159, 141, 222, 161, 142, - 205, 147, 127, 198, 143, 122, 196, 142, 118, 196, 138, 116, 197, 137, 113, - 199, 137, 114, 200, 138, 113, 201, 139, 116, 199, 141, 119, 195, 140, 120, - 193, 146, 128, 168, 130, 117, 47, 19, 8, 36, 17, 10, 32, 21, 17, - 13, 7, 7, 20, 18, 19, 15, 15, 15, 16, 16, 16, 16, 16, 16, - 17, 17, 17, 18, 18, 18, 19, 19, 19, 19, 19, 19, 20, 20, 20, - 20, 20, 22, 22, 22, 24, 24, 24, 26, 26, 26, 28, 28, 28, 30, - 30, 30, 32, 33, 33, 35, 35, 35, 37, 120, 123, 128, 121, 124, 129, - 119, 124, 128, 115, 120, 124, 116, 121, 127, 123, 128, 134, 125, 132, 140, - 122, 129, 137, 134, 141, 149, 166, 173, 179, 186, 191, 197, 195, 200, 204, - 203, 208, 212, 210, 215, 219, 219, 223, 226, 217, 221, 224, 211, 214, 219, - 216, 221, 224, 235, 241, 237, 235, 236, 230, 255, 247, 238, 242, 212, 202, - 192, 133, 129, 163, 85, 83, 182, 96, 95, 226, 142, 140, 239, 172, 164, - 180, 126, 116, 37, 0, 0, 73, 37, 25, 78, 44, 32, 132, 96, 82, - 199, 156, 140, 225, 179, 163, 229, 182, 166, 235, 188, 170, 242, 195, 177, - 238, 189, 172, 239, 186, 170, 241, 185, 172, 236, 178, 167, 238, 178, 170, - 240, 177, 170, 241, 178, 169, 240, 180, 169, 240, 181, 167, 240, 183, 166, - 241, 184, 165, 239, 183, 166, 240, 184, 169, 238, 182, 167, 238, 182, 167, - 242, 189, 173, 244, 191, 175, 234, 181, 165, 219, 166, 150, 215, 162, 146, - 221, 170, 153, 230, 178, 164, 236, 184, 170, 239, 187, 173, 237, 188, 173, - 239, 187, 173, 238, 189, 174, 237, 188, 173, 245, 196, 181, 249, 197, 183, - 242, 190, 176, 226, 170, 157, 193, 137, 124, 173, 115, 103, 175, 117, 105, - 141, 81, 70, 147, 87, 76, 147, 87, 76, 161, 101, 90, 177, 117, 106, - 196, 136, 125, 204, 144, 133, 217, 157, 146, 219, 161, 149, 222, 164, 152, - 224, 166, 154, 220, 162, 148, 215, 157, 143, 212, 156, 141, 210, 154, 139, - 209, 153, 136, 198, 142, 125, 211, 155, 138, 213, 156, 137, 198, 141, 122, - 192, 133, 115, 209, 150, 132, 223, 162, 144, 213, 154, 136, 198, 141, 122, - 196, 141, 120, 197, 139, 117, 200, 140, 116, 203, 138, 116, 203, 138, 116, - 202, 137, 115, 198, 137, 116, 194, 137, 118, 194, 145, 128, 184, 144, 132, - 90, 60, 50, 19, 0, 0, 35, 24, 20, 13, 7, 7, 20, 18, 19, - 16, 16, 16, 16, 16, 16, 17, 17, 19, 19, 19, 21, 20, 20, 22, - 22, 22, 24, 24, 24, 26, 24, 24, 26, 26, 25, 30, 28, 27, 32, - 30, 29, 34, 33, 32, 37, 35, 34, 39, 37, 36, 41, 39, 38, 43, - 41, 40, 45, 122, 125, 130, 120, 123, 128, 119, 124, 128, 117, 122, 126, - 114, 119, 125, 120, 125, 131, 124, 131, 139, 120, 127, 135, 130, 137, 145, - 158, 165, 173, 176, 181, 187, 190, 195, 201, 201, 206, 210, 208, 213, 217, - 218, 222, 225, 218, 222, 225, 212, 215, 220, 212, 216, 219, 234, 238, 239, - 236, 237, 232, 251, 248, 239, 251, 233, 223, 211, 164, 158, 185, 116, 111, - 162, 77, 74, 235, 147, 143, 241, 167, 158, 219, 155, 145, 126, 69, 60, - 40, 0, 0, 74, 40, 30, 74, 42, 29, 175, 133, 121, 216, 170, 155, - 226, 180, 165, 234, 188, 172, 242, 196, 180, 234, 187, 169, 238, 186, 172, - 241, 184, 173, 241, 182, 174, 242, 182, 174, 243, 180, 173, 243, 180, 173, - 241, 181, 171, 242, 183, 169, 241, 184, 167, 242, 185, 168, 240, 184, 169, - 240, 184, 169, 241, 185, 170, 243, 187, 172, 243, 190, 174, 240, 187, 171, - 228, 175, 159, 217, 164, 148, 214, 163, 146, 219, 168, 151, 227, 175, 161, - 235, 183, 169, 240, 191, 176, 245, 196, 181, 249, 200, 185, 251, 202, 187, - 255, 209, 194, 246, 197, 182, 243, 191, 177, 229, 177, 163, 211, 155, 142, - 197, 141, 128, 160, 102, 90, 103, 45, 33, 121, 61, 50, 130, 70, 59, - 147, 87, 76, 175, 115, 104, 197, 137, 126, 206, 146, 135, 209, 149, 138, - 218, 158, 147, 225, 167, 155, 222, 164, 152, 219, 161, 149, 216, 160, 147, - 219, 163, 148, 223, 167, 152, 223, 167, 152, 220, 164, 149, 204, 148, 131, - 209, 153, 136, 210, 153, 134, 207, 150, 131, 199, 140, 122, 200, 141, 123, - 215, 154, 136, 214, 155, 137, 201, 144, 125, 199, 142, 123, 199, 138, 119, - 200, 138, 117, 204, 137, 118, 206, 140, 118, 206, 140, 118, 202, 140, 119, - 192, 135, 116, 197, 148, 133, 191, 151, 139, 122, 92, 82, 14, 0, 0, - 34, 23, 19, 19, 15, 14, 16, 16, 16, 18, 18, 18, 19, 19, 19, - 20, 20, 22, 22, 22, 24, 24, 24, 26, 26, 26, 28, 28, 28, 30, - 29, 29, 31, 33, 32, 37, 35, 34, 39, 38, 37, 42, 40, 39, 44, - 41, 40, 45, 43, 42, 47, 44, 43, 48, 46, 45, 50, 124, 127, 132, - 119, 122, 127, 119, 124, 128, 119, 124, 128, 112, 119, 125, 115, 122, 128, - 121, 128, 136, 118, 125, 133, 127, 134, 142, 148, 155, 163, 162, 169, 175, - 181, 188, 194, 199, 204, 208, 205, 210, 214, 215, 218, 223, 219, 222, 227, - 216, 217, 222, 218, 217, 223, 228, 227, 232, 241, 241, 241, 240, 243, 236, - 249, 240, 231, 236, 199, 191, 205, 144, 139, 177, 97, 90, 200, 113, 106, - 255, 177, 166, 225, 151, 140, 192, 124, 115, 117, 60, 53, 35, 0, 0, - 58, 28, 17, 132, 92, 82, 198, 154, 141, 220, 177, 161, 227, 184, 167, - 234, 191, 174, 231, 185, 169, 237, 188, 174, 237, 183, 171, 241, 182, 174, - 242, 181, 176, 243, 180, 175, 243, 180, 173, 242, 182, 172, 243, 183, 172, - 244, 186, 172, 243, 187, 170, 242, 186, 171, 243, 187, 172, 243, 190, 176, - 242, 189, 175, 236, 183, 169, 227, 174, 160, 218, 166, 152, 216, 164, 150, - 220, 168, 154, 219, 167, 153, 219, 170, 155, 223, 174, 159, 231, 182, 167, - 239, 190, 175, 245, 198, 182, 248, 201, 185, 236, 187, 173, 243, 194, 180, - 235, 183, 170, 221, 169, 156, 202, 145, 134, 156, 99, 88, 130, 72, 61, - 142, 84, 73, 177, 117, 107, 177, 117, 107, 185, 122, 113, 196, 133, 124, - 203, 143, 133, 207, 147, 137, 212, 152, 142, 218, 158, 148, 218, 160, 149, - 219, 161, 150, 219, 163, 150, 221, 165, 152, 224, 168, 155, 220, 167, 153, - 211, 158, 142, 201, 148, 132, 214, 161, 143, 205, 152, 134, 201, 145, 128, - 211, 155, 138, 210, 153, 134, 204, 147, 128, 218, 159, 141, 224, 165, 147, - 204, 145, 129, 200, 141, 123, 199, 138, 120, 200, 137, 119, 206, 139, 120, - 209, 142, 123, 208, 141, 122, 204, 141, 123, 192, 135, 118, 193, 144, 129, - 188, 150, 137, 143, 115, 104, 23, 6, 0, 27, 17, 15, 23, 22, 20, - 18, 20, 19, 23, 23, 25, 24, 24, 26, 26, 26, 28, 28, 28, 30, - 31, 31, 33, 33, 33, 35, 35, 34, 39, 36, 35, 40, 40, 39, 44, - 42, 41, 46, 44, 43, 49, 45, 44, 50, 46, 45, 51, 47, 46, 52, - 48, 47, 53, 49, 48, 54, 126, 129, 134, 118, 121, 126, 119, 124, 128, - 120, 125, 129, 111, 118, 124, 113, 120, 126, 119, 126, 134, 116, 123, 131, - 121, 128, 136, 137, 144, 152, 150, 157, 163, 173, 180, 186, 193, 198, 202, - 199, 204, 208, 209, 212, 217, 215, 218, 223, 214, 214, 222, 221, 222, 227, - 220, 219, 224, 245, 245, 247, 238, 245, 238, 255, 252, 245, 255, 235, 227, - 213, 168, 162, 195, 128, 120, 211, 132, 125, 239, 159, 152, 227, 147, 140, - 227, 148, 143, 192, 125, 117, 126, 82, 71, 62, 24, 11, 99, 55, 44, - 183, 137, 124, 216, 170, 155, 223, 177, 162, 230, 184, 169, 231, 183, 169, - 241, 189, 176, 236, 182, 172, 240, 181, 175, 241, 182, 176, 243, 182, 177, - 243, 182, 177, 243, 184, 176, 242, 184, 173, 241, 185, 170, 241, 185, 170, - 242, 186, 171, 243, 185, 171, 243, 187, 174, 240, 184, 171, 227, 171, 158, - 211, 158, 144, 209, 156, 142, 215, 162, 148, 227, 174, 160, 219, 167, 153, - 212, 160, 146, 209, 157, 143, 212, 160, 146, 219, 167, 153, 223, 174, 159, - 226, 177, 162, 231, 177, 165, 222, 168, 156, 218, 164, 152, 204, 150, 138, - 173, 116, 105, 157, 100, 89, 173, 116, 105, 194, 137, 126, 178, 120, 109, - 184, 126, 115, 200, 140, 130, 210, 150, 140, 213, 153, 143, 212, 152, 142, - 211, 151, 141, 204, 146, 135, 218, 164, 152, 220, 168, 155, 221, 169, 155, - 220, 168, 154, 219, 167, 153, 217, 165, 151, 213, 161, 147, 207, 156, 139, - 200, 149, 132, 197, 146, 127, 196, 143, 125, 212, 156, 139, 210, 153, 134, - 202, 145, 126, 222, 163, 145, 234, 173, 155, 204, 143, 125, 201, 140, 122, - 198, 137, 119, 202, 139, 121, 208, 143, 123, 210, 145, 125, 207, 142, 124, - 202, 139, 121, 196, 137, 121, 190, 138, 124, 190, 148, 136, 162, 129, 122, - 52, 33, 27, 22, 14, 11, 25, 25, 25, 24, 28, 29, 28, 29, 31, - 30, 30, 32, 32, 32, 34, 34, 34, 36, 37, 37, 39, 39, 39, 41, - 42, 41, 46, 43, 42, 47, 45, 44, 49, 46, 45, 50, 48, 47, 53, - 49, 48, 54, 49, 48, 54, 49, 48, 54, 50, 49, 55, 50, 49, 55, - 123, 128, 134, 121, 126, 132, 120, 125, 131, 119, 124, 130, 116, 121, 127, - 114, 119, 125, 117, 122, 128, 121, 126, 132, 122, 127, 133, 134, 139, 145, - 149, 154, 160, 166, 171, 177, 183, 188, 194, 193, 198, 204, 202, 207, 213, - 214, 219, 225, 220, 224, 233, 209, 214, 220, 222, 225, 230, 238, 242, 243, - 236, 242, 238, 245, 248, 241, 255, 248, 240, 250, 227, 219, 208, 165, 159, - 193, 132, 131, 224, 146, 146, 248, 162, 163, 227, 142, 139, 217, 140, 132, - 203, 141, 126, 161, 108, 90, 96, 44, 30, 145, 93, 79, 214, 162, 149, - 223, 171, 158, 227, 175, 162, 224, 172, 161, 242, 187, 180, 231, 176, 169, - 240, 182, 178, 241, 183, 179, 241, 184, 177, 242, 185, 178, 239, 185, 175, - 239, 185, 173, 242, 188, 176, 245, 192, 178, 246, 188, 174, 248, 189, 175, - 235, 176, 162, 215, 156, 142, 204, 146, 132, 217, 159, 145, 205, 147, 133, - 212, 156, 141, 224, 168, 155, 222, 169, 155, 213, 159, 147, 201, 147, 135, - 196, 142, 130, 195, 141, 129, 202, 148, 136, 215, 158, 147, 225, 165, 154, - 218, 156, 145, 199, 139, 128, 179, 121, 109, 171, 113, 101, 174, 118, 105, - 177, 123, 111, 179, 125, 113, 187, 133, 121, 193, 139, 127, 200, 147, 133, - 207, 151, 138, 212, 156, 143, 216, 158, 146, 218, 160, 148, 214, 161, 147, - 215, 169, 154, 210, 167, 151, 216, 173, 157, 213, 167, 152, 221, 173, 159, - 212, 165, 149, 207, 160, 144, 199, 152, 134, 192, 145, 127, 181, 134, 116, - 184, 136, 116, 205, 152, 134, 208, 153, 133, 221, 163, 143, 223, 162, 143, - 237, 174, 156, 211, 148, 130, 202, 139, 121, 201, 143, 123, 199, 141, 119, - 198, 142, 119, 205, 147, 125, 204, 143, 122, 203, 140, 122, 196, 133, 116, - 198, 139, 125, 194, 141, 133, 172, 131, 125, 83, 57, 56, 15, 5, 4, - 28, 29, 31, 27, 35, 38, 33, 34, 38, 36, 35, 40, 39, 38, 43, - 42, 41, 46, 43, 42, 47, 45, 44, 49, 46, 45, 50, 47, 46, 51, - 48, 47, 52, 48, 47, 52, 49, 48, 53, 49, 48, 53, 49, 48, 53, - 49, 48, 53, 49, 48, 53, 49, 48, 53, 123, 128, 134, 122, 127, 133, - 121, 126, 132, 119, 124, 130, 116, 121, 127, 114, 119, 125, 117, 122, 128, - 121, 126, 132, 119, 124, 130, 130, 135, 141, 144, 149, 155, 162, 167, 173, - 180, 185, 191, 191, 196, 202, 200, 205, 211, 212, 217, 223, 216, 223, 231, - 208, 215, 223, 218, 223, 227, 232, 236, 237, 236, 241, 237, 243, 248, 242, - 248, 249, 241, 244, 235, 228, 238, 213, 208, 212, 166, 166, 215, 149, 151, - 237, 158, 161, 232, 148, 146, 213, 133, 124, 202, 130, 116, 193, 130, 112, - 142, 86, 69, 121, 70, 53, 183, 131, 117, 219, 167, 154, 226, 172, 160, - 233, 179, 169, 230, 175, 168, 234, 179, 174, 239, 184, 179, 240, 185, 180, - 241, 186, 179, 241, 186, 179, 241, 188, 180, 242, 190, 179, 245, 193, 182, - 249, 195, 183, 249, 190, 176, 237, 175, 162, 222, 160, 147, 204, 145, 131, - 200, 141, 127, 216, 158, 144, 215, 157, 143, 216, 160, 145, 212, 156, 143, - 217, 161, 148, 198, 141, 130, 161, 104, 93, 135, 78, 67, 139, 82, 71, - 168, 111, 102, 198, 140, 129, 200, 140, 129, 191, 129, 116, 169, 109, 98, - 149, 91, 79, 145, 87, 75, 157, 101, 88, 176, 122, 110, 190, 138, 125, - 196, 144, 131, 198, 146, 133, 204, 152, 138, 208, 156, 142, 208, 155, 141, - 209, 153, 140, 217, 161, 146, 225, 172, 156, 223, 176, 160, 224, 176, 162, - 235, 186, 172, 221, 172, 158, 221, 169, 156, 215, 163, 150, 204, 152, 138, - 195, 146, 131, 174, 125, 110, 144, 95, 78, 171, 122, 105, 211, 160, 141, - 216, 161, 141, 229, 172, 152, 239, 181, 161, 248, 187, 168, 216, 154, 133, - 204, 142, 121, 202, 144, 122, 198, 144, 120, 196, 144, 120, 203, 149, 125, - 200, 142, 120, 198, 136, 115, 198, 132, 116, 200, 136, 124, 197, 138, 130, - 179, 134, 129, 99, 71, 70, 18, 6, 6, 35, 39, 42, 31, 39, 42, - 38, 39, 43, 41, 40, 45, 44, 43, 48, 45, 44, 49, 46, 45, 50, - 47, 46, 51, 48, 47, 52, 49, 48, 53, 48, 47, 52, 49, 48, 53, - 49, 48, 53, 50, 49, 54, 50, 49, 54, 50, 49, 54, 50, 49, 54, - 50, 49, 54, 124, 129, 135, 122, 127, 133, 121, 126, 132, 120, 125, 131, - 117, 122, 128, 114, 119, 125, 116, 121, 127, 119, 124, 130, 117, 122, 128, - 126, 131, 137, 137, 142, 148, 154, 159, 165, 174, 179, 185, 188, 193, 199, - 198, 203, 209, 208, 213, 219, 216, 221, 227, 213, 218, 224, 217, 218, 223, - 225, 226, 228, 235, 237, 236, 243, 245, 240, 244, 247, 240, 243, 240, 233, - 255, 241, 236, 244, 215, 211, 222, 174, 172, 216, 155, 154, 229, 158, 154, - 222, 145, 137, 199, 121, 111, 185, 113, 99, 157, 101, 84, 129, 80, 63, - 145, 96, 79, 207, 158, 143, 228, 176, 163, 220, 168, 157, 227, 174, 166, - 232, 179, 171, 238, 185, 179, 241, 188, 182, 245, 190, 185, 247, 192, 185, - 247, 192, 185, 247, 193, 183, 247, 193, 183, 248, 191, 180, 243, 184, 170, - 222, 160, 145, 206, 147, 133, 190, 131, 117, 196, 137, 123, 213, 155, 141, - 224, 166, 152, 222, 166, 151, 211, 155, 142, 190, 137, 123, 155, 101, 89, - 131, 77, 65, 145, 88, 79, 176, 119, 110, 198, 141, 132, 207, 150, 139, - 201, 145, 132, 168, 112, 97, 132, 79, 65, 127, 74, 60, 147, 93, 81, - 170, 116, 104, 180, 126, 114, 181, 127, 115, 196, 142, 130, 204, 150, 138, - 206, 154, 141, 204, 152, 139, 213, 161, 147, 229, 177, 163, 233, 182, 165, - 225, 172, 156, 225, 166, 152, 241, 177, 167, 236, 169, 160, 227, 160, 151, - 218, 151, 143, 192, 128, 119, 179, 116, 107, 147, 87, 77, 136, 79, 68, - 99, 46, 32, 165, 114, 97, 223, 172, 153, 225, 173, 152, 230, 178, 156, - 240, 186, 162, 236, 180, 157, 216, 155, 134, 203, 142, 121, 199, 143, 120, - 197, 143, 119, 197, 145, 121, 203, 149, 125, 198, 140, 118, 194, 132, 111, - 198, 132, 116, 196, 134, 121, 193, 136, 127, 182, 137, 131, 118, 90, 87, - 20, 8, 8, 46, 47, 51, 36, 41, 45, 43, 44, 48, 46, 45, 50, - 47, 46, 51, 48, 47, 52, 48, 47, 52, 48, 47, 52, 49, 48, 53, - 49, 48, 53, 49, 48, 53, 49, 48, 53, 50, 49, 54, 50, 49, 54, - 50, 49, 54, 50, 49, 54, 50, 49, 54, 50, 49, 54, 125, 130, 136, - 123, 128, 134, 121, 126, 132, 120, 125, 131, 118, 123, 129, 115, 120, 126, - 115, 120, 126, 118, 123, 129, 116, 121, 127, 122, 127, 133, 129, 134, 140, - 144, 149, 155, 165, 170, 176, 182, 187, 193, 194, 199, 205, 205, 210, 216, - 215, 220, 226, 218, 221, 226, 216, 217, 221, 217, 217, 219, 231, 231, 231, - 239, 239, 237, 238, 240, 235, 240, 241, 236, 241, 236, 232, 255, 242, 236, - 236, 208, 204, 212, 168, 165, 224, 165, 161, 233, 160, 154, 215, 132, 126, - 189, 111, 99, 166, 109, 90, 170, 122, 102, 142, 94, 74, 173, 124, 107, - 217, 168, 153, 213, 164, 150, 228, 176, 165, 230, 177, 169, 236, 183, 177, - 241, 188, 182, 247, 192, 187, 250, 195, 190, 250, 195, 188, 247, 192, 185, - 243, 186, 177, 238, 181, 170, 229, 170, 156, 214, 155, 139, 196, 137, 123, - 177, 119, 105, 197, 139, 125, 211, 155, 140, 225, 169, 154, 226, 173, 157, - 225, 172, 158, 214, 161, 147, 191, 137, 125, 177, 123, 111, 189, 132, 123, - 205, 148, 139, 213, 156, 147, 213, 159, 147, 195, 142, 128, 173, 122, 105, - 154, 102, 88, 152, 100, 86, 163, 109, 97, 174, 120, 108, 183, 129, 117, - 189, 135, 123, 207, 153, 141, 214, 160, 148, 225, 168, 157, 230, 173, 162, - 230, 174, 161, 227, 171, 158, 224, 168, 153, 225, 166, 152, 225, 157, 146, - 215, 142, 133, 188, 114, 105, 163, 88, 82, 146, 71, 66, 124, 51, 45, - 99, 30, 23, 72, 5, 0, 90, 27, 20, 79, 21, 10, 171, 118, 104, - 228, 177, 158, 234, 183, 162, 240, 190, 167, 247, 197, 172, 240, 188, 164, - 210, 152, 130, 200, 139, 118, 198, 142, 119, 194, 142, 118, 195, 143, 119, - 202, 148, 124, 198, 140, 118, 194, 133, 112, 194, 131, 114, 195, 133, 118, - 190, 133, 122, 182, 137, 131, 133, 104, 100, 28, 14, 13, 49, 49, 51, - 39, 43, 46, 45, 46, 50, 47, 46, 51, 48, 47, 52, 48, 47, 52, - 48, 47, 52, 48, 47, 52, 48, 47, 52, 49, 48, 53, 50, 49, 54, - 50, 49, 54, 50, 49, 54, 51, 50, 55, 51, 50, 55, 51, 50, 55, - 51, 50, 55, 51, 50, 55, 125, 130, 136, 123, 128, 134, 122, 127, 133, - 121, 126, 132, 119, 124, 130, 116, 121, 127, 115, 120, 126, 117, 122, 128, - 118, 123, 129, 121, 126, 132, 124, 129, 135, 134, 139, 145, 156, 161, 167, - 176, 181, 187, 190, 195, 201, 202, 207, 213, 213, 216, 221, 222, 223, 227, - 216, 215, 220, 212, 212, 214, 225, 223, 226, 232, 232, 232, 231, 233, 232, - 233, 237, 236, 225, 230, 226, 234, 235, 230, 232, 225, 219, 219, 196, 190, - 215, 170, 165, 226, 161, 157, 240, 155, 152, 237, 154, 146, 211, 150, 131, - 207, 157, 134, 182, 131, 110, 149, 98, 79, 197, 146, 129, 222, 170, 156, - 225, 171, 161, 226, 172, 162, 233, 178, 171, 238, 183, 176, 245, 188, 181, - 246, 189, 182, 246, 189, 182, 243, 186, 179, 238, 179, 171, 231, 173, 162, - 219, 160, 146, 210, 151, 135, 181, 122, 106, 167, 110, 93, 207, 149, 135, - 221, 165, 150, 228, 172, 159, 232, 179, 165, 220, 166, 154, 225, 173, 160, - 223, 171, 158, 212, 160, 147, 201, 147, 137, 190, 136, 126, 191, 137, 127, - 202, 148, 136, 191, 138, 124, 185, 132, 118, 178, 126, 112, 177, 125, 111, - 177, 125, 112, 183, 131, 118, 198, 146, 135, 213, 159, 149, 226, 169, 160, - 233, 174, 166, 233, 173, 163, 228, 165, 156, 227, 160, 151, 223, 155, 146, - 205, 137, 128, 186, 116, 106, 157, 87, 75, 135, 63, 51, 129, 55, 46, - 120, 45, 39, 123, 48, 43, 128, 53, 48, 102, 28, 25, 94, 25, 20, - 105, 40, 36, 129, 70, 62, 208, 155, 141, 233, 182, 165, 231, 183, 161, - 233, 187, 163, 235, 189, 163, 231, 181, 154, 206, 150, 125, 198, 140, 116, - 198, 144, 120, 194, 142, 118, 194, 142, 120, 198, 146, 124, 196, 140, 117, - 194, 136, 114, 194, 131, 114, 196, 134, 119, 189, 132, 121, 178, 134, 125, - 144, 115, 109, 45, 30, 27, 47, 43, 42, 43, 44, 46, 45, 44, 49, - 46, 45, 50, 47, 46, 51, 48, 47, 52, 47, 46, 51, 48, 47, 52, - 48, 47, 52, 49, 48, 53, 50, 49, 54, 50, 49, 54, 50, 49, 54, - 51, 50, 55, 51, 50, 55, 51, 50, 55, 51, 50, 55, 51, 50, 55, - 125, 130, 136, 123, 128, 134, 121, 126, 132, 121, 126, 132, 119, 124, 130, - 116, 121, 127, 115, 120, 126, 116, 121, 127, 119, 124, 130, 122, 127, 133, - 122, 127, 133, 128, 133, 139, 148, 153, 159, 169, 174, 180, 185, 190, 196, - 197, 202, 206, 210, 211, 215, 219, 220, 224, 215, 216, 218, 208, 208, 210, - 216, 216, 218, 224, 224, 226, 225, 226, 230, 226, 231, 234, 223, 233, 232, - 215, 226, 222, 216, 223, 216, 211, 204, 196, 199, 168, 163, 214, 159, 154, - 243, 163, 162, 242, 159, 153, 239, 176, 158, 238, 184, 160, 226, 171, 150, - 184, 132, 111, 198, 145, 127, 208, 155, 139, 226, 169, 158, 215, 158, 149, - 229, 172, 163, 233, 176, 167, 235, 178, 171, 235, 176, 168, 236, 177, 169, - 237, 178, 170, 234, 174, 166, 229, 169, 159, 215, 156, 142, 198, 139, 123, - 162, 105, 88, 170, 113, 96, 219, 163, 148, 232, 179, 163, 232, 179, 165, - 235, 183, 169, 234, 182, 169, 230, 178, 165, 224, 172, 159, 224, 172, 159, - 226, 172, 162, 219, 165, 155, 213, 159, 149, 216, 162, 152, 208, 154, 142, - 193, 141, 127, 183, 130, 116, 187, 134, 120, 204, 150, 138, 222, 165, 154, - 231, 172, 164, 235, 175, 167, 241, 178, 171, 236, 169, 163, 220, 151, 146, - 200, 129, 123, 190, 117, 111, 180, 105, 99, 164, 87, 81, 141, 68, 59, - 157, 94, 77, 167, 106, 88, 139, 76, 61, 174, 108, 96, 178, 109, 102, - 154, 85, 80, 156, 86, 84, 125, 57, 54, 114, 51, 46, 169, 110, 102, - 225, 171, 159, 231, 182, 165, 234, 188, 165, 240, 194, 168, 238, 193, 164, - 234, 187, 159, 207, 153, 127, 199, 143, 118, 199, 145, 121, 194, 142, 118, - 191, 141, 118, 196, 144, 122, 194, 140, 116, 192, 135, 115, 193, 132, 113, - 196, 137, 121, 188, 135, 121, 175, 131, 120, 154, 124, 116, 79, 61, 57, - 40, 35, 32, 47, 47, 47, 45, 45, 47, 46, 45, 50, 47, 46, 51, - 48, 47, 52, 48, 47, 52, 48, 47, 52, 49, 48, 53, 51, 50, 55, - 50, 49, 54, 50, 49, 54, 50, 49, 54, 51, 50, 55, 51, 50, 55, - 51, 50, 55, 51, 50, 55, 51, 50, 55, 125, 130, 136, 122, 127, 133, - 121, 126, 132, 121, 126, 132, 120, 125, 131, 117, 122, 128, 116, 121, 127, - 116, 121, 127, 119, 124, 130, 123, 128, 134, 121, 126, 132, 125, 130, 136, - 143, 148, 154, 163, 168, 174, 179, 184, 190, 191, 196, 200, 201, 202, 206, - 213, 214, 216, 211, 215, 216, 203, 207, 208, 207, 208, 212, 216, 217, 221, - 223, 222, 228, 222, 225, 230, 220, 231, 233, 210, 224, 224, 209, 224, 219, - 196, 201, 194, 181, 164, 157, 197, 156, 150, 226, 156, 156, 218, 141, 135, - 238, 171, 152, 252, 192, 166, 249, 189, 165, 233, 175, 153, 226, 168, 148, - 205, 146, 128, 218, 159, 145, 212, 152, 141, 221, 163, 152, 226, 168, 157, - 228, 169, 161, 229, 169, 159, 231, 171, 161, 233, 173, 163, 231, 168, 159, - 222, 162, 151, 209, 150, 134, 179, 120, 102, 156, 99, 82, 193, 136, 119, - 230, 174, 159, 235, 182, 166, 234, 182, 168, 234, 185, 170, 240, 191, 177, - 236, 187, 173, 226, 176, 165, 220, 170, 159, 222, 170, 159, 217, 165, 154, - 212, 158, 148, 212, 158, 148, 214, 162, 149, 212, 160, 147, 212, 158, 146, - 217, 160, 149, 228, 168, 160, 240, 175, 169, 246, 176, 174, 248, 174, 173, - 234, 158, 158, 211, 133, 131, 194, 114, 113, 185, 106, 102, 165, 86, 82, - 143, 64, 60, 147, 68, 64, 162, 94, 83, 212, 164, 142, 233, 191, 166, - 170, 125, 104, 213, 164, 147, 211, 157, 145, 169, 112, 103, 192, 133, 127, - 137, 78, 74, 150, 92, 88, 206, 151, 144, 231, 179, 166, 235, 186, 169, - 233, 187, 164, 234, 188, 162, 228, 183, 154, 222, 173, 143, 209, 155, 129, - 197, 143, 117, 195, 143, 119, 190, 140, 115, 189, 139, 116, 195, 143, 121, - 192, 137, 116, 189, 132, 112, 191, 133, 113, 196, 139, 120, 188, 135, 119, - 172, 128, 115, 165, 132, 123, 118, 98, 91, 37, 28, 23, 52, 48, 45, - 46, 44, 47, 46, 45, 50, 47, 46, 51, 48, 47, 52, 48, 47, 52, - 48, 47, 52, 50, 49, 54, 51, 50, 55, 49, 48, 53, 50, 49, 54, - 50, 49, 54, 50, 49, 54, 51, 50, 55, 51, 50, 55, 51, 50, 55, - 50, 49, 54, 125, 130, 136, 122, 127, 133, 121, 126, 132, 122, 127, 133, - 121, 126, 132, 118, 123, 129, 116, 121, 127, 116, 121, 127, 118, 123, 129, - 123, 128, 134, 122, 127, 133, 125, 130, 136, 140, 145, 151, 159, 164, 170, - 175, 180, 186, 186, 191, 195, 192, 196, 199, 205, 209, 210, 208, 214, 214, - 199, 208, 207, 200, 204, 207, 212, 213, 218, 222, 221, 229, 222, 222, 230, - 213, 222, 227, 210, 224, 227, 213, 229, 228, 197, 208, 202, 170, 163, 157, - 176, 147, 143, 209, 155, 153, 225, 158, 150, 235, 168, 149, 246, 180, 156, - 255, 190, 168, 242, 177, 155, 245, 182, 164, 233, 170, 153, 198, 135, 120, - 223, 161, 148, 217, 155, 144, 222, 162, 151, 227, 167, 156, 229, 169, 158, - 233, 171, 160, 233, 171, 158, 226, 164, 151, 216, 154, 139, 201, 142, 124, - 164, 105, 87, 159, 102, 85, 219, 163, 146, 233, 180, 164, 230, 179, 162, - 232, 183, 168, 234, 185, 170, 234, 185, 171, 237, 188, 174, 232, 182, 171, - 224, 174, 163, 226, 174, 163, 225, 173, 162, 222, 168, 158, 221, 167, 157, - 218, 166, 153, 226, 174, 161, 237, 180, 169, 243, 183, 173, 249, 182, 176, - 249, 175, 172, 240, 162, 162, 229, 147, 149, 192, 107, 110, 184, 99, 102, - 155, 74, 73, 134, 56, 54, 158, 83, 80, 203, 132, 126, 215, 146, 139, - 188, 132, 119, 241, 205, 179, 241, 212, 182, 202, 168, 143, 222, 184, 163, - 222, 176, 161, 200, 150, 139, 184, 131, 125, 135, 82, 76, 184, 131, 125, - 224, 174, 165, 225, 176, 162, 234, 185, 168, 232, 184, 162, 235, 188, 162, - 235, 188, 160, 228, 179, 149, 208, 154, 128, 195, 141, 115, 190, 138, 114, - 186, 136, 111, 187, 137, 114, 193, 143, 120, 191, 136, 115, 186, 131, 110, - 188, 131, 111, 195, 138, 119, 185, 134, 117, 169, 126, 110, 172, 138, 128, - 146, 122, 112, 37, 22, 15, 55, 47, 44, 47, 45, 46, 46, 45, 50, - 47, 46, 51, 47, 46, 51, 47, 46, 51, 48, 47, 52, 49, 48, 53, - 50, 49, 54, 49, 48, 53, 49, 48, 53, 50, 49, 54, 50, 49, 54, - 50, 49, 54, 50, 49, 54, 50, 49, 54, 50, 49, 54, 124, 129, 135, - 124, 129, 135, 124, 129, 135, 123, 128, 134, 121, 126, 132, 119, 124, 130, - 117, 122, 128, 116, 121, 127, 119, 124, 130, 121, 126, 132, 123, 128, 134, - 126, 131, 137, 135, 140, 146, 150, 155, 161, 167, 172, 178, 178, 183, 187, - 183, 187, 190, 196, 202, 202, 203, 213, 212, 196, 208, 206, 190, 198, 200, - 203, 208, 212, 222, 221, 229, 225, 223, 234, 223, 226, 235, 211, 218, 226, - 207, 218, 220, 187, 196, 195, 174, 173, 169, 144, 126, 122, 181, 146, 142, - 221, 171, 162, 237, 172, 154, 250, 179, 157, 254, 183, 163, 252, 184, 163, - 248, 181, 164, 255, 189, 173, 205, 139, 125, 212, 148, 136, 218, 154, 142, - 212, 150, 137, 223, 161, 148, 220, 158, 143, 230, 167, 152, 229, 166, 151, - 222, 159, 142, 202, 141, 123, 185, 127, 107, 155, 97, 77, 191, 134, 115, - 224, 168, 151, 234, 181, 165, 229, 178, 161, 230, 181, 166, 236, 188, 174, - 234, 186, 174, 231, 183, 171, 225, 175, 164, 229, 179, 168, 217, 165, 154, - 222, 170, 159, 225, 171, 161, 222, 168, 158, 235, 183, 170, 236, 182, 170, - 244, 184, 176, 239, 172, 166, 231, 157, 156, 221, 141, 142, 197, 112, 115, - 188, 102, 105, 166, 80, 83, 148, 66, 68, 192, 116, 116, 193, 124, 119, - 187, 128, 120, 237, 185, 174, 255, 213, 198, 203, 166, 147, 230, 205, 175, - 251, 228, 196, 218, 191, 164, 213, 178, 158, 227, 185, 169, 175, 129, 116, - 158, 109, 102, 169, 119, 112, 213, 163, 154, 217, 169, 157, 227, 179, 165, - 234, 185, 168, 233, 185, 163, 235, 185, 160, 234, 184, 157, 229, 178, 149, - 201, 150, 123, 193, 142, 115, 190, 140, 115, 193, 143, 118, 191, 141, 118, - 191, 141, 118, 193, 138, 117, 188, 133, 112, 190, 133, 113, 192, 137, 117, - 190, 139, 120, 170, 124, 109, 165, 129, 115, 177, 149, 138, 86, 66, 57, - 41, 30, 24, 52, 48, 49, 43, 42, 47, 49, 48, 53, 48, 47, 52, - 49, 48, 53, 45, 44, 49, 54, 53, 58, 47, 46, 51, 50, 49, 54, - 50, 49, 54, 50, 49, 54, 50, 49, 54, 50, 49, 54, 50, 49, 54, - 50, 49, 54, 51, 50, 55, 124, 129, 135, 124, 129, 135, 124, 129, 135, - 123, 128, 134, 122, 127, 133, 120, 125, 131, 118, 123, 129, 117, 122, 128, - 118, 123, 129, 119, 124, 130, 122, 127, 133, 125, 130, 136, 132, 137, 143, - 144, 149, 155, 158, 163, 169, 168, 173, 177, 176, 181, 184, 186, 194, 196, - 196, 208, 208, 190, 204, 204, 185, 197, 197, 194, 202, 205, 213, 213, 221, - 220, 217, 228, 224, 222, 235, 204, 204, 214, 198, 203, 209, 199, 204, 207, - 178, 178, 176, 122, 114, 111, 122, 103, 97, 205, 168, 159, 232, 173, 157, - 248, 177, 159, 246, 178, 159, 246, 177, 161, 251, 184, 168, 253, 187, 173, - 234, 171, 156, 198, 136, 123, 211, 149, 136, 206, 144, 131, 221, 159, 144, - 223, 162, 144, 222, 161, 143, 211, 148, 130, 204, 141, 123, 192, 130, 109, - 179, 118, 99, 160, 102, 82, 214, 157, 138, 240, 185, 165, 225, 172, 154, - 218, 169, 152, 227, 178, 164, 220, 172, 158, 222, 174, 162, 234, 186, 174, - 234, 184, 173, 216, 166, 155, 225, 173, 162, 227, 175, 164, 236, 182, 172, - 233, 176, 167, 228, 170, 159, 225, 162, 153, 212, 147, 141, 196, 127, 122, - 183, 109, 108, 167, 91, 91, 160, 82, 82, 142, 66, 66, 154, 80, 79, - 222, 154, 151, 255, 204, 199, 252, 199, 191, 192, 148, 137, 237, 201, 185, - 255, 232, 214, 224, 198, 175, 221, 194, 167, 234, 204, 178, 226, 191, 169, - 197, 159, 140, 205, 159, 144, 159, 111, 99, 160, 110, 101, 195, 145, 136, - 215, 165, 156, 218, 168, 157, 226, 179, 163, 232, 183, 166, 231, 183, 161, - 234, 184, 159, 234, 183, 156, 228, 177, 148, 205, 154, 127, 195, 144, 117, - 190, 140, 115, 192, 142, 117, 191, 141, 118, 192, 140, 118, 193, 138, 117, - 188, 133, 112, 197, 140, 120, 191, 136, 116, 185, 134, 115, 164, 118, 102, - 171, 132, 117, 191, 159, 146, 116, 89, 78, 41, 24, 17, 53, 47, 47, - 49, 48, 53, 46, 45, 50, 47, 46, 51, 50, 49, 54, 46, 45, 50, - 52, 51, 56, 48, 47, 52, 49, 48, 53, 49, 48, 53, 50, 49, 54, - 50, 49, 54, 50, 49, 54, 50, 49, 54, 50, 49, 54, 50, 49, 54, - 125, 130, 136, 125, 130, 136, 124, 129, 135, 124, 129, 135, 122, 127, 133, - 121, 126, 132, 119, 124, 130, 118, 123, 129, 116, 121, 127, 118, 123, 129, - 120, 125, 131, 123, 128, 134, 128, 133, 139, 136, 141, 147, 147, 152, 158, - 155, 160, 166, 165, 170, 174, 174, 182, 185, 186, 197, 199, 186, 200, 200, - 182, 194, 194, 188, 196, 199, 206, 206, 214, 215, 212, 221, 217, 211, 223, - 204, 201, 212, 190, 189, 197, 190, 191, 196, 165, 165, 165, 108, 107, 103, - 60, 55, 49, 135, 115, 106, 218, 169, 155, 242, 179, 164, 244, 182, 167, - 245, 183, 170, 250, 191, 177, 241, 183, 171, 228, 170, 158, 200, 142, 130, - 204, 146, 134, 202, 144, 130, 215, 158, 141, 219, 160, 142, 216, 155, 136, - 208, 147, 126, 211, 149, 126, 202, 140, 117, 172, 111, 90, 178, 120, 98, - 230, 173, 153, 236, 181, 161, 220, 167, 149, 220, 171, 154, 230, 181, 167, - 225, 177, 163, 224, 176, 164, 217, 169, 157, 222, 172, 163, 227, 177, 168, - 228, 176, 165, 242, 188, 178, 243, 186, 177, 227, 167, 159, 212, 141, 137, - 198, 123, 120, 188, 114, 113, 173, 102, 100, 151, 86, 84, 140, 79, 76, - 169, 114, 109, 155, 105, 98, 195, 151, 142, 255, 221, 210, 255, 232, 220, - 255, 240, 224, 219, 192, 175, 228, 203, 183, 240, 218, 197, 228, 200, 179, - 224, 183, 165, 242, 193, 176, 233, 181, 167, 150, 94, 81, 158, 100, 89, - 176, 117, 109, 193, 134, 126, 206, 149, 140, 219, 165, 155, 220, 168, 155, - 226, 177, 160, 230, 182, 162, 228, 180, 158, 231, 181, 156, 232, 181, 154, - 227, 176, 149, 209, 158, 131, 197, 146, 119, 191, 139, 115, 192, 140, 116, - 192, 140, 118, 193, 141, 120, 193, 138, 117, 188, 133, 112, 197, 142, 121, - 189, 134, 113, 181, 130, 109, 158, 111, 93, 178, 136, 120, 202, 166, 152, - 154, 122, 109, 55, 35, 26, 48, 39, 40, 54, 53, 58, 44, 43, 48, - 46, 45, 50, 51, 50, 55, 46, 45, 50, 49, 48, 53, 48, 47, 52, - 49, 48, 53, 49, 48, 53, 49, 48, 53, 49, 48, 53, 50, 49, 54, - 50, 49, 54, 50, 49, 54, 50, 49, 54, 125, 130, 136, 125, 130, 136, - 125, 130, 136, 124, 129, 135, 123, 128, 134, 122, 127, 133, 120, 125, 131, - 119, 124, 130, 116, 121, 127, 116, 121, 127, 118, 123, 129, 120, 125, 131, - 123, 128, 134, 128, 133, 139, 137, 142, 148, 145, 150, 156, 154, 161, 169, - 161, 170, 175, 176, 187, 191, 185, 196, 198, 183, 193, 194, 186, 194, 196, - 200, 203, 208, 211, 210, 218, 209, 206, 215, 205, 199, 209, 180, 174, 184, - 168, 165, 172, 146, 146, 148, 98, 100, 99, 31, 33, 28, 62, 52, 43, - 157, 120, 111, 221, 171, 160, 240, 190, 179, 224, 174, 165, 221, 173, 163, - 225, 177, 167, 182, 134, 124, 181, 133, 121, 192, 143, 129, 199, 147, 133, - 206, 153, 137, 211, 156, 136, 215, 157, 137, 222, 161, 140, 226, 166, 142, - 212, 150, 125, 169, 109, 85, 202, 141, 120, 231, 173, 153, 216, 161, 141, - 223, 170, 152, 226, 175, 158, 219, 170, 156, 226, 178, 164, 212, 164, 152, - 225, 177, 165, 228, 178, 169, 224, 174, 165, 239, 185, 175, 223, 169, 159, - 194, 137, 128, 191, 128, 121, 189, 111, 109, 171, 90, 89, 142, 68, 67, - 128, 63, 59, 188, 133, 128, 230, 186, 177, 248, 212, 200, 218, 190, 176, - 208, 187, 170, 254, 235, 218, 251, 232, 215, 244, 223, 206, 242, 219, 201, - 233, 206, 189, 237, 208, 190, 228, 189, 174, 193, 136, 125, 193, 129, 120, - 200, 133, 125, 162, 95, 87, 179, 112, 106, 198, 131, 125, 206, 143, 136, - 219, 159, 149, 221, 164, 153, 220, 168, 154, 226, 178, 158, 229, 181, 159, - 226, 178, 155, 227, 180, 154, 230, 178, 154, 224, 173, 146, 211, 160, 133, - 198, 147, 120, 191, 139, 115, 192, 140, 116, 192, 140, 119, 192, 140, 119, - 192, 137, 116, 185, 130, 109, 188, 133, 112, 186, 134, 112, 178, 126, 105, - 155, 107, 87, 185, 142, 123, 202, 163, 146, 183, 147, 133, 99, 72, 63, - 36, 26, 25, 51, 50, 55, 45, 44, 49, 45, 44, 49, 49, 48, 53, - 47, 46, 51, 48, 47, 52, 48, 47, 52, 49, 48, 53, 49, 48, 53, - 49, 48, 53, 49, 48, 53, 49, 48, 53, 50, 49, 54, 50, 49, 54, - 50, 49, 54, 125, 130, 136, 125, 130, 136, 125, 130, 136, 125, 130, 136, - 124, 129, 135, 122, 127, 133, 121, 126, 132, 120, 125, 131, 117, 122, 128, - 116, 121, 127, 116, 121, 127, 118, 123, 129, 119, 124, 130, 123, 128, 134, - 132, 137, 143, 141, 145, 154, 150, 157, 167, 155, 164, 173, 171, 178, 184, - 183, 191, 194, 184, 192, 194, 186, 194, 196, 194, 199, 202, 199, 202, 207, - 203, 204, 209, 189, 188, 194, 166, 161, 168, 154, 149, 156, 125, 123, 128, - 70, 70, 72, 30, 35, 31, 40, 37, 30, 70, 47, 41, 120, 87, 80, - 154, 121, 114, 169, 136, 129, 166, 131, 125, 137, 102, 96, 92, 55, 47, - 104, 66, 57, 181, 141, 131, 191, 147, 134, 191, 144, 128, 204, 153, 134, - 217, 162, 142, 224, 166, 144, 223, 163, 139, 206, 146, 120, 173, 111, 88, - 208, 147, 126, 230, 172, 152, 210, 153, 134, 221, 165, 148, 219, 168, 151, - 203, 154, 140, 208, 160, 146, 216, 168, 156, 207, 159, 149, 227, 177, 168, - 210, 160, 151, 206, 152, 142, 184, 130, 120, 170, 113, 104, 150, 87, 80, - 119, 43, 43, 188, 112, 112, 211, 143, 140, 173, 118, 111, 233, 193, 183, - 255, 241, 227, 252, 235, 219, 243, 232, 214, 209, 201, 182, 232, 224, 205, - 249, 232, 214, 238, 215, 199, 253, 220, 205, 220, 176, 165, 202, 152, 143, - 200, 139, 134, 164, 93, 91, 168, 90, 90, 184, 106, 104, 201, 126, 123, - 206, 132, 129, 201, 130, 124, 206, 139, 131, 224, 164, 153, 220, 164, 149, - 220, 169, 150, 225, 177, 155, 227, 181, 157, 225, 177, 154, 225, 178, 152, - 227, 175, 151, 221, 169, 145, 211, 160, 133, 199, 148, 121, 192, 140, 116, - 193, 141, 117, 194, 139, 119, 194, 139, 119, 191, 134, 115, 183, 126, 106, - 182, 127, 106, 186, 134, 110, 169, 117, 95, 155, 107, 85, 195, 150, 129, - 201, 158, 139, 197, 158, 141, 146, 116, 106, 35, 25, 24, 43, 42, 47, - 48, 47, 52, 44, 43, 48, 45, 44, 49, 47, 46, 51, 48, 47, 52, - 47, 46, 51, 48, 47, 52, 48, 47, 52, 48, 47, 52, 49, 48, 53, - 49, 48, 53, 49, 48, 53, 49, 48, 53, 49, 48, 53, 124, 129, 135, - 124, 129, 135, 125, 130, 136, 125, 130, 136, 124, 129, 135, 123, 128, 134, - 121, 126, 132, 121, 126, 132, 119, 124, 130, 116, 121, 127, 116, 121, 127, - 117, 122, 128, 118, 123, 129, 121, 126, 132, 129, 134, 140, 137, 144, 152, - 149, 157, 168, 154, 160, 172, 169, 173, 182, 183, 186, 193, 187, 191, 194, - 187, 192, 195, 182, 190, 192, 176, 186, 187, 178, 186, 188, 170, 173, 178, - 153, 150, 157, 124, 119, 126, 86, 81, 87, 40, 38, 41, 36, 40, 39, - 42, 42, 40, 43, 33, 31, 31, 16, 13, 33, 15, 13, 50, 32, 28, - 53, 34, 30, 19, 0, 0, 40, 15, 10, 37, 8, 0, 170, 137, 128, - 190, 152, 141, 182, 138, 125, 196, 149, 131, 213, 161, 140, 218, 162, 139, - 217, 159, 135, 216, 156, 130, 191, 129, 106, 203, 143, 119, 232, 171, 152, - 218, 161, 142, 213, 157, 140, 210, 158, 144, 204, 155, 141, 202, 154, 142, - 211, 163, 153, 215, 167, 157, 195, 145, 136, 178, 125, 117, 150, 96, 86, - 142, 85, 76, 139, 80, 72, 200, 140, 132, 189, 126, 121, 219, 160, 154, - 255, 212, 203, 228, 188, 176, 229, 200, 186, 249, 230, 213, 246, 233, 216, - 247, 236, 218, 223, 212, 194, 229, 212, 196, 254, 228, 213, 248, 210, 199, - 230, 180, 171, 182, 121, 116, 149, 78, 76, 165, 87, 87, 184, 104, 107, - 202, 120, 124, 199, 119, 122, 207, 129, 129, 200, 125, 122, 206, 135, 129, - 212, 148, 138, 210, 152, 138, 218, 167, 148, 218, 170, 148, 223, 177, 153, - 225, 179, 155, 223, 176, 150, 226, 176, 151, 226, 174, 150, 221, 169, 145, - 211, 160, 133, 199, 148, 121, 194, 142, 118, 194, 142, 118, 194, 139, 119, - 192, 137, 117, 190, 133, 114, 183, 126, 106, 185, 130, 109, 184, 130, 106, - 157, 105, 83, 165, 115, 92, 202, 156, 133, 205, 160, 139, 204, 161, 144, - 179, 147, 136, 63, 51, 51, 35, 34, 39, 51, 50, 55, 44, 43, 48, - 44, 43, 48, 46, 45, 50, 48, 47, 52, 46, 45, 50, 48, 47, 52, - 48, 47, 52, 48, 47, 52, 48, 47, 52, 49, 48, 53, 49, 48, 53, - 49, 48, 53, 49, 48, 53, 124, 129, 135, 124, 129, 135, 124, 129, 135, - 124, 129, 135, 124, 129, 135, 123, 128, 134, 122, 127, 133, 121, 126, 132, - 120, 125, 131, 117, 122, 128, 116, 121, 127, 118, 123, 129, 118, 123, 129, - 120, 125, 131, 128, 133, 139, 135, 142, 150, 149, 157, 168, 153, 159, 173, - 170, 170, 182, 186, 183, 192, 193, 191, 196, 190, 191, 193, 172, 182, 181, - 152, 167, 164, 142, 157, 154, 140, 150, 151, 125, 126, 131, 78, 73, 80, - 48, 41, 48, 37, 30, 37, 37, 37, 39, 36, 38, 37, 36, 36, 36, - 37, 37, 35, 36, 35, 33, 30, 26, 25, 36, 31, 28, 36, 26, 24, - 58, 45, 39, 14, 0, 0, 131, 106, 99, 189, 156, 147, 187, 149, 136, - 193, 147, 131, 205, 154, 135, 216, 161, 140, 221, 163, 141, 227, 167, 143, - 214, 152, 129, 208, 148, 124, 231, 170, 151, 223, 166, 147, 216, 160, 143, - 199, 147, 133, 187, 138, 124, 186, 136, 125, 190, 142, 132, 177, 129, 119, - 151, 101, 92, 138, 85, 77, 100, 46, 36, 135, 78, 69, 172, 113, 105, - 247, 195, 184, 242, 204, 191, 209, 180, 164, 253, 225, 211, 255, 235, 220, - 230, 207, 191, 240, 219, 202, 255, 233, 219, 247, 221, 208, 247, 215, 204, - 232, 192, 184, 223, 173, 166, 184, 123, 120, 158, 86, 87, 171, 91, 94, - 195, 106, 110, 224, 135, 141, 207, 125, 131, 208, 129, 134, 202, 126, 128, - 214, 140, 139, 216, 145, 141, 211, 144, 135, 210, 151, 137, 208, 155, 137, - 217, 171, 148, 217, 173, 148, 221, 177, 152, 221, 177, 150, 219, 173, 147, - 224, 174, 149, 227, 175, 153, 224, 170, 146, 212, 161, 134, 201, 150, 123, - 197, 143, 119, 196, 142, 118, 194, 137, 118, 192, 135, 116, 190, 133, 114, - 185, 128, 108, 187, 130, 110, 175, 121, 97, 153, 101, 77, 182, 132, 109, - 202, 154, 132, 209, 162, 142, 211, 164, 146, 197, 163, 151, 114, 103, 101, - 32, 31, 36, 50, 49, 54, 44, 43, 48, 45, 44, 49, 45, 44, 49, - 48, 47, 52, 46, 45, 50, 48, 47, 52, 48, 47, 52, 48, 47, 52, - 48, 47, 52, 48, 47, 52, 48, 47, 52, 49, 48, 53, 49, 48, 53, - 123, 128, 134, 124, 129, 135, 124, 129, 135, 124, 129, 135, 124, 129, 135, - 123, 128, 134, 122, 127, 133, 121, 126, 132, 121, 126, 132, 118, 123, 129, - 117, 122, 128, 120, 125, 131, 120, 125, 131, 120, 125, 131, 127, 132, 138, - 136, 140, 149, 148, 156, 167, 152, 158, 170, 169, 169, 181, 186, 183, 192, - 195, 192, 199, 192, 193, 195, 168, 178, 177, 141, 156, 153, 122, 137, 134, - 109, 119, 120, 90, 91, 95, 46, 44, 49, 38, 31, 38, 48, 41, 48, - 31, 29, 32, 34, 35, 37, 32, 36, 37, 26, 32, 32, 26, 32, 32, - 27, 33, 33, 32, 36, 35, 37, 37, 35, 34, 29, 26, 34, 23, 21, - 80, 61, 57, 183, 156, 149, 201, 164, 155, 194, 150, 137, 202, 151, 134, - 219, 164, 143, 220, 162, 138, 217, 157, 131, 228, 168, 144, 222, 161, 140, - 227, 169, 147, 223, 165, 145, 227, 170, 151, 189, 133, 116, 146, 93, 79, - 149, 97, 84, 147, 97, 86, 109, 59, 50, 79, 29, 22, 43, 0, 0, - 137, 84, 76, 210, 157, 149, 244, 189, 182, 241, 194, 184, 244, 215, 199, - 222, 199, 181, 234, 208, 193, 243, 215, 201, 234, 205, 191, 245, 211, 199, - 251, 213, 204, 243, 198, 192, 219, 166, 162, 160, 100, 99, 158, 90, 91, - 177, 101, 103, 203, 121, 125, 211, 122, 128, 215, 122, 130, 211, 120, 127, - 216, 136, 139, 207, 133, 134, 207, 135, 136, 207, 137, 135, 215, 148, 140, - 203, 141, 130, 206, 150, 135, 213, 162, 143, 219, 173, 150, 218, 174, 149, - 220, 176, 151, 220, 174, 148, 218, 171, 145, 223, 173, 148, 227, 175, 151, - 224, 172, 148, 213, 162, 135, 202, 151, 124, 196, 144, 120, 196, 141, 120, - 192, 137, 116, 190, 135, 115, 190, 135, 115, 186, 131, 110, 183, 128, 107, - 166, 112, 88, 155, 103, 79, 197, 147, 124, 200, 150, 127, 212, 164, 142, - 216, 168, 148, 209, 172, 156, 160, 141, 135, 38, 29, 30, 51, 47, 48, - 44, 42, 45, 47, 46, 51, 43, 44, 49, 46, 47, 52, 46, 47, 52, - 47, 46, 51, 48, 47, 52, 49, 47, 50, 49, 47, 50, 49, 47, 50, - 48, 47, 52, 48, 47, 52, 47, 48, 52, 124, 127, 134, 124, 127, 134, - 125, 128, 135, 125, 128, 135, 125, 128, 135, 125, 128, 135, 124, 127, 134, - 124, 127, 134, 122, 125, 132, 120, 123, 130, 119, 122, 129, 120, 123, 130, - 121, 124, 131, 121, 124, 131, 126, 129, 136, 131, 136, 142, 147, 151, 162, - 157, 161, 172, 167, 170, 179, 181, 184, 191, 187, 190, 197, 185, 188, 193, - 172, 177, 181, 145, 150, 153, 122, 127, 130, 100, 104, 107, 71, 72, 76, - 42, 41, 46, 37, 35, 40, 40, 38, 41, 34, 34, 36, 36, 36, 38, - 33, 32, 37, 34, 33, 38, 32, 36, 39, 32, 37, 40, 31, 40, 39, - 34, 40, 40, 40, 41, 43, 47, 41, 43, 21, 5, 6, 169, 143, 144, - 196, 158, 155, 204, 160, 151, 208, 156, 142, 213, 156, 136, 212, 155, 128, - 220, 163, 134, 225, 169, 144, 225, 169, 146, 234, 176, 154, 236, 178, 156, - 231, 170, 149, 216, 155, 136, 164, 102, 87, 94, 36, 22, 74, 17, 6, - 65, 12, 4, 75, 24, 20, 49, 2, 0, 127, 82, 77, 215, 170, 165, - 238, 193, 187, 236, 193, 184, 231, 193, 182, 236, 198, 185, 220, 177, 168, - 237, 190, 182, 214, 163, 159, 189, 134, 131, 214, 152, 153, 182, 113, 116, - 164, 92, 96, 186, 109, 115, 204, 123, 130, 216, 134, 140, 227, 142, 149, - 222, 137, 144, 214, 127, 135, 213, 131, 135, 216, 142, 141, 207, 140, 134, - 208, 141, 135, 211, 147, 138, 208, 145, 136, 200, 142, 130, 206, 150, 135, - 216, 165, 146, 220, 169, 148, 220, 172, 149, 220, 172, 149, 218, 170, 147, - 219, 169, 144, 222, 172, 147, 226, 174, 150, 226, 174, 150, 216, 164, 140, - 198, 148, 123, 187, 137, 114, 190, 138, 116, 194, 142, 120, 189, 137, 115, - 184, 132, 110, 183, 131, 109, 174, 122, 100, 153, 101, 79, 180, 130, 107, - 196, 146, 123, 205, 155, 132, 221, 171, 148, 213, 162, 141, 213, 170, 151, - 189, 160, 146, 105, 85, 76, 37, 23, 20, 48, 42, 42, 45, 44, 50, - 40, 44, 53, 49, 53, 62, 37, 41, 50, 45, 46, 51, 47, 45, 48, - 50, 46, 47, 51, 45, 45, 51, 47, 48, 49, 47, 50, 48, 49, 54, - 46, 49, 54, 123, 126, 133, 124, 127, 134, 125, 128, 135, 125, 128, 135, - 125, 128, 135, 125, 128, 135, 125, 128, 135, 124, 127, 134, 122, 125, 132, - 120, 123, 130, 120, 123, 130, 121, 124, 131, 121, 124, 131, 122, 125, 132, - 126, 129, 136, 130, 133, 140, 141, 145, 154, 154, 158, 167, 163, 168, 174, - 173, 178, 184, 175, 180, 186, 174, 179, 185, 168, 171, 176, 145, 148, 153, - 121, 122, 126, 87, 88, 92, 60, 59, 64, 41, 40, 45, 38, 38, 40, - 40, 40, 42, 38, 38, 40, 42, 42, 44, 43, 40, 47, 42, 41, 47, - 38, 42, 45, 36, 41, 44, 32, 42, 43, 33, 41, 43, 38, 42, 45, - 43, 41, 44, 27, 12, 17, 98, 73, 76, 197, 161, 161, 203, 160, 154, - 211, 162, 148, 217, 162, 142, 210, 153, 126, 219, 162, 133, 222, 168, 142, - 227, 175, 151, 246, 190, 165, 250, 192, 168, 245, 183, 160, 240, 178, 155, - 217, 154, 136, 177, 115, 100, 170, 112, 100, 161, 107, 97, 124, 73, 69, - 95, 47, 43, 95, 50, 45, 172, 129, 123, 188, 145, 139, 221, 176, 170, - 212, 163, 156, 212, 159, 151, 186, 128, 124, 175, 114, 111, 165, 99, 100, - 163, 91, 94, 188, 111, 117, 194, 113, 120, 217, 131, 140, 224, 137, 146, - 229, 142, 151, 230, 143, 151, 228, 141, 149, 221, 136, 143, 218, 136, 142, - 221, 142, 145, 207, 138, 133, 201, 138, 129, 202, 139, 130, 202, 142, 131, - 202, 144, 132, 203, 147, 132, 211, 155, 138, 218, 165, 147, 221, 170, 149, - 223, 172, 151, 223, 173, 150, 221, 171, 148, 222, 172, 147, 224, 174, 149, - 226, 175, 148, 226, 175, 148, 215, 165, 142, 201, 151, 128, 190, 140, 117, - 191, 141, 118, 192, 142, 119, 188, 138, 115, 183, 133, 110, 181, 131, 108, - 156, 106, 83, 163, 113, 90, 187, 137, 114, 196, 146, 123, 211, 161, 138, - 224, 174, 151, 215, 165, 142, 216, 169, 149, 207, 170, 152, 148, 120, 108, - 40, 21, 14, 55, 45, 44, 45, 44, 49, 39, 43, 52, 37, 44, 54, - 44, 51, 61, 45, 46, 51, 47, 45, 48, 50, 44, 44, 51, 45, 45, - 51, 47, 48, 49, 47, 50, 48, 49, 54, 46, 49, 56, 123, 126, 133, - 124, 127, 134, 124, 127, 134, 125, 128, 135, 125, 128, 135, 125, 128, 135, - 125, 128, 135, 124, 127, 134, 122, 125, 132, 121, 124, 131, 121, 124, 131, - 122, 125, 132, 122, 125, 132, 122, 125, 132, 124, 127, 134, 127, 130, 137, - 137, 141, 150, 153, 157, 166, 162, 167, 173, 165, 170, 176, 162, 165, 172, - 162, 165, 172, 159, 162, 167, 139, 142, 147, 108, 109, 114, 66, 67, 72, - 45, 46, 50, 41, 42, 46, 42, 42, 44, 45, 45, 47, 45, 45, 47, - 48, 48, 50, 47, 46, 52, 46, 45, 51, 41, 45, 48, 37, 42, 45, - 34, 39, 42, 34, 39, 42, 36, 40, 43, 41, 39, 42, 41, 30, 34, - 40, 20, 21, 169, 139, 137, 205, 166, 159, 211, 165, 152, 216, 163, 145, - 211, 153, 129, 215, 158, 131, 217, 166, 139, 220, 170, 145, 236, 182, 156, - 244, 188, 161, 245, 185, 159, 249, 189, 165, 243, 182, 163, 222, 163, 145, - 209, 151, 137, 216, 162, 150, 210, 160, 153, 187, 138, 133, 165, 116, 111, - 165, 116, 111, 161, 112, 107, 174, 124, 117, 171, 112, 106, 190, 125, 121, - 197, 129, 126, 195, 124, 122, 207, 131, 133, 210, 130, 133, 209, 124, 131, - 230, 143, 151, 232, 142, 151, 230, 139, 148, 234, 143, 152, 239, 150, 156, - 231, 144, 150, 219, 134, 139, 211, 129, 133, 206, 128, 128, 205, 138, 130, - 203, 141, 130, 204, 142, 131, 201, 141, 130, 204, 146, 134, 211, 155, 140, - 219, 163, 146, 221, 168, 150, 221, 170, 149, 223, 172, 151, 223, 173, 150, - 223, 173, 150, 224, 174, 149, 226, 176, 151, 225, 175, 148, 223, 173, 146, - 215, 165, 142, 203, 153, 130, 193, 143, 120, 190, 140, 117, 191, 141, 118, - 186, 136, 113, 179, 129, 106, 174, 124, 101, 149, 99, 76, 175, 125, 102, - 191, 141, 118, 202, 152, 129, 220, 170, 147, 224, 174, 151, 218, 168, 145, - 220, 174, 151, 210, 172, 153, 193, 161, 146, 80, 57, 49, 43, 29, 28, - 46, 44, 49, 43, 46, 55, 40, 47, 57, 42, 46, 55, 43, 46, 51, - 46, 46, 48, 49, 45, 46, 50, 46, 45, 50, 46, 47, 49, 47, 50, - 48, 47, 52, 48, 49, 54, 123, 126, 133, 123, 126, 133, 124, 127, 134, - 125, 128, 135, 125, 128, 135, 125, 128, 135, 125, 128, 135, 125, 128, 135, - 122, 125, 132, 122, 125, 132, 122, 125, 132, 122, 125, 132, 122, 125, 132, - 122, 125, 132, 123, 126, 133, 124, 127, 134, 134, 138, 147, 151, 155, 164, - 158, 163, 169, 156, 161, 167, 150, 153, 160, 149, 152, 159, 146, 149, 154, - 125, 128, 133, 91, 92, 97, 53, 54, 59, 43, 44, 48, 47, 48, 52, - 48, 48, 50, 53, 53, 55, 54, 54, 56, 53, 52, 57, 47, 46, 52, - 45, 46, 51, 43, 44, 49, 38, 42, 45, 35, 39, 42, 35, 39, 42, - 39, 40, 44, 41, 41, 43, 57, 51, 53, 40, 26, 26, 115, 91, 89, - 199, 166, 159, 207, 165, 153, 211, 160, 143, 218, 160, 140, 213, 155, 131, - 217, 165, 141, 215, 168, 142, 228, 177, 150, 239, 185, 157, 244, 187, 160, - 247, 189, 165, 244, 186, 164, 233, 176, 156, 226, 170, 155, 228, 175, 161, - 241, 189, 178, 223, 170, 162, 222, 169, 163, 189, 136, 130, 192, 139, 133, - 188, 129, 123, 200, 132, 129, 212, 138, 137, 215, 139, 139, 208, 130, 130, - 219, 137, 141, 223, 138, 143, 215, 128, 134, 236, 147, 153, 235, 144, 153, - 217, 128, 134, 215, 126, 132, 222, 136, 139, 220, 135, 138, 215, 133, 135, - 212, 132, 133, 204, 130, 127, 208, 141, 132, 203, 143, 132, 204, 144, 133, - 205, 147, 133, 210, 152, 138, 216, 160, 143, 219, 166, 148, 221, 169, 148, - 220, 169, 148, 221, 171, 148, 223, 173, 150, 223, 173, 148, 225, 175, 150, - 227, 177, 152, 225, 175, 148, 222, 172, 147, 214, 164, 141, 203, 153, 130, - 192, 142, 119, 188, 138, 115, 188, 138, 115, 182, 132, 109, 171, 121, 98, - 162, 112, 89, 160, 110, 87, 179, 129, 106, 190, 140, 117, 212, 162, 139, - 227, 177, 154, 220, 170, 147, 222, 172, 149, 223, 175, 153, 209, 167, 145, - 208, 173, 154, 142, 115, 106, 36, 21, 16, 49, 43, 47, 45, 45, 53, - 45, 49, 58, 37, 41, 50, 42, 45, 50, 44, 45, 49, 47, 45, 46, - 49, 45, 46, 50, 46, 47, 49, 47, 50, 48, 47, 52, 47, 48, 53, - 123, 126, 133, 123, 126, 133, 124, 127, 134, 125, 128, 135, 125, 128, 135, - 125, 128, 135, 125, 128, 135, 125, 128, 135, 122, 125, 132, 122, 125, 132, - 122, 125, 132, 122, 125, 132, 122, 125, 132, 122, 125, 132, 121, 124, 131, - 120, 123, 130, 128, 133, 139, 142, 147, 153, 147, 152, 158, 146, 151, 157, - 141, 144, 151, 139, 142, 149, 133, 136, 141, 110, 113, 118, 74, 75, 80, - 51, 52, 57, 50, 51, 55, 53, 54, 58, 51, 50, 55, 58, 57, 62, - 58, 57, 62, 52, 51, 56, 47, 48, 53, 47, 48, 53, 45, 46, 51, - 44, 45, 50, 44, 45, 49, 45, 46, 50, 48, 49, 53, 51, 52, 54, - 64, 64, 64, 61, 56, 53, 75, 60, 57, 167, 142, 135, 203, 165, 154, - 210, 162, 148, 222, 163, 147, 217, 159, 139, 209, 159, 136, 211, 164, 138, - 224, 174, 147, 235, 184, 157, 240, 184, 157, 241, 185, 158, 244, 188, 163, - 245, 189, 166, 226, 170, 153, 232, 179, 163, 234, 180, 168, 245, 191, 181, - 241, 184, 177, 229, 172, 163, 217, 158, 150, 206, 141, 135, 201, 127, 124, - 208, 130, 128, 215, 135, 134, 224, 143, 142, 230, 148, 150, 232, 147, 150, - 228, 142, 145, 224, 138, 141, 225, 138, 144, 211, 126, 129, 211, 129, 131, - 222, 142, 141, 218, 143, 140, 213, 139, 136, 211, 140, 136, 208, 139, 132, - 205, 143, 132, 200, 141, 127, 203, 144, 130, 210, 152, 138, 215, 157, 143, - 215, 159, 142, 215, 162, 144, 219, 167, 146, 219, 168, 147, 222, 172, 149, - 225, 175, 152, 226, 176, 151, 227, 177, 152, 228, 178, 151, 227, 177, 150, - 224, 174, 149, 215, 165, 142, 203, 152, 131, 190, 139, 118, 186, 135, 114, - 185, 134, 113, 177, 126, 105, 164, 113, 92, 154, 103, 82, 171, 120, 99, - 181, 130, 109, 194, 143, 122, 220, 169, 148, 225, 174, 153, 221, 170, 149, - 228, 177, 156, 212, 164, 142, 214, 168, 145, 204, 166, 145, 181, 151, 140, - 73, 53, 46, 41, 31, 32, 48, 46, 51, 34, 37, 44, 45, 49, 58, - 42, 45, 50, 44, 45, 49, 46, 44, 47, 47, 45, 48, 48, 46, 49, - 48, 46, 49, 48, 47, 52, 48, 47, 52, 122, 125, 132, 123, 126, 133, - 124, 127, 134, 125, 128, 135, 125, 128, 135, 126, 129, 136, 125, 128, 135, - 125, 128, 135, 123, 126, 133, 123, 126, 133, 123, 126, 133, 121, 124, 131, - 121, 124, 131, 122, 125, 132, 121, 124, 131, 119, 122, 129, 123, 128, 134, - 132, 137, 143, 135, 140, 146, 137, 142, 148, 134, 137, 144, 129, 132, 139, - 120, 123, 128, 97, 100, 105, 58, 59, 64, 49, 50, 55, 54, 55, 59, - 52, 53, 57, 50, 49, 54, 57, 56, 61, 55, 54, 59, 49, 50, 54, - 50, 53, 60, 50, 53, 60, 54, 53, 59, 54, 53, 59, 57, 55, 60, - 59, 58, 63, 61, 62, 66, 62, 66, 69, 68, 72, 73, 72, 72, 70, - 74, 66, 63, 126, 107, 101, 191, 158, 149, 211, 167, 156, 218, 162, 149, - 224, 165, 149, 210, 159, 138, 206, 158, 135, 210, 160, 135, 220, 169, 142, - 232, 178, 150, 240, 184, 157, 244, 188, 163, 246, 192, 168, 246, 194, 173, - 245, 192, 174, 234, 181, 167, 241, 188, 174, 230, 173, 162, 238, 178, 168, - 234, 171, 162, 229, 162, 154, 222, 151, 145, 216, 141, 138, 207, 132, 129, - 213, 135, 133, 209, 131, 129, 208, 130, 130, 217, 137, 138, 203, 125, 125, - 207, 129, 129, 205, 131, 128, 215, 141, 138, 219, 150, 143, 211, 144, 136, - 200, 136, 126, 196, 133, 124, 196, 136, 125, 204, 145, 131, 201, 143, 129, - 205, 147, 133, 214, 158, 143, 219, 163, 146, 215, 162, 144, 217, 165, 144, - 221, 169, 148, 221, 171, 148, 225, 175, 152, 229, 179, 154, 229, 179, 154, - 229, 179, 152, 229, 179, 152, 228, 178, 151, 226, 176, 151, 216, 166, 143, - 202, 151, 130, 189, 138, 117, 185, 134, 113, 180, 129, 108, 169, 118, 97, - 160, 109, 88, 156, 105, 84, 173, 122, 101, 188, 137, 116, 205, 154, 133, - 221, 170, 149, 222, 171, 150, 226, 175, 154, 230, 179, 158, 202, 151, 130, - 213, 165, 142, 215, 170, 149, 199, 163, 147, 127, 103, 93, 31, 17, 14, - 57, 51, 53, 30, 31, 36, 47, 50, 57, 41, 44, 49, 44, 45, 50, - 45, 44, 49, 47, 45, 48, 47, 45, 48, 48, 46, 49, 47, 46, 51, - 47, 46, 51, 122, 125, 132, 123, 126, 133, 124, 127, 134, 125, 128, 135, - 125, 128, 135, 126, 129, 136, 126, 129, 136, 125, 128, 135, 124, 127, 134, - 125, 128, 135, 123, 126, 133, 121, 124, 131, 122, 125, 132, 124, 127, 134, - 122, 125, 132, 119, 122, 129, 121, 124, 131, 125, 128, 135, 124, 127, 134, - 127, 130, 137, 120, 123, 130, 109, 112, 119, 96, 99, 106, 74, 77, 84, - 50, 51, 56, 47, 48, 53, 53, 54, 59, 51, 52, 57, 52, 53, 58, - 59, 60, 65, 57, 58, 62, 60, 61, 65, 61, 64, 71, 62, 65, 72, - 67, 66, 72, 69, 66, 73, 74, 69, 75, 75, 73, 78, 76, 77, 81, - 76, 81, 84, 77, 85, 87, 79, 85, 83, 90, 91, 86, 100, 89, 83, - 161, 134, 127, 202, 162, 154, 210, 158, 147, 223, 165, 153, 223, 170, 152, - 214, 163, 142, 206, 156, 133, 210, 158, 134, 226, 172, 146, 236, 182, 154, - 240, 186, 158, 240, 189, 162, 249, 197, 175, 242, 191, 170, 249, 198, 179, - 244, 191, 175, 241, 185, 172, 237, 178, 164, 240, 178, 165, 233, 169, 157, - 231, 167, 157, 224, 160, 151, 217, 153, 144, 217, 150, 142, 212, 145, 137, - 210, 143, 137, 214, 147, 141, 204, 139, 133, 205, 140, 134, 204, 144, 134, - 201, 141, 131, 194, 138, 125, 188, 135, 121, 184, 133, 116, 187, 138, 123, - 199, 148, 131, 206, 150, 135, 209, 153, 138, 213, 157, 140, 218, 162, 145, - 221, 165, 148, 221, 168, 150, 223, 171, 150, 223, 172, 151, 224, 174, 151, - 229, 179, 156, 231, 184, 158, 230, 183, 157, 227, 180, 152, 226, 179, 151, - 225, 178, 150, 224, 177, 151, 215, 165, 142, 200, 149, 128, 188, 137, 116, - 182, 131, 110, 173, 122, 101, 160, 109, 88, 158, 107, 86, 165, 114, 93, - 175, 124, 103, 197, 146, 125, 214, 163, 142, 220, 169, 148, 223, 172, 151, - 227, 176, 155, 225, 174, 153, 209, 159, 136, 214, 162, 138, 223, 175, 152, - 205, 167, 148, 172, 142, 131, 61, 42, 36, 49, 39, 38, 43, 41, 44, - 42, 43, 48, 41, 44, 49, 41, 44, 49, 44, 45, 49, 45, 44, 49, - 47, 45, 48, 48, 46, 49, 48, 46, 51, 48, 46, 51, 122, 125, 132, - 123, 126, 133, 124, 127, 134, 125, 128, 135, 126, 129, 136, 126, 129, 136, - 126, 129, 136, 126, 129, 136, 126, 129, 136, 126, 129, 136, 124, 127, 134, - 122, 125, 132, 122, 125, 132, 125, 128, 135, 123, 126, 133, 120, 123, 130, - 118, 121, 128, 118, 121, 128, 114, 117, 124, 115, 118, 125, 104, 107, 114, - 86, 89, 96, 72, 75, 82, 51, 54, 61, 50, 51, 56, 50, 51, 56, - 54, 55, 60, 54, 55, 60, 60, 61, 66, 67, 68, 73, 67, 68, 72, - 75, 78, 83, 73, 78, 84, 76, 79, 86, 80, 79, 85, 83, 80, 87, - 88, 81, 88, 90, 85, 91, 89, 90, 94, 88, 93, 96, 89, 99, 100, - 90, 100, 99, 100, 104, 103, 96, 91, 87, 130, 111, 105, 186, 151, 145, - 205, 156, 151, 214, 160, 150, 218, 166, 152, 218, 167, 148, 212, 160, 139, - 207, 155, 133, 213, 159, 133, 220, 166, 138, 228, 177, 148, 239, 188, 161, - 243, 193, 168, 234, 186, 163, 247, 199, 177, 248, 197, 178, 238, 185, 167, - 240, 183, 166, 238, 179, 163, 237, 178, 162, 226, 168, 154, 224, 168, 155, - 223, 167, 154, 216, 159, 148, 213, 156, 145, 210, 153, 142, 205, 148, 139, - 209, 152, 141, 202, 148, 136, 204, 152, 139, 196, 147, 132, 192, 143, 128, - 197, 150, 132, 196, 151, 132, 192, 149, 130, 200, 155, 136, 206, 155, 138, - 214, 161, 145, 219, 163, 146, 216, 163, 145, 218, 165, 147, 224, 171, 153, - 225, 174, 153, 222, 171, 150, 225, 175, 152, 231, 181, 158, 233, 186, 160, - 230, 183, 157, 226, 179, 153, 223, 176, 148, 223, 176, 148, 223, 176, 150, - 213, 163, 140, 198, 147, 126, 186, 135, 114, 180, 129, 108, 167, 116, 95, - 152, 101, 80, 157, 106, 85, 172, 121, 100, 180, 129, 108, 203, 152, 131, - 216, 165, 144, 220, 169, 148, 227, 176, 155, 224, 173, 152, 218, 167, 146, - 226, 176, 153, 223, 169, 143, 218, 166, 142, 206, 164, 142, 199, 166, 151, - 114, 91, 83, 24, 10, 7, 56, 50, 50, 42, 42, 44, 43, 44, 48, - 43, 44, 48, 44, 45, 49, 44, 45, 49, 46, 46, 48, 47, 45, 48, - 48, 46, 51, 48, 46, 51, 123, 126, 133, 123, 126, 133, 124, 127, 134, - 126, 129, 136, 127, 130, 137, 127, 130, 137, 127, 130, 137, 127, 130, 137, - 125, 128, 135, 125, 128, 135, 124, 127, 134, 123, 126, 133, 123, 126, 133, - 123, 126, 133, 123, 126, 133, 123, 126, 133, 115, 118, 125, 110, 113, 120, - 105, 108, 115, 98, 101, 108, 84, 87, 94, 65, 68, 75, 53, 56, 63, - 49, 52, 59, 54, 54, 62, 57, 57, 65, 62, 63, 68, 66, 67, 72, - 71, 72, 77, 76, 77, 82, 80, 81, 86, 81, 84, 89, 84, 89, 95, - 85, 90, 96, 90, 89, 95, 94, 91, 98, 100, 93, 100, 103, 98, 104, - 102, 103, 108, 101, 106, 110, 99, 110, 112, 103, 115, 115, 108, 117, 116, - 108, 108, 106, 119, 105, 102, 156, 128, 124, 195, 154, 150, 208, 159, 154, - 211, 161, 150, 218, 166, 152, 220, 167, 149, 214, 159, 139, 209, 153, 130, - 212, 158, 132, 220, 169, 142, 226, 176, 149, 236, 189, 163, 238, 192, 168, - 244, 198, 175, 249, 203, 180, 248, 200, 178, 244, 192, 171, 240, 185, 165, - 235, 183, 162, 227, 178, 161, 223, 176, 158, 218, 169, 152, 214, 165, 150, - 212, 163, 148, 209, 160, 145, 206, 157, 143, 204, 155, 141, 206, 158, 144, - 205, 158, 142, 203, 157, 141, 202, 156, 140, 201, 156, 137, 201, 158, 139, - 203, 161, 139, 207, 162, 141, 213, 165, 145, 219, 168, 149, 222, 169, 151, - 221, 170, 151, 220, 169, 150, 221, 170, 151, 224, 173, 152, 227, 176, 155, - 231, 181, 158, 231, 181, 158, 231, 183, 160, 232, 185, 159, 230, 183, 157, - 225, 178, 152, 221, 175, 149, 221, 175, 149, 206, 158, 135, 191, 143, 121, - 180, 132, 110, 166, 118, 96, 155, 107, 85, 153, 105, 83, 155, 107, 85, - 169, 121, 99, 190, 142, 120, 206, 158, 136, 216, 168, 146, 219, 171, 149, - 222, 174, 152, 223, 175, 153, 222, 174, 152, 225, 175, 152, 226, 170, 143, - 218, 164, 138, 213, 167, 144, 206, 169, 151, 156, 128, 116, 14, 0, 0, - 44, 34, 32, 34, 30, 29, 36, 36, 38, 50, 51, 55, 39, 40, 44, - 43, 44, 48, 48, 47, 52, 42, 41, 46, 49, 47, 52, 45, 43, 48, - 122, 125, 132, 123, 126, 133, 124, 127, 134, 125, 128, 135, 126, 129, 136, - 126, 129, 136, 126, 129, 136, 126, 129, 136, 125, 128, 135, 125, 128, 135, - 125, 128, 135, 124, 127, 134, 123, 126, 133, 123, 126, 133, 122, 125, 132, - 122, 125, 132, 115, 118, 125, 108, 111, 118, 99, 102, 109, 90, 93, 100, - 78, 81, 88, 65, 68, 75, 58, 61, 68, 59, 62, 69, 67, 67, 75, - 69, 69, 77, 73, 74, 79, 77, 78, 83, 81, 82, 87, 85, 86, 91, - 88, 89, 94, 89, 92, 99, 92, 96, 105, 93, 97, 106, 101, 100, 108, - 105, 102, 109, 111, 106, 113, 112, 110, 115, 113, 114, 119, 111, 116, 120, - 109, 120, 122, 102, 116, 117, 108, 118, 119, 116, 118, 117, 118, 108, 107, - 131, 111, 110, 167, 136, 133, 201, 160, 156, 206, 159, 153, 211, 161, 150, - 218, 166, 152, 219, 166, 148, 213, 158, 137, 205, 151, 127, 206, 154, 130, - 215, 165, 138, 226, 179, 153, 232, 186, 162, 238, 193, 170, 238, 193, 170, - 239, 193, 170, 240, 192, 169, 241, 191, 168, 236, 188, 165, 233, 186, 166, - 229, 184, 165, 225, 180, 161, 222, 177, 158, 220, 174, 158, 219, 173, 157, - 219, 171, 157, 218, 170, 156, 218, 171, 155, 218, 171, 155, 215, 169, 153, - 212, 166, 150, 210, 165, 146, 210, 163, 145, 211, 164, 144, 212, 165, 145, - 215, 167, 147, 220, 169, 150, 222, 171, 152, 223, 172, 153, 223, 172, 153, - 225, 174, 155, 228, 177, 156, 230, 179, 158, 234, 183, 162, 235, 185, 162, - 233, 185, 162, 232, 184, 161, 228, 180, 157, 222, 176, 150, 218, 172, 146, - 216, 170, 146, 200, 152, 130, 185, 137, 115, 174, 126, 104, 159, 111, 89, - 153, 105, 83, 156, 108, 86, 160, 112, 90, 172, 124, 102, 198, 150, 128, - 212, 164, 142, 219, 171, 149, 219, 171, 149, 222, 174, 152, 222, 174, 152, - 220, 172, 150, 223, 173, 150, 226, 170, 145, 224, 168, 143, 211, 163, 140, - 213, 172, 152, 190, 158, 143, 93, 71, 58, 11, 0, 0, 26, 18, 15, - 26, 22, 21, 32, 32, 32, 44, 44, 46, 45, 46, 50, 41, 40, 45, - 41, 40, 45, 45, 43, 48, 45, 43, 48, 121, 124, 131, 122, 125, 132, - 123, 126, 133, 124, 127, 134, 125, 128, 135, 125, 128, 135, 125, 128, 135, - 125, 128, 135, 125, 128, 135, 125, 128, 135, 125, 128, 135, 125, 128, 135, - 124, 127, 134, 122, 125, 132, 121, 124, 131, 120, 123, 130, 116, 116, 124, - 107, 107, 115, 97, 97, 105, 88, 88, 96, 79, 79, 87, 70, 70, 78, - 69, 69, 77, 72, 72, 80, 77, 77, 85, 79, 79, 87, 83, 83, 91, - 87, 87, 95, 90, 90, 98, 94, 94, 102, 97, 97, 105, 97, 100, 107, - 100, 104, 113, 104, 107, 116, 110, 110, 118, 116, 113, 120, 119, 116, 123, - 120, 117, 124, 119, 120, 125, 116, 121, 125, 115, 124, 129, 108, 119, 121, - 109, 119, 121, 117, 121, 124, 118, 114, 115, 116, 102, 102, 137, 116, 115, - 175, 144, 141, 200, 159, 155, 204, 157, 151, 207, 159, 147, 214, 162, 148, - 217, 164, 146, 213, 161, 139, 208, 156, 132, 204, 154, 129, 214, 166, 143, - 224, 178, 154, 230, 185, 162, 228, 183, 160, 228, 184, 159, 235, 189, 165, - 238, 192, 168, 237, 189, 166, 236, 190, 167, 234, 187, 167, 230, 183, 163, - 228, 181, 161, 226, 179, 161, 226, 179, 161, 227, 178, 163, 227, 178, 163, - 224, 175, 160, 225, 176, 161, 227, 175, 161, 226, 174, 160, 225, 174, 157, - 226, 173, 157, 226, 173, 157, 227, 174, 158, 222, 171, 154, 221, 172, 155, - 222, 173, 156, 224, 175, 158, 228, 177, 158, 230, 179, 160, 231, 180, 161, - 232, 181, 160, 235, 187, 165, 236, 188, 166, 236, 188, 166, 233, 185, 162, - 228, 182, 158, 223, 177, 153, 216, 170, 146, 212, 166, 142, 194, 146, 124, - 177, 129, 107, 165, 117, 95, 153, 105, 83, 152, 104, 82, 160, 112, 90, - 167, 119, 97, 179, 131, 109, 205, 157, 135, 215, 167, 145, 219, 171, 149, - 218, 170, 148, 221, 173, 151, 222, 174, 152, 219, 171, 149, 221, 171, 148, - 218, 162, 137, 227, 171, 146, 211, 161, 138, 204, 162, 140, 202, 167, 148, - 159, 131, 117, 17, 0, 0, 19, 6, 0, 14, 6, 3, 5, 1, 0, - 30, 30, 30, 42, 41, 46, 42, 41, 46, 47, 46, 52, 42, 41, 47, - 46, 45, 51, 121, 124, 131, 122, 125, 132, 123, 126, 133, 124, 127, 134, - 125, 128, 135, 125, 128, 135, 125, 128, 135, 125, 128, 135, 125, 128, 135, - 125, 128, 135, 125, 128, 135, 125, 128, 135, 123, 126, 133, 122, 125, 132, - 120, 123, 130, 119, 122, 129, 114, 114, 122, 108, 108, 116, 100, 100, 108, - 93, 93, 101, 85, 85, 93, 79, 79, 87, 78, 78, 86, 80, 80, 88, - 84, 84, 92, 87, 87, 95, 91, 91, 99, 95, 95, 103, 99, 99, 107, - 103, 103, 111, 106, 106, 114, 107, 110, 117, 110, 113, 122, 112, 115, 124, - 117, 117, 125, 120, 119, 127, 121, 120, 126, 120, 121, 126, 117, 120, 125, - 115, 120, 124, 113, 120, 126, 113, 122, 127, 109, 116, 122, 111, 116, 120, - 119, 119, 121, 117, 111, 113, 119, 107, 107, 136, 116, 115, 179, 148, 145, - 195, 156, 151, 201, 158, 149, 201, 155, 142, 209, 160, 143, 220, 169, 148, - 218, 166, 144, 204, 154, 131, 208, 160, 137, 216, 170, 146, 223, 178, 155, - 223, 178, 155, 223, 179, 154, 227, 183, 158, 232, 186, 160, 234, 188, 162, - 238, 190, 167, 235, 187, 165, 232, 184, 164, 229, 181, 161, 227, 178, 161, - 227, 178, 161, 227, 178, 163, 227, 178, 163, 226, 174, 160, 228, 176, 162, - 230, 177, 163, 231, 178, 164, 234, 178, 165, 234, 178, 163, 236, 178, 164, - 236, 180, 165, 229, 178, 161, 225, 176, 159, 225, 176, 159, 227, 178, 161, - 231, 180, 161, 231, 180, 161, 231, 180, 161, 231, 180, 161, 230, 182, 162, - 234, 186, 164, 235, 187, 165, 232, 184, 162, 228, 182, 159, 223, 177, 153, - 214, 170, 145, 206, 162, 137, 190, 142, 120, 168, 120, 98, 156, 108, 86, - 151, 103, 81, 154, 106, 84, 162, 114, 92, 172, 124, 102, 189, 141, 119, - 207, 159, 137, 215, 167, 145, 217, 169, 147, 217, 169, 147, 221, 173, 151, - 222, 174, 152, 219, 171, 149, 221, 170, 149, 222, 168, 144, 231, 177, 153, - 218, 168, 145, 200, 155, 132, 206, 168, 147, 189, 158, 138, 95, 72, 56, - 14, 0, 0, 20, 10, 1, 4, 0, 0, 8, 7, 5, 25, 25, 27, - 40, 39, 44, 46, 45, 51, 38, 37, 43, 48, 47, 53, 121, 124, 131, - 122, 125, 132, 123, 126, 133, 124, 127, 134, 124, 127, 134, 125, 128, 135, - 124, 127, 134, 124, 127, 134, 124, 127, 134, 124, 127, 134, 124, 127, 134, - 124, 127, 134, 123, 126, 133, 121, 124, 131, 119, 122, 129, 117, 120, 127, - 115, 115, 123, 111, 111, 119, 104, 104, 112, 98, 98, 106, 92, 92, 100, - 88, 88, 96, 87, 87, 95, 89, 89, 97, 93, 96, 103, 96, 99, 106, - 100, 103, 110, 104, 107, 114, 108, 111, 118, 111, 114, 121, 114, 117, 124, - 116, 119, 126, 118, 121, 130, 118, 121, 130, 119, 122, 129, 119, 122, 129, - 119, 122, 127, 119, 122, 127, 117, 122, 126, 116, 121, 125, 113, 118, 124, - 117, 121, 130, 112, 116, 125, 110, 113, 120, 119, 120, 125, 119, 119, 121, - 111, 109, 110, 115, 107, 105, 143, 122, 119, 173, 144, 140, 195, 162, 153, - 197, 159, 148, 199, 156, 140, 208, 161, 143, 214, 163, 142, 211, 160, 139, - 208, 160, 138, 210, 164, 141, 218, 172, 149, 225, 179, 156, 226, 180, 156, - 225, 179, 155, 228, 182, 156, 234, 187, 161, 240, 190, 167, 240, 188, 166, - 238, 186, 165, 234, 183, 162, 232, 181, 162, 232, 181, 164, 232, 180, 166, - 232, 180, 166, 232, 180, 166, 233, 181, 167, 235, 181, 169, 236, 182, 170, - 236, 179, 168, 235, 179, 166, 236, 178, 166, 235, 179, 166, 230, 181, 166, - 226, 179, 163, 225, 178, 160, 228, 181, 163, 231, 182, 165, 230, 181, 164, - 228, 179, 162, 228, 180, 160, 226, 178, 158, 231, 183, 163, 233, 185, 165, - 229, 181, 161, 224, 177, 157, 219, 174, 151, 208, 163, 140, 197, 152, 129, - 184, 136, 116, 159, 111, 91, 150, 102, 82, 154, 106, 86, 159, 111, 91, - 163, 115, 95, 173, 125, 105, 197, 149, 129, 208, 160, 140, 215, 167, 147, - 216, 168, 148, 217, 169, 149, 222, 174, 154, 222, 174, 154, 218, 170, 150, - 220, 169, 148, 220, 165, 144, 220, 165, 144, 210, 160, 137, 193, 147, 123, - 206, 164, 142, 197, 161, 139, 156, 127, 109, 21, 0, 0, 23, 9, 0, - 17, 8, 1, 7, 2, 0, 10, 8, 9, 26, 25, 30, 29, 30, 35, - 29, 29, 37, 38, 38, 46, 121, 124, 131, 122, 125, 132, 123, 126, 133, - 124, 127, 134, 124, 127, 134, 124, 127, 134, 124, 127, 134, 124, 127, 134, - 124, 127, 134, 124, 127, 134, 123, 126, 133, 122, 125, 132, 121, 124, 131, - 119, 122, 129, 118, 121, 128, 117, 120, 127, 118, 118, 126, 114, 114, 122, - 107, 107, 115, 101, 101, 109, 96, 96, 104, 95, 95, 103, 98, 98, 106, - 100, 100, 108, 105, 108, 115, 107, 110, 117, 110, 113, 120, 113, 116, 123, - 114, 117, 124, 115, 118, 125, 117, 120, 127, 118, 121, 130, 118, 120, 132, - 118, 121, 130, 118, 121, 130, 116, 121, 127, 117, 122, 126, 117, 122, 126, - 117, 122, 126, 117, 122, 128, 116, 119, 128, 117, 120, 129, 116, 116, 126, - 114, 117, 126, 115, 118, 125, 111, 116, 120, 107, 116, 115, 115, 117, 114, - 117, 106, 104, 140, 121, 115, 167, 142, 135, 187, 157, 146, 199, 162, 146, - 202, 159, 142, 209, 161, 141, 215, 164, 143, 211, 160, 139, 207, 159, 137, - 214, 166, 144, 224, 178, 155, 230, 182, 160, 227, 181, 157, 230, 182, 159, - 236, 189, 163, 240, 188, 166, 240, 188, 166, 240, 188, 167, 238, 187, 166, - 237, 186, 167, 235, 187, 167, 235, 186, 171, 236, 187, 172, 235, 186, 171, - 236, 187, 172, 237, 188, 174, 239, 187, 174, 238, 186, 173, 237, 183, 171, - 236, 182, 170, 235, 183, 169, 231, 184, 168, 226, 180, 164, 227, 180, 162, - 231, 184, 166, 234, 185, 168, 231, 182, 165, 230, 181, 164, 231, 182, 165, - 228, 180, 160, 234, 186, 166, 234, 186, 166, 225, 178, 158, 219, 174, 153, - 214, 169, 148, 201, 156, 133, 187, 142, 119, 171, 124, 104, 151, 103, 83, - 148, 100, 80, 156, 108, 88, 162, 114, 94, 165, 117, 97, 177, 129, 109, - 202, 154, 134, 212, 164, 144, 217, 169, 149, 218, 170, 150, 218, 170, 150, - 222, 174, 154, 220, 172, 152, 216, 168, 148, 219, 168, 149, 223, 171, 150, - 222, 170, 149, 221, 169, 147, 208, 160, 137, 217, 173, 148, 213, 172, 150, - 193, 161, 140, 103, 77, 60, 14, 0, 0, 18, 8, 0, 14, 6, 3, - 9, 7, 8, 16, 15, 20, 19, 19, 27, 21, 21, 31, 24, 24, 34, - 121, 124, 131, 121, 124, 131, 122, 125, 132, 123, 126, 133, 123, 126, 133, - 123, 126, 133, 123, 126, 133, 123, 126, 133, 123, 126, 133, 123, 126, 133, - 122, 125, 132, 121, 124, 131, 119, 122, 129, 118, 121, 128, 118, 121, 128, - 117, 120, 127, 117, 117, 125, 115, 115, 123, 110, 110, 118, 106, 106, 114, - 103, 103, 111, 104, 104, 112, 108, 108, 116, 110, 110, 118, 111, 114, 121, - 112, 115, 122, 114, 117, 124, 116, 119, 126, 116, 119, 128, 115, 118, 127, - 115, 118, 127, 116, 119, 128, 118, 118, 130, 116, 119, 128, 115, 119, 128, - 113, 120, 126, 114, 122, 125, 114, 122, 125, 116, 121, 127, 117, 120, 127, - 120, 120, 130, 117, 117, 129, 120, 118, 131, 120, 120, 130, 112, 117, 123, - 108, 118, 120, 107, 121, 121, 110, 121, 117, 112, 111, 107, 118, 107, 101, - 132, 115, 107, 159, 135, 123, 185, 152, 137, 199, 157, 141, 205, 158, 140, - 210, 159, 140, 211, 160, 139, 208, 157, 136, 210, 159, 140, 217, 169, 147, - 228, 177, 156, 230, 182, 159, 235, 185, 162, 237, 187, 164, 238, 186, 162, - 239, 187, 163, 241, 189, 167, 240, 189, 168, 237, 190, 170, 236, 189, 169, - 236, 190, 174, 237, 191, 175, 233, 190, 174, 234, 191, 175, 235, 192, 176, - 238, 192, 177, 237, 191, 178, 237, 189, 175, 237, 189, 175, 237, 189, 175, - 234, 188, 172, 231, 185, 169, 231, 185, 169, 236, 189, 173, 237, 188, 173, - 233, 184, 169, 232, 183, 166, 234, 185, 168, 229, 180, 163, 234, 185, 168, - 229, 182, 164, 217, 170, 152, 209, 164, 143, 204, 159, 138, 189, 147, 125, - 175, 130, 109, 156, 109, 89, 147, 99, 79, 152, 104, 84, 158, 110, 90, - 163, 115, 95, 172, 124, 104, 184, 136, 116, 206, 158, 138, 213, 165, 145, - 217, 169, 149, 217, 169, 149, 217, 169, 149, 219, 171, 151, 217, 169, 149, - 215, 167, 147, 220, 169, 150, 218, 165, 147, 220, 167, 149, 221, 169, 148, - 214, 164, 141, 215, 169, 145, 209, 167, 143, 201, 165, 143, 174, 146, 125, - 58, 39, 24, 18, 4, 0, 12, 5, 0, 14, 10, 9, 12, 11, 16, - 19, 19, 27, 14, 17, 26, 15, 17, 29, 120, 123, 130, 121, 124, 131, - 121, 124, 131, 122, 125, 132, 122, 125, 132, 122, 125, 132, 122, 125, 132, - 122, 125, 132, 123, 126, 133, 122, 125, 132, 121, 124, 131, 119, 122, 129, - 118, 121, 128, 118, 121, 128, 117, 120, 127, 117, 120, 127, 114, 114, 122, - 114, 114, 122, 113, 113, 121, 112, 112, 120, 111, 111, 119, 112, 112, 120, - 114, 114, 122, 115, 115, 123, 113, 116, 123, 115, 118, 125, 116, 119, 126, - 117, 120, 127, 117, 120, 129, 116, 119, 128, 115, 118, 127, 115, 118, 127, - 119, 119, 129, 118, 121, 130, 117, 122, 128, 116, 123, 129, 116, 124, 127, - 115, 123, 126, 116, 121, 127, 117, 120, 127, 118, 118, 128, 117, 117, 127, - 121, 119, 132, 119, 119, 129, 111, 116, 122, 113, 122, 127, 111, 125, 126, - 101, 111, 110, 117, 117, 115, 116, 111, 107, 115, 106, 101, 124, 111, 103, - 147, 127, 118, 174, 146, 134, 191, 153, 140, 199, 153, 138, 209, 160, 143, - 208, 157, 138, 205, 157, 135, 209, 161, 139, 220, 172, 150, 231, 183, 161, - 234, 186, 164, 234, 183, 162, 237, 187, 164, 239, 189, 166, 242, 192, 169, - 240, 192, 170, 239, 192, 172, 237, 192, 173, 237, 191, 175, 236, 193, 176, - 236, 193, 177, 235, 193, 177, 237, 194, 178, 237, 194, 178, 235, 192, 176, - 234, 191, 175, 234, 191, 175, 234, 191, 174, 237, 194, 177, 236, 190, 174, - 236, 190, 174, 239, 193, 177, 238, 191, 175, 234, 185, 170, 232, 183, 166, - 234, 185, 168, 225, 176, 159, 228, 179, 162, 221, 174, 156, 206, 159, 141, - 196, 151, 130, 192, 147, 126, 180, 135, 114, 164, 119, 98, 145, 98, 78, - 146, 99, 79, 156, 108, 88, 159, 111, 91, 164, 116, 96, 178, 130, 110, - 192, 144, 124, 209, 161, 141, 212, 164, 144, 215, 167, 147, 215, 167, 147, - 214, 166, 146, 216, 168, 148, 214, 166, 146, 214, 166, 146, 220, 172, 152, - 221, 170, 151, 220, 169, 150, 221, 169, 148, 220, 170, 147, 222, 174, 151, - 209, 165, 140, 210, 170, 145, 195, 160, 138, 152, 125, 106, 36, 17, 3, - 11, 0, 0, 16, 6, 4, 12, 8, 9, 20, 19, 24, 12, 12, 20, - 16, 19, 28, 119, 122, 129, 119, 122, 129, 119, 122, 129, 120, 123, 130, - 120, 123, 130, 121, 124, 131, 121, 124, 131, 121, 124, 131, 121, 124, 131, - 120, 123, 130, 120, 123, 130, 119, 122, 129, 118, 121, 128, 117, 120, 127, - 116, 119, 126, 116, 119, 126, 114, 117, 124, 114, 117, 124, 113, 116, 123, - 112, 115, 122, 112, 115, 122, 113, 116, 123, 114, 117, 124, 115, 118, 125, - 115, 118, 125, 116, 119, 126, 116, 119, 126, 116, 119, 126, 116, 119, 126, - 115, 118, 125, 115, 118, 125, 115, 118, 125, 115, 118, 125, 116, 119, 126, - 116, 119, 126, 116, 121, 127, 117, 122, 128, 117, 122, 128, 118, 121, 128, - 118, 121, 128, 118, 121, 128, 118, 121, 128, 120, 120, 130, 117, 120, 127, - 116, 119, 126, 114, 119, 125, 112, 119, 125, 114, 118, 121, 120, 116, 117, - 119, 113, 115, 111, 112, 114, 108, 109, 111, 109, 109, 109, 126, 116, 115, - 158, 134, 130, 185, 151, 142, 197, 153, 140, 196, 149, 131, 211, 167, 142, - 200, 156, 129, 205, 163, 138, 218, 173, 150, 228, 181, 163, 234, 185, 168, - 237, 189, 167, 238, 190, 168, 238, 190, 168, 238, 192, 169, 240, 193, 173, - 241, 194, 176, 239, 192, 176, 236, 190, 174, 241, 195, 179, 236, 193, 176, - 237, 191, 175, 239, 193, 177, 240, 194, 178, 239, 193, 177, 238, 192, 176, - 236, 193, 176, 233, 190, 173, 233, 190, 173, 234, 191, 174, 238, 192, 176, - 238, 192, 176, 235, 188, 172, 227, 180, 164, 221, 174, 158, 217, 170, 152, - 214, 167, 149, 204, 157, 139, 192, 145, 127, 184, 137, 119, 176, 129, 111, - 161, 114, 96, 146, 101, 82, 138, 91, 71, 150, 105, 84, 159, 112, 92, - 163, 116, 96, 172, 125, 105, 185, 138, 118, 198, 151, 131, 209, 162, 142, - 211, 164, 144, 213, 166, 146, 214, 167, 147, 214, 167, 147, 214, 166, 146, - 213, 165, 145, 214, 166, 146, 215, 167, 147, 216, 168, 148, 217, 169, 147, - 220, 169, 148, 217, 169, 146, 217, 169, 146, 216, 170, 146, 212, 168, 143, - 206, 164, 140, 192, 154, 131, 141, 108, 89, 34, 8, 0, 14, 0, 0, - 26, 15, 9, 22, 18, 15, 14, 15, 19, 12, 15, 20, 119, 122, 129, - 119, 122, 129, 119, 122, 129, 119, 122, 129, 120, 123, 130, 120, 123, 130, - 120, 123, 130, 120, 123, 130, 119, 122, 129, 119, 122, 129, 119, 122, 129, - 118, 121, 128, 117, 120, 127, 116, 119, 126, 115, 118, 125, 115, 118, 125, - 114, 117, 124, 114, 117, 124, 113, 116, 123, 113, 116, 123, 113, 116, 123, - 113, 116, 123, 114, 117, 124, 115, 118, 125, 115, 118, 125, 115, 118, 125, - 115, 118, 125, 116, 119, 126, 116, 119, 126, 115, 118, 125, 115, 118, 125, - 115, 118, 125, 115, 118, 125, 116, 119, 126, 116, 119, 126, 117, 120, 127, - 118, 121, 128, 118, 121, 128, 118, 121, 128, 118, 121, 128, 118, 121, 128, - 118, 121, 128, 118, 121, 128, 117, 120, 127, 117, 120, 127, 116, 119, 126, - 115, 118, 125, 118, 117, 123, 121, 115, 119, 120, 115, 119, 111, 116, 120, - 105, 114, 119, 102, 111, 116, 108, 109, 113, 128, 114, 114, 147, 119, 115, - 177, 139, 128, 186, 143, 124, 200, 158, 133, 198, 157, 129, 203, 161, 136, - 208, 166, 142, 221, 175, 159, 235, 188, 172, 235, 188, 168, 235, 189, 166, - 238, 192, 169, 242, 195, 175, 242, 195, 177, 239, 192, 174, 238, 191, 175, - 240, 193, 177, 239, 193, 177, 237, 191, 175, 236, 190, 174, 236, 190, 174, - 237, 191, 175, 238, 192, 176, 237, 192, 173, 233, 190, 171, 224, 181, 164, - 227, 186, 168, 233, 190, 173, 236, 193, 176, 236, 190, 174, 228, 182, 166, - 219, 172, 156, 212, 165, 149, 208, 161, 143, 207, 160, 142, 196, 149, 131, - 178, 131, 113, 166, 119, 101, 160, 113, 95, 146, 99, 81, 128, 81, 63, - 144, 99, 78, 155, 110, 89, 160, 115, 94, 164, 119, 98, 177, 130, 110, - 191, 144, 124, 202, 155, 135, 211, 164, 144, 213, 166, 146, 214, 167, 147, - 214, 167, 147, 213, 166, 146, 214, 166, 146, 214, 166, 146, 215, 167, 147, - 216, 168, 148, 216, 168, 146, 218, 170, 148, 218, 170, 148, 218, 170, 148, - 218, 170, 147, 218, 170, 147, 215, 169, 143, 211, 165, 139, 208, 164, 139, - 175, 137, 114, 102, 71, 51, 35, 12, 0, 33, 19, 10, 21, 14, 8, - 18, 18, 18, 11, 15, 18, 118, 121, 128, 118, 121, 128, 118, 121, 128, - 118, 121, 128, 118, 121, 128, 118, 121, 128, 119, 122, 129, 119, 122, 129, - 118, 121, 128, 118, 121, 128, 118, 121, 128, 117, 120, 127, 117, 120, 127, - 116, 119, 126, 115, 118, 125, 114, 117, 124, 115, 118, 125, 114, 117, 124, - 114, 117, 124, 113, 116, 123, 113, 116, 123, 114, 117, 124, 114, 117, 124, - 114, 117, 124, 115, 118, 125, 115, 118, 125, 115, 118, 125, 115, 118, 125, - 115, 118, 125, 115, 118, 125, 115, 118, 125, 115, 118, 125, 116, 119, 126, - 116, 119, 126, 117, 120, 127, 117, 120, 127, 118, 121, 128, 118, 121, 128, - 119, 122, 129, 119, 122, 129, 118, 121, 128, 118, 121, 128, 118, 121, 128, - 118, 121, 128, 118, 121, 128, 117, 120, 127, 117, 120, 127, 119, 120, 125, - 121, 116, 122, 119, 117, 122, 113, 118, 122, 110, 117, 123, 107, 114, 120, - 108, 107, 112, 115, 103, 105, 124, 100, 96, 180, 146, 136, 189, 148, 130, - 180, 135, 112, 186, 142, 115, 196, 152, 127, 203, 158, 135, 211, 166, 147, - 223, 178, 159, 230, 185, 164, 228, 183, 160, 231, 186, 165, 238, 193, 172, - 240, 195, 176, 238, 193, 174, 237, 191, 175, 240, 194, 178, 239, 193, 178, - 241, 195, 180, 241, 195, 180, 239, 193, 178, 238, 192, 176, 238, 192, 176, - 232, 186, 170, 224, 181, 164, 216, 173, 156, 214, 173, 155, 214, 171, 154, - 213, 170, 153, 213, 167, 151, 210, 164, 148, 209, 162, 146, 207, 160, 144, - 203, 154, 137, 189, 140, 123, 176, 127, 110, 167, 118, 101, 150, 103, 85, - 133, 86, 68, 130, 83, 65, 136, 89, 71, 153, 108, 87, 162, 117, 96, - 165, 120, 99, 170, 125, 104, 185, 138, 118, 199, 152, 132, 207, 160, 140, - 212, 165, 145, 214, 167, 147, 212, 165, 145, 210, 163, 143, 210, 163, 143, - 212, 164, 144, 213, 165, 145, 214, 166, 146, 215, 167, 147, 215, 167, 145, - 217, 169, 147, 218, 170, 148, 218, 170, 148, 218, 170, 147, 219, 171, 148, - 217, 170, 144, 213, 167, 141, 213, 169, 144, 194, 156, 133, 153, 120, 101, - 63, 40, 24, 39, 22, 12, 22, 13, 8, 19, 17, 18, 16, 17, 19, - 117, 120, 127, 117, 120, 127, 117, 120, 127, 117, 120, 127, 117, 120, 127, - 117, 120, 127, 117, 120, 127, 117, 120, 127, 117, 120, 127, 117, 120, 127, - 117, 120, 127, 117, 120, 127, 116, 119, 126, 116, 119, 126, 115, 118, 125, - 115, 118, 125, 115, 118, 125, 115, 118, 125, 114, 117, 124, 114, 117, 124, - 114, 117, 124, 114, 117, 124, 114, 117, 124, 114, 117, 124, 114, 117, 124, - 114, 117, 124, 115, 118, 125, 115, 118, 125, 115, 118, 125, 115, 118, 125, - 115, 118, 125, 115, 118, 125, 116, 119, 126, 116, 119, 126, 117, 120, 127, - 118, 121, 128, 118, 121, 128, 119, 122, 129, 119, 122, 129, 119, 122, 129, - 118, 121, 128, 118, 121, 128, 119, 122, 129, 119, 122, 129, 119, 122, 129, - 119, 122, 129, 118, 121, 128, 120, 121, 126, 121, 120, 125, 119, 118, 123, - 114, 117, 124, 113, 118, 124, 112, 117, 123, 114, 113, 119, 116, 107, 108, - 121, 102, 98, 168, 138, 127, 202, 165, 147, 197, 152, 129, 195, 149, 125, - 183, 137, 113, 180, 134, 111, 191, 146, 127, 211, 166, 147, 224, 179, 158, - 225, 180, 157, 228, 183, 162, 233, 188, 167, 236, 191, 172, 237, 192, 173, - 237, 191, 175, 236, 190, 174, 237, 191, 176, 242, 196, 181, 243, 197, 182, - 239, 193, 178, 235, 189, 174, 231, 185, 169, 221, 175, 159, 208, 162, 146, - 197, 154, 137, 199, 158, 140, 206, 163, 146, 210, 167, 150, 213, 167, 151, - 207, 161, 145, 199, 152, 136, 192, 145, 129, 192, 143, 126, 171, 122, 105, - 155, 106, 89, 148, 99, 82, 134, 85, 68, 121, 74, 56, 132, 85, 67, - 155, 108, 90, 158, 113, 92, 168, 123, 102, 174, 129, 108, 180, 135, 114, - 194, 147, 127, 205, 158, 138, 209, 162, 142, 212, 165, 145, 213, 166, 146, - 211, 164, 144, 208, 161, 141, 207, 160, 140, 210, 162, 142, 213, 165, 145, - 214, 166, 146, 214, 166, 146, 214, 166, 144, 216, 168, 146, 217, 169, 147, - 217, 169, 147, 218, 170, 147, 220, 172, 149, 218, 171, 145, 214, 168, 142, - 214, 170, 145, 201, 161, 136, 163, 131, 110, 97, 71, 56, 45, 27, 17, - 24, 15, 8, 16, 15, 13, 18, 20, 19, 116, 119, 126, 116, 119, 126, - 116, 119, 126, 116, 119, 126, 116, 119, 126, 116, 119, 126, 116, 119, 126, - 116, 119, 126, 117, 120, 127, 117, 120, 127, 117, 120, 127, 117, 120, 127, - 117, 120, 127, 116, 119, 126, 116, 119, 126, 116, 119, 126, 116, 119, 126, - 115, 118, 125, 115, 118, 125, 115, 118, 125, 114, 117, 124, 114, 117, 124, - 114, 117, 124, 114, 117, 124, 114, 117, 124, 114, 117, 124, 115, 118, 125, - 115, 118, 125, 116, 119, 126, 116, 119, 126, 116, 119, 126, 115, 118, 125, - 116, 119, 126, 117, 120, 127, 117, 120, 127, 118, 121, 128, 119, 122, 129, - 119, 122, 129, 119, 122, 129, 119, 122, 129, 119, 122, 129, 119, 122, 129, - 119, 122, 129, 120, 123, 130, 120, 123, 130, 120, 123, 130, 120, 123, 130, - 120, 123, 130, 121, 124, 129, 118, 121, 126, 115, 118, 125, 113, 116, 125, - 113, 116, 125, 115, 114, 120, 114, 108, 110, 116, 102, 99, 148, 124, 114, - 202, 169, 152, 214, 172, 150, 215, 167, 144, 201, 151, 128, 189, 141, 119, - 184, 139, 118, 184, 142, 120, 204, 162, 140, 217, 175, 153, 228, 185, 166, - 230, 187, 168, 228, 185, 168, 230, 187, 170, 231, 188, 172, 230, 187, 171, - 228, 184, 171, 233, 189, 176, 233, 189, 176, 227, 184, 168, 224, 178, 163, - 221, 175, 160, 210, 164, 149, 198, 152, 137, 188, 145, 128, 191, 148, 131, - 199, 153, 137, 205, 159, 143, 207, 160, 144, 199, 152, 136, 187, 138, 123, - 176, 127, 112, 165, 114, 97, 154, 103, 86, 136, 85, 68, 119, 70, 53, - 120, 71, 54, 134, 85, 68, 149, 100, 83, 156, 109, 91, 162, 117, 96, - 176, 131, 110, 186, 141, 120, 192, 147, 126, 203, 156, 136, 209, 162, 142, - 209, 162, 142, 211, 164, 144, 213, 166, 146, 211, 164, 144, 208, 161, 141, - 208, 161, 141, 211, 163, 143, 214, 166, 146, 215, 167, 147, 215, 167, 147, - 215, 167, 147, 217, 169, 149, 218, 170, 150, 218, 170, 148, 219, 171, 148, - 221, 173, 150, 220, 173, 147, 216, 171, 142, 219, 175, 148, 208, 168, 143, - 175, 140, 118, 120, 93, 76, 53, 35, 23, 22, 11, 5, 21, 17, 14, - 14, 14, 12, 115, 118, 125, 115, 118, 125, 115, 118, 125, 115, 118, 125, - 115, 118, 125, 115, 118, 125, 116, 119, 126, 116, 119, 126, 117, 120, 127, - 117, 120, 127, 117, 120, 127, 117, 120, 127, 117, 120, 127, 117, 120, 127, - 117, 120, 127, 116, 119, 126, 116, 119, 126, 116, 119, 126, 116, 119, 126, - 115, 118, 125, 115, 118, 125, 115, 118, 125, 114, 117, 124, 114, 117, 124, - 114, 117, 124, 115, 118, 125, 115, 118, 125, 116, 119, 126, 116, 119, 126, - 116, 119, 126, 116, 119, 126, 116, 119, 126, 117, 120, 127, 117, 120, 127, - 118, 121, 128, 119, 122, 129, 119, 122, 129, 120, 123, 130, 120, 123, 130, - 120, 123, 130, 120, 123, 130, 120, 123, 130, 121, 124, 131, 121, 124, 131, - 121, 124, 131, 121, 124, 131, 120, 123, 130, 120, 123, 130, 119, 124, 128, - 118, 123, 129, 117, 120, 129, 117, 117, 127, 117, 117, 127, 116, 115, 123, - 113, 111, 114, 112, 104, 101, 137, 119, 109, 186, 157, 143, 212, 171, 153, - 220, 172, 152, 223, 171, 150, 220, 169, 148, 200, 155, 132, 179, 137, 115, - 180, 138, 116, 198, 156, 134, 217, 174, 155, 221, 178, 159, 219, 176, 159, - 220, 177, 160, 224, 181, 165, 228, 185, 169, 225, 181, 168, 226, 182, 169, - 223, 179, 166, 217, 173, 160, 216, 170, 155, 214, 168, 153, 208, 162, 147, - 201, 155, 140, 190, 147, 130, 190, 147, 130, 191, 145, 129, 190, 144, 128, - 187, 140, 124, 177, 130, 114, 165, 116, 101, 156, 107, 92, 132, 81, 64, - 121, 70, 53, 111, 60, 43, 113, 62, 45, 128, 79, 62, 148, 99, 82, - 159, 110, 93, 160, 113, 95, 172, 125, 105, 186, 141, 120, 197, 152, 131, - 201, 156, 135, 208, 161, 141, 210, 163, 143, 208, 161, 141, 210, 163, 143, - 210, 163, 143, 209, 162, 142, 209, 162, 142, 210, 163, 143, 213, 165, 145, - 214, 166, 146, 216, 168, 148, 216, 168, 148, 219, 171, 151, 221, 173, 153, - 221, 173, 153, 221, 173, 151, 222, 174, 152, 224, 177, 151, 222, 175, 149, - 220, 173, 145, 217, 171, 145, 214, 172, 147, 196, 160, 138, 130, 101, 83, - 54, 34, 23, 20, 7, 0, 30, 25, 21, 12, 11, 9, 114, 117, 124, - 114, 117, 124, 115, 118, 125, 115, 118, 125, 115, 118, 125, 115, 118, 125, - 116, 119, 126, 116, 119, 126, 116, 119, 126, 117, 120, 127, 117, 120, 127, - 117, 120, 127, 117, 120, 127, 117, 120, 127, 117, 120, 127, 117, 120, 127, - 116, 119, 126, 116, 119, 126, 116, 119, 126, 116, 119, 126, 115, 118, 125, - 115, 118, 125, 114, 117, 124, 114, 117, 124, 115, 118, 125, 115, 118, 125, - 116, 119, 126, 116, 119, 126, 117, 120, 127, 117, 120, 127, 117, 120, 127, - 117, 120, 127, 117, 120, 127, 117, 120, 127, 118, 121, 128, 119, 122, 129, - 120, 123, 130, 120, 123, 130, 120, 123, 130, 120, 123, 130, 121, 124, 131, - 121, 124, 131, 121, 124, 131, 122, 125, 132, 122, 125, 132, 121, 124, 131, - 121, 124, 131, 120, 125, 131, 115, 122, 128, 116, 123, 129, 119, 122, 131, - 120, 118, 131, 118, 116, 129, 118, 117, 125, 114, 115, 119, 115, 111, 108, - 118, 105, 97, 167, 144, 130, 218, 179, 164, 223, 174, 157, 222, 169, 151, - 224, 172, 151, 219, 173, 150, 212, 170, 146, 185, 144, 122, 186, 145, 125, - 192, 151, 131, 203, 162, 142, 208, 167, 149, 208, 166, 150, 211, 169, 155, - 216, 174, 160, 218, 174, 161, 216, 172, 159, 211, 167, 154, 207, 163, 150, - 204, 160, 147, 200, 156, 143, 195, 152, 136, 191, 148, 132, 180, 137, 120, - 184, 141, 124, 189, 143, 127, 185, 139, 123, 173, 126, 110, 153, 106, 90, - 134, 85, 70, 122, 73, 58, 111, 60, 43, 104, 53, 36, 109, 58, 41, - 129, 78, 61, 145, 96, 79, 154, 105, 88, 164, 115, 98, 176, 129, 111, - 186, 139, 119, 198, 153, 132, 205, 160, 139, 206, 161, 140, 210, 163, 143, - 210, 163, 143, 208, 161, 141, 209, 162, 142, 209, 162, 142, 211, 164, 144, - 213, 166, 146, 215, 168, 148, 217, 169, 149, 218, 170, 150, 219, 171, 151, - 220, 172, 152, 221, 174, 154, 222, 175, 155, 222, 175, 155, 222, 176, 153, - 223, 175, 153, 225, 178, 152, 226, 176, 151, 221, 174, 146, 217, 171, 145, - 213, 171, 146, 206, 170, 148, 139, 110, 92, 47, 25, 12, 25, 10, 3, - 29, 21, 18, 18, 14, 11, 114, 117, 124, 114, 117, 124, 114, 117, 124, - 115, 118, 125, 115, 118, 125, 116, 119, 126, 116, 119, 126, 116, 119, 126, - 116, 119, 126, 116, 119, 126, 116, 119, 126, 117, 120, 127, 117, 120, 127, - 117, 120, 127, 117, 120, 127, 117, 120, 127, 116, 119, 126, 116, 119, 126, - 116, 119, 126, 116, 119, 126, 116, 119, 126, 115, 118, 125, 114, 117, 124, - 114, 117, 124, 115, 118, 125, 115, 118, 125, 116, 119, 126, 117, 120, 127, - 117, 120, 127, 117, 120, 127, 117, 120, 127, 117, 120, 127, 117, 120, 127, - 118, 121, 128, 118, 121, 128, 119, 122, 129, 120, 123, 130, 120, 123, 130, - 120, 123, 130, 120, 123, 130, 122, 125, 132, 122, 125, 132, 122, 125, 132, - 122, 125, 132, 122, 125, 132, 121, 124, 131, 121, 124, 131, 120, 125, 131, - 115, 124, 129, 117, 126, 133, 122, 122, 134, 118, 116, 129, 114, 112, 125, - 114, 114, 124, 112, 115, 120, 114, 114, 112, 113, 106, 98, 150, 130, 119, - 211, 173, 162, 218, 170, 156, 225, 172, 154, 231, 179, 158, 229, 183, 159, - 225, 183, 159, 217, 176, 154, 191, 150, 130, 177, 136, 116, 189, 148, 128, - 203, 161, 145, 202, 160, 144, 198, 156, 142, 200, 158, 144, 206, 162, 149, - 202, 158, 145, 199, 155, 142, 197, 153, 140, 192, 148, 135, 183, 139, 126, - 175, 132, 116, 171, 128, 112, 171, 128, 111, 171, 128, 111, 169, 123, 107, - 155, 109, 93, 136, 89, 73, 117, 70, 54, 104, 55, 40, 99, 50, 35, - 103, 52, 35, 116, 65, 48, 133, 82, 65, 144, 93, 76, 148, 99, 82, - 157, 108, 91, 172, 123, 106, 183, 136, 118, 198, 151, 131, 207, 162, 141, - 210, 165, 144, 207, 162, 141, 210, 163, 143, 211, 164, 144, 209, 162, 142, - 210, 163, 143, 213, 166, 146, 216, 169, 149, 220, 173, 153, 222, 175, 155, - 224, 176, 156, 224, 176, 156, 225, 177, 157, 226, 178, 158, 222, 175, 155, - 223, 176, 156, 223, 176, 156, 222, 175, 155, 223, 175, 153, 224, 176, 153, - 225, 175, 150, 221, 174, 146, 226, 179, 153, 213, 171, 146, 206, 168, 147, - 153, 122, 104, 38, 16, 3, 33, 19, 10, 18, 8, 6, 22, 17, 14, - 114, 117, 124, 114, 117, 124, 114, 117, 124, 114, 117, 124, 114, 117, 124, - 114, 117, 124, 115, 118, 125, 115, 118, 125, 117, 120, 127, 117, 120, 127, - 117, 120, 127, 117, 120, 127, 117, 120, 127, 117, 120, 127, 117, 120, 127, - 118, 121, 128, 117, 120, 127, 117, 120, 127, 117, 120, 127, 117, 120, 127, - 116, 119, 126, 116, 119, 126, 115, 118, 125, 115, 118, 125, 115, 118, 125, - 115, 118, 125, 116, 119, 126, 117, 120, 127, 117, 120, 127, 117, 120, 127, - 117, 120, 127, 117, 120, 127, 118, 121, 128, 119, 122, 129, 119, 122, 129, - 120, 123, 130, 120, 123, 130, 121, 124, 131, 121, 124, 131, 122, 125, 132, - 122, 125, 132, 122, 125, 132, 122, 125, 132, 122, 125, 132, 122, 125, 132, - 122, 125, 132, 122, 125, 132, 120, 125, 131, 117, 126, 133, 116, 125, 132, - 121, 121, 133, 121, 119, 132, 119, 117, 130, 117, 117, 127, 111, 116, 120, - 110, 114, 115, 116, 113, 108, 129, 112, 104, 193, 159, 149, 221, 175, 162, - 226, 175, 158, 226, 175, 154, 232, 184, 161, 230, 186, 161, 224, 182, 160, - 219, 178, 158, 206, 165, 145, 187, 146, 126, 173, 131, 115, 173, 131, 115, - 182, 140, 126, 191, 149, 135, 191, 147, 134, 187, 143, 130, 186, 142, 129, - 184, 140, 127, 180, 136, 123, 178, 134, 121, 170, 127, 111, 157, 114, 98, - 150, 107, 90, 137, 94, 77, 121, 75, 59, 106, 60, 44, 96, 49, 33, - 93, 46, 30, 99, 50, 35, 106, 57, 42, 123, 72, 55, 129, 78, 61, - 137, 86, 69, 147, 96, 79, 159, 110, 93, 176, 127, 110, 189, 140, 123, - 195, 148, 130, 206, 159, 141, 209, 164, 145, 213, 168, 149, 213, 168, 149, - 211, 164, 146, 210, 163, 145, 213, 166, 148, 216, 169, 151, 223, 176, 158, - 223, 176, 158, 222, 175, 157, 223, 176, 158, 224, 175, 158, 225, 176, 159, - 224, 175, 158, 224, 175, 158, 223, 176, 158, 223, 176, 158, 222, 175, 155, - 222, 175, 155, 223, 175, 153, 223, 175, 152, 224, 174, 149, 222, 175, 149, - 225, 178, 152, 213, 171, 146, 210, 172, 151, 149, 118, 100, 35, 13, 0, - 33, 19, 10, 21, 11, 9, 24, 19, 16, 114, 117, 124, 114, 117, 124, - 114, 117, 124, 114, 117, 124, 114, 117, 124, 115, 118, 125, 115, 118, 125, - 115, 118, 125, 116, 119, 126, 116, 119, 126, 117, 120, 127, 117, 120, 127, - 117, 120, 127, 117, 120, 127, 117, 120, 127, 117, 120, 127, 117, 120, 127, - 117, 120, 127, 117, 120, 127, 117, 120, 127, 116, 119, 126, 116, 119, 126, - 115, 118, 125, 115, 118, 125, 115, 118, 125, 115, 118, 125, 116, 119, 126, - 117, 120, 127, 117, 120, 127, 117, 120, 127, 117, 120, 127, 117, 120, 127, - 118, 121, 128, 119, 122, 129, 119, 122, 129, 120, 123, 130, 120, 123, 130, - 121, 124, 131, 121, 124, 131, 121, 124, 131, 122, 125, 132, 122, 125, 132, - 122, 125, 132, 122, 125, 132, 122, 125, 132, 122, 125, 132, 122, 125, 132, - 121, 126, 132, 118, 125, 133, 117, 124, 132, 121, 121, 133, 121, 119, 132, - 119, 119, 131, 115, 118, 127, 112, 117, 123, 111, 115, 118, 113, 112, 110, - 123, 110, 104, 174, 145, 137, 211, 171, 159, 222, 175, 159, 226, 175, 156, - 232, 184, 161, 232, 186, 162, 229, 187, 165, 229, 188, 168, 226, 183, 164, - 213, 172, 152, 198, 155, 138, 181, 139, 123, 168, 126, 112, 160, 118, 104, - 164, 120, 107, 158, 114, 101, 153, 109, 96, 146, 102, 89, 139, 95, 82, - 138, 94, 81, 136, 93, 77, 129, 86, 70, 114, 71, 54, 113, 70, 53, - 116, 70, 54, 119, 73, 57, 120, 73, 57, 120, 73, 57, 122, 73, 58, - 125, 76, 61, 136, 85, 68, 147, 96, 79, 162, 111, 94, 175, 126, 109, - 189, 140, 123, 202, 153, 136, 210, 161, 144, 211, 164, 146, 212, 167, 148, - 213, 168, 149, 213, 168, 149, 211, 166, 147, 210, 163, 145, 210, 163, 145, - 214, 167, 149, 218, 171, 153, 223, 176, 158, 222, 175, 157, 222, 175, 157, - 223, 176, 158, 224, 175, 158, 225, 176, 159, 225, 176, 159, 224, 175, 158, - 223, 176, 158, 223, 176, 158, 223, 176, 156, 223, 176, 156, 223, 175, 153, - 223, 175, 152, 225, 175, 152, 222, 175, 149, 223, 177, 151, 214, 172, 147, - 207, 171, 149, 144, 115, 97, 37, 15, 2, 30, 15, 8, 22, 14, 11, - 22, 18, 15, 114, 117, 124, 114, 117, 124, 114, 117, 124, 114, 117, 124, - 114, 117, 124, 115, 118, 125, 115, 118, 125, 115, 118, 125, 116, 119, 126, - 116, 119, 126, 116, 119, 126, 117, 120, 127, 117, 120, 127, 117, 120, 127, - 117, 120, 127, 117, 120, 127, 117, 120, 127, 117, 120, 127, 117, 120, 127, - 117, 120, 127, 117, 120, 127, 116, 119, 126, 116, 119, 126, 115, 118, 125, - 115, 118, 125, 115, 118, 125, 116, 119, 126, 116, 119, 126, 117, 120, 127, - 117, 120, 127, 117, 120, 127, 117, 120, 127, 118, 121, 128, 118, 121, 128, - 119, 122, 129, 119, 122, 129, 120, 123, 130, 121, 124, 131, 121, 124, 131, - 121, 124, 131, 122, 125, 132, 122, 125, 132, 122, 125, 132, 123, 126, 133, - 123, 126, 133, 122, 125, 132, 122, 125, 132, 122, 125, 132, 121, 126, 132, - 120, 125, 131, 121, 121, 131, 120, 120, 130, 117, 119, 131, 115, 119, 130, - 110, 117, 125, 111, 116, 120, 112, 112, 112, 118, 108, 106, 150, 127, 121, - 200, 166, 156, 218, 175, 159, 224, 176, 156, 233, 183, 160, 232, 184, 161, - 227, 182, 159, 227, 185, 163, 231, 186, 167, 227, 184, 165, 223, 177, 161, - 210, 167, 150, 194, 151, 135, 181, 138, 122, 171, 127, 114, 165, 121, 108, - 161, 117, 104, 156, 112, 99, 149, 107, 91, 150, 108, 92, 153, 111, 95, - 150, 108, 92, 160, 119, 101, 160, 119, 101, 160, 117, 100, 161, 118, 101, - 161, 115, 99, 160, 114, 98, 161, 114, 98, 163, 116, 100, 168, 119, 102, - 180, 131, 114, 195, 146, 129, 208, 159, 142, 217, 168, 151, 221, 174, 156, - 220, 173, 155, 218, 171, 153, 218, 173, 154, 215, 170, 151, 212, 167, 148, - 208, 163, 144, 208, 161, 143, 210, 163, 145, 215, 168, 150, 218, 171, 153, - 221, 174, 156, 222, 175, 157, 222, 175, 157, 223, 176, 158, 225, 176, 159, - 225, 176, 159, 225, 176, 159, 225, 176, 159, 225, 176, 159, 224, 175, 158, - 224, 176, 156, 224, 176, 156, 223, 175, 153, 223, 175, 152, 223, 175, 152, - 222, 175, 149, 222, 176, 152, 216, 174, 150, 204, 167, 148, 140, 111, 95, - 39, 19, 8, 25, 12, 6, 25, 20, 17, 18, 17, 15, 114, 117, 124, - 114, 117, 124, 114, 117, 124, 114, 117, 124, 114, 117, 124, 114, 117, 124, - 115, 118, 125, 115, 118, 125, 116, 119, 126, 116, 119, 126, 116, 119, 126, - 116, 119, 126, 117, 120, 127, 117, 120, 127, 117, 120, 127, 117, 120, 127, - 118, 121, 128, 118, 121, 128, 118, 121, 128, 118, 121, 128, 117, 120, 127, - 117, 120, 127, 116, 119, 126, 116, 119, 126, 115, 118, 125, 115, 118, 125, - 116, 119, 126, 116, 119, 126, 116, 119, 126, 117, 120, 127, 117, 120, 127, - 117, 120, 127, 118, 121, 128, 118, 121, 128, 119, 122, 129, 119, 122, 129, - 120, 123, 130, 120, 123, 130, 121, 124, 131, 121, 124, 131, 122, 125, 132, - 122, 125, 132, 122, 125, 132, 123, 126, 133, 123, 126, 133, 123, 126, 133, - 123, 126, 133, 122, 125, 132, 122, 125, 132, 121, 124, 131, 120, 123, 132, - 119, 122, 131, 117, 121, 132, 114, 121, 131, 111, 118, 126, 112, 117, 123, - 115, 114, 119, 118, 109, 110, 130, 112, 108, 188, 159, 151, 214, 176, 163, - 223, 178, 159, 231, 180, 159, 233, 181, 159, 236, 188, 166, 233, 188, 167, - 231, 184, 166, 229, 184, 165, 229, 183, 167, 227, 181, 165, 219, 173, 158, - 208, 165, 149, 202, 158, 145, 198, 154, 141, 197, 153, 140, 197, 154, 138, - 194, 152, 136, 196, 154, 138, 198, 156, 140, 194, 152, 136, 189, 148, 130, - 187, 146, 128, 184, 141, 124, 182, 139, 122, 185, 139, 123, 190, 144, 128, - 198, 151, 135, 203, 156, 140, 204, 155, 138, 211, 162, 145, 218, 169, 152, - 221, 174, 156, 223, 176, 158, 222, 175, 157, 219, 172, 154, 216, 169, 151, - 218, 173, 154, 214, 169, 150, 208, 163, 144, 204, 159, 140, 206, 159, 141, - 209, 162, 144, 214, 167, 149, 217, 170, 152, 220, 173, 155, 221, 174, 156, - 222, 175, 157, 223, 176, 158, 225, 176, 159, 225, 176, 159, 225, 176, 159, - 226, 177, 160, 224, 175, 158, 224, 175, 158, 224, 176, 156, 223, 175, 155, - 223, 175, 153, 223, 175, 153, 222, 174, 151, 221, 175, 149, 222, 178, 153, - 217, 176, 154, 198, 163, 143, 133, 105, 91, 40, 22, 12, 21, 10, 6, - 27, 23, 22, 16, 16, 16, 114, 117, 124, 114, 117, 124, 113, 116, 123, - 113, 116, 123, 114, 117, 124, 114, 117, 124, 114, 117, 124, 115, 118, 125, - 116, 119, 126, 116, 119, 126, 116, 119, 126, 116, 119, 126, 117, 120, 127, - 117, 120, 127, 117, 120, 127, 117, 120, 127, 118, 121, 128, 118, 121, 128, - 118, 121, 128, 118, 121, 128, 117, 120, 127, 117, 120, 127, 116, 119, 126, - 116, 119, 126, 115, 118, 125, 115, 118, 125, 115, 118, 125, 116, 119, 126, - 116, 119, 126, 116, 119, 126, 117, 120, 127, 117, 120, 127, 118, 121, 128, - 118, 121, 128, 119, 122, 129, 119, 122, 129, 120, 123, 130, 120, 123, 130, - 121, 124, 131, 121, 124, 131, 122, 125, 132, 122, 125, 132, 122, 125, 132, - 123, 126, 133, 123, 126, 133, 123, 126, 133, 123, 126, 133, 123, 126, 133, - 126, 125, 133, 124, 124, 132, 121, 124, 131, 119, 124, 130, 116, 123, 131, - 115, 122, 130, 112, 119, 129, 114, 117, 126, 116, 115, 121, 118, 112, 114, - 120, 106, 105, 172, 149, 143, 207, 175, 162, 224, 181, 164, 231, 179, 158, - 234, 179, 158, 237, 186, 165, 234, 188, 165, 234, 186, 166, 231, 184, 164, - 231, 184, 166, 229, 184, 165, 223, 177, 161, 217, 171, 155, 206, 163, 147, - 200, 157, 141, 199, 156, 140, 201, 158, 142, 200, 158, 142, 201, 160, 142, - 200, 159, 141, 194, 153, 135, 182, 144, 125, 185, 147, 128, 192, 151, 133, - 197, 156, 138, 204, 161, 144, 211, 168, 151, 220, 174, 158, 223, 177, 161, - 219, 172, 154, 222, 175, 157, 224, 177, 159, 223, 176, 158, 221, 174, 156, - 220, 175, 156, 218, 173, 154, 216, 171, 152, 214, 169, 150, 210, 165, 146, - 206, 161, 142, 204, 159, 140, 206, 159, 141, 210, 163, 145, 213, 166, 148, - 215, 168, 150, 219, 172, 154, 221, 174, 156, 223, 176, 158, 224, 177, 159, - 225, 176, 159, 225, 176, 159, 226, 177, 160, 226, 177, 160, 223, 174, 157, - 223, 174, 157, 223, 175, 155, 223, 175, 155, 223, 175, 153, 223, 175, 153, - 222, 174, 151, 221, 175, 151, 224, 179, 156, 217, 176, 154, 189, 156, 137, - 123, 97, 84, 37, 18, 11, 21, 11, 9, 25, 23, 24, 15, 16, 18, - 114, 117, 124, 114, 117, 124, 114, 117, 124, 114, 117, 124, 114, 117, 124, - 114, 117, 124, 115, 118, 125, 115, 118, 125, 116, 119, 126, 116, 119, 126, - 116, 119, 126, 116, 119, 126, 116, 119, 126, 117, 120, 127, 117, 120, 127, - 117, 120, 127, 117, 120, 127, 117, 120, 127, 117, 120, 127, 117, 120, 127, - 117, 120, 127, 116, 119, 126, 116, 119, 126, 115, 118, 125, 115, 118, 125, - 115, 118, 125, 115, 118, 125, 115, 118, 125, 116, 119, 126, 116, 119, 126, - 117, 120, 127, 117, 120, 127, 118, 121, 128, 118, 121, 128, 118, 121, 128, - 119, 122, 129, 120, 123, 130, 120, 123, 130, 121, 124, 131, 121, 124, 131, - 122, 125, 132, 122, 125, 132, 122, 125, 132, 123, 126, 133, 123, 126, 133, - 123, 126, 133, 123, 126, 133, 125, 125, 133, 127, 124, 133, 125, 124, 132, - 121, 124, 131, 118, 125, 131, 116, 125, 132, 115, 124, 131, 115, 119, 130, - 115, 118, 127, 115, 114, 122, 118, 113, 119, 116, 106, 105, 151, 134, 127, - 197, 169, 157, 223, 181, 165, 231, 178, 160, 236, 179, 159, 229, 177, 156, - 229, 181, 159, 231, 183, 163, 231, 183, 163, 232, 183, 166, 232, 185, 167, - 231, 184, 168, 228, 182, 166, 225, 179, 164, 213, 170, 154, 210, 167, 151, - 212, 169, 153, 212, 171, 153, 215, 174, 156, 216, 175, 157, 210, 172, 153, - 209, 171, 152, 214, 176, 157, 220, 179, 161, 222, 181, 163, 224, 181, 164, - 225, 182, 165, 226, 180, 164, 224, 178, 162, 224, 177, 159, 227, 180, 162, - 227, 180, 162, 225, 178, 160, 221, 176, 157, 219, 174, 155, 217, 172, 153, - 215, 170, 151, 210, 165, 146, 208, 163, 144, 206, 161, 142, 205, 160, 141, - 208, 161, 143, 211, 164, 146, 214, 167, 149, 215, 168, 150, 219, 172, 154, - 221, 174, 156, 224, 177, 159, 224, 177, 159, 225, 176, 159, 224, 175, 158, - 225, 176, 159, 226, 177, 160, 223, 174, 157, 223, 174, 157, 223, 175, 155, - 223, 175, 155, 223, 175, 153, 223, 175, 153, 224, 176, 154, 223, 177, 153, - 224, 179, 156, 210, 172, 151, 179, 146, 129, 109, 86, 72, 29, 12, 5, - 25, 15, 14, 21, 19, 22, 15, 16, 20, 115, 118, 125, 115, 118, 125, - 115, 118, 125, 115, 118, 125, 115, 118, 125, 115, 118, 125, 116, 119, 126, - 116, 119, 126, 116, 119, 126, 116, 119, 126, 116, 119, 126, 116, 119, 126, - 116, 119, 126, 116, 119, 126, 117, 120, 127, 117, 120, 127, 117, 120, 127, - 117, 120, 127, 117, 120, 127, 117, 120, 127, 116, 119, 126, 116, 119, 126, - 115, 118, 125, 115, 118, 125, 115, 118, 125, 115, 118, 125, 115, 118, 125, - 115, 118, 125, 115, 118, 125, 116, 119, 126, 117, 120, 127, 117, 120, 127, - 118, 121, 128, 118, 121, 128, 118, 121, 128, 119, 122, 129, 119, 122, 129, - 120, 123, 130, 120, 123, 130, 121, 124, 131, 121, 124, 131, 122, 125, 132, - 122, 125, 132, 123, 126, 133, 123, 126, 133, 124, 127, 134, 124, 127, 134, - 126, 126, 134, 130, 125, 132, 127, 124, 131, 121, 126, 132, 117, 126, 131, - 116, 127, 133, 115, 124, 131, 116, 120, 131, 117, 117, 129, 116, 113, 124, - 119, 114, 121, 117, 111, 111, 130, 117, 111, 184, 157, 146, 218, 179, 164, - 230, 174, 157, 236, 178, 158, 236, 181, 161, 235, 184, 163, 235, 184, 163, - 231, 183, 163, 231, 182, 165, 231, 184, 166, 232, 185, 169, 230, 184, 168, - 228, 182, 166, 218, 172, 156, 212, 169, 152, 214, 171, 154, 214, 173, 155, - 218, 177, 159, 221, 183, 162, 221, 183, 162, 225, 187, 168, 226, 189, 170, - 227, 189, 170, 224, 186, 167, 224, 183, 165, 225, 182, 165, 227, 181, 165, - 225, 179, 163, 228, 183, 164, 230, 185, 166, 229, 184, 165, 225, 180, 161, - 220, 175, 156, 216, 171, 152, 209, 166, 147, 206, 163, 144, 206, 161, 142, - 206, 161, 142, 206, 161, 142, 206, 161, 142, 208, 161, 143, 211, 164, 146, - 213, 166, 148, 215, 168, 150, 218, 171, 153, 221, 174, 156, 224, 177, 159, - 225, 178, 160, 225, 176, 159, 224, 175, 158, 225, 176, 159, 226, 177, 160, - 223, 175, 155, 223, 175, 155, 223, 175, 155, 224, 176, 156, 224, 176, 156, - 225, 177, 155, 224, 178, 155, 225, 179, 156, 221, 176, 155, 202, 164, 143, - 166, 135, 117, 97, 73, 61, 18, 3, 0, 28, 20, 18, 15, 14, 19, - 15, 18, 23, 116, 119, 126, 116, 119, 126, 116, 119, 126, 116, 119, 126, - 116, 119, 126, 116, 119, 126, 117, 120, 127, 117, 120, 127, 115, 118, 125, - 116, 119, 126, 116, 119, 126, 116, 119, 126, 116, 119, 126, 116, 119, 126, - 116, 119, 126, 116, 119, 126, 117, 120, 127, 117, 120, 127, 117, 120, 127, - 117, 120, 127, 116, 119, 126, 116, 119, 126, 115, 118, 125, 115, 118, 125, - 115, 118, 125, 115, 118, 125, 115, 118, 125, 115, 118, 125, 115, 118, 125, - 116, 119, 126, 117, 120, 127, 117, 120, 127, 117, 120, 127, 118, 121, 128, - 118, 121, 128, 119, 122, 129, 119, 122, 129, 120, 123, 130, 120, 123, 130, - 121, 124, 131, 121, 124, 131, 122, 125, 132, 122, 125, 132, 123, 126, 133, - 124, 127, 134, 124, 127, 134, 124, 127, 134, 126, 126, 134, 131, 124, 132, - 129, 124, 131, 121, 126, 132, 117, 128, 132, 116, 127, 133, 115, 126, 132, - 118, 120, 132, 119, 117, 130, 118, 115, 126, 120, 115, 122, 120, 114, 116, - 116, 105, 99, 173, 149, 139, 213, 176, 160, 226, 170, 153, 236, 175, 156, - 232, 177, 157, 233, 181, 160, 234, 183, 162, 235, 184, 163, 234, 185, 168, - 235, 186, 169, 233, 186, 170, 230, 183, 167, 231, 185, 169, 223, 177, 161, - 218, 175, 158, 219, 176, 159, 216, 175, 157, 219, 178, 160, 223, 185, 164, - 225, 187, 166, 229, 192, 173, 231, 194, 175, 233, 195, 176, 230, 192, 173, - 231, 190, 172, 232, 191, 173, 236, 190, 174, 235, 189, 173, 230, 185, 166, - 231, 186, 167, 229, 184, 165, 222, 177, 158, 216, 171, 152, 211, 166, 147, - 205, 162, 143, 201, 158, 139, 204, 159, 140, 205, 160, 141, 206, 161, 142, - 206, 161, 142, 207, 160, 142, 209, 162, 144, 212, 165, 147, 214, 167, 149, - 218, 171, 153, 221, 174, 156, 225, 178, 160, 225, 178, 160, 225, 176, 159, - 224, 175, 158, 224, 175, 158, 226, 177, 160, 223, 175, 155, 223, 175, 155, - 224, 176, 156, 225, 177, 157, 225, 177, 157, 226, 178, 158, 226, 180, 157, - 225, 180, 157, 219, 174, 153, 195, 157, 136, 158, 126, 111, 89, 67, 54, - 11, 0, 0, 29, 23, 23, 11, 10, 15, 15, 18, 25 -]; diff --git a/tfjs-master/e2e/custom_module/blazeface/webpack.config.js b/tfjs-master/e2e/custom_module/blazeface/webpack.config.js deleted file mode 100644 index d2d62ed93..000000000 --- a/tfjs-master/e2e/custom_module/blazeface/webpack.config.js +++ /dev/null @@ -1,72 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -const path = require('path'); -const TerserPlugin = require('terser-webpack-plugin'); - -module.exports = function(env) { - const outputPath = (env && env.useCustomTfjs) ? 'dist/custom' : 'dist/full' - - const config = { - mode: 'production', - entry: './app.js', - target: 'web', - output: { - path: path.resolve(__dirname, outputPath), - filename: 'app_webpack.js', - }, - optimization: { - minimizer: [ - new TerserPlugin({ - cache: true, - parallel: true, - sourceMap: false, - terserOptions: { - comments: false, - } - }), - ] - }, - module: { - rules: [ - { - test: /\.wasm$/i, - type: 'javascript/auto', - use: [ - { - loader: 'file-loader', - }, - ], - }, - ], - } - }; - - if (env && env.useCustomTfjs) { - config.resolve = { - alias: { - '@tensorflow/tfjs$': - path.resolve(__dirname, './custom_tfjs_blazeface/custom_tfjs.js'), - '@tensorflow/tfjs-core$': path.resolve( - __dirname, './custom_tfjs_blazeface/custom_tfjs_core.js'), - '@tensorflow/tfjs-core/dist/ops/ops_for_converter': path.resolve( - __dirname, './custom_tfjs_blazeface/custom_ops_for_converter.js'), - } - } - } - return config; -} diff --git a/tfjs-master/e2e/custom_module/blazeface/yarn.lock b/tfjs-master/e2e/custom_module/blazeface/yarn.lock deleted file mode 100644 index 1173fe11b..000000000 --- a/tfjs-master/e2e/custom_module/blazeface/yarn.lock +++ /dev/null @@ -1,1975 +0,0 @@ -# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. -# yarn lockfile v1 - - -"@babel/code-frame@^7.8.3": - version "7.10.4" - resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.10.4.tgz#168da1a36e90da68ae8d49c0f1b48c7c6249213a" - integrity sha512-vG6SvB6oYEhvgisZNFRmRCUkLz11c7rp+tbNTynGqc6mS1d5ATd/sGyV6W0KZZnXRKMTzZDRgQT3Ou9jhpAfUg== - dependencies: - "@babel/highlight" "^7.10.4" - -"@babel/helper-validator-identifier@^7.10.4": - version "7.10.4" - resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.10.4.tgz#a78c7a7251e01f616512d31b10adcf52ada5e0d2" - integrity sha512-3U9y+43hz7ZM+rzG24Qe2mufW5KhvFg/NhnNph+i9mgCtdTCtMJuI1TMkrIUiK7Ix4PYlRF9I5dhqaLYA/ADXw== - -"@babel/highlight@^7.10.4": - version "7.10.4" - resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.10.4.tgz#7d1bdfd65753538fabe6c38596cdb76d9ac60143" - integrity sha512-i6rgnR/YgPEQzZZnbTHHuZdlE8qyoBNalD6F+q4vAFlcMEcqmkoG+mPqJYJCo63qPf74+Y1UZsl3l6f7/RIkmA== - dependencies: - "@babel/helper-validator-identifier" "^7.10.4" - chalk "^2.0.0" - js-tokens "^4.0.0" - -"@jridgewell/gen-mapping@^0.3.0": - version "0.3.2" - resolved "https://registry.yarnpkg.com/@jridgewell/gen-mapping/-/gen-mapping-0.3.2.tgz#c1aedc61e853f2bb9f5dfe6d4442d3b565b253b9" - integrity sha512-mh65xKQAzI6iBcFzwv28KVWSmCkdRBWoOh+bYQGW3+6OZvbbN3TqMGo5hqYxQniRcH9F2VZIoJCm4pa3BPDK/A== - dependencies: - "@jridgewell/set-array" "^1.0.1" - "@jridgewell/sourcemap-codec" "^1.4.10" - "@jridgewell/trace-mapping" "^0.3.9" - -"@jridgewell/resolve-uri@3.1.0": - version "3.1.0" - resolved "https://registry.yarnpkg.com/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz#2203b118c157721addfe69d47b70465463066d78" - integrity sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w== - -"@jridgewell/set-array@^1.0.1": - version "1.1.2" - resolved "https://registry.yarnpkg.com/@jridgewell/set-array/-/set-array-1.1.2.tgz#7c6cf998d6d20b914c0a55a91ae928ff25965e72" - integrity sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw== - -"@jridgewell/source-map@^0.3.2": - version "0.3.2" - resolved "https://registry.yarnpkg.com/@jridgewell/source-map/-/source-map-0.3.2.tgz#f45351aaed4527a298512ec72f81040c998580fb" - integrity sha512-m7O9o2uR8k2ObDysZYzdfhb08VuEml5oWGiosa1VdaPZ/A6QyPkAJuwN0Q1lhULOf6B7MtQmHENS743hWtCrgw== - dependencies: - "@jridgewell/gen-mapping" "^0.3.0" - "@jridgewell/trace-mapping" "^0.3.9" - -"@jridgewell/sourcemap-codec@1.4.14", "@jridgewell/sourcemap-codec@^1.4.10": - version "1.4.14" - resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz#add4c98d341472a289190b424efbdb096991bb24" - integrity sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw== - -"@jridgewell/trace-mapping@^0.3.17", "@jridgewell/trace-mapping@^0.3.9": - version "0.3.17" - resolved "https://registry.yarnpkg.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.17.tgz#793041277af9073b0951a7fe0f0d8c4c98c36985" - integrity sha512-MCNzAp77qzKca9+W/+I0+sEpaUnZoeasnghNeVc41VZCEKaCH73Vq3BZZ/SzWIgrqE4H4ceI+p+b6C0mHf9T4g== - dependencies: - "@jridgewell/resolve-uri" "3.1.0" - "@jridgewell/sourcemap-codec" "1.4.14" - -"@npmcli/move-file@^1.0.1": - version "1.0.1" - resolved "https://registry.yarnpkg.com/@npmcli/move-file/-/move-file-1.0.1.tgz#de103070dac0f48ce49cf6693c23af59c0f70464" - integrity sha512-Uv6h1sT+0DrblvIrolFtbvM1FgWm+/sy4B3pvLp67Zys+thcukzS5ekn7HsZFGpWP4Q3fYJCljbWQE/XivMRLw== - dependencies: - mkdirp "^1.0.4" - -"@rollup/plugin-alias@^3.1.1": - version "3.1.1" - resolved "https://registry.yarnpkg.com/@rollup/plugin-alias/-/plugin-alias-3.1.1.tgz#bb96cf37fefeb0a953a6566c284855c7d1cd290c" - integrity sha512-hNcQY4bpBUIvxekd26DBPgF7BT4mKVNDF5tBG4Zi+3IgwLxGYRY0itHs9D0oLVwXM5pvJDWJlBQro+au8WaUWw== - dependencies: - slash "^3.0.0" - -"@rollup/plugin-commonjs@^14.0.0": - version "14.0.0" - resolved "https://registry.yarnpkg.com/@rollup/plugin-commonjs/-/plugin-commonjs-14.0.0.tgz#4285f9ec2db686a31129e5a2b415c94aa1f836f0" - integrity sha512-+PSmD9ePwTAeU106i9FRdc+Zb3XUWyW26mo5Atr2mk82hor8+nPwkztEjFo8/B1fJKfaQDg9aM2bzQkjhi7zOw== - dependencies: - "@rollup/pluginutils" "^3.0.8" - commondir "^1.0.1" - estree-walker "^1.0.1" - glob "^7.1.2" - is-reference "^1.1.2" - magic-string "^0.25.2" - resolve "^1.11.0" - -"@rollup/plugin-node-resolve@^8.4.0": - version "8.4.0" - resolved "https://registry.yarnpkg.com/@rollup/plugin-node-resolve/-/plugin-node-resolve-8.4.0.tgz#261d79a680e9dc3d86761c14462f24126ba83575" - integrity sha512-LFqKdRLn0ShtQyf6SBYO69bGE1upV6wUhBX0vFOUnLAyzx5cwp8svA0eHUnu8+YU57XOkrMtfG63QOpQx25pHQ== - dependencies: - "@rollup/pluginutils" "^3.1.0" - "@types/resolve" "1.17.1" - builtin-modules "^3.1.0" - deep-freeze "^0.0.1" - deepmerge "^4.2.2" - is-module "^1.0.0" - resolve "^1.17.0" - -"@rollup/pluginutils@^3.0.8", "@rollup/pluginutils@^3.1.0": - version "3.1.0" - resolved "https://registry.yarnpkg.com/@rollup/pluginutils/-/pluginutils-3.1.0.tgz#706b4524ee6dc8b103b3c995533e5ad680c02b9b" - integrity sha512-GksZ6pr6TpIjHm8h9lSQ8pi8BE9VeubNT0OMJ3B5uZJ8pz73NPiqOtCog/x2/QzM1ENChPKxMDhiQuRHsqc+lg== - dependencies: - "@types/estree" "0.0.39" - estree-walker "^1.0.1" - picomatch "^2.2.2" - -"@tensorflow-models/blazeface@^0.0.5": - version "0.0.5" - resolved "https://registry.yarnpkg.com/@tensorflow-models/blazeface/-/blazeface-0.0.5.tgz#6261fcc5de61a283ea409b69f6a851f44a809826" - integrity "sha1-YmH8xd5hooPqQJtp9qhR9EqAmCY= sha512-bIMJDV2CD8rr7v9OrIDdDZVh9sbk0EhlZdHaDFpgWUw3Lp21wUN7GSifOJVE5hV2ngmpzM+J12OH8bG1GZoDag==" - -"@tensorflow/tfjs-backend-cpu@link:../../../link-package/node_modules/@tensorflow/link-package/node_modules/@tensorflow/tfjs-backend-cpu": - version "0.0.0" - -"@tensorflow/tfjs-backend-cpu@link:../../../link-package/node_modules/@tensorflow/tfjs-backend-cpu": - version "0.0.0" - uid "" - -"@tensorflow/tfjs-backend-wasm@link:../../../link-package/node_modules/@tensorflow/tfjs-backend-wasm": - version "0.0.0" - uid "" - -"@tensorflow/tfjs-backend-webgl@link:../../../link-package/node_modules/@tensorflow/tfjs-backend-webgl": - version "0.0.0" - uid "" - -"@tensorflow/tfjs-converter@link:../../../link-package/node_modules/@tensorflow/tfjs-converter": - version "0.0.0" - uid "" - -"@tensorflow/tfjs-core@link:../../../link-package/node_modules/@tensorflow/tfjs-core": - version "0.0.0" - uid "" - -"@tensorflow/tfjs-data@link:../../../link-package/node_modules/@tensorflow/tfjs-data": - version "0.0.0" - uid "" - -"@tensorflow/tfjs-layers@link:../../../link-package/node_modules/@tensorflow/tfjs-layers": - version "0.0.0" - uid "" - -"@tensorflow/tfjs@link:../../../tfjs": - version "0.0.0" - uid "" - -"@types/color-name@^1.1.1": - version "1.1.1" - resolved "https://registry.yarnpkg.com/@types/color-name/-/color-name-1.1.1.tgz#1c1261bbeaa10a8055bbc5d8ab84b7b2afc846a0" - integrity "sha1-HBJhu+qhCoBVu8XYq4S3sq/IRqA= sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ==" - -"@types/emscripten@~0.0.34": - version "0.0.34" - resolved "https://registry.yarnpkg.com/@types/emscripten/-/emscripten-0.0.34.tgz#12b4a344274fb102ff2f6c877b37587bc3e46008" - integrity sha512-QSb9ojDincskc+uKMI0KXp8e1NALFINCrMlp8VGKGcTSxeEyRTTKyjWw75NYrCZHUsVEEEpr1tYHpbtaC++/sQ== - -"@types/eslint-scope@^3.7.3": - version "3.7.4" - resolved "https://registry.yarnpkg.com/@types/eslint-scope/-/eslint-scope-3.7.4.tgz#37fc1223f0786c39627068a12e94d6e6fc61de16" - integrity sha512-9K4zoImiZc3HlIp6AVUDE4CWYx22a+lhSZMYNpbjW04+YF0KWj4pJXnEMjdnFTiQibFFmElcsasJXDbdI/EPhA== - dependencies: - "@types/eslint" "*" - "@types/estree" "*" - -"@types/eslint@*": - version "7.2.6" - resolved "https://registry.yarnpkg.com/@types/eslint/-/eslint-7.2.6.tgz#5e9aff555a975596c03a98b59ecd103decc70c3c" - integrity "sha1-Xpr/VVqXVZbAOpi1ns0QPezHDDw= sha512-I+1sYH+NPQ3/tVqCeUSBwTE/0heyvtXqpIopUUArlBm0Kpocb8FbMa3AZ/ASKIFpN3rnEx932TTXDbt9OXsNDw==" - dependencies: - "@types/estree" "*" - "@types/json-schema" "*" - -"@types/estree@*", "@types/estree@^0.0.51": - version "0.0.51" - resolved "https://registry.yarnpkg.com/@types/estree/-/estree-0.0.51.tgz#cfd70924a25a3fd32b218e5e420e6897e1ac4f40" - integrity sha512-CuPgU6f3eT/XgKKPqKd/gLZV1Xmvf1a2R5POBOGQa6uv82xpls89HU5zKeVoyR8XzHd1RGNOlQlvUe3CFkjWNQ== - -"@types/estree@0.0.39": - version "0.0.39" - resolved "https://registry.yarnpkg.com/@types/estree/-/estree-0.0.39.tgz#e177e699ee1b8c22d23174caaa7422644389509f" - integrity sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw== - -"@types/json-schema@*", "@types/json-schema@^7.0.5": - version "7.0.6" - resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.6.tgz#f4c7ec43e81b319a9815115031709f26987891f0" - integrity sha512-3c+yGKvVP5Y9TYBEibGNR+kLtijnj7mYrXRg+WpFb2X9xm04g/DXYkfg4hmzJQosc9snFNUPkbYIhu+KAm6jJw== - -"@types/json-schema@^7.0.8": - version "7.0.11" - resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.11.tgz#d421b6c527a3037f7c84433fd2c4229e016863d3" - integrity sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ== - -"@types/long@^4.0.1": - version "4.0.2" - resolved "https://registry.yarnpkg.com/@types/long/-/long-4.0.2.tgz#b74129719fc8d11c01868010082d483b7545591a" - integrity sha512-MqTGEo5bj5t157U6fA/BiDynNkn0YknVdh48CMPkTSpFTVmvao5UQmm7uEF6xBEo7qIMAlY/JSleYaE6VOdpaA== - -"@types/node-fetch@^2.1.2": - version "2.6.4" - resolved "https://registry.yarnpkg.com/@types/node-fetch/-/node-fetch-2.6.4.tgz#1bc3a26de814f6bf466b25aeb1473fa1afe6a660" - integrity sha512-1ZX9fcN4Rvkvgv4E6PAY5WXUFWFcRWxZa3EW83UjycOB9ljJCedb2CupIP4RZMEwF/M3eTcCihbBRgwtGbg5Rg== - dependencies: - "@types/node" "*" - form-data "^3.0.0" - -"@types/node@*": - version "14.10.1" - resolved "https://registry.yarnpkg.com/@types/node/-/node-14.10.1.tgz#cc323bad8e8a533d4822f45ce4e5326f36e42177" - integrity "sha1-zDI7rY6KUz1IIvRc5OUybzbkIXc= sha512-aYNbO+FZ/3KGeQCEkNhHFRIzBOUgc7QvcVNKXbfnhDkSfwUv91JsQQa10rDgKSTSLkXZ1UIyPe4FJJNVgw1xWQ==" - -"@types/offscreencanvas@~2019.3.0": - version "2019.3.0" - resolved "https://registry.yarnpkg.com/@types/offscreencanvas/-/offscreencanvas-2019.3.0.tgz#3336428ec7e9180cf4566dfea5da04eb586a6553" - integrity sha512-esIJx9bQg+QYF0ra8GnvfianIY8qWB0GBx54PK5Eps6m+xTj86KLavHv6qDhzKcu5UUOgNfJ2pWaIIV7TRUd9Q== - -"@types/offscreencanvas@~2019.7.0": - version "2019.7.0" - resolved "https://registry.yarnpkg.com/@types/offscreencanvas/-/offscreencanvas-2019.7.0.tgz#e4a932069db47bb3eabeb0b305502d01586fa90d" - integrity sha512-PGcyveRIpL1XIqK8eBsmRBt76eFgtzuPiSTyKHZxnGemp2yzGzWpjYKAfK3wIMiU7eH+851yEpiuP8JZerTmWg== - -"@types/resolve@0.0.8": - version "0.0.8" - resolved "https://registry.yarnpkg.com/@types/resolve/-/resolve-0.0.8.tgz#f26074d238e02659e323ce1a13d041eee280e194" - integrity sha512-auApPaJf3NPfe18hSoJkp8EbZzer2ISk7o8mCC3M9he/a04+gbMF97NkpD2S8riMGvm4BMRI59/SZQSaLTKpsQ== - dependencies: - "@types/node" "*" - -"@types/resolve@1.17.1": - version "1.17.1" - resolved "https://registry.yarnpkg.com/@types/resolve/-/resolve-1.17.1.tgz#3afd6ad8967c77e4376c598a82ddd58f46ec45d6" - integrity sha512-yy7HuzQhj0dhGpD8RLXSZWEkLsV9ibvxvi6EiJ3bkqLAO1RGo0WbkWQiwpRlSFymTJRz0d3k5LM3kkx8ArDbLw== - dependencies: - "@types/node" "*" - -"@types/seedrandom@^2.4.28": - version "2.4.30" - resolved "https://registry.yarnpkg.com/@types/seedrandom/-/seedrandom-2.4.30.tgz#d2efe425869b84163c2d56e779dddadb9372cbfa" - integrity sha512-AnxLHewubLVzoF/A4qdxBGHCKifw8cY32iro3DQX9TPcetE95zBeVt3jnsvtvAUf1vwzMfwzp4t/L2yqPlnjkQ== - -"@webassemblyjs/ast@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.11.1.tgz#2bfd767eae1a6996f432ff7e8d7fc75679c0b6a7" - integrity sha512-ukBh14qFLjxTQNTXocdyksN5QdM28S1CxHt2rdskFyL+xFV7VremuBLVbmCePj+URalXBENx/9Lm7lnhihtCSw== - dependencies: - "@webassemblyjs/helper-numbers" "1.11.1" - "@webassemblyjs/helper-wasm-bytecode" "1.11.1" - -"@webassemblyjs/floating-point-hex-parser@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/floating-point-hex-parser/-/floating-point-hex-parser-1.11.1.tgz#f6c61a705f0fd7a6aecaa4e8198f23d9dc179e4f" - integrity sha512-iGRfyc5Bq+NnNuX8b5hwBrRjzf0ocrJPI6GWFodBFzmFnyvrQ83SHKhmilCU/8Jv67i4GJZBMhEzltxzcNagtQ== - -"@webassemblyjs/helper-api-error@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-api-error/-/helper-api-error-1.11.1.tgz#1a63192d8788e5c012800ba6a7a46c705288fd16" - integrity sha512-RlhS8CBCXfRUR/cwo2ho9bkheSXG0+NwooXcc3PAILALf2QLdFyj7KGsKRbVc95hZnhnERon4kW/D3SZpp6Tcg== - -"@webassemblyjs/helper-buffer@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-buffer/-/helper-buffer-1.11.1.tgz#832a900eb444884cde9a7cad467f81500f5e5ab5" - integrity sha512-gwikF65aDNeeXa8JxXa2BAk+REjSyhrNC9ZwdT0f8jc4dQQeDQ7G4m0f2QCLPJiMTTO6wfDmRmj/pW0PsUvIcA== - -"@webassemblyjs/helper-numbers@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-numbers/-/helper-numbers-1.11.1.tgz#64d81da219fbbba1e3bd1bfc74f6e8c4e10a62ae" - integrity sha512-vDkbxiB8zfnPdNK9Rajcey5C0w+QJugEglN0of+kmO8l7lDb77AnlKYQF7aarZuCrv+l0UvqL+68gSDr3k9LPQ== - dependencies: - "@webassemblyjs/floating-point-hex-parser" "1.11.1" - "@webassemblyjs/helper-api-error" "1.11.1" - "@xtuc/long" "4.2.2" - -"@webassemblyjs/helper-wasm-bytecode@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-wasm-bytecode/-/helper-wasm-bytecode-1.11.1.tgz#f328241e41e7b199d0b20c18e88429c4433295e1" - integrity sha512-PvpoOGiJwXeTrSf/qfudJhwlvDQxFgelbMqtq52WWiXC6Xgg1IREdngmPN3bs4RoO83PnL/nFrxucXj1+BX62Q== - -"@webassemblyjs/helper-wasm-section@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-wasm-section/-/helper-wasm-section-1.11.1.tgz#21ee065a7b635f319e738f0dd73bfbda281c097a" - integrity sha512-10P9No29rYX1j7F3EVPX3JvGPQPae+AomuSTPiF9eBQeChHI6iqjMIwR9JmOJXwpnn/oVGDk7I5IlskuMwU/pg== - dependencies: - "@webassemblyjs/ast" "1.11.1" - "@webassemblyjs/helper-buffer" "1.11.1" - "@webassemblyjs/helper-wasm-bytecode" "1.11.1" - "@webassemblyjs/wasm-gen" "1.11.1" - -"@webassemblyjs/ieee754@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/ieee754/-/ieee754-1.11.1.tgz#963929e9bbd05709e7e12243a099180812992614" - integrity sha512-hJ87QIPtAMKbFq6CGTkZYJivEwZDbQUgYd3qKSadTNOhVY7p+gfP6Sr0lLRVTaG1JjFj+r3YchoqRYxNH3M0GQ== - dependencies: - "@xtuc/ieee754" "^1.2.0" - -"@webassemblyjs/leb128@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/leb128/-/leb128-1.11.1.tgz#ce814b45574e93d76bae1fb2644ab9cdd9527aa5" - integrity sha512-BJ2P0hNZ0u+Th1YZXJpzW6miwqQUGcIHT1G/sf72gLVD9DZ5AdYTqPNbHZh6K1M5VmKvFXwGSWZADz+qBWxeRw== - dependencies: - "@xtuc/long" "4.2.2" - -"@webassemblyjs/utf8@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/utf8/-/utf8-1.11.1.tgz#d1f8b764369e7c6e6bae350e854dec9a59f0a3ff" - integrity sha512-9kqcxAEdMhiwQkHpkNiorZzqpGrodQQ2IGrHHxCy+Ozng0ofyMA0lTqiLkVs1uzTRejX+/O0EOT7KxqVPuXosQ== - -"@webassemblyjs/wasm-edit@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-edit/-/wasm-edit-1.11.1.tgz#ad206ebf4bf95a058ce9880a8c092c5dec8193d6" - integrity sha512-g+RsupUC1aTHfR8CDgnsVRVZFJqdkFHpsHMfJuWQzWU3tvnLC07UqHICfP+4XyL2tnr1amvl1Sdp06TnYCmVkA== - dependencies: - "@webassemblyjs/ast" "1.11.1" - "@webassemblyjs/helper-buffer" "1.11.1" - "@webassemblyjs/helper-wasm-bytecode" "1.11.1" - "@webassemblyjs/helper-wasm-section" "1.11.1" - "@webassemblyjs/wasm-gen" "1.11.1" - "@webassemblyjs/wasm-opt" "1.11.1" - "@webassemblyjs/wasm-parser" "1.11.1" - "@webassemblyjs/wast-printer" "1.11.1" - -"@webassemblyjs/wasm-gen@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-gen/-/wasm-gen-1.11.1.tgz#86c5ea304849759b7d88c47a32f4f039ae3c8f76" - integrity sha512-F7QqKXwwNlMmsulj6+O7r4mmtAlCWfO/0HdgOxSklZfQcDu0TpLiD1mRt/zF25Bk59FIjEuGAIyn5ei4yMfLhA== - dependencies: - "@webassemblyjs/ast" "1.11.1" - "@webassemblyjs/helper-wasm-bytecode" "1.11.1" - "@webassemblyjs/ieee754" "1.11.1" - "@webassemblyjs/leb128" "1.11.1" - "@webassemblyjs/utf8" "1.11.1" - -"@webassemblyjs/wasm-opt@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-opt/-/wasm-opt-1.11.1.tgz#657b4c2202f4cf3b345f8a4c6461c8c2418985f2" - integrity sha512-VqnkNqnZlU5EB64pp1l7hdm3hmQw7Vgqa0KF/KCNO9sIpI6Fk6brDEiX+iCOYrvMuBWDws0NkTOxYEb85XQHHw== - dependencies: - "@webassemblyjs/ast" "1.11.1" - "@webassemblyjs/helper-buffer" "1.11.1" - "@webassemblyjs/wasm-gen" "1.11.1" - "@webassemblyjs/wasm-parser" "1.11.1" - -"@webassemblyjs/wasm-parser@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-parser/-/wasm-parser-1.11.1.tgz#86ca734534f417e9bd3c67c7a1c75d8be41fb199" - integrity sha512-rrBujw+dJu32gYB7/Lup6UhdkPx9S9SnobZzRVL7VcBH9Bt9bCBLEuX/YXOOtBsOZ4NQrRykKhffRWHvigQvOA== - dependencies: - "@webassemblyjs/ast" "1.11.1" - "@webassemblyjs/helper-api-error" "1.11.1" - "@webassemblyjs/helper-wasm-bytecode" "1.11.1" - "@webassemblyjs/ieee754" "1.11.1" - "@webassemblyjs/leb128" "1.11.1" - "@webassemblyjs/utf8" "1.11.1" - -"@webassemblyjs/wast-printer@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/wast-printer/-/wast-printer-1.11.1.tgz#d0c73beda8eec5426f10ae8ef55cee5e7084c2f0" - integrity sha512-IQboUWM4eKzWW+N/jij2sRatKMh99QEelo3Eb2q0qXkvPRISAj8Qxtmw5itwqK+TTkBuUIE45AxYPToqPtL5gg== - dependencies: - "@webassemblyjs/ast" "1.11.1" - "@xtuc/long" "4.2.2" - -"@webgpu/types@0.1.30": - version "0.1.30" - resolved "https://registry.yarnpkg.com/@webgpu/types/-/types-0.1.30.tgz#b6406dc4a1c1e0d469028ceb30ddffbbd2fa706c" - integrity sha512-9AXJSmL3MzY8ZL//JjudA//q+2kBRGhLBFpkdGksWIuxrMy81nFrCzj2Am+mbh8WoU6rXmv7cY5E3rdlyru2Qg== - -"@webpack-cli/info@^1.1.0": - version "1.1.0" - resolved "https://registry.yarnpkg.com/@webpack-cli/info/-/info-1.1.0.tgz#c596d5bc48418b39df00c5ed7341bf0f102dbff1" - integrity "sha1-xZbVvEhBiznfAMXtc0G/DxAtv/E= sha512-uNWSdaYHc+f3LdIZNwhdhkjjLDDl3jP2+XBqAq9H8DjrJUvlOKdP8TNruy1yEaDfgpAIgbSAN7pye4FEHg9tYQ==" - dependencies: - envinfo "^7.7.3" - -"@webpack-cli/serve@^1.1.0": - version "1.1.0" - resolved "https://registry.yarnpkg.com/@webpack-cli/serve/-/serve-1.1.0.tgz#13ad38f89b6e53d1133bac0006a128217a6ebf92" - integrity "sha1-E604+JtuU9ETO6wABqEoIXpuv5I= sha512-7RfnMXCpJ/NThrhq4gYQYILB18xWyoQcBey81oIyVbmgbc6m5ZHHyFK+DyH7pLHJf0p14MxL4mTsoPAgBSTpIg==" - -"@xtuc/ieee754@^1.2.0": - version "1.2.0" - resolved "https://registry.yarnpkg.com/@xtuc/ieee754/-/ieee754-1.2.0.tgz#eef014a3145ae477a1cbc00cd1e552336dceb790" - integrity sha512-DX8nKgqcGwsc0eJSqYt5lwP4DH5FlHnmuWWBRy7X0NcaGR0ZtuyeESgMwTYVEtxmsNGY+qit4QYT/MIYTOTPeA== - -"@xtuc/long@4.2.2": - version "4.2.2" - resolved "https://registry.yarnpkg.com/@xtuc/long/-/long-4.2.2.tgz#d291c6a4e97989b5c61d9acf396ae4fe133a718d" - integrity sha512-NuHqBY1PB/D8xU6s/thBgOAiAP7HOYDQ32+BFZILJ8ivkUkAHQnWfn6WhL79Owj1qmUnoN/YPhktdIoucipkAQ== - -acorn-import-assertions@^1.7.6: - version "1.8.0" - resolved "https://registry.yarnpkg.com/acorn-import-assertions/-/acorn-import-assertions-1.8.0.tgz#ba2b5939ce62c238db6d93d81c9b111b29b855e9" - integrity sha512-m7VZ3jwz4eK6A4Vtt8Ew1/mNbP24u0FhdyfA7fSvnJR6LMdfOYnmuIrrJAgrYfYJ10F/otaHTtrtrtmHdMNzEw== - -acorn@^8.5.0, acorn@^8.7.1: - version "8.8.2" - resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.8.2.tgz#1b2f25db02af965399b9776b0c2c391276d37c4a" - integrity sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw== - -aggregate-error@^3.0.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/aggregate-error/-/aggregate-error-3.1.0.tgz#92670ff50f5359bdb7a3e0d40d0ec30c5737687a" - integrity sha512-4I7Td01quW/RpocfNayFdFVk1qSuoh0E7JrbRJ16nH01HhKFQ88INq9Sd+nd72zqRySlr9BmDA8xlEJ6vJMrYA== - dependencies: - clean-stack "^2.0.0" - indent-string "^4.0.0" - -ajv-keywords@^3.5.2: - version "3.5.2" - resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-3.5.2.tgz#31f29da5ab6e00d1c2d329acf7b5929614d5014d" - integrity sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ== - -ajv@^6.12.4: - version "6.12.5" - resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.5.tgz#19b0e8bae8f476e5ba666300387775fb1a00a4da" - integrity sha512-lRF8RORchjpKG50/WFf8xmg7sgCLFiYNNnqdKflk63whMQcWR5ngGjiSXkL9bjxy6B2npOK2HSMN49jEBMSkag== - dependencies: - fast-deep-equal "^3.1.1" - fast-json-stable-stringify "^2.0.0" - json-schema-traverse "^0.4.1" - uri-js "^4.2.2" - -ajv@^6.12.5: - version "6.12.6" - resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.6.tgz#baf5a62e802b07d977034586f8c3baf5adf26df4" - integrity sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g== - dependencies: - fast-deep-equal "^3.1.1" - fast-json-stable-stringify "^2.0.0" - json-schema-traverse "^0.4.1" - uri-js "^4.2.2" - -ansi-colors@^4.1.1: - version "4.1.1" - resolved "https://registry.yarnpkg.com/ansi-colors/-/ansi-colors-4.1.1.tgz#cbb9ae256bf750af1eab344f229aa27fe94ba348" - integrity sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA== - -ansi-regex@^5.0.0: - version "5.0.1" - resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.1.tgz#082cb2c89c9fe8659a311a53bd6a4dc5301db304" - integrity sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ== - -ansi-styles@^3.2.1: - version "3.2.1" - resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d" - integrity sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA== - dependencies: - color-convert "^1.9.0" - -ansi-styles@^4.0.0, ansi-styles@^4.1.0: - version "4.2.1" - resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-4.2.1.tgz#90ae75c424d008d2624c5bf29ead3177ebfcf359" - integrity "sha1-kK51xCTQCNJiTFvynq0xd+v881k= sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==" - dependencies: - "@types/color-name" "^1.1.1" - color-convert "^2.0.1" - -argparse@^1.0.10: - version "1.0.10" - resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911" - integrity sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg== - dependencies: - sprintf-js "~1.0.2" - -array-back@^4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/array-back/-/array-back-4.0.1.tgz#9b80312935a52062e1a233a9c7abeb5481b30e90" - integrity "sha1-m4AxKTWlIGLhojOpx6vrVIGzDpA= sha512-Z/JnaVEXv+A9xabHzN43FiiiWEE7gPCRXMrVmRm00tWbjZRul1iHm7ECzlyNq1p4a4ATXz+G9FJ3GqGOkOV3fg==" - -asynckit@^0.4.0: - version "0.4.0" - resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" - integrity sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q== - -balanced-match@^1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee" - integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw== - -big.js@^5.2.2: - version "5.2.2" - resolved "https://registry.yarnpkg.com/big.js/-/big.js-5.2.2.tgz#65f0af382f578bcdc742bd9c281e9cb2d7768328" - integrity sha512-vyL2OymJxmarO8gxMr0mhChsO9QGwhynfuu4+MHTAW6czfq9humCB7rKpUjDd9YUiDPU4mzpyupFSvOClAwbmQ== - -brace-expansion@^1.1.7: - version "1.1.11" - resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" - integrity sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA== - dependencies: - balanced-match "^1.0.0" - concat-map "0.0.1" - -browserslist@^4.14.5: - version "4.20.0" - resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.20.0.tgz#35951e3541078c125d36df76056e94738a52ebe9" - integrity sha512-bnpOoa+DownbciXj0jVGENf8VYQnE2LNWomhYuCsMmmx9Jd9lwq0WXODuwpSsp8AVdKM2/HorrzxAfbKvWTByQ== - dependencies: - caniuse-lite "^1.0.30001313" - electron-to-chromium "^1.4.76" - escalade "^3.1.1" - node-releases "^2.0.2" - picocolors "^1.0.0" - -buffer-from@^1.0.0: - version "1.1.2" - resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.2.tgz#2b146a6fd72e80b4f55d255f35ed59a3a9a41bd5" - integrity sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ== - -builtin-modules@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/builtin-modules/-/builtin-modules-3.1.0.tgz#aad97c15131eb76b65b50ef208e7584cd76a7484" - integrity sha512-k0KL0aWZuBt2lrxrcASWDfwOLMnodeQjodT/1SxEQAXsHANgo6ZC/VEaSEHCXt7aSTZ4/4H5LKa+tBXmW7Vtvw== - -cacache@^15.0.5: - version "15.0.5" - resolved "https://registry.yarnpkg.com/cacache/-/cacache-15.0.5.tgz#69162833da29170d6732334643c60e005f5f17d0" - integrity sha512-lloiL22n7sOjEEXdL8NAjTgv9a1u43xICE9/203qonkZUCj5X1UEWIdf2/Y0d6QcCtMzbKQyhrcDbdvlZTs/+A== - dependencies: - "@npmcli/move-file" "^1.0.1" - chownr "^2.0.0" - fs-minipass "^2.0.0" - glob "^7.1.4" - infer-owner "^1.0.4" - lru-cache "^6.0.0" - minipass "^3.1.1" - minipass-collect "^1.0.2" - minipass-flush "^1.0.5" - minipass-pipeline "^1.2.2" - mkdirp "^1.0.3" - p-map "^4.0.0" - promise-inflight "^1.0.1" - rimraf "^3.0.2" - ssri "^8.0.0" - tar "^6.0.2" - unique-filename "^1.1.1" - -camelcase@^5.0.0: - version "5.3.1" - resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-5.3.1.tgz#e3c9b31569e106811df242f715725a1f4c494320" - integrity sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg== - -caniuse-lite@^1.0.30001313: - version "1.0.30001316" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001316.tgz#b44a1f419f82d2e119aa0bbdab5ec15471796358" - integrity sha512-JgUdNoZKxPZFzbzJwy4hDSyGuH/gXz2rN51QmoR8cBQsVo58llD3A0vlRKKRt8FGf5u69P9eQyIH8/z9vN/S0Q== - -chalk@^2.0.0, chalk@^2.4.2: - version "2.4.2" - resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" - integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ== - dependencies: - ansi-styles "^3.2.1" - escape-string-regexp "^1.0.5" - supports-color "^5.3.0" - -chalk@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.0.tgz#4e14870a618d9e2edd97dd8345fd9d9dc315646a" - integrity sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A== - dependencies: - ansi-styles "^4.1.0" - supports-color "^7.1.0" - -chownr@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/chownr/-/chownr-2.0.0.tgz#15bfbe53d2eab4cf70f18a8cd68ebe5b3cb1dece" - integrity sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ== - -chrome-trace-event@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/chrome-trace-event/-/chrome-trace-event-1.0.2.tgz#234090ee97c7d4ad1a2c4beae27505deffc608a4" - integrity sha512-9e/zx1jw7B4CO+c/RXoCsfg/x1AfUBioy4owYH0bJprEYAx5hRFLRhWBqHAG57D0ZM4H7vxbP7bPe0VwhQRYDQ== - dependencies: - tslib "^1.9.0" - -clean-stack@^2.0.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/clean-stack/-/clean-stack-2.2.0.tgz#ee8472dbb129e727b31e8a10a427dee9dfe4008b" - integrity sha512-4diC9HaTE+KRAMWhDhrGOECgWZxoevMc5TlkObMqNSsVU62PYzXZ/SMTjzyGAFF1YusgxGcSWTEXBhp0CPwQ1A== - -cliui@^6.0.0: - version "6.0.0" - resolved "https://registry.yarnpkg.com/cliui/-/cliui-6.0.0.tgz#511d702c0c4e41ca156d7d0e96021f23e13225b1" - integrity sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ== - dependencies: - string-width "^4.2.0" - strip-ansi "^6.0.0" - wrap-ansi "^6.2.0" - -cliui@^7.0.0: - version "7.0.1" - resolved "https://registry.yarnpkg.com/cliui/-/cliui-7.0.1.tgz#a4cb67aad45cd83d8d05128fc9f4d8fbb887e6b3" - integrity sha512-rcvHOWyGyid6I1WjT/3NatKj2kDt9OdSHSXpyLXaMWFbKpGACNW8pRhhdPUq9MWUOdwn8Rz9AVETjF4105rZZQ== - dependencies: - string-width "^4.2.0" - strip-ansi "^6.0.0" - wrap-ansi "^7.0.0" - -color-convert@^1.9.0: - version "1.9.3" - resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8" - integrity sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg== - dependencies: - color-name "1.1.3" - -color-convert@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-2.0.1.tgz#72d3a68d598c9bdb3af2ad1e84f21d896abd4de3" - integrity sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ== - dependencies: - color-name "~1.1.4" - -color-name@1.1.3: - version "1.1.3" - resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25" - integrity sha1-p9BVi9icQveV3UIyj3QIMcpTvCU= - -color-name@~1.1.4: - version "1.1.4" - resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2" - integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA== - -colorette@^1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/colorette/-/colorette-1.2.1.tgz#4d0b921325c14faf92633086a536db6e89564b1b" - integrity "sha1-TQuSEyXBT6+SYzCGpTbbbolWSxs= sha512-puCDz0CzydiSYOrnXpz/PKd69zRrribezjtE9yd4zvytoRc8+RY/KJPvtPFKZS3E3wP6neGyMe0vOTlHO5L3Pw==" - -combined-stream@^1.0.8: - version "1.0.8" - resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.8.tgz#c3d45a8b34fd730631a110a8a2520682b31d5a7f" - integrity sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg== - dependencies: - delayed-stream "~1.0.0" - -command-line-usage@^6.1.0: - version "6.1.1" - resolved "https://registry.yarnpkg.com/command-line-usage/-/command-line-usage-6.1.1.tgz#c908e28686108917758a49f45efb4f02f76bc03f" - integrity "sha1-yQjihoYQiRd1ikn0XvtPAvdrwD8= sha512-F59pEuAR9o1SF/bD0dQBDluhpT4jJQNWUHEuVBqpDmCUo6gPjCi+m9fCWnWZVR/oG6cMTUms4h+3NPl74wGXvA==" - dependencies: - array-back "^4.0.1" - chalk "^2.4.2" - table-layout "^1.0.1" - typical "^5.2.0" - -commander@^2.20.0: - version "2.20.3" - resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33" - integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ== - -commander@^6.2.0: - version "6.2.0" - resolved "https://registry.yarnpkg.com/commander/-/commander-6.2.0.tgz#b990bfb8ac030aedc6d11bc04d1488ffef56db75" - integrity "sha1-uZC/uKwDCu3G0RvATRSI/+9W23U= sha512-zP4jEKbe8SHzKJYQmq8Y9gYjtO/POJLgIdKgV7B9qNmABVFVc+ctqSX6iXh4mCpJfRBOabiZ2YKPg8ciDw6C+Q==" - -commondir@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/commondir/-/commondir-1.0.1.tgz#ddd800da0c66127393cca5950ea968a3aaf1253b" - integrity sha1-3dgA2gxmEnOTzKWVDqloo6rxJTs= - -concat-map@0.0.1: - version "0.0.1" - resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" - integrity sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg== - -core-js@3.29.1: - version "3.29.1" - resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.29.1.tgz#40ff3b41588b091aaed19ca1aa5cb111803fa9a6" - integrity sha512-+jwgnhg6cQxKYIIjGtAHq2nwUOolo9eoFZ4sHfUH09BLXBgxnH4gA0zEd+t+BO2cNB8idaBtZFcFTRjQJRJmAw== - -cross-spawn@^7.0.0: - version "7.0.3" - resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6" - integrity sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w== - dependencies: - path-key "^3.1.0" - shebang-command "^2.0.0" - which "^2.0.1" - -decamelize@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" - integrity sha1-9lNNFRSCabIDUue+4m9QH5oZEpA= - -deep-extend@~0.6.0: - version "0.6.0" - resolved "https://registry.yarnpkg.com/deep-extend/-/deep-extend-0.6.0.tgz#c4fa7c95404a17a9c3e8ca7e1537312b736330ac" - integrity sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA== - -deep-freeze@^0.0.1: - version "0.0.1" - resolved "https://registry.yarnpkg.com/deep-freeze/-/deep-freeze-0.0.1.tgz#3a0b0005de18672819dfd38cd31f91179c893e84" - integrity sha1-OgsABd4YZygZ39OM0x+RF5yJPoQ= - -deepmerge@^4.2.2: - version "4.2.2" - resolved "https://registry.yarnpkg.com/deepmerge/-/deepmerge-4.2.2.tgz#44d2ea3679b8f4d4ffba33f03d865fc1e7bf4955" - integrity sha512-FJ3UgI4gIl+PHZm53knsuSFpE+nESMr7M4v9QcgB7S63Kj/6WqMiFQJpBBYz1Pt+66bZpP3Q7Lye0Oo9MPKEdg== - -delayed-stream@~1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" - integrity sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ== - -electron-to-chromium@^1.4.76: - version "1.4.82" - resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.82.tgz#51e123ca434b1eba8c434ece2b54f095b304a651" - integrity sha512-Ks+ANzLoIrFDUOJdjxYMH6CMKB8UQo5modAwvSZTxgF+vEs/U7G5IbWFUp6dS4klPkTDVdxbORuk8xAXXhMsWw== - -emoji-regex@^8.0.0: - version "8.0.0" - resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37" - integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A== - -emojis-list@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/emojis-list/-/emojis-list-3.0.0.tgz#5570662046ad29e2e916e71aae260abdff4f6a78" - integrity sha512-/kyM18EfinwXZbno9FyUGeFh87KC8HRQBQGildHZbEuRyWFOmv1U10o9BBp8XVZDVNNuQKyIGIu5ZYAAXJ0V2Q== - -end-of-stream@^1.1.0: - version "1.4.4" - resolved "https://registry.yarnpkg.com/end-of-stream/-/end-of-stream-1.4.4.tgz#5ae64a5f45057baf3626ec14da0ca5e4b2431eb0" - integrity sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q== - dependencies: - once "^1.4.0" - -enhanced-resolve@^5.10.0: - version "5.12.0" - resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-5.12.0.tgz#300e1c90228f5b570c4d35babf263f6da7155634" - integrity sha512-QHTXI/sZQmko1cbDoNAa3mJ5qhWUUNAq3vR0/YiD379fWQrcfuoX1+HW2S0MTt7XmoPLapdaDKUtelUSPic7hQ== - dependencies: - graceful-fs "^4.2.4" - tapable "^2.2.0" - -enquirer@^2.3.6: - version "2.3.6" - resolved "https://registry.yarnpkg.com/enquirer/-/enquirer-2.3.6.tgz#2a7fe5dd634a1e4125a975ec994ff5456dc3734d" - integrity sha512-yjNnPr315/FjS4zIsUxYguYUPP2e1NK4d7E7ZOLiyYCcbFBiTMyID+2wvm2w6+pZ/odMA7cRkjhsPbltwBOrLg== - dependencies: - ansi-colors "^4.1.1" - -envinfo@^7.7.3: - version "7.7.3" - resolved "https://registry.yarnpkg.com/envinfo/-/envinfo-7.7.3.tgz#4b2d8622e3e7366afb8091b23ed95569ea0208cc" - integrity "sha1-Sy2GIuPnNmr7gJGyPtlVaeoCCMw= sha512-46+j5QxbPWza0PB1i15nZx0xQ4I/EfQxg9J8Had3b408SV63nEtor2e+oiY63amTo9KTuh2a3XLObNwduxYwwA==" - -es-module-lexer@^0.9.0: - version "0.9.3" - resolved "https://registry.yarnpkg.com/es-module-lexer/-/es-module-lexer-0.9.3.tgz#6f13db00cc38417137daf74366f535c8eb438f19" - integrity sha512-1HQ2M2sPtxwnvOvT1ZClHyQDiggdNjURWpY2we6aMKCQiUVxTmVs2UYPLIrD84sS+kMdUwfBSylbJPwNnBrnHQ== - -escalade@^3.0.2: - version "3.1.0" - resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.1.0.tgz#e8e2d7c7a8b76f6ee64c2181d6b8151441602d4e" - integrity sha512-mAk+hPSO8fLDkhV7V0dXazH5pDc6MrjBTPyD3VeKzxnVFjH1MIxbCdqGZB9O8+EwWakZs3ZCbDS4IpRt79V1ig== - -escalade@^3.1.1: - version "3.1.1" - resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.1.1.tgz#d8cfdc7000965c5a0174b4a82eaa5c0552742e40" - integrity sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw== - -escape-goat@^2.0.0: - version "2.1.1" - resolved "https://registry.yarnpkg.com/escape-goat/-/escape-goat-2.1.1.tgz#1b2dc77003676c457ec760b2dc68edb648188675" - integrity sha512-8/uIhbG12Csjy2JEW7D9pHbreaVaS/OpN3ycnyvElTdwM5n6GY6W6e2IPemfvGZeUMqZ9A/3GqIZMgKnBhAw/Q== - -escape-string-regexp@^1.0.5: - version "1.0.5" - resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" - integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ= - -eslint-scope@5.1.1: - version "5.1.1" - resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-5.1.1.tgz#e786e59a66cb92b3f6c1fb0d508aab174848f48c" - integrity sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw== - dependencies: - esrecurse "^4.3.0" - estraverse "^4.1.1" - -esrecurse@^4.3.0: - version "4.3.0" - resolved "https://registry.yarnpkg.com/esrecurse/-/esrecurse-4.3.0.tgz#7ad7964d679abb28bee72cec63758b1c5d2c9921" - integrity sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag== - dependencies: - estraverse "^5.2.0" - -estraverse@^4.1.1: - version "4.3.0" - resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-4.3.0.tgz#398ad3f3c5a24948be7725e83d11a7de28cdbd1d" - integrity sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw== - -estraverse@^5.2.0: - version "5.2.0" - resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-5.2.0.tgz#307df42547e6cc7324d3cf03c155d5cdb8c53880" - integrity sha512-BxbNGGNm0RyRYvUdHpIwv9IWzeM9XClbOxwoATuFdOE7ZE6wHL+HQ5T8hoPM+zHvmKzzsEqhgy0GrQ5X13afiQ== - -estree-walker@^0.6.1: - version "0.6.1" - resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-0.6.1.tgz#53049143f40c6eb918b23671d1fe3219f3a1b362" - integrity sha512-SqmZANLWS0mnatqbSfRP5g8OXZC12Fgg1IwNtLsyHDzJizORW4khDfjPqJZsemPWBB2uqykUah5YpQ6epsqC/w== - -estree-walker@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-1.0.1.tgz#31bc5d612c96b704106b477e6dd5d8aa138cb700" - integrity sha512-1fMXF3YP4pZZVozF8j/ZLfvnR8NSIljt56UhbZ5PeeDmmGHpgpdwQt7ITlGvYaQukCvuBRMLEiKiYC+oeIg4cg== - -events@^3.2.0: - version "3.2.0" - resolved "https://registry.yarnpkg.com/events/-/events-3.2.0.tgz#93b87c18f8efcd4202a461aec4dfc0556b639379" - integrity sha512-/46HWwbfCX2xTawVfkKLGxMifJYQBWMwY1mjywRtb4c9x8l5NP3KoJtnIOiL1hfdRkIuYhETxQlo62IF8tcnlg== - -execa@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/execa/-/execa-4.1.0.tgz#4e5491ad1572f2f17a77d388c6c857135b22847a" - integrity "sha1-TlSRrRVy8vF6d9OIxshXE1sihHo= sha512-j5W0//W7f8UxAn8hXVnwG8tLwdiUy4FJLcSupCg6maBYZDpyBvTApK7KyuI4bKj8KOh1r2YH+6ucuYtJv1bTZA==" - dependencies: - cross-spawn "^7.0.0" - get-stream "^5.0.0" - human-signals "^1.1.1" - is-stream "^2.0.0" - merge-stream "^2.0.0" - npm-run-path "^4.0.0" - onetime "^5.1.0" - signal-exit "^3.0.2" - strip-final-newline "^2.0.0" - -fast-deep-equal@^3.1.1: - version "3.1.3" - resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525" - integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q== - -fast-json-stable-stringify@^2.0.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz#874bf69c6f404c2b5d99c481341399fd55892633" - integrity sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw== - -file-loader@^6.1.0: - version "6.1.0" - resolved "https://registry.yarnpkg.com/file-loader/-/file-loader-6.1.0.tgz#65b9fcfb0ea7f65a234a1f10cdd7f1ab9a33f253" - integrity sha512-26qPdHyTsArQ6gU4P1HJbAbnFTyT2r0pG7czh1GFAd9TZbj0n94wWbupgixZH/ET/meqi2/5+F7DhW4OAXD+Lg== - dependencies: - loader-utils "^2.0.0" - schema-utils "^2.7.1" - -find-cache-dir@^3.3.1: - version "3.3.1" - resolved "https://registry.yarnpkg.com/find-cache-dir/-/find-cache-dir-3.3.1.tgz#89b33fad4a4670daa94f855f7fbe31d6d84fe880" - integrity sha512-t2GDMt3oGC/v+BMwzmllWDuJF/xcDtE5j/fCGbqDD7OLuJkj0cfh1YSA5VKPvwMeLFLNDBkwOKZ2X85jGLVftQ== - dependencies: - commondir "^1.0.1" - make-dir "^3.0.2" - pkg-dir "^4.1.0" - -find-up@^4.0.0, find-up@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/find-up/-/find-up-4.1.0.tgz#97afe7d6cdc0bc5928584b7c8d7b16e8a9aa5d19" - integrity sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw== - dependencies: - locate-path "^5.0.0" - path-exists "^4.0.0" - -form-data@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/form-data/-/form-data-3.0.1.tgz#ebd53791b78356a99af9a300d4282c4d5eb9755f" - integrity sha512-RHkBKtLWUVwd7SqRIvCZMEvAMoGUp0XU+seQiZejj0COz3RI3hWP4sCv3gZWWLjJTd7rGwcsF5eKZGii0r/hbg== - dependencies: - asynckit "^0.4.0" - combined-stream "^1.0.8" - mime-types "^2.1.12" - -fs-minipass@^2.0.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/fs-minipass/-/fs-minipass-2.1.0.tgz#7f5036fdbf12c63c169190cbe4199c852271f9fb" - integrity sha512-V/JgOLFCS+R6Vcq0slCuaeWEdNC3ouDlJMNIsacH2VtALiu9mV4LPrHc5cDl8k5aw6J8jwgWWpiTo5RYhmIzvg== - dependencies: - minipass "^3.0.0" - -fs.realpath@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" - integrity sha1-FQStJSMVjKpA20onh8sBQRmU6k8= - -fsevents@~2.1.2: - version "2.1.3" - resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.1.3.tgz#fb738703ae8d2f9fe900c33836ddebee8b97f23e" - integrity sha512-Auw9a4AxqWpa9GUfj370BMPzzyncfBABW8Mab7BGWBYDj4Isgq+cDKtx0i6u9jcX9pQDnswsaaOTgTmA5pEjuQ== - -function-bind@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d" - integrity sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A== - -get-caller-file@^2.0.1, get-caller-file@^2.0.5: - version "2.0.5" - resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e" - integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg== - -get-stream@^5.0.0: - version "5.2.0" - resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-5.2.0.tgz#4966a1795ee5ace65e706c4b7beb71257d6e22d3" - integrity sha512-nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA== - dependencies: - pump "^3.0.0" - -glob-to-regexp@^0.4.1: - version "0.4.1" - resolved "https://registry.yarnpkg.com/glob-to-regexp/-/glob-to-regexp-0.4.1.tgz#c75297087c851b9a578bd217dd59a92f59fe546e" - integrity sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw== - -glob@^7.1.2, glob@^7.1.3, glob@^7.1.4: - version "7.1.6" - resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.6.tgz#141f33b81a7c2492e125594307480c46679278a6" - integrity sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA== - dependencies: - fs.realpath "^1.0.0" - inflight "^1.0.4" - inherits "2" - minimatch "^3.0.4" - once "^1.3.0" - path-is-absolute "^1.0.0" - -graceful-fs@^4.1.2, graceful-fs@^4.2.4, graceful-fs@^4.2.9: - version "4.2.10" - resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.10.tgz#147d3a006da4ca3ce14728c7aefc287c367d7a6c" - integrity sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA== - -has-flag@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd" - integrity sha1-tdRU3CGZriJWmfNGfloH87lVuv0= - -has-flag@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b" - integrity sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ== - -has@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/has/-/has-1.0.3.tgz#722d7cbfc1f6aa8241f16dd814e011e1f41e8796" - integrity sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw== - dependencies: - function-bind "^1.1.1" - -human-signals@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-1.1.1.tgz#c5b1cd14f50aeae09ab6c59fe63ba3395fe4dfa3" - integrity "sha1-xbHNFPUK6uCatsWf5jujOV/k36M= sha512-SEQu7vl8KjNL2eoGBLF3+wAjpsNfA9XMlXAYj/3EdaNfAlxKthD1xjEQfGOUhllCGGJVNY34bRr6lPINhNjyZw==" - -import-local@^3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/import-local/-/import-local-3.0.2.tgz#a8cfd0431d1de4a2199703d003e3e62364fa6db6" - integrity sha512-vjL3+w0oulAVZ0hBHnxa/Nm5TAurf9YLQJDhqRZyqb+VKGOB6LU8t9H1Nr5CIo16vh9XfJTOoHwU0B71S557gA== - dependencies: - pkg-dir "^4.2.0" - resolve-cwd "^3.0.0" - -imurmurhash@^0.1.4: - version "0.1.4" - resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea" - integrity sha1-khi5srkoojixPcT7a21XbyMUU+o= - -indent-string@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/indent-string/-/indent-string-4.0.0.tgz#624f8f4497d619b2d9768531d58f4122854d7251" - integrity sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg== - -infer-owner@^1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/infer-owner/-/infer-owner-1.0.4.tgz#c4cefcaa8e51051c2a40ba2ce8a3d27295af9467" - integrity sha512-IClj+Xz94+d7irH5qRyfJonOdfTzuDaifE6ZPWfx0N0+/ATZCbuTPq2prFl526urkQd90WyUKIh1DfBQ2hMz9A== - -inflight@^1.0.4: - version "1.0.6" - resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" - integrity sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk= - dependencies: - once "^1.3.0" - wrappy "1" - -inherits@2: - version "2.0.4" - resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" - integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== - -interpret@^2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/interpret/-/interpret-2.2.0.tgz#1a78a0b5965c40a5416d007ad6f50ad27c417df9" - integrity sha512-Ju0Bz/cEia55xDwUWEa8+olFpCiQoypjnQySseKtmjNrnps3P+xfpUmGr90T7yjlVJmOtybRvPXhKMbHr+fWnw== - -is-core-module@^2.1.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.2.0.tgz#97037ef3d52224d85163f5597b2b63d9afed981a" - integrity sha512-XRAfAdyyY5F5cOXn7hYQDqh2Xmii+DEfIcQGxK/uNwMHhIkPWO0g8msXcbzLe+MpGoR951MlqM/2iIlU4vKDdQ== - dependencies: - has "^1.0.3" - -is-docker@^2.0.0: - version "2.1.1" - resolved "https://registry.yarnpkg.com/is-docker/-/is-docker-2.1.1.tgz#4125a88e44e450d384e09047ede71adc2d144156" - integrity sha512-ZOoqiXfEwtGknTiuDEy8pN2CfE3TxMHprvNer1mXiqwkOT77Rw3YVrUQ52EqAOU3QAWDQ+bQdx7HJzrv7LS2Hw== - -is-fullwidth-code-point@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz#f116f8064fe90b3f7844a38997c0b75051269f1d" - integrity sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg== - -is-module@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/is-module/-/is-module-1.0.0.tgz#3258fb69f78c14d5b815d664336b4cffb6441591" - integrity sha1-Mlj7afeMFNW4FdZkM2tM/7ZEFZE= - -is-reference@^1.1.2: - version "1.2.1" - resolved "https://registry.yarnpkg.com/is-reference/-/is-reference-1.2.1.tgz#8b2dac0b371f4bc994fdeaba9eb542d03002d0b7" - integrity sha512-U82MsXXiFIrjCK4otLT+o2NA2Cd2g5MLoOVXUZjIOhLurrRxpEXzI8O0KZHr3IjLvlAH1kTPYSuqer5T9ZVBKQ== - dependencies: - "@types/estree" "*" - -is-stream@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-2.0.0.tgz#bde9c32680d6fae04129d6ac9d921ce7815f78e3" - integrity sha512-XCoy+WlUr7d1+Z8GgSuXmpuUFC9fOhRXglJMx+dwLKTkL44Cjd4W1Z5P+BQZpr+cR93aGP4S/s7Ftw6Nd/kiEw== - -is-wsl@^2.1.1: - version "2.2.0" - resolved "https://registry.yarnpkg.com/is-wsl/-/is-wsl-2.2.0.tgz#74a4c76e77ca9fd3f932f290c17ea326cd157271" - integrity sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww== - dependencies: - is-docker "^2.0.0" - -isexe@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" - integrity sha1-6PvzdNxVb/iUehDcsFctYz8s+hA= - -jest-worker@^26.0.0, jest-worker@^26.3.0: - version "26.3.0" - resolved "https://registry.yarnpkg.com/jest-worker/-/jest-worker-26.3.0.tgz#7c8a97e4f4364b4f05ed8bca8ca0c24de091871f" - integrity "sha1-fIqX5PQ2S08F7YvKjKDCTeCRhx8= sha512-Vmpn2F6IASefL+DVBhPzI2J9/GJUsqzomdeN+P+dK8/jKxbh8R3BtFnx3FIta7wYlPU62cpJMJQo4kuOowcMnw==" - dependencies: - "@types/node" "*" - merge-stream "^2.0.0" - supports-color "^7.0.0" - -jest-worker@^27.4.5: - version "27.5.1" - resolved "https://registry.yarnpkg.com/jest-worker/-/jest-worker-27.5.1.tgz#8d146f0900e8973b106b6f73cc1e9a8cb86f8db0" - integrity sha512-7vuh85V5cdDofPyxn58nrPjBktZo0u9x1g8WtjQol+jZDaE+fhN+cIvTj11GndBnMnyfrUOG1sZQxCdjKh+DKg== - dependencies: - "@types/node" "*" - merge-stream "^2.0.0" - supports-color "^8.0.0" - -js-tokens@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" - integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ== - -json-parse-even-better-errors@^2.3.1: - version "2.3.1" - resolved "https://registry.yarnpkg.com/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz#7c47805a94319928e05777405dc12e1f7a4ee02d" - integrity sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w== - -json-schema-traverse@^0.4.1: - version "0.4.1" - resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz#69f6a87d9513ab8bb8fe63bdb0979c448e684660" - integrity sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg== - -json5@^2.1.2: - version "2.2.3" - resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.3.tgz#78cd6f1a19bdc12b73db5ad0c61efd66c1e29283" - integrity sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg== - -leven@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/leven/-/leven-3.1.0.tgz#77891de834064cccba82ae7842bb6b14a13ed7f2" - integrity "sha1-d4kd6DQGTMy6gq54QrtrFKE+1/I= sha512-qsda+H8jTaUaN/x5vzW2rzc+8Rw4TAQ/4KjB46IwK5VH+IlVeeeje/EoZRpiXvIqjFgK84QffqPztGI3VBLG1A==" - -loader-runner@^4.2.0: - version "4.3.0" - resolved "https://registry.yarnpkg.com/loader-runner/-/loader-runner-4.3.0.tgz#c1b4a163b99f614830353b16755e7149ac2314e1" - integrity sha512-3R/1M+yS3j5ou80Me59j7F9IMs4PXs3VqRrm0TU3AbKPxlmpoY1TNscJV/oGJXo8qCatFGTfDbY6W6ipGOYXfg== - -loader-utils@^2.0.0: - version "2.0.4" - resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-2.0.4.tgz#8b5cb38b5c34a9a018ee1fc0e6a066d1dfcc528c" - integrity sha512-xXqpXoINfFhgua9xiqD8fPFHgkoq1mmmpE92WlDbm9rNRd/EbRb+Gqf908T2DMfuHjjJlksiK2RbHVOdD/MqSw== - dependencies: - big.js "^5.2.2" - emojis-list "^3.0.0" - json5 "^2.1.2" - -locate-path@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-5.0.0.tgz#1afba396afd676a6d42504d0a67a3a7eb9f62aa0" - integrity sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g== - dependencies: - p-locate "^4.1.0" - -lodash@^4.17.15: - version "4.17.21" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c" - integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg== - -long@4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/long/-/long-4.0.0.tgz#9a7b71cfb7d361a194ea555241c92f7468d5bf28" - integrity sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA== - -lru-cache@^6.0.0: - version "6.0.0" - resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-6.0.0.tgz#6d6fe6570ebd96aaf90fcad1dafa3b2566db3a94" - integrity sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA== - dependencies: - yallist "^4.0.0" - -magic-string@^0.25.2: - version "0.25.7" - resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.25.7.tgz#3f497d6fd34c669c6798dcb821f2ef31f5445051" - integrity sha512-4CrMT5DOHTDk4HYDlzmwu4FVCcIYI8gauveasrdCu2IKIFOJ3f0v/8MDGJCDL9oD2ppz/Av1b0Nj345H9M+XIA== - dependencies: - sourcemap-codec "^1.4.4" - -make-dir@^3.0.2: - version "3.1.0" - resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-3.1.0.tgz#415e967046b3a7f1d185277d84aa58203726a13f" - integrity sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw== - dependencies: - semver "^6.0.0" - -merge-stream@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/merge-stream/-/merge-stream-2.0.0.tgz#52823629a14dd00c9770fb6ad47dc6310f2c1f60" - integrity sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w== - -mime-db@1.44.0: - version "1.44.0" - resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.44.0.tgz#fa11c5eb0aca1334b4233cb4d52f10c5a6272f92" - integrity sha512-/NOTfLrsPBVeH7YtFPgsVWveuL+4SjjYxaQ1xtM1KMFj7HdxlBlxeyNLzhyJVx7r4rZGJAZ/6lkKCitSc/Nmpg== - -mime-db@1.52.0: - version "1.52.0" - resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.52.0.tgz#bbabcdc02859f4987301c856e3387ce5ec43bf70" - integrity sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg== - -mime-types@^2.1.12: - version "2.1.35" - resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.35.tgz#381a871b62a734450660ae3deee44813f70d959a" - integrity sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw== - dependencies: - mime-db "1.52.0" - -mime-types@^2.1.27: - version "2.1.27" - resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.27.tgz#47949f98e279ea53119f5722e0f34e529bec009f" - integrity sha512-JIhqnCasI9yD+SsmkquHBxTSEuZdQX5BuQnS2Vc7puQQQ+8yiP5AY5uWhpdv4YL4VM5c6iliiYWPgJ/nJQLp7w== - dependencies: - mime-db "1.44.0" - -mimic-fn@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-2.1.0.tgz#7ed2c2ccccaf84d3ffcb7a69b57711fc2083401b" - integrity sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg== - -minimatch@^3.0.4: - version "3.1.2" - resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b" - integrity sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw== - dependencies: - brace-expansion "^1.1.7" - -minimist@1.2.6: - version "1.2.6" - resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.6.tgz#8637a5b759ea0d6e98702cfb3a9283323c93af44" - integrity sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q== - -minipass-collect@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/minipass-collect/-/minipass-collect-1.0.2.tgz#22b813bf745dc6edba2576b940022ad6edc8c617" - integrity sha512-6T6lH0H8OG9kITm/Jm6tdooIbogG9e0tLgpY6mphXSm/A9u8Nq1ryBG+Qspiub9LjWlBPsPS3tWQ/Botq4FdxA== - dependencies: - minipass "^3.0.0" - -minipass-flush@^1.0.5: - version "1.0.5" - resolved "https://registry.yarnpkg.com/minipass-flush/-/minipass-flush-1.0.5.tgz#82e7135d7e89a50ffe64610a787953c4c4cbb373" - integrity sha512-JmQSYYpPUqX5Jyn1mXaRwOda1uQ8HP5KAT/oDSLCzt1BYRhQU0/hDtsB1ufZfEEzMZ9aAVmsBw8+FWsIXlClWw== - dependencies: - minipass "^3.0.0" - -minipass-pipeline@^1.2.2: - version "1.2.4" - resolved "https://registry.yarnpkg.com/minipass-pipeline/-/minipass-pipeline-1.2.4.tgz#68472f79711c084657c067c5c6ad93cddea8214c" - integrity sha512-xuIq7cIOt09RPRJ19gdi4b+RiNvDFYe5JH+ggNvBqGqpQXcru3PcRmOZuHBKWK1Txf9+cQ+HMVN4d6z46LZP7A== - dependencies: - minipass "^3.0.0" - -minipass@^3.0.0, minipass@^3.1.1: - version "3.1.3" - resolved "https://registry.yarnpkg.com/minipass/-/minipass-3.1.3.tgz#7d42ff1f39635482e15f9cdb53184deebd5815fd" - integrity sha512-Mgd2GdMVzY+x3IJ+oHnVM+KG3lA5c8tnabyJKmHSaG2kAGpudxuOf8ToDkhumF7UzME7DecbQE9uOZhNm7PuJg== - dependencies: - yallist "^4.0.0" - -minizlib@^2.1.1: - version "2.1.2" - resolved "https://registry.yarnpkg.com/minizlib/-/minizlib-2.1.2.tgz#e90d3466ba209b932451508a11ce3d3632145931" - integrity sha512-bAxsR8BVfj60DWXHE3u30oHzfl4G7khkSuPW+qvpd7jFRHm7dLxOjUk1EHACJ/hxLY8phGJ0YhYHZo7jil7Qdg== - dependencies: - minipass "^3.0.0" - yallist "^4.0.0" - -mkdirp@^1.0.3, mkdirp@^1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-1.0.4.tgz#3eb5ed62622756d79a5f0e2a221dfebad75c2f7e" - integrity sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw== - -nanoid@^3.0.1: - version "3.3.1" - resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.1.tgz#6347a18cac88af88f58af0b3594b723d5e99bb35" - integrity sha512-n6Vs/3KGyxPQd6uO0eH4Bv0ojGSUvuLlIHtC3Y0kEO23YRge8H9x1GCzLn28YX0H66pMkxuaeESFq4tKISKwdw== - -neo-async@^2.6.2: - version "2.6.2" - resolved "https://registry.yarnpkg.com/neo-async/-/neo-async-2.6.2.tgz#b4aafb93e3aeb2d8174ca53cf163ab7d7308305f" - integrity sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw== - -node-fetch@2.6.7, node-fetch@~2.6.1: - version "2.6.7" - resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.7.tgz#24de9fba827e3b4ae44dc8b20256a379160052ad" - integrity sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ== - dependencies: - whatwg-url "^5.0.0" - -node-releases@^2.0.2: - version "2.0.2" - resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-2.0.2.tgz#7139fe71e2f4f11b47d4d2986aaf8c48699e0c01" - integrity sha512-XxYDdcQ6eKqp/YjI+tb2C5WM2LgjnZrfYg4vgQt49EK268b6gYCHsBLrK2qvJo4FmCtqmKezb0WZFK4fkrZNsg== - -npm-run-path@^4.0.0: - version "4.0.1" - resolved "https://registry.yarnpkg.com/npm-run-path/-/npm-run-path-4.0.1.tgz#b7ecd1e5ed53da8e37a55e1c2269e0b97ed748ea" - integrity sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw== - dependencies: - path-key "^3.0.0" - -once@^1.3.0, once@^1.3.1, once@^1.4.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" - integrity sha1-WDsap3WWHUsROsF9nFC6753Xa9E= - dependencies: - wrappy "1" - -onetime@^5.1.0: - version "5.1.2" - resolved "https://registry.yarnpkg.com/onetime/-/onetime-5.1.2.tgz#d0e96ebb56b07476df1dd9c4806e5237985ca45e" - integrity sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg== - dependencies: - mimic-fn "^2.1.0" - -open@^7.0.3: - version "7.2.1" - resolved "https://registry.yarnpkg.com/open/-/open-7.2.1.tgz#07b0ade11a43f2a8ce718480bdf3d7563a095195" - integrity "sha1-B7Ct4RpD8qjOcYSAvfPXVjoJUZU= sha512-xbYCJib4spUdmcs0g/2mK1nKo/jO2T7INClWd/beL7PFkXRWgr8B23ssDHX/USPn2M2IjDR5UdpYs6I67SnTSA==" - dependencies: - is-docker "^2.0.0" - is-wsl "^2.1.1" - -p-limit@^2.2.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-2.3.0.tgz#3dd33c647a214fdfffd835933eb086da0dc21db1" - integrity sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w== - dependencies: - p-try "^2.0.0" - -p-limit@^3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-3.0.2.tgz#1664e010af3cadc681baafd3e2a437be7b0fb5fe" - integrity sha512-iwqZSOoWIW+Ew4kAGUlN16J4M7OB3ysMLSZtnhmqx7njIHFPlxWBX8xo3lVTyFVq6mI/lL9qt2IsN1sHwaxJkg== - dependencies: - p-try "^2.0.0" - -p-locate@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-4.1.0.tgz#a3428bb7088b3a60292f66919278b7c297ad4f07" - integrity sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A== - dependencies: - p-limit "^2.2.0" - -p-map@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/p-map/-/p-map-4.0.0.tgz#bb2f95a5eda2ec168ec9274e06a747c3e2904d2b" - integrity sha512-/bjOqmgETBYB5BoEeGVea8dmvHb2m9GLy1E9W43yeyfP6QQCZGFNa+XRceJEuDB6zqr+gKpIAmlLebMpykw/MQ== - dependencies: - aggregate-error "^3.0.0" - -p-try@^2.0.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/p-try/-/p-try-2.2.0.tgz#cb2868540e313d61de58fafbe35ce9004d5540e6" - integrity sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ== - -path-exists@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-4.0.0.tgz#513bdbe2d3b95d7762e8c1137efa195c6c61b5b3" - integrity sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w== - -path-is-absolute@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" - integrity sha1-F0uSaHNVNP+8es5r9TpanhtcX18= - -path-key@^3.0.0, path-key@^3.1.0: - version "3.1.1" - resolved "https://registry.yarnpkg.com/path-key/-/path-key-3.1.1.tgz#581f6ade658cbba65a0d3380de7753295054f375" - integrity sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q== - -path-parse@^1.0.6: - version "1.0.7" - resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.7.tgz#fbc114b60ca42b30d9daf5858e4bd68bbedb6735" - integrity sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw== - -picocolors@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/picocolors/-/picocolors-1.0.0.tgz#cb5bdc74ff3f51892236eaf79d68bc44564ab81c" - integrity sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ== - -picomatch@^2.2.2: - version "2.2.2" - resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.2.2.tgz#21f333e9b6b8eaff02468f5146ea406d345f4dad" - integrity sha512-q0M/9eZHzmr0AulXyPwNfZjtwZ/RBZlbN3K3CErVrk50T2ASYI7Bye0EvekFY3IP1Nt2DHu0re+V2ZHIpMkuWg== - -pkg-dir@^4.1.0, pkg-dir@^4.2.0: - version "4.2.0" - resolved "https://registry.yarnpkg.com/pkg-dir/-/pkg-dir-4.2.0.tgz#f099133df7ede422e81d1d8448270eeb3e4261f3" - integrity sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ== - dependencies: - find-up "^4.0.0" - -promise-inflight@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/promise-inflight/-/promise-inflight-1.0.1.tgz#98472870bf228132fcbdd868129bad12c3c029e3" - integrity sha1-mEcocL8igTL8vdhoEputEsPAKeM= - -pump@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/pump/-/pump-3.0.0.tgz#b4a2116815bde2f4e1ea602354e8c75565107a64" - integrity sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww== - dependencies: - end-of-stream "^1.1.0" - once "^1.3.1" - -punycode@^2.1.0: - version "2.1.1" - resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec" - integrity sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A== - -pupa@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/pupa/-/pupa-2.0.1.tgz#dbdc9ff48ffbea4a26a069b6f9f7abb051008726" - integrity sha512-hEJH0s8PXLY/cdXh66tNEQGndDrIKNqNC5xmrysZy3i5C3oEoLna7YAOad+7u125+zH1HNXUmGEkrhb3c2VriA== - dependencies: - escape-goat "^2.0.0" - -randombytes@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/randombytes/-/randombytes-2.1.0.tgz#df6f84372f0270dc65cdf6291349ab7a473d4f2a" - integrity sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ== - dependencies: - safe-buffer "^5.1.0" - -rechoir@^0.7.0: - version "0.7.0" - resolved "https://registry.yarnpkg.com/rechoir/-/rechoir-0.7.0.tgz#32650fd52c21ab252aa5d65b19310441c7e03aca" - integrity sha512-ADsDEH2bvbjltXEP+hTIAmeFekTFK0V2BTxMkok6qILyAJEXV0AFfoWcAq4yfll5VdIMd/RVXq0lR+wQi5ZU3Q== - dependencies: - resolve "^1.9.0" - -reduce-flatten@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/reduce-flatten/-/reduce-flatten-2.0.0.tgz#734fd84e65f375d7ca4465c69798c25c9d10ae27" - integrity "sha1-c0/YTmXzddfKRGXGl5jCXJ0Qric= sha512-EJ4UNY/U1t2P/2k6oqotuX2Cc3T6nxJwsM0N0asT7dhrtH1ltUxDn4NalSYmPE2rCkVpcf/X6R0wDwcFpzhd4w==" - -regenerator-runtime@^0.13.5: - version "0.13.7" - resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.7.tgz#cac2dacc8a1ea675feaabaeb8ae833898ae46f55" - integrity sha512-a54FxoJDIr27pgf7IgeQGxmqUNYrcV338lf/6gH456HZ/PhX+5BcwHXG9ajESmwe6WRO0tAzRUrRmNONWgkrew== - -require-directory@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42" - integrity sha1-jGStX9MNqxyXbiNE/+f3kqam30I= - -require-main-filename@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-2.0.0.tgz#d0b329ecc7cc0f61649f62215be69af54aa8989b" - integrity sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg== - -resolve-cwd@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/resolve-cwd/-/resolve-cwd-3.0.0.tgz#0f0075f1bb2544766cf73ba6a6e2adfebcb13f2d" - integrity sha512-OrZaX2Mb+rJCpH/6CpSqt9xFVpN++x01XnN2ie9g6P5/3xelLAkXWVADpdz1IHD/KFfEXyE6V0U01OQ3UO2rEg== - dependencies: - resolve-from "^5.0.0" - -resolve-from@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-5.0.0.tgz#c35225843df8f776df21c57557bc087e9dfdfc69" - integrity sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw== - -resolve@^1.11.0, resolve@^1.11.1, resolve@^1.17.0: - version "1.17.0" - resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.17.0.tgz#b25941b54968231cc2d1bb76a79cb7f2c0bf8444" - integrity sha512-ic+7JYiV8Vi2yzQGFWOkiZD5Z9z7O2Zhm9XMaTxdJExKasieFCr+yXZ/WmXsckHiKl12ar0y6XiXDx3m4RHn1w== - dependencies: - path-parse "^1.0.6" - -resolve@^1.9.0: - version "1.19.0" - resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.19.0.tgz#1af5bf630409734a067cae29318aac7fa29a267c" - integrity sha512-rArEXAgsBG4UgRGcynxWIWKFvh/XZCcS8UJdHhwy91zwAvCZIbcs+vAbflgBnNjYMs/i/i+/Ux6IZhML1yPvxg== - dependencies: - is-core-module "^2.1.0" - path-parse "^1.0.6" - -rimraf@^3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-3.0.2.tgz#f1a5402ba6220ad52cc1282bac1ae3aa49fd061a" - integrity sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA== - dependencies: - glob "^7.1.3" - -rollup-plugin-commonjs@^10.1.0: - version "10.1.0" - resolved "https://registry.yarnpkg.com/rollup-plugin-commonjs/-/rollup-plugin-commonjs-10.1.0.tgz#417af3b54503878e084d127adf4d1caf8beb86fb" - integrity sha512-jlXbjZSQg8EIeAAvepNwhJj++qJWNJw1Cl0YnOqKtP5Djx+fFGkp3WRh+W0ASCaFG5w1jhmzDxgu3SJuVxPF4Q== - dependencies: - estree-walker "^0.6.1" - is-reference "^1.1.2" - magic-string "^0.25.2" - resolve "^1.11.0" - rollup-pluginutils "^2.8.1" - -rollup-plugin-node-resolve@^5.2.0: - version "5.2.0" - resolved "https://registry.yarnpkg.com/rollup-plugin-node-resolve/-/rollup-plugin-node-resolve-5.2.0.tgz#730f93d10ed202473b1fb54a5997a7db8c6d8523" - integrity sha512-jUlyaDXts7TW2CqQ4GaO5VJ4PwwaV8VUGA7+km3n6k6xtOEacf61u0VXwN80phY/evMcaS+9eIeJ9MOyDxt5Zw== - dependencies: - "@types/resolve" "0.0.8" - builtin-modules "^3.1.0" - is-module "^1.0.0" - resolve "^1.11.1" - rollup-pluginutils "^2.8.1" - -rollup-plugin-terser@^6.1.0: - version "6.1.0" - resolved "https://registry.yarnpkg.com/rollup-plugin-terser/-/rollup-plugin-terser-6.1.0.tgz#071866585aea104bfbb9dd1019ac523e63c81e45" - integrity sha512-4fB3M9nuoWxrwm39habpd4hvrbrde2W2GG4zEGPQg1YITNkM3Tqur5jSuXlWNzbv/2aMLJ+dZJaySc3GCD8oDw== - dependencies: - "@babel/code-frame" "^7.8.3" - jest-worker "^26.0.0" - serialize-javascript "^3.0.0" - terser "^4.7.0" - -rollup-plugin-visualizer@^4.0.4: - version "4.1.1" - resolved "https://registry.yarnpkg.com/rollup-plugin-visualizer/-/rollup-plugin-visualizer-4.1.1.tgz#b8b18db0aa4b0e3b2af583399fa9d7e3f5a61808" - integrity sha512-aQBukhj8T+1BcOjD/5xB3+mZSSzHIVT+WpQDDEVpmPCkILVX0J7NPOuKEvKIXU+iZLvF7B5/wJA4+wxuH7FNew== - dependencies: - nanoid "^3.0.1" - open "^7.0.3" - pupa "^2.0.0" - source-map "^0.7.3" - yargs "^15.0.0" - -rollup-pluginutils@^2.8.1: - version "2.8.2" - resolved "https://registry.yarnpkg.com/rollup-pluginutils/-/rollup-pluginutils-2.8.2.tgz#72f2af0748b592364dbd3389e600e5a9444a351e" - integrity sha512-EEp9NhnUkwY8aif6bxgovPHMoMoNr2FulJziTndpt5H9RdwC47GSGuII9XxpSdzVGM0GWrNPHV6ie1LTNJPaLQ== - dependencies: - estree-walker "^0.6.1" - -rollup@^2.23.0: - version "2.26.11" - resolved "https://registry.yarnpkg.com/rollup/-/rollup-2.26.11.tgz#4fc31de9c7b83d50916fc8395f8c3d24730cdaae" - integrity "sha1-T8Md6ce4PVCRb8g5X4w9JHMM2q4= sha512-xyfxxhsE6hW57xhfL1I+ixH8l2bdoIMaAecdQiWF3N7IgJEMu99JG+daBiSZQjnBpzFxa0/xZm+3pbCdAQehHw==" - optionalDependencies: - fsevents "~2.1.2" - -safe-buffer@^5.1.0, safe-buffer@~5.2.0: - version "5.2.1" - resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" - integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== - -schema-utils@^2.7.1: - version "2.7.1" - resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-2.7.1.tgz#1ca4f32d1b24c590c203b8e7a50bf0ea4cd394d7" - integrity sha512-SHiNtMOUGWBQJwzISiVYKu82GiV4QYGePp3odlY1tuKO7gPtphAT5R/py0fA6xtbgLL/RvtJZnU9b8s0F1q0Xg== - dependencies: - "@types/json-schema" "^7.0.5" - ajv "^6.12.4" - ajv-keywords "^3.5.2" - -schema-utils@^3.1.0, schema-utils@^3.1.1: - version "3.1.1" - resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-3.1.1.tgz#bc74c4b6b6995c1d88f76a8b77bea7219e0c8281" - integrity sha512-Y5PQxS4ITlC+EahLuXaY86TXfR7Dc5lw294alXOq86JAHCihAIZfqv8nNCWvaEJvaC51uN9hbLGeV0cFBdH+Fw== - dependencies: - "@types/json-schema" "^7.0.8" - ajv "^6.12.5" - ajv-keywords "^3.5.2" - -seedrandom@^3.0.5: - version "3.0.5" - resolved "https://registry.yarnpkg.com/seedrandom/-/seedrandom-3.0.5.tgz#54edc85c95222525b0c7a6f6b3543d8e0b3aa0a7" - integrity sha512-8OwmbklUNzwezjGInmZ+2clQmExQPvomqjL7LFqOYqtmuxRgQYqOD3mHaU+MvZn5FLUeVxVfQjwLZW/n/JFuqg== - -semver@^6.0.0: - version "6.3.1" - resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.1.tgz#556d2ef8689146e46dcea4bfdd095f3434dffcb4" - integrity sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA== - -serialize-javascript@^3.0.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-3.1.0.tgz#8bf3a9170712664ef2561b44b691eafe399214ea" - integrity sha512-JIJT1DGiWmIKhzRsG91aS6Ze4sFUrYbltlkg2onR5OrnNM02Kl/hnY/T4FN2omvyeBbQmMJv+K4cPOpGzOTFBg== - dependencies: - randombytes "^2.1.0" - -serialize-javascript@^5.0.1: - version "5.0.1" - resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-5.0.1.tgz#7886ec848049a462467a97d3d918ebb2aaf934f4" - integrity sha512-SaaNal9imEO737H2c05Og0/8LUXG7EnsZyMa8MzkmuHoELfT6txuj0cMqRj6zfPKnmQ1yasR4PCJc8x+M4JSPA== - dependencies: - randombytes "^2.1.0" - -serialize-javascript@^6.0.1: - version "6.0.1" - resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-6.0.1.tgz#b206efb27c3da0b0ab6b52f48d170b7996458e5c" - integrity sha512-owoXEFjWRllis8/M1Q+Cw5k8ZH40e3zhp/ovX+Xr/vi1qj6QesbyXXViFbpNvWvPNAD62SutwEXavefrLJWj7w== - dependencies: - randombytes "^2.1.0" - -set-blocking@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7" - integrity sha1-BF+XgtARrppoA93TgrJDkrPYkPc= - -shebang-command@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-2.0.0.tgz#ccd0af4f8835fbdc265b82461aaf0c36663f34ea" - integrity sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA== - dependencies: - shebang-regex "^3.0.0" - -shebang-regex@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-3.0.0.tgz#ae16f1644d873ecad843b0307b143362d4c42172" - integrity sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A== - -signal-exit@^3.0.2: - version "3.0.3" - resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.3.tgz#a1410c2edd8f077b08b4e253c8eacfcaf057461c" - integrity sha512-VUJ49FC8U1OxwZLxIbTTrDvLnf/6TDgxZcK8wxR8zs13xpx7xbG60ndBlhNrFi2EMuFRoeDoJO7wthSLq42EjA== - -slash@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/slash/-/slash-3.0.0.tgz#6539be870c165adbd5240220dbe361f1bc4d4634" - integrity sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q== - -source-list-map@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/source-list-map/-/source-list-map-2.0.1.tgz#3993bd873bfc48479cca9ea3a547835c7c154b34" - integrity sha512-qnQ7gVMxGNxsiL4lEuJwe/To8UnK7fAnmbGEEH8RpLouuKbeEm0lhbQVFIrNSuB+G7tVrAlVsZgETT5nljf+Iw== - -source-map-support@~0.5.12, source-map-support@~0.5.19, source-map-support@~0.5.20: - version "0.5.21" - resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.21.tgz#04fe7c7f9e1ed2d662233c28cb2b35b9f63f6e4f" - integrity sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w== - dependencies: - buffer-from "^1.0.0" - source-map "^0.6.0" - -source-map@^0.6.0, source-map@^0.6.1, source-map@~0.6.1: - version "0.6.1" - resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" - integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== - -source-map@^0.7.3, source-map@~0.7.2: - version "0.7.3" - resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.7.3.tgz#5302f8169031735226544092e64981f751750383" - integrity sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ== - -sourcemap-codec@^1.4.4: - version "1.4.8" - resolved "https://registry.yarnpkg.com/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz#ea804bd94857402e6992d05a38ef1ae35a9ab4c4" - integrity sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA== - -sprintf-js@~1.0.2: - version "1.0.3" - resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" - integrity sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw= - -ssri@^8.0.0: - version "8.0.1" - resolved "https://registry.yarnpkg.com/ssri/-/ssri-8.0.1.tgz#638e4e439e2ffbd2cd289776d5ca457c4f51a2af" - integrity sha512-97qShzy1AiyxvPNIkLWoGua7xoQzzPjQ0HAH4B0rWKo7SZ6USuPcrUiAFrws0UH8RrbWmgq3LMTObhPIHbbBeQ== - dependencies: - minipass "^3.1.1" - -string-width@^4.1.0, string-width@^4.2.0: - version "4.2.0" - resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.0.tgz#952182c46cc7b2c313d1596e623992bd163b72b5" - integrity sha512-zUz5JD+tgqtuDjMhwIg5uFVV3dtqZ9yQJlZVfq4I01/K5Paj5UHj7VyrQOJvzawSVlKpObApbfD0Ed6yJc+1eg== - dependencies: - emoji-regex "^8.0.0" - is-fullwidth-code-point "^3.0.0" - strip-ansi "^6.0.0" - -string_decoder@^1.3.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.3.0.tgz#42f114594a46cf1a8e30b0a84f56c78c3edac21e" - integrity sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA== - dependencies: - safe-buffer "~5.2.0" - -strip-ansi@^6.0.0: - version "6.0.0" - resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.0.tgz#0b1571dd7669ccd4f3e06e14ef1eed26225ae532" - integrity sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w== - dependencies: - ansi-regex "^5.0.0" - -strip-final-newline@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/strip-final-newline/-/strip-final-newline-2.0.0.tgz#89b852fb2fcbe936f6f4b3187afb0a12c1ab58ad" - integrity sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA== - -supports-color@^5.3.0: - version "5.5.0" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f" - integrity sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow== - dependencies: - has-flag "^3.0.0" - -supports-color@^7.0.0, supports-color@^7.1.0: - version "7.2.0" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-7.2.0.tgz#1b7dcdcb32b8138801b3e478ba6a51caa89648da" - integrity sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw== - dependencies: - has-flag "^4.0.0" - -supports-color@^8.0.0: - version "8.1.1" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-8.1.1.tgz#cd6fc17e28500cff56c1b86c0a7fd4a54a73005c" - integrity sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q== - dependencies: - has-flag "^4.0.0" - -table-layout@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/table-layout/-/table-layout-1.0.1.tgz#8411181ee951278ad0638aea2f779a9ce42894f9" - integrity "sha1-hBEYHulRJ4rQY4rqL3eanOQolPk= sha512-dEquqYNJiGwY7iPfZ3wbXDI944iqanTSchrACLL2nOB+1r+h1Nzu2eH+DuPPvWvm5Ry7iAPeFlgEtP5bIp5U7Q==" - dependencies: - array-back "^4.0.1" - deep-extend "~0.6.0" - typical "^5.2.0" - wordwrapjs "^4.0.0" - -tapable@^2.1.1, tapable@^2.2.0: - version "2.2.1" - resolved "https://registry.yarnpkg.com/tapable/-/tapable-2.2.1.tgz#1967a73ef4060a82f12ab96af86d52fdb76eeca0" - integrity sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ== - -tar@^6.0.2: - version "6.1.11" - resolved "https://registry.yarnpkg.com/tar/-/tar-6.1.11.tgz#6760a38f003afa1b2ffd0ffe9e9abbd0eab3d621" - integrity "sha1-Z2CjjwA6+hsv/Q/+npq70Oqz1iE= sha512-an/KZQzQUkZCkuoAA64hM92X0Urb6VpRhAFllDzz44U2mcD5scmT3zBc4VgVpkugF580+DQn8eAFSyoQt0tznA==" - dependencies: - chownr "^2.0.0" - fs-minipass "^2.0.0" - minipass "^3.0.0" - minizlib "^2.1.1" - mkdirp "^1.0.3" - yallist "^4.0.0" - -terser-webpack-plugin@^4.2.1: - version "4.2.1" - resolved "https://registry.yarnpkg.com/terser-webpack-plugin/-/terser-webpack-plugin-4.2.1.tgz#44b88ef4d7443129fb136a68b5ec3e80d63ec471" - integrity "sha1-RLiO9NdEMSn7E2potew+gNY+xHE= sha512-D0IZQNl1ZN/JivFNDFzOeU2Bk2LdQQESHJhKTHsodpUmISkaeRwVFk7gzHzX4OuQwanDGelOxIEsBt1SZ+s6nA==" - dependencies: - cacache "^15.0.5" - find-cache-dir "^3.3.1" - jest-worker "^26.3.0" - p-limit "^3.0.2" - schema-utils "^2.7.1" - serialize-javascript "^5.0.1" - source-map "^0.6.1" - terser "^5.3.1" - webpack-sources "^1.4.3" - -terser-webpack-plugin@^5.1.3: - version "5.3.7" - resolved "https://registry.yarnpkg.com/terser-webpack-plugin/-/terser-webpack-plugin-5.3.7.tgz#ef760632d24991760f339fe9290deb936ad1ffc7" - integrity sha512-AfKwIktyP7Cu50xNjXF/6Qb5lBNzYaWpU6YfoX3uZicTx0zTy0stDDCsvjDapKsSDvOeWo5MEq4TmdBy2cNoHw== - dependencies: - "@jridgewell/trace-mapping" "^0.3.17" - jest-worker "^27.4.5" - schema-utils "^3.1.1" - serialize-javascript "^6.0.1" - terser "^5.16.5" - -terser@^4.7.0: - version "4.8.1" - resolved "https://registry.yarnpkg.com/terser/-/terser-4.8.1.tgz#a00e5634562de2239fd404c649051bf6fc21144f" - integrity sha512-4GnLC0x667eJG0ewJTa6z/yXrbLGv80D9Ru6HIpCQmO+Q4PfEtBFi0ObSckqwL6VyQv/7ENJieXHo2ANmdQwgw== - dependencies: - commander "^2.20.0" - source-map "~0.6.1" - source-map-support "~0.5.12" - -terser@^5.16.5: - version "5.16.6" - resolved "https://registry.yarnpkg.com/terser/-/terser-5.16.6.tgz#f6c7a14a378ee0630fbe3ac8d1f41b4681109533" - integrity sha512-IBZ+ZQIA9sMaXmRZCUMDjNH0D5AQQfdn4WUjHL0+1lF4TP1IHRJbrhb6fNaXWikrYQTSkb7SLxkeXAiy1p7mbg== - dependencies: - "@jridgewell/source-map" "^0.3.2" - acorn "^8.5.0" - commander "^2.20.0" - source-map-support "~0.5.20" - -terser@^5.3.1: - version "5.5.1" - resolved "https://registry.yarnpkg.com/terser/-/terser-5.5.1.tgz#540caa25139d6f496fdea056e414284886fb2289" - integrity "sha1-VAyqJROdb0lv3qBW5BQoSIb7Iok= sha512-6VGWZNVP2KTUcltUQJ25TtNjx/XgdDsBDKGt8nN0MpydU36LmbPPcMBd2kmtZNNGVVDLg44k7GKeHHj+4zPIBQ==" - dependencies: - commander "^2.20.0" - source-map "~0.7.2" - source-map-support "~0.5.19" - -tr46@~0.0.3: - version "0.0.3" - resolved "https://registry.yarnpkg.com/tr46/-/tr46-0.0.3.tgz#8184fd347dac9cdc185992f3a6622e14b9d9ab6a" - integrity sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o= - -tslib@^1.9.0: - version "1.13.0" - resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.13.0.tgz#c881e13cc7015894ed914862d276436fa9a47043" - integrity "sha1-yIHhPMcBWJTtkUhi0nZDb6mkcEM= sha512-i/6DQjL8Xf3be4K/E6Wgpekn5Qasl1usyw++dAA35Ue5orEn65VIxOA+YvNNl9HV3qv70T7CNwjODHZrLwvd1Q==" - -typical@^5.0.0, typical@^5.2.0: - version "5.2.0" - resolved "https://registry.yarnpkg.com/typical/-/typical-5.2.0.tgz#4daaac4f2b5315460804f0acf6cb69c52bb93066" - integrity "sha1-TaqsTytTFUYIBPCs9stpxSu5MGY= sha512-dvdQgNDNJo+8B2uBQoqdb11eUCE1JQXhvjC/CZtgvZseVd5TYMXnq0+vuUemXbd/Se29cTaUuPX3YIc2xgbvIg==" - -unique-filename@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/unique-filename/-/unique-filename-1.1.1.tgz#1d69769369ada0583103a1e6ae87681b56573230" - integrity sha512-Vmp0jIp2ln35UTXuryvjzkjGdRyf9b2lTXuSYUiPmzRcl3FDtYqAwOnTJkAngD9SWhnoJzDbTKwaOrZ+STtxNQ== - dependencies: - unique-slug "^2.0.0" - -unique-slug@^2.0.0: - version "2.0.2" - resolved "https://registry.yarnpkg.com/unique-slug/-/unique-slug-2.0.2.tgz#baabce91083fc64e945b0f3ad613e264f7cd4e6c" - integrity sha512-zoWr9ObaxALD3DOPfjPSqxt4fnZiWblxHIgeWqW8x7UqDzEtHEQLzji2cuJYQFCU6KmoJikOYAZlrTHHebjx2w== - dependencies: - imurmurhash "^0.1.4" - -uri-js@^4.2.2: - version "4.4.0" - resolved "https://registry.yarnpkg.com/uri-js/-/uri-js-4.4.0.tgz#aa714261de793e8a82347a7bcc9ce74e86f28602" - integrity sha512-B0yRTzYdUCCn9n+F4+Gh4yIDtMQcaJsmYBDsTSG8g/OejKBodLQ2IHfN3bM7jUsRXndopT7OIXWdYqc1fjmV6g== - dependencies: - punycode "^2.1.0" - -v8-compile-cache@^2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/v8-compile-cache/-/v8-compile-cache-2.2.0.tgz#9471efa3ef9128d2f7c6a7ca39c4dd6b5055b132" - integrity "sha1-lHHvo++RKNL3xqfKOcTda1BVsTI= sha512-gTpR5XQNKFwOd4clxfnhaqvfqMpqEwr4tOtCyz4MtYZX2JYhfr1JvBFKdS+7K/9rfpZR3VLX+YWBbKoxCgS43Q==" - -watchpack@^2.4.0: - version "2.4.0" - resolved "https://registry.yarnpkg.com/watchpack/-/watchpack-2.4.0.tgz#fa33032374962c78113f93c7f2fb4c54c9862a5d" - integrity sha512-Lcvm7MGST/4fup+ifyKi2hjyIAwcdI4HRgtvTpIUxBRhB+RFtUh8XtDOxUfctVCnhVi+QQj49i91OyvzkJl6cg== - dependencies: - glob-to-regexp "^0.4.1" - graceful-fs "^4.1.2" - -webidl-conversions@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871" - integrity sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE= - -webpack-cli@^4.2.0: - version "4.2.0" - resolved "https://registry.yarnpkg.com/webpack-cli/-/webpack-cli-4.2.0.tgz#10a09030ad2bd4d8b0f78322fba6ea43ec56aaaa" - integrity "sha1-EKCQMK0r1Niw94Mi+6bqQ+xWqqo= sha512-EIl3k88vaF4fSxWSgtAQR+VwicfLMTZ9amQtqS4o+TDPW9HGaEpbFBbAZ4A3ZOT5SOnMxNOzROsSTPiE8tBJPA==" - dependencies: - "@webpack-cli/info" "^1.1.0" - "@webpack-cli/serve" "^1.1.0" - colorette "^1.2.1" - command-line-usage "^6.1.0" - commander "^6.2.0" - enquirer "^2.3.6" - execa "^4.1.0" - import-local "^3.0.2" - interpret "^2.2.0" - leven "^3.1.0" - rechoir "^0.7.0" - v8-compile-cache "^2.2.0" - webpack-merge "^4.2.2" - -webpack-merge@^4.2.2: - version "4.2.2" - resolved "https://registry.yarnpkg.com/webpack-merge/-/webpack-merge-4.2.2.tgz#a27c52ea783d1398afd2087f547d7b9d2f43634d" - integrity "sha1-onxS6ng9E5iv0gh/VH17nS9DY00= sha512-TUE1UGoTX2Cd42j3krGYqObZbOD+xF7u28WB7tfUordytSjbWTIjK/8V0amkBfTYN4/pB/GIDlJZZ657BGG19g==" - dependencies: - lodash "^4.17.15" - -webpack-sources@^1.4.3: - version "1.4.3" - resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-1.4.3.tgz#eedd8ec0b928fbf1cbfe994e22d2d890f330a933" - integrity sha512-lgTS3Xhv1lCOKo7SA5TjKXMjpSM4sBjNV5+q2bqesbSPs5FjGmU6jjtBSkX9b4qW87vDIsCIlUPOEhbZrMdjeQ== - dependencies: - source-list-map "^2.0.0" - source-map "~0.6.1" - -webpack-sources@^3.2.3: - version "3.2.3" - resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-3.2.3.tgz#2d4daab8451fd4b240cc27055ff6a0c2ccea0cde" - integrity sha512-/DyMEOrDgLKKIG0fmvtz+4dUX/3Ghozwgm6iPp8KRhvn+eQf9+Q7GWxVNMk3+uCPWfdXYC4ExGBckIXdFEfH1w== - -webpack@^5.76.0: - version "5.76.0" - resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.76.0.tgz#f9fb9fb8c4a7dbdcd0d56a98e56b8a942ee2692c" - integrity sha512-l5sOdYBDunyf72HW8dF23rFtWq/7Zgvt/9ftMof71E/yUb1YLOBmTgA2K4vQthB3kotMrSj609txVE0dnr2fjA== - dependencies: - "@types/eslint-scope" "^3.7.3" - "@types/estree" "^0.0.51" - "@webassemblyjs/ast" "1.11.1" - "@webassemblyjs/wasm-edit" "1.11.1" - "@webassemblyjs/wasm-parser" "1.11.1" - acorn "^8.7.1" - acorn-import-assertions "^1.7.6" - browserslist "^4.14.5" - chrome-trace-event "^1.0.2" - enhanced-resolve "^5.10.0" - es-module-lexer "^0.9.0" - eslint-scope "5.1.1" - events "^3.2.0" - glob-to-regexp "^0.4.1" - graceful-fs "^4.2.9" - json-parse-even-better-errors "^2.3.1" - loader-runner "^4.2.0" - mime-types "^2.1.27" - neo-async "^2.6.2" - schema-utils "^3.1.0" - tapable "^2.1.1" - terser-webpack-plugin "^5.1.3" - watchpack "^2.4.0" - webpack-sources "^3.2.3" - -whatwg-url@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-5.0.0.tgz#966454e8765462e37644d3626f6742ce8b70965d" - integrity sha1-lmRU6HZUYuN2RNNib2dCzotwll0= - dependencies: - tr46 "~0.0.3" - webidl-conversions "^3.0.0" - -which-module@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/which-module/-/which-module-2.0.0.tgz#d9ef07dce77b9902b8a3a8fa4b31c3e3f7e6e87a" - integrity sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho= - -which@^2.0.1: - version "2.0.2" - resolved "https://registry.yarnpkg.com/which/-/which-2.0.2.tgz#7c6a8dd0a636a0327e10b59c9286eee93f3f51b1" - integrity sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA== - dependencies: - isexe "^2.0.0" - -wordwrapjs@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/wordwrapjs/-/wordwrapjs-4.0.0.tgz#9aa9394155993476e831ba8e59fb5795ebde6800" - integrity "sha1-mqk5QVWZNHboMbqOWftXleveaAA= sha512-Svqw723a3R34KvsMgpjFBYCgNOSdcW3mQFK4wIfhGQhtaFVOJmdYoXgi63ne3dTlWgatVcUc7t4HtQ/+bUVIzQ==" - dependencies: - reduce-flatten "^2.0.0" - typical "^5.0.0" - -wrap-ansi@^6.2.0: - version "6.2.0" - resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-6.2.0.tgz#e9393ba07102e6c91a3b221478f0257cd2856e53" - integrity sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA== - dependencies: - ansi-styles "^4.0.0" - string-width "^4.1.0" - strip-ansi "^6.0.0" - -wrap-ansi@^7.0.0: - version "7.0.0" - resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" - integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== - dependencies: - ansi-styles "^4.0.0" - string-width "^4.1.0" - strip-ansi "^6.0.0" - -wrappy@1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" - integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8= - -y18n@^4.0.0: - version "4.0.3" - resolved "https://registry.yarnpkg.com/y18n/-/y18n-4.0.3.tgz#b5f259c82cd6e336921efd7bfd8bf560de9eeedf" - integrity sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ== - -y18n@^5.0.1: - version "5.0.2" - resolved "https://registry.yarnpkg.com/y18n/-/y18n-5.0.2.tgz#48218df5da2731b4403115c39a1af709c873f829" - integrity sha512-CkwaeZw6dQgqgPGeTWKMXCRmMcBgETFlTml1+ZOO+q7kGst8NREJ+eWwFNPVUQ4QGdAaklbqCZHH6Zuep1RjiA== - -yallist@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72" - integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A== - -yargs-parser@^18.1.2: - version "18.1.3" - resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-18.1.3.tgz#be68c4975c6b2abf469236b0c870362fab09a7b0" - integrity sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ== - dependencies: - camelcase "^5.0.0" - decamelize "^1.2.0" - -yargs-parser@^20.0.0: - version "20.2.1" - resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.1.tgz#28f3773c546cdd8a69ddae68116b48a5da328e77" - integrity sha512-yYsjuSkjbLMBp16eaOt7/siKTjNVjMm3SoJnIg3sEh/JsvqVVDyjRKmaJV4cl+lNIgq6QEco2i3gDebJl7/vLA== - -yargs@^15.0.0: - version "15.4.1" - resolved "https://registry.yarnpkg.com/yargs/-/yargs-15.4.1.tgz#0d87a16de01aee9d8bec2bfbf74f67851730f4f8" - integrity sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A== - dependencies: - cliui "^6.0.0" - decamelize "^1.2.0" - find-up "^4.1.0" - get-caller-file "^2.0.1" - require-directory "^2.1.1" - require-main-filename "^2.0.0" - set-blocking "^2.0.0" - string-width "^4.2.0" - which-module "^2.0.0" - y18n "^4.0.0" - yargs-parser "^18.1.2" - -yargs@^16.0.3: - version "16.0.3" - resolved "https://registry.yarnpkg.com/yargs/-/yargs-16.0.3.tgz#7a919b9e43c90f80d4a142a89795e85399a7e54c" - integrity sha512-6+nLw8xa9uK1BOEOykaiYAJVh6/CjxWXK/q9b5FpRgNslt8s22F2xMBqVIKgCRjNgGvGPBy8Vog7WN7yh4amtA== - dependencies: - cliui "^7.0.0" - escalade "^3.0.2" - get-caller-file "^2.0.5" - require-directory "^2.1.1" - string-width "^4.2.0" - y18n "^5.0.1" - yargs-parser "^20.0.0" diff --git a/tfjs-master/e2e/custom_module/dense_model/app.js b/tfjs-master/e2e/custom_module/dense_model/app.js deleted file mode 100644 index 9d94ca4ed..000000000 --- a/tfjs-master/e2e/custom_module/dense_model/app.js +++ /dev/null @@ -1,57 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '@tensorflow/tfjs'; - -async function main(modelUrl) { - await tf.ready(); - const backend = tf.getBackend(); - self.postMessage({ - msg: true, - payload: `Backend ready: ${backend}. Got model url: ${modelUrl}` - }); - - const registeredKernels = tf.getKernelsForBackend(backend); - let model; - try { - model = await tf.loadGraphModel(modelUrl) - } catch (e) { - self.postMessage({error: true, payload: e}); - } - - const predictions = model.predict(tf.tensor2d([20], [1, 1])).dataSync(); - // result is 38.17822265625 - - // send the final result of the test. - self.postMessage({ - result: true, - payload: { - numKernels: registeredKernels.length, - kernelNames: registeredKernels.map(k => k.kernelName), - backend, - predictions: predictions - } - }); -} - -self.addEventListener('message', function(e) { - try { - main(e.data.modelUrl); - } catch (e) { - self.postMessage({error: true, payload: e}); - } -}, false); diff --git a/tfjs-master/e2e/custom_module/dense_model/app_tfjs_config.json b/tfjs-master/e2e/custom_module/dense_model/app_tfjs_config.json deleted file mode 100644 index 6bb4cedf3..000000000 --- a/tfjs-master/e2e/custom_module/dense_model/app_tfjs_config.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "kernels": ["Reshape", "_FusedMatMul", "fusedMatMul__op", "Identity"], - "backends": [ - "cpu" - ], - "models": [ - "./model/model.json" - ], - "outputPath": "./custom_tfjs", - "forwardModeOnly": true -} diff --git a/tfjs-master/e2e/custom_module/dense_model/build.sh b/tfjs-master/e2e/custom_module/dense_model/build.sh deleted file mode 100644 index 705b93531..000000000 --- a/tfjs-master/e2e/custom_module/dense_model/build.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env bash - -# Copyright 2023 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================== - -set -e - -yarn --mutex network -# Ensure that we test against freshly generated custom modules. -rm -f ./custom_tfjs/*.js -yarn make-custom-tfjs-modules - -parallel ::: "yarn webpack:full" \ - "yarn webpack:custom" \ - "yarn rollup:full" \ - "yarn rollup:custom" diff --git a/tfjs-master/e2e/custom_module/dense_model/model/group1-shard1of1.bin b/tfjs-master/e2e/custom_module/dense_model/model/group1-shard1of1.bin deleted file mode 100644 index b23eb545d..000000000 --- a/tfjs-master/e2e/custom_module/dense_model/model/group1-shard1of1.bin +++ /dev/null @@ -1 +0,0 @@ -šÆù?ègY¿ \ No newline at end of file diff --git a/tfjs-master/e2e/custom_module/dense_model/model/model.json b/tfjs-master/e2e/custom_module/dense_model/model/model.json deleted file mode 100644 index 9f51cc112..000000000 --- a/tfjs-master/e2e/custom_module/dense_model/model/model.json +++ /dev/null @@ -1,189 +0,0 @@ -{ - "format": "graph-model", - "signature": { - "inputs": { - "dense_dense1_input:0": { - "dtype": "DT_FLOAT", - "name": "dense_dense1_input:0", - "tensorShape": { - "dim": [ - { - "size": "-1" - }, - { - "size": "1" - } - ] - } - } - }, - "outputs": { - "Identity:0": { - "dtype": "DT_FLOAT", - "name": "Identity:0", - "tensorShape": { - "dim": [ - { - "size": "-1" - }, - { - "size": "1" - } - ] - } - } - } - }, - "modelTopology": { - "node": [ - { - "attr": { - "dtype": { - "type": "DT_FLOAT" - }, - "shape": { - "shape": { - "dim": [ - { - "size": "-1" - }, - { - "size": "1" - } - ] - } - } - }, - "name": "dense_dense1_input", - "op": "Placeholder" - }, - { - "input": [ - "^dense_dense1_input" - ], - "attr": { - "dtype": { - "type": "DT_FLOAT" - }, - "value": { - "tensor": { - "dtype": "DT_FLOAT", - "tensorShape": { - "dim": [ - { - "size": "1" - }, - { - "size": "1" - } - ] - } - } - } - }, - "name": "StatefulPartitionedCall/sequential_1/dense_Dense1/MatMul/ReadVariableOp", - "op": "Const" - }, - { - "input": [ - "^dense_dense1_input" - ], - "attr": { - "dtype": { - "type": "DT_FLOAT" - }, - "value": { - "tensor": { - "dtype": "DT_FLOAT", - "tensorShape": { - "dim": [ - { - "size": "1" - } - ] - } - } - } - }, - "name": "StatefulPartitionedCall/sequential_1/dense_Dense1/BiasAdd/ReadVariableOp", - "op": "Const" - }, - { - "device": "/device:CPU:0", - "input": [ - "dense_dense1_input", - "StatefulPartitionedCall/sequential_1/dense_Dense1/MatMul/ReadVariableOp", - "StatefulPartitionedCall/sequential_1/dense_Dense1/BiasAdd/ReadVariableOp" - ], - "attr": { - "epsilon": { - "f": 0 - }, - "num_args": { - "i": "1" - }, - "T": { - "type": "DT_FLOAT" - }, - "transpose_b": { - "b": false - }, - "fused_ops": { - "list": { - "s": [ - "Qmlhc0FkZA==" - ] - } - }, - "transpose_a": { - "b": false - } - }, - "name": "StatefulPartitionedCall/sequential_1/dense_Dense1/BiasAdd", - "op": "_FusedMatMul" - }, - { - "input": [ - "StatefulPartitionedCall/sequential_1/dense_Dense1/BiasAdd" - ], - "attr": { - "T": { - "type": "DT_FLOAT" - } - }, - "name": "Identity", - "op": "Identity" - } - ], - "library": {}, - "versions": { - "producer": 175 - } - }, - "generatedBy": "2.1.0", - "weightsManifest": [ - { - "paths": [ - "group1-shard1of1.bin" - ], - "weights": [ - { - "dtype": "float32", - "shape": [ - 1, - 1 - ], - "name": "StatefulPartitionedCall/sequential_1/dense_Dense1/MatMul/ReadVariableOp" - }, - { - "dtype": "float32", - "shape": [ - 1 - ], - "name": "StatefulPartitionedCall/sequential_1/dense_Dense1/BiasAdd/ReadVariableOp" - } - ] - } - ], - "convertedBy": "TensorFlow.js Converter v2.4.0" -} diff --git a/tfjs-master/e2e/custom_module/dense_model/package.json b/tfjs-master/e2e/custom_module/dense_model/package.json deleted file mode 100644 index e9fa76394..000000000 --- a/tfjs-master/e2e/custom_module/dense_model/package.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "name": "dense-model-treeshake", - "version": "1.0.0", - "description": "", - "main": "app.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1", - "make-custom-tfjs-modules": "node ./node_modules/@tensorflow/tfjs/dist/tools/custom_module/cli.js --config app_tfjs_config.json", - "rollup:full": "rollup -c", - "rollup:custom": "rollup -c --useCustomTfjs", - "webpack:full": "webpack", - "webpack:custom": "webpack --env useCustomTfjs" - }, - "dependencies": { - "@tensorflow/tfjs": "link:../../../tfjs" - }, - "devDependencies": { - "@rollup/plugin-alias": "^3.1.1", - "@rollup/plugin-commonjs": "^14.0.0", - "@rollup/plugin-node-resolve": "^8.4.0", - "file-loader": "^6.1.0", - "rollup": "^2.23.0", - "rollup-plugin-commonjs": "^10.1.0", - "rollup-plugin-node-resolve": "^5.2.0", - "rollup-plugin-terser": "^6.1.0", - "rollup-plugin-visualizer": "^4.0.4", - "terser-webpack-plugin": "^5.3.1", - "webpack": "^5.76.0", - "webpack-cli": "^4.9.2" - }, - "resolutions": { - "node-fetch": "2.6.7", - "minimist": "1.2.6" - } -} diff --git a/tfjs-master/e2e/custom_module/dense_model/rollup.config.js b/tfjs-master/e2e/custom_module/dense_model/rollup.config.js deleted file mode 100644 index b5a9a68b2..000000000 --- a/tfjs-master/e2e/custom_module/dense_model/rollup.config.js +++ /dev/null @@ -1,99 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import alias from '@rollup/plugin-alias'; -import commonjs from '@rollup/plugin-commonjs'; -import resolve from '@rollup/plugin-node-resolve'; -import * as path from 'path'; -import {terser} from 'rollup-plugin-terser'; -import visualizer from 'rollup-plugin-visualizer'; - - -const sourcemap = false; - -function getPlugins(options) { - let plugins = []; - - if (options.useCustomTfjs) { - plugins.push( - // replace top level imports to tfjs-core with custom import. - // after v3 is out we still need to do this in converter. - alias({ - entries: [ - { - find: /@tensorflow\/tfjs$/, - replacement: path.resolve(__dirname, options.customTfjsPath), - }, - { - find: /@tensorflow\/tfjs-core$/, - replacement: path.resolve(__dirname, options.customTfjsCorePath), - }, - { - find: '@tensorflow/tfjs-core/dist/ops/ops_for_converter', - replacement: path.resolve(__dirname, options.customOpsPath), - }, - ], - })); - } - - plugins = [ - ...plugins, - resolve({browser: true, dedupe: ['seedrandom']}), - commonjs({include: ['node_modules/**']}), - terser({output: {comments: false}}), - ]; - - if (options.visualize) { - plugins.push(visualizer({sourcemap, filename: options.visPath})); - } - - return plugins; -} - - -module.exports = (cmdOptions) => { - const {useCustomTfjs, visualize} = cmdOptions; - // remove custom command line options from being passed onto rollup. - delete cmdOptions.useCustomTfjs; - delete cmdOptions.visualize; - - const bundles = []; - const outputPath = useCustomTfjs ? 'dist/custom' : 'dist/full'; - - bundles.push( - { - input: 'app.js', - output: { - file: `${outputPath}/app_rollup.js`, - sourcemap, - format: 'umd', - }, - plugins: [ - ...getPlugins({ - useCustomTfjs: useCustomTfjs, - customTfjsPath: './custom_tfjs/custom_tfjs.js', - customTfjsCorePath: './custom_tfjs/custom_tfjs_core.js', - customOpsPath: './custom_tfjs/custom_ops_for_converter.js', - visualize: visualize, - visPath: `${outputPath}/app_rollup.js.html`, - }), - ], - }, - ); - - return bundles; -}; diff --git a/tfjs-master/e2e/custom_module/dense_model/webpack.config.js b/tfjs-master/e2e/custom_module/dense_model/webpack.config.js deleted file mode 100644 index 14bfdd538..000000000 --- a/tfjs-master/e2e/custom_module/dense_model/webpack.config.js +++ /dev/null @@ -1,65 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -const path = require('path'); -const TerserPlugin = require('terser-webpack-plugin'); - -module.exports = function(env) { - const outputPath = (env && env.useCustomTfjs) ? 'dist/custom' : 'dist/full' - - const config = { - mode: 'production', - entry: './app.js', - target: 'web', - output: { - path: path.resolve(__dirname, outputPath), - filename: 'app_webpack.js', - }, - optimization: { - minimizer: [ - new TerserPlugin({parallel: true, terserOptions: {}}), - ] - }, - module: { - rules: [ - { - test: /\.wasm$/i, - type: 'javascript/auto', - use: [ - { - loader: 'file-loader', - }, - ], - }, - ], - } - }; - - if (env && env.useCustomTfjs) { - config.resolve = { - alias: { - '@tensorflow/tfjs$': - path.resolve(__dirname, './custom_tfjs/custom_tfjs.js'), - '@tensorflow/tfjs-core$': - path.resolve(__dirname, './custom_tfjs/custom_tfjs_core.js'), - '@tensorflow/tfjs-core/dist/ops/ops_for_converter': path.resolve( - __dirname, './custom_tfjs/custom_ops_for_converter.js'), - } - } - } - return config; -} diff --git a/tfjs-master/e2e/custom_module/dense_model/yarn.lock b/tfjs-master/e2e/custom_module/dense_model/yarn.lock deleted file mode 100644 index ca6d72ed3..000000000 --- a/tfjs-master/e2e/custom_module/dense_model/yarn.lock +++ /dev/null @@ -1,1613 +0,0 @@ -# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. -# yarn lockfile v1 - - -"@babel/code-frame@^7.8.3": - version "7.10.4" - resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.10.4.tgz#168da1a36e90da68ae8d49c0f1b48c7c6249213a" - integrity sha512-vG6SvB6oYEhvgisZNFRmRCUkLz11c7rp+tbNTynGqc6mS1d5ATd/sGyV6W0KZZnXRKMTzZDRgQT3Ou9jhpAfUg== - dependencies: - "@babel/highlight" "^7.10.4" - -"@babel/helper-validator-identifier@^7.10.4": - version "7.10.4" - resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.10.4.tgz#a78c7a7251e01f616512d31b10adcf52ada5e0d2" - integrity sha512-3U9y+43hz7ZM+rzG24Qe2mufW5KhvFg/NhnNph+i9mgCtdTCtMJuI1TMkrIUiK7Ix4PYlRF9I5dhqaLYA/ADXw== - -"@babel/highlight@^7.10.4": - version "7.10.4" - resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.10.4.tgz#7d1bdfd65753538fabe6c38596cdb76d9ac60143" - integrity sha512-i6rgnR/YgPEQzZZnbTHHuZdlE8qyoBNalD6F+q4vAFlcMEcqmkoG+mPqJYJCo63qPf74+Y1UZsl3l6f7/RIkmA== - dependencies: - "@babel/helper-validator-identifier" "^7.10.4" - chalk "^2.0.0" - js-tokens "^4.0.0" - -"@discoveryjs/json-ext@^0.5.0": - version "0.5.7" - resolved "https://registry.yarnpkg.com/@discoveryjs/json-ext/-/json-ext-0.5.7.tgz#1d572bfbbe14b7704e0ba0f39b74815b84870d70" - integrity sha512-dBVuXR082gk3jsFp7Rd/JI4kytwGHecnCoTtXFb7DB6CNHp4rg5k1bhg0nWdLGLnOV71lmDzGQaLMy8iPLY0pw== - -"@rollup/plugin-alias@^3.1.1": - version "3.1.1" - resolved "https://registry.yarnpkg.com/@rollup/plugin-alias/-/plugin-alias-3.1.1.tgz#bb96cf37fefeb0a953a6566c284855c7d1cd290c" - integrity sha512-hNcQY4bpBUIvxekd26DBPgF7BT4mKVNDF5tBG4Zi+3IgwLxGYRY0itHs9D0oLVwXM5pvJDWJlBQro+au8WaUWw== - dependencies: - slash "^3.0.0" - -"@rollup/plugin-commonjs@^14.0.0": - version "14.0.0" - resolved "https://registry.yarnpkg.com/@rollup/plugin-commonjs/-/plugin-commonjs-14.0.0.tgz#4285f9ec2db686a31129e5a2b415c94aa1f836f0" - integrity sha512-+PSmD9ePwTAeU106i9FRdc+Zb3XUWyW26mo5Atr2mk82hor8+nPwkztEjFo8/B1fJKfaQDg9aM2bzQkjhi7zOw== - dependencies: - "@rollup/pluginutils" "^3.0.8" - commondir "^1.0.1" - estree-walker "^1.0.1" - glob "^7.1.2" - is-reference "^1.1.2" - magic-string "^0.25.2" - resolve "^1.11.0" - -"@rollup/plugin-node-resolve@^8.4.0": - version "8.4.0" - resolved "https://registry.yarnpkg.com/@rollup/plugin-node-resolve/-/plugin-node-resolve-8.4.0.tgz#261d79a680e9dc3d86761c14462f24126ba83575" - integrity sha512-LFqKdRLn0ShtQyf6SBYO69bGE1upV6wUhBX0vFOUnLAyzx5cwp8svA0eHUnu8+YU57XOkrMtfG63QOpQx25pHQ== - dependencies: - "@rollup/pluginutils" "^3.1.0" - "@types/resolve" "1.17.1" - builtin-modules "^3.1.0" - deep-freeze "^0.0.1" - deepmerge "^4.2.2" - is-module "^1.0.0" - resolve "^1.17.0" - -"@rollup/pluginutils@^3.0.8", "@rollup/pluginutils@^3.1.0": - version "3.1.0" - resolved "https://registry.yarnpkg.com/@rollup/pluginutils/-/pluginutils-3.1.0.tgz#706b4524ee6dc8b103b3c995533e5ad680c02b9b" - integrity sha512-GksZ6pr6TpIjHm8h9lSQ8pi8BE9VeubNT0OMJ3B5uZJ8pz73NPiqOtCog/x2/QzM1ENChPKxMDhiQuRHsqc+lg== - dependencies: - "@types/estree" "0.0.39" - estree-walker "^1.0.1" - picomatch "^2.2.2" - -"@tensorflow/tfjs-backend-cpu@link:../../../link-package/node_modules/@tensorflow/link-package/node_modules/@tensorflow/tfjs-backend-cpu": - version "0.0.0" - -"@tensorflow/tfjs-backend-cpu@link:../../../link-package/node_modules/@tensorflow/tfjs-backend-cpu": - version "0.0.0" - uid "" - -"@tensorflow/tfjs-backend-webgl@link:../../../link-package/node_modules/@tensorflow/tfjs-backend-webgl": - version "0.0.0" - uid "" - -"@tensorflow/tfjs-converter@link:../../../link-package/node_modules/@tensorflow/tfjs-converter": - version "0.0.0" - uid "" - -"@tensorflow/tfjs-core@link:../../../link-package/node_modules/@tensorflow/tfjs-core": - version "0.0.0" - uid "" - -"@tensorflow/tfjs-data@link:../../../link-package/node_modules/@tensorflow/tfjs-data": - version "0.0.0" - uid "" - -"@tensorflow/tfjs-layers@link:../../../link-package/node_modules/@tensorflow/tfjs-layers": - version "0.0.0" - uid "" - -"@tensorflow/tfjs@link:../../../tfjs": - version "0.0.0" - uid "" - -"@types/eslint-scope@^3.7.3": - version "3.7.3" - resolved "https://registry.yarnpkg.com/@types/eslint-scope/-/eslint-scope-3.7.3.tgz#125b88504b61e3c8bc6f870882003253005c3224" - integrity sha512-PB3ldyrcnAicT35TWPs5IcwKD8S333HMaa2VVv4+wdvebJkjWuW/xESoB8IwRcog8HYVYamb1g/R31Qv5Bx03g== - dependencies: - "@types/eslint" "*" - "@types/estree" "*" - -"@types/eslint@*": - version "8.4.1" - resolved "https://registry.yarnpkg.com/@types/eslint/-/eslint-8.4.1.tgz#c48251553e8759db9e656de3efc846954ac32304" - integrity sha512-GE44+DNEyxxh2Kc6ro/VkIj+9ma0pO0bwv9+uHSyBrikYOHr8zYcdPvnBOp1aw8s+CjRvuSx7CyWqRrNFQ59mA== - dependencies: - "@types/estree" "*" - "@types/json-schema" "*" - -"@types/estree@*", "@types/estree@^0.0.51": - version "0.0.51" - resolved "https://registry.yarnpkg.com/@types/estree/-/estree-0.0.51.tgz#cfd70924a25a3fd32b218e5e420e6897e1ac4f40" - integrity sha512-CuPgU6f3eT/XgKKPqKd/gLZV1Xmvf1a2R5POBOGQa6uv82xpls89HU5zKeVoyR8XzHd1RGNOlQlvUe3CFkjWNQ== - -"@types/estree@0.0.39": - version "0.0.39" - resolved "https://registry.yarnpkg.com/@types/estree/-/estree-0.0.39.tgz#e177e699ee1b8c22d23174caaa7422644389509f" - integrity sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw== - -"@types/json-schema@*", "@types/json-schema@^7.0.8": - version "7.0.9" - resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.9.tgz#97edc9037ea0c38585320b28964dde3b39e4660d" - integrity sha512-qcUXuemtEu+E5wZSJHNxUXeCZhAfXKQ41D+duX+VYPde7xyEVZci+/oXKJL13tnRs9lR2pr4fod59GT6/X1/yQ== - -"@types/json-schema@^7.0.5": - version "7.0.6" - resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.6.tgz#f4c7ec43e81b319a9815115031709f26987891f0" - integrity sha512-3c+yGKvVP5Y9TYBEibGNR+kLtijnj7mYrXRg+WpFb2X9xm04g/DXYkfg4hmzJQosc9snFNUPkbYIhu+KAm6jJw== - -"@types/long@^4.0.1": - version "4.0.2" - resolved "https://registry.yarnpkg.com/@types/long/-/long-4.0.2.tgz#b74129719fc8d11c01868010082d483b7545591a" - integrity sha512-MqTGEo5bj5t157U6fA/BiDynNkn0YknVdh48CMPkTSpFTVmvao5UQmm7uEF6xBEo7qIMAlY/JSleYaE6VOdpaA== - -"@types/node-fetch@^2.1.2": - version "2.6.4" - resolved "https://registry.yarnpkg.com/@types/node-fetch/-/node-fetch-2.6.4.tgz#1bc3a26de814f6bf466b25aeb1473fa1afe6a660" - integrity sha512-1ZX9fcN4Rvkvgv4E6PAY5WXUFWFcRWxZa3EW83UjycOB9ljJCedb2CupIP4RZMEwF/M3eTcCihbBRgwtGbg5Rg== - dependencies: - "@types/node" "*" - form-data "^3.0.0" - -"@types/node@*": - version "14.11.5" - resolved "https://registry.yarnpkg.com/@types/node/-/node-14.11.5.tgz#fecad41c041cae7f2404ad4b2d0742fdb628b305" - integrity sha512-jVFzDV6NTbrLMxm4xDSIW/gKnk8rQLF9wAzLWIOg+5nU6ACrIMndeBdXci0FGtqJbP9tQvm6V39eshc96TO2wQ== - -"@types/offscreencanvas@~2019.3.0": - version "2019.3.0" - resolved "https://registry.yarnpkg.com/@types/offscreencanvas/-/offscreencanvas-2019.3.0.tgz#3336428ec7e9180cf4566dfea5da04eb586a6553" - integrity sha512-esIJx9bQg+QYF0ra8GnvfianIY8qWB0GBx54PK5Eps6m+xTj86KLavHv6qDhzKcu5UUOgNfJ2pWaIIV7TRUd9Q== - -"@types/offscreencanvas@~2019.7.0": - version "2019.7.0" - resolved "https://registry.yarnpkg.com/@types/offscreencanvas/-/offscreencanvas-2019.7.0.tgz#e4a932069db47bb3eabeb0b305502d01586fa90d" - integrity sha512-PGcyveRIpL1XIqK8eBsmRBt76eFgtzuPiSTyKHZxnGemp2yzGzWpjYKAfK3wIMiU7eH+851yEpiuP8JZerTmWg== - -"@types/resolve@0.0.8": - version "0.0.8" - resolved "https://registry.yarnpkg.com/@types/resolve/-/resolve-0.0.8.tgz#f26074d238e02659e323ce1a13d041eee280e194" - integrity sha512-auApPaJf3NPfe18hSoJkp8EbZzer2ISk7o8mCC3M9he/a04+gbMF97NkpD2S8riMGvm4BMRI59/SZQSaLTKpsQ== - dependencies: - "@types/node" "*" - -"@types/resolve@1.17.1": - version "1.17.1" - resolved "https://registry.yarnpkg.com/@types/resolve/-/resolve-1.17.1.tgz#3afd6ad8967c77e4376c598a82ddd58f46ec45d6" - integrity sha512-yy7HuzQhj0dhGpD8RLXSZWEkLsV9ibvxvi6EiJ3bkqLAO1RGo0WbkWQiwpRlSFymTJRz0d3k5LM3kkx8ArDbLw== - dependencies: - "@types/node" "*" - -"@types/seedrandom@^2.4.28": - version "2.4.30" - resolved "https://registry.yarnpkg.com/@types/seedrandom/-/seedrandom-2.4.30.tgz#d2efe425869b84163c2d56e779dddadb9372cbfa" - integrity sha512-AnxLHewubLVzoF/A4qdxBGHCKifw8cY32iro3DQX9TPcetE95zBeVt3jnsvtvAUf1vwzMfwzp4t/L2yqPlnjkQ== - -"@webassemblyjs/ast@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.11.1.tgz#2bfd767eae1a6996f432ff7e8d7fc75679c0b6a7" - integrity sha512-ukBh14qFLjxTQNTXocdyksN5QdM28S1CxHt2rdskFyL+xFV7VremuBLVbmCePj+URalXBENx/9Lm7lnhihtCSw== - dependencies: - "@webassemblyjs/helper-numbers" "1.11.1" - "@webassemblyjs/helper-wasm-bytecode" "1.11.1" - -"@webassemblyjs/floating-point-hex-parser@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/floating-point-hex-parser/-/floating-point-hex-parser-1.11.1.tgz#f6c61a705f0fd7a6aecaa4e8198f23d9dc179e4f" - integrity sha512-iGRfyc5Bq+NnNuX8b5hwBrRjzf0ocrJPI6GWFodBFzmFnyvrQ83SHKhmilCU/8Jv67i4GJZBMhEzltxzcNagtQ== - -"@webassemblyjs/helper-api-error@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-api-error/-/helper-api-error-1.11.1.tgz#1a63192d8788e5c012800ba6a7a46c705288fd16" - integrity sha512-RlhS8CBCXfRUR/cwo2ho9bkheSXG0+NwooXcc3PAILALf2QLdFyj7KGsKRbVc95hZnhnERon4kW/D3SZpp6Tcg== - -"@webassemblyjs/helper-buffer@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-buffer/-/helper-buffer-1.11.1.tgz#832a900eb444884cde9a7cad467f81500f5e5ab5" - integrity sha512-gwikF65aDNeeXa8JxXa2BAk+REjSyhrNC9ZwdT0f8jc4dQQeDQ7G4m0f2QCLPJiMTTO6wfDmRmj/pW0PsUvIcA== - -"@webassemblyjs/helper-numbers@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-numbers/-/helper-numbers-1.11.1.tgz#64d81da219fbbba1e3bd1bfc74f6e8c4e10a62ae" - integrity sha512-vDkbxiB8zfnPdNK9Rajcey5C0w+QJugEglN0of+kmO8l7lDb77AnlKYQF7aarZuCrv+l0UvqL+68gSDr3k9LPQ== - dependencies: - "@webassemblyjs/floating-point-hex-parser" "1.11.1" - "@webassemblyjs/helper-api-error" "1.11.1" - "@xtuc/long" "4.2.2" - -"@webassemblyjs/helper-wasm-bytecode@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-wasm-bytecode/-/helper-wasm-bytecode-1.11.1.tgz#f328241e41e7b199d0b20c18e88429c4433295e1" - integrity sha512-PvpoOGiJwXeTrSf/qfudJhwlvDQxFgelbMqtq52WWiXC6Xgg1IREdngmPN3bs4RoO83PnL/nFrxucXj1+BX62Q== - -"@webassemblyjs/helper-wasm-section@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-wasm-section/-/helper-wasm-section-1.11.1.tgz#21ee065a7b635f319e738f0dd73bfbda281c097a" - integrity sha512-10P9No29rYX1j7F3EVPX3JvGPQPae+AomuSTPiF9eBQeChHI6iqjMIwR9JmOJXwpnn/oVGDk7I5IlskuMwU/pg== - dependencies: - "@webassemblyjs/ast" "1.11.1" - "@webassemblyjs/helper-buffer" "1.11.1" - "@webassemblyjs/helper-wasm-bytecode" "1.11.1" - "@webassemblyjs/wasm-gen" "1.11.1" - -"@webassemblyjs/ieee754@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/ieee754/-/ieee754-1.11.1.tgz#963929e9bbd05709e7e12243a099180812992614" - integrity sha512-hJ87QIPtAMKbFq6CGTkZYJivEwZDbQUgYd3qKSadTNOhVY7p+gfP6Sr0lLRVTaG1JjFj+r3YchoqRYxNH3M0GQ== - dependencies: - "@xtuc/ieee754" "^1.2.0" - -"@webassemblyjs/leb128@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/leb128/-/leb128-1.11.1.tgz#ce814b45574e93d76bae1fb2644ab9cdd9527aa5" - integrity sha512-BJ2P0hNZ0u+Th1YZXJpzW6miwqQUGcIHT1G/sf72gLVD9DZ5AdYTqPNbHZh6K1M5VmKvFXwGSWZADz+qBWxeRw== - dependencies: - "@xtuc/long" "4.2.2" - -"@webassemblyjs/utf8@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/utf8/-/utf8-1.11.1.tgz#d1f8b764369e7c6e6bae350e854dec9a59f0a3ff" - integrity sha512-9kqcxAEdMhiwQkHpkNiorZzqpGrodQQ2IGrHHxCy+Ozng0ofyMA0lTqiLkVs1uzTRejX+/O0EOT7KxqVPuXosQ== - -"@webassemblyjs/wasm-edit@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-edit/-/wasm-edit-1.11.1.tgz#ad206ebf4bf95a058ce9880a8c092c5dec8193d6" - integrity sha512-g+RsupUC1aTHfR8CDgnsVRVZFJqdkFHpsHMfJuWQzWU3tvnLC07UqHICfP+4XyL2tnr1amvl1Sdp06TnYCmVkA== - dependencies: - "@webassemblyjs/ast" "1.11.1" - "@webassemblyjs/helper-buffer" "1.11.1" - "@webassemblyjs/helper-wasm-bytecode" "1.11.1" - "@webassemblyjs/helper-wasm-section" "1.11.1" - "@webassemblyjs/wasm-gen" "1.11.1" - "@webassemblyjs/wasm-opt" "1.11.1" - "@webassemblyjs/wasm-parser" "1.11.1" - "@webassemblyjs/wast-printer" "1.11.1" - -"@webassemblyjs/wasm-gen@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-gen/-/wasm-gen-1.11.1.tgz#86c5ea304849759b7d88c47a32f4f039ae3c8f76" - integrity sha512-F7QqKXwwNlMmsulj6+O7r4mmtAlCWfO/0HdgOxSklZfQcDu0TpLiD1mRt/zF25Bk59FIjEuGAIyn5ei4yMfLhA== - dependencies: - "@webassemblyjs/ast" "1.11.1" - "@webassemblyjs/helper-wasm-bytecode" "1.11.1" - "@webassemblyjs/ieee754" "1.11.1" - "@webassemblyjs/leb128" "1.11.1" - "@webassemblyjs/utf8" "1.11.1" - -"@webassemblyjs/wasm-opt@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-opt/-/wasm-opt-1.11.1.tgz#657b4c2202f4cf3b345f8a4c6461c8c2418985f2" - integrity sha512-VqnkNqnZlU5EB64pp1l7hdm3hmQw7Vgqa0KF/KCNO9sIpI6Fk6brDEiX+iCOYrvMuBWDws0NkTOxYEb85XQHHw== - dependencies: - "@webassemblyjs/ast" "1.11.1" - "@webassemblyjs/helper-buffer" "1.11.1" - "@webassemblyjs/wasm-gen" "1.11.1" - "@webassemblyjs/wasm-parser" "1.11.1" - -"@webassemblyjs/wasm-parser@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-parser/-/wasm-parser-1.11.1.tgz#86ca734534f417e9bd3c67c7a1c75d8be41fb199" - integrity sha512-rrBujw+dJu32gYB7/Lup6UhdkPx9S9SnobZzRVL7VcBH9Bt9bCBLEuX/YXOOtBsOZ4NQrRykKhffRWHvigQvOA== - dependencies: - "@webassemblyjs/ast" "1.11.1" - "@webassemblyjs/helper-api-error" "1.11.1" - "@webassemblyjs/helper-wasm-bytecode" "1.11.1" - "@webassemblyjs/ieee754" "1.11.1" - "@webassemblyjs/leb128" "1.11.1" - "@webassemblyjs/utf8" "1.11.1" - -"@webassemblyjs/wast-printer@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/wast-printer/-/wast-printer-1.11.1.tgz#d0c73beda8eec5426f10ae8ef55cee5e7084c2f0" - integrity sha512-IQboUWM4eKzWW+N/jij2sRatKMh99QEelo3Eb2q0qXkvPRISAj8Qxtmw5itwqK+TTkBuUIE45AxYPToqPtL5gg== - dependencies: - "@webassemblyjs/ast" "1.11.1" - "@xtuc/long" "4.2.2" - -"@webgpu/types@0.1.30": - version "0.1.30" - resolved "https://registry.yarnpkg.com/@webgpu/types/-/types-0.1.30.tgz#b6406dc4a1c1e0d469028ceb30ddffbbd2fa706c" - integrity sha512-9AXJSmL3MzY8ZL//JjudA//q+2kBRGhLBFpkdGksWIuxrMy81nFrCzj2Am+mbh8WoU6rXmv7cY5E3rdlyru2Qg== - -"@webpack-cli/configtest@^1.1.1": - version "1.1.1" - resolved "https://registry.yarnpkg.com/@webpack-cli/configtest/-/configtest-1.1.1.tgz#9f53b1b7946a6efc2a749095a4f450e2932e8356" - integrity sha512-1FBc1f9G4P/AxMqIgfZgeOTuRnwZMten8E7zap5zgpPInnCrP8D4Q81+4CWIch8i/Nf7nXjP0v6CjjbHOrXhKg== - -"@webpack-cli/info@^1.4.1": - version "1.4.1" - resolved "https://registry.yarnpkg.com/@webpack-cli/info/-/info-1.4.1.tgz#2360ea1710cbbb97ff156a3f0f24556e0fc1ebea" - integrity sha512-PKVGmazEq3oAo46Q63tpMr4HipI3OPfP7LiNOEJg963RMgT0rqheag28NCML0o3GIzA3DmxP1ZIAv9oTX1CUIA== - dependencies: - envinfo "^7.7.3" - -"@webpack-cli/serve@^1.6.1": - version "1.6.1" - resolved "https://registry.yarnpkg.com/@webpack-cli/serve/-/serve-1.6.1.tgz#0de2875ac31b46b6c5bb1ae0a7d7f0ba5678dffe" - integrity sha512-gNGTiTrjEVQ0OcVnzsRSqTxaBSr+dmTfm+qJsCDluky8uhdLWep7Gcr62QsAKHTMxjCS/8nEITsmFAhfIx+QSw== - -"@xtuc/ieee754@^1.2.0": - version "1.2.0" - resolved "https://registry.yarnpkg.com/@xtuc/ieee754/-/ieee754-1.2.0.tgz#eef014a3145ae477a1cbc00cd1e552336dceb790" - integrity sha512-DX8nKgqcGwsc0eJSqYt5lwP4DH5FlHnmuWWBRy7X0NcaGR0ZtuyeESgMwTYVEtxmsNGY+qit4QYT/MIYTOTPeA== - -"@xtuc/long@4.2.2": - version "4.2.2" - resolved "https://registry.yarnpkg.com/@xtuc/long/-/long-4.2.2.tgz#d291c6a4e97989b5c61d9acf396ae4fe133a718d" - integrity sha512-NuHqBY1PB/D8xU6s/thBgOAiAP7HOYDQ32+BFZILJ8ivkUkAHQnWfn6WhL79Owj1qmUnoN/YPhktdIoucipkAQ== - -acorn-import-assertions@^1.7.6: - version "1.8.0" - resolved "https://registry.yarnpkg.com/acorn-import-assertions/-/acorn-import-assertions-1.8.0.tgz#ba2b5939ce62c238db6d93d81c9b111b29b855e9" - integrity sha512-m7VZ3jwz4eK6A4Vtt8Ew1/mNbP24u0FhdyfA7fSvnJR6LMdfOYnmuIrrJAgrYfYJ10F/otaHTtrtrtmHdMNzEw== - -acorn@^8.5.0, acorn@^8.7.1: - version "8.8.2" - resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.8.2.tgz#1b2f25db02af965399b9776b0c2c391276d37c4a" - integrity sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw== - -ajv-keywords@^3.5.2: - version "3.5.2" - resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-3.5.2.tgz#31f29da5ab6e00d1c2d329acf7b5929614d5014d" - integrity sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ== - -ajv@^6.12.4, ajv@^6.12.5: - version "6.12.5" - resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.5.tgz#19b0e8bae8f476e5ba666300387775fb1a00a4da" - integrity sha512-lRF8RORchjpKG50/WFf8xmg7sgCLFiYNNnqdKflk63whMQcWR5ngGjiSXkL9bjxy6B2npOK2HSMN49jEBMSkag== - dependencies: - fast-deep-equal "^3.1.1" - fast-json-stable-stringify "^2.0.0" - json-schema-traverse "^0.4.1" - uri-js "^4.2.2" - -ansi-regex@^5.0.0: - version "5.0.1" - resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.1.tgz#082cb2c89c9fe8659a311a53bd6a4dc5301db304" - integrity sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ== - -ansi-styles@^3.2.1: - version "3.2.1" - resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d" - integrity sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA== - dependencies: - color-convert "^1.9.0" - -ansi-styles@^4.0.0, ansi-styles@^4.1.0: - version "4.3.0" - resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-4.3.0.tgz#edd803628ae71c04c85ae7a0906edad34b648937" - integrity sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg== - dependencies: - color-convert "^2.0.1" - -argparse@^1.0.10: - version "1.0.10" - resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911" - integrity sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg== - dependencies: - sprintf-js "~1.0.2" - -asynckit@^0.4.0: - version "0.4.0" - resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" - integrity sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q== - -balanced-match@^1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee" - integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw== - -big.js@^5.2.2: - version "5.2.2" - resolved "https://registry.yarnpkg.com/big.js/-/big.js-5.2.2.tgz#65f0af382f578bcdc742bd9c281e9cb2d7768328" - integrity sha512-vyL2OymJxmarO8gxMr0mhChsO9QGwhynfuu4+MHTAW6czfq9humCB7rKpUjDd9YUiDPU4mzpyupFSvOClAwbmQ== - -brace-expansion@^1.1.7: - version "1.1.11" - resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" - integrity sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA== - dependencies: - balanced-match "^1.0.0" - concat-map "0.0.1" - -browserslist@^4.14.5: - version "4.20.2" - resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.20.2.tgz#567b41508757ecd904dab4d1c646c612cd3d4f88" - integrity sha512-CQOBCqp/9pDvDbx3xfMi+86pr4KXIf2FDkTTdeuYw8OxS9t898LA1Khq57gtufFILXpfgsSx5woNgsBgvGjpsA== - dependencies: - caniuse-lite "^1.0.30001317" - electron-to-chromium "^1.4.84" - escalade "^3.1.1" - node-releases "^2.0.2" - picocolors "^1.0.0" - -buffer-from@^1.0.0: - version "1.1.2" - resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.2.tgz#2b146a6fd72e80b4f55d255f35ed59a3a9a41bd5" - integrity sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ== - -builtin-modules@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/builtin-modules/-/builtin-modules-3.1.0.tgz#aad97c15131eb76b65b50ef208e7584cd76a7484" - integrity sha512-k0KL0aWZuBt2lrxrcASWDfwOLMnodeQjodT/1SxEQAXsHANgo6ZC/VEaSEHCXt7aSTZ4/4H5LKa+tBXmW7Vtvw== - -camelcase@^5.0.0: - version "5.3.1" - resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-5.3.1.tgz#e3c9b31569e106811df242f715725a1f4c494320" - integrity sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg== - -caniuse-lite@^1.0.30001317: - version "1.0.30001317" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001317.tgz#0548fb28fd5bc259a70b8c1ffdbe598037666a1b" - integrity sha512-xIZLh8gBm4dqNX0gkzrBeyI86J2eCjWzYAs40q88smG844YIrN4tVQl/RhquHvKEKImWWFIVh1Lxe5n1G/N+GQ== - -chalk@^2.0.0: - version "2.4.2" - resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" - integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ== - dependencies: - ansi-styles "^3.2.1" - escape-string-regexp "^1.0.5" - supports-color "^5.3.0" - -chalk@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.0.tgz#4e14870a618d9e2edd97dd8345fd9d9dc315646a" - integrity sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A== - dependencies: - ansi-styles "^4.1.0" - supports-color "^7.1.0" - -chrome-trace-event@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/chrome-trace-event/-/chrome-trace-event-1.0.2.tgz#234090ee97c7d4ad1a2c4beae27505deffc608a4" - integrity sha512-9e/zx1jw7B4CO+c/RXoCsfg/x1AfUBioy4owYH0bJprEYAx5hRFLRhWBqHAG57D0ZM4H7vxbP7bPe0VwhQRYDQ== - dependencies: - tslib "^1.9.0" - -cliui@^6.0.0: - version "6.0.0" - resolved "https://registry.yarnpkg.com/cliui/-/cliui-6.0.0.tgz#511d702c0c4e41ca156d7d0e96021f23e13225b1" - integrity sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ== - dependencies: - string-width "^4.2.0" - strip-ansi "^6.0.0" - wrap-ansi "^6.2.0" - -cliui@^7.0.0: - version "7.0.1" - resolved "https://registry.yarnpkg.com/cliui/-/cliui-7.0.1.tgz#a4cb67aad45cd83d8d05128fc9f4d8fbb887e6b3" - integrity sha512-rcvHOWyGyid6I1WjT/3NatKj2kDt9OdSHSXpyLXaMWFbKpGACNW8pRhhdPUq9MWUOdwn8Rz9AVETjF4105rZZQ== - dependencies: - string-width "^4.2.0" - strip-ansi "^6.0.0" - wrap-ansi "^7.0.0" - -clone-deep@^4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/clone-deep/-/clone-deep-4.0.1.tgz#c19fd9bdbbf85942b4fd979c84dcf7d5f07c2387" - integrity sha512-neHB9xuzh/wk0dIHweyAXv2aPGZIVk3pLMe+/RNzINf17fe0OG96QroktYAUm7SM1PBnzTabaLboqqxDyMU+SQ== - dependencies: - is-plain-object "^2.0.4" - kind-of "^6.0.2" - shallow-clone "^3.0.0" - -color-convert@^1.9.0: - version "1.9.3" - resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8" - integrity sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg== - dependencies: - color-name "1.1.3" - -color-convert@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-2.0.1.tgz#72d3a68d598c9bdb3af2ad1e84f21d896abd4de3" - integrity sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ== - dependencies: - color-name "~1.1.4" - -color-name@1.1.3: - version "1.1.3" - resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25" - integrity sha1-p9BVi9icQveV3UIyj3QIMcpTvCU= - -color-name@~1.1.4: - version "1.1.4" - resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2" - integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA== - -colorette@^2.0.14: - version "2.0.16" - resolved "https://registry.yarnpkg.com/colorette/-/colorette-2.0.16.tgz#713b9af84fdb000139f04546bd4a93f62a5085da" - integrity sha512-hUewv7oMjCp+wkBv5Rm0v87eJhq4woh5rSR+42YSQJKecCqgIqNkZ6lAlQms/BwHPJA5NKMRlpxPRv0n8HQW6g== - -combined-stream@^1.0.8: - version "1.0.8" - resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.8.tgz#c3d45a8b34fd730631a110a8a2520682b31d5a7f" - integrity sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg== - dependencies: - delayed-stream "~1.0.0" - -commander@^2.20.0: - version "2.20.3" - resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33" - integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ== - -commander@^7.0.0: - version "7.2.0" - resolved "https://registry.yarnpkg.com/commander/-/commander-7.2.0.tgz#a36cb57d0b501ce108e4d20559a150a391d97ab7" - integrity sha512-QrWXB+ZQSVPmIWIhtEO9H+gwHaMGYiF5ChvoJ+K9ZGHG/sVsa6yiesAD1GC/x46sET00Xlwo1u49RVVVzvcSkw== - -commondir@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/commondir/-/commondir-1.0.1.tgz#ddd800da0c66127393cca5950ea968a3aaf1253b" - integrity sha1-3dgA2gxmEnOTzKWVDqloo6rxJTs= - -concat-map@0.0.1: - version "0.0.1" - resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" - integrity sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg== - -core-js@3.29.1: - version "3.29.1" - resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.29.1.tgz#40ff3b41588b091aaed19ca1aa5cb111803fa9a6" - integrity sha512-+jwgnhg6cQxKYIIjGtAHq2nwUOolo9eoFZ4sHfUH09BLXBgxnH4gA0zEd+t+BO2cNB8idaBtZFcFTRjQJRJmAw== - -cross-spawn@^7.0.3: - version "7.0.3" - resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6" - integrity sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w== - dependencies: - path-key "^3.1.0" - shebang-command "^2.0.0" - which "^2.0.1" - -decamelize@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" - integrity sha1-9lNNFRSCabIDUue+4m9QH5oZEpA= - -deep-freeze@^0.0.1: - version "0.0.1" - resolved "https://registry.yarnpkg.com/deep-freeze/-/deep-freeze-0.0.1.tgz#3a0b0005de18672819dfd38cd31f91179c893e84" - integrity sha1-OgsABd4YZygZ39OM0x+RF5yJPoQ= - -deepmerge@^4.2.2: - version "4.2.2" - resolved "https://registry.yarnpkg.com/deepmerge/-/deepmerge-4.2.2.tgz#44d2ea3679b8f4d4ffba33f03d865fc1e7bf4955" - integrity sha512-FJ3UgI4gIl+PHZm53knsuSFpE+nESMr7M4v9QcgB7S63Kj/6WqMiFQJpBBYz1Pt+66bZpP3Q7Lye0Oo9MPKEdg== - -delayed-stream@~1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" - integrity sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ== - -electron-to-chromium@^1.4.84: - version "1.4.85" - resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.85.tgz#a3666ba42147026b9f34d4d8d4caf0740e80f751" - integrity sha512-K9AsQ41WS2bjZUFpRWfvaS4RjEcRCamEkBJN1Z1TQILBfP1H8QnJ9ti0wiLiMv0sRjX3EHKzgs9jDnmGFx2jXg== - -emoji-regex@^8.0.0: - version "8.0.0" - resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37" - integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A== - -emojis-list@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/emojis-list/-/emojis-list-3.0.0.tgz#5570662046ad29e2e916e71aae260abdff4f6a78" - integrity sha512-/kyM18EfinwXZbno9FyUGeFh87KC8HRQBQGildHZbEuRyWFOmv1U10o9BBp8XVZDVNNuQKyIGIu5ZYAAXJ0V2Q== - -enhanced-resolve@^5.10.0: - version "5.12.0" - resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-5.12.0.tgz#300e1c90228f5b570c4d35babf263f6da7155634" - integrity sha512-QHTXI/sZQmko1cbDoNAa3mJ5qhWUUNAq3vR0/YiD379fWQrcfuoX1+HW2S0MTt7XmoPLapdaDKUtelUSPic7hQ== - dependencies: - graceful-fs "^4.2.4" - tapable "^2.2.0" - -envinfo@^7.7.3: - version "7.8.1" - resolved "https://registry.yarnpkg.com/envinfo/-/envinfo-7.8.1.tgz#06377e3e5f4d379fea7ac592d5ad8927e0c4d475" - integrity sha512-/o+BXHmB7ocbHEAs6F2EnG0ogybVVUdkRunTT2glZU9XAaGmhqskrvKwqXuDfNjEO0LZKWdejEEpnq8aM0tOaw== - -es-module-lexer@^0.9.0: - version "0.9.3" - resolved "https://registry.yarnpkg.com/es-module-lexer/-/es-module-lexer-0.9.3.tgz#6f13db00cc38417137daf74366f535c8eb438f19" - integrity sha512-1HQ2M2sPtxwnvOvT1ZClHyQDiggdNjURWpY2we6aMKCQiUVxTmVs2UYPLIrD84sS+kMdUwfBSylbJPwNnBrnHQ== - -escalade@^3.0.2: - version "3.1.0" - resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.1.0.tgz#e8e2d7c7a8b76f6ee64c2181d6b8151441602d4e" - integrity sha512-mAk+hPSO8fLDkhV7V0dXazH5pDc6MrjBTPyD3VeKzxnVFjH1MIxbCdqGZB9O8+EwWakZs3ZCbDS4IpRt79V1ig== - -escalade@^3.1.1: - version "3.1.1" - resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.1.1.tgz#d8cfdc7000965c5a0174b4a82eaa5c0552742e40" - integrity sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw== - -escape-goat@^2.0.0: - version "2.1.1" - resolved "https://registry.yarnpkg.com/escape-goat/-/escape-goat-2.1.1.tgz#1b2dc77003676c457ec760b2dc68edb648188675" - integrity sha512-8/uIhbG12Csjy2JEW7D9pHbreaVaS/OpN3ycnyvElTdwM5n6GY6W6e2IPemfvGZeUMqZ9A/3GqIZMgKnBhAw/Q== - -escape-string-regexp@^1.0.5: - version "1.0.5" - resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" - integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ= - -eslint-scope@5.1.1: - version "5.1.1" - resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-5.1.1.tgz#e786e59a66cb92b3f6c1fb0d508aab174848f48c" - integrity sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw== - dependencies: - esrecurse "^4.3.0" - estraverse "^4.1.1" - -esrecurse@^4.3.0: - version "4.3.0" - resolved "https://registry.yarnpkg.com/esrecurse/-/esrecurse-4.3.0.tgz#7ad7964d679abb28bee72cec63758b1c5d2c9921" - integrity sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag== - dependencies: - estraverse "^5.2.0" - -estraverse@^4.1.1: - version "4.3.0" - resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-4.3.0.tgz#398ad3f3c5a24948be7725e83d11a7de28cdbd1d" - integrity sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw== - -estraverse@^5.2.0: - version "5.2.0" - resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-5.2.0.tgz#307df42547e6cc7324d3cf03c155d5cdb8c53880" - integrity sha512-BxbNGGNm0RyRYvUdHpIwv9IWzeM9XClbOxwoATuFdOE7ZE6wHL+HQ5T8hoPM+zHvmKzzsEqhgy0GrQ5X13afiQ== - -estree-walker@^0.6.1: - version "0.6.1" - resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-0.6.1.tgz#53049143f40c6eb918b23671d1fe3219f3a1b362" - integrity sha512-SqmZANLWS0mnatqbSfRP5g8OXZC12Fgg1IwNtLsyHDzJizORW4khDfjPqJZsemPWBB2uqykUah5YpQ6epsqC/w== - -estree-walker@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-1.0.1.tgz#31bc5d612c96b704106b477e6dd5d8aa138cb700" - integrity sha512-1fMXF3YP4pZZVozF8j/ZLfvnR8NSIljt56UhbZ5PeeDmmGHpgpdwQt7ITlGvYaQukCvuBRMLEiKiYC+oeIg4cg== - -events@^3.2.0: - version "3.3.0" - resolved "https://registry.yarnpkg.com/events/-/events-3.3.0.tgz#31a95ad0a924e2d2c419a813aeb2c4e878ea7400" - integrity sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q== - -execa@^5.0.0: - version "5.1.1" - resolved "https://registry.yarnpkg.com/execa/-/execa-5.1.1.tgz#f80ad9cbf4298f7bd1d4c9555c21e93741c411dd" - integrity sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg== - dependencies: - cross-spawn "^7.0.3" - get-stream "^6.0.0" - human-signals "^2.1.0" - is-stream "^2.0.0" - merge-stream "^2.0.0" - npm-run-path "^4.0.1" - onetime "^5.1.2" - signal-exit "^3.0.3" - strip-final-newline "^2.0.0" - -fast-deep-equal@^3.1.1: - version "3.1.3" - resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525" - integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q== - -fast-json-stable-stringify@^2.0.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz#874bf69c6f404c2b5d99c481341399fd55892633" - integrity sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw== - -fastest-levenshtein@^1.0.12: - version "1.0.12" - resolved "https://registry.yarnpkg.com/fastest-levenshtein/-/fastest-levenshtein-1.0.12.tgz#9990f7d3a88cc5a9ffd1f1745745251700d497e2" - integrity sha512-On2N+BpYJ15xIC974QNVuYGMOlEVt4s0EOI3wwMqOmK1fdDY+FN/zltPV8vosq4ad4c/gJ1KHScUn/6AWIgiow== - -file-loader@^6.1.0: - version "6.1.0" - resolved "https://registry.yarnpkg.com/file-loader/-/file-loader-6.1.0.tgz#65b9fcfb0ea7f65a234a1f10cdd7f1ab9a33f253" - integrity sha512-26qPdHyTsArQ6gU4P1HJbAbnFTyT2r0pG7czh1GFAd9TZbj0n94wWbupgixZH/ET/meqi2/5+F7DhW4OAXD+Lg== - dependencies: - loader-utils "^2.0.0" - schema-utils "^2.7.1" - -find-up@^4.0.0, find-up@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/find-up/-/find-up-4.1.0.tgz#97afe7d6cdc0bc5928584b7c8d7b16e8a9aa5d19" - integrity sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw== - dependencies: - locate-path "^5.0.0" - path-exists "^4.0.0" - -form-data@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/form-data/-/form-data-3.0.1.tgz#ebd53791b78356a99af9a300d4282c4d5eb9755f" - integrity sha512-RHkBKtLWUVwd7SqRIvCZMEvAMoGUp0XU+seQiZejj0COz3RI3hWP4sCv3gZWWLjJTd7rGwcsF5eKZGii0r/hbg== - dependencies: - asynckit "^0.4.0" - combined-stream "^1.0.8" - mime-types "^2.1.12" - -fs.realpath@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" - integrity sha1-FQStJSMVjKpA20onh8sBQRmU6k8= - -fsevents@~2.1.2: - version "2.1.3" - resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.1.3.tgz#fb738703ae8d2f9fe900c33836ddebee8b97f23e" - integrity sha512-Auw9a4AxqWpa9GUfj370BMPzzyncfBABW8Mab7BGWBYDj4Isgq+cDKtx0i6u9jcX9pQDnswsaaOTgTmA5pEjuQ== - -function-bind@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d" - integrity sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A== - -get-caller-file@^2.0.1, get-caller-file@^2.0.5: - version "2.0.5" - resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e" - integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg== - -get-stream@^6.0.0: - version "6.0.1" - resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-6.0.1.tgz#a262d8eef67aced57c2852ad6167526a43cbf7b7" - integrity sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg== - -glob-to-regexp@^0.4.1: - version "0.4.1" - resolved "https://registry.yarnpkg.com/glob-to-regexp/-/glob-to-regexp-0.4.1.tgz#c75297087c851b9a578bd217dd59a92f59fe546e" - integrity sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw== - -glob@^7.1.2: - version "7.1.6" - resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.6.tgz#141f33b81a7c2492e125594307480c46679278a6" - integrity sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA== - dependencies: - fs.realpath "^1.0.0" - inflight "^1.0.4" - inherits "2" - minimatch "^3.0.4" - once "^1.3.0" - path-is-absolute "^1.0.0" - -graceful-fs@^4.1.2, graceful-fs@^4.2.4, graceful-fs@^4.2.9: - version "4.2.9" - resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.9.tgz#041b05df45755e587a24942279b9d113146e1c96" - integrity sha512-NtNxqUcXgpW2iMrfqSfR73Glt39K+BLwWsPs94yR63v45T0Wbej7eRmL5cWfwEgqXnmjQp3zaJTshdRW/qC2ZQ== - -has-flag@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd" - integrity sha1-tdRU3CGZriJWmfNGfloH87lVuv0= - -has-flag@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b" - integrity sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ== - -has@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/has/-/has-1.0.3.tgz#722d7cbfc1f6aa8241f16dd814e011e1f41e8796" - integrity sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw== - dependencies: - function-bind "^1.1.1" - -human-signals@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-2.1.0.tgz#dc91fcba42e4d06e4abaed33b3e7a3c02f514ea0" - integrity sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw== - -import-local@^3.0.2: - version "3.1.0" - resolved "https://registry.yarnpkg.com/import-local/-/import-local-3.1.0.tgz#b4479df8a5fd44f6cdce24070675676063c95cb4" - integrity sha512-ASB07uLtnDs1o6EHjKpX34BKYDSqnFerfTOJL2HvMqF70LnxpjkzDB8J44oT9pu4AMPkQwf8jl6szgvNd2tRIg== - dependencies: - pkg-dir "^4.2.0" - resolve-cwd "^3.0.0" - -inflight@^1.0.4: - version "1.0.6" - resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" - integrity sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk= - dependencies: - once "^1.3.0" - wrappy "1" - -inherits@2: - version "2.0.4" - resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" - integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== - -interpret@^2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/interpret/-/interpret-2.2.0.tgz#1a78a0b5965c40a5416d007ad6f50ad27c417df9" - integrity sha512-Ju0Bz/cEia55xDwUWEa8+olFpCiQoypjnQySseKtmjNrnps3P+xfpUmGr90T7yjlVJmOtybRvPXhKMbHr+fWnw== - -is-core-module@^2.8.1: - version "2.8.1" - resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.8.1.tgz#f59fdfca701d5879d0a6b100a40aa1560ce27211" - integrity sha512-SdNCUs284hr40hFTFP6l0IfZ/RSrMXF3qgoRHd3/79unUTvrFO/JoXwkGm+5J/Oe3E/b5GsnG330uUNgRpu1PA== - dependencies: - has "^1.0.3" - -is-docker@^2.0.0: - version "2.1.1" - resolved "https://registry.yarnpkg.com/is-docker/-/is-docker-2.1.1.tgz#4125a88e44e450d384e09047ede71adc2d144156" - integrity sha512-ZOoqiXfEwtGknTiuDEy8pN2CfE3TxMHprvNer1mXiqwkOT77Rw3YVrUQ52EqAOU3QAWDQ+bQdx7HJzrv7LS2Hw== - -is-fullwidth-code-point@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz#f116f8064fe90b3f7844a38997c0b75051269f1d" - integrity sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg== - -is-module@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/is-module/-/is-module-1.0.0.tgz#3258fb69f78c14d5b815d664336b4cffb6441591" - integrity sha1-Mlj7afeMFNW4FdZkM2tM/7ZEFZE= - -is-plain-object@^2.0.4: - version "2.0.4" - resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-2.0.4.tgz#2c163b3fafb1b606d9d17928f05c2a1c38e07677" - integrity sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og== - dependencies: - isobject "^3.0.1" - -is-reference@^1.1.2: - version "1.2.1" - resolved "https://registry.yarnpkg.com/is-reference/-/is-reference-1.2.1.tgz#8b2dac0b371f4bc994fdeaba9eb542d03002d0b7" - integrity sha512-U82MsXXiFIrjCK4otLT+o2NA2Cd2g5MLoOVXUZjIOhLurrRxpEXzI8O0KZHr3IjLvlAH1kTPYSuqer5T9ZVBKQ== - dependencies: - "@types/estree" "*" - -is-stream@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-2.0.1.tgz#fac1e3d53b97ad5a9d0ae9cef2389f5810a5c077" - integrity sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg== - -is-wsl@^2.1.1: - version "2.2.0" - resolved "https://registry.yarnpkg.com/is-wsl/-/is-wsl-2.2.0.tgz#74a4c76e77ca9fd3f932f290c17ea326cd157271" - integrity sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww== - dependencies: - is-docker "^2.0.0" - -isexe@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" - integrity sha1-6PvzdNxVb/iUehDcsFctYz8s+hA= - -isobject@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/isobject/-/isobject-3.0.1.tgz#4e431e92b11a9731636aa1f9c8d1ccbcfdab78df" - integrity sha1-TkMekrEalzFjaqH5yNHMvP2reN8= - -jest-worker@^26.0.0: - version "26.5.0" - resolved "https://registry.yarnpkg.com/jest-worker/-/jest-worker-26.5.0.tgz#87deee86dbbc5f98d9919e0dadf2c40e3152fa30" - integrity sha512-kTw66Dn4ZX7WpjZ7T/SUDgRhapFRKWmisVAF0Rv4Fu8SLFD7eLbqpLvbxVqYhSgaWa7I+bW7pHnbyfNsH6stug== - dependencies: - "@types/node" "*" - merge-stream "^2.0.0" - supports-color "^7.0.0" - -jest-worker@^27.4.5: - version "27.5.1" - resolved "https://registry.yarnpkg.com/jest-worker/-/jest-worker-27.5.1.tgz#8d146f0900e8973b106b6f73cc1e9a8cb86f8db0" - integrity sha512-7vuh85V5cdDofPyxn58nrPjBktZo0u9x1g8WtjQol+jZDaE+fhN+cIvTj11GndBnMnyfrUOG1sZQxCdjKh+DKg== - dependencies: - "@types/node" "*" - merge-stream "^2.0.0" - supports-color "^8.0.0" - -js-tokens@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" - integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ== - -json-parse-even-better-errors@^2.3.1: - version "2.3.1" - resolved "https://registry.yarnpkg.com/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz#7c47805a94319928e05777405dc12e1f7a4ee02d" - integrity sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w== - -json-schema-traverse@^0.4.1: - version "0.4.1" - resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz#69f6a87d9513ab8bb8fe63bdb0979c448e684660" - integrity sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg== - -json5@^2.1.2: - version "2.2.3" - resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.3.tgz#78cd6f1a19bdc12b73db5ad0c61efd66c1e29283" - integrity sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg== - -kind-of@^6.0.2: - version "6.0.3" - resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.3.tgz#07c05034a6c349fa06e24fa35aa76db4580ce4dd" - integrity sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw== - -loader-runner@^4.2.0: - version "4.2.0" - resolved "https://registry.yarnpkg.com/loader-runner/-/loader-runner-4.2.0.tgz#d7022380d66d14c5fb1d496b89864ebcfd478384" - integrity sha512-92+huvxMvYlMzMt0iIOukcwYBFpkYJdpl2xsZ7LrlayO7E8SOv+JJUEK17B/dJIHAOLMfh2dZZ/Y18WgmGtYNw== - -loader-utils@^2.0.0: - version "2.0.4" - resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-2.0.4.tgz#8b5cb38b5c34a9a018ee1fc0e6a066d1dfcc528c" - integrity sha512-xXqpXoINfFhgua9xiqD8fPFHgkoq1mmmpE92WlDbm9rNRd/EbRb+Gqf908T2DMfuHjjJlksiK2RbHVOdD/MqSw== - dependencies: - big.js "^5.2.2" - emojis-list "^3.0.0" - json5 "^2.1.2" - -locate-path@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-5.0.0.tgz#1afba396afd676a6d42504d0a67a3a7eb9f62aa0" - integrity sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g== - dependencies: - p-locate "^4.1.0" - -long@4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/long/-/long-4.0.0.tgz#9a7b71cfb7d361a194ea555241c92f7468d5bf28" - integrity sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA== - -magic-string@^0.25.2: - version "0.25.7" - resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.25.7.tgz#3f497d6fd34c669c6798dcb821f2ef31f5445051" - integrity sha512-4CrMT5DOHTDk4HYDlzmwu4FVCcIYI8gauveasrdCu2IKIFOJ3f0v/8MDGJCDL9oD2ppz/Av1b0Nj345H9M+XIA== - dependencies: - sourcemap-codec "^1.4.4" - -merge-stream@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/merge-stream/-/merge-stream-2.0.0.tgz#52823629a14dd00c9770fb6ad47dc6310f2c1f60" - integrity sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w== - -mime-db@1.52.0: - version "1.52.0" - resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.52.0.tgz#bbabcdc02859f4987301c856e3387ce5ec43bf70" - integrity sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg== - -mime-types@^2.1.12, mime-types@^2.1.27: - version "2.1.35" - resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.35.tgz#381a871b62a734450660ae3deee44813f70d959a" - integrity sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw== - dependencies: - mime-db "1.52.0" - -mimic-fn@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-2.1.0.tgz#7ed2c2ccccaf84d3ffcb7a69b57711fc2083401b" - integrity sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg== - -minimatch@^3.0.4: - version "3.1.2" - resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b" - integrity sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw== - dependencies: - brace-expansion "^1.1.7" - -minimist@1.2.6: - version "1.2.6" - resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.6.tgz#8637a5b759ea0d6e98702cfb3a9283323c93af44" - integrity sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q== - -nanoid@^3.0.1: - version "3.3.1" - resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.1.tgz#6347a18cac88af88f58af0b3594b723d5e99bb35" - integrity sha512-n6Vs/3KGyxPQd6uO0eH4Bv0ojGSUvuLlIHtC3Y0kEO23YRge8H9x1GCzLn28YX0H66pMkxuaeESFq4tKISKwdw== - -neo-async@^2.6.2: - version "2.6.2" - resolved "https://registry.yarnpkg.com/neo-async/-/neo-async-2.6.2.tgz#b4aafb93e3aeb2d8174ca53cf163ab7d7308305f" - integrity sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw== - -node-fetch@2.6.7, node-fetch@~2.6.1: - version "2.6.7" - resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.7.tgz#24de9fba827e3b4ae44dc8b20256a379160052ad" - integrity sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ== - dependencies: - whatwg-url "^5.0.0" - -node-releases@^2.0.2: - version "2.0.2" - resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-2.0.2.tgz#7139fe71e2f4f11b47d4d2986aaf8c48699e0c01" - integrity sha512-XxYDdcQ6eKqp/YjI+tb2C5WM2LgjnZrfYg4vgQt49EK268b6gYCHsBLrK2qvJo4FmCtqmKezb0WZFK4fkrZNsg== - -npm-run-path@^4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/npm-run-path/-/npm-run-path-4.0.1.tgz#b7ecd1e5ed53da8e37a55e1c2269e0b97ed748ea" - integrity sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw== - dependencies: - path-key "^3.0.0" - -once@^1.3.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" - integrity sha1-WDsap3WWHUsROsF9nFC6753Xa9E= - dependencies: - wrappy "1" - -onetime@^5.1.2: - version "5.1.2" - resolved "https://registry.yarnpkg.com/onetime/-/onetime-5.1.2.tgz#d0e96ebb56b07476df1dd9c4806e5237985ca45e" - integrity sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg== - dependencies: - mimic-fn "^2.1.0" - -open@^7.0.3: - version "7.3.0" - resolved "https://registry.yarnpkg.com/open/-/open-7.3.0.tgz#45461fdee46444f3645b6e14eb3ca94b82e1be69" - integrity sha512-mgLwQIx2F/ye9SmbrUkurZCnkoXyXyu9EbHtJZrICjVAJfyMArdHp3KkixGdZx1ZHFPNIwl0DDM1dFFqXbTLZw== - dependencies: - is-docker "^2.0.0" - is-wsl "^2.1.1" - -p-limit@^2.2.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-2.3.0.tgz#3dd33c647a214fdfffd835933eb086da0dc21db1" - integrity sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w== - dependencies: - p-try "^2.0.0" - -p-locate@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-4.1.0.tgz#a3428bb7088b3a60292f66919278b7c297ad4f07" - integrity sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A== - dependencies: - p-limit "^2.2.0" - -p-try@^2.0.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/p-try/-/p-try-2.2.0.tgz#cb2868540e313d61de58fafbe35ce9004d5540e6" - integrity sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ== - -path-exists@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-4.0.0.tgz#513bdbe2d3b95d7762e8c1137efa195c6c61b5b3" - integrity sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w== - -path-is-absolute@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" - integrity sha1-F0uSaHNVNP+8es5r9TpanhtcX18= - -path-key@^3.0.0, path-key@^3.1.0: - version "3.1.1" - resolved "https://registry.yarnpkg.com/path-key/-/path-key-3.1.1.tgz#581f6ade658cbba65a0d3380de7753295054f375" - integrity sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q== - -path-parse@^1.0.6, path-parse@^1.0.7: - version "1.0.7" - resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.7.tgz#fbc114b60ca42b30d9daf5858e4bd68bbedb6735" - integrity sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw== - -picocolors@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/picocolors/-/picocolors-1.0.0.tgz#cb5bdc74ff3f51892236eaf79d68bc44564ab81c" - integrity sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ== - -picomatch@^2.2.2: - version "2.2.2" - resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.2.2.tgz#21f333e9b6b8eaff02468f5146ea406d345f4dad" - integrity sha512-q0M/9eZHzmr0AulXyPwNfZjtwZ/RBZlbN3K3CErVrk50T2ASYI7Bye0EvekFY3IP1Nt2DHu0re+V2ZHIpMkuWg== - -pkg-dir@^4.2.0: - version "4.2.0" - resolved "https://registry.yarnpkg.com/pkg-dir/-/pkg-dir-4.2.0.tgz#f099133df7ede422e81d1d8448270eeb3e4261f3" - integrity sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ== - dependencies: - find-up "^4.0.0" - -punycode@^2.1.0: - version "2.1.1" - resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec" - integrity sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A== - -pupa@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/pupa/-/pupa-2.0.1.tgz#dbdc9ff48ffbea4a26a069b6f9f7abb051008726" - integrity sha512-hEJH0s8PXLY/cdXh66tNEQGndDrIKNqNC5xmrysZy3i5C3oEoLna7YAOad+7u125+zH1HNXUmGEkrhb3c2VriA== - dependencies: - escape-goat "^2.0.0" - -randombytes@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/randombytes/-/randombytes-2.1.0.tgz#df6f84372f0270dc65cdf6291349ab7a473d4f2a" - integrity sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ== - dependencies: - safe-buffer "^5.1.0" - -rechoir@^0.7.0: - version "0.7.1" - resolved "https://registry.yarnpkg.com/rechoir/-/rechoir-0.7.1.tgz#9478a96a1ca135b5e88fc027f03ee92d6c645686" - integrity sha512-/njmZ8s1wVeR6pjTZ+0nCnv8SpZNRMT2D1RLOJQESlYFDBvwpTA4KWJpZ+sBJ4+vhjILRcK7JIFdGCdxEAAitg== - dependencies: - resolve "^1.9.0" - -regenerator-runtime@^0.13.5: - version "0.13.7" - resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.7.tgz#cac2dacc8a1ea675feaabaeb8ae833898ae46f55" - integrity sha512-a54FxoJDIr27pgf7IgeQGxmqUNYrcV338lf/6gH456HZ/PhX+5BcwHXG9ajESmwe6WRO0tAzRUrRmNONWgkrew== - -require-directory@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42" - integrity sha1-jGStX9MNqxyXbiNE/+f3kqam30I= - -require-main-filename@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-2.0.0.tgz#d0b329ecc7cc0f61649f62215be69af54aa8989b" - integrity sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg== - -resolve-cwd@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/resolve-cwd/-/resolve-cwd-3.0.0.tgz#0f0075f1bb2544766cf73ba6a6e2adfebcb13f2d" - integrity sha512-OrZaX2Mb+rJCpH/6CpSqt9xFVpN++x01XnN2ie9g6P5/3xelLAkXWVADpdz1IHD/KFfEXyE6V0U01OQ3UO2rEg== - dependencies: - resolve-from "^5.0.0" - -resolve-from@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-5.0.0.tgz#c35225843df8f776df21c57557bc087e9dfdfc69" - integrity sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw== - -resolve@^1.11.0, resolve@^1.11.1, resolve@^1.17.0: - version "1.17.0" - resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.17.0.tgz#b25941b54968231cc2d1bb76a79cb7f2c0bf8444" - integrity sha512-ic+7JYiV8Vi2yzQGFWOkiZD5Z9z7O2Zhm9XMaTxdJExKasieFCr+yXZ/WmXsckHiKl12ar0y6XiXDx3m4RHn1w== - dependencies: - path-parse "^1.0.6" - -resolve@^1.9.0: - version "1.22.0" - resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.22.0.tgz#5e0b8c67c15df57a89bdbabe603a002f21731198" - integrity sha512-Hhtrw0nLeSrFQ7phPp4OOcVjLPIeMnRlr5mcnVuMe7M/7eBn98A3hmFRLoFo3DLZkivSYwhRUJTyPyWAk56WLw== - dependencies: - is-core-module "^2.8.1" - path-parse "^1.0.7" - supports-preserve-symlinks-flag "^1.0.0" - -rollup-plugin-commonjs@^10.1.0: - version "10.1.0" - resolved "https://registry.yarnpkg.com/rollup-plugin-commonjs/-/rollup-plugin-commonjs-10.1.0.tgz#417af3b54503878e084d127adf4d1caf8beb86fb" - integrity sha512-jlXbjZSQg8EIeAAvepNwhJj++qJWNJw1Cl0YnOqKtP5Djx+fFGkp3WRh+W0ASCaFG5w1jhmzDxgu3SJuVxPF4Q== - dependencies: - estree-walker "^0.6.1" - is-reference "^1.1.2" - magic-string "^0.25.2" - resolve "^1.11.0" - rollup-pluginutils "^2.8.1" - -rollup-plugin-node-resolve@^5.2.0: - version "5.2.0" - resolved "https://registry.yarnpkg.com/rollup-plugin-node-resolve/-/rollup-plugin-node-resolve-5.2.0.tgz#730f93d10ed202473b1fb54a5997a7db8c6d8523" - integrity sha512-jUlyaDXts7TW2CqQ4GaO5VJ4PwwaV8VUGA7+km3n6k6xtOEacf61u0VXwN80phY/evMcaS+9eIeJ9MOyDxt5Zw== - dependencies: - "@types/resolve" "0.0.8" - builtin-modules "^3.1.0" - is-module "^1.0.0" - resolve "^1.11.1" - rollup-pluginutils "^2.8.1" - -rollup-plugin-terser@^6.1.0: - version "6.1.0" - resolved "https://registry.yarnpkg.com/rollup-plugin-terser/-/rollup-plugin-terser-6.1.0.tgz#071866585aea104bfbb9dd1019ac523e63c81e45" - integrity sha512-4fB3M9nuoWxrwm39habpd4hvrbrde2W2GG4zEGPQg1YITNkM3Tqur5jSuXlWNzbv/2aMLJ+dZJaySc3GCD8oDw== - dependencies: - "@babel/code-frame" "^7.8.3" - jest-worker "^26.0.0" - serialize-javascript "^3.0.0" - terser "^4.7.0" - -rollup-plugin-visualizer@^4.0.4: - version "4.1.1" - resolved "https://registry.yarnpkg.com/rollup-plugin-visualizer/-/rollup-plugin-visualizer-4.1.1.tgz#b8b18db0aa4b0e3b2af583399fa9d7e3f5a61808" - integrity sha512-aQBukhj8T+1BcOjD/5xB3+mZSSzHIVT+WpQDDEVpmPCkILVX0J7NPOuKEvKIXU+iZLvF7B5/wJA4+wxuH7FNew== - dependencies: - nanoid "^3.0.1" - open "^7.0.3" - pupa "^2.0.0" - source-map "^0.7.3" - yargs "^15.0.0" - -rollup-pluginutils@^2.8.1: - version "2.8.2" - resolved "https://registry.yarnpkg.com/rollup-pluginutils/-/rollup-pluginutils-2.8.2.tgz#72f2af0748b592364dbd3389e600e5a9444a351e" - integrity sha512-EEp9NhnUkwY8aif6bxgovPHMoMoNr2FulJziTndpt5H9RdwC47GSGuII9XxpSdzVGM0GWrNPHV6ie1LTNJPaLQ== - dependencies: - estree-walker "^0.6.1" - -rollup@^2.23.0: - version "2.28.2" - resolved "https://registry.yarnpkg.com/rollup/-/rollup-2.28.2.tgz#599ec4978144a82d8a8ec3d37670a8440cb04e4b" - integrity sha512-8txbsFBFLmm9Xdt4ByTOGa9Muonmc8MfNjnGAR8U8scJlF1ZW7AgNZa7aqBXaKtlvnYP/ab++fQIq9dB9NWUbg== - optionalDependencies: - fsevents "~2.1.2" - -safe-buffer@^5.1.0, safe-buffer@~5.2.0: - version "5.2.1" - resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" - integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== - -schema-utils@^2.7.1: - version "2.7.1" - resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-2.7.1.tgz#1ca4f32d1b24c590c203b8e7a50bf0ea4cd394d7" - integrity sha512-SHiNtMOUGWBQJwzISiVYKu82GiV4QYGePp3odlY1tuKO7gPtphAT5R/py0fA6xtbgLL/RvtJZnU9b8s0F1q0Xg== - dependencies: - "@types/json-schema" "^7.0.5" - ajv "^6.12.4" - ajv-keywords "^3.5.2" - -schema-utils@^3.1.0, schema-utils@^3.1.1: - version "3.1.1" - resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-3.1.1.tgz#bc74c4b6b6995c1d88f76a8b77bea7219e0c8281" - integrity sha512-Y5PQxS4ITlC+EahLuXaY86TXfR7Dc5lw294alXOq86JAHCihAIZfqv8nNCWvaEJvaC51uN9hbLGeV0cFBdH+Fw== - dependencies: - "@types/json-schema" "^7.0.8" - ajv "^6.12.5" - ajv-keywords "^3.5.2" - -seedrandom@^3.0.5: - version "3.0.5" - resolved "https://registry.yarnpkg.com/seedrandom/-/seedrandom-3.0.5.tgz#54edc85c95222525b0c7a6f6b3543d8e0b3aa0a7" - integrity sha512-8OwmbklUNzwezjGInmZ+2clQmExQPvomqjL7LFqOYqtmuxRgQYqOD3mHaU+MvZn5FLUeVxVfQjwLZW/n/JFuqg== - -serialize-javascript@^3.0.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-3.1.0.tgz#8bf3a9170712664ef2561b44b691eafe399214ea" - integrity sha512-JIJT1DGiWmIKhzRsG91aS6Ze4sFUrYbltlkg2onR5OrnNM02Kl/hnY/T4FN2omvyeBbQmMJv+K4cPOpGzOTFBg== - dependencies: - randombytes "^2.1.0" - -serialize-javascript@^6.0.0: - version "6.0.0" - resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-6.0.0.tgz#efae5d88f45d7924141da8b5c3a7a7e663fefeb8" - integrity sha512-Qr3TosvguFt8ePWqsvRfrKyQXIiW+nGbYpy8XK24NQHE83caxWt+mIymTT19DGFbNWNLfEwsrkSmN64lVWB9ag== - dependencies: - randombytes "^2.1.0" - -set-blocking@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7" - integrity sha1-BF+XgtARrppoA93TgrJDkrPYkPc= - -shallow-clone@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/shallow-clone/-/shallow-clone-3.0.1.tgz#8f2981ad92531f55035b01fb230769a40e02efa3" - integrity sha512-/6KqX+GVUdqPuPPd2LxDDxzX6CAbjJehAAOKlNpqqUpAqPM6HeL8f+o3a+JsyGjn2lv0WY8UsTgUJjU9Ok55NA== - dependencies: - kind-of "^6.0.2" - -shebang-command@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-2.0.0.tgz#ccd0af4f8835fbdc265b82461aaf0c36663f34ea" - integrity sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA== - dependencies: - shebang-regex "^3.0.0" - -shebang-regex@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-3.0.0.tgz#ae16f1644d873ecad843b0307b143362d4c42172" - integrity sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A== - -signal-exit@^3.0.3: - version "3.0.7" - resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.7.tgz#a9a1767f8af84155114eaabd73f99273c8f59ad9" - integrity sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ== - -slash@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/slash/-/slash-3.0.0.tgz#6539be870c165adbd5240220dbe361f1bc4d4634" - integrity sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q== - -source-map-support@~0.5.12, source-map-support@~0.5.20: - version "0.5.21" - resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.21.tgz#04fe7c7f9e1ed2d662233c28cb2b35b9f63f6e4f" - integrity sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w== - dependencies: - buffer-from "^1.0.0" - source-map "^0.6.0" - -source-map@^0.6.0, source-map@^0.6.1, source-map@~0.6.1: - version "0.6.1" - resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" - integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== - -source-map@^0.7.3, source-map@~0.7.2: - version "0.7.3" - resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.7.3.tgz#5302f8169031735226544092e64981f751750383" - integrity sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ== - -sourcemap-codec@^1.4.4: - version "1.4.8" - resolved "https://registry.yarnpkg.com/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz#ea804bd94857402e6992d05a38ef1ae35a9ab4c4" - integrity sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA== - -sprintf-js@~1.0.2: - version "1.0.3" - resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" - integrity sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw= - -string-width@^4.1.0, string-width@^4.2.0: - version "4.2.0" - resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.0.tgz#952182c46cc7b2c313d1596e623992bd163b72b5" - integrity sha512-zUz5JD+tgqtuDjMhwIg5uFVV3dtqZ9yQJlZVfq4I01/K5Paj5UHj7VyrQOJvzawSVlKpObApbfD0Ed6yJc+1eg== - dependencies: - emoji-regex "^8.0.0" - is-fullwidth-code-point "^3.0.0" - strip-ansi "^6.0.0" - -string_decoder@^1.3.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.3.0.tgz#42f114594a46cf1a8e30b0a84f56c78c3edac21e" - integrity sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA== - dependencies: - safe-buffer "~5.2.0" - -strip-ansi@^6.0.0: - version "6.0.0" - resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.0.tgz#0b1571dd7669ccd4f3e06e14ef1eed26225ae532" - integrity sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w== - dependencies: - ansi-regex "^5.0.0" - -strip-final-newline@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/strip-final-newline/-/strip-final-newline-2.0.0.tgz#89b852fb2fcbe936f6f4b3187afb0a12c1ab58ad" - integrity sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA== - -supports-color@^5.3.0: - version "5.5.0" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f" - integrity sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow== - dependencies: - has-flag "^3.0.0" - -supports-color@^7.0.0, supports-color@^7.1.0: - version "7.2.0" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-7.2.0.tgz#1b7dcdcb32b8138801b3e478ba6a51caa89648da" - integrity sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw== - dependencies: - has-flag "^4.0.0" - -supports-color@^8.0.0: - version "8.1.1" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-8.1.1.tgz#cd6fc17e28500cff56c1b86c0a7fd4a54a73005c" - integrity sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q== - dependencies: - has-flag "^4.0.0" - -supports-preserve-symlinks-flag@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz#6eda4bd344a3c94aea376d4cc31bc77311039e09" - integrity sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w== - -tapable@^2.1.1, tapable@^2.2.0: - version "2.2.1" - resolved "https://registry.yarnpkg.com/tapable/-/tapable-2.2.1.tgz#1967a73ef4060a82f12ab96af86d52fdb76eeca0" - integrity sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ== - -terser-webpack-plugin@^5.1.3, terser-webpack-plugin@^5.3.1: - version "5.3.1" - resolved "https://registry.yarnpkg.com/terser-webpack-plugin/-/terser-webpack-plugin-5.3.1.tgz#0320dcc270ad5372c1e8993fabbd927929773e54" - integrity sha512-GvlZdT6wPQKbDNW/GDQzZFg/j4vKU96yl2q6mcUkzKOgW4gwf1Z8cZToUCrz31XHlPWH8MVb1r2tFtdDtTGJ7g== - dependencies: - jest-worker "^27.4.5" - schema-utils "^3.1.1" - serialize-javascript "^6.0.0" - source-map "^0.6.1" - terser "^5.7.2" - -terser@^4.7.0: - version "4.8.1" - resolved "https://registry.yarnpkg.com/terser/-/terser-4.8.1.tgz#a00e5634562de2239fd404c649051bf6fc21144f" - integrity sha512-4GnLC0x667eJG0ewJTa6z/yXrbLGv80D9Ru6HIpCQmO+Q4PfEtBFi0ObSckqwL6VyQv/7ENJieXHo2ANmdQwgw== - dependencies: - commander "^2.20.0" - source-map "~0.6.1" - source-map-support "~0.5.12" - -terser@^5.7.2: - version "5.12.1" - resolved "https://registry.yarnpkg.com/terser/-/terser-5.12.1.tgz#4cf2ebed1f5bceef5c83b9f60104ac4a78b49e9c" - integrity sha512-NXbs+7nisos5E+yXwAD+y7zrcTkMqb0dEJxIGtSKPdCBzopf7ni4odPul2aechpV7EXNvOudYOX2bb5tln1jbQ== - dependencies: - acorn "^8.5.0" - commander "^2.20.0" - source-map "~0.7.2" - source-map-support "~0.5.20" - -tr46@~0.0.3: - version "0.0.3" - resolved "https://registry.yarnpkg.com/tr46/-/tr46-0.0.3.tgz#8184fd347dac9cdc185992f3a6622e14b9d9ab6a" - integrity sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o= - -tslib@^1.9.0: - version "1.14.0" - resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.0.tgz#d624983f3e2c5e0b55307c3dd6c86acd737622c6" - integrity sha512-+Zw5lu0D9tvBMjGP8LpvMb0u2WW2QV3y+D8mO6J+cNzCYIN4sVy43Bf9vl92nqFahutN0I8zHa7cc4vihIshnw== - -uri-js@^4.2.2: - version "4.4.0" - resolved "https://registry.yarnpkg.com/uri-js/-/uri-js-4.4.0.tgz#aa714261de793e8a82347a7bcc9ce74e86f28602" - integrity sha512-B0yRTzYdUCCn9n+F4+Gh4yIDtMQcaJsmYBDsTSG8g/OejKBodLQ2IHfN3bM7jUsRXndopT7OIXWdYqc1fjmV6g== - dependencies: - punycode "^2.1.0" - -watchpack@^2.4.0: - version "2.4.0" - resolved "https://registry.yarnpkg.com/watchpack/-/watchpack-2.4.0.tgz#fa33032374962c78113f93c7f2fb4c54c9862a5d" - integrity sha512-Lcvm7MGST/4fup+ifyKi2hjyIAwcdI4HRgtvTpIUxBRhB+RFtUh8XtDOxUfctVCnhVi+QQj49i91OyvzkJl6cg== - dependencies: - glob-to-regexp "^0.4.1" - graceful-fs "^4.1.2" - -webidl-conversions@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871" - integrity sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE= - -webpack-cli@^4.9.2: - version "4.9.2" - resolved "https://registry.yarnpkg.com/webpack-cli/-/webpack-cli-4.9.2.tgz#77c1adaea020c3f9e2db8aad8ea78d235c83659d" - integrity sha512-m3/AACnBBzK/kMTcxWHcZFPrw/eQuY4Df1TxvIWfWM2x7mRqBQCqKEd96oCUa9jkapLBaFfRce33eGDb4Pr7YQ== - dependencies: - "@discoveryjs/json-ext" "^0.5.0" - "@webpack-cli/configtest" "^1.1.1" - "@webpack-cli/info" "^1.4.1" - "@webpack-cli/serve" "^1.6.1" - colorette "^2.0.14" - commander "^7.0.0" - execa "^5.0.0" - fastest-levenshtein "^1.0.12" - import-local "^3.0.2" - interpret "^2.2.0" - rechoir "^0.7.0" - webpack-merge "^5.7.3" - -webpack-merge@^5.7.3: - version "5.8.0" - resolved "https://registry.yarnpkg.com/webpack-merge/-/webpack-merge-5.8.0.tgz#2b39dbf22af87776ad744c390223731d30a68f61" - integrity sha512-/SaI7xY0831XwP6kzuwhKWVKDP9t1QY1h65lAFLbZqMPIuYcD9QAW4u9STIbU9kaJbPBB/geU/gLr1wDjOhQ+Q== - dependencies: - clone-deep "^4.0.1" - wildcard "^2.0.0" - -webpack-sources@^3.2.3: - version "3.2.3" - resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-3.2.3.tgz#2d4daab8451fd4b240cc27055ff6a0c2ccea0cde" - integrity sha512-/DyMEOrDgLKKIG0fmvtz+4dUX/3Ghozwgm6iPp8KRhvn+eQf9+Q7GWxVNMk3+uCPWfdXYC4ExGBckIXdFEfH1w== - -webpack@^5.76.0: - version "5.76.0" - resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.76.0.tgz#f9fb9fb8c4a7dbdcd0d56a98e56b8a942ee2692c" - integrity sha512-l5sOdYBDunyf72HW8dF23rFtWq/7Zgvt/9ftMof71E/yUb1YLOBmTgA2K4vQthB3kotMrSj609txVE0dnr2fjA== - dependencies: - "@types/eslint-scope" "^3.7.3" - "@types/estree" "^0.0.51" - "@webassemblyjs/ast" "1.11.1" - "@webassemblyjs/wasm-edit" "1.11.1" - "@webassemblyjs/wasm-parser" "1.11.1" - acorn "^8.7.1" - acorn-import-assertions "^1.7.6" - browserslist "^4.14.5" - chrome-trace-event "^1.0.2" - enhanced-resolve "^5.10.0" - es-module-lexer "^0.9.0" - eslint-scope "5.1.1" - events "^3.2.0" - glob-to-regexp "^0.4.1" - graceful-fs "^4.2.9" - json-parse-even-better-errors "^2.3.1" - loader-runner "^4.2.0" - mime-types "^2.1.27" - neo-async "^2.6.2" - schema-utils "^3.1.0" - tapable "^2.1.1" - terser-webpack-plugin "^5.1.3" - watchpack "^2.4.0" - webpack-sources "^3.2.3" - -whatwg-url@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-5.0.0.tgz#966454e8765462e37644d3626f6742ce8b70965d" - integrity sha1-lmRU6HZUYuN2RNNib2dCzotwll0= - dependencies: - tr46 "~0.0.3" - webidl-conversions "^3.0.0" - -which-module@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/which-module/-/which-module-2.0.0.tgz#d9ef07dce77b9902b8a3a8fa4b31c3e3f7e6e87a" - integrity sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho= - -which@^2.0.1: - version "2.0.2" - resolved "https://registry.yarnpkg.com/which/-/which-2.0.2.tgz#7c6a8dd0a636a0327e10b59c9286eee93f3f51b1" - integrity sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA== - dependencies: - isexe "^2.0.0" - -wildcard@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/wildcard/-/wildcard-2.0.0.tgz#a77d20e5200c6faaac979e4b3aadc7b3dd7f8fec" - integrity sha512-JcKqAHLPxcdb9KM49dufGXn2x3ssnfjbcaQdLlfZsL9rH9wgDQjUtDxbo8NE0F6SFvydeu1VhZe7hZuHsB2/pw== - -wrap-ansi@^6.2.0: - version "6.2.0" - resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-6.2.0.tgz#e9393ba07102e6c91a3b221478f0257cd2856e53" - integrity sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA== - dependencies: - ansi-styles "^4.0.0" - string-width "^4.1.0" - strip-ansi "^6.0.0" - -wrap-ansi@^7.0.0: - version "7.0.0" - resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" - integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== - dependencies: - ansi-styles "^4.0.0" - string-width "^4.1.0" - strip-ansi "^6.0.0" - -wrappy@1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" - integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8= - -y18n@^4.0.0: - version "4.0.3" - resolved "https://registry.yarnpkg.com/y18n/-/y18n-4.0.3.tgz#b5f259c82cd6e336921efd7bfd8bf560de9eeedf" - integrity sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ== - -y18n@^5.0.1: - version "5.0.2" - resolved "https://registry.yarnpkg.com/y18n/-/y18n-5.0.2.tgz#48218df5da2731b4403115c39a1af709c873f829" - integrity sha512-CkwaeZw6dQgqgPGeTWKMXCRmMcBgETFlTml1+ZOO+q7kGst8NREJ+eWwFNPVUQ4QGdAaklbqCZHH6Zuep1RjiA== - -yargs-parser@^18.1.2: - version "18.1.3" - resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-18.1.3.tgz#be68c4975c6b2abf469236b0c870362fab09a7b0" - integrity sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ== - dependencies: - camelcase "^5.0.0" - decamelize "^1.2.0" - -yargs-parser@^20.0.0: - version "20.2.1" - resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.1.tgz#28f3773c546cdd8a69ddae68116b48a5da328e77" - integrity sha512-yYsjuSkjbLMBp16eaOt7/siKTjNVjMm3SoJnIg3sEh/JsvqVVDyjRKmaJV4cl+lNIgq6QEco2i3gDebJl7/vLA== - -yargs@^15.0.0: - version "15.4.1" - resolved "https://registry.yarnpkg.com/yargs/-/yargs-15.4.1.tgz#0d87a16de01aee9d8bec2bfbf74f67851730f4f8" - integrity sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A== - dependencies: - cliui "^6.0.0" - decamelize "^1.2.0" - find-up "^4.1.0" - get-caller-file "^2.0.1" - require-directory "^2.1.1" - require-main-filename "^2.0.0" - set-blocking "^2.0.0" - string-width "^4.2.0" - which-module "^2.0.0" - y18n "^4.0.0" - yargs-parser "^18.1.2" - -yargs@^16.0.3: - version "16.0.3" - resolved "https://registry.yarnpkg.com/yargs/-/yargs-16.0.3.tgz#7a919b9e43c90f80d4a142a89795e85399a7e54c" - integrity sha512-6+nLw8xa9uK1BOEOykaiYAJVh6/CjxWXK/q9b5FpRgNslt8s22F2xMBqVIKgCRjNgGvGPBy8Vog7WN7yh4amtA== - dependencies: - cliui "^7.0.0" - escalade "^3.0.2" - get-caller-file "^2.0.5" - require-directory "^2.1.1" - string-width "^4.2.0" - y18n "^5.0.1" - yargs-parser "^20.0.0" diff --git a/tfjs-master/e2e/custom_module/development.md b/tfjs-master/e2e/custom_module/development.md deleted file mode 100644 index 04e1be669..000000000 --- a/tfjs-master/e2e/custom_module/development.md +++ /dev/null @@ -1,23 +0,0 @@ -# A few notes on the custom_module subfolders - - - -In each folders package.json there is an entry like: - -`"make-custom-tfjs-modules": "node ./node_modules/@tensorflow/tfjs/dist/tools/custom_module/cli.js --config app_tfjs_config.json",` - -This would normally look like: - -`"make-custom-tfjs-modules": "npx tfjs-custom-module --config app_tfjs_config.json",` - -However when yarn is installing a dependency specified with `link://` it does -not properly symlink `bin` scripts in the dependencies. - -This can be fixed by changing `link://` to (the potentially more standard) -`file:..` (it also works when installing from npm). However that would -potentially introduce skew in the lock files as the paths generated after -running yarn are have parts local to the specific file system. We also have -other scripts that look to replace `link` dependencies with npm ones. - -This file is just to document that quirk. - diff --git a/tfjs-master/e2e/custom_module/universal_sentence_encoder/app.js b/tfjs-master/e2e/custom_module/universal_sentence_encoder/app.js deleted file mode 100644 index 379ef6436..000000000 --- a/tfjs-master/e2e/custom_module/universal_sentence_encoder/app.js +++ /dev/null @@ -1,63 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as use from '@tensorflow-models/universal-sentence-encoder'; -import * as tf from '@tensorflow/tfjs'; - -async function main() { - await tf.ready(); - const backend = tf.getBackend(); - self.postMessage({msg: true, payload: `Backend ready: ${backend}.`}); - - const registeredKernels = tf.getKernelsForBackend(backend); - let model; - try { - model = await use.load(); - } catch (e) { - self.postMessage({error: true, payload: e}); - } - - const sentences = ['Hello.', 'How are you?']; - const predictions = await model.embed(sentences); - // shape of predictions should be [2, 512] - - // send the final result of the test. - self.postMessage({ - result: true, - payload: { - numKernels: registeredKernels.length, - kernelNames: registeredKernels.map(k => k.kernelName), - backend, - predictions: predictions - } - }); -} - -self.addEventListener('message', function(e) { - try { - if (e.data.profile) { - tf.profile(() => main()).then((profile) => { - const usedKernels = profile.kernelNames; - self.postMessage({msg: true, payload: {usedKernels}}); - }); - } else { - main(); - } - } catch (e) { - self.postMessage({error: true, payload: e}); - } -}, false); diff --git a/tfjs-master/e2e/custom_module/universal_sentence_encoder/app_tfjs_config.json b/tfjs-master/e2e/custom_module/universal_sentence_encoder/app_tfjs_config.json deleted file mode 100644 index d64b91171..000000000 --- a/tfjs-master/e2e/custom_module/universal_sentence_encoder/app_tfjs_config.json +++ /dev/null @@ -1,47 +0,0 @@ -{ - "kernels": [ - "StridedSlice", - "Less", - "Cast", - "Reshape", - "GatherV2", - "Max", - "Add", - "Maximum", - "SparseToDense", - "Greater", - "Sum", - "ExpandDims", - "Concat", - "LogicalNot", - "Multiply", - "ScatterNd", - "GatherNd", - "Cos", - "Sin", - "BatchMatMul", - "Mean", - "Sub", - "Square", - "Rsqrt", - "Conv2D", - "SplitV", - "Pack", - "Transpose", - "Slice", - "Softmax", - "Prod", - "Relu", - "Range", - "RealDiv", - "Tanh" - ], - "backends": [ - "webgl" - ], - "models": [ - "./model.json" - ], - "outputPath": "./custom_tfjs", - "forwardModeOnly": true -} diff --git a/tfjs-master/e2e/custom_module/universal_sentence_encoder/build.sh b/tfjs-master/e2e/custom_module/universal_sentence_encoder/build.sh deleted file mode 100644 index 81fa5f87c..000000000 --- a/tfjs-master/e2e/custom_module/universal_sentence_encoder/build.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env bash - -# Copyright 2023 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================== - -set -e - -yarn --mutex network -# Ensure that we test against freshly generated custom modules. -rm -f ./custom_tfjs/*.js -yarn make-custom-tfjs-modules - -parallel ::: "yarn webpack:full" \ - "yarn webpack:custom" \ - "yarn rollup:full" \ - "yarn rollup:custom" - diff --git a/tfjs-master/e2e/custom_module/universal_sentence_encoder/model.json b/tfjs-master/e2e/custom_module/universal_sentence_encoder/model.json deleted file mode 100644 index 175278573..000000000 --- a/tfjs-master/e2e/custom_module/universal_sentence_encoder/model.json +++ /dev/null @@ -1,7182 +0,0 @@ -{ - "modelTopology": { - "node": [ - { - "input": [], - "attr": { - "value": { - "tensor": { - "floatVal": [], - "doubleVal": [], - "intVal": [], - "stringVal": [], - "scomplexVal": [], - "int64Val": [], - "boolVal": [], - "uint32Val": [], - "uint64Val": [], - "dtype": 1, - "tensorShape": { - "dim": [ - { - "size": "1536" - }, - { - "size": "512" - } - ] - } - } - }, - "dtype": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv2/Tensordot/Reshape_1", - "op": "Const" - }, - { - "input": [], - "attr": { - "value": { - "tensor": { - "floatVal": [], - "doubleVal": [], - "intVal": [], - "stringVal": [], - "scomplexVal": [], - "int64Val": [], - "boolVal": [], - "uint32Val": [], - "uint64Val": [], - "dtype": 1, - "tensorShape": { - "dim": [ - { - "size": "512" - }, - { - "size": "1536" - } - ] - } - } - }, - "dtype": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv1/Tensordot/Reshape_1", - "op": "Const" - }, - { - "input": [], - "attr": { - "dtype": { - "type": 1 - }, - "value": { - "tensor": { - "floatVal": [], - "doubleVal": [], - "intVal": [], - "stringVal": [], - "scomplexVal": [], - "int64Val": [], - "boolVal": [], - "uint32Val": [], - "uint64Val": [], - "dtype": 1, - "tensorShape": { - "dim": [ - { - "size": "512" - } - ] - } - } - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/Layer_1/TransformerLayer/FFN/layer_prepostprocess/layer_norm/layer_norm_scale/ConcatPartitions/concat", - "op": "Const" - }, - { - "input": [], - "attr": { - "value": { - "tensor": { - "floatVal": [], - "doubleVal": [], - "intVal": [], - "stringVal": [], - "scomplexVal": [], - "int64Val": [], - "boolVal": [], - "uint32Val": [], - "uint64Val": [], - "dtype": 1, - "tensorShape": { - "dim": [ - { - "size": "512" - } - ] - } - } - }, - "dtype": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/Layer_1/TransformerLayer/FFN/layer_prepostprocess/layer_norm/layer_norm_bias/ConcatPartitions/concat", - "op": "Const" - }, - { - "input": [], - "attr": { - "value": { - "tensor": { - "floatVal": [], - "doubleVal": [], - "intVal": [], - "stringVal": [], - "scomplexVal": [], - "int64Val": [], - "boolVal": [], - "uint32Val": [], - "uint64Val": [], - "dtype": 1, - "tensorShape": { - "dim": [ - { - "size": "1536" - } - ] - } - } - }, - "dtype": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/Layer_1/TransformerLayer/FFN/conv1/bias/ConcatPartitions/concat", - "op": "Const" - }, - { - "input": [], - "attr": { - "value": { - "tensor": { - "floatVal": [], - "doubleVal": [], - "intVal": [], - "stringVal": [], - "scomplexVal": [], - "int64Val": [], - "boolVal": [], - "uint32Val": [], - "uint64Val": [], - "dtype": 1, - "tensorShape": { - "dim": [ - { - "size": "512" - } - ] - } - } - }, - "dtype": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/Layer_1/TransformerLayer/FFN/conv2/bias/ConcatPartitions/concat", - "op": "Const" - }, - { - "input": [], - "attr": { - "value": { - "tensor": { - "floatVal": [], - "doubleVal": [], - "intVal": [], - "stringVal": [], - "scomplexVal": [], - "int64Val": [], - "boolVal": [], - "uint32Val": [], - "uint64Val": [], - "dtype": 1, - "tensorShape": { - "dim": [] - } - } - }, - "dtype": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/mul/y", - "op": "Const" - }, - { - "input": [], - "attr": { - "value": { - "tensor": { - "floatVal": [], - "doubleVal": [], - "intVal": [], - "stringVal": [], - "scomplexVal": [], - "int64Val": [], - "boolVal": [], - "uint32Val": [], - "uint64Val": [], - "dtype": 1, - "tensorShape": { - "dim": [ - { - "size": "512" - } - ] - } - } - }, - "dtype": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/Layer_1/TransformerLayer/layer_prepostprocess/layer_norm/layer_norm_scale/ConcatPartitions/concat", - "op": "Const" - }, - { - "input": [], - "attr": { - "value": { - "tensor": { - "floatVal": [], - "doubleVal": [], - "intVal": [], - "stringVal": [], - "scomplexVal": [], - "int64Val": [], - "boolVal": [], - "uint32Val": [], - "uint64Val": [], - "dtype": 1, - "tensorShape": { - "dim": [ - { - "size": "512" - } - ] - } - } - }, - "dtype": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/Layer_1/TransformerLayer/layer_prepostprocess/layer_norm/layer_norm_bias/ConcatPartitions/concat", - "op": "Const" - }, - { - "input": [], - "attr": { - "value": { - "tensor": { - "floatVal": [], - "doubleVal": [], - "intVal": [], - "stringVal": [], - "scomplexVal": [], - "int64Val": [], - "boolVal": [], - "uint32Val": [], - "uint64Val": [], - "dtype": 1, - "tensorShape": { - "dim": [ - { - "size": "1" - }, - { - "size": "1" - }, - { - "size": "512" - }, - { - "size": "1536" - } - ] - } - } - }, - "dtype": { - "type": 1 - } - }, - "name": "module/Encoder_en/KonaTransformer/Encode/Layer_1/TransformerLayer/MultiheadAttention/qkv_transform_single/kernel/part_0", - "op": "Const" - }, - { - "input": [], - "attr": { - "value": { - "tensor": { - "floatVal": [], - "doubleVal": [], - "intVal": [], - "stringVal": [], - "scomplexVal": [], - "int64Val": [], - "boolVal": [], - "uint32Val": [], - "uint64Val": [], - "dtype": 1, - "tensorShape": { - "dim": [ - { - "size": "1536" - } - ] - } - } - }, - "dtype": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/Layer_1/TransformerLayer/MultiheadAttention/qkv_transform_single/bias/ConcatPartitions/concat", - "op": "Const" - }, - { - "input": [], - "attr": { - "value": { - "tensor": { - "floatVal": [], - "doubleVal": [], - "intVal": [], - "stringVal": [], - "scomplexVal": [], - "int64Val": [], - "boolVal": [], - "uint32Val": [], - "uint64Val": [], - "dtype": 3, - "tensorShape": { - "dim": [ - { - "size": "3" - } - ] - } - } - }, - "dtype": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/Const", - "op": "Const" - }, - { - "input": [], - "attr": { - "value": { - "tensor": { - "floatVal": [], - "doubleVal": [], - "intVal": [], - "stringVal": [], - "scomplexVal": [], - "int64Val": [], - "boolVal": [], - "uint32Val": [], - "uint64Val": [], - "dtype": 3, - "tensorShape": { - "dim": [] - } - } - }, - "dtype": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/split_heads/split_last_dimension/Reshape/shape/3", - "op": "Const" - }, - { - "input": [], - "attr": { - "value": { - "tensor": { - "floatVal": [], - "doubleVal": [], - "intVal": [], - "stringVal": [], - "scomplexVal": [], - "int64Val": [], - "boolVal": [], - "uint32Val": [], - "uint64Val": [], - "dtype": 3, - "tensorShape": { - "dim": [] - } - } - }, - "dtype": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/combine_heads/combine_last_two_dimensions/Reshape/shape/2", - "op": "Const" - }, - { - "input": [], - "attr": { - "value": { - "tensor": { - "floatVal": [], - "doubleVal": [], - "intVal": [], - "stringVal": [], - "scomplexVal": [], - "int64Val": [], - "boolVal": [], - "uint32Val": [], - "uint64Val": [], - "dtype": 1, - "tensorShape": { - "dim": [ - { - "size": "1" - }, - { - "size": "1" - }, - { - "size": "512" - }, - { - "size": "512" - } - ] - } - } - }, - "dtype": { - "type": 1 - } - }, - "name": "module/Encoder_en/KonaTransformer/Encode/Layer_1/TransformerLayer/MultiheadAttention/output_transform_single/kernel/part_0", - "op": "Const" - }, - { - "input": [], - "attr": { - "value": { - "tensor": { - "floatVal": [], - "doubleVal": [], - "intVal": [], - "stringVal": [], - "scomplexVal": [], - "int64Val": [], - "boolVal": [], - "uint32Val": [], - "uint64Val": [], - "dtype": 1, - "tensorShape": { - "dim": [ - { - "size": "512" - } - ] - } - } - }, - "dtype": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/Layer_1/TransformerLayer/MultiheadAttention/output_transform_single/bias/ConcatPartitions/concat", - "op": "Const" - }, - { - "input": [], - "attr": { - "value": { - "tensor": { - "floatVal": [], - "doubleVal": [], - "intVal": [], - "stringVal": [], - "scomplexVal": [], - "int64Val": [], - "boolVal": [], - "uint32Val": [], - "uint64Val": [], - "dtype": 1, - "tensorShape": { - "dim": [ - { - "size": "1536" - }, - { - "size": "512" - } - ] - } - } - }, - "dtype": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/conv2/Tensordot/Reshape_1", - "op": "Const" - }, - { - "input": [], - "attr": { - "value": { - "tensor": { - "floatVal": [], - "doubleVal": [], - "intVal": [], - "stringVal": [], - "scomplexVal": [], - "int64Val": [], - "boolVal": [], - "uint32Val": [], - "uint64Val": [], - "dtype": 1, - "tensorShape": { - "dim": [ - { - "size": "512" - }, - { - "size": "1536" - } - ] - } - } - }, - "dtype": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/conv1/Tensordot/Reshape_1", - "op": "Const" - }, - { - "input": [], - "attr": { - "value": { - "tensor": { - "floatVal": [], - "doubleVal": [], - "intVal": [], - "stringVal": [], - "scomplexVal": [], - "int64Val": [], - "boolVal": [], - "uint32Val": [], - "uint64Val": [], - "dtype": 1, - "tensorShape": { - "dim": [ - { - "size": "512" - } - ] - } - } - }, - "dtype": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/Layer_0/TransformerLayer/FFN/layer_prepostprocess/layer_norm/layer_norm_scale/ConcatPartitions/concat", - "op": "Const" - }, - { - "input": [], - "attr": { - "value": { - "tensor": { - "floatVal": [], - "doubleVal": [], - "intVal": [], - "stringVal": [], - "scomplexVal": [], - "int64Val": [], - "boolVal": [], - "uint32Val": [], - "uint64Val": [], - "dtype": 1, - "tensorShape": { - "dim": [ - { - "size": "512" - } - ] - } - } - }, - "dtype": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/Layer_0/TransformerLayer/FFN/layer_prepostprocess/layer_norm/layer_norm_bias/ConcatPartitions/concat", - "op": "Const" - }, - { - "input": [], - "attr": { - "value": { - "tensor": { - "floatVal": [], - "doubleVal": [], - "intVal": [], - "stringVal": [], - "scomplexVal": [], - "int64Val": [], - "boolVal": [], - "uint32Val": [], - "uint64Val": [], - "dtype": 3, - "tensorShape": { - "dim": [ - { - "size": "1" - } - ] - } - } - }, - "dtype": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv1/Tensordot/Const_2", - "op": "Const" - }, - { - "input": [], - "attr": { - "value": { - "tensor": { - "floatVal": [], - "doubleVal": [], - "intVal": [], - "stringVal": [], - "scomplexVal": [], - "int64Val": [], - "boolVal": [], - "uint32Val": [], - "uint64Val": [], - "dtype": 1, - "tensorShape": { - "dim": [ - { - "size": "1536" - } - ] - } - } - }, - "dtype": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/Layer_0/TransformerLayer/FFN/conv1/bias/ConcatPartitions/concat", - "op": "Const" - }, - { - "input": [], - "attr": { - "value": { - "tensor": { - "floatVal": [], - "doubleVal": [], - "intVal": [], - "stringVal": [], - "scomplexVal": [], - "int64Val": [], - "boolVal": [], - "uint32Val": [], - "uint64Val": [], - "dtype": 3, - "tensorShape": { - "dim": [ - { - "size": "1" - } - ] - } - } - }, - "dtype": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv2/Tensordot/Const_2", - "op": "Const" - }, - { - "input": [], - "attr": { - "value": { - "tensor": { - "floatVal": [], - "doubleVal": [], - "intVal": [], - "stringVal": [], - "scomplexVal": [], - "int64Val": [], - "boolVal": [], - "uint32Val": [], - "uint64Val": [], - "dtype": 1, - "tensorShape": { - "dim": [ - { - "size": "512" - } - ] - } - } - }, - "dtype": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/Layer_0/TransformerLayer/FFN/conv2/bias/ConcatPartitions/concat", - "op": "Const" - }, - { - "input": [], - "attr": { - "value": { - "tensor": { - "floatVal": [], - "doubleVal": [], - "intVal": [], - "stringVal": [], - "scomplexVal": [], - "int64Val": [], - "boolVal": [], - "uint32Val": [], - "uint64Val": [], - "dtype": 3, - "tensorShape": { - "dim": [ - { - "size": "1" - } - ] - } - } - }, - "dtype": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/DotProductAttention/BaseDotProductAttention/Slice/begin", - "op": "Const" - }, - { - "input": [], - "attr": { - "value": { - "tensor": { - "floatVal": [], - "doubleVal": [], - "intVal": [], - "stringVal": [], - "scomplexVal": [], - "int64Val": [], - "boolVal": [], - "uint32Val": [], - "uint64Val": [], - "dtype": 1, - "tensorShape": { - "dim": [] - } - } - }, - "dtype": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/mul/y", - "op": "Const" - }, - { - "input": [], - "attr": { - "dtype": { - "type": 1 - }, - "value": { - "tensor": { - "floatVal": [], - "doubleVal": [], - "intVal": [], - "stringVal": [], - "scomplexVal": [], - "int64Val": [], - "boolVal": [], - "uint32Val": [], - "uint64Val": [], - "dtype": 1, - "tensorShape": { - "dim": [] - } - } - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/DotProductAttention/attention_bias_ignore_padding/mul/y", - "op": "Const" - }, - { - "input": [], - "attr": { - "value": { - "tensor": { - "floatVal": [], - "doubleVal": [], - "intVal": [], - "stringVal": [], - "scomplexVal": [], - "int64Val": [], - "boolVal": [], - "uint32Val": [], - "uint64Val": [], - "dtype": 1, - "tensorShape": { - "dim": [ - { - "size": "256" - } - ] - } - } - }, - "dtype": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/Layer_0/TransformerLayer/layer_prepostprocess/layer_norm/layer_norm_scale/ConcatPartitions/concat", - "op": "Const" - }, - { - "input": [], - "attr": { - "value": { - "tensor": { - "floatVal": [], - "doubleVal": [], - "intVal": [], - "stringVal": [], - "scomplexVal": [], - "int64Val": [], - "boolVal": [], - "uint32Val": [], - "uint64Val": [], - "dtype": 1, - "tensorShape": { - "dim": [] - } - } - }, - "dtype": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/layer_prepostprocess/layer_norm/Cast/x", - "op": "Const" - }, - { - "input": [], - "attr": { - "dtype": { - "type": 1 - }, - "value": { - "tensor": { - "floatVal": [], - "doubleVal": [], - "intVal": [], - "stringVal": [], - "scomplexVal": [], - "int64Val": [], - "boolVal": [], - "uint32Val": [], - "uint64Val": [], - "dtype": 1, - "tensorShape": { - "dim": [ - { - "size": "256" - } - ] - } - } - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/Layer_0/TransformerLayer/layer_prepostprocess/layer_norm/layer_norm_bias/ConcatPartitions/concat", - "op": "Const" - }, - { - "input": [], - "attr": { - "value": { - "tensor": { - "floatVal": [], - "doubleVal": [], - "intVal": [], - "stringVal": [], - "scomplexVal": [], - "int64Val": [], - "boolVal": [], - "uint32Val": [], - "uint64Val": [], - "dtype": 1, - "tensorShape": { - "dim": [ - { - "size": "1" - }, - { - "size": "1" - }, - { - "size": "256" - }, - { - "size": "768" - } - ] - } - } - }, - "dtype": { - "type": 1 - } - }, - "name": "module/Encoder_en/KonaTransformer/Encode/Layer_0/TransformerLayer/MultiheadAttention/qkv_transform_single/kernel/part_0", - "op": "Const" - }, - { - "input": [], - "attr": { - "value": { - "tensor": { - "floatVal": [], - "doubleVal": [], - "intVal": [], - "stringVal": [], - "scomplexVal": [], - "int64Val": [], - "boolVal": [], - "uint32Val": [], - "uint64Val": [], - "dtype": 1, - "tensorShape": { - "dim": [ - { - "size": "768" - } - ] - } - } - }, - "dtype": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/Layer_0/TransformerLayer/MultiheadAttention/qkv_transform_single/bias/ConcatPartitions/concat", - "op": "Const" - }, - { - "input": [], - "attr": { - "value": { - "tensor": { - "floatVal": [], - "doubleVal": [], - "intVal": [], - "stringVal": [], - "scomplexVal": [], - "int64Val": [], - "boolVal": [], - "uint32Val": [], - "uint64Val": [], - "dtype": 3, - "tensorShape": { - "dim": [ - { - "size": "3" - } - ] - } - } - }, - "dtype": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/Const", - "op": "Const" - }, - { - "input": [], - "attr": { - "value": { - "tensor": { - "floatVal": [], - "doubleVal": [], - "intVal": [], - "stringVal": [], - "scomplexVal": [], - "int64Val": [], - "boolVal": [], - "uint32Val": [], - "uint64Val": [], - "dtype": 3, - "tensorShape": { - "dim": [] - } - } - }, - "dtype": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/split_heads/split_last_dimension/Reshape/shape/2", - "op": "Const" - }, - { - "input": [], - "attr": { - "value": { - "tensor": { - "floatVal": [], - "doubleVal": [], - "intVal": [], - "stringVal": [], - "scomplexVal": [], - "int64Val": [], - "boolVal": [], - "uint32Val": [], - "uint64Val": [], - "dtype": 3, - "tensorShape": { - "dim": [] - } - } - }, - "dtype": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/split_heads/split_last_dimension/Reshape/shape/3", - "op": "Const" - }, - { - "input": [], - "attr": { - "value": { - "tensor": { - "floatVal": [], - "doubleVal": [], - "intVal": [], - "stringVal": [], - "scomplexVal": [], - "int64Val": [], - "boolVal": [], - "uint32Val": [], - "uint64Val": [], - "dtype": 3, - "tensorShape": { - "dim": [ - { - "size": "4" - } - ] - } - } - }, - "dtype": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/split_heads/transpose/perm", - "op": "Const" - }, - { - "input": [], - "attr": { - "value": { - "tensor": { - "floatVal": [], - "doubleVal": [], - "intVal": [], - "stringVal": [], - "scomplexVal": [], - "int64Val": [], - "boolVal": [], - "uint32Val": [], - "uint64Val": [], - "dtype": 3, - "tensorShape": { - "dim": [] - } - } - }, - "dtype": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/combine_heads/combine_last_two_dimensions/Reshape/shape/2", - "op": "Const" - }, - { - "input": [], - "attr": { - "value": { - "tensor": { - "floatVal": [], - "doubleVal": [], - "intVal": [], - "stringVal": [], - "scomplexVal": [], - "int64Val": [], - "boolVal": [], - "uint32Val": [], - "uint64Val": [], - "dtype": 1, - "tensorShape": { - "dim": [ - { - "size": "1" - }, - { - "size": "1" - }, - { - "size": "256" - }, - { - "size": "512" - } - ] - } - } - }, - "dtype": { - "type": 1 - } - }, - "name": "module/Encoder_en/KonaTransformer/Encode/Layer_0/TransformerLayer/MultiheadAttention/output_transform_single/kernel/part_0", - "op": "Const" - }, - { - "input": [], - "attr": { - "value": { - "tensor": { - "floatVal": [], - "doubleVal": [], - "intVal": [], - "stringVal": [], - "scomplexVal": [], - "int64Val": [], - "boolVal": [], - "uint32Val": [], - "uint64Val": [], - "dtype": 1, - "tensorShape": { - "dim": [ - { - "size": "512" - } - ] - } - } - }, - "dtype": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/Layer_0/TransformerLayer/MultiheadAttention/output_transform_single/bias/ConcatPartitions/concat", - "op": "Const" - }, - { - "input": [], - "attr": { - "value": { - "tensor": { - "floatVal": [], - "doubleVal": [], - "intVal": [], - "stringVal": [], - "scomplexVal": [], - "int64Val": [], - "boolVal": [], - "uint32Val": [], - "uint64Val": [], - "dtype": 1, - "tensorShape": { - "dim": [ - { - "size": "8002" - }, - { - "size": "256" - } - ] - } - } - }, - "dtype": { - "type": 1 - } - }, - "name": "module/Embeddings_en", - "op": "Const" - }, - { - "input": [], - "attr": { - "value": { - "tensor": { - "floatVal": [], - "doubleVal": [], - "intVal": [], - "stringVal": [], - "scomplexVal": [], - "int64Val": [], - "boolVal": [], - "uint32Val": [], - "uint64Val": [], - "dtype": 1, - "tensorShape": { - "dim": [ - { - "size": "1" - }, - { - "size": "128" - } - ] - } - } - }, - "dtype": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/AddTimingSignal/TimingSignal/ExpandDims_1", - "op": "Const" - }, - { - "input": [], - "attr": { - "value": { - "tensor": { - "floatVal": [], - "doubleVal": [], - "intVal": [], - "stringVal": [], - "scomplexVal": [], - "int64Val": [], - "boolVal": [], - "uint32Val": [], - "uint64Val": [], - "dtype": 1, - "tensorShape": { - "dim": [ - { - "size": "256" - }, - { - "size": "512" - } - ] - } - } - }, - "dtype": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/Layer_0/TransformerLayer/dense/kernel/ConcatPartitions/concat", - "op": "Const" - }, - { - "input": [], - "attr": { - "value": { - "tensor": { - "floatVal": [], - "doubleVal": [], - "intVal": [], - "stringVal": [], - "scomplexVal": [], - "int64Val": [], - "boolVal": [], - "uint32Val": [], - "uint64Val": [], - "dtype": 1, - "tensorShape": { - "dim": [ - { - "size": "512" - } - ] - } - } - }, - "dtype": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/Layer_0/TransformerLayer/dense/bias/ConcatPartitions/concat", - "op": "Const" - }, - { - "input": [], - "attr": { - "value": { - "tensor": { - "floatVal": [], - "doubleVal": [], - "intVal": [], - "stringVal": [], - "scomplexVal": [], - "int64Val": [], - "boolVal": [], - "uint32Val": [], - "uint64Val": [], - "dtype": 3, - "tensorShape": { - "dim": [ - { - "size": "1" - } - ] - } - } - }, - "dtype": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv2/Tensordot/Const", - "op": "Const" - }, - { - "input": [], - "attr": { - "value": { - "tensor": { - "floatVal": [], - "doubleVal": [], - "intVal": [], - "stringVal": [], - "scomplexVal": [], - "int64Val": [], - "boolVal": [], - "uint32Val": [], - "uint64Val": [], - "dtype": 3, - "tensorShape": { - "dim": [ - { - "size": "1" - } - ] - } - } - }, - "dtype": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv1/Tensordot/add_1", - "op": "Const" - }, - { - "input": [], - "attr": { - "value": { - "tensor": { - "floatVal": [], - "doubleVal": [], - "intVal": [], - "stringVal": [], - "scomplexVal": [], - "int64Val": [], - "boolVal": [], - "uint32Val": [], - "uint64Val": [], - "dtype": 3, - "tensorShape": { - "dim": [ - { - "size": "1" - } - ] - } - } - }, - "dtype": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/Scatter/strided_slice/stack", - "op": "Const" - }, - { - "input": [], - "attr": { - "value": { - "tensor": { - "floatVal": [], - "doubleVal": [], - "intVal": [], - "stringVal": [], - "scomplexVal": [], - "int64Val": [], - "boolVal": [], - "uint32Val": [], - "uint64Val": [], - "dtype": 3, - "tensorShape": { - "dim": [] - } - } - }, - "dtype": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/SequenceMask/ExpandDims/dim", - "op": "Const" - }, - { - "input": [], - "attr": { - "value": { - "tensor": { - "floatVal": [], - "doubleVal": [], - "intVal": [], - "stringVal": [], - "scomplexVal": [], - "int64Val": [], - "boolVal": [], - "uint32Val": [], - "uint64Val": [], - "dtype": 3, - "tensorShape": { - "dim": [] - } - } - }, - "dtype": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/ExpandDims/dim", - "op": "Const" - }, - { - "input": [], - "attr": { - "value": { - "tensor": { - "floatVal": [], - "doubleVal": [], - "intVal": [], - "stringVal": [], - "scomplexVal": [], - "int64Val": [], - "boolVal": [], - "uint32Val": [], - "uint64Val": [], - "dtype": 9, - "tensorShape": { - "dim": [] - } - } - }, - "dtype": { - "type": 9 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/ClipToMaxLength/Const", - "op": "Const" - }, - { - "input": [], - "attr": { - "value": { - "tensor": { - "floatVal": [], - "doubleVal": [], - "intVal": [], - "stringVal": [], - "scomplexVal": [], - "int64Val": [], - "boolVal": [], - "uint32Val": [], - "uint64Val": [], - "dtype": 9, - "tensorShape": { - "dim": [ - { - "size": "2" - } - ] - } - } - }, - "dtype": { - "type": 9 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/ClipToMaxLength/ones_like", - "op": "Const" - }, - { - "input": [], - "attr": { - "dtype": { - "type": 9 - }, - "shape": { - "shape": { - "dim": [ - { - "size": "-1" - }, - { - "size": "2" - } - ] - } - } - }, - "name": "indices", - "op": "Placeholder" - }, - { - "input": [], - "attr": { - "value": { - "tensor": { - "floatVal": [], - "doubleVal": [], - "intVal": [], - "stringVal": [], - "scomplexVal": [], - "int64Val": [], - "boolVal": [], - "uint32Val": [], - "uint64Val": [], - "dtype": 3, - "tensorShape": { - "dim": [ - { - "size": "2" - } - ] - } - } - }, - "dtype": { - "type": 3 - } - }, - "name": "ConstantFolding/module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv1/Tensordot/ListDiff-folded-0", - "op": "Const" - }, - { - "input": [], - "attr": { - "value": { - "tensor": { - "floatVal": [], - "doubleVal": [], - "intVal": [], - "stringVal": [], - "scomplexVal": [], - "int64Val": [], - "boolVal": [], - "uint32Val": [], - "uint64Val": [], - "dtype": 3, - "tensorShape": { - "dim": [ - { - "size": "2" - } - ] - } - } - }, - "dtype": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/AddTimingSignal/strided_slice_2/stack_1", - "op": "Const" - }, - { - "input": [], - "attr": { - "value": { - "tensor": { - "floatVal": [], - "doubleVal": [], - "intVal": [], - "stringVal": [], - "scomplexVal": [], - "int64Val": [], - "boolVal": [], - "uint32Val": [], - "uint64Val": [], - "dtype": 3, - "tensorShape": { - "dim": [ - { - "size": "2" - } - ] - } - } - }, - "dtype": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/AddTimingSignal/strided_slice_2/stack_2", - "op": "Const" - }, - { - "input": [], - "attr": { - "value": { - "tensor": { - "floatVal": [], - "doubleVal": [], - "intVal": [], - "stringVal": [], - "scomplexVal": [], - "int64Val": [], - "boolVal": [], - "uint32Val": [], - "uint64Val": [], - "dtype": 9, - "tensorShape": { - "dim": [] - } - } - }, - "dtype": { - "type": 9 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/ClipToMaxLength/Less/y", - "op": "Const" - }, - { - "input": [], - "attr": { - "value": { - "tensor": { - "floatVal": [], - "doubleVal": [], - "intVal": [], - "stringVal": [], - "scomplexVal": [], - "int64Val": [], - "boolVal": [], - "uint32Val": [], - "uint64Val": [], - "dtype": 3, - "tensorShape": { - "dim": [ - { - "size": "1" - } - ] - } - } - }, - "dtype": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/layer_prepostprocess/layer_norm/Mean/reduction_indices", - "op": "Const" - }, - { - "input": [], - "attr": { - "value": { - "tensor": { - "floatVal": [], - "doubleVal": [], - "intVal": [], - "stringVal": [], - "scomplexVal": [], - "int64Val": [], - "boolVal": [], - "uint32Val": [], - "uint64Val": [], - "dtype": 3, - "tensorShape": { - "dim": [] - } - } - }, - "dtype": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/SequenceMask/Const", - "op": "Const" - }, - { - "input": [], - "attr": { - "dtype": { - "type": 9 - }, - "value": { - "tensor": { - "floatVal": [], - "doubleVal": [], - "intVal": [], - "stringVal": [], - "scomplexVal": [], - "int64Val": [], - "boolVal": [], - "uint32Val": [], - "uint64Val": [], - "dtype": 9, - "tensorShape": { - "dim": [] - } - } - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/SparseToDense/default_value", - "op": "Const" - }, - { - "input": [], - "attr": { - "value": { - "tensor": { - "floatVal": [], - "doubleVal": [], - "intVal": [], - "stringVal": [], - "scomplexVal": [], - "int64Val": [], - "boolVal": [], - "uint32Val": [], - "uint64Val": [], - "dtype": 1, - "tensorShape": { - "dim": [ - { - "size": "512" - }, - { - "size": "512" - } - ] - } - } - }, - "dtype": { - "type": 1 - } - }, - "name": "module/Encoder_en/hidden_layers/tanh_layer_0/weights", - "op": "Const" - }, - { - "input": [], - "attr": { - "value": { - "tensor": { - "floatVal": [], - "doubleVal": [], - "intVal": [], - "stringVal": [], - "scomplexVal": [], - "int64Val": [], - "boolVal": [], - "uint32Val": [], - "uint64Val": [], - "dtype": 1, - "tensorShape": { - "dim": [ - { - "size": "512" - } - ] - } - } - }, - "dtype": { - "type": 1 - } - }, - "name": "module/Encoder_en/hidden_layers/tanh_layer_0/bias", - "op": "Const" - }, - { - "input": [], - "attr": { - "value": { - "tensor": { - "floatVal": [], - "doubleVal": [], - "intVal": [], - "stringVal": [], - "scomplexVal": [], - "int64Val": [], - "boolVal": [], - "uint32Val": [], - "uint64Val": [], - "dtype": 3, - "tensorShape": { - "dim": [] - } - } - }, - "dtype": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/DotProductAttention/attention_bias_ignore_padding/ExpandDims/dim", - "op": "Const" - }, - { - "input": [], - "attr": { - "value": { - "tensor": { - "floatVal": [], - "doubleVal": [], - "intVal": [], - "stringVal": [], - "scomplexVal": [], - "int64Val": [], - "boolVal": [], - "uint32Val": [], - "uint64Val": [], - "dtype": 1, - "tensorShape": { - "dim": [] - } - } - }, - "dtype": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/hidden_layers/l2_normalize/Maximum/y", - "op": "Const" - }, - { - "input": [], - "attr": { - "shape": { - "shape": { - "dim": [ - { - "size": "-1" - } - ] - } - }, - "dtype": { - "type": 9 - } - }, - "name": "values", - "op": "Placeholder" - }, - { - "input": [ - "indices", - "ConstantFolding/module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv1/Tensordot/ListDiff-folded-0", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/AddTimingSignal/strided_slice_2/stack_1", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/AddTimingSignal/strided_slice_2/stack_2" - ], - "attr": { - "shrink_axis_mask": { - "i": "2" - }, - "begin_mask": { - "i": "1" - }, - "ellipsis_mask": { - "i": "0" - }, - "new_axis_mask": { - "i": "0" - }, - "end_mask": { - "i": "1" - }, - "Index": { - "type": 3 - }, - "T": { - "type": 9 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/ClipToMaxLength/strided_slice", - "op": "StridedSlice" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/ClipToMaxLength/strided_slice", - "module_apply_default/Encoder_en/KonaTransformer/ClipToMaxLength/Less/y" - ], - "attr": { - "T": { - "type": 9 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/ClipToMaxLength/Less", - "op": "Less" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/ClipToMaxLength/Less" - ], - "attr": { - "T": { - "type": 10 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/ClipToMaxLength/Where", - "op": "Where" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/ClipToMaxLength/Where", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/layer_prepostprocess/layer_norm/Mean/reduction_indices" - ], - "attr": { - "T": { - "type": 9 - }, - "Tshape": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/ClipToMaxLength/Reshape", - "op": "Reshape" - }, - { - "input": [ - "indices", - "module_apply_default/Encoder_en/KonaTransformer/ClipToMaxLength/Reshape", - "module_apply_default/Encoder_en/KonaTransformer/SequenceMask/Const" - ], - "attr": { - "Taxis": { - "type": 3 - }, - "Tindices": { - "type": 9 - }, - "Tparams": { - "type": 9 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/ClipToMaxLength/GatherV2", - "op": "GatherV2" - }, - { - "input": [ - "values", - "module_apply_default/Encoder_en/KonaTransformer/ClipToMaxLength/Reshape", - "module_apply_default/Encoder_en/KonaTransformer/SequenceMask/Const" - ], - "attr": { - "Tindices": { - "type": 9 - }, - "Tparams": { - "type": 9 - }, - "Taxis": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/ClipToMaxLength/GatherV2_1", - "op": "GatherV2" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/ClipToMaxLength/GatherV2", - "module_apply_default/Encoder_en/KonaTransformer/SequenceMask/Const" - ], - "attr": { - "Tidx": { - "type": 3 - }, - "keep_dims": { - "b": false - }, - "T": { - "type": 9 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/ClipToMaxLength/Max", - "op": "Max" - }, - { - "input": [ - "module/Embeddings_en", - "module_apply_default/Encoder_en/KonaTransformer/ClipToMaxLength/GatherV2_1", - "module_apply_default/Encoder_en/KonaTransformer/SequenceMask/Const" - ], - "attr": { - "Tindices": { - "type": 9 - }, - "Tparams": { - "type": 1 - }, - "Taxis": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/embedding_lookup", - "op": "GatherV2" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/ClipToMaxLength/Max", - "module_apply_default/Encoder_en/KonaTransformer/ClipToMaxLength/ones_like" - ], - "attr": { - "T": { - "type": 9 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/ClipToMaxLength/Add", - "op": "Add" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/embedding_lookup" - ], - "attr": { - "out_type": { - "type": 3 - }, - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/Scatter/Shape", - "op": "Shape" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/ClipToMaxLength/Const", - "module_apply_default/Encoder_en/KonaTransformer/ClipToMaxLength/Add" - ], - "attr": { - "T": { - "type": 9 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/ClipToMaxLength/Maximum", - "op": "Maximum" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/Scatter/Shape", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/Scatter/strided_slice/stack", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv2/Tensordot/Const", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/Scatter/strided_slice/stack" - ], - "attr": { - "shrink_axis_mask": { - "i": "0" - }, - "ellipsis_mask": { - "i": "0" - }, - "begin_mask": { - "i": "0" - }, - "new_axis_mask": { - "i": "0" - }, - "end_mask": { - "i": "1" - }, - "T": { - "type": 3 - }, - "Index": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/Scatter/strided_slice", - "op": "StridedSlice" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/ClipToMaxLength/GatherV2", - "module_apply_default/Encoder_en/KonaTransformer/ClipToMaxLength/Maximum", - "module_apply_default/Encoder_en/KonaTransformer/ClipToMaxLength/GatherV2_1", - "module_apply_default/Encoder_en/KonaTransformer/Encode/SparseToDense/default_value" - ], - "attr": { - "Tindices": { - "type": 9 - }, - "validate_indices": { - "b": true - }, - "T": { - "type": 9 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/SparseToDense", - "op": "SparseToDense" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/SparseToDense", - "module_apply_default/Encoder_en/KonaTransformer/Encode/SparseToDense/default_value" - ], - "attr": { - "T": { - "type": 9 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/Greater", - "op": "Greater" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/Greater" - ], - "attr": {}, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/DotProductAttention/LogicalNot", - "op": "LogicalNot" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/Greater" - ], - "attr": { - "T": { - "type": 10 - }, - "out_type": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/StoreMask/Shape", - "op": "Shape" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/Greater" - ], - "attr": { - "T": { - "type": 10 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/StoreMask/Where", - "op": "Where" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/Greater" - ], - "attr": { - "SrcT": { - "type": 10 - }, - "Truncate": { - "b": false - }, - "DstT": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/MaskLength/ToInt32", - "op": "Cast" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/DotProductAttention/LogicalNot" - ], - "attr": { - "DstT": { - "type": 1 - }, - "SrcT": { - "type": 10 - }, - "Truncate": { - "b": false - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/DotProductAttention/ToFloat", - "op": "Cast" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/StoreMask/Shape", - "module_apply_default/Encoder_en/KonaTransformer/Encode/Scatter/strided_slice", - "module_apply_default/Encoder_en/KonaTransformer/SequenceMask/Const" - ], - "attr": { - "N": { - "i": "2" - }, - "Tidx": { - "type": 3 - }, - "T": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/Scatter/concat", - "op": "ConcatV2" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/StoreMask/Where", - "ConstantFolding/module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv1/Tensordot/ListDiff-folded-0", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/AddTimingSignal/strided_slice_2/stack_1", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/AddTimingSignal/strided_slice_2/stack_2" - ], - "attr": { - "new_axis_mask": { - "i": "0" - }, - "end_mask": { - "i": "1" - }, - "T": { - "type": 9 - }, - "Index": { - "type": 3 - }, - "shrink_axis_mask": { - "i": "2" - }, - "begin_mask": { - "i": "1" - }, - "ellipsis_mask": { - "i": "0" - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/AddTimingSignal/strided_slice_2", - "op": "StridedSlice" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/StoreMask/Where" - ], - "attr": { - "Truncate": { - "b": false - }, - "DstT": { - "type": 3 - }, - "SrcT": { - "type": 9 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/StoreMask/ToInt32", - "op": "Cast" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/MaskLength/ToInt32", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/DotProductAttention/attention_bias_ignore_padding/ExpandDims/dim" - ], - "attr": { - "Tidx": { - "type": 3 - }, - "keep_dims": { - "b": false - }, - "T": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/MaskLength/Sum", - "op": "Sum" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/DotProductAttention/ToFloat", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/DotProductAttention/attention_bias_ignore_padding/mul/y" - ], - "attr": { - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/DotProductAttention/attention_bias_ignore_padding/mul", - "op": "Mul" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/AddTimingSignal/strided_slice_2" - ], - "attr": { - "SrcT": { - "type": 9 - }, - "Truncate": { - "b": false - }, - "DstT": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/AddTimingSignal/TimingSignal/ToFloat_2", - "op": "Cast" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/StoreMask/ToInt32", - "module_apply_default/Encoder_en/KonaTransformer/Encode/embedding_lookup", - "module_apply_default/Encoder_en/KonaTransformer/Encode/Scatter/concat" - ], - "attr": { - "T": { - "type": 1 - }, - "Tindices": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/Scatter/ScatterNd", - "op": "ScatterNd" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/MaskLength/Sum", - "module_apply_default/Encoder_en/KonaTransformer/SequenceMask/ExpandDims/dim" - ], - "attr": { - "Tdim": { - "type": 3 - }, - "T": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/SequenceMask/ExpandDims", - "op": "ExpandDims" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/MaskLength/Sum", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/DotProductAttention/attention_bias_ignore_padding/ExpandDims/dim" - ], - "attr": { - "T": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Maximum", - "op": "Maximum" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/DotProductAttention/attention_bias_ignore_padding/mul", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/DotProductAttention/attention_bias_ignore_padding/ExpandDims/dim" - ], - "attr": { - "Tdim": { - "type": 3 - }, - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/DotProductAttention/attention_bias_ignore_padding/ExpandDims", - "op": "ExpandDims" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/AddTimingSignal/TimingSignal/ToFloat_2", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/DotProductAttention/attention_bias_ignore_padding/ExpandDims/dim" - ], - "attr": { - "Tdim": { - "type": 3 - }, - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/AddTimingSignal/TimingSignal/ExpandDims", - "op": "ExpandDims" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/Scatter/ScatterNd", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/StoreMask/ToInt32" - ], - "attr": { - "Tindices": { - "type": 3 - }, - "Tparams": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/AddTimingSignal/Gather/GatherNd", - "op": "GatherNd" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Maximum" - ], - "attr": { - "SrcT": { - "type": 3 - }, - "Truncate": { - "b": false - }, - "DstT": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/ToFloat_1", - "op": "Cast" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/DotProductAttention/attention_bias_ignore_padding/ExpandDims", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/DotProductAttention/attention_bias_ignore_padding/ExpandDims/dim" - ], - "attr": { - "T": { - "type": 1 - }, - "Tdim": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/DotProductAttention/attention_bias_ignore_padding/ExpandDims_1", - "op": "ExpandDims" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/AddTimingSignal/TimingSignal/ExpandDims", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/AddTimingSignal/TimingSignal/ExpandDims_1" - ], - "attr": { - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/AddTimingSignal/TimingSignal/mul_2", - "op": "Mul" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/ToFloat_1", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/DotProductAttention/attention_bias_ignore_padding/ExpandDims/dim" - ], - "attr": { - "Tdim": { - "type": 3 - }, - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/ExpandDims_1", - "op": "ExpandDims" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/AddTimingSignal/TimingSignal/mul_2" - ], - "attr": { - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/AddTimingSignal/TimingSignal/Sin", - "op": "Sin" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/AddTimingSignal/TimingSignal/mul_2" - ], - "attr": { - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/AddTimingSignal/TimingSignal/Cos", - "op": "Cos" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/AddTimingSignal/TimingSignal/Sin", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/AddTimingSignal/TimingSignal/Cos", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/DotProductAttention/attention_bias_ignore_padding/ExpandDims/dim" - ], - "attr": { - "T": { - "type": 1 - }, - "N": { - "i": "2" - }, - "Tidx": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/AddTimingSignal/TimingSignal/concat", - "op": "ConcatV2" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/AddTimingSignal/Gather/GatherNd", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/AddTimingSignal/TimingSignal/concat" - ], - "attr": { - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/AddTimingSignal/add", - "op": "Add" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/AddTimingSignal/add" - ], - "attr": { - "T": { - "type": 1 - }, - "out_type": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/AddTimingSignal/Scatter/Shape", - "op": "Shape" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/AddTimingSignal/Scatter/Shape", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/Scatter/strided_slice/stack", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv2/Tensordot/Const", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/Scatter/strided_slice/stack" - ], - "attr": { - "Index": { - "type": 3 - }, - "T": { - "type": 3 - }, - "shrink_axis_mask": { - "i": "0" - }, - "begin_mask": { - "i": "0" - }, - "ellipsis_mask": { - "i": "0" - }, - "new_axis_mask": { - "i": "0" - }, - "end_mask": { - "i": "1" - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/AddTimingSignal/Scatter/strided_slice", - "op": "StridedSlice" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/StoreMask/Shape", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/AddTimingSignal/Scatter/strided_slice", - "module_apply_default/Encoder_en/KonaTransformer/SequenceMask/Const" - ], - "attr": { - "Tidx": { - "type": 3 - }, - "T": { - "type": 3 - }, - "N": { - "i": "2" - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/AddTimingSignal/Scatter/concat", - "op": "ConcatV2" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/StoreMask/ToInt32", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/AddTimingSignal/add", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/AddTimingSignal/Scatter/concat" - ], - "attr": { - "Tindices": { - "type": 3 - }, - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/AddTimingSignal/Scatter/ScatterNd", - "op": "ScatterNd" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/Scatter/ScatterNd", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/AddTimingSignal/Scatter/ScatterNd" - ], - "attr": { - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/add", - "op": "Add" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/add", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/layer_prepostprocess/layer_norm/Mean/reduction_indices" - ], - "attr": { - "T": { - "type": 1 - }, - "Tidx": { - "type": 3 - }, - "keep_dims": { - "b": true - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/layer_prepostprocess/layer_norm/Mean", - "op": "Mean" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/add", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/StoreMask/ToInt32" - ], - "attr": { - "Tindices": { - "type": 3 - }, - "Tparams": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/AdjustResidualInput/Gather/GatherNd", - "op": "GatherNd" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/add", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/layer_prepostprocess/layer_norm/Mean" - ], - "attr": { - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/layer_prepostprocess/layer_norm/sub_1", - "op": "Sub" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/AdjustResidualInput/Gather/GatherNd", - "module_apply_default/Encoder_en/KonaTransformer/Encode/Layer_0/TransformerLayer/dense/kernel/ConcatPartitions/concat" - ], - "attr": { - "transpose_b": { - "b": false - }, - "T": { - "type": 1 - }, - "transpose_a": { - "b": false - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/AdjustResidualInput/dense/MatMul", - "op": "MatMul" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/layer_prepostprocess/layer_norm/sub_1" - ], - "attr": { - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/layer_prepostprocess/layer_norm/Square", - "op": "Square" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/AdjustResidualInput/dense/MatMul", - "module_apply_default/Encoder_en/KonaTransformer/Encode/Layer_0/TransformerLayer/dense/bias/ConcatPartitions/concat" - ], - "attr": { - "T": { - "type": 1 - }, - "data_format": { - "s": [ - 78, - 72, - 87, - 67 - ] - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/AdjustResidualInput/dense/BiasAdd", - "op": "BiasAdd" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/layer_prepostprocess/layer_norm/Square", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/layer_prepostprocess/layer_norm/Mean/reduction_indices" - ], - "attr": { - "Tidx": { - "type": 3 - }, - "keep_dims": { - "b": true - }, - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/layer_prepostprocess/layer_norm/Mean_1", - "op": "Mean" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/AdjustResidualInput/dense/BiasAdd" - ], - "attr": { - "T": { - "type": 1 - }, - "out_type": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/AdjustResidualInput/Scatter/Shape", - "op": "Shape" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/layer_prepostprocess/layer_norm/Mean_1", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/layer_prepostprocess/layer_norm/Cast/x" - ], - "attr": { - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/layer_prepostprocess/layer_norm/add", - "op": "Add" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/AdjustResidualInput/Scatter/Shape", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/Scatter/strided_slice/stack", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv2/Tensordot/Const", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/Scatter/strided_slice/stack" - ], - "attr": { - "ellipsis_mask": { - "i": "0" - }, - "begin_mask": { - "i": "0" - }, - "new_axis_mask": { - "i": "0" - }, - "end_mask": { - "i": "1" - }, - "Index": { - "type": 3 - }, - "T": { - "type": 3 - }, - "shrink_axis_mask": { - "i": "0" - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/AdjustResidualInput/Scatter/strided_slice", - "op": "StridedSlice" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/layer_prepostprocess/layer_norm/add" - ], - "attr": { - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/layer_prepostprocess/layer_norm/Rsqrt", - "op": "Rsqrt" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/StoreMask/Shape", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/AdjustResidualInput/Scatter/strided_slice", - "module_apply_default/Encoder_en/KonaTransformer/SequenceMask/Const" - ], - "attr": { - "N": { - "i": "2" - }, - "Tidx": { - "type": 3 - }, - "T": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/AdjustResidualInput/Scatter/concat", - "op": "ConcatV2" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/Layer_0/TransformerLayer/layer_prepostprocess/layer_norm/layer_norm_scale/ConcatPartitions/concat", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/layer_prepostprocess/layer_norm/Rsqrt" - ], - "attr": { - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/layer_prepostprocess/layer_norm/mul", - "op": "Mul" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/StoreMask/ToInt32", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/AdjustResidualInput/dense/BiasAdd", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/AdjustResidualInput/Scatter/concat" - ], - "attr": { - "Tindices": { - "type": 3 - }, - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/AdjustResidualInput/Scatter/ScatterNd", - "op": "ScatterNd" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/layer_prepostprocess/layer_norm/mul", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/layer_prepostprocess/layer_norm/sub_1" - ], - "attr": { - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/layer_prepostprocess/layer_norm/mul_1", - "op": "Mul" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/layer_prepostprocess/layer_norm/mul_1", - "module_apply_default/Encoder_en/KonaTransformer/Encode/Layer_0/TransformerLayer/layer_prepostprocess/layer_norm/layer_norm_bias/ConcatPartitions/concat" - ], - "attr": { - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/layer_prepostprocess/layer_norm/add_1", - "op": "Add" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/layer_prepostprocess/layer_norm/add_1", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/ExpandDims/dim" - ], - "attr": { - "Tdim": { - "type": 3 - }, - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/ExpandDims", - "op": "ExpandDims" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/ExpandDims", - "module/Encoder_en/KonaTransformer/Encode/Layer_0/TransformerLayer/MultiheadAttention/qkv_transform_single/kernel/part_0" - ], - "attr": { - "dilations": { - "list": { - "s": [], - "i": [ - "1", - "1", - "1", - "1" - ], - "f": [], - "b": [], - "type": [], - "shape": [], - "tensor": [], - "func": [] - } - }, - "T": { - "type": 1 - }, - "strides": { - "list": { - "s": [], - "i": [ - "1", - "1", - "1", - "1" - ], - "f": [], - "b": [], - "type": [], - "shape": [], - "tensor": [], - "func": [] - } - }, - "data_format": { - "s": [ - 78, - 72, - 87, - 67 - ] - }, - "use_cudnn_on_gpu": { - "b": true - }, - "padding": { - "s": [ - 86, - 65, - 76, - 73, - 68 - ] - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/qkv_transform_single/Conv2D", - "op": "Conv2D" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/qkv_transform_single/Conv2D", - "module_apply_default/Encoder_en/KonaTransformer/Encode/Layer_0/TransformerLayer/MultiheadAttention/qkv_transform_single/bias/ConcatPartitions/concat" - ], - "attr": { - "T": { - "type": 1 - }, - "data_format": { - "s": [ - 78, - 72, - 87, - 67 - ] - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/qkv_transform_single/BiasAdd", - "op": "BiasAdd" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/qkv_transform_single/BiasAdd" - ], - "attr": { - "squeeze_dims": { - "list": { - "s": [], - "i": [ - "2" - ], - "f": [], - "b": [], - "type": [], - "shape": [], - "tensor": [], - "func": [] - } - }, - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/Squeeze", - "op": "Squeeze" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/Squeeze", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/Const", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/ExpandDims/dim" - ], - "attr": { - "Tlen": { - "type": 3 - }, - "num_split": { - "i": "3" - }, - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/split", - "op": "SplitV" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/split" - ], - "attr": { - "out_type": { - "type": 3 - }, - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/split_heads/split_last_dimension/Shape", - "op": "Shape" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/split:1" - ], - "attr": { - "T": { - "type": 1 - }, - "out_type": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/split_heads_1/split_last_dimension/Shape", - "op": "Shape" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/split:2" - ], - "attr": { - "T": { - "type": 1 - }, - "out_type": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/split_heads_2/split_last_dimension/Shape", - "op": "Shape" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/split_heads/split_last_dimension/Shape", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv2/Tensordot/Const", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/Scatter/strided_slice/stack", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/Scatter/strided_slice/stack" - ], - "attr": { - "ellipsis_mask": { - "i": "0" - }, - "begin_mask": { - "i": "0" - }, - "new_axis_mask": { - "i": "0" - }, - "end_mask": { - "i": "0" - }, - "Index": { - "type": 3 - }, - "T": { - "type": 3 - }, - "shrink_axis_mask": { - "i": "1" - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/split_heads/split_last_dimension/strided_slice", - "op": "StridedSlice" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/split_heads/split_last_dimension/Shape", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/Scatter/strided_slice/stack", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv1/Tensordot/add_1", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/Scatter/strided_slice/stack" - ], - "attr": { - "Index": { - "type": 3 - }, - "T": { - "type": 3 - }, - "shrink_axis_mask": { - "i": "1" - }, - "ellipsis_mask": { - "i": "0" - }, - "begin_mask": { - "i": "0" - }, - "new_axis_mask": { - "i": "0" - }, - "end_mask": { - "i": "0" - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/split_heads/split_last_dimension/strided_slice_1", - "op": "StridedSlice" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/split_heads_1/split_last_dimension/Shape", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv2/Tensordot/Const", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/Scatter/strided_slice/stack", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/Scatter/strided_slice/stack" - ], - "attr": { - "begin_mask": { - "i": "0" - }, - "ellipsis_mask": { - "i": "0" - }, - "new_axis_mask": { - "i": "0" - }, - "end_mask": { - "i": "0" - }, - "Index": { - "type": 3 - }, - "T": { - "type": 3 - }, - "shrink_axis_mask": { - "i": "1" - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/split_heads_1/split_last_dimension/strided_slice", - "op": "StridedSlice" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/split_heads_1/split_last_dimension/Shape", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/Scatter/strided_slice/stack", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv1/Tensordot/add_1", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/Scatter/strided_slice/stack" - ], - "attr": { - "new_axis_mask": { - "i": "0" - }, - "end_mask": { - "i": "0" - }, - "T": { - "type": 3 - }, - "Index": { - "type": 3 - }, - "shrink_axis_mask": { - "i": "1" - }, - "ellipsis_mask": { - "i": "0" - }, - "begin_mask": { - "i": "0" - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/split_heads_1/split_last_dimension/strided_slice_1", - "op": "StridedSlice" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/split_heads_2/split_last_dimension/Shape", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv2/Tensordot/Const", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/Scatter/strided_slice/stack", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/Scatter/strided_slice/stack" - ], - "attr": { - "shrink_axis_mask": { - "i": "1" - }, - "begin_mask": { - "i": "0" - }, - "ellipsis_mask": { - "i": "0" - }, - "new_axis_mask": { - "i": "0" - }, - "end_mask": { - "i": "0" - }, - "T": { - "type": 3 - }, - "Index": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/split_heads_2/split_last_dimension/strided_slice", - "op": "StridedSlice" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/split_heads_2/split_last_dimension/Shape", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/Scatter/strided_slice/stack", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv1/Tensordot/add_1", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/Scatter/strided_slice/stack" - ], - "attr": { - "Index": { - "type": 3 - }, - "T": { - "type": 3 - }, - "shrink_axis_mask": { - "i": "1" - }, - "begin_mask": { - "i": "0" - }, - "ellipsis_mask": { - "i": "0" - }, - "new_axis_mask": { - "i": "0" - }, - "end_mask": { - "i": "0" - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/split_heads_2/split_last_dimension/strided_slice_1", - "op": "StridedSlice" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/split_heads/split_last_dimension/strided_slice", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/split_heads/split_last_dimension/strided_slice_1", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/split_heads/split_last_dimension/Reshape/shape/2", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/split_heads/split_last_dimension/Reshape/shape/3" - ], - "attr": { - "T": { - "type": 3 - }, - "axis": { - "i": "0" - }, - "N": { - "i": "4" - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/split_heads/split_last_dimension/Reshape/shape", - "op": "Pack" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/split_heads_1/split_last_dimension/strided_slice", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/split_heads_1/split_last_dimension/strided_slice_1", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/split_heads/split_last_dimension/Reshape/shape/2", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/split_heads/split_last_dimension/Reshape/shape/3" - ], - "attr": { - "axis": { - "i": "0" - }, - "N": { - "i": "4" - }, - "T": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/split_heads_1/split_last_dimension/Reshape/shape", - "op": "Pack" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/split_heads_2/split_last_dimension/strided_slice", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/split_heads_2/split_last_dimension/strided_slice_1", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/split_heads/split_last_dimension/Reshape/shape/2", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/split_heads/split_last_dimension/Reshape/shape/3" - ], - "attr": { - "T": { - "type": 3 - }, - "axis": { - "i": "0" - }, - "N": { - "i": "4" - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/split_heads_2/split_last_dimension/Reshape/shape", - "op": "Pack" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/split", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/split_heads/split_last_dimension/Reshape/shape" - ], - "attr": { - "T": { - "type": 1 - }, - "Tshape": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/split_heads/split_last_dimension/Reshape", - "op": "Reshape" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/split:1", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/split_heads_1/split_last_dimension/Reshape/shape" - ], - "attr": { - "T": { - "type": 1 - }, - "Tshape": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/split_heads_1/split_last_dimension/Reshape", - "op": "Reshape" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/split:2", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/split_heads_2/split_last_dimension/Reshape/shape" - ], - "attr": { - "T": { - "type": 1 - }, - "Tshape": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/split_heads_2/split_last_dimension/Reshape", - "op": "Reshape" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/split_heads/split_last_dimension/Reshape", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/split_heads/transpose/perm" - ], - "attr": { - "T": { - "type": 1 - }, - "Tperm": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/split_heads/transpose", - "op": "Transpose" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/split_heads_1/split_last_dimension/Reshape", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/split_heads/transpose/perm" - ], - "attr": { - "T": { - "type": 1 - }, - "Tperm": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/split_heads_1/transpose", - "op": "Transpose" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/split_heads_2/split_last_dimension/Reshape", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/split_heads/transpose/perm" - ], - "attr": { - "T": { - "type": 1 - }, - "Tperm": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/split_heads_2/transpose", - "op": "Transpose" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/split_heads/transpose", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/mul/y" - ], - "attr": { - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/mul", - "op": "Mul" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/mul", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/split_heads_1/transpose" - ], - "attr": { - "T": { - "type": 1 - }, - "adj_x": { - "b": false - }, - "adj_y": { - "b": true - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/DotProductAttention/BaseDotProductAttention/MatMul", - "op": "BatchMatMul" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/DotProductAttention/BaseDotProductAttention/MatMul", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/DotProductAttention/attention_bias_ignore_padding/ExpandDims_1" - ], - "attr": { - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/DotProductAttention/BaseDotProductAttention/add", - "op": "Add" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/DotProductAttention/BaseDotProductAttention/add" - ], - "attr": { - "T": { - "type": 1 - }, - "out_type": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/DotProductAttention/BaseDotProductAttention/Shape_1", - "op": "Shape" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/DotProductAttention/BaseDotProductAttention/Shape_1", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/DotProductAttention/BaseDotProductAttention/Slice/begin", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/Scatter/strided_slice/stack" - ], - "attr": { - "T": { - "type": 3 - }, - "Index": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/DotProductAttention/BaseDotProductAttention/Slice", - "op": "Slice" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/layer_prepostprocess/layer_norm/Mean/reduction_indices", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/DotProductAttention/BaseDotProductAttention/Slice", - "module_apply_default/Encoder_en/KonaTransformer/SequenceMask/Const" - ], - "attr": { - "N": { - "i": "2" - }, - "Tidx": { - "type": 3 - }, - "T": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/DotProductAttention/BaseDotProductAttention/concat", - "op": "ConcatV2" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/DotProductAttention/BaseDotProductAttention/add", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/DotProductAttention/BaseDotProductAttention/concat" - ], - "attr": { - "T": { - "type": 1 - }, - "Tshape": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/DotProductAttention/BaseDotProductAttention/Reshape", - "op": "Reshape" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/DotProductAttention/BaseDotProductAttention/Reshape" - ], - "attr": { - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/DotProductAttention/BaseDotProductAttention/Softmax", - "op": "Softmax" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/DotProductAttention/BaseDotProductAttention/Softmax", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/DotProductAttention/BaseDotProductAttention/Shape_1" - ], - "attr": { - "T": { - "type": 1 - }, - "Tshape": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/DotProductAttention/BaseDotProductAttention/attention_weights", - "op": "Reshape" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/DotProductAttention/BaseDotProductAttention/attention_weights", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/split_heads_2/transpose" - ], - "attr": { - "adj_x": { - "b": false - }, - "adj_y": { - "b": false - }, - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/DotProductAttention/BaseDotProductAttention/MatMul_1", - "op": "BatchMatMul" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/DotProductAttention/BaseDotProductAttention/MatMul_1", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/split_heads/transpose/perm" - ], - "attr": { - "T": { - "type": 1 - }, - "Tperm": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/combine_heads/transpose", - "op": "Transpose" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/combine_heads/transpose" - ], - "attr": { - "out_type": { - "type": 3 - }, - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/combine_heads/combine_last_two_dimensions/Shape", - "op": "Shape" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/combine_heads/combine_last_two_dimensions/Shape", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv2/Tensordot/Const", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/Scatter/strided_slice/stack", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/Scatter/strided_slice/stack" - ], - "attr": { - "end_mask": { - "i": "0" - }, - "T": { - "type": 3 - }, - "Index": { - "type": 3 - }, - "shrink_axis_mask": { - "i": "1" - }, - "begin_mask": { - "i": "0" - }, - "ellipsis_mask": { - "i": "0" - }, - "new_axis_mask": { - "i": "0" - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/combine_heads/combine_last_two_dimensions/strided_slice", - "op": "StridedSlice" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/combine_heads/combine_last_two_dimensions/Shape", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/Scatter/strided_slice/stack", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv1/Tensordot/add_1", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/Scatter/strided_slice/stack" - ], - "attr": { - "shrink_axis_mask": { - "i": "1" - }, - "begin_mask": { - "i": "0" - }, - "ellipsis_mask": { - "i": "0" - }, - "new_axis_mask": { - "i": "0" - }, - "end_mask": { - "i": "0" - }, - "Index": { - "type": 3 - }, - "T": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/combine_heads/combine_last_two_dimensions/strided_slice_1", - "op": "StridedSlice" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/combine_heads/combine_last_two_dimensions/strided_slice", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/combine_heads/combine_last_two_dimensions/strided_slice_1", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/combine_heads/combine_last_two_dimensions/Reshape/shape/2" - ], - "attr": { - "N": { - "i": "3" - }, - "T": { - "type": 3 - }, - "axis": { - "i": "0" - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/combine_heads/combine_last_two_dimensions/Reshape/shape", - "op": "Pack" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/combine_heads/transpose", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/combine_heads/combine_last_two_dimensions/Reshape/shape" - ], - "attr": { - "T": { - "type": 1 - }, - "Tshape": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/combine_heads/combine_last_two_dimensions/Reshape", - "op": "Reshape" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/combine_heads/combine_last_two_dimensions/Reshape", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/ExpandDims/dim" - ], - "attr": { - "Tdim": { - "type": 3 - }, - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/ExpandDims_1", - "op": "ExpandDims" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/ExpandDims_1", - "module/Encoder_en/KonaTransformer/Encode/Layer_0/TransformerLayer/MultiheadAttention/output_transform_single/kernel/part_0" - ], - "attr": { - "padding": { - "s": [ - 86, - 65, - 76, - 73, - 68 - ] - }, - "dilations": { - "list": { - "s": [], - "i": [ - "1", - "1", - "1", - "1" - ], - "f": [], - "b": [], - "type": [], - "shape": [], - "tensor": [], - "func": [] - } - }, - "T": { - "type": 1 - }, - "strides": { - "list": { - "s": [], - "i": [ - "1", - "1", - "1", - "1" - ], - "f": [], - "b": [], - "type": [], - "shape": [], - "tensor": [], - "func": [] - } - }, - "data_format": { - "s": [ - 78, - 72, - 87, - 67 - ] - }, - "use_cudnn_on_gpu": { - "b": true - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/output_transform_single/Conv2D", - "op": "Conv2D" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/output_transform_single/Conv2D", - "module_apply_default/Encoder_en/KonaTransformer/Encode/Layer_0/TransformerLayer/MultiheadAttention/output_transform_single/bias/ConcatPartitions/concat" - ], - "attr": { - "T": { - "type": 1 - }, - "data_format": { - "s": [ - 78, - 72, - 87, - 67 - ] - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/output_transform_single/BiasAdd", - "op": "BiasAdd" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/output_transform_single/BiasAdd" - ], - "attr": { - "squeeze_dims": { - "list": { - "s": [], - "i": [ - "2" - ], - "f": [], - "b": [], - "type": [], - "shape": [], - "tensor": [], - "func": [] - } - }, - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/Squeeze_1", - "op": "Squeeze" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/Squeeze_1", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/AdjustResidualInput/Scatter/ScatterNd" - ], - "attr": { - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/layer_postprocess/add", - "op": "Add" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/layer_postprocess/add", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/layer_prepostprocess/layer_norm/Mean/reduction_indices" - ], - "attr": { - "T": { - "type": 1 - }, - "Tidx": { - "type": 3 - }, - "keep_dims": { - "b": true - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/layer_prepostprocess/layer_norm/Mean", - "op": "Mean" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/layer_postprocess/add", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/layer_prepostprocess/layer_norm/Mean" - ], - "attr": { - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/layer_prepostprocess/layer_norm/sub_1", - "op": "Sub" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/layer_prepostprocess/layer_norm/sub_1" - ], - "attr": { - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/layer_prepostprocess/layer_norm/Square", - "op": "Square" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/layer_prepostprocess/layer_norm/Square", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/layer_prepostprocess/layer_norm/Mean/reduction_indices" - ], - "attr": { - "T": { - "type": 1 - }, - "Tidx": { - "type": 3 - }, - "keep_dims": { - "b": true - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/layer_prepostprocess/layer_norm/Mean_1", - "op": "Mean" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/layer_prepostprocess/layer_norm/Mean_1", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/layer_prepostprocess/layer_norm/Cast/x" - ], - "attr": { - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/layer_prepostprocess/layer_norm/add", - "op": "Add" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/layer_prepostprocess/layer_norm/add" - ], - "attr": { - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/layer_prepostprocess/layer_norm/Rsqrt", - "op": "Rsqrt" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/Layer_0/TransformerLayer/FFN/layer_prepostprocess/layer_norm/layer_norm_scale/ConcatPartitions/concat", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/layer_prepostprocess/layer_norm/Rsqrt" - ], - "attr": { - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/layer_prepostprocess/layer_norm/mul", - "op": "Mul" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/layer_prepostprocess/layer_norm/mul", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/layer_prepostprocess/layer_norm/sub_1" - ], - "attr": { - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/layer_prepostprocess/layer_norm/mul_1", - "op": "Mul" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/layer_prepostprocess/layer_norm/mul_1", - "module_apply_default/Encoder_en/KonaTransformer/Encode/Layer_0/TransformerLayer/FFN/layer_prepostprocess/layer_norm/layer_norm_bias/ConcatPartitions/concat" - ], - "attr": { - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/layer_prepostprocess/layer_norm/add_1", - "op": "Add" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/layer_prepostprocess/layer_norm/add_1", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/StoreMask/ToInt32" - ], - "attr": { - "Tindices": { - "type": 3 - }, - "Tparams": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/Gather/GatherNd", - "op": "GatherNd" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/Gather/GatherNd", - "module_apply_default/Encoder_en/KonaTransformer/SequenceMask/Const" - ], - "attr": { - "Tdim": { - "type": 3 - }, - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/ExpandDims", - "op": "ExpandDims" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/ExpandDims" - ], - "attr": { - "T": { - "type": 1 - }, - "out_type": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/conv1/Tensordot/Shape", - "op": "Shape" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/conv1/Tensordot/Shape", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv1/Tensordot/add_1", - "module_apply_default/Encoder_en/KonaTransformer/SequenceMask/Const" - ], - "attr": { - "Taxis": { - "type": 3 - }, - "Tindices": { - "type": 3 - }, - "Tparams": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/conv1/Tensordot/GatherV2_1", - "op": "GatherV2" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/conv1/Tensordot/Shape", - "ConstantFolding/module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv1/Tensordot/ListDiff-folded-0", - "module_apply_default/Encoder_en/KonaTransformer/SequenceMask/Const" - ], - "attr": { - "Tindices": { - "type": 3 - }, - "Tparams": { - "type": 3 - }, - "Taxis": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/conv1/Tensordot/GatherV2", - "op": "GatherV2" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/conv1/Tensordot/GatherV2_1", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv2/Tensordot/Const" - ], - "attr": { - "Tidx": { - "type": 3 - }, - "keep_dims": { - "b": false - }, - "T": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/conv1/Tensordot/Prod_1", - "op": "Prod" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/conv1/Tensordot/GatherV2", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv2/Tensordot/Const" - ], - "attr": { - "T": { - "type": 3 - }, - "Tidx": { - "type": 3 - }, - "keep_dims": { - "b": false - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/conv1/Tensordot/Prod", - "op": "Prod" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/conv1/Tensordot/GatherV2", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv1/Tensordot/Const_2", - "module_apply_default/Encoder_en/KonaTransformer/SequenceMask/Const" - ], - "attr": { - "T": { - "type": 3 - }, - "N": { - "i": "2" - }, - "Tidx": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/conv1/Tensordot/concat_2", - "op": "ConcatV2" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/conv1/Tensordot/Prod", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/conv1/Tensordot/Prod_1" - ], - "attr": { - "T": { - "type": 3 - }, - "axis": { - "i": "0" - }, - "N": { - "i": "2" - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/conv1/Tensordot/stack", - "op": "Pack" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/ExpandDims", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/conv1/Tensordot/stack" - ], - "attr": { - "T": { - "type": 1 - }, - "Tshape": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/conv1/Tensordot/Reshape", - "op": "Reshape" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/conv1/Tensordot/Reshape", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/conv1/Tensordot/Reshape_1" - ], - "attr": { - "transpose_a": { - "b": false - }, - "transpose_b": { - "b": false - }, - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/conv1/Tensordot/MatMul", - "op": "MatMul" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/conv1/Tensordot/MatMul", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/conv1/Tensordot/concat_2" - ], - "attr": { - "T": { - "type": 1 - }, - "Tshape": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/conv1/Tensordot", - "op": "Reshape" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/conv1/Tensordot", - "module_apply_default/Encoder_en/KonaTransformer/Encode/Layer_0/TransformerLayer/FFN/conv1/bias/ConcatPartitions/concat" - ], - "attr": { - "data_format": { - "s": [ - 78, - 72, - 87, - 67 - ] - }, - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/conv1/BiasAdd", - "op": "BiasAdd" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/conv1/BiasAdd" - ], - "attr": { - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/conv1/Relu", - "op": "Relu" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/conv1/Relu" - ], - "attr": { - "T": { - "type": 1 - }, - "out_type": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/conv2/Tensordot/Shape", - "op": "Shape" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/conv2/Tensordot/Shape", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv1/Tensordot/add_1", - "module_apply_default/Encoder_en/KonaTransformer/SequenceMask/Const" - ], - "attr": { - "Taxis": { - "type": 3 - }, - "Tindices": { - "type": 3 - }, - "Tparams": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/conv2/Tensordot/GatherV2_1", - "op": "GatherV2" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/conv2/Tensordot/Shape", - "ConstantFolding/module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv1/Tensordot/ListDiff-folded-0", - "module_apply_default/Encoder_en/KonaTransformer/SequenceMask/Const" - ], - "attr": { - "Tindices": { - "type": 3 - }, - "Tparams": { - "type": 3 - }, - "Taxis": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/conv2/Tensordot/GatherV2", - "op": "GatherV2" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/conv2/Tensordot/GatherV2_1", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv2/Tensordot/Const" - ], - "attr": { - "Tidx": { - "type": 3 - }, - "keep_dims": { - "b": false - }, - "T": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/conv2/Tensordot/Prod_1", - "op": "Prod" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/conv2/Tensordot/GatherV2", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv2/Tensordot/Const" - ], - "attr": { - "Tidx": { - "type": 3 - }, - "keep_dims": { - "b": false - }, - "T": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/conv2/Tensordot/Prod", - "op": "Prod" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/conv2/Tensordot/GatherV2", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv2/Tensordot/Const_2", - "module_apply_default/Encoder_en/KonaTransformer/SequenceMask/Const" - ], - "attr": { - "Tidx": { - "type": 3 - }, - "T": { - "type": 3 - }, - "N": { - "i": "2" - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/conv2/Tensordot/concat_2", - "op": "ConcatV2" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/conv2/Tensordot/Prod", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/conv2/Tensordot/Prod_1" - ], - "attr": { - "T": { - "type": 3 - }, - "axis": { - "i": "0" - }, - "N": { - "i": "2" - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/conv2/Tensordot/stack", - "op": "Pack" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/conv1/Relu", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/conv2/Tensordot/stack" - ], - "attr": { - "T": { - "type": 1 - }, - "Tshape": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/conv2/Tensordot/Reshape", - "op": "Reshape" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/conv2/Tensordot/Reshape", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/conv2/Tensordot/Reshape_1" - ], - "attr": { - "transpose_a": { - "b": false - }, - "transpose_b": { - "b": false - }, - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/conv2/Tensordot/MatMul", - "op": "MatMul" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/conv2/Tensordot/MatMul", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/conv2/Tensordot/concat_2" - ], - "attr": { - "T": { - "type": 1 - }, - "Tshape": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/conv2/Tensordot", - "op": "Reshape" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/conv2/Tensordot", - "module_apply_default/Encoder_en/KonaTransformer/Encode/Layer_0/TransformerLayer/FFN/conv2/bias/ConcatPartitions/concat" - ], - "attr": { - "T": { - "type": 1 - }, - "data_format": { - "s": [ - 78, - 72, - 87, - 67 - ] - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/conv2/BiasAdd", - "op": "BiasAdd" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/conv2/BiasAdd" - ], - "attr": { - "T": { - "type": 1 - }, - "squeeze_dims": { - "list": { - "s": [], - "i": [ - "0" - ], - "f": [], - "b": [], - "type": [], - "shape": [], - "tensor": [], - "func": [] - } - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/Squeeze", - "op": "Squeeze" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/Squeeze" - ], - "attr": { - "T": { - "type": 1 - }, - "out_type": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/Scatter/Shape", - "op": "Shape" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/Scatter/Shape", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/Scatter/strided_slice/stack", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv2/Tensordot/Const", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/Scatter/strided_slice/stack" - ], - "attr": { - "shrink_axis_mask": { - "i": "0" - }, - "ellipsis_mask": { - "i": "0" - }, - "begin_mask": { - "i": "0" - }, - "new_axis_mask": { - "i": "0" - }, - "end_mask": { - "i": "1" - }, - "Index": { - "type": 3 - }, - "T": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/Scatter/strided_slice", - "op": "StridedSlice" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/StoreMask/Shape", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/Scatter/strided_slice", - "module_apply_default/Encoder_en/KonaTransformer/SequenceMask/Const" - ], - "attr": { - "T": { - "type": 3 - }, - "N": { - "i": "2" - }, - "Tidx": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/Scatter/concat", - "op": "ConcatV2" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/StoreMask/ToInt32", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/Squeeze", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/Scatter/concat" - ], - "attr": { - "Tindices": { - "type": 3 - }, - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/Scatter/ScatterNd", - "op": "ScatterNd" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/Scatter/ScatterNd", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/layer_postprocess/add" - ], - "attr": { - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/layer_postprocess/add", - "op": "Add" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/layer_postprocess/add", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/layer_prepostprocess/layer_norm/Mean/reduction_indices" - ], - "attr": { - "Tidx": { - "type": 3 - }, - "keep_dims": { - "b": true - }, - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/layer_prepostprocess/layer_norm/Mean", - "op": "Mean" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/layer_postprocess/add", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/layer_prepostprocess/layer_norm/Mean" - ], - "attr": { - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/layer_prepostprocess/layer_norm/sub_1", - "op": "Sub" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/layer_prepostprocess/layer_norm/sub_1" - ], - "attr": { - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/layer_prepostprocess/layer_norm/Square", - "op": "Square" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/layer_prepostprocess/layer_norm/Square", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/layer_prepostprocess/layer_norm/Mean/reduction_indices" - ], - "attr": { - "Tidx": { - "type": 3 - }, - "keep_dims": { - "b": true - }, - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/layer_prepostprocess/layer_norm/Mean_1", - "op": "Mean" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/layer_prepostprocess/layer_norm/Mean_1", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/layer_prepostprocess/layer_norm/Cast/x" - ], - "attr": { - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/layer_prepostprocess/layer_norm/add", - "op": "Add" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/layer_prepostprocess/layer_norm/add" - ], - "attr": { - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/layer_prepostprocess/layer_norm/Rsqrt", - "op": "Rsqrt" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/Layer_1/TransformerLayer/layer_prepostprocess/layer_norm/layer_norm_scale/ConcatPartitions/concat", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/layer_prepostprocess/layer_norm/Rsqrt" - ], - "attr": { - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/layer_prepostprocess/layer_norm/mul", - "op": "Mul" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/layer_prepostprocess/layer_norm/mul", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/layer_prepostprocess/layer_norm/sub_1" - ], - "attr": { - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/layer_prepostprocess/layer_norm/mul_1", - "op": "Mul" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/layer_prepostprocess/layer_norm/mul_1", - "module_apply_default/Encoder_en/KonaTransformer/Encode/Layer_1/TransformerLayer/layer_prepostprocess/layer_norm/layer_norm_bias/ConcatPartitions/concat" - ], - "attr": { - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/layer_prepostprocess/layer_norm/add_1", - "op": "Add" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/layer_prepostprocess/layer_norm/add_1", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/ExpandDims/dim" - ], - "attr": { - "Tdim": { - "type": 3 - }, - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/ExpandDims", - "op": "ExpandDims" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/ExpandDims", - "module/Encoder_en/KonaTransformer/Encode/Layer_1/TransformerLayer/MultiheadAttention/qkv_transform_single/kernel/part_0" - ], - "attr": { - "dilations": { - "list": { - "s": [], - "i": [ - "1", - "1", - "1", - "1" - ], - "f": [], - "b": [], - "type": [], - "shape": [], - "tensor": [], - "func": [] - } - }, - "T": { - "type": 1 - }, - "data_format": { - "s": [ - 78, - 72, - 87, - 67 - ] - }, - "strides": { - "list": { - "s": [], - "i": [ - "1", - "1", - "1", - "1" - ], - "f": [], - "b": [], - "type": [], - "shape": [], - "tensor": [], - "func": [] - } - }, - "use_cudnn_on_gpu": { - "b": true - }, - "padding": { - "s": [ - 86, - 65, - 76, - 73, - 68 - ] - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/qkv_transform_single/Conv2D", - "op": "Conv2D" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/qkv_transform_single/Conv2D", - "module_apply_default/Encoder_en/KonaTransformer/Encode/Layer_1/TransformerLayer/MultiheadAttention/qkv_transform_single/bias/ConcatPartitions/concat" - ], - "attr": { - "T": { - "type": 1 - }, - "data_format": { - "s": [ - 78, - 72, - 87, - 67 - ] - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/qkv_transform_single/BiasAdd", - "op": "BiasAdd" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/qkv_transform_single/BiasAdd" - ], - "attr": { - "squeeze_dims": { - "list": { - "s": [], - "i": [ - "2" - ], - "f": [], - "b": [], - "type": [], - "shape": [], - "tensor": [], - "func": [] - } - }, - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/Squeeze", - "op": "Squeeze" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/Squeeze", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/Const", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/ExpandDims/dim" - ], - "attr": { - "T": { - "type": 1 - }, - "Tlen": { - "type": 3 - }, - "num_split": { - "i": "3" - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/split", - "op": "SplitV" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/split" - ], - "attr": { - "out_type": { - "type": 3 - }, - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/split_heads/split_last_dimension/Shape", - "op": "Shape" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/split:1" - ], - "attr": { - "T": { - "type": 1 - }, - "out_type": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/split_heads_1/split_last_dimension/Shape", - "op": "Shape" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/split:2" - ], - "attr": { - "T": { - "type": 1 - }, - "out_type": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/split_heads_2/split_last_dimension/Shape", - "op": "Shape" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/split_heads/split_last_dimension/Shape", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv2/Tensordot/Const", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/Scatter/strided_slice/stack", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/Scatter/strided_slice/stack" - ], - "attr": { - "T": { - "type": 3 - }, - "Index": { - "type": 3 - }, - "shrink_axis_mask": { - "i": "1" - }, - "ellipsis_mask": { - "i": "0" - }, - "begin_mask": { - "i": "0" - }, - "new_axis_mask": { - "i": "0" - }, - "end_mask": { - "i": "0" - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/split_heads/split_last_dimension/strided_slice", - "op": "StridedSlice" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/split_heads/split_last_dimension/Shape", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/Scatter/strided_slice/stack", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv1/Tensordot/add_1", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/Scatter/strided_slice/stack" - ], - "attr": { - "begin_mask": { - "i": "0" - }, - "ellipsis_mask": { - "i": "0" - }, - "new_axis_mask": { - "i": "0" - }, - "end_mask": { - "i": "0" - }, - "Index": { - "type": 3 - }, - "T": { - "type": 3 - }, - "shrink_axis_mask": { - "i": "1" - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/split_heads/split_last_dimension/strided_slice_1", - "op": "StridedSlice" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/split_heads_1/split_last_dimension/Shape", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv2/Tensordot/Const", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/Scatter/strided_slice/stack", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/Scatter/strided_slice/stack" - ], - "attr": { - "shrink_axis_mask": { - "i": "1" - }, - "begin_mask": { - "i": "0" - }, - "ellipsis_mask": { - "i": "0" - }, - "new_axis_mask": { - "i": "0" - }, - "end_mask": { - "i": "0" - }, - "T": { - "type": 3 - }, - "Index": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/split_heads_1/split_last_dimension/strided_slice", - "op": "StridedSlice" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/split_heads_1/split_last_dimension/Shape", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/Scatter/strided_slice/stack", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv1/Tensordot/add_1", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/Scatter/strided_slice/stack" - ], - "attr": { - "Index": { - "type": 3 - }, - "T": { - "type": 3 - }, - "shrink_axis_mask": { - "i": "1" - }, - "ellipsis_mask": { - "i": "0" - }, - "begin_mask": { - "i": "0" - }, - "new_axis_mask": { - "i": "0" - }, - "end_mask": { - "i": "0" - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/split_heads_1/split_last_dimension/strided_slice_1", - "op": "StridedSlice" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/split_heads_2/split_last_dimension/Shape", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv2/Tensordot/Const", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/Scatter/strided_slice/stack", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/Scatter/strided_slice/stack" - ], - "attr": { - "shrink_axis_mask": { - "i": "1" - }, - "begin_mask": { - "i": "0" - }, - "ellipsis_mask": { - "i": "0" - }, - "new_axis_mask": { - "i": "0" - }, - "end_mask": { - "i": "0" - }, - "T": { - "type": 3 - }, - "Index": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/split_heads_2/split_last_dimension/strided_slice", - "op": "StridedSlice" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/split_heads_2/split_last_dimension/Shape", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/Scatter/strided_slice/stack", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv1/Tensordot/add_1", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/Scatter/strided_slice/stack" - ], - "attr": { - "T": { - "type": 3 - }, - "Index": { - "type": 3 - }, - "shrink_axis_mask": { - "i": "1" - }, - "begin_mask": { - "i": "0" - }, - "ellipsis_mask": { - "i": "0" - }, - "new_axis_mask": { - "i": "0" - }, - "end_mask": { - "i": "0" - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/split_heads_2/split_last_dimension/strided_slice_1", - "op": "StridedSlice" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/split_heads/split_last_dimension/strided_slice", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/split_heads/split_last_dimension/strided_slice_1", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/split_heads/split_last_dimension/Reshape/shape/2", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/split_heads/split_last_dimension/Reshape/shape/3" - ], - "attr": { - "axis": { - "i": "0" - }, - "N": { - "i": "4" - }, - "T": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/split_heads/split_last_dimension/Reshape/shape", - "op": "Pack" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/split_heads_1/split_last_dimension/strided_slice", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/split_heads_1/split_last_dimension/strided_slice_1", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/split_heads/split_last_dimension/Reshape/shape/2", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/split_heads/split_last_dimension/Reshape/shape/3" - ], - "attr": { - "T": { - "type": 3 - }, - "axis": { - "i": "0" - }, - "N": { - "i": "4" - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/split_heads_1/split_last_dimension/Reshape/shape", - "op": "Pack" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/split_heads_2/split_last_dimension/strided_slice", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/split_heads_2/split_last_dimension/strided_slice_1", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/split_heads/split_last_dimension/Reshape/shape/2", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/split_heads/split_last_dimension/Reshape/shape/3" - ], - "attr": { - "T": { - "type": 3 - }, - "axis": { - "i": "0" - }, - "N": { - "i": "4" - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/split_heads_2/split_last_dimension/Reshape/shape", - "op": "Pack" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/split", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/split_heads/split_last_dimension/Reshape/shape" - ], - "attr": { - "T": { - "type": 1 - }, - "Tshape": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/split_heads/split_last_dimension/Reshape", - "op": "Reshape" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/split:1", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/split_heads_1/split_last_dimension/Reshape/shape" - ], - "attr": { - "T": { - "type": 1 - }, - "Tshape": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/split_heads_1/split_last_dimension/Reshape", - "op": "Reshape" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/split:2", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/split_heads_2/split_last_dimension/Reshape/shape" - ], - "attr": { - "T": { - "type": 1 - }, - "Tshape": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/split_heads_2/split_last_dimension/Reshape", - "op": "Reshape" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/split_heads/split_last_dimension/Reshape", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/split_heads/transpose/perm" - ], - "attr": { - "T": { - "type": 1 - }, - "Tperm": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/split_heads/transpose", - "op": "Transpose" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/split_heads_1/split_last_dimension/Reshape", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/split_heads/transpose/perm" - ], - "attr": { - "Tperm": { - "type": 3 - }, - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/split_heads_1/transpose", - "op": "Transpose" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/split_heads_2/split_last_dimension/Reshape", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/split_heads/transpose/perm" - ], - "attr": { - "Tperm": { - "type": 3 - }, - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/split_heads_2/transpose", - "op": "Transpose" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/split_heads/transpose", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/mul/y" - ], - "attr": { - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/mul", - "op": "Mul" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/mul", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/split_heads_1/transpose" - ], - "attr": { - "adj_x": { - "b": false - }, - "adj_y": { - "b": true - }, - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/DotProductAttention/BaseDotProductAttention/MatMul", - "op": "BatchMatMul" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/DotProductAttention/BaseDotProductAttention/MatMul", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/DotProductAttention/attention_bias_ignore_padding/ExpandDims_1" - ], - "attr": { - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/DotProductAttention/BaseDotProductAttention/add", - "op": "Add" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/DotProductAttention/BaseDotProductAttention/add" - ], - "attr": { - "out_type": { - "type": 3 - }, - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/DotProductAttention/BaseDotProductAttention/Shape_1", - "op": "Shape" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/DotProductAttention/BaseDotProductAttention/Shape_1", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/DotProductAttention/BaseDotProductAttention/Slice/begin", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/Scatter/strided_slice/stack" - ], - "attr": { - "T": { - "type": 3 - }, - "Index": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/DotProductAttention/BaseDotProductAttention/Slice", - "op": "Slice" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/layer_prepostprocess/layer_norm/Mean/reduction_indices", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/DotProductAttention/BaseDotProductAttention/Slice", - "module_apply_default/Encoder_en/KonaTransformer/SequenceMask/Const" - ], - "attr": { - "Tidx": { - "type": 3 - }, - "T": { - "type": 3 - }, - "N": { - "i": "2" - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/DotProductAttention/BaseDotProductAttention/concat", - "op": "ConcatV2" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/DotProductAttention/BaseDotProductAttention/add", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/DotProductAttention/BaseDotProductAttention/concat" - ], - "attr": { - "Tshape": { - "type": 3 - }, - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/DotProductAttention/BaseDotProductAttention/Reshape", - "op": "Reshape" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/DotProductAttention/BaseDotProductAttention/Reshape" - ], - "attr": { - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/DotProductAttention/BaseDotProductAttention/Softmax", - "op": "Softmax" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/DotProductAttention/BaseDotProductAttention/Softmax", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/DotProductAttention/BaseDotProductAttention/Shape_1" - ], - "attr": { - "T": { - "type": 1 - }, - "Tshape": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/DotProductAttention/BaseDotProductAttention/attention_weights", - "op": "Reshape" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/DotProductAttention/BaseDotProductAttention/attention_weights", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/split_heads_2/transpose" - ], - "attr": { - "adj_x": { - "b": false - }, - "adj_y": { - "b": false - }, - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/DotProductAttention/BaseDotProductAttention/MatMul_1", - "op": "BatchMatMul" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/DotProductAttention/BaseDotProductAttention/MatMul_1", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/split_heads/transpose/perm" - ], - "attr": { - "Tperm": { - "type": 3 - }, - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/combine_heads/transpose", - "op": "Transpose" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/combine_heads/transpose" - ], - "attr": { - "T": { - "type": 1 - }, - "out_type": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/combine_heads/combine_last_two_dimensions/Shape", - "op": "Shape" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/combine_heads/combine_last_two_dimensions/Shape", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv2/Tensordot/Const", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/Scatter/strided_slice/stack", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/Scatter/strided_slice/stack" - ], - "attr": { - "ellipsis_mask": { - "i": "0" - }, - "begin_mask": { - "i": "0" - }, - "new_axis_mask": { - "i": "0" - }, - "end_mask": { - "i": "0" - }, - "T": { - "type": 3 - }, - "Index": { - "type": 3 - }, - "shrink_axis_mask": { - "i": "1" - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/combine_heads/combine_last_two_dimensions/strided_slice", - "op": "StridedSlice" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/combine_heads/combine_last_two_dimensions/Shape", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/Scatter/strided_slice/stack", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv1/Tensordot/add_1", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/Scatter/strided_slice/stack" - ], - "attr": { - "begin_mask": { - "i": "0" - }, - "ellipsis_mask": { - "i": "0" - }, - "new_axis_mask": { - "i": "0" - }, - "end_mask": { - "i": "0" - }, - "T": { - "type": 3 - }, - "Index": { - "type": 3 - }, - "shrink_axis_mask": { - "i": "1" - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/combine_heads/combine_last_two_dimensions/strided_slice_1", - "op": "StridedSlice" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/combine_heads/combine_last_two_dimensions/strided_slice", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/combine_heads/combine_last_two_dimensions/strided_slice_1", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/combine_heads/combine_last_two_dimensions/Reshape/shape/2" - ], - "attr": { - "T": { - "type": 3 - }, - "axis": { - "i": "0" - }, - "N": { - "i": "3" - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/combine_heads/combine_last_two_dimensions/Reshape/shape", - "op": "Pack" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/combine_heads/transpose", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/combine_heads/combine_last_two_dimensions/Reshape/shape" - ], - "attr": { - "T": { - "type": 1 - }, - "Tshape": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/combine_heads/combine_last_two_dimensions/Reshape", - "op": "Reshape" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/combine_heads/combine_last_two_dimensions/Reshape", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/ExpandDims/dim" - ], - "attr": { - "Tdim": { - "type": 3 - }, - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/ExpandDims_1", - "op": "ExpandDims" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/ExpandDims_1", - "module/Encoder_en/KonaTransformer/Encode/Layer_1/TransformerLayer/MultiheadAttention/output_transform_single/kernel/part_0" - ], - "attr": { - "dilations": { - "list": { - "s": [], - "i": [ - "1", - "1", - "1", - "1" - ], - "f": [], - "b": [], - "type": [], - "shape": [], - "tensor": [], - "func": [] - } - }, - "T": { - "type": 1 - }, - "data_format": { - "s": [ - 78, - 72, - 87, - 67 - ] - }, - "strides": { - "list": { - "s": [], - "i": [ - "1", - "1", - "1", - "1" - ], - "f": [], - "b": [], - "type": [], - "shape": [], - "tensor": [], - "func": [] - } - }, - "use_cudnn_on_gpu": { - "b": true - }, - "padding": { - "s": [ - 86, - 65, - 76, - 73, - 68 - ] - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/output_transform_single/Conv2D", - "op": "Conv2D" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/output_transform_single/Conv2D", - "module_apply_default/Encoder_en/KonaTransformer/Encode/Layer_1/TransformerLayer/MultiheadAttention/output_transform_single/bias/ConcatPartitions/concat" - ], - "attr": { - "data_format": { - "s": [ - 78, - 72, - 87, - 67 - ] - }, - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/output_transform_single/BiasAdd", - "op": "BiasAdd" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/output_transform_single/BiasAdd" - ], - "attr": { - "squeeze_dims": { - "list": { - "s": [], - "i": [ - "2" - ], - "f": [], - "b": [], - "type": [], - "shape": [], - "tensor": [], - "func": [] - } - }, - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/Squeeze_1", - "op": "Squeeze" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/Squeeze_1", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/layer_postprocess/add" - ], - "attr": { - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/layer_postprocess/add", - "op": "Add" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/layer_postprocess/add", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/layer_prepostprocess/layer_norm/Mean/reduction_indices" - ], - "attr": { - "Tidx": { - "type": 3 - }, - "keep_dims": { - "b": true - }, - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/layer_prepostprocess/layer_norm/Mean", - "op": "Mean" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/layer_postprocess/add", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/layer_prepostprocess/layer_norm/Mean" - ], - "attr": { - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/layer_prepostprocess/layer_norm/sub_1", - "op": "Sub" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/layer_prepostprocess/layer_norm/sub_1" - ], - "attr": { - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/layer_prepostprocess/layer_norm/Square", - "op": "Square" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/layer_prepostprocess/layer_norm/Square", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/layer_prepostprocess/layer_norm/Mean/reduction_indices" - ], - "attr": { - "T": { - "type": 1 - }, - "Tidx": { - "type": 3 - }, - "keep_dims": { - "b": true - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/layer_prepostprocess/layer_norm/Mean_1", - "op": "Mean" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/layer_prepostprocess/layer_norm/Mean_1", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/layer_prepostprocess/layer_norm/Cast/x" - ], - "attr": { - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/layer_prepostprocess/layer_norm/add", - "op": "Add" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/layer_prepostprocess/layer_norm/add" - ], - "attr": { - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/layer_prepostprocess/layer_norm/Rsqrt", - "op": "Rsqrt" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/Layer_1/TransformerLayer/FFN/layer_prepostprocess/layer_norm/layer_norm_scale/ConcatPartitions/concat", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/layer_prepostprocess/layer_norm/Rsqrt" - ], - "attr": { - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/layer_prepostprocess/layer_norm/mul", - "op": "Mul" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/layer_prepostprocess/layer_norm/mul", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/layer_prepostprocess/layer_norm/sub_1" - ], - "attr": { - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/layer_prepostprocess/layer_norm/mul_1", - "op": "Mul" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/layer_prepostprocess/layer_norm/mul_1", - "module_apply_default/Encoder_en/KonaTransformer/Encode/Layer_1/TransformerLayer/FFN/layer_prepostprocess/layer_norm/layer_norm_bias/ConcatPartitions/concat" - ], - "attr": { - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/layer_prepostprocess/layer_norm/add_1", - "op": "Add" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/layer_prepostprocess/layer_norm/add_1", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/StoreMask/ToInt32" - ], - "attr": { - "Tindices": { - "type": 3 - }, - "Tparams": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/Gather/GatherNd", - "op": "GatherNd" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/Gather/GatherNd", - "module_apply_default/Encoder_en/KonaTransformer/SequenceMask/Const" - ], - "attr": { - "Tdim": { - "type": 3 - }, - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/ExpandDims", - "op": "ExpandDims" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/ExpandDims" - ], - "attr": { - "T": { - "type": 1 - }, - "out_type": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv1/Tensordot/Shape", - "op": "Shape" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv1/Tensordot/Shape", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv1/Tensordot/add_1", - "module_apply_default/Encoder_en/KonaTransformer/SequenceMask/Const" - ], - "attr": { - "Tindices": { - "type": 3 - }, - "Tparams": { - "type": 3 - }, - "Taxis": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv1/Tensordot/GatherV2_1", - "op": "GatherV2" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv1/Tensordot/Shape", - "ConstantFolding/module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv1/Tensordot/ListDiff-folded-0", - "module_apply_default/Encoder_en/KonaTransformer/SequenceMask/Const" - ], - "attr": { - "Taxis": { - "type": 3 - }, - "Tindices": { - "type": 3 - }, - "Tparams": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv1/Tensordot/GatherV2", - "op": "GatherV2" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv1/Tensordot/GatherV2_1", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv2/Tensordot/Const" - ], - "attr": { - "T": { - "type": 3 - }, - "Tidx": { - "type": 3 - }, - "keep_dims": { - "b": false - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv1/Tensordot/Prod_1", - "op": "Prod" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv1/Tensordot/GatherV2", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv2/Tensordot/Const" - ], - "attr": { - "T": { - "type": 3 - }, - "Tidx": { - "type": 3 - }, - "keep_dims": { - "b": false - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv1/Tensordot/Prod", - "op": "Prod" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv1/Tensordot/GatherV2", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv1/Tensordot/Const_2", - "module_apply_default/Encoder_en/KonaTransformer/SequenceMask/Const" - ], - "attr": { - "T": { - "type": 3 - }, - "N": { - "i": "2" - }, - "Tidx": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv1/Tensordot/concat_2", - "op": "ConcatV2" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv1/Tensordot/Prod", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv1/Tensordot/Prod_1" - ], - "attr": { - "T": { - "type": 3 - }, - "axis": { - "i": "0" - }, - "N": { - "i": "2" - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv1/Tensordot/stack", - "op": "Pack" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/ExpandDims", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv1/Tensordot/stack" - ], - "attr": { - "T": { - "type": 1 - }, - "Tshape": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv1/Tensordot/Reshape", - "op": "Reshape" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv1/Tensordot/Reshape", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv1/Tensordot/Reshape_1" - ], - "attr": { - "transpose_b": { - "b": false - }, - "T": { - "type": 1 - }, - "transpose_a": { - "b": false - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv1/Tensordot/MatMul", - "op": "MatMul" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv1/Tensordot/MatMul", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv1/Tensordot/concat_2" - ], - "attr": { - "T": { - "type": 1 - }, - "Tshape": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv1/Tensordot", - "op": "Reshape" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv1/Tensordot", - "module_apply_default/Encoder_en/KonaTransformer/Encode/Layer_1/TransformerLayer/FFN/conv1/bias/ConcatPartitions/concat" - ], - "attr": { - "data_format": { - "s": [ - 78, - 72, - 87, - 67 - ] - }, - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv1/BiasAdd", - "op": "BiasAdd" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv1/BiasAdd" - ], - "attr": { - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv1/Relu", - "op": "Relu" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv1/Relu" - ], - "attr": { - "T": { - "type": 1 - }, - "out_type": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv2/Tensordot/Shape", - "op": "Shape" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv2/Tensordot/Shape", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv1/Tensordot/add_1", - "module_apply_default/Encoder_en/KonaTransformer/SequenceMask/Const" - ], - "attr": { - "Tindices": { - "type": 3 - }, - "Tparams": { - "type": 3 - }, - "Taxis": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv2/Tensordot/GatherV2_1", - "op": "GatherV2" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv2/Tensordot/Shape", - "ConstantFolding/module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv1/Tensordot/ListDiff-folded-0", - "module_apply_default/Encoder_en/KonaTransformer/SequenceMask/Const" - ], - "attr": { - "Taxis": { - "type": 3 - }, - "Tindices": { - "type": 3 - }, - "Tparams": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv2/Tensordot/GatherV2", - "op": "GatherV2" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv2/Tensordot/GatherV2_1", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv2/Tensordot/Const" - ], - "attr": { - "Tidx": { - "type": 3 - }, - "keep_dims": { - "b": false - }, - "T": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv2/Tensordot/Prod_1", - "op": "Prod" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv2/Tensordot/GatherV2", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv2/Tensordot/Const" - ], - "attr": { - "Tidx": { - "type": 3 - }, - "keep_dims": { - "b": false - }, - "T": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv2/Tensordot/Prod", - "op": "Prod" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv2/Tensordot/GatherV2", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv2/Tensordot/Const_2", - "module_apply_default/Encoder_en/KonaTransformer/SequenceMask/Const" - ], - "attr": { - "T": { - "type": 3 - }, - "N": { - "i": "2" - }, - "Tidx": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv2/Tensordot/concat_2", - "op": "ConcatV2" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv2/Tensordot/Prod", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv2/Tensordot/Prod_1" - ], - "attr": { - "T": { - "type": 3 - }, - "axis": { - "i": "0" - }, - "N": { - "i": "2" - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv2/Tensordot/stack", - "op": "Pack" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv1/Relu", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv2/Tensordot/stack" - ], - "attr": { - "T": { - "type": 1 - }, - "Tshape": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv2/Tensordot/Reshape", - "op": "Reshape" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv2/Tensordot/Reshape", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv2/Tensordot/Reshape_1" - ], - "attr": { - "transpose_a": { - "b": false - }, - "transpose_b": { - "b": false - }, - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv2/Tensordot/MatMul", - "op": "MatMul" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv2/Tensordot/MatMul", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv2/Tensordot/concat_2" - ], - "attr": { - "T": { - "type": 1 - }, - "Tshape": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv2/Tensordot", - "op": "Reshape" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv2/Tensordot", - "module_apply_default/Encoder_en/KonaTransformer/Encode/Layer_1/TransformerLayer/FFN/conv2/bias/ConcatPartitions/concat" - ], - "attr": { - "data_format": { - "s": [ - 78, - 72, - 87, - 67 - ] - }, - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv2/BiasAdd", - "op": "BiasAdd" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv2/BiasAdd" - ], - "attr": { - "T": { - "type": 1 - }, - "squeeze_dims": { - "list": { - "s": [], - "i": [ - "0" - ], - "f": [], - "b": [], - "type": [], - "shape": [], - "tensor": [], - "func": [] - } - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/Squeeze", - "op": "Squeeze" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/Squeeze" - ], - "attr": { - "T": { - "type": 1 - }, - "out_type": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/Scatter/Shape", - "op": "Shape" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/Scatter/Shape", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/Scatter/strided_slice/stack", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv2/Tensordot/Const", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/Scatter/strided_slice/stack" - ], - "attr": { - "Index": { - "type": 3 - }, - "T": { - "type": 3 - }, - "shrink_axis_mask": { - "i": "0" - }, - "begin_mask": { - "i": "0" - }, - "ellipsis_mask": { - "i": "0" - }, - "new_axis_mask": { - "i": "0" - }, - "end_mask": { - "i": "1" - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/Scatter/strided_slice", - "op": "StridedSlice" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/StoreMask/Shape", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/Scatter/strided_slice", - "module_apply_default/Encoder_en/KonaTransformer/SequenceMask/Const" - ], - "attr": { - "N": { - "i": "2" - }, - "Tidx": { - "type": 3 - }, - "T": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/Scatter/concat", - "op": "ConcatV2" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/StoreMask/ToInt32", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/Squeeze", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/Scatter/concat" - ], - "attr": { - "Tindices": { - "type": 3 - }, - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/Scatter/ScatterNd", - "op": "ScatterNd" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/Scatter/ScatterNd", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/layer_postprocess/add" - ], - "attr": { - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/layer_postprocess/add", - "op": "Add" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/layer_postprocess/add" - ], - "attr": { - "T": { - "type": 1 - }, - "out_type": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Shape", - "op": "Shape" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Shape", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/Scatter/strided_slice/stack", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv1/Tensordot/add_1", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/Scatter/strided_slice/stack" - ], - "attr": { - "T": { - "type": 3 - }, - "Index": { - "type": 3 - }, - "shrink_axis_mask": { - "i": "1" - }, - "begin_mask": { - "i": "0" - }, - "ellipsis_mask": { - "i": "0" - }, - "new_axis_mask": { - "i": "0" - }, - "end_mask": { - "i": "0" - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/strided_slice", - "op": "StridedSlice" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/SequenceMask/Const", - "module_apply_default/Encoder_en/KonaTransformer/strided_slice", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/DotProductAttention/attention_bias_ignore_padding/ExpandDims/dim" - ], - "attr": { - "Tidx": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/SequenceMask/Range", - "op": "Range" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/SequenceMask/Range", - "module_apply_default/Encoder_en/KonaTransformer/SequenceMask/ExpandDims" - ], - "attr": { - "T": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/SequenceMask/Less", - "op": "Less" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/SequenceMask/Less" - ], - "attr": { - "Truncate": { - "b": false - }, - "DstT": { - "type": 1 - }, - "SrcT": { - "type": 10 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/ToFloat", - "op": "Cast" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/ToFloat", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/ExpandDims/dim" - ], - "attr": { - "T": { - "type": 1 - }, - "Tdim": { - "type": 3 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/ExpandDims", - "op": "ExpandDims" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/layer_postprocess/add", - "module_apply_default/Encoder_en/KonaTransformer/ExpandDims" - ], - "attr": { - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/mul", - "op": "Mul" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/mul", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/DotProductAttention/attention_bias_ignore_padding/ExpandDims/dim" - ], - "attr": { - "Tidx": { - "type": 3 - }, - "keep_dims": { - "b": false - }, - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/Sum", - "op": "Sum" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/Sum", - "module_apply_default/Encoder_en/KonaTransformer/ExpandDims_1" - ], - "attr": { - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/KonaTransformer/div", - "op": "RealDiv" - }, - { - "input": [ - "module_apply_default/Encoder_en/KonaTransformer/div", - "module/Encoder_en/hidden_layers/tanh_layer_0/weights" - ], - "attr": { - "transpose_a": { - "b": false - }, - "transpose_b": { - "b": false - }, - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/hidden_layers/tanh_layer_0/MatMul", - "op": "MatMul" - }, - { - "input": [ - "module_apply_default/Encoder_en/hidden_layers/tanh_layer_0/MatMul", - "module/Encoder_en/hidden_layers/tanh_layer_0/bias" - ], - "attr": { - "data_format": { - "s": [ - 78, - 72, - 87, - 67 - ] - }, - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/hidden_layers/tanh_layer_0/BiasAdd", - "op": "BiasAdd" - }, - { - "input": [ - "module_apply_default/Encoder_en/hidden_layers/tanh_layer_0/BiasAdd" - ], - "attr": { - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/hidden_layers/tanh_layer_0/Tanh", - "op": "Tanh" - }, - { - "input": [ - "module_apply_default/Encoder_en/hidden_layers/tanh_layer_0/Tanh" - ], - "attr": { - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/hidden_layers/l2_normalize/Square", - "op": "Square" - }, - { - "input": [ - "module_apply_default/Encoder_en/hidden_layers/l2_normalize/Square", - "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/DotProductAttention/attention_bias_ignore_padding/ExpandDims/dim" - ], - "attr": { - "Tidx": { - "type": 3 - }, - "keep_dims": { - "b": true - }, - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/hidden_layers/l2_normalize/Sum", - "op": "Sum" - }, - { - "input": [ - "module_apply_default/Encoder_en/hidden_layers/l2_normalize/Sum", - "module_apply_default/Encoder_en/hidden_layers/l2_normalize/Maximum/y" - ], - "attr": { - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/hidden_layers/l2_normalize/Maximum", - "op": "Maximum" - }, - { - "input": [ - "module_apply_default/Encoder_en/hidden_layers/l2_normalize/Maximum" - ], - "attr": { - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/hidden_layers/l2_normalize/Rsqrt", - "op": "Rsqrt" - }, - { - "input": [ - "module_apply_default/Encoder_en/hidden_layers/tanh_layer_0/Tanh", - "module_apply_default/Encoder_en/hidden_layers/l2_normalize/Rsqrt" - ], - "attr": { - "T": { - "type": 1 - } - }, - "name": "module_apply_default/Encoder_en/hidden_layers/l2_normalize", - "op": "Mul" - } - ], - "library": { - "function": [], - "gradient": [] - }, - "versions": { - "badConsumers": [] - } - }, - "weightsManifest": [ - { - "paths": [ - "group1-shard1of7", - "group1-shard2of7", - "group1-shard3of7", - "group1-shard4of7", - "group1-shard5of7", - "group1-shard6of7", - "group1-shard7of7" - ], - "weights": [ - { - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv2/Tensordot/Reshape_1", - "shape": [ - 1536, - 512 - ], - "dtype": "float32" - }, - { - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv1/Tensordot/Reshape_1", - "shape": [ - 512, - 1536 - ], - "dtype": "float32" - }, - { - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/Layer_1/TransformerLayer/FFN/layer_prepostprocess/layer_norm/layer_norm_scale/ConcatPartitions/concat", - "shape": [ - 512 - ], - "dtype": "float32" - }, - { - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/Layer_1/TransformerLayer/FFN/layer_prepostprocess/layer_norm/layer_norm_bias/ConcatPartitions/concat", - "shape": [ - 512 - ], - "dtype": "float32" - }, - { - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/Layer_1/TransformerLayer/FFN/conv1/bias/ConcatPartitions/concat", - "shape": [ - 1536 - ], - "dtype": "float32" - }, - { - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/Layer_1/TransformerLayer/FFN/conv2/bias/ConcatPartitions/concat", - "shape": [ - 512 - ], - "dtype": "float32" - }, - { - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/mul/y", - "shape": [], - "dtype": "float32" - }, - { - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/Layer_1/TransformerLayer/layer_prepostprocess/layer_norm/layer_norm_scale/ConcatPartitions/concat", - "shape": [ - 512 - ], - "dtype": "float32" - }, - { - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/Layer_1/TransformerLayer/layer_prepostprocess/layer_norm/layer_norm_bias/ConcatPartitions/concat", - "shape": [ - 512 - ], - "dtype": "float32" - }, - { - "name": "module/Encoder_en/KonaTransformer/Encode/Layer_1/TransformerLayer/MultiheadAttention/qkv_transform_single/kernel/part_0", - "shape": [ - 1, - 1, - 512, - 1536 - ], - "dtype": "float32" - }, - { - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/Layer_1/TransformerLayer/MultiheadAttention/qkv_transform_single/bias/ConcatPartitions/concat", - "shape": [ - 1536 - ], - "dtype": "float32" - }, - { - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/Const", - "shape": [ - 3 - ], - "dtype": "int32" - }, - { - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/split_heads/split_last_dimension/Reshape/shape/3", - "shape": [], - "dtype": "int32" - }, - { - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/combine_heads/combine_last_two_dimensions/Reshape/shape/2", - "shape": [], - "dtype": "int32" - }, - { - "name": "module/Encoder_en/KonaTransformer/Encode/Layer_1/TransformerLayer/MultiheadAttention/output_transform_single/kernel/part_0", - "shape": [ - 1, - 1, - 512, - 512 - ], - "dtype": "float32" - }, - { - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/Layer_1/TransformerLayer/MultiheadAttention/output_transform_single/bias/ConcatPartitions/concat", - "shape": [ - 512 - ], - "dtype": "float32" - }, - { - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/conv2/Tensordot/Reshape_1", - "shape": [ - 1536, - 512 - ], - "dtype": "float32" - }, - { - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/FFN/conv1/Tensordot/Reshape_1", - "shape": [ - 512, - 1536 - ], - "dtype": "float32" - }, - { - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/Layer_0/TransformerLayer/FFN/layer_prepostprocess/layer_norm/layer_norm_scale/ConcatPartitions/concat", - "shape": [ - 512 - ], - "dtype": "float32" - }, - { - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/Layer_0/TransformerLayer/FFN/layer_prepostprocess/layer_norm/layer_norm_bias/ConcatPartitions/concat", - "shape": [ - 512 - ], - "dtype": "float32" - }, - { - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv1/Tensordot/Const_2", - "shape": [ - 1 - ], - "dtype": "int32" - }, - { - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/Layer_0/TransformerLayer/FFN/conv1/bias/ConcatPartitions/concat", - "shape": [ - 1536 - ], - "dtype": "float32" - }, - { - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv2/Tensordot/Const_2", - "shape": [ - 1 - ], - "dtype": "int32" - }, - { - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/Layer_0/TransformerLayer/FFN/conv2/bias/ConcatPartitions/concat", - "shape": [ - 512 - ], - "dtype": "float32" - }, - { - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/DotProductAttention/BaseDotProductAttention/Slice/begin", - "shape": [ - 1 - ], - "dtype": "int32" - }, - { - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/mul/y", - "shape": [], - "dtype": "float32" - }, - { - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/DotProductAttention/attention_bias_ignore_padding/mul/y", - "shape": [], - "dtype": "float32" - }, - { - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/Layer_0/TransformerLayer/layer_prepostprocess/layer_norm/layer_norm_scale/ConcatPartitions/concat", - "shape": [ - 256 - ], - "dtype": "float32" - }, - { - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/layer_prepostprocess/layer_norm/Cast/x", - "shape": [], - "dtype": "float32" - }, - { - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/Layer_0/TransformerLayer/layer_prepostprocess/layer_norm/layer_norm_bias/ConcatPartitions/concat", - "shape": [ - 256 - ], - "dtype": "float32" - }, - { - "name": "module/Encoder_en/KonaTransformer/Encode/Layer_0/TransformerLayer/MultiheadAttention/qkv_transform_single/kernel/part_0", - "shape": [ - 1, - 1, - 256, - 768 - ], - "dtype": "float32" - }, - { - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/Layer_0/TransformerLayer/MultiheadAttention/qkv_transform_single/bias/ConcatPartitions/concat", - "shape": [ - 768 - ], - "dtype": "float32" - }, - { - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/Const", - "shape": [ - 3 - ], - "dtype": "int32" - }, - { - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/split_heads/split_last_dimension/Reshape/shape/2", - "shape": [], - "dtype": "int32" - }, - { - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/split_heads/split_last_dimension/Reshape/shape/3", - "shape": [], - "dtype": "int32" - }, - { - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/split_heads/transpose/perm", - "shape": [ - 4 - ], - "dtype": "int32" - }, - { - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/TransformerLayer/MultiheadAttention/combine_heads/combine_last_two_dimensions/Reshape/shape/2", - "shape": [], - "dtype": "int32" - }, - { - "name": "module/Encoder_en/KonaTransformer/Encode/Layer_0/TransformerLayer/MultiheadAttention/output_transform_single/kernel/part_0", - "shape": [ - 1, - 1, - 256, - 512 - ], - "dtype": "float32" - }, - { - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/Layer_0/TransformerLayer/MultiheadAttention/output_transform_single/bias/ConcatPartitions/concat", - "shape": [ - 512 - ], - "dtype": "float32" - }, - { - "name": "module/Embeddings_en", - "shape": [ - 8002, - 256 - ], - "dtype": "float32" - }, - { - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/AddTimingSignal/TimingSignal/ExpandDims_1", - "shape": [ - 1, - 128 - ], - "dtype": "float32" - }, - { - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/Layer_0/TransformerLayer/dense/kernel/ConcatPartitions/concat", - "shape": [ - 256, - 512 - ], - "dtype": "float32" - }, - { - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/Layer_0/TransformerLayer/dense/bias/ConcatPartitions/concat", - "shape": [ - 512 - ], - "dtype": "float32" - }, - { - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv2/Tensordot/Const", - "shape": [ - 1 - ], - "dtype": "int32" - }, - { - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv1/Tensordot/add_1", - "shape": [ - 1 - ], - "dtype": "int32" - }, - { - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/Scatter/strided_slice/stack", - "shape": [ - 1 - ], - "dtype": "int32" - }, - { - "name": "module_apply_default/Encoder_en/KonaTransformer/SequenceMask/ExpandDims/dim", - "shape": [], - "dtype": "int32" - }, - { - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/ExpandDims/dim", - "shape": [], - "dtype": "int32" - }, - { - "name": "module_apply_default/Encoder_en/KonaTransformer/ClipToMaxLength/Const", - "shape": [], - "dtype": "int32" - }, - { - "name": "module_apply_default/Encoder_en/KonaTransformer/ClipToMaxLength/ones_like", - "shape": [ - 2 - ], - "dtype": "int32" - }, - { - "name": "ConstantFolding/module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/conv1/Tensordot/ListDiff-folded-0", - "shape": [ - 2 - ], - "dtype": "int32" - }, - { - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/AddTimingSignal/strided_slice_2/stack_1", - "shape": [ - 2 - ], - "dtype": "int32" - }, - { - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_0/AddTimingSignal/strided_slice_2/stack_2", - "shape": [ - 2 - ], - "dtype": "int32" - }, - { - "name": "module_apply_default/Encoder_en/KonaTransformer/ClipToMaxLength/Less/y", - "shape": [], - "dtype": "int32" - }, - { - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/FFN/layer_prepostprocess/layer_norm/Mean/reduction_indices", - "shape": [ - 1 - ], - "dtype": "int32" - }, - { - "name": "module_apply_default/Encoder_en/KonaTransformer/SequenceMask/Const", - "shape": [], - "dtype": "int32" - }, - { - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/SparseToDense/default_value", - "shape": [], - "dtype": "int32" - }, - { - "name": "module/Encoder_en/hidden_layers/tanh_layer_0/weights", - "shape": [ - 512, - 512 - ], - "dtype": "float32" - }, - { - "name": "module/Encoder_en/hidden_layers/tanh_layer_0/bias", - "shape": [ - 512 - ], - "dtype": "float32" - }, - { - "name": "module_apply_default/Encoder_en/KonaTransformer/Encode/TransformerStack/Layer_1/TransformerLayer/MultiheadAttention/DotProductAttention/attention_bias_ignore_padding/ExpandDims/dim", - "shape": [], - "dtype": "int32" - }, - { - "name": "module_apply_default/Encoder_en/hidden_layers/l2_normalize/Maximum/y", - "shape": [], - "dtype": "float32" - } - ] - } - ] -} \ No newline at end of file diff --git a/tfjs-master/e2e/custom_module/universal_sentence_encoder/package.json b/tfjs-master/e2e/custom_module/universal_sentence_encoder/package.json deleted file mode 100644 index 6faf624cd..000000000 --- a/tfjs-master/e2e/custom_module/universal_sentence_encoder/package.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "name": "use-treeshake", - "version": "1.0.0", - "description": "", - "main": "app.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1", - "make-custom-tfjs-modules": "node ./node_modules/@tensorflow/tfjs/dist/tools/custom_module/cli.js --config app_tfjs_config.json", - "rollup:full": "rollup -c", - "rollup:custom": "rollup -c --useCustomTfjs", - "webpack:full": "webpack", - "webpack:custom": "webpack --env useCustomTfjs" - }, - "dependencies": { - "@tensorflow-models/universal-sentence-encoder": "^1.3.2", - "@tensorflow/tfjs": "link:../../../tfjs" - }, - "devDependencies": { - "@rollup/plugin-alias": "^3.1.1", - "@rollup/plugin-commonjs": "^14.0.0", - "@rollup/plugin-node-resolve": "^8.4.0", - "file-loader": "^6.1.0", - "rollup": "^2.23.0", - "rollup-plugin-commonjs": "^10.1.0", - "rollup-plugin-node-resolve": "^5.2.0", - "rollup-plugin-terser": "^6.1.0", - "rollup-plugin-visualizer": "^4.0.4", - "terser-webpack-plugin": "^5.3.1", - "webpack": "^5.76.0", - "webpack-cli": "^4.9.2" - }, - "resolutions": { - "minimist": "1.2.6" - } -} diff --git a/tfjs-master/e2e/custom_module/universal_sentence_encoder/rollup.config.js b/tfjs-master/e2e/custom_module/universal_sentence_encoder/rollup.config.js deleted file mode 100644 index b5a9a68b2..000000000 --- a/tfjs-master/e2e/custom_module/universal_sentence_encoder/rollup.config.js +++ /dev/null @@ -1,99 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import alias from '@rollup/plugin-alias'; -import commonjs from '@rollup/plugin-commonjs'; -import resolve from '@rollup/plugin-node-resolve'; -import * as path from 'path'; -import {terser} from 'rollup-plugin-terser'; -import visualizer from 'rollup-plugin-visualizer'; - - -const sourcemap = false; - -function getPlugins(options) { - let plugins = []; - - if (options.useCustomTfjs) { - plugins.push( - // replace top level imports to tfjs-core with custom import. - // after v3 is out we still need to do this in converter. - alias({ - entries: [ - { - find: /@tensorflow\/tfjs$/, - replacement: path.resolve(__dirname, options.customTfjsPath), - }, - { - find: /@tensorflow\/tfjs-core$/, - replacement: path.resolve(__dirname, options.customTfjsCorePath), - }, - { - find: '@tensorflow/tfjs-core/dist/ops/ops_for_converter', - replacement: path.resolve(__dirname, options.customOpsPath), - }, - ], - })); - } - - plugins = [ - ...plugins, - resolve({browser: true, dedupe: ['seedrandom']}), - commonjs({include: ['node_modules/**']}), - terser({output: {comments: false}}), - ]; - - if (options.visualize) { - plugins.push(visualizer({sourcemap, filename: options.visPath})); - } - - return plugins; -} - - -module.exports = (cmdOptions) => { - const {useCustomTfjs, visualize} = cmdOptions; - // remove custom command line options from being passed onto rollup. - delete cmdOptions.useCustomTfjs; - delete cmdOptions.visualize; - - const bundles = []; - const outputPath = useCustomTfjs ? 'dist/custom' : 'dist/full'; - - bundles.push( - { - input: 'app.js', - output: { - file: `${outputPath}/app_rollup.js`, - sourcemap, - format: 'umd', - }, - plugins: [ - ...getPlugins({ - useCustomTfjs: useCustomTfjs, - customTfjsPath: './custom_tfjs/custom_tfjs.js', - customTfjsCorePath: './custom_tfjs/custom_tfjs_core.js', - customOpsPath: './custom_tfjs/custom_ops_for_converter.js', - visualize: visualize, - visPath: `${outputPath}/app_rollup.js.html`, - }), - ], - }, - ); - - return bundles; -}; diff --git a/tfjs-master/e2e/custom_module/universal_sentence_encoder/webpack.config.js b/tfjs-master/e2e/custom_module/universal_sentence_encoder/webpack.config.js deleted file mode 100644 index 14bfdd538..000000000 --- a/tfjs-master/e2e/custom_module/universal_sentence_encoder/webpack.config.js +++ /dev/null @@ -1,65 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -const path = require('path'); -const TerserPlugin = require('terser-webpack-plugin'); - -module.exports = function(env) { - const outputPath = (env && env.useCustomTfjs) ? 'dist/custom' : 'dist/full' - - const config = { - mode: 'production', - entry: './app.js', - target: 'web', - output: { - path: path.resolve(__dirname, outputPath), - filename: 'app_webpack.js', - }, - optimization: { - minimizer: [ - new TerserPlugin({parallel: true, terserOptions: {}}), - ] - }, - module: { - rules: [ - { - test: /\.wasm$/i, - type: 'javascript/auto', - use: [ - { - loader: 'file-loader', - }, - ], - }, - ], - } - }; - - if (env && env.useCustomTfjs) { - config.resolve = { - alias: { - '@tensorflow/tfjs$': - path.resolve(__dirname, './custom_tfjs/custom_tfjs.js'), - '@tensorflow/tfjs-core$': - path.resolve(__dirname, './custom_tfjs/custom_tfjs_core.js'), - '@tensorflow/tfjs-core/dist/ops/ops_for_converter': path.resolve( - __dirname, './custom_tfjs/custom_ops_for_converter.js'), - } - } - } - return config; -} diff --git a/tfjs-master/e2e/custom_module/universal_sentence_encoder/yarn.lock b/tfjs-master/e2e/custom_module/universal_sentence_encoder/yarn.lock deleted file mode 100644 index e94b3433e..000000000 --- a/tfjs-master/e2e/custom_module/universal_sentence_encoder/yarn.lock +++ /dev/null @@ -1,1499 +0,0 @@ -# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. -# yarn lockfile v1 - - -"@babel/code-frame@^7.8.3": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.16.7.tgz#44416b6bd7624b998f5b1af5d470856c40138789" - integrity sha512-iAXqUn8IIeBTNd72xsFlgaXHkMBMt6y4HJp1tIaK465CWLT/fG1aqB7ykr95gHHmlBdGbFeWWfyB4NJJ0nmeIg== - dependencies: - "@babel/highlight" "^7.16.7" - -"@babel/helper-validator-identifier@^7.16.7": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz#e8c602438c4a8195751243da9031d1607d247cad" - integrity sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw== - -"@babel/highlight@^7.16.7": - version "7.16.10" - resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.16.10.tgz#744f2eb81579d6eea753c227b0f570ad785aba88" - integrity sha512-5FnTQLSLswEj6IkgVw5KusNUUFY9ZGqe/TRFnP/BKYHYgfh7tc+C7mwiy95/yNP7Dh9x580Vv8r7u7ZfTBFxdw== - dependencies: - "@babel/helper-validator-identifier" "^7.16.7" - chalk "^2.0.0" - js-tokens "^4.0.0" - -"@discoveryjs/json-ext@^0.5.0": - version "0.5.7" - resolved "https://registry.yarnpkg.com/@discoveryjs/json-ext/-/json-ext-0.5.7.tgz#1d572bfbbe14b7704e0ba0f39b74815b84870d70" - integrity sha512-dBVuXR082gk3jsFp7Rd/JI4kytwGHecnCoTtXFb7DB6CNHp4rg5k1bhg0nWdLGLnOV71lmDzGQaLMy8iPLY0pw== - -"@rollup/plugin-alias@^3.1.1": - version "3.1.9" - resolved "https://registry.yarnpkg.com/@rollup/plugin-alias/-/plugin-alias-3.1.9.tgz#a5d267548fe48441f34be8323fb64d1d4a1b3fdf" - integrity sha512-QI5fsEvm9bDzt32k39wpOwZhVzRcL5ydcffUHMyLVaVaLeC70I8TJZ17F1z1eMoLu4E/UOcH9BWVkKpIKdrfiw== - dependencies: - slash "^3.0.0" - -"@rollup/plugin-commonjs@^14.0.0": - version "14.0.0" - resolved "https://registry.yarnpkg.com/@rollup/plugin-commonjs/-/plugin-commonjs-14.0.0.tgz#4285f9ec2db686a31129e5a2b415c94aa1f836f0" - integrity sha512-+PSmD9ePwTAeU106i9FRdc+Zb3XUWyW26mo5Atr2mk82hor8+nPwkztEjFo8/B1fJKfaQDg9aM2bzQkjhi7zOw== - dependencies: - "@rollup/pluginutils" "^3.0.8" - commondir "^1.0.1" - estree-walker "^1.0.1" - glob "^7.1.2" - is-reference "^1.1.2" - magic-string "^0.25.2" - resolve "^1.11.0" - -"@rollup/plugin-node-resolve@^8.4.0": - version "8.4.0" - resolved "https://registry.yarnpkg.com/@rollup/plugin-node-resolve/-/plugin-node-resolve-8.4.0.tgz#261d79a680e9dc3d86761c14462f24126ba83575" - integrity sha512-LFqKdRLn0ShtQyf6SBYO69bGE1upV6wUhBX0vFOUnLAyzx5cwp8svA0eHUnu8+YU57XOkrMtfG63QOpQx25pHQ== - dependencies: - "@rollup/pluginutils" "^3.1.0" - "@types/resolve" "1.17.1" - builtin-modules "^3.1.0" - deep-freeze "^0.0.1" - deepmerge "^4.2.2" - is-module "^1.0.0" - resolve "^1.17.0" - -"@rollup/pluginutils@^3.0.8", "@rollup/pluginutils@^3.1.0": - version "3.1.0" - resolved "https://registry.yarnpkg.com/@rollup/pluginutils/-/pluginutils-3.1.0.tgz#706b4524ee6dc8b103b3c995533e5ad680c02b9b" - integrity sha512-GksZ6pr6TpIjHm8h9lSQ8pi8BE9VeubNT0OMJ3B5uZJ8pz73NPiqOtCog/x2/QzM1ENChPKxMDhiQuRHsqc+lg== - dependencies: - "@types/estree" "0.0.39" - estree-walker "^1.0.1" - picomatch "^2.2.2" - -"@tensorflow-models/universal-sentence-encoder@^1.3.2": - version "1.3.3" - resolved "https://registry.yarnpkg.com/@tensorflow-models/universal-sentence-encoder/-/universal-sentence-encoder-1.3.3.tgz#39874e8a49a42c9c06716a3cdc25eea844f4de50" - integrity sha512-mipL7ad0CW6uQ68FUkNgkNj/zgA4qgBnNcnMMkNTdL9MUMnzCxu3AE8pWnx2ReKHwdqEG4e8IpaYKfH4B8bojg== - -"@tensorflow/tfjs-backend-cpu@link:../../../link-package/node_modules/@tensorflow/link-package/node_modules/@tensorflow/tfjs-backend-cpu": - version "0.0.0" - -"@tensorflow/tfjs-backend-cpu@link:../../../link-package/node_modules/@tensorflow/tfjs-backend-cpu": - version "0.0.0" - uid "" - -"@tensorflow/tfjs-backend-webgl@link:../../../link-package/node_modules/@tensorflow/tfjs-backend-webgl": - version "0.0.0" - uid "" - -"@tensorflow/tfjs-converter@link:../../../link-package/node_modules/@tensorflow/tfjs-converter": - version "0.0.0" - uid "" - -"@tensorflow/tfjs-core@link:../../../link-package/node_modules/@tensorflow/tfjs-core": - version "0.0.0" - uid "" - -"@tensorflow/tfjs-data@link:../../../link-package/node_modules/@tensorflow/tfjs-data": - version "0.0.0" - uid "" - -"@tensorflow/tfjs-layers@link:../../../link-package/node_modules/@tensorflow/tfjs-layers": - version "0.0.0" - uid "" - -"@tensorflow/tfjs@link:../../../tfjs": - version "0.0.0" - uid "" - -"@types/eslint-scope@^3.7.3": - version "3.7.3" - resolved "https://registry.yarnpkg.com/@types/eslint-scope/-/eslint-scope-3.7.3.tgz#125b88504b61e3c8bc6f870882003253005c3224" - integrity sha512-PB3ldyrcnAicT35TWPs5IcwKD8S333HMaa2VVv4+wdvebJkjWuW/xESoB8IwRcog8HYVYamb1g/R31Qv5Bx03g== - dependencies: - "@types/eslint" "*" - "@types/estree" "*" - -"@types/eslint@*": - version "8.4.1" - resolved "https://registry.yarnpkg.com/@types/eslint/-/eslint-8.4.1.tgz#c48251553e8759db9e656de3efc846954ac32304" - integrity sha512-GE44+DNEyxxh2Kc6ro/VkIj+9ma0pO0bwv9+uHSyBrikYOHr8zYcdPvnBOp1aw8s+CjRvuSx7CyWqRrNFQ59mA== - dependencies: - "@types/estree" "*" - "@types/json-schema" "*" - -"@types/estree@*", "@types/estree@^0.0.51": - version "0.0.51" - resolved "https://registry.yarnpkg.com/@types/estree/-/estree-0.0.51.tgz#cfd70924a25a3fd32b218e5e420e6897e1ac4f40" - integrity sha512-CuPgU6f3eT/XgKKPqKd/gLZV1Xmvf1a2R5POBOGQa6uv82xpls89HU5zKeVoyR8XzHd1RGNOlQlvUe3CFkjWNQ== - -"@types/estree@0.0.39": - version "0.0.39" - resolved "https://registry.yarnpkg.com/@types/estree/-/estree-0.0.39.tgz#e177e699ee1b8c22d23174caaa7422644389509f" - integrity sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw== - -"@types/json-schema@*", "@types/json-schema@^7.0.8": - version "7.0.9" - resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.9.tgz#97edc9037ea0c38585320b28964dde3b39e4660d" - integrity sha512-qcUXuemtEu+E5wZSJHNxUXeCZhAfXKQ41D+duX+VYPde7xyEVZci+/oXKJL13tnRs9lR2pr4fod59GT6/X1/yQ== - -"@types/long@^4.0.1": - version "4.0.2" - resolved "https://registry.yarnpkg.com/@types/long/-/long-4.0.2.tgz#b74129719fc8d11c01868010082d483b7545591a" - integrity sha512-MqTGEo5bj5t157U6fA/BiDynNkn0YknVdh48CMPkTSpFTVmvao5UQmm7uEF6xBEo7qIMAlY/JSleYaE6VOdpaA== - -"@types/node-fetch@^2.1.2": - version "2.6.4" - resolved "https://registry.yarnpkg.com/@types/node-fetch/-/node-fetch-2.6.4.tgz#1bc3a26de814f6bf466b25aeb1473fa1afe6a660" - integrity sha512-1ZX9fcN4Rvkvgv4E6PAY5WXUFWFcRWxZa3EW83UjycOB9ljJCedb2CupIP4RZMEwF/M3eTcCihbBRgwtGbg5Rg== - dependencies: - "@types/node" "*" - form-data "^3.0.0" - -"@types/node@*": - version "17.0.21" - resolved "https://registry.yarnpkg.com/@types/node/-/node-17.0.21.tgz#864b987c0c68d07b4345845c3e63b75edd143644" - integrity sha512-DBZCJbhII3r90XbQxI8Y9IjjiiOGlZ0Hr32omXIZvwwZ7p4DMMXGrKXVyPfuoBOri9XNtL0UK69jYIBIsRX3QQ== - -"@types/offscreencanvas@~2019.3.0": - version "2019.3.0" - resolved "https://registry.yarnpkg.com/@types/offscreencanvas/-/offscreencanvas-2019.3.0.tgz#3336428ec7e9180cf4566dfea5da04eb586a6553" - integrity sha512-esIJx9bQg+QYF0ra8GnvfianIY8qWB0GBx54PK5Eps6m+xTj86KLavHv6qDhzKcu5UUOgNfJ2pWaIIV7TRUd9Q== - -"@types/offscreencanvas@~2019.7.0": - version "2019.7.0" - resolved "https://registry.yarnpkg.com/@types/offscreencanvas/-/offscreencanvas-2019.7.0.tgz#e4a932069db47bb3eabeb0b305502d01586fa90d" - integrity sha512-PGcyveRIpL1XIqK8eBsmRBt76eFgtzuPiSTyKHZxnGemp2yzGzWpjYKAfK3wIMiU7eH+851yEpiuP8JZerTmWg== - -"@types/resolve@0.0.8": - version "0.0.8" - resolved "https://registry.yarnpkg.com/@types/resolve/-/resolve-0.0.8.tgz#f26074d238e02659e323ce1a13d041eee280e194" - integrity sha512-auApPaJf3NPfe18hSoJkp8EbZzer2ISk7o8mCC3M9he/a04+gbMF97NkpD2S8riMGvm4BMRI59/SZQSaLTKpsQ== - dependencies: - "@types/node" "*" - -"@types/resolve@1.17.1": - version "1.17.1" - resolved "https://registry.yarnpkg.com/@types/resolve/-/resolve-1.17.1.tgz#3afd6ad8967c77e4376c598a82ddd58f46ec45d6" - integrity sha512-yy7HuzQhj0dhGpD8RLXSZWEkLsV9ibvxvi6EiJ3bkqLAO1RGo0WbkWQiwpRlSFymTJRz0d3k5LM3kkx8ArDbLw== - dependencies: - "@types/node" "*" - -"@types/seedrandom@^2.4.28": - version "2.4.30" - resolved "https://registry.yarnpkg.com/@types/seedrandom/-/seedrandom-2.4.30.tgz#d2efe425869b84163c2d56e779dddadb9372cbfa" - integrity sha512-AnxLHewubLVzoF/A4qdxBGHCKifw8cY32iro3DQX9TPcetE95zBeVt3jnsvtvAUf1vwzMfwzp4t/L2yqPlnjkQ== - -"@webassemblyjs/ast@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.11.1.tgz#2bfd767eae1a6996f432ff7e8d7fc75679c0b6a7" - integrity sha512-ukBh14qFLjxTQNTXocdyksN5QdM28S1CxHt2rdskFyL+xFV7VremuBLVbmCePj+URalXBENx/9Lm7lnhihtCSw== - dependencies: - "@webassemblyjs/helper-numbers" "1.11.1" - "@webassemblyjs/helper-wasm-bytecode" "1.11.1" - -"@webassemblyjs/floating-point-hex-parser@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/floating-point-hex-parser/-/floating-point-hex-parser-1.11.1.tgz#f6c61a705f0fd7a6aecaa4e8198f23d9dc179e4f" - integrity sha512-iGRfyc5Bq+NnNuX8b5hwBrRjzf0ocrJPI6GWFodBFzmFnyvrQ83SHKhmilCU/8Jv67i4GJZBMhEzltxzcNagtQ== - -"@webassemblyjs/helper-api-error@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-api-error/-/helper-api-error-1.11.1.tgz#1a63192d8788e5c012800ba6a7a46c705288fd16" - integrity sha512-RlhS8CBCXfRUR/cwo2ho9bkheSXG0+NwooXcc3PAILALf2QLdFyj7KGsKRbVc95hZnhnERon4kW/D3SZpp6Tcg== - -"@webassemblyjs/helper-buffer@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-buffer/-/helper-buffer-1.11.1.tgz#832a900eb444884cde9a7cad467f81500f5e5ab5" - integrity sha512-gwikF65aDNeeXa8JxXa2BAk+REjSyhrNC9ZwdT0f8jc4dQQeDQ7G4m0f2QCLPJiMTTO6wfDmRmj/pW0PsUvIcA== - -"@webassemblyjs/helper-numbers@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-numbers/-/helper-numbers-1.11.1.tgz#64d81da219fbbba1e3bd1bfc74f6e8c4e10a62ae" - integrity sha512-vDkbxiB8zfnPdNK9Rajcey5C0w+QJugEglN0of+kmO8l7lDb77AnlKYQF7aarZuCrv+l0UvqL+68gSDr3k9LPQ== - dependencies: - "@webassemblyjs/floating-point-hex-parser" "1.11.1" - "@webassemblyjs/helper-api-error" "1.11.1" - "@xtuc/long" "4.2.2" - -"@webassemblyjs/helper-wasm-bytecode@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-wasm-bytecode/-/helper-wasm-bytecode-1.11.1.tgz#f328241e41e7b199d0b20c18e88429c4433295e1" - integrity sha512-PvpoOGiJwXeTrSf/qfudJhwlvDQxFgelbMqtq52WWiXC6Xgg1IREdngmPN3bs4RoO83PnL/nFrxucXj1+BX62Q== - -"@webassemblyjs/helper-wasm-section@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-wasm-section/-/helper-wasm-section-1.11.1.tgz#21ee065a7b635f319e738f0dd73bfbda281c097a" - integrity sha512-10P9No29rYX1j7F3EVPX3JvGPQPae+AomuSTPiF9eBQeChHI6iqjMIwR9JmOJXwpnn/oVGDk7I5IlskuMwU/pg== - dependencies: - "@webassemblyjs/ast" "1.11.1" - "@webassemblyjs/helper-buffer" "1.11.1" - "@webassemblyjs/helper-wasm-bytecode" "1.11.1" - "@webassemblyjs/wasm-gen" "1.11.1" - -"@webassemblyjs/ieee754@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/ieee754/-/ieee754-1.11.1.tgz#963929e9bbd05709e7e12243a099180812992614" - integrity sha512-hJ87QIPtAMKbFq6CGTkZYJivEwZDbQUgYd3qKSadTNOhVY7p+gfP6Sr0lLRVTaG1JjFj+r3YchoqRYxNH3M0GQ== - dependencies: - "@xtuc/ieee754" "^1.2.0" - -"@webassemblyjs/leb128@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/leb128/-/leb128-1.11.1.tgz#ce814b45574e93d76bae1fb2644ab9cdd9527aa5" - integrity sha512-BJ2P0hNZ0u+Th1YZXJpzW6miwqQUGcIHT1G/sf72gLVD9DZ5AdYTqPNbHZh6K1M5VmKvFXwGSWZADz+qBWxeRw== - dependencies: - "@xtuc/long" "4.2.2" - -"@webassemblyjs/utf8@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/utf8/-/utf8-1.11.1.tgz#d1f8b764369e7c6e6bae350e854dec9a59f0a3ff" - integrity sha512-9kqcxAEdMhiwQkHpkNiorZzqpGrodQQ2IGrHHxCy+Ozng0ofyMA0lTqiLkVs1uzTRejX+/O0EOT7KxqVPuXosQ== - -"@webassemblyjs/wasm-edit@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-edit/-/wasm-edit-1.11.1.tgz#ad206ebf4bf95a058ce9880a8c092c5dec8193d6" - integrity sha512-g+RsupUC1aTHfR8CDgnsVRVZFJqdkFHpsHMfJuWQzWU3tvnLC07UqHICfP+4XyL2tnr1amvl1Sdp06TnYCmVkA== - dependencies: - "@webassemblyjs/ast" "1.11.1" - "@webassemblyjs/helper-buffer" "1.11.1" - "@webassemblyjs/helper-wasm-bytecode" "1.11.1" - "@webassemblyjs/helper-wasm-section" "1.11.1" - "@webassemblyjs/wasm-gen" "1.11.1" - "@webassemblyjs/wasm-opt" "1.11.1" - "@webassemblyjs/wasm-parser" "1.11.1" - "@webassemblyjs/wast-printer" "1.11.1" - -"@webassemblyjs/wasm-gen@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-gen/-/wasm-gen-1.11.1.tgz#86c5ea304849759b7d88c47a32f4f039ae3c8f76" - integrity sha512-F7QqKXwwNlMmsulj6+O7r4mmtAlCWfO/0HdgOxSklZfQcDu0TpLiD1mRt/zF25Bk59FIjEuGAIyn5ei4yMfLhA== - dependencies: - "@webassemblyjs/ast" "1.11.1" - "@webassemblyjs/helper-wasm-bytecode" "1.11.1" - "@webassemblyjs/ieee754" "1.11.1" - "@webassemblyjs/leb128" "1.11.1" - "@webassemblyjs/utf8" "1.11.1" - -"@webassemblyjs/wasm-opt@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-opt/-/wasm-opt-1.11.1.tgz#657b4c2202f4cf3b345f8a4c6461c8c2418985f2" - integrity sha512-VqnkNqnZlU5EB64pp1l7hdm3hmQw7Vgqa0KF/KCNO9sIpI6Fk6brDEiX+iCOYrvMuBWDws0NkTOxYEb85XQHHw== - dependencies: - "@webassemblyjs/ast" "1.11.1" - "@webassemblyjs/helper-buffer" "1.11.1" - "@webassemblyjs/wasm-gen" "1.11.1" - "@webassemblyjs/wasm-parser" "1.11.1" - -"@webassemblyjs/wasm-parser@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-parser/-/wasm-parser-1.11.1.tgz#86ca734534f417e9bd3c67c7a1c75d8be41fb199" - integrity sha512-rrBujw+dJu32gYB7/Lup6UhdkPx9S9SnobZzRVL7VcBH9Bt9bCBLEuX/YXOOtBsOZ4NQrRykKhffRWHvigQvOA== - dependencies: - "@webassemblyjs/ast" "1.11.1" - "@webassemblyjs/helper-api-error" "1.11.1" - "@webassemblyjs/helper-wasm-bytecode" "1.11.1" - "@webassemblyjs/ieee754" "1.11.1" - "@webassemblyjs/leb128" "1.11.1" - "@webassemblyjs/utf8" "1.11.1" - -"@webassemblyjs/wast-printer@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/wast-printer/-/wast-printer-1.11.1.tgz#d0c73beda8eec5426f10ae8ef55cee5e7084c2f0" - integrity sha512-IQboUWM4eKzWW+N/jij2sRatKMh99QEelo3Eb2q0qXkvPRISAj8Qxtmw5itwqK+TTkBuUIE45AxYPToqPtL5gg== - dependencies: - "@webassemblyjs/ast" "1.11.1" - "@xtuc/long" "4.2.2" - -"@webgpu/types@0.1.30": - version "0.1.30" - resolved "https://registry.yarnpkg.com/@webgpu/types/-/types-0.1.30.tgz#b6406dc4a1c1e0d469028ceb30ddffbbd2fa706c" - integrity sha512-9AXJSmL3MzY8ZL//JjudA//q+2kBRGhLBFpkdGksWIuxrMy81nFrCzj2Am+mbh8WoU6rXmv7cY5E3rdlyru2Qg== - -"@webpack-cli/configtest@^1.1.1": - version "1.1.1" - resolved "https://registry.yarnpkg.com/@webpack-cli/configtest/-/configtest-1.1.1.tgz#9f53b1b7946a6efc2a749095a4f450e2932e8356" - integrity sha512-1FBc1f9G4P/AxMqIgfZgeOTuRnwZMten8E7zap5zgpPInnCrP8D4Q81+4CWIch8i/Nf7nXjP0v6CjjbHOrXhKg== - -"@webpack-cli/info@^1.4.1": - version "1.4.1" - resolved "https://registry.yarnpkg.com/@webpack-cli/info/-/info-1.4.1.tgz#2360ea1710cbbb97ff156a3f0f24556e0fc1ebea" - integrity sha512-PKVGmazEq3oAo46Q63tpMr4HipI3OPfP7LiNOEJg963RMgT0rqheag28NCML0o3GIzA3DmxP1ZIAv9oTX1CUIA== - dependencies: - envinfo "^7.7.3" - -"@webpack-cli/serve@^1.6.1": - version "1.6.1" - resolved "https://registry.yarnpkg.com/@webpack-cli/serve/-/serve-1.6.1.tgz#0de2875ac31b46b6c5bb1ae0a7d7f0ba5678dffe" - integrity sha512-gNGTiTrjEVQ0OcVnzsRSqTxaBSr+dmTfm+qJsCDluky8uhdLWep7Gcr62QsAKHTMxjCS/8nEITsmFAhfIx+QSw== - -"@xtuc/ieee754@^1.2.0": - version "1.2.0" - resolved "https://registry.yarnpkg.com/@xtuc/ieee754/-/ieee754-1.2.0.tgz#eef014a3145ae477a1cbc00cd1e552336dceb790" - integrity sha512-DX8nKgqcGwsc0eJSqYt5lwP4DH5FlHnmuWWBRy7X0NcaGR0ZtuyeESgMwTYVEtxmsNGY+qit4QYT/MIYTOTPeA== - -"@xtuc/long@4.2.2": - version "4.2.2" - resolved "https://registry.yarnpkg.com/@xtuc/long/-/long-4.2.2.tgz#d291c6a4e97989b5c61d9acf396ae4fe133a718d" - integrity sha512-NuHqBY1PB/D8xU6s/thBgOAiAP7HOYDQ32+BFZILJ8ivkUkAHQnWfn6WhL79Owj1qmUnoN/YPhktdIoucipkAQ== - -acorn-import-assertions@^1.7.6: - version "1.8.0" - resolved "https://registry.yarnpkg.com/acorn-import-assertions/-/acorn-import-assertions-1.8.0.tgz#ba2b5939ce62c238db6d93d81c9b111b29b855e9" - integrity sha512-m7VZ3jwz4eK6A4Vtt8Ew1/mNbP24u0FhdyfA7fSvnJR6LMdfOYnmuIrrJAgrYfYJ10F/otaHTtrtrtmHdMNzEw== - -acorn@^8.5.0, acorn@^8.7.1: - version "8.8.2" - resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.8.2.tgz#1b2f25db02af965399b9776b0c2c391276d37c4a" - integrity sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw== - -ajv-keywords@^3.5.2: - version "3.5.2" - resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-3.5.2.tgz#31f29da5ab6e00d1c2d329acf7b5929614d5014d" - integrity sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ== - -ajv@^6.12.5: - version "6.12.6" - resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.6.tgz#baf5a62e802b07d977034586f8c3baf5adf26df4" - integrity sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g== - dependencies: - fast-deep-equal "^3.1.1" - fast-json-stable-stringify "^2.0.0" - json-schema-traverse "^0.4.1" - uri-js "^4.2.2" - -ansi-regex@^5.0.1: - version "5.0.1" - resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.1.tgz#082cb2c89c9fe8659a311a53bd6a4dc5301db304" - integrity sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ== - -ansi-styles@^3.2.1: - version "3.2.1" - resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d" - integrity sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA== - dependencies: - color-convert "^1.9.0" - -ansi-styles@^4.0.0, ansi-styles@^4.1.0: - version "4.3.0" - resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-4.3.0.tgz#edd803628ae71c04c85ae7a0906edad34b648937" - integrity sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg== - dependencies: - color-convert "^2.0.1" - -argparse@^1.0.10: - version "1.0.10" - resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911" - integrity sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg== - dependencies: - sprintf-js "~1.0.2" - -asynckit@^0.4.0: - version "0.4.0" - resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" - integrity sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q== - -balanced-match@^1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee" - integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw== - -big.js@^5.2.2: - version "5.2.2" - resolved "https://registry.yarnpkg.com/big.js/-/big.js-5.2.2.tgz#65f0af382f578bcdc742bd9c281e9cb2d7768328" - integrity sha512-vyL2OymJxmarO8gxMr0mhChsO9QGwhynfuu4+MHTAW6czfq9humCB7rKpUjDd9YUiDPU4mzpyupFSvOClAwbmQ== - -brace-expansion@^1.1.7: - version "1.1.11" - resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" - integrity sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA== - dependencies: - balanced-match "^1.0.0" - concat-map "0.0.1" - -browserslist@^4.14.5: - version "4.20.2" - resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.20.2.tgz#567b41508757ecd904dab4d1c646c612cd3d4f88" - integrity sha512-CQOBCqp/9pDvDbx3xfMi+86pr4KXIf2FDkTTdeuYw8OxS9t898LA1Khq57gtufFILXpfgsSx5woNgsBgvGjpsA== - dependencies: - caniuse-lite "^1.0.30001317" - electron-to-chromium "^1.4.84" - escalade "^3.1.1" - node-releases "^2.0.2" - picocolors "^1.0.0" - -buffer-from@^1.0.0: - version "1.1.2" - resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.2.tgz#2b146a6fd72e80b4f55d255f35ed59a3a9a41bd5" - integrity sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ== - -builtin-modules@^3.1.0: - version "3.2.0" - resolved "https://registry.yarnpkg.com/builtin-modules/-/builtin-modules-3.2.0.tgz#45d5db99e7ee5e6bc4f362e008bf917ab5049887" - integrity sha512-lGzLKcioL90C7wMczpkY0n/oART3MbBa8R9OFGE1rJxoVI86u4WAGfEk8Wjv10eKSyTHVGkSo3bvBylCEtk7LA== - -caniuse-lite@^1.0.30001317: - version "1.0.30001317" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001317.tgz#0548fb28fd5bc259a70b8c1ffdbe598037666a1b" - integrity sha512-xIZLh8gBm4dqNX0gkzrBeyI86J2eCjWzYAs40q88smG844YIrN4tVQl/RhquHvKEKImWWFIVh1Lxe5n1G/N+GQ== - -chalk@^2.0.0: - version "2.4.2" - resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" - integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ== - dependencies: - ansi-styles "^3.2.1" - escape-string-regexp "^1.0.5" - supports-color "^5.3.0" - -chalk@^4.1.0: - version "4.1.2" - resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01" - integrity sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA== - dependencies: - ansi-styles "^4.1.0" - supports-color "^7.1.0" - -chrome-trace-event@^1.0.2: - version "1.0.3" - resolved "https://registry.yarnpkg.com/chrome-trace-event/-/chrome-trace-event-1.0.3.tgz#1015eced4741e15d06664a957dbbf50d041e26ac" - integrity sha512-p3KULyQg4S7NIHixdwbGX+nFHkoBiA4YQmyWtjb8XngSKV124nJmRysgAeujbUVb15vh+RvFUfCPqU7rXk+hZg== - -cliui@^7.0.2: - version "7.0.4" - resolved "https://registry.yarnpkg.com/cliui/-/cliui-7.0.4.tgz#a0265ee655476fc807aea9df3df8df7783808b4f" - integrity sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ== - dependencies: - string-width "^4.2.0" - strip-ansi "^6.0.0" - wrap-ansi "^7.0.0" - -clone-deep@^4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/clone-deep/-/clone-deep-4.0.1.tgz#c19fd9bdbbf85942b4fd979c84dcf7d5f07c2387" - integrity sha512-neHB9xuzh/wk0dIHweyAXv2aPGZIVk3pLMe+/RNzINf17fe0OG96QroktYAUm7SM1PBnzTabaLboqqxDyMU+SQ== - dependencies: - is-plain-object "^2.0.4" - kind-of "^6.0.2" - shallow-clone "^3.0.0" - -color-convert@^1.9.0: - version "1.9.3" - resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8" - integrity sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg== - dependencies: - color-name "1.1.3" - -color-convert@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-2.0.1.tgz#72d3a68d598c9bdb3af2ad1e84f21d896abd4de3" - integrity sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ== - dependencies: - color-name "~1.1.4" - -color-name@1.1.3: - version "1.1.3" - resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25" - integrity sha1-p9BVi9icQveV3UIyj3QIMcpTvCU= - -color-name@~1.1.4: - version "1.1.4" - resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2" - integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA== - -colorette@^2.0.14: - version "2.0.16" - resolved "https://registry.yarnpkg.com/colorette/-/colorette-2.0.16.tgz#713b9af84fdb000139f04546bd4a93f62a5085da" - integrity sha512-hUewv7oMjCp+wkBv5Rm0v87eJhq4woh5rSR+42YSQJKecCqgIqNkZ6lAlQms/BwHPJA5NKMRlpxPRv0n8HQW6g== - -combined-stream@^1.0.8: - version "1.0.8" - resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.8.tgz#c3d45a8b34fd730631a110a8a2520682b31d5a7f" - integrity sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg== - dependencies: - delayed-stream "~1.0.0" - -commander@^2.20.0: - version "2.20.3" - resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33" - integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ== - -commander@^7.0.0: - version "7.2.0" - resolved "https://registry.yarnpkg.com/commander/-/commander-7.2.0.tgz#a36cb57d0b501ce108e4d20559a150a391d97ab7" - integrity sha512-QrWXB+ZQSVPmIWIhtEO9H+gwHaMGYiF5ChvoJ+K9ZGHG/sVsa6yiesAD1GC/x46sET00Xlwo1u49RVVVzvcSkw== - -commondir@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/commondir/-/commondir-1.0.1.tgz#ddd800da0c66127393cca5950ea968a3aaf1253b" - integrity sha1-3dgA2gxmEnOTzKWVDqloo6rxJTs= - -concat-map@0.0.1: - version "0.0.1" - resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" - integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s= - -core-js@3.29.1: - version "3.29.1" - resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.29.1.tgz#40ff3b41588b091aaed19ca1aa5cb111803fa9a6" - integrity sha512-+jwgnhg6cQxKYIIjGtAHq2nwUOolo9eoFZ4sHfUH09BLXBgxnH4gA0zEd+t+BO2cNB8idaBtZFcFTRjQJRJmAw== - -cross-spawn@^7.0.3: - version "7.0.3" - resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6" - integrity sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w== - dependencies: - path-key "^3.1.0" - shebang-command "^2.0.0" - which "^2.0.1" - -deep-freeze@^0.0.1: - version "0.0.1" - resolved "https://registry.yarnpkg.com/deep-freeze/-/deep-freeze-0.0.1.tgz#3a0b0005de18672819dfd38cd31f91179c893e84" - integrity sha1-OgsABd4YZygZ39OM0x+RF5yJPoQ= - -deepmerge@^4.2.2: - version "4.2.2" - resolved "https://registry.yarnpkg.com/deepmerge/-/deepmerge-4.2.2.tgz#44d2ea3679b8f4d4ffba33f03d865fc1e7bf4955" - integrity sha512-FJ3UgI4gIl+PHZm53knsuSFpE+nESMr7M4v9QcgB7S63Kj/6WqMiFQJpBBYz1Pt+66bZpP3Q7Lye0Oo9MPKEdg== - -delayed-stream@~1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" - integrity sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ== - -electron-to-chromium@^1.4.84: - version "1.4.85" - resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.85.tgz#a3666ba42147026b9f34d4d8d4caf0740e80f751" - integrity sha512-K9AsQ41WS2bjZUFpRWfvaS4RjEcRCamEkBJN1Z1TQILBfP1H8QnJ9ti0wiLiMv0sRjX3EHKzgs9jDnmGFx2jXg== - -emoji-regex@^8.0.0: - version "8.0.0" - resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37" - integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A== - -emojis-list@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/emojis-list/-/emojis-list-3.0.0.tgz#5570662046ad29e2e916e71aae260abdff4f6a78" - integrity sha512-/kyM18EfinwXZbno9FyUGeFh87KC8HRQBQGildHZbEuRyWFOmv1U10o9BBp8XVZDVNNuQKyIGIu5ZYAAXJ0V2Q== - -enhanced-resolve@^5.10.0: - version "5.12.0" - resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-5.12.0.tgz#300e1c90228f5b570c4d35babf263f6da7155634" - integrity sha512-QHTXI/sZQmko1cbDoNAa3mJ5qhWUUNAq3vR0/YiD379fWQrcfuoX1+HW2S0MTt7XmoPLapdaDKUtelUSPic7hQ== - dependencies: - graceful-fs "^4.2.4" - tapable "^2.2.0" - -envinfo@^7.7.3: - version "7.8.1" - resolved "https://registry.yarnpkg.com/envinfo/-/envinfo-7.8.1.tgz#06377e3e5f4d379fea7ac592d5ad8927e0c4d475" - integrity sha512-/o+BXHmB7ocbHEAs6F2EnG0ogybVVUdkRunTT2glZU9XAaGmhqskrvKwqXuDfNjEO0LZKWdejEEpnq8aM0tOaw== - -es-module-lexer@^0.9.0: - version "0.9.3" - resolved "https://registry.yarnpkg.com/es-module-lexer/-/es-module-lexer-0.9.3.tgz#6f13db00cc38417137daf74366f535c8eb438f19" - integrity sha512-1HQ2M2sPtxwnvOvT1ZClHyQDiggdNjURWpY2we6aMKCQiUVxTmVs2UYPLIrD84sS+kMdUwfBSylbJPwNnBrnHQ== - -escalade@^3.1.1: - version "3.1.1" - resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.1.1.tgz#d8cfdc7000965c5a0174b4a82eaa5c0552742e40" - integrity sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw== - -escape-string-regexp@^1.0.5: - version "1.0.5" - resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" - integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ= - -eslint-scope@5.1.1: - version "5.1.1" - resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-5.1.1.tgz#e786e59a66cb92b3f6c1fb0d508aab174848f48c" - integrity sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw== - dependencies: - esrecurse "^4.3.0" - estraverse "^4.1.1" - -esrecurse@^4.3.0: - version "4.3.0" - resolved "https://registry.yarnpkg.com/esrecurse/-/esrecurse-4.3.0.tgz#7ad7964d679abb28bee72cec63758b1c5d2c9921" - integrity sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag== - dependencies: - estraverse "^5.2.0" - -estraverse@^4.1.1: - version "4.3.0" - resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-4.3.0.tgz#398ad3f3c5a24948be7725e83d11a7de28cdbd1d" - integrity sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw== - -estraverse@^5.2.0: - version "5.3.0" - resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-5.3.0.tgz#2eea5290702f26ab8fe5370370ff86c965d21123" - integrity sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA== - -estree-walker@^0.6.1: - version "0.6.1" - resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-0.6.1.tgz#53049143f40c6eb918b23671d1fe3219f3a1b362" - integrity sha512-SqmZANLWS0mnatqbSfRP5g8OXZC12Fgg1IwNtLsyHDzJizORW4khDfjPqJZsemPWBB2uqykUah5YpQ6epsqC/w== - -estree-walker@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-1.0.1.tgz#31bc5d612c96b704106b477e6dd5d8aa138cb700" - integrity sha512-1fMXF3YP4pZZVozF8j/ZLfvnR8NSIljt56UhbZ5PeeDmmGHpgpdwQt7ITlGvYaQukCvuBRMLEiKiYC+oeIg4cg== - -events@^3.2.0: - version "3.3.0" - resolved "https://registry.yarnpkg.com/events/-/events-3.3.0.tgz#31a95ad0a924e2d2c419a813aeb2c4e878ea7400" - integrity sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q== - -execa@^5.0.0: - version "5.1.1" - resolved "https://registry.yarnpkg.com/execa/-/execa-5.1.1.tgz#f80ad9cbf4298f7bd1d4c9555c21e93741c411dd" - integrity sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg== - dependencies: - cross-spawn "^7.0.3" - get-stream "^6.0.0" - human-signals "^2.1.0" - is-stream "^2.0.0" - merge-stream "^2.0.0" - npm-run-path "^4.0.1" - onetime "^5.1.2" - signal-exit "^3.0.3" - strip-final-newline "^2.0.0" - -fast-deep-equal@^3.1.1: - version "3.1.3" - resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525" - integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q== - -fast-json-stable-stringify@^2.0.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz#874bf69c6f404c2b5d99c481341399fd55892633" - integrity sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw== - -fastest-levenshtein@^1.0.12: - version "1.0.12" - resolved "https://registry.yarnpkg.com/fastest-levenshtein/-/fastest-levenshtein-1.0.12.tgz#9990f7d3a88cc5a9ffd1f1745745251700d497e2" - integrity sha512-On2N+BpYJ15xIC974QNVuYGMOlEVt4s0EOI3wwMqOmK1fdDY+FN/zltPV8vosq4ad4c/gJ1KHScUn/6AWIgiow== - -file-loader@^6.1.0: - version "6.2.0" - resolved "https://registry.yarnpkg.com/file-loader/-/file-loader-6.2.0.tgz#baef7cf8e1840df325e4390b4484879480eebe4d" - integrity sha512-qo3glqyTa61Ytg4u73GultjHGjdRyig3tG6lPtyX/jOEJvHif9uB0/OCI2Kif6ctF3caQTW2G5gym21oAsI4pw== - dependencies: - loader-utils "^2.0.0" - schema-utils "^3.0.0" - -find-up@^4.0.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/find-up/-/find-up-4.1.0.tgz#97afe7d6cdc0bc5928584b7c8d7b16e8a9aa5d19" - integrity sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw== - dependencies: - locate-path "^5.0.0" - path-exists "^4.0.0" - -form-data@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/form-data/-/form-data-3.0.1.tgz#ebd53791b78356a99af9a300d4282c4d5eb9755f" - integrity sha512-RHkBKtLWUVwd7SqRIvCZMEvAMoGUp0XU+seQiZejj0COz3RI3hWP4sCv3gZWWLjJTd7rGwcsF5eKZGii0r/hbg== - dependencies: - asynckit "^0.4.0" - combined-stream "^1.0.8" - mime-types "^2.1.12" - -fs.realpath@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" - integrity sha1-FQStJSMVjKpA20onh8sBQRmU6k8= - -fsevents@~2.3.2: - version "2.3.2" - resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a" - integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA== - -function-bind@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d" - integrity sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A== - -get-caller-file@^2.0.5: - version "2.0.5" - resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e" - integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg== - -get-stream@^6.0.0: - version "6.0.1" - resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-6.0.1.tgz#a262d8eef67aced57c2852ad6167526a43cbf7b7" - integrity sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg== - -glob-to-regexp@^0.4.1: - version "0.4.1" - resolved "https://registry.yarnpkg.com/glob-to-regexp/-/glob-to-regexp-0.4.1.tgz#c75297087c851b9a578bd217dd59a92f59fe546e" - integrity sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw== - -glob@^7.1.2: - version "7.2.0" - resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.0.tgz#d15535af7732e02e948f4c41628bd910293f6023" - integrity sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q== - dependencies: - fs.realpath "^1.0.0" - inflight "^1.0.4" - inherits "2" - minimatch "^3.0.4" - once "^1.3.0" - path-is-absolute "^1.0.0" - -graceful-fs@^4.1.2, graceful-fs@^4.2.4, graceful-fs@^4.2.9: - version "4.2.9" - resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.9.tgz#041b05df45755e587a24942279b9d113146e1c96" - integrity sha512-NtNxqUcXgpW2iMrfqSfR73Glt39K+BLwWsPs94yR63v45T0Wbej7eRmL5cWfwEgqXnmjQp3zaJTshdRW/qC2ZQ== - -has-flag@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd" - integrity sha1-tdRU3CGZriJWmfNGfloH87lVuv0= - -has-flag@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b" - integrity sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ== - -has@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/has/-/has-1.0.3.tgz#722d7cbfc1f6aa8241f16dd814e011e1f41e8796" - integrity sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw== - dependencies: - function-bind "^1.1.1" - -human-signals@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-2.1.0.tgz#dc91fcba42e4d06e4abaed33b3e7a3c02f514ea0" - integrity sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw== - -import-local@^3.0.2: - version "3.1.0" - resolved "https://registry.yarnpkg.com/import-local/-/import-local-3.1.0.tgz#b4479df8a5fd44f6cdce24070675676063c95cb4" - integrity sha512-ASB07uLtnDs1o6EHjKpX34BKYDSqnFerfTOJL2HvMqF70LnxpjkzDB8J44oT9pu4AMPkQwf8jl6szgvNd2tRIg== - dependencies: - pkg-dir "^4.2.0" - resolve-cwd "^3.0.0" - -inflight@^1.0.4: - version "1.0.6" - resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" - integrity sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk= - dependencies: - once "^1.3.0" - wrappy "1" - -inherits@2: - version "2.0.4" - resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" - integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== - -interpret@^2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/interpret/-/interpret-2.2.0.tgz#1a78a0b5965c40a5416d007ad6f50ad27c417df9" - integrity sha512-Ju0Bz/cEia55xDwUWEa8+olFpCiQoypjnQySseKtmjNrnps3P+xfpUmGr90T7yjlVJmOtybRvPXhKMbHr+fWnw== - -is-core-module@^2.8.1: - version "2.8.1" - resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.8.1.tgz#f59fdfca701d5879d0a6b100a40aa1560ce27211" - integrity sha512-SdNCUs284hr40hFTFP6l0IfZ/RSrMXF3qgoRHd3/79unUTvrFO/JoXwkGm+5J/Oe3E/b5GsnG330uUNgRpu1PA== - dependencies: - has "^1.0.3" - -is-docker@^2.0.0: - version "2.2.1" - resolved "https://registry.yarnpkg.com/is-docker/-/is-docker-2.2.1.tgz#33eeabe23cfe86f14bde4408a02c0cfb853acdaa" - integrity sha512-F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ== - -is-fullwidth-code-point@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz#f116f8064fe90b3f7844a38997c0b75051269f1d" - integrity sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg== - -is-module@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/is-module/-/is-module-1.0.0.tgz#3258fb69f78c14d5b815d664336b4cffb6441591" - integrity sha1-Mlj7afeMFNW4FdZkM2tM/7ZEFZE= - -is-plain-object@^2.0.4: - version "2.0.4" - resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-2.0.4.tgz#2c163b3fafb1b606d9d17928f05c2a1c38e07677" - integrity sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og== - dependencies: - isobject "^3.0.1" - -is-reference@^1.1.2: - version "1.2.1" - resolved "https://registry.yarnpkg.com/is-reference/-/is-reference-1.2.1.tgz#8b2dac0b371f4bc994fdeaba9eb542d03002d0b7" - integrity sha512-U82MsXXiFIrjCK4otLT+o2NA2Cd2g5MLoOVXUZjIOhLurrRxpEXzI8O0KZHr3IjLvlAH1kTPYSuqer5T9ZVBKQ== - dependencies: - "@types/estree" "*" - -is-stream@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-2.0.1.tgz#fac1e3d53b97ad5a9d0ae9cef2389f5810a5c077" - integrity sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg== - -is-wsl@^2.1.1: - version "2.2.0" - resolved "https://registry.yarnpkg.com/is-wsl/-/is-wsl-2.2.0.tgz#74a4c76e77ca9fd3f932f290c17ea326cd157271" - integrity sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww== - dependencies: - is-docker "^2.0.0" - -isexe@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" - integrity sha1-6PvzdNxVb/iUehDcsFctYz8s+hA= - -isobject@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/isobject/-/isobject-3.0.1.tgz#4e431e92b11a9731636aa1f9c8d1ccbcfdab78df" - integrity sha1-TkMekrEalzFjaqH5yNHMvP2reN8= - -jest-worker@^26.0.0: - version "26.6.2" - resolved "https://registry.yarnpkg.com/jest-worker/-/jest-worker-26.6.2.tgz#7f72cbc4d643c365e27b9fd775f9d0eaa9c7a8ed" - integrity sha512-KWYVV1c4i+jbMpaBC+U++4Va0cp8OisU185o73T1vo99hqi7w8tSJfUXYswwqqrjzwxa6KpRK54WhPvwf5w6PQ== - dependencies: - "@types/node" "*" - merge-stream "^2.0.0" - supports-color "^7.0.0" - -jest-worker@^27.4.5: - version "27.5.1" - resolved "https://registry.yarnpkg.com/jest-worker/-/jest-worker-27.5.1.tgz#8d146f0900e8973b106b6f73cc1e9a8cb86f8db0" - integrity sha512-7vuh85V5cdDofPyxn58nrPjBktZo0u9x1g8WtjQol+jZDaE+fhN+cIvTj11GndBnMnyfrUOG1sZQxCdjKh+DKg== - dependencies: - "@types/node" "*" - merge-stream "^2.0.0" - supports-color "^8.0.0" - -js-tokens@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" - integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ== - -json-parse-even-better-errors@^2.3.1: - version "2.3.1" - resolved "https://registry.yarnpkg.com/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz#7c47805a94319928e05777405dc12e1f7a4ee02d" - integrity sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w== - -json-schema-traverse@^0.4.1: - version "0.4.1" - resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz#69f6a87d9513ab8bb8fe63bdb0979c448e684660" - integrity sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg== - -json5@^2.1.2: - version "2.2.3" - resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.3.tgz#78cd6f1a19bdc12b73db5ad0c61efd66c1e29283" - integrity sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg== - -kind-of@^6.0.2: - version "6.0.3" - resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.3.tgz#07c05034a6c349fa06e24fa35aa76db4580ce4dd" - integrity sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw== - -loader-runner@^4.2.0: - version "4.2.0" - resolved "https://registry.yarnpkg.com/loader-runner/-/loader-runner-4.2.0.tgz#d7022380d66d14c5fb1d496b89864ebcfd478384" - integrity sha512-92+huvxMvYlMzMt0iIOukcwYBFpkYJdpl2xsZ7LrlayO7E8SOv+JJUEK17B/dJIHAOLMfh2dZZ/Y18WgmGtYNw== - -loader-utils@^2.0.0: - version "2.0.4" - resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-2.0.4.tgz#8b5cb38b5c34a9a018ee1fc0e6a066d1dfcc528c" - integrity sha512-xXqpXoINfFhgua9xiqD8fPFHgkoq1mmmpE92WlDbm9rNRd/EbRb+Gqf908T2DMfuHjjJlksiK2RbHVOdD/MqSw== - dependencies: - big.js "^5.2.2" - emojis-list "^3.0.0" - json5 "^2.1.2" - -locate-path@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-5.0.0.tgz#1afba396afd676a6d42504d0a67a3a7eb9f62aa0" - integrity sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g== - dependencies: - p-locate "^4.1.0" - -long@4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/long/-/long-4.0.0.tgz#9a7b71cfb7d361a194ea555241c92f7468d5bf28" - integrity sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA== - -magic-string@^0.25.2: - version "0.25.9" - resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.25.9.tgz#de7f9faf91ef8a1c91d02c2e5314c8277dbcdd1c" - integrity sha512-RmF0AsMzgt25qzqqLc1+MbHmhdx0ojF2Fvs4XnOqz2ZOBXzzkEwc/dJQZCYHAn7v1jbVOjAZfK8msRn4BxO4VQ== - dependencies: - sourcemap-codec "^1.4.8" - -merge-stream@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/merge-stream/-/merge-stream-2.0.0.tgz#52823629a14dd00c9770fb6ad47dc6310f2c1f60" - integrity sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w== - -mime-db@1.52.0: - version "1.52.0" - resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.52.0.tgz#bbabcdc02859f4987301c856e3387ce5ec43bf70" - integrity sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg== - -mime-types@^2.1.12, mime-types@^2.1.27: - version "2.1.35" - resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.35.tgz#381a871b62a734450660ae3deee44813f70d959a" - integrity sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw== - dependencies: - mime-db "1.52.0" - -mimic-fn@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-2.1.0.tgz#7ed2c2ccccaf84d3ffcb7a69b57711fc2083401b" - integrity sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg== - -minimatch@^3.0.4: - version "3.1.2" - resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b" - integrity sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw== - dependencies: - brace-expansion "^1.1.7" - -minimist@1.2.6: - version "1.2.6" - resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.6.tgz#8637a5b759ea0d6e98702cfb3a9283323c93af44" - integrity sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q== - -nanoid@^3.1.22: - version "3.3.1" - resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.1.tgz#6347a18cac88af88f58af0b3594b723d5e99bb35" - integrity sha512-n6Vs/3KGyxPQd6uO0eH4Bv0ojGSUvuLlIHtC3Y0kEO23YRge8H9x1GCzLn28YX0H66pMkxuaeESFq4tKISKwdw== - -neo-async@^2.6.2: - version "2.6.2" - resolved "https://registry.yarnpkg.com/neo-async/-/neo-async-2.6.2.tgz#b4aafb93e3aeb2d8174ca53cf163ab7d7308305f" - integrity sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw== - -node-fetch@~2.6.1: - version "2.6.12" - resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.12.tgz#02eb8e22074018e3d5a83016649d04df0e348fba" - integrity sha512-C/fGU2E8ToujUivIO0H+tpQ6HWo4eEmchoPIoXtxCrVghxdKq+QOHqEZW7tuP3KlV3bC8FRMO5nMCC7Zm1VP6g== - dependencies: - whatwg-url "^5.0.0" - -node-releases@^2.0.2: - version "2.0.2" - resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-2.0.2.tgz#7139fe71e2f4f11b47d4d2986aaf8c48699e0c01" - integrity sha512-XxYDdcQ6eKqp/YjI+tb2C5WM2LgjnZrfYg4vgQt49EK268b6gYCHsBLrK2qvJo4FmCtqmKezb0WZFK4fkrZNsg== - -npm-run-path@^4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/npm-run-path/-/npm-run-path-4.0.1.tgz#b7ecd1e5ed53da8e37a55e1c2269e0b97ed748ea" - integrity sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw== - dependencies: - path-key "^3.0.0" - -once@^1.3.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" - integrity sha1-WDsap3WWHUsROsF9nFC6753Xa9E= - dependencies: - wrappy "1" - -onetime@^5.1.2: - version "5.1.2" - resolved "https://registry.yarnpkg.com/onetime/-/onetime-5.1.2.tgz#d0e96ebb56b07476df1dd9c4806e5237985ca45e" - integrity sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg== - dependencies: - mimic-fn "^2.1.0" - -open@^7.4.2: - version "7.4.2" - resolved "https://registry.yarnpkg.com/open/-/open-7.4.2.tgz#b8147e26dcf3e426316c730089fd71edd29c2321" - integrity sha512-MVHddDVweXZF3awtlAS+6pgKLlm/JgxZ90+/NBurBoQctVOOB/zDdVjcyPzQ+0laDGbsWgrRkflI65sQeOgT9Q== - dependencies: - is-docker "^2.0.0" - is-wsl "^2.1.1" - -p-limit@^2.2.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-2.3.0.tgz#3dd33c647a214fdfffd835933eb086da0dc21db1" - integrity sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w== - dependencies: - p-try "^2.0.0" - -p-locate@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-4.1.0.tgz#a3428bb7088b3a60292f66919278b7c297ad4f07" - integrity sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A== - dependencies: - p-limit "^2.2.0" - -p-try@^2.0.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/p-try/-/p-try-2.2.0.tgz#cb2868540e313d61de58fafbe35ce9004d5540e6" - integrity sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ== - -path-exists@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-4.0.0.tgz#513bdbe2d3b95d7762e8c1137efa195c6c61b5b3" - integrity sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w== - -path-is-absolute@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" - integrity sha1-F0uSaHNVNP+8es5r9TpanhtcX18= - -path-key@^3.0.0, path-key@^3.1.0: - version "3.1.1" - resolved "https://registry.yarnpkg.com/path-key/-/path-key-3.1.1.tgz#581f6ade658cbba65a0d3380de7753295054f375" - integrity sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q== - -path-parse@^1.0.7: - version "1.0.7" - resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.7.tgz#fbc114b60ca42b30d9daf5858e4bd68bbedb6735" - integrity sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw== - -picocolors@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/picocolors/-/picocolors-1.0.0.tgz#cb5bdc74ff3f51892236eaf79d68bc44564ab81c" - integrity sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ== - -picomatch@^2.2.2: - version "2.3.1" - resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42" - integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA== - -pkg-dir@^4.2.0: - version "4.2.0" - resolved "https://registry.yarnpkg.com/pkg-dir/-/pkg-dir-4.2.0.tgz#f099133df7ede422e81d1d8448270eeb3e4261f3" - integrity sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ== - dependencies: - find-up "^4.0.0" - -punycode@^2.1.0: - version "2.1.1" - resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec" - integrity sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A== - -randombytes@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/randombytes/-/randombytes-2.1.0.tgz#df6f84372f0270dc65cdf6291349ab7a473d4f2a" - integrity sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ== - dependencies: - safe-buffer "^5.1.0" - -rechoir@^0.7.0: - version "0.7.1" - resolved "https://registry.yarnpkg.com/rechoir/-/rechoir-0.7.1.tgz#9478a96a1ca135b5e88fc027f03ee92d6c645686" - integrity sha512-/njmZ8s1wVeR6pjTZ+0nCnv8SpZNRMT2D1RLOJQESlYFDBvwpTA4KWJpZ+sBJ4+vhjILRcK7JIFdGCdxEAAitg== - dependencies: - resolve "^1.9.0" - -regenerator-runtime@^0.13.5: - version "0.13.9" - resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.9.tgz#8925742a98ffd90814988d7566ad30ca3b263b52" - integrity sha512-p3VT+cOEgxFsRRA9X4lkI1E+k2/CtnKtU4gcxyaCUreilL/vqI6CdZ3wxVUx3UOUg+gnUOQQcRI7BmSI656MYA== - -require-directory@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42" - integrity sha1-jGStX9MNqxyXbiNE/+f3kqam30I= - -resolve-cwd@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/resolve-cwd/-/resolve-cwd-3.0.0.tgz#0f0075f1bb2544766cf73ba6a6e2adfebcb13f2d" - integrity sha512-OrZaX2Mb+rJCpH/6CpSqt9xFVpN++x01XnN2ie9g6P5/3xelLAkXWVADpdz1IHD/KFfEXyE6V0U01OQ3UO2rEg== - dependencies: - resolve-from "^5.0.0" - -resolve-from@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-5.0.0.tgz#c35225843df8f776df21c57557bc087e9dfdfc69" - integrity sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw== - -resolve@^1.11.0, resolve@^1.11.1, resolve@^1.17.0, resolve@^1.9.0: - version "1.22.0" - resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.22.0.tgz#5e0b8c67c15df57a89bdbabe603a002f21731198" - integrity sha512-Hhtrw0nLeSrFQ7phPp4OOcVjLPIeMnRlr5mcnVuMe7M/7eBn98A3hmFRLoFo3DLZkivSYwhRUJTyPyWAk56WLw== - dependencies: - is-core-module "^2.8.1" - path-parse "^1.0.7" - supports-preserve-symlinks-flag "^1.0.0" - -rollup-plugin-commonjs@^10.1.0: - version "10.1.0" - resolved "https://registry.yarnpkg.com/rollup-plugin-commonjs/-/rollup-plugin-commonjs-10.1.0.tgz#417af3b54503878e084d127adf4d1caf8beb86fb" - integrity sha512-jlXbjZSQg8EIeAAvepNwhJj++qJWNJw1Cl0YnOqKtP5Djx+fFGkp3WRh+W0ASCaFG5w1jhmzDxgu3SJuVxPF4Q== - dependencies: - estree-walker "^0.6.1" - is-reference "^1.1.2" - magic-string "^0.25.2" - resolve "^1.11.0" - rollup-pluginutils "^2.8.1" - -rollup-plugin-node-resolve@^5.2.0: - version "5.2.0" - resolved "https://registry.yarnpkg.com/rollup-plugin-node-resolve/-/rollup-plugin-node-resolve-5.2.0.tgz#730f93d10ed202473b1fb54a5997a7db8c6d8523" - integrity sha512-jUlyaDXts7TW2CqQ4GaO5VJ4PwwaV8VUGA7+km3n6k6xtOEacf61u0VXwN80phY/evMcaS+9eIeJ9MOyDxt5Zw== - dependencies: - "@types/resolve" "0.0.8" - builtin-modules "^3.1.0" - is-module "^1.0.0" - resolve "^1.11.1" - rollup-pluginutils "^2.8.1" - -rollup-plugin-terser@^6.1.0: - version "6.1.0" - resolved "https://registry.yarnpkg.com/rollup-plugin-terser/-/rollup-plugin-terser-6.1.0.tgz#071866585aea104bfbb9dd1019ac523e63c81e45" - integrity sha512-4fB3M9nuoWxrwm39habpd4hvrbrde2W2GG4zEGPQg1YITNkM3Tqur5jSuXlWNzbv/2aMLJ+dZJaySc3GCD8oDw== - dependencies: - "@babel/code-frame" "^7.8.3" - jest-worker "^26.0.0" - serialize-javascript "^3.0.0" - terser "^4.7.0" - -rollup-plugin-visualizer@^4.0.4: - version "4.2.2" - resolved "https://registry.yarnpkg.com/rollup-plugin-visualizer/-/rollup-plugin-visualizer-4.2.2.tgz#edeb8b3fc6f49b3c95f6cc668f4eba57c6112099" - integrity sha512-10/TsugsaQL5rdynl0lrklBngTtkRBESZdxUJy+3fN+xKqNdg5cr7JQU1OoPx4p5mhQ+nspa6EvX3qc8SsBvnA== - dependencies: - nanoid "^3.1.22" - open "^7.4.2" - source-map "^0.7.3" - yargs "^16.2.0" - -rollup-pluginutils@^2.8.1: - version "2.8.2" - resolved "https://registry.yarnpkg.com/rollup-pluginutils/-/rollup-pluginutils-2.8.2.tgz#72f2af0748b592364dbd3389e600e5a9444a351e" - integrity sha512-EEp9NhnUkwY8aif6bxgovPHMoMoNr2FulJziTndpt5H9RdwC47GSGuII9XxpSdzVGM0GWrNPHV6ie1LTNJPaLQ== - dependencies: - estree-walker "^0.6.1" - -rollup@^2.23.0: - version "2.70.1" - resolved "https://registry.yarnpkg.com/rollup/-/rollup-2.70.1.tgz#824b1f1f879ea396db30b0fc3ae8d2fead93523e" - integrity sha512-CRYsI5EuzLbXdxC6RnYhOuRdtz4bhejPMSWjsFLfVM/7w/85n2szZv6yExqUXsBdz5KT8eoubeyDUDjhLHEslA== - optionalDependencies: - fsevents "~2.3.2" - -safe-buffer@^5.1.0, safe-buffer@~5.2.0: - version "5.2.1" - resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" - integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== - -schema-utils@^3.0.0, schema-utils@^3.1.0, schema-utils@^3.1.1: - version "3.1.1" - resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-3.1.1.tgz#bc74c4b6b6995c1d88f76a8b77bea7219e0c8281" - integrity sha512-Y5PQxS4ITlC+EahLuXaY86TXfR7Dc5lw294alXOq86JAHCihAIZfqv8nNCWvaEJvaC51uN9hbLGeV0cFBdH+Fw== - dependencies: - "@types/json-schema" "^7.0.8" - ajv "^6.12.5" - ajv-keywords "^3.5.2" - -seedrandom@^3.0.5: - version "3.0.5" - resolved "https://registry.yarnpkg.com/seedrandom/-/seedrandom-3.0.5.tgz#54edc85c95222525b0c7a6f6b3543d8e0b3aa0a7" - integrity sha512-8OwmbklUNzwezjGInmZ+2clQmExQPvomqjL7LFqOYqtmuxRgQYqOD3mHaU+MvZn5FLUeVxVfQjwLZW/n/JFuqg== - -serialize-javascript@^3.0.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-3.1.0.tgz#8bf3a9170712664ef2561b44b691eafe399214ea" - integrity sha512-JIJT1DGiWmIKhzRsG91aS6Ze4sFUrYbltlkg2onR5OrnNM02Kl/hnY/T4FN2omvyeBbQmMJv+K4cPOpGzOTFBg== - dependencies: - randombytes "^2.1.0" - -serialize-javascript@^6.0.0: - version "6.0.0" - resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-6.0.0.tgz#efae5d88f45d7924141da8b5c3a7a7e663fefeb8" - integrity sha512-Qr3TosvguFt8ePWqsvRfrKyQXIiW+nGbYpy8XK24NQHE83caxWt+mIymTT19DGFbNWNLfEwsrkSmN64lVWB9ag== - dependencies: - randombytes "^2.1.0" - -shallow-clone@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/shallow-clone/-/shallow-clone-3.0.1.tgz#8f2981ad92531f55035b01fb230769a40e02efa3" - integrity sha512-/6KqX+GVUdqPuPPd2LxDDxzX6CAbjJehAAOKlNpqqUpAqPM6HeL8f+o3a+JsyGjn2lv0WY8UsTgUJjU9Ok55NA== - dependencies: - kind-of "^6.0.2" - -shebang-command@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-2.0.0.tgz#ccd0af4f8835fbdc265b82461aaf0c36663f34ea" - integrity sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA== - dependencies: - shebang-regex "^3.0.0" - -shebang-regex@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-3.0.0.tgz#ae16f1644d873ecad843b0307b143362d4c42172" - integrity sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A== - -signal-exit@^3.0.3: - version "3.0.7" - resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.7.tgz#a9a1767f8af84155114eaabd73f99273c8f59ad9" - integrity sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ== - -slash@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/slash/-/slash-3.0.0.tgz#6539be870c165adbd5240220dbe361f1bc4d4634" - integrity sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q== - -source-map-support@~0.5.12, source-map-support@~0.5.20: - version "0.5.21" - resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.21.tgz#04fe7c7f9e1ed2d662233c28cb2b35b9f63f6e4f" - integrity sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w== - dependencies: - buffer-from "^1.0.0" - source-map "^0.6.0" - -source-map@^0.6.0, source-map@^0.6.1, source-map@~0.6.1: - version "0.6.1" - resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" - integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== - -source-map@^0.7.3, source-map@~0.7.2: - version "0.7.3" - resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.7.3.tgz#5302f8169031735226544092e64981f751750383" - integrity sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ== - -sourcemap-codec@^1.4.8: - version "1.4.8" - resolved "https://registry.yarnpkg.com/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz#ea804bd94857402e6992d05a38ef1ae35a9ab4c4" - integrity sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA== - -sprintf-js@~1.0.2: - version "1.0.3" - resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" - integrity sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw= - -string-width@^4.1.0, string-width@^4.2.0: - version "4.2.3" - resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" - integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== - dependencies: - emoji-regex "^8.0.0" - is-fullwidth-code-point "^3.0.0" - strip-ansi "^6.0.1" - -string_decoder@^1.3.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.3.0.tgz#42f114594a46cf1a8e30b0a84f56c78c3edac21e" - integrity sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA== - dependencies: - safe-buffer "~5.2.0" - -strip-ansi@^6.0.0, strip-ansi@^6.0.1: - version "6.0.1" - resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" - integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== - dependencies: - ansi-regex "^5.0.1" - -strip-final-newline@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/strip-final-newline/-/strip-final-newline-2.0.0.tgz#89b852fb2fcbe936f6f4b3187afb0a12c1ab58ad" - integrity sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA== - -supports-color@^5.3.0: - version "5.5.0" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f" - integrity sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow== - dependencies: - has-flag "^3.0.0" - -supports-color@^7.0.0, supports-color@^7.1.0: - version "7.2.0" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-7.2.0.tgz#1b7dcdcb32b8138801b3e478ba6a51caa89648da" - integrity sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw== - dependencies: - has-flag "^4.0.0" - -supports-color@^8.0.0: - version "8.1.1" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-8.1.1.tgz#cd6fc17e28500cff56c1b86c0a7fd4a54a73005c" - integrity sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q== - dependencies: - has-flag "^4.0.0" - -supports-preserve-symlinks-flag@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz#6eda4bd344a3c94aea376d4cc31bc77311039e09" - integrity sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w== - -tapable@^2.1.1, tapable@^2.2.0: - version "2.2.1" - resolved "https://registry.yarnpkg.com/tapable/-/tapable-2.2.1.tgz#1967a73ef4060a82f12ab96af86d52fdb76eeca0" - integrity sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ== - -terser-webpack-plugin@^5.1.3, terser-webpack-plugin@^5.3.1: - version "5.3.1" - resolved "https://registry.yarnpkg.com/terser-webpack-plugin/-/terser-webpack-plugin-5.3.1.tgz#0320dcc270ad5372c1e8993fabbd927929773e54" - integrity sha512-GvlZdT6wPQKbDNW/GDQzZFg/j4vKU96yl2q6mcUkzKOgW4gwf1Z8cZToUCrz31XHlPWH8MVb1r2tFtdDtTGJ7g== - dependencies: - jest-worker "^27.4.5" - schema-utils "^3.1.1" - serialize-javascript "^6.0.0" - source-map "^0.6.1" - terser "^5.7.2" - -terser@^4.7.0: - version "4.8.1" - resolved "https://registry.yarnpkg.com/terser/-/terser-4.8.1.tgz#a00e5634562de2239fd404c649051bf6fc21144f" - integrity sha512-4GnLC0x667eJG0ewJTa6z/yXrbLGv80D9Ru6HIpCQmO+Q4PfEtBFi0ObSckqwL6VyQv/7ENJieXHo2ANmdQwgw== - dependencies: - commander "^2.20.0" - source-map "~0.6.1" - source-map-support "~0.5.12" - -terser@^5.7.2: - version "5.12.1" - resolved "https://registry.yarnpkg.com/terser/-/terser-5.12.1.tgz#4cf2ebed1f5bceef5c83b9f60104ac4a78b49e9c" - integrity sha512-NXbs+7nisos5E+yXwAD+y7zrcTkMqb0dEJxIGtSKPdCBzopf7ni4odPul2aechpV7EXNvOudYOX2bb5tln1jbQ== - dependencies: - acorn "^8.5.0" - commander "^2.20.0" - source-map "~0.7.2" - source-map-support "~0.5.20" - -tr46@~0.0.3: - version "0.0.3" - resolved "https://registry.yarnpkg.com/tr46/-/tr46-0.0.3.tgz#8184fd347dac9cdc185992f3a6622e14b9d9ab6a" - integrity sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw== - -uri-js@^4.2.2: - version "4.4.1" - resolved "https://registry.yarnpkg.com/uri-js/-/uri-js-4.4.1.tgz#9b1a52595225859e55f669d928f88c6c57f2a77e" - integrity sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg== - dependencies: - punycode "^2.1.0" - -watchpack@^2.4.0: - version "2.4.0" - resolved "https://registry.yarnpkg.com/watchpack/-/watchpack-2.4.0.tgz#fa33032374962c78113f93c7f2fb4c54c9862a5d" - integrity sha512-Lcvm7MGST/4fup+ifyKi2hjyIAwcdI4HRgtvTpIUxBRhB+RFtUh8XtDOxUfctVCnhVi+QQj49i91OyvzkJl6cg== - dependencies: - glob-to-regexp "^0.4.1" - graceful-fs "^4.1.2" - -webidl-conversions@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871" - integrity sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ== - -webpack-cli@^4.9.2: - version "4.9.2" - resolved "https://registry.yarnpkg.com/webpack-cli/-/webpack-cli-4.9.2.tgz#77c1adaea020c3f9e2db8aad8ea78d235c83659d" - integrity sha512-m3/AACnBBzK/kMTcxWHcZFPrw/eQuY4Df1TxvIWfWM2x7mRqBQCqKEd96oCUa9jkapLBaFfRce33eGDb4Pr7YQ== - dependencies: - "@discoveryjs/json-ext" "^0.5.0" - "@webpack-cli/configtest" "^1.1.1" - "@webpack-cli/info" "^1.4.1" - "@webpack-cli/serve" "^1.6.1" - colorette "^2.0.14" - commander "^7.0.0" - execa "^5.0.0" - fastest-levenshtein "^1.0.12" - import-local "^3.0.2" - interpret "^2.2.0" - rechoir "^0.7.0" - webpack-merge "^5.7.3" - -webpack-merge@^5.7.3: - version "5.8.0" - resolved "https://registry.yarnpkg.com/webpack-merge/-/webpack-merge-5.8.0.tgz#2b39dbf22af87776ad744c390223731d30a68f61" - integrity sha512-/SaI7xY0831XwP6kzuwhKWVKDP9t1QY1h65lAFLbZqMPIuYcD9QAW4u9STIbU9kaJbPBB/geU/gLr1wDjOhQ+Q== - dependencies: - clone-deep "^4.0.1" - wildcard "^2.0.0" - -webpack-sources@^3.2.3: - version "3.2.3" - resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-3.2.3.tgz#2d4daab8451fd4b240cc27055ff6a0c2ccea0cde" - integrity sha512-/DyMEOrDgLKKIG0fmvtz+4dUX/3Ghozwgm6iPp8KRhvn+eQf9+Q7GWxVNMk3+uCPWfdXYC4ExGBckIXdFEfH1w== - -webpack@^5.76.0: - version "5.76.0" - resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.76.0.tgz#f9fb9fb8c4a7dbdcd0d56a98e56b8a942ee2692c" - integrity sha512-l5sOdYBDunyf72HW8dF23rFtWq/7Zgvt/9ftMof71E/yUb1YLOBmTgA2K4vQthB3kotMrSj609txVE0dnr2fjA== - dependencies: - "@types/eslint-scope" "^3.7.3" - "@types/estree" "^0.0.51" - "@webassemblyjs/ast" "1.11.1" - "@webassemblyjs/wasm-edit" "1.11.1" - "@webassemblyjs/wasm-parser" "1.11.1" - acorn "^8.7.1" - acorn-import-assertions "^1.7.6" - browserslist "^4.14.5" - chrome-trace-event "^1.0.2" - enhanced-resolve "^5.10.0" - es-module-lexer "^0.9.0" - eslint-scope "5.1.1" - events "^3.2.0" - glob-to-regexp "^0.4.1" - graceful-fs "^4.2.9" - json-parse-even-better-errors "^2.3.1" - loader-runner "^4.2.0" - mime-types "^2.1.27" - neo-async "^2.6.2" - schema-utils "^3.1.0" - tapable "^2.1.1" - terser-webpack-plugin "^5.1.3" - watchpack "^2.4.0" - webpack-sources "^3.2.3" - -whatwg-url@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-5.0.0.tgz#966454e8765462e37644d3626f6742ce8b70965d" - integrity sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw== - dependencies: - tr46 "~0.0.3" - webidl-conversions "^3.0.0" - -which@^2.0.1: - version "2.0.2" - resolved "https://registry.yarnpkg.com/which/-/which-2.0.2.tgz#7c6a8dd0a636a0327e10b59c9286eee93f3f51b1" - integrity sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA== - dependencies: - isexe "^2.0.0" - -wildcard@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/wildcard/-/wildcard-2.0.0.tgz#a77d20e5200c6faaac979e4b3aadc7b3dd7f8fec" - integrity sha512-JcKqAHLPxcdb9KM49dufGXn2x3ssnfjbcaQdLlfZsL9rH9wgDQjUtDxbo8NE0F6SFvydeu1VhZe7hZuHsB2/pw== - -wrap-ansi@^7.0.0: - version "7.0.0" - resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" - integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== - dependencies: - ansi-styles "^4.0.0" - string-width "^4.1.0" - strip-ansi "^6.0.0" - -wrappy@1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" - integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8= - -y18n@^5.0.5: - version "5.0.8" - resolved "https://registry.yarnpkg.com/y18n/-/y18n-5.0.8.tgz#7f4934d0f7ca8c56f95314939ddcd2dd91ce1d55" - integrity sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA== - -yargs-parser@^20.2.2: - version "20.2.9" - resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.9.tgz#2eb7dc3b0289718fc295f362753845c41a0c94ee" - integrity sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w== - -yargs@^16.0.3, yargs@^16.2.0: - version "16.2.0" - resolved "https://registry.yarnpkg.com/yargs/-/yargs-16.2.0.tgz#1c82bf0f6b6a66eafce7ef30e376f49a12477f66" - integrity sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw== - dependencies: - cliui "^7.0.2" - escalade "^3.1.1" - get-caller-file "^2.0.5" - require-directory "^2.1.1" - string-width "^4.2.0" - y18n "^5.0.5" - yargs-parser "^20.2.2" diff --git a/tfjs-master/e2e/integration_tests/backends_test.ts b/tfjs-master/e2e/integration_tests/backends_test.ts deleted file mode 100644 index b3cc7630a..000000000 --- a/tfjs-master/e2e/integration_tests/backends_test.ts +++ /dev/null @@ -1,204 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import '@tensorflow/tfjs-backend-cpu'; -import '@tensorflow/tfjs-backend-webgl'; -import '@tensorflow/tfjs-backend-webgpu'; - -import * as tfc from '@tensorflow/tfjs-core'; -// tslint:disable-next-line: no-imports-from-dist -import {describeWithFlags} from '@tensorflow/tfjs-core/dist/jasmine_util'; - -import {SMOKE} from './constants'; - -/** - * This file tests backend switching scenario. - */ -// TODO: Support backend switching between wasm and cpu. -// https://github.com/tensorflow/tfjs/issues/7623 -describeWithFlags( - `${SMOKE} backend switching`, { - predicate: testEnv => - testEnv.backendName !== 'cpu' && testEnv.backendName !== 'wasm' - }, - - (env) => { - it(`from ${env.name} to cpu.`, async () => { - await tfc.setBackend(env.name); - - const backendBefore = tfc.engine().backend.numDataIds(); - - const input = tfc.tensor2d([1, 1, 1, 1], [2, 2], 'float32'); - // input is stored in backend. - - const inputReshaped = tfc.reshape(input, [2, 2]); - - const backendAfter = tfc.engine().backend.numDataIds(); - - expect(backendAfter).toEqual(backendBefore + 1); - - await tfc.setBackend('cpu'); - - const cpuBefore = tfc.engine().backend.numDataIds(); - - const inputReshaped2 = tfc.reshape(inputReshaped, [2, 2]); - // input moved to cpu. - - // Because input is moved to cpu, data should be deleted from backend. - expect(tfc.findBackend(env.name).numDataIds()) - .toEqual(backendAfter - 1); - - const cpuAfter = tfc.engine().backend.numDataIds(); - - expect(cpuAfter).toEqual(cpuBefore + 1); - - input.dispose(); - expect(tfc.engine().backend.numDataIds()).toEqual(cpuAfter); - - inputReshaped.dispose(); - - expect(tfc.engine().backend.numDataIds()).toEqual(cpuAfter); - - inputReshaped2.dispose(); - - const after = tfc.engine().backend.numDataIds(); - - expect(after).toBe(cpuBefore); - }); - - it(`from cpu to ${env.name}.`, async () => { - await tfc.setBackend('cpu'); - - const cpuBefore = tfc.engine().backend.numDataIds(); - - const input = tfc.tensor2d([1, 1, 1, 1], [2, 2], 'float32'); - // input is stored in cpu backend. - - const inputReshaped = tfc.reshape(input, [2, 2]); - - const cpuAfter = tfc.engine().backend.numDataIds(); - - expect(cpuAfter).toEqual(cpuBefore + 1); - - await tfc.setBackend(env.name); - - const backendBefore = tfc.engine().backend.numDataIds(); - - const inputReshaped2 = tfc.reshape(inputReshaped, [2, 2]); - // input moved to webgl or webgpu. - - // Because input is moved to backend, data should be deleted - // from cpu. - expect(tfc.findBackend('cpu').numDataIds()).toEqual(cpuAfter - 1); - - const backendAfter = tfc.engine().backend.numDataIds(); - - expect(backendAfter).toEqual(backendBefore + 1); - - input.dispose(); - - expect(tfc.engine().backend.numDataIds()).toEqual(backendAfter); - - inputReshaped.dispose(); - - expect(tfc.engine().backend.numDataIds()).toEqual(backendAfter); - - inputReshaped2.dispose(); - - const after = tfc.engine().backend.numDataIds(); - - expect(after).toBe(backendBefore); - }); - - it('can execute op with data from mixed backends', async () => { - const numTensors = tfc.memory().numTensors; - const backendNumDataIds = tfc.findBackend(env.name).numDataIds(); - const cpuNumDataIds = tfc.findBackend('cpu').numDataIds(); - - await tfc.setBackend('cpu'); - // This scalar lives in cpu. - const a = tfc.scalar(5); - - await tfc.setBackend(env.name); - // This scalar lives in webgl or webgpu. - const b = tfc.scalar(3); - - // Verify that ops can execute with mixed backend data. - tfc.engine().startScope(); - - await tfc.setBackend('cpu'); - const result = tfc.add(a, b); - tfc.test_util.expectArraysClose(await result.data(), [8]); - expect(tfc.findBackend('cpu').numDataIds()).toBe(cpuNumDataIds + 3); - - await tfc.setBackend(env.name); - tfc.test_util.expectArraysClose(await tfc.add(a, b).data(), [8]); - expect(tfc.findBackend(env.name).numDataIds()) - .toBe(backendNumDataIds + 3); - - tfc.engine().endScope(); - - expect(tfc.memory().numTensors).toBe(numTensors + 2); - expect(tfc.findBackend(env.name).numDataIds()) - .toBe(backendNumDataIds + 2); - expect(tfc.findBackend('cpu').numDataIds()).toBe(cpuNumDataIds); - - tfc.dispose([a, b]); - - expect(tfc.memory().numTensors).toBe(numTensors); - expect(tfc.findBackend(env.name).numDataIds()).toBe(backendNumDataIds); - expect(tfc.findBackend('cpu').numDataIds()).toBe(cpuNumDataIds); - }); - - // tslint:disable-next-line: ban - xit(`can move complex tensor from cpu to ${env.name}.`, async () => { - await tfc.setBackend('cpu'); - - const real1 = tfc.tensor1d([1]); - const imag1 = tfc.tensor1d([2]); - const complex1 = tfc.complex(real1, imag1); - - await tfc.setBackend(env.name); - - const real2 = tfc.tensor1d([3]); - const imag2 = tfc.tensor1d([4]); - const complex2 = tfc.complex(real2, imag2); - - const result = complex1.add(complex2); - - tfc.test_util.expectArraysClose(await result.data(), [4, 6]); - }); - - // tslint:disable-next-line: ban - xit(`can move complex tensor from ${env.name} to cpu.`, async () => { - await tfc.setBackend(env.name); - - const real1 = tfc.tensor1d([1]); - const imag1 = tfc.tensor1d([2]); - const complex1 = tfc.complex(real1, imag1); - - await tfc.setBackend('cpu'); - - const real2 = tfc.tensor1d([3]); - const imag2 = tfc.tensor1d([4]); - const complex2 = tfc.complex(real2, imag2); - - const result = complex1.add(complex2); - - tfc.test_util.expectArraysClose(await result.data(), [4, 6]); - }); - }); diff --git a/tfjs-master/e2e/integration_tests/constants.ts b/tfjs-master/e2e/integration_tests/constants.ts deleted file mode 100644 index e6cba15c0..000000000 --- a/tfjs-master/e2e/integration_tests/constants.ts +++ /dev/null @@ -1,50 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -/** Smoke tests run in PR and nightly builds. */ -export const SMOKE = '#SMOKE'; -/** Regression tests run in nightly builds. */ -export const REGRESSION = '#REGRESSION'; -// TODO: Make golden tests part of regression tests. -/** Golden regression tests */ -export const GOLDEN = '#GOLDEN'; - -/** Testing tags. */ -export const TAGS = [SMOKE, REGRESSION, GOLDEN]; - -/** Testing backends. */ -export const BACKENDS = ['cpu', 'webgl', 'webgpu']; - -/** Testing models for CUJ: create -> save -> predict. */ -export const LAYERS_MODELS = [ - 'mlp', 'cnn', 'depthwise_cnn', 'simple_rnn', 'gru', 'bidirectional_lstm', - 'time_distributed_lstm', 'one_dimensional', 'functional_merge' -]; - -export const CONVERT_PREDICT_MODELS = { - graph_model: [ - 'saved_model_v1', 'saved_model_v2', 'saved_model_v2_with_control_flow', - 'saved_model_with_conv2d', 'saved_model_with_prelu', - 'saved_model_v2_complex64', 'saved_model_v2_with_control_flow_v2', - 'saved_model_v2_with_tensorlist_ops', 'saved_model_v1_with_hashtable', - 'saved_model_v2_with_hashtable' - ], - layers_model: ['mobilenet'] -}; - -/** Karma server directory serving local files. */ -export const KARMA_SERVER = './base/integration_tests'; diff --git a/tfjs-master/e2e/integration_tests/convert_predict.py b/tfjs-master/e2e/integration_tests/convert_predict.py deleted file mode 100644 index a44b96aaa..000000000 --- a/tfjs-master/e2e/integration_tests/convert_predict.py +++ /dev/null @@ -1,520 +0,0 @@ -# @license -# Copyright 2019 Google LLC. All Rights Reserved. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================= - -# This file is 1/2 of the test suites for CUJ: convert->predict. -# -# This file does below things: -# - Create saved models with TensorFlow. -# - Convert the saved models to tfjs format and store in files. -# - Store inputs in files. -# - Make inference and store outputs in files. - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -import argparse -import functools -import json -import os -import subprocess -import shutil -import sys -import tempfile -import time - -import numpy as np -import tensorflow as tf -from tensorflow.python.eager import def_function -from tensorflow.python.framework import constant_op -from tensorflow.python.framework import dtypes -from tensorflow.python.framework import tensor_spec -from tensorflow.python.ops import variables -from tensorflow.python.trackable import autotrackable -from tensorflow.python.saved_model.save import save -import tensorflow_hub as hub -import tensorflowjs as tfjs - -curr_dir = os.path.dirname(os.path.realpath(__file__)) -_tmp_dir = os.path.join(curr_dir, 'convert_predict_data') - -def _save_and_convert_model(model_fn, model_path, control_flow_v2=False): - """Benchmark a model's fit() and predict() calls; serialize the model. - - Args: - model_fn: A function that creates the saved model. - model_path: Path to construct files related to the model. - - Returns: - predict task_log hash that specifies the inputs and outputs for - validation test. - """ - # Generate model, inputs, and outputs using Tensorflow. - tmp_saved_model_dir = tempfile.mkdtemp() - model_info = model_fn(tmp_saved_model_dir) - - # Write inputs to file. - xs_data = [] - xs_shape = [] - xs_dtype = [] - xs_names = [] - keys = model_info['inputs'].keys() - for key in keys: - xs_names.append(key) - xs_data.append(model_info['inputs'][key]['value']) - xs_shape.append(model_info['inputs'][key]['shape']) - xs_dtype.append(model_info['inputs'][key]['dtype']) - - xs_name_path = os.path.join(_tmp_dir, model_path + '.xs-name.json') - xs_shape_path = os.path.join(_tmp_dir, model_path + '.xs-shapes.json') - xs_data_path = os.path.join(_tmp_dir, model_path + '.xs-data.json') - xs_dtype_path = os.path.join(_tmp_dir, model_path + '.xs-dtype.json') - with open(xs_name_path, 'w') as f: - f.write(json.dumps(xs_names)) - with open(xs_data_path, 'w') as f: - f.write(json.dumps(xs_data)) - with open(xs_shape_path, 'w') as f: - f.write(json.dumps(xs_shape)) - with open(xs_dtype_path, 'w') as f: - f.write(json.dumps(xs_dtype)) - # Write outputs to file. - ys_data = [] - ys_shape = [] - ys_dtype = [] - ys_names = [] - keys = model_info['outputs'].keys() - for key in keys: - ys_names.append(key) - ys_data.append(model_info['outputs'][key]['value']) - ys_shape.append(model_info['outputs'][key]['shape']) - ys_dtype.append(model_info['outputs'][key]['dtype']) - - ys_name_path = os.path.join(_tmp_dir, model_path + '.ys-name.json') - ys_data_path = os.path.join(_tmp_dir, model_path + '.ys-data.json') - ys_shape_path = os.path.join(_tmp_dir, model_path + '.ys-shapes.json') - ys_dtype_path = os.path.join(_tmp_dir, model_path + '.ys-dtype.json') - with open(ys_name_path, 'w') as f: - f.write(json.dumps(ys_names)) - with open(ys_data_path, 'w') as f: - f.write(json.dumps(ys_data)) - with open(ys_shape_path, 'w') as f: - f.write(json.dumps(ys_shape)) - with open(ys_dtype_path, 'w') as f: - f.write(json.dumps(ys_dtype)) - artifacts_dir = os.path.join(_tmp_dir, model_path) - - # Convert and store model to file. - args = [ - 'tensorflowjs_converter', - '--input_format', 'tf_saved_model', - '--output_format', 'tfjs_graph_model', - '--signature_name', 'serving_default', - '--saved_model_tags', 'serve']; - if control_flow_v2: - args = args + ['--control_flow_v2', 'True'] - - print(args, tmp_saved_model_dir, artifacts_dir) - subprocess.check_output(args +[tmp_saved_model_dir, artifacts_dir]) - -def _create_saved_model_v1(save_dir): - """Create a TensorFlow V1 SavedModel for testing. - - Args: - save_dir: directory name of where the saved model will be stored. - """ - - graph = tf.Graph() - with graph.as_default(): - input = tf.compat.v1.placeholder(tf.float32, shape=[2, 2]) - w = tf.compat.v1.get_variable('w', shape=[2, 2]) - output = tf.compat.v1.matmul(input, w) - init_op = w.initializer - - # Create a builder. - builder = tf.compat.v1.saved_model.builder.SavedModelBuilder(save_dir) - - with tf.compat.v1.Session() as sess: - # Run the initializer on `w`. - sess.run(init_op) - output_val = sess.run(output, {input: [[1, 1], [1, 1]]}) - builder.add_meta_graph_and_variables( - sess, [tf.compat.v1.saved_model.tag_constants.SERVING], - signature_def_map={ - "serving_default": - tf.compat.v1.saved_model \ - .signature_def_utils.predict_signature_def( - inputs={"input": input}, - outputs={"output": output}) - }, - assets_collection=None) - - builder.save() - return { - "async": False, - "inputs": { - "Placeholder": { - "value": [[1, 1], [1, 1]], "shape": [2, 2], "dtype": 'float32' - } - }, - "outputs": { - "MatMul": { - "value": output_val.tolist(), "shape": [2, 2], "dtype": "float32" - } - } - } - -def _create_saved_model_v2(save_dir): - """Test a basic TF V2 model with functions to make sure functions are inlined. - - Args: - save_dir: directory name of where the saved model will be stored. - """ - input_data = constant_op.constant(1., shape=[1]) - root = autotrackable.AutoTrackable() - root.v1 = variables.Variable(3.) - root.v2 = variables.Variable(2.) - root.f = def_function.function(lambda x: root.v1 * root.v2 * x) - to_save = root.f.get_concrete_function(input_data) - - save(root, save_dir, to_save) - return { - "async": False, - "inputs": { - "x": {"value": [1], "shape": [1], "dtype": 'float32'}}, - "outputs": { - "Identity:0": {"value": [6], "shape": [1], "dtype": "float32"}}} - - -def _create_saved_model_v2_with_control_flow(save_dir): - """Test a basic TF v2 model with control flow to inlined. - - Args: - save_dir: directory name of where the saved model will be stored. - """ - @tf.function - def square_if_positive(v): - if v > 0: - v = v * v - else: - v = v + 1 - return v - - root = autotrackable.AutoTrackable() - root.f = square_if_positive - to_save = root.f.get_concrete_function( - tensor_spec.TensorSpec([], dtypes.float32)) - - save(root, save_dir, to_save) - print(square_if_positive(tf.constant(-2))) - print(square_if_positive(tf.constant(3))) - print(to_save.structured_input_signature) - print(to_save.structured_outputs) - return { - "async": True, - "inputs": {"v": {"value": 3, "shape": [], "dtype": 'float32'}}, - "outputs": {"Identity:0": {"value": [9], "shape": [], "dtype": "float32"}}} - -def _create_saved_model_with_conv2d(save_dir): - """Test a basic model with fusable conv2d. - Args: - save_dir: directory name of where the saved model will be stored. - """ - layers = [ - tf.keras.layers.Conv2D( - 16, [3, 3], padding='same', use_bias=False), - tf.keras.layers.BatchNormalization(), - tf.keras.layers.ReLU() - ] - model = tf.keras.Sequential(layers) - result = model.predict(tf.ones((1, 24, 24, 3))) - # set the learning phase to avoid keara learning placeholder, which - # will cause error when saving. - tf.keras.backend.set_learning_phase(0) - tf.saved_model.save(model, save_dir) - return { - "async": False, - "inputs": { - "conv2d_input:0": {"value": np.ones((1, 24, 24, 3)).tolist(), - "shape": [1, 24, 24, 3], - "dtype": 'float32'}}, - "outputs": { - "Identity:0": {"value": result.tolist(), - "shape": result.shape, - "dtype": "float32"}}} - - -def _create_saved_model_with_prelu(save_dir): - """Test a basic model with prelu activation. - Args: - save_dir: directory name of where the saved model will be stored. - """ - # set the bias and alpha intitialize to make them constant and ensure grappler - # be able to fuse the op. - layers = [ - tf.keras.layers.Conv2D( - 16, [3, 3], padding='same', use_bias=True, - bias_initializer=tf.initializers.constant(0.25)), - tf.keras.layers.PReLU(alpha_initializer=tf.initializers.constant(0.25)) - ] - model = tf.keras.Sequential(layers) - result = model.predict(tf.ones((1, 24, 24, 3))) - tf.keras.backend.set_learning_phase(0) - tf.saved_model.save(model, save_dir) - return { - "async": False, - "inputs": { - "conv2d_1_input": {"value": np.ones((1, 24, 24, 3)).tolist(), - "shape": [1, 24, 24, 3], - "dtype": 'float32'}}, - "outputs": { - "Identity:0": {"value": result.tolist(), - "shape": result.shape, - "dtype": "float32"}}} - -def _create_saved_model_v2_complex64(save_dir): - """Test a TF V2 model with complex dtype. - - Args: - save_dir: directory name of where the saved model will be stored. - """ - input_data = constant_op.constant(1., shape=[1]) - root = autotrackable.AutoTrackable() - root.v1 = variables.Variable(3 + 1j, dtype=tf.complex64) - root.f = def_function.function(lambda x: tf.complex(x, x) + root.v1) - to_save = root.f.get_concrete_function(input_data) - - save(root, save_dir, to_save) - return { - "async": False, - "inputs": { - "x": {"value": [1], "shape": [1], "dtype": 'float32'}}, - "outputs": { - "Identity:0": {"value": [4, 2], "shape": [1], "dtype": "complex64"}}} - -def _create_saved_model_v2_with_control_flow_v2(save_dir): - """Test a TF V2 model with control flow v2. - - Args: - save_dir: directory name of where the saved model will be stored. - """ - class CustomModule(tf.Module): - - def __init__(self): - super(CustomModule, self).__init__() - - @tf.function(input_signature=[tf.TensorSpec([], tf.int32), - tf.TensorSpec([], tf.int32), - tf.TensorSpec([], tf.int32)]) - def control_flow(self, x, y, z): - i = 0 - while i < z: - i += 1 - j = 0 - while j < y: - j += 1 - if z > 0: - x += 1 - else: - x += 2 - return x - - - module = CustomModule() - print(module.control_flow(0, 2, 10)) - tf.saved_model.save(module, save_dir, - signatures=module.control_flow) - - return { - "async": False, - "inputs": { - "x": {"value": [0], "shape": [], "dtype": 'int32'}, - "y": {"value": [2], "shape": [], "dtype": 'int32'}, - "z": {"value": [10], "shape": [], "dtype": 'int32'}}, - "outputs": { - "Identity:0": {"value": [20], "shape": [], "dtype": "int32"}}} - -def _create_saved_model_v2_with_tensorlist_ops(save_dir): - """Test a TF V2 model with TensorList Ops. - - Args: - save_dir: directory name of where the saved model will be stored. - """ - model = tf.keras.Sequential() - model.add(tf.keras.layers.Embedding(100, 20, input_shape=[10])) - model.add(tf.keras.layers.GRU(4)) - - result = model.predict(tf.ones([1, 10])) - - tf.keras.backend.set_learning_phase(0) - tf.saved_model.save(model, save_dir) - - return { - "async": False, - "inputs": { - "embedding_input": { - "value": np.ones((1, 10)).tolist(), - "shape": [1, 10], "dtype": 'float32'}}, - "outputs": { - "Identity:0": { - "value": result.tolist(), - "shape": result.shape, - "dtype": "float32"}}} - -def _create_saved_model_v1_with_hashtable(save_dir): - """Test a TF V1 model with HashTable Ops. - - Args: - save_dir: directory name of where the saved model will be stored. - """ - graph = tf.Graph() - - with graph.as_default(): - # Create a builder. - builder = tf.compat.v1.saved_model.builder.SavedModelBuilder(save_dir) - - with tf.compat.v1.Session() as sess: - keys_tensor = tf.constant(["a", "b"]) - vals_tensor = tf.constant([3, 4]) - - table = tf.lookup.StaticHashTable( - tf.lookup.KeyValueTensorInitializer(keys=keys_tensor, values=vals_tensor - ), - default_value=-1 - ) - input = tf.compat.v1.placeholder(tf.string, shape=[2]) - output = table.lookup(input) - - sess.run(tf.compat.v1.tables_initializer()) - - # output_val = [3, -1] - output_val = sess.run(output, {input: ["a", "c"]}) - - builder.add_meta_graph_and_variables( - sess, [tf.compat.v1.saved_model.tag_constants.SERVING], - signature_def_map={ - "serving_default": - tf.compat.v1.saved_model \ - .signature_def_utils.predict_signature_def( - inputs={"input": input}, - outputs={"output": output}) - }, - assets_collection=None) - - builder.save() - return { - "async": False, - "inputs": { - "Placeholder:0": { - "value": ["a", "c"], "shape": [2], "dtype": "string" - } - }, - "outputs": { - "hash_table_Lookup/LookupTableFindV2:0": { - "value": output_val.tolist(), "shape": [2], "dtype": "int32" - } - } - } - -def _create_saved_model_v2_with_hashtable(save_dir): - """Test a TF V2 model with HashTable Ops. - - Args: - save_dir: directory name of where the saved model will be stored. - """ - class Table(tf.Module): - def __init__(self): - super(Table, self).__init__() - keys = tf.constant(['a', 'b']) - vals= tf.constant([0, 1]) - init = tf.lookup.KeyValueTensorInitializer(keys, vals) - self.table = tf.lookup.StaticHashTable(init, -1) - - def initializeTable(self): - @tf.function - def lookup(input): - return self.table.lookup(input) - - return lookup - - model = Table() - concrete_fn = model.initializeTable().get_concrete_function( - input=tf.TensorSpec([None], tf.string)) - - tf.saved_model.save(model, save_dir, signatures={"serving_default": concrete_fn}) - - return { - "async": False, - "inputs": { - "input:0": { - "value": ["a", "b", "c"], "shape": [3], "dtype": "string" - } - }, - "outputs": { - "StatefulPartitionedCall/None_Lookup/LookupTableFindV2:0": { - "value": [0, 1, -1], "shape": [3], "dtype": "int32" - } - } - } - -def _layers_mobilenet(): - model = tf.keras.applications.MobileNetV2() - model_path = 'mobilenet' - tfjs.converters.save_keras_model(model, os.path.join( - _tmp_dir, model_path)) - xs_data_path = os.path.join(_tmp_dir, model_path + '.xs-data.json') - xs_shape_path = os.path.join(_tmp_dir, model_path + '.xs-shapes.json') - ys_data_path = os.path.join(_tmp_dir, model_path + '.ys-data.json') - ys_shape_path = os.path.join(_tmp_dir, model_path + '.ys-shapes.json') - - input = tf.ones([1, 224, 224, 3]) - output = model.predict(input) - - with open(xs_data_path, 'w') as f: - f.write(json.dumps([input.numpy().tolist()])) - with open(xs_shape_path, 'w') as f: - f.write(json.dumps([input.shape.as_list()])) - with open(ys_data_path, 'w') as f: - f.write(json.dumps([output.tolist()])) - with open(ys_shape_path, 'w') as f: - f.write(json.dumps([output.shape])) - -def main(): - # Create the directory to store model and data. - if os.path.exists(_tmp_dir) and os.path.isdir(_tmp_dir): - shutil.rmtree(_tmp_dir) - os.mkdir(_tmp_dir) - - _save_and_convert_model(_create_saved_model_v1, 'saved_model_v1') - _save_and_convert_model(_create_saved_model_v2, 'saved_model_v2') - _save_and_convert_model(_create_saved_model_v2_complex64, - 'saved_model_v2_complex64') - _save_and_convert_model(_create_saved_model_v2_with_control_flow, - 'saved_model_v2_with_control_flow') - _save_and_convert_model(_create_saved_model_v2_with_control_flow_v2, - 'saved_model_v2_with_control_flow_v2', control_flow_v2=True) - _save_and_convert_model(_create_saved_model_with_conv2d, - 'saved_model_with_conv2d') - _save_and_convert_model(_create_saved_model_with_prelu, - 'saved_model_with_prelu') - _save_and_convert_model(_create_saved_model_v2_with_tensorlist_ops, - 'saved_model_v2_with_tensorlist_ops', control_flow_v2=True) - _save_and_convert_model(_create_saved_model_v1_with_hashtable, - 'saved_model_v1_with_hashtable') - _save_and_convert_model(_create_saved_model_v2_with_hashtable, - 'saved_model_v2_with_hashtable') - - _layers_mobilenet() -if __name__ == '__main__': - main() diff --git a/tfjs-master/e2e/integration_tests/convert_predict.ts b/tfjs-master/e2e/integration_tests/convert_predict.ts deleted file mode 100644 index 97f67b23f..000000000 --- a/tfjs-master/e2e/integration_tests/convert_predict.ts +++ /dev/null @@ -1,157 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -/** - * This file is 2/2 of the test suites for CUJ: convert->predict. - * - * This file does below things: - * - Load graph models using Converter api. - * - Load inputs. - * - Make inference using each backends, and validate the results against TF - * results. - */ -import '@tensorflow/tfjs-backend-cpu'; -import '@tensorflow/tfjs-backend-webgl'; -import '@tensorflow/tfjs-backend-webgpu'; - -import * as tfconverter from '@tensorflow/tfjs-converter'; -import * as tfc from '@tensorflow/tfjs-core'; -// tslint:disable-next-line: no-imports-from-dist -import {ALL_ENVS, describeWithFlags} from '@tensorflow/tfjs-core/dist/jasmine_util'; -import * as tfl from '@tensorflow/tfjs-layers'; - -import {CONVERT_PREDICT_MODELS, KARMA_SERVER, REGRESSION} from './constants'; -import {createInputTensors} from './test_util'; - -const DATA_URL = 'convert_predict_data'; - -describeWithFlags(`${REGRESSION} convert_predict`, ALL_ENVS, (env) => { - let originalTimeout: number; - - beforeAll(() => { - // This test needs more time to finish the async fetch, adjusting - // jasmine timeout for this test to avoid flakiness. See jasmine - // documentation for detail: - // https://jasmine.github.io/2.0/introduction.html#section-42 - originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL; - jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000000; - }); - - afterAll(() => jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout); - - for (const modelType in CONVERT_PREDICT_MODELS) { - const models = - (CONVERT_PREDICT_MODELS as {[key: string]: string[]})[modelType]; - for (const model of models) { - if (env.backendName === 'wasm' && model.includes('complex')) { - // WASM does not support complex - continue; - } - it(`${model}.`, async () => { - await tfc.setBackend(env.name); - let inputsNames: string[]; - let inputsData: tfc.TypedArray[]; - let inputsShapes: number[][]; - let inputsDtypes: tfc.DataType[]; - let tfOutputNames: string[]; - let tfOutputData: tfc.TypedArray[]; - let tfOutputShapes: number[][]; - let tfOutputDtypes: tfc.DataType[]; - - const fetches = [ - fetch(`${KARMA_SERVER}/${DATA_URL}/${model}.xs-data.json`) - .then(response => response.json()), - fetch(`${KARMA_SERVER}/${DATA_URL}/${model}.xs-shapes.json`) - .then(response => response.json()), - fetch(`${KARMA_SERVER}/${DATA_URL}/${model}.ys-data.json`) - .then(response => response.json()), - fetch(`${KARMA_SERVER}/${DATA_URL}/${model}.ys-shapes.json`) - .then(response => response.json()) - ]; - if (modelType === 'graph_model') { - fetches.push( - ...[fetch(`${KARMA_SERVER}/${DATA_URL}/${model}.xs-name.json`) - .then(response => response.json()), - fetch(`${KARMA_SERVER}/${DATA_URL}/${model}.xs-dtype.json`) - .then(response => response.json()), - fetch(`${KARMA_SERVER}/${DATA_URL}/${model}.ys-name.json`) - .then(response => response.json()), - fetch(`${KARMA_SERVER}/${DATA_URL}/${model}.ys-dtype.json`) - .then(response => response.json())]); - } - [inputsData, inputsShapes, tfOutputData, tfOutputShapes, inputsNames, - inputsDtypes, tfOutputNames, tfOutputDtypes] = - await Promise.all(fetches); - - if (modelType === 'graph_model') { - const numTensors = tfc.memory().numTensors; - - const $model = await tfconverter.loadGraphModel( - `${KARMA_SERVER}/${DATA_URL}/${model}/model.json`); - - const namedInputs = createInputTensors( - inputsData, inputsShapes, inputsDtypes, - inputsNames) as tfc.NamedTensorMap; - - const result = await $model.executeAsync(namedInputs, tfOutputNames); - - const ys = - ($model.outputs.length === 1 ? [result] : result) as tfc.Tensor[]; - - // Validate outputs with tf results. - for (let i = 0; i < ys.length; i++) { - const y = ys[i]; - expect(y.shape).toEqual(tfOutputShapes[i]); - expect(y.dtype).toEqual(tfOutputDtypes[i]); - tfc.test_util.expectArraysClose(await y.data(), tfOutputData[i]); - } - - // Dispose all tensors; - Object.keys(namedInputs).forEach(key => namedInputs[key].dispose()); - ys.forEach(tensor => tensor.dispose()); - $model.dispose(); - - expect(tfc.memory().numTensors).toEqual(numTensors); - } - if (modelType === 'layers_model') { - const $model = await tfl.loadLayersModel( - `${KARMA_SERVER}/${DATA_URL}/${model}/model.json`); - - const xs = - createInputTensors(inputsData, inputsShapes) as tfc.Tensor[]; - - const result = $model.predict(xs); - - const ys = - ($model.outputs.length === 1 ? [result] : result) as tfc.Tensor[]; - - // Validate outputs with keras results. - for (let i = 0; i < ys.length; i++) { - const y = ys[i]; - expect(y.shape).toEqual(tfOutputShapes[i]); - tfc.test_util.expectArraysClose( - await y.data(), tfOutputData[i], 0.005); - } - - // Dispose all tensors; - xs.forEach(tensor => tensor.dispose()); - ys.forEach(tensor => tensor.dispose()); - } - }); - } - } -}); diff --git a/tfjs-master/e2e/integration_tests/cpu_forwarding_test.ts b/tfjs-master/e2e/integration_tests/cpu_forwarding_test.ts deleted file mode 100644 index 02a671b5e..000000000 --- a/tfjs-master/e2e/integration_tests/cpu_forwarding_test.ts +++ /dev/null @@ -1,246 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import '@tensorflow/tfjs-backend-cpu'; -import '@tensorflow/tfjs-backend-webgl'; -import '@tensorflow/tfjs-backend-webgpu'; - -import * as tfc from '@tensorflow/tfjs-core'; -// tslint:disable-next-line: no-imports-from-dist -import {describeWithFlags} from '@tensorflow/tfjs-core/dist/jasmine_util'; - -import {SMOKE} from './constants'; - -/** - * This file tests cpu forwarding from webgl backend. - */ - -describeWithFlags( - `${SMOKE} cpu forwarding)`, - {predicate: testEnv => testEnv.backendName !== 'cpu'}, - - (env) => { - let webglCpuForwardFlagSaved: boolean; - let webgpuCpuForwardFlagSaved: boolean; - - beforeAll(async () => { - webglCpuForwardFlagSaved = tfc.env().getBool('WEBGL_CPU_FORWARD'); - tfc.env().set('WEBGL_CPU_FORWARD', true); - webgpuCpuForwardFlagSaved = tfc.env().getBool('WEBGPU_CPU_FORWARD'); - tfc.env().set('WEBGPU_CPU_FORWARD', true); - await tfc.setBackend(env.name); - }); - - afterAll(() => { - tfc.env().set('WEBGL_CPU_FORWARD', webglCpuForwardFlagSaved); - tfc.env().set('WEBGPU_CPU_FORWARD', webgpuCpuForwardFlagSaved); - }); - - it('should work for slice.', async () => { - const a = tfc.tensor3d([1, 2, 3, 4, 5, 6, 7, 8], [2, 2, 2]); - const result = a.slice([0, 1, 1]); - expect(result.shape).toEqual([2, 1, 1]); - tfc.test_util.expectArraysClose(await result.data(), [4, 8]); - }); - - it('should work for stridedSlice.', async () => { - const t = tfc.tensor2d([ - [1, 2, 3, 4, 5], - [2, 3, 4, 5, 6], - [3, 4, 5, 6, 7], - [4, 5, 6, 7, 8], - [5, 6, 7, 8, 9], - [6, 7, 8, 9, 10], - [7, 8, 9, 10, 11], - [8, 8, 9, 10, 11], - [9, 8, 9, 10, 11], - [10, 8, 9, 10, 11], - ]); - const begin = [0, 4]; - const end = [0, 5]; - const strides = [1, 1]; - const beginMask = 0; - const endMask = 0; - const ellipsisMask = 1; - const output = t.stridedSlice( - begin, end, strides, beginMask, endMask, ellipsisMask); - expect(output.shape).toEqual([10, 1]); - tfc.test_util.expectArraysClose( - await output.data(), [5, 6, 7, 8, 9, 10, 11, 11, 11, 11]); - }); - - it('should work for concat.', async () => { - const a = tfc.tensor1d([3]); - const b = tfc.tensor1d([5]); - - const result = tfc.concat1d([a, b]); - const expected = [3, 5]; - tfc.test_util.expectArraysClose(await result.data(), expected); - }); - - it('should work for neg.', async () => { - const a = tfc.tensor1d([1, -3, 2, 7, -4]); - const result = tfc.neg(a); - tfc.test_util.expectArraysClose( - await result.data(), [-1, 3, -2, -7, 4]); - }); - - it('should work for multiply.', async () => { - const a = tfc.tensor2d([1, 2, -3, -4], [2, 2]); - const b = tfc.tensor2d([5, 3, 4, -7], [2, 2]); - const expected = [5, 6, -12, 28]; - const result = tfc.mul(a, b); - - expect(result.shape).toEqual([2, 2]); - tfc.test_util.expectArraysClose(await result.data(), expected); - }); - - it('should work for gather.', async () => { - const t = tfc.tensor1d([1, 2, 3]); - - const t2 = tfc.gather(t, tfc.scalar(1, 'int32'), 0); - - expect(t2.shape).toEqual([]); - tfc.test_util.expectArraysClose(await t2.data(), [2]); - }); - - it('should work for prod.', async () => { - const a = tfc.tensor2d([1, 2, 3, 0, 0, 1], [3, 2]); - const result = tfc.prod(a); - tfc.test_util.expectArraysClose(await result.data(), 0); - }); - - it('should work for less.', async () => { - const a = tfc.tensor1d([1, 4, 5], 'int32'); - const b = tfc.tensor1d([2, 3, 5], 'int32'); - const res = tfc.less(a, b); - - expect(res.dtype).toBe('bool'); - tfc.test_util.expectArraysClose(await res.data(), [1, 0, 0]); - }); - - it('should work for greater.', async () => { - const a = tfc.tensor1d([1, 4, 5], 'int32'); - const b = tfc.tensor1d([2, 3, 5], 'int32'); - const res = tfc.greater(a, b); - - expect(res.dtype).toBe('bool'); - tfc.test_util.expectArraysClose(await res.data(), [0, 1, 0]); - }); - - it('should work for minimum.', async () => { - const a = tfc.tensor1d([0.5, 3, -0.1, -4]); - const b = tfc.tensor1d([0.2, 0.4, 0.25, 0.15]); - const result = tfc.minimum(a, b); - - expect(result.shape).toEqual(a.shape); - tfc.test_util.expectArraysClose( - await result.data(), [0.2, 0.4, -0.1, -4]); - }); - - it('should work for maximum.', async () => { - const a = tfc.tensor1d([0.5, 3, -0.1, -4]); - const b = tfc.tensor1d([0.2, 0.4, 0.25, 0.15]); - const result = tfc.maximum(a, b); - - expect(result.shape).toEqual(a.shape); - tfc.test_util.expectArraysClose( - await result.data(), [0.5, 3, 0.25, 0.15]); - }); - - it('should work for max.', async () => { - const a = tfc.tensor1d([3, -1, 0, 100, -7, 2]); - const r = tfc.max(a); - tfc.test_util.expectArraysClose(await r.data(), 100); - }); - - it('should work for add.', async () => { - const c = tfc.scalar(5); - const a = tfc.tensor1d([1, 2, 3]); - - const result = tfc.add(c, a); - - tfc.test_util.expectArraysClose(await result.data(), [6, 7, 8]); - }); - - it('should work for sub.', async () => { - const c = tfc.scalar(5); - const a = tfc.tensor1d([7, 2, 3]); - - const result = tfc.sub(c, a); - - tfc.test_util.expectArraysClose(await result.data(), [-2, 3, 2]); - }); - - it('should work for ceil.', async () => { - const a = tfc.tensor1d([1.5, 2.1, -1.4]); - const r = tfc.ceil(a); - tfc.test_util.expectArraysClose(await r.data(), [2, 3, -1]); - }); - - it('should work for floor.', async () => { - const a = tfc.tensor1d([1.5, 2.1, -1.4]); - const r = tfc.floor(a); - - tfc.test_util.expectArraysClose(await r.data(), [1, 2, -2]); - }); - - it('should work for exp.', async () => { - const a = tfc.tensor1d([1, 2, 0]); - const r = tfc.exp(a); - - tfc.test_util.expectArraysClose( - await r.data(), [Math.exp(1), Math.exp(2), 1]); - }); - - it('should work for expm1.', async () => { - const a = tfc.tensor1d([1, 2, 0]); - const r = tfc.expm1(a); - - tfc.test_util.expectArraysClose( - await r.data(), [Math.expm1(1), Math.expm1(2), Math.expm1(0)]); - }); - - it('should work for log.', async () => { - const a = tfc.tensor1d([1, 2]); - const r = tfc.log(a); - tfc.test_util.expectArraysClose( - await r.data(), [Math.log(1), Math.log(2)]); - }); - - it('should work for rsqrt.', async () => { - const a = tfc.tensor1d([2, 4]); - const r = tfc.rsqrt(a); - tfc.test_util.expectArraysClose( - await r.data(), [1 / Math.sqrt(2), 1 / Math.sqrt(4)]); - }); - - it('should work for abs.', async () => { - const a = tfc.tensor1d([1, -2, 0, 3, -0.1]); - const result = tfc.abs(a); - tfc.test_util.expectArraysClose(await result.data(), [1, 2, 0, 3, 0.1]); - }); - - it('should work for transpose.', async () => { - const t = tfc.tensor2d([1, 11, 2, 22, 3, 33, 4, 44], [2, 4]); - const t2 = tfc.transpose(t, [1, 0]); - - expect(t2.shape).toEqual([4, 2]); - tfc.test_util.expectArraysClose( - await t2.data(), [1, 3, 11, 33, 2, 4, 22, 44]); - }); - }); diff --git a/tfjs-master/e2e/integration_tests/create_save_predict.js b/tfjs-master/e2e/integration_tests/create_save_predict.js deleted file mode 100644 index 396ee5ffe..000000000 --- a/tfjs-master/e2e/integration_tests/create_save_predict.js +++ /dev/null @@ -1,240 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -/** - * This file is 1/3 of the test suites for CUJ: create->save->predict. - * - * This file does below things: - * - Create and save models using Layers' API. - * - Generate random inputs and stored in local file. - */ -const tfc = require('@tensorflow/tfjs-core'); -const tfl = require('@tensorflow/tfjs-layers'); -const tfjsNode = require('@tensorflow/tfjs-node'); -const fs = require('fs'); -const join = require('path').join; - -process.on('unhandledRejection', ex => { - throw ex; -}); - -/** - * Generate random input(s), get predict() output(s), and save them along with - * the model. - * - * @param model The `tf.LayersModel` instance in question. It may have one or - * more inputs and one or more outputs. It is assumed that for each input, only - * the first dimension (i.e., the batch dimension) is undetermined. - * @param exportPathprefix The path prefix to which the model, the input and - * output tensors will be saved - * @param inputIntegerMax (Optional) Maximum integer value for the input - * tensors. Used for models that take integer tensors as inputs. - */ -async function saveModelAndRandomInputs( - model, exportPathprefix, inputIntegerMax) { - await model.save(tfjsNode.io.fileSystem(exportPathprefix)); - - const xs = []; - const xsData = []; - const xsShapes = []; - for (const inputTensor of model.inputs) { - const inputShape = inputTensor.shape; - inputShape[0] = 1; - if (inputShape.indexOf(null) !== -1) { - throw new Error( - `It is assumed that the only the first dimension of the tensor ` + - `is undetermined, but the assumption is not satisfied for ` + - `input shape ${JSON.stringify(inputTensor.shape)}`); - } - const xTensor = inputIntegerMax == null ? - tfc.randomNormal(inputShape) : - tfc.floor(tfc.randomUniform(inputShape, 0, inputIntegerMax)); - xs.push(xTensor); - xsData.push(Array.from(xTensor.dataSync())); - xsShapes.push(xTensor.shape); - } - fs.writeFileSync(exportPathprefix + '.xs-data.json', JSON.stringify(xsData)); - fs.writeFileSync( - exportPathprefix + '.xs-shapes.json', JSON.stringify(xsShapes)); -} - -// Multi-layer perceptron (MLP). -async function exportMLPModel(exportPath) { - const model = tfl.sequential(); - // Test both activations encapsulated in other layers and as standalone - // layers. - model.add( - tfl.layers.dense({units: 100, inputShape: [200], activation: 'relu'})); - model.add(tfl.layers.dense({units: 50, activation: 'elu'})); - model.add(tfl.layers.dense({units: 24})); - model.add(tfl.layers.activation({activation: 'elu'})); - model.add(tfl.layers.dense({units: 8, activation: 'softmax'})); - - await saveModelAndRandomInputs(model, exportPath); -} - -// Convolutional neural network (CNN). -async function exportCNNModel(exportPath) { - const model = tfl.sequential(); - - // Cover separable and non-separable convoluational layers. - const inputShape = [40, 40, 3]; - model.add(tfl.layers.conv2d({ - filters: 32, - kernelSize: [3, 3], - strides: [2, 2], - inputShape, - padding: 'valid', - })); - model.add(tfl.layers.batchNormalization({})); - model.add(tfl.layers.activation({activation: 'relu'})); - model.add(tfl.layers.dropout({rate: 0.5})); - model.add(tfl.layers.maxPooling2d({poolSize: 2})); - model.add(tfl.layers.separableConv2d({ - filters: 32, - kernelSize: [4, 4], - strides: [3, 3], - })); - model.add(tfl.layers.batchNormalization({})); - model.add(tfl.layers.activation({activation: 'relu'})); - model.add(tfl.layers.dropout({rate: 0.5})); - model.add(tfl.layers.avgPooling2d({poolSize: [2, 2]})); - model.add(tfl.layers.flatten({})); - model.add(tfl.layers.dense({units: 100, activation: 'softmax'})); - - await saveModelAndRandomInputs(model, exportPath); -} - -async function exportDepthwiseCNNModel(exportPath) { - const model = tfl.sequential(); - - // Cover depthwise 2D convoluational layer. - model.add(tfl.layers.depthwiseConv2d({ - depthMultiplier: 2, - kernelSize: [3, 3], - strides: [2, 2], - inputShape: [40, 40, 3], - padding: 'valid', - })); - model.add(tfl.layers.batchNormalization({})); - model.add(tfl.layers.activation({activation: 'relu'})); - model.add(tfl.layers.dropout({rate: 0.5})); - model.add(tfl.layers.maxPooling2d({poolSize: 2})); - model.add(tfl.layers.flatten({})); - model.add(tfl.layers.dense({units: 100, activation: 'softmax'})); - - await saveModelAndRandomInputs(model, exportPath); -} - -// SimpleRNN with embedding. -async function exportSimpleRNNModel(exportPath) { - const model = tfl.sequential(); - const inputDim = 100; - model.add(tfl.layers.embedding({inputDim, outputDim: 20, inputShape: [10]})); - model.add(tfl.layers.simpleRNN({units: 4})); - - await saveModelAndRandomInputs(model, exportPath, inputDim); -} - -// GRU with embedding. -async function exportGRUModel(exportPath) { - const model = tfl.sequential(); - const inputDim = 100; - model.add(tfl.layers.embedding({inputDim, outputDim: 20, inputShape: [10]})); - model.add(tfl.layers.gru({units: 4, goBackwards: true})); - - await saveModelAndRandomInputs(model, exportPath, inputDim); -} - -// Bidirecitonal LSTM with embedding. -async function exportBidirectionalLSTMModel(exportPath) { - const model = tfl.sequential(); - const inputDim = 100; - model.add(tfl.layers.embedding({inputDim, outputDim: 20, inputShape: [10]})); - // TODO(cais): Investigate why the `tfl.layers.RNN` typing doesn't work. - const lstm = tfl.layers.lstm({units: 4, goBackwards: true}); - model.add(tfl.layers.bidirectional({layer: lstm, mergeMode: 'concat'})); - - await saveModelAndRandomInputs(model, exportPath, inputDim); -} - -// LSTM + time-distributed layer with embedding. -async function exportTimeDistributedLSTMModel(exportPath) { - const model = tfl.sequential(); - const inputDim = 100; - model.add(tfl.layers.embedding({inputDim, outputDim: 20, inputShape: [10]})); - model.add(tfl.layers.lstm({units: 4, returnSequences: true})); - model.add(tfl.layers.timeDistributed({ - layer: tfl.layers.dense({units: 2, useBias: false, activation: 'softmax'}) - })); - - await saveModelAndRandomInputs(model, exportPath, inputDim); -} - -// Model with Conv1D and Pooling1D layers. -async function exportOneDimensionalModel(exportPath) { - const model = tfl.sequential(); - model.add(tfl.layers.conv1d( - {filters: 16, kernelSize: [4], inputShape: [80, 1], activation: 'relu'})); - model.add(tfl.layers.maxPooling1d({poolSize: 3})); - model.add( - tfl.layers.conv1d({filters: 8, kernelSize: [3], activation: 'relu'})); - model.add(tfl.layers.avgPooling1d({poolSize: 5})); - model.add(tfl.layers.flatten()); - - await saveModelAndRandomInputs(model, exportPath); -} - -// Functional model with two Merge layers. -async function exportFunctionalMergeModel(exportPath) { - const input1 = tfl.input({shape: [2, 5]}); - const input2 = tfl.input({shape: [4, 5]}); - const input3 = tfl.input({shape: [30]}); - const reshaped1 = tfl.layers.reshape({targetShape: [10]}).apply(input1); - const reshaped2 = tfl.layers.reshape({targetShape: [20]}).apply(input2); - const dense1 = tfl.layers.dense({units: 5}).apply(reshaped1); - const dense2 = tfl.layers.dense({units: 5}).apply(reshaped2); - const dense3 = tfl.layers.dense({units: 5}).apply(input3); - const avg = tfl.layers.average().apply([dense1, dense2]); - const concat = tfl.layers.concatenate({axis: -1}).apply([avg, dense3]); - const output = tfl.layers.dense({units: 1}).apply(concat); - const model = tfl.model({inputs: [input1, input2, input3], outputs: output}); - - await saveModelAndRandomInputs(model, exportPath); -} - -console.log(`Using tfjs-core version: ${tfc.version_core}`); -console.log(`Using tfjs-layers version: ${tfl.version_layers}`); -console.log(`Using tfjs-node version: ${JSON.stringify(tfjsNode.version)}`); - -if (process.argv.length !== 3) { - throw new Error('Usage: node tfjs_save.ts '); -} -const testDataDir = process.argv[2]; - -(async function() { - await exportMLPModel(join(testDataDir, 'mlp')); - await exportCNNModel(join(testDataDir, 'cnn')); - await exportDepthwiseCNNModel(join(testDataDir, 'depthwise_cnn')); - await exportSimpleRNNModel(join(testDataDir, 'simple_rnn')); - await exportGRUModel(join(testDataDir, 'gru')); - await exportBidirectionalLSTMModel(join(testDataDir, 'bidirectional_lstm')); - await exportTimeDistributedLSTMModel( - join(testDataDir, 'time_distributed_lstm')); - await exportOneDimensionalModel(join(testDataDir, 'one_dimensional')); - await exportFunctionalMergeModel(join(testDataDir, 'functional_merge')); -})(); diff --git a/tfjs-master/e2e/integration_tests/create_save_predict.py b/tfjs-master/e2e/integration_tests/create_save_predict.py deleted file mode 100644 index d55caf6da..000000000 --- a/tfjs-master/e2e/integration_tests/create_save_predict.py +++ /dev/null @@ -1,92 +0,0 @@ -# Copyright 2020 Google LLC -# -# Use of this source code is governed by an MIT-style -# license that can be found in the LICENSE file or at -# https://opensource.org/licenses/MIT. -# ============================================================================= - -# This file is 2/3 of the test suites for CUJ: create->save->predict. -# -# This file does below things: -# - Load Keras models equivalent with models generated by Layers. -# - Load inputs. -# - Make inference and store in local files. - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -import json -import os -import shutil -import tempfile - -import numpy as np -import tensorflow as tf -import tensorflowjs as tfjs - -from tensorflow import keras - -curr_dir = os.path.dirname(os.path.realpath(__file__)) -_tmp_dir = os.path.join(curr_dir, 'create_save_predict_data') - -def _load_predict_save(model_path): - """Load a Keras Model from artifacts generated by tensorflow.js and inputs. - Make inference with the model and inputs. - Write outputs to file. - - Args: - model_path: Path to the model JSON file. - """ - xs_shape_path = os.path.join( - _tmp_dir, model_path + '.xs-shapes.json') - xs_data_path = os.path.join( - _tmp_dir, model_path + '.xs-data.json') - with open(xs_shape_path, 'rt') as f: - xs_shapes = json.load(f) - with open(xs_data_path, 'rt') as f: - xs_values = json.load(f) - xs = [np.array(value, dtype=np.float32).reshape(shape) - for value, shape in zip(xs_values, xs_shapes)] - if len(xs) == 1: - xs = xs[0] - - session = tf.Session() if hasattr(tf, 'Session') else tf.compat.v1.Session() - with tf.Graph().as_default(), session: - model_json_path = os.path.join(_tmp_dir, model_path, 'model.json') - print('Loading model from path %s' % model_json_path) - model = tfjs.converters.load_keras_model(model_json_path) - ys = model.predict(xs) - - ys_data = None - ys_shape = None - - if isinstance(ys, list): - ys_data = [y.tolist() for y in ys] - ys_shape = [list(y.shape) for y in ys] - else: - ys_data = ys.tolist() - ys_shape = [list(ys.shape)] - - ys_data_path = os.path.join( - _tmp_dir, model_path + '.ys-data.json') - ys_shape_path = os.path.join( - _tmp_dir, model_path + '.ys-shapes.json') - with open(ys_data_path, 'w') as f: - f.write(json.dumps(ys_data)) - with open(ys_shape_path, 'w') as f: - f.write(json.dumps(ys_shape)) - -def main(): - _load_predict_save('mlp') - _load_predict_save('cnn') - _load_predict_save('depthwise_cnn') - _load_predict_save('simple_rnn') - _load_predict_save('gru') - _load_predict_save('bidirectional_lstm') - _load_predict_save('time_distributed_lstm') - _load_predict_save('one_dimensional') - _load_predict_save('functional_merge') - -if __name__ == '__main__': - main() diff --git a/tfjs-master/e2e/integration_tests/create_save_predict.ts b/tfjs-master/e2e/integration_tests/create_save_predict.ts deleted file mode 100644 index baea45d0e..000000000 --- a/tfjs-master/e2e/integration_tests/create_save_predict.ts +++ /dev/null @@ -1,98 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import '@tensorflow/tfjs-backend-cpu'; -import '@tensorflow/tfjs-backend-webgl'; -import '@tensorflow/tfjs-backend-webgpu'; - -import * as tfc from '@tensorflow/tfjs-core'; -// tslint:disable-next-line: no-imports-from-dist -import {ALL_ENVS, describeWithFlags} from '@tensorflow/tfjs-core/dist/jasmine_util'; -import * as tfl from '@tensorflow/tfjs-layers'; - -import {KARMA_SERVER, LAYERS_MODELS, REGRESSION} from './constants'; -import {createInputTensors} from './test_util'; - -/** Directory that stores the model. */ -const DATA_URL = 'create_save_predict_data'; - -/** - * This file is 3/3 of the test suites for CUJ: create->save->predict. - * - * This file test below things: - * - Load layers models using Layers api. - * - Load inputs. - * - Make inference using each backends, and validate the results against - * Keras results. - */ -describeWithFlags(`${REGRESSION} create_save_predict`, ALL_ENVS, (env) => { - let originalTimeout: number; - - beforeAll(() => { - // This test needs more time to finish the async fetch, adjusting - // jasmine timeout for this test to avoid flakiness. See jasmine - // documentation for detail: - // https://jasmine.github.io/2.0/introduction.html#section-42 - originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL; - jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000000; - }); - - afterAll(() => jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout); - - LAYERS_MODELS.forEach(model => { - it(`${model}.`, async () => { - await tfc.setBackend(env.name); - let inputsData: tfc.TypedArray[]; - let inputsShapes: number[][]; - let kerasOutputData: tfc.TypedArray[]; - let kerasOutputShapes: number[][]; - - [inputsData, inputsShapes, kerasOutputData, kerasOutputShapes] = - await Promise.all([ - fetch(`${KARMA_SERVER}/${DATA_URL}/${model}.xs-data.json`) - .then(response => response.json()), - fetch(`${KARMA_SERVER}/${DATA_URL}/${model}.xs-shapes.json`) - .then(response => response.json()), - fetch(`${KARMA_SERVER}/${DATA_URL}/${model}.ys-data.json`) - .then(response => response.json()), - fetch(`${KARMA_SERVER}/${DATA_URL}/${model}.ys-shapes.json`) - .then(response => response.json()) - ]); - - const $model = await tfl.loadLayersModel( - `${KARMA_SERVER}/${DATA_URL}/${model}/model.json`); - - const xs = createInputTensors(inputsData, inputsShapes) as tfc.Tensor[]; - const result = $model.predict(xs); - - const ys = - ($model.outputs.length === 1 ? [result] : result) as tfc.Tensor[]; - - // Validate outputs with keras results. - for (let i = 0; i < ys.length; i++) { - const y = ys[i]; - expect(y.shape).toEqual(kerasOutputShapes[i]); - tfc.test_util.expectArraysClose( - await y.data(), kerasOutputData[i], 0.005); - } - - // Dispose all tensors; - xs.forEach(tensor => tensor.dispose()); - ys.forEach(tensor => tensor.dispose()); - }); - }); -}); diff --git a/tfjs-master/e2e/integration_tests/custom_bundle_test.ts b/tfjs-master/e2e/integration_tests/custom_bundle_test.ts deleted file mode 100644 index 4bd24a815..000000000 --- a/tfjs-master/e2e/integration_tests/custom_bundle_test.ts +++ /dev/null @@ -1,340 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -// tslint:disable-next-line: no-imports-from-dist -import {CHROME_ENVS, Constraints, describeWithFlags, HAS_WORKER} from '@tensorflow/tfjs-core/dist/jasmine_util'; - -import {REGRESSION} from './constants'; - -const CHROME_ENVS_WITH_WORKER: Constraints = - Object.assign({}, CHROME_ENVS, HAS_WORKER); -/** - * This file is the test suite for CUJ: custom_module->custom_module->predict. - */ - -function getBundleUrl(folder: string, custom: boolean, bundler: string) { - const distFolder = custom ? 'custom' : 'full'; - return `./base/custom_module/${folder}/dist/${distFolder}/app_${bundler}.js`; -} - -const DEBUG_WORKER_SCRIPT = true; - -describe(`${REGRESSION} blazeface`, () => { - describeWithFlags('webpack', CHROME_ENVS_WITH_WORKER, () => { - let webpackBundle: {full: string, custom: string}; - let originalTimeout: number; - beforeAll(async () => { - originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL; - jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000000; - - const [webpackFull, webpackCustom] = await Promise.all([ - fetch(getBundleUrl('blazeface', false /* custom */, 'webpack')) - .then(r => r.text()) - .catch(e => { - console.error( - 'Failed to fetch blazeface full bundle at ', - getBundleUrl('blazeface', false /* custom */, 'webpack')); - throw e; - }), - fetch(getBundleUrl('blazeface', true /* custom */, 'webpack')) - .then(r => r.text()) - .catch(e => { - console.error( - 'Failed to fetch blazeface custom bundle at ', - getBundleUrl('blazeface', false /* custom */, 'webpack')); - throw e; - }), - ]); - - webpackBundle = {full: webpackFull, custom: webpackCustom}; - }); - - afterAll(() => jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout); - - it('custom webpack should be smaller', async () => { - expect(webpackBundle.custom.length) - .toBeLessThan( - webpackBundle.full.length, - 'Custom bundle should be smaller than full bundle'); - }); - - it('custom bundle should execute with exact kernels', async () => { - const programUrl = - getBundleUrl('blazeface', true /* custom */, 'webpack'); - // tslint:disable-next-line: no-any - const result: any = - await executeInWorker(programUrl, {debug: DEBUG_WORKER_SCRIPT}); - const kernelNames = result.kernelNames; - expect(kernelNames).toEqual(jasmine.arrayWithExactContents([ - 'Cast', - 'ExpandDims', - 'Reshape', - 'ResizeBilinear', - 'RealDiv', - 'Sub', - 'Multiply', - 'FusedConv2D', - 'DepthwiseConv2dNative', - 'Add', - 'Relu', - 'Pack', - 'PadV2', - 'MaxPool', - 'Slice', - 'StridedSlice', - 'Concat', - 'Identity', - 'Sigmoid', - 'NonMaxSuppressionV3' - ])); - - expect(result.predictions.length).toEqual(1); - }); - }); -}); - -describe(`${REGRESSION} dense model`, () => { - describeWithFlags('webpack', CHROME_ENVS_WITH_WORKER, () => { - let webpackBundle: {full: string, custom: string}; - let originalTimeout: number; - - let modelUrl: string; - beforeAll(async () => { - originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL; - jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000000; - - modelUrl = `/base/custom_module/dense_model/model/model.json`; - const [webpackFull, webpackCustom] = await Promise.all([ - fetch(getBundleUrl('dense_model', false /* custom */, 'webpack')) - .then(r => r.text()), - fetch(getBundleUrl('dense_model', true /* custom */, 'webpack')) - .then(r => r.text()), - ]); - - webpackBundle = {full: webpackFull, custom: webpackCustom}; - }); - - afterAll(() => jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout); - - it('custom webpack should be smaller', async () => { - expect(webpackBundle.custom.length) - .toBeLessThan( - webpackBundle.full.length / 2, - 'Custom bundle should be smaller than full bundle'); - }); - - it('custom bundle should execute with exact kernels', async () => { - const programUrl = - getBundleUrl('dense_model', true /* custom */, 'webpack'); - - // tslint:disable-next-line: no-any - const result: any = await executeInWorker( - programUrl, {debug: DEBUG_WORKER_SCRIPT, workerParams: {modelUrl}}); - const kernelNames = result.kernelNames; - expect(kernelNames).toEqual(jasmine.arrayWithExactContents([ - 'Reshape', '_FusedMatMul', 'Identity' - ])); - - expect(Math.floor(result.predictions[0])).toEqual(38); - }); - }); - - describeWithFlags('rollup', CHROME_ENVS_WITH_WORKER, () => { - let rollupBundle: {full: string, custom: string}; - let originalTimeout: number; - - let modelUrl: string; - beforeAll(async () => { - originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL; - jasmine.DEFAULT_TIMEOUT_INTERVAL = 500000; - - modelUrl = `/base/custom_module/dense_model/model/model.json`; - const [rollupFull, rollupCustom] = await Promise.all([ - fetch(getBundleUrl('dense_model', false /* custom */, 'rollup')) - .then(r => r.text()), - fetch(getBundleUrl('dense_model', true /* custom */, 'rollup')) - .then(r => r.text()), - ]); - - rollupBundle = {full: rollupFull, custom: rollupCustom}; - }); - - afterAll(() => jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout); - - it('custom rollup should be smaller', async () => { - expect(rollupBundle.custom.length) - .toBeLessThan( - rollupBundle.full.length / 2, - 'Custom bundle should be smaller than full bundle'); - }); - - it('custom bundle should execute with exact kernels', async () => { - const programUrl = - getBundleUrl('dense_model', true /* custom */, 'webpack'); - - // tslint:disable-next-line: no-any - const result: any = await executeInWorker( - programUrl, {debug: DEBUG_WORKER_SCRIPT, workerParams: {modelUrl}}); - const kernelNames = result.kernelNames; - expect(kernelNames).toEqual(jasmine.arrayWithExactContents([ - 'Reshape', '_FusedMatMul', 'Identity' - ])); - - expect(Math.floor(result.predictions[0])).toEqual(38); - }); - }); -}); - -describe(`${REGRESSION} universal sentence encoder model`, () => { - const expectedKernels = [ - 'StridedSlice', 'Less', 'Cast', 'Reshape', 'GatherV2', - 'Max', 'Add', 'Maximum', 'SparseToDense', 'Greater', - 'Sum', 'ExpandDims', 'Concat', 'LogicalNot', 'Multiply', - 'ScatterNd', 'GatherNd', 'Cos', 'Sin', 'BatchMatMul', - 'Mean', 'Sub', 'Square', 'Rsqrt', 'Conv2D', - 'SplitV', 'Pack', 'Transpose', 'Slice', 'Softmax', - 'Prod', 'Relu', 'Range', 'RealDiv', 'Tanh' - ]; - - describeWithFlags('webpack', CHROME_ENVS_WITH_WORKER, () => { - let webpackBundle: {full: string, custom: string}; - let originalTimeout: number; - - beforeAll(async () => { - originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL; - jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000000; - - const [webpackFull, webpackCustom] = await Promise.all([ - fetch(getBundleUrl( - 'universal_sentence_encoder', false /* custom */, 'webpack')) - .then(r => r.text()), - fetch(getBundleUrl( - 'universal_sentence_encoder', true /* custom */, 'webpack')) - .then(r => r.text()), - ]); - - webpackBundle = {full: webpackFull, custom: webpackCustom}; - }); - - afterAll(() => jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout); - - it('custom webpack should be smaller', async () => { - expect(webpackBundle.custom.length) - .toBeLessThan( - webpackBundle.full.length / 2, - 'Custom bundle should be smaller than full bundle'); - }); - - it('custom bundle should execute with exact kernels', async () => { - const programUrl = getBundleUrl( - 'universal_sentence_encoder', true /* custom */, 'webpack'); - - // tslint:disable-next-line: no-any - const result: any = await executeInWorker( - programUrl, - {debug: DEBUG_WORKER_SCRIPT, workerParams: {profile: false}}); - const kernelNames = result.kernelNames; - expect(kernelNames) - .toEqual(jasmine.arrayWithExactContents(expectedKernels)); - - expect(result.predictions.shape[0]).toEqual(2); - expect(result.predictions.shape[1]).toEqual(512); - expect(result.predictions.shape.length).toEqual(2); - }); - }); - - describeWithFlags('rollup', CHROME_ENVS_WITH_WORKER, () => { - let rollupBundle: {full: string, custom: string}; - let originalTimeout: number; - - beforeAll(async () => { - originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL; - jasmine.DEFAULT_TIMEOUT_INTERVAL = 500000; - - const [rollupFull, rollupCustom] = await Promise.all([ - fetch(getBundleUrl( - 'universal_sentence_encoder', false /* custom */, 'rollup')) - .then(r => r.text()), - fetch(getBundleUrl( - 'universal_sentence_encoder', true /* custom */, 'rollup')) - .then(r => r.text()), - ]); - - rollupBundle = {full: rollupFull, custom: rollupCustom}; - }); - - afterAll(() => jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout); - - it('custom rollup should be smaller', async () => { - expect(rollupBundle.custom.length) - .toBeLessThan( - rollupBundle.full.length / 2, - 'Custom bundle should be smaller than full bundle'); - }); - - it('custom bundle should execute with exact kernels', async () => { - const programUrl = getBundleUrl( - 'universal_sentence_encoder', true /* custom */, 'webpack'); - - // tslint:disable-next-line: no-any - const result: any = await executeInWorker( - programUrl, - {debug: DEBUG_WORKER_SCRIPT, workerParams: {profile: false}}); - const kernelNames = result.kernelNames; - expect(kernelNames) - .toEqual(jasmine.arrayWithExactContents(expectedKernels)); - - expect(result.predictions.shape[0]).toEqual(2); - expect(result.predictions.shape[1]).toEqual(512); - expect(result.predictions.shape.length).toEqual(2); - }); - }); -}); - -/** - * Helper function for executing scripts in a webworker. We use - * webworkers to get isolated contexts for tests for custom bundles. - * - * @param programUrl url to script to run in worker - * @param debug debug mode - */ -async function executeInWorker( - programUrl: string, opts: {debug?: boolean, workerParams?: {}}) { - return new Promise((resolve, reject) => { - const debug = opts.debug || false; - const workerParams = opts.workerParams || {}; - const worker = new Worker(programUrl); - - worker.addEventListener('message', (evt) => { - if (evt.data.error) { - reject(evt.data.payload); - } - - if (debug && evt.data.msg) { - console.log('msg from worker: ', evt.data); - } - - if (evt.data.result) { - if (debug) { - console.log('result from worker: ', evt.data.result); - } - resolve(evt.data.payload); - } - }, false); - - worker.postMessage(workerParams); // Send data to our worker. - }); -} diff --git a/tfjs-master/e2e/integration_tests/grad_layers_test.ts b/tfjs-master/e2e/integration_tests/grad_layers_test.ts deleted file mode 100644 index 3f20efc9a..000000000 --- a/tfjs-master/e2e/integration_tests/grad_layers_test.ts +++ /dev/null @@ -1,53 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import '@tensorflow/tfjs-backend-cpu'; -import '@tensorflow/tfjs-backend-webgl'; -import '@tensorflow/tfjs-backend-webgpu'; - -import * as tfc from '@tensorflow/tfjs-core'; -// tslint:disable-next-line: no-imports-from-dist -import {Constraints, describeWithFlags} from '@tensorflow/tfjs-core/dist/jasmine_util'; -import * as tfl from '@tensorflow/tfjs-layers'; - -import {SMOKE} from './constants'; - -// TODO(#6518): Test against wasm as well. -const NOT_WASM: Constraints = { - predicate: testEnv => testEnv.backendName !== 'wasm', -}; -/** - * Tests that tf.grad works for layers models. - * Regression test for https://github.com/tensorflow/tfjs/issues/4130 - */ -describe(`${SMOKE} tf.grad for layers models`, () => { - describeWithFlags(`layers_model`, NOT_WASM, (env) => { - it(`can compute grad of prediction`, async () => { - await tfc.setBackend(env.name); - const model = tfl.sequential(); - model.add(tfl.layers.dense({inputShape: [1], units: 1})); - const forward = (x: tfc.Tensor) => model.predict(x) as tfc.Tensor; - const grad = tfc.grad(forward); - - const input = tfc.tensor([1], [1, 1]); - const dy = tfc.onesLike(input); - expect(() => { - grad(input, dy); - }).not.toThrow(); - }); - }); -}); diff --git a/tfjs-master/e2e/integration_tests/graph_model_golden_data/filenames.json b/tfjs-master/e2e/integration_tests/graph_model_golden_data/filenames.json deleted file mode 100644 index 64e8a872d..000000000 --- a/tfjs-master/e2e/integration_tests/graph_model_golden_data/filenames.json +++ /dev/null @@ -1 +0,0 @@ -["MobileNetV3_small_075.golden.json"] \ No newline at end of file diff --git a/tfjs-master/e2e/integration_tests/graph_model_golden_tests.ts b/tfjs-master/e2e/integration_tests/graph_model_golden_tests.ts deleted file mode 100644 index 70022122b..000000000 --- a/tfjs-master/e2e/integration_tests/graph_model_golden_tests.ts +++ /dev/null @@ -1,190 +0,0 @@ -/** - * @license - * Copyright 2023 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import '@tensorflow/tfjs-backend-cpu'; -import '@tensorflow/tfjs-backend-webgl'; - -import * as tfconverter from '@tensorflow/tfjs-converter'; -import * as tfc from '@tensorflow/tfjs-core'; -// tslint:disable-next-line: no-imports-from-dist -import {ALL_ENVS, describeWithFlags} from '@tensorflow/tfjs-core/dist/jasmine_util'; - -import {GOLDEN, KARMA_SERVER} from './constants'; -import * as GOLDEN_MODEL_DATA_FILENAMES from './graph_model_golden_data/filenames.json'; -import {GraphModeGoldenData, TensorDetail} from './types'; - -/** Directory that stores the model golden data. */ -const DATA_URL = 'graph_model_golden_data'; -const INTERMEDIATE_NODE_TESTS_NUM = 5; - -describeWithFlags(`${GOLDEN} graph_model_golden`, ALL_ENVS, (env) => { - let originalTimeout: number; - - beforeAll(async () => { - // This test needs more time to finish the async fetch, adjusting - // jasmine timeout for this test to avoid flakiness. See jasmine - // documentation for detail: - // https://jasmine.github.io/2.0/introduction.html#section-42 - originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL; - jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000000; - await tfc.setBackend(env.backendName); - }); - - afterAll(() => jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout); - - for (const goldenFilename of GOLDEN_MODEL_DATA_FILENAMES) { - describe(goldenFilename, () => { - it('model.predict(...)', async () => { - const [modelGolden, model] = await loadModelGolden(goldenFilename); - const outputs = model.predict(createGoldenInputTensors(modelGolden)); - await expectTensorsToEqualGoldens(outputs, modelGolden.outputDetails); - tfc.dispose(outputs); - }); - - it('model.execute(...) with default outputs', async () => { - const [modelGolden, model] = await loadModelGolden(goldenFilename); - const outputs = model.execute(createGoldenInputTensors(modelGolden)); - await expectTensorsToEqualGoldens(outputs, modelGolden.outputDetails); - tfc.dispose(outputs); - }); - - for (let batchId = 1; batchId <= INTERMEDIATE_NODE_TESTS_NUM; ++batchId) { - it(`model.execute(...) with intermediate node names #${batchId}`, - async () => { - const [modelGolden, model] = await loadModelGolden(goldenFilename); - const intermediateNodeNames = - Object.keys(modelGolden.intermediateDetails); - - // Validates the intermediate node tensor values and output values. - // Every `INTERMEDIATE_NODE_TESTS_NUM` nodes in - // `intermediateDetails` are chosen to be validated. - const targetNodeNames = [ - ...intermediateNodeNames.filter( - (unused, i) => - (i % INTERMEDIATE_NODE_TESTS_NUM) + 1 === batchId), - ...model.outputs.map(output => output.name), - ]; - - const goldens = targetNodeNames.map((name) => { - const details = modelGolden.intermediateDetails[name]; - if (details == null) { - throw new Error( - `Golden file is missing tensor details for ` + - `${name}`); - } - return details; - }); - - const outputs = model.execute( - createGoldenInputTensors(modelGolden), - targetNodeNames) as tfc.Tensor[]; - - expect(outputs.length).toEqual(goldens.length); - await expectTensorsToEqualGoldens(outputs, goldens); - tfc.dispose(outputs); - }); - } - }); - } -}); - -async function loadModelGolden(goldenFilename: string) { - const modelGoldenPromise: Promise = - fetch(`${KARMA_SERVER}/${DATA_URL}/${goldenFilename}`) - .then(response => response.json()); - const modelPromise = modelGoldenPromise.then((modelGolden) => { - return tfconverter.loadGraphModel(modelGolden.url, { - fromTFHub: modelGolden.fromTFHub, - }); - }); - - return Promise.all([modelGoldenPromise, modelPromise]); -} - -async function expectTensorToEqualGolden( - tensor: tfc.Tensor, golden: TensorDetail) { - expect(tensor).toEqual(jasmine.anything()); - expect(golden).toEqual(jasmine.anything()); - - expect(isTensorDetail(golden)); - expect(tensor.isDisposed).toEqual(false); - expect(tensor.dtype).toEqual(golden.dtype); - expect(tensor.shape).toEqual(golden.shape); - tfc.test_util.expectArraysClose(Array.from(await tensor.data()), golden.data); -} - -async function expectTensorsToEqualGoldens( - tensors: tfc.Tensor|tfc.Tensor[]|tfc.NamedTensorMap, - goldens: TensorDetail|TensorDetail[]|Record) { - expect(tensors).toEqual(jasmine.anything()); - expect(goldens).toEqual(jasmine.anything()); - if (tensors instanceof tfc.Tensor) { - await expectTensorToEqualGolden(tensors, goldens as TensorDetail); - } else if (Array.isArray(tensors)) { - expect(Array.isArray(goldens)).toEqual(true); - const details = goldens as TensorDetail[]; - expect(tensors.length).toEqual(details.length); - for (let i = 0; i < tensors.length; ++i) { - await expectTensorToEqualGolden(tensors[i], details[i]); - } - } else { - const detailMap = goldens as Record; - expect(new Set(Object.keys(detailMap))) - .toEqual(new Set(Object.keys(tensors))); - for (const [name, detail] of Object.entries(detailMap)) { - await expectTensorToEqualGolden(tensors[name], detail); - } - } -} - -function isTensorDetail(x: any): x is TensorDetail { - return x != null && typeof x === 'object' && 'dtype' in x && - typeof x.dtype === 'string' && 'shape' in x && Array.isArray(x.shape) && - 'data' in x && Array.isArray(x.data); -} - -function createGoldenInputTensors({inputs}: GraphModeGoldenData) { - function toTensor({data, dtype, shape}: TensorDetail) { - let typedArray: tfc.TypedArray; - switch (dtype) { - case 'bool': - typedArray = Uint8Array.from(data); - break; - case 'float32': - typedArray = Float32Array.from(data); - break; - case 'int32': - typedArray = Int32Array.from(data); - break; - default: - throw new Error(`Unsupported input tensor type ${dtype}`); - } - return tfc.tensor(typedArray, shape, dtype); - } - - if (Array.isArray(inputs)) { - return inputs.map(toTensor); - } - if (isTensorDetail(inputs)) { - return toTensor(inputs as TensorDetail); - } - return Object.entries(inputs).reduce( - (map: tfc.NamedTensorMap, [name, detail]) => { - map[name] = toTensor(detail); - return map; - }, - {}); -} diff --git a/tfjs-master/e2e/integration_tests/load_predict_data/graph_model/model.json b/tfjs-master/e2e/integration_tests/load_predict_data/graph_model/model.json deleted file mode 100644 index 5ad2cdf88..000000000 --- a/tfjs-master/e2e/integration_tests/load_predict_data/graph_model/model.json +++ /dev/null @@ -1 +0,0 @@ -{"format": "graph-model", "generatedBy": "2.1.0", "convertedBy": "TensorFlow.js Converter v1.7.4r1", "userDefinedMetadata": {"signature": {"inputs": {"Placeholder:0": {"name": "Placeholder:0", "dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "2"}, {"size": "2"}]}}}, "outputs": {"MatMul:0": {"name": "MatMul:0", "dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "2"}, {"size": "2"}]}}}}}, "modelTopology": {"node": [{"name": "w", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "2"}, {"size": "2"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "Placeholder", "op": "Placeholder", "attr": {"dtype": {"type": "DT_FLOAT"}, "shape": {"shape": {"dim": [{"size": "2"}, {"size": "2"}]}}}}, {"name": "MatMul", "op": "MatMul", "input": ["Placeholder", "w"], "device": "/device:CPU:0", "attr": {"transpose_a": {"b": false}, "transpose_b": {"b": false}, "T": {"type": "DT_FLOAT"}}}], "versions": {"producer": 175}}, "weightsManifest": [{"paths": ["weights.bin"], "weights": [{"name": "w", "shape": [2, 2], "dtype": "float32"}]}]} diff --git a/tfjs-master/e2e/integration_tests/load_predict_data/graph_model/model_new.json b/tfjs-master/e2e/integration_tests/load_predict_data/graph_model/model_new.json deleted file mode 100644 index 88a620729..000000000 --- a/tfjs-master/e2e/integration_tests/load_predict_data/graph_model/model_new.json +++ /dev/null @@ -1 +0,0 @@ -{"format": "graph-model", "generatedBy": "2.8.0", "convertedBy": "TensorFlow.js Converter v2.8.0", "signature": {"inputs": {"Placeholder:0": {"name": "Placeholder:0", "dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "2"}, {"size": "2"}]}}}, "outputs": {"MatMul:0": {"name": "MatMul:0", "dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "2"}, {"size": "2"}]}}}}, "modelTopology": {"node": [{"name": "w", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "2"}, {"size": "2"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "Placeholder", "op": "Placeholder", "attr": {"dtype": {"type": "DT_FLOAT"}, "shape": {"shape": {"dim": [{"size": "2"}, {"size": "2"}]}}}}, {"name": "MatMul", "op": "MatMul", "input": ["Placeholder", "w"], "device": "/device:CPU:0", "attr": {"transpose_a": {"b": false}, "transpose_b": {"b": false}, "T": {"type": "DT_FLOAT"}}}], "versions": {"producer": 175}}, "weightsManifest": [{"paths": ["weights.bin"], "weights": [{"name": "w", "shape": [2, 2], "dtype": "float32"}]}]} diff --git a/tfjs-master/e2e/integration_tests/load_predict_data/graph_model/weights.bin b/tfjs-master/e2e/integration_tests/load_predict_data/graph_model/weights.bin deleted file mode 100644 index 527027940..000000000 Binary files a/tfjs-master/e2e/integration_tests/load_predict_data/graph_model/weights.bin and /dev/null differ diff --git a/tfjs-master/e2e/integration_tests/load_predict_data/layers_model/model.json b/tfjs-master/e2e/integration_tests/load_predict_data/layers_model/model.json deleted file mode 100644 index 2e67d8163..000000000 --- a/tfjs-master/e2e/integration_tests/load_predict_data/layers_model/model.json +++ /dev/null @@ -1 +0,0 @@ -{"modelTopology":{"class_name":"Sequential","config":{"name":"sequential_5","layers":[{"class_name":"Embedding","config":{"input_dim":100,"output_dim":20,"embeddings_initializer":{"class_name":"RandomUniform","config":{"minval":-0.05,"maxval":0.05,"seed":null}},"embeddings_regularizer":null,"activity_regularizer":null,"embeddings_constraint":null,"mask_zero":null,"input_length":null,"name":"embedding_Embedding2","trainable":true,"batch_input_shape":[null,10],"dtype":"float32"}},{"class_name":"GRU","config":{"units":4,"activation":"tanh","recurrent_activation":"hard_sigmoid","use_bias":true,"kernel_initializer":{"class_name":"VarianceScaling","config":{"scale":1,"mode":"fan_avg","distribution":"normal","seed":null}},"recurrent_initializer":{"class_name":"Orthogonal","config":{"gain":1,"seed":null}},"bias_initializer":{"class_name":"Zeros","config":{}},"kernel_regularizer":null,"recurrent_regularizer":null,"bias_regularizer":null,"activity_regularizer":null,"kernel_constraint":null,"recurrent_constraint":null,"bias_constraint":null,"dropout":0,"recurrent_dropout":0,"implementation":null,"return_sequences":false,"return_state":false,"go_backwards":true,"stateful":false,"unroll":false,"name":"gru_GRU1","trainable":true}}]},"keras_version":"tfjs-layers 0.0.0","backend":"tensor_flow.js"},"weightsManifest":[{"paths":["weights.bin"],"weights":[{"name":"embedding_Embedding2/embeddings","shape":[100,20],"dtype":"float32"},{"name":"gru_GRU1/kernel","shape":[20,12],"dtype":"float32"},{"name":"gru_GRU1/recurrent_kernel","shape":[4,12],"dtype":"float32"},{"name":"gru_GRU1/bias","shape":[12],"dtype":"float32"}]}],"format":"layers-model","generatedBy":"TensorFlow.js tfjs-layers v0.0.0","convertedBy":null} \ No newline at end of file diff --git a/tfjs-master/e2e/integration_tests/load_predict_data/layers_model/weights.bin b/tfjs-master/e2e/integration_tests/load_predict_data/layers_model/weights.bin deleted file mode 100644 index 37107d181..000000000 Binary files a/tfjs-master/e2e/integration_tests/load_predict_data/layers_model/weights.bin and /dev/null differ diff --git a/tfjs-master/e2e/integration_tests/load_predict_test.ts b/tfjs-master/e2e/integration_tests/load_predict_test.ts deleted file mode 100644 index a2de61c76..000000000 --- a/tfjs-master/e2e/integration_tests/load_predict_test.ts +++ /dev/null @@ -1,86 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import '@tensorflow/tfjs-backend-cpu'; -import '@tensorflow/tfjs-backend-webgl'; -import '@tensorflow/tfjs-backend-webgpu'; - -import * as tfconverter from '@tensorflow/tfjs-converter'; -import * as tfc from '@tensorflow/tfjs-core'; -// tslint:disable-next-line: no-imports-from-dist -import {ALL_ENVS, describeWithFlags} from '@tensorflow/tfjs-core/dist/jasmine_util'; -import * as tfl from '@tensorflow/tfjs-layers'; - -import {KARMA_SERVER, SMOKE} from './constants'; - -/** - * This file is the test suites for CUJ: load->predict. - * - * This file test below things: - * - Load layers or graph model. - * - Make inference using each backends. - */ -describe(`${SMOKE} load_predict`, () => { - describeWithFlags(`layers_model`, ALL_ENVS, (env) => { - it(`predict`, async () => { - await tfc.setBackend(env.name); - const model = await tfl.loadLayersModel( - `${KARMA_SERVER}/load_predict_data/layers_model/model.json`); - const inputs = - tfc.tensor([86, 11, 62, 40, 36, 75, 82, 94, 67, 75], [1, 10]); - const expected = [ - -0.003578941337764263, 0.0028922036290168762, -0.002957976423203945, - 0.00955402385443449 - ]; - const result = model.predict(inputs) as tfc.Tensor; - tfc.test_util.expectArraysClose(await result.data(), expected); - inputs.dispose(); - }); - }); - - describeWithFlags(`graph_model`, ALL_ENVS, async (env) => { - let a: tfc.Tensor; - - const expected = [ - 0.7567615509033203, -0.18349379301071167, 0.7567615509033203, - -0.18349379301071167 - ]; - - beforeEach(async () => { - await tfc.setBackend(env.name); - a = tfc.tensor2d([1, 1, 1, 1], [2, 2], 'float32'); - }); - - afterEach(() => { - a.dispose(); - }); - - it(`predict for old model.`, async () => { - const model = await tfconverter.loadGraphModel( - `${KARMA_SERVER}/load_predict_data/graph_model/model.json`); - const result = await model.executeAsync({'Placeholder': a}) as tfc.Tensor; - tfc.test_util.expectArraysClose(await result.data(), expected); - }); - - it(`predict for new model.`, async () => { - const model = await tfconverter.loadGraphModel( - `${KARMA_SERVER}/load_predict_data/graph_model/model_new.json`); - const result = await model.executeAsync({'Placeholder': a}) as tfc.Tensor; - tfc.test_util.expectArraysClose(await result.data(), expected); - }); - }); -}); diff --git a/tfjs-master/e2e/integration_tests/memory_leak_test.ts b/tfjs-master/e2e/integration_tests/memory_leak_test.ts deleted file mode 100644 index bc849475e..000000000 --- a/tfjs-master/e2e/integration_tests/memory_leak_test.ts +++ /dev/null @@ -1,104 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import '@tensorflow/tfjs-backend-cpu'; -import '@tensorflow/tfjs-backend-webgl'; -import '@tensorflow/tfjs-backend-webgpu'; - -import * as tfconverter from '@tensorflow/tfjs-converter'; -import * as tfc from '@tensorflow/tfjs-core'; -// tslint:disable-next-line: no-imports-from-dist -import {ALL_ENVS, describeWithFlags} from '@tensorflow/tfjs-core/dist/jasmine_util'; - -import {SMOKE} from './constants'; - -const HOST = 'http://example.org'; -const MODEL_URL = `${HOST}/model.json`; - -const CUSTOM_OP_MODEL = { - node: [ - { - name: 'Input', - op: 'Placeholder', - attr: { - dtype: { - type: 1, // DT_FLOAT - }, - shape: {shape: {dim: [{size: 4}]}} - } - }, - {name: 'CustomOp', op: 'CustomOp', input: ['Input'], attr: {}} - ], - versions: {producer: 1.0, minConsumer: 3} -}; - -const weightsManifest: tfc.io.WeightsManifestEntry[] = - [{'name': 'Const', 'dtype': 'float32', 'shape': [1]}]; - -const CUSTOM_HTTP_MODEL_LOADER = { - load: async () => { - const bias = tfc.tensor1d([0], 'float32'); - return { - modelTopology: CUSTOM_OP_MODEL, - weightSpecs: weightsManifest, - weightData: bias.dataSync(), - format: 'tfjs-graph-model', - generatedBy: '1.15', - convertedBy: '1.3.1' - }; - } -}; - -describeWithFlags( - `${SMOKE} A custom op that calls unmodularized kernels and modularized ` + - `kernels`, - ALL_ENVS, () => { - it('should have no memory leak in a model run.', async () => { - const model = new tfconverter.GraphModel(MODEL_URL); - - spyOn(tfc.io, 'getLoadHandlers').and.returnValue([ - CUSTOM_HTTP_MODEL_LOADER - ]); - - // A custom op that calls unmodularized kernels and modularized kernels. - tfconverter.registerOp('CustomOp', (nodeValue) => { - const x = nodeValue.inputs[0]; - const softMax = tfc.softmax(x); - const clone = tfc.clone(softMax); - return [tfc.reshape(clone, [2, 2])]; - }); - - await model.load(); - - const before = tfc.memory().numTensors; - - const input = tfc.tensor1d([1, 2, 3, 4]); - const output = model.predict(input) as tfc.Tensor; - - tfc.test_util.expectArraysClose(await output.data(), [ - 0.032058604061603546, 0.08714432269334793, 0.23688283562660217, - 0.6439142823219299 - ]); - - input.dispose(); - output.dispose(); - - const after = tfc.memory().numTensors; - - expect(after).toEqual(before); - }); - }); diff --git a/tfjs-master/e2e/integration_tests/metadata.py b/tfjs-master/e2e/integration_tests/metadata.py deleted file mode 100644 index 31a577024..000000000 --- a/tfjs-master/e2e/integration_tests/metadata.py +++ /dev/null @@ -1,105 +0,0 @@ -# @license -# Copyright 2020 Google LLC. All Rights Reserved. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================= - -# This file is 1/2 of the test suites for CUJ: convert->predict. -# -# This file does below things: -# - Create saved models with TensorFlow. -# - Convert the saved models to tfjs format and store in files. -# - Store inputs in files. -# - Make inference and store outputs in files. - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -import argparse -import functools -import json -import os -import subprocess -import shutil -import sys -import tempfile -import time - -import numpy as np -import tensorflow as tf -from tensorflow.python.eager import def_function -from tensorflow.python.framework import constant_op -from tensorflow.python.framework import dtypes -from tensorflow.python.framework import tensor_spec -from tensorflow.python.ops import variables -from tensorflow.python.trackable import autotrackable -from tensorflow.python.saved_model.save import save -import tensorflow_hub as hub -import tensorflowjs as tfjs - -curr_dir = os.path.dirname(os.path.realpath(__file__)) -_tmp_dir = os.path.join(curr_dir, 'metadata') - -def _create_model_with_metadata(): - # Generate model, inputs, and outputs using Tensorflow. - tmp_saved_model_dir = tempfile.mkdtemp() - model_info = _create_saved_model(tmp_saved_model_dir) - - metadata1 = {'a': 1} - metadata2 = {'label1': 0, 'label2': 1} - metadata1_path = os.path.join(_tmp_dir, 'metadata1.json') - metadata2_path = os.path.join(_tmp_dir, 'metadata2.json') - with open(metadata1_path, 'w') as f: - f.write(json.dumps(metadata1)) - with open(metadata2_path, 'w') as f: - f.write(json.dumps(metadata2)) - metadata_option = 'metadata1:'+metadata1_path+','+'metadata2:'+metadata2_path - - # Convert and store model to file. - args = [ - 'tensorflowjs_converter', - '--input_format', 'tf_saved_model', - '--output_format', 'tfjs_graph_model', - '--signature_name', 'serving_default', - '--saved_model_tags', 'serve', - '--metadata', metadata_option]; - - print(args, tmp_saved_model_dir, _tmp_dir) - subprocess.check_output(args +[tmp_saved_model_dir, _tmp_dir]) - -def _create_saved_model(save_dir): - input_data = constant_op.constant(1., shape=[1]) - root = autotrackable.AutoTrackable() - root.v1 = variables.Variable(3.) - root.v2 = variables.Variable(2.) - root.f = def_function.function(lambda x: root.v1 * root.v2 * x) - to_save = root.f.get_concrete_function(input_data) - - save(root, save_dir, to_save) - return { - "async": False, - "inputs": { - "x": {"value": [1], "shape": [1], "dtype": 'float32'}}, - "outputs": { - "Identity:0": {"value": [6], "shape": [1], "dtype": "float32"}}} - -def main(): - # Create the directory to store model and data. - if os.path.exists(_tmp_dir) and os.path.isdir(_tmp_dir): - shutil.rmtree(_tmp_dir) - os.mkdir(_tmp_dir) - - _create_model_with_metadata() - -if __name__ == '__main__': - main() diff --git a/tfjs-master/e2e/integration_tests/metadata.ts b/tfjs-master/e2e/integration_tests/metadata.ts deleted file mode 100644 index a17997991..000000000 --- a/tfjs-master/e2e/integration_tests/metadata.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import * as tfconverter from '@tensorflow/tfjs-converter'; -import {KARMA_SERVER, REGRESSION} from './constants'; -import * as tfc from '@tensorflow/tfjs-core'; - -const DATA_URL = 'metadata'; - -describe(`${REGRESSION} Metadata`, () => { - it('can load metadata.', async () => { - await tfc.ready(); - const model = await tfconverter.loadGraphModel( - `${KARMA_SERVER}/${DATA_URL}/model.json`); - const metadata = {metadata1: {a: 1}, metadata2: {label1: 0, label2: 1}}; - expect(model.metadata).toEqual(metadata); - }); -}); diff --git a/tfjs-master/e2e/integration_tests/requirements-dev.txt b/tfjs-master/e2e/integration_tests/requirements-dev.txt deleted file mode 100644 index 577fbe57a..000000000 --- a/tfjs-master/e2e/integration_tests/requirements-dev.txt +++ /dev/null @@ -1 +0,0 @@ --r ../../tfjs-converter/python/requirements.txt diff --git a/tfjs-master/e2e/integration_tests/requirements-stable.txt b/tfjs-master/e2e/integration_tests/requirements-stable.txt deleted file mode 100644 index 577fbe57a..000000000 --- a/tfjs-master/e2e/integration_tests/requirements-stable.txt +++ /dev/null @@ -1 +0,0 @@ --r ../../tfjs-converter/python/requirements.txt diff --git a/tfjs-master/e2e/integration_tests/setup_test.ts b/tfjs-master/e2e/integration_tests/setup_test.ts deleted file mode 100644 index 8e319b1a6..000000000 --- a/tfjs-master/e2e/integration_tests/setup_test.ts +++ /dev/null @@ -1,136 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// Import core for side effects (e.g. flag registration) -import '@tensorflow/tfjs-core'; -// tslint:disable-next-line: no-imports-from-dist -import '@tensorflow/tfjs-core/dist/public/chained_ops/register_all_chained_ops'; -import '@tensorflow/tfjs-backend-wasm'; - -// tslint:disable-next-line: no-imports-from-dist -import {parseTestEnvFromKarmaFlags, registerTestEnv, setTestEnvs, TEST_ENVS} from '@tensorflow/tfjs-core/dist/jasmine_util'; - -import {TAGS} from './constants'; - -registerTestEnv({ - name: 'webgl', - backendName: 'webgl', - flags: { - 'WEBGL_VERSION': 2, - 'WEBGL_CPU_FORWARD': false, - 'WEBGL_SIZE_UPLOAD_UNIFORM': 0 - }, - isDataSync: true -}); - -registerTestEnv({ - name: 'wasm', - backendName: 'wasm', - isDataSync: true, -}); - -registerTestEnv({name: 'cpu', backendName: 'cpu', isDataSync: true}); - -// TODO: Support test windows on WebGPU. Bug: -// https://github.com/tensorflow/tfjs/issues/7616. -if (navigator.platform.toUpperCase().indexOf('MAC') >= 0 && - (window as any).chrome != null) { - registerTestEnv({ - name: 'webgpu', - backendName: 'webgpu', - flags: {'WEBGPU_CPU_FORWARD': false}, - isDataSync: true - }); -} - -// tslint:disable-next-line:no-any -declare let __karma__: any; -if (typeof __karma__ !== 'undefined') { - const args = __karma__.config.args || []; - - const testEnv = parseTestEnvFromKarmaFlags(__karma__.config.args, TEST_ENVS); - if (testEnv != null) { - setTestEnvs([testEnv]); - } - - let tags; - - args.forEach((arg: string, i: number) => { - if (arg === '--tags') { - tags = parseTags(args[i + 1]); - } - }); - - setupTestFilters(tags); -} - -/** - * Given a string separated with comma, validate and return tags as an array. - */ -function parseTags(tagsInput: string): string[] { - if (!tagsInput || tagsInput === '') { - throw new Error( - '--tags did not have any value. Please specify tags separated ' + - 'by comma.'); - } - - const tags = tagsInput.split(','); - - const $tags = []; - - for (let i = 0; i < tags.length; i++) { - const tag = tags[i].trim(); - - if (!TAGS.includes(tag)) { - throw new Error(`Tag ${tag} is not supported. Supported tags: ${TAGS}`); - } - $tags.push(tag); - } - - return $tags; -} - -/** - * Run Jasmine tests only for allowlisted tags. - */ -function setupTestFilters(tags: string[] = []) { - const env = jasmine.getEnv(); - - // Account for --grep flag passed to karma by saving the existing specFilter. - const grepFilter = env.specFilter; - - // tslint:disable-next-line: no-any - env.specFilter = (spec: any) => { - // Filter out tests if the --grep flag is passed. - if (!grepFilter(spec)) { - return false; - } - - const name = spec.getFullName(); - - // Only include a test if it belongs to one of the specified tags. - for (let i = 0; i < tags.length; i++) { - const tag = tags[i]; - if (name.includes(tag)) { - return true; - } - } - - // Otherwise ignore the test. - return false; - }; -} diff --git a/tfjs-master/e2e/integration_tests/test_util.ts b/tfjs-master/e2e/integration_tests/test_util.ts deleted file mode 100644 index faeca3caa..000000000 --- a/tfjs-master/e2e/integration_tests/test_util.ts +++ /dev/null @@ -1,45 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tfc from '@tensorflow/tfjs-core'; - -/** - * Create a list of input tensors. - * @param inputsData An array with each element being the value to create a - * tensor. - * @param inputsShapes An array with each element being the shape to create a - * tensor. - */ -export function createInputTensors( - inputsData: tfc.TypedArray[], inputsShapes: number[][], - inputDtypes?: tfc.DataType[], inputNames?: string[]): tfc.Tensor[]| - tfc.NamedTensorMap { - const xs: tfc.Tensor[] = []; - for (let i = 0; i < inputsData.length; i++) { - const input = tfc.tensor( - inputsData[i], inputsShapes[i], - inputDtypes ? inputDtypes[i] : 'float32'); - xs.push(input); - } - if (inputNames) { - return inputNames.reduce((map: tfc.NamedTensorMap, name, index) => { - map[name] = xs[index]; - return map; - }, {}); - } - return xs; -} diff --git a/tfjs-master/e2e/integration_tests/types.ts b/tfjs-master/e2e/integration_tests/types.ts deleted file mode 100644 index 274447313..000000000 --- a/tfjs-master/e2e/integration_tests/types.ts +++ /dev/null @@ -1,46 +0,0 @@ -/** - * @license - * Copyright 2023 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import * as tfc from '@tensorflow/tfjs-core'; - -export interface TensorDetail { - data: number[]; - shape: number[]; - dtype: tfc.DataType; -} - -export interface GraphModeGoldenData { - /** The model name. */ - readonly name: string; - /** Url for loading the model with `tf.loadGraphModel`. */ - readonly url: string; - /** Whether model is to be loaded from TF Hub. */ - readonly fromTFHub?: boolean; - /** - * Golden tensor values for `model.predict`. - */ - readonly inputs: TensorDetail|TensorDetail[]|Record; - /** - * The returned tensor values of `model.predict(this.inputs)`. - */ - readonly outputDetails: TensorDetail|TensorDetail[]| - Record; - /** - * All intermediate node tensor values after calling - * `model.predict(this.inputs)`. The object keys are the node names. - */ - readonly intermediateDetails: Record; -} diff --git a/tfjs-master/e2e/karma.conf.js b/tfjs-master/e2e/karma.conf.js deleted file mode 100644 index e478c88bf..000000000 --- a/tfjs-master/e2e/karma.conf.js +++ /dev/null @@ -1,213 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -const karmaTypescriptConfig = { - tsconfig: 'tsconfig.json', - coverageOptions: {instrumentation: false}, - bundlerOptions: { - sourceMap: true, - transforms: [ - require('karma-typescript-es6-transform')({ - presets: [ - // ensure we get es5 by adding IE 11 as a target - ['@babel/env', {targets: {browsers: ['defaults', 'IE 11']}}] - ] - }), - ] - } -}; - -// Enable coverage reports and instrumentation under KARMA_COVERAGE=1 env -const coverageEnabled = !!process.env.KARMA_COVERAGE; -if (coverageEnabled) { - karmaTypescriptConfig.coverageOptions.instrumentation = true; - karmaTypescriptConfig.coverageOptions.exclude = /_test\.ts$/; - karmaTypescriptConfig.reports = {html: 'coverage', 'text-summary': ''}; -} - -const devConfig = { - frameworks: ['jasmine', 'karma-typescript'], - files: [ - {pattern: './node_modules/@babel/polyfill/dist/polyfill.js'}, - 'integration_tests/setup_test.ts', - {pattern: 'integration_tests/**/*.ts'}, - { - pattern: 'integration_tests/*_data/**/*', - watched: true, - included: false, - served: true, - nocache: true - }, - { - pattern: 'integration_tests/metadata/**/*', - watched: true, - included: false, - served: true, - nocache: true - }, - // Serve program bundles as files - { - pattern: 'custom_module/*/dist/**/*', - watched: true, - included: false, - served: true, - nocache: true - }, - // Serve model assets as files - { - pattern: 'custom_module/*/model/**/*', - watched: true, - included: false, - served: true, - nocache: true - }, - // Serve wasm files - { - pattern: 'node_modules/@tensorflow/tfjs-backend-wasm/wasm-out/*.wasm', - watched: true, - included: false, - served: true, - }, - ], - basePath: '', - proxies: { - '/base/node_modules/karma-typescript/dist/client/tfjs-backend-wasm.wasm': - '/base/node_modules/@tensorflow/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm.wasm', - '/base/node_modules/karma-typescript/dist/client/tfjs-backend-wasm-simd.wasm': - '/base/node_modules/@tensorflow/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm-simd.wasm', - '/base/node_modules/karma-typescript/dist/client/tfjs-backend-wasm-threaded-simd.wasm': - '/base/node_modules/@tensorflow/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm-threaded-simd.wasm', - }, - exclude: ['integration_tests/custom_bundle_test.ts'], - include: ['integration_tests/**/*.ts'], - preprocessors: { - '**/*.ts': ['karma-typescript'], // *.tsx for React Jsx - }, - karmaTypescriptConfig, - reporters: ['spec', 'karma-typescript'] -}; - -const browserstackConfig = { - ...devConfig, - // TODONT: do not use `hostname: 'bs-local.com'. This is automatically changed - // by BrowserStack when necessary (i.e. on ios safari). Setting it manually - // breaks WASM file serving. - // See https://www.browserstack.com/question/39574 - singleRun: true, - port: 9200 -}; - -const chromeWebgpuFlags = [ - '--enable-unsafe-webgpu', // Can be removed after WebGPU release - '--use-webgpu-adapter=swiftshader', - // https://github.com/tensorflow/tfjs/issues/7631 - '--disable-vulkan-fallback-to-gl-for-testing', -]; - -module.exports = function(config) { - const args = []; - - if (config.testEnv) { - args.push('--testEnv', config.testEnv); - } - if (config.flags) { - args.push('--flags', config.flags); - } - if (config.grep) { - args.push('--grep', config.grep); - } - if (config.tags) { - args.push('--tags', config.tags); - } - - let extraConfig = null; - - if (config.browserstack) { - extraConfig = browserstackConfig; - } else { - extraConfig = devConfig; - } - - config.set({ - ...extraConfig, - reporters: [ - 'spec', - 'jasmine-order', - ], - browsers: ['Chrome'], - browserStack: { - username: process.env.BROWSERSTACK_USERNAME, - accessKey: process.env.BROWSERSTACK_KEY, - timeout: 1800, - tunnelIdentifier: `e2e_${Date.now()}_${Math.floor(Math.random() * 1000)}` - }, - captureTimeout: 3e5, - reportSlowerThan: 500, - browserNoActivityTimeout: 3e5, - browserDisconnectTimeout: 3e5, - browserDisconnectTolerance: 0, - browserSocketTimeout: 1.2e5, - customLaunchers: { - bs_chrome_mac: { - base: 'BrowserStack', - browser: 'chrome', - browser_version: 'latest', - os: 'OS X', - os_version: 'High Sierra', - flags: chromeWebgpuFlags, - }, - bs_firefox_mac: { - base: 'BrowserStack', - browser: 'firefox', - browser_version: 'latest', - os: 'OS X', - os_version: 'High Sierra' - }, - bs_safari_mac: { - base: 'BrowserStack', - browser: 'safari', - browser_version: 'latest', - os: 'OS X', - os_version: 'Mojave' - }, - bs_ios_12: { - base: 'BrowserStack', - device: 'iPhone XS', - os: 'ios', - os_version: '12.3', - real_mobile: true - }, - bs_android_10: { - base: 'BrowserStack', - device: 'Google Pixel 4 XL', - os: 'android', - os_version: '10.0', - real_mobile: true - }, - win_10_chrome: { - base: 'BrowserStack', - browser: 'chrome', - browser_version: '101.0', - os: 'Windows', - os_version: '10', - flags: chromeWebgpuFlags, - } - }, - client: {jasmine: {random: false}, args: args, captureConsole: true}, - logLevel: 'info' - }); -}; diff --git a/tfjs-master/e2e/package.json b/tfjs-master/e2e/package.json deleted file mode 100644 index eab1b88f7..000000000 --- a/tfjs-master/e2e/package.json +++ /dev/null @@ -1,69 +0,0 @@ -{ - "name": "benchmarks", - "version": "0.0.1", - "description": "Benchmark for TensorFlow.js", - "private": true, - "repository": { - "type": "git", - "url": "https://github.com/tensorflow/tfjs" - }, - "devDependencies": { - "@babel/polyfill": "^7.10.4", - "@tensorflow/tfjs": "link:../tfjs", - "@tensorflow/tfjs-backend-cpu": "link:../link-package/node_modules/@tensorflow/tfjs-backend-cpu", - "@tensorflow/tfjs-backend-wasm": "link:../link-package/node_modules/@tensorflow/tfjs-backend-wasm", - "@tensorflow/tfjs-backend-webgl": "link:../link-package/node_modules/@tensorflow/tfjs-backend-webgl", - "@tensorflow/tfjs-backend-webgpu": "link:../link-package/node_modules/@tensorflow/tfjs-backend-webgpu", - "@tensorflow/tfjs-converter": "link:../link-package/node_modules/@tensorflow/tfjs-converter", - "@tensorflow/tfjs-core": "link:../link-package/node_modules/@tensorflow/tfjs-core", - "@tensorflow/tfjs-data": "link:../link-package/node_modules/@tensorflow/tfjs-data", - "@tensorflow/tfjs-layers": "link:../link-package/node_modules/@tensorflow/tfjs-layers", - "@tensorflow/tfjs-node": "link:../tfjs-node", - "@types/detect-browser": "^4.0.0", - "@types/jasmine": "~3.0.0", - "@types/mathjs": "^5.0.1", - "clang-format": "~1.2.4", - "detect-browser": "~4.2.0", - "jasmine": "~3.1.0", - "jasmine-core": "~3.1.0", - "karma": "~6.3.20", - "karma-browserstack-launcher": "~1.6.0", - "karma-chrome-launcher": "~3.1.1", - "karma-jasmine": "~1.1.0", - "karma-jasmine-order-reporter": "^1.1.0", - "karma-spec-reporter": "~0.0.32", - "karma-typescript": "~5.5.1", - "karma-typescript-es6-transform": "^5.1.0", - "mathjs": "^7.5.1", - "request": "^2.88.0", - "ts-node": "^10.9.1", - "tsify": "^3.0.4", - "tslint": "^6.1.3", - "tslint-no-circular-imports": "~0.7.0", - "typescript": "5.0.4" - }, - "scripts": { - "build": "tsc", - "build-link-package": "cd ../link-package && yarn build", - "build-union": "cd ../tfjs && yarn && yarn build", - "build-union-ci": "cd ../tfjs && yarn && yarn build-ci", - "build-node": "cd ../tfjs-node && yarn && yarn build", - "build-node-ci": "cd ../tfjs-node && yarn && yarn build-ci", - "build-deps": "yarn build-link-package && yarn build-union && yarn build-node", - "build-deps-ci": "./scripts/build-deps-ci.sh", - "build-graph-model-golden-data": "ts-node ./scripts/build-graph-model-golden-data.ts", - "fetch-graph-model-golden-data-ci": "./scripts/fetch-graph-model-golden-data-ci.sh", - "lint": "tslint -p . -t verbose", - "run-browserstack": "karma start --browserstack", - "test": "./scripts/test.sh", - "coverage": "KARMA_COVERAGE=1 ./scripts/test.sh", - "test-ci": "./scripts/test-ci.sh", - "deploy-benchmarks": "./scripts/deploy-benchmarks.sh", - "deploy-benchmarks-dev": "./scripts/deploy-benchmarks.sh --dev", - "deploy-benchmarks-staging": "./scripts/deploy-benchmarks.sh --staging" - }, - "license": "Apache-2.0", - "engines": { - "yarn": ">= 1.0.0" - } -} diff --git a/tfjs-master/e2e/script_tag_tests/tfjs-core-cpu/core_test.js b/tfjs-master/e2e/script_tag_tests/tfjs-core-cpu/core_test.js deleted file mode 100644 index 03178844d..000000000 --- a/tfjs-master/e2e/script_tag_tests/tfjs-core-cpu/core_test.js +++ /dev/null @@ -1,74 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -describe('loaded packages', () => { - it('should have core', () => { - expect(tf.version_core).toBeTruthy(); - }); - - it('should have cpu backend', () => { - expect(tf.version_cpu).toBeTruthy(); - }); -}); - -describe('ops', () => { - beforeAll(async () => { - await tf.setBackend('cpu'); - }); - - it('should support basic math', () => { - tf.tidy(() => { - const a = tf.scalar(3); - const b = tf.scalar(4); - expect(tf.add(a, b).dataSync()[0]).toBe(7); - }); - }); - - it('should clone', () => { - tf.tidy(() => { - const a = tf.tensor([1, 2, 3, 4]); - const b = tf.tensor([1, 2, 3, 4]).clone(); - expect(a.dataSync()).toEqual(b.dataSync()); - }); - }); - - it('should reshape', () => { - tf.tidy(() => { - const a = tf.tensor([1, 2, 3, 4], [1, 4]); - const b = tf.reshape(a, [2, 2]); - expect(a.dataSync()).toEqual(b.dataSync()); - }); - }); - - it('should cast', () => { - tf.tidy(() => { - const a = tf.tensor([1, 2, 3, 4], [1, 4], 'float32'); - const b = a.cast('int32'); - expect(Array.from(a.dataSync())).toEqual(Array.from(b.dataSync())); - }); - }); -}); - -describe('backends are registered', () => { - it('should find cpu backend', () => { - expect(tf.findBackend('cpu')).toBeTruthy(); - }); - - it('should not find fake backend', () => { - expect(tf.findBackend('fake')).toBeFalsy(); - }); -}); diff --git a/tfjs-master/e2e/script_tag_tests/tfjs-core-cpu/karma.conf.js b/tfjs-master/e2e/script_tag_tests/tfjs-core-cpu/karma.conf.js deleted file mode 100644 index 55bc70140..000000000 --- a/tfjs-master/e2e/script_tag_tests/tfjs-core-cpu/karma.conf.js +++ /dev/null @@ -1,124 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -module.exports = function(config) { - const args = []; - - const coreBundle = config.coreBundle ? config.coreBundle : 'tf-core.min.js'; - const coreBundlePath = - `../../node_modules/@tensorflow/tfjs-core/dist/${coreBundle}`; - const cpuBundle = - config.cpuBundle ? config.cpuBundle : 'tf-backend-cpu.min.js'; - const cpuBundlePath = - `../../node_modules/@tensorflow/tfjs-backend-cpu/dist/${cpuBundle}`; - - const devConfig = { - frameworks: ['jasmine'], - files: [ - { - pattern: coreBundlePath, - nocache: true, - }, - { - pattern: cpuBundlePath, - nocache: true, - }, - {pattern: './**/*_test.js'}, - ], - reporters: ['progress'] - }; - - const browserstackConfig = - {...devConfig, hostname: 'bs-local.com', singleRun: true, port: 9200}; - - if (config.grep) { - args.push('--grep', config.grep); - } - if (config.tags) { - args.push('--tags', config.tags); - } - - let extraConfig = null; - - if (config.browserstack) { - extraConfig = browserstackConfig; - } else { - extraConfig = devConfig; - } - - config.set({ - ...extraConfig, - browsers: ['Chrome'], - browserStack: { - username: process.env.BROWSERSTACK_USERNAME, - accessKey: process.env.BROWSERSTACK_KEY, - tunnelIdentifier: `e2e_script_tag_tests_${Date.now()}_${ - Math.floor(Math.random() * 1000)}` - }, - captureTimeout: 3e5, - reportSlowerThan: 500, - browserNoActivityTimeout: 3e5, - browserDisconnectTimeout: 3e5, - browserDisconnectTolerance: 0, - browserSocketTimeout: 1.2e5, - customLaunchers: { - bs_chrome_mac: { - base: 'BrowserStack', - browser: 'chrome', - browser_version: 'latest', - os: 'OS X', - os_version: 'High Sierra' - }, - bs_firefox_mac: { - base: 'BrowserStack', - browser: 'firefox', - browser_version: 'latest', - os: 'OS X', - os_version: 'High Sierra' - }, - bs_safari_mac: { - base: 'BrowserStack', - browser: 'safari', - browser_version: 'latest', - os: 'OS X', - os_version: 'Mojave' - }, - bs_ios_12: { - base: 'BrowserStack', - device: 'iPhone X', - os: 'iOS', - os_version: '12.3', - real_mobile: true - }, - bs_android_10: { - base: 'BrowserStack', - device: 'Google Pixel 4 XL', - os: 'android', - os_version: '10.0', - real_mobile: true - }, - win_10_chrome: { - base: 'BrowserStack', - browser: 'chrome', - browser_version: '101.0', - os: 'Windows', - os_version: '10' - } - }, - client: {jasmine: {random: false}, args: args} - }); -}; diff --git a/tfjs-master/e2e/script_tag_tests/tfjs/karma.conf.js b/tfjs-master/e2e/script_tag_tests/tfjs/karma.conf.js deleted file mode 100644 index 46146a61e..000000000 --- a/tfjs-master/e2e/script_tag_tests/tfjs/karma.conf.js +++ /dev/null @@ -1,116 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -module.exports = function(config) { - const args = []; - - const tfjsBundle = config.testBundle ? config.testBundle : 'tf.min.js'; - const tfjsBundlePath = - `../../node_modules/@tensorflow/tfjs/dist/${tfjsBundle}`; - - const devConfig = { - frameworks: ['jasmine'], - files: [ - { - pattern: tfjsBundlePath, - nocache: true, - }, - {pattern: './**/*_test.js'}, - ], - reporters: ['progress'] - }; - - const browserstackConfig = - {...devConfig, hostname: 'bs-local.com', singleRun: true, port: 9200}; - - if (config.grep) { - args.push('--grep', config.grep); - } - if (config.tags) { - args.push('--tags', config.tags); - } - - let extraConfig = null; - - if (config.browserstack) { - extraConfig = browserstackConfig; - } else { - extraConfig = devConfig; - } - - config.set({ - ...extraConfig, - browsers: ['Chrome'], - browserStack: { - username: process.env.BROWSERSTACK_USERNAME, - accessKey: process.env.BROWSERSTACK_KEY, - tunnelIdentifier: `e2e_script_tag_tests_${Date.now()}_${ - Math.floor(Math.random() * 1000)}` - }, - captureTimeout: 3e5, - reportSlowerThan: 500, - browserNoActivityTimeout: 3e5, - browserDisconnectTimeout: 3e5, - browserDisconnectTolerance: 0, - browserSocketTimeout: 1.2e5, - customLaunchers: { - bs_chrome_mac: { - base: 'BrowserStack', - browser: 'chrome', - browser_version: 'latest', - os: 'OS X', - os_version: 'High Sierra' - }, - bs_firefox_mac: { - base: 'BrowserStack', - browser: 'firefox', - browser_version: 'latest', - os: 'OS X', - os_version: 'High Sierra' - }, - bs_safari_mac: { - base: 'BrowserStack', - browser: 'safari', - browser_version: 'latest', - os: 'OS X', - os_version: 'Mojave' - }, - bs_ios_12: { - base: 'BrowserStack', - device: 'iPhone X', - os: 'iOS', - os_version: '12.3', - real_mobile: true - }, - bs_android_10: { - base: 'BrowserStack', - device: 'Google Pixel 4 XL', - os: 'android', - os_version: '10.0', - real_mobile: true - }, - win_10_chrome: { - base: 'BrowserStack', - browser: 'chrome', - browser_version: 'latest', - os: 'Windows', - os_version: '10' - } - }, - client: {jasmine: {random: false}, args: args} - }); -}; diff --git a/tfjs-master/e2e/script_tag_tests/tfjs/symbols_and_basic_api_test.js b/tfjs-master/e2e/script_tag_tests/tfjs/symbols_and_basic_api_test.js deleted file mode 100644 index 5adcdd696..000000000 --- a/tfjs-master/e2e/script_tag_tests/tfjs/symbols_and_basic_api_test.js +++ /dev/null @@ -1,127 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -describe('tfjs union sub-packages', () => { - it('should have core', () => { - expect(tf.version['tfjs-core']).toBeTruthy(); - }); - - it('should have cpu backend', () => { - expect(tf.version['tfjs-backend-cpu']).toBeTruthy(); - }); - - it('should have webgl backend', () => { - expect(tf.version['tfjs-backend-webgl']).toBeTruthy(); - }); - - it('should have converter', () => { - expect(tf.version['tfjs-converter']).toBeTruthy(); - }); - - it('should have layers', () => { - expect(tf.version['tfjs-layers']).toBeTruthy(); - }); - - it('should have data', () => { - expect(tf.version['tfjs-data']).toBeTruthy(); - }); - - it('should have union version', () => { - expect(tf.version['tfjs']).toBeTruthy(); - }); -}); - -describe('ops', () => { - beforeAll(async () => { - await tf.setBackend('cpu'); - }); - - it('should support basic math', () => { - tf.tidy(() => { - const a = tf.scalar(3); - const b = tf.scalar(4); - expect(tf.add(a, b).dataSync()[0]).toBe(7); - }); - }); - - it('should clone', () => { - tf.tidy(() => { - const a = tf.tensor([1, 2, 3, 4]); - const b = tf.tensor([1, 2, 3, 4]).clone(); - expect(a.dataSync()).toEqual(b.dataSync()); - }); - }); - - it('should reshape', () => { - tf.tidy(() => { - const a = tf.tensor([1, 2, 3, 4], [1, 4]); - const b = a.reshape([2, 2]); - expect(a.dataSync()).toEqual(b.dataSync()); - }); - }); - - it('should cast', () => { - tf.tidy(() => { - const a = tf.tensor([1, 2, 3, 4], [1, 4], 'float32'); - const b = a.cast('int32'); - expect(Array.from(a.dataSync())).toEqual(Array.from(b.dataSync())); - }); - }); -}); - -describe('backends are registered', () => { - it('should find cpu backend', () => { - expect(tf.findBackend('cpu')).toBeTruthy(); - }); - - it('should find webgl backend', () => { - expect(tf.findBackend('webgl')).toBeTruthy(); - }); - - it('should not find fake backend', () => { - expect(tf.findBackend('fake')).toBeFalsy(); - }); -}); - -describe('chaining api is present', () => { - it('tensor should have max method', () => { - tf.tidy(() => { - const a = tf.scalar(3); - expect(a.max).toBeDefined(); - }); - }); - - it('tensor should have resizeBilinear method', () => { - tf.tidy(() => { - const a = tf.scalar(3); - expect(a.resizeBilinear).toBeDefined(); - }); - }); -}); - - -describe('gradients are registered', () => { - it('SplitV gradient should be registered', () => { - const gradient = tf.getGradient(tf.SplitV); - expect(gradient).toBeDefined(); - }); - - it('fake gradient does not exist', () => { - const gradient = tf.getGradient('NotARealKernel'); - expect(gradient).toBeUndefined(); - }); -}); diff --git a/tfjs-master/e2e/scripts/build-deps-ci.sh b/tfjs-master/e2e/scripts/build-deps-ci.sh deleted file mode 100644 index 50069ff04..000000000 --- a/tfjs-master/e2e/scripts/build-deps-ci.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env bash -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================== - -set -e - -yarn build-link-package -yarn build-union-ci -yarn build-node-ci - -if [[ "$NIGHTLY" = true || "$RELEASE" = true ]]; then - # Build the wasm backend - yarn build-backend-wasm-ci -fi diff --git a/tfjs-master/e2e/scripts/build-graph-model-golden-data.ts b/tfjs-master/e2e/scripts/build-graph-model-golden-data.ts deleted file mode 100644 index b100e47db..000000000 --- a/tfjs-master/e2e/scripts/build-graph-model-golden-data.ts +++ /dev/null @@ -1,135 +0,0 @@ -/** - * @license - * Copyright 2023 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import * as tf from '@tensorflow/tfjs'; -import * as fs from 'fs'; -import * as path from 'path'; - -import {GraphModeGoldenData, TensorDetail} from '../integration_tests/types'; - -const GRAPH_MODEL_GOLDEN_DATA_DIR = - './integration_tests/graph_model_golden_data/'; - -// Defines models to be used in the golden tests here. -// TODO: Support async models (models with control flow ops). -const MODEL_CONFIGS: GraphModelConfig[] = [ - { - name: 'MobileNetV3_small_075', - url: - 'https://tfhub.dev/google/tfjs-model/imagenet/mobilenet_v3_small_075_224/classification/5/default/1', - fromTFHub: true, - inputs: tf.randomNormal([1, 224, 224, 3]), - }, -]; - -type GraphModelInputs = tf.Tensor|tf.Tensor[]|tf.NamedTensorMap; - -interface GraphModelConfig { - readonly name: string; - readonly url: string; - readonly fromTFHub?: boolean; - readonly inputs: GraphModelInputs; -} - -async function getTensorDetail(tensor: tf.Tensor): Promise { - const data = await tensor.data(); - return { - data: Array.from(data), - shape: tensor.shape, - dtype: tensor.dtype, - }; -} - -async function getTensorDetails(tensors: tf.Tensor|tf.Tensor[]| - tf.NamedTensorMap) { - if (tensors instanceof tf.Tensor) { - return await getTensorDetail(tensors); - } - - if (Array.isArray(tensors)) { - return await Promise.all(tensors.map(getTensorDetail)); - } - - const details: Record = {}; - for (const [name, tensor] of Object.entries(tensors)) { - details[name] = await getTensorDetail(tensor); - } - return details; -} - -function getGraphModelGoldenDataFilename(modelName: string) { - return `${modelName}.golden.json`; -} - -function writeGraphModelGoldenData(data: GraphModeGoldenData) { - if (!fs.existsSync(GRAPH_MODEL_GOLDEN_DATA_DIR)) { - fs.mkdirSync(GRAPH_MODEL_GOLDEN_DATA_DIR, {recursive: true}); - } - fs.writeFileSync( - path.join( - GRAPH_MODEL_GOLDEN_DATA_DIR, - getGraphModelGoldenDataFilename(data.name)), - JSON.stringify(data)); -} - -(async function main() { - if (MODEL_CONFIGS.length === 0) { - return; - } - - const models = await Promise.all(MODEL_CONFIGS.map( - ({url, fromTFHub}) => tf.loadGraphModel(url, {fromTFHub}))); - - tf.env().set('KEEP_INTERMEDIATE_TENSORS', true); - for (let i = 0; i < MODEL_CONFIGS.length; ++i) { - const model = models[i]; - const {inputs} = MODEL_CONFIGS[i]; - - const outputTensors = model.predict(inputs); - const outputDetails = await getTensorDetails(outputTensors); - - const intermediateTensors = model.getIntermediateTensors(); - const intermediateDetails: Record = {}; - - for (const [name, tensors] of Object.entries(intermediateTensors)) { - const details = await Promise.all(tensors.map(getTensorDetail)); - intermediateDetails[name] = details[0]; - } - - writeGraphModelGoldenData({ - ...MODEL_CONFIGS[i], - inputs: await getTensorDetails(inputs), - outputDetails, - intermediateDetails, - }); - - // Dispose tensors - if (outputTensors instanceof tf.Tensor) { - outputTensors.dispose(); - } else if (Array.isArray(outputTensors)) { - for (const tensor of outputTensors) tensor.dispose(); - } else { - for (const tensor of Object.values(outputTensors)) tensor.dispose(); - } - model.disposeIntermediateTensors(); - } - - // Write all golden filenames to GRAPH_MODEL_GOLDEN_DATA_DIR/filenames.json. - fs.writeFileSync( - path.join(GRAPH_MODEL_GOLDEN_DATA_DIR, 'filenames.json'), - JSON.stringify(MODEL_CONFIGS.map( - ({name}) => getGraphModelGoldenDataFilename(name)))); -}()); diff --git a/tfjs-master/e2e/scripts/cleanup-py-env.sh b/tfjs-master/e2e/scripts/cleanup-py-env.sh deleted file mode 100644 index fbb5829d3..000000000 --- a/tfjs-master/e2e/scripts/cleanup-py-env.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env bash - -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================== - -# Clean up virtualenv directory. -rm -rf "${VENV_DIR}" diff --git a/tfjs-master/e2e/scripts/create-python-models.sh b/tfjs-master/e2e/scripts/create-python-models.sh deleted file mode 100644 index 80170bfa4..000000000 --- a/tfjs-master/e2e/scripts/create-python-models.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env bash -# Copyright 2023 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================== - -set -e - -# Generate canonical layers models and inputs. -./scripts/create_save_predict.sh - -cd integration_tests - -source ../scripts/setup-py-env.sh --dev - -parallel ::: 'echo "Load equivalent keras models and generate outputs." && python create_save_predict.py' \ - 'echo "Create saved models and convert." && python convert_predict.py' \ - 'echo "Convert model with user defined metadata." && python metadata.py' - -# Cleanup python env. -source ../scripts/cleanup-py-env.sh - -cd .. diff --git a/tfjs-master/e2e/scripts/create_save_predict.sh b/tfjs-master/e2e/scripts/create_save_predict.sh deleted file mode 100644 index f4910f965..000000000 --- a/tfjs-master/e2e/scripts/create_save_predict.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/env bash - -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================== - -set -e - -TEST_DATA="integration_tests/create_save_predict_data/" - -rm -rf "$TEST_DATA" -mkdir "$TEST_DATA" - -node integration_tests/create_save_predict.js "$TEST_DATA" diff --git a/tfjs-master/e2e/scripts/deploy-benchmarks.sh b/tfjs-master/e2e/scripts/deploy-benchmarks.sh deleted file mode 100644 index 1a2a8b03c..000000000 --- a/tfjs-master/e2e/scripts/deploy-benchmarks.sh +++ /dev/null @@ -1,46 +0,0 @@ -#!/usr/bin/env bash -# Copyright 2021 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================== - -# Deploy content in e2e/benchmarks to firebase hosting. - -# Halt if a single command errors -set -e - -PROJECT="jstensorflow" - -if [[ "$1" == "--dev" ]]; then - # Deploy to the preview channel. - # - # Use the second command line parameter as the feature name which will be - # part of the preview URL. Use the current date+time as fallback. - feature_name="${2:-$(date '+%Y%m%d-%H%M%S')}" - firebase hosting:channel:deploy \ - "${feature_name}" \ - --config benchmarks/firebase.json \ - --only tfjs-benchmarks \ - --project ${PROJECT} \ - --expires 14d -elif [[ "$1" == "--staging" ]]; then - firebase deploy \ - --config benchmarks/firebase_staging.json \ - --only hosting:tfjs-benchmarks-staging \ - --project ${PROJECT} -else - firebase deploy \ - --config benchmarks/firebase.json \ - --only hosting:tfjs-benchmarks \ - --project ${PROJECT} -fi diff --git a/tfjs-master/e2e/scripts/fetch-graph-model-golden-data-ci.sh b/tfjs-master/e2e/scripts/fetch-graph-model-golden-data-ci.sh deleted file mode 100644 index 1af969e26..000000000 --- a/tfjs-master/e2e/scripts/fetch-graph-model-golden-data-ci.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env bash -# Copyright 2023 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================== - -STORAGE_URL="https://storage.googleapis.com/tfjs-e2e-graph-model-golden-data" - -cd ./integration_tests/graph_model_golden_data - -golden_files=$(python -c "import json; print('\n'.join(json.load(open('./filenames.json'))))") - -while read golden_file; do - url="$STORAGE_URL/$golden_file" - echo "Downloading $url" - curl -O "$url" -done <<<"$(echo "$golden_files")" diff --git a/tfjs-master/e2e/scripts/local-registry.sh b/tfjs-master/e2e/scripts/local-registry.sh deleted file mode 100644 index 67b6161dd..000000000 --- a/tfjs-master/e2e/scripts/local-registry.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/usr/bin/env bash -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================== - -custom_registry_url=http://127.0.0.1:4873 -original_npm_registry_url=`npm get registry` -original_yarn_registry_url=`yarn config get registry` -default_verdaccio_package=verdaccio@5.9.0 - -function startLocalRegistry { - # Start local registry - tmp_registry_log=`mktemp` - echo "Registry output file: $tmp_registry_log" - (cd && nohup npx ${VERDACCIO_PACKAGE:-$default_verdaccio_package} -c $1 &>$tmp_registry_log &) - # Wait for Verdaccio to boot - grep -q 'http address' <(tail -f $tmp_registry_log) - - # Login so we can publish packages - npx npm-cli-login -u user -p password -e user@example.com -r $custom_registry_url - - # Set registry to local registry - npm set registry "$custom_registry_url" - yarn config set registry "$custom_registry_url" -} - -function stopLocalRegistry { - # Restore the original NPM and Yarn registry URLs and stop Verdaccio - npm set registry "$original_npm_registry_url" - yarn config set registry "$original_yarn_registry_url" -} diff --git a/tfjs-master/e2e/scripts/release-e2e.sh b/tfjs-master/e2e/scripts/release-e2e.sh deleted file mode 100644 index b87ac814b..000000000 --- a/tfjs-master/e2e/scripts/release-e2e.sh +++ /dev/null @@ -1,89 +0,0 @@ -#!/usr/bin/env bash -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================== - -# This script is used for starting Verdaccio, a private npm registry. - -# Start in scripts/ even if run from root directory -cd "$(dirname "$0")" - -function cleanup { - echo 'Cleaning up.' - # Restore the original NPM and Yarn registry URLs and stop Verdaccio - stopLocalRegistry -} - -# Error messages are redirected to stderr -function handle_error { - echo "$(basename $0): ERROR! An error was encountered executing line $1." 1>&2; - cleanup - echo 'Exiting with error.' 1>&2; - exit 1 -} - -function handle_exit { - cleanup - echo 'Exiting without error.' 1>&2; - exit -} - -# Exit the script with a helpful error message when any error is encountered -trap 'set +x; handle_error $LINENO $BASH_COMMAND' ERR - -# Cleanup before exit on any termination signal -trap 'set +x; handle_exit' SIGQUIT SIGTERM SIGINT SIGKILL SIGHUP - -# Echo every command being executed -set -x - -# Go to e2e root -cd .. -e2e_root_path=$PWD - -# **************************************************************************** -# First, publish the monorepo. -# **************************************************************************** -# Load functions for working with local NPM registry (Verdaccio) -source "$e2e_root_path"/scripts/local-registry.sh - -# Publish the monorepo to the local NPM registry. Note this publish script will -# automatically start and stop the registry while it publishes. -cd "$e2e_root_path"/../ -yarn publish-npm --release-this-branch --dry --ci 'tfjs-core' \ - 'tfjs-backend-cpu' 'tfjs-backend-webgl' 'tfjs-backend-webgpu' \ - 'tfjs-backend-wasm' 'tfjs-layers' 'tfjs-converter' 'tfjs-data' 'tfjs' \ - 'tfjs-node' 'tfjs-node-gpu' -cd "$e2e_root_path" - -# **************************************************************************** -# Second, install the packages from local registry and fetch golden data for testing. -# **************************************************************************** -# Start the local NPM registry -startLocalRegistry "$e2e_root_path"/scripts/verdaccio.yaml -# First make sure npm install succeeds. -npm install -rm -rf node_modules -# Then install dependencies via yarn. -yarn -# Fetch golden data for testing -yarn fetch-graph-model-golden-data-ci - -# **************************************************************************** -# Third, run integration tests against locally published version. -# **************************************************************************** -yarn test-ci - -# Cleanup -cleanup diff --git a/tfjs-master/e2e/scripts/run-browserstack-tests.sh b/tfjs-master/e2e/scripts/run-browserstack-tests.sh deleted file mode 100644 index 8822421b5..000000000 --- a/tfjs-master/e2e/scripts/run-browserstack-tests.sh +++ /dev/null @@ -1,53 +0,0 @@ -#!/usr/bin/env bash -# Copyright 2023 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================== - -# This script runs browserstack tests on all configured browsers. It requires -# the TAGS variable to be set in the environment. - -set -e - -# Smoke and regression tests run in PR and nightly builds. -TAGS="#SMOKE,#REGRESSION" -TAGS_WITH_GOLDEN="$TAGS,#GOLDEN" - -# Test macOS with smoke/regression tests. -# Skip golden tests because they time out on browserstack (they work locally). -# TODO(mattSoulanille): Make golden tests work on BrowserStack Mac. -COMMANDS+=("yarn run-browserstack --browsers=bs_chrome_mac --tags '$TAGS'") - -# Test windows 10 with smoke/regression/golden tests. -COMMANDS+=("yarn run-browserstack --browsers=win_10_chrome --tags '$TAGS_WITH_GOLDEN'") - -# Test script tag bundles -COMMANDS+=("karma start ./script_tag_tests/tfjs/karma.conf.js --browserstack --browsers=bs_chrome_mac --testBundle tf.min.js") - -# Additional tests to run in nightly only. -if [[ "$NIGHTLY" = true || "$RELEASE" = true ]]; then - COMMANDS+=( - "yarn run-browserstack --browsers=bs_ios_12 --tags '$TAGS' --testEnv webgl --flags '{\"\\"\"WEBGL_VERSION\"\\"\": 1, \"\\"\"WEBGL_CPU_FORWARD\"\\"\": false, \"\\"\"WEBGL_SIZE_UPLOAD_UNIFORM\"\\"\": 0}'" - "yarn run-browserstack --browsers=bs_safari_mac --tags '$TAGS' --testEnv webgl --flags '{\"\\"\"WEBGL_VERSION\"\\"\": 1, \"\\"\"WEBGL_CPU_FORWARD\"\\"\": false, \"\\"\"WEBGL_SIZE_UPLOAD_UNIFORM\"\\"\": 0}'" - "yarn run-browserstack --browsers=bs_firefox_mac --tags '$TAGS'" - "yarn run-browserstack --browsers=bs_android_10 --tags '$TAGS'" - # Test script tag bundles - "karma start ./script_tag_tests/tfjs-core-cpu/karma.conf.js --browserstack --browsers=bs_chrome_mac" - ) -fi - -for command in "${COMMANDS[@]}"; do - TO_RUN+=("node ../scripts/run_flaky.js \"$command\"") -done - -parallel ::: "${TO_RUN[@]}" diff --git a/tfjs-master/e2e/scripts/run-custom-builds.sh b/tfjs-master/e2e/scripts/run-custom-builds.sh deleted file mode 100644 index 033340dec..000000000 --- a/tfjs-master/e2e/scripts/run-custom-builds.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env bash - -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================== - -# Start in scripts/ even if run from root directory -cd "$(dirname "$0")" - -# Go to e2e root -cd .. - -parallel ::: 'cd custom_module/blazeface && ./build.sh' \ - 'cd custom_module/dense_model && ./build.sh' \ - 'cd custom_module/universal_sentence_encoder && ./build.sh' diff --git a/tfjs-master/e2e/scripts/setup-py-env.sh b/tfjs-master/e2e/scripts/setup-py-env.sh deleted file mode 100644 index 1897f678b..000000000 --- a/tfjs-master/e2e/scripts/setup-py-env.sh +++ /dev/null @@ -1,59 +0,0 @@ -#!/usr/bin/env bash - -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================== - -# Decide which environment to use. -DEV_VERSION="" -while [[ ! -z "$1" ]]; do - if [[ "$1" == "--stable" ]]; then - DEV_VERSION="stable" - elif [[ "$1" == "--dev" ]]; then - DEV_VERSION="dev" - else - echo "ERROR: Unrecognized command-line flag $1" - exit 1 - fi - shift -done - -echo "DEV_VERSION: ${DEV_VERSION}" - -if [[ -z "${DEV_VERSION}" ]]; then - echo "Must specify one of --stable and --dev." - exit 1 -fi - -VENV_DIR="$(mktemp -d)_venv" -echo "Creating virtualenv at ${VENV_DIR} ..." -PLATFORM="$(python -m platform)" -if [[ $PLATFORM =~ "Windows" ]] -then - python -m virtualenv -p python3 "${VENV_DIR}" - source "${VENV_DIR}/Scripts/activate" -else - virtualenv -p python3 "${VENV_DIR}" - source "${VENV_DIR}/bin/activate" -fi - -# Install python packages. -if [[ "${DEV_VERSION}" == "stable" ]]; then - pip3 install -r requirements-stable.txt -else - pip3 install -r requirements-dev.txt -fi - -echo "Loading tensorflowjs pip from source ...." -pip3 install -e ../../tfjs-converter/python diff --git a/tfjs-master/e2e/scripts/test-ci.sh b/tfjs-master/e2e/scripts/test-ci.sh deleted file mode 100644 index f622ef357..000000000 --- a/tfjs-master/e2e/scripts/test-ci.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/env bash -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================== - -set -e - -# Generate custom bundle files and model files for tests -parallel ::: ./scripts/run-custom-builds.sh \ - ./scripts/create-python-models.sh - -# Run browserstack tests (and webpack test) -parallel ::: ./scripts/run-browserstack-tests.sh \ - "cd webpack_test && yarn --mutex network && yarn build" diff --git a/tfjs-master/e2e/scripts/test.sh b/tfjs-master/e2e/scripts/test.sh deleted file mode 100644 index fa2b561db..000000000 --- a/tfjs-master/e2e/scripts/test.sh +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/env bash -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================== - -# This script is used for local testing. Set environment variable TAGS to -# filter tests. If no TAGS is specified, the script will the TAGS to #SMOKE. -# Multiple tags are allowed, separate by comma. - -set -e - -if [[ -z "$TAGS" ]]; then - echo "Env variable TAGS is not found, set TAGS='#SMOKE'" - TAGS="#SMOKE" -fi - -if [[ "$NIGHTLY" = true ]]; then - TAGS="${TAGS},#GOLDEN,#REGRESSION" -fi - -# Additional setup for regression tests. -if [[ "$TAGS" == *"#REGRESSION"* ]]; then - # Generate canonical layers models and inputs. - ./scripts/create-python-models.sh - - # Test webpack - cd webpack_test - yarn - yarn build - cd .. - - # Generate custom bundle files for tests - ./scripts/run-custom-builds.sh -fi - -echo "Karma tests." -yarn karma start --tags $TAGS diff --git a/tfjs-master/e2e/scripts/verdaccio.yaml b/tfjs-master/e2e/scripts/verdaccio.yaml deleted file mode 100644 index ff7ed6064..000000000 --- a/tfjs-master/e2e/scripts/verdaccio.yaml +++ /dev/null @@ -1,42 +0,0 @@ -# Path to a directory with all packages. -storage: ./storage - -# Maximum body size for a JSON document. -max_body_size: 1000mb - -auth: - htpasswd: - file: ./htpasswd - -# a list of other known repositories we can talk to -uplinks: - npmjs: - url: https://registry.npmjs.org/ - -# Enable messaging so node can tell when verdaccio starts. -# https://verdaccio.org/docs/verdaccio-programmatically/#using-fork-from-child_process-module -_debug: true - -# Fine-grained control of package access, we set it -# to allow all users to read and publish all packages. -packages: - '@tensorflow/**': - access: $all - publish: $all - proxy: npmjs - '@*/*': - access: $all - publish: $all - proxy: npmjs - '**': - access: $all - publish: $all - # If package is not available locally, proxy requests to 'npmjs' registry - proxy: npmjs - -# Log settings. -logs: - - {type: stdout, format: pretty, level: http} - -listen: - - 127.0.0.1:4873 diff --git a/tfjs-master/e2e/tsconfig.json b/tfjs-master/e2e/tsconfig.json deleted file mode 100644 index fa5643201..000000000 --- a/tfjs-master/e2e/tsconfig.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "moduleResolution": "node", - "allowJs": true, - "noImplicitAny": true, - "sourceMap": true, - "removeComments": true, - "preserveConstEnums": true, - "declaration": false, - "target": "es5", - "lib": ["es2017", "dom"], - "outDir": "./dist", - "noUnusedLocals": true, - "noImplicitReturns": true, - "noImplicitThis": true, - "alwaysStrict": true, - "noUnusedParameters": false, - "pretty": true, - "noFallthroughCasesInSwitch": true, - "allowUnreachableCode": false, - "resolveJsonModule":true - }, - "include": [ - "*.ts", - "integration_tests/**/*.ts" - ], - "exclude": [ - "node_modules/" - ] -} diff --git a/tfjs-master/e2e/tslint.json b/tfjs-master/e2e/tslint.json deleted file mode 100644 index ec365f164..000000000 --- a/tfjs-master/e2e/tslint.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "../tslint.json" -} diff --git a/tfjs-master/e2e/webpack_test/app.js b/tfjs-master/e2e/webpack_test/app.js deleted file mode 100644 index 2d2a962f7..000000000 --- a/tfjs-master/e2e/webpack_test/app.js +++ /dev/null @@ -1,22 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '@tensorflow/tfjs-core'; -import '@tensorflow/tfjs-backend-cpu'; - -const t = tf.tensor1d([1,2,3,4,5]); -t.print(); diff --git a/tfjs-master/e2e/webpack_test/package.json b/tfjs-master/e2e/webpack_test/package.json deleted file mode 100644 index f2e4895e5..000000000 --- a/tfjs-master/e2e/webpack_test/package.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name": "webpack_test", - "version": "1.0.0", - "main": "index.js", - "license": "Apache-2.0", - "scripts": { - "build-deps": "cd ../../link-package && yarn build", - "build": "webpack" - }, - "devDependencies": { - "@tensorflow/tfjs-core": "link:../../link-package/node_modules/@tensorflow/tfjs-core", - "@tensorflow/tfjs-backend-cpu": "link:../../link-package/node_modules/@tensorflow/tfjs-backend-cpu", - "webpack": "^5.76.0", - "webpack-cli": "^4.7.2" - } -} diff --git a/tfjs-master/e2e/webpack_test/webpack.config.js b/tfjs-master/e2e/webpack_test/webpack.config.js deleted file mode 100644 index f1a9ed8ba..000000000 --- a/tfjs-master/e2e/webpack_test/webpack.config.js +++ /dev/null @@ -1,28 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -const path = require('path'); - -module.exports = { - mode: 'production', - entry: './app.js', - target: 'web', - output: { - path: path.resolve(__dirname, 'dist'), - filename: 'app_webpack.js', - }, -}; diff --git a/tfjs-master/e2e/webpack_test/yarn.lock b/tfjs-master/e2e/webpack_test/yarn.lock deleted file mode 100644 index b3b39b2d9..000000000 --- a/tfjs-master/e2e/webpack_test/yarn.lock +++ /dev/null @@ -1,914 +0,0 @@ -# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. -# yarn lockfile v1 - - -"@discoveryjs/json-ext@^0.5.0": - version "0.5.3" - resolved "https://registry.yarnpkg.com/@discoveryjs/json-ext/-/json-ext-0.5.3.tgz#90420f9f9c6d3987f176a19a7d8e764271a2f55d" - integrity sha512-Fxt+AfXgjMoin2maPIYzFZnQjAXjAL0PHscM5pRTtatFqB+vZxAM9tLp2Optnuw3QOQC40jTNeGYFOMvyf7v9g== - -"@jridgewell/gen-mapping@^0.3.0": - version "0.3.2" - resolved "https://registry.yarnpkg.com/@jridgewell/gen-mapping/-/gen-mapping-0.3.2.tgz#c1aedc61e853f2bb9f5dfe6d4442d3b565b253b9" - integrity sha512-mh65xKQAzI6iBcFzwv28KVWSmCkdRBWoOh+bYQGW3+6OZvbbN3TqMGo5hqYxQniRcH9F2VZIoJCm4pa3BPDK/A== - dependencies: - "@jridgewell/set-array" "^1.0.1" - "@jridgewell/sourcemap-codec" "^1.4.10" - "@jridgewell/trace-mapping" "^0.3.9" - -"@jridgewell/resolve-uri@^3.0.3": - version "3.1.0" - resolved "https://registry.yarnpkg.com/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz#2203b118c157721addfe69d47b70465463066d78" - integrity sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w== - -"@jridgewell/set-array@^1.0.1": - version "1.1.2" - resolved "https://registry.yarnpkg.com/@jridgewell/set-array/-/set-array-1.1.2.tgz#7c6cf998d6d20b914c0a55a91ae928ff25965e72" - integrity sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw== - -"@jridgewell/source-map@^0.3.2": - version "0.3.2" - resolved "https://registry.yarnpkg.com/@jridgewell/source-map/-/source-map-0.3.2.tgz#f45351aaed4527a298512ec72f81040c998580fb" - integrity sha512-m7O9o2uR8k2ObDysZYzdfhb08VuEml5oWGiosa1VdaPZ/A6QyPkAJuwN0Q1lhULOf6B7MtQmHENS743hWtCrgw== - dependencies: - "@jridgewell/gen-mapping" "^0.3.0" - "@jridgewell/trace-mapping" "^0.3.9" - -"@jridgewell/sourcemap-codec@^1.4.10": - version "1.4.14" - resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz#add4c98d341472a289190b424efbdb096991bb24" - integrity sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw== - -"@jridgewell/trace-mapping@^0.3.9": - version "0.3.14" - resolved "https://registry.yarnpkg.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.14.tgz#b231a081d8f66796e475ad588a1ef473112701ed" - integrity sha512-bJWEfQ9lPTvm3SneWwRFVLzrh6nhjwqw7TUFFBEMzwvg7t7PCDenf2lDwqo4NQXzdpgBXyFgDWnQA+2vkruksQ== - dependencies: - "@jridgewell/resolve-uri" "^3.0.3" - "@jridgewell/sourcemap-codec" "^1.4.10" - -"@tensorflow/tfjs-backend-cpu@link:../../link-package/node_modules/@tensorflow/tfjs-backend-cpu": - version "0.0.0" - uid "" - -"@tensorflow/tfjs-core@link:../../link-package/node_modules/@tensorflow/tfjs-core": - version "0.0.0" - uid "" - -"@types/eslint-scope@^3.7.3": - version "3.7.4" - resolved "https://registry.yarnpkg.com/@types/eslint-scope/-/eslint-scope-3.7.4.tgz#37fc1223f0786c39627068a12e94d6e6fc61de16" - integrity sha512-9K4zoImiZc3HlIp6AVUDE4CWYx22a+lhSZMYNpbjW04+YF0KWj4pJXnEMjdnFTiQibFFmElcsasJXDbdI/EPhA== - dependencies: - "@types/eslint" "*" - "@types/estree" "*" - -"@types/eslint@*": - version "7.28.0" - resolved "https://registry.yarnpkg.com/@types/eslint/-/eslint-7.28.0.tgz#7e41f2481d301c68e14f483fe10b017753ce8d5a" - integrity sha512-07XlgzX0YJUn4iG1ocY4IX9DzKSmMGUs6ESKlxWhZRaa0fatIWaHWUVapcuGa8r5HFnTqzj+4OCjd5f7EZ/i/A== - dependencies: - "@types/estree" "*" - "@types/json-schema" "*" - -"@types/estree@*", "@types/estree@^0.0.51": - version "0.0.51" - resolved "https://registry.yarnpkg.com/@types/estree/-/estree-0.0.51.tgz#cfd70924a25a3fd32b218e5e420e6897e1ac4f40" - integrity sha512-CuPgU6f3eT/XgKKPqKd/gLZV1Xmvf1a2R5POBOGQa6uv82xpls89HU5zKeVoyR8XzHd1RGNOlQlvUe3CFkjWNQ== - -"@types/json-schema@*", "@types/json-schema@^7.0.8": - version "7.0.8" - resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.8.tgz#edf1bf1dbf4e04413ca8e5b17b3b7d7d54b59818" - integrity sha512-YSBPTLTVm2e2OoQIDYx8HaeWJ5tTToLH67kXR7zYNGupXMEHa2++G8k+DczX2cFVgalypqtyZIcU19AFcmOpmg== - -"@types/long@^4.0.1": - version "4.0.2" - resolved "https://registry.yarnpkg.com/@types/long/-/long-4.0.2.tgz#b74129719fc8d11c01868010082d483b7545591a" - integrity sha512-MqTGEo5bj5t157U6fA/BiDynNkn0YknVdh48CMPkTSpFTVmvao5UQmm7uEF6xBEo7qIMAlY/JSleYaE6VOdpaA== - -"@types/node@*": - version "16.4.3" - resolved "https://registry.yarnpkg.com/@types/node/-/node-16.4.3.tgz#c01c1a215721f6dec71b47d88b4687463601ba48" - integrity sha512-GKM4FLMkWDc0sfx7tXqPWkM6NBow1kge0fgQh0bOnlqo4iT1kvTvMEKE0c1RtUGnbLlGRXiAA8SumE//90uKAg== - -"@types/offscreencanvas@~2019.7.0": - version "2019.7.0" - resolved "https://registry.yarnpkg.com/@types/offscreencanvas/-/offscreencanvas-2019.7.0.tgz#e4a932069db47bb3eabeb0b305502d01586fa90d" - integrity sha512-PGcyveRIpL1XIqK8eBsmRBt76eFgtzuPiSTyKHZxnGemp2yzGzWpjYKAfK3wIMiU7eH+851yEpiuP8JZerTmWg== - -"@types/seedrandom@^2.4.28": - version "2.4.30" - resolved "https://registry.yarnpkg.com/@types/seedrandom/-/seedrandom-2.4.30.tgz#d2efe425869b84163c2d56e779dddadb9372cbfa" - integrity sha512-AnxLHewubLVzoF/A4qdxBGHCKifw8cY32iro3DQX9TPcetE95zBeVt3jnsvtvAUf1vwzMfwzp4t/L2yqPlnjkQ== - -"@webassemblyjs/ast@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.11.1.tgz#2bfd767eae1a6996f432ff7e8d7fc75679c0b6a7" - integrity sha512-ukBh14qFLjxTQNTXocdyksN5QdM28S1CxHt2rdskFyL+xFV7VremuBLVbmCePj+URalXBENx/9Lm7lnhihtCSw== - dependencies: - "@webassemblyjs/helper-numbers" "1.11.1" - "@webassemblyjs/helper-wasm-bytecode" "1.11.1" - -"@webassemblyjs/floating-point-hex-parser@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/floating-point-hex-parser/-/floating-point-hex-parser-1.11.1.tgz#f6c61a705f0fd7a6aecaa4e8198f23d9dc179e4f" - integrity sha512-iGRfyc5Bq+NnNuX8b5hwBrRjzf0ocrJPI6GWFodBFzmFnyvrQ83SHKhmilCU/8Jv67i4GJZBMhEzltxzcNagtQ== - -"@webassemblyjs/helper-api-error@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-api-error/-/helper-api-error-1.11.1.tgz#1a63192d8788e5c012800ba6a7a46c705288fd16" - integrity sha512-RlhS8CBCXfRUR/cwo2ho9bkheSXG0+NwooXcc3PAILALf2QLdFyj7KGsKRbVc95hZnhnERon4kW/D3SZpp6Tcg== - -"@webassemblyjs/helper-buffer@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-buffer/-/helper-buffer-1.11.1.tgz#832a900eb444884cde9a7cad467f81500f5e5ab5" - integrity sha512-gwikF65aDNeeXa8JxXa2BAk+REjSyhrNC9ZwdT0f8jc4dQQeDQ7G4m0f2QCLPJiMTTO6wfDmRmj/pW0PsUvIcA== - -"@webassemblyjs/helper-numbers@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-numbers/-/helper-numbers-1.11.1.tgz#64d81da219fbbba1e3bd1bfc74f6e8c4e10a62ae" - integrity sha512-vDkbxiB8zfnPdNK9Rajcey5C0w+QJugEglN0of+kmO8l7lDb77AnlKYQF7aarZuCrv+l0UvqL+68gSDr3k9LPQ== - dependencies: - "@webassemblyjs/floating-point-hex-parser" "1.11.1" - "@webassemblyjs/helper-api-error" "1.11.1" - "@xtuc/long" "4.2.2" - -"@webassemblyjs/helper-wasm-bytecode@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-wasm-bytecode/-/helper-wasm-bytecode-1.11.1.tgz#f328241e41e7b199d0b20c18e88429c4433295e1" - integrity sha512-PvpoOGiJwXeTrSf/qfudJhwlvDQxFgelbMqtq52WWiXC6Xgg1IREdngmPN3bs4RoO83PnL/nFrxucXj1+BX62Q== - -"@webassemblyjs/helper-wasm-section@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-wasm-section/-/helper-wasm-section-1.11.1.tgz#21ee065a7b635f319e738f0dd73bfbda281c097a" - integrity sha512-10P9No29rYX1j7F3EVPX3JvGPQPae+AomuSTPiF9eBQeChHI6iqjMIwR9JmOJXwpnn/oVGDk7I5IlskuMwU/pg== - dependencies: - "@webassemblyjs/ast" "1.11.1" - "@webassemblyjs/helper-buffer" "1.11.1" - "@webassemblyjs/helper-wasm-bytecode" "1.11.1" - "@webassemblyjs/wasm-gen" "1.11.1" - -"@webassemblyjs/ieee754@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/ieee754/-/ieee754-1.11.1.tgz#963929e9bbd05709e7e12243a099180812992614" - integrity sha512-hJ87QIPtAMKbFq6CGTkZYJivEwZDbQUgYd3qKSadTNOhVY7p+gfP6Sr0lLRVTaG1JjFj+r3YchoqRYxNH3M0GQ== - dependencies: - "@xtuc/ieee754" "^1.2.0" - -"@webassemblyjs/leb128@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/leb128/-/leb128-1.11.1.tgz#ce814b45574e93d76bae1fb2644ab9cdd9527aa5" - integrity sha512-BJ2P0hNZ0u+Th1YZXJpzW6miwqQUGcIHT1G/sf72gLVD9DZ5AdYTqPNbHZh6K1M5VmKvFXwGSWZADz+qBWxeRw== - dependencies: - "@xtuc/long" "4.2.2" - -"@webassemblyjs/utf8@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/utf8/-/utf8-1.11.1.tgz#d1f8b764369e7c6e6bae350e854dec9a59f0a3ff" - integrity sha512-9kqcxAEdMhiwQkHpkNiorZzqpGrodQQ2IGrHHxCy+Ozng0ofyMA0lTqiLkVs1uzTRejX+/O0EOT7KxqVPuXosQ== - -"@webassemblyjs/wasm-edit@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-edit/-/wasm-edit-1.11.1.tgz#ad206ebf4bf95a058ce9880a8c092c5dec8193d6" - integrity sha512-g+RsupUC1aTHfR8CDgnsVRVZFJqdkFHpsHMfJuWQzWU3tvnLC07UqHICfP+4XyL2tnr1amvl1Sdp06TnYCmVkA== - dependencies: - "@webassemblyjs/ast" "1.11.1" - "@webassemblyjs/helper-buffer" "1.11.1" - "@webassemblyjs/helper-wasm-bytecode" "1.11.1" - "@webassemblyjs/helper-wasm-section" "1.11.1" - "@webassemblyjs/wasm-gen" "1.11.1" - "@webassemblyjs/wasm-opt" "1.11.1" - "@webassemblyjs/wasm-parser" "1.11.1" - "@webassemblyjs/wast-printer" "1.11.1" - -"@webassemblyjs/wasm-gen@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-gen/-/wasm-gen-1.11.1.tgz#86c5ea304849759b7d88c47a32f4f039ae3c8f76" - integrity sha512-F7QqKXwwNlMmsulj6+O7r4mmtAlCWfO/0HdgOxSklZfQcDu0TpLiD1mRt/zF25Bk59FIjEuGAIyn5ei4yMfLhA== - dependencies: - "@webassemblyjs/ast" "1.11.1" - "@webassemblyjs/helper-wasm-bytecode" "1.11.1" - "@webassemblyjs/ieee754" "1.11.1" - "@webassemblyjs/leb128" "1.11.1" - "@webassemblyjs/utf8" "1.11.1" - -"@webassemblyjs/wasm-opt@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-opt/-/wasm-opt-1.11.1.tgz#657b4c2202f4cf3b345f8a4c6461c8c2418985f2" - integrity sha512-VqnkNqnZlU5EB64pp1l7hdm3hmQw7Vgqa0KF/KCNO9sIpI6Fk6brDEiX+iCOYrvMuBWDws0NkTOxYEb85XQHHw== - dependencies: - "@webassemblyjs/ast" "1.11.1" - "@webassemblyjs/helper-buffer" "1.11.1" - "@webassemblyjs/wasm-gen" "1.11.1" - "@webassemblyjs/wasm-parser" "1.11.1" - -"@webassemblyjs/wasm-parser@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-parser/-/wasm-parser-1.11.1.tgz#86ca734534f417e9bd3c67c7a1c75d8be41fb199" - integrity sha512-rrBujw+dJu32gYB7/Lup6UhdkPx9S9SnobZzRVL7VcBH9Bt9bCBLEuX/YXOOtBsOZ4NQrRykKhffRWHvigQvOA== - dependencies: - "@webassemblyjs/ast" "1.11.1" - "@webassemblyjs/helper-api-error" "1.11.1" - "@webassemblyjs/helper-wasm-bytecode" "1.11.1" - "@webassemblyjs/ieee754" "1.11.1" - "@webassemblyjs/leb128" "1.11.1" - "@webassemblyjs/utf8" "1.11.1" - -"@webassemblyjs/wast-printer@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/wast-printer/-/wast-printer-1.11.1.tgz#d0c73beda8eec5426f10ae8ef55cee5e7084c2f0" - integrity sha512-IQboUWM4eKzWW+N/jij2sRatKMh99QEelo3Eb2q0qXkvPRISAj8Qxtmw5itwqK+TTkBuUIE45AxYPToqPtL5gg== - dependencies: - "@webassemblyjs/ast" "1.11.1" - "@xtuc/long" "4.2.2" - -"@webgpu/types@0.1.30": - version "0.1.30" - resolved "https://registry.yarnpkg.com/@webgpu/types/-/types-0.1.30.tgz#b6406dc4a1c1e0d469028ceb30ddffbbd2fa706c" - integrity sha512-9AXJSmL3MzY8ZL//JjudA//q+2kBRGhLBFpkdGksWIuxrMy81nFrCzj2Am+mbh8WoU6rXmv7cY5E3rdlyru2Qg== - -"@webpack-cli/configtest@^1.0.4": - version "1.0.4" - resolved "https://registry.yarnpkg.com/@webpack-cli/configtest/-/configtest-1.0.4.tgz#f03ce6311c0883a83d04569e2c03c6238316d2aa" - integrity sha512-cs3XLy+UcxiP6bj0A6u7MLLuwdXJ1c3Dtc0RkKg+wiI1g/Ti1om8+/2hc2A2B60NbBNAbMgyBMHvyymWm/j4wQ== - -"@webpack-cli/info@^1.3.0": - version "1.3.0" - resolved "https://registry.yarnpkg.com/@webpack-cli/info/-/info-1.3.0.tgz#9d78a31101a960997a4acd41ffd9b9300627fe2b" - integrity sha512-ASiVB3t9LOKHs5DyVUcxpraBXDOKubYu/ihHhU+t1UPpxsivg6Od2E2qU4gJCekfEddzRBzHhzA/Acyw/mlK/w== - dependencies: - envinfo "^7.7.3" - -"@webpack-cli/serve@^1.5.1": - version "1.5.1" - resolved "https://registry.yarnpkg.com/@webpack-cli/serve/-/serve-1.5.1.tgz#b5fde2f0f79c1e120307c415a4c1d5eb15a6f278" - integrity sha512-4vSVUiOPJLmr45S8rMGy7WDvpWxfFxfP/Qx/cxZFCfvoypTYpPPL1X8VIZMe0WTA+Jr7blUxwUSEZNkjoMTgSw== - -"@xtuc/ieee754@^1.2.0": - version "1.2.0" - resolved "https://registry.yarnpkg.com/@xtuc/ieee754/-/ieee754-1.2.0.tgz#eef014a3145ae477a1cbc00cd1e552336dceb790" - integrity sha512-DX8nKgqcGwsc0eJSqYt5lwP4DH5FlHnmuWWBRy7X0NcaGR0ZtuyeESgMwTYVEtxmsNGY+qit4QYT/MIYTOTPeA== - -"@xtuc/long@4.2.2": - version "4.2.2" - resolved "https://registry.yarnpkg.com/@xtuc/long/-/long-4.2.2.tgz#d291c6a4e97989b5c61d9acf396ae4fe133a718d" - integrity sha512-NuHqBY1PB/D8xU6s/thBgOAiAP7HOYDQ32+BFZILJ8ivkUkAHQnWfn6WhL79Owj1qmUnoN/YPhktdIoucipkAQ== - -acorn-import-assertions@^1.7.6: - version "1.8.0" - resolved "https://registry.yarnpkg.com/acorn-import-assertions/-/acorn-import-assertions-1.8.0.tgz#ba2b5939ce62c238db6d93d81c9b111b29b855e9" - integrity sha512-m7VZ3jwz4eK6A4Vtt8Ew1/mNbP24u0FhdyfA7fSvnJR6LMdfOYnmuIrrJAgrYfYJ10F/otaHTtrtrtmHdMNzEw== - -acorn@^8.5.0, acorn@^8.7.1: - version "8.8.2" - resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.8.2.tgz#1b2f25db02af965399b9776b0c2c391276d37c4a" - integrity sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw== - -ajv-keywords@^3.5.2: - version "3.5.2" - resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-3.5.2.tgz#31f29da5ab6e00d1c2d329acf7b5929614d5014d" - integrity sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ== - -ajv@^6.12.5: - version "6.12.6" - resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.6.tgz#baf5a62e802b07d977034586f8c3baf5adf26df4" - integrity sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g== - dependencies: - fast-deep-equal "^3.1.1" - fast-json-stable-stringify "^2.0.0" - json-schema-traverse "^0.4.1" - uri-js "^4.2.2" - -browserslist@^4.14.5: - version "4.16.6" - resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.16.6.tgz#d7901277a5a88e554ed305b183ec9b0c08f66fa2" - integrity sha512-Wspk/PqO+4W9qp5iUTJsa1B/QrYn1keNCcEP5OvP7WBwT4KaDly0uONYmC6Xa3Z5IqnUgS0KcgLYu1l74x0ZXQ== - dependencies: - caniuse-lite "^1.0.30001219" - colorette "^1.2.2" - electron-to-chromium "^1.3.723" - escalade "^3.1.1" - node-releases "^1.1.71" - -buffer-from@^1.0.0: - version "1.1.2" - resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.2.tgz#2b146a6fd72e80b4f55d255f35ed59a3a9a41bd5" - integrity sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ== - -caniuse-lite@^1.0.30001219: - version "1.0.30001247" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001247.tgz#105be7a8fb30cdd303275e769a9dfb87d4b3577a" - integrity sha512-4rS7co+7+AoOSPRPOPUt5/GdaqZc0EsUpWk66ofE3HJTAajUK2Ss2VwoNzVN69ghg8lYYlh0an0Iy4LIHHo9UQ== - -chrome-trace-event@^1.0.2: - version "1.0.3" - resolved "https://registry.yarnpkg.com/chrome-trace-event/-/chrome-trace-event-1.0.3.tgz#1015eced4741e15d06664a957dbbf50d041e26ac" - integrity sha512-p3KULyQg4S7NIHixdwbGX+nFHkoBiA4YQmyWtjb8XngSKV124nJmRysgAeujbUVb15vh+RvFUfCPqU7rXk+hZg== - -clone-deep@^4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/clone-deep/-/clone-deep-4.0.1.tgz#c19fd9bdbbf85942b4fd979c84dcf7d5f07c2387" - integrity sha512-neHB9xuzh/wk0dIHweyAXv2aPGZIVk3pLMe+/RNzINf17fe0OG96QroktYAUm7SM1PBnzTabaLboqqxDyMU+SQ== - dependencies: - is-plain-object "^2.0.4" - kind-of "^6.0.2" - shallow-clone "^3.0.0" - -colorette@^1.2.1, colorette@^1.2.2: - version "1.2.2" - resolved "https://registry.yarnpkg.com/colorette/-/colorette-1.2.2.tgz#cbcc79d5e99caea2dbf10eb3a26fd8b3e6acfa94" - integrity sha512-MKGMzyfeuutC/ZJ1cba9NqcNpfeqMUcYmyF1ZFY6/Cn7CNSAKx6a+s48sqLqyAiZuaP2TcqMhoo+dlwFnVxT9w== - -commander@^2.20.0: - version "2.20.3" - resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33" - integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ== - -commander@^7.0.0: - version "7.2.0" - resolved "https://registry.yarnpkg.com/commander/-/commander-7.2.0.tgz#a36cb57d0b501ce108e4d20559a150a391d97ab7" - integrity sha512-QrWXB+ZQSVPmIWIhtEO9H+gwHaMGYiF5ChvoJ+K9ZGHG/sVsa6yiesAD1GC/x46sET00Xlwo1u49RVVVzvcSkw== - -cross-spawn@^7.0.3: - version "7.0.3" - resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6" - integrity sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w== - dependencies: - path-key "^3.1.0" - shebang-command "^2.0.0" - which "^2.0.1" - -electron-to-chromium@^1.3.723: - version "1.3.786" - resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.786.tgz#1fc572abc77e2f474725f8a61acf7e25ced9fbe2" - integrity sha512-AmvbLBj3hepRk8v/DHrFF8gINxOFfDbrn6Ts3PcK46/FBdQb5OMmpamSpZQXSkfi77FfBzYtQtAk+00LCLYMVw== - -enhanced-resolve@^5.10.0: - version "5.12.0" - resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-5.12.0.tgz#300e1c90228f5b570c4d35babf263f6da7155634" - integrity sha512-QHTXI/sZQmko1cbDoNAa3mJ5qhWUUNAq3vR0/YiD379fWQrcfuoX1+HW2S0MTt7XmoPLapdaDKUtelUSPic7hQ== - dependencies: - graceful-fs "^4.2.4" - tapable "^2.2.0" - -envinfo@^7.7.3: - version "7.8.1" - resolved "https://registry.yarnpkg.com/envinfo/-/envinfo-7.8.1.tgz#06377e3e5f4d379fea7ac592d5ad8927e0c4d475" - integrity sha512-/o+BXHmB7ocbHEAs6F2EnG0ogybVVUdkRunTT2glZU9XAaGmhqskrvKwqXuDfNjEO0LZKWdejEEpnq8aM0tOaw== - -es-module-lexer@^0.9.0: - version "0.9.3" - resolved "https://registry.yarnpkg.com/es-module-lexer/-/es-module-lexer-0.9.3.tgz#6f13db00cc38417137daf74366f535c8eb438f19" - integrity sha512-1HQ2M2sPtxwnvOvT1ZClHyQDiggdNjURWpY2we6aMKCQiUVxTmVs2UYPLIrD84sS+kMdUwfBSylbJPwNnBrnHQ== - -escalade@^3.1.1: - version "3.1.1" - resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.1.1.tgz#d8cfdc7000965c5a0174b4a82eaa5c0552742e40" - integrity sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw== - -eslint-scope@5.1.1: - version "5.1.1" - resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-5.1.1.tgz#e786e59a66cb92b3f6c1fb0d508aab174848f48c" - integrity sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw== - dependencies: - esrecurse "^4.3.0" - estraverse "^4.1.1" - -esrecurse@^4.3.0: - version "4.3.0" - resolved "https://registry.yarnpkg.com/esrecurse/-/esrecurse-4.3.0.tgz#7ad7964d679abb28bee72cec63758b1c5d2c9921" - integrity sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag== - dependencies: - estraverse "^5.2.0" - -estraverse@^4.1.1: - version "4.3.0" - resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-4.3.0.tgz#398ad3f3c5a24948be7725e83d11a7de28cdbd1d" - integrity sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw== - -estraverse@^5.2.0: - version "5.2.0" - resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-5.2.0.tgz#307df42547e6cc7324d3cf03c155d5cdb8c53880" - integrity sha512-BxbNGGNm0RyRYvUdHpIwv9IWzeM9XClbOxwoATuFdOE7ZE6wHL+HQ5T8hoPM+zHvmKzzsEqhgy0GrQ5X13afiQ== - -events@^3.2.0: - version "3.3.0" - resolved "https://registry.yarnpkg.com/events/-/events-3.3.0.tgz#31a95ad0a924e2d2c419a813aeb2c4e878ea7400" - integrity sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q== - -execa@^5.0.0: - version "5.1.1" - resolved "https://registry.yarnpkg.com/execa/-/execa-5.1.1.tgz#f80ad9cbf4298f7bd1d4c9555c21e93741c411dd" - integrity sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg== - dependencies: - cross-spawn "^7.0.3" - get-stream "^6.0.0" - human-signals "^2.1.0" - is-stream "^2.0.0" - merge-stream "^2.0.0" - npm-run-path "^4.0.1" - onetime "^5.1.2" - signal-exit "^3.0.3" - strip-final-newline "^2.0.0" - -fast-deep-equal@^3.1.1: - version "3.1.3" - resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525" - integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q== - -fast-json-stable-stringify@^2.0.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz#874bf69c6f404c2b5d99c481341399fd55892633" - integrity sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw== - -fastest-levenshtein@^1.0.12: - version "1.0.12" - resolved "https://registry.yarnpkg.com/fastest-levenshtein/-/fastest-levenshtein-1.0.12.tgz#9990f7d3a88cc5a9ffd1f1745745251700d497e2" - integrity sha512-On2N+BpYJ15xIC974QNVuYGMOlEVt4s0EOI3wwMqOmK1fdDY+FN/zltPV8vosq4ad4c/gJ1KHScUn/6AWIgiow== - -find-up@^4.0.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/find-up/-/find-up-4.1.0.tgz#97afe7d6cdc0bc5928584b7c8d7b16e8a9aa5d19" - integrity sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw== - dependencies: - locate-path "^5.0.0" - path-exists "^4.0.0" - -function-bind@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d" - integrity sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A== - -get-stream@^6.0.0: - version "6.0.1" - resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-6.0.1.tgz#a262d8eef67aced57c2852ad6167526a43cbf7b7" - integrity sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg== - -glob-to-regexp@^0.4.1: - version "0.4.1" - resolved "https://registry.yarnpkg.com/glob-to-regexp/-/glob-to-regexp-0.4.1.tgz#c75297087c851b9a578bd217dd59a92f59fe546e" - integrity sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw== - -graceful-fs@^4.1.2, graceful-fs@^4.2.4, graceful-fs@^4.2.9: - version "4.2.10" - resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.10.tgz#147d3a006da4ca3ce14728c7aefc287c367d7a6c" - integrity sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA== - -has-flag@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b" - integrity sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ== - -has@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/has/-/has-1.0.3.tgz#722d7cbfc1f6aa8241f16dd814e011e1f41e8796" - integrity sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw== - dependencies: - function-bind "^1.1.1" - -human-signals@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-2.1.0.tgz#dc91fcba42e4d06e4abaed33b3e7a3c02f514ea0" - integrity sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw== - -import-local@^3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/import-local/-/import-local-3.0.2.tgz#a8cfd0431d1de4a2199703d003e3e62364fa6db6" - integrity sha512-vjL3+w0oulAVZ0hBHnxa/Nm5TAurf9YLQJDhqRZyqb+VKGOB6LU8t9H1Nr5CIo16vh9XfJTOoHwU0B71S557gA== - dependencies: - pkg-dir "^4.2.0" - resolve-cwd "^3.0.0" - -interpret@^2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/interpret/-/interpret-2.2.0.tgz#1a78a0b5965c40a5416d007ad6f50ad27c417df9" - integrity sha512-Ju0Bz/cEia55xDwUWEa8+olFpCiQoypjnQySseKtmjNrnps3P+xfpUmGr90T7yjlVJmOtybRvPXhKMbHr+fWnw== - -is-core-module@^2.2.0: - version "2.5.0" - resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.5.0.tgz#f754843617c70bfd29b7bd87327400cda5c18491" - integrity sha512-TXCMSDsEHMEEZ6eCA8rwRDbLu55MRGmrctljsBX/2v1d9/GzqHOxW5c5oPSgrUt2vBFXebu9rGqckXGPWOlYpg== - dependencies: - has "^1.0.3" - -is-plain-object@^2.0.4: - version "2.0.4" - resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-2.0.4.tgz#2c163b3fafb1b606d9d17928f05c2a1c38e07677" - integrity sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og== - dependencies: - isobject "^3.0.1" - -is-stream@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-2.0.1.tgz#fac1e3d53b97ad5a9d0ae9cef2389f5810a5c077" - integrity sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg== - -isexe@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" - integrity sha1-6PvzdNxVb/iUehDcsFctYz8s+hA= - -isobject@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/isobject/-/isobject-3.0.1.tgz#4e431e92b11a9731636aa1f9c8d1ccbcfdab78df" - integrity sha1-TkMekrEalzFjaqH5yNHMvP2reN8= - -jest-worker@^27.0.2: - version "27.0.6" - resolved "https://registry.yarnpkg.com/jest-worker/-/jest-worker-27.0.6.tgz#a5fdb1e14ad34eb228cfe162d9f729cdbfa28aed" - integrity sha512-qupxcj/dRuA3xHPMUd40gr2EaAurFbkwzOh7wfPaeE9id7hyjURRQoqNfHifHK3XjJU6YJJUQKILGUnwGPEOCA== - dependencies: - "@types/node" "*" - merge-stream "^2.0.0" - supports-color "^8.0.0" - -json-parse-even-better-errors@^2.3.1: - version "2.3.1" - resolved "https://registry.yarnpkg.com/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz#7c47805a94319928e05777405dc12e1f7a4ee02d" - integrity sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w== - -json-schema-traverse@^0.4.1: - version "0.4.1" - resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz#69f6a87d9513ab8bb8fe63bdb0979c448e684660" - integrity sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg== - -kind-of@^6.0.2: - version "6.0.3" - resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.3.tgz#07c05034a6c349fa06e24fa35aa76db4580ce4dd" - integrity sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw== - -loader-runner@^4.2.0: - version "4.2.0" - resolved "https://registry.yarnpkg.com/loader-runner/-/loader-runner-4.2.0.tgz#d7022380d66d14c5fb1d496b89864ebcfd478384" - integrity sha512-92+huvxMvYlMzMt0iIOukcwYBFpkYJdpl2xsZ7LrlayO7E8SOv+JJUEK17B/dJIHAOLMfh2dZZ/Y18WgmGtYNw== - -locate-path@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-5.0.0.tgz#1afba396afd676a6d42504d0a67a3a7eb9f62aa0" - integrity sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g== - dependencies: - p-locate "^4.1.0" - -long@4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/long/-/long-4.0.0.tgz#9a7b71cfb7d361a194ea555241c92f7468d5bf28" - integrity sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA== - -merge-stream@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/merge-stream/-/merge-stream-2.0.0.tgz#52823629a14dd00c9770fb6ad47dc6310f2c1f60" - integrity sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w== - -mime-db@1.48.0: - version "1.48.0" - resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.48.0.tgz#e35b31045dd7eada3aaad537ed88a33afbef2d1d" - integrity sha512-FM3QwxV+TnZYQ2aRqhlKBMHxk10lTbMt3bBkMAp54ddrNeVSfcQYOOKuGuy3Ddrm38I04If834fOUSq1yzslJQ== - -mime-types@^2.1.27: - version "2.1.31" - resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.31.tgz#a00d76b74317c61f9c2db2218b8e9f8e9c5c9e6b" - integrity sha512-XGZnNzm3QvgKxa8dpzyhFTHmpP3l5YNusmne07VUOXxou9CqUqYa/HBy124RqtVh/O2pECas/MOcsDgpilPOPg== - dependencies: - mime-db "1.48.0" - -mimic-fn@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-2.1.0.tgz#7ed2c2ccccaf84d3ffcb7a69b57711fc2083401b" - integrity sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg== - -neo-async@^2.6.2: - version "2.6.2" - resolved "https://registry.yarnpkg.com/neo-async/-/neo-async-2.6.2.tgz#b4aafb93e3aeb2d8174ca53cf163ab7d7308305f" - integrity sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw== - -node-fetch@~2.6.1: - version "2.6.12" - resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.12.tgz#02eb8e22074018e3d5a83016649d04df0e348fba" - integrity sha512-C/fGU2E8ToujUivIO0H+tpQ6HWo4eEmchoPIoXtxCrVghxdKq+QOHqEZW7tuP3KlV3bC8FRMO5nMCC7Zm1VP6g== - dependencies: - whatwg-url "^5.0.0" - -node-releases@^1.1.71: - version "1.1.73" - resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-1.1.73.tgz#dd4e81ddd5277ff846b80b52bb40c49edf7a7b20" - integrity sha512-uW7fodD6pyW2FZNZnp/Z3hvWKeEW1Y8R1+1CnErE8cXFXzl5blBOoVB41CvMer6P6Q0S5FXDwcHgFd1Wj0U9zg== - -npm-run-path@^4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/npm-run-path/-/npm-run-path-4.0.1.tgz#b7ecd1e5ed53da8e37a55e1c2269e0b97ed748ea" - integrity sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw== - dependencies: - path-key "^3.0.0" - -onetime@^5.1.2: - version "5.1.2" - resolved "https://registry.yarnpkg.com/onetime/-/onetime-5.1.2.tgz#d0e96ebb56b07476df1dd9c4806e5237985ca45e" - integrity sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg== - dependencies: - mimic-fn "^2.1.0" - -p-limit@^2.2.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-2.3.0.tgz#3dd33c647a214fdfffd835933eb086da0dc21db1" - integrity sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w== - dependencies: - p-try "^2.0.0" - -p-limit@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-3.1.0.tgz#e1daccbe78d0d1388ca18c64fea38e3e57e3706b" - integrity sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ== - dependencies: - yocto-queue "^0.1.0" - -p-locate@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-4.1.0.tgz#a3428bb7088b3a60292f66919278b7c297ad4f07" - integrity sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A== - dependencies: - p-limit "^2.2.0" - -p-try@^2.0.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/p-try/-/p-try-2.2.0.tgz#cb2868540e313d61de58fafbe35ce9004d5540e6" - integrity sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ== - -path-exists@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-4.0.0.tgz#513bdbe2d3b95d7762e8c1137efa195c6c61b5b3" - integrity sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w== - -path-key@^3.0.0, path-key@^3.1.0: - version "3.1.1" - resolved "https://registry.yarnpkg.com/path-key/-/path-key-3.1.1.tgz#581f6ade658cbba65a0d3380de7753295054f375" - integrity sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q== - -path-parse@^1.0.6: - version "1.0.7" - resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.7.tgz#fbc114b60ca42b30d9daf5858e4bd68bbedb6735" - integrity sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw== - -pkg-dir@^4.2.0: - version "4.2.0" - resolved "https://registry.yarnpkg.com/pkg-dir/-/pkg-dir-4.2.0.tgz#f099133df7ede422e81d1d8448270eeb3e4261f3" - integrity sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ== - dependencies: - find-up "^4.0.0" - -punycode@^2.1.0: - version "2.1.1" - resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec" - integrity sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A== - -randombytes@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/randombytes/-/randombytes-2.1.0.tgz#df6f84372f0270dc65cdf6291349ab7a473d4f2a" - integrity sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ== - dependencies: - safe-buffer "^5.1.0" - -rechoir@^0.7.0: - version "0.7.1" - resolved "https://registry.yarnpkg.com/rechoir/-/rechoir-0.7.1.tgz#9478a96a1ca135b5e88fc027f03ee92d6c645686" - integrity sha512-/njmZ8s1wVeR6pjTZ+0nCnv8SpZNRMT2D1RLOJQESlYFDBvwpTA4KWJpZ+sBJ4+vhjILRcK7JIFdGCdxEAAitg== - dependencies: - resolve "^1.9.0" - -resolve-cwd@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/resolve-cwd/-/resolve-cwd-3.0.0.tgz#0f0075f1bb2544766cf73ba6a6e2adfebcb13f2d" - integrity sha512-OrZaX2Mb+rJCpH/6CpSqt9xFVpN++x01XnN2ie9g6P5/3xelLAkXWVADpdz1IHD/KFfEXyE6V0U01OQ3UO2rEg== - dependencies: - resolve-from "^5.0.0" - -resolve-from@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-5.0.0.tgz#c35225843df8f776df21c57557bc087e9dfdfc69" - integrity sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw== - -resolve@^1.9.0: - version "1.20.0" - resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.20.0.tgz#629a013fb3f70755d6f0b7935cc1c2c5378b1975" - integrity sha512-wENBPt4ySzg4ybFQW2TT1zMQucPK95HSh/nq2CFTZVOGut2+pQvSsgtda4d26YrYcr067wjbmzOG8byDPBX63A== - dependencies: - is-core-module "^2.2.0" - path-parse "^1.0.6" - -safe-buffer@^5.1.0: - version "5.2.1" - resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" - integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== - -schema-utils@^3.0.0, schema-utils@^3.1.0: - version "3.1.1" - resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-3.1.1.tgz#bc74c4b6b6995c1d88f76a8b77bea7219e0c8281" - integrity sha512-Y5PQxS4ITlC+EahLuXaY86TXfR7Dc5lw294alXOq86JAHCihAIZfqv8nNCWvaEJvaC51uN9hbLGeV0cFBdH+Fw== - dependencies: - "@types/json-schema" "^7.0.8" - ajv "^6.12.5" - ajv-keywords "^3.5.2" - -seedrandom@^3.0.5: - version "3.0.5" - resolved "https://registry.yarnpkg.com/seedrandom/-/seedrandom-3.0.5.tgz#54edc85c95222525b0c7a6f6b3543d8e0b3aa0a7" - integrity sha512-8OwmbklUNzwezjGInmZ+2clQmExQPvomqjL7LFqOYqtmuxRgQYqOD3mHaU+MvZn5FLUeVxVfQjwLZW/n/JFuqg== - -serialize-javascript@^6.0.0: - version "6.0.0" - resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-6.0.0.tgz#efae5d88f45d7924141da8b5c3a7a7e663fefeb8" - integrity sha512-Qr3TosvguFt8ePWqsvRfrKyQXIiW+nGbYpy8XK24NQHE83caxWt+mIymTT19DGFbNWNLfEwsrkSmN64lVWB9ag== - dependencies: - randombytes "^2.1.0" - -shallow-clone@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/shallow-clone/-/shallow-clone-3.0.1.tgz#8f2981ad92531f55035b01fb230769a40e02efa3" - integrity sha512-/6KqX+GVUdqPuPPd2LxDDxzX6CAbjJehAAOKlNpqqUpAqPM6HeL8f+o3a+JsyGjn2lv0WY8UsTgUJjU9Ok55NA== - dependencies: - kind-of "^6.0.2" - -shebang-command@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-2.0.0.tgz#ccd0af4f8835fbdc265b82461aaf0c36663f34ea" - integrity sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA== - dependencies: - shebang-regex "^3.0.0" - -shebang-regex@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-3.0.0.tgz#ae16f1644d873ecad843b0307b143362d4c42172" - integrity sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A== - -signal-exit@^3.0.3: - version "3.0.3" - resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.3.tgz#a1410c2edd8f077b08b4e253c8eacfcaf057461c" - integrity sha512-VUJ49FC8U1OxwZLxIbTTrDvLnf/6TDgxZcK8wxR8zs13xpx7xbG60ndBlhNrFi2EMuFRoeDoJO7wthSLq42EjA== - -source-map-support@~0.5.20: - version "0.5.21" - resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.21.tgz#04fe7c7f9e1ed2d662233c28cb2b35b9f63f6e4f" - integrity sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w== - dependencies: - buffer-from "^1.0.0" - source-map "^0.6.0" - -source-map@^0.6.0, source-map@^0.6.1: - version "0.6.1" - resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" - integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== - -strip-final-newline@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/strip-final-newline/-/strip-final-newline-2.0.0.tgz#89b852fb2fcbe936f6f4b3187afb0a12c1ab58ad" - integrity sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA== - -supports-color@^8.0.0: - version "8.1.1" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-8.1.1.tgz#cd6fc17e28500cff56c1b86c0a7fd4a54a73005c" - integrity sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q== - dependencies: - has-flag "^4.0.0" - -tapable@^2.1.1, tapable@^2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/tapable/-/tapable-2.2.0.tgz#5c373d281d9c672848213d0e037d1c4165ab426b" - integrity sha512-FBk4IesMV1rBxX2tfiK8RAmogtWn53puLOQlvO8XuwlgxcYbP4mVPS9Ph4aeamSyyVjOl24aYWAuc8U5kCVwMw== - -terser-webpack-plugin@^5.1.3: - version "5.1.4" - resolved "https://registry.yarnpkg.com/terser-webpack-plugin/-/terser-webpack-plugin-5.1.4.tgz#c369cf8a47aa9922bd0d8a94fe3d3da11a7678a1" - integrity sha512-C2WkFwstHDhVEmsmlCxrXUtVklS+Ir1A7twrYzrDrQQOIMOaVAYykaoo/Aq1K0QRkMoY2hhvDQY1cm4jnIMFwA== - dependencies: - jest-worker "^27.0.2" - p-limit "^3.1.0" - schema-utils "^3.0.0" - serialize-javascript "^6.0.0" - source-map "^0.6.1" - terser "^5.7.0" - -terser@^5.7.0: - version "5.14.2" - resolved "https://registry.yarnpkg.com/terser/-/terser-5.14.2.tgz#9ac9f22b06994d736174f4091aa368db896f1c10" - integrity sha512-oL0rGeM/WFQCUd0y2QrWxYnq7tfSuKBiqTjRPWrRgB46WD/kiwHwF8T23z78H6Q6kGCuuHcPB+KULHRdxvVGQA== - dependencies: - "@jridgewell/source-map" "^0.3.2" - acorn "^8.5.0" - commander "^2.20.0" - source-map-support "~0.5.20" - -tr46@~0.0.3: - version "0.0.3" - resolved "https://registry.yarnpkg.com/tr46/-/tr46-0.0.3.tgz#8184fd347dac9cdc185992f3a6622e14b9d9ab6a" - integrity sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw== - -uri-js@^4.2.2: - version "4.4.1" - resolved "https://registry.yarnpkg.com/uri-js/-/uri-js-4.4.1.tgz#9b1a52595225859e55f669d928f88c6c57f2a77e" - integrity sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg== - dependencies: - punycode "^2.1.0" - -v8-compile-cache@^2.2.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz#2de19618c66dc247dcfb6f99338035d8245a2cee" - integrity sha512-l8lCEmLcLYZh4nbunNZvQCJc5pv7+RCwa8q/LdUx8u7lsWvPDKmpodJAJNwkAhJC//dFY48KuIEmjtd4RViDrA== - -watchpack@^2.4.0: - version "2.4.0" - resolved "https://registry.yarnpkg.com/watchpack/-/watchpack-2.4.0.tgz#fa33032374962c78113f93c7f2fb4c54c9862a5d" - integrity sha512-Lcvm7MGST/4fup+ifyKi2hjyIAwcdI4HRgtvTpIUxBRhB+RFtUh8XtDOxUfctVCnhVi+QQj49i91OyvzkJl6cg== - dependencies: - glob-to-regexp "^0.4.1" - graceful-fs "^4.1.2" - -webidl-conversions@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871" - integrity sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ== - -webpack-cli@^4.7.2: - version "4.7.2" - resolved "https://registry.yarnpkg.com/webpack-cli/-/webpack-cli-4.7.2.tgz#a718db600de6d3906a4357e059ae584a89f4c1a5" - integrity sha512-mEoLmnmOIZQNiRl0ebnjzQ74Hk0iKS5SiEEnpq3dRezoyR3yPaeQZCMCe+db4524pj1Pd5ghZXjT41KLzIhSLw== - dependencies: - "@discoveryjs/json-ext" "^0.5.0" - "@webpack-cli/configtest" "^1.0.4" - "@webpack-cli/info" "^1.3.0" - "@webpack-cli/serve" "^1.5.1" - colorette "^1.2.1" - commander "^7.0.0" - execa "^5.0.0" - fastest-levenshtein "^1.0.12" - import-local "^3.0.2" - interpret "^2.2.0" - rechoir "^0.7.0" - v8-compile-cache "^2.2.0" - webpack-merge "^5.7.3" - -webpack-merge@^5.7.3: - version "5.8.0" - resolved "https://registry.yarnpkg.com/webpack-merge/-/webpack-merge-5.8.0.tgz#2b39dbf22af87776ad744c390223731d30a68f61" - integrity sha512-/SaI7xY0831XwP6kzuwhKWVKDP9t1QY1h65lAFLbZqMPIuYcD9QAW4u9STIbU9kaJbPBB/geU/gLr1wDjOhQ+Q== - dependencies: - clone-deep "^4.0.1" - wildcard "^2.0.0" - -webpack-sources@^3.2.3: - version "3.2.3" - resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-3.2.3.tgz#2d4daab8451fd4b240cc27055ff6a0c2ccea0cde" - integrity sha512-/DyMEOrDgLKKIG0fmvtz+4dUX/3Ghozwgm6iPp8KRhvn+eQf9+Q7GWxVNMk3+uCPWfdXYC4ExGBckIXdFEfH1w== - -webpack@^5.76.0: - version "5.76.0" - resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.76.0.tgz#f9fb9fb8c4a7dbdcd0d56a98e56b8a942ee2692c" - integrity sha512-l5sOdYBDunyf72HW8dF23rFtWq/7Zgvt/9ftMof71E/yUb1YLOBmTgA2K4vQthB3kotMrSj609txVE0dnr2fjA== - dependencies: - "@types/eslint-scope" "^3.7.3" - "@types/estree" "^0.0.51" - "@webassemblyjs/ast" "1.11.1" - "@webassemblyjs/wasm-edit" "1.11.1" - "@webassemblyjs/wasm-parser" "1.11.1" - acorn "^8.7.1" - acorn-import-assertions "^1.7.6" - browserslist "^4.14.5" - chrome-trace-event "^1.0.2" - enhanced-resolve "^5.10.0" - es-module-lexer "^0.9.0" - eslint-scope "5.1.1" - events "^3.2.0" - glob-to-regexp "^0.4.1" - graceful-fs "^4.2.9" - json-parse-even-better-errors "^2.3.1" - loader-runner "^4.2.0" - mime-types "^2.1.27" - neo-async "^2.6.2" - schema-utils "^3.1.0" - tapable "^2.1.1" - terser-webpack-plugin "^5.1.3" - watchpack "^2.4.0" - webpack-sources "^3.2.3" - -whatwg-url@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-5.0.0.tgz#966454e8765462e37644d3626f6742ce8b70965d" - integrity sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw== - dependencies: - tr46 "~0.0.3" - webidl-conversions "^3.0.0" - -which@^2.0.1: - version "2.0.2" - resolved "https://registry.yarnpkg.com/which/-/which-2.0.2.tgz#7c6a8dd0a636a0327e10b59c9286eee93f3f51b1" - integrity sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA== - dependencies: - isexe "^2.0.0" - -wildcard@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/wildcard/-/wildcard-2.0.0.tgz#a77d20e5200c6faaac979e4b3aadc7b3dd7f8fec" - integrity sha512-JcKqAHLPxcdb9KM49dufGXn2x3ssnfjbcaQdLlfZsL9rH9wgDQjUtDxbo8NE0F6SFvydeu1VhZe7hZuHsB2/pw== - -yocto-queue@^0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b" - integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q== diff --git a/tfjs-master/e2e/yarn.lock b/tfjs-master/e2e/yarn.lock deleted file mode 100644 index d7f3dd60e..000000000 --- a/tfjs-master/e2e/yarn.lock +++ /dev/null @@ -1,4326 +0,0 @@ -# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. -# yarn lockfile v1 - - -"@ampproject/remapping@^2.1.0": - version "2.1.2" - resolved "https://registry.yarnpkg.com/@ampproject/remapping/-/remapping-2.1.2.tgz#4edca94973ded9630d20101cd8559cedb8d8bd34" - integrity sha512-hoyByceqwKirw7w3Z7gnIIZC3Wx3J484Y3L/cMpXFbr7d9ZQj2mODrirNzcJa+SM3UlpWXYvKV4RlRpFXlWgXg== - dependencies: - "@jridgewell/trace-mapping" "^0.3.0" - -"@babel/code-frame@^7.0.0", "@babel/code-frame@^7.16.7": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.16.7.tgz#44416b6bd7624b998f5b1af5d470856c40138789" - integrity sha512-iAXqUn8IIeBTNd72xsFlgaXHkMBMt6y4HJp1tIaK465CWLT/fG1aqB7ykr95gHHmlBdGbFeWWfyB4NJJ0nmeIg== - dependencies: - "@babel/highlight" "^7.16.7" - -"@babel/compat-data@^7.13.11", "@babel/compat-data@^7.16.8", "@babel/compat-data@^7.17.0", "@babel/compat-data@^7.17.7": - version "7.17.7" - resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.17.7.tgz#078d8b833fbbcc95286613be8c716cef2b519fa2" - integrity sha512-p8pdE6j0a29TNGebNm7NzYZWB3xVZJBZ7XGs42uAKzQo8VQ3F0By/cQCtUEABwIqw5zo6WA4NbmxsfzADzMKnQ== - -"@babel/core@^7.11.1", "@babel/core@^7.7.5": - version "7.17.8" - resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.17.8.tgz#3dac27c190ebc3a4381110d46c80e77efe172e1a" - integrity sha512-OdQDV/7cRBtJHLSOBqqbYNkOcydOgnX59TZx4puf41fzcVtN3e/4yqY8lMQsK+5X2lJtAdmA+6OHqsj1hBJ4IQ== - dependencies: - "@ampproject/remapping" "^2.1.0" - "@babel/code-frame" "^7.16.7" - "@babel/generator" "^7.17.7" - "@babel/helper-compilation-targets" "^7.17.7" - "@babel/helper-module-transforms" "^7.17.7" - "@babel/helpers" "^7.17.8" - "@babel/parser" "^7.17.8" - "@babel/template" "^7.16.7" - "@babel/traverse" "^7.17.3" - "@babel/types" "^7.17.0" - convert-source-map "^1.7.0" - debug "^4.1.0" - gensync "^1.0.0-beta.2" - json5 "^2.1.2" - semver "^6.3.0" - -"@babel/generator@^7.17.3", "@babel/generator@^7.17.7": - version "7.17.7" - resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.17.7.tgz#8da2599beb4a86194a3b24df6c085931d9ee45ad" - integrity sha512-oLcVCTeIFadUoArDTwpluncplrYBmTCCZZgXCbgNGvOBBiSDDK3eWO4b/+eOTli5tKv1lg+a5/NAXg+nTcei1w== - dependencies: - "@babel/types" "^7.17.0" - jsesc "^2.5.1" - source-map "^0.5.0" - -"@babel/helper-annotate-as-pure@^7.16.7": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.16.7.tgz#bb2339a7534a9c128e3102024c60760a3a7f3862" - integrity sha512-s6t2w/IPQVTAET1HitoowRGXooX8mCgtuP5195wD/QJPV6wYjpujCGF7JuMODVX2ZAJOf1GT6DT9MHEZvLOFSw== - dependencies: - "@babel/types" "^7.16.7" - -"@babel/helper-builder-binary-assignment-operator-visitor@^7.16.7": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/helper-builder-binary-assignment-operator-visitor/-/helper-builder-binary-assignment-operator-visitor-7.16.7.tgz#38d138561ea207f0f69eb1626a418e4f7e6a580b" - integrity sha512-C6FdbRaxYjwVu/geKW4ZeQ0Q31AftgRcdSnZ5/jsH6BzCJbtvXvhpfkbkThYSuutZA7nCXpPR6AD9zd1dprMkA== - dependencies: - "@babel/helper-explode-assignable-expression" "^7.16.7" - "@babel/types" "^7.16.7" - -"@babel/helper-compilation-targets@^7.13.0", "@babel/helper-compilation-targets@^7.16.7", "@babel/helper-compilation-targets@^7.17.7": - version "7.17.7" - resolved "https://registry.yarnpkg.com/@babel/helper-compilation-targets/-/helper-compilation-targets-7.17.7.tgz#a3c2924f5e5f0379b356d4cfb313d1414dc30e46" - integrity sha512-UFzlz2jjd8kroj0hmCFV5zr+tQPi1dpC2cRsDV/3IEW8bJfCPrPpmcSN6ZS8RqIq4LXcmpipCQFPddyFA5Yc7w== - dependencies: - "@babel/compat-data" "^7.17.7" - "@babel/helper-validator-option" "^7.16.7" - browserslist "^4.17.5" - semver "^6.3.0" - -"@babel/helper-create-class-features-plugin@^7.16.10", "@babel/helper-create-class-features-plugin@^7.16.7", "@babel/helper-create-class-features-plugin@^7.17.6": - version "7.17.6" - resolved "https://registry.yarnpkg.com/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.17.6.tgz#3778c1ed09a7f3e65e6d6e0f6fbfcc53809d92c9" - integrity sha512-SogLLSxXm2OkBbSsHZMM4tUi8fUzjs63AT/d0YQIzr6GSd8Hxsbk2KYDX0k0DweAzGMj/YWeiCsorIdtdcW8Eg== - dependencies: - "@babel/helper-annotate-as-pure" "^7.16.7" - "@babel/helper-environment-visitor" "^7.16.7" - "@babel/helper-function-name" "^7.16.7" - "@babel/helper-member-expression-to-functions" "^7.16.7" - "@babel/helper-optimise-call-expression" "^7.16.7" - "@babel/helper-replace-supers" "^7.16.7" - "@babel/helper-split-export-declaration" "^7.16.7" - -"@babel/helper-create-regexp-features-plugin@^7.16.7": - version "7.17.0" - resolved "https://registry.yarnpkg.com/@babel/helper-create-regexp-features-plugin/-/helper-create-regexp-features-plugin-7.17.0.tgz#1dcc7d40ba0c6b6b25618997c5dbfd310f186fe1" - integrity sha512-awO2So99wG6KnlE+TPs6rn83gCz5WlEePJDTnLEqbchMVrBeAujURVphRdigsk094VhvZehFoNOihSlcBjwsXA== - dependencies: - "@babel/helper-annotate-as-pure" "^7.16.7" - regexpu-core "^5.0.1" - -"@babel/helper-define-polyfill-provider@^0.3.1": - version "0.3.1" - resolved "https://registry.yarnpkg.com/@babel/helper-define-polyfill-provider/-/helper-define-polyfill-provider-0.3.1.tgz#52411b445bdb2e676869e5a74960d2d3826d2665" - integrity sha512-J9hGMpJQmtWmj46B3kBHmL38UhJGhYX7eqkcq+2gsstyYt341HmPeWspihX43yVRA0mS+8GGk2Gckc7bY/HCmA== - dependencies: - "@babel/helper-compilation-targets" "^7.13.0" - "@babel/helper-module-imports" "^7.12.13" - "@babel/helper-plugin-utils" "^7.13.0" - "@babel/traverse" "^7.13.0" - debug "^4.1.1" - lodash.debounce "^4.0.8" - resolve "^1.14.2" - semver "^6.1.2" - -"@babel/helper-environment-visitor@^7.16.7": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/helper-environment-visitor/-/helper-environment-visitor-7.16.7.tgz#ff484094a839bde9d89cd63cba017d7aae80ecd7" - integrity sha512-SLLb0AAn6PkUeAfKJCCOl9e1R53pQlGAfc4y4XuMRZfqeMYLE0dM1LMhqbGAlGQY0lfw5/ohoYWAe9V1yibRag== - dependencies: - "@babel/types" "^7.16.7" - -"@babel/helper-explode-assignable-expression@^7.16.7": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/helper-explode-assignable-expression/-/helper-explode-assignable-expression-7.16.7.tgz#12a6d8522fdd834f194e868af6354e8650242b7a" - integrity sha512-KyUenhWMC8VrxzkGP0Jizjo4/Zx+1nNZhgocs+gLzyZyB8SHidhoq9KK/8Ato4anhwsivfkBLftky7gvzbZMtQ== - dependencies: - "@babel/types" "^7.16.7" - -"@babel/helper-function-name@^7.16.7": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/helper-function-name/-/helper-function-name-7.16.7.tgz#f1ec51551fb1c8956bc8dd95f38523b6cf375f8f" - integrity sha512-QfDfEnIUyyBSR3HtrtGECuZ6DAyCkYFp7GHl75vFtTnn6pjKeK0T1DB5lLkFvBea8MdaiUABx3osbgLyInoejA== - dependencies: - "@babel/helper-get-function-arity" "^7.16.7" - "@babel/template" "^7.16.7" - "@babel/types" "^7.16.7" - -"@babel/helper-get-function-arity@^7.16.7": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/helper-get-function-arity/-/helper-get-function-arity-7.16.7.tgz#ea08ac753117a669f1508ba06ebcc49156387419" - integrity sha512-flc+RLSOBXzNzVhcLu6ujeHUrD6tANAOU5ojrRx/as+tbzf8+stUCj7+IfRRoAbEZqj/ahXEMsjhOhgeZsrnTw== - dependencies: - "@babel/types" "^7.16.7" - -"@babel/helper-hoist-variables@^7.16.7": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/helper-hoist-variables/-/helper-hoist-variables-7.16.7.tgz#86bcb19a77a509c7b77d0e22323ef588fa58c246" - integrity sha512-m04d/0Op34H5v7pbZw6pSKP7weA6lsMvfiIAMeIvkY/R4xQtBSMFEigu9QTZ2qB/9l22vsxtM8a+Q8CzD255fg== - dependencies: - "@babel/types" "^7.16.7" - -"@babel/helper-member-expression-to-functions@^7.16.7": - version "7.17.7" - resolved "https://registry.yarnpkg.com/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.17.7.tgz#a34013b57d8542a8c4ff8ba3f747c02452a4d8c4" - integrity sha512-thxXgnQ8qQ11W2wVUObIqDL4p148VMxkt5T/qpN5k2fboRyzFGFmKsTGViquyM5QHKUy48OZoca8kw4ajaDPyw== - dependencies: - "@babel/types" "^7.17.0" - -"@babel/helper-module-imports@^7.12.13", "@babel/helper-module-imports@^7.16.7": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/helper-module-imports/-/helper-module-imports-7.16.7.tgz#25612a8091a999704461c8a222d0efec5d091437" - integrity sha512-LVtS6TqjJHFc+nYeITRo6VLXve70xmq7wPhWTqDJusJEgGmkAACWwMiTNrvfoQo6hEhFwAIixNkvB0jPXDL8Wg== - dependencies: - "@babel/types" "^7.16.7" - -"@babel/helper-module-transforms@^7.16.7", "@babel/helper-module-transforms@^7.17.7": - version "7.17.7" - resolved "https://registry.yarnpkg.com/@babel/helper-module-transforms/-/helper-module-transforms-7.17.7.tgz#3943c7f777139e7954a5355c815263741a9c1cbd" - integrity sha512-VmZD99F3gNTYB7fJRDTi+u6l/zxY0BE6OIxPSU7a50s6ZUQkHwSDmV92FfM+oCG0pZRVojGYhkR8I0OGeCVREw== - dependencies: - "@babel/helper-environment-visitor" "^7.16.7" - "@babel/helper-module-imports" "^7.16.7" - "@babel/helper-simple-access" "^7.17.7" - "@babel/helper-split-export-declaration" "^7.16.7" - "@babel/helper-validator-identifier" "^7.16.7" - "@babel/template" "^7.16.7" - "@babel/traverse" "^7.17.3" - "@babel/types" "^7.17.0" - -"@babel/helper-optimise-call-expression@^7.16.7": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.16.7.tgz#a34e3560605abbd31a18546bd2aad3e6d9a174f2" - integrity sha512-EtgBhg7rd/JcnpZFXpBy0ze1YRfdm7BnBX4uKMBd3ixa3RGAE002JZB66FJyNH7g0F38U05pXmA5P8cBh7z+1w== - dependencies: - "@babel/types" "^7.16.7" - -"@babel/helper-plugin-utils@^7.0.0", "@babel/helper-plugin-utils@^7.10.4", "@babel/helper-plugin-utils@^7.12.13", "@babel/helper-plugin-utils@^7.13.0", "@babel/helper-plugin-utils@^7.14.5", "@babel/helper-plugin-utils@^7.16.7", "@babel/helper-plugin-utils@^7.8.0", "@babel/helper-plugin-utils@^7.8.3": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/helper-plugin-utils/-/helper-plugin-utils-7.16.7.tgz#aa3a8ab4c3cceff8e65eb9e73d87dc4ff320b2f5" - integrity sha512-Qg3Nk7ZxpgMrsox6HreY1ZNKdBq7K72tDSliA6dCl5f007jR4ne8iD5UzuNnCJH2xBf2BEEVGr+/OL6Gdp7RxA== - -"@babel/helper-remap-async-to-generator@^7.16.8": - version "7.16.8" - resolved "https://registry.yarnpkg.com/@babel/helper-remap-async-to-generator/-/helper-remap-async-to-generator-7.16.8.tgz#29ffaade68a367e2ed09c90901986918d25e57e3" - integrity sha512-fm0gH7Flb8H51LqJHy3HJ3wnE1+qtYR2A99K06ahwrawLdOFsCEWjZOrYricXJHoPSudNKxrMBUPEIPxiIIvBw== - dependencies: - "@babel/helper-annotate-as-pure" "^7.16.7" - "@babel/helper-wrap-function" "^7.16.8" - "@babel/types" "^7.16.8" - -"@babel/helper-replace-supers@^7.16.7": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/helper-replace-supers/-/helper-replace-supers-7.16.7.tgz#e9f5f5f32ac90429c1a4bdec0f231ef0c2838ab1" - integrity sha512-y9vsWilTNaVnVh6xiJfABzsNpgDPKev9HnAgz6Gb1p6UUwf9NepdlsV7VXGCftJM+jqD5f7JIEubcpLjZj5dBw== - dependencies: - "@babel/helper-environment-visitor" "^7.16.7" - "@babel/helper-member-expression-to-functions" "^7.16.7" - "@babel/helper-optimise-call-expression" "^7.16.7" - "@babel/traverse" "^7.16.7" - "@babel/types" "^7.16.7" - -"@babel/helper-simple-access@^7.17.7": - version "7.17.7" - resolved "https://registry.yarnpkg.com/@babel/helper-simple-access/-/helper-simple-access-7.17.7.tgz#aaa473de92b7987c6dfa7ce9a7d9674724823367" - integrity sha512-txyMCGroZ96i+Pxr3Je3lzEJjqwaRC9buMUgtomcrLe5Nd0+fk1h0LLA+ixUF5OW7AhHuQ7Es1WcQJZmZsz2XA== - dependencies: - "@babel/types" "^7.17.0" - -"@babel/helper-skip-transparent-expression-wrappers@^7.16.0": - version "7.16.0" - resolved "https://registry.yarnpkg.com/@babel/helper-skip-transparent-expression-wrappers/-/helper-skip-transparent-expression-wrappers-7.16.0.tgz#0ee3388070147c3ae051e487eca3ebb0e2e8bb09" - integrity sha512-+il1gTy0oHwUsBQZyJvukbB4vPMdcYBrFHa0Uc4AizLxbq6BOYC51Rv4tWocX9BLBDLZ4kc6qUFpQ6HRgL+3zw== - dependencies: - "@babel/types" "^7.16.0" - -"@babel/helper-split-export-declaration@^7.16.7": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.16.7.tgz#0b648c0c42da9d3920d85ad585f2778620b8726b" - integrity sha512-xbWoy/PFoxSWazIToT9Sif+jJTlrMcndIsaOKvTA6u7QEo7ilkRZpjew18/W3c7nm8fXdUDXh02VXTbZ0pGDNw== - dependencies: - "@babel/types" "^7.16.7" - -"@babel/helper-validator-identifier@^7.16.7": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz#e8c602438c4a8195751243da9031d1607d247cad" - integrity sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw== - -"@babel/helper-validator-option@^7.16.7": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/helper-validator-option/-/helper-validator-option-7.16.7.tgz#b203ce62ce5fe153899b617c08957de860de4d23" - integrity sha512-TRtenOuRUVo9oIQGPC5G9DgK4743cdxvtOw0weQNpZXaS16SCBi5MNjZF8vba3ETURjZpTbVn7Vvcf2eAwFozQ== - -"@babel/helper-wrap-function@^7.16.8": - version "7.16.8" - resolved "https://registry.yarnpkg.com/@babel/helper-wrap-function/-/helper-wrap-function-7.16.8.tgz#58afda087c4cd235de92f7ceedebca2c41274200" - integrity sha512-8RpyRVIAW1RcDDGTA+GpPAwV22wXCfKOoM9bet6TLkGIFTkRQSkH1nMQ5Yet4MpoXe1ZwHPVtNasc2w0uZMqnw== - dependencies: - "@babel/helper-function-name" "^7.16.7" - "@babel/template" "^7.16.7" - "@babel/traverse" "^7.16.8" - "@babel/types" "^7.16.8" - -"@babel/helpers@^7.17.8": - version "7.17.8" - resolved "https://registry.yarnpkg.com/@babel/helpers/-/helpers-7.17.8.tgz#288450be8c6ac7e4e44df37bcc53d345e07bc106" - integrity sha512-QcL86FGxpfSJwGtAvv4iG93UL6bmqBdmoVY0CMCU2g+oD2ezQse3PT5Pa+jiD6LJndBQi0EDlpzOWNlLuhz5gw== - dependencies: - "@babel/template" "^7.16.7" - "@babel/traverse" "^7.17.3" - "@babel/types" "^7.17.0" - -"@babel/highlight@^7.16.7": - version "7.16.10" - resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.16.10.tgz#744f2eb81579d6eea753c227b0f570ad785aba88" - integrity sha512-5FnTQLSLswEj6IkgVw5KusNUUFY9ZGqe/TRFnP/BKYHYgfh7tc+C7mwiy95/yNP7Dh9x580Vv8r7u7ZfTBFxdw== - dependencies: - "@babel/helper-validator-identifier" "^7.16.7" - chalk "^2.0.0" - js-tokens "^4.0.0" - -"@babel/parser@^7.16.7", "@babel/parser@^7.17.3", "@babel/parser@^7.17.8": - version "7.17.8" - resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.17.8.tgz#2817fb9d885dd8132ea0f8eb615a6388cca1c240" - integrity sha512-BoHhDJrJXqcg+ZL16Xv39H9n+AqJ4pcDrQBGZN+wHxIysrLZ3/ECwCBUch/1zUNhnsXULcONU3Ei5Hmkfk6kiQ== - -"@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression@^7.16.7": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression/-/plugin-bugfix-safari-id-destructuring-collision-in-function-expression-7.16.7.tgz#4eda6d6c2a0aa79c70fa7b6da67763dfe2141050" - integrity sha512-anv/DObl7waiGEnC24O9zqL0pSuI9hljihqiDuFHC8d7/bjr/4RLGPWuc8rYOff/QPzbEPSkzG8wGG9aDuhHRg== - dependencies: - "@babel/helper-plugin-utils" "^7.16.7" - -"@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining@^7.16.7": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining/-/plugin-bugfix-v8-spread-parameters-in-optional-chaining-7.16.7.tgz#cc001234dfc139ac45f6bcf801866198c8c72ff9" - integrity sha512-di8vUHRdf+4aJ7ltXhaDbPoszdkh59AQtJM5soLsuHpQJdFQZOA4uGj0V2u/CZ8bJ/u8ULDL5yq6FO/bCXnKHw== - dependencies: - "@babel/helper-plugin-utils" "^7.16.7" - "@babel/helper-skip-transparent-expression-wrappers" "^7.16.0" - "@babel/plugin-proposal-optional-chaining" "^7.16.7" - -"@babel/plugin-proposal-async-generator-functions@^7.16.8": - version "7.16.8" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-async-generator-functions/-/plugin-proposal-async-generator-functions-7.16.8.tgz#3bdd1ebbe620804ea9416706cd67d60787504bc8" - integrity sha512-71YHIvMuiuqWJQkebWJtdhQTfd4Q4mF76q2IX37uZPkG9+olBxsX+rH1vkhFto4UeJZ9dPY2s+mDvhDm1u2BGQ== - dependencies: - "@babel/helper-plugin-utils" "^7.16.7" - "@babel/helper-remap-async-to-generator" "^7.16.8" - "@babel/plugin-syntax-async-generators" "^7.8.4" - -"@babel/plugin-proposal-class-properties@^7.16.7": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-class-properties/-/plugin-proposal-class-properties-7.16.7.tgz#925cad7b3b1a2fcea7e59ecc8eb5954f961f91b0" - integrity sha512-IobU0Xme31ewjYOShSIqd/ZGM/r/cuOz2z0MDbNrhF5FW+ZVgi0f2lyeoj9KFPDOAqsYxmLWZte1WOwlvY9aww== - dependencies: - "@babel/helper-create-class-features-plugin" "^7.16.7" - "@babel/helper-plugin-utils" "^7.16.7" - -"@babel/plugin-proposal-class-static-block@^7.16.7": - version "7.17.6" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-class-static-block/-/plugin-proposal-class-static-block-7.17.6.tgz#164e8fd25f0d80fa48c5a4d1438a6629325ad83c" - integrity sha512-X/tididvL2zbs7jZCeeRJ8167U/+Ac135AM6jCAx6gYXDUviZV5Ku9UDvWS2NCuWlFjIRXklYhwo6HhAC7ETnA== - dependencies: - "@babel/helper-create-class-features-plugin" "^7.17.6" - "@babel/helper-plugin-utils" "^7.16.7" - "@babel/plugin-syntax-class-static-block" "^7.14.5" - -"@babel/plugin-proposal-dynamic-import@^7.16.7": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-dynamic-import/-/plugin-proposal-dynamic-import-7.16.7.tgz#c19c897eaa46b27634a00fee9fb7d829158704b2" - integrity sha512-I8SW9Ho3/8DRSdmDdH3gORdyUuYnk1m4cMxUAdu5oy4n3OfN8flDEH+d60iG7dUfi0KkYwSvoalHzzdRzpWHTg== - dependencies: - "@babel/helper-plugin-utils" "^7.16.7" - "@babel/plugin-syntax-dynamic-import" "^7.8.3" - -"@babel/plugin-proposal-export-namespace-from@^7.16.7": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-export-namespace-from/-/plugin-proposal-export-namespace-from-7.16.7.tgz#09de09df18445a5786a305681423ae63507a6163" - integrity sha512-ZxdtqDXLRGBL64ocZcs7ovt71L3jhC1RGSyR996svrCi3PYqHNkb3SwPJCs8RIzD86s+WPpt2S73+EHCGO+NUA== - dependencies: - "@babel/helper-plugin-utils" "^7.16.7" - "@babel/plugin-syntax-export-namespace-from" "^7.8.3" - -"@babel/plugin-proposal-json-strings@^7.16.7": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-json-strings/-/plugin-proposal-json-strings-7.16.7.tgz#9732cb1d17d9a2626a08c5be25186c195b6fa6e8" - integrity sha512-lNZ3EEggsGY78JavgbHsK9u5P3pQaW7k4axlgFLYkMd7UBsiNahCITShLjNQschPyjtO6dADrL24757IdhBrsQ== - dependencies: - "@babel/helper-plugin-utils" "^7.16.7" - "@babel/plugin-syntax-json-strings" "^7.8.3" - -"@babel/plugin-proposal-logical-assignment-operators@^7.16.7": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-logical-assignment-operators/-/plugin-proposal-logical-assignment-operators-7.16.7.tgz#be23c0ba74deec1922e639832904be0bea73cdea" - integrity sha512-K3XzyZJGQCr00+EtYtrDjmwX7o7PLK6U9bi1nCwkQioRFVUv6dJoxbQjtWVtP+bCPy82bONBKG8NPyQ4+i6yjg== - dependencies: - "@babel/helper-plugin-utils" "^7.16.7" - "@babel/plugin-syntax-logical-assignment-operators" "^7.10.4" - -"@babel/plugin-proposal-nullish-coalescing-operator@^7.16.7": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-nullish-coalescing-operator/-/plugin-proposal-nullish-coalescing-operator-7.16.7.tgz#141fc20b6857e59459d430c850a0011e36561d99" - integrity sha512-aUOrYU3EVtjf62jQrCj63pYZ7k6vns2h/DQvHPWGmsJRYzWXZ6/AsfgpiRy6XiuIDADhJzP2Q9MwSMKauBQ+UQ== - dependencies: - "@babel/helper-plugin-utils" "^7.16.7" - "@babel/plugin-syntax-nullish-coalescing-operator" "^7.8.3" - -"@babel/plugin-proposal-numeric-separator@^7.16.7": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-numeric-separator/-/plugin-proposal-numeric-separator-7.16.7.tgz#d6b69f4af63fb38b6ca2558442a7fb191236eba9" - integrity sha512-vQgPMknOIgiuVqbokToyXbkY/OmmjAzr/0lhSIbG/KmnzXPGwW/AdhdKpi+O4X/VkWiWjnkKOBiqJrTaC98VKw== - dependencies: - "@babel/helper-plugin-utils" "^7.16.7" - "@babel/plugin-syntax-numeric-separator" "^7.10.4" - -"@babel/plugin-proposal-object-rest-spread@^7.16.7": - version "7.17.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-object-rest-spread/-/plugin-proposal-object-rest-spread-7.17.3.tgz#d9eb649a54628a51701aef7e0ea3d17e2b9dd390" - integrity sha512-yuL5iQA/TbZn+RGAfxQXfi7CNLmKi1f8zInn4IgobuCWcAb7i+zj4TYzQ9l8cEzVyJ89PDGuqxK1xZpUDISesw== - dependencies: - "@babel/compat-data" "^7.17.0" - "@babel/helper-compilation-targets" "^7.16.7" - "@babel/helper-plugin-utils" "^7.16.7" - "@babel/plugin-syntax-object-rest-spread" "^7.8.3" - "@babel/plugin-transform-parameters" "^7.16.7" - -"@babel/plugin-proposal-optional-catch-binding@^7.16.7": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-optional-catch-binding/-/plugin-proposal-optional-catch-binding-7.16.7.tgz#c623a430674ffc4ab732fd0a0ae7722b67cb74cf" - integrity sha512-eMOH/L4OvWSZAE1VkHbr1vckLG1WUcHGJSLqqQwl2GaUqG6QjddvrOaTUMNYiv77H5IKPMZ9U9P7EaHwvAShfA== - dependencies: - "@babel/helper-plugin-utils" "^7.16.7" - "@babel/plugin-syntax-optional-catch-binding" "^7.8.3" - -"@babel/plugin-proposal-optional-chaining@^7.16.7": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-optional-chaining/-/plugin-proposal-optional-chaining-7.16.7.tgz#7cd629564724816c0e8a969535551f943c64c39a" - integrity sha512-eC3xy+ZrUcBtP7x+sq62Q/HYd674pPTb/77XZMb5wbDPGWIdUbSr4Agr052+zaUPSb+gGRnjxXfKFvx5iMJ+DA== - dependencies: - "@babel/helper-plugin-utils" "^7.16.7" - "@babel/helper-skip-transparent-expression-wrappers" "^7.16.0" - "@babel/plugin-syntax-optional-chaining" "^7.8.3" - -"@babel/plugin-proposal-private-methods@^7.16.11": - version "7.16.11" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-private-methods/-/plugin-proposal-private-methods-7.16.11.tgz#e8df108288555ff259f4527dbe84813aac3a1c50" - integrity sha512-F/2uAkPlXDr8+BHpZvo19w3hLFKge+k75XUprE6jaqKxjGkSYcK+4c+bup5PdW/7W/Rpjwql7FTVEDW+fRAQsw== - dependencies: - "@babel/helper-create-class-features-plugin" "^7.16.10" - "@babel/helper-plugin-utils" "^7.16.7" - -"@babel/plugin-proposal-private-property-in-object@^7.16.7": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-private-property-in-object/-/plugin-proposal-private-property-in-object-7.16.7.tgz#b0b8cef543c2c3d57e59e2c611994861d46a3fce" - integrity sha512-rMQkjcOFbm+ufe3bTZLyOfsOUOxyvLXZJCTARhJr+8UMSoZmqTe1K1BgkFcrW37rAchWg57yI69ORxiWvUINuQ== - dependencies: - "@babel/helper-annotate-as-pure" "^7.16.7" - "@babel/helper-create-class-features-plugin" "^7.16.7" - "@babel/helper-plugin-utils" "^7.16.7" - "@babel/plugin-syntax-private-property-in-object" "^7.14.5" - -"@babel/plugin-proposal-unicode-property-regex@^7.16.7", "@babel/plugin-proposal-unicode-property-regex@^7.4.4": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-unicode-property-regex/-/plugin-proposal-unicode-property-regex-7.16.7.tgz#635d18eb10c6214210ffc5ff4932552de08188a2" - integrity sha512-QRK0YI/40VLhNVGIjRNAAQkEHws0cswSdFFjpFyt943YmJIU1da9uW63Iu6NFV6CxTZW5eTDCrwZUstBWgp/Rg== - dependencies: - "@babel/helper-create-regexp-features-plugin" "^7.16.7" - "@babel/helper-plugin-utils" "^7.16.7" - -"@babel/plugin-syntax-async-generators@^7.8.4": - version "7.8.4" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-async-generators/-/plugin-syntax-async-generators-7.8.4.tgz#a983fb1aeb2ec3f6ed042a210f640e90e786fe0d" - integrity sha512-tycmZxkGfZaxhMRbXlPXuVFpdWlXpir2W4AMhSJgRKzk/eDlIXOhb2LHWoLpDF7TEHylV5zNhykX6KAgHJmTNw== - dependencies: - "@babel/helper-plugin-utils" "^7.8.0" - -"@babel/plugin-syntax-class-properties@^7.12.13": - version "7.12.13" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-class-properties/-/plugin-syntax-class-properties-7.12.13.tgz#b5c987274c4a3a82b89714796931a6b53544ae10" - integrity sha512-fm4idjKla0YahUNgFNLCB0qySdsoPiZP3iQE3rky0mBUtMZ23yDJ9SJdg6dXTSDnulOVqiF3Hgr9nbXvXTQZYA== - dependencies: - "@babel/helper-plugin-utils" "^7.12.13" - -"@babel/plugin-syntax-class-static-block@^7.14.5": - version "7.14.5" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-class-static-block/-/plugin-syntax-class-static-block-7.14.5.tgz#195df89b146b4b78b3bf897fd7a257c84659d406" - integrity sha512-b+YyPmr6ldyNnM6sqYeMWE+bgJcJpO6yS4QD7ymxgH34GBPNDM/THBh8iunyvKIZztiwLH4CJZ0RxTk9emgpjw== - dependencies: - "@babel/helper-plugin-utils" "^7.14.5" - -"@babel/plugin-syntax-dynamic-import@^7.8.3": - version "7.8.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-dynamic-import/-/plugin-syntax-dynamic-import-7.8.3.tgz#62bf98b2da3cd21d626154fc96ee5b3cb68eacb3" - integrity sha512-5gdGbFon+PszYzqs83S3E5mpi7/y/8M9eC90MRTZfduQOYW76ig6SOSPNe41IG5LoP3FGBn2N0RjVDSQiS94kQ== - dependencies: - "@babel/helper-plugin-utils" "^7.8.0" - -"@babel/plugin-syntax-export-namespace-from@^7.8.3": - version "7.8.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-export-namespace-from/-/plugin-syntax-export-namespace-from-7.8.3.tgz#028964a9ba80dbc094c915c487ad7c4e7a66465a" - integrity sha512-MXf5laXo6c1IbEbegDmzGPwGNTsHZmEy6QGznu5Sh2UCWvueywb2ee+CCE4zQiZstxU9BMoQO9i6zUFSY0Kj0Q== - dependencies: - "@babel/helper-plugin-utils" "^7.8.3" - -"@babel/plugin-syntax-json-strings@^7.8.3": - version "7.8.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-json-strings/-/plugin-syntax-json-strings-7.8.3.tgz#01ca21b668cd8218c9e640cb6dd88c5412b2c96a" - integrity sha512-lY6kdGpWHvjoe2vk4WrAapEuBR69EMxZl+RoGRhrFGNYVK8mOPAW8VfbT/ZgrFbXlDNiiaxQnAtgVCZ6jv30EA== - dependencies: - "@babel/helper-plugin-utils" "^7.8.0" - -"@babel/plugin-syntax-logical-assignment-operators@^7.10.4": - version "7.10.4" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-logical-assignment-operators/-/plugin-syntax-logical-assignment-operators-7.10.4.tgz#ca91ef46303530448b906652bac2e9fe9941f699" - integrity sha512-d8waShlpFDinQ5MtvGU9xDAOzKH47+FFoney2baFIoMr952hKOLp1HR7VszoZvOsV/4+RRszNY7D17ba0te0ig== - dependencies: - "@babel/helper-plugin-utils" "^7.10.4" - -"@babel/plugin-syntax-nullish-coalescing-operator@^7.8.3": - version "7.8.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-nullish-coalescing-operator/-/plugin-syntax-nullish-coalescing-operator-7.8.3.tgz#167ed70368886081f74b5c36c65a88c03b66d1a9" - integrity sha512-aSff4zPII1u2QD7y+F8oDsz19ew4IGEJg9SVW+bqwpwtfFleiQDMdzA/R+UlWDzfnHFCxxleFT0PMIrR36XLNQ== - dependencies: - "@babel/helper-plugin-utils" "^7.8.0" - -"@babel/plugin-syntax-numeric-separator@^7.10.4": - version "7.10.4" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-numeric-separator/-/plugin-syntax-numeric-separator-7.10.4.tgz#b9b070b3e33570cd9fd07ba7fa91c0dd37b9af97" - integrity sha512-9H6YdfkcK/uOnY/K7/aA2xpzaAgkQn37yzWUMRK7OaPOqOpGS1+n0H5hxT9AUw9EsSjPW8SVyMJwYRtWs3X3ug== - dependencies: - "@babel/helper-plugin-utils" "^7.10.4" - -"@babel/plugin-syntax-object-rest-spread@^7.8.3": - version "7.8.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-object-rest-spread/-/plugin-syntax-object-rest-spread-7.8.3.tgz#60e225edcbd98a640332a2e72dd3e66f1af55871" - integrity sha512-XoqMijGZb9y3y2XskN+P1wUGiVwWZ5JmoDRwx5+3GmEplNyVM2s2Dg8ILFQm8rWM48orGy5YpI5Bl8U1y7ydlA== - dependencies: - "@babel/helper-plugin-utils" "^7.8.0" - -"@babel/plugin-syntax-optional-catch-binding@^7.8.3": - version "7.8.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-optional-catch-binding/-/plugin-syntax-optional-catch-binding-7.8.3.tgz#6111a265bcfb020eb9efd0fdfd7d26402b9ed6c1" - integrity sha512-6VPD0Pc1lpTqw0aKoeRTMiB+kWhAoT24PA+ksWSBrFtl5SIRVpZlwN3NNPQjehA2E/91FV3RjLWoVTglWcSV3Q== - dependencies: - "@babel/helper-plugin-utils" "^7.8.0" - -"@babel/plugin-syntax-optional-chaining@^7.8.3": - version "7.8.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-optional-chaining/-/plugin-syntax-optional-chaining-7.8.3.tgz#4f69c2ab95167e0180cd5336613f8c5788f7d48a" - integrity sha512-KoK9ErH1MBlCPxV0VANkXW2/dw4vlbGDrFgz8bmUsBGYkFRcbRwMh6cIJubdPrkxRwuGdtCk0v/wPTKbQgBjkg== - dependencies: - "@babel/helper-plugin-utils" "^7.8.0" - -"@babel/plugin-syntax-private-property-in-object@^7.14.5": - version "7.14.5" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-private-property-in-object/-/plugin-syntax-private-property-in-object-7.14.5.tgz#0dc6671ec0ea22b6e94a1114f857970cd39de1ad" - integrity sha512-0wVnp9dxJ72ZUJDV27ZfbSj6iHLoytYZmh3rFcxNnvsJF3ktkzLDZPy/mA17HGsaQT3/DQsWYX1f1QGWkCoVUg== - dependencies: - "@babel/helper-plugin-utils" "^7.14.5" - -"@babel/plugin-syntax-top-level-await@^7.14.5": - version "7.14.5" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-top-level-await/-/plugin-syntax-top-level-await-7.14.5.tgz#c1cfdadc35a646240001f06138247b741c34d94c" - integrity sha512-hx++upLv5U1rgYfwe1xBQUhRmU41NEvpUvrp8jkrSCdvGSnM5/qdRMtylJ6PG5OFkBaHkbTAKTnd3/YyESRHFw== - dependencies: - "@babel/helper-plugin-utils" "^7.14.5" - -"@babel/plugin-transform-arrow-functions@^7.16.7": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-arrow-functions/-/plugin-transform-arrow-functions-7.16.7.tgz#44125e653d94b98db76369de9c396dc14bef4154" - integrity sha512-9ffkFFMbvzTvv+7dTp/66xvZAWASuPD5Tl9LK3Z9vhOmANo6j94rik+5YMBt4CwHVMWLWpMsriIc2zsa3WW3xQ== - dependencies: - "@babel/helper-plugin-utils" "^7.16.7" - -"@babel/plugin-transform-async-to-generator@^7.16.8": - version "7.16.8" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-async-to-generator/-/plugin-transform-async-to-generator-7.16.8.tgz#b83dff4b970cf41f1b819f8b49cc0cfbaa53a808" - integrity sha512-MtmUmTJQHCnyJVrScNzNlofQJ3dLFuobYn3mwOTKHnSCMtbNsqvF71GQmJfFjdrXSsAA7iysFmYWw4bXZ20hOg== - dependencies: - "@babel/helper-module-imports" "^7.16.7" - "@babel/helper-plugin-utils" "^7.16.7" - "@babel/helper-remap-async-to-generator" "^7.16.8" - -"@babel/plugin-transform-block-scoped-functions@^7.16.7": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-block-scoped-functions/-/plugin-transform-block-scoped-functions-7.16.7.tgz#4d0d57d9632ef6062cdf354bb717102ee042a620" - integrity sha512-JUuzlzmF40Z9cXyytcbZEZKckgrQzChbQJw/5PuEHYeqzCsvebDx0K0jWnIIVcmmDOAVctCgnYs0pMcrYj2zJg== - dependencies: - "@babel/helper-plugin-utils" "^7.16.7" - -"@babel/plugin-transform-block-scoping@^7.16.7": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-block-scoping/-/plugin-transform-block-scoping-7.16.7.tgz#f50664ab99ddeaee5bc681b8f3a6ea9d72ab4f87" - integrity sha512-ObZev2nxVAYA4bhyusELdo9hb3H+A56bxH3FZMbEImZFiEDYVHXQSJ1hQKFlDnlt8G9bBrCZ5ZpURZUrV4G5qQ== - dependencies: - "@babel/helper-plugin-utils" "^7.16.7" - -"@babel/plugin-transform-classes@^7.16.7": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-classes/-/plugin-transform-classes-7.16.7.tgz#8f4b9562850cd973de3b498f1218796eb181ce00" - integrity sha512-WY7og38SFAGYRe64BrjKf8OrE6ulEHtr5jEYaZMwox9KebgqPi67Zqz8K53EKk1fFEJgm96r32rkKZ3qA2nCWQ== - dependencies: - "@babel/helper-annotate-as-pure" "^7.16.7" - "@babel/helper-environment-visitor" "^7.16.7" - "@babel/helper-function-name" "^7.16.7" - "@babel/helper-optimise-call-expression" "^7.16.7" - "@babel/helper-plugin-utils" "^7.16.7" - "@babel/helper-replace-supers" "^7.16.7" - "@babel/helper-split-export-declaration" "^7.16.7" - globals "^11.1.0" - -"@babel/plugin-transform-computed-properties@^7.16.7": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-computed-properties/-/plugin-transform-computed-properties-7.16.7.tgz#66dee12e46f61d2aae7a73710f591eb3df616470" - integrity sha512-gN72G9bcmenVILj//sv1zLNaPyYcOzUho2lIJBMh/iakJ9ygCo/hEF9cpGb61SCMEDxbbyBoVQxrt+bWKu5KGw== - dependencies: - "@babel/helper-plugin-utils" "^7.16.7" - -"@babel/plugin-transform-destructuring@^7.16.7": - version "7.17.7" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-destructuring/-/plugin-transform-destructuring-7.17.7.tgz#49dc2675a7afa9a5e4c6bdee636061136c3408d1" - integrity sha512-XVh0r5yq9sLR4vZ6eVZe8FKfIcSgaTBxVBRSYokRj2qksf6QerYnTxz9/GTuKTH/n/HwLP7t6gtlybHetJ/6hQ== - dependencies: - "@babel/helper-plugin-utils" "^7.16.7" - -"@babel/plugin-transform-dotall-regex@^7.16.7", "@babel/plugin-transform-dotall-regex@^7.4.4": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-dotall-regex/-/plugin-transform-dotall-regex-7.16.7.tgz#6b2d67686fab15fb6a7fd4bd895d5982cfc81241" - integrity sha512-Lyttaao2SjZF6Pf4vk1dVKv8YypMpomAbygW+mU5cYP3S5cWTfCJjG8xV6CFdzGFlfWK81IjL9viiTvpb6G7gQ== - dependencies: - "@babel/helper-create-regexp-features-plugin" "^7.16.7" - "@babel/helper-plugin-utils" "^7.16.7" - -"@babel/plugin-transform-duplicate-keys@^7.16.7": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-duplicate-keys/-/plugin-transform-duplicate-keys-7.16.7.tgz#2207e9ca8f82a0d36a5a67b6536e7ef8b08823c9" - integrity sha512-03DvpbRfvWIXyK0/6QiR1KMTWeT6OcQ7tbhjrXyFS02kjuX/mu5Bvnh5SDSWHxyawit2g5aWhKwI86EE7GUnTw== - dependencies: - "@babel/helper-plugin-utils" "^7.16.7" - -"@babel/plugin-transform-exponentiation-operator@^7.16.7": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-exponentiation-operator/-/plugin-transform-exponentiation-operator-7.16.7.tgz#efa9862ef97e9e9e5f653f6ddc7b665e8536fe9b" - integrity sha512-8UYLSlyLgRixQvlYH3J2ekXFHDFLQutdy7FfFAMm3CPZ6q9wHCwnUyiXpQCe3gVVnQlHc5nsuiEVziteRNTXEA== - dependencies: - "@babel/helper-builder-binary-assignment-operator-visitor" "^7.16.7" - "@babel/helper-plugin-utils" "^7.16.7" - -"@babel/plugin-transform-for-of@^7.16.7": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-for-of/-/plugin-transform-for-of-7.16.7.tgz#649d639d4617dff502a9a158c479b3b556728d8c" - integrity sha512-/QZm9W92Ptpw7sjI9Nx1mbcsWz33+l8kuMIQnDwgQBG5s3fAfQvkRjQ7NqXhtNcKOnPkdICmUHyCaWW06HCsqg== - dependencies: - "@babel/helper-plugin-utils" "^7.16.7" - -"@babel/plugin-transform-function-name@^7.16.7": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-function-name/-/plugin-transform-function-name-7.16.7.tgz#5ab34375c64d61d083d7d2f05c38d90b97ec65cf" - integrity sha512-SU/C68YVwTRxqWj5kgsbKINakGag0KTgq9f2iZEXdStoAbOzLHEBRYzImmA6yFo8YZhJVflvXmIHUO7GWHmxxA== - dependencies: - "@babel/helper-compilation-targets" "^7.16.7" - "@babel/helper-function-name" "^7.16.7" - "@babel/helper-plugin-utils" "^7.16.7" - -"@babel/plugin-transform-literals@^7.16.7": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-literals/-/plugin-transform-literals-7.16.7.tgz#254c9618c5ff749e87cb0c0cef1a0a050c0bdab1" - integrity sha512-6tH8RTpTWI0s2sV6uq3e/C9wPo4PTqqZps4uF0kzQ9/xPLFQtipynvmT1g/dOfEJ+0EQsHhkQ/zyRId8J2b8zQ== - dependencies: - "@babel/helper-plugin-utils" "^7.16.7" - -"@babel/plugin-transform-member-expression-literals@^7.16.7": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-member-expression-literals/-/plugin-transform-member-expression-literals-7.16.7.tgz#6e5dcf906ef8a098e630149d14c867dd28f92384" - integrity sha512-mBruRMbktKQwbxaJof32LT9KLy2f3gH+27a5XSuXo6h7R3vqltl0PgZ80C8ZMKw98Bf8bqt6BEVi3svOh2PzMw== - dependencies: - "@babel/helper-plugin-utils" "^7.16.7" - -"@babel/plugin-transform-modules-amd@^7.16.7": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-amd/-/plugin-transform-modules-amd-7.16.7.tgz#b28d323016a7daaae8609781d1f8c9da42b13186" - integrity sha512-KaaEtgBL7FKYwjJ/teH63oAmE3lP34N3kshz8mm4VMAw7U3PxjVwwUmxEFksbgsNUaO3wId9R2AVQYSEGRa2+g== - dependencies: - "@babel/helper-module-transforms" "^7.16.7" - "@babel/helper-plugin-utils" "^7.16.7" - babel-plugin-dynamic-import-node "^2.3.3" - -"@babel/plugin-transform-modules-commonjs@^7.16.8": - version "7.17.7" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.17.7.tgz#d86b217c8e45bb5f2dbc11eefc8eab62cf980d19" - integrity sha512-ITPmR2V7MqioMJyrxUo2onHNC3e+MvfFiFIR0RP21d3PtlVb6sfzoxNKiphSZUOM9hEIdzCcZe83ieX3yoqjUA== - dependencies: - "@babel/helper-module-transforms" "^7.17.7" - "@babel/helper-plugin-utils" "^7.16.7" - "@babel/helper-simple-access" "^7.17.7" - babel-plugin-dynamic-import-node "^2.3.3" - -"@babel/plugin-transform-modules-systemjs@^7.16.7": - version "7.17.8" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-systemjs/-/plugin-transform-modules-systemjs-7.17.8.tgz#81fd834024fae14ea78fbe34168b042f38703859" - integrity sha512-39reIkMTUVagzgA5x88zDYXPCMT6lcaRKs1+S9K6NKBPErbgO/w/kP8GlNQTC87b412ZTlmNgr3k2JrWgHH+Bw== - dependencies: - "@babel/helper-hoist-variables" "^7.16.7" - "@babel/helper-module-transforms" "^7.17.7" - "@babel/helper-plugin-utils" "^7.16.7" - "@babel/helper-validator-identifier" "^7.16.7" - babel-plugin-dynamic-import-node "^2.3.3" - -"@babel/plugin-transform-modules-umd@^7.16.7": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-umd/-/plugin-transform-modules-umd-7.16.7.tgz#23dad479fa585283dbd22215bff12719171e7618" - integrity sha512-EMh7uolsC8O4xhudF2F6wedbSHm1HHZ0C6aJ7K67zcDNidMzVcxWdGr+htW9n21klm+bOn+Rx4CBsAntZd3rEQ== - dependencies: - "@babel/helper-module-transforms" "^7.16.7" - "@babel/helper-plugin-utils" "^7.16.7" - -"@babel/plugin-transform-named-capturing-groups-regex@^7.16.8": - version "7.16.8" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-named-capturing-groups-regex/-/plugin-transform-named-capturing-groups-regex-7.16.8.tgz#7f860e0e40d844a02c9dcf9d84965e7dfd666252" - integrity sha512-j3Jw+n5PvpmhRR+mrgIh04puSANCk/T/UA3m3P1MjJkhlK906+ApHhDIqBQDdOgL/r1UYpz4GNclTXxyZrYGSw== - dependencies: - "@babel/helper-create-regexp-features-plugin" "^7.16.7" - -"@babel/plugin-transform-new-target@^7.16.7": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-new-target/-/plugin-transform-new-target-7.16.7.tgz#9967d89a5c243818e0800fdad89db22c5f514244" - integrity sha512-xiLDzWNMfKoGOpc6t3U+etCE2yRnn3SM09BXqWPIZOBpL2gvVrBWUKnsJx0K/ADi5F5YC5f8APFfWrz25TdlGg== - dependencies: - "@babel/helper-plugin-utils" "^7.16.7" - -"@babel/plugin-transform-object-super@^7.16.7": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-object-super/-/plugin-transform-object-super-7.16.7.tgz#ac359cf8d32cf4354d27a46867999490b6c32a94" - integrity sha512-14J1feiQVWaGvRxj2WjyMuXS2jsBkgB3MdSN5HuC2G5nRspa5RK9COcs82Pwy5BuGcjb+fYaUj94mYcOj7rCvw== - dependencies: - "@babel/helper-plugin-utils" "^7.16.7" - "@babel/helper-replace-supers" "^7.16.7" - -"@babel/plugin-transform-parameters@^7.16.7": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-parameters/-/plugin-transform-parameters-7.16.7.tgz#a1721f55b99b736511cb7e0152f61f17688f331f" - integrity sha512-AT3MufQ7zZEhU2hwOA11axBnExW0Lszu4RL/tAlUJBuNoRak+wehQW8h6KcXOcgjY42fHtDxswuMhMjFEuv/aw== - dependencies: - "@babel/helper-plugin-utils" "^7.16.7" - -"@babel/plugin-transform-property-literals@^7.16.7": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-property-literals/-/plugin-transform-property-literals-7.16.7.tgz#2dadac85155436f22c696c4827730e0fe1057a55" - integrity sha512-z4FGr9NMGdoIl1RqavCqGG+ZuYjfZ/hkCIeuH6Do7tXmSm0ls11nYVSJqFEUOSJbDab5wC6lRE/w6YjVcr6Hqw== - dependencies: - "@babel/helper-plugin-utils" "^7.16.7" - -"@babel/plugin-transform-regenerator@^7.16.7": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-regenerator/-/plugin-transform-regenerator-7.16.7.tgz#9e7576dc476cb89ccc5096fff7af659243b4adeb" - integrity sha512-mF7jOgGYCkSJagJ6XCujSQg+6xC1M77/03K2oBmVJWoFGNUtnVJO4WHKJk3dnPC8HCcj4xBQP1Egm8DWh3Pb3Q== - dependencies: - regenerator-transform "^0.14.2" - -"@babel/plugin-transform-reserved-words@^7.16.7": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-reserved-words/-/plugin-transform-reserved-words-7.16.7.tgz#1d798e078f7c5958eec952059c460b220a63f586" - integrity sha512-KQzzDnZ9hWQBjwi5lpY5v9shmm6IVG0U9pB18zvMu2i4H90xpT4gmqwPYsn8rObiadYe2M0gmgsiOIF5A/2rtg== - dependencies: - "@babel/helper-plugin-utils" "^7.16.7" - -"@babel/plugin-transform-shorthand-properties@^7.16.7": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-shorthand-properties/-/plugin-transform-shorthand-properties-7.16.7.tgz#e8549ae4afcf8382f711794c0c7b6b934c5fbd2a" - integrity sha512-hah2+FEnoRoATdIb05IOXf+4GzXYTq75TVhIn1PewihbpyrNWUt2JbudKQOETWw6QpLe+AIUpJ5MVLYTQbeeUg== - dependencies: - "@babel/helper-plugin-utils" "^7.16.7" - -"@babel/plugin-transform-spread@^7.16.7": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-spread/-/plugin-transform-spread-7.16.7.tgz#a303e2122f9f12e0105daeedd0f30fb197d8ff44" - integrity sha512-+pjJpgAngb53L0iaA5gU/1MLXJIfXcYepLgXB3esVRf4fqmj8f2cxM3/FKaHsZms08hFQJkFccEWuIpm429TXg== - dependencies: - "@babel/helper-plugin-utils" "^7.16.7" - "@babel/helper-skip-transparent-expression-wrappers" "^7.16.0" - -"@babel/plugin-transform-sticky-regex@^7.16.7": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-sticky-regex/-/plugin-transform-sticky-regex-7.16.7.tgz#c84741d4f4a38072b9a1e2e3fd56d359552e8660" - integrity sha512-NJa0Bd/87QV5NZZzTuZG5BPJjLYadeSZ9fO6oOUoL4iQx+9EEuw/eEM92SrsT19Yc2jgB1u1hsjqDtH02c3Drw== - dependencies: - "@babel/helper-plugin-utils" "^7.16.7" - -"@babel/plugin-transform-template-literals@^7.16.7": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-template-literals/-/plugin-transform-template-literals-7.16.7.tgz#f3d1c45d28967c8e80f53666fc9c3e50618217ab" - integrity sha512-VwbkDDUeenlIjmfNeDX/V0aWrQH2QiVyJtwymVQSzItFDTpxfyJh3EVaQiS0rIN/CqbLGr0VcGmuwyTdZtdIsA== - dependencies: - "@babel/helper-plugin-utils" "^7.16.7" - -"@babel/plugin-transform-typeof-symbol@^7.16.7": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-typeof-symbol/-/plugin-transform-typeof-symbol-7.16.7.tgz#9cdbe622582c21368bd482b660ba87d5545d4f7e" - integrity sha512-p2rOixCKRJzpg9JB4gjnG4gjWkWa89ZoYUnl9snJ1cWIcTH/hvxZqfO+WjG6T8DRBpctEol5jw1O5rA8gkCokQ== - dependencies: - "@babel/helper-plugin-utils" "^7.16.7" - -"@babel/plugin-transform-unicode-escapes@^7.16.7": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-unicode-escapes/-/plugin-transform-unicode-escapes-7.16.7.tgz#da8717de7b3287a2c6d659750c964f302b31ece3" - integrity sha512-TAV5IGahIz3yZ9/Hfv35TV2xEm+kaBDaZQCn2S/hG9/CZ0DktxJv9eKfPc7yYCvOYR4JGx1h8C+jcSOvgaaI/Q== - dependencies: - "@babel/helper-plugin-utils" "^7.16.7" - -"@babel/plugin-transform-unicode-regex@^7.16.7": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-unicode-regex/-/plugin-transform-unicode-regex-7.16.7.tgz#0f7aa4a501198976e25e82702574c34cfebe9ef2" - integrity sha512-oC5tYYKw56HO75KZVLQ+R/Nl3Hro9kf8iG0hXoaHP7tjAyCpvqBiSNe6vGrZni1Z6MggmUOC6A7VP7AVmw225Q== - dependencies: - "@babel/helper-create-regexp-features-plugin" "^7.16.7" - "@babel/helper-plugin-utils" "^7.16.7" - -"@babel/polyfill@^7.10.4": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/polyfill/-/polyfill-7.12.1.tgz#1f2d6371d1261bbd961f3c5d5909150e12d0bd96" - integrity sha512-X0pi0V6gxLi6lFZpGmeNa4zxtwEmCs42isWLNjZZDE0Y8yVfgu0T2OAHlzBbdYlqbW/YXVvoBHpATEM+goCj8g== - dependencies: - core-js "^2.6.5" - regenerator-runtime "^0.13.4" - -"@babel/preset-env@^7.11.0": - version "7.16.11" - resolved "https://registry.yarnpkg.com/@babel/preset-env/-/preset-env-7.16.11.tgz#5dd88fd885fae36f88fd7c8342475c9f0abe2982" - integrity sha512-qcmWG8R7ZW6WBRPZK//y+E3Cli151B20W1Rv7ln27vuPaXU/8TKms6jFdiJtF7UDTxcrb7mZd88tAeK9LjdT8g== - dependencies: - "@babel/compat-data" "^7.16.8" - "@babel/helper-compilation-targets" "^7.16.7" - "@babel/helper-plugin-utils" "^7.16.7" - "@babel/helper-validator-option" "^7.16.7" - "@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression" "^7.16.7" - "@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining" "^7.16.7" - "@babel/plugin-proposal-async-generator-functions" "^7.16.8" - "@babel/plugin-proposal-class-properties" "^7.16.7" - "@babel/plugin-proposal-class-static-block" "^7.16.7" - "@babel/plugin-proposal-dynamic-import" "^7.16.7" - "@babel/plugin-proposal-export-namespace-from" "^7.16.7" - "@babel/plugin-proposal-json-strings" "^7.16.7" - "@babel/plugin-proposal-logical-assignment-operators" "^7.16.7" - "@babel/plugin-proposal-nullish-coalescing-operator" "^7.16.7" - "@babel/plugin-proposal-numeric-separator" "^7.16.7" - "@babel/plugin-proposal-object-rest-spread" "^7.16.7" - "@babel/plugin-proposal-optional-catch-binding" "^7.16.7" - "@babel/plugin-proposal-optional-chaining" "^7.16.7" - "@babel/plugin-proposal-private-methods" "^7.16.11" - "@babel/plugin-proposal-private-property-in-object" "^7.16.7" - "@babel/plugin-proposal-unicode-property-regex" "^7.16.7" - "@babel/plugin-syntax-async-generators" "^7.8.4" - "@babel/plugin-syntax-class-properties" "^7.12.13" - "@babel/plugin-syntax-class-static-block" "^7.14.5" - "@babel/plugin-syntax-dynamic-import" "^7.8.3" - "@babel/plugin-syntax-export-namespace-from" "^7.8.3" - "@babel/plugin-syntax-json-strings" "^7.8.3" - "@babel/plugin-syntax-logical-assignment-operators" "^7.10.4" - "@babel/plugin-syntax-nullish-coalescing-operator" "^7.8.3" - "@babel/plugin-syntax-numeric-separator" "^7.10.4" - "@babel/plugin-syntax-object-rest-spread" "^7.8.3" - "@babel/plugin-syntax-optional-catch-binding" "^7.8.3" - "@babel/plugin-syntax-optional-chaining" "^7.8.3" - "@babel/plugin-syntax-private-property-in-object" "^7.14.5" - "@babel/plugin-syntax-top-level-await" "^7.14.5" - "@babel/plugin-transform-arrow-functions" "^7.16.7" - "@babel/plugin-transform-async-to-generator" "^7.16.8" - "@babel/plugin-transform-block-scoped-functions" "^7.16.7" - "@babel/plugin-transform-block-scoping" "^7.16.7" - "@babel/plugin-transform-classes" "^7.16.7" - "@babel/plugin-transform-computed-properties" "^7.16.7" - "@babel/plugin-transform-destructuring" "^7.16.7" - "@babel/plugin-transform-dotall-regex" "^7.16.7" - "@babel/plugin-transform-duplicate-keys" "^7.16.7" - "@babel/plugin-transform-exponentiation-operator" "^7.16.7" - "@babel/plugin-transform-for-of" "^7.16.7" - "@babel/plugin-transform-function-name" "^7.16.7" - "@babel/plugin-transform-literals" "^7.16.7" - "@babel/plugin-transform-member-expression-literals" "^7.16.7" - "@babel/plugin-transform-modules-amd" "^7.16.7" - "@babel/plugin-transform-modules-commonjs" "^7.16.8" - "@babel/plugin-transform-modules-systemjs" "^7.16.7" - "@babel/plugin-transform-modules-umd" "^7.16.7" - "@babel/plugin-transform-named-capturing-groups-regex" "^7.16.8" - "@babel/plugin-transform-new-target" "^7.16.7" - "@babel/plugin-transform-object-super" "^7.16.7" - "@babel/plugin-transform-parameters" "^7.16.7" - "@babel/plugin-transform-property-literals" "^7.16.7" - "@babel/plugin-transform-regenerator" "^7.16.7" - "@babel/plugin-transform-reserved-words" "^7.16.7" - "@babel/plugin-transform-shorthand-properties" "^7.16.7" - "@babel/plugin-transform-spread" "^7.16.7" - "@babel/plugin-transform-sticky-regex" "^7.16.7" - "@babel/plugin-transform-template-literals" "^7.16.7" - "@babel/plugin-transform-typeof-symbol" "^7.16.7" - "@babel/plugin-transform-unicode-escapes" "^7.16.7" - "@babel/plugin-transform-unicode-regex" "^7.16.7" - "@babel/preset-modules" "^0.1.5" - "@babel/types" "^7.16.8" - babel-plugin-polyfill-corejs2 "^0.3.0" - babel-plugin-polyfill-corejs3 "^0.5.0" - babel-plugin-polyfill-regenerator "^0.3.0" - core-js-compat "^3.20.2" - semver "^6.3.0" - -"@babel/preset-modules@^0.1.5": - version "0.1.5" - resolved "https://registry.yarnpkg.com/@babel/preset-modules/-/preset-modules-0.1.5.tgz#ef939d6e7f268827e1841638dc6ff95515e115d9" - integrity sha512-A57th6YRG7oR3cq/yt/Y84MvGgE0eJG2F1JLhKuyG+jFxEgrd/HAMJatiFtmOiZurz+0DkrvbheCLaV5f2JfjA== - dependencies: - "@babel/helper-plugin-utils" "^7.0.0" - "@babel/plugin-proposal-unicode-property-regex" "^7.4.4" - "@babel/plugin-transform-dotall-regex" "^7.4.4" - "@babel/types" "^7.4.4" - esutils "^2.0.2" - -"@babel/runtime@^7.8.4": - version "7.17.8" - resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.17.8.tgz#3e56e4aff81befa55ac3ac6a0967349fd1c5bca2" - integrity sha512-dQpEpK0O9o6lj6oPu0gRDbbnk+4LeHlNcBpspf6Olzt3GIX4P1lWF1gS+pHLDFlaJvbR6q7jCfQ08zA4QJBnmA== - dependencies: - regenerator-runtime "^0.13.4" - -"@babel/template@^7.16.7": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.16.7.tgz#8d126c8701fde4d66b264b3eba3d96f07666d155" - integrity sha512-I8j/x8kHUrbYRTUxXrrMbfCa7jxkE7tZre39x3kjr9hvI82cK1FfqLygotcWN5kdPGWcLdWMHpSBavse5tWw3w== - dependencies: - "@babel/code-frame" "^7.16.7" - "@babel/parser" "^7.16.7" - "@babel/types" "^7.16.7" - -"@babel/traverse@^7.13.0", "@babel/traverse@^7.16.7", "@babel/traverse@^7.16.8", "@babel/traverse@^7.17.3": - version "7.17.3" - resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.17.3.tgz#0ae0f15b27d9a92ba1f2263358ea7c4e7db47b57" - integrity sha512-5irClVky7TxRWIRtxlh2WPUUOLhcPN06AGgaQSB8AEwuyEBgJVuJ5imdHm5zxk8w0QS5T+tDfnDxAlhWjpb7cw== - dependencies: - "@babel/code-frame" "^7.16.7" - "@babel/generator" "^7.17.3" - "@babel/helper-environment-visitor" "^7.16.7" - "@babel/helper-function-name" "^7.16.7" - "@babel/helper-hoist-variables" "^7.16.7" - "@babel/helper-split-export-declaration" "^7.16.7" - "@babel/parser" "^7.17.3" - "@babel/types" "^7.17.0" - debug "^4.1.0" - globals "^11.1.0" - -"@babel/types@^7.16.0", "@babel/types@^7.16.7", "@babel/types@^7.16.8", "@babel/types@^7.17.0", "@babel/types@^7.4.4": - version "7.17.0" - resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.17.0.tgz#a826e368bccb6b3d84acd76acad5c0d87342390b" - integrity sha512-TmKSNO4D5rzhL5bjWFcVHHLETzfQ/AmbKpKPOSjlP0WoHZ6L911fgoOKY4Alp/emzG4cHJdyN49zpgkbXFEHHw== - dependencies: - "@babel/helper-validator-identifier" "^7.16.7" - to-fast-properties "^2.0.0" - -"@colors/colors@1.5.0": - version "1.5.0" - resolved "https://registry.yarnpkg.com/@colors/colors/-/colors-1.5.0.tgz#bb504579c1cae923e6576a4f5da43d25f97bdbd9" - integrity sha512-ooWCrlZP11i8GImSjTHYHLkvFDP48nS4+204nGb1RiX/WXYHmJA2III9/e2DWVabCESdW7hBAEzHRqUn9OUVvQ== - -"@cspotcode/source-map-support@^0.8.0": - version "0.8.1" - resolved "https://registry.yarnpkg.com/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz#00629c35a688e05a88b1cda684fb9d5e73f000a1" - integrity sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw== - dependencies: - "@jridgewell/trace-mapping" "0.3.9" - -"@istanbuljs/schema@^0.1.2": - version "0.1.3" - resolved "https://registry.yarnpkg.com/@istanbuljs/schema/-/schema-0.1.3.tgz#e45e384e4b8ec16bce2fd903af78450f6bf7ec98" - integrity sha512-ZXRY4jNvVgSVQ8DL3LTcakaAtXwTVUxE81hslsyD2AtoXW/wVob10HkOJ1X/pAlcI7D+2YoZKg5do8G/w6RYgA== - -"@jridgewell/resolve-uri@^3.0.3": - version "3.0.5" - resolved "https://registry.yarnpkg.com/@jridgewell/resolve-uri/-/resolve-uri-3.0.5.tgz#68eb521368db76d040a6315cdb24bf2483037b9c" - integrity sha512-VPeQ7+wH0itvQxnG+lIzWgkysKIr3L9sslimFW55rHMdGu/qCQ5z5h9zq4gI8uBtqkpHhsF4Z/OwExufUCThew== - -"@jridgewell/sourcemap-codec@^1.4.10": - version "1.4.11" - resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.11.tgz#771a1d8d744eeb71b6adb35808e1a6c7b9b8c8ec" - integrity sha512-Fg32GrJo61m+VqYSdRSjRXMjQ06j8YIYfcTqndLYVAaHmroZHLJZCydsWBOTDqXS2v+mjxohBWEMfg97GXmYQg== - -"@jridgewell/trace-mapping@0.3.9": - version "0.3.9" - resolved "https://registry.yarnpkg.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz#6534fd5933a53ba7cbf3a17615e273a0d1273ff9" - integrity sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ== - dependencies: - "@jridgewell/resolve-uri" "^3.0.3" - "@jridgewell/sourcemap-codec" "^1.4.10" - -"@jridgewell/trace-mapping@^0.3.0": - version "0.3.4" - resolved "https://registry.yarnpkg.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.4.tgz#f6a0832dffd5b8a6aaa633b7d9f8e8e94c83a0c3" - integrity sha512-vFv9ttIedivx0ux3QSjhgtCVjPZd5l46ZOMDSCwnH1yUO2e964gO8LZGyv2QkqcgR6TnBU1v+1IFqmeoG+0UJQ== - dependencies: - "@jridgewell/resolve-uri" "^3.0.3" - "@jridgewell/sourcemap-codec" "^1.4.10" - -"@mapbox/node-pre-gyp@1.0.9": - version "1.0.9" - resolved "https://registry.yarnpkg.com/@mapbox/node-pre-gyp/-/node-pre-gyp-1.0.9.tgz#09a8781a3a036151cdebbe8719d6f8b25d4058bc" - integrity sha512-aDF3S3rK9Q2gey/WAttUlISduDItz5BU3306M9Eyv6/oS40aMprnopshtlKTykxRNIBEZuRMaZAnbrQ4QtKGyw== - dependencies: - detect-libc "^2.0.0" - https-proxy-agent "^5.0.0" - make-dir "^3.1.0" - node-fetch "^2.6.7" - nopt "^5.0.0" - npmlog "^5.0.1" - rimraf "^3.0.2" - semver "^7.3.5" - tar "^6.1.11" - -"@tensorflow/tfjs-backend-cpu@link:../link-package/node_modules/@tensorflow/link-package/node_modules/@tensorflow/tfjs-backend-cpu": - version "0.0.0" - -"@tensorflow/tfjs-backend-cpu@link:../link-package/node_modules/@tensorflow/tfjs-backend-cpu": - version "0.0.0" - uid "" - -"@tensorflow/tfjs-backend-wasm@link:../link-package/node_modules/@tensorflow/tfjs-backend-wasm": - version "0.0.0" - uid "" - -"@tensorflow/tfjs-backend-webgl@link:../link-package/node_modules/@tensorflow/tfjs-backend-webgl": - version "0.0.0" - uid "" - -"@tensorflow/tfjs-backend-webgpu@link:../link-package/node_modules/@tensorflow/tfjs-backend-webgpu": - version "0.0.0" - uid "" - -"@tensorflow/tfjs-converter@link:../link-package/node_modules/@tensorflow/tfjs-converter": - version "0.0.0" - uid "" - -"@tensorflow/tfjs-core@link:../link-package/node_modules/@tensorflow/tfjs-core": - version "0.0.0" - uid "" - -"@tensorflow/tfjs-data@link:../link-package/node_modules/@tensorflow/tfjs-data": - version "0.0.0" - uid "" - -"@tensorflow/tfjs-layers@link:../link-package/node_modules/@tensorflow/tfjs-layers": - version "0.0.0" - uid "" - -"@tensorflow/tfjs-node@link:../tfjs-node": - version "0.0.0" - uid "" - -"@tensorflow/tfjs@link:../tfjs": - version "0.0.0" - uid "" - -"@tsconfig/node10@^1.0.7": - version "1.0.9" - resolved "https://registry.yarnpkg.com/@tsconfig/node10/-/node10-1.0.9.tgz#df4907fc07a886922637b15e02d4cebc4c0021b2" - integrity sha512-jNsYVVxU8v5g43Erja32laIDHXeoNvFEpX33OK4d6hljo3jDhCBDhx5dhCCTMWUojscpAagGiRkBKxpdl9fxqA== - -"@tsconfig/node12@^1.0.7": - version "1.0.11" - resolved "https://registry.yarnpkg.com/@tsconfig/node12/-/node12-1.0.11.tgz#ee3def1f27d9ed66dac6e46a295cffb0152e058d" - integrity sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag== - -"@tsconfig/node14@^1.0.0": - version "1.0.3" - resolved "https://registry.yarnpkg.com/@tsconfig/node14/-/node14-1.0.3.tgz#e4386316284f00b98435bf40f72f75a09dabf6c1" - integrity sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow== - -"@tsconfig/node16@^1.0.2": - version "1.0.3" - resolved "https://registry.yarnpkg.com/@tsconfig/node16/-/node16-1.0.3.tgz#472eaab5f15c1ffdd7f8628bd4c4f753995ec79e" - integrity sha512-yOlFc+7UtL/89t2ZhjPvvB/DeAr3r+Dq58IgzsFkOAvVC6NMJXmCGjbptdXdR9qsX7pKcTL+s87FtYREi2dEEQ== - -"@types/component-emitter@^1.2.10": - version "1.2.11" - resolved "https://registry.yarnpkg.com/@types/component-emitter/-/component-emitter-1.2.11.tgz#50d47d42b347253817a39709fef03ce66a108506" - integrity sha512-SRXjM+tfsSlA9VuG8hGO2nft2p8zjXCK1VcC6N4NXbBbYbSia9kzCChYQajIjzIqOOOuh5Ock6MmV2oux4jDZQ== - -"@types/cookie@^0.4.1": - version "0.4.1" - resolved "https://registry.yarnpkg.com/@types/cookie/-/cookie-0.4.1.tgz#bfd02c1f2224567676c1545199f87c3a861d878d" - integrity sha512-XW/Aa8APYr6jSVVA1y/DEIZX0/GMKLEVekNG727R8cs56ahETkRAy/3DR7+fJyh7oUgGwNQaRfXCun0+KbWY7Q== - -"@types/cors@^2.8.12": - version "2.8.12" - resolved "https://registry.yarnpkg.com/@types/cors/-/cors-2.8.12.tgz#6b2c510a7ad7039e98e7b8d3d6598f4359e5c080" - integrity sha512-vt+kDhq/M2ayberEtJcIN/hxXy1Pk+59g2FV/ZQceeaTyCtCucjL2Q7FXlFjtWn4n15KCr1NE2lNNFhp0lEThw== - -"@types/detect-browser@^4.0.0": - version "4.0.0" - resolved "https://registry.yarnpkg.com/@types/detect-browser/-/detect-browser-4.0.0.tgz#5672576f9621aad8773489593fca2e4c57c29fb5" - integrity sha512-c2cAqR4G5QL2aPDgzpsk8ck/R+w7djxpe05Z8XYg1Ahfe/Bekb+06PG9zw64T6I1oNWDVM+IAsSbyASVydAdRw== - dependencies: - detect-browser "*" - -"@types/emscripten@~0.0.34": - version "0.0.34" - resolved "https://registry.yarnpkg.com/@types/emscripten/-/emscripten-0.0.34.tgz#12b4a344274fb102ff2f6c877b37587bc3e46008" - integrity sha512-QSb9ojDincskc+uKMI0KXp8e1NALFINCrMlp8VGKGcTSxeEyRTTKyjWw75NYrCZHUsVEEEpr1tYHpbtaC++/sQ== - -"@types/jasmine@~3.0.0": - version "3.0.0" - resolved "https://registry.yarnpkg.com/@types/jasmine/-/jasmine-3.0.0.tgz#9a6b6755a02fcd6baa088a767557709c79728f98" - integrity sha512-yeQ81bQ46gOfj+AQLp5/x0Kylq6lz9d5a82Vo5JS63rDn1ctoItKcwrcKEM1wGsjqA4SrYkzzIHo8dbq8RhG5w== - -"@types/long@^4.0.1": - version "4.0.2" - resolved "https://registry.yarnpkg.com/@types/long/-/long-4.0.2.tgz#b74129719fc8d11c01868010082d483b7545591a" - integrity sha512-MqTGEo5bj5t157U6fA/BiDynNkn0YknVdh48CMPkTSpFTVmvao5UQmm7uEF6xBEo7qIMAlY/JSleYaE6VOdpaA== - -"@types/mathjs@^5.0.1": - version "5.0.1" - resolved "https://registry.yarnpkg.com/@types/mathjs/-/mathjs-5.0.1.tgz#b98e163ea396b4f27bec20ee25ffb8fe9e656af8" - integrity sha512-EFBuueI+BRed9bnUO6/9my55b4FH+VQIvqMm58h9JGbtaGCkqr3YSDhnmVbM1SJjF//8SURERSypzNwejOk7lA== - dependencies: - decimal.js "^10.0.0" - -"@types/node-fetch@^2.1.2": - version "2.6.2" - resolved "https://registry.yarnpkg.com/@types/node-fetch/-/node-fetch-2.6.2.tgz#d1a9c5fd049d9415dce61571557104dec3ec81da" - integrity sha512-DHqhlq5jeESLy19TYhLakJ07kNumXWjcDdxXsLUMJZ6ue8VZJj4kLPQVE/2mdHh3xZziNF1xppu5lwmS53HR+A== - dependencies: - "@types/node" "*" - form-data "^3.0.0" - -"@types/node@*": - version "18.15.10" - resolved "https://registry.yarnpkg.com/@types/node/-/node-18.15.10.tgz#4ee2171c3306a185d1208dad5f44dae3dee4cfe3" - integrity sha512-9avDaQJczATcXgfmMAW3MIWArOO7A+m90vuCFLr8AotWf8igO/mRoYukrk2cqZVtv38tHs33retzHEilM7FpeQ== - -"@types/node@>=10.0.0": - version "18.11.9" - resolved "https://registry.yarnpkg.com/@types/node/-/node-18.11.9.tgz#02d013de7058cea16d36168ef2fc653464cfbad4" - integrity sha512-CRpX21/kGdzjOpFsZSkcrXMGIBWMGNIHXXBVFSH+ggkftxg+XYP20TESbh+zFvFj3EQOl5byk0HTRn1IL6hbqg== - -"@types/offscreencanvas@~2019.3.0": - version "2019.3.0" - resolved "https://registry.yarnpkg.com/@types/offscreencanvas/-/offscreencanvas-2019.3.0.tgz#3336428ec7e9180cf4566dfea5da04eb586a6553" - integrity sha512-esIJx9bQg+QYF0ra8GnvfianIY8qWB0GBx54PK5Eps6m+xTj86KLavHv6qDhzKcu5UUOgNfJ2pWaIIV7TRUd9Q== - -"@types/offscreencanvas@~2019.7.0": - version "2019.7.0" - resolved "https://registry.yarnpkg.com/@types/offscreencanvas/-/offscreencanvas-2019.7.0.tgz#e4a932069db47bb3eabeb0b305502d01586fa90d" - integrity sha512-PGcyveRIpL1XIqK8eBsmRBt76eFgtzuPiSTyKHZxnGemp2yzGzWpjYKAfK3wIMiU7eH+851yEpiuP8JZerTmWg== - -"@types/seedrandom@^2.4.28": - version "2.4.30" - resolved "https://registry.yarnpkg.com/@types/seedrandom/-/seedrandom-2.4.30.tgz#d2efe425869b84163c2d56e779dddadb9372cbfa" - integrity sha512-AnxLHewubLVzoF/A4qdxBGHCKifw8cY32iro3DQX9TPcetE95zBeVt3jnsvtvAUf1vwzMfwzp4t/L2yqPlnjkQ== - -"@webgpu/types@0.1.30": - version "0.1.30" - resolved "https://registry.yarnpkg.com/@webgpu/types/-/types-0.1.30.tgz#b6406dc4a1c1e0d469028ceb30ddffbbd2fa706c" - integrity sha512-9AXJSmL3MzY8ZL//JjudA//q+2kBRGhLBFpkdGksWIuxrMy81nFrCzj2Am+mbh8WoU6rXmv7cY5E3rdlyru2Qg== - -abbrev@1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/abbrev/-/abbrev-1.1.1.tgz#f8f2c887ad10bf67f634f005b6987fed3179aac8" - integrity sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q== - -accepts@~1.3.4: - version "1.3.8" - resolved "https://registry.yarnpkg.com/accepts/-/accepts-1.3.8.tgz#0bf0be125b67014adcb0b0921e62db7bffe16b2e" - integrity sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw== - dependencies: - mime-types "~2.1.34" - negotiator "0.6.3" - -acorn-walk@^8.0.2, acorn-walk@^8.1.1: - version "8.2.0" - resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-8.2.0.tgz#741210f2e2426454508853a2f44d0ab83b7f69c1" - integrity sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA== - -acorn@^8.1.0: - version "8.7.0" - resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.7.0.tgz#90951fde0f8f09df93549481e5fc141445b791cf" - integrity sha512-V/LGr1APy+PXIwKebEWrkZPwoeoF+w1jiOBUmuxuiUIaOHtob8Qc9BTrYo7VuI5fR8tqsy+buA2WFooR5olqvQ== - -acorn@^8.4.1: - version "8.8.2" - resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.8.2.tgz#1b2f25db02af965399b9776b0c2c391276d37c4a" - integrity sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw== - -adm-zip@^0.5.2: - version "0.5.9" - resolved "https://registry.yarnpkg.com/adm-zip/-/adm-zip-0.5.9.tgz#b33691028333821c0cf95c31374c5462f2905a83" - integrity sha512-s+3fXLkeeLjZ2kLjCBwQufpI5fuN+kIGBxu6530nVQZGVol0d7Y/M88/xw9HGGUcJjKf8LutN3VPRUBq6N7Ajg== - -agent-base@5: - version "5.1.1" - resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-5.1.1.tgz#e8fb3f242959db44d63be665db7a8e739537a32c" - integrity sha512-TMeqbNl2fMW0nMjTEPOwe3J/PRFP4vqeoNuQMG0HlMrtm5QxKqdvAkZ1pRBQ/ulIyDD5Yq0nJ7YbdD8ey0TO3g== - -agent-base@6: - version "6.0.2" - resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-6.0.2.tgz#49fff58577cfee3f37176feab4c22e00f86d7f77" - integrity sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ== - dependencies: - debug "4" - -agent-base@^4.3.0: - version "4.3.0" - resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-4.3.0.tgz#8165f01c436009bccad0b1d122f05ed770efc6ee" - integrity sha512-salcGninV0nPrwpGNn4VTXBb1SOuXQBiqbrNXoeizJsHrsL6ERFM2Ne3JUSBWRE6aeNJI2ROP/WEEIDUiDe3cg== - dependencies: - es6-promisify "^5.0.0" - -ajv@^6.12.3: - version "6.12.6" - resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.6.tgz#baf5a62e802b07d977034586f8c3baf5adf26df4" - integrity sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g== - dependencies: - fast-deep-equal "^3.1.1" - fast-json-stable-stringify "^2.0.0" - json-schema-traverse "^0.4.1" - uri-js "^4.2.2" - -ansi-regex@^5.0.1: - version "5.0.1" - resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.1.tgz#082cb2c89c9fe8659a311a53bd6a4dc5301db304" - integrity sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ== - -ansi-styles@^3.2.1: - version "3.2.1" - resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d" - integrity sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA== - dependencies: - color-convert "^1.9.0" - -ansi-styles@^4.0.0, ansi-styles@^4.1.0: - version "4.3.0" - resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-4.3.0.tgz#edd803628ae71c04c85ae7a0906edad34b648937" - integrity sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg== - dependencies: - color-convert "^2.0.1" - -any-promise@^1.3.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/any-promise/-/any-promise-1.3.0.tgz#abc6afeedcea52e809cdc0376aed3ce39635d17f" - integrity sha1-q8av7tzqUugJzcA3au0845Y10X8= - -anymatch@~3.1.2: - version "3.1.2" - resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-3.1.2.tgz#c0557c096af32f106198f4f4e2a383537e378716" - integrity sha512-P43ePfOAIupkguHUycrc4qJ9kz8ZiuOUijaETwX7THt0Y/GNK7v0aa8rY816xWjZ7rJdA5XdMcpVFTKMq+RvWg== - dependencies: - normalize-path "^3.0.0" - picomatch "^2.0.4" - -"aproba@^1.0.3 || ^2.0.0": - version "2.0.0" - resolved "https://registry.yarnpkg.com/aproba/-/aproba-2.0.0.tgz#52520b8ae5b569215b354efc0caa3fe1e45a8adc" - integrity sha512-lYe4Gx7QT+MKGbDsA+Z+he/Wtef0BiwDOlK/XkBrdfsh9J/jPPXbX0tE9x9cl27Tmu5gg3QUbUrQYa/y+KOHPQ== - -are-we-there-yet@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/are-we-there-yet/-/are-we-there-yet-2.0.0.tgz#372e0e7bd279d8e94c653aaa1f67200884bf3e1c" - integrity sha512-Ci/qENmwHnsYo9xKIcUJN5LeDKdJ6R1Z1j9V/J5wyq8nh/mYPEpIKJbBZXtZjG04HiK7zV/p6Vs9952MrMeUIw== - dependencies: - delegates "^1.0.0" - readable-stream "^3.6.0" - -arg@^4.1.0: - version "4.1.3" - resolved "https://registry.yarnpkg.com/arg/-/arg-4.1.3.tgz#269fc7ad5b8e42cb63c896d5666017261c144089" - integrity sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA== - -argparse@^1.0.10, argparse@^1.0.7: - version "1.0.10" - resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911" - integrity sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg== - dependencies: - sprintf-js "~1.0.2" - -asn1.js@^5.2.0: - version "5.4.1" - resolved "https://registry.yarnpkg.com/asn1.js/-/asn1.js-5.4.1.tgz#11a980b84ebb91781ce35b0fdc2ee294e3783f07" - integrity sha512-+I//4cYPccV8LdmBLiX8CYvf9Sp3vQsrqu2QNXRcrbiWvcx/UdlFiqUJJzxRQxgsZmvhXhn4cSKeSmoFjVdupA== - dependencies: - bn.js "^4.0.0" - inherits "^2.0.1" - minimalistic-assert "^1.0.0" - safer-buffer "^2.1.0" - -asn1@~0.2.3: - version "0.2.6" - resolved "https://registry.yarnpkg.com/asn1/-/asn1-0.2.6.tgz#0d3a7bb6e64e02a90c0303b31f292868ea09a08d" - integrity sha512-ix/FxPn0MDjeyJ7i/yoHGFt/EX6LyNbxSEhPPXODPL+KB0VPk86UYfL0lMdy+KCnv+fmvIzySwaK5COwqVbWTQ== - dependencies: - safer-buffer "~2.1.0" - -assert-plus@1.0.0, assert-plus@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/assert-plus/-/assert-plus-1.0.0.tgz#f12e0f3c5d77b0b1cdd9146942e4e96c1e4dd525" - integrity sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU= - -assert@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/assert/-/assert-2.0.0.tgz#95fc1c616d48713510680f2eaf2d10dd22e02d32" - integrity sha512-se5Cd+js9dXJnu6Ag2JFc00t+HmHOen+8Q+L7O9zI0PqQXr20uk2J0XQqMxZEeo5U50o8Nvmmx7dZrl+Ufr35A== - dependencies: - es6-object-assign "^1.1.0" - is-nan "^1.2.1" - object-is "^1.0.1" - util "^0.12.0" - -async@^1.5.2: - version "1.5.2" - resolved "https://registry.yarnpkg.com/async/-/async-1.5.2.tgz#ec6a61ae56480c0c3cb241c95618e20892f9672a" - integrity sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo= - -async@^3.0.1: - version "3.2.3" - resolved "https://registry.yarnpkg.com/async/-/async-3.2.3.tgz#ac53dafd3f4720ee9e8a160628f18ea91df196c9" - integrity sha512-spZRyzKL5l5BZQrr/6m/SqFdBN0q3OCI0f9rjfBzCMBIP4p75P620rR3gTmaksNOhmzgdxcaxdNfMy6anrbM0g== - -asynckit@^0.4.0: - version "0.4.0" - resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" - integrity sha1-x57Zf380y48robyXkLzDZkdLS3k= - -available-typed-arrays@^1.0.5: - version "1.0.5" - resolved "https://registry.yarnpkg.com/available-typed-arrays/-/available-typed-arrays-1.0.5.tgz#92f95616501069d07d10edb2fc37d3e1c65123b7" - integrity sha512-DMD0KiN46eipeziST1LPP/STfDU0sufISXmjSgvVsoU2tqxctQeASejWcfNtxYKqETM1UxQ8sp2OrSBWpHY6sw== - -aws-sign2@~0.7.0: - version "0.7.0" - resolved "https://registry.yarnpkg.com/aws-sign2/-/aws-sign2-0.7.0.tgz#b46e890934a9591f2d2f6f86d7e6a9f1b3fe76a8" - integrity sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg= - -aws4@^1.8.0: - version "1.11.0" - resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.11.0.tgz#d61f46d83b2519250e2784daf5b09479a8b41c59" - integrity sha512-xh1Rl34h6Fi1DC2WWKfxUTVqRsNnr6LsKz2+hfwDxQJWmrx8+c7ylaqBMcHfl1U1r2dsifOvKX3LQuLNZ+XSvA== - -babel-plugin-dynamic-import-node@^2.3.3: - version "2.3.3" - resolved "https://registry.yarnpkg.com/babel-plugin-dynamic-import-node/-/babel-plugin-dynamic-import-node-2.3.3.tgz#84fda19c976ec5c6defef57f9427b3def66e17a3" - integrity sha512-jZVI+s9Zg3IqA/kdi0i6UDCybUI3aSBLnglhYbSSjKlV7yF1F/5LWv8MakQmvYpnbJDS6fcBL2KzHSxNCMtWSQ== - dependencies: - object.assign "^4.1.0" - -babel-plugin-polyfill-corejs2@^0.3.0: - version "0.3.1" - resolved "https://registry.yarnpkg.com/babel-plugin-polyfill-corejs2/-/babel-plugin-polyfill-corejs2-0.3.1.tgz#440f1b70ccfaabc6b676d196239b138f8a2cfba5" - integrity sha512-v7/T6EQcNfVLfcN2X8Lulb7DjprieyLWJK/zOWH5DUYcAgex9sP3h25Q+DLsX9TloXe3y1O8l2q2Jv9q8UVB9w== - dependencies: - "@babel/compat-data" "^7.13.11" - "@babel/helper-define-polyfill-provider" "^0.3.1" - semver "^6.1.1" - -babel-plugin-polyfill-corejs3@^0.5.0: - version "0.5.2" - resolved "https://registry.yarnpkg.com/babel-plugin-polyfill-corejs3/-/babel-plugin-polyfill-corejs3-0.5.2.tgz#aabe4b2fa04a6e038b688c5e55d44e78cd3a5f72" - integrity sha512-G3uJih0XWiID451fpeFaYGVuxHEjzKTHtc9uGFEjR6hHrvNzeS/PX+LLLcetJcytsB5m4j+K3o/EpXJNb/5IEQ== - dependencies: - "@babel/helper-define-polyfill-provider" "^0.3.1" - core-js-compat "^3.21.0" - -babel-plugin-polyfill-regenerator@^0.3.0: - version "0.3.1" - resolved "https://registry.yarnpkg.com/babel-plugin-polyfill-regenerator/-/babel-plugin-polyfill-regenerator-0.3.1.tgz#2c0678ea47c75c8cc2fbb1852278d8fb68233990" - integrity sha512-Y2B06tvgHYt1x0yz17jGkGeeMr5FeKUu+ASJ+N6nB5lQ8Dapfg42i0OVrf8PNGJ3zKL4A23snMi1IRwrqqND7A== - dependencies: - "@babel/helper-define-polyfill-provider" "^0.3.1" - -balanced-match@^1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee" - integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw== - -base64-js@^1.3.1: - version "1.5.1" - resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a" - integrity sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA== - -base64id@2.0.0, base64id@~2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/base64id/-/base64id-2.0.0.tgz#2770ac6bc47d312af97a8bf9a634342e0cd25cb6" - integrity sha512-lGe34o6EHj9y3Kts9R4ZYs/Gr+6N7MCaMlIFA3F1R2O5/m7K06AxfSeO5530PEERE6/WyEg3lsuyw4GHlPZHog== - -bcrypt-pbkdf@^1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz#a4301d389b6a43f9b67ff3ca11a3f6637e360e9e" - integrity sha1-pDAdOJtqQ/m2f/PKEaP2Y342Dp4= - dependencies: - tweetnacl "^0.14.3" - -binary-extensions@^2.0.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.2.0.tgz#75f502eeaf9ffde42fc98829645be4ea76bd9e2d" - integrity sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA== - -bn.js@^4.0.0, bn.js@^4.1.0, bn.js@^4.11.9: - version "4.12.0" - resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-4.12.0.tgz#775b3f278efbb9718eec7361f483fb36fbbfea88" - integrity sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA== - -bn.js@^5.0.0, bn.js@^5.1.1: - version "5.2.0" - resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-5.2.0.tgz#358860674396c6997771a9d051fcc1b57d4ae002" - integrity sha512-D7iWRBvnZE8ecXiLj/9wbxH7Tk79fAh8IHaTNq1RWRixsS02W+5qS+iE9yq6RYl0asXx5tw0bLhmT5pIfbSquw== - -body-parser@^1.19.0: - version "1.19.2" - resolved "https://registry.yarnpkg.com/body-parser/-/body-parser-1.19.2.tgz#4714ccd9c157d44797b8b5607d72c0b89952f26e" - integrity sha512-SAAwOxgoCKMGs9uUAUFHygfLAyaniaoun6I8mFY9pRAJL9+Kec34aU+oIjDhTycub1jozEfEwx1W1IuOYxVSFw== - dependencies: - bytes "3.1.2" - content-type "~1.0.4" - debug "2.6.9" - depd "~1.1.2" - http-errors "1.8.1" - iconv-lite "0.4.24" - on-finished "~2.3.0" - qs "6.9.7" - raw-body "2.4.3" - type-is "~1.6.18" - -brace-expansion@^1.1.7: - version "1.1.11" - resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" - integrity sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA== - dependencies: - balanced-match "^1.0.0" - concat-map "0.0.1" - -braces@^3.0.2, braces@~3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107" - integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A== - dependencies: - fill-range "^7.0.1" - -brorand@^1.0.1, brorand@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/brorand/-/brorand-1.1.0.tgz#12c25efe40a45e3c323eb8675a0a0ce57b22371f" - integrity sha1-EsJe/kCkXjwyPrhnWgoM5XsiNx8= - -browser-resolve@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/browser-resolve/-/browser-resolve-2.0.0.tgz#99b7304cb392f8d73dba741bb2d7da28c6d7842b" - integrity sha512-7sWsQlYL2rGLy2IWm8WL8DCTJvYLc/qlOnsakDac87SOoCd16WLsaAMdCiAqsTNHIe+SXfaqyxyo6THoWqs8WQ== - dependencies: - resolve "^1.17.0" - -browserify-aes@^1.0.0, browserify-aes@^1.0.4: - version "1.2.0" - resolved "https://registry.yarnpkg.com/browserify-aes/-/browserify-aes-1.2.0.tgz#326734642f403dabc3003209853bb70ad428ef48" - integrity sha512-+7CHXqGuspUn/Sl5aO7Ea0xWGAtETPXNSAjHo48JfLdPWcMng33Xe4znFvQweqc/uzk5zSOI3H52CYnjCfb5hA== - dependencies: - buffer-xor "^1.0.3" - cipher-base "^1.0.0" - create-hash "^1.1.0" - evp_bytestokey "^1.0.3" - inherits "^2.0.1" - safe-buffer "^5.0.1" - -browserify-cipher@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/browserify-cipher/-/browserify-cipher-1.0.1.tgz#8d6474c1b870bfdabcd3bcfcc1934a10e94f15f0" - integrity sha512-sPhkz0ARKbf4rRQt2hTpAHqn47X3llLkUGn+xEJzLjwY8LRs2p0v7ljvI5EyoRO/mexrNunNECisZs+gw2zz1w== - dependencies: - browserify-aes "^1.0.4" - browserify-des "^1.0.0" - evp_bytestokey "^1.0.0" - -browserify-des@^1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/browserify-des/-/browserify-des-1.0.2.tgz#3af4f1f59839403572f1c66204375f7a7f703e9c" - integrity sha512-BioO1xf3hFwz4kc6iBhI3ieDFompMhrMlnDFC4/0/vd5MokpuAc3R+LYbwTA9A5Yc9pq9UYPqffKpW2ObuwX5A== - dependencies: - cipher-base "^1.0.1" - des.js "^1.0.0" - inherits "^2.0.1" - safe-buffer "^5.1.2" - -browserify-rsa@^4.0.0, browserify-rsa@^4.0.1: - version "4.1.0" - resolved "https://registry.yarnpkg.com/browserify-rsa/-/browserify-rsa-4.1.0.tgz#b2fd06b5b75ae297f7ce2dc651f918f5be158c8d" - integrity sha512-AdEER0Hkspgno2aR97SAf6vi0y0k8NuOpGnVH3O99rcA5Q6sh8QxcngtHuJ6uXwnfAXNM4Gn1Gb7/MV1+Ymbog== - dependencies: - bn.js "^5.0.0" - randombytes "^2.0.1" - -browserify-sign@^4.0.0: - version "4.2.1" - resolved "https://registry.yarnpkg.com/browserify-sign/-/browserify-sign-4.2.1.tgz#eaf4add46dd54be3bb3b36c0cf15abbeba7956c3" - integrity sha512-/vrA5fguVAKKAVTNJjgSm1tRQDHUU6DbwO9IROu/0WAzC8PKhucDSh18J0RMvVeHAn5puMd+QHC2erPRNf8lmg== - dependencies: - bn.js "^5.1.1" - browserify-rsa "^4.0.1" - create-hash "^1.2.0" - create-hmac "^1.1.7" - elliptic "^6.5.3" - inherits "^2.0.4" - parse-asn1 "^5.1.5" - readable-stream "^3.6.0" - safe-buffer "^5.2.0" - -browserify-zlib@^0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/browserify-zlib/-/browserify-zlib-0.2.0.tgz#2869459d9aa3be245fe8fe2ca1f46e2e7f54d73f" - integrity sha512-Z942RysHXmJrhqk88FmKBVq/v5tqmSkDz7p54G/MGyjMnCFFnC79XWNbg+Vta8W6Wb2qtSZTSxIGkJrRpCFEiA== - dependencies: - pako "~1.0.5" - -browserslist@^4.17.5, browserslist@^4.19.1: - version "4.20.2" - resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.20.2.tgz#567b41508757ecd904dab4d1c646c612cd3d4f88" - integrity sha512-CQOBCqp/9pDvDbx3xfMi+86pr4KXIf2FDkTTdeuYw8OxS9t898LA1Khq57gtufFILXpfgsSx5woNgsBgvGjpsA== - dependencies: - caniuse-lite "^1.0.30001317" - electron-to-chromium "^1.4.84" - escalade "^3.1.1" - node-releases "^2.0.2" - picocolors "^1.0.0" - -browserstack-local@^1.3.7: - version "1.4.9" - resolved "https://registry.yarnpkg.com/browserstack-local/-/browserstack-local-1.4.9.tgz#5d3e405d425ee5a3ec5cba853c9a078242d944db" - integrity sha512-V+q8HQwRQFr9nd32xR66ZZ3VDWa3Kct4IMMudhKgcuD7cWrvvFARZOibx71II+Rf7P5nMQpWWxl9z/3p927nbg== - dependencies: - https-proxy-agent "^4.0.0" - is-running "^2.1.0" - ps-tree "=1.2.0" - temp-fs "^0.9.9" - -browserstack@~1.5.1: - version "1.5.3" - resolved "https://registry.yarnpkg.com/browserstack/-/browserstack-1.5.3.tgz#93ab48799a12ef99dbd074dd595410ddb196a7ac" - integrity sha512-AO+mECXsW4QcqC9bxwM29O7qWa7bJT94uBFzeb5brylIQwawuEziwq20dPYbins95GlWzOawgyDNdjYAo32EKg== - dependencies: - https-proxy-agent "^2.2.1" - -buffer-xor@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/buffer-xor/-/buffer-xor-1.0.3.tgz#26e61ed1422fb70dd42e6e36729ed51d855fe8d9" - integrity sha1-JuYe0UIvtw3ULm42cp7VHYVf6Nk= - -buffer@^5.4.3: - version "5.7.1" - resolved "https://registry.yarnpkg.com/buffer/-/buffer-5.7.1.tgz#ba62e7c13133053582197160851a8f648e99eed0" - integrity sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ== - dependencies: - base64-js "^1.3.1" - ieee754 "^1.1.13" - -builtin-modules@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/builtin-modules/-/builtin-modules-1.1.1.tgz#270f076c5a72c02f5b65a47df94c5fe3a278892f" - integrity sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8= - -builtin-status-codes@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz#85982878e21b98e1c66425e03d0174788f569ee8" - integrity sha1-hZgoeOIbmOHGZCXgPQF0eI9Wnug= - -bytes@3.1.2: - version "3.1.2" - resolved "https://registry.yarnpkg.com/bytes/-/bytes-3.1.2.tgz#8b0beeb98605adf1b128fa4386403c009e0221a5" - integrity sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg== - -call-bind@^1.0.0, call-bind@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/call-bind/-/call-bind-1.0.2.tgz#b1d4e89e688119c3c9a903ad30abb2f6a919be3c" - integrity sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA== - dependencies: - function-bind "^1.1.1" - get-intrinsic "^1.0.2" - -caniuse-lite@^1.0.30001317: - version "1.0.30001320" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001320.tgz#8397391bec389b8ccce328636499b7284ee13285" - integrity sha512-MWPzG54AGdo3nWx7zHZTefseM5Y1ccM7hlQKHRqJkPozUaw3hNbBTMmLn16GG2FUzjR13Cr3NPfhIieX5PzXDA== - -caseless@~0.12.0: - version "0.12.0" - resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.12.0.tgz#1b681c21ff84033c826543090689420d187151dc" - integrity sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw= - -chalk@^2.0.0, chalk@^2.3.0: - version "2.4.2" - resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" - integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ== - dependencies: - ansi-styles "^3.2.1" - escape-string-regexp "^1.0.5" - supports-color "^5.3.0" - -chalk@^4.1.0: - version "4.1.2" - resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01" - integrity sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA== - dependencies: - ansi-styles "^4.1.0" - supports-color "^7.1.0" - -chokidar@^3.5.1: - version "3.5.3" - resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.5.3.tgz#1cf37c8707b932bd1af1ae22c0432e2acd1903bd" - integrity sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw== - dependencies: - anymatch "~3.1.2" - braces "~3.0.2" - glob-parent "~5.1.2" - is-binary-path "~2.1.0" - is-glob "~4.0.1" - normalize-path "~3.0.0" - readdirp "~3.6.0" - optionalDependencies: - fsevents "~2.3.2" - -chownr@^1.1.4: - version "1.1.4" - resolved "https://registry.yarnpkg.com/chownr/-/chownr-1.1.4.tgz#6fc9d7b42d32a583596337666e7d08084da2cc6b" - integrity sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg== - -chownr@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/chownr/-/chownr-2.0.0.tgz#15bfbe53d2eab4cf70f18a8cd68ebe5b3cb1dece" - integrity sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ== - -cipher-base@^1.0.0, cipher-base@^1.0.1, cipher-base@^1.0.3: - version "1.0.4" - resolved "https://registry.yarnpkg.com/cipher-base/-/cipher-base-1.0.4.tgz#8760e4ecc272f4c363532f926d874aae2c1397de" - integrity sha512-Kkht5ye6ZGmwv40uUDZztayT2ThLQGfnj/T71N/XzeZeo3nf8foyW7zGTsPYkEya3m5f3cAypH+qe7YOrM1U2Q== - dependencies: - inherits "^2.0.1" - safe-buffer "^5.0.1" - -clang-format@~1.2.4: - version "1.2.4" - resolved "https://registry.yarnpkg.com/clang-format/-/clang-format-1.2.4.tgz#4bb4b0a98180428deb093cf20982e9fc1af20b6c" - integrity sha512-sw+nrGUp3hvmANd1qF8vZPuezSYQAiXgGBiEtkXTtJnnu6b00fCqkkDIsnRKrNgg4nv6NYZE92ejvOMIXZoejw== - dependencies: - async "^1.5.2" - glob "^7.0.0" - resolve "^1.1.6" - -cliui@^7.0.2: - version "7.0.4" - resolved "https://registry.yarnpkg.com/cliui/-/cliui-7.0.4.tgz#a0265ee655476fc807aea9df3df8df7783808b4f" - integrity sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ== - dependencies: - string-width "^4.2.0" - strip-ansi "^6.0.0" - wrap-ansi "^7.0.0" - -clone@^1.0.2: - version "1.0.4" - resolved "https://registry.yarnpkg.com/clone/-/clone-1.0.4.tgz#da309cc263df15994c688ca902179ca3c7cd7c7e" - integrity sha1-2jCcwmPfFZlMaIypAheco8fNfH4= - -color-convert@^1.9.0: - version "1.9.3" - resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8" - integrity sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg== - dependencies: - color-name "1.1.3" - -color-convert@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-2.0.1.tgz#72d3a68d598c9bdb3af2ad1e84f21d896abd4de3" - integrity sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ== - dependencies: - color-name "~1.1.4" - -color-name@1.1.3: - version "1.1.3" - resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25" - integrity sha1-p9BVi9icQveV3UIyj3QIMcpTvCU= - -color-name@~1.1.4: - version "1.1.4" - resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2" - integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA== - -color-support@^1.1.2: - version "1.1.3" - resolved "https://registry.yarnpkg.com/color-support/-/color-support-1.1.3.tgz#93834379a1cc9a0c61f82f52f0d04322251bd5a2" - integrity sha512-qiBjkpbMLO/HL68y+lh4q0/O1MZFj2RX6X/KmMa3+gJD3z+WwI1ZzDHysvqHGS3mP6mznPckpXmw1nI9cJjyRg== - -colors@1.4.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/colors/-/colors-1.4.0.tgz#c50491479d4c1bdaed2c9ced32cf7c7dc2360f78" - integrity sha512-a+UqTh4kgZg/SlGvfbzDHpgRu7AAQOmmqRHJnxhRZICKFUT91brVhNNt58CMWU9PsBbv3PDCZUHbVxuDiH2mtA== - -combine-source-map@^0.8.0: - version "0.8.0" - resolved "https://registry.yarnpkg.com/combine-source-map/-/combine-source-map-0.8.0.tgz#a58d0df042c186fcf822a8e8015f5450d2d79a8b" - integrity sha1-pY0N8ELBhvz4IqjoAV9UUNLXmos= - dependencies: - convert-source-map "~1.1.0" - inline-source-map "~0.6.0" - lodash.memoize "~3.0.3" - source-map "~0.5.3" - -combined-stream@^1.0.6, combined-stream@^1.0.8, combined-stream@~1.0.6: - version "1.0.8" - resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.8.tgz#c3d45a8b34fd730631a110a8a2520682b31d5a7f" - integrity sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg== - dependencies: - delayed-stream "~1.0.0" - -commander@^2.12.1: - version "2.20.3" - resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33" - integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ== - -complex.js@^2.0.11: - version "2.0.15" - resolved "https://registry.yarnpkg.com/complex.js/-/complex.js-2.0.15.tgz#7add6848b4c1d12aa9262f7df925ebe7a51a7406" - integrity sha512-gDBvQU8IG139ZBQTSo2qvDFP+lANMGluM779csXOr6ny1NUtA3wkUnCFjlDNH/moAVfXtvClYt6G0zarFbtz5w== - -component-emitter@~1.3.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/component-emitter/-/component-emitter-1.3.0.tgz#16e4070fba8ae29b679f2215853ee181ab2eabc0" - integrity sha512-Rd3se6QB+sO1TwqZjscQrurpEPIfO0/yYnSin6Q/rD3mOutHvUrCAhJub3r90uNb+SESBuE0QYoB90YdfatsRg== - -concat-map@0.0.1: - version "0.0.1" - resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" - integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s= - -connect@^3.7.0: - version "3.7.0" - resolved "https://registry.yarnpkg.com/connect/-/connect-3.7.0.tgz#5d49348910caa5e07a01800b030d0c35f20484f8" - integrity sha512-ZqRXc+tZukToSNmh5C2iWMSoV3X1YUcPbqEM4DkEG5tNQXrQUZCNVGGv3IuicnkMtPfGf3Xtp8WCXs295iQ1pQ== - dependencies: - debug "2.6.9" - finalhandler "1.1.2" - parseurl "~1.3.3" - utils-merge "1.0.1" - -console-browserify@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/console-browserify/-/console-browserify-1.2.0.tgz#67063cef57ceb6cf4993a2ab3a55840ae8c49336" - integrity sha512-ZMkYO/LkF17QvCPqM0gxw8yUzigAOZOSWSHg91FH6orS7vcEj5dVZTidN2fQ14yBSdg97RqhSNwLUXInd52OTA== - -console-control-strings@^1.0.0, console-control-strings@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/console-control-strings/-/console-control-strings-1.1.0.tgz#3d7cf4464db6446ea644bf4b39507f9851008e8e" - integrity sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4= - -constants-browserify@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/constants-browserify/-/constants-browserify-1.0.0.tgz#c20b96d8c617748aaf1c16021760cd27fcb8cb75" - integrity sha1-wguW2MYXdIqvHBYCF2DNJ/y4y3U= - -content-type@~1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/content-type/-/content-type-1.0.4.tgz#e138cc75e040c727b1966fe5e5f8c9aee256fe3b" - integrity sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA== - -convert-source-map@^1.1.0, convert-source-map@^1.7.0: - version "1.8.0" - resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.8.0.tgz#f3373c32d21b4d780dd8004514684fb791ca4369" - integrity sha512-+OQdjP49zViI/6i7nIJpA8rAl4sV/JdPfU9nZs3VqOwGIgizICvuN2ru6fMd+4llL0tar18UYJXfZ/TWtmhUjA== - dependencies: - safe-buffer "~5.1.1" - -convert-source-map@~1.1.0: - version "1.1.3" - resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.1.3.tgz#4829c877e9fe49b3161f3bf3673888e204699860" - integrity sha1-SCnId+n+SbMWHzvzZziI4gRpmGA= - -cookie@~0.4.1: - version "0.4.2" - resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.4.2.tgz#0e41f24de5ecf317947c82fc789e06a884824432" - integrity sha512-aSWTXFzaKWkvHO1Ny/s+ePFpvKsPnjc551iI41v3ny/ow6tBG5Vd+FuqGNhh1LxOmVzOlGUriIlOaokOvhaStA== - -core-js-compat@^3.20.2, core-js-compat@^3.21.0: - version "3.21.1" - resolved "https://registry.yarnpkg.com/core-js-compat/-/core-js-compat-3.21.1.tgz#cac369f67c8d134ff8f9bd1623e3bc2c42068c82" - integrity sha512-gbgX5AUvMb8gwxC7FLVWYT7Kkgu/y7+h/h1X43yJkNqhlK2fuYyQimqvKGNZFAY6CKii/GFKJ2cp/1/42TN36g== - dependencies: - browserslist "^4.19.1" - semver "7.0.0" - -core-js@3.29.1: - version "3.29.1" - resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.29.1.tgz#40ff3b41588b091aaed19ca1aa5cb111803fa9a6" - integrity sha512-+jwgnhg6cQxKYIIjGtAHq2nwUOolo9eoFZ4sHfUH09BLXBgxnH4gA0zEd+t+BO2cNB8idaBtZFcFTRjQJRJmAw== - -core-js@^2.6.5: - version "2.6.12" - resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.6.12.tgz#d9333dfa7b065e347cc5682219d6f690859cc2ec" - integrity sha512-Kb2wC0fvsWfQrgk8HU5lW6U/Lcs8+9aaYcy4ZFc6DDlo4nZ7n70dEgE5rtR0oG6ufKDUnrwfWL1mXR5ljDatrQ== - -core-util-is@1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" - integrity sha1-tf1UIgqivFq1eqtxQMlAdUUDwac= - -core-util-is@~1.0.0: - version "1.0.3" - resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.3.tgz#a6042d3634c2b27e9328f837b965fac83808db85" - integrity sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ== - -cors@~2.8.5: - version "2.8.5" - resolved "https://registry.yarnpkg.com/cors/-/cors-2.8.5.tgz#eac11da51592dd86b9f06f6e7ac293b3df875d29" - integrity sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g== - dependencies: - object-assign "^4" - vary "^1" - -create-ecdh@^4.0.0: - version "4.0.4" - resolved "https://registry.yarnpkg.com/create-ecdh/-/create-ecdh-4.0.4.tgz#d6e7f4bffa66736085a0762fd3a632684dabcc4e" - integrity sha512-mf+TCx8wWc9VpuxfP2ht0iSISLZnt0JgWlrOKZiNqyUZWnjIaCIVNQArMHnCZKfEYRg6IM7A+NeJoN8gf/Ws0A== - dependencies: - bn.js "^4.1.0" - elliptic "^6.5.3" - -create-hash@^1.1.0, create-hash@^1.1.2, create-hash@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/create-hash/-/create-hash-1.2.0.tgz#889078af11a63756bcfb59bd221996be3a9ef196" - integrity sha512-z00bCGNHDG8mHAkP7CtT1qVu+bFQUPjYq/4Iv3C3kWjTFV10zIjfSoeqXo9Asws8gwSHDGj/hl2u4OGIjapeCg== - dependencies: - cipher-base "^1.0.1" - inherits "^2.0.1" - md5.js "^1.3.4" - ripemd160 "^2.0.1" - sha.js "^2.4.0" - -create-hmac@^1.1.0, create-hmac@^1.1.4, create-hmac@^1.1.7: - version "1.1.7" - resolved "https://registry.yarnpkg.com/create-hmac/-/create-hmac-1.1.7.tgz#69170c78b3ab957147b2b8b04572e47ead2243ff" - integrity sha512-MJG9liiZ+ogc4TzUwuvbER1JRdgvUFSB5+VR/g5h82fGaIRWMWddtKBHi7/sVhfjQZ6SehlyhvQYrcYkaUIpLg== - dependencies: - cipher-base "^1.0.3" - create-hash "^1.1.0" - inherits "^2.0.1" - ripemd160 "^2.0.0" - safe-buffer "^5.0.1" - sha.js "^2.4.8" - -create-require@^1.1.0: - version "1.1.1" - resolved "https://registry.yarnpkg.com/create-require/-/create-require-1.1.1.tgz#c1d7e8f1e5f6cfc9ff65f9cd352d37348756c333" - integrity sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ== - -crypto-browserify@^3.12.0: - version "3.12.0" - resolved "https://registry.yarnpkg.com/crypto-browserify/-/crypto-browserify-3.12.0.tgz#396cf9f3137f03e4b8e532c58f698254e00f80ec" - integrity sha512-fz4spIh+znjO2VjL+IdhEpRJ3YN6sMzITSBijk6FK2UvTqruSQW+/cCZTSNsMiZNvUeq0CqurF+dAbyiGOY6Wg== - dependencies: - browserify-cipher "^1.0.0" - browserify-sign "^4.0.0" - create-ecdh "^4.0.0" - create-hash "^1.1.0" - create-hmac "^1.1.0" - diffie-hellman "^5.0.0" - inherits "^2.0.1" - pbkdf2 "^3.0.3" - public-encrypt "^4.0.0" - randombytes "^2.0.0" - randomfill "^1.0.3" - -custom-event@~1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/custom-event/-/custom-event-1.0.1.tgz#5d02a46850adf1b4a317946a3928fccb5bfd0425" - integrity sha1-XQKkaFCt8bSjF5RqOSj8y1v9BCU= - -dashdash@^1.12.0: - version "1.14.1" - resolved "https://registry.yarnpkg.com/dashdash/-/dashdash-1.14.1.tgz#853cfa0f7cbe2fed5de20326b8dd581035f6e2f0" - integrity sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA= - dependencies: - assert-plus "^1.0.0" - -date-format@^4.0.6: - version "4.0.6" - resolved "https://registry.yarnpkg.com/date-format/-/date-format-4.0.6.tgz#f6138b8f17968df9815b3d101fc06b0523f066c5" - integrity sha512-B9vvg5rHuQ8cbUXE/RMWMyX2YA5TecT3jKF5fLtGNlzPlU7zblSPmAm2OImDbWL+LDOQ6pUm+4LOFz+ywS41Zw== - -debug@2.6.9: - version "2.6.9" - resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" - integrity sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA== - dependencies: - ms "2.0.0" - -debug@4, debug@^4.1.0, debug@^4.1.1, debug@^4.3.4, debug@~4.3.1, debug@~4.3.2: - version "4.3.4" - resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865" - integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ== - dependencies: - ms "2.1.2" - -debug@^3.1.0: - version "3.2.7" - resolved "https://registry.yarnpkg.com/debug/-/debug-3.2.7.tgz#72580b7e9145fb39b6676f9c5e5fb100b934179a" - integrity sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ== - dependencies: - ms "^2.1.1" - -decimal.js@^10.0.0, decimal.js@^10.2.1: - version "10.3.1" - resolved "https://registry.yarnpkg.com/decimal.js/-/decimal.js-10.3.1.tgz#d8c3a444a9c6774ba60ca6ad7261c3a94fd5e783" - integrity sha512-V0pfhfr8suzyPGOx3nmq4aHqabehUZn6Ch9kyFpV79TGDTWFmHqUqXdabR7QHqxzrYolF4+tVmJhUG4OURg5dQ== - -defaults@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/defaults/-/defaults-1.0.3.tgz#c656051e9817d9ff08ed881477f3fe4019f3ef7d" - integrity sha1-xlYFHpgX2f8I7YgUd/P+QBnz730= - dependencies: - clone "^1.0.2" - -define-properties@^1.1.3: - version "1.1.3" - resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.1.3.tgz#cf88da6cbee26fe6db7094f61d870cbd84cee9f1" - integrity sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ== - dependencies: - object-keys "^1.0.12" - -delayed-stream@~1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" - integrity sha1-3zrhmayt+31ECqrgsp4icrJOxhk= - -delegates@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/delegates/-/delegates-1.0.0.tgz#84c6e159b81904fdca59a0ef44cd870d31250f9a" - integrity sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o= - -depd@~1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/depd/-/depd-1.1.2.tgz#9bcd52e14c097763e749b274c4346ed2e560b5a9" - integrity sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak= - -des.js@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/des.js/-/des.js-1.0.1.tgz#5382142e1bdc53f85d86d53e5f4aa7deb91e0843" - integrity sha512-Q0I4pfFrv2VPd34/vfLrFOoRmlYj3OV50i7fskps1jZWK1kApMWWT9G6RRUeYedLcBDIhnSDaUvJMb3AhUlaEA== - dependencies: - inherits "^2.0.1" - minimalistic-assert "^1.0.0" - -detect-browser@*: - version "5.3.0" - resolved "https://registry.yarnpkg.com/detect-browser/-/detect-browser-5.3.0.tgz#9705ef2bddf46072d0f7265a1fe300e36fe7ceca" - integrity sha512-53rsFbGdwMwlF7qvCt0ypLM5V5/Mbl0szB7GPN8y9NCcbknYOeVVXdrXEq+90IwAfrrzt6Hd+u2E2ntakICU8w== - -detect-browser@~4.2.0: - version "4.2.1" - resolved "https://registry.yarnpkg.com/detect-browser/-/detect-browser-4.2.1.tgz#b48fbd867513a21c57d64e16d897487fda0d5282" - integrity sha512-6+Uo6k9QaiFJXH/eVYnXJ/Kauw4M5wvSDB2jEZ9ngfSsJuTPNKSGG16+cPCreLpBEJeNdQngHRUV6RJGF/vNtQ== - -detect-libc@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/detect-libc/-/detect-libc-2.0.1.tgz#e1897aa88fa6ad197862937fbc0441ef352ee0cd" - integrity sha512-463v3ZeIrcWtdgIg6vI6XUncguvr2TnGl4SzDXinkt9mSLpBJKXT3mW6xT3VQdDN11+WVs29pgvivTc4Lp8v+w== - -di@^0.0.1: - version "0.0.1" - resolved "https://registry.yarnpkg.com/di/-/di-0.0.1.tgz#806649326ceaa7caa3306d75d985ea2748ba913c" - integrity sha1-gGZJMmzqp8qjMG112YXqJ0i6kTw= - -diff@^4.0.1: - version "4.0.2" - resolved "https://registry.yarnpkg.com/diff/-/diff-4.0.2.tgz#60f3aecb89d5fae520c11aa19efc2bb982aade7d" - integrity sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A== - -diffie-hellman@^5.0.0: - version "5.0.3" - resolved "https://registry.yarnpkg.com/diffie-hellman/-/diffie-hellman-5.0.3.tgz#40e8ee98f55a2149607146921c63e1ae5f3d2875" - integrity sha512-kqag/Nl+f3GwyK25fhUMYj81BUOrZ9IuJsjIcDE5icNM9FJHAVm3VcUDxdLPoQtTuUylWm6ZIknYJwwaPxsUzg== - dependencies: - bn.js "^4.1.0" - miller-rabin "^4.0.0" - randombytes "^2.0.0" - -dom-serialize@^2.2.1: - version "2.2.1" - resolved "https://registry.yarnpkg.com/dom-serialize/-/dom-serialize-2.2.1.tgz#562ae8999f44be5ea3076f5419dcd59eb43ac95b" - integrity sha1-ViromZ9Evl6jB29UGdzVnrQ6yVs= - dependencies: - custom-event "~1.0.0" - ent "~2.2.0" - extend "^3.0.0" - void-elements "^2.0.0" - -domain-browser@^4.16.0: - version "4.22.0" - resolved "https://registry.yarnpkg.com/domain-browser/-/domain-browser-4.22.0.tgz#6ddd34220ec281f9a65d3386d267ddd35c491f9f" - integrity sha512-IGBwjF7tNk3cwypFNH/7bfzBcgSCbaMOD3GsaY1AU/JRrnHnYgEM0+9kQt52iZxjNsjBtJYtao146V+f8jFZNw== - -duplexer@~0.1.1: - version "0.1.2" - resolved "https://registry.yarnpkg.com/duplexer/-/duplexer-0.1.2.tgz#3abe43aef3835f8ae077d136ddce0f276b0400e6" - integrity sha512-jtD6YG370ZCIi/9GTaJKQxWTZD045+4R4hTk/x1UyoqadyJ9x9CgSi1RlVDQF8U2sxLLSnFkCaMihqljHIWgMg== - -ecc-jsbn@~0.1.1: - version "0.1.2" - resolved "https://registry.yarnpkg.com/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz#3a83a904e54353287874c564b7549386849a98c9" - integrity sha1-OoOpBOVDUyh4dMVkt1SThoSamMk= - dependencies: - jsbn "~0.1.0" - safer-buffer "^2.1.0" - -ee-first@1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d" - integrity sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0= - -electron-to-chromium@^1.4.84: - version "1.4.94" - resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.94.tgz#f19206c977361264a51d53a7ea7ef861a94baa10" - integrity sha512-CoOKsuACoa0PAG3hQXxbh/XDiFcjGuSyGKUi09cjMHOt6RCi7/EXgXhaFF3I+aC89Omudqmkzd0YOQKxwtf/Bg== - -elliptic@^6.5.3: - version "6.5.4" - resolved "https://registry.yarnpkg.com/elliptic/-/elliptic-6.5.4.tgz#da37cebd31e79a1367e941b592ed1fbebd58abbb" - integrity sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ== - dependencies: - bn.js "^4.11.9" - brorand "^1.1.0" - hash.js "^1.0.0" - hmac-drbg "^1.0.1" - inherits "^2.0.4" - minimalistic-assert "^1.0.1" - minimalistic-crypto-utils "^1.0.1" - -emoji-regex@^8.0.0: - version "8.0.0" - resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37" - integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A== - -encodeurl@~1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/encodeurl/-/encodeurl-1.0.2.tgz#ad3ff4c86ec2d029322f5a02c3a9a606c95b3f59" - integrity sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k= - -engine.io-parser@~5.0.3: - version "5.0.4" - resolved "https://registry.yarnpkg.com/engine.io-parser/-/engine.io-parser-5.0.4.tgz#0b13f704fa9271b3ec4f33112410d8f3f41d0fc0" - integrity sha512-+nVFp+5z1E3HcToEnO7ZIj3g+3k9389DvWtvJZz0T6/eOCPIyyxehFcedoYrZQrp0LgQbD9pPXhpMBKMd5QURg== - -engine.io@~6.2.0: - version "6.2.1" - resolved "https://registry.yarnpkg.com/engine.io/-/engine.io-6.2.1.tgz#e3f7826ebc4140db9bbaa9021ad6b1efb175878f" - integrity sha512-ECceEFcAaNRybd3lsGQKas3ZlMVjN3cyWwMP25D2i0zWfyiytVbTpRPa34qrr+FHddtpBVOmq4H/DCv1O0lZRA== - dependencies: - "@types/cookie" "^0.4.1" - "@types/cors" "^2.8.12" - "@types/node" ">=10.0.0" - accepts "~1.3.4" - base64id "2.0.0" - cookie "~0.4.1" - cors "~2.8.5" - debug "~4.3.1" - engine.io-parser "~5.0.3" - ws "~8.2.3" - -ent@~2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/ent/-/ent-2.2.0.tgz#e964219325a21d05f44466a2f686ed6ce5f5dd1d" - integrity sha1-6WQhkyWiHQX0RGai9obtbOX13R0= - -error-ex@^1.2.0: - version "1.3.2" - resolved "https://registry.yarnpkg.com/error-ex/-/error-ex-1.3.2.tgz#b4ac40648107fdcdcfae242f428bea8a14d4f1bf" - integrity sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g== - dependencies: - is-arrayish "^0.2.1" - -es-abstract@^1.18.5: - version "1.19.1" - resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.19.1.tgz#d4885796876916959de78edaa0df456627115ec3" - integrity sha512-2vJ6tjA/UfqLm2MPs7jxVybLoB8i1t1Jd9R3kISld20sIxPcTbLuggQOUxeWeAvIUkduv/CfMjuh4WmiXr2v9w== - dependencies: - call-bind "^1.0.2" - es-to-primitive "^1.2.1" - function-bind "^1.1.1" - get-intrinsic "^1.1.1" - get-symbol-description "^1.0.0" - has "^1.0.3" - has-symbols "^1.0.2" - internal-slot "^1.0.3" - is-callable "^1.2.4" - is-negative-zero "^2.0.1" - is-regex "^1.1.4" - is-shared-array-buffer "^1.0.1" - is-string "^1.0.7" - is-weakref "^1.0.1" - object-inspect "^1.11.0" - object-keys "^1.1.1" - object.assign "^4.1.2" - string.prototype.trimend "^1.0.4" - string.prototype.trimstart "^1.0.4" - unbox-primitive "^1.0.1" - -es-to-primitive@^1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/es-to-primitive/-/es-to-primitive-1.2.1.tgz#e55cd4c9cdc188bcefb03b366c736323fc5c898a" - integrity sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA== - dependencies: - is-callable "^1.1.4" - is-date-object "^1.0.1" - is-symbol "^1.0.2" - -es6-object-assign@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/es6-object-assign/-/es6-object-assign-1.1.0.tgz#c2c3582656247c39ea107cb1e6652b6f9f24523c" - integrity sha1-wsNYJlYkfDnqEHyx5mUrb58kUjw= - -es6-promise@^4.0.3: - version "4.2.8" - resolved "https://registry.yarnpkg.com/es6-promise/-/es6-promise-4.2.8.tgz#4eb21594c972bc40553d276e510539143db53e0a" - integrity sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w== - -es6-promisify@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/es6-promisify/-/es6-promisify-5.0.0.tgz#5109d62f3e56ea967c4b63505aef08291c8a5203" - integrity sha1-UQnWLz5W6pZ8S2NQWu8IKRyKUgM= - dependencies: - es6-promise "^4.0.3" - -escalade@^3.1.1: - version "3.1.1" - resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.1.1.tgz#d8cfdc7000965c5a0174b4a82eaa5c0552742e40" - integrity sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw== - -escape-html@~1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/escape-html/-/escape-html-1.0.3.tgz#0258eae4d3d0c0974de1c169188ef0051d1d1988" - integrity sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg= - -escape-latex@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/escape-latex/-/escape-latex-1.2.0.tgz#07c03818cf7dac250cce517f4fda1b001ef2bca1" - integrity sha512-nV5aVWW1K0wEiUIEdZ4erkGGH8mDxGyxSeqPzRNtWP7ataw+/olFObw7hujFWlVjNsaDFw5VZ5NzVSIqRgfTiw== - -escape-string-regexp@^1.0.5: - version "1.0.5" - resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" - integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ= - -esprima@^4.0.0: - version "4.0.1" - resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71" - integrity sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A== - -esutils@^2.0.2: - version "2.0.3" - resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.3.tgz#74d2eb4de0b8da1293711910d50775b9b710ef64" - integrity sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g== - -event-stream@=3.3.4: - version "3.3.4" - resolved "https://registry.yarnpkg.com/event-stream/-/event-stream-3.3.4.tgz#4ab4c9a0f5a54db9338b4c34d86bfce8f4b35571" - integrity sha1-SrTJoPWlTbkzi0w02Gv86PSzVXE= - dependencies: - duplexer "~0.1.1" - from "~0" - map-stream "~0.1.0" - pause-stream "0.0.11" - split "0.3" - stream-combiner "~0.0.4" - through "~2.3.1" - -eventemitter3@^4.0.0: - version "4.0.7" - resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-4.0.7.tgz#2de9b68f6528d5644ef5c59526a1b4a07306169f" - integrity sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw== - -events@^3.2.0: - version "3.3.0" - resolved "https://registry.yarnpkg.com/events/-/events-3.3.0.tgz#31a95ad0a924e2d2c419a813aeb2c4e878ea7400" - integrity sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q== - -evp_bytestokey@^1.0.0, evp_bytestokey@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/evp_bytestokey/-/evp_bytestokey-1.0.3.tgz#7fcbdb198dc71959432efe13842684e0525acb02" - integrity sha512-/f2Go4TognH/KvCISP7OUsHn85hT9nUkxxA9BEWxFn+Oj9o8ZNLm/40hdlgSLyuOimsrTKLUMEorQexp/aPQeA== - dependencies: - md5.js "^1.3.4" - safe-buffer "^5.1.1" - -extend@^3.0.0, extend@~3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.2.tgz#f8b1136b4071fbd8eb140aff858b1019ec2915fa" - integrity sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g== - -extsprintf@1.3.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.3.0.tgz#96918440e3041a7a414f8c52e3c574eb3c3e1e05" - integrity sha1-lpGEQOMEGnpBT4xS48V06zw+HgU= - -extsprintf@^1.2.0: - version "1.4.1" - resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.4.1.tgz#8d172c064867f235c0c84a596806d279bf4bcc07" - integrity sha512-Wrk35e8ydCKDj/ArClo1VrPVmN8zph5V4AtHwIuHhvMXsKf73UT3BOD+azBIW+3wOJ4FhEH7zyaJCFvChjYvMA== - -fast-deep-equal@^3.1.1: - version "3.1.3" - resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525" - integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q== - -fast-json-stable-stringify@^2.0.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz#874bf69c6f404c2b5d99c481341399fd55892633" - integrity sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw== - -fill-range@^7.0.1: - version "7.0.1" - resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.0.1.tgz#1919a6a7c75fe38b2c7c77e5198535da9acdda40" - integrity sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ== - dependencies: - to-regex-range "^5.0.1" - -finalhandler@1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/finalhandler/-/finalhandler-1.1.2.tgz#b7e7d000ffd11938d0fdb053506f6ebabe9f587d" - integrity sha512-aAWcW57uxVNrQZqFXjITpW3sIUQmHGG3qSb9mUah9MgMC4NeWhNOlNjXEYq3HjRAvL6arUviZGGJsBg6z0zsWA== - dependencies: - debug "2.6.9" - encodeurl "~1.0.2" - escape-html "~1.0.3" - on-finished "~2.3.0" - parseurl "~1.3.3" - statuses "~1.5.0" - unpipe "~1.0.0" - -flatted@^3.2.5: - version "3.2.5" - resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.2.5.tgz#76c8584f4fc843db64702a6bd04ab7a8bd666da3" - integrity sha512-WIWGi2L3DyTUvUrwRKgGi9TwxQMUEqPOPQBVi71R96jZXJdFskXEmf54BoZaS1kknGODoIGASGEzBUYdyMCBJg== - -follow-redirects@^1.0.0: - version "1.14.9" - resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.9.tgz#dd4ea157de7bfaf9ea9b3fbd85aa16951f78d8d7" - integrity sha512-MQDfihBQYMcyy5dhRDJUHcw7lb2Pv/TuE6xP1vyraLukNDHKbDxDNaOE3NbCAdKQApno+GPRyo1YAp89yCjK4w== - -foreach@^2.0.5: - version "2.0.5" - resolved "https://registry.yarnpkg.com/foreach/-/foreach-2.0.5.tgz#0bee005018aeb260d0a3af3ae658dd0136ec1b99" - integrity sha1-C+4AUBiusmDQo6865ljdATbsG5k= - -forever-agent@~0.6.1: - version "0.6.1" - resolved "https://registry.yarnpkg.com/forever-agent/-/forever-agent-0.6.1.tgz#fbc71f0c41adeb37f96c577ad1ed42d8fdacca91" - integrity sha1-+8cfDEGt6zf5bFd60e1C2P2sypE= - -form-data@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/form-data/-/form-data-3.0.1.tgz#ebd53791b78356a99af9a300d4282c4d5eb9755f" - integrity sha512-RHkBKtLWUVwd7SqRIvCZMEvAMoGUp0XU+seQiZejj0COz3RI3hWP4sCv3gZWWLjJTd7rGwcsF5eKZGii0r/hbg== - dependencies: - asynckit "^0.4.0" - combined-stream "^1.0.8" - mime-types "^2.1.12" - -form-data@~2.3.2: - version "2.3.3" - resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.3.3.tgz#dcce52c05f644f298c6a7ab936bd724ceffbf3a6" - integrity sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ== - dependencies: - asynckit "^0.4.0" - combined-stream "^1.0.6" - mime-types "^2.1.12" - -fraction.js@^4.0.12: - version "4.2.0" - resolved "https://registry.yarnpkg.com/fraction.js/-/fraction.js-4.2.0.tgz#448e5109a313a3527f5a3ab2119ec4cf0e0e2950" - integrity sha512-MhLuK+2gUcnZe8ZHlaaINnQLl0xRIGRfcGk2yl8xoQAfHrSsL3rYu6FCmBdkdbhc9EPlwyGHewaRsvwRMJtAlA== - -from@~0: - version "0.1.7" - resolved "https://registry.yarnpkg.com/from/-/from-0.1.7.tgz#83c60afc58b9c56997007ed1a768b3ab303a44fe" - integrity sha1-g8YK/Fi5xWmXAH7Rp2izqzA6RP4= - -fs-extra@^10.0.1: - version "10.0.1" - resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-10.0.1.tgz#27de43b4320e833f6867cc044bfce29fdf0ef3b8" - integrity sha512-NbdoVMZso2Lsrn/QwLXOy6rm0ufY2zEOKCDzJR/0kBsb0E6qed0P3iYK+Ath3BfvXEeu4JhEtXLgILx5psUfag== - dependencies: - graceful-fs "^4.2.0" - jsonfile "^6.0.1" - universalify "^2.0.0" - -fs-minipass@^1.2.7: - version "1.2.7" - resolved "https://registry.yarnpkg.com/fs-minipass/-/fs-minipass-1.2.7.tgz#ccff8570841e7fe4265693da88936c55aed7f7c7" - integrity sha512-GWSSJGFy4e9GUeCcbIkED+bgAoFyj7XF1mV8rma3QW4NIqX9Kyx79N/PF61H5udOV3aY1IaMLs6pGbH71nlCTA== - dependencies: - minipass "^2.6.0" - -fs-minipass@^2.0.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/fs-minipass/-/fs-minipass-2.1.0.tgz#7f5036fdbf12c63c169190cbe4199c852271f9fb" - integrity sha512-V/JgOLFCS+R6Vcq0slCuaeWEdNC3ouDlJMNIsacH2VtALiu9mV4LPrHc5cDl8k5aw6J8jwgWWpiTo5RYhmIzvg== - dependencies: - minipass "^3.0.0" - -fs.realpath@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" - integrity sha1-FQStJSMVjKpA20onh8sBQRmU6k8= - -fsevents@~2.3.2: - version "2.3.2" - resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a" - integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA== - -function-bind@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d" - integrity sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A== - -gauge@^3.0.0: - version "3.0.2" - resolved "https://registry.yarnpkg.com/gauge/-/gauge-3.0.2.tgz#03bf4441c044383908bcfa0656ad91803259b395" - integrity sha512-+5J6MS/5XksCuXq++uFRsnUd7Ovu1XenbeuIuNRJxYWjgQbPuFhT14lAvsWfqfAmnwluf1OwMjz39HjfLPci0Q== - dependencies: - aproba "^1.0.3 || ^2.0.0" - color-support "^1.1.2" - console-control-strings "^1.0.0" - has-unicode "^2.0.1" - object-assign "^4.1.1" - signal-exit "^3.0.0" - string-width "^4.2.3" - strip-ansi "^6.0.1" - wide-align "^1.1.2" - -gensync@^1.0.0-beta.2: - version "1.0.0-beta.2" - resolved "https://registry.yarnpkg.com/gensync/-/gensync-1.0.0-beta.2.tgz#32a6ee76c3d7f52d46b2b1ae5d93fea8580a25e0" - integrity sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg== - -get-caller-file@^2.0.5: - version "2.0.5" - resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e" - integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg== - -get-intrinsic@^1.0.2, get-intrinsic@^1.1.0, get-intrinsic@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/get-intrinsic/-/get-intrinsic-1.1.1.tgz#15f59f376f855c446963948f0d24cd3637b4abc6" - integrity sha512-kWZrnVM42QCiEA2Ig1bG8zjoIMOgxWwYCEeNdwY6Tv/cOSeGpcoX4pXHfKUxNKVoArnrEr2e9srnAxxGIraS9Q== - dependencies: - function-bind "^1.1.1" - has "^1.0.3" - has-symbols "^1.0.1" - -get-symbol-description@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/get-symbol-description/-/get-symbol-description-1.0.0.tgz#7fdb81c900101fbd564dd5f1a30af5aadc1e58d6" - integrity sha512-2EmdH1YvIQiZpltCNgkuiUnyukzxM/R6NDJX31Ke3BG1Nq5b0S2PhX59UKi9vZpPDQVdqn+1IcaAwnzTT5vCjw== - dependencies: - call-bind "^1.0.2" - get-intrinsic "^1.1.1" - -getpass@^0.1.1: - version "0.1.7" - resolved "https://registry.yarnpkg.com/getpass/-/getpass-0.1.7.tgz#5eff8e3e684d569ae4cb2b1282604e8ba62149fa" - integrity sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo= - dependencies: - assert-plus "^1.0.0" - -glob-parent@~5.1.2: - version "5.1.2" - resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4" - integrity sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow== - dependencies: - is-glob "^4.0.1" - -glob@^7.0.0, glob@^7.0.5, glob@^7.0.6, glob@^7.1.1, glob@^7.1.3, glob@^7.1.6, glob@^7.1.7: - version "7.2.0" - resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.0.tgz#d15535af7732e02e948f4c41628bd910293f6023" - integrity sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q== - dependencies: - fs.realpath "^1.0.0" - inflight "^1.0.4" - inherits "2" - minimatch "^3.0.4" - once "^1.3.0" - path-is-absolute "^1.0.0" - -globals@^11.1.0: - version "11.12.0" - resolved "https://registry.yarnpkg.com/globals/-/globals-11.12.0.tgz#ab8795338868a0babd8525758018c2a7eb95c42e" - integrity sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA== - -google-protobuf@^3.9.2: - version "3.19.4" - resolved "https://registry.yarnpkg.com/google-protobuf/-/google-protobuf-3.19.4.tgz#8d32c3e34be9250956f28c0fb90955d13f311888" - integrity sha512-OIPNCxsG2lkIvf+P5FNfJ/Km95CsXOBecS9ZcAU6m2Rq3svc0Apl9nB3GMDNKfQ9asNv4KjyAqGwPQFrVle3Yg== - -graceful-fs@^4.1.6, graceful-fs@^4.2.0, graceful-fs@^4.2.6: - version "4.2.9" - resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.9.tgz#041b05df45755e587a24942279b9d113146e1c96" - integrity sha512-NtNxqUcXgpW2iMrfqSfR73Glt39K+BLwWsPs94yR63v45T0Wbej7eRmL5cWfwEgqXnmjQp3zaJTshdRW/qC2ZQ== - -har-schema@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/har-schema/-/har-schema-2.0.0.tgz#a94c2224ebcac04782a0d9035521f24735b7ec92" - integrity sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI= - -har-validator@~5.1.3: - version "5.1.5" - resolved "https://registry.yarnpkg.com/har-validator/-/har-validator-5.1.5.tgz#1f0803b9f8cb20c0fa13822df1ecddb36bde1efd" - integrity sha512-nmT2T0lljbxdQZfspsno9hgrG3Uir6Ks5afism62poxqBM6sDnMEuPmzTq8XN0OEwqKLLdh1jQI3qyE66Nzb3w== - dependencies: - ajv "^6.12.3" - har-schema "^2.0.0" - -has-bigints@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/has-bigints/-/has-bigints-1.0.1.tgz#64fe6acb020673e3b78db035a5af69aa9d07b113" - integrity sha512-LSBS2LjbNBTf6287JEbEzvJgftkF5qFkmCo9hDRpAzKhUOlJ+hx8dd4USs00SgsUNwc4617J9ki5YtEClM2ffA== - -has-flag@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd" - integrity sha1-tdRU3CGZriJWmfNGfloH87lVuv0= - -has-flag@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b" - integrity sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ== - -has-symbols@^1.0.1, has-symbols@^1.0.2: - version "1.0.3" - resolved "https://registry.yarnpkg.com/has-symbols/-/has-symbols-1.0.3.tgz#bb7b2c4349251dce87b125f7bdf874aa7c8b39f8" - integrity sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A== - -has-tostringtag@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/has-tostringtag/-/has-tostringtag-1.0.0.tgz#7e133818a7d394734f941e73c3d3f9291e658b25" - integrity sha512-kFjcSNhnlGV1kyoGk7OXKSawH5JOb/LzUc5w9B02hOTO0dfFRjbHQKvg1d6cf3HbeUmtU9VbbV3qzZ2Teh97WQ== - dependencies: - has-symbols "^1.0.2" - -has-unicode@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/has-unicode/-/has-unicode-2.0.1.tgz#e0e6fe6a28cf51138855e086d1691e771de2a8b9" - integrity sha512-8Rf9Y83NBReMnx0gFzA8JImQACstCYWUplepDa9xprwwtmgEZUF0h/i5xSA625zB/I37EtrswSST6OXxwaaIJQ== - -has@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/has/-/has-1.0.3.tgz#722d7cbfc1f6aa8241f16dd814e011e1f41e8796" - integrity sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw== - dependencies: - function-bind "^1.1.1" - -hash-base@^3.0.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/hash-base/-/hash-base-3.1.0.tgz#55c381d9e06e1d2997a883b4a3fddfe7f0d3af33" - integrity sha512-1nmYp/rhMDiE7AYkDw+lLwlAzz0AntGIe51F3RfFfEqyQ3feY2eI/NcwC6umIQVOASPMsWJLJScWKSSvzL9IVA== - dependencies: - inherits "^2.0.4" - readable-stream "^3.6.0" - safe-buffer "^5.2.0" - -hash.js@^1.0.0, hash.js@^1.0.3: - version "1.1.7" - resolved "https://registry.yarnpkg.com/hash.js/-/hash.js-1.1.7.tgz#0babca538e8d4ee4a0f8988d68866537a003cf42" - integrity sha512-taOaskGt4z4SOANNseOviYDvjEJinIkRgmp7LbKP2YTTmVxWBl87s/uzK9r+44BclBSp2X7K1hqeNfz9JbBeXA== - dependencies: - inherits "^2.0.3" - minimalistic-assert "^1.0.1" - -hmac-drbg@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/hmac-drbg/-/hmac-drbg-1.0.1.tgz#d2745701025a6c775a6c545793ed502fc0c649a1" - integrity sha1-0nRXAQJabHdabFRXk+1QL8DGSaE= - dependencies: - hash.js "^1.0.3" - minimalistic-assert "^1.0.0" - minimalistic-crypto-utils "^1.0.1" - -html-escaper@^2.0.0: - version "2.0.2" - resolved "https://registry.yarnpkg.com/html-escaper/-/html-escaper-2.0.2.tgz#dfd60027da36a36dfcbe236262c00a5822681453" - integrity sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg== - -http-errors@1.8.1: - version "1.8.1" - resolved "https://registry.yarnpkg.com/http-errors/-/http-errors-1.8.1.tgz#7c3f28577cbc8a207388455dbd62295ed07bd68c" - integrity sha512-Kpk9Sm7NmI+RHhnj6OIWDI1d6fIoFAtFt9RLaTMRlg/8w49juAStsrBgp0Dp4OdxdVbRIeKhtCUvoi/RuAhO4g== - dependencies: - depd "~1.1.2" - inherits "2.0.4" - setprototypeof "1.2.0" - statuses ">= 1.5.0 < 2" - toidentifier "1.0.1" - -http-proxy@^1.18.1: - version "1.18.1" - resolved "https://registry.yarnpkg.com/http-proxy/-/http-proxy-1.18.1.tgz#401541f0534884bbf95260334e72f88ee3976549" - integrity sha512-7mz/721AbnJwIVbnaSv1Cz3Am0ZLT/UBwkC92VlxhXv/k/BBQfM2fXElQNC27BVGr0uwUpplYPQM9LnaBMR5NQ== - dependencies: - eventemitter3 "^4.0.0" - follow-redirects "^1.0.0" - requires-port "^1.0.0" - -http-signature@~1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/http-signature/-/http-signature-1.2.0.tgz#9aecd925114772f3d95b65a60abb8f7c18fbace1" - integrity sha1-muzZJRFHcvPZW2WmCruPfBj7rOE= - dependencies: - assert-plus "^1.0.0" - jsprim "^1.2.2" - sshpk "^1.7.0" - -https-browserify@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/https-browserify/-/https-browserify-1.0.0.tgz#ec06c10e0a34c0f2faf199f7fd7fc78fffd03c73" - integrity sha1-7AbBDgo0wPL68Zn3/X/Hj//QPHM= - -https-proxy-agent@^2.2.1: - version "2.2.4" - resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-2.2.4.tgz#4ee7a737abd92678a293d9b34a1af4d0d08c787b" - integrity sha512-OmvfoQ53WLjtA9HeYP9RNrWMJzzAz1JGaSFr1nijg0PVR1JaD/xbJq1mdEIIlxGpXp9eSe/O2LgU9DJmTPd0Eg== - dependencies: - agent-base "^4.3.0" - debug "^3.1.0" - -https-proxy-agent@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-4.0.0.tgz#702b71fb5520a132a66de1f67541d9e62154d82b" - integrity sha512-zoDhWrkR3of1l9QAL8/scJZyLu8j/gBkcwcaQOZh7Gyh/+uJQzGVETdgT30akuwkpL8HTRfssqI3BZuV18teDg== - dependencies: - agent-base "5" - debug "4" - -https-proxy-agent@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-5.0.0.tgz#e2a90542abb68a762e0a0850f6c9edadfd8506b2" - integrity sha512-EkYm5BcKUGiduxzSt3Eppko+PiNWNEpa4ySk9vTC6wDsQJW9rHSa+UhGNJoRYp7bz6Ht1eaRIa6QaJqO5rCFbA== - dependencies: - agent-base "6" - debug "4" - -iconv-lite@0.4.24: - version "0.4.24" - resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.24.tgz#2022b4b25fbddc21d2f524974a474aafe733908b" - integrity sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA== - dependencies: - safer-buffer ">= 2.1.2 < 3" - -ieee754@^1.1.13: - version "1.2.1" - resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.2.1.tgz#8eb7a10a63fff25d15a57b001586d177d1b0d352" - integrity sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA== - -inflight@^1.0.4: - version "1.0.6" - resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" - integrity sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk= - dependencies: - once "^1.3.0" - wrappy "1" - -inherits@2, inherits@2.0.4, inherits@^2.0.1, inherits@^2.0.3, inherits@^2.0.4, inherits@~2.0.3, inherits@~2.0.4: - version "2.0.4" - resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" - integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== - -inline-source-map@~0.6.0: - version "0.6.2" - resolved "https://registry.yarnpkg.com/inline-source-map/-/inline-source-map-0.6.2.tgz#f9393471c18a79d1724f863fa38b586370ade2a5" - integrity sha1-+Tk0ccGKedFyT4Y/o4tYY3Ct4qU= - dependencies: - source-map "~0.5.3" - -internal-slot@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/internal-slot/-/internal-slot-1.0.3.tgz#7347e307deeea2faac2ac6205d4bc7d34967f59c" - integrity sha512-O0DB1JC/sPyZl7cIo78n5dR7eUSwwpYPiXRhTzNxZVAMUuB8vlnRFyLxdrVToks6XPLVnFfbzaVd5WLjhgg+vA== - dependencies: - get-intrinsic "^1.1.0" - has "^1.0.3" - side-channel "^1.0.4" - -is-arguments@^1.0.4: - version "1.1.1" - resolved "https://registry.yarnpkg.com/is-arguments/-/is-arguments-1.1.1.tgz#15b3f88fda01f2a97fec84ca761a560f123efa9b" - integrity sha512-8Q7EARjzEnKpt/PCD7e1cgUS0a6X8u5tdSiMqXhojOdoV9TsMsiO+9VLC5vAmO8N7/GmXn7yjR8qnA6bVAEzfA== - dependencies: - call-bind "^1.0.2" - has-tostringtag "^1.0.0" - -is-arrayish@^0.2.1: - version "0.2.1" - resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.2.1.tgz#77c99840527aa8ecb1a8ba697b80645a7a926a9d" - integrity sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0= - -is-bigint@^1.0.1: - version "1.0.4" - resolved "https://registry.yarnpkg.com/is-bigint/-/is-bigint-1.0.4.tgz#08147a1875bc2b32005d41ccd8291dffc6691df3" - integrity sha512-zB9CruMamjym81i2JZ3UMn54PKGsQzsJeo6xvN3HJJ4CAsQNB6iRutp2To77OfCNuoxspsIhzaPoO1zyCEhFOg== - dependencies: - has-bigints "^1.0.1" - -is-binary-path@~2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/is-binary-path/-/is-binary-path-2.1.0.tgz#ea1f7f3b80f064236e83470f86c09c254fb45b09" - integrity sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw== - dependencies: - binary-extensions "^2.0.0" - -is-boolean-object@^1.1.0: - version "1.1.2" - resolved "https://registry.yarnpkg.com/is-boolean-object/-/is-boolean-object-1.1.2.tgz#5c6dc200246dd9321ae4b885a114bb1f75f63719" - integrity sha512-gDYaKHJmnj4aWxyj6YHyXVpdQawtVLHU5cb+eztPGczf6cjuTdwve5ZIEfgXqH4e57An1D1AKf8CZ3kYrQRqYA== - dependencies: - call-bind "^1.0.2" - has-tostringtag "^1.0.0" - -is-callable@^1.1.4, is-callable@^1.2.4: - version "1.2.4" - resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.2.4.tgz#47301d58dd0259407865547853df6d61fe471945" - integrity sha512-nsuwtxZfMX67Oryl9LCQ+upnC0Z0BgpwntpS89m1H/TLF0zNfzfLMV/9Wa/6MZsj0acpEjAO0KF1xT6ZdLl95w== - -is-core-module@^2.8.1: - version "2.8.1" - resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.8.1.tgz#f59fdfca701d5879d0a6b100a40aa1560ce27211" - integrity sha512-SdNCUs284hr40hFTFP6l0IfZ/RSrMXF3qgoRHd3/79unUTvrFO/JoXwkGm+5J/Oe3E/b5GsnG330uUNgRpu1PA== - dependencies: - has "^1.0.3" - -is-date-object@^1.0.1: - version "1.0.5" - resolved "https://registry.yarnpkg.com/is-date-object/-/is-date-object-1.0.5.tgz#0841d5536e724c25597bf6ea62e1bd38298df31f" - integrity sha512-9YQaSxsAiSwcvS33MBk3wTCVnWK+HhF8VZR2jRxehM16QcVOdHqPn4VPHmRK4lSr38n9JriurInLcP90xsYNfQ== - dependencies: - has-tostringtag "^1.0.0" - -is-extglob@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2" - integrity sha1-qIwCU1eR8C7TfHahueqXc8gz+MI= - -is-fullwidth-code-point@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz#f116f8064fe90b3f7844a38997c0b75051269f1d" - integrity sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg== - -is-generator-function@^1.0.7: - version "1.0.10" - resolved "https://registry.yarnpkg.com/is-generator-function/-/is-generator-function-1.0.10.tgz#f1558baf1ac17e0deea7c0415c438351ff2b3c72" - integrity sha512-jsEjy9l3yiXEQ+PsXdmBwEPcOxaXWLspKdplFUVI9vq1iZgIekeC0L167qeu86czQaxed3q/Uzuw0swL0irL8A== - dependencies: - has-tostringtag "^1.0.0" - -is-glob@^4.0.1, is-glob@~4.0.1: - version "4.0.3" - resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.3.tgz#64f61e42cbbb2eec2071a9dac0b28ba1e65d5084" - integrity sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg== - dependencies: - is-extglob "^2.1.1" - -is-nan@^1.2.1: - version "1.3.2" - resolved "https://registry.yarnpkg.com/is-nan/-/is-nan-1.3.2.tgz#043a54adea31748b55b6cd4e09aadafa69bd9e1d" - integrity sha512-E+zBKpQ2t6MEo1VsonYmluk9NxGrbzpeeLC2xIViuO2EjU2xsXsBPwTr3Ykv9l08UYEVEdWeRZNouaZqF6RN0w== - dependencies: - call-bind "^1.0.0" - define-properties "^1.1.3" - -is-negative-zero@^2.0.1: - version "2.0.2" - resolved "https://registry.yarnpkg.com/is-negative-zero/-/is-negative-zero-2.0.2.tgz#7bf6f03a28003b8b3965de3ac26f664d765f3150" - integrity sha512-dqJvarLawXsFbNDeJW7zAz8ItJ9cd28YufuuFzh0G8pNHjJMnY08Dv7sYX2uF5UpQOwieAeOExEYAWWfu7ZZUA== - -is-number-object@^1.0.4: - version "1.0.6" - resolved "https://registry.yarnpkg.com/is-number-object/-/is-number-object-1.0.6.tgz#6a7aaf838c7f0686a50b4553f7e54a96494e89f0" - integrity sha512-bEVOqiRcvo3zO1+G2lVMy+gkkEm9Yh7cDMRusKKu5ZJKPUYSJwICTKZrNKHA2EbSP0Tu0+6B/emsYNHZyn6K8g== - dependencies: - has-tostringtag "^1.0.0" - -is-number@^7.0.0: - version "7.0.0" - resolved "https://registry.yarnpkg.com/is-number/-/is-number-7.0.0.tgz#7535345b896734d5f80c4d06c50955527a14f12b" - integrity sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng== - -is-regex@^1.1.4: - version "1.1.4" - resolved "https://registry.yarnpkg.com/is-regex/-/is-regex-1.1.4.tgz#eef5663cd59fa4c0ae339505323df6854bb15958" - integrity sha512-kvRdxDsxZjhzUX07ZnLydzS1TU/TJlTUHHY4YLL87e37oUA49DfkLqgy+VjFocowy29cKvcSiu+kIv728jTTVg== - dependencies: - call-bind "^1.0.2" - has-tostringtag "^1.0.0" - -is-running@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/is-running/-/is-running-2.1.0.tgz#30a73ff5cc3854e4fc25490809e9f5abf8de09e0" - integrity sha1-MKc/9cw4VOT8JUkICen1q/jeCeA= - -is-shared-array-buffer@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/is-shared-array-buffer/-/is-shared-array-buffer-1.0.1.tgz#97b0c85fbdacb59c9c446fe653b82cf2b5b7cfe6" - integrity sha512-IU0NmyknYZN0rChcKhRO1X8LYz5Isj/Fsqh8NJOSf+N/hCOTwy29F32Ik7a+QszE63IdvmwdTPDd6cZ5pg4cwA== - -is-string@^1.0.5, is-string@^1.0.7: - version "1.0.7" - resolved "https://registry.yarnpkg.com/is-string/-/is-string-1.0.7.tgz#0dd12bf2006f255bb58f695110eff7491eebc0fd" - integrity sha512-tE2UXzivje6ofPW7l23cjDOMa09gb7xlAqG6jG5ej6uPV32TlWP3NKPigtaGeHNu9fohccRYvIiZMfOOnOYUtg== - dependencies: - has-tostringtag "^1.0.0" - -is-symbol@^1.0.2, is-symbol@^1.0.3: - version "1.0.4" - resolved "https://registry.yarnpkg.com/is-symbol/-/is-symbol-1.0.4.tgz#a6dac93b635b063ca6872236de88910a57af139c" - integrity sha512-C/CPBqKWnvdcxqIARxyOh4v1UUEOCHpgDa0WYgpKDFMszcrPcffg5uhwSgPCLD2WWxmq6isisz87tzT01tuGhg== - dependencies: - has-symbols "^1.0.2" - -is-typed-array@^1.1.3, is-typed-array@^1.1.7: - version "1.1.8" - resolved "https://registry.yarnpkg.com/is-typed-array/-/is-typed-array-1.1.8.tgz#cbaa6585dc7db43318bc5b89523ea384a6f65e79" - integrity sha512-HqH41TNZq2fgtGT8WHVFVJhBVGuY3AnP3Q36K8JKXUxSxRgk/d+7NjmwG2vo2mYmXK8UYZKu0qH8bVP5gEisjA== - dependencies: - available-typed-arrays "^1.0.5" - call-bind "^1.0.2" - es-abstract "^1.18.5" - foreach "^2.0.5" - has-tostringtag "^1.0.0" - -is-typedarray@~1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a" - integrity sha1-5HnICFjfDBsR3dppQPlgEfzaSpo= - -is-utf8@^0.2.0: - version "0.2.1" - resolved "https://registry.yarnpkg.com/is-utf8/-/is-utf8-0.2.1.tgz#4b0da1442104d1b336340e80797e865cf39f7d72" - integrity sha1-Sw2hRCEE0bM2NA6AeX6GXPOffXI= - -is-weakref@^1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/is-weakref/-/is-weakref-1.0.2.tgz#9529f383a9338205e89765e0392efc2f100f06f2" - integrity sha512-qctsuLZmIQ0+vSSMfoVvyFe2+GSEvnmZ2ezTup1SBse9+twCCeial6EEi3Nc2KFcf6+qz2FBPnjXsk8xhKSaPQ== - dependencies: - call-bind "^1.0.2" - -isarray@~1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11" - integrity sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE= - -isbinaryfile@^4.0.8: - version "4.0.10" - resolved "https://registry.yarnpkg.com/isbinaryfile/-/isbinaryfile-4.0.10.tgz#0c5b5e30c2557a2f06febd37b7322946aaee42b3" - integrity sha512-iHrqe5shvBUcFbmZq9zOQHBoeOhZJu6RQGrDpBgenUm/Am+F3JM2MgQj+rK3Z601fzrL5gLZWtAPH2OBaSVcyw== - -isexe@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" - integrity sha1-6PvzdNxVb/iUehDcsFctYz8s+hA= - -isstream@~0.1.2: - version "0.1.2" - resolved "https://registry.yarnpkg.com/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a" - integrity sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo= - -istanbul-lib-coverage@^3.0.0: - version "3.2.0" - resolved "https://registry.yarnpkg.com/istanbul-lib-coverage/-/istanbul-lib-coverage-3.2.0.tgz#189e7909d0a39fa5a3dfad5b03f71947770191d3" - integrity sha512-eOeJ5BHCmHYvQK7xt9GkdHuzuCGS1Y6g9Gvnx3Ym33fz/HpLRYxiS0wHNr+m/MBC8B647Xt608vCDEvhl9c6Mw== - -istanbul-lib-instrument@^4.0.0: - version "4.0.3" - resolved "https://registry.yarnpkg.com/istanbul-lib-instrument/-/istanbul-lib-instrument-4.0.3.tgz#873c6fff897450118222774696a3f28902d77c1d" - integrity sha512-BXgQl9kf4WTCPCCpmFGoJkz/+uhvm7h7PFKUYxh7qarQd3ER33vHG//qaE8eN25l07YqZPpHXU9I09l/RD5aGQ== - dependencies: - "@babel/core" "^7.7.5" - "@istanbuljs/schema" "^0.1.2" - istanbul-lib-coverage "^3.0.0" - semver "^6.3.0" - -istanbul-lib-report@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/istanbul-lib-report/-/istanbul-lib-report-3.0.0.tgz#7518fe52ea44de372f460a76b5ecda9ffb73d8a6" - integrity sha512-wcdi+uAKzfiGT2abPpKZ0hSU1rGQjUQnLvtY5MpQ7QCTahD3VODhcu4wcfY1YtkGaDD5yuydOLINXsfbus9ROw== - dependencies: - istanbul-lib-coverage "^3.0.0" - make-dir "^3.0.0" - supports-color "^7.1.0" - -istanbul-lib-source-maps@^4.0.0: - version "4.0.1" - resolved "https://registry.yarnpkg.com/istanbul-lib-source-maps/-/istanbul-lib-source-maps-4.0.1.tgz#895f3a709fcfba34c6de5a42939022f3e4358551" - integrity sha512-n3s8EwkdFIJCG3BPKBYvskgXGoy88ARzvegkitk60NxRdwltLOTaH7CUiMRXvwYorl0Q712iEjcWB+fK/MrWVw== - dependencies: - debug "^4.1.1" - istanbul-lib-coverage "^3.0.0" - source-map "^0.6.1" - -istanbul-reports@^3.0.0: - version "3.1.4" - resolved "https://registry.yarnpkg.com/istanbul-reports/-/istanbul-reports-3.1.4.tgz#1b6f068ecbc6c331040aab5741991273e609e40c" - integrity sha512-r1/DshN4KSE7xWEknZLLLLDn5CJybV3nw01VTkp6D5jzLuELlcbudfj/eSQFvrKsJuTVCGnePO7ho82Nw9zzfw== - dependencies: - html-escaper "^2.0.0" - istanbul-lib-report "^3.0.0" - -jasmine-core@~3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/jasmine-core/-/jasmine-core-3.1.0.tgz#a4785e135d5df65024dfc9224953df585bd2766c" - integrity sha1-pHheE11d9lAk38kiSVPfWFvSdmw= - -jasmine@~3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/jasmine/-/jasmine-3.1.0.tgz#2bd59fd7ec6ec0e8acb64e09f45a68ed2ad1952a" - integrity sha1-K9Wf1+xuwOistk4J9Fpo7SrRlSo= - dependencies: - glob "^7.0.6" - jasmine-core "~3.1.0" - -javascript-natural-sort@^0.7.1: - version "0.7.1" - resolved "https://registry.yarnpkg.com/javascript-natural-sort/-/javascript-natural-sort-0.7.1.tgz#f9e2303d4507f6d74355a73664d1440fb5a0ef59" - integrity sha1-+eIwPUUH9tdDVac2ZNFED7Wg71k= - -js-tokens@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" - integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ== - -js-yaml@^3.13.1: - version "3.14.1" - resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.14.1.tgz#dae812fdb3825fa306609a8717383c50c36a0537" - integrity sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g== - dependencies: - argparse "^1.0.7" - esprima "^4.0.0" - -jsbn@~0.1.0: - version "0.1.1" - resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-0.1.1.tgz#a5e654c2e5a2deb5f201d96cefbca80c0ef2f513" - integrity sha1-peZUwuWi3rXyAdls77yoDA7y9RM= - -jsesc@^2.5.1: - version "2.5.2" - resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-2.5.2.tgz#80564d2e483dacf6e8ef209650a67df3f0c283a4" - integrity sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA== - -jsesc@~0.5.0: - version "0.5.0" - resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-0.5.0.tgz#e7dee66e35d6fc16f710fe91d5cf69f70f08911d" - integrity sha1-597mbjXW/Bb3EP6R1c9p9w8IkR0= - -json-schema-traverse@^0.4.1: - version "0.4.1" - resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz#69f6a87d9513ab8bb8fe63bdb0979c448e684660" - integrity sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg== - -json-schema@0.4.0: - version "0.4.0" - resolved "https://registry.yarnpkg.com/json-schema/-/json-schema-0.4.0.tgz#f7de4cf6efab838ebaeb3236474cbba5a1930ab5" - integrity sha512-es94M3nTIfsEPisRafak+HDLfHXnKBhV3vU5eqPcS3flIWqcxJWgXHXiey3YrpaNsanY5ei1VoYEbOzijuq9BA== - -json-stringify-safe@^5.0.1, json-stringify-safe@~5.0.1: - version "5.0.1" - resolved "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb" - integrity sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus= - -json5@^2.1.2: - version "2.2.3" - resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.3.tgz#78cd6f1a19bdc12b73db5ad0c61efd66c1e29283" - integrity sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg== - -jsonfile@^6.0.1: - version "6.1.0" - resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-6.1.0.tgz#bc55b2634793c679ec6403094eb13698a6ec0aae" - integrity sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ== - dependencies: - universalify "^2.0.0" - optionalDependencies: - graceful-fs "^4.1.6" - -jsprim@^1.2.2: - version "1.4.2" - resolved "https://registry.yarnpkg.com/jsprim/-/jsprim-1.4.2.tgz#712c65533a15c878ba59e9ed5f0e26d5b77c5feb" - integrity sha512-P2bSOMAc/ciLz6DzgjVlGJP9+BrJWu5UDGK70C2iweC5QBIeFf0ZXRvGjEj2uYgrY2MkAAhsSWHDWlFtEroZWw== - dependencies: - assert-plus "1.0.0" - extsprintf "1.3.0" - json-schema "0.4.0" - verror "1.10.0" - -karma-browserstack-launcher@~1.6.0: - version "1.6.0" - resolved "https://registry.yarnpkg.com/karma-browserstack-launcher/-/karma-browserstack-launcher-1.6.0.tgz#2f6000647073e77ae296653b8830b279669766ef" - integrity sha512-Y/UWPdHZkHIVH2To4GWHCTzmrsB6H7PBWy6pw+TWz5sr4HW2mcE+Uj6qWgoVNxvQU1Pfn5LQQzI6EQ65p8QbiQ== - dependencies: - browserstack "~1.5.1" - browserstack-local "^1.3.7" - q "~1.5.0" - -karma-chrome-launcher@~3.1.1: - version "3.1.1" - resolved "https://registry.yarnpkg.com/karma-chrome-launcher/-/karma-chrome-launcher-3.1.1.tgz#baca9cc071b1562a1db241827257bfe5cab597ea" - integrity sha512-hsIglcq1vtboGPAN+DGCISCFOxW+ZVnIqhDQcCMqqCp+4dmJ0Qpq5QAjkbA0X2L9Mi6OBkHi2Srrbmm7pUKkzQ== - dependencies: - which "^1.2.1" - -karma-jasmine-order-reporter@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/karma-jasmine-order-reporter/-/karma-jasmine-order-reporter-1.1.0.tgz#3bd4cfd9e5ae53cc0d972905b811a479c127d0a8" - integrity sha512-mzC6WfOg7y5kCf7K4W+nB5NHea1ogcDjRpepFLLRjbi4lx08wQG+6EY2zd+mC2ANIvb6+ux2d9mFVtZ3MIwTYg== - -karma-jasmine@~1.1.0: - version "1.1.2" - resolved "https://registry.yarnpkg.com/karma-jasmine/-/karma-jasmine-1.1.2.tgz#394f2b25ffb4a644b9ada6f22d443e2fd08886c3" - integrity sha512-SENGE9DhlIIFTSZWiNq4eGeXL8G6z9cqHIOdkx9jh1qhhQqwEy3tAoLRyER0vOcHqdOlKmGpOuXk+HOipIy7sg== - -karma-spec-reporter@~0.0.32: - version "0.0.33" - resolved "https://registry.yarnpkg.com/karma-spec-reporter/-/karma-spec-reporter-0.0.33.tgz#5b2712c3eaff7ae50dbd6ad4e5fb59befd740a96" - integrity sha512-xRVevDUkiIVhKbDQ3CmeGEpyzA4b3HeVl95Sx5yJAvurpdKUSYF6ZEbQOqKJ7vrtDniABV1hyFez9KX9+7ruBA== - dependencies: - colors "1.4.0" - -karma-typescript-es6-transform@^5.1.0: - version "5.5.3" - resolved "https://registry.yarnpkg.com/karma-typescript-es6-transform/-/karma-typescript-es6-transform-5.5.3.tgz#5396da512c20b69d49e3e362a41f250342da5c03" - integrity sha512-vB1Cv8z9yxyR2KQuvks5soNKASyS2RPApdMsB3Ad55RqFJeag9G+xyGIwxOdyCHtgOwa4yn1rngMwaN7WBQTbQ== - dependencies: - "@babel/core" "^7.11.1" - "@babel/preset-env" "^7.11.0" - acorn "^8.1.0" - acorn-walk "^8.0.2" - log4js "^6.3.0" - magic-string "^0.25.7" - -karma-typescript@~5.5.1: - version "5.5.3" - resolved "https://registry.yarnpkg.com/karma-typescript/-/karma-typescript-5.5.3.tgz#29c04d9677f8bd78dfacd89e8fa6f475dd25aba2" - integrity sha512-l1FHurolXEBIzRa9ExpNtjzysAhsi/vLpTazpwLHWWK86mknvVpqor6pRZ5Nid7jvOPrTBqAq0JRuLgiCdRkFw== - dependencies: - acorn "^8.1.0" - acorn-walk "^8.0.2" - assert "^2.0.0" - async "^3.0.1" - browser-resolve "^2.0.0" - browserify-zlib "^0.2.0" - buffer "^5.4.3" - combine-source-map "^0.8.0" - console-browserify "^1.2.0" - constants-browserify "^1.0.0" - convert-source-map "^1.7.0" - crypto-browserify "^3.12.0" - diff "^4.0.1" - domain-browser "^4.16.0" - events "^3.2.0" - glob "^7.1.6" - https-browserify "^1.0.0" - istanbul-lib-coverage "^3.0.0" - istanbul-lib-instrument "^4.0.0" - istanbul-lib-report "^3.0.0" - istanbul-lib-source-maps "^4.0.0" - istanbul-reports "^3.0.0" - json-stringify-safe "^5.0.1" - lodash "^4.17.19" - log4js "^6.3.0" - minimatch "^3.0.4" - os-browserify "^0.3.0" - pad "^3.2.0" - path-browserify "^1.0.0" - process "^0.11.10" - punycode "^2.1.1" - querystring-es3 "^0.2.1" - readable-stream "^3.1.1" - source-map "^0.7.3" - stream-browserify "^3.0.0" - stream-http "^3.1.0" - string_decoder "^1.3.0" - timers-browserify "^2.0.11" - tmp "^0.2.1" - tty-browserify "^0.0.1" - url "^0.11.0" - util "^0.12.1" - vm-browserify "^1.1.2" - -karma@~6.3.20: - version "6.3.20" - resolved "https://registry.yarnpkg.com/karma/-/karma-6.3.20.tgz#12f5c3b0e68f204607cb0a3a78d4751b42ef61a8" - integrity sha512-HRNQhMuKOwKpjYlWiJP0DUrJOh+QjaI/DTaD8b9rEm4Il3tJ8MijutVZH4ts10LuUFst/CedwTS6vieCN8yTSw== - dependencies: - "@colors/colors" "1.5.0" - body-parser "^1.19.0" - braces "^3.0.2" - chokidar "^3.5.1" - connect "^3.7.0" - di "^0.0.1" - dom-serialize "^2.2.1" - glob "^7.1.7" - graceful-fs "^4.2.6" - http-proxy "^1.18.1" - isbinaryfile "^4.0.8" - lodash "^4.17.21" - log4js "^6.4.1" - mime "^2.5.2" - minimatch "^3.0.4" - mkdirp "^0.5.5" - qjobs "^1.2.0" - range-parser "^1.2.1" - rimraf "^3.0.2" - socket.io "^4.4.1" - source-map "^0.6.1" - tmp "^0.2.1" - ua-parser-js "^0.7.30" - yargs "^16.1.1" - -lodash.debounce@^4.0.8: - version "4.0.8" - resolved "https://registry.yarnpkg.com/lodash.debounce/-/lodash.debounce-4.0.8.tgz#82d79bff30a67c4005ffd5e2515300ad9ca4d7af" - integrity sha1-gteb/zCmfEAF/9XiUVMArZyk168= - -lodash.memoize@~3.0.3: - version "3.0.4" - resolved "https://registry.yarnpkg.com/lodash.memoize/-/lodash.memoize-3.0.4.tgz#2dcbd2c287cbc0a55cc42328bd0c736150d53e3f" - integrity sha1-LcvSwofLwKVcxCMovQxzYVDVPj8= - -lodash@^4.17.19, lodash@^4.17.21: - version "4.17.21" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c" - integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg== - -log4js@^6.3.0, log4js@^6.4.1: - version "6.4.4" - resolved "https://registry.yarnpkg.com/log4js/-/log4js-6.4.4.tgz#c9bc75569f3f40bba22fe1bd0677afa7a6a13bac" - integrity sha512-ncaWPsuw9Vl1CKA406hVnJLGQKy1OHx6buk8J4rE2lVW+NW5Y82G5/DIloO7NkqLOUtNPEANaWC1kZYVjXssPw== - dependencies: - date-format "^4.0.6" - debug "^4.3.4" - flatted "^3.2.5" - rfdc "^1.3.0" - streamroller "^3.0.6" - -long@4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/long/-/long-4.0.0.tgz#9a7b71cfb7d361a194ea555241c92f7468d5bf28" - integrity sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA== - -lru-cache@^6.0.0: - version "6.0.0" - resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-6.0.0.tgz#6d6fe6570ebd96aaf90fcad1dafa3b2566db3a94" - integrity sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA== - dependencies: - yallist "^4.0.0" - -magic-string@^0.25.7: - version "0.25.9" - resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.25.9.tgz#de7f9faf91ef8a1c91d02c2e5314c8277dbcdd1c" - integrity sha512-RmF0AsMzgt25qzqqLc1+MbHmhdx0ojF2Fvs4XnOqz2ZOBXzzkEwc/dJQZCYHAn7v1jbVOjAZfK8msRn4BxO4VQ== - dependencies: - sourcemap-codec "^1.4.8" - -make-dir@^3.0.0, make-dir@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-3.1.0.tgz#415e967046b3a7f1d185277d84aa58203726a13f" - integrity sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw== - dependencies: - semver "^6.0.0" - -make-error@^1.1.1: - version "1.3.6" - resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.6.tgz#2eb2e37ea9b67c4891f684a1394799af484cf7a2" - integrity sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw== - -map-stream@~0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/map-stream/-/map-stream-0.1.0.tgz#e56aa94c4c8055a16404a0674b78f215f7c8e194" - integrity sha1-5WqpTEyAVaFkBKBnS3jyFffI4ZQ= - -mathjs@^7.5.1: - version "7.6.0" - resolved "https://registry.yarnpkg.com/mathjs/-/mathjs-7.6.0.tgz#f0b7579e0756b13422995d0c4f29bd17d65d4dcc" - integrity sha512-abywR28hUpKF4at5jE8Ys+Kigk40eKMT5mcBLD0/dtsqjfOLbtzd3WjlRqIopNo7oQ6FME51qph6lb8h/bhpUg== - dependencies: - complex.js "^2.0.11" - decimal.js "^10.2.1" - escape-latex "^1.2.0" - fraction.js "^4.0.12" - javascript-natural-sort "^0.7.1" - seed-random "^2.2.0" - tiny-emitter "^2.1.0" - typed-function "^2.0.0" - -md5.js@^1.3.4: - version "1.3.5" - resolved "https://registry.yarnpkg.com/md5.js/-/md5.js-1.3.5.tgz#b5d07b8e3216e3e27cd728d72f70d1e6a342005f" - integrity sha512-xitP+WxNPcTTOgnTJcrhM0xvdPepipPSf3I8EIpGKeFLjt3PlJLIDG3u8EX53ZIubkb+5U2+3rELYpEhHhzdkg== - dependencies: - hash-base "^3.0.0" - inherits "^2.0.1" - safe-buffer "^5.1.2" - -media-typer@0.3.0: - version "0.3.0" - resolved "https://registry.yarnpkg.com/media-typer/-/media-typer-0.3.0.tgz#8710d7af0aa626f8fffa1ce00168545263255748" - integrity sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g= - -miller-rabin@^4.0.0: - version "4.0.1" - resolved "https://registry.yarnpkg.com/miller-rabin/-/miller-rabin-4.0.1.tgz#f080351c865b0dc562a8462966daa53543c78a4d" - integrity sha512-115fLhvZVqWwHPbClyntxEVfVDfl9DLLTuJvq3g2O/Oxi8AiNouAHvDSzHS0viUJc+V5vm3eq91Xwqn9dp4jRA== - dependencies: - bn.js "^4.0.0" - brorand "^1.0.1" - -mime-db@1.52.0: - version "1.52.0" - resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.52.0.tgz#bbabcdc02859f4987301c856e3387ce5ec43bf70" - integrity sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg== - -mime-types@^2.1.12, mime-types@~2.1.19, mime-types@~2.1.24, mime-types@~2.1.34: - version "2.1.35" - resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.35.tgz#381a871b62a734450660ae3deee44813f70d959a" - integrity sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw== - dependencies: - mime-db "1.52.0" - -mime@^2.5.2: - version "2.6.0" - resolved "https://registry.yarnpkg.com/mime/-/mime-2.6.0.tgz#a2a682a95cd4d0cb1d6257e28f83da7e35800367" - integrity sha512-USPkMeET31rOMiarsBNIHZKLGgvKc/LrjofAnBlOttf5ajRvqiRA8QsenbcooctK6d6Ts6aqZXBA+XbkKthiQg== - -minimalistic-assert@^1.0.0, minimalistic-assert@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz#2e194de044626d4a10e7f7fbc00ce73e83e4d5c7" - integrity sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A== - -minimalistic-crypto-utils@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz#f6c00c1c0b082246e5c4d99dfb8c7c083b2b582a" - integrity sha1-9sAMHAsIIkblxNmd+4x8CDsrWCo= - -minimatch@^3.0.4: - version "3.1.2" - resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b" - integrity sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw== - dependencies: - brace-expansion "^1.1.7" - -minimist@^1.2.6: - version "1.2.6" - resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.6.tgz#8637a5b759ea0d6e98702cfb3a9283323c93af44" - integrity sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q== - -minipass@^2.6.0, minipass@^2.9.0: - version "2.9.0" - resolved "https://registry.yarnpkg.com/minipass/-/minipass-2.9.0.tgz#e713762e7d3e32fed803115cf93e04bca9fcc9a6" - integrity sha512-wxfUjg9WebH+CUDX/CdbRlh5SmfZiy/hpkxaRI16Y9W56Pa75sWgd/rvFilSgrauD9NyFymP/+JFV3KwzIsJeg== - dependencies: - safe-buffer "^5.1.2" - yallist "^3.0.0" - -minipass@^3.0.0: - version "3.1.6" - resolved "https://registry.yarnpkg.com/minipass/-/minipass-3.1.6.tgz#3b8150aa688a711a1521af5e8779c1d3bb4f45ee" - integrity sha512-rty5kpw9/z8SX9dmxblFA6edItUmwJgMeYDZRrwlIVN27i8gysGbznJwUggw2V/FVqFSDdWy040ZPS811DYAqQ== - dependencies: - yallist "^4.0.0" - -minizlib@^1.3.3: - version "1.3.3" - resolved "https://registry.yarnpkg.com/minizlib/-/minizlib-1.3.3.tgz#2290de96818a34c29551c8a8d301216bd65a861d" - integrity sha512-6ZYMOEnmVsdCeTJVE0W9ZD+pVnE8h9Hma/iOwwRDsdQoePpoX56/8B6z3P9VNwppJuBKNRuFDRNRqRWexT9G9Q== - dependencies: - minipass "^2.9.0" - -minizlib@^2.1.1: - version "2.1.2" - resolved "https://registry.yarnpkg.com/minizlib/-/minizlib-2.1.2.tgz#e90d3466ba209b932451508a11ce3d3632145931" - integrity sha512-bAxsR8BVfj60DWXHE3u30oHzfl4G7khkSuPW+qvpd7jFRHm7dLxOjUk1EHACJ/hxLY8phGJ0YhYHZo7jil7Qdg== - dependencies: - minipass "^3.0.0" - yallist "^4.0.0" - -mkdirp@^0.5.3, mkdirp@^0.5.5: - version "0.5.6" - resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.6.tgz#7def03d2432dcae4ba1d611445c48396062255f6" - integrity sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw== - dependencies: - minimist "^1.2.6" - -mkdirp@^1.0.3: - version "1.0.4" - resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-1.0.4.tgz#3eb5ed62622756d79a5f0e2a221dfebad75c2f7e" - integrity sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw== - -ms@2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" - integrity sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g= - -ms@2.1.2: - version "2.1.2" - resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" - integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== - -ms@^2.1.1: - version "2.1.3" - resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2" - integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA== - -negotiator@0.6.3: - version "0.6.3" - resolved "https://registry.yarnpkg.com/negotiator/-/negotiator-0.6.3.tgz#58e323a72fedc0d6f9cd4d31fe49f51479590ccd" - integrity sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg== - -node-fetch@^2.6.7: - version "2.6.7" - resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.7.tgz#24de9fba827e3b4ae44dc8b20256a379160052ad" - integrity sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ== - dependencies: - whatwg-url "^5.0.0" - -node-fetch@~2.6.1: - version "2.6.9" - resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.9.tgz#7c7f744b5cc6eb5fd404e0c7a9fec630a55657e6" - integrity sha512-DJm/CJkZkRjKKj4Zi4BsKVZh3ValV5IR5s7LVZnW+6YMh0W1BfNA8XSs6DLMGYlId5F3KnA70uu2qepcR08Qqg== - dependencies: - whatwg-url "^5.0.0" - -node-releases@^2.0.2: - version "2.0.2" - resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-2.0.2.tgz#7139fe71e2f4f11b47d4d2986aaf8c48699e0c01" - integrity sha512-XxYDdcQ6eKqp/YjI+tb2C5WM2LgjnZrfYg4vgQt49EK268b6gYCHsBLrK2qvJo4FmCtqmKezb0WZFK4fkrZNsg== - -nopt@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/nopt/-/nopt-5.0.0.tgz#530942bb58a512fccafe53fe210f13a25355dc88" - integrity sha512-Tbj67rffqceeLpcRXrT7vKAN8CwfPeIBgM7E6iBkmKLV7bEMwpGgYLGv0jACUsECaa/vuxP0IjEont6umdMgtQ== - dependencies: - abbrev "1" - -normalize-path@^3.0.0, normalize-path@~3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-3.0.0.tgz#0dcd69ff23a1c9b11fd0978316644a0388216a65" - integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA== - -npmlog@^5.0.1: - version "5.0.1" - resolved "https://registry.yarnpkg.com/npmlog/-/npmlog-5.0.1.tgz#f06678e80e29419ad67ab964e0fa69959c1eb8b0" - integrity sha512-AqZtDUWOMKs1G/8lwylVjrdYgqA4d9nu8hc+0gzRxlDb1I10+FHBGMXs6aiQHFdCUUlqH99MUMuLfzWDNDtfxw== - dependencies: - are-we-there-yet "^2.0.0" - console-control-strings "^1.1.0" - gauge "^3.0.0" - set-blocking "^2.0.0" - -oauth-sign@~0.9.0: - version "0.9.0" - resolved "https://registry.yarnpkg.com/oauth-sign/-/oauth-sign-0.9.0.tgz#47a7b016baa68b5fa0ecf3dee08a85c679ac6455" - integrity sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ== - -object-assign@^4, object-assign@^4.1.0, object-assign@^4.1.1: - version "4.1.1" - resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" - integrity sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg== - -object-inspect@^1.11.0, object-inspect@^1.9.0: - version "1.12.0" - resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.12.0.tgz#6e2c120e868fd1fd18cb4f18c31741d0d6e776f0" - integrity sha512-Ho2z80bVIvJloH+YzRmpZVQe87+qASmBUKZDWgx9cu+KDrX2ZDH/3tMy+gXbZETVGs2M8YdxObOh7XAtim9Y0g== - -object-is@^1.0.1: - version "1.1.5" - resolved "https://registry.yarnpkg.com/object-is/-/object-is-1.1.5.tgz#b9deeaa5fc7f1846a0faecdceec138e5778f53ac" - integrity sha512-3cyDsyHgtmi7I7DfSSI2LDp6SK2lwvtbg0p0R1e0RvTqF5ceGx+K2dfSjm1bKDMVCFEDAQvy+o8c6a7VujOddw== - dependencies: - call-bind "^1.0.2" - define-properties "^1.1.3" - -object-keys@^1.0.12, object-keys@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.1.1.tgz#1c47f272df277f3b1daf061677d9c82e2322c60e" - integrity sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA== - -object.assign@^4.1.0, object.assign@^4.1.2: - version "4.1.2" - resolved "https://registry.yarnpkg.com/object.assign/-/object.assign-4.1.2.tgz#0ed54a342eceb37b38ff76eb831a0e788cb63940" - integrity sha512-ixT2L5THXsApyiUPYKmW+2EHpXXe5Ii3M+f4e+aJFAHao5amFRW6J0OO6c/LU8Be47utCx2GL89hxGB6XSmKuQ== - dependencies: - call-bind "^1.0.0" - define-properties "^1.1.3" - has-symbols "^1.0.1" - object-keys "^1.1.1" - -on-finished@~2.3.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/on-finished/-/on-finished-2.3.0.tgz#20f1336481b083cd75337992a16971aa2d906947" - integrity sha1-IPEzZIGwg811M3mSoWlxqi2QaUc= - dependencies: - ee-first "1.1.1" - -once@^1.3.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" - integrity sha1-WDsap3WWHUsROsF9nFC6753Xa9E= - dependencies: - wrappy "1" - -os-browserify@^0.3.0: - version "0.3.0" - resolved "https://registry.yarnpkg.com/os-browserify/-/os-browserify-0.3.0.tgz#854373c7f5c2315914fc9bfc6bd8238fdda1ec27" - integrity sha1-hUNzx/XCMVkU/Jv8a9gjj92h7Cc= - -pad@^3.2.0: - version "3.2.0" - resolved "https://registry.yarnpkg.com/pad/-/pad-3.2.0.tgz#be7a1d1cb6757049b4ad5b70e71977158fea95d1" - integrity sha512-2u0TrjcGbOjBTJpyewEl4hBO3OeX5wWue7eIFPzQTg6wFSvoaHcBTTUY5m+n0hd04gmTCPuY0kCpVIVuw5etwg== - dependencies: - wcwidth "^1.0.1" - -pako@~1.0.5: - version "1.0.11" - resolved "https://registry.yarnpkg.com/pako/-/pako-1.0.11.tgz#6c9599d340d54dfd3946380252a35705a6b992bf" - integrity sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw== - -parse-asn1@^5.0.0, parse-asn1@^5.1.5: - version "5.1.6" - resolved "https://registry.yarnpkg.com/parse-asn1/-/parse-asn1-5.1.6.tgz#385080a3ec13cb62a62d39409cb3e88844cdaed4" - integrity sha512-RnZRo1EPU6JBnra2vGHj0yhp6ebyjBZpmUCLHWiFhxlzvBCCpAuZ7elsBp1PVAbQN0/04VD/19rfzlBSwLstMw== - dependencies: - asn1.js "^5.2.0" - browserify-aes "^1.0.0" - evp_bytestokey "^1.0.0" - pbkdf2 "^3.0.3" - safe-buffer "^5.1.1" - -parse-json@^2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/parse-json/-/parse-json-2.2.0.tgz#f480f40434ef80741f8469099f8dea18f55a4dc9" - integrity sha1-9ID0BDTvgHQfhGkJn43qGPVaTck= - dependencies: - error-ex "^1.2.0" - -parseurl@~1.3.3: - version "1.3.3" - resolved "https://registry.yarnpkg.com/parseurl/-/parseurl-1.3.3.tgz#9da19e7bee8d12dff0513ed5b76957793bc2e8d4" - integrity sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ== - -path-browserify@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/path-browserify/-/path-browserify-1.0.1.tgz#d98454a9c3753d5790860f16f68867b9e46be1fd" - integrity sha512-b7uo2UCUOYZcnF/3ID0lulOJi/bafxa1xPe7ZPsammBSpjSWQkjNxlt635YGS2MiR9GjvuXCtz2emr3jbsz98g== - -path-is-absolute@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" - integrity sha1-F0uSaHNVNP+8es5r9TpanhtcX18= - -path-parse@^1.0.7: - version "1.0.7" - resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.7.tgz#fbc114b60ca42b30d9daf5858e4bd68bbedb6735" - integrity sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw== - -pause-stream@0.0.11: - version "0.0.11" - resolved "https://registry.yarnpkg.com/pause-stream/-/pause-stream-0.0.11.tgz#fe5a34b0cbce12b5aa6a2b403ee2e73b602f1445" - integrity sha1-/lo0sMvOErWqaitAPuLnO2AvFEU= - dependencies: - through "~2.3" - -pbkdf2@^3.0.3: - version "3.1.2" - resolved "https://registry.yarnpkg.com/pbkdf2/-/pbkdf2-3.1.2.tgz#dd822aa0887580e52f1a039dc3eda108efae3075" - integrity sha512-iuh7L6jA7JEGu2WxDwtQP1ddOpaJNC4KlDEFfdQajSGgGPNi4OyDc2R7QnbY2bR9QjBVGwgvTdNJZoE7RaxUMA== - dependencies: - create-hash "^1.1.2" - create-hmac "^1.1.4" - ripemd160 "^2.0.1" - safe-buffer "^5.0.1" - sha.js "^2.4.8" - -performance-now@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b" - integrity sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns= - -picocolors@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/picocolors/-/picocolors-1.0.0.tgz#cb5bdc74ff3f51892236eaf79d68bc44564ab81c" - integrity sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ== - -picomatch@^2.0.4, picomatch@^2.2.1: - version "2.3.1" - resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42" - integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA== - -process-nextick-args@~2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.1.tgz#7820d9b16120cc55ca9ae7792680ae7dba6d7fe2" - integrity sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag== - -process@^0.11.10: - version "0.11.10" - resolved "https://registry.yarnpkg.com/process/-/process-0.11.10.tgz#7332300e840161bda3e69a1d1d91a7d4bc16f182" - integrity sha1-czIwDoQBYb2j5podHZGn1LwW8YI= - -progress@^2.0.0: - version "2.0.3" - resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.3.tgz#7e8cf8d8f5b8f239c1bc68beb4eb78567d572ef8" - integrity sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA== - -ps-tree@=1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/ps-tree/-/ps-tree-1.2.0.tgz#5e7425b89508736cdd4f2224d028f7bb3f722ebd" - integrity sha512-0VnamPPYHl4uaU/nSFeZZpR21QAWRz+sRv4iW9+v/GS/J5U5iZB5BNN6J0RMoOvdx2gWM2+ZFMIm58q24e4UYA== - dependencies: - event-stream "=3.3.4" - -psl@^1.1.28: - version "1.8.0" - resolved "https://registry.yarnpkg.com/psl/-/psl-1.8.0.tgz#9326f8bcfb013adcc005fdff056acce020e51c24" - integrity sha512-RIdOzyoavK+hA18OGGWDqUTsCLhtA7IcZ/6NCs4fFJaHBDab+pDDmDIByWFRQJq2Cd7r1OoQxBGKOaztq+hjIQ== - -public-encrypt@^4.0.0: - version "4.0.3" - resolved "https://registry.yarnpkg.com/public-encrypt/-/public-encrypt-4.0.3.tgz#4fcc9d77a07e48ba7527e7cbe0de33d0701331e0" - integrity sha512-zVpa8oKZSz5bTMTFClc1fQOnyyEzpl5ozpi1B5YcvBrdohMjH2rfsBtyXcuNuwjsDIXmBYlF2N5FlJYhR29t8Q== - dependencies: - bn.js "^4.1.0" - browserify-rsa "^4.0.0" - create-hash "^1.1.0" - parse-asn1 "^5.0.0" - randombytes "^2.0.1" - safe-buffer "^5.1.2" - -punycode@1.3.2: - version "1.3.2" - resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.3.2.tgz#9653a036fb7c1ee42342f2325cceefea3926c48d" - integrity sha1-llOgNvt8HuQjQvIyXM7v6jkmxI0= - -punycode@^2.1.0, punycode@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec" - integrity sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A== - -q@~1.5.0: - version "1.5.1" - resolved "https://registry.yarnpkg.com/q/-/q-1.5.1.tgz#7e32f75b41381291d04611f1bf14109ac00651d7" - integrity sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc= - -qjobs@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/qjobs/-/qjobs-1.2.0.tgz#c45e9c61800bd087ef88d7e256423bdd49e5d071" - integrity sha512-8YOJEHtxpySA3fFDyCRxA+UUV+fA+rTWnuWvylOK/NCjhY+b4ocCtmu8TtsWb+mYeU+GCHf/S66KZF/AsteKHg== - -qs@6.9.7: - version "6.9.7" - resolved "https://registry.yarnpkg.com/qs/-/qs-6.9.7.tgz#4610846871485e1e048f44ae3b94033f0e675afe" - integrity sha512-IhMFgUmuNpyRfxA90umL7ByLlgRXu6tIfKPpF5TmcfRLlLCckfP/g3IQmju6jjpu+Hh8rA+2p6A27ZSPOOHdKw== - -qs@~6.5.2: - version "6.5.3" - resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.3.tgz#3aeeffc91967ef6e35c0e488ef46fb296ab76aad" - integrity sha512-qxXIEh4pCGfHICj1mAJQ2/2XVZkjCDTcEgfoSQxc/fYivUZxTkk7L3bDBJSoNrEzXI17oUO5Dp07ktqE5KzczA== - -querystring-es3@^0.2.1: - version "0.2.1" - resolved "https://registry.yarnpkg.com/querystring-es3/-/querystring-es3-0.2.1.tgz#9ec61f79049875707d69414596fd907a4d711e73" - integrity sha1-nsYfeQSYdXB9aUFFlv2Qek1xHnM= - -querystring@0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/querystring/-/querystring-0.2.0.tgz#b209849203bb25df820da756e747005878521620" - integrity sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA= - -randombytes@^2.0.0, randombytes@^2.0.1, randombytes@^2.0.5: - version "2.1.0" - resolved "https://registry.yarnpkg.com/randombytes/-/randombytes-2.1.0.tgz#df6f84372f0270dc65cdf6291349ab7a473d4f2a" - integrity sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ== - dependencies: - safe-buffer "^5.1.0" - -randomfill@^1.0.3: - version "1.0.4" - resolved "https://registry.yarnpkg.com/randomfill/-/randomfill-1.0.4.tgz#c92196fc86ab42be983f1bf31778224931d61458" - integrity sha512-87lcbR8+MhcWcUiQ+9e+Rwx8MyR2P7qnt15ynUlbm3TU/fjbgz4GsvfSUDTemtCCtVCqb4ZcEFlyPNTh9bBTLw== - dependencies: - randombytes "^2.0.5" - safe-buffer "^5.1.0" - -range-parser@^1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/range-parser/-/range-parser-1.2.1.tgz#3cf37023d199e1c24d1a55b84800c2f3e6468031" - integrity sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg== - -raw-body@2.4.3: - version "2.4.3" - resolved "https://registry.yarnpkg.com/raw-body/-/raw-body-2.4.3.tgz#8f80305d11c2a0a545c2d9d89d7a0286fcead43c" - integrity sha512-UlTNLIcu0uzb4D2f4WltY6cVjLi+/jEN4lgEUj3E04tpMDpUlkBo/eSn6zou9hum2VMNpCCUone0O0WeJim07g== - dependencies: - bytes "3.1.2" - http-errors "1.8.1" - iconv-lite "0.4.24" - unpipe "1.0.0" - -readable-stream@^3.1.1, readable-stream@^3.5.0, readable-stream@^3.6.0: - version "3.6.0" - resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-3.6.0.tgz#337bbda3adc0706bd3e024426a286d4b4b2c9198" - integrity sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA== - dependencies: - inherits "^2.0.3" - string_decoder "^1.1.1" - util-deprecate "^1.0.1" - -readable-stream@~2.3.6: - version "2.3.7" - resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.7.tgz#1eca1cf711aef814c04f62252a36a62f6cb23b57" - integrity sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw== - dependencies: - core-util-is "~1.0.0" - inherits "~2.0.3" - isarray "~1.0.0" - process-nextick-args "~2.0.0" - safe-buffer "~5.1.1" - string_decoder "~1.1.1" - util-deprecate "~1.0.1" - -readdirp@~3.6.0: - version "3.6.0" - resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-3.6.0.tgz#74a370bd857116e245b29cc97340cd431a02a6c7" - integrity sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA== - dependencies: - picomatch "^2.2.1" - -regenerate-unicode-properties@^10.0.1: - version "10.0.1" - resolved "https://registry.yarnpkg.com/regenerate-unicode-properties/-/regenerate-unicode-properties-10.0.1.tgz#7f442732aa7934a3740c779bb9b3340dccc1fb56" - integrity sha512-vn5DU6yg6h8hP/2OkQo3K7uVILvY4iu0oI4t3HFa81UPkhGJwkRwM10JEc3upjdhHjs/k8GJY1sRBhk5sr69Bw== - dependencies: - regenerate "^1.4.2" - -regenerate@^1.4.2: - version "1.4.2" - resolved "https://registry.yarnpkg.com/regenerate/-/regenerate-1.4.2.tgz#b9346d8827e8f5a32f7ba29637d398b69014848a" - integrity sha512-zrceR/XhGYU/d/opr2EKO7aRHUeiBI8qjtfHqADTwZd6Szfy16la6kqD0MIUs5z5hx6AaKa+PixpPrR289+I0A== - -regenerator-runtime@^0.13.4, regenerator-runtime@^0.13.5: - version "0.13.9" - resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.9.tgz#8925742a98ffd90814988d7566ad30ca3b263b52" - integrity sha512-p3VT+cOEgxFsRRA9X4lkI1E+k2/CtnKtU4gcxyaCUreilL/vqI6CdZ3wxVUx3UOUg+gnUOQQcRI7BmSI656MYA== - -regenerator-transform@^0.14.2: - version "0.14.5" - resolved "https://registry.yarnpkg.com/regenerator-transform/-/regenerator-transform-0.14.5.tgz#c98da154683671c9c4dcb16ece736517e1b7feb4" - integrity sha512-eOf6vka5IO151Jfsw2NO9WpGX58W6wWmefK3I1zEGr0lOD0u8rwPaNqQL1aRxUaxLeKO3ArNh3VYg1KbaD+FFw== - dependencies: - "@babel/runtime" "^7.8.4" - -regexpu-core@^5.0.1: - version "5.0.1" - resolved "https://registry.yarnpkg.com/regexpu-core/-/regexpu-core-5.0.1.tgz#c531122a7840de743dcf9c83e923b5560323ced3" - integrity sha512-CriEZlrKK9VJw/xQGJpQM5rY88BtuL8DM+AEwvcThHilbxiTAy8vq4iJnd2tqq8wLmjbGZzP7ZcKFjbGkmEFrw== - dependencies: - regenerate "^1.4.2" - regenerate-unicode-properties "^10.0.1" - regjsgen "^0.6.0" - regjsparser "^0.8.2" - unicode-match-property-ecmascript "^2.0.0" - unicode-match-property-value-ecmascript "^2.0.0" - -regjsgen@^0.6.0: - version "0.6.0" - resolved "https://registry.yarnpkg.com/regjsgen/-/regjsgen-0.6.0.tgz#83414c5354afd7d6627b16af5f10f41c4e71808d" - integrity sha512-ozE883Uigtqj3bx7OhL1KNbCzGyW2NQZPl6Hs09WTvCuZD5sTI4JY58bkbQWa/Y9hxIsvJ3M8Nbf7j54IqeZbA== - -regjsparser@^0.8.2: - version "0.8.4" - resolved "https://registry.yarnpkg.com/regjsparser/-/regjsparser-0.8.4.tgz#8a14285ffcc5de78c5b95d62bbf413b6bc132d5f" - integrity sha512-J3LABycON/VNEu3abOviqGHuB/LOtOQj8SKmfP9anY5GfAVw/SPjwzSjxGjbZXIxbGfqTHtJw58C2Li/WkStmA== - dependencies: - jsesc "~0.5.0" - -request@^2.88.0: - version "2.88.2" - resolved "https://registry.yarnpkg.com/request/-/request-2.88.2.tgz#d73c918731cb5a87da047e207234146f664d12b3" - integrity sha512-MsvtOrfG9ZcrOwAW+Qi+F6HbD0CWXEh9ou77uOb7FM2WPhwT7smM833PzanhJLsgXjN89Ir6V2PczXNnMpwKhw== - dependencies: - aws-sign2 "~0.7.0" - aws4 "^1.8.0" - caseless "~0.12.0" - combined-stream "~1.0.6" - extend "~3.0.2" - forever-agent "~0.6.1" - form-data "~2.3.2" - har-validator "~5.1.3" - http-signature "~1.2.0" - is-typedarray "~1.0.0" - isstream "~0.1.2" - json-stringify-safe "~5.0.1" - mime-types "~2.1.19" - oauth-sign "~0.9.0" - performance-now "^2.1.0" - qs "~6.5.2" - safe-buffer "^5.1.2" - tough-cookie "~2.5.0" - tunnel-agent "^0.6.0" - uuid "^3.3.2" - -require-directory@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42" - integrity sha1-jGStX9MNqxyXbiNE/+f3kqam30I= - -requires-port@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/requires-port/-/requires-port-1.0.0.tgz#925d2601d39ac485e091cf0da5c6e694dc3dcaff" - integrity sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8= - -resolve@^1.1.6, resolve@^1.14.2, resolve@^1.17.0, resolve@^1.3.2: - version "1.22.0" - resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.22.0.tgz#5e0b8c67c15df57a89bdbabe603a002f21731198" - integrity sha512-Hhtrw0nLeSrFQ7phPp4OOcVjLPIeMnRlr5mcnVuMe7M/7eBn98A3hmFRLoFo3DLZkivSYwhRUJTyPyWAk56WLw== - dependencies: - is-core-module "^2.8.1" - path-parse "^1.0.7" - supports-preserve-symlinks-flag "^1.0.0" - -rfdc@^1.3.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/rfdc/-/rfdc-1.3.0.tgz#d0b7c441ab2720d05dc4cf26e01c89631d9da08b" - integrity sha512-V2hovdzFbOi77/WajaSMXk2OLm+xNIeQdMMuB7icj7bk6zi2F8GGAxigcnDFpJHbNyNcgyJDiP+8nOrY5cZGrA== - -rimraf@^2.6.2: - version "2.7.1" - resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.7.1.tgz#35797f13a7fdadc566142c29d4f07ccad483e3ec" - integrity sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w== - dependencies: - glob "^7.1.3" - -rimraf@^3.0.0, rimraf@^3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-3.0.2.tgz#f1a5402ba6220ad52cc1282bac1ae3aa49fd061a" - integrity sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA== - dependencies: - glob "^7.1.3" - -rimraf@~2.5.2: - version "2.5.4" - resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.5.4.tgz#96800093cbf1a0c86bd95b4625467535c29dfa04" - integrity sha1-loAAk8vxoMhr2VtGJUZ1NcKd+gQ= - dependencies: - glob "^7.0.5" - -ripemd160@^2.0.0, ripemd160@^2.0.1: - version "2.0.2" - resolved "https://registry.yarnpkg.com/ripemd160/-/ripemd160-2.0.2.tgz#a1c1a6f624751577ba5d07914cbc92850585890c" - integrity sha512-ii4iagi25WusVoiC4B4lq7pbXfAp3D9v5CwfkY33vffw2+pkDjY1D8GaN7spsxvCSx8dkPqOZCEZyfxcmJG2IA== - dependencies: - hash-base "^3.0.0" - inherits "^2.0.1" - -safe-buffer@^5.0.1, safe-buffer@^5.1.0, safe-buffer@^5.1.1, safe-buffer@^5.1.2, safe-buffer@^5.2.0, safe-buffer@^5.2.1, safe-buffer@~5.2.0: - version "5.2.1" - resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" - integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== - -safe-buffer@~5.1.0, safe-buffer@~5.1.1: - version "5.1.2" - resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" - integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g== - -"safer-buffer@>= 2.1.2 < 3", safer-buffer@^2.0.2, safer-buffer@^2.1.0, safer-buffer@~2.1.0: - version "2.1.2" - resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a" - integrity sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg== - -seed-random@^2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/seed-random/-/seed-random-2.2.0.tgz#2a9b19e250a817099231a5b99a4daf80b7fbed54" - integrity sha1-KpsZ4lCoFwmSMaW5mk2vgLf77VQ= - -seedrandom@^3.0.5: - version "3.0.5" - resolved "https://registry.yarnpkg.com/seedrandom/-/seedrandom-3.0.5.tgz#54edc85c95222525b0c7a6f6b3543d8e0b3aa0a7" - integrity sha512-8OwmbklUNzwezjGInmZ+2clQmExQPvomqjL7LFqOYqtmuxRgQYqOD3mHaU+MvZn5FLUeVxVfQjwLZW/n/JFuqg== - -semver@7.0.0: - version "7.0.0" - resolved "https://registry.yarnpkg.com/semver/-/semver-7.0.0.tgz#5f3ca35761e47e05b206c6daff2cf814f0316b8e" - integrity sha512-+GB6zVA9LWh6zovYQLALHwv5rb2PHGlJi3lfiqIHxR0uuwCgefcOJc59v9fv1w8GbStwxuuqqAjI9NMAOOgq1A== - -semver@^5.1.0, semver@^5.3.0: - version "5.7.1" - resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" - integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ== - -semver@^6.0.0, semver@^6.1.1, semver@^6.1.2, semver@^6.3.0: - version "6.3.0" - resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d" - integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw== - -semver@^7.3.5: - version "7.3.7" - resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.7.tgz#12c5b649afdbf9049707796e22a4028814ce523f" - integrity sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g== - dependencies: - lru-cache "^6.0.0" - -set-blocking@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7" - integrity sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw== - -setimmediate@^1.0.4: - version "1.0.5" - resolved "https://registry.yarnpkg.com/setimmediate/-/setimmediate-1.0.5.tgz#290cbb232e306942d7d7ea9b83732ab7856f8285" - integrity sha1-KQy7Iy4waULX1+qbg3Mqt4VvgoU= - -setprototypeof@1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/setprototypeof/-/setprototypeof-1.2.0.tgz#66c9a24a73f9fc28cbe66b09fed3d33dcaf1b424" - integrity sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw== - -sha.js@^2.4.0, sha.js@^2.4.8: - version "2.4.11" - resolved "https://registry.yarnpkg.com/sha.js/-/sha.js-2.4.11.tgz#37a5cf0b81ecbc6943de109ba2960d1b26584ae7" - integrity sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ== - dependencies: - inherits "^2.0.1" - safe-buffer "^5.0.1" - -side-channel@^1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/side-channel/-/side-channel-1.0.4.tgz#efce5c8fdc104ee751b25c58d4290011fa5ea2cf" - integrity sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw== - dependencies: - call-bind "^1.0.0" - get-intrinsic "^1.0.2" - object-inspect "^1.9.0" - -signal-exit@^3.0.0: - version "3.0.7" - resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.7.tgz#a9a1767f8af84155114eaabd73f99273c8f59ad9" - integrity sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ== - -socket.io-adapter@~2.4.0: - version "2.4.0" - resolved "https://registry.yarnpkg.com/socket.io-adapter/-/socket.io-adapter-2.4.0.tgz#b50a4a9ecdd00c34d4c8c808224daa1a786152a6" - integrity sha512-W4N+o69rkMEGVuk2D/cvca3uYsvGlMwsySWV447y99gUPghxq42BxqLNMndb+a1mm/5/7NeXVQS7RLa2XyXvYg== - -socket.io-parser@~4.0.4: - version "4.0.5" - resolved "https://registry.yarnpkg.com/socket.io-parser/-/socket.io-parser-4.0.5.tgz#cb404382c32324cc962f27f3a44058cf6e0552df" - integrity sha512-sNjbT9dX63nqUFIOv95tTVm6elyIU4RvB1m8dOeZt+IgWwcWklFDOdmGcfo3zSiRsnR/3pJkjY5lfoGqEe4Eig== - dependencies: - "@types/component-emitter" "^1.2.10" - component-emitter "~1.3.0" - debug "~4.3.1" - -socket.io@^4.4.1: - version "4.5.1" - resolved "https://registry.yarnpkg.com/socket.io/-/socket.io-4.5.1.tgz#aa7e73f8a6ce20ee3c54b2446d321bbb6b1a9029" - integrity sha512-0y9pnIso5a9i+lJmsCdtmTTgJFFSvNQKDnPQRz28mGNnxbmqYg2QPtJTLFxhymFZhAIn50eHAKzJeiNaKr+yUQ== - dependencies: - accepts "~1.3.4" - base64id "~2.0.0" - debug "~4.3.2" - engine.io "~6.2.0" - socket.io-adapter "~2.4.0" - socket.io-parser "~4.0.4" - -source-map@^0.5.0, source-map@~0.5.3: - version "0.5.7" - resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" - integrity sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w= - -source-map@^0.6.1: - version "0.6.1" - resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" - integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== - -source-map@^0.7.3: - version "0.7.3" - resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.7.3.tgz#5302f8169031735226544092e64981f751750383" - integrity sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ== - -sourcemap-codec@^1.4.8: - version "1.4.8" - resolved "https://registry.yarnpkg.com/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz#ea804bd94857402e6992d05a38ef1ae35a9ab4c4" - integrity sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA== - -split@0.3: - version "0.3.3" - resolved "https://registry.yarnpkg.com/split/-/split-0.3.3.tgz#cd0eea5e63a211dfff7eb0f091c4133e2d0dd28f" - integrity sha1-zQ7qXmOiEd//frDwkcQTPi0N0o8= - dependencies: - through "2" - -sprintf-js@~1.0.2: - version "1.0.3" - resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" - integrity sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw= - -sshpk@^1.7.0: - version "1.17.0" - resolved "https://registry.yarnpkg.com/sshpk/-/sshpk-1.17.0.tgz#578082d92d4fe612b13007496e543fa0fbcbe4c5" - integrity sha512-/9HIEs1ZXGhSPE8X6Ccm7Nam1z8KcoCqPdI7ecm1N33EzAetWahvQWVqLZtaZQ+IDKX4IyA2o0gBzqIMkAagHQ== - dependencies: - asn1 "~0.2.3" - assert-plus "^1.0.0" - bcrypt-pbkdf "^1.0.0" - dashdash "^1.12.0" - ecc-jsbn "~0.1.1" - getpass "^0.1.1" - jsbn "~0.1.0" - safer-buffer "^2.0.2" - tweetnacl "~0.14.0" - -"statuses@>= 1.5.0 < 2", statuses@~1.5.0: - version "1.5.0" - resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.5.0.tgz#161c7dac177659fd9811f43771fa99381478628c" - integrity sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow= - -stream-browserify@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/stream-browserify/-/stream-browserify-3.0.0.tgz#22b0a2850cdf6503e73085da1fc7b7d0c2122f2f" - integrity sha512-H73RAHsVBapbim0tU2JwwOiXUj+fikfiaoYAKHF3VJfA0pe2BCzkhAHBlLG6REzE+2WNZcxOXjK7lkso+9euLA== - dependencies: - inherits "~2.0.4" - readable-stream "^3.5.0" - -stream-combiner@~0.0.4: - version "0.0.4" - resolved "https://registry.yarnpkg.com/stream-combiner/-/stream-combiner-0.0.4.tgz#4d5e433c185261dde623ca3f44c586bcf5c4ad14" - integrity sha1-TV5DPBhSYd3mI8o/RMWGvPXErRQ= - dependencies: - duplexer "~0.1.1" - -stream-http@^3.1.0: - version "3.2.0" - resolved "https://registry.yarnpkg.com/stream-http/-/stream-http-3.2.0.tgz#1872dfcf24cb15752677e40e5c3f9cc1926028b5" - integrity sha512-Oq1bLqisTyK3TSCXpPbT4sdeYNdmyZJv1LxpEm2vu1ZhK89kSE5YXwZc3cWk0MagGaKriBh9mCFbVGtO+vY29A== - dependencies: - builtin-status-codes "^3.0.0" - inherits "^2.0.4" - readable-stream "^3.6.0" - xtend "^4.0.2" - -streamroller@^3.0.6: - version "3.0.6" - resolved "https://registry.yarnpkg.com/streamroller/-/streamroller-3.0.6.tgz#52823415800ded79a49aa3f7712f50a422b97493" - integrity sha512-Qz32plKq/MZywYyhEatxyYc8vs994Gz0Hu2MSYXXLD233UyPeIeRBZARIIGwFer4Mdb8r3Y2UqKkgyDghM6QCg== - dependencies: - date-format "^4.0.6" - debug "^4.3.4" - fs-extra "^10.0.1" - -"string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3: - version "4.2.3" - resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" - integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== - dependencies: - emoji-regex "^8.0.0" - is-fullwidth-code-point "^3.0.0" - strip-ansi "^6.0.1" - -string.prototype.trimend@^1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/string.prototype.trimend/-/string.prototype.trimend-1.0.4.tgz#e75ae90c2942c63504686c18b287b4a0b1a45f80" - integrity sha512-y9xCjw1P23Awk8EvTpcyL2NIr1j7wJ39f+k6lvRnSMz+mz9CGz9NYPelDk42kOz6+ql8xjfK8oYzy3jAP5QU5A== - dependencies: - call-bind "^1.0.2" - define-properties "^1.1.3" - -string.prototype.trimstart@^1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/string.prototype.trimstart/-/string.prototype.trimstart-1.0.4.tgz#b36399af4ab2999b4c9c648bd7a3fb2bb26feeed" - integrity sha512-jh6e984OBfvxS50tdY2nRZnoC5/mLFKOREQfw8t5yytkoUsJRNxvI/E39qu1sD0OtWI3OC0XgKSmcWwziwYuZw== - dependencies: - call-bind "^1.0.2" - define-properties "^1.1.3" - -string_decoder@^1.1.1, string_decoder@^1.3.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.3.0.tgz#42f114594a46cf1a8e30b0a84f56c78c3edac21e" - integrity sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA== - dependencies: - safe-buffer "~5.2.0" - -string_decoder@~1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.1.1.tgz#9cf1611ba62685d7030ae9e4ba34149c3af03fc8" - integrity sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg== - dependencies: - safe-buffer "~5.1.0" - -strip-ansi@^6.0.0, strip-ansi@^6.0.1: - version "6.0.1" - resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" - integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== - dependencies: - ansi-regex "^5.0.1" - -strip-bom@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-2.0.0.tgz#6219a85616520491f35788bdbf1447a99c7e6b0e" - integrity sha1-YhmoVhZSBJHzV4i9vxRHqZx+aw4= - dependencies: - is-utf8 "^0.2.0" - -strip-json-comments@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a" - integrity sha1-PFMZQukIwml8DsNEhYwobHygpgo= - -supports-color@^5.3.0: - version "5.5.0" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f" - integrity sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow== - dependencies: - has-flag "^3.0.0" - -supports-color@^7.1.0: - version "7.2.0" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-7.2.0.tgz#1b7dcdcb32b8138801b3e478ba6a51caa89648da" - integrity sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw== - dependencies: - has-flag "^4.0.0" - -supports-preserve-symlinks-flag@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz#6eda4bd344a3c94aea376d4cc31bc77311039e09" - integrity sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w== - -tar@^4.4.6: - version "4.4.19" - resolved "https://registry.yarnpkg.com/tar/-/tar-4.4.19.tgz#2e4d7263df26f2b914dee10c825ab132123742f3" - integrity sha512-a20gEsvHnWe0ygBY8JbxoM4w3SJdhc7ZAuxkLqh+nvNQN2IOt0B5lLgM490X5Hl8FF0dl0tOf2ewFYAlIFgzVA== - dependencies: - chownr "^1.1.4" - fs-minipass "^1.2.7" - minipass "^2.9.0" - minizlib "^1.3.3" - mkdirp "^0.5.5" - safe-buffer "^5.2.1" - yallist "^3.1.1" - -tar@^6.1.11: - version "6.1.11" - resolved "https://registry.yarnpkg.com/tar/-/tar-6.1.11.tgz#6760a38f003afa1b2ffd0ffe9e9abbd0eab3d621" - integrity sha512-an/KZQzQUkZCkuoAA64hM92X0Urb6VpRhAFllDzz44U2mcD5scmT3zBc4VgVpkugF580+DQn8eAFSyoQt0tznA== - dependencies: - chownr "^2.0.0" - fs-minipass "^2.0.0" - minipass "^3.0.0" - minizlib "^2.1.1" - mkdirp "^1.0.3" - yallist "^4.0.0" - -temp-fs@^0.9.9: - version "0.9.9" - resolved "https://registry.yarnpkg.com/temp-fs/-/temp-fs-0.9.9.tgz#8071730437870720e9431532fe2814364f8803d7" - integrity sha1-gHFzBDeHByDpQxUy/igUNk+IA9c= - dependencies: - rimraf "~2.5.2" - -through2@^2.0.0: - version "2.0.5" - resolved "https://registry.yarnpkg.com/through2/-/through2-2.0.5.tgz#01c1e39eb31d07cb7d03a96a70823260b23132cd" - integrity sha512-/mrRod8xqpA+IHSLyGCQ2s8SPHiCDEeQJSep1jqLYeEUClOFG2Qsh+4FU6G9VeqpZnGW/Su8LQGc4YKni5rYSQ== - dependencies: - readable-stream "~2.3.6" - xtend "~4.0.1" - -through@2, through@~2.3, through@~2.3.1: - version "2.3.8" - resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5" - integrity sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU= - -timers-browserify@^2.0.11: - version "2.0.12" - resolved "https://registry.yarnpkg.com/timers-browserify/-/timers-browserify-2.0.12.tgz#44a45c11fbf407f34f97bccd1577c652361b00ee" - integrity sha512-9phl76Cqm6FhSX9Xe1ZUAMLtm1BLkKj2Qd5ApyWkXzsMRaA7dgr81kf4wJmQf/hAvg8EEyJxDo3du/0KlhPiKQ== - dependencies: - setimmediate "^1.0.4" - -tiny-emitter@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/tiny-emitter/-/tiny-emitter-2.1.0.tgz#1d1a56edfc51c43e863cbb5382a72330e3555423" - integrity sha512-NB6Dk1A9xgQPMoGqC5CVXn123gWyte215ONT5Pp5a0yt4nlEoO1ZWeCwpncaekPHXO60i47ihFnZPiRPjRMq4Q== - -tmp@^0.2.1: - version "0.2.1" - resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.2.1.tgz#8457fc3037dcf4719c251367a1af6500ee1ccf14" - integrity sha512-76SUhtfqR2Ijn+xllcI5P1oyannHNHByD80W1q447gU3mp9G9PSpGdWmjUOHRDPiHYacIk66W7ubDTuPF3BEtQ== - dependencies: - rimraf "^3.0.0" - -to-fast-properties@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/to-fast-properties/-/to-fast-properties-2.0.0.tgz#dc5e698cbd079265bc73e0377681a4e4e83f616e" - integrity sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4= - -to-regex-range@^5.0.1: - version "5.0.1" - resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-5.0.1.tgz#1648c44aae7c8d988a326018ed72f5b4dd0392e4" - integrity sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ== - dependencies: - is-number "^7.0.0" - -toidentifier@1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/toidentifier/-/toidentifier-1.0.1.tgz#3be34321a88a820ed1bd80dfaa33e479fbb8dd35" - integrity sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA== - -tough-cookie@~2.5.0: - version "2.5.0" - resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.5.0.tgz#cd9fb2a0aa1d5a12b473bd9fb96fa3dcff65ade2" - integrity sha512-nlLsUzgm1kfLXSXfRZMc1KLAugd4hqJHDTvc2hDIwS3mZAfMEuMbc03SujMF+GEcpaX/qboeycw6iO8JwVv2+g== - dependencies: - psl "^1.1.28" - punycode "^2.1.1" - -tr46@~0.0.3: - version "0.0.3" - resolved "https://registry.yarnpkg.com/tr46/-/tr46-0.0.3.tgz#8184fd347dac9cdc185992f3a6622e14b9d9ab6a" - integrity sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o= - -ts-node@^10.9.1: - version "10.9.1" - resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-10.9.1.tgz#e73de9102958af9e1f0b168a6ff320e25adcff4b" - integrity sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw== - dependencies: - "@cspotcode/source-map-support" "^0.8.0" - "@tsconfig/node10" "^1.0.7" - "@tsconfig/node12" "^1.0.7" - "@tsconfig/node14" "^1.0.0" - "@tsconfig/node16" "^1.0.2" - acorn "^8.4.1" - acorn-walk "^8.1.1" - arg "^4.1.0" - create-require "^1.1.0" - diff "^4.0.1" - make-error "^1.1.1" - v8-compile-cache-lib "^3.0.1" - yn "3.1.1" - -tsconfig@^5.0.3: - version "5.0.3" - resolved "https://registry.yarnpkg.com/tsconfig/-/tsconfig-5.0.3.tgz#5f4278e701800967a8fc383fd19648878f2a6e3a" - integrity sha1-X0J45wGACWeo/Dg/0ZZIh48qbjo= - dependencies: - any-promise "^1.3.0" - parse-json "^2.2.0" - strip-bom "^2.0.0" - strip-json-comments "^2.0.0" - -tsify@^3.0.4: - version "3.0.4" - resolved "https://registry.yarnpkg.com/tsify/-/tsify-3.0.4.tgz#3c862c934aeeff705290de9ad2af8d197ac5bb03" - integrity sha512-y75+qgB41YS8HJck+jmSIn395I4qRGtm5ZELzvNh80Llzh8ojPWp47jm0ZoIJesNYVzbqEyLzgYXV9d/calvVg== - dependencies: - convert-source-map "^1.1.0" - fs.realpath "^1.0.0" - object-assign "^4.1.0" - semver "^5.1.0" - through2 "^2.0.0" - tsconfig "^5.0.3" - -tslib@^1.13.0, tslib@^1.8.1: - version "1.14.1" - resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00" - integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg== - -tslint-no-circular-imports@~0.7.0: - version "0.7.0" - resolved "https://registry.yarnpkg.com/tslint-no-circular-imports/-/tslint-no-circular-imports-0.7.0.tgz#9df0a15654d66b172e0b7843eed073fa5ae99b5f" - integrity sha512-k3wxpeMC4ef40UbpfBVHEHIzKfNZq5/SCtAO1YjGsaNTklo+K53/TWLrym+poA65RJFDiYgYNWvkeIIkJNA0Vw== - -tslint@^6.1.3: - version "6.1.3" - resolved "https://registry.yarnpkg.com/tslint/-/tslint-6.1.3.tgz#5c23b2eccc32487d5523bd3a470e9aa31789d904" - integrity sha512-IbR4nkT96EQOvKE2PW/djGz8iGNeJ4rF2mBfiYaR/nvUWYKJhLwimoJKgjIFEIDibBtOevj7BqCRL4oHeWWUCg== - dependencies: - "@babel/code-frame" "^7.0.0" - builtin-modules "^1.1.1" - chalk "^2.3.0" - commander "^2.12.1" - diff "^4.0.1" - glob "^7.1.1" - js-yaml "^3.13.1" - minimatch "^3.0.4" - mkdirp "^0.5.3" - resolve "^1.3.2" - semver "^5.3.0" - tslib "^1.13.0" - tsutils "^2.29.0" - -tsutils@^2.29.0: - version "2.29.0" - resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-2.29.0.tgz#32b488501467acbedd4b85498673a0812aca0b99" - integrity sha512-g5JVHCIJwzfISaXpXE1qvNalca5Jwob6FjI4AoPlqMusJ6ftFE7IkkFoMhVLRgK+4Kx3gkzb8UZK5t5yTTvEmA== - dependencies: - tslib "^1.8.1" - -tty-browserify@^0.0.1: - version "0.0.1" - resolved "https://registry.yarnpkg.com/tty-browserify/-/tty-browserify-0.0.1.tgz#3f05251ee17904dfd0677546670db9651682b811" - integrity sha512-C3TaO7K81YvjCgQH9Q1S3R3P3BtN3RIM8n+OvX4il1K1zgE8ZhI0op7kClgkxtutIE8hQrcrHBXvIheqKUUCxw== - -tunnel-agent@^0.6.0: - version "0.6.0" - resolved "https://registry.yarnpkg.com/tunnel-agent/-/tunnel-agent-0.6.0.tgz#27a5dea06b36b04a0a9966774b290868f0fc40fd" - integrity sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0= - dependencies: - safe-buffer "^5.0.1" - -tweetnacl@^0.14.3, tweetnacl@~0.14.0: - version "0.14.5" - resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-0.14.5.tgz#5ae68177f192d4456269d108afa93ff8743f4f64" - integrity sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q= - -type-is@~1.6.18: - version "1.6.18" - resolved "https://registry.yarnpkg.com/type-is/-/type-is-1.6.18.tgz#4e552cd05df09467dcbc4ef739de89f2cf37c131" - integrity sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g== - dependencies: - media-typer "0.3.0" - mime-types "~2.1.24" - -typed-function@^2.0.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/typed-function/-/typed-function-2.1.0.tgz#ded6f8a442ba8749ff3fe75bc41419c8d46ccc3f" - integrity sha512-bctQIOqx2iVbWGDGPWwIm18QScpu2XRmkC19D8rQGFsjKSgteq/o1hTZvIG/wuDq8fanpBDrLkLq+aEN/6y5XQ== - -typescript@5.0.4: - version "5.0.4" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.0.4.tgz#b217fd20119bd61a94d4011274e0ab369058da3b" - integrity sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw== - -ua-parser-js@^0.7.30: - version "0.7.33" - resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.33.tgz#1d04acb4ccef9293df6f70f2c3d22f3030d8b532" - integrity sha512-s8ax/CeZdK9R/56Sui0WM6y9OFREJarMRHqLB2EwkovemBxNQ+Bqu8GAsUnVcXKgphb++ghr/B2BZx4mahujPw== - -unbox-primitive@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/unbox-primitive/-/unbox-primitive-1.0.1.tgz#085e215625ec3162574dc8859abee78a59b14471" - integrity sha512-tZU/3NqK3dA5gpE1KtyiJUrEB0lxnGkMFHptJ7q6ewdZ8s12QrODwNbhIJStmJkd1QDXa1NRA8aF2A1zk/Ypyw== - dependencies: - function-bind "^1.1.1" - has-bigints "^1.0.1" - has-symbols "^1.0.2" - which-boxed-primitive "^1.0.2" - -unicode-canonical-property-names-ecmascript@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-2.0.0.tgz#301acdc525631670d39f6146e0e77ff6bbdebddc" - integrity sha512-yY5PpDlfVIU5+y/BSCxAJRBIS1Zc2dDG3Ujq+sR0U+JjUevW2JhocOF+soROYDSaAezOzOKuyyixhD6mBknSmQ== - -unicode-match-property-ecmascript@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/unicode-match-property-ecmascript/-/unicode-match-property-ecmascript-2.0.0.tgz#54fd16e0ecb167cf04cf1f756bdcc92eba7976c3" - integrity sha512-5kaZCrbp5mmbz5ulBkDkbY0SsPOjKqVS35VpL9ulMPfSl0J0Xsm+9Evphv9CoIZFwre7aJoa94AY6seMKGVN5Q== - dependencies: - unicode-canonical-property-names-ecmascript "^2.0.0" - unicode-property-aliases-ecmascript "^2.0.0" - -unicode-match-property-value-ecmascript@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/unicode-match-property-value-ecmascript/-/unicode-match-property-value-ecmascript-2.0.0.tgz#1a01aa57247c14c568b89775a54938788189a714" - integrity sha512-7Yhkc0Ye+t4PNYzOGKedDhXbYIBe1XEQYQxOPyhcXNMJ0WCABqqj6ckydd6pWRZTHV4GuCPKdBAUiMc60tsKVw== - -unicode-property-aliases-ecmascript@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/unicode-property-aliases-ecmascript/-/unicode-property-aliases-ecmascript-2.0.0.tgz#0a36cb9a585c4f6abd51ad1deddb285c165297c8" - integrity sha512-5Zfuy9q/DFr4tfO7ZPeVXb1aPoeQSdeFMLpYuFebehDAhbuevLs5yxSZmIFN1tP5F9Wl4IpJrYojg85/zgyZHQ== - -universalify@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/universalify/-/universalify-2.0.0.tgz#75a4984efedc4b08975c5aeb73f530d02df25717" - integrity sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ== - -unpipe@1.0.0, unpipe@~1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/unpipe/-/unpipe-1.0.0.tgz#b2bf4ee8514aae6165b4817829d21b2ef49904ec" - integrity sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw= - -uri-js@^4.2.2: - version "4.4.1" - resolved "https://registry.yarnpkg.com/uri-js/-/uri-js-4.4.1.tgz#9b1a52595225859e55f669d928f88c6c57f2a77e" - integrity sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg== - dependencies: - punycode "^2.1.0" - -url@^0.11.0: - version "0.11.0" - resolved "https://registry.yarnpkg.com/url/-/url-0.11.0.tgz#3838e97cfc60521eb73c525a8e55bfdd9e2e28f1" - integrity sha1-ODjpfPxgUh63PFJajlW/3Z4uKPE= - dependencies: - punycode "1.3.2" - querystring "0.2.0" - -util-deprecate@^1.0.1, util-deprecate@~1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" - integrity sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8= - -util@^0.12.0, util@^0.12.1: - version "0.12.4" - resolved "https://registry.yarnpkg.com/util/-/util-0.12.4.tgz#66121a31420df8f01ca0c464be15dfa1d1850253" - integrity sha512-bxZ9qtSlGUWSOy9Qa9Xgk11kSslpuZwaxCg4sNIDj6FLucDab2JxnHwyNTCpHMtK1MjoQiWQ6DiUMZYbSrO+Sw== - dependencies: - inherits "^2.0.3" - is-arguments "^1.0.4" - is-generator-function "^1.0.7" - is-typed-array "^1.1.3" - safe-buffer "^5.1.2" - which-typed-array "^1.1.2" - -utils-merge@1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/utils-merge/-/utils-merge-1.0.1.tgz#9f95710f50a267947b2ccc124741c1028427e713" - integrity sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM= - -uuid@^3.3.2: - version "3.4.0" - resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.4.0.tgz#b23e4358afa8a202fe7a100af1f5f883f02007ee" - integrity sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A== - -v8-compile-cache-lib@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz#6336e8d71965cb3d35a1bbb7868445a7c05264bf" - integrity sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg== - -vary@^1: - version "1.1.2" - resolved "https://registry.yarnpkg.com/vary/-/vary-1.1.2.tgz#2299f02c6ded30d4a5961b0b9f74524a18f634fc" - integrity sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg== - -verror@1.10.0: - version "1.10.0" - resolved "https://registry.yarnpkg.com/verror/-/verror-1.10.0.tgz#3a105ca17053af55d6e270c1f8288682e18da400" - integrity sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA= - dependencies: - assert-plus "^1.0.0" - core-util-is "1.0.2" - extsprintf "^1.2.0" - -vm-browserify@^1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/vm-browserify/-/vm-browserify-1.1.2.tgz#78641c488b8e6ca91a75f511e7a3b32a86e5dda0" - integrity sha512-2ham8XPWTONajOR0ohOKOHXkm3+gaBmGut3SRuu75xLd/RRaY6vqgh8NBYYk7+RW3u5AtzPQZG8F10LHkl0lAQ== - -void-elements@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/void-elements/-/void-elements-2.0.1.tgz#c066afb582bb1cb4128d60ea92392e94d5e9dbec" - integrity sha1-wGavtYK7HLQSjWDqkjkulNXp2+w= - -wcwidth@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/wcwidth/-/wcwidth-1.0.1.tgz#f0b0dcf915bc5ff1528afadb2c0e17b532da2fe8" - integrity sha1-8LDc+RW8X/FSivrbLA4XtTLaL+g= - dependencies: - defaults "^1.0.3" - -webidl-conversions@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871" - integrity sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE= - -whatwg-url@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-5.0.0.tgz#966454e8765462e37644d3626f6742ce8b70965d" - integrity sha1-lmRU6HZUYuN2RNNib2dCzotwll0= - dependencies: - tr46 "~0.0.3" - webidl-conversions "^3.0.0" - -which-boxed-primitive@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/which-boxed-primitive/-/which-boxed-primitive-1.0.2.tgz#13757bc89b209b049fe5d86430e21cf40a89a8e6" - integrity sha512-bwZdv0AKLpplFY2KZRX6TvyuN7ojjr7lwkg6ml0roIy9YeuSr7JS372qlNW18UQYzgYK9ziGcerWqZOmEn9VNg== - dependencies: - is-bigint "^1.0.1" - is-boolean-object "^1.1.0" - is-number-object "^1.0.4" - is-string "^1.0.5" - is-symbol "^1.0.3" - -which-typed-array@^1.1.2: - version "1.1.7" - resolved "https://registry.yarnpkg.com/which-typed-array/-/which-typed-array-1.1.7.tgz#2761799b9a22d4b8660b3c1b40abaa7739691793" - integrity sha512-vjxaB4nfDqwKI0ws7wZpxIlde1XrLX5uB0ZjpfshgmapJMD7jJWhZI+yToJTqaFByF0eNBcYxbjmCzoRP7CfEw== - dependencies: - available-typed-arrays "^1.0.5" - call-bind "^1.0.2" - es-abstract "^1.18.5" - foreach "^2.0.5" - has-tostringtag "^1.0.0" - is-typed-array "^1.1.7" - -which@^1.2.1: - version "1.3.1" - resolved "https://registry.yarnpkg.com/which/-/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a" - integrity sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ== - dependencies: - isexe "^2.0.0" - -wide-align@^1.1.2: - version "1.1.5" - resolved "https://registry.yarnpkg.com/wide-align/-/wide-align-1.1.5.tgz#df1d4c206854369ecf3c9a4898f1b23fbd9d15d3" - integrity sha512-eDMORYaPNZ4sQIuuYPDHdQvf4gyCF9rEEV/yPxGfwPkRodwEgiMUUXTx/dex+Me0wxx53S+NgUHaP7y3MGlDmg== - dependencies: - string-width "^1.0.2 || 2 || 3 || 4" - -wrap-ansi@^7.0.0: - version "7.0.0" - resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" - integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== - dependencies: - ansi-styles "^4.0.0" - string-width "^4.1.0" - strip-ansi "^6.0.0" - -wrappy@1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" - integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8= - -ws@~8.2.3: - version "8.2.3" - resolved "https://registry.yarnpkg.com/ws/-/ws-8.2.3.tgz#63a56456db1b04367d0b721a0b80cae6d8becbba" - integrity sha512-wBuoj1BDpC6ZQ1B7DWQBYVLphPWkm8i9Y0/3YdHjHKHiohOJ1ws+3OccDWtH+PoC9DZD5WOTrJvNbWvjS6JWaA== - -xtend@^4.0.2, xtend@~4.0.1: - version "4.0.2" - resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.2.tgz#bb72779f5fa465186b1f438f674fa347fdb5db54" - integrity sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ== - -y18n@^5.0.5: - version "5.0.8" - resolved "https://registry.yarnpkg.com/y18n/-/y18n-5.0.8.tgz#7f4934d0f7ca8c56f95314939ddcd2dd91ce1d55" - integrity sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA== - -yallist@^3.0.0, yallist@^3.1.1: - version "3.1.1" - resolved "https://registry.yarnpkg.com/yallist/-/yallist-3.1.1.tgz#dbb7daf9bfd8bac9ab45ebf602b8cbad0d5d08fd" - integrity sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g== - -yallist@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72" - integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A== - -yargs-parser@^20.2.2: - version "20.2.9" - resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.9.tgz#2eb7dc3b0289718fc295f362753845c41a0c94ee" - integrity sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w== - -yargs@^16.0.3, yargs@^16.1.1: - version "16.2.0" - resolved "https://registry.yarnpkg.com/yargs/-/yargs-16.2.0.tgz#1c82bf0f6b6a66eafce7ef30e376f49a12477f66" - integrity sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw== - dependencies: - cliui "^7.0.2" - escalade "^3.1.1" - get-caller-file "^2.0.5" - require-directory "^2.1.1" - string-width "^4.2.0" - y18n "^5.0.5" - yargs-parser "^20.2.2" - -yn@3.1.1: - version "3.1.1" - resolved "https://registry.yarnpkg.com/yn/-/yn-3.1.1.tgz#1e87401a09d767c1d5eab26a6e4c185182d2eb50" - integrity sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q== diff --git a/tfjs-master/link-package/build_deps.ts b/tfjs-master/link-package/build_deps.ts deleted file mode 100644 index ba41e7a64..000000000 --- a/tfjs-master/link-package/build_deps.ts +++ /dev/null @@ -1,247 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as argparse from 'argparse'; -import {spawnSync, exec} from 'child_process'; -import * as fs from 'fs'; -import * as path from 'path'; -import * as rimraf from 'rimraf'; -import {BAZEL_PACKAGES} from '../scripts/bazel_packages'; - -const parser = new argparse.ArgumentParser(); - -parser.add_argument('tfjs_package', { - type: String, - help: 'tfjs package to build dependencies for', - nargs: '*', -}); - -parser.add_argument('--all', { - action: 'store_true', - help: 'Build all packages', -}); - -parser.add_argument('--bazel_options', { - type: String, - default: '', - help: 'Options to pass to Bazel', -}); - -/** - * Build bazel dependencies for the packages specified by the repeated argument - * tfjs_package. If the package is a Bazel package, also build the package - * itself. - * - * @example 'yarn build-deps-for tfjs-react-native' builds all bazel - * dependencies for @tensorflow/tfjs-react-native. - * - * @example 'yarn build-deps-for tfjs-backend-cpu' builds all bazel - * dependencies for @tensorflow/tfjs-backend-cpu and builds tfjs-backend-cpu - * (since it's a Bazel package). - * - * @example 'yarn build-deps-for --all' builds all bazel packages. - */ -async function main() { - const args = parser.parse_args(); - let packageNames: string[] = args.tfjs_package; - - let targets: string[]; - if (args.all) { - targets = [...BAZEL_PACKAGES].map(dirToTarget); - } else { - const bazelDeps = findTransitiveBazelDeps(packageNames); - targets = [...bazelDeps].map(dirToTarget); - } - - if (targets.length > 0) { - if (process.platform === 'win32') { - const child = exec('yarn bazel build --color=yes ' - + `${args.bazel_options} ${targets.join(' ')}`); - await new Promise((resolve, reject) => { - child.stdout.pipe(process.stdout); - child.stderr.pipe(process.stderr); - child.on('exit', code => { - if (code !== 0) { - reject(code); - } - resolve(code); - }); - }); - } else { - // Use spawnSync intead of exec for prettier printing. - const bazelArgs = ['bazel', 'build']; - if (args.bazel_options) { - bazelArgs.push(args.bazel_options); - } - bazelArgs.push(...targets); - spawnSync('yarn', bazelArgs, {stdio:'inherit'}); - } - } - - const tfjsDir = `${__dirname}/node_modules/@tensorflow`; - rimraf.sync(tfjsDir); - fs.mkdirSync(tfjsDir, {recursive: true}); - - // Copy all built packages to node_modules. Note that this does not install - // their dependencies, but that's okay since the node resolution algorithm - // will find dependencies in the root node_modules folder of the repository. - for (const pkg of BAZEL_PACKAGES) { - const pkgPath = path.normalize( - `${__dirname}/../dist/bin/${pkg}/${pkg}_pkg`); - - if (fs.existsSync(pkgPath)) { - const newPath = path.join(tfjsDir, pkg); - copyRecursive(pkgPath, newPath); - } - } - chmodRecursive(tfjsDir); -} - -/** - * Get all dependencies and devDependencies of a tfjs package. - * - * @param packageName The package name (without @tensorflow/). - */ -function getDeps(packageName: string): Set { - const packageJsonPath = path.normalize( - `${__dirname}/../${packageName}/package.json`); - - const pkg = fs.readFileSync(packageJsonPath).toString('utf8'); - const parsedPkg = JSON.parse(pkg) as { - dependencies?: Record, - devDependencies?: Record, - }; - - const allDeps = new Set(); - function addDepsFrom(record?: Record) { - if (record) { - for (const key of Object.keys(record)) { - allDeps.add(key); - } - } - } - addDepsFrom(parsedPkg.dependencies); - addDepsFrom(parsedPkg.devDependencies); - return allDeps; -} - -/** - * Get just the @tensorflow/ scoped deps of a tfjs package. - * - * @param packageName The package name (without @tensorflow/). - * @returns The tfjs package names (not paths) of immediate dependencies. - */ -function getTfjsDeps(packageName: string): Set { - const deps = getDeps(packageName); - const tfjsDeps = [...deps] - .map(dep => dep.match(/@tensorflow\/(.*)/)) - .filter(Boolean) - .map(dep => dep[1]); - return new Set(tfjsDeps); -} - -/** - * Find the set of tfjs Bazel packages that the given packages depend on, - * including transitively. - * - * @param packages An iterable of tfjs package names to check for Bazel - * dependencies - * @returns The set of TFJS packages that constitute the edge between the Bazel - * build graph and the npm build graph, i.e. the minimum set of Bazel packages - * that need to be built in order to build the packages listed in `packages`. - */ -function findTransitiveBazelDeps(packages: Iterable): Set { - let toVisit = new Set([...packages]); - const visited = new Set(); - const bazelPackages = new Set(); - - while (toVisit.size > 0) { - for (const pkg of toVisit) { - if (BAZEL_PACKAGES.has(pkg)) { - bazelPackages.add(pkg); - } else { - const deps = getTfjsDeps(pkg); - // Only add deps that haven't been visited - const newDeps = [...deps].filter(dep => !visited.has(dep)); - toVisit = new Set([...toVisit, ...newDeps]); - } - visited.add(pkg); - toVisit.delete(pkg); - } - } - - return bazelPackages; -} - -/** - * Get the bazel target from a tfjs package's directory. - * - * @param dir The tfjs package's directory. - * @returns The bazel target to build the tfjs package. - */ -function dirToTarget(dir: string) { - return `//${dir}:${dir}_pkg`; -} - -/** - * Recursively copy a file or directory. - * - * @param src The source directory. - * @param dest The destination to copy src to. - */ -function copyRecursive(src: string, dest: string) { - // Avoid 'cp -r', which Windows does not suppport - const stat = fs.lstatSync(src); - if (stat.isFile()) { - fs.copyFileSync(src, dest); - } else if (stat.isDirectory()) { - const contents = fs.readdirSync(src); - fs.mkdirSync(dest); - for (let name of contents) { - copyRecursive(path.join(src, name), - path.join(dest, name)); - } - } -} - -/** - * Map a function on all files and directories under a path. - * - * @param rootPath The path where the function will be mapped. - * @param mapFn The function to map on all subpaths of the rootPath. - */ -function mapFiles(rootPath: string, mapFn: (path: string) => void) { - mapFn(rootPath); - const stat = fs.lstatSync(rootPath); - if (stat.isDirectory()) { - const contents = fs.readdirSync(rootPath); - for (let subPath of contents) { - mapFiles(path.join(rootPath, subPath), mapFn); - } - } -} - -/** - * Recursively change permissions of files to 775. - * - * @param rootPath The path where permissions are changed. - */ -function chmodRecursive(rootPath: string) { - mapFiles(rootPath, path => fs.chmodSync(path, 0o775)); -} - -main(); diff --git a/tfjs-master/link-package/package.json b/tfjs-master/link-package/package.json deleted file mode 100644 index 763a5eda1..000000000 --- a/tfjs-master/link-package/package.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name": "link-package", - "version": "1.0.0", - "description": "A package to help resolve npm link dependencies during the Bazel transition. Other packages link to the packages installed in its node_modules directory. Should never be published.", - "license": "Apache 2.0", - "private": true, - "scripts": { - "build": "yarn build-deps-for --all", - "build-deps-for": "yarn && ts-node build_deps.ts" - }, - "devDependencies": { - "@types/rimraf": "^3.0.2", - "rimraf": "^3.0.2", - "ts-node": "^10.7.0" - }, - "dependencies": { - "@bazel/bazelisk": "^1.12.0", - "@types/argparse": "^2.0.10", - "argparse": "^2.0.1" - } -} diff --git a/tfjs-master/link-package/tsconfig.json b/tfjs-master/link-package/tsconfig.json deleted file mode 100644 index 8f446823b..000000000 --- a/tfjs-master/link-package/tsconfig.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "extends": "../tsconfig", - "compilerOptions": { - "module": "commonjs", - "target": "es5", - "lib": [ - "esnext" - ], - "downlevelIteration": true, - "esModuleInterop": true - }, - "include": [ - "**/*.ts" - ] -} diff --git a/tfjs-master/link-package/yarn.lock b/tfjs-master/link-package/yarn.lock deleted file mode 100644 index e28b20a46..000000000 --- a/tfjs-master/link-package/yarn.lock +++ /dev/null @@ -1,214 +0,0 @@ -# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. -# yarn lockfile v1 - - -"@bazel/bazelisk@^1.12.0": - version "1.12.0" - resolved "https://registry.yarnpkg.com/@bazel/bazelisk/-/bazelisk-1.12.0.tgz#f08aebbf4afcb12684422450b0845dd6ef5cfe50" - integrity sha512-7oQusq1e4AIyFgotxVV7Pc40Et0QyvoVjujL+7/qV5Vrbfh0Nj3CfqSgl63weEyI4r0+K6RlGVsjfRuBi05p5w== - -"@cspotcode/source-map-consumer@0.8.0": - version "0.8.0" - resolved "https://registry.yarnpkg.com/@cspotcode/source-map-consumer/-/source-map-consumer-0.8.0.tgz#33bf4b7b39c178821606f669bbc447a6a629786b" - integrity sha512-41qniHzTU8yAGbCp04ohlmSrZf8bkf/iJsl3V0dRGsQN/5GFfx+LbCSsCpp2gqrqjTVg/K6O8ycoV35JIwAzAg== - -"@cspotcode/source-map-support@0.7.0": - version "0.7.0" - resolved "https://registry.yarnpkg.com/@cspotcode/source-map-support/-/source-map-support-0.7.0.tgz#4789840aa859e46d2f3173727ab707c66bf344f5" - integrity sha512-X4xqRHqN8ACt2aHVe51OxeA2HjbcL4MqFqXkrmQszJ1NOUuUu5u6Vqx/0lZSVNku7velL5FC/s5uEAj1lsBMhA== - dependencies: - "@cspotcode/source-map-consumer" "0.8.0" - -"@tsconfig/node10@^1.0.7": - version "1.0.8" - resolved "https://registry.yarnpkg.com/@tsconfig/node10/-/node10-1.0.8.tgz#c1e4e80d6f964fbecb3359c43bd48b40f7cadad9" - integrity sha512-6XFfSQmMgq0CFLY1MslA/CPUfhIL919M1rMsa5lP2P097N2Wd1sSX0tx1u4olM16fLNhtHZpRhedZJphNJqmZg== - -"@tsconfig/node12@^1.0.7": - version "1.0.9" - resolved "https://registry.yarnpkg.com/@tsconfig/node12/-/node12-1.0.9.tgz#62c1f6dee2ebd9aead80dc3afa56810e58e1a04c" - integrity sha512-/yBMcem+fbvhSREH+s14YJi18sp7J9jpuhYByADT2rypfajMZZN4WQ6zBGgBKp53NKmqI36wFYDb3yaMPurITw== - -"@tsconfig/node14@^1.0.0": - version "1.0.1" - resolved "https://registry.yarnpkg.com/@tsconfig/node14/-/node14-1.0.1.tgz#95f2d167ffb9b8d2068b0b235302fafd4df711f2" - integrity sha512-509r2+yARFfHHE7T6Puu2jjkoycftovhXRqW328PDXTVGKihlb1P8Z9mMZH04ebyajfRY7dedfGynlrFHJUQCg== - -"@tsconfig/node16@^1.0.2": - version "1.0.2" - resolved "https://registry.yarnpkg.com/@tsconfig/node16/-/node16-1.0.2.tgz#423c77877d0569db20e1fc80885ac4118314010e" - integrity sha512-eZxlbI8GZscaGS7kkc/trHTT5xgrjH3/1n2JDwusC9iahPKWMRvRjJSAN5mCXviuTGQ/lHnhvv8Q1YTpnfz9gA== - -"@types/argparse@^2.0.10": - version "2.0.10" - resolved "https://registry.yarnpkg.com/@types/argparse/-/argparse-2.0.10.tgz#664e84808accd1987548d888b9d21b3e9c996a6c" - integrity sha512-C4wahC3gz3vQtvPazrJ5ONwmK1zSDllQboiWvpMM/iOswCYfBREFnjFbq/iWKIVOCl8+m5Pk6eva6/ZSsDuIGA== - -"@types/glob@*": - version "7.2.0" - resolved "https://registry.yarnpkg.com/@types/glob/-/glob-7.2.0.tgz#bc1b5bf3aa92f25bd5dd39f35c57361bdce5b2eb" - integrity sha512-ZUxbzKl0IfJILTS6t7ip5fQQM/J3TJYubDm3nMbgubNNYS62eXeUpoLUC8/7fJNiFYHTrGPQn7hspDUzIHX3UA== - dependencies: - "@types/minimatch" "*" - "@types/node" "*" - -"@types/minimatch@*": - version "3.0.5" - resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.5.tgz#1001cc5e6a3704b83c236027e77f2f58ea010f40" - integrity sha512-Klz949h02Gz2uZCMGwDUSDS1YBlTdDDgbWHi+81l29tQALUtvz4rAYi5uoVhE5Lagoq6DeqAUlbrHvW/mXDgdQ== - -"@types/node@*": - version "17.0.31" - resolved "https://registry.yarnpkg.com/@types/node/-/node-17.0.31.tgz#a5bb84ecfa27eec5e1c802c6bbf8139bdb163a5d" - integrity sha512-AR0x5HbXGqkEx9CadRH3EBYx/VkiUgZIhP4wvPn/+5KIsgpNoyFaRlVe0Zlx9gRtg8fA06a9tskE2MSN7TcG4Q== - -"@types/rimraf@^3.0.2": - version "3.0.2" - resolved "https://registry.yarnpkg.com/@types/rimraf/-/rimraf-3.0.2.tgz#a63d175b331748e5220ad48c901d7bbf1f44eef8" - integrity sha512-F3OznnSLAUxFrCEu/L5PY8+ny8DtcFRjx7fZZ9bycvXRi3KPTRS9HOitGZwvPg0juRhXFWIeKX58cnX5YqLohQ== - dependencies: - "@types/glob" "*" - "@types/node" "*" - -acorn-walk@^8.1.1: - version "8.2.0" - resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-8.2.0.tgz#741210f2e2426454508853a2f44d0ab83b7f69c1" - integrity sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA== - -acorn@^8.4.1: - version "8.7.1" - resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.7.1.tgz#0197122c843d1bf6d0a5e83220a788f278f63c30" - integrity sha512-Xx54uLJQZ19lKygFXOWsscKUbsBZW0CPykPhVQdhIeIwrbPmJzqeASDInc8nKBnp/JT6igTs82qPXz069H8I/A== - -arg@^4.1.0: - version "4.1.3" - resolved "https://registry.yarnpkg.com/arg/-/arg-4.1.3.tgz#269fc7ad5b8e42cb63c896d5666017261c144089" - integrity sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA== - -argparse@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/argparse/-/argparse-2.0.1.tgz#246f50f3ca78a3240f6c997e8a9bd1eac49e4b38" - integrity sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q== - -balanced-match@^1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee" - integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw== - -brace-expansion@^1.1.7: - version "1.1.11" - resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" - integrity sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA== - dependencies: - balanced-match "^1.0.0" - concat-map "0.0.1" - -concat-map@0.0.1: - version "0.0.1" - resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" - integrity sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg== - -create-require@^1.1.0: - version "1.1.1" - resolved "https://registry.yarnpkg.com/create-require/-/create-require-1.1.1.tgz#c1d7e8f1e5f6cfc9ff65f9cd352d37348756c333" - integrity sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ== - -diff@^4.0.1: - version "4.0.2" - resolved "https://registry.yarnpkg.com/diff/-/diff-4.0.2.tgz#60f3aecb89d5fae520c11aa19efc2bb982aade7d" - integrity sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A== - -fs.realpath@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" - integrity sha1-FQStJSMVjKpA20onh8sBQRmU6k8= - -glob@^7.1.3: - version "7.1.7" - resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.7.tgz#3b193e9233f01d42d0b3f78294bbeeb418f94a90" - integrity sha512-OvD9ENzPLbegENnYP5UUfJIirTg4+XwMWGaQfQTY0JenxNvvIKP3U3/tAQSPIu/lHxXYSZmpXlUHeqAIdKzBLQ== - dependencies: - fs.realpath "^1.0.0" - inflight "^1.0.4" - inherits "2" - minimatch "^3.0.4" - once "^1.3.0" - path-is-absolute "^1.0.0" - -inflight@^1.0.4: - version "1.0.6" - resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" - integrity sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk= - dependencies: - once "^1.3.0" - wrappy "1" - -inherits@2: - version "2.0.4" - resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" - integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== - -make-error@^1.1.1: - version "1.3.6" - resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.6.tgz#2eb2e37ea9b67c4891f684a1394799af484cf7a2" - integrity sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw== - -minimatch@^3.0.4: - version "3.1.2" - resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b" - integrity sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw== - dependencies: - brace-expansion "^1.1.7" - -once@^1.3.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" - integrity sha1-WDsap3WWHUsROsF9nFC6753Xa9E= - dependencies: - wrappy "1" - -path-is-absolute@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" - integrity sha1-F0uSaHNVNP+8es5r9TpanhtcX18= - -rimraf@^3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-3.0.2.tgz#f1a5402ba6220ad52cc1282bac1ae3aa49fd061a" - integrity sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA== - dependencies: - glob "^7.1.3" - -ts-node@^10.7.0: - version "10.7.0" - resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-10.7.0.tgz#35d503d0fab3e2baa672a0e94f4b40653c2463f5" - integrity sha512-TbIGS4xgJoX2i3do417KSaep1uRAW/Lu+WAL2doDHC0D6ummjirVOXU5/7aiZotbQ5p1Zp9tP7U6cYhA0O7M8A== - dependencies: - "@cspotcode/source-map-support" "0.7.0" - "@tsconfig/node10" "^1.0.7" - "@tsconfig/node12" "^1.0.7" - "@tsconfig/node14" "^1.0.0" - "@tsconfig/node16" "^1.0.2" - acorn "^8.4.1" - acorn-walk "^8.1.1" - arg "^4.1.0" - create-require "^1.1.0" - diff "^4.0.1" - make-error "^1.1.1" - v8-compile-cache-lib "^3.0.0" - yn "3.1.1" - -v8-compile-cache-lib@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz#6336e8d71965cb3d35a1bbb7868445a7c05264bf" - integrity sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg== - -wrappy@1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" - integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8= - -yn@3.1.1: - version "3.1.1" - resolved "https://registry.yarnpkg.com/yn/-/yn-3.1.1.tgz#1e87401a09d767c1d5eab26a6e4c185182d2eb50" - integrity sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q== diff --git a/tfjs-master/package.json b/tfjs-master/package.json deleted file mode 100644 index 16b119a9c..000000000 --- a/tfjs-master/package.json +++ /dev/null @@ -1,111 +0,0 @@ -{ - "devDependencies": { - "@bazel/bazelisk": "^1.12.0", - "@bazel/buildifier": "6.1.0", - "@bazel/concatjs": "5.8.1", - "@bazel/esbuild": "5.8.1", - "@bazel/ibazel": "^0.16.2", - "@bazel/jasmine": "5.8.1", - "@bazel/rollup": "5.8.1", - "@bazel/terser": "5.8.1", - "@bazel/typescript": "5.8.1", - "@octokit/rest": "15.17.0", - "@rollup/plugin-commonjs": "^24.1.0", - "@rollup/plugin-node-resolve": "^15.0.2", - "@types/argparse": "^1.0.38", - "@types/emscripten": "~0.0.34", - "@types/estree": "^0.0.51", - "@types/inquirer": "^8.0.0", - "@types/jasmine": "~4.0.3", - "@types/js-yaml": "^4.0.5", - "@types/long": "4.0.1", - "@types/mkdirp": "^0.5.2", - "@types/node": "^18.11.15", - "@types/node-fetch": "~2.1.2", - "@types/offscreencanvas": "^2019.7.0", - "@types/rimraf": "^3.0.2", - "@types/rollup-plugin-visualizer": "^4.2.1", - "@types/seedrandom": "^2.4.28", - "@types/semver": "^7.3.9", - "@types/shelljs": "^0.8.7", - "@types/dom-webcodecs": "0.1.4", - "@webgpu/types": "0.1.38", - "ajv": "~6.12.3", - "argparse": "^1.0.10", - "chalk": "~2.4.2", - "clang-format": "~1.2.4", - "console-table-printer": "^2.4.32", - "copyfiles": "~1.2.0", - "core-js": "3", - "deep-equal": "^1.0.1", - "estree-walker": "~1.0.1", - "express": "4.18.2", - "inquirer": "^8.0.0", - "jasmine": "~4.2.1", - "jasmine-core": "~4.2.0", - "js-yaml": "^3.14.0", - "jszip": "^3.10.0", - "karma": "^6.4.0", - "karma-browserstack-launcher": "^1.6.0", - "karma-chrome-launcher": "^3.1.1", - "karma-firefox-launcher": "^2.1.2", - "karma-jasmine": "~5.1.0", - "karma-jasmine-html-reporter": "^2.0.0", - "karma-jasmine-order-reporter": "^1.1.0", - "karma-requirejs": "^1.1.0", - "karma-sourcemap-loader": "^0.3.8", - "long": "4.0.0", - "mkdirp": "~0.5.1", - "opn": "~5.1.0", - "protobufjs": "~7.2.4", - "requirejs": "^2.3.6", - "rimraf": "~2.6.2", - "rollup": "^3.20.2", - "rollup-plugin-sourcemaps": "^0.6.3", - "rollup-plugin-terser": "^7.0.2", - "rollup-plugin-visualizer": "~5.9.0", - "seedrandom": "^3.0.5", - "semver": "^7.5.2", - "shelljs": "~0.8.5", - "string_decoder": "^1.3.0", - "terser": "^5.14.2", - "ts-morph": "^11.0.3", - "ts-node": "~8.8.2", - "tslib": "^2.4.0", - "tslint": "^6.1.3", - "tslint-no-circular-imports": "~0.7.0", - "typescript": "5.0.4", - "verdaccio": "^5.9.0" - }, - "scripts": { - "lint": "tslint -p tsconfig_tslint.json", - "test": "bazel test //:tests", - "test-packages-ci": "yarn generate-cloudbuild-for-packages && ./scripts/run-build.sh", - "nightly-cloudbuild": "NIGHTLY=true yarn generate-cloudbuild-for-packages && gcloud builds submit . --config=cloudbuild_generated.yml --substitutions=_NIGHTLY=true", - "generate-cloudbuild-for-packages": "ts-node -s ./scripts/generate_cloudbuild_for_packages.ts", - "test-generate-cloudbuild": "cd scripts && node --require ts-node/register ../node_modules/jasmine/bin/jasmine.js run generate_cloudbuild_test.ts", - "test-run-flaky": "jasmine run scripts/run_flaky_test.js", - "release": "ts-node -s ./scripts/release.ts", - "release-tfjs": "ts-node -s ./scripts/release-tfjs.ts", - "publish-npm": "ts-node -s ./scripts/publish-npm.ts", - "publish-pypi": "ts-node -s ./scripts/publish-pypi.ts", - "release-notes": "ts-node -s ./scripts/release_notes/release_notes.ts", - "test-release-notes": "ts-node -s ./scripts/release_notes/run_tests.ts", - "update-tfjs-lockfiles": "ts-node -s ./scripts/update-tfjs-lockfiles", - "tag-tfjs-release": "ts-node -s ./scripts/tag-tfjs-release", - "update-cloudbuild-tests": "yarn generate-cloudbuild-for-packages tfjs-node -o scripts/cloudbuild_tfjs_node_expected.yml && yarn generate-cloudbuild-for-packages e2e -o scripts/cloudbuild_e2e_expected.yml", - "bazel:format": "find . -type f \\( -name \"*.bzl\" -or -name WORKSPACE -or -name BUILD -or -name BUILD.bazel \\) ! -path \"*/node_modules/*\" | xargs buildifier -v --warnings=attr-cfg,attr-license,attr-non-empty,attr-output-default,attr-single-file,constant-glob,ctx-actions,ctx-args,depset-iteration,depset-union,dict-concatenation,duplicated-name,filetype,git-repository,http-archive,integer-division,load,load-on-top,native-build,native-package,out-of-order-load,output-group,package-name,package-on-top,positional-args,redefined-variable,repository-name,same-origin-load,string-iteration,unsorted-dict-items,unused-variable", - "bazel:format-check": "yarn bazel:format --mode=check", - "bazel:lint": "yarn bazel:format --lint=warn", - "bazel:lint-fix": "yarn bazel:format --lint=fix", - "bazel:lint-check": "yarn bazel:format --lint=warn --mode=check", - "buildifier-ci": "./scripts/buildifier-ci.sh", - "start-local-debugger-server": "node ./scripts/start_local_debugger_server.js" - }, - "dependencies": { - "node-fetch": "^2.6.7" - }, - "resolutions": { - "minimist": "1.2.6" - } -} diff --git a/tfjs-master/pull_request_template.md b/tfjs-master/pull_request_template.md deleted file mode 100644 index f1a5010ff..000000000 --- a/tfjs-master/pull_request_template.md +++ /dev/null @@ -1 +0,0 @@ -To see the logs from the Cloud Build CI, please join either our [discussion](https://groups.google.com/a/tensorflow.org/forum/#!forum/tfjs) or [announcement](https://groups.google.com/a/tensorflow.org/forum/#!forum/tfjs-announce) mailing list. \ No newline at end of file diff --git a/tfjs-master/remote-execution/BUILD.bazel b/tfjs-master/remote-execution/BUILD.bazel deleted file mode 100644 index 21703436a..000000000 --- a/tfjs-master/remote-execution/BUILD.bazel +++ /dev/null @@ -1,41 +0,0 @@ -package(default_visibility = ["//visibility:public"]) - -platform( - name = "platform", - constraint_values = [ - "@bazel_tools//platforms:linux", - "@bazel_tools//platforms:x86_64", - "@bazel_tools//tools/cpp:clang", - ], - exec_properties = { - # We use the same docker image for remote builds as we use for CI testing. - "container-image": "docker://gcr.io/learnjs-174218/release@sha256:d85abab6146eaf1e01312bdb9e353a5efa0508b913dccf30fc5e505d009026ff", - # By default in Google Cloud Remote build execution, network access is disabled. We explicitly set the - # property in the platform again in case the default ever changes. Network access is not desirable in - # Bazel builds as it is potential source of flaky tests and therefore also breaks hermeticity. - "dockerNetwork": "off", - }, -) - -platform( - name = "platform_with_network", - exec_properties = { - # By default we have network access disabled with the `:platform` target. This is an - # additional platform that extends from the default one but enables network access. - # Network is generally not recommended, but for some exceptions, like integration tests - # running a Yarn install, network access is reasonable. In such special cases, Bazel can - # be invoked to run with this platform. It is recommended that exec platforms with network - # access are used in combination with `--sandbox_default_allow_network=false` as this allows - # specific targets to be granted network access, while others will not have access. - "dockerNetwork": "standard", - }, - parents = [":platform"], -) - -filegroup( - name = "files", - srcs = [ - "BUILD.bazel", - "@npm//@angular/dev-infra-private/bazel/remote-execution/cpp:files", - ], -) diff --git a/tfjs-master/remote-execution/cpp/BUILD.bazel b/tfjs-master/remote-execution/cpp/BUILD.bazel deleted file mode 100644 index a94de2526..000000000 --- a/tfjs-master/remote-execution/cpp/BUILD.bazel +++ /dev/null @@ -1,58 +0,0 @@ -load("@bazel_tools//tools/cpp:cc_toolchain_config.bzl", "cc_toolchain_config") - -package(default_visibility = ["//visibility:public"]) - -filegroup( - name = "files", - srcs = ["BUILD.bazel"], -) - -cc_toolchain_suite( - name = "cc_toolchain_suite", - tags = ["manual"], - toolchains = { - "k8": ":cc_compiler_k8", - }, -) - -toolchain( - name = "cc_toolchain", - exec_compatible_with = [ - "@bazel_tools//platforms:linux", - "@bazel_tools//platforms:x86_64", - "@bazel_tools//tools/cpp:clang", - ], - target_compatible_with = [ - "@bazel_tools//platforms:linux", - "@bazel_tools//platforms:x86_64", - ], - toolchain = ":cc_compiler_k8", - toolchain_type = "@bazel_tools//tools/cpp:toolchain_type", -) - -# Basic CC toolchain for k8 remote containers. Based on the default k8 -# toolchain provided in Bazel (but unfortunately internal). -# https://github.com/bazelbuild/bazel/blob/c951753097b45cfb9be512c02199aa891b9646b8/tools/cpp/BUILD.tools#L298-L311 -cc_toolchain( - name = "cc_compiler_k8", - all_files = ":empty", - ar_files = ":empty", - as_files = ":empty", - compiler_files = ":empty", - dwp_files = ":empty", - linker_files = ":empty", - objcopy_files = ":empty", - strip_files = ":empty", - supports_param_files = 1, - toolchain_config = ":k8_toolchain_config", - toolchain_identifier = "cc-k8-compiler", -) - -cc_toolchain_config( - name = "k8_toolchain_config", - compiler = "compiler", - cpu = "local", -) - -# Empty filegroup used for defining the CC toolchain. -filegroup(name = "empty") diff --git a/tfjs-master/rollup.config.helpers.js b/tfjs-master/rollup.config.helpers.js deleted file mode 100644 index 7ad2be4f0..000000000 --- a/tfjs-master/rollup.config.helpers.js +++ /dev/null @@ -1,114 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {terser} from 'rollup-plugin-terser'; - -/** - * Returns a standardized list of browser package configuration options - * that we want to use in all our rollup files and ship to NPM. - * - * @param {string} fileName - * @param {string} preamble - * @param {boolean} visualize - produce bundle visualizations for certain - * bundles - * @param {boolean} ci is this a CI build - * @param {object} terserExtraOptions is any extra options passed to terser - */ -export function getBrowserBundleConfigOptions( - config, name, fileName, preamble, visualize, ci, terserExtraOptions = {}) { - const bundles = []; - - const terserPlugin = - terser({output: {preamble, comments: false}, ...terserExtraOptions}); - const extend = true; - const umdFormat = 'umd'; - const fesmFormat = 'es'; - - // UMD ES5 minified - bundles.push(config({ - plugins: [terserPlugin], - output: { - format: umdFormat, - name, - extend, - file: `dist/${fileName}.min.js`, - freeze: false - }, - tsCompilerOptions: {target: 'es5'}, - visualize - })); - - if (ci) { - // In CI we do not build all the possible bundles. - return bundles; - } - - // UMD ES5 unminified - bundles.push(config({ - output: { - format: umdFormat, - name, - extend, - file: `dist/${fileName}.js`, - freeze: false - }, - tsCompilerOptions: {target: 'es5'} - })); - - // UMD ES2017 - bundles.push(config({ - output: - {format: umdFormat, name, extend, file: `dist/${fileName}.es2017.js`}, - tsCompilerOptions: {target: 'es2017'} - })); - - // UMD ES2017 minified - bundles.push(config({ - plugins: [terserPlugin], - output: { - format: umdFormat, - name, - extend, - file: `dist/${fileName}.es2017.min.js` - }, - tsCompilerOptions: {target: 'es2017'}, - visualize - })); - - // FESM ES2017 - bundles.push(config({ - output: - {format: fesmFormat, name, extend, file: `dist/${fileName}.fesm.js`}, - tsCompilerOptions: {target: 'es2017'} - })); - - // FESM ES2017 minified - bundles.push(config({ - plugins: [terserPlugin], - output: { - format: fesmFormat, - name, - extend, - file: `dist/${fileName}.fesm.min.js` - }, - tsCompilerOptions: {target: 'es2017'}, - visualize - })); - - - return bundles; -} diff --git a/tfjs-master/scripts/bazel_packages.ts b/tfjs-master/scripts/bazel_packages.ts deleted file mode 100644 index dafb6ee79..000000000 --- a/tfjs-master/scripts/bazel_packages.ts +++ /dev/null @@ -1,12 +0,0 @@ -export const BAZEL_PACKAGES = new Set([ - 'tfjs-core', - 'tfjs-backend-cpu', - 'tfjs-tfdf', - 'tfjs-tflite', - 'tfjs-converter', - 'tfjs-backend-webgl', - 'tfjs-backend-webgpu', - 'tfjs-layers', - 'tfjs-data', - 'tfjs-backend-wasm', -]); diff --git a/tfjs-master/scripts/buildifier-ci.sh b/tfjs-master/scripts/buildifier-ci.sh deleted file mode 100644 index e114452ea..000000000 --- a/tfjs-master/scripts/buildifier-ci.sh +++ /dev/null @@ -1,45 +0,0 @@ -#!/usr/bin/env bash -# Copyright 2019 Google LLC. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================= - -yarn bazel:format-check - -if [ $? -eq 0 ] -then - echo -else - echo - echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" - echo "'yarn bazel:format-check' failed!" - echo "Please run 'yarn bazel:format'." - echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" - echo - exit 1 -fi - -yarn bazel:lint-check - -if [ $? -eq 0 ] -then - echo -else - echo - echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" - echo "'yarn bazel:lint-check' failed!" - echo "Please run 'yarn bazel:lint'." - echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" - echo - exit 1 -fi diff --git a/tfjs-master/scripts/bundle-size-util.js b/tfjs-master/scripts/bundle-size-util.js deleted file mode 100644 index 40fd6ba5a..000000000 --- a/tfjs-master/scripts/bundle-size-util.js +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/env node -// Copyright 2019 Google LLC. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= -const {exec} = require('./test-util'); - -function getFileSizeBytes(filename) { - const fileSizeBytes = - +(exec(`cat ${filename} | wc -c`, {silent: true})); - const gzipFileSizeBytes = - +(exec(`gzip -c ${filename} | wc -c`, {silent: true})); - return {fileSizeBytes, gzipFileSizeBytes}; -} - -function showDiff(newSize, masterSize) { - const diffBytes = newSize - masterSize; - const diffPercent = (100 * diffBytes / masterSize).toFixed(2); - const sign = diffBytes > 0 ? '+' : ''; - - const charWidth = 7; - const diffKiloBytes = - (sign + (diffBytes / 1024).toFixed(2)).padStart(charWidth, ' '); - const masterKiloBytes = - ((masterSize / 1024).toFixed(2)).padStart(charWidth, ' '); - const newKiloBytes = ((newSize / 1024).toFixed(2)).padStart(charWidth, ' '); - - console.log(` diff: ${diffKiloBytes} K (${sign}${diffPercent}%)`); - console.log(` master: ${masterKiloBytes} K`); - console.log(` change: ${newKiloBytes} K`); -} - -exports.getFileSizeBytes = getFileSizeBytes; -exports.showDiff = showDiff; diff --git a/tfjs-master/scripts/cloud_funcs/README.md b/tfjs-master/scripts/cloud_funcs/README.md deleted file mode 100644 index 359f3cc48..000000000 --- a/tfjs-master/scripts/cloud_funcs/README.md +++ /dev/null @@ -1,50 +0,0 @@ -This directory contains the following Google Cloud Functions. - -### `trigger_nightly` -Programatically triggers a Cloud Build on master. This function is called by the Cloud Scheduler around 4am "America/New York" time every day (configurable via the Cloud Scheduler UI). -You can also trigger the function manually via the Cloud UI. - -Command to re-deploy: -```sh -gcloud functions deploy nightly_tfjs \ - --runtime nodejs14 \ - --trigger-topic nightly_tfjs -``` - -If a build was triggered by nightly, there is a substitution variable `_NIGHTLY=true`. -You can forward the substitution as the `NIGHTLY` environment variable so the scripts can use it, by specifying `env: ['NIGHTLY=$_NIGHTLY']` in `cloudbuild.yml`. E.g. `integration_tests/benchmarks/benchmark_cloud.sh` uses the `NIGHTLY` bit to always run on nightly. - -### `send_email` -Sends an email and a chat message with the nightly build status. Every build sends a message to the `cloud-builds` topic with its build information. The `send_email` function is subscribed to that topic and ignores all builds (e.g. builds triggered by pull requests) **except** for the nightly build and sends an email to an internal mailing list with its build status around 4:40am. - -Command to re-deploy: - -```sh -gcloud functions deploy send_email \ - --runtime nodejs14 \ - --stage-bucket learnjs-174218_cloudbuild \ - --trigger-topic cloud-builds \ - --set-env-vars MAILGUN_API_KEY="[API_KEY_HERE]",HANGOUTS_URL="[URL_HERE]" -``` - -### `sync_reactnative` -Makes a request to browserStack to sync the current build of the tfjs-react-native integration app to browserstack. The app itself is stored in a GCP bucket. This needs to be done at least once every 30 days and is triggered via cloud scheduler via the `sync_reactnative` topic. -Currently set to run weekly on Thursdays at 3AM. - -Command to re-deploy: - -```sh -gcloud functions deploy sync_reactnative \ - --runtime nodejs14 \ - --trigger-topic sync_reactnative \ - --set-env-vars HANGOUTS_URL="[URL_HERE]",BOTS_HANGOUTS_URL="[URL_HERE]" -``` - -### The pipeline - -The pipeline looks like this: - -1) At 4am, Cloud Scheduler writes to `nightly_tfjs` topic -2) That triggers the `nightly_tfjs` function, which starts a build programatically -3) That build runs and writes its status to `cloud-builds` topic -4) That triggers the `send_email` function, which sends email and chat with the build status. diff --git a/tfjs-master/scripts/cloud_funcs/send_email/.gcloudignore b/tfjs-master/scripts/cloud_funcs/send_email/.gcloudignore deleted file mode 100644 index ccc4eb240..000000000 --- a/tfjs-master/scripts/cloud_funcs/send_email/.gcloudignore +++ /dev/null @@ -1,16 +0,0 @@ -# This file specifies files that are *not* uploaded to Google Cloud Platform -# using gcloud. It follows the same syntax as .gitignore, with the addition of -# "#!include" directives (which insert the entries of the given .gitignore-style -# file at that point). -# -# For more information, run: -# $ gcloud topic gcloudignore -# -.gcloudignore -# If you would like to upload your .git directory, .gitignore file or files -# from your .gitignore file, remove the corresponding line -# below: -.git -.gitignore - -node_modules diff --git a/tfjs-master/scripts/cloud_funcs/send_email/index.js b/tfjs-master/scripts/cloud_funcs/send_email/index.js deleted file mode 100644 index 83fdfdcbd..000000000 --- a/tfjs-master/scripts/cloud_funcs/send_email/index.js +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright 2019 Google LLC. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= - -const humanizeDuration = require('humanize-duration'); -const request = require('request-promise-native'); -const fetch = require('node-fetch'); - - -const TRIGGER_ID = '43c56710-ccb3-4db9-b746-603cffbf0c02'; - -// The main function called by Cloud Functions. -module.exports.send_email = async event => { - // Parse the build information. - const build = JSON.parse(Buffer.from(event.data, 'base64').toString()); - // Also added 'SUCCESS' to monitor successful builds. - const status = [ - 'SUCCESS', 'FAILURE', 'INTERNAL_ERROR', 'TIMEOUT', 'CANCELLED', 'FAILED' - ]; - // Email only known status. - if (status.indexOf(build.status) === -1) { - return; - } - // Email only on nightly builds. - if (build.buildTriggerId !== TRIGGER_ID) { - return; - } - - let duration = - humanizeDuration(new Date(build.finishTime) - new Date(build.startTime)); - const msg = `${build.substitutions.REPO_NAME} nightly finished with status ` + - `${build.status}, in ${duration}.`; - - await sendChatMsg(build, msg); -}; - -async function sendChatMsg(build, msg) { - let chatMsg = `${msg} <${build.logUrl}|See logs>.`; - - const success = build.status === 'SUCCESS'; - - if (!success) { - const joke = (await (await fetch('https://icanhazdadjoke.com/', { - headers: {'Accept': 'application/json'} - })).json()) - .joke; - const jokeMsg = `Oh no! Failed builds are not fun... So here's a joke ` + - `to brighten your day :) -- ${joke}`; - chatMsg = `${chatMsg} ${jokeMsg}`; - } - - const res = await request(process.env.HANGOUTS_URL, { - resolveWithFullResponse: true, - method: 'POST', - json: true, - body: {text: chatMsg}, - }); - console.log(`statusCode: ${res.statusCode}`); - console.log(res.body); -} diff --git a/tfjs-master/scripts/cloud_funcs/send_email/package.json b/tfjs-master/scripts/cloud_funcs/send_email/package.json deleted file mode 100644 index 6f4e6e7e1..000000000 --- a/tfjs-master/scripts/cloud_funcs/send_email/package.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "name": "cloudbuild-email", - "version": "0.0.2", - "description": "Email integration for Google Cloud Build, using Google Cloud Functions", - "main": "index.js", - "dependencies": { - "humanize-duration": "3.10.0", - "node-fetch": "^2.6.7", - "request": "^2.88.0", - "request-promise-native": "^1.0.7" - } -} diff --git a/tfjs-master/scripts/cloud_funcs/send_email/yarn.lock b/tfjs-master/scripts/cloud_funcs/send_email/yarn.lock deleted file mode 100644 index 31aa9d5aa..000000000 --- a/tfjs-master/scripts/cloud_funcs/send_email/yarn.lock +++ /dev/null @@ -1,377 +0,0 @@ -# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. -# yarn lockfile v1 - - -ajv@^6.12.3: - version "6.12.6" - resolved "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz" - integrity sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g== - dependencies: - fast-deep-equal "^3.1.1" - fast-json-stable-stringify "^2.0.0" - json-schema-traverse "^0.4.1" - uri-js "^4.2.2" - -asn1@~0.2.3: - version "0.2.4" - resolved "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz" - integrity sha512-jxwzQpLQjSmWXgwaCZE9Nz+glAG01yF1QnWgbhGwHI5A6FRIEY6IVqtHhIepHqI7/kyEyQEagBC5mBEFlIYvdg== - dependencies: - safer-buffer "~2.1.0" - -assert-plus@1.0.0, assert-plus@^1.0.0: - version "1.0.0" - resolved "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz" - integrity sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU= - -asynckit@^0.4.0: - version "0.4.0" - resolved "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz" - integrity sha1-x57Zf380y48robyXkLzDZkdLS3k= - -aws-sign2@~0.7.0: - version "0.7.0" - resolved "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz" - integrity sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg= - -aws4@^1.8.0: - version "1.11.0" - resolved "https://registry.npmjs.org/aws4/-/aws4-1.11.0.tgz" - integrity sha512-xh1Rl34h6Fi1DC2WWKfxUTVqRsNnr6LsKz2+hfwDxQJWmrx8+c7ylaqBMcHfl1U1r2dsifOvKX3LQuLNZ+XSvA== - -bcrypt-pbkdf@^1.0.0: - version "1.0.2" - resolved "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz" - integrity sha1-pDAdOJtqQ/m2f/PKEaP2Y342Dp4= - dependencies: - tweetnacl "^0.14.3" - -caseless@~0.12.0: - version "0.12.0" - resolved "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz" - integrity sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw= - -combined-stream@^1.0.6, combined-stream@~1.0.6: - version "1.0.8" - resolved "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz" - integrity sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg== - dependencies: - delayed-stream "~1.0.0" - -core-util-is@1.0.2: - version "1.0.2" - resolved "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz" - integrity sha1-tf1UIgqivFq1eqtxQMlAdUUDwac= - -dashdash@^1.12.0: - version "1.14.1" - resolved "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz" - integrity sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA= - dependencies: - assert-plus "^1.0.0" - -delayed-stream@~1.0.0: - version "1.0.0" - resolved "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz" - integrity sha1-3zrhmayt+31ECqrgsp4icrJOxhk= - -ecc-jsbn@~0.1.1: - version "0.1.2" - resolved "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz" - integrity sha1-OoOpBOVDUyh4dMVkt1SThoSamMk= - dependencies: - jsbn "~0.1.0" - safer-buffer "^2.1.0" - -extend@~3.0.2: - version "3.0.2" - resolved "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz" - integrity sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g== - -extsprintf@1.3.0: - version "1.3.0" - resolved "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz" - integrity sha1-lpGEQOMEGnpBT4xS48V06zw+HgU= - -extsprintf@^1.2.0: - version "1.4.0" - resolved "https://registry.npmjs.org/extsprintf/-/extsprintf-1.4.0.tgz" - integrity sha1-4mifjzVvrWLMplo6kcXfX5VRaS8= - -fast-deep-equal@^3.1.1: - version "3.1.3" - resolved "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz" - integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q== - -fast-json-stable-stringify@^2.0.0: - version "2.1.0" - resolved "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz" - integrity sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw== - -forever-agent@~0.6.1: - version "0.6.1" - resolved "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz" - integrity sha1-+8cfDEGt6zf5bFd60e1C2P2sypE= - -form-data@~2.3.2: - version "2.3.3" - resolved "https://registry.npmjs.org/form-data/-/form-data-2.3.3.tgz" - integrity sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ== - dependencies: - asynckit "^0.4.0" - combined-stream "^1.0.6" - mime-types "^2.1.12" - -getpass@^0.1.1: - version "0.1.7" - resolved "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz" - integrity sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo= - dependencies: - assert-plus "^1.0.0" - -har-schema@^2.0.0: - version "2.0.0" - resolved "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz" - integrity sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI= - -har-validator@~5.1.3: - version "5.1.5" - resolved "https://registry.npmjs.org/har-validator/-/har-validator-5.1.5.tgz" - integrity sha512-nmT2T0lljbxdQZfspsno9hgrG3Uir6Ks5afism62poxqBM6sDnMEuPmzTq8XN0OEwqKLLdh1jQI3qyE66Nzb3w== - dependencies: - ajv "^6.12.3" - har-schema "^2.0.0" - -http-signature@~1.2.0: - version "1.2.0" - resolved "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz" - integrity sha1-muzZJRFHcvPZW2WmCruPfBj7rOE= - dependencies: - assert-plus "^1.0.0" - jsprim "^1.2.2" - sshpk "^1.7.0" - -humanize-duration@3.10.0: - version "3.10.0" - resolved "https://registry.npmjs.org/humanize-duration/-/humanize-duration-3.10.0.tgz" - integrity sha1-TRW8yu/LEkAbTYBHXPbEmgOeOVk= - -is-typedarray@~1.0.0: - version "1.0.0" - resolved "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz" - integrity sha1-5HnICFjfDBsR3dppQPlgEfzaSpo= - -isstream@~0.1.2: - version "0.1.2" - resolved "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz" - integrity sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo= - -jsbn@~0.1.0: - version "0.1.1" - resolved "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz" - integrity sha1-peZUwuWi3rXyAdls77yoDA7y9RM= - -json-schema-traverse@^0.4.1: - version "0.4.1" - resolved "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz" - integrity sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg== - -json-schema@0.2.3: - version "0.2.3" - resolved "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz" - integrity sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM= - -json-stringify-safe@~5.0.1: - version "5.0.1" - resolved "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz" - integrity sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus= - -jsprim@^1.2.2: - version "1.4.1" - resolved "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz" - integrity sha1-MT5mvB5cwG5Di8G3SZwuXFastqI= - dependencies: - assert-plus "1.0.0" - extsprintf "1.3.0" - json-schema "0.2.3" - verror "1.10.0" - -lodash@^4.17.19: - version "4.17.21" - resolved "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz" - integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg== - -mime-db@1.46.0: - version "1.46.0" - resolved "https://registry.npmjs.org/mime-db/-/mime-db-1.46.0.tgz" - integrity sha512-svXaP8UQRZ5K7or+ZmfNhg2xX3yKDMUzqadsSqi4NCH/KomcH75MAMYAGVlvXn4+b/xOPhS3I2uHKRUzvjY7BQ== - -mime-types@^2.1.12, mime-types@~2.1.19: - version "2.1.29" - resolved "https://registry.npmjs.org/mime-types/-/mime-types-2.1.29.tgz" - integrity sha512-Y/jMt/S5sR9OaqteJtslsFZKWOIIqMACsJSiHghlCAyhf7jfVYjKBmLiX8OgpWeW+fjJ2b+Az69aPFPkUOY6xQ== - dependencies: - mime-db "1.46.0" - -node-fetch@^2.6.7: - version "2.6.7" - resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.7.tgz#24de9fba827e3b4ae44dc8b20256a379160052ad" - integrity sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ== - dependencies: - whatwg-url "^5.0.0" - -oauth-sign@~0.9.0: - version "0.9.0" - resolved "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz" - integrity sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ== - -performance-now@^2.1.0: - version "2.1.0" - resolved "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz" - integrity sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns= - -psl@^1.1.28: - version "1.8.0" - resolved "https://registry.npmjs.org/psl/-/psl-1.8.0.tgz" - integrity sha512-RIdOzyoavK+hA18OGGWDqUTsCLhtA7IcZ/6NCs4fFJaHBDab+pDDmDIByWFRQJq2Cd7r1OoQxBGKOaztq+hjIQ== - -punycode@^2.1.0, punycode@^2.1.1: - version "2.1.1" - resolved "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz" - integrity sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A== - -qs@~6.5.2: - version "6.5.3" - resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.3.tgz#3aeeffc91967ef6e35c0e488ef46fb296ab76aad" - integrity sha512-qxXIEh4pCGfHICj1mAJQ2/2XVZkjCDTcEgfoSQxc/fYivUZxTkk7L3bDBJSoNrEzXI17oUO5Dp07ktqE5KzczA== - -request-promise-core@1.1.4: - version "1.1.4" - resolved "https://registry.npmjs.org/request-promise-core/-/request-promise-core-1.1.4.tgz" - integrity sha512-TTbAfBBRdWD7aNNOoVOBH4pN/KigV6LyapYNNlAPA8JwbovRti1E88m3sYAwsLi5ryhPKsE9APwnjFTgdUjTpw== - dependencies: - lodash "^4.17.19" - -request-promise-native@^1.0.7: - version "1.0.9" - resolved "https://registry.npmjs.org/request-promise-native/-/request-promise-native-1.0.9.tgz" - integrity sha512-wcW+sIUiWnKgNY0dqCpOZkUbF/I+YPi+f09JZIDa39Ec+q82CpSYniDp+ISgTTbKmnpJWASeJBPZmoxH84wt3g== - dependencies: - request-promise-core "1.1.4" - stealthy-require "^1.1.1" - tough-cookie "^2.3.3" - -request@^2.88.0: - version "2.88.2" - resolved "https://registry.npmjs.org/request/-/request-2.88.2.tgz" - integrity sha512-MsvtOrfG9ZcrOwAW+Qi+F6HbD0CWXEh9ou77uOb7FM2WPhwT7smM833PzanhJLsgXjN89Ir6V2PczXNnMpwKhw== - dependencies: - aws-sign2 "~0.7.0" - aws4 "^1.8.0" - caseless "~0.12.0" - combined-stream "~1.0.6" - extend "~3.0.2" - forever-agent "~0.6.1" - form-data "~2.3.2" - har-validator "~5.1.3" - http-signature "~1.2.0" - is-typedarray "~1.0.0" - isstream "~0.1.2" - json-stringify-safe "~5.0.1" - mime-types "~2.1.19" - oauth-sign "~0.9.0" - performance-now "^2.1.0" - qs "~6.5.2" - safe-buffer "^5.1.2" - tough-cookie "~2.5.0" - tunnel-agent "^0.6.0" - uuid "^3.3.2" - -safe-buffer@^5.0.1, safe-buffer@^5.1.2: - version "5.2.1" - resolved "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz" - integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== - -safer-buffer@^2.0.2, safer-buffer@^2.1.0, safer-buffer@~2.1.0: - version "2.1.2" - resolved "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz" - integrity sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg== - -sshpk@^1.7.0: - version "1.16.1" - resolved "https://registry.npmjs.org/sshpk/-/sshpk-1.16.1.tgz" - integrity sha512-HXXqVUq7+pcKeLqqZj6mHFUMvXtOJt1uoUx09pFW6011inTMxqI8BA8PM95myrIyyKwdnzjdFjLiE6KBPVtJIg== - dependencies: - asn1 "~0.2.3" - assert-plus "^1.0.0" - bcrypt-pbkdf "^1.0.0" - dashdash "^1.12.0" - ecc-jsbn "~0.1.1" - getpass "^0.1.1" - jsbn "~0.1.0" - safer-buffer "^2.0.2" - tweetnacl "~0.14.0" - -stealthy-require@^1.1.1: - version "1.1.1" - resolved "https://registry.npmjs.org/stealthy-require/-/stealthy-require-1.1.1.tgz" - integrity sha1-NbCYdbT/SfJqd35QmzCQoyJr8ks= - -tough-cookie@^2.3.3, tough-cookie@~2.5.0: - version "2.5.0" - resolved "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.5.0.tgz" - integrity sha512-nlLsUzgm1kfLXSXfRZMc1KLAugd4hqJHDTvc2hDIwS3mZAfMEuMbc03SujMF+GEcpaX/qboeycw6iO8JwVv2+g== - dependencies: - psl "^1.1.28" - punycode "^2.1.1" - -tr46@~0.0.3: - version "0.0.3" - resolved "https://registry.yarnpkg.com/tr46/-/tr46-0.0.3.tgz#8184fd347dac9cdc185992f3a6622e14b9d9ab6a" - integrity sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o= - -tunnel-agent@^0.6.0: - version "0.6.0" - resolved "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz" - integrity sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0= - dependencies: - safe-buffer "^5.0.1" - -tweetnacl@^0.14.3, tweetnacl@~0.14.0: - version "0.14.5" - resolved "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz" - integrity sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q= - -uri-js@^4.2.2: - version "4.4.1" - resolved "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz" - integrity sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg== - dependencies: - punycode "^2.1.0" - -uuid@^3.3.2: - version "3.4.0" - resolved "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz" - integrity sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A== - -verror@1.10.0: - version "1.10.0" - resolved "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz" - integrity sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA= - dependencies: - assert-plus "^1.0.0" - core-util-is "1.0.2" - extsprintf "^1.2.0" - -webidl-conversions@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871" - integrity sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE= - -whatwg-url@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-5.0.0.tgz#966454e8765462e37644d3626f6742ce8b70965d" - integrity sha1-lmRU6HZUYuN2RNNib2dCzotwll0= - dependencies: - tr46 "~0.0.3" - webidl-conversions "^3.0.0" diff --git a/tfjs-master/scripts/cloud_funcs/sync_reactnative/.gcloudignore b/tfjs-master/scripts/cloud_funcs/sync_reactnative/.gcloudignore deleted file mode 100644 index ccc4eb240..000000000 --- a/tfjs-master/scripts/cloud_funcs/sync_reactnative/.gcloudignore +++ /dev/null @@ -1,16 +0,0 @@ -# This file specifies files that are *not* uploaded to Google Cloud Platform -# using gcloud. It follows the same syntax as .gitignore, with the addition of -# "#!include" directives (which insert the entries of the given .gitignore-style -# file at that point). -# -# For more information, run: -# $ gcloud topic gcloudignore -# -.gcloudignore -# If you would like to upload your .git directory, .gitignore file or files -# from your .gitignore file, remove the corresponding line -# below: -.git -.gitignore - -node_modules diff --git a/tfjs-master/scripts/cloud_funcs/sync_reactnative/index.js b/tfjs-master/scripts/cloud_funcs/sync_reactnative/index.js deleted file mode 100644 index 7d20ac418..000000000 --- a/tfjs-master/scripts/cloud_funcs/sync_reactnative/index.js +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2019 Google LLC. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= - -const kms = require('@google-cloud/kms'); -const request = require('request-promise-native'); - -const projectId = 'learnjs-174218'; -const locationId = 'global'; -const keyRingId = 'tfjs'; -const cryptoKeyId = 'enc' -const ciphertext = - 'CiQAkwyoIW0LcnxymzotLwaH4udVTQFBEN4AEA5CA+a3+yflL2ASPQAD8BdZnGARf78MhH5T9rQqyz9HNODwVjVIj64CTkFlUCGrP1B2HX9LXHWHLmtKutEGTeFFX9XhuBzNExA='; -const browserStackUploadUrl = - 'https://api-cloud.browserstack.com/app-automate/upload'; -const browserStackUser = 'deeplearnjs1'; -const testAppUrl = - 'https://storage.googleapis.com/tfjs-rn/integration-tests/app-debug.apk'; -const appUploadId = 'tfjs-rn-integration-android'; - -async function sync_reactnative(event, context, callback) { - const client = new kms.KeyManagementServiceClient(); - const name = - client.cryptoKeyPath(projectId, locationId, keyRingId, cryptoKeyId); - - const [result] = await client.decrypt({name, ciphertext}); - const browserStackKey = result.plaintext.toString(); - - try { - const syncRes = await request.post(browserStackUploadUrl, { - auth: { - user: browserStackUser, - pass: browserStackKey, - }, - form: { - data: JSON.stringify({'url': testAppUrl, 'custom_id': appUploadId}), - } - }); - sendChatMsg( - process.env.BOTS_HANGOUTS_URL, - 'Success syncing tfjs-react-native integration test app to BrowserStack'); - } catch (e) { - console.log('Error syncing app to browserstack', e); - sendChatMsg( - process.env.HANGOUTS_URL, - 'Error syncing tfjs-react-native integration test app to BrowserStack'); - } -}; - -async function sendChatMsg(url, msg) { - const res = await request(url, { - resolveWithFullResponse: true, - method: 'POST', - json: true, - body: {text: msg}, - }); -} - -module.exports.sync_reactnative = sync_reactnative; diff --git a/tfjs-master/scripts/cloud_funcs/sync_reactnative/package.json b/tfjs-master/scripts/cloud_funcs/sync_reactnative/package.json deleted file mode 100644 index b125bad44..000000000 --- a/tfjs-master/scripts/cloud_funcs/sync_reactnative/package.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name": "cloudfunc-tfjs-rn", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "start": "functions-framework --target=sync_reactnative" - }, - "dependencies": { - "@google-cloud/functions-framework": "^1.3.2", - "@google-cloud/kms": "^1.5.3", - "request": "^2.88.0", - "request-promise-native": "^1.0.8" - } -} diff --git a/tfjs-master/scripts/cloud_funcs/trigger_nightly/.gcloudignore b/tfjs-master/scripts/cloud_funcs/trigger_nightly/.gcloudignore deleted file mode 100644 index ccc4eb240..000000000 --- a/tfjs-master/scripts/cloud_funcs/trigger_nightly/.gcloudignore +++ /dev/null @@ -1,16 +0,0 @@ -# This file specifies files that are *not* uploaded to Google Cloud Platform -# using gcloud. It follows the same syntax as .gitignore, with the addition of -# "#!include" directives (which insert the entries of the given .gitignore-style -# file at that point). -# -# For more information, run: -# $ gcloud topic gcloudignore -# -.gcloudignore -# If you would like to upload your .git directory, .gitignore file or files -# from your .gitignore file, remove the corresponding line -# below: -.git -.gitignore - -node_modules diff --git a/tfjs-master/scripts/cloud_funcs/trigger_nightly/index.js b/tfjs-master/scripts/cloud_funcs/trigger_nightly/index.js deleted file mode 100644 index 928a5e4a7..000000000 --- a/tfjs-master/scripts/cloud_funcs/trigger_nightly/index.js +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2019 Google LLC. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= - -const {google} = require('googleapis'); - -module.exports.nightly_tfjs = async data => { - const cloudbuild = google.cloudbuild('v1'); - const auth = await google.auth.getClient( - {scopes: ['https://www.googleapis.com/auth/cloud-platform']}); - google.options({auth}); - const resp = await cloudbuild.projects.triggers.run({ - 'projectId': 'learnjs-174218', - 'triggerId': '43c56710-ccb3-4db9-b746-603cffbf0c02', - 'resource': {'branchName': 'master'} - }); - console.log(resp); -}; diff --git a/tfjs-master/scripts/cloud_funcs/trigger_nightly/package.json b/tfjs-master/scripts/cloud_funcs/trigger_nightly/package.json deleted file mode 100644 index b31eb43eb..000000000 --- a/tfjs-master/scripts/cloud_funcs/trigger_nightly/package.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "name": "cloudbuild", - "version": "1.0.0", - "description": "", - "main": "index.js", - "dependencies": { - "googleapis": "^68.0.0" - } -} diff --git a/tfjs-master/scripts/cloudbuild_e2e_expected.yml b/tfjs-master/scripts/cloudbuild_e2e_expected.yml deleted file mode 100644 index 917d66e64..000000000 --- a/tfjs-master/scripts/cloudbuild_e2e_expected.yml +++ /dev/null @@ -1,227 +0,0 @@ -steps: - - name: gcr.io/learnjs-174218/release - entrypoint: yarn - id: yarn-common - args: - - install - - name: gcr.io/learnjs-174218/release - dir: scripts - id: test-generate-cloudbuild - entrypoint: yarn - args: - - test-generate-cloudbuild - waitFor: - - yarn-common - - name: gcr.io/learnjs-174218/release - id: test-run-flaky - entrypoint: yarn - args: - - test-run-flaky - waitFor: - - yarn-common - - name: gcr.io/learnjs-174218/release - id: buildifier - entrypoint: yarn - args: - - buildifier-ci - waitFor: - - yarn-common - - name: gcr.io/learnjs-174218/release - id: tslint - entrypoint: yarn - args: - - lint - waitFor: - - yarn-common - - name: gcr.io/learnjs-174218/release - id: bazel-tests - waitFor: - - yarn-common - entrypoint: bash - args: - - ./scripts/run_bazel_ci_tests.sh - env: - - BROWSERSTACK_USERNAME=deeplearnjs1 - - NIGHTLY=$_NIGHTLY - secretEnv: - - BROWSERSTACK_KEY - - name: gcr.io/learnjs-174218/release - dir: link-package - entrypoint: yarn - id: yarn-link-package - args: - - install - waitFor: - - bazel-tests - - name: gcr.io/learnjs-174218/release - dir: link-package - entrypoint: yarn - id: yarn-link-package-build - args: - - build - - '--bazel_options=--config=ci' - waitFor: - - yarn-link-package - - name: gcr.io/learnjs-174218/release - dir: tfjs - entrypoint: yarn - id: yarn-tfjs - args: - - install - waitFor: - - yarn-common - - yarn-link-package-build - - name: gcr.io/learnjs-174218/release - dir: tfjs - entrypoint: yarn - id: build-tfjs - args: - - build-ci - waitFor: - - yarn-tfjs - - yarn-common - - yarn-link-package-build - - name: gcr.io/learnjs-174218/release - dir: tfjs - entrypoint: yarn - id: lint-tfjs - args: - - lint - waitFor: - - yarn-tfjs - - yarn-common - - yarn-link-package-build - - name: gcr.io/learnjs-174218/release - dir: tfjs-node - entrypoint: yarn - id: yarn-tfjs-node - args: - - install - waitFor: - - yarn-common - - yarn-link-package-build - - yarn-tfjs - - build-tfjs - - lint-tfjs - - name: gcr.io/learnjs-174218/release - dir: tfjs-node - entrypoint: yarn - id: build-addon-tfjs-node - args: - - build-addon-from-source - waitFor: - - yarn-tfjs-node - - yarn-common - - yarn-link-package-build - - yarn-tfjs - - build-tfjs - - lint-tfjs - - name: gcr.io/learnjs-174218/release - dir: tfjs-node - entrypoint: yarn - id: build-tfjs-node - args: - - build-ci - waitFor: - - yarn-tfjs-node - - yarn-common - - yarn-link-package-build - - yarn-tfjs - - build-tfjs - - lint-tfjs - - name: gcr.io/learnjs-174218/release - dir: tfjs-node - entrypoint: yarn - id: lint-tfjs-node - args: - - lint - waitFor: - - yarn-tfjs-node - - yarn-common - - yarn-link-package-build - - yarn-tfjs - - build-tfjs - - lint-tfjs - - name: gcr.io/learnjs-174218/release - dir: tfjs-node - entrypoint: yarn - id: ensure-cpu-gpu-packages-align-tfjs-node - args: - - ensure-cpu-gpu-packages-align - waitFor: - - yarn-common - - yarn-link-package-build - - yarn-tfjs - - build-tfjs - - lint-tfjs - - name: gcr.io/learnjs-174218/release - dir: e2e - entrypoint: yarn - id: yarn-e2e - args: - - install - waitFor: - - yarn-common - - yarn-link-package-build - - yarn-tfjs - - build-tfjs - - lint-tfjs - - yarn-tfjs-node - - build-addon-tfjs-node - - build-tfjs-node - - lint-tfjs-node - - ensure-cpu-gpu-packages-align-tfjs-node - - name: gcr.io/learnjs-174218/release - dir: e2e - entrypoint: yarn - id: fetch-graph-model-golden-data-e2e - args: - - fetch-graph-model-golden-data-ci - waitFor: - - yarn-common - - yarn-link-package-build - - yarn-tfjs - - build-tfjs - - lint-tfjs - - yarn-tfjs-node - - build-addon-tfjs-node - - build-tfjs-node - - lint-tfjs-node - - ensure-cpu-gpu-packages-align-tfjs-node - - name: gcr.io/learnjs-174218/release - dir: e2e - entrypoint: yarn - id: test-e2e - args: - - test-ci - env: - - BROWSERSTACK_USERNAME=deeplearnjs1 - - NIGHTLY=$_NIGHTLY - secretEnv: - - BROWSERSTACK_KEY - waitFor: - - yarn-e2e - - fetch-graph-model-golden-data-e2e - - yarn-common - - yarn-link-package-build - - yarn-tfjs - - build-tfjs - - lint-tfjs - - yarn-tfjs-node - - build-addon-tfjs-node - - build-tfjs-node - - lint-tfjs-node - - ensure-cpu-gpu-packages-align-tfjs-node -secrets: - - kmsKeyName: projects/learnjs-174218/locations/global/keyRings/tfjs/cryptoKeys/enc - secretEnv: - BROWSERSTACK_KEY: >- - CiQAkwyoIW0LcnxymzotLwaH4udVTQFBEN4AEA5CA+a3+yflL2ASPQAD8BdZnGARf78MhH5T9rQqyz9HNODwVjVIj64CTkFlUCGrP1B2HX9LXHWHLmtKutEGTeFFX9XhuBzNExA= -timeout: 7200s -logsBucket: 'gs://tfjs-build-logs' -substitutions: - _NIGHTLY: '' -options: - logStreamingOption: STREAM_ON - machineType: E2_HIGHCPU_32 - substitution_option: ALLOW_LOOSE diff --git a/tfjs-master/scripts/cloudbuild_general_config.yml b/tfjs-master/scripts/cloudbuild_general_config.yml deleted file mode 100644 index a7d7b2491..000000000 --- a/tfjs-master/scripts/cloudbuild_general_config.yml +++ /dev/null @@ -1,86 +0,0 @@ -steps: -# Install top-level deps. -- name: 'gcr.io/learnjs-174218/release' - entrypoint: 'yarn' - id: 'yarn-common' - args: ['install'] - waitedForByPackages: true - -# Test generate_cloudbuild.js -# See #4523 for why this is special-cased into every cloudbuild. -- name: 'gcr.io/learnjs-174218/release' - dir: 'scripts' - id: 'test-generate-cloudbuild' - entrypoint: 'yarn' - args: ['test-generate-cloudbuild'] - waitFor: ['yarn-common'] - -# Test run_flaky.js -# The flaky test runner is important enough to test every time and takes less -# than 5 seconds. -- name: 'gcr.io/learnjs-174218/release' - id: 'test-run-flaky' - entrypoint: 'yarn' - args: ['test-run-flaky'] - waitFor: ['yarn-common'] - -# Lint bazel files. -- name: 'gcr.io/learnjs-174218/release' - id: 'buildifier' - entrypoint: 'yarn' - args: ['buildifier-ci'] - waitFor: ['yarn-common'] - -# Lint Bazel package typescript files. -- name: 'gcr.io/learnjs-174218/release' - id: 'tslint' - entrypoint: 'yarn' - args: ['lint'] - waitFor: ['yarn-common'] - -# Bazel tests -# These use a remote cache and only re-run if changes occurred, so we run them -# in every build. -- name: 'gcr.io/learnjs-174218/release' - id: 'bazel-tests' - waitFor: ['yarn-common'] - entrypoint: 'bash' - args: - - './scripts/run_bazel_ci_tests.sh' - env: - - 'BROWSERSTACK_USERNAME=deeplearnjs1' - - 'NIGHTLY=$_NIGHTLY' - secretEnv: ['BROWSERSTACK_KEY'] - -# The following step builds the link package, which is a temporary package -# that helps packages that don't build with Bazel load outputs from packages -# that build with Bazel. -- name: 'gcr.io/learnjs-174218/release' - dir: 'link-package' - entrypoint: 'yarn' - id: 'yarn-link-package' - args: ['install'] - waitFor: ['bazel-tests'] - -- name: 'gcr.io/learnjs-174218/release' - dir: 'link-package' - entrypoint: 'yarn' - id: 'yarn-link-package-build' - args: ['build', '--bazel_options=--config=ci'] - waitFor: ['yarn-link-package'] - waitedForByPackages: true - -# General configuration -secrets: -- kmsKeyName: projects/learnjs-174218/locations/global/keyRings/tfjs/cryptoKeys/enc - secretEnv: - BROWSERSTACK_KEY: CiQAkwyoIW0LcnxymzotLwaH4udVTQFBEN4AEA5CA+a3+yflL2ASPQAD8BdZnGARf78MhH5T9rQqyz9HNODwVjVIj64CTkFlUCGrP1B2HX9LXHWHLmtKutEGTeFFX9XhuBzNExA= - FIREBASE_KEY: CiQAkwyoIXmET39jOD3ywloCIa6+WUpu3w49twpMmkMqy0vS+YsSUAAD8BdZQGOL8FKEBxr/1jl0G78OigwlNVHjD3usZobNtlOp8tV/9iacb8zPFqy0SwIO1gvz3HRr+VU7c7LS2qqaTCdacZF+dx3VJNewvdZu -timeout: 7200s -logsBucket: 'gs://tfjs-build-logs' -substitutions: - _NIGHTLY: '' -options: - logStreamingOption: 'STREAM_ON' - machineType: 'E2_HIGHCPU_32' - substitution_option: 'ALLOW_LOOSE' diff --git a/tfjs-master/scripts/cloudbuild_tfjs_node_expected.yml b/tfjs-master/scripts/cloudbuild_tfjs_node_expected.yml deleted file mode 100644 index 72cb08b64..000000000 --- a/tfjs-master/scripts/cloudbuild_tfjs_node_expected.yml +++ /dev/null @@ -1,242 +0,0 @@ -steps: - - name: gcr.io/learnjs-174218/release - entrypoint: yarn - id: yarn-common - args: - - install - - name: gcr.io/learnjs-174218/release - dir: scripts - id: test-generate-cloudbuild - entrypoint: yarn - args: - - test-generate-cloudbuild - waitFor: - - yarn-common - - name: gcr.io/learnjs-174218/release - id: test-run-flaky - entrypoint: yarn - args: - - test-run-flaky - waitFor: - - yarn-common - - name: gcr.io/learnjs-174218/release - id: buildifier - entrypoint: yarn - args: - - buildifier-ci - waitFor: - - yarn-common - - name: gcr.io/learnjs-174218/release - id: tslint - entrypoint: yarn - args: - - lint - waitFor: - - yarn-common - - name: gcr.io/learnjs-174218/release - id: bazel-tests - waitFor: - - yarn-common - entrypoint: bash - args: - - ./scripts/run_bazel_ci_tests.sh - env: - - BROWSERSTACK_USERNAME=deeplearnjs1 - - NIGHTLY=$_NIGHTLY - secretEnv: - - BROWSERSTACK_KEY - - name: gcr.io/learnjs-174218/release - dir: link-package - entrypoint: yarn - id: yarn-link-package - args: - - install - waitFor: - - bazel-tests - - name: gcr.io/learnjs-174218/release - dir: link-package - entrypoint: yarn - id: yarn-link-package-build - args: - - build - - '--bazel_options=--config=ci' - waitFor: - - yarn-link-package - - name: gcr.io/learnjs-174218/release - dir: tfjs - entrypoint: yarn - id: yarn-tfjs - args: - - install - waitFor: - - yarn-common - - yarn-link-package-build - - name: gcr.io/learnjs-174218/release - dir: tfjs - entrypoint: yarn - id: build-tfjs - args: - - build-ci - waitFor: - - yarn-tfjs - - yarn-common - - yarn-link-package-build - - name: gcr.io/learnjs-174218/release - dir: tfjs - entrypoint: yarn - id: lint-tfjs - args: - - lint - waitFor: - - yarn-tfjs - - yarn-common - - yarn-link-package-build - - name: gcr.io/learnjs-174218/release - dir: tfjs-node - entrypoint: yarn - id: yarn-tfjs-node - args: - - install - waitFor: - - yarn-common - - yarn-link-package-build - - yarn-tfjs - - build-tfjs - - lint-tfjs - - name: gcr.io/learnjs-174218/release - dir: tfjs-node - entrypoint: yarn - id: build-addon-tfjs-node - args: - - build-addon-from-source - waitFor: - - yarn-tfjs-node - - yarn-common - - yarn-link-package-build - - yarn-tfjs - - build-tfjs - - lint-tfjs - - name: gcr.io/learnjs-174218/release - dir: tfjs-node - entrypoint: yarn - id: build-tfjs-node - args: - - build-ci - waitFor: - - yarn-tfjs-node - - yarn-common - - yarn-link-package-build - - yarn-tfjs - - build-tfjs - - lint-tfjs - - name: gcr.io/learnjs-174218/release - dir: tfjs-node - entrypoint: yarn - id: lint-tfjs-node - args: - - lint - waitFor: - - yarn-tfjs-node - - yarn-common - - yarn-link-package-build - - yarn-tfjs - - build-tfjs - - lint-tfjs - - name: gcr.io/learnjs-174218/release - dir: tfjs-node - entrypoint: yarn - id: test-tfjs-node - args: - - test-ci - waitFor: - - yarn-tfjs-node - - build-addon-tfjs-node - - lint-tfjs-node - - yarn-common - - yarn-link-package-build - - yarn-tfjs - - build-tfjs - - lint-tfjs - - name: gcr.io/learnjs-174218/release - dir: tfjs-node - entrypoint: yarn - id: ensure-cpu-gpu-packages-align-tfjs-node - args: - - ensure-cpu-gpu-packages-align - waitFor: - - yarn-common - - yarn-link-package-build - - yarn-tfjs - - build-tfjs - - lint-tfjs - - name: gcr.io/learnjs-174218/release - dir: e2e - entrypoint: yarn - id: yarn-e2e - args: - - install - waitFor: - - yarn-common - - yarn-link-package-build - - yarn-tfjs - - build-tfjs - - lint-tfjs - - yarn-tfjs-node - - build-addon-tfjs-node - - build-tfjs-node - - lint-tfjs-node - - ensure-cpu-gpu-packages-align-tfjs-node - - name: gcr.io/learnjs-174218/release - dir: e2e - entrypoint: yarn - id: fetch-graph-model-golden-data-e2e - args: - - fetch-graph-model-golden-data-ci - waitFor: - - yarn-common - - yarn-link-package-build - - yarn-tfjs - - build-tfjs - - lint-tfjs - - yarn-tfjs-node - - build-addon-tfjs-node - - build-tfjs-node - - lint-tfjs-node - - ensure-cpu-gpu-packages-align-tfjs-node - - name: gcr.io/learnjs-174218/release - dir: e2e - entrypoint: yarn - id: test-e2e - args: - - test-ci - env: - - BROWSERSTACK_USERNAME=deeplearnjs1 - - NIGHTLY=$_NIGHTLY - secretEnv: - - BROWSERSTACK_KEY - waitFor: - - yarn-e2e - - fetch-graph-model-golden-data-e2e - - yarn-common - - yarn-link-package-build - - yarn-tfjs - - build-tfjs - - lint-tfjs - - yarn-tfjs-node - - build-addon-tfjs-node - - build-tfjs-node - - lint-tfjs-node - - ensure-cpu-gpu-packages-align-tfjs-node -secrets: - - kmsKeyName: projects/learnjs-174218/locations/global/keyRings/tfjs/cryptoKeys/enc - secretEnv: - BROWSERSTACK_KEY: >- - CiQAkwyoIW0LcnxymzotLwaH4udVTQFBEN4AEA5CA+a3+yflL2ASPQAD8BdZnGARf78MhH5T9rQqyz9HNODwVjVIj64CTkFlUCGrP1B2HX9LXHWHLmtKutEGTeFFX9XhuBzNExA= -timeout: 7200s -logsBucket: 'gs://tfjs-build-logs' -substitutions: - _NIGHTLY: '' -options: - logStreamingOption: STREAM_ON - machineType: E2_HIGHCPU_32 - substitution_option: ALLOW_LOOSE diff --git a/tfjs-master/scripts/find_packages_with_diff.js b/tfjs-master/scripts/find_packages_with_diff.js deleted file mode 100644 index 28810ca14..000000000 --- a/tfjs-master/scripts/find_packages_with_diff.js +++ /dev/null @@ -1,124 +0,0 @@ -#!/usr/bin/env node -// Copyright 2019 Google LLC. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= - -const {exec} = require('./test-util'); -const shell = require('shelljs'); -const {readFileSync} = require('fs'); -const {join} = require('path'); - - -const filesAllowlistToTriggerBuild = [ - 'cloudbuild.yml', 'package.json', 'tsconfig.json', 'tslint.json', - 'scripts/find_packages_with_diff.js', 'scripts/run-build.sh', - 'scripts/generate_cloudbuild.js' -]; - -const CLONE_PATH = '/tmp/tfjs-diff-clone'; -let commitSha = process.env['COMMIT_SHA']; -let branchName = process.env['BRANCH_NAME']; -let baseBranch = process.env['BASE_BRANCH']; - - -const packageDependencies = JSON.parse(readFileSync( - join(__dirname, 'package_dependencies.json'), 'utf8')); -const allPackages = Object.keys(packageDependencies); - - -function findPackagesWithDiff() { - // For Nightly build, baseBranch is one of the falsey values. We use master - // for Nightly build. - if (!baseBranch) { - baseBranch = 'master'; - } - console.log('commitSha: ', commitSha); - console.log('branchName: ', branchName); - console.log('baseBranch: ', baseBranch); - - // We cannot do --depth=1 here because we need to check out an old merge base. - // We cannot do --single-branch here because we need multiple branches. - console.log(`Clone branch ${baseBranch}`); - shell.rm('-rf', CLONE_PATH); - exec(`git clone -b ${baseBranch} https://github.com/tensorflow/tfjs ${ - CLONE_PATH}`); - - console.log(); // Break up the console for readability. - - const originalPath = process.cwd(); - shell.cd(CLONE_PATH); - - // If we cannot check out the commit then this PR is coming from a fork. - const res = shell.exec(`git checkout ${commitSha}`, {silent: true}); - const isPullRequestFromFork = res.code !== 0; - - // Only checkout the merge base if the pull requests comes from a - // tensorflow/tfjs branch. Otherwise clone master and diff against master. - if (!isPullRequestFromFork) { - console.log('PR is coming from tensorflow/tfjs. Finding the merge base...'); - exec(`git checkout ${branchName}`); - const mergeBase = - exec(`git merge-base ${baseBranch} ${branchName}`).stdout.trim(); - exec(`git fetch origin ${mergeBase}`); - exec(`git checkout ${mergeBase}`); - console.log('mergeBase: ', mergeBase); - } else { - console.log(`PR is going to diff against branch ${baseBranch}.`); - } - shell.cd(originalPath); - console.log(); // Break up the console for readability. - - let triggerAllBuilds = false; - let allowlistDiffOutput = []; - filesAllowlistToTriggerBuild.forEach(fileToTriggerBuild => { - const diffOutput = diff(fileToTriggerBuild); - if (diffOutput !== '') { - console.log(fileToTriggerBuild, 'has changed. Triggering all builds.'); - triggerAllBuilds = true; - allowlistDiffOutput.push(diffOutput); - } - }); - - console.log(); // Break up the console for readability. - - let packagesWithDiff = []; - allPackages.forEach(dir => { - const diffOutput = diff(`${dir}/`); - if (diffOutput !== '') { - console.log(`${dir} has modified files.`); - } else { - console.log(`No modified files found in ${dir}`); - } - - const shouldDiff = diffOutput !== '' || triggerAllBuilds; - if (shouldDiff) { - packagesWithDiff.push(dir); - } - }); - - console.log(); // Break up the console for readability. - - console.log(`Packages directly affected: ${packagesWithDiff.join(', ')}`); - return packagesWithDiff; -} - -function diff(fileOrDirName) { - const diffCmd = `diff -rq --exclude='settings.json' ` + - `${CLONE_PATH}/${fileOrDirName} ` + - `${join(__dirname, '../', fileOrDirName)}`; - return exec(diffCmd, {silent: true}, true).stdout.trim(); -} - -exports.findPackagesWithDiff = findPackagesWithDiff; -exports.allPackages = allPackages; diff --git a/tfjs-master/scripts/generate_cloudbuild.ts b/tfjs-master/scripts/generate_cloudbuild.ts deleted file mode 100644 index d9450cf8b..000000000 --- a/tfjs-master/scripts/generate_cloudbuild.ts +++ /dev/null @@ -1,223 +0,0 @@ -// Copyright 2020 Google LLC. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= - -import {printTable} from 'console-table-printer'; -import * as fs from 'fs'; -import * as yaml from 'js-yaml'; -import * as path from 'path'; -import {BAZEL_PACKAGES} from './bazel_packages'; -import {DEPENDENCY_GRAPH, DEPENDENCY_ORDER, findDeps, findReverseDeps} from './graph_utils'; - -// Steps to exclude from cloudbuild files. -const EXCLUDE_STEPS = new Set(['build-deps', 'yarn-common']); - -interface CloudbuildStep { - name: string, - id: string, - waitFor?: string[], - secretEnv?: string[]; -} - -const CUSTOM_PROPS = new Set(['nightlyOnly', 'waitedForByPackages']); -interface CustomCloudbuildStep extends CloudbuildStep { - nightlyOnly?: boolean; // Only run during nightly tests - waitedForByPackages?: boolean; // Other non-bazel pacakges `waitFor` this step -} - -function removeCustomProps(step: CustomCloudbuildStep): CloudbuildStep { - return Object.fromEntries( - Object.entries(step).filter(([k, ]) => !CUSTOM_PROPS.has(k)) - ) as CloudbuildStep; -} - -interface CloudbuildSecret { - kmsKeyName: string, - secretEnv: { - [index: string]: string, - } -} - -export interface CloudbuildYaml { - steps: CustomCloudbuildStep[], - secrets: CloudbuildSecret[], -} - - -/** - * Construct a cloudbuild.yml file that does the following: - * 1. Builds all the dependencies of `packages` - * 2. Builds and tests all the packages in `packages` - * 3. Builds and tests all the reverse dependnecies of `packages` - */ -export function generateCloudbuild(packages: Iterable, nightly = false, print = true) { - // Make sure all packages are declared in package_dependencies.json. - const allPackages = new Set(Object.keys(DEPENDENCY_GRAPH)); - for (const packageName of packages) { - if (!allPackages.has(packageName) && - // TODO: remove this check once tfjs-react-native nightly test is fixed. - packageName !== 'tfjs-react-native') { - throw new Error( - `Package ${packageName} was not declared in ` + - 'package_dependencies.json'); - } - } - - const deps = findDeps(packages); - const reverseDeps = findReverseDeps(packages); - const depsOfReverseDeps = findDeps(reverseDeps); - - const toBuild = - new Set([...deps, ...packages, ...reverseDeps, ...depsOfReverseDeps]); - const toTest = new Set([...packages, ...reverseDeps]); - - if (print) { - // Log what will be built and tested - const buildTestTable = []; - for (const packageName of allPackages) { - const bazel = BAZEL_PACKAGES.has(packageName); - const bazelStr = 'bazel '; // Spaces for left alignment - buildTestTable.push({ - 'Package': packageName, - 'Will Build': bazel ? bazelStr : toBuild.has(packageName) ? '✔' : '', - 'Will Test': bazel ? bazelStr : toTest.has(packageName) ? '✔' : '', - }); - } - printTable(buildTestTable); - } - - // Load the general cloudbuild config - const baseCloudbuild = - yaml.load(fs.readFileSync(path.join( - __dirname, 'cloudbuild_general_config.yml'), 'utf8')) as CloudbuildYaml; - - // Filter steps that only run in nightly tests. - const nightlyFilter = (step: CustomCloudbuildStep) => nightly || !step.nightlyOnly; - const customSteps = baseCloudbuild.steps.filter(nightlyFilter); - - // Steps that are waited for by non-bazel packages. - const waitedForByPackages = customSteps - .filter(step => step.waitedForByPackages) - .map(step => step.id); - - const steps = customSteps.map(removeCustomProps); - - // Load all the cloudbuild files for the packages - // that need to be built or tested. - const packageCloudbuildSteps = new Map>(); - for (const packageName of new Set([...toBuild, ...toTest])) { - if (BAZEL_PACKAGES.has(packageName)) { - // Do not build or test Bazel packages. The bazel-tests step does this. - continue; - } - const doc = yaml.load( - fs.readFileSync(path.join(__dirname, '../', packageName, - 'cloudbuild.yml'), 'utf8')) as CloudbuildYaml; - packageCloudbuildSteps.set(packageName, new Set(doc.steps)); - } - - // Filter out excluded steps. Also remove test steps if the package is - // not going to be tested. Change step ids to avoid name conflicts. - for (const [packageName, steps] of packageCloudbuildSteps.entries()) { - // TODO(msoulanille): Steps that depend on excluded steps might still - // need to wait for the steps that the excluded steps wait for. - for (const step of steps) { - if (!step.id) { - throw new Error(`Step from ${packageName} missing id`); - } - - // Exclude a specific set of steps defined in `excludeSteps`. - // Only include test steps if the package - // is to be tested. - if (EXCLUDE_STEPS.has(step.id) || - (!toTest.has(packageName) && isTestStep(step.id))) { - steps.delete(step); - continue; - } - - // Append package name to each step's id. - if (step.id) { - // Test steps are not required to have ids. - step.id = makeStepId(step.id, packageName); - } - - // Append package names to step ids in the 'waitFor' field. - if (step.waitFor) { - step.waitFor = step.waitFor.filter(id => id && !EXCLUDE_STEPS.has(id)) - .map(id => makeStepId(id, packageName)); - } - } - } - - // Set 'waitFor' fields based on dependencies. - for (const [packageName, steps] of packageCloudbuildSteps.entries()) { - // Construct the set of step ids that rules in this package must wait for. - // All packages depend on 'yarn-common' and 'yarn-link-package-build', so - // we special-case them here. - const waitForSteps = new Set(waitedForByPackages); - for (const dependencyName of (DEPENDENCY_GRAPH[packageName] || new Set())) { - const cloudbuildSteps = - packageCloudbuildSteps.get(dependencyName) || new Set(); - - for (const step of cloudbuildSteps) { - if (!isTestStep(step.id)) { - waitForSteps.add(step.id); - } - } - } - - // Add the above step ids to the `waitFor` field in each step. - for (const step of steps) { - step.waitFor = [...new Set([...(step.waitFor || []), ...waitForSteps])] - } - } - - // Arrange steps in dependency order - for (const packageName of DEPENDENCY_ORDER) { - const packageSteps = packageCloudbuildSteps.get(packageName); - if (packageSteps) { - for (const step of packageSteps) { - steps.push(step); - } - } - } - - // Remove unused secrets. Cloudbuild fails if extra secrets are included. - const usedSecrets = new Set(); - for (const step of steps) { - for (const secret of step.secretEnv || []) { - usedSecrets.add(secret); - } - } - const secretEnv = baseCloudbuild.secrets[0].secretEnv; - for (const secret of Object.keys(secretEnv)) { - if (!usedSecrets.has(secret)) { - delete secretEnv[secret]; - } - } - if (Object.keys(secretEnv).length === 0) { - delete baseCloudbuild.secrets; - } - - baseCloudbuild.steps = steps; - return baseCloudbuild; -} - -function isTestStep(id: string) { - return id.includes('test'); -} - -function makeStepId(id: string, packageName: string) { - return `${id}-${packageName}`; -} diff --git a/tfjs-master/scripts/generate_cloudbuild_for_packages.ts b/tfjs-master/scripts/generate_cloudbuild_for_packages.ts deleted file mode 100644 index b63c0377b..000000000 --- a/tfjs-master/scripts/generate_cloudbuild_for_packages.ts +++ /dev/null @@ -1,60 +0,0 @@ -#!/usr/bin/env node -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -const {findPackagesWithDiff, allPackages} = - require('./find_packages_with_diff.js'); -const {generateCloudbuild} = require('./generate_cloudbuild'); -const {ArgumentParser} = require('argparse'); -const yaml = require('js-yaml'); -const fs = require('fs'); - -const parser = new ArgumentParser({ - description: 'Generate a cloudbuild file to test packages. When run' + - ' with no arguments, tests packages affected by the current' + - ' changes.' -}); - -parser.addArgument('packages', { - type: String, - nargs: '*', - help: 'packages to consider as having changed', -}); - -parser.addArgument(['-o', '--output'], { - type: String, - nargs: '?', - defaultValue: 'cloudbuild_generated.yml', -}); - -const args = parser.parseArgs(process.argv.slice(2)); - -let packages; -const nightly = process.env['NIGHTLY'] -if (args.packages.length > 0) { - // Test packages specified in command line args. - packages = args.packages; -} else if (nightly) { - // Test all packages during the nightly build. - packages = allPackages; -} else { - // Test packages that have changed. - packages = findPackagesWithDiff(); -} - -const cloudbuild = generateCloudbuild(packages, nightly); -fs.writeFileSync(args.output, yaml.safeDump(cloudbuild)); diff --git a/tfjs-master/scripts/generate_cloudbuild_test.ts b/tfjs-master/scripts/generate_cloudbuild_test.ts deleted file mode 100644 index 5cf578dbf..000000000 --- a/tfjs-master/scripts/generate_cloudbuild_test.ts +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2020 Google LLC. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= - -import { generateCloudbuild, CloudbuildYaml} from './generate_cloudbuild'; -//const generateCloudbuild = require('./generate_cloudbuild').generateCloudbuild; -import * as yaml from 'js-yaml'; -import * as fs from 'fs'; -import * as path from 'path'; - -// These tests only detect changes in the generated file, and may need to be -// updated if the project structure changes. To update them, run -// 'yarn update-cloudbuild-tests`. -// TODO(mattsoulanille): When Jasmine is updated to >=3.3.0, Use -// jasmine.withContext to show the above message if the tests fail. -describe('generateCloudbuild', () => { - it('generates the correct cloudbuild file for e2e', () => { - const expectedCloudbuild = yaml.load(fs.readFileSync( - path.join(__dirname, 'cloudbuild_e2e_expected.yml'), 'utf8')); - const cloudbuild = generateCloudbuild(['e2e'], /* nightly */ false, - /* print */ false); - expect(cloudbuild).toEqual(expectedCloudbuild as CloudbuildYaml); - }); - - it('generates the correct cloudbuild file for tfjs-node', () => { - const expectedCloudbuild = yaml.load(fs.readFileSync( - path.join(__dirname, 'cloudbuild_tfjs_node_expected.yml'), 'utf8')); - const cloudbuild = generateCloudbuild(['tfjs-node'], /* nightly */ false, - /* print */ false); - expect(cloudbuild).toEqual(expectedCloudbuild as CloudbuildYaml); - }); -}); diff --git a/tfjs-master/scripts/graph_utils.ts b/tfjs-master/scripts/graph_utils.ts deleted file mode 100644 index f19b02633..000000000 --- a/tfjs-master/scripts/graph_utils.ts +++ /dev/null @@ -1,150 +0,0 @@ -// Copyright 2023 Google LLC. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= - -import * as fs from 'fs'; -import * as path from 'path'; - -export const DEPENDENCY_GRAPH = JSON.parse( - fs.readFileSync(path.join(__dirname, 'package_dependencies.json'), 'utf8')); - -// This is a reverse dependencies graph. Each entry in the graph lists the -// packages that depend on it. -export const REVERSE_DEPENDENCY_GRAPH = transposeGraph(DEPENDENCY_GRAPH); - -// Topologically sort the dependency tree and arrange -// steps in dependency order. -export const DEPENDENCY_ORDER = topologicalSort(DEPENDENCY_GRAPH); - -export type Graph = Iterable> = { - [node: string]: V -} - -/** - * Verify that an object is a valid graph. - */ -export function verifyGraph(graph: Graph) { - const nodes = new Set(Object.keys(graph)); - for (const [node, edges] of Object.entries(graph)) { - for (const edge of edges) { - if (!nodes.has(edge)) { - throw new Error( - `Graph edge ${edge} of node ${node} not found in the graph`); - } - } - } -} - -/** - * Transpose a directed graph i.e. reverse the direction of the edges. - */ -export function transposeGraph(graph: Graph) { - verifyGraph(graph); - const transposed: Graph> = {}; - for (const [nodeName, connectedNodes] of Object.entries(graph)) { - for (const connectedNode of connectedNodes) { - if (!transposed[connectedNode]) { - transposed[connectedNode] = new Set(); - } - if (!transposed[nodeName]) { - // Make sure the node itself ends up in the transposed graph. - transposed[nodeName] = new Set(); - } - transposed[connectedNode].add(nodeName); - } - } - return transposed; -} - -/** - * Topologically sort a directed acyclic graph. - * - * Returns a list of graph nodes such that, by following edges, - * you can only move forward in the list, not backward. - */ -export function topologicalSort(graph: Graph) { - // We can't use a standard sorting algorithm because - // often, two packages won't have any dependency relationship - // between each other, meaning they are incomparable. - verifyGraph(graph); - const sorted: string[] = []; - - while (sorted.length < Object.keys(graph).length) { - // Find nodes not yet in 'sorted' that have edges - // only to nodes already in 'sorted' - const emptyNodes = Object.entries(graph) - .filter(([node, edges]) => { - if (sorted.includes(node)) { - return false; - } - for (const edge of edges) { - if (!sorted.includes(edge)) { - return false; - } - } - return true; - }) - .map(([node, edges]) => node); - - // If there are no such nodes, then the graph has a cycle. - if (emptyNodes.length === 0) { - throw new Error('Dependency graph has a cycle.'); - } - - for (let node of emptyNodes) { - sorted.push(node); - } - } - return sorted; -} - -/** - * Find all subnodes in the subgraph generated by taking the transitive - * closure at `node`. - */ -export function findSubgraph(node: string, graph: Graph, subnodes = new Set()) { - const directSubnodes = graph[node]; - if (directSubnodes) { - for (const directSubnode of directSubnodes) { - if (!subnodes.has(directSubnode)) { - subnodes.add(directSubnode); - findSubgraph(directSubnode, graph, subnodes); - } - } - } - - return subnodes; -} - -/** - * Find the transitive closure of dependencies of the given packages. - */ -export function findDeps(packages: Iterable): Set { - return new Set( - [...packages] - .map(packageName => findSubgraph(packageName, DEPENDENCY_GRAPH)) - .reduce((a, b) => [...a, ...b], [])); -} - -/** - * Find the reverse dependencies of the given packages, i.e. find the - * set of packages that include at least one of the given packages in - * their transitive closure of dependencies. - */ -export function findReverseDeps(packages: Iterable): Set { - return new Set( - [...packages] - .map(packageName => findSubgraph(packageName, REVERSE_DEPENDENCY_GRAPH)) - .reduce((a, b) => [...a, ...b], [])); -} diff --git a/tfjs-master/scripts/make-version.js b/tfjs-master/scripts/make-version.js deleted file mode 100644 index 77ac3458e..000000000 --- a/tfjs-master/scripts/make-version.js +++ /dev/null @@ -1,79 +0,0 @@ -#!/usr/bin/env node -// Copyright 2018 Google LLC. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= - -// Run this script from the base directory (not the package directory): -// ./scripts/make-version.js DIR_NAME -// Where DIR_NAME is the directory name for the package you want to make a -// version for. -const fs = require('fs'); -const path = require('path'); - -const dirName = process.argv[2]; -const packageJsonFile = path.join(dirName, 'package.json'); -if (!fs.existsSync(packageJsonFile)) { - console.log( - packageJsonFile, 'does not exist. Please call this script as follows:'); - console.log('./scripts/make-version.js DIR_NAME'); - process.exit(1); -} - -const version = JSON.parse(fs.readFileSync(packageJsonFile, 'utf8')).version; - -const versionCode = `/** @license See the LICENSE file. */ - -// This code is auto-generated, do not modify this file! -const version = '${version}'; -export {version}; -` - -fs.writeFile(path.join(dirName, 'src/version.ts'), versionCode, err => { - if (err) { - throw new Error(`Could not save version file ${version}: ${err}`); - } - console.log(`Version file for version ${version} saved sucessfully.`); -}); - -if (dirName === 'tfjs-converter') { - const pipVersionCode = `# @license See the LICENSE file. - -# This code is auto-generated, do not modify this file! -version = '${version}' -`; - - fs.writeFile( - path.join(dirName, '/python/tensorflowjs/version.py'), - pipVersionCode, err => { - if (err != null) { - throw new Error(`Could not save pip version file ${version}: ${err}`); - } - console.log( - `Version file for pip version ${version} saved sucessfully.`); - }); - - const buildFilename = path.join(dirName, '/python/BUILD.bazel'); - fs.readFile(buildFilename, 'utf-8', function(err, data) { - if (err != null) { - throw new Error(`Could not update the BUILD.bazel file: ${err}`); - } - - const newValue = data.replace( - /version\ =\ \"[0-9]+\.[0-9]+\.[0-9]+\"/g, `version = "${version}"`); - fs.writeFileSync(buildFilename, newValue, 'utf-8'); - - console.log( - `pip version ${version} for BUILD.bazel file is updated sucessfully.`); - }); -} diff --git a/tfjs-master/scripts/package_dependencies.json b/tfjs-master/scripts/package_dependencies.json deleted file mode 100644 index 5cf8b6d5c..000000000 --- a/tfjs-master/scripts/package_dependencies.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "e2e": ["tfjs", "tfjs-converter", "tfjs-node", "tfjs-backend-wasm", "tfjs-backend-webgpu"], - "tfjs": ["tfjs-backend-cpu", "tfjs-backend-webgl", "tfjs-converter", "tfjs-core", "tfjs-data", "tfjs-layers"], - "tfjs-automl": [], - "tfjs-backend-cpu": ["tfjs-core"], - "tfjs-backend-wasm": ["tfjs-core", "tfjs-backend-cpu"], - "tfjs-backend-webgl": ["tfjs-core", "tfjs-backend-cpu"], - "tfjs-backend-webgpu": ["tfjs-core", "tfjs-backend-cpu"], - "tfjs-converter": ["tfjs-core", "tfjs-backend-cpu"], - "tfjs-core": [], - "tfjs-data": ["tfjs-core", "tfjs-backend-cpu", "tfjs-layers"], - "tfjs-inference": [], - "tfjs-layers": ["tfjs-core", "tfjs-backend-cpu", "tfjs-backend-webgl"], - "tfjs-node": ["tfjs-core", "tfjs"], - "tfjs-node-gpu": ["tfjs-core", "tfjs"], - "tfjs-tfdf": ["tfjs-core", "tfjs-backend-cpu", "tfjs-converter"], - "tfjs-tflite": ["tfjs-core", "tfjs-backend-cpu"], - "tfjs-vis": [] -} diff --git a/tfjs-master/scripts/publish-npm.sh b/tfjs-master/scripts/publish-npm.sh deleted file mode 100644 index e9888d1ea..000000000 --- a/tfjs-master/scripts/publish-npm.sh +++ /dev/null @@ -1,72 +0,0 @@ -#!/usr/bin/env bash -# Copyright 2017 Google LLC. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================= - -# Before you run this script, run `yarn release` and commit the PRs. - -# Then: -# 1) Checkout the master branch of this repo. -# 2) Run this script as `./scripts/publish-npm.sh DIR_NAME` -# from the project base dir where DIR_NAME is the directory name of the -# package you want to publish, e.g. "tfjs-core". - -set -e - -BRANCH=`git rev-parse --abbrev-ref HEAD` -ORIGIN=`git config --get remote.origin.url` -CHANGES=`git status --porcelain` - -# Yarn in the top-level and in the directory, -yarn -cd $1 -# Yarn above the other checks to make sure yarn doesn't change the lock file. -yarn -cd .. - -PACKAGE_JSON_FILE="$1/package.json" -if ! test -f "$PACKAGE_JSON_FILE"; then - echo "$PACKAGE_JSON_FILE does not exist." - echo "Please pass the package name as the first argument." - exit 1 -fi - -if [ "$BRANCH" != "master" ]; then - echo "Error: Switch to the master branch before publishing." - exit -fi - -if ! [[ "$ORIGIN" =~ tensorflow/tfjs ]]; then - echo "Error: Switch to the main repo (tensorflow/tfjs) before publishing." - exit -fi - -if [ ! -z "$CHANGES" ]; -then - echo "Make sure the master branch is clean. Found changes:" - echo $CHANGES - exit 1 -fi - -./scripts/make-version.js $1 - -cd $1 -yarn build-npm for-publish -cd .. - -./scripts/tag-version.js $1 - -cd $1 -npm publish -echo 'Yay! Published a new package to npm.' diff --git a/tfjs-master/scripts/publish-npm.ts b/tfjs-master/scripts/publish-npm.ts deleted file mode 100644 index d62f78b00..000000000 --- a/tfjs-master/scripts/publish-npm.ts +++ /dev/null @@ -1,424 +0,0 @@ -#!/usr/bin/env node -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -/* - * This script publish to npm for all the TensorFlow.js packages. Before you run - * this script, run `yarn release` and commit the PRs. - * Then run this script as `yarn publish-npm`. - */ - -import * as argparse from 'argparse'; -import chalk from 'chalk'; -import * as shell from 'shelljs'; -import { RELEASE_UNITS, question, $, getReleaseBranch, checkoutReleaseBranch, ALPHA_RELEASE_UNIT, TFJS_RELEASE_UNIT, selectPackages, getLocalVersion, getNpmVersion, memoize, printReleaseUnit, checkPublishable, runVerdaccio, ReleaseUnit, getVersion, getTagFromVersion, filterPackages, ALL_PACKAGES, WEBSITE_RELEASE_UNIT, getPackages } from './release-util'; -import semverCompare from 'semver/functions/compare'; -import * as child_process from 'child_process'; - -import {BAZEL_PACKAGES} from './bazel_packages'; - -const TMP_DIR = '/tmp/tfjs-publish'; -const VERDACCIO_REGISTRY = 'http://127.0.0.1:4873'; -const NPM_REGISTRY = 'https://registry.npmjs.org/'; - -// This script can not publish the tfjs website -const PUBLISHABLE_RELEASE_UNITS = RELEASE_UNITS.filter(r => r !== WEBSITE_RELEASE_UNIT); - -async function retry(f: () => T, tries = 3, sleep=5_000): Promise { - let lastError; - for (let i = 0; i < tries; i++) { - try { - return f(); - } catch (e) { - lastError = e; - console.warn(e); - if (i + 1 < tries) { - // Only delay if the loop will run again. - await delay(sleep); - } - } - } - throw lastError; -} - -/** - * For sets `a` and `b`, compute the set difference `a \ b` - * - * The set difference of `a` and `b`, denoted `a \ b`, is the set containing all - * elements of `a` that are not in `b` - * - * @param a The set to subtract from - * @param b The set to remove from `a` when creating the output set - */ -function setDifference(a: Set, b: Set): Set { - const difference = new Set(); - for (const val of a) { - if (!b.has(val)) { - difference.add(val); - } - } - return difference; -} - -const parser = new argparse.ArgumentParser(); -parser.addArgument('--git-protocol', { - action: 'storeTrue', - help: 'Use the git protocal rather than the http protocol when cloning repos.' -}); - -parser.addArgument('--registry', { - type: 'string', - defaultValue: NPM_REGISTRY, - help: 'Which registry to install packages from and publish to.', -}); - -parser.addArgument('--no-otp', { - action: 'storeTrue', - help: 'Do not use an OTP when publishing to the registry.', -}); - -parser.addArgument(['--release-this-branch', '--release-current-branch'], { - action: 'storeTrue', - help: 'Release the current branch instead of checking out a new one.', -}); - -parser.addArgument(['--dry'], { - action: 'storeTrue', - help: 'Dry run. Stage all packages in verdaccio but do not publish them to ' - + 'the registry.', -}); - -parser.addArgument(['--auto-publish-local-newer'], { - action: 'storeTrue', - help: 'Automatically publish local packages that have newer versions than' - + ' the packages in the registry', -}); - -parser.addArgument(['--ci'], { - action: 'storeTrue', - help: 'Enable CI bazel flags for faster compilation and don\'t ask for user ' - + 'input before closing the verdaccio server once tests are done. ' - + 'Has no effect on results.', -}); - -parser.addArgument(['packages'], { - type: 'string', - nargs: '*', - help: 'Packages to publish. Leave empty to select interactively', -}); - -function delay(ms: number): Promise { - return new Promise((resolve) => { - setTimeout(resolve, ms); - }); -} - -async function publish(pkg: string, registry: string, otp?: string, - build = true) { - const registryEnv = { - YARN_REGISTRY: registry, - NPM_CONFIG_REGISTRY: registry, - NPM_REGISTRY: registry, // For npx npm-cli-login - }; - - function run(command: string) { - return $(command, registryEnv); - } - - function yarn(args: string) { - return run(`yarn --registry '${registry}' ${args}`); - } - - const startDir = process.cwd(); - try { - // Use a try block so cwd can be restored in 'finally' if an error occurs. - shell.cd(pkg); - - checkPublishable('./package.json'); - - if (build && !BAZEL_PACKAGES.has(pkg)) { - console.log(chalk.magenta.bold(`~~~ Preparing package ${pkg}~~~`)); - console.log(chalk.magenta('~~~ Installing packages ~~~')); - // Without a delay, this sometimes has issues downloading dependencies. - await delay(5_000); - - // tfjs-node-gpu needs to get some files from tfjs-node. - if (pkg === 'tfjs-node-gpu') { - yarn('prep-gpu'); - } - - // Yarn above the other checks to make sure yarn doesn't change the lock - // file. - await retry(() => - console.log(run(`yarn --registry '${registry}'`))); - console.log(chalk.magenta('~~~ Build npm ~~~')); - - if (pkg === 'tfjs-react-native') { - yarn('build-npm'); - } else { - yarn('build-npm for-publish'); - } - } - - // Used for nightly dev releases. - const version = getVersion('package.json'); - const tag = getTagFromVersion(version); - - let otpFlag = ''; - if (otp) { - otpFlag = `--otp=${otp} `; - } - - console.log( - chalk.magenta.bold(`~~~ Publishing ${pkg} to ${registry} with tag ` - + `${tag} ~~~`)); - - let login = ''; - if (registry === VERDACCIO_REGISTRY) { - // If publishing to verdaccio, we must log in before every command. - login = 'npx npm-cli-login -u user -p password -e user@example.com && '; - } - - if (BAZEL_PACKAGES.has(pkg)) { - let dashes = '-- --'; - if (pkg === 'tfjs-backend-webgpu') { - // Special case for webgpu, which has an additional call to `yarn` - // in publish-npm. - dashes = '-- -- --'; - } - await retry(() => - run(`${login}yarn --registry '${registry}' publish-npm ${dashes} ${otpFlag} --tag=${tag} --force`)); - } else { - // Special case for tfjs-node(-gpu), which must upload the node addon - // to GCP as well. Only do this when publishing to NPM. - if (registry === NPM_REGISTRY && pkg.startsWith('tfjs-node')) { - $('yarn build-and-upload-addon publish'); - } - - // Publish the package to the registry. - await retry(() => - run(`${login}npm --registry '${registry}' publish --tag=${tag} ${otpFlag}`)); - } - console.log(`Published ${pkg} to ${registry}.`); - - } finally { - shell.cd(startDir); - } -} - -async function main() { - const args = parser.parseArgs(); - - const killVerdaccio = await runVerdaccio(); - - let releaseUnits: ReleaseUnit[]; - if (args.release_this_branch) { - console.log('Releasing current branch'); - releaseUnits = PUBLISHABLE_RELEASE_UNITS; - } else { - PUBLISHABLE_RELEASE_UNITS.forEach(printReleaseUnit); - console.log(); - - const releaseUnitStr = - await question('Which release unit (leave empty for 0): '); - const releaseUnitInt = Number(releaseUnitStr); - if (releaseUnitInt < 0 || releaseUnitInt >= PUBLISHABLE_RELEASE_UNITS.length) { - console.log(chalk.red(`Invalid release unit: ${releaseUnitStr}`)); - process.exit(1); - } - console.log(chalk.blue(`Using release unit ${releaseUnitInt}`)); - console.log(); - - const releaseUnit = PUBLISHABLE_RELEASE_UNITS[releaseUnitInt]; - const {name, } = releaseUnit; - - let releaseBranch: string; - if (releaseUnit === ALPHA_RELEASE_UNIT) { - // Alpha release unit is published with the tfjs release unit. - releaseBranch = await getReleaseBranch(TFJS_RELEASE_UNIT.name); - } else { - releaseBranch = await getReleaseBranch(name); - } - console.log(); - - releaseUnits = [releaseUnit]; - checkoutReleaseBranch(releaseBranch, args.git_protocol, TMP_DIR); - shell.cd(TMP_DIR); - } - - const getNpmVersionMemoized = memoize((pkg: string) => { - const version = getLocalVersion(pkg); - const tag = getTagFromVersion(version); - return getNpmVersion(pkg, args.registry, tag); - }); - - async function getVersions(pkg: string) { - const localVersion = getLocalVersion(pkg); - const npmVersion = await getNpmVersionMemoized(pkg); - let localIsNewer = true; - if (npmVersion !== '') { - // Unpublished tags return '' for their version. - localIsNewer = semverCompare(localVersion, npmVersion) > 0; - } - return {localVersion, npmVersion, localIsNewer}; - } - - async function packageSelected(pkg: string) { - // Automatically select local packages with version numbers greater than - // npm. - try { - const {localVersion, localIsNewer} = await getVersions(pkg); - return localVersion !== '0.0.0' && localIsNewer; - } catch (e) { - console.warn(e); - return false; - } - } - - // Get the list of packages to build and publish. - // There are three ways packages can be selected. - // 1. By passing them as CLI arguments in `packages`. - // 2. Automatically based on the versions on npm. - // 3. Interactively on the command line. - let packages: string[]; - if (args.packages.length > 0) { - // Get packages to publish from the 'packages' arg - // Filter from the set of all packages to make sure they end up - // in topological order. - const allPackages = getPackages(PUBLISHABLE_RELEASE_UNITS); - const requestedPackages = new Set(args.packages); - packages = allPackages.filter(pkg => requestedPackages.has(pkg)); - - // Check if there are any unsupported packages requested by the user - const unsupportedPackages = setDifference(requestedPackages, - new Set(packages)); - if (unsupportedPackages.size > 0) { - throw new Error(`Can not publish ${[...unsupportedPackages]}. ` - + `Supported packages are:\n${[...ALL_PACKAGES].join('\n')}`); - } - } else if (args.auto_publish_local_newer) { - // Automatically select packages based on npm versions - packages = await filterPackages(packageSelected, PUBLISHABLE_RELEASE_UNITS); - console.log(`Publishing ${packages}`); - } else { - // Select packages interactively - packages = await selectPackages({ - message: 'Select packages to publish', - releaseUnits, - selected: packageSelected, - async modifyName(pkg) { - // Add the local and remote versions to the printed name. - try { - const {localVersion, npmVersion, localIsNewer} = await getVersions(pkg); - const pkgWithVersion = - `${pkg.padEnd(20)} (${npmVersion ?? 'unpublished'} → ${localVersion})`; - if (localIsNewer) { - return chalk.bold(pkgWithVersion); - } else { - return pkgWithVersion; - } - } catch (e) { - console.warn(e); - return pkg; - } - } - }); - } - - // Yarn in the top-level to download Bazel - $('yarn'); - console.log(); - - // Pre-build all the bazel packages in a single bazel command for better - // efficiency. - const bazelTargets = packages.filter(pkg => BAZEL_PACKAGES.has(pkg)) - .map(name => `//${name}:${name}_pkg`); - - const bazelArgs = ['bazel', 'build'] - if (args.ci) { - bazelArgs.push('--config=ci'); - } - // Use child_process.spawnSync to show bazel build progress. - const result = child_process.spawnSync('yarn', - [...bazelArgs, ...bazelTargets], - {stdio:'inherit'}); - if (result.status !== 0) { - throw new Error(`Bazel process failed with exit code ${result.status}`); - } - - // Build and publish all packages to a local Verdaccio repo for staging. - console.log( - chalk.magenta.bold('~~~ Staging packages locally in Verdaccio ~~~')); - - try { - for (const pkg of packages) { - await publish(pkg, VERDACCIO_REGISTRY); - } - } catch (e) { - // Make sure to kill the verdaccio server before exiting even if publish - // throws an error. Otherwise, it blocks the port for the next run. - killVerdaccio(); - throw e; - } - - if (args.dry) { - console.log('Not publishing packages due to \'--dry\''); - if (!args.ci) { - await question('Press enter to quit verdaccio.'); - } - killVerdaccio(); - } else { - // Publish all built packages to the selected registry - let otp = ''; - if (!args.no_otp) { - otp = await question(`Enter one-time password from your authenticator: `); - } - console.log(`Publishing packages to ${args.registry}`); - - killVerdaccio(); - - const toPublish = [...packages]; - while (toPublish.length > 0) { - // Using a while loop instead of .map since a stale OTP will require - // a retry. - let pkg = toPublish[0]; - if (args.no_otp) { - await publish(pkg, args.registry, '', false); - toPublish.shift(); // Remove the published package from 'toPublish'. - continue; - } - - try { - await publish(pkg, args.registry, otp, false) - toPublish.shift(); // Remove the published package from 'toPublish'. - } catch (err) { - if ((err as Error).message.includes('code EOTP')) { - // Try again with a new otp - otp = await question(`OTP ${otp} failed. Enter a new one-time ` - + `password from your authenticator: `); - continue; // Don't shift the package since it failed to publish. - } - throw err; - } - } - - console.log(`Published packages to ${args.registry}`); - } - process.exit(0); -} - -main(); diff --git a/tfjs-master/scripts/publish-pypi.ts b/tfjs-master/scripts/publish-pypi.ts deleted file mode 100644 index d0498a2f6..000000000 --- a/tfjs-master/scripts/publish-pypi.ts +++ /dev/null @@ -1,66 +0,0 @@ -// publish-pypi.ts -import * as argparse from 'argparse'; -import { checkoutReleaseBranch, question, $ } from './release-util'; -import * as shell from 'shelljs'; -import * as fs from 'fs'; -import chalk from 'chalk'; - -const TMP_DIR = '/tmp/tfjs-pypi'; - -const parser = new argparse.ArgumentParser(); -parser.addArgument('--git-protocol', { - action: 'storeTrue', - help: 'Use the git protocol rather than the http protocol when cloning repos.', -}); - -async function getNewlyCreatedBranches(): Promise { - const branchesStr = $(`git branch -r --sort=-authordate --format='%(HEAD) %(refname:lstrip=-1)'`); - - const branches = branchesStr.split('\n').map((line: string) => line.trim()); - - const pattern = /^tfjs_\d+\.\d+\.\d+.*$/; - const tfjsBranches = branches.filter((branch: string) => pattern.test(branch)); - - return tfjsBranches; -} - -async function main() { - const args = parser.parseArgs(); - - try { - const branches = await getNewlyCreatedBranches(); - console.log('Branches:', branches); - - const latestBranch = branches[0]; - console.log('Latest Branch:', latestBranch); - - const answer = await question(chalk.cyan.bold(`Is this the right branch '${latestBranch}' you are looking for? (y/N): `)); - - if (answer.toLowerCase() === 'y') { - checkoutReleaseBranch(latestBranch, args.git_protocol, TMP_DIR); - const targetDir = `${TMP_DIR}/tfjs-converter/python`; - shell.cd(targetDir); - console.log(chalk.blue.bold('Current directory:', shell.pwd().toString())); - - $('bazel clean'); - $('bazel build python3_wheel'); - - // Remove dist folder if it exists - if (fs.existsSync('./dist')) { - fs.rmdirSync('./dist', { recursive: true }); - } - - $('./build-pip-package.sh --upload ./dist'); - - // Command executed successfully - console.log('Command executed successfully'); - } else { - console.log('Aborted.'); - } - } catch (error) { - console.error('Error:', error); - } -} - -// Invoke the main function -main(); diff --git a/tfjs-master/scripts/release-tfjs.ts b/tfjs-master/scripts/release-tfjs.ts deleted file mode 100644 index c4c37251f..000000000 --- a/tfjs-master/scripts/release-tfjs.ts +++ /dev/null @@ -1,301 +0,0 @@ -#!/usr/bin/env node -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -/** - * This script creates pull requests to make releases for all the TensorFlow.js - * packages. - * - * This script requires hub to be installed: https://hub.github.com/ - */ - -import * as argparse from 'argparse'; -import chalk from 'chalk'; -import semver from 'semver'; -import * as fs from 'fs'; -import * as shell from 'shelljs'; -import {TMP_DIR, $, question, makeReleaseDir, createPR, TFJS_RELEASE_UNIT, updateTFJSDependencyVersions, ALPHA_RELEASE_UNIT, getMinorUpdateVersion, getPatchUpdateVersion, E2E_PHASE, getReleaseBlockers, getNightlyVersion} from './release-util'; -import * as path from 'path'; -import {findDeps} from './graph_utils'; - -const parser = new argparse.ArgumentParser({ - description: 'Create a release PR for the tfjs monorepo.', -}); - -parser.addArgument('--git-protocol', { - action: 'storeTrue', - help: 'Use the git protocol rather than the http protocol when cloning repos.' -}); - -parser.addArgument(['--dry'], { - action: 'storeTrue', - help: 'Only create the release branch locally. Do not push or create a PR.', -}); - -parser.addArgument('--guess-version', { - type: 'string', - choices: ['release', 'nightly'], - help: 'Use the guessed version without asking for confirmation.', -}); - -parser.addArgument(['--commit-hash', '--hash'], { - type: 'string', - help: 'Commit hash to publish. Usually the latest successful nightly run.', -}); - -parser.addArgument(['--use-local-changes'], { - action: 'storeTrue', - help: 'Use local changes to the repo instead of a remote branch. Only for' + - ' testing and debugging.', -}); - -parser.addArgument('--force', { - action: 'storeTrue', - help: 'Force a release even if there are release blockers.', -}); - -async function getNewVersion( - packageName: string, incrementVersion: (version: string) => string, - ask = true) { - let newVersion: string|undefined; - try { - const versions: string[] = - JSON.parse($(`npm view @tensorflow/${packageName} versions --json`)); - if (Array.isArray(versions) && versions.length !== 0) { - const latestVersion = semver.rsort(versions)[0]; - newVersion = incrementVersion(latestVersion); - } - } catch (e) { - // Suppress errors when guessing the version. - } - - if (newVersion != null) { - if (!ask) { - return newVersion; - } - newVersion = await question(`New version for ${ - packageName} (leave empty for ${newVersion}): `) || - newVersion; - return newVersion; - } - - if (!ask) { - console.warn( - 'Guessing version 0.0.1 for unpublished package ' + - `${packageName}`); - return '0.0.1'; - } - - // Repeat until the user answers. - while (true) { - newVersion = await question( - `New Version for ${packageName} (no current version found on npm): `); - if (newVersion !== '') { - return newVersion; - } - console.log( - `${packageName} has no version on npm. ` + - 'Please provide an initial version.'); - } -} - -async function main() { - const args = parser.parseArgs(); - - let incrementVersion: ((version: string) => string)|undefined; - if (args.guess_version === 'nightly') { - incrementVersion = v => getNightlyVersion(getMinorUpdateVersion(v)); - } - - if (args.use_local_changes) { - // Force dry run when using local files instead of a release branch. - // This is for debugging. - args.dry = true; - } - const urlBase = args.git_protocol ? 'git@github.com:' : 'https://github.com/'; - const dir = `${TMP_DIR}/tfjs`; - makeReleaseDir(dir); - - if (args.force) { - console.warn('Ignoring any potential release blockerse due to \'--force\''); - } else { - const blockers = getReleaseBlockers(); - if (blockers) { - throw new Error(`Can not release due to release blockers:\n ${blockers}`); - } - } - - // Guess release version from tfjs-core's latest version, with a minor update. - const newVersion = await getNewVersion( - 'tfjs-core', incrementVersion ?? getMinorUpdateVersion, - !args.guess_version); - - // Populate the versions map with new versions for monorepo packages. - const versions = new Map(); - for (const phase of TFJS_RELEASE_UNIT.phases) { - for (const packageName of phase.packages) { - versions.set(packageName, newVersion); - } - } - - // Add versions for alpha monorepo packages, which do not have the same - // version as the other monorepo packages. - for (const phase of ALPHA_RELEASE_UNIT.phases) { - for (const packageName of phase.packages) { - const newVersion = await getNewVersion( - packageName, incrementVersion ?? getPatchUpdateVersion, - !args.guess_version); - versions.set(packageName, newVersion); - } - } - - // Get release candidate commit. - let commit = args.commit_hash; - if (!args.use_local_changes) { - if (!commit) { - commit = await question( - 'Commit of release candidate (the last ' + - 'successful nightly build): '); - } - if (commit === '') { - console.log(chalk.red('Commit cannot be empty.')); - process.exit(1); - } - } - - // Create a release branch in remote. - $(`git clone ${urlBase}tensorflow/tfjs ${dir}`); - - const releaseBranch = `tfjs_${newVersion}`; - - if (args.use_local_changes) { - shell.cd(path.join(__dirname, '../')); - console.log(chalk.magenta.bold( - '~~~ Copying current changes to a new release branch' + - ` ${releaseBranch} ~~~`)); - // Avoid copying `.git/` because this script will `git push` - // to origin, which it expects to be the tfjs repo as was set - // up when the script ran 'git clone' above. - // This makes sure other hidden files like .bazelrc are copied. - $(`cp -r \`ls -A | grep -v ".git"\` ${dir}`); - shell.cd(dir); - } else { - shell.cd(dir); - console.log(chalk.magenta.bold( - `~~~ Creating new release branch ${releaseBranch} ~~~`)); - $(`git checkout -b ${releaseBranch} ${commit}`); - } - if (!args.dry) { - $(`git push origin ${releaseBranch}`); - } - - // Update versions in package.json files. - const phases = - [...TFJS_RELEASE_UNIT.phases, ...ALPHA_RELEASE_UNIT.phases, E2E_PHASE]; - const errors: Error[] = []; - for (const phase of phases) { - for (const packageName of phase.packages) { - shell.cd(packageName); - - // Update the version number of the package.json - const packagePath = path.join(dir, packageName); - const packageJsonPath = path.join(packagePath, 'package.json'); - let pkg = fs.readFileSync(packageJsonPath, 'utf8'); - const parsedPkg = JSON.parse(`${pkg}`); - - console.log(chalk.magenta.bold(`~~~ Processing ${packageName} ~~~`)); - const newVersion = versions.get(packageName); - pkg = `${pkg}`.replace( - `"version": "${parsedPkg.version}"`, `"version": "${newVersion}"`); - - fs.writeFileSync(packageJsonPath, pkg); - - // Update dependency versions of all package.json files found in the - // package to use the new verison numbers (except ones in node_modules). - const subpackages = - $(`find ${ - packagePath} -name package.json -not -path \'*/node_modules/*\'`) - .split('\n'); - for (const packageJsonPath of subpackages) { - const pkg = fs.readFileSync(packageJsonPath, 'utf8'); - console.log(chalk.magenta.bold( - `~~~ Update dependency versions for ${packageJsonPath} ~~~`)); - - // Only update versions that are a (possibly transitive) dependency of - // the package and are listed in the phase deps (we throw an error - // if we find a dependency that doesn't satisfy these conditions). - const transitiveDeps = [...findDeps([packageName])].filter( - dep => phase.deps.includes(dep)); - - // Also add the package itself so subpackages can use it. - // Some packages, like e2e, are never published to npm, so check first. - if (versions.has(packageName)) { - transitiveDeps.push(packageName); - } - - const packageDependencyVersions = - new Map(transitiveDeps.map(dep => [dep, versions.get(dep)!])); - - try { - const updated = - updateTFJSDependencyVersions(pkg, packageDependencyVersions); - - fs.writeFileSync(packageJsonPath, updated); - } catch (e) { - e.message = `For ${packageJsonPath}, ${packageName} ${e.message}`; - console.error(e.stack); - errors.push(e); - } - } - - shell.cd('..'); - - // Make version for all packages other than tfjs-node-gpu and e2e. - if (packageName !== 'tfjs-node-gpu' && packageName !== 'e2e') { - $(`./scripts/make-version.js ${packageName}`); - } - } - } - if (errors.length > 0) { - throw new Error('Some package version updates had errors' + errors); - } - - - // Use dev prefix to avoid branch being locked. - const devBranchName = `dev_${releaseBranch}`; - - const message = `Update monorepo to ${newVersion}.`; - if (!args.dry) { - createPR(devBranchName, releaseBranch, message); - } - - console.log( - 'Done. FYI, this script does not publish to NPM. ' + - 'Please publish by running ' + - 'YARN_REGISTRY="https://registry.npmjs.org/" yarn publish-npm ' + - 'after you merge the PR.' + - 'Remember to delete the dev branch once PR is merged.' + - 'Please remeber to update the website once you have released ' + - 'a new package version.'); - - if (args.dry) { - console.log(`No PR was created. Local output is located in ${dir}.`); - } - process.exit(0); -} - -main(); diff --git a/tfjs-master/scripts/release-util.ts b/tfjs-master/scripts/release-util.ts deleted file mode 100644 index 5e6107fb2..000000000 --- a/tfjs-master/scripts/release-util.ts +++ /dev/null @@ -1,701 +0,0 @@ -#!/usr/bin/env node -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import chalk from 'chalk'; -import * as fs from 'fs'; -import * as inquirer from 'inquirer'; -import {Separator} from 'inquirer'; -import mkdirp from 'mkdirp'; -import * as readline from 'readline'; -import * as shell from 'shelljs'; -import rimraf from 'rimraf'; -import * as path from 'path'; -import {fork} from 'child_process'; - -export interface Phase { - // The list of packages that will be updated with this change. - packages: string[]; - // The list of dependencies that all of the packages will update to. - // TODO(mattSoulanille): Parse this from package_dependencies.json or from the - // package.json file of each package. - deps?: string[]; - // An ordered map of scripts, key is package name, value is an object with two - // optional fields: `before-yarn` with scripts to run before `yarn`, and - // `after-yarn` with scripts to run after yarn is called and before the pull - // request is sent out. - scripts?: {[key: string]: {[key: string]: string[]}}; - // Whether to leave the version of the package alone. Defaults to false - // (change the version). - leaveVersion?: boolean; - title?: string; -} - -export interface ReleaseUnit { - // A human-readable name. Used for generating release branch. - name: string; - // The phases in this release unit. - phases: Phase[]; - // The repository *only if it is not the same as tfjs*. - repo?: string; -} - -export const CORE_PHASE: Phase = { - packages: ['tfjs-core'], - // Do not mark tfjs-backend-cpu as a dependency during releases. As a - // devDependency it should keep the link:// path. Once tests have passed in CI - // building and releasing core should not depend on the cpu backend -}; - -export const CPU_PHASE: Phase = { - packages: ['tfjs-backend-cpu'], - deps: ['tfjs-core'] -}; - -export const WEBGL_PHASE: Phase = { - packages: ['tfjs-backend-webgl'], - deps: ['tfjs-core', 'tfjs-backend-cpu'] -}; - -export const LAYERS_CONVERTER_PHASE: Phase = { - packages: ['tfjs-layers', 'tfjs-converter'], - deps: ['tfjs-core', 'tfjs-backend-cpu', 'tfjs-backend-webgl'] -}; - -export const DATA_PHASE: Phase = { - packages: ['tfjs-data'], - deps: ['tfjs-core', 'tfjs-layers', 'tfjs-backend-cpu'] -} - -export const UNION_PHASE: Phase = { - packages: ['tfjs'], - deps: [ - 'tfjs-core', 'tfjs-layers', 'tfjs-converter', 'tfjs-data', - 'tfjs-backend-cpu', 'tfjs-backend-webgl' - ] -}; - -// We added tfjs-core and tfjs-layers because Node has unit tests that directly -// use tf.core and tf.layers to test serialization of models. Consider moving -// the test to tf.layers. -export const NODE_PHASE: Phase = { - packages: ['tfjs-node', 'tfjs-node-gpu'], - deps: ['tfjs', 'tfjs-core'], - scripts: {'tfjs-node-gpu': {'before-yarn': ['yarn prep-gpu']}} -}; - -export const WASM_PHASE: Phase = { - packages: ['tfjs-backend-wasm'], - deps: ['tfjs-core', 'tfjs-backend-cpu'] -}; - -export const WEBGPU_PHASE: Phase = { - packages: ['tfjs-backend-webgpu'], - deps: ['tfjs-core', 'tfjs-backend-cpu'], -}; - -export const VIS_PHASE: Phase = { - packages: ['tfjs-vis'] -}; - -export const REACT_NATIVE_PHASE: Phase = { - packages: ['tfjs-react-native'], - deps: ['tfjs-core', 'tfjs-backend-cpu', 'tfjs-backend-webgl'] -}; - -export const TFDF_PHASE: Phase = { - packages: ['tfjs-tfdf'], - deps: ['tfjs-core', 'tfjs-backend-cpu', 'tfjs-converter'] -}; - -export const TFLITE_PHASE: Phase = { - packages: ['tfjs-tflite'], - deps: ['tfjs-core', 'tfjs-backend-cpu'] -}; - -export const AUTOML_PHASE: Phase = { - packages: ['tfjs-automl'], - deps: ['tfjs-core', 'tfjs-backend-webgl', 'tfjs-converter'] -}; - -export const WEBSITE_PHASE: Phase = { - packages: ['tfjs-website'], - deps: [ - 'tfjs', 'tfjs-node', 'tfjs-vis', 'tfjs-react-native', 'tfjs-tfdf', - 'tfjs-tflite', '@tensorflow-models/tasks' - ], - scripts: {'tfjs-website': {'after-yarn': ['yarn prep && yarn build-prod']}}, - leaveVersion: true, - title: 'Update website to latest dependencies.' -}; - -// Note that e2e is not actually published. As a result, this phase is not -// included in any release unit, however, it is used for updating dependencies. -export const E2E_PHASE: Phase = { - packages: ['e2e'], - deps: [ - 'tfjs', 'tfjs-backend-cpu', 'tfjs-backend-wasm', 'tfjs-backend-webgl', - 'tfjs-backend-webgpu', 'tfjs-converter', 'tfjs-core', 'tfjs-data', - 'tfjs-layers', 'tfjs-node' - ], -} - -export const TFJS_RELEASE_UNIT: ReleaseUnit = { - name: 'tfjs', - phases: [ - CORE_PHASE, CPU_PHASE, WEBGL_PHASE, WEBGPU_PHASE, LAYERS_CONVERTER_PHASE, - DATA_PHASE, UNION_PHASE, NODE_PHASE, WASM_PHASE - ] -}; - -// TODO(mattsoulanille): Move WEBGPU_PHASE to TFJS_RELEASE_UNIT when webgpu -// is out of alpha. -// Alpha packages use monorepo dependencies at the latest version but are -// not yet released at the same version number as the monorepo packages. -// Use this for packages that will be a part of the monorepo in the future. -// The release script will ask for a new version for each phase, and it will -// replace 'link' dependencies with the new monorepo version. -export const ALPHA_RELEASE_UNIT: ReleaseUnit = { - name: 'alpha-monorepo-packages', - phases: [TFDF_PHASE], -}; - -export const VIS_RELEASE_UNIT: ReleaseUnit = { - name: 'vis', - phases: [VIS_PHASE] -}; - -export const REACT_NATIVE_RELEASE_UNIT: ReleaseUnit = { - name: 'react-native', - phases: [REACT_NATIVE_PHASE] -}; - -export const TFLITE_RELEASE_UNIT: ReleaseUnit = { - name: 'tflite', - phases: [TFLITE_PHASE] -}; - -export const AUTOML_RELEASE_UNIT: ReleaseUnit = { - name: 'automl', - phases: [AUTOML_PHASE] -}; - -export const WEBSITE_RELEASE_UNIT: ReleaseUnit = { - name: 'website', - phases: [WEBSITE_PHASE], - repo: 'tfjs-website' -}; - -export const RELEASE_UNITS: ReleaseUnit[] = [ - TFJS_RELEASE_UNIT, - ALPHA_RELEASE_UNIT, - VIS_RELEASE_UNIT, - REACT_NATIVE_RELEASE_UNIT, - TFLITE_RELEASE_UNIT, - AUTOML_RELEASE_UNIT, - WEBSITE_RELEASE_UNIT, -]; - -export const ALL_PACKAGES: Set = new Set(getPackages(RELEASE_UNITS)); - -export const TMP_DIR = '/tmp/tfjs-release'; - -export async function question(questionStr: string): Promise { - const rl = - readline.createInterface({ input: process.stdin, output: process.stdout }); - - console.log(chalk.bold(questionStr)); - return new Promise( - resolve => { - rl.question('> ', response => { - resolve(response); - rl.close(); - }); - }); -} - -/** - * A wrapper around shell.exec for readability. - * @param cmd The bash command to execute. - * @returns stdout returned by the executed bash script. - */ -export function $(cmd: string, env: Record = {}) { - env = {...process.env, ...env}; - - const result = shell.exec(cmd, {silent: true, env}); - if (result.code > 0) { - throw new Error(`$ ${cmd}\n ${result.stderr}`); - } - return result.stdout.trim(); -} - -/** - * An async wrapper around shell.exec for readability. - * @param cmd The bash command to execute. - * @returns stdout returned by the executed bash script. - */ -export function $async(cmd: string, - env: Record = {}): Promise { - env = {...shell.env, ...env}; - return new Promise((resolve, reject) => { - shell.exec(cmd, {silent: true, env}, (code, stdout, stderr) => { - if (code > 0) { - console.log('$', cmd); - console.log(stdout); - console.log(stderr); - reject(stderr); - } - resolve(stdout.trim()); - }) - }); -} - -export function printReleaseUnit(releaseUnit: ReleaseUnit, id: number) { - console.log(chalk.green(`Release unit ${id}:`)); - console.log(` packages: ${ - chalk.blue(releaseUnit.phases.map(phase => phase.packages.join(', ')) - .join(', '))}`); -} - -export function printPhase(phases: Phase[], phaseId: number) { - const phase = phases[phaseId]; - console.log(chalk.green(`Phase ${phaseId}:`)); - console.log(` packages: ${chalk.blue(phase.packages.join(', '))}`); - if (phase.deps != null) { - console.log(` deps: ${phase.deps.join(', ')}`); - } -} - -export function makeReleaseDir(dir: string) { - mkdirp(TMP_DIR, err => { - if (err) { - console.log('Error creating temp dir', TMP_DIR); - process.exit(1); - } - }); - $(`rm -f -r ${dir}/*`); - $(`rm -f -r ${dir}`); - $(`mkdir ${dir}`); -} - -export async function updateDependency( - deps: string[], pkg: string, parsedPkg: any): Promise { - console.log(chalk.magenta.bold(`~~~ Update dependency versions ~~~`)); - - if (deps != null) { - const depsLatestVersion: string[] = deps.map( - dep => $(`npm view ${ - dep.includes('@') ? dep : '@tensorflow/' + dep} dist-tags.latest`)); - - for (let j = 0; j < deps.length; j++) { - const dep = deps[j]; - - let version = ''; - const depNpmName = dep.includes('@') ? dep : `@tensorflow/${dep}`; - if (parsedPkg['dependencies'] != null && - parsedPkg['dependencies'][depNpmName] != null) { - version = parsedPkg['dependencies'][depNpmName]; - } else if ( - parsedPkg['peerDependencies'] != null && - parsedPkg['peerDependencies'][depNpmName] != null) { - version = parsedPkg['peerDependencies'][depNpmName]; - } else if ( - parsedPkg['devDependencies'] != null && - parsedPkg['devDependencies'][depNpmName] != null) { - version = parsedPkg['devDependencies'][depNpmName]; - } - if (version == null) { - throw new Error(`No dependency found for ${dep}.`); - } - - let relaxedVersionPrefix = ''; - if (version.startsWith('~') || version.startsWith('^')) { - relaxedVersionPrefix = version.slice(0, 1); - } - const depVersionLatest = relaxedVersionPrefix + depsLatestVersion[j]; - - let depVersion = await question( - `Updated version for ` + - `${dep} (current is ${version}, leave empty for latest ${ - depVersionLatest}): `); - if (depVersion === '') { - depVersion = depVersionLatest; - } - console.log(chalk.blue(`Using version ${depVersion}`)); - - pkg = `${pkg}`.replace( - new RegExp(`"${depNpmName}": "${version}"`, 'g'), - `"${depNpmName}": "${depVersion}"`); - } - } - - return pkg; -} - -// Update package.json dependencies of tfjs packages. This method is different -// than `updateDependency`, it does not rely on published versions, instead it -// uses a map from packageName to newVersion to update the versions. -export function updateTFJSDependencyVersions( - pkg: string, versions: Map, - depsToReplace = [...versions.keys()]): string { - - const parsedPkg = JSON.parse(pkg); - - const dependencyMaps: Array<{[index: string]: string}> = [ - parsedPkg['dependencies'], - parsedPkg['peerDependencies'], - parsedPkg['devDependencies'], - ].filter(v => v != null); - - for (const dependencyMap of dependencyMaps) { - for (const [name, version] of Object.entries(dependencyMap)) { - const prefix = '@tensorflow/'; - if (name.startsWith(prefix) && version.startsWith('link:')) { - const tfjsName = name.slice(prefix.length); - const newVersion = versions.get(tfjsName); - if (newVersion == null) { - throw new Error(`Versions map does not include ${tfjsName}`); - } - - let relaxedVersionPrefix = ''; - if (version.startsWith('~') || version.startsWith('^')) { - relaxedVersionPrefix = version.slice(0, 1); - } - const versionLatest = relaxedVersionPrefix + newVersion; - pkg = `${pkg}`.replace( - new RegExp(`"${name}": "${version}"`, 'g'), - `"${name}": "${versionLatest}"`); - } - } - } - - return pkg; -} - -export function prepareReleaseBuild(phase: Phase, packageName: string) { - console.log(chalk.magenta.bold(`~~~ Prepare release build ~~~`)); - console.log(chalk.bold('Prepare before-yarn')); - if (phase.scripts != null && phase.scripts[packageName] != null && - phase.scripts[packageName]['before-yarn'] != null) { - phase.scripts[packageName]['before-yarn'].forEach(script => $(script)); - } - - console.log(chalk.bold('yarn')); - $(`yarn`); - - console.log(chalk.bold('Prepare after-yarn')); - if (phase.scripts != null && phase.scripts[packageName] != null && - phase.scripts[packageName]['after-yarn'] != null) { - phase.scripts[packageName]['after-yarn'].forEach(script => $(script)); - } -} - -export async function getReleaseBranch(name: string): Promise { - // Infer release branch name. - let releaseBranch = ''; - - // Get a list of branches sorted by timestamp in descending order. - const branchesStr = $( - `git branch -r --sort=-authordate --format='%(HEAD) %(refname:lstrip=-1)'`); - const branches = - Array.from(branchesStr.split(/\n/)).map(line => line.toString().trim()); - - // Find the latest matching branch, e.g. tfjs_1.7.1 - // It will not match temprary generated branches such as tfjs_1.7.1_phase0. - const exp = '^' + name + '_([^_]+)$'; - const regObj = new RegExp(exp); - const maybeBranch = branches.find(branch => branch.match(regObj)); - releaseBranch = await question( - `Which release branch (leave empty for ` + - `${maybeBranch}):`); - if (releaseBranch === '') { - releaseBranch = maybeBranch; - } - - return releaseBranch; -} - -export function checkoutReleaseBranch( - releaseBranch: string, git_protocol: string, dir: string) { - console.log(chalk.magenta.bold( - `~~~ Checking out release branch ${releaseBranch} ~~~`)); - $(`rm -f -r ${dir}`); - mkdirp(dir, err => { - if (err) { - console.log('Error creating temp dir', dir); - process.exit(1); - } - }); - - const urlBase = git_protocol ? 'git@github.com:' : 'https://github.com/'; - $(`git clone -b ${releaseBranch} ${urlBase}tensorflow/tfjs ${dir} --depth=1`); -} - -export function createPR( - devBranchName: string, releaseBranch: string, message: string) { - console.log( - chalk.magenta.bold('~~~ Creating PR to update release branch ~~~')); - $(`git checkout -b ${devBranchName}`); - $(`git push -u origin ${devBranchName}`); - $(`git add .`); - $(`git commit -a -m "${message}"`); - $(`git push`); - - $(`hub pull-request -b ${releaseBranch} -m "${message}" -l INTERNAL -o`); - console.log(); -} - -/** - * Get all GitHub issues tagged as release blockers. - * - * @return A string of all the issues. Empty if there are none. - */ -export function getReleaseBlockers() { - return $('hub issue -l "RELEASE BLOCKER"'); -} - -// Computes the default updated version (does a patch version update). -export function getPatchUpdateVersion(version: string): string { - const versionSplit = version.split('.'); - - // For alpha or beta version string (e.g. "0.0.1-alpha.5"), increase the - // number after alpha/beta. - if (versionSplit[2].includes('alpha') || versionSplit[2].includes('beta')) { - return [ - versionSplit[0], versionSplit[1], versionSplit[2], +versionSplit[3] + 1 - ].join('.'); - } - - return [versionSplit[0], versionSplit[1], +versionSplit[2] + 1].join('.'); -} - - -/** - * Get the next minor update version for the given version. - * - * e.g. given 1.2.3, return 1.3.0 - */ -export function getMinorUpdateVersion(version: string): string { - const versionSplit = version.split('.'); - - return [versionSplit[0], + versionSplit[1] + 1, '0'].join('.'); -} - -/** - * Create the nightly version string by appending `dev-{current date}` to the - * given version. - * - * Versioning format is from semver: https://semver.org/spec/v2.0.0.html - * This version should be published with the 'next' tag and should increment the - * current 'latest' tfjs version. - * We approximate TypeScript's versioning practice as seen on their npm page - * https://www.npmjs.com/package/typescript?activeTab=versions - */ -export function getNightlyVersion(version: string): string { - // Format date to YYYYMMDD. - const date = - new Date().toISOString().split('T')[0].replace(new RegExp('-', 'g'), ''); - return `${version}-dev.${date}`; -} - -/** - * Filter a list with an async filter function - */ -async function filterAsync( - array: T[], - condition: (t: T) => Promise): Promise { - - const results = await Promise.all(array.map(condition)); - return array.filter((_val, index) => results[index]); -} - -/** - * Get the packages contained in the given release units. - */ -export function getPackages(releaseUnits: ReleaseUnit[]): string[] { - return releaseUnits.map(releaseUnit => releaseUnit.phases) - .flat().map(phase => phase.packages) - .flat(); -} - -/** - * Filter packages in release units according to an async filter. - */ -export async function filterPackages(filter: (pkg: string) => Promise, - releaseUnits = RELEASE_UNITS) { - return filterAsync(getPackages(releaseUnits), filter); -} - -export async function selectPackages({ - message = "Select packages", - selected = async (_pkg: string) => false, - modifyName = async (name: string) => name, - releaseUnits = RELEASE_UNITS}) { - - type SeparatorInstance = InstanceType; - type Choice = {name: string, checked: boolean}; - - // Using Array.map instead of for loops for better performance from - // Promise.all. Otherwise, it can take ~10 seconds to show the packages - // if modifyName or selected take a long time. - const choices = await Promise.all>( - releaseUnits - .map(releaseUnit => [ - new inquirer.Separator( // Separate release units with a line - chalk.underline(releaseUnit.name)), - ...releaseUnit.phases // Display the packages of a release unit. - .map(phase => phase.packages - .map(async pkg => { - const [name, checked] = await Promise.all([ - modifyName(pkg), selected(pkg)]); - return {name, value: pkg, checked}; - }) // Promise[] from one phase's packages - ).flat() // Promise[] from one release unit - ]).flat() // (Separator | Promise)[] for all release units - ); - - const choice = await inquirer.prompt({ - name: 'packages', - type: 'checkbox', - message, - pageSize: 30, - choices, - loop: false, - } as {name: 'packages'}); - - return choice['packages'] as string[]; -} - -export function getVersion(packageJsonPath: string) { - return JSON.parse(fs.readFileSync(packageJsonPath) - .toString('utf8')).version as string; -} - -export function getLocalVersion(pkg: string) { - return getVersion(path.join(pkg, 'package.json')); -} - -export async function getNpmVersion(pkg: string, registry?: string, - tag = 'latest') { - const env: Record = {}; - if (registry) { - env['NPM_CONFIG_REGISTRY'] = registry; - } - return $async(`npm view @tensorflow/${pkg} dist-tags.${tag}`, env); -} - -export function getTagFromVersion(version: string): string { - if (version.includes('dev')) { - return 'nightly'; - }else if (version.includes('rc')) { - return 'next'; - } - return 'latest'; -} - -export function memoize(f: (arg: I) => Promise): (arg: I) => Promise { - const map = new Map>(); - return async (i: I) => { - if (!map.has(i)) { - map.set(i, f(i)); - } - return map.get(i)!; - } -} - -export async function runVerdaccio(): Promise<() => void> { - // Remove the verdaccio package store. - // TODO(mattsoulanille): Move the verdaccio storage and config file here - // once the nightly verdaccio tests are handled by this script. - rimraf.sync(path.join(__dirname, '../e2e/scripts/storage')); - - // Start verdaccio. It must be started directly from its binary so that IPC - // messaging works and verdaccio can tell node that it has started. - // https://verdaccio.org/docs/verdaccio-programmatically/#using-fork-from-child_process-module - const verdaccioBin = require.resolve('verdaccio/bin/verdaccio'); - const config = path.join(__dirname, '../e2e/scripts/verdaccio.yaml'); - const serverProcess = fork(verdaccioBin, [`--config=${config}`]); - const ready = new Promise((resolve, reject) => { - const timeLimitMilliseconds = 30_000; - console.log(`Waiting ${timeLimitMilliseconds / 1000} seconds for ` + - 'verdaccio to start....'); - const timeout = setTimeout(() => { - serverProcess.kill(); - reject(`Verdaccio did not start in ${timeLimitMilliseconds} seconds.`); - }, timeLimitMilliseconds); - - serverProcess.on('message', (msg: {verdaccio_started: boolean}) => { - if (msg.verdaccio_started) { - console.log(chalk.magenta.bold( - `Verdaccio Started. Visit http://localhost:4873 to see packages.`)); - clearTimeout(timeout); - resolve(); - } - }); - }); - - serverProcess.on('error', (err: unknown) => { - throw new Error(`Verdaccio error: ${err}`); - }); - - const onUnexpectedDisconnect = (err: unknown) => { - throw new Error(`Verdaccio process unexpectedly disconnected: ${err}`); - }; - serverProcess.on('disconnect', onUnexpectedDisconnect); - - const killVerdaccio = () => { - serverProcess.off('disconnect', onUnexpectedDisconnect); - serverProcess.kill(); - }; - - // Kill verdaccio when node exits. - process.on('exit', killVerdaccio); - - await ready; - return killVerdaccio; -} - -/** - * Check a package.json path for `link://` and `file://` dependencies. - */ -export function checkPublishable(packageJsonPath: string): void { - const packageJson = JSON.parse( - fs.readFileSync(packageJsonPath) - .toString('utf8')) as { - name?: string, - private?: boolean, - dependencies?: Record, - }; - - if (!packageJson.name) { - throw new Error(`${packageJsonPath} has no name.`); - } - const pkg = packageJson.name; - if (packageJson.private) { - throw new Error(`${pkg} is private.`); - } - - if (packageJson.dependencies) { - for (let [dep, depVersion] of Object.entries(packageJson.dependencies)) { - const start = depVersion.slice(0,5); - if (start === 'link:' || start === 'file:') { - throw new Error(`${pkg} has a '${start}' dependency on ${dep}. ` - + 'Refusing to publish.'); - } - } - } -} diff --git a/tfjs-master/scripts/release-website.ts b/tfjs-master/scripts/release-website.ts deleted file mode 100644 index c55ae4094..000000000 --- a/tfjs-master/scripts/release-website.ts +++ /dev/null @@ -1,70 +0,0 @@ -#!/usr/bin/env node -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -/** - * This script creates pull requests to make release for tfjs website. Once the - * pull request is merged, you must deploy the website. - * - * This script requires hub to be installed: https://hub.github.com/ - */ -import chalk from 'chalk'; -import * as fs from 'fs'; -import * as shell from 'shelljs'; - -import {$, makeReleaseDir, TMP_DIR, WEBSITE_RELEASE_UNIT, updateDependency, prepareReleaseBuild, createPR} from './release-util'; - -export async function releaseWebsite(args: any) { - const {phases, repo} = WEBSITE_RELEASE_UNIT; - // Website release only has one phase. - const phase = phases[0]; - const packages = phases[0].packages; - const deps = phases[0].deps || []; - - const dir = `${TMP_DIR}/${repo}`; - makeReleaseDir(dir); - - const urlBase = args.git_protocol ? 'git@github.com:' : 'https://github.com/'; - - // Publishing website, another repo. - $(`git clone ${urlBase}tensorflow/${repo} ${dir} --depth=1`); - shell.cd(dir); - - for (let i = 0; i < packages.length; i++) { - const packageName = packages[i]; - - // Update the version. - const packageJsonPath = `${dir}/package.json`; - let pkg = `${fs.readFileSync(packageJsonPath)}`; - const parsedPkg = JSON.parse(`${pkg}`); - const latestVersion = parsedPkg.version; - - console.log(chalk.magenta.bold( - `~~~ Processing ${packageName} (${latestVersion}) ~~~`)); - - pkg = await updateDependency(deps, pkg, parsedPkg); - - fs.writeFileSync(packageJsonPath, pkg); - - prepareReleaseBuild(phase, packageName); - } - - const timestamp = Date.now(); - const branchName = `master_${timestamp}`; - - createPR(branchName, 'master', phase.title); -} diff --git a/tfjs-master/scripts/release.ts b/tfjs-master/scripts/release.ts deleted file mode 100644 index c0aa9e8fb..000000000 --- a/tfjs-master/scripts/release.ts +++ /dev/null @@ -1,183 +0,0 @@ -#!/usr/bin/env node -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -/** - * This script creates pull requests to make releases for all the TensorFlow.js - * packages. The release process is split up into multiple phases. Each - * phase will update the version of a package and the dependency versions and - * send a pull request. Once the pull request is merged, you must publish the - * packages manually from the individual packages. - * - * This script requires hub to be installed: https://hub.github.com/ - */ - -import * as argparse from 'argparse'; -import chalk from 'chalk'; -import semver from 'semver'; -import * as fs from 'fs'; -import * as shell from 'shelljs'; -import {RELEASE_UNITS, WEBSITE_RELEASE_UNIT, TMP_DIR, $, question, printReleaseUnit, printPhase, makeReleaseDir, updateDependency, prepareReleaseBuild, createPR, getPatchUpdateVersion, ALPHA_RELEASE_UNIT} from './release-util'; -import {releaseWebsite} from './release-website'; - -const parser = new argparse.ArgumentParser(); - -parser.addArgument('--git-protocol', { - action: 'storeTrue', - help: 'Use the git protocal rather than the http protocol when cloning repos.' -}); - -async function main() { - const args = parser.parseArgs(); - - // The alpha release unit is released with the monorepo and should not be - // released by this script. Packages in the alpha release unit need their - // package.json dependencies rewritten. - const releaseUnits = RELEASE_UNITS.filter(r => r !== ALPHA_RELEASE_UNIT); - releaseUnits.forEach(printReleaseUnit); - console.log(); - - const releaseUnitStr = - await question('Which release unit (leave empty for 0): '); - const releaseUnitInt = +releaseUnitStr; - if (releaseUnitInt < 0 || releaseUnitInt >= releaseUnits.length) { - console.log(chalk.red(`Invalid release unit: ${releaseUnitStr}`)); - process.exit(1); - } - console.log(chalk.blue(`Using release unit ${releaseUnitInt}`)); - console.log(); - - const releaseUnit = releaseUnits[releaseUnitInt]; - const {name, phases} = releaseUnit; - - phases.forEach((_, i) => printPhase(phases, i)); - console.log(); - - const phaseStr = await question('Which phase (leave empty for 0): '); - const phaseInt = +phaseStr; - if (phaseInt < 0 || phaseInt >= phases.length) { - console.log(chalk.red(`Invalid phase: ${phaseStr}`)); - process.exit(1); - } - console.log(chalk.blue(`Using phase ${phaseInt}`)); - console.log(); - - const phase = phases[phaseInt]; - const packages = phases[phaseInt].packages; - const deps = phases[phaseInt].deps || []; - - if (releaseUnit === WEBSITE_RELEASE_UNIT) { - await releaseWebsite(args); - - console.log( - 'Done. Please remember to deploy the website once you merged the PR.'); - - process.exit(0); - } - - // Release packages in tfjs repo. - const dir = `${TMP_DIR}/tfjs`; - makeReleaseDir(dir); - - const urlBase = args.git_protocol ? 'git@github.com:' : 'https://github.com/'; - let releaseBranch = ''; - - if (phaseInt !== 0) { - // Phase0 should be published and release branch should have been created. - const firstPackageVersions: string[] = JSON.parse( - $(`npm view @tensorflow/${phases[0].packages[0]} versions --json`)); - const firstPackageLatestVersion = semver.rsort(firstPackageVersions)[0]; - - releaseBranch = `${name}_${firstPackageLatestVersion}`; - - $(`git clone -b ${releaseBranch} ${urlBase}tensorflow/tfjs ${ - dir} --depth=1`); - shell.cd(dir); - } else { - // Phase0 needs user input of the release version to create release - // branch. - $(`git clone ${urlBase}tensorflow/tfjs ${dir} --depth=1`); - shell.cd(dir); - } - - const newVersions = []; - for (let i = 0; i < packages.length; i++) { - const packageName = packages[i]; - shell.cd(packageName); - - // Update the version. - const packageJsonPath = `${dir}/${packageName}/package.json`; - let pkg = `${fs.readFileSync(packageJsonPath)}`; - const parsedPkg = JSON.parse(`${pkg}`); - const packageVersions: string[] = - JSON.parse($(`npm view @tensorflow/${packageName} versions --json`)); - const latestVersion = semver.rsort(packageVersions)[0]; - - console.log(chalk.magenta.bold( - `~~~ Processing ${packageName} (${latestVersion}) ~~~`)); - - const patchUpdateVersion = getPatchUpdateVersion(latestVersion); - let newVersion = latestVersion; - newVersion = - await question(`New version (leave empty for ${patchUpdateVersion}): `); - if (newVersion === '') { - newVersion = patchUpdateVersion; - } - - if (releaseBranch === '') { - releaseBranch = `${name}_${newVersion}`; - console.log(chalk.magenta.bold( - `~~~ Creating new release branch ${releaseBranch} ~~~`)); - $(`git checkout -b ${releaseBranch}`); - $(`git push origin ${releaseBranch}`); - } - - pkg = `${pkg}`.replace( - `"version": "${parsedPkg.version}"`, `"version": "${newVersion}"`); - - pkg = await updateDependency(deps, pkg, parsedPkg); - - fs.writeFileSync(packageJsonPath, pkg); - - prepareReleaseBuild(phase, packageName); - - shell.cd('..'); - - $(`./scripts/make-version.js ${packageName}`); - - newVersions.push(newVersion); - } - - const packageNames = packages.join(', '); - const versionNames = newVersions.join(', '); - const devBranchName = `dev_${releaseBranch}_phase${phaseInt}`; - - const message = `Update ${packageNames} to ${versionNames}.`; - createPR(devBranchName, releaseBranch, message); - - console.log( - `Done. FYI, this script does not publish to NPM. ` + - `Please publish by running ` + - `YARN_REGISTRY="https://registry.npmjs.org/" yarn publish-npm ` + - `after you merge the PR.` + - `Please remeber to update the website once you have released ` + - 'a new package version'); - - process.exit(0); -} - -main(); diff --git a/tfjs-master/scripts/release_notes/release_notes.ts b/tfjs-master/scripts/release_notes/release_notes.ts deleted file mode 100644 index 107f03fb3..000000000 --- a/tfjs-master/scripts/release_notes/release_notes.ts +++ /dev/null @@ -1,356 +0,0 @@ -#!/usr/bin/env node -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -/** - * Generates a draft release notes markdown file for a release. This script - * takes a start version of the union package, and optionally an end version. - * It then finds the matching versions for all the dependency packages, and - * finds all commit messages between those versions. - * - * The release notes are grouped by repository, and then bucketed by a set of - * tags which committers can use to organize commits into sections. See - * DEVELOPMENT.md for more details on the available tags. - * - * This script will ask for your github token which is used to make requests - * to the github API for usernames for commits as this is not stored in git - * logs. You can generate a token for your account here; - * https://github.com/settings/tokens - * - * Usage: - * yarn release-notes - */ - -import * as argparse from 'argparse'; -import * as fs from 'fs'; -import * as util from './util'; -import * as path from 'path'; -import {$, Commit, Repo, RepoCommits} from './util'; - -// tslint:disable-next-line:no-require-imports -const octokit = require('@octokit/rest')(); - -const OUT_FILE = path.resolve('release-notes.md'); - -const TFJS_REPOS: Repo[] = [ - {name: 'Core', identifier: 'tfjs', path: 'tfjs-core'}, - {name: 'Data', identifier: 'tfjs', path: 'tfjs-data'}, - {name: 'Layers', identifier: 'tfjs', path: 'tfjs-layers'}, - {name: 'Converter', identifier: 'tfjs', path: 'tfjs-converter'}, - {name: 'Node', identifier: 'tfjs', path: 'tfjs-node'}, - {name: 'Wasm', identifier: 'tfjs', path: 'tfjs-backend-wasm'}, - {name: 'Cpu', identifier: 'tfjs', path: 'tfjs-backend-cpu'}, - {name: 'Webgl', identifier: 'tfjs', path: 'tfjs-backend-webgl'}, - {name: 'WebGPU', identifier: 'tfjs', path: 'tfjs-backend-webgpu'}, -]; - -const VIS_REPO: Repo = { - name: 'tfjs-vis', - identifier: 'tfjs-vis', - path: 'tfjs-vis', -}; - -const RN_REPO: Repo = { - name: 'tfjs-react-native', - identifier: 'tfjs-react-native', - path: 'tfjs-react-native', -}; - -const TFDF_REPO: Repo = { - name: 'tfjs-tfdf', - identifier: 'tfjs-tfdf', - path: 'tfjs-tfdf', -}; - -const TFLITE_REPO: Repo = { - name: 'tfjs-tflite', - identifier: 'tfjs-tflite', - path: 'tfjs-tflite', -}; - -const WEBGPU_REPO: Repo = { - name: 'tfjs-backend-webgpu', - identifier: 'tfjs-backend-webgpu', - path: 'tfjs-backend-webgpu', -}; - -const AUTOML_REPO: Repo = { - name: 'tfjs-automl', - identifier: 'tfjs-automl', - path: 'tfjs-automl', -}; - -async function askUserForVersions(validVersions: string[], packageName: string): - Promise<{startVersion: string, endVersion: string}> { - const YELLOW_TERMINAL_COLOR = '\x1b[33m%s\x1b[0m'; - const RED_TERMINAL_COLOR = '\x1b[31m%s\x1b[0m'; - - console.log(YELLOW_TERMINAL_COLOR, packageName + ' versions'); - console.log(validVersions.join(', ')); - const startVersion = await util.question(`Enter the start version: `); - if (validVersions.indexOf(startVersion) === -1) { - console.log(RED_TERMINAL_COLOR, `Unknown start version: ${startVersion}`); - process.exit(1); - } - const defaultVersion = validVersions[validVersions.length - 1]; - let endVersion = await util.question( - `Enter the end version (leave empty for ${defaultVersion}): `); - if (endVersion === '') { - endVersion = defaultVersion; - } - if (validVersions.indexOf(endVersion) === -1) { - console.log(RED_TERMINAL_COLOR, `Unknown end version: ${endVersion}`); - process.exit(1); - } - return {startVersion, endVersion}; -} - -function getTaggedVersions(packageName: string) { - const versions = - $(`git tag`) - .split('\n') - .filter(x => new RegExp('^' + packageName + '-v([0-9])').test(x)) - .map(x => x.substring((packageName + '-v').length)); - return versions; -} - -function getTagName(packageName: string, version: string) { - return packageName + '-v' + version; -} - -async function generateTfjsPackageNotes() { - // Get union start version and end version. - const identifier = 'tfjs'; - const versions = getTaggedVersions(identifier); - const {startVersion, endVersion} = - await askUserForVersions(versions, identifier); - const startCommit = - `git rev-list -n 1 ` + getTagName(identifier, startVersion); - - // Populate start and end for each of the tfjs packages. - TFJS_REPOS.forEach(repo => { - // Find the version of the dependency from the package.json from the - // earliest tfjs tag. - repo.startCommit = startCommit; - repo.startVersion = startVersion; - repo.endVersion = endVersion; - }); - - await generateNotes(TFJS_REPOS); -} - -async function generateVisNotes() { - // Get union start version and end version. - const versions = getTaggedVersions('tfjs-vis'); - const {startVersion, endVersion} = - await askUserForVersions(versions, 'tfjs-vis'); - - // Get tfjs-vis start version and end version. - VIS_REPO.startVersion = startVersion; - VIS_REPO.endVersion = endVersion; - VIS_REPO.startCommit = $(`git rev-list -n 1 ${ - getTagName(VIS_REPO.identifier, VIS_REPO.startVersion)}`); - - await generateNotes([VIS_REPO]); -} - - -async function generateReactNativeNotes() { - // Get start version and end version. - const versions = getTaggedVersions('tfjs-react-native'); - const {startVersion, endVersion} = - await askUserForVersions(versions, 'tfjs-react-native'); - - // Get tfjs-react-native start version and end version. - RN_REPO.startVersion = startVersion; - RN_REPO.endVersion = endVersion; - RN_REPO.startCommit = $(`git rev-list -n 1 ${ - getTagName(RN_REPO.identifier, RN_REPO.startVersion)}`); - - await generateNotes([RN_REPO]); -} - -async function generateTfdfNotes() { - // Get start version and end version. - const versions = getTaggedVersions('tfjs-tfdf'); - const {startVersion, endVersion} = - await askUserForVersions(versions, 'tfjs-tfdf'); - - // Get tfjs-tfdf start version and end version. - TFDF_REPO.startVersion = startVersion; - TFDF_REPO.endVersion = endVersion; - TFDF_REPO.startCommit = $(`git rev-list -n 1 ${ - getTagName(TFDF_REPO.identifier, TFDF_REPO.startVersion)}`); - - await generateNotes([TFDF_REPO]); -} - -async function generateTfliteNotes() { - // Get start version and end version. - const versions = getTaggedVersions('tfjs-tflite'); - const {startVersion, endVersion} = - await askUserForVersions(versions, 'tfjs-tflite'); - - // Get tfjs-tflite start version and end version. - TFLITE_REPO.startVersion = startVersion; - TFLITE_REPO.endVersion = endVersion; - TFLITE_REPO.startCommit = $(`git rev-list -n 1 ${ - getTagName(TFLITE_REPO.identifier, TFLITE_REPO.startVersion)}`); - - await generateNotes([TFLITE_REPO]); -} - -async function generateWebgpuNotes() { - // Get start version and end version. - const versions = getTaggedVersions('tfjs-backend-webgpu'); - const {startVersion, endVersion} = - await askUserForVersions(versions, 'tfjs-backend-webgpu'); - - // Get tfjs-webgpu start version and end version. - WEBGPU_REPO.startVersion = startVersion; - WEBGPU_REPO.endVersion = endVersion; - WEBGPU_REPO.startCommit = $(`git rev-list -n 1 ${ - getTagName(WEBGPU_REPO.identifier, WEBGPU_REPO.startVersion)}`); - - await generateNotes([WEBGPU_REPO]); -} - -async function generateAutomlNotes() { - // Get start version and end version. - const versions = getTaggedVersions('tfjs-automl'); - const {startVersion, endVersion} = - await askUserForVersions(versions, 'tfjs-automl'); - - // Get tfjs-automl start version and end version. - AUTOML_REPO.startVersion = startVersion; - AUTOML_REPO.endVersion = endVersion; - AUTOML_REPO.startCommit = $(`git rev-list -n 1 ${ - getTagName(AUTOML_REPO.identifier, AUTOML_REPO.startVersion)}`); - - await generateNotes([AUTOML_REPO]); -} - -async function generateNotes(repositories: util.Repo[]) { - const repoCommits: RepoCommits[] = []; - // Clone all of the dependencies into the tmp directory. - repositories.forEach(repo => { - console.log( - `${repo.name}: ${repo.startVersion}` + - ` =====> ${repo.endVersion}`); - - console.log('Querying commits...'); - // Get subjects, bodies, emails, etc from commit metadata. - const commitFieldQueries = ['%s', '%b', '%aE', '%H']; - const commitFields = commitFieldQueries.map(query => { - // Use a unique delimiter so we can split the log. - const uniqueDelimiter = '--^^&&'; - const versionQuery = repo.startVersion != null ? - `${getTagName(repo.identifier, repo.startVersion)}..` + - `${getTagName(repo.identifier, repo.endVersion)}` : - `#${repo.startCommit}..${ - getTagName(repo.identifier, repo.endVersion)}`; - return $(`git log --pretty=format:"${query}${uniqueDelimiter}" ` + - `${versionQuery}`) - .trim() - .split(uniqueDelimiter) - .slice(0, -1) - .map(str => str.trim()); - }); - - const commits: Commit[] = []; - for (let i = 0; i < commitFields[0].length; i++) { - // Make sure the files touched contain the repo directory. - const filesTouched = - $(`git show --pretty="format:" --name-only ${commitFields[3][i]}`) - .split('\n'); - let touchedDir = false; - for (let j = 0; j < filesTouched.length; j++) { - if (filesTouched[j].startsWith(repo.path)) { - touchedDir = true; - break; - } - } - if (!touchedDir) { - continue; - } - - commits.push({ - subject: commitFields[0][i], - body: commitFields[1][i], - authorEmail: commitFields[2][i], - sha: commitFields[3][i] - }); - } - - repoCommits.push({ - repo, - startVersion: repo.startVersion, - endVersion: repo.endVersion, - startCommit: repo.startCommit, - commits - }); - }); - - // Ask for github token. - - // Getting the github token. - let token = process.env.GITHUB_TOKEN; - if (token == null) { - token = await util.question( - 'Enter GitHub token (https://github.com/settings/tokens): '); - - } else { - console.log('The GITHUB_TOKEN is present as environment variable'); - } - octokit.authenticate({type: 'token', token}); - - const notes = await util.getReleaseNotesDraft(octokit, repoCommits); - - fs.writeFileSync(OUT_FILE, notes); - - console.log('Done writing notes to', OUT_FILE); - - // So the script doesn't just hang. - process.exit(0); -} - -const parser = new argparse.ArgumentParser(); - -parser.addArgument('--project', { - help: - 'Which project to generate release notes for. One of union|vis|rn|tfdf|tflite|webgpu|automl. Defaults to union.', - defaultValue: 'union', - choices: ['union', 'vis', 'rn', 'tfdf', 'tflite', 'webgpu', 'automl'] -}); - -const args = parser.parseArgs(); - -if (args.project === 'union') { - generateTfjsPackageNotes(); -} else if (args.project === 'vis') { - generateVisNotes(); -} else if (args.project === 'rn') { - generateReactNativeNotes(); -} else if (args.project === 'tfdf') { - generateTfdfNotes(); -} else if (args.project === 'tflite') { - generateTfliteNotes(); -} else if (args.project === 'webgpu') { - generateWebgpuNotes(); -} else if (args.project === 'automl') { - generateAutomlNotes(); -} diff --git a/tfjs-master/scripts/release_notes/release_notes_test.ts b/tfjs-master/scripts/release_notes/release_notes_test.ts deleted file mode 100644 index df369377f..000000000 --- a/tfjs-master/scripts/release_notes/release_notes_test.ts +++ /dev/null @@ -1,218 +0,0 @@ -#!/usr/bin/env node -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as util from './util'; -import {OctokitGetCommit, RepoCommits} from './util'; - -const fakeCommitContributors: {[key: string]: string;} = { - 'sha1': 'fakecontributor1', - 'sha2': 'fakecontributor2', - 'sha3': 'fakecontributor3' -}; - -const missingAuthorLoginFake = { - name: 'example', - email: 'example@example.com' -}; - - -const fakeOctokit: OctokitGetCommit = { - repos: { - getCommit: (config: {owner: string, repo: string, sha: string}) => { - return { - data: { - author: { - login: fakeCommitContributors[config.sha], - }, - commit: { - author: { - name: missingAuthorLoginFake.name, - email: missingAuthorLoginFake.email - } - } - } - }; - } - } -}; - -describe('getReleaseNotesDraft', () => { - it('Basic draft written', done => { - const repoCommits: RepoCommits[] = [{ - repo: {name: 'Core', identifier: 'tfjs', path: 'tfjs-core'}, - startVersion: '0.9.0', - endVersion: '0.10.0', - startCommit: 'fakecommit', - commits: [{ - subject: 'Add tf.toPixels. (#900)', - body: ` - tf.toPixels is the inverse of tf.fromPixels. - FEATURE - `, - authorEmail: 'test@google.com', - sha: 'sha1' - }] - }]; - - util.getReleaseNotesDraft(fakeOctokit, repoCommits).then(notes => { - expect(notes).toEqual([ - '## Core (0.9.0 ==> 0.10.0)', '', '### Features', - '- Add tf.toPixels. ([#900]' + - '(https://github.com/tensorflow/tfjs/pull/900)).' - ].join('\n')); - done(); - }); - }); - - it('Basic draft external contributor thanks them', done => { - const repoCommits: RepoCommits[] = [{ - repo: {name: 'Core', identifier: 'tfjs', path: 'tfjs-core'}, - startVersion: '0.9.0', - endVersion: '0.10.0', - startCommit: 'fakecommit', - commits: [{ - subject: 'Add tf.toPixels. (#900)', - body: ` - tf.toPixels is the inverse of tf.fromPixels. - FEATURE - `, - authorEmail: 'test@gmail.com', - sha: 'sha1' - }] - }]; - - util.getReleaseNotesDraft(fakeOctokit, repoCommits).then(notes => { - expect(notes).toEqual([ - '## Core (0.9.0 ==> 0.10.0)', '', '### Features', - '- Add tf.toPixels. ([#900]' + - '(https://github.com/tensorflow/tfjs/pull/900)).' + - ' Thanks, @fakecontributor1.' - ].join('\n')); - done(); - }); - }); - - it('Complex draft', done => { - const repoCommits: RepoCommits[] = [ - { - repo: {name: 'Core', identifier: 'tfjs', path: 'tfjs-core'}, - startVersion: '0.9.0', - endVersion: '0.10.0', - startCommit: 'fakecommit', - commits: [ - { - subject: 'Add tf.toPixels. (#900)', - body: ` - tf.toPixels is the inverse of tf.fromPixels. - `, - authorEmail: 'test@gmail.com', - sha: 'sha1' - }, - { - subject: 'Improvements to matMul. (#901)', - body: ` - Makes matmul better overall. - FEATURE Adds transpose bit. - PERF Improves speed of matMul by 100%. - `, - authorEmail: 'test@gmail.com', - sha: 'sha2' - } - ] - }, - { - repo: {name: 'Layers', identifier: 'tfjs', path: 'tfjs-layers'}, - startVersion: '0.4.0', - endVersion: '0.5.1', - startCommit: 'fakecommit2', - commits: [{ - subject: 'Change API of layers. (#100)', - body: ` - tf.toPixels is the inverse of tf.fromPixels. - BREAKING - DOC Update docstrings of tf.layers.dense. - FEATURE Add automatic argument parsing. - `, - authorEmail: 'test@gmail.com', - sha: 'sha1' - }] - } - ]; - - util.getReleaseNotesDraft(fakeOctokit, repoCommits).then(notes => { - expect(notes).toEqual([ - '## Core (0.9.0 ==> 0.10.0)', - '', - '### Features', - '- Adds transpose bit. [Improvements to matMul.] ([#901]' + - '(https://github.com/tensorflow/tfjs/pull/901)).' + - ' Thanks, @fakecontributor2.', - '### Performance', - '- Improves speed of matMul by 100%. [Improvements to matMul.]' + - ' ([#901](https://github.com/tensorflow/tfjs/pull/901)).' + - ' Thanks, @fakecontributor2.', - '### Misc', - '- Add tf.toPixels. ([#900]' + - '(https://github.com/tensorflow/tfjs/pull/900)).' + - ' Thanks, @fakecontributor1.', - '', - '## Layers (0.4.0 ==> 0.5.1)', - '', - '### Features', - '- Add automatic argument parsing. [Change API of layers.] ' + - '([#100](https://github.com/tensorflow/tfjs/pull/100)).' + - ' Thanks, @fakecontributor1.', - - '### Breaking changes', - '- Change API of layers. ' + - '([#100](https://github.com/tensorflow/tfjs/pull/100)).' + - ' Thanks, @fakecontributor1.', - '### Documentation', - '- Update docstrings of tf.layers.dense. [Change API of layers.] ' + - '([#100](https://github.com/tensorflow/tfjs/pull/100)).' + - ' Thanks, @fakecontributor1.', - ].join('\n')); - done(); - }); - }); - - it('Subject has no pull request number', done => { - const repoCommits: RepoCommits[] = [{ - repo: {name: 'Core', identifier: 'tfjs', path: 'tfjs-core'}, - startVersion: '0.9.0', - endVersion: '0.10.0', - startCommit: 'fakecommit', - commits: [{ - subject: 'Add tf.toPixels.', - body: ` - tf.toPixels is the inverse of tf.fromPixels. - FEATURE - `, - authorEmail: 'test@google.com', - sha: 'sha1' - }] - }]; - - util.getReleaseNotesDraft(fakeOctokit, repoCommits).then(notes => { - expect(notes).toEqual([ - '## Core (0.9.0 ==> 0.10.0)', '', '### Features', '- Add tf.toPixels.' - ].join('\n')); - done(); - }); - }); -}); diff --git a/tfjs-master/scripts/release_notes/run_tests.ts b/tfjs-master/scripts/release_notes/run_tests.ts deleted file mode 100644 index 413f972f0..000000000 --- a/tfjs-master/scripts/release_notes/run_tests.ts +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env node -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -// tslint:disable-next-line:no-require-imports -const jasmineCtor = require('jasmine'); -const runner = new jasmineCtor(); - -runner.loadConfig({spec_files: ['scripts/release_notes/**/*_test.ts']}); -runner.execute(); diff --git a/tfjs-master/scripts/release_notes/tsconfig.json b/tfjs-master/scripts/release_notes/tsconfig.json deleted file mode 100644 index 3f840fa91..000000000 --- a/tfjs-master/scripts/release_notes/tsconfig.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "extends": "../../tsconfig", - "compilerOptions": { - "module": "commonjs", - "target": "es5", - } -} diff --git a/tfjs-master/scripts/release_notes/util.ts b/tfjs-master/scripts/release_notes/util.ts deleted file mode 100644 index 3d40c9105..000000000 --- a/tfjs-master/scripts/release_notes/util.ts +++ /dev/null @@ -1,242 +0,0 @@ -#!/usr/bin/env node -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as shell from 'shelljs'; -import * as readline from 'readline'; - -const GOOGLERS_WITH_GMAIL = new Set([ - 'dsmilkov', - 'kainino0x', - 'davidsoergel', - 'pyu10055', - 'nkreeger', - 'tafsiri', - 'annxingyuan', - 'Kangyi Zhang', - 'lina128', - 'mattsoulanille', - 'jinjingforever', - 'chunnienc', - 'Linchenn', - 'fengwuyao', -].map((s) => s.trim().toLowerCase())); - -function isGooglerUsername(username: string): boolean { - return GOOGLERS_WITH_GMAIL.has(username.trim().toLocaleLowerCase()); -} - -const rl = - readline.createInterface({input: process.stdin, output: process.stdout}); - -/** - * A wrapper around shell.exec for readability. - * @param cmd The bash command to execute. - * @returns stdout returned by the executed bash script. - */ -export function $(cmd: string) { - const result = shell.exec(cmd, {silent: true}); - if (result.code > 0) { - console.log('$', cmd); - console.log(result.stderr); - process.exit(1); - } - return result.stdout.trim(); -} - -export async function question(questionStr: string): Promise { - return new Promise( - resolve => rl.question(questionStr, response => resolve(response))); -} - -export interface Repo { - name: string; - identifier: string; - path: string; - startVersion?: string; - startCommit?: string; - endVersion?: string; -} - -export interface RepoCommits { - repo: Repo; - startVersion: string; - endVersion: string; - startCommit: string; - commits: Commit[]; -} - -export interface Commit { - subject: string; - body: string; - authorEmail: string; - sha: string; -} - -export interface OctokitGetCommit { - repos: { - getCommit: - (config: {owner: string, repo: string, sha: string}) => { - data: { - commit: { - author: { - name: string, - email: string, - } - }, - author: {login: string}, - } - } - }; -} - -interface SectionTag { - section: string; - tag: string; -} - -const SECTION_TAGS: SectionTag[] = [ - {section: 'Features', tag: 'FEATURE'}, - {section: 'Breaking changes', tag: 'BREAKING'}, - {section: 'Bug fixes', tag: 'BUG'}, {section: 'Performance', tag: 'PERF'}, - {section: 'Development', tag: 'DEV'}, {section: 'Documentation', tag: 'DOC'}, - {section: 'Security', tag: 'SECURITY'}, {section: 'Misc', tag: 'MISC'}, - {section: 'Internal', tag: 'INTERNAL'} -]; - -/** - * Assembles the release note drafts from a set of commits. - * - * @param octokit An authenticated octokit object (to make github API - * requests). - * It only needs to satisfy the OctokitGetCommit interface which gets commit - * metadata. - * @param repoCommits An object representing the metadata for commits to - * assmemble into release notes. - * @returns The release notes markdown draft as a string. - */ -export async function getReleaseNotesDraft( - octokit: OctokitGetCommit, repoCommits: RepoCommits[]): Promise { - const repoNotes: string[] = []; - for (let i = 0; i < repoCommits.length; i++) { - const repoCommit = repoCommits[i]; - - const getUsernameForCommit = async (sha: string) => { - let result; - try { - result = await octokit.repos.getCommit( - {owner: 'tensorflow', repo: 'tfjs', sha}); - return result.data.author.login; - } catch (e) { - console.log(`Error fetching username for commit ${sha}`); - console.log(`Using ${result.data.commit.author.name}`); - return result.data.commit.author.name; - } - }; - - const tagEntries: {[tag: string]: string[]} = {}; - SECTION_TAGS.forEach(({tag}) => tagEntries[tag] = []); - - for (let j = 0; j < repoCommit.commits.length; j++) { - const commit = repoCommit.commits[j]; - - const tagsFound: Array<{tag: string, tagMessage: string}> = []; - const bodyLines = commit.body.split('\n').map(line => line.trim()); - // Get tags for the body by finding lines that start with tags. Do - // this without a regex for readability. - SECTION_TAGS.forEach(({tag}) => { - if (tag === 'INTERNAL') { - return; - } - - bodyLines.forEach(line => { - // Split by word boundaries, and make sure the first word is the - // tag. - const split = line.split(/\b/); - if (split[0] === tag) { - const tagMessage = line.substring(tag.length).trim(); - tagsFound.push({tag, tagMessage}); - } - }); - }); - // If no explicit tags, put this under misc. - if (tagsFound.length === 0) { - tagsFound.push({tag: 'MISC', tagMessage: ''}); - } - - const username = await getUsernameForCommit(commit.sha); - const isExternalContributor = - !commit.authorEmail.endsWith('@google.com') && - !isGooglerUsername(username); - - const pullRequestRegexp = /\(#([0-9]+)\)/; - const pullRequestMatch = commit.subject.match(pullRequestRegexp); - - let subject = commit.subject; - let pullRequestNumber: string|null = null; - if (pullRequestMatch != null) { - subject = subject.replace(pullRequestRegexp, '').trim(); - pullRequestNumber = pullRequestMatch[1]; - } - - for (let k = 0; k < tagsFound.length; k++) { - const {tag, tagMessage} = tagsFound[k]; - - // When the tag has no message, use the subject. - let entry; - if (tagMessage === '') { - entry = '- ' + subject; - } else { - entry = '- ' + tagMessage + ' [' + subject + ']'; - } - - // Attach the link to the pull request. - const pullRequestSuffix = pullRequestNumber != null ? - ` ([#${pullRequestNumber}]` + - `(https://github.com/tensorflow/tfjs/pull/${ - pullRequestNumber})).` : - ''; - - entry = entry.trim() + pullRequestSuffix; - - // For external contributors, we need to query github because git - // does not contain github username metadatea. - if (isExternalContributor) { - entry += (!entry.endsWith('.') ? '.' : '') + ` Thanks, @${username}.`; - } - - tagEntries[tag].push(entry); - } - } - - const repoLines: string[] = []; - SECTION_TAGS.forEach(({tag, section}) => { - if (tagEntries[tag].length !== 0) { - const sectionNotes = tagEntries[tag].join('\n'); - repoLines.push(`### ${section}`); - repoLines.push(sectionNotes); - } - }); - - const repoSection = `## ${repoCommit.repo.name} ` + - `(${repoCommit.startVersion} ==> ` + - `${repoCommit.endVersion})\n\n` + repoLines.join('\n'); - repoNotes.push(repoSection); - } - - return repoNotes.join('\n\n'); -} diff --git a/tfjs-master/scripts/run-build.sh b/tfjs-master/scripts/run-build.sh deleted file mode 100644 index ea5ae07e8..000000000 --- a/tfjs-master/scripts/run-build.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env bash -# Copyright 2019 Google LLC. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================= - -# Echo every command being executed -set -x - -# Exit the script on any command with non 0 return code -set -e - -gcloud builds submit . --config=cloudbuild_generated.yml \ - --substitutions _NIGHTLY=$NIGHTLY diff --git a/tfjs-master/scripts/run_bazel_ci_tests.sh b/tfjs-master/scripts/run_bazel_ci_tests.sh deleted file mode 100644 index a083a588e..000000000 --- a/tfjs-master/scripts/run_bazel_ci_tests.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env bash -# Copyright 2021 Google LLC. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================= - -# Exit the script on any command with non 0 return code -set -e - -if [ "$NIGHTLY" = true ]; then - # Run `bazel test` on all targets that have the "ci" or "nightly" tag. - TARGETS=`./node_modules/.bin/bazel query --output label 'attr("tags", "ci", ...) union attr("tags", "nightly", ...)'` -else - # Run `bazel test` on all targets that have the "ci" tag. - TARGETS=`./node_modules/.bin/bazel query --output label 'attr("tags", "ci", ...)'` -fi - -yarn bazel test --config=ci --flaky_test_attempts=3 --local_test_jobs=25 $TARGETS diff --git a/tfjs-master/scripts/run_flaky.js b/tfjs-master/scripts/run_flaky.js deleted file mode 100644 index acd2dddc5..000000000 --- a/tfjs-master/scripts/run_flaky.js +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright 2021 Google LLC. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= - -const {ArgumentParser} = require('argparse'); -const {exec} = require('shelljs'); - - -function main(args) { - const command = args['command']; - const times = parseInt(args['times']); - - if (times === 0) { - throw new Error(`Flaky test asked to run zero times: '${command}'`); - } - - console.log(`Running flaky test at most ${times} times`); - console.log(`Command: '${command}'`); - const exitCodes = []; - for (let i = 0; i < times; i++) { - console.log(`Flaky run ${i + 1} of a potential ${times} for '${command}'`); - const exitCode = exec(command).code; - exitCodes.push(exitCode); - if (exitCode === 0) { - break; - } - } - - const success = exitCodes[exitCodes.length - 1] === 0; - if (!success) { - console.error(`Flaky test failed ${times} times`); - } else if (exitCodes.length > 1) { - console.warn( - `Flaky test failed ${exitCodes.length - 1} times before passing.`); - } else { - // Test passed with no fails - console.log('Flaky test passed on the first run'); - } - console.error(`Command: '${command}'`); - console.error(`Exit codes: ${exitCodes}`); - - if (!success) { - process.exit(1); - } -} - -const parser = new ArgumentParser( - {description: 'Run a flaky test a number of times or until it passes'}); - -parser.addArgument('command', {help: 'Flaky command to run'}) -parser.addArgument('--times', { - help: 'Maximum number of times to run the command', - defaultValue: 3, - nargs: '?', - type: 'int', -}); - -main(parser.parseArgs()); diff --git a/tfjs-master/scripts/run_flaky_test.js b/tfjs-master/scripts/run_flaky_test.js deleted file mode 100644 index 03c34a181..000000000 --- a/tfjs-master/scripts/run_flaky_test.js +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2021 Google LLC. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= - -const {exec} = require('shelljs'); -const fs = require('fs'); - -const {FILE_NAME} = require('./run_flaky_test_helper.js'); - -describe('run_flaky', () => { - it('exits with zero if the command succeeds', () => { - expect(exec('node ./scripts/run_flaky.js "echo success"').code).toEqual(0); - }); - - it('exits with one if the command fails', () => { - expect(exec('node ./scripts/run_flaky.js "exit 1"').code).toEqual(1); - }); - - it('exits with zero if the command eventually succeeds', () => { - // Remove test file that was not cleaned up from a prior run. - if (fs.existsSync(FILE_NAME)) { - fs.unlinkSync(FILE_NAME); - } - - // This command should fail once and then succeed the next run. - expect(exec( - 'node ./scripts/run_flaky.js --times 2' + - ' \'node ./scripts/run_flaky_test_helper.js\'') - .code) - .toEqual(0); - - // Clean up test file - fs.unlinkSync(FILE_NAME); - }); -}); diff --git a/tfjs-master/scripts/run_flaky_test_helper.js b/tfjs-master/scripts/run_flaky_test_helper.js deleted file mode 100644 index 0c146818f..000000000 --- a/tfjs-master/scripts/run_flaky_test_helper.js +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2021 Google LLC. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= - -const fs = require('fs'); -const FILE_NAME = './flaky_test_has_run'; -module.exports.FILE_NAME = FILE_NAME; - -function main() { - if (!fs.existsSync(FILE_NAME)) { - fs.writeFileSync( - FILE_NAME, - 'This temp file is used for testing' + - ' scripts/flaky_test.js and can be safely removed.'); - process.exit(1); - } -} - -if (require.main === module) { - main(); -} diff --git a/tfjs-master/scripts/start_local_debugger_server.js b/tfjs-master/scripts/start_local_debugger_server.js deleted file mode 100644 index 17ad7c9ab..000000000 --- a/tfjs-master/scripts/start_local_debugger_server.js +++ /dev/null @@ -1,126 +0,0 @@ -// Copyright 2022 Google LLC. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= - -const express = require('express'); -const {ArgumentParser, ArgumentDefaultsHelpFormatter} = require('argparse'); -const JSZip = require('jszip'); -const fetch = require('node-fetch'); -const path = require('node:path'); - -const DEFAULT_VERSION = '20221122-100434'; -const TFJS_DEBUGGER_BUNDLE_URL_BASE = - 'https://storage.googleapis.com/tfweb/tfjs-debugger-bundle'; -const EXTS_WITH_ARRAY_BUFFER_CONTENT = ['.ttf']; - -const app = express(); -const debuggerStaticFile = {}; - -function main(args) { - const port = parseInt(args['port']); - const version = args['version']; - - app.get('/*', (req, res) => { - // Remove leading '/'. - let filePath = req.path.substring(1); - if (filePath === '') { - filePath = 'index.html'; - } - - // Send file from the unzipped tfjs-debugger bundle from memory. - if (debuggerStaticFile[filePath]) { - res.contentType(path.basename(filePath)); - res.send(debuggerStaticFile[filePath]); - } - // Send other files from the local file system. - else { - const tfjsRoot = __dirname.replace('/scripts', '/'); - res.sendFile(tfjsRoot + filePath); - } - }); - - app.listen(port, async () => { - // On server start-up, fetch the zipped debugger bundle and unzip in memory. - console.log('Fetching tfjs debugger static files...'); - await fetchAndUnzipTfjsDebuggerBundle(version); - console.log('Done'); - console.log(`Local debugger server started at http://localhost:${ - port}/?bv__0=Local%20build&bv__1=`); - }); -} - -async function fetchAndUnzipTfjsDebuggerBundle(version) { - let resp; - try { - resp = await new Promise(resolve => { - const fileUrl = - `${TFJS_DEBUGGER_BUNDLE_URL_BASE}/tfjs-debugger_${version}.zip`; - fetch(fileUrl).then(response => { - if (!response.ok) { - throw new Error(`Failed to load bundle: ${fileUrl}`); - } - resolve(response); - }) - }); - } catch (e) { - console.error(e.message); - } - const buffer = await resp.buffer(); - - // Read zip objects. - const zipObjects = await new Promise(resolve => { - const zipObjects = []; - JSZip.loadAsync(buffer).then((zip) => { - zip.folder('dist').forEach((relativePath, zipObject) => { - zipObjects.push(zipObject); - }); - resolve(zipObjects); - }) - }); - - // Read and index files content. - for (const zipObject of zipObjects) { - await new Promise(resolve => { - const name = zipObject.name; - zipObject - .async( - EXTS_WITH_ARRAY_BUFFER_CONTENT.some(ext => name.endsWith(ext)) ? - 'nodebuffer' : - 'text') - .then(content => { - const fileName = name.replace('dist/', ''); - debuggerStaticFile[fileName] = content; - resolve(); - }); - }); - } -} - -const parser = new ArgumentParser({ - description: 'Run tfjs-debugger locally that supports loading local packages', -}); - -parser.addArgument('--port', { - help: 'Server port', - defaultValue: 9876, - type: 'int', -}); - -parser.addArgument('--version', { - help: `The verison of the bundle. Default: ${DEFAULT_VERSION}`, - defaultValue: DEFAULT_VERSION, - type: 'string', -}); - -main(parser.parseArgs()); diff --git a/tfjs-master/scripts/tag-tfjs-release.ts b/tfjs-master/scripts/tag-tfjs-release.ts deleted file mode 100644 index a23536767..000000000 --- a/tfjs-master/scripts/tag-tfjs-release.ts +++ /dev/null @@ -1,57 +0,0 @@ -#!/usr/bin/env node -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -/** - * This script tags a release after lockfiles are updated - */ - -import * as argparse from 'argparse'; -import * as shell from 'shelljs'; -import {$, checkoutReleaseBranch, getReleaseBranch} from './release-util'; - -const parser = new argparse.ArgumentParser(); - -parser.addArgument('--git-protocol', { - action: 'storeTrue', - help: 'Use the git protocol rather than the http protocol when cloning repos.' -}); - -async function main() { - const args = parser.parseArgs(); - // ========== Get release branch. ============================================ - const releaseBranch = await getReleaseBranch('tfjs'); - - const TMP_DIR = '/tmp/tfjs-tag'; - - // ========== Checkout release branch. ======================================= - checkoutReleaseBranch(releaseBranch, args.git_protocol, TMP_DIR); - - shell.cd(TMP_DIR); - - // ========== Tag the release. =============================================== - const version = releaseBranch.split('_')[1]; - const tag = `tfjs-v${version}`; - console.log(`Tagging with ${tag}`); - $(`git tag ${tag} && git push --tags`); - console.log('Done.'); - - // So the script doesn't just hang. - process.exit(0); -} - -main(); diff --git a/tfjs-master/scripts/tag-version.js b/tfjs-master/scripts/tag-version.js deleted file mode 100644 index 511c340e4..000000000 --- a/tfjs-master/scripts/tag-version.js +++ /dev/null @@ -1,45 +0,0 @@ -#!/usr/bin/env node -// Copyright 2018 Google LLC. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= - -// Run this script from the base directory (not the package directory): -// ./scripts/tag-version.js DIR_NAME -// Where DIR_NAME is the directory name for the package you want to make a -// version for. -const fs = require('fs'); - -let dirName = process.argv[2]; -if (dirName.endsWith('/')) { - dirName = dirName.slice(0, -1); -} -const packageJsonFile = dirName + '/package.json'; -if (!fs.existsSync(packageJsonFile)) { - console.log( - packageJsonFile, 'does not exist. Please call this script as follows:'); - console.log('./scripts/tag-version.js DIR_NAME'); - process.exit(1); -} - -var exec = require('child_process').exec; - -var version = JSON.parse(fs.readFileSync(packageJsonFile, 'utf8')).version; -var tag = `${dirName}-v${version}`; - -exec(`git tag ${tag} && git push --tags`, (err, stdout, stderr) => { - if (err) { - throw new Error(`Could not git tag with ${tag}: ${err.message}.`); - } - console.log(`Successfully tagged with ${tag}.`); -}); diff --git a/tfjs-master/scripts/test-util.js b/tfjs-master/scripts/test-util.js deleted file mode 100644 index d2d3b085a..000000000 --- a/tfjs-master/scripts/test-util.js +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright 2019 Google LLC. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= - -const shell = require('shelljs'); -const fs = require('fs'); - -function exec(command, opt, ignoreCode) { - const res = shell.exec(command, opt); - if (!ignoreCode && res.code !== 0) { - shell.echo('command', command, 'returned code', res.code); - process.exit(1); - } - return res; -} - -// Construct a dependency graph keyed by dependency package. -// Example: -// dependencyGraph = { -// "tfjs-core": ["tfjs-converter", "tfjs", ...], -// "tfjs": ["tfjs-node"], -// ... -// } -function constructDependencyGraph(dependencyFilePath) { - const str = fs.readFileSync(dependencyFilePath, 'utf8'); - const dependencyInfo = JSON.parse(str); - - const dependencyGraph = {}; - - Object.keys(dependencyInfo) - .forEach(package => dependencyInfo[package].forEach(dependency => { - if (!dependencyGraph[dependency]) { - dependencyGraph[dependency] = []; - } - dependencyGraph[dependency].push(package); - })); - - return dependencyGraph; -} - -function computeAffectedPackages(dependencyGraph, package) { - const affectedPackages = new Set(); - traverseDependencyGraph(dependencyGraph, package, affectedPackages); - - return Array.from(affectedPackages); -} - -// This function performs a depth-first-search to add affected packages that -// transitively depend on the given package. -function traverseDependencyGraph(graph, package, affectedPackages) { - // Terminate early if the package has been visited. - if (affectedPackages.has(package)) { - return; - } - - const consumingPackages = graph[package]; - - if (!consumingPackages) { - return; - } - - consumingPackages.forEach(consumingPackage => { - traverseDependencyGraph(graph, consumingPackage, affectedPackages); - affectedPackages.add(consumingPackage); - }); -} - -exports.exec = exec; -exports.constructDependencyGraph = constructDependencyGraph; -exports.computeAffectedPackages = computeAffectedPackages; diff --git a/tfjs-master/scripts/tsconfig.json b/tfjs-master/scripts/tsconfig.json deleted file mode 100644 index 0a66f17bc..000000000 --- a/tfjs-master/scripts/tsconfig.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "extends": "../tsconfig", - "compilerOptions": { - "module": "commonjs", - "target": "es6", - "lib": [ - "esnext" - ], - "downlevelIteration": true, - "esModuleInterop": true - }, - "include": [ - "**/*.ts" - ] -} diff --git a/tfjs-master/scripts/update-tfjs-lockfiles.ts b/tfjs-master/scripts/update-tfjs-lockfiles.ts deleted file mode 100644 index da036aca1..000000000 --- a/tfjs-master/scripts/update-tfjs-lockfiles.ts +++ /dev/null @@ -1,98 +0,0 @@ -#!/usr/bin/env node -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -/** - * This script update yarn.lock after tfjs packages are published. - * - * This script requires hub to be installed: https://hub.github.com/ - */ - -import chalk from 'chalk'; -import * as argparse from 'argparse'; -import * as shell from 'shelljs'; - -import {$, TFJS_RELEASE_UNIT, prepareReleaseBuild, getReleaseBranch, checkoutReleaseBranch, createPR} from './release-util'; - -const parser = new argparse.ArgumentParser(); - -parser.addArgument('--git-protocol', { - action: 'storeTrue', - help: 'Use the git protocol rather than the http protocol when cloning repos.' -}); - -const TMP_DIR = '/tmp/tfjs-publish-after'; - -async function main() { - const args = parser.parseArgs(); - - // ========== Get release branch. ============================================ - // Infer release branch name. - let releaseBranch = await getReleaseBranch('tfjs'); - console.log(); - - // ========== Checkout release branch. ======================================= - checkoutReleaseBranch(releaseBranch, args.git_protocol, TMP_DIR); - - shell.cd(TMP_DIR); - - // ========== Delete a possible prior lockfiles branch from a failed run ===== - const lockfilesBranch = `${releaseBranch}_lockfiles`; - console.log(chalk.magenta.bold( - `~~~ Creating new lockfiles branch ${lockfilesBranch} ~~~`)); - - // Delete possible branch from a prior execution of this script - const branchCmd = `git branch -D ${lockfilesBranch}`; - const result = shell.exec(branchCmd, {silent: true}); - const okErrCode = `branch '${lockfilesBranch}' not found`; - if (result.code > 0 && !result.stderr.trim().match(okErrCode)) { - console.log('$', branchCmd); - console.log(result.stderr); - process.exit(1); - } - - // ========== Run yarn to update yarn.lock file for each package. ============ - // Yarn in the top-level. - $('yarn'); - - // run yarn for every tfjs package - const phases = TFJS_RELEASE_UNIT.phases; - - for (let i = 0; i < phases.length; i++) { - const phase = phases[i]; - const packages = phase.packages; - - for (let i = 0; i < packages.length; i++) { - const packageName = packages[i]; - shell.cd(packageName); - - prepareReleaseBuild(phase, packageName); - - shell.cd('..'); - } - } - - // ========== Send a PR to the release branch ===================== - const message = `Update lockfiles branch ${lockfilesBranch} lock files.`; - createPR(lockfilesBranch, releaseBranch, message); - - console.log('Done.'); - - process.exit(0); -} - -main(); diff --git a/tfjs-master/tfjs-automl/.npmignore b/tfjs-master/tfjs-automl/.npmignore deleted file mode 100644 index 72daebb83..000000000 --- a/tfjs-master/tfjs-automl/.npmignore +++ /dev/null @@ -1,21 +0,0 @@ -.vscode/ -.rpt2_cache/ -.cache/ -demo/ -src/**/*_test.ts -dist/**/*_test.* -coverage/ -package/ -scripts/ -**/node_modules/ -karma.conf.js -*.tgz -*.log -.travis.yml -CONTRIBUTING.md -tslint.json -yarn.lock -rollup.config.js -tsconfig.json -.yalc/ -yalc.lock diff --git a/tfjs-master/tfjs-automl/.vscode/settings.json b/tfjs-master/tfjs-automl/.vscode/settings.json deleted file mode 100644 index 5f30a3cfd..000000000 --- a/tfjs-master/tfjs-automl/.vscode/settings.json +++ /dev/null @@ -1 +0,0 @@ -../../.vscode/settings.json \ No newline at end of file diff --git a/tfjs-master/tfjs-automl/.vscode/tasks.json b/tfjs-master/tfjs-automl/.vscode/tasks.json deleted file mode 100644 index 5edb3db96..000000000 --- a/tfjs-master/tfjs-automl/.vscode/tasks.json +++ /dev/null @@ -1 +0,0 @@ -../../.vscode/tasks.json \ No newline at end of file diff --git a/tfjs-master/tfjs-automl/README.md b/tfjs-master/tfjs-automl/README.md deleted file mode 100644 index 6dda15844..000000000 --- a/tfjs-master/tfjs-automl/README.md +++ /dev/null @@ -1,206 +0,0 @@ -# AutoML Edge API - -This packages provides a set of APIs to load and run models produced by AutoML -Edge. - -## Installation - -If you are using npm/yarn -```sh -npm i @tensorflow/tfjs-automl -``` - -If you are using CDN: -```html - -``` - -We support the following types of AutoML Edge models: -1) [Image classification](#image-classification) -2) [Object detection](#object-detection) - -## Image classification - -AutoML Image classification model will output the following set of files: -- `model.json`, the model topology -- `dict.txt`, a newline-separated list of labels -- One or more of `*.bin` files which hold the weights - -Make sure you can access those files as static assets from your web app by serving them locally or on Google Cloud Storage. - -### Demo - -The image classification demo lives in -[demo/img_classification](./demo/img_classification). To run it: - -```sh -cd demo/img_classification -yarn -yarn watch -``` - -This will start a local HTTP server on port 1234 that serves the demo. - -### Loading the model -```js -import * as automl from '@tensorflow/tfjs-automl'; -const modelUrl = 'model.json'; // URL to the model.json file. -const model = await automl.loadImageClassification(modelUrl); -``` - -If you do not want (or cannot) load the model over HTTP you can also load the model separately and directly use the constuctor. -This is particularly relevant for __non-browser__ platforms. - -The following psuedocode demonstrates this approach: - -```js -import * as automl from '@tensorflow/tfjs-automl'; -import * as tf from '@tensorflow/tfjs'; -// You can load the graph model using any IO handler -const graphModel = await tf.loadGraphModel(string|io.IOHandler); // a url or ioHandler instance -// You can load the dictionary using any api available to the platform -const dict = loadDictionary("path/to/dict.txt"); -const model = new automl.ImageClassificationModel(graphModel, dict); -``` - -### Making a prediction - -The AutoML library takes care of any image preprocessing -(normalize, resize, crop). The input `img` you provide can be -[`HTMLImageElement`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement), -[`HTMLCanvasElement`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement), -[`HTMLVideoElement`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLVideoElement), -[`ImageData`](https://developer.mozilla.org/en-US/docs/Web/API/ImageData) or -a 3D [`Tensor`](https://js.tensorflow.org/api/latest/#class:Tensor): - -```html - -``` - -```js -const img = document.getElementById('img'); -const options = {centerCrop: true}; -const predictions = await model.classify(img, options); -``` - -`options` is optional and has the following properties: -- `centerCrop` - Defaults to true. Since the ML model expects a square image, -we need to resize. If true, the image will be cropped first to the center before -resizing. - -The result `predictions` is a sorted list of predicted labels and their -probabilities: - -```js -[ - {label: "daisy", prob: 0.931}, - {label: "dandelion", prob: 0.027}, - {label: "roses", prob: 0.013}, - ... -] -``` - -### Advanced usage - -Advanced users can access the underlying -[`GraphModel`](https://js.tensorflow.org/api/latest/#class:GraphModel) via -`model.graphModel`. The `GraphModel` allows users to call lower level methods -such as `predict()`, `execute()` and `executeAsync()` which return tensors. - -`model.dictionary` gives you access to the ordered list of labels. - -## Object detection - -AutoML Object detection model will output the following set of files: -- `model.json`, the model topology -- `dict.txt`, a newline-separated list of labels -- One or more of `*.bin` files which hold the weights - -Make sure you can access those files as static assets from your web app by serving them locally or on Google Cloud Storage. - -### Demo - -The object detection demo lives in -[demo/object_detection](./demo/object_detection). To run it: - -```sh -cd demo/object_detection -yarn -yarn watch -``` - -This will start a local HTTP server on port 1234 that serves the demo. - -### Loading the model -```js -import * as automl from '@tensorflow/tfjs-automl'; -const modelUrl = 'model.json'; // URL to the model.json file. -const model = await automl.loadObjectDetection(modelUrl); -``` - -If you do not want (or cannot) load the model over HTTP you can also load the model separately and directly use the constuctor. -This is particularly relevant for __non-browser__ platforms. - -The following psuedocode demonstrates this approach: - -```js -import * as automl from '@tensorflow/tfjs-automl'; -import * as tf from '@tensorflow/tfjs'; -// You can load the graph model using any IO handler -const graphModel = await tf.loadGraphModel(string|io.IOHandler); // a url or ioHandler instance -// You can load the dictionary using any api available to the platform -const dict = readDictionary("path/to/dict.txt"); -const model = new automl.ObjectDetectionModel(graphModel, dict); -``` - -### Making a prediction - -The AutoML library takes care of any image preprocessing -(normalize, resize, crop). The input `img` you provide can be -[`HTMLImageElement`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement), -[`HTMLCanvasElement`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement), -[`HTMLVideoElement`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLVideoElement), -[`ImageData`](https://developer.mozilla.org/en-US/docs/Web/API/ImageData) or -a 3D [`Tensor`](https://js.tensorflow.org/api/latest/#class:Tensor): - -```html - -``` - -```js -const img = document.getElementById('img'); -const options = {score: 0.5, iou: 0.5, topk: 20}; -const predictions = await model.detect(img, options); -``` - -`options` is optional and has the following properties: -- `score` - Probability score between 0 and 1. Defaults to 0.5. Boxes with score lower than this threshold will be ignored. -- `topk` - Only the `topk` most likely objects are returned. The actual number of objects might be less than this number. -- `iou` - Intersection over union threshold. IoU is a metric between 0 and 1 used to measure the overlap of two boxes. The predicted boxes will not overlap more than the specified threshold. - -The result `predictions` is a sorted list of predicted objects: - -```js -[ - { - box: { - left: 105.1, - top: 22.2, - width: 70.6, - height: 55.7 - }, - label: "Tomato", - score: 0.972 - }, - ... -] -``` - -### Advanced usage - -Advanced users can access the underlying -[`GraphModel`](https://js.tensorflow.org/api/latest/#class:GraphModel) via -`model.graphModel`. The `GraphModel` allows users to call lower level methods -such as `predict()`, `execute()` and `executeAsync()` which return tensors. - -`model.dictionary` gives you access to the ordered list of labels. diff --git a/tfjs-master/tfjs-automl/cloudbuild.yml b/tfjs-master/tfjs-automl/cloudbuild.yml deleted file mode 100644 index 3d927092b..000000000 --- a/tfjs-master/tfjs-automl/cloudbuild.yml +++ /dev/null @@ -1,62 +0,0 @@ -steps: -# Install common dependencies. -- name: 'gcr.io/learnjs-174218/release' - entrypoint: 'yarn' - id: 'yarn-common' - args: ['install'] - -# Install tfjs-automl dependencies. -- name: 'gcr.io/learnjs-174218/release' - dir: 'tfjs-automl' - entrypoint: 'yarn' - id: 'yarn' - args: ['install'] - waitFor: ['yarn-common'] - -# Build. -- name: 'gcr.io/learnjs-174218/release' - dir: 'tfjs-automl' - entrypoint: 'yarn' - id: 'build' - args: ['build'] - waitFor: ['yarn'] - -# Lint. -- name: 'gcr.io/learnjs-174218/release' - dir: 'tfjs-automl' - entrypoint: 'yarn' - id: 'lint' - args: ['lint'] - waitFor: ['yarn'] - -# Run node tests. -- name: 'gcr.io/learnjs-174218/release' - dir: 'tfjs-automl' - entrypoint: 'yarn' - id: 'test-js' - args: ['test-node'] - waitFor: ['yarn', 'build', 'lint'] - - # Run browser tests. -- name: 'gcr.io/learnjs-174218/release' - dir: 'tfjs-automl' - entrypoint: 'yarn' - id: 'test-browser' - args: ['test-ci'] - env: ['BROWSERSTACK_USERNAME=deeplearnjs1'] - secretEnv: ['BROWSERSTACK_KEY'] - waitFor: ['yarn', 'build', 'lint'] - -# General settings. -secrets: -- kmsKeyName: projects/learnjs-174218/locations/global/keyRings/tfjs/cryptoKeys/enc - secretEnv: - BROWSERSTACK_KEY: CiQAkwyoIW0LcnxymzotLwaH4udVTQFBEN4AEA5CA+a3+yflL2ASPQAD8BdZnGARf78MhH5T9rQqyz9HNODwVjVIj64CTkFlUCGrP1B2HX9LXHWHLmtKutEGTeFFX9XhuBzNExA= -timeout: 1800s -logsBucket: 'gs://tfjs-build-logs' -substitutions: - _NIGHTLY: '' -options: - logStreamingOption: 'STREAM_ON' - substitution_option: 'ALLOW_LOOSE' - machineType: 'N1_HIGHCPU_8' diff --git a/tfjs-master/tfjs-automl/code_snippets/img_classification.html b/tfjs-master/tfjs-automl/code_snippets/img_classification.html deleted file mode 100644 index d52041da7..000000000 --- a/tfjs-master/tfjs-automl/code_snippets/img_classification.html +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - diff --git a/tfjs-master/tfjs-automl/code_snippets/object_detection.html b/tfjs-master/tfjs-automl/code_snippets/object_detection.html deleted file mode 100644 index e6a8e7723..000000000 --- a/tfjs-master/tfjs-automl/code_snippets/object_detection.html +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - diff --git a/tfjs-master/tfjs-automl/demo/img_classification/index.html b/tfjs-master/tfjs-automl/demo/img_classification/index.html deleted file mode 100644 index 3ddb8864e..000000000 --- a/tfjs-master/tfjs-automl/demo/img_classification/index.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - AutoML Image classification demo - - - - - - - diff --git a/tfjs-master/tfjs-automl/demo/img_classification/index.js b/tfjs-master/tfjs-automl/demo/img_classification/index.js deleted file mode 100644 index bea8f1b65..000000000 --- a/tfjs-master/tfjs-automl/demo/img_classification/index.js +++ /dev/null @@ -1,35 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import '@tensorflow/tfjs-backend-webgl'; -import * as automl from '@tensorflow/tfjs-automl'; - -const MODEL_URL = - 'https://storage.googleapis.com/tfjs-testing/tfjs-automl/img_classification/model.json'; - -async function run() { - const model = await automl.loadImageClassification(MODEL_URL); - const image = document.getElementById('daisy'); - const predictions = await model.classify(image); - - // Show the resulting object on the page. - const pre = document.createElement('pre'); - pre.textContent = JSON.stringify(predictions, null, 2); - document.body.append(pre); -} - -run(); diff --git a/tfjs-master/tfjs-automl/demo/img_classification/package.json b/tfjs-master/tfjs-automl/demo/img_classification/package.json deleted file mode 100644 index 9f74d534c..000000000 --- a/tfjs-master/tfjs-automl/demo/img_classification/package.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "name": "automl-img-classification-demo", - "version": "0.0.1", - "private": true, - "description": "Image classification demo using the AutoML NPM library", - "main": "index.js", - "browserslist": "> 0.25%, not dead", - "scripts": { - "watch": "cross-env NODE_ENV=development parcel index.html --no-hmr --open ", - "build": "cross-env NODE_ENV=production parcel build index.html --public-url ./" - }, - "devDependencies": { - "babel-core": "^6.26.3", - "babel-plugin-transform-runtime": "~6.23.0", - "babel-polyfill": "~6.26.0", - "babel-preset-env": "~1.7.0", - "clang-format": "~1.8.0", - "cross-env": "^7.0.3", - "parcel": "~2.8.3", - "yalc": "~1.0.0-pre.27" - }, - "dependencies": { - "@tensorflow/tfjs-automl": "link:../../", - "@tensorflow/tfjs-backend-webgl": "^4.2.0", - "@tensorflow/tfjs-converter": "^4.2.0", - "@tensorflow/tfjs-core": "^4.2.0" - }, - "resolutions": { - "minimist": "1.2.6" - }, - "license": "Apache-2.0" -} diff --git a/tfjs-master/tfjs-automl/demo/img_classification/yarn.lock b/tfjs-master/tfjs-automl/demo/img_classification/yarn.lock deleted file mode 100644 index f74bb130c..000000000 --- a/tfjs-master/tfjs-automl/demo/img_classification/yarn.lock +++ /dev/null @@ -1,2626 +0,0 @@ -# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. -# yarn lockfile v1 - - -"@babel/code-frame@^7.0.0": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.16.7.tgz#44416b6bd7624b998f5b1af5d470856c40138789" - integrity sha512-iAXqUn8IIeBTNd72xsFlgaXHkMBMt6y4HJp1tIaK465CWLT/fG1aqB7ykr95gHHmlBdGbFeWWfyB4NJJ0nmeIg== - dependencies: - "@babel/highlight" "^7.16.7" - -"@babel/helper-validator-identifier@^7.16.7": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz#e8c602438c4a8195751243da9031d1607d247cad" - integrity sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw== - -"@babel/highlight@^7.16.7": - version "7.16.10" - resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.16.10.tgz#744f2eb81579d6eea753c227b0f570ad785aba88" - integrity sha512-5FnTQLSLswEj6IkgVw5KusNUUFY9ZGqe/TRFnP/BKYHYgfh7tc+C7mwiy95/yNP7Dh9x580Vv8r7u7ZfTBFxdw== - dependencies: - "@babel/helper-validator-identifier" "^7.16.7" - chalk "^2.0.0" - js-tokens "^4.0.0" - -"@lezer/common@^0.15.0", "@lezer/common@^0.15.7": - version "0.15.12" - resolved "https://registry.yarnpkg.com/@lezer/common/-/common-0.15.12.tgz#2f21aec551dd5fd7d24eb069f90f54d5bc6ee5e9" - integrity sha512-edfwCxNLnzq5pBA/yaIhwJ3U3Kz8VAUOTRg0hhxaizaI1N+qxV7EXDv/kLCkLeq2RzSFvxexlaj5Mzfn2kY0Ig== - -"@lezer/lr@^0.15.4": - version "0.15.8" - resolved "https://registry.yarnpkg.com/@lezer/lr/-/lr-0.15.8.tgz#1564a911e62b0a0f75ca63794a6aa8c5dc63db21" - integrity sha512-bM6oE6VQZ6hIFxDNKk8bKPa14hqFrV07J/vHGOeiAbJReIaQXmkVb6xQu4MR+JBTLa5arGRyAAjJe1qaQt3Uvg== - dependencies: - "@lezer/common" "^0.15.0" - -"@lmdb/lmdb-darwin-arm64@2.5.2": - version "2.5.2" - resolved "https://registry.yarnpkg.com/@lmdb/lmdb-darwin-arm64/-/lmdb-darwin-arm64-2.5.2.tgz#bc66fa43286b5c082e8fee0eacc17995806b6fbe" - integrity sha512-+F8ioQIUN68B4UFiIBYu0QQvgb9FmlKw2ctQMSBfW2QBrZIxz9vD9jCGqTCPqZBRbPHAS/vG1zSXnKqnS2ch/A== - -"@lmdb/lmdb-darwin-x64@2.5.2": - version "2.5.2" - resolved "https://registry.yarnpkg.com/@lmdb/lmdb-darwin-x64/-/lmdb-darwin-x64-2.5.2.tgz#89d8390041bce6bab24a82a20392be22faf54ffc" - integrity sha512-KvPH56KRLLx4KSfKBx0m1r7GGGUMXm0jrKmNE7plbHlesZMuPJICtn07HYgQhj1LNsK7Yqwuvnqh1QxhJnF1EA== - -"@lmdb/lmdb-linux-arm64@2.5.2": - version "2.5.2" - resolved "https://registry.yarnpkg.com/@lmdb/lmdb-linux-arm64/-/lmdb-linux-arm64-2.5.2.tgz#14fe4c96c2bb1285f93797f45915fa35ee047268" - integrity sha512-aLl89VHL/wjhievEOlPocoefUyWdvzVrcQ/MHQYZm2JfV1jUsrbr/ZfkPPUFvZBf+VSE+Q0clWs9l29PCX1hTQ== - -"@lmdb/lmdb-linux-arm@2.5.2": - version "2.5.2" - resolved "https://registry.yarnpkg.com/@lmdb/lmdb-linux-arm/-/lmdb-linux-arm-2.5.2.tgz#05bde4573ab10cf21827339fe687148f2590cfa1" - integrity sha512-5kQAP21hAkfW5Bl+e0P57dV4dGYnkNIpR7f/GAh6QHlgXx+vp/teVj4PGRZaKAvt0GX6++N6hF8NnGElLDuIDw== - -"@lmdb/lmdb-linux-x64@2.5.2": - version "2.5.2" - resolved "https://registry.yarnpkg.com/@lmdb/lmdb-linux-x64/-/lmdb-linux-x64-2.5.2.tgz#d2f85afd857d2c33d2caa5b057944574edafcfee" - integrity sha512-xUdUfwDJLGjOUPH3BuPBt0NlIrR7f/QHKgu3GZIXswMMIihAekj2i97oI0iWG5Bok/b+OBjHPfa8IU9velnP/Q== - -"@lmdb/lmdb-win32-x64@2.5.2": - version "2.5.2" - resolved "https://registry.yarnpkg.com/@lmdb/lmdb-win32-x64/-/lmdb-win32-x64-2.5.2.tgz#28f643fbc0bec30b07fbe95b137879b6b4d1c9c5" - integrity sha512-zrBczSbXKxEyK2ijtbRdICDygRqWSRPpZMN5dD1T8VMEW5RIhIbwFWw2phDRXuBQdVDpSjalCIUMWMV2h3JaZA== - -"@mischnic/json-sourcemap@^0.1.0": - version "0.1.0" - resolved "https://registry.yarnpkg.com/@mischnic/json-sourcemap/-/json-sourcemap-0.1.0.tgz#38af657be4108140a548638267d02a2ea3336507" - integrity sha512-dQb3QnfNqmQNYA4nFSN/uLaByIic58gOXq4Y4XqLOWmOrw73KmJPt/HLyG0wvn1bnR6mBKs/Uwvkh+Hns1T0XA== - dependencies: - "@lezer/common" "^0.15.7" - "@lezer/lr" "^0.15.4" - json5 "^2.2.1" - -"@parcel/bundler-default@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/bundler-default/-/bundler-default-2.8.3.tgz#d64739dbc2dbd59d6629861bf77a8083aced5229" - integrity sha512-yJvRsNWWu5fVydsWk3O2L4yIy3UZiKWO2cPDukGOIWMgp/Vbpp+2Ct5IygVRtE22bnseW/E/oe0PV3d2IkEJGg== - dependencies: - "@parcel/diagnostic" "2.8.3" - "@parcel/graph" "2.8.3" - "@parcel/hash" "2.8.3" - "@parcel/plugin" "2.8.3" - "@parcel/utils" "2.8.3" - nullthrows "^1.1.1" - -"@parcel/cache@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/cache/-/cache-2.8.3.tgz#169e130cf59913c0ed9fadce1a450e68f710e16f" - integrity sha512-k7xv5vSQrJLdXuglo+Hv3yF4BCSs1tQ/8Vbd6CHTkOhf7LcGg6CPtLw053R/KdMpd/4GPn0QrAsOLdATm1ELtQ== - dependencies: - "@parcel/fs" "2.8.3" - "@parcel/logger" "2.8.3" - "@parcel/utils" "2.8.3" - lmdb "2.5.2" - -"@parcel/codeframe@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/codeframe/-/codeframe-2.8.3.tgz#84fb529ef70def7f5bc64f6c59b18d24826f5fcc" - integrity sha512-FE7sY53D6n/+2Pgg6M9iuEC6F5fvmyBkRE4d9VdnOoxhTXtkEqpqYgX7RJ12FAQwNlxKq4suBJQMgQHMF2Kjeg== - dependencies: - chalk "^4.1.0" - -"@parcel/compressor-raw@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/compressor-raw/-/compressor-raw-2.8.3.tgz#301753df8c6de967553149639e8a4179b88f0c95" - integrity sha512-bVDsqleBUxRdKMakWSlWC9ZjOcqDKE60BE+Gh3JSN6WJrycJ02P5wxjTVF4CStNP/G7X17U+nkENxSlMG77ySg== - dependencies: - "@parcel/plugin" "2.8.3" - -"@parcel/config-default@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/config-default/-/config-default-2.8.3.tgz#9a43486e7c702e96c68052c37b79098d7240e35b" - integrity sha512-o/A/mbrO6X/BfGS65Sib8d6SSG45NYrNooNBkH/o7zbOBSRQxwyTlysleK1/3Wa35YpvFyLOwgfakqCtbGy4fw== - dependencies: - "@parcel/bundler-default" "2.8.3" - "@parcel/compressor-raw" "2.8.3" - "@parcel/namer-default" "2.8.3" - "@parcel/optimizer-css" "2.8.3" - "@parcel/optimizer-htmlnano" "2.8.3" - "@parcel/optimizer-image" "2.8.3" - "@parcel/optimizer-svgo" "2.8.3" - "@parcel/optimizer-terser" "2.8.3" - "@parcel/packager-css" "2.8.3" - "@parcel/packager-html" "2.8.3" - "@parcel/packager-js" "2.8.3" - "@parcel/packager-raw" "2.8.3" - "@parcel/packager-svg" "2.8.3" - "@parcel/reporter-dev-server" "2.8.3" - "@parcel/resolver-default" "2.8.3" - "@parcel/runtime-browser-hmr" "2.8.3" - "@parcel/runtime-js" "2.8.3" - "@parcel/runtime-react-refresh" "2.8.3" - "@parcel/runtime-service-worker" "2.8.3" - "@parcel/transformer-babel" "2.8.3" - "@parcel/transformer-css" "2.8.3" - "@parcel/transformer-html" "2.8.3" - "@parcel/transformer-image" "2.8.3" - "@parcel/transformer-js" "2.8.3" - "@parcel/transformer-json" "2.8.3" - "@parcel/transformer-postcss" "2.8.3" - "@parcel/transformer-posthtml" "2.8.3" - "@parcel/transformer-raw" "2.8.3" - "@parcel/transformer-react-refresh-wrap" "2.8.3" - "@parcel/transformer-svg" "2.8.3" - -"@parcel/core@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/core/-/core-2.8.3.tgz#22a69f36095d53736ab10bf42697d9aa5f4e382b" - integrity sha512-Euf/un4ZAiClnlUXqPB9phQlKbveU+2CotZv7m7i+qkgvFn5nAGnrV4h1OzQU42j9dpgOxWi7AttUDMrvkbhCQ== - dependencies: - "@mischnic/json-sourcemap" "^0.1.0" - "@parcel/cache" "2.8.3" - "@parcel/diagnostic" "2.8.3" - "@parcel/events" "2.8.3" - "@parcel/fs" "2.8.3" - "@parcel/graph" "2.8.3" - "@parcel/hash" "2.8.3" - "@parcel/logger" "2.8.3" - "@parcel/package-manager" "2.8.3" - "@parcel/plugin" "2.8.3" - "@parcel/source-map" "^2.1.1" - "@parcel/types" "2.8.3" - "@parcel/utils" "2.8.3" - "@parcel/workers" "2.8.3" - abortcontroller-polyfill "^1.1.9" - base-x "^3.0.8" - browserslist "^4.6.6" - clone "^2.1.1" - dotenv "^7.0.0" - dotenv-expand "^5.1.0" - json5 "^2.2.0" - msgpackr "^1.5.4" - nullthrows "^1.1.1" - semver "^5.7.1" - -"@parcel/diagnostic@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/diagnostic/-/diagnostic-2.8.3.tgz#d560276d5d2804b48beafa1feaf3fc6b2ac5e39d" - integrity sha512-u7wSzuMhLGWZjVNYJZq/SOViS3uFG0xwIcqXw12w54Uozd6BH8JlhVtVyAsq9kqnn7YFkw6pXHqAo5Tzh4FqsQ== - dependencies: - "@mischnic/json-sourcemap" "^0.1.0" - nullthrows "^1.1.1" - -"@parcel/events@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/events/-/events-2.8.3.tgz#205f8d874e6ecc2cbdb941bf8d54bae669e571af" - integrity sha512-hoIS4tAxWp8FJk3628bsgKxEvR7bq2scCVYHSqZ4fTi/s0+VymEATrRCUqf+12e5H47uw1/ZjoqrGtBI02pz4w== - -"@parcel/fs-search@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/fs-search/-/fs-search-2.8.3.tgz#1c7d812c110b808758f44c56e61dfffdb09e9451" - integrity sha512-DJBT2N8knfN7Na6PP2mett3spQLTqxFrvl0gv+TJRp61T8Ljc4VuUTb0hqBj+belaASIp3Q+e8+SgaFQu7wLiQ== - dependencies: - detect-libc "^1.0.3" - -"@parcel/fs@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/fs/-/fs-2.8.3.tgz#80536afe877fc8a2bd26be5576b9ba27bb4c5754" - integrity sha512-y+i+oXbT7lP0e0pJZi/YSm1vg0LDsbycFuHZIL80pNwdEppUAtibfJZCp606B7HOjMAlNZOBo48e3hPG3d8jgQ== - dependencies: - "@parcel/fs-search" "2.8.3" - "@parcel/types" "2.8.3" - "@parcel/utils" "2.8.3" - "@parcel/watcher" "^2.0.7" - "@parcel/workers" "2.8.3" - -"@parcel/graph@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/graph/-/graph-2.8.3.tgz#00ffe8ec032e74fee57199e54529f1da7322571d" - integrity sha512-26GL8fYZPdsRhSXCZ0ZWliloK6DHlMJPWh6Z+3VVZ5mnDSbYg/rRKWmrkhnr99ZWmL9rJsv4G74ZwvDEXTMPBg== - dependencies: - nullthrows "^1.1.1" - -"@parcel/hash@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/hash/-/hash-2.8.3.tgz#bc2499a27395169616cad2a99e19e69b9098f6e9" - integrity sha512-FVItqzjWmnyP4ZsVgX+G00+6U2IzOvqDtdwQIWisCcVoXJFCqZJDy6oa2qDDFz96xCCCynjRjPdQx2jYBCpfYw== - dependencies: - detect-libc "^1.0.3" - xxhash-wasm "^0.4.2" - -"@parcel/logger@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/logger/-/logger-2.8.3.tgz#e14e4debafb3ca9e87c07c06780f9afc38b2712c" - integrity sha512-Kpxd3O/Vs7nYJIzkdmB6Bvp3l/85ydIxaZaPfGSGTYOfaffSOTkhcW9l6WemsxUrlts4za6CaEWcc4DOvaMOPA== - dependencies: - "@parcel/diagnostic" "2.8.3" - "@parcel/events" "2.8.3" - -"@parcel/markdown-ansi@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/markdown-ansi/-/markdown-ansi-2.8.3.tgz#1337d421bb1133ad178f386a8e1b746631bba4a1" - integrity sha512-4v+pjyoh9f5zuU/gJlNvNFGEAb6J90sOBwpKJYJhdWXLZMNFCVzSigxrYO+vCsi8G4rl6/B2c0LcwIMjGPHmFQ== - dependencies: - chalk "^4.1.0" - -"@parcel/namer-default@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/namer-default/-/namer-default-2.8.3.tgz#5304bee74beb4b9c1880781bdbe35be0656372f4" - integrity sha512-tJ7JehZviS5QwnxbARd8Uh63rkikZdZs1QOyivUhEvhN+DddSAVEdQLHGPzkl3YRk0tjFhbqo+Jci7TpezuAMw== - dependencies: - "@parcel/diagnostic" "2.8.3" - "@parcel/plugin" "2.8.3" - nullthrows "^1.1.1" - -"@parcel/node-resolver-core@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/node-resolver-core/-/node-resolver-core-2.8.3.tgz#581df074a27646400b3fed9da95297b616a7db8f" - integrity sha512-12YryWcA5Iw2WNoEVr/t2HDjYR1iEzbjEcxfh1vaVDdZ020PiGw67g5hyIE/tsnG7SRJ0xdRx1fQ2hDgED+0Ww== - dependencies: - "@parcel/diagnostic" "2.8.3" - "@parcel/utils" "2.8.3" - nullthrows "^1.1.1" - semver "^5.7.1" - -"@parcel/optimizer-css@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/optimizer-css/-/optimizer-css-2.8.3.tgz#420a333f4b78f7ff15e69217dfed34421b1143ee" - integrity sha512-JotGAWo8JhuXsQDK0UkzeQB0UR5hDAKvAviXrjqB4KM9wZNLhLleeEAW4Hk8R9smCeQFP6Xg/N/NkLDpqMwT3g== - dependencies: - "@parcel/diagnostic" "2.8.3" - "@parcel/plugin" "2.8.3" - "@parcel/source-map" "^2.1.1" - "@parcel/utils" "2.8.3" - browserslist "^4.6.6" - lightningcss "^1.16.1" - nullthrows "^1.1.1" - -"@parcel/optimizer-htmlnano@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/optimizer-htmlnano/-/optimizer-htmlnano-2.8.3.tgz#a71ab6f0f24160ef9f573266064438eff65e96d0" - integrity sha512-L8/fHbEy8Id2a2E0fwR5eKGlv9VYDjrH9PwdJE9Za9v1O/vEsfl/0T/79/x129l5O0yB6EFQkFa20MiK3b+vOg== - dependencies: - "@parcel/plugin" "2.8.3" - htmlnano "^2.0.0" - nullthrows "^1.1.1" - posthtml "^0.16.5" - svgo "^2.4.0" - -"@parcel/optimizer-image@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/optimizer-image/-/optimizer-image-2.8.3.tgz#ea49b4245b4f7d60b38c7585c6311fb21d341baa" - integrity sha512-SD71sSH27SkCDNUNx9A3jizqB/WIJr3dsfp+JZGZC42tpD/Siim6Rqy9M4To/BpMMQIIiEXa5ofwS+DgTEiEHQ== - dependencies: - "@parcel/diagnostic" "2.8.3" - "@parcel/plugin" "2.8.3" - "@parcel/utils" "2.8.3" - "@parcel/workers" "2.8.3" - detect-libc "^1.0.3" - -"@parcel/optimizer-svgo@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/optimizer-svgo/-/optimizer-svgo-2.8.3.tgz#04da4efec6b623679539a84961bff6998034ba8a" - integrity sha512-9KQed99NZnQw3/W4qBYVQ7212rzA9EqrQG019TIWJzkA9tjGBMIm2c/nXpK1tc3hQ3e7KkXkFCQ3C+ibVUnHNA== - dependencies: - "@parcel/diagnostic" "2.8.3" - "@parcel/plugin" "2.8.3" - "@parcel/utils" "2.8.3" - svgo "^2.4.0" - -"@parcel/optimizer-terser@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/optimizer-terser/-/optimizer-terser-2.8.3.tgz#3a06d98d09386a1a0ae1be85376a8739bfba9618" - integrity sha512-9EeQlN6zIeUWwzrzu6Q2pQSaYsYGah8MtiQ/hog9KEPlYTP60hBv/+utDyYEHSQhL7y5ym08tPX5GzBvwAD/dA== - dependencies: - "@parcel/diagnostic" "2.8.3" - "@parcel/plugin" "2.8.3" - "@parcel/source-map" "^2.1.1" - "@parcel/utils" "2.8.3" - nullthrows "^1.1.1" - terser "^5.2.0" - -"@parcel/package-manager@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/package-manager/-/package-manager-2.8.3.tgz#ddd0d62feae3cf0fb6cc0537791b3a16296ad458" - integrity sha512-tIpY5pD2lH53p9hpi++GsODy6V3khSTX4pLEGuMpeSYbHthnOViobqIlFLsjni+QA1pfc8NNNIQwSNdGjYflVA== - dependencies: - "@parcel/diagnostic" "2.8.3" - "@parcel/fs" "2.8.3" - "@parcel/logger" "2.8.3" - "@parcel/types" "2.8.3" - "@parcel/utils" "2.8.3" - "@parcel/workers" "2.8.3" - semver "^5.7.1" - -"@parcel/packager-css@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/packager-css/-/packager-css-2.8.3.tgz#0eff34268cb4f5dfb53c1bbca85f5567aeb1835a" - integrity sha512-WyvkMmsurlHG8d8oUVm7S+D+cC/T3qGeqogb7sTI52gB6uiywU7lRCizLNqGFyFGIxcVTVHWnSHqItBcLN76lA== - dependencies: - "@parcel/plugin" "2.8.3" - "@parcel/source-map" "^2.1.1" - "@parcel/utils" "2.8.3" - nullthrows "^1.1.1" - -"@parcel/packager-html@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/packager-html/-/packager-html-2.8.3.tgz#f9263b891aa4dd46c6e2fa2b07025a482132fff1" - integrity sha512-OhPu1Hx1RRKJodpiu86ZqL8el2Aa4uhBHF6RAL1Pcrh2EhRRlPf70Sk0tC22zUpYL7es+iNKZ/n0Rl+OWSHWEw== - dependencies: - "@parcel/plugin" "2.8.3" - "@parcel/types" "2.8.3" - "@parcel/utils" "2.8.3" - nullthrows "^1.1.1" - posthtml "^0.16.5" - -"@parcel/packager-js@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/packager-js/-/packager-js-2.8.3.tgz#3ed11565915d73d12192b6901c75a6b820e4a83a" - integrity sha512-0pGKC3Ax5vFuxuZCRB+nBucRfFRz4ioie19BbDxYnvBxrd4M3FIu45njf6zbBYsI9eXqaDnL1b3DcZJfYqtIzw== - dependencies: - "@parcel/diagnostic" "2.8.3" - "@parcel/hash" "2.8.3" - "@parcel/plugin" "2.8.3" - "@parcel/source-map" "^2.1.1" - "@parcel/utils" "2.8.3" - globals "^13.2.0" - nullthrows "^1.1.1" - -"@parcel/packager-raw@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/packager-raw/-/packager-raw-2.8.3.tgz#bdec826df991e186cb58691cc45d12ad5c06676e" - integrity sha512-BA6enNQo1RCnco9MhkxGrjOk59O71IZ9DPKu3lCtqqYEVd823tXff2clDKHK25i6cChmeHu6oB1Rb73hlPqhUA== - dependencies: - "@parcel/plugin" "2.8.3" - -"@parcel/packager-svg@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/packager-svg/-/packager-svg-2.8.3.tgz#7233315296001c531cb55ca96b5f2ef672343630" - integrity sha512-mvIoHpmv5yzl36OjrklTDFShLUfPFTwrmp1eIwiszGdEBuQaX7JVI3Oo2jbVQgcN4W7J6SENzGQ3Q5hPTW3pMw== - dependencies: - "@parcel/plugin" "2.8.3" - "@parcel/types" "2.8.3" - "@parcel/utils" "2.8.3" - posthtml "^0.16.4" - -"@parcel/plugin@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/plugin/-/plugin-2.8.3.tgz#7bb30a5775eaa6473c27f002a0a3ee7308d6d669" - integrity sha512-jZ6mnsS4D9X9GaNnvrixDQwlUQJCohDX2hGyM0U0bY2NWU8Km97SjtoCpWjq+XBCx/gpC4g58+fk9VQeZq2vlw== - dependencies: - "@parcel/types" "2.8.3" - -"@parcel/reporter-cli@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/reporter-cli/-/reporter-cli-2.8.3.tgz#12a4743b51b8fe6837f53c20e01bbf1f7336e8e4" - integrity sha512-3sJkS6tFFzgIOz3u3IpD/RsmRxvOKKiQHOTkiiqRt1l44mMDGKS7zANRnJYsQzdCsgwc9SOP30XFgJwtoVlMbw== - dependencies: - "@parcel/plugin" "2.8.3" - "@parcel/types" "2.8.3" - "@parcel/utils" "2.8.3" - chalk "^4.1.0" - term-size "^2.2.1" - -"@parcel/reporter-dev-server@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/reporter-dev-server/-/reporter-dev-server-2.8.3.tgz#a0daa5cc015642684cea561f4e0e7116bbffdc1c" - integrity sha512-Y8C8hzgzTd13IoWTj+COYXEyCkXfmVJs3//GDBsH22pbtSFMuzAZd+8J9qsCo0EWpiDow7V9f1LischvEh3FbQ== - dependencies: - "@parcel/plugin" "2.8.3" - "@parcel/utils" "2.8.3" - -"@parcel/resolver-default@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/resolver-default/-/resolver-default-2.8.3.tgz#5ae41e537ae4a793c1abb47f094482b9e2ac3535" - integrity sha512-k0B5M/PJ+3rFbNj4xZSBr6d6HVIe6DH/P3dClLcgBYSXAvElNDfXgtIimbjCyItFkW9/BfcgOVKEEIZOeySH/A== - dependencies: - "@parcel/node-resolver-core" "2.8.3" - "@parcel/plugin" "2.8.3" - -"@parcel/runtime-browser-hmr@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/runtime-browser-hmr/-/runtime-browser-hmr-2.8.3.tgz#1fa74e1fbd1030b0a920c58afa3a9eb7dc4bcd1e" - integrity sha512-2O1PYi2j/Q0lTyGNV3JdBYwg4rKo6TEVFlYGdd5wCYU9ZIN9RRuoCnWWH2qCPj3pjIVtBeppYxzfVjPEHINWVg== - dependencies: - "@parcel/plugin" "2.8.3" - "@parcel/utils" "2.8.3" - -"@parcel/runtime-js@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/runtime-js/-/runtime-js-2.8.3.tgz#0baa4c8fbf77eabce05d01ccc186614968ffc0cd" - integrity sha512-IRja0vNKwvMtPgIqkBQh0QtRn0XcxNC8HU1jrgWGRckzu10qJWO+5ULgtOeR4pv9krffmMPqywGXw6l/gvJKYQ== - dependencies: - "@parcel/plugin" "2.8.3" - "@parcel/utils" "2.8.3" - nullthrows "^1.1.1" - -"@parcel/runtime-react-refresh@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/runtime-react-refresh/-/runtime-react-refresh-2.8.3.tgz#381a942fb81e8f5ac6c7e0ee1b91dbf34763c3f8" - integrity sha512-2v/qFKp00MfG0234OdOgQNAo6TLENpFYZMbVbAsPMY9ITiqG73MrEsrGXVoGbYiGTMB/Toer/lSWlJxtacOCuA== - dependencies: - "@parcel/plugin" "2.8.3" - "@parcel/utils" "2.8.3" - react-error-overlay "6.0.9" - react-refresh "^0.9.0" - -"@parcel/runtime-service-worker@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/runtime-service-worker/-/runtime-service-worker-2.8.3.tgz#54d92da9ff1dfbd27db0e84164a22fa59e99b348" - integrity sha512-/Skkw+EeRiwzOJso5fQtK8c9b452uWLNhQH1ISTodbmlcyB4YalAiSsyHCtMYD0c3/t5Sx4ZS7vxBAtQd0RvOw== - dependencies: - "@parcel/plugin" "2.8.3" - "@parcel/utils" "2.8.3" - nullthrows "^1.1.1" - -"@parcel/source-map@^2.1.1": - version "2.1.1" - resolved "https://registry.yarnpkg.com/@parcel/source-map/-/source-map-2.1.1.tgz#fb193b82dba6dd62cc7a76b326f57bb35000a782" - integrity sha512-Ejx1P/mj+kMjQb8/y5XxDUn4reGdr+WyKYloBljpppUy8gs42T+BNoEOuRYqDVdgPc6NxduzIDoJS9pOFfV5Ew== - dependencies: - detect-libc "^1.0.3" - -"@parcel/transformer-babel@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/transformer-babel/-/transformer-babel-2.8.3.tgz#286bc6cb9afe4c0259f0b28e0f2f47322a24b130" - integrity sha512-L6lExfpvvC7T/g3pxf3CIJRouQl+sgrSzuWQ0fD4PemUDHvHchSP4SNUVnd6gOytF3Y1KpnEZIunQGi5xVqQCQ== - dependencies: - "@parcel/diagnostic" "2.8.3" - "@parcel/plugin" "2.8.3" - "@parcel/source-map" "^2.1.1" - "@parcel/utils" "2.8.3" - browserslist "^4.6.6" - json5 "^2.2.0" - nullthrows "^1.1.1" - semver "^5.7.0" - -"@parcel/transformer-css@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/transformer-css/-/transformer-css-2.8.3.tgz#d6c44100204e73841ad8e0f90472172ea8b9120c" - integrity sha512-xTqFwlSXtnaYen9ivAgz+xPW7yRl/u4QxtnDyDpz5dr8gSeOpQYRcjkd4RsYzKsWzZcGtB5EofEk8ayUbWKEUg== - dependencies: - "@parcel/diagnostic" "2.8.3" - "@parcel/plugin" "2.8.3" - "@parcel/source-map" "^2.1.1" - "@parcel/utils" "2.8.3" - browserslist "^4.6.6" - lightningcss "^1.16.1" - nullthrows "^1.1.1" - -"@parcel/transformer-html@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/transformer-html/-/transformer-html-2.8.3.tgz#5c68b28ee6b8c7a13b8aee87f7957ad3227bd83f" - integrity sha512-kIZO3qsMYTbSnSpl9cnZog+SwL517ffWH54JeB410OSAYF1ouf4n5v9qBnALZbuCCmPwJRGs4jUtE452hxwN4g== - dependencies: - "@parcel/diagnostic" "2.8.3" - "@parcel/hash" "2.8.3" - "@parcel/plugin" "2.8.3" - nullthrows "^1.1.1" - posthtml "^0.16.5" - posthtml-parser "^0.10.1" - posthtml-render "^3.0.0" - semver "^5.7.1" - srcset "4" - -"@parcel/transformer-image@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/transformer-image/-/transformer-image-2.8.3.tgz#73805b2bfc3c8919d7737544e5f8be39e3f303fe" - integrity sha512-cO4uptcCGTi5H6bvTrAWEFUsTNhA4kCo8BSvRSCHA2sf/4C5tGQPHt3JhdO0GQLPwZRCh/R41EkJs5HZ8A8DAg== - dependencies: - "@parcel/plugin" "2.8.3" - "@parcel/utils" "2.8.3" - "@parcel/workers" "2.8.3" - nullthrows "^1.1.1" - -"@parcel/transformer-js@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/transformer-js/-/transformer-js-2.8.3.tgz#fe400df428394d1e7fe5afb6dea5c7c858e44f03" - integrity sha512-9Qd6bib+sWRcpovvzvxwy/PdFrLUXGfmSW9XcVVG8pvgXsZPFaNjnNT8stzGQj1pQiougCoxMY4aTM5p1lGHEQ== - dependencies: - "@parcel/diagnostic" "2.8.3" - "@parcel/plugin" "2.8.3" - "@parcel/source-map" "^2.1.1" - "@parcel/utils" "2.8.3" - "@parcel/workers" "2.8.3" - "@swc/helpers" "^0.4.12" - browserslist "^4.6.6" - detect-libc "^1.0.3" - nullthrows "^1.1.1" - regenerator-runtime "^0.13.7" - semver "^5.7.1" - -"@parcel/transformer-json@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/transformer-json/-/transformer-json-2.8.3.tgz#25deb3a5138cc70a83269fc5d39d564609354d36" - integrity sha512-B7LmVq5Q7bZO4ERb6NHtRuUKWGysEeaj9H4zelnyBv+wLgpo4f5FCxSE1/rTNmP9u1qHvQ3scGdK6EdSSokGPg== - dependencies: - "@parcel/plugin" "2.8.3" - json5 "^2.2.0" - -"@parcel/transformer-postcss@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/transformer-postcss/-/transformer-postcss-2.8.3.tgz#df4fdc1c90893823445f2a8eb8e2bdd0349ccc58" - integrity sha512-e8luB/poIlz6jBsD1Izms+6ElbyzuoFVa4lFVLZnTAChI3UxPdt9p/uTsIO46HyBps/Bk8ocvt3J4YF84jzmvg== - dependencies: - "@parcel/diagnostic" "2.8.3" - "@parcel/hash" "2.8.3" - "@parcel/plugin" "2.8.3" - "@parcel/utils" "2.8.3" - clone "^2.1.1" - nullthrows "^1.1.1" - postcss-value-parser "^4.2.0" - semver "^5.7.1" - -"@parcel/transformer-posthtml@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/transformer-posthtml/-/transformer-posthtml-2.8.3.tgz#7c3912a5a631cb26485f6464e0d6eeabb6f1e718" - integrity sha512-pkzf9Smyeaw4uaRLsT41RGrPLT5Aip8ZPcntawAfIo+KivBQUV0erY1IvHYjyfFzq1ld/Fo2Ith9He6mxpPifA== - dependencies: - "@parcel/plugin" "2.8.3" - "@parcel/utils" "2.8.3" - nullthrows "^1.1.1" - posthtml "^0.16.5" - posthtml-parser "^0.10.1" - posthtml-render "^3.0.0" - semver "^5.7.1" - -"@parcel/transformer-raw@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/transformer-raw/-/transformer-raw-2.8.3.tgz#3a22213fe18a5f83fd78889cb49f06e059cfead7" - integrity sha512-G+5cXnd2/1O3nV/pgRxVKZY/HcGSseuhAe71gQdSQftb8uJEURyUHoQ9Eh0JUD3MgWh9V+nIKoyFEZdf9T0sUQ== - dependencies: - "@parcel/plugin" "2.8.3" - -"@parcel/transformer-react-refresh-wrap@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/transformer-react-refresh-wrap/-/transformer-react-refresh-wrap-2.8.3.tgz#8b0392638405dd470a886002229f7889d5464822" - integrity sha512-q8AAoEvBnCf/nPvgOwFwKZfEl/thwq7c2duxXkhl+tTLDRN2vGmyz4355IxCkavSX+pLWSQ5MexklSEeMkgthg== - dependencies: - "@parcel/plugin" "2.8.3" - "@parcel/utils" "2.8.3" - react-refresh "^0.9.0" - -"@parcel/transformer-svg@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/transformer-svg/-/transformer-svg-2.8.3.tgz#4df959cba4ebf45d7aaddd540f752e6e84df38b2" - integrity sha512-3Zr/gBzxi1ZH1fftH/+KsZU7w5GqkmxlB0ZM8ovS5E/Pl1lq1t0xvGJue9m2VuQqP8Mxfpl5qLFmsKlhaZdMIQ== - dependencies: - "@parcel/diagnostic" "2.8.3" - "@parcel/hash" "2.8.3" - "@parcel/plugin" "2.8.3" - nullthrows "^1.1.1" - posthtml "^0.16.5" - posthtml-parser "^0.10.1" - posthtml-render "^3.0.0" - semver "^5.7.1" - -"@parcel/types@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/types/-/types-2.8.3.tgz#3306bc5391b6913bd619914894b8cd84a24b30fa" - integrity sha512-FECA1FB7+0UpITKU0D6TgGBpGxYpVSMNEENZbSJxFSajNy3wrko+zwBKQmFOLOiPcEtnGikxNs+jkFWbPlUAtw== - dependencies: - "@parcel/cache" "2.8.3" - "@parcel/diagnostic" "2.8.3" - "@parcel/fs" "2.8.3" - "@parcel/package-manager" "2.8.3" - "@parcel/source-map" "^2.1.1" - "@parcel/workers" "2.8.3" - utility-types "^3.10.0" - -"@parcel/utils@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/utils/-/utils-2.8.3.tgz#0d56c9e8e22c119590a5e044a0e01031965da40e" - integrity sha512-IhVrmNiJ+LOKHcCivG5dnuLGjhPYxQ/IzbnF2DKNQXWBTsYlHkJZpmz7THoeLtLliGmSOZ3ZCsbR8/tJJKmxjA== - dependencies: - "@parcel/codeframe" "2.8.3" - "@parcel/diagnostic" "2.8.3" - "@parcel/hash" "2.8.3" - "@parcel/logger" "2.8.3" - "@parcel/markdown-ansi" "2.8.3" - "@parcel/source-map" "^2.1.1" - chalk "^4.1.0" - -"@parcel/watcher@^2.0.7": - version "2.1.0" - resolved "https://registry.yarnpkg.com/@parcel/watcher/-/watcher-2.1.0.tgz#5f32969362db4893922c526a842d8af7a8538545" - integrity sha512-8s8yYjd19pDSsBpbkOHnT6Z2+UJSuLQx61pCFM0s5wSRvKCEMDjd/cHY3/GI1szHIWbpXpsJdg3V6ISGGx9xDw== - dependencies: - is-glob "^4.0.3" - micromatch "^4.0.5" - node-addon-api "^3.2.1" - node-gyp-build "^4.3.0" - -"@parcel/workers@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/workers/-/workers-2.8.3.tgz#255450ccf4db234082407e4ddda5fd575f08c235" - integrity sha512-+AxBnKgjqVpUHBcHLWIHcjYgKIvHIpZjN33mG5LG9XXvrZiqdWvouEzqEXlVLq5VzzVbKIQQcmsvRy138YErkg== - dependencies: - "@parcel/diagnostic" "2.8.3" - "@parcel/logger" "2.8.3" - "@parcel/types" "2.8.3" - "@parcel/utils" "2.8.3" - chrome-trace-event "^1.0.2" - nullthrows "^1.1.1" - -"@swc/helpers@^0.4.12": - version "0.4.14" - resolved "https://registry.yarnpkg.com/@swc/helpers/-/helpers-0.4.14.tgz#1352ac6d95e3617ccb7c1498ff019654f1e12a74" - integrity sha512-4C7nX/dvpzB7za4Ql9K81xK3HPxCpHMgwTZVyf+9JQ6VUbn9jjZVN7/Nkdz/Ugzs2CSjqnL/UPXroiVBVHUWUw== - dependencies: - tslib "^2.4.0" - -"@tensorflow/tfjs-automl@link:../..": - version "0.0.0" - uid "" - -"@tensorflow/tfjs-backend-cpu@4.2.0": - version "4.2.0" - resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-backend-cpu/-/tfjs-backend-cpu-4.2.0.tgz#24912f8ef20b04ca4056365d83e5cc5a1671581f" - integrity sha512-8HWg9J69m0Ovc6w8TVhhixMOcwA3t/NPXLblOA/sgJ+/JD5gsbpLWJk4QISQyb1RnpSVzw6PX3BSMTJU7hWVOg== - dependencies: - "@types/seedrandom" "^2.4.28" - seedrandom "^3.0.5" - -"@tensorflow/tfjs-backend-webgl@^4.2.0": - version "4.2.0" - resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-backend-webgl/-/tfjs-backend-webgl-4.2.0.tgz#684368f9a2605511d6d6753bf6fe9a08c73f6791" - integrity sha512-Qvf+hD5pSh+xi48kChSGzcDKJemkc4EKfoVVjuxl4k25ZUPwuEd7zZUAtinkLu1dzgHNyvePZY8k+9rVm59HJA== - dependencies: - "@tensorflow/tfjs-backend-cpu" "4.2.0" - "@types/offscreencanvas" "~2019.3.0" - "@types/seedrandom" "^2.4.28" - "@types/webgl-ext" "0.0.30" - seedrandom "^3.0.5" - -"@tensorflow/tfjs-converter@^4.2.0": - version "4.2.0" - resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-converter/-/tfjs-converter-4.2.0.tgz#3a51d446dc0d6194f31407345891966e0a77937f" - integrity sha512-m+E2KJM6yGQdi8ElzWpChdD/JaqhWMCi9yK70v/ndkOaCL2q2UN48nYP2T5S15vkDvMIgzAQyZfh7hxQsMuvRQ== - -"@tensorflow/tfjs-core@^4.2.0": - version "4.2.0" - resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-core/-/tfjs-core-4.2.0.tgz#34dc455c0a00feac12015caec34a54414a404230" - integrity sha512-uuHkiWVC8b00ngFbHvAV7J7haRlN/9PEdeenCi0CzBjgKd7aN25wPWaoN0TSQcU+GT4FJ8mofMZ9VBYZ/s/WLg== - dependencies: - "@types/long" "^4.0.1" - "@types/offscreencanvas" "~2019.7.0" - "@types/seedrandom" "^2.4.28" - "@types/webgl-ext" "0.0.30" - "@webgpu/types" "0.1.21" - long "4.0.0" - node-fetch "~2.6.1" - seedrandom "^3.0.5" - -"@trysound/sax@0.2.0": - version "0.2.0" - resolved "https://registry.yarnpkg.com/@trysound/sax/-/sax-0.2.0.tgz#cccaab758af56761eb7bf37af6f03f326dd798ad" - integrity sha512-L7z9BgrNEcYyUYtF+HaEfiS5ebkh9jXqbszz7pC0hRBPaatV0XjSD3+eHrpqFemQfgwiFF0QPIarnIihIDn7OA== - -"@types/long@^4.0.1": - version "4.0.1" - resolved "https://registry.yarnpkg.com/@types/long/-/long-4.0.1.tgz#459c65fa1867dafe6a8f322c4c51695663cc55e9" - integrity sha512-5tXH6Bx/kNGd3MgffdmP4dy2Z+G4eaXw0SE81Tq3BNadtnMR5/ySMzX4SLEzHJzSmPNn4HIdpQsBvXMUykr58w== - -"@types/offscreencanvas@~2019.3.0": - version "2019.3.0" - resolved "https://registry.yarnpkg.com/@types/offscreencanvas/-/offscreencanvas-2019.3.0.tgz#3336428ec7e9180cf4566dfea5da04eb586a6553" - integrity sha512-esIJx9bQg+QYF0ra8GnvfianIY8qWB0GBx54PK5Eps6m+xTj86KLavHv6qDhzKcu5UUOgNfJ2pWaIIV7TRUd9Q== - -"@types/offscreencanvas@~2019.7.0": - version "2019.7.0" - resolved "https://registry.yarnpkg.com/@types/offscreencanvas/-/offscreencanvas-2019.7.0.tgz#e4a932069db47bb3eabeb0b305502d01586fa90d" - integrity sha512-PGcyveRIpL1XIqK8eBsmRBt76eFgtzuPiSTyKHZxnGemp2yzGzWpjYKAfK3wIMiU7eH+851yEpiuP8JZerTmWg== - -"@types/parse-json@^4.0.0": - version "4.0.0" - resolved "https://registry.yarnpkg.com/@types/parse-json/-/parse-json-4.0.0.tgz#2f8bb441434d163b35fb8ffdccd7138927ffb8c0" - integrity sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA== - -"@types/seedrandom@^2.4.28": - version "2.4.30" - resolved "https://registry.yarnpkg.com/@types/seedrandom/-/seedrandom-2.4.30.tgz#d2efe425869b84163c2d56e779dddadb9372cbfa" - integrity sha512-AnxLHewubLVzoF/A4qdxBGHCKifw8cY32iro3DQX9TPcetE95zBeVt3jnsvtvAUf1vwzMfwzp4t/L2yqPlnjkQ== - -"@types/webgl-ext@0.0.30": - version "0.0.30" - resolved "https://registry.yarnpkg.com/@types/webgl-ext/-/webgl-ext-0.0.30.tgz#0ce498c16a41a23d15289e0b844d945b25f0fb9d" - integrity sha512-LKVgNmBxN0BbljJrVUwkxwRYqzsAEPcZOe6S2T6ZaBDIrFp0qu4FNlpc5sM1tGbXUYFgdVQIoeLk1Y1UoblyEg== - -"@webgpu/types@0.1.21": - version "0.1.21" - resolved "https://registry.yarnpkg.com/@webgpu/types/-/types-0.1.21.tgz#b181202daec30d66ccd67264de23814cfd176d3a" - integrity sha512-pUrWq3V5PiSGFLeLxoGqReTZmiiXwY3jRkIG5sLLKjyqNxrwm/04b4nw7LSmGWJcKk59XOM/YRTUwOzo4MMlow== - -abortcontroller-polyfill@^1.1.9: - version "1.7.3" - resolved "https://registry.yarnpkg.com/abortcontroller-polyfill/-/abortcontroller-polyfill-1.7.3.tgz#1b5b487bd6436b5b764fd52a612509702c3144b5" - integrity sha512-zetDJxd89y3X99Kvo4qFx8GKlt6GsvN3UcRZHwU6iFA/0KiOmhkTVhe8oRoTBiTVPZu09x3vCra47+w8Yz1+2Q== - -acorn@^8.5.0: - version "8.7.0" - resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.7.0.tgz#90951fde0f8f09df93549481e5fc141445b791cf" - integrity sha512-V/LGr1APy+PXIwKebEWrkZPwoeoF+w1jiOBUmuxuiUIaOHtob8Qc9BTrYo7VuI5fR8tqsy+buA2WFooR5olqvQ== - -ansi-regex@^2.0.0: - version "2.1.1" - resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-2.1.1.tgz#c3b33ab5ee360d86e0e628f0468ae7ef27d654df" - integrity sha1-w7M6te42DYbg5ijwRorn7yfWVN8= - -ansi-regex@^5.0.1: - version "5.0.1" - resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.1.tgz#082cb2c89c9fe8659a311a53bd6a4dc5301db304" - integrity sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ== - -ansi-styles@^2.2.1: - version "2.2.1" - resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-2.2.1.tgz#b432dd3358b634cf75e1e4664368240533c1ddbe" - integrity sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4= - -ansi-styles@^3.2.1: - version "3.2.1" - resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d" - integrity sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA== - dependencies: - color-convert "^1.9.0" - -ansi-styles@^4.0.0, ansi-styles@^4.1.0: - version "4.3.0" - resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-4.3.0.tgz#edd803628ae71c04c85ae7a0906edad34b648937" - integrity sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg== - dependencies: - color-convert "^2.0.1" - -async@^3.2.3: - version "3.2.4" - resolved "https://registry.yarnpkg.com/async/-/async-3.2.4.tgz#2d22e00f8cddeb5fde5dd33522b56d1cf569a81c" - integrity sha512-iAB+JbDEGXhyIUavoDl9WP/Jj106Kz9DEn1DPgYw5ruDn0e3Wgi3sKFm55sASdGBNOQB8F59d9qQ7deqrHA8wQ== - -babel-code-frame@^6.26.0: - version "6.26.0" - resolved "https://registry.yarnpkg.com/babel-code-frame/-/babel-code-frame-6.26.0.tgz#63fd43f7dc1e3bb7ce35947db8fe369a3f58c74b" - integrity sha1-Y/1D99weO7fONZR9uP42mj9Yx0s= - dependencies: - chalk "^1.1.3" - esutils "^2.0.2" - js-tokens "^3.0.2" - -babel-core@^6.26.0, babel-core@^6.26.3: - version "6.26.3" - resolved "https://registry.yarnpkg.com/babel-core/-/babel-core-6.26.3.tgz#b2e2f09e342d0f0c88e2f02e067794125e75c207" - integrity sha512-6jyFLuDmeidKmUEb3NM+/yawG0M2bDZ9Z1qbZP59cyHLz8kYGKYwpJP0UwUKKUiTRNvxfLesJnTedqczP7cTDA== - dependencies: - babel-code-frame "^6.26.0" - babel-generator "^6.26.0" - babel-helpers "^6.24.1" - babel-messages "^6.23.0" - babel-register "^6.26.0" - babel-runtime "^6.26.0" - babel-template "^6.26.0" - babel-traverse "^6.26.0" - babel-types "^6.26.0" - babylon "^6.18.0" - convert-source-map "^1.5.1" - debug "^2.6.9" - json5 "^0.5.1" - lodash "^4.17.4" - minimatch "^3.0.4" - path-is-absolute "^1.0.1" - private "^0.1.8" - slash "^1.0.0" - source-map "^0.5.7" - -babel-generator@^6.26.0: - version "6.26.1" - resolved "https://registry.yarnpkg.com/babel-generator/-/babel-generator-6.26.1.tgz#1844408d3b8f0d35a404ea7ac180f087a601bd90" - integrity sha512-HyfwY6ApZj7BYTcJURpM5tznulaBvyio7/0d4zFOeMPUmfxkCjHocCuoLa2SAGzBI8AREcH3eP3758F672DppA== - dependencies: - babel-messages "^6.23.0" - babel-runtime "^6.26.0" - babel-types "^6.26.0" - detect-indent "^4.0.0" - jsesc "^1.3.0" - lodash "^4.17.4" - source-map "^0.5.7" - trim-right "^1.0.1" - -babel-helper-builder-binary-assignment-operator-visitor@^6.24.1: - version "6.24.1" - resolved "https://registry.yarnpkg.com/babel-helper-builder-binary-assignment-operator-visitor/-/babel-helper-builder-binary-assignment-operator-visitor-6.24.1.tgz#cce4517ada356f4220bcae8a02c2b346f9a56664" - integrity sha1-zORReto1b0IgvK6KAsKzRvmlZmQ= - dependencies: - babel-helper-explode-assignable-expression "^6.24.1" - babel-runtime "^6.22.0" - babel-types "^6.24.1" - -babel-helper-call-delegate@^6.24.1: - version "6.24.1" - resolved "https://registry.yarnpkg.com/babel-helper-call-delegate/-/babel-helper-call-delegate-6.24.1.tgz#ece6aacddc76e41c3461f88bfc575bd0daa2df8d" - integrity sha1-7Oaqzdx25Bw0YfiL/Fdb0Nqi340= - dependencies: - babel-helper-hoist-variables "^6.24.1" - babel-runtime "^6.22.0" - babel-traverse "^6.24.1" - babel-types "^6.24.1" - -babel-helper-define-map@^6.24.1: - version "6.26.0" - resolved "https://registry.yarnpkg.com/babel-helper-define-map/-/babel-helper-define-map-6.26.0.tgz#a5f56dab41a25f97ecb498c7ebaca9819f95be5f" - integrity sha1-pfVtq0GiX5fstJjH66ypgZ+Vvl8= - dependencies: - babel-helper-function-name "^6.24.1" - babel-runtime "^6.26.0" - babel-types "^6.26.0" - lodash "^4.17.4" - -babel-helper-explode-assignable-expression@^6.24.1: - version "6.24.1" - resolved "https://registry.yarnpkg.com/babel-helper-explode-assignable-expression/-/babel-helper-explode-assignable-expression-6.24.1.tgz#f25b82cf7dc10433c55f70592d5746400ac22caa" - integrity sha1-8luCz33BBDPFX3BZLVdGQArCLKo= - dependencies: - babel-runtime "^6.22.0" - babel-traverse "^6.24.1" - babel-types "^6.24.1" - -babel-helper-function-name@^6.24.1: - version "6.24.1" - resolved "https://registry.yarnpkg.com/babel-helper-function-name/-/babel-helper-function-name-6.24.1.tgz#d3475b8c03ed98242a25b48351ab18399d3580a9" - integrity sha1-00dbjAPtmCQqJbSDUasYOZ01gKk= - dependencies: - babel-helper-get-function-arity "^6.24.1" - babel-runtime "^6.22.0" - babel-template "^6.24.1" - babel-traverse "^6.24.1" - babel-types "^6.24.1" - -babel-helper-get-function-arity@^6.24.1: - version "6.24.1" - resolved "https://registry.yarnpkg.com/babel-helper-get-function-arity/-/babel-helper-get-function-arity-6.24.1.tgz#8f7782aa93407c41d3aa50908f89b031b1b6853d" - integrity sha1-j3eCqpNAfEHTqlCQj4mwMbG2hT0= - dependencies: - babel-runtime "^6.22.0" - babel-types "^6.24.1" - -babel-helper-hoist-variables@^6.24.1: - version "6.24.1" - resolved "https://registry.yarnpkg.com/babel-helper-hoist-variables/-/babel-helper-hoist-variables-6.24.1.tgz#1ecb27689c9d25513eadbc9914a73f5408be7a76" - integrity sha1-HssnaJydJVE+rbyZFKc/VAi+enY= - dependencies: - babel-runtime "^6.22.0" - babel-types "^6.24.1" - -babel-helper-optimise-call-expression@^6.24.1: - version "6.24.1" - resolved "https://registry.yarnpkg.com/babel-helper-optimise-call-expression/-/babel-helper-optimise-call-expression-6.24.1.tgz#f7a13427ba9f73f8f4fa993c54a97882d1244257" - integrity sha1-96E0J7qfc/j0+pk8VKl4gtEkQlc= - dependencies: - babel-runtime "^6.22.0" - babel-types "^6.24.1" - -babel-helper-regex@^6.24.1: - version "6.26.0" - resolved "https://registry.yarnpkg.com/babel-helper-regex/-/babel-helper-regex-6.26.0.tgz#325c59f902f82f24b74faceed0363954f6495e72" - integrity sha1-MlxZ+QL4LyS3T6zu0DY5VPZJXnI= - dependencies: - babel-runtime "^6.26.0" - babel-types "^6.26.0" - lodash "^4.17.4" - -babel-helper-remap-async-to-generator@^6.24.1: - version "6.24.1" - resolved "https://registry.yarnpkg.com/babel-helper-remap-async-to-generator/-/babel-helper-remap-async-to-generator-6.24.1.tgz#5ec581827ad723fecdd381f1c928390676e4551b" - integrity sha1-XsWBgnrXI/7N04HxySg5BnbkVRs= - dependencies: - babel-helper-function-name "^6.24.1" - babel-runtime "^6.22.0" - babel-template "^6.24.1" - babel-traverse "^6.24.1" - babel-types "^6.24.1" - -babel-helper-replace-supers@^6.24.1: - version "6.24.1" - resolved "https://registry.yarnpkg.com/babel-helper-replace-supers/-/babel-helper-replace-supers-6.24.1.tgz#bf6dbfe43938d17369a213ca8a8bf74b6a90ab1a" - integrity sha1-v22/5Dk40XNpohPKiov3S2qQqxo= - dependencies: - babel-helper-optimise-call-expression "^6.24.1" - babel-messages "^6.23.0" - babel-runtime "^6.22.0" - babel-template "^6.24.1" - babel-traverse "^6.24.1" - babel-types "^6.24.1" - -babel-helpers@^6.24.1: - version "6.24.1" - resolved "https://registry.yarnpkg.com/babel-helpers/-/babel-helpers-6.24.1.tgz#3471de9caec388e5c850e597e58a26ddf37602b2" - integrity sha1-NHHenK7DiOXIUOWX5Yom3fN2ArI= - dependencies: - babel-runtime "^6.22.0" - babel-template "^6.24.1" - -babel-messages@^6.23.0: - version "6.23.0" - resolved "https://registry.yarnpkg.com/babel-messages/-/babel-messages-6.23.0.tgz#f3cdf4703858035b2a2951c6ec5edf6c62f2630e" - integrity sha1-8830cDhYA1sqKVHG7F7fbGLyYw4= - dependencies: - babel-runtime "^6.22.0" - -babel-plugin-check-es2015-constants@^6.22.0: - version "6.22.0" - resolved "https://registry.yarnpkg.com/babel-plugin-check-es2015-constants/-/babel-plugin-check-es2015-constants-6.22.0.tgz#35157b101426fd2ffd3da3f75c7d1e91835bbf8a" - integrity sha1-NRV7EBQm/S/9PaP3XH0ekYNbv4o= - dependencies: - babel-runtime "^6.22.0" - -babel-plugin-syntax-async-functions@^6.8.0: - version "6.13.0" - resolved "https://registry.yarnpkg.com/babel-plugin-syntax-async-functions/-/babel-plugin-syntax-async-functions-6.13.0.tgz#cad9cad1191b5ad634bf30ae0872391e0647be95" - integrity sha1-ytnK0RkbWtY0vzCuCHI5HgZHvpU= - -babel-plugin-syntax-exponentiation-operator@^6.8.0: - version "6.13.0" - resolved "https://registry.yarnpkg.com/babel-plugin-syntax-exponentiation-operator/-/babel-plugin-syntax-exponentiation-operator-6.13.0.tgz#9ee7e8337290da95288201a6a57f4170317830de" - integrity sha1-nufoM3KQ2pUoggGmpX9BcDF4MN4= - -babel-plugin-syntax-trailing-function-commas@^6.22.0: - version "6.22.0" - resolved "https://registry.yarnpkg.com/babel-plugin-syntax-trailing-function-commas/-/babel-plugin-syntax-trailing-function-commas-6.22.0.tgz#ba0360937f8d06e40180a43fe0d5616fff532cf3" - integrity sha1-ugNgk3+NBuQBgKQ/4NVhb/9TLPM= - -babel-plugin-transform-async-to-generator@^6.22.0: - version "6.24.1" - resolved "https://registry.yarnpkg.com/babel-plugin-transform-async-to-generator/-/babel-plugin-transform-async-to-generator-6.24.1.tgz#6536e378aff6cb1d5517ac0e40eb3e9fc8d08761" - integrity sha1-ZTbjeK/2yx1VF6wOQOs+n8jQh2E= - dependencies: - babel-helper-remap-async-to-generator "^6.24.1" - babel-plugin-syntax-async-functions "^6.8.0" - babel-runtime "^6.22.0" - -babel-plugin-transform-es2015-arrow-functions@^6.22.0: - version "6.22.0" - resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-arrow-functions/-/babel-plugin-transform-es2015-arrow-functions-6.22.0.tgz#452692cb711d5f79dc7f85e440ce41b9f244d221" - integrity sha1-RSaSy3EdX3ncf4XkQM5BufJE0iE= - dependencies: - babel-runtime "^6.22.0" - -babel-plugin-transform-es2015-block-scoped-functions@^6.22.0: - version "6.22.0" - resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-block-scoped-functions/-/babel-plugin-transform-es2015-block-scoped-functions-6.22.0.tgz#bbc51b49f964d70cb8d8e0b94e820246ce3a6141" - integrity sha1-u8UbSflk1wy42OC5ToICRs46YUE= - dependencies: - babel-runtime "^6.22.0" - -babel-plugin-transform-es2015-block-scoping@^6.23.0: - version "6.26.0" - resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-block-scoping/-/babel-plugin-transform-es2015-block-scoping-6.26.0.tgz#d70f5299c1308d05c12f463813b0a09e73b1895f" - integrity sha1-1w9SmcEwjQXBL0Y4E7CgnnOxiV8= - dependencies: - babel-runtime "^6.26.0" - babel-template "^6.26.0" - babel-traverse "^6.26.0" - babel-types "^6.26.0" - lodash "^4.17.4" - -babel-plugin-transform-es2015-classes@^6.23.0: - version "6.24.1" - resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-classes/-/babel-plugin-transform-es2015-classes-6.24.1.tgz#5a4c58a50c9c9461e564b4b2a3bfabc97a2584db" - integrity sha1-WkxYpQyclGHlZLSyo7+ryXolhNs= - dependencies: - babel-helper-define-map "^6.24.1" - babel-helper-function-name "^6.24.1" - babel-helper-optimise-call-expression "^6.24.1" - babel-helper-replace-supers "^6.24.1" - babel-messages "^6.23.0" - babel-runtime "^6.22.0" - babel-template "^6.24.1" - babel-traverse "^6.24.1" - babel-types "^6.24.1" - -babel-plugin-transform-es2015-computed-properties@^6.22.0: - version "6.24.1" - resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-computed-properties/-/babel-plugin-transform-es2015-computed-properties-6.24.1.tgz#6fe2a8d16895d5634f4cd999b6d3480a308159b3" - integrity sha1-b+Ko0WiV1WNPTNmZttNICjCBWbM= - dependencies: - babel-runtime "^6.22.0" - babel-template "^6.24.1" - -babel-plugin-transform-es2015-destructuring@^6.23.0: - version "6.23.0" - resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-destructuring/-/babel-plugin-transform-es2015-destructuring-6.23.0.tgz#997bb1f1ab967f682d2b0876fe358d60e765c56d" - integrity sha1-mXux8auWf2gtKwh2/jWNYOdlxW0= - dependencies: - babel-runtime "^6.22.0" - -babel-plugin-transform-es2015-duplicate-keys@^6.22.0: - version "6.24.1" - resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-duplicate-keys/-/babel-plugin-transform-es2015-duplicate-keys-6.24.1.tgz#73eb3d310ca969e3ef9ec91c53741a6f1576423e" - integrity sha1-c+s9MQypaePvnskcU3QabxV2Qj4= - dependencies: - babel-runtime "^6.22.0" - babel-types "^6.24.1" - -babel-plugin-transform-es2015-for-of@^6.23.0: - version "6.23.0" - resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-for-of/-/babel-plugin-transform-es2015-for-of-6.23.0.tgz#f47c95b2b613df1d3ecc2fdb7573623c75248691" - integrity sha1-9HyVsrYT3x0+zC/bdXNiPHUkhpE= - dependencies: - babel-runtime "^6.22.0" - -babel-plugin-transform-es2015-function-name@^6.22.0: - version "6.24.1" - resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-function-name/-/babel-plugin-transform-es2015-function-name-6.24.1.tgz#834c89853bc36b1af0f3a4c5dbaa94fd8eacaa8b" - integrity sha1-g0yJhTvDaxrw86TF26qU/Y6sqos= - dependencies: - babel-helper-function-name "^6.24.1" - babel-runtime "^6.22.0" - babel-types "^6.24.1" - -babel-plugin-transform-es2015-literals@^6.22.0: - version "6.22.0" - resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-literals/-/babel-plugin-transform-es2015-literals-6.22.0.tgz#4f54a02d6cd66cf915280019a31d31925377ca2e" - integrity sha1-T1SgLWzWbPkVKAAZox0xklN3yi4= - dependencies: - babel-runtime "^6.22.0" - -babel-plugin-transform-es2015-modules-amd@^6.22.0, babel-plugin-transform-es2015-modules-amd@^6.24.1: - version "6.24.1" - resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-modules-amd/-/babel-plugin-transform-es2015-modules-amd-6.24.1.tgz#3b3e54017239842d6d19c3011c4bd2f00a00d154" - integrity sha1-Oz5UAXI5hC1tGcMBHEvS8AoA0VQ= - dependencies: - babel-plugin-transform-es2015-modules-commonjs "^6.24.1" - babel-runtime "^6.22.0" - babel-template "^6.24.1" - -babel-plugin-transform-es2015-modules-commonjs@^6.23.0, babel-plugin-transform-es2015-modules-commonjs@^6.24.1: - version "6.26.2" - resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-modules-commonjs/-/babel-plugin-transform-es2015-modules-commonjs-6.26.2.tgz#58a793863a9e7ca870bdc5a881117ffac27db6f3" - integrity sha512-CV9ROOHEdrjcwhIaJNBGMBCodN+1cfkwtM1SbUHmvyy35KGT7fohbpOxkE2uLz1o6odKK2Ck/tz47z+VqQfi9Q== - dependencies: - babel-plugin-transform-strict-mode "^6.24.1" - babel-runtime "^6.26.0" - babel-template "^6.26.0" - babel-types "^6.26.0" - -babel-plugin-transform-es2015-modules-systemjs@^6.23.0: - version "6.24.1" - resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-modules-systemjs/-/babel-plugin-transform-es2015-modules-systemjs-6.24.1.tgz#ff89a142b9119a906195f5f106ecf305d9407d23" - integrity sha1-/4mhQrkRmpBhlfXxBuzzBdlAfSM= - dependencies: - babel-helper-hoist-variables "^6.24.1" - babel-runtime "^6.22.0" - babel-template "^6.24.1" - -babel-plugin-transform-es2015-modules-umd@^6.23.0: - version "6.24.1" - resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-modules-umd/-/babel-plugin-transform-es2015-modules-umd-6.24.1.tgz#ac997e6285cd18ed6176adb607d602344ad38468" - integrity sha1-rJl+YoXNGO1hdq22B9YCNErThGg= - dependencies: - babel-plugin-transform-es2015-modules-amd "^6.24.1" - babel-runtime "^6.22.0" - babel-template "^6.24.1" - -babel-plugin-transform-es2015-object-super@^6.22.0: - version "6.24.1" - resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-object-super/-/babel-plugin-transform-es2015-object-super-6.24.1.tgz#24cef69ae21cb83a7f8603dad021f572eb278f8d" - integrity sha1-JM72muIcuDp/hgPa0CH1cusnj40= - dependencies: - babel-helper-replace-supers "^6.24.1" - babel-runtime "^6.22.0" - -babel-plugin-transform-es2015-parameters@^6.23.0: - version "6.24.1" - resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-parameters/-/babel-plugin-transform-es2015-parameters-6.24.1.tgz#57ac351ab49caf14a97cd13b09f66fdf0a625f2b" - integrity sha1-V6w1GrScrxSpfNE7CfZv3wpiXys= - dependencies: - babel-helper-call-delegate "^6.24.1" - babel-helper-get-function-arity "^6.24.1" - babel-runtime "^6.22.0" - babel-template "^6.24.1" - babel-traverse "^6.24.1" - babel-types "^6.24.1" - -babel-plugin-transform-es2015-shorthand-properties@^6.22.0: - version "6.24.1" - resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-shorthand-properties/-/babel-plugin-transform-es2015-shorthand-properties-6.24.1.tgz#24f875d6721c87661bbd99a4622e51f14de38aa0" - integrity sha1-JPh11nIch2YbvZmkYi5R8U3jiqA= - dependencies: - babel-runtime "^6.22.0" - babel-types "^6.24.1" - -babel-plugin-transform-es2015-spread@^6.22.0: - version "6.22.0" - resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-spread/-/babel-plugin-transform-es2015-spread-6.22.0.tgz#d6d68a99f89aedc4536c81a542e8dd9f1746f8d1" - integrity sha1-1taKmfia7cRTbIGlQujdnxdG+NE= - dependencies: - babel-runtime "^6.22.0" - -babel-plugin-transform-es2015-sticky-regex@^6.22.0: - version "6.24.1" - resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-sticky-regex/-/babel-plugin-transform-es2015-sticky-regex-6.24.1.tgz#00c1cdb1aca71112cdf0cf6126c2ed6b457ccdbc" - integrity sha1-AMHNsaynERLN8M9hJsLta0V8zbw= - dependencies: - babel-helper-regex "^6.24.1" - babel-runtime "^6.22.0" - babel-types "^6.24.1" - -babel-plugin-transform-es2015-template-literals@^6.22.0: - version "6.22.0" - resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-template-literals/-/babel-plugin-transform-es2015-template-literals-6.22.0.tgz#a84b3450f7e9f8f1f6839d6d687da84bb1236d8d" - integrity sha1-qEs0UPfp+PH2g51taH2oS7EjbY0= - dependencies: - babel-runtime "^6.22.0" - -babel-plugin-transform-es2015-typeof-symbol@^6.23.0: - version "6.23.0" - resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-typeof-symbol/-/babel-plugin-transform-es2015-typeof-symbol-6.23.0.tgz#dec09f1cddff94b52ac73d505c84df59dcceb372" - integrity sha1-3sCfHN3/lLUqxz1QXITfWdzOs3I= - dependencies: - babel-runtime "^6.22.0" - -babel-plugin-transform-es2015-unicode-regex@^6.22.0: - version "6.24.1" - resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-unicode-regex/-/babel-plugin-transform-es2015-unicode-regex-6.24.1.tgz#d38b12f42ea7323f729387f18a7c5ae1faeb35e9" - integrity sha1-04sS9C6nMj9yk4fxinxa4frrNek= - dependencies: - babel-helper-regex "^6.24.1" - babel-runtime "^6.22.0" - regexpu-core "^2.0.0" - -babel-plugin-transform-exponentiation-operator@^6.22.0: - version "6.24.1" - resolved "https://registry.yarnpkg.com/babel-plugin-transform-exponentiation-operator/-/babel-plugin-transform-exponentiation-operator-6.24.1.tgz#2ab0c9c7f3098fa48907772bb813fe41e8de3a0e" - integrity sha1-KrDJx/MJj6SJB3cruBP+QejeOg4= - dependencies: - babel-helper-builder-binary-assignment-operator-visitor "^6.24.1" - babel-plugin-syntax-exponentiation-operator "^6.8.0" - babel-runtime "^6.22.0" - -babel-plugin-transform-regenerator@^6.22.0: - version "6.26.0" - resolved "https://registry.yarnpkg.com/babel-plugin-transform-regenerator/-/babel-plugin-transform-regenerator-6.26.0.tgz#e0703696fbde27f0a3efcacf8b4dca2f7b3a8f2f" - integrity sha1-4HA2lvveJ/Cj78rPi03KL3s6jy8= - dependencies: - regenerator-transform "^0.10.0" - -babel-plugin-transform-runtime@~6.23.0: - version "6.23.0" - resolved "https://registry.yarnpkg.com/babel-plugin-transform-runtime/-/babel-plugin-transform-runtime-6.23.0.tgz#88490d446502ea9b8e7efb0fe09ec4d99479b1ee" - integrity sha1-iEkNRGUC6puOfvsP4J7E2ZR5se4= - dependencies: - babel-runtime "^6.22.0" - -babel-plugin-transform-strict-mode@^6.24.1: - version "6.24.1" - resolved "https://registry.yarnpkg.com/babel-plugin-transform-strict-mode/-/babel-plugin-transform-strict-mode-6.24.1.tgz#d5faf7aa578a65bbe591cf5edae04a0c67020758" - integrity sha1-1fr3qleKZbvlkc9e2uBKDGcCB1g= - dependencies: - babel-runtime "^6.22.0" - babel-types "^6.24.1" - -babel-polyfill@~6.26.0: - version "6.26.0" - resolved "https://registry.yarnpkg.com/babel-polyfill/-/babel-polyfill-6.26.0.tgz#379937abc67d7895970adc621f284cd966cf2153" - integrity sha1-N5k3q8Z9eJWXCtxiHyhM2WbPIVM= - dependencies: - babel-runtime "^6.26.0" - core-js "^2.5.0" - regenerator-runtime "^0.10.5" - -babel-preset-env@~1.7.0: - version "1.7.0" - resolved "https://registry.yarnpkg.com/babel-preset-env/-/babel-preset-env-1.7.0.tgz#dea79fa4ebeb883cd35dab07e260c1c9c04df77a" - integrity sha512-9OR2afuKDneX2/q2EurSftUYM0xGu4O2D9adAhVfADDhrYDaxXV0rBbevVYoY9n6nyX1PmQW/0jtpJvUNr9CHg== - dependencies: - babel-plugin-check-es2015-constants "^6.22.0" - babel-plugin-syntax-trailing-function-commas "^6.22.0" - babel-plugin-transform-async-to-generator "^6.22.0" - babel-plugin-transform-es2015-arrow-functions "^6.22.0" - babel-plugin-transform-es2015-block-scoped-functions "^6.22.0" - babel-plugin-transform-es2015-block-scoping "^6.23.0" - babel-plugin-transform-es2015-classes "^6.23.0" - babel-plugin-transform-es2015-computed-properties "^6.22.0" - babel-plugin-transform-es2015-destructuring "^6.23.0" - babel-plugin-transform-es2015-duplicate-keys "^6.22.0" - babel-plugin-transform-es2015-for-of "^6.23.0" - babel-plugin-transform-es2015-function-name "^6.22.0" - babel-plugin-transform-es2015-literals "^6.22.0" - babel-plugin-transform-es2015-modules-amd "^6.22.0" - babel-plugin-transform-es2015-modules-commonjs "^6.23.0" - babel-plugin-transform-es2015-modules-systemjs "^6.23.0" - babel-plugin-transform-es2015-modules-umd "^6.23.0" - babel-plugin-transform-es2015-object-super "^6.22.0" - babel-plugin-transform-es2015-parameters "^6.23.0" - babel-plugin-transform-es2015-shorthand-properties "^6.22.0" - babel-plugin-transform-es2015-spread "^6.22.0" - babel-plugin-transform-es2015-sticky-regex "^6.22.0" - babel-plugin-transform-es2015-template-literals "^6.22.0" - babel-plugin-transform-es2015-typeof-symbol "^6.23.0" - babel-plugin-transform-es2015-unicode-regex "^6.22.0" - babel-plugin-transform-exponentiation-operator "^6.22.0" - babel-plugin-transform-regenerator "^6.22.0" - browserslist "^3.2.6" - invariant "^2.2.2" - semver "^5.3.0" - -babel-register@^6.26.0: - version "6.26.0" - resolved "https://registry.yarnpkg.com/babel-register/-/babel-register-6.26.0.tgz#6ed021173e2fcb486d7acb45c6009a856f647071" - integrity sha1-btAhFz4vy0htestFxgCahW9kcHE= - dependencies: - babel-core "^6.26.0" - babel-runtime "^6.26.0" - core-js "^2.5.0" - home-or-tmp "^2.0.0" - lodash "^4.17.4" - mkdirp "^0.5.1" - source-map-support "^0.4.15" - -babel-runtime@^6.18.0, babel-runtime@^6.22.0, babel-runtime@^6.26.0: - version "6.26.0" - resolved "https://registry.yarnpkg.com/babel-runtime/-/babel-runtime-6.26.0.tgz#965c7058668e82b55d7bfe04ff2337bc8b5647fe" - integrity sha1-llxwWGaOgrVde/4E/yM3vItWR/4= - dependencies: - core-js "^2.4.0" - regenerator-runtime "^0.11.0" - -babel-template@^6.24.1, babel-template@^6.26.0: - version "6.26.0" - resolved "https://registry.yarnpkg.com/babel-template/-/babel-template-6.26.0.tgz#de03e2d16396b069f46dd9fff8521fb1a0e35e02" - integrity sha1-3gPi0WOWsGn0bdn/+FIfsaDjXgI= - dependencies: - babel-runtime "^6.26.0" - babel-traverse "^6.26.0" - babel-types "^6.26.0" - babylon "^6.18.0" - lodash "^4.17.4" - -babel-traverse@^6.24.1, babel-traverse@^6.26.0: - version "6.26.0" - resolved "https://registry.yarnpkg.com/babel-traverse/-/babel-traverse-6.26.0.tgz#46a9cbd7edcc62c8e5c064e2d2d8d0f4035766ee" - integrity sha1-RqnL1+3MYsjlwGTi0tjQ9ANXZu4= - dependencies: - babel-code-frame "^6.26.0" - babel-messages "^6.23.0" - babel-runtime "^6.26.0" - babel-types "^6.26.0" - babylon "^6.18.0" - debug "^2.6.8" - globals "^9.18.0" - invariant "^2.2.2" - lodash "^4.17.4" - -babel-types@^6.19.0, babel-types@^6.24.1, babel-types@^6.26.0: - version "6.26.0" - resolved "https://registry.yarnpkg.com/babel-types/-/babel-types-6.26.0.tgz#a3b073f94ab49eb6fa55cd65227a334380632497" - integrity sha1-o7Bz+Uq0nrb6Vc1lInozQ4BjJJc= - dependencies: - babel-runtime "^6.26.0" - esutils "^2.0.2" - lodash "^4.17.4" - to-fast-properties "^1.0.3" - -babylon@^6.18.0: - version "6.18.0" - resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.18.0.tgz#af2f3b88fa6f5c1e4c634d1a0f8eac4f55b395e3" - integrity sha512-q/UEjfGJ2Cm3oKV71DJz9d25TPnq5rhBVL2Q4fA5wcC3jcrdn7+SssEybFIxwAvvP+YCsCYNKughoF33GxgycQ== - -balanced-match@^1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee" - integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw== - -base-x@^3.0.8: - version "3.0.9" - resolved "https://registry.yarnpkg.com/base-x/-/base-x-3.0.9.tgz#6349aaabb58526332de9f60995e548a53fe21320" - integrity sha512-H7JU6iBHTal1gp56aKoaa//YUxEaAOUiydvrV/pILqIHXTtqxSkATOnDA2u+jZ/61sD+L/412+7kzXRtWukhpQ== - dependencies: - safe-buffer "^5.0.1" - -boolbase@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/boolbase/-/boolbase-1.0.0.tgz#68dff5fbe60c51eb37725ea9e3ed310dcc1e776e" - integrity sha1-aN/1++YMUes3cl6p4+0xDcwed24= - -brace-expansion@^1.1.7: - version "1.1.11" - resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" - integrity sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA== - dependencies: - balanced-match "^1.0.0" - concat-map "0.0.1" - -braces@^3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107" - integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A== - dependencies: - fill-range "^7.0.1" - -browserslist@^3.2.6: - version "3.2.8" - resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-3.2.8.tgz#b0005361d6471f0f5952797a76fc985f1f978fc6" - integrity sha512-WHVocJYavUwVgVViC0ORikPHQquXwVh939TaelZ4WDqpWgTX/FsGhl/+P4qBUAGcRvtOgDgC+xftNWWp2RUTAQ== - dependencies: - caniuse-lite "^1.0.30000844" - electron-to-chromium "^1.3.47" - -browserslist@^4.6.6: - version "4.20.0" - resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.20.0.tgz#35951e3541078c125d36df76056e94738a52ebe9" - integrity sha512-bnpOoa+DownbciXj0jVGENf8VYQnE2LNWomhYuCsMmmx9Jd9lwq0WXODuwpSsp8AVdKM2/HorrzxAfbKvWTByQ== - dependencies: - caniuse-lite "^1.0.30001313" - electron-to-chromium "^1.4.76" - escalade "^3.1.1" - node-releases "^2.0.2" - picocolors "^1.0.0" - -buffer-from@^1.0.0: - version "1.1.2" - resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.2.tgz#2b146a6fd72e80b4f55d255f35ed59a3a9a41bd5" - integrity sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ== - -callsites@^3.0.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/callsites/-/callsites-3.1.0.tgz#b3630abd8943432f54b3f0519238e33cd7df2f73" - integrity sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ== - -caniuse-lite@^1.0.30000844: - version "1.0.30001457" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001457.tgz#6af34bb5d720074e2099432aa522c21555a18301" - integrity sha512-SDIV6bgE1aVbK6XyxdURbUE89zY7+k1BBBaOwYwkNCglXlel/E7mELiHC64HQ+W0xSKlqWhV9Wh7iHxUjMs4fA== - -caniuse-lite@^1.0.30001313: - version "1.0.30001317" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001317.tgz#0548fb28fd5bc259a70b8c1ffdbe598037666a1b" - integrity sha512-xIZLh8gBm4dqNX0gkzrBeyI86J2eCjWzYAs40q88smG844YIrN4tVQl/RhquHvKEKImWWFIVh1Lxe5n1G/N+GQ== - -chalk@^1.1.3: - version "1.1.3" - resolved "https://registry.yarnpkg.com/chalk/-/chalk-1.1.3.tgz#a8115c55e4a702fe4d150abd3872822a7e09fc98" - integrity sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg= - dependencies: - ansi-styles "^2.2.1" - escape-string-regexp "^1.0.2" - has-ansi "^2.0.0" - strip-ansi "^3.0.0" - supports-color "^2.0.0" - -chalk@^2.0.0: - version "2.4.2" - resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" - integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ== - dependencies: - ansi-styles "^3.2.1" - escape-string-regexp "^1.0.5" - supports-color "^5.3.0" - -chalk@^4.1.0: - version "4.1.2" - resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01" - integrity sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA== - dependencies: - ansi-styles "^4.1.0" - supports-color "^7.1.0" - -chrome-trace-event@^1.0.2: - version "1.0.3" - resolved "https://registry.yarnpkg.com/chrome-trace-event/-/chrome-trace-event-1.0.3.tgz#1015eced4741e15d06664a957dbbf50d041e26ac" - integrity sha512-p3KULyQg4S7NIHixdwbGX+nFHkoBiA4YQmyWtjb8XngSKV124nJmRysgAeujbUVb15vh+RvFUfCPqU7rXk+hZg== - -clang-format@~1.8.0: - version "1.8.0" - resolved "https://registry.yarnpkg.com/clang-format/-/clang-format-1.8.0.tgz#7779df1c5ce1bc8aac1b0b02b4e479191ef21d46" - integrity sha512-pK8gzfu55/lHzIpQ1givIbWfn3eXnU7SfxqIwVgnn5jEM6j4ZJYjpFqFs4iSBPNedzRMmfjYjuQhu657WAXHXw== - dependencies: - async "^3.2.3" - glob "^7.0.0" - resolve "^1.1.6" - -cliui@^7.0.2: - version "7.0.4" - resolved "https://registry.yarnpkg.com/cliui/-/cliui-7.0.4.tgz#a0265ee655476fc807aea9df3df8df7783808b4f" - integrity sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ== - dependencies: - string-width "^4.2.0" - strip-ansi "^6.0.0" - wrap-ansi "^7.0.0" - -clone@^2.1.1: - version "2.1.2" - resolved "https://registry.yarnpkg.com/clone/-/clone-2.1.2.tgz#1b7f4b9f591f1e8f83670401600345a02887435f" - integrity sha1-G39Ln1kfHo+DZwQBYANFoCiHQ18= - -color-convert@^1.9.0: - version "1.9.3" - resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8" - integrity sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg== - dependencies: - color-name "1.1.3" - -color-convert@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-2.0.1.tgz#72d3a68d598c9bdb3af2ad1e84f21d896abd4de3" - integrity sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ== - dependencies: - color-name "~1.1.4" - -color-name@1.1.3: - version "1.1.3" - resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25" - integrity sha1-p9BVi9icQveV3UIyj3QIMcpTvCU= - -color-name@~1.1.4: - version "1.1.4" - resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2" - integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA== - -commander@^2.20.0: - version "2.20.3" - resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33" - integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ== - -commander@^7.0.0, commander@^7.2.0: - version "7.2.0" - resolved "https://registry.yarnpkg.com/commander/-/commander-7.2.0.tgz#a36cb57d0b501ce108e4d20559a150a391d97ab7" - integrity sha512-QrWXB+ZQSVPmIWIhtEO9H+gwHaMGYiF5ChvoJ+K9ZGHG/sVsa6yiesAD1GC/x46sET00Xlwo1u49RVVVzvcSkw== - -concat-map@0.0.1: - version "0.0.1" - resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" - integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s= - -convert-source-map@^1.5.1: - version "1.8.0" - resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.8.0.tgz#f3373c32d21b4d780dd8004514684fb791ca4369" - integrity sha512-+OQdjP49zViI/6i7nIJpA8rAl4sV/JdPfU9nZs3VqOwGIgizICvuN2ru6fMd+4llL0tar18UYJXfZ/TWtmhUjA== - dependencies: - safe-buffer "~5.1.1" - -core-js@^2.4.0, core-js@^2.5.0: - version "2.6.12" - resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.6.12.tgz#d9333dfa7b065e347cc5682219d6f690859cc2ec" - integrity sha512-Kb2wC0fvsWfQrgk8HU5lW6U/Lcs8+9aaYcy4ZFc6DDlo4nZ7n70dEgE5rtR0oG6ufKDUnrwfWL1mXR5ljDatrQ== - -cosmiconfig@^7.0.1: - version "7.0.1" - resolved "https://registry.yarnpkg.com/cosmiconfig/-/cosmiconfig-7.0.1.tgz#714d756522cace867867ccb4474c5d01bbae5d6d" - integrity sha512-a1YWNUV2HwGimB7dU2s1wUMurNKjpx60HxBB6xUM8Re+2s1g1IIfJvFR0/iCF+XHdE0GMTKTuLR32UQff4TEyQ== - dependencies: - "@types/parse-json" "^4.0.0" - import-fresh "^3.2.1" - parse-json "^5.0.0" - path-type "^4.0.0" - yaml "^1.10.0" - -cross-env@^7.0.3: - version "7.0.3" - resolved "https://registry.yarnpkg.com/cross-env/-/cross-env-7.0.3.tgz#865264b29677dc015ba8418918965dd232fc54cf" - integrity sha512-+/HKd6EgcQCJGh2PSjZuUitQBQynKor4wrFbRg4DtAgS1aWO+gU52xpH7M9ScGgXSYmAVS9bIJ8EzuaGw0oNAw== - dependencies: - cross-spawn "^7.0.1" - -cross-spawn@^7.0.1: - version "7.0.3" - resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6" - integrity sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w== - dependencies: - path-key "^3.1.0" - shebang-command "^2.0.0" - which "^2.0.1" - -css-select@^4.1.3: - version "4.2.1" - resolved "https://registry.yarnpkg.com/css-select/-/css-select-4.2.1.tgz#9e665d6ae4c7f9d65dbe69d0316e3221fb274cdd" - integrity sha512-/aUslKhzkTNCQUB2qTX84lVmfia9NyjP3WpDGtj/WxhwBzWBYUV3DgUpurHTme8UTPcPlAD1DJ+b0nN/t50zDQ== - dependencies: - boolbase "^1.0.0" - css-what "^5.1.0" - domhandler "^4.3.0" - domutils "^2.8.0" - nth-check "^2.0.1" - -css-tree@^1.1.2, css-tree@^1.1.3: - version "1.1.3" - resolved "https://registry.yarnpkg.com/css-tree/-/css-tree-1.1.3.tgz#eb4870fb6fd7707327ec95c2ff2ab09b5e8db91d" - integrity sha512-tRpdppF7TRazZrjJ6v3stzv93qxRcSsFmW6cX0Zm2NVKpxE1WV1HblnghVv9TreireHkqI/VDEsfolRF1p6y7Q== - dependencies: - mdn-data "2.0.14" - source-map "^0.6.1" - -css-what@^5.1.0: - version "5.1.0" - resolved "https://registry.yarnpkg.com/css-what/-/css-what-5.1.0.tgz#3f7b707aadf633baf62c2ceb8579b545bb40f7fe" - integrity sha512-arSMRWIIFY0hV8pIxZMEfmMI47Wj3R/aWpZDDxWYCPEiOMv6tfOrnpDtgxBYPEQD4V0Y/958+1TdC3iWTFcUPw== - -csso@^4.2.0: - version "4.2.0" - resolved "https://registry.yarnpkg.com/csso/-/csso-4.2.0.tgz#ea3a561346e8dc9f546d6febedd50187cf389529" - integrity sha512-wvlcdIbf6pwKEk7vHj8/Bkc0B4ylXZruLvOgs9doS5eOsOpuodOV2zJChSpkp+pRpYQLQMeF04nr3Z68Sta9jA== - dependencies: - css-tree "^1.1.2" - -debug@^2.6.8, debug@^2.6.9: - version "2.6.9" - resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" - integrity sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA== - dependencies: - ms "2.0.0" - -detect-indent@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/detect-indent/-/detect-indent-4.0.0.tgz#f76d064352cdf43a1cb6ce619c4ee3a9475de208" - integrity sha1-920GQ1LN9Docts5hnE7jqUdd4gg= - dependencies: - repeating "^2.0.0" - -detect-indent@^6.0.0: - version "6.1.0" - resolved "https://registry.yarnpkg.com/detect-indent/-/detect-indent-6.1.0.tgz#592485ebbbf6b3b1ab2be175c8393d04ca0d57e6" - integrity sha512-reYkTUJAZb9gUuZ2RvVCNhVHdg62RHnJ7WJl8ftMi4diZ6NWlciOzQN88pUhSELEwflJht4oQDv0F0BMlwaYtA== - -detect-libc@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/detect-libc/-/detect-libc-1.0.3.tgz#fa137c4bd698edf55cd5cd02ac559f91a4c4ba9b" - integrity sha1-+hN8S9aY7fVc1c0CrFWfkaTEups= - -dom-serializer@^1.0.1: - version "1.3.2" - resolved "https://registry.yarnpkg.com/dom-serializer/-/dom-serializer-1.3.2.tgz#6206437d32ceefaec7161803230c7a20bc1b4d91" - integrity sha512-5c54Bk5Dw4qAxNOI1pFEizPSjVsx5+bpJKmL2kPn8JhBUq2q09tTCa3mjijun2NfK78NMouDYNMBkOrPZiS+ig== - dependencies: - domelementtype "^2.0.1" - domhandler "^4.2.0" - entities "^2.0.0" - -domelementtype@^2.0.1, domelementtype@^2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/domelementtype/-/domelementtype-2.2.0.tgz#9a0b6c2782ed6a1c7323d42267183df9bd8b1d57" - integrity sha512-DtBMo82pv1dFtUmHyr48beiuq792Sxohr+8Hm9zoxklYPfa6n0Z3Byjj2IV7bmr2IyqClnqEQhfgHJJ5QF0R5A== - -domhandler@^4.2.0, domhandler@^4.2.2, domhandler@^4.3.0: - version "4.3.0" - resolved "https://registry.yarnpkg.com/domhandler/-/domhandler-4.3.0.tgz#16c658c626cf966967e306f966b431f77d4a5626" - integrity sha512-fC0aXNQXqKSFTr2wDNZDhsEYjCiYsDWl3D01kwt25hm1YIPyDGHvvi3rw+PLqHAl/m71MaiF7d5zvBr0p5UB2g== - dependencies: - domelementtype "^2.2.0" - -domutils@^2.8.0: - version "2.8.0" - resolved "https://registry.yarnpkg.com/domutils/-/domutils-2.8.0.tgz#4437def5db6e2d1f5d6ee859bd95ca7d02048135" - integrity sha512-w96Cjofp72M5IIhpjgobBimYEfoPjx1Vx0BSX9P30WBdZW2WIKU0T1Bd0kz2eNZ9ikjKgHbEyKx8BB6H1L3h3A== - dependencies: - dom-serializer "^1.0.1" - domelementtype "^2.2.0" - domhandler "^4.2.0" - -dotenv-expand@^5.1.0: - version "5.1.0" - resolved "https://registry.yarnpkg.com/dotenv-expand/-/dotenv-expand-5.1.0.tgz#3fbaf020bfd794884072ea26b1e9791d45a629f0" - integrity sha512-YXQl1DSa4/PQyRfgrv6aoNjhasp/p4qs9FjJ4q4cQk+8m4r6k4ZSiEyytKG8f8W9gi8WsQtIObNmKd+tMzNTmA== - -dotenv@^7.0.0: - version "7.0.0" - resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-7.0.0.tgz#a2be3cd52736673206e8a85fb5210eea29628e7c" - integrity sha512-M3NhsLbV1i6HuGzBUH8vXrtxOk+tWmzWKDMbAVSUp3Zsjm7ywFeuwrUXhmhQyRK1q5B5GGy7hcXPbj3bnfZg2g== - -electron-to-chromium@^1.3.47: - version "1.4.305" - resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.305.tgz#e4dfe3e06ab783f33171f9bde9e8ed092510fcd0" - integrity sha512-WETy6tG0CT5gm1O+xCbyapWNsCcmIvrn4NHViIGYo2AT8FV2qUCXdaB+WqYxSv/vS5mFqhBYnfZAAkVArjBmUg== - -electron-to-chromium@^1.4.76: - version "1.4.84" - resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.84.tgz#2700befbcb49c42c4ee162e137ff392c07658249" - integrity sha512-b+DdcyOiZtLXHdgEG8lncYJdxbdJWJvclPNMg0eLUDcSOSO876WA/pYjdSblUTd7eJdIs4YdIxHWGazx7UPSJw== - -emoji-regex@^8.0.0: - version "8.0.0" - resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37" - integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A== - -entities@^2.0.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/entities/-/entities-2.2.0.tgz#098dc90ebb83d8dffa089d55256b351d34c4da55" - integrity sha512-p92if5Nz619I0w+akJrLZH0MX0Pb5DX39XOwQTtXSdQQOaYH03S1uIQp4mhOZtAXrxq4ViO67YTiLBo2638o9A== - -entities@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/entities/-/entities-3.0.1.tgz#2b887ca62585e96db3903482d336c1006c3001d4" - integrity sha512-WiyBqoomrwMdFG1e0kqvASYfnlb0lp8M5o5Fw2OFq1hNZxxcNk8Ik0Xm7LxzBhuidnZB/UtBqVCgUz3kBOP51Q== - -error-ex@^1.3.1: - version "1.3.2" - resolved "https://registry.yarnpkg.com/error-ex/-/error-ex-1.3.2.tgz#b4ac40648107fdcdcfae242f428bea8a14d4f1bf" - integrity sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g== - dependencies: - is-arrayish "^0.2.1" - -escalade@^3.1.1: - version "3.1.1" - resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.1.1.tgz#d8cfdc7000965c5a0174b4a82eaa5c0552742e40" - integrity sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw== - -escape-string-regexp@^1.0.2, escape-string-regexp@^1.0.5: - version "1.0.5" - resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" - integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ= - -esutils@^2.0.2: - version "2.0.3" - resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.3.tgz#74d2eb4de0b8da1293711910d50775b9b710ef64" - integrity sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g== - -fill-range@^7.0.1: - version "7.0.1" - resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.0.1.tgz#1919a6a7c75fe38b2c7c77e5198535da9acdda40" - integrity sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ== - dependencies: - to-regex-range "^5.0.1" - -fs-extra@^8.0.1: - version "8.1.0" - resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-8.1.0.tgz#49d43c45a88cd9677668cb7be1b46efdb8d2e1c0" - integrity sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g== - dependencies: - graceful-fs "^4.2.0" - jsonfile "^4.0.0" - universalify "^0.1.0" - -fs.realpath@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" - integrity sha1-FQStJSMVjKpA20onh8sBQRmU6k8= - -function-bind@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d" - integrity sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A== - -get-caller-file@^2.0.5: - version "2.0.5" - resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e" - integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg== - -get-port@^4.2.0: - version "4.2.0" - resolved "https://registry.yarnpkg.com/get-port/-/get-port-4.2.0.tgz#e37368b1e863b7629c43c5a323625f95cf24b119" - integrity sha512-/b3jarXkH8KJoOMQc3uVGHASwGLPq3gSFJ7tgJm2diza+bydJPTGOibin2steecKeOylE8oY2JERlVWkAJO6yw== - -glob@^7.0.0, glob@^7.1.4, glob@^7.1.6: - version "7.2.0" - resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.0.tgz#d15535af7732e02e948f4c41628bd910293f6023" - integrity sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q== - dependencies: - fs.realpath "^1.0.0" - inflight "^1.0.4" - inherits "2" - minimatch "^3.0.4" - once "^1.3.0" - path-is-absolute "^1.0.0" - -globals@^13.2.0: - version "13.12.1" - resolved "https://registry.yarnpkg.com/globals/-/globals-13.12.1.tgz#ec206be932e6c77236677127577aa8e50bf1c5cb" - integrity sha512-317dFlgY2pdJZ9rspXDks7073GpDmXdfbM3vYYp0HAMKGDh1FfWPleI2ljVNLQX5M5lXcAslTcPTrOrMEFOjyw== - dependencies: - type-fest "^0.20.2" - -globals@^9.18.0: - version "9.18.0" - resolved "https://registry.yarnpkg.com/globals/-/globals-9.18.0.tgz#aa3896b3e69b487f17e31ed2143d69a8e30c2d8a" - integrity sha512-S0nG3CLEQiY/ILxqtztTWH/3iRRdyBLw6KMDxnKMchrtbj2OFmehVh0WUCfW3DUrIgx/qFrJPICrq4Z4sTR9UQ== - -graceful-fs@^4.1.6, graceful-fs@^4.2.0: - version "4.2.9" - resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.9.tgz#041b05df45755e587a24942279b9d113146e1c96" - integrity sha512-NtNxqUcXgpW2iMrfqSfR73Glt39K+BLwWsPs94yR63v45T0Wbej7eRmL5cWfwEgqXnmjQp3zaJTshdRW/qC2ZQ== - -has-ansi@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/has-ansi/-/has-ansi-2.0.0.tgz#34f5049ce1ecdf2b0649af3ef24e45ed35416d91" - integrity sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE= - dependencies: - ansi-regex "^2.0.0" - -has-flag@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd" - integrity sha1-tdRU3CGZriJWmfNGfloH87lVuv0= - -has-flag@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b" - integrity sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ== - -has@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/has/-/has-1.0.3.tgz#722d7cbfc1f6aa8241f16dd814e011e1f41e8796" - integrity sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw== - dependencies: - function-bind "^1.1.1" - -home-or-tmp@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/home-or-tmp/-/home-or-tmp-2.0.0.tgz#e36c3f2d2cae7d746a857e38d18d5f32a7882db8" - integrity sha1-42w/LSyufXRqhX440Y1fMqeILbg= - dependencies: - os-homedir "^1.0.0" - os-tmpdir "^1.0.1" - -htmlnano@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/htmlnano/-/htmlnano-2.0.0.tgz#07376faa064f7e1e832dfd91e1a9f606b0bc9b78" - integrity sha512-thKQfhcp2xgtsWNE27A2bliEeqVL5xjAgGn0wajyttvFFsvFWWah1ntV9aEX61gz0T6MBQ5xK/1lXuEumhJTcg== - dependencies: - cosmiconfig "^7.0.1" - posthtml "^0.16.5" - timsort "^0.3.0" - -htmlparser2@^7.1.1: - version "7.2.0" - resolved "https://registry.yarnpkg.com/htmlparser2/-/htmlparser2-7.2.0.tgz#8817cdea38bbc324392a90b1990908e81a65f5a5" - integrity sha512-H7MImA4MS6cw7nbyURtLPO1Tms7C5H602LRETv95z1MxO/7CP7rDVROehUYeYBUYEON94NXXDEPmZuq+hX4sog== - dependencies: - domelementtype "^2.0.1" - domhandler "^4.2.2" - domutils "^2.8.0" - entities "^3.0.1" - -ignore-walk@^3.0.3: - version "3.0.4" - resolved "https://registry.yarnpkg.com/ignore-walk/-/ignore-walk-3.0.4.tgz#c9a09f69b7c7b479a5d74ac1a3c0d4236d2a6335" - integrity sha512-PY6Ii8o1jMRA1z4F2hRkH/xN59ox43DavKvD3oDpfurRlOJyAHpifIwpbdv1n4jt4ov0jSpw3kQ4GhJnpBL6WQ== - dependencies: - minimatch "^3.0.4" - -ignore@^5.0.4: - version "5.2.0" - resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.2.0.tgz#6d3bac8fa7fe0d45d9f9be7bac2fc279577e345a" - integrity sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ== - -import-fresh@^3.2.1: - version "3.3.0" - resolved "https://registry.yarnpkg.com/import-fresh/-/import-fresh-3.3.0.tgz#37162c25fcb9ebaa2e6e53d5b4d88ce17d9e0c2b" - integrity sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw== - dependencies: - parent-module "^1.0.0" - resolve-from "^4.0.0" - -inflight@^1.0.4: - version "1.0.6" - resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" - integrity sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk= - dependencies: - once "^1.3.0" - wrappy "1" - -inherits@2: - version "2.0.4" - resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" - integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== - -ini@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/ini/-/ini-2.0.0.tgz#e5fd556ecdd5726be978fa1001862eacb0a94bc5" - integrity sha512-7PnF4oN3CvZF23ADhA5wRaYEQpJ8qygSkbtTXWBeXWXmEVRXK+1ITciHWwHhsjv1TmW0MgacIv6hEi5pX5NQdA== - -invariant@^2.2.2: - version "2.2.4" - resolved "https://registry.yarnpkg.com/invariant/-/invariant-2.2.4.tgz#610f3c92c9359ce1db616e538008d23ff35158e6" - integrity sha512-phJfQVBuaJM5raOpJjSfkiD6BpbCE4Ns//LaXl6wGYtUBY83nWS6Rf9tXm2e8VaK60JEjYldbPif/A2B1C2gNA== - dependencies: - loose-envify "^1.0.0" - -is-arrayish@^0.2.1: - version "0.2.1" - resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.2.1.tgz#77c99840527aa8ecb1a8ba697b80645a7a926a9d" - integrity sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0= - -is-core-module@^2.8.1: - version "2.8.1" - resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.8.1.tgz#f59fdfca701d5879d0a6b100a40aa1560ce27211" - integrity sha512-SdNCUs284hr40hFTFP6l0IfZ/RSrMXF3qgoRHd3/79unUTvrFO/JoXwkGm+5J/Oe3E/b5GsnG330uUNgRpu1PA== - dependencies: - has "^1.0.3" - -is-extglob@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2" - integrity sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ== - -is-finite@^1.0.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/is-finite/-/is-finite-1.1.0.tgz#904135c77fb42c0641d6aa1bcdbc4daa8da082f3" - integrity sha512-cdyMtqX/BOqqNBBiKlIVkytNHm49MtMlYyn1zxzvJKWmFMlGzm+ry5BBfYyeY9YmNKbRSo/o7OX9w9ale0wg3w== - -is-fullwidth-code-point@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz#f116f8064fe90b3f7844a38997c0b75051269f1d" - integrity sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg== - -is-glob@^4.0.3: - version "4.0.3" - resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.3.tgz#64f61e42cbbb2eec2071a9dac0b28ba1e65d5084" - integrity sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg== - dependencies: - is-extglob "^2.1.1" - -is-json@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/is-json/-/is-json-2.0.1.tgz#6be166d144828a131d686891b983df62c39491ff" - integrity sha1-a+Fm0USCihMdaGiRuYPfYsOUkf8= - -is-number@^7.0.0: - version "7.0.0" - resolved "https://registry.yarnpkg.com/is-number/-/is-number-7.0.0.tgz#7535345b896734d5f80c4d06c50955527a14f12b" - integrity sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng== - -isexe@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" - integrity sha1-6PvzdNxVb/iUehDcsFctYz8s+hA= - -"js-tokens@^3.0.0 || ^4.0.0", js-tokens@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" - integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ== - -js-tokens@^3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b" - integrity sha1-mGbfOVECEw449/mWvOtlRDIJwls= - -jsesc@^1.3.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-1.3.0.tgz#46c3fec8c1892b12b0833db9bc7622176dbab34b" - integrity sha1-RsP+yMGJKxKwgz25vHYiF226s0s= - -jsesc@~0.5.0: - version "0.5.0" - resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-0.5.0.tgz#e7dee66e35d6fc16f710fe91d5cf69f70f08911d" - integrity sha1-597mbjXW/Bb3EP6R1c9p9w8IkR0= - -json-parse-even-better-errors@^2.3.0: - version "2.3.1" - resolved "https://registry.yarnpkg.com/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz#7c47805a94319928e05777405dc12e1f7a4ee02d" - integrity sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w== - -json5@^0.5.1: - version "0.5.1" - resolved "https://registry.yarnpkg.com/json5/-/json5-0.5.1.tgz#1eade7acc012034ad84e2396767ead9fa5495821" - integrity sha1-Hq3nrMASA0rYTiOWdn6tn6VJWCE= - -json5@^2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.0.tgz#2dfefe720c6ba525d9ebd909950f0515316c89a3" - integrity sha512-f+8cldu7X/y7RAJurMEJmdoKXGB/X550w2Nr3tTbezL6RwEE/iMcm+tZnXeoZtKuOq6ft8+CqzEkrIgx1fPoQA== - dependencies: - minimist "^1.2.5" - -json5@^2.2.1: - version "2.2.3" - resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.3.tgz#78cd6f1a19bdc12b73db5ad0c61efd66c1e29283" - integrity sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg== - -jsonfile@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-4.0.0.tgz#8771aae0799b64076b76640fca058f9c10e33ecb" - integrity sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss= - optionalDependencies: - graceful-fs "^4.1.6" - -lightningcss-darwin-arm64@1.19.0: - version "1.19.0" - resolved "https://registry.yarnpkg.com/lightningcss-darwin-arm64/-/lightningcss-darwin-arm64-1.19.0.tgz#56ab071e932f845dbb7667f44f5b78441175a343" - integrity sha512-wIJmFtYX0rXHsXHSr4+sC5clwblEMji7HHQ4Ub1/CznVRxtCFha6JIt5JZaNf8vQrfdZnBxLLC6R8pC818jXqg== - -lightningcss-darwin-x64@1.19.0: - version "1.19.0" - resolved "https://registry.yarnpkg.com/lightningcss-darwin-x64/-/lightningcss-darwin-x64-1.19.0.tgz#c867308b88859ba61a2c46c82b1ca52ff73a1bd0" - integrity sha512-Lif1wD6P4poaw9c/4Uh2z+gmrWhw/HtXFoeZ3bEsv6Ia4tt8rOJBdkfVaUJ6VXmpKHALve+iTyP2+50xY1wKPw== - -lightningcss-linux-arm-gnueabihf@1.19.0: - version "1.19.0" - resolved "https://registry.yarnpkg.com/lightningcss-linux-arm-gnueabihf/-/lightningcss-linux-arm-gnueabihf-1.19.0.tgz#0f921dc45f2e5c3aea70fab98844ac0e5f2f81be" - integrity sha512-P15VXY5682mTXaiDtbnLYQflc8BYb774j2R84FgDLJTN6Qp0ZjWEFyN1SPqyfTj2B2TFjRHRUvQSSZ7qN4Weig== - -lightningcss-linux-arm64-gnu@1.19.0: - version "1.19.0" - resolved "https://registry.yarnpkg.com/lightningcss-linux-arm64-gnu/-/lightningcss-linux-arm64-gnu-1.19.0.tgz#027f9df9c7f4ffa127c37a71726245a5794d7ba2" - integrity sha512-zwXRjWqpev8wqO0sv0M1aM1PpjHz6RVIsBcxKszIG83Befuh4yNysjgHVplF9RTU7eozGe3Ts7r6we1+Qkqsww== - -lightningcss-linux-arm64-musl@1.19.0: - version "1.19.0" - resolved "https://registry.yarnpkg.com/lightningcss-linux-arm64-musl/-/lightningcss-linux-arm64-musl-1.19.0.tgz#85ea987da868524eac6db94f8e1eaa23d0b688a3" - integrity sha512-vSCKO7SDnZaFN9zEloKSZM5/kC5gbzUjoJQ43BvUpyTFUX7ACs/mDfl2Eq6fdz2+uWhUh7vf92c4EaaP4udEtA== - -lightningcss-linux-x64-gnu@1.19.0: - version "1.19.0" - resolved "https://registry.yarnpkg.com/lightningcss-linux-x64-gnu/-/lightningcss-linux-x64-gnu-1.19.0.tgz#02bec89579ab4153dccc0def755d1fd9e3ee7f3c" - integrity sha512-0AFQKvVzXf9byrXUq9z0anMGLdZJS+XSDqidyijI5njIwj6MdbvX2UZK/c4FfNmeRa2N/8ngTffoIuOUit5eIQ== - -lightningcss-linux-x64-musl@1.19.0: - version "1.19.0" - resolved "https://registry.yarnpkg.com/lightningcss-linux-x64-musl/-/lightningcss-linux-x64-musl-1.19.0.tgz#e36a5df8193ae961d22974635e4c100a1823bb8c" - integrity sha512-SJoM8CLPt6ECCgSuWe+g0qo8dqQYVcPiW2s19dxkmSI5+Uu1GIRzyKA0b7QqmEXolA+oSJhQqCmJpzjY4CuZAg== - -lightningcss-win32-x64-msvc@1.19.0: - version "1.19.0" - resolved "https://registry.yarnpkg.com/lightningcss-win32-x64-msvc/-/lightningcss-win32-x64-msvc-1.19.0.tgz#0854dbd153035eca1396e2227c708ad43655a61c" - integrity sha512-C+VuUTeSUOAaBZZOPT7Etn/agx/MatzJzGRkeV+zEABmPuntv1zihncsi+AyGmjkkzq3wVedEy7h0/4S84mUtg== - -lightningcss@^1.16.1: - version "1.19.0" - resolved "https://registry.yarnpkg.com/lightningcss/-/lightningcss-1.19.0.tgz#fbbad0975de66252e38d96b5bdd2a62f2dd0ffbf" - integrity sha512-yV5UR7og+Og7lQC+70DA7a8ta1uiOPnWPJfxa0wnxylev5qfo4P+4iMpzWAdYWOca4jdNQZii+bDL/l+4hUXIA== - dependencies: - detect-libc "^1.0.3" - optionalDependencies: - lightningcss-darwin-arm64 "1.19.0" - lightningcss-darwin-x64 "1.19.0" - lightningcss-linux-arm-gnueabihf "1.19.0" - lightningcss-linux-arm64-gnu "1.19.0" - lightningcss-linux-arm64-musl "1.19.0" - lightningcss-linux-x64-gnu "1.19.0" - lightningcss-linux-x64-musl "1.19.0" - lightningcss-win32-x64-msvc "1.19.0" - -lines-and-columns@^1.1.6: - version "1.2.4" - resolved "https://registry.yarnpkg.com/lines-and-columns/-/lines-and-columns-1.2.4.tgz#eca284f75d2965079309dc0ad9255abb2ebc1632" - integrity sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg== - -lmdb@2.5.2: - version "2.5.2" - resolved "https://registry.yarnpkg.com/lmdb/-/lmdb-2.5.2.tgz#37e28a9fb43405f4dc48c44cec0e13a14c4a6ff1" - integrity sha512-V5V5Xa2Hp9i2XsbDALkBTeHXnBXh/lEmk9p22zdr7jtuOIY9TGhjK6vAvTpOOx9IKU4hJkRWZxn/HsvR1ELLtA== - dependencies: - msgpackr "^1.5.4" - node-addon-api "^4.3.0" - node-gyp-build-optional-packages "5.0.3" - ordered-binary "^1.2.4" - weak-lru-cache "^1.2.2" - optionalDependencies: - "@lmdb/lmdb-darwin-arm64" "2.5.2" - "@lmdb/lmdb-darwin-x64" "2.5.2" - "@lmdb/lmdb-linux-arm" "2.5.2" - "@lmdb/lmdb-linux-arm64" "2.5.2" - "@lmdb/lmdb-linux-x64" "2.5.2" - "@lmdb/lmdb-win32-x64" "2.5.2" - -lodash@^4.17.4: - version "4.17.21" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c" - integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg== - -long@4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/long/-/long-4.0.0.tgz#9a7b71cfb7d361a194ea555241c92f7468d5bf28" - integrity sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA== - -loose-envify@^1.0.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.4.0.tgz#71ee51fa7be4caec1a63839f7e682d8132d30caf" - integrity sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q== - dependencies: - js-tokens "^3.0.0 || ^4.0.0" - -mdn-data@2.0.14: - version "2.0.14" - resolved "https://registry.yarnpkg.com/mdn-data/-/mdn-data-2.0.14.tgz#7113fc4281917d63ce29b43446f701e68c25ba50" - integrity sha512-dn6wd0uw5GsdswPFfsgMp5NSB0/aDe6fK94YJV/AJDYXL6HVLWBsxeq7js7Ad+mU2K9LAlwpk6kN2D5mwCPVow== - -micromatch@^4.0.5: - version "4.0.5" - resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.5.tgz#bc8999a7cbbf77cdc89f132f6e467051b49090c6" - integrity sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA== - dependencies: - braces "^3.0.2" - picomatch "^2.3.1" - -minimatch@^3.0.4: - version "3.1.2" - resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b" - integrity sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw== - dependencies: - brace-expansion "^1.1.7" - -minimist@1.2.6, minimist@^1.2.5: - version "1.2.6" - resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.6.tgz#8637a5b759ea0d6e98702cfb3a9283323c93af44" - integrity sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q== - -mkdirp@^0.5.1: - version "0.5.5" - resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.5.tgz#d91cefd62d1436ca0f41620e251288d420099def" - integrity sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ== - dependencies: - minimist "^1.2.5" - -ms@2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" - integrity sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g= - -msgpackr-extract@^1.0.14: - version "1.0.16" - resolved "https://registry.yarnpkg.com/msgpackr-extract/-/msgpackr-extract-1.0.16.tgz#701c4f6e6f25c100ae84557092274e8fffeefe45" - integrity sha512-fxdRfQUxPrL/TizyfYfMn09dK58e+d65bRD/fcaVH4052vj30QOzzqxcQIS7B0NsqlypEQ/6Du3QmP2DhWFfCA== - dependencies: - nan "^2.14.2" - node-gyp-build "^4.2.3" - -msgpackr@^1.5.4: - version "1.5.5" - resolved "https://registry.yarnpkg.com/msgpackr/-/msgpackr-1.5.5.tgz#c0562abc2951d7e29f75d77a8656b01f103a042c" - integrity sha512-JG0V47xRIQ9pyUnx6Hb4+3TrQoia2nA3UIdmyTldhxaxtKFkekkKpUW/N6fwHwod9o4BGuJGtouxOk+yCP5PEA== - optionalDependencies: - msgpackr-extract "^1.0.14" - -nan@^2.14.2: - version "2.15.0" - resolved "https://registry.yarnpkg.com/nan/-/nan-2.15.0.tgz#3f34a473ff18e15c1b5626b62903b5ad6e665fee" - integrity sha512-8ZtvEnA2c5aYCZYd1cvgdnU6cqwixRoYg70xPLWUws5ORTa/lnw+u4amixRS/Ac5U5mQVgp9pnlSUnbNWFaWZQ== - -node-addon-api@^3.2.1: - version "3.2.1" - resolved "https://registry.yarnpkg.com/node-addon-api/-/node-addon-api-3.2.1.tgz#81325e0a2117789c0128dab65e7e38f07ceba161" - integrity sha512-mmcei9JghVNDYydghQmeDX8KoAm0FAiYyIcUt/N4nhyAipB17pllZQDOJD2fotxABnt4Mdz+dKTO7eftLg4d0A== - -node-addon-api@^4.3.0: - version "4.3.0" - resolved "https://registry.yarnpkg.com/node-addon-api/-/node-addon-api-4.3.0.tgz#52a1a0b475193e0928e98e0426a0d1254782b77f" - integrity sha512-73sE9+3UaLYYFmDsFZnqCInzPyh3MqIwZO9cw58yIqAZhONrrabrYyYe3TuIqtIiOuTXVhsGau8hcrhhwSsDIQ== - -node-fetch@~2.6.1: - version "2.6.7" - resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.7.tgz#24de9fba827e3b4ae44dc8b20256a379160052ad" - integrity sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ== - dependencies: - whatwg-url "^5.0.0" - -node-gyp-build-optional-packages@5.0.3: - version "5.0.3" - resolved "https://registry.yarnpkg.com/node-gyp-build-optional-packages/-/node-gyp-build-optional-packages-5.0.3.tgz#92a89d400352c44ad3975010368072b41ad66c17" - integrity sha512-k75jcVzk5wnnc/FMxsf4udAoTEUv2jY3ycfdSd3yWu6Cnd1oee6/CfZJApyscA4FJOmdoixWwiwOyf16RzD5JA== - -node-gyp-build@^4.2.3, node-gyp-build@^4.3.0: - version "4.3.0" - resolved "https://registry.yarnpkg.com/node-gyp-build/-/node-gyp-build-4.3.0.tgz#9f256b03e5826150be39c764bf51e993946d71a3" - integrity sha512-iWjXZvmboq0ja1pUGULQBexmxq8CV4xBhX7VDOTbL7ZR4FOowwY/VOtRxBN/yKxmdGoIp4j5ysNT4u3S2pDQ3Q== - -node-releases@^2.0.2: - version "2.0.2" - resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-2.0.2.tgz#7139fe71e2f4f11b47d4d2986aaf8c48699e0c01" - integrity sha512-XxYDdcQ6eKqp/YjI+tb2C5WM2LgjnZrfYg4vgQt49EK268b6gYCHsBLrK2qvJo4FmCtqmKezb0WZFK4fkrZNsg== - -npm-bundled@^1.1.1: - version "1.1.2" - resolved "https://registry.yarnpkg.com/npm-bundled/-/npm-bundled-1.1.2.tgz#944c78789bd739035b70baa2ca5cc32b8d860bc1" - integrity sha512-x5DHup0SuyQcmL3s7Rx/YQ8sbw/Hzg0rj48eN0dV7hf5cmQq5PXIeioroH3raV1QC1yh3uTYuMThvEQF3iKgGQ== - dependencies: - npm-normalize-package-bin "^1.0.1" - -npm-normalize-package-bin@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/npm-normalize-package-bin/-/npm-normalize-package-bin-1.0.1.tgz#6e79a41f23fd235c0623218228da7d9c23b8f6e2" - integrity sha512-EPfafl6JL5/rU+ot6P3gRSCpPDW5VmIzX959Ob1+ySFUuuYHWHekXpwdUZcKP5C+DS4GEtdJluwBjnsNDl+fSA== - -npm-packlist@^2.1.5: - version "2.2.2" - resolved "https://registry.yarnpkg.com/npm-packlist/-/npm-packlist-2.2.2.tgz#076b97293fa620f632833186a7a8f65aaa6148c8" - integrity sha512-Jt01acDvJRhJGthnUJVF/w6gumWOZxO7IkpY/lsX9//zqQgnF7OJaxgQXcerd4uQOLu7W5bkb4mChL9mdfm+Zg== - dependencies: - glob "^7.1.6" - ignore-walk "^3.0.3" - npm-bundled "^1.1.1" - npm-normalize-package-bin "^1.0.1" - -nth-check@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/nth-check/-/nth-check-2.0.1.tgz#2efe162f5c3da06a28959fbd3db75dbeea9f0fc2" - integrity sha512-it1vE95zF6dTT9lBsYbxvqh0Soy4SPowchj0UBGj/V6cTPnXXtQOPUbhZ6CmGzAD/rW22LQK6E96pcdJXk4A4w== - dependencies: - boolbase "^1.0.0" - -nullthrows@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/nullthrows/-/nullthrows-1.1.1.tgz#7818258843856ae971eae4208ad7d7eb19a431b1" - integrity sha512-2vPPEi+Z7WqML2jZYddDIfy5Dqb0r2fze2zTxNNknZaFpVHU3mFB3R+DWeJWGVx0ecvttSGlJTI+WG+8Z4cDWw== - -once@^1.3.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" - integrity sha1-WDsap3WWHUsROsF9nFC6753Xa9E= - dependencies: - wrappy "1" - -ordered-binary@^1.2.4: - version "1.2.4" - resolved "https://registry.yarnpkg.com/ordered-binary/-/ordered-binary-1.2.4.tgz#51d3a03af078a0bdba6c7bc8f4fedd1f5d45d83e" - integrity sha512-A/csN0d3n+igxBPfUrjbV5GC69LWj2pjZzAAeeHXLukQ4+fytfP4T1Lg0ju7MSPSwq7KtHkGaiwO8URZN5IpLg== - -os-homedir@^1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/os-homedir/-/os-homedir-1.0.2.tgz#ffbc4988336e0e833de0c168c7ef152121aa7fb3" - integrity sha1-/7xJiDNuDoM94MFox+8VISGqf7M= - -os-tmpdir@^1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274" - integrity sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ= - -parcel@~2.8.3: - version "2.8.3" - resolved "https://registry.yarnpkg.com/parcel/-/parcel-2.8.3.tgz#1ff71d7317274fd367379bc7310a52c6b75d30c2" - integrity sha512-5rMBpbNE72g6jZvkdR5gS2nyhwIXaJy8i65osOqs/+5b7zgf3eMKgjSsDrv6bhz3gzifsba6MBJiZdBckl+vnA== - dependencies: - "@parcel/config-default" "2.8.3" - "@parcel/core" "2.8.3" - "@parcel/diagnostic" "2.8.3" - "@parcel/events" "2.8.3" - "@parcel/fs" "2.8.3" - "@parcel/logger" "2.8.3" - "@parcel/package-manager" "2.8.3" - "@parcel/reporter-cli" "2.8.3" - "@parcel/reporter-dev-server" "2.8.3" - "@parcel/utils" "2.8.3" - chalk "^4.1.0" - commander "^7.0.0" - get-port "^4.2.0" - v8-compile-cache "^2.0.0" - -parent-module@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/parent-module/-/parent-module-1.0.1.tgz#691d2709e78c79fae3a156622452d00762caaaa2" - integrity sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g== - dependencies: - callsites "^3.0.0" - -parse-json@^5.0.0: - version "5.2.0" - resolved "https://registry.yarnpkg.com/parse-json/-/parse-json-5.2.0.tgz#c76fc66dee54231c962b22bcc8a72cf2f99753cd" - integrity sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg== - dependencies: - "@babel/code-frame" "^7.0.0" - error-ex "^1.3.1" - json-parse-even-better-errors "^2.3.0" - lines-and-columns "^1.1.6" - -path-is-absolute@^1.0.0, path-is-absolute@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" - integrity sha1-F0uSaHNVNP+8es5r9TpanhtcX18= - -path-key@^3.1.0: - version "3.1.1" - resolved "https://registry.yarnpkg.com/path-key/-/path-key-3.1.1.tgz#581f6ade658cbba65a0d3380de7753295054f375" - integrity sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q== - -path-parse@^1.0.7: - version "1.0.7" - resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.7.tgz#fbc114b60ca42b30d9daf5858e4bd68bbedb6735" - integrity sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw== - -path-type@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/path-type/-/path-type-4.0.0.tgz#84ed01c0a7ba380afe09d90a8c180dcd9d03043b" - integrity sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw== - -picocolors@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/picocolors/-/picocolors-1.0.0.tgz#cb5bdc74ff3f51892236eaf79d68bc44564ab81c" - integrity sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ== - -picomatch@^2.3.1: - version "2.3.1" - resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42" - integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA== - -postcss-value-parser@^4.2.0: - version "4.2.0" - resolved "https://registry.yarnpkg.com/postcss-value-parser/-/postcss-value-parser-4.2.0.tgz#723c09920836ba6d3e5af019f92bc0971c02e514" - integrity sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ== - -posthtml-parser@^0.10.1: - version "0.10.2" - resolved "https://registry.yarnpkg.com/posthtml-parser/-/posthtml-parser-0.10.2.tgz#df364d7b179f2a6bf0466b56be7b98fd4e97c573" - integrity sha512-PId6zZ/2lyJi9LiKfe+i2xv57oEjJgWbsHGGANwos5AvdQp98i6AtamAl8gzSVFGfQ43Glb5D614cvZf012VKg== - dependencies: - htmlparser2 "^7.1.1" - -posthtml-parser@^0.11.0: - version "0.11.0" - resolved "https://registry.yarnpkg.com/posthtml-parser/-/posthtml-parser-0.11.0.tgz#25d1c7bf811ea83559bc4c21c189a29747a24b7a" - integrity sha512-QecJtfLekJbWVo/dMAA+OSwY79wpRmbqS5TeXvXSX+f0c6pW4/SE6inzZ2qkU7oAMCPqIDkZDvd/bQsSFUnKyw== - dependencies: - htmlparser2 "^7.1.1" - -posthtml-render@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/posthtml-render/-/posthtml-render-3.0.0.tgz#97be44931496f495b4f07b99e903cc70ad6a3205" - integrity sha512-z+16RoxK3fUPgwaIgH9NGnK1HKY9XIDpydky5eQGgAFVXTCSezalv9U2jQuNV+Z9qV1fDWNzldcw4eK0SSbqKA== - dependencies: - is-json "^2.0.1" - -posthtml@^0.16.4, posthtml@^0.16.5: - version "0.16.6" - resolved "https://registry.yarnpkg.com/posthtml/-/posthtml-0.16.6.tgz#e2fc407f67a64d2fa3567afe770409ffdadafe59" - integrity sha512-JcEmHlyLK/o0uGAlj65vgg+7LIms0xKXe60lcDOTU7oVX/3LuEuLwrQpW3VJ7de5TaFKiW4kWkaIpJL42FEgxQ== - dependencies: - posthtml-parser "^0.11.0" - posthtml-render "^3.0.0" - -private@^0.1.6, private@^0.1.8: - version "0.1.8" - resolved "https://registry.yarnpkg.com/private/-/private-0.1.8.tgz#2381edb3689f7a53d653190060fcf822d2f368ff" - integrity sha512-VvivMrbvd2nKkiG38qjULzlc+4Vx4wm/whI9pQD35YrARNnhxeiRktSOhSukRLFNlzg6Br/cJPet5J/u19r/mg== - -react-error-overlay@6.0.9: - version "6.0.9" - resolved "https://registry.yarnpkg.com/react-error-overlay/-/react-error-overlay-6.0.9.tgz#3c743010c9359608c375ecd6bc76f35d93995b0a" - integrity sha512-nQTTcUu+ATDbrSD1BZHr5kgSD4oF8OFjxun8uAaL8RwPBacGBNPf/yAuVVdx17N8XNzRDMrZ9XcKZHCjPW+9ew== - -react-refresh@^0.9.0: - version "0.9.0" - resolved "https://registry.yarnpkg.com/react-refresh/-/react-refresh-0.9.0.tgz#71863337adc3e5c2f8a6bfddd12ae3bfe32aafbf" - integrity sha512-Gvzk7OZpiqKSkxsQvO/mbTN1poglhmAV7gR/DdIrRrSMXraRQQlfikRJOr3Nb9GTMPC5kof948Zy6jJZIFtDvQ== - -regenerate@^1.2.1: - version "1.4.2" - resolved "https://registry.yarnpkg.com/regenerate/-/regenerate-1.4.2.tgz#b9346d8827e8f5a32f7ba29637d398b69014848a" - integrity sha512-zrceR/XhGYU/d/opr2EKO7aRHUeiBI8qjtfHqADTwZd6Szfy16la6kqD0MIUs5z5hx6AaKa+PixpPrR289+I0A== - -regenerator-runtime@^0.10.5: - version "0.10.5" - resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.10.5.tgz#336c3efc1220adcedda2c9fab67b5a7955a33658" - integrity sha1-M2w+/BIgrc7dosn6tntaeVWjNlg= - -regenerator-runtime@^0.11.0: - version "0.11.1" - resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz#be05ad7f9bf7d22e056f9726cee5017fbf19e2e9" - integrity sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg== - -regenerator-runtime@^0.13.7: - version "0.13.9" - resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.9.tgz#8925742a98ffd90814988d7566ad30ca3b263b52" - integrity sha512-p3VT+cOEgxFsRRA9X4lkI1E+k2/CtnKtU4gcxyaCUreilL/vqI6CdZ3wxVUx3UOUg+gnUOQQcRI7BmSI656MYA== - -regenerator-transform@^0.10.0: - version "0.10.1" - resolved "https://registry.yarnpkg.com/regenerator-transform/-/regenerator-transform-0.10.1.tgz#1e4996837231da8b7f3cf4114d71b5691a0680dd" - integrity sha512-PJepbvDbuK1xgIgnau7Y90cwaAmO/LCLMI2mPvaXq2heGMR3aWW5/BQvYrhJ8jgmQjXewXvBjzfqKcVOmhjZ6Q== - dependencies: - babel-runtime "^6.18.0" - babel-types "^6.19.0" - private "^0.1.6" - -regexpu-core@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/regexpu-core/-/regexpu-core-2.0.0.tgz#49d038837b8dcf8bfa5b9a42139938e6ea2ae240" - integrity sha1-SdA4g3uNz4v6W5pCE5k45uoq4kA= - dependencies: - regenerate "^1.2.1" - regjsgen "^0.2.0" - regjsparser "^0.1.4" - -regjsgen@^0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/regjsgen/-/regjsgen-0.2.0.tgz#6c016adeac554f75823fe37ac05b92d5a4edb1f7" - integrity sha1-bAFq3qxVT3WCP+N6wFuS1aTtsfc= - -regjsparser@^0.1.4: - version "0.1.5" - resolved "https://registry.yarnpkg.com/regjsparser/-/regjsparser-0.1.5.tgz#7ee8f84dc6fa792d3fd0ae228d24bd949ead205c" - integrity sha1-fuj4Tcb6eS0/0K4ijSS9lJ6tIFw= - dependencies: - jsesc "~0.5.0" - -repeating@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/repeating/-/repeating-2.0.1.tgz#5214c53a926d3552707527fbab415dbc08d06dda" - integrity sha1-UhTFOpJtNVJwdSf7q0FdvAjQbdo= - dependencies: - is-finite "^1.0.0" - -require-directory@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42" - integrity sha1-jGStX9MNqxyXbiNE/+f3kqam30I= - -resolve-from@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-4.0.0.tgz#4abcd852ad32dd7baabfe9b40e00a36db5f392e6" - integrity sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g== - -resolve@^1.1.6: - version "1.22.0" - resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.22.0.tgz#5e0b8c67c15df57a89bdbabe603a002f21731198" - integrity sha512-Hhtrw0nLeSrFQ7phPp4OOcVjLPIeMnRlr5mcnVuMe7M/7eBn98A3hmFRLoFo3DLZkivSYwhRUJTyPyWAk56WLw== - dependencies: - is-core-module "^2.8.1" - path-parse "^1.0.7" - supports-preserve-symlinks-flag "^1.0.0" - -safe-buffer@^5.0.1: - version "5.2.1" - resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" - integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== - -safe-buffer@~5.1.1: - version "5.1.2" - resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" - integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g== - -seedrandom@^3.0.5: - version "3.0.5" - resolved "https://registry.yarnpkg.com/seedrandom/-/seedrandom-3.0.5.tgz#54edc85c95222525b0c7a6f6b3543d8e0b3aa0a7" - integrity sha512-8OwmbklUNzwezjGInmZ+2clQmExQPvomqjL7LFqOYqtmuxRgQYqOD3mHaU+MvZn5FLUeVxVfQjwLZW/n/JFuqg== - -semver@^5.3.0, semver@^5.7.0, semver@^5.7.1: - version "5.7.1" - resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" - integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ== - -shebang-command@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-2.0.0.tgz#ccd0af4f8835fbdc265b82461aaf0c36663f34ea" - integrity sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA== - dependencies: - shebang-regex "^3.0.0" - -shebang-regex@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-3.0.0.tgz#ae16f1644d873ecad843b0307b143362d4c42172" - integrity sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A== - -slash@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/slash/-/slash-1.0.0.tgz#c41f2f6c39fc16d1cd17ad4b5d896114ae470d55" - integrity sha1-xB8vbDn8FtHNF61LXYlhFK5HDVU= - -source-map-support@^0.4.15: - version "0.4.18" - resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.4.18.tgz#0286a6de8be42641338594e97ccea75f0a2c585f" - integrity sha512-try0/JqxPLF9nOjvSta7tVondkP5dwgyLDjVoyMDlmjugT2lRZ1OfsrYTkCd2hkDnJTKRbO/Rl3orm8vlsUzbA== - dependencies: - source-map "^0.5.6" - -source-map-support@~0.5.20: - version "0.5.21" - resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.21.tgz#04fe7c7f9e1ed2d662233c28cb2b35b9f63f6e4f" - integrity sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w== - dependencies: - buffer-from "^1.0.0" - source-map "^0.6.0" - -source-map@^0.5.6, source-map@^0.5.7: - version "0.5.7" - resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" - integrity sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w= - -source-map@^0.6.0, source-map@^0.6.1: - version "0.6.1" - resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" - integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== - -source-map@~0.7.2: - version "0.7.3" - resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.7.3.tgz#5302f8169031735226544092e64981f751750383" - integrity sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ== - -srcset@4: - version "4.0.0" - resolved "https://registry.yarnpkg.com/srcset/-/srcset-4.0.0.tgz#336816b665b14cd013ba545b6fe62357f86e65f4" - integrity sha512-wvLeHgcVHKO8Sc/H/5lkGreJQVeYMm9rlmt8PuR1xE31rIuXhuzznUUqAt8MqLhB3MqJdFzlNAfpcWnxiFUcPw== - -stable@^0.1.8: - version "0.1.8" - resolved "https://registry.yarnpkg.com/stable/-/stable-0.1.8.tgz#836eb3c8382fe2936feaf544631017ce7d47a3cf" - integrity sha512-ji9qxRnOVfcuLDySj9qzhGSEFVobyt1kIOSkj1qZzYLzq7Tos/oUUWvotUPQLlrsidqsK6tBH89Bc9kL5zHA6w== - -string-width@^4.1.0, string-width@^4.2.0: - version "4.2.3" - resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" - integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== - dependencies: - emoji-regex "^8.0.0" - is-fullwidth-code-point "^3.0.0" - strip-ansi "^6.0.1" - -strip-ansi@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-3.0.1.tgz#6a385fb8853d952d5ff05d0e8aaf94278dc63dcf" - integrity sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8= - dependencies: - ansi-regex "^2.0.0" - -strip-ansi@^6.0.0, strip-ansi@^6.0.1: - version "6.0.1" - resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" - integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== - dependencies: - ansi-regex "^5.0.1" - -supports-color@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7" - integrity sha1-U10EXOa2Nj+kARcIRimZXp3zJMc= - -supports-color@^5.3.0: - version "5.5.0" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f" - integrity sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow== - dependencies: - has-flag "^3.0.0" - -supports-color@^7.1.0: - version "7.2.0" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-7.2.0.tgz#1b7dcdcb32b8138801b3e478ba6a51caa89648da" - integrity sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw== - dependencies: - has-flag "^4.0.0" - -supports-preserve-symlinks-flag@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz#6eda4bd344a3c94aea376d4cc31bc77311039e09" - integrity sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w== - -svgo@^2.4.0: - version "2.8.0" - resolved "https://registry.yarnpkg.com/svgo/-/svgo-2.8.0.tgz#4ff80cce6710dc2795f0c7c74101e6764cfccd24" - integrity sha512-+N/Q9kV1+F+UeWYoSiULYo4xYSDQlTgb+ayMobAXPwMnLvop7oxKMo9OzIrX5x3eS4L4f2UHhc9axXwY8DpChg== - dependencies: - "@trysound/sax" "0.2.0" - commander "^7.2.0" - css-select "^4.1.3" - css-tree "^1.1.3" - csso "^4.2.0" - picocolors "^1.0.0" - stable "^0.1.8" - -term-size@^2.2.1: - version "2.2.1" - resolved "https://registry.yarnpkg.com/term-size/-/term-size-2.2.1.tgz#2a6a54840432c2fb6320fea0f415531e90189f54" - integrity sha512-wK0Ri4fOGjv/XPy8SBHZChl8CM7uMc5VML7SqiQ0zG7+J5Vr+RMQDoHa2CNT6KHUnTGIXH34UDMkPzAUyapBZg== - -terser@^5.2.0: - version "5.12.1" - resolved "https://registry.yarnpkg.com/terser/-/terser-5.12.1.tgz#4cf2ebed1f5bceef5c83b9f60104ac4a78b49e9c" - integrity sha512-NXbs+7nisos5E+yXwAD+y7zrcTkMqb0dEJxIGtSKPdCBzopf7ni4odPul2aechpV7EXNvOudYOX2bb5tln1jbQ== - dependencies: - acorn "^8.5.0" - commander "^2.20.0" - source-map "~0.7.2" - source-map-support "~0.5.20" - -timsort@^0.3.0: - version "0.3.0" - resolved "https://registry.yarnpkg.com/timsort/-/timsort-0.3.0.tgz#405411a8e7e6339fe64db9a234de11dc31e02bd4" - integrity sha1-QFQRqOfmM5/mTbmiNN4R3DHgK9Q= - -to-fast-properties@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/to-fast-properties/-/to-fast-properties-1.0.3.tgz#b83571fa4d8c25b82e231b06e3a3055de4ca1a47" - integrity sha1-uDVx+k2MJbguIxsG46MFXeTKGkc= - -to-regex-range@^5.0.1: - version "5.0.1" - resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-5.0.1.tgz#1648c44aae7c8d988a326018ed72f5b4dd0392e4" - integrity sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ== - dependencies: - is-number "^7.0.0" - -tr46@~0.0.3: - version "0.0.3" - resolved "https://registry.yarnpkg.com/tr46/-/tr46-0.0.3.tgz#8184fd347dac9cdc185992f3a6622e14b9d9ab6a" - integrity sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o= - -trim-right@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/trim-right/-/trim-right-1.0.1.tgz#cb2e1203067e0c8de1f614094b9fe45704ea6003" - integrity sha1-yy4SAwZ+DI3h9hQJS5/kVwTqYAM= - -tslib@^2.4.0: - version "2.5.0" - resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.5.0.tgz#42bfed86f5787aeb41d031866c8f402429e0fddf" - integrity sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg== - -type-fest@^0.20.2: - version "0.20.2" - resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.20.2.tgz#1bf207f4b28f91583666cb5fbd327887301cd5f4" - integrity sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ== - -universalify@^0.1.0: - version "0.1.2" - resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.2.tgz#b646f69be3942dabcecc9d6639c80dc105efaa66" - integrity sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg== - -utility-types@^3.10.0: - version "3.10.0" - resolved "https://registry.yarnpkg.com/utility-types/-/utility-types-3.10.0.tgz#ea4148f9a741015f05ed74fd615e1d20e6bed82b" - integrity sha512-O11mqxmi7wMKCo6HKFt5AhO4BwY3VV68YU07tgxfz8zJTIxr4BpsezN49Ffwy9j3ZpwwJp4fkRwjRzq3uWE6Rg== - -v8-compile-cache@^2.0.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz#2de19618c66dc247dcfb6f99338035d8245a2cee" - integrity sha512-l8lCEmLcLYZh4nbunNZvQCJc5pv7+RCwa8q/LdUx8u7lsWvPDKmpodJAJNwkAhJC//dFY48KuIEmjtd4RViDrA== - -weak-lru-cache@^1.2.2: - version "1.2.2" - resolved "https://registry.yarnpkg.com/weak-lru-cache/-/weak-lru-cache-1.2.2.tgz#fdbb6741f36bae9540d12f480ce8254060dccd19" - integrity sha512-DEAoo25RfSYMuTGc9vPJzZcZullwIqRDSI9LOy+fkCJPi6hykCnfKaXTuPBDuXAUcqHXyOgFtHNp/kB2FjYHbw== - -webidl-conversions@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871" - integrity sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE= - -whatwg-url@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-5.0.0.tgz#966454e8765462e37644d3626f6742ce8b70965d" - integrity sha1-lmRU6HZUYuN2RNNib2dCzotwll0= - dependencies: - tr46 "~0.0.3" - webidl-conversions "^3.0.0" - -which@^2.0.1: - version "2.0.2" - resolved "https://registry.yarnpkg.com/which/-/which-2.0.2.tgz#7c6a8dd0a636a0327e10b59c9286eee93f3f51b1" - integrity sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA== - dependencies: - isexe "^2.0.0" - -wrap-ansi@^7.0.0: - version "7.0.0" - resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" - integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== - dependencies: - ansi-styles "^4.0.0" - string-width "^4.1.0" - strip-ansi "^6.0.0" - -wrappy@1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" - integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8= - -xxhash-wasm@^0.4.2: - version "0.4.2" - resolved "https://registry.yarnpkg.com/xxhash-wasm/-/xxhash-wasm-0.4.2.tgz#752398c131a4dd407b5132ba62ad372029be6f79" - integrity sha512-/eyHVRJQCirEkSZ1agRSCwriMhwlyUcFkXD5TPVSLP+IPzjsqMVzZwdoczLp1SoQU0R3dxz1RpIK+4YNQbCVOA== - -y18n@^5.0.5: - version "5.0.8" - resolved "https://registry.yarnpkg.com/y18n/-/y18n-5.0.8.tgz#7f4934d0f7ca8c56f95314939ddcd2dd91ce1d55" - integrity sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA== - -yalc@~1.0.0-pre.27: - version "1.0.0-pre.53" - resolved "https://registry.yarnpkg.com/yalc/-/yalc-1.0.0-pre.53.tgz#c51db2bb924a6908f4cb7e82af78f7e5606810bc" - integrity sha512-tpNqBCpTXplnduzw5XC+FF8zNJ9L/UXmvQyyQj7NKrDNavbJtHvzmZplL5ES/RCnjX7JR7W9wz5GVDXVP3dHUQ== - dependencies: - chalk "^4.1.0" - detect-indent "^6.0.0" - fs-extra "^8.0.1" - glob "^7.1.4" - ignore "^5.0.4" - ini "^2.0.0" - npm-packlist "^2.1.5" - yargs "^16.1.1" - -yaml@^1.10.0: - version "1.10.2" - resolved "https://registry.yarnpkg.com/yaml/-/yaml-1.10.2.tgz#2301c5ffbf12b467de8da2333a459e29e7920e4b" - integrity sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg== - -yargs-parser@^20.2.2: - version "20.2.9" - resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.9.tgz#2eb7dc3b0289718fc295f362753845c41a0c94ee" - integrity sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w== - -yargs@^16.1.1: - version "16.2.0" - resolved "https://registry.yarnpkg.com/yargs/-/yargs-16.2.0.tgz#1c82bf0f6b6a66eafce7ef30e376f49a12477f66" - integrity sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw== - dependencies: - cliui "^7.0.2" - escalade "^3.1.1" - get-caller-file "^2.0.5" - require-directory "^2.1.1" - string-width "^4.2.0" - y18n "^5.0.5" - yargs-parser "^20.2.2" diff --git a/tfjs-master/tfjs-automl/demo/object_detection/index.html b/tfjs-master/tfjs-automl/demo/object_detection/index.html deleted file mode 100644 index 481059045..000000000 --- a/tfjs-master/tfjs-automl/demo/object_detection/index.html +++ /dev/null @@ -1,31 +0,0 @@ - - - - AutoML Object detection demo - - - -
- - - - -
- - - diff --git a/tfjs-master/tfjs-automl/demo/object_detection/index.js b/tfjs-master/tfjs-automl/demo/object_detection/index.js deleted file mode 100644 index f8fe56605..000000000 --- a/tfjs-master/tfjs-automl/demo/object_detection/index.js +++ /dev/null @@ -1,72 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import '@tensorflow/tfjs-backend-webgl'; -import * as automl from '@tensorflow/tfjs-automl'; - -const MODEL_URL = - 'https://storage.googleapis.com/tfjs-testing/tfjs-automl/object_detection/model.json'; - -async function run() { - const model = await automl.loadObjectDetection(MODEL_URL); - const image = document.getElementById('salad'); - // These are the default options. - const options = {score: 0.5, iou: 0.5, topk: 20}; - const predictions = await model.detect(image, options); - - // Show the resulting object on the page. - const pre = document.createElement('pre'); - pre.textContent = JSON.stringify(predictions, null, 2); - document.body.append(pre); - - drawBoxes(predictions); -} - -// Overlays boxes with labels onto the image using `rect` and `text` svg -// elements. -function drawBoxes(predictions) { - const svg = document.querySelector('svg'); - predictions.forEach(prediction => { - const {box, label, score} = prediction; - const {left, top, width, height} = box; - const rect = document.createElementNS('http://www.w3.org/2000/svg', 'rect'); - rect.setAttribute('width', width); - rect.setAttribute('height', height); - rect.setAttribute('x', left); - rect.setAttribute('y', top); - rect.setAttribute('class', 'box'); - const text = document.createElementNS('http://www.w3.org/2000/svg', 'text'); - text.setAttribute('x', left + width / 2); - text.setAttribute('y', top); - text.setAttribute('dy', 12); - text.setAttribute('class', 'label'); - text.textContent = `${label}: ${score.toFixed(3)}`; - svg.appendChild(rect); - svg.appendChild(text); - const textBBox = text.getBBox(); - const textRect = - document.createElementNS('http://www.w3.org/2000/svg', 'rect'); - textRect.setAttribute('x', textBBox.x); - textRect.setAttribute('y', textBBox.y); - textRect.setAttribute('width', textBBox.width); - textRect.setAttribute('height', textBBox.height); - textRect.setAttribute('class', 'label-rect'); - svg.insertBefore(textRect, text); - }); -} - -run(); diff --git a/tfjs-master/tfjs-automl/demo/object_detection/package.json b/tfjs-master/tfjs-automl/demo/object_detection/package.json deleted file mode 100644 index f713c139c..000000000 --- a/tfjs-master/tfjs-automl/demo/object_detection/package.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "name": "automl-object-detection-demo", - "version": "0.0.1", - "private": true, - "description": "Object detection demo using the AutoML NPM library", - "main": "index.js", - "browserslist": "> 0.25%, not dead", - "scripts": { - "watch": "cross-env NODE_ENV=development parcel index.html --no-hmr --open ", - "build": "cross-env NODE_ENV=production parcel build index.html --public-url ./" - }, - "devDependencies": { - "clang-format": "~1.8.0", - "cross-env": "^7.0.3", - "parcel": "~2.8.3", - "yalc": "~1.0.0-pre.53" - }, - "license": "Apache-2.0", - "dependencies": { - "@tensorflow/tfjs-automl": "link:../../", - "@tensorflow/tfjs-backend-webgl": "^4.2.0", - "@tensorflow/tfjs-converter": "^4.2.0", - "@tensorflow/tfjs-core": "^4.2.0" - }, - "resolutions": { - "minimist": "1.2.6" - } -} diff --git a/tfjs-master/tfjs-automl/demo/object_detection/yarn.lock b/tfjs-master/tfjs-automl/demo/object_detection/yarn.lock deleted file mode 100644 index 254791ad8..000000000 --- a/tfjs-master/tfjs-automl/demo/object_detection/yarn.lock +++ /dev/null @@ -1,1870 +0,0 @@ -# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. -# yarn lockfile v1 - - -"@babel/code-frame@^7.0.0": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.16.7.tgz#44416b6bd7624b998f5b1af5d470856c40138789" - integrity sha512-iAXqUn8IIeBTNd72xsFlgaXHkMBMt6y4HJp1tIaK465CWLT/fG1aqB7ykr95gHHmlBdGbFeWWfyB4NJJ0nmeIg== - dependencies: - "@babel/highlight" "^7.16.7" - -"@babel/helper-validator-identifier@^7.16.7": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz#e8c602438c4a8195751243da9031d1607d247cad" - integrity sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw== - -"@babel/highlight@^7.16.7": - version "7.16.10" - resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.16.10.tgz#744f2eb81579d6eea753c227b0f570ad785aba88" - integrity sha512-5FnTQLSLswEj6IkgVw5KusNUUFY9ZGqe/TRFnP/BKYHYgfh7tc+C7mwiy95/yNP7Dh9x580Vv8r7u7ZfTBFxdw== - dependencies: - "@babel/helper-validator-identifier" "^7.16.7" - chalk "^2.0.0" - js-tokens "^4.0.0" - -"@jridgewell/gen-mapping@^0.3.0": - version "0.3.2" - resolved "https://registry.yarnpkg.com/@jridgewell/gen-mapping/-/gen-mapping-0.3.2.tgz#c1aedc61e853f2bb9f5dfe6d4442d3b565b253b9" - integrity sha512-mh65xKQAzI6iBcFzwv28KVWSmCkdRBWoOh+bYQGW3+6OZvbbN3TqMGo5hqYxQniRcH9F2VZIoJCm4pa3BPDK/A== - dependencies: - "@jridgewell/set-array" "^1.0.1" - "@jridgewell/sourcemap-codec" "^1.4.10" - "@jridgewell/trace-mapping" "^0.3.9" - -"@jridgewell/resolve-uri@^3.0.3": - version "3.1.0" - resolved "https://registry.yarnpkg.com/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz#2203b118c157721addfe69d47b70465463066d78" - integrity sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w== - -"@jridgewell/set-array@^1.0.1": - version "1.1.2" - resolved "https://registry.yarnpkg.com/@jridgewell/set-array/-/set-array-1.1.2.tgz#7c6cf998d6d20b914c0a55a91ae928ff25965e72" - integrity sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw== - -"@jridgewell/source-map@^0.3.2": - version "0.3.2" - resolved "https://registry.yarnpkg.com/@jridgewell/source-map/-/source-map-0.3.2.tgz#f45351aaed4527a298512ec72f81040c998580fb" - integrity sha512-m7O9o2uR8k2ObDysZYzdfhb08VuEml5oWGiosa1VdaPZ/A6QyPkAJuwN0Q1lhULOf6B7MtQmHENS743hWtCrgw== - dependencies: - "@jridgewell/gen-mapping" "^0.3.0" - "@jridgewell/trace-mapping" "^0.3.9" - -"@jridgewell/sourcemap-codec@^1.4.10": - version "1.4.14" - resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz#add4c98d341472a289190b424efbdb096991bb24" - integrity sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw== - -"@jridgewell/trace-mapping@^0.3.9": - version "0.3.14" - resolved "https://registry.yarnpkg.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.14.tgz#b231a081d8f66796e475ad588a1ef473112701ed" - integrity sha512-bJWEfQ9lPTvm3SneWwRFVLzrh6nhjwqw7TUFFBEMzwvg7t7PCDenf2lDwqo4NQXzdpgBXyFgDWnQA+2vkruksQ== - dependencies: - "@jridgewell/resolve-uri" "^3.0.3" - "@jridgewell/sourcemap-codec" "^1.4.10" - -"@lezer/common@^0.15.0", "@lezer/common@^0.15.7": - version "0.15.12" - resolved "https://registry.yarnpkg.com/@lezer/common/-/common-0.15.12.tgz#2f21aec551dd5fd7d24eb069f90f54d5bc6ee5e9" - integrity sha512-edfwCxNLnzq5pBA/yaIhwJ3U3Kz8VAUOTRg0hhxaizaI1N+qxV7EXDv/kLCkLeq2RzSFvxexlaj5Mzfn2kY0Ig== - -"@lezer/lr@^0.15.4": - version "0.15.8" - resolved "https://registry.yarnpkg.com/@lezer/lr/-/lr-0.15.8.tgz#1564a911e62b0a0f75ca63794a6aa8c5dc63db21" - integrity sha512-bM6oE6VQZ6hIFxDNKk8bKPa14hqFrV07J/vHGOeiAbJReIaQXmkVb6xQu4MR+JBTLa5arGRyAAjJe1qaQt3Uvg== - dependencies: - "@lezer/common" "^0.15.0" - -"@lmdb/lmdb-darwin-arm64@2.5.2": - version "2.5.2" - resolved "https://registry.yarnpkg.com/@lmdb/lmdb-darwin-arm64/-/lmdb-darwin-arm64-2.5.2.tgz#bc66fa43286b5c082e8fee0eacc17995806b6fbe" - integrity sha512-+F8ioQIUN68B4UFiIBYu0QQvgb9FmlKw2ctQMSBfW2QBrZIxz9vD9jCGqTCPqZBRbPHAS/vG1zSXnKqnS2ch/A== - -"@lmdb/lmdb-darwin-x64@2.5.2": - version "2.5.2" - resolved "https://registry.yarnpkg.com/@lmdb/lmdb-darwin-x64/-/lmdb-darwin-x64-2.5.2.tgz#89d8390041bce6bab24a82a20392be22faf54ffc" - integrity sha512-KvPH56KRLLx4KSfKBx0m1r7GGGUMXm0jrKmNE7plbHlesZMuPJICtn07HYgQhj1LNsK7Yqwuvnqh1QxhJnF1EA== - -"@lmdb/lmdb-linux-arm64@2.5.2": - version "2.5.2" - resolved "https://registry.yarnpkg.com/@lmdb/lmdb-linux-arm64/-/lmdb-linux-arm64-2.5.2.tgz#14fe4c96c2bb1285f93797f45915fa35ee047268" - integrity sha512-aLl89VHL/wjhievEOlPocoefUyWdvzVrcQ/MHQYZm2JfV1jUsrbr/ZfkPPUFvZBf+VSE+Q0clWs9l29PCX1hTQ== - -"@lmdb/lmdb-linux-arm@2.5.2": - version "2.5.2" - resolved "https://registry.yarnpkg.com/@lmdb/lmdb-linux-arm/-/lmdb-linux-arm-2.5.2.tgz#05bde4573ab10cf21827339fe687148f2590cfa1" - integrity sha512-5kQAP21hAkfW5Bl+e0P57dV4dGYnkNIpR7f/GAh6QHlgXx+vp/teVj4PGRZaKAvt0GX6++N6hF8NnGElLDuIDw== - -"@lmdb/lmdb-linux-x64@2.5.2": - version "2.5.2" - resolved "https://registry.yarnpkg.com/@lmdb/lmdb-linux-x64/-/lmdb-linux-x64-2.5.2.tgz#d2f85afd857d2c33d2caa5b057944574edafcfee" - integrity sha512-xUdUfwDJLGjOUPH3BuPBt0NlIrR7f/QHKgu3GZIXswMMIihAekj2i97oI0iWG5Bok/b+OBjHPfa8IU9velnP/Q== - -"@lmdb/lmdb-win32-x64@2.5.2": - version "2.5.2" - resolved "https://registry.yarnpkg.com/@lmdb/lmdb-win32-x64/-/lmdb-win32-x64-2.5.2.tgz#28f643fbc0bec30b07fbe95b137879b6b4d1c9c5" - integrity sha512-zrBczSbXKxEyK2ijtbRdICDygRqWSRPpZMN5dD1T8VMEW5RIhIbwFWw2phDRXuBQdVDpSjalCIUMWMV2h3JaZA== - -"@mischnic/json-sourcemap@^0.1.0": - version "0.1.0" - resolved "https://registry.yarnpkg.com/@mischnic/json-sourcemap/-/json-sourcemap-0.1.0.tgz#38af657be4108140a548638267d02a2ea3336507" - integrity sha512-dQb3QnfNqmQNYA4nFSN/uLaByIic58gOXq4Y4XqLOWmOrw73KmJPt/HLyG0wvn1bnR6mBKs/Uwvkh+Hns1T0XA== - dependencies: - "@lezer/common" "^0.15.7" - "@lezer/lr" "^0.15.4" - json5 "^2.2.1" - -"@parcel/bundler-default@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/bundler-default/-/bundler-default-2.8.3.tgz#d64739dbc2dbd59d6629861bf77a8083aced5229" - integrity sha512-yJvRsNWWu5fVydsWk3O2L4yIy3UZiKWO2cPDukGOIWMgp/Vbpp+2Ct5IygVRtE22bnseW/E/oe0PV3d2IkEJGg== - dependencies: - "@parcel/diagnostic" "2.8.3" - "@parcel/graph" "2.8.3" - "@parcel/hash" "2.8.3" - "@parcel/plugin" "2.8.3" - "@parcel/utils" "2.8.3" - nullthrows "^1.1.1" - -"@parcel/cache@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/cache/-/cache-2.8.3.tgz#169e130cf59913c0ed9fadce1a450e68f710e16f" - integrity sha512-k7xv5vSQrJLdXuglo+Hv3yF4BCSs1tQ/8Vbd6CHTkOhf7LcGg6CPtLw053R/KdMpd/4GPn0QrAsOLdATm1ELtQ== - dependencies: - "@parcel/fs" "2.8.3" - "@parcel/logger" "2.8.3" - "@parcel/utils" "2.8.3" - lmdb "2.5.2" - -"@parcel/codeframe@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/codeframe/-/codeframe-2.8.3.tgz#84fb529ef70def7f5bc64f6c59b18d24826f5fcc" - integrity sha512-FE7sY53D6n/+2Pgg6M9iuEC6F5fvmyBkRE4d9VdnOoxhTXtkEqpqYgX7RJ12FAQwNlxKq4suBJQMgQHMF2Kjeg== - dependencies: - chalk "^4.1.0" - -"@parcel/compressor-raw@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/compressor-raw/-/compressor-raw-2.8.3.tgz#301753df8c6de967553149639e8a4179b88f0c95" - integrity sha512-bVDsqleBUxRdKMakWSlWC9ZjOcqDKE60BE+Gh3JSN6WJrycJ02P5wxjTVF4CStNP/G7X17U+nkENxSlMG77ySg== - dependencies: - "@parcel/plugin" "2.8.3" - -"@parcel/config-default@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/config-default/-/config-default-2.8.3.tgz#9a43486e7c702e96c68052c37b79098d7240e35b" - integrity sha512-o/A/mbrO6X/BfGS65Sib8d6SSG45NYrNooNBkH/o7zbOBSRQxwyTlysleK1/3Wa35YpvFyLOwgfakqCtbGy4fw== - dependencies: - "@parcel/bundler-default" "2.8.3" - "@parcel/compressor-raw" "2.8.3" - "@parcel/namer-default" "2.8.3" - "@parcel/optimizer-css" "2.8.3" - "@parcel/optimizer-htmlnano" "2.8.3" - "@parcel/optimizer-image" "2.8.3" - "@parcel/optimizer-svgo" "2.8.3" - "@parcel/optimizer-terser" "2.8.3" - "@parcel/packager-css" "2.8.3" - "@parcel/packager-html" "2.8.3" - "@parcel/packager-js" "2.8.3" - "@parcel/packager-raw" "2.8.3" - "@parcel/packager-svg" "2.8.3" - "@parcel/reporter-dev-server" "2.8.3" - "@parcel/resolver-default" "2.8.3" - "@parcel/runtime-browser-hmr" "2.8.3" - "@parcel/runtime-js" "2.8.3" - "@parcel/runtime-react-refresh" "2.8.3" - "@parcel/runtime-service-worker" "2.8.3" - "@parcel/transformer-babel" "2.8.3" - "@parcel/transformer-css" "2.8.3" - "@parcel/transformer-html" "2.8.3" - "@parcel/transformer-image" "2.8.3" - "@parcel/transformer-js" "2.8.3" - "@parcel/transformer-json" "2.8.3" - "@parcel/transformer-postcss" "2.8.3" - "@parcel/transformer-posthtml" "2.8.3" - "@parcel/transformer-raw" "2.8.3" - "@parcel/transformer-react-refresh-wrap" "2.8.3" - "@parcel/transformer-svg" "2.8.3" - -"@parcel/core@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/core/-/core-2.8.3.tgz#22a69f36095d53736ab10bf42697d9aa5f4e382b" - integrity sha512-Euf/un4ZAiClnlUXqPB9phQlKbveU+2CotZv7m7i+qkgvFn5nAGnrV4h1OzQU42j9dpgOxWi7AttUDMrvkbhCQ== - dependencies: - "@mischnic/json-sourcemap" "^0.1.0" - "@parcel/cache" "2.8.3" - "@parcel/diagnostic" "2.8.3" - "@parcel/events" "2.8.3" - "@parcel/fs" "2.8.3" - "@parcel/graph" "2.8.3" - "@parcel/hash" "2.8.3" - "@parcel/logger" "2.8.3" - "@parcel/package-manager" "2.8.3" - "@parcel/plugin" "2.8.3" - "@parcel/source-map" "^2.1.1" - "@parcel/types" "2.8.3" - "@parcel/utils" "2.8.3" - "@parcel/workers" "2.8.3" - abortcontroller-polyfill "^1.1.9" - base-x "^3.0.8" - browserslist "^4.6.6" - clone "^2.1.1" - dotenv "^7.0.0" - dotenv-expand "^5.1.0" - json5 "^2.2.0" - msgpackr "^1.5.4" - nullthrows "^1.1.1" - semver "^5.7.1" - -"@parcel/diagnostic@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/diagnostic/-/diagnostic-2.8.3.tgz#d560276d5d2804b48beafa1feaf3fc6b2ac5e39d" - integrity sha512-u7wSzuMhLGWZjVNYJZq/SOViS3uFG0xwIcqXw12w54Uozd6BH8JlhVtVyAsq9kqnn7YFkw6pXHqAo5Tzh4FqsQ== - dependencies: - "@mischnic/json-sourcemap" "^0.1.0" - nullthrows "^1.1.1" - -"@parcel/events@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/events/-/events-2.8.3.tgz#205f8d874e6ecc2cbdb941bf8d54bae669e571af" - integrity sha512-hoIS4tAxWp8FJk3628bsgKxEvR7bq2scCVYHSqZ4fTi/s0+VymEATrRCUqf+12e5H47uw1/ZjoqrGtBI02pz4w== - -"@parcel/fs-search@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/fs-search/-/fs-search-2.8.3.tgz#1c7d812c110b808758f44c56e61dfffdb09e9451" - integrity sha512-DJBT2N8knfN7Na6PP2mett3spQLTqxFrvl0gv+TJRp61T8Ljc4VuUTb0hqBj+belaASIp3Q+e8+SgaFQu7wLiQ== - dependencies: - detect-libc "^1.0.3" - -"@parcel/fs@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/fs/-/fs-2.8.3.tgz#80536afe877fc8a2bd26be5576b9ba27bb4c5754" - integrity sha512-y+i+oXbT7lP0e0pJZi/YSm1vg0LDsbycFuHZIL80pNwdEppUAtibfJZCp606B7HOjMAlNZOBo48e3hPG3d8jgQ== - dependencies: - "@parcel/fs-search" "2.8.3" - "@parcel/types" "2.8.3" - "@parcel/utils" "2.8.3" - "@parcel/watcher" "^2.0.7" - "@parcel/workers" "2.8.3" - -"@parcel/graph@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/graph/-/graph-2.8.3.tgz#00ffe8ec032e74fee57199e54529f1da7322571d" - integrity sha512-26GL8fYZPdsRhSXCZ0ZWliloK6DHlMJPWh6Z+3VVZ5mnDSbYg/rRKWmrkhnr99ZWmL9rJsv4G74ZwvDEXTMPBg== - dependencies: - nullthrows "^1.1.1" - -"@parcel/hash@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/hash/-/hash-2.8.3.tgz#bc2499a27395169616cad2a99e19e69b9098f6e9" - integrity sha512-FVItqzjWmnyP4ZsVgX+G00+6U2IzOvqDtdwQIWisCcVoXJFCqZJDy6oa2qDDFz96xCCCynjRjPdQx2jYBCpfYw== - dependencies: - detect-libc "^1.0.3" - xxhash-wasm "^0.4.2" - -"@parcel/logger@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/logger/-/logger-2.8.3.tgz#e14e4debafb3ca9e87c07c06780f9afc38b2712c" - integrity sha512-Kpxd3O/Vs7nYJIzkdmB6Bvp3l/85ydIxaZaPfGSGTYOfaffSOTkhcW9l6WemsxUrlts4za6CaEWcc4DOvaMOPA== - dependencies: - "@parcel/diagnostic" "2.8.3" - "@parcel/events" "2.8.3" - -"@parcel/markdown-ansi@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/markdown-ansi/-/markdown-ansi-2.8.3.tgz#1337d421bb1133ad178f386a8e1b746631bba4a1" - integrity sha512-4v+pjyoh9f5zuU/gJlNvNFGEAb6J90sOBwpKJYJhdWXLZMNFCVzSigxrYO+vCsi8G4rl6/B2c0LcwIMjGPHmFQ== - dependencies: - chalk "^4.1.0" - -"@parcel/namer-default@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/namer-default/-/namer-default-2.8.3.tgz#5304bee74beb4b9c1880781bdbe35be0656372f4" - integrity sha512-tJ7JehZviS5QwnxbARd8Uh63rkikZdZs1QOyivUhEvhN+DddSAVEdQLHGPzkl3YRk0tjFhbqo+Jci7TpezuAMw== - dependencies: - "@parcel/diagnostic" "2.8.3" - "@parcel/plugin" "2.8.3" - nullthrows "^1.1.1" - -"@parcel/node-resolver-core@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/node-resolver-core/-/node-resolver-core-2.8.3.tgz#581df074a27646400b3fed9da95297b616a7db8f" - integrity sha512-12YryWcA5Iw2WNoEVr/t2HDjYR1iEzbjEcxfh1vaVDdZ020PiGw67g5hyIE/tsnG7SRJ0xdRx1fQ2hDgED+0Ww== - dependencies: - "@parcel/diagnostic" "2.8.3" - "@parcel/utils" "2.8.3" - nullthrows "^1.1.1" - semver "^5.7.1" - -"@parcel/optimizer-css@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/optimizer-css/-/optimizer-css-2.8.3.tgz#420a333f4b78f7ff15e69217dfed34421b1143ee" - integrity sha512-JotGAWo8JhuXsQDK0UkzeQB0UR5hDAKvAviXrjqB4KM9wZNLhLleeEAW4Hk8R9smCeQFP6Xg/N/NkLDpqMwT3g== - dependencies: - "@parcel/diagnostic" "2.8.3" - "@parcel/plugin" "2.8.3" - "@parcel/source-map" "^2.1.1" - "@parcel/utils" "2.8.3" - browserslist "^4.6.6" - lightningcss "^1.16.1" - nullthrows "^1.1.1" - -"@parcel/optimizer-htmlnano@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/optimizer-htmlnano/-/optimizer-htmlnano-2.8.3.tgz#a71ab6f0f24160ef9f573266064438eff65e96d0" - integrity sha512-L8/fHbEy8Id2a2E0fwR5eKGlv9VYDjrH9PwdJE9Za9v1O/vEsfl/0T/79/x129l5O0yB6EFQkFa20MiK3b+vOg== - dependencies: - "@parcel/plugin" "2.8.3" - htmlnano "^2.0.0" - nullthrows "^1.1.1" - posthtml "^0.16.5" - svgo "^2.4.0" - -"@parcel/optimizer-image@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/optimizer-image/-/optimizer-image-2.8.3.tgz#ea49b4245b4f7d60b38c7585c6311fb21d341baa" - integrity sha512-SD71sSH27SkCDNUNx9A3jizqB/WIJr3dsfp+JZGZC42tpD/Siim6Rqy9M4To/BpMMQIIiEXa5ofwS+DgTEiEHQ== - dependencies: - "@parcel/diagnostic" "2.8.3" - "@parcel/plugin" "2.8.3" - "@parcel/utils" "2.8.3" - "@parcel/workers" "2.8.3" - detect-libc "^1.0.3" - -"@parcel/optimizer-svgo@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/optimizer-svgo/-/optimizer-svgo-2.8.3.tgz#04da4efec6b623679539a84961bff6998034ba8a" - integrity sha512-9KQed99NZnQw3/W4qBYVQ7212rzA9EqrQG019TIWJzkA9tjGBMIm2c/nXpK1tc3hQ3e7KkXkFCQ3C+ibVUnHNA== - dependencies: - "@parcel/diagnostic" "2.8.3" - "@parcel/plugin" "2.8.3" - "@parcel/utils" "2.8.3" - svgo "^2.4.0" - -"@parcel/optimizer-terser@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/optimizer-terser/-/optimizer-terser-2.8.3.tgz#3a06d98d09386a1a0ae1be85376a8739bfba9618" - integrity sha512-9EeQlN6zIeUWwzrzu6Q2pQSaYsYGah8MtiQ/hog9KEPlYTP60hBv/+utDyYEHSQhL7y5ym08tPX5GzBvwAD/dA== - dependencies: - "@parcel/diagnostic" "2.8.3" - "@parcel/plugin" "2.8.3" - "@parcel/source-map" "^2.1.1" - "@parcel/utils" "2.8.3" - nullthrows "^1.1.1" - terser "^5.2.0" - -"@parcel/package-manager@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/package-manager/-/package-manager-2.8.3.tgz#ddd0d62feae3cf0fb6cc0537791b3a16296ad458" - integrity sha512-tIpY5pD2lH53p9hpi++GsODy6V3khSTX4pLEGuMpeSYbHthnOViobqIlFLsjni+QA1pfc8NNNIQwSNdGjYflVA== - dependencies: - "@parcel/diagnostic" "2.8.3" - "@parcel/fs" "2.8.3" - "@parcel/logger" "2.8.3" - "@parcel/types" "2.8.3" - "@parcel/utils" "2.8.3" - "@parcel/workers" "2.8.3" - semver "^5.7.1" - -"@parcel/packager-css@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/packager-css/-/packager-css-2.8.3.tgz#0eff34268cb4f5dfb53c1bbca85f5567aeb1835a" - integrity sha512-WyvkMmsurlHG8d8oUVm7S+D+cC/T3qGeqogb7sTI52gB6uiywU7lRCizLNqGFyFGIxcVTVHWnSHqItBcLN76lA== - dependencies: - "@parcel/plugin" "2.8.3" - "@parcel/source-map" "^2.1.1" - "@parcel/utils" "2.8.3" - nullthrows "^1.1.1" - -"@parcel/packager-html@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/packager-html/-/packager-html-2.8.3.tgz#f9263b891aa4dd46c6e2fa2b07025a482132fff1" - integrity sha512-OhPu1Hx1RRKJodpiu86ZqL8el2Aa4uhBHF6RAL1Pcrh2EhRRlPf70Sk0tC22zUpYL7es+iNKZ/n0Rl+OWSHWEw== - dependencies: - "@parcel/plugin" "2.8.3" - "@parcel/types" "2.8.3" - "@parcel/utils" "2.8.3" - nullthrows "^1.1.1" - posthtml "^0.16.5" - -"@parcel/packager-js@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/packager-js/-/packager-js-2.8.3.tgz#3ed11565915d73d12192b6901c75a6b820e4a83a" - integrity sha512-0pGKC3Ax5vFuxuZCRB+nBucRfFRz4ioie19BbDxYnvBxrd4M3FIu45njf6zbBYsI9eXqaDnL1b3DcZJfYqtIzw== - dependencies: - "@parcel/diagnostic" "2.8.3" - "@parcel/hash" "2.8.3" - "@parcel/plugin" "2.8.3" - "@parcel/source-map" "^2.1.1" - "@parcel/utils" "2.8.3" - globals "^13.2.0" - nullthrows "^1.1.1" - -"@parcel/packager-raw@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/packager-raw/-/packager-raw-2.8.3.tgz#bdec826df991e186cb58691cc45d12ad5c06676e" - integrity sha512-BA6enNQo1RCnco9MhkxGrjOk59O71IZ9DPKu3lCtqqYEVd823tXff2clDKHK25i6cChmeHu6oB1Rb73hlPqhUA== - dependencies: - "@parcel/plugin" "2.8.3" - -"@parcel/packager-svg@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/packager-svg/-/packager-svg-2.8.3.tgz#7233315296001c531cb55ca96b5f2ef672343630" - integrity sha512-mvIoHpmv5yzl36OjrklTDFShLUfPFTwrmp1eIwiszGdEBuQaX7JVI3Oo2jbVQgcN4W7J6SENzGQ3Q5hPTW3pMw== - dependencies: - "@parcel/plugin" "2.8.3" - "@parcel/types" "2.8.3" - "@parcel/utils" "2.8.3" - posthtml "^0.16.4" - -"@parcel/plugin@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/plugin/-/plugin-2.8.3.tgz#7bb30a5775eaa6473c27f002a0a3ee7308d6d669" - integrity sha512-jZ6mnsS4D9X9GaNnvrixDQwlUQJCohDX2hGyM0U0bY2NWU8Km97SjtoCpWjq+XBCx/gpC4g58+fk9VQeZq2vlw== - dependencies: - "@parcel/types" "2.8.3" - -"@parcel/reporter-cli@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/reporter-cli/-/reporter-cli-2.8.3.tgz#12a4743b51b8fe6837f53c20e01bbf1f7336e8e4" - integrity sha512-3sJkS6tFFzgIOz3u3IpD/RsmRxvOKKiQHOTkiiqRt1l44mMDGKS7zANRnJYsQzdCsgwc9SOP30XFgJwtoVlMbw== - dependencies: - "@parcel/plugin" "2.8.3" - "@parcel/types" "2.8.3" - "@parcel/utils" "2.8.3" - chalk "^4.1.0" - term-size "^2.2.1" - -"@parcel/reporter-dev-server@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/reporter-dev-server/-/reporter-dev-server-2.8.3.tgz#a0daa5cc015642684cea561f4e0e7116bbffdc1c" - integrity sha512-Y8C8hzgzTd13IoWTj+COYXEyCkXfmVJs3//GDBsH22pbtSFMuzAZd+8J9qsCo0EWpiDow7V9f1LischvEh3FbQ== - dependencies: - "@parcel/plugin" "2.8.3" - "@parcel/utils" "2.8.3" - -"@parcel/resolver-default@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/resolver-default/-/resolver-default-2.8.3.tgz#5ae41e537ae4a793c1abb47f094482b9e2ac3535" - integrity sha512-k0B5M/PJ+3rFbNj4xZSBr6d6HVIe6DH/P3dClLcgBYSXAvElNDfXgtIimbjCyItFkW9/BfcgOVKEEIZOeySH/A== - dependencies: - "@parcel/node-resolver-core" "2.8.3" - "@parcel/plugin" "2.8.3" - -"@parcel/runtime-browser-hmr@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/runtime-browser-hmr/-/runtime-browser-hmr-2.8.3.tgz#1fa74e1fbd1030b0a920c58afa3a9eb7dc4bcd1e" - integrity sha512-2O1PYi2j/Q0lTyGNV3JdBYwg4rKo6TEVFlYGdd5wCYU9ZIN9RRuoCnWWH2qCPj3pjIVtBeppYxzfVjPEHINWVg== - dependencies: - "@parcel/plugin" "2.8.3" - "@parcel/utils" "2.8.3" - -"@parcel/runtime-js@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/runtime-js/-/runtime-js-2.8.3.tgz#0baa4c8fbf77eabce05d01ccc186614968ffc0cd" - integrity sha512-IRja0vNKwvMtPgIqkBQh0QtRn0XcxNC8HU1jrgWGRckzu10qJWO+5ULgtOeR4pv9krffmMPqywGXw6l/gvJKYQ== - dependencies: - "@parcel/plugin" "2.8.3" - "@parcel/utils" "2.8.3" - nullthrows "^1.1.1" - -"@parcel/runtime-react-refresh@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/runtime-react-refresh/-/runtime-react-refresh-2.8.3.tgz#381a942fb81e8f5ac6c7e0ee1b91dbf34763c3f8" - integrity sha512-2v/qFKp00MfG0234OdOgQNAo6TLENpFYZMbVbAsPMY9ITiqG73MrEsrGXVoGbYiGTMB/Toer/lSWlJxtacOCuA== - dependencies: - "@parcel/plugin" "2.8.3" - "@parcel/utils" "2.8.3" - react-error-overlay "6.0.9" - react-refresh "^0.9.0" - -"@parcel/runtime-service-worker@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/runtime-service-worker/-/runtime-service-worker-2.8.3.tgz#54d92da9ff1dfbd27db0e84164a22fa59e99b348" - integrity sha512-/Skkw+EeRiwzOJso5fQtK8c9b452uWLNhQH1ISTodbmlcyB4YalAiSsyHCtMYD0c3/t5Sx4ZS7vxBAtQd0RvOw== - dependencies: - "@parcel/plugin" "2.8.3" - "@parcel/utils" "2.8.3" - nullthrows "^1.1.1" - -"@parcel/source-map@^2.1.1": - version "2.1.1" - resolved "https://registry.yarnpkg.com/@parcel/source-map/-/source-map-2.1.1.tgz#fb193b82dba6dd62cc7a76b326f57bb35000a782" - integrity sha512-Ejx1P/mj+kMjQb8/y5XxDUn4reGdr+WyKYloBljpppUy8gs42T+BNoEOuRYqDVdgPc6NxduzIDoJS9pOFfV5Ew== - dependencies: - detect-libc "^1.0.3" - -"@parcel/transformer-babel@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/transformer-babel/-/transformer-babel-2.8.3.tgz#286bc6cb9afe4c0259f0b28e0f2f47322a24b130" - integrity sha512-L6lExfpvvC7T/g3pxf3CIJRouQl+sgrSzuWQ0fD4PemUDHvHchSP4SNUVnd6gOytF3Y1KpnEZIunQGi5xVqQCQ== - dependencies: - "@parcel/diagnostic" "2.8.3" - "@parcel/plugin" "2.8.3" - "@parcel/source-map" "^2.1.1" - "@parcel/utils" "2.8.3" - browserslist "^4.6.6" - json5 "^2.2.0" - nullthrows "^1.1.1" - semver "^5.7.0" - -"@parcel/transformer-css@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/transformer-css/-/transformer-css-2.8.3.tgz#d6c44100204e73841ad8e0f90472172ea8b9120c" - integrity sha512-xTqFwlSXtnaYen9ivAgz+xPW7yRl/u4QxtnDyDpz5dr8gSeOpQYRcjkd4RsYzKsWzZcGtB5EofEk8ayUbWKEUg== - dependencies: - "@parcel/diagnostic" "2.8.3" - "@parcel/plugin" "2.8.3" - "@parcel/source-map" "^2.1.1" - "@parcel/utils" "2.8.3" - browserslist "^4.6.6" - lightningcss "^1.16.1" - nullthrows "^1.1.1" - -"@parcel/transformer-html@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/transformer-html/-/transformer-html-2.8.3.tgz#5c68b28ee6b8c7a13b8aee87f7957ad3227bd83f" - integrity sha512-kIZO3qsMYTbSnSpl9cnZog+SwL517ffWH54JeB410OSAYF1ouf4n5v9qBnALZbuCCmPwJRGs4jUtE452hxwN4g== - dependencies: - "@parcel/diagnostic" "2.8.3" - "@parcel/hash" "2.8.3" - "@parcel/plugin" "2.8.3" - nullthrows "^1.1.1" - posthtml "^0.16.5" - posthtml-parser "^0.10.1" - posthtml-render "^3.0.0" - semver "^5.7.1" - srcset "4" - -"@parcel/transformer-image@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/transformer-image/-/transformer-image-2.8.3.tgz#73805b2bfc3c8919d7737544e5f8be39e3f303fe" - integrity sha512-cO4uptcCGTi5H6bvTrAWEFUsTNhA4kCo8BSvRSCHA2sf/4C5tGQPHt3JhdO0GQLPwZRCh/R41EkJs5HZ8A8DAg== - dependencies: - "@parcel/plugin" "2.8.3" - "@parcel/utils" "2.8.3" - "@parcel/workers" "2.8.3" - nullthrows "^1.1.1" - -"@parcel/transformer-js@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/transformer-js/-/transformer-js-2.8.3.tgz#fe400df428394d1e7fe5afb6dea5c7c858e44f03" - integrity sha512-9Qd6bib+sWRcpovvzvxwy/PdFrLUXGfmSW9XcVVG8pvgXsZPFaNjnNT8stzGQj1pQiougCoxMY4aTM5p1lGHEQ== - dependencies: - "@parcel/diagnostic" "2.8.3" - "@parcel/plugin" "2.8.3" - "@parcel/source-map" "^2.1.1" - "@parcel/utils" "2.8.3" - "@parcel/workers" "2.8.3" - "@swc/helpers" "^0.4.12" - browserslist "^4.6.6" - detect-libc "^1.0.3" - nullthrows "^1.1.1" - regenerator-runtime "^0.13.7" - semver "^5.7.1" - -"@parcel/transformer-json@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/transformer-json/-/transformer-json-2.8.3.tgz#25deb3a5138cc70a83269fc5d39d564609354d36" - integrity sha512-B7LmVq5Q7bZO4ERb6NHtRuUKWGysEeaj9H4zelnyBv+wLgpo4f5FCxSE1/rTNmP9u1qHvQ3scGdK6EdSSokGPg== - dependencies: - "@parcel/plugin" "2.8.3" - json5 "^2.2.0" - -"@parcel/transformer-postcss@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/transformer-postcss/-/transformer-postcss-2.8.3.tgz#df4fdc1c90893823445f2a8eb8e2bdd0349ccc58" - integrity sha512-e8luB/poIlz6jBsD1Izms+6ElbyzuoFVa4lFVLZnTAChI3UxPdt9p/uTsIO46HyBps/Bk8ocvt3J4YF84jzmvg== - dependencies: - "@parcel/diagnostic" "2.8.3" - "@parcel/hash" "2.8.3" - "@parcel/plugin" "2.8.3" - "@parcel/utils" "2.8.3" - clone "^2.1.1" - nullthrows "^1.1.1" - postcss-value-parser "^4.2.0" - semver "^5.7.1" - -"@parcel/transformer-posthtml@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/transformer-posthtml/-/transformer-posthtml-2.8.3.tgz#7c3912a5a631cb26485f6464e0d6eeabb6f1e718" - integrity sha512-pkzf9Smyeaw4uaRLsT41RGrPLT5Aip8ZPcntawAfIo+KivBQUV0erY1IvHYjyfFzq1ld/Fo2Ith9He6mxpPifA== - dependencies: - "@parcel/plugin" "2.8.3" - "@parcel/utils" "2.8.3" - nullthrows "^1.1.1" - posthtml "^0.16.5" - posthtml-parser "^0.10.1" - posthtml-render "^3.0.0" - semver "^5.7.1" - -"@parcel/transformer-raw@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/transformer-raw/-/transformer-raw-2.8.3.tgz#3a22213fe18a5f83fd78889cb49f06e059cfead7" - integrity sha512-G+5cXnd2/1O3nV/pgRxVKZY/HcGSseuhAe71gQdSQftb8uJEURyUHoQ9Eh0JUD3MgWh9V+nIKoyFEZdf9T0sUQ== - dependencies: - "@parcel/plugin" "2.8.3" - -"@parcel/transformer-react-refresh-wrap@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/transformer-react-refresh-wrap/-/transformer-react-refresh-wrap-2.8.3.tgz#8b0392638405dd470a886002229f7889d5464822" - integrity sha512-q8AAoEvBnCf/nPvgOwFwKZfEl/thwq7c2duxXkhl+tTLDRN2vGmyz4355IxCkavSX+pLWSQ5MexklSEeMkgthg== - dependencies: - "@parcel/plugin" "2.8.3" - "@parcel/utils" "2.8.3" - react-refresh "^0.9.0" - -"@parcel/transformer-svg@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/transformer-svg/-/transformer-svg-2.8.3.tgz#4df959cba4ebf45d7aaddd540f752e6e84df38b2" - integrity sha512-3Zr/gBzxi1ZH1fftH/+KsZU7w5GqkmxlB0ZM8ovS5E/Pl1lq1t0xvGJue9m2VuQqP8Mxfpl5qLFmsKlhaZdMIQ== - dependencies: - "@parcel/diagnostic" "2.8.3" - "@parcel/hash" "2.8.3" - "@parcel/plugin" "2.8.3" - nullthrows "^1.1.1" - posthtml "^0.16.5" - posthtml-parser "^0.10.1" - posthtml-render "^3.0.0" - semver "^5.7.1" - -"@parcel/types@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/types/-/types-2.8.3.tgz#3306bc5391b6913bd619914894b8cd84a24b30fa" - integrity sha512-FECA1FB7+0UpITKU0D6TgGBpGxYpVSMNEENZbSJxFSajNy3wrko+zwBKQmFOLOiPcEtnGikxNs+jkFWbPlUAtw== - dependencies: - "@parcel/cache" "2.8.3" - "@parcel/diagnostic" "2.8.3" - "@parcel/fs" "2.8.3" - "@parcel/package-manager" "2.8.3" - "@parcel/source-map" "^2.1.1" - "@parcel/workers" "2.8.3" - utility-types "^3.10.0" - -"@parcel/utils@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/utils/-/utils-2.8.3.tgz#0d56c9e8e22c119590a5e044a0e01031965da40e" - integrity sha512-IhVrmNiJ+LOKHcCivG5dnuLGjhPYxQ/IzbnF2DKNQXWBTsYlHkJZpmz7THoeLtLliGmSOZ3ZCsbR8/tJJKmxjA== - dependencies: - "@parcel/codeframe" "2.8.3" - "@parcel/diagnostic" "2.8.3" - "@parcel/hash" "2.8.3" - "@parcel/logger" "2.8.3" - "@parcel/markdown-ansi" "2.8.3" - "@parcel/source-map" "^2.1.1" - chalk "^4.1.0" - -"@parcel/watcher@^2.0.7": - version "2.1.0" - resolved "https://registry.yarnpkg.com/@parcel/watcher/-/watcher-2.1.0.tgz#5f32969362db4893922c526a842d8af7a8538545" - integrity sha512-8s8yYjd19pDSsBpbkOHnT6Z2+UJSuLQx61pCFM0s5wSRvKCEMDjd/cHY3/GI1szHIWbpXpsJdg3V6ISGGx9xDw== - dependencies: - is-glob "^4.0.3" - micromatch "^4.0.5" - node-addon-api "^3.2.1" - node-gyp-build "^4.3.0" - -"@parcel/workers@2.8.3": - version "2.8.3" - resolved "https://registry.yarnpkg.com/@parcel/workers/-/workers-2.8.3.tgz#255450ccf4db234082407e4ddda5fd575f08c235" - integrity sha512-+AxBnKgjqVpUHBcHLWIHcjYgKIvHIpZjN33mG5LG9XXvrZiqdWvouEzqEXlVLq5VzzVbKIQQcmsvRy138YErkg== - dependencies: - "@parcel/diagnostic" "2.8.3" - "@parcel/logger" "2.8.3" - "@parcel/types" "2.8.3" - "@parcel/utils" "2.8.3" - chrome-trace-event "^1.0.2" - nullthrows "^1.1.1" - -"@swc/helpers@^0.4.12": - version "0.4.14" - resolved "https://registry.yarnpkg.com/@swc/helpers/-/helpers-0.4.14.tgz#1352ac6d95e3617ccb7c1498ff019654f1e12a74" - integrity sha512-4C7nX/dvpzB7za4Ql9K81xK3HPxCpHMgwTZVyf+9JQ6VUbn9jjZVN7/Nkdz/Ugzs2CSjqnL/UPXroiVBVHUWUw== - dependencies: - tslib "^2.4.0" - -"@tensorflow/tfjs-automl@link:../..": - version "0.0.0" - uid "" - -"@tensorflow/tfjs-backend-cpu@4.2.0": - version "4.2.0" - resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-backend-cpu/-/tfjs-backend-cpu-4.2.0.tgz#24912f8ef20b04ca4056365d83e5cc5a1671581f" - integrity sha512-8HWg9J69m0Ovc6w8TVhhixMOcwA3t/NPXLblOA/sgJ+/JD5gsbpLWJk4QISQyb1RnpSVzw6PX3BSMTJU7hWVOg== - dependencies: - "@types/seedrandom" "^2.4.28" - seedrandom "^3.0.5" - -"@tensorflow/tfjs-backend-webgl@^4.2.0": - version "4.2.0" - resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-backend-webgl/-/tfjs-backend-webgl-4.2.0.tgz#684368f9a2605511d6d6753bf6fe9a08c73f6791" - integrity sha512-Qvf+hD5pSh+xi48kChSGzcDKJemkc4EKfoVVjuxl4k25ZUPwuEd7zZUAtinkLu1dzgHNyvePZY8k+9rVm59HJA== - dependencies: - "@tensorflow/tfjs-backend-cpu" "4.2.0" - "@types/offscreencanvas" "~2019.3.0" - "@types/seedrandom" "^2.4.28" - "@types/webgl-ext" "0.0.30" - seedrandom "^3.0.5" - -"@tensorflow/tfjs-converter@^4.2.0": - version "4.2.0" - resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-converter/-/tfjs-converter-4.2.0.tgz#3a51d446dc0d6194f31407345891966e0a77937f" - integrity sha512-m+E2KJM6yGQdi8ElzWpChdD/JaqhWMCi9yK70v/ndkOaCL2q2UN48nYP2T5S15vkDvMIgzAQyZfh7hxQsMuvRQ== - -"@tensorflow/tfjs-core@^4.2.0": - version "4.2.0" - resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-core/-/tfjs-core-4.2.0.tgz#34dc455c0a00feac12015caec34a54414a404230" - integrity sha512-uuHkiWVC8b00ngFbHvAV7J7haRlN/9PEdeenCi0CzBjgKd7aN25wPWaoN0TSQcU+GT4FJ8mofMZ9VBYZ/s/WLg== - dependencies: - "@types/long" "^4.0.1" - "@types/offscreencanvas" "~2019.7.0" - "@types/seedrandom" "^2.4.28" - "@types/webgl-ext" "0.0.30" - "@webgpu/types" "0.1.21" - long "4.0.0" - node-fetch "~2.6.1" - seedrandom "^3.0.5" - -"@trysound/sax@0.2.0": - version "0.2.0" - resolved "https://registry.yarnpkg.com/@trysound/sax/-/sax-0.2.0.tgz#cccaab758af56761eb7bf37af6f03f326dd798ad" - integrity sha512-L7z9BgrNEcYyUYtF+HaEfiS5ebkh9jXqbszz7pC0hRBPaatV0XjSD3+eHrpqFemQfgwiFF0QPIarnIihIDn7OA== - -"@types/long@^4.0.1": - version "4.0.1" - resolved "https://registry.yarnpkg.com/@types/long/-/long-4.0.1.tgz#459c65fa1867dafe6a8f322c4c51695663cc55e9" - integrity sha512-5tXH6Bx/kNGd3MgffdmP4dy2Z+G4eaXw0SE81Tq3BNadtnMR5/ySMzX4SLEzHJzSmPNn4HIdpQsBvXMUykr58w== - -"@types/offscreencanvas@~2019.3.0": - version "2019.3.0" - resolved "https://registry.yarnpkg.com/@types/offscreencanvas/-/offscreencanvas-2019.3.0.tgz#3336428ec7e9180cf4566dfea5da04eb586a6553" - integrity sha512-esIJx9bQg+QYF0ra8GnvfianIY8qWB0GBx54PK5Eps6m+xTj86KLavHv6qDhzKcu5UUOgNfJ2pWaIIV7TRUd9Q== - -"@types/offscreencanvas@~2019.7.0": - version "2019.7.0" - resolved "https://registry.yarnpkg.com/@types/offscreencanvas/-/offscreencanvas-2019.7.0.tgz#e4a932069db47bb3eabeb0b305502d01586fa90d" - integrity sha512-PGcyveRIpL1XIqK8eBsmRBt76eFgtzuPiSTyKHZxnGemp2yzGzWpjYKAfK3wIMiU7eH+851yEpiuP8JZerTmWg== - -"@types/parse-json@^4.0.0": - version "4.0.0" - resolved "https://registry.yarnpkg.com/@types/parse-json/-/parse-json-4.0.0.tgz#2f8bb441434d163b35fb8ffdccd7138927ffb8c0" - integrity sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA== - -"@types/seedrandom@^2.4.28": - version "2.4.30" - resolved "https://registry.yarnpkg.com/@types/seedrandom/-/seedrandom-2.4.30.tgz#d2efe425869b84163c2d56e779dddadb9372cbfa" - integrity sha512-AnxLHewubLVzoF/A4qdxBGHCKifw8cY32iro3DQX9TPcetE95zBeVt3jnsvtvAUf1vwzMfwzp4t/L2yqPlnjkQ== - -"@types/webgl-ext@0.0.30": - version "0.0.30" - resolved "https://registry.yarnpkg.com/@types/webgl-ext/-/webgl-ext-0.0.30.tgz#0ce498c16a41a23d15289e0b844d945b25f0fb9d" - integrity sha512-LKVgNmBxN0BbljJrVUwkxwRYqzsAEPcZOe6S2T6ZaBDIrFp0qu4FNlpc5sM1tGbXUYFgdVQIoeLk1Y1UoblyEg== - -"@webgpu/types@0.1.21": - version "0.1.21" - resolved "https://registry.yarnpkg.com/@webgpu/types/-/types-0.1.21.tgz#b181202daec30d66ccd67264de23814cfd176d3a" - integrity sha512-pUrWq3V5PiSGFLeLxoGqReTZmiiXwY3jRkIG5sLLKjyqNxrwm/04b4nw7LSmGWJcKk59XOM/YRTUwOzo4MMlow== - -abortcontroller-polyfill@^1.1.9: - version "1.7.3" - resolved "https://registry.yarnpkg.com/abortcontroller-polyfill/-/abortcontroller-polyfill-1.7.3.tgz#1b5b487bd6436b5b764fd52a612509702c3144b5" - integrity sha512-zetDJxd89y3X99Kvo4qFx8GKlt6GsvN3UcRZHwU6iFA/0KiOmhkTVhe8oRoTBiTVPZu09x3vCra47+w8Yz1+2Q== - -acorn@^8.5.0: - version "8.7.1" - resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.7.1.tgz#0197122c843d1bf6d0a5e83220a788f278f63c30" - integrity sha512-Xx54uLJQZ19lKygFXOWsscKUbsBZW0CPykPhVQdhIeIwrbPmJzqeASDInc8nKBnp/JT6igTs82qPXz069H8I/A== - -ansi-regex@^5.0.1: - version "5.0.1" - resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.1.tgz#082cb2c89c9fe8659a311a53bd6a4dc5301db304" - integrity sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ== - -ansi-styles@^3.2.1: - version "3.2.1" - resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d" - integrity sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA== - dependencies: - color-convert "^1.9.0" - -ansi-styles@^4.0.0, ansi-styles@^4.1.0: - version "4.3.0" - resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-4.3.0.tgz#edd803628ae71c04c85ae7a0906edad34b648937" - integrity sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg== - dependencies: - color-convert "^2.0.1" - -async@^3.2.3: - version "3.2.4" - resolved "https://registry.yarnpkg.com/async/-/async-3.2.4.tgz#2d22e00f8cddeb5fde5dd33522b56d1cf569a81c" - integrity sha512-iAB+JbDEGXhyIUavoDl9WP/Jj106Kz9DEn1DPgYw5ruDn0e3Wgi3sKFm55sASdGBNOQB8F59d9qQ7deqrHA8wQ== - -balanced-match@^1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee" - integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw== - -base-x@^3.0.8: - version "3.0.9" - resolved "https://registry.yarnpkg.com/base-x/-/base-x-3.0.9.tgz#6349aaabb58526332de9f60995e548a53fe21320" - integrity sha512-H7JU6iBHTal1gp56aKoaa//YUxEaAOUiydvrV/pILqIHXTtqxSkATOnDA2u+jZ/61sD+L/412+7kzXRtWukhpQ== - dependencies: - safe-buffer "^5.0.1" - -boolbase@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/boolbase/-/boolbase-1.0.0.tgz#68dff5fbe60c51eb37725ea9e3ed310dcc1e776e" - integrity sha1-aN/1++YMUes3cl6p4+0xDcwed24= - -brace-expansion@^1.1.7: - version "1.1.11" - resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" - integrity sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA== - dependencies: - balanced-match "^1.0.0" - concat-map "0.0.1" - -braces@^3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107" - integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A== - dependencies: - fill-range "^7.0.1" - -browserslist@^4.6.6: - version "4.20.0" - resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.20.0.tgz#35951e3541078c125d36df76056e94738a52ebe9" - integrity sha512-bnpOoa+DownbciXj0jVGENf8VYQnE2LNWomhYuCsMmmx9Jd9lwq0WXODuwpSsp8AVdKM2/HorrzxAfbKvWTByQ== - dependencies: - caniuse-lite "^1.0.30001313" - electron-to-chromium "^1.4.76" - escalade "^3.1.1" - node-releases "^2.0.2" - picocolors "^1.0.0" - -buffer-from@^1.0.0: - version "1.1.2" - resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.2.tgz#2b146a6fd72e80b4f55d255f35ed59a3a9a41bd5" - integrity sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ== - -callsites@^3.0.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/callsites/-/callsites-3.1.0.tgz#b3630abd8943432f54b3f0519238e33cd7df2f73" - integrity sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ== - -caniuse-lite@^1.0.30001313: - version "1.0.30001317" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001317.tgz#0548fb28fd5bc259a70b8c1ffdbe598037666a1b" - integrity sha512-xIZLh8gBm4dqNX0gkzrBeyI86J2eCjWzYAs40q88smG844YIrN4tVQl/RhquHvKEKImWWFIVh1Lxe5n1G/N+GQ== - -chalk@^2.0.0: - version "2.4.2" - resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" - integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ== - dependencies: - ansi-styles "^3.2.1" - escape-string-regexp "^1.0.5" - supports-color "^5.3.0" - -chalk@^4.1.0: - version "4.1.2" - resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01" - integrity sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA== - dependencies: - ansi-styles "^4.1.0" - supports-color "^7.1.0" - -chrome-trace-event@^1.0.2: - version "1.0.3" - resolved "https://registry.yarnpkg.com/chrome-trace-event/-/chrome-trace-event-1.0.3.tgz#1015eced4741e15d06664a957dbbf50d041e26ac" - integrity sha512-p3KULyQg4S7NIHixdwbGX+nFHkoBiA4YQmyWtjb8XngSKV124nJmRysgAeujbUVb15vh+RvFUfCPqU7rXk+hZg== - -clang-format@~1.8.0: - version "1.8.0" - resolved "https://registry.yarnpkg.com/clang-format/-/clang-format-1.8.0.tgz#7779df1c5ce1bc8aac1b0b02b4e479191ef21d46" - integrity sha512-pK8gzfu55/lHzIpQ1givIbWfn3eXnU7SfxqIwVgnn5jEM6j4ZJYjpFqFs4iSBPNedzRMmfjYjuQhu657WAXHXw== - dependencies: - async "^3.2.3" - glob "^7.0.0" - resolve "^1.1.6" - -cliui@^7.0.2: - version "7.0.4" - resolved "https://registry.yarnpkg.com/cliui/-/cliui-7.0.4.tgz#a0265ee655476fc807aea9df3df8df7783808b4f" - integrity sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ== - dependencies: - string-width "^4.2.0" - strip-ansi "^6.0.0" - wrap-ansi "^7.0.0" - -clone@^2.1.1: - version "2.1.2" - resolved "https://registry.yarnpkg.com/clone/-/clone-2.1.2.tgz#1b7f4b9f591f1e8f83670401600345a02887435f" - integrity sha1-G39Ln1kfHo+DZwQBYANFoCiHQ18= - -color-convert@^1.9.0: - version "1.9.3" - resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8" - integrity sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg== - dependencies: - color-name "1.1.3" - -color-convert@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-2.0.1.tgz#72d3a68d598c9bdb3af2ad1e84f21d896abd4de3" - integrity sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ== - dependencies: - color-name "~1.1.4" - -color-name@1.1.3: - version "1.1.3" - resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25" - integrity sha1-p9BVi9icQveV3UIyj3QIMcpTvCU= - -color-name@~1.1.4: - version "1.1.4" - resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2" - integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA== - -commander@^2.20.0: - version "2.20.3" - resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33" - integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ== - -commander@^7.0.0, commander@^7.2.0: - version "7.2.0" - resolved "https://registry.yarnpkg.com/commander/-/commander-7.2.0.tgz#a36cb57d0b501ce108e4d20559a150a391d97ab7" - integrity sha512-QrWXB+ZQSVPmIWIhtEO9H+gwHaMGYiF5ChvoJ+K9ZGHG/sVsa6yiesAD1GC/x46sET00Xlwo1u49RVVVzvcSkw== - -concat-map@0.0.1: - version "0.0.1" - resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" - integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s= - -cosmiconfig@^7.0.1: - version "7.0.1" - resolved "https://registry.yarnpkg.com/cosmiconfig/-/cosmiconfig-7.0.1.tgz#714d756522cace867867ccb4474c5d01bbae5d6d" - integrity sha512-a1YWNUV2HwGimB7dU2s1wUMurNKjpx60HxBB6xUM8Re+2s1g1IIfJvFR0/iCF+XHdE0GMTKTuLR32UQff4TEyQ== - dependencies: - "@types/parse-json" "^4.0.0" - import-fresh "^3.2.1" - parse-json "^5.0.0" - path-type "^4.0.0" - yaml "^1.10.0" - -cross-env@^7.0.3: - version "7.0.3" - resolved "https://registry.yarnpkg.com/cross-env/-/cross-env-7.0.3.tgz#865264b29677dc015ba8418918965dd232fc54cf" - integrity sha512-+/HKd6EgcQCJGh2PSjZuUitQBQynKor4wrFbRg4DtAgS1aWO+gU52xpH7M9ScGgXSYmAVS9bIJ8EzuaGw0oNAw== - dependencies: - cross-spawn "^7.0.1" - -cross-spawn@^7.0.1: - version "7.0.3" - resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6" - integrity sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w== - dependencies: - path-key "^3.1.0" - shebang-command "^2.0.0" - which "^2.0.1" - -css-select@^4.1.3: - version "4.2.1" - resolved "https://registry.yarnpkg.com/css-select/-/css-select-4.2.1.tgz#9e665d6ae4c7f9d65dbe69d0316e3221fb274cdd" - integrity sha512-/aUslKhzkTNCQUB2qTX84lVmfia9NyjP3WpDGtj/WxhwBzWBYUV3DgUpurHTme8UTPcPlAD1DJ+b0nN/t50zDQ== - dependencies: - boolbase "^1.0.0" - css-what "^5.1.0" - domhandler "^4.3.0" - domutils "^2.8.0" - nth-check "^2.0.1" - -css-tree@^1.1.2, css-tree@^1.1.3: - version "1.1.3" - resolved "https://registry.yarnpkg.com/css-tree/-/css-tree-1.1.3.tgz#eb4870fb6fd7707327ec95c2ff2ab09b5e8db91d" - integrity sha512-tRpdppF7TRazZrjJ6v3stzv93qxRcSsFmW6cX0Zm2NVKpxE1WV1HblnghVv9TreireHkqI/VDEsfolRF1p6y7Q== - dependencies: - mdn-data "2.0.14" - source-map "^0.6.1" - -css-what@^5.1.0: - version "5.1.0" - resolved "https://registry.yarnpkg.com/css-what/-/css-what-5.1.0.tgz#3f7b707aadf633baf62c2ceb8579b545bb40f7fe" - integrity sha512-arSMRWIIFY0hV8pIxZMEfmMI47Wj3R/aWpZDDxWYCPEiOMv6tfOrnpDtgxBYPEQD4V0Y/958+1TdC3iWTFcUPw== - -csso@^4.2.0: - version "4.2.0" - resolved "https://registry.yarnpkg.com/csso/-/csso-4.2.0.tgz#ea3a561346e8dc9f546d6febedd50187cf389529" - integrity sha512-wvlcdIbf6pwKEk7vHj8/Bkc0B4ylXZruLvOgs9doS5eOsOpuodOV2zJChSpkp+pRpYQLQMeF04nr3Z68Sta9jA== - dependencies: - css-tree "^1.1.2" - -detect-indent@^6.0.0: - version "6.1.0" - resolved "https://registry.yarnpkg.com/detect-indent/-/detect-indent-6.1.0.tgz#592485ebbbf6b3b1ab2be175c8393d04ca0d57e6" - integrity sha512-reYkTUJAZb9gUuZ2RvVCNhVHdg62RHnJ7WJl8ftMi4diZ6NWlciOzQN88pUhSELEwflJht4oQDv0F0BMlwaYtA== - -detect-libc@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/detect-libc/-/detect-libc-1.0.3.tgz#fa137c4bd698edf55cd5cd02ac559f91a4c4ba9b" - integrity sha1-+hN8S9aY7fVc1c0CrFWfkaTEups= - -dom-serializer@^1.0.1: - version "1.3.2" - resolved "https://registry.yarnpkg.com/dom-serializer/-/dom-serializer-1.3.2.tgz#6206437d32ceefaec7161803230c7a20bc1b4d91" - integrity sha512-5c54Bk5Dw4qAxNOI1pFEizPSjVsx5+bpJKmL2kPn8JhBUq2q09tTCa3mjijun2NfK78NMouDYNMBkOrPZiS+ig== - dependencies: - domelementtype "^2.0.1" - domhandler "^4.2.0" - entities "^2.0.0" - -domelementtype@^2.0.1, domelementtype@^2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/domelementtype/-/domelementtype-2.2.0.tgz#9a0b6c2782ed6a1c7323d42267183df9bd8b1d57" - integrity sha512-DtBMo82pv1dFtUmHyr48beiuq792Sxohr+8Hm9zoxklYPfa6n0Z3Byjj2IV7bmr2IyqClnqEQhfgHJJ5QF0R5A== - -domhandler@^4.2.0, domhandler@^4.2.2, domhandler@^4.3.0: - version "4.3.0" - resolved "https://registry.yarnpkg.com/domhandler/-/domhandler-4.3.0.tgz#16c658c626cf966967e306f966b431f77d4a5626" - integrity sha512-fC0aXNQXqKSFTr2wDNZDhsEYjCiYsDWl3D01kwt25hm1YIPyDGHvvi3rw+PLqHAl/m71MaiF7d5zvBr0p5UB2g== - dependencies: - domelementtype "^2.2.0" - -domutils@^2.8.0: - version "2.8.0" - resolved "https://registry.yarnpkg.com/domutils/-/domutils-2.8.0.tgz#4437def5db6e2d1f5d6ee859bd95ca7d02048135" - integrity sha512-w96Cjofp72M5IIhpjgobBimYEfoPjx1Vx0BSX9P30WBdZW2WIKU0T1Bd0kz2eNZ9ikjKgHbEyKx8BB6H1L3h3A== - dependencies: - dom-serializer "^1.0.1" - domelementtype "^2.2.0" - domhandler "^4.2.0" - -dotenv-expand@^5.1.0: - version "5.1.0" - resolved "https://registry.yarnpkg.com/dotenv-expand/-/dotenv-expand-5.1.0.tgz#3fbaf020bfd794884072ea26b1e9791d45a629f0" - integrity sha512-YXQl1DSa4/PQyRfgrv6aoNjhasp/p4qs9FjJ4q4cQk+8m4r6k4ZSiEyytKG8f8W9gi8WsQtIObNmKd+tMzNTmA== - -dotenv@^7.0.0: - version "7.0.0" - resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-7.0.0.tgz#a2be3cd52736673206e8a85fb5210eea29628e7c" - integrity sha512-M3NhsLbV1i6HuGzBUH8vXrtxOk+tWmzWKDMbAVSUp3Zsjm7ywFeuwrUXhmhQyRK1q5B5GGy7hcXPbj3bnfZg2g== - -electron-to-chromium@^1.4.76: - version "1.4.84" - resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.84.tgz#2700befbcb49c42c4ee162e137ff392c07658249" - integrity sha512-b+DdcyOiZtLXHdgEG8lncYJdxbdJWJvclPNMg0eLUDcSOSO876WA/pYjdSblUTd7eJdIs4YdIxHWGazx7UPSJw== - -emoji-regex@^8.0.0: - version "8.0.0" - resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37" - integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A== - -entities@^2.0.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/entities/-/entities-2.2.0.tgz#098dc90ebb83d8dffa089d55256b351d34c4da55" - integrity sha512-p92if5Nz619I0w+akJrLZH0MX0Pb5DX39XOwQTtXSdQQOaYH03S1uIQp4mhOZtAXrxq4ViO67YTiLBo2638o9A== - -entities@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/entities/-/entities-3.0.1.tgz#2b887ca62585e96db3903482d336c1006c3001d4" - integrity sha512-WiyBqoomrwMdFG1e0kqvASYfnlb0lp8M5o5Fw2OFq1hNZxxcNk8Ik0Xm7LxzBhuidnZB/UtBqVCgUz3kBOP51Q== - -error-ex@^1.3.1: - version "1.3.2" - resolved "https://registry.yarnpkg.com/error-ex/-/error-ex-1.3.2.tgz#b4ac40648107fdcdcfae242f428bea8a14d4f1bf" - integrity sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g== - dependencies: - is-arrayish "^0.2.1" - -escalade@^3.1.1: - version "3.1.1" - resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.1.1.tgz#d8cfdc7000965c5a0174b4a82eaa5c0552742e40" - integrity sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw== - -escape-string-regexp@^1.0.5: - version "1.0.5" - resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" - integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ= - -fill-range@^7.0.1: - version "7.0.1" - resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.0.1.tgz#1919a6a7c75fe38b2c7c77e5198535da9acdda40" - integrity sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ== - dependencies: - to-regex-range "^5.0.1" - -fs-extra@^8.0.1: - version "8.1.0" - resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-8.1.0.tgz#49d43c45a88cd9677668cb7be1b46efdb8d2e1c0" - integrity sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g== - dependencies: - graceful-fs "^4.2.0" - jsonfile "^4.0.0" - universalify "^0.1.0" - -fs.realpath@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" - integrity sha1-FQStJSMVjKpA20onh8sBQRmU6k8= - -function-bind@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d" - integrity sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A== - -get-caller-file@^2.0.5: - version "2.0.5" - resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e" - integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg== - -get-port@^4.2.0: - version "4.2.0" - resolved "https://registry.yarnpkg.com/get-port/-/get-port-4.2.0.tgz#e37368b1e863b7629c43c5a323625f95cf24b119" - integrity sha512-/b3jarXkH8KJoOMQc3uVGHASwGLPq3gSFJ7tgJm2diza+bydJPTGOibin2steecKeOylE8oY2JERlVWkAJO6yw== - -glob@^7.0.0, glob@^7.1.4, glob@^7.1.6: - version "7.2.0" - resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.0.tgz#d15535af7732e02e948f4c41628bd910293f6023" - integrity sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q== - dependencies: - fs.realpath "^1.0.0" - inflight "^1.0.4" - inherits "2" - minimatch "^3.0.4" - once "^1.3.0" - path-is-absolute "^1.0.0" - -globals@^13.2.0: - version "13.12.1" - resolved "https://registry.yarnpkg.com/globals/-/globals-13.12.1.tgz#ec206be932e6c77236677127577aa8e50bf1c5cb" - integrity sha512-317dFlgY2pdJZ9rspXDks7073GpDmXdfbM3vYYp0HAMKGDh1FfWPleI2ljVNLQX5M5lXcAslTcPTrOrMEFOjyw== - dependencies: - type-fest "^0.20.2" - -graceful-fs@^4.1.6, graceful-fs@^4.2.0: - version "4.2.9" - resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.9.tgz#041b05df45755e587a24942279b9d113146e1c96" - integrity sha512-NtNxqUcXgpW2iMrfqSfR73Glt39K+BLwWsPs94yR63v45T0Wbej7eRmL5cWfwEgqXnmjQp3zaJTshdRW/qC2ZQ== - -has-flag@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd" - integrity sha1-tdRU3CGZriJWmfNGfloH87lVuv0= - -has-flag@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b" - integrity sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ== - -has@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/has/-/has-1.0.3.tgz#722d7cbfc1f6aa8241f16dd814e011e1f41e8796" - integrity sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw== - dependencies: - function-bind "^1.1.1" - -htmlnano@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/htmlnano/-/htmlnano-2.0.0.tgz#07376faa064f7e1e832dfd91e1a9f606b0bc9b78" - integrity sha512-thKQfhcp2xgtsWNE27A2bliEeqVL5xjAgGn0wajyttvFFsvFWWah1ntV9aEX61gz0T6MBQ5xK/1lXuEumhJTcg== - dependencies: - cosmiconfig "^7.0.1" - posthtml "^0.16.5" - timsort "^0.3.0" - -htmlparser2@^7.1.1: - version "7.2.0" - resolved "https://registry.yarnpkg.com/htmlparser2/-/htmlparser2-7.2.0.tgz#8817cdea38bbc324392a90b1990908e81a65f5a5" - integrity sha512-H7MImA4MS6cw7nbyURtLPO1Tms7C5H602LRETv95z1MxO/7CP7rDVROehUYeYBUYEON94NXXDEPmZuq+hX4sog== - dependencies: - domelementtype "^2.0.1" - domhandler "^4.2.2" - domutils "^2.8.0" - entities "^3.0.1" - -ignore-walk@^3.0.3: - version "3.0.4" - resolved "https://registry.yarnpkg.com/ignore-walk/-/ignore-walk-3.0.4.tgz#c9a09f69b7c7b479a5d74ac1a3c0d4236d2a6335" - integrity sha512-PY6Ii8o1jMRA1z4F2hRkH/xN59ox43DavKvD3oDpfurRlOJyAHpifIwpbdv1n4jt4ov0jSpw3kQ4GhJnpBL6WQ== - dependencies: - minimatch "^3.0.4" - -ignore@^5.0.4: - version "5.2.0" - resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.2.0.tgz#6d3bac8fa7fe0d45d9f9be7bac2fc279577e345a" - integrity sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ== - -import-fresh@^3.2.1: - version "3.3.0" - resolved "https://registry.yarnpkg.com/import-fresh/-/import-fresh-3.3.0.tgz#37162c25fcb9ebaa2e6e53d5b4d88ce17d9e0c2b" - integrity sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw== - dependencies: - parent-module "^1.0.0" - resolve-from "^4.0.0" - -inflight@^1.0.4: - version "1.0.6" - resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" - integrity sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk= - dependencies: - once "^1.3.0" - wrappy "1" - -inherits@2: - version "2.0.4" - resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" - integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== - -ini@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/ini/-/ini-2.0.0.tgz#e5fd556ecdd5726be978fa1001862eacb0a94bc5" - integrity sha512-7PnF4oN3CvZF23ADhA5wRaYEQpJ8qygSkbtTXWBeXWXmEVRXK+1ITciHWwHhsjv1TmW0MgacIv6hEi5pX5NQdA== - -is-arrayish@^0.2.1: - version "0.2.1" - resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.2.1.tgz#77c99840527aa8ecb1a8ba697b80645a7a926a9d" - integrity sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0= - -is-core-module@^2.8.1: - version "2.8.1" - resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.8.1.tgz#f59fdfca701d5879d0a6b100a40aa1560ce27211" - integrity sha512-SdNCUs284hr40hFTFP6l0IfZ/RSrMXF3qgoRHd3/79unUTvrFO/JoXwkGm+5J/Oe3E/b5GsnG330uUNgRpu1PA== - dependencies: - has "^1.0.3" - -is-extglob@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2" - integrity sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ== - -is-fullwidth-code-point@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz#f116f8064fe90b3f7844a38997c0b75051269f1d" - integrity sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg== - -is-glob@^4.0.3: - version "4.0.3" - resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.3.tgz#64f61e42cbbb2eec2071a9dac0b28ba1e65d5084" - integrity sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg== - dependencies: - is-extglob "^2.1.1" - -is-json@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/is-json/-/is-json-2.0.1.tgz#6be166d144828a131d686891b983df62c39491ff" - integrity sha1-a+Fm0USCihMdaGiRuYPfYsOUkf8= - -is-number@^7.0.0: - version "7.0.0" - resolved "https://registry.yarnpkg.com/is-number/-/is-number-7.0.0.tgz#7535345b896734d5f80c4d06c50955527a14f12b" - integrity sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng== - -isexe@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" - integrity sha1-6PvzdNxVb/iUehDcsFctYz8s+hA= - -js-tokens@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" - integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ== - -json-parse-even-better-errors@^2.3.0: - version "2.3.1" - resolved "https://registry.yarnpkg.com/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz#7c47805a94319928e05777405dc12e1f7a4ee02d" - integrity sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w== - -json5@^2.2.0, json5@^2.2.1: - version "2.2.3" - resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.3.tgz#78cd6f1a19bdc12b73db5ad0c61efd66c1e29283" - integrity sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg== - -jsonfile@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-4.0.0.tgz#8771aae0799b64076b76640fca058f9c10e33ecb" - integrity sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss= - optionalDependencies: - graceful-fs "^4.1.6" - -lightningcss-darwin-arm64@1.19.0: - version "1.19.0" - resolved "https://registry.yarnpkg.com/lightningcss-darwin-arm64/-/lightningcss-darwin-arm64-1.19.0.tgz#56ab071e932f845dbb7667f44f5b78441175a343" - integrity sha512-wIJmFtYX0rXHsXHSr4+sC5clwblEMji7HHQ4Ub1/CznVRxtCFha6JIt5JZaNf8vQrfdZnBxLLC6R8pC818jXqg== - -lightningcss-darwin-x64@1.19.0: - version "1.19.0" - resolved "https://registry.yarnpkg.com/lightningcss-darwin-x64/-/lightningcss-darwin-x64-1.19.0.tgz#c867308b88859ba61a2c46c82b1ca52ff73a1bd0" - integrity sha512-Lif1wD6P4poaw9c/4Uh2z+gmrWhw/HtXFoeZ3bEsv6Ia4tt8rOJBdkfVaUJ6VXmpKHALve+iTyP2+50xY1wKPw== - -lightningcss-linux-arm-gnueabihf@1.19.0: - version "1.19.0" - resolved "https://registry.yarnpkg.com/lightningcss-linux-arm-gnueabihf/-/lightningcss-linux-arm-gnueabihf-1.19.0.tgz#0f921dc45f2e5c3aea70fab98844ac0e5f2f81be" - integrity sha512-P15VXY5682mTXaiDtbnLYQflc8BYb774j2R84FgDLJTN6Qp0ZjWEFyN1SPqyfTj2B2TFjRHRUvQSSZ7qN4Weig== - -lightningcss-linux-arm64-gnu@1.19.0: - version "1.19.0" - resolved "https://registry.yarnpkg.com/lightningcss-linux-arm64-gnu/-/lightningcss-linux-arm64-gnu-1.19.0.tgz#027f9df9c7f4ffa127c37a71726245a5794d7ba2" - integrity sha512-zwXRjWqpev8wqO0sv0M1aM1PpjHz6RVIsBcxKszIG83Befuh4yNysjgHVplF9RTU7eozGe3Ts7r6we1+Qkqsww== - -lightningcss-linux-arm64-musl@1.19.0: - version "1.19.0" - resolved "https://registry.yarnpkg.com/lightningcss-linux-arm64-musl/-/lightningcss-linux-arm64-musl-1.19.0.tgz#85ea987da868524eac6db94f8e1eaa23d0b688a3" - integrity sha512-vSCKO7SDnZaFN9zEloKSZM5/kC5gbzUjoJQ43BvUpyTFUX7ACs/mDfl2Eq6fdz2+uWhUh7vf92c4EaaP4udEtA== - -lightningcss-linux-x64-gnu@1.19.0: - version "1.19.0" - resolved "https://registry.yarnpkg.com/lightningcss-linux-x64-gnu/-/lightningcss-linux-x64-gnu-1.19.0.tgz#02bec89579ab4153dccc0def755d1fd9e3ee7f3c" - integrity sha512-0AFQKvVzXf9byrXUq9z0anMGLdZJS+XSDqidyijI5njIwj6MdbvX2UZK/c4FfNmeRa2N/8ngTffoIuOUit5eIQ== - -lightningcss-linux-x64-musl@1.19.0: - version "1.19.0" - resolved "https://registry.yarnpkg.com/lightningcss-linux-x64-musl/-/lightningcss-linux-x64-musl-1.19.0.tgz#e36a5df8193ae961d22974635e4c100a1823bb8c" - integrity sha512-SJoM8CLPt6ECCgSuWe+g0qo8dqQYVcPiW2s19dxkmSI5+Uu1GIRzyKA0b7QqmEXolA+oSJhQqCmJpzjY4CuZAg== - -lightningcss-win32-x64-msvc@1.19.0: - version "1.19.0" - resolved "https://registry.yarnpkg.com/lightningcss-win32-x64-msvc/-/lightningcss-win32-x64-msvc-1.19.0.tgz#0854dbd153035eca1396e2227c708ad43655a61c" - integrity sha512-C+VuUTeSUOAaBZZOPT7Etn/agx/MatzJzGRkeV+zEABmPuntv1zihncsi+AyGmjkkzq3wVedEy7h0/4S84mUtg== - -lightningcss@^1.16.1: - version "1.19.0" - resolved "https://registry.yarnpkg.com/lightningcss/-/lightningcss-1.19.0.tgz#fbbad0975de66252e38d96b5bdd2a62f2dd0ffbf" - integrity sha512-yV5UR7og+Og7lQC+70DA7a8ta1uiOPnWPJfxa0wnxylev5qfo4P+4iMpzWAdYWOca4jdNQZii+bDL/l+4hUXIA== - dependencies: - detect-libc "^1.0.3" - optionalDependencies: - lightningcss-darwin-arm64 "1.19.0" - lightningcss-darwin-x64 "1.19.0" - lightningcss-linux-arm-gnueabihf "1.19.0" - lightningcss-linux-arm64-gnu "1.19.0" - lightningcss-linux-arm64-musl "1.19.0" - lightningcss-linux-x64-gnu "1.19.0" - lightningcss-linux-x64-musl "1.19.0" - lightningcss-win32-x64-msvc "1.19.0" - -lines-and-columns@^1.1.6: - version "1.2.4" - resolved "https://registry.yarnpkg.com/lines-and-columns/-/lines-and-columns-1.2.4.tgz#eca284f75d2965079309dc0ad9255abb2ebc1632" - integrity sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg== - -lmdb@2.5.2: - version "2.5.2" - resolved "https://registry.yarnpkg.com/lmdb/-/lmdb-2.5.2.tgz#37e28a9fb43405f4dc48c44cec0e13a14c4a6ff1" - integrity sha512-V5V5Xa2Hp9i2XsbDALkBTeHXnBXh/lEmk9p22zdr7jtuOIY9TGhjK6vAvTpOOx9IKU4hJkRWZxn/HsvR1ELLtA== - dependencies: - msgpackr "^1.5.4" - node-addon-api "^4.3.0" - node-gyp-build-optional-packages "5.0.3" - ordered-binary "^1.2.4" - weak-lru-cache "^1.2.2" - optionalDependencies: - "@lmdb/lmdb-darwin-arm64" "2.5.2" - "@lmdb/lmdb-darwin-x64" "2.5.2" - "@lmdb/lmdb-linux-arm" "2.5.2" - "@lmdb/lmdb-linux-arm64" "2.5.2" - "@lmdb/lmdb-linux-x64" "2.5.2" - "@lmdb/lmdb-win32-x64" "2.5.2" - -long@4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/long/-/long-4.0.0.tgz#9a7b71cfb7d361a194ea555241c92f7468d5bf28" - integrity sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA== - -mdn-data@2.0.14: - version "2.0.14" - resolved "https://registry.yarnpkg.com/mdn-data/-/mdn-data-2.0.14.tgz#7113fc4281917d63ce29b43446f701e68c25ba50" - integrity sha512-dn6wd0uw5GsdswPFfsgMp5NSB0/aDe6fK94YJV/AJDYXL6HVLWBsxeq7js7Ad+mU2K9LAlwpk6kN2D5mwCPVow== - -micromatch@^4.0.5: - version "4.0.5" - resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.5.tgz#bc8999a7cbbf77cdc89f132f6e467051b49090c6" - integrity sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA== - dependencies: - braces "^3.0.2" - picomatch "^2.3.1" - -minimatch@^3.0.4: - version "3.1.2" - resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b" - integrity sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw== - dependencies: - brace-expansion "^1.1.7" - -minimist@1.2.6: - version "1.2.6" - resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.6.tgz#8637a5b759ea0d6e98702cfb3a9283323c93af44" - integrity sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q== - -msgpackr-extract@^1.0.14: - version "1.0.16" - resolved "https://registry.yarnpkg.com/msgpackr-extract/-/msgpackr-extract-1.0.16.tgz#701c4f6e6f25c100ae84557092274e8fffeefe45" - integrity sha512-fxdRfQUxPrL/TizyfYfMn09dK58e+d65bRD/fcaVH4052vj30QOzzqxcQIS7B0NsqlypEQ/6Du3QmP2DhWFfCA== - dependencies: - nan "^2.14.2" - node-gyp-build "^4.2.3" - -msgpackr@^1.5.4: - version "1.5.5" - resolved "https://registry.yarnpkg.com/msgpackr/-/msgpackr-1.5.5.tgz#c0562abc2951d7e29f75d77a8656b01f103a042c" - integrity sha512-JG0V47xRIQ9pyUnx6Hb4+3TrQoia2nA3UIdmyTldhxaxtKFkekkKpUW/N6fwHwod9o4BGuJGtouxOk+yCP5PEA== - optionalDependencies: - msgpackr-extract "^1.0.14" - -nan@^2.14.2: - version "2.15.0" - resolved "https://registry.yarnpkg.com/nan/-/nan-2.15.0.tgz#3f34a473ff18e15c1b5626b62903b5ad6e665fee" - integrity sha512-8ZtvEnA2c5aYCZYd1cvgdnU6cqwixRoYg70xPLWUws5ORTa/lnw+u4amixRS/Ac5U5mQVgp9pnlSUnbNWFaWZQ== - -node-addon-api@^3.2.1: - version "3.2.1" - resolved "https://registry.yarnpkg.com/node-addon-api/-/node-addon-api-3.2.1.tgz#81325e0a2117789c0128dab65e7e38f07ceba161" - integrity sha512-mmcei9JghVNDYydghQmeDX8KoAm0FAiYyIcUt/N4nhyAipB17pllZQDOJD2fotxABnt4Mdz+dKTO7eftLg4d0A== - -node-addon-api@^4.3.0: - version "4.3.0" - resolved "https://registry.yarnpkg.com/node-addon-api/-/node-addon-api-4.3.0.tgz#52a1a0b475193e0928e98e0426a0d1254782b77f" - integrity sha512-73sE9+3UaLYYFmDsFZnqCInzPyh3MqIwZO9cw58yIqAZhONrrabrYyYe3TuIqtIiOuTXVhsGau8hcrhhwSsDIQ== - -node-fetch@~2.6.1: - version "2.6.7" - resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.7.tgz#24de9fba827e3b4ae44dc8b20256a379160052ad" - integrity sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ== - dependencies: - whatwg-url "^5.0.0" - -node-gyp-build-optional-packages@5.0.3: - version "5.0.3" - resolved "https://registry.yarnpkg.com/node-gyp-build-optional-packages/-/node-gyp-build-optional-packages-5.0.3.tgz#92a89d400352c44ad3975010368072b41ad66c17" - integrity sha512-k75jcVzk5wnnc/FMxsf4udAoTEUv2jY3ycfdSd3yWu6Cnd1oee6/CfZJApyscA4FJOmdoixWwiwOyf16RzD5JA== - -node-gyp-build@^4.2.3, node-gyp-build@^4.3.0: - version "4.3.0" - resolved "https://registry.yarnpkg.com/node-gyp-build/-/node-gyp-build-4.3.0.tgz#9f256b03e5826150be39c764bf51e993946d71a3" - integrity sha512-iWjXZvmboq0ja1pUGULQBexmxq8CV4xBhX7VDOTbL7ZR4FOowwY/VOtRxBN/yKxmdGoIp4j5ysNT4u3S2pDQ3Q== - -node-releases@^2.0.2: - version "2.0.2" - resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-2.0.2.tgz#7139fe71e2f4f11b47d4d2986aaf8c48699e0c01" - integrity sha512-XxYDdcQ6eKqp/YjI+tb2C5WM2LgjnZrfYg4vgQt49EK268b6gYCHsBLrK2qvJo4FmCtqmKezb0WZFK4fkrZNsg== - -npm-bundled@^1.1.1: - version "1.1.2" - resolved "https://registry.yarnpkg.com/npm-bundled/-/npm-bundled-1.1.2.tgz#944c78789bd739035b70baa2ca5cc32b8d860bc1" - integrity sha512-x5DHup0SuyQcmL3s7Rx/YQ8sbw/Hzg0rj48eN0dV7hf5cmQq5PXIeioroH3raV1QC1yh3uTYuMThvEQF3iKgGQ== - dependencies: - npm-normalize-package-bin "^1.0.1" - -npm-normalize-package-bin@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/npm-normalize-package-bin/-/npm-normalize-package-bin-1.0.1.tgz#6e79a41f23fd235c0623218228da7d9c23b8f6e2" - integrity sha512-EPfafl6JL5/rU+ot6P3gRSCpPDW5VmIzX959Ob1+ySFUuuYHWHekXpwdUZcKP5C+DS4GEtdJluwBjnsNDl+fSA== - -npm-packlist@^2.1.5: - version "2.2.2" - resolved "https://registry.yarnpkg.com/npm-packlist/-/npm-packlist-2.2.2.tgz#076b97293fa620f632833186a7a8f65aaa6148c8" - integrity sha512-Jt01acDvJRhJGthnUJVF/w6gumWOZxO7IkpY/lsX9//zqQgnF7OJaxgQXcerd4uQOLu7W5bkb4mChL9mdfm+Zg== - dependencies: - glob "^7.1.6" - ignore-walk "^3.0.3" - npm-bundled "^1.1.1" - npm-normalize-package-bin "^1.0.1" - -nth-check@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/nth-check/-/nth-check-2.0.1.tgz#2efe162f5c3da06a28959fbd3db75dbeea9f0fc2" - integrity sha512-it1vE95zF6dTT9lBsYbxvqh0Soy4SPowchj0UBGj/V6cTPnXXtQOPUbhZ6CmGzAD/rW22LQK6E96pcdJXk4A4w== - dependencies: - boolbase "^1.0.0" - -nullthrows@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/nullthrows/-/nullthrows-1.1.1.tgz#7818258843856ae971eae4208ad7d7eb19a431b1" - integrity sha512-2vPPEi+Z7WqML2jZYddDIfy5Dqb0r2fze2zTxNNknZaFpVHU3mFB3R+DWeJWGVx0ecvttSGlJTI+WG+8Z4cDWw== - -once@^1.3.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" - integrity sha1-WDsap3WWHUsROsF9nFC6753Xa9E= - dependencies: - wrappy "1" - -ordered-binary@^1.2.4: - version "1.2.4" - resolved "https://registry.yarnpkg.com/ordered-binary/-/ordered-binary-1.2.4.tgz#51d3a03af078a0bdba6c7bc8f4fedd1f5d45d83e" - integrity sha512-A/csN0d3n+igxBPfUrjbV5GC69LWj2pjZzAAeeHXLukQ4+fytfP4T1Lg0ju7MSPSwq7KtHkGaiwO8URZN5IpLg== - -parcel@~2.8.3: - version "2.8.3" - resolved "https://registry.yarnpkg.com/parcel/-/parcel-2.8.3.tgz#1ff71d7317274fd367379bc7310a52c6b75d30c2" - integrity sha512-5rMBpbNE72g6jZvkdR5gS2nyhwIXaJy8i65osOqs/+5b7zgf3eMKgjSsDrv6bhz3gzifsba6MBJiZdBckl+vnA== - dependencies: - "@parcel/config-default" "2.8.3" - "@parcel/core" "2.8.3" - "@parcel/diagnostic" "2.8.3" - "@parcel/events" "2.8.3" - "@parcel/fs" "2.8.3" - "@parcel/logger" "2.8.3" - "@parcel/package-manager" "2.8.3" - "@parcel/reporter-cli" "2.8.3" - "@parcel/reporter-dev-server" "2.8.3" - "@parcel/utils" "2.8.3" - chalk "^4.1.0" - commander "^7.0.0" - get-port "^4.2.0" - v8-compile-cache "^2.0.0" - -parent-module@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/parent-module/-/parent-module-1.0.1.tgz#691d2709e78c79fae3a156622452d00762caaaa2" - integrity sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g== - dependencies: - callsites "^3.0.0" - -parse-json@^5.0.0: - version "5.2.0" - resolved "https://registry.yarnpkg.com/parse-json/-/parse-json-5.2.0.tgz#c76fc66dee54231c962b22bcc8a72cf2f99753cd" - integrity sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg== - dependencies: - "@babel/code-frame" "^7.0.0" - error-ex "^1.3.1" - json-parse-even-better-errors "^2.3.0" - lines-and-columns "^1.1.6" - -path-is-absolute@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" - integrity sha1-F0uSaHNVNP+8es5r9TpanhtcX18= - -path-key@^3.1.0: - version "3.1.1" - resolved "https://registry.yarnpkg.com/path-key/-/path-key-3.1.1.tgz#581f6ade658cbba65a0d3380de7753295054f375" - integrity sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q== - -path-parse@^1.0.7: - version "1.0.7" - resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.7.tgz#fbc114b60ca42b30d9daf5858e4bd68bbedb6735" - integrity sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw== - -path-type@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/path-type/-/path-type-4.0.0.tgz#84ed01c0a7ba380afe09d90a8c180dcd9d03043b" - integrity sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw== - -picocolors@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/picocolors/-/picocolors-1.0.0.tgz#cb5bdc74ff3f51892236eaf79d68bc44564ab81c" - integrity sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ== - -picomatch@^2.3.1: - version "2.3.1" - resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42" - integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA== - -postcss-value-parser@^4.2.0: - version "4.2.0" - resolved "https://registry.yarnpkg.com/postcss-value-parser/-/postcss-value-parser-4.2.0.tgz#723c09920836ba6d3e5af019f92bc0971c02e514" - integrity sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ== - -posthtml-parser@^0.10.1: - version "0.10.2" - resolved "https://registry.yarnpkg.com/posthtml-parser/-/posthtml-parser-0.10.2.tgz#df364d7b179f2a6bf0466b56be7b98fd4e97c573" - integrity sha512-PId6zZ/2lyJi9LiKfe+i2xv57oEjJgWbsHGGANwos5AvdQp98i6AtamAl8gzSVFGfQ43Glb5D614cvZf012VKg== - dependencies: - htmlparser2 "^7.1.1" - -posthtml-parser@^0.11.0: - version "0.11.0" - resolved "https://registry.yarnpkg.com/posthtml-parser/-/posthtml-parser-0.11.0.tgz#25d1c7bf811ea83559bc4c21c189a29747a24b7a" - integrity sha512-QecJtfLekJbWVo/dMAA+OSwY79wpRmbqS5TeXvXSX+f0c6pW4/SE6inzZ2qkU7oAMCPqIDkZDvd/bQsSFUnKyw== - dependencies: - htmlparser2 "^7.1.1" - -posthtml-render@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/posthtml-render/-/posthtml-render-3.0.0.tgz#97be44931496f495b4f07b99e903cc70ad6a3205" - integrity sha512-z+16RoxK3fUPgwaIgH9NGnK1HKY9XIDpydky5eQGgAFVXTCSezalv9U2jQuNV+Z9qV1fDWNzldcw4eK0SSbqKA== - dependencies: - is-json "^2.0.1" - -posthtml@^0.16.4, posthtml@^0.16.5: - version "0.16.6" - resolved "https://registry.yarnpkg.com/posthtml/-/posthtml-0.16.6.tgz#e2fc407f67a64d2fa3567afe770409ffdadafe59" - integrity sha512-JcEmHlyLK/o0uGAlj65vgg+7LIms0xKXe60lcDOTU7oVX/3LuEuLwrQpW3VJ7de5TaFKiW4kWkaIpJL42FEgxQ== - dependencies: - posthtml-parser "^0.11.0" - posthtml-render "^3.0.0" - -react-error-overlay@6.0.9: - version "6.0.9" - resolved "https://registry.yarnpkg.com/react-error-overlay/-/react-error-overlay-6.0.9.tgz#3c743010c9359608c375ecd6bc76f35d93995b0a" - integrity sha512-nQTTcUu+ATDbrSD1BZHr5kgSD4oF8OFjxun8uAaL8RwPBacGBNPf/yAuVVdx17N8XNzRDMrZ9XcKZHCjPW+9ew== - -react-refresh@^0.9.0: - version "0.9.0" - resolved "https://registry.yarnpkg.com/react-refresh/-/react-refresh-0.9.0.tgz#71863337adc3e5c2f8a6bfddd12ae3bfe32aafbf" - integrity sha512-Gvzk7OZpiqKSkxsQvO/mbTN1poglhmAV7gR/DdIrRrSMXraRQQlfikRJOr3Nb9GTMPC5kof948Zy6jJZIFtDvQ== - -regenerator-runtime@^0.13.7: - version "0.13.9" - resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.9.tgz#8925742a98ffd90814988d7566ad30ca3b263b52" - integrity sha512-p3VT+cOEgxFsRRA9X4lkI1E+k2/CtnKtU4gcxyaCUreilL/vqI6CdZ3wxVUx3UOUg+gnUOQQcRI7BmSI656MYA== - -require-directory@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42" - integrity sha1-jGStX9MNqxyXbiNE/+f3kqam30I= - -resolve-from@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-4.0.0.tgz#4abcd852ad32dd7baabfe9b40e00a36db5f392e6" - integrity sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g== - -resolve@^1.1.6: - version "1.22.0" - resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.22.0.tgz#5e0b8c67c15df57a89bdbabe603a002f21731198" - integrity sha512-Hhtrw0nLeSrFQ7phPp4OOcVjLPIeMnRlr5mcnVuMe7M/7eBn98A3hmFRLoFo3DLZkivSYwhRUJTyPyWAk56WLw== - dependencies: - is-core-module "^2.8.1" - path-parse "^1.0.7" - supports-preserve-symlinks-flag "^1.0.0" - -safe-buffer@^5.0.1: - version "5.2.1" - resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" - integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== - -seedrandom@^3.0.5: - version "3.0.5" - resolved "https://registry.yarnpkg.com/seedrandom/-/seedrandom-3.0.5.tgz#54edc85c95222525b0c7a6f6b3543d8e0b3aa0a7" - integrity sha512-8OwmbklUNzwezjGInmZ+2clQmExQPvomqjL7LFqOYqtmuxRgQYqOD3mHaU+MvZn5FLUeVxVfQjwLZW/n/JFuqg== - -semver@^5.7.0, semver@^5.7.1: - version "5.7.1" - resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" - integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ== - -shebang-command@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-2.0.0.tgz#ccd0af4f8835fbdc265b82461aaf0c36663f34ea" - integrity sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA== - dependencies: - shebang-regex "^3.0.0" - -shebang-regex@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-3.0.0.tgz#ae16f1644d873ecad843b0307b143362d4c42172" - integrity sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A== - -source-map-support@~0.5.20: - version "0.5.21" - resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.21.tgz#04fe7c7f9e1ed2d662233c28cb2b35b9f63f6e4f" - integrity sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w== - dependencies: - buffer-from "^1.0.0" - source-map "^0.6.0" - -source-map@^0.6.0, source-map@^0.6.1: - version "0.6.1" - resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" - integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== - -srcset@4: - version "4.0.0" - resolved "https://registry.yarnpkg.com/srcset/-/srcset-4.0.0.tgz#336816b665b14cd013ba545b6fe62357f86e65f4" - integrity sha512-wvLeHgcVHKO8Sc/H/5lkGreJQVeYMm9rlmt8PuR1xE31rIuXhuzznUUqAt8MqLhB3MqJdFzlNAfpcWnxiFUcPw== - -stable@^0.1.8: - version "0.1.8" - resolved "https://registry.yarnpkg.com/stable/-/stable-0.1.8.tgz#836eb3c8382fe2936feaf544631017ce7d47a3cf" - integrity sha512-ji9qxRnOVfcuLDySj9qzhGSEFVobyt1kIOSkj1qZzYLzq7Tos/oUUWvotUPQLlrsidqsK6tBH89Bc9kL5zHA6w== - -string-width@^4.1.0, string-width@^4.2.0: - version "4.2.3" - resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" - integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== - dependencies: - emoji-regex "^8.0.0" - is-fullwidth-code-point "^3.0.0" - strip-ansi "^6.0.1" - -strip-ansi@^6.0.0, strip-ansi@^6.0.1: - version "6.0.1" - resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" - integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== - dependencies: - ansi-regex "^5.0.1" - -supports-color@^5.3.0: - version "5.5.0" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f" - integrity sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow== - dependencies: - has-flag "^3.0.0" - -supports-color@^7.1.0: - version "7.2.0" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-7.2.0.tgz#1b7dcdcb32b8138801b3e478ba6a51caa89648da" - integrity sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw== - dependencies: - has-flag "^4.0.0" - -supports-preserve-symlinks-flag@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz#6eda4bd344a3c94aea376d4cc31bc77311039e09" - integrity sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w== - -svgo@^2.4.0: - version "2.8.0" - resolved "https://registry.yarnpkg.com/svgo/-/svgo-2.8.0.tgz#4ff80cce6710dc2795f0c7c74101e6764cfccd24" - integrity sha512-+N/Q9kV1+F+UeWYoSiULYo4xYSDQlTgb+ayMobAXPwMnLvop7oxKMo9OzIrX5x3eS4L4f2UHhc9axXwY8DpChg== - dependencies: - "@trysound/sax" "0.2.0" - commander "^7.2.0" - css-select "^4.1.3" - css-tree "^1.1.3" - csso "^4.2.0" - picocolors "^1.0.0" - stable "^0.1.8" - -term-size@^2.2.1: - version "2.2.1" - resolved "https://registry.yarnpkg.com/term-size/-/term-size-2.2.1.tgz#2a6a54840432c2fb6320fea0f415531e90189f54" - integrity sha512-wK0Ri4fOGjv/XPy8SBHZChl8CM7uMc5VML7SqiQ0zG7+J5Vr+RMQDoHa2CNT6KHUnTGIXH34UDMkPzAUyapBZg== - -terser@^5.2.0: - version "5.14.2" - resolved "https://registry.yarnpkg.com/terser/-/terser-5.14.2.tgz#9ac9f22b06994d736174f4091aa368db896f1c10" - integrity sha512-oL0rGeM/WFQCUd0y2QrWxYnq7tfSuKBiqTjRPWrRgB46WD/kiwHwF8T23z78H6Q6kGCuuHcPB+KULHRdxvVGQA== - dependencies: - "@jridgewell/source-map" "^0.3.2" - acorn "^8.5.0" - commander "^2.20.0" - source-map-support "~0.5.20" - -timsort@^0.3.0: - version "0.3.0" - resolved "https://registry.yarnpkg.com/timsort/-/timsort-0.3.0.tgz#405411a8e7e6339fe64db9a234de11dc31e02bd4" - integrity sha1-QFQRqOfmM5/mTbmiNN4R3DHgK9Q= - -to-regex-range@^5.0.1: - version "5.0.1" - resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-5.0.1.tgz#1648c44aae7c8d988a326018ed72f5b4dd0392e4" - integrity sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ== - dependencies: - is-number "^7.0.0" - -tr46@~0.0.3: - version "0.0.3" - resolved "https://registry.yarnpkg.com/tr46/-/tr46-0.0.3.tgz#8184fd347dac9cdc185992f3a6622e14b9d9ab6a" - integrity sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o= - -tslib@^2.4.0: - version "2.5.0" - resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.5.0.tgz#42bfed86f5787aeb41d031866c8f402429e0fddf" - integrity sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg== - -type-fest@^0.20.2: - version "0.20.2" - resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.20.2.tgz#1bf207f4b28f91583666cb5fbd327887301cd5f4" - integrity sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ== - -universalify@^0.1.0: - version "0.1.2" - resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.2.tgz#b646f69be3942dabcecc9d6639c80dc105efaa66" - integrity sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg== - -utility-types@^3.10.0: - version "3.10.0" - resolved "https://registry.yarnpkg.com/utility-types/-/utility-types-3.10.0.tgz#ea4148f9a741015f05ed74fd615e1d20e6bed82b" - integrity sha512-O11mqxmi7wMKCo6HKFt5AhO4BwY3VV68YU07tgxfz8zJTIxr4BpsezN49Ffwy9j3ZpwwJp4fkRwjRzq3uWE6Rg== - -v8-compile-cache@^2.0.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz#2de19618c66dc247dcfb6f99338035d8245a2cee" - integrity sha512-l8lCEmLcLYZh4nbunNZvQCJc5pv7+RCwa8q/LdUx8u7lsWvPDKmpodJAJNwkAhJC//dFY48KuIEmjtd4RViDrA== - -weak-lru-cache@^1.2.2: - version "1.2.2" - resolved "https://registry.yarnpkg.com/weak-lru-cache/-/weak-lru-cache-1.2.2.tgz#fdbb6741f36bae9540d12f480ce8254060dccd19" - integrity sha512-DEAoo25RfSYMuTGc9vPJzZcZullwIqRDSI9LOy+fkCJPi6hykCnfKaXTuPBDuXAUcqHXyOgFtHNp/kB2FjYHbw== - -webidl-conversions@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871" - integrity sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE= - -whatwg-url@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-5.0.0.tgz#966454e8765462e37644d3626f6742ce8b70965d" - integrity sha1-lmRU6HZUYuN2RNNib2dCzotwll0= - dependencies: - tr46 "~0.0.3" - webidl-conversions "^3.0.0" - -which@^2.0.1: - version "2.0.2" - resolved "https://registry.yarnpkg.com/which/-/which-2.0.2.tgz#7c6a8dd0a636a0327e10b59c9286eee93f3f51b1" - integrity sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA== - dependencies: - isexe "^2.0.0" - -wrap-ansi@^7.0.0: - version "7.0.0" - resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" - integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== - dependencies: - ansi-styles "^4.0.0" - string-width "^4.1.0" - strip-ansi "^6.0.0" - -wrappy@1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" - integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8= - -xxhash-wasm@^0.4.2: - version "0.4.2" - resolved "https://registry.yarnpkg.com/xxhash-wasm/-/xxhash-wasm-0.4.2.tgz#752398c131a4dd407b5132ba62ad372029be6f79" - integrity sha512-/eyHVRJQCirEkSZ1agRSCwriMhwlyUcFkXD5TPVSLP+IPzjsqMVzZwdoczLp1SoQU0R3dxz1RpIK+4YNQbCVOA== - -y18n@^5.0.5: - version "5.0.8" - resolved "https://registry.yarnpkg.com/y18n/-/y18n-5.0.8.tgz#7f4934d0f7ca8c56f95314939ddcd2dd91ce1d55" - integrity sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA== - -yalc@~1.0.0-pre.53: - version "1.0.0-pre.53" - resolved "https://registry.yarnpkg.com/yalc/-/yalc-1.0.0-pre.53.tgz#c51db2bb924a6908f4cb7e82af78f7e5606810bc" - integrity sha512-tpNqBCpTXplnduzw5XC+FF8zNJ9L/UXmvQyyQj7NKrDNavbJtHvzmZplL5ES/RCnjX7JR7W9wz5GVDXVP3dHUQ== - dependencies: - chalk "^4.1.0" - detect-indent "^6.0.0" - fs-extra "^8.0.1" - glob "^7.1.4" - ignore "^5.0.4" - ini "^2.0.0" - npm-packlist "^2.1.5" - yargs "^16.1.1" - -yaml@^1.10.0: - version "1.10.2" - resolved "https://registry.yarnpkg.com/yaml/-/yaml-1.10.2.tgz#2301c5ffbf12b467de8da2333a459e29e7920e4b" - integrity sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg== - -yargs-parser@^20.2.2: - version "20.2.9" - resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.9.tgz#2eb7dc3b0289718fc295f362753845c41a0c94ee" - integrity sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w== - -yargs@^16.1.1: - version "16.2.0" - resolved "https://registry.yarnpkg.com/yargs/-/yargs-16.2.0.tgz#1c82bf0f6b6a66eafce7ef30e376f49a12477f66" - integrity sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw== - dependencies: - cliui "^7.0.2" - escalade "^3.1.1" - get-caller-file "^2.0.5" - require-directory "^2.1.1" - string-width "^4.2.0" - y18n "^5.0.5" - yargs-parser "^20.2.2" diff --git a/tfjs-master/tfjs-automl/karma.conf.js b/tfjs-master/tfjs-automl/karma.conf.js deleted file mode 100644 index 67a8c219b..000000000 --- a/tfjs-master/tfjs-automl/karma.conf.js +++ /dev/null @@ -1,122 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -const karmaTypescriptConfig = { - tsconfig: 'tsconfig.test.json', - // Disable coverage reports and instrumentation by default for tests - coverageOptions: {instrumentation: false}, - reports: {}, - bundlerOptions: { - sourceMap: true, // Process any non es5 code through - // karma-typescript-es6-transform (babel) - acornOptions: {ecmaVersion: 11}, - transforms: [ - require('karma-typescript-es6-transform')({ - presets: [ - // ensure we get es5 by adding IE 11 as a target - ['@babel/env', {'targets': {'ie': '11'}, 'loose': true}] - ] - }), - ] - } -}; - -// Enable coverage reports and instrumentation under KARMA_COVERAGE=1 env -const coverageEnabled = !!process.env.KARMA_COVERAGE; -if (coverageEnabled) { - karmaTypescriptConfig.coverageOptions.instrumentation = true; - karmaTypescriptConfig.coverageOptions.exclude = [ - /test_browser\.ts/, - /test_util\.ts/, - /_test\.ts/ - ]; - karmaTypescriptConfig.reports = {html: 'coverage', 'text-summary': ''}; -} - -module.exports = function(config) { - const args = []; - if (config.testEnv) { - args.push('--testEnv', config.testEnv); - } - if (config.grep) { - args.push('--grep', config.grep); - } - if (config.flags) { - args.push('--flags', config.flags); - } - - config.set({ - basePath: '', - frameworks: ['jasmine', 'karma-typescript'], - files: [ - {pattern: './node_modules/@babel/polyfill/dist/polyfill.js'}, - 'src/test_browser.ts', - {pattern: 'src/**/*.ts'}, - ], - exclude: ['src/test_node.ts'], - preprocessors: {'**/*.ts': ['karma-typescript']}, - karmaTypescriptConfig, - reporters: ['progress', 'karma-typescript'], - port: 9200, - colors: true, - browsers: ['Chrome'], - client: {jasmine: {random: false}, args: args}, - browserStack: { - username: process.env.BROWSERSTACK_USERNAME, - accessKey: process.env.BROWSERSTACK_KEY, - timeout: 900, // Seconds - tunnelIdentifier: - `tfjs_automl_${Date.now()}_${Math.floor(Math.random() * 1000)}` - }, - captureTimeout: 10 * 1000, - reportSlowerThan: 500, - browserNoActivityTimeout: 3e5, - browserDisconnectTimeout: 3e5, - browserDisconnectTolerance: 0, - browserSocketTimeout: 1.2e5, - customLaunchers: { - bs_chrome_mac: { - base: 'BrowserStack', - browser: 'chrome', - browser_version: 'latest', - os: 'OS X', - os_version: 'Ventura' - }, - bs_firefox_mac: { - base: 'BrowserStack', - browser: 'firefox', - browser_version: 'latest', - os: 'OS X', - os_version: 'Ventura' - }, - bs_safari_mac: { - base: 'BrowserStack', - browser: 'safari', - browser_version: 'latest', - os: 'OS X', - os_version: 'Ventura' - }, - bs_ios_12: { - base: 'BrowserStack', - device: 'iPhone X', - os: 'iOS', - os_version: '11.0', - real_mobile: true - }, - } - }) -} diff --git a/tfjs-master/tfjs-automl/package.json b/tfjs-master/tfjs-automl/package.json deleted file mode 100644 index dca63ac78..000000000 --- a/tfjs-master/tfjs-automl/package.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "name": "@tensorflow/tfjs-automl", - "version": "1.2.0", - "main": "dist/tf-automl.node.js", - "types": "dist/index.d.ts", - "module": "dist/tf-automl.esm.js", - "unpkg": "dist/tf-automl.min.js", - "jsdelivr": "dist/tf-automl.min.js", - "scripts": { - "build": "tsc && yarn bundle", - "bundle": "rollup -c", - "lint": "tslint -p . -t verbose", - "test": "yarn && yarn build && karma start", - "test-dev": "karma start", - "test-node": "tsc && ts-node --transpile-only --skip-ignore --project tsconfig.test.json src/test_node.ts", - "coverage": "KARMA_COVERAGE=1 karma start --singleRun", - "run-flaky": "node ../scripts/run_flaky.js", - "run-browserstack": "karma start --singleRun --reporters='dots,karma-typescript,BrowserStack'", - "test-ci": "./scripts/test-ci.sh", - "build-npm": "./scripts/build-npm.sh" - }, - "license": "Apache-2.0", - "repository": { - "type": "git", - "url": "https://github.com/tensorflow/tfjs.git", - "directory": "tfjs-automl" - }, - "devDependencies": { - "@babel/polyfill": "^7.8.7", - "@tensorflow/tfjs-backend-webgl": "^4.9.0", - "@tensorflow/tfjs-converter": "^4.9.0", - "@tensorflow/tfjs-core": "^4.9.0", - "@types/jasmine": "~4.3.1", - "clang-format": "~1.8.0", - "jasmine": "4.5.0", - "jasmine-core": "~4.5.0", - "karma": "~6.4.1", - "karma-browserstack-launcher": "~1.6.0", - "karma-chrome-launcher": "~3.1.1", - "karma-commonjs": "^1.0.0", - "karma-firefox-launcher": "~2.1.2", - "karma-jasmine": "~5.1.0", - "karma-safari-launcher": "~1.0.0", - "karma-typescript": "~5.5.3", - "karma-typescript-es6-transform": "^5.5.3", - "npm-run-all": "~4.1.5", - "rimraf": "~4.1.2", - "rollup": "^3.17.2", - "rollup-plugin-commonjs": "10.1.0", - "rollup-plugin-node-resolve": "5.2.0", - "rollup-plugin-terser": "^7.0.2", - "rollup-plugin-typescript2": "0.34.1", - "rollup-plugin-uglify": "~6.0.4", - "ts-node": "^10.9.1", - "tslint": "~6.1.3", - "tslint-no-circular-imports": "^0.7.0", - "typescript": "5.0.4", - "yalc": "~1.0.0-pre.21" - }, - "peerDependencies": { - "@tensorflow/tfjs-backend-webgl": "^3.9.0", - "@tensorflow/tfjs-converter": "^3.9.0", - "@tensorflow/tfjs-core": "^3.9.0" - } -} diff --git a/tfjs-master/tfjs-automl/rollup.config.mjs b/tfjs-master/tfjs-automl/rollup.config.mjs deleted file mode 100644 index 92dac69ab..000000000 --- a/tfjs-master/tfjs-automl/rollup.config.mjs +++ /dev/null @@ -1,125 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import commonjs from 'rollup-plugin-commonjs'; -import node from 'rollup-plugin-node-resolve'; -import {terser} from 'rollup-plugin-terser'; -import typescript from 'rollup-plugin-typescript2'; - -const PREAMBLE = `/** - * @license - * Copyright ${(new Date).getFullYear()} Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */`; - -function config({plugins = [], output = {}}) { - return { - input: 'src/index.ts', - plugins: [ - typescript({tsconfigOverride: {compilerOptions: {module: 'ES2015'}}}), - node(), - // Polyfill require() from dependencies. - commonjs({ - ignore: ['crypto', 'node-fetch', 'util'], - include: 'node_modules/**', - }), - ...plugins - ], - output: { - banner: PREAMBLE, - sourcemap: true, - globals: { - 'node-fetch': 'nodeFetch', - '@tensorflow/tfjs-core': 'tf', - '@tensorflow/tfjs-converter': 'tf', - }, - ...output, - }, - external: [ - 'crypto', - 'node-fetch', - '@tensorflow/tfjs-core', - '@tensorflow/tfjs-converter', - ], - onwarn: warning => { - let {code} = warning; - if (code === 'CIRCULAR_DEPENDENCY' || code === 'CIRCULAR' || - code === 'THIS_IS_UNDEFINED') { - return; - } - console.warn('WARNING: ', warning.toString()); - } - }; -} - -export default cmdOptions => { - const bundles = []; - - // Node - bundles.push(config({ - output: { - format: 'cjs', - name: 'tf.automl', - extend: true, - file: `dist/tf-automl.node.js`, - freeze: false - }, - tsCompilerOptions: {target: 'es5'} - })); - - // tf-automl.js - bundles.push(config({ - output: { - format: 'umd', - name: 'tf.automl', - extend: true, - file: 'dist/tf-automl.js', - } - })); - - // tf-automl.min.js - bundles.push(config({ - plugins: [terser({output: {preamble: PREAMBLE}})], - output: { - format: 'umd', - name: 'tf.automl', - extend: true, - file: 'dist/tf-automl.min.js', - } - })); - - // tf-automl.esm.js - bundles.push(config({ - plugins: [terser({output: {preamble: PREAMBLE}})], - output: { - format: 'es', - file: 'dist/tf-automl.esm.js', - } - })); - return bundles; -}; diff --git a/tfjs-master/tfjs-automl/scripts/build-npm.sh b/tfjs-master/tfjs-automl/scripts/build-npm.sh deleted file mode 100644 index 6f48cfb8a..000000000 --- a/tfjs-master/tfjs-automl/scripts/build-npm.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env bash -# Copyright 2019 Google LLC. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================= - -set -e - -yarn rimraf dist/ -yarn -yarn build -yarn rollup -c - -echo "Stored standalone library at dist/tf-automl(.min).js" diff --git a/tfjs-master/tfjs-automl/scripts/test-ci.sh b/tfjs-master/tfjs-automl/scripts/test-ci.sh deleted file mode 100644 index 6c4dee491..000000000 --- a/tfjs-master/tfjs-automl/scripts/test-ci.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/env bash -# Copyright 2018 Google LLC. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================= - -set -e - -yarn -yarn lint -yarn build - -# Run the first karma separately so it can download the BrowserStack binary -# without conflicting with others. -yarn run-flaky "yarn run-browserstack --browsers=bs_chrome_mac" - -# Run the rest of the karma tests in parallel. These runs will reuse the -# already downloaded binary. -npm-run-all -p -c --aggregate-output \ - "run-flaky \"yarn run-browserstack --browsers=bs_firefox_mac\"" \ - "run-flaky \"yarn run-browserstack --browsers=bs_safari_mac --testEnv webgl1\"" diff --git a/tfjs-master/tfjs-automl/src/img_classification.ts b/tfjs-master/tfjs-automl/src/img_classification.ts deleted file mode 100644 index 5626dc6c7..000000000 --- a/tfjs-master/tfjs-automl/src/img_classification.ts +++ /dev/null @@ -1,103 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {GraphModel, loadGraphModel} from '@tensorflow/tfjs-converter'; -import {cast, div, expandDims, image, sub, Tensor, Tensor3D, Tensor4D, tidy} from '@tensorflow/tfjs-core'; - -import {ImageInput} from './types'; -import {imageToTensor, loadDictionary} from './util'; - -export interface ImagePrediction { - prob: number; - label: string; -} - -export interface ImageClassificationOptions { - centerCrop: boolean; -} - -/** Input size as expected by the model. */ -const IMG_SIZE: [number, number] = [224, 224]; -// Constants used to normalize the image between -1 and 1. -const DIV_FACTOR = 127.5; -const SUB_FACTOR = 1; - -export class ImageClassificationModel { - constructor(public graphModel: GraphModel, public dictionary: string[]) {} - - async classify(input: ImageInput, options?: ImageClassificationOptions): - Promise { - options = sanitizeOptions(options); - - const scores = tidy(() => { - const preprocessedImg = this.preprocess(input, options); - return this.graphModel.predict(preprocessedImg) as Tensor; - }); - const probabilities = await scores.data() as Float32Array; - scores.dispose(); - const result = Array.from(probabilities) - .map((prob, i) => ({label: this.dictionary[i], prob})); - return result; - } - - private preprocess(input: ImageInput, options: ImageClassificationOptions) { - // Preprocessing involves center crop and normalizing between [-1, 1]. - const img = imageToTensor(input); - const croppedImg = options.centerCrop ? - centerCropAndResize(img) : - expandDims(image.resizeBilinear(img, IMG_SIZE)); - return sub(div(croppedImg, DIV_FACTOR), SUB_FACTOR); - } -} - -export async function loadImageClassification(modelUrl: string): - Promise { - const [model, dict] = - await Promise.all([loadGraphModel(modelUrl), loadDictionary(modelUrl)]); - return new ImageClassificationModel(model, dict); -} - -function sanitizeOptions(options: ImageClassificationOptions) { - options = options || {} as ImageClassificationOptions; - if (options.centerCrop == null) { - options.centerCrop = true; - } - return options; -} - -/** Center crops an image */ -function centerCropAndResize(img: Tensor3D) { - return tidy(() => { - const [height, width] = img.shape.slice(0, 2); - let top = 0; - let left = 0; - if (height > width) { - top = (height - width) / 2; - } else { - left = (width - height) / 2; - } - const size = Math.min(width, height); - const boxes = [ - [top / height, left / width, (top + size) / height, (left + size) / width] - ]; - const boxIndices = [0]; - return image.cropAndResize( - // tslint:disable-next-line - expandDims(cast(img, 'float32')) as Tensor4D, boxes, boxIndices, - IMG_SIZE); - }); -} diff --git a/tfjs-master/tfjs-automl/src/img_classification_test.ts b/tfjs-master/tfjs-automl/src/img_classification_test.ts deleted file mode 100644 index 1616f5d95..000000000 --- a/tfjs-master/tfjs-automl/src/img_classification_test.ts +++ /dev/null @@ -1,131 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {GraphModel} from '@tensorflow/tfjs-converter'; -import * as tf from '@tensorflow/tfjs-core'; -// tslint:disable-next-line: no-imports-from-dist -import {BROWSER_ENVS, describeWithFlags} from '@tensorflow/tfjs-core/dist/jasmine_util'; - -import * as automl from './index'; -import {fetchImage} from './test_util'; - -const MODEL_URL = - 'https://storage.googleapis.com/tfjs-testing/tfjs-automl/img_classification/model.json'; - -const DAISY_URL = - 'https://storage.googleapis.com/tfjs-testing/tfjs-automl/img_classification/daisy.jpg'; - -describeWithFlags('image classification', {}, () => { - let model: automl.ImageClassificationModel = null; - - beforeAll(async () => { - model = await automl.loadImageClassification(MODEL_URL); - }); - - it('make prediction from a tensor', async () => { - const img: tf.Tensor3D = tf.zeros([100, 80, 3]); - const predictions = await model.classify(img); - expect(predictions[0].label).toBe('daisy'); - expect(predictions[1].label).toBe('dandelion'); - expect(predictions[2].label).toBe('roses'); - - tf.test_util.expectNumbersClose(predictions[0].prob, 0.5806022); - tf.test_util.expectNumbersClose(predictions[1].prob, 0.32249659); - tf.test_util.expectNumbersClose(predictions[2].prob, 0.0283515); - }); - - it('make prediction from a tensor without cropping', async () => { - const img: tf.Tensor3D = tf.zeros([100, 80, 3]); - const predictions = await model.classify(img, {centerCrop: false}); - expect(predictions[0].label).toBe('daisy'); - expect(predictions[1].label).toBe('dandelion'); - expect(predictions[2].label).toBe('roses'); - - tf.test_util.expectNumbersClose(predictions[0].prob, 0.5806022); - tf.test_util.expectNumbersClose(predictions[1].prob, 0.32249659); - tf.test_util.expectNumbersClose(predictions[2].prob, 0.0283515); - }); - - it('no memory leak when making a prediction', async () => { - const img: tf.Tensor3D = tf.zeros([100, 80, 3]); - const numTensorsBefore = tf.memory().numTensors; - await model.classify(img); - const numTensorsAfter = tf.memory().numTensors; - expect(numTensorsAfter).toEqual(numTensorsBefore); - }); - - it('has access to dictionary', () => { - expect(model.dictionary).toEqual([ - 'daisy', 'dandelion', 'roses', 'sunflowers', 'tulips' - ]); - }); - - it('can access the underlying graph model', () => { - expect(model.graphModel instanceof GraphModel).toBe(true); - expect(model.graphModel.inputNodes).toEqual(['image']); - expect(model.graphModel.outputNodes).toEqual(['scores']); - const img: tf.Tensor = tf.zeros([1, 224, 224, 3]); - const scores = model.graphModel.predict(img) as tf.Tensor; - expect(scores.shape).toEqual([1, 5]); - }); -}); - -describeWithFlags('image classification browser', BROWSER_ENVS, () => { - let model: automl.ImageClassificationModel = null; - let daisyImg: HTMLImageElement; - - beforeAll(async () => { - model = await automl.loadImageClassification(MODEL_URL); - daisyImg = await fetchImage(DAISY_URL); - }); - - function assertTop3PredsForDaisy( - predictions: automl.ImagePrediction[], centerCrop: boolean) { - const probs = centerCrop ? [0.9310929, 0.0273733, 0.0130559] : - [0.8411523, 0.0729438, 0.03020708]; - expect(predictions[0].label).toBe('daisy'); - tf.test_util.expectNumbersClose(predictions[0].prob, probs[0]); - - expect(predictions[1].label).toBe('dandelion'); - tf.test_util.expectNumbersClose(predictions[1].prob, probs[1]); - - expect(predictions[2].label).toBe('roses'); - tf.test_util.expectNumbersClose(predictions[2].prob, probs[2]); - } - - it('make prediction from an image element', async () => { - const predictions = await model.classify(daisyImg); - assertTop3PredsForDaisy(predictions, true /* centerCrop */); - }); - - it('make prediction from a canvas element', async () => { - // Copy the pixels from the image to a canvas. - const canvas = document.createElement('canvas'); - const ctx = canvas.getContext('2d'); - canvas.width = daisyImg.width; - canvas.height = daisyImg.height; - ctx.drawImage(daisyImg, 0, 0, daisyImg.width, daisyImg.height); - - const predictions = await model.classify(canvas); - assertTop3PredsForDaisy(predictions, true /* centerCrop */); - }); - - it('make prediction without center cropping', async () => { - const predictions = await model.classify(daisyImg, {centerCrop: false}); - assertTop3PredsForDaisy(predictions, false /* centerCrop */); - }); -}); diff --git a/tfjs-master/tfjs-automl/src/index.ts b/tfjs-master/tfjs-automl/src/index.ts deleted file mode 100644 index a93c3b7d8..000000000 --- a/tfjs-master/tfjs-automl/src/index.ts +++ /dev/null @@ -1,25 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// Image classification API. -export {ImageClassificationModel, ImageClassificationOptions, ImagePrediction, loadImageClassification} from './img_classification'; -// Object detection API. -export {Box, loadObjectDetection, ObjectDetectionModel, ObjectDetectionOptions, PredictedObject} from './object_detection'; - -// Shared API. -export {ImageInput} from './types'; -export {version} from './version'; diff --git a/tfjs-master/tfjs-automl/src/index_test.ts b/tfjs-master/tfjs-automl/src/index_test.ts deleted file mode 100644 index 4f0a04ebd..000000000 --- a/tfjs-master/tfjs-automl/src/index_test.ts +++ /dev/null @@ -1,26 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as automl from './index'; - -describe('public API', () => { - it('exported version matches package version', () => { - // tslint:disable-next-line:no-require-imports - const expected = require('../package.json').version; - expect(automl.version).toBe(expected); - }); -}); diff --git a/tfjs-master/tfjs-automl/src/object_detection.ts b/tfjs-master/tfjs-automl/src/object_detection.ts deleted file mode 100644 index cc0dbcdba..000000000 --- a/tfjs-master/tfjs-automl/src/object_detection.ts +++ /dev/null @@ -1,173 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {GraphModel, loadGraphModel} from '@tensorflow/tfjs-converter'; -import {cast, dispose, expandDims, image, Tensor, Tensor2D, tidy} from '@tensorflow/tfjs-core'; - -import {ImageInput} from './types'; -import {imageToTensor, loadDictionary} from './util'; - -const DEFAULT_TOPK = 20; -const DEFAULT_IOU_THRESHOLD = 0.5; -const DEFAULT_SCORE_THRESHOLD = 0.5; - -const INPUT_NODE_NAME = 'ToFloat'; -const OUTPUT_NODE_NAMES = - ['Postprocessor/convert_scores', 'Postprocessor/Decode/transpose_1']; - -export interface ObjectDetectionOptions { - /** - * Only the `topk` most likely objects are returned. The actual number of - * objects might be less than this number. - */ - topk?: number; - /** - * Intersection over union threshold. IoU is a metric between 0 and 1 used to - * measure the overlap of two boxes. The predicted boxes will not overlap more - * than the specified threshold. - */ - iou?: number; - /** Boxes with score lower than this threshold will be ignored. */ - score?: number; -} - -/** Contains the coordinates of a bounding box. */ -export interface Box { - /** Number of pixels from the top of the image (top padding). */ - top: number; - /** Number of pixels from the left of the image (left padding). */ - left: number; - /** The width of the box. */ - width: number; - /** The height of the box. */ - height: number; -} - -/** The predicted object, which holds the score, label and bounding box. */ -export interface PredictedObject { - box: Box; - score: number; - label: string; -} - -export class ObjectDetectionModel { - constructor(public graphModel: GraphModel, public dictionary: string[]) {} - - async detect(input: ImageInput, options?: ObjectDetectionOptions): - Promise { - options = sanitizeOptions(options); - const img = tidy(() => this.preprocess(input, options)); - const [height, width] = [img.shape[1], img.shape[2]]; - const feedDict: {[name: string]: Tensor} = {}; - feedDict[INPUT_NODE_NAME] = img; - const [scoresTensor, boxesTensor] = - await this.graphModel.executeAsync(feedDict, OUTPUT_NODE_NAMES) as - Tensor[]; - - const [, numBoxes, numClasses] = scoresTensor.shape; - const [scores, boxes] = - await Promise.all([scoresTensor.data(), boxesTensor.data()]); - const {boxScores, boxLabels} = - calculateMostLikelyLabels(scores as Float32Array, numBoxes, numClasses); - - // Sort the boxes by score, ignoring overlapping boxes. - const selectedBoxesTensor = await image.nonMaxSuppressionAsync( - boxesTensor as Tensor2D, boxScores, options.topk, options.iou, - options.score); - const selectedBoxes = await selectedBoxesTensor.data() as Int32Array; - dispose([img, scoresTensor, boxesTensor, selectedBoxesTensor]); - - const result = buildDetectedObjects( - width, height, boxes as Float32Array, boxScores, boxLabels, - selectedBoxes, this.dictionary); - return result; - } - - private preprocess(input: ImageInput, options: ObjectDetectionOptions) { - return cast(expandDims(imageToTensor(input)), 'float32'); - } -} - -export async function loadObjectDetection(modelUrl: string): - Promise { - const [model, dict] = - await Promise.all([loadGraphModel(modelUrl), loadDictionary(modelUrl)]); - return new ObjectDetectionModel(model, dict); -} - -function sanitizeOptions(options: ObjectDetectionOptions) { - options = options || {} as ObjectDetectionOptions; - if (options.topk == null) { - options.topk = DEFAULT_TOPK; - } - if (options.iou == null) { - options.iou = DEFAULT_IOU_THRESHOLD; - } - if (options.score == null) { - options.score = DEFAULT_SCORE_THRESHOLD; - } - return options; -} - -function calculateMostLikelyLabels( - scores: Float32Array, numBoxes: number, - numClasses: number): {boxScores: number[], boxLabels: number[]} { - // Holds a score for each box. - const boxScores: number[] = []; - // Holds the label id for each box. - const boxLabels: number[] = []; - for (let i = 0; i < numBoxes; i++) { - let maxScore = Number.MIN_VALUE; - let mostLikelyLabel = -1; - for (let j = 0; j < numClasses; j++) { - const flatIndex = i * numClasses + j; - const score = scores[flatIndex]; - if (score > maxScore) { - maxScore = scores[flatIndex]; - mostLikelyLabel = j; - } - } - boxScores[i] = maxScore; - boxLabels[i] = mostLikelyLabel; - } - return {boxScores, boxLabels}; -} - -function buildDetectedObjects( - width: number, height: number, boxes: Float32Array, boxScores: number[], - boxLabels: number[], selectedBoxes: Int32Array, - dictionary: string[]): PredictedObject[] { - const objects: PredictedObject[] = []; - // Each 2d rectangle is fully described with 4 coordinates. - const numBoxCoords = 4; - for (let i = 0; i < selectedBoxes.length; i++) { - const boxIndex = selectedBoxes[i]; - const [top, left, bottom, right] = Array.from(boxes.slice( - boxIndex * numBoxCoords, boxIndex * numBoxCoords + numBoxCoords)); - objects.push({ - box: { - left: left * width, - top: top * height, - width: (right - left) * width, - height: (bottom - top) * height, - }, - label: dictionary[boxLabels[boxIndex]], - score: boxScores[boxIndex], - }); - } - return objects; -} diff --git a/tfjs-master/tfjs-automl/src/object_detection_test.ts b/tfjs-master/tfjs-automl/src/object_detection_test.ts deleted file mode 100644 index ca96ba379..000000000 --- a/tfjs-master/tfjs-automl/src/object_detection_test.ts +++ /dev/null @@ -1,148 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {GraphModel} from '@tensorflow/tfjs-converter'; -import * as tf from '@tensorflow/tfjs-core'; -// tslint:disable-next-line: no-imports-from-dist -import {BROWSER_ENVS, describeWithFlags} from '@tensorflow/tfjs-core/dist/jasmine_util'; - -import * as automl from './index'; -import {fetchImage} from './test_util'; - -const MODEL_URL = - 'https://storage.googleapis.com/tfjs-testing/tfjs-automl/object_detection/model.json'; - -const SALAD_IMAGE = - 'https://storage.googleapis.com/tfjs-testing/tfjs-automl/object_detection/test_image.jpg'; - -describeWithFlags('object detection', {}, () => { - let model: automl.ObjectDetectionModel = null; - const originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL; - jasmine.DEFAULT_TIMEOUT_INTERVAL = 40000; - - beforeAll(async () => { - model = await automl.loadObjectDetection(MODEL_URL); - }); - - afterAll(() => { - jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout; - }); - - it('prediction from a zero tensor', async () => { - const img: tf.Tensor3D = tf.zeros([100, 80, 3]); - const predictions = await model.detect(img); - expect(predictions.length).toBe(0); - }); - - it('prediction from a zero tensor with score threshold', async () => { - const img: tf.Tensor3D = tf.zeros([100, 80, 3]); - const options = {score: 0.11}; - const predictions = await model.detect(img, options); - expect(predictions.length).toBe(1); - const {box: {left, top, width, height}, label, score} = predictions[0]; - - expect(label).toBe('Salad'); - tf.test_util.expectNumbersClose(score, 0.116391); - tf.test_util.expectNumbersClose(left, 26.6741156); - tf.test_util.expectNumbersClose(top, 94.003981); - tf.test_util.expectNumbersClose(width, 22.6277661); - tf.test_util.expectNumbersClose(height, 6.30063414); - }); - - it('prediction with iou threshold', async () => { - const img: tf.Tensor3D = tf.zeros([100, 80, 3]); - const options: automl.ObjectDetectionOptions = {score: 0.10}; - options.iou = 0.9; - let predictions = await model.detect(img, options); - expect(predictions.length).toBe(9); - - options.iou = 0.1; - predictions = await model.detect(img, options); - expect(predictions.length).toBe(1); - }); - - it('no memory leak when making a prediction', async () => { - const img: tf.Tensor3D = tf.zeros([100, 80, 3]); - const numTensorsBefore = tf.memory().numTensors; - await model.detect(img); - const numTensorsAfter = tf.memory().numTensors; - // The increased tensor is for the hashtable id handle - expect(numTensorsAfter).toBeLessThanOrEqual(numTensorsBefore + 1); - }); - - it('has access to dictionary', () => { - expect(model.dictionary).toEqual([ - 'background', 'Tomato', 'Seafood', 'Salad', 'Baked Goods', 'Cheese' - ]); - }); - - it('can access the underlying graph model', () => { - expect(model.graphModel instanceof GraphModel).toBe(true); - }); -}); - -describeWithFlags('object detection browser', BROWSER_ENVS, () => { - let model: automl.ObjectDetectionModel = null; - let saladImg: HTMLImageElement; - - beforeAll(async () => { - model = await automl.loadObjectDetection(MODEL_URL); - saladImg = await fetchImage(SALAD_IMAGE); - }); - - function assertTop3PredsForSalad(predictions: automl.PredictedObject[]) { - expect(predictions.length).toBe(3); - const [top1, top2, top3] = predictions; - expect(top1.label).toBe('Tomato'); - tf.test_util.expectNumbersClose(top1.score, 0.97170084); - - expect(top2.label).toBe('Tomato'); - tf.test_util.expectNumbersClose(top2.score, 0.93456619); - - expect(top3.label).toBe('Salad'); - tf.test_util.expectNumbersClose(top3.score, 0.9074271); - } - - it('make prediction from an image element', async () => { - const predictions = await model.detect(saladImg); - assertTop3PredsForSalad(predictions); - }); - - it('make prediction from a canvas element', async () => { - // Copy the pixels from the image to a canvas. - const canvas = document.createElement('canvas'); - const ctx = canvas.getContext('2d'); - canvas.width = saladImg.width; - canvas.height = saladImg.height; - ctx.drawImage(saladImg, 0, 0, saladImg.width, saladImg.height); - - const predictions = await model.detect(canvas); - assertTop3PredsForSalad(predictions); - }); - - it('make prediction from image data', async () => { - const canvas = document.createElement('canvas'); - const ctx = canvas.getContext('2d'); - canvas.width = saladImg.width; - canvas.height = saladImg.height; - ctx.drawImage(saladImg, 0, 0, saladImg.width, saladImg.height); - const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height); - - const predictions = await model.detect(imageData); - assertTop3PredsForSalad(predictions); - }); -}); diff --git a/tfjs-master/tfjs-automl/src/test_browser.ts b/tfjs-master/tfjs-automl/src/test_browser.ts deleted file mode 100644 index 989bab447..000000000 --- a/tfjs-master/tfjs-automl/src/test_browser.ts +++ /dev/null @@ -1,56 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import '@tensorflow/tfjs-backend-webgl'; - -// tslint:disable-next-line: no-imports-from-dist -import {parseTestEnvFromKarmaFlags, registerTestEnv, setTestEnvs, TEST_ENVS} from '@tensorflow/tfjs-core/dist/jasmine_util'; - -// Increase test timeout since we are fetching the model files from GCS. -jasmine.DEFAULT_TIMEOUT_INTERVAL = 20000; - -registerTestEnv({ - name: 'webgl1', - backendName: 'webgl', - flags: { - 'WEBGL_VERSION': 1, - 'WEBGL_CPU_FORWARD': false, - 'WEBGL_SIZE_UPLOAD_UNIFORM': 0 - }, - isDataSync: true -}); - -// tslint:disable-next-line:no-any -declare let __karma__: any; -const testEnv = parseTestEnvFromKarmaFlags(__karma__.config.args, TEST_ENVS); -if (testEnv != null) { - setTestEnvs([testEnv]); -} else { - // Run browser tests againts both the webgl backends. - setTestEnvs([ - // WebGL. - { - name: 'test-webgl', - backendName: 'webgl', - flags: { - 'WEBGL_VERSION': 2, - 'WEBGL_CPU_FORWARD': false, - 'WEBGL_SIZE_UPLOAD_UNIFORM': 0 - }, - isDataSync: true - } - ]); -} diff --git a/tfjs-master/tfjs-automl/src/test_node.ts b/tfjs-master/tfjs-automl/src/test_node.ts deleted file mode 100644 index ee60399ea..000000000 --- a/tfjs-master/tfjs-automl/src/test_node.ts +++ /dev/null @@ -1,37 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import '@tensorflow/tfjs-backend-cpu'; -// tslint:disable-next-line: no-imports-from-dist -import {setTestEnvs} from '@tensorflow/tfjs-core/dist/jasmine_util'; - -// tslint:disable-next-line:no-require-imports -const jasmine = require('jasmine'); - -// Increase test timeout since we are fetching the model files from GCS. -jasmine.DEFAULT_TIMEOUT_INTERVAL = 20000; - -process.on('unhandledRejection', e => { - throw e; -}); - -// Run node tests againts the cpu backend. -setTestEnvs([{name: 'node', backendName: 'cpu'}]); - -const runner = new jasmine(); -runner.loadConfig({spec_files: ['src/**/*_test.ts'], jsLoader: 'require', - random: false}); -runner.execute(); diff --git a/tfjs-master/tfjs-automl/src/test_util.ts b/tfjs-master/tfjs-automl/src/test_util.ts deleted file mode 100644 index 0a11a0acf..000000000 --- a/tfjs-master/tfjs-automl/src/test_util.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -export async function fetchImage(url: string): Promise { - const response = await fetch(url); - const blob = await response.blob(); - const img = new Image(); - const blobUrl = URL.createObjectURL(blob); - return new Promise((resolve, reject) => { - img.onload = () => { - URL.revokeObjectURL(blobUrl); - resolve(img); - }; - img.onerror = (evt /* Arg is an event, not error. Can't rethrow it */) => { - reject(new Error('Failed to load blob as image.')); - }; - img.src = blobUrl; - }); -} diff --git a/tfjs-master/tfjs-automl/src/types.ts b/tfjs-master/tfjs-automl/src/types.ts deleted file mode 100644 index e969b37c0..000000000 --- a/tfjs-master/tfjs-automl/src/types.ts +++ /dev/null @@ -1,21 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Tensor3D} from '@tensorflow/tfjs-core'; - -export type ImageInput = - ImageData|HTMLImageElement|HTMLCanvasElement|HTMLVideoElement|Tensor3D; diff --git a/tfjs-master/tfjs-automl/src/util.ts b/tfjs-master/tfjs-automl/src/util.ts deleted file mode 100644 index 0457cf19d..000000000 --- a/tfjs-master/tfjs-automl/src/util.ts +++ /dev/null @@ -1,34 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {browser, Tensor, Tensor3D, util} from '@tensorflow/tfjs-core'; -import {ImageInput} from './types'; - -export function imageToTensor(img: ImageInput): Tensor3D { - return img instanceof Tensor ? img : browser.fromPixels(img); -} - -/** Loads and parses the dictionary. */ -export async function loadDictionary(modelUrl: string): Promise { - const lastIndexOfSlash = modelUrl.lastIndexOf('/'); - const prefixUrl = - lastIndexOfSlash >= 0 ? modelUrl.slice(0, lastIndexOfSlash + 1) : ''; - const dictUrl = `${prefixUrl}dict.txt`; - const response = await util.fetch(dictUrl); - const text = await response.text(); - return text.trim().split('\n'); -} diff --git a/tfjs-master/tfjs-automl/src/util_test.ts b/tfjs-master/tfjs-automl/src/util_test.ts deleted file mode 100644 index 4316b3d30..000000000 --- a/tfjs-master/tfjs-automl/src/util_test.ts +++ /dev/null @@ -1,58 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import '@tensorflow/tfjs-backend-cpu'; -import '@tensorflow/tfjs-backend-webgl'; -import {util} from '@tensorflow/tfjs-core'; -import {loadDictionary} from './util'; - -describe('load dictionary', () => { - it('relative url to model.json', async () => { - spyOn(util, 'fetch').and.callFake(async (dictUrl: string) => { - expect(dictUrl).toBe('dict.txt'); - return {text: async () => 'first\nsecond\nthird'} as Response; - }); - const res = await loadDictionary('model.json'); - expect(res).toEqual(['first', 'second', 'third']); - }); - - it('relative url to model.json with a base path', async () => { - spyOn(util, 'fetch').and.callFake(async (dictUrl: string) => { - expect(dictUrl).toBe('base/path/dict.txt'); - return {text: async () => 'first\nsecond\nthird'} as Response; - }); - const res = await loadDictionary('base/path/model.json'); - expect(res).toEqual(['first', 'second', 'third']); - }); - - it('absolute url to model.json', async () => { - spyOn(util, 'fetch').and.callFake(async (dictUrl: string) => { - expect(dictUrl).toBe('/dict.txt'); - return {text: async () => 'first\nsecond\nthird\n'} as Response; - }); - const res = await loadDictionary('/model.json'); - expect(res).toEqual(['first', 'second', 'third']); - }); - - it('absolute url to model.json with a base path', async () => { - spyOn(util, 'fetch').and.callFake(async (dictUrl: string) => { - expect(dictUrl).toBe('/base/path/dict.txt'); - return {text: async () => 'first\nsecond\nthird\n'} as Response; - }); - const res = await loadDictionary('/base/path/model.json'); - expect(res).toEqual(['first', 'second', 'third']); - }); -}); diff --git a/tfjs-master/tfjs-automl/src/version.ts b/tfjs-master/tfjs-automl/src/version.ts deleted file mode 100644 index 4bdc4cd85..000000000 --- a/tfjs-master/tfjs-automl/src/version.ts +++ /dev/null @@ -1,5 +0,0 @@ -/** @license See the LICENSE file. */ - -// This code is auto-generated, do not modify this file! -const version = '1.2.0'; -export {version}; diff --git a/tfjs-master/tfjs-automl/tsconfig.json b/tfjs-master/tfjs-automl/tsconfig.json deleted file mode 100644 index 7941039d6..000000000 --- a/tfjs-master/tfjs-automl/tsconfig.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "extends": "../tsconfig_base.json", - "include": [ - "src/" - ], - "exclude": [ - "node_modules/" - ], - "compilerOptions": { - "outDir": "./dist", - "skipLibCheck": true - } -} diff --git a/tfjs-master/tfjs-automl/tsconfig.test.json b/tfjs-master/tfjs-automl/tsconfig.test.json deleted file mode 100644 index 537324152..000000000 --- a/tfjs-master/tfjs-automl/tsconfig.test.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "extends": "../tsconfig.test", - "include": [ - "src/" - ], - "exclude": [ - "node_modules/" - ], - "compilerOptions": { - "outDir": "./dist" - } -} diff --git a/tfjs-master/tfjs-automl/tslint.json b/tfjs-master/tfjs-automl/tslint.json deleted file mode 100644 index ec365f164..000000000 --- a/tfjs-master/tfjs-automl/tslint.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "../tslint.json" -} diff --git a/tfjs-master/tfjs-automl/yarn.lock b/tfjs-master/tfjs-automl/yarn.lock deleted file mode 100644 index e1a7f56b7..000000000 --- a/tfjs-master/tfjs-automl/yarn.lock +++ /dev/null @@ -1,4052 +0,0 @@ -# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. -# yarn lockfile v1 - - -"@babel/code-frame@^7.0.0", "@babel/code-frame@^7.10.4", "@babel/code-frame@^7.12.13": - version "7.12.13" - resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.12.13.tgz#dcfc826beef65e75c50e21d3837d7d95798dd658" - integrity sha512-HV1Cm0Q3ZrpCR93tkWOYiuYIgLxZXZFVG2VgK+MBWjUqZTundupbfx2aXarXuw5Ko5aMcjtJgbSs4vUGBS5v6g== - dependencies: - "@babel/highlight" "^7.12.13" - -"@babel/compat-data@^7.13.0", "@babel/compat-data@^7.13.12", "@babel/compat-data@^7.13.8": - version "7.13.12" - resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.13.12.tgz#a8a5ccac19c200f9dd49624cac6e19d7be1236a1" - integrity sha512-3eJJ841uKxeV8dcN/2yGEUy+RfgQspPEgQat85umsE1rotuquQ2AbIub4S6j7c50a2d+4myc+zSlnXeIHrOnhQ== - -"@babel/core@^7.11.1", "@babel/core@^7.7.5": - version "7.13.13" - resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.13.13.tgz#bc44c4a2be2288ec4ddf56b66fc718019c76ac29" - integrity "sha1-vETEor4iiOxN31a2b8cYAZx2rCk= sha512-1xEs9jZAyKIouOoCmpsgk/I26PoKyvzQ2ixdRpRzfbcp1fL+ozw7TUgdDgwonbTovqRaTfRh50IXuw4QrWO0GA==" - dependencies: - "@babel/code-frame" "^7.12.13" - "@babel/generator" "^7.13.9" - "@babel/helper-compilation-targets" "^7.13.13" - "@babel/helper-module-transforms" "^7.13.12" - "@babel/helpers" "^7.13.10" - "@babel/parser" "^7.13.13" - "@babel/template" "^7.12.13" - "@babel/traverse" "^7.13.13" - "@babel/types" "^7.13.13" - convert-source-map "^1.7.0" - debug "^4.1.0" - gensync "^1.0.0-beta.2" - json5 "^2.1.2" - lodash "^4.17.19" - semver "^6.3.0" - source-map "^0.5.0" - -"@babel/generator@^7.13.9": - version "7.13.9" - resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.13.9.tgz#3a7aa96f9efb8e2be42d38d80e2ceb4c64d8de39" - integrity sha512-mHOOmY0Axl/JCTkxTU6Lf5sWOg/v8nUa+Xkt4zMTftX0wqmb6Sh7J8gvcehBw7q0AhrhAR+FDacKjCZ2X8K+Sw== - dependencies: - "@babel/types" "^7.13.0" - jsesc "^2.5.1" - source-map "^0.5.0" - -"@babel/helper-annotate-as-pure@^7.12.13": - version "7.12.13" - resolved "https://registry.yarnpkg.com/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.12.13.tgz#0f58e86dfc4bb3b1fcd7db806570e177d439b6ab" - integrity sha512-7YXfX5wQ5aYM/BOlbSccHDbuXXFPxeoUmfWtz8le2yTkTZc+BxsiEnENFoi2SlmA8ewDkG2LgIMIVzzn2h8kfw== - dependencies: - "@babel/types" "^7.12.13" - -"@babel/helper-builder-binary-assignment-operator-visitor@^7.12.13": - version "7.12.13" - resolved "https://registry.yarnpkg.com/@babel/helper-builder-binary-assignment-operator-visitor/-/helper-builder-binary-assignment-operator-visitor-7.12.13.tgz#6bc20361c88b0a74d05137a65cac8d3cbf6f61fc" - integrity sha512-CZOv9tGphhDRlVjVkAgm8Nhklm9RzSmWpX2my+t7Ua/KT616pEzXsQCjinzvkRvHWJ9itO4f296efroX23XCMA== - dependencies: - "@babel/helper-explode-assignable-expression" "^7.12.13" - "@babel/types" "^7.12.13" - -"@babel/helper-compilation-targets@^7.13.0", "@babel/helper-compilation-targets@^7.13.10", "@babel/helper-compilation-targets@^7.13.13", "@babel/helper-compilation-targets@^7.13.8": - version "7.13.13" - resolved "https://registry.yarnpkg.com/@babel/helper-compilation-targets/-/helper-compilation-targets-7.13.13.tgz#2b2972a0926474853f41e4adbc69338f520600e5" - integrity sha512-q1kcdHNZehBwD9jYPh3WyXcsFERi39X4I59I3NadciWtNDyZ6x+GboOxncFK0kXlKIv6BJm5acncehXWUjWQMQ== - dependencies: - "@babel/compat-data" "^7.13.12" - "@babel/helper-validator-option" "^7.12.17" - browserslist "^4.14.5" - semver "^6.3.0" - -"@babel/helper-create-class-features-plugin@^7.13.0": - version "7.13.11" - resolved "https://registry.yarnpkg.com/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.13.11.tgz#30d30a005bca2c953f5653fc25091a492177f4f6" - integrity sha512-ays0I7XYq9xbjCSvT+EvysLgfc3tOkwCULHjrnscGT3A9qD4sk3wXnJ3of0MAWsWGjdinFvajHU2smYuqXKMrw== - dependencies: - "@babel/helper-function-name" "^7.12.13" - "@babel/helper-member-expression-to-functions" "^7.13.0" - "@babel/helper-optimise-call-expression" "^7.12.13" - "@babel/helper-replace-supers" "^7.13.0" - "@babel/helper-split-export-declaration" "^7.12.13" - -"@babel/helper-create-regexp-features-plugin@^7.12.13": - version "7.12.17" - resolved "https://registry.yarnpkg.com/@babel/helper-create-regexp-features-plugin/-/helper-create-regexp-features-plugin-7.12.17.tgz#a2ac87e9e319269ac655b8d4415e94d38d663cb7" - integrity sha512-p2VGmBu9oefLZ2nQpgnEnG0ZlRPvL8gAGvPUMQwUdaE8k49rOMuZpOwdQoy5qJf6K8jL3bcAMhVUlHAjIgJHUg== - dependencies: - "@babel/helper-annotate-as-pure" "^7.12.13" - regexpu-core "^4.7.1" - -"@babel/helper-define-polyfill-provider@^0.1.5": - version "0.1.5" - resolved "https://registry.yarnpkg.com/@babel/helper-define-polyfill-provider/-/helper-define-polyfill-provider-0.1.5.tgz#3c2f91b7971b9fc11fe779c945c014065dea340e" - integrity sha512-nXuzCSwlJ/WKr8qxzW816gwyT6VZgiJG17zR40fou70yfAcqjoNyTLl/DQ+FExw5Hx5KNqshmN8Ldl/r2N7cTg== - dependencies: - "@babel/helper-compilation-targets" "^7.13.0" - "@babel/helper-module-imports" "^7.12.13" - "@babel/helper-plugin-utils" "^7.13.0" - "@babel/traverse" "^7.13.0" - debug "^4.1.1" - lodash.debounce "^4.0.8" - resolve "^1.14.2" - semver "^6.1.2" - -"@babel/helper-explode-assignable-expression@^7.12.13": - version "7.13.0" - resolved "https://registry.yarnpkg.com/@babel/helper-explode-assignable-expression/-/helper-explode-assignable-expression-7.13.0.tgz#17b5c59ff473d9f956f40ef570cf3a76ca12657f" - integrity sha512-qS0peLTDP8kOisG1blKbaoBg/o9OSa1qoumMjTK5pM+KDTtpxpsiubnCGP34vK8BXGcb2M9eigwgvoJryrzwWA== - dependencies: - "@babel/types" "^7.13.0" - -"@babel/helper-function-name@^7.12.13": - version "7.12.13" - resolved "https://registry.yarnpkg.com/@babel/helper-function-name/-/helper-function-name-7.12.13.tgz#93ad656db3c3c2232559fd7b2c3dbdcbe0eb377a" - integrity sha512-TZvmPn0UOqmvi5G4vvw0qZTpVptGkB1GL61R6lKvrSdIxGm5Pky7Q3fpKiIkQCAtRCBUwB0PaThlx9vebCDSwA== - dependencies: - "@babel/helper-get-function-arity" "^7.12.13" - "@babel/template" "^7.12.13" - "@babel/types" "^7.12.13" - -"@babel/helper-get-function-arity@^7.12.13": - version "7.12.13" - resolved "https://registry.yarnpkg.com/@babel/helper-get-function-arity/-/helper-get-function-arity-7.12.13.tgz#bc63451d403a3b3082b97e1d8b3fe5bd4091e583" - integrity sha512-DjEVzQNz5LICkzN0REdpD5prGoidvbdYk1BVgRUOINaWJP2t6avB27X1guXK1kXNrX0WMfsrm1A/ZBthYuIMQg== - dependencies: - "@babel/types" "^7.12.13" - -"@babel/helper-hoist-variables@^7.13.0": - version "7.13.0" - resolved "https://registry.yarnpkg.com/@babel/helper-hoist-variables/-/helper-hoist-variables-7.13.0.tgz#5d5882e855b5c5eda91e0cadc26c6e7a2c8593d8" - integrity sha512-0kBzvXiIKfsCA0y6cFEIJf4OdzfpRuNk4+YTeHZpGGc666SATFKTz6sRncwFnQk7/ugJ4dSrCj6iJuvW4Qwr2g== - dependencies: - "@babel/traverse" "^7.13.0" - "@babel/types" "^7.13.0" - -"@babel/helper-member-expression-to-functions@^7.13.0", "@babel/helper-member-expression-to-functions@^7.13.12": - version "7.13.12" - resolved "https://registry.yarnpkg.com/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.13.12.tgz#dfe368f26d426a07299d8d6513821768216e6d72" - integrity sha512-48ql1CLL59aKbU94Y88Xgb2VFy7a95ykGRbJJaaVv+LX5U8wFpLfiGXJJGUozsmA1oEh/o5Bp60Voq7ACyA/Sw== - dependencies: - "@babel/types" "^7.13.12" - -"@babel/helper-module-imports@^7.12.13", "@babel/helper-module-imports@^7.13.12": - version "7.13.12" - resolved "https://registry.yarnpkg.com/@babel/helper-module-imports/-/helper-module-imports-7.13.12.tgz#c6a369a6f3621cb25da014078684da9196b61977" - integrity sha512-4cVvR2/1B693IuOvSI20xqqa/+bl7lqAMR59R4iu39R9aOX8/JoYY1sFaNvUMyMBGnHdwvJgUrzNLoUZxXypxA== - dependencies: - "@babel/types" "^7.13.12" - -"@babel/helper-module-transforms@^7.13.0", "@babel/helper-module-transforms@^7.13.12": - version "7.13.12" - resolved "https://registry.yarnpkg.com/@babel/helper-module-transforms/-/helper-module-transforms-7.13.12.tgz#600e58350490828d82282631a1422268e982ba96" - integrity sha512-7zVQqMO3V+K4JOOj40kxiCrMf6xlQAkewBB0eu2b03OO/Q21ZutOzjpfD79A5gtE/2OWi1nv625MrDlGlkbknQ== - dependencies: - "@babel/helper-module-imports" "^7.13.12" - "@babel/helper-replace-supers" "^7.13.12" - "@babel/helper-simple-access" "^7.13.12" - "@babel/helper-split-export-declaration" "^7.12.13" - "@babel/helper-validator-identifier" "^7.12.11" - "@babel/template" "^7.12.13" - "@babel/traverse" "^7.13.0" - "@babel/types" "^7.13.12" - -"@babel/helper-optimise-call-expression@^7.12.13": - version "7.12.13" - resolved "https://registry.yarnpkg.com/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.12.13.tgz#5c02d171b4c8615b1e7163f888c1c81c30a2aaea" - integrity sha512-BdWQhoVJkp6nVjB7nkFWcn43dkprYauqtk++Py2eaf/GRDFm5BxRqEIZCiHlZUGAVmtwKcsVL1dC68WmzeFmiA== - dependencies: - "@babel/types" "^7.12.13" - -"@babel/helper-plugin-utils@^7.0.0", "@babel/helper-plugin-utils@^7.10.4", "@babel/helper-plugin-utils@^7.12.13", "@babel/helper-plugin-utils@^7.13.0", "@babel/helper-plugin-utils@^7.8.0", "@babel/helper-plugin-utils@^7.8.3": - version "7.13.0" - resolved "https://registry.yarnpkg.com/@babel/helper-plugin-utils/-/helper-plugin-utils-7.13.0.tgz#806526ce125aed03373bc416a828321e3a6a33af" - integrity sha512-ZPafIPSwzUlAoWT8DKs1W2VyF2gOWthGd5NGFMsBcMMol+ZhK+EQY/e6V96poa6PA/Bh+C9plWN0hXO1uB8AfQ== - -"@babel/helper-remap-async-to-generator@^7.13.0": - version "7.13.0" - resolved "https://registry.yarnpkg.com/@babel/helper-remap-async-to-generator/-/helper-remap-async-to-generator-7.13.0.tgz#376a760d9f7b4b2077a9dd05aa9c3927cadb2209" - integrity sha512-pUQpFBE9JvC9lrQbpX0TmeNIy5s7GnZjna2lhhcHC7DzgBs6fWn722Y5cfwgrtrqc7NAJwMvOa0mKhq6XaE4jg== - dependencies: - "@babel/helper-annotate-as-pure" "^7.12.13" - "@babel/helper-wrap-function" "^7.13.0" - "@babel/types" "^7.13.0" - -"@babel/helper-replace-supers@^7.12.13", "@babel/helper-replace-supers@^7.13.0", "@babel/helper-replace-supers@^7.13.12": - version "7.13.12" - resolved "https://registry.yarnpkg.com/@babel/helper-replace-supers/-/helper-replace-supers-7.13.12.tgz#6442f4c1ad912502481a564a7386de0c77ff3804" - integrity sha512-Gz1eiX+4yDO8mT+heB94aLVNCL+rbuT2xy4YfyNqu8F+OI6vMvJK891qGBTqL9Uc8wxEvRW92Id6G7sDen3fFw== - dependencies: - "@babel/helper-member-expression-to-functions" "^7.13.12" - "@babel/helper-optimise-call-expression" "^7.12.13" - "@babel/traverse" "^7.13.0" - "@babel/types" "^7.13.12" - -"@babel/helper-simple-access@^7.12.13", "@babel/helper-simple-access@^7.13.12": - version "7.13.12" - resolved "https://registry.yarnpkg.com/@babel/helper-simple-access/-/helper-simple-access-7.13.12.tgz#dd6c538afb61819d205a012c31792a39c7a5eaf6" - integrity sha512-7FEjbrx5SL9cWvXioDbnlYTppcZGuCY6ow3/D5vMggb2Ywgu4dMrpTJX0JdQAIcRRUElOIxF3yEooa9gUb9ZbA== - dependencies: - "@babel/types" "^7.13.12" - -"@babel/helper-skip-transparent-expression-wrappers@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/helper-skip-transparent-expression-wrappers/-/helper-skip-transparent-expression-wrappers-7.12.1.tgz#462dc63a7e435ade8468385c63d2b84cce4b3cbf" - integrity sha512-Mf5AUuhG1/OCChOJ/HcADmvcHM42WJockombn8ATJG3OnyiSxBK/Mm5x78BQWvmtXZKHgbjdGL2kin/HOLlZGA== - dependencies: - "@babel/types" "^7.12.1" - -"@babel/helper-split-export-declaration@^7.12.13": - version "7.12.13" - resolved "https://registry.yarnpkg.com/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.12.13.tgz#e9430be00baf3e88b0e13e6f9d4eaf2136372b05" - integrity sha512-tCJDltF83htUtXx5NLcaDqRmknv652ZWCHyoTETf1CXYJdPC7nohZohjUgieXhv0hTJdRf2FjDueFehdNucpzg== - dependencies: - "@babel/types" "^7.12.13" - -"@babel/helper-validator-identifier@^7.12.11": - version "7.12.11" - resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.12.11.tgz#c9a1f021917dcb5ccf0d4e453e399022981fc9ed" - integrity sha512-np/lG3uARFybkoHokJUmf1QfEvRVCPbmQeUQpKow5cQ3xWrV9i3rUHodKDJPQfTVX61qKi+UdYk8kik84n7XOw== - -"@babel/helper-validator-option@^7.12.17": - version "7.12.17" - resolved "https://registry.yarnpkg.com/@babel/helper-validator-option/-/helper-validator-option-7.12.17.tgz#d1fbf012e1a79b7eebbfdc6d270baaf8d9eb9831" - integrity sha512-TopkMDmLzq8ngChwRlyjR6raKD6gMSae4JdYDB8bByKreQgG0RBTuKe9LRxW3wFtUnjxOPRKBDwEH6Mg5KeDfw== - -"@babel/helper-wrap-function@^7.13.0": - version "7.13.0" - resolved "https://registry.yarnpkg.com/@babel/helper-wrap-function/-/helper-wrap-function-7.13.0.tgz#bdb5c66fda8526ec235ab894ad53a1235c79fcc4" - integrity sha512-1UX9F7K3BS42fI6qd2A4BjKzgGjToscyZTdp1DjknHLCIvpgne6918io+aL5LXFcER/8QWiwpoY902pVEqgTXA== - dependencies: - "@babel/helper-function-name" "^7.12.13" - "@babel/template" "^7.12.13" - "@babel/traverse" "^7.13.0" - "@babel/types" "^7.13.0" - -"@babel/helpers@^7.13.10": - version "7.13.10" - resolved "https://registry.yarnpkg.com/@babel/helpers/-/helpers-7.13.10.tgz#fd8e2ba7488533cdeac45cc158e9ebca5e3c7df8" - integrity sha512-4VO883+MWPDUVRF3PhiLBUFHoX/bsLTGFpFK/HqvvfBZz2D57u9XzPVNFVBTc0PW/CWR9BXTOKt8NF4DInUHcQ== - dependencies: - "@babel/template" "^7.12.13" - "@babel/traverse" "^7.13.0" - "@babel/types" "^7.13.0" - -"@babel/highlight@^7.12.13": - version "7.13.10" - resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.13.10.tgz#a8b2a66148f5b27d666b15d81774347a731d52d1" - integrity sha512-5aPpe5XQPzflQrFwL1/QoeHkP2MsA4JCntcXHRhEsdsfPVkvPi2w7Qix4iV7t5S/oC9OodGrggd8aco1g3SZFg== - dependencies: - "@babel/helper-validator-identifier" "^7.12.11" - chalk "^2.0.0" - js-tokens "^4.0.0" - -"@babel/parser@^7.12.13", "@babel/parser@^7.13.13": - version "7.13.13" - resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.13.13.tgz#42f03862f4aed50461e543270916b47dd501f0df" - integrity sha512-OhsyMrqygfk5v8HmWwOzlYjJrtLaFhF34MrfG/Z73DgYCI6ojNUTUp2TYbtnjo8PegeJp12eamsNettCQjKjVw== - -"@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining@^7.13.12": - version "7.13.12" - resolved "https://registry.yarnpkg.com/@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining/-/plugin-bugfix-v8-spread-parameters-in-optional-chaining-7.13.12.tgz#a3484d84d0b549f3fc916b99ee4783f26fabad2a" - integrity sha512-d0u3zWKcoZf379fOeJdr1a5WPDny4aOFZ6hlfKivgK0LY7ZxNfoaHL2fWwdGtHyVvra38FC+HVYkO+byfSA8AQ== - dependencies: - "@babel/helper-plugin-utils" "^7.13.0" - "@babel/helper-skip-transparent-expression-wrappers" "^7.12.1" - "@babel/plugin-proposal-optional-chaining" "^7.13.12" - -"@babel/plugin-proposal-async-generator-functions@^7.13.8": - version "7.13.8" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-async-generator-functions/-/plugin-proposal-async-generator-functions-7.13.8.tgz#87aacb574b3bc4b5603f6fe41458d72a5a2ec4b1" - integrity sha512-rPBnhj+WgoSmgq+4gQUtXx/vOcU+UYtjy1AA/aeD61Hwj410fwYyqfUcRP3lR8ucgliVJL/G7sXcNUecC75IXA== - dependencies: - "@babel/helper-plugin-utils" "^7.13.0" - "@babel/helper-remap-async-to-generator" "^7.13.0" - "@babel/plugin-syntax-async-generators" "^7.8.4" - -"@babel/plugin-proposal-class-properties@^7.13.0": - version "7.13.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-class-properties/-/plugin-proposal-class-properties-7.13.0.tgz#146376000b94efd001e57a40a88a525afaab9f37" - integrity sha512-KnTDjFNC1g+45ka0myZNvSBFLhNCLN+GeGYLDEA8Oq7MZ6yMgfLoIRh86GRT0FjtJhZw8JyUskP9uvj5pHM9Zg== - dependencies: - "@babel/helper-create-class-features-plugin" "^7.13.0" - "@babel/helper-plugin-utils" "^7.13.0" - -"@babel/plugin-proposal-dynamic-import@^7.13.8": - version "7.13.8" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-dynamic-import/-/plugin-proposal-dynamic-import-7.13.8.tgz#876a1f6966e1dec332e8c9451afda3bebcdf2e1d" - integrity sha512-ONWKj0H6+wIRCkZi9zSbZtE/r73uOhMVHh256ys0UzfM7I3d4n+spZNWjOnJv2gzopumP2Wxi186vI8N0Y2JyQ== - dependencies: - "@babel/helper-plugin-utils" "^7.13.0" - "@babel/plugin-syntax-dynamic-import" "^7.8.3" - -"@babel/plugin-proposal-export-namespace-from@^7.12.13": - version "7.12.13" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-export-namespace-from/-/plugin-proposal-export-namespace-from-7.12.13.tgz#393be47a4acd03fa2af6e3cde9b06e33de1b446d" - integrity sha512-INAgtFo4OnLN3Y/j0VwAgw3HDXcDtX+C/erMvWzuV9v71r7urb6iyMXu7eM9IgLr1ElLlOkaHjJ0SbCmdOQ3Iw== - dependencies: - "@babel/helper-plugin-utils" "^7.12.13" - "@babel/plugin-syntax-export-namespace-from" "^7.8.3" - -"@babel/plugin-proposal-json-strings@^7.13.8": - version "7.13.8" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-json-strings/-/plugin-proposal-json-strings-7.13.8.tgz#bf1fb362547075afda3634ed31571c5901afef7b" - integrity sha512-w4zOPKUFPX1mgvTmL/fcEqy34hrQ1CRcGxdphBc6snDnnqJ47EZDIyop6IwXzAC8G916hsIuXB2ZMBCExC5k7Q== - dependencies: - "@babel/helper-plugin-utils" "^7.13.0" - "@babel/plugin-syntax-json-strings" "^7.8.3" - -"@babel/plugin-proposal-logical-assignment-operators@^7.13.8": - version "7.13.8" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-logical-assignment-operators/-/plugin-proposal-logical-assignment-operators-7.13.8.tgz#93fa78d63857c40ce3c8c3315220fd00bfbb4e1a" - integrity sha512-aul6znYB4N4HGweImqKn59Su9RS8lbUIqxtXTOcAGtNIDczoEFv+l1EhmX8rUBp3G1jMjKJm8m0jXVp63ZpS4A== - dependencies: - "@babel/helper-plugin-utils" "^7.13.0" - "@babel/plugin-syntax-logical-assignment-operators" "^7.10.4" - -"@babel/plugin-proposal-nullish-coalescing-operator@^7.13.8": - version "7.13.8" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-nullish-coalescing-operator/-/plugin-proposal-nullish-coalescing-operator-7.13.8.tgz#3730a31dafd3c10d8ccd10648ed80a2ac5472ef3" - integrity sha512-iePlDPBn//UhxExyS9KyeYU7RM9WScAG+D3Hhno0PLJebAEpDZMocbDe64eqynhNAnwz/vZoL/q/QB2T1OH39A== - dependencies: - "@babel/helper-plugin-utils" "^7.13.0" - "@babel/plugin-syntax-nullish-coalescing-operator" "^7.8.3" - -"@babel/plugin-proposal-numeric-separator@^7.12.13": - version "7.12.13" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-numeric-separator/-/plugin-proposal-numeric-separator-7.12.13.tgz#bd9da3188e787b5120b4f9d465a8261ce67ed1db" - integrity sha512-O1jFia9R8BUCl3ZGB7eitaAPu62TXJRHn7rh+ojNERCFyqRwJMTmhz+tJ+k0CwI6CLjX/ee4qW74FSqlq9I35w== - dependencies: - "@babel/helper-plugin-utils" "^7.12.13" - "@babel/plugin-syntax-numeric-separator" "^7.10.4" - -"@babel/plugin-proposal-object-rest-spread@^7.13.8": - version "7.13.8" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-object-rest-spread/-/plugin-proposal-object-rest-spread-7.13.8.tgz#5d210a4d727d6ce3b18f9de82cc99a3964eed60a" - integrity sha512-DhB2EuB1Ih7S3/IRX5AFVgZ16k3EzfRbq97CxAVI1KSYcW+lexV8VZb7G7L8zuPVSdQMRn0kiBpf/Yzu9ZKH0g== - dependencies: - "@babel/compat-data" "^7.13.8" - "@babel/helper-compilation-targets" "^7.13.8" - "@babel/helper-plugin-utils" "^7.13.0" - "@babel/plugin-syntax-object-rest-spread" "^7.8.3" - "@babel/plugin-transform-parameters" "^7.13.0" - -"@babel/plugin-proposal-optional-catch-binding@^7.13.8": - version "7.13.8" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-optional-catch-binding/-/plugin-proposal-optional-catch-binding-7.13.8.tgz#3ad6bd5901506ea996fc31bdcf3ccfa2bed71107" - integrity sha512-0wS/4DUF1CuTmGo+NiaHfHcVSeSLj5S3e6RivPTg/2k3wOv3jO35tZ6/ZWsQhQMvdgI7CwphjQa/ccarLymHVA== - dependencies: - "@babel/helper-plugin-utils" "^7.13.0" - "@babel/plugin-syntax-optional-catch-binding" "^7.8.3" - -"@babel/plugin-proposal-optional-chaining@^7.13.12": - version "7.13.12" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-optional-chaining/-/plugin-proposal-optional-chaining-7.13.12.tgz#ba9feb601d422e0adea6760c2bd6bbb7bfec4866" - integrity sha512-fcEdKOkIB7Tf4IxrgEVeFC4zeJSTr78no9wTdBuZZbqF64kzllU0ybo2zrzm7gUQfxGhBgq4E39oRs8Zx/RMYQ== - dependencies: - "@babel/helper-plugin-utils" "^7.13.0" - "@babel/helper-skip-transparent-expression-wrappers" "^7.12.1" - "@babel/plugin-syntax-optional-chaining" "^7.8.3" - -"@babel/plugin-proposal-private-methods@^7.13.0": - version "7.13.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-private-methods/-/plugin-proposal-private-methods-7.13.0.tgz#04bd4c6d40f6e6bbfa2f57e2d8094bad900ef787" - integrity sha512-MXyyKQd9inhx1kDYPkFRVOBXQ20ES8Pto3T7UZ92xj2mY0EVD8oAVzeyYuVfy/mxAdTSIayOvg+aVzcHV2bn6Q== - dependencies: - "@babel/helper-create-class-features-plugin" "^7.13.0" - "@babel/helper-plugin-utils" "^7.13.0" - -"@babel/plugin-proposal-unicode-property-regex@^7.12.13", "@babel/plugin-proposal-unicode-property-regex@^7.4.4": - version "7.12.13" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-unicode-property-regex/-/plugin-proposal-unicode-property-regex-7.12.13.tgz#bebde51339be829c17aaaaced18641deb62b39ba" - integrity sha512-XyJmZidNfofEkqFV5VC/bLabGmO5QzenPO/YOfGuEbgU+2sSwMmio3YLb4WtBgcmmdwZHyVyv8on77IUjQ5Gvg== - dependencies: - "@babel/helper-create-regexp-features-plugin" "^7.12.13" - "@babel/helper-plugin-utils" "^7.12.13" - -"@babel/plugin-syntax-async-generators@^7.8.4": - version "7.8.4" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-async-generators/-/plugin-syntax-async-generators-7.8.4.tgz#a983fb1aeb2ec3f6ed042a210f640e90e786fe0d" - integrity sha512-tycmZxkGfZaxhMRbXlPXuVFpdWlXpir2W4AMhSJgRKzk/eDlIXOhb2LHWoLpDF7TEHylV5zNhykX6KAgHJmTNw== - dependencies: - "@babel/helper-plugin-utils" "^7.8.0" - -"@babel/plugin-syntax-class-properties@^7.12.13": - version "7.12.13" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-class-properties/-/plugin-syntax-class-properties-7.12.13.tgz#b5c987274c4a3a82b89714796931a6b53544ae10" - integrity sha512-fm4idjKla0YahUNgFNLCB0qySdsoPiZP3iQE3rky0mBUtMZ23yDJ9SJdg6dXTSDnulOVqiF3Hgr9nbXvXTQZYA== - dependencies: - "@babel/helper-plugin-utils" "^7.12.13" - -"@babel/plugin-syntax-dynamic-import@^7.8.3": - version "7.8.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-dynamic-import/-/plugin-syntax-dynamic-import-7.8.3.tgz#62bf98b2da3cd21d626154fc96ee5b3cb68eacb3" - integrity sha512-5gdGbFon+PszYzqs83S3E5mpi7/y/8M9eC90MRTZfduQOYW76ig6SOSPNe41IG5LoP3FGBn2N0RjVDSQiS94kQ== - dependencies: - "@babel/helper-plugin-utils" "^7.8.0" - -"@babel/plugin-syntax-export-namespace-from@^7.8.3": - version "7.8.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-export-namespace-from/-/plugin-syntax-export-namespace-from-7.8.3.tgz#028964a9ba80dbc094c915c487ad7c4e7a66465a" - integrity sha512-MXf5laXo6c1IbEbegDmzGPwGNTsHZmEy6QGznu5Sh2UCWvueywb2ee+CCE4zQiZstxU9BMoQO9i6zUFSY0Kj0Q== - dependencies: - "@babel/helper-plugin-utils" "^7.8.3" - -"@babel/plugin-syntax-json-strings@^7.8.3": - version "7.8.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-json-strings/-/plugin-syntax-json-strings-7.8.3.tgz#01ca21b668cd8218c9e640cb6dd88c5412b2c96a" - integrity sha512-lY6kdGpWHvjoe2vk4WrAapEuBR69EMxZl+RoGRhrFGNYVK8mOPAW8VfbT/ZgrFbXlDNiiaxQnAtgVCZ6jv30EA== - dependencies: - "@babel/helper-plugin-utils" "^7.8.0" - -"@babel/plugin-syntax-logical-assignment-operators@^7.10.4": - version "7.10.4" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-logical-assignment-operators/-/plugin-syntax-logical-assignment-operators-7.10.4.tgz#ca91ef46303530448b906652bac2e9fe9941f699" - integrity sha512-d8waShlpFDinQ5MtvGU9xDAOzKH47+FFoney2baFIoMr952hKOLp1HR7VszoZvOsV/4+RRszNY7D17ba0te0ig== - dependencies: - "@babel/helper-plugin-utils" "^7.10.4" - -"@babel/plugin-syntax-nullish-coalescing-operator@^7.8.3": - version "7.8.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-nullish-coalescing-operator/-/plugin-syntax-nullish-coalescing-operator-7.8.3.tgz#167ed70368886081f74b5c36c65a88c03b66d1a9" - integrity sha512-aSff4zPII1u2QD7y+F8oDsz19ew4IGEJg9SVW+bqwpwtfFleiQDMdzA/R+UlWDzfnHFCxxleFT0PMIrR36XLNQ== - dependencies: - "@babel/helper-plugin-utils" "^7.8.0" - -"@babel/plugin-syntax-numeric-separator@^7.10.4": - version "7.10.4" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-numeric-separator/-/plugin-syntax-numeric-separator-7.10.4.tgz#b9b070b3e33570cd9fd07ba7fa91c0dd37b9af97" - integrity sha512-9H6YdfkcK/uOnY/K7/aA2xpzaAgkQn37yzWUMRK7OaPOqOpGS1+n0H5hxT9AUw9EsSjPW8SVyMJwYRtWs3X3ug== - dependencies: - "@babel/helper-plugin-utils" "^7.10.4" - -"@babel/plugin-syntax-object-rest-spread@^7.8.3": - version "7.8.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-object-rest-spread/-/plugin-syntax-object-rest-spread-7.8.3.tgz#60e225edcbd98a640332a2e72dd3e66f1af55871" - integrity sha512-XoqMijGZb9y3y2XskN+P1wUGiVwWZ5JmoDRwx5+3GmEplNyVM2s2Dg8ILFQm8rWM48orGy5YpI5Bl8U1y7ydlA== - dependencies: - "@babel/helper-plugin-utils" "^7.8.0" - -"@babel/plugin-syntax-optional-catch-binding@^7.8.3": - version "7.8.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-optional-catch-binding/-/plugin-syntax-optional-catch-binding-7.8.3.tgz#6111a265bcfb020eb9efd0fdfd7d26402b9ed6c1" - integrity sha512-6VPD0Pc1lpTqw0aKoeRTMiB+kWhAoT24PA+ksWSBrFtl5SIRVpZlwN3NNPQjehA2E/91FV3RjLWoVTglWcSV3Q== - dependencies: - "@babel/helper-plugin-utils" "^7.8.0" - -"@babel/plugin-syntax-optional-chaining@^7.8.3": - version "7.8.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-optional-chaining/-/plugin-syntax-optional-chaining-7.8.3.tgz#4f69c2ab95167e0180cd5336613f8c5788f7d48a" - integrity sha512-KoK9ErH1MBlCPxV0VANkXW2/dw4vlbGDrFgz8bmUsBGYkFRcbRwMh6cIJubdPrkxRwuGdtCk0v/wPTKbQgBjkg== - dependencies: - "@babel/helper-plugin-utils" "^7.8.0" - -"@babel/plugin-syntax-top-level-await@^7.12.13": - version "7.12.13" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-top-level-await/-/plugin-syntax-top-level-await-7.12.13.tgz#c5f0fa6e249f5b739727f923540cf7a806130178" - integrity sha512-A81F9pDwyS7yM//KwbCSDqy3Uj4NMIurtplxphWxoYtNPov7cJsDkAFNNyVlIZ3jwGycVsurZ+LtOA8gZ376iQ== - dependencies: - "@babel/helper-plugin-utils" "^7.12.13" - -"@babel/plugin-transform-arrow-functions@^7.13.0": - version "7.13.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-arrow-functions/-/plugin-transform-arrow-functions-7.13.0.tgz#10a59bebad52d637a027afa692e8d5ceff5e3dae" - integrity sha512-96lgJagobeVmazXFaDrbmCLQxBysKu7U6Do3mLsx27gf5Dk85ezysrs2BZUpXD703U/Su1xTBDxxar2oa4jAGg== - dependencies: - "@babel/helper-plugin-utils" "^7.13.0" - -"@babel/plugin-transform-async-to-generator@^7.13.0": - version "7.13.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-async-to-generator/-/plugin-transform-async-to-generator-7.13.0.tgz#8e112bf6771b82bf1e974e5e26806c5c99aa516f" - integrity sha512-3j6E004Dx0K3eGmhxVJxwwI89CTJrce7lg3UrtFuDAVQ/2+SJ/h/aSFOeE6/n0WB1GsOffsJp6MnPQNQ8nmwhg== - dependencies: - "@babel/helper-module-imports" "^7.12.13" - "@babel/helper-plugin-utils" "^7.13.0" - "@babel/helper-remap-async-to-generator" "^7.13.0" - -"@babel/plugin-transform-block-scoped-functions@^7.12.13": - version "7.12.13" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-block-scoped-functions/-/plugin-transform-block-scoped-functions-7.12.13.tgz#a9bf1836f2a39b4eb6cf09967739de29ea4bf4c4" - integrity sha512-zNyFqbc3kI/fVpqwfqkg6RvBgFpC4J18aKKMmv7KdQ/1GgREapSJAykLMVNwfRGO3BtHj3YQZl8kxCXPcVMVeg== - dependencies: - "@babel/helper-plugin-utils" "^7.12.13" - -"@babel/plugin-transform-block-scoping@^7.12.13": - version "7.12.13" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-block-scoping/-/plugin-transform-block-scoping-7.12.13.tgz#f36e55076d06f41dfd78557ea039c1b581642e61" - integrity sha512-Pxwe0iqWJX4fOOM2kEZeUuAxHMWb9nK+9oh5d11bsLoB0xMg+mkDpt0eYuDZB7ETrY9bbcVlKUGTOGWy7BHsMQ== - dependencies: - "@babel/helper-plugin-utils" "^7.12.13" - -"@babel/plugin-transform-classes@^7.13.0": - version "7.13.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-classes/-/plugin-transform-classes-7.13.0.tgz#0265155075c42918bf4d3a4053134176ad9b533b" - integrity sha512-9BtHCPUARyVH1oXGcSJD3YpsqRLROJx5ZNP6tN5vnk17N0SVf9WCtf8Nuh1CFmgByKKAIMstitKduoCmsaDK5g== - dependencies: - "@babel/helper-annotate-as-pure" "^7.12.13" - "@babel/helper-function-name" "^7.12.13" - "@babel/helper-optimise-call-expression" "^7.12.13" - "@babel/helper-plugin-utils" "^7.13.0" - "@babel/helper-replace-supers" "^7.13.0" - "@babel/helper-split-export-declaration" "^7.12.13" - globals "^11.1.0" - -"@babel/plugin-transform-computed-properties@^7.13.0": - version "7.13.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-computed-properties/-/plugin-transform-computed-properties-7.13.0.tgz#845c6e8b9bb55376b1fa0b92ef0bdc8ea06644ed" - integrity sha512-RRqTYTeZkZAz8WbieLTvKUEUxZlUTdmL5KGMyZj7FnMfLNKV4+r5549aORG/mgojRmFlQMJDUupwAMiF2Q7OUg== - dependencies: - "@babel/helper-plugin-utils" "^7.13.0" - -"@babel/plugin-transform-destructuring@^7.13.0": - version "7.13.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-destructuring/-/plugin-transform-destructuring-7.13.0.tgz#c5dce270014d4e1ebb1d806116694c12b7028963" - integrity sha512-zym5em7tePoNT9s964c0/KU3JPPnuq7VhIxPRefJ4/s82cD+q1mgKfuGRDMCPL0HTyKz4dISuQlCusfgCJ86HA== - dependencies: - "@babel/helper-plugin-utils" "^7.13.0" - -"@babel/plugin-transform-dotall-regex@^7.12.13", "@babel/plugin-transform-dotall-regex@^7.4.4": - version "7.12.13" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-dotall-regex/-/plugin-transform-dotall-regex-7.12.13.tgz#3f1601cc29905bfcb67f53910f197aeafebb25ad" - integrity sha512-foDrozE65ZFdUC2OfgeOCrEPTxdB3yjqxpXh8CH+ipd9CHd4s/iq81kcUpyH8ACGNEPdFqbtzfgzbT/ZGlbDeQ== - dependencies: - "@babel/helper-create-regexp-features-plugin" "^7.12.13" - "@babel/helper-plugin-utils" "^7.12.13" - -"@babel/plugin-transform-duplicate-keys@^7.12.13": - version "7.12.13" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-duplicate-keys/-/plugin-transform-duplicate-keys-7.12.13.tgz#6f06b87a8b803fd928e54b81c258f0a0033904de" - integrity sha512-NfADJiiHdhLBW3pulJlJI2NB0t4cci4WTZ8FtdIuNc2+8pslXdPtRRAEWqUY+m9kNOk2eRYbTAOipAxlrOcwwQ== - dependencies: - "@babel/helper-plugin-utils" "^7.12.13" - -"@babel/plugin-transform-exponentiation-operator@^7.12.13": - version "7.12.13" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-exponentiation-operator/-/plugin-transform-exponentiation-operator-7.12.13.tgz#4d52390b9a273e651e4aba6aee49ef40e80cd0a1" - integrity sha512-fbUelkM1apvqez/yYx1/oICVnGo2KM5s63mhGylrmXUxK/IAXSIf87QIxVfZldWf4QsOafY6vV3bX8aMHSvNrA== - dependencies: - "@babel/helper-builder-binary-assignment-operator-visitor" "^7.12.13" - "@babel/helper-plugin-utils" "^7.12.13" - -"@babel/plugin-transform-for-of@^7.13.0": - version "7.13.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-for-of/-/plugin-transform-for-of-7.13.0.tgz#c799f881a8091ac26b54867a845c3e97d2696062" - integrity sha512-IHKT00mwUVYE0zzbkDgNRP6SRzvfGCYsOxIRz8KsiaaHCcT9BWIkO+H9QRJseHBLOGBZkHUdHiqj6r0POsdytg== - dependencies: - "@babel/helper-plugin-utils" "^7.13.0" - -"@babel/plugin-transform-function-name@^7.12.13": - version "7.12.13" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-function-name/-/plugin-transform-function-name-7.12.13.tgz#bb024452f9aaed861d374c8e7a24252ce3a50051" - integrity sha512-6K7gZycG0cmIwwF7uMK/ZqeCikCGVBdyP2J5SKNCXO5EOHcqi+z7Jwf8AmyDNcBgxET8DrEtCt/mPKPyAzXyqQ== - dependencies: - "@babel/helper-function-name" "^7.12.13" - "@babel/helper-plugin-utils" "^7.12.13" - -"@babel/plugin-transform-literals@^7.12.13": - version "7.12.13" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-literals/-/plugin-transform-literals-7.12.13.tgz#2ca45bafe4a820197cf315794a4d26560fe4bdb9" - integrity sha512-FW+WPjSR7hiUxMcKqyNjP05tQ2kmBCdpEpZHY1ARm96tGQCCBvXKnpjILtDplUnJ/eHZ0lALLM+d2lMFSpYJrQ== - dependencies: - "@babel/helper-plugin-utils" "^7.12.13" - -"@babel/plugin-transform-member-expression-literals@^7.12.13": - version "7.12.13" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-member-expression-literals/-/plugin-transform-member-expression-literals-7.12.13.tgz#5ffa66cd59b9e191314c9f1f803b938e8c081e40" - integrity sha512-kxLkOsg8yir4YeEPHLuO2tXP9R/gTjpuTOjshqSpELUN3ZAg2jfDnKUvzzJxObun38sw3wm4Uu69sX/zA7iRvg== - dependencies: - "@babel/helper-plugin-utils" "^7.12.13" - -"@babel/plugin-transform-modules-amd@^7.13.0": - version "7.13.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-amd/-/plugin-transform-modules-amd-7.13.0.tgz#19f511d60e3d8753cc5a6d4e775d3a5184866cc3" - integrity sha512-EKy/E2NHhY/6Vw5d1k3rgoobftcNUmp9fGjb9XZwQLtTctsRBOTRO7RHHxfIky1ogMN5BxN7p9uMA3SzPfotMQ== - dependencies: - "@babel/helper-module-transforms" "^7.13.0" - "@babel/helper-plugin-utils" "^7.13.0" - babel-plugin-dynamic-import-node "^2.3.3" - -"@babel/plugin-transform-modules-commonjs@^7.13.8": - version "7.13.8" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.13.8.tgz#7b01ad7c2dcf2275b06fa1781e00d13d420b3e1b" - integrity sha512-9QiOx4MEGglfYZ4XOnU79OHr6vIWUakIj9b4mioN8eQIoEh+pf5p/zEB36JpDFWA12nNMiRf7bfoRvl9Rn79Bw== - dependencies: - "@babel/helper-module-transforms" "^7.13.0" - "@babel/helper-plugin-utils" "^7.13.0" - "@babel/helper-simple-access" "^7.12.13" - babel-plugin-dynamic-import-node "^2.3.3" - -"@babel/plugin-transform-modules-systemjs@^7.13.8": - version "7.13.8" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-systemjs/-/plugin-transform-modules-systemjs-7.13.8.tgz#6d066ee2bff3c7b3d60bf28dec169ad993831ae3" - integrity sha512-hwqctPYjhM6cWvVIlOIe27jCIBgHCsdH2xCJVAYQm7V5yTMoilbVMi9f6wKg0rpQAOn6ZG4AOyvCqFF/hUh6+A== - dependencies: - "@babel/helper-hoist-variables" "^7.13.0" - "@babel/helper-module-transforms" "^7.13.0" - "@babel/helper-plugin-utils" "^7.13.0" - "@babel/helper-validator-identifier" "^7.12.11" - babel-plugin-dynamic-import-node "^2.3.3" - -"@babel/plugin-transform-modules-umd@^7.13.0": - version "7.13.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-umd/-/plugin-transform-modules-umd-7.13.0.tgz#8a3d96a97d199705b9fd021580082af81c06e70b" - integrity sha512-D/ILzAh6uyvkWjKKyFE/W0FzWwasv6vPTSqPcjxFqn6QpX3u8DjRVliq4F2BamO2Wee/om06Vyy+vPkNrd4wxw== - dependencies: - "@babel/helper-module-transforms" "^7.13.0" - "@babel/helper-plugin-utils" "^7.13.0" - -"@babel/plugin-transform-named-capturing-groups-regex@^7.12.13": - version "7.12.13" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-named-capturing-groups-regex/-/plugin-transform-named-capturing-groups-regex-7.12.13.tgz#2213725a5f5bbbe364b50c3ba5998c9599c5c9d9" - integrity sha512-Xsm8P2hr5hAxyYblrfACXpQKdQbx4m2df9/ZZSQ8MAhsadw06+jW7s9zsSw6he+mJZXRlVMyEnVktJo4zjk1WA== - dependencies: - "@babel/helper-create-regexp-features-plugin" "^7.12.13" - -"@babel/plugin-transform-new-target@^7.12.13": - version "7.12.13" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-new-target/-/plugin-transform-new-target-7.12.13.tgz#e22d8c3af24b150dd528cbd6e685e799bf1c351c" - integrity sha512-/KY2hbLxrG5GTQ9zzZSc3xWiOy379pIETEhbtzwZcw9rvuaVV4Fqy7BYGYOWZnaoXIQYbbJ0ziXLa/sKcGCYEQ== - dependencies: - "@babel/helper-plugin-utils" "^7.12.13" - -"@babel/plugin-transform-object-super@^7.12.13": - version "7.12.13" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-object-super/-/plugin-transform-object-super-7.12.13.tgz#b4416a2d63b8f7be314f3d349bd55a9c1b5171f7" - integrity sha512-JzYIcj3XtYspZDV8j9ulnoMPZZnF/Cj0LUxPOjR89BdBVx+zYJI9MdMIlUZjbXDX+6YVeS6I3e8op+qQ3BYBoQ== - dependencies: - "@babel/helper-plugin-utils" "^7.12.13" - "@babel/helper-replace-supers" "^7.12.13" - -"@babel/plugin-transform-parameters@^7.13.0": - version "7.13.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-parameters/-/plugin-transform-parameters-7.13.0.tgz#8fa7603e3097f9c0b7ca1a4821bc2fb52e9e5007" - integrity sha512-Jt8k/h/mIwE2JFEOb3lURoY5C85ETcYPnbuAJ96zRBzh1XHtQZfs62ChZ6EP22QlC8c7Xqr9q+e1SU5qttwwjw== - dependencies: - "@babel/helper-plugin-utils" "^7.13.0" - -"@babel/plugin-transform-property-literals@^7.12.13": - version "7.12.13" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-property-literals/-/plugin-transform-property-literals-7.12.13.tgz#4e6a9e37864d8f1b3bc0e2dce7bf8857db8b1a81" - integrity sha512-nqVigwVan+lR+g8Fj8Exl0UQX2kymtjcWfMOYM1vTYEKujeyv2SkMgazf2qNcK7l4SDiKyTA/nHCPqL4e2zo1A== - dependencies: - "@babel/helper-plugin-utils" "^7.12.13" - -"@babel/plugin-transform-regenerator@^7.12.13": - version "7.12.13" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-regenerator/-/plugin-transform-regenerator-7.12.13.tgz#b628bcc9c85260ac1aeb05b45bde25210194a2f5" - integrity sha512-lxb2ZAvSLyJ2PEe47hoGWPmW22v7CtSl9jW8mingV4H2sEX/JOcrAj2nPuGWi56ERUm2bUpjKzONAuT6HCn2EA== - dependencies: - regenerator-transform "^0.14.2" - -"@babel/plugin-transform-reserved-words@^7.12.13": - version "7.12.13" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-reserved-words/-/plugin-transform-reserved-words-7.12.13.tgz#7d9988d4f06e0fe697ea1d9803188aa18b472695" - integrity sha512-xhUPzDXxZN1QfiOy/I5tyye+TRz6lA7z6xaT4CLOjPRMVg1ldRf0LHw0TDBpYL4vG78556WuHdyO9oi5UmzZBg== - dependencies: - "@babel/helper-plugin-utils" "^7.12.13" - -"@babel/plugin-transform-shorthand-properties@^7.12.13": - version "7.12.13" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-shorthand-properties/-/plugin-transform-shorthand-properties-7.12.13.tgz#db755732b70c539d504c6390d9ce90fe64aff7ad" - integrity sha512-xpL49pqPnLtf0tVluuqvzWIgLEhuPpZzvs2yabUHSKRNlN7ScYU7aMlmavOeyXJZKgZKQRBlh8rHbKiJDraTSw== - dependencies: - "@babel/helper-plugin-utils" "^7.12.13" - -"@babel/plugin-transform-spread@^7.13.0": - version "7.13.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-spread/-/plugin-transform-spread-7.13.0.tgz#84887710e273c1815ace7ae459f6f42a5d31d5fd" - integrity sha512-V6vkiXijjzYeFmQTr3dBxPtZYLPcUfY34DebOU27jIl2M/Y8Egm52Hw82CSjjPqd54GTlJs5x+CR7HeNr24ckg== - dependencies: - "@babel/helper-plugin-utils" "^7.13.0" - "@babel/helper-skip-transparent-expression-wrappers" "^7.12.1" - -"@babel/plugin-transform-sticky-regex@^7.12.13": - version "7.12.13" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-sticky-regex/-/plugin-transform-sticky-regex-7.12.13.tgz#760ffd936face73f860ae646fb86ee82f3d06d1f" - integrity sha512-Jc3JSaaWT8+fr7GRvQP02fKDsYk4K/lYwWq38r/UGfaxo89ajud321NH28KRQ7xy1Ybc0VUE5Pz8psjNNDUglg== - dependencies: - "@babel/helper-plugin-utils" "^7.12.13" - -"@babel/plugin-transform-template-literals@^7.13.0": - version "7.13.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-template-literals/-/plugin-transform-template-literals-7.13.0.tgz#a36049127977ad94438dee7443598d1cefdf409d" - integrity sha512-d67umW6nlfmr1iehCcBv69eSUSySk1EsIS8aTDX4Xo9qajAh6mYtcl4kJrBkGXuxZPEgVr7RVfAvNW6YQkd4Mw== - dependencies: - "@babel/helper-plugin-utils" "^7.13.0" - -"@babel/plugin-transform-typeof-symbol@^7.12.13": - version "7.12.13" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-typeof-symbol/-/plugin-transform-typeof-symbol-7.12.13.tgz#785dd67a1f2ea579d9c2be722de8c84cb85f5a7f" - integrity sha512-eKv/LmUJpMnu4npgfvs3LiHhJua5fo/CysENxa45YCQXZwKnGCQKAg87bvoqSW1fFT+HA32l03Qxsm8ouTY3ZQ== - dependencies: - "@babel/helper-plugin-utils" "^7.12.13" - -"@babel/plugin-transform-unicode-escapes@^7.12.13": - version "7.12.13" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-unicode-escapes/-/plugin-transform-unicode-escapes-7.12.13.tgz#840ced3b816d3b5127dd1d12dcedc5dead1a5e74" - integrity sha512-0bHEkdwJ/sN/ikBHfSmOXPypN/beiGqjo+o4/5K+vxEFNPRPdImhviPakMKG4x96l85emoa0Z6cDflsdBusZbw== - dependencies: - "@babel/helper-plugin-utils" "^7.12.13" - -"@babel/plugin-transform-unicode-regex@^7.12.13": - version "7.12.13" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-unicode-regex/-/plugin-transform-unicode-regex-7.12.13.tgz#b52521685804e155b1202e83fc188d34bb70f5ac" - integrity sha512-mDRzSNY7/zopwisPZ5kM9XKCfhchqIYwAKRERtEnhYscZB79VRekuRSoYbN0+KVe3y8+q1h6A4svXtP7N+UoCA== - dependencies: - "@babel/helper-create-regexp-features-plugin" "^7.12.13" - "@babel/helper-plugin-utils" "^7.12.13" - -"@babel/polyfill@^7.8.7": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/polyfill/-/polyfill-7.12.1.tgz#1f2d6371d1261bbd961f3c5d5909150e12d0bd96" - integrity sha512-X0pi0V6gxLi6lFZpGmeNa4zxtwEmCs42isWLNjZZDE0Y8yVfgu0T2OAHlzBbdYlqbW/YXVvoBHpATEM+goCj8g== - dependencies: - core-js "^2.6.5" - regenerator-runtime "^0.13.4" - -"@babel/preset-env@^7.11.0": - version "7.13.12" - resolved "https://registry.yarnpkg.com/@babel/preset-env/-/preset-env-7.13.12.tgz#6dff470478290582ac282fb77780eadf32480237" - integrity sha512-JzElc6jk3Ko6zuZgBtjOd01pf9yYDEIH8BcqVuYIuOkzOwDesoa/Nz4gIo4lBG6K861KTV9TvIgmFuT6ytOaAA== - dependencies: - "@babel/compat-data" "^7.13.12" - "@babel/helper-compilation-targets" "^7.13.10" - "@babel/helper-plugin-utils" "^7.13.0" - "@babel/helper-validator-option" "^7.12.17" - "@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining" "^7.13.12" - "@babel/plugin-proposal-async-generator-functions" "^7.13.8" - "@babel/plugin-proposal-class-properties" "^7.13.0" - "@babel/plugin-proposal-dynamic-import" "^7.13.8" - "@babel/plugin-proposal-export-namespace-from" "^7.12.13" - "@babel/plugin-proposal-json-strings" "^7.13.8" - "@babel/plugin-proposal-logical-assignment-operators" "^7.13.8" - "@babel/plugin-proposal-nullish-coalescing-operator" "^7.13.8" - "@babel/plugin-proposal-numeric-separator" "^7.12.13" - "@babel/plugin-proposal-object-rest-spread" "^7.13.8" - "@babel/plugin-proposal-optional-catch-binding" "^7.13.8" - "@babel/plugin-proposal-optional-chaining" "^7.13.12" - "@babel/plugin-proposal-private-methods" "^7.13.0" - "@babel/plugin-proposal-unicode-property-regex" "^7.12.13" - "@babel/plugin-syntax-async-generators" "^7.8.4" - "@babel/plugin-syntax-class-properties" "^7.12.13" - "@babel/plugin-syntax-dynamic-import" "^7.8.3" - "@babel/plugin-syntax-export-namespace-from" "^7.8.3" - "@babel/plugin-syntax-json-strings" "^7.8.3" - "@babel/plugin-syntax-logical-assignment-operators" "^7.10.4" - "@babel/plugin-syntax-nullish-coalescing-operator" "^7.8.3" - "@babel/plugin-syntax-numeric-separator" "^7.10.4" - "@babel/plugin-syntax-object-rest-spread" "^7.8.3" - "@babel/plugin-syntax-optional-catch-binding" "^7.8.3" - "@babel/plugin-syntax-optional-chaining" "^7.8.3" - "@babel/plugin-syntax-top-level-await" "^7.12.13" - "@babel/plugin-transform-arrow-functions" "^7.13.0" - "@babel/plugin-transform-async-to-generator" "^7.13.0" - "@babel/plugin-transform-block-scoped-functions" "^7.12.13" - "@babel/plugin-transform-block-scoping" "^7.12.13" - "@babel/plugin-transform-classes" "^7.13.0" - "@babel/plugin-transform-computed-properties" "^7.13.0" - "@babel/plugin-transform-destructuring" "^7.13.0" - "@babel/plugin-transform-dotall-regex" "^7.12.13" - "@babel/plugin-transform-duplicate-keys" "^7.12.13" - "@babel/plugin-transform-exponentiation-operator" "^7.12.13" - "@babel/plugin-transform-for-of" "^7.13.0" - "@babel/plugin-transform-function-name" "^7.12.13" - "@babel/plugin-transform-literals" "^7.12.13" - "@babel/plugin-transform-member-expression-literals" "^7.12.13" - "@babel/plugin-transform-modules-amd" "^7.13.0" - "@babel/plugin-transform-modules-commonjs" "^7.13.8" - "@babel/plugin-transform-modules-systemjs" "^7.13.8" - "@babel/plugin-transform-modules-umd" "^7.13.0" - "@babel/plugin-transform-named-capturing-groups-regex" "^7.12.13" - "@babel/plugin-transform-new-target" "^7.12.13" - "@babel/plugin-transform-object-super" "^7.12.13" - "@babel/plugin-transform-parameters" "^7.13.0" - "@babel/plugin-transform-property-literals" "^7.12.13" - "@babel/plugin-transform-regenerator" "^7.12.13" - "@babel/plugin-transform-reserved-words" "^7.12.13" - "@babel/plugin-transform-shorthand-properties" "^7.12.13" - "@babel/plugin-transform-spread" "^7.13.0" - "@babel/plugin-transform-sticky-regex" "^7.12.13" - "@babel/plugin-transform-template-literals" "^7.13.0" - "@babel/plugin-transform-typeof-symbol" "^7.12.13" - "@babel/plugin-transform-unicode-escapes" "^7.12.13" - "@babel/plugin-transform-unicode-regex" "^7.12.13" - "@babel/preset-modules" "^0.1.4" - "@babel/types" "^7.13.12" - babel-plugin-polyfill-corejs2 "^0.1.4" - babel-plugin-polyfill-corejs3 "^0.1.3" - babel-plugin-polyfill-regenerator "^0.1.2" - core-js-compat "^3.9.0" - semver "^6.3.0" - -"@babel/preset-modules@^0.1.4": - version "0.1.4" - resolved "https://registry.yarnpkg.com/@babel/preset-modules/-/preset-modules-0.1.4.tgz#362f2b68c662842970fdb5e254ffc8fc1c2e415e" - integrity sha512-J36NhwnfdzpmH41M1DrnkkgAqhZaqr/NBdPfQ677mLzlaXo+oDiv1deyCDtgAhz8p328otdob0Du7+xgHGZbKg== - dependencies: - "@babel/helper-plugin-utils" "^7.0.0" - "@babel/plugin-proposal-unicode-property-regex" "^7.4.4" - "@babel/plugin-transform-dotall-regex" "^7.4.4" - "@babel/types" "^7.4.4" - esutils "^2.0.2" - -"@babel/runtime@^7.8.4": - version "7.13.10" - resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.13.10.tgz#47d42a57b6095f4468da440388fdbad8bebf0d7d" - integrity sha512-4QPkjJq6Ns3V/RgpEahRk+AGfL0eO6RHHtTWoNNr5mO49G6B5+X6d6THgWEAvTrznU5xYpbAlVKRYcsCgh/Akw== - dependencies: - regenerator-runtime "^0.13.4" - -"@babel/template@^7.12.13": - version "7.12.13" - resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.12.13.tgz#530265be8a2589dbb37523844c5bcb55947fb327" - integrity sha512-/7xxiGA57xMo/P2GVvdEumr8ONhFOhfgq2ihK3h1e6THqzTAkHbkXgB0xI9yeTfIUoH3+oAeHhqm/I43OTbbjA== - dependencies: - "@babel/code-frame" "^7.12.13" - "@babel/parser" "^7.12.13" - "@babel/types" "^7.12.13" - -"@babel/traverse@^7.13.0", "@babel/traverse@^7.13.13": - version "7.13.13" - resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.13.13.tgz#39aa9c21aab69f74d948a486dd28a2dbdbf5114d" - integrity sha512-CblEcwmXKR6eP43oQGG++0QMTtCjAsa3frUuzHoiIJWpaIIi8dwMyEFUJoXRLxagGqCK+jALRwIO+o3R9p/uUg== - dependencies: - "@babel/code-frame" "^7.12.13" - "@babel/generator" "^7.13.9" - "@babel/helper-function-name" "^7.12.13" - "@babel/helper-split-export-declaration" "^7.12.13" - "@babel/parser" "^7.13.13" - "@babel/types" "^7.13.13" - debug "^4.1.0" - globals "^11.1.0" - -"@babel/types@^7.12.1", "@babel/types@^7.12.13", "@babel/types@^7.13.0", "@babel/types@^7.13.12", "@babel/types@^7.13.13", "@babel/types@^7.4.4": - version "7.13.13" - resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.13.13.tgz#dcd8b815b38f537a3697ce84c8e3cc62197df96f" - integrity "sha1-3Ni4FbOPU3o2l86EyOPMYhl9+W8= sha512-kt+EpC6qDfIaqlP+DIbIJOclYy/A1YXs9dAf/ljbi+39Bcbc073H6jKVpXEr/EoIh5anGn5xq/yRVzKl+uIc9w==" - dependencies: - "@babel/helper-validator-identifier" "^7.12.11" - lodash "^4.17.19" - to-fast-properties "^2.0.0" - -"@colors/colors@1.5.0": - version "1.5.0" - resolved "https://registry.yarnpkg.com/@colors/colors/-/colors-1.5.0.tgz#bb504579c1cae923e6576a4f5da43d25f97bdbd9" - integrity sha512-ooWCrlZP11i8GImSjTHYHLkvFDP48nS4+204nGb1RiX/WXYHmJA2III9/e2DWVabCESdW7hBAEzHRqUn9OUVvQ== - -"@cspotcode/source-map-support@^0.8.0": - version "0.8.1" - resolved "https://registry.yarnpkg.com/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz#00629c35a688e05a88b1cda684fb9d5e73f000a1" - integrity sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw== - dependencies: - "@jridgewell/trace-mapping" "0.3.9" - -"@istanbuljs/schema@^0.1.2": - version "0.1.3" - resolved "https://registry.yarnpkg.com/@istanbuljs/schema/-/schema-0.1.3.tgz#e45e384e4b8ec16bce2fd903af78450f6bf7ec98" - integrity sha512-ZXRY4jNvVgSVQ8DL3LTcakaAtXwTVUxE81hslsyD2AtoXW/wVob10HkOJ1X/pAlcI7D+2YoZKg5do8G/w6RYgA== - -"@jridgewell/gen-mapping@^0.3.0": - version "0.3.2" - resolved "https://registry.yarnpkg.com/@jridgewell/gen-mapping/-/gen-mapping-0.3.2.tgz#c1aedc61e853f2bb9f5dfe6d4442d3b565b253b9" - integrity sha512-mh65xKQAzI6iBcFzwv28KVWSmCkdRBWoOh+bYQGW3+6OZvbbN3TqMGo5hqYxQniRcH9F2VZIoJCm4pa3BPDK/A== - dependencies: - "@jridgewell/set-array" "^1.0.1" - "@jridgewell/sourcemap-codec" "^1.4.10" - "@jridgewell/trace-mapping" "^0.3.9" - -"@jridgewell/resolve-uri@^3.0.3": - version "3.1.0" - resolved "https://registry.yarnpkg.com/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz#2203b118c157721addfe69d47b70465463066d78" - integrity sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w== - -"@jridgewell/set-array@^1.0.1": - version "1.1.2" - resolved "https://registry.yarnpkg.com/@jridgewell/set-array/-/set-array-1.1.2.tgz#7c6cf998d6d20b914c0a55a91ae928ff25965e72" - integrity sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw== - -"@jridgewell/source-map@^0.3.2": - version "0.3.2" - resolved "https://registry.yarnpkg.com/@jridgewell/source-map/-/source-map-0.3.2.tgz#f45351aaed4527a298512ec72f81040c998580fb" - integrity sha512-m7O9o2uR8k2ObDysZYzdfhb08VuEml5oWGiosa1VdaPZ/A6QyPkAJuwN0Q1lhULOf6B7MtQmHENS743hWtCrgw== - dependencies: - "@jridgewell/gen-mapping" "^0.3.0" - "@jridgewell/trace-mapping" "^0.3.9" - -"@jridgewell/sourcemap-codec@^1.4.10": - version "1.4.14" - resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz#add4c98d341472a289190b424efbdb096991bb24" - integrity sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw== - -"@jridgewell/trace-mapping@0.3.9": - version "0.3.9" - resolved "https://registry.yarnpkg.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz#6534fd5933a53ba7cbf3a17615e273a0d1273ff9" - integrity sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ== - dependencies: - "@jridgewell/resolve-uri" "^3.0.3" - "@jridgewell/sourcemap-codec" "^1.4.10" - -"@jridgewell/trace-mapping@^0.3.9": - version "0.3.14" - resolved "https://registry.yarnpkg.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.14.tgz#b231a081d8f66796e475ad588a1ef473112701ed" - integrity sha512-bJWEfQ9lPTvm3SneWwRFVLzrh6nhjwqw7TUFFBEMzwvg7t7PCDenf2lDwqo4NQXzdpgBXyFgDWnQA+2vkruksQ== - dependencies: - "@jridgewell/resolve-uri" "^3.0.3" - "@jridgewell/sourcemap-codec" "^1.4.10" - -"@rollup/pluginutils@^4.1.2": - version "4.2.1" - resolved "https://registry.yarnpkg.com/@rollup/pluginutils/-/pluginutils-4.2.1.tgz#e6c6c3aba0744edce3fb2074922d3776c0af2a6d" - integrity sha512-iKnFXr7NkdZAIHiIWE+BX5ULi/ucVFYWD6TbAV+rZctiRTY2PL6tsIKhoIOaoskiWAkgu+VsbXgUVDNLHf+InQ== - dependencies: - estree-walker "^2.0.1" - picomatch "^2.2.2" - -"@socket.io/component-emitter@~3.1.0": - version "3.1.0" - resolved "https://registry.yarnpkg.com/@socket.io/component-emitter/-/component-emitter-3.1.0.tgz#96116f2a912e0c02817345b3c10751069920d553" - integrity sha512-+9jVqKhRSpsc591z5vX+X5Yyw+he/HCB4iQ/RYxw35CEPaY1gnsNE43nf9n9AaYjAQrTiI/mOwKUKdUs9vf7Xg== - -"@tensorflow/tfjs-backend-cpu@4.9.0": - version "4.9.0" - resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-backend-cpu/-/tfjs-backend-cpu-4.9.0.tgz#76ce8f4e83814293b662404f16d70f65926195a2" - integrity sha512-AHIfI3iD1fyQgQKeoQmtkI3exPWRfOo+W0Ws/bxOdapTXcAYWGg0179t52j8XPDwsl8WopfaTINNgYNG6FnP3Q== - dependencies: - "@types/seedrandom" "^2.4.28" - seedrandom "^3.0.5" - -"@tensorflow/tfjs-backend-webgl@^4.9.0": - version "4.9.0" - resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-backend-webgl/-/tfjs-backend-webgl-4.9.0.tgz#272812af5c61d02af3b541ed543c3484f5eb8618" - integrity sha512-lSEOjR9zi6vb1V9yhrby8jWt6SS+wWBXRa3sDE5GCbpcHMWHv41wZktB2WQyIXDqJQcw1lRZBDoYneibMqr2uQ== - dependencies: - "@tensorflow/tfjs-backend-cpu" "4.9.0" - "@types/offscreencanvas" "~2019.3.0" - "@types/seedrandom" "^2.4.28" - "@types/webgl-ext" "0.0.30" - seedrandom "^3.0.5" - -"@tensorflow/tfjs-converter@^4.9.0": - version "4.9.0" - resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-converter/-/tfjs-converter-4.9.0.tgz#7958f563043b3c54f757f47d2b5b08e963f466ad" - integrity sha512-mRlzdG3jVsxMkFfHFgDNY10HMoh+vtfPPIghtY+Fc4U/ZnBUFvSfZqwEFyXfOJAewn4fY4BX8+6RE4a0kRXqGA== - -"@tensorflow/tfjs-core@^4.9.0": - version "4.9.0" - resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-core/-/tfjs-core-4.9.0.tgz#7df04d13df85dfb53762a5bb654bfcc24fb34de1" - integrity sha512-1nYs9OA934eSI33eTvyCVJUEji2wnMXyZ3VK7l2iS/TPDFISI3ETyh286mW56LCihoniv8HH2MtOAQwo4Qhrdg== - dependencies: - "@types/long" "^4.0.1" - "@types/offscreencanvas" "~2019.7.0" - "@types/seedrandom" "^2.4.28" - "@types/webgl-ext" "0.0.30" - "@webgpu/types" "0.1.30" - long "4.0.0" - node-fetch "~2.6.1" - seedrandom "^3.0.5" - -"@tsconfig/node10@^1.0.7": - version "1.0.9" - resolved "https://registry.yarnpkg.com/@tsconfig/node10/-/node10-1.0.9.tgz#df4907fc07a886922637b15e02d4cebc4c0021b2" - integrity sha512-jNsYVVxU8v5g43Erja32laIDHXeoNvFEpX33OK4d6hljo3jDhCBDhx5dhCCTMWUojscpAagGiRkBKxpdl9fxqA== - -"@tsconfig/node12@^1.0.7": - version "1.0.11" - resolved "https://registry.yarnpkg.com/@tsconfig/node12/-/node12-1.0.11.tgz#ee3def1f27d9ed66dac6e46a295cffb0152e058d" - integrity sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag== - -"@tsconfig/node14@^1.0.0": - version "1.0.3" - resolved "https://registry.yarnpkg.com/@tsconfig/node14/-/node14-1.0.3.tgz#e4386316284f00b98435bf40f72f75a09dabf6c1" - integrity sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow== - -"@tsconfig/node16@^1.0.2": - version "1.0.3" - resolved "https://registry.yarnpkg.com/@tsconfig/node16/-/node16-1.0.3.tgz#472eaab5f15c1ffdd7f8628bd4c4f753995ec79e" - integrity sha512-yOlFc+7UtL/89t2ZhjPvvB/DeAr3r+Dq58IgzsFkOAvVC6NMJXmCGjbptdXdR9qsX7pKcTL+s87FtYREi2dEEQ== - -"@types/cookie@^0.4.1": - version "0.4.1" - resolved "https://registry.yarnpkg.com/@types/cookie/-/cookie-0.4.1.tgz#bfd02c1f2224567676c1545199f87c3a861d878d" - integrity sha512-XW/Aa8APYr6jSVVA1y/DEIZX0/GMKLEVekNG727R8cs56ahETkRAy/3DR7+fJyh7oUgGwNQaRfXCun0+KbWY7Q== - -"@types/cors@^2.8.12": - version "2.8.12" - resolved "https://registry.yarnpkg.com/@types/cors/-/cors-2.8.12.tgz#6b2c510a7ad7039e98e7b8d3d6598f4359e5c080" - integrity sha512-vt+kDhq/M2ayberEtJcIN/hxXy1Pk+59g2FV/ZQceeaTyCtCucjL2Q7FXlFjtWn4n15KCr1NE2lNNFhp0lEThw== - -"@types/estree@*": - version "1.0.0" - resolved "https://registry.yarnpkg.com/@types/estree/-/estree-1.0.0.tgz#5fb2e536c1ae9bf35366eed879e827fa59ca41c2" - integrity sha512-WulqXMDUTYAXCjZnk6JtIHPigp55cVtDgDrO2gHRwhyJto21+1zbVCtOYB2L1F9w4qCQ0rOGWBnBe0FNTiEJIQ== - -"@types/jasmine@~4.3.1": - version "4.3.1" - resolved "https://registry.yarnpkg.com/@types/jasmine/-/jasmine-4.3.1.tgz#2d8ab5601c2fe7d9673dcb157e03f128ab5c5fff" - integrity sha512-Vu8l+UGcshYmV1VWwULgnV/2RDbBaO6i2Ptx7nd//oJPIZGhoI1YLST4VKagD2Pq/Bc2/7zvtvhM7F3p4SN7kQ== - -"@types/long@^4.0.1": - version "4.0.1" - resolved "https://registry.yarnpkg.com/@types/long/-/long-4.0.1.tgz#459c65fa1867dafe6a8f322c4c51695663cc55e9" - integrity sha512-5tXH6Bx/kNGd3MgffdmP4dy2Z+G4eaXw0SE81Tq3BNadtnMR5/ySMzX4SLEzHJzSmPNn4HIdpQsBvXMUykr58w== - -"@types/node@*", "@types/node@>=10.0.0": - version "14.14.36" - resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.36.tgz#5637905dbb15c30a33a3c65b9ef7c20e3c85ebad" - integrity sha512-kjivUwDJfIjngzbhooRnOLhGYz6oRFi+L+EpMjxroDYXwDw9lHrJJ43E+dJ6KAd3V3WxWAJ/qZE9XKYHhjPOFQ== - -"@types/offscreencanvas@~2019.3.0": - version "2019.3.0" - resolved "https://registry.yarnpkg.com/@types/offscreencanvas/-/offscreencanvas-2019.3.0.tgz#3336428ec7e9180cf4566dfea5da04eb586a6553" - integrity sha512-esIJx9bQg+QYF0ra8GnvfianIY8qWB0GBx54PK5Eps6m+xTj86KLavHv6qDhzKcu5UUOgNfJ2pWaIIV7TRUd9Q== - -"@types/offscreencanvas@~2019.7.0": - version "2019.7.0" - resolved "https://registry.yarnpkg.com/@types/offscreencanvas/-/offscreencanvas-2019.7.0.tgz#e4a932069db47bb3eabeb0b305502d01586fa90d" - integrity sha512-PGcyveRIpL1XIqK8eBsmRBt76eFgtzuPiSTyKHZxnGemp2yzGzWpjYKAfK3wIMiU7eH+851yEpiuP8JZerTmWg== - -"@types/resolve@0.0.8": - version "0.0.8" - resolved "https://registry.yarnpkg.com/@types/resolve/-/resolve-0.0.8.tgz#f26074d238e02659e323ce1a13d041eee280e194" - integrity sha512-auApPaJf3NPfe18hSoJkp8EbZzer2ISk7o8mCC3M9he/a04+gbMF97NkpD2S8riMGvm4BMRI59/SZQSaLTKpsQ== - dependencies: - "@types/node" "*" - -"@types/seedrandom@^2.4.28": - version "2.4.30" - resolved "https://registry.yarnpkg.com/@types/seedrandom/-/seedrandom-2.4.30.tgz#d2efe425869b84163c2d56e779dddadb9372cbfa" - integrity sha512-AnxLHewubLVzoF/A4qdxBGHCKifw8cY32iro3DQX9TPcetE95zBeVt3jnsvtvAUf1vwzMfwzp4t/L2yqPlnjkQ== - -"@types/webgl-ext@0.0.30": - version "0.0.30" - resolved "https://registry.yarnpkg.com/@types/webgl-ext/-/webgl-ext-0.0.30.tgz#0ce498c16a41a23d15289e0b844d945b25f0fb9d" - integrity sha512-LKVgNmBxN0BbljJrVUwkxwRYqzsAEPcZOe6S2T6ZaBDIrFp0qu4FNlpc5sM1tGbXUYFgdVQIoeLk1Y1UoblyEg== - -"@webgpu/types@0.1.30": - version "0.1.30" - resolved "https://registry.yarnpkg.com/@webgpu/types/-/types-0.1.30.tgz#b6406dc4a1c1e0d469028ceb30ddffbbd2fa706c" - integrity sha512-9AXJSmL3MzY8ZL//JjudA//q+2kBRGhLBFpkdGksWIuxrMy81nFrCzj2Am+mbh8WoU6rXmv7cY5E3rdlyru2Qg== - -accepts@~1.3.4: - version "1.3.7" - resolved "https://registry.yarnpkg.com/accepts/-/accepts-1.3.7.tgz#531bc726517a3b2b41f850021c6cc15eaab507cd" - integrity sha512-Il80Qs2WjYlJIBNzNkK6KYqlVMTbZLXgHx2oT0pU/fjRHyEp+PEfEPY0R3WCwAGVOtauxh1hOxNgIf5bv7dQpA== - dependencies: - mime-types "~2.1.24" - negotiator "0.6.2" - -acorn-walk@^8.0.2: - version "8.0.2" - resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-8.0.2.tgz#d4632bfc63fd93d0f15fd05ea0e984ffd3f5a8c3" - integrity sha512-+bpA9MJsHdZ4bgfDcpk0ozQyhhVct7rzOmO0s1IIr0AGGgKBljss8n2zp11rRP2wid5VGeh04CgeKzgat5/25A== - -acorn-walk@^8.1.1: - version "8.2.0" - resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-8.2.0.tgz#741210f2e2426454508853a2f44d0ab83b7f69c1" - integrity sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA== - -acorn@^8.1.0, acorn@^8.5.0: - version "8.7.1" - resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.7.1.tgz#0197122c843d1bf6d0a5e83220a788f278f63c30" - integrity sha512-Xx54uLJQZ19lKygFXOWsscKUbsBZW0CPykPhVQdhIeIwrbPmJzqeASDInc8nKBnp/JT6igTs82qPXz069H8I/A== - -acorn@^8.4.1: - version "8.8.1" - resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.8.1.tgz#0a3f9cbecc4ec3bea6f0a80b66ae8dd2da250b73" - integrity sha512-7zFpHzhnqYKrkYdUjF1HI1bzd0VygEGX8lFk4k5zVMqHEoES+P+7TKI+EvLO9WVMJ8eekdO0aDEK044xTXwPPA== - -agent-base@5: - version "5.1.1" - resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-5.1.1.tgz#e8fb3f242959db44d63be665db7a8e739537a32c" - integrity sha512-TMeqbNl2fMW0nMjTEPOwe3J/PRFP4vqeoNuQMG0HlMrtm5QxKqdvAkZ1pRBQ/ulIyDD5Yq0nJ7YbdD8ey0TO3g== - -agent-base@^4.3.0: - version "4.3.0" - resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-4.3.0.tgz#8165f01c436009bccad0b1d122f05ed770efc6ee" - integrity sha512-salcGninV0nPrwpGNn4VTXBb1SOuXQBiqbrNXoeizJsHrsL6ERFM2Ne3JUSBWRE6aeNJI2ROP/WEEIDUiDe3cg== - dependencies: - es6-promisify "^5.0.0" - -ansi-regex@^5.0.0: - version "5.0.1" - resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.1.tgz#082cb2c89c9fe8659a311a53bd6a4dc5301db304" - integrity sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ== - -ansi-styles@^3.2.1: - version "3.2.1" - resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d" - integrity sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA== - dependencies: - color-convert "^1.9.0" - -ansi-styles@^4.0.0, ansi-styles@^4.1.0: - version "4.3.0" - resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-4.3.0.tgz#edd803628ae71c04c85ae7a0906edad34b648937" - integrity sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg== - dependencies: - color-convert "^2.0.1" - -anymatch@~3.1.2: - version "3.1.2" - resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-3.1.2.tgz#c0557c096af32f106198f4f4e2a383537e378716" - integrity sha512-P43ePfOAIupkguHUycrc4qJ9kz8ZiuOUijaETwX7THt0Y/GNK7v0aa8rY816xWjZ7rJdA5XdMcpVFTKMq+RvWg== - dependencies: - normalize-path "^3.0.0" - picomatch "^2.0.4" - -arg@^4.1.0: - version "4.1.3" - resolved "https://registry.yarnpkg.com/arg/-/arg-4.1.3.tgz#269fc7ad5b8e42cb63c896d5666017261c144089" - integrity sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA== - -argparse@^1.0.7: - version "1.0.10" - resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911" - integrity sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg== - dependencies: - sprintf-js "~1.0.2" - -array-filter@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/array-filter/-/array-filter-1.0.0.tgz#baf79e62e6ef4c2a4c0b831232daffec251f9d83" - integrity sha1-uveeYubvTCpMC4MSMtr/7CUfnYM= - -asn1.js@^5.2.0: - version "5.4.1" - resolved "https://registry.yarnpkg.com/asn1.js/-/asn1.js-5.4.1.tgz#11a980b84ebb91781ce35b0fdc2ee294e3783f07" - integrity sha512-+I//4cYPccV8LdmBLiX8CYvf9Sp3vQsrqu2QNXRcrbiWvcx/UdlFiqUJJzxRQxgsZmvhXhn4cSKeSmoFjVdupA== - dependencies: - bn.js "^4.0.0" - inherits "^2.0.1" - minimalistic-assert "^1.0.0" - safer-buffer "^2.1.0" - -assert@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/assert/-/assert-2.0.0.tgz#95fc1c616d48713510680f2eaf2d10dd22e02d32" - integrity sha512-se5Cd+js9dXJnu6Ag2JFc00t+HmHOen+8Q+L7O9zI0PqQXr20uk2J0XQqMxZEeo5U50o8Nvmmx7dZrl+Ufr35A== - dependencies: - es6-object-assign "^1.1.0" - is-nan "^1.2.1" - object-is "^1.0.1" - util "^0.12.0" - -async@^3.0.1, async@^3.2.3: - version "3.2.3" - resolved "https://registry.yarnpkg.com/async/-/async-3.2.3.tgz#ac53dafd3f4720ee9e8a160628f18ea91df196c9" - integrity sha512-spZRyzKL5l5BZQrr/6m/SqFdBN0q3OCI0f9rjfBzCMBIP4p75P620rR3gTmaksNOhmzgdxcaxdNfMy6anrbM0g== - -available-typed-arrays@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/available-typed-arrays/-/available-typed-arrays-1.0.2.tgz#6b098ca9d8039079ee3f77f7b783c4480ba513f5" - integrity sha512-XWX3OX8Onv97LMk/ftVyBibpGwY5a8SmuxZPzeOxqmuEqUCOM9ZE+uIaD1VNJ5QnvU2UQusvmKbuM1FR8QWGfQ== - dependencies: - array-filter "^1.0.0" - -babel-plugin-dynamic-import-node@^2.3.3: - version "2.3.3" - resolved "https://registry.yarnpkg.com/babel-plugin-dynamic-import-node/-/babel-plugin-dynamic-import-node-2.3.3.tgz#84fda19c976ec5c6defef57f9427b3def66e17a3" - integrity sha512-jZVI+s9Zg3IqA/kdi0i6UDCybUI3aSBLnglhYbSSjKlV7yF1F/5LWv8MakQmvYpnbJDS6fcBL2KzHSxNCMtWSQ== - dependencies: - object.assign "^4.1.0" - -babel-plugin-polyfill-corejs2@^0.1.4: - version "0.1.10" - resolved "https://registry.yarnpkg.com/babel-plugin-polyfill-corejs2/-/babel-plugin-polyfill-corejs2-0.1.10.tgz#a2c5c245f56c0cac3dbddbf0726a46b24f0f81d1" - integrity sha512-DO95wD4g0A8KRaHKi0D51NdGXzvpqVLnLu5BTvDlpqUEpTmeEtypgC1xqesORaWmiUOQI14UHKlzNd9iZ2G3ZA== - dependencies: - "@babel/compat-data" "^7.13.0" - "@babel/helper-define-polyfill-provider" "^0.1.5" - semver "^6.1.1" - -babel-plugin-polyfill-corejs3@^0.1.3: - version "0.1.7" - resolved "https://registry.yarnpkg.com/babel-plugin-polyfill-corejs3/-/babel-plugin-polyfill-corejs3-0.1.7.tgz#80449d9d6f2274912e05d9e182b54816904befd0" - integrity sha512-u+gbS9bbPhZWEeyy1oR/YaaSpod/KDT07arZHb80aTpl8H5ZBq+uN1nN9/xtX7jQyfLdPfoqI4Rue/MQSWJquw== - dependencies: - "@babel/helper-define-polyfill-provider" "^0.1.5" - core-js-compat "^3.8.1" - -babel-plugin-polyfill-regenerator@^0.1.2: - version "0.1.6" - resolved "https://registry.yarnpkg.com/babel-plugin-polyfill-regenerator/-/babel-plugin-polyfill-regenerator-0.1.6.tgz#0fe06a026fe0faa628ccc8ba3302da0a6ce02f3f" - integrity sha512-OUrYG9iKPKz8NxswXbRAdSwF0GhRdIEMTloQATJi4bDuFqrXaXcCUT/VGNrr8pBcjMh1RxZ7Xt9cytVJTJfvMg== - dependencies: - "@babel/helper-define-polyfill-provider" "^0.1.5" - -balanced-match@^1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee" - integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw== - -base64-js@^1.3.1: - version "1.5.1" - resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a" - integrity sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA== - -base64id@2.0.0, base64id@~2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/base64id/-/base64id-2.0.0.tgz#2770ac6bc47d312af97a8bf9a634342e0cd25cb6" - integrity sha512-lGe34o6EHj9y3Kts9R4ZYs/Gr+6N7MCaMlIFA3F1R2O5/m7K06AxfSeO5530PEERE6/WyEg3lsuyw4GHlPZHog== - -binary-extensions@^2.0.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.2.0.tgz#75f502eeaf9ffde42fc98829645be4ea76bd9e2d" - integrity sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA== - -bn.js@^4.0.0, bn.js@^4.1.0, bn.js@^4.11.9: - version "4.12.0" - resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-4.12.0.tgz#775b3f278efbb9718eec7361f483fb36fbbfea88" - integrity sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA== - -bn.js@^5.0.0, bn.js@^5.1.1: - version "5.2.0" - resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-5.2.0.tgz#358860674396c6997771a9d051fcc1b57d4ae002" - integrity sha512-D7iWRBvnZE8ecXiLj/9wbxH7Tk79fAh8IHaTNq1RWRixsS02W+5qS+iE9yq6RYl0asXx5tw0bLhmT5pIfbSquw== - -body-parser@^1.19.0: - version "1.19.0" - resolved "https://registry.yarnpkg.com/body-parser/-/body-parser-1.19.0.tgz#96b2709e57c9c4e09a6fd66a8fd979844f69f08a" - integrity sha512-dhEPs72UPbDnAQJ9ZKMNTP6ptJaionhP5cBb541nXPlW60Jepo9RV/a4fX4XWW9CuFNK22krhrj1+rgzifNCsw== - dependencies: - bytes "3.1.0" - content-type "~1.0.4" - debug "2.6.9" - depd "~1.1.2" - http-errors "1.7.2" - iconv-lite "0.4.24" - on-finished "~2.3.0" - qs "6.7.0" - raw-body "2.4.0" - type-is "~1.6.17" - -brace-expansion@^1.1.7: - version "1.1.11" - resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" - integrity sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA== - dependencies: - balanced-match "^1.0.0" - concat-map "0.0.1" - -braces@^3.0.2, braces@~3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107" - integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A== - dependencies: - fill-range "^7.0.1" - -brorand@^1.0.1, brorand@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/brorand/-/brorand-1.1.0.tgz#12c25efe40a45e3c323eb8675a0a0ce57b22371f" - integrity sha1-EsJe/kCkXjwyPrhnWgoM5XsiNx8= - -browser-resolve@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/browser-resolve/-/browser-resolve-2.0.0.tgz#99b7304cb392f8d73dba741bb2d7da28c6d7842b" - integrity sha512-7sWsQlYL2rGLy2IWm8WL8DCTJvYLc/qlOnsakDac87SOoCd16WLsaAMdCiAqsTNHIe+SXfaqyxyo6THoWqs8WQ== - dependencies: - resolve "^1.17.0" - -browserify-aes@^1.0.0, browserify-aes@^1.0.4: - version "1.2.0" - resolved "https://registry.yarnpkg.com/browserify-aes/-/browserify-aes-1.2.0.tgz#326734642f403dabc3003209853bb70ad428ef48" - integrity sha512-+7CHXqGuspUn/Sl5aO7Ea0xWGAtETPXNSAjHo48JfLdPWcMng33Xe4znFvQweqc/uzk5zSOI3H52CYnjCfb5hA== - dependencies: - buffer-xor "^1.0.3" - cipher-base "^1.0.0" - create-hash "^1.1.0" - evp_bytestokey "^1.0.3" - inherits "^2.0.1" - safe-buffer "^5.0.1" - -browserify-cipher@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/browserify-cipher/-/browserify-cipher-1.0.1.tgz#8d6474c1b870bfdabcd3bcfcc1934a10e94f15f0" - integrity sha512-sPhkz0ARKbf4rRQt2hTpAHqn47X3llLkUGn+xEJzLjwY8LRs2p0v7ljvI5EyoRO/mexrNunNECisZs+gw2zz1w== - dependencies: - browserify-aes "^1.0.4" - browserify-des "^1.0.0" - evp_bytestokey "^1.0.0" - -browserify-des@^1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/browserify-des/-/browserify-des-1.0.2.tgz#3af4f1f59839403572f1c66204375f7a7f703e9c" - integrity sha512-BioO1xf3hFwz4kc6iBhI3ieDFompMhrMlnDFC4/0/vd5MokpuAc3R+LYbwTA9A5Yc9pq9UYPqffKpW2ObuwX5A== - dependencies: - cipher-base "^1.0.1" - des.js "^1.0.0" - inherits "^2.0.1" - safe-buffer "^5.1.2" - -browserify-rsa@^4.0.0, browserify-rsa@^4.0.1: - version "4.1.0" - resolved "https://registry.yarnpkg.com/browserify-rsa/-/browserify-rsa-4.1.0.tgz#b2fd06b5b75ae297f7ce2dc651f918f5be158c8d" - integrity sha512-AdEER0Hkspgno2aR97SAf6vi0y0k8NuOpGnVH3O99rcA5Q6sh8QxcngtHuJ6uXwnfAXNM4Gn1Gb7/MV1+Ymbog== - dependencies: - bn.js "^5.0.0" - randombytes "^2.0.1" - -browserify-sign@^4.0.0: - version "4.2.1" - resolved "https://registry.yarnpkg.com/browserify-sign/-/browserify-sign-4.2.1.tgz#eaf4add46dd54be3bb3b36c0cf15abbeba7956c3" - integrity sha512-/vrA5fguVAKKAVTNJjgSm1tRQDHUU6DbwO9IROu/0WAzC8PKhucDSh18J0RMvVeHAn5puMd+QHC2erPRNf8lmg== - dependencies: - bn.js "^5.1.1" - browserify-rsa "^4.0.1" - create-hash "^1.2.0" - create-hmac "^1.1.7" - elliptic "^6.5.3" - inherits "^2.0.4" - parse-asn1 "^5.1.5" - readable-stream "^3.6.0" - safe-buffer "^5.2.0" - -browserify-zlib@^0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/browserify-zlib/-/browserify-zlib-0.2.0.tgz#2869459d9aa3be245fe8fe2ca1f46e2e7f54d73f" - integrity sha512-Z942RysHXmJrhqk88FmKBVq/v5tqmSkDz7p54G/MGyjMnCFFnC79XWNbg+Vta8W6Wb2qtSZTSxIGkJrRpCFEiA== - dependencies: - pako "~1.0.5" - -browserslist@^4.14.5, browserslist@^4.16.3: - version "4.18.1" - resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.18.1.tgz#60d3920f25b6860eb917c6c7b185576f4d8b017f" - integrity "sha1-YNOSDyW2hg65F8bHsYVXb02LAX8= sha512-8ScCzdpPwR2wQh8IT82CA2VgDwjHyqMovPBZSNH54+tm4Jk2pCuv90gmAdH6J84OCRWi0b4gMe6O6XPXuJnjgQ==" - dependencies: - caniuse-lite "^1.0.30001280" - electron-to-chromium "^1.3.896" - escalade "^3.1.1" - node-releases "^2.0.1" - picocolors "^1.0.0" - -browserstack-local@^1.3.7: - version "1.4.8" - resolved "https://registry.yarnpkg.com/browserstack-local/-/browserstack-local-1.4.8.tgz#07f74a19b324cf2de69ffe65f9c2baa3a2dd9a0e" - integrity sha512-s+mc3gTOJwELdLWi4qFVKtGwMbb5JWsR+JxKlMaJkRJxoZ0gg3WREgPxAN0bm6iU5+S4Bi0sz0oxBRZT8BiNsQ== - dependencies: - https-proxy-agent "^4.0.0" - is-running "^2.1.0" - ps-tree "=1.2.0" - temp-fs "^0.9.9" - -browserstack@~1.5.1: - version "1.5.3" - resolved "https://registry.yarnpkg.com/browserstack/-/browserstack-1.5.3.tgz#93ab48799a12ef99dbd074dd595410ddb196a7ac" - integrity sha512-AO+mECXsW4QcqC9bxwM29O7qWa7bJT94uBFzeb5brylIQwawuEziwq20dPYbins95GlWzOawgyDNdjYAo32EKg== - dependencies: - https-proxy-agent "^2.2.1" - -buffer-from@^1.0.0: - version "1.1.2" - resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.2.tgz#2b146a6fd72e80b4f55d255f35ed59a3a9a41bd5" - integrity sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ== - -buffer-xor@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/buffer-xor/-/buffer-xor-1.0.3.tgz#26e61ed1422fb70dd42e6e36729ed51d855fe8d9" - integrity sha1-JuYe0UIvtw3ULm42cp7VHYVf6Nk= - -buffer@^5.4.3: - version "5.7.1" - resolved "https://registry.yarnpkg.com/buffer/-/buffer-5.7.1.tgz#ba62e7c13133053582197160851a8f648e99eed0" - integrity sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ== - dependencies: - base64-js "^1.3.1" - ieee754 "^1.1.13" - -builtin-modules@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/builtin-modules/-/builtin-modules-1.1.1.tgz#270f076c5a72c02f5b65a47df94c5fe3a278892f" - integrity sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8= - -builtin-modules@^3.1.0: - version "3.3.0" - resolved "https://registry.yarnpkg.com/builtin-modules/-/builtin-modules-3.3.0.tgz#cae62812b89801e9656336e46223e030386be7b6" - integrity sha512-zhaCDicdLuWN5UbN5IMnFqNMhNfo919sH85y2/ea+5Yg9TsTkeZxpL+JLbp6cgYFS4sRLp3YV4S6yDuqVWHYOw== - -builtin-status-codes@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz#85982878e21b98e1c66425e03d0174788f569ee8" - integrity sha1-hZgoeOIbmOHGZCXgPQF0eI9Wnug= - -bytes@3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/bytes/-/bytes-3.1.0.tgz#f6cf7933a360e0588fa9fde85651cdc7f805d1f6" - integrity sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg== - -call-bind@^1.0.0, call-bind@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/call-bind/-/call-bind-1.0.2.tgz#b1d4e89e688119c3c9a903ad30abb2f6a919be3c" - integrity sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA== - dependencies: - function-bind "^1.1.1" - get-intrinsic "^1.0.2" - -caniuse-lite@^1.0.30001280: - version "1.0.30001282" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001282.tgz#38c781ee0a90ccfe1fe7fefd00e43f5ffdcb96fd" - integrity "sha1-OMeB7gqQzP4f5/79AOQ/X/3Llv0= sha512-YhF/hG6nqBEllymSIjLtR2iWDDnChvhnVJqp+vloyt2tEHFG1yBR+ac2B/rOw0qOK0m0lEXU2dv4E/sMk5P9Kg==" - -chalk@^2.0.0, chalk@^2.3.0, chalk@^2.4.1: - version "2.4.2" - resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" - integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ== - dependencies: - ansi-styles "^3.2.1" - escape-string-regexp "^1.0.5" - supports-color "^5.3.0" - -chalk@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.0.tgz#4e14870a618d9e2edd97dd8345fd9d9dc315646a" - integrity sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A== - dependencies: - ansi-styles "^4.1.0" - supports-color "^7.1.0" - -chokidar@^3.5.1: - version "3.5.3" - resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.5.3.tgz#1cf37c8707b932bd1af1ae22c0432e2acd1903bd" - integrity sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw== - dependencies: - anymatch "~3.1.2" - braces "~3.0.2" - glob-parent "~5.1.2" - is-binary-path "~2.1.0" - is-glob "~4.0.1" - normalize-path "~3.0.0" - readdirp "~3.6.0" - optionalDependencies: - fsevents "~2.3.2" - -cipher-base@^1.0.0, cipher-base@^1.0.1, cipher-base@^1.0.3: - version "1.0.4" - resolved "https://registry.yarnpkg.com/cipher-base/-/cipher-base-1.0.4.tgz#8760e4ecc272f4c363532f926d874aae2c1397de" - integrity sha512-Kkht5ye6ZGmwv40uUDZztayT2ThLQGfnj/T71N/XzeZeo3nf8foyW7zGTsPYkEya3m5f3cAypH+qe7YOrM1U2Q== - dependencies: - inherits "^2.0.1" - safe-buffer "^5.0.1" - -clang-format@~1.8.0: - version "1.8.0" - resolved "https://registry.yarnpkg.com/clang-format/-/clang-format-1.8.0.tgz#7779df1c5ce1bc8aac1b0b02b4e479191ef21d46" - integrity sha512-pK8gzfu55/lHzIpQ1givIbWfn3eXnU7SfxqIwVgnn5jEM6j4ZJYjpFqFs4iSBPNedzRMmfjYjuQhu657WAXHXw== - dependencies: - async "^3.2.3" - glob "^7.0.0" - resolve "^1.1.6" - -cliui@^7.0.2: - version "7.0.4" - resolved "https://registry.yarnpkg.com/cliui/-/cliui-7.0.4.tgz#a0265ee655476fc807aea9df3df8df7783808b4f" - integrity sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ== - dependencies: - string-width "^4.2.0" - strip-ansi "^6.0.0" - wrap-ansi "^7.0.0" - -clone@^1.0.2: - version "1.0.4" - resolved "https://registry.yarnpkg.com/clone/-/clone-1.0.4.tgz#da309cc263df15994c688ca902179ca3c7cd7c7e" - integrity sha1-2jCcwmPfFZlMaIypAheco8fNfH4= - -color-convert@^1.9.0: - version "1.9.3" - resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8" - integrity sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg== - dependencies: - color-name "1.1.3" - -color-convert@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-2.0.1.tgz#72d3a68d598c9bdb3af2ad1e84f21d896abd4de3" - integrity sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ== - dependencies: - color-name "~1.1.4" - -color-name@1.1.3: - version "1.1.3" - resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25" - integrity sha1-p9BVi9icQveV3UIyj3QIMcpTvCU= - -color-name@~1.1.4: - version "1.1.4" - resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2" - integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA== - -combine-source-map@^0.8.0: - version "0.8.0" - resolved "https://registry.yarnpkg.com/combine-source-map/-/combine-source-map-0.8.0.tgz#a58d0df042c186fcf822a8e8015f5450d2d79a8b" - integrity sha1-pY0N8ELBhvz4IqjoAV9UUNLXmos= - dependencies: - convert-source-map "~1.1.0" - inline-source-map "~0.6.0" - lodash.memoize "~3.0.3" - source-map "~0.5.3" - -commander@^2.12.1, commander@^2.20.0: - version "2.20.3" - resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33" - integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ== - -commondir@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/commondir/-/commondir-1.0.1.tgz#ddd800da0c66127393cca5950ea968a3aaf1253b" - integrity sha1-3dgA2gxmEnOTzKWVDqloo6rxJTs= - -concat-map@0.0.1: - version "0.0.1" - resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" - integrity sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg== - -connect@^3.7.0: - version "3.7.0" - resolved "https://registry.yarnpkg.com/connect/-/connect-3.7.0.tgz#5d49348910caa5e07a01800b030d0c35f20484f8" - integrity sha512-ZqRXc+tZukToSNmh5C2iWMSoV3X1YUcPbqEM4DkEG5tNQXrQUZCNVGGv3IuicnkMtPfGf3Xtp8WCXs295iQ1pQ== - dependencies: - debug "2.6.9" - finalhandler "1.1.2" - parseurl "~1.3.3" - utils-merge "1.0.1" - -console-browserify@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/console-browserify/-/console-browserify-1.2.0.tgz#67063cef57ceb6cf4993a2ab3a55840ae8c49336" - integrity sha512-ZMkYO/LkF17QvCPqM0gxw8yUzigAOZOSWSHg91FH6orS7vcEj5dVZTidN2fQ14yBSdg97RqhSNwLUXInd52OTA== - -constants-browserify@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/constants-browserify/-/constants-browserify-1.0.0.tgz#c20b96d8c617748aaf1c16021760cd27fcb8cb75" - integrity sha1-wguW2MYXdIqvHBYCF2DNJ/y4y3U= - -content-type@~1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/content-type/-/content-type-1.0.4.tgz#e138cc75e040c727b1966fe5e5f8c9aee256fe3b" - integrity sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA== - -convert-source-map@^1.7.0: - version "1.7.0" - resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.7.0.tgz#17a2cb882d7f77d3490585e2ce6c524424a3a442" - integrity sha512-4FJkXzKXEDB1snCFZlLP4gpC3JILicCpGbzG9f9G7tGqGCzETQ2hWPrcinA9oU4wtf2biUaEH5065UnMeR33oA== - dependencies: - safe-buffer "~5.1.1" - -convert-source-map@~1.1.0: - version "1.1.3" - resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.1.3.tgz#4829c877e9fe49b3161f3bf3673888e204699860" - integrity sha1-SCnId+n+SbMWHzvzZziI4gRpmGA= - -cookie@~0.4.1: - version "0.4.1" - resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.4.1.tgz#afd713fe26ebd21ba95ceb61f9a8116e50a537d1" - integrity sha512-ZwrFkGJxUR3EIoXtO+yVE69Eb7KlixbaeAWfBQB9vVsNn/o+Yw69gBWSSDK825hQNdN+wF8zELf3dFNl/kxkUA== - -core-js-compat@^3.8.1, core-js-compat@^3.9.0: - version "3.9.1" - resolved "https://registry.yarnpkg.com/core-js-compat/-/core-js-compat-3.9.1.tgz#4e572acfe90aff69d76d8c37759d21a5c59bb455" - integrity sha512-jXAirMQxrkbiiLsCx9bQPJFA6llDadKMpYrBJQJ3/c4/vsPP/fAf29h24tviRlvwUL6AmY5CHLu2GvjuYviQqA== - dependencies: - browserslist "^4.16.3" - semver "7.0.0" - -core-js@^2.6.5: - version "2.6.12" - resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.6.12.tgz#d9333dfa7b065e347cc5682219d6f690859cc2ec" - integrity sha512-Kb2wC0fvsWfQrgk8HU5lW6U/Lcs8+9aaYcy4ZFc6DDlo4nZ7n70dEgE5rtR0oG6ufKDUnrwfWL1mXR5ljDatrQ== - -cors@~2.8.5: - version "2.8.5" - resolved "https://registry.yarnpkg.com/cors/-/cors-2.8.5.tgz#eac11da51592dd86b9f06f6e7ac293b3df875d29" - integrity sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g== - dependencies: - object-assign "^4" - vary "^1" - -create-ecdh@^4.0.0: - version "4.0.4" - resolved "https://registry.yarnpkg.com/create-ecdh/-/create-ecdh-4.0.4.tgz#d6e7f4bffa66736085a0762fd3a632684dabcc4e" - integrity sha512-mf+TCx8wWc9VpuxfP2ht0iSISLZnt0JgWlrOKZiNqyUZWnjIaCIVNQArMHnCZKfEYRg6IM7A+NeJoN8gf/Ws0A== - dependencies: - bn.js "^4.1.0" - elliptic "^6.5.3" - -create-hash@^1.1.0, create-hash@^1.1.2, create-hash@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/create-hash/-/create-hash-1.2.0.tgz#889078af11a63756bcfb59bd221996be3a9ef196" - integrity sha512-z00bCGNHDG8mHAkP7CtT1qVu+bFQUPjYq/4Iv3C3kWjTFV10zIjfSoeqXo9Asws8gwSHDGj/hl2u4OGIjapeCg== - dependencies: - cipher-base "^1.0.1" - inherits "^2.0.1" - md5.js "^1.3.4" - ripemd160 "^2.0.1" - sha.js "^2.4.0" - -create-hmac@^1.1.0, create-hmac@^1.1.4, create-hmac@^1.1.7: - version "1.1.7" - resolved "https://registry.yarnpkg.com/create-hmac/-/create-hmac-1.1.7.tgz#69170c78b3ab957147b2b8b04572e47ead2243ff" - integrity sha512-MJG9liiZ+ogc4TzUwuvbER1JRdgvUFSB5+VR/g5h82fGaIRWMWddtKBHi7/sVhfjQZ6SehlyhvQYrcYkaUIpLg== - dependencies: - cipher-base "^1.0.3" - create-hash "^1.1.0" - inherits "^2.0.1" - ripemd160 "^2.0.0" - safe-buffer "^5.0.1" - sha.js "^2.4.8" - -create-require@^1.1.0: - version "1.1.1" - resolved "https://registry.yarnpkg.com/create-require/-/create-require-1.1.1.tgz#c1d7e8f1e5f6cfc9ff65f9cd352d37348756c333" - integrity sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ== - -cross-spawn@^6.0.5: - version "6.0.5" - resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-6.0.5.tgz#4a5ec7c64dfae22c3a14124dbacdee846d80cbc4" - integrity sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ== - dependencies: - nice-try "^1.0.4" - path-key "^2.0.1" - semver "^5.5.0" - shebang-command "^1.2.0" - which "^1.2.9" - -crypto-browserify@^3.12.0: - version "3.12.0" - resolved "https://registry.yarnpkg.com/crypto-browserify/-/crypto-browserify-3.12.0.tgz#396cf9f3137f03e4b8e532c58f698254e00f80ec" - integrity sha512-fz4spIh+znjO2VjL+IdhEpRJ3YN6sMzITSBijk6FK2UvTqruSQW+/cCZTSNsMiZNvUeq0CqurF+dAbyiGOY6Wg== - dependencies: - browserify-cipher "^1.0.0" - browserify-sign "^4.0.0" - create-ecdh "^4.0.0" - create-hash "^1.1.0" - create-hmac "^1.1.0" - diffie-hellman "^5.0.0" - inherits "^2.0.1" - pbkdf2 "^3.0.3" - public-encrypt "^4.0.0" - randombytes "^2.0.0" - randomfill "^1.0.3" - -custom-event@~1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/custom-event/-/custom-event-1.0.1.tgz#5d02a46850adf1b4a317946a3928fccb5bfd0425" - integrity sha1-XQKkaFCt8bSjF5RqOSj8y1v9BCU= - -date-format@^4.0.3: - version "4.0.3" - resolved "https://registry.yarnpkg.com/date-format/-/date-format-4.0.3.tgz#f63de5dc08dc02efd8ef32bf2a6918e486f35873" - integrity sha512-7P3FyqDcfeznLZp2b+OMitV9Sz2lUnsT87WaTat9nVwqsBkTzPG3lPLNwW3en6F4pHUiWzr6vb8CLhjdK9bcxQ== - -debug@2.6.9: - version "2.6.9" - resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" - integrity sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA== - dependencies: - ms "2.0.0" - -debug@4, debug@^4.1.0, debug@^4.1.1, debug@^4.3.3, debug@~4.3.1, debug@~4.3.2: - version "4.3.4" - resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865" - integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ== - dependencies: - ms "2.1.2" - -debug@^3.1.0: - version "3.2.7" - resolved "https://registry.yarnpkg.com/debug/-/debug-3.2.7.tgz#72580b7e9145fb39b6676f9c5e5fb100b934179a" - integrity sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ== - dependencies: - ms "^2.1.1" - -defaults@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/defaults/-/defaults-1.0.3.tgz#c656051e9817d9ff08ed881477f3fe4019f3ef7d" - integrity sha1-xlYFHpgX2f8I7YgUd/P+QBnz730= - dependencies: - clone "^1.0.2" - -define-properties@^1.1.3: - version "1.1.3" - resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.1.3.tgz#cf88da6cbee26fe6db7094f61d870cbd84cee9f1" - integrity sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ== - dependencies: - object-keys "^1.0.12" - -depd@~1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/depd/-/depd-1.1.2.tgz#9bcd52e14c097763e749b274c4346ed2e560b5a9" - integrity sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak= - -des.js@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/des.js/-/des.js-1.0.1.tgz#5382142e1bdc53f85d86d53e5f4aa7deb91e0843" - integrity sha512-Q0I4pfFrv2VPd34/vfLrFOoRmlYj3OV50i7fskps1jZWK1kApMWWT9G6RRUeYedLcBDIhnSDaUvJMb3AhUlaEA== - dependencies: - inherits "^2.0.1" - minimalistic-assert "^1.0.0" - -detect-indent@^6.0.0: - version "6.0.0" - resolved "https://registry.yarnpkg.com/detect-indent/-/detect-indent-6.0.0.tgz#0abd0f549f69fc6659a254fe96786186b6f528fd" - integrity sha512-oSyFlqaTHCItVRGK5RmrmjB+CmaMOW7IaNA/kdxqhoa6d17j/5ce9O9eWXmV/KEdRwqpQA+Vqe8a8Bsybu4YnA== - -di@^0.0.1: - version "0.0.1" - resolved "https://registry.yarnpkg.com/di/-/di-0.0.1.tgz#806649326ceaa7caa3306d75d985ea2748ba913c" - integrity sha1-gGZJMmzqp8qjMG112YXqJ0i6kTw= - -diff@^4.0.1: - version "4.0.2" - resolved "https://registry.yarnpkg.com/diff/-/diff-4.0.2.tgz#60f3aecb89d5fae520c11aa19efc2bb982aade7d" - integrity sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A== - -diffie-hellman@^5.0.0: - version "5.0.3" - resolved "https://registry.yarnpkg.com/diffie-hellman/-/diffie-hellman-5.0.3.tgz#40e8ee98f55a2149607146921c63e1ae5f3d2875" - integrity sha512-kqag/Nl+f3GwyK25fhUMYj81BUOrZ9IuJsjIcDE5icNM9FJHAVm3VcUDxdLPoQtTuUylWm6ZIknYJwwaPxsUzg== - dependencies: - bn.js "^4.1.0" - miller-rabin "^4.0.0" - randombytes "^2.0.0" - -dom-serialize@^2.2.1: - version "2.2.1" - resolved "https://registry.yarnpkg.com/dom-serialize/-/dom-serialize-2.2.1.tgz#562ae8999f44be5ea3076f5419dcd59eb43ac95b" - integrity sha1-ViromZ9Evl6jB29UGdzVnrQ6yVs= - dependencies: - custom-event "~1.0.0" - ent "~2.2.0" - extend "^3.0.0" - void-elements "^2.0.0" - -domain-browser@^4.16.0: - version "4.19.0" - resolved "https://registry.yarnpkg.com/domain-browser/-/domain-browser-4.19.0.tgz#1093e17c0a17dbd521182fe90d49ac1370054af1" - integrity sha512-fRA+BaAWOR/yr/t7T9E9GJztHPeFjj8U35ajyAjCDtAAnTn1Rc1f6W6VGPJrO1tkQv9zWu+JRof7z6oQtiYVFQ== - -duplexer@~0.1.1: - version "0.1.2" - resolved "https://registry.yarnpkg.com/duplexer/-/duplexer-0.1.2.tgz#3abe43aef3835f8ae077d136ddce0f276b0400e6" - integrity sha512-jtD6YG370ZCIi/9GTaJKQxWTZD045+4R4hTk/x1UyoqadyJ9x9CgSi1RlVDQF8U2sxLLSnFkCaMihqljHIWgMg== - -ee-first@1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d" - integrity sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0= - -electron-to-chromium@^1.3.896: - version "1.3.907" - resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.907.tgz#c8e155a17cb642a1023481c601aa3ad9ee61f402" - integrity "sha1-yOFVoXy2QqECNIHGAao62e5h9AI= sha512-xoUPSkjimw51d9ryeH38XUwmR3HmCA+eky4hk0YEgsWeBWGyhb35OCvT3lWAdmvIkcGYCRNOB8LvtO00dJQpOA==" - -elliptic@^6.5.3: - version "6.5.4" - resolved "https://registry.yarnpkg.com/elliptic/-/elliptic-6.5.4.tgz#da37cebd31e79a1367e941b592ed1fbebd58abbb" - integrity sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ== - dependencies: - bn.js "^4.11.9" - brorand "^1.1.0" - hash.js "^1.0.0" - hmac-drbg "^1.0.1" - inherits "^2.0.4" - minimalistic-assert "^1.0.1" - minimalistic-crypto-utils "^1.0.1" - -emoji-regex@^8.0.0: - version "8.0.0" - resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37" - integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A== - -encodeurl@~1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/encodeurl/-/encodeurl-1.0.2.tgz#ad3ff4c86ec2d029322f5a02c3a9a606c95b3f59" - integrity sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k= - -engine.io-parser@~5.0.3: - version "5.0.4" - resolved "https://registry.yarnpkg.com/engine.io-parser/-/engine.io-parser-5.0.4.tgz#0b13f704fa9271b3ec4f33112410d8f3f41d0fc0" - integrity sha512-+nVFp+5z1E3HcToEnO7ZIj3g+3k9389DvWtvJZz0T6/eOCPIyyxehFcedoYrZQrp0LgQbD9pPXhpMBKMd5QURg== - -engine.io@~6.2.0: - version "6.2.0" - resolved "https://registry.yarnpkg.com/engine.io/-/engine.io-6.2.0.tgz#003bec48f6815926f2b1b17873e576acd54f41d0" - integrity sha512-4KzwW3F3bk+KlzSOY57fj/Jx6LyRQ1nbcyIadehl+AnXjKT7gDO0ORdRi/84ixvMKTym6ZKuxvbzN62HDDU1Lg== - dependencies: - "@types/cookie" "^0.4.1" - "@types/cors" "^2.8.12" - "@types/node" ">=10.0.0" - accepts "~1.3.4" - base64id "2.0.0" - cookie "~0.4.1" - cors "~2.8.5" - debug "~4.3.1" - engine.io-parser "~5.0.3" - ws "~8.2.3" - -ent@~2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/ent/-/ent-2.2.0.tgz#e964219325a21d05f44466a2f686ed6ce5f5dd1d" - integrity sha1-6WQhkyWiHQX0RGai9obtbOX13R0= - -error-ex@^1.3.1: - version "1.3.2" - resolved "https://registry.yarnpkg.com/error-ex/-/error-ex-1.3.2.tgz#b4ac40648107fdcdcfae242f428bea8a14d4f1bf" - integrity sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g== - dependencies: - is-arrayish "^0.2.1" - -es-abstract@^1.18.0-next.1, es-abstract@^1.18.0-next.2: - version "1.18.0" - resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.18.0.tgz#ab80b359eecb7ede4c298000390bc5ac3ec7b5a4" - integrity sha512-LJzK7MrQa8TS0ja2w3YNLzUgJCGPdPOV1yVvezjNnS89D+VR08+Szt2mz3YB2Dck/+w5tfIq/RoUAFqJJGM2yw== - dependencies: - call-bind "^1.0.2" - es-to-primitive "^1.2.1" - function-bind "^1.1.1" - get-intrinsic "^1.1.1" - has "^1.0.3" - has-symbols "^1.0.2" - is-callable "^1.2.3" - is-negative-zero "^2.0.1" - is-regex "^1.1.2" - is-string "^1.0.5" - object-inspect "^1.9.0" - object-keys "^1.1.1" - object.assign "^4.1.2" - string.prototype.trimend "^1.0.4" - string.prototype.trimstart "^1.0.4" - unbox-primitive "^1.0.0" - -es-to-primitive@^1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/es-to-primitive/-/es-to-primitive-1.2.1.tgz#e55cd4c9cdc188bcefb03b366c736323fc5c898a" - integrity sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA== - dependencies: - is-callable "^1.1.4" - is-date-object "^1.0.1" - is-symbol "^1.0.2" - -es6-object-assign@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/es6-object-assign/-/es6-object-assign-1.1.0.tgz#c2c3582656247c39ea107cb1e6652b6f9f24523c" - integrity sha1-wsNYJlYkfDnqEHyx5mUrb58kUjw= - -es6-promise@^4.0.3: - version "4.2.8" - resolved "https://registry.yarnpkg.com/es6-promise/-/es6-promise-4.2.8.tgz#4eb21594c972bc40553d276e510539143db53e0a" - integrity sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w== - -es6-promisify@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/es6-promisify/-/es6-promisify-5.0.0.tgz#5109d62f3e56ea967c4b63505aef08291c8a5203" - integrity sha1-UQnWLz5W6pZ8S2NQWu8IKRyKUgM= - dependencies: - es6-promise "^4.0.3" - -escalade@^3.1.1: - version "3.1.1" - resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.1.1.tgz#d8cfdc7000965c5a0174b4a82eaa5c0552742e40" - integrity sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw== - -escape-html@~1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/escape-html/-/escape-html-1.0.3.tgz#0258eae4d3d0c0974de1c169188ef0051d1d1988" - integrity sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg= - -escape-string-regexp@^1.0.5: - version "1.0.5" - resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" - integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ= - -esprima@^4.0.0: - version "4.0.1" - resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71" - integrity sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A== - -estree-walker@^0.6.1: - version "0.6.1" - resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-0.6.1.tgz#53049143f40c6eb918b23671d1fe3219f3a1b362" - integrity sha512-SqmZANLWS0mnatqbSfRP5g8OXZC12Fgg1IwNtLsyHDzJizORW4khDfjPqJZsemPWBB2uqykUah5YpQ6epsqC/w== - -estree-walker@^2.0.1: - version "2.0.2" - resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-2.0.2.tgz#52f010178c2a4c117a7757cfe942adb7d2da4cac" - integrity sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w== - -esutils@^2.0.2: - version "2.0.3" - resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.3.tgz#74d2eb4de0b8da1293711910d50775b9b710ef64" - integrity sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g== - -event-stream@=3.3.4: - version "3.3.4" - resolved "https://registry.yarnpkg.com/event-stream/-/event-stream-3.3.4.tgz#4ab4c9a0f5a54db9338b4c34d86bfce8f4b35571" - integrity sha1-SrTJoPWlTbkzi0w02Gv86PSzVXE= - dependencies: - duplexer "~0.1.1" - from "~0" - map-stream "~0.1.0" - pause-stream "0.0.11" - split "0.3" - stream-combiner "~0.0.4" - through "~2.3.1" - -eventemitter3@^4.0.0: - version "4.0.7" - resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-4.0.7.tgz#2de9b68f6528d5644ef5c59526a1b4a07306169f" - integrity sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw== - -events@^3.2.0: - version "3.3.0" - resolved "https://registry.yarnpkg.com/events/-/events-3.3.0.tgz#31a95ad0a924e2d2c419a813aeb2c4e878ea7400" - integrity sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q== - -evp_bytestokey@^1.0.0, evp_bytestokey@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/evp_bytestokey/-/evp_bytestokey-1.0.3.tgz#7fcbdb198dc71959432efe13842684e0525acb02" - integrity sha512-/f2Go4TognH/KvCISP7OUsHn85hT9nUkxxA9BEWxFn+Oj9o8ZNLm/40hdlgSLyuOimsrTKLUMEorQexp/aPQeA== - dependencies: - md5.js "^1.3.4" - safe-buffer "^5.1.1" - -extend@^3.0.0: - version "3.0.2" - resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.2.tgz#f8b1136b4071fbd8eb140aff858b1019ec2915fa" - integrity sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g== - -fill-range@^7.0.1: - version "7.0.1" - resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.0.1.tgz#1919a6a7c75fe38b2c7c77e5198535da9acdda40" - integrity sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ== - dependencies: - to-regex-range "^5.0.1" - -finalhandler@1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/finalhandler/-/finalhandler-1.1.2.tgz#b7e7d000ffd11938d0fdb053506f6ebabe9f587d" - integrity sha512-aAWcW57uxVNrQZqFXjITpW3sIUQmHGG3qSb9mUah9MgMC4NeWhNOlNjXEYq3HjRAvL6arUviZGGJsBg6z0zsWA== - dependencies: - debug "2.6.9" - encodeurl "~1.0.2" - escape-html "~1.0.3" - on-finished "~2.3.0" - parseurl "~1.3.3" - statuses "~1.5.0" - unpipe "~1.0.0" - -find-cache-dir@^3.3.2: - version "3.3.2" - resolved "https://registry.yarnpkg.com/find-cache-dir/-/find-cache-dir-3.3.2.tgz#b30c5b6eff0730731aea9bbd9dbecbd80256d64b" - integrity sha512-wXZV5emFEjrridIgED11OoUKLxiYjAcqot/NJdAkOhlJ+vGzwhOAfcG5OX1jP+S0PcjEn8bdMJv+g2jwQ3Onig== - dependencies: - commondir "^1.0.1" - make-dir "^3.0.2" - pkg-dir "^4.1.0" - -find-up@^4.0.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/find-up/-/find-up-4.1.0.tgz#97afe7d6cdc0bc5928584b7c8d7b16e8a9aa5d19" - integrity sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw== - dependencies: - locate-path "^5.0.0" - path-exists "^4.0.0" - -flatted@^3.2.4: - version "3.2.4" - resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.2.4.tgz#28d9969ea90661b5134259f312ab6aa7929ac5e2" - integrity sha512-8/sOawo8tJ4QOBX8YlQBMxL8+RLZfxMQOif9o0KUKTNTjMYElWPE0r/m5VNFxTRd0NSw8qSy8dajrwX4RYI1Hw== - -follow-redirects@^1.0.0: - version "1.14.8" - resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.8.tgz#016996fb9a11a100566398b1c6839337d7bfa8fc" - integrity sha512-1x0S9UVJHsQprFcEC/qnNzBLcIxsjAV905f/UkQxbclCsoTWlacCNOpQa/anodLl2uaEKFhfWOvM2Qg77+15zA== - -foreach@^2.0.5: - version "2.0.5" - resolved "https://registry.yarnpkg.com/foreach/-/foreach-2.0.5.tgz#0bee005018aeb260d0a3af3ae658dd0136ec1b99" - integrity sha1-C+4AUBiusmDQo6865ljdATbsG5k= - -from@~0: - version "0.1.7" - resolved "https://registry.yarnpkg.com/from/-/from-0.1.7.tgz#83c60afc58b9c56997007ed1a768b3ab303a44fe" - integrity sha1-g8YK/Fi5xWmXAH7Rp2izqzA6RP4= - -fs-extra@^10.0.0: - version "10.0.0" - resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-10.0.0.tgz#9ff61b655dde53fb34a82df84bb214ce802e17c1" - integrity sha512-C5owb14u9eJwizKGdchcDUQeFtlSHHthBk8pbX9Vc1PFZrLombudjDnNns88aYslCyF6IY5SUw3Roz6xShcEIQ== - dependencies: - graceful-fs "^4.2.0" - jsonfile "^6.0.1" - universalify "^2.0.0" - -fs-extra@^8.0.1: - version "8.1.0" - resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-8.1.0.tgz#49d43c45a88cd9677668cb7be1b46efdb8d2e1c0" - integrity sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g== - dependencies: - graceful-fs "^4.2.0" - jsonfile "^4.0.0" - universalify "^0.1.0" - -fs.realpath@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" - integrity sha1-FQStJSMVjKpA20onh8sBQRmU6k8= - -fsevents@~2.3.2: - version "2.3.2" - resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a" - integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA== - -function-bind@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d" - integrity sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A== - -gensync@^1.0.0-beta.2: - version "1.0.0-beta.2" - resolved "https://registry.yarnpkg.com/gensync/-/gensync-1.0.0-beta.2.tgz#32a6ee76c3d7f52d46b2b1ae5d93fea8580a25e0" - integrity sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg== - -get-caller-file@^2.0.5: - version "2.0.5" - resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e" - integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg== - -get-intrinsic@^1.0.2, get-intrinsic@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/get-intrinsic/-/get-intrinsic-1.1.1.tgz#15f59f376f855c446963948f0d24cd3637b4abc6" - integrity sha512-kWZrnVM42QCiEA2Ig1bG8zjoIMOgxWwYCEeNdwY6Tv/cOSeGpcoX4pXHfKUxNKVoArnrEr2e9srnAxxGIraS9Q== - dependencies: - function-bind "^1.1.1" - has "^1.0.3" - has-symbols "^1.0.1" - -glob-parent@~5.1.2: - version "5.1.2" - resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4" - integrity sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow== - dependencies: - is-glob "^4.0.1" - -glob@^7.0.0, glob@^7.0.5, glob@^7.1.1, glob@^7.1.3, glob@^7.1.4, glob@^7.1.6, glob@^7.1.7: - version "7.2.0" - resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.0.tgz#d15535af7732e02e948f4c41628bd910293f6023" - integrity sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q== - dependencies: - fs.realpath "^1.0.0" - inflight "^1.0.4" - inherits "2" - minimatch "^3.0.4" - once "^1.3.0" - path-is-absolute "^1.0.0" - -globals@^11.1.0: - version "11.12.0" - resolved "https://registry.yarnpkg.com/globals/-/globals-11.12.0.tgz#ab8795338868a0babd8525758018c2a7eb95c42e" - integrity sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA== - -graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.2.0, graceful-fs@^4.2.6: - version "4.2.9" - resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.9.tgz#041b05df45755e587a24942279b9d113146e1c96" - integrity sha512-NtNxqUcXgpW2iMrfqSfR73Glt39K+BLwWsPs94yR63v45T0Wbej7eRmL5cWfwEgqXnmjQp3zaJTshdRW/qC2ZQ== - -has-bigints@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/has-bigints/-/has-bigints-1.0.1.tgz#64fe6acb020673e3b78db035a5af69aa9d07b113" - integrity sha512-LSBS2LjbNBTf6287JEbEzvJgftkF5qFkmCo9hDRpAzKhUOlJ+hx8dd4USs00SgsUNwc4617J9ki5YtEClM2ffA== - -has-flag@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd" - integrity sha1-tdRU3CGZriJWmfNGfloH87lVuv0= - -has-flag@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b" - integrity sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ== - -has-symbols@^1.0.1, has-symbols@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/has-symbols/-/has-symbols-1.0.2.tgz#165d3070c00309752a1236a479331e3ac56f1423" - integrity sha512-chXa79rL/UC2KlX17jo3vRGz0azaWEx5tGqZg5pO3NUyEJVB17dMruQlzCCOfUvElghKcm5194+BCRvi2Rv/Gw== - -has@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/has/-/has-1.0.3.tgz#722d7cbfc1f6aa8241f16dd814e011e1f41e8796" - integrity sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw== - dependencies: - function-bind "^1.1.1" - -hash-base@^3.0.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/hash-base/-/hash-base-3.1.0.tgz#55c381d9e06e1d2997a883b4a3fddfe7f0d3af33" - integrity sha512-1nmYp/rhMDiE7AYkDw+lLwlAzz0AntGIe51F3RfFfEqyQ3feY2eI/NcwC6umIQVOASPMsWJLJScWKSSvzL9IVA== - dependencies: - inherits "^2.0.4" - readable-stream "^3.6.0" - safe-buffer "^5.2.0" - -hash.js@^1.0.0, hash.js@^1.0.3: - version "1.1.7" - resolved "https://registry.yarnpkg.com/hash.js/-/hash.js-1.1.7.tgz#0babca538e8d4ee4a0f8988d68866537a003cf42" - integrity sha512-taOaskGt4z4SOANNseOviYDvjEJinIkRgmp7LbKP2YTTmVxWBl87s/uzK9r+44BclBSp2X7K1hqeNfz9JbBeXA== - dependencies: - inherits "^2.0.3" - minimalistic-assert "^1.0.1" - -hmac-drbg@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/hmac-drbg/-/hmac-drbg-1.0.1.tgz#d2745701025a6c775a6c545793ed502fc0c649a1" - integrity sha1-0nRXAQJabHdabFRXk+1QL8DGSaE= - dependencies: - hash.js "^1.0.3" - minimalistic-assert "^1.0.0" - minimalistic-crypto-utils "^1.0.1" - -hosted-git-info@^2.1.4: - version "2.8.9" - resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.8.9.tgz#dffc0bf9a21c02209090f2aa69429e1414daf3f9" - integrity sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw== - -html-escaper@^2.0.0: - version "2.0.2" - resolved "https://registry.yarnpkg.com/html-escaper/-/html-escaper-2.0.2.tgz#dfd60027da36a36dfcbe236262c00a5822681453" - integrity sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg== - -http-errors@1.7.2: - version "1.7.2" - resolved "https://registry.yarnpkg.com/http-errors/-/http-errors-1.7.2.tgz#4f5029cf13239f31036e5b2e55292bcfbcc85c8f" - integrity sha512-uUQBt3H/cSIVfch6i1EuPNy/YsRSOUBXTVfZ+yR7Zjez3qjBz6i9+i4zjNaoqcoFVI4lQJ5plg63TvGfRSDCRg== - dependencies: - depd "~1.1.2" - inherits "2.0.3" - setprototypeof "1.1.1" - statuses ">= 1.5.0 < 2" - toidentifier "1.0.0" - -http-proxy@^1.18.1: - version "1.18.1" - resolved "https://registry.yarnpkg.com/http-proxy/-/http-proxy-1.18.1.tgz#401541f0534884bbf95260334e72f88ee3976549" - integrity sha512-7mz/721AbnJwIVbnaSv1Cz3Am0ZLT/UBwkC92VlxhXv/k/BBQfM2fXElQNC27BVGr0uwUpplYPQM9LnaBMR5NQ== - dependencies: - eventemitter3 "^4.0.0" - follow-redirects "^1.0.0" - requires-port "^1.0.0" - -https-browserify@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/https-browserify/-/https-browserify-1.0.0.tgz#ec06c10e0a34c0f2faf199f7fd7fc78fffd03c73" - integrity sha1-7AbBDgo0wPL68Zn3/X/Hj//QPHM= - -https-proxy-agent@^2.2.1: - version "2.2.4" - resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-2.2.4.tgz#4ee7a737abd92678a293d9b34a1af4d0d08c787b" - integrity sha512-OmvfoQ53WLjtA9HeYP9RNrWMJzzAz1JGaSFr1nijg0PVR1JaD/xbJq1mdEIIlxGpXp9eSe/O2LgU9DJmTPd0Eg== - dependencies: - agent-base "^4.3.0" - debug "^3.1.0" - -https-proxy-agent@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-4.0.0.tgz#702b71fb5520a132a66de1f67541d9e62154d82b" - integrity sha512-zoDhWrkR3of1l9QAL8/scJZyLu8j/gBkcwcaQOZh7Gyh/+uJQzGVETdgT30akuwkpL8HTRfssqI3BZuV18teDg== - dependencies: - agent-base "5" - debug "4" - -iconv-lite@0.4.24: - version "0.4.24" - resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.24.tgz#2022b4b25fbddc21d2f524974a474aafe733908b" - integrity sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA== - dependencies: - safer-buffer ">= 2.1.2 < 3" - -ieee754@^1.1.13: - version "1.2.1" - resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.2.1.tgz#8eb7a10a63fff25d15a57b001586d177d1b0d352" - integrity sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA== - -ignore-walk@^3.0.3: - version "3.0.4" - resolved "https://registry.yarnpkg.com/ignore-walk/-/ignore-walk-3.0.4.tgz#c9a09f69b7c7b479a5d74ac1a3c0d4236d2a6335" - integrity sha512-PY6Ii8o1jMRA1z4F2hRkH/xN59ox43DavKvD3oDpfurRlOJyAHpifIwpbdv1n4jt4ov0jSpw3kQ4GhJnpBL6WQ== - dependencies: - minimatch "^3.0.4" - -ignore@^5.0.4: - version "5.1.8" - resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.1.8.tgz#f150a8b50a34289b33e22f5889abd4d8016f0e57" - integrity sha512-BMpfD7PpiETpBl/A6S498BaIJ6Y/ABT93ETbby2fP00v4EbvPBXWEoaR1UBPKs3iR53pJY7EtZk5KACI57i1Uw== - -inflight@^1.0.4: - version "1.0.6" - resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" - integrity sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk= - dependencies: - once "^1.3.0" - wrappy "1" - -inherits@2, inherits@^2.0.1, inherits@^2.0.3, inherits@^2.0.4, inherits@~2.0.4: - version "2.0.4" - resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" - integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== - -inherits@2.0.3: - version "2.0.3" - resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" - integrity sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4= - -ini@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/ini/-/ini-2.0.0.tgz#e5fd556ecdd5726be978fa1001862eacb0a94bc5" - integrity sha512-7PnF4oN3CvZF23ADhA5wRaYEQpJ8qygSkbtTXWBeXWXmEVRXK+1ITciHWwHhsjv1TmW0MgacIv6hEi5pX5NQdA== - -inline-source-map@~0.6.0: - version "0.6.2" - resolved "https://registry.yarnpkg.com/inline-source-map/-/inline-source-map-0.6.2.tgz#f9393471c18a79d1724f863fa38b586370ade2a5" - integrity sha1-+Tk0ccGKedFyT4Y/o4tYY3Ct4qU= - dependencies: - source-map "~0.5.3" - -is-arguments@^1.0.4: - version "1.1.0" - resolved "https://registry.yarnpkg.com/is-arguments/-/is-arguments-1.1.0.tgz#62353031dfbee07ceb34656a6bde59efecae8dd9" - integrity sha512-1Ij4lOMPl/xB5kBDn7I+b2ttPMKa8szhEIrXDuXQD/oe3HJLTLhqhgGspwgyGd6MOywBUqVvYicF72lkgDnIHg== - dependencies: - call-bind "^1.0.0" - -is-arrayish@^0.2.1: - version "0.2.1" - resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.2.1.tgz#77c99840527aa8ecb1a8ba697b80645a7a926a9d" - integrity sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0= - -is-bigint@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/is-bigint/-/is-bigint-1.0.1.tgz#6923051dfcbc764278540b9ce0e6b3213aa5ebc2" - integrity sha512-J0ELF4yHFxHy0cmSxZuheDOz2luOdVvqjwmEcj8H/L1JHeuEDSDbeRP+Dk9kFVk5RTFzbucJ2Kb9F7ixY2QaCg== - -is-binary-path@~2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/is-binary-path/-/is-binary-path-2.1.0.tgz#ea1f7f3b80f064236e83470f86c09c254fb45b09" - integrity sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw== - dependencies: - binary-extensions "^2.0.0" - -is-boolean-object@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/is-boolean-object/-/is-boolean-object-1.1.0.tgz#e2aaad3a3a8fca34c28f6eee135b156ed2587ff0" - integrity sha512-a7Uprx8UtD+HWdyYwnD1+ExtTgqQtD2k/1yJgtXP6wnMm8byhkoTZRl+95LLThpzNZJ5aEvi46cdH+ayMFRwmA== - dependencies: - call-bind "^1.0.0" - -is-callable@^1.1.4, is-callable@^1.2.3: - version "1.2.3" - resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.2.3.tgz#8b1e0500b73a1d76c70487636f368e519de8db8e" - integrity sha512-J1DcMe8UYTBSrKezuIUTUwjXsho29693unXM2YhJUTR2txK/eG47bvNa/wipPFmZFgr/N6f1GA66dv0mEyTIyQ== - -is-core-module@^2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.2.0.tgz#97037ef3d52224d85163f5597b2b63d9afed981a" - integrity sha512-XRAfAdyyY5F5cOXn7hYQDqh2Xmii+DEfIcQGxK/uNwMHhIkPWO0g8msXcbzLe+MpGoR951MlqM/2iIlU4vKDdQ== - dependencies: - has "^1.0.3" - -is-core-module@^2.9.0: - version "2.9.0" - resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.9.0.tgz#e1c34429cd51c6dd9e09e0799e396e27b19a9c69" - integrity sha512-+5FPy5PnwmO3lvfMb0AsoPaBG+5KHUI0wYFXOtYPnVVVspTFUuMZNfNaNVRt3FZadstu2c8x23vykRW/NBoU6A== - dependencies: - has "^1.0.3" - -is-date-object@^1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/is-date-object/-/is-date-object-1.0.2.tgz#bda736f2cd8fd06d32844e7743bfa7494c3bfd7e" - integrity sha512-USlDT524woQ08aoZFzh3/Z6ch9Y/EWXEHQ/AaRN0SkKq4t2Jw2R2339tSXmwuVoY7LLlBCbOIlx2myP/L5zk0g== - -is-docker@^2.0.0: - version "2.2.1" - resolved "https://registry.yarnpkg.com/is-docker/-/is-docker-2.2.1.tgz#33eeabe23cfe86f14bde4408a02c0cfb853acdaa" - integrity sha512-F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ== - -is-extglob@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2" - integrity sha1-qIwCU1eR8C7TfHahueqXc8gz+MI= - -is-fullwidth-code-point@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz#f116f8064fe90b3f7844a38997c0b75051269f1d" - integrity sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg== - -is-generator-function@^1.0.7: - version "1.0.8" - resolved "https://registry.yarnpkg.com/is-generator-function/-/is-generator-function-1.0.8.tgz#dfb5c2b120e02b0a8d9d2c6806cd5621aa922f7b" - integrity sha512-2Omr/twNtufVZFr1GhxjOMFPAj2sjc/dKaIqBhvo4qciXfJmITGH6ZGd8eZYNHza8t1y0e01AuqRhJwfWp26WQ== - -is-glob@^4.0.1, is-glob@~4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.1.tgz#7567dbe9f2f5e2467bc77ab83c4a29482407a5dc" - integrity sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg== - dependencies: - is-extglob "^2.1.1" - -is-module@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/is-module/-/is-module-1.0.0.tgz#3258fb69f78c14d5b815d664336b4cffb6441591" - integrity sha1-Mlj7afeMFNW4FdZkM2tM/7ZEFZE= - -is-nan@^1.2.1: - version "1.3.2" - resolved "https://registry.yarnpkg.com/is-nan/-/is-nan-1.3.2.tgz#043a54adea31748b55b6cd4e09aadafa69bd9e1d" - integrity sha512-E+zBKpQ2t6MEo1VsonYmluk9NxGrbzpeeLC2xIViuO2EjU2xsXsBPwTr3Ykv9l08UYEVEdWeRZNouaZqF6RN0w== - dependencies: - call-bind "^1.0.0" - define-properties "^1.1.3" - -is-negative-zero@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/is-negative-zero/-/is-negative-zero-2.0.1.tgz#3de746c18dda2319241a53675908d8f766f11c24" - integrity sha512-2z6JzQvZRa9A2Y7xC6dQQm4FSTSTNWjKIYYTt4246eMTJmIo0Q+ZyOsU66X8lxK1AbB92dFeglPLrhwpeRKO6w== - -is-number-object@^1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/is-number-object/-/is-number-object-1.0.4.tgz#36ac95e741cf18b283fc1ddf5e83da798e3ec197" - integrity sha512-zohwelOAur+5uXtk8O3GPQ1eAcu4ZX3UwxQhUlfFFMNpUd83gXgjbhJh6HmB6LUNV/ieOLQuDwJO3dWJosUeMw== - -is-number@^7.0.0: - version "7.0.0" - resolved "https://registry.yarnpkg.com/is-number/-/is-number-7.0.0.tgz#7535345b896734d5f80c4d06c50955527a14f12b" - integrity sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng== - -is-reference@^1.1.2: - version "1.2.1" - resolved "https://registry.yarnpkg.com/is-reference/-/is-reference-1.2.1.tgz#8b2dac0b371f4bc994fdeaba9eb542d03002d0b7" - integrity sha512-U82MsXXiFIrjCK4otLT+o2NA2Cd2g5MLoOVXUZjIOhLurrRxpEXzI8O0KZHr3IjLvlAH1kTPYSuqer5T9ZVBKQ== - dependencies: - "@types/estree" "*" - -is-regex@^1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/is-regex/-/is-regex-1.1.2.tgz#81c8ebde4db142f2cf1c53fc86d6a45788266251" - integrity sha512-axvdhb5pdhEVThqJzYXwMlVuZwC+FF2DpcOhTS+y/8jVq4trxyPgfcwIxIKiyeuLlSQYKkmUaPQJ8ZE4yNKXDg== - dependencies: - call-bind "^1.0.2" - has-symbols "^1.0.1" - -is-running@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/is-running/-/is-running-2.1.0.tgz#30a73ff5cc3854e4fc25490809e9f5abf8de09e0" - integrity sha1-MKc/9cw4VOT8JUkICen1q/jeCeA= - -is-string@^1.0.5: - version "1.0.5" - resolved "https://registry.yarnpkg.com/is-string/-/is-string-1.0.5.tgz#40493ed198ef3ff477b8c7f92f644ec82a5cd3a6" - integrity sha512-buY6VNRjhQMiF1qWDouloZlQbRhDPCebwxSjxMjxgemYT46YMd2NR0/H+fBhEfWX4A/w9TBJ+ol+okqJKFE6vQ== - -is-symbol@^1.0.2, is-symbol@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/is-symbol/-/is-symbol-1.0.3.tgz#38e1014b9e6329be0de9d24a414fd7441ec61937" - integrity sha512-OwijhaRSgqvhm/0ZdAcXNZt9lYdKFpcRDT5ULUuYXPoT794UNOdU+gpT6Rzo7b4V2HUl/op6GqY894AZwv9faQ== - dependencies: - has-symbols "^1.0.1" - -is-typed-array@^1.1.3: - version "1.1.5" - resolved "https://registry.yarnpkg.com/is-typed-array/-/is-typed-array-1.1.5.tgz#f32e6e096455e329eb7b423862456aa213f0eb4e" - integrity sha512-S+GRDgJlR3PyEbsX/Fobd9cqpZBuvUS+8asRqYDMLCb2qMzt1oz5m5oxQCxOgUDxiWsOVNi4yaF+/uvdlHlYug== - dependencies: - available-typed-arrays "^1.0.2" - call-bind "^1.0.2" - es-abstract "^1.18.0-next.2" - foreach "^2.0.5" - has-symbols "^1.0.1" - -is-wsl@^2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/is-wsl/-/is-wsl-2.2.0.tgz#74a4c76e77ca9fd3f932f290c17ea326cd157271" - integrity sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww== - dependencies: - is-docker "^2.0.0" - -isbinaryfile@^4.0.8: - version "4.0.8" - resolved "https://registry.yarnpkg.com/isbinaryfile/-/isbinaryfile-4.0.8.tgz#5d34b94865bd4946633ecc78a026fc76c5b11fcf" - integrity sha512-53h6XFniq77YdW+spoRrebh0mnmTxRPTlcuIArO57lmMdq4uBKFKaeTjnb92oYWrSn/LVL+LT+Hap2tFQj8V+w== - -isexe@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" - integrity sha1-6PvzdNxVb/iUehDcsFctYz8s+hA= - -istanbul-lib-coverage@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/istanbul-lib-coverage/-/istanbul-lib-coverage-3.0.0.tgz#f5944a37c70b550b02a78a5c3b2055b280cec8ec" - integrity sha512-UiUIqxMgRDET6eR+o5HbfRYP1l0hqkWOs7vNxC/mggutCMUIhWMm8gAHb8tHlyfD3/l6rlgNA5cKdDzEAf6hEg== - -istanbul-lib-instrument@^4.0.0: - version "4.0.3" - resolved "https://registry.yarnpkg.com/istanbul-lib-instrument/-/istanbul-lib-instrument-4.0.3.tgz#873c6fff897450118222774696a3f28902d77c1d" - integrity sha512-BXgQl9kf4WTCPCCpmFGoJkz/+uhvm7h7PFKUYxh7qarQd3ER33vHG//qaE8eN25l07YqZPpHXU9I09l/RD5aGQ== - dependencies: - "@babel/core" "^7.7.5" - "@istanbuljs/schema" "^0.1.2" - istanbul-lib-coverage "^3.0.0" - semver "^6.3.0" - -istanbul-lib-report@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/istanbul-lib-report/-/istanbul-lib-report-3.0.0.tgz#7518fe52ea44de372f460a76b5ecda9ffb73d8a6" - integrity sha512-wcdi+uAKzfiGT2abPpKZ0hSU1rGQjUQnLvtY5MpQ7QCTahD3VODhcu4wcfY1YtkGaDD5yuydOLINXsfbus9ROw== - dependencies: - istanbul-lib-coverage "^3.0.0" - make-dir "^3.0.0" - supports-color "^7.1.0" - -istanbul-lib-source-maps@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/istanbul-lib-source-maps/-/istanbul-lib-source-maps-4.0.0.tgz#75743ce6d96bb86dc7ee4352cf6366a23f0b1ad9" - integrity sha512-c16LpFRkR8vQXyHZ5nLpY35JZtzj1PQY1iZmesUbf1FZHbIupcWfjgOXBY9YHkLEQ6puz1u4Dgj6qmU/DisrZg== - dependencies: - debug "^4.1.1" - istanbul-lib-coverage "^3.0.0" - source-map "^0.6.1" - -istanbul-reports@^3.0.0: - version "3.0.2" - resolved "https://registry.yarnpkg.com/istanbul-reports/-/istanbul-reports-3.0.2.tgz#d593210e5000683750cb09fc0644e4b6e27fd53b" - integrity sha512-9tZvz7AiR3PEDNGiV9vIouQ/EAcqMXFmkcA1CDFTwOB98OZVDL0PH9glHotf5Ugp6GCOTypfzGWI/OqjWNCRUw== - dependencies: - html-escaper "^2.0.0" - istanbul-lib-report "^3.0.0" - -jasmine-core@^4.1.0, jasmine-core@^4.5.0, jasmine-core@~4.5.0: - version "4.5.0" - resolved "https://registry.yarnpkg.com/jasmine-core/-/jasmine-core-4.5.0.tgz#1a6bd0bde3f60996164311c88a0995d67ceda7c3" - integrity sha512-9PMzyvhtocxb3aXJVOPqBDswdgyAeSB81QnLop4npOpbqnheaTEwPc9ZloQeVswugPManznQBjD8kWDTjlnHuw== - -jasmine@4.5.0: - version "4.5.0" - resolved "https://registry.yarnpkg.com/jasmine/-/jasmine-4.5.0.tgz#8d3c0d0a33a61e4d05c9f9747ee5dfaf6f7b5d3d" - integrity sha512-9olGRvNZyADIwYL9XBNBst5BTU/YaePzuddK+YRslc7rI9MdTIE4r3xaBKbv2GEmzYYUfMOdTR8/i6JfLZaxSQ== - dependencies: - glob "^7.1.6" - jasmine-core "^4.5.0" - -jest-worker@^24.0.0: - version "24.9.0" - resolved "https://registry.yarnpkg.com/jest-worker/-/jest-worker-24.9.0.tgz#5dbfdb5b2d322e98567898238a9697bcce67b3e5" - integrity sha512-51PE4haMSXcHohnSMdM42anbvZANYTqMrr52tVKPqqsPJMzoP6FYYDVqahX/HrAoKEKz3uUPzSvKs9A3qR4iVw== - dependencies: - merge-stream "^2.0.0" - supports-color "^6.1.0" - -jest-worker@^26.2.1: - version "26.6.2" - resolved "https://registry.yarnpkg.com/jest-worker/-/jest-worker-26.6.2.tgz#7f72cbc4d643c365e27b9fd775f9d0eaa9c7a8ed" - integrity sha512-KWYVV1c4i+jbMpaBC+U++4Va0cp8OisU185o73T1vo99hqi7w8tSJfUXYswwqqrjzwxa6KpRK54WhPvwf5w6PQ== - dependencies: - "@types/node" "*" - merge-stream "^2.0.0" - supports-color "^7.0.0" - -js-tokens@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" - integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ== - -js-yaml@^3.13.1: - version "3.14.1" - resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.14.1.tgz#dae812fdb3825fa306609a8717383c50c36a0537" - integrity sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g== - dependencies: - argparse "^1.0.7" - esprima "^4.0.0" - -jsesc@^2.5.1: - version "2.5.2" - resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-2.5.2.tgz#80564d2e483dacf6e8ef209650a67df3f0c283a4" - integrity sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA== - -jsesc@~0.5.0: - version "0.5.0" - resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-0.5.0.tgz#e7dee66e35d6fc16f710fe91d5cf69f70f08911d" - integrity sha1-597mbjXW/Bb3EP6R1c9p9w8IkR0= - -json-parse-better-errors@^1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz#bb867cfb3450e69107c131d1c514bab3dc8bcaa9" - integrity sha512-mrqyZKfX5EhL7hvqcV6WG1yYjnjeuYDzDhhcAAUrq8Po85NBQBJP+ZDUT75qZQ98IkUoBqdkExkukOU7Ts2wrw== - -json-stringify-safe@^5.0.1: - version "5.0.1" - resolved "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb" - integrity sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus= - -json5@^2.1.2: - version "2.2.3" - resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.3.tgz#78cd6f1a19bdc12b73db5ad0c61efd66c1e29283" - integrity sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg== - -jsonfile@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-4.0.0.tgz#8771aae0799b64076b76640fca058f9c10e33ecb" - integrity sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss= - optionalDependencies: - graceful-fs "^4.1.6" - -jsonfile@^6.0.1: - version "6.1.0" - resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-6.1.0.tgz#bc55b2634793c679ec6403094eb13698a6ec0aae" - integrity sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ== - dependencies: - universalify "^2.0.0" - optionalDependencies: - graceful-fs "^4.1.6" - -karma-browserstack-launcher@~1.6.0: - version "1.6.0" - resolved "https://registry.yarnpkg.com/karma-browserstack-launcher/-/karma-browserstack-launcher-1.6.0.tgz#2f6000647073e77ae296653b8830b279669766ef" - integrity sha512-Y/UWPdHZkHIVH2To4GWHCTzmrsB6H7PBWy6pw+TWz5sr4HW2mcE+Uj6qWgoVNxvQU1Pfn5LQQzI6EQ65p8QbiQ== - dependencies: - browserstack "~1.5.1" - browserstack-local "^1.3.7" - q "~1.5.0" - -karma-chrome-launcher@~3.1.1: - version "3.1.1" - resolved "https://registry.yarnpkg.com/karma-chrome-launcher/-/karma-chrome-launcher-3.1.1.tgz#baca9cc071b1562a1db241827257bfe5cab597ea" - integrity sha512-hsIglcq1vtboGPAN+DGCISCFOxW+ZVnIqhDQcCMqqCp+4dmJ0Qpq5QAjkbA0X2L9Mi6OBkHi2Srrbmm7pUKkzQ== - dependencies: - which "^1.2.1" - -karma-commonjs@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/karma-commonjs/-/karma-commonjs-1.0.0.tgz#8681d5d7d606628c5f00a36e6aef3cf943c6b0a9" - integrity sha1-hoHV19YGYoxfAKNuau88+UPGsKk= - -karma-firefox-launcher@~2.1.2: - version "2.1.2" - resolved "https://registry.yarnpkg.com/karma-firefox-launcher/-/karma-firefox-launcher-2.1.2.tgz#9a38cc783c579a50f3ed2a82b7386186385cfc2d" - integrity sha512-VV9xDQU1QIboTrjtGVD4NCfzIH7n01ZXqy/qpBhnOeGVOkG5JYPEm8kuSd7psHE6WouZaQ9Ool92g8LFweSNMA== - dependencies: - is-wsl "^2.2.0" - which "^2.0.1" - -karma-jasmine@~5.1.0: - version "5.1.0" - resolved "https://registry.yarnpkg.com/karma-jasmine/-/karma-jasmine-5.1.0.tgz#3af4558a6502fa16856a0f346ec2193d4b884b2f" - integrity sha512-i/zQLFrfEpRyQoJF9fsCdTMOF5c2dK7C7OmsuKg2D0YSsuZSfQDiLuaiktbuio6F2wiCsZSnSnieIQ0ant/uzQ== - dependencies: - jasmine-core "^4.1.0" - -karma-safari-launcher@~1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/karma-safari-launcher/-/karma-safari-launcher-1.0.0.tgz#96982a2cc47d066aae71c553babb28319115a2ce" - integrity sha1-lpgqLMR9BmquccVTursoMZEVos4= - -karma-typescript-es6-transform@^5.5.3: - version "5.5.3" - resolved "https://registry.yarnpkg.com/karma-typescript-es6-transform/-/karma-typescript-es6-transform-5.5.3.tgz#5396da512c20b69d49e3e362a41f250342da5c03" - integrity sha512-vB1Cv8z9yxyR2KQuvks5soNKASyS2RPApdMsB3Ad55RqFJeag9G+xyGIwxOdyCHtgOwa4yn1rngMwaN7WBQTbQ== - dependencies: - "@babel/core" "^7.11.1" - "@babel/preset-env" "^7.11.0" - acorn "^8.1.0" - acorn-walk "^8.0.2" - log4js "^6.3.0" - magic-string "^0.25.7" - -karma-typescript@~5.5.3: - version "5.5.3" - resolved "https://registry.yarnpkg.com/karma-typescript/-/karma-typescript-5.5.3.tgz#29c04d9677f8bd78dfacd89e8fa6f475dd25aba2" - integrity sha512-l1FHurolXEBIzRa9ExpNtjzysAhsi/vLpTazpwLHWWK86mknvVpqor6pRZ5Nid7jvOPrTBqAq0JRuLgiCdRkFw== - dependencies: - acorn "^8.1.0" - acorn-walk "^8.0.2" - assert "^2.0.0" - async "^3.0.1" - browser-resolve "^2.0.0" - browserify-zlib "^0.2.0" - buffer "^5.4.3" - combine-source-map "^0.8.0" - console-browserify "^1.2.0" - constants-browserify "^1.0.0" - convert-source-map "^1.7.0" - crypto-browserify "^3.12.0" - diff "^4.0.1" - domain-browser "^4.16.0" - events "^3.2.0" - glob "^7.1.6" - https-browserify "^1.0.0" - istanbul-lib-coverage "^3.0.0" - istanbul-lib-instrument "^4.0.0" - istanbul-lib-report "^3.0.0" - istanbul-lib-source-maps "^4.0.0" - istanbul-reports "^3.0.0" - json-stringify-safe "^5.0.1" - lodash "^4.17.19" - log4js "^6.3.0" - minimatch "^3.0.4" - os-browserify "^0.3.0" - pad "^3.2.0" - path-browserify "^1.0.0" - process "^0.11.10" - punycode "^2.1.1" - querystring-es3 "^0.2.1" - readable-stream "^3.1.1" - source-map "^0.7.3" - stream-browserify "^3.0.0" - stream-http "^3.1.0" - string_decoder "^1.3.0" - timers-browserify "^2.0.11" - tmp "^0.2.1" - tty-browserify "^0.0.1" - url "^0.11.0" - util "^0.12.1" - vm-browserify "^1.1.2" - -karma@~6.4.1: - version "6.4.1" - resolved "https://registry.yarnpkg.com/karma/-/karma-6.4.1.tgz#f2253716dd3a41aaa813fa9f54b6ee047e1127d9" - integrity sha512-Cj57NKOskK7wtFWSlMvZf459iX+kpYIPXmkNUzP2WAFcA7nhr/ALn5R7sw3w+1udFDcpMx/tuB8d5amgm3ijaA== - dependencies: - "@colors/colors" "1.5.0" - body-parser "^1.19.0" - braces "^3.0.2" - chokidar "^3.5.1" - connect "^3.7.0" - di "^0.0.1" - dom-serialize "^2.2.1" - glob "^7.1.7" - graceful-fs "^4.2.6" - http-proxy "^1.18.1" - isbinaryfile "^4.0.8" - lodash "^4.17.21" - log4js "^6.4.1" - mime "^2.5.2" - minimatch "^3.0.4" - mkdirp "^0.5.5" - qjobs "^1.2.0" - range-parser "^1.2.1" - rimraf "^3.0.2" - socket.io "^4.4.1" - source-map "^0.6.1" - tmp "^0.2.1" - ua-parser-js "^0.7.30" - yargs "^16.1.1" - -load-json-file@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/load-json-file/-/load-json-file-4.0.0.tgz#2f5f45ab91e33216234fd53adab668eb4ec0993b" - integrity sha1-L19Fq5HjMhYjT9U62rZo607AmTs= - dependencies: - graceful-fs "^4.1.2" - parse-json "^4.0.0" - pify "^3.0.0" - strip-bom "^3.0.0" - -locate-path@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-5.0.0.tgz#1afba396afd676a6d42504d0a67a3a7eb9f62aa0" - integrity sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g== - dependencies: - p-locate "^4.1.0" - -lodash.debounce@^4.0.8: - version "4.0.8" - resolved "https://registry.yarnpkg.com/lodash.debounce/-/lodash.debounce-4.0.8.tgz#82d79bff30a67c4005ffd5e2515300ad9ca4d7af" - integrity sha1-gteb/zCmfEAF/9XiUVMArZyk168= - -lodash.memoize@~3.0.3: - version "3.0.4" - resolved "https://registry.yarnpkg.com/lodash.memoize/-/lodash.memoize-3.0.4.tgz#2dcbd2c287cbc0a55cc42328bd0c736150d53e3f" - integrity sha1-LcvSwofLwKVcxCMovQxzYVDVPj8= - -lodash@^4.17.19, lodash@^4.17.21: - version "4.17.21" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c" - integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg== - -log4js@^6.3.0, log4js@^6.4.1: - version "6.4.1" - resolved "https://registry.yarnpkg.com/log4js/-/log4js-6.4.1.tgz#9d3a8bf2c31c1e213fe3fc398a6053f7a2bc53e8" - integrity sha512-iUiYnXqAmNKiIZ1XSAitQ4TmNs8CdZYTAWINARF3LjnsLN8tY5m0vRwd6uuWj/yNY0YHxeZodnbmxKFUOM2rMg== - dependencies: - date-format "^4.0.3" - debug "^4.3.3" - flatted "^3.2.4" - rfdc "^1.3.0" - streamroller "^3.0.2" - -long@4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/long/-/long-4.0.0.tgz#9a7b71cfb7d361a194ea555241c92f7468d5bf28" - integrity sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA== - -lru-cache@^6.0.0: - version "6.0.0" - resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-6.0.0.tgz#6d6fe6570ebd96aaf90fcad1dafa3b2566db3a94" - integrity sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA== - dependencies: - yallist "^4.0.0" - -magic-string@^0.25.2: - version "0.25.9" - resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.25.9.tgz#de7f9faf91ef8a1c91d02c2e5314c8277dbcdd1c" - integrity sha512-RmF0AsMzgt25qzqqLc1+MbHmhdx0ojF2Fvs4XnOqz2ZOBXzzkEwc/dJQZCYHAn7v1jbVOjAZfK8msRn4BxO4VQ== - dependencies: - sourcemap-codec "^1.4.8" - -magic-string@^0.25.7: - version "0.25.7" - resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.25.7.tgz#3f497d6fd34c669c6798dcb821f2ef31f5445051" - integrity sha512-4CrMT5DOHTDk4HYDlzmwu4FVCcIYI8gauveasrdCu2IKIFOJ3f0v/8MDGJCDL9oD2ppz/Av1b0Nj345H9M+XIA== - dependencies: - sourcemap-codec "^1.4.4" - -make-dir@^3.0.0, make-dir@^3.0.2: - version "3.1.0" - resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-3.1.0.tgz#415e967046b3a7f1d185277d84aa58203726a13f" - integrity sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw== - dependencies: - semver "^6.0.0" - -make-error@^1.1.1: - version "1.3.6" - resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.6.tgz#2eb2e37ea9b67c4891f684a1394799af484cf7a2" - integrity sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw== - -map-stream@~0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/map-stream/-/map-stream-0.1.0.tgz#e56aa94c4c8055a16404a0674b78f215f7c8e194" - integrity sha1-5WqpTEyAVaFkBKBnS3jyFffI4ZQ= - -md5.js@^1.3.4: - version "1.3.5" - resolved "https://registry.yarnpkg.com/md5.js/-/md5.js-1.3.5.tgz#b5d07b8e3216e3e27cd728d72f70d1e6a342005f" - integrity sha512-xitP+WxNPcTTOgnTJcrhM0xvdPepipPSf3I8EIpGKeFLjt3PlJLIDG3u8EX53ZIubkb+5U2+3rELYpEhHhzdkg== - dependencies: - hash-base "^3.0.0" - inherits "^2.0.1" - safe-buffer "^5.1.2" - -media-typer@0.3.0: - version "0.3.0" - resolved "https://registry.yarnpkg.com/media-typer/-/media-typer-0.3.0.tgz#8710d7af0aa626f8fffa1ce00168545263255748" - integrity sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g= - -memorystream@^0.3.1: - version "0.3.1" - resolved "https://registry.yarnpkg.com/memorystream/-/memorystream-0.3.1.tgz#86d7090b30ce455d63fbae12dda51a47ddcaf9b2" - integrity sha1-htcJCzDORV1j+64S3aUaR93K+bI= - -merge-stream@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/merge-stream/-/merge-stream-2.0.0.tgz#52823629a14dd00c9770fb6ad47dc6310f2c1f60" - integrity sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w== - -miller-rabin@^4.0.0: - version "4.0.1" - resolved "https://registry.yarnpkg.com/miller-rabin/-/miller-rabin-4.0.1.tgz#f080351c865b0dc562a8462966daa53543c78a4d" - integrity sha512-115fLhvZVqWwHPbClyntxEVfVDfl9DLLTuJvq3g2O/Oxi8AiNouAHvDSzHS0viUJc+V5vm3eq91Xwqn9dp4jRA== - dependencies: - bn.js "^4.0.0" - brorand "^1.0.1" - -mime-db@1.51.0: - version "1.51.0" - resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.51.0.tgz#d9ff62451859b18342d960850dc3cfb77e63fb0c" - integrity sha512-5y8A56jg7XVQx2mbv1lu49NR4dokRnhZYTtL+KGfaa27uq4pSTXkwQkFJl4pkRMyNFz/EtYDSkiiEHx3F7UN6g== - -mime-types@~2.1.24: - version "2.1.34" - resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.34.tgz#5a712f9ec1503511a945803640fafe09d3793c24" - integrity sha512-6cP692WwGIs9XXdOO4++N+7qjqv0rqxxVvJ3VHPh/Sc9mVZcQP+ZGhkKiTvWMQRr2tbHkJP/Yn7Y0npb3ZBs4A== - dependencies: - mime-db "1.51.0" - -mime@^2.5.2: - version "2.6.0" - resolved "https://registry.yarnpkg.com/mime/-/mime-2.6.0.tgz#a2a682a95cd4d0cb1d6257e28f83da7e35800367" - integrity sha512-USPkMeET31rOMiarsBNIHZKLGgvKc/LrjofAnBlOttf5ajRvqiRA8QsenbcooctK6d6Ts6aqZXBA+XbkKthiQg== - -minimalistic-assert@^1.0.0, minimalistic-assert@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz#2e194de044626d4a10e7f7fbc00ce73e83e4d5c7" - integrity sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A== - -minimalistic-crypto-utils@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz#f6c00c1c0b082246e5c4d99dfb8c7c083b2b582a" - integrity sha1-9sAMHAsIIkblxNmd+4x8CDsrWCo= - -minimatch@^3.0.4: - version "3.0.4" - resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083" - integrity sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA== - dependencies: - brace-expansion "^1.1.7" - -minimist@^1.2.5: - version "1.2.6" - resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.6.tgz#8637a5b759ea0d6e98702cfb3a9283323c93af44" - integrity sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q== - -mkdirp@^0.5.3, mkdirp@^0.5.5: - version "0.5.5" - resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.5.tgz#d91cefd62d1436ca0f41620e251288d420099def" - integrity sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ== - dependencies: - minimist "^1.2.5" - -ms@2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" - integrity sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g= - -ms@2.1.2: - version "2.1.2" - resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" - integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== - -ms@^2.1.1: - version "2.1.3" - resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2" - integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA== - -negotiator@0.6.2: - version "0.6.2" - resolved "https://registry.yarnpkg.com/negotiator/-/negotiator-0.6.2.tgz#feacf7ccf525a77ae9634436a64883ffeca346fb" - integrity sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw== - -nice-try@^1.0.4: - version "1.0.5" - resolved "https://registry.yarnpkg.com/nice-try/-/nice-try-1.0.5.tgz#a3378a7696ce7d223e88fc9b764bd7ef1089e366" - integrity sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ== - -node-fetch@~2.6.1: - version "2.6.7" - resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.7.tgz#24de9fba827e3b4ae44dc8b20256a379160052ad" - integrity sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ== - dependencies: - whatwg-url "^5.0.0" - -node-releases@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-2.0.1.tgz#3d1d395f204f1f2f29a54358b9fb678765ad2fc5" - integrity "sha1-PR05XyBPHy8ppUNYuftnh2WtL8U= sha512-CqyzN6z7Q6aMeF/ktcMVTzhAHCEpf8SOarwpzpf8pNBY2k5/oM34UHldUwp8VKI7uxct2HxSRdJjBaZeESzcxA==" - -normalize-package-data@^2.3.2: - version "2.5.0" - resolved "https://registry.yarnpkg.com/normalize-package-data/-/normalize-package-data-2.5.0.tgz#e66db1838b200c1dfc233225d12cb36520e234a8" - integrity sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA== - dependencies: - hosted-git-info "^2.1.4" - resolve "^1.10.0" - semver "2 || 3 || 4 || 5" - validate-npm-package-license "^3.0.1" - -normalize-path@^3.0.0, normalize-path@~3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-3.0.0.tgz#0dcd69ff23a1c9b11fd0978316644a0388216a65" - integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA== - -npm-bundled@^1.1.1: - version "1.1.2" - resolved "https://registry.yarnpkg.com/npm-bundled/-/npm-bundled-1.1.2.tgz#944c78789bd739035b70baa2ca5cc32b8d860bc1" - integrity sha512-x5DHup0SuyQcmL3s7Rx/YQ8sbw/Hzg0rj48eN0dV7hf5cmQq5PXIeioroH3raV1QC1yh3uTYuMThvEQF3iKgGQ== - dependencies: - npm-normalize-package-bin "^1.0.1" - -npm-normalize-package-bin@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/npm-normalize-package-bin/-/npm-normalize-package-bin-1.0.1.tgz#6e79a41f23fd235c0623218228da7d9c23b8f6e2" - integrity sha512-EPfafl6JL5/rU+ot6P3gRSCpPDW5VmIzX959Ob1+ySFUuuYHWHekXpwdUZcKP5C+DS4GEtdJluwBjnsNDl+fSA== - -npm-packlist@^2.1.5: - version "2.2.2" - resolved "https://registry.yarnpkg.com/npm-packlist/-/npm-packlist-2.2.2.tgz#076b97293fa620f632833186a7a8f65aaa6148c8" - integrity sha512-Jt01acDvJRhJGthnUJVF/w6gumWOZxO7IkpY/lsX9//zqQgnF7OJaxgQXcerd4uQOLu7W5bkb4mChL9mdfm+Zg== - dependencies: - glob "^7.1.6" - ignore-walk "^3.0.3" - npm-bundled "^1.1.1" - npm-normalize-package-bin "^1.0.1" - -npm-run-all@~4.1.5: - version "4.1.5" - resolved "https://registry.yarnpkg.com/npm-run-all/-/npm-run-all-4.1.5.tgz#04476202a15ee0e2e214080861bff12a51d98fba" - integrity sha512-Oo82gJDAVcaMdi3nuoKFavkIHBRVqQ1qvMb+9LHk/cF4P6B2m8aP04hGf7oL6wZ9BuGwX1onlLhpuoofSyoQDQ== - dependencies: - ansi-styles "^3.2.1" - chalk "^2.4.1" - cross-spawn "^6.0.5" - memorystream "^0.3.1" - minimatch "^3.0.4" - pidtree "^0.3.0" - read-pkg "^3.0.0" - shell-quote "^1.6.1" - string.prototype.padend "^3.0.0" - -object-assign@^4: - version "4.1.1" - resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" - integrity sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM= - -object-inspect@^1.9.0: - version "1.9.0" - resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.9.0.tgz#c90521d74e1127b67266ded3394ad6116986533a" - integrity sha512-i3Bp9iTqwhaLZBxGkRfo5ZbE07BQRT7MGu8+nNgwW9ItGp1TzCTw2DLEoWwjClxBjOFI/hWljTAmYGCEwmtnOw== - -object-is@^1.0.1: - version "1.1.5" - resolved "https://registry.yarnpkg.com/object-is/-/object-is-1.1.5.tgz#b9deeaa5fc7f1846a0faecdceec138e5778f53ac" - integrity sha512-3cyDsyHgtmi7I7DfSSI2LDp6SK2lwvtbg0p0R1e0RvTqF5ceGx+K2dfSjm1bKDMVCFEDAQvy+o8c6a7VujOddw== - dependencies: - call-bind "^1.0.2" - define-properties "^1.1.3" - -object-keys@^1.0.12, object-keys@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.1.1.tgz#1c47f272df277f3b1daf061677d9c82e2322c60e" - integrity sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA== - -object.assign@^4.1.0, object.assign@^4.1.2: - version "4.1.2" - resolved "https://registry.yarnpkg.com/object.assign/-/object.assign-4.1.2.tgz#0ed54a342eceb37b38ff76eb831a0e788cb63940" - integrity sha512-ixT2L5THXsApyiUPYKmW+2EHpXXe5Ii3M+f4e+aJFAHao5amFRW6J0OO6c/LU8Be47utCx2GL89hxGB6XSmKuQ== - dependencies: - call-bind "^1.0.0" - define-properties "^1.1.3" - has-symbols "^1.0.1" - object-keys "^1.1.1" - -on-finished@~2.3.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/on-finished/-/on-finished-2.3.0.tgz#20f1336481b083cd75337992a16971aa2d906947" - integrity sha1-IPEzZIGwg811M3mSoWlxqi2QaUc= - dependencies: - ee-first "1.1.1" - -once@^1.3.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" - integrity sha1-WDsap3WWHUsROsF9nFC6753Xa9E= - dependencies: - wrappy "1" - -os-browserify@^0.3.0: - version "0.3.0" - resolved "https://registry.yarnpkg.com/os-browserify/-/os-browserify-0.3.0.tgz#854373c7f5c2315914fc9bfc6bd8238fdda1ec27" - integrity sha1-hUNzx/XCMVkU/Jv8a9gjj92h7Cc= - -p-limit@^2.2.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-2.3.0.tgz#3dd33c647a214fdfffd835933eb086da0dc21db1" - integrity sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w== - dependencies: - p-try "^2.0.0" - -p-locate@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-4.1.0.tgz#a3428bb7088b3a60292f66919278b7c297ad4f07" - integrity sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A== - dependencies: - p-limit "^2.2.0" - -p-try@^2.0.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/p-try/-/p-try-2.2.0.tgz#cb2868540e313d61de58fafbe35ce9004d5540e6" - integrity sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ== - -pad@^3.2.0: - version "3.2.0" - resolved "https://registry.yarnpkg.com/pad/-/pad-3.2.0.tgz#be7a1d1cb6757049b4ad5b70e71977158fea95d1" - integrity sha512-2u0TrjcGbOjBTJpyewEl4hBO3OeX5wWue7eIFPzQTg6wFSvoaHcBTTUY5m+n0hd04gmTCPuY0kCpVIVuw5etwg== - dependencies: - wcwidth "^1.0.1" - -pako@~1.0.5: - version "1.0.11" - resolved "https://registry.yarnpkg.com/pako/-/pako-1.0.11.tgz#6c9599d340d54dfd3946380252a35705a6b992bf" - integrity sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw== - -parse-asn1@^5.0.0, parse-asn1@^5.1.5: - version "5.1.6" - resolved "https://registry.yarnpkg.com/parse-asn1/-/parse-asn1-5.1.6.tgz#385080a3ec13cb62a62d39409cb3e88844cdaed4" - integrity sha512-RnZRo1EPU6JBnra2vGHj0yhp6ebyjBZpmUCLHWiFhxlzvBCCpAuZ7elsBp1PVAbQN0/04VD/19rfzlBSwLstMw== - dependencies: - asn1.js "^5.2.0" - browserify-aes "^1.0.0" - evp_bytestokey "^1.0.0" - pbkdf2 "^3.0.3" - safe-buffer "^5.1.1" - -parse-json@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/parse-json/-/parse-json-4.0.0.tgz#be35f5425be1f7f6c747184f98a788cb99477ee0" - integrity sha1-vjX1Qlvh9/bHRxhPmKeIy5lHfuA= - dependencies: - error-ex "^1.3.1" - json-parse-better-errors "^1.0.1" - -parseurl@~1.3.3: - version "1.3.3" - resolved "https://registry.yarnpkg.com/parseurl/-/parseurl-1.3.3.tgz#9da19e7bee8d12dff0513ed5b76957793bc2e8d4" - integrity sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ== - -path-browserify@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/path-browserify/-/path-browserify-1.0.1.tgz#d98454a9c3753d5790860f16f68867b9e46be1fd" - integrity sha512-b7uo2UCUOYZcnF/3ID0lulOJi/bafxa1xPe7ZPsammBSpjSWQkjNxlt635YGS2MiR9GjvuXCtz2emr3jbsz98g== - -path-exists@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-4.0.0.tgz#513bdbe2d3b95d7762e8c1137efa195c6c61b5b3" - integrity sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w== - -path-is-absolute@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" - integrity sha1-F0uSaHNVNP+8es5r9TpanhtcX18= - -path-key@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/path-key/-/path-key-2.0.1.tgz#411cadb574c5a140d3a4b1910d40d80cc9f40b40" - integrity sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A= - -path-parse@^1.0.6, path-parse@^1.0.7: - version "1.0.7" - resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.7.tgz#fbc114b60ca42b30d9daf5858e4bd68bbedb6735" - integrity sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw== - -path-type@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/path-type/-/path-type-3.0.0.tgz#cef31dc8e0a1a3bb0d105c0cd97cf3bf47f4e36f" - integrity sha512-T2ZUsdZFHgA3u4e5PfPbjd7HDDpxPnQb5jN0SrDsjNSuVXHJqtwTnWqG0B1jZrgmJ/7lj1EmVIByWt1gxGkWvg== - dependencies: - pify "^3.0.0" - -pause-stream@0.0.11: - version "0.0.11" - resolved "https://registry.yarnpkg.com/pause-stream/-/pause-stream-0.0.11.tgz#fe5a34b0cbce12b5aa6a2b403ee2e73b602f1445" - integrity sha1-/lo0sMvOErWqaitAPuLnO2AvFEU= - dependencies: - through "~2.3" - -pbkdf2@^3.0.3: - version "3.1.1" - resolved "https://registry.yarnpkg.com/pbkdf2/-/pbkdf2-3.1.1.tgz#cb8724b0fada984596856d1a6ebafd3584654b94" - integrity sha512-4Ejy1OPxi9f2tt1rRV7Go7zmfDQ+ZectEQz3VGUQhgq62HtIRPDyG/JtnwIxs6x3uNMwo2V7q1fMvKjb+Tnpqg== - dependencies: - create-hash "^1.1.2" - create-hmac "^1.1.4" - ripemd160 "^2.0.1" - safe-buffer "^5.0.1" - sha.js "^2.4.8" - -picocolors@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/picocolors/-/picocolors-1.0.0.tgz#cb5bdc74ff3f51892236eaf79d68bc44564ab81c" - integrity sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ== - -picomatch@^2.0.4, picomatch@^2.2.1, picomatch@^2.2.2: - version "2.2.2" - resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.2.2.tgz#21f333e9b6b8eaff02468f5146ea406d345f4dad" - integrity sha512-q0M/9eZHzmr0AulXyPwNfZjtwZ/RBZlbN3K3CErVrk50T2ASYI7Bye0EvekFY3IP1Nt2DHu0re+V2ZHIpMkuWg== - -pidtree@^0.3.0: - version "0.3.1" - resolved "https://registry.yarnpkg.com/pidtree/-/pidtree-0.3.1.tgz#ef09ac2cc0533df1f3250ccf2c4d366b0d12114a" - integrity sha512-qQbW94hLHEqCg7nhby4yRC7G2+jYHY4Rguc2bjw7Uug4GIJuu1tvf2uHaZv5Q8zdt+WKJ6qK1FOI6amaWUo5FA== - -pify@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/pify/-/pify-3.0.0.tgz#e5a4acd2c101fdf3d9a4d07f0dbc4db49dd28176" - integrity sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY= - -pkg-dir@^4.1.0: - version "4.2.0" - resolved "https://registry.yarnpkg.com/pkg-dir/-/pkg-dir-4.2.0.tgz#f099133df7ede422e81d1d8448270eeb3e4261f3" - integrity sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ== - dependencies: - find-up "^4.0.0" - -process@^0.11.10: - version "0.11.10" - resolved "https://registry.yarnpkg.com/process/-/process-0.11.10.tgz#7332300e840161bda3e69a1d1d91a7d4bc16f182" - integrity sha1-czIwDoQBYb2j5podHZGn1LwW8YI= - -ps-tree@=1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/ps-tree/-/ps-tree-1.2.0.tgz#5e7425b89508736cdd4f2224d028f7bb3f722ebd" - integrity sha512-0VnamPPYHl4uaU/nSFeZZpR21QAWRz+sRv4iW9+v/GS/J5U5iZB5BNN6J0RMoOvdx2gWM2+ZFMIm58q24e4UYA== - dependencies: - event-stream "=3.3.4" - -public-encrypt@^4.0.0: - version "4.0.3" - resolved "https://registry.yarnpkg.com/public-encrypt/-/public-encrypt-4.0.3.tgz#4fcc9d77a07e48ba7527e7cbe0de33d0701331e0" - integrity sha512-zVpa8oKZSz5bTMTFClc1fQOnyyEzpl5ozpi1B5YcvBrdohMjH2rfsBtyXcuNuwjsDIXmBYlF2N5FlJYhR29t8Q== - dependencies: - bn.js "^4.1.0" - browserify-rsa "^4.0.0" - create-hash "^1.1.0" - parse-asn1 "^5.0.0" - randombytes "^2.0.1" - safe-buffer "^5.1.2" - -punycode@1.3.2: - version "1.3.2" - resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.3.2.tgz#9653a036fb7c1ee42342f2325cceefea3926c48d" - integrity sha1-llOgNvt8HuQjQvIyXM7v6jkmxI0= - -punycode@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec" - integrity sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A== - -q@~1.5.0: - version "1.5.1" - resolved "https://registry.yarnpkg.com/q/-/q-1.5.1.tgz#7e32f75b41381291d04611f1bf14109ac00651d7" - integrity sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc= - -qjobs@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/qjobs/-/qjobs-1.2.0.tgz#c45e9c61800bd087ef88d7e256423bdd49e5d071" - integrity sha512-8YOJEHtxpySA3fFDyCRxA+UUV+fA+rTWnuWvylOK/NCjhY+b4ocCtmu8TtsWb+mYeU+GCHf/S66KZF/AsteKHg== - -qs@6.7.0: - version "6.7.0" - resolved "https://registry.yarnpkg.com/qs/-/qs-6.7.0.tgz#41dc1a015e3d581f1621776be31afb2876a9b1bc" - integrity sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ== - -querystring-es3@^0.2.1: - version "0.2.1" - resolved "https://registry.yarnpkg.com/querystring-es3/-/querystring-es3-0.2.1.tgz#9ec61f79049875707d69414596fd907a4d711e73" - integrity sha1-nsYfeQSYdXB9aUFFlv2Qek1xHnM= - -querystring@0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/querystring/-/querystring-0.2.0.tgz#b209849203bb25df820da756e747005878521620" - integrity sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA= - -randombytes@^2.0.0, randombytes@^2.0.1, randombytes@^2.0.5, randombytes@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/randombytes/-/randombytes-2.1.0.tgz#df6f84372f0270dc65cdf6291349ab7a473d4f2a" - integrity sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ== - dependencies: - safe-buffer "^5.1.0" - -randomfill@^1.0.3: - version "1.0.4" - resolved "https://registry.yarnpkg.com/randomfill/-/randomfill-1.0.4.tgz#c92196fc86ab42be983f1bf31778224931d61458" - integrity sha512-87lcbR8+MhcWcUiQ+9e+Rwx8MyR2P7qnt15ynUlbm3TU/fjbgz4GsvfSUDTemtCCtVCqb4ZcEFlyPNTh9bBTLw== - dependencies: - randombytes "^2.0.5" - safe-buffer "^5.1.0" - -range-parser@^1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/range-parser/-/range-parser-1.2.1.tgz#3cf37023d199e1c24d1a55b84800c2f3e6468031" - integrity sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg== - -raw-body@2.4.0: - version "2.4.0" - resolved "https://registry.yarnpkg.com/raw-body/-/raw-body-2.4.0.tgz#a1ce6fb9c9bc356ca52e89256ab59059e13d0332" - integrity sha512-4Oz8DUIwdvoa5qMJelxipzi/iJIi40O5cGV1wNYp5hvZP8ZN0T+jiNkL0QepXs+EsQ9XJ8ipEDoiH70ySUJP3Q== - dependencies: - bytes "3.1.0" - http-errors "1.7.2" - iconv-lite "0.4.24" - unpipe "1.0.0" - -read-pkg@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/read-pkg/-/read-pkg-3.0.0.tgz#9cbc686978fee65d16c00e2b19c237fcf6e38389" - integrity sha1-nLxoaXj+5l0WwA4rGcI3/Pbjg4k= - dependencies: - load-json-file "^4.0.0" - normalize-package-data "^2.3.2" - path-type "^3.0.0" - -readable-stream@^3.1.1, readable-stream@^3.5.0, readable-stream@^3.6.0: - version "3.6.0" - resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-3.6.0.tgz#337bbda3adc0706bd3e024426a286d4b4b2c9198" - integrity sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA== - dependencies: - inherits "^2.0.3" - string_decoder "^1.1.1" - util-deprecate "^1.0.1" - -readdirp@~3.6.0: - version "3.6.0" - resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-3.6.0.tgz#74a370bd857116e245b29cc97340cd431a02a6c7" - integrity sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA== - dependencies: - picomatch "^2.2.1" - -regenerate-unicode-properties@^8.2.0: - version "8.2.0" - resolved "https://registry.yarnpkg.com/regenerate-unicode-properties/-/regenerate-unicode-properties-8.2.0.tgz#e5de7111d655e7ba60c057dbe9ff37c87e65cdec" - integrity sha512-F9DjY1vKLo/tPePDycuH3dn9H1OTPIkVD9Kz4LODu+F2C75mgjAJ7x/gwy6ZcSNRAAkhNlJSOHRe8k3p+K9WhA== - dependencies: - regenerate "^1.4.0" - -regenerate@^1.4.0: - version "1.4.2" - resolved "https://registry.yarnpkg.com/regenerate/-/regenerate-1.4.2.tgz#b9346d8827e8f5a32f7ba29637d398b69014848a" - integrity sha512-zrceR/XhGYU/d/opr2EKO7aRHUeiBI8qjtfHqADTwZd6Szfy16la6kqD0MIUs5z5hx6AaKa+PixpPrR289+I0A== - -regenerator-runtime@^0.13.4: - version "0.13.7" - resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.7.tgz#cac2dacc8a1ea675feaabaeb8ae833898ae46f55" - integrity sha512-a54FxoJDIr27pgf7IgeQGxmqUNYrcV338lf/6gH456HZ/PhX+5BcwHXG9ajESmwe6WRO0tAzRUrRmNONWgkrew== - -regenerator-transform@^0.14.2: - version "0.14.5" - resolved "https://registry.yarnpkg.com/regenerator-transform/-/regenerator-transform-0.14.5.tgz#c98da154683671c9c4dcb16ece736517e1b7feb4" - integrity sha512-eOf6vka5IO151Jfsw2NO9WpGX58W6wWmefK3I1zEGr0lOD0u8rwPaNqQL1aRxUaxLeKO3ArNh3VYg1KbaD+FFw== - dependencies: - "@babel/runtime" "^7.8.4" - -regexpu-core@^4.7.1: - version "4.7.1" - resolved "https://registry.yarnpkg.com/regexpu-core/-/regexpu-core-4.7.1.tgz#2dea5a9a07233298fbf0db91fa9abc4c6e0f8ad6" - integrity sha512-ywH2VUraA44DZQuRKzARmw6S66mr48pQVva4LBeRhcOltJ6hExvWly5ZjFLYo67xbIxb6W1q4bAGtgfEl20zfQ== - dependencies: - regenerate "^1.4.0" - regenerate-unicode-properties "^8.2.0" - regjsgen "^0.5.1" - regjsparser "^0.6.4" - unicode-match-property-ecmascript "^1.0.4" - unicode-match-property-value-ecmascript "^1.2.0" - -regjsgen@^0.5.1: - version "0.5.2" - resolved "https://registry.yarnpkg.com/regjsgen/-/regjsgen-0.5.2.tgz#92ff295fb1deecbf6ecdab2543d207e91aa33733" - integrity sha512-OFFT3MfrH90xIW8OOSyUrk6QHD5E9JOTeGodiJeBS3J6IwlgzJMNE/1bZklWz5oTg+9dCMyEetclvCVXOPoN3A== - -regjsparser@^0.6.4: - version "0.6.9" - resolved "https://registry.yarnpkg.com/regjsparser/-/regjsparser-0.6.9.tgz#b489eef7c9a2ce43727627011429cf833a7183e6" - integrity sha512-ZqbNRz1SNjLAiYuwY0zoXW8Ne675IX5q+YHioAGbCw4X96Mjl2+dcX9B2ciaeyYjViDAfvIjFpQjJgLttTEERQ== - dependencies: - jsesc "~0.5.0" - -require-directory@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42" - integrity sha1-jGStX9MNqxyXbiNE/+f3kqam30I= - -requires-port@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/requires-port/-/requires-port-1.0.0.tgz#925d2601d39ac485e091cf0da5c6e694dc3dcaff" - integrity sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8= - -resolve@^1.1.6, resolve@^1.10.0, resolve@^1.14.2, resolve@^1.17.0, resolve@^1.3.2: - version "1.20.0" - resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.20.0.tgz#629a013fb3f70755d6f0b7935cc1c2c5378b1975" - integrity sha512-wENBPt4ySzg4ybFQW2TT1zMQucPK95HSh/nq2CFTZVOGut2+pQvSsgtda4d26YrYcr067wjbmzOG8byDPBX63A== - dependencies: - is-core-module "^2.2.0" - path-parse "^1.0.6" - -resolve@^1.11.0, resolve@^1.11.1: - version "1.22.1" - resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.22.1.tgz#27cb2ebb53f91abb49470a928bba7558066ac177" - integrity sha512-nBpuuYuY5jFsli/JIs1oldw6fOQCBioohqWZg/2hiaOybXOft4lonv85uDOKXdf8rhyK159cxU5cDcK/NKk8zw== - dependencies: - is-core-module "^2.9.0" - path-parse "^1.0.7" - supports-preserve-symlinks-flag "^1.0.0" - -rfdc@^1.3.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/rfdc/-/rfdc-1.3.0.tgz#d0b7c441ab2720d05dc4cf26e01c89631d9da08b" - integrity sha512-V2hovdzFbOi77/WajaSMXk2OLm+xNIeQdMMuB7icj7bk6zi2F8GGAxigcnDFpJHbNyNcgyJDiP+8nOrY5cZGrA== - -rimraf@^3.0.0, rimraf@^3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-3.0.2.tgz#f1a5402ba6220ad52cc1282bac1ae3aa49fd061a" - integrity sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA== - dependencies: - glob "^7.1.3" - -rimraf@~2.5.2: - version "2.5.4" - resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.5.4.tgz#96800093cbf1a0c86bd95b4625467535c29dfa04" - integrity sha1-loAAk8vxoMhr2VtGJUZ1NcKd+gQ= - dependencies: - glob "^7.0.5" - -rimraf@~4.1.2: - version "4.1.2" - resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-4.1.2.tgz#20dfbc98083bdfaa28b01183162885ef213dbf7c" - integrity sha512-BlIbgFryTbw3Dz6hyoWFhKk+unCcHMSkZGrTFVAx2WmttdBSonsdtRlwiuTbDqTKr+UlXIUqJVS4QT5tUzGENQ== - -ripemd160@^2.0.0, ripemd160@^2.0.1: - version "2.0.2" - resolved "https://registry.yarnpkg.com/ripemd160/-/ripemd160-2.0.2.tgz#a1c1a6f624751577ba5d07914cbc92850585890c" - integrity sha512-ii4iagi25WusVoiC4B4lq7pbXfAp3D9v5CwfkY33vffw2+pkDjY1D8GaN7spsxvCSx8dkPqOZCEZyfxcmJG2IA== - dependencies: - hash-base "^3.0.0" - inherits "^2.0.1" - -rollup-plugin-commonjs@10.1.0: - version "10.1.0" - resolved "https://registry.yarnpkg.com/rollup-plugin-commonjs/-/rollup-plugin-commonjs-10.1.0.tgz#417af3b54503878e084d127adf4d1caf8beb86fb" - integrity sha512-jlXbjZSQg8EIeAAvepNwhJj++qJWNJw1Cl0YnOqKtP5Djx+fFGkp3WRh+W0ASCaFG5w1jhmzDxgu3SJuVxPF4Q== - dependencies: - estree-walker "^0.6.1" - is-reference "^1.1.2" - magic-string "^0.25.2" - resolve "^1.11.0" - rollup-pluginutils "^2.8.1" - -rollup-plugin-node-resolve@5.2.0: - version "5.2.0" - resolved "https://registry.yarnpkg.com/rollup-plugin-node-resolve/-/rollup-plugin-node-resolve-5.2.0.tgz#730f93d10ed202473b1fb54a5997a7db8c6d8523" - integrity sha512-jUlyaDXts7TW2CqQ4GaO5VJ4PwwaV8VUGA7+km3n6k6xtOEacf61u0VXwN80phY/evMcaS+9eIeJ9MOyDxt5Zw== - dependencies: - "@types/resolve" "0.0.8" - builtin-modules "^3.1.0" - is-module "^1.0.0" - resolve "^1.11.1" - rollup-pluginutils "^2.8.1" - -rollup-plugin-terser@^7.0.2: - version "7.0.2" - resolved "https://registry.yarnpkg.com/rollup-plugin-terser/-/rollup-plugin-terser-7.0.2.tgz#e8fbba4869981b2dc35ae7e8a502d5c6c04d324d" - integrity sha512-w3iIaU4OxcF52UUXiZNsNeuXIMDvFrr+ZXK6bFZ0Q60qyVfq4uLptoS4bbq3paG3x216eQllFZX7zt6TIImguQ== - dependencies: - "@babel/code-frame" "^7.10.4" - jest-worker "^26.2.1" - serialize-javascript "^4.0.0" - terser "^5.0.0" - -rollup-plugin-typescript2@0.34.1: - version "0.34.1" - resolved "https://registry.yarnpkg.com/rollup-plugin-typescript2/-/rollup-plugin-typescript2-0.34.1.tgz#c457f155a71d133c142689213fce78694e30d0be" - integrity sha512-P4cHLtGikESmqi1CA+tdMDUv8WbQV48mzPYt77TSTOPJpERyZ9TXdDgjSDix8Fkqce6soYz3+fa4lrC93IEkcw== - dependencies: - "@rollup/pluginutils" "^4.1.2" - find-cache-dir "^3.3.2" - fs-extra "^10.0.0" - semver "^7.3.7" - tslib "^2.4.0" - -rollup-plugin-uglify@~6.0.4: - version "6.0.4" - resolved "https://registry.yarnpkg.com/rollup-plugin-uglify/-/rollup-plugin-uglify-6.0.4.tgz#65a0959d91586627f1e46a7db966fd504ec6c4e6" - integrity sha512-ddgqkH02klveu34TF0JqygPwZnsbhHVI6t8+hGTcYHngPkQb5MIHI0XiztXIN/d6V9j+efwHAqEL7LspSxQXGw== - dependencies: - "@babel/code-frame" "^7.0.0" - jest-worker "^24.0.0" - serialize-javascript "^2.1.2" - uglify-js "^3.4.9" - -rollup-pluginutils@^2.8.1: - version "2.8.2" - resolved "https://registry.yarnpkg.com/rollup-pluginutils/-/rollup-pluginutils-2.8.2.tgz#72f2af0748b592364dbd3389e600e5a9444a351e" - integrity sha512-EEp9NhnUkwY8aif6bxgovPHMoMoNr2FulJziTndpt5H9RdwC47GSGuII9XxpSdzVGM0GWrNPHV6ie1LTNJPaLQ== - dependencies: - estree-walker "^0.6.1" - -rollup@^3.17.2: - version "3.17.2" - resolved "https://registry.yarnpkg.com/rollup/-/rollup-3.17.2.tgz#a4ecd29c488672a0606e41ef57474fad715750a9" - integrity sha512-qMNZdlQPCkWodrAZ3qnJtvCAl4vpQ8q77uEujVCCbC/6CLB7Lcmvjq7HyiOSnf4fxTT9XgsE36oLHJBH49xjqA== - optionalDependencies: - fsevents "~2.3.2" - -safe-buffer@^5.0.1, safe-buffer@^5.1.0, safe-buffer@^5.1.1, safe-buffer@^5.1.2, safe-buffer@^5.2.0, safe-buffer@~5.2.0: - version "5.2.1" - resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" - integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== - -safe-buffer@~5.1.1: - version "5.1.2" - resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" - integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g== - -"safer-buffer@>= 2.1.2 < 3", safer-buffer@^2.1.0: - version "2.1.2" - resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a" - integrity sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg== - -seedrandom@^3.0.5: - version "3.0.5" - resolved "https://registry.yarnpkg.com/seedrandom/-/seedrandom-3.0.5.tgz#54edc85c95222525b0c7a6f6b3543d8e0b3aa0a7" - integrity sha512-8OwmbklUNzwezjGInmZ+2clQmExQPvomqjL7LFqOYqtmuxRgQYqOD3mHaU+MvZn5FLUeVxVfQjwLZW/n/JFuqg== - -"semver@2 || 3 || 4 || 5", semver@^5.3.0, semver@^5.5.0: - version "5.7.2" - resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.2.tgz#48d55db737c3287cd4835e17fa13feace1c41ef8" - integrity sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g== - -semver@7.0.0: - version "7.0.0" - resolved "https://registry.yarnpkg.com/semver/-/semver-7.0.0.tgz#5f3ca35761e47e05b206c6daff2cf814f0316b8e" - integrity sha512-+GB6zVA9LWh6zovYQLALHwv5rb2PHGlJi3lfiqIHxR0uuwCgefcOJc59v9fv1w8GbStwxuuqqAjI9NMAOOgq1A== - -semver@^6.0.0, semver@^6.1.1, semver@^6.1.2, semver@^6.3.0: - version "6.3.1" - resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.1.tgz#556d2ef8689146e46dcea4bfdd095f3434dffcb4" - integrity sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA== - -semver@^7.3.7: - version "7.5.4" - resolved "https://registry.yarnpkg.com/semver/-/semver-7.5.4.tgz#483986ec4ed38e1c6c48c34894a9182dbff68a6e" - integrity sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA== - dependencies: - lru-cache "^6.0.0" - -serialize-javascript@^2.1.2: - version "2.1.2" - resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-2.1.2.tgz#ecec53b0e0317bdc95ef76ab7074b7384785fa61" - integrity sha512-rs9OggEUF0V4jUSecXazOYsLfu7OGK2qIn3c7IPBiffz32XniEp/TX9Xmc9LQfK2nQ2QKHvZ2oygKUGU0lG4jQ== - -serialize-javascript@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-4.0.0.tgz#b525e1238489a5ecfc42afacc3fe99e666f4b1aa" - integrity sha512-GaNA54380uFefWghODBWEGisLZFj00nS5ACs6yHa9nLqlLpVLO8ChDGeKRjZnV4Nh4n0Qi7nhYZD/9fCPzEqkw== - dependencies: - randombytes "^2.1.0" - -setimmediate@^1.0.4: - version "1.0.5" - resolved "https://registry.yarnpkg.com/setimmediate/-/setimmediate-1.0.5.tgz#290cbb232e306942d7d7ea9b83732ab7856f8285" - integrity sha1-KQy7Iy4waULX1+qbg3Mqt4VvgoU= - -setprototypeof@1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/setprototypeof/-/setprototypeof-1.1.1.tgz#7e95acb24aa92f5885e0abef5ba131330d4ae683" - integrity sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw== - -sha.js@^2.4.0, sha.js@^2.4.8: - version "2.4.11" - resolved "https://registry.yarnpkg.com/sha.js/-/sha.js-2.4.11.tgz#37a5cf0b81ecbc6943de109ba2960d1b26584ae7" - integrity sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ== - dependencies: - inherits "^2.0.1" - safe-buffer "^5.0.1" - -shebang-command@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-1.2.0.tgz#44aac65b695b03398968c39f363fee5deafdf1ea" - integrity sha1-RKrGW2lbAzmJaMOfNj/uXer98eo= - dependencies: - shebang-regex "^1.0.0" - -shebang-regex@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-1.0.0.tgz#da42f49740c0b42db2ca9728571cb190c98efea3" - integrity sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM= - -shell-quote@^1.6.1: - version "1.7.3" - resolved "https://registry.yarnpkg.com/shell-quote/-/shell-quote-1.7.3.tgz#aa40edac170445b9a431e17bb62c0b881b9c4123" - integrity sha512-Vpfqwm4EnqGdlsBFNmHhxhElJYrdfcxPThu+ryKS5J8L/fhAwLazFZtq+S+TWZ9ANj2piSQLGj6NQg+lKPmxrw== - -socket.io-adapter@~2.4.0: - version "2.4.0" - resolved "https://registry.yarnpkg.com/socket.io-adapter/-/socket.io-adapter-2.4.0.tgz#b50a4a9ecdd00c34d4c8c808224daa1a786152a6" - integrity sha512-W4N+o69rkMEGVuk2D/cvca3uYsvGlMwsySWV447y99gUPghxq42BxqLNMndb+a1mm/5/7NeXVQS7RLa2XyXvYg== - -socket.io-parser@~4.2.0: - version "4.2.4" - resolved "https://registry.yarnpkg.com/socket.io-parser/-/socket.io-parser-4.2.4.tgz#c806966cf7270601e47469ddeec30fbdfda44c83" - integrity sha512-/GbIKmo8ioc+NIWIhwdecY0ge+qVBSMdgxGygevmdHj24bsfgtCmcUUcQ5ZzcylGFHsN3k4HB4Cgkl96KVnuew== - dependencies: - "@socket.io/component-emitter" "~3.1.0" - debug "~4.3.1" - -socket.io@^4.4.1: - version "4.5.3" - resolved "https://registry.yarnpkg.com/socket.io/-/socket.io-4.5.3.tgz#44dffea48d7f5aa41df4a66377c386b953bc521c" - integrity sha512-zdpnnKU+H6mOp7nYRXH4GNv1ux6HL6+lHL8g7Ds7Lj8CkdK1jJK/dlwsKDculbyOHifcJ0Pr/yeXnZQ5GeFrcg== - dependencies: - accepts "~1.3.4" - base64id "~2.0.0" - debug "~4.3.2" - engine.io "~6.2.0" - socket.io-adapter "~2.4.0" - socket.io-parser "~4.2.0" - -source-map-support@~0.5.20: - version "0.5.21" - resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.21.tgz#04fe7c7f9e1ed2d662233c28cb2b35b9f63f6e4f" - integrity sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w== - dependencies: - buffer-from "^1.0.0" - source-map "^0.6.0" - -source-map@^0.5.0, source-map@~0.5.3: - version "0.5.7" - resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" - integrity sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w= - -source-map@^0.6.0, source-map@^0.6.1: - version "0.6.1" - resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" - integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== - -source-map@^0.7.3: - version "0.7.3" - resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.7.3.tgz#5302f8169031735226544092e64981f751750383" - integrity sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ== - -sourcemap-codec@^1.4.4, sourcemap-codec@^1.4.8: - version "1.4.8" - resolved "https://registry.yarnpkg.com/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz#ea804bd94857402e6992d05a38ef1ae35a9ab4c4" - integrity sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA== - -spdx-correct@^3.0.0: - version "3.1.1" - resolved "https://registry.yarnpkg.com/spdx-correct/-/spdx-correct-3.1.1.tgz#dece81ac9c1e6713e5f7d1b6f17d468fa53d89a9" - integrity sha512-cOYcUWwhCuHCXi49RhFRCyJEK3iPj1Ziz9DpViV3tbZOwXD49QzIN3MpOLJNxh2qwq2lJJZaKMVw9qNi4jTC0w== - dependencies: - spdx-expression-parse "^3.0.0" - spdx-license-ids "^3.0.0" - -spdx-exceptions@^2.1.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/spdx-exceptions/-/spdx-exceptions-2.3.0.tgz#3f28ce1a77a00372683eade4a433183527a2163d" - integrity sha512-/tTrYOC7PPI1nUAgx34hUpqXuyJG+DTHJTnIULG4rDygi4xu/tfgmq1e1cIRwRzwZgo4NLySi+ricLkZkw4i5A== - -spdx-expression-parse@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/spdx-expression-parse/-/spdx-expression-parse-3.0.1.tgz#cf70f50482eefdc98e3ce0a6833e4a53ceeba679" - integrity sha512-cbqHunsQWnJNE6KhVSMsMeH5H/L9EpymbzqTQ3uLwNCLZ1Q481oWaofqH7nO6V07xlXwY6PhQdQ2IedWx/ZK4Q== - dependencies: - spdx-exceptions "^2.1.0" - spdx-license-ids "^3.0.0" - -spdx-license-ids@^3.0.0: - version "3.0.7" - resolved "https://registry.yarnpkg.com/spdx-license-ids/-/spdx-license-ids-3.0.7.tgz#e9c18a410e5ed7e12442a549fbd8afa767038d65" - integrity sha512-U+MTEOO0AiDzxwFvoa4JVnMV6mZlJKk2sBLt90s7G0Gd0Mlknc7kxEn3nuDPNZRta7O2uy8oLcZLVT+4sqNZHQ== - -split@0.3: - version "0.3.3" - resolved "https://registry.yarnpkg.com/split/-/split-0.3.3.tgz#cd0eea5e63a211dfff7eb0f091c4133e2d0dd28f" - integrity sha1-zQ7qXmOiEd//frDwkcQTPi0N0o8= - dependencies: - through "2" - -sprintf-js@~1.0.2: - version "1.0.3" - resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" - integrity sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw= - -"statuses@>= 1.5.0 < 2", statuses@~1.5.0: - version "1.5.0" - resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.5.0.tgz#161c7dac177659fd9811f43771fa99381478628c" - integrity sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow= - -stream-browserify@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/stream-browserify/-/stream-browserify-3.0.0.tgz#22b0a2850cdf6503e73085da1fc7b7d0c2122f2f" - integrity sha512-H73RAHsVBapbim0tU2JwwOiXUj+fikfiaoYAKHF3VJfA0pe2BCzkhAHBlLG6REzE+2WNZcxOXjK7lkso+9euLA== - dependencies: - inherits "~2.0.4" - readable-stream "^3.5.0" - -stream-combiner@~0.0.4: - version "0.0.4" - resolved "https://registry.yarnpkg.com/stream-combiner/-/stream-combiner-0.0.4.tgz#4d5e433c185261dde623ca3f44c586bcf5c4ad14" - integrity sha1-TV5DPBhSYd3mI8o/RMWGvPXErRQ= - dependencies: - duplexer "~0.1.1" - -stream-http@^3.1.0: - version "3.1.1" - resolved "https://registry.yarnpkg.com/stream-http/-/stream-http-3.1.1.tgz#0370a8017cf8d050b9a8554afe608f043eaff564" - integrity sha512-S7OqaYu0EkFpgeGFb/NPOoPLxFko7TPqtEeFg5DXPB4v/KETHG0Ln6fRFrNezoelpaDKmycEmmZ81cC9DAwgYg== - dependencies: - builtin-status-codes "^3.0.0" - inherits "^2.0.4" - readable-stream "^3.6.0" - xtend "^4.0.2" - -streamroller@^3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/streamroller/-/streamroller-3.0.2.tgz#30418d0eee3d6c93ec897f892ed098e3a81e68b7" - integrity sha512-ur6y5S5dopOaRXBuRIZ1u6GC5bcEXHRZKgfBjfCglMhmIf+roVCECjvkEYzNQOXIN2/JPnkMPW/8B3CZoKaEPA== - dependencies: - date-format "^4.0.3" - debug "^4.1.1" - fs-extra "^10.0.0" - -string-width@^4.1.0, string-width@^4.2.0: - version "4.2.2" - resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.2.tgz#dafd4f9559a7585cfba529c6a0a4f73488ebd4c5" - integrity sha512-XBJbT3N4JhVumXE0eoLU9DCjcaF92KLNqTmFCnG1pf8duUxFGwtP6AD6nkjw9a3IdiRtL3E2w3JDiE/xi3vOeA== - dependencies: - emoji-regex "^8.0.0" - is-fullwidth-code-point "^3.0.0" - strip-ansi "^6.0.0" - -string.prototype.padend@^3.0.0: - version "3.1.2" - resolved "https://registry.yarnpkg.com/string.prototype.padend/-/string.prototype.padend-3.1.2.tgz#6858ca4f35c5268ebd5e8615e1327d55f59ee311" - integrity sha512-/AQFLdYvePENU3W5rgurfWSMU6n+Ww8n/3cUt7E+vPBB/D7YDG8x+qjoFs4M/alR2bW7Qg6xMjVwWUOvuQ0XpQ== - dependencies: - call-bind "^1.0.2" - define-properties "^1.1.3" - es-abstract "^1.18.0-next.2" - -string.prototype.trimend@^1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/string.prototype.trimend/-/string.prototype.trimend-1.0.4.tgz#e75ae90c2942c63504686c18b287b4a0b1a45f80" - integrity sha512-y9xCjw1P23Awk8EvTpcyL2NIr1j7wJ39f+k6lvRnSMz+mz9CGz9NYPelDk42kOz6+ql8xjfK8oYzy3jAP5QU5A== - dependencies: - call-bind "^1.0.2" - define-properties "^1.1.3" - -string.prototype.trimstart@^1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/string.prototype.trimstart/-/string.prototype.trimstart-1.0.4.tgz#b36399af4ab2999b4c9c648bd7a3fb2bb26feeed" - integrity sha512-jh6e984OBfvxS50tdY2nRZnoC5/mLFKOREQfw8t5yytkoUsJRNxvI/E39qu1sD0OtWI3OC0XgKSmcWwziwYuZw== - dependencies: - call-bind "^1.0.2" - define-properties "^1.1.3" - -string_decoder@^1.1.1, string_decoder@^1.3.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.3.0.tgz#42f114594a46cf1a8e30b0a84f56c78c3edac21e" - integrity sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA== - dependencies: - safe-buffer "~5.2.0" - -strip-ansi@^6.0.0: - version "6.0.0" - resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.0.tgz#0b1571dd7669ccd4f3e06e14ef1eed26225ae532" - integrity sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w== - dependencies: - ansi-regex "^5.0.0" - -strip-bom@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-3.0.0.tgz#2334c18e9c759f7bdd56fdef7e9ae3d588e68ed3" - integrity sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM= - -supports-color@^5.3.0: - version "5.5.0" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f" - integrity sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow== - dependencies: - has-flag "^3.0.0" - -supports-color@^6.1.0: - version "6.1.0" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-6.1.0.tgz#0764abc69c63d5ac842dd4867e8d025e880df8f3" - integrity sha512-qe1jfm1Mg7Nq/NSh6XE24gPXROEVsWHxC1LIx//XNlD9iw7YZQGjZNjYN7xGaEG6iKdA8EtNFW6R0gjnVXp+wQ== - dependencies: - has-flag "^3.0.0" - -supports-color@^7.0.0, supports-color@^7.1.0: - version "7.2.0" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-7.2.0.tgz#1b7dcdcb32b8138801b3e478ba6a51caa89648da" - integrity sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw== - dependencies: - has-flag "^4.0.0" - -supports-preserve-symlinks-flag@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz#6eda4bd344a3c94aea376d4cc31bc77311039e09" - integrity sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w== - -temp-fs@^0.9.9: - version "0.9.9" - resolved "https://registry.yarnpkg.com/temp-fs/-/temp-fs-0.9.9.tgz#8071730437870720e9431532fe2814364f8803d7" - integrity sha1-gHFzBDeHByDpQxUy/igUNk+IA9c= - dependencies: - rimraf "~2.5.2" - -terser@^5.0.0: - version "5.14.2" - resolved "https://registry.yarnpkg.com/terser/-/terser-5.14.2.tgz#9ac9f22b06994d736174f4091aa368db896f1c10" - integrity sha512-oL0rGeM/WFQCUd0y2QrWxYnq7tfSuKBiqTjRPWrRgB46WD/kiwHwF8T23z78H6Q6kGCuuHcPB+KULHRdxvVGQA== - dependencies: - "@jridgewell/source-map" "^0.3.2" - acorn "^8.5.0" - commander "^2.20.0" - source-map-support "~0.5.20" - -through@2, through@~2.3, through@~2.3.1: - version "2.3.8" - resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5" - integrity sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU= - -timers-browserify@^2.0.11: - version "2.0.12" - resolved "https://registry.yarnpkg.com/timers-browserify/-/timers-browserify-2.0.12.tgz#44a45c11fbf407f34f97bccd1577c652361b00ee" - integrity sha512-9phl76Cqm6FhSX9Xe1ZUAMLtm1BLkKj2Qd5ApyWkXzsMRaA7dgr81kf4wJmQf/hAvg8EEyJxDo3du/0KlhPiKQ== - dependencies: - setimmediate "^1.0.4" - -tmp@^0.2.1: - version "0.2.1" - resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.2.1.tgz#8457fc3037dcf4719c251367a1af6500ee1ccf14" - integrity sha512-76SUhtfqR2Ijn+xllcI5P1oyannHNHByD80W1q447gU3mp9G9PSpGdWmjUOHRDPiHYacIk66W7ubDTuPF3BEtQ== - dependencies: - rimraf "^3.0.0" - -to-fast-properties@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/to-fast-properties/-/to-fast-properties-2.0.0.tgz#dc5e698cbd079265bc73e0377681a4e4e83f616e" - integrity sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4= - -to-regex-range@^5.0.1: - version "5.0.1" - resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-5.0.1.tgz#1648c44aae7c8d988a326018ed72f5b4dd0392e4" - integrity sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ== - dependencies: - is-number "^7.0.0" - -toidentifier@1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/toidentifier/-/toidentifier-1.0.0.tgz#7e1be3470f1e77948bc43d94a3c8f4d7752ba553" - integrity sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw== - -tr46@~0.0.3: - version "0.0.3" - resolved "https://registry.yarnpkg.com/tr46/-/tr46-0.0.3.tgz#8184fd347dac9cdc185992f3a6622e14b9d9ab6a" - integrity sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o= - -ts-node@^10.9.1: - version "10.9.1" - resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-10.9.1.tgz#e73de9102958af9e1f0b168a6ff320e25adcff4b" - integrity sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw== - dependencies: - "@cspotcode/source-map-support" "^0.8.0" - "@tsconfig/node10" "^1.0.7" - "@tsconfig/node12" "^1.0.7" - "@tsconfig/node14" "^1.0.0" - "@tsconfig/node16" "^1.0.2" - acorn "^8.4.1" - acorn-walk "^8.1.1" - arg "^4.1.0" - create-require "^1.1.0" - diff "^4.0.1" - make-error "^1.1.1" - v8-compile-cache-lib "^3.0.1" - yn "3.1.1" - -tslib@^1.13.0, tslib@^1.8.1: - version "1.14.1" - resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00" - integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg== - -tslib@^2.4.0: - version "2.4.0" - resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.4.0.tgz#7cecaa7f073ce680a05847aa77be941098f36dc3" - integrity sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ== - -tslint-no-circular-imports@^0.7.0: - version "0.7.0" - resolved "https://registry.yarnpkg.com/tslint-no-circular-imports/-/tslint-no-circular-imports-0.7.0.tgz#9df0a15654d66b172e0b7843eed073fa5ae99b5f" - integrity sha512-k3wxpeMC4ef40UbpfBVHEHIzKfNZq5/SCtAO1YjGsaNTklo+K53/TWLrym+poA65RJFDiYgYNWvkeIIkJNA0Vw== - -tslint@~6.1.3: - version "6.1.3" - resolved "https://registry.yarnpkg.com/tslint/-/tslint-6.1.3.tgz#5c23b2eccc32487d5523bd3a470e9aa31789d904" - integrity sha512-IbR4nkT96EQOvKE2PW/djGz8iGNeJ4rF2mBfiYaR/nvUWYKJhLwimoJKgjIFEIDibBtOevj7BqCRL4oHeWWUCg== - dependencies: - "@babel/code-frame" "^7.0.0" - builtin-modules "^1.1.1" - chalk "^2.3.0" - commander "^2.12.1" - diff "^4.0.1" - glob "^7.1.1" - js-yaml "^3.13.1" - minimatch "^3.0.4" - mkdirp "^0.5.3" - resolve "^1.3.2" - semver "^5.3.0" - tslib "^1.13.0" - tsutils "^2.29.0" - -tsutils@^2.29.0: - version "2.29.0" - resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-2.29.0.tgz#32b488501467acbedd4b85498673a0812aca0b99" - integrity sha512-g5JVHCIJwzfISaXpXE1qvNalca5Jwob6FjI4AoPlqMusJ6ftFE7IkkFoMhVLRgK+4Kx3gkzb8UZK5t5yTTvEmA== - dependencies: - tslib "^1.8.1" - -tty-browserify@^0.0.1: - version "0.0.1" - resolved "https://registry.yarnpkg.com/tty-browserify/-/tty-browserify-0.0.1.tgz#3f05251ee17904dfd0677546670db9651682b811" - integrity sha512-C3TaO7K81YvjCgQH9Q1S3R3P3BtN3RIM8n+OvX4il1K1zgE8ZhI0op7kClgkxtutIE8hQrcrHBXvIheqKUUCxw== - -type-is@~1.6.17: - version "1.6.18" - resolved "https://registry.yarnpkg.com/type-is/-/type-is-1.6.18.tgz#4e552cd05df09467dcbc4ef739de89f2cf37c131" - integrity sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g== - dependencies: - media-typer "0.3.0" - mime-types "~2.1.24" - -typescript@5.0.4: - version "5.0.4" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.0.4.tgz#b217fd20119bd61a94d4011274e0ab369058da3b" - integrity sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw== - -ua-parser-js@^0.7.30: - version "0.7.33" - resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.33.tgz#1d04acb4ccef9293df6f70f2c3d22f3030d8b532" - integrity sha512-s8ax/CeZdK9R/56Sui0WM6y9OFREJarMRHqLB2EwkovemBxNQ+Bqu8GAsUnVcXKgphb++ghr/B2BZx4mahujPw== - -uglify-js@^3.4.9: - version "3.17.4" - resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.17.4.tgz#61678cf5fa3f5b7eb789bb345df29afb8257c22c" - integrity sha512-T9q82TJI9e/C1TAxYvfb16xO120tMVFZrGA3f9/P4424DNu6ypK103y0GPFVa17yotwSyZW5iYXgjYHkGrJW/g== - -unbox-primitive@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/unbox-primitive/-/unbox-primitive-1.0.1.tgz#085e215625ec3162574dc8859abee78a59b14471" - integrity sha512-tZU/3NqK3dA5gpE1KtyiJUrEB0lxnGkMFHptJ7q6ewdZ8s12QrODwNbhIJStmJkd1QDXa1NRA8aF2A1zk/Ypyw== - dependencies: - function-bind "^1.1.1" - has-bigints "^1.0.1" - has-symbols "^1.0.2" - which-boxed-primitive "^1.0.2" - -unicode-canonical-property-names-ecmascript@^1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-1.0.4.tgz#2619800c4c825800efdd8343af7dd9933cbe2818" - integrity sha512-jDrNnXWHd4oHiTZnx/ZG7gtUTVp+gCcTTKr8L0HjlwphROEW3+Him+IpvC+xcJEFegapiMZyZe02CyuOnRmbnQ== - -unicode-match-property-ecmascript@^1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/unicode-match-property-ecmascript/-/unicode-match-property-ecmascript-1.0.4.tgz#8ed2a32569961bce9227d09cd3ffbb8fed5f020c" - integrity sha512-L4Qoh15vTfntsn4P1zqnHulG0LdXgjSO035fEpdtp6YxXhMT51Q6vgM5lYdG/5X3MjS+k/Y9Xw4SFCY9IkR0rg== - dependencies: - unicode-canonical-property-names-ecmascript "^1.0.4" - unicode-property-aliases-ecmascript "^1.0.4" - -unicode-match-property-value-ecmascript@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/unicode-match-property-value-ecmascript/-/unicode-match-property-value-ecmascript-1.2.0.tgz#0d91f600eeeb3096aa962b1d6fc88876e64ea531" - integrity sha512-wjuQHGQVofmSJv1uVISKLE5zO2rNGzM/KCYZch/QQvez7C1hUhBIuZ701fYXExuufJFMPhv2SyL8CyoIfMLbIQ== - -unicode-property-aliases-ecmascript@^1.0.4: - version "1.1.0" - resolved "https://registry.yarnpkg.com/unicode-property-aliases-ecmascript/-/unicode-property-aliases-ecmascript-1.1.0.tgz#dd57a99f6207bedff4628abefb94c50db941c8f4" - integrity sha512-PqSoPh/pWetQ2phoj5RLiaqIk4kCNwoV3CI+LfGmWLKI3rE3kl1h59XpX2BjgDrmbxD9ARtQobPGU1SguCYuQg== - -universalify@^0.1.0: - version "0.1.2" - resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.2.tgz#b646f69be3942dabcecc9d6639c80dc105efaa66" - integrity sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg== - -universalify@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/universalify/-/universalify-2.0.0.tgz#75a4984efedc4b08975c5aeb73f530d02df25717" - integrity sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ== - -unpipe@1.0.0, unpipe@~1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/unpipe/-/unpipe-1.0.0.tgz#b2bf4ee8514aae6165b4817829d21b2ef49904ec" - integrity sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw= - -url@^0.11.0: - version "0.11.0" - resolved "https://registry.yarnpkg.com/url/-/url-0.11.0.tgz#3838e97cfc60521eb73c525a8e55bfdd9e2e28f1" - integrity sha1-ODjpfPxgUh63PFJajlW/3Z4uKPE= - dependencies: - punycode "1.3.2" - querystring "0.2.0" - -util-deprecate@^1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" - integrity sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8= - -util@^0.12.0, util@^0.12.1: - version "0.12.3" - resolved "https://registry.yarnpkg.com/util/-/util-0.12.3.tgz#971bb0292d2cc0c892dab7c6a5d37c2bec707888" - integrity sha512-I8XkoQwE+fPQEhy9v012V+TSdH2kp9ts29i20TaaDUXsg7x/onePbhFJUExBfv/2ay1ZOp/Vsm3nDlmnFGSAog== - dependencies: - inherits "^2.0.3" - is-arguments "^1.0.4" - is-generator-function "^1.0.7" - is-typed-array "^1.1.3" - safe-buffer "^5.1.2" - which-typed-array "^1.1.2" - -utils-merge@1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/utils-merge/-/utils-merge-1.0.1.tgz#9f95710f50a267947b2ccc124741c1028427e713" - integrity sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM= - -v8-compile-cache-lib@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz#6336e8d71965cb3d35a1bbb7868445a7c05264bf" - integrity sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg== - -validate-npm-package-license@^3.0.1: - version "3.0.4" - resolved "https://registry.yarnpkg.com/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz#fc91f6b9c7ba15c857f4cb2c5defeec39d4f410a" - integrity sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew== - dependencies: - spdx-correct "^3.0.0" - spdx-expression-parse "^3.0.0" - -vary@^1: - version "1.1.2" - resolved "https://registry.yarnpkg.com/vary/-/vary-1.1.2.tgz#2299f02c6ded30d4a5961b0b9f74524a18f634fc" - integrity sha1-IpnwLG3tMNSllhsLn3RSShj2NPw= - -vm-browserify@^1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/vm-browserify/-/vm-browserify-1.1.2.tgz#78641c488b8e6ca91a75f511e7a3b32a86e5dda0" - integrity sha512-2ham8XPWTONajOR0ohOKOHXkm3+gaBmGut3SRuu75xLd/RRaY6vqgh8NBYYk7+RW3u5AtzPQZG8F10LHkl0lAQ== - -void-elements@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/void-elements/-/void-elements-2.0.1.tgz#c066afb582bb1cb4128d60ea92392e94d5e9dbec" - integrity sha1-wGavtYK7HLQSjWDqkjkulNXp2+w= - -wcwidth@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/wcwidth/-/wcwidth-1.0.1.tgz#f0b0dcf915bc5ff1528afadb2c0e17b532da2fe8" - integrity sha1-8LDc+RW8X/FSivrbLA4XtTLaL+g= - dependencies: - defaults "^1.0.3" - -webidl-conversions@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871" - integrity sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE= - -whatwg-url@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-5.0.0.tgz#966454e8765462e37644d3626f6742ce8b70965d" - integrity sha1-lmRU6HZUYuN2RNNib2dCzotwll0= - dependencies: - tr46 "~0.0.3" - webidl-conversions "^3.0.0" - -which-boxed-primitive@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/which-boxed-primitive/-/which-boxed-primitive-1.0.2.tgz#13757bc89b209b049fe5d86430e21cf40a89a8e6" - integrity sha512-bwZdv0AKLpplFY2KZRX6TvyuN7ojjr7lwkg6ml0roIy9YeuSr7JS372qlNW18UQYzgYK9ziGcerWqZOmEn9VNg== - dependencies: - is-bigint "^1.0.1" - is-boolean-object "^1.1.0" - is-number-object "^1.0.4" - is-string "^1.0.5" - is-symbol "^1.0.3" - -which-typed-array@^1.1.2: - version "1.1.4" - resolved "https://registry.yarnpkg.com/which-typed-array/-/which-typed-array-1.1.4.tgz#8fcb7d3ee5adf2d771066fba7cf37e32fe8711ff" - integrity sha512-49E0SpUe90cjpoc7BOJwyPHRqSAd12c10Qm2amdEZrJPCY2NDxaW01zHITrem+rnETY3dwrbH3UUrUwagfCYDA== - dependencies: - available-typed-arrays "^1.0.2" - call-bind "^1.0.0" - es-abstract "^1.18.0-next.1" - foreach "^2.0.5" - function-bind "^1.1.1" - has-symbols "^1.0.1" - is-typed-array "^1.1.3" - -which@^1.2.1, which@^1.2.9: - version "1.3.1" - resolved "https://registry.yarnpkg.com/which/-/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a" - integrity sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ== - dependencies: - isexe "^2.0.0" - -which@^2.0.1: - version "2.0.2" - resolved "https://registry.yarnpkg.com/which/-/which-2.0.2.tgz#7c6a8dd0a636a0327e10b59c9286eee93f3f51b1" - integrity sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA== - dependencies: - isexe "^2.0.0" - -wrap-ansi@^7.0.0: - version "7.0.0" - resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" - integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== - dependencies: - ansi-styles "^4.0.0" - string-width "^4.1.0" - strip-ansi "^6.0.0" - -wrappy@1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" - integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8= - -ws@~8.2.3: - version "8.2.3" - resolved "https://registry.yarnpkg.com/ws/-/ws-8.2.3.tgz#63a56456db1b04367d0b721a0b80cae6d8becbba" - integrity sha512-wBuoj1BDpC6ZQ1B7DWQBYVLphPWkm8i9Y0/3YdHjHKHiohOJ1ws+3OccDWtH+PoC9DZD5WOTrJvNbWvjS6JWaA== - -xtend@^4.0.2: - version "4.0.2" - resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.2.tgz#bb72779f5fa465186b1f438f674fa347fdb5db54" - integrity sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ== - -y18n@^5.0.5: - version "5.0.5" - resolved "https://registry.yarnpkg.com/y18n/-/y18n-5.0.5.tgz#8769ec08d03b1ea2df2500acef561743bbb9ab18" - integrity sha512-hsRUr4FFrvhhRH12wOdfs38Gy7k2FFzB9qgN9v3aLykRq0dRcdcpz5C9FxdS2NuhOrI/628b/KSTJ3rwHysYSg== - -yalc@~1.0.0-pre.21: - version "1.0.0-pre.53" - resolved "https://registry.yarnpkg.com/yalc/-/yalc-1.0.0-pre.53.tgz#c51db2bb924a6908f4cb7e82af78f7e5606810bc" - integrity sha512-tpNqBCpTXplnduzw5XC+FF8zNJ9L/UXmvQyyQj7NKrDNavbJtHvzmZplL5ES/RCnjX7JR7W9wz5GVDXVP3dHUQ== - dependencies: - chalk "^4.1.0" - detect-indent "^6.0.0" - fs-extra "^8.0.1" - glob "^7.1.4" - ignore "^5.0.4" - ini "^2.0.0" - npm-packlist "^2.1.5" - yargs "^16.1.1" - -yallist@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72" - integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A== - -yargs-parser@^20.2.2: - version "20.2.7" - resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.7.tgz#61df85c113edfb5a7a4e36eb8aa60ef423cbc90a" - integrity sha512-FiNkvbeHzB/syOjIUxFDCnhSfzAL8R5vs40MgLFBorXACCOAEaWu0gRZl14vG8MR9AOJIZbmkjhusqBYZ3HTHw== - -yargs@^16.1.1: - version "16.2.0" - resolved "https://registry.yarnpkg.com/yargs/-/yargs-16.2.0.tgz#1c82bf0f6b6a66eafce7ef30e376f49a12477f66" - integrity sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw== - dependencies: - cliui "^7.0.2" - escalade "^3.1.1" - get-caller-file "^2.0.5" - require-directory "^2.1.1" - string-width "^4.2.0" - y18n "^5.0.5" - yargs-parser "^20.2.2" - -yn@3.1.1: - version "3.1.1" - resolved "https://registry.yarnpkg.com/yn/-/yn-3.1.1.tgz#1e87401a09d767c1d5eab26a6e4c185182d2eb50" - integrity sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q== diff --git a/tfjs-master/tfjs-backend-cpu/.npmignore b/tfjs-master/tfjs-backend-cpu/.npmignore deleted file mode 100644 index 6292b5fdb..000000000 --- a/tfjs-master/tfjs-backend-cpu/.npmignore +++ /dev/null @@ -1,27 +0,0 @@ -.babelrc -.DS_Store -.idea/ -.rpt2_cache -.travis.yml -.vscode -*.tgz -*.txt -**.yalc -**yalc.lock -cloudbuild.yml -coverage/ -demo/ -dist/**/*_test.d.ts -dist/**/*_test.js -karma.conf.js -node_modules/ -npm-debug.log -package-lock.json -package/ -rollup.config.js -scripts/ -src/**/*_test.ts -tsconfig.json -tslint.json -yarn-error.log -yarn.lock diff --git a/tfjs-master/tfjs-backend-cpu/.npmrc b/tfjs-master/tfjs-backend-cpu/.npmrc deleted file mode 100644 index 43c97e719..000000000 --- a/tfjs-master/tfjs-backend-cpu/.npmrc +++ /dev/null @@ -1 +0,0 @@ -package-lock=false diff --git a/tfjs-master/tfjs-backend-cpu/.nycrc b/tfjs-master/tfjs-backend-cpu/.nycrc deleted file mode 100644 index c13fc92d2..000000000 --- a/tfjs-master/tfjs-backend-cpu/.nycrc +++ /dev/null @@ -1,19 +0,0 @@ -{ - "extension": [ - ".ts" - ], - "reporter": [ - "html", - "text-summary" - ], - "include": [ - "src/**/*" - ], - "exclude": [ - "src/run_tests.ts", - "src/**/*_test.ts" - ], - "cache": false, - "sourceMap": true, - "instrument": true -} diff --git a/tfjs-master/tfjs-backend-cpu/.vscode/launch.json b/tfjs-master/tfjs-backend-cpu/.vscode/launch.json deleted file mode 100644 index 0aa0bb52b..000000000 --- a/tfjs-master/tfjs-backend-cpu/.vscode/launch.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "name": "Run tests", - "type": "node", - "request": "launch", - "runtimeExecutable": "yarn", - "runtimeArgs": ["test"], - "sourceMaps": true, - "cwd": "${workspaceRoot}", - "protocol": "inspector", - } - ] -} diff --git a/tfjs-master/tfjs-backend-cpu/BUILD.bazel b/tfjs-master/tfjs-backend-cpu/BUILD.bazel deleted file mode 100644 index ece7e27f2..000000000 --- a/tfjs-master/tfjs-backend-cpu/BUILD.bazel +++ /dev/null @@ -1,110 +0,0 @@ -# Copyright 2021 Google LLC. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================= - -load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_test", "pkg_npm") -load("//tools:copy_to_dist.bzl", "copy_to_dist", "copy_ts_library_to_dist") -load("//tools:tfjs_bundle.bzl", "tfjs_bundle") -load("//tools:tfjs_web_test.bzl", "tfjs_web_test") - -package(default_visibility = ["//visibility:public"]) - -nodejs_test( - name = "tfjs-backend-cpu_test", - data = [ - "//tfjs-backend-cpu/src:tfjs-backend-cpu_test_lib", - ], - entry_point = "//tfjs-backend-cpu/src:run_tests.ts", - link_workspace_root = True, - tags = ["ci"], -) - -tfjs_web_test( - name = "tfjs-backend-cpu_browser_test", - srcs = [ - "//tfjs-backend-cpu/src:tfjs-backend-cpu_test_bundle", - ], - args = [], - browsers = [ - "bs_chrome_mac", - ], - headless = False, - presubmit_browsers = [ - "bs_chrome_mac", - ], -) - -tfjs_bundle( - name = "tf-backend-cpu", - entry_point = "//tfjs-backend-cpu/src:index.ts", - external = [ - "@tensorflow/tfjs-core", - "crypto", - "node-fetch", - "seedrandom", - "util", - ], - globals = { - "@tensorflow/tfjs-core": "tf", - "seedrandom": "seedrandom", - }, - umd_name = "tf", - deps = [ - "//tfjs-backend-cpu/src:tfjs-backend-cpu_lib", - "//tfjs-backend-cpu/src:tfjs-backend-cpu_src_lib", - ], -) - -copy_ts_library_to_dist( - name = "copy_src_to_dist", - srcs = [ - "//tfjs-backend-cpu/src:tfjs-backend-cpu_lib", - "//tfjs-backend-cpu/src:tfjs-backend-cpu_src_lib", - ], - root = "src", -) - -copy_to_dist( - name = "copy_bundles", - srcs = [ - ":tf-backend-cpu", - ":tf-backend-cpu.es2017", - ":tf-backend-cpu.es2017.min", - ":tf-backend-cpu.fesm", - ":tf-backend-cpu.fesm.min", - ":tf-backend-cpu.min", - ":tf-backend-cpu.node", - ], -) - -pkg_npm( - name = "tfjs-backend-cpu_pkg", - package_name = "@tensorflow/tfjs-backend-cpu", - srcs = [ - "README.md", - "package.json", - ], - tags = ["ci"], - deps = [ - ":copy_bundles", - ":copy_src_to_dist", - ], -) - -test_suite( - name = "tests", - tests = [ - ":tfjs-backend-cpu_test", - ], -) diff --git a/tfjs-master/tfjs-backend-cpu/README.md b/tfjs-master/tfjs-backend-cpu/README.md deleted file mode 100644 index 5e1e55361..000000000 --- a/tfjs-master/tfjs-backend-cpu/README.md +++ /dev/null @@ -1,37 +0,0 @@ -# Usage - -This package implements a JavaScript based CPU backend to TensorFlow.js. - -## Importing the backend - -Note: this backend is included by default in `@tensorflow/tfjs`. - -### Via NPM - -```js -// Import @tensorflow/tfjs-core -import * as tf from '@tensorflow/tfjs-core'; -// Adds the CPU backend to the global backend registry. -import '@tensorflow/tfjs-backend-cpu'; -``` - -### Via a script tag - -```html - - - - - -``` - -You can also get ES2017 code using the following links - -```html - - - - - -``` - diff --git a/tfjs-master/tfjs-backend-cpu/package.json b/tfjs-master/tfjs-backend-cpu/package.json deleted file mode 100644 index a93ea02f4..000000000 --- a/tfjs-master/tfjs-backend-cpu/package.json +++ /dev/null @@ -1,56 +0,0 @@ -{ - "name": "@tensorflow/tfjs-backend-cpu", - "version": "0.0.0", - "description": "Vanilla JavaScript backend for TensorFlow.js", - "private": false, - "main": "dist/tf-backend-cpu.node.js", - "jsdelivr": "dist/tf-backend-cpu.min.js", - "unpkg": "dist/tf-backend-cpu.min.js", - "types": "dist/index.d.ts", - "jsnext:main": "dist/index.js", - "module": "dist/index.js", - "miniprogram": "dist/miniprogram", - "engines": { - "yarn": ">= 1.3.2" - }, - "repository": { - "type": "git", - "url": "https://github.com/tensorflow/tfjs.git", - "directory": "tfjs-backend-cpu" - }, - "license": "Apache-2.0", - "devDependencies": { - "@bazel/bazelisk": "^1.12.0", - "@bazel/ibazel": "^0.16.2" - }, - "scripts": { - "build": "bazel build :tfjs-backend-cpu_pkg", - "publish-npm": "bazel run :tfjs-backend-cpu_pkg.publish", - "coverage": "bazel coverage :tfjs-backend-cpu_test", - "test": "bazel test :tests --test_output=streamed", - "test-debug": "bazel run :tfjs-backend-cpu_test --config=debug", - "test-dev": "ibazel run :tests --test-output=streamed" - }, - "dependencies": { - "@types/seedrandom": "^2.4.28", - "seedrandom": "^3.0.5" - }, - "peerDependencies": { - "@tensorflow/tfjs-core": "link:../link-package/node_modules/@tensorflow/tfjs-core" - }, - "browser": { - "util": false, - "crypto": false - }, - "sideEffects": [ - "./dist/register_all_kernels.js", - "./dist/base.js", - "./dist/index.js", - "./src/register_all_kernels.mjs", - "./src/base.mjs", - "./src/index.mjs" - ], - "resolutions": { - "minimist": "1.2.6" - } -} diff --git a/tfjs-master/tfjs-backend-cpu/scripts/build-npm.sh b/tfjs-master/tfjs-backend-cpu/scripts/build-npm.sh deleted file mode 100644 index d1e157e89..000000000 --- a/tfjs-master/tfjs-backend-cpu/scripts/build-npm.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/env bash -# Copyright 2017 Google LLC. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================= - -set -e - -yarn rimraf dist/ -yarn - -yarn build -yarn rollup -c --visualize --npm - -# Use minified files for miniprogram -mkdir dist/miniprogram -cp dist/tf-backend-cpu.min.js dist/miniprogram/index.js -cp dist/tf-backend-cpu.min.js.map dist/miniprogram/index.js.map - -echo "Stored standalone library at dist/tf-backend-cpu(.min).js" diff --git a/tfjs-master/tfjs-backend-cpu/src/BUILD.bazel b/tfjs-master/tfjs-backend-cpu/src/BUILD.bazel deleted file mode 100644 index 64d9d36b1..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/BUILD.bazel +++ /dev/null @@ -1,101 +0,0 @@ -# Copyright 2021 Google LLC. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================= - -load("//tools:defaults.bzl", "esbuild", "ts_library") -load("//tools:enumerate_tests.bzl", "enumerate_tests") - -package(default_visibility = ["//visibility:public"]) - -TEST_SRCS = [ - "**/*_test.ts", - "run_tests.ts", -] - -filegroup( - name = "all_test_entrypoints", - srcs = glob( - ["**/*_test.ts"], - exclude = [ - "setup_test.ts", - ], - ), -) - -# Generates the 'tests.ts' file that imports all test entrypoints. -enumerate_tests( - name = "tests", - srcs = [":all_test_entrypoints"], - root_path = "tfjs-backend-cpu/src", -) - -ts_library( - name = "tfjs-backend-cpu_src_lib", - srcs = glob( - ["**/*.ts"], - exclude = TEST_SRCS + ["index.ts"], - ), - module_name = "@tensorflow/tfjs-backend-cpu/dist", - deps = [ - "//tfjs-core/src:tfjs-core_lib", - "@npm//@types/seedrandom", - "@npm//seedrandom", - ], -) - -ts_library( - name = "tfjs-backend-cpu_lib", - srcs = ["index.ts"], - module_name = "@tensorflow/tfjs-backend-cpu", - deps = [ - ":tfjs-backend-cpu_src_lib", - ], -) - -ts_library( - name = "tfjs-backend-cpu_test_lib", - testonly = True, - srcs = glob(TEST_SRCS) + [ - ":tests", - ], - module_name = "@tensorflow/tfjs-backend-cpu/dist", - deps = [ - ":tfjs-backend-cpu_lib", - ":tfjs-backend-cpu_src_lib", - "//tfjs-core/src:tfjs-core_lib", - "//tfjs-core/src:tfjs-core_src_lib", - "//tfjs-core/src:tfjs-core_test_lib", - "@npm//@types/jasmine", - "@npm//jasmine", - ], -) - -esbuild( - name = "tfjs-backend-cpu_test_bundle", - testonly = True, - entry_point = "setup_test.ts", - external = [ - # webworker tests call 'require('@tensorflow/tfjs')', which - # is external to the test bundle. - # Note: This is not a bazel target. It's just a string. - "@tensorflow/tfjs", - "worker_threads", - "util", - ], - sources_content = True, - deps = [ - ":tfjs-backend-cpu_lib", - ":tfjs-backend-cpu_test_lib", - ], -) diff --git a/tfjs-master/tfjs-backend-cpu/src/backend_cpu.ts b/tfjs-master/tfjs-backend-cpu/src/backend_cpu.ts deleted file mode 100644 index 854cb366c..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/backend_cpu.ts +++ /dev/null @@ -1,233 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, BackendTimingInfo, buffer, DataStorage, DataType, engine, env, kernel_impls, KernelBackend, Rank, ShapeMap, Tensor, Tensor2D, TensorBuffer, TensorInfo, TypedArray, util} from '@tensorflow/tfjs-core'; - -const whereImpl = kernel_impls.whereImpl; -import {assertNotComplex} from './cpu_util'; - -interface DataId {} - -export interface TensorData { - values?: backend_util.BackendValues; - dtype: D; - // For complex numbers, the real and imaginary parts are stored as their own - // individual tensors, with a parent joining the two with the - // complexTensorInfos field. - complexTensorInfos?: {real: TensorInfo, imag: TensorInfo}; - // refCount keeps track of how many tensors reference it. Used for memory - // management. - refCount: number; -} - -export class MathBackendCPU extends KernelBackend { - public blockSize = 48; - - data: DataStorage>; - private firstUse = true; - private static nextDataId = 0; - private nextDataId(): number { - return MathBackendCPU.nextDataId++; - } - - constructor() { - super(); - this.data = new DataStorage(this, engine()); - } - - override write( - values: backend_util.BackendValues, shape: number[], - dtype: DataType): DataId { - if (this.firstUse) { - this.firstUse = false; - if (env().get('IS_NODE')) { - backend_util.warn( - '\n============================\n' + - 'Hi, looks like you are running TensorFlow.js in ' + - 'Node.js. To speed things up dramatically, install our node ' + - 'backend, visit https://github.com/tensorflow/tfjs-node for more details. ' + - '\n============================'); - } - } - const dataId = {id: this.nextDataId()}; - - this.data.set(dataId, {values, dtype, refCount: 1}); - - return dataId; - } - - /** - * Create a data bucket in cpu backend. - * @param shape Shape of the `TensorInfo`. - * @param dtype DType of the `TensorInfo`. - * @param values The value of the `TensorInfo` stored as a flattened array. - */ - makeTensorInfo( - shape: number[], dtype: DataType, - values?: backend_util.BackendValues|string[]): TensorInfo { - let outId; - if (dtype === 'string' && values != null && values.length > 0 && - util.isString(values[0])) { - const encodedValues = - (values as unknown as string[]).map(d => util.encodeString(d)); - - outId = this.write(encodedValues, shape, dtype); - } else { - outId = this.write(values as TypedArray, shape, dtype); - } - - return {dataId: outId, shape, dtype}; - } - - /** Return refCount of a `TensorData`. */ - override refCount(dataId: DataId): number { - if (this.data.has(dataId)) { - const tensorData = this.data.get(dataId); - return tensorData.refCount; - } - return 0; - } - - /** Increase refCount of a `TensorData`. */ - override incRef(dataId: DataId): void { - const tensorData = this.data.get(dataId); - tensorData.refCount++; - } - - /** Decrease refCount of a `TensorData`. */ - decRef(dataId: DataId): void { - if (this.data.has(dataId)) { - const tensorData = this.data.get(dataId); - tensorData.refCount--; - } - } - - override move( - dataId: DataId, values: backend_util.BackendValues, shape: number[], - dtype: DataType, refCount: number): void { - this.data.set(dataId, {values, dtype, refCount}); - } - - override numDataIds(): number { - return this.data.numDataIds(); - } - - override async read(dataId: DataId): Promise { - return this.readSync(dataId); - } - override readSync(dataId: DataId): backend_util.BackendValues { - const {dtype, complexTensorInfos} = this.data.get(dataId); - - if (dtype === 'complex64') { - const realValues = - this.readSync(complexTensorInfos.real.dataId) as Float32Array; - const imagValues = - this.readSync(complexTensorInfos.imag.dataId) as Float32Array; - return backend_util.mergeRealAndImagArrays(realValues, imagValues); - } - return util.convertBackendValuesAndArrayBuffer( - this.data.get(dataId).values, dtype); - } - - bufferSync(t: TensorInfo): - TensorBuffer { - const data = this.readSync(t.dataId); - if (t.dtype === 'string') { - try { - // Decode the bytes into string. - const strings = (data as Uint8Array[]).map(d => util.decodeString(d)); - return buffer(t.shape as ShapeMap[R], t.dtype, strings) as - TensorBuffer; - } catch { - throw new Error('Failed to decode encoded string bytes into utf-8'); - } - } - return buffer(t.shape as ShapeMap[R], t.dtype, data as TypedArray) as - TensorBuffer; - } - - makeOutput( - values: backend_util.BackendValues, shape: number[], dtype: DataType): T { - return engine().makeTensorFromTensorInfo( - this.makeTensorInfo(shape, dtype, values), this) as T; - } - - /** - * Dispose the memory if the dataId has 0 refCount. Return true if the memory - * is released or memory is not managed in this backend, false if memory is - * not cleared. - * @param dataId - * @oaram force Optional, remove the data regardless of refCount - */ - override disposeData(dataId: DataId, force = false): boolean { - if (this.data.has(dataId)) { - this.data.get(dataId).refCount--; - if (!force && this.data.get(dataId).refCount > 0) { - return false; - } - - const {complexTensorInfos} = this.data.get(dataId); - - if (complexTensorInfos != null) { - this.disposeData(complexTensorInfos.real.dataId, true); - this.disposeData(complexTensorInfos.imag.dataId, true); - } - - this.data.delete(dataId); - } - return true; - } - - disposeIntermediateTensorInfo(tensorInfo: TensorInfo): void { - this.disposeData(tensorInfo.dataId); - } - - override async time(f: () => void): Promise { - const start = util.now(); - f(); - const kernelMs = util.now() - start; - return {kernelMs}; - } - - override memory() { - return { - // Unreliable due to automatic gc. The numbers above are cumulative. - unreliable: true, - reasons: - ['The reported memory is an upper bound. Due to automatic garbage ' + - 'collection, the true allocated memory may be less.'] - }; - } - - where(condition: Tensor): Tensor2D { - assertNotComplex([condition], 'where'); - - const condVals = this.readSync(condition.dataId) as TypedArray; - return whereImpl(condition.shape, condVals); - } - - override dispose() {} - - override floatPrecision(): 16|32 { - return 32; - } - - /** Returns the smallest representable number. */ - override epsilon(): number { - return super.epsilon(); - } -} diff --git a/tfjs-master/tfjs-backend-cpu/src/backend_cpu_test.ts b/tfjs-master/tfjs-backend-cpu/src/backend_cpu_test.ts deleted file mode 100644 index b4aa455df..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/backend_cpu_test.ts +++ /dev/null @@ -1,135 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '@tensorflow/tfjs-core'; -import {engine, test_util, util} from '@tensorflow/tfjs-core'; - -const {expectArraysEqual} = test_util; -// tslint:disable-next-line: no-imports-from-dist -import {describeWithFlags, ALL_ENVS} from '@tensorflow/tfjs-core/dist/jasmine_util'; - -import {MathBackendCPU} from './backend_cpu'; - -/** Private test util for decoding array of strings in utf-8. */ -function decodeStrings(bytes: Uint8Array[]): string[] { - return bytes.map(b => util.decodeString(b)); -} - -describeWithFlags('backendCPU', ALL_ENVS, () => { - let backend: MathBackendCPU; - beforeEach(() => { - backend = tf.backend() as MathBackendCPU; - }); - - it('register string tensor with values', () => { - const t = engine().makeTensor(['a', 'b', 'c'], [3], 'string'); - expectArraysEqual( - decodeStrings(backend.readSync(t.dataId) as Uint8Array[]), - ['a', 'b', 'c']); - }); - - it('register string tensor with values and mismatched shape', () => { - expect(() => tf.tensor(['a', 'b', 'c'], [4], 'string')).toThrowError(); - }); -}); - -describeWithFlags('depthToSpace', ALL_ENVS, () => { - it('throws when CPU backend used with data format NCHW', () => { - const t = tf.tensor4d([1, 2, 3, 4], [1, 4, 1, 1]); - const blockSize = 2; - const dataFormat = 'NCHW'; - - expect(() => tf.depthToSpace(t, blockSize, dataFormat)) - .toThrowError( - `Only NHWC dataFormat supported on CPU for depthToSpace. Got ${ - dataFormat}`); - }); -}); - -describeWithFlags('gatherND CPU', ALL_ENVS, () => { - it('should throw error when index out of range', () => { - const indices = tf.tensor2d([0, 2, 99], [3, 1], 'int32'); - const input = tf.tensor2d( - [100, 101, 102, 777, 778, 779, 10000, 10001, 10002], [3, 3], 'float32'); - expect(() => tf.gatherND(input, indices)).toThrow(); - }); -}); - -describeWithFlags('scatterND CPU', ALL_ENVS, () => { - it('should throw error when index out of range', () => { - const indices = tf.tensor2d([0, 4, 99], [3, 1], 'int32'); - const updates = tf.tensor2d( - [100, 101, 102, 777, 778, 779, 10000, 10001, 10002], [3, 3], 'float32'); - const shape = [5, 3]; - expect(() => tf.scatterND(indices, updates, shape)).toThrow(); - }); - - it('should throw error when indices has wrong dimension', () => { - const indices = tf.tensor2d([0, 4, 99], [3, 1], 'int32'); - const updates = tf.tensor2d( - [100, 101, 102, 777, 778, 779, 10000, 10001, 10002], [3, 3], 'float32'); - const shape = [2, 3]; - expect(() => tf.scatterND(indices, updates, shape)).toThrow(); - }); -}); - -describeWithFlags('sparseToDense CPU', ALL_ENVS, () => { - it('should throw error when index out of range', () => { - const defaultValue = 2; - const indices = tf.tensor1d([0, 2, 6], 'int32'); - const values = tf.tensor1d([100, 101, 102], 'int32'); - const shape = [6]; - expect(() => tf.sparseToDense(indices, values, shape, defaultValue)) - .toThrow(); - }); -}); - -describeWithFlags('memory cpu', ALL_ENVS, () => { - it('unreliable is true due to auto gc', () => { - tf.tensor(1); - const mem = tf.memory(); - expect(mem.numTensors).toBe(1); - expect(mem.numDataBuffers).toBe(1); - expect(mem.numBytes).toBe(4); - expect(mem.unreliable).toBe(true); - - const expectedReason = - 'The reported memory is an upper bound. Due to automatic garbage ' + - 'collection, the true allocated memory may be less.'; - expect(mem.reasons.indexOf(expectedReason) >= 0).toBe(true); - }); - - it('unreliable is true due to both auto gc and string tensors', () => { - tf.tensor(1); - tf.tensor('a'); - - const mem = tf.memory(); - expect(mem.numTensors).toBe(2); - expect(mem.numDataBuffers).toBe(2); - expect(mem.numBytes).toBe(5); - expect(mem.unreliable).toBe(true); - - const expectedReasonGC = - 'The reported memory is an upper bound. Due to automatic garbage ' + - 'collection, the true allocated memory may be less.'; - expect(mem.reasons.indexOf(expectedReasonGC) >= 0).toBe(true); - const expectedReasonString = - 'Memory usage by string tensors is approximate ' + - '(2 bytes per character)'; - expect(mem.reasons.indexOf(expectedReasonString) >= 0).toBe(true); - }); -}); diff --git a/tfjs-master/tfjs-backend-cpu/src/base.ts b/tfjs-master/tfjs-backend-cpu/src/base.ts deleted file mode 100644 index 60d137700..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/base.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -/* - * base.ts contains all the exports from tfjs-backend-cpu - * without auto-kernel registration - */ -import {registerBackend} from '@tensorflow/tfjs-core'; -import {MathBackendCPU} from './backend_cpu'; -import * as shared from './shared'; - -export {MathBackendCPU} from './backend_cpu'; -export {version as version_cpu} from './version'; -export {shared}; - -// Side effects for default initialization of MathBackendCPU -registerBackend('cpu', () => new MathBackendCPU(), 1 /* priority */); diff --git a/tfjs-master/tfjs-backend-cpu/src/cpu_util.ts b/tfjs-master/tfjs-backend-cpu/src/cpu_util.ts deleted file mode 100644 index 28ed23e0f..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/cpu_util.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {TensorInfo, util} from '@tensorflow/tfjs-core'; - -export function assertNotComplex( - tensor: TensorInfo|TensorInfo[], opName: string): void { - if (!Array.isArray(tensor)) { - tensor = [tensor]; - } - tensor.forEach(t => { - if (t != null) { - util.assert( - t.dtype !== 'complex64', - () => `${ - opName} does not support complex64 tensors in the CPU backend.`); - } - }); -} diff --git a/tfjs-master/tfjs-backend-cpu/src/index.ts b/tfjs-master/tfjs-backend-cpu/src/index.ts deleted file mode 100644 index abf89246e..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/index.ts +++ /dev/null @@ -1,20 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// All exports from this package should be in base. -export * from './base'; -import './register_all_kernels'; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Abs.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Abs.ts deleted file mode 100644 index 970838ad4..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Abs.ts +++ /dev/null @@ -1,48 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Abs, AbsInputs, KernelConfig, KernelFunc, TypedArray, util} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; -import {assertNotComplex} from '../cpu_util'; - -export function simpleAbsImpl(vals: TypedArray): Float32Array { - const resultValues = new Float32Array(vals.length); - for (let i = 0; i < vals.length; ++i) { - resultValues[i] = Math.abs(vals[i]); - } - return resultValues; -} - -export const abs = (args: {inputs: AbsInputs, backend: MathBackendCPU}) => { - const {x} = args.inputs; - const cpuBackend = args.backend; - - assertNotComplex(x, 'abs'); - - let resultValues = new Float32Array(util.sizeFromShape(x.shape)); - const values = cpuBackend.data.get(x.dataId).values as TypedArray; - resultValues = simpleAbsImpl(values); - - return cpuBackend.makeOutput(resultValues, x.shape, x.dtype); -}; - -export const absConfig: KernelConfig = { - kernelName: Abs, - backendName: 'cpu', - kernelFunc: abs as unknown as KernelFunc, -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Acos.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Acos.ts deleted file mode 100644 index 1311ac7a4..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Acos.ts +++ /dev/null @@ -1,28 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Acos, KernelConfig} from '@tensorflow/tfjs-core'; - -import {unaryKernelFunc} from '../utils/unary_utils'; - -export const acos = unaryKernelFunc(Acos, (xi) => Math.acos(xi)); - -export const acosConfig: KernelConfig = { - kernelName: Acos, - backendName: 'cpu', - kernelFunc: acos, -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Acosh.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Acosh.ts deleted file mode 100644 index 332eb6f35..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Acosh.ts +++ /dev/null @@ -1,28 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Acosh, KernelConfig} from '@tensorflow/tfjs-core'; - -import {unaryKernelFunc} from '../utils/unary_utils'; - -export const acosh = unaryKernelFunc(Acosh, (xi) => Math.acosh(xi)); - -export const acoshConfig: KernelConfig = { - kernelName: Acosh, - backendName: 'cpu', - kernelFunc: acosh, -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Add.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Add.ts deleted file mode 100644 index 2cd873730..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Add.ts +++ /dev/null @@ -1,36 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Add, KernelConfig} from '@tensorflow/tfjs-core'; - -import {createSimpleBinaryKernelImpl} from '../utils/binary_impl'; -import {binaryKernelFunc, createComplexBinaryKernelImpl} from '../utils/binary_utils'; - -export const addImpl = - createSimpleBinaryKernelImpl(((a: number, b: number) => a + b)); -export const addComplexImpl = - createComplexBinaryKernelImpl(((aReal, aImag, bReal, bImag) => { - return {real: aReal + bReal, imag: aImag + bImag}; - })); - -export const add = binaryKernelFunc(Add, addImpl, addComplexImpl); - -export const addConfig: KernelConfig = { - kernelName: Add, - backendName: 'cpu', - kernelFunc: add -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/AddN.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/AddN.ts deleted file mode 100644 index c43b4d2b6..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/AddN.ts +++ /dev/null @@ -1,48 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {AddN, AddNInputs, buffer, KernelConfig, KernelFunc, Tensor, TensorInfo, TypedArray} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; -import {assertNotComplex} from '../cpu_util'; - -export function addN(args: {inputs: AddNInputs, backend: MathBackendCPU}): - TensorInfo { - const {inputs, backend} = args; - const tensors = inputs as Tensor[]; - - assertNotComplex(inputs, 'addN'); - - const vals = - tensors.map(t => backend.data.get(t.dataId).values as TypedArray); - const outBuf = buffer(tensors[0].shape, tensors[0].dtype as 'float32'); - const outVals = outBuf.values; - for (let i = 0; i < tensors.length; i++) { - const currVals = vals[i]; - for (let j = 0; j < outVals.length; j++) { - outVals[j] += currVals[j]; - } - } - - return backend.makeTensorInfo(outBuf.shape, outBuf.dtype, outBuf.values); -} - -export const addNConfig: KernelConfig = { - kernelName: AddN, - backendName: 'cpu', - kernelFunc: addN as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/All.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/All.ts deleted file mode 100644 index bcf821cf8..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/All.ts +++ /dev/null @@ -1,83 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {All, AllAttrs, AllInputs, backend_util, KernelConfig, KernelFunc, TensorInfo, TypedArray, util} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; -import {assertNotComplex} from '../cpu_util'; -import {reshape} from './Reshape'; -import {transpose} from './Transpose'; - -export function all( - args: {inputs: AllInputs, backend: MathBackendCPU, attrs: AllAttrs}): - TensorInfo { - const {inputs, backend, attrs} = args; - const {x} = inputs; - const {axis, keepDims} = attrs; - - assertNotComplex(x, 'all'); - - const origAxes = util.parseAxisParam(axis, x.shape); - let axes = origAxes; - const permutedAxes = backend_util.getAxesPermutation(axes, x.shape.length); - let $x = x; - if (permutedAxes != null) { - $x = transpose({inputs: {x}, backend, attrs: {perm: permutedAxes}}); - axes = backend_util.getInnerMostAxes(axes.length, x.shape.length); - } - - backend_util.assertAxesAreInnerMostDims('all', axes, $x.shape.length); - const [outShape, reduceShape] = - backend_util.computeOutAndReduceShapes($x.shape, axes); - const reduceSize = util.sizeFromShape(reduceShape); - const vals = util.makeZerosTypedArray(util.sizeFromShape(outShape), $x.dtype); - - const aVals = backend.data.get($x.dataId).values as TypedArray; - for (let i = 0; i < vals.length; ++i) { - const offset = i * reduceSize; - let all = aVals[offset]; - for (let j = 0; j < reduceSize; ++j) { - const value = aVals[offset + j]; - all = all && value; - } - vals[i] = all; - } - - if (permutedAxes != null) { - backend.disposeIntermediateTensorInfo($x); - } - - const result = backend.makeTensorInfo(outShape, $x.dtype, vals); - - if (keepDims) { - const expandedShape = backend_util.expandShapeToKeepDim(outShape, origAxes); - const reshapedResult = - reshape({inputs: {x: result}, backend, attrs: {shape: expandedShape}}); - - backend.disposeIntermediateTensorInfo(result); - - return reshapedResult; - } - - return result; -} - -export const allConfig: KernelConfig = { - kernelName: All, - backendName: 'cpu', - kernelFunc: all as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Any.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Any.ts deleted file mode 100644 index 5f9888dc1..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Any.ts +++ /dev/null @@ -1,83 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Any, AnyAttrs, AnyInputs, backend_util, KernelConfig, KernelFunc, TensorInfo, TypedArray, util} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; -import {assertNotComplex} from '../cpu_util'; -import {reshape} from './Reshape'; -import {transpose} from './Transpose'; - -export function any( - args: {inputs: AnyInputs, backend: MathBackendCPU, attrs: AnyAttrs}): - TensorInfo { - const {inputs, backend, attrs} = args; - const {x} = inputs; - const {axis, keepDims} = attrs; - - assertNotComplex(x, 'any'); - - const origAxes = util.parseAxisParam(axis, x.shape); - let axes = origAxes; - const permutedAxes = backend_util.getAxesPermutation(axes, x.shape.length); - let $x = x; - if (permutedAxes != null) { - $x = transpose({inputs: {x}, backend, attrs: {perm: permutedAxes}}); - axes = backend_util.getInnerMostAxes(axes.length, x.shape.length); - } - - backend_util.assertAxesAreInnerMostDims('any', axes, $x.shape.length); - const [outShape, reduceShape] = - backend_util.computeOutAndReduceShapes($x.shape, axes); - const reduceSize = util.sizeFromShape(reduceShape); - const vals = util.makeZerosTypedArray(util.sizeFromShape(outShape), $x.dtype); - - const aVals = backend.data.get($x.dataId).values as TypedArray; - for (let i = 0; i < vals.length; ++i) { - const offset = i * reduceSize; - let anyVal = aVals[offset]; - for (let j = 0; j < reduceSize; ++j) { - const value = aVals[offset + j]; - anyVal = anyVal || value; - } - vals[i] = anyVal; - } - - if (permutedAxes != null) { - backend.disposeIntermediateTensorInfo($x); - } - - const result = backend.makeTensorInfo(outShape, $x.dtype, vals); - - if (keepDims) { - const expandedShape = backend_util.expandShapeToKeepDim(outShape, origAxes); - const reshapedResult = - reshape({inputs: {x: result}, backend, attrs: {shape: expandedShape}}); - - backend.disposeIntermediateTensorInfo(result); - - return reshapedResult; - } - - return result; -} - -export const anyConfig: KernelConfig = { - kernelName: Any, - backendName: 'cpu', - kernelFunc: any as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/ArgMax.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/ArgMax.ts deleted file mode 100644 index f5d202d23..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/ArgMax.ts +++ /dev/null @@ -1,77 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ArgMax, ArgMaxAttrs, ArgMaxInputs, backend_util, KernelConfig, KernelFunc, TensorInfo, TypedArray, util} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; -import {assertNotComplex} from '../cpu_util'; -import {transpose} from './Transpose'; - -export function argMax( - args: {inputs: ArgMaxInputs, backend: MathBackendCPU, attrs: ArgMaxAttrs}): - TensorInfo { - const {inputs, backend, attrs} = args; - const {x} = inputs; - const {axis} = attrs; - - assertNotComplex(x, 'argMax'); - - let axes = util.parseAxisParam(axis, x.shape); - const permutedAxes = backend_util.getAxesPermutation(axes, x.shape.length); - let $x = x; - const intermediateTensorInfos = []; - if (permutedAxes != null) { - $x = transpose({inputs: {x}, backend, attrs: {perm: permutedAxes}}); - intermediateTensorInfos.push($x); - axes = backend_util.getInnerMostAxes(axes.length, $x.shape.length); - } - - axes = [axes[0]]; - backend_util.assertAxesAreInnerMostDims('argMax', axes, $x.shape.length); - const [outShape, reduceShape] = - backend_util.computeOutAndReduceShapes($x.shape, axes); - - const outSize = util.sizeFromShape(outShape); - const vals = util.makeZerosTypedArray(outSize, 'int32'); - const reduceSize = util.sizeFromShape(reduceShape); - - const aVals = backend.data.get($x.dataId).values as TypedArray; - for (let i = 0; i < vals.length; ++i) { - const offset = i * reduceSize; - let max = aVals[offset]; - let maxIndex = 0; - for (let j = 0; j < reduceSize; ++j) { - const value = aVals[offset + j]; - if (value > max) { - max = value; - maxIndex = j; - } - } - vals[i] = maxIndex; - } - - intermediateTensorInfos.forEach( - t => backend.disposeIntermediateTensorInfo(t)); - - return backend.makeTensorInfo(outShape, 'int32', vals); -} - -export const argMaxConfig: KernelConfig = { - kernelName: ArgMax, - backendName: 'cpu', - kernelFunc: argMax as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/ArgMin.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/ArgMin.ts deleted file mode 100644 index e0c300105..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/ArgMin.ts +++ /dev/null @@ -1,77 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ArgMin, ArgMinAttrs, ArgMinInputs, backend_util, KernelConfig, KernelFunc, TensorInfo, TypedArray, util} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; -import {assertNotComplex} from '../cpu_util'; -import {transpose} from './Transpose'; - -export function argMin( - args: {inputs: ArgMinInputs, backend: MathBackendCPU, attrs: ArgMinAttrs}): - TensorInfo { - const {inputs, backend, attrs} = args; - const {x} = inputs; - const {axis} = attrs; - - assertNotComplex(x, 'argMin'); - - let axes = util.parseAxisParam(axis, x.shape); - const permutedAxes = backend_util.getAxesPermutation(axes, x.shape.length); - let $x = x; - const intermediateTensorInfos = []; - if (permutedAxes != null) { - $x = transpose({inputs: {x}, backend, attrs: {perm: permutedAxes}}); - intermediateTensorInfos.push($x); - axes = backend_util.getInnerMostAxes(axes.length, $x.shape.length); - } - - axes = [axes[0]]; - backend_util.assertAxesAreInnerMostDims('argMin', axes, $x.shape.length); - const [outShape, reduceShape] = - backend_util.computeOutAndReduceShapes($x.shape, axes); - - const outSize = util.sizeFromShape(outShape); - const vals = util.makeZerosTypedArray(outSize, 'int32'); - const reduceSize = util.sizeFromShape(reduceShape); - - const aVals = backend.data.get($x.dataId).values as TypedArray; - for (let i = 0; i < vals.length; ++i) { - const offset = i * reduceSize; - let min = aVals[offset]; - let minIndex = 0; - for (let j = 0; j < reduceSize; ++j) { - const value = aVals[offset + j]; - if (value < min) { - min = value; - minIndex = j; - } - } - vals[i] = minIndex; - } - - intermediateTensorInfos.forEach( - t => backend.disposeIntermediateTensorInfo(t)); - - return backend.makeTensorInfo(outShape, 'int32', vals); -} - -export const argMinConfig: KernelConfig = { - kernelName: ArgMin, - backendName: 'cpu', - kernelFunc: argMin as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Asin.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Asin.ts deleted file mode 100644 index e2cd8f9bb..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Asin.ts +++ /dev/null @@ -1,28 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Asin, KernelConfig} from '@tensorflow/tfjs-core'; - -import {unaryKernelFunc} from '../utils/unary_utils'; - -export const asin = unaryKernelFunc(Asin, (xi) => Math.asin(xi)); - -export const asinConfig: KernelConfig = { - kernelName: Asin, - backendName: 'cpu', - kernelFunc: asin, -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Asinh.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Asinh.ts deleted file mode 100644 index 292de1968..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Asinh.ts +++ /dev/null @@ -1,28 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Asinh, KernelConfig} from '@tensorflow/tfjs-core'; - -import {unaryKernelFunc} from '../utils/unary_utils'; - -export const asinh = unaryKernelFunc(Asinh, (xi) => Math.asinh(xi)); - -export const asinhConfig: KernelConfig = { - kernelName: Asinh, - backendName: 'cpu', - kernelFunc: asinh, -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Atan.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Atan.ts deleted file mode 100644 index 1a51b3d23..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Atan.ts +++ /dev/null @@ -1,28 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Atan, KernelConfig} from '@tensorflow/tfjs-core'; - -import {unaryKernelFunc} from '../utils/unary_utils'; - -export const atan = unaryKernelFunc(Atan, (xi) => Math.atan(xi)); - -export const atanConfig: KernelConfig = { - kernelName: Atan, - backendName: 'cpu', - kernelFunc: atan, -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Atan2.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Atan2.ts deleted file mode 100644 index b434a55db..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Atan2.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Atan2, KernelConfig} from '@tensorflow/tfjs-core'; -import {createSimpleBinaryKernelImpl} from '../utils/binary_impl'; -import {binaryKernelFunc} from '../utils/binary_utils'; - -export const atan2Impl = createSimpleBinaryKernelImpl( - (aValue, bValue) => Math.atan2(aValue as number, bValue as number)); - -export const atan2 = binaryKernelFunc(Atan2, atan2Impl); - -export const atan2Config: KernelConfig = { - kernelName: Atan2, - backendName: 'cpu', - kernelFunc: atan2, -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Atanh.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Atanh.ts deleted file mode 100644 index 7306d1321..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Atanh.ts +++ /dev/null @@ -1,28 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Atanh, KernelConfig} from '@tensorflow/tfjs-core'; - -import {unaryKernelFunc} from '../utils/unary_utils'; - -export const atanh = unaryKernelFunc(Atanh, (xi) => Math.atanh(xi)); - -export const atanhConfig: KernelConfig = { - kernelName: Atanh, - backendName: 'cpu', - kernelFunc: atanh, -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/AvgPool.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/AvgPool.ts deleted file mode 100644 index 0b5210f1c..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/AvgPool.ts +++ /dev/null @@ -1,61 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {AvgPool, AvgPoolAttrs, AvgPoolInputs, backend_util, KernelConfig, KernelFunc, TensorInfo, TypedArray, util} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; -import {assertNotComplex} from '../cpu_util'; -import {pool} from '../utils/pool_utils'; -import {identity} from './Identity'; - -export function avgPool( - args: - {inputs: AvgPoolInputs, backend: MathBackendCPU, attrs: AvgPoolAttrs}): - TensorInfo { - const {inputs, backend, attrs} = args; - const {x} = inputs; - assertNotComplex(x, 'avgPool'); - const {filterSize, strides, pad, dimRoundingMode} = attrs; - const dilations = 1; - - util.assert( - backend_util.eitherStridesOrDilationsAreOne(strides, dilations), - () => 'Error in avgPool: Either strides or dilations must be 1. ' + - `Got strides ${strides} and dilations '${dilations}'`); - - const convInfo = backend_util.computePool2DInfo( - x.shape as [number, number, number, number], filterSize, strides, - dilations, pad, dimRoundingMode); - let res: TensorInfo; - - if (convInfo.filterWidth === 1 && convInfo.filterHeight === 1 && - util.arraysEqual(convInfo.inShape, convInfo.outShape)) { - res = identity({inputs: {x}, backend}); - } else { - const xValues = backend.data.get(x.dataId).values as TypedArray; - const strides = util.computeStrides(x.shape); - const buffer = pool(xValues, x.shape, x.dtype, strides, convInfo, 'avg'); - res = backend.makeTensorInfo( - convInfo.outShape, x.dtype, buffer.values as TypedArray); - } - return res; -} - -export const avgPoolConfig: KernelConfig = { - kernelName: AvgPool, - backendName: 'cpu', - kernelFunc: avgPool as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/AvgPool3D.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/AvgPool3D.ts deleted file mode 100644 index 9cf67f4df..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/AvgPool3D.ts +++ /dev/null @@ -1,50 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {AvgPool3D, AvgPool3DAttrs, AvgPool3DInputs, backend_util, KernelConfig, KernelFunc, TensorInfo, TypedArray, util} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; -import {assertNotComplex} from '../cpu_util'; -import {pool3d} from '../utils/pool_utils'; - -export function avgPool3D(args: { - inputs: AvgPool3DInputs, - backend: MathBackendCPU, - attrs: AvgPool3DAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {x} = inputs; - const {filterSize, strides, pad, dimRoundingMode, dataFormat} = attrs; - - assertNotComplex(x, 'avgPool3d'); - - const convInfo = backend_util.computePool3DInfo( - x.shape as [number, number, number, number, number], filterSize, strides, - 1 /* dilations */, pad, dimRoundingMode, dataFormat); - - const xValues = backend.data.get(x.dataId).values as TypedArray; - const outBuf = pool3d( - xValues, x.shape, x.dtype, util.computeStrides(x.shape), convInfo, 'avg'); - - return backend.makeTensorInfo(outBuf.shape, 'float32', outBuf.values); -} - -export const avgPool3DConfig: KernelConfig = { - kernelName: AvgPool3D, - backendName: 'cpu', - kernelFunc: avgPool3D as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/AvgPool3DGrad.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/AvgPool3DGrad.ts deleted file mode 100644 index f1586a8f0..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/AvgPool3DGrad.ts +++ /dev/null @@ -1,112 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {AvgPool3DGrad, AvgPool3DGradAttrs, AvgPool3DGradInputs, backend_util, buffer, KernelConfig, KernelFunc, Rank, TensorInfo} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; -import {assertNotComplex} from '../cpu_util'; - -export function avgPool3DGrad(args: { - inputs: AvgPool3DGradInputs, - backend: MathBackendCPU, - attrs: AvgPool3DGradAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {dy, input} = inputs; - const {filterSize, strides, pad, dimRoundingMode} = attrs; - - assertNotComplex([dy, input], 'avgPool3DGrad'); - - const convInfo = backend_util.computePool3DInfo( - input.shape as [number, number, number, number, number], filterSize, - strides, 1 /* dilations */, pad, dimRoundingMode); - - const strideDepth = convInfo.strideDepth; - const strideHeight = convInfo.strideHeight; - const strideWidth = convInfo.strideWidth; - const filterDepth = convInfo.filterDepth; - const filterHeight = convInfo.filterHeight; - const filterWidth = convInfo.filterWidth; - const dilationDepth = convInfo.dilationDepth; - const dilationHeight = convInfo.dilationHeight; - const dilationWidth = convInfo.dilationWidth; - const effectiveFilterDepth = convInfo.effectiveFilterDepth; - const effectiveFilterHeight = convInfo.effectiveFilterHeight; - const effectiveFilterWidth = convInfo.effectiveFilterWidth; - const padFront = effectiveFilterDepth - 1 - convInfo.padInfo.front; - const padLeft = effectiveFilterWidth - 1 - convInfo.padInfo.left; - const padTop = effectiveFilterHeight - 1 - convInfo.padInfo.top; - const dx = buffer(input.shape, 'float32'); - - const avgMultiplier = 1 / (filterDepth * filterHeight * filterWidth); - - const dyBuf = backend.bufferSync(dy); - - for (let batch = 0; batch < convInfo.batchSize; ++batch) { - for (let channel = 0; channel < convInfo.inChannels; ++channel) { - for (let dxDepth = 0; dxDepth < convInfo.inDepth; ++dxDepth) { - for (let dxRow = 0; dxRow < convInfo.inHeight; ++dxRow) { - for (let dxCol = 0; dxCol < convInfo.inWidth; ++dxCol) { - // Shader code begins. - const dyDepthCorner = dxDepth - padFront; - const dyRowCorner = dxRow - padTop; - const dyColCorner = dxCol - padLeft; - let dotProd = 0; - for (let wDepth = 0; wDepth < effectiveFilterDepth; - wDepth += dilationDepth) { - const dyDepth = (dyDepthCorner + wDepth) / strideDepth; - if (dyDepth < 0 || dyDepth >= convInfo.outDepth || - Math.floor(dyDepth) !== dyDepth) { - continue; - } - for (let wRow = 0; wRow < effectiveFilterHeight; - wRow += dilationHeight) { - const dyRow = (dyRowCorner + wRow) / strideHeight; - if (dyRow < 0 || dyRow >= convInfo.outHeight || - Math.floor(dyRow) !== dyRow) { - continue; - } - for (let wCol = 0; wCol < effectiveFilterWidth; - wCol += dilationWidth) { - const dyCol = (dyColCorner + wCol) / strideWidth; - if (dyCol < 0 || dyCol >= convInfo.outWidth || - Math.floor(dyCol) !== dyCol) { - continue; - } - - const pixel = - dyBuf.get(batch, dyDepth, dyRow, dyCol, channel); - dotProd += pixel; - } - } - } - dx.set( - dotProd * avgMultiplier, batch, dxDepth, dxRow, dxCol, channel); - } - } - } - } - } - - return backend.makeTensorInfo(dx.shape, dx.dtype, dx.values); -} - -export const avgPool3DGradConfig: KernelConfig = { - kernelName: AvgPool3DGrad, - backendName: 'cpu', - kernelFunc: avgPool3DGrad as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/AvgPoolGrad.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/AvgPoolGrad.ts deleted file mode 100644 index 4e629672e..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/AvgPoolGrad.ts +++ /dev/null @@ -1,92 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {AvgPoolGrad, AvgPoolGradAttrs, AvgPoolGradInputs, backend_util, buffer, KernelConfig, KernelFunc, Rank, TensorInfo} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; -import {assertNotComplex} from '../cpu_util'; - -export function avgPoolGrad(args: { - inputs: AvgPoolGradInputs, - backend: MathBackendCPU, - attrs: AvgPoolGradAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {dy, input} = inputs; - const x = input; - assertNotComplex([dy, input], 'avgPoolGrad'); - const {filterSize, strides, pad} = attrs; - - const convInfo = backend_util.computePool2DInfo( - x.shape as [number, number, number, number], filterSize, strides, - 1 /* dilations */, pad); - const strideHeight = convInfo.strideHeight; - const strideWidth = convInfo.strideWidth; - const filterHeight = convInfo.filterHeight; - const filterWidth = convInfo.filterWidth; - const dilationHeight = convInfo.dilationHeight; - const dilationWidth = convInfo.dilationWidth; - const effectiveFilterHeight = convInfo.effectiveFilterHeight; - const effectiveFilterWidth = convInfo.effectiveFilterWidth; - const padLeft = effectiveFilterWidth - 1 - convInfo.padInfo.left; - const padTop = effectiveFilterHeight - 1 - convInfo.padInfo.top; - const dx = - buffer(x.shape as [number, number, number, number], 'float32'); - - const avgMultiplier = 1 / (filterHeight * filterWidth); - - const dyData = backend.data.get(dy.dataId).values as Float32Array; - const dyBuf = buffer( - dy.shape as [number, number, number, number], 'float32', dyData); - - for (let b = 0; b < convInfo.batchSize; ++b) { - for (let d = 0; d < convInfo.inChannels; ++d) { - for (let dxR = 0; dxR < convInfo.inHeight; ++dxR) { - for (let dxC = 0; dxC < convInfo.inWidth; ++dxC) { - // Shader code begins. - const dyRCorner = dxR - padTop; - const dyCCorner = dxC - padLeft; - let dotProd = 0; - for (let wR = 0; wR < effectiveFilterHeight; wR += dilationHeight) { - const dyR = (dyRCorner + wR) / strideHeight; - if (dyR < 0 || dyR >= convInfo.outHeight || - Math.floor(dyR) !== dyR) { - continue; - } - for (let wC = 0; wC < effectiveFilterWidth; wC += dilationWidth) { - const dyC = (dyCCorner + wC) / strideWidth; - if (dyC < 0 || dyC >= convInfo.outWidth || - Math.floor(dyC) !== dyC) { - continue; - } - - const pixel = dyBuf.get(b, dyR, dyC, d); - dotProd += pixel; - } - } - dx.set(dotProd * avgMultiplier, b, dxR, dxC, d); - } - } - } - } - return backend.makeTensorInfo(dx.shape, dx.dtype, dx.values); -} - -export const avgPoolGradConfig: KernelConfig = { - kernelName: AvgPoolGrad, - backendName: 'cpu', - kernelFunc: avgPoolGrad as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/BatchMatMul.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/BatchMatMul.ts deleted file mode 100644 index 22a6a01ac..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/BatchMatMul.ts +++ /dev/null @@ -1,139 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {BatchMatMul, BatchMatMulAttrs, BatchMatMulInputs, broadcast_util, buffer, KernelConfig, KernelFunc, TypedArray, util} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; -import {assertNotComplex} from '../cpu_util'; - -import {reshape} from './Reshape'; - -export function batchMatMul(args: { - inputs: BatchMatMulInputs, - attrs: BatchMatMulAttrs, - backend: MathBackendCPU -}) { - const {inputs, backend, attrs} = args; - const {a, b} = inputs; - const {transposeA, transposeB} = attrs; - - assertNotComplex([a, b], 'matMul'); - - const aRank = a.shape.length; - const bRank = b.shape.length; - - const innerShapeA = transposeA ? a.shape[aRank - 2] : a.shape[aRank - 1]; - const innerShapeB = transposeB ? b.shape[bRank - 1] : b.shape[bRank - 2]; - - const outerShapeA = transposeA ? a.shape[aRank - 1] : a.shape[aRank - 2]; - const outerShapeB = transposeB ? b.shape[bRank - 2] : b.shape[bRank - 1]; - - const outerDimsA = a.shape.slice(0, -2); - const outerDimsB = b.shape.slice(0, -2); - - const batchDimA = util.sizeFromShape(outerDimsA); - const batchDimB = util.sizeFromShape(outerDimsB); - - const outShapeOuterDims = broadcast_util.assertAndGetBroadcastShape( - a.shape.slice(0, -2), b.shape.slice(0, -2)); - const outShape = outShapeOuterDims.concat([outerShapeA, outerShapeB]); - - util.assert( - innerShapeA === innerShapeB, - () => `Error in matMul: inner shapes (${innerShapeA}) and (` + - `${innerShapeB}) of Tensors with shapes ${a.shape} and ` + - `${b.shape} and transposeA=${transposeA}` + - ` and transposeB=${transposeB} must match.`); - - const a3dShape = transposeA ? [batchDimA, innerShapeA, outerShapeA] : - [batchDimA, outerShapeA, innerShapeA]; - const b3dShape = transposeB ? [batchDimB, outerShapeB, innerShapeB] : - [batchDimB, innerShapeB, outerShapeB]; - - // The rest of the implementation is designed to operate on rank-3 tensors - const a3d = reshape({inputs: {x: a}, backend, attrs: {shape: a3dShape}}); - const b3d = reshape({inputs: {x: b}, backend, attrs: {shape: b3dShape}}); - - const sharedDim = transposeA ? a3d.shape[1] : a3d.shape[2]; - const leftDim = transposeA ? a3d.shape[2] : a3d.shape[1]; - const rightDim = transposeB ? b3d.shape[1] : b3d.shape[2]; - const batchDim = Math.max(batchDimA, batchDimB); - - const a3dValues = backend.data.get(a3d.dataId).values as TypedArray; - const b3dValues = backend.data.get(b3d.dataId).values as TypedArray; - - const a3dStrides = util.computeStrides(a3d.shape); - const b3dStrides = util.computeStrides(b3d.shape); - - const [aBatch, aOuterStep, aInnerStep] = transposeA ? - [a3dStrides[0], 1, a3dStrides[1]] : - [a3dStrides[0], a3dStrides[1], 1]; - const [bInnerStep, bOuterStep, bBatch] = transposeB ? - [1, b3dStrides[1], b3dStrides[0]] : - [b3dStrides[1], 1, b3dStrides[0]]; - - const size = leftDim * rightDim; - const result = buffer([batchDim, leftDim, rightDim], a3d.dtype); - - const resVals = result.values as TypedArray; - const blockSize = backend.blockSize; - - for (let bi = 0; bi < batchDim; bi++) { - const batchIndexA = bi % batchDimA; - const batchIndexB = bi % batchDimB; - for (let i0 = 0; i0 < leftDim; i0 += blockSize) { - // for when blockSize doesn't evenly divide the input - const iBlock = Math.min(i0 + blockSize, leftDim); - for (let j0 = 0; j0 < rightDim; j0 += blockSize) { - const jBlock = Math.min(j0 + blockSize, rightDim); - for (let k0 = 0; k0 < sharedDim; k0 += blockSize) { - const kBlock = Math.min(k0 + blockSize, sharedDim); - - for (let i = i0; i < iBlock; i++) { - for (let j = j0; j < jBlock; j++) { - let sum = 0.0; - - for (let k = k0; k < kBlock; k++) { - const aVal = - // tslint:disable-next-line: max-line-length - a3dValues[batchIndexA * aBatch + i * aOuterStep + k * aInnerStep]; - const bVal = - // tslint:disable-next-line: max-line-length - b3dValues[k * bInnerStep + j * bOuterStep + batchIndexB * bBatch]; - sum += aVal * bVal; - } - resVals[bi * size + (i * rightDim + j)] += sum; - } - } - } - } - } - } - - backend.disposeIntermediateTensorInfo(a3d); - backend.disposeIntermediateTensorInfo(b3d); - - // set correct shape on output. - return backend.makeTensorInfo( - outShape, result.dtype, result.values as TypedArray); -} - -export const batchMatMulConfig: KernelConfig = { - kernelName: BatchMatMul, - backendName: 'cpu', - kernelFunc: batchMatMul as unknown as KernelFunc, -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/BatchNorm.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/BatchNorm.ts deleted file mode 100644 index a7af6f5a1..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/BatchNorm.ts +++ /dev/null @@ -1,94 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {FusedBatchNorm, FusedBatchNormAttrs, FusedBatchNormInputs, KernelConfig, KernelFunc, TensorInfo, TypedArray, util} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; -import {assertNotComplex} from '../cpu_util'; - -export function batchNorm(args: { - inputs: FusedBatchNormInputs, - backend: MathBackendCPU, - attrs: FusedBatchNormAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {x, scale, offset, mean, variance} = inputs; - - util.assert( - mean.shape.length === variance.shape.length, - () => 'Batch normalization gradient requires mean and variance to have ' + - 'equal ranks.'); - util.assert( - offset == null || mean.shape.length === offset.shape.length, - () => 'Batch normalization gradient requires mean and offset to have ' + - 'equal ranks.'); - util.assert( - scale == null || mean.shape.length === scale.shape.length, - () => 'Batch normalization gradient requires mean and scale to have ' + - 'equal ranks.'); - - assertNotComplex([x, mean, variance, scale, offset], 'batchNorm'); - - let {varianceEpsilon} = attrs; - if (varianceEpsilon == null) { - varianceEpsilon = 0.001; - } - - const xVals = backend.data.get(x.dataId).values as TypedArray; - const mVals = backend.data.get(mean.dataId).values as TypedArray; - const varVals = backend.data.get(variance.dataId).values as TypedArray; - const sVals = scale ? backend.data.get(scale.dataId).values as TypedArray : - new Float32Array([1]); - const offVals = offset ? - backend.data.get(offset.dataId).values as TypedArray : - new Float32Array([0]); - const outVals = new Float32Array(xVals.length); - - const offValsLength = offVals.length; - const sValsLength = sVals.length; - const varValsLength = varVals.length; - const mValsLength = mVals.length; - - let offi = 0; - let mi = 0; - let si = 0; - let vi = 0; - for (let i = 0; i < xVals.length; ++i) { - outVals[i] = offVals[offi++] + - (xVals[i] - mVals[mi++]) * sVals[si++] / - Math.sqrt(varVals[vi++] + varianceEpsilon); - if (offi >= offValsLength) { - offi = 0; - } - if (mi >= mValsLength) { - mi = 0; - } - if (si >= sValsLength) { - si = 0; - } - if (vi >= varValsLength) { - vi = 0; - } - } - return backend.makeTensorInfo(x.shape, x.dtype, outVals); -} - -export const batchNormConfig: KernelConfig = { - kernelName: FusedBatchNorm, - backendName: 'cpu', - kernelFunc: batchNorm as unknown as KernelFunc, -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/BatchToSpaceND.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/BatchToSpaceND.ts deleted file mode 100644 index 30106a948..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/BatchToSpaceND.ts +++ /dev/null @@ -1,70 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, BatchToSpaceND, BatchToSpaceNDAttrs, BatchToSpaceNDInputs, KernelConfig, KernelFunc, TensorInfo} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; -import {assertNotComplex} from '../cpu_util'; -import {reshape} from './Reshape'; -import {slice} from './Slice'; -import {transpose} from './Transpose'; - -export function batchToSpaceND(args: { - inputs: BatchToSpaceNDInputs, - backend: MathBackendCPU, - attrs: BatchToSpaceNDAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {x} = inputs; - const {blockShape, crops} = attrs; - - assertNotComplex([x], 'batchToSpaceND'); - - const prod = blockShape.reduce((a, b) => a * b); - - const reshaped = backend_util.getReshaped(x.shape, blockShape, prod); - const permuted = backend_util.getPermuted(reshaped.length, blockShape.length); - const reshapedPermuted = - backend_util.getReshapedPermuted(x.shape, blockShape, prod); - const sliceBeginCoords = - backend_util.getSliceBeginCoords(crops, blockShape.length); - const sliceSize = - backend_util.getSliceSize(reshapedPermuted, crops, blockShape.length); - - const xReshaped = reshape({inputs: {x}, backend, attrs: {shape: reshaped}}); - const xTransposed = - transpose({inputs: {x: xReshaped}, backend, attrs: {perm: permuted}}); - const xTransposedReshaped = reshape( - {inputs: {x: xTransposed}, backend, attrs: {shape: reshapedPermuted}}); - const result = slice({ - inputs: {x: xTransposedReshaped}, - backend, - attrs: {begin: sliceBeginCoords, size: sliceSize} - }); - - backend.disposeIntermediateTensorInfo(xReshaped); - backend.disposeIntermediateTensorInfo(xTransposed); - backend.disposeIntermediateTensorInfo(xTransposedReshaped); - - return result; -} - -export const batchToSpaceNDConfig: KernelConfig = { - kernelName: BatchToSpaceND, - backendName: 'cpu', - kernelFunc: batchToSpaceND as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Bincount.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Bincount.ts deleted file mode 100644 index 718b59df8..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Bincount.ts +++ /dev/null @@ -1,45 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Bincount, BincountAttrs, BincountInputs, KernelConfig, KernelFunc, TensorInfo, TypedArray} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; -import {bincountImpl} from './Bincount_impl'; - -export function bincount(args: { - inputs: BincountInputs, - backend: MathBackendCPU, - attrs: BincountAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {x, weights} = inputs; - const {size} = attrs; - - const xVals = backend.data.get(x.dataId).values as TypedArray; - const weightsVals = backend.data.get(weights.dataId).values as TypedArray; - - const outVals = - bincountImpl(xVals, weightsVals, weights.dtype, weights.shape, size); - - return backend.makeTensorInfo([size], weights.dtype, outVals); -} - -export const bincountConfig: KernelConfig = { - kernelName: Bincount, - backendName: 'cpu', - kernelFunc: bincount as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Bincount_impl.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Bincount_impl.ts deleted file mode 100644 index efed2861e..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Bincount_impl.ts +++ /dev/null @@ -1,78 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {buffer, DataType, Rank, TensorBuffer, TypedArray, util} from '@tensorflow/tfjs-core'; - -export function bincountImpl( - xVals: TypedArray, weightsVals: TypedArray, weightsDtype: DataType, - weightsShape: number[], size: number): TypedArray { - const weightsSize = util.sizeFromShape(weightsShape); - const outVals = util.makeZerosTypedArray(size, weightsDtype) as TypedArray; - - for (let i = 0; i < xVals.length; i++) { - const value = xVals[i]; - if (value < 0) { - throw new Error('Input x must be non-negative!'); - } - - if (value >= size) { - continue; - } - - if (weightsSize > 0) { - outVals[value] += weightsVals[i]; - } else { - outVals[value] += 1; - } - } - - return outVals; -} - -export function bincountReduceImpl( - xBuf: TensorBuffer, weightsBuf: TensorBuffer, size: number, - binaryOutput = false): TensorBuffer { - const numRows = xBuf.shape[0]; - const numCols = xBuf.shape[1]; - - const outBuf = buffer([numRows, size], weightsBuf.dtype); - - for (let i = 0; i < numRows; i++) { - for (let j = 0; j < numCols; j++) { - const value = xBuf.get(i, j); - if (value < 0) { - throw new Error('Input x must be non-negative!'); - } - - if (value >= size) { - continue; - } - - if (binaryOutput) { - outBuf.set(1, i, value); - } else { - if (weightsBuf.size > 0) { - outBuf.set(outBuf.get(i, value) + weightsBuf.get(i, j), i, value); - } else { - outBuf.set(outBuf.get(i, value) + 1, i, value); - } - } - } - } - - return outBuf as TensorBuffer; -} diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/BitwiseAnd.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/BitwiseAnd.ts deleted file mode 100644 index 899f5c401..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/BitwiseAnd.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @license - * Copyright 2023 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {BitwiseAnd, KernelConfig} from '@tensorflow/tfjs-core'; - -import {createSimpleBinaryKernelImpl} from '../utils/binary_impl'; -import {binaryKernelFunc} from '../utils/binary_utils'; - -export const bitwiseAndImpl = - createSimpleBinaryKernelImpl(((a: number, b: number) => a & b)); - -export const bitwiseAnd = binaryKernelFunc(BitwiseAnd, bitwiseAndImpl); - -export const bitwiseAndConfig: KernelConfig = { - kernelName: BitwiseAnd, - backendName: 'cpu', - kernelFunc: bitwiseAnd -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/BroadcastArgs.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/BroadcastArgs.ts deleted file mode 100644 index 7082b4a58..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/BroadcastArgs.ts +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, BroadcastArgs, BroadcastArgsInputs, KernelConfig, TensorInfo, TypedArray} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; - -export function broadcastArgs(args: { - inputs: BroadcastArgsInputs, - backend: MathBackendCPU, -}): TensorInfo { - const {inputs, backend} = args; - const {s0, s1} = inputs; - - const s0Vals = backend.data.get(s0.dataId).values as TypedArray; - const s1Vals = backend.data.get(s1.dataId).values as TypedArray; - - const broadcastShape = backend_util.assertAndGetBroadcastShape( - Array.from(s0Vals), Array.from(s1Vals)); - - return backend.makeTensorInfo( - [broadcastShape.length], 'int32', Int32Array.from(broadcastShape)); -} - -export const broadcastArgsConfig: KernelConfig = { - kernelName: BroadcastArgs, - backendName: 'cpu', - kernelFunc: broadcastArgs -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Cast.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Cast.ts deleted file mode 100644 index 6f0e916f0..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Cast.ts +++ /dev/null @@ -1,101 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {Cast, CastAttrs, CastInputs, DataType, KernelConfig, KernelFunc, TensorInfo, TypedArray, util} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; -import {createSimpleBinaryKernelImpl} from '../utils/binary_impl'; -import {zeros} from '../utils/zeros_impl'; - -import {complex} from './Complex'; -import {identity} from './Identity'; -import {real} from './Real'; - -export function castImpl( - values: TypedArray, shape: number[], inputType: DataType, - dtype: DataType): [number[], DataType, TypedArray] { - if (dtype === 'int32') { - const resultValues = Int32Array.from(values); - return [shape, 'int32', resultValues]; - } - - if (dtype === 'bool') { - // This is essentially the result of notEqual(x, 0). We avoid using - // kernel notEqual to avoid circular dependency, i.e. binary_utils -> - // cast -> notEqual -> binary_utils. - const zero = util.toTypedArray([0], inputType); - - const [resultData, resultShape] = createSimpleBinaryKernelImpl( - (a, b) => (a !== b) ? 1 : 0)(shape, [], values, zero, 'bool'); - - return [resultShape, 'bool', resultData]; - } - throw new Error(`Error in Cast: failed to cast ${inputType} to ${dtype}`); -} - -export function cast( - args: {inputs: CastInputs, backend: MathBackendCPU, attrs: CastAttrs}): - TensorInfo { - const {inputs, backend, attrs} = args; - const {x} = inputs; - const {dtype} = attrs; - - // Casting to complex64. - if (dtype === 'complex64') { - if (x.dtype === 'complex64') { - return identity({inputs: {x}, backend}); - } - - const zerosTensorInfo = zeros(backend, x.shape, x.dtype); - const floatX = cast({inputs: {x}, backend, attrs: {dtype: 'float32'}}); - - const result = - complex({inputs: {real: floatX, imag: zerosTensorInfo}, backend}); - - backend.disposeIntermediateTensorInfo(zerosTensorInfo); - backend.disposeIntermediateTensorInfo(floatX); - - return result; - } - - // Casting from complex64 - if (x.dtype === 'complex64') { - const realPart = real({inputs: {input: x}, backend}); - const result = cast({inputs: {x: realPart}, backend, attrs: {dtype}}); - - backend.disposeIntermediateTensorInfo(realPart); - - return result; - } - - if (!util.hasEncodingLoss(x.dtype, dtype)) { - // We don't change the underlying data, since we cast to higher - // precision. - const result = identity({inputs: {x}, backend}); - return {dataId: result.dataId, shape: result.shape, dtype}; - } - - const values = backend.data.get(x.dataId).values as TypedArray; - const [resultShape, resultType, resultData] = - castImpl(values, x.shape, x.dtype, dtype); - return backend.makeTensorInfo(resultShape, resultType, resultData); -} - -export const castConfig: KernelConfig = { - kernelName: Cast, - backendName: 'cpu', - kernelFunc: cast as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Ceil.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Ceil.ts deleted file mode 100644 index 527049139..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Ceil.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Ceil, KernelConfig} from '@tensorflow/tfjs-core'; - -import {createSimpleUnaryImpl} from '../utils/unary_impl'; -import {unaryKernelFuncFromImpl} from '../utils/unary_utils'; - -export const ceilImpl = createSimpleUnaryImpl((xi) => Math.ceil(xi)); -export const ceil = unaryKernelFuncFromImpl(Ceil, ceilImpl); - -export const ceilConfig: KernelConfig = { - kernelName: Ceil, - backendName: 'cpu', - kernelFunc: ceil, -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/ClipByValue.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/ClipByValue.ts deleted file mode 100644 index 3c26ef486..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/ClipByValue.ts +++ /dev/null @@ -1,34 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ClipByValue, ClipByValueAttrs, KernelConfig} from '@tensorflow/tfjs-core'; - -import {unaryKernelFunc} from '../utils/unary_utils'; - -export const clipByValue = unaryKernelFunc(ClipByValue, (xi, attrs) => { - const clipAttrs = attrs as unknown as ClipByValueAttrs; - if (xi > clipAttrs.clipValueMax) { - return clipAttrs.clipValueMax; - } - return xi < clipAttrs.clipValueMin ? clipAttrs.clipValueMin : xi; -}); - -export const clipByValueConfig: KernelConfig = { - kernelName: ClipByValue, - backendName: 'cpu', - kernelFunc: clipByValue, -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Complex.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Complex.ts deleted file mode 100644 index ed3b73355..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Complex.ts +++ /dev/null @@ -1,49 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Complex, ComplexInputs, KernelConfig, KernelFunc, TensorInfo, TypedArray} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; - -export function complex(args: {inputs: ComplexInputs, backend: MathBackendCPU}): - TensorInfo { - const {inputs, backend} = args; - const {real, imag} = inputs; - - const realVals = backend.data.get(real.dataId).values as TypedArray; - const imagVals = backend.data.get(imag.dataId).values as TypedArray; - - const complexInfo = backend.makeTensorInfo(real.shape, 'complex64'); - - const complex = backend.data.get(complexInfo.dataId); - - // The complex tensor owns the underlying real and imag tensorInfos, only the - // complex tensor tracks refCount, when complexData is disposed the - // underlying tensorData will be disposed. - complex.complexTensorInfos = { - real: backend.makeTensorInfo(real.shape, 'float32', realVals), - imag: backend.makeTensorInfo(imag.shape, 'float32', imagVals) - }; - - return complexInfo; -} - -export const complexConfig: KernelConfig = { - kernelName: Complex, - backendName: 'cpu', - kernelFunc: complex as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/ComplexAbs.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/ComplexAbs.ts deleted file mode 100644 index 23133dd6c..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/ComplexAbs.ts +++ /dev/null @@ -1,45 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ComplexAbs, ComplexAbsInputs, KernelConfig, KernelFunc, util} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; - -export const complexAbs = - (args: {inputs: ComplexAbsInputs, backend: MathBackendCPU}) => { - const {x} = args.inputs; - const cpuBackend = args.backend; - const resultValues = new Float32Array(util.sizeFromShape(x.shape)); - const complexVals = cpuBackend.data.get(x.dataId); - const real = complexVals.complexTensorInfos.real; - const imag = complexVals.complexTensorInfos.imag; - const realVals = cpuBackend.data.get(real.dataId).values as Float32Array; - const imagVals = cpuBackend.data.get(imag.dataId).values as Float32Array; - for (let i = 0; i < realVals.length; i++) { - const real = realVals[i]; - const imag = imagVals[i]; - resultValues[i] = Math.hypot(real, imag); - } - - return cpuBackend.makeOutput(resultValues, x.shape, 'float32'); - }; - -export const complexAbsConfig: KernelConfig = { - kernelName: ComplexAbs, - backendName: 'cpu', - kernelFunc: complexAbs as unknown as KernelFunc, -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Complex_test.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Complex_test.ts deleted file mode 100644 index 865610946..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Complex_test.ts +++ /dev/null @@ -1,283 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '@tensorflow/tfjs-core'; -import {test_util} from '@tensorflow/tfjs-core'; - -const {expectArraysClose} = test_util; -// tslint:disable-next-line: no-imports-from-dist -import {describeWithFlags, ALL_ENVS} from '@tensorflow/tfjs-core/dist/jasmine_util'; - -describeWithFlags('Complex.', ALL_ENVS, () => { - it('memory usage.', async () => { - let numTensors = tf.memory().numTensors; - let numDataIds = tf.engine().backend.numDataIds(); - const startTensors = numTensors; - const startDataIds = numDataIds; - - const real1 = tf.tensor1d([1]); - const imag1 = tf.tensor1d([2]); - - // 2 new Tensors: real1, imag1. - expect(tf.memory().numTensors).toBe(numTensors + 2); - expect(tf.engine().backend.numDataIds()).toBe(numDataIds + 2); - numTensors = tf.memory().numTensors; - numDataIds = tf.engine().backend.numDataIds(); - - const complex1 = tf.complex(real1, imag1); - - // 1 new Tensor and 3 new TensorData for complex, real and imag. - expect(tf.memory().numTensors).toBe(numTensors + 1); - expect(tf.engine().backend.numDataIds()).toBe(numDataIds + 3); - numTensors = tf.memory().numTensors; - numDataIds = tf.engine().backend.numDataIds(); - - const real2 = tf.tensor1d([3]); - const imag2 = tf.tensor1d([4]); - - // 2 new Tensors: real2, imag2. - expect(tf.memory().numTensors).toBe(numTensors + 2); - expect(tf.engine().backend.numDataIds()).toBe(numDataIds + 2); - numTensors = tf.memory().numTensors; - numDataIds = tf.engine().backend.numDataIds(); - - const complex2 = tf.complex(real2, imag2); - - // 1 new Tensor and 3 new TensorData for complex, real and imag. - expect(tf.memory().numTensors).toBe(numTensors + 1); - expect(tf.engine().backend.numDataIds()).toBe(numDataIds + 3); - numTensors = tf.memory().numTensors; - numDataIds = tf.engine().backend.numDataIds(); - - const result = complex1.add(complex2); - - // A complex tensor is created, which is composed of real and imag parts. - // They should not increase tensor count, only complex tensor does. - // 3 new tensorData is created for complex, real and imag. - expect(tf.memory().numTensors).toBe(numTensors + 1); - expect(tf.engine().backend.numDataIds()).toBe(numDataIds + 3); - numTensors = tf.memory().numTensors; - numDataIds = tf.engine().backend.numDataIds(); - - expect(result.dtype).toBe('complex64'); - expect(result.shape).toEqual([1]); - expectArraysClose(await result.data(), [4, 6]); - - const real = tf.real(result); - - // A new tensor is created. A new tensorData is created. - expect(tf.memory().numTensors).toBe(numTensors + 1); - expect(tf.engine().backend.numDataIds()).toBe(numDataIds + 1); - numTensors = tf.memory().numTensors; - numDataIds = tf.engine().backend.numDataIds(); - - expectArraysClose(await real.data(), [4]); - - const imag = tf.imag(result); - - // A new tensor is created. A new tensorData is created. - expect(tf.memory().numTensors).toBe(numTensors + 1); - expect(tf.engine().backend.numDataIds()).toBe(numDataIds + 1); - numTensors = tf.memory().numTensors; - numDataIds = tf.engine().backend.numDataIds(); - - expectArraysClose(await imag.data(), [6]); - - // After disposing, there should be no tensors. - real1.dispose(); - imag1.dispose(); - real2.dispose(); - imag2.dispose(); - complex1.dispose(); - complex2.dispose(); - result.dispose(); - real.dispose(); - imag.dispose(); - expect(tf.memory().numTensors).toBe(startTensors); - expect(tf.engine().backend.numDataIds()).toBe(startDataIds); - }); - - it('Creating tf.real, tf.imag from complex.', async () => { - let numTensors = tf.memory().numTensors; - let numDataIds = tf.engine().backend.numDataIds(); - - const startTensors = numTensors; - const startDataIds = numDataIds; - - const complex = tf.complex([3, 30], [4, 40]); - - // 1 new tensor, 3 new data buckets. - expect(tf.memory().numTensors).toBe(numTensors + 1); - expect(tf.engine().backend.numDataIds()).toBe(numDataIds + 3); - numTensors = tf.memory().numTensors; - numDataIds = tf.engine().backend.numDataIds(); - - const real = tf.real(complex); - const imag = tf.imag(complex); - - // 2 new tensors, 2 new data buckets. - expect(tf.memory().numTensors).toBe(numTensors + 2); - expect(tf.engine().backend.numDataIds()).toBe(numDataIds + 2); - - numTensors = tf.memory().numTensors; - numDataIds = tf.engine().backend.numDataIds(); - - complex.dispose(); - - // 1 fewer tensor, 3 fewer data buckets. - expect(tf.memory().numTensors).toBe(numTensors - 1); - expect(tf.engine().backend.numDataIds()).toBe(numDataIds - 3); - - numTensors = tf.memory().numTensors; - numDataIds = tf.engine().backend.numDataIds(); - - real.dispose(); - imag.dispose(); - - // Zero net tensors / data buckets. - expect(tf.memory().numTensors).toBe(startTensors); - expect(tf.engine().backend.numDataIds()).toBe(startDataIds); - }); - - it('tf.complex disposing underlying tensors', async () => { - const numTensors = tf.memory().numTensors; - const numDataIds = tf.engine().backend.numDataIds(); - - const real = tf.tensor1d([3, 30]); - const imag = tf.tensor1d([4, 40]); - expect(tf.memory().numTensors).toEqual(numTensors + 2); - expect(tf.engine().backend.numDataIds()).toEqual(numDataIds + 2); - - const complex = tf.complex(real, imag); - - // 1 new tensor is created for complex. real and imag tensorData is created. - expect(tf.memory().numTensors).toEqual(numTensors + 3); - expect(tf.engine().backend.numDataIds()).toEqual(numDataIds + 5); - - real.dispose(); - imag.dispose(); - - expect(tf.memory().numTensors).toEqual(numTensors + 1); - expect(tf.engine().backend.numDataIds()).toEqual(numDataIds + 3); - - expect(complex.dtype).toBe('complex64'); - expect(complex.shape).toEqual(real.shape); - expectArraysClose(await complex.data(), [3, 4, 30, 40]); - - complex.dispose(); - - expect(tf.memory().numTensors).toEqual(numTensors); - expect(tf.engine().backend.numDataIds()).toEqual(numDataIds); - }); - - it('reshape', async () => { - const memoryBefore = tf.memory(); - const numDataIdsBefore = tf.engine().backend.numDataIds(); - - const a = tf.complex([[1, 3, 5], [7, 9, 11]], [[2, 4, 6], [8, 10, 12]]); - - // 1 new tensor, the complex64 tensor - expect(tf.memory().numTensors).toBe(memoryBefore.numTensors + 1); - // 1 new tensor and 2 underlying tensors for real and imag. - expect(tf.engine().backend.numDataIds()).toBe(numDataIdsBefore + 3); - - const b = a.reshape([6]); - - // 1 new tensor from the reshape. - expect(tf.memory().numTensors).toBe(memoryBefore.numTensors + 2); - // No new tensor data. - expect(tf.engine().backend.numDataIds()).toBe(numDataIdsBefore + 3); - - expect(b.dtype).toBe('complex64'); - expect(b.shape).toEqual([6]); - expectArraysClose(await a.data(), await b.data()); - - b.dispose(); - // 1 complex tensor should be disposed. - expect(tf.memory().numTensors).toBe(memoryBefore.numTensors + 1); - // Tensor data not deleted yet. - expect(tf.engine().backend.numDataIds()).toBe(numDataIdsBefore + 3); - - a.dispose(); - - // All the tensors should now be disposed. - expect(tf.memory().numTensors).toBe(memoryBefore.numTensors); - expect(tf.engine().backend.numDataIds()).toBe(numDataIdsBefore); - }); - - it('clone', async () => { - const memoryBefore = tf.memory(); - const numDataIdsBefore = tf.engine().backend.numDataIds(); - - const a = tf.complex([[1, 3, 5], [7, 9, 11]], [[2, 4, 6], [8, 10, 12]]); - - // 1 new tensor, the complex64 tensor - expect(tf.memory().numTensors).toBe(memoryBefore.numTensors + 1); - // 1 new tensor and 2 underlying tensors for real and imag. - expect(tf.engine().backend.numDataIds()).toBe(numDataIdsBefore + 3); - - const b = a.clone(); - - // 1 new tensor from the clone. - expect(tf.memory().numTensors).toBe(memoryBefore.numTensors + 2); - // No new tensor data. - expect(tf.engine().backend.numDataIds()).toBe(numDataIdsBefore + 3); - - expect(b.dtype).toBe('complex64'); - expectArraysClose(await a.data(), await b.data()); - - b.dispose(); - - // 1 complex tensor should be disposed. - expect(tf.memory().numTensors).toBe(memoryBefore.numTensors + 1); - // Tensor data not deleted yet. - expect(tf.engine().backend.numDataIds()).toBe(numDataIdsBefore + 3); - - a.dispose(); - - // All the tensors should now be disposed. - expect(tf.memory().numTensors).toBe(memoryBefore.numTensors); - expect(tf.engine().backend.numDataIds()).toBe(numDataIdsBefore); - }); - - it('tidy should not have mem leak', async () => { - const numTensors = tf.memory().numTensors; - const numDataIds = tf.engine().backend.numDataIds(); - const complex = tf.tidy(() => { - const real = tf.tensor1d([3, 30]); - const realReshape = tf.reshape(real, [2]); - const imag = tf.tensor1d([4, 40]); - const imagReshape = tf.reshape(imag, [2]); - expect(tf.memory().numTensors).toEqual(numTensors + 4); - expect(tf.engine().backend.numDataIds()).toEqual(numDataIds + 2); - - const complex = tf.complex(realReshape, imagReshape); - - // 1 new tensor is created for complex. real and imag data buckets - // created. - expect(tf.memory().numTensors).toEqual(numTensors + 5); - expect(tf.engine().backend.numDataIds()).toEqual(numDataIds + 5); - - return complex; - }); - - complex.dispose(); - - expect(tf.memory().numTensors).toEqual(numTensors); - expect(tf.engine().backend.numDataIds()).toEqual(numDataIds); - }); -}); diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Concat.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Concat.ts deleted file mode 100644 index 42936694a..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Concat.ts +++ /dev/null @@ -1,109 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, Concat, ConcatAttrs, ConcatInputs, KernelConfig, KernelFunc, TensorInfo, util} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; - -import {complex} from './Complex'; -import {concatImpl} from './Concat_impl'; -import {identity} from './Identity'; -import {imag} from './Imag'; -import {real} from './Real'; -import {reshape} from './Reshape'; - -export function concat( - args: {inputs: ConcatInputs, backend: MathBackendCPU, attrs: ConcatAttrs}): - TensorInfo { - const {inputs, backend, attrs} = args; - const {axis} = attrs; - - const $axis = util.parseAxisParam(axis, inputs[0].shape)[0]; - - const shapes = inputs.map(t => t.shape); - backend_util.assertParamsConsistent(shapes, $axis); - - let outShape = backend_util.computeOutShape(inputs.map(t => t.shape), $axis); - - if (util.sizeFromShape(outShape) === 0) { - return backend.makeTensorInfo(outShape, inputs[0].dtype, []); - } - - // Keep only non-empty tensors (ignore tensors with 0 in their shape). - const $inputs = inputs.filter(t => util.sizeFromShape(t.shape) > 0); - if ($inputs.length === 1) { - return identity({inputs: {x: $inputs[0]}, backend}); - } - - if ($inputs[0].dtype === 'complex64') { - const reals = $inputs.map((t) => real({inputs: {input: t}, backend})); - const imags = $inputs.map((t) => imag({inputs: {input: t}, backend})); - - const realConcated = concat({inputs: reals, backend, attrs: {axis: $axis}}); - const imagConcated = concat({inputs: imags, backend, attrs: {axis: $axis}}); - - const result = - complex({inputs: {real: realConcated, imag: imagConcated}, backend}); - - reals.forEach(r => backend.disposeIntermediateTensorInfo(r)); - imags.forEach(i => backend.disposeIntermediateTensorInfo(i)); - backend.disposeIntermediateTensorInfo(realConcated); - backend.disposeIntermediateTensorInfo(imagConcated); - - return result; - } - - // Any concat of n-dimensional tensors across any axis can be reduced to - // a concatenation of two-dimensional tensors across the axis 1 by first - // partitioning the axes of the original tensors into those less than the - // axis to be concatenated and the rest. Then reshape the tensors - // into a two-dimensional tensor by collapsing these two sets of axes and - // concatenate the resulting matrices across the axis 1, finally reshaping - // the result to have the proper shape. - const inputs2D = $inputs.map(t => { - const innerSize = util.sizeFromShape(t.shape.slice($axis)); - const shape = [-1, innerSize]; - return reshape({inputs: {x: t}, backend, attrs: {shape}}); - }); - - const inputsValShapes = inputs2D.map(t => { - return {vals: backend.data.get(t.dataId).values, shape: t.shape}; - }); - - // Concats 2d tensors along axis=1. - outShape = - backend_util.computeOutShape(inputs2D.map(t => t.shape), 1 /* axis */); - const simplyConcat = inputs2D[0].shape[0] === 1; - const outVals = - concatImpl(inputsValShapes, outShape, inputs[0].dtype, simplyConcat); - - const finalOutShape = - backend_util.computeOutShape($inputs.map(t => t.shape), $axis); - - const outInfo = - backend.makeTensorInfo(finalOutShape, inputs[0].dtype, outVals); - - inputs2D.forEach(t => backend.disposeIntermediateTensorInfo(t)); - - return outInfo; -} - -export const concatConfig: KernelConfig = { - kernelName: Concat, - backendName: 'cpu', - kernelFunc: concat as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Concat_impl.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Concat_impl.ts deleted file mode 100644 index 33913515a..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Concat_impl.ts +++ /dev/null @@ -1,56 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, BackendValues, DataType, TypedArray, util} from '@tensorflow/tfjs-core'; - -export function concatImpl( - inputs: Array<{vals: BackendValues, shape: number[]}>, outShape: number[], - dtype: DataType, simplyConcat: boolean): TypedArray|string[] { - const outVals = util.getArrayFromDType(dtype, util.sizeFromShape(outShape)); - - if (simplyConcat && dtype !== 'string') { - // Use built-in TypedArray.set() method for speed. - let offset = 0; - inputs.forEach(input => { - const size = util.sizeFromShape(input.shape); - - (outVals as TypedArray).set(input.vals as TypedArray, offset); - offset += size; - }); - } else { - let colOffset = 0; - - inputs.forEach(input => { - const decodedData = dtype === 'string' ? - backend_util.fromUint8ToStringArray(input.vals as Uint8Array[]) : - input.vals as TypedArray; - - let tIdx = 0; - - for (let row = 0; row < input.shape[0]; ++row) { - const resIdx = row * outShape[1] + colOffset; - for (let col = 0; col < input.shape[1]; ++col) { - outVals[resIdx + col] = decodedData[tIdx++]; - } - } - - colOffset += input.shape[1]; - }); - } - - return outVals; -} diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Conv2D.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Conv2D.ts deleted file mode 100644 index e67e8d4ed..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Conv2D.ts +++ /dev/null @@ -1,109 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, Conv2D, Conv2DAttrs, Conv2DInputs, KernelConfig, KernelFunc, TensorBuffer, TensorInfo, TypedArray, util} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; -import {assertNotComplex} from '../cpu_util'; - -export function conv2D( - args: {inputs: Conv2DInputs, backend: MathBackendCPU, attrs: Conv2DAttrs}): - TensorInfo { - const {inputs, backend, attrs} = args; - const {x, filter} = inputs; - const {strides, pad, dataFormat, dilations, dimRoundingMode} = attrs; - - assertNotComplex([x, filter], 'conv2d'); - - const $dataFormat = backend_util.convertConv2DDataFormat(dataFormat); - const convInfo = backend_util.computeConv2DInfo( - x.shape as [number, number, number, number], - filter.shape as [number, number, number, number], strides, dilations, pad, - dimRoundingMode, false /* depthwise */, $dataFormat); - - const filterHeight = convInfo.filterHeight; - const filterWidth = convInfo.filterWidth; - const dilationHeight = convInfo.dilationHeight; - const dilationWidth = convInfo.dilationWidth; - const padLeft = convInfo.padInfo.left; - const padTop = convInfo.padInfo.top; - const isChannelsLast = convInfo.dataFormat === 'channelsLast'; - - const y = new TensorBuffer(convInfo.outShape, x.dtype as 'float32'); - - const xStrides = util.computeStrides(x.shape); - const filterStrides = util.computeStrides(filter.shape); - - const xBatchStride = xStrides[0]; - const xRowStride = isChannelsLast ? xStrides[1] : xStrides[2]; - const xColStride = isChannelsLast ? xStrides[2] : 1; - const xChannelStride = isChannelsLast ? 1 : xStrides[1]; - const yBatchStride = y.strides[0]; - const yRowStride = isChannelsLast ? y.strides[1] : y.strides[2]; - const yColStride = isChannelsLast ? y.strides[2] : 1; - const yChannelStride = isChannelsLast ? 1 : y.strides[1]; - - const xVals = backend.data.get(x.dataId).values as TypedArray; - const wVals = backend.data.get(filter.dataId).values as TypedArray; - const yVals = y.values; - - for (let b = 0; b < convInfo.batchSize; ++b) { - const xOffset1 = b * xBatchStride; - const yOffset1 = b * yBatchStride; - for (let yR = 0; yR < convInfo.outHeight; ++yR) { - const yOffset2 = yOffset1 + yR * yRowStride; - const xRCorner = yR * convInfo.strideHeight - padTop; - for (let wR = 0; wR < filterHeight; ++wR) { - const xR = xRCorner + wR * dilationHeight; - if (xR < 0 || xR >= convInfo.inHeight) { - continue; - } - const wOffset1 = wR * filterStrides[0]; - const xOffset2 = xOffset1 + xR * xRowStride; - for (let yC = 0; yC < convInfo.outWidth; ++yC) { - const yOffset3 = yOffset2 + yC * yColStride; - const xCCorner = yC * convInfo.strideWidth - padLeft; - for (let wC = 0; wC < filterWidth; ++wC) { - const xC = xCCorner + wC * dilationWidth; - if (xC < 0 || xC >= convInfo.inWidth) { - continue; - } - const wOffset2 = wOffset1 + wC * filterStrides[1]; - const xOffset3 = xOffset2 + xC * xColStride; - let wOffset3 = wOffset2; - for (let d1 = 0; d1 < convInfo.inChannels; ++d1) { - const xVal = xVals[xOffset3 + d1 * xChannelStride]; - for (let d2 = 0; d2 < convInfo.outChannels; ++d2) { - yVals[yOffset3 + d2 * yChannelStride] += - xVal * wVals[wOffset3 + d2]; - } - wOffset3 += convInfo.outChannels; - } - } - } - } - } - } - - return backend.makeTensorInfo(y.shape, y.dtype, yVals); -} - -export const conv2DConfig: KernelConfig = { - kernelName: Conv2D, - backendName: 'cpu', - kernelFunc: conv2D as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Conv2DBackpropFilter.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Conv2DBackpropFilter.ts deleted file mode 100644 index 3947a1b93..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Conv2DBackpropFilter.ts +++ /dev/null @@ -1,93 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, Conv2DBackpropFilter, Conv2DBackpropFilterAttrs, Conv2DBackpropFilterInputs, KernelConfig, KernelFunc, TensorBuffer, TensorInfo, TypedArray} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; -import {assertNotComplex} from '../cpu_util'; - -export function conv2DBackpropFilter(args: { - inputs: Conv2DBackpropFilterInputs, - backend: MathBackendCPU, - attrs: Conv2DBackpropFilterAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {x, dy} = inputs; - const {strides, pad, dataFormat, dimRoundingMode, filterShape} = attrs; - - assertNotComplex([x, dy], 'conv2dBackpropFilter'); - - const $dataFormat = backend_util.convertConv2DDataFormat(dataFormat); - const convInfo = backend_util.computeConv2DInfo( - x.shape as [number, number, number, number], filterShape, strides, - 1 /* dilations */, pad, dimRoundingMode, false /* depthwise */, - $dataFormat); - - const {strideHeight, strideWidth, filterHeight, filterWidth} = convInfo; - const isChannelsLast = convInfo.dataFormat === 'channelsLast'; - const dW = new TensorBuffer(convInfo.filterShape, 'float32'); - - const leftPad = convInfo.padInfo.left; - const topPad = convInfo.padInfo.top; - const xVals = backend.data.get(x.dataId).values as TypedArray; - const dyVals = backend.data.get(dy.dataId).values as TypedArray; - - const xBuf = new TensorBuffer(x.shape, x.dtype, xVals); - const dyBuf = new TensorBuffer(dy.shape, dy.dtype, dyVals); - - for (let wR = 0; wR < filterHeight; ++wR) { - const yRMin = Math.max(0, Math.ceil((topPad - wR) / strideHeight)); - const yRMax = Math.min( - convInfo.outHeight, (convInfo.inHeight + topPad - wR) / strideHeight); - - for (let wC = 0; wC < filterWidth; ++wC) { - const yCMin = Math.max(0, Math.ceil((leftPad - wC) / strideWidth)); - const yCMax = Math.min( - convInfo.outWidth, (convInfo.inWidth + leftPad - wC) / strideWidth); - - for (let d1 = 0; d1 < convInfo.inChannels; ++d1) { - for (let d2 = 0; d2 < convInfo.outChannels; ++d2) { - let dotProd = 0; - for (let b = 0; b < convInfo.batchSize; ++b) { - for (let yR = yRMin; yR < yRMax; ++yR) { - const xR = wR + yR * strideHeight - topPad; - for (let yC = yCMin; yC < yCMax; ++yC) { - const xC = wC + yC * strideWidth - leftPad; - if (isChannelsLast) { - dotProd += (xBuf.get(b, xR, xC, d1) as number) * - (dyBuf.get(b, yR, yC, d2) as number); - } else { - dotProd += (xBuf.get(b, d1, xR, xC) as number) * - (dyBuf.get(b, d2, yR, yC) as number); - } - } - } - } - dW.set(dotProd, wR, wC, d1, d2); - } - } - } - } - - return backend.makeTensorInfo(dW.shape, dW.dtype, dW.values); -} - -export const conv2DBackpropFilterConfig: KernelConfig = { - kernelName: Conv2DBackpropFilter, - backendName: 'cpu', - kernelFunc: conv2DBackpropFilter as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Conv2DBackpropInput.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Conv2DBackpropInput.ts deleted file mode 100644 index 851809921..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Conv2DBackpropInput.ts +++ /dev/null @@ -1,121 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, Conv2DBackpropInput, Conv2DBackpropInputAttrs, Conv2DBackpropInputInputs, KernelConfig, KernelFunc, TensorBuffer, TensorInfo, TypedArray, util} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; -import {assertNotComplex} from '../cpu_util'; - -export function conv2DBackpropInput(args: { - inputs: Conv2DBackpropInputInputs, - backend: MathBackendCPU, - attrs: Conv2DBackpropInputAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {dy, filter} = inputs; - const {inputShape, strides, pad, dataFormat, dimRoundingMode} = attrs; - - assertNotComplex([dy, filter], 'conv2dBackpropInput'); - - const filterStrides = util.computeStrides(filter.shape); - const dyStrides = util.computeStrides(dy.shape); - - let $dataFormat = backend_util.convertConv2DDataFormat(dataFormat); - const convInfo = backend_util.computeConv2DInfo( - inputShape, filter.shape as [number, number, number, number], strides, - 1 /* dilations */, pad, dimRoundingMode, false, $dataFormat); - - const dx = new TensorBuffer(convInfo.inShape, 'float32'); - const dxValues = dx.values; - const dyValues = backend.data.get(dy.dataId).values as TypedArray; - const fltValues = backend.data.get(filter.dataId).values as TypedArray; - const [fltS0, fltS1, fltS2] = filterStrides; - const { - batchSize, - filterHeight, - filterWidth, - inChannels, - inHeight, - inWidth, - outChannels, - outHeight, - outWidth, - strideHeight, - strideWidth - } = convInfo; - $dataFormat = convInfo.dataFormat; - const topPad = filterHeight - 1 - convInfo.padInfo.top; - const leftPad = filterWidth - 1 - convInfo.padInfo.left; - - const isChannelsLast = $dataFormat === 'channelsLast'; - const xBatchStride = dx.strides[0]; - const xRowStride = isChannelsLast ? dx.strides[1] : dx.strides[2]; - const xColStride = isChannelsLast ? dx.strides[2] : 1; - const xChannelStride = isChannelsLast ? 1 : dx.strides[1]; - const yBatchStride = dyStrides[0]; - const yRowStride = isChannelsLast ? dyStrides[1] : dyStrides[2]; - const yColStride = isChannelsLast ? dyStrides[2] : 1; - const yChannelStride = isChannelsLast ? 1 : dyStrides[1]; - - for (let b = 0; b < batchSize; ++b) { - for (let d1 = 0; d1 < inChannels; ++d1) { - for (let xR = 0; xR < inHeight; ++xR) { - const xRCorner = xR - topPad; - const xRMin = Math.max(0, Math.ceil(xRCorner / strideHeight)); - const yRMax = - Math.min(outHeight, (filterHeight + xRCorner) / strideHeight); - - for (let xC = 0; xC < inWidth; ++xC) { - const xCCorner = xC - leftPad; - const xCMin = Math.max(0, Math.ceil(xCCorner / strideWidth)); - const yCMax = - Math.min(outWidth, (filterWidth + xCCorner) / strideWidth); - - let dotProd = 0; - for (let yR = xRMin; yR < yRMax; ++yR) { - const wR = yR * strideHeight - xRCorner; - - for (let yC = xCMin; yC < yCMax; ++yC) { - const wC = yC * strideWidth - xCCorner; - const dyOffset = - yBatchStride * b + yRowStride * yR + yColStride * yC; - const fltOffset = fltS0 * (filterHeight - 1 - wR) + - fltS1 * (filterWidth - 1 - wC) + fltS2 * d1; - - for (let d2 = 0; d2 < outChannels; ++d2) { - const pixel = dyValues[dyOffset + yChannelStride * d2]; - const weight = fltValues[fltOffset + d2]; - dotProd += pixel * weight; - } - } - } - const dxOffset = xBatchStride * b + xRowStride * xR + - xColStride * xC + xChannelStride * d1; - dxValues[dxOffset] = dotProd; - } - } - } - } - - return backend.makeTensorInfo(dx.shape, dx.dtype, dx.values); -} - -export const conv2DBackpropInputConfig: KernelConfig = { - kernelName: Conv2DBackpropInput, - backendName: 'cpu', - kernelFunc: conv2DBackpropInput as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Conv3D.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Conv3D.ts deleted file mode 100644 index fc006b621..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Conv3D.ts +++ /dev/null @@ -1,115 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, Conv3D, Conv3DAttrs, Conv3DInputs, KernelConfig, KernelFunc, TensorBuffer, TensorInfo, TypedArray, util} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; -import {assertNotComplex} from '../cpu_util'; - -export function conv3D( - args: {inputs: Conv3DInputs, backend: MathBackendCPU, attrs: Conv3DAttrs}): - TensorInfo { - const {inputs, backend, attrs} = args; - const {x, filter} = inputs; - const {strides, pad, dilations} = attrs; - - assertNotComplex([x, filter], 'conv3d'); - - const convInfo = backend_util.computeConv3DInfo( - x.shape as [number, number, number, number, number], - filter.shape as [number, number, number, number, number], strides, - dilations, pad); - - const { - filterDepth, - filterHeight, - filterWidth, - dilationDepth, - dilationHeight, - dilationWidth, - padInfo - } = convInfo; - const padFront = padInfo.front; - const padLeft = padInfo.left; - const padTop = padInfo.top; - const y = new TensorBuffer(convInfo.outShape, x.dtype as 'float32'); - - const xVals = backend.data.get(x.dataId).values as TypedArray; - const wVals = backend.data.get(filter.dataId).values as TypedArray; - const yVals = y.values; - - const xStrides = util.computeStrides(x.shape); - const filterStrides = util.computeStrides(filter.shape); - - for (let b = 0; b < convInfo.batchSize; ++b) { - const xOffset1 = b * xStrides[0]; - const yOffset1 = b * y.strides[0]; - for (let yF = 0; yF < convInfo.outDepth; ++yF) { - const yOffset2 = yOffset1 + yF * y.strides[1]; - const xFCorner = yF * convInfo.strideDepth - padFront; - for (let wF = 0; wF < filterDepth; ++wF) { - const xF = xFCorner + wF * dilationDepth; - if (xF < 0 || xF >= convInfo.inDepth) { - continue; - } - const wOffset1 = wF * filterStrides[0]; - const xOffset2 = xOffset1 + xF * xStrides[1]; - - for (let yR = 0; yR < convInfo.outHeight; ++yR) { - const yOffset3 = yOffset2 + yR * y.strides[2]; - const xRCorner = yR * convInfo.strideHeight - padTop; - for (let wR = 0; wR < filterHeight; ++wR) { - const xR = xRCorner + wR * dilationHeight; - if (xR < 0 || xR >= convInfo.inHeight) { - continue; - } - const wOffset2 = wOffset1 + wR * filterStrides[1]; - const xOffset3 = xOffset2 + xR * xStrides[2]; - for (let yC = 0; yC < convInfo.outWidth; ++yC) { - const yOffset4 = yOffset3 + yC * convInfo.outChannels; - const xCCorner = yC * convInfo.strideWidth - padLeft; - for (let wC = 0; wC < filterWidth; ++wC) { - const xC = xCCorner + wC * dilationWidth; - if (xC < 0 || xC >= convInfo.inWidth) { - continue; - } - const wOffset3 = wOffset2 + wC * filterStrides[2]; - const xOffset4 = xOffset3 + xC * convInfo.inChannels; - let wOffset4 = wOffset3; - for (let d1 = 0; d1 < convInfo.inChannels; ++d1) { - const xVal = xVals[xOffset4 + d1]; - for (let d2 = 0; d2 < convInfo.outChannels; ++d2) { - yVals[yOffset4 + d2] += xVal * wVals[wOffset4 + d2]; - } - wOffset4 += convInfo.outChannels; - } - } - } - } - } - } - } - } - - return backend.makeTensorInfo(y.shape, y.dtype, y.values); -} - -export const conv3DConfig: KernelConfig = { - kernelName: Conv3D, - backendName: 'cpu', - kernelFunc: conv3D as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Conv3DBackpropFilterV2.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Conv3DBackpropFilterV2.ts deleted file mode 100644 index 71b80c030..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Conv3DBackpropFilterV2.ts +++ /dev/null @@ -1,121 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, Conv3DBackpropFilterV2, Conv3DBackpropFilterV2Attrs, Conv3DBackpropFilterV2Inputs, KernelConfig, KernelFunc, TensorBuffer, TensorInfo, TypedArray, util} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; -import {assertNotComplex} from '../cpu_util'; - -export function conv3DBackpropFilterV2(args: { - inputs: Conv3DBackpropFilterV2Inputs, - backend: MathBackendCPU, - attrs: Conv3DBackpropFilterV2Attrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {x, dy} = inputs; - const {strides, pad, filterShape} = attrs; - - assertNotComplex([x, dy], 'conv3dBackpropFilterV2'); - - const xStrides = util.computeStrides(x.shape); - const dyStrides = util.computeStrides(dy.shape); - - const convInfo = backend_util.computeConv3DInfo( - x.shape as [number, number, number, number, number], filterShape, strides, - 1 /* dilations */, pad); - - const strideDepth = convInfo.strideDepth; - const strideHeight = convInfo.strideHeight; - const strideWidth = convInfo.strideWidth; - const filterDepth = convInfo.filterDepth; - const filterHeight = convInfo.filterHeight; - const filterWidth = convInfo.filterWidth; - - const dw = new TensorBuffer(convInfo.filterShape, 'float32'); - const dwValues = dw.values; - const [dwS0, dwS1, dwS2, dwS3] = dw.strides; - const dyValues = backend.data.get(dy.dataId).values as TypedArray; - const [dyS0, dyS1, dyS2, dyS3] = dyStrides; - const xValues = backend.data.get(x.dataId).values as TypedArray; - const [xS0, xS1, xS2, xS3] = xStrides; - - const frontPad = convInfo.padInfo.front; - const leftPad = convInfo.padInfo.left; - const topPad = convInfo.padInfo.top; - - for (let wF = 0; wF < filterDepth; ++wF) { - const yFMin = Math.max(0, Math.ceil((frontPad - wF) / strideDepth)); - const yFMax = Math.min( - convInfo.outDepth, (convInfo.inDepth + frontPad - wF) / strideDepth); - const wOffset1 = wF * dwS0; - - for (let wR = 0; wR < filterHeight; ++wR) { - const yRMin = Math.max(0, Math.ceil((topPad - wR) / strideHeight)); - const yRMax = Math.min( - convInfo.outHeight, (convInfo.inHeight + topPad - wR) / strideHeight); - const wOffset2 = wR * dwS1 + wOffset1; - - for (let wC = 0; wC < filterWidth; ++wC) { - const yCMin = Math.max(0, Math.ceil((leftPad - wC) / strideWidth)); - const yCMax = Math.min( - convInfo.outWidth, (convInfo.inWidth + leftPad - wC) / strideWidth); - const wOffset3 = wC * dwS2 + wOffset2; - - for (let d1 = 0; d1 < convInfo.inChannels; ++d1) { - const wOffset4 = d1 * dwS3 + wOffset3; - - for (let d2 = 0; d2 < convInfo.outChannels; ++d2) { - let dotProd = 0; - for (let b = 0; b < convInfo.batchSize; ++b) { - const xOffset1 = b * xS0; - const yOffset1 = b * dyS0; - - for (let yF = yFMin; yF < yFMax; ++yF) { - const xF = wF + yF * strideDepth - frontPad; - const xOffset2 = xF * xS1 + xOffset1; - const yOffset2 = yF * dyS1 + yOffset1; - - for (let yR = yRMin; yR < yRMax; ++yR) { - const xR = wR + yR * strideHeight - topPad; - const xOffset3 = xR * xS2 + xOffset2; - const yOffset3 = yR * dyS2 + yOffset2; - - for (let yC = yCMin; yC < yCMax; ++yC) { - const xC = wC + yC * strideWidth - leftPad; - const xOffset4 = xC * xS3 + xOffset3; - const yOffset4 = yC * dyS3 + yOffset3; - - dotProd += xValues[xOffset4 + d1] * dyValues[yOffset4 + d2]; - } - } - } - } - dwValues[wOffset4 + d2] = dotProd; - } - } - } - } - } - - return backend.makeTensorInfo(dw.shape, dw.dtype, dw.values); -} - -export const conv3DBackpropFilterV2Config: KernelConfig = { - kernelName: Conv3DBackpropFilterV2, - backendName: 'cpu', - kernelFunc: conv3DBackpropFilterV2 as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Conv3DBackpropInputV2.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Conv3DBackpropInputV2.ts deleted file mode 100644 index 0b0d015d4..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Conv3DBackpropInputV2.ts +++ /dev/null @@ -1,128 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, Conv3DBackpropInputV2, Conv3DBackpropInputV2Attrs, Conv3DBackpropInputV2Inputs, KernelConfig, KernelFunc, TensorBuffer, TensorInfo, TypedArray, util} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; -import {assertNotComplex} from '../cpu_util'; - -export function conv3DBackpropInputV2(args: { - inputs: Conv3DBackpropInputV2Inputs, - backend: MathBackendCPU, - attrs: Conv3DBackpropInputV2Attrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {dy, filter} = inputs; - const {pad, strides, inputShape} = attrs; - - assertNotComplex([dy], 'conv3dBackpropInputV2'); - - const dyStrides = util.computeStrides(dy.shape); - const filterStrides = util.computeStrides(filter.shape); - - const convInfo = backend_util.computeConv3DInfo( - inputShape, filter.shape as [number, number, number, number, number], - strides, 1 /* dilations */, pad); - - const dx = new TensorBuffer(convInfo.inShape, 'float32'); - const dxValues = dx.values; - const [dxS0, dxS1, dxS2, dxS3] = dx.strides; - const dyValues = backend.data.get(dy.dataId).values as TypedArray; - const [dyS0, dyS1, dyS2, dyS3] = dyStrides; - const fltValues = backend.data.get(filter.dataId).values as TypedArray; - const [fltS0, fltS1, fltS2, fltS3] = filterStrides; - const { - batchSize, - filterDepth, - filterHeight, - filterWidth, - inChannels, - inDepth, - inHeight, - inWidth, - outChannels, - outDepth, - outHeight, - outWidth, - strideDepth, - strideHeight, - strideWidth - } = convInfo; - const frontPad = filterDepth - 1 - convInfo.padInfo.front; - const topPad = filterHeight - 1 - convInfo.padInfo.top; - const leftPad = filterWidth - 1 - convInfo.padInfo.left; - - for (let b = 0; b < batchSize; ++b) { - for (let d1 = 0; d1 < inChannels; ++d1) { - // Frames of depth - for (let xF = 0; xF < inDepth; ++xF) { - const xFCorner = xF - frontPad; - const xFMin = Math.max(0, Math.ceil(xFCorner / strideDepth)); - const yFMax = - Math.min(outDepth, (filterDepth + xFCorner) / strideDepth); - - // Rows as per standard 2d matrix notation - for (let xR = 0; xR < inHeight; ++xR) { - const xRCorner = xR - topPad; - const xRMin = Math.max(0, Math.ceil(xRCorner / strideHeight)); - const yRMax = - Math.min(outHeight, (filterHeight + xRCorner) / strideHeight); - // Columns as per standard 2d matrix notation - for (let xC = 0; xC < inWidth; ++xC) { - const xCCorner = xC - leftPad; - const xCMin = Math.max(0, Math.ceil(xCCorner / strideWidth)); - const yCMax = - Math.min(outWidth, (filterWidth + xCCorner) / strideWidth); - - let dotProd = 0; - for (let yF = xFMin; yF < yFMax; ++yF) { - const wF = yF * strideDepth - xFCorner; - - for (let yR = xRMin; yR < yRMax; ++yR) { - const wR = yR * strideHeight - xRCorner; - - for (let yC = xCMin; yC < yCMax; ++yC) { - const wC = yC * strideWidth - xCCorner; - const dyOffset = dyS0 * b + dyS1 * yF + dyS2 * yR + dyS3 * yC; - const fltOffset = fltS0 * (filterDepth - 1 - wF) + - fltS1 * (filterHeight - 1 - wR) + - fltS2 * (filterWidth - 1 - wC) + fltS3 * d1; - - for (let d2 = 0; d2 < outChannels; ++d2) { - const pixel = dyValues[dyOffset + d2]; - const weight = fltValues[fltOffset + d2]; - dotProd += pixel * weight; - } - } - } - } - dxValues[dxS0 * b + dxS1 * xF + dxS2 * xR + dxS3 * xC + d1] = - dotProd; - } - } - } - } - } - - return backend.makeTensorInfo(dx.shape, dx.dtype, dx.values); -} - -export const conv3DBackpropInputV2Config: KernelConfig = { - kernelName: Conv3DBackpropInputV2, - backendName: 'cpu', - kernelFunc: conv3DBackpropInputV2 as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Cos.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Cos.ts deleted file mode 100644 index 7e7e6fcfa..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Cos.ts +++ /dev/null @@ -1,28 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Cos, KernelConfig} from '@tensorflow/tfjs-core'; - -import {unaryKernelFunc} from '../utils/unary_utils'; - -export const cos = unaryKernelFunc(Cos, (xi) => Math.cos(xi)); - -export const cosConfig: KernelConfig = { - kernelName: Cos, - backendName: 'cpu', - kernelFunc: cos, -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Cosh.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Cosh.ts deleted file mode 100644 index d12dd44ec..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Cosh.ts +++ /dev/null @@ -1,28 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Cosh, KernelConfig} from '@tensorflow/tfjs-core'; - -import {unaryKernelFunc} from '../utils/unary_utils'; - -export const cosh = unaryKernelFunc(Cosh, (xi) => Math.cosh(xi)); - -export const coshConfig: KernelConfig = { - kernelName: Cosh, - backendName: 'cpu', - kernelFunc: cosh, -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/CropAndResize.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/CropAndResize.ts deleted file mode 100644 index 9ab4f29a9..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/CropAndResize.ts +++ /dev/null @@ -1,166 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {buffer, CropAndResize, CropAndResizeAttrs, CropAndResizeInputs, KernelConfig, KernelFunc, TensorInfo, TypedArray, util} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; - -export function cropAndResize(args: { - inputs: CropAndResizeInputs, - backend: MathBackendCPU, - attrs: CropAndResizeAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {image, boxes, boxInd} = inputs; - const {cropSize, method, extrapolationValue} = attrs; - - const [batch, imageHeight, imageWidth, numChannels] = image.shape; - const numBoxes = boxes.shape[0]; - - const [cropHeight, cropWidth] = cropSize; - const output = - buffer([numBoxes, cropHeight, cropWidth, numChannels], 'float32'); - - const boxVals = backend.data.get(boxes.dataId).values as TypedArray; - const boxIndVals = backend.data.get(boxInd.dataId).values as TypedArray; - const imageVals = backend.data.get(image.dataId).values as TypedArray; - - const inStride = - util.computeStrides(image.shape); // to calculate flat indexes into image - const outStride = util.computeStrides( - output.shape); // to calculate flat indexes into output - - // Reference implementation - // tslint:disable-next-line:max-line-length - // https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/kernels/crop_and_resize_op.cc - for (let b = 0; b < numBoxes; b++) { - const startInd = b * 4; - const y1 = boxVals[startInd]; - const x1 = boxVals[startInd + 1]; - const y2 = boxVals[startInd + 2]; - const x2 = boxVals[startInd + 3]; - - const bInd: number = boxIndVals[b]; - if (bInd >= batch) { - continue; - } - - const heightScale = - (cropHeight > 1) ? (y2 - y1) * (imageHeight - 1) / (cropHeight - 1) : 0; - const widthScale = - (cropWidth > 1) ? (x2 - x1) * (imageWidth - 1) / (cropWidth - 1) : 0; - - for (let y = 0; y < cropHeight; y++) { - const yInd: number = (cropHeight > 1) ? - y1 * (imageHeight - 1) + y * (heightScale) : - 0.5 * (y1 + y2) * (imageHeight - 1); - - if (yInd < 0 || yInd > imageHeight - 1) { - for (let x = 0; x < cropWidth; x++) { - for (let c = 0; c < numChannels; c++) { - const ind = - c + x * outStride[2] + y * outStride[1] + b * outStride[0]; - output.values[ind] = extrapolationValue; - } - } - continue; - } - - if (method === 'bilinear') { - const topInd = Math.floor(yInd); - const bottomInd = Math.ceil(yInd); - const yLerp = yInd - topInd; - - for (let x = 0; x < cropWidth; x++) { - const xInd = (cropWidth > 1) ? - x1 * (imageWidth - 1) + x * widthScale : - 0.5 * (x1 + x2) * (imageWidth - 1); - - if (xInd < 0 || xInd > imageWidth - 1) { - for (let c = 0; c < numChannels; c++) { - const ind = - c + x * outStride[2] + y * outStride[1] + b * outStride[0]; - output.values[ind] = extrapolationValue; - } - continue; - } - - const leftInd = Math.floor(xInd); - const rightInd = Math.ceil(xInd); - const xLerp = xInd - leftInd; - - for (let c = 0; c < numChannels; c++) { - let ind = c + leftInd * inStride[2] + topInd * inStride[1] + - bInd * inStride[0]; - const topLeft = imageVals[ind]; - - ind = c + rightInd * inStride[2] + topInd * inStride[1] + - bInd * inStride[0]; - const topRight = imageVals[ind]; - - ind = c + leftInd * inStride[2] + bottomInd * inStride[1] + - bInd * inStride[0]; - const bottomLeft = imageVals[ind]; - - ind = c + rightInd * inStride[2] + bottomInd * inStride[1] + - bInd * inStride[0]; - const bottomRight = imageVals[ind]; - - const top = topLeft + (topRight - topLeft) * xLerp; - const bottom = bottomLeft + (bottomRight - bottomLeft) * xLerp; - - ind = c + x * outStride[2] + y * outStride[1] + b * outStride[0]; - output.values[ind] = top + ((bottom - top) * yLerp); - } - } - } else { // method == "nearest" - for (let x = 0; x < cropWidth; ++x) { - const xInd = (cropWidth > 1) ? - x1 * (imageWidth - 1) + x * widthScale : - 0.5 * (x1 + x2) * (imageWidth - 1); - - if (xInd < 0 || xInd > imageWidth - 1) { - for (let c = 0; c < numChannels; c++) { - const ind = - c + x * outStride[2] + y * outStride[1] + b * outStride[0]; - output.values[ind] = extrapolationValue; - } - continue; - } - - const closestX = Math.round(xInd); - const closestY = Math.round(yInd); - for (let c = 0; c < numChannels; c++) { - const inInd = c + closestX * inStride[2] + closestY * inStride[1] + - bInd * inStride[0]; - const outInd = - c + x * outStride[2] + y * outStride[1] + b * outStride[0]; - output.values[outInd] = imageVals[inInd]; - } - } - } - } - } - - return backend.makeTensorInfo(output.shape, output.dtype, output.values); -} - -export const cropAndResizeConfig: KernelConfig = { - kernelName: CropAndResize, - backendName: 'cpu', - kernelFunc: cropAndResize as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Cumprod.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Cumprod.ts deleted file mode 100644 index 40f01d883..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Cumprod.ts +++ /dev/null @@ -1,88 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, Cumprod, CumprodAttrs, CumprodInputs, KernelConfig, KernelFunc, TensorInfo, TypedArray, upcastType, util} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; -import {assertNotComplex} from '../cpu_util'; -import {transpose} from './Transpose'; - -export function cumprod( - args: {inputs: CumprodInputs, backend: MathBackendCPU, - attrs: CumprodAttrs}): TensorInfo { - const {inputs, backend, attrs} = args; - const {x} = inputs; - const {axis, exclusive, reverse} = attrs; - - assertNotComplex(x, 'cumprod'); - - const permutation = backend_util.getAxesPermutation([axis], x.shape.length); - let $x = x; - if (permutation != null) { - $x = transpose({inputs: {x}, backend, attrs: {perm: permutation}}); - } - const permutedAxis = backend_util.getInnerMostAxes(1, x.shape.length)[0]; - - if (permutedAxis !== $x.shape.length - 1) { - throw new Error( - `backend.cumprod in CPU expects an inner-most ` + - `axis=${$x.shape.length - 1} but got axis=${permutedAxis}`); - } - - const resultDtype = upcastType($x.dtype, 'int32'); - const vals = util.makeOnesTypedArray( - util.sizeFromShape($x.shape), resultDtype) as TypedArray; - - const aVals = backend.data.get($x.dataId).values as TypedArray; - const finalDim = $x.shape[$x.shape.length - 1]; - const indexAdjuster = reverse ? - (i: number, j: number) => i + finalDim - j - 1 : - (i: number, j: number) => i + j; - for (let i = 0; i < aVals.length; i += finalDim) { - for (let j = 0; j < finalDim; j++) { - const idx = indexAdjuster(i, j); - if (j === 0) { - vals[idx] = exclusive ? 1 : aVals[idx]; - } else { - const prevIdx = indexAdjuster(i, j - 1); - vals[idx] = exclusive ? aVals[prevIdx] * vals[prevIdx] : - aVals[idx] * vals[prevIdx]; - } - } - } - - const result = backend.makeTensorInfo($x.shape, resultDtype, vals); - - if (permutation != null) { - const reversePermutation = backend_util.getUndoAxesPermutation(permutation); - const reverseTransposedResult = transpose( - {inputs: {x: result}, backend, attrs: {perm: reversePermutation}}); - - backend.disposeIntermediateTensorInfo(result); - backend.disposeIntermediateTensorInfo($x); - - return reverseTransposedResult; - } - - return result; -} - -export const cumprodConfig: KernelConfig = { - kernelName: Cumprod, - backendName: 'cpu', - kernelFunc: cumprod as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Cumsum.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Cumsum.ts deleted file mode 100644 index 9a29f9229..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Cumsum.ts +++ /dev/null @@ -1,88 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, Cumsum, CumsumAttrs, CumsumInputs, KernelConfig, KernelFunc, TensorInfo, TypedArray, upcastType, util} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; -import {assertNotComplex} from '../cpu_util'; -import {transpose} from './Transpose'; - -export function cumsum( - args: {inputs: CumsumInputs, backend: MathBackendCPU, attrs: CumsumAttrs}): - TensorInfo { - const {inputs, backend, attrs} = args; - const {x} = inputs; - const {axis, exclusive, reverse} = attrs; - - assertNotComplex(x, 'cumsum'); - - const permutation = backend_util.getAxesPermutation([axis], x.shape.length); - let $x = x; - if (permutation != null) { - $x = transpose({inputs: {x}, backend, attrs: {perm: permutation}}); - } - const permutedAxis = backend_util.getInnerMostAxes(1, x.shape.length)[0]; - - if (permutedAxis !== $x.shape.length - 1) { - throw new Error( - `backend.cumsum in CPU expects an inner-most ` + - `axis=${$x.shape.length - 1} but got axis=${permutedAxis}`); - } - - const resultDtype = upcastType($x.dtype, 'int32'); - const vals = util.makeZerosTypedArray( - util.sizeFromShape($x.shape), resultDtype) as TypedArray; - - const aVals = backend.data.get($x.dataId).values as TypedArray; - const finalDim = $x.shape[$x.shape.length - 1]; - const indexAdjuster = reverse ? - (i: number, j: number) => i + finalDim - j - 1 : - (i: number, j: number) => i + j; - for (let i = 0; i < aVals.length; i += finalDim) { - for (let j = 0; j < finalDim; j++) { - const idx = indexAdjuster(i, j); - if (j === 0) { - vals[idx] = exclusive ? 0 : aVals[idx]; - } else { - const prevIdx = indexAdjuster(i, j - 1); - vals[idx] = exclusive ? aVals[prevIdx] + vals[prevIdx] : - aVals[idx] + vals[prevIdx]; - } - } - } - - const result = backend.makeTensorInfo($x.shape, resultDtype, vals); - - if (permutation != null) { - const reversePermutation = backend_util.getUndoAxesPermutation(permutation); - const reverseTransposedResult = transpose( - {inputs: {x: result}, backend, attrs: {perm: reversePermutation}}); - - backend.disposeIntermediateTensorInfo(result); - backend.disposeIntermediateTensorInfo($x); - - return reverseTransposedResult; - } - - return result; -} - -export const cumsumConfig: KernelConfig = { - kernelName: Cumsum, - backendName: 'cpu', - kernelFunc: cumsum as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/DenseBincount.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/DenseBincount.ts deleted file mode 100644 index bff662685..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/DenseBincount.ts +++ /dev/null @@ -1,58 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {DenseBincount, DenseBincountAttrs, DenseBincountInputs, KernelConfig, KernelFunc, Rank, TensorInfo, TypedArray} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; -import {bincountImpl, bincountReduceImpl} from './Bincount_impl'; - -export function denseBincount(args: { - inputs: DenseBincountInputs, - backend: MathBackendCPU, - attrs: DenseBincountAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {x, weights} = inputs; - const {size, binaryOutput} = attrs; - - if (x.shape.length === 1) { - const xVals = backend.data.get(x.dataId).values as TypedArray; - const weightsVals = backend.data.get(weights.dataId).values as TypedArray; - - const outVals = - bincountImpl(xVals, weightsVals, weights.dtype, weights.shape, size); - - return backend.makeTensorInfo([size], weights.dtype, outVals); - } else if (x.shape.length === 2) { - const xBuf = backend.bufferSync(x); - const weightsBuf = backend.bufferSync(weights); - - const outBuf = bincountReduceImpl(xBuf, weightsBuf, size, binaryOutput); - - return backend.makeTensorInfo(outBuf.shape, weights.dtype, outBuf.values); - } - - throw new Error( - `Error in denseBincount: input must be at most rank 2, but got rank` + - `${x.shape.length}.`); -} - -export const denseBincountConfig: KernelConfig = { - kernelName: DenseBincount, - backendName: 'cpu', - kernelFunc: denseBincount as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/DepthToSpace.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/DepthToSpace.ts deleted file mode 100644 index 67a742655..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/DepthToSpace.ts +++ /dev/null @@ -1,76 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {DepthToSpace, DepthToSpaceAttrs, DepthToSpaceInputs, KernelConfig, KernelFunc, TensorInfo, TypedArray, util} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; - -export function depthToSpace(args: { - inputs: DepthToSpaceInputs, - backend: MathBackendCPU, - attrs: DepthToSpaceAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {x} = inputs; - const {blockSize, dataFormat} = attrs; - - util.assert( - dataFormat === 'NHWC', - () => `Only NHWC dataFormat supported on CPU for depthToSpace. Got ${ - dataFormat}`); - - const batchSize = x.shape[0]; - const inputHeight = x.shape[1]; - const inputWidth = x.shape[2]; - const inputDepth = x.shape[3]; - - const outputHeight = inputHeight * blockSize; - const outputWidth = inputWidth * blockSize; - const outputDepth = inputDepth / (blockSize * blockSize); - - const xValues = backend.data.get(x.dataId).values as TypedArray; - const result = - new Float32Array(batchSize * outputHeight * outputWidth * outputDepth); - - let outputIdx = 0; - for (let b = 0; b < batchSize; ++b) { - for (let h = 0; h < outputHeight; ++h) { - const inH = Math.floor(h / blockSize); - const offsetH = (h % blockSize); - for (let w = 0; w < outputWidth; ++w) { - const inW = Math.floor(w / blockSize); - const offsetW = (w % blockSize); - const offsetD = (offsetH * blockSize + offsetW) * outputDepth; - for (let d = 0; d < outputDepth; ++d) { - const inD = d + offsetD; - const inputIdx = - inD + inputDepth * (inW + inputWidth * (inH + inputHeight * b)); - result[outputIdx++] = xValues[inputIdx]; - } - } - } - } - - return backend.makeTensorInfo( - [batchSize, outputHeight, outputWidth, outputDepth], x.dtype, result); -} - -export const depthToSpaceConfig: KernelConfig = { - kernelName: DepthToSpace, - backendName: 'cpu', - kernelFunc: depthToSpace as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/DepthwiseConv2dNative.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/DepthwiseConv2dNative.ts deleted file mode 100644 index 9356d79a9..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/DepthwiseConv2dNative.ts +++ /dev/null @@ -1,108 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, DepthwiseConv2dNative, DepthwiseConv2dNativeAttrs, DepthwiseConv2dNativeInputs, KernelConfig, KernelFunc, TensorBuffer, TensorInfo, TypedArray, util} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; -import {assertNotComplex} from '../cpu_util'; - -export function depthwiseConv2dNative(args: { - inputs: DepthwiseConv2dNativeInputs, - backend: MathBackendCPU, - attrs: DepthwiseConv2dNativeAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {x, filter} = inputs; - const {strides, pad, dilations, dimRoundingMode} = attrs; - - assertNotComplex([x, filter], 'depthwiseConv2DNative'); - - const xStrides = util.computeStrides(x.shape); - const filterStrides = util.computeStrides(filter.shape); - - let $dilations = dilations; - if ($dilations == null) { - $dilations = [1, 1]; - } - - util.assert( - backend_util.eitherStridesOrDilationsAreOne(strides, $dilations), - () => 'Error in depthwiseConv2d: Either strides or dilations must be ' + - `1. Got strides ${strides} and dilations '${$dilations}'`); - - const convInfo = backend_util.computeConv2DInfo( - x.shape as [number, number, number, number], - filter.shape as [number, number, number, number], strides, $dilations, - pad, dimRoundingMode, true /* depthwise */); - - const {filterHeight, filterWidth, dilationHeight, dilationWidth, padInfo} = - convInfo; - const padLeft = padInfo.left; - const padTop = padInfo.top; - const chMul = convInfo.outChannels / convInfo.inChannels; - const y = new TensorBuffer(convInfo.outShape, x.dtype as 'float32'); - const xVals = backend.data.get(x.dataId).values as TypedArray; - const wVals = backend.data.get(filter.dataId).values as TypedArray; - const yVals = y.values; - - for (let b = 0; b < convInfo.batchSize; ++b) { - const xOffset1 = b * xStrides[0]; - const yOffset1 = b * y.strides[0]; - for (let yR = 0; yR < convInfo.outHeight; ++yR) { - const yOffset2 = yOffset1 + yR * y.strides[1]; - const xRCorner = yR * convInfo.strideHeight - padTop; - for (let wR = 0; wR < filterHeight; ++wR) { - const xR = xRCorner + wR * dilationHeight; - if (xR < 0 || xR >= convInfo.inHeight) { - continue; - } - const wOffset1 = wR * filterStrides[0]; - const xOffset2 = xOffset1 + xR * xStrides[1]; - for (let yC = 0; yC < convInfo.outWidth; ++yC) { - const yOffset3 = yOffset2 + yC * y.strides[2]; - const xCCorner = yC * convInfo.strideWidth - padLeft; - for (let wC = 0; wC < filterWidth; ++wC) { - const xC = xCCorner + wC * dilationWidth; - if (xC < 0 || xC >= convInfo.inWidth) { - continue; - } - const wOffset2 = wOffset1 + wC * filterStrides[1]; - const xOffset3 = xOffset2 + xC * convInfo.inChannels; - let yOffset4 = yOffset3; - let wOffset3 = wOffset2; - for (let d1 = 0; d1 < convInfo.inChannels; ++d1) { - const xVal = xVals[xOffset3 + d1]; - for (let q = 0; q < chMul; ++q) { - yVals[yOffset4 + q] += xVal * wVals[wOffset3 + q]; - } - yOffset4 += chMul; - wOffset3 += chMul; - } - } - } - } - } - } - - return backend.makeTensorInfo(y.shape, y.dtype, y.values); -} - -export const depthwiseConv2dNativeConfig: KernelConfig = { - kernelName: DepthwiseConv2dNative, - backendName: 'cpu', - kernelFunc: depthwiseConv2dNative as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/DepthwiseConv2dNativeBackpropFilter.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/DepthwiseConv2dNativeBackpropFilter.ts deleted file mode 100644 index edd361ff8..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/DepthwiseConv2dNativeBackpropFilter.ts +++ /dev/null @@ -1,87 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, DepthwiseConv2dNativeBackpropFilter, DepthwiseConv2dNativeBackpropFilterAttrs, DepthwiseConv2dNativeBackpropFilterInputs, KernelConfig, KernelFunc, TensorBuffer, TensorInfo, TypedArray} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; -import {assertNotComplex} from '../cpu_util'; - -export function depthwiseConv2dNativeBackpropFilter(args: { - inputs: DepthwiseConv2dNativeBackpropFilterInputs, - backend: MathBackendCPU, - attrs: DepthwiseConv2dNativeBackpropFilterAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {x, dy} = inputs; - const {strides, dilations, pad, dimRoundingMode, filterShape} = attrs; - - assertNotComplex([x, dy], 'depthwiseConv2dNativeBackpropFilter'); - - const convInfo = backend_util.computeConv2DInfo( - x.shape as [number, number, number, number], filterShape, strides, - dilations, pad, dimRoundingMode, true /* depthwise */); - - const {strideHeight, strideWidth, filterHeight, filterWidth} = convInfo; - - const dW = new TensorBuffer(convInfo.filterShape, 'float32'); - - const leftPad = convInfo.padInfo.left; - const topPad = convInfo.padInfo.top; - const chMul = convInfo.outChannels / convInfo.inChannels; - - const xVals = backend.data.get(x.dataId).values as TypedArray; - const xBuf = new TensorBuffer(x.shape, x.dtype, xVals); - const dyVals = backend.data.get(dy.dataId).values as TypedArray; - const dyBuf = new TensorBuffer(dy.shape, dy.dtype, dyVals); - for (let wR = 0; wR < filterHeight; ++wR) { - const yRMin = Math.max(0, Math.ceil((topPad - wR) / strideHeight)); - const yRMax = Math.min( - convInfo.outHeight, (convInfo.inHeight + topPad - wR) / strideHeight); - - for (let wC = 0; wC < filterWidth; ++wC) { - const yCMin = Math.max(0, Math.ceil((leftPad - wC) / strideWidth)); - const yCMax = Math.min( - convInfo.outWidth, (convInfo.inWidth + leftPad - wC) / strideWidth); - - for (let d2 = 0; d2 < convInfo.outChannels; ++d2) { - const d1 = Math.trunc(d2 / chMul); - const dm = d2 % chMul; - - let dotProd = 0; - for (let b = 0; b < convInfo.batchSize; ++b) { - for (let yR = yRMin; yR < yRMax; ++yR) { - const xR = wR + yR * strideHeight - topPad; - for (let yC = yCMin; yC < yCMax; ++yC) { - const xC = wC + yC * strideWidth - leftPad; - dotProd += (xBuf.get(b, xR, xC, d1) as number) * - (dyBuf.get(b, yR, yC, d2) as number); - } - } - } - dW.set(dotProd, wR, wC, d1, dm); - } - } - } - - return backend.makeTensorInfo(dW.shape, dW.dtype, dW.values); -} - -export const depthwiseConv2dNativeBackpropFilterConfig: KernelConfig = { - kernelName: DepthwiseConv2dNativeBackpropFilter, - backendName: 'cpu', - kernelFunc: depthwiseConv2dNativeBackpropFilter as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/DepthwiseConv2dNativeBackpropInput.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/DepthwiseConv2dNativeBackpropInput.ts deleted file mode 100644 index ab6771e31..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/DepthwiseConv2dNativeBackpropInput.ts +++ /dev/null @@ -1,110 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, DepthwiseConv2dNativeBackpropInput, DepthwiseConv2dNativeBackpropInputAttrs, DepthwiseConv2dNativeBackpropInputInputs, KernelConfig, KernelFunc, TensorBuffer, TensorInfo, TypedArray, util} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; -import {assertNotComplex} from '../cpu_util'; - -export function depthwiseConv2dNativeBackpropInput(args: { - inputs: DepthwiseConv2dNativeBackpropInputInputs, - backend: MathBackendCPU, - attrs: DepthwiseConv2dNativeBackpropInputAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {dy, filter} = inputs; - const {strides, dilations, pad, dimRoundingMode, inputShape} = attrs; - - assertNotComplex([dy, filter], 'depthwiseConv2DNativeBackpropInput'); - - const dyStrides = util.computeStrides(dy.shape); - const filterStrides = util.computeStrides(filter.shape); - - const convInfo = backend_util.computeConv2DInfo( - inputShape, filter.shape as [number, number, number, number], strides, - dilations, pad, dimRoundingMode, true /* depthwise */); - - const dx = new TensorBuffer(convInfo.inShape, 'float32'); - const dxValues = dx.values; - const [dxS0, dxS1, dxS2] = dx.strides; - const dyValues = backend.data.get(dy.dataId).values as TypedArray; - const [dyS0, dyS1, dyS2] = dyStrides; - const fltValues = backend.data.get(filter.dataId).values as TypedArray; - const [fltS0, fltS1, fltS2] = filterStrides; - const { - batchSize, - filterHeight, - filterWidth, - inChannels, - inHeight, - inWidth, - outChannels, - outHeight, - outWidth, - strideHeight, - strideWidth - } = convInfo; - const topPad = filterHeight - 1 - convInfo.padInfo.top; - const leftPad = filterWidth - 1 - convInfo.padInfo.left; - const chMul = outChannels / inChannels; - - for (let b = 0; b < batchSize; ++b) { - for (let d1 = 0; d1 < inChannels; ++d1) { - for (let xR = 0; xR < inHeight; ++xR) { - const xRCorner = xR - topPad; - const xRMin = Math.max(0, Math.ceil(xRCorner / strideHeight)); - const yRMax = - Math.min(outHeight, (filterHeight + xRCorner) / strideHeight); - - for (let xC = 0; xC < inWidth; ++xC) { - const xCCorner = xC - leftPad; - const xCMin = Math.max(0, Math.ceil(xCCorner / strideWidth)); - const yCMax = - Math.min(outWidth, (filterWidth + xCCorner) / strideWidth); - - let dotProd = 0; - for (let yR = xRMin; yR < yRMax; ++yR) { - const wR = yR * strideHeight - xRCorner; - - for (let yC = xCMin; yC < yCMax; ++yC) { - const wC = yC * strideWidth - xCCorner; - const dyOffset = dyS0 * b + dyS1 * yR + dyS2 * yC; - const fltOffset = fltS0 * (filterHeight - 1 - wR) + - fltS1 * (filterWidth - 1 - wC) + fltS2 * d1; - - for (let dm = 0; dm < chMul; ++dm) { - const d2 = d1 * chMul + dm; - const pixel = dyValues[dyOffset + d2]; - const weight = fltValues[fltOffset + dm]; - dotProd += pixel * weight; - } - } - } - dxValues[dxS0 * b + dxS1 * xR + dxS2 * xC + d1] = dotProd; - } - } - } - } - - return backend.makeTensorInfo(dx.shape, dx.dtype, dx.values); -} - -export const depthwiseConv2dNativeBackpropInputConfig: KernelConfig = { - kernelName: DepthwiseConv2dNativeBackpropInput, - backendName: 'cpu', - kernelFunc: depthwiseConv2dNativeBackpropInput as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Diag.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Diag.ts deleted file mode 100644 index 6dd1788bd..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Diag.ts +++ /dev/null @@ -1,45 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {buffer, Diag, DiagInputs, KernelConfig, KernelFunc, TensorInfo, TypedArray, util} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; - -export function diag(args: {inputs: DiagInputs, backend: MathBackendCPU}): - TensorInfo { - const {inputs, backend} = args; - const {x} = inputs; - - const xSize = util.sizeFromShape(x.shape); - - const xVals = backend.data.get(x.dataId).values as TypedArray; - const outBuf = buffer([xSize, xSize], x.dtype); - const vals = outBuf.values; - for (let i = 0; i < xVals.length; i++) { - vals[i * xSize + i] = xVals[i]; - } - - const outShape = [...x.shape, ...x.shape]; - - return backend.makeTensorInfo(outShape, outBuf.dtype, outBuf.values); -} - -export const diagConfig: KernelConfig = { - kernelName: Diag, - backendName: 'cpu', - kernelFunc: diag as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Dilation2D.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Dilation2D.ts deleted file mode 100644 index 4abbe3644..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Dilation2D.ts +++ /dev/null @@ -1,104 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, Dilation2D, Dilation2DAttrs, Dilation2DInputs, KernelConfig, TypedArray, util} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; - -export const dilation2DConfig: KernelConfig = { - kernelName: Dilation2D, - backendName: 'cpu', - kernelFunc: ({inputs, backend, attrs}) => { - const {x, filter} = inputs as Dilation2DInputs; - const {strides, pad, dilations} = attrs as unknown as Dilation2DAttrs; - const cpuBackend = backend as MathBackendCPU; - - const xVals = cpuBackend.data.get(x.dataId).values as TypedArray; - const xRank = x.shape.length; - - const filterVals = cpuBackend.data.get(filter.dataId).values as TypedArray; - const filterRank = filter.shape.length; - - const { - batchSize, - inHeight, - inWidth, - inChannels, - outHeight, - outWidth, - padInfo, - strideHeight, - strideWidth, - filterHeight, - filterWidth, - dilationHeight, - dilationWidth, - outShape - } = - backend_util.computeDilation2DInfo( - x.shape as [number, number, number, number], - filter.shape as [number, number, number], strides, pad, - 'NHWC' /* dataFormat */, dilations); - - const outSize = util.sizeFromShape(outShape); - const outRank = outShape.length; - const outputVals = util.getArrayFromDType(x.dtype, outSize); - - // Upsampling the input by fill in `dilation size - 1` values between each - // input value. - // This implementation follows the TF c++ implementation: - // https://github.com/tensorflow/tensorflow/blob/d9a3a849edc198e90172bc58eb293de457f9d986/tensorflow/core/kernels/dilation_ops.cc - for (let b = 0; b < batchSize; ++b) { - for (let hOut = 0; hOut < outHeight; ++hOut) { - const hBeg = hOut * strideHeight - padInfo.top; - for (let wOut = 0; wOut < outWidth; ++wOut) { - const wBeg = wOut * strideWidth - padInfo.left; - for (let d = 0; d < inChannels; ++d) { - let curVal = Number.MIN_SAFE_INTEGER; - for (let h = 0; h < filterHeight; ++h) { - const hIn = hBeg + h * dilationHeight; - if (hIn >= 0 && hIn < inHeight) { - for (let w = 0; w < filterWidth; ++w) { - const wIn = wBeg + w * dilationWidth; - if (wIn >= 0 && wIn < inWidth) { - const xIndex = util.locToIndex( - [b, hIn, wIn, d], xRank, util.computeStrides(x.shape)); - const filterIndex = util.locToIndex( - [h, w, d], filterRank, - util.computeStrides(filter.shape)); - const val = xVals[xIndex] + filterVals[filterIndex]; - if (val > curVal) { - curVal = val; - } - } - } - } - } - const outputIndex = util.locToIndex( - [b, hOut, wOut, d], outRank, util.computeStrides(outShape)); - outputVals[outputIndex] = curVal; - } - } - } - } - - const dataId = cpuBackend.write( - util.toTypedArray(outputVals, x.dtype), outShape, x.dtype); - - return {dataId, shape: outShape, dtype: x.dtype}; - } -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Dilation2DBackpropFilter.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Dilation2DBackpropFilter.ts deleted file mode 100644 index 9924c903e..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Dilation2DBackpropFilter.ts +++ /dev/null @@ -1,120 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, Dilation2DAttrs, Dilation2DBackpropFilter, Tensor3D, Tensor4D, TypedArray, util} from '@tensorflow/tfjs-core'; -import {KernelConfig} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; - -export const dilation2DBackpropFilterConfig: KernelConfig = { - kernelName: Dilation2DBackpropFilter, - backendName: 'cpu', - kernelFunc: ({inputs, backend, attrs}) => { - const {x, filter, dy} = - inputs as {x: Tensor4D, filter: Tensor3D, dy: Tensor4D}; - const {strides, pad, dilations} = attrs as unknown as Dilation2DAttrs; - const cpuBackend = backend as MathBackendCPU; - - const $x = - util.toNestedArray( - x.shape, cpuBackend.data.get(x.dataId).values as TypedArray) as - number[][][][]; - - const $filter = util.toNestedArray( - filter.shape, - cpuBackend.data.get(filter.dataId).values as - TypedArray) as number[][][]; - - const { - batchSize, - inHeight, - inWidth, - inChannels, - outHeight, - outWidth, - padInfo, - strideHeight, - strideWidth, - filterHeight, - filterWidth, - dilationHeight, - dilationWidth, - outShape - } = - backend_util.computeDilation2DInfo( - x.shape as [number, number, number, number], - filter.shape as [number, number, number], strides, pad, - 'NHWC' /* dataFormat */, dilations); - - util.assert( - dy.rank === outShape.length, - () => `Error in ${Dilation2DBackpropFilter}, dy ` + - `must have the same rank as output ${outShape.length}, but got ` + - `${dy.rank}`); - - const $dy = - util.toNestedArray( - outShape, cpuBackend.data.get(dy.dataId).values as TypedArray) as - number[][][][]; - - // The computed filter gradients has the same dimensions as the filter: - // [filterHeight, filterWidth, depth] - const gradients = util.makeZerosNestedTypedArray( - filter.shape, filter.dtype) as number[][][]; - - // In the case of multiple argmax branches, we only back-propagate along the - // last branch, i.e., the one with largest value of `h * filter_cols + w`, - // similarly to the max-pooling backward routines. - // This implementation follows the TF c++ implementation: - // https://github.com/tensorflow/tensorflow/blob/d9a3a849edc198e90172bc58eb293de457f9d986/tensorflow/core/kernels/dilation_ops.cc - for (let b = 0; b < batchSize; ++b) { - for (let hOut = 0; hOut < outHeight; ++hOut) { - const hBeg = hOut * strideHeight - padInfo.top; - for (let wOut = 0; wOut < outWidth; ++wOut) { - const wBeg = wOut * strideWidth - padInfo.left; - for (let d = 0; d < inChannels; ++d) { - let curVal = Number.MIN_SAFE_INTEGER; - let hMax = 0; - let wMax = 0; - for (let h = 0; h < filterHeight; ++h) { - const hIn = hBeg + h * dilationHeight; - if (hIn >= 0 && hIn < inHeight) { - for (let w = 0; w < filterWidth; ++w) { - const wIn = wBeg + w * dilationWidth; - if (wIn >= 0 && wIn < inWidth) { - const val = $x[b][hIn][wIn][d] + $filter[h][w][d]; - if (val > curVal) { - curVal = val; - hMax = h; - wMax = w; - } - } - } - } - } - gradients[hMax][wMax][d] += $dy[b][hOut][wOut][d]; - } - } - } - } - - const dataId = cpuBackend.write( - util.toTypedArray(gradients, x.dtype), filter.shape, filter.dtype); - - return {dataId, shape: filter.shape, dtype: filter.dtype}; - } -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Dilation2DBackpropInput.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Dilation2DBackpropInput.ts deleted file mode 100644 index b4592a454..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Dilation2DBackpropInput.ts +++ /dev/null @@ -1,120 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, Dilation2DAttrs, Dilation2DBackpropInput, Tensor3D, Tensor4D, TypedArray, util} from '@tensorflow/tfjs-core'; -import {KernelConfig} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; - -export const dilation2DBackpropInputConfig: KernelConfig = { - kernelName: Dilation2DBackpropInput, - backendName: 'cpu', - kernelFunc: ({inputs, backend, attrs}) => { - const {x, filter, dy} = - inputs as {x: Tensor4D, filter: Tensor3D, dy: Tensor4D}; - const {strides, pad, dilations} = attrs as unknown as Dilation2DAttrs; - const cpuBackend = backend as MathBackendCPU; - - const $x = - util.toNestedArray( - x.shape, cpuBackend.data.get(x.dataId).values as TypedArray) as - number[][][][]; - - const $filter = util.toNestedArray( - filter.shape, - cpuBackend.data.get(filter.dataId).values as - TypedArray) as number[][][]; - - const { - batchSize, - inHeight, - inWidth, - inChannels, - outHeight, - outWidth, - padInfo, - strideHeight, - strideWidth, - filterHeight, - filterWidth, - dilationHeight, - dilationWidth, - outShape - } = - backend_util.computeDilation2DInfo( - x.shape as [number, number, number, number], - filter.shape as [number, number, number], strides, pad, - 'NHWC' /* dataFormat */, dilations); - - util.assert( - dy.rank === outShape.length, - () => `Error in ${Dilation2DBackpropInput}, dy ` + - `must have the same rank as output ${outShape.length}, but got ` + - `${dy.rank}`); - - const $dy = - util.toNestedArray( - outShape, cpuBackend.data.get(dy.dataId).values as TypedArray) as - number[][][][]; - - // The computed gradients has the same dimensions as the input: - // [batch, inputHeight, inputCols, inChannel] - const gradients = - util.makeZerosNestedTypedArray(x.shape, x.dtype) as number[][][][]; - - // In the case of multiple argmax branches, we only back-propagate along the - // last branch, i.e., the one with largest value of `h * filter_cols + w`, - // similarly to the max-pooling backward routines. - // This implementation follows the TF c++ implementation: - // https://github.com/tensorflow/tensorflow/blob/d9a3a849edc198e90172bc58eb293de457f9d986/tensorflow/core/kernels/dilation_ops.cc - for (let b = 0; b < batchSize; ++b) { - for (let hOut = 0; hOut < outHeight; ++hOut) { - const hBeg = hOut * strideHeight - padInfo.top; - for (let wOut = 0; wOut < outWidth; ++wOut) { - const wBeg = wOut * strideWidth - padInfo.left; - for (let d = 0; d < inChannels; ++d) { - let curVal = Number.MIN_SAFE_INTEGER; - let hInMax = (hBeg < 0) ? 0 : hBeg; - let wInMax = (wBeg < 0) ? 0 : wBeg; - for (let h = 0; h < filterHeight; ++h) { - const hIn = hBeg + h * dilationHeight; - if (hIn >= 0 && hIn < inHeight) { - for (let w = 0; w < filterWidth; ++w) { - const wIn = wBeg + w * dilationWidth; - if (wIn >= 0 && wIn < inWidth) { - const val = $x[b][hIn][wIn][d] + $filter[h][w][d]; - if (val > curVal) { - curVal = val; - hInMax = hIn; - wInMax = wIn; - } - } - } - } - } - gradients[b][hInMax][wInMax][d] += $dy[b][hOut][wOut][d]; - } - } - } - } - - const dataId = cpuBackend.write( - util.toTypedArray(gradients, x.dtype), x.shape, x.dtype); - - return {dataId, shape: x.shape, dtype: x.dtype}; - } -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Draw.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Draw.ts deleted file mode 100644 index b71d7c2c3..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Draw.ts +++ /dev/null @@ -1,96 +0,0 @@ -/** - * @license - * Copyright 2023 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Draw, DrawAttrs, DrawInputs, KernelConfig, KernelFunc, TypedArray} from '@tensorflow/tfjs-core'; -import {TensorInfo} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; - -export function draw( - args: {inputs: DrawInputs, backend: MathBackendCPU, attrs: DrawAttrs}): - TensorInfo { - const {inputs, backend, attrs} = args; - const {image} = inputs; - const {canvas, options} = attrs; - const {contextOptions, imageOptions} = options || {}; - const alpha = imageOptions ?.alpha || 1; - - const contextType = contextOptions ?.contextType || '2d'; - if (contextType !== '2d') { - throw new Error(`Context type ${ - contextOptions.contextType} is not supported by the CPU backend.`); - } - const ctx = canvas.getContext(contextType, - contextOptions?.contextAttributes || {}) as CanvasRenderingContext2D ; - if (ctx == null) { - throw new Error(`Could not get the context with ${contextType} type.`); - } - - const [height, width] = image.shape.slice(0, 2); - const depth = image.shape.length === 2 ? 1 : image.shape[2]; - const data = backend.data.get(image.dataId).values as TypedArray; - const multiplier = image.dtype === 'float32' ? 255 : 1; - const bytes = new Uint8ClampedArray(width * height * 4); - - for (let i = 0; i < height * width; ++i) { - const rgba = [0, 0, 0, 255 * alpha]; - - for (let d = 0; d < depth; d++) { - const value = data[i * depth + d]; - - if (image.dtype === 'float32') { - if (value < 0 || value > 1) { - throw new Error( - `Tensor values for a float32 Tensor must be in the ` + - `range [0 - 1] but encountered ${value}.`); - } - } else if (image.dtype === 'int32') { - if (value < 0 || value > 255) { - throw new Error( - `Tensor values for a int32 Tensor must be in the ` + - `range [0 - 255] but encountered ${value}.`); - } - } - - if (depth === 1) { - rgba[0] = value * multiplier; - rgba[1] = value * multiplier; - rgba[2] = value * multiplier; - } else { - rgba[d] = value * multiplier; - } - } - - const j = i * 4; - bytes[j + 0] = Math.round(rgba[0]); - bytes[j + 1] = Math.round(rgba[1]); - bytes[j + 2] = Math.round(rgba[2]); - bytes[j + 3] = Math.round(rgba[3]); - } - - canvas.width = width; - canvas.height = height; - const imageData = new ImageData(bytes, width, height); - ctx.putImageData(imageData, 0, 0); - return image; -} - -export const drawConfig: KernelConfig = { - kernelName: Draw, - backendName: 'cpu', - kernelFunc: draw as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Einsum.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Einsum.ts deleted file mode 100644 index 40c2c24ae..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Einsum.ts +++ /dev/null @@ -1,102 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, Einsum, EinsumAttrs, EinsumInputs, KernelConfig, KernelFunc, Tensor, TensorInfo, util} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; - -import {multiply} from './Multiply'; -import {reshape} from './Reshape'; -import {sum} from './Sum'; -import {transpose} from './Transpose'; - -export function einsum( - args: {inputs: EinsumInputs, backend: MathBackendCPU, attrs: EinsumAttrs}): - TensorInfo { - const {inputs, backend, attrs} = args; - const {equation} = attrs; - const tensors = inputs as Tensor[]; - - const {allDims, summedDims, idDims} = - backend_util.decodeEinsumEquation(equation, tensors.length); - backend_util.checkEinsumDimSizes(allDims.length, idDims, tensors); - const {path, steps} = backend_util.getEinsumComputePath(summedDims, idDims); - - const nSteps = steps.length; - let out: TensorInfo|null = null; - let numDimsRemaining = allDims.length; - const tensorsToDispose: TensorInfo[] = []; - for (let i = 0; i < nSteps; ++i) { - for (const idTerm of steps[i]) { - const {permutationIndices: perm, expandDims: dimsToExpand} = - backend_util.getEinsumPermutation(numDimsRemaining, idDims[idTerm]); - let x: TensorInfo; - if (backend_util.isIdentityPermutation(perm)) { - x = tensors[idTerm]; - } else { - x = transpose({inputs: {x: tensors[idTerm]}, backend, attrs: {perm}}); - tensorsToDispose.push(x); - } - const targetShape: number[] = x.shape.slice(); - for (let k = 0; k < dimsToExpand.length; ++k) { - targetShape.splice(dimsToExpand[k], 0, 1); - } - - if (!util.arraysEqual(x.shape, targetShape)) { - x = reshape({inputs: {x}, backend, attrs: {shape: targetShape}}); - tensorsToDispose.push(x); - } - if (out === null) { - out = x; - } else { - // tslint:disable-next-line: no-unnecessary-type-assertion - out = multiply({inputs: {a: x, b: out}, backend}) as TensorInfo; - tensorsToDispose.push(out); - } - } - if (i < nSteps - 1) { - if (path[i] >= 0) { - out = sum({ - inputs: {x: out}, - backend, - attrs: { - axis: path[i] - (allDims.length - numDimsRemaining), - keepDims: false - } - }); - tensorsToDispose.push(out); - } - numDimsRemaining--; - } - } - - // Clean up intermediate tensors. - for (const tensorInfo of tensorsToDispose) { - if (tensorInfo === out) { - continue; - } - backend.disposeIntermediateTensorInfo(tensorInfo); - } - - return out; -} - -export const einsumConfig: KernelConfig = { - kernelName: Einsum, - backendName: 'cpu', - kernelFunc: einsum as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Elu.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Elu.ts deleted file mode 100644 index 555d402df..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Elu.ts +++ /dev/null @@ -1,29 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Elu, KernelConfig} from '@tensorflow/tfjs-core'; - -import {unaryKernelFunc} from '../utils/unary_utils'; - -export const elu = - unaryKernelFunc(Elu, (xi) => xi >= 0 ? xi : (Math.exp(xi) - 1)); - -export const eluConfig: KernelConfig = { - kernelName: Elu, - backendName: 'cpu', - kernelFunc: elu, -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/EluGrad.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/EluGrad.ts deleted file mode 100644 index f7495bc97..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/EluGrad.ts +++ /dev/null @@ -1,49 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {EluGrad, EluGradInputs, KernelConfig, KernelFunc, TensorInfo, TypedArray, util} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; -import {assertNotComplex} from '../cpu_util'; - -export function eluGrad(args: {inputs: EluGradInputs, backend: MathBackendCPU}): - TensorInfo { - const {inputs, backend} = args; - const {dy, y} = inputs; - - assertNotComplex([dy, y], 'eluGrad'); - - const resultValues = new Float32Array(util.sizeFromShape(y.shape)); - const values = backend.data.get(y.dataId).values as TypedArray; - const dyValues = backend.data.get(dy.dataId).values as TypedArray; - for (let i = 0; i < values.length; ++i) { - const v = values[i]; - if (v >= 0) { - resultValues[i] = dyValues[i]; - } else { - resultValues[i] = dyValues[i] * (v + 1); - } - } - - return backend.makeTensorInfo(y.shape, 'float32', resultValues); -} - -export const eluGradConfig: KernelConfig = { - kernelName: EluGrad, - backendName: 'cpu', - kernelFunc: eluGrad as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Equal.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Equal.ts deleted file mode 100644 index bd21f00c4..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Equal.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Equal, KernelConfig} from '@tensorflow/tfjs-core'; - -import {createSimpleBinaryKernelImpl} from '../utils/binary_impl'; -import {binaryKernelFunc} from '../utils/binary_utils'; - -export const equalImpl = - createSimpleBinaryKernelImpl((a: number, b: number) => (a === b) ? 1 : 0); -export const equal = - binaryKernelFunc(Equal, equalImpl, null /* complexImpl */, 'bool'); - -export const equalConfig: KernelConfig = { - kernelName: Equal, - backendName: 'cpu', - kernelFunc: equal -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Erf.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Erf.ts deleted file mode 100644 index 6c41d9cff..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Erf.ts +++ /dev/null @@ -1,46 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, Erf, KernelConfig} from '@tensorflow/tfjs-core'; - -import {unaryKernelFunc} from '../utils/unary_utils'; - -const p = backend_util.ERF_P; -const a1 = backend_util.ERF_A1; -const a2 = backend_util.ERF_A2; -const a3 = backend_util.ERF_A3; -const a4 = backend_util.ERF_A4; -const a5 = backend_util.ERF_A5; - -export const erf = unaryKernelFunc( - Erf, - (xi) => { - const sign = Math.sign(xi); - const v = Math.abs(xi); - const t = 1.0 / (1.0 + p * v); - return sign * - (1.0 - - (((((a5 * t + a4) * t) + a3) * t + a2) * t + a1) * t * - Math.exp(-v * v)); - }, -); - -export const erfConfig: KernelConfig = { - kernelName: Erf, - backendName: 'cpu', - kernelFunc: erf, -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Exp.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Exp.ts deleted file mode 100644 index 612cbb79b..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Exp.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Exp, KernelConfig} from '@tensorflow/tfjs-core'; - -import {createSimpleUnaryImpl} from '../utils/unary_impl'; -import {unaryKernelFuncFromImpl} from '../utils/unary_utils'; - -export const expImpl = createSimpleUnaryImpl((xi) => Math.exp(xi)); -export const exp = unaryKernelFuncFromImpl(Exp, expImpl, 'float32'); - -export const expConfig: KernelConfig = { - kernelName: Exp, - backendName: 'cpu', - kernelFunc: exp, -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/ExpandDims.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/ExpandDims.ts deleted file mode 100644 index de606e7bf..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/ExpandDims.ts +++ /dev/null @@ -1,52 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ExpandDims, ExpandDimsAttrs, ExpandDimsInputs, KernelConfig, KernelFunc, TensorInfo, util} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; -import {reshape} from './Reshape'; - -export function expandDims(args: { - inputs: ExpandDimsInputs, - backend: MathBackendCPU, - attrs: ExpandDimsAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {input} = inputs; - const {dim} = attrs; - - const inputRank = input.shape.length; - const newShape = input.shape.slice(); - let $dim = dim; - if (dim < 0) { - // Negative value is counted from the tail of rank. - util.assert( - -(inputRank + 1) <= dim, - () => `Axis must be in the interval [${- (inputRank + 1)}, ${ - inputRank}]`); - $dim = inputRank + dim + 1; - } - newShape.splice($dim, 0, 1); - - return reshape({inputs: {x: input}, backend, attrs: {shape: newShape}}); -} - -export const expandDimsConfig: KernelConfig = { - kernelName: ExpandDims, - backendName: 'cpu', - kernelFunc: expandDims as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Expm1.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Expm1.ts deleted file mode 100644 index 3b52a7b06..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Expm1.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Expm1, KernelConfig} from '@tensorflow/tfjs-core'; - -import {createSimpleUnaryImpl} from '../utils/unary_impl'; -import {unaryKernelFuncFromImpl} from '../utils/unary_utils'; - -export const expm1Impl = createSimpleUnaryImpl((xi) => Math.expm1(xi)); -export const expm1 = unaryKernelFuncFromImpl(Expm1, expm1Impl); - -export const expm1Config: KernelConfig = { - kernelName: Expm1, - backendName: 'cpu', - kernelFunc: expm1, -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/FFT.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/FFT.ts deleted file mode 100644 index a8c3dd272..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/FFT.ts +++ /dev/null @@ -1,56 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {FFT, FFTInputs, KernelConfig, KernelFunc, TensorInfo, util} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; -import {fftBatch} from '../utils/fft_utils'; -import {reshape} from './Reshape'; - -export function fft(args: {inputs: FFTInputs, backend: MathBackendCPU}): - TensorInfo { - const {inputs, backend} = args; - const {input} = inputs; - - const inputSize = util.sizeFromShape(input.shape); - - // Collapse all outer dimensions to a single batch dimension. - const innerDimensionSize = input.shape[input.shape.length - 1]; - const batch = inputSize / innerDimensionSize; - - const input2D = reshape({ - inputs: {x: input}, - backend, - attrs: {shape: [batch, innerDimensionSize]} - }); - - const result = fftBatch(input2D, false, backend); - - const resultReshaped = - reshape({inputs: {x: result}, backend, attrs: {shape: input.shape}}); - - backend.disposeIntermediateTensorInfo(input2D); - backend.disposeIntermediateTensorInfo(result); - - return resultReshaped; -} - -export const fftConfig: KernelConfig = { - kernelName: FFT, - backendName: 'cpu', - kernelFunc: fft as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Fill.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Fill.ts deleted file mode 100644 index d4c64a2e1..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Fill.ts +++ /dev/null @@ -1,47 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {DataType, DataValues, Fill, FillAttrs, KernelConfig, KernelFunc, TensorInfo, TypedArray, util} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; - -export function fill(args: {backend: MathBackendCPU, attrs: FillAttrs}): - TensorInfo { - const {backend, attrs} = args; - const {shape, value, dtype} = attrs; - - const $dtype = dtype || util.inferDtype(value); - const values = util.getArrayFromDType($dtype, util.sizeFromShape(shape)); - fillValues(values, value, $dtype); - - return backend.makeTensorInfo(shape, $dtype, values); -} - -export const fillConfig: KernelConfig = { - kernelName: Fill, - backendName: 'cpu', - kernelFunc: fill as unknown as KernelFunc -}; - -function fillValues( - values: DataValues, value: string|number, dtype: DataType): void { - if (dtype === 'string') { - (values as string[]).fill(value as string); - } else { - (values as TypedArray).fill(value as number); - } -} diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/FlipLeftRight.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/FlipLeftRight.ts deleted file mode 100644 index b3acba7e2..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/FlipLeftRight.ts +++ /dev/null @@ -1,67 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, NumericDataType, TypedArray} from '@tensorflow/tfjs-core'; -import {FlipLeftRight, FlipLeftRightInputs, util} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; - -export const flipLeftRightConfig: KernelConfig = { - kernelName: FlipLeftRight, - backendName: 'cpu', - kernelFunc: ({inputs, attrs, backend}) => { - const {image} = inputs as FlipLeftRightInputs; - const cpuBackend = backend as MathBackendCPU; - - const output = util.getTypedArrayFromDType( - image.dtype as NumericDataType, util.sizeFromShape(image.shape)); - const [batch, imageHeight, imageWidth, numChannels] = image.shape; - - const imageVals = cpuBackend.data.get(image.dataId).values as TypedArray; - - for (let batchIdx = 0; batchIdx < batch; batchIdx++) { - const batchOffset = batchIdx * imageWidth * imageHeight * numChannels; - - for (let row = 0; row < imageHeight; row++) { - const rowOffset = row * (imageWidth * numChannels); - - for (let col = 0; col < imageWidth; col++) { - const colOffset = col * numChannels; - - for (let channel = 0; channel < numChannels; channel++) { - const coordX = Math.round(imageWidth - col - 1); - const outIdx = batchOffset + rowOffset + colOffset + channel; - - let outputValue = imageVals[outIdx]; - // If the coordinate position falls within the image boundaries... - if (coordX >= 0 && coordX < imageWidth) { - // set the output to the image value at the coordinate position. - const rotatedColOffset = coordX * numChannels; - const imageIdx = - batchOffset + rowOffset + rotatedColOffset + channel; - outputValue = imageVals[imageIdx]; - } - output[outIdx] = outputValue; - } - } - } - } - - const dataId = cpuBackend.write(output, image.shape, image.dtype); - return {dataId, shape: image.shape, dtype: image.dtype}; - } -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Floor.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Floor.ts deleted file mode 100644 index 5b6636471..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Floor.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Floor, KernelConfig} from '@tensorflow/tfjs-core'; - -import {createSimpleUnaryImpl} from '../utils/unary_impl'; -import {unaryKernelFuncFromImpl} from '../utils/unary_utils'; - -export const floorImpl = createSimpleUnaryImpl((xi) => Math.floor(xi)); -export const floor = unaryKernelFuncFromImpl(Floor, floorImpl); - -export const floorConfig: KernelConfig = { - kernelName: Floor, - backendName: 'cpu', - kernelFunc: floor, -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/FloorDiv.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/FloorDiv.ts deleted file mode 100644 index 71346b866..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/FloorDiv.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {FloorDiv, KernelConfig} from '@tensorflow/tfjs-core'; - -import {createSimpleBinaryKernelImpl} from '../utils/binary_impl'; -import {binaryKernelFunc} from '../utils/binary_utils'; - -export const floorDivImpl = - createSimpleBinaryKernelImpl((a: number, b: number) => Math.floor(a / b)); -export const floorDiv = - binaryKernelFunc(FloorDiv, floorDivImpl, null /* complexImpl */, 'int32'); - -export const floorDivConfig: KernelConfig = { - kernelName: FloorDiv, - backendName: 'cpu', - kernelFunc: floorDiv -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/FusedConv2D.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/FusedConv2D.ts deleted file mode 100644 index 0af847dfa..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/FusedConv2D.ts +++ /dev/null @@ -1,101 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {FusedConv2D, FusedConv2DAttrs, FusedConv2DInputs, KernelConfig, KernelFunc, TensorInfo} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; -import {applyActivation} from '../utils/fused_utils'; -import {add} from './Add'; -import {conv2D} from './Conv2D'; -import {reshape} from './Reshape'; - -export function fusedConv2D(args: { - inputs: FusedConv2DInputs, - backend: MathBackendCPU, - attrs: FusedConv2DAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {x, filter, bias, preluActivationWeights} = inputs; - const { - strides, - pad, - dataFormat, - dilations, - dimRoundingMode, - activation, - leakyreluAlpha - } = attrs; - - let result = conv2D({ - inputs: {x, filter}, - backend, - attrs: {strides, pad, dataFormat, dilations, dimRoundingMode} - }); - - if (bias) { - const resultOld = result; - // For NCHW format, if bias is a 1-D tensor, it is supposed to be aligned - // to the channel of the conv2d's result; if the bias is a scalar, the - // bias_add is computed as if the bias was broadcasted to the shape of the - // conv2d's result. - if (dataFormat === 'NCHW' && bias.shape.length === 1 && - bias.shape[0] !== 1) { - const reshapedBias = reshape( - {inputs: {x: bias}, backend, attrs: {shape: [bias.shape[0], 1, 1]}}); - result = - add({inputs: {a: result, b: reshapedBias}, backend}) as TensorInfo; - backend.disposeIntermediateTensorInfo(reshapedBias); - } else { - // This condition handles NHWC and NCHW (scalar case). The only other case - // for NCHW (1D case) is handled above. - result = add({inputs: {a: result, b: bias}, backend}) as TensorInfo; - } - backend.disposeIntermediateTensorInfo(resultOld); - } - - if (activation) { - const resultOld = result; - // For NCHW format, if PReLu activation weights is a 1-D tensor, it is - // supposed to be aligned with the channel of the conv2d's result. For other - // cases, whether NCHW or NHWC data format, the conv2d result is - // already aligned with the activation weights. - if (dataFormat === 'NCHW' && activation === 'prelu' && - preluActivationWeights.shape.length === 1 && - preluActivationWeights.shape[0] !== 1) { - const reshapedAlpha = reshape({ - inputs: {x: preluActivationWeights}, - backend, - attrs: {shape: [preluActivationWeights.shape[0], 1, 1]} - }); - result = applyActivation( - backend, result, activation, reshapedAlpha, leakyreluAlpha); - backend.disposeIntermediateTensorInfo(reshapedAlpha); - } else { - result = applyActivation( - backend, result, activation, preluActivationWeights, leakyreluAlpha); - } - backend.disposeIntermediateTensorInfo(resultOld); - } - - return result; -} - -export const fusedConv2DConfig: KernelConfig = { - kernelName: FusedConv2D, - backendName: 'cpu', - kernelFunc: fusedConv2D as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/FusedDepthwiseConv2D.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/FusedDepthwiseConv2D.ts deleted file mode 100644 index c37ae7787..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/FusedDepthwiseConv2D.ts +++ /dev/null @@ -1,67 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {FusedDepthwiseConv2D, FusedDepthwiseConv2DAttrs, FusedDepthwiseConv2DInputs, KernelConfig, KernelFunc, TensorInfo} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; -import {applyActivation} from '../utils/fused_utils'; -import {add} from './Add'; -import {depthwiseConv2dNative} from './DepthwiseConv2dNative'; - -export function fusedDepthwiseConv2D(args: { - inputs: FusedDepthwiseConv2DInputs, - backend: MathBackendCPU, - attrs: FusedDepthwiseConv2DAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {x, filter, bias, preluActivationWeights} = inputs; - const { - strides, - pad, - dataFormat, - dilations, - dimRoundingMode, - activation, - leakyreluAlpha - } = attrs; - - let result = depthwiseConv2dNative({ - inputs: {x, filter}, - backend, - attrs: {strides, pad, dataFormat, dilations, dimRoundingMode} - }); - - if (bias) { - const oldResult = result; - result = add({inputs: {a: result, b: bias}, backend}) as TensorInfo; - backend.disposeIntermediateTensorInfo(oldResult); - } - if (activation) { - const oldResult = result; - result = applyActivation( - backend, result, activation, preluActivationWeights, leakyreluAlpha); - backend.disposeIntermediateTensorInfo(oldResult); - } - - return result; -} - -export const fusedDepthwiseConv2DConfig: KernelConfig = { - kernelName: FusedDepthwiseConv2D, - backendName: 'cpu', - kernelFunc: fusedDepthwiseConv2D as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/GatherNd.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/GatherNd.ts deleted file mode 100644 index 80ade55cc..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/GatherNd.ts +++ /dev/null @@ -1,53 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, GatherNd, GatherNdInputs, KernelConfig, KernelFunc, Rank, TensorInfo, TypedArray, util} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; - -import {gatherNdImpl} from './GatherNd_Impl'; - -export function gatherNd( - args: {inputs: GatherNdInputs, backend: MathBackendCPU}): TensorInfo { - const {inputs, backend} = args; - const {params, indices} = inputs; - - const paramsSize = util.sizeFromShape(params.shape); - - const indicesShape = indices.shape; - const sliceRank = indicesShape[indicesShape.length - 1]; - - const [resultShape, numSlices, sliceSize, strides] = - backend_util.prepareAndValidate(params, indices); - if (numSlices === 0) { - return backend.makeTensorInfo(resultShape, params.dtype, []); - } - - const indicesData = backend.data.get(indices.dataId).values as TypedArray; - const paramsBuf = backend.bufferSync(params); - const outBuf = gatherNdImpl( - indicesData, paramsBuf, params.dtype, numSlices, sliceRank, sliceSize, - strides, params.shape, paramsSize); - - return backend.makeTensorInfo(resultShape, params.dtype, outBuf.values); -} - -export const gatherNdConfig: KernelConfig = { - kernelName: GatherNd, - backendName: 'cpu', - kernelFunc: gatherNd as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/GatherNd_Impl.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/GatherNd_Impl.ts deleted file mode 100644 index 36e6f2b5f..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/GatherNd_Impl.ts +++ /dev/null @@ -1,46 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {buffer, DataType, Rank, TensorBuffer, TypedArray} from '@tensorflow/tfjs-core'; - -export function gatherNdImpl( - indicesData: TypedArray, paramsBuf: TensorBuffer, dtype: DataType, - numSlices: number, sliceRank: number, sliceSize: number, strides: number[], - paramsShape: number[], paramsSize: number): TensorBuffer { - const outBuf = buffer([numSlices, sliceSize], dtype); - - for (let i = 0; i < numSlices; i++) { - const index = []; - let flattenIndex = 0; - for (let j = 0; j < sliceRank; j++) { - const dim = indicesData[i * sliceRank + j]; - flattenIndex += dim * strides[j]; - index.push(dim); - } - if (flattenIndex < 0 || flattenIndex >= paramsSize / sliceSize) { - throw new Error( - `Invalid indices: ${index} does not index into ${paramsShape}`); - } - - for (let k = 0; k < sliceSize; k++) { - outBuf.values[i * sliceSize + k] = - paramsBuf.get(...paramsBuf.indexToLoc(flattenIndex * sliceSize + k)); - } - } - - return outBuf as TensorBuffer; -} diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/GatherV2.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/GatherV2.ts deleted file mode 100644 index 57d0eecc5..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/GatherV2.ts +++ /dev/null @@ -1,96 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, GatherV2, GatherV2Attrs, GatherV2Inputs, KernelConfig, KernelFunc, TensorInfo, TypedArray, util} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; -import {assertNotComplex} from '../cpu_util'; -import {gatherV2Impl} from './GatherV2_impl'; -import {reshape} from './Reshape'; - -export function gatherV2(args: { - inputs: GatherV2Inputs, - backend: MathBackendCPU, - attrs: GatherV2Attrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {x, indices} = inputs; - const {axis, batchDims} = attrs; - - assertNotComplex([x, indices], 'gatherV2'); - - // Throw error when any index is out of bound. - const parsedAxis = util.parseAxisParam(axis, x.shape)[0]; - const indicesVals = backend.data.get(indices.dataId).values as TypedArray; - const axisDim = x.shape[parsedAxis]; - for (let i = 0; i < indicesVals.length; ++i) { - const index = indicesVals[i]; - util.assert( - index <= axisDim - 1 && index >= 0, - () => - `GatherV2: the index value ${index} is not in [0, ${axisDim - 1}]`); - } - - let $batchDims = batchDims; - - if (batchDims == null) { - $batchDims = 0; - } - - const indicesSize = util.sizeFromShape(indices.shape); - - const shapeInfo = backend_util.segment_util.collectGatherOpShapeInfo( - x, indices, parsedAxis, $batchDims); - - const flattenX = reshape({ - inputs: {x}, - backend, - attrs: { - shape: [ - shapeInfo.batchSize, shapeInfo.outerSize, shapeInfo.dimSize, - shapeInfo.sliceSize - ] - } - }); - - const flattenIndex = reshape({ - inputs: {x: indices}, - backend, - attrs: {shape: [shapeInfo.batchSize, indicesSize / shapeInfo.batchSize]} - }); - - const flattenOutputShape = [ - shapeInfo.batchSize, shapeInfo.outerSize, indicesSize / shapeInfo.batchSize, - shapeInfo.sliceSize - ]; - - const indicesBuf = backend.bufferSync(flattenIndex); - const xBuf = backend.bufferSync(flattenX); - const outBuf = gatherV2Impl(xBuf, indicesBuf, flattenOutputShape); - - backend.disposeIntermediateTensorInfo(flattenX); - backend.disposeIntermediateTensorInfo(flattenIndex); - - return backend.makeTensorInfo( - shapeInfo.outputShape, outBuf.dtype, outBuf.values); -} - -export const gatherV2Config: KernelConfig = { - kernelName: GatherV2, - backendName: 'cpu', - kernelFunc: gatherV2 as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/GatherV2_impl.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/GatherV2_impl.ts deleted file mode 100644 index 5e8414338..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/GatherV2_impl.ts +++ /dev/null @@ -1,41 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {buffer, DataType, Rank, TensorBuffer} from '@tensorflow/tfjs-core'; - -export function gatherV2Impl( - xBuf: TensorBuffer, indicesBuf: TensorBuffer, - flattenOutputShape: number[]): TensorBuffer { - const outBuf = buffer(flattenOutputShape, xBuf.dtype); - for (let i = 0; i < outBuf.size; ++i) { - const newLoc = outBuf.indexToLoc(i); - - const originalLoc: number[] = newLoc.slice(); - const batchIdx = originalLoc[0]; - const indicesIdx = originalLoc[2]; - const indicesIndex = indicesBuf.locToIndex([batchIdx, indicesIdx]); - originalLoc[2] = indicesBuf.values[indicesIndex] as number; - - const originalIndex = xBuf.locToIndex(originalLoc); - - if (0 <= originalIndex && originalIndex < xBuf.values.length) { - outBuf.values[i] = xBuf.values[originalIndex]; - } // Else, index is out of bounds, so leave the default zero val in outBuf. - } - - return outBuf as TensorBuffer; -} diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Greater.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Greater.ts deleted file mode 100644 index fe8094057..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Greater.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Greater, KernelConfig} from '@tensorflow/tfjs-core'; - -import {createSimpleBinaryKernelImpl} from '../utils/binary_impl'; -import {binaryKernelFunc} from '../utils/binary_utils'; - -export const greaterImpl = - createSimpleBinaryKernelImpl((a: number, b: number) => (a > b) ? 1 : 0); -export const greater = - binaryKernelFunc(Greater, greaterImpl, null /* complexImpl */, 'bool'); - -export const greaterConfig: KernelConfig = { - kernelName: Greater, - backendName: 'cpu', - kernelFunc: greater -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/GreaterEqual.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/GreaterEqual.ts deleted file mode 100644 index 827c54233..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/GreaterEqual.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {GreaterEqual, KernelConfig} from '@tensorflow/tfjs-core'; - -import {createSimpleBinaryKernelImpl} from '../utils/binary_impl'; -import {binaryKernelFunc} from '../utils/binary_utils'; - -export const greaterEqualImpl = - createSimpleBinaryKernelImpl((a: number, b: number) => (a >= b) ? 1 : 0); -export const greaterEqual = binaryKernelFunc( - GreaterEqual, greaterEqualImpl, null /* complexImpl */, 'bool'); - -export const greaterEqualConfig: KernelConfig = { - kernelName: GreaterEqual, - backendName: 'cpu', - kernelFunc: greaterEqual -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/IFFT.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/IFFT.ts deleted file mode 100644 index a733fab6b..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/IFFT.ts +++ /dev/null @@ -1,56 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {IFFT, IFFTInputs, KernelConfig, KernelFunc, TensorInfo, util} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; -import {fftBatch} from '../utils/fft_utils'; -import {reshape} from './Reshape'; - -export function ifft(args: {inputs: IFFTInputs, backend: MathBackendCPU}): - TensorInfo { - const {inputs, backend} = args; - const {input} = inputs; - - const inputSize = util.sizeFromShape(input.shape); - - // Collapse all outer dimensions to a single batch dimension. - const innerDimensionSize = input.shape[input.shape.length - 1]; - const batch = inputSize / innerDimensionSize; - - const input2D = reshape({ - inputs: {x: input}, - backend, - attrs: {shape: [batch, innerDimensionSize]} - }); - - const result = fftBatch(input2D, true, backend); - - const resultReshaped = - reshape({inputs: {x: result}, backend, attrs: {shape: input.shape}}); - - backend.disposeIntermediateTensorInfo(input2D); - backend.disposeIntermediateTensorInfo(result); - - return resultReshaped; -} - -export const ifftConfig: KernelConfig = { - kernelName: IFFT, - backendName: 'cpu', - kernelFunc: ifft as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Identity.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Identity.ts deleted file mode 100644 index 8f0cf0389..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Identity.ts +++ /dev/null @@ -1,36 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Identity, IdentityInputs, KernelConfig, KernelFunc, TensorInfo} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; - -export function identity( - args: {inputs: IdentityInputs, backend: MathBackendCPU}): TensorInfo { - const {inputs, backend} = args; - const {x} = inputs; - - backend.incRef(x.dataId); - - return {dataId: x.dataId, shape: x.shape, dtype: x.dtype}; -} - -export const identityConfig: KernelConfig = { - kernelName: Identity, - backendName: 'cpu', - kernelFunc: identity as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Imag.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Imag.ts deleted file mode 100644 index 758ad683a..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Imag.ts +++ /dev/null @@ -1,40 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Imag, ImagInputs, KernelConfig, KernelFunc, TensorInfo} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; - -export function imag(args: {inputs: ImagInputs, backend: MathBackendCPU}): - TensorInfo { - const {inputs, backend} = args; - const {input} = inputs; - - const imag = backend.data.get(input.dataId).complexTensorInfos.imag; - const imagVal = backend.data.get(imag.dataId).values; - - // When complex tensor is disposed, its underlying parts will be disposed too. - // Make new tensor out of the imag value of the complex. This makes sure the - // value is still accessible even if complex tensor is disposed. - return backend.makeTensorInfo(imag.shape, imag.dtype, imagVal); -} - -export const imagConfig: KernelConfig = { - kernelName: Imag, - backendName: 'cpu', - kernelFunc: imag as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/IsFinite.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/IsFinite.ts deleted file mode 100644 index 36ce04241..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/IsFinite.ts +++ /dev/null @@ -1,29 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {IsFinite, KernelConfig} from '@tensorflow/tfjs-core'; - -import {unaryKernelFunc} from '../utils/unary_utils'; - -export const isFinite = - unaryKernelFunc(IsFinite, (xi) => Number.isFinite(xi) ? 1 : 0, 'bool'); - -export const isFiniteConfig: KernelConfig = { - kernelName: IsFinite, - backendName: 'cpu', - kernelFunc: isFinite, -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/IsInf.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/IsInf.ts deleted file mode 100644 index ce511d601..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/IsInf.ts +++ /dev/null @@ -1,29 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {IsInf, KernelConfig} from '@tensorflow/tfjs-core'; - -import {unaryKernelFunc} from '../utils/unary_utils'; - -export const isInf = - unaryKernelFunc(IsInf, (xi) => Math.abs(xi) === Infinity ? 1 : 0, 'bool'); - -export const isInfConfig: KernelConfig = { - kernelName: IsInf, - backendName: 'cpu', - kernelFunc: isInf, -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/IsNaN.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/IsNaN.ts deleted file mode 100644 index 0c3607fcc..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/IsNaN.ts +++ /dev/null @@ -1,29 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {IsNan, KernelConfig} from '@tensorflow/tfjs-core'; - -import {unaryKernelFunc} from '../utils/unary_utils'; - -export const isNaN = - unaryKernelFunc(IsNan, (xi) => Number.isNaN(xi) ? 1 : 0, 'bool'); - -export const isNaNConfig: KernelConfig = { - kernelName: IsNan, - backendName: 'cpu', - kernelFunc: isNaN, -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/LRN.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/LRN.ts deleted file mode 100644 index 0e0516e1e..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/LRN.ts +++ /dev/null @@ -1,67 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, LRN, LRNAttrs, LRNInputs, TensorInfo, TypedArray, util} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; -import {assertNotComplex} from '../cpu_util'; - -export function lRN( - args: {inputs: LRNInputs, backend: MathBackendCPU, attrs: LRNAttrs}): - TensorInfo { - const {inputs, backend, attrs} = args; - const {x} = inputs; - const {depthRadius, bias, alpha, beta} = attrs; - - assertNotComplex(x, 'LRN'); - - const channels = x.shape[3]; - const maxD = channels - 1; - const xValues = backend.data.get(x.dataId).values as TypedArray; - const size = util.sizeFromShape(x.shape); - const result = new Float32Array(size); - - function sumAcrossChannels(offset: number) { - const currentChannel = offset % channels; - let beginSumOffset = - offset - currentChannel + Math.max(0, currentChannel - depthRadius); - const endSumOffset = - offset - currentChannel + Math.min(currentChannel + depthRadius, maxD); - - let sum = 0.0; - for (; beginSumOffset <= endSumOffset; beginSumOffset++) { - const z = xValues[beginSumOffset]; - sum += z * z; - } - return sum; - } - - for (let offset = 0; offset < size; offset++) { - const sum = sumAcrossChannels(offset); - const val = xValues[offset] * Math.pow(bias + alpha * sum, -beta); - result[offset] = val; - } - - return backend.makeTensorInfo(x.shape, x.dtype, result); -} - -// tslint:disable-next-line: variable-name -export const LRNConfig: KernelConfig = { - kernelName: LRN, - backendName: 'cpu', - kernelFunc: lRN as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/LRNGrad.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/LRNGrad.ts deleted file mode 100644 index 45528d46b..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/LRNGrad.ts +++ /dev/null @@ -1,73 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, LRNGrad, LRNGradAttrs, LRNGradInputs, TensorInfo, TypedArray, util} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; -import {assertNotComplex} from '../cpu_util'; - -export function lRNGrad( - args: - {inputs: LRNGradInputs, backend: MathBackendCPU, attrs: LRNGradAttrs}): - TensorInfo { - const {inputs, backend, attrs} = args; - const {x, y, dy} = inputs; - const {depthRadius, bias, alpha, beta} = attrs; - - assertNotComplex(dy, 'LRNGrad'); - - const dySize = util.sizeFromShape(dy.shape); - - const channels = dy.shape[3]; - const dyValues = backend.data.get(dy.dataId).values as TypedArray; - const xValues = backend.data.get(x.dataId).values as TypedArray; - const yValues = backend.data.get(y.dataId).values as TypedArray; - const result = new Float32Array(dySize); - const size = dySize; - - for (let offset = 0; offset < size; offset++) { - const currentChannel = offset % channels; - const depthBegin = - (offset - currentChannel) + Math.max(0, currentChannel - depthRadius); - const depthEnd = (offset - currentChannel) + - Math.min(channels, currentChannel + depthRadius + 1); - - let norm = 0; - for (let k = depthBegin; k < depthEnd; k++) { - norm += Math.pow(xValues[k], 2); - } - norm = alpha * norm + bias; - - for (let k = depthBegin; k < depthEnd; k++) { - let dyi = -2 * alpha * beta * xValues[k] * yValues[offset] / norm; - if (offset === k) { - dyi += Math.pow(norm, -beta); - } - dyi *= dyValues[offset]; - result[k] += dyi; - } - } - - return backend.makeTensorInfo(dy.shape, x.dtype, result); -} - -// tslint:disable-next-line: variable-name -export const LRNGradConfig: KernelConfig = { - kernelName: LRNGrad, - backendName: 'cpu', - kernelFunc: lRNGrad as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/LeakyRelu.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/LeakyRelu.ts deleted file mode 100644 index 3de5b91e1..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/LeakyRelu.ts +++ /dev/null @@ -1,49 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, LeakyRelu, LeakyReluAttrs, LeakyReluInputs, TensorInfo, TypedArray, util} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; -import {assertNotComplex} from '../cpu_util'; - -export function leakyRelu(args: { - inputs: LeakyReluInputs, - backend: MathBackendCPU, - attrs: LeakyReluAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {x} = inputs; - const {alpha} = attrs; - - assertNotComplex([x], 'leakyRelu'); - - const xSize = util.sizeFromShape(x.shape); - const xVals = backend.data.get(x.dataId).values as TypedArray; - const outVals = util.getTypedArrayFromDType('float32', xSize); - - for (let i = 0; i < xVals.length; i++) { - outVals[i] = xVals[i] < 0 ? alpha * xVals[i] : xVals[i]; - } - - return backend.makeTensorInfo(x.shape, 'float32', outVals); -} - -export const leakyReluConfig: KernelConfig = { - kernelName: LeakyRelu, - backendName: 'cpu', - kernelFunc: leakyRelu as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Less.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Less.ts deleted file mode 100644 index 567d60b67..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Less.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, Less} from '@tensorflow/tfjs-core'; - -import {createSimpleBinaryKernelImpl} from '../utils/binary_impl'; -import {binaryKernelFunc} from '../utils/binary_utils'; - -export const lessImpl = - createSimpleBinaryKernelImpl((a: number, b: number) => (a < b) ? 1 : 0); -export const less = - binaryKernelFunc(Less, lessImpl, null /* complexImpl */, 'bool'); - -export const lessConfig: KernelConfig = { - kernelName: Less, - backendName: 'cpu', - kernelFunc: less -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/LessEqual.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/LessEqual.ts deleted file mode 100644 index c0ec04f00..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/LessEqual.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, LessEqual} from '@tensorflow/tfjs-core'; - -import {createSimpleBinaryKernelImpl} from '../utils/binary_impl'; -import {binaryKernelFunc} from '../utils/binary_utils'; - -export const lessEqualImpl = - createSimpleBinaryKernelImpl((a: number, b: number) => (a <= b) ? 1 : 0); -export const lessEqual = - binaryKernelFunc(LessEqual, lessEqualImpl, null /* complexImpl */, 'bool'); - -export const lessEqualConfig: KernelConfig = { - kernelName: LessEqual, - backendName: 'cpu', - kernelFunc: lessEqual -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/LinSpace.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/LinSpace.ts deleted file mode 100644 index 75675c63e..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/LinSpace.ts +++ /dev/null @@ -1,37 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, LinSpace, LinSpaceAttrs, TensorInfo} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; -import {linSpaceImpl} from './LinSpace_impl'; - -export function linSpace(args: {backend: MathBackendCPU, attrs: LinSpaceAttrs}): - TensorInfo { - const {backend, attrs} = args; - const {start, stop, num} = attrs; - - const outVals = linSpaceImpl(start, stop, num); - - return backend.makeTensorInfo([outVals.length], 'float32', outVals); -} - -export const linSpaceConfig: KernelConfig = { - kernelName: LinSpace, - backendName: 'cpu', - kernelFunc: linSpace as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/LinSpace_impl.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/LinSpace_impl.ts deleted file mode 100644 index dd92521dc..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/LinSpace_impl.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {TypedArray, util} from '@tensorflow/tfjs-core'; - -export function linSpaceImpl( - start: number, stop: number, num: number): TypedArray { - const step = (stop - start) / (num - 1); - - const values = util.makeZerosTypedArray(num, 'float32'); - values[0] = start; - for (let i = 1; i < values.length; i++) { - values[i] = values[i - 1] + step; - } - - return values; -} diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Log.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Log.ts deleted file mode 100644 index 06a91e8b4..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Log.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, Log} from '@tensorflow/tfjs-core'; - -import {createSimpleUnaryImpl} from '../utils/unary_impl'; -import {unaryKernelFuncFromImpl} from '../utils/unary_utils'; - -export const logImpl = createSimpleUnaryImpl((xi) => Math.log(xi)); -export const log = unaryKernelFuncFromImpl(Log, logImpl); - -export const logConfig: KernelConfig = { - kernelName: Log, - backendName: 'cpu', - kernelFunc: log, -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Log1p.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Log1p.ts deleted file mode 100644 index f173f5c7c..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Log1p.ts +++ /dev/null @@ -1,28 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, Log1p} from '@tensorflow/tfjs-core'; - -import {unaryKernelFunc} from '../utils/unary_utils'; - -export const log1p = unaryKernelFunc(Log1p, (xi) => Math.log1p(xi)); - -export const log1pConfig: KernelConfig = { - kernelName: Log1p, - backendName: 'cpu', - kernelFunc: log1p, -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/LogicalAnd.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/LogicalAnd.ts deleted file mode 100644 index 6b2178b0f..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/LogicalAnd.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, LogicalAnd} from '@tensorflow/tfjs-core'; - -import {createSimpleBinaryKernelImpl} from '../utils/binary_impl'; -import {binaryKernelFunc} from '../utils/binary_utils'; - -export const logicalAndImpl = - createSimpleBinaryKernelImpl((a: number, b: number) => a && b); -export const logicalAnd = binaryKernelFunc( - LogicalAnd, logicalAndImpl, null /* complexImpl */, 'bool'); - -export const logicalAndConfig: KernelConfig = { - kernelName: LogicalAnd, - backendName: 'cpu', - kernelFunc: logicalAnd -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/LogicalNot.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/LogicalNot.ts deleted file mode 100644 index e56316ba3..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/LogicalNot.ts +++ /dev/null @@ -1,29 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, LogicalNot} from '@tensorflow/tfjs-core'; - -import {unaryKernelFunc} from '../utils/unary_utils'; - -export const logicalNot = - unaryKernelFunc(LogicalNot, (xi) => xi ? 0 : 1, 'bool'); - -export const logicalNotConfig: KernelConfig = { - kernelName: LogicalNot, - backendName: 'cpu', - kernelFunc: logicalNot, -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/LogicalOr.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/LogicalOr.ts deleted file mode 100644 index 7867fdfc9..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/LogicalOr.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, LogicalOr} from '@tensorflow/tfjs-core'; - -import {createSimpleBinaryKernelImpl} from '../utils/binary_impl'; -import {binaryKernelFunc} from '../utils/binary_utils'; - -export const logicalOrImpl = - createSimpleBinaryKernelImpl((a: number, b: number) => a || b); -export const logicalOr = - binaryKernelFunc(LogicalOr, logicalOrImpl, null /* complexImpl */, 'bool'); - -export const logicalOrConfig: KernelConfig = { - kernelName: LogicalOr, - backendName: 'cpu', - kernelFunc: logicalOr -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Max.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Max.ts deleted file mode 100644 index 56f3de1e0..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Max.ts +++ /dev/null @@ -1,78 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelFunc, Max, MaxAttrs, MaxInputs, TensorInfo} from '@tensorflow/tfjs-core'; -import {backend_util, KernelConfig} from '@tensorflow/tfjs-core'; -import {TypedArray, util} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; -import {assertNotComplex} from '../cpu_util'; - -import {maxImpl} from './Max_impl'; -import {transposeImpl} from './Transpose_impl'; - -export function max( - args: {inputs: MaxInputs, backend: MathBackendCPU, attrs: MaxAttrs}): - TensorInfo { - const {inputs, backend, attrs} = args; - const {x} = inputs; - const {reductionIndices, keepDims} = attrs; - const cpuBackend = backend; - let xShape = x.shape; - const xRank = xShape.length; - - const origAxes = util.parseAxisParam(reductionIndices, xShape); - let axes = origAxes; - const permutedAxes = backend_util.getAxesPermutation(axes, xRank); - let xVals = cpuBackend.data.get(x.dataId).values as TypedArray; - if (permutedAxes != null) { - const newShape: number[] = new Array(xRank); - for (let i = 0; i < newShape.length; i++) { - newShape[i] = xShape[permutedAxes[i]]; - } - - xVals = transposeImpl(xVals, xShape, x.dtype, permutedAxes, newShape); - axes = backend_util.getInnerMostAxes(axes.length, xRank); - - xShape = newShape; - } - - assertNotComplex(x, 'max'); - backend_util.assertAxesAreInnerMostDims('max', axes, xRank); - const [maxOutShape, reduceShape] = - backend_util.computeOutAndReduceShapes(xShape, axes); - - const reduceSize = util.sizeFromShape(reduceShape); - - const result = maxImpl(xVals, reduceSize, maxOutShape, x.dtype); - const dataId = cpuBackend.write(result, maxOutShape, x.dtype); - - let outShape = maxOutShape; - if (keepDims) { - // reshape - const newShape = backend_util.expandShapeToKeepDim(maxOutShape, origAxes); - outShape = newShape; - } - - return {dataId, shape: outShape, dtype: x.dtype}; -} - -export const maxConfig: KernelConfig = { - kernelName: Max, - backendName: 'cpu', - kernelFunc: max as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/MaxPool.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/MaxPool.ts deleted file mode 100644 index fa3a6a193..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/MaxPool.ts +++ /dev/null @@ -1,61 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {backend_util, KernelConfig, KernelFunc, MaxPool, MaxPoolAttrs, MaxPoolInputs, TensorInfo, TypedArray, util} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; -import {assertNotComplex} from '../cpu_util'; -import {pool} from '../utils/pool_utils'; -import {identity} from './Identity'; - -export function maxPool( - args: - {inputs: MaxPoolInputs, backend: MathBackendCPU, attrs: MaxPoolAttrs}): - TensorInfo { - const {inputs, backend, attrs} = args; - const {x} = inputs; - assertNotComplex(x, 'maxPool'); - const {filterSize, strides, pad, dimRoundingMode} = attrs; - const dilations = 1; - - util.assert( - backend_util.eitherStridesOrDilationsAreOne(strides, dilations), - () => 'Error in maxPool: Either strides or dilations must be 1. ' + - `Got strides ${strides} and dilations '${dilations}'`); - - const convInfo = backend_util.computePool2DInfo( - x.shape as [number, number, number, number], filterSize, strides, - dilations, pad, dimRoundingMode); - let res: TensorInfo; - - if (convInfo.filterWidth === 1 && convInfo.filterHeight === 1 && - util.arraysEqual(convInfo.inShape, convInfo.outShape)) { - res = identity({inputs: {x}, backend}); - } else { - const xValues = backend.data.get(x.dataId).values as TypedArray; - const strides = util.computeStrides(x.shape); - const buffer = pool(xValues, x.shape, x.dtype, strides, convInfo, 'max'); - res = backend.makeTensorInfo( - convInfo.outShape, x.dtype, buffer.values as TypedArray); - } - return res; -} - -export const maxPoolConfig: KernelConfig = { - kernelName: MaxPool, - backendName: 'cpu', - kernelFunc: maxPool as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/MaxPool3D.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/MaxPool3D.ts deleted file mode 100644 index 3036007f4..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/MaxPool3D.ts +++ /dev/null @@ -1,50 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, KernelConfig, KernelFunc, MaxPool3D, MaxPool3DAttrs, MaxPool3DInputs, TensorInfo, TypedArray, util} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; -import {assertNotComplex} from '../cpu_util'; -import {pool3d} from '../utils/pool_utils'; - -export function maxPool3D(args: { - inputs: MaxPool3DInputs, - backend: MathBackendCPU, - attrs: MaxPool3DAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {x} = inputs; - const {filterSize, strides, pad, dimRoundingMode, dataFormat} = attrs; - - assertNotComplex(x, 'maxPool3d'); - - const convInfo = backend_util.computePool3DInfo( - x.shape as [number, number, number, number, number], filterSize, strides, - 1 /* dilations */, pad, dimRoundingMode, dataFormat); - - const xValues = backend.data.get(x.dataId).values as TypedArray; - const outBuf = pool3d( - xValues, x.shape, x.dtype, util.computeStrides(x.shape), convInfo, 'max'); - - return backend.makeTensorInfo(outBuf.shape, 'float32', outBuf.values); -} - -export const maxPool3DConfig: KernelConfig = { - kernelName: MaxPool3D, - backendName: 'cpu', - kernelFunc: maxPool3D as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/MaxPool3DGrad.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/MaxPool3DGrad.ts deleted file mode 100644 index 280328f4d..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/MaxPool3DGrad.ts +++ /dev/null @@ -1,123 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, buffer, KernelConfig, KernelFunc, MaxPool3DGrad, MaxPool3DGradAttrs, MaxPool3DGradInputs, Rank, TensorInfo} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; -import {assertNotComplex} from '../cpu_util'; -import {maxPool3dPositions} from '../utils/pool_utils'; - -export function maxPool3DGrad(args: { - inputs: MaxPool3DGradInputs, - backend: MathBackendCPU, - attrs: MaxPool3DGradAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {dy, input} = inputs; - const {filterSize, strides, pad, dimRoundingMode} = attrs; - - assertNotComplex([dy, input], 'maxPool3DGrad'); - - const convInfo = backend_util.computePool3DInfo( - input.shape as [number, number, number, number, number], filterSize, - strides, 1 /* dilations */, pad, dimRoundingMode); - - const inputBuf = backend.bufferSync(input); - const maxPosBuf = maxPool3dPositions(inputBuf, convInfo); - const strideDepth = convInfo.strideDepth; - const strideHeight = convInfo.strideHeight; - const strideWidth = convInfo.strideWidth; - const dilationDepth = convInfo.dilationDepth; - const dilationHeight = convInfo.dilationHeight; - const dilationWidth = convInfo.dilationWidth; - const effectiveFilterDepth = convInfo.effectiveFilterDepth; - const effectiveFilterHeight = convInfo.effectiveFilterHeight; - const effectiveFilterWidth = convInfo.effectiveFilterWidth; - const padFront = effectiveFilterDepth - 1 - convInfo.padInfo.front; - const padLeft = effectiveFilterWidth - 1 - convInfo.padInfo.left; - const padTop = effectiveFilterHeight - 1 - convInfo.padInfo.top; - const dx = buffer(input.shape, 'float32'); - - const dyBuf = backend.bufferSync(dy); - - for (let batch = 0; batch < convInfo.batchSize; ++batch) { - for (let channel = 0; channel < convInfo.inChannels; ++channel) { - for (let dxDepth = 0; dxDepth < convInfo.inDepth; ++dxDepth) { - for (let dxRow = 0; dxRow < convInfo.inHeight; ++dxRow) { - for (let dxCol = 0; dxCol < convInfo.inWidth; ++dxCol) { - // Shader code begins - const dyDepthCorner = dxDepth - padFront; - const dyRowCorner = dxRow - padTop; - const dyColCorner = dxCol - padLeft; - let dotProd = 0; - for (let wDepth = 0; wDepth < effectiveFilterDepth; - wDepth += dilationDepth) { - const dyDepth = (dyDepthCorner + wDepth) / strideDepth; - if (dyDepth < 0 || dyDepth >= convInfo.outDepth || - Math.floor(dyDepth) !== dyDepth) { - continue; - } - for (let wRow = 0; wRow < effectiveFilterHeight; - wRow += dilationHeight) { - const dyRow = (dyRowCorner + wRow) / strideHeight; - if (dyRow < 0 || dyRow >= convInfo.outHeight || - Math.floor(dyRow) !== dyRow) { - continue; - } - for (let wCol = 0; wCol < effectiveFilterWidth; - wCol += dilationWidth) { - const dyCol = (dyColCorner + wCol) / strideWidth; - if (dyCol < 0 || dyCol >= convInfo.outWidth || - Math.floor(dyCol) !== dyCol) { - continue; - } - - const maxPos = effectiveFilterDepth * effectiveFilterHeight * - effectiveFilterWidth - - 1 - - (maxPosBuf.get(batch, dyDepth, dyRow, dyCol, channel) as - number); - const curPos = - wDepth * effectiveFilterHeight * effectiveFilterWidth + - wRow * effectiveFilterWidth + wCol; - - const mask = maxPos === curPos ? 1 : 0; - if (mask === 0) { - continue; - } - - const pixel = - dyBuf.get(batch, dyDepth, dyRow, dyCol, channel); - dotProd += pixel * mask; - } - } - } - dx.set(dotProd, batch, dxDepth, dxRow, dxCol, channel); - } - } - } - } - } - - return backend.makeTensorInfo(dx.shape, dx.dtype, dx.values); -} - -export const maxPool3DGradConfig: KernelConfig = { - kernelName: MaxPool3DGrad, - backendName: 'cpu', - kernelFunc: maxPool3DGrad as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/MaxPoolGrad.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/MaxPoolGrad.ts deleted file mode 100644 index aeb1fc7e1..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/MaxPoolGrad.ts +++ /dev/null @@ -1,101 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {backend_util, buffer, KernelConfig, KernelFunc, MaxPoolGrad, MaxPoolGradAttrs, MaxPoolGradInputs, Rank, TensorInfo, TypedArray} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; -import {assertNotComplex} from '../cpu_util'; -import {maxPoolPositions} from '../utils/pool_utils'; - -export function maxPoolGrad(args: { - inputs: MaxPoolGradInputs, - backend: MathBackendCPU, - attrs: MaxPoolGradAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {dy, input, output} = inputs; - const x = input; - assertNotComplex([input, output], 'maxPoolGrad'); - const {filterSize, strides, pad, dimRoundingMode} = attrs; - - const convInfo = backend_util.computePool2DInfo( - x.shape as [number, number, number, number], filterSize, strides, - 1 /* dilations */, pad, dimRoundingMode); - const xValues = backend.data.get(x.dataId).values as TypedArray; - const maxPosBuf = buffer( - convInfo.outShape, x.dtype, - maxPoolPositions(xValues, x.shape, x.dtype, convInfo).values); - const strideHeight = convInfo.strideHeight; - const strideWidth = convInfo.strideWidth; - const dilationHeight = convInfo.dilationHeight; - const dilationWidth = convInfo.dilationWidth; - const effectiveFilterHeight = convInfo.effectiveFilterHeight; - const effectiveFilterWidth = convInfo.effectiveFilterWidth; - const padLeft = effectiveFilterWidth - 1 - convInfo.padInfo.left; - const padTop = effectiveFilterHeight - 1 - convInfo.padInfo.top; - const dx = - buffer(x.shape as [number, number, number, number], 'float32'); - - const dyData = backend.data.get(dy.dataId).values as Float32Array; - const dyBuf = buffer( - dy.shape as [number, number, number, number], 'float32', dyData); - - for (let b = 0; b < convInfo.batchSize; ++b) { - for (let d = 0; d < convInfo.inChannels; ++d) { - for (let dxR = 0; dxR < convInfo.inHeight; ++dxR) { - for (let dxC = 0; dxC < convInfo.inWidth; ++dxC) { - // Shader code begins. - const dyRCorner = dxR - padTop; - const dyCCorner = dxC - padLeft; - let dotProd = 0; - for (let wR = 0; wR < effectiveFilterHeight; wR += dilationHeight) { - const dyR = (dyRCorner + wR) / strideHeight; - if (dyR < 0 || dyR >= convInfo.outHeight || - Math.floor(dyR) !== dyR) { - continue; - } - for (let wC = 0; wC < effectiveFilterWidth; wC += dilationWidth) { - const dyC = (dyCCorner + wC) / strideWidth; - if (dyC < 0 || dyC >= convInfo.outWidth || - Math.floor(dyC) !== dyC) { - continue; - } - const maxPos = effectiveFilterHeight * effectiveFilterWidth - 1 - - (maxPosBuf.get(b, dyR, dyC, d) as number); - const curPos = wR * effectiveFilterWidth + wC; - - const mask = maxPos === curPos ? 1 : 0; - if (mask === 0) { - continue; - } - - const pixel = dyBuf.get(b, dyR, dyC, d); - dotProd += pixel * mask; - } - } - dx.set(dotProd, b, dxR, dxC, d); - } - } - } - } - return backend.makeTensorInfo(dx.shape, dx.dtype, dx.values); -} - -export const maxPoolGradConfig: KernelConfig = { - kernelName: MaxPoolGrad, - backendName: 'cpu', - kernelFunc: maxPoolGrad as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/MaxPoolWithArgmax.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/MaxPoolWithArgmax.ts deleted file mode 100644 index 18d147f27..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/MaxPoolWithArgmax.ts +++ /dev/null @@ -1,51 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {MaxPoolWithArgmax, MaxPoolWithArgmaxAttrs, MaxPoolWithArgmaxInputs} from '@tensorflow/tfjs-core'; -import {backend_util, KernelConfig, TypedArray} from '@tensorflow/tfjs-core'; -import {MathBackendCPU} from '../backend_cpu'; -import {assertNotComplex} from '../cpu_util'; - -import {maxPoolWithArgmaxImpl} from './MaxPoolWithArgmax_impl'; - -export const maxPoolWithArgmaxConfig: KernelConfig = { - kernelName: MaxPoolWithArgmax, - backendName: 'cpu', - kernelFunc: ({inputs, attrs, backend}) => { - const {x} = inputs as MaxPoolWithArgmaxInputs; - const {filterSize, strides, pad, includeBatchInIndex} = - attrs as unknown as MaxPoolWithArgmaxAttrs; - const cpuBackend = backend as MathBackendCPU; - assertNotComplex(x, 'MaxPoolWithArgmax'); - - const values = cpuBackend.data.get(x.dataId).values as TypedArray; - const convInfo = backend_util.computePool2DInfo( - x.shape as [number, number, number, number], filterSize, strides, - [1, 1], pad); - const [pooled, indexes] = maxPoolWithArgmaxImpl( - values, x.shape, x.dtype, includeBatchInIndex, convInfo); - - const pooledDataId = - cpuBackend.write(pooled as Float32Array, convInfo.outShape, x.dtype); - const indexesDataId = - cpuBackend.write(indexes as Int32Array, convInfo.outShape, x.dtype); - return [ - {dataId: pooledDataId, shape: convInfo.outShape, dtype: x.dtype}, - {dataId: indexesDataId, shape: convInfo.outShape, dtype: 'int32'} - ]; - } -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/MaxPoolWithArgmax_impl.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/MaxPoolWithArgmax_impl.ts deleted file mode 100644 index 5a40153c3..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/MaxPoolWithArgmax_impl.ts +++ /dev/null @@ -1,29 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {backend_util, DataType, TypedArray, util} from '@tensorflow/tfjs-core'; - -import {maxPoolPositions, pool} from '../utils/pool_utils'; -export function maxPoolWithArgmaxImpl( - xValues: TypedArray, xShape: number[], dtype: DataType, - includeBatchInIndex: boolean, convInfo: backend_util.Conv2DInfo) { - const strides = util.computeStrides(xShape); - const maxPools = pool(xValues, xShape, dtype, strides, convInfo, 'max'); - const maxPositions = maxPoolPositions( - xValues, xShape, dtype, convInfo, true, includeBatchInIndex); - - return [maxPools.values, maxPositions.values]; -} diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Max_impl.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Max_impl.ts deleted file mode 100644 index 2983784e0..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Max_impl.ts +++ /dev/null @@ -1,39 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {DataType, NumericDataType, TypedArray, util} from '@tensorflow/tfjs-core'; - -export function maxImpl( - aVals: TypedArray, reduceSize: number, outShape: number[], - dtype: DataType): TypedArray { - const vals = util.getTypedArrayFromDType( - dtype as NumericDataType, util.sizeFromShape(outShape)); - - for (let i = 0; i < vals.length; ++i) { - const offset = i * reduceSize; - let max = aVals[offset]; - for (let j = 0; j < reduceSize; ++j) { - const value = aVals[offset + j]; - if (Number.isNaN(value) || - value > max) { // comparison with NaN always return false - max = value; - } - } - vals[i] = max; - } - return vals; -} diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Maximum.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Maximum.ts deleted file mode 100644 index 3e6d9308d..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Maximum.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, Maximum} from '@tensorflow/tfjs-core'; - -import {createSimpleBinaryKernelImpl} from '../utils/binary_impl'; -import {binaryKernelFunc} from '../utils/binary_utils'; - -export const maximumImpl = createSimpleBinaryKernelImpl( - ((aValue, bValue) => Math.max(aValue as number, bValue as number))); -export const maximum = binaryKernelFunc(Maximum, maximumImpl); - -export const maximumConfig: KernelConfig = { - kernelName: Maximum, - backendName: 'cpu', - kernelFunc: maximum -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Mean.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Mean.ts deleted file mode 100644 index c2e1d508f..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Mean.ts +++ /dev/null @@ -1,59 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, KernelConfig, KernelFunc, Mean, MeanAttrs, MeanInputs, TensorInfo, util} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; -import {cast} from './Cast'; -import {div} from './RealDiv'; -import {sum} from './Sum'; - -export function mean( - args: {inputs: MeanInputs, backend: MathBackendCPU, attrs: MeanAttrs}): - TensorInfo { - const {inputs, backend, attrs} = args; - const {x} = inputs; - const {axis, keepDims} = attrs; - - const axes = util.parseAxisParam(axis, x.shape); - const shapes = backend_util.computeOutAndReduceShapes(x.shape, axes); - const reduceShape = shapes[1]; - const reduceSize = util.sizeFromShape(reduceShape); - const toDispose = []; - const reduceSizeScalar = - backend.makeTensorInfo([], 'float32', new Float32Array([reduceSize])); - toDispose.push(reduceSizeScalar); - - const $x = cast({inputs: {x}, backend, attrs: {dtype: 'float32'}}); - toDispose.push($x); - - const res = - div({inputs: {a: $x, b: reduceSizeScalar}, backend}) as TensorInfo; - toDispose.push(res); - - const result = sum({inputs: {x: res}, backend, attrs: {axis, keepDims}}); - - toDispose.forEach(t => backend.disposeIntermediateTensorInfo(t)); - - return result; -} - -export const meanConfig: KernelConfig = { - kernelName: Mean, - backendName: 'cpu', - kernelFunc: mean as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Min.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Min.ts deleted file mode 100644 index 346692d8b..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Min.ts +++ /dev/null @@ -1,86 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, KernelConfig, KernelFunc, Min, MinAttrs, MinInputs, TensorInfo, TypedArray, util} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; -import {assertNotComplex} from '../cpu_util'; -import {reshape} from './Reshape'; -import {transpose} from './Transpose'; - -export function min( - args: {inputs: MinInputs, backend: MathBackendCPU, attrs: MinAttrs}): - TensorInfo { - const {inputs, backend, attrs} = args; - const {x} = inputs; - const {axis, keepDims} = attrs; - - assertNotComplex(x, 'min'); - - const origAxes = util.parseAxisParam(axis, x.shape); - let axes = origAxes; - const permutedAxes = backend_util.getAxesPermutation(axes, x.shape.length); - let $x = x; - if (permutedAxes != null) { - $x = transpose({inputs: {x}, backend, attrs: {perm: permutedAxes}}); - axes = backend_util.getInnerMostAxes(axes.length, x.shape.length); - } - - backend_util.assertAxesAreInnerMostDims('min', axes, $x.shape.length); - const [outShape, reduceShape] = - backend_util.computeOutAndReduceShapes($x.shape, axes); - const reduceSize = util.sizeFromShape(reduceShape); - const vals = util.makeZerosTypedArray(util.sizeFromShape(outShape), $x.dtype); - - const aVals = backend.data.get($x.dataId).values as TypedArray; - for (let i = 0; i < vals.length; ++i) { - const offset = i * reduceSize; - let min = aVals[offset]; - for (let j = 0; j < reduceSize; ++j) { - const value = aVals[offset + j]; - if (Number.isNaN(value) || - value < min) { // comparison with NaN always return false - min = value; - } - } - vals[i] = min; - } - - if (permutedAxes != null) { - backend.disposeIntermediateTensorInfo($x); - } - - const result = backend.makeTensorInfo(outShape, $x.dtype, vals); - - if (keepDims) { - const expandedShape = backend_util.expandShapeToKeepDim(outShape, origAxes); - const reshapedResult = - reshape({inputs: {x: result}, backend, attrs: {shape: expandedShape}}); - - backend.disposeIntermediateTensorInfo(result); - - return reshapedResult; - } - - return result; -} - -export const minConfig: KernelConfig = { - kernelName: Min, - backendName: 'cpu', - kernelFunc: min as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Minimum.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Minimum.ts deleted file mode 100644 index a8b64277a..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Minimum.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, Minimum} from '@tensorflow/tfjs-core'; - -import {createSimpleBinaryKernelImpl} from '../utils/binary_impl'; -import {binaryKernelFunc} from '../utils/binary_utils'; - -export const minimumImpl = createSimpleBinaryKernelImpl( - ((aValue, bValue) => Math.min(aValue as number, bValue as number))); -export const minimum = binaryKernelFunc(Minimum, minimumImpl); - -export const minimumConfig: KernelConfig = { - kernelName: Minimum, - backendName: 'cpu', - kernelFunc: minimum -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/MirrorPad.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/MirrorPad.ts deleted file mode 100644 index f05e1e73e..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/MirrorPad.ts +++ /dev/null @@ -1,76 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, MirrorPad, MirrorPadAttrs, MirrorPadInputs, NumericDataType, TensorInfo, TypedArray, util} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; -import {assertNotComplex} from '../cpu_util'; - -export function mirrorPad(args: { - inputs: MirrorPadInputs, - backend: MathBackendCPU, - attrs: MirrorPadAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {x} = inputs; - const {paddings, mode} = attrs; - - assertNotComplex(x, 'mirrorPad'); - - const outShape = paddings.map( - (p, i) => p[0] /* beforePad */ + x.shape[i] + p[1] /* afterPad */); - - const start = paddings.map(p => p[0]); - const end = paddings.map((p, i) => p[0] + x.shape[i]); - const offset = mode === 'reflect' ? 0 : 1; - - const xVals = backend.data.get(x.dataId).values as TypedArray; - const xRank = x.shape.length; - const xStrides = util.computeStrides(x.shape); - - const resultSize = util.sizeFromShape(outShape); - const resultRank = outShape.length; - const resultStrides = util.computeStrides(outShape); - const resVals = - util.getTypedArrayFromDType(x.dtype as NumericDataType, resultSize); - - for (let i = 0; i < resultSize; i++) { - let coords = util.indexToLoc(i, resultRank, resultStrides); - for (let i = 0; i < resultRank; i++) { - if (coords[i] < start[i]) { - coords[i] = start[i] * 2 - coords[i] - offset; - } else if (coords[i] >= end[i]) { - coords[i] = (end[i] - 1) * 2 - coords[i] + offset; - } - } - coords = coords.map((c, i) => c - start[i]); - - const inIndex = util.locToIndex(coords, xRank, xStrides); - - resVals[i] = xVals[inIndex]; - } - - const outId = backend.write(resVals, outShape, x.dtype); - - return {dataId: outId, shape: outShape, dtype: x.dtype}; -} - -export const mirrorPadConfig: KernelConfig = { - kernelName: MirrorPad, - backendName: 'cpu', - kernelFunc: mirrorPad as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Mod.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Mod.ts deleted file mode 100644 index 860a6d2d7..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Mod.ts +++ /dev/null @@ -1,39 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, Mod} from '@tensorflow/tfjs-core'; - -import {createSimpleBinaryKernelImpl} from '../utils/binary_impl'; -import {binaryKernelFunc} from '../utils/binary_utils'; - -export const modImpl = - createSimpleBinaryKernelImpl(((aValue: number, bValue: number) => { - const rem = aValue % bValue; - if ((aValue < 0 && bValue < 0) || (aValue >= 0 && bValue >= 0)) { - return rem; - } else { - return (rem + bValue) % bValue; - } - })); - -export const mod = binaryKernelFunc(Mod, modImpl); - -export const modConfig: KernelConfig = { - kernelName: Mod, - backendName: 'cpu', - kernelFunc: mod -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Multinomial.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Multinomial.ts deleted file mode 100644 index beab6a747..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Multinomial.ts +++ /dev/null @@ -1,86 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, Multinomial, MultinomialAttrs, MultinomialInputs, TensorInfo, TypedArray, util} from '@tensorflow/tfjs-core'; -import * as seedrandom from 'seedrandom'; - -import {MathBackendCPU} from '../backend_cpu'; -import {assertNotComplex} from '../cpu_util'; - -import {softmax} from './Softmax'; - -export function multinomial(args: { - inputs: MultinomialInputs, - backend: MathBackendCPU, - attrs: MultinomialAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {logits} = inputs; - const {numSamples, seed, normalized} = attrs; - - assertNotComplex(logits, 'multinomial'); - - const probabilities = normalized ? - logits : - softmax({inputs: {logits}, backend, attrs: {dim: -1}}); - - const batchSize = probabilities.shape[0]; - const numEvents = probabilities.shape[1]; - const probVals = backend.data.get(probabilities.dataId).values as TypedArray; - const resShape = [batchSize, numSamples]; - const resVals = - util.makeZerosTypedArray(util.sizeFromShape(resShape), 'int32'); - - for (let b = 0; b < batchSize; ++b) { - const offset = b * numEvents; - // The cdf won't include the last event. It will be implicit if no other - // event happened. - const cdf = new Float32Array(numEvents - 1); - cdf[0] = probVals[offset]; - for (let event = 1; event < cdf.length; ++event) { - cdf[event] = cdf[event - 1] + probVals[offset + event]; - } - - const random = seedrandom.alea(seed.toString()); - const outOffset = b * numSamples; - for (let sampleId = 0; sampleId < numSamples; ++sampleId) { - const r = random(); - - // Assume last event happened by default. - resVals[outOffset + sampleId] = cdf.length; - - for (let event = 0; event < cdf.length; event++) { - if (r < cdf[event]) { - resVals[outOffset + sampleId] = event; - break; - } - } - } - } - - if (!normalized) { - backend.disposeIntermediateTensorInfo(probabilities); - } - - return backend.makeTensorInfo(resShape, 'int32', resVals); -} - -export const multinomialConfig: KernelConfig = { - kernelName: Multinomial, - backendName: 'cpu', - kernelFunc: multinomial as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Multiply.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Multiply.ts deleted file mode 100644 index cb6223e17..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Multiply.ts +++ /dev/null @@ -1,39 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, Multiply} from '@tensorflow/tfjs-core'; -import {createSimpleBinaryKernelImpl} from '../utils/binary_impl'; -import {binaryKernelFunc, createComplexBinaryKernelImpl} from '../utils/binary_utils'; - -export const multiplyImpl = createSimpleBinaryKernelImpl( - ((aValue: number, bValue: number) => aValue * bValue)); -export const multiplyComplexImpl = - createComplexBinaryKernelImpl(((aReal, aImag, bReal, bImag) => { - return { - real: aReal * bReal - aImag * bImag, - imag: aReal * bImag + aImag * bReal - }; - })); - -export const multiply = - binaryKernelFunc(Multiply, multiplyImpl, multiplyComplexImpl); - -export const multiplyConfig: KernelConfig = { - kernelName: Multiply, - backendName: 'cpu', - kernelFunc: multiply -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Neg.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Neg.ts deleted file mode 100644 index 815cb5e47..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Neg.ts +++ /dev/null @@ -1,48 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {DataType, KernelConfig, KernelFunc, Neg, TensorInfo, TypedArray, UnaryInputs, util} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; -import {assertNotComplex} from '../cpu_util'; -import {multiplyImpl} from './Multiply'; - -export function negImpl(xVals: TypedArray, xShape: number[], xDtype: DataType): - [TypedArray, number[]] { - const minusOne = - util.createScalarValue(-1 as unknown as 'float32', xDtype) as TypedArray; - return multiplyImpl([], xShape, minusOne, xVals, xDtype); -} - -export function neg(args: {inputs: UnaryInputs, backend: MathBackendCPU}): - TensorInfo { - const {inputs, backend} = args; - const {x} = inputs; - - assertNotComplex(x, 'neg'); - - const xVals = backend.data.get(x.dataId).values as TypedArray; - const [res, newShape] = negImpl(xVals, x.shape, x.dtype); - - return backend.makeTensorInfo(newShape, x.dtype, res); -} - -export const negConfig: KernelConfig = { - kernelName: Neg, - backendName: 'cpu', - kernelFunc: neg as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/NonMaxSuppressionV3.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/NonMaxSuppressionV3.ts deleted file mode 100644 index adbfd4dca..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/NonMaxSuppressionV3.ts +++ /dev/null @@ -1,50 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {kernel_impls, KernelConfig, KernelFunc, NonMaxSuppressionV3, NonMaxSuppressionV3Attrs, NonMaxSuppressionV3Inputs, TensorInfo, TypedArray} from '@tensorflow/tfjs-core'; - -const nonMaxSuppressionV3Impl = kernel_impls.nonMaxSuppressionV3Impl; - -import {MathBackendCPU} from '../backend_cpu'; -import {assertNotComplex} from '../cpu_util'; - -export function nonMaxSuppressionV3(args: { - inputs: NonMaxSuppressionV3Inputs, - backend: MathBackendCPU, - attrs: NonMaxSuppressionV3Attrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {boxes, scores} = inputs; - const {maxOutputSize, iouThreshold, scoreThreshold} = attrs; - - assertNotComplex(boxes, 'NonMaxSuppression'); - - const boxesVals = backend.data.get(boxes.dataId).values as TypedArray; - const scoresVals = backend.data.get(scores.dataId).values as TypedArray; - - const {selectedIndices} = nonMaxSuppressionV3Impl( - boxesVals, scoresVals, maxOutputSize, iouThreshold, scoreThreshold); - - return backend.makeTensorInfo( - [selectedIndices.length], 'int32', new Int32Array(selectedIndices)); -} - -export const nonMaxSuppressionV3Config: KernelConfig = { - kernelName: NonMaxSuppressionV3, - backendName: 'cpu', - kernelFunc: nonMaxSuppressionV3 as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/NonMaxSuppressionV4.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/NonMaxSuppressionV4.ts deleted file mode 100644 index 51765b0b1..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/NonMaxSuppressionV4.ts +++ /dev/null @@ -1,53 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {kernel_impls, KernelConfig, KernelFunc, NonMaxSuppressionV4, NonMaxSuppressionV4Attrs, NonMaxSuppressionV4Inputs, TensorInfo, TypedArray} from '@tensorflow/tfjs-core'; - -const nonMaxSuppressionV4Impl = kernel_impls.nonMaxSuppressionV4Impl; -import {MathBackendCPU} from '../backend_cpu'; -import {assertNotComplex} from '../cpu_util'; - -export function nonMaxSuppressionV4(args: { - inputs: NonMaxSuppressionV4Inputs, - backend: MathBackendCPU, - attrs: NonMaxSuppressionV4Attrs -}): [TensorInfo, TensorInfo] { - const {inputs, backend, attrs} = args; - const {boxes, scores} = inputs; - const {maxOutputSize, iouThreshold, scoreThreshold, padToMaxOutputSize} = - attrs; - - assertNotComplex(boxes, 'NonMaxSuppressionPadded'); - - const boxesVals = backend.data.get(boxes.dataId).values as TypedArray; - const scoresVals = backend.data.get(scores.dataId).values as TypedArray; - - const {selectedIndices, validOutputs} = nonMaxSuppressionV4Impl( - boxesVals, scoresVals, maxOutputSize, iouThreshold, scoreThreshold, - padToMaxOutputSize); - - return [ - backend.makeTensorInfo( - [selectedIndices.length], 'int32', new Int32Array(selectedIndices)), - backend.makeTensorInfo([], 'int32', new Int32Array([validOutputs])) - ]; -} -export const nonMaxSuppressionV4Config: KernelConfig = { - kernelName: NonMaxSuppressionV4, - backendName: 'cpu', - kernelFunc: nonMaxSuppressionV4 as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/NonMaxSuppressionV5.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/NonMaxSuppressionV5.ts deleted file mode 100644 index bef6bcaa7..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/NonMaxSuppressionV5.ts +++ /dev/null @@ -1,59 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {kernel_impls, KernelConfig, KernelFunc, NonMaxSuppressionV5, NonMaxSuppressionV5Attrs, NonMaxSuppressionV5Inputs, TensorInfo, TypedArray} from '@tensorflow/tfjs-core'; - -const nonMaxSuppressionV5Impl = kernel_impls.nonMaxSuppressionV5Impl; -import {MathBackendCPU} from '../backend_cpu'; -import {assertNotComplex} from '../cpu_util'; - -export function nonMaxSuppressionV5(args: { - inputs: NonMaxSuppressionV5Inputs, - backend: MathBackendCPU, - attrs: NonMaxSuppressionV5Attrs -}): [TensorInfo, TensorInfo] { - const {inputs, backend, attrs} = args; - const {boxes, scores} = inputs; - const {maxOutputSize, iouThreshold, scoreThreshold, softNmsSigma} = attrs; - - assertNotComplex(boxes, 'NonMaxSuppressionWithScore'); - - const boxesVals = backend.data.get(boxes.dataId).values as TypedArray; - const scoresVals = backend.data.get(scores.dataId).values as TypedArray; - - const maxOutputSizeVal = maxOutputSize; - const iouThresholdVal = iouThreshold; - const scoreThresholdVal = scoreThreshold; - const softNmsSigmaVal = softNmsSigma; - - const {selectedIndices, selectedScores} = nonMaxSuppressionV5Impl( - boxesVals, scoresVals, maxOutputSizeVal, iouThresholdVal, - scoreThresholdVal, softNmsSigmaVal); - - return [ - backend.makeTensorInfo( - [selectedIndices.length], 'int32', new Int32Array(selectedIndices)), - backend.makeTensorInfo( - [selectedScores.length], 'float32', new Float32Array(selectedScores)) - ]; -} - -export const nonMaxSuppressionV5Config: KernelConfig = { - kernelName: NonMaxSuppressionV5, - backendName: 'cpu', - kernelFunc: nonMaxSuppressionV5 as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/NotEqual.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/NotEqual.ts deleted file mode 100644 index 31276dbea..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/NotEqual.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, NotEqual} from '@tensorflow/tfjs-core'; - -import {createSimpleBinaryKernelImpl} from '../utils/binary_impl'; -import {binaryKernelFunc} from '../utils/binary_utils'; - -export const notEqualImpl = - createSimpleBinaryKernelImpl(((a, b) => (a !== b) ? 1 : 0)); -export const notEqual = - binaryKernelFunc(NotEqual, notEqualImpl, null /* complexOp */, 'bool'); - -export const notEqualConfig: KernelConfig = { - kernelName: NotEqual, - backendName: 'cpu', - kernelFunc: notEqual -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/OneHot.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/OneHot.ts deleted file mode 100644 index 955aaf607..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/OneHot.ts +++ /dev/null @@ -1,51 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, OneHot, OneHotAttrs, OneHotInputs, TensorInfo, TypedArray, util} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; -import {assertNotComplex} from '../cpu_util'; - -export function oneHot( - args: {inputs: OneHotInputs, backend: MathBackendCPU, attrs: OneHotAttrs}): - TensorInfo { - const {inputs, backend, attrs} = args; - const {indices} = inputs; - const {dtype, depth, onValue, offValue} = attrs; - - assertNotComplex(indices, 'oneHot'); - - const indicesSize = util.sizeFromShape(indices.shape); - - const res = new Float32Array(indicesSize * depth); - res.fill(offValue); - const indicesVal = backend.data.get(indices.dataId).values as TypedArray; - - for (let event = 0; event < indicesSize; ++event) { - if (indicesVal[event] >= 0 && indicesVal[event] < depth) { - res[event * depth + indicesVal[event]] = onValue; - } - } - - return backend.makeTensorInfo([...indices.shape, depth], dtype, res); -} - -export const oneHotConfig: KernelConfig = { - kernelName: OneHot, - backendName: 'cpu', - kernelFunc: oneHot as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/OnesLike.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/OnesLike.ts deleted file mode 100644 index 21cc30bdf..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/OnesLike.ts +++ /dev/null @@ -1,57 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, OnesLike, OnesLikeInputs, TensorInfo} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; -import {complex} from './Complex'; -import {fill} from './Fill'; -import {imag} from './Imag'; -import {real} from './Real'; -import {zerosLike} from './ZerosLike'; - -export function onesLike( - args: {inputs: OnesLikeInputs, backend: MathBackendCPU}): TensorInfo { - const {inputs, backend} = args; - const {x} = inputs; - - if (x.dtype === 'string') { - throw new Error('onesLike is not supported for string tensors'); - } else if (x.dtype === 'complex64') { - const realPart = real({inputs: {input: x}, backend}); - const r = onesLike({inputs: {x: realPart}, backend}); - const imagPart = imag({inputs: {input: x}, backend}); - const i = zerosLike({inputs: {x: imagPart}, backend}); - - const result = complex({inputs: {real: r, imag: i}, backend}); - - backend.disposeIntermediateTensorInfo(realPart); - backend.disposeIntermediateTensorInfo(r); - backend.disposeIntermediateTensorInfo(imagPart); - backend.disposeIntermediateTensorInfo(i); - - return result; - } else { - return fill({backend, attrs: {shape: x.shape, value: 1, dtype: x.dtype}}); - } -} - -export const onesLikeConfig: KernelConfig = { - kernelName: OnesLike, - backendName: 'cpu', - kernelFunc: onesLike as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Pack.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Pack.ts deleted file mode 100644 index da7b80f2a..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Pack.ts +++ /dev/null @@ -1,67 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, Pack, PackAttrs, PackInputs, TensorInfo, util} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; -import {concat} from './Concat'; -import {expandDims} from './ExpandDims'; - -export function pack( - args: {inputs: PackInputs, backend: MathBackendCPU, attrs: PackAttrs}): - TensorInfo { - const {inputs, backend, attrs} = args; - const {axis} = attrs; - - if (inputs.length === 1) { - return expandDims( - {inputs: {input: inputs[0]}, backend, attrs: {dim: axis}}); - } - - const shape = inputs[0].shape; - const dtype = inputs[0].dtype; - - inputs.forEach(t => { - util.assertShapesMatch( - shape, t.shape, - 'All tensors passed to stack must have matching shapes'); - util.assert( - dtype === t.dtype, - () => 'All tensors passed to stack must have matching dtypes'); - }); - - const intermediateTensorInfos: TensorInfo[] = []; - const expandedTensors = inputs.map(t => { - const expandedT = - expandDims({inputs: {input: t}, backend, attrs: {dim: axis}}); - intermediateTensorInfos.push(expandedT); - return expandedT; - }); - - const result = concat({inputs: expandedTensors, backend, attrs: {axis}}); - - intermediateTensorInfos.forEach( - t => backend.disposeIntermediateTensorInfo(t)); - - return result; -} - -export const packConfig: KernelConfig = { - kernelName: Pack, - backendName: 'cpu', - kernelFunc: pack as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/PadV2.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/PadV2.ts deleted file mode 100644 index 5e1b55aba..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/PadV2.ts +++ /dev/null @@ -1,69 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, NumericDataType, PadV2, PadV2Attrs, PadV2Inputs, TensorInfo, TypedArray, util} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; -import {assertNotComplex} from '../cpu_util'; - -export function padV2( - args: {inputs: PadV2Inputs, backend: MathBackendCPU, attrs: PadV2Attrs}): - TensorInfo { - const {inputs, backend, attrs} = args; - const {x} = inputs; - const {paddings, constantValue} = attrs; - - assertNotComplex(x, 'pad'); - - const outShape = paddings.map( - (p, i) => p[0] /* beforePad */ + x.shape[i] + p[1] /* afterPad */); - - const start = paddings.map(p => p[0]); - - const xVals = backend.data.get(x.dataId).values as TypedArray; - const xSize = util.sizeFromShape(x.shape); - const xRank = x.shape.length; - const xStrides = util.computeStrides(x.shape); - - const resultSize = util.sizeFromShape(outShape); - const resultRank = outShape.length; - const resultStrides = util.computeStrides(outShape); - const resVals = - util.getTypedArrayFromDType(x.dtype as NumericDataType, resultSize); - - if (constantValue !== 0) { - resVals.fill(constantValue); - } - - for (let i = 0; i < xSize; i++) { - const coords = util.indexToLoc(i, xRank, xStrides); - const outCoords = coords.map((c, i) => c + start[i]); - const outIndex = util.locToIndex(outCoords, resultRank, resultStrides); - - resVals[outIndex] = xVals[i]; - } - - const outId = backend.write(resVals, outShape, x.dtype); - - return {dataId: outId, shape: outShape, dtype: x.dtype}; -} - -export const padV2Config: KernelConfig = { - kernelName: PadV2, - backendName: 'cpu', - kernelFunc: padV2 as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Pow.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Pow.ts deleted file mode 100644 index 39398e078..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Pow.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, Pow} from '@tensorflow/tfjs-core'; - -import {createSimpleBinaryKernelImpl} from '../utils/binary_impl'; -import {binaryKernelFunc} from '../utils/binary_utils'; - -export const powImpl = - createSimpleBinaryKernelImpl((a: number, b: number) => Math.pow(a, b)); -export const pow = binaryKernelFunc(Pow, powImpl); - -export const powConfig: KernelConfig = { - kernelName: Pow, - backendName: 'cpu', - kernelFunc: pow -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Prelu.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Prelu.ts deleted file mode 100644 index 4bfa36751..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Prelu.ts +++ /dev/null @@ -1,47 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, Prelu, PreluInputs, TensorInfo, TypedArray} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; -import {assertNotComplex} from '../cpu_util'; -import {createSimpleBinaryKernelImpl} from '../utils/binary_impl'; - -const preluImpl = createSimpleBinaryKernelImpl( - (xValue: number, aValue: number) => xValue < 0 ? aValue * xValue : xValue); - -export function prelu(args: {inputs: PreluInputs, backend: MathBackendCPU}): - TensorInfo { - const {inputs, backend} = args; - const {x, alpha} = inputs; - - assertNotComplex([x, alpha], 'prelu'); - - const aVals = backend.data.get(x.dataId).values as TypedArray; - const bVals = backend.data.get(alpha.dataId).values as TypedArray; - - const [resultData, resultShape] = - preluImpl(x.shape, alpha.shape, aVals, bVals, 'float32'); - - return backend.makeTensorInfo(resultShape, 'float32', resultData); -} - -export const preluConfig: KernelConfig = { - kernelName: Prelu, - backendName: 'cpu', - kernelFunc: prelu, -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Prod.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Prod.ts deleted file mode 100644 index 3472c3da5..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Prod.ts +++ /dev/null @@ -1,88 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, DataType, KernelConfig, KernelFunc, Prod, ProdAttrs, ProdInputs, TensorInfo, TypedArray, upcastType, util} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; -import {assertNotComplex} from '../cpu_util'; -import {transpose} from './Transpose'; - -export function prodImpl( - xShape: number[], xDtype: DataType, xVals: TypedArray, - reductionAxes: number[]): - {outVals: TypedArray, outShape: number[], outDtype: DataType} { - const [outShape, reduceShape] = - backend_util.computeOutAndReduceShapes(xShape, reductionAxes); - const outDtype = upcastType(xDtype, 'int32'); - const outVals = util.makeZerosTypedArray( - util.sizeFromShape(outShape), outDtype) as TypedArray; - const reduceSize = util.sizeFromShape(reduceShape); - - for (let i = 0; i < outVals.length; ++i) { - const offset = i * reduceSize; - let prod = 1; - for (let j = 0; j < reduceSize; ++j) { - prod *= xVals[offset + j]; - } - outVals[i] = prod; - } - - return {outVals, outShape, outDtype}; -} - -export function prod( - args: {inputs: ProdInputs, backend: MathBackendCPU, attrs: ProdAttrs}): - TensorInfo { - const {inputs, backend, attrs} = args; - const {x} = inputs; - const {axis, keepDims} = attrs; - - assertNotComplex(x, 'prod'); - - const xRank = x.shape.length; - const axes = util.parseAxisParam(axis, x.shape); - - const permutation = backend_util.getAxesPermutation(axes, xRank); - let reductionAxes = axes; - let permutedX = x; - const intermediateTensorInfos = []; - if (permutation != null) { - permutedX = transpose({inputs: {x}, backend, attrs: {perm: permutation}}); - intermediateTensorInfos.push(permutedX); - reductionAxes = backend_util.getInnerMostAxes(reductionAxes.length, xRank); - } - - const xVals = backend.data.get(permutedX.dataId).values as TypedArray; - const {outVals, outShape, outDtype} = - prodImpl(permutedX.shape, permutedX.dtype, xVals, reductionAxes); - - let resultShape = outShape; - if (keepDims) { - resultShape = backend_util.expandShapeToKeepDim(outShape, axes); - } - - intermediateTensorInfos.forEach( - t => backend.disposeIntermediateTensorInfo(t)); - - return backend.makeTensorInfo(resultShape, outDtype, outVals); -} - -export const prodConfig: KernelConfig = { - kernelName: Prod, - backendName: 'cpu', - kernelFunc: prod as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/RaggedGather.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/RaggedGather.ts deleted file mode 100644 index 436dd0915..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/RaggedGather.ts +++ /dev/null @@ -1,59 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, RaggedGather, RaggedGatherAttrs, RaggedGatherInputs, TensorInfo, TypedArray} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; - -import {raggedGatherImpl} from './RaggedGather_impl'; - -export function raggedGather(args: { - inputs: RaggedGatherInputs, - backend: MathBackendCPU, - attrs: RaggedGatherAttrs -}): TensorInfo[] { - const {inputs, backend, attrs} = args; - const {paramsNestedSplits, paramsDenseValues, indices} = inputs; - const {outputRaggedRank} = attrs; - - const $paramsNestedSplits = paramsNestedSplits.map( - t => backend.data.get(t.dataId).values as TypedArray); - const $paramsNestedSplitsShapes = paramsNestedSplits.map(t => t.shape); - const $paramsDenseValues = - backend.data.get(paramsDenseValues.dataId).values as TypedArray; - const $indices = backend.data.get(indices.dataId).values as TypedArray; - - const [outputNestedSplits, outputDenseValues, outputDenseValuesShape] = - raggedGatherImpl( - $paramsNestedSplits, $paramsNestedSplitsShapes, $paramsDenseValues, - paramsDenseValues.shape, paramsDenseValues.dtype, $indices, - indices.shape, outputRaggedRank); - - const outputNestedSplitsTensors = outputNestedSplits.map( - (splits) => backend.makeTensorInfo([splits.length], 'int32', splits)); - - const outputDenseValuesTensor = backend.makeTensorInfo( - outputDenseValuesShape, paramsDenseValues.dtype, outputDenseValues); - - return outputNestedSplitsTensors.concat([outputDenseValuesTensor]); -} - -export const raggedGatherConfig: KernelConfig = { - kernelName: RaggedGather, - backendName: 'cpu', - kernelFunc: raggedGather as unknown as KernelFunc, -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/RaggedGather_impl.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/RaggedGather_impl.ts deleted file mode 100644 index e7580b497..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/RaggedGather_impl.ts +++ /dev/null @@ -1,226 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {DataType, TypedArray, util} from '@tensorflow/tfjs-core'; - -function validateIndices( - indices: TypedArray, indicesShape: number[], numParams: number) { - indices.forEach((index: number, i: number) => { - if (index < 0 || index >= numParams) { - const locString = - util.indexToLoc( - i, indicesShape.length, util.computeStrides(indicesShape)) - .join(','); - throw new Error( - `indices[${locString}] = ${index} is not in [0, ${numParams})`); - } - }); -} - -function validateSplits( - paramsNestedSplits: TypedArray[], numParamsDenseValues: number) { - // Validate - for (let dim = 0; dim < paramsNestedSplits.length; ++dim) { - const splits = paramsNestedSplits[dim]; - const lastSplit = (dim === paramsNestedSplits.length - 1) ? - numParamsDenseValues : - paramsNestedSplits[dim + 1].length; - if (splits.length === 0) { - throw new Error('Ragged splits may not be empty'); - } - if (splits[0] < 0) { - throw new Error('Ragged splits must be non-negative'); - } - if (splits[splits.length - 1] > lastSplit) { - throw new Error('Ragged splits must not point past values'); - } - for (let i = 1; i < splits.length; ++i) { - if (splits[i - 1] > splits[i]) { - throw new Error('Ragged splits must be sorted in ascending order'); - } - } - } -} - -// Construct the `splits` output tensors, encoded using a nested vector. -// Also find the slices of values that need to be copied, and store them -// in `valueSlices`. The total number of values that will be copied (which -// we need for allocating the output values tensor) is stored in `numValues`. -function makeSplits( - indices: TypedArray, indicesShape: number[], - paramsNestedSplits: TypedArray[], numParamsDenseValues: number) { - const valueSlices: Array<[number, number]> = []; - let numValues = 0; - - const numSplits = indicesShape.length - 1 + paramsNestedSplits.length; - const outSplits = new Array(numSplits).fill(null).map(() => [0]); - - validateSplits(paramsNestedSplits, numParamsDenseValues); - - // Add `splits` that come from all but the last dimension of the dense - // Tensor `indices`. In particular, for each dimension D, we add a - // splits tensor whose values are: - // range(reduceProd(splits.shape[:D]) + 1) * splits.shape[D+1] - // E.g., if indices.shape=[2, 3, 4] then we will add splits tensors: - // [0, 3, 6] # length=2+1, stride=3 - // [0, 4, 8, 12, 16, 20, 24] # length=2*3+1, stride=4 - let nrows = 1; - for (let dim = 0; dim < indicesShape.length - 1; ++dim) { - nrows *= indicesShape[dim]; - const rowLength = indicesShape[dim + 1]; - for (let i = 1; i < nrows + 1; ++i) { - outSplits[dim].push(i * rowLength); - } - } - - // Add `splits` that come from `paramsNestedSplits`. Starting with the - // outermost ragged dimension (i.e., the first `splits` tensor), we work - // our way in, finding the range of values that should be copied. As we - // go, we update the output `splits` for each dimension with the appropriate - // values. In particular, the *lengths* of the slices from `param_splits` - // should be copied to generate corresponding slice lengths in the output - // splits. E.g., if we are copying a ragged row with length 4, then we - // should add a new split point to outSplits that is 4 greater than the - // previous split point in outSplits. - for (let i = 0; i < indices.length; ++i) { - let start = indices[i]; - let limit = indices[i] + 1; - - // Copy splits. - for (let dim = 0; dim < paramsNestedSplits.length; ++dim) { - const splits = paramsNestedSplits[dim]; - const outDim = dim + indicesShape.length - 1; - if (outDim >= 0) { - const outSplitsOutDim = outSplits[outDim]; - const delta = - outSplitsOutDim[outSplitsOutDim.length - 1] - splits[start]; - for (let j = start; j < limit; ++j) { - outSplits[outDim].push(splits[j + 1] + delta); - } - } - start = splits[start]; - limit = splits[limit]; - } - if (limit !== start) { - valueSlices.push([start, limit]); - numValues += limit - start; - } - } - - return {outSplits, valueSlices, numValues}; -} - -function getSplits(outSplits: number[][]) { - const splitsOut: TypedArray[] = []; - for (let i = 0; i < outSplits.length; ++i) { - const numSplits = outSplits[i].length; - const splits = util.getArrayFromDType('int32', numSplits) as TypedArray; - splitsOut.push(splits); - - outSplits[i].forEach((value, j: number) => splits[j] = value); - } - - return splitsOut; -} - -function computeFlatOuterDims(orig: number[], numOutDims: number) { - const outDims = orig.slice(0, numOutDims); - while (outDims.length < numOutDims) { - outDims.push(1); - } - - for (let inDim = numOutDims; inDim < orig.length; inDim++) { - outDims[numOutDims - 1] *= orig[inDim]; - } - - return outDims; -} -// For each slice in `(start, limit)` in `valueSlices`, append -// `paramsDenseValues[start,...,limit] to `values`. `valueSize` indicates -// the number of scalars contained in each value paramsDenseValues[i]. -function writeValueSlices( - paramsDenseValues: TypedArray, paramsDenseValuesShape: number[], - valueSlices: Array<[number, number]>, valueSize: number, values: TypedArray, - valuesShape: number[]) { - const denseM = computeFlatOuterDims(paramsDenseValuesShape, 2)[1]; - const valuesM = computeFlatOuterDims(valuesShape, 2)[1]; - - let outPos = 0; - for (const slice of valueSlices) { - for (let i = slice[0]; i < slice[1]; ++i) { - for (let j = 0; j < valueSize; ++j) { - values[outPos * valuesM + j] = paramsDenseValues[i * denseM + j]; - } - ++outPos; - } - } -} - -function getValues( - paramsDenseValues: TypedArray, paramsDenseValuesShape: number[], - paramsDenseValuesDType: DataType, valueSlices: Array<[number, number]>, - numValues: number): [TypedArray, number[]] { - const valuesShape = paramsDenseValuesShape.slice(); - valuesShape[0] = numValues; - - const valuesOut = util.getArrayFromDType( - paramsDenseValuesDType, - util.sizeFromShape(valuesShape)) as TypedArray; - - const numElements = paramsDenseValues.length; - const valueSize = - numElements === 0 ? 0 : (numElements / paramsDenseValuesShape[0]); - writeValueSlices( - paramsDenseValues, paramsDenseValuesShape, valueSlices, valueSize, - valuesOut, valuesShape); - - return [valuesOut, valuesShape]; -} -export function raggedGatherImpl( - paramsNestedSplits: TypedArray[], paramsNestedSplitsShapes: number[][], - paramsDenseValues: TypedArray, paramsDenseValuesShape: number[], - paramsDenseValuesDType: DataType, indices: TypedArray, - indicesShape: number[], - outputRaggedRank: number): [TypedArray[], TypedArray, number[]] { - if (paramsNestedSplits.length === 0) { - throw new Error('paramsNestedSplits must be non empty'); - } - - if (paramsNestedSplitsShapes[0].length === 0) { - throw new Error('Split tensors must not be scalars'); - } - const numParams = paramsNestedSplitsShapes[0][0] - 1; - validateIndices(indices, indicesShape, numParams); - - if (paramsDenseValuesShape.length === 0) { - throw new Error('params.rank must be nonzero'); - } - const numParamsDenseValues = paramsDenseValuesShape[0]; - - // Calculate the `splits`, and store the value slices that we need to - // copy in `valueSlices`. - const {outSplits, valueSlices, numValues} = makeSplits( - indices, indicesShape, paramsNestedSplits, numParamsDenseValues); - - // Write the output tensors. - const outputNestedSplits = getSplits(outSplits); - const outputDenseValues = getValues( - paramsDenseValues, paramsDenseValuesShape, paramsDenseValuesDType, - valueSlices, numValues); - - return [outputNestedSplits, outputDenseValues[0], outputDenseValues[1]]; -} diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/RaggedRange.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/RaggedRange.ts deleted file mode 100644 index 41efb6d8c..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/RaggedRange.ts +++ /dev/null @@ -1,50 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, RaggedRange, RaggedRangeInputs, TensorInfo, TypedArray} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; - -import {raggedRangeImpl} from './RaggedRange_impl'; - -export function raggedRange( - args: {inputs: RaggedRangeInputs, backend: MathBackendCPU}): - [TensorInfo, TensorInfo] { - const {inputs, backend} = args; - const {starts, limits, deltas} = inputs; - - const $starts = backend.data.get(starts.dataId).values as TypedArray; - const $limits = backend.data.get(limits.dataId).values as TypedArray; - const $deltas = backend.data.get(deltas.dataId).values as TypedArray; - - const [rtNestedSplitsData, rtDenseValuesData] = raggedRangeImpl( - $starts, starts.shape, starts.dtype, $limits, limits.shape, $deltas, - deltas.shape); - - const rtNestedSplits = backend.makeTensorInfo( - [rtNestedSplitsData.length], 'int32', rtNestedSplitsData); - const rtDenseValues = backend.makeTensorInfo( - [rtDenseValuesData.length], starts.dtype, rtDenseValuesData); - - return [rtNestedSplits, rtDenseValues]; -} - -export const raggedRangeConfig: KernelConfig = { - kernelName: RaggedRange, - backendName: 'cpu', - kernelFunc: raggedRange as unknown as KernelFunc, -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/RaggedRange_impl.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/RaggedRange_impl.ts deleted file mode 100644 index 256ca4b0a..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/RaggedRange_impl.ts +++ /dev/null @@ -1,104 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {DataType, TypedArray, util} from '@tensorflow/tfjs-core'; - -const INT32_MAX = 2147483647; - -export function raggedRangeImpl( - starts: TypedArray, startsShape: number[], startsDType: DataType, - limits: TypedArray, limitsShape: number[], deltas: TypedArray, - deltasShape: number[]): [TypedArray, TypedArray] { - // Check input tensor shapes. - if (startsShape.length > 1) { - throw new Error('starts must be a scalar or vector'); - } - if (limitsShape.length > 1) { - throw new Error('limits must be a scalar or vector'); - } - if (deltasShape.length > 1) { - throw new Error('deltas must be a scalar or vector'); - } - - // Determine which tensors we need to broadcast. - const broadcastStarts = startsShape.length === 0; - const broadcastLimits = limitsShape.length === 0; - const broadcastDeltas = deltasShape.length === 0; - - // nRows (number of output rows) is the size of the non-broadcast inputs, - // or 1 if all inputs are scalars. - const inSizes: number[] = []; - if (!broadcastStarts) { - inSizes.push(startsShape[0]); - } - if (!broadcastLimits) { - inSizes.push(limitsShape[0]); - } - if (!broadcastDeltas) { - inSizes.push(deltasShape[0]); - } - - for (let i = 1; i < inSizes.length; ++i) { - if (inSizes[i] !== inSizes[i - 1]) { - throw new Error('starts, limits, and deltas must have the same shape'); - } - } - const nRows = inSizes.length === 0 ? 1 : inSizes[0]; - - // Construct the rtNestedSplits tensor. - const rtNestedSplits = - util.getArrayFromDType('int32', nRows + 1) as TypedArray; - rtNestedSplits[0] = 0; - for (let row = 0; row < nRows; ++row) { - const start = broadcastStarts ? starts[0] : starts[row]; - const limit = broadcastLimits ? limits[0] : limits[row]; - const delta = broadcastDeltas ? deltas[0] : deltas[row]; - if (delta === 0) { - throw new Error('Requires delta != 0'); - } - let size: number; // The number of elements in the specified range. - if (((delta > 0) && (limit < start)) || ((delta < 0) && (limit > start))) { - size = 0; - } else { - size = Math.ceil(Math.abs((limit - start) / delta)); - - if (size > INT32_MAX) { - throw new Error(`Requires ((limit - start) / delta) <= ${INT32_MAX}`); - } - } - rtNestedSplits[row + 1] = rtNestedSplits[row] + size; - } - - const nVals = rtNestedSplits[nRows]; - - // Construct the rtDenseValues tensor. - const rtDenseValues = - util.getArrayFromDType(startsDType, nVals) as TypedArray; - - let valueIndex = 0; - for (let row = 0; row < nRows; ++row) { - const rowSize = rtNestedSplits[row + 1] - rtNestedSplits[row]; - let value = broadcastStarts ? starts[0] : starts[row]; - const delta = broadcastDeltas ? deltas[0] : deltas[row]; - for (let i = 0; i < rowSize; ++i) { - rtDenseValues[valueIndex++] = value; - value += delta; - } - } - - return [rtNestedSplits, rtDenseValues]; -} diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/RaggedTensorToTensor.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/RaggedTensorToTensor.ts deleted file mode 100644 index 3849cba0b..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/RaggedTensorToTensor.ts +++ /dev/null @@ -1,52 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, RaggedTensorToTensor, RaggedTensorToTensorAttrs, RaggedTensorToTensorInputs, TensorInfo, TypedArray} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; - -import {raggedTensorToTensorImpl} from './RaggedTensorToTensor_impl'; - -export function raggedTensorToTensor(args: { - inputs: RaggedTensorToTensorInputs, - backend: MathBackendCPU, - attrs: RaggedTensorToTensorAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {shape, values, defaultValue, rowPartitionTensors} = inputs; - const {rowPartitionTypes} = attrs; - - const $shape = backend.data.get(shape.dataId).values as TypedArray; - const $values = backend.data.get(values.dataId).values as TypedArray; - const $defaultValue = - backend.data.get(defaultValue.dataId).values as TypedArray; - const $rowPartitionValues = rowPartitionTensors.map( - t => backend.data.get(t.dataId).values as TypedArray); - const rowPartitionValuesShapes = rowPartitionTensors.map(t => t.shape); - - const [outputShape, output] = raggedTensorToTensorImpl( - $shape, shape.shape, $values, values.shape, values.dtype, $defaultValue, - defaultValue.shape, $rowPartitionValues, rowPartitionValuesShapes, - rowPartitionTypes); - return backend.makeTensorInfo(outputShape, values.dtype, output); -} - -export const raggedTensorToTensorConfig: KernelConfig = { - kernelName: RaggedTensorToTensor, - backendName: 'cpu', - kernelFunc: raggedTensorToTensor as unknown as KernelFunc, -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/RaggedTensorToTensor_impl.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/RaggedTensorToTensor_impl.ts deleted file mode 100644 index 06ae621cc..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/RaggedTensorToTensor_impl.ts +++ /dev/null @@ -1,479 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, broadcastTo, DataType, reshape, tidy, TypedArray, util} from '@tensorflow/tfjs-core'; - -import RowPartitionType = backend_util.RowPartitionType; -// Based on -// https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/kernels/ragged_tensor_to_tensor_op.cc -class RaggedTensorToTensorOp { - private readonly rowPartitionTypes: RowPartitionType[]; - private readonly raggedRank: number; - constructor( - private shape: TypedArray, private shapeShape: number[], - private values: TypedArray, private valuesShape: number[], - private valuesDType: DataType, private defaultValue: TypedArray, - private defaultValueShape: number[], - private readonly rowPartitionValues: TypedArray[], - private readonly rowPartitionValuesShapes: number[][], - rowPartitionTypeStrings: string[]) { - this.rowPartitionTypes = - backend_util.getRowPartitionTypesHelper(rowPartitionTypeStrings); - this.raggedRank = backend_util.getRaggedRank(this.rowPartitionTypes); - } - - private getRowPartitionTypeByDimension(dimension: number) { - if (this.rowPartitionTypes[0] === RowPartitionType.FIRST_DIM_SIZE) { - return this.rowPartitionTypes[dimension + 1]; - } else { - return this.rowPartitionTypes[dimension]; - } - } - - // Returns the relationship between dimension and dimension + 1. - private getRowPartitionTensor(dimension: number) { - if (this.rowPartitionTypes[0] === RowPartitionType.FIRST_DIM_SIZE) { - return this.rowPartitionValues[dimension + 1]; - } else { - return this.rowPartitionValues[dimension]; - } - } - - private getMaxWidth(dimension: number) { - const rowPartitionTensor = this.getRowPartitionTensor(dimension - 1); - switch (this.getRowPartitionTypeByDimension(dimension - 1)) { - case RowPartitionType.VALUE_ROWIDS: - return RaggedTensorToTensorOp.getMaxWidthValueRowID(rowPartitionTensor); - case RowPartitionType.ROW_SPLITS: - return RaggedTensorToTensorOp.getMaxWidthRowSplit(rowPartitionTensor); - default: - throw new Error(`Cannot handle partition type ${ - RowPartitionType[this.getRowPartitionTypeByDimension( - dimension - 1)]}`); - } - } - - static getMaxWidthRowSplit(rowSplit: TypedArray) { - const tensorLength = rowSplit.length; - if (tensorLength === 0 || tensorLength === 1) { - return 0; - } - let maxWidth = 0; - for (let i = 0; i < tensorLength - 1; ++i) { - const currentWidth = rowSplit[i + 1] - rowSplit[i]; - if (currentWidth > maxWidth) { - maxWidth = currentWidth; - } - } - return maxWidth; - } - - static getMaxWidthValueRowID(valueRowIds: TypedArray) { - const indexLength = valueRowIds.length; - if (indexLength === 0) { - return 0; - } - let firstEqualIndex = 0; - let firstEqualIndexValue = valueRowIds[0]; - let maxWidth = 0; - for (let i = 1; i < indexLength; ++i) { - const value = valueRowIds[i]; - if (value !== firstEqualIndexValue) { - firstEqualIndexValue = value; - maxWidth = Math.max(i - firstEqualIndex, maxWidth); - firstEqualIndex = i; - } - } - return Math.max(indexLength - firstEqualIndex, maxWidth); - } - - private tensorShapeFromTensor( - t: TypedArray, tShape: number[], isPartial = true) { - if (tShape.length === 0) { - if (t[0] === -1) { - return []; - } - throw new Error( - `The only valid scalar shape tensor is the fully unknown shape specified as -1.`); - } - // MakePartialShape/MakeShapeHelper. - return makeShape(t, isPartial); - } - - private calculateOutputSize(firstDim: number) { - const valueShape = this.valuesShape; - const defaultValueShape = this.defaultValueShape; - - backend_util.validateDefaultValueShape(defaultValueShape, valueShape); - - const shape = this.tensorShapeFromTensor(this.shape, this.shapeShape); - const outputShape = backend_util.combineRaggedTensorToTensorShapes( - this.raggedRank, shape, valueShape); - - const result = outputShape; - - if (result[0] < 0) { - result[0] = firstDim; - } - for (let i = 1; i <= this.raggedRank; ++i) { - if (result[i] < 0) { - result[i] = this.getMaxWidth(i); - } - } - - return result; - } - - /** - * The outputIndex represents the index in the output tensor - * where the first element of a particular dimension would be written. - * If it is -1, it indicates that the index is out of scope. - * Example, given firstDimension = 10, firstDimensionOutput = 6, - * and outputIndexMultiplier = 100: - * result = [0 100 200 300 400 500 -1 -1 -1 -1] - * If firstDimensionOutput = 11 instead, then: - * result = [0 100 200 300 400 500 600 700 800 900] - */ - private calculateFirstParentOutputIndex( - firstDimension: number, outputIndexMultiplier: number, - firstDimensionOutput: number) { - const minDimension = Math.min(firstDimension, firstDimensionOutput); - const result: number[] = []; - let currentOutputIndex = 0; - for (let i = 0; i < minDimension; - ++i, currentOutputIndex += outputIndexMultiplier) { - result.push(currentOutputIndex); - } - for (let i = minDimension; i < firstDimension; ++i) { - result.push(-1); - } - util.assert( - result.length === firstDimension, - () => 'Final length of result must be equal to firstDimension.'); - - return result; - } - - private calculateOutputIndexRowSplit( - rowSplit: TypedArray, parentOutputIndex: number[], - outputIndexMultiplier: number, outputSize: number) { - const rowSplitSize = rowSplit.length; - const result: number[] = []; - for (let i = 0; i < rowSplitSize - 1; ++i) { - const rowLength = rowSplit[i + 1] - rowSplit[i]; - let realLength = Math.min(outputSize, rowLength); - let parentOutputIndexCurrent = parentOutputIndex[i]; - - if (parentOutputIndexCurrent === -1) { - realLength = 0; - } - for (let j = 0; j < realLength; ++j) { - result.push(parentOutputIndexCurrent); - parentOutputIndexCurrent += outputIndexMultiplier; - } - for (let j = 0; j < rowLength - realLength; ++j) { - result.push(-1); - } - } - if (rowSplitSize > 0 && result.length !== rowSplit[rowSplitSize - 1]) { - throw new Error('Invalid row split size.'); - } - - return result; - } - - // Calculate the output index of the first element of a list. - // The parentOutputIndex is the same computation for the previous list. - // -1 indicates an element or list that is out of range. - // The outputIndexMultiplier is the number of output indices one moves - // forward for each column. - // E.g., given: - // valueRowIds:[0 1 2 2 2 3 5 5 6] - // parentOutputIndex:[1000 1100 2000 2100 -1 3000 4000] - // outputIndexMultiplier: 10 - // outputSize: 2 - // You get: - // result = [1000 1100 2000 2010 -1 2100 -1 -1 3000] - // result[0] = parentOutputIndex[valueRowIds[0]] - // result[1] = parentOutputIndex[valueRowIds[1]] - // result[2] = parentOutputIndex[valueRowIds[2]] - // result[3] = parentOutputIndex[valueRowIds[2] + 10] - // result[4] = -1 because it is the third element the size is 2. - // result[5] = parentOutputIndex[valueRowIds[3]] - // result[6] = -1 because parentOutputIndex[valueRowIds[6]] == -1 - // result[7] = -1 because parentOutputIndex[valueRowIds[6]] == -1 - // result[8] = parentOutputIndex[valueRowIds[7]] - private calculateOutputIndexValueRowID( - valueRowIds: TypedArray, parentOutputIndex: number[], - outputIndexMultiplier: number, outputSize: number) { - const indexSize = valueRowIds.length; - const result: number[] = []; - if (indexSize === 0) { - return []; - } - - let currentOutputColumn = 0; - let currentValueRowId = valueRowIds[0]; - - if (currentValueRowId >= parentOutputIndex.length) { - throw new Error( - `Got currentValueRowId=${currentValueRowId}, which is not less than ${ - parentOutputIndex.length}`); - } - - let currentOutputIndex = parentOutputIndex[currentValueRowId]; - result.push(currentOutputIndex); - for (let i = 1; i < indexSize; ++i) { - const nextValueRowId = valueRowIds[i]; - if (nextValueRowId === currentValueRowId) { - if (currentOutputIndex >= 0) { - ++currentOutputColumn; - if (currentOutputColumn < outputSize) { - currentOutputIndex += outputIndexMultiplier; - } else { - currentOutputIndex = -1; - } - } - } else { - currentOutputColumn = 0; - currentValueRowId = nextValueRowId; - - if (nextValueRowId >= parentOutputIndex.length) { - throw new Error( - `Got nextValueRowId=${nextValueRowId} which is not less than ${ - parentOutputIndex.length}`); - } - - currentOutputIndex = parentOutputIndex[nextValueRowId]; - } - result.push(currentOutputIndex); - } - - if (result.length !== valueRowIds.length) { - throw new Error('Invalid row ids.'); - } - - return result; - } - - private calculateOutputIndex( - dimension: number, parentOutputIndex: number[], - outputIndexMultiplier: number, outputSize: number) { - const rowPartitionTensor = this.getRowPartitionTensor(dimension); - const partitionType = this.getRowPartitionTypeByDimension(dimension); - switch (partitionType) { - case RowPartitionType.VALUE_ROWIDS: - return this.calculateOutputIndexValueRowID( - rowPartitionTensor, parentOutputIndex, outputIndexMultiplier, - outputSize); - case RowPartitionType.ROW_SPLITS: - if (rowPartitionTensor.length - 1 > parentOutputIndex.length) { - throw new Error(`Row partition size is greater than output size: ${ - rowPartitionTensor.length - 1} > ${parentOutputIndex.length}`); - } - return this.calculateOutputIndexRowSplit( - rowPartitionTensor, parentOutputIndex, outputIndexMultiplier, - outputSize); - default: - throw new Error( - `Unsupported partition type: ${RowPartitionType[partitionType]}`); - } - } - - private getFirstDimensionSize() { - const firstPartitionTensor = this.rowPartitionValues[0]; - if (this.rowPartitionTypes.length === 0) { - throw new Error('No row_partition_types given.'); - } - const firstPartitionType = this.rowPartitionTypes[0]; - switch (firstPartitionType) { - case RowPartitionType.FIRST_DIM_SIZE: - return firstPartitionTensor[0]; - case RowPartitionType.VALUE_ROWIDS: - throw new Error('Cannot handle VALUE_ROWIDS in first dimension.'); - case RowPartitionType.ROW_SPLITS: - return this.rowPartitionValuesShapes[0][0] - 1; - default: - throw new Error( - `Cannot handle type ${RowPartitionType[firstPartitionType]}`); - } - } - - compute(): [number[], TypedArray] { - const firstPartitionTensor = this.rowPartitionValues[0]; - if (firstPartitionTensor.length <= 0) { - throw new Error( - 'Invalid first partition input. ' + - 'Tensor requires at least one element.'); - } - const firstDimension = this.getFirstDimensionSize(); - const outputSize = this.calculateOutputSize(firstDimension); - const multiplier: number[] = new Array(this.raggedRank + 1); - - multiplier[multiplier.length - 1] = 1; - for (let i = multiplier.length - 2; i >= 0; --i) { - multiplier[i] = multiplier[i + 1] * outputSize[i + 1]; - } - // Full size of the tensor. - const outputShape: number[] = makeShape(outputSize, false); - const outputTensor = - util.getArrayFromDType( - this.valuesDType, util.sizeFromShape(outputShape)) as TypedArray; - - const fullSize = multiplier[0] * outputSize[0]; - if (fullSize > 0) { - let outputIndex = this.calculateFirstParentOutputIndex( - firstDimension, multiplier[0], outputSize[0]); - for (let i = 1; i <= this.raggedRank; ++i) { - const newOutputIndex = this.calculateOutputIndex( - i - 1, outputIndex, multiplier[i], outputSize[i]); - outputIndex = newOutputIndex; - } - - this.setOutput(this.raggedRank, outputIndex, outputTensor, outputShape); - } - - return [outputShape, outputTensor]; - } - setOutput( - raggedRank: number, outputIndex: number[], outputTensor: TypedArray, - outputShape: number[]) { - if (outputTensor.length === 0) { - return; - } - - const valuesBase = this.values; - const outputBase = outputTensor; - - let elementShape = outputShape.slice(); - elementShape = elementShape.slice(raggedRank + 1); - const valueElementSize = util.sizeFromShape(elementShape); - const outputIndexSize = outputIndex.length; - - // Broadcast the default value to value_element_size. (We can skip this - // if defaultValueTensor.size == 1, since we use fill when that's true.) - let defaultValue = this.defaultValue; - if (defaultValue.length !== valueElementSize && defaultValue.length !== 1) { - const srcShape = this.defaultValueShape; - tidy(() => { - const defaultValueTensor = reshape(defaultValue, srcShape); - const bCastDefault = broadcastTo(defaultValueTensor, elementShape); - defaultValue = bCastDefault.dataSync(); - }); - } - - // Loop through the outputIndex array, finding contiguous regions that - // should be copied. Once we find the end of a contiguous region, copy it - // and add any necessary padding (with defaultValue). - let srcStart = 0; // Start of contiguous region (in values) - let dstStart = 0; // Destination for contiguous region (in output) - let dstEnd = 0; // Destination for contiguous region (in output) - for (let srcI = 0; srcI <= outputIndexSize; ++srcI) { - // dstI is the destination where the value at srcI should be copied. - let dstI = srcI < outputIndexSize ? outputIndex[srcI] : -1; - - // If we're still in a contiguous region, then update dstEnd go to the - // next srcI. - if (dstI === dstEnd) { - ++dstEnd; - continue; - } - - // We found the end of contiguous region. This can be because we found - // a gap (dstI > dstEnd), or a source value that shouldn't be copied - // because it's out-of-bounds (dstI == -1), or the end of the tensor - // (dstI === -1). - if (dstStart < dstEnd) { - // Copy the contiguous region. - const src = valuesBase.subarray(srcStart * valueElementSize); - const dst = outputBase.subarray(dstStart * valueElementSize); - const nVals = (dstEnd - dstStart) * valueElementSize; - copyArray(dst, src, nVals); - } - - // Add any necessary padding (w/ defaultValue). - if (srcI >= outputIndexSize) { - // We reached the end of values: pad to the end of output. - const outputSize = outputTensor.length; - dstI = Math.floor(outputSize / valueElementSize); - } - if (dstI > dstEnd) { - if (this.defaultValue.length === 1) { - outputBase - .subarray(dstEnd * valueElementSize, dstI * valueElementSize) - .fill(this.defaultValue[0]); - dstEnd = dstI; - } else { - while (dstI > dstEnd) { - const dst = outputBase.slice(dstEnd * valueElementSize); - copyArray(dst, defaultValue, valueElementSize); - ++dstEnd; - } - } - } - - // Update indices. - if (dstI < 0) { - // srcI should be skipped -- leave it out of the contiguous region. - srcStart = srcI + 1; - dstStart = dstEnd; - } else { - // srcI should be copied -- include it in the contiguous region. - srcStart = srcI; - dstStart = dstEnd; - dstEnd = dstStart + 1; - } - } - } -} - -function copyArray(dst: TypedArray, src: TypedArray, size: number) { - for (let i = 0; i < size; i++) { - dst[i] = src[i]; - } -} - -function makeShape(shape: number[]|TypedArray, isPartial: boolean) { - const out: number[] = []; - for (let dim of shape) { - if (dim < 0) { - if (!isPartial) { - throw new Error(`Dimension ${dim} must be >= 0`); - } - if (dim < -1) { - throw new Error(`Dimension ${dim} must be >= -1`); - } - dim = -1; - } - out.push(dim); - } - - return out; -} - -export function raggedTensorToTensorImpl( - shape: TypedArray, shapesShape: number[], values: TypedArray, - valuesShape: number[], valuesDType: DataType, defaultValue: TypedArray, - defaultValueShape: number[], rowPartitionValues: TypedArray[], - rowPartitionValuesShapes: number[][], - rowPartitionTypes: string[]): [number[], TypedArray] { - return new RaggedTensorToTensorOp( - shape, shapesShape, values, valuesShape, valuesDType, defaultValue, - defaultValueShape, rowPartitionValues, rowPartitionValuesShapes, - rowPartitionTypes) - .compute(); -} diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Range.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Range.ts deleted file mode 100644 index 713a4735e..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Range.ts +++ /dev/null @@ -1,36 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, Range, RangeAttrs, TensorInfo} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; -import {rangeImpl} from './Range_impl'; - -export function range(args: {backend: MathBackendCPU, attrs: RangeAttrs}): - TensorInfo { - const {backend, attrs} = args; - const {start, stop, dtype, step} = attrs; - - const values = rangeImpl(start, stop, step, dtype); - return backend.makeTensorInfo([values.length], dtype, values); -} - -export const rangeConfig: KernelConfig = { - kernelName: Range, - backendName: 'cpu', - kernelFunc: range as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Range_impl.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Range_impl.ts deleted file mode 100644 index 8b0b34caf..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Range_impl.ts +++ /dev/null @@ -1,46 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {DataTypeMap, util} from '@tensorflow/tfjs-core'; - -export function rangeImpl( - start: number, stop: number, step: number, - dtype: 'float32'|'int32'): DataTypeMap['float32' | 'int32'] { - const sameStartStop = start === stop; - const increasingRangeNegativeStep = start < stop && step < 0; - const decreasingRangePositiveStep = stop < start && step > 1; - - if (sameStartStop || increasingRangeNegativeStep || - decreasingRangePositiveStep) { - return util.makeZerosTypedArray(0, dtype); - } - - const numElements = Math.abs(Math.ceil((stop - start) / step)); - const values = util.makeZerosTypedArray(numElements, dtype); - - if (stop < start && step === 1) { - // Auto adjust the step's sign if it hasn't been set - // (or was set to 1) - step = -1; - } - - values[0] = start; - for (let i = 1; i < values.length; i++) { - values[i] = values[i - 1] + step; - } - return values; -} diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Real.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Real.ts deleted file mode 100644 index 2c25f254a..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Real.ts +++ /dev/null @@ -1,40 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, Real, RealInputs, TensorInfo} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; - -export function real(args: {inputs: RealInputs, backend: MathBackendCPU}): - TensorInfo { - const {inputs, backend} = args; - const {input} = inputs; - - const real = backend.data.get(input.dataId).complexTensorInfos.real; - const realVal = backend.data.get(real.dataId).values; - - // When complex tensor is disposed, its underlying parts will be disposed too. - // Make new tensor out of the real value of the complex. This makes sure the - // value is still accessible even if complex tensor is disposed. - return backend.makeTensorInfo(real.shape, real.dtype, realVal); -} - -export const realConfig: KernelConfig = { - kernelName: Real, - backendName: 'cpu', - kernelFunc: real as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/RealDiv.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/RealDiv.ts deleted file mode 100644 index 92714ed34..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/RealDiv.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, RealDiv} from '@tensorflow/tfjs-core'; - -import {createSimpleBinaryKernelImpl} from '../utils/binary_impl'; -import {binaryKernelFunc} from '../utils/binary_utils'; - -export const realDivImpl = - createSimpleBinaryKernelImpl((a: number, b: number) => a / b); -export const div = binaryKernelFunc(RealDiv, realDivImpl); - -export const realDivConfig: KernelConfig = { - kernelName: RealDiv, - backendName: 'cpu', - kernelFunc: div -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Reciprocal.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Reciprocal.ts deleted file mode 100644 index 2b63199ae..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Reciprocal.ts +++ /dev/null @@ -1,28 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, Reciprocal} from '@tensorflow/tfjs-core'; - -import {unaryKernelFunc} from '../utils/unary_utils'; - -export const reciprocal = unaryKernelFunc(Reciprocal, (xi) => 1 / xi); - -export const reciprocalConfig: KernelConfig = { - kernelName: Reciprocal, - backendName: 'cpu', - kernelFunc: reciprocal, -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Relu.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Relu.ts deleted file mode 100644 index 19c2f80a4..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Relu.ts +++ /dev/null @@ -1,28 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, Relu} from '@tensorflow/tfjs-core'; - -import {unaryKernelFunc} from '../utils/unary_utils'; - -export const relu = unaryKernelFunc(Relu, (xi) => Math.max(0, xi)); - -export const reluConfig: KernelConfig = { - kernelName: Relu, - backendName: 'cpu', - kernelFunc: relu, -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Relu6.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Relu6.ts deleted file mode 100644 index 891d80903..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Relu6.ts +++ /dev/null @@ -1,29 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, Relu6} from '@tensorflow/tfjs-core'; - -import {unaryKernelFunc} from '../utils/unary_utils'; - -export const relu6 = - unaryKernelFunc(Relu6, (xi) => Math.min(Math.max(0, xi), 6)); - -export const relu6Config: KernelConfig = { - kernelName: Relu6, - backendName: 'cpu', - kernelFunc: relu6, -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Reshape.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Reshape.ts deleted file mode 100644 index 02c455d98..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Reshape.ts +++ /dev/null @@ -1,59 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, Reshape, ReshapeAttrs, ReshapeInputs, TensorInfo, util} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; - -export function reshape( - args: - {inputs: ReshapeInputs, backend: MathBackendCPU, attrs: ReshapeAttrs}): - TensorInfo { - const {inputs, backend, attrs} = args; - const {x} = inputs; - const {shape} = attrs; - - const xSize = util.sizeFromShape(x.shape); - const $shape = util.inferFromImplicitShape(shape, xSize); - const $xSize = util.sizeFromShape($shape); - - util.assert( - xSize === $xSize, - () => `The new shape (${$shape}) has ${$xSize} elements and the old ` + - `shape (${x.shape}) has ${xSize} elements. The new shape and old ` + - `shape must have the same number of elements.`); - - backend.incRef(x.dataId); - - const xData = backend.data.get(x.dataId); - - if (xData.complexTensorInfos != null) { - const real = xData.complexTensorInfos.real; - const imag = xData.complexTensorInfos.imag; - - real.shape = $shape; - imag.shape = $shape; - } - - return {dataId: x.dataId, shape: $shape, dtype: x.dtype}; -} - -export const reshapeConfig: KernelConfig = { - kernelName: Reshape, - backendName: 'cpu', - kernelFunc: reshape as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Reshape_test.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Reshape_test.ts deleted file mode 100644 index 7796fded4..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Reshape_test.ts +++ /dev/null @@ -1,81 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '@tensorflow/tfjs-core'; -import {Tensor, test_util} from '@tensorflow/tfjs-core'; - -const {expectArraysClose, expectArraysEqual} = test_util; -// tslint:disable-next-line: no-imports-from-dist -import {describeWithFlags, ALL_ENVS} from '@tensorflow/tfjs-core/dist/jasmine_util'; - -describeWithFlags('Reshape.', ALL_ENVS, () => { - it('does not have memory leak.', async () => { - const beforeDataIds = tf.engine().backend.numDataIds(); - - const x = tf.tensor1d([1, 1, 1, 1]); - const res = - // tslint:disable-next-line: no-unnecessary-type-assertion - tf.engine().runKernel('Reshape', {x}, {shape: [2, 2]}) as Tensor; - - expectArraysClose(await res.data(), [1, 1, 1, 1]); - expectArraysEqual(res.shape, [2, 2]); - - const afterResDataIds = tf.engine().backend.numDataIds(); - expect(afterResDataIds).toEqual(beforeDataIds + 1); - - x.dispose(); - res.dispose(); - - const afterDisposeDataIds = tf.engine().backend.numDataIds(); - expect(afterDisposeDataIds).toEqual(beforeDataIds); - }); - - it('does not have memory leak calling reshape twice.', async () => { - const beforeDataIds = tf.engine().backend.numDataIds(); - - // Adding 1 new dataId. - const x = tf.tensor1d([1, 1, 1, 1]); - - // Does not add new dataId; - const res = - // tslint:disable-next-line: no-unnecessary-type-assertion - tf.engine().runKernel('Reshape', {x}, {shape: [2, 2]}) as Tensor; - - expectArraysEqual(res.shape, [2, 2]); - - // Does not add new dataId. - const res2 = - // tslint:disable-next-line: no-unnecessary-type-assertion - tf.engine().runKernel('Reshape', {x: res}, {shape: [1, 4]}) as Tensor; - expectArraysEqual(res2.shape, [1, 4]); - - const afterRes2DataIds = tf.engine().backend.numDataIds(); - expect(afterRes2DataIds).toEqual(beforeDataIds + 1); - - res.dispose(); - - const afterResDataIds = tf.engine().backend.numDataIds(); - expect(afterResDataIds).toEqual(beforeDataIds + 1); - - x.dispose(); - res2.dispose(); - - const afterDisposeDataIds = tf.engine().backend.numDataIds(); - // Should be able to dispose the dataId. - expect(afterDisposeDataIds).toEqual(beforeDataIds); - }); -}); diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/ResizeBilinear.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/ResizeBilinear.ts deleted file mode 100644 index 024dd4f04..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/ResizeBilinear.ts +++ /dev/null @@ -1,111 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, ResizeBilinear, ResizeBilinearAttrs, ResizeBilinearInputs, TensorInfo, TypedArray, util} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; -import {assertNotComplex} from '../cpu_util'; - -export function resizeBilinear(args: { - inputs: ResizeBilinearInputs, - backend: MathBackendCPU, - attrs: ResizeBilinearAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {images} = inputs; - const {alignCorners, halfPixelCenters, size} = attrs; - - assertNotComplex(images, 'resizeBilinear'); - - const imagesStrides = util.computeStrides(images.shape); - const [newHeight, newWidth] = size; - - const [batch, oldHeight, oldWidth, numChannels] = images.shape; - const xValues = backend.data.get(images.dataId).values as TypedArray; - const result = new Float32Array( - util.sizeFromShape([batch, newHeight, newWidth, numChannels])); - - const effectiveInputSize: [number, number] = [ - (alignCorners && newHeight > 1) ? oldHeight - 1 : oldHeight, - (alignCorners && newWidth > 1) ? oldWidth - 1 : oldWidth - ]; - - const effectiveOutputSize: [number, number] = [ - (alignCorners && newHeight > 1) ? newHeight - 1 : newHeight, - (alignCorners && newWidth > 1) ? newWidth - 1 : newWidth - ]; - let outputIdx = 0; - const effectiveRowSizeRatio = effectiveInputSize[0] / effectiveOutputSize[0]; - const effectiveColSizeRatio = effectiveInputSize[1] / effectiveOutputSize[1]; - for (let b = 0; b < batch; b++) { - for (let r = 0; r < newHeight; r++) { - let sourceFracRow: number; - if (halfPixelCenters) { - sourceFracRow = effectiveRowSizeRatio * (r + 0.5) - 0.5; - } else { - sourceFracRow = effectiveRowSizeRatio * r; - } - - const sourceRowFloor = Math.max(0, Math.floor(sourceFracRow)); - const rowFrac = sourceFracRow - sourceRowFloor; - const sourceRowCeil = Math.min(oldHeight - 1, Math.ceil(sourceFracRow)); - const topRowOffset = - b * imagesStrides[0] + sourceRowFloor * imagesStrides[1]; - const botRowOffset = - b * imagesStrides[0] + sourceRowCeil * imagesStrides[1]; - for (let c = 0; c < newWidth; c++) { - let sourceFracCol: number; - if (halfPixelCenters) { - sourceFracCol = effectiveColSizeRatio * (c + 0.5) - 0.5; - } else { - sourceFracCol = effectiveColSizeRatio * c; - } - const sourceColFloor = Math.max(0, Math.floor(sourceFracCol)); - const colFrac = sourceFracCol - sourceColFloor; - const sourceColCeil = Math.min(oldWidth - 1, Math.ceil(sourceFracCol)); - const topLeftOffest = topRowOffset + sourceColFloor * imagesStrides[2]; - const botLeftOffset = botRowOffset + sourceColFloor * imagesStrides[2]; - const topRightOffset = topRowOffset + sourceColCeil * imagesStrides[2]; - const botRightOffest = botRowOffset + sourceColCeil * imagesStrides[2]; - for (let d = 0; d < numChannels; d++) { - // Begin shader. - - // Compute the fractional index of the source. - const topLeft = xValues[topLeftOffest + d]; - const bottomLeft = xValues[botLeftOffset + d]; - const topRight = xValues[topRightOffset + d]; - const bottomRight = xValues[botRightOffest + d]; - - const top = topLeft + (topRight - topLeft) * colFrac; - const bottom = bottomLeft + (bottomRight - bottomLeft) * colFrac; - const newValue = top + (bottom - top) * rowFrac; - - result[outputIdx++] = newValue; - } - } - } - } - - return backend.makeTensorInfo( - [batch, newHeight, newWidth, numChannels], 'float32', result); -} - -export const resizeBilinearConfig: KernelConfig = { - kernelName: ResizeBilinear, - backendName: 'cpu', - kernelFunc: resizeBilinear as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/ResizeBilinearGrad.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/ResizeBilinearGrad.ts deleted file mode 100644 index fda7c4c5c..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/ResizeBilinearGrad.ts +++ /dev/null @@ -1,116 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, ResizeBilinearGrad, ResizeBilinearGradAttrs, ResizeBilinearGradInputs, TensorInfo, TypedArray, util} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; -import {assertNotComplex} from '../cpu_util'; - -export function resizeBilinearGrad(args: { - inputs: ResizeBilinearGradInputs, - backend: MathBackendCPU, - attrs: ResizeBilinearGradAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {images, dy} = inputs; - const {alignCorners} = attrs; - - assertNotComplex([dy, images], 'resizeBilinearGrad'); - - const imagesStrides = util.computeStrides(images.shape); - - const [batch, xHeight, xWidth, depth] = images.shape; - const [, yHeight, yWidth] = dy.shape; - - const output = new Float32Array(batch * xHeight * xWidth * depth); - - // In the backwards pass, we want to find the pixels that were generated - // for each pixel in the input image the forward pass and add the - // corresponding coefficient from dy to the gradient (with some - // interpolation). - - const effectiveXSize: [number, number] = [ - (alignCorners && yHeight > 1) ? xHeight - 1 : xHeight, - (alignCorners && yWidth > 1) ? xWidth - 1 : xWidth - ]; - - const effectiveYSize: [number, number] = [ - (alignCorners && yHeight > 1) ? yHeight - 1 : yHeight, - (alignCorners && yWidth > 1) ? yWidth - 1 : yWidth - ]; - - const heightScale = effectiveXSize[0] / effectiveYSize[0]; - const widthScale = effectiveXSize[1] / effectiveYSize[1]; - - // Reference implementation - // tslint:disable-next-line:max-line-length - // https://github.com/tensorflow/tensorflow/blob/3039375c86a5bbc9610c7725dcaa95d635f87ba2/tensorflow/core/kernels/resize_bilinear_op.cc#L275 - const dyValues = backend.data.get(dy.dataId).values as TypedArray; - let offset = 0; - for (let b = 0; b < batch; b++) { - const bOffset = b * imagesStrides[0]; - for (let r = 0; r < yHeight; r++) { - const dxR = r * heightScale; - const topDxRIndex = Math.floor(dxR); - const bottomDxRIndex = Math.min(Math.ceil(dxR), xHeight - 1); - - const topDxROffset = bOffset + topDxRIndex * imagesStrides[1]; - const bottomDxROffset = bOffset + bottomDxRIndex * imagesStrides[1]; - - const dxRLerp = dxR - topDxRIndex; - const inverseDxRLerp = 1.0 - dxRLerp; - for (let c = 0; c < yWidth; c++) { - const dxC = c * widthScale; - const leftDxCIndex = Math.floor(dxC); - const rightDxCIndex = Math.min(Math.ceil(dxC), xWidth - 1); - const dxCLerp = dxC - leftDxCIndex; - const inverseDxCLerp = 1.0 - dxCLerp; - - const topLeftRCOffset = topDxROffset + leftDxCIndex * imagesStrides[2]; - const topRightRCOffset = - topDxROffset + rightDxCIndex * imagesStrides[2]; - const bottomLeftRCOffset = - bottomDxROffset + leftDxCIndex * imagesStrides[2]; - const bottomRightRCOffset = - bottomDxROffset + rightDxCIndex * imagesStrides[2]; - - const inverseDxRLerpTimesInverseDxCLerp = - inverseDxRLerp * inverseDxCLerp; - const inverseDxRLerpTimesDxCLerp = inverseDxRLerp * dxCLerp; - const dxRLerpTimesInverseDxCLerp = dxRLerp * inverseDxCLerp; - const dxRLerpTimesDxCLerp = dxRLerp * dxCLerp; - for (let d = 0; d < depth; d++) { - const dyVal = dyValues[offset++]; - output[topLeftRCOffset + d] += - dyVal * inverseDxRLerpTimesInverseDxCLerp; - output[topRightRCOffset + d] += dyVal * inverseDxRLerpTimesDxCLerp; - output[bottomLeftRCOffset + d] += dyVal * dxRLerpTimesInverseDxCLerp; - output[bottomRightRCOffset + d] += dyVal * dxRLerpTimesDxCLerp; - } - } - } - } - - return backend.makeTensorInfo( - [batch, xWidth, xHeight, depth], 'float32', output); -} - -export const resizeBilinearGradConfig: KernelConfig = { - kernelName: ResizeBilinearGrad, - backendName: 'cpu', - kernelFunc: resizeBilinearGrad as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/ResizeNearestNeighbor.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/ResizeNearestNeighbor.ts deleted file mode 100644 index b9545dea2..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/ResizeNearestNeighbor.ts +++ /dev/null @@ -1,98 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, ResizeNearestNeighbor, ResizeNearestNeighborAttrs, ResizeNearestNeighborInputs, TensorInfo, TypedArray, util} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; -import {assertNotComplex} from '../cpu_util'; - -export function resizeNearestNeighbor(args: { - inputs: ResizeNearestNeighborInputs, - backend: MathBackendCPU, - attrs: ResizeNearestNeighborAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {images} = inputs; - const {alignCorners, halfPixelCenters, size} = attrs; - - assertNotComplex(images, 'resizeNearestNeighbor'); - - const imagesStrides = util.computeStrides(images.shape); - const [newHeight, newWidth] = size; - - const [batch, oldHeight, oldWidth, numChannels] = images.shape; - const xValues = backend.data.get(images.dataId).values as TypedArray; - const output = new Float32Array(batch * newHeight * newWidth * numChannels); - - const effectiveInputSize: [number, number] = [ - (alignCorners && newHeight > 1) ? oldHeight - 1 : oldHeight, - (alignCorners && newWidth > 1) ? oldWidth - 1 : oldWidth - ]; - - const effectiveOutputSize: [number, number] = [ - (alignCorners && newHeight > 1) ? newHeight - 1 : newHeight, - (alignCorners && newWidth > 1) ? newWidth - 1 : newWidth - ]; - - const effectiveRowSizeRatio = effectiveInputSize[0] / effectiveOutputSize[0]; - const effectiveColSizeRatio = effectiveInputSize[1] / effectiveOutputSize[1]; - - let outputOffset = 0; - for (let b = 0; b < batch; b++) { - const batchOffset = b * imagesStrides[0]; - for (let r = 0; r < newHeight; r++) { - const sourceFracRow = halfPixelCenters ? - effectiveRowSizeRatio * (r + 0.5) : - effectiveRowSizeRatio * r; - let sourceNearestRow = Math.min( - oldHeight - 1, - alignCorners ? Math.round(sourceFracRow) : Math.floor(sourceFracRow)); - if (halfPixelCenters) { - sourceNearestRow = Math.max(0, sourceNearestRow); - } - const rowOffset = batchOffset + sourceNearestRow * imagesStrides[1]; - for (let c = 0; c < newWidth; c++) { - const sourceFracCol = halfPixelCenters ? - effectiveColSizeRatio * (c + 0.5) : - effectiveColSizeRatio * c; - let sourceNearestCol = Math.min( - oldWidth - 1, - alignCorners ? Math.round(sourceFracCol) : - Math.floor(sourceFracCol)); - if (halfPixelCenters) { - sourceNearestCol = Math.max(0, sourceNearestCol); - } - const colOffset = rowOffset + sourceNearestCol * imagesStrides[2]; - for (let d = 0; d < numChannels; d++) { - // Begin shader. - // Compute the fractional index of the source. - const newVal = xValues[colOffset + d]; - output[outputOffset++] = newVal; - } - } - } - } - - return backend.makeTensorInfo( - [batch, newHeight, newWidth, numChannels], images.dtype, output); -} - -export const resizeNearestNeighborConfig: KernelConfig = { - kernelName: ResizeNearestNeighbor, - backendName: 'cpu', - kernelFunc: resizeNearestNeighbor as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/ResizeNearestNeighborGrad.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/ResizeNearestNeighborGrad.ts deleted file mode 100644 index bd524ac39..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/ResizeNearestNeighborGrad.ts +++ /dev/null @@ -1,134 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, ResizeNearestNeighborGrad, ResizeNearestNeighborGradAttrs, ResizeNearestNeighborGradInputs, TensorInfo, TypedArray, util} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; -import {assertNotComplex} from '../cpu_util'; - -export function resizeNearestNeighborGrad(args: { - inputs: ResizeNearestNeighborGradInputs, - backend: MathBackendCPU, - attrs: ResizeNearestNeighborGradAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {images, dy} = inputs; - const {alignCorners} = attrs; - - assertNotComplex([dy, images], 'resizeNearestNeighborGrad'); - - const imagesStrides = util.computeStrides(images.shape); - const dyStrides = util.computeStrides(dy.shape); - const [batch, xHeight, xWidth, depth] = images.shape; - const [, yHeight, yWidth] = dy.shape; - - const output = new Float32Array(batch * xHeight * xWidth * depth); - const dyValues = backend.data.get(dy.dataId).values as TypedArray; - - // In the backwards pass, we want to find the pixels that were generated - // for each pixel in the input image the forward pass - - const effectiveXSize: [number, number] = [ - (alignCorners && yHeight > 1) ? xHeight - 1 : xHeight, - (alignCorners && yWidth > 1) ? xWidth - 1 : xWidth - ]; - - const effectiveYSize: [number, number] = [ - (alignCorners && yHeight > 1) ? yHeight - 1 : yHeight, - (alignCorners && yWidth > 1) ? yWidth - 1 : yWidth - ]; - - const heightScale = effectiveXSize[0] / effectiveYSize[0]; - const widthScale = effectiveXSize[1] / effectiveYSize[1]; - - const invHeightScale = 1 / heightScale; - const invWidthScale = 1 / widthScale; - - // This defines the size of the window of values around a particular - // index in dy that we want to search for contributions to dx. - const winHeight = (Math.ceil(invHeightScale) * 2) + 2; - const winWidth = (Math.ceil(invWidthScale) * 2) + 2; - - // Loop over the output space. - for (let b = 0; b < batch; b++) { - const batchOffset = b * imagesStrides[0]; - for (let r = 0; r < xHeight; r++) { - const rowOffset = batchOffset + r * imagesStrides[1]; - - // Compute bounds for where in dy we will look - const startRLerp = Math.floor(r * invHeightScale); - const startDyR = Math.floor(startRLerp - (winHeight / 2)); - for (let c = 0; c < xWidth; c++) { - const colOffset = rowOffset + c * imagesStrides[2]; - - // Compute bounds for where in dy we will look - const startCLerp = Math.floor(c * invWidthScale); - const startDyC = Math.floor(startCLerp - (winWidth / 2)); - - for (let d = 0; d < depth; d++) { - let accum = 0; - // loop over dy - - for (let dyRIndex = 0; dyRIndex < winHeight; dyRIndex++) { - const dyR = dyRIndex + startDyR; - // Guard against the window exceeding the bounds of dy - if (dyR < 0 || dyR >= yHeight) { - continue; - } - - const dyROffset = batchOffset + dyR * dyStrides[1]; - const sourceFracRow = dyR * heightScale; - const sourceNearestRow = Math.min( - xHeight - 1, - alignCorners ? Math.round(sourceFracRow) : - Math.floor(sourceFracRow)); - if (r !== sourceNearestRow) { - continue; - } - for (let dyCIndex = 0; dyCIndex < winWidth; dyCIndex++) { - const dyC = dyCIndex + startDyC; - // Guard against the window exceeding the bounds of dy - if (dyC < 0 || dyC >= yWidth) { - continue; - } - - const dyCOffset = dyROffset + dyC * dyStrides[2]; - const sourceFracCol = dyC * widthScale; - const sourceNearestCol = Math.min( - xWidth - 1, - alignCorners ? Math.round(sourceFracCol) : - Math.floor(sourceFracCol)); - - if (c === sourceNearestCol) { - accum += dyValues[dyCOffset + d]; - } - } - } - output[colOffset + d] = accum; - } - } - } - } - - return backend.makeTensorInfo(images.shape, images.dtype, output); -} - -export const resizeNearestNeighborGradConfig: KernelConfig = { - kernelName: ResizeNearestNeighborGrad, - backendName: 'cpu', - kernelFunc: resizeNearestNeighborGrad as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Reverse.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Reverse.ts deleted file mode 100644 index 5b3b2ea81..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Reverse.ts +++ /dev/null @@ -1,58 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, Reverse, ReverseAttrs, ReverseInputs, TensorBuffer, TensorInfo, util} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; -import {assertNotComplex} from '../cpu_util'; -import {identity} from './Identity'; - -export function reverse( - args: - {inputs: ReverseInputs, backend: MathBackendCPU, attrs: ReverseAttrs}): - TensorInfo { - const {inputs, backend, attrs} = args; - const {x} = inputs; - const {dims} = attrs; - - assertNotComplex(x, 'reverse'); - - const xRank = x.shape.length; - - const $dims = util.parseAxisParam(dims, x.shape); - if (xRank === 0) { - return identity({inputs: {x}, backend}); - } - - const outBuf = new TensorBuffer(x.shape, x.dtype); - const xBuf = backend.bufferSync(x); - - for (let i = 0; i < outBuf.size; i++) { - const outLoc = outBuf.indexToLoc(i); - const inLoc = outLoc.slice(); - $dims.forEach(d => inLoc[d] = x.shape[d] - 1 - inLoc[d]); - outBuf.set(xBuf.get(...inLoc), ...outLoc); - } - - return backend.makeTensorInfo(outBuf.shape, outBuf.dtype, outBuf.values); -} - -export const reverseConfig: KernelConfig = { - kernelName: Reverse, - backendName: 'cpu', - kernelFunc: reverse as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/RotateWithOffset.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/RotateWithOffset.ts deleted file mode 100644 index 2beffa455..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/RotateWithOffset.ts +++ /dev/null @@ -1,95 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, NumericDataType, TypedArray} from '@tensorflow/tfjs-core'; -import {backend_util, RotateWithOffset, RotateWithOffsetAttrs, RotateWithOffsetInputs, util} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; - -export const rotateWithOffsetConfig: KernelConfig = { - kernelName: RotateWithOffset, - backendName: 'cpu', - kernelFunc: ({inputs, attrs, backend}) => { - const {image} = inputs as RotateWithOffsetInputs; - const {radians, fillValue, center} = - attrs as unknown as RotateWithOffsetAttrs; - const cpuBackend = backend as MathBackendCPU; - - const output = util.getTypedArrayFromDType( - image.dtype as NumericDataType, util.sizeFromShape(image.shape)); - const [batch, imageHeight, imageWidth, numChannels] = image.shape; - - const [centerX, centerY] = - backend_util.getImageCenter(center, imageHeight, imageWidth); - const fullOpacityValue = 255; - - const sinFactor = Math.sin(radians); - const cosFactor = Math.cos(radians); - const imageVals = cpuBackend.data.get(image.dataId).values as TypedArray; - - for (let batchIdx = 0; batchIdx < batch; batchIdx++) { - const batchOffset = batchIdx * imageWidth * imageHeight * numChannels; - - for (let row = 0; row < imageHeight; row++) { - const rowOffset = row * (imageWidth * numChannels); - - for (let col = 0; col < imageWidth; col++) { - const colOffset = col * numChannels; - - for (let channel = 0; channel < numChannels; channel++) { - const coords = [batch, row, col, channel]; - - const x = coords[2]; - const y = coords[1]; - - // coordX/coordY are the result of rotating and translating x/y. - let coordX = (x - centerX) * cosFactor - (y - centerY) * sinFactor; - let coordY = (x - centerX) * sinFactor + (y - centerY) * cosFactor; - coordX = Math.round(coordX + centerX); - coordY = Math.round(coordY + centerY); - - let outputValue = fillValue; - if (typeof fillValue !== 'number') { - if (channel === 3) { - outputValue = fullOpacityValue; - } else { - outputValue = fillValue[channel]; - } - } - - // If the coordinate position falls within the image boundaries... - if (coordX >= 0 && coordX < imageWidth && coordY >= 0 && - coordY < imageHeight) { - // set the output to the image value at the coordinate position. - const rotatedRowOffset = coordY * (imageWidth * numChannels); - const rotatedColOffset = coordX * numChannels; - const imageIdx = - batchOffset + rotatedRowOffset + rotatedColOffset + channel; - outputValue = imageVals[imageIdx]; - } - - const outIdx = batchOffset + rowOffset + colOffset + channel; - output[outIdx] = outputValue as number; - } - } - } - } - - const dataId = cpuBackend.write(output, image.shape, image.dtype); - return {dataId, shape: image.shape, dtype: image.dtype}; - } -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Round.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Round.ts deleted file mode 100644 index 7fc9d3a02..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Round.ts +++ /dev/null @@ -1,42 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, Round} from '@tensorflow/tfjs-core'; - -import {unaryKernelFunc} from '../utils/unary_utils'; - -export const round = unaryKernelFunc(Round, (xi) => { - // The algorithm is based on banker's rounding. - const base = Math.floor(xi); - if (xi - base < 0.5) { - return Math.floor(xi); - } else if (xi - base > 0.5) { - return Math.ceil(xi); - } else { - if (base % 2.0 === 0.0) { - return base; - } else { - return base + 1.0; - } - } -}); - -export const roundConfig: KernelConfig = { - kernelName: Round, - backendName: 'cpu', - kernelFunc: round, -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Rsqrt.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Rsqrt.ts deleted file mode 100644 index 5aa0ba6f9..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Rsqrt.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, Rsqrt} from '@tensorflow/tfjs-core'; - -import {createSimpleUnaryImpl} from '../utils/unary_impl'; -import {unaryKernelFuncFromImpl} from '../utils/unary_utils'; - -export const rsqrtImpl = createSimpleUnaryImpl((xi) => 1 / Math.sqrt(xi)); -export const rsqrt = unaryKernelFuncFromImpl(Rsqrt, rsqrtImpl); - -export const rsqrtConfig: KernelConfig = { - kernelName: Rsqrt, - backendName: 'cpu', - kernelFunc: rsqrt, -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/STFT_test.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/STFT_test.ts deleted file mode 100644 index dc79027b6..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/STFT_test.ts +++ /dev/null @@ -1,44 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '@tensorflow/tfjs-core'; -// tslint:disable-next-line: no-imports-from-dist -import {ALL_ENVS, describeWithFlags} from '@tensorflow/tfjs-core/dist/jasmine_util'; - -describeWithFlags('stft memory test', ALL_ENVS, () => { - it('should have no mem leak', async () => { - const win = 320; - const fft = 320; - const hop = 160; - const input = tf.zeros([1760]); - - const startTensors = tf.memory().numTensors; - const startDataIds = tf.engine().backend.numDataIds(); - const result = await tf.signal.stft(input, win, hop, fft); - - // 1 new tensor, 3 new data buckets. - expect(tf.memory().numTensors).toBe(startTensors + 1); - expect(tf.engine().backend.numDataIds()).toBe(startTensors + 3); - - result.dispose(); - - // Zero net tensors / data buckets. - expect(tf.memory().numTensors).toBe(startTensors); - expect(tf.engine().backend.numDataIds()).toBe(startDataIds); - input.dispose(); - }); -}); diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/ScatterNd.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/ScatterNd.ts deleted file mode 100644 index 43d049833..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/ScatterNd.ts +++ /dev/null @@ -1,50 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, KernelConfig, KernelFunc, Rank, ScatterNd, ScatterNdAttrs, ScatterNdInputs, TensorInfo} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; -import {scatterImpl} from './Scatter_impl'; - -export function scatterNd(args: { - inputs: ScatterNdInputs, - backend: MathBackendCPU, - attrs: ScatterNdAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {indices, updates} = inputs; - const {shape} = attrs; - - const {sliceRank, numUpdates, sliceSize, strides, outputSize} = - backend_util.calculateShapes(updates, indices, shape); - const sumDupeIndices = true; - - const indicesBuf = backend.bufferSync(indices); - const updatesBuf = backend.bufferSync(updates); - - const outBuf = scatterImpl( - indicesBuf, updatesBuf, shape, outputSize, sliceSize, numUpdates, - sliceRank, strides, 0 /* defaultValue */, sumDupeIndices); - - return backend.makeTensorInfo(shape, outBuf.dtype, outBuf.values); -} - -export const scatterNdConfig: KernelConfig = { - kernelName: ScatterNd, - backendName: 'cpu', - kernelFunc: scatterNd as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Scatter_impl.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Scatter_impl.ts deleted file mode 100644 index 77a4d444f..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Scatter_impl.ts +++ /dev/null @@ -1,79 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {buffer, Rank, ShapeMap, TensorBuffer, TypedArray} from '@tensorflow/tfjs-core'; - -interface DefaultValueTypeMap { - bool: boolean; - int32: number; - float32: number; - string: string; -} - -export function -scatterImpl( - indices: TensorBuffer, updates: TensorBuffer, - shape: number[], outputSize: number, sliceSize: number, numUpdates: number, - sliceRank: number, strides: number[], - defaultValue: TensorBuffer|DefaultValueTypeMap[D], - sumDupeIndices: boolean): TensorBuffer { - const flattenShape = [outputSize / sliceSize, sliceSize]; - - const indicesData = indices.values as TypedArray; - const updatesData = updates.values; - - if (outputSize === 0) { - return buffer(shape as ShapeMap[R], updates.dtype); - } - - const outBuf = (defaultValue instanceof TensorBuffer) ? - defaultValue : - buffer(flattenShape, updates.dtype); - if (typeof defaultValue === 'string') { - (outBuf.values as string[]).fill(defaultValue); - } else if (typeof defaultValue === 'number') { - (outBuf.values as TypedArray).fill(defaultValue); - } else if (typeof defaultValue === 'boolean') { - (outBuf.values as TypedArray).fill(+defaultValue); - } - - for (let i = 0; i < numUpdates; i++) { - const index = []; - let flattenIndex = 0; - for (let j = 0; j < sliceRank; j++) { - const dim = indicesData[i * sliceRank + j]; - index.push(dim); - flattenIndex += dim * strides[j]; - } - - if (flattenIndex < 0 || flattenIndex >= outputSize / sliceSize) { - throw new Error(`Invalid indices: ${index} does not index into ${shape}`); - } - - for (let k = 0; k < sliceSize; k++) { - if (sumDupeIndices) { - (outBuf.values as TypedArray)[flattenIndex * sliceSize + k] += - (updatesData as TypedArray)[i * sliceSize + k]; - } else { - outBuf.values[flattenIndex * sliceSize + k] = updates.rank === 0 ? - updatesData[0] : - updatesData[i * sliceSize + k]; - } - } - } - - return outBuf as TensorBuffer; -} diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/SearchSorted.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/SearchSorted.ts deleted file mode 100644 index 34b466176..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/SearchSorted.ts +++ /dev/null @@ -1,47 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, SearchSorted, SearchSortedAttrs, SearchSortedInputs, TensorInfo, TypedArray} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; - -import {searchSortedImpl} from './SearchSorted_impl'; - -export function searchSorted(args: { - inputs: SearchSortedInputs, - backend: MathBackendCPU, - attrs: SearchSortedAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {sortedSequence, values} = inputs; - const {side} = attrs; - - const $sortedSequence = - backend.data.get(sortedSequence.dataId).values as TypedArray; - const $values = backend.data.get(values.dataId).values as TypedArray; - - const output = searchSortedImpl( - $sortedSequence, $values, sortedSequence.shape[0], - sortedSequence.shape[1], values.shape[1], side); - return backend.makeTensorInfo(values.shape, 'int32', output); -} - -export const searchSortedConfig: KernelConfig = { - kernelName: SearchSorted, - backendName: 'cpu', - kernelFunc: searchSorted as unknown as KernelFunc, -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/SearchSorted_impl.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/SearchSorted_impl.ts deleted file mode 100644 index 09a5d105d..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/SearchSorted_impl.ts +++ /dev/null @@ -1,66 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {TypedArray, util} from '@tensorflow/tfjs-core'; - -function lowerBound(array: TypedArray, value: number) { - let left = 0; - let right = array.length; - let mid = 0; - while (left < right) { - mid = Math.floor((left + right) / 2); - if (array[mid] < value) { - left = mid + 1; - } else { - right = mid; - } - } - return right; -} - -function upperBound(array: TypedArray, value: number) { - let left = 0; - let right = array.length; - let mid = 0; - while (left < right) { - mid = Math.floor((left + right) / 2); - if (array[mid] <= value) { - left = mid + 1; - } else { - right = mid; - } - } - return right; -} - -export function searchSortedImpl( - sortedInputs: TypedArray, values: TypedArray, batchSize: number, - numInputs: number, numValues: number, side: 'left'|'right'): TypedArray { - const output = - util.getArrayFromDType('int32', batchSize * numValues) as TypedArray; - for (let b = 0; b < batchSize; ++b) { - const sortedInputsSlice = - sortedInputs.slice(b * numInputs, (b + 1) * numInputs); - const outputOffset = b * numValues; - for (let i = 0; i < numValues; ++i) { - output[outputOffset + i] = side === 'left' ? - lowerBound(sortedInputsSlice, values[i + outputOffset]) : - upperBound(sortedInputsSlice, values[i + outputOffset]); - } - } - return output; -} diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Select.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Select.ts deleted file mode 100644 index e11ae9627..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Select.ts +++ /dev/null @@ -1,61 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, Select, SelectInputs, TensorInfo, TypedArray, upcastType, util} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; -import {assertNotComplex} from '../cpu_util'; - -export function select(args: {inputs: SelectInputs, backend: MathBackendCPU}): - TensorInfo { - const {inputs, backend} = args; - const {condition, t, e} = inputs; - - assertNotComplex([condition, t, e], 'select'); - const conditionRank = condition.shape.length; - - const values = backend.data.get(condition.dataId).values as TypedArray; - const tValues = backend.data.get(t.dataId).values as TypedArray; - const eValues = backend.data.get(e.dataId).values as TypedArray; - const resultDtype = upcastType(t.dtype, e.dtype); - const newValues = - util.makeZerosTypedArray(util.sizeFromShape(t.shape), resultDtype); - - let index = 0; - const offset = - conditionRank === 0 || conditionRank > 1 || t.shape.length === 1 ? - 1 : - util.sizeFromShape(t.shape.slice(1)); - - for (let i = 0; i < values.length; i++) { - for (let j = 0; j < offset; j++) { - if (values[i] === 1) { - newValues[index++] = tValues[i]; - } else { - newValues[index++] = eValues[i]; - } - } - } - - return backend.makeTensorInfo(t.shape, resultDtype, newValues); -} - -export const selectConfig: KernelConfig = { - kernelName: Select, - backendName: 'cpu', - kernelFunc: select as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Selu.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Selu.ts deleted file mode 100644 index e2d6bb28e..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Selu.ts +++ /dev/null @@ -1,37 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, KernelConfig, Selu} from '@tensorflow/tfjs-core'; - -import {unaryKernelFunc} from '../utils/unary_utils'; - -const scaleAlpha = backend_util.SELU_SCALEALPHA; -const scale = backend_util.SELU_SCALE; - -export const selu = unaryKernelFunc(Selu, (xi) => { - if (xi >= 0) { - return scale * xi; - } else { - return scaleAlpha * (Math.exp(xi) - 1); - } -}); - -export const seluConfig: KernelConfig = { - kernelName: Selu, - backendName: 'cpu', - kernelFunc: selu, -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Sigmoid.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Sigmoid.ts deleted file mode 100644 index 86aac6e3f..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Sigmoid.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, Sigmoid} from '@tensorflow/tfjs-core'; - -import {createSimpleUnaryImpl} from '../utils/unary_impl'; -import {unaryKernelFunc} from '../utils/unary_utils'; - -export const sigmoidImpl = - createSimpleUnaryImpl((xi) => 1 / (1 + Math.exp(-xi))); -export const sigmoid = - unaryKernelFunc(Sigmoid, (xi) => 1 / (1 + Math.exp(-xi))); - -export const sigmoidConfig: KernelConfig = { - kernelName: Sigmoid, - backendName: 'cpu', - kernelFunc: sigmoid, -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Sign.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Sign.ts deleted file mode 100644 index 6baa70cb3..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Sign.ts +++ /dev/null @@ -1,36 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, Sign} from '@tensorflow/tfjs-core'; - -import {unaryKernelFunc} from '../utils/unary_utils'; - -export const sign = unaryKernelFunc(Sign, (xi) => { - if (xi < 0) { - return -1; - } else if (xi > 0) { - return 1; - } else { - return 0; - } -}); - -export const signConfig: KernelConfig = { - kernelName: Sign, - backendName: 'cpu', - kernelFunc: sign, -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Sin.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Sin.ts deleted file mode 100644 index bd900bb9f..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Sin.ts +++ /dev/null @@ -1,28 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, Sin} from '@tensorflow/tfjs-core'; - -import {unaryKernelFunc} from '../utils/unary_utils'; - -export const sin = unaryKernelFunc(Sin, (xi) => Math.sin(xi)); - -export const sinConfig: KernelConfig = { - kernelName: Sin, - backendName: 'cpu', - kernelFunc: sin, -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Sinh.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Sinh.ts deleted file mode 100644 index 60518d8df..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Sinh.ts +++ /dev/null @@ -1,28 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, Sinh} from '@tensorflow/tfjs-core'; - -import {unaryKernelFunc} from '../utils/unary_utils'; - -export const sinh = unaryKernelFunc(Sinh, (xi) => Math.sinh(xi)); - -export const sinhConfig: KernelConfig = { - kernelName: Sinh, - backendName: 'cpu', - kernelFunc: sinh, -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Slice.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Slice.ts deleted file mode 100644 index ccfff5e3f..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Slice.ts +++ /dev/null @@ -1,79 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, BackendValues, buffer, DataType, KernelConfig, KernelFunc, Slice, slice_util, SliceAttrs, SliceInputs, TensorInfo, TypedArray, util} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; -import {assertNotComplex} from '../cpu_util'; - -export function sliceImpl( - vals: BackendValues, begin: number[], size: number[], shape: number[], - dtype: DataType): BackendValues { - const isContinous = slice_util.isSliceContinous(shape, begin, size); - const length = util.sizeFromShape(size); - const xStrides = util.computeStrides(shape); - - if (isContinous) { - const flatOffset = slice_util.computeFlatOffset(begin, xStrides); - - if (dtype === 'string') { - return (vals as Uint8Array[]).slice(flatOffset, flatOffset + length); - } - - return (vals as TypedArray).subarray(flatOffset, flatOffset + length); - } - - const decodedData = dtype === 'string' ? - backend_util.fromUint8ToStringArray(vals as Uint8Array[]) : - vals as TypedArray; - - const inBuf = buffer(shape, dtype, decodedData); - const outBuf = buffer(size, dtype); - for (let i = 0; i < outBuf.size; ++i) { - const outLoc = outBuf.indexToLoc(i); - const inLoc = outLoc.map((idx: number, j) => idx + begin[j]); - outBuf.set(inBuf.get(...inLoc), ...outLoc); - } - - if (dtype === 'string') { - return backend_util.fromStringArrayToUint8(outBuf.values as string[]); - } - return outBuf.values as TypedArray; -} - -export function slice( - args: {inputs: SliceInputs, backend: MathBackendCPU, attrs: SliceAttrs}): - TensorInfo { - const {inputs, backend, attrs} = args; - const {x} = inputs; - const {begin, size} = attrs; - - assertNotComplex(x, 'slice'); - - const [$begin, $size] = slice_util.parseSliceParams(x, begin, size); - slice_util.assertParamsValid(x, $begin, $size); - - const vals = backend.data.get(x.dataId).values; - const outVals = sliceImpl(vals, $begin, $size, x.shape, x.dtype); - return backend.makeTensorInfo($size, x.dtype, outVals); -} - -export const sliceConfig: KernelConfig = { - kernelName: Slice, - backendName: 'cpu', - kernelFunc: slice as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Softmax.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Softmax.ts deleted file mode 100644 index 2c77c2431..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Softmax.ts +++ /dev/null @@ -1,83 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, KernelConfig, KernelFunc, Softmax, SoftmaxAttrs, SoftmaxInputs, TensorInfo, util} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; - -import {exp} from './Exp'; -import {max} from './Max'; -import {div} from './RealDiv'; -import {reshape} from './Reshape'; -import {sub} from './Sub'; -import {sum} from './Sum'; - -export function softmax( - args: - {inputs: SoftmaxInputs, backend: MathBackendCPU, attrs: SoftmaxAttrs}): - TensorInfo { - const {inputs, backend, attrs} = args; - const {logits} = inputs; - const {dim} = attrs; - - const logitsRank = logits.shape.length; - - let $dim = dim; - if ($dim === -1) { - $dim = logitsRank - 1; - } - if ($dim !== logitsRank - 1) { - throw Error( - 'Softmax along a non-last dimension is not yet supported. ' + - `Logits was rank ${logitsRank} and dim was ${$dim}`); - } - - const axes = util.parseAxisParam([$dim], logits.shape); - const maxLogit = max({ - inputs: {x: logits}, - backend, - attrs: {reductionIndices: axes, keepDims: false} - }); - const expandedShape = backend_util.expandShapeToKeepDim(maxLogit.shape, axes); - - const maxLogitReshaped = - reshape({inputs: {x: maxLogit}, backend, attrs: {shape: expandedShape}}); - const a = - sub({inputs: {a: logits, b: maxLogitReshaped}, backend}) as TensorInfo; - const b = exp({inputs: {x: a}, backend}) as TensorInfo; - const sumExp = - sum({inputs: {x: b}, backend, attrs: {axis: axes, keepDims: false}}); - const sumReshaped = - reshape({inputs: {x: sumExp}, backend, attrs: {shape: expandedShape}}); - - const result = div({inputs: {a: b, b: sumReshaped}, backend}) as TensorInfo; - - backend.disposeIntermediateTensorInfo(maxLogit); - backend.disposeIntermediateTensorInfo(maxLogitReshaped); - backend.disposeIntermediateTensorInfo(a); - backend.disposeIntermediateTensorInfo(b); - backend.disposeIntermediateTensorInfo(sumExp); - backend.disposeIntermediateTensorInfo(sumReshaped); - - return result; -} - -export const softmaxConfig: KernelConfig = { - kernelName: Softmax, - backendName: 'cpu', - kernelFunc: softmax as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Softplus.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Softplus.ts deleted file mode 100644 index 53466048b..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Softplus.ts +++ /dev/null @@ -1,56 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, Softplus} from '@tensorflow/tfjs-core'; - -import {unaryKernelFunc} from '../utils/unary_utils'; - -// mirrors the implementation of tf.nn.softplus: https://goo.gl/vkcvwX - -// epsilon is the difference between 1.0 and the next representable float. -// For a single precision 32 bit float this should be 2^-23, see: -// https://math.byu.edu/~schow/work/IEEEFloatingPoint.htm -const epsilon = 1.1920928955078125e-7; -const threshold = Math.log(epsilon) + 2.0; - -export const softplus = unaryKernelFunc(Softplus, (xi) => { - // Value above which exp(x) may overflow, but softplus(x) == x - // is within machine epsilon. - const tooLarge = xi > -threshold; - - // Value below which exp(x) may underflow, but softplus(x) == exp(x) - // is within machine epsilon. - const tooSmall = xi < threshold; - - const expX = Math.exp(xi); - let result; - - if (tooSmall) { - result = expX; - } else if (tooLarge) { - result = xi; - } else { - result = Math.log(1.0 + expX); - } - return result; -}); - -export const softplusConfig: KernelConfig = { - kernelName: Softplus, - backendName: 'cpu', - kernelFunc: softplus, -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/SpaceToBatchND.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/SpaceToBatchND.ts deleted file mode 100644 index 20120956e..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/SpaceToBatchND.ts +++ /dev/null @@ -1,89 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, KernelConfig, KernelFunc, ReshapeAttrs, ReshapeInputs, SpaceToBatchND, SpaceToBatchNDAttrs, SpaceToBatchNDInputs, TensorInfo, TransposeAttrs, TransposeInputs, util} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; -import {assertNotComplex} from '../cpu_util'; - -import {padV2Config} from './PadV2'; -import {reshape} from './Reshape'; -import {transpose} from './Transpose'; - -export function spaceToBatchND(args: { - inputs: SpaceToBatchNDInputs, - backend: MathBackendCPU, - attrs: SpaceToBatchNDAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {x} = inputs; - const {blockShape, paddings} = attrs; - - assertNotComplex([x], 'spaceToBatchND'); - - const prod = util.sizeFromShape(blockShape); - - const completePaddings: Array<[number, number]> = [[0, 0]]; - completePaddings.push(...(paddings as Array<[number, number]>)); - - for (let i = 1 + blockShape.length; i < x.shape.length; ++i) { - completePaddings.push([0, 0]); - } - - const paddedX = padV2Config.kernelFunc({ - inputs: {x}, - backend, - attrs: {paddings: completePaddings, constantValue: 0} - }) as TensorInfo; - - const reshapedPaddedShape = - backend_util.getReshaped(paddedX.shape, blockShape, prod, false); - - const permutedReshapedPaddedPermutation = backend_util.getPermuted( - reshapedPaddedShape.length, blockShape.length, false); - - const flattenShape = - backend_util.getReshapedPermuted(paddedX.shape, blockShape, prod, false); - - const reshapeInputs: ReshapeInputs = {x: paddedX}; - const reshapeAttrs: ReshapeAttrs = {shape: reshapedPaddedShape}; - const paddedXReshaped = - reshape({inputs: reshapeInputs, backend, attrs: reshapeAttrs}); - - const transposeInputs: TransposeInputs = {x: paddedXReshaped}; - const transposeAttrs: - TransposeAttrs = {perm: permutedReshapedPaddedPermutation}; - const paddedXT = - transpose({inputs: transposeInputs, backend, attrs: transposeAttrs}); - - const resultReshapeInputs: ReshapeInputs = {x: paddedXT}; - const resultReshapeAttrs: ReshapeAttrs = {shape: flattenShape}; - const result = reshape( - {inputs: resultReshapeInputs, backend, attrs: resultReshapeAttrs}); - - backend.disposeIntermediateTensorInfo(paddedX); - backend.disposeIntermediateTensorInfo(paddedXReshaped); - backend.disposeIntermediateTensorInfo(paddedXT); - - return result; -} - -export const spaceToBatchNDConfig: KernelConfig = { - kernelName: SpaceToBatchND, - backendName: 'cpu', - kernelFunc: spaceToBatchND as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/SparseFillEmptyRows.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/SparseFillEmptyRows.ts deleted file mode 100644 index e1683752f..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/SparseFillEmptyRows.ts +++ /dev/null @@ -1,76 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, SparseFillEmptyRows, SparseFillEmptyRowsInputs, TensorInfo, TypedArray} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; - -import {sparseFillEmptyRowsImpl} from './SparseFillEmptyRows_impl'; - -export function sparseFillEmptyRows(args: { - inputs: SparseFillEmptyRowsInputs, - backend: MathBackendCPU -}): [TensorInfo, TensorInfo, TensorInfo, TensorInfo] { - const {inputs, backend} = args; - const {indices, values, denseShape, defaultValue} = inputs; - if (denseShape.shape.length !== 1) { - throw new Error(`Dense shape must be a vector, saw: - ${denseShape.shape}`); - } - if (indices.shape.length !== 2) { - throw new Error(`Indices must be a matrix, saw: - ${indices.shape}`); - } - if (values.shape.length !== 1) { - throw new Error(`Values must be a vector, saw: - ${values.shape}`); - } - if (defaultValue.shape.length !== 0) { - throw new Error(`Default value must be a scalar, saw: - ${defaultValue.shape}`); - } - - const $indices = backend.data.get(indices.dataId).values as TypedArray; - const $values = backend.data.get(values.dataId).values as TypedArray; - const $denseShape = backend.data.get(denseShape.dataId).values as TypedArray; - const $defaultValue = - backend.data.get(defaultValue.dataId).values[0] as number; - - const [outputIndices, outputIndicesShape, outputValues, - emptyRowIndicator, reverseIndexMap] = - sparseFillEmptyRowsImpl( - $indices, indices.shape, indices.dtype, $values, values.dtype, - $denseShape, $defaultValue); - return [ - backend.makeTensorInfo(outputIndicesShape, indices.dtype, outputIndices), - backend.makeTensorInfo( - [outputIndicesShape[0]], values.dtype, outputValues), - backend.makeTensorInfo( - [emptyRowIndicator.length], 'bool', - new Uint8Array( - emptyRowIndicator.map((value: boolean) => Number(value)))), - backend.makeTensorInfo( - [reverseIndexMap.length], indices.dtype, - new Int32Array(reverseIndexMap)), - ]; -} - -export const sparseFillEmptyRowsConfig: KernelConfig = { - kernelName: SparseFillEmptyRows, - backendName: 'cpu', - kernelFunc: sparseFillEmptyRows as unknown as KernelFunc, -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/SparseFillEmptyRows_impl.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/SparseFillEmptyRows_impl.ts deleted file mode 100644 index 4ffb0584f..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/SparseFillEmptyRows_impl.ts +++ /dev/null @@ -1,141 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, DataType, TypedArray, util} from '@tensorflow/tfjs-core'; - -export function sparseFillEmptyRowsImpl( - indices: TypedArray, indicesShape: number[], indicesDType: DataType, - values: TypedArray, valuesDType: DataType, denseShape: TypedArray, - defaultValue: number): - [TypedArray, number[], TypedArray, boolean[], number[]] { - const indicesCount = indicesShape[0]; - const denseRows = denseShape[0]; - - const emptyRowIndicator: boolean[] = new Array(denseRows); - const reverseIndexMap: number[] = new Array(indicesCount); - - const rank = indicesShape[1]; - - if (denseRows === 0) { - if (indicesCount !== 0) { - throw new Error( - backend_util.getSparseFillEmptyRowsIndicesDenseShapeMismatch( - indicesCount)); - } - const outputIndices = util.getArrayFromDType(indicesDType, 0) as TypedArray; - const outputValues = util.getArrayFromDType(valuesDType, 0) as TypedArray; - return [ - outputIndices, [0, rank], outputValues, emptyRowIndicator, reverseIndexMap - ]; - } - - let rowsAreOrdered = true; - let lastIndicesRow = 0; - const csrOffset: number[] = new Array(denseRows).fill(0); - - for (let i = 0; i < indicesCount; ++i) { - // indices is a 2d tensor with shape of [N, rank] - const row = indices[i * rank]; - if (row < 0) { - throw new Error( - backend_util.getSparseFillEmptyRowsNegativeIndexErrorMessage(i, row)); - } - if (row >= denseRows) { - throw new Error( - backend_util.getSparseFillEmptyRowsOutOfRangeIndexErrorMessage( - i, row, denseRows)); - } - ++csrOffset[row]; - rowsAreOrdered = rowsAreOrdered && (row >= lastIndicesRow); - lastIndicesRow = row; - } - - let allRowsFull = true; - for (let row = 0; row < denseRows; ++row) { - // csrOffset here describes the number of elements in this dense row - const rowEmpty = (csrOffset[row] === 0); - emptyRowIndicator[row] = rowEmpty; - allRowsFull = allRowsFull && !rowEmpty; - // In filled version, each row has at least one element. - csrOffset[row] = Math.max(csrOffset[row], 1); - // Update csrOffset to represent the number of elements up to and - // including denseRows + 1: - // csrOffset[0] == #{elements of row 0} - // csrOffset[1] == #{elements of row 1} + #{elements of row 0} - // .. - // csrOffset[i] == starting index for elements in row i + 1. - if (row > 0) { - csrOffset[row] += csrOffset[row - 1]; - } - } - - if (allRowsFull && rowsAreOrdered) { - const outputIndices: TypedArray = indices; - const outputValues: TypedArray = values; - for (let i = 0; i < indicesCount; ++i) { - reverseIndexMap[i] = i; - } - return [ - outputIndices, [indicesCount, rank], outputValues, emptyRowIndicator, - reverseIndexMap - ]; - } else { - const fullIndicesCount = csrOffset[denseRows - 1]; - const outputIndices = - util.getArrayFromDType(indicesDType, fullIndicesCount * rank) as - TypedArray; - const outputValues = - util.getArrayFromDType(valuesDType, fullIndicesCount) as TypedArray; - const filledCount: number[] = new Array(denseRows).fill(0); - - // Fill in values for rows that are not missing - for (let i = 0; i < indicesCount; ++i) { - // indices is a 2d tensor with shape of [N, rank] - const row = indices[i * rank]; - const offset = filledCount[row]; - const outputI = ((row === 0) ? 0 : csrOffset[row - 1]) + offset; - filledCount[row]++; // Increment the filled count for this row. - for (let j = 0; j < rank; ++j) { - // indices and outputIndices are 2d tensors with shape of [N, rank] - outputIndices[outputI * rank + j] = indices[i * rank + j]; - } - outputValues[outputI] = values[i]; - // We'll need this reverse index map to backprop correctly. - reverseIndexMap[i] = outputI; - } - - // Fill in values for rows that are missing - for (let row = 0; row < denseRows; ++row) { - const rowCount = filledCount[row]; - if (rowCount === 0) { // We haven't filled this row - const startingIndex = (row === 0) ? 0 : csrOffset[row - 1]; - // Remaining index values were set to zero already. - // Just need to set the row index in the right location. - // outputIndices is a 2d tensor with shape of [N, rank] - outputIndices[startingIndex * rank + 0] = row; - for (let col = 1; col < rank; ++col) { - outputIndices[startingIndex * rank + col] = 0; - } - outputValues[startingIndex] = defaultValue; - } - } - return [ - outputIndices, [fullIndicesCount, rank], outputValues, emptyRowIndicator, - reverseIndexMap - ]; - } -} diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/SparseReshape.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/SparseReshape.ts deleted file mode 100644 index 107710196..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/SparseReshape.ts +++ /dev/null @@ -1,64 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, SparseReshape, SparseReshapeInputs, TensorInfo, TypedArray} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; - -import {sparseReshapeImpl} from './SparseReshape_impl'; - -export function sparseReshape( - args: {inputs: SparseReshapeInputs, backend: MathBackendCPU}): - [TensorInfo, TensorInfo] { - const {inputs, backend} = args; - const {inputIndices, inputShape, newShape} = inputs; - if (inputIndices.shape.length !== 2) { - throw new Error(`Input indices should be a matrix but received shape - ${inputIndices.shape}`); - } - if (inputShape.shape.length !== 1) { - throw new Error(`Input shape should be a vector but received shape - ${inputShape.shape}`); - } - - if (newShape.shape.length !== 1) { - throw new Error( - `Target shape should be a vector but received shape ${newShape.shape}`); - } - - const $inputShape = - Array.from(backend.data.get(inputShape.dataId).values as TypedArray); - const $inputIndices = - backend.data.get(inputIndices.dataId).values as TypedArray; - const targetShape = - Array.from(backend.data.get(newShape.dataId).values as TypedArray); - - const [newIndices, indicesShape, outputShape] = sparseReshapeImpl( - $inputIndices, inputIndices.shape, inputIndices.dtype, $inputShape, - targetShape); - return [ - backend.makeTensorInfo(indicesShape, inputIndices.dtype, newIndices), - backend.makeTensorInfo( - [outputShape.length], newShape.dtype, new Int32Array(outputShape)), - ]; -} - -export const sparseReshapeConfig: KernelConfig = { - kernelName: SparseReshape, - backendName: 'cpu', - kernelFunc: sparseReshape, -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/SparseReshape_impl.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/SparseReshape_impl.ts deleted file mode 100644 index c8d3d8e9b..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/SparseReshape_impl.ts +++ /dev/null @@ -1,107 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, DataType, TypedArray, util} from '@tensorflow/tfjs-core'; - -export function sparseReshapeImpl( - inputIndices: TypedArray, inputIndicesShape: number[], inputDType: DataType, - inputShape: number[], - targetShape: number[]): [TypedArray, number[], number[]] { - const denseSize = util.sizeFromShape(inputShape); - const nnz = inputIndicesShape[0]; - const outputRank = targetShape.length; - - // Compute the output shape. Determine product of specified dimensions, and - // find the index of the unspecified one. - const outputShape: number[] = []; - let product = 1; - let unknownIndex = -1; - for (let d = 0; d < outputRank; ++d) { - const size = targetShape[d]; - if (size === -1) { - if (unknownIndex !== -1) { - throw new Error( - backend_util - .getSparseReshapeMultipleNegativeOneOutputDimErrorMessage( - unknownIndex, d)); - } - unknownIndex = d; - outputShape.push(1); - } else { - if (size < 0) { - throw new Error( - backend_util.getSparseReshapeNegativeOutputDimErrorMessage( - d, size)); - } - product *= size; - outputShape.push(size); - } - } - if (unknownIndex !== -1) { - if (product <= 0) { - throw new Error( - backend_util.getSparseReshapeEmptyTensorZeroOutputDimErrorMessage()); - } - const missing = Math.trunc(denseSize / product); - if (product * missing !== denseSize) { - throw new Error( - backend_util.getSparseReshapeInputOutputMultipleErrorMessage( - inputShape, outputShape)); - } - - outputShape[unknownIndex] = missing; - } - const outputSize = util.sizeFromShape(outputShape); - if (outputSize !== denseSize) { - throw new Error( - backend_util.getSparseReshapeInputOutputMismatchErrorMessage( - inputShape, outputShape)); - } - - const inputRank = inputShape.length; - const inputStrides: number[] = []; - if (inputRank > 0) { - inputStrides[inputRank - 1] = 1; - for (let d = inputRank - 2; d >= 0; --d) { - inputStrides[d] = inputStrides[d + 1] * inputShape[d + 1]; - } - } - - const outputStrides: number[] = []; - if (outputRank > 0) { - outputStrides[outputRank - 1] = 1; - for (let d = outputRank - 2; d >= 0; --d) { - outputStrides[d] = outputStrides[d + 1] * outputShape[d + 1]; - } - } - - const newIndices = - util.getArrayFromDType(inputDType, nnz * outputRank) as TypedArray; - for (let i = 0; i < nnz; ++i) { - let id = 0; - for (let j = 0; j < inputRank; ++j) { - // inputIndices is a 2d tensor with shape of [nnz, inputRank] - id += inputIndices[i * inputRank + j] * inputStrides[j]; - } - for (let j = 0; j < outputRank; ++j) { - // newIndices is a 2d tensor with shape of [nnz, outputRank] - newIndices[i * outputRank + j] = Math.trunc(id / outputStrides[j]); - id %= outputStrides[j]; - } - } - return [newIndices, [nnz, outputRank], outputShape]; -} diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/SparseSegmentMean.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/SparseSegmentMean.ts deleted file mode 100644 index 0c87e0929..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/SparseSegmentMean.ts +++ /dev/null @@ -1,58 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, SparseSegmentMean, SparseSegmentMeanInputs, TensorInfo, TypedArray} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; - -import {sparseSegmentReductionImpl} from './SparseSegmentReduction_impl'; - -export function sparseSegmentMean( - args: {inputs: SparseSegmentMeanInputs, backend: MathBackendCPU}): - TensorInfo { - const {inputs, backend} = args; - const {data, indices, segmentIds} = inputs; - if (data.shape.length < 1) { - throw new Error( - `Data should be at least 1 dimensional but received scalar`); - } - if (indices.shape.length !== 1) { - throw new Error(`Indices should be a vector but received shape - ${indices.shape}`); - } - if (segmentIds.shape.length !== 1) { - throw new Error(`Segment ids should be a vector but received shape - ${segmentIds.shape}`); - } - if (indices.shape[0] !== segmentIds.shape[0]) { - throw new Error(`segmentIds and indices should have same size.`); - } - - const $data = backend.data.get(data.dataId).values as TypedArray; - const $indices = backend.data.get(indices.dataId).values as TypedArray; - const $segmentIds = backend.data.get(segmentIds.dataId).values as TypedArray; - - const [outputData, outputDataShape] = sparseSegmentReductionImpl( - $data, data.shape, data.dtype, $indices, $segmentIds, true); - return backend.makeTensorInfo(outputDataShape, data.dtype, outputData); -} - -export const sparseSegmentMeanConfig: KernelConfig = { - kernelName: SparseSegmentMean, - backendName: 'cpu', - kernelFunc: sparseSegmentMean, -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/SparseSegmentReduction_impl.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/SparseSegmentReduction_impl.ts deleted file mode 100644 index 089689d72..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/SparseSegmentReduction_impl.ts +++ /dev/null @@ -1,128 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, DataType, TypedArray, util} from '@tensorflow/tfjs-core'; - -export function sparseSegmentReductionImpl( - input: TypedArray, inputShape: number[], inputDType: DataType, - indices: TypedArray, segmentIds: TypedArray, isMean = false, - defaultValue = 0): [TypedArray, number[]] { - const numIndices = indices.length; - - // Flatten the array to two dimensions - const inputFlat: number[] = [inputShape[0], input.length / inputShape[0]]; - const numCol = inputFlat[1]; - // Note that the current implementation assumes that segmentIds values are - // sorted. - const lastSegmentIdPlusOne = - numIndices > 0 ? segmentIds[numIndices - 1] + 1 : 0; - const outputRows = lastSegmentIdPlusOne; - - if (outputRows < 0) { - throw new Error( - backend_util.getSparseSegmentReductionNegativeSegmentIdsErrorMessage()); - } - - const outputShape = inputShape.slice(); - outputShape[0] = outputRows; - - const outputLength = - outputShape.reduce((product, value) => product * value, 1); - // Output array is initialized with the value 0 by default. - const output = util.getArrayFromDType(inputDType, outputLength) as TypedArray; - - // Note that we do not initialize the output buffer with a default value, so - // we need to explicitly set missing indices to the default value. - if (numIndices === 0) { - if (outputRows > 0) { - output.fill(defaultValue); - } - return [output, outputShape]; - } - - if (outputRows <= 0) { - throw new Error( - backend_util.getSparseSegmentReductionNegativeSegmentIdsErrorMessage()); - } - - let start = 0, end = 1; - // Index from which the output is not initialized. - let uninitializedIndex = 0; - let outIndex = segmentIds[start]; - - while (true) { - // We initialize nextIndex to 0 to avoid may be uninitialized warning - let nextIndex = 0; - if (end < numIndices) { - nextIndex = segmentIds[end]; - if (outIndex === nextIndex) { - ++end; - continue; - } - // We have a new segment here. Verify that the segment ids are growing. - if (outIndex >= nextIndex) { - throw new Error(backend_util - .getSparseSegmentReductionNonIncreasingSegmentIdsErrorMessage()); - } - } - - if (outIndex < 0 || outIndex >= outputRows) { - throw new Error( - backend_util.getSparseSegmentReductionSegmentIdOutOfRangeErrorMessage( - outIndex, outputRows)); - } - - // If there is a gap between two indices, we need to set that gap to the - // default value. - if (outIndex > uninitializedIndex) { - output.fill(defaultValue, uninitializedIndex * numCol, outIndex * numCol); - } - - for (let i = start; i < end; ++i) { - const index = indices[i]; - if (index < 0 || index >= inputFlat[0]) { - throw new Error( - backend_util.getSparseSegmentReductionIndicesOutOfRangeErrorMessage( - i, indices[i], inputFlat[0])); - } - for (let j = 0; j < numCol; j++) { - output[outIndex * numCol + j] += input[index * numCol + j]; - } - } - - if (isMean) { - for (let j = 0; j < numCol; j++) { - output[outIndex * numCol + j] /= end - start; - } - } - - start = end; - ++end; - uninitializedIndex = outIndex + 1; - outIndex = nextIndex; - if (end > numIndices) { - break; - } - } - - // Fill the gap at the end with the default value. - if (uninitializedIndex < outputRows) { - output.fill(defaultValue, uninitializedIndex * numCol, outputRows * numCol); - } - - return [output, outputShape]; -} diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/SparseSegmentSum.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/SparseSegmentSum.ts deleted file mode 100644 index 4afed5abd..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/SparseSegmentSum.ts +++ /dev/null @@ -1,58 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, SparseSegmentSum, SparseSegmentSumInputs, TensorInfo, TypedArray} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; - -import {sparseSegmentReductionImpl} from './SparseSegmentReduction_impl'; - -export function sparseSegmentSum( - args: {inputs: SparseSegmentSumInputs, backend: MathBackendCPU}): - TensorInfo { - const {inputs, backend} = args; - const {data, indices, segmentIds} = inputs; - if (data.shape.length < 1) { - throw new Error( - `Data should be at least 1 dimensional but received scalar`); - } - if (indices.shape.length !== 1) { - throw new Error(`Indices should be a vector but received shape - ${indices.shape}`); - } - if (segmentIds.shape.length !== 1) { - throw new Error(`Segment ids should be a vector but received shape - ${segmentIds.shape}`); - } - if (indices.shape[0] !== segmentIds.shape[0]) { - throw new Error(`segmentIds and indices should have same size.`); - } - - const $data = backend.data.get(data.dataId).values as TypedArray; - const $indices = backend.data.get(indices.dataId).values as TypedArray; - const $segmentIds = backend.data.get(segmentIds.dataId).values as TypedArray; - - const [outputData, outputDataShape] = sparseSegmentReductionImpl( - $data, data.shape, data.dtype, $indices, $segmentIds); - return backend.makeTensorInfo(outputDataShape, data.dtype, outputData); -} - -export const sparseSegmentSumConfig: KernelConfig = { - kernelName: SparseSegmentSum, - backendName: 'cpu', - kernelFunc: sparseSegmentSum, -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/SparseToDense.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/SparseToDense.ts deleted file mode 100644 index 5c82f0478..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/SparseToDense.ts +++ /dev/null @@ -1,86 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, KernelConfig, KernelFunc, Rank, SparseToDense, SparseToDenseAttrs, SparseToDenseInputs, TensorInfo, util} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; -import {scatterImpl} from './Scatter_impl'; - -export function sparseToDense(args: { - inputs: SparseToDenseInputs, - backend: MathBackendCPU, - attrs: SparseToDenseAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {sparseIndices, sparseValues, defaultValue} = inputs; - const {outputShape} = attrs; - - const {sliceRank, numUpdates, sliceSize, strides, outputSize} = - backend_util.calculateShapes(sparseValues, sparseIndices, outputShape); - const sumDupeIndices = false; - - const indicesBuf = backend.bufferSync(sparseIndices); - - let outBuf; - switch (sparseValues.dtype) { - case 'bool': { - const updatesBuf = backend.bufferSync(sparseValues); - const $defaultValue = - Boolean(backend.data.get(defaultValue.dataId).values[0]); - outBuf = scatterImpl( - indicesBuf, updatesBuf, outputShape, outputSize, sliceSize, - numUpdates, sliceRank, strides, $defaultValue, sumDupeIndices); - break; - } - case 'float32': { - const updatesBuf = backend.bufferSync(sparseValues); - const $defaultValue = - backend.data.get(defaultValue.dataId).values[0] as number; - outBuf = scatterImpl( - indicesBuf, updatesBuf, outputShape, outputSize, sliceSize, - numUpdates, sliceRank, strides, $defaultValue, sumDupeIndices); - break; - } - case 'int32': { - const updatesBuf = backend.bufferSync(sparseValues); - const $defaultValue = - backend.data.get(defaultValue.dataId).values[0] as number; - outBuf = scatterImpl( - indicesBuf, updatesBuf, outputShape, outputSize, sliceSize, - numUpdates, sliceRank, strides, $defaultValue, sumDupeIndices); - break; - } - case 'string': { - const updatesBuf = backend.bufferSync(sparseValues); - const $defaultValue = util.decodeString( - backend.data.get(defaultValue.dataId).values[0] as Uint8Array); - outBuf = scatterImpl( - indicesBuf, updatesBuf, outputShape, outputSize, sliceSize, - numUpdates, sliceRank, strides, $defaultValue, sumDupeIndices); - break; - } - default: - throw new Error(`Unsupported type ${sparseValues.dtype}`); - } - return backend.makeTensorInfo(outputShape, outBuf.dtype, outBuf.values); -} - -export const sparseToDenseConfig: KernelConfig = { - kernelName: SparseToDense, - backendName: 'cpu', - kernelFunc: sparseToDense as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/SplitV.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/SplitV.ts deleted file mode 100644 index 7d2899ed3..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/SplitV.ts +++ /dev/null @@ -1,50 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, SplitVAttrs, SplitVInputs} from '@tensorflow/tfjs-core'; -import {KernelConfig, KernelFunc, SplitV, TensorInfo, util} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; -import {slice} from './Slice'; - -export function splitV( - args: {inputs: SplitVInputs, backend: MathBackendCPU, attrs: SplitVAttrs}): - TensorInfo[] { - const {inputs, backend, attrs} = args; - const {x} = inputs; - const {numOrSizeSplits, axis} = attrs; - - const $axis = util.parseAxisParam(axis, x.shape)[0]; - const splitSizes = backend_util.prepareSplitSize(x, numOrSizeSplits, $axis); - - const begin = new Array(x.shape.length).fill(0); - const size = x.shape.slice(); - return splitSizes.map(s => { - const sliceSize = [...size]; - sliceSize[$axis] = s; - const sliceT = - slice({inputs: {x}, backend, attrs: {begin, size: sliceSize}}); - begin[$axis] += s; - return sliceT; - }); -} - -export const splitVConfig: KernelConfig = { - kernelName: SplitV, - backendName: 'cpu', - kernelFunc: splitV as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Sqrt.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Sqrt.ts deleted file mode 100644 index f8d3ec017..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Sqrt.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, Sqrt} from '@tensorflow/tfjs-core'; - -import {createSimpleUnaryImpl} from '../utils/unary_impl'; -import {unaryKernelFunc} from '../utils/unary_utils'; - -export const sqrtImpl = createSimpleUnaryImpl((xi) => Math.sqrt(xi)); -export const sqrt = unaryKernelFunc(Sqrt, (xi) => Math.sqrt(xi)); - -export const sqrtConfig: KernelConfig = { - kernelName: Sqrt, - backendName: 'cpu', - kernelFunc: sqrt, -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Square.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Square.ts deleted file mode 100644 index 849e36a47..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Square.ts +++ /dev/null @@ -1,40 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Square, SquareInputs} from '@tensorflow/tfjs-core'; -import {KernelConfig} from '@tensorflow/tfjs-core'; -import {MathBackendCPU} from '../backend_cpu'; -import {assertNotComplex} from '../cpu_util'; - -export const squareConfig: KernelConfig = { - kernelName: Square, - backendName: 'cpu', - kernelFunc: ({inputs, backend}) => { - const {x} = inputs as SquareInputs; - const cpuBackend = backend as MathBackendCPU; - assertNotComplex(x, 'square'); - - const values = cpuBackend.data.get(x.dataId).values as Float32Array; - const newValues = new Float32Array(values.length); - for (let i = 0; i < values.length; ++i) { - const value = values[i]; - newValues[i] = value * value; - } - const dataId = cpuBackend.write(newValues, x.shape, x.dtype); - return {dataId, shape: x.shape, dtype: x.dtype}; - } -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/SquaredDifference.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/SquaredDifference.ts deleted file mode 100644 index 5fafa2136..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/SquaredDifference.ts +++ /dev/null @@ -1,35 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, SquaredDifference} from '@tensorflow/tfjs-core'; - -import {createSimpleBinaryKernelImpl} from '../utils/binary_impl'; -import {binaryKernelFunc} from '../utils/binary_utils'; - -export const squaredDifferenceImpl = - createSimpleBinaryKernelImpl(((a: number, b: number) => { - const diff = a - b; - return diff * diff; - })); -export const squaredDifference = - binaryKernelFunc(SquaredDifference, squaredDifferenceImpl); - -export const squaredDifferenceConfig: KernelConfig = { - kernelName: SquaredDifference, - backendName: 'cpu', - kernelFunc: squaredDifference -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/StaticRegexReplace.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/StaticRegexReplace.ts deleted file mode 100644 index 5e8c51d5a..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/StaticRegexReplace.ts +++ /dev/null @@ -1,37 +0,0 @@ -/** - * @license - * Copyright 2023 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, StaticRegexReplace, StaticRegexReplaceAttrs} from '@tensorflow/tfjs-core'; -import {createSimpleUnaryImpl} from '../utils/unary_impl'; -import {unaryKernelFuncFromImpl} from '../utils/unary_utils'; - -export const staticRegexReplaceImpl = createSimpleUnaryImpl((x: string, attrs) => { - const {pattern, replaceGlobal, rewrite} = - attrs as unknown as StaticRegexReplaceAttrs; - // TODO(mattSoulanille): Don't create a regex each time. - return x.replace(new RegExp(pattern, replaceGlobal ? 'g' : ''), rewrite); -}); - -const staticRegexReplace = - unaryKernelFuncFromImpl(StaticRegexReplace, staticRegexReplaceImpl); - -export const staticRegexReplaceConfig: KernelConfig = { - kernelName: StaticRegexReplace, - backendName: 'cpu', - kernelFunc: staticRegexReplace, -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Step.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Step.ts deleted file mode 100644 index d7b2e4426..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Step.ts +++ /dev/null @@ -1,35 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, Step, StepAttrs} from '@tensorflow/tfjs-core'; - -import {unaryKernelFunc} from '../utils/unary_utils'; - -export const step = unaryKernelFunc(Step, (xi, attrs) => { - const stepAttrs = attrs as unknown as StepAttrs; - if (isNaN(xi)) { - return NaN; - } else { - return xi > 0 ? 1 : stepAttrs.alpha; - } -}); - -export const stepConfig: KernelConfig = { - kernelName: Step, - backendName: 'cpu', - kernelFunc: step, -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/StridedSlice.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/StridedSlice.ts deleted file mode 100644 index cfd93cd37..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/StridedSlice.ts +++ /dev/null @@ -1,93 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, Rank, slice_util, StridedSlice, StridedSliceAttrs, StridedSliceInputs, TensorInfo, util} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; -import {assertNotComplex} from '../cpu_util'; -import {reshape} from './Reshape'; -import {slice} from './Slice'; -import {stridedSliceImpl} from './StridedSlice_impl'; - -export function stridedSlice(args: { - inputs: StridedSliceInputs, - backend: MathBackendCPU, - attrs: StridedSliceAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {x} = inputs; - const { - begin, - end, - strides, - beginMask, - endMask, - ellipsisMask, - newAxisMask, - shrinkAxisMask - } = attrs; - - assertNotComplex(x, 'stridedSlice'); - - const { - finalShapeSparse, - finalShape, - isIdentity, - sliceDim0, - isSimpleSlice, - begin: $begin, - end: $end, - strides: $strides - } = - slice_util.sliceInfo( - x.shape, begin, end, strides, beginMask, endMask, ellipsisMask, - newAxisMask, shrinkAxisMask); - - let result; - - // ref: - // https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/kernels/strided_slice_op.cc - if (isIdentity) { - // Optimization #1, slice is a no-op plus reshape - result = reshape({inputs: {x}, backend, attrs: {shape: finalShape}}); - } else if (sliceDim0 || isSimpleSlice) { - // Optimization #2, slice is memory contiguous (only occurs in dim 0) - util.assert( - x.shape.length >= 1, - () => `Input must have rank at least 1, got: ${x.shape.length}`); - - const size = slice_util.computeOutShape($begin, $end, $strides); - // To tolerate begin[0] > end[0] (a 0-output slice), we min(begin, end). - const sliced = slice({inputs: {x}, backend, attrs: {begin: $begin, size}}); - result = - reshape({inputs: {x: sliced}, backend, attrs: {shape: finalShape}}); - backend.disposeIntermediateTensorInfo(sliced); - } else { - const xBuf = backend.bufferSync(x); - const outBuf = stridedSliceImpl(finalShapeSparse, xBuf, $strides, $begin); - - result = backend.makeTensorInfo(finalShape, outBuf.dtype, outBuf.values); - } - - return result; -} - -export const stridedSliceConfig: KernelConfig = { - kernelName: StridedSlice, - backendName: 'cpu', - kernelFunc: stridedSlice as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/StridedSlice_impl.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/StridedSlice_impl.ts deleted file mode 100644 index c8107bad8..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/StridedSlice_impl.ts +++ /dev/null @@ -1,36 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {buffer, Rank, TensorBuffer} from '@tensorflow/tfjs-core'; - -export function stridedSliceImpl( - outShape: number[], xBuf: TensorBuffer, strides: number[], - begin: number[]): TensorBuffer { - const outBuf = buffer(outShape, xBuf.dtype); - - for (let i = 0; i < outBuf.size; i++) { - const loc = outBuf.indexToLoc(i); - - const newLoc: number[] = new Array(loc.length); - for (let j = 0; j < newLoc.length; j++) { - newLoc[j] = loc[j] * strides[j] + begin[j]; - } - outBuf.set(xBuf.get(...newLoc), ...loc); - } - - return outBuf as TensorBuffer; -} diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/StringNGrams.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/StringNGrams.ts deleted file mode 100644 index 34405373c..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/StringNGrams.ts +++ /dev/null @@ -1,55 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, StringNGrams, StringNGramsAttrs, StringNGramsInputs, TensorInfo} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; - -import {stringNGramsImpl} from './StringNGrams_impl'; - -export function stringNGrams(args: { - inputs: StringNGramsInputs, - backend: MathBackendCPU, - attrs: StringNGramsAttrs -}): [TensorInfo, TensorInfo] { - const {inputs, backend, attrs} = args; - const { - separator, - nGramWidths, - leftPad, - rightPad, - padWidth, - preserveShortSequences - } = attrs; - const {data, dataSplits} = inputs; - const $data = backend.data.get(data.dataId).values as Uint8Array[]; - const $dataSplits = backend.data.get(dataSplits.dataId).values as Int32Array; - - const [nGrams, nGramsSplits] = stringNGramsImpl( - $data, $dataSplits, separator, nGramWidths, leftPad, rightPad, padWidth, - preserveShortSequences); - return [ - backend.makeTensorInfo([nGrams.length], 'string', nGrams), - backend.makeTensorInfo(dataSplits.shape, 'int32', nGramsSplits), - ]; -} - -export const stringNGramsConfig: KernelConfig = { - kernelName: StringNGrams, - backendName: 'cpu', - kernelFunc: stringNGrams as unknown as KernelFunc, -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/StringNGrams_impl.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/StringNGrams_impl.ts deleted file mode 100644 index 4ff068f4c..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/StringNGrams_impl.ts +++ /dev/null @@ -1,225 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {util} from '@tensorflow/tfjs-core'; - -/** - * The StringNGramsOp class creates ngrams from ragged string data. - * The constructor contains all attributes related to the operation such as - * padding widths and strings, and the compute function can be used to - * compute the ngrams for different ragged tensor inputs. - */ -class StringNGramsOp { - private separator: Uint8Array; - private nGramWidths: number[]; - private padWidth: number; - private leftPad: Uint8Array; - private rightPad: Uint8Array; - private preserveShort: boolean; - - constructor( - separator: string, nGramWidths: number[], leftPad: string, - rightPad: string, padWidth: number, preserveShortSequences: boolean) { - this.separator = util.encodeString(separator); - this.nGramWidths = nGramWidths; - this.leftPad = util.encodeString(leftPad); - this.rightPad = util.encodeString(rightPad); - this.padWidth = padWidth; - this.preserveShort = preserveShortSequences; - } - - private getPadWidth(nGramWidth: number) { - // Ngrams can be padded with either a fixed pad width or a dynamic pad - // width depending on the 'padWidth' arg, but in no case should the padding - // ever be wider than 'nGramWidth' - 1. - return Math.min( - this.padWidth < 0 ? nGramWidth - 1 : this.padWidth, nGramWidth - 1); - } - - private getNumNGrams(length: number, nGramWidth: number) { - const padWidth = this.getPadWidth(nGramWidth); - return Math.max(0, ((length + 2 * padWidth) - nGramWidth) + 1); - } - - private createNGrams( - data: Uint8Array[], splitIndex: number, output: Uint8Array[], - outputStartIndex: number, numNGrams: number, nGramWidth: number) { - for (let nGramIndex = 0; nGramIndex < numNGrams; ++nGramIndex) { - const padWidth = this.getPadWidth(nGramWidth); - const leftPadding = Math.max(0, padWidth - nGramIndex); - const rightPadding = - Math.max(0, padWidth - (numNGrams - (nGramIndex + 1))); - const numTokens = nGramWidth - (leftPadding + rightPadding); - const dataStartIndex = - splitIndex + (leftPadding > 0 ? 0 : nGramIndex - padWidth); - - // Calculate the total expected size of the nGram so we can reserve the - // correct amount of space in the string. - let nGramSize = 0; - // Size of the left padding. - nGramSize += leftPadding * this.leftPad.length; - // Size of the tokens. - for (let n = 0; n < numTokens; ++n) { - nGramSize += data[dataStartIndex + n].length; - } - // Size of the right padding. - nGramSize += rightPadding * this.rightPad.length; - // Size of the separators. - const numSeparators = leftPadding + rightPadding + numTokens - 1; - nGramSize += numSeparators * this.separator.length; - - // Build the nGram. - output[outputStartIndex + nGramIndex] = new Uint8Array(nGramSize); - const nGram = output[outputStartIndex + nGramIndex]; - - let nextNGramIndex = 0; - const appendToNGram = (str: Uint8Array) => - str.forEach((value) => nGram[nextNGramIndex++] = value); - - for (let n = 0; n < leftPadding; ++n) { - appendToNGram(this.leftPad); - appendToNGram(this.separator); - } - // Only output first numTokens - 1 pairs of data and separator - for (let n = 0; n < numTokens - 1; ++n) { - appendToNGram(data[dataStartIndex + n]); - appendToNGram(this.separator); - } - // Handle case when there are no tokens or no right padding as these - // can result in consecutive separators. - if (numTokens > 0) { - // If we have tokens, then output last and then pair each separator - // with the right padding that follows, to ensure nGram ends either with - // the token or with the right pad. - appendToNGram(data[dataStartIndex + numTokens - 1]); - for (let n = 0; n < rightPadding; ++n) { - appendToNGram(this.separator); - appendToNGram(this.rightPad); - } - } else { - // If we don't have tokens, then the last item inserted into the nGram - // has been the separator from the left padding loop above. Hence, - // output right pad and separator and make sure to finish with a - // padding, not a separator. - for (let n = 0; n < rightPadding - 1; ++n) { - appendToNGram(this.rightPad); - appendToNGram(this.separator); - } - appendToNGram(this.rightPad); - } - } - } - - // Data and splits together form the definition of the ragged tensor, - // where data is 1 dimensional and contains the values of the tensor - // and splits denotes the indices at which each row starts. - public compute(data: Uint8Array[], splits: Int32Array): - [Uint8Array[], Int32Array] { - // Validate that the splits are valid indices into data, only if there are - // splits specified. - const inputDataSize = data.length; - const splitsSize = splits.length; - if (splitsSize > 0) { - let prevSplit = splits[0]; - if (prevSplit !== 0) { - throw new Error(`First split value must be 0, got ${prevSplit}`); - } - for (let i = 1; i < splitsSize; ++i) { - let validSplits = splits[i] >= prevSplit; - validSplits = validSplits && (splits[i] <= inputDataSize); - if (!validSplits) { - throw new Error(`Invalid split value ${splits[i]}, must be in [${ - prevSplit}, ${inputDataSize}]`); - } - prevSplit = splits[i]; - } - if (prevSplit !== inputDataSize) { - throw new Error(`Last split value must be data size. Expected ${ - inputDataSize}, got ${prevSplit}`); - } - } - - const numBatchItems = splitsSize - 1; - const nGramsSplits = util.getArrayFromDType('int32', splitsSize); - // If there is no data or size, return an empty ragged tensor. - if (inputDataSize === 0 || splitsSize === 0) { - const empty: Uint8Array[] = new Array(inputDataSize); - for (let i = 0; i <= numBatchItems; ++i) { - nGramsSplits[i] = 0; - } - return [empty, nGramsSplits]; - } - - nGramsSplits[0] = 0; - for (let i = 1; i <= numBatchItems; ++i) { - const length = splits[i] - splits[i - 1]; - let numNGrams = 0; - this.nGramWidths.forEach((nGramWidth) => { - numNGrams += this.getNumNGrams(length, nGramWidth); - }); - if (this.preserveShort && length > 0 && numNGrams === 0) { - numNGrams = 1; - } - nGramsSplits[i] = nGramsSplits[i - 1] + numNGrams; - } - - const nGrams: Uint8Array[] = new Array(nGramsSplits[numBatchItems]); - - for (let i = 0; i < numBatchItems; ++i) { - const splitIndex = splits[i]; - let outputStartIdx = nGramsSplits[i]; - this.nGramWidths.forEach((nGramWidth) => { - const length = splits[i + 1] - splits[i]; - const numNGrams = this.getNumNGrams(length, nGramWidth); - this.createNGrams( - data, splitIndex, nGrams, outputStartIdx, numNGrams, nGramWidth); - outputStartIdx += numNGrams; - }); - // If we're preserving short sequences, check to see if no sequence was - // generated by comparing the current output start idx to the original - // one (nGramSplitsdata). If no ngrams were generated, then they will - // be equal (since we increment outputStartIdx by numNGrams every - // time we create a set of ngrams.) - if (this.preserveShort && outputStartIdx === nGramsSplits[i]) { - const dataLength = splits[i + 1] - splits[i]; - // One legitimate reason to not have any ngrams when this.preserveShort - // is true is if the sequence itself is empty. In that case, move on. - if (dataLength === 0) { - continue; - } - // We don't have to worry about dynamic padding sizes here: if padding - // was dynamic, every sequence would have had sufficient padding to - // generate at least one nGram. - const nGramWidth = dataLength + 2 * this.padWidth; - const numNGrams = 1; - this.createNGrams( - data, splitIndex, nGrams, outputStartIdx, numNGrams, nGramWidth); - } - } - return [nGrams, nGramsSplits]; - } -} - -export function stringNGramsImpl( - data: Uint8Array[], dataSplits: Int32Array, separator: string, - nGramWidths: number[], leftPad: string, rightPad: string, padWidth: number, - preserveShortSequences: boolean): [Uint8Array[], Int32Array] { - return new StringNGramsOp( - separator, nGramWidths, leftPad, rightPad, padWidth, - preserveShortSequences) - .compute(data, dataSplits); -} diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/StringSplit.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/StringSplit.ts deleted file mode 100644 index 8bf74a5ff..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/StringSplit.ts +++ /dev/null @@ -1,61 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, StringSplit, StringSplitAttrs, StringSplitInputs, TensorInfo} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; - -import {stringSplitImpl} from './StringSplit_impl'; - -export function stringSplit(args: { - inputs: StringSplitInputs, - backend: MathBackendCPU, - attrs: StringSplitAttrs -}): [TensorInfo, TensorInfo, TensorInfo] { - const {inputs, backend, attrs} = args; - const {skipEmpty} = attrs; - const {input, delimiter} = inputs; - - if (input.dtype !== 'string') { - throw new Error('Input must be of datatype string'); - } - if (input.shape.length !== 1) { - throw new Error(`Input must be a vector, got shape: ${input.shape}`); - } - if (delimiter.shape.length !== 0) { - throw new Error( - `Delimiter must be a scalar, got shape: ${delimiter.shape}`); - } - - const $input = backend.data.get(input.dataId).values as Uint8Array[]; - const $delimiter = backend.data.get(delimiter.dataId).values[0] as Uint8Array; - - const [indices, values, shape] = - stringSplitImpl($input, $delimiter, skipEmpty); - const outputSize = values.length; - return [ - backend.makeTensorInfo([outputSize, 2], 'int32', indices), - backend.makeTensorInfo([outputSize], 'string', values), - backend.makeTensorInfo([2], 'int32', new Int32Array(shape)) - ]; -} - -export const stringSplitConfig: KernelConfig = { - kernelName: StringSplit, - backendName: 'cpu', - kernelFunc: stringSplit as unknown as KernelFunc, -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/StringSplit_impl.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/StringSplit_impl.ts deleted file mode 100644 index 352add3b6..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/StringSplit_impl.ts +++ /dev/null @@ -1,100 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {TypedArray, util} from '@tensorflow/tfjs-core'; - -function split( - str: Uint8Array, delimiters: Uint8Array, skipEmpty: boolean, - result: Uint8Array[]): void { - if (!str.length) { - return; - } - // When the delimiter is empty, the input is split into individual characters. - if (delimiters.length === 0) { - for (let i = 0; i < str.length; ++i) { - result.push(str.subarray(i, i + 1)); - } - return; - } - // When there is one delimiter, the input is split only at that delimiter. - if (delimiters.length === 1) { - const delimiter = delimiters[0]; - let f = str.indexOf(delimiter); - while (f !== -1) { - const token = str.subarray(0, f); - if (!skipEmpty || token.length !== 0) { - result.push(token); - } - str = str.subarray(f + 1); - f = str.indexOf(delimiter); - } - if (!skipEmpty || str.length !== 0) { - result.push(str); - } - return; - } - // When there are multiple delimiters, the input is split at every instance - // one of the delimiters appears. - let tokenStart = 0; - for (let i = 0; i < str.length + 1; i++) { - if ((i === str.length) || (delimiters.indexOf(str[i]) !== -1)) { - const token = str.subarray(tokenStart, i); - if (!skipEmpty || token.length !== 0) { - result.push(token); - } - tokenStart = i + 1; - } - } -} - -export function stringSplitImpl( - input: Uint8Array[], delimiter: Uint8Array, - skipEmpty: boolean): [TypedArray, Uint8Array[], [number, number]] { - const batchSize = input.length; - - // Empty delimiter means split the input character by character. - const tokens: Uint8Array[] = []; - - let outputSize = 0; - let maxNumEntries = 0; - const numIndices: number[] = new Array(batchSize); - for (let i = 0; i < batchSize; ++i) { - const prevTokensLength = tokens.length; - split(input[i], delimiter, skipEmpty, tokens); - const nEntries = tokens.length - prevTokensLength; - numIndices[i] = nEntries; - outputSize += nEntries; - maxNumEntries = Math.max(maxNumEntries, nEntries); - } - - const indices = util.getArrayFromDType('int32', outputSize * 2) as TypedArray; - const values: Uint8Array[] = new Array(outputSize); - const shape: [number, number] = [batchSize, maxNumEntries]; - - let c = 0; - for (let i = 0; i < batchSize; ++i) { - for (let j = 0; j < numIndices[i]; ++j) { - // indices is a 2d tensor with shape of [outputSize, 2] - indices[c * 2] = i; - indices[c * 2 + 1] = j; - values[c] = tokens[c]; - ++c; - } - } - - return [indices, values, shape]; -} diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/StringToHashBucketFast.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/StringToHashBucketFast.ts deleted file mode 100644 index 98bb6de1f..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/StringToHashBucketFast.ts +++ /dev/null @@ -1,50 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, StringToHashBucketFast, StringToHashBucketFastAttrs, StringToHashBucketFastInputs, TensorInfo} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; - -import {stringToHashBucketFastImpl} from './StringToHashBucketFast_impl'; - -export function stringToHashBucketFast(args: { - inputs: StringToHashBucketFastInputs, - backend: MathBackendCPU, - attrs: StringToHashBucketFastAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {numBuckets} = attrs; - const {input} = inputs; - - if (input.dtype !== 'string') { - throw new Error('Input must be of datatype string'); - } - if (numBuckets <= 0) { - throw new Error(`Number of buckets must be at least 1`); - } - - const $input = backend.data.get(input.dataId).values as Uint8Array[]; - - const output = stringToHashBucketFastImpl($input, numBuckets); - return backend.makeTensorInfo(input.shape, 'int32', output); -} - -export const stringToHashBucketFastConfig: KernelConfig = { - kernelName: StringToHashBucketFast, - backendName: 'cpu', - kernelFunc: stringToHashBucketFast as unknown as KernelFunc, -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/StringToHashBucketFast_impl.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/StringToHashBucketFast_impl.ts deleted file mode 100644 index b2ad6bde3..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/StringToHashBucketFast_impl.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {TypedArray, util} from '@tensorflow/tfjs-core'; - -export function stringToHashBucketFastImpl( - input: Uint8Array[], numBuckets: number): TypedArray { - const output = util.getArrayFromDType('int32', input.length) as TypedArray; - - for (let i = 0; i < input.length; ++i) { - output[i] = - util.fingerPrint64(input[i]).modulo(numBuckets).getLowBitsUnsigned(); - } - - return output; -} diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Sub.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Sub.ts deleted file mode 100644 index 1456d3658..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Sub.ts +++ /dev/null @@ -1,35 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, Sub} from '@tensorflow/tfjs-core'; - -import {createSimpleBinaryKernelImpl} from '../utils/binary_impl'; -import {binaryKernelFunc, createComplexBinaryKernelImpl} from '../utils/binary_utils'; - -export const subImpl = createSimpleBinaryKernelImpl( - ((aValue: number, bValue: number) => aValue - bValue)); -export const subComplexImpl = - createComplexBinaryKernelImpl(((aReal, aImag, bReal, bImag) => { - return {real: aReal - bReal, imag: aImag - bImag}; - })); -export const sub = binaryKernelFunc(Sub, subImpl, subComplexImpl); - -export const subConfig: KernelConfig = { - kernelName: Sub, - backendName: 'cpu', - kernelFunc: sub -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Sum.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Sum.ts deleted file mode 100644 index 1ff128333..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Sum.ts +++ /dev/null @@ -1,96 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, KernelConfig, KernelFunc, Sum, SumAttrs, SumInputs, TensorInfo, TypedArray, util} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; -import {assertNotComplex} from '../cpu_util'; -import {zeros} from '../utils/zeros_impl'; -import {cast} from './Cast'; -import {identity} from './Identity'; -import {reshape} from './Reshape'; -import {transpose} from './Transpose'; - -export function sum( - args: {inputs: SumInputs, backend: MathBackendCPU, attrs: SumAttrs}): - TensorInfo { - const {inputs, backend, attrs} = args; - const {x} = inputs; - const {axis, keepDims} = attrs; - - assertNotComplex(x, 'sum'); - - let $x; - if (x.dtype === 'bool') { - $x = cast({inputs: {x}, backend, attrs: {dtype: 'int32'}}); - } else { - $x = identity({inputs: {x}, backend}); - } - - const xRank = $x.shape.length; - const axes = util.parseAxisParam(axis, $x.shape); - const permutation = backend_util.getAxesPermutation(axes, xRank); - - let reductionAxes = axes; - let permutedX = $x; - if (permutation != null) { - permutedX = - transpose({inputs: {x: $x}, backend, attrs: {perm: permutation}}); - reductionAxes = backend_util.getInnerMostAxes(reductionAxes.length, xRank); - } - - backend_util.assertAxesAreInnerMostDims( - 'sum', reductionAxes, permutedX.shape.length); - - const [outShape, reduceShape] = - backend_util.computeOutAndReduceShapes(permutedX.shape, reductionAxes); - const resultDtype = backend_util.upcastType(permutedX.dtype, 'int32'); - let result = zeros(backend, outShape, resultDtype); - const reduceSize = util.sizeFromShape(reduceShape); - const vals = backend.data.get(result.dataId).values as TypedArray; - - const aVals = backend.data.get(permutedX.dataId).values as TypedArray; - for (let i = 0; i < vals.length; ++i) { - const offset = i * reduceSize; - let sum = 0; - for (let j = 0; j < reduceSize; ++j) { - sum += aVals[offset + j]; - } - vals[i] = sum; - } - - if (keepDims) { - const newShape = backend_util.expandShapeToKeepDim(result.shape, axes); - const oldResult = result; - result = reshape({inputs: {x: result}, backend, attrs: {shape: newShape}}); - backend.disposeIntermediateTensorInfo(oldResult); - } - - backend.disposeIntermediateTensorInfo($x); - - if (permutation != null) { - backend.disposeIntermediateTensorInfo(permutedX); - } - - return result; -} - -export const sumConfig: KernelConfig = { - kernelName: Sum, - backendName: 'cpu', - kernelFunc: sum as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Tan.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Tan.ts deleted file mode 100644 index 4a828cabd..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Tan.ts +++ /dev/null @@ -1,28 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, Tan} from '@tensorflow/tfjs-core'; - -import {unaryKernelFunc} from '../utils/unary_utils'; - -export const tan = unaryKernelFunc(Tan, (xi) => Math.tan(xi)); - -export const tanConfig: KernelConfig = { - kernelName: Tan, - backendName: 'cpu', - kernelFunc: tan, -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Tanh.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Tanh.ts deleted file mode 100644 index 89a324d79..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Tanh.ts +++ /dev/null @@ -1,28 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, Tanh} from '@tensorflow/tfjs-core'; - -import {unaryKernelFunc} from '../utils/unary_utils'; - -export const tanh = unaryKernelFunc(Tanh, (xi) => Math.tanh(xi)); - -export const tanhConfig: KernelConfig = { - kernelName: Tanh, - backendName: 'cpu', - kernelFunc: tanh, -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/TensorScatterUpdate.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/TensorScatterUpdate.ts deleted file mode 100644 index f1306a5cb..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/TensorScatterUpdate.ts +++ /dev/null @@ -1,49 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, KernelConfig, KernelFunc, Rank, TensorInfo, TensorScatterUpdate, TensorScatterUpdateAttrs, TensorScatterUpdateInputs} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; - -import {scatterImpl} from './Scatter_impl'; - -export function tensorScatterUpdate(args: { - inputs: TensorScatterUpdateInputs, - backend: MathBackendCPU, - attrs: TensorScatterUpdateAttrs -}): TensorInfo { - const {inputs, backend} = args; - const {tensor, indices, updates} = inputs; - - const {sliceRank, numUpdates, sliceSize, strides, outputSize} = - backend_util.calculateShapes(updates, indices, tensor.shape); - const sumDupeIndices = false; - - const indicesBuf = backend.bufferSync(indices); - const updatesBuf = backend.bufferSync(updates); - const tensorBuf = backend.bufferSync(tensor); - const outBuf = scatterImpl( - indicesBuf, updatesBuf, tensor.shape, outputSize, sliceSize, numUpdates, - sliceRank, strides, tensorBuf, sumDupeIndices); - return backend.makeTensorInfo(tensor.shape, outBuf.dtype, outBuf.values); -} - -export const tensorScatterUpdateConfig: KernelConfig = { - kernelName: TensorScatterUpdate, - backendName: 'cpu', - kernelFunc: tensorScatterUpdate as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Tile.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Tile.ts deleted file mode 100644 index 0bd900d14..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Tile.ts +++ /dev/null @@ -1,41 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, TensorInfo, Tile, TileAttrs, TileInputs} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; -import {assertNotComplex} from '../cpu_util'; -import {tileImpl} from './Tile_impl'; - -export function tile( - args: {inputs: TileInputs, backend: MathBackendCPU, attrs: TileAttrs}): - TensorInfo { - const {inputs, backend, attrs} = args; - const {x} = inputs; - const {reps} = attrs; - - assertNotComplex(x, 'tile'); - const outBuf = tileImpl(backend.bufferSync(x), reps); - - return backend.makeTensorInfo(outBuf.shape, outBuf.dtype, outBuf.values); -} - -export const tileConfig: KernelConfig = { - kernelName: Tile, - backendName: 'cpu', - kernelFunc: tile as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Tile_impl.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Tile_impl.ts deleted file mode 100644 index 8953f9c79..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Tile_impl.ts +++ /dev/null @@ -1,46 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {buffer, DataType, Rank, TensorBuffer} from '@tensorflow/tfjs-core'; - -/** - * An implementation of the tile kernel shared between webgl and cpu for string - * tensors only. - */ - -export function tileImpl( - xBuf: TensorBuffer, - reps: number[]): TensorBuffer { - const newShape: number[] = new Array(xBuf.rank); - for (let i = 0; i < newShape.length; i++) { - newShape[i] = xBuf.shape[i] * reps[i]; - } - const result = buffer(newShape, xBuf.dtype); - for (let i = 0; i < result.values.length; ++i) { - const newLoc = result.indexToLoc(i); - - const originalLoc: number[] = new Array(xBuf.rank); - for (let j = 0; j < originalLoc.length; j++) { - originalLoc[j] = newLoc[j] % xBuf.shape[j]; - } - - const originalIndex = xBuf.locToIndex(originalLoc); - - result.values[i] = xBuf.values[originalIndex]; - } - return result as TensorBuffer; -} diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/TopK.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/TopK.ts deleted file mode 100644 index 74b170575..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/TopK.ts +++ /dev/null @@ -1,49 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, NumericDataType, TensorInfo, TopK, TopKAttrs, TopKInputs, TypedArray} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; -import {assertNotComplex} from '../cpu_util'; -import {topKImpl} from './TopK_impl'; - -export function topK( - args: {inputs: TopKInputs, backend: MathBackendCPU, attrs: TopKAttrs}): - [TensorInfo, TensorInfo] { - const {inputs, backend, attrs} = args; - const {x} = inputs; - const {k, sorted} = attrs; - - assertNotComplex(x, 'topk'); - - const xVals = backend.data.get(x.dataId).values as TypedArray; - const [allTopKVals, allTopKIndices] = - topKImpl(xVals, x.shape, x.dtype as NumericDataType, k, sorted); - - return [ - backend.makeTensorInfo( - allTopKVals.shape, allTopKVals.dtype, allTopKVals.values), - backend.makeTensorInfo( - allTopKIndices.shape, allTopKIndices.dtype, allTopKIndices.values) - ]; -} - -export const topKConfig: KernelConfig = { - kernelName: TopK, - backendName: 'cpu', - kernelFunc: topK as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/TopK_impl.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/TopK_impl.ts deleted file mode 100644 index 88b6d0bf1..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/TopK_impl.ts +++ /dev/null @@ -1,140 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -/** An implementation of the TopK kernel shared between webgl and cpu. */ - -import {buffer, NumericDataType, Rank, ShapeMap, Tensor, TensorBuffer, TypedArray, util} from '@tensorflow/tfjs-core'; - -type Pair = { - value: number, - index: number -}; - -const comparePair = (a: Pair, b: Pair) => { - const valueDiff = b.value - a.value; - return valueDiff === 0 ? a.index - b.index : valueDiff; -}; - -/** - * Partitions array where all elements smaller than the (k+1) smallest element - * are found to the left of it, and all larger to the right of it. - * Based on the Floyd-Rivest Algorithm, ref: - * https://en.wikipedia.org/wiki/Floyd%E2%80%93Rivest_algorithm - * @param array: Array to partition - * @param left: Left index for the interval - * @param right: Right index for the interval - * @param k: Desired index value, where array[k] is the (k+1)th smallest element - * when left = 0 - */ -function select(array: Pair[], k: number, left = 0, right = array.length - 1) { - while (right > left) { - // Use select recursively to sample a smaller set of size s - // the arbitrary constants 600 and 0.5 are used in the original - // version to minimize execution time. - if (right - left > 600) { - const n = right - left + 1; - const i = k - left + 1; - const z = Math.log(n); - const s = 0.5 * Math.exp(2 * z / 3); - const sd = 0.5 * Math.sqrt(z * s * (n - s) / n) * Math.sign(i - n / 2); - const newLeft = Math.max(left, Math.floor(k - i * s / n + sd)); - const newRight = Math.min(right, Math.floor(k + (n - i) * s / n + sd)); - select(array, k, newLeft, newRight); - } - // partition the elements between left and right around t - const t = array[k]; - let i = left; - let j = right; - - util.swap(array, left, k); - - if (comparePair(array[right], t) > 0) { - util.swap(array, left, right); - } - while (i < j) { - util.swap(array, i, j); - i++; - j--; - while (comparePair(array[i], t) < 0) { - i = i + 1; - } - while (comparePair(array[j], t) > 0) { - j = j - 1; - } - } - if (comparePair(array[left], t) === 0) { - util.swap(array, left, j); - } else { - j = j + 1; - util.swap(array, j, right); - } - // Adjust left and right towards the boundaries of the subset - // containing the (k - left + 1)th smallest element. - if (j <= k) { - left = j + 1; - } - if (k <= j) { - right = j - 1; - } - } -} - -export function topKImpl( - x: TypedArray, xShape: number[], xDtype: NumericDataType, k: number, - sorted: boolean): - [TensorBuffer, TensorBuffer] { - // Reshape into a 2d tensor [batch, lastDim] and compute topk along lastDim. - const lastDim = xShape[xShape.length - 1]; - const [batch, size] = [x.length / lastDim, lastDim]; - const allTopKVals = util.getTypedArrayFromDType(xDtype, batch * k); - const allTopKIndices = util.getTypedArrayFromDType('int32', batch * k); - - for (let b = 0; b < batch; b++) { - const offset = b * size; - const vals = x.subarray(offset, offset + size); - - let valAndInd: Pair[] = new Array(vals.length); - vals.forEach( - (value: number, index: number) => valAndInd[index] = {value, index}); - - if (k < valAndInd.length) { - select(valAndInd, k); - valAndInd = valAndInd.slice(0, k); - } - - if (sorted) { - valAndInd.sort(comparePair); - } - - const outOffset = b * k; - const topKVals = allTopKVals.subarray(outOffset, outOffset + k); - const topKIndices = allTopKIndices.subarray(outOffset, outOffset + k); - for (let i = 0; i < k; i++) { - topKVals[i] = valAndInd[i].value; - topKIndices[i] = valAndInd[i].index; - } - } - // Reshape back to the original input shape, except that the last - // dimension is k. - const outputShape = xShape.slice(); - outputShape[outputShape.length - 1] = k; - - return [ - buffer(outputShape as ShapeMap[R], xDtype, allTopKVals), - buffer(outputShape as ShapeMap[R], 'int32', allTopKIndices) - ]; -} diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Transform.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Transform.ts deleted file mode 100644 index f15138a02..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Transform.ts +++ /dev/null @@ -1,257 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, NumericDataType, TensorInfo, Transform, TransformAttrs, TransformInputs, TypedArray, util} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; - -export function transform(args: { - inputs: TransformInputs, - attrs: TransformAttrs, - backend: MathBackendCPU -}): TensorInfo { - const {inputs, attrs, backend} = args; - const {image, transforms} = inputs; - const {interpolation, fillMode, fillValue, outputShape} = attrs; - - const [batch, imageHeight, imageWidth, numChannels] = image.shape; - const [outHeight, outWidth] = - outputShape != null ? outputShape : [imageHeight, imageWidth]; - const outShape = [batch, outHeight, outWidth, numChannels]; - - const inStrides = util.computeStrides(image.shape); - const batchInStride = inStrides[0]; - const rowInStride = inStrides[1]; - const colInStride = inStrides[2]; - - const outStrides = util.computeStrides(outShape); - const batchOutStride = outStrides[0]; - const rowOutStride = outStrides[1]; - const colOutStride = outStrides[2]; - - const outVals = util.getTypedArrayFromDType( - image.dtype as NumericDataType, util.sizeFromShape(outShape)); - - outVals.fill(fillValue); - - const imageVals = backend.data.get(image.dataId).values as TypedArray; - const transformVals = - backend.data.get(transforms.dataId).values as TypedArray; - - // Ref TF implementation: - // https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/kernels/image/image_ops.h - for (let b = 0; b < batch; ++b) { - const transform = transforms.shape[0] === 1 ? - transformVals : - transformVals.subarray(b * 8, b * 8 + 8); - - for (let outY = 0; outY < outHeight; ++outY) { - for (let outX = 0; outX < outWidth; ++outX) { - for (let channel = 0; channel < numChannels; ++channel) { - let val; - - const projection = transform[6] * outX + transform[7] * outY + 1; - - if (projection === 0) { - // Return the fill value for infinite coordinates, - // which are outside the input image - continue; - } - - const inX = - (transform[0] * outX + transform[1] * outY + transform[2]) / - projection; - const inY = - (transform[3] * outX + transform[4] * outY + transform[5]) / - projection; - - const x = mapCoord(inX, imageWidth, fillMode); - const y = mapCoord(inY, imageHeight, fillMode); - - switch (interpolation) { - case 'nearest': - val = nearestInterpolation( - imageVals, imageHeight, imageWidth, batchInStride, - rowInStride, colInStride, b, y, x, channel, fillValue); - break; - case 'bilinear': - val = bilinearInterpolation( - imageVals, imageHeight, imageWidth, batchInStride, - rowInStride, colInStride, b, y, x, channel, fillValue); - break; - default: - throw new Error( - `Error in Transform: Expect 'nearest' or ` + - `'bilinear', but got ${interpolation}`); - } - - const ind = - b * batchOutStride + outY * rowOutStride + - outX * colOutStride + channel; - - outVals[ind] = val; - } - } - } - - return backend.makeTensorInfo(outShape, image.dtype, outVals); - } - - const dataId = backend.write(outVals, outShape, image.dtype); - return {dataId, shape: image.shape, dtype: image.dtype}; -} - -export const transformConfig: KernelConfig = { - kernelName: Transform, - backendName: 'cpu', - kernelFunc: transform as unknown as KernelFunc -}; - -function mapCoord( - outCoord: number, len: number, - mode: 'constant'|'reflect'|'wrap'|'nearest') { - switch (mode) { - case 'reflect': - return mapCoordReflect(outCoord, len); - case 'wrap': - return mapCoordWrap(outCoord, len); - case 'nearest': - return mapCoordNearest(outCoord, len); - case 'constant': - default: - return mapCoordConstant(outCoord, len); - } -} - -function mapCoordReflect(outCoord: number, len: number): number { - // Reflect [abcd] to [dcba|abcd|dcba]. - let inCoord = outCoord; - if (inCoord < 0) { - if (len <= 1) { - inCoord = 0; - } else { - const sz2 = 2 * len; - if (inCoord < sz2) { - inCoord = sz2 * Math.trunc(-inCoord / sz2) + inCoord; - } - inCoord = inCoord < -len ? inCoord + sz2 : -inCoord - 1; - } - } else if (inCoord > len - 1) { - if (len <= 1) { - inCoord = 0; - } else { - const sz2 = 2 * len; - inCoord -= sz2 * Math.trunc(inCoord / sz2); - if (inCoord >= len) { - inCoord = sz2 - inCoord - 1; - } - } - } - // clamp is necessary because when outCoord = 3.5 and len = 4, - // inCoord = 3.5 and will be rounded to 4 in nearest interpolation. - return util.clamp(0, inCoord, len - 1); -} - -function mapCoordWrap(outCoord: number, len: number): number { - // Wrap [abcd] to [abcd|abcd|abcd]. - let inCoord = outCoord; - if (inCoord < 0) { - if (len <= 1) { - inCoord = 0; - } else { - const sz = len - 1; - inCoord += len * (Math.trunc(-inCoord / sz) + 1); - } - } else if (inCoord > len - 1) { - if (len <= 1) { - inCoord = 0; - } else { - const sz = len - 1; - inCoord -= len * Math.trunc(inCoord / sz); - } - } - // clamp is necessary because when outCoord = -0.5 and len = 4, - // inCoord = 3.5 and will be rounded to 4 in nearest interpolation. - return util.clamp(0, inCoord, len - 1); -} - -function mapCoordConstant(outCoord: number, len: number): number { - return outCoord; -} - -function mapCoordNearest(outCoord: number, len: number): number { - return util.clamp(0, outCoord, len - 1); -} - -function readWithFillValue( - imageVals: TypedArray, imageHeight: number, imageWidth: number, - batchStride: number, rowStride: number, colStride: number, batch: number, - y: number, x: number, channel: number, fillValue: number): number { - const ind = batch * batchStride + y * rowStride + x * colStride + channel; - if (0 <= y && y < imageHeight && 0 <= x && x < imageWidth) { - return imageVals[ind]; - } else { - return fillValue; - } -} - -function nearestInterpolation( - imageVals: TypedArray, imageHeight: number, imageWidth: number, - batchStride: number, rowStride: number, colStride: number, batch: number, - y: number, x: number, channel: number, fillValue: number): number { - const $y = Math.round(y); - const $x = Math.round(x); - - return readWithFillValue( - imageVals, imageHeight, imageWidth, batchStride, rowStride, colStride, - batch, $y, $x, channel, fillValue); -} - -function bilinearInterpolation( - imageVals: TypedArray, imageHeight: number, imageWidth: number, - batchStride: number, rowStride: number, colStride: number, batch: number, - y: number, x: number, channel: number, fillValue: number) { - const yFloor = Math.floor(y); - const xFloor = Math.floor(x); - const yCeil = yFloor + 1; - const xCeil = xFloor + 1; - // f(x, yFloor) = (xCeil - x) / (xCeil - xFloor) * f(xFloor, yFloor) - // + (x - xFloor) / (xCeil - xFloor) * f(xCeil, yFloor) - const valueYFloor = - (xCeil - x) * - readWithFillValue( - imageVals, imageHeight, imageWidth, batchStride, rowStride, - colStride, batch, yFloor, xFloor, channel, fillValue) + - (x - xFloor) * - readWithFillValue( - imageVals, imageHeight, imageWidth, batchStride, rowStride, - colStride, batch, yFloor, xCeil, channel, fillValue); - // f(x, yCeil) = (xCeil - x) / (xCeil - xFloor) * f(xFloor, yCeil) - // + (x - xFloor) / (xCeil - xFloor) * f(xCeil, yCeil) - const valueYCeil = - (xCeil - x) * - readWithFillValue( - imageVals, imageHeight, imageWidth, batchStride, rowStride, - colStride, batch, yCeil, xFloor, channel, fillValue) + - (x - xFloor) * - readWithFillValue( - imageVals, imageHeight, imageWidth, batchStride, rowStride, - colStride, batch, yCeil, xCeil, channel, fillValue); - // f(x, y) = (yCeil - y) / (yCeil - yFloor) * f(x, yFloor) - // + (y - yFloor) / (yCeil - yFloor) * f(x, yCeil) - return (yCeil - y) * valueYFloor + (y - yFloor) * valueYCeil; -} diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Transpose.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Transpose.ts deleted file mode 100644 index 06a1fbf5a..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Transpose.ts +++ /dev/null @@ -1,54 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, TensorInfo, Transpose, TransposeAttrs, TransposeInputs, TypedArray} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; -import {assertNotComplex} from '../cpu_util'; - -import {transposeImpl} from './Transpose_impl'; - -export function transpose(args: { - inputs: TransposeInputs, - attrs: TransposeAttrs, - backend: MathBackendCPU -}): TensorInfo { - const {inputs, attrs, backend} = args; - const {x} = inputs; - const {perm} = attrs; - - assertNotComplex(x, 'transpose'); - - const xRank = x.shape.length; - - const newShape: number[] = new Array(xRank); - for (let i = 0; i < newShape.length; i++) { - newShape[i] = x.shape[perm[i]]; - } - - const values = backend.data.get(x.dataId).values as TypedArray; - const result = transposeImpl(values, x.shape, x.dtype, perm, newShape); - - const dataId = backend.write(result, newShape, x.dtype); - return {dataId, shape: newShape, dtype: x.dtype}; -} - -export const transposeConfig: KernelConfig = { - kernelName: Transpose, - backendName: 'cpu', - kernelFunc: transpose as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Transpose_impl.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Transpose_impl.ts deleted file mode 100644 index ffa2afa88..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Transpose_impl.ts +++ /dev/null @@ -1,45 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {DataType, NumericDataType, TypedArray} from '@tensorflow/tfjs-core'; -import {util} from '@tensorflow/tfjs-core'; - -export function transposeImpl( - xVals: TypedArray, xShape: number[], dtype: DataType, perm: number[], - newShape: number[]): TypedArray { - const xRank = xShape.length; - const xSize = util.sizeFromShape(xShape); - const xStrides = util.computeStrides(xShape); - const newStrides = util.computeStrides(newShape); - - const result = util.getTypedArrayFromDType( - dtype as NumericDataType, util.sizeFromShape(newShape)); - - for (let i = 0; i < xSize; ++i) { - const loc = util.indexToLoc(i, xRank, xStrides); - - // Permute location. - const newLoc: number[] = new Array(loc.length); - for (let i = 0; i < newLoc.length; i++) { - newLoc[i] = loc[perm[i]]; - } - - const newIndex = util.locToIndex(newLoc, xRank, newStrides); - result[newIndex] = xVals[i]; - } - return result; -} diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Unique.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Unique.ts deleted file mode 100644 index f0dd50fcb..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Unique.ts +++ /dev/null @@ -1,46 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, TensorInfo, Unique, UniqueAttrs, UniqueInputs} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; -import {assertNotComplex} from '../cpu_util'; - -import {uniqueImpl} from './Unique_impl'; - -export function unique( - args: {inputs: UniqueInputs, attrs: UniqueAttrs, backend: MathBackendCPU}): - TensorInfo[] { - const {inputs, attrs, backend} = args; - const {axis} = attrs; - const {x} = inputs; - assertNotComplex(x, 'unique'); - - const values = backend.data.get(x.dataId).values; - const {outputValues, outputShape, indices} = - uniqueImpl(values, axis, x.shape, x.dtype); - return [ - backend.makeTensorInfo(outputShape, x.dtype, outputValues), - backend.makeTensorInfo([indices.length], 'int32', indices), - ]; -} - -export const uniqueConfig: KernelConfig = { - kernelName: Unique, - backendName: 'cpu', - kernelFunc: unique as unknown as KernelFunc, -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Unique_impl.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Unique_impl.ts deleted file mode 100644 index ab9bfd171..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Unique_impl.ts +++ /dev/null @@ -1,157 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {BackendValues, DataType, TensorBuffer, TypedArray, util} from '@tensorflow/tfjs-core'; - -export function uniqueImpl( - values: BackendValues, axis: number, shape: number[], dtype: DataType): { - outputValues: BackendValues, - outputShape: number[], - indices: BackendValues -} { - // Normalize and validate axis. - const $axis = util.parseAxisParam(axis, shape)[0]; - - // Calculate the new shape that is suitable for extracting data along the - // given axis. - // - // The rank is 3. - // The size of the 1st dimension is the size of all the axes < the given axis. - // The size of the 2nd dimension is the same as the size of the given axis. - // The size of the 3rd dimension is the size of all the axes > the given axis. - // - // For example, for a 4D tensor with shape=[2, 3, 5, 4] and axis=2, the - // newShape would be: [2*3, 5, 4]. - // - // Note that this is not the final output shape. This will be the shape for an - // intermediate TensorBuffer (see inputBuffer below) to allow us to extract - // values along the given axis. To demonstrate how it works, consider the - // following example: - // - // Input: a 3D tensor, with shape [1, 2, 3] - // [ - // [ - // [1,2,3], - // [4,5,6] - // ] - // ] - // Axis: 2 (the last axis). - // Along axis 2, we expect to extract 3 tensors: [1,4], [2,5], [3,6]. - // - // For this example, newShape would be: [2, 3, 1], where 2 is calculated from - // 1*2. The re-shaped data would look like: - // - // [ - // [ - // [1], [2], [3] - // ], - // [ - // [4], [5], [6] - // ] - // ] - // - // Then, we can construct a 3-level nested loop by the following dimension - // order to extract the values along the axis (dimension1): - // i: dimension1 // 0,1,2 (newShape[1]) - // m: dimension0 // 0,1 (newShape[0]) - // n: dimension2 // 0 (newShape[2]) - // - // m, i, n - // --------- - // Iteration 0: data at [0, 0, 0] => "1" - // Iteration 1: data at [1, 0, 0] => "4" - // We got [1,4]. - // Iteration 2: data at [0, 1, 0] => "2" - // Iteration 3: data at [1, 1, 0] => "5" - // We got [2,5]. - // Iteration 4: data at [0, 2, 0] => "3" - // Iteration 5: data at [1, 2, 0] => "6" - // We got [3,6]. - const newShape = [1, shape[0], 1]; - for (let i = 0; i < $axis; i++) { - newShape[0] *= shape[i]; - } - newShape[1] = shape[$axis]; - for (let i = $axis + 1; i < shape.length; i++) { - newShape[2] *= shape[i]; - } - - // A map from unique elements (their string representations) to their values - // in "indices" (below). - const uniqueElements = new Map(); - // The indices of each unique element in the original tensor along the given - // axis. It is 1D and has the same size as the given axis. - const indices = new Int32Array(shape[$axis]); - // Create a buffer so we can easily extract value at a given location. - const inputBuffer = new TensorBuffer(newShape, dtype, values as TypedArray); - // The indices along the given axis that have unique elements. This is a - // de-duped version of "indices" above. - const uniqueIndices: number[] = []; - const is1DTensor = newShape[0] === 1 && newShape[2] === 1; - for (let i = 0; i < shape[$axis]; i++) { - // Extract values along the axis. - let element: string; - if (is1DTensor) { - // Fast path for 1D tensor input. - element = values[i].toString(); - } else { - const axisValues = []; - for (let m = 0; m < newShape[0]; m++) { - for (let n = 0; n < newShape[2]; n++) { - axisValues.push(inputBuffer.get(m, i, n)); - } - } - element = axisValues.join(','); - } - - // Dedup and update various indices. - const existingIndex = uniqueElements.get(element); - if (existingIndex != null) { - indices[i] = existingIndex; - } else { - const uniqueIndex = uniqueElements.size; - uniqueElements.set(element, uniqueIndex); - indices[i] = uniqueIndex; - uniqueIndices.push(i); - } - } - - // Now we know where each of the unique elements are located along the axis - // (uniqueIndices). Extract them from input buffer and store them in the - // output buffer. - const outputTmpShape = newShape.slice(); - outputTmpShape[1] = uniqueElements.size; - const outputBuffer = new TensorBuffer(outputTmpShape, dtype); - uniqueIndices.forEach((uniqueElementIndex, i) => { - for (let m = 0; m < newShape[0]; m++) { - for (let n = 0; n < newShape[2]; n++) { - outputBuffer.set(inputBuffer.get(m, uniqueElementIndex, n), m, i, n); - } - } - }); - - // The output shape can be calculated from the input shape with the size of - // the given axis replaced by the number of unique elements along that axis. - const outputShape = shape.slice(); - outputShape[$axis] = outputTmpShape[1]; - - return { - outputValues: outputBuffer.values as BackendValues, - outputShape, - indices, - }; -} diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/Unpack.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/Unpack.ts deleted file mode 100644 index 3f0637bf1..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/Unpack.ts +++ /dev/null @@ -1,64 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, TensorInfo, Unpack, UnpackAttrs, UnpackInputs} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; -import {reshape} from './Reshape'; -import {slice} from './Slice'; - -export function unpack( - args: {inputs: UnpackInputs, backend: MathBackendCPU, attrs: UnpackAttrs}): - TensorInfo[] { - const {inputs, backend, attrs} = args; - const {value} = inputs; - let {axis} = attrs; - - if (axis < 0) { - axis += value.shape.length; - } - - const valueRank = value.shape.length; - - const num = value.shape[axis]; - const outShape: number[] = new Array(valueRank - 1); - let outIndex = 0; - for (let i = 0; i < valueRank; i++) { - if (i !== axis) { - outShape[outIndex++] = value.shape[i]; - } - } - - const begin = new Array(valueRank).fill(0); - const size = value.shape.slice(); - size[axis] = 1; - const res = new Array(num); - for (let i = 0; i < res.length; i++) { - begin[axis] = i; - const tempRes = slice({inputs: {x: value}, backend, attrs: {begin, size}}); - res[i] = reshape({inputs: {x: tempRes}, backend, attrs: {shape: outShape}}); - backend.disposeIntermediateTensorInfo(tempRes); - } - - return res; -} - -export const unpackConfig: KernelConfig = { - kernelName: Unpack, - backendName: 'cpu', - kernelFunc: unpack as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/UnsortedSegmentSum.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/UnsortedSegmentSum.ts deleted file mode 100644 index aa0a80021..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/UnsortedSegmentSum.ts +++ /dev/null @@ -1,88 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, TensorInfo, UnsortedSegmentSum, UnsortedSegmentSumAttrs, UnsortedSegmentSumInputs, util} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; -import {assertNotComplex} from '../cpu_util'; -import {cast} from './Cast'; -import {equal} from './Equal'; -import {expandDims} from './ExpandDims'; -import {multiply} from './Multiply'; -import {pack} from './Pack'; -import {sum} from './Sum'; - -export function unsortedSegmentSum(args: { - inputs: UnsortedSegmentSumInputs, - backend: MathBackendCPU, - attrs: UnsortedSegmentSumAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {x, segmentIds} = inputs; - const {numSegments} = attrs; - - assertNotComplex(x, 'unsortedSegmentSum'); - - const xRank = x.shape.length; - const segmentIdsRank = segmentIds.shape.length; - const res = []; - const intermediates: TensorInfo[] = []; - - // Reshape the segment id's so that they can be broadcast with - // x. The new shape should be [segmentIds.shape, 1, ..., 1] - const numIters = xRank - segmentIdsRank; - let $segmentIds = segmentIds; - - for (let i = 0; i < numIters; ++i) { - const expanded = expandDims( - {inputs: {input: $segmentIds}, backend, attrs: {dim: i + 1}}); - $segmentIds = expanded; - intermediates.push(expanded); - } - - for (let i = 0; i < numSegments; ++i) { - const scalarValue = util.createScalarValue( - i as unknown as 'int32', 'int32'); - const segmentId = backend.makeTensorInfo([], 'int32', scalarValue); - const mask = - equal({inputs: {a: segmentId, b: $segmentIds}, backend}) as TensorInfo; - const maskCasted = - cast({inputs: {x: mask}, backend, attrs: {dtype: 'float32'}}); - const mul = - multiply({inputs: {a: maskCasted, b: x}, backend}) as TensorInfo; - const sumTensorInfo = - sum({inputs: {x: mul}, backend, attrs: {axis: 0, keepDims: false}}); - res.push(sumTensorInfo); - intermediates.push(segmentId); - intermediates.push(mask); - intermediates.push(maskCasted); - intermediates.push(mul); - intermediates.push(sumTensorInfo); - } - - const result = pack({inputs: res, backend, attrs: {axis: 0}}); - - intermediates.forEach(t => backend.disposeIntermediateTensorInfo(t)); - - return result; -} - -export const unsortedSegmentSumConfig: KernelConfig = { - kernelName: UnsortedSegmentSum, - backendName: 'cpu', - kernelFunc: unsortedSegmentSum as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/ZerosLike.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/ZerosLike.ts deleted file mode 100644 index 2a13ff9e6..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/ZerosLike.ts +++ /dev/null @@ -1,57 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, TensorInfo, ZerosLike, ZerosLikeInputs} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; - -import {complex} from './Complex'; -import {fill} from './Fill'; -import {imag} from './Imag'; -import {real} from './Real'; - -export function zerosLike( - args: {inputs: ZerosLikeInputs, backend: MathBackendCPU}): TensorInfo { - const {inputs, backend} = args; - const {x} = inputs; - - if (x.dtype === 'string') { - throw new Error('zerosLike is not supported for string tensors'); - } else if (x.dtype === 'complex64') { - const realPart = real({inputs: {input: x}, backend}); - const r = zerosLike({inputs: {x: realPart}, backend}); - const imagPart = imag({inputs: {input: x}, backend}); - const i = zerosLike({inputs: {x: imagPart}, backend}); - - const result = complex({inputs: {real: r, imag: i}, backend}); - - backend.disposeIntermediateTensorInfo(realPart); - backend.disposeIntermediateTensorInfo(r); - backend.disposeIntermediateTensorInfo(imagPart); - backend.disposeIntermediateTensorInfo(i); - - return result; - } else { - return fill({backend, attrs: {shape: x.shape, value: 0, dtype: x.dtype}}); - } -} - -export const zerosLikeConfig: KernelConfig = { - kernelName: ZerosLike, - backendName: 'cpu', - kernelFunc: zerosLike as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/kernels/_FusedMatMul.ts b/tfjs-master/tfjs-backend-cpu/src/kernels/_FusedMatMul.ts deleted file mode 100644 index d493d97a9..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/kernels/_FusedMatMul.ts +++ /dev/null @@ -1,68 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {_FusedMatMul, _FusedMatMulAttrs, _FusedMatMulInputs, KernelConfig, KernelFunc, TensorInfo} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; -import {applyActivation} from '../utils/fused_utils'; - -import {add} from './Add'; -import {batchMatMul} from './BatchMatMul'; - -export function _fusedMatMul(args: { - inputs: _FusedMatMulInputs, - attrs: _FusedMatMulAttrs, - backend: MathBackendCPU -}) { - const {inputs, backend, attrs} = args; - const {a, b, bias, preluActivationWeights} = inputs; - const {transposeA, transposeB, activation, leakyreluAlpha} = attrs; - - let current; - let addRes; - let activationRes; - - const intermediates: TensorInfo[] = []; - - const matMulRes = - batchMatMul({inputs: {a, b}, attrs: {transposeA, transposeB}, backend}); - current = matMulRes; - - if (bias) { - addRes = add({inputs: {a: current, b: bias}, backend}) as TensorInfo; - intermediates.push(current); - current = addRes; - } - if (activation) { - activationRes = applyActivation( - backend, current, activation, preluActivationWeights, leakyreluAlpha); - intermediates.push(current); - current = activationRes; - } - - for (const i of intermediates) { - backend.disposeIntermediateTensorInfo(i); - } - - return current; -} - -export const _fusedMatMulConfig: KernelConfig = { - kernelName: _FusedMatMul, - backendName: 'cpu', - kernelFunc: _fusedMatMul as unknown as KernelFunc, -}; diff --git a/tfjs-master/tfjs-backend-cpu/src/register_all_kernels.ts b/tfjs-master/tfjs-backend-cpu/src/register_all_kernels.ts deleted file mode 100644 index 60f61bfd1..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/register_all_kernels.ts +++ /dev/null @@ -1,373 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -// We explicitly import the modular kernels so they get registered in the -// global registry when we compile the library. A modular build would replace -// the contents of this file and import only the kernels that are needed. -import {KernelConfig, registerKernel} from '@tensorflow/tfjs-core'; - -import {_fusedMatMulConfig} from './kernels/_FusedMatMul'; -import {absConfig} from './kernels/Abs'; -import {acosConfig} from './kernels/Acos'; -import {acoshConfig} from './kernels/Acosh'; -import {addConfig} from './kernels/Add'; -import {addNConfig} from './kernels/AddN'; -import {allConfig} from './kernels/All'; -import {anyConfig} from './kernels/Any'; -import {argMaxConfig} from './kernels/ArgMax'; -import {argMinConfig} from './kernels/ArgMin'; -import {asinConfig} from './kernels/Asin'; -import {asinhConfig} from './kernels/Asinh'; -import {atanConfig} from './kernels/Atan'; -import {atan2Config} from './kernels/Atan2'; -import {atanhConfig} from './kernels/Atanh'; -import {avgPoolConfig} from './kernels/AvgPool'; -import {avgPool3DConfig} from './kernels/AvgPool3D'; -import {avgPool3DGradConfig} from './kernels/AvgPool3DGrad'; -import {avgPoolGradConfig} from './kernels/AvgPoolGrad'; -import {batchMatMulConfig} from './kernels/BatchMatMul'; -import {batchNormConfig} from './kernels/BatchNorm'; -import {batchToSpaceNDConfig} from './kernels/BatchToSpaceND'; -import {bincountConfig} from './kernels/Bincount'; -import {bitwiseAndConfig} from './kernels/BitwiseAnd'; -import {broadcastArgsConfig} from './kernels/BroadcastArgs'; -import {castConfig} from './kernels/Cast'; -import {ceilConfig} from './kernels/Ceil'; -import {clipByValueConfig} from './kernels/ClipByValue'; -import {complexConfig} from './kernels/Complex'; -import {complexAbsConfig} from './kernels/ComplexAbs'; -import {concatConfig} from './kernels/Concat'; -import {conv2DConfig} from './kernels/Conv2D'; -import {conv2DBackpropFilterConfig} from './kernels/Conv2DBackpropFilter'; -import {conv2DBackpropInputConfig} from './kernels/Conv2DBackpropInput'; -import {conv3DConfig} from './kernels/Conv3D'; -import {conv3DBackpropFilterV2Config} from './kernels/Conv3DBackpropFilterV2'; -import {conv3DBackpropInputV2Config} from './kernels/Conv3DBackpropInputV2'; -import {cosConfig} from './kernels/Cos'; -import {coshConfig} from './kernels/Cosh'; -import {cropAndResizeConfig} from './kernels/CropAndResize'; -import {cumprodConfig} from './kernels/Cumprod'; -import {cumsumConfig} from './kernels/Cumsum'; -import {denseBincountConfig} from './kernels/DenseBincount'; -import {depthToSpaceConfig} from './kernels/DepthToSpace'; -import {depthwiseConv2dNativeConfig} from './kernels/DepthwiseConv2dNative'; -import {depthwiseConv2dNativeBackpropFilterConfig} from './kernels/DepthwiseConv2dNativeBackpropFilter'; -import {depthwiseConv2dNativeBackpropInputConfig} from './kernels/DepthwiseConv2dNativeBackpropInput'; -import {diagConfig} from './kernels/Diag'; -import {dilation2DConfig} from './kernels/Dilation2D'; -import {dilation2DBackpropFilterConfig} from './kernels/Dilation2DBackpropFilter'; -import {dilation2DBackpropInputConfig} from './kernels/Dilation2DBackpropInput'; -import {drawConfig} from './kernels/Draw'; -import {einsumConfig} from './kernels/Einsum'; -import {eluConfig} from './kernels/Elu'; -import {eluGradConfig} from './kernels/EluGrad'; -import {equalConfig} from './kernels/Equal'; -import {erfConfig} from './kernels/Erf'; -import {expConfig} from './kernels/Exp'; -import {expandDimsConfig} from './kernels/ExpandDims'; -import {expm1Config} from './kernels/Expm1'; -import {fftConfig} from './kernels/FFT'; -import {fillConfig} from './kernels/Fill'; -import {flipLeftRightConfig} from './kernels/FlipLeftRight'; -import {floorConfig} from './kernels/Floor'; -import {floorDivConfig} from './kernels/FloorDiv'; -import {fusedConv2DConfig} from './kernels/FusedConv2D'; -import {fusedDepthwiseConv2DConfig} from './kernels/FusedDepthwiseConv2D'; -import {gatherNdConfig} from './kernels/GatherNd'; -import {gatherV2Config} from './kernels/GatherV2'; -import {greaterConfig} from './kernels/Greater'; -import {greaterEqualConfig} from './kernels/GreaterEqual'; -import {identityConfig} from './kernels/Identity'; -import {ifftConfig} from './kernels/IFFT'; -import {imagConfig} from './kernels/Imag'; -import {isFiniteConfig} from './kernels/IsFinite'; -import {isInfConfig} from './kernels/IsInf'; -import {isNaNConfig} from './kernels/IsNaN'; -import {leakyReluConfig} from './kernels/LeakyRelu'; -import {lessConfig} from './kernels/Less'; -import {lessEqualConfig} from './kernels/LessEqual'; -import {linSpaceConfig} from './kernels/LinSpace'; -import {logConfig} from './kernels/Log'; -import {log1pConfig} from './kernels/Log1p'; -import {logicalAndConfig} from './kernels/LogicalAnd'; -import {logicalNotConfig} from './kernels/LogicalNot'; -import {logicalOrConfig} from './kernels/LogicalOr'; -import {LRNConfig} from './kernels/LRN'; -import {LRNGradConfig} from './kernels/LRNGrad'; -import {maxConfig} from './kernels/Max'; -import {maximumConfig} from './kernels/Maximum'; -import {maxPoolConfig} from './kernels/MaxPool'; -import {maxPool3DConfig} from './kernels/MaxPool3D'; -import {maxPool3DGradConfig} from './kernels/MaxPool3DGrad'; -import {maxPoolGradConfig} from './kernels/MaxPoolGrad'; -import {maxPoolWithArgmaxConfig} from './kernels/MaxPoolWithArgmax'; -import {meanConfig} from './kernels/Mean'; -import {minConfig} from './kernels/Min'; -import {minimumConfig} from './kernels/Minimum'; -import {mirrorPadConfig} from './kernels/MirrorPad'; -import {modConfig} from './kernels/Mod'; -import {multinomialConfig} from './kernels/Multinomial'; -import {multiplyConfig} from './kernels/Multiply'; -import {negConfig} from './kernels/Neg'; -import {nonMaxSuppressionV3Config} from './kernels/NonMaxSuppressionV3'; -import {nonMaxSuppressionV4Config} from './kernels/NonMaxSuppressionV4'; -import {nonMaxSuppressionV5Config} from './kernels/NonMaxSuppressionV5'; -import {notEqualConfig} from './kernels/NotEqual'; -import {oneHotConfig} from './kernels/OneHot'; -import {onesLikeConfig} from './kernels/OnesLike'; -import {packConfig} from './kernels/Pack'; -import {padV2Config} from './kernels/PadV2'; -import {powConfig} from './kernels/Pow'; -import {preluConfig} from './kernels/Prelu'; -import {prodConfig} from './kernels/Prod'; -import {raggedGatherConfig} from './kernels/RaggedGather'; -import {raggedRangeConfig} from './kernels/RaggedRange'; -import {raggedTensorToTensorConfig} from './kernels/RaggedTensorToTensor'; -import {rangeConfig} from './kernels/Range'; -import {realConfig} from './kernels/Real'; -import {realDivConfig} from './kernels/RealDiv'; -import {reciprocalConfig} from './kernels/Reciprocal'; -import {reluConfig} from './kernels/Relu'; -import {relu6Config} from './kernels/Relu6'; -import {reshapeConfig} from './kernels/Reshape'; -import {resizeBilinearConfig} from './kernels/ResizeBilinear'; -import {resizeBilinearGradConfig} from './kernels/ResizeBilinearGrad'; -import {resizeNearestNeighborConfig} from './kernels/ResizeNearestNeighbor'; -import {resizeNearestNeighborGradConfig} from './kernels/ResizeNearestNeighborGrad'; -import {reverseConfig} from './kernels/Reverse'; -import {rotateWithOffsetConfig} from './kernels/RotateWithOffset'; -import {roundConfig} from './kernels/Round'; -import {rsqrtConfig} from './kernels/Rsqrt'; -import {scatterNdConfig} from './kernels/ScatterNd'; -import {searchSortedConfig} from './kernels/SearchSorted'; -import {selectConfig} from './kernels/Select'; -import {seluConfig} from './kernels/Selu'; -import {sigmoidConfig} from './kernels/Sigmoid'; -import {signConfig} from './kernels/Sign'; -import {sinConfig} from './kernels/Sin'; -import {sinhConfig} from './kernels/Sinh'; -import {sliceConfig} from './kernels/Slice'; -import {softmaxConfig} from './kernels/Softmax'; -import {softplusConfig} from './kernels/Softplus'; -import {spaceToBatchNDConfig} from './kernels/SpaceToBatchND'; -import {sparseFillEmptyRowsConfig} from './kernels/SparseFillEmptyRows'; -import {sparseReshapeConfig} from './kernels/SparseReshape'; -import {sparseSegmentMeanConfig} from './kernels/SparseSegmentMean'; -import {sparseSegmentSumConfig} from './kernels/SparseSegmentSum'; -import {sparseToDenseConfig} from './kernels/SparseToDense'; -import {splitVConfig} from './kernels/SplitV'; -import {sqrtConfig} from './kernels/Sqrt'; -import {squareConfig} from './kernels/Square'; -import {squaredDifferenceConfig} from './kernels/SquaredDifference'; -import {staticRegexReplaceConfig} from './kernels/StaticRegexReplace'; -import {stepConfig} from './kernels/Step'; -import {stridedSliceConfig} from './kernels/StridedSlice'; -import {stringNGramsConfig} from './kernels/StringNGrams'; -import {stringSplitConfig} from './kernels/StringSplit'; -import {stringToHashBucketFastConfig} from './kernels/StringToHashBucketFast'; -import {subConfig} from './kernels/Sub'; -import {sumConfig} from './kernels/Sum'; -import {tanConfig} from './kernels/Tan'; -import {tanhConfig} from './kernels/Tanh'; -import {tensorScatterUpdateConfig} from './kernels/TensorScatterUpdate'; -import {tileConfig} from './kernels/Tile'; -import {topKConfig} from './kernels/TopK'; -import {transformConfig} from './kernels/Transform'; -import {transposeConfig} from './kernels/Transpose'; -import {uniqueConfig} from './kernels/Unique'; -import {unpackConfig} from './kernels/Unpack'; -import {unsortedSegmentSumConfig} from './kernels/UnsortedSegmentSum'; -import {zerosLikeConfig} from './kernels/ZerosLike'; - -// List all kernel configs here -const kernelConfigs: KernelConfig[] = [ - _fusedMatMulConfig, - absConfig, - acosConfig, - acoshConfig, - addConfig, - addNConfig, - allConfig, - anyConfig, - argMaxConfig, - argMinConfig, - asinConfig, - asinhConfig, - atanConfig, - atan2Config, - atanhConfig, - avgPoolConfig, - avgPool3DConfig, - avgPool3DGradConfig, - avgPoolGradConfig, - batchMatMulConfig, - batchNormConfig, - batchToSpaceNDConfig, - bincountConfig, - bitwiseAndConfig, - broadcastArgsConfig, - castConfig, - ceilConfig, - clipByValueConfig, - complexConfig, - complexAbsConfig, - concatConfig, - conv2DConfig, - conv2DBackpropFilterConfig, - conv2DBackpropInputConfig, - conv3DConfig, - conv3DBackpropFilterV2Config, - conv3DBackpropInputV2Config, - cosConfig, - coshConfig, - cropAndResizeConfig, - cumprodConfig, - cumsumConfig, - denseBincountConfig, - depthToSpaceConfig, - depthwiseConv2dNativeConfig, - depthwiseConv2dNativeBackpropFilterConfig, - depthwiseConv2dNativeBackpropInputConfig, - diagConfig, - dilation2DConfig, - dilation2DBackpropFilterConfig, - dilation2DBackpropInputConfig, - drawConfig, - einsumConfig, - eluConfig, - eluGradConfig, - equalConfig, - erfConfig, - expConfig, - expandDimsConfig, - expm1Config, - fftConfig, - fillConfig, - flipLeftRightConfig, - floorConfig, - floorDivConfig, - fusedConv2DConfig, - fusedDepthwiseConv2DConfig, - gatherNdConfig, - gatherV2Config, - greaterConfig, - greaterEqualConfig, - identityConfig, - ifftConfig, - imagConfig, - isFiniteConfig, - isInfConfig, - isNaNConfig, - leakyReluConfig, - lessConfig, - lessEqualConfig, - linSpaceConfig, - logConfig, - log1pConfig, - logicalAndConfig, - logicalNotConfig, - logicalOrConfig, - LRNConfig, - LRNGradConfig, - maxConfig, - maximumConfig, - maxPoolConfig, - maxPool3DConfig, - maxPool3DGradConfig, - maxPoolGradConfig, - maxPoolWithArgmaxConfig, - meanConfig, - minConfig, - minimumConfig, - mirrorPadConfig, - modConfig, - multinomialConfig, - multiplyConfig, - negConfig, - nonMaxSuppressionV3Config, - nonMaxSuppressionV4Config, - nonMaxSuppressionV5Config, - notEqualConfig, - oneHotConfig, - onesLikeConfig, - packConfig, - padV2Config, - powConfig, - preluConfig, - prodConfig, - raggedGatherConfig, - raggedRangeConfig, - raggedTensorToTensorConfig, - rangeConfig, - realConfig, - realDivConfig, - reciprocalConfig, - reluConfig, - relu6Config, - reshapeConfig, - resizeBilinearConfig, - resizeBilinearGradConfig, - resizeNearestNeighborConfig, - resizeNearestNeighborGradConfig, - reverseConfig, - rotateWithOffsetConfig, - roundConfig, - rsqrtConfig, - scatterNdConfig, - searchSortedConfig, - selectConfig, - seluConfig, - sigmoidConfig, - signConfig, - sinConfig, - sinhConfig, - sliceConfig, - softmaxConfig, - softplusConfig, - spaceToBatchNDConfig, - sparseFillEmptyRowsConfig, - sparseReshapeConfig, - sparseSegmentMeanConfig, - sparseSegmentSumConfig, - sparseToDenseConfig, - splitVConfig, - sqrtConfig, - squareConfig, - squaredDifferenceConfig, - staticRegexReplaceConfig, - stepConfig, - stridedSliceConfig, - stringNGramsConfig, - stringSplitConfig, - stringToHashBucketFastConfig, - subConfig, - sumConfig, - tanConfig, - tanhConfig, - tensorScatterUpdateConfig, - tileConfig, - topKConfig, - transformConfig, - transposeConfig, - uniqueConfig, - unpackConfig, - unsortedSegmentSumConfig, - zerosLikeConfig -]; - -for (const kernelConfig of kernelConfigs) { - registerKernel(kernelConfig); -} diff --git a/tfjs-master/tfjs-backend-cpu/src/run_tests.ts b/tfjs-master/tfjs-backend-cpu/src/run_tests.ts deleted file mode 100644 index ff56ee4da..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/run_tests.ts +++ /dev/null @@ -1,57 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// Register the backend. -import './index'; -// tslint:disable-next-line: no-imports-from-dist -import '@tensorflow/tfjs-core/dist/public/chained_ops/register_all_chained_ops'; -// tslint:disable-next-line: no-imports-from-dist -import '@tensorflow/tfjs-core/dist/register_all_gradients'; -// tslint:disable-next-line: no-imports-from-dist -import {setTestEnvs, setupTestFilters, TestFilter} from '@tensorflow/tfjs-core/dist/jasmine_util'; - -// tslint:disable-next-line:no-require-imports -const jasmineCtor = require('jasmine'); -// tslint:disable-next-line:no-require-imports - -Error.stackTraceLimit = Infinity; - -process.on('unhandledRejection', e => { - throw e; -}); - -setTestEnvs([{name: 'cpu', backendName: 'cpu', isDataSync: true}]); - -const coreTests = 'tfjs-core/src/tests.js'; -const cpuTests = 'tfjs-backend-cpu/src/**/*_test.js'; - -const runner = new jasmineCtor(); -runner.loadConfig({spec_files: [cpuTests, coreTests], random: false}); - -const TEST_FILTERS: TestFilter[] = []; -const customInclude = (testName: string) => { - // Exclude webworker test - if (testName.includes('computation in worker')) { - return false; - } - - // Include all other tests. - return true; -}; -setupTestFilters(TEST_FILTERS, customInclude); - -runner.execute(); diff --git a/tfjs-master/tfjs-backend-cpu/src/setup_test.ts b/tfjs-master/tfjs-backend-cpu/src/setup_test.ts deleted file mode 100644 index 13d720a55..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/setup_test.ts +++ /dev/null @@ -1,50 +0,0 @@ -/** - * @license - * Copyright 2023 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import '@tensorflow/tfjs-backend-cpu'; -// Register the backend. -import './index'; -// tslint:disable-next-line: no-imports-from-dist -import '@tensorflow/tfjs-core/dist/public/chained_ops/register_all_chained_ops'; -// tslint:disable-next-line: no-imports-from-dist -import '@tensorflow/tfjs-core/dist/register_all_gradients'; - -// tslint:disable-next-line: no-imports-from-dist -import {parseTestEnvFromKarmaFlags, setTestEnvs, setupTestFilters, TEST_ENVS, TestFilter} from '@tensorflow/tfjs-core/dist/jasmine_util'; - -setTestEnvs([{name: 'cpu', backendName: 'cpu', isDataSync: true}]); - -const TEST_FILTERS: TestFilter[] = []; -const customInclude = (testName: string) => { - return true; -}; -setupTestFilters(TEST_FILTERS, customInclude); - -// Allow flags to override test envs -// tslint:disable-next-line:no-any -declare let __karma__: any; -if (typeof __karma__ !== 'undefined') { - const testEnv = parseTestEnvFromKarmaFlags(__karma__.config.args, TEST_ENVS); - if (testEnv != null) { - setTestEnvs([testEnv]); - } -} - -// Import and run tests from cpu. -// tslint:disable-next-line:no-imports-from-dist -// tslint:disable-next-line:no-require-imports -require('./tests'); diff --git a/tfjs-master/tfjs-backend-cpu/src/shared.ts b/tfjs-master/tfjs-backend-cpu/src/shared.ts deleted file mode 100644 index 23b6cfdb3..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/shared.ts +++ /dev/null @@ -1,69 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// Shared functionality among backends. -export {simpleAbsImpl} from './kernels/Abs'; -export {addImpl} from './kernels/Add'; -export {bincountImpl, bincountReduceImpl} from './kernels/Bincount_impl'; -export {bitwiseAndImpl} from './kernels/BitwiseAnd'; -export {castImpl} from './kernels/Cast'; -export {ceilImpl} from './kernels/Ceil'; -export {concatImpl} from './kernels/Concat_impl'; -export {equalImpl} from './kernels/Equal'; -export {expImpl} from './kernels/Exp'; -export {expm1Impl} from './kernels/Expm1'; -export {floorImpl} from './kernels/Floor'; -export {floorDivImpl} from './kernels/FloorDiv'; -export {gatherNdImpl} from './kernels/GatherNd_Impl'; -export {gatherV2Impl} from './kernels/GatherV2_impl'; -export {greaterImpl} from './kernels/Greater'; -export {greaterEqualImpl} from './kernels/GreaterEqual'; -export {lessImpl} from './kernels/Less'; -export {lessEqualImpl} from './kernels/LessEqual'; -export {linSpaceImpl} from './kernels/LinSpace_impl'; -export {logImpl} from './kernels/Log'; -export {maxImpl} from './kernels/Max_impl'; -export {maximumImpl} from './kernels/Maximum'; -export {minimumImpl} from './kernels/Minimum'; -export {multiplyImpl} from './kernels/Multiply'; -export {negImpl} from './kernels/Neg'; -export {notEqualImpl} from './kernels/NotEqual'; -export {prodImpl} from './kernels/Prod'; -export {raggedGatherImpl} from './kernels/RaggedGather_impl'; -export {raggedRangeImpl} from './kernels/RaggedRange_impl'; -export {raggedTensorToTensorImpl} from './kernels/RaggedTensorToTensor_impl'; -export {rangeImpl} from './kernels/Range_impl'; -export {rsqrtImpl} from './kernels/Rsqrt'; -export {scatterImpl} from './kernels/Scatter_impl'; -export {sigmoidImpl} from './kernels/Sigmoid'; -export {sliceImpl} from './kernels/Slice'; -export {sparseFillEmptyRowsImpl} from './kernels/SparseFillEmptyRows_impl'; -export {sparseReshapeImpl} from './kernels/SparseReshape_impl'; -export {sparseSegmentReductionImpl} from './kernels/SparseSegmentReduction_impl'; -export {sqrtImpl} from './kernels/Sqrt'; -export {squaredDifferenceImpl} from './kernels/SquaredDifference'; -export {staticRegexReplaceImpl} from './kernels/StaticRegexReplace'; -export {stridedSliceImpl} from './kernels/StridedSlice_impl'; -export {stringNGramsImpl} from './kernels/StringNGrams_impl'; -export {stringSplitImpl} from './kernels/StringSplit_impl'; -export {stringToHashBucketFastImpl} from './kernels/StringToHashBucketFast_impl'; -export {subImpl} from './kernels/Sub'; -export {tileImpl} from './kernels/Tile_impl'; -export {topKImpl} from './kernels/TopK_impl'; -export {transposeImpl} from './kernels/Transpose_impl'; -export {uniqueImpl} from './kernels/Unique_impl'; -export {ComplexBinaryKernelImpl, SimpleBinaryKernelImpl} from './utils/binary_types'; diff --git a/tfjs-master/tfjs-backend-cpu/src/utils/binary_impl.ts b/tfjs-master/tfjs-backend-cpu/src/utils/binary_impl.ts deleted file mode 100644 index 79366bfe4..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/utils/binary_impl.ts +++ /dev/null @@ -1,69 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, DataType, DataValues, NumericDataType, TypedArray, util} from '@tensorflow/tfjs-core'; - -import {SimpleBinaryKernelImpl, SimpleBinaryOperation} from './binary_types'; - -/** - * Template that creates implementation for binary ops. Supports broadcast. - */ -export function createSimpleBinaryKernelImpl(op: SimpleBinaryOperation): - SimpleBinaryKernelImpl { - return (aShape: number[], bShape: number[], aVals: DataValues, - bVals: DataValues, dtype: DataType): [TypedArray, number[]] => { - const newShape = backend_util.assertAndGetBroadcastShape(aShape, bShape); - - const resultRank = newShape.length; - const resultStrides = util.computeStrides(newShape); - const resultSize = util.sizeFromShape(newShape); - - const result = - util.getTypedArrayFromDType(dtype as NumericDataType, resultSize); - - const aRank = aShape.length; - const bRank = bShape.length; - - const aStrides = util.computeStrides(aShape); - const bStrides = util.computeStrides(bShape); - - const aBroadcastDims = backend_util.getBroadcastDims(aShape, newShape); - const bBroadcastDims = backend_util.getBroadcastDims(bShape, newShape); - - if (aBroadcastDims.length + bBroadcastDims.length === 0) { - for (let i = 0; i < result.length; ++i) { - result[i] = op(aVals[i % aVals.length], bVals[i % bVals.length]); - } - } else { - for (let i = 0; i < result.length; ++i) { - const loc = util.indexToLoc(i, resultRank, resultStrides); - - const aLoc = loc.slice(-aRank); - aBroadcastDims.forEach(d => aLoc[d] = 0); - const aIndex = util.locToIndex(aLoc, aRank, aStrides); - - const bLoc = loc.slice(-bRank); - bBroadcastDims.forEach(d => bLoc[d] = 0); - const bIndex = util.locToIndex(bLoc, bRank, bStrides); - - result[i] = op(aVals[aIndex], bVals[bIndex]); - } - } - - return [result, newShape]; - }; -} diff --git a/tfjs-master/tfjs-backend-cpu/src/utils/binary_types.ts b/tfjs-master/tfjs-backend-cpu/src/utils/binary_types.ts deleted file mode 100644 index b0f74b2fc..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/utils/binary_types.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {DataType, TypedArray} from '@tensorflow/tfjs-core'; - -export type SimpleBinaryOperation = (a: number|string, b: number|string) => - number; -export type SimpleBinaryKernelImpl = - (aShape: number[], bShape: number[], aVals: TypedArray|string[], - bVals: TypedArray|string[], dtype: DataType) => [TypedArray, number[]]; -export type ComplexBinaryOperation = - (aReal: number, aImag: number, bReal: number, bImag: number) => { - real: number, imag: number - }; -export type ComplexBinaryKernelImpl = - (aShape: number[], bShape: number[], aRealVals: Float32Array, - aImagVals: Float32Array, bRealVals: Float32Array, - bImagVals: Float32Array) => [TypedArray, TypedArray, number[]]; diff --git a/tfjs-master/tfjs-backend-cpu/src/utils/binary_utils.ts b/tfjs-master/tfjs-backend-cpu/src/utils/binary_utils.ts deleted file mode 100644 index e9f116f1d..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/utils/binary_utils.ts +++ /dev/null @@ -1,194 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, BinaryInputs, DataType, KernelFunc, TypedArray, util} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; -import {assertNotComplex} from '../cpu_util'; -import {cast} from '../kernels/Cast'; -import {complex} from '../kernels/Complex'; - -import {ComplexBinaryKernelImpl, ComplexBinaryOperation, SimpleBinaryKernelImpl} from './binary_types'; - -/** - * Template that creates a `KernelFunc` for binary ops. - * @param name Kernel name. - * @param binaryKernelImpl A `SimpleBinaryKernelImpl` for the kernel. - * @param binaryKernelComplexImpl Optional. If exists, represents a - * `ComplexBinaryKernelImpl` for the kernel, will be used when input dtype - * is `complex64`. - * @param dtype Optional. If set, the result has this dtype. Otherwise, the - * result has the same dtype as the first input. This is mainly used in - * comparison kernels, such as Equal, Less, Greater, etc. - */ -export function binaryKernelFunc( - name: string, simpleImpl: SimpleBinaryKernelImpl, - complexImpl?: ComplexBinaryKernelImpl, dtype?: DataType): KernelFunc { - if (complexImpl == null) { - return ({inputs, backend}) => { - const {a, b} = inputs as BinaryInputs; - const cpuBackend = backend as MathBackendCPU; - - assertNotComplex([a, b], name); - - const aVals = cpuBackend.data.get(a.dataId).values as TypedArray; - const bVals = cpuBackend.data.get(b.dataId).values as TypedArray; - - const decodedAVals = a.dtype === 'string' ? - // tslint:disable-next-line: no-any - backend_util.fromUint8ToStringArray(aVals as any as Uint8Array[]) : - aVals; - const decodedBVals = a.dtype === 'string' ? - // tslint:disable-next-line: no-any - backend_util.fromUint8ToStringArray(bVals as any as Uint8Array[]) : - bVals; - const $dtype = dtype || a.dtype; - - const [resultData, resultShape] = - simpleImpl(a.shape, b.shape, decodedAVals, decodedBVals, $dtype); - - return cpuBackend.makeTensorInfo(resultShape, $dtype, resultData); - }; - } - - return ({inputs, backend}) => { - const {a, b} = inputs as BinaryInputs; - const cpuBackend = backend as MathBackendCPU; - - if (a.dtype === 'complex64' || b.dtype === 'complex64') { - const $aComplex = cast( - {inputs: {x: a}, backend: cpuBackend, attrs: {dtype: 'complex64'}}); - - const $aComplexVals = cpuBackend.data.get($aComplex.dataId); - - const aReal = $aComplexVals.complexTensorInfos.real; - const aImag = $aComplexVals.complexTensorInfos.imag; - - const aRealVals = - cpuBackend.data.get(aReal.dataId).values as Float32Array; - const aImagVals = - cpuBackend.data.get(aImag.dataId).values as Float32Array; - - const $bComplex = cast( - {inputs: {x: b}, backend: cpuBackend, attrs: {dtype: 'complex64'}}); - - const $bComplexVals = cpuBackend.data.get($bComplex.dataId); - - const bReal = $bComplexVals.complexTensorInfos.real; - const bImag = $bComplexVals.complexTensorInfos.imag; - - const bRealVals = - cpuBackend.data.get(bReal.dataId).values as Float32Array; - const bImagVals = - cpuBackend.data.get(bImag.dataId).values as Float32Array; - - const [resultRealData, resultImagData, resultShape] = complexImpl( - a.shape, b.shape, aRealVals, aImagVals, bRealVals, bImagVals); - - const resultReal = - cpuBackend.makeTensorInfo(resultShape, 'float32', resultRealData); - - const resultImag = - cpuBackend.makeTensorInfo(resultShape, 'float32', resultImagData); - - const result = complex( - {inputs: {real: resultReal, imag: resultImag}, backend: cpuBackend}); - - cpuBackend.disposeIntermediateTensorInfo($aComplex); - cpuBackend.disposeIntermediateTensorInfo($bComplex); - cpuBackend.disposeIntermediateTensorInfo(resultReal); - cpuBackend.disposeIntermediateTensorInfo(resultImag); - - return result; - } else { - const aVals = cpuBackend.data.get(a.dataId).values as TypedArray; - const bVals = cpuBackend.data.get(b.dataId).values as TypedArray; - - const $dtype = dtype || a.dtype; - - const [resultData, resultShape] = - simpleImpl(a.shape, b.shape, aVals, bVals, $dtype); - - return cpuBackend.makeTensorInfo(resultShape, $dtype, resultData); - } - }; -} - -/** - * Template that creates the complex type implementation for binary ops. - * Supports broadcast. - */ -export function createComplexBinaryKernelImpl(op: ComplexBinaryOperation): - ComplexBinaryKernelImpl { - return (aShape: number[], bShape: number[], aRealVals: Float32Array, - aImagVals: Float32Array, bRealVals: Float32Array, - bImagVals: Float32Array): [TypedArray, TypedArray, number[]] => { - const resultShape = backend_util.assertAndGetBroadcastShape(aShape, bShape); - const resultSize = util.sizeFromShape(resultShape); - const resultRank = resultShape.length; - const resultStrides = util.computeStrides(resultShape); - - const resultRealVals = util.getTypedArrayFromDType('float32', resultSize); - const resultImagVals = util.getTypedArrayFromDType('float32', resultSize); - - const aBroadcastDims = backend_util.getBroadcastDims(aShape, resultShape); - const bBroadcastDims = backend_util.getBroadcastDims(bShape, resultShape); - - const aVals = backend_util.mergeRealAndImagArrays(aRealVals, aImagVals); - const bVals = backend_util.mergeRealAndImagArrays(bRealVals, bImagVals); - - const aRank = aShape.length; - const aStrides = util.computeStrides(aShape); - - const bRank = bShape.length; - const bStrides = util.computeStrides(bShape); - - if (aBroadcastDims.length + bBroadcastDims.length === 0) { - for (let i = 0; i < resultRealVals.length; i++) { - const aIdx = i % aVals.length; - const bIdx = i % bVals.length; - - const result = - op(aVals[aIdx * 2], aVals[aIdx * 2 + 1], bVals[bIdx * 2], - bVals[bIdx * 2 + 1]); - - resultRealVals[i] = result.real; - resultImagVals[i] = result.imag; - } - } else { - for (let i = 0; i < resultRealVals.length; i++) { - const loc = util.indexToLoc(i, resultRank, resultStrides); - - const aLoc = loc.slice(-aRank); - aBroadcastDims.forEach(d => aLoc[d] = 0); - const aIndex = util.locToIndex(aLoc, aRank, aStrides); - - const bLoc = loc.slice(-bRank); - bBroadcastDims.forEach(d => bLoc[d] = 0); - const bIndex = util.locToIndex(bLoc, bRank, bStrides); - - const opResult = - op(aVals[aIndex * 2], aVals[aIndex * 2 + 1], bVals[bIndex * 2], - bVals[bIndex * 2 + 1]); - - resultRealVals[i] = opResult.real; - resultImagVals[i] = opResult.imag; - } - } - return [resultRealVals, resultImagVals, resultShape]; - }; -} diff --git a/tfjs-master/tfjs-backend-cpu/src/utils/fft_utils.ts b/tfjs-master/tfjs-backend-cpu/src/utils/fft_utils.ts deleted file mode 100644 index bf5250ad3..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/utils/fft_utils.ts +++ /dev/null @@ -1,339 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, Tensor, TensorInfo, TypedArray, util} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; -import {add} from '../kernels/Add'; -import {complex} from '../kernels/Complex'; -import {concat} from '../kernels/Concat'; -import {identity} from '../kernels/Identity'; -import {imag} from '../kernels/Imag'; -import {multiply} from '../kernels/Multiply'; -import {real} from '../kernels/Real'; -import {realDivConfig} from '../kernels/RealDiv'; -import {slice} from '../kernels/Slice'; -import {sub} from '../kernels/Sub'; - -/** - * Calculate FFT of inner most elements of batch tensor. - */ -export function fftBatch( - input: TensorInfo, inverse: boolean, - cpuBackend: MathBackendCPU): TensorInfo { - const inputShape = input.shape; - const batch = inputShape[0]; - const innerDim = inputShape[1]; - - const inputVals = cpuBackend.data.get(input.dataId); - - const real2D = inputVals.complexTensorInfos.real; - const imag2D = inputVals.complexTensorInfos.imag; - - // Collects real and imaginary values separately. - const resultShape = [batch, innerDim]; - const resultSize = util.sizeFromShape(resultShape); - const resultReal = util.getTypedArrayFromDType('float32', resultSize); - const resultImag = util.getTypedArrayFromDType('float32', resultSize); - - for (let b = 0; b < batch; b++) { - // TODO: Support slice ops for complex type. - const r = slice({ - inputs: {x: real2D}, - backend: cpuBackend, - attrs: {begin: [b, 0], size: [1, innerDim]} - }); - const i = slice({ - inputs: {x: imag2D}, - backend: cpuBackend, - attrs: {begin: [b, 0], size: [1, innerDim]} - }); - - const input = complex({inputs: {real: r, imag: i}, backend: cpuBackend}); - - // Run FFT by batch element. - const {real, imag} = fftImpl(input, inverse, cpuBackend); - const res = backend_util.mergeRealAndImagArrays(real, imag); - - for (let d = 0; d < innerDim; d++) { - const c = backend_util.getComplexWithIndex(res, d); - resultReal[b * innerDim + d] = c.real; - resultImag[b * innerDim + d] = c.imag; - } - - cpuBackend.disposeIntermediateTensorInfo(r); - cpuBackend.disposeIntermediateTensorInfo(i); - cpuBackend.disposeIntermediateTensorInfo(input); - } - - const $realInfo: TensorInfo = - cpuBackend.makeTensorInfo(resultShape, 'float32', resultReal); - const $imagInfo: TensorInfo = - cpuBackend.makeTensorInfo(resultShape, 'float32', resultImag); - - const result = complex( - {inputs: {real: $realInfo, imag: $imagInfo}, backend: cpuBackend}); - - cpuBackend.disposeIntermediateTensorInfo($realInfo); - cpuBackend.disposeIntermediateTensorInfo($imagInfo); - - return result; -} - -export function fftImpl( - input: TensorInfo, inverse: boolean, - cpuBackend: MathBackendCPU): {real: Float32Array, imag: Float32Array} { - const inputSize = util.sizeFromShape(input.shape); - - const inputVals = cpuBackend.data.get(input.dataId); - - const realVals = - cpuBackend.data.get(inputVals.complexTensorInfos.real.dataId).values as - Float32Array; - - const imagVals = - cpuBackend.data.get(inputVals.complexTensorInfos.imag.dataId).values as - Float32Array; - - if (isExponentOf2(inputSize)) { - const result = - fftRadix2(realVals, imagVals, inputSize, inverse, cpuBackend); - - const resultShape = [input.shape[0], input.shape[1]]; - - if (inverse) { - const realInfo: TensorInfo = - cpuBackend.makeTensorInfo(resultShape, 'float32', result.real); - const imagInfo: TensorInfo = - cpuBackend.makeTensorInfo(resultShape, 'float32', result.imag); - - const sizeInfo: TensorInfo = cpuBackend.makeTensorInfo( - [], 'float32', - util.createScalarValue(inputSize as unknown as 'float32', 'float32')); - const sizeInfoCopy = - identity({inputs: {x: sizeInfo}, backend: cpuBackend}); - - const divRealInfo = - realDivConfig.kernelFunc( - {inputs: {a: realInfo, b: sizeInfo}, backend: cpuBackend}) as - TensorInfo; - const divImagInfo = - realDivConfig.kernelFunc( - {inputs: {a: imagInfo, b: sizeInfoCopy}, backend: cpuBackend}) as - TensorInfo; - - const divRealVals = - cpuBackend.data.get(divRealInfo.dataId).values as Float32Array; - const divImagVals = - cpuBackend.data.get(divImagInfo.dataId).values as Float32Array; - - cpuBackend.disposeIntermediateTensorInfo(realInfo); - cpuBackend.disposeIntermediateTensorInfo(imagInfo); - cpuBackend.disposeIntermediateTensorInfo(sizeInfo); - cpuBackend.disposeIntermediateTensorInfo(sizeInfoCopy); - cpuBackend.disposeIntermediateTensorInfo(divRealInfo); - cpuBackend.disposeIntermediateTensorInfo(divImagInfo); - - return {real: divRealVals, imag: divImagVals}; - } - - return result; - } else { - const data = backend_util.mergeRealAndImagArrays(realVals, imagVals); - - const rawOutput = - fourierTransformByMatmul(data, inputSize, inverse) as Float32Array; - - return backend_util.splitRealAndImagArrays(rawOutput); - } -} - -function isExponentOf2(size: number): boolean { - return (size & size - 1) === 0; -} - -// FFT using Cooley-Tukey algorithm on radix 2 dimensional input. -function fftRadix2( - realVals: Float32Array, imagVals: Float32Array, size: number, - inverse: boolean, - cpuBackend: MathBackendCPU): {real: Float32Array, imag: Float32Array} { - if (size === 1) { - return {real: realVals, imag: imagVals}; - } - - const data = backend_util.mergeRealAndImagArrays(realVals, imagVals); - - const half = size / 2; - - const evenComplex = backend_util.complexWithEvenIndex(data); - - const evenRealVals = evenComplex.real; - const evenImagVals = evenComplex.imag; - - const evenShape = [evenRealVals.length]; - - const evenRealInfo = - cpuBackend.makeTensorInfo(evenShape, 'float32', evenRealVals); - const evenImagInfo = - cpuBackend.makeTensorInfo(evenShape, 'float32', evenImagVals); - - const evenTensorInfo = complex( - {inputs: {real: evenRealInfo, imag: evenImagInfo}, backend: cpuBackend}); - - const oddComplex = backend_util.complexWithOddIndex(data); - - const oddRealVals = oddComplex.real; - const oddImagVals = oddComplex.imag; - - const oddShape = [oddRealVals.length]; - - const oddRealInfo = - cpuBackend.makeTensorInfo(oddShape, 'float32', oddRealVals); - const oddImagInfo = - cpuBackend.makeTensorInfo(oddShape, 'float32', oddImagVals); - - const oddTensorInfo = complex( - {inputs: {real: oddRealInfo, imag: oddImagInfo}, backend: cpuBackend}); - - // Recursive call for half part of original input. - const $evenComplex = - fftRadix2(evenRealVals, evenImagVals, half, inverse, cpuBackend); - - const $evenRealVals = $evenComplex.real; - const $evenImagVals = $evenComplex.imag; - - const $evenShape = [$evenRealVals.length]; - - const $evenRealInfo = - cpuBackend.makeTensorInfo($evenShape, 'float32', $evenRealVals); - const $evenImagInfo = - cpuBackend.makeTensorInfo($evenShape, 'float32', $evenImagVals); - - const $evenTensorInfo = complex({ - inputs: {real: $evenRealInfo, imag: $evenImagInfo}, - backend: cpuBackend - }); - - const $oddComplex = - fftRadix2(oddRealVals, oddImagVals, half, inverse, cpuBackend); - - const $oddRealVals = $oddComplex.real; - const $oddImagVals = $oddComplex.imag; - - const $oddShape = [$oddRealVals.length]; - - const $oddRealInfo = - cpuBackend.makeTensorInfo($oddShape, 'float32', $oddRealVals); - const $oddImagInfo = - cpuBackend.makeTensorInfo($oddShape, 'float32', $oddImagVals); - - const $oddTensorInfo = complex( - {inputs: {real: $oddRealInfo, imag: $oddImagInfo}, backend: cpuBackend}); - - const e = backend_util.exponents(size, inverse); - const eShape = [e.real.length]; - - const eRealInfo = cpuBackend.makeTensorInfo(eShape, 'float32', e.real); - const eImagInfo = cpuBackend.makeTensorInfo(eShape, 'float32', e.imag); - - const complexInfo = complex( - {inputs: {real: eRealInfo, imag: eImagInfo}, backend: cpuBackend}); - - const exponentInfo = - multiply( - {inputs: {a: complexInfo, b: $oddTensorInfo}, backend: cpuBackend}) as - TensorInfo; - - const addPart = add({ - inputs: {a: $evenTensorInfo, b: exponentInfo}, - backend: cpuBackend - }) as TensorInfo; - const subPart = sub({ - inputs: {a: $evenTensorInfo, b: exponentInfo}, - backend: cpuBackend - }) as TensorInfo; - - const addPartReal = real({inputs: {input: addPart}, backend: cpuBackend}); - const subPartReal = real({inputs: {input: subPart}, backend: cpuBackend}); - - const addPartImag = imag({inputs: {input: addPart}, backend: cpuBackend}); - const subPartImag = imag({inputs: {input: subPart}, backend: cpuBackend}); - - const $real = concat({ - inputs: [addPartReal as Tensor, subPartReal as Tensor], - backend: cpuBackend, - attrs: {axis: 0} - }); - const $imag = concat({ - inputs: [addPartImag as Tensor, subPartImag as Tensor], - backend: cpuBackend, - attrs: {axis: 0} - }); - - const $realVals = cpuBackend.data.get($real.dataId).values as Float32Array; - const $imagVals = cpuBackend.data.get($imag.dataId).values as Float32Array; - - cpuBackend.disposeIntermediateTensorInfo(evenRealInfo); - cpuBackend.disposeIntermediateTensorInfo(evenImagInfo); - cpuBackend.disposeIntermediateTensorInfo(evenTensorInfo); - cpuBackend.disposeIntermediateTensorInfo(oddRealInfo); - cpuBackend.disposeIntermediateTensorInfo(oddImagInfo); - cpuBackend.disposeIntermediateTensorInfo(oddTensorInfo); - cpuBackend.disposeIntermediateTensorInfo($evenRealInfo); - cpuBackend.disposeIntermediateTensorInfo($evenImagInfo); - cpuBackend.disposeIntermediateTensorInfo($evenTensorInfo); - cpuBackend.disposeIntermediateTensorInfo($oddRealInfo); - cpuBackend.disposeIntermediateTensorInfo($oddImagInfo); - cpuBackend.disposeIntermediateTensorInfo($oddTensorInfo); - cpuBackend.disposeIntermediateTensorInfo(eRealInfo); - cpuBackend.disposeIntermediateTensorInfo(eImagInfo); - cpuBackend.disposeIntermediateTensorInfo(complexInfo); - cpuBackend.disposeIntermediateTensorInfo(exponentInfo); - cpuBackend.disposeIntermediateTensorInfo(addPart); - cpuBackend.disposeIntermediateTensorInfo(subPart); - cpuBackend.disposeIntermediateTensorInfo(addPartReal); - cpuBackend.disposeIntermediateTensorInfo(addPartImag); - cpuBackend.disposeIntermediateTensorInfo(subPartReal); - cpuBackend.disposeIntermediateTensorInfo(subPartImag); - cpuBackend.disposeIntermediateTensorInfo($real); - cpuBackend.disposeIntermediateTensorInfo($imag); - - return {real: $realVals, imag: $imagVals}; -} - -// Calculate fourier transform by multplying sinusoid matrix. -function fourierTransformByMatmul( - data: TypedArray, size: number, inverse: boolean): TypedArray { - const ret = new Float32Array(size * 2); - // TODO: Use matmul instead once it supports complex64 type. - for (let r = 0; r < size; r++) { - let real = 0.0; - let imag = 0.0; - for (let c = 0; c < size; c++) { - const e = backend_util.exponent(r * c, size, inverse); - const term = backend_util.getComplexWithIndex(data as Float32Array, c); - real += term.real * e.real - term.imag * e.imag; - imag += term.real * e.imag + term.imag * e.real; - } - if (inverse) { - real /= size; - imag /= size; - } - backend_util.assignToTypedArray(ret, real, imag, r); - } - return ret; -} diff --git a/tfjs-master/tfjs-backend-cpu/src/utils/fused_utils.ts b/tfjs-master/tfjs-backend-cpu/src/utils/fused_utils.ts deleted file mode 100644 index b2edefbe6..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/utils/fused_utils.ts +++ /dev/null @@ -1,49 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {_FusedMatMul, _FusedMatMulAttrs, _FusedMatMulInputs, backend_util, TensorInfo} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; -import {elu} from '../kernels/Elu'; -import {identity} from '../kernels/Identity'; -import {leakyRelu} from '../kernels/LeakyRelu'; -import {prelu} from '../kernels/Prelu'; -import {relu} from '../kernels/Relu'; -import {relu6} from '../kernels/Relu6'; -import {sigmoid} from '../kernels/Sigmoid'; - -export function applyActivation( - backend: MathBackendCPU, x: TensorInfo, activation: backend_util.Activation, - preluActivationWeights?: TensorInfo, leakyreluAlpha?: number): TensorInfo { - if (activation === 'linear') { - return identity({inputs: {x}, backend}); - } else if (activation === 'relu') { - return relu({inputs: {x}, backend}) as TensorInfo; - } else if (activation === 'elu') { - return elu({inputs: {x}, backend}) as TensorInfo; - } else if (activation === 'relu6') { - return relu6({inputs: {x}, backend}) as TensorInfo; - } else if (activation === 'prelu') { - return prelu({inputs: {x, alpha: preluActivationWeights}, backend}); - } else if (activation === 'leakyrelu') { - return leakyRelu({inputs: {x}, backend, attrs: {alpha: leakyreluAlpha}}); - } else if (activation === 'sigmoid') { - return sigmoid({inputs: {x}, backend}) as TensorInfo; - } - throw new Error( - `Activation ${activation} has not been implemented for the CPU backend.`); -} diff --git a/tfjs-master/tfjs-backend-cpu/src/utils/pool_utils.ts b/tfjs-master/tfjs-backend-cpu/src/utils/pool_utils.ts deleted file mode 100644 index fa6fa2522..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/utils/pool_utils.ts +++ /dev/null @@ -1,339 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, buffer, DataType, Rank, TensorBuffer, TypedArray} from '@tensorflow/tfjs-core'; - -export function pool( - xValues: TypedArray, xShape: number[], dtype: DataType, strides: number[], - convInfo: backend_util.Conv2DInfo, - poolType: 'max'|'avg'): TensorBuffer { - const strideHeight = convInfo.strideHeight; - const strideWidth = convInfo.strideWidth; - const dilationHeight = convInfo.dilationHeight; - const dilationWidth = convInfo.dilationWidth; - const effectiveFilterHeight = convInfo.effectiveFilterHeight; - const effectiveFilterWidth = convInfo.effectiveFilterWidth; - const padTop = convInfo.padInfo.top; - const padLeft = convInfo.padInfo.left; - - const initialValue = - (poolType === 'max' ? Number.NEGATIVE_INFINITY : - Number.POSITIVE_INFINITY); - - const output = buffer(convInfo.outShape, dtype); - const outputVals = output.values; - - const outputBatchStrides = - convInfo.outShape[1] * convInfo.outShape[2] * convInfo.outShape[3]; - const outputRowStrides = convInfo.outShape[2] * convInfo.outShape[3]; - const outputColStrides = convInfo.outShape[3]; - - for (let b = 0; b < convInfo.batchSize; ++b) { - const outputBatchOffset = b * outputBatchStrides; - const inputBatchOffset = b * strides[0]; - for (let d = 0; d < convInfo.inChannels; ++d) { - for (let yR = 0; yR < convInfo.outHeight; ++yR) { - const xRCorner = yR * strideHeight - padTop; - const xRMin = Math.max(0, xRCorner); - const xRMax = - Math.min(convInfo.inHeight, effectiveFilterHeight + xRCorner); - const outputRowOffset = outputBatchOffset + yR * outputRowStrides; - for (let yC = 0; yC < convInfo.outWidth; ++yC) { - const xCCorner = yC * strideWidth - padLeft; - const xCMin = Math.max(0, xCCorner); - const xCMax = - Math.min(convInfo.inWidth, effectiveFilterWidth + xCCorner); - let minMaxValue = initialValue; - let avgValue = 0; - let count = 0; - for (let xR = xRMin; xR < xRMax; xR += dilationHeight) { - const xROffset = inputBatchOffset + xR * strides[1]; - for (let xC = xCMin; xC < xCMax; xC += dilationWidth) { - const xCOffset = xROffset + xC * strides[2]; - const pixel = xValues[xCOffset + d]; - if ((poolType === 'max' && pixel > minMaxValue)) { - minMaxValue = pixel; - } else if (poolType === 'avg') { - avgValue += pixel; - count++; - } - } - if (isNaN(minMaxValue)) { - break; - } - } - const outputOffset = outputRowOffset + yC * outputColStrides + d; - outputVals[outputOffset] = - poolType === 'avg' ? avgValue / count : minMaxValue; - } - } - } - } - return output; -} - -export function maxPoolPositions( - xValues: TypedArray, xShape: number[], dtype: DataType, - convInfo: backend_util.Conv2DInfo, flattenPositions = false, - includeBatchInIndex = false): TensorBuffer { - const maxPositions = buffer(convInfo.outShape, 'int32'); - const strideHeight = convInfo.strideHeight; - const strideWidth = convInfo.strideWidth; - const dilationHeight = convInfo.dilationHeight; - const dilationWidth = convInfo.dilationWidth; - const effectiveFilterHeight = convInfo.effectiveFilterHeight; - const effectiveFilterWidth = convInfo.effectiveFilterWidth; - const padTop = convInfo.padInfo.top; - const padLeft = convInfo.padInfo.left; - - const xBuf = buffer(xShape, dtype, xValues); - for (let b = 0; b < convInfo.batchSize; ++b) { - for (let d = 0; d < convInfo.inChannels; ++d) { - for (let yR = 0; yR < convInfo.outHeight; ++yR) { - const xRCorner = yR * strideHeight - padTop; - let xRMin = xRCorner; - while (xRMin < 0) { - xRMin += dilationHeight; - } - // const xRMin = Math.max(0, xRCorner); - const xRMax = - Math.min(convInfo.inHeight, effectiveFilterHeight + xRCorner); - for (let yC = 0; yC < convInfo.outWidth; ++yC) { - const xCCorner = yC * strideWidth - padLeft; - let xCMin = xCCorner; - while (xCMin < 0) { - xCMin += dilationWidth; - } - const xCMax = - Math.min(convInfo.inWidth, effectiveFilterWidth + xCCorner); - let maxValue = Number.NEGATIVE_INFINITY; - let maxPosition = -1; - - for (let xR = xRMin; xR < xRMax; xR += dilationHeight) { - const wR = xR - xRCorner; - for (let xC = xCMin; xC < xCMax; xC += dilationWidth) { - const wC = xC - xCCorner; - // For some reason, disable-next-line is not working - // TODO(mattsoulanille): Remove this when switching to TS5. - /* tslint:disable: no-unnecessary-type-assertion */ - const pixel = xBuf.get(b, xR, xC, d) as number; - if (pixel > maxValue) { - maxValue = pixel as number; - if (flattenPositions) { - maxPosition = includeBatchInIndex ? - ((b * convInfo.inHeight + xR) * convInfo.inWidth + xC) * - convInfo.inChannels + - d : - (xR * convInfo.inWidth + xC) * convInfo.inChannels + d; - } else { - maxPosition = wR * effectiveFilterWidth + wC; - } - } - } - } - maxPositions.set(maxPosition, b, yR, yC, d); - } - } - } - } - return maxPositions; -} - -export function pool3d( - xValues: TypedArray, xShape: number[], dtype: DataType, strides: number[], - convInfo: backend_util.Conv3DInfo, - poolType: 'max'|'avg'): TensorBuffer { - const strideDepth = convInfo.strideDepth; - const strideHeight = convInfo.strideHeight; - const strideWidth = convInfo.strideWidth; - const dilationDepth = convInfo.dilationDepth; - const dilationHeight = convInfo.dilationHeight; - const dilationWidth = convInfo.dilationWidth; - const effectiveFilterDepth = convInfo.effectiveFilterDepth; - const effectiveFilterHeight = convInfo.effectiveFilterHeight; - const effectiveFilterWidth = convInfo.effectiveFilterWidth; - const padFront = convInfo.padInfo.front; - const padTop = convInfo.padInfo.top; - const padLeft = convInfo.padInfo.left; - - const initialValue = - (poolType === 'max' ? Number.NEGATIVE_INFINITY : - Number.POSITIVE_INFINITY); - - const output = buffer(convInfo.outShape, dtype); - const outputVals = output.values; - - const outputBatchStrides = convInfo.outShape[1] * convInfo.outShape[2] * - convInfo.outShape[3] * convInfo.outShape[4]; - const outputDepthStrides = - convInfo.outShape[2] * convInfo.outShape[3] * convInfo.outShape[4]; - const outputRowStrides = convInfo.outShape[3] * convInfo.outShape[4]; - const outputColStrides = convInfo.outShape[4]; - - for (let batch = 0; batch < convInfo.batchSize; ++batch) { - const outputBatchOffset = batch * outputBatchStrides; - const inputBatchOffset = batch * strides[0]; - for (let channel = 0; channel < convInfo.inChannels; ++channel) { - for (let yDepth = 0; yDepth < convInfo.outDepth; ++yDepth) { - const xDepthCorner = yDepth * strideDepth - padFront; - let xDepthMin = xDepthCorner; - while (xDepthMin < 0) { - xDepthMin += dilationDepth; - } - const xDepthMax = - Math.min(convInfo.inDepth, effectiveFilterDepth + xDepthCorner); - const outputDepthOffset = - outputBatchOffset + yDepth * outputDepthStrides; - for (let yRow = 0; yRow < convInfo.outHeight; ++yRow) { - const xRowCorner = yRow * strideHeight - padTop; - let xRowMin = xRowCorner; - while (xRowMin < 0) { - xRowMin += dilationHeight; - } - const xRowMax = - Math.min(convInfo.inHeight, effectiveFilterHeight + xRowCorner); - const outputRowOffset = outputDepthOffset + yRow * outputRowStrides; - for (let yCol = 0; yCol < convInfo.outWidth; ++yCol) { - const xColCorner = yCol * strideWidth - padLeft; - let xColMin = xColCorner; - while (xColMin < 0) { - xColMin += dilationWidth; - } - const xColMax = - Math.min(convInfo.inWidth, effectiveFilterWidth + xColCorner); - // Shader code begins - const outputColOffset = outputRowOffset + yCol * outputColStrides; - let minMaxValue = initialValue; - let avgValue = 0; - let count = 0; - for (let xDepth = xDepthMin; xDepth < xDepthMax; - xDepth += dilationDepth) { - const xDepthOffset = inputBatchOffset + xDepth * strides[1]; - for (let xRow = xRowMin; xRow < xRowMax; xRow += dilationHeight) { - const xRowOffset = xDepthOffset + xRow * strides[2]; - for (let xCol = xColMin; xCol < xColMax; - xCol += dilationWidth) { - const xColOffset = xRowOffset + xCol * strides[3]; - const pixel = xValues[xColOffset + channel]; - if ((poolType === 'max' && pixel > minMaxValue)) { - minMaxValue = pixel; - } else if (poolType === 'avg') { - avgValue += pixel; - count++; - } - if (isNaN(minMaxValue)) { - break; - } - } - if (isNaN(minMaxValue)) { - break; - } - } - if (isNaN(minMaxValue)) { - break; - } - } - const outputOffset = outputColOffset + channel; - outputVals[outputOffset] = poolType === 'avg' ? - avgValue / Math.max(count, 1) : - minMaxValue; - } - } - } - } - } - - return output; -} - -export function maxPool3dPositions( - xBuf: TensorBuffer, - convInfo: backend_util.Conv3DInfo): TensorBuffer { - const maxPositions = buffer(convInfo.outShape, 'int32'); - const strideDepth = convInfo.strideDepth; - const strideHeight = convInfo.strideHeight; - const strideWidth = convInfo.strideWidth; - const dilationDepth = convInfo.dilationDepth; - const dilationHeight = convInfo.dilationHeight; - const dilationWidth = convInfo.dilationWidth; - const effectiveFilterDepth = convInfo.effectiveFilterDepth; - const effectiveFilterHeight = convInfo.effectiveFilterHeight; - const effectiveFilterWidth = convInfo.effectiveFilterWidth; - const padFront = convInfo.padInfo.front; - const padTop = convInfo.padInfo.top; - const padLeft = convInfo.padInfo.left; - - for (let batch = 0; batch < convInfo.batchSize; ++batch) { - for (let channel = 0; channel < convInfo.inChannels; ++channel) { - for (let yDepth = 0; yDepth < convInfo.outDepth; ++yDepth) { - const xDepthCorner = yDepth * strideDepth - padFront; - let xDepthMin = xDepthCorner; - while (xDepthMin < 0) { - xDepthMin += dilationDepth; - } - const xDepthMax = - Math.min(convInfo.inDepth, effectiveFilterDepth + xDepthCorner); - for (let yRow = 0; yRow < convInfo.outHeight; ++yRow) { - const xRowCorner = yRow * strideHeight - padTop; - let xRowMin = xRowCorner; - while (xRowMin < 0) { - xRowMin += dilationHeight; - } - const xRowMax = - Math.min(convInfo.inHeight, effectiveFilterHeight + xRowCorner); - for (let yCol = 0; yCol < convInfo.outWidth; ++yCol) { - const xColCorner = yCol * strideWidth - padLeft; - let xColMin = xColCorner; - while (xColMin < 0) { - xColMin += dilationWidth; - } - const xColMax = - Math.min(convInfo.inWidth, effectiveFilterWidth + xColCorner); - - // Shader code begins - let maxValue = Number.NEGATIVE_INFINITY; - let maxPosition = -1; - - for (let xDepth = xDepthMin; xDepth < xDepthMax; - xDepth += dilationDepth) { - const wDepth = xDepth - xDepthCorner; - for (let xRow = xRowMin; xRow < xRowMax; xRow += dilationHeight) { - const wRow = xRow - xRowCorner; - for (let xCol = xColMin; xCol < xColMax; - xCol += dilationWidth) { - const wCol = xCol - xColCorner; - const pixel = xBuf.get(batch, xDepth, xRow, xCol, - channel) as number; - if (pixel >= maxValue) { - maxValue = pixel as number; - maxPosition = - wDepth * effectiveFilterHeight * effectiveFilterWidth + - wRow * effectiveFilterHeight + wCol; - } - } - } - } - - maxPositions.set(maxPosition, batch, yDepth, yRow, yCol, channel); - } - } - } - } - } - - return maxPositions; -} diff --git a/tfjs-master/tfjs-backend-cpu/src/utils/unary_impl.ts b/tfjs-master/tfjs-backend-cpu/src/utils/unary_impl.ts deleted file mode 100644 index fcf27ad2f..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/utils/unary_impl.ts +++ /dev/null @@ -1,36 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {util} from '@tensorflow/tfjs-core'; - -import {SimpleUnaryImpl, SimpleUnaryOperation} from './unary_types'; - -/** - * Template that creates implementation for unary op. - */ -export function createSimpleUnaryImpl(op: SimpleUnaryOperation): - SimpleUnaryImpl { - return (values, dtype, attrs) => { - const newValues = - util.getArrayFromDType(dtype, values.length); - for (let i = 0; i < values.length; ++i) { - newValues[i] = op(values[i], attrs); - } - return newValues; - }; -} diff --git a/tfjs-master/tfjs-backend-cpu/src/utils/unary_types.ts b/tfjs-master/tfjs-backend-cpu/src/utils/unary_types.ts deleted file mode 100644 index 50af2116c..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/utils/unary_types.ts +++ /dev/null @@ -1,26 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {DataTypeFor, DataTypeMap, NamedAttrMap} from '@tensorflow/tfjs-core'; - -export type SimpleUnaryOperation = (x: I, attrs?: NamedAttrMap) => O; - -export type SimpleUnaryImpl = - (values: ArrayLike, dtype: DataTypeFor, - attrs?: NamedAttrMap) => DataTypeMap[DataTypeFor]; diff --git a/tfjs-master/tfjs-backend-cpu/src/utils/unary_utils.ts b/tfjs-master/tfjs-backend-cpu/src/utils/unary_utils.ts deleted file mode 100644 index 1f913804f..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/utils/unary_utils.ts +++ /dev/null @@ -1,79 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, DataTypeFor, KernelFunc, UnaryInputs} from '@tensorflow/tfjs-core'; - -import {MathBackendCPU} from '../backend_cpu'; -import {assertNotComplex} from '../cpu_util'; -import {createSimpleUnaryImpl} from './unary_impl'; - -import {SimpleUnaryImpl, SimpleUnaryOperation} from './unary_types'; - -/** - * Template that creates a `KernelFunc` for unary ops. - * @param name Kernel name. - * @param op A `SimpleUnaryOperation` for the kernel. - * @param dtype Optional. If set, the result has this dtype. Otherwise, the - * result has the same dtype as the input. This is mainly used in certain - * kernels that return bool type, such as isFinite, isInf, etc. - */ -export function unaryKernelFunc( - name: string, op: SimpleUnaryOperation, - dtype?: DataTypeFor): KernelFunc { - - const impl = createSimpleUnaryImpl(op); - - return unaryKernelFuncFromImpl(name, impl, dtype); -} - -/** - * Template that creates a `KernelFunc` for unary ops from the given - * `SimpleUnaryImpl`.. - * @param name Kernel name. - * @param unaryImpl A `SimpleUnaryImpl` that implements the op. - * @param dtype Optional. If set, the result has this dtype. Otherwise, the - * result has the same dtype as the input. This is mainly used in certain - * kernels that return bool type, such as isFinite, isInf, etc. - */ -export function unaryKernelFuncFromImpl( - name: string, unaryImpl: SimpleUnaryImpl, - dtype?: DataTypeFor): KernelFunc { - - return ({inputs, attrs, backend}) => { - const {x} = inputs as UnaryInputs; - assertNotComplex(x, name); - - const cpuBackend = backend as MathBackendCPU; - const values = cpuBackend.data.get(x.dataId).values; - let decoded: ArrayLike; - if (x.dtype === 'string') { - if (!Array.isArray(values)) { - throw new Error('String tensor\'s value was not an instance of Array'); - } - decoded = backend_util.fromUint8ToStringArray(values) as unknown as - ArrayLike; - } else { - decoded = values as unknown as ArrayLike; - } - - const $dtype = dtype || x.dtype as DataTypeFor; - const newValues = unaryImpl(decoded, $dtype, attrs); - return cpuBackend.makeTensorInfo(x.shape, $dtype, newValues); - }; -} diff --git a/tfjs-master/tfjs-backend-cpu/src/utils/zeros_impl.ts b/tfjs-master/tfjs-backend-cpu/src/utils/zeros_impl.ts deleted file mode 100644 index b6699faf9..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/utils/zeros_impl.ts +++ /dev/null @@ -1,41 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {DataType, TensorInfo, util} from '@tensorflow/tfjs-core'; -import {MathBackendCPU} from '../backend_cpu'; -import {complex} from '../kernels/Complex'; - -/** - * Generates a tensorInfo with all zeros value. - * @param backend cpu backend. - * @param shape Shape for the zeros tensor. - * @param dtype Optional. If set, the result has this dtype. - */ -export function zeros( - backend: MathBackendCPU, shape: number[], - dtype: DataType = 'float32'): TensorInfo { - if (dtype === 'complex64') { - const real = zeros(backend, shape, 'float32'); - const imag = zeros(backend, shape, 'float32'); - - return complex({inputs: {real, imag}, backend}); - } - - const values = util.makeZerosTypedArray(util.sizeFromShape(shape), dtype); - - return backend.makeTensorInfo(shape, dtype, values); -} diff --git a/tfjs-master/tfjs-backend-cpu/src/version.ts b/tfjs-master/tfjs-backend-cpu/src/version.ts deleted file mode 100644 index 5fa574e7d..000000000 --- a/tfjs-master/tfjs-backend-cpu/src/version.ts +++ /dev/null @@ -1,5 +0,0 @@ -/** @license See the LICENSE file. */ - -// This code is auto-generated, do not modify this file! -const version = '0.0.0'; -export {version}; diff --git a/tfjs-master/tfjs-backend-cpu/tsconfig.json b/tfjs-master/tfjs-backend-cpu/tsconfig.json deleted file mode 100644 index ecb732e21..000000000 --- a/tfjs-master/tfjs-backend-cpu/tsconfig.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "extends": "../tsconfig", - "include": [ - "src/" - ], - "exclude": [ - "node_modules/" - ], - "compilerOptions": { - "outDir": "./dist" - } -} diff --git a/tfjs-master/tfjs-backend-cpu/yarn.lock b/tfjs-master/tfjs-backend-cpu/yarn.lock deleted file mode 100644 index db79cb196..000000000 --- a/tfjs-master/tfjs-backend-cpu/yarn.lock +++ /dev/null @@ -1,28 +0,0 @@ -# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. -# yarn lockfile v1 - - -"@bazel/bazelisk@^1.12.0": - version "1.12.0" - resolved "https://registry.yarnpkg.com/@bazel/bazelisk/-/bazelisk-1.12.0.tgz#f08aebbf4afcb12684422450b0845dd6ef5cfe50" - integrity sha512-7oQusq1e4AIyFgotxVV7Pc40Et0QyvoVjujL+7/qV5Vrbfh0Nj3CfqSgl63weEyI4r0+K6RlGVsjfRuBi05p5w== - -"@bazel/ibazel@^0.16.2": - version "0.16.2" - resolved "https://registry.yarnpkg.com/@bazel/ibazel/-/ibazel-0.16.2.tgz#05dd7f06659759fda30f87b15534f1e42f1201bb" - integrity sha512-KgqAWMH0emL6f3xH6nqyTryoBMqlJ627LBIe9PT1PRRQPz2FtHib3FIHJPukp1slzF3hJYZvdiVwgPnHbaSOOA== - -"@types/seedrandom@^2.4.28": - version "2.4.30" - resolved "https://registry.yarnpkg.com/@types/seedrandom/-/seedrandom-2.4.30.tgz#d2efe425869b84163c2d56e779dddadb9372cbfa" - integrity sha512-AnxLHewubLVzoF/A4qdxBGHCKifw8cY32iro3DQX9TPcetE95zBeVt3jnsvtvAUf1vwzMfwzp4t/L2yqPlnjkQ== - -minimist@1.2.6: - version "1.2.6" - resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.6.tgz#8637a5b759ea0d6e98702cfb3a9283323c93af44" - integrity sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q== - -seedrandom@^3.0.5: - version "3.0.5" - resolved "https://registry.yarnpkg.com/seedrandom/-/seedrandom-3.0.5.tgz#54edc85c95222525b0c7a6f6b3543d8e0b3aa0a7" - integrity sha512-8OwmbklUNzwezjGInmZ+2clQmExQPvomqjL7LFqOYqtmuxRgQYqOD3mHaU+MvZn5FLUeVxVfQjwLZW/n/JFuqg== \ No newline at end of file diff --git a/tfjs-master/tfjs-backend-nodegl/.vscode/settings.json b/tfjs-master/tfjs-backend-nodegl/.vscode/settings.json deleted file mode 100644 index 5f30a3cfd..000000000 --- a/tfjs-master/tfjs-backend-nodegl/.vscode/settings.json +++ /dev/null @@ -1 +0,0 @@ -../../.vscode/settings.json \ No newline at end of file diff --git a/tfjs-master/tfjs-backend-nodegl/README.md b/tfjs-master/tfjs-backend-nodegl/README.md deleted file mode 100644 index f423d58ab..000000000 --- a/tfjs-master/tfjs-backend-nodegl/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# Headless WebGL backend for TensorFlow.js via Node.js - -** This project is under heavy development ** - -This new backend will provide a light-weight headless WebGL runtime for TensorFlow.js running under Node.js. This new backend is powered by the [node-gles](https://github.com/google/node-gles) module which uses [ANGLE](https://github.com/google/angle) to provide an integration layer to system GL runtime. This package aims to provide a think acceleration engine for IoT, desktop, and Node.js applications where CUDA (size/OS compatibility) is not an option. diff --git a/tfjs-master/tfjs-backend-nodegl/demo/README.md b/tfjs-master/tfjs-backend-nodegl/demo/README.md deleted file mode 100644 index 761f5dd87..000000000 --- a/tfjs-master/tfjs-backend-nodegl/demo/README.md +++ /dev/null @@ -1,44 +0,0 @@ -# MobileNet tfjs-backend-nodegl Demo - -*This is a very early demo to show how tfjs-backend-nodegl can be used for headless WebGL acceleration.* - -To run this demo, perform the following: - -1. Move into `tfjs-backend-nodegl` (parent directory of this demo folder): -```sh -$ cd tfjs-backend-nodegl -``` - -2. Build package and compile TypeScript: -```sh -$ yarn && yarn tsc -``` - -3. Move into the demo directory: -```sh -$ cd demo -``` - -4. Prep and build demo: -```sh -$ yarn -``` - -5. Run demo: -```sh -$ node run_mobilenet_inference.js dog.jpg -``` - -Expected output: -```sh -$ node run_mobilenet_inference.js dog.jpg -Platform node has already been set. Overwriting the platform with [object Object]. - - gl.VERSION: OpenGL ES 3.0 (ANGLE 2.1.0.9512a0ef062a) - - gl.RENDERER: ANGLE (Intel Inc., Intel(R) Iris(TM) Plus Graphics 640, OpenGL 4.1 core) - - Loading model... - - Mobilenet load: 6450.763924002647ms - - Coldstarting model... - - Mobilenet cold start: 297.92842200398445ms - - Running inference (100x) ... - - Mobilenet inference: (100x) : 35.75772546708584ms -``` diff --git a/tfjs-master/tfjs-backend-nodegl/demo/dog.jpg b/tfjs-master/tfjs-backend-nodegl/demo/dog.jpg deleted file mode 100644 index 815e2cae8..000000000 Binary files a/tfjs-master/tfjs-backend-nodegl/demo/dog.jpg and /dev/null differ diff --git a/tfjs-master/tfjs-backend-nodegl/demo/package.json b/tfjs-master/tfjs-backend-nodegl/demo/package.json deleted file mode 100644 index d9830beb7..000000000 --- a/tfjs-master/tfjs-backend-nodegl/demo/package.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name": "tfjs-backend-nodegl-demo", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "dependencies": { - "@tensorflow-models/mobilenet": "^2.1.0", - "@tensorflow/tfjs": "^3.18.0", - "jpeg-js": "^0.4.4" - }, - "author": "", - "license": "ISC" -} diff --git a/tfjs-master/tfjs-backend-nodegl/demo/run_mobilenet_inference.js b/tfjs-master/tfjs-backend-nodegl/demo/run_mobilenet_inference.js deleted file mode 100644 index 7d2d52309..000000000 --- a/tfjs-master/tfjs-backend-nodegl/demo/run_mobilenet_inference.js +++ /dev/null @@ -1,90 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -const mobilenet = require('@tensorflow-models/mobilenet'); -const tf = require('@tensorflow/tfjs'); -const fs = require('fs'); -const jpeg = require('jpeg-js'); - -const backendNodeGL = require('./../dist/index'); - -const gl = tf.backend().getGPGPUContext().gl; -console.log(` - gl.VERSION: ${gl.getParameter(gl.VERSION)}`); -console.log(` - gl.RENDERER: ${gl.getParameter(gl.RENDERER)}`); - -const NUMBER_OF_CHANNELS = 3; -const PREPROCESS_DIVISOR = 255 / 2; - -function readImageAsJpeg(path) { - return jpeg.decode(fs.readFileSync(path), true); -} - -function imageByteArray(image, numChannels) { - const pixels = image.data; - const numPixels = image.width * image.height; - const values = new Int32Array(numPixels * numChannels); - for (let i = 0; i < numPixels; i++) { - for (let j = 0; j < numChannels; j++) { - values[i * numChannels + j] = pixels[i * 4 + j]; - } - } - return values; -} - -function imageToInput(image, numChannels) { - const values = imageByteArray(image, numChannels); - const outShape = [1, image.height, image.width, numChannels]; - const input = tf.tensor4d(values, outShape, 'float32'); - return tf.div(tf.sub(input, PREPROCESS_DIVISOR), PREPROCESS_DIVISOR); -} - -async function run(path) { - const image = readImageAsJpeg(path); - const input = imageToInput(image, NUMBER_OF_CHANNELS); - - console.log(' - Loading model...'); - let start = tf.util.now(); - const model = await mobilenet.load(); - let end = tf.util.now(); - console.log(` - Mobilenet load: ${end - start}ms`); - - start = tf.util.now(); - console.log(' - Coldstarting model...'); - await model.classify(input); - end = tf.util.now(); - console.log(` - Mobilenet cold start: ${end - start}ms`); - - const times = 100; - let totalMs = 0; - console.log(` - Running inference (${times}x) ...`); - for (let i = 0; i < times; i++) { - start = tf.util.now(); - await model.classify(input); - end = tf.util.now(); - - totalMs += end - start; - } - - console.log(` - Mobilenet inference: (${times}x) : ${(totalMs / times)}ms`); -} - -if (process.argv.length !== 3) { - throw new Error( - 'incorrect arguments: node packaged-mobilenet-test.js '); -} - -run(process.argv[2]); diff --git a/tfjs-master/tfjs-backend-nodegl/demo/yarn.lock b/tfjs-master/tfjs-backend-nodegl/demo/yarn.lock deleted file mode 100644 index fd5e05191..000000000 --- a/tfjs-master/tfjs-backend-nodegl/demo/yarn.lock +++ /dev/null @@ -1,307 +0,0 @@ -# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. -# yarn lockfile v1 - - -"@tensorflow-models/mobilenet@^2.1.0": - version "2.1.0" - resolved "https://registry.yarnpkg.com/@tensorflow-models/mobilenet/-/mobilenet-2.1.0.tgz#58583f0793a7091eda370aa441d09d94b808aeb1" - integrity sha512-JjqT9ijHDFA2FEpUGWg7H2lQ0GrMuE2VmiCRBYmUew6b4JKht8LXDjG5HxZh95YH6c/25sZWTpGeHbquloH+hw== - -"@tensorflow/tfjs-backend-cpu@3.18.0": - version "3.18.0" - resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-backend-cpu/-/tfjs-backend-cpu-3.18.0.tgz#f0596911c14adf3dfa428e7d04305ef37c6f65e1" - integrity "sha1-8FlpEcFK3z36Qo59BDBe83xvZeE= sha512-LcSqlylzGtpgngcMFIL3q9Q3eVaPRJ7ITZt7ivhzkCj4R5ZsnPa9qM3DCVihkQ77heAwSw4hPTo2jp5C4mJ4Cg==" - dependencies: - "@types/seedrandom" "2.4.27" - seedrandom "2.4.3" - -"@tensorflow/tfjs-backend-webgl@3.18.0": - version "3.18.0" - resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-backend-webgl/-/tfjs-backend-webgl-3.18.0.tgz#56d806a43b4695b1af4ee04c01d6381b1973c2c7" - integrity "sha1-VtgGpDtGlbGvTuBMAdY4Gxlzwsc= sha512-3NknSzS1oX2BEBOrpjPMZl823S12RgshQthmIbG6QADHb4bCJA8aM4UjWpw+3bNQnRKbRDQdFbuvj10Un79s2A==" - dependencies: - "@tensorflow/tfjs-backend-cpu" "3.18.0" - "@types/offscreencanvas" "~2019.3.0" - "@types/seedrandom" "2.4.27" - "@types/webgl-ext" "0.0.30" - "@types/webgl2" "0.0.6" - seedrandom "2.4.3" - -"@tensorflow/tfjs-converter@3.18.0": - version "3.18.0" - resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-converter/-/tfjs-converter-3.18.0.tgz#f4b6d8812d133aa0b6eaa06f75abbde1dbb3550f" - integrity "sha1-9LbYgS0TOqC26qBvdau94duzVQ8= sha512-hpChA+zVNQOVwRnCfqDb1WI9jbEAKA6DuEm4m75Zb3dIlE6VVooDmAaHBhlc++z2q2G1sBzF9A4Bv48SUpN6vA==" - -"@tensorflow/tfjs-core@3.18.0": - version "3.18.0" - resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-core/-/tfjs-core-3.18.0.tgz#c9eb420d1ae2852109fae640ae8a38041b82f9ec" - integrity "sha1-yetCDRrihSEJ+uZAroo4BBuC+ew= sha512-gMxisZozqsr5sCKlphF/eVBLg91MjlBiN60tjX8hJAu0WlSn6Gi5k65GNIL+Pq6hrxpvImcfdCmTH/2XJVZ0Mg==" - dependencies: - "@types/long" "^4.0.1" - "@types/offscreencanvas" "~2019.3.0" - "@types/seedrandom" "2.4.27" - "@types/webgl-ext" "0.0.30" - "@webgpu/types" "^0.1.16" - long "4.0.0" - node-fetch "~2.6.1" - seedrandom "2.4.3" - -"@tensorflow/tfjs-data@3.18.0": - version "3.18.0" - resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-data/-/tfjs-data-3.18.0.tgz#c6edf3bfa05fe581eeebb6a6c08cd4815d96bbf9" - integrity "sha1-xu3zv6Bf5YHu67amwIzUgV2Wu/k= sha512-s43vISJh8K/UN2E2zGRhtj/Kyn8dr4ll8EQkapwzm7fGO9afXCnMsTp6rkZq3fFXouCYA2k1B/j7JssIDr50+w==" - dependencies: - "@types/node-fetch" "^2.1.2" - node-fetch "~2.6.1" - -"@tensorflow/tfjs-layers@3.18.0": - version "3.18.0" - resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-layers/-/tfjs-layers-3.18.0.tgz#8b7d32030e797456e49fd5c26d6f169e0c59b9ca" - integrity "sha1-i30yAw55dFbkn9XCbW8WngxZuco= sha512-AV7yDnPlH+RCcq8VPqkX1iyEchObE+e66m0XmJvLj+ncfKHYLa+39ZNroUA+OgB2/cMG6jgq77R4EhZbT6hwJA==" - -"@tensorflow/tfjs@^3.18.0": - version "3.18.0" - resolved "https://registry.yarnpkg.com/@tensorflow/tfjs/-/tfjs-3.18.0.tgz#be59951d1981c887d2b786100e43abc4c2332164" - integrity "sha1-vlmVHRmByIfSt4YQDkOrxMIzIWQ= sha512-mOzz4jJdgIpqFS7EHndVuxrQnLUDVIKGyTqOPTYps89fZwcOFfTVxi4BHemDNQpqlVE8IaGh9UUxVXpjgPY5+Q==" - dependencies: - "@tensorflow/tfjs-backend-cpu" "3.18.0" - "@tensorflow/tfjs-backend-webgl" "3.18.0" - "@tensorflow/tfjs-converter" "3.18.0" - "@tensorflow/tfjs-core" "3.18.0" - "@tensorflow/tfjs-data" "3.18.0" - "@tensorflow/tfjs-layers" "3.18.0" - argparse "^1.0.10" - chalk "^4.1.0" - core-js "3" - regenerator-runtime "^0.13.5" - yargs "^16.0.3" - -"@types/long@^4.0.1": - version "4.0.2" - resolved "https://registry.yarnpkg.com/@types/long/-/long-4.0.2.tgz#b74129719fc8d11c01868010082d483b7545591a" - integrity sha512-MqTGEo5bj5t157U6fA/BiDynNkn0YknVdh48CMPkTSpFTVmvao5UQmm7uEF6xBEo7qIMAlY/JSleYaE6VOdpaA== - -"@types/node-fetch@^2.1.2": - version "2.3.7" - resolved "https://registry.yarnpkg.com/@types/node-fetch/-/node-fetch-2.3.7.tgz#b7212e895100f8642dbdab698472bab5f3c1d2f1" - integrity "sha1-tyEuiVEA+GQtvatphHK6tfPB0vE= sha512-+bKtuxhj/TYSSP1r4CZhfmyA0vm/aDRQNo7vbAgf6/cZajn0SAniGGST07yvI4Q+q169WTa2/x9gEHfJrkcALw==" - dependencies: - "@types/node" "*" - -"@types/node@*": - version "12.6.1" - resolved "https://registry.yarnpkg.com/@types/node/-/node-12.6.1.tgz#d5544f6de0aae03eefbb63d5120f6c8be0691946" - integrity "sha1-1VRPbeCq4D7vu2PVEg9si+BpGUY= sha512-rp7La3m845mSESCgsJePNL/JQyhkOJA6G4vcwvVgkDAwHhGdq5GCumxmPjEk1MZf+8p5ZQAUE7tqgQRQTXN7uQ==" - -"@types/offscreencanvas@~2019.3.0": - version "2019.3.0" - resolved "https://registry.yarnpkg.com/@types/offscreencanvas/-/offscreencanvas-2019.3.0.tgz#3336428ec7e9180cf4566dfea5da04eb586a6553" - integrity sha512-esIJx9bQg+QYF0ra8GnvfianIY8qWB0GBx54PK5Eps6m+xTj86KLavHv6qDhzKcu5UUOgNfJ2pWaIIV7TRUd9Q== - -"@types/seedrandom@2.4.27": - version "2.4.27" - resolved "https://registry.yarnpkg.com/@types/seedrandom/-/seedrandom-2.4.27.tgz#9db563937dd86915f69092bc43259d2f48578e41" - integrity sha1-nbVjk33YaRX2kJK8QyWdL0hXjkE= - -"@types/webgl-ext@0.0.30": - version "0.0.30" - resolved "https://registry.yarnpkg.com/@types/webgl-ext/-/webgl-ext-0.0.30.tgz#0ce498c16a41a23d15289e0b844d945b25f0fb9d" - integrity sha512-LKVgNmBxN0BbljJrVUwkxwRYqzsAEPcZOe6S2T6ZaBDIrFp0qu4FNlpc5sM1tGbXUYFgdVQIoeLk1Y1UoblyEg== - -"@types/webgl2@0.0.6": - version "0.0.6" - resolved "https://registry.yarnpkg.com/@types/webgl2/-/webgl2-0.0.6.tgz#1ea2db791362bd8521548d664dbd3c5311cdf4b6" - integrity sha512-50GQhDVTq/herLMiqSQkdtRu+d5q/cWHn4VvKJtrj4DJAjo1MNkWYa2MA41BaBO1q1HgsUjuQvEOk0QHvlnAaQ== - -"@webgpu/types@^0.1.16": - version "0.1.17" - resolved "https://registry.yarnpkg.com/@webgpu/types/-/types-0.1.17.tgz#91e8ec9fd6a1e63945ef12bff11394949ea1a583" - integrity "sha1-kejsn9ah5jlF7xK/8ROUlJ6hpYM= sha512-M8INbXsMdkWtVsSHRPEiTXHe0S4gxMhYA/Kz4pNoUF9IXd3PHMi6/2n8EAsqkAEdna+aeCm2RmscWV0hsmIf0Q==" - -ansi-regex@^5.0.1: - version "5.0.1" - resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.1.tgz#082cb2c89c9fe8659a311a53bd6a4dc5301db304" - integrity sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ== - -ansi-styles@^4.0.0, ansi-styles@^4.1.0: - version "4.3.0" - resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-4.3.0.tgz#edd803628ae71c04c85ae7a0906edad34b648937" - integrity sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg== - dependencies: - color-convert "^2.0.1" - -argparse@^1.0.10: - version "1.0.10" - resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911" - integrity sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg== - dependencies: - sprintf-js "~1.0.2" - -chalk@^4.1.0: - version "4.1.2" - resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01" - integrity sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA== - dependencies: - ansi-styles "^4.1.0" - supports-color "^7.1.0" - -cliui@^7.0.2: - version "7.0.4" - resolved "https://registry.yarnpkg.com/cliui/-/cliui-7.0.4.tgz#a0265ee655476fc807aea9df3df8df7783808b4f" - integrity sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ== - dependencies: - string-width "^4.2.0" - strip-ansi "^6.0.0" - wrap-ansi "^7.0.0" - -color-convert@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-2.0.1.tgz#72d3a68d598c9bdb3af2ad1e84f21d896abd4de3" - integrity sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ== - dependencies: - color-name "~1.1.4" - -color-name@~1.1.4: - version "1.1.4" - resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2" - integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA== - -core-js@3: - version "3.22.7" - resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.22.7.tgz#8d6c37f630f6139b8732d10f2c114c3f1d00024f" - integrity "sha1-jWw39jD2E5uHMtEPLBFMPx0AAk8= sha512-Jt8SReuDKVNZnZEzyEQT5eK6T2RRCXkfTq7Lo09kpm+fHjgGewSbNjV+Wt4yZMhPDdzz2x1ulI5z/w4nxpBseg==" - -emoji-regex@^8.0.0: - version "8.0.0" - resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37" - integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A== - -escalade@^3.1.1: - version "3.1.1" - resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.1.1.tgz#d8cfdc7000965c5a0174b4a82eaa5c0552742e40" - integrity sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw== - -get-caller-file@^2.0.5: - version "2.0.5" - resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e" - integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg== - -has-flag@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b" - integrity sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ== - -is-fullwidth-code-point@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz#f116f8064fe90b3f7844a38997c0b75051269f1d" - integrity sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg== - -jpeg-js@^0.4.4: - version "0.4.4" - resolved "https://registry.yarnpkg.com/jpeg-js/-/jpeg-js-0.4.4.tgz#a9f1c6f1f9f0fa80cdb3484ed9635054d28936aa" - integrity sha512-WZzeDOEtTOBK4Mdsar0IqEU5sMr3vSV2RqkAIzUEV2BHnUfKGyswWFPFwK5EeDo93K3FohSHbLAjj0s1Wzd+dg== - -long@4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/long/-/long-4.0.0.tgz#9a7b71cfb7d361a194ea555241c92f7468d5bf28" - integrity sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA== - -node-fetch@~2.6.1: - version "2.6.7" - resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.7.tgz#24de9fba827e3b4ae44dc8b20256a379160052ad" - integrity sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ== - dependencies: - whatwg-url "^5.0.0" - -regenerator-runtime@^0.13.5: - version "0.13.9" - resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.9.tgz#8925742a98ffd90814988d7566ad30ca3b263b52" - integrity sha512-p3VT+cOEgxFsRRA9X4lkI1E+k2/CtnKtU4gcxyaCUreilL/vqI6CdZ3wxVUx3UOUg+gnUOQQcRI7BmSI656MYA== - -require-directory@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42" - integrity sha1-jGStX9MNqxyXbiNE/+f3kqam30I= - -seedrandom@2.4.3: - version "2.4.3" - resolved "https://registry.yarnpkg.com/seedrandom/-/seedrandom-2.4.3.tgz#2438504dad33917314bff18ac4d794f16d6aaecc" - integrity sha1-JDhQTa0zkXMUv/GKxNeU8W1qrsw= - -sprintf-js@~1.0.2: - version "1.0.3" - resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" - integrity sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw= - -string-width@^4.1.0, string-width@^4.2.0: - version "4.2.3" - resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" - integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== - dependencies: - emoji-regex "^8.0.0" - is-fullwidth-code-point "^3.0.0" - strip-ansi "^6.0.1" - -strip-ansi@^6.0.0, strip-ansi@^6.0.1: - version "6.0.1" - resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" - integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== - dependencies: - ansi-regex "^5.0.1" - -supports-color@^7.1.0: - version "7.2.0" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-7.2.0.tgz#1b7dcdcb32b8138801b3e478ba6a51caa89648da" - integrity sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw== - dependencies: - has-flag "^4.0.0" - -tr46@~0.0.3: - version "0.0.3" - resolved "https://registry.yarnpkg.com/tr46/-/tr46-0.0.3.tgz#8184fd347dac9cdc185992f3a6622e14b9d9ab6a" - integrity sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o= - -webidl-conversions@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871" - integrity sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE= - -whatwg-url@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-5.0.0.tgz#966454e8765462e37644d3626f6742ce8b70965d" - integrity sha1-lmRU6HZUYuN2RNNib2dCzotwll0= - dependencies: - tr46 "~0.0.3" - webidl-conversions "^3.0.0" - -wrap-ansi@^7.0.0: - version "7.0.0" - resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" - integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== - dependencies: - ansi-styles "^4.0.0" - string-width "^4.1.0" - strip-ansi "^6.0.0" - -y18n@^5.0.5: - version "5.0.8" - resolved "https://registry.yarnpkg.com/y18n/-/y18n-5.0.8.tgz#7f4934d0f7ca8c56f95314939ddcd2dd91ce1d55" - integrity sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA== - -yargs-parser@^20.2.2: - version "20.2.9" - resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.9.tgz#2eb7dc3b0289718fc295f362753845c41a0c94ee" - integrity sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w== - -yargs@^16.0.3: - version "16.2.0" - resolved "https://registry.yarnpkg.com/yargs/-/yargs-16.2.0.tgz#1c82bf0f6b6a66eafce7ef30e376f49a12477f66" - integrity sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw== - dependencies: - cliui "^7.0.2" - escalade "^3.1.1" - get-caller-file "^2.0.5" - require-directory "^2.1.1" - string-width "^4.2.0" - y18n "^5.0.5" - yargs-parser "^20.2.2" diff --git a/tfjs-master/tfjs-backend-nodegl/package.json b/tfjs-master/tfjs-backend-nodegl/package.json deleted file mode 100644 index 9d9a43a4f..000000000 --- a/tfjs-master/tfjs-backend-nodegl/package.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "name": "tfjs-backend-nodegl", - "version": "0.0.1", - "description": "", - "main": "dist/index.js", - "types": "dist/index.d.ts", - "scripts": { - "build": "tsc", - "lint": "tslint -p . -t verbose", - "test": "yarn && yarn build && ts-node --transpile-only src/run_tests.ts", - "test-dev": "tsc && ts-node --transpile-only src/run_tests.ts" - }, - "author": "", - "license": "Apache-2.0", - "repository": { - "type": "git", - "url": "https://github.com/tensorflow/tfjs.git", - "directory": "tfjs-backend-nodegl" - }, - "dependencies": { - "@tensorflow/tfjs-core": "^3.3.0", - "node-gles": "^0.0.13" - }, - "devDependencies": { - "@types/jasmine": "~2.8.6", - "@types/node": "^10.5.1", - "@types/rimraf": "~2.0.2", - "clang-format": "^1.2.4", - "jasmine": "~3.1.0", - "ts-node": "^8.1.0", - "tslint": "~5.9.1", - "tslint-no-circular-imports": "^0.5.0", - "typescript": "3.5.3" - }, - "resolutions": { - "node-fetch": "2.6.7", - "minimist": "1.2.6" - } -} diff --git a/tfjs-master/tfjs-backend-nodegl/src/index.ts b/tfjs-master/tfjs-backend-nodegl/src/index.ts deleted file mode 100644 index 1175c58bb..000000000 --- a/tfjs-master/tfjs-backend-nodegl/src/index.ts +++ /dev/null @@ -1,41 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '@tensorflow/tfjs-core'; -// TODO(kreeger): Fix binding definition in node-gles before switching to a -// non-require import style. -// tslint:disable-next-line:no-require-imports -const nodeGles = require('node-gles'); - -const nodeGl = nodeGles.binding.createWebGLRenderingContext(); - -// TODO(kreeger): These are hard-coded GL integration flags. These need to be -// updated to ensure they work on all systems with proper exception reporting. -tf.env().set('WEBGL_VERSION', 2); -tf.env().set('WEBGL_RENDER_FLOAT32_ENABLED', true); -tf.env().set('WEBGL_DOWNLOAD_FLOAT_ENABLED', true); -tf.env().set('WEBGL_FENCE_API_ENABLED', true); // OpenGL ES 3.0 and higher.. -tf.env().set( - 'WEBGL_MAX_TEXTURE_SIZE', nodeGl.getParameter(nodeGl.MAX_TEXTURE_SIZE)); -tf.webgl.setWebGLContext(2, nodeGl); - -tf.registerBackend('headless-nodegl', () => { - // TODO(kreeger): Consider moving all GL creation here. However, weak-ref to - // GL context tends to cause an issue when running unit tests: - // https://github.com/tensorflow/tfjs/issues/1732 - return new tf.webgl.MathBackendWebGL(new tf.webgl.GPGPUContext(nodeGl)); -}, 3 /* priority */); diff --git a/tfjs-master/tfjs-backend-nodegl/src/run_tests.ts b/tfjs-master/tfjs-backend-nodegl/src/run_tests.ts deleted file mode 100644 index 9d96865cf..000000000 --- a/tfjs-master/tfjs-backend-nodegl/src/run_tests.ts +++ /dev/null @@ -1,79 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// We import index.ts so that the Node backend gets registered. -import './index'; - -import * as tf from '@tensorflow/tfjs-core'; -// tslint:disable-next-line:no-imports-from-dist -import * as jasmine_util from '@tensorflow/tfjs-core/dist/jasmine_util'; - -Error.stackTraceLimit = Infinity; - -// tslint:disable-next-line:no-require-imports -const jasmineCtor = require('jasmine'); - -process.on('unhandledRejection', e => { - throw e; -}); - -jasmine_util.setTestEnvs( - [{name: 'test-tensorflow', backendName: 'headless-nodegl', flags: {}}]); - -const IGNORE_LIST: string[] = [ - // https://github.com/tensorflow/tfjs/issues/1711 - 'time cpu test-tensorflow {} simple upload', - // TODO(kreeger): File issue: bad uniform in input.uniformValues. - 'sparseToDense test-tensorflow {} should work with 0-sized tensors', - // TODO(kreeger): File issue: fromPixels doesn't have data field. - // tslint:disable:max-line-length - 'fromPixels, mock canvas test-tensorflow {} accepts a canvas-like element, numChannels=4', - 'fromPixels, mock canvas test-tensorflow {} accepts a canvas-like element' -]; - -const runner = new jasmineCtor(); -runner.loadConfig({ - spec_files: [ - 'src/**/*_test.ts', 'node_modules/@tensorflow/tfjs-core/dist/**/*_test.js' - ], - random: false -}); - -if (process.env.JASMINE_SEED) { - runner.seed(process.env.JASMINE_SEED); -} - -const env = jasmine.getEnv(); - -// Filter method that returns boolean, if a given test should return. -env.specFilter = spec => { - // Return false (skip the test) if the test is in the ignore list. - for (let i = 0; i < IGNORE_LIST.length; ++i) { - if (spec.getFullName().indexOf(IGNORE_LIST[i]) > -1) { - return false; - } - } - // Otherwise run the test. - return true; -}; - -console.log(`Running tests with the following GL info`); -const gl = (tf.backend() as tf.webgl.MathBackendWebGL).getGPGPUContext().gl; -console.log(` GL_VERSION: ${gl.getParameter(gl.VERSION)}`); -console.log(` GL_RENDERER: ${gl.getParameter(gl.RENDERER)}`); - -runner.execute(); diff --git a/tfjs-master/tfjs-backend-nodegl/src/version.ts b/tfjs-master/tfjs-backend-nodegl/src/version.ts deleted file mode 100644 index 2dc61bb92..000000000 --- a/tfjs-master/tfjs-backend-nodegl/src/version.ts +++ /dev/null @@ -1,5 +0,0 @@ -/** @license See the LICENSE file. */ - -// This code is auto-generated, do not modify this file! -const version = '0.0.1'; -export {version}; diff --git a/tfjs-master/tfjs-backend-nodegl/tasks.json b/tfjs-master/tfjs-backend-nodegl/tasks.json deleted file mode 100644 index 594b0eea8..000000000 --- a/tfjs-master/tfjs-backend-nodegl/tasks.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "version": "2.0.0", - "tasks": [ - { - "command": "yarn", - "label": "lint", - "type": "shell", - "args": [ - "lint" - ], - "problemMatcher": { - "base": "$tslint5", - "owner": "tslint-type-checked", - "fileLocation": "absolute" - } - }, - { - "command": "yarn", - "label": "build", - "type": "shell", - "args": ["build", "--pretty", "false", "--noEmit"], - "problemMatcher": [ - "$tsc" - ] - } - ] - } diff --git a/tfjs-master/tfjs-backend-nodegl/tsconfig.json b/tfjs-master/tfjs-backend-nodegl/tsconfig.json deleted file mode 100644 index 1ad387d16..000000000 --- a/tfjs-master/tfjs-backend-nodegl/tsconfig.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "extends": "../tsconfig_base.json", - "include": [ - "src/" - ], - "exclude": [ - "node_modules/" - ], - "compilerOptions": { - "outDir": "./dist" - } -} diff --git a/tfjs-master/tfjs-backend-nodegl/tslint.json b/tfjs-master/tfjs-backend-nodegl/tslint.json deleted file mode 100644 index ec365f164..000000000 --- a/tfjs-master/tfjs-backend-nodegl/tslint.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "../tslint.json" -} diff --git a/tfjs-master/tfjs-backend-nodegl/yarn.lock b/tfjs-master/tfjs-backend-nodegl/yarn.lock deleted file mode 100644 index 1b6ed2561..000000000 --- a/tfjs-master/tfjs-backend-nodegl/yarn.lock +++ /dev/null @@ -1,606 +0,0 @@ -# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. -# yarn lockfile v1 - - -"@tensorflow/tfjs-core@^3.3.0": - version "3.3.0" - resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-core/-/tfjs-core-3.3.0.tgz#3d26bd03cb58e0ecf46c96d118c39c4a90b7f5ed" - integrity "sha1-PSa9A8tY4Oz0bJbRGMOcSpC39e0= sha512-6G+LcCiQBl4Kza5mDbWbf8QSWBTW3l7SDjGhQzMO1ITtQatHzxkuHGHcJ4CTUJvNA0JmKf4QJWOvlFqEmxwyLQ==" - dependencies: - "@types/offscreencanvas" "~2019.3.0" - "@types/seedrandom" "2.4.27" - "@types/webgl-ext" "0.0.30" - node-fetch "~2.6.1" - seedrandom "2.4.3" - -"@types/glob@*": - version "7.1.3" - resolved "https://registry.yarnpkg.com/@types/glob/-/glob-7.1.3.tgz#e6ba80f36b7daad2c685acd9266382e68985c183" - integrity sha512-SEYeGAIQIQX8NN6LDKprLjbrd5dARM5EXsd8GI/A5l0apYI1fGMWgPHSe4ZKL4eozlAyI+doUE9XbYS4xCkQ1w== - dependencies: - "@types/minimatch" "*" - "@types/node" "*" - -"@types/jasmine@~2.8.6": - version "2.8.17" - resolved "https://registry.yarnpkg.com/@types/jasmine/-/jasmine-2.8.17.tgz#65fa3be377126253f6c7988b365dfc78d62d536e" - integrity sha512-lXmY2lBjE38ASvP7ah38yZwXCdc7DTCKhHqx4J3WGNiVzp134U0BD9VKdL5x9q9AAfhnpJeQr4owL6ZOXhOpfA== - -"@types/minimatch@*": - version "3.0.4" - resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.4.tgz#f0ec25dbf2f0e4b18647313ac031134ca5b24b21" - integrity sha512-1z8k4wzFnNjVK/tlxvrWuK5WMt6mydWWP7+zvH5eFep4oj+UkrfiJTRtjCeBXNpwaA/FYqqtb4/QS4ianFpIRA== - -"@types/node@*": - version "14.14.37" - resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.37.tgz#a3dd8da4eb84a996c36e331df98d82abd76b516e" - integrity sha512-XYmBiy+ohOR4Lh5jE379fV2IU+6Jn4g5qASinhitfyO71b/sCo6MKsMLF5tc7Zf2CE8hViVQyYSobJNke8OvUw== - -"@types/node@^10.5.1": - version "10.17.56" - resolved "https://registry.yarnpkg.com/@types/node/-/node-10.17.56.tgz#010c9e047c3ff09ddcd11cbb6cf5912725cdc2b3" - integrity sha512-LuAa6t1t0Bfw4CuSR0UITsm1hP17YL+u82kfHGrHUWdhlBtH7sa7jGY5z7glGaIj/WDYDkRtgGd+KCjCzxBW1w== - -"@types/offscreencanvas@~2019.3.0": - version "2019.3.0" - resolved "https://registry.yarnpkg.com/@types/offscreencanvas/-/offscreencanvas-2019.3.0.tgz#3336428ec7e9180cf4566dfea5da04eb586a6553" - integrity sha512-esIJx9bQg+QYF0ra8GnvfianIY8qWB0GBx54PK5Eps6m+xTj86KLavHv6qDhzKcu5UUOgNfJ2pWaIIV7TRUd9Q== - -"@types/rimraf@~2.0.2": - version "2.0.4" - resolved "https://registry.yarnpkg.com/@types/rimraf/-/rimraf-2.0.4.tgz#403887b0b53c6100a6c35d2ab24f6ccc042fec46" - integrity sha512-8gBudvllD2A/c0CcEX/BivIDorHFt5UI5m46TsNj8DjWCCTTZT74kEe4g+QsY7P/B9WdO98d82zZgXO/RQzu2Q== - dependencies: - "@types/glob" "*" - "@types/node" "*" - -"@types/seedrandom@2.4.27": - version "2.4.27" - resolved "https://registry.yarnpkg.com/@types/seedrandom/-/seedrandom-2.4.27.tgz#9db563937dd86915f69092bc43259d2f48578e41" - integrity sha1-nbVjk33YaRX2kJK8QyWdL0hXjkE= - -"@types/webgl-ext@0.0.30": - version "0.0.30" - resolved "https://registry.yarnpkg.com/@types/webgl-ext/-/webgl-ext-0.0.30.tgz#0ce498c16a41a23d15289e0b844d945b25f0fb9d" - integrity sha512-LKVgNmBxN0BbljJrVUwkxwRYqzsAEPcZOe6S2T6ZaBDIrFp0qu4FNlpc5sM1tGbXUYFgdVQIoeLk1Y1UoblyEg== - -adm-zip@^0.4.13: - version "0.4.16" - resolved "https://registry.yarnpkg.com/adm-zip/-/adm-zip-0.4.16.tgz#cf4c508fdffab02c269cbc7f471a875f05570365" - integrity sha512-TFi4HBKSGfIKsK5YCkKaaFG2m4PEDyViZmEwof3MTIgzimHLto6muaHVpbrljdIvIrFZzEq/p4nafOeLcYegrg== - -agent-base@^4.3.0: - version "4.3.0" - resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-4.3.0.tgz#8165f01c436009bccad0b1d122f05ed770efc6ee" - integrity sha512-salcGninV0nPrwpGNn4VTXBb1SOuXQBiqbrNXoeizJsHrsL6ERFM2Ne3JUSBWRE6aeNJI2ROP/WEEIDUiDe3cg== - dependencies: - es6-promisify "^5.0.0" - -ansi-regex@^2.0.0: - version "2.1.1" - resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-2.1.1.tgz#c3b33ab5ee360d86e0e628f0468ae7ef27d654df" - integrity sha1-w7M6te42DYbg5ijwRorn7yfWVN8= - -ansi-styles@^2.2.1: - version "2.2.1" - resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-2.2.1.tgz#b432dd3358b634cf75e1e4664368240533c1ddbe" - integrity sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4= - -ansi-styles@^3.2.1: - version "3.2.1" - resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d" - integrity sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA== - dependencies: - color-convert "^1.9.0" - -arg@^4.1.0: - version "4.1.3" - resolved "https://registry.yarnpkg.com/arg/-/arg-4.1.3.tgz#269fc7ad5b8e42cb63c896d5666017261c144089" - integrity sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA== - -argparse@^1.0.7: - version "1.0.10" - resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911" - integrity sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg== - dependencies: - sprintf-js "~1.0.2" - -async@^1.5.2: - version "1.5.2" - resolved "https://registry.yarnpkg.com/async/-/async-1.5.2.tgz#ec6a61ae56480c0c3cb241c95618e20892f9672a" - integrity sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo= - -babel-code-frame@^6.22.0: - version "6.26.0" - resolved "https://registry.yarnpkg.com/babel-code-frame/-/babel-code-frame-6.26.0.tgz#63fd43f7dc1e3bb7ce35947db8fe369a3f58c74b" - integrity sha1-Y/1D99weO7fONZR9uP42mj9Yx0s= - dependencies: - chalk "^1.1.3" - esutils "^2.0.2" - js-tokens "^3.0.2" - -balanced-match@^1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee" - integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw== - -bindings@^1.3.0: - version "1.5.0" - resolved "https://registry.yarnpkg.com/bindings/-/bindings-1.5.0.tgz#10353c9e945334bc0511a6d90b38fbc7c9c504df" - integrity sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ== - dependencies: - file-uri-to-path "1.0.0" - -brace-expansion@^1.1.7: - version "1.1.11" - resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" - integrity sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA== - dependencies: - balanced-match "^1.0.0" - concat-map "0.0.1" - -buffer-from@^1.0.0: - version "1.1.1" - resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef" - integrity sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A== - -builtin-modules@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/builtin-modules/-/builtin-modules-1.1.1.tgz#270f076c5a72c02f5b65a47df94c5fe3a278892f" - integrity sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8= - -chalk@^1.1.3: - version "1.1.3" - resolved "https://registry.yarnpkg.com/chalk/-/chalk-1.1.3.tgz#a8115c55e4a702fe4d150abd3872822a7e09fc98" - integrity sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg= - dependencies: - ansi-styles "^2.2.1" - escape-string-regexp "^1.0.2" - has-ansi "^2.0.0" - strip-ansi "^3.0.0" - supports-color "^2.0.0" - -chalk@^2.3.0: - version "2.4.2" - resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" - integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ== - dependencies: - ansi-styles "^3.2.1" - escape-string-regexp "^1.0.5" - supports-color "^5.3.0" - -chownr@^1.1.4: - version "1.1.4" - resolved "https://registry.yarnpkg.com/chownr/-/chownr-1.1.4.tgz#6fc9d7b42d32a583596337666e7d08084da2cc6b" - integrity sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg== - -clang-format@^1.2.4: - version "1.5.0" - resolved "https://registry.yarnpkg.com/clang-format/-/clang-format-1.5.0.tgz#1bd4c47b66a1a02556b192b93f5505e7ccec84fb" - integrity sha512-C1LucFX7E+ABVYcPEbBHM4PYQ2+WInXsqsLpFlQ9cmRfSbk7A7b1I06h/nE4bQ3MsyEkb31jY2gC0Dtc76b4IA== - dependencies: - async "^1.5.2" - glob "^7.0.0" - resolve "^1.1.6" - -color-convert@^1.9.0: - version "1.9.3" - resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8" - integrity sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg== - dependencies: - color-name "1.1.3" - -color-name@1.1.3: - version "1.1.3" - resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25" - integrity sha1-p9BVi9icQveV3UIyj3QIMcpTvCU= - -commander@^2.12.1: - version "2.20.3" - resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33" - integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ== - -concat-map@0.0.1: - version "0.0.1" - resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" - integrity sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg== - -debug@^3.1.0: - version "3.2.7" - resolved "https://registry.yarnpkg.com/debug/-/debug-3.2.7.tgz#72580b7e9145fb39b6676f9c5e5fb100b934179a" - integrity sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ== - dependencies: - ms "^2.1.1" - -diff@^3.2.0: - version "3.5.0" - resolved "https://registry.yarnpkg.com/diff/-/diff-3.5.0.tgz#800c0dd1e0a8bfbc95835c202ad220fe317e5a12" - integrity sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA== - -diff@^4.0.1: - version "4.0.2" - resolved "https://registry.yarnpkg.com/diff/-/diff-4.0.2.tgz#60f3aecb89d5fae520c11aa19efc2bb982aade7d" - integrity sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A== - -es6-promise@^4.0.3: - version "4.2.8" - resolved "https://registry.yarnpkg.com/es6-promise/-/es6-promise-4.2.8.tgz#4eb21594c972bc40553d276e510539143db53e0a" - integrity sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w== - -es6-promisify@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/es6-promisify/-/es6-promisify-5.0.0.tgz#5109d62f3e56ea967c4b63505aef08291c8a5203" - integrity sha1-UQnWLz5W6pZ8S2NQWu8IKRyKUgM= - dependencies: - es6-promise "^4.0.3" - -escape-string-regexp@^1.0.2, escape-string-regexp@^1.0.5: - version "1.0.5" - resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" - integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ= - -esprima@^4.0.0: - version "4.0.1" - resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71" - integrity sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A== - -esutils@^2.0.2: - version "2.0.3" - resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.3.tgz#74d2eb4de0b8da1293711910d50775b9b710ef64" - integrity sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g== - -file-uri-to-path@1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz#553a7b8446ff6f684359c445f1e37a05dacc33dd" - integrity sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw== - -fs-minipass@^1.2.7: - version "1.2.7" - resolved "https://registry.yarnpkg.com/fs-minipass/-/fs-minipass-1.2.7.tgz#ccff8570841e7fe4265693da88936c55aed7f7c7" - integrity sha512-GWSSJGFy4e9GUeCcbIkED+bgAoFyj7XF1mV8rma3QW4NIqX9Kyx79N/PF61H5udOV3aY1IaMLs6pGbH71nlCTA== - dependencies: - minipass "^2.6.0" - -fs.realpath@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" - integrity sha1-FQStJSMVjKpA20onh8sBQRmU6k8= - -function-bind@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d" - integrity sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A== - -glob@^7.0.0, glob@^7.0.6, glob@^7.1.1, glob@^7.1.3: - version "7.1.6" - resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.6.tgz#141f33b81a7c2492e125594307480c46679278a6" - integrity sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA== - dependencies: - fs.realpath "^1.0.0" - inflight "^1.0.4" - inherits "2" - minimatch "^3.0.4" - once "^1.3.0" - path-is-absolute "^1.0.0" - -has-ansi@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/has-ansi/-/has-ansi-2.0.0.tgz#34f5049ce1ecdf2b0649af3ef24e45ed35416d91" - integrity sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE= - dependencies: - ansi-regex "^2.0.0" - -has-flag@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd" - integrity sha1-tdRU3CGZriJWmfNGfloH87lVuv0= - -has@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/has/-/has-1.0.3.tgz#722d7cbfc1f6aa8241f16dd814e011e1f41e8796" - integrity sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw== - dependencies: - function-bind "^1.1.1" - -https-proxy-agent@^2.2.1: - version "2.2.4" - resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-2.2.4.tgz#4ee7a737abd92678a293d9b34a1af4d0d08c787b" - integrity sha512-OmvfoQ53WLjtA9HeYP9RNrWMJzzAz1JGaSFr1nijg0PVR1JaD/xbJq1mdEIIlxGpXp9eSe/O2LgU9DJmTPd0Eg== - dependencies: - agent-base "^4.3.0" - debug "^3.1.0" - -inflight@^1.0.4: - version "1.0.6" - resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" - integrity sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk= - dependencies: - once "^1.3.0" - wrappy "1" - -inherits@2: - version "2.0.4" - resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" - integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== - -is-core-module@^2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.2.0.tgz#97037ef3d52224d85163f5597b2b63d9afed981a" - integrity sha512-XRAfAdyyY5F5cOXn7hYQDqh2Xmii+DEfIcQGxK/uNwMHhIkPWO0g8msXcbzLe+MpGoR951MlqM/2iIlU4vKDdQ== - dependencies: - has "^1.0.3" - -jasmine-core@~3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/jasmine-core/-/jasmine-core-3.1.0.tgz#a4785e135d5df65024dfc9224953df585bd2766c" - integrity sha1-pHheE11d9lAk38kiSVPfWFvSdmw= - -jasmine@~3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/jasmine/-/jasmine-3.1.0.tgz#2bd59fd7ec6ec0e8acb64e09f45a68ed2ad1952a" - integrity sha1-K9Wf1+xuwOistk4J9Fpo7SrRlSo= - dependencies: - glob "^7.0.6" - jasmine-core "~3.1.0" - -js-tokens@^3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b" - integrity sha1-mGbfOVECEw449/mWvOtlRDIJwls= - -js-yaml@^3.7.0: - version "3.14.1" - resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.14.1.tgz#dae812fdb3825fa306609a8717383c50c36a0537" - integrity sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g== - dependencies: - argparse "^1.0.7" - esprima "^4.0.0" - -make-error@^1.1.1: - version "1.3.6" - resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.6.tgz#2eb2e37ea9b67c4891f684a1394799af484cf7a2" - integrity sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw== - -minimatch@^3.0.4: - version "3.1.2" - resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b" - integrity sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw== - dependencies: - brace-expansion "^1.1.7" - -minimist@1.2.6, minimist@^1.2.5: - version "1.2.6" - resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.6.tgz#8637a5b759ea0d6e98702cfb3a9283323c93af44" - integrity sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q== - -minipass@^2.6.0, minipass@^2.9.0: - version "2.9.0" - resolved "https://registry.yarnpkg.com/minipass/-/minipass-2.9.0.tgz#e713762e7d3e32fed803115cf93e04bca9fcc9a6" - integrity sha512-wxfUjg9WebH+CUDX/CdbRlh5SmfZiy/hpkxaRI16Y9W56Pa75sWgd/rvFilSgrauD9NyFymP/+JFV3KwzIsJeg== - dependencies: - safe-buffer "^5.1.2" - yallist "^3.0.0" - -minizlib@^1.3.3: - version "1.3.3" - resolved "https://registry.yarnpkg.com/minizlib/-/minizlib-1.3.3.tgz#2290de96818a34c29551c8a8d301216bd65a861d" - integrity sha512-6ZYMOEnmVsdCeTJVE0W9ZD+pVnE8h9Hma/iOwwRDsdQoePpoX56/8B6z3P9VNwppJuBKNRuFDRNRqRWexT9G9Q== - dependencies: - minipass "^2.9.0" - -mkdirp@^0.5.5: - version "0.5.5" - resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.5.tgz#d91cefd62d1436ca0f41620e251288d420099def" - integrity sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ== - dependencies: - minimist "^1.2.5" - -ms@^2.1.1: - version "2.1.3" - resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2" - integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA== - -node-fetch@2.6.7, node-fetch@~2.6.1: - version "2.6.7" - resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.7.tgz#24de9fba827e3b4ae44dc8b20256a379160052ad" - integrity sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ== - dependencies: - whatwg-url "^5.0.0" - -node-gles@^0.0.13: - version "0.0.13" - resolved "https://registry.yarnpkg.com/node-gles/-/node-gles-0.0.13.tgz#55df9725b047355284d8343af058d428e05eeeac" - integrity "sha1-Vd+XJbBHNVKE2DQ68FjUKOBe7qw= sha512-dEqRhLf/ZYZCxZJ8qxLYSOYkXKNNJb+mQcpVSg5RuF8sXvxK/eEWIhZqDl8pcboaDuXNEyeeVvTD8cpYlkJNdw==" - dependencies: - adm-zip "^0.4.13" - bindings "^1.3.0" - https-proxy-agent "^2.2.1" - progress "^2.0.3" - rimraf "^2.6.2" - tar "^4.4.8" - -once@^1.3.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" - integrity sha1-WDsap3WWHUsROsF9nFC6753Xa9E= - dependencies: - wrappy "1" - -path-is-absolute@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" - integrity sha1-F0uSaHNVNP+8es5r9TpanhtcX18= - -path-parse@^1.0.6: - version "1.0.7" - resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.7.tgz#fbc114b60ca42b30d9daf5858e4bd68bbedb6735" - integrity sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw== - -progress@^2.0.3: - version "2.0.3" - resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.3.tgz#7e8cf8d8f5b8f239c1bc68beb4eb78567d572ef8" - integrity sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA== - -resolve@^1.1.6, resolve@^1.3.2: - version "1.20.0" - resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.20.0.tgz#629a013fb3f70755d6f0b7935cc1c2c5378b1975" - integrity sha512-wENBPt4ySzg4ybFQW2TT1zMQucPK95HSh/nq2CFTZVOGut2+pQvSsgtda4d26YrYcr067wjbmzOG8byDPBX63A== - dependencies: - is-core-module "^2.2.0" - path-parse "^1.0.6" - -rimraf@^2.6.2: - version "2.7.1" - resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.7.1.tgz#35797f13a7fdadc566142c29d4f07ccad483e3ec" - integrity sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w== - dependencies: - glob "^7.1.3" - -safe-buffer@^5.1.2, safe-buffer@^5.2.1: - version "5.2.1" - resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" - integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== - -seedrandom@2.4.3: - version "2.4.3" - resolved "https://registry.yarnpkg.com/seedrandom/-/seedrandom-2.4.3.tgz#2438504dad33917314bff18ac4d794f16d6aaecc" - integrity sha1-JDhQTa0zkXMUv/GKxNeU8W1qrsw= - -semver@^5.3.0: - version "5.7.1" - resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" - integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ== - -source-map-support@^0.5.17: - version "0.5.19" - resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.19.tgz#a98b62f86dcaf4f67399648c085291ab9e8fed61" - integrity sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw== - dependencies: - buffer-from "^1.0.0" - source-map "^0.6.0" - -source-map@^0.6.0: - version "0.6.1" - resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" - integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== - -sprintf-js@~1.0.2: - version "1.0.3" - resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" - integrity sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw= - -strip-ansi@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-3.0.1.tgz#6a385fb8853d952d5ff05d0e8aaf94278dc63dcf" - integrity sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8= - dependencies: - ansi-regex "^2.0.0" - -supports-color@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7" - integrity sha1-U10EXOa2Nj+kARcIRimZXp3zJMc= - -supports-color@^5.3.0: - version "5.5.0" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f" - integrity sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow== - dependencies: - has-flag "^3.0.0" - -tar@^4.4.8: - version "4.4.19" - resolved "https://registry.yarnpkg.com/tar/-/tar-4.4.19.tgz#2e4d7263df26f2b914dee10c825ab132123742f3" - integrity sha512-a20gEsvHnWe0ygBY8JbxoM4w3SJdhc7ZAuxkLqh+nvNQN2IOt0B5lLgM490X5Hl8FF0dl0tOf2ewFYAlIFgzVA== - dependencies: - chownr "^1.1.4" - fs-minipass "^1.2.7" - minipass "^2.9.0" - minizlib "^1.3.3" - mkdirp "^0.5.5" - safe-buffer "^5.2.1" - yallist "^3.1.1" - -tr46@~0.0.3: - version "0.0.3" - resolved "https://registry.yarnpkg.com/tr46/-/tr46-0.0.3.tgz#8184fd347dac9cdc185992f3a6622e14b9d9ab6a" - integrity sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o= - -ts-node@^8.1.0: - version "8.10.2" - resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-8.10.2.tgz#eee03764633b1234ddd37f8db9ec10b75ec7fb8d" - integrity sha512-ISJJGgkIpDdBhWVu3jufsWpK3Rzo7bdiIXJjQc0ynKxVOVcg2oIrf2H2cejminGrptVc6q6/uynAHNCuWGbpVA== - dependencies: - arg "^4.1.0" - diff "^4.0.1" - make-error "^1.1.1" - source-map-support "^0.5.17" - yn "3.1.1" - -tslib@^1.8.0, tslib@^1.8.1: - version "1.14.1" - resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00" - integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg== - -tslint-no-circular-imports@^0.5.0: - version "0.5.2" - resolved "https://registry.yarnpkg.com/tslint-no-circular-imports/-/tslint-no-circular-imports-0.5.2.tgz#47ac9194ec531101ac19198d5144f7ac9f57d980" - integrity sha512-Uzu2NiVX7b/kAk9vPrLqUmoCkth0dXUUNOaqwfxpvYgsHfoH67cmj0IHOUMZ1bC0swksJjaTyq7acHe/gU8H4A== - -tslint@~5.9.1: - version "5.9.1" - resolved "https://registry.yarnpkg.com/tslint/-/tslint-5.9.1.tgz#1255f87a3ff57eb0b0e1f0e610a8b4748046c9ae" - integrity "sha1-ElX4ej/1frCw4fDmEKi0dIBGya4= sha512-EDEyKYflb79XSj/rX9abiYrpBJtdHvhYGnLaHNf3fW0KPlByePKwhlAmBtH4Y0PYQVkwPsrYSE6Fg1s8gDqucA==" - dependencies: - babel-code-frame "^6.22.0" - builtin-modules "^1.1.1" - chalk "^2.3.0" - commander "^2.12.1" - diff "^3.2.0" - glob "^7.1.1" - js-yaml "^3.7.0" - minimatch "^3.0.4" - resolve "^1.3.2" - semver "^5.3.0" - tslib "^1.8.0" - tsutils "^2.12.1" - -tsutils@^2.12.1: - version "2.29.0" - resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-2.29.0.tgz#32b488501467acbedd4b85498673a0812aca0b99" - integrity sha512-g5JVHCIJwzfISaXpXE1qvNalca5Jwob6FjI4AoPlqMusJ6ftFE7IkkFoMhVLRgK+4Kx3gkzb8UZK5t5yTTvEmA== - dependencies: - tslib "^1.8.1" - -typescript@3.5.3: - version "3.5.3" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.5.3.tgz#c830f657f93f1ea846819e929092f5fe5983e977" - integrity sha512-ACzBtm/PhXBDId6a6sDJfroT2pOWt/oOnk4/dElG5G33ZL776N3Y6/6bKZJBFpd+b05F3Ct9qDjMeJmRWtE2/g== - -webidl-conversions@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871" - integrity sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE= - -whatwg-url@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-5.0.0.tgz#966454e8765462e37644d3626f6742ce8b70965d" - integrity sha1-lmRU6HZUYuN2RNNib2dCzotwll0= - dependencies: - tr46 "~0.0.3" - webidl-conversions "^3.0.0" - -wrappy@1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" - integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8= - -yallist@^3.0.0, yallist@^3.1.1: - version "3.1.1" - resolved "https://registry.yarnpkg.com/yallist/-/yallist-3.1.1.tgz#dbb7daf9bfd8bac9ab45ebf602b8cbad0d5d08fd" - integrity sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g== - -yn@3.1.1: - version "3.1.1" - resolved "https://registry.yarnpkg.com/yn/-/yn-3.1.1.tgz#1e87401a09d767c1d5eab26a6e4c185182d2eb50" - integrity sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q== diff --git a/tfjs-master/tfjs-backend-wasm/.npmignore b/tfjs-master/tfjs-backend-wasm/.npmignore deleted file mode 100644 index 7f15f07af..000000000 --- a/tfjs-master/tfjs-backend-wasm/.npmignore +++ /dev/null @@ -1,23 +0,0 @@ -.vscode/ -.rpt2_cache/ -src/**/*_test.ts - -cloudbuild.yml -scripts/ -tools/ -toolchain/ -**/node_modules/ -karma.conf.js -*.tgz -*.log -WORKSPACE.md -tslint.json -yarn.lock -DEVELOPMENT.md -ISSUE_TEMPLATE.md -PULL_REQUEST_TEMPLATE.md -rollup.config.js -tsconfig.json -.yalc/ -yalc.lock -*.png diff --git a/tfjs-master/tfjs-backend-wasm/.npmrc b/tfjs-master/tfjs-backend-wasm/.npmrc deleted file mode 100644 index 43c97e719..000000000 --- a/tfjs-master/tfjs-backend-wasm/.npmrc +++ /dev/null @@ -1 +0,0 @@ -package-lock=false diff --git a/tfjs-master/tfjs-backend-wasm/.vscode/c_cpp_properties.json b/tfjs-master/tfjs-backend-wasm/.vscode/c_cpp_properties.json deleted file mode 100644 index 5aa2575ac..000000000 --- a/tfjs-master/tfjs-backend-wasm/.vscode/c_cpp_properties.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "configurations": [ - { - "name": "Linux", - "includePath": [ - "${workspaceFolder}/..", - "${workspaceFolder}/../dist/tfjs/external/emsdk/emsdk/upstream/emscripten/system/include", - "${workspaceFolder}/../dist/tfjs/external/com_google_googletest/googletest/include", - "${workspaceFolder}/../dist/tfjs/external/xnnpack/include", - "${workspaceFolder}/../dist/tfjs/external/pthreadpool/include" - ], - "defines": [], - "compilerPath": "/usr/bin/clang", - "cStandard": "c11", - "cppStandard": "c++11", - "intelliSenseMode": "clang-x64" - } - ], - "version": 4 -} diff --git a/tfjs-master/tfjs-backend-wasm/.vscode/settings.json b/tfjs-master/tfjs-backend-wasm/.vscode/settings.json deleted file mode 100644 index 5f30a3cfd..000000000 --- a/tfjs-master/tfjs-backend-wasm/.vscode/settings.json +++ /dev/null @@ -1 +0,0 @@ -../../.vscode/settings.json \ No newline at end of file diff --git a/tfjs-master/tfjs-backend-wasm/BUILD.bazel b/tfjs-master/tfjs-backend-wasm/BUILD.bazel deleted file mode 100644 index e7a3051a7..000000000 --- a/tfjs-master/tfjs-backend-wasm/BUILD.bazel +++ /dev/null @@ -1,185 +0,0 @@ -# Copyright 2021 Google LLC. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================= - -load("@bazel_skylib//rules:copy_file.bzl", "copy_file") -load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_test", "pkg_npm") -load("@npm//@bazel/rollup:index.bzl", "rollup_bundle") -load("//tools:copy_to_dist.bzl", "copy_to_dist", "copy_ts_library_to_dist") -load("//tools:get_extension.bzl", "get_extension") -load("//tools:tfjs_bundle.bzl", "tfjs_bundle") -load("//tools:tfjs_web_test.bzl", "tfjs_web_test") - -package(default_visibility = ["//visibility:public"]) - -tfjs_bundle( - name = "tf-backend-wasm", - entry_point = "//tfjs-backend-wasm/src:index.ts", - # When updating external, also update rollup_wechat.config.mjs - external = [ - "crypto", - "@tensorflow/tfjs-core", - "fs", - "path", - "worker_threads", - "perf_hooks", - ], - # When updating globals, also update rollup_wechat.config.mjs - globals = { - "@tensorflow/tfjs-core": "tf", - "fs": "fs", - "path": "path", - "perf_hooks": "perf_hooks", - "worker_threads": "worker_threads", - }, - leave_as_require = [ - "crypto", - "node-fetch", - "util", - ], - umd_name = "tf.wasm", - deps = [ - "//tfjs-backend-wasm/src:tfjs-backend-wasm_lib", - "//tfjs-backend-wasm/src:tfjs-backend-wasm_src_lib", - ], -) - -rollup_bundle( - name = "tf-backend-wasm-miniprogram.min", - args = ["--output.name=tf"], - config_file = "rollup_wechat.config.mjs", - entry_point = "//tfjs-backend-wasm/src:index.ts", - format = "umd", - sourcemap = "true", - deps = [ - "//tfjs-backend-wasm/scripts:patch_wechat_webassembly", - "//tfjs-backend-wasm/src:tfjs-backend-wasm_lib", - "//tools:make_rollup_config", - "@npm//tslib", - ], -) - -copy_ts_library_to_dist( - name = "copy_src_to_dist", - srcs = [ - "//tfjs-backend-wasm/src:tfjs-backend-wasm_lib", - "//tfjs-backend-wasm/src:tfjs-backend-wasm_src_lib", - ], - root = "src", -) - -copy_to_dist( - name = "copy_bundles", - srcs = [ - ":tf-backend-wasm", - ":tf-backend-wasm.es2017", - ":tf-backend-wasm.es2017.min", - ":tf-backend-wasm.fesm", - ":tf-backend-wasm.fesm.min", - ":tf-backend-wasm.min", - ":tf-backend-wasm.node", - ], -) - -get_extension( - name = "wasm_files", - srcs = [ - "//tfjs-backend-wasm/wasm-out", - ], - include = [ - ".wasm", - ], -) - -copy_to_dist( - name = "copy_wasm_files", - srcs = [ - ":wasm_files", - ], - root = "wasm-out", -) - -copy_file( - name = "copy_miniprogram", - src = ":tf-backend-wasm-miniprogram.min.js", - out = "dist/miniprogram/index.js", -) - -copy_file( - name = "copy_miniprogram_map", - src = ":tf-backend-wasm-miniprogram.min.js.map", - out = "dist/miniprogram/index.js.map", -) - -pkg_npm( - name = "tfjs-backend-wasm_pkg", - package_name = "@tensorflow/tfjs-backend-wasm", - srcs = [ - "README.md", - "package.json", - ], - tags = ["ci"], - deps = [ - ":copy_bundles", - ":copy_miniprogram", - ":copy_miniprogram_map", - ":copy_src_to_dist", - ":copy_wasm_files", - "//tfjs-backend-wasm/wasm-out", - ], -) - -# TODO(mattsoulanille): This test uses the default chrome flags and tests -# the simd implementation. We should also test the non-simd implementation and -# the threaded implementation. When writing those tests, also try to depend on -# only the required wasm outputs, since it takes a long time to compile them. -tfjs_web_test( - name = "tfjs-backend-wasm_test", - srcs = [ - "//tfjs-backend-wasm/src:tfjs-backend-wasm_test_bundle", - ], - browsers = [ - "bs_chrome_mac", - "bs_firefox_mac", - "bs_safari_mac", - "bs_ios_12", - # TODO(mattsoulanille): Fix clipByValue on Android. - # "bs_android_10", - "win_10_chrome", - ], - static_files = [ - "//tfjs-backend-wasm/src:tfjs-backend-wasm_test_bundle", - "//tfjs-backend-wasm/wasm-out", - ], -) - -nodejs_test( - name = "tfjs-backend-wasm_node_test", - data = [ - "//tfjs-backend-wasm/src:tfjs-backend-wasm_src_lib", - "//tfjs-backend-wasm/src:tfjs-backend-wasm_test_lib", - "//tfjs-backend-wasm/wasm-out", - ], - entry_point = "//tfjs-backend-wasm/src:test_node.ts", - tags = ["ci"], -) - -test_suite( - name = "tests", - tests = [ - ":tfjs-backend-wasm_node_test", - ":tfjs-backend-wasm_test", - "//tfjs-backend-wasm/src/cc:cc_tests", - ], -) diff --git a/tfjs-master/tfjs-backend-wasm/README.md b/tfjs-master/tfjs-backend-wasm/README.md deleted file mode 100644 index 59397cfb8..000000000 --- a/tfjs-master/tfjs-backend-wasm/README.md +++ /dev/null @@ -1,348 +0,0 @@ -# Usage - -This package adds a WebAssembly backend to TensorFlow.js. It currently supports -the following models from our -[models](https://github.com/tensorflow/tfjs-models) repo: -- BlazeFace -- BodyPix -- CocoSSD -- Face landmarks detection -- HandPose -- KNN classifier -- MobileNet -- PoseDetection -- Q&A -- Universal sentence encoder -- AutoML Image classification -- AutoML Object detection - -## Importing the backend - -### Via NPM - -```js -// Import @tensorflow/tfjs or @tensorflow/tfjs-core -import * as tf from '@tensorflow/tfjs'; -// Adds the WASM backend to the global backend registry. -import '@tensorflow/tfjs-backend-wasm'; -// Set the backend to WASM and wait for the module to be ready. -tf.setBackend('wasm').then(() => main()); -``` - -### Via a script tag - -```html - - - - - - -``` - -## Setting up cross-origin isolation - -Starting from Chrome 92 (to be released around July 2021), **cross-origin -isolation** needs to be set up in your site in order to take advantage of -the multi-threading support in WASM backend. Without this, the backend -will fallback to the WASM binary with SIMD-only support (or the vanila version -if SIMD is not enabled). Without multi-threading support, certain models might -not achieve the best performance. - -Here are the high-level steps to set up the cross-origin isolation. You can -learn more about this topic [here](https://web.dev/coop-coep/). - -1. Send the following two HTTP headers when your main document (e.g.index.html) - that uses the WASM backend is served. You may need to configure or ask your - web host provider to enable these headers. - - - `Cross-Origin-Opener-Policy: same-origin` - - `Cross-Origin-Embedder-Policy: require-corp` - -1. If you are loading the WASM backend from `jsdelivr` through the script tag, - you are good to go. No more steps are needed. - - If you are loading the WASM backend from your own or other third-party - servers, you need to make sure the script is served with either CORS or CORP - header. - - - CORS header: `Access-Control-Allow-Origin: *`. In addition, you will also - need to add the "crossorigin" attribute to your script tags. - - - CORP header: - - - If the resource is loaded from the *same origin* as your main site - (e.g. main site: mysite.com/, script: mysite.com/script.js), set: - - `Cross-Origin-Resource-Policy: same-origin` - - If the resource is loaded from the *same site but cross origin* - (e.g. main site: mysite.com/, script: static.mysite.com:8080/script.js), - set: - - - `Cross-Origin-Resource-Policy: same-site` - - If the resource is loaded from the *cross origin(s)* - (e.g. main site: mysite.com/, script: mystatic.com/script.js), set: - - `Cross-Origin-Resource-Policy: cross-origin` - -If the steps above are correctly done, you can check the Network tab from the -console and make sure the -tfjs-backend-wasm-threaded-simd.wasm WASM binary is loaded. - -## Threads count - -By default, the backend will use the number of logical CPU cores as the -threads count when creating the threadpool used by XNNPACK. You can use the -`setThreadsCount` API to manually set it (must be called before calling -`tf.setBackend('wasm')`). `getThreadsCount` API can be used to get the actual -number of threads being used (must be called after the WASM backend is -initialized). - -### Via NPM - -```js -import * as tf from '@tensorflow/tfjs'; -import {getThreadsCount, setThreadsCount} from '@tensorflow/tfjs-backend-wasm'; - -setThreadsCount(2); -tf.setBackend('wasm').then(() => { - console.log(getThreadsCount()); -}); -``` - -### Via script tag - -```js -tf.wasm.setThreadsCount(2); -tf.setBackend('wasm').then(() => { - console.log(tf.wasm.getThreadsCount()); -}); -``` - -## Running MobileNet - -```js -async function main() { - let img = tf.browser.fromPixels(document.getElementById('img')) - .resizeBilinear([224, 224]) - .expandDims(0) - .toFloat(); - - let model = await tf.loadGraphModel( - 'https://tfhub.dev/google/imagenet/mobilenet_v2_100_224/classification/2', - {fromTFHub: true}); - const y = model.predict(img); - - y.print(); -} -main(); -``` - -Our WASM backend builds on top of the -[XNNPACK library](https://github.com/google/XNNPACK) which provides -high-efficiency floating-point neural network inference operators. - -## Using bundlers - -The shipped library on NPM consists of 2 files: -- the main js file (bundled js for browsers) -- the WebAssembly binary in `dist/tfjs-backend-wasm.wasm` - -There is a [proposal](https://github.com/WebAssembly/esm-integration) to add -WASM support for ES6 modules. In the meantime, we have to manually read the wasm -file. When the WASM backend is initialized, we make a `fetch`/`readFile` -for `tfjs-backend-wasm.wasm` relative from the main js file. This means that -bundlers such as Parcel and WebPack need to be able to serve the `.wasm` file in -production. See [starter/parcel](./starter/parcel/) and -[starter/webpack](./starter/webpack/) for how to setup your favorite bundler. - -If you are serving the `.wasm` files from a different directory, call -`setWasmPaths` with the location of that directory before you initialize the -backend: - -```ts -import {setWasmPaths} from '@tensorflow/tfjs-backend-wasm'; -// setWasmPaths accepts a `prefixOrFileMap` argument which can be either a -// string or an object. If passing in a string, this indicates the path to -// the directory where your WASM binaries are located. -setWasmPaths('www.yourdomain.com/'); -tf.setBackend('wasm').then(() => {...}); -``` - -If the WASM backend is imported through ` - - diff --git a/tfjs-master/tfjs-backend-wasm/starter/parcel/index.js b/tfjs-master/tfjs-backend-wasm/starter/parcel/index.js deleted file mode 100644 index 6a4983988..000000000 --- a/tfjs-master/tfjs-backend-wasm/starter/parcel/index.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2019 Google LLC. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= -import '@tensorflow/tfjs-backend-wasm'; -import * as tf from '@tensorflow/tfjs-core'; - -async function run() { - await tf.setBackend('wasm'); - tf.add(5, 3).print(); -} -run(); diff --git a/tfjs-master/tfjs-backend-wasm/starter/parcel/package.json b/tfjs-master/tfjs-backend-wasm/starter/parcel/package.json deleted file mode 100644 index 584177216..000000000 --- a/tfjs-master/tfjs-backend-wasm/starter/parcel/package.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "name": "wasm-parcel", - "version": "1.0.0", - "description": "Sample parcel app that uses the WASM backend", - "scripts": { - "watch": "parcel index.html --open", - "build": "parcel build index.html" - }, - "dependencies": { - "@tensorflow/tfjs-backend-wasm": "3.14.0", - "@tensorflow/tfjs-core": "3.14.0" - }, - "browserslist": [ - "defaults" - ], - "staticFiles": { - "staticPath": "./node_modules/@tensorflow/tfjs-backend-wasm/dist", - "excludeGlob": [ - "**/!(*.wasm)" - ] - }, - "devDependencies": { - "parcel": "^2.3.2", - "parcel-reporter-static-files-copy": "^1.3.4" - }, - "resolutions": { - "minimist": "1.2.6" - }, - "keywords": [] -} diff --git a/tfjs-master/tfjs-backend-wasm/starter/parcel/yarn.lock b/tfjs-master/tfjs-backend-wasm/starter/parcel/yarn.lock deleted file mode 100644 index 9fa740278..000000000 --- a/tfjs-master/tfjs-backend-wasm/starter/parcel/yarn.lock +++ /dev/null @@ -1,1654 +0,0 @@ -# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. -# yarn lockfile v1 - - -"@babel/code-frame@^7.0.0": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.16.7.tgz#44416b6bd7624b998f5b1af5d470856c40138789" - integrity sha512-iAXqUn8IIeBTNd72xsFlgaXHkMBMt6y4HJp1tIaK465CWLT/fG1aqB7ykr95gHHmlBdGbFeWWfyB4NJJ0nmeIg== - dependencies: - "@babel/highlight" "^7.16.7" - -"@babel/helper-validator-identifier@^7.16.7": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz#e8c602438c4a8195751243da9031d1607d247cad" - integrity sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw== - -"@babel/highlight@^7.16.7": - version "7.16.10" - resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.16.10.tgz#744f2eb81579d6eea753c227b0f570ad785aba88" - integrity sha512-5FnTQLSLswEj6IkgVw5KusNUUFY9ZGqe/TRFnP/BKYHYgfh7tc+C7mwiy95/yNP7Dh9x580Vv8r7u7ZfTBFxdw== - dependencies: - "@babel/helper-validator-identifier" "^7.16.7" - chalk "^2.0.0" - js-tokens "^4.0.0" - -"@jridgewell/gen-mapping@^0.3.0": - version "0.3.2" - resolved "https://registry.yarnpkg.com/@jridgewell/gen-mapping/-/gen-mapping-0.3.2.tgz#c1aedc61e853f2bb9f5dfe6d4442d3b565b253b9" - integrity sha512-mh65xKQAzI6iBcFzwv28KVWSmCkdRBWoOh+bYQGW3+6OZvbbN3TqMGo5hqYxQniRcH9F2VZIoJCm4pa3BPDK/A== - dependencies: - "@jridgewell/set-array" "^1.0.1" - "@jridgewell/sourcemap-codec" "^1.4.10" - "@jridgewell/trace-mapping" "^0.3.9" - -"@jridgewell/resolve-uri@^3.0.3": - version "3.1.0" - resolved "https://registry.yarnpkg.com/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz#2203b118c157721addfe69d47b70465463066d78" - integrity sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w== - -"@jridgewell/set-array@^1.0.1": - version "1.1.2" - resolved "https://registry.yarnpkg.com/@jridgewell/set-array/-/set-array-1.1.2.tgz#7c6cf998d6d20b914c0a55a91ae928ff25965e72" - integrity sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw== - -"@jridgewell/source-map@^0.3.2": - version "0.3.2" - resolved "https://registry.yarnpkg.com/@jridgewell/source-map/-/source-map-0.3.2.tgz#f45351aaed4527a298512ec72f81040c998580fb" - integrity sha512-m7O9o2uR8k2ObDysZYzdfhb08VuEml5oWGiosa1VdaPZ/A6QyPkAJuwN0Q1lhULOf6B7MtQmHENS743hWtCrgw== - dependencies: - "@jridgewell/gen-mapping" "^0.3.0" - "@jridgewell/trace-mapping" "^0.3.9" - -"@jridgewell/sourcemap-codec@^1.4.10": - version "1.4.14" - resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz#add4c98d341472a289190b424efbdb096991bb24" - integrity sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw== - -"@jridgewell/trace-mapping@^0.3.9": - version "0.3.14" - resolved "https://registry.yarnpkg.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.14.tgz#b231a081d8f66796e475ad588a1ef473112701ed" - integrity sha512-bJWEfQ9lPTvm3SneWwRFVLzrh6nhjwqw7TUFFBEMzwvg7t7PCDenf2lDwqo4NQXzdpgBXyFgDWnQA+2vkruksQ== - dependencies: - "@jridgewell/resolve-uri" "^3.0.3" - "@jridgewell/sourcemap-codec" "^1.4.10" - -"@parcel/bundler-default@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/bundler-default/-/bundler-default-2.3.2.tgz#329f171e210dfb22beaa52ae706ccde1dae384c1" - integrity sha512-JUrto4mjSD0ic9dEqRp0loL5o3HVYHja1ZIYSq+rBl2UWRV6/9cGTb07lXOCqqm0BWE+hQ4krUxB76qWaF0Lqw== - dependencies: - "@parcel/diagnostic" "2.3.2" - "@parcel/hash" "2.3.2" - "@parcel/plugin" "2.3.2" - "@parcel/utils" "2.3.2" - nullthrows "^1.1.1" - -"@parcel/cache@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/cache/-/cache-2.3.2.tgz#ba8c2af02fd45b90c7bc6f829bfc566d1ded0a13" - integrity sha512-Xxq+ekgcFEme6Fn1v7rEOBkyMOUOUu7eNqQw0l6HQS+INZ2Q7YzzfdW7pI8rEOAAICVg5BWKpmBQZpgJlT+HxQ== - dependencies: - "@parcel/fs" "2.3.2" - "@parcel/logger" "2.3.2" - "@parcel/utils" "2.3.2" - lmdb "^2.0.2" - -"@parcel/codeframe@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/codeframe/-/codeframe-2.3.2.tgz#73fb5a89910b977342808ca8f6ece61fa01b7690" - integrity sha512-ireQALcxxrTdIEpzTOoMo/GpfbFm1qlyezeGl3Hce3PMvHLg3a5S6u/Vcy7SAjdld5GfhHEqVY+blME6Z4CyXQ== - dependencies: - chalk "^4.1.0" - -"@parcel/compressor-raw@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/compressor-raw/-/compressor-raw-2.3.2.tgz#1a808ae9e61ed86f655935e1d2a984383b3c00a7" - integrity sha512-8dIoFwinYK6bOTpnZOAwwIv0v73y0ezsctPmfMnIqVQPn7wJwfhw/gbKVcmK5AkgQMkyid98hlLZoaZtGF1Mdg== - dependencies: - "@parcel/plugin" "2.3.2" - -"@parcel/config-default@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/config-default/-/config-default-2.3.2.tgz#3f21a37fa07b22de9cd6b1aea19bc310a02d4abb" - integrity sha512-E7/iA7fGCYvXU3u6zF9nxjeDVsgjCN6MVvDjymjaxYMoDWTIsPV245SBEXqzgtmzbMAV+VAl4rVWLMB4pzMt9g== - dependencies: - "@parcel/bundler-default" "2.3.2" - "@parcel/compressor-raw" "2.3.2" - "@parcel/namer-default" "2.3.2" - "@parcel/optimizer-cssnano" "2.3.2" - "@parcel/optimizer-htmlnano" "2.3.2" - "@parcel/optimizer-image" "2.3.2" - "@parcel/optimizer-svgo" "2.3.2" - "@parcel/optimizer-terser" "2.3.2" - "@parcel/packager-css" "2.3.2" - "@parcel/packager-html" "2.3.2" - "@parcel/packager-js" "2.3.2" - "@parcel/packager-raw" "2.3.2" - "@parcel/packager-svg" "2.3.2" - "@parcel/reporter-dev-server" "2.3.2" - "@parcel/resolver-default" "2.3.2" - "@parcel/runtime-browser-hmr" "2.3.2" - "@parcel/runtime-js" "2.3.2" - "@parcel/runtime-react-refresh" "2.3.2" - "@parcel/runtime-service-worker" "2.3.2" - "@parcel/transformer-babel" "2.3.2" - "@parcel/transformer-css" "2.3.2" - "@parcel/transformer-html" "2.3.2" - "@parcel/transformer-image" "2.3.2" - "@parcel/transformer-js" "2.3.2" - "@parcel/transformer-json" "2.3.2" - "@parcel/transformer-postcss" "2.3.2" - "@parcel/transformer-posthtml" "2.3.2" - "@parcel/transformer-raw" "2.3.2" - "@parcel/transformer-react-refresh-wrap" "2.3.2" - "@parcel/transformer-svg" "2.3.2" - -"@parcel/core@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/core/-/core-2.3.2.tgz#1b9a79c1ff96dba5e0f53d4277bed4e7ab4590d0" - integrity sha512-gdJzpsgeUhv9H8T0UKVmyuptiXdduEfKIUx0ci+/PGhq8cCoiFnlnuhW6H7oLr79OUc+YJStabDJuG4U2A6ysw== - dependencies: - "@parcel/cache" "2.3.2" - "@parcel/diagnostic" "2.3.2" - "@parcel/events" "2.3.2" - "@parcel/fs" "2.3.2" - "@parcel/graph" "2.3.2" - "@parcel/hash" "2.3.2" - "@parcel/logger" "2.3.2" - "@parcel/package-manager" "2.3.2" - "@parcel/plugin" "2.3.2" - "@parcel/source-map" "^2.0.0" - "@parcel/types" "2.3.2" - "@parcel/utils" "2.3.2" - "@parcel/workers" "2.3.2" - abortcontroller-polyfill "^1.1.9" - base-x "^3.0.8" - browserslist "^4.6.6" - clone "^2.1.1" - dotenv "^7.0.0" - dotenv-expand "^5.1.0" - json-source-map "^0.6.1" - json5 "^2.2.0" - msgpackr "^1.5.1" - nullthrows "^1.1.1" - semver "^5.7.1" - -"@parcel/diagnostic@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/diagnostic/-/diagnostic-2.3.2.tgz#1d3f0b55bfd9839c6f41d704ebbc89a96cca88dc" - integrity sha512-/xW93Az4AOiifuYW/c4CDbUcu3lx5FcUDAj9AGiR9NSTsF/ROC/RqnxvQ3AGtqa14R7vido4MXEpY3JEp6FsqA== - dependencies: - json-source-map "^0.6.1" - nullthrows "^1.1.1" - -"@parcel/events@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/events/-/events-2.3.2.tgz#b6bcfbbc96d883716ee9d0e6ab232acdee862790" - integrity sha512-WiYIwXMo4Vd+pi58vRoHkul8TPE5VEfMY+3FYwVCKPl/LYqSD+vz6wMx9uG18mEbB1d/ofefv5ZFQNtPGKO4tQ== - -"@parcel/fs-search@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/fs-search/-/fs-search-2.3.2.tgz#18611877ac1b370932c71987c2ec0e93a4a7e53d" - integrity sha512-u3DTEFnPtKuZvEtgGzfVjQUytegSSn3POi7WfwMwPIaeDPfYcyyhfl+c96z7VL9Gk/pqQ99/cGyAwFdFsnxxXA== - dependencies: - detect-libc "^1.0.3" - -"@parcel/fs@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/fs/-/fs-2.3.2.tgz#9628441a84c2582e1f6e69549feb0da0cc143e40" - integrity sha512-XV+OsnRpN01QKU37lBN0TFKvv7uPKfQGbqFqYOrMbXH++Ae8rBU0Ykz+Yu4tv2h7shMlde+AMKgRnRTAJZpWEQ== - dependencies: - "@parcel/fs-search" "2.3.2" - "@parcel/types" "2.3.2" - "@parcel/utils" "2.3.2" - "@parcel/watcher" "^2.0.0" - "@parcel/workers" "2.3.2" - -"@parcel/graph@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/graph/-/graph-2.3.2.tgz#4194816952ab322ab22a17f7d9ea17befbade64d" - integrity sha512-ltTBM3IEqumgmy4ABBFETT8NtAwSsjD9mY3WCyJ5P8rUshfVCg093rvBPbpuJYMaH/TV1AHVaWfZqaZ4JQDIQQ== - dependencies: - "@parcel/utils" "2.3.2" - nullthrows "^1.1.1" - -"@parcel/hash@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/hash/-/hash-2.3.2.tgz#33b8ff04bb44f6661bdc1054b302ef1b6bd3acb3" - integrity sha512-SMtYTsHihws/wqdVnOr0QAGyGYsW9rJSJkkoRujUxo8l2ctnBN1ztv89eOUrdtgHsmcnj/oz1yw6sN38X+BUng== - dependencies: - detect-libc "^1.0.3" - xxhash-wasm "^0.4.2" - -"@parcel/logger@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/logger/-/logger-2.3.2.tgz#b5fc7a9c1664ee0286d0f67641c7c81c8fec1561" - integrity sha512-jIWd8TXDQf+EnNWSa7Q10lSQ6C1LSH8OZkTlaINrfVIw7s+3tVxO3I4pjp7/ARw7RX2gdNPlw6fH4Gn/HvvYbw== - dependencies: - "@parcel/diagnostic" "2.3.2" - "@parcel/events" "2.3.2" - -"@parcel/markdown-ansi@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/markdown-ansi/-/markdown-ansi-2.3.2.tgz#2a5be7ce76a506a9d238ea2257cb28e43abe4902" - integrity sha512-l01ggmag5QScCk9mYA0xHh5TWSffR84uPFP2KvaAMQQ9NLNufcFiU0mn/Mtr3pCb5L5dSzmJ+Oo9s7P1Kh/Fmg== - dependencies: - chalk "^4.1.0" - -"@parcel/namer-default@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/namer-default/-/namer-default-2.3.2.tgz#84e17abfc84fd293b23b3f405280ed2e279c75d8" - integrity sha512-3QUMC0+5+3KMKfoAxYAbpZtuRqTgyZKsGDWzOpuqwemqp6P8ahAvNPwSCi6QSkGcTmvtYwBu9/NHPSONxIFOfg== - dependencies: - "@parcel/diagnostic" "2.3.2" - "@parcel/plugin" "2.3.2" - nullthrows "^1.1.1" - -"@parcel/node-resolver-core@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/node-resolver-core/-/node-resolver-core-2.3.2.tgz#dd360f405949fdcd62980cd44825052ab28f6135" - integrity sha512-wmrnMNzJN4GuHw2Ftho+BWgSWR6UCkW3XoMdphqcxpw/ieAdS2a+xYSosYkZgQZ6lGutSvLyJ1CkVvP6RLIdQQ== - dependencies: - "@parcel/diagnostic" "2.3.2" - "@parcel/utils" "2.3.2" - nullthrows "^1.1.1" - -"@parcel/optimizer-cssnano@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/optimizer-cssnano/-/optimizer-cssnano-2.3.2.tgz#70758f6646fd4debc26a90ae7dddf398928c0ce1" - integrity sha512-wTBOxMiBI38NAB9XIlQZRCjS59+EWjWR9M04D3TWyxl+dL5gYMc1cl4GNynUnmcPdz+3s1UbOdo5/8V90wjiiw== - dependencies: - "@parcel/plugin" "2.3.2" - "@parcel/source-map" "^2.0.0" - cssnano "^5.0.15" - postcss "^8.4.5" - -"@parcel/optimizer-htmlnano@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/optimizer-htmlnano/-/optimizer-htmlnano-2.3.2.tgz#4086736866621182f5dd1a8abe78e9f5764e1a28" - integrity sha512-U8C0TDSxsx8HmHaLW0Zc7ha1fXQynzhvBjCRMGYnOiLiw0MOfLQxzQ2WKVSeCotmdlF63ayCwxWsd6BuqStiKQ== - dependencies: - "@parcel/plugin" "2.3.2" - htmlnano "^2.0.0" - nullthrows "^1.1.1" - posthtml "^0.16.5" - svgo "^2.4.0" - -"@parcel/optimizer-image@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/optimizer-image/-/optimizer-image-2.3.2.tgz#0549cc1abc99fdd6f46bd44ce8551eb135e44d4f" - integrity sha512-HOk3r5qdvY/PmI7Q3i2qEgFH3kP2QWG4Wq3wmC4suaF1+c2gpiQc+HKHWp4QvfbH3jhT00c5NxQyqPhbXeNI9Q== - dependencies: - "@parcel/diagnostic" "2.3.2" - "@parcel/plugin" "2.3.2" - "@parcel/utils" "2.3.2" - "@parcel/workers" "2.3.2" - detect-libc "^1.0.3" - -"@parcel/optimizer-svgo@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/optimizer-svgo/-/optimizer-svgo-2.3.2.tgz#ebf2f48f356ad557d2bbfae361520d3d29bc1c37" - integrity sha512-l7WvZ5+e7D1mVmLUxMVaSb29cviXzuvSY2OpQs0ukdPACDqag+C65hWMzwTiOSSRGPMIu96kQKpeVru2YjibhA== - dependencies: - "@parcel/diagnostic" "2.3.2" - "@parcel/plugin" "2.3.2" - "@parcel/utils" "2.3.2" - svgo "^2.4.0" - -"@parcel/optimizer-terser@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/optimizer-terser/-/optimizer-terser-2.3.2.tgz#790b69e6ecc6ef0d8f25b57e9a13806e1f1c2943" - integrity sha512-dOapHhfy0xiNZa2IoEyHGkhhla07xsja79NPem14e5jCqY6Oi40jKNV4ab5uu5u1elWUjJuw69tiYbkDZWbKQw== - dependencies: - "@parcel/diagnostic" "2.3.2" - "@parcel/plugin" "2.3.2" - "@parcel/source-map" "^2.0.0" - "@parcel/utils" "2.3.2" - nullthrows "^1.1.1" - terser "^5.2.0" - -"@parcel/package-manager@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/package-manager/-/package-manager-2.3.2.tgz#380f0741c9d0c79c170c437efae02506484df315" - integrity sha512-pAQfywKVORY8Ee+NHAyKzzQrKbnz8otWRejps7urwhDaTVLfAd5C/1ZV64ATZ9ALYP9jyoQ8bTaxVd4opcSuwg== - dependencies: - "@parcel/diagnostic" "2.3.2" - "@parcel/fs" "2.3.2" - "@parcel/logger" "2.3.2" - "@parcel/types" "2.3.2" - "@parcel/utils" "2.3.2" - "@parcel/workers" "2.3.2" - semver "^5.7.1" - -"@parcel/packager-css@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/packager-css/-/packager-css-2.3.2.tgz#4994d872449843c1c0cda524b6df3327e2f0a121" - integrity sha512-ByuF9xDnQnpVL1Hdu9aY6SpxOuZowd3TH7joh1qdRPLeMHTEvUywHBXoiAyNdrhnLGum8uPEdY8Ra5Xuo1U7kg== - dependencies: - "@parcel/plugin" "2.3.2" - "@parcel/source-map" "^2.0.0" - "@parcel/utils" "2.3.2" - nullthrows "^1.1.1" - -"@parcel/packager-html@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/packager-html/-/packager-html-2.3.2.tgz#e54085fbaa49bed4258ffef80bc36b421895965f" - integrity sha512-YqAptdU+uqfgwSii76mRGcA/3TpuC6yHr8xG+11brqj/tEFLsurmX0naombzd7FgmrTE9w+kb0HUIMl2vRBn0A== - dependencies: - "@parcel/plugin" "2.3.2" - "@parcel/types" "2.3.2" - "@parcel/utils" "2.3.2" - nullthrows "^1.1.1" - posthtml "^0.16.5" - -"@parcel/packager-js@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/packager-js/-/packager-js-2.3.2.tgz#2d2566bde0da921042b79aa827c71109665d795c" - integrity sha512-3OP0Ro9M1J+PIKZK4Ec2N5hjIPiqk++B2kMFeiUqvaNZjJgKrPPEICBhjS52rma4IE/NgmIMB3aI5pWqE/KwNA== - dependencies: - "@parcel/diagnostic" "2.3.2" - "@parcel/hash" "2.3.2" - "@parcel/plugin" "2.3.2" - "@parcel/source-map" "^2.0.0" - "@parcel/utils" "2.3.2" - globals "^13.2.0" - nullthrows "^1.1.1" - -"@parcel/packager-raw@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/packager-raw/-/packager-raw-2.3.2.tgz#869cc3e7bee8ff3655891a0af400cf4e7dd4f144" - integrity sha512-RnoZ7WgNAFWkEPrEefvyDqus7xfv9XGprHyTbfLittPaVAZpl+4eAv43nXyMfzk77Cgds6KcNpkosj3acEpNIQ== - dependencies: - "@parcel/plugin" "2.3.2" - -"@parcel/packager-svg@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/packager-svg/-/packager-svg-2.3.2.tgz#a7a02e22642ae93f42b8bfd7d122b4a159988743" - integrity sha512-iIC0VeczOXynS7M5jCi3naMBRyAznBVJ3iMg92/GaI9duxPlUMGAlHzLAKNtoXkc00HMXDH7rrmMb04VX6FYSg== - dependencies: - "@parcel/plugin" "2.3.2" - "@parcel/types" "2.3.2" - "@parcel/utils" "2.3.2" - posthtml "^0.16.4" - -"@parcel/plugin@2.3.2", "@parcel/plugin@^2.0.0-beta.1": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/plugin/-/plugin-2.3.2.tgz#7701c40567d2eddd5d5b2b6298949cd03a2a22fa" - integrity sha512-SaLZAJX4KH+mrAmqmcy9KJN+V7L+6YNTlgyqYmfKlNiHu7aIjLL+3prX8QRcgGtjAYziCxvPj0cl1CCJssaiGg== - dependencies: - "@parcel/types" "2.3.2" - -"@parcel/reporter-cli@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/reporter-cli/-/reporter-cli-2.3.2.tgz#0617e088aac5ef7fa255d088e7016bb4f9d66a53" - integrity sha512-VYetmTXqW83npsvVvqlQZTbF3yVL3k/FCCl3kSWvOr9LZA0lmyqJWPjMHq37yIIOszQN/p5guLtgCjsP0UQw1Q== - dependencies: - "@parcel/plugin" "2.3.2" - "@parcel/types" "2.3.2" - "@parcel/utils" "2.3.2" - chalk "^4.1.0" - -"@parcel/reporter-dev-server@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/reporter-dev-server/-/reporter-dev-server-2.3.2.tgz#46ee4c53ad08c8b8afd2c79fb37381b6ba55cfb5" - integrity sha512-E7LtnjAX4iiWMw2qKUyFBi3+bDz0UGjqgHoPQylUYYLi6opXjJz/oC+cCcCy4e3RZlkrl187XonvagS59YjDxA== - dependencies: - "@parcel/plugin" "2.3.2" - "@parcel/utils" "2.3.2" - -"@parcel/resolver-default@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/resolver-default/-/resolver-default-2.3.2.tgz#286070412ad7fe506f7c88409f39b362d2041798" - integrity sha512-y3r+xOwWsATrNGUWuZ6soA7q24f8E5tY1AZ9lHCufnkK2cdKZJ5O1cyd7ohkAiKZx2/pMd+FgmVZ/J3oxetXkA== - dependencies: - "@parcel/node-resolver-core" "2.3.2" - "@parcel/plugin" "2.3.2" - -"@parcel/runtime-browser-hmr@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/runtime-browser-hmr/-/runtime-browser-hmr-2.3.2.tgz#cb23a850324ea792168438a9be6a345ebb66eb6d" - integrity sha512-nRD6uOyF1+HGylP9GASbYmvUDOsDaNwvaxuGTSh8+5M0mmCgib+hVBiPEKbwdmKjGbUPt9wRFPyMa/JpeQZsIQ== - dependencies: - "@parcel/plugin" "2.3.2" - "@parcel/utils" "2.3.2" - -"@parcel/runtime-js@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/runtime-js/-/runtime-js-2.3.2.tgz#c0e14251ce43f95977577e23bb9ac5c2487f3bb1" - integrity sha512-SJepcHvYO/7CEe/Q85sngk+smcJ6TypuPh4D2R8kN+cAJPi5WvbQEe7+x5BEgbN+5Jumi/Uo3FfOOE5mYh+F6g== - dependencies: - "@parcel/plugin" "2.3.2" - "@parcel/utils" "2.3.2" - nullthrows "^1.1.1" - -"@parcel/runtime-react-refresh@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/runtime-react-refresh/-/runtime-react-refresh-2.3.2.tgz#11961d7429ae3333b7efe14c4f57515df57eb5f2" - integrity sha512-P+GRPO2XVDSBQ4HmRSj2xfbHSQvL9+ahTE/AB74IJExLTITv5l4SHAV3VsiKohuHYUAYHW3A/Oe7tEFCAb6Cug== - dependencies: - "@parcel/plugin" "2.3.2" - "@parcel/utils" "2.3.2" - react-refresh "^0.9.0" - -"@parcel/runtime-service-worker@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/runtime-service-worker/-/runtime-service-worker-2.3.2.tgz#aa91797e57d1bb5b2aac04ac62c5410709ae0a27" - integrity sha512-iREHj/eapphC4uS/zGUkiTJvG57q+CVbTrfE42kB8ECtf/RYNo5YC9htdvPZjRSXDPrEPc5NCoKp4X09ENNikw== - dependencies: - "@parcel/plugin" "2.3.2" - "@parcel/utils" "2.3.2" - nullthrows "^1.1.1" - -"@parcel/source-map@^2.0.0": - version "2.0.2" - resolved "https://registry.yarnpkg.com/@parcel/source-map/-/source-map-2.0.2.tgz#9aa0b00518cee31d5634de6e9c924a5539b142c1" - integrity sha512-NnUrPYLpYB6qyx2v6bcRPn/gVigmGG6M6xL8wIg/i0dP1GLkuY1nf+Hqdf63FzPTqqT7K3k6eE5yHPQVMO5jcA== - dependencies: - detect-libc "^1.0.3" - -"@parcel/transformer-babel@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/transformer-babel/-/transformer-babel-2.3.2.tgz#2d8c0d1f95d9747936d132dc4c34edb0b6b80d39" - integrity sha512-QpWfH2V6jJ+kcUBIMM/uBBG8dGFvNaOGS+8jD6b+eTP+1owzm83RoWgqhRV2D/hhv2qMXEQzIljoc/wg2y+X4g== - dependencies: - "@parcel/diagnostic" "2.3.2" - "@parcel/plugin" "2.3.2" - "@parcel/source-map" "^2.0.0" - "@parcel/utils" "2.3.2" - browserslist "^4.6.6" - json5 "^2.2.0" - nullthrows "^1.1.1" - semver "^5.7.0" - -"@parcel/transformer-css@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/transformer-css/-/transformer-css-2.3.2.tgz#968826e42d7cac9963dc0a67a30d393ef996e48c" - integrity sha512-8lzvDny+78DIAqhcXam2Bf9FyaUoqzHdUQdNFn+PuXTHroG/QGPvln1kvqngJjn4/cpJS9vYmAPVXe+nai3P8g== - dependencies: - "@parcel/hash" "2.3.2" - "@parcel/plugin" "2.3.2" - "@parcel/source-map" "^2.0.0" - "@parcel/utils" "2.3.2" - nullthrows "^1.1.1" - postcss "^8.4.5" - postcss-value-parser "^4.2.0" - semver "^5.7.1" - -"@parcel/transformer-html@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/transformer-html/-/transformer-html-2.3.2.tgz#c240f09369445d287d16beba207407c925532d90" - integrity sha512-idT1I/8WM65IFYBqzRwpwT7sf0xGur4EDQDHhuPX1w+pIVZnh0lkLMAnEqs6ar1SPRMys4chzkuDNnqh0d76hg== - dependencies: - "@parcel/diagnostic" "2.3.2" - "@parcel/hash" "2.3.2" - "@parcel/plugin" "2.3.2" - nullthrows "^1.1.1" - posthtml "^0.16.5" - posthtml-parser "^0.10.1" - posthtml-render "^3.0.0" - semver "^5.7.1" - -"@parcel/transformer-image@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/transformer-image/-/transformer-image-2.3.2.tgz#24b6eda51a6b07c195886bbb67fb2ade14c325f3" - integrity sha512-0K7cJHXysli6hZsUz/zVGO7WCoaaIeVdzAxKpLA1Yl3LKw/ODiMyXKt08LiV/ljQ2xT5qb9EsXUWDRvcZ0b96A== - dependencies: - "@parcel/plugin" "2.3.2" - "@parcel/workers" "2.3.2" - nullthrows "^1.1.1" - -"@parcel/transformer-js@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/transformer-js/-/transformer-js-2.3.2.tgz#24bcb488d5f82678343a5630fe4bbe822789ac33" - integrity sha512-U1fbIoAoqR5P49S+DMhH8BUd9IHRPwrTTv6ARYGsYnhuNsjTFhNYE0kkfRYboe/e0z7vEbeJICZXjnZ7eQDw5A== - dependencies: - "@parcel/diagnostic" "2.3.2" - "@parcel/plugin" "2.3.2" - "@parcel/source-map" "^2.0.0" - "@parcel/utils" "2.3.2" - "@parcel/workers" "2.3.2" - "@swc/helpers" "^0.2.11" - browserslist "^4.6.6" - detect-libc "^1.0.3" - nullthrows "^1.1.1" - regenerator-runtime "^0.13.7" - semver "^5.7.1" - -"@parcel/transformer-json@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/transformer-json/-/transformer-json-2.3.2.tgz#4c470e86659e87ee13b1f31e75a3621d3615b6bd" - integrity sha512-Pv2iPaxKINtFwOk5fDbHjQlSm2Vza/NLimQY896FLxiXPNAJxWGvMwdutgOPEBKksxRx9LZPyIOHiRVZ0KcA3w== - dependencies: - "@parcel/plugin" "2.3.2" - json5 "^2.2.0" - -"@parcel/transformer-postcss@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/transformer-postcss/-/transformer-postcss-2.3.2.tgz#a428c81569dd66758c5fab866dca69b4c6e59743" - integrity sha512-Rpdxc1rt2aJFCh/y/ccaBc9J1crDjNY5o44xYoOemBoUNDMREsmg5sR5iO81qKKO5GxfoosGb2zh59aeTmywcg== - dependencies: - "@parcel/hash" "2.3.2" - "@parcel/plugin" "2.3.2" - "@parcel/utils" "2.3.2" - clone "^2.1.1" - nullthrows "^1.1.1" - postcss-value-parser "^4.2.0" - semver "^5.7.1" - -"@parcel/transformer-posthtml@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/transformer-posthtml/-/transformer-posthtml-2.3.2.tgz#5da3f24bf240c3c49b2fdb17dcda5988d3057a30" - integrity sha512-tMdVExfdM+1G8A9KSHDsjg+S9xEGbhH5mApF2NslPnNZ4ciLKRNuHU2sSV/v8i0a6kacKvDTrwQXYBQJGOodBw== - dependencies: - "@parcel/plugin" "2.3.2" - "@parcel/utils" "2.3.2" - nullthrows "^1.1.1" - posthtml "^0.16.5" - posthtml-parser "^0.10.1" - posthtml-render "^3.0.0" - semver "^5.7.1" - -"@parcel/transformer-raw@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/transformer-raw/-/transformer-raw-2.3.2.tgz#40d21773e295bae3b16bfe7a89e414ccf534b9c5" - integrity sha512-lY7eOCaALZ90+GH+4PZRmAPGQRXoZ66NakSdhEtH6JSSAYOmZKDvNLGTMRo/vK1oELzWMuAHGdqvbcPDtNLLVw== - dependencies: - "@parcel/plugin" "2.3.2" - -"@parcel/transformer-react-refresh-wrap@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/transformer-react-refresh-wrap/-/transformer-react-refresh-wrap-2.3.2.tgz#43ecfe6f4567b88abb81db9fe56b8d860d6a69f7" - integrity sha512-FZaderyCExn0SBZ6D+zHPWc8JSn9YDcbfibv0wkCl+D7sYfeWZ22i7MRp5NwCe/TZ21WuxDWySCggEp/Waz2xg== - dependencies: - "@parcel/plugin" "2.3.2" - "@parcel/utils" "2.3.2" - react-refresh "^0.9.0" - -"@parcel/transformer-svg@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/transformer-svg/-/transformer-svg-2.3.2.tgz#9a66aef5011c7bbb1fa3ce9bb52ca56d8f0f964d" - integrity sha512-k9My6bePsaGgUh+tidDjFbbVgKPTzwCAQfoloZRMt7y396KgUbvCfqDruk04k6k+cJn7Jl1o/5lUpTEruBze7g== - dependencies: - "@parcel/diagnostic" "2.3.2" - "@parcel/hash" "2.3.2" - "@parcel/plugin" "2.3.2" - nullthrows "^1.1.1" - posthtml "^0.16.5" - posthtml-parser "^0.10.1" - posthtml-render "^3.0.0" - semver "^5.7.1" - -"@parcel/types@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/types/-/types-2.3.2.tgz#7eb6925bc852a518dd75b742419e51292418769f" - integrity sha512-C77Ct1xNM7LWjPTfe/dQ/9rq1efdsX5VJu2o8/TVi6qoFh64Wp/c5/vCHwKInOTBZUTchVO6z4PGJNIZoUVJuA== - dependencies: - "@parcel/cache" "2.3.2" - "@parcel/diagnostic" "2.3.2" - "@parcel/fs" "2.3.2" - "@parcel/package-manager" "2.3.2" - "@parcel/source-map" "^2.0.0" - "@parcel/workers" "2.3.2" - utility-types "^3.10.0" - -"@parcel/utils@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/utils/-/utils-2.3.2.tgz#4aab052fc9f3227811a504da7b9663ca75004f55" - integrity sha512-xzZ+0vWhrXlLzGoz7WlANaO5IPtyWGeCZruGtepUL3yheRWb1UU4zFN9xz7Z+j++Dmf1Fgkc3qdk/t4O8u9HLQ== - dependencies: - "@parcel/codeframe" "2.3.2" - "@parcel/diagnostic" "2.3.2" - "@parcel/hash" "2.3.2" - "@parcel/logger" "2.3.2" - "@parcel/markdown-ansi" "2.3.2" - "@parcel/source-map" "^2.0.0" - chalk "^4.1.0" - -"@parcel/watcher@^2.0.0": - version "2.0.5" - resolved "https://registry.yarnpkg.com/@parcel/watcher/-/watcher-2.0.5.tgz#f913a54e1601b0aac972803829b0eece48de215b" - integrity sha512-x0hUbjv891omnkcHD7ZOhiyyUqUUR6MNjq89JhEI3BxppeKWAm6NPQsqqRrAkCJBogdT/o/My21sXtTI9rJIsw== - dependencies: - node-addon-api "^3.2.1" - node-gyp-build "^4.3.0" - -"@parcel/workers@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/workers/-/workers-2.3.2.tgz#05ffa2da9169bfb83335892c2b8abce55686ceb1" - integrity sha512-JbOm+Ceuyymd1SuKGgodC2EXAiPuFRpaNUSJpz3NAsS3lVIt2TDAPMOWBivS7sML/KltspUfl/Q9YwO0TPUFNw== - dependencies: - "@parcel/diagnostic" "2.3.2" - "@parcel/logger" "2.3.2" - "@parcel/types" "2.3.2" - "@parcel/utils" "2.3.2" - chrome-trace-event "^1.0.2" - nullthrows "^1.1.1" - -"@swc/helpers@^0.2.11": - version "0.2.14" - resolved "https://registry.yarnpkg.com/@swc/helpers/-/helpers-0.2.14.tgz#20288c3627442339dd3d743c944f7043ee3590f0" - integrity sha512-wpCQMhf5p5GhNg2MmGKXzUNwxe7zRiCsmqYsamez2beP7mKPCSiu+BjZcdN95yYSzO857kr0VfQewmGpS77nqA== - -"@tensorflow/tfjs-backend-cpu@3.14.0": - version "3.14.0" - resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-backend-cpu/-/tfjs-backend-cpu-3.14.0.tgz#f4db5cd17609e274709f86a0c34233d35cb886b2" - integrity sha512-Sk0B8p1QUqxEVsOmBNxxX2BUgeR8mfXVc6JZM5lWKP79bYy8YGzuiitrSrcxAhEFAANgmDVvM9FTTVR25a0CWg== - dependencies: - "@types/seedrandom" "2.4.27" - seedrandom "2.4.3" - -"@tensorflow/tfjs-backend-wasm@3.14.0": - version "3.14.0" - resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-backend-wasm/-/tfjs-backend-wasm-3.14.0.tgz#56ba7987a89029ff33ea5c677483fb57a234a4c6" - integrity sha512-7dCG5eJRyK3CpXXbisbMcFyoi//fx62EQ+bvIra4/9YaTzkCoREDw9TAyyyTG4/wCxtOlU4+lmKD9675AXf97Q== - dependencies: - "@tensorflow/tfjs-backend-cpu" "3.14.0" - "@types/emscripten" "~0.0.34" - -"@tensorflow/tfjs-core@3.14.0": - version "3.14.0" - resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-core/-/tfjs-core-3.14.0.tgz#2d73e76e2ae740c2f91c2cbf15312b9e61ec1c72" - integrity sha512-bS/iuI9BpDVZuqEPfLzIFLoHYd+ihNIiux+EXveuFO8phPx7FkgPqakatHYLzrdYlOfAXurIxIlGNAzVKNQOUQ== - dependencies: - "@types/long" "^4.0.1" - "@types/offscreencanvas" "~2019.3.0" - "@types/seedrandom" "2.4.27" - "@types/webgl-ext" "0.0.30" - long "4.0.0" - node-fetch "~2.6.1" - seedrandom "2.4.3" - -"@trysound/sax@0.2.0": - version "0.2.0" - resolved "https://registry.yarnpkg.com/@trysound/sax/-/sax-0.2.0.tgz#cccaab758af56761eb7bf37af6f03f326dd798ad" - integrity sha512-L7z9BgrNEcYyUYtF+HaEfiS5ebkh9jXqbszz7pC0hRBPaatV0XjSD3+eHrpqFemQfgwiFF0QPIarnIihIDn7OA== - -"@types/emscripten@~0.0.34": - version "0.0.34" - resolved "https://registry.yarnpkg.com/@types/emscripten/-/emscripten-0.0.34.tgz#12b4a344274fb102ff2f6c877b37587bc3e46008" - integrity sha512-QSb9ojDincskc+uKMI0KXp8e1NALFINCrMlp8VGKGcTSxeEyRTTKyjWw75NYrCZHUsVEEEpr1tYHpbtaC++/sQ== - -"@types/long@^4.0.1": - version "4.0.1" - resolved "https://registry.yarnpkg.com/@types/long/-/long-4.0.1.tgz#459c65fa1867dafe6a8f322c4c51695663cc55e9" - integrity sha512-5tXH6Bx/kNGd3MgffdmP4dy2Z+G4eaXw0SE81Tq3BNadtnMR5/ySMzX4SLEzHJzSmPNn4HIdpQsBvXMUykr58w== - -"@types/offscreencanvas@~2019.3.0": - version "2019.3.0" - resolved "https://registry.yarnpkg.com/@types/offscreencanvas/-/offscreencanvas-2019.3.0.tgz#3336428ec7e9180cf4566dfea5da04eb586a6553" - integrity sha512-esIJx9bQg+QYF0ra8GnvfianIY8qWB0GBx54PK5Eps6m+xTj86KLavHv6qDhzKcu5UUOgNfJ2pWaIIV7TRUd9Q== - -"@types/parse-json@^4.0.0": - version "4.0.0" - resolved "https://registry.yarnpkg.com/@types/parse-json/-/parse-json-4.0.0.tgz#2f8bb441434d163b35fb8ffdccd7138927ffb8c0" - integrity sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA== - -"@types/seedrandom@2.4.27": - version "2.4.27" - resolved "https://registry.yarnpkg.com/@types/seedrandom/-/seedrandom-2.4.27.tgz#9db563937dd86915f69092bc43259d2f48578e41" - integrity sha1-nbVjk33YaRX2kJK8QyWdL0hXjkE= - -"@types/webgl-ext@0.0.30": - version "0.0.30" - resolved "https://registry.yarnpkg.com/@types/webgl-ext/-/webgl-ext-0.0.30.tgz#0ce498c16a41a23d15289e0b844d945b25f0fb9d" - integrity sha512-LKVgNmBxN0BbljJrVUwkxwRYqzsAEPcZOe6S2T6ZaBDIrFp0qu4FNlpc5sM1tGbXUYFgdVQIoeLk1Y1UoblyEg== - -abortcontroller-polyfill@^1.1.9: - version "1.7.3" - resolved "https://registry.yarnpkg.com/abortcontroller-polyfill/-/abortcontroller-polyfill-1.7.3.tgz#1b5b487bd6436b5b764fd52a612509702c3144b5" - integrity sha512-zetDJxd89y3X99Kvo4qFx8GKlt6GsvN3UcRZHwU6iFA/0KiOmhkTVhe8oRoTBiTVPZu09x3vCra47+w8Yz1+2Q== - -acorn@^8.5.0: - version "8.7.1" - resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.7.1.tgz#0197122c843d1bf6d0a5e83220a788f278f63c30" - integrity sha512-Xx54uLJQZ19lKygFXOWsscKUbsBZW0CPykPhVQdhIeIwrbPmJzqeASDInc8nKBnp/JT6igTs82qPXz069H8I/A== - -ansi-styles@^3.2.1: - version "3.2.1" - resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d" - integrity sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA== - dependencies: - color-convert "^1.9.0" - -ansi-styles@^4.1.0: - version "4.3.0" - resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-4.3.0.tgz#edd803628ae71c04c85ae7a0906edad34b648937" - integrity sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg== - dependencies: - color-convert "^2.0.1" - -base-x@^3.0.8: - version "3.0.9" - resolved "https://registry.yarnpkg.com/base-x/-/base-x-3.0.9.tgz#6349aaabb58526332de9f60995e548a53fe21320" - integrity sha512-H7JU6iBHTal1gp56aKoaa//YUxEaAOUiydvrV/pILqIHXTtqxSkATOnDA2u+jZ/61sD+L/412+7kzXRtWukhpQ== - dependencies: - safe-buffer "^5.0.1" - -boolbase@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/boolbase/-/boolbase-1.0.0.tgz#68dff5fbe60c51eb37725ea9e3ed310dcc1e776e" - integrity sha1-aN/1++YMUes3cl6p4+0xDcwed24= - -browserslist@^4.0.0, browserslist@^4.16.6, browserslist@^4.6.6: - version "4.20.0" - resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.20.0.tgz#35951e3541078c125d36df76056e94738a52ebe9" - integrity sha512-bnpOoa+DownbciXj0jVGENf8VYQnE2LNWomhYuCsMmmx9Jd9lwq0WXODuwpSsp8AVdKM2/HorrzxAfbKvWTByQ== - dependencies: - caniuse-lite "^1.0.30001313" - electron-to-chromium "^1.4.76" - escalade "^3.1.1" - node-releases "^2.0.2" - picocolors "^1.0.0" - -buffer-from@^1.0.0: - version "1.1.2" - resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.2.tgz#2b146a6fd72e80b4f55d255f35ed59a3a9a41bd5" - integrity sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ== - -callsites@^3.0.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/callsites/-/callsites-3.1.0.tgz#b3630abd8943432f54b3f0519238e33cd7df2f73" - integrity sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ== - -caniuse-api@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/caniuse-api/-/caniuse-api-3.0.0.tgz#5e4d90e2274961d46291997df599e3ed008ee4c0" - integrity sha512-bsTwuIg/BZZK/vreVTYYbSWoe2F+71P7K5QGEX+pT250DZbfU1MQ5prOKpPR+LL6uWKK3KMwMCAS74QB3Um1uw== - dependencies: - browserslist "^4.0.0" - caniuse-lite "^1.0.0" - lodash.memoize "^4.1.2" - lodash.uniq "^4.5.0" - -caniuse-lite@^1.0.0, caniuse-lite@^1.0.30001313: - version "1.0.30001317" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001317.tgz#0548fb28fd5bc259a70b8c1ffdbe598037666a1b" - integrity sha512-xIZLh8gBm4dqNX0gkzrBeyI86J2eCjWzYAs40q88smG844YIrN4tVQl/RhquHvKEKImWWFIVh1Lxe5n1G/N+GQ== - -chalk@^2.0.0: - version "2.4.2" - resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" - integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ== - dependencies: - ansi-styles "^3.2.1" - escape-string-regexp "^1.0.5" - supports-color "^5.3.0" - -chalk@^4.1.0: - version "4.1.2" - resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01" - integrity sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA== - dependencies: - ansi-styles "^4.1.0" - supports-color "^7.1.0" - -chrome-trace-event@^1.0.2: - version "1.0.3" - resolved "https://registry.yarnpkg.com/chrome-trace-event/-/chrome-trace-event-1.0.3.tgz#1015eced4741e15d06664a957dbbf50d041e26ac" - integrity sha512-p3KULyQg4S7NIHixdwbGX+nFHkoBiA4YQmyWtjb8XngSKV124nJmRysgAeujbUVb15vh+RvFUfCPqU7rXk+hZg== - -clone@^2.1.1: - version "2.1.2" - resolved "https://registry.yarnpkg.com/clone/-/clone-2.1.2.tgz#1b7f4b9f591f1e8f83670401600345a02887435f" - integrity sha1-G39Ln1kfHo+DZwQBYANFoCiHQ18= - -color-convert@^1.9.0: - version "1.9.3" - resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8" - integrity sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg== - dependencies: - color-name "1.1.3" - -color-convert@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-2.0.1.tgz#72d3a68d598c9bdb3af2ad1e84f21d896abd4de3" - integrity sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ== - dependencies: - color-name "~1.1.4" - -color-name@1.1.3: - version "1.1.3" - resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25" - integrity sha1-p9BVi9icQveV3UIyj3QIMcpTvCU= - -color-name@~1.1.4: - version "1.1.4" - resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2" - integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA== - -colord@^2.9.1: - version "2.9.2" - resolved "https://registry.yarnpkg.com/colord/-/colord-2.9.2.tgz#25e2bacbbaa65991422c07ea209e2089428effb1" - integrity sha512-Uqbg+J445nc1TKn4FoDPS6ZZqAvEDnwrH42yo8B40JSOgSLxMZ/gt3h4nmCtPLQeXhjJJkqBx7SCY35WnIixaQ== - -commander@^2.20.0: - version "2.20.3" - resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33" - integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ== - -commander@^7.0.0, commander@^7.2.0: - version "7.2.0" - resolved "https://registry.yarnpkg.com/commander/-/commander-7.2.0.tgz#a36cb57d0b501ce108e4d20559a150a391d97ab7" - integrity sha512-QrWXB+ZQSVPmIWIhtEO9H+gwHaMGYiF5ChvoJ+K9ZGHG/sVsa6yiesAD1GC/x46sET00Xlwo1u49RVVVzvcSkw== - -cosmiconfig@^7.0.1: - version "7.0.1" - resolved "https://registry.yarnpkg.com/cosmiconfig/-/cosmiconfig-7.0.1.tgz#714d756522cace867867ccb4474c5d01bbae5d6d" - integrity sha512-a1YWNUV2HwGimB7dU2s1wUMurNKjpx60HxBB6xUM8Re+2s1g1IIfJvFR0/iCF+XHdE0GMTKTuLR32UQff4TEyQ== - dependencies: - "@types/parse-json" "^4.0.0" - import-fresh "^3.2.1" - parse-json "^5.0.0" - path-type "^4.0.0" - yaml "^1.10.0" - -css-declaration-sorter@^6.0.3: - version "6.1.4" - resolved "https://registry.yarnpkg.com/css-declaration-sorter/-/css-declaration-sorter-6.1.4.tgz#b9bfb4ed9a41f8dcca9bf7184d849ea94a8294b4" - integrity sha512-lpfkqS0fctcmZotJGhnxkIyJWvBXgpyi2wsFd4J8VB7wzyrT6Ch/3Q+FMNJpjK4gu1+GN5khOnpU2ZVKrLbhCw== - dependencies: - timsort "^0.3.0" - -css-select@^4.1.3: - version "4.2.1" - resolved "https://registry.yarnpkg.com/css-select/-/css-select-4.2.1.tgz#9e665d6ae4c7f9d65dbe69d0316e3221fb274cdd" - integrity sha512-/aUslKhzkTNCQUB2qTX84lVmfia9NyjP3WpDGtj/WxhwBzWBYUV3DgUpurHTme8UTPcPlAD1DJ+b0nN/t50zDQ== - dependencies: - boolbase "^1.0.0" - css-what "^5.1.0" - domhandler "^4.3.0" - domutils "^2.8.0" - nth-check "^2.0.1" - -css-tree@^1.1.2, css-tree@^1.1.3: - version "1.1.3" - resolved "https://registry.yarnpkg.com/css-tree/-/css-tree-1.1.3.tgz#eb4870fb6fd7707327ec95c2ff2ab09b5e8db91d" - integrity sha512-tRpdppF7TRazZrjJ6v3stzv93qxRcSsFmW6cX0Zm2NVKpxE1WV1HblnghVv9TreireHkqI/VDEsfolRF1p6y7Q== - dependencies: - mdn-data "2.0.14" - source-map "^0.6.1" - -css-what@^5.1.0: - version "5.1.0" - resolved "https://registry.yarnpkg.com/css-what/-/css-what-5.1.0.tgz#3f7b707aadf633baf62c2ceb8579b545bb40f7fe" - integrity sha512-arSMRWIIFY0hV8pIxZMEfmMI47Wj3R/aWpZDDxWYCPEiOMv6tfOrnpDtgxBYPEQD4V0Y/958+1TdC3iWTFcUPw== - -cssesc@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/cssesc/-/cssesc-3.0.0.tgz#37741919903b868565e1c09ea747445cd18983ee" - integrity sha512-/Tb/JcjK111nNScGob5MNtsntNM1aCNUDipB/TkwZFhyDrrE47SOx/18wF2bbjgc3ZzCSKW1T5nt5EbFoAz/Vg== - -cssnano-preset-default@^*: - version "5.2.4" - resolved "https://registry.yarnpkg.com/cssnano-preset-default/-/cssnano-preset-default-5.2.4.tgz#eced79bbc1ab7270337c4038a21891daac2329bc" - integrity sha512-w1Gg8xsebln6/axZ6qDFQHuglrGfbIHOIx0g4y9+etRlRab8CGpSpe6UMsrgJe4zhCaJ0LwLmc+PhdLRTwnhIA== - dependencies: - css-declaration-sorter "^6.0.3" - cssnano-utils "^*" - postcss-calc "^8.2.3" - postcss-colormin "^*" - postcss-convert-values "^*" - postcss-discard-comments "^*" - postcss-discard-duplicates "^*" - postcss-discard-empty "^*" - postcss-discard-overridden "^*" - postcss-merge-longhand "^*" - postcss-merge-rules "^*" - postcss-minify-font-values "^*" - postcss-minify-gradients "^*" - postcss-minify-params "^*" - postcss-minify-selectors "^*" - postcss-normalize-charset "^*" - postcss-normalize-display-values "^*" - postcss-normalize-positions "^*" - postcss-normalize-repeat-style "^*" - postcss-normalize-string "^*" - postcss-normalize-timing-functions "^*" - postcss-normalize-unicode "^*" - postcss-normalize-url "^*" - postcss-normalize-whitespace "^*" - postcss-ordered-values "^*" - postcss-reduce-initial "^*" - postcss-reduce-transforms "^*" - postcss-svgo "^*" - postcss-unique-selectors "^*" - -cssnano-utils@^*, cssnano-utils@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/cssnano-utils/-/cssnano-utils-3.1.0.tgz#95684d08c91511edfc70d2636338ca37ef3a6861" - integrity sha512-JQNR19/YZhz4psLX/rQ9M83e3z2Wf/HdJbryzte4a3NSuafyp9w/I4U+hx5C2S9g41qlstH7DEWnZaaj83OuEA== - -cssnano@^5.0.15: - version "5.1.4" - resolved "https://registry.yarnpkg.com/cssnano/-/cssnano-5.1.4.tgz#c648192e8e2f1aacb7d839e6aa3706b50cc7f8e4" - integrity sha512-hbfhVZreEPyzl+NbvRsjNo54JOX80b+j6nqG2biLVLaZHJEiqGyMh4xDGHtwhUKd5p59mj2GlDqlUBwJUuIu5A== - dependencies: - cssnano-preset-default "^*" - lilconfig "^2.0.3" - yaml "^1.10.2" - -csso@^4.2.0: - version "4.2.0" - resolved "https://registry.yarnpkg.com/csso/-/csso-4.2.0.tgz#ea3a561346e8dc9f546d6febedd50187cf389529" - integrity sha512-wvlcdIbf6pwKEk7vHj8/Bkc0B4ylXZruLvOgs9doS5eOsOpuodOV2zJChSpkp+pRpYQLQMeF04nr3Z68Sta9jA== - dependencies: - css-tree "^1.1.2" - -detect-libc@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/detect-libc/-/detect-libc-1.0.3.tgz#fa137c4bd698edf55cd5cd02ac559f91a4c4ba9b" - integrity sha1-+hN8S9aY7fVc1c0CrFWfkaTEups= - -dom-serializer@^1.0.1: - version "1.3.2" - resolved "https://registry.yarnpkg.com/dom-serializer/-/dom-serializer-1.3.2.tgz#6206437d32ceefaec7161803230c7a20bc1b4d91" - integrity sha512-5c54Bk5Dw4qAxNOI1pFEizPSjVsx5+bpJKmL2kPn8JhBUq2q09tTCa3mjijun2NfK78NMouDYNMBkOrPZiS+ig== - dependencies: - domelementtype "^2.0.1" - domhandler "^4.2.0" - entities "^2.0.0" - -domelementtype@^2.0.1, domelementtype@^2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/domelementtype/-/domelementtype-2.2.0.tgz#9a0b6c2782ed6a1c7323d42267183df9bd8b1d57" - integrity sha512-DtBMo82pv1dFtUmHyr48beiuq792Sxohr+8Hm9zoxklYPfa6n0Z3Byjj2IV7bmr2IyqClnqEQhfgHJJ5QF0R5A== - -domhandler@^4.2.0, domhandler@^4.2.2, domhandler@^4.3.0: - version "4.3.0" - resolved "https://registry.yarnpkg.com/domhandler/-/domhandler-4.3.0.tgz#16c658c626cf966967e306f966b431f77d4a5626" - integrity sha512-fC0aXNQXqKSFTr2wDNZDhsEYjCiYsDWl3D01kwt25hm1YIPyDGHvvi3rw+PLqHAl/m71MaiF7d5zvBr0p5UB2g== - dependencies: - domelementtype "^2.2.0" - -domutils@^2.8.0: - version "2.8.0" - resolved "https://registry.yarnpkg.com/domutils/-/domutils-2.8.0.tgz#4437def5db6e2d1f5d6ee859bd95ca7d02048135" - integrity sha512-w96Cjofp72M5IIhpjgobBimYEfoPjx1Vx0BSX9P30WBdZW2WIKU0T1Bd0kz2eNZ9ikjKgHbEyKx8BB6H1L3h3A== - dependencies: - dom-serializer "^1.0.1" - domelementtype "^2.2.0" - domhandler "^4.2.0" - -dotenv-expand@^5.1.0: - version "5.1.0" - resolved "https://registry.yarnpkg.com/dotenv-expand/-/dotenv-expand-5.1.0.tgz#3fbaf020bfd794884072ea26b1e9791d45a629f0" - integrity sha512-YXQl1DSa4/PQyRfgrv6aoNjhasp/p4qs9FjJ4q4cQk+8m4r6k4ZSiEyytKG8f8W9gi8WsQtIObNmKd+tMzNTmA== - -dotenv@^7.0.0: - version "7.0.0" - resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-7.0.0.tgz#a2be3cd52736673206e8a85fb5210eea29628e7c" - integrity sha512-M3NhsLbV1i6HuGzBUH8vXrtxOk+tWmzWKDMbAVSUp3Zsjm7ywFeuwrUXhmhQyRK1q5B5GGy7hcXPbj3bnfZg2g== - -electron-to-chromium@^1.4.76: - version "1.4.84" - resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.84.tgz#2700befbcb49c42c4ee162e137ff392c07658249" - integrity sha512-b+DdcyOiZtLXHdgEG8lncYJdxbdJWJvclPNMg0eLUDcSOSO876WA/pYjdSblUTd7eJdIs4YdIxHWGazx7UPSJw== - -entities@^2.0.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/entities/-/entities-2.2.0.tgz#098dc90ebb83d8dffa089d55256b351d34c4da55" - integrity sha512-p92if5Nz619I0w+akJrLZH0MX0Pb5DX39XOwQTtXSdQQOaYH03S1uIQp4mhOZtAXrxq4ViO67YTiLBo2638o9A== - -entities@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/entities/-/entities-3.0.1.tgz#2b887ca62585e96db3903482d336c1006c3001d4" - integrity sha512-WiyBqoomrwMdFG1e0kqvASYfnlb0lp8M5o5Fw2OFq1hNZxxcNk8Ik0Xm7LxzBhuidnZB/UtBqVCgUz3kBOP51Q== - -error-ex@^1.3.1: - version "1.3.2" - resolved "https://registry.yarnpkg.com/error-ex/-/error-ex-1.3.2.tgz#b4ac40648107fdcdcfae242f428bea8a14d4f1bf" - integrity sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g== - dependencies: - is-arrayish "^0.2.1" - -escalade@^3.1.1: - version "3.1.1" - resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.1.1.tgz#d8cfdc7000965c5a0174b4a82eaa5c0552742e40" - integrity sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw== - -escape-string-regexp@^1.0.5: - version "1.0.5" - resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" - integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ= - -get-port@^4.2.0: - version "4.2.0" - resolved "https://registry.yarnpkg.com/get-port/-/get-port-4.2.0.tgz#e37368b1e863b7629c43c5a323625f95cf24b119" - integrity sha512-/b3jarXkH8KJoOMQc3uVGHASwGLPq3gSFJ7tgJm2diza+bydJPTGOibin2steecKeOylE8oY2JERlVWkAJO6yw== - -globals@^13.2.0: - version "13.12.1" - resolved "https://registry.yarnpkg.com/globals/-/globals-13.12.1.tgz#ec206be932e6c77236677127577aa8e50bf1c5cb" - integrity sha512-317dFlgY2pdJZ9rspXDks7073GpDmXdfbM3vYYp0HAMKGDh1FfWPleI2ljVNLQX5M5lXcAslTcPTrOrMEFOjyw== - dependencies: - type-fest "^0.20.2" - -has-flag@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd" - integrity sha1-tdRU3CGZriJWmfNGfloH87lVuv0= - -has-flag@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b" - integrity sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ== - -htmlnano@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/htmlnano/-/htmlnano-2.0.0.tgz#07376faa064f7e1e832dfd91e1a9f606b0bc9b78" - integrity sha512-thKQfhcp2xgtsWNE27A2bliEeqVL5xjAgGn0wajyttvFFsvFWWah1ntV9aEX61gz0T6MBQ5xK/1lXuEumhJTcg== - dependencies: - cosmiconfig "^7.0.1" - posthtml "^0.16.5" - timsort "^0.3.0" - -htmlparser2@^7.1.1: - version "7.2.0" - resolved "https://registry.yarnpkg.com/htmlparser2/-/htmlparser2-7.2.0.tgz#8817cdea38bbc324392a90b1990908e81a65f5a5" - integrity sha512-H7MImA4MS6cw7nbyURtLPO1Tms7C5H602LRETv95z1MxO/7CP7rDVROehUYeYBUYEON94NXXDEPmZuq+hX4sog== - dependencies: - domelementtype "^2.0.1" - domhandler "^4.2.2" - domutils "^2.8.0" - entities "^3.0.1" - -import-fresh@^3.2.1: - version "3.3.0" - resolved "https://registry.yarnpkg.com/import-fresh/-/import-fresh-3.3.0.tgz#37162c25fcb9ebaa2e6e53d5b4d88ce17d9e0c2b" - integrity sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw== - dependencies: - parent-module "^1.0.0" - resolve-from "^4.0.0" - -is-arrayish@^0.2.1: - version "0.2.1" - resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.2.1.tgz#77c99840527aa8ecb1a8ba697b80645a7a926a9d" - integrity sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0= - -is-json@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/is-json/-/is-json-2.0.1.tgz#6be166d144828a131d686891b983df62c39491ff" - integrity sha1-a+Fm0USCihMdaGiRuYPfYsOUkf8= - -js-tokens@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" - integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ== - -json-parse-even-better-errors@^2.3.0: - version "2.3.1" - resolved "https://registry.yarnpkg.com/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz#7c47805a94319928e05777405dc12e1f7a4ee02d" - integrity sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w== - -json-source-map@^0.6.1: - version "0.6.1" - resolved "https://registry.yarnpkg.com/json-source-map/-/json-source-map-0.6.1.tgz#e0b1f6f4ce13a9ad57e2ae165a24d06e62c79a0f" - integrity sha512-1QoztHPsMQqhDq0hlXY5ZqcEdUzxQEIxgFkKl4WUp2pgShObl+9ovi4kRh2TfvAfxAoHOJ9vIMEqk3k4iex7tg== - -json5@^2.2.0: - version "2.2.3" - resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.3.tgz#78cd6f1a19bdc12b73db5ad0c61efd66c1e29283" - integrity sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg== - -lilconfig@^2.0.3: - version "2.0.4" - resolved "https://registry.yarnpkg.com/lilconfig/-/lilconfig-2.0.4.tgz#f4507d043d7058b380b6a8f5cb7bcd4b34cee082" - integrity sha512-bfTIN7lEsiooCocSISTWXkiWJkRqtL9wYtYy+8EK3Y41qh3mpwPU0ycTOgjdY9ErwXCc8QyrQp82bdL0Xkm9yA== - -lines-and-columns@^1.1.6: - version "1.2.4" - resolved "https://registry.yarnpkg.com/lines-and-columns/-/lines-and-columns-1.2.4.tgz#eca284f75d2965079309dc0ad9255abb2ebc1632" - integrity sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg== - -lmdb@^2.0.2: - version "2.2.5" - resolved "https://registry.yarnpkg.com/lmdb/-/lmdb-2.2.5.tgz#37f08b5963a1b81da67f378c7084f59b84c3d443" - integrity sha512-yx+jtqSgp9uzp+2b3U3VTvS/g5hw4jXqvTAX+QU4Izdueq5O6MUTLwp/94R4F7SYq96zOfaGN/IUgiz6AWo+yg== - dependencies: - msgpackr "^1.5.4" - nan "^2.14.2" - node-gyp-build "^4.2.3" - ordered-binary "^1.2.4" - weak-lru-cache "^1.2.2" - -lodash.memoize@^4.1.2: - version "4.1.2" - resolved "https://registry.yarnpkg.com/lodash.memoize/-/lodash.memoize-4.1.2.tgz#bcc6c49a42a2840ed997f323eada5ecd182e0bfe" - integrity sha1-vMbEmkKihA7Zl/Mj6tpezRguC/4= - -lodash.uniq@^4.5.0: - version "4.5.0" - resolved "https://registry.yarnpkg.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773" - integrity sha1-0CJTc662Uq3BvILklFM5qEJ1R3M= - -long@4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/long/-/long-4.0.0.tgz#9a7b71cfb7d361a194ea555241c92f7468d5bf28" - integrity sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA== - -mdn-data@2.0.14: - version "2.0.14" - resolved "https://registry.yarnpkg.com/mdn-data/-/mdn-data-2.0.14.tgz#7113fc4281917d63ce29b43446f701e68c25ba50" - integrity sha512-dn6wd0uw5GsdswPFfsgMp5NSB0/aDe6fK94YJV/AJDYXL6HVLWBsxeq7js7Ad+mU2K9LAlwpk6kN2D5mwCPVow== - -minimist@1.2.6: - version "1.2.6" - resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.6.tgz#8637a5b759ea0d6e98702cfb3a9283323c93af44" - integrity sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q== - -msgpackr-extract@^1.0.14: - version "1.0.16" - resolved "https://registry.yarnpkg.com/msgpackr-extract/-/msgpackr-extract-1.0.16.tgz#701c4f6e6f25c100ae84557092274e8fffeefe45" - integrity sha512-fxdRfQUxPrL/TizyfYfMn09dK58e+d65bRD/fcaVH4052vj30QOzzqxcQIS7B0NsqlypEQ/6Du3QmP2DhWFfCA== - dependencies: - nan "^2.14.2" - node-gyp-build "^4.2.3" - -msgpackr@^1.5.1, msgpackr@^1.5.4: - version "1.5.5" - resolved "https://registry.yarnpkg.com/msgpackr/-/msgpackr-1.5.5.tgz#c0562abc2951d7e29f75d77a8656b01f103a042c" - integrity sha512-JG0V47xRIQ9pyUnx6Hb4+3TrQoia2nA3UIdmyTldhxaxtKFkekkKpUW/N6fwHwod9o4BGuJGtouxOk+yCP5PEA== - optionalDependencies: - msgpackr-extract "^1.0.14" - -nan@^2.14.2: - version "2.15.0" - resolved "https://registry.yarnpkg.com/nan/-/nan-2.15.0.tgz#3f34a473ff18e15c1b5626b62903b5ad6e665fee" - integrity sha512-8ZtvEnA2c5aYCZYd1cvgdnU6cqwixRoYg70xPLWUws5ORTa/lnw+u4amixRS/Ac5U5mQVgp9pnlSUnbNWFaWZQ== - -nanoid@^3.3.1: - version "3.3.1" - resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.1.tgz#6347a18cac88af88f58af0b3594b723d5e99bb35" - integrity sha512-n6Vs/3KGyxPQd6uO0eH4Bv0ojGSUvuLlIHtC3Y0kEO23YRge8H9x1GCzLn28YX0H66pMkxuaeESFq4tKISKwdw== - -node-addon-api@^3.2.1: - version "3.2.1" - resolved "https://registry.yarnpkg.com/node-addon-api/-/node-addon-api-3.2.1.tgz#81325e0a2117789c0128dab65e7e38f07ceba161" - integrity sha512-mmcei9JghVNDYydghQmeDX8KoAm0FAiYyIcUt/N4nhyAipB17pllZQDOJD2fotxABnt4Mdz+dKTO7eftLg4d0A== - -node-fetch@~2.6.1: - version "2.6.7" - resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.7.tgz#24de9fba827e3b4ae44dc8b20256a379160052ad" - integrity sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ== - dependencies: - whatwg-url "^5.0.0" - -node-gyp-build@^4.2.3, node-gyp-build@^4.3.0: - version "4.3.0" - resolved "https://registry.yarnpkg.com/node-gyp-build/-/node-gyp-build-4.3.0.tgz#9f256b03e5826150be39c764bf51e993946d71a3" - integrity sha512-iWjXZvmboq0ja1pUGULQBexmxq8CV4xBhX7VDOTbL7ZR4FOowwY/VOtRxBN/yKxmdGoIp4j5ysNT4u3S2pDQ3Q== - -node-releases@^2.0.2: - version "2.0.2" - resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-2.0.2.tgz#7139fe71e2f4f11b47d4d2986aaf8c48699e0c01" - integrity sha512-XxYDdcQ6eKqp/YjI+tb2C5WM2LgjnZrfYg4vgQt49EK268b6gYCHsBLrK2qvJo4FmCtqmKezb0WZFK4fkrZNsg== - -normalize-url@^6.0.1: - version "6.1.0" - resolved "https://registry.yarnpkg.com/normalize-url/-/normalize-url-6.1.0.tgz#40d0885b535deffe3f3147bec877d05fe4c5668a" - integrity sha512-DlL+XwOy3NxAQ8xuC0okPgK46iuVNAK01YN7RueYBqqFeGsBjV9XmCAzAdgt+667bCl5kPh9EqKKDwnaPG1I7A== - -nth-check@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/nth-check/-/nth-check-2.0.1.tgz#2efe162f5c3da06a28959fbd3db75dbeea9f0fc2" - integrity sha512-it1vE95zF6dTT9lBsYbxvqh0Soy4SPowchj0UBGj/V6cTPnXXtQOPUbhZ6CmGzAD/rW22LQK6E96pcdJXk4A4w== - dependencies: - boolbase "^1.0.0" - -nullthrows@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/nullthrows/-/nullthrows-1.1.1.tgz#7818258843856ae971eae4208ad7d7eb19a431b1" - integrity sha512-2vPPEi+Z7WqML2jZYddDIfy5Dqb0r2fze2zTxNNknZaFpVHU3mFB3R+DWeJWGVx0ecvttSGlJTI+WG+8Z4cDWw== - -ordered-binary@^1.2.4: - version "1.2.4" - resolved "https://registry.yarnpkg.com/ordered-binary/-/ordered-binary-1.2.4.tgz#51d3a03af078a0bdba6c7bc8f4fedd1f5d45d83e" - integrity sha512-A/csN0d3n+igxBPfUrjbV5GC69LWj2pjZzAAeeHXLukQ4+fytfP4T1Lg0ju7MSPSwq7KtHkGaiwO8URZN5IpLg== - -parcel-reporter-static-files-copy@^1.3.4: - version "1.3.4" - resolved "https://registry.yarnpkg.com/parcel-reporter-static-files-copy/-/parcel-reporter-static-files-copy-1.3.4.tgz#73694a4eb0da96c91c9cdcf9b3658f959b6c5d74" - integrity sha512-JRTzz8P7jyaHdj1piBY+YzkWrNFmi+LKYdImxAdoOimdYCpeM1Tuk4vVEhVxeh2lN83MBxc72evWm0lPaZGWZA== - dependencies: - "@parcel/plugin" "^2.0.0-beta.1" - -parcel@^2.3.2: - version "2.3.2" - resolved "https://registry.yarnpkg.com/parcel/-/parcel-2.3.2.tgz#d1cb475f27edae981edea7a7104e04d3a35a87ca" - integrity sha512-4jhgoBcQaiGKmnmBvNyKyOvZrxCgzgUzdEoVup/fRCOP99hNmvYIN5IErIIJxsU9ObcG/RGCFF8wa4kVRsWfIg== - dependencies: - "@parcel/config-default" "2.3.2" - "@parcel/core" "2.3.2" - "@parcel/diagnostic" "2.3.2" - "@parcel/events" "2.3.2" - "@parcel/fs" "2.3.2" - "@parcel/logger" "2.3.2" - "@parcel/package-manager" "2.3.2" - "@parcel/reporter-cli" "2.3.2" - "@parcel/reporter-dev-server" "2.3.2" - "@parcel/utils" "2.3.2" - chalk "^4.1.0" - commander "^7.0.0" - get-port "^4.2.0" - v8-compile-cache "^2.0.0" - -parent-module@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/parent-module/-/parent-module-1.0.1.tgz#691d2709e78c79fae3a156622452d00762caaaa2" - integrity sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g== - dependencies: - callsites "^3.0.0" - -parse-json@^5.0.0: - version "5.2.0" - resolved "https://registry.yarnpkg.com/parse-json/-/parse-json-5.2.0.tgz#c76fc66dee54231c962b22bcc8a72cf2f99753cd" - integrity sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg== - dependencies: - "@babel/code-frame" "^7.0.0" - error-ex "^1.3.1" - json-parse-even-better-errors "^2.3.0" - lines-and-columns "^1.1.6" - -path-type@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/path-type/-/path-type-4.0.0.tgz#84ed01c0a7ba380afe09d90a8c180dcd9d03043b" - integrity sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw== - -picocolors@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/picocolors/-/picocolors-1.0.0.tgz#cb5bdc74ff3f51892236eaf79d68bc44564ab81c" - integrity sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ== - -postcss-calc@^8.2.3: - version "8.2.4" - resolved "https://registry.yarnpkg.com/postcss-calc/-/postcss-calc-8.2.4.tgz#77b9c29bfcbe8a07ff6693dc87050828889739a5" - integrity sha512-SmWMSJmB8MRnnULldx0lQIyhSNvuDl9HfrZkaqqE/WHAhToYsAvDq+yAsA/kIyINDszOp3Rh0GFoNuH5Ypsm3Q== - dependencies: - postcss-selector-parser "^6.0.9" - postcss-value-parser "^4.2.0" - -postcss-colormin@^*: - version "5.3.0" - resolved "https://registry.yarnpkg.com/postcss-colormin/-/postcss-colormin-5.3.0.tgz#3cee9e5ca62b2c27e84fce63affc0cfb5901956a" - integrity sha512-WdDO4gOFG2Z8n4P8TWBpshnL3JpmNmJwdnfP2gbk2qBA8PWwOYcmjmI/t3CmMeL72a7Hkd+x/Mg9O2/0rD54Pg== - dependencies: - browserslist "^4.16.6" - caniuse-api "^3.0.0" - colord "^2.9.1" - postcss-value-parser "^4.2.0" - -postcss-convert-values@^*: - version "5.1.0" - resolved "https://registry.yarnpkg.com/postcss-convert-values/-/postcss-convert-values-5.1.0.tgz#f8d3abe40b4ce4b1470702a0706343eac17e7c10" - integrity sha512-GkyPbZEYJiWtQB0KZ0X6qusqFHUepguBCNFi9t5JJc7I2OTXG7C0twbTLvCfaKOLl3rSXmpAwV7W5txd91V84g== - dependencies: - postcss-value-parser "^4.2.0" - -postcss-discard-comments@^*: - version "5.1.1" - resolved "https://registry.yarnpkg.com/postcss-discard-comments/-/postcss-discard-comments-5.1.1.tgz#e90019e1a0e5b99de05f63516ce640bd0df3d369" - integrity sha512-5JscyFmvkUxz/5/+TB3QTTT9Gi9jHkcn8dcmmuN68JQcv3aQg4y88yEHHhwFB52l/NkaJ43O0dbksGMAo49nfQ== - -postcss-discard-duplicates@^*: - version "5.1.0" - resolved "https://registry.yarnpkg.com/postcss-discard-duplicates/-/postcss-discard-duplicates-5.1.0.tgz#9eb4fe8456706a4eebd6d3b7b777d07bad03e848" - integrity sha512-zmX3IoSI2aoenxHV6C7plngHWWhUOV3sP1T8y2ifzxzbtnuhk1EdPwm0S1bIUNaJ2eNbWeGLEwzw8huPD67aQw== - -postcss-discard-empty@^*: - version "5.1.1" - resolved "https://registry.yarnpkg.com/postcss-discard-empty/-/postcss-discard-empty-5.1.1.tgz#e57762343ff7f503fe53fca553d18d7f0c369c6c" - integrity sha512-zPz4WljiSuLWsI0ir4Mcnr4qQQ5e1Ukc3i7UfE2XcrwKK2LIPIqE5jxMRxO6GbI3cv//ztXDsXwEWT3BHOGh3A== - -postcss-discard-overridden@^*: - version "5.1.0" - resolved "https://registry.yarnpkg.com/postcss-discard-overridden/-/postcss-discard-overridden-5.1.0.tgz#7e8c5b53325747e9d90131bb88635282fb4a276e" - integrity sha512-21nOL7RqWR1kasIVdKs8HNqQJhFxLsyRfAnUDm4Fe4t4mCWL9OJiHvlHPjcd8zc5Myu89b/7wZDnOSjFgeWRtw== - -postcss-merge-longhand@^*: - version "5.1.2" - resolved "https://registry.yarnpkg.com/postcss-merge-longhand/-/postcss-merge-longhand-5.1.2.tgz#fe3002f38ad5827c1d6f7d5bb3f71d2566a2a138" - integrity sha512-18/bp9DZnY1ai9RlahOfLBbmIUKfKFPASxRCiZ1vlpZqWPCn8qWPFlEozqmWL+kBtcEQmG8W9YqGCstDImvp/Q== - dependencies: - postcss-value-parser "^4.2.0" - stylehacks "^*" - -postcss-merge-rules@^*: - version "5.1.0" - resolved "https://registry.yarnpkg.com/postcss-merge-rules/-/postcss-merge-rules-5.1.0.tgz#a2d5117eba09c8686a5471d97bd9afcf30d1b41f" - integrity sha512-NecukEJovQ0mG7h7xV8wbYAkXGTO3MPKnXvuiXzOKcxoOodfTTKYjeo8TMhAswlSkjcPIBlnKbSFcTuVSDaPyQ== - dependencies: - browserslist "^4.16.6" - caniuse-api "^3.0.0" - cssnano-utils "^3.1.0" - postcss-selector-parser "^6.0.5" - -postcss-minify-font-values@^*: - version "5.1.0" - resolved "https://registry.yarnpkg.com/postcss-minify-font-values/-/postcss-minify-font-values-5.1.0.tgz#f1df0014a726083d260d3bd85d7385fb89d1f01b" - integrity sha512-el3mYTgx13ZAPPirSVsHqFzl+BBBDrXvbySvPGFnQcTI4iNslrPaFq4muTkLZmKlGk4gyFAYUBMH30+HurREyA== - dependencies: - postcss-value-parser "^4.2.0" - -postcss-minify-gradients@^*: - version "5.1.0" - resolved "https://registry.yarnpkg.com/postcss-minify-gradients/-/postcss-minify-gradients-5.1.0.tgz#de0260a67a13b7b321a8adc3150725f2c6612377" - integrity sha512-J/TMLklkONn3LuL8wCwfwU8zKC1hpS6VcxFkNUNjmVt53uKqrrykR3ov11mdUYyqVMEx67slMce0tE14cE4DTg== - dependencies: - colord "^2.9.1" - cssnano-utils "^3.1.0" - postcss-value-parser "^4.2.0" - -postcss-minify-params@^*: - version "5.1.1" - resolved "https://registry.yarnpkg.com/postcss-minify-params/-/postcss-minify-params-5.1.1.tgz#c5f8e7dac565e577dd99904787fbec576cbdbfb2" - integrity sha512-WCpr+J9Uz8XzMpAfg3UL8z5rde6MifBbh5L8bn8S2F5hq/YDJJzASYCnCHvAB4Fqb94ys8v95ULQkW2EhCFvNg== - dependencies: - browserslist "^4.16.6" - cssnano-utils "^3.1.0" - postcss-value-parser "^4.2.0" - -postcss-minify-selectors@^*: - version "5.2.0" - resolved "https://registry.yarnpkg.com/postcss-minify-selectors/-/postcss-minify-selectors-5.2.0.tgz#17c2be233e12b28ffa8a421a02fc8b839825536c" - integrity sha512-vYxvHkW+iULstA+ctVNx0VoRAR4THQQRkG77o0oa4/mBS0OzGvvzLIvHDv/nNEM0crzN2WIyFU5X7wZhaUK3RA== - dependencies: - postcss-selector-parser "^6.0.5" - -postcss-normalize-charset@^*: - version "5.1.0" - resolved "https://registry.yarnpkg.com/postcss-normalize-charset/-/postcss-normalize-charset-5.1.0.tgz#9302de0b29094b52c259e9b2cf8dc0879879f0ed" - integrity sha512-mSgUJ+pd/ldRGVx26p2wz9dNZ7ji6Pn8VWBajMXFf8jk7vUoSrZ2lt/wZR7DtlZYKesmZI680qjr2CeFF2fbUg== - -postcss-normalize-display-values@^*: - version "5.1.0" - resolved "https://registry.yarnpkg.com/postcss-normalize-display-values/-/postcss-normalize-display-values-5.1.0.tgz#72abbae58081960e9edd7200fcf21ab8325c3da8" - integrity sha512-WP4KIM4o2dazQXWmFaqMmcvsKmhdINFblgSeRgn8BJ6vxaMyaJkwAzpPpuvSIoG/rmX3M+IrRZEz2H0glrQNEA== - dependencies: - postcss-value-parser "^4.2.0" - -postcss-normalize-positions@^*: - version "5.1.0" - resolved "https://registry.yarnpkg.com/postcss-normalize-positions/-/postcss-normalize-positions-5.1.0.tgz#902a7cb97cf0b9e8b1b654d4a43d451e48966458" - integrity sha512-8gmItgA4H5xiUxgN/3TVvXRoJxkAWLW6f/KKhdsH03atg0cB8ilXnrB5PpSshwVu/dD2ZsRFQcR1OEmSBDAgcQ== - dependencies: - postcss-value-parser "^4.2.0" - -postcss-normalize-repeat-style@^*: - version "5.1.0" - resolved "https://registry.yarnpkg.com/postcss-normalize-repeat-style/-/postcss-normalize-repeat-style-5.1.0.tgz#f6d6fd5a54f51a741cc84a37f7459e60ef7a6398" - integrity sha512-IR3uBjc+7mcWGL6CtniKNQ4Rr5fTxwkaDHwMBDGGs1x9IVRkYIT/M4NelZWkAOBdV6v3Z9S46zqaKGlyzHSchw== - dependencies: - postcss-value-parser "^4.2.0" - -postcss-normalize-string@^*: - version "5.1.0" - resolved "https://registry.yarnpkg.com/postcss-normalize-string/-/postcss-normalize-string-5.1.0.tgz#411961169e07308c82c1f8c55f3e8a337757e228" - integrity sha512-oYiIJOf4T9T1N4i+abeIc7Vgm/xPCGih4bZz5Nm0/ARVJ7K6xrDlLwvwqOydvyL3RHNf8qZk6vo3aatiw/go3w== - dependencies: - postcss-value-parser "^4.2.0" - -postcss-normalize-timing-functions@^*: - version "5.1.0" - resolved "https://registry.yarnpkg.com/postcss-normalize-timing-functions/-/postcss-normalize-timing-functions-5.1.0.tgz#d5614410f8f0b2388e9f240aa6011ba6f52dafbb" - integrity sha512-DOEkzJ4SAXv5xkHl0Wa9cZLF3WCBhF3o1SKVxKQAa+0pYKlueTpCgvkFAHfk+Y64ezX9+nITGrDZeVGgITJXjg== - dependencies: - postcss-value-parser "^4.2.0" - -postcss-normalize-unicode@^*: - version "5.1.0" - resolved "https://registry.yarnpkg.com/postcss-normalize-unicode/-/postcss-normalize-unicode-5.1.0.tgz#3d23aede35e160089a285e27bf715de11dc9db75" - integrity sha512-J6M3MizAAZ2dOdSjy2caayJLQT8E8K9XjLce8AUQMwOrCvjCHv24aLC/Lps1R1ylOfol5VIDMaM/Lo9NGlk1SQ== - dependencies: - browserslist "^4.16.6" - postcss-value-parser "^4.2.0" - -postcss-normalize-url@^*: - version "5.1.0" - resolved "https://registry.yarnpkg.com/postcss-normalize-url/-/postcss-normalize-url-5.1.0.tgz#ed9d88ca82e21abef99f743457d3729a042adcdc" - integrity sha512-5upGeDO+PVthOxSmds43ZeMeZfKH+/DKgGRD7TElkkyS46JXAUhMzIKiCa7BabPeIy3AQcTkXwVVN7DbqsiCew== - dependencies: - normalize-url "^6.0.1" - postcss-value-parser "^4.2.0" - -postcss-normalize-whitespace@^*: - version "5.1.1" - resolved "https://registry.yarnpkg.com/postcss-normalize-whitespace/-/postcss-normalize-whitespace-5.1.1.tgz#08a1a0d1ffa17a7cc6efe1e6c9da969cc4493cfa" - integrity sha512-83ZJ4t3NUDETIHTa3uEg6asWjSBYL5EdkVB0sDncx9ERzOKBVJIUeDO9RyA9Zwtig8El1d79HBp0JEi8wvGQnA== - dependencies: - postcss-value-parser "^4.2.0" - -postcss-ordered-values@^*: - version "5.1.0" - resolved "https://registry.yarnpkg.com/postcss-ordered-values/-/postcss-ordered-values-5.1.0.tgz#04ef429e0991b0292bc918b135cd4c038f7b889f" - integrity sha512-wU4Z4D4uOIH+BUKkYid36gGDJNQtkVJT7Twv8qH6UyfttbbJWyw4/xIPuVEkkCtQLAJ0EdsNSh8dlvqkXb49TA== - dependencies: - cssnano-utils "^3.1.0" - postcss-value-parser "^4.2.0" - -postcss-reduce-initial@^*: - version "5.1.0" - resolved "https://registry.yarnpkg.com/postcss-reduce-initial/-/postcss-reduce-initial-5.1.0.tgz#fc31659ea6e85c492fb2a7b545370c215822c5d6" - integrity sha512-5OgTUviz0aeH6MtBjHfbr57tml13PuedK/Ecg8szzd4XRMbYxH4572JFG067z+FqBIf6Zp/d+0581glkvvWMFw== - dependencies: - browserslist "^4.16.6" - caniuse-api "^3.0.0" - -postcss-reduce-transforms@^*: - version "5.1.0" - resolved "https://registry.yarnpkg.com/postcss-reduce-transforms/-/postcss-reduce-transforms-5.1.0.tgz#333b70e7758b802f3dd0ddfe98bb1ccfef96b6e9" - integrity sha512-2fbdbmgir5AvpW9RLtdONx1QoYG2/EtqpNQbFASDlixBbAYuTcJ0dECwlqNqH7VbaUnEnh8SrxOe2sRIn24XyQ== - dependencies: - postcss-value-parser "^4.2.0" - -postcss-selector-parser@^6.0.4, postcss-selector-parser@^6.0.5, postcss-selector-parser@^6.0.9: - version "6.0.9" - resolved "https://registry.yarnpkg.com/postcss-selector-parser/-/postcss-selector-parser-6.0.9.tgz#ee71c3b9ff63d9cd130838876c13a2ec1a992b2f" - integrity sha512-UO3SgnZOVTwu4kyLR22UQ1xZh086RyNZppb7lLAKBFK8a32ttG5i87Y/P3+2bRSjZNyJ1B7hfFNo273tKe9YxQ== - dependencies: - cssesc "^3.0.0" - util-deprecate "^1.0.2" - -postcss-svgo@^*: - version "5.1.0" - resolved "https://registry.yarnpkg.com/postcss-svgo/-/postcss-svgo-5.1.0.tgz#0a317400ced789f233a28826e77523f15857d80d" - integrity sha512-D75KsH1zm5ZrHyxPakAxJWtkyXew5qwS70v56exwvw542d9CRtTo78K0WeFxZB4G7JXKKMbEZtZayTGdIky/eA== - dependencies: - postcss-value-parser "^4.2.0" - svgo "^2.7.0" - -postcss-unique-selectors@^*: - version "5.1.1" - resolved "https://registry.yarnpkg.com/postcss-unique-selectors/-/postcss-unique-selectors-5.1.1.tgz#a9f273d1eacd09e9aa6088f4b0507b18b1b541b6" - integrity sha512-5JiODlELrz8L2HwxfPnhOWZYWDxVHWL83ufOv84NrcgipI7TaeRsatAhK4Tr2/ZiYldpK/wBvw5BD3qfaK96GA== - dependencies: - postcss-selector-parser "^6.0.5" - -postcss-value-parser@^4.2.0: - version "4.2.0" - resolved "https://registry.yarnpkg.com/postcss-value-parser/-/postcss-value-parser-4.2.0.tgz#723c09920836ba6d3e5af019f92bc0971c02e514" - integrity sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ== - -postcss@^8.4.5: - version "8.4.8" - resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.4.8.tgz#dad963a76e82c081a0657d3a2f3602ce10c2e032" - integrity sha512-2tXEqGxrjvAO6U+CJzDL2Fk2kPHTv1jQsYkSoMeOis2SsYaXRO2COxTdQp99cYvif9JTXaAk9lYGc3VhJt7JPQ== - dependencies: - nanoid "^3.3.1" - picocolors "^1.0.0" - source-map-js "^1.0.2" - -posthtml-parser@^0.10.1: - version "0.10.2" - resolved "https://registry.yarnpkg.com/posthtml-parser/-/posthtml-parser-0.10.2.tgz#df364d7b179f2a6bf0466b56be7b98fd4e97c573" - integrity sha512-PId6zZ/2lyJi9LiKfe+i2xv57oEjJgWbsHGGANwos5AvdQp98i6AtamAl8gzSVFGfQ43Glb5D614cvZf012VKg== - dependencies: - htmlparser2 "^7.1.1" - -posthtml-parser@^0.11.0: - version "0.11.0" - resolved "https://registry.yarnpkg.com/posthtml-parser/-/posthtml-parser-0.11.0.tgz#25d1c7bf811ea83559bc4c21c189a29747a24b7a" - integrity sha512-QecJtfLekJbWVo/dMAA+OSwY79wpRmbqS5TeXvXSX+f0c6pW4/SE6inzZ2qkU7oAMCPqIDkZDvd/bQsSFUnKyw== - dependencies: - htmlparser2 "^7.1.1" - -posthtml-render@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/posthtml-render/-/posthtml-render-3.0.0.tgz#97be44931496f495b4f07b99e903cc70ad6a3205" - integrity sha512-z+16RoxK3fUPgwaIgH9NGnK1HKY9XIDpydky5eQGgAFVXTCSezalv9U2jQuNV+Z9qV1fDWNzldcw4eK0SSbqKA== - dependencies: - is-json "^2.0.1" - -posthtml@^0.16.4, posthtml@^0.16.5: - version "0.16.6" - resolved "https://registry.yarnpkg.com/posthtml/-/posthtml-0.16.6.tgz#e2fc407f67a64d2fa3567afe770409ffdadafe59" - integrity sha512-JcEmHlyLK/o0uGAlj65vgg+7LIms0xKXe60lcDOTU7oVX/3LuEuLwrQpW3VJ7de5TaFKiW4kWkaIpJL42FEgxQ== - dependencies: - posthtml-parser "^0.11.0" - posthtml-render "^3.0.0" - -react-refresh@^0.9.0: - version "0.9.0" - resolved "https://registry.yarnpkg.com/react-refresh/-/react-refresh-0.9.0.tgz#71863337adc3e5c2f8a6bfddd12ae3bfe32aafbf" - integrity sha512-Gvzk7OZpiqKSkxsQvO/mbTN1poglhmAV7gR/DdIrRrSMXraRQQlfikRJOr3Nb9GTMPC5kof948Zy6jJZIFtDvQ== - -regenerator-runtime@^0.13.7: - version "0.13.9" - resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.9.tgz#8925742a98ffd90814988d7566ad30ca3b263b52" - integrity sha512-p3VT+cOEgxFsRRA9X4lkI1E+k2/CtnKtU4gcxyaCUreilL/vqI6CdZ3wxVUx3UOUg+gnUOQQcRI7BmSI656MYA== - -resolve-from@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-4.0.0.tgz#4abcd852ad32dd7baabfe9b40e00a36db5f392e6" - integrity sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g== - -safe-buffer@^5.0.1: - version "5.2.1" - resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" - integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== - -seedrandom@2.4.3: - version "2.4.3" - resolved "https://registry.yarnpkg.com/seedrandom/-/seedrandom-2.4.3.tgz#2438504dad33917314bff18ac4d794f16d6aaecc" - integrity sha1-JDhQTa0zkXMUv/GKxNeU8W1qrsw= - -semver@^5.7.0, semver@^5.7.1: - version "5.7.1" - resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" - integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ== - -source-map-js@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/source-map-js/-/source-map-js-1.0.2.tgz#adbc361d9c62df380125e7f161f71c826f1e490c" - integrity sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw== - -source-map-support@~0.5.20: - version "0.5.21" - resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.21.tgz#04fe7c7f9e1ed2d662233c28cb2b35b9f63f6e4f" - integrity sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w== - dependencies: - buffer-from "^1.0.0" - source-map "^0.6.0" - -source-map@^0.6.0, source-map@^0.6.1: - version "0.6.1" - resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" - integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== - -stable@^0.1.8: - version "0.1.8" - resolved "https://registry.yarnpkg.com/stable/-/stable-0.1.8.tgz#836eb3c8382fe2936feaf544631017ce7d47a3cf" - integrity sha512-ji9qxRnOVfcuLDySj9qzhGSEFVobyt1kIOSkj1qZzYLzq7Tos/oUUWvotUPQLlrsidqsK6tBH89Bc9kL5zHA6w== - -stylehacks@^*: - version "5.1.0" - resolved "https://registry.yarnpkg.com/stylehacks/-/stylehacks-5.1.0.tgz#a40066490ca0caca04e96c6b02153ddc39913520" - integrity sha512-SzLmvHQTrIWfSgljkQCw2++C9+Ne91d/6Sp92I8c5uHTcy/PgeHamwITIbBW9wnFTY/3ZfSXR9HIL6Ikqmcu6Q== - dependencies: - browserslist "^4.16.6" - postcss-selector-parser "^6.0.4" - -supports-color@^5.3.0: - version "5.5.0" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f" - integrity sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow== - dependencies: - has-flag "^3.0.0" - -supports-color@^7.1.0: - version "7.2.0" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-7.2.0.tgz#1b7dcdcb32b8138801b3e478ba6a51caa89648da" - integrity sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw== - dependencies: - has-flag "^4.0.0" - -svgo@^2.4.0, svgo@^2.7.0: - version "2.8.0" - resolved "https://registry.yarnpkg.com/svgo/-/svgo-2.8.0.tgz#4ff80cce6710dc2795f0c7c74101e6764cfccd24" - integrity sha512-+N/Q9kV1+F+UeWYoSiULYo4xYSDQlTgb+ayMobAXPwMnLvop7oxKMo9OzIrX5x3eS4L4f2UHhc9axXwY8DpChg== - dependencies: - "@trysound/sax" "0.2.0" - commander "^7.2.0" - css-select "^4.1.3" - css-tree "^1.1.3" - csso "^4.2.0" - picocolors "^1.0.0" - stable "^0.1.8" - -terser@^5.2.0: - version "5.14.2" - resolved "https://registry.yarnpkg.com/terser/-/terser-5.14.2.tgz#9ac9f22b06994d736174f4091aa368db896f1c10" - integrity sha512-oL0rGeM/WFQCUd0y2QrWxYnq7tfSuKBiqTjRPWrRgB46WD/kiwHwF8T23z78H6Q6kGCuuHcPB+KULHRdxvVGQA== - dependencies: - "@jridgewell/source-map" "^0.3.2" - acorn "^8.5.0" - commander "^2.20.0" - source-map-support "~0.5.20" - -timsort@^0.3.0: - version "0.3.0" - resolved "https://registry.yarnpkg.com/timsort/-/timsort-0.3.0.tgz#405411a8e7e6339fe64db9a234de11dc31e02bd4" - integrity sha1-QFQRqOfmM5/mTbmiNN4R3DHgK9Q= - -tr46@~0.0.3: - version "0.0.3" - resolved "https://registry.yarnpkg.com/tr46/-/tr46-0.0.3.tgz#8184fd347dac9cdc185992f3a6622e14b9d9ab6a" - integrity sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o= - -type-fest@^0.20.2: - version "0.20.2" - resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.20.2.tgz#1bf207f4b28f91583666cb5fbd327887301cd5f4" - integrity sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ== - -util-deprecate@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" - integrity sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8= - -utility-types@^3.10.0: - version "3.10.0" - resolved "https://registry.yarnpkg.com/utility-types/-/utility-types-3.10.0.tgz#ea4148f9a741015f05ed74fd615e1d20e6bed82b" - integrity sha512-O11mqxmi7wMKCo6HKFt5AhO4BwY3VV68YU07tgxfz8zJTIxr4BpsezN49Ffwy9j3ZpwwJp4fkRwjRzq3uWE6Rg== - -v8-compile-cache@^2.0.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz#2de19618c66dc247dcfb6f99338035d8245a2cee" - integrity sha512-l8lCEmLcLYZh4nbunNZvQCJc5pv7+RCwa8q/LdUx8u7lsWvPDKmpodJAJNwkAhJC//dFY48KuIEmjtd4RViDrA== - -weak-lru-cache@^1.2.2: - version "1.2.2" - resolved "https://registry.yarnpkg.com/weak-lru-cache/-/weak-lru-cache-1.2.2.tgz#fdbb6741f36bae9540d12f480ce8254060dccd19" - integrity sha512-DEAoo25RfSYMuTGc9vPJzZcZullwIqRDSI9LOy+fkCJPi6hykCnfKaXTuPBDuXAUcqHXyOgFtHNp/kB2FjYHbw== - -webidl-conversions@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871" - integrity sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE= - -whatwg-url@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-5.0.0.tgz#966454e8765462e37644d3626f6742ce8b70965d" - integrity sha1-lmRU6HZUYuN2RNNib2dCzotwll0= - dependencies: - tr46 "~0.0.3" - webidl-conversions "^3.0.0" - -xxhash-wasm@^0.4.2: - version "0.4.2" - resolved "https://registry.yarnpkg.com/xxhash-wasm/-/xxhash-wasm-0.4.2.tgz#752398c131a4dd407b5132ba62ad372029be6f79" - integrity sha512-/eyHVRJQCirEkSZ1agRSCwriMhwlyUcFkXD5TPVSLP+IPzjsqMVzZwdoczLp1SoQU0R3dxz1RpIK+4YNQbCVOA== - -yaml@^1.10.0, yaml@^1.10.2: - version "1.10.2" - resolved "https://registry.yarnpkg.com/yaml/-/yaml-1.10.2.tgz#2301c5ffbf12b467de8da2333a459e29e7920e4b" - integrity sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg== diff --git a/tfjs-master/tfjs-backend-wasm/starter/webpack/README.md b/tfjs-master/tfjs-backend-wasm/starter/webpack/README.md deleted file mode 100644 index 586ee9bb4..000000000 --- a/tfjs-master/tfjs-backend-wasm/starter/webpack/README.md +++ /dev/null @@ -1,42 +0,0 @@ -# Starter project for WebPack - -A minimal starter project using WebPack and the WASM backend. -See [Using Bundlers](../../README.md#using-bundlers) section in the main readme -for details on how we serve the WASM backend on NPM. - -To serve the `.wasm` file, we use the `file-loader` plugin and added the -following to `webpack.config.js`, which tells WebPack to provide the serving url -when importing `.wasm` files: - -```js -module: { - rules: [ - { - test: /\.wasm$/i, - type: 'javascript/auto', - use: [ - { - loader: 'file-loader', - }, - ], - }, - ], -} -``` - -Then we obtain the final serving path of the WASM binaries that were shipped on -NPM, and use `setWasmPaths` to let the library know the serving locations: - -```ts -import {setWasmPaths} from '@tensorflow/tfjs-backend-wasm'; - -import wasmSimdPath from './node_modules/@tensorflow/tfjs-backend-wasm/dist/tfjs-backend-wasm-simd.wasm'; -import wasmSimdThreadedPath from './node_modules/@tensorflow/tfjs-backend-wasm/dist/tfjs-backend-wasm-threaded-simd.wasm'; -import wasmPath from './node_modules/@tensorflow/tfjs-backend-wasm/dist/tfjs-backend-wasm.wasm'; - -setWasmPaths({ - 'tfjs-backend-wasm.wasm': wasmPath, - 'tfjs-backend-wasm-simd.wasm': wasmSimdPath, - 'tfjs-backend-wasm-threaded-simd.wasm': wasmSimdThreadedPath -}); -``` diff --git a/tfjs-master/tfjs-backend-wasm/starter/webpack/package.json b/tfjs-master/tfjs-backend-wasm/starter/webpack/package.json deleted file mode 100644 index 5217a0395..000000000 --- a/tfjs-master/tfjs-backend-wasm/starter/webpack/package.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "name": "wasm-webpack", - "version": "1.0.0", - "description": "Sample webpack app that uses the WASM backend", - "private": true, - "scripts": { - "watch": "webpack-dev-server --open", - "build": "webpack" - }, - "dependencies": { - "@tensorflow/tfjs-backend-wasm": "2.6.0", - "@tensorflow/tfjs-core": "2.6.0" - }, - "browserslist": [ - "defaults" - ], - "devDependencies": { - "file-loader": "^5.0.2", - "html-webpack-plugin": "^5.5.0", - "webpack": "^5.76.0", - "webpack-cli": "^4.9.2", - "webpack-dev-server": "^4.7.4" - }, - "resolutions": { - "minimist": "1.2.6" - }, - "keywords": [] -} diff --git a/tfjs-master/tfjs-backend-wasm/starter/webpack/src/index.js b/tfjs-master/tfjs-backend-wasm/starter/webpack/src/index.js deleted file mode 100644 index fde4332d8..000000000 --- a/tfjs-master/tfjs-backend-wasm/starter/webpack/src/index.js +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2019 Google LLC. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= - -import {setWasmPaths} from '@tensorflow/tfjs-backend-wasm'; -import * as tf from '@tensorflow/tfjs-core'; - -import wasmSimdPath from '../node_modules/@tensorflow/tfjs-backend-wasm/dist/tfjs-backend-wasm-simd.wasm'; -import wasmSimdThreadedPath from '../node_modules/@tensorflow/tfjs-backend-wasm/dist/tfjs-backend-wasm-threaded-simd.wasm'; -import wasmPath from '../node_modules/@tensorflow/tfjs-backend-wasm/dist/tfjs-backend-wasm.wasm'; - - -async function run() { - setWasmPaths({ - 'tfjs-backend-wasm.wasm': wasmPath, - 'tfjs-backend-wasm-simd.wasm': wasmSimdPath, - 'tfjs-backend-wasm-threaded-simd.wasm': wasmSimdThreadedPath - }); - await tf.setBackend('wasm'); - tf.add(5, 3).print(); -} - -run(); diff --git a/tfjs-master/tfjs-backend-wasm/starter/webpack/webpack.config.js b/tfjs-master/tfjs-backend-wasm/starter/webpack/webpack.config.js deleted file mode 100644 index 3f042cdf1..000000000 --- a/tfjs-master/tfjs-backend-wasm/starter/webpack/webpack.config.js +++ /dev/null @@ -1,29 +0,0 @@ -const HtmlWebpackPlugin = require('html-webpack-plugin'); - -module.exports = { - mode: 'development', - entry: { - app: './src/index.js', - }, - devServer: { - static: './dist', - }, - plugins: [ - new HtmlWebpackPlugin({ - title: 'Webpack sample app', - }), - ], - module: { - rules: [ - { - test: /\.wasm$/i, - type: 'javascript/auto', - use: [ - { - loader: 'file-loader', - }, - ], - }, - ], - }, -}; diff --git a/tfjs-master/tfjs-backend-wasm/starter/webpack/yarn.lock b/tfjs-master/tfjs-backend-wasm/starter/webpack/yarn.lock deleted file mode 100644 index 5b3f73bfb..000000000 --- a/tfjs-master/tfjs-backend-wasm/starter/webpack/yarn.lock +++ /dev/null @@ -1,2635 +0,0 @@ -# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. -# yarn lockfile v1 - - -"@discoveryjs/json-ext@^0.5.0": - version "0.5.7" - resolved "https://registry.yarnpkg.com/@discoveryjs/json-ext/-/json-ext-0.5.7.tgz#1d572bfbbe14b7704e0ba0f39b74815b84870d70" - integrity sha512-dBVuXR082gk3jsFp7Rd/JI4kytwGHecnCoTtXFb7DB6CNHp4rg5k1bhg0nWdLGLnOV71lmDzGQaLMy8iPLY0pw== - -"@jridgewell/gen-mapping@^0.3.0": - version "0.3.2" - resolved "https://registry.yarnpkg.com/@jridgewell/gen-mapping/-/gen-mapping-0.3.2.tgz#c1aedc61e853f2bb9f5dfe6d4442d3b565b253b9" - integrity sha512-mh65xKQAzI6iBcFzwv28KVWSmCkdRBWoOh+bYQGW3+6OZvbbN3TqMGo5hqYxQniRcH9F2VZIoJCm4pa3BPDK/A== - dependencies: - "@jridgewell/set-array" "^1.0.1" - "@jridgewell/sourcemap-codec" "^1.4.10" - "@jridgewell/trace-mapping" "^0.3.9" - -"@jridgewell/resolve-uri@^3.0.3": - version "3.1.0" - resolved "https://registry.yarnpkg.com/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz#2203b118c157721addfe69d47b70465463066d78" - integrity sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w== - -"@jridgewell/set-array@^1.0.1": - version "1.1.2" - resolved "https://registry.yarnpkg.com/@jridgewell/set-array/-/set-array-1.1.2.tgz#7c6cf998d6d20b914c0a55a91ae928ff25965e72" - integrity sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw== - -"@jridgewell/source-map@^0.3.2": - version "0.3.2" - resolved "https://registry.yarnpkg.com/@jridgewell/source-map/-/source-map-0.3.2.tgz#f45351aaed4527a298512ec72f81040c998580fb" - integrity sha512-m7O9o2uR8k2ObDysZYzdfhb08VuEml5oWGiosa1VdaPZ/A6QyPkAJuwN0Q1lhULOf6B7MtQmHENS743hWtCrgw== - dependencies: - "@jridgewell/gen-mapping" "^0.3.0" - "@jridgewell/trace-mapping" "^0.3.9" - -"@jridgewell/sourcemap-codec@^1.4.10": - version "1.4.14" - resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz#add4c98d341472a289190b424efbdb096991bb24" - integrity sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw== - -"@jridgewell/trace-mapping@^0.3.9": - version "0.3.14" - resolved "https://registry.yarnpkg.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.14.tgz#b231a081d8f66796e475ad588a1ef473112701ed" - integrity sha512-bJWEfQ9lPTvm3SneWwRFVLzrh6nhjwqw7TUFFBEMzwvg7t7PCDenf2lDwqo4NQXzdpgBXyFgDWnQA+2vkruksQ== - dependencies: - "@jridgewell/resolve-uri" "^3.0.3" - "@jridgewell/sourcemap-codec" "^1.4.10" - -"@nodelib/fs.scandir@2.1.5": - version "2.1.5" - resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz#7619c2eb21b25483f6d167548b4cfd5a7488c3d5" - integrity sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g== - dependencies: - "@nodelib/fs.stat" "2.0.5" - run-parallel "^1.1.9" - -"@nodelib/fs.stat@2.0.5", "@nodelib/fs.stat@^2.0.2": - version "2.0.5" - resolved "https://registry.yarnpkg.com/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz#5bd262af94e9d25bd1e71b05deed44876a222e8b" - integrity sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A== - -"@nodelib/fs.walk@^1.2.3": - version "1.2.8" - resolved "https://registry.yarnpkg.com/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz#e95737e8bb6746ddedf69c556953494f196fe69a" - integrity sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg== - dependencies: - "@nodelib/fs.scandir" "2.1.5" - fastq "^1.6.0" - -"@tensorflow/tfjs-backend-wasm@2.6.0": - version "2.6.0" - resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-backend-wasm/-/tfjs-backend-wasm-2.6.0.tgz#e6d43d09a52aa92050f29f779e1ae4f4afe03991" - integrity "sha1-5tQ9CaUqqSBQ8p93nhrk9K/gOZE= sha512-yrhKcZQ3xjStXKTCvg6aQzgmE77vFrIoGW3kuhJrrVJfbihnrekuysPEXtl1UnYOlgGTCM/JrSC0P0sNK9Rq6A==" - dependencies: - "@types/emscripten" "~0.0.34" - -"@tensorflow/tfjs-core@2.6.0": - version "2.6.0" - resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-core/-/tfjs-core-2.6.0.tgz#ab2f2c9e8f46990643076d7d5bdb912885282bd2" - integrity "sha1-qy8sno9GmQZDB219W9uRKIUoK9I= sha512-akUB1iz663UCUdOfEUu91XeHzGpdYtdtMPxjsGEdF0CwENzSAcvHzQrEVoPBRD+RKpxrVXvQBoOd7GYBxMIIKQ==" - dependencies: - "@types/offscreencanvas" "~2019.3.0" - "@types/seedrandom" "2.4.27" - "@types/webgl-ext" "0.0.30" - "@types/webgl2" "0.0.4" - node-fetch "~2.6.1" - seedrandom "2.4.3" - -"@types/body-parser@*": - version "1.19.2" - resolved "https://registry.yarnpkg.com/@types/body-parser/-/body-parser-1.19.2.tgz#aea2059e28b7658639081347ac4fab3de166e6f0" - integrity sha512-ALYone6pm6QmwZoAgeyNksccT9Q4AWZQ6PvfwR37GT6r6FWUPguq6sUmNGSMV2Wr761oQoBxwGGa6DR5o1DC9g== - dependencies: - "@types/connect" "*" - "@types/node" "*" - -"@types/bonjour@^3.5.9": - version "3.5.10" - resolved "https://registry.yarnpkg.com/@types/bonjour/-/bonjour-3.5.10.tgz#0f6aadfe00ea414edc86f5d106357cda9701e275" - integrity sha512-p7ienRMiS41Nu2/igbJxxLDWrSZ0WxM8UQgCeO9KhoVF7cOVFkrKsiDr1EsJIla8vV3oEEjGcz11jc5yimhzZw== - dependencies: - "@types/node" "*" - -"@types/connect-history-api-fallback@^1.3.5": - version "1.3.5" - resolved "https://registry.yarnpkg.com/@types/connect-history-api-fallback/-/connect-history-api-fallback-1.3.5.tgz#d1f7a8a09d0ed5a57aee5ae9c18ab9b803205dae" - integrity sha512-h8QJa8xSb1WD4fpKBDcATDNGXghFj6/3GRWG6dhmRcu0RX1Ubasur2Uvx5aeEwlf0MwblEC2bMzzMQntxnw/Cw== - dependencies: - "@types/express-serve-static-core" "*" - "@types/node" "*" - -"@types/connect@*": - version "3.4.35" - resolved "https://registry.yarnpkg.com/@types/connect/-/connect-3.4.35.tgz#5fcf6ae445e4021d1fc2219a4873cc73a3bb2ad1" - integrity sha512-cdeYyv4KWoEgpBISTxWvqYsVy444DOqehiF3fM3ne10AmJ62RSyNkUnxMJXHQWRQQX2eR94m5y1IZyDwBjV9FQ== - dependencies: - "@types/node" "*" - -"@types/emscripten@~0.0.34": - version "0.0.34" - resolved "https://registry.yarnpkg.com/@types/emscripten/-/emscripten-0.0.34.tgz#12b4a344274fb102ff2f6c877b37587bc3e46008" - integrity sha512-QSb9ojDincskc+uKMI0KXp8e1NALFINCrMlp8VGKGcTSxeEyRTTKyjWw75NYrCZHUsVEEEpr1tYHpbtaC++/sQ== - -"@types/eslint-scope@^3.7.3": - version "3.7.3" - resolved "https://registry.yarnpkg.com/@types/eslint-scope/-/eslint-scope-3.7.3.tgz#125b88504b61e3c8bc6f870882003253005c3224" - integrity sha512-PB3ldyrcnAicT35TWPs5IcwKD8S333HMaa2VVv4+wdvebJkjWuW/xESoB8IwRcog8HYVYamb1g/R31Qv5Bx03g== - dependencies: - "@types/eslint" "*" - "@types/estree" "*" - -"@types/eslint@*": - version "8.4.1" - resolved "https://registry.yarnpkg.com/@types/eslint/-/eslint-8.4.1.tgz#c48251553e8759db9e656de3efc846954ac32304" - integrity sha512-GE44+DNEyxxh2Kc6ro/VkIj+9ma0pO0bwv9+uHSyBrikYOHr8zYcdPvnBOp1aw8s+CjRvuSx7CyWqRrNFQ59mA== - dependencies: - "@types/estree" "*" - "@types/json-schema" "*" - -"@types/estree@*", "@types/estree@^0.0.51": - version "0.0.51" - resolved "https://registry.yarnpkg.com/@types/estree/-/estree-0.0.51.tgz#cfd70924a25a3fd32b218e5e420e6897e1ac4f40" - integrity sha512-CuPgU6f3eT/XgKKPqKd/gLZV1Xmvf1a2R5POBOGQa6uv82xpls89HU5zKeVoyR8XzHd1RGNOlQlvUe3CFkjWNQ== - -"@types/express-serve-static-core@*", "@types/express-serve-static-core@^4.17.18": - version "4.17.28" - resolved "https://registry.yarnpkg.com/@types/express-serve-static-core/-/express-serve-static-core-4.17.28.tgz#c47def9f34ec81dc6328d0b1b5303d1ec98d86b8" - integrity sha512-P1BJAEAW3E2DJUlkgq4tOL3RyMunoWXqbSCygWo5ZIWTjUgN1YnaXWW4VWl/oc8vs/XoYibEGBKP0uZyF4AHig== - dependencies: - "@types/node" "*" - "@types/qs" "*" - "@types/range-parser" "*" - -"@types/express@*", "@types/express@^4.17.13": - version "4.17.13" - resolved "https://registry.yarnpkg.com/@types/express/-/express-4.17.13.tgz#a76e2995728999bab51a33fabce1d705a3709034" - integrity sha512-6bSZTPaTIACxn48l50SR+axgrqm6qXFIxrdAKaG6PaJk3+zuUr35hBlgT7vOmJcum+OEaIBLtHV/qloEAFITeA== - dependencies: - "@types/body-parser" "*" - "@types/express-serve-static-core" "^4.17.18" - "@types/qs" "*" - "@types/serve-static" "*" - -"@types/html-minifier-terser@^6.0.0": - version "6.1.0" - resolved "https://registry.yarnpkg.com/@types/html-minifier-terser/-/html-minifier-terser-6.1.0.tgz#4fc33a00c1d0c16987b1a20cf92d20614c55ac35" - integrity sha512-oh/6byDPnL1zeNXFrDXFLyZjkr1MsBG667IM792caf1L2UPOOMf65NFzjUH/ltyfwjAGfs1rsX1eftK0jC/KIg== - -"@types/http-proxy@^1.17.8": - version "1.17.8" - resolved "https://registry.yarnpkg.com/@types/http-proxy/-/http-proxy-1.17.8.tgz#968c66903e7e42b483608030ee85800f22d03f55" - integrity sha512-5kPLG5BKpWYkw/LVOGWpiq3nEVqxiN32rTgI53Sk12/xHFQ2rG3ehI9IO+O3W2QoKeyB92dJkoka8SUm6BX1pA== - dependencies: - "@types/node" "*" - -"@types/json-schema@*", "@types/json-schema@^7.0.5", "@types/json-schema@^7.0.8", "@types/json-schema@^7.0.9": - version "7.0.9" - resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.9.tgz#97edc9037ea0c38585320b28964dde3b39e4660d" - integrity sha512-qcUXuemtEu+E5wZSJHNxUXeCZhAfXKQ41D+duX+VYPde7xyEVZci+/oXKJL13tnRs9lR2pr4fod59GT6/X1/yQ== - -"@types/mime@^1": - version "1.3.2" - resolved "https://registry.yarnpkg.com/@types/mime/-/mime-1.3.2.tgz#93e25bf9ee75fe0fd80b594bc4feb0e862111b5a" - integrity sha512-YATxVxgRqNH6nHEIsvg6k2Boc1JHI9ZbH5iWFFv/MTkchz3b1ieGDa5T0a9RznNdI0KhVbdbWSN+KWWrQZRxTw== - -"@types/node@*": - version "17.0.21" - resolved "https://registry.yarnpkg.com/@types/node/-/node-17.0.21.tgz#864b987c0c68d07b4345845c3e63b75edd143644" - integrity sha512-DBZCJbhII3r90XbQxI8Y9IjjiiOGlZ0Hr32omXIZvwwZ7p4DMMXGrKXVyPfuoBOri9XNtL0UK69jYIBIsRX3QQ== - -"@types/offscreencanvas@~2019.3.0": - version "2019.3.0" - resolved "https://registry.yarnpkg.com/@types/offscreencanvas/-/offscreencanvas-2019.3.0.tgz#3336428ec7e9180cf4566dfea5da04eb586a6553" - integrity sha512-esIJx9bQg+QYF0ra8GnvfianIY8qWB0GBx54PK5Eps6m+xTj86KLavHv6qDhzKcu5UUOgNfJ2pWaIIV7TRUd9Q== - -"@types/qs@*": - version "6.9.7" - resolved "https://registry.yarnpkg.com/@types/qs/-/qs-6.9.7.tgz#63bb7d067db107cc1e457c303bc25d511febf6cb" - integrity sha512-FGa1F62FT09qcrueBA6qYTrJPVDzah9a+493+o2PCXsesWHIn27G98TsSMs3WPNbZIEj4+VJf6saSFpvD+3Zsw== - -"@types/range-parser@*": - version "1.2.4" - resolved "https://registry.yarnpkg.com/@types/range-parser/-/range-parser-1.2.4.tgz#cd667bcfdd025213aafb7ca5915a932590acdcdc" - integrity sha512-EEhsLsD6UsDM1yFhAvy0Cjr6VwmpMWqFBCb9w07wVugF7w9nfajxLuVmngTIpgS6svCnm6Vaw+MZhoDCKnOfsw== - -"@types/retry@^0.12.0": - version "0.12.1" - resolved "https://registry.yarnpkg.com/@types/retry/-/retry-0.12.1.tgz#d8f1c0d0dc23afad6dc16a9e993a0865774b4065" - integrity sha512-xoDlM2S4ortawSWORYqsdU+2rxdh4LRW9ytc3zmT37RIKQh6IHyKwwtKhKis9ah8ol07DCkZxPt8BBvPjC6v4g== - -"@types/seedrandom@2.4.27": - version "2.4.27" - resolved "https://registry.yarnpkg.com/@types/seedrandom/-/seedrandom-2.4.27.tgz#9db563937dd86915f69092bc43259d2f48578e41" - integrity sha1-nbVjk33YaRX2kJK8QyWdL0hXjkE= - -"@types/serve-index@^1.9.1": - version "1.9.1" - resolved "https://registry.yarnpkg.com/@types/serve-index/-/serve-index-1.9.1.tgz#1b5e85370a192c01ec6cec4735cf2917337a6278" - integrity sha512-d/Hs3nWDxNL2xAczmOVZNj92YZCS6RGxfBPjKzuu/XirCgXdpKEb88dYNbrYGint6IVWLNP+yonwVAuRC0T2Dg== - dependencies: - "@types/express" "*" - -"@types/serve-static@*": - version "1.13.10" - resolved "https://registry.yarnpkg.com/@types/serve-static/-/serve-static-1.13.10.tgz#f5e0ce8797d2d7cc5ebeda48a52c96c4fa47a8d9" - integrity sha512-nCkHGI4w7ZgAdNkrEu0bv+4xNV/XDqW+DydknebMOQwkpDGx8G+HTlj7R7ABI8i8nKxVw0wtKPi1D+lPOkh4YQ== - dependencies: - "@types/mime" "^1" - "@types/node" "*" - -"@types/sockjs@^0.3.33": - version "0.3.33" - resolved "https://registry.yarnpkg.com/@types/sockjs/-/sockjs-0.3.33.tgz#570d3a0b99ac995360e3136fd6045113b1bd236f" - integrity sha512-f0KEEe05NvUnat+boPTZ0dgaLZ4SfSouXUgv5noUiefG2ajgKjmETo9ZJyuqsl7dfl2aHlLJUiki6B4ZYldiiw== - dependencies: - "@types/node" "*" - -"@types/webgl-ext@0.0.30": - version "0.0.30" - resolved "https://registry.yarnpkg.com/@types/webgl-ext/-/webgl-ext-0.0.30.tgz#0ce498c16a41a23d15289e0b844d945b25f0fb9d" - integrity sha512-LKVgNmBxN0BbljJrVUwkxwRYqzsAEPcZOe6S2T6ZaBDIrFp0qu4FNlpc5sM1tGbXUYFgdVQIoeLk1Y1UoblyEg== - -"@types/webgl2@0.0.4": - version "0.0.4" - resolved "https://registry.yarnpkg.com/@types/webgl2/-/webgl2-0.0.4.tgz#c3b0f9d6b465c66138e84e64cb3bdf8373c2c279" - integrity sha512-PACt1xdErJbMUOUweSrbVM7gSIYm1vTncW2hF6Os/EeWi6TXYAYMPp+8v6rzHmypE5gHrxaxZNXgMkJVIdZpHw== - -"@types/ws@^8.2.2": - version "8.5.3" - resolved "https://registry.yarnpkg.com/@types/ws/-/ws-8.5.3.tgz#7d25a1ffbecd3c4f2d35068d0b283c037003274d" - integrity sha512-6YOoWjruKj1uLf3INHH7D3qTXwFfEsg1kf3c0uDdSBJwfa/llkwIjrAGV7j7mVgGNbzTQ3HiHKKDXl6bJPD97w== - dependencies: - "@types/node" "*" - -"@webassemblyjs/ast@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.11.1.tgz#2bfd767eae1a6996f432ff7e8d7fc75679c0b6a7" - integrity sha512-ukBh14qFLjxTQNTXocdyksN5QdM28S1CxHt2rdskFyL+xFV7VremuBLVbmCePj+URalXBENx/9Lm7lnhihtCSw== - dependencies: - "@webassemblyjs/helper-numbers" "1.11.1" - "@webassemblyjs/helper-wasm-bytecode" "1.11.1" - -"@webassemblyjs/floating-point-hex-parser@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/floating-point-hex-parser/-/floating-point-hex-parser-1.11.1.tgz#f6c61a705f0fd7a6aecaa4e8198f23d9dc179e4f" - integrity sha512-iGRfyc5Bq+NnNuX8b5hwBrRjzf0ocrJPI6GWFodBFzmFnyvrQ83SHKhmilCU/8Jv67i4GJZBMhEzltxzcNagtQ== - -"@webassemblyjs/helper-api-error@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-api-error/-/helper-api-error-1.11.1.tgz#1a63192d8788e5c012800ba6a7a46c705288fd16" - integrity sha512-RlhS8CBCXfRUR/cwo2ho9bkheSXG0+NwooXcc3PAILALf2QLdFyj7KGsKRbVc95hZnhnERon4kW/D3SZpp6Tcg== - -"@webassemblyjs/helper-buffer@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-buffer/-/helper-buffer-1.11.1.tgz#832a900eb444884cde9a7cad467f81500f5e5ab5" - integrity sha512-gwikF65aDNeeXa8JxXa2BAk+REjSyhrNC9ZwdT0f8jc4dQQeDQ7G4m0f2QCLPJiMTTO6wfDmRmj/pW0PsUvIcA== - -"@webassemblyjs/helper-numbers@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-numbers/-/helper-numbers-1.11.1.tgz#64d81da219fbbba1e3bd1bfc74f6e8c4e10a62ae" - integrity sha512-vDkbxiB8zfnPdNK9Rajcey5C0w+QJugEglN0of+kmO8l7lDb77AnlKYQF7aarZuCrv+l0UvqL+68gSDr3k9LPQ== - dependencies: - "@webassemblyjs/floating-point-hex-parser" "1.11.1" - "@webassemblyjs/helper-api-error" "1.11.1" - "@xtuc/long" "4.2.2" - -"@webassemblyjs/helper-wasm-bytecode@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-wasm-bytecode/-/helper-wasm-bytecode-1.11.1.tgz#f328241e41e7b199d0b20c18e88429c4433295e1" - integrity sha512-PvpoOGiJwXeTrSf/qfudJhwlvDQxFgelbMqtq52WWiXC6Xgg1IREdngmPN3bs4RoO83PnL/nFrxucXj1+BX62Q== - -"@webassemblyjs/helper-wasm-section@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-wasm-section/-/helper-wasm-section-1.11.1.tgz#21ee065a7b635f319e738f0dd73bfbda281c097a" - integrity sha512-10P9No29rYX1j7F3EVPX3JvGPQPae+AomuSTPiF9eBQeChHI6iqjMIwR9JmOJXwpnn/oVGDk7I5IlskuMwU/pg== - dependencies: - "@webassemblyjs/ast" "1.11.1" - "@webassemblyjs/helper-buffer" "1.11.1" - "@webassemblyjs/helper-wasm-bytecode" "1.11.1" - "@webassemblyjs/wasm-gen" "1.11.1" - -"@webassemblyjs/ieee754@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/ieee754/-/ieee754-1.11.1.tgz#963929e9bbd05709e7e12243a099180812992614" - integrity sha512-hJ87QIPtAMKbFq6CGTkZYJivEwZDbQUgYd3qKSadTNOhVY7p+gfP6Sr0lLRVTaG1JjFj+r3YchoqRYxNH3M0GQ== - dependencies: - "@xtuc/ieee754" "^1.2.0" - -"@webassemblyjs/leb128@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/leb128/-/leb128-1.11.1.tgz#ce814b45574e93d76bae1fb2644ab9cdd9527aa5" - integrity sha512-BJ2P0hNZ0u+Th1YZXJpzW6miwqQUGcIHT1G/sf72gLVD9DZ5AdYTqPNbHZh6K1M5VmKvFXwGSWZADz+qBWxeRw== - dependencies: - "@xtuc/long" "4.2.2" - -"@webassemblyjs/utf8@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/utf8/-/utf8-1.11.1.tgz#d1f8b764369e7c6e6bae350e854dec9a59f0a3ff" - integrity sha512-9kqcxAEdMhiwQkHpkNiorZzqpGrodQQ2IGrHHxCy+Ozng0ofyMA0lTqiLkVs1uzTRejX+/O0EOT7KxqVPuXosQ== - -"@webassemblyjs/wasm-edit@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-edit/-/wasm-edit-1.11.1.tgz#ad206ebf4bf95a058ce9880a8c092c5dec8193d6" - integrity sha512-g+RsupUC1aTHfR8CDgnsVRVZFJqdkFHpsHMfJuWQzWU3tvnLC07UqHICfP+4XyL2tnr1amvl1Sdp06TnYCmVkA== - dependencies: - "@webassemblyjs/ast" "1.11.1" - "@webassemblyjs/helper-buffer" "1.11.1" - "@webassemblyjs/helper-wasm-bytecode" "1.11.1" - "@webassemblyjs/helper-wasm-section" "1.11.1" - "@webassemblyjs/wasm-gen" "1.11.1" - "@webassemblyjs/wasm-opt" "1.11.1" - "@webassemblyjs/wasm-parser" "1.11.1" - "@webassemblyjs/wast-printer" "1.11.1" - -"@webassemblyjs/wasm-gen@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-gen/-/wasm-gen-1.11.1.tgz#86c5ea304849759b7d88c47a32f4f039ae3c8f76" - integrity sha512-F7QqKXwwNlMmsulj6+O7r4mmtAlCWfO/0HdgOxSklZfQcDu0TpLiD1mRt/zF25Bk59FIjEuGAIyn5ei4yMfLhA== - dependencies: - "@webassemblyjs/ast" "1.11.1" - "@webassemblyjs/helper-wasm-bytecode" "1.11.1" - "@webassemblyjs/ieee754" "1.11.1" - "@webassemblyjs/leb128" "1.11.1" - "@webassemblyjs/utf8" "1.11.1" - -"@webassemblyjs/wasm-opt@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-opt/-/wasm-opt-1.11.1.tgz#657b4c2202f4cf3b345f8a4c6461c8c2418985f2" - integrity sha512-VqnkNqnZlU5EB64pp1l7hdm3hmQw7Vgqa0KF/KCNO9sIpI6Fk6brDEiX+iCOYrvMuBWDws0NkTOxYEb85XQHHw== - dependencies: - "@webassemblyjs/ast" "1.11.1" - "@webassemblyjs/helper-buffer" "1.11.1" - "@webassemblyjs/wasm-gen" "1.11.1" - "@webassemblyjs/wasm-parser" "1.11.1" - -"@webassemblyjs/wasm-parser@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-parser/-/wasm-parser-1.11.1.tgz#86ca734534f417e9bd3c67c7a1c75d8be41fb199" - integrity sha512-rrBujw+dJu32gYB7/Lup6UhdkPx9S9SnobZzRVL7VcBH9Bt9bCBLEuX/YXOOtBsOZ4NQrRykKhffRWHvigQvOA== - dependencies: - "@webassemblyjs/ast" "1.11.1" - "@webassemblyjs/helper-api-error" "1.11.1" - "@webassemblyjs/helper-wasm-bytecode" "1.11.1" - "@webassemblyjs/ieee754" "1.11.1" - "@webassemblyjs/leb128" "1.11.1" - "@webassemblyjs/utf8" "1.11.1" - -"@webassemblyjs/wast-printer@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/wast-printer/-/wast-printer-1.11.1.tgz#d0c73beda8eec5426f10ae8ef55cee5e7084c2f0" - integrity sha512-IQboUWM4eKzWW+N/jij2sRatKMh99QEelo3Eb2q0qXkvPRISAj8Qxtmw5itwqK+TTkBuUIE45AxYPToqPtL5gg== - dependencies: - "@webassemblyjs/ast" "1.11.1" - "@xtuc/long" "4.2.2" - -"@webpack-cli/configtest@^1.1.1": - version "1.1.1" - resolved "https://registry.yarnpkg.com/@webpack-cli/configtest/-/configtest-1.1.1.tgz#9f53b1b7946a6efc2a749095a4f450e2932e8356" - integrity sha512-1FBc1f9G4P/AxMqIgfZgeOTuRnwZMten8E7zap5zgpPInnCrP8D4Q81+4CWIch8i/Nf7nXjP0v6CjjbHOrXhKg== - -"@webpack-cli/info@^1.4.1": - version "1.4.1" - resolved "https://registry.yarnpkg.com/@webpack-cli/info/-/info-1.4.1.tgz#2360ea1710cbbb97ff156a3f0f24556e0fc1ebea" - integrity sha512-PKVGmazEq3oAo46Q63tpMr4HipI3OPfP7LiNOEJg963RMgT0rqheag28NCML0o3GIzA3DmxP1ZIAv9oTX1CUIA== - dependencies: - envinfo "^7.7.3" - -"@webpack-cli/serve@^1.6.1": - version "1.6.1" - resolved "https://registry.yarnpkg.com/@webpack-cli/serve/-/serve-1.6.1.tgz#0de2875ac31b46b6c5bb1ae0a7d7f0ba5678dffe" - integrity sha512-gNGTiTrjEVQ0OcVnzsRSqTxaBSr+dmTfm+qJsCDluky8uhdLWep7Gcr62QsAKHTMxjCS/8nEITsmFAhfIx+QSw== - -"@xtuc/ieee754@^1.2.0": - version "1.2.0" - resolved "https://registry.yarnpkg.com/@xtuc/ieee754/-/ieee754-1.2.0.tgz#eef014a3145ae477a1cbc00cd1e552336dceb790" - integrity sha512-DX8nKgqcGwsc0eJSqYt5lwP4DH5FlHnmuWWBRy7X0NcaGR0ZtuyeESgMwTYVEtxmsNGY+qit4QYT/MIYTOTPeA== - -"@xtuc/long@4.2.2": - version "4.2.2" - resolved "https://registry.yarnpkg.com/@xtuc/long/-/long-4.2.2.tgz#d291c6a4e97989b5c61d9acf396ae4fe133a718d" - integrity sha512-NuHqBY1PB/D8xU6s/thBgOAiAP7HOYDQ32+BFZILJ8ivkUkAHQnWfn6WhL79Owj1qmUnoN/YPhktdIoucipkAQ== - -accepts@~1.3.4, accepts@~1.3.5, accepts@~1.3.8: - version "1.3.8" - resolved "https://registry.yarnpkg.com/accepts/-/accepts-1.3.8.tgz#0bf0be125b67014adcb0b0921e62db7bffe16b2e" - integrity sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw== - dependencies: - mime-types "~2.1.34" - negotiator "0.6.3" - -acorn-import-assertions@^1.7.6: - version "1.8.0" - resolved "https://registry.yarnpkg.com/acorn-import-assertions/-/acorn-import-assertions-1.8.0.tgz#ba2b5939ce62c238db6d93d81c9b111b29b855e9" - integrity sha512-m7VZ3jwz4eK6A4Vtt8Ew1/mNbP24u0FhdyfA7fSvnJR6LMdfOYnmuIrrJAgrYfYJ10F/otaHTtrtrtmHdMNzEw== - -acorn@^8.5.0, acorn@^8.7.1: - version "8.8.2" - resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.8.2.tgz#1b2f25db02af965399b9776b0c2c391276d37c4a" - integrity sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw== - -aggregate-error@^3.0.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/aggregate-error/-/aggregate-error-3.1.0.tgz#92670ff50f5359bdb7a3e0d40d0ec30c5737687a" - integrity sha512-4I7Td01quW/RpocfNayFdFVk1qSuoh0E7JrbRJ16nH01HhKFQ88INq9Sd+nd72zqRySlr9BmDA8xlEJ6vJMrYA== - dependencies: - clean-stack "^2.0.0" - indent-string "^4.0.0" - -ajv-formats@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/ajv-formats/-/ajv-formats-2.1.1.tgz#6e669400659eb74973bbf2e33327180a0996b520" - integrity sha512-Wx0Kx52hxE7C18hkMEggYlEifqWZtYaRgouJor+WMdPnQyEK13vgEWyVNup7SoeeoLMsr4kf5h6dOW11I15MUA== - dependencies: - ajv "^8.0.0" - -ajv-keywords@^3.5.2: - version "3.5.2" - resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-3.5.2.tgz#31f29da5ab6e00d1c2d329acf7b5929614d5014d" - integrity sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ== - -ajv-keywords@^5.0.0: - version "5.1.0" - resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-5.1.0.tgz#69d4d385a4733cdbeab44964a1170a88f87f0e16" - integrity sha512-YCS/JNFAUyr5vAuhk1DWm1CBxRHW9LbJ2ozWeemrIqpbsqKjHVxYPyi5GC0rjZIT5JxJ3virVTS8wk4i/Z+krw== - dependencies: - fast-deep-equal "^3.1.3" - -ajv@^6.12.4, ajv@^6.12.5: - version "6.12.6" - resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.6.tgz#baf5a62e802b07d977034586f8c3baf5adf26df4" - integrity sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g== - dependencies: - fast-deep-equal "^3.1.1" - fast-json-stable-stringify "^2.0.0" - json-schema-traverse "^0.4.1" - uri-js "^4.2.2" - -ajv@^8.0.0, ajv@^8.8.0: - version "8.10.0" - resolved "https://registry.yarnpkg.com/ajv/-/ajv-8.10.0.tgz#e573f719bd3af069017e3b66538ab968d040e54d" - integrity sha512-bzqAEZOjkrUMl2afH8dknrq5KEk2SrwdBROR+vH1EKVQTqaUbJVPdc/gEdggTMM0Se+s+Ja4ju4TlNcStKl2Hw== - dependencies: - fast-deep-equal "^3.1.1" - json-schema-traverse "^1.0.0" - require-from-string "^2.0.2" - uri-js "^4.2.2" - -ansi-html-community@^0.0.8: - version "0.0.8" - resolved "https://registry.yarnpkg.com/ansi-html-community/-/ansi-html-community-0.0.8.tgz#69fbc4d6ccbe383f9736934ae34c3f8290f1bf41" - integrity sha512-1APHAyr3+PCamwNw3bXCPp4HFLONZt/yIH0sZp0/469KWNTEy+qN5jQ3GVX6DMZ1UXAi34yVwtTeaG/HpBuuzw== - -ansi-regex@^5.0.1: - version "5.0.1" - resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.1.tgz#082cb2c89c9fe8659a311a53bd6a4dc5301db304" - integrity sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ== - -ansi-regex@^6.0.1: - version "6.0.1" - resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-6.0.1.tgz#3183e38fae9a65d7cb5e53945cd5897d0260a06a" - integrity sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA== - -anymatch@~3.1.2: - version "3.1.2" - resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-3.1.2.tgz#c0557c096af32f106198f4f4e2a383537e378716" - integrity sha512-P43ePfOAIupkguHUycrc4qJ9kz8ZiuOUijaETwX7THt0Y/GNK7v0aa8rY816xWjZ7rJdA5XdMcpVFTKMq+RvWg== - dependencies: - normalize-path "^3.0.0" - picomatch "^2.0.4" - -array-flatten@1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/array-flatten/-/array-flatten-1.1.1.tgz#9a5f699051b1e7073328f2a008968b64ea2955d2" - integrity sha1-ml9pkFGx5wczKPKgCJaLZOopVdI= - -array-flatten@^2.1.0: - version "2.1.2" - resolved "https://registry.yarnpkg.com/array-flatten/-/array-flatten-2.1.2.tgz#24ef80a28c1a893617e2149b0c6d0d788293b099" - integrity sha512-hNfzcOV8W4NdualtqBFPyVO+54DSJuZGY9qT4pRroB6S9e3iiido2ISIC5h9R2sPJ8H3FHCIiEnsv1lPXO3KtQ== - -array-union@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/array-union/-/array-union-2.1.0.tgz#b798420adbeb1de828d84acd8a2e23d3efe85e8d" - integrity sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw== - -async@^2.6.2: - version "2.6.4" - resolved "https://registry.yarnpkg.com/async/-/async-2.6.4.tgz#706b7ff6084664cd7eae713f6f965433b5504221" - integrity sha512-mzo5dfJYwAn29PeiJ0zvwTo04zj8HDJj0Mn8TD7sno7q12prdbnasKJHhkm2c1LgrhlJ0teaea8860oxi51mGA== - dependencies: - lodash "^4.17.14" - -balanced-match@^1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee" - integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw== - -batch@0.6.1: - version "0.6.1" - resolved "https://registry.yarnpkg.com/batch/-/batch-0.6.1.tgz#dc34314f4e679318093fc760272525f94bf25c16" - integrity sha1-3DQxT05nkxgJP8dgJyUl+UvyXBY= - -big.js@^5.2.2: - version "5.2.2" - resolved "https://registry.yarnpkg.com/big.js/-/big.js-5.2.2.tgz#65f0af382f578bcdc742bd9c281e9cb2d7768328" - integrity sha512-vyL2OymJxmarO8gxMr0mhChsO9QGwhynfuu4+MHTAW6czfq9humCB7rKpUjDd9YUiDPU4mzpyupFSvOClAwbmQ== - -binary-extensions@^2.0.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.2.0.tgz#75f502eeaf9ffde42fc98829645be4ea76bd9e2d" - integrity sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA== - -body-parser@1.19.2: - version "1.19.2" - resolved "https://registry.yarnpkg.com/body-parser/-/body-parser-1.19.2.tgz#4714ccd9c157d44797b8b5607d72c0b89952f26e" - integrity sha512-SAAwOxgoCKMGs9uUAUFHygfLAyaniaoun6I8mFY9pRAJL9+Kec34aU+oIjDhTycub1jozEfEwx1W1IuOYxVSFw== - dependencies: - bytes "3.1.2" - content-type "~1.0.4" - debug "2.6.9" - depd "~1.1.2" - http-errors "1.8.1" - iconv-lite "0.4.24" - on-finished "~2.3.0" - qs "6.9.7" - raw-body "2.4.3" - type-is "~1.6.18" - -bonjour@^3.5.0: - version "3.5.0" - resolved "https://registry.yarnpkg.com/bonjour/-/bonjour-3.5.0.tgz#8e890a183d8ee9a2393b3844c691a42bcf7bc9f5" - integrity sha1-jokKGD2O6aI5OzhExpGkK897yfU= - dependencies: - array-flatten "^2.1.0" - deep-equal "^1.0.1" - dns-equal "^1.0.0" - dns-txt "^2.0.2" - multicast-dns "^6.0.1" - multicast-dns-service-types "^1.1.0" - -boolbase@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/boolbase/-/boolbase-1.0.0.tgz#68dff5fbe60c51eb37725ea9e3ed310dcc1e776e" - integrity sha1-aN/1++YMUes3cl6p4+0xDcwed24= - -brace-expansion@^1.1.7: - version "1.1.11" - resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" - integrity sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA== - dependencies: - balanced-match "^1.0.0" - concat-map "0.0.1" - -braces@^3.0.1, braces@~3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107" - integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A== - dependencies: - fill-range "^7.0.1" - -browserslist@^4.14.5: - version "4.20.2" - resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.20.2.tgz#567b41508757ecd904dab4d1c646c612cd3d4f88" - integrity sha512-CQOBCqp/9pDvDbx3xfMi+86pr4KXIf2FDkTTdeuYw8OxS9t898LA1Khq57gtufFILXpfgsSx5woNgsBgvGjpsA== - dependencies: - caniuse-lite "^1.0.30001317" - electron-to-chromium "^1.4.84" - escalade "^3.1.1" - node-releases "^2.0.2" - picocolors "^1.0.0" - -buffer-from@^1.0.0: - version "1.1.2" - resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.2.tgz#2b146a6fd72e80b4f55d255f35ed59a3a9a41bd5" - integrity sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ== - -buffer-indexof@^1.0.0: - version "1.1.1" - resolved "https://registry.yarnpkg.com/buffer-indexof/-/buffer-indexof-1.1.1.tgz#52fabcc6a606d1a00302802648ef68f639da268c" - integrity sha512-4/rOEg86jivtPTeOUUT61jJO1Ya1TrR/OkqCSZDyq84WJh3LuuiphBYJN+fm5xufIk4XAFcEwte/8WzC8If/1g== - -bytes@3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/bytes/-/bytes-3.0.0.tgz#d32815404d689699f85a4ea4fa8755dd13a96048" - integrity sha1-0ygVQE1olpn4Wk6k+odV3ROpYEg= - -bytes@3.1.2: - version "3.1.2" - resolved "https://registry.yarnpkg.com/bytes/-/bytes-3.1.2.tgz#8b0beeb98605adf1b128fa4386403c009e0221a5" - integrity sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg== - -call-bind@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/call-bind/-/call-bind-1.0.2.tgz#b1d4e89e688119c3c9a903ad30abb2f6a919be3c" - integrity sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA== - dependencies: - function-bind "^1.1.1" - get-intrinsic "^1.0.2" - -camel-case@^4.1.2: - version "4.1.2" - resolved "https://registry.yarnpkg.com/camel-case/-/camel-case-4.1.2.tgz#9728072a954f805228225a6deea6b38461e1bd5a" - integrity sha512-gxGWBrTT1JuMx6R+o5PTXMmUnhnVzLQ9SNutD4YqKtI6ap897t3tKECYla6gCWEkplXnlNybEkZg9GEGxKFCgw== - dependencies: - pascal-case "^3.1.2" - tslib "^2.0.3" - -caniuse-lite@^1.0.30001317: - version "1.0.30001317" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001317.tgz#0548fb28fd5bc259a70b8c1ffdbe598037666a1b" - integrity sha512-xIZLh8gBm4dqNX0gkzrBeyI86J2eCjWzYAs40q88smG844YIrN4tVQl/RhquHvKEKImWWFIVh1Lxe5n1G/N+GQ== - -chokidar@^3.5.3: - version "3.5.3" - resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.5.3.tgz#1cf37c8707b932bd1af1ae22c0432e2acd1903bd" - integrity sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw== - dependencies: - anymatch "~3.1.2" - braces "~3.0.2" - glob-parent "~5.1.2" - is-binary-path "~2.1.0" - is-glob "~4.0.1" - normalize-path "~3.0.0" - readdirp "~3.6.0" - optionalDependencies: - fsevents "~2.3.2" - -chrome-trace-event@^1.0.2: - version "1.0.3" - resolved "https://registry.yarnpkg.com/chrome-trace-event/-/chrome-trace-event-1.0.3.tgz#1015eced4741e15d06664a957dbbf50d041e26ac" - integrity sha512-p3KULyQg4S7NIHixdwbGX+nFHkoBiA4YQmyWtjb8XngSKV124nJmRysgAeujbUVb15vh+RvFUfCPqU7rXk+hZg== - -clean-css@^5.2.2: - version "5.2.4" - resolved "https://registry.yarnpkg.com/clean-css/-/clean-css-5.2.4.tgz#982b058f8581adb2ae062520808fb2429bd487a4" - integrity sha512-nKseG8wCzEuji/4yrgM/5cthL9oTDc5UOQyFMvW/Q53oP6gLH690o1NbuTh6Y18nujr7BxlsFuS7gXLnLzKJGg== - dependencies: - source-map "~0.6.0" - -clean-stack@^2.0.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/clean-stack/-/clean-stack-2.2.0.tgz#ee8472dbb129e727b31e8a10a427dee9dfe4008b" - integrity sha512-4diC9HaTE+KRAMWhDhrGOECgWZxoevMc5TlkObMqNSsVU62PYzXZ/SMTjzyGAFF1YusgxGcSWTEXBhp0CPwQ1A== - -clone-deep@^4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/clone-deep/-/clone-deep-4.0.1.tgz#c19fd9bdbbf85942b4fd979c84dcf7d5f07c2387" - integrity sha512-neHB9xuzh/wk0dIHweyAXv2aPGZIVk3pLMe+/RNzINf17fe0OG96QroktYAUm7SM1PBnzTabaLboqqxDyMU+SQ== - dependencies: - is-plain-object "^2.0.4" - kind-of "^6.0.2" - shallow-clone "^3.0.0" - -colorette@^2.0.10, colorette@^2.0.14: - version "2.0.16" - resolved "https://registry.yarnpkg.com/colorette/-/colorette-2.0.16.tgz#713b9af84fdb000139f04546bd4a93f62a5085da" - integrity sha512-hUewv7oMjCp+wkBv5Rm0v87eJhq4woh5rSR+42YSQJKecCqgIqNkZ6lAlQms/BwHPJA5NKMRlpxPRv0n8HQW6g== - -commander@^2.20.0: - version "2.20.3" - resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33" - integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ== - -commander@^7.0.0: - version "7.2.0" - resolved "https://registry.yarnpkg.com/commander/-/commander-7.2.0.tgz#a36cb57d0b501ce108e4d20559a150a391d97ab7" - integrity sha512-QrWXB+ZQSVPmIWIhtEO9H+gwHaMGYiF5ChvoJ+K9ZGHG/sVsa6yiesAD1GC/x46sET00Xlwo1u49RVVVzvcSkw== - -commander@^8.3.0: - version "8.3.0" - resolved "https://registry.yarnpkg.com/commander/-/commander-8.3.0.tgz#4837ea1b2da67b9c616a67afbb0fafee567bca66" - integrity sha512-OkTL9umf+He2DZkUq8f8J9of7yL6RJKI24dVITBmNfZBmri9zYZQrKkuXiKhyfPSu8tUhnVBB1iKXevvnlR4Ww== - -compressible@~2.0.16: - version "2.0.18" - resolved "https://registry.yarnpkg.com/compressible/-/compressible-2.0.18.tgz#af53cca6b070d4c3c0750fbd77286a6d7cc46fba" - integrity sha512-AF3r7P5dWxL8MxyITRMlORQNaOA2IkAFaTr4k7BUumjPtRpGDTZpl0Pb1XCO6JeDCBdp126Cgs9sMxqSjgYyRg== - dependencies: - mime-db ">= 1.43.0 < 2" - -compression@^1.7.4: - version "1.7.4" - resolved "https://registry.yarnpkg.com/compression/-/compression-1.7.4.tgz#95523eff170ca57c29a0ca41e6fe131f41e5bb8f" - integrity sha512-jaSIDzP9pZVS4ZfQ+TzvtiWhdpFhE2RDHz8QJkpX9SIpLq88VueF5jJw6t+6CUQcAoA6t+x89MLrWAqpfDE8iQ== - dependencies: - accepts "~1.3.5" - bytes "3.0.0" - compressible "~2.0.16" - debug "2.6.9" - on-headers "~1.0.2" - safe-buffer "5.1.2" - vary "~1.1.2" - -concat-map@0.0.1: - version "0.0.1" - resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" - integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s= - -connect-history-api-fallback@^1.6.0: - version "1.6.0" - resolved "https://registry.yarnpkg.com/connect-history-api-fallback/-/connect-history-api-fallback-1.6.0.tgz#8b32089359308d111115d81cad3fceab888f97bc" - integrity sha512-e54B99q/OUoH64zYYRf3HBP5z24G38h5D3qXu23JGRoigpX5Ss4r9ZnDk3g0Z8uQC2x2lPaJ+UlWBc1ZWBWdLg== - -content-disposition@0.5.4: - version "0.5.4" - resolved "https://registry.yarnpkg.com/content-disposition/-/content-disposition-0.5.4.tgz#8b82b4efac82512a02bb0b1dcec9d2c5e8eb5bfe" - integrity sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ== - dependencies: - safe-buffer "5.2.1" - -content-type@~1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/content-type/-/content-type-1.0.4.tgz#e138cc75e040c727b1966fe5e5f8c9aee256fe3b" - integrity sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA== - -cookie-signature@1.0.6: - version "1.0.6" - resolved "https://registry.yarnpkg.com/cookie-signature/-/cookie-signature-1.0.6.tgz#e303a882b342cc3ee8ca513a79999734dab3ae2c" - integrity sha1-4wOogrNCzD7oylE6eZmXNNqzriw= - -cookie@0.4.2: - version "0.4.2" - resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.4.2.tgz#0e41f24de5ecf317947c82fc789e06a884824432" - integrity sha512-aSWTXFzaKWkvHO1Ny/s+ePFpvKsPnjc551iI41v3ny/ow6tBG5Vd+FuqGNhh1LxOmVzOlGUriIlOaokOvhaStA== - -core-util-is@~1.0.0: - version "1.0.3" - resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.3.tgz#a6042d3634c2b27e9328f837b965fac83808db85" - integrity sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ== - -cross-spawn@^7.0.3: - version "7.0.3" - resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6" - integrity sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w== - dependencies: - path-key "^3.1.0" - shebang-command "^2.0.0" - which "^2.0.1" - -css-select@^4.1.3: - version "4.2.1" - resolved "https://registry.yarnpkg.com/css-select/-/css-select-4.2.1.tgz#9e665d6ae4c7f9d65dbe69d0316e3221fb274cdd" - integrity sha512-/aUslKhzkTNCQUB2qTX84lVmfia9NyjP3WpDGtj/WxhwBzWBYUV3DgUpurHTme8UTPcPlAD1DJ+b0nN/t50zDQ== - dependencies: - boolbase "^1.0.0" - css-what "^5.1.0" - domhandler "^4.3.0" - domutils "^2.8.0" - nth-check "^2.0.1" - -css-what@^5.1.0: - version "5.1.0" - resolved "https://registry.yarnpkg.com/css-what/-/css-what-5.1.0.tgz#3f7b707aadf633baf62c2ceb8579b545bb40f7fe" - integrity sha512-arSMRWIIFY0hV8pIxZMEfmMI47Wj3R/aWpZDDxWYCPEiOMv6tfOrnpDtgxBYPEQD4V0Y/958+1TdC3iWTFcUPw== - -debug@2.6.9: - version "2.6.9" - resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" - integrity sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA== - dependencies: - ms "2.0.0" - -debug@^3.1.1: - version "3.2.7" - resolved "https://registry.yarnpkg.com/debug/-/debug-3.2.7.tgz#72580b7e9145fb39b6676f9c5e5fb100b934179a" - integrity sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ== - dependencies: - ms "^2.1.1" - -debug@^4.1.0: - version "4.3.3" - resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.3.tgz#04266e0b70a98d4462e6e288e38259213332b664" - integrity sha512-/zxw5+vh1Tfv+4Qn7a5nsbcJKPaSvCDhojn6FEl9vupwK2VCSDtEiEtqr8DFtzYFOdz63LBkxec7DYuc2jon6Q== - dependencies: - ms "2.1.2" - -deep-equal@^1.0.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/deep-equal/-/deep-equal-1.1.1.tgz#b5c98c942ceffaf7cb051e24e1434a25a2e6076a" - integrity sha512-yd9c5AdiqVcR+JjcwUQb9DkhJc8ngNr0MahEBGvDiJw8puWab2yZlh+nkasOnZP+EGTAP6rRp2JzJhJZzvNF8g== - dependencies: - is-arguments "^1.0.4" - is-date-object "^1.0.1" - is-regex "^1.0.4" - object-is "^1.0.1" - object-keys "^1.1.1" - regexp.prototype.flags "^1.2.0" - -default-gateway@^6.0.3: - version "6.0.3" - resolved "https://registry.yarnpkg.com/default-gateway/-/default-gateway-6.0.3.tgz#819494c888053bdb743edbf343d6cdf7f2943a71" - integrity sha512-fwSOJsbbNzZ/CUFpqFBqYfYNLj1NbMPm8MMCIzHjC83iSJRBEGmDUxU+WP661BaBQImeC2yHwXtz+P/O9o+XEg== - dependencies: - execa "^5.0.0" - -define-lazy-prop@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/define-lazy-prop/-/define-lazy-prop-2.0.0.tgz#3f7ae421129bcaaac9bc74905c98a0009ec9ee7f" - integrity sha512-Ds09qNh8yw3khSjiJjiUInaGX9xlqZDY7JVryGxdxV7NPeuqQfplOpQ66yJFZut3jLa5zOwkXw1g9EI2uKh4Og== - -define-properties@^1.1.3: - version "1.1.3" - resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.1.3.tgz#cf88da6cbee26fe6db7094f61d870cbd84cee9f1" - integrity sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ== - dependencies: - object-keys "^1.0.12" - -del@^6.0.0: - version "6.0.0" - resolved "https://registry.yarnpkg.com/del/-/del-6.0.0.tgz#0b40d0332cea743f1614f818be4feb717714c952" - integrity sha512-1shh9DQ23L16oXSZKB2JxpL7iMy2E0S9d517ptA1P8iw0alkPtQcrKH7ru31rYtKwF499HkTu+DRzq3TCKDFRQ== - dependencies: - globby "^11.0.1" - graceful-fs "^4.2.4" - is-glob "^4.0.1" - is-path-cwd "^2.2.0" - is-path-inside "^3.0.2" - p-map "^4.0.0" - rimraf "^3.0.2" - slash "^3.0.0" - -depd@~1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/depd/-/depd-1.1.2.tgz#9bcd52e14c097763e749b274c4346ed2e560b5a9" - integrity sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak= - -destroy@~1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/destroy/-/destroy-1.0.4.tgz#978857442c44749e4206613e37946205826abd80" - integrity sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA= - -detect-node@^2.0.4: - version "2.1.0" - resolved "https://registry.yarnpkg.com/detect-node/-/detect-node-2.1.0.tgz#c9c70775a49c3d03bc2c06d9a73be550f978f8b1" - integrity sha512-T0NIuQpnTvFDATNuHN5roPwSBG83rFsuO+MXXH9/3N1eFbn4wcPjttvjMLEPWJ0RGUYgQE7cGgS3tNxbqCGM7g== - -dir-glob@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/dir-glob/-/dir-glob-3.0.1.tgz#56dbf73d992a4a93ba1584f4534063fd2e41717f" - integrity sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA== - dependencies: - path-type "^4.0.0" - -dns-equal@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/dns-equal/-/dns-equal-1.0.0.tgz#b39e7f1da6eb0a75ba9c17324b34753c47e0654d" - integrity sha1-s55/HabrCnW6nBcySzR1PEfgZU0= - -dns-packet@^1.3.1: - version "1.3.4" - resolved "https://registry.yarnpkg.com/dns-packet/-/dns-packet-1.3.4.tgz#e3455065824a2507ba886c55a89963bb107dec6f" - integrity sha512-BQ6F4vycLXBvdrJZ6S3gZewt6rcrks9KBgM9vrhW+knGRqc8uEdT7fuCwloc7nny5xNoMJ17HGH0R/6fpo8ECA== - dependencies: - ip "^1.1.0" - safe-buffer "^5.0.1" - -dns-txt@^2.0.2: - version "2.0.2" - resolved "https://registry.yarnpkg.com/dns-txt/-/dns-txt-2.0.2.tgz#b91d806f5d27188e4ab3e7d107d881a1cc4642b6" - integrity sha1-uR2Ab10nGI5Ks+fRB9iBocxGQrY= - dependencies: - buffer-indexof "^1.0.0" - -dom-converter@^0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/dom-converter/-/dom-converter-0.2.0.tgz#6721a9daee2e293682955b6afe416771627bb768" - integrity "sha1-ZyGp2u4uKTaClVtq/kFncWJ7t2g= sha512-gd3ypIPfOMr9h5jIKq8E3sHOTCjeirnl0WK5ZdS1AW0Odt0b1PaWaHdJ4Qk4klv+YB9aJBS7mESXjFoDQPu6DA==" - dependencies: - utila "~0.4" - -dom-serializer@^1.0.1: - version "1.3.2" - resolved "https://registry.yarnpkg.com/dom-serializer/-/dom-serializer-1.3.2.tgz#6206437d32ceefaec7161803230c7a20bc1b4d91" - integrity sha512-5c54Bk5Dw4qAxNOI1pFEizPSjVsx5+bpJKmL2kPn8JhBUq2q09tTCa3mjijun2NfK78NMouDYNMBkOrPZiS+ig== - dependencies: - domelementtype "^2.0.1" - domhandler "^4.2.0" - entities "^2.0.0" - -domelementtype@^2.0.1, domelementtype@^2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/domelementtype/-/domelementtype-2.2.0.tgz#9a0b6c2782ed6a1c7323d42267183df9bd8b1d57" - integrity sha512-DtBMo82pv1dFtUmHyr48beiuq792Sxohr+8Hm9zoxklYPfa6n0Z3Byjj2IV7bmr2IyqClnqEQhfgHJJ5QF0R5A== - -domhandler@^4.0.0, domhandler@^4.2.0, domhandler@^4.3.0: - version "4.3.0" - resolved "https://registry.yarnpkg.com/domhandler/-/domhandler-4.3.0.tgz#16c658c626cf966967e306f966b431f77d4a5626" - integrity sha512-fC0aXNQXqKSFTr2wDNZDhsEYjCiYsDWl3D01kwt25hm1YIPyDGHvvi3rw+PLqHAl/m71MaiF7d5zvBr0p5UB2g== - dependencies: - domelementtype "^2.2.0" - -domutils@^2.5.2, domutils@^2.8.0: - version "2.8.0" - resolved "https://registry.yarnpkg.com/domutils/-/domutils-2.8.0.tgz#4437def5db6e2d1f5d6ee859bd95ca7d02048135" - integrity sha512-w96Cjofp72M5IIhpjgobBimYEfoPjx1Vx0BSX9P30WBdZW2WIKU0T1Bd0kz2eNZ9ikjKgHbEyKx8BB6H1L3h3A== - dependencies: - dom-serializer "^1.0.1" - domelementtype "^2.2.0" - domhandler "^4.2.0" - -dot-case@^3.0.4: - version "3.0.4" - resolved "https://registry.yarnpkg.com/dot-case/-/dot-case-3.0.4.tgz#9b2b670d00a431667a8a75ba29cd1b98809ce751" - integrity sha512-Kv5nKlh6yRrdrGvxeJ2e5y2eRUpkUosIW4A2AS38zwSz27zu7ufDwQPi5Jhs3XAlGNetl3bmnGhQsMtkKJnj3w== - dependencies: - no-case "^3.0.4" - tslib "^2.0.3" - -ee-first@1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d" - integrity sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0= - -electron-to-chromium@^1.4.84: - version "1.4.85" - resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.85.tgz#a3666ba42147026b9f34d4d8d4caf0740e80f751" - integrity sha512-K9AsQ41WS2bjZUFpRWfvaS4RjEcRCamEkBJN1Z1TQILBfP1H8QnJ9ti0wiLiMv0sRjX3EHKzgs9jDnmGFx2jXg== - -emojis-list@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/emojis-list/-/emojis-list-3.0.0.tgz#5570662046ad29e2e916e71aae260abdff4f6a78" - integrity sha512-/kyM18EfinwXZbno9FyUGeFh87KC8HRQBQGildHZbEuRyWFOmv1U10o9BBp8XVZDVNNuQKyIGIu5ZYAAXJ0V2Q== - -encodeurl@~1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/encodeurl/-/encodeurl-1.0.2.tgz#ad3ff4c86ec2d029322f5a02c3a9a606c95b3f59" - integrity sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k= - -enhanced-resolve@^5.10.0: - version "5.12.0" - resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-5.12.0.tgz#300e1c90228f5b570c4d35babf263f6da7155634" - integrity sha512-QHTXI/sZQmko1cbDoNAa3mJ5qhWUUNAq3vR0/YiD379fWQrcfuoX1+HW2S0MTt7XmoPLapdaDKUtelUSPic7hQ== - dependencies: - graceful-fs "^4.2.4" - tapable "^2.2.0" - -entities@^2.0.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/entities/-/entities-2.2.0.tgz#098dc90ebb83d8dffa089d55256b351d34c4da55" - integrity sha512-p92if5Nz619I0w+akJrLZH0MX0Pb5DX39XOwQTtXSdQQOaYH03S1uIQp4mhOZtAXrxq4ViO67YTiLBo2638o9A== - -envinfo@^7.7.3: - version "7.8.1" - resolved "https://registry.yarnpkg.com/envinfo/-/envinfo-7.8.1.tgz#06377e3e5f4d379fea7ac592d5ad8927e0c4d475" - integrity sha512-/o+BXHmB7ocbHEAs6F2EnG0ogybVVUdkRunTT2glZU9XAaGmhqskrvKwqXuDfNjEO0LZKWdejEEpnq8aM0tOaw== - -es-module-lexer@^0.9.0: - version "0.9.3" - resolved "https://registry.yarnpkg.com/es-module-lexer/-/es-module-lexer-0.9.3.tgz#6f13db00cc38417137daf74366f535c8eb438f19" - integrity sha512-1HQ2M2sPtxwnvOvT1ZClHyQDiggdNjURWpY2we6aMKCQiUVxTmVs2UYPLIrD84sS+kMdUwfBSylbJPwNnBrnHQ== - -escalade@^3.1.1: - version "3.1.1" - resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.1.1.tgz#d8cfdc7000965c5a0174b4a82eaa5c0552742e40" - integrity sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw== - -escape-html@~1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/escape-html/-/escape-html-1.0.3.tgz#0258eae4d3d0c0974de1c169188ef0051d1d1988" - integrity sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg= - -eslint-scope@5.1.1: - version "5.1.1" - resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-5.1.1.tgz#e786e59a66cb92b3f6c1fb0d508aab174848f48c" - integrity sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw== - dependencies: - esrecurse "^4.3.0" - estraverse "^4.1.1" - -esrecurse@^4.3.0: - version "4.3.0" - resolved "https://registry.yarnpkg.com/esrecurse/-/esrecurse-4.3.0.tgz#7ad7964d679abb28bee72cec63758b1c5d2c9921" - integrity sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag== - dependencies: - estraverse "^5.2.0" - -estraverse@^4.1.1: - version "4.3.0" - resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-4.3.0.tgz#398ad3f3c5a24948be7725e83d11a7de28cdbd1d" - integrity sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw== - -estraverse@^5.2.0: - version "5.3.0" - resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-5.3.0.tgz#2eea5290702f26ab8fe5370370ff86c965d21123" - integrity sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA== - -etag@~1.8.1: - version "1.8.1" - resolved "https://registry.yarnpkg.com/etag/-/etag-1.8.1.tgz#41ae2eeb65efa62268aebfea83ac7d79299b0887" - integrity sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc= - -eventemitter3@^4.0.0: - version "4.0.7" - resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-4.0.7.tgz#2de9b68f6528d5644ef5c59526a1b4a07306169f" - integrity sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw== - -events@^3.2.0: - version "3.3.0" - resolved "https://registry.yarnpkg.com/events/-/events-3.3.0.tgz#31a95ad0a924e2d2c419a813aeb2c4e878ea7400" - integrity sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q== - -execa@^5.0.0: - version "5.1.1" - resolved "https://registry.yarnpkg.com/execa/-/execa-5.1.1.tgz#f80ad9cbf4298f7bd1d4c9555c21e93741c411dd" - integrity sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg== - dependencies: - cross-spawn "^7.0.3" - get-stream "^6.0.0" - human-signals "^2.1.0" - is-stream "^2.0.0" - merge-stream "^2.0.0" - npm-run-path "^4.0.1" - onetime "^5.1.2" - signal-exit "^3.0.3" - strip-final-newline "^2.0.0" - -express@^4.17.1: - version "4.17.3" - resolved "https://registry.yarnpkg.com/express/-/express-4.17.3.tgz#f6c7302194a4fb54271b73a1fe7a06478c8f85a1" - integrity sha512-yuSQpz5I+Ch7gFrPCk4/c+dIBKlQUxtgwqzph132bsT6qhuzss6I8cLJQz7B3rFblzd6wtcI0ZbGltH/C4LjUg== - dependencies: - accepts "~1.3.8" - array-flatten "1.1.1" - body-parser "1.19.2" - content-disposition "0.5.4" - content-type "~1.0.4" - cookie "0.4.2" - cookie-signature "1.0.6" - debug "2.6.9" - depd "~1.1.2" - encodeurl "~1.0.2" - escape-html "~1.0.3" - etag "~1.8.1" - finalhandler "~1.1.2" - fresh "0.5.2" - merge-descriptors "1.0.1" - methods "~1.1.2" - on-finished "~2.3.0" - parseurl "~1.3.3" - path-to-regexp "0.1.7" - proxy-addr "~2.0.7" - qs "6.9.7" - range-parser "~1.2.1" - safe-buffer "5.2.1" - send "0.17.2" - serve-static "1.14.2" - setprototypeof "1.2.0" - statuses "~1.5.0" - type-is "~1.6.18" - utils-merge "1.0.1" - vary "~1.1.2" - -fast-deep-equal@^3.1.1, fast-deep-equal@^3.1.3: - version "3.1.3" - resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525" - integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q== - -fast-glob@^3.2.9: - version "3.2.11" - resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.2.11.tgz#a1172ad95ceb8a16e20caa5c5e56480e5129c1d9" - integrity sha512-xrO3+1bxSo3ZVHAnqzyuewYT6aMFHRAd4Kcs92MAonjwQZLsK9d0SF1IyQ3k5PoirxTW0Oe/RqFgMQ6TcNE5Ew== - dependencies: - "@nodelib/fs.stat" "^2.0.2" - "@nodelib/fs.walk" "^1.2.3" - glob-parent "^5.1.2" - merge2 "^1.3.0" - micromatch "^4.0.4" - -fast-json-stable-stringify@^2.0.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz#874bf69c6f404c2b5d99c481341399fd55892633" - integrity sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw== - -fastest-levenshtein@^1.0.12: - version "1.0.12" - resolved "https://registry.yarnpkg.com/fastest-levenshtein/-/fastest-levenshtein-1.0.12.tgz#9990f7d3a88cc5a9ffd1f1745745251700d497e2" - integrity sha512-On2N+BpYJ15xIC974QNVuYGMOlEVt4s0EOI3wwMqOmK1fdDY+FN/zltPV8vosq4ad4c/gJ1KHScUn/6AWIgiow== - -fastq@^1.6.0: - version "1.13.0" - resolved "https://registry.yarnpkg.com/fastq/-/fastq-1.13.0.tgz#616760f88a7526bdfc596b7cab8c18938c36b98c" - integrity sha512-YpkpUnK8od0o1hmeSc7UUs/eB/vIPWJYjKck2QKIzAf71Vm1AAQ3EbuZB3g2JIy+pg+ERD0vqI79KyZiB2e2Nw== - dependencies: - reusify "^1.0.4" - -faye-websocket@^0.11.3: - version "0.11.4" - resolved "https://registry.yarnpkg.com/faye-websocket/-/faye-websocket-0.11.4.tgz#7f0d9275cfdd86a1c963dc8b65fcc451edcbb1da" - integrity sha512-CzbClwlXAuiRQAlUyfqPgvPoNKTckTPGfwZV4ZdAhVcP2lh9KUxJg2b5GkE7XbjKQ3YJnQ9z6D9ntLAlB+tP8g== - dependencies: - websocket-driver ">=0.5.1" - -file-loader@^5.0.2: - version "5.1.0" - resolved "https://registry.yarnpkg.com/file-loader/-/file-loader-5.1.0.tgz#cb56c070efc0e40666424309bd0d9e45ac6f2bb8" - integrity sha512-u/VkLGskw3Ue59nyOwUwXI/6nuBCo7KBkniB/l7ICwr/7cPNGsL1WCXUp3GB0qgOOKU1TiP49bv4DZF/LJqprg== - dependencies: - loader-utils "^1.4.0" - schema-utils "^2.5.0" - -fill-range@^7.0.1: - version "7.0.1" - resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.0.1.tgz#1919a6a7c75fe38b2c7c77e5198535da9acdda40" - integrity sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ== - dependencies: - to-regex-range "^5.0.1" - -finalhandler@~1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/finalhandler/-/finalhandler-1.1.2.tgz#b7e7d000ffd11938d0fdb053506f6ebabe9f587d" - integrity sha512-aAWcW57uxVNrQZqFXjITpW3sIUQmHGG3qSb9mUah9MgMC4NeWhNOlNjXEYq3HjRAvL6arUviZGGJsBg6z0zsWA== - dependencies: - debug "2.6.9" - encodeurl "~1.0.2" - escape-html "~1.0.3" - on-finished "~2.3.0" - parseurl "~1.3.3" - statuses "~1.5.0" - unpipe "~1.0.0" - -find-up@^4.0.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/find-up/-/find-up-4.1.0.tgz#97afe7d6cdc0bc5928584b7c8d7b16e8a9aa5d19" - integrity sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw== - dependencies: - locate-path "^5.0.0" - path-exists "^4.0.0" - -follow-redirects@^1.0.0: - version "1.14.9" - resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.9.tgz#dd4ea157de7bfaf9ea9b3fbd85aa16951f78d8d7" - integrity sha512-MQDfihBQYMcyy5dhRDJUHcw7lb2Pv/TuE6xP1vyraLukNDHKbDxDNaOE3NbCAdKQApno+GPRyo1YAp89yCjK4w== - -forwarded@0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/forwarded/-/forwarded-0.2.0.tgz#2269936428aad4c15c7ebe9779a84bf0b2a81811" - integrity sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow== - -fresh@0.5.2: - version "0.5.2" - resolved "https://registry.yarnpkg.com/fresh/-/fresh-0.5.2.tgz#3d8cadd90d976569fa835ab1f8e4b23a105605a7" - integrity sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac= - -fs-monkey@1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/fs-monkey/-/fs-monkey-1.0.3.tgz#ae3ac92d53bb328efe0e9a1d9541f6ad8d48e2d3" - integrity sha512-cybjIfiiE+pTWicSCLFHSrXZ6EilF30oh91FDP9S2B051prEa7QWfrVTQm10/dDpswBDXZugPa1Ogu8Yh+HV0Q== - -fs.realpath@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" - integrity sha1-FQStJSMVjKpA20onh8sBQRmU6k8= - -fsevents@~2.3.2: - version "2.3.2" - resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a" - integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA== - -function-bind@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d" - integrity sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A== - -get-intrinsic@^1.0.2: - version "1.1.1" - resolved "https://registry.yarnpkg.com/get-intrinsic/-/get-intrinsic-1.1.1.tgz#15f59f376f855c446963948f0d24cd3637b4abc6" - integrity sha512-kWZrnVM42QCiEA2Ig1bG8zjoIMOgxWwYCEeNdwY6Tv/cOSeGpcoX4pXHfKUxNKVoArnrEr2e9srnAxxGIraS9Q== - dependencies: - function-bind "^1.1.1" - has "^1.0.3" - has-symbols "^1.0.1" - -get-stream@^6.0.0: - version "6.0.1" - resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-6.0.1.tgz#a262d8eef67aced57c2852ad6167526a43cbf7b7" - integrity sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg== - -glob-parent@^5.1.2, glob-parent@~5.1.2: - version "5.1.2" - resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4" - integrity sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow== - dependencies: - is-glob "^4.0.1" - -glob-to-regexp@^0.4.1: - version "0.4.1" - resolved "https://registry.yarnpkg.com/glob-to-regexp/-/glob-to-regexp-0.4.1.tgz#c75297087c851b9a578bd217dd59a92f59fe546e" - integrity sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw== - -glob@^7.1.3: - version "7.2.0" - resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.0.tgz#d15535af7732e02e948f4c41628bd910293f6023" - integrity sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q== - dependencies: - fs.realpath "^1.0.0" - inflight "^1.0.4" - inherits "2" - minimatch "^3.0.4" - once "^1.3.0" - path-is-absolute "^1.0.0" - -globby@^11.0.1: - version "11.1.0" - resolved "https://registry.yarnpkg.com/globby/-/globby-11.1.0.tgz#bd4be98bb042f83d796f7e3811991fbe82a0d34b" - integrity sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g== - dependencies: - array-union "^2.1.0" - dir-glob "^3.0.1" - fast-glob "^3.2.9" - ignore "^5.2.0" - merge2 "^1.4.1" - slash "^3.0.0" - -graceful-fs@^4.1.2, graceful-fs@^4.2.4, graceful-fs@^4.2.6, graceful-fs@^4.2.9: - version "4.2.9" - resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.9.tgz#041b05df45755e587a24942279b9d113146e1c96" - integrity sha512-NtNxqUcXgpW2iMrfqSfR73Glt39K+BLwWsPs94yR63v45T0Wbej7eRmL5cWfwEgqXnmjQp3zaJTshdRW/qC2ZQ== - -handle-thing@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/handle-thing/-/handle-thing-2.0.1.tgz#857f79ce359580c340d43081cc648970d0bb234e" - integrity sha512-9Qn4yBxelxoh2Ow62nP+Ka/kMnOXRi8BXnRaUwezLNhqelnN49xKz4F/dPP8OYLxLxq6JDtZb2i9XznUQbNPTg== - -has-flag@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b" - integrity sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ== - -has-symbols@^1.0.1, has-symbols@^1.0.2: - version "1.0.3" - resolved "https://registry.yarnpkg.com/has-symbols/-/has-symbols-1.0.3.tgz#bb7b2c4349251dce87b125f7bdf874aa7c8b39f8" - integrity sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A== - -has-tostringtag@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/has-tostringtag/-/has-tostringtag-1.0.0.tgz#7e133818a7d394734f941e73c3d3f9291e658b25" - integrity sha512-kFjcSNhnlGV1kyoGk7OXKSawH5JOb/LzUc5w9B02hOTO0dfFRjbHQKvg1d6cf3HbeUmtU9VbbV3qzZ2Teh97WQ== - dependencies: - has-symbols "^1.0.2" - -has@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/has/-/has-1.0.3.tgz#722d7cbfc1f6aa8241f16dd814e011e1f41e8796" - integrity sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw== - dependencies: - function-bind "^1.1.1" - -he@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/he/-/he-1.2.0.tgz#84ae65fa7eafb165fddb61566ae14baf05664f0f" - integrity sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw== - -hpack.js@^2.1.6: - version "2.1.6" - resolved "https://registry.yarnpkg.com/hpack.js/-/hpack.js-2.1.6.tgz#87774c0949e513f42e84575b3c45681fade2a0b2" - integrity sha1-h3dMCUnlE/QuhFdbPEVoH63ioLI= - dependencies: - inherits "^2.0.1" - obuf "^1.0.0" - readable-stream "^2.0.1" - wbuf "^1.1.0" - -html-entities@^2.3.2: - version "2.3.2" - resolved "https://registry.yarnpkg.com/html-entities/-/html-entities-2.3.2.tgz#760b404685cb1d794e4f4b744332e3b00dcfe488" - integrity sha512-c3Ab/url5ksaT0WyleslpBEthOzWhrjQbg75y7XUsfSzi3Dgzt0l8w5e7DylRn15MTlMMD58dTfzddNS2kcAjQ== - -html-minifier-terser@^6.0.2: - version "6.1.0" - resolved "https://registry.yarnpkg.com/html-minifier-terser/-/html-minifier-terser-6.1.0.tgz#bfc818934cc07918f6b3669f5774ecdfd48f32ab" - integrity sha512-YXxSlJBZTP7RS3tWnQw74ooKa6L9b9i9QYXY21eUEvhZ3u9XLfv6OnFsQq6RxkhHygsaUMvYsZRV5rU/OVNZxw== - dependencies: - camel-case "^4.1.2" - clean-css "^5.2.2" - commander "^8.3.0" - he "^1.2.0" - param-case "^3.0.4" - relateurl "^0.2.7" - terser "^5.10.0" - -html-webpack-plugin@^5.5.0: - version "5.5.0" - resolved "https://registry.yarnpkg.com/html-webpack-plugin/-/html-webpack-plugin-5.5.0.tgz#c3911936f57681c1f9f4d8b68c158cd9dfe52f50" - integrity sha512-sy88PC2cRTVxvETRgUHFrL4No3UxvcH8G1NepGhqaTT+GXN2kTamqasot0inS5hXeg1cMbFDt27zzo9p35lZVw== - dependencies: - "@types/html-minifier-terser" "^6.0.0" - html-minifier-terser "^6.0.2" - lodash "^4.17.21" - pretty-error "^4.0.0" - tapable "^2.0.0" - -htmlparser2@^6.1.0: - version "6.1.0" - resolved "https://registry.yarnpkg.com/htmlparser2/-/htmlparser2-6.1.0.tgz#c4d762b6c3371a05dbe65e94ae43a9f845fb8fb7" - integrity sha512-gyyPk6rgonLFEDGoeRgQNaEUvdJ4ktTmmUh/h2t7s+M8oPpIPxgNACWa+6ESR57kXstwqPiCut0V8NRpcwgU7A== - dependencies: - domelementtype "^2.0.1" - domhandler "^4.0.0" - domutils "^2.5.2" - entities "^2.0.0" - -http-deceiver@^1.2.7: - version "1.2.7" - resolved "https://registry.yarnpkg.com/http-deceiver/-/http-deceiver-1.2.7.tgz#fa7168944ab9a519d337cb0bec7284dc3e723d87" - integrity sha1-+nFolEq5pRnTN8sL7HKE3D5yPYc= - -http-errors@1.8.1: - version "1.8.1" - resolved "https://registry.yarnpkg.com/http-errors/-/http-errors-1.8.1.tgz#7c3f28577cbc8a207388455dbd62295ed07bd68c" - integrity sha512-Kpk9Sm7NmI+RHhnj6OIWDI1d6fIoFAtFt9RLaTMRlg/8w49juAStsrBgp0Dp4OdxdVbRIeKhtCUvoi/RuAhO4g== - dependencies: - depd "~1.1.2" - inherits "2.0.4" - setprototypeof "1.2.0" - statuses ">= 1.5.0 < 2" - toidentifier "1.0.1" - -http-errors@~1.6.2: - version "1.6.3" - resolved "https://registry.yarnpkg.com/http-errors/-/http-errors-1.6.3.tgz#8b55680bb4be283a0b5bf4ea2e38580be1d9320d" - integrity sha1-i1VoC7S+KDoLW/TqLjhYC+HZMg0= - dependencies: - depd "~1.1.2" - inherits "2.0.3" - setprototypeof "1.1.0" - statuses ">= 1.4.0 < 2" - -http-parser-js@>=0.5.1: - version "0.5.6" - resolved "https://registry.yarnpkg.com/http-parser-js/-/http-parser-js-0.5.6.tgz#2e02406ab2df8af8a7abfba62e0da01c62b95afd" - integrity sha512-vDlkRPDJn93swjcjqMSaGSPABbIarsr1TLAui/gLDXzV5VsJNdXNzMYDyNBLQkjWQCJ1uizu8T2oDMhmGt0PRA== - -http-proxy-middleware@^2.0.0: - version "2.0.4" - resolved "https://registry.yarnpkg.com/http-proxy-middleware/-/http-proxy-middleware-2.0.4.tgz#03af0f4676d172ae775cb5c33f592f40e1a4e07a" - integrity sha512-m/4FxX17SUvz4lJ5WPXOHDUuCwIqXLfLHs1s0uZ3oYjhoXlx9csYxaOa0ElDEJ+h8Q4iJ1s+lTMbiCa4EXIJqg== - dependencies: - "@types/http-proxy" "^1.17.8" - http-proxy "^1.18.1" - is-glob "^4.0.1" - is-plain-obj "^3.0.0" - micromatch "^4.0.2" - -http-proxy@^1.18.1: - version "1.18.1" - resolved "https://registry.yarnpkg.com/http-proxy/-/http-proxy-1.18.1.tgz#401541f0534884bbf95260334e72f88ee3976549" - integrity sha512-7mz/721AbnJwIVbnaSv1Cz3Am0ZLT/UBwkC92VlxhXv/k/BBQfM2fXElQNC27BVGr0uwUpplYPQM9LnaBMR5NQ== - dependencies: - eventemitter3 "^4.0.0" - follow-redirects "^1.0.0" - requires-port "^1.0.0" - -human-signals@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-2.1.0.tgz#dc91fcba42e4d06e4abaed33b3e7a3c02f514ea0" - integrity sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw== - -iconv-lite@0.4.24: - version "0.4.24" - resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.24.tgz#2022b4b25fbddc21d2f524974a474aafe733908b" - integrity sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA== - dependencies: - safer-buffer ">= 2.1.2 < 3" - -ignore@^5.2.0: - version "5.2.0" - resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.2.0.tgz#6d3bac8fa7fe0d45d9f9be7bac2fc279577e345a" - integrity sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ== - -import-local@^3.0.2: - version "3.1.0" - resolved "https://registry.yarnpkg.com/import-local/-/import-local-3.1.0.tgz#b4479df8a5fd44f6cdce24070675676063c95cb4" - integrity sha512-ASB07uLtnDs1o6EHjKpX34BKYDSqnFerfTOJL2HvMqF70LnxpjkzDB8J44oT9pu4AMPkQwf8jl6szgvNd2tRIg== - dependencies: - pkg-dir "^4.2.0" - resolve-cwd "^3.0.0" - -indent-string@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/indent-string/-/indent-string-4.0.0.tgz#624f8f4497d619b2d9768531d58f4122854d7251" - integrity sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg== - -inflight@^1.0.4: - version "1.0.6" - resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" - integrity sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk= - dependencies: - once "^1.3.0" - wrappy "1" - -inherits@2, inherits@2.0.4, inherits@^2.0.1, inherits@^2.0.3, inherits@~2.0.3: - version "2.0.4" - resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" - integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== - -inherits@2.0.3: - version "2.0.3" - resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" - integrity sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4= - -interpret@^2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/interpret/-/interpret-2.2.0.tgz#1a78a0b5965c40a5416d007ad6f50ad27c417df9" - integrity sha512-Ju0Bz/cEia55xDwUWEa8+olFpCiQoypjnQySseKtmjNrnps3P+xfpUmGr90T7yjlVJmOtybRvPXhKMbHr+fWnw== - -ip@^1.1.0: - version "1.1.5" - resolved "https://registry.yarnpkg.com/ip/-/ip-1.1.5.tgz#bdded70114290828c0a039e72ef25f5aaec4354a" - integrity sha1-vd7XARQpCCjAoDnnLvJfWq7ENUo= - -ipaddr.js@1.9.1: - version "1.9.1" - resolved "https://registry.yarnpkg.com/ipaddr.js/-/ipaddr.js-1.9.1.tgz#bff38543eeb8984825079ff3a2a8e6cbd46781b3" - integrity sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g== - -ipaddr.js@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/ipaddr.js/-/ipaddr.js-2.0.1.tgz#eca256a7a877e917aeb368b0a7497ddf42ef81c0" - integrity sha512-1qTgH9NG+IIJ4yfKs2e6Pp1bZg8wbDbKHT21HrLIeYBTRLgMYKnMTPAuI3Lcs61nfx5h1xlXnbJtH1kX5/d/ng== - -is-arguments@^1.0.4: - version "1.1.1" - resolved "https://registry.yarnpkg.com/is-arguments/-/is-arguments-1.1.1.tgz#15b3f88fda01f2a97fec84ca761a560f123efa9b" - integrity sha512-8Q7EARjzEnKpt/PCD7e1cgUS0a6X8u5tdSiMqXhojOdoV9TsMsiO+9VLC5vAmO8N7/GmXn7yjR8qnA6bVAEzfA== - dependencies: - call-bind "^1.0.2" - has-tostringtag "^1.0.0" - -is-binary-path@~2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/is-binary-path/-/is-binary-path-2.1.0.tgz#ea1f7f3b80f064236e83470f86c09c254fb45b09" - integrity sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw== - dependencies: - binary-extensions "^2.0.0" - -is-core-module@^2.8.1: - version "2.8.1" - resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.8.1.tgz#f59fdfca701d5879d0a6b100a40aa1560ce27211" - integrity sha512-SdNCUs284hr40hFTFP6l0IfZ/RSrMXF3qgoRHd3/79unUTvrFO/JoXwkGm+5J/Oe3E/b5GsnG330uUNgRpu1PA== - dependencies: - has "^1.0.3" - -is-date-object@^1.0.1: - version "1.0.5" - resolved "https://registry.yarnpkg.com/is-date-object/-/is-date-object-1.0.5.tgz#0841d5536e724c25597bf6ea62e1bd38298df31f" - integrity sha512-9YQaSxsAiSwcvS33MBk3wTCVnWK+HhF8VZR2jRxehM16QcVOdHqPn4VPHmRK4lSr38n9JriurInLcP90xsYNfQ== - dependencies: - has-tostringtag "^1.0.0" - -is-docker@^2.0.0, is-docker@^2.1.1: - version "2.2.1" - resolved "https://registry.yarnpkg.com/is-docker/-/is-docker-2.2.1.tgz#33eeabe23cfe86f14bde4408a02c0cfb853acdaa" - integrity sha512-F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ== - -is-extglob@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2" - integrity sha1-qIwCU1eR8C7TfHahueqXc8gz+MI= - -is-glob@^4.0.1, is-glob@~4.0.1: - version "4.0.3" - resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.3.tgz#64f61e42cbbb2eec2071a9dac0b28ba1e65d5084" - integrity sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg== - dependencies: - is-extglob "^2.1.1" - -is-number@^7.0.0: - version "7.0.0" - resolved "https://registry.yarnpkg.com/is-number/-/is-number-7.0.0.tgz#7535345b896734d5f80c4d06c50955527a14f12b" - integrity sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng== - -is-path-cwd@^2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/is-path-cwd/-/is-path-cwd-2.2.0.tgz#67d43b82664a7b5191fd9119127eb300048a9fdb" - integrity sha512-w942bTcih8fdJPJmQHFzkS76NEP8Kzzvmw92cXsazb8intwLqPibPPdXf4ANdKV3rYMuuQYGIWtvz9JilB3NFQ== - -is-path-inside@^3.0.2: - version "3.0.3" - resolved "https://registry.yarnpkg.com/is-path-inside/-/is-path-inside-3.0.3.tgz#d231362e53a07ff2b0e0ea7fed049161ffd16283" - integrity sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ== - -is-plain-obj@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/is-plain-obj/-/is-plain-obj-3.0.0.tgz#af6f2ea14ac5a646183a5bbdb5baabbc156ad9d7" - integrity sha512-gwsOE28k+23GP1B6vFl1oVh/WOzmawBrKwo5Ev6wMKzPkaXaCDIQKzLnvsA42DRlbVTWorkgTKIviAKCWkfUwA== - -is-plain-object@^2.0.4: - version "2.0.4" - resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-2.0.4.tgz#2c163b3fafb1b606d9d17928f05c2a1c38e07677" - integrity sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og== - dependencies: - isobject "^3.0.1" - -is-regex@^1.0.4: - version "1.1.4" - resolved "https://registry.yarnpkg.com/is-regex/-/is-regex-1.1.4.tgz#eef5663cd59fa4c0ae339505323df6854bb15958" - integrity sha512-kvRdxDsxZjhzUX07ZnLydzS1TU/TJlTUHHY4YLL87e37oUA49DfkLqgy+VjFocowy29cKvcSiu+kIv728jTTVg== - dependencies: - call-bind "^1.0.2" - has-tostringtag "^1.0.0" - -is-stream@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-2.0.1.tgz#fac1e3d53b97ad5a9d0ae9cef2389f5810a5c077" - integrity sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg== - -is-wsl@^2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/is-wsl/-/is-wsl-2.2.0.tgz#74a4c76e77ca9fd3f932f290c17ea326cd157271" - integrity sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww== - dependencies: - is-docker "^2.0.0" - -isarray@~1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11" - integrity sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE= - -isexe@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" - integrity sha1-6PvzdNxVb/iUehDcsFctYz8s+hA= - -isobject@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/isobject/-/isobject-3.0.1.tgz#4e431e92b11a9731636aa1f9c8d1ccbcfdab78df" - integrity sha1-TkMekrEalzFjaqH5yNHMvP2reN8= - -jest-worker@^27.4.5: - version "27.5.1" - resolved "https://registry.yarnpkg.com/jest-worker/-/jest-worker-27.5.1.tgz#8d146f0900e8973b106b6f73cc1e9a8cb86f8db0" - integrity sha512-7vuh85V5cdDofPyxn58nrPjBktZo0u9x1g8WtjQol+jZDaE+fhN+cIvTj11GndBnMnyfrUOG1sZQxCdjKh+DKg== - dependencies: - "@types/node" "*" - merge-stream "^2.0.0" - supports-color "^8.0.0" - -json-parse-even-better-errors@^2.3.1: - version "2.3.1" - resolved "https://registry.yarnpkg.com/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz#7c47805a94319928e05777405dc12e1f7a4ee02d" - integrity sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w== - -json-schema-traverse@^0.4.1: - version "0.4.1" - resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz#69f6a87d9513ab8bb8fe63bdb0979c448e684660" - integrity sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg== - -json-schema-traverse@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz#ae7bcb3656ab77a73ba5c49bf654f38e6b6860e2" - integrity sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug== - -json5@^1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/json5/-/json5-1.0.2.tgz#63d98d60f21b313b77c4d6da18bfa69d80e1d593" - integrity sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA== - dependencies: - minimist "^1.2.0" - -kind-of@^6.0.2: - version "6.0.3" - resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.3.tgz#07c05034a6c349fa06e24fa35aa76db4580ce4dd" - integrity sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw== - -loader-runner@^4.2.0: - version "4.2.0" - resolved "https://registry.yarnpkg.com/loader-runner/-/loader-runner-4.2.0.tgz#d7022380d66d14c5fb1d496b89864ebcfd478384" - integrity sha512-92+huvxMvYlMzMt0iIOukcwYBFpkYJdpl2xsZ7LrlayO7E8SOv+JJUEK17B/dJIHAOLMfh2dZZ/Y18WgmGtYNw== - -loader-utils@^1.4.0: - version "1.4.2" - resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-1.4.2.tgz#29a957f3a63973883eb684f10ffd3d151fec01a3" - integrity sha512-I5d00Pd/jwMD2QCduo657+YM/6L3KZu++pmX9VFncxaxvHcru9jx1lBaFft+r4Mt2jK0Yhp41XlRAihzPxHNCg== - dependencies: - big.js "^5.2.2" - emojis-list "^3.0.0" - json5 "^1.0.1" - -locate-path@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-5.0.0.tgz#1afba396afd676a6d42504d0a67a3a7eb9f62aa0" - integrity sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g== - dependencies: - p-locate "^4.1.0" - -lodash@^4.17.14, lodash@^4.17.20, lodash@^4.17.21: - version "4.17.21" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c" - integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg== - -lower-case@^2.0.2: - version "2.0.2" - resolved "https://registry.yarnpkg.com/lower-case/-/lower-case-2.0.2.tgz#6fa237c63dbdc4a82ca0fd882e4722dc5e634e28" - integrity sha512-7fm3l3NAF9WfN6W3JOmf5drwpVqX78JtoGJ3A6W0a6ZnldM41w2fV5D490psKFTpMds8TJse/eHLFFsNHHjHgg== - dependencies: - tslib "^2.0.3" - -media-typer@0.3.0: - version "0.3.0" - resolved "https://registry.yarnpkg.com/media-typer/-/media-typer-0.3.0.tgz#8710d7af0aa626f8fffa1ce00168545263255748" - integrity sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g= - -memfs@^3.4.1: - version "3.4.1" - resolved "https://registry.yarnpkg.com/memfs/-/memfs-3.4.1.tgz#b78092f466a0dce054d63d39275b24c71d3f1305" - integrity sha512-1c9VPVvW5P7I85c35zAdEr1TD5+F11IToIHIlrVIcflfnzPkJa0ZoYEoEdYDP8KgPFoSZ/opDrUsAoZWym3mtw== - dependencies: - fs-monkey "1.0.3" - -merge-descriptors@1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/merge-descriptors/-/merge-descriptors-1.0.1.tgz#b00aaa556dd8b44568150ec9d1b953f3f90cbb61" - integrity sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E= - -merge-stream@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/merge-stream/-/merge-stream-2.0.0.tgz#52823629a14dd00c9770fb6ad47dc6310f2c1f60" - integrity sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w== - -merge2@^1.3.0, merge2@^1.4.1: - version "1.4.1" - resolved "https://registry.yarnpkg.com/merge2/-/merge2-1.4.1.tgz#4368892f885e907455a6fd7dc55c0c9d404990ae" - integrity sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg== - -methods@~1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/methods/-/methods-1.1.2.tgz#5529a4d67654134edcc5266656835b0f851afcee" - integrity sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4= - -micromatch@^4.0.2, micromatch@^4.0.4: - version "4.0.4" - resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.4.tgz#896d519dfe9db25fce94ceb7a500919bf881ebf9" - integrity sha512-pRmzw/XUcwXGpD9aI9q/0XOwLNygjETJ8y0ao0wdqprrzDa4YnxLcz7fQRZr8voh8V10kGhABbNcHVk5wHgWwg== - dependencies: - braces "^3.0.1" - picomatch "^2.2.3" - -mime-db@1.52.0, "mime-db@>= 1.43.0 < 2": - version "1.52.0" - resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.52.0.tgz#bbabcdc02859f4987301c856e3387ce5ec43bf70" - integrity sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg== - -mime-types@^2.1.27, mime-types@^2.1.31, mime-types@~2.1.17, mime-types@~2.1.24, mime-types@~2.1.34: - version "2.1.35" - resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.35.tgz#381a871b62a734450660ae3deee44813f70d959a" - integrity sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw== - dependencies: - mime-db "1.52.0" - -mime@1.6.0: - version "1.6.0" - resolved "https://registry.yarnpkg.com/mime/-/mime-1.6.0.tgz#32cd9e5c64553bd58d19a568af452acff04981b1" - integrity sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg== - -mimic-fn@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-2.1.0.tgz#7ed2c2ccccaf84d3ffcb7a69b57711fc2083401b" - integrity sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg== - -minimalistic-assert@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz#2e194de044626d4a10e7f7fbc00ce73e83e4d5c7" - integrity sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A== - -minimatch@^3.0.4: - version "3.1.2" - resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b" - integrity sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw== - dependencies: - brace-expansion "^1.1.7" - -minimist@1.2.6, minimist@^1.2.0, minimist@^1.2.5: - version "1.2.6" - resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.6.tgz#8637a5b759ea0d6e98702cfb3a9283323c93af44" - integrity sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q== - -mkdirp@^0.5.5: - version "0.5.5" - resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.5.tgz#d91cefd62d1436ca0f41620e251288d420099def" - integrity sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ== - dependencies: - minimist "^1.2.5" - -ms@2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" - integrity sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g= - -ms@2.1.2: - version "2.1.2" - resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" - integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== - -ms@2.1.3, ms@^2.1.1: - version "2.1.3" - resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2" - integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA== - -multicast-dns-service-types@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/multicast-dns-service-types/-/multicast-dns-service-types-1.1.0.tgz#899f11d9686e5e05cb91b35d5f0e63b773cfc901" - integrity sha1-iZ8R2WhuXgXLkbNdXw5jt3PPyQE= - -multicast-dns@^6.0.1: - version "6.2.3" - resolved "https://registry.yarnpkg.com/multicast-dns/-/multicast-dns-6.2.3.tgz#a0ec7bd9055c4282f790c3c82f4e28db3b31b229" - integrity sha512-ji6J5enbMyGRHIAkAOu3WdV8nggqviKCEKtXcOqfphZZtQrmHKycfynJ2V7eVPUA4NhJ6V7Wf4TmGbTwKE9B6g== - dependencies: - dns-packet "^1.3.1" - thunky "^1.0.2" - -negotiator@0.6.3: - version "0.6.3" - resolved "https://registry.yarnpkg.com/negotiator/-/negotiator-0.6.3.tgz#58e323a72fedc0d6f9cd4d31fe49f51479590ccd" - integrity sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg== - -neo-async@^2.6.2: - version "2.6.2" - resolved "https://registry.yarnpkg.com/neo-async/-/neo-async-2.6.2.tgz#b4aafb93e3aeb2d8174ca53cf163ab7d7308305f" - integrity sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw== - -no-case@^3.0.4: - version "3.0.4" - resolved "https://registry.yarnpkg.com/no-case/-/no-case-3.0.4.tgz#d361fd5c9800f558551a8369fc0dcd4662b6124d" - integrity sha512-fgAN3jGAh+RoxUGZHTSOLJIqUc2wmoBwGR4tbpNAKmmovFoWq0OdRkb0VkldReO2a2iBT/OEulG9XSUc10r3zg== - dependencies: - lower-case "^2.0.2" - tslib "^2.0.3" - -node-fetch@~2.6.1: - version "2.6.7" - resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.7.tgz#24de9fba827e3b4ae44dc8b20256a379160052ad" - integrity sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ== - dependencies: - whatwg-url "^5.0.0" - -node-forge@^1.2.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/node-forge/-/node-forge-1.3.0.tgz#37a874ea723855f37db091e6c186e5b67a01d4b2" - integrity sha512-08ARB91bUi6zNKzVmaj3QO7cr397uiDT2nJ63cHjyNtCTWIgvS47j3eT0WfzUwS9+6Z5YshRaoasFkXCKrIYbA== - -node-releases@^2.0.2: - version "2.0.2" - resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-2.0.2.tgz#7139fe71e2f4f11b47d4d2986aaf8c48699e0c01" - integrity sha512-XxYDdcQ6eKqp/YjI+tb2C5WM2LgjnZrfYg4vgQt49EK268b6gYCHsBLrK2qvJo4FmCtqmKezb0WZFK4fkrZNsg== - -normalize-path@^3.0.0, normalize-path@~3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-3.0.0.tgz#0dcd69ff23a1c9b11fd0978316644a0388216a65" - integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA== - -npm-run-path@^4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/npm-run-path/-/npm-run-path-4.0.1.tgz#b7ecd1e5ed53da8e37a55e1c2269e0b97ed748ea" - integrity sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw== - dependencies: - path-key "^3.0.0" - -nth-check@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/nth-check/-/nth-check-2.0.1.tgz#2efe162f5c3da06a28959fbd3db75dbeea9f0fc2" - integrity sha512-it1vE95zF6dTT9lBsYbxvqh0Soy4SPowchj0UBGj/V6cTPnXXtQOPUbhZ6CmGzAD/rW22LQK6E96pcdJXk4A4w== - dependencies: - boolbase "^1.0.0" - -object-is@^1.0.1: - version "1.1.5" - resolved "https://registry.yarnpkg.com/object-is/-/object-is-1.1.5.tgz#b9deeaa5fc7f1846a0faecdceec138e5778f53ac" - integrity sha512-3cyDsyHgtmi7I7DfSSI2LDp6SK2lwvtbg0p0R1e0RvTqF5ceGx+K2dfSjm1bKDMVCFEDAQvy+o8c6a7VujOddw== - dependencies: - call-bind "^1.0.2" - define-properties "^1.1.3" - -object-keys@^1.0.12, object-keys@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.1.1.tgz#1c47f272df277f3b1daf061677d9c82e2322c60e" - integrity sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA== - -obuf@^1.0.0, obuf@^1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/obuf/-/obuf-1.1.2.tgz#09bea3343d41859ebd446292d11c9d4db619084e" - integrity sha512-PX1wu0AmAdPqOL1mWhqmlOd8kOIZQwGZw6rh7uby9fTc5lhaOWFLX3I6R1hrF9k3zUY40e6igsLGkDXK92LJNg== - -on-finished@~2.3.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/on-finished/-/on-finished-2.3.0.tgz#20f1336481b083cd75337992a16971aa2d906947" - integrity sha1-IPEzZIGwg811M3mSoWlxqi2QaUc= - dependencies: - ee-first "1.1.1" - -on-headers@~1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/on-headers/-/on-headers-1.0.2.tgz#772b0ae6aaa525c399e489adfad90c403eb3c28f" - integrity sha512-pZAE+FJLoyITytdqK0U5s+FIpjN0JP3OzFi/u8Rx+EV5/W+JTWGXG8xFzevE7AjBfDqHv/8vL8qQsIhHnqRkrA== - -once@^1.3.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" - integrity sha1-WDsap3WWHUsROsF9nFC6753Xa9E= - dependencies: - wrappy "1" - -onetime@^5.1.2: - version "5.1.2" - resolved "https://registry.yarnpkg.com/onetime/-/onetime-5.1.2.tgz#d0e96ebb56b07476df1dd9c4806e5237985ca45e" - integrity sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg== - dependencies: - mimic-fn "^2.1.0" - -open@^8.0.9: - version "8.4.0" - resolved "https://registry.yarnpkg.com/open/-/open-8.4.0.tgz#345321ae18f8138f82565a910fdc6b39e8c244f8" - integrity sha512-XgFPPM+B28FtCCgSb9I+s9szOC1vZRSwgWsRUA5ylIxRTgKozqjOCrVOqGsYABPYK5qnfqClxZTFBa8PKt2v6Q== - dependencies: - define-lazy-prop "^2.0.0" - is-docker "^2.1.1" - is-wsl "^2.2.0" - -p-limit@^2.2.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-2.3.0.tgz#3dd33c647a214fdfffd835933eb086da0dc21db1" - integrity sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w== - dependencies: - p-try "^2.0.0" - -p-locate@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-4.1.0.tgz#a3428bb7088b3a60292f66919278b7c297ad4f07" - integrity sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A== - dependencies: - p-limit "^2.2.0" - -p-map@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/p-map/-/p-map-4.0.0.tgz#bb2f95a5eda2ec168ec9274e06a747c3e2904d2b" - integrity sha512-/bjOqmgETBYB5BoEeGVea8dmvHb2m9GLy1E9W43yeyfP6QQCZGFNa+XRceJEuDB6zqr+gKpIAmlLebMpykw/MQ== - dependencies: - aggregate-error "^3.0.0" - -p-retry@^4.5.0: - version "4.6.1" - resolved "https://registry.yarnpkg.com/p-retry/-/p-retry-4.6.1.tgz#8fcddd5cdf7a67a0911a9cf2ef0e5df7f602316c" - integrity sha512-e2xXGNhZOZ0lfgR9kL34iGlU8N/KO0xZnQxVEwdeOvpqNDQfdnxIYizvWtK8RglUa3bGqI8g0R/BdfzLMxRkiA== - dependencies: - "@types/retry" "^0.12.0" - retry "^0.13.1" - -p-try@^2.0.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/p-try/-/p-try-2.2.0.tgz#cb2868540e313d61de58fafbe35ce9004d5540e6" - integrity sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ== - -param-case@^3.0.4: - version "3.0.4" - resolved "https://registry.yarnpkg.com/param-case/-/param-case-3.0.4.tgz#7d17fe4aa12bde34d4a77d91acfb6219caad01c5" - integrity sha512-RXlj7zCYokReqWpOPH9oYivUzLYZ5vAPIfEmCTNViosC78F8F0H9y7T7gG2M39ymgutxF5gcFEsyZQSph9Bp3A== - dependencies: - dot-case "^3.0.4" - tslib "^2.0.3" - -parseurl@~1.3.2, parseurl@~1.3.3: - version "1.3.3" - resolved "https://registry.yarnpkg.com/parseurl/-/parseurl-1.3.3.tgz#9da19e7bee8d12dff0513ed5b76957793bc2e8d4" - integrity sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ== - -pascal-case@^3.1.2: - version "3.1.2" - resolved "https://registry.yarnpkg.com/pascal-case/-/pascal-case-3.1.2.tgz#b48e0ef2b98e205e7c1dae747d0b1508237660eb" - integrity sha512-uWlGT3YSnK9x3BQJaOdcZwrnV6hPpd8jFH1/ucpiLRPh/2zCVJKS19E4GvYHvaCcACn3foXZ0cLB9Wrx1KGe5g== - dependencies: - no-case "^3.0.4" - tslib "^2.0.3" - -path-exists@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-4.0.0.tgz#513bdbe2d3b95d7762e8c1137efa195c6c61b5b3" - integrity sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w== - -path-is-absolute@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" - integrity sha1-F0uSaHNVNP+8es5r9TpanhtcX18= - -path-key@^3.0.0, path-key@^3.1.0: - version "3.1.1" - resolved "https://registry.yarnpkg.com/path-key/-/path-key-3.1.1.tgz#581f6ade658cbba65a0d3380de7753295054f375" - integrity sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q== - -path-parse@^1.0.7: - version "1.0.7" - resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.7.tgz#fbc114b60ca42b30d9daf5858e4bd68bbedb6735" - integrity sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw== - -path-to-regexp@0.1.7: - version "0.1.7" - resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-0.1.7.tgz#df604178005f522f15eb4490e7247a1bfaa67f8c" - integrity sha1-32BBeABfUi8V60SQ5yR6G/qmf4w= - -path-type@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/path-type/-/path-type-4.0.0.tgz#84ed01c0a7ba380afe09d90a8c180dcd9d03043b" - integrity sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw== - -picocolors@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/picocolors/-/picocolors-1.0.0.tgz#cb5bdc74ff3f51892236eaf79d68bc44564ab81c" - integrity sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ== - -picomatch@^2.0.4, picomatch@^2.2.1, picomatch@^2.2.3: - version "2.3.1" - resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42" - integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA== - -pkg-dir@^4.2.0: - version "4.2.0" - resolved "https://registry.yarnpkg.com/pkg-dir/-/pkg-dir-4.2.0.tgz#f099133df7ede422e81d1d8448270eeb3e4261f3" - integrity sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ== - dependencies: - find-up "^4.0.0" - -portfinder@^1.0.28: - version "1.0.28" - resolved "https://registry.yarnpkg.com/portfinder/-/portfinder-1.0.28.tgz#67c4622852bd5374dd1dd900f779f53462fac778" - integrity sha512-Se+2isanIcEqf2XMHjyUKskczxbPH7dQnlMjXX6+dybayyHvAf/TCgyMRlzf/B6QDhAEFOGes0pzRo3by4AbMA== - dependencies: - async "^2.6.2" - debug "^3.1.1" - mkdirp "^0.5.5" - -pretty-error@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/pretty-error/-/pretty-error-4.0.0.tgz#90a703f46dd7234adb46d0f84823e9d1cb8f10d6" - integrity sha512-AoJ5YMAcXKYxKhuJGdcvse+Voc6v1RgnsR3nWcYU7q4t6z0Q6T86sv5Zq8VIRbOWWFpvdGE83LtdSMNd+6Y0xw== - dependencies: - lodash "^4.17.20" - renderkid "^3.0.0" - -process-nextick-args@~2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.1.tgz#7820d9b16120cc55ca9ae7792680ae7dba6d7fe2" - integrity sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag== - -proxy-addr@~2.0.7: - version "2.0.7" - resolved "https://registry.yarnpkg.com/proxy-addr/-/proxy-addr-2.0.7.tgz#f19fe69ceab311eeb94b42e70e8c2070f9ba1025" - integrity sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg== - dependencies: - forwarded "0.2.0" - ipaddr.js "1.9.1" - -punycode@^2.1.0: - version "2.1.1" - resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec" - integrity sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A== - -qs@6.9.7: - version "6.9.7" - resolved "https://registry.yarnpkg.com/qs/-/qs-6.9.7.tgz#4610846871485e1e048f44ae3b94033f0e675afe" - integrity sha512-IhMFgUmuNpyRfxA90umL7ByLlgRXu6tIfKPpF5TmcfRLlLCckfP/g3IQmju6jjpu+Hh8rA+2p6A27ZSPOOHdKw== - -queue-microtask@^1.2.2: - version "1.2.3" - resolved "https://registry.yarnpkg.com/queue-microtask/-/queue-microtask-1.2.3.tgz#4929228bbc724dfac43e0efb058caf7b6cfb6243" - integrity sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A== - -randombytes@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/randombytes/-/randombytes-2.1.0.tgz#df6f84372f0270dc65cdf6291349ab7a473d4f2a" - integrity sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ== - dependencies: - safe-buffer "^5.1.0" - -range-parser@^1.2.1, range-parser@~1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/range-parser/-/range-parser-1.2.1.tgz#3cf37023d199e1c24d1a55b84800c2f3e6468031" - integrity sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg== - -raw-body@2.4.3: - version "2.4.3" - resolved "https://registry.yarnpkg.com/raw-body/-/raw-body-2.4.3.tgz#8f80305d11c2a0a545c2d9d89d7a0286fcead43c" - integrity sha512-UlTNLIcu0uzb4D2f4WltY6cVjLi+/jEN4lgEUj3E04tpMDpUlkBo/eSn6zou9hum2VMNpCCUone0O0WeJim07g== - dependencies: - bytes "3.1.2" - http-errors "1.8.1" - iconv-lite "0.4.24" - unpipe "1.0.0" - -readable-stream@^2.0.1: - version "2.3.7" - resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.7.tgz#1eca1cf711aef814c04f62252a36a62f6cb23b57" - integrity sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw== - dependencies: - core-util-is "~1.0.0" - inherits "~2.0.3" - isarray "~1.0.0" - process-nextick-args "~2.0.0" - safe-buffer "~5.1.1" - string_decoder "~1.1.1" - util-deprecate "~1.0.1" - -readable-stream@^3.0.6: - version "3.6.0" - resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-3.6.0.tgz#337bbda3adc0706bd3e024426a286d4b4b2c9198" - integrity sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA== - dependencies: - inherits "^2.0.3" - string_decoder "^1.1.1" - util-deprecate "^1.0.1" - -readdirp@~3.6.0: - version "3.6.0" - resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-3.6.0.tgz#74a370bd857116e245b29cc97340cd431a02a6c7" - integrity sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA== - dependencies: - picomatch "^2.2.1" - -rechoir@^0.7.0: - version "0.7.1" - resolved "https://registry.yarnpkg.com/rechoir/-/rechoir-0.7.1.tgz#9478a96a1ca135b5e88fc027f03ee92d6c645686" - integrity sha512-/njmZ8s1wVeR6pjTZ+0nCnv8SpZNRMT2D1RLOJQESlYFDBvwpTA4KWJpZ+sBJ4+vhjILRcK7JIFdGCdxEAAitg== - dependencies: - resolve "^1.9.0" - -regexp.prototype.flags@^1.2.0: - version "1.4.1" - resolved "https://registry.yarnpkg.com/regexp.prototype.flags/-/regexp.prototype.flags-1.4.1.tgz#b3f4c0059af9e47eca9f3f660e51d81307e72307" - integrity sha512-pMR7hBVUUGI7PMA37m2ofIdQCsomVnas+Jn5UPGAHQ+/LlwKm/aTLJHdasmHRzlfeZwHiAOaRSo2rbBDm3nNUQ== - dependencies: - call-bind "^1.0.2" - define-properties "^1.1.3" - -relateurl@^0.2.7: - version "0.2.7" - resolved "https://registry.yarnpkg.com/relateurl/-/relateurl-0.2.7.tgz#54dbf377e51440aca90a4cd274600d3ff2d888a9" - integrity sha1-VNvzd+UUQKypCkzSdGANP/LYiKk= - -renderkid@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/renderkid/-/renderkid-3.0.0.tgz#5fd823e4d6951d37358ecc9a58b1f06836b6268a" - integrity sha512-q/7VIQA8lmM1hF+jn+sFSPWGlMkSAeNYcPLmDQx2zzuiDfaLrOmumR8iaUKlenFgh0XRPIUeSPlH3A+AW3Z5pg== - dependencies: - css-select "^4.1.3" - dom-converter "^0.2.0" - htmlparser2 "^6.1.0" - lodash "^4.17.21" - strip-ansi "^6.0.1" - -require-from-string@^2.0.2: - version "2.0.2" - resolved "https://registry.yarnpkg.com/require-from-string/-/require-from-string-2.0.2.tgz#89a7fdd938261267318eafe14f9c32e598c36909" - integrity sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw== - -requires-port@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/requires-port/-/requires-port-1.0.0.tgz#925d2601d39ac485e091cf0da5c6e694dc3dcaff" - integrity sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8= - -resolve-cwd@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/resolve-cwd/-/resolve-cwd-3.0.0.tgz#0f0075f1bb2544766cf73ba6a6e2adfebcb13f2d" - integrity sha512-OrZaX2Mb+rJCpH/6CpSqt9xFVpN++x01XnN2ie9g6P5/3xelLAkXWVADpdz1IHD/KFfEXyE6V0U01OQ3UO2rEg== - dependencies: - resolve-from "^5.0.0" - -resolve-from@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-5.0.0.tgz#c35225843df8f776df21c57557bc087e9dfdfc69" - integrity sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw== - -resolve@^1.9.0: - version "1.22.0" - resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.22.0.tgz#5e0b8c67c15df57a89bdbabe603a002f21731198" - integrity sha512-Hhtrw0nLeSrFQ7phPp4OOcVjLPIeMnRlr5mcnVuMe7M/7eBn98A3hmFRLoFo3DLZkivSYwhRUJTyPyWAk56WLw== - dependencies: - is-core-module "^2.8.1" - path-parse "^1.0.7" - supports-preserve-symlinks-flag "^1.0.0" - -retry@^0.13.1: - version "0.13.1" - resolved "https://registry.yarnpkg.com/retry/-/retry-0.13.1.tgz#185b1587acf67919d63b357349e03537b2484658" - integrity sha512-XQBQ3I8W1Cge0Seh+6gjj03LbmRFWuoszgK9ooCpwYIrhhoO80pfq4cUkU5DkknwfOfFteRwlZ56PYOGYyFWdg== - -reusify@^1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/reusify/-/reusify-1.0.4.tgz#90da382b1e126efc02146e90845a88db12925d76" - integrity sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw== - -rimraf@^3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-3.0.2.tgz#f1a5402ba6220ad52cc1282bac1ae3aa49fd061a" - integrity sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA== - dependencies: - glob "^7.1.3" - -run-parallel@^1.1.9: - version "1.2.0" - resolved "https://registry.yarnpkg.com/run-parallel/-/run-parallel-1.2.0.tgz#66d1368da7bdf921eb9d95bd1a9229e7f21a43ee" - integrity sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA== - dependencies: - queue-microtask "^1.2.2" - -safe-buffer@5.1.2, safe-buffer@~5.1.0, safe-buffer@~5.1.1: - version "5.1.2" - resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" - integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g== - -safe-buffer@5.2.1, safe-buffer@>=5.1.0, safe-buffer@^5.0.1, safe-buffer@^5.1.0, safe-buffer@~5.2.0: - version "5.2.1" - resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" - integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== - -"safer-buffer@>= 2.1.2 < 3": - version "2.1.2" - resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a" - integrity sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg== - -schema-utils@^2.5.0: - version "2.7.1" - resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-2.7.1.tgz#1ca4f32d1b24c590c203b8e7a50bf0ea4cd394d7" - integrity sha512-SHiNtMOUGWBQJwzISiVYKu82GiV4QYGePp3odlY1tuKO7gPtphAT5R/py0fA6xtbgLL/RvtJZnU9b8s0F1q0Xg== - dependencies: - "@types/json-schema" "^7.0.5" - ajv "^6.12.4" - ajv-keywords "^3.5.2" - -schema-utils@^3.1.0, schema-utils@^3.1.1: - version "3.1.1" - resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-3.1.1.tgz#bc74c4b6b6995c1d88f76a8b77bea7219e0c8281" - integrity sha512-Y5PQxS4ITlC+EahLuXaY86TXfR7Dc5lw294alXOq86JAHCihAIZfqv8nNCWvaEJvaC51uN9hbLGeV0cFBdH+Fw== - dependencies: - "@types/json-schema" "^7.0.8" - ajv "^6.12.5" - ajv-keywords "^3.5.2" - -schema-utils@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-4.0.0.tgz#60331e9e3ae78ec5d16353c467c34b3a0a1d3df7" - integrity sha512-1edyXKgh6XnJsJSQ8mKWXnN/BVaIbFMLpouRUrXgVq7WYne5kw3MW7UPhO44uRXQSIpTSXoJbmrR2X0w9kUTyg== - dependencies: - "@types/json-schema" "^7.0.9" - ajv "^8.8.0" - ajv-formats "^2.1.1" - ajv-keywords "^5.0.0" - -seedrandom@2.4.3: - version "2.4.3" - resolved "https://registry.yarnpkg.com/seedrandom/-/seedrandom-2.4.3.tgz#2438504dad33917314bff18ac4d794f16d6aaecc" - integrity sha1-JDhQTa0zkXMUv/GKxNeU8W1qrsw= - -select-hose@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/select-hose/-/select-hose-2.0.0.tgz#625d8658f865af43ec962bfc376a37359a4994ca" - integrity sha1-Yl2GWPhlr0Psliv8N2o3NZpJlMo= - -selfsigned@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/selfsigned/-/selfsigned-2.0.0.tgz#e927cd5377cbb0a1075302cff8df1042cc2bce5b" - integrity sha512-cUdFiCbKoa1mZ6osuJs2uDHrs0k0oprsKveFiiaBKCNq3SYyb5gs2HxhQyDNLCmL51ZZThqi4YNDpCK6GOP1iQ== - dependencies: - node-forge "^1.2.0" - -send@0.17.2: - version "0.17.2" - resolved "https://registry.yarnpkg.com/send/-/send-0.17.2.tgz#926622f76601c41808012c8bf1688fe3906f7820" - integrity sha512-UJYB6wFSJE3G00nEivR5rgWp8c2xXvJ3OPWPhmuteU0IKj8nKbG3DrjiOmLwpnHGYWAVwA69zmTm++YG0Hmwww== - dependencies: - debug "2.6.9" - depd "~1.1.2" - destroy "~1.0.4" - encodeurl "~1.0.2" - escape-html "~1.0.3" - etag "~1.8.1" - fresh "0.5.2" - http-errors "1.8.1" - mime "1.6.0" - ms "2.1.3" - on-finished "~2.3.0" - range-parser "~1.2.1" - statuses "~1.5.0" - -serialize-javascript@^6.0.0: - version "6.0.0" - resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-6.0.0.tgz#efae5d88f45d7924141da8b5c3a7a7e663fefeb8" - integrity sha512-Qr3TosvguFt8ePWqsvRfrKyQXIiW+nGbYpy8XK24NQHE83caxWt+mIymTT19DGFbNWNLfEwsrkSmN64lVWB9ag== - dependencies: - randombytes "^2.1.0" - -serve-index@^1.9.1: - version "1.9.1" - resolved "https://registry.yarnpkg.com/serve-index/-/serve-index-1.9.1.tgz#d3768d69b1e7d82e5ce050fff5b453bea12a9239" - integrity sha1-03aNabHn2C5c4FD/9bRTvqEqkjk= - dependencies: - accepts "~1.3.4" - batch "0.6.1" - debug "2.6.9" - escape-html "~1.0.3" - http-errors "~1.6.2" - mime-types "~2.1.17" - parseurl "~1.3.2" - -serve-static@1.14.2: - version "1.14.2" - resolved "https://registry.yarnpkg.com/serve-static/-/serve-static-1.14.2.tgz#722d6294b1d62626d41b43a013ece4598d292bfa" - integrity sha512-+TMNA9AFxUEGuC0z2mevogSnn9MXKb4fa7ngeRMJaaGv8vTwnIEkKi+QGvPt33HSnf8pRS+WGM0EbMtCJLKMBQ== - dependencies: - encodeurl "~1.0.2" - escape-html "~1.0.3" - parseurl "~1.3.3" - send "0.17.2" - -setprototypeof@1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/setprototypeof/-/setprototypeof-1.1.0.tgz#d0bd85536887b6fe7c0d818cb962d9d91c54e656" - integrity sha512-BvE/TwpZX4FXExxOxZyRGQQv651MSwmWKZGqvmPcRIjDqWub67kTKuIMx43cZZrS/cBBzwBcNDWoFxt2XEFIpQ== - -setprototypeof@1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/setprototypeof/-/setprototypeof-1.2.0.tgz#66c9a24a73f9fc28cbe66b09fed3d33dcaf1b424" - integrity sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw== - -shallow-clone@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/shallow-clone/-/shallow-clone-3.0.1.tgz#8f2981ad92531f55035b01fb230769a40e02efa3" - integrity sha512-/6KqX+GVUdqPuPPd2LxDDxzX6CAbjJehAAOKlNpqqUpAqPM6HeL8f+o3a+JsyGjn2lv0WY8UsTgUJjU9Ok55NA== - dependencies: - kind-of "^6.0.2" - -shebang-command@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-2.0.0.tgz#ccd0af4f8835fbdc265b82461aaf0c36663f34ea" - integrity sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA== - dependencies: - shebang-regex "^3.0.0" - -shebang-regex@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-3.0.0.tgz#ae16f1644d873ecad843b0307b143362d4c42172" - integrity sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A== - -signal-exit@^3.0.3: - version "3.0.7" - resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.7.tgz#a9a1767f8af84155114eaabd73f99273c8f59ad9" - integrity sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ== - -slash@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/slash/-/slash-3.0.0.tgz#6539be870c165adbd5240220dbe361f1bc4d4634" - integrity sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q== - -sockjs@^0.3.21: - version "0.3.24" - resolved "https://registry.yarnpkg.com/sockjs/-/sockjs-0.3.24.tgz#c9bc8995f33a111bea0395ec30aa3206bdb5ccce" - integrity sha512-GJgLTZ7vYb/JtPSSZ10hsOYIvEYsjbNU+zPdIHcUaWVNUEPivzxku31865sSSud0Da0W4lEeOPlmw93zLQchuQ== - dependencies: - faye-websocket "^0.11.3" - uuid "^8.3.2" - websocket-driver "^0.7.4" - -source-map-support@~0.5.20: - version "0.5.21" - resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.21.tgz#04fe7c7f9e1ed2d662233c28cb2b35b9f63f6e4f" - integrity sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w== - dependencies: - buffer-from "^1.0.0" - source-map "^0.6.0" - -source-map@^0.6.0, source-map@^0.6.1, source-map@~0.6.0: - version "0.6.1" - resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" - integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== - -spdy-transport@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/spdy-transport/-/spdy-transport-3.0.0.tgz#00d4863a6400ad75df93361a1608605e5dcdcf31" - integrity sha512-hsLVFE5SjA6TCisWeJXFKniGGOpBgMLmerfO2aCyCU5s7nJ/rpAepqmFifv/GCbSbueEeAJJnmSQ2rKC/g8Fcw== - dependencies: - debug "^4.1.0" - detect-node "^2.0.4" - hpack.js "^2.1.6" - obuf "^1.1.2" - readable-stream "^3.0.6" - wbuf "^1.7.3" - -spdy@^4.0.2: - version "4.0.2" - resolved "https://registry.yarnpkg.com/spdy/-/spdy-4.0.2.tgz#b74f466203a3eda452c02492b91fb9e84a27677b" - integrity sha512-r46gZQZQV+Kl9oItvl1JZZqJKGr+oEkB08A6BzkiR7593/7IbtuncXHd2YoYeTsG4157ZssMu9KYvUHLcjcDoA== - dependencies: - debug "^4.1.0" - handle-thing "^2.0.0" - http-deceiver "^1.2.7" - select-hose "^2.0.0" - spdy-transport "^3.0.0" - -"statuses@>= 1.4.0 < 2", "statuses@>= 1.5.0 < 2", statuses@~1.5.0: - version "1.5.0" - resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.5.0.tgz#161c7dac177659fd9811f43771fa99381478628c" - integrity sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow= - -string_decoder@^1.1.1: - version "1.3.0" - resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.3.0.tgz#42f114594a46cf1a8e30b0a84f56c78c3edac21e" - integrity sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA== - dependencies: - safe-buffer "~5.2.0" - -string_decoder@~1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.1.1.tgz#9cf1611ba62685d7030ae9e4ba34149c3af03fc8" - integrity sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg== - dependencies: - safe-buffer "~5.1.0" - -strip-ansi@^6.0.1: - version "6.0.1" - resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" - integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== - dependencies: - ansi-regex "^5.0.1" - -strip-ansi@^7.0.0: - version "7.0.1" - resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.0.1.tgz#61740a08ce36b61e50e65653f07060d000975fb2" - integrity sha512-cXNxvT8dFNRVfhVME3JAe98mkXDYN2O1l7jmcwMnOslDeESg1rF/OZMtK0nRAhiari1unG5cD4jG3rapUAkLbw== - dependencies: - ansi-regex "^6.0.1" - -strip-final-newline@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/strip-final-newline/-/strip-final-newline-2.0.0.tgz#89b852fb2fcbe936f6f4b3187afb0a12c1ab58ad" - integrity sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA== - -supports-color@^8.0.0: - version "8.1.1" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-8.1.1.tgz#cd6fc17e28500cff56c1b86c0a7fd4a54a73005c" - integrity sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q== - dependencies: - has-flag "^4.0.0" - -supports-preserve-symlinks-flag@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz#6eda4bd344a3c94aea376d4cc31bc77311039e09" - integrity sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w== - -tapable@^2.0.0, tapable@^2.1.1, tapable@^2.2.0: - version "2.2.1" - resolved "https://registry.yarnpkg.com/tapable/-/tapable-2.2.1.tgz#1967a73ef4060a82f12ab96af86d52fdb76eeca0" - integrity sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ== - -terser-webpack-plugin@^5.1.3: - version "5.3.1" - resolved "https://registry.yarnpkg.com/terser-webpack-plugin/-/terser-webpack-plugin-5.3.1.tgz#0320dcc270ad5372c1e8993fabbd927929773e54" - integrity sha512-GvlZdT6wPQKbDNW/GDQzZFg/j4vKU96yl2q6mcUkzKOgW4gwf1Z8cZToUCrz31XHlPWH8MVb1r2tFtdDtTGJ7g== - dependencies: - jest-worker "^27.4.5" - schema-utils "^3.1.1" - serialize-javascript "^6.0.0" - source-map "^0.6.1" - terser "^5.7.2" - -terser@^5.10.0, terser@^5.7.2: - version "5.14.2" - resolved "https://registry.yarnpkg.com/terser/-/terser-5.14.2.tgz#9ac9f22b06994d736174f4091aa368db896f1c10" - integrity sha512-oL0rGeM/WFQCUd0y2QrWxYnq7tfSuKBiqTjRPWrRgB46WD/kiwHwF8T23z78H6Q6kGCuuHcPB+KULHRdxvVGQA== - dependencies: - "@jridgewell/source-map" "^0.3.2" - acorn "^8.5.0" - commander "^2.20.0" - source-map-support "~0.5.20" - -thunky@^1.0.2: - version "1.1.0" - resolved "https://registry.yarnpkg.com/thunky/-/thunky-1.1.0.tgz#5abaf714a9405db0504732bbccd2cedd9ef9537d" - integrity sha512-eHY7nBftgThBqOyHGVN+l8gF0BucP09fMo0oO/Lb0w1OF80dJv+lDVpXG60WMQvkcxAkNybKsrEIE3ZtKGmPrA== - -to-regex-range@^5.0.1: - version "5.0.1" - resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-5.0.1.tgz#1648c44aae7c8d988a326018ed72f5b4dd0392e4" - integrity sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ== - dependencies: - is-number "^7.0.0" - -toidentifier@1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/toidentifier/-/toidentifier-1.0.1.tgz#3be34321a88a820ed1bd80dfaa33e479fbb8dd35" - integrity sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA== - -tr46@~0.0.3: - version "0.0.3" - resolved "https://registry.yarnpkg.com/tr46/-/tr46-0.0.3.tgz#8184fd347dac9cdc185992f3a6622e14b9d9ab6a" - integrity sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o= - -tslib@^2.0.3: - version "2.3.1" - resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.3.1.tgz#e8a335add5ceae51aa261d32a490158ef042ef01" - integrity sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw== - -type-is@~1.6.18: - version "1.6.18" - resolved "https://registry.yarnpkg.com/type-is/-/type-is-1.6.18.tgz#4e552cd05df09467dcbc4ef739de89f2cf37c131" - integrity sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g== - dependencies: - media-typer "0.3.0" - mime-types "~2.1.24" - -unpipe@1.0.0, unpipe@~1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/unpipe/-/unpipe-1.0.0.tgz#b2bf4ee8514aae6165b4817829d21b2ef49904ec" - integrity sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw= - -uri-js@^4.2.2: - version "4.4.1" - resolved "https://registry.yarnpkg.com/uri-js/-/uri-js-4.4.1.tgz#9b1a52595225859e55f669d928f88c6c57f2a77e" - integrity sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg== - dependencies: - punycode "^2.1.0" - -util-deprecate@^1.0.1, util-deprecate@~1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" - integrity sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8= - -utila@~0.4: - version "0.4.0" - resolved "https://registry.yarnpkg.com/utila/-/utila-0.4.0.tgz#8a16a05d445657a3aea5eecc5b12a4fa5379772c" - integrity "sha1-ihagXURWV6Oupe7MWxKk+lN5dyw= sha512-Z0DbgELS9/L/75wZbro8xAnT50pBVFQZ+hUEueGDU5FN51YSCYM+jdxsfCiHjwNP/4LCDD0i/graKpeBnOXKRA==" - -utils-merge@1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/utils-merge/-/utils-merge-1.0.1.tgz#9f95710f50a267947b2ccc124741c1028427e713" - integrity sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM= - -uuid@^8.3.2: - version "8.3.2" - resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2" - integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg== - -vary@~1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/vary/-/vary-1.1.2.tgz#2299f02c6ded30d4a5961b0b9f74524a18f634fc" - integrity sha1-IpnwLG3tMNSllhsLn3RSShj2NPw= - -watchpack@^2.4.0: - version "2.4.0" - resolved "https://registry.yarnpkg.com/watchpack/-/watchpack-2.4.0.tgz#fa33032374962c78113f93c7f2fb4c54c9862a5d" - integrity sha512-Lcvm7MGST/4fup+ifyKi2hjyIAwcdI4HRgtvTpIUxBRhB+RFtUh8XtDOxUfctVCnhVi+QQj49i91OyvzkJl6cg== - dependencies: - glob-to-regexp "^0.4.1" - graceful-fs "^4.1.2" - -wbuf@^1.1.0, wbuf@^1.7.3: - version "1.7.3" - resolved "https://registry.yarnpkg.com/wbuf/-/wbuf-1.7.3.tgz#c1d8d149316d3ea852848895cb6a0bfe887b87df" - integrity sha512-O84QOnr0icsbFGLS0O3bI5FswxzRr8/gHwWkDlQFskhSPryQXvrTMxjxGP4+iWYoauLoBvfDpkrOauZ+0iZpDA== - dependencies: - minimalistic-assert "^1.0.0" - -webidl-conversions@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871" - integrity sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE= - -webpack-cli@^4.9.2: - version "4.9.2" - resolved "https://registry.yarnpkg.com/webpack-cli/-/webpack-cli-4.9.2.tgz#77c1adaea020c3f9e2db8aad8ea78d235c83659d" - integrity sha512-m3/AACnBBzK/kMTcxWHcZFPrw/eQuY4Df1TxvIWfWM2x7mRqBQCqKEd96oCUa9jkapLBaFfRce33eGDb4Pr7YQ== - dependencies: - "@discoveryjs/json-ext" "^0.5.0" - "@webpack-cli/configtest" "^1.1.1" - "@webpack-cli/info" "^1.4.1" - "@webpack-cli/serve" "^1.6.1" - colorette "^2.0.14" - commander "^7.0.0" - execa "^5.0.0" - fastest-levenshtein "^1.0.12" - import-local "^3.0.2" - interpret "^2.2.0" - rechoir "^0.7.0" - webpack-merge "^5.7.3" - -webpack-dev-middleware@^5.3.1: - version "5.3.1" - resolved "https://registry.yarnpkg.com/webpack-dev-middleware/-/webpack-dev-middleware-5.3.1.tgz#aa079a8dedd7e58bfeab358a9af7dab304cee57f" - integrity sha512-81EujCKkyles2wphtdrnPg/QqegC/AtqNH//mQkBYSMqwFVCQrxM6ktB2O/SPlZy7LqeEfTbV3cZARGQz6umhg== - dependencies: - colorette "^2.0.10" - memfs "^3.4.1" - mime-types "^2.1.31" - range-parser "^1.2.1" - schema-utils "^4.0.0" - -webpack-dev-server@^4.7.4: - version "4.7.4" - resolved "https://registry.yarnpkg.com/webpack-dev-server/-/webpack-dev-server-4.7.4.tgz#d0ef7da78224578384e795ac228d8efb63d5f945" - integrity sha512-nfdsb02Zi2qzkNmgtZjkrMOcXnYZ6FLKcQwpxT7MvmHKc+oTtDsBju8j+NMyAygZ9GW1jMEUpy3itHtqgEhe1A== - dependencies: - "@types/bonjour" "^3.5.9" - "@types/connect-history-api-fallback" "^1.3.5" - "@types/express" "^4.17.13" - "@types/serve-index" "^1.9.1" - "@types/sockjs" "^0.3.33" - "@types/ws" "^8.2.2" - ansi-html-community "^0.0.8" - bonjour "^3.5.0" - chokidar "^3.5.3" - colorette "^2.0.10" - compression "^1.7.4" - connect-history-api-fallback "^1.6.0" - default-gateway "^6.0.3" - del "^6.0.0" - express "^4.17.1" - graceful-fs "^4.2.6" - html-entities "^2.3.2" - http-proxy-middleware "^2.0.0" - ipaddr.js "^2.0.1" - open "^8.0.9" - p-retry "^4.5.0" - portfinder "^1.0.28" - schema-utils "^4.0.0" - selfsigned "^2.0.0" - serve-index "^1.9.1" - sockjs "^0.3.21" - spdy "^4.0.2" - strip-ansi "^7.0.0" - webpack-dev-middleware "^5.3.1" - ws "^8.4.2" - -webpack-merge@^5.7.3: - version "5.8.0" - resolved "https://registry.yarnpkg.com/webpack-merge/-/webpack-merge-5.8.0.tgz#2b39dbf22af87776ad744c390223731d30a68f61" - integrity sha512-/SaI7xY0831XwP6kzuwhKWVKDP9t1QY1h65lAFLbZqMPIuYcD9QAW4u9STIbU9kaJbPBB/geU/gLr1wDjOhQ+Q== - dependencies: - clone-deep "^4.0.1" - wildcard "^2.0.0" - -webpack-sources@^3.2.3: - version "3.2.3" - resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-3.2.3.tgz#2d4daab8451fd4b240cc27055ff6a0c2ccea0cde" - integrity sha512-/DyMEOrDgLKKIG0fmvtz+4dUX/3Ghozwgm6iPp8KRhvn+eQf9+Q7GWxVNMk3+uCPWfdXYC4ExGBckIXdFEfH1w== - -webpack@^5.76.0: - version "5.76.0" - resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.76.0.tgz#f9fb9fb8c4a7dbdcd0d56a98e56b8a942ee2692c" - integrity sha512-l5sOdYBDunyf72HW8dF23rFtWq/7Zgvt/9ftMof71E/yUb1YLOBmTgA2K4vQthB3kotMrSj609txVE0dnr2fjA== - dependencies: - "@types/eslint-scope" "^3.7.3" - "@types/estree" "^0.0.51" - "@webassemblyjs/ast" "1.11.1" - "@webassemblyjs/wasm-edit" "1.11.1" - "@webassemblyjs/wasm-parser" "1.11.1" - acorn "^8.7.1" - acorn-import-assertions "^1.7.6" - browserslist "^4.14.5" - chrome-trace-event "^1.0.2" - enhanced-resolve "^5.10.0" - es-module-lexer "^0.9.0" - eslint-scope "5.1.1" - events "^3.2.0" - glob-to-regexp "^0.4.1" - graceful-fs "^4.2.9" - json-parse-even-better-errors "^2.3.1" - loader-runner "^4.2.0" - mime-types "^2.1.27" - neo-async "^2.6.2" - schema-utils "^3.1.0" - tapable "^2.1.1" - terser-webpack-plugin "^5.1.3" - watchpack "^2.4.0" - webpack-sources "^3.2.3" - -websocket-driver@>=0.5.1, websocket-driver@^0.7.4: - version "0.7.4" - resolved "https://registry.yarnpkg.com/websocket-driver/-/websocket-driver-0.7.4.tgz#89ad5295bbf64b480abcba31e4953aca706f5760" - integrity sha512-b17KeDIQVjvb0ssuSDF2cYXSg2iztliJ4B9WdsuB6J952qCPKmnVq4DyW5motImXHDC1cBT/1UezrJVsKw5zjg== - dependencies: - http-parser-js ">=0.5.1" - safe-buffer ">=5.1.0" - websocket-extensions ">=0.1.1" - -websocket-extensions@>=0.1.1: - version "0.1.4" - resolved "https://registry.yarnpkg.com/websocket-extensions/-/websocket-extensions-0.1.4.tgz#7f8473bc839dfd87608adb95d7eb075211578a42" - integrity sha512-OqedPIGOfsDlo31UNwYbCFMSaO9m9G/0faIHj5/dZFDMFqPTcx6UwqyOy3COEaEOg/9VsGIpdqn62W5KhoKSpg== - -whatwg-url@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-5.0.0.tgz#966454e8765462e37644d3626f6742ce8b70965d" - integrity sha1-lmRU6HZUYuN2RNNib2dCzotwll0= - dependencies: - tr46 "~0.0.3" - webidl-conversions "^3.0.0" - -which@^2.0.1: - version "2.0.2" - resolved "https://registry.yarnpkg.com/which/-/which-2.0.2.tgz#7c6a8dd0a636a0327e10b59c9286eee93f3f51b1" - integrity sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA== - dependencies: - isexe "^2.0.0" - -wildcard@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/wildcard/-/wildcard-2.0.0.tgz#a77d20e5200c6faaac979e4b3aadc7b3dd7f8fec" - integrity sha512-JcKqAHLPxcdb9KM49dufGXn2x3ssnfjbcaQdLlfZsL9rH9wgDQjUtDxbo8NE0F6SFvydeu1VhZe7hZuHsB2/pw== - -wrappy@1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" - integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8= - -ws@^8.4.2: - version "8.5.0" - resolved "https://registry.yarnpkg.com/ws/-/ws-8.5.0.tgz#bfb4be96600757fe5382de12c670dab984a1ed4f" - integrity sha512-BWX0SWVgLPzYwF8lTzEy1egjhS4S4OEAHfsO8o65WOVsrnSRGaSiUaa9e0ggGlkMTtBlmOpEXiie9RUcBO86qg== diff --git a/tfjs-master/tfjs-backend-wasm/tools/cpplint.py b/tfjs-master/tfjs-backend-wasm/tools/cpplint.py deleted file mode 100644 index aea5da40c..000000000 --- a/tfjs-master/tfjs-backend-wasm/tools/cpplint.py +++ /dev/null @@ -1,6244 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (c) 2009 Google LLC. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following disclaimer -# in the documentation and/or other materials provided with the -# distribution. -# * Neither the name of Google LLC nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -"""Does google-lint on c++ files. - -The goal of this script is to identify places in the code that *may* -be in non-compliance with google style. It does not attempt to fix -up these problems -- the point is to educate. It does also not -attempt to find all problems, or to ensure that everything it does -find is legitimately a problem. - -In particular, we can get very confused by /* and // inside strings! -We do a small hack, which is to ignore //'s with "'s after them on the -same line, but it is far from perfect (in either direction). -""" - -import codecs -import copy -import getopt -import math # for log -import os -import re -import sre_compile -import string -import sys -import unicodedata -import sysconfig - -try: - xrange # Python 2 -except NameError: - xrange = range # Python 3 - - -_USAGE = """ -Syntax: cpplint.py [--verbose=#] [--output=vs7] [--filter=-x,+y,...] - [--counting=total|toplevel|detailed] [--root=subdir] - [--linelength=digits] [--headers=x,y,...] - [--quiet] - [file] ... - - The style guidelines this tries to follow are those in - https://google-styleguide.googlecode.com/svn/trunk/cppguide.xml - - Every problem is given a confidence score from 1-5, with 5 meaning we are - certain of the problem, and 1 meaning it could be a legitimate construct. - This will miss some errors, and is not a substitute for a code review. - - To suppress false-positive errors of a certain category, add a - 'NOLINT(category)' comment to the line. NOLINT or NOLINT(*) - suppresses errors of all categories on that line. - - The files passed in will be linted; at least one file must be provided. - Default linted extensions are .cc, .cpp, .cu, .cuh and .h. Change the - extensions with the --extensions flag. - - Flags: - - output=vs7 - By default, the output is formatted to ease emacs parsing. Visual Studio - compatible output (vs7) may also be used. Other formats are unsupported. - - verbose=# - Specify a number 0-5 to restrict errors to certain verbosity levels. - - quiet - Don't print anything if no errors are found. - - filter=-x,+y,... - Specify a comma-separated list of category-filters to apply: only - error messages whose category names pass the filters will be printed. - (Category names are printed with the message and look like - "[whitespace/indent]".) Filters are evaluated left to right. - "-FOO" and "FOO" means "do not print categories that start with FOO". - "+FOO" means "do print categories that start with FOO". - - Examples: --filter=-whitespace,+whitespace/braces - --filter=whitespace,runtime/printf,+runtime/printf_format - --filter=-,+build/include_what_you_use - - To see a list of all the categories used in cpplint, pass no arg: - --filter= - - counting=total|toplevel|detailed - The total number of errors found is always printed. If - 'toplevel' is provided, then the count of errors in each of - the top-level categories like 'build' and 'whitespace' will - also be printed. If 'detailed' is provided, then a count - is provided for each category like 'build/class'. - - root=subdir - The root directory used for deriving header guard CPP variable. - By default, the header guard CPP variable is calculated as the relative - path to the directory that contains .git, .hg, or .svn. When this flag - is specified, the relative path is calculated from the specified - directory. If the specified directory does not exist, this flag is - ignored. - - Examples: - Assuming that top/src/.git exists (and cwd=top/src), the header guard - CPP variables for top/src/chrome/browser/ui/browser.h are: - - No flag => CHROME_BROWSER_UI_BROWSER_H_ - --root=chrome => BROWSER_UI_BROWSER_H_ - --root=chrome/browser => UI_BROWSER_H_ - --root=.. => SRC_CHROME_BROWSER_UI_BROWSER_H_ - - linelength=digits - This is the allowed line length for the project. The default value is - 80 characters. - - Examples: - --linelength=120 - - extensions=extension,extension,... - The allowed file extensions that cpplint will check - - Examples: - --extensions=hpp,cpp - - headers=x,y,... - The header extensions that cpplint will treat as .h in checks. Values are - automatically added to --extensions list. - - Examples: - --headers=hpp,hxx - --headers=hpp - - cpplint.py supports per-directory configurations specified in CPPLINT.cfg - files. CPPLINT.cfg file can contain a number of key=value pairs. - Currently the following options are supported: - - set noparent - filter=+filter1,-filter2,... - exclude_files=regex - linelength=80 - root=subdir - headers=x,y,... - - "set noparent" option prevents cpplint from traversing directory tree - upwards looking for more .cfg files in parent directories. This option - is usually placed in the top-level project directory. - - The "filter" option is similar in function to --filter flag. It specifies - message filters in addition to the |_DEFAULT_FILTERS| and those specified - through --filter command-line flag. - - "exclude_files" allows to specify a regular expression to be matched against - a file name. If the expression matches, the file is skipped and not run - through liner. - - "linelength" allows to specify the allowed line length for the project. - - The "root" option is similar in function to the --root flag (see example - above). Paths are relative to the directory of the CPPLINT.cfg. - - The "headers" option is similar in function to the --headers flag - (see example above). - - CPPLINT.cfg has an effect on files in the same directory and all - sub-directories, unless overridden by a nested configuration file. - - Example file: - filter=-build/include_order,+build/include_alpha - exclude_files=.*\.cc - - The above example disables build/include_order warning and enables - build/include_alpha as well as excludes all .cc from being - processed by linter, in the current directory (where the .cfg - file is located) and all sub-directories. -""" - -# We categorize each error message we print. Here are the categories. -# We want an explicit list so we can list them all in cpplint --filter=. -# If you add a new error message with a new category, add it to the list -# here! cpplint_unittest.py should tell you if you forget to do this. -_ERROR_CATEGORIES = [ - 'build/class', - 'build/c++11', - 'build/c++14', - 'build/c++tr1', - 'build/deprecated', - 'build/endif_comment', - 'build/explicit_make_pair', - 'build/forward_decl', - 'build/header_guard', - 'build/include', - 'build/include_alpha', - 'build/include_order', - 'build/include_what_you_use', - 'build/namespaces', - 'build/printf_format', - 'build/storage_class', - 'legal/copyright', - 'readability/alt_tokens', - 'readability/braces', - 'readability/casting', - 'readability/check', - 'readability/constructors', - 'readability/fn_size', - 'readability/inheritance', - 'readability/multiline_comment', - 'readability/multiline_string', - 'readability/namespace', - 'readability/nolint', - 'readability/nul', - 'readability/strings', - 'readability/todo', - 'readability/utf8', - 'runtime/arrays', - 'runtime/casting', - 'runtime/explicit', - 'runtime/int', - 'runtime/init', - 'runtime/invalid_increment', - 'runtime/member_string_references', - 'runtime/memset', - 'runtime/indentation_namespace', - 'runtime/operator', - 'runtime/printf', - 'runtime/printf_format', - 'runtime/references', - 'runtime/string', - 'runtime/threadsafe_fn', - 'runtime/vlog', - 'whitespace/blank_line', - 'whitespace/braces', - 'whitespace/comma', - 'whitespace/comments', - 'whitespace/empty_conditional_body', - 'whitespace/empty_if_body', - 'whitespace/empty_loop_body', - 'whitespace/end_of_line', - 'whitespace/ending_newline', - 'whitespace/forcolon', - 'whitespace/indent', - 'whitespace/line_length', - 'whitespace/newline', - 'whitespace/operators', - 'whitespace/parens', - 'whitespace/semicolon', - 'whitespace/tab', - 'whitespace/todo', - ] - -# These error categories are no longer enforced by cpplint, but for backwards- -# compatibility they may still appear in NOLINT comments. -_LEGACY_ERROR_CATEGORIES = [ - 'readability/streams', - 'readability/function', - ] - -# The default state of the category filter. This is overridden by the --filter= -# flag. By default all errors are on, so only add here categories that should be -# off by default (i.e., categories that must be enabled by the --filter= flags). -# All entries here should start with a '-' or '+', as in the --filter= flag. -_DEFAULT_FILTERS = ['-build/include_alpha'] - -# The default list of categories suppressed for C (not C++) files. -_DEFAULT_C_SUPPRESSED_CATEGORIES = [ - 'readability/casting', - ] - -# The default list of categories suppressed for Linux Kernel files. -_DEFAULT_KERNEL_SUPPRESSED_CATEGORIES = [ - 'whitespace/tab', - ] - -# We used to check for high-bit characters, but after much discussion we -# decided those were OK, as long as they were in UTF-8 and didn't represent -# hard-coded international strings, which belong in a separate i18n file. - -# C++ headers -_CPP_HEADERS = frozenset([ - # Legacy - 'algobase.h', - 'algo.h', - 'alloc.h', - 'builtinbuf.h', - 'bvector.h', - 'complex.h', - 'defalloc.h', - 'deque.h', - 'editbuf.h', - 'fstream.h', - 'function.h', - 'hash_map', - 'hash_map.h', - 'hash_set', - 'hash_set.h', - 'hashtable.h', - 'heap.h', - 'indstream.h', - 'iomanip.h', - 'iostream.h', - 'istream.h', - 'iterator.h', - 'list.h', - 'map.h', - 'multimap.h', - 'multiset.h', - 'ostream.h', - 'pair.h', - 'parsestream.h', - 'pfstream.h', - 'procbuf.h', - 'pthread_alloc', - 'pthread_alloc.h', - 'rope', - 'rope.h', - 'ropeimpl.h', - 'set.h', - 'slist', - 'slist.h', - 'stack.h', - 'stdiostream.h', - 'stl_alloc.h', - 'stl_relops.h', - 'streambuf.h', - 'stream.h', - 'strfile.h', - 'strstream.h', - 'tempbuf.h', - 'tree.h', - 'type_traits.h', - 'vector.h', - # 17.6.1.2 C++ library headers - 'algorithm', - 'array', - 'atomic', - 'bitset', - 'chrono', - 'codecvt', - 'complex', - 'condition_variable', - 'deque', - 'exception', - 'forward_list', - 'fstream', - 'functional', - 'future', - 'initializer_list', - 'iomanip', - 'ios', - 'iosfwd', - 'iostream', - 'istream', - 'iterator', - 'limits', - 'list', - 'locale', - 'map', - 'memory', - 'mutex', - 'new', - 'numeric', - 'ostream', - 'queue', - 'random', - 'ratio', - 'regex', - 'scoped_allocator', - 'set', - 'sstream', - 'stack', - 'stdexcept', - 'streambuf', - 'string', - 'strstream', - 'system_error', - 'thread', - 'tuple', - 'typeindex', - 'typeinfo', - 'type_traits', - 'unordered_map', - 'unordered_set', - 'utility', - 'valarray', - 'vector', - # 17.6.1.2 C++ headers for C library facilities - 'cassert', - 'ccomplex', - 'cctype', - 'cerrno', - 'cfenv', - 'cfloat', - 'cinttypes', - 'ciso646', - 'climits', - 'clocale', - 'cmath', - 'csetjmp', - 'csignal', - 'cstdalign', - 'cstdarg', - 'cstdbool', - 'cstddef', - 'cstdint', - 'cstdio', - 'cstdlib', - 'cstring', - 'ctgmath', - 'ctime', - 'cuchar', - 'cwchar', - 'cwctype', - ]) - -# Type names -_TYPES = re.compile( - r'^(?:' - # [dcl.type.simple] - r'(char(16_t|32_t)?)|wchar_t|' - r'bool|short|int|long|signed|unsigned|float|double|' - # [support.types] - r'(ptrdiff_t|size_t|max_align_t|nullptr_t)|' - # [cstdint.syn] - r'(u?int(_fast|_least)?(8|16|32|64)_t)|' - r'(u?int(max|ptr)_t)|' - r')$') - - -# These headers are excluded from [build/include] and [build/include_order] -# checks: -# - Anything not following google file name conventions (containing an -# uppercase character, such as Python.h or nsStringAPI.h, for example). -# - Lua headers. -_THIRD_PARTY_HEADERS_PATTERN = re.compile( - r'^(?:[^/]*[A-Z][^/]*\.h|lua\.h|lauxlib\.h|lualib\.h)$') - -# Pattern for matching FileInfo.BaseName() against test file name -_TEST_FILE_SUFFIX = r'(_test|_unittest|_regtest)$' - -# Pattern that matches only complete whitespace, possibly across multiple lines. -_EMPTY_CONDITIONAL_BODY_PATTERN = re.compile(r'^\s*$', re.DOTALL) - -# Assertion macros. These are defined in base/logging.h and -# testing/base/public/gunit.h. -_CHECK_MACROS = [ - 'DCHECK', 'CHECK', - 'EXPECT_TRUE', 'ASSERT_TRUE', - 'EXPECT_FALSE', 'ASSERT_FALSE', - ] - -# Replacement macros for CHECK/DCHECK/EXPECT_TRUE/EXPECT_FALSE -_CHECK_REPLACEMENT = dict([(m, {}) for m in _CHECK_MACROS]) - -for op, replacement in [('==', 'EQ'), ('!=', 'NE'), - ('>=', 'GE'), ('>', 'GT'), - ('<=', 'LE'), ('<', 'LT')]: - _CHECK_REPLACEMENT['DCHECK'][op] = 'DCHECK_%s' % replacement - _CHECK_REPLACEMENT['CHECK'][op] = 'CHECK_%s' % replacement - _CHECK_REPLACEMENT['EXPECT_TRUE'][op] = 'EXPECT_%s' % replacement - _CHECK_REPLACEMENT['ASSERT_TRUE'][op] = 'ASSERT_%s' % replacement - -for op, inv_replacement in [('==', 'NE'), ('!=', 'EQ'), - ('>=', 'LT'), ('>', 'LE'), - ('<=', 'GT'), ('<', 'GE')]: - _CHECK_REPLACEMENT['EXPECT_FALSE'][op] = 'EXPECT_%s' % inv_replacement - _CHECK_REPLACEMENT['ASSERT_FALSE'][op] = 'ASSERT_%s' % inv_replacement - -# Alternative tokens and their replacements. For full list, see section 2.5 -# Alternative tokens [lex.digraph] in the C++ standard. -# -# Digraphs (such as '%:') are not included here since it's a mess to -# match those on a word boundary. -_ALT_TOKEN_REPLACEMENT = { - 'and': '&&', - 'bitor': '|', - 'or': '||', - 'xor': '^', - 'compl': '~', - 'bitand': '&', - 'and_eq': '&=', - 'or_eq': '|=', - 'xor_eq': '^=', - 'not': '!', - 'not_eq': '!=' - } - -# Compile regular expression that matches all the above keywords. The "[ =()]" -# bit is meant to avoid matching these keywords outside of boolean expressions. -# -# False positives include C-style multi-line comments and multi-line strings -# but those have always been troublesome for cpplint. -_ALT_TOKEN_REPLACEMENT_PATTERN = re.compile( - r'[ =()](' + ('|'.join(_ALT_TOKEN_REPLACEMENT.keys())) + r')(?=[ (]|$)') - - -# These constants define types of headers for use with -# _IncludeState.CheckNextIncludeOrder(). -_C_SYS_HEADER = 1 -_CPP_SYS_HEADER = 2 -_LIKELY_MY_HEADER = 3 -_POSSIBLE_MY_HEADER = 4 -_OTHER_HEADER = 5 - -# These constants define the current inline assembly state -_NO_ASM = 0 # Outside of inline assembly block -_INSIDE_ASM = 1 # Inside inline assembly block -_END_ASM = 2 # Last line of inline assembly block -_BLOCK_ASM = 3 # The whole block is an inline assembly block - -# Match start of assembly blocks -_MATCH_ASM = re.compile(r'^\s*(?:asm|_asm|__asm|__asm__)' - r'(?:\s+(volatile|__volatile__))?' - r'\s*[{(]') - -# Match strings that indicate we're working on a C (not C++) file. -_SEARCH_C_FILE = re.compile(r'\b(?:LINT_C_FILE|' - r'vim?:\s*.*(\s*|:)filetype=c(\s*|:|$))') - -# Match string that indicates we're working on a Linux Kernel file. -_SEARCH_KERNEL_FILE = re.compile(r'\b(?:LINT_KERNEL_FILE)') - -_regexp_compile_cache = {} - -# {str, set(int)}: a map from error categories to sets of linenumbers -# on which those errors are expected and should be suppressed. -_error_suppressions = {} - -# The root directory used for deriving header guard CPP variable. -# This is set by --root flag. -_root = None -_root_debug = False - -# The allowed line length of files. -# This is set by --linelength flag. -_line_length = 80 - -# The allowed extensions for file names -# This is set by --extensions flag. -_valid_extensions = set(['cc', 'h', 'cpp', 'cu', 'cuh']) - -# Treat all headers starting with 'h' equally: .h, .hpp, .hxx etc. -# This is set by --headers flag. -_hpp_headers = set(['h']) - -# {str, bool}: a map from error categories to booleans which indicate if the -# category should be suppressed for every line. -_global_error_suppressions = {} - -def ProcessHppHeadersOption(val): - global _hpp_headers - try: - _hpp_headers = set(val.split(',')) - # Automatically append to extensions list so it does not have to be set 2 times - _valid_extensions.update(_hpp_headers) - except ValueError: - PrintUsage('Header extensions must be comma separated list.') - -def IsHeaderExtension(file_extension): - return file_extension in _hpp_headers - -def ParseNolintSuppressions(filename, raw_line, linenum, error): - """Updates the global list of line error-suppressions. - - Parses any NOLINT comments on the current line, updating the global - error_suppressions store. Reports an error if the NOLINT comment - was malformed. - - Args: - filename: str, the name of the input file. - raw_line: str, the line of input text, with comments. - linenum: int, the number of the current line. - error: function, an error handler. - """ - matched = Search(r'\bNOLINT(NEXTLINE)?\b(\([^)]+\))?', raw_line) - if matched: - if matched.group(1): - suppressed_line = linenum + 1 - else: - suppressed_line = linenum - category = matched.group(2) - if category in (None, '(*)'): # => "suppress all" - _error_suppressions.setdefault(None, set()).add(suppressed_line) - else: - if category.startswith('(') and category.endswith(')'): - category = category[1:-1] - if category in _ERROR_CATEGORIES: - _error_suppressions.setdefault(category, set()).add(suppressed_line) - elif category not in _LEGACY_ERROR_CATEGORIES: - error(filename, linenum, 'readability/nolint', 5, - 'Unknown NOLINT error category: %s' % category) - - -def ProcessGlobalSuppresions(lines): - """Updates the list of global error suppressions. - - Parses any lint directives in the file that have global effect. - - Args: - lines: An array of strings, each representing a line of the file, with the - last element being empty if the file is terminated with a newline. - """ - for line in lines: - if _SEARCH_C_FILE.search(line): - for category in _DEFAULT_C_SUPPRESSED_CATEGORIES: - _global_error_suppressions[category] = True - if _SEARCH_KERNEL_FILE.search(line): - for category in _DEFAULT_KERNEL_SUPPRESSED_CATEGORIES: - _global_error_suppressions[category] = True - - -def ResetNolintSuppressions(): - """Resets the set of NOLINT suppressions to empty.""" - _error_suppressions.clear() - _global_error_suppressions.clear() - - -def IsErrorSuppressedByNolint(category, linenum): - """Returns true if the specified error category is suppressed on this line. - - Consults the global error_suppressions map populated by - ParseNolintSuppressions/ProcessGlobalSuppresions/ResetNolintSuppressions. - - Args: - category: str, the category of the error. - linenum: int, the current line number. - Returns: - bool, True iff the error should be suppressed due to a NOLINT comment or - global suppression. - """ - return (_global_error_suppressions.get(category, False) or - linenum in _error_suppressions.get(category, set()) or - linenum in _error_suppressions.get(None, set())) - - -def Match(pattern, s): - """Matches the string with the pattern, caching the compiled regexp.""" - # The regexp compilation caching is inlined in both Match and Search for - # performance reasons; factoring it out into a separate function turns out - # to be noticeably expensive. - if pattern not in _regexp_compile_cache: - _regexp_compile_cache[pattern] = sre_compile.compile(pattern) - return _regexp_compile_cache[pattern].match(s) - - -def ReplaceAll(pattern, rep, s): - """Replaces instances of pattern in a string with a replacement. - - The compiled regex is kept in a cache shared by Match and Search. - - Args: - pattern: regex pattern - rep: replacement text - s: search string - - Returns: - string with replacements made (or original string if no replacements) - """ - if pattern not in _regexp_compile_cache: - _regexp_compile_cache[pattern] = sre_compile.compile(pattern) - return _regexp_compile_cache[pattern].sub(rep, s) - - -def Search(pattern, s): - """Searches the string for the pattern, caching the compiled regexp.""" - if pattern not in _regexp_compile_cache: - _regexp_compile_cache[pattern] = sre_compile.compile(pattern) - return _regexp_compile_cache[pattern].search(s) - - -def _IsSourceExtension(s): - """File extension (excluding dot) matches a source file extension.""" - return s in ('c', 'cc', 'cpp', 'cxx') - - -class _IncludeState(object): - """Tracks line numbers for includes, and the order in which includes appear. - - include_list contains list of lists of (header, line number) pairs. - It's a lists of lists rather than just one flat list to make it - easier to update across preprocessor boundaries. - - Call CheckNextIncludeOrder() once for each header in the file, passing - in the type constants defined above. Calls in an illegal order will - raise an _IncludeError with an appropriate error message. - - """ - # self._section will move monotonically through this set. If it ever - # needs to move backwards, CheckNextIncludeOrder will raise an error. - _INITIAL_SECTION = 0 - _MY_H_SECTION = 1 - _C_SECTION = 2 - _CPP_SECTION = 3 - _OTHER_H_SECTION = 4 - - _TYPE_NAMES = { - _C_SYS_HEADER: 'C system header', - _CPP_SYS_HEADER: 'C++ system header', - _LIKELY_MY_HEADER: 'header this file implements', - _POSSIBLE_MY_HEADER: 'header this file may implement', - _OTHER_HEADER: 'other header', - } - _SECTION_NAMES = { - _INITIAL_SECTION: "... nothing. (This can't be an error.)", - _MY_H_SECTION: 'a header this file implements', - _C_SECTION: 'C system header', - _CPP_SECTION: 'C++ system header', - _OTHER_H_SECTION: 'other header', - } - - def __init__(self): - self.include_list = [[]] - self.ResetSection('') - - def FindHeader(self, header): - """Check if a header has already been included. - - Args: - header: header to check. - Returns: - Line number of previous occurrence, or -1 if the header has not - been seen before. - """ - for section_list in self.include_list: - for f in section_list: - if f[0] == header: - return f[1] - return -1 - - def ResetSection(self, directive): - """Reset section checking for preprocessor directive. - - Args: - directive: preprocessor directive (e.g. "if", "else"). - """ - # The name of the current section. - self._section = self._INITIAL_SECTION - # The path of last found header. - self._last_header = '' - - # Update list of includes. Note that we never pop from the - # include list. - if directive in ('if', 'ifdef', 'ifndef'): - self.include_list.append([]) - elif directive in ('else', 'elif'): - self.include_list[-1] = [] - - def SetLastHeader(self, header_path): - self._last_header = header_path - - def CanonicalizeAlphabeticalOrder(self, header_path): - """Returns a path canonicalized for alphabetical comparison. - - - replaces "-" with "_" so they both cmp the same. - - removes '-inl' since we don't require them to be after the main header. - - lowercase everything, just in case. - - Args: - header_path: Path to be canonicalized. - - Returns: - Canonicalized path. - """ - return header_path.replace('-inl.h', '.h').replace('-', '_').lower() - - def IsInAlphabeticalOrder(self, clean_lines, linenum, header_path): - """Check if a header is in alphabetical order with the previous header. - - Args: - clean_lines: A CleansedLines instance containing the file. - linenum: The number of the line to check. - header_path: Canonicalized header to be checked. - - Returns: - Returns true if the header is in alphabetical order. - """ - # If previous section is different from current section, _last_header will - # be reset to empty string, so it's always less than current header. - # - # If previous line was a blank line, assume that the headers are - # intentionally sorted the way they are. - if (self._last_header > header_path and - Match(r'^\s*#\s*include\b', clean_lines.elided[linenum - 1])): - return False - return True - - def CheckNextIncludeOrder(self, header_type): - """Returns a non-empty error message if the next header is out of order. - - This function also updates the internal state to be ready to check - the next include. - - Args: - header_type: One of the _XXX_HEADER constants defined above. - - Returns: - The empty string if the header is in the right order, or an - error message describing what's wrong. - - """ - error_message = ('Found %s after %s' % - (self._TYPE_NAMES[header_type], - self._SECTION_NAMES[self._section])) - - last_section = self._section - - if header_type == _C_SYS_HEADER: - if self._section <= self._C_SECTION: - self._section = self._C_SECTION - else: - self._last_header = '' - return error_message - elif header_type == _CPP_SYS_HEADER: - if self._section <= self._CPP_SECTION: - self._section = self._CPP_SECTION - else: - self._last_header = '' - return error_message - elif header_type == _LIKELY_MY_HEADER: - if self._section <= self._MY_H_SECTION: - self._section = self._MY_H_SECTION - else: - self._section = self._OTHER_H_SECTION - elif header_type == _POSSIBLE_MY_HEADER: - if self._section <= self._MY_H_SECTION: - self._section = self._MY_H_SECTION - else: - # This will always be the fallback because we're not sure - # enough that the header is associated with this file. - self._section = self._OTHER_H_SECTION - else: - assert header_type == _OTHER_HEADER - self._section = self._OTHER_H_SECTION - - if last_section != self._section: - self._last_header = '' - - return '' - - -class _CppLintState(object): - """Maintains module-wide state..""" - - def __init__(self): - self.verbose_level = 1 # global setting. - self.error_count = 0 # global count of reported errors - # filters to apply when emitting error messages - self.filters = _DEFAULT_FILTERS[:] - # backup of filter list. Used to restore the state after each file. - self._filters_backup = self.filters[:] - self.counting = 'total' # In what way are we counting errors? - self.errors_by_category = {} # string to int dict storing error counts - self.quiet = False # Suppress non-error messagess? - - # output format: - # "emacs" - format that emacs can parse (default) - # "vs7" - format that Microsoft Visual Studio 7 can parse - self.output_format = 'emacs' - - def SetOutputFormat(self, output_format): - """Sets the output format for errors.""" - self.output_format = output_format - - def SetQuiet(self, quiet): - """Sets the module's quiet settings, and returns the previous setting.""" - last_quiet = self.quiet - self.quiet = quiet - return last_quiet - - def SetVerboseLevel(self, level): - """Sets the module's verbosity, and returns the previous setting.""" - last_verbose_level = self.verbose_level - self.verbose_level = level - return last_verbose_level - - def SetCountingStyle(self, counting_style): - """Sets the module's counting options.""" - self.counting = counting_style - - def SetFilters(self, filters): - """Sets the error-message filters. - - These filters are applied when deciding whether to emit a given - error message. - - Args: - filters: A string of comma-separated filters (eg "+whitespace/indent"). - Each filter should start with + or -; else we die. - - Raises: - ValueError: The comma-separated filters did not all start with '+' or '-'. - E.g. "-,+whitespace,-whitespace/indent,whitespace/badfilter" - """ - # Default filters always have less priority than the flag ones. - self.filters = _DEFAULT_FILTERS[:] - self.AddFilters(filters) - - def AddFilters(self, filters): - """ Adds more filters to the existing list of error-message filters. """ - for filt in filters.split(','): - clean_filt = filt.strip() - if clean_filt: - self.filters.append(clean_filt) - for filt in self.filters: - if not (filt.startswith('+') or filt.startswith('-')): - raise ValueError('Every filter in --filters must start with + or -' - ' (%s does not)' % filt) - - def BackupFilters(self): - """ Saves the current filter list to backup storage.""" - self._filters_backup = self.filters[:] - - def RestoreFilters(self): - """ Restores filters previously backed up.""" - self.filters = self._filters_backup[:] - - def ResetErrorCounts(self): - """Sets the module's error statistic back to zero.""" - self.error_count = 0 - self.errors_by_category = {} - - def IncrementErrorCount(self, category): - """Bumps the module's error statistic.""" - self.error_count += 1 - if self.counting in ('toplevel', 'detailed'): - if self.counting != 'detailed': - category = category.split('/')[0] - if category not in self.errors_by_category: - self.errors_by_category[category] = 0 - self.errors_by_category[category] += 1 - - def PrintErrorCounts(self): - """Print a summary of errors by category, and the total.""" - for category, count in self.errors_by_category.iteritems(): - sys.stderr.write('Category \'%s\' errors found: %d\n' % - (category, count)) - sys.stdout.write('Total errors found: %d\n' % self.error_count) - -_cpplint_state = _CppLintState() - - -def _OutputFormat(): - """Gets the module's output format.""" - return _cpplint_state.output_format - - -def _SetOutputFormat(output_format): - """Sets the module's output format.""" - _cpplint_state.SetOutputFormat(output_format) - -def _Quiet(): - """Return's the module's quiet setting.""" - return _cpplint_state.quiet - -def _SetQuiet(quiet): - """Set the module's quiet status, and return previous setting.""" - return _cpplint_state.SetQuiet(quiet) - - -def _VerboseLevel(): - """Returns the module's verbosity setting.""" - return _cpplint_state.verbose_level - - -def _SetVerboseLevel(level): - """Sets the module's verbosity, and returns the previous setting.""" - return _cpplint_state.SetVerboseLevel(level) - - -def _SetCountingStyle(level): - """Sets the module's counting options.""" - _cpplint_state.SetCountingStyle(level) - - -def _Filters(): - """Returns the module's list of output filters, as a list.""" - return _cpplint_state.filters - - -def _SetFilters(filters): - """Sets the module's error-message filters. - - These filters are applied when deciding whether to emit a given - error message. - - Args: - filters: A string of comma-separated filters (eg "whitespace/indent"). - Each filter should start with + or -; else we die. - """ - _cpplint_state.SetFilters(filters) - -def _AddFilters(filters): - """Adds more filter overrides. - - Unlike _SetFilters, this function does not reset the current list of filters - available. - - Args: - filters: A string of comma-separated filters (eg "whitespace/indent"). - Each filter should start with + or -; else we die. - """ - _cpplint_state.AddFilters(filters) - -def _BackupFilters(): - """ Saves the current filter list to backup storage.""" - _cpplint_state.BackupFilters() - -def _RestoreFilters(): - """ Restores filters previously backed up.""" - _cpplint_state.RestoreFilters() - -class _FunctionState(object): - """Tracks current function name and the number of lines in its body.""" - - _NORMAL_TRIGGER = 250 # for --v=0, 500 for --v=1, etc. - _TEST_TRIGGER = 400 # about 50% more than _NORMAL_TRIGGER. - - def __init__(self): - self.in_a_function = False - self.lines_in_function = 0 - self.current_function = '' - - def Begin(self, function_name): - """Start analyzing function body. - - Args: - function_name: The name of the function being tracked. - """ - self.in_a_function = True - self.lines_in_function = 0 - self.current_function = function_name - - def Count(self): - """Count line in current function body.""" - if self.in_a_function: - self.lines_in_function += 1 - - def Check(self, error, filename, linenum): - """Report if too many lines in function body. - - Args: - error: The function to call with any errors found. - filename: The name of the current file. - linenum: The number of the line to check. - """ - if not self.in_a_function: - return - - if Match(r'T(EST|est)', self.current_function): - base_trigger = self._TEST_TRIGGER - else: - base_trigger = self._NORMAL_TRIGGER - trigger = base_trigger * 2**_VerboseLevel() - - if self.lines_in_function > trigger: - error_level = int(math.log(self.lines_in_function / base_trigger, 2)) - # 50 => 0, 100 => 1, 200 => 2, 400 => 3, 800 => 4, 1600 => 5, ... - if error_level > 5: - error_level = 5 - error(filename, linenum, 'readability/fn_size', error_level, - 'Small and focused functions are preferred:' - ' %s has %d non-comment lines' - ' (error triggered by exceeding %d lines).' % ( - self.current_function, self.lines_in_function, trigger)) - - def End(self): - """Stop analyzing function body.""" - self.in_a_function = False - - -class _IncludeError(Exception): - """Indicates a problem with the include order in a file.""" - pass - - -class FileInfo(object): - """Provides utility functions for filenames. - - FileInfo provides easy access to the components of a file's path - relative to the project root. - """ - - def __init__(self, filename): - self._filename = filename - - def FullName(self): - """Make Windows paths like Unix.""" - return os.path.abspath(self._filename).replace('\\', '/') - - def RepositoryName(self): - """FullName after removing the local path to the repository. - - If we have a real absolute path name here we can try to do something smart: - detecting the root of the checkout and truncating /path/to/checkout from - the name so that we get header guards that don't include things like - "C:\Documents and Settings\..." or "/home/username/..." in them and thus - people on different computers who have checked the source out to different - locations won't see bogus errors. - """ - fullname = self.FullName() - - if os.path.exists(fullname): - project_dir = os.path.dirname(fullname) - - if os.path.exists(os.path.join(project_dir, ".svn")): - # If there's a .svn file in the current directory, we recursively look - # up the directory tree for the top of the SVN checkout - root_dir = project_dir - one_up_dir = os.path.dirname(root_dir) - while os.path.exists(os.path.join(one_up_dir, ".svn")): - root_dir = os.path.dirname(root_dir) - one_up_dir = os.path.dirname(one_up_dir) - - prefix = os.path.commonprefix([root_dir, project_dir]) - return fullname[len(prefix) + 1:] - - # Not SVN <= 1.6? Try to find a git, hg, or svn top level directory by - # searching up from the current path. - root_dir = current_dir = os.path.dirname(fullname) - while current_dir != os.path.dirname(current_dir): - if (os.path.exists(os.path.join(current_dir, ".git")) or - os.path.exists(os.path.join(current_dir, ".hg")) or - os.path.exists(os.path.join(current_dir, ".svn"))): - root_dir = current_dir - current_dir = os.path.dirname(current_dir) - - if (os.path.exists(os.path.join(root_dir, ".git")) or - os.path.exists(os.path.join(root_dir, ".hg")) or - os.path.exists(os.path.join(root_dir, ".svn"))): - prefix = os.path.commonprefix([root_dir, project_dir]) - return fullname[len(prefix) + 1:] - - # Don't know what to do; header guard warnings may be wrong... - return fullname - - def Split(self): - """Splits the file into the directory, basename, and extension. - - For 'chrome/browser/browser.cc', Split() would - return ('chrome/browser', 'browser', '.cc') - - Returns: - A tuple of (directory, basename, extension). - """ - - googlename = self.RepositoryName() - project, rest = os.path.split(googlename) - return (project,) + os.path.splitext(rest) - - def BaseName(self): - """File base name - text after the final slash, before the final period.""" - return self.Split()[1] - - def Extension(self): - """File extension - text following the final period.""" - return self.Split()[2] - - def NoExtension(self): - """File has no source file extension.""" - return '/'.join(self.Split()[0:2]) - - def IsSource(self): - """File has a source file extension.""" - return _IsSourceExtension(self.Extension()[1:]) - - -def _ShouldPrintError(category, confidence, linenum): - """If confidence >= verbose, category passes filter and is not suppressed.""" - - # There are three ways we might decide not to print an error message: - # a "NOLINT(category)" comment appears in the source, - # the verbosity level isn't high enough, or the filters filter it out. - if IsErrorSuppressedByNolint(category, linenum): - return False - - if confidence < _cpplint_state.verbose_level: - return False - - is_filtered = False - for one_filter in _Filters(): - if one_filter.startswith('-'): - if category.startswith(one_filter[1:]): - is_filtered = True - elif one_filter.startswith('+'): - if category.startswith(one_filter[1:]): - is_filtered = False - else: - assert False # should have been checked for in SetFilter. - if is_filtered: - return False - - return True - - -def Error(filename, linenum, category, confidence, message): - """Logs the fact we've found a lint error. - - We log where the error was found, and also our confidence in the error, - that is, how certain we are this is a legitimate style regression, and - not a misidentification or a use that's sometimes justified. - - False positives can be suppressed by the use of - "cpplint(category)" comments on the offending line. These are - parsed into _error_suppressions. - - Args: - filename: The name of the file containing the error. - linenum: The number of the line containing the error. - category: A string used to describe the "category" this bug - falls under: "whitespace", say, or "runtime". Categories - may have a hierarchy separated by slashes: "whitespace/indent". - confidence: A number from 1-5 representing a confidence score for - the error, with 5 meaning that we are certain of the problem, - and 1 meaning that it could be a legitimate construct. - message: The error message. - """ - if _ShouldPrintError(category, confidence, linenum): - _cpplint_state.IncrementErrorCount(category) - if _cpplint_state.output_format == 'vs7': - sys.stderr.write('%s(%s): error cpplint: [%s] %s [%d]\n' % ( - filename, linenum, category, message, confidence)) - elif _cpplint_state.output_format == 'eclipse': - sys.stderr.write('%s:%s: warning: %s [%s] [%d]\n' % ( - filename, linenum, message, category, confidence)) - else: - sys.stderr.write('%s:%s: %s [%s] [%d]\n' % ( - filename, linenum, message, category, confidence)) - - -# Matches standard C++ escape sequences per 2.13.2.3 of the C++ standard. -_RE_PATTERN_CLEANSE_LINE_ESCAPES = re.compile( - r'\\([abfnrtv?"\\\']|\d+|x[0-9a-fA-F]+)') -# Match a single C style comment on the same line. -_RE_PATTERN_C_COMMENTS = r'/\*(?:[^*]|\*(?!/))*\*/' -# Matches multi-line C style comments. -# This RE is a little bit more complicated than one might expect, because we -# have to take care of space removals tools so we can handle comments inside -# statements better. -# The current rule is: We only clear spaces from both sides when we're at the -# end of the line. Otherwise, we try to remove spaces from the right side, -# if this doesn't work we try on left side but only if there's a non-character -# on the right. -_RE_PATTERN_CLEANSE_LINE_C_COMMENTS = re.compile( - r'(\s*' + _RE_PATTERN_C_COMMENTS + r'\s*$|' + - _RE_PATTERN_C_COMMENTS + r'\s+|' + - r'\s+' + _RE_PATTERN_C_COMMENTS + r'(?=\W)|' + - _RE_PATTERN_C_COMMENTS + r')') - - -def IsCppString(line): - """Does line terminate so, that the next symbol is in string constant. - - This function does not consider single-line nor multi-line comments. - - Args: - line: is a partial line of code starting from the 0..n. - - Returns: - True, if next character appended to 'line' is inside a - string constant. - """ - - line = line.replace(r'\\', 'XX') # after this, \\" does not match to \" - return ((line.count('"') - line.count(r'\"') - line.count("'\"'")) & 1) == 1 - - -def CleanseRawStrings(raw_lines): - """Removes C++11 raw strings from lines. - - Before: - static const char kData[] = R"( - multi-line string - )"; - - After: - static const char kData[] = "" - (replaced by blank line) - ""; - - Args: - raw_lines: list of raw lines. - - Returns: - list of lines with C++11 raw strings replaced by empty strings. - """ - - delimiter = None - lines_without_raw_strings = [] - for line in raw_lines: - if delimiter: - # Inside a raw string, look for the end - end = line.find(delimiter) - if end >= 0: - # Found the end of the string, match leading space for this - # line and resume copying the original lines, and also insert - # a "" on the last line. - leading_space = Match(r'^(\s*)\S', line) - line = leading_space.group(1) + '""' + line[end + len(delimiter):] - delimiter = None - else: - # Haven't found the end yet, append a blank line. - line = '""' - - # Look for beginning of a raw string, and replace them with - # empty strings. This is done in a loop to handle multiple raw - # strings on the same line. - while delimiter is None: - # Look for beginning of a raw string. - # See 2.14.15 [lex.string] for syntax. - # - # Once we have matched a raw string, we check the prefix of the - # line to make sure that the line is not part of a single line - # comment. It's done this way because we remove raw strings - # before removing comments as opposed to removing comments - # before removing raw strings. This is because there are some - # cpplint checks that requires the comments to be preserved, but - # we don't want to check comments that are inside raw strings. - matched = Match(r'^(.*?)\b(?:R|u8R|uR|UR|LR)"([^\s\\()]*)\((.*)$', line) - if (matched and - not Match(r'^([^\'"]|\'(\\.|[^\'])*\'|"(\\.|[^"])*")*//', - matched.group(1))): - delimiter = ')' + matched.group(2) + '"' - - end = matched.group(3).find(delimiter) - if end >= 0: - # Raw string ended on same line - line = (matched.group(1) + '""' + - matched.group(3)[end + len(delimiter):]) - delimiter = None - else: - # Start of a multi-line raw string - line = matched.group(1) + '""' - else: - break - - lines_without_raw_strings.append(line) - - # TODO(unknown): if delimiter is not None here, we might want to - # emit a warning for unterminated string. - return lines_without_raw_strings - - -def FindNextMultiLineCommentStart(lines, lineix): - """Find the beginning marker for a multiline comment.""" - while lineix < len(lines): - if lines[lineix].strip().startswith('/*'): - # Only return this marker if the comment goes beyond this line - if lines[lineix].strip().find('*/', 2) < 0: - return lineix - lineix += 1 - return len(lines) - - -def FindNextMultiLineCommentEnd(lines, lineix): - """We are inside a comment, find the end marker.""" - while lineix < len(lines): - if lines[lineix].strip().endswith('*/'): - return lineix - lineix += 1 - return len(lines) - - -def RemoveMultiLineCommentsFromRange(lines, begin, end): - """Clears a range of lines for multi-line comments.""" - # Having // dummy comments makes the lines non-empty, so we will not get - # unnecessary blank line warnings later in the code. - for i in range(begin, end): - lines[i] = '/**/' - - -def RemoveMultiLineComments(filename, lines, error): - """Removes multiline (c-style) comments from lines.""" - lineix = 0 - while lineix < len(lines): - lineix_begin = FindNextMultiLineCommentStart(lines, lineix) - if lineix_begin >= len(lines): - return - lineix_end = FindNextMultiLineCommentEnd(lines, lineix_begin) - if lineix_end >= len(lines): - error(filename, lineix_begin + 1, 'readability/multiline_comment', 5, - 'Could not find end of multi-line comment') - return - RemoveMultiLineCommentsFromRange(lines, lineix_begin, lineix_end + 1) - lineix = lineix_end + 1 - - -def CleanseComments(line): - """Removes //-comments and single-line C-style /* */ comments. - - Args: - line: A line of C++ source. - - Returns: - The line with single-line comments removed. - """ - commentpos = line.find('//') - if commentpos != -1 and not IsCppString(line[:commentpos]): - line = line[:commentpos].rstrip() - # get rid of /* ... */ - return _RE_PATTERN_CLEANSE_LINE_C_COMMENTS.sub('', line) - - -class CleansedLines(object): - """Holds 4 copies of all lines with different preprocessing applied to them. - - 1) elided member contains lines without strings and comments. - 2) lines member contains lines without comments. - 3) raw_lines member contains all the lines without processing. - 4) lines_without_raw_strings member is same as raw_lines, but with C++11 raw - strings removed. - All these members are of , and of the same length. - """ - - def __init__(self, lines): - self.elided = [] - self.lines = [] - self.raw_lines = lines - self.num_lines = len(lines) - self.lines_without_raw_strings = CleanseRawStrings(lines) - for linenum in range(len(self.lines_without_raw_strings)): - self.lines.append(CleanseComments( - self.lines_without_raw_strings[linenum])) - elided = self._CollapseStrings(self.lines_without_raw_strings[linenum]) - self.elided.append(CleanseComments(elided)) - - def NumLines(self): - """Returns the number of lines represented.""" - return self.num_lines - - @staticmethod - def _CollapseStrings(elided): - """Collapses strings and chars on a line to simple "" or '' blocks. - - We nix strings first so we're not fooled by text like '"http://"' - - Args: - elided: The line being processed. - - Returns: - The line with collapsed strings. - """ - if _RE_PATTERN_INCLUDE.match(elided): - return elided - - # Remove escaped characters first to make quote/single quote collapsing - # basic. Things that look like escaped characters shouldn't occur - # outside of strings and chars. - elided = _RE_PATTERN_CLEANSE_LINE_ESCAPES.sub('', elided) - - # Replace quoted strings and digit separators. Both single quotes - # and double quotes are processed in the same loop, otherwise - # nested quotes wouldn't work. - collapsed = '' - while True: - # Find the first quote character - match = Match(r'^([^\'"]*)([\'"])(.*)$', elided) - if not match: - collapsed += elided - break - head, quote, tail = match.groups() - - if quote == '"': - # Collapse double quoted strings - second_quote = tail.find('"') - if second_quote >= 0: - collapsed += head + '""' - elided = tail[second_quote + 1:] - else: - # Unmatched double quote, don't bother processing the rest - # of the line since this is probably a multiline string. - collapsed += elided - break - else: - # Found single quote, check nearby text to eliminate digit separators. - # - # There is no special handling for floating point here, because - # the integer/fractional/exponent parts would all be parsed - # correctly as long as there are digits on both sides of the - # separator. So we are fine as long as we don't see something - # like "0.'3" (gcc 4.9.0 will not allow this literal). - if Search(r'\b(?:0[bBxX]?|[1-9])[0-9a-fA-F]*$', head): - match_literal = Match(r'^((?:\'?[0-9a-zA-Z_])*)(.*)$', "'" + tail) - collapsed += head + match_literal.group(1).replace("'", '') - elided = match_literal.group(2) - else: - second_quote = tail.find('\'') - if second_quote >= 0: - collapsed += head + "''" - elided = tail[second_quote + 1:] - else: - # Unmatched single quote - collapsed += elided - break - - return collapsed - - -def FindEndOfExpressionInLine(line, startpos, stack): - """Find the position just after the end of current parenthesized expression. - - Args: - line: a CleansedLines line. - startpos: start searching at this position. - stack: nesting stack at startpos. - - Returns: - On finding matching end: (index just after matching end, None) - On finding an unclosed expression: (-1, None) - Otherwise: (-1, new stack at end of this line) - """ - for i in xrange(startpos, len(line)): - char = line[i] - if char in '([{': - # Found start of parenthesized expression, push to expression stack - stack.append(char) - elif char == '<': - # Found potential start of template argument list - if i > 0 and line[i - 1] == '<': - # Left shift operator - if stack and stack[-1] == '<': - stack.pop() - if not stack: - return (-1, None) - elif i > 0 and Search(r'\boperator\s*$', line[0:i]): - # operator<, don't add to stack - continue - else: - # Tentative start of template argument list - stack.append('<') - elif char in ')]}': - # Found end of parenthesized expression. - # - # If we are currently expecting a matching '>', the pending '<' - # must have been an operator. Remove them from expression stack. - while stack and stack[-1] == '<': - stack.pop() - if not stack: - return (-1, None) - if ((stack[-1] == '(' and char == ')') or - (stack[-1] == '[' and char == ']') or - (stack[-1] == '{' and char == '}')): - stack.pop() - if not stack: - return (i + 1, None) - else: - # Mismatched parentheses - return (-1, None) - elif char == '>': - # Found potential end of template argument list. - - # Ignore "->" and operator functions - if (i > 0 and - (line[i - 1] == '-' or Search(r'\boperator\s*$', line[0:i - 1]))): - continue - - # Pop the stack if there is a matching '<'. Otherwise, ignore - # this '>' since it must be an operator. - if stack: - if stack[-1] == '<': - stack.pop() - if not stack: - return (i + 1, None) - elif char == ';': - # Found something that look like end of statements. If we are currently - # expecting a '>', the matching '<' must have been an operator, since - # template argument list should not contain statements. - while stack and stack[-1] == '<': - stack.pop() - if not stack: - return (-1, None) - - # Did not find end of expression or unbalanced parentheses on this line - return (-1, stack) - - -def CloseExpression(clean_lines, linenum, pos): - """If input points to ( or { or [ or <, finds the position that closes it. - - If lines[linenum][pos] points to a '(' or '{' or '[' or '<', finds the - linenum/pos that correspond to the closing of the expression. - - TODO(unknown): cpplint spends a fair bit of time matching parentheses. - Ideally we would want to index all opening and closing parentheses once - and have CloseExpression be just a simple lookup, but due to preprocessor - tricks, this is not so easy. - - Args: - clean_lines: A CleansedLines instance containing the file. - linenum: The number of the line to check. - pos: A position on the line. - - Returns: - A tuple (line, linenum, pos) pointer *past* the closing brace, or - (line, len(lines), -1) if we never find a close. Note we ignore - strings and comments when matching; and the line we return is the - 'cleansed' line at linenum. - """ - - line = clean_lines.elided[linenum] - if (line[pos] not in '({[<') or Match(r'<[<=]', line[pos:]): - return (line, clean_lines.NumLines(), -1) - - # Check first line - (end_pos, stack) = FindEndOfExpressionInLine(line, pos, []) - if end_pos > -1: - return (line, linenum, end_pos) - - # Continue scanning forward - while stack and linenum < clean_lines.NumLines() - 1: - linenum += 1 - line = clean_lines.elided[linenum] - (end_pos, stack) = FindEndOfExpressionInLine(line, 0, stack) - if end_pos > -1: - return (line, linenum, end_pos) - - # Did not find end of expression before end of file, give up - return (line, clean_lines.NumLines(), -1) - - -def FindStartOfExpressionInLine(line, endpos, stack): - """Find position at the matching start of current expression. - - This is almost the reverse of FindEndOfExpressionInLine, but note - that the input position and returned position differs by 1. - - Args: - line: a CleansedLines line. - endpos: start searching at this position. - stack: nesting stack at endpos. - - Returns: - On finding matching start: (index at matching start, None) - On finding an unclosed expression: (-1, None) - Otherwise: (-1, new stack at beginning of this line) - """ - i = endpos - while i >= 0: - char = line[i] - if char in ')]}': - # Found end of expression, push to expression stack - stack.append(char) - elif char == '>': - # Found potential end of template argument list. - # - # Ignore it if it's a "->" or ">=" or "operator>" - if (i > 0 and - (line[i - 1] == '-' or - Match(r'\s>=\s', line[i - 1:]) or - Search(r'\boperator\s*$', line[0:i]))): - i -= 1 - else: - stack.append('>') - elif char == '<': - # Found potential start of template argument list - if i > 0 and line[i - 1] == '<': - # Left shift operator - i -= 1 - else: - # If there is a matching '>', we can pop the expression stack. - # Otherwise, ignore this '<' since it must be an operator. - if stack and stack[-1] == '>': - stack.pop() - if not stack: - return (i, None) - elif char in '([{': - # Found start of expression. - # - # If there are any unmatched '>' on the stack, they must be - # operators. Remove those. - while stack and stack[-1] == '>': - stack.pop() - if not stack: - return (-1, None) - if ((char == '(' and stack[-1] == ')') or - (char == '[' and stack[-1] == ']') or - (char == '{' and stack[-1] == '}')): - stack.pop() - if not stack: - return (i, None) - else: - # Mismatched parentheses - return (-1, None) - elif char == ';': - # Found something that look like end of statements. If we are currently - # expecting a '<', the matching '>' must have been an operator, since - # template argument list should not contain statements. - while stack and stack[-1] == '>': - stack.pop() - if not stack: - return (-1, None) - - i -= 1 - - return (-1, stack) - - -def ReverseCloseExpression(clean_lines, linenum, pos): - """If input points to ) or } or ] or >, finds the position that opens it. - - If lines[linenum][pos] points to a ')' or '}' or ']' or '>', finds the - linenum/pos that correspond to the opening of the expression. - - Args: - clean_lines: A CleansedLines instance containing the file. - linenum: The number of the line to check. - pos: A position on the line. - - Returns: - A tuple (line, linenum, pos) pointer *at* the opening brace, or - (line, 0, -1) if we never find the matching opening brace. Note - we ignore strings and comments when matching; and the line we - return is the 'cleansed' line at linenum. - """ - line = clean_lines.elided[linenum] - if line[pos] not in ')}]>': - return (line, 0, -1) - - # Check last line - (start_pos, stack) = FindStartOfExpressionInLine(line, pos, []) - if start_pos > -1: - return (line, linenum, start_pos) - - # Continue scanning backward - while stack and linenum > 0: - linenum -= 1 - line = clean_lines.elided[linenum] - (start_pos, stack) = FindStartOfExpressionInLine(line, len(line) - 1, stack) - if start_pos > -1: - return (line, linenum, start_pos) - - # Did not find start of expression before beginning of file, give up - return (line, 0, -1) - - -def CheckForCopyright(filename, lines, error): - """Logs an error if no Copyright message appears at the top of the file.""" - - # We'll say it should occur by line 10. Don't forget there's a - # dummy line at the front. - for line in xrange(1, min(len(lines), 11)): - if re.search(r'Copyright', lines[line], re.I): break - else: # means no copyright line was found - error(filename, 0, 'legal/copyright', 5, - 'No copyright message found. ' - 'You should have a line: "Copyright [year] "') - - -def GetIndentLevel(line): - """Return the number of leading spaces in line. - - Args: - line: A string to check. - - Returns: - An integer count of leading spaces, possibly zero. - """ - indent = Match(r'^( *)\S', line) - if indent: - return len(indent.group(1)) - else: - return 0 - -def PathSplitToList(path): - """Returns the path split into a list by the separator. - - Args: - path: An absolute or relative path (e.g. '/a/b/c/' or '../a') - - Returns: - A list of path components (e.g. ['a', 'b', 'c]). - """ - lst = [] - while True: - (head, tail) = os.path.split(path) - if head == path: # absolute paths end - lst.append(head) - break - if tail == path: # relative paths end - lst.append(tail) - break - - path = head - lst.append(tail) - - lst.reverse() - return lst - -def GetHeaderGuardCPPVariable(filename): - """Returns the CPP variable that should be used as a header guard. - - Args: - filename: The name of a C++ header file. - - Returns: - The CPP variable that should be used as a header guard in the - named file. - - """ - - # Restores original filename in case that cpplint is invoked from Emacs's - # flymake. - filename = re.sub(r'_flymake\.h$', '.h', filename) - filename = re.sub(r'/\.flymake/([^/]*)$', r'/\1', filename) - # Replace 'c++' with 'cpp'. - filename = filename.replace('C++', 'cpp').replace('c++', 'cpp') - - fileinfo = FileInfo(filename) - file_path_from_root = fileinfo.RepositoryName() - - def FixupPathFromRoot(): - if _root_debug: - sys.stderr.write("\n_root fixup, _root = '%s', repository name = '%s'\n" - %(_root, fileinfo.RepositoryName())) - - # Process the file path with the --root flag if it was set. - if not _root: - if _root_debug: - sys.stderr.write("_root unspecified\n") - return file_path_from_root - - def StripListPrefix(lst, prefix): - # f(['x', 'y'], ['w, z']) -> None (not a valid prefix) - if lst[:len(prefix)] != prefix: - return None - # f(['a, 'b', 'c', 'd'], ['a', 'b']) -> ['c', 'd'] - return lst[(len(prefix)):] - - # root behavior: - # --root=subdir , lstrips subdir from the header guard - maybe_path = StripListPrefix(PathSplitToList(file_path_from_root), - PathSplitToList(_root)) - - if _root_debug: - sys.stderr.write(("_root lstrip (maybe_path=%s, file_path_from_root=%s," + - " _root=%s)\n") %(maybe_path, file_path_from_root, _root)) - - if maybe_path: - return os.path.join(*maybe_path) - - # --root=.. , will prepend the outer directory to the header guard - full_path = fileinfo.FullName() - root_abspath = os.path.abspath(_root) - - maybe_path = StripListPrefix(PathSplitToList(full_path), - PathSplitToList(root_abspath)) - - if _root_debug: - sys.stderr.write(("_root prepend (maybe_path=%s, full_path=%s, " + - "root_abspath=%s)\n") %(maybe_path, full_path, root_abspath)) - - if maybe_path: - return os.path.join(*maybe_path) - - if _root_debug: - sys.stderr.write("_root ignore, returning %s\n" %(file_path_from_root)) - - # --root=FAKE_DIR is ignored - return file_path_from_root - - file_path_from_root = FixupPathFromRoot() - return re.sub(r'[^a-zA-Z0-9]', '_', file_path_from_root).upper() + '_' - - -def CheckForHeaderGuard(filename, clean_lines, error): - """Checks that the file contains a header guard. - - Logs an error if no #ifndef header guard is present. For other - headers, checks that the full pathname is used. - - Args: - filename: The name of the C++ header file. - clean_lines: A CleansedLines instance containing the file. - error: The function to call with any errors found. - """ - - # Don't check for header guards if there are error suppression - # comments somewhere in this file. - # - # Because this is silencing a warning for a nonexistent line, we - # only support the very specific NOLINT(build/header_guard) syntax, - # and not the general NOLINT or NOLINT(*) syntax. - raw_lines = clean_lines.lines_without_raw_strings - for i in raw_lines: - if Search(r'//\s*NOLINT\(build/header_guard\)', i): - return - - cppvar = GetHeaderGuardCPPVariable(filename) - - ifndef = '' - ifndef_linenum = 0 - define = '' - endif = '' - endif_linenum = 0 - for linenum, line in enumerate(raw_lines): - linesplit = line.split() - if len(linesplit) >= 2: - # find the first occurrence of #ifndef and #define, save arg - if not ifndef and linesplit[0] == '#ifndef': - # set ifndef to the header guard presented on the #ifndef line. - ifndef = linesplit[1] - ifndef_linenum = linenum - if not define and linesplit[0] == '#define': - define = linesplit[1] - # find the last occurrence of #endif, save entire line - if line.startswith('#endif'): - endif = line - endif_linenum = linenum - - if not ifndef or not define or ifndef != define: - error(filename, 0, 'build/header_guard', 5, - 'No #ifndef header guard found, suggested CPP variable is: %s' % - cppvar) - return - - # The guard should be PATH_FILE_H_, but we also allow PATH_FILE_H__ - # for backward compatibility. - if ifndef != cppvar: - error_level = 0 - if ifndef != cppvar + '_': - error_level = 5 - - ParseNolintSuppressions(filename, raw_lines[ifndef_linenum], ifndef_linenum, - error) - error(filename, ifndef_linenum, 'build/header_guard', error_level, - '#ifndef header guard has wrong style, please use: %s' % cppvar) - - # Check for "//" comments on endif line. - ParseNolintSuppressions(filename, raw_lines[endif_linenum], endif_linenum, - error) - match = Match(r'#endif\s*//\s*' + cppvar + r'(_)?\b', endif) - if match: - if match.group(1) == '_': - # Issue low severity warning for deprecated double trailing underscore - error(filename, endif_linenum, 'build/header_guard', 0, - '#endif line should be "#endif // %s"' % cppvar) - return - - # Didn't find the corresponding "//" comment. If this file does not - # contain any "//" comments at all, it could be that the compiler - # only wants "/**/" comments, look for those instead. - no_single_line_comments = True - for i in xrange(1, len(raw_lines) - 1): - line = raw_lines[i] - if Match(r'^(?:(?:\'(?:\.|[^\'])*\')|(?:"(?:\.|[^"])*")|[^\'"])*//', line): - no_single_line_comments = False - break - - if no_single_line_comments: - match = Match(r'#endif\s*/\*\s*' + cppvar + r'(_)?\s*\*/', endif) - if match: - if match.group(1) == '_': - # Low severity warning for double trailing underscore - error(filename, endif_linenum, 'build/header_guard', 0, - '#endif line should be "#endif /* %s */"' % cppvar) - return - - # Didn't find anything - error(filename, endif_linenum, 'build/header_guard', 5, - '#endif line should be "#endif // %s"' % cppvar) - - -def CheckHeaderFileIncluded(filename, include_state, error): - """Logs an error if a .cc file does not include its header.""" - - # Do not check test files - fileinfo = FileInfo(filename) - if Search(_TEST_FILE_SUFFIX, fileinfo.BaseName()): - return - - headerfile = filename[0:len(filename) - len(fileinfo.Extension())] + '.h' - if not os.path.exists(headerfile): - return - headername = FileInfo(headerfile).RepositoryName() - first_include = 0 - for section_list in include_state.include_list: - for f in section_list: - if headername in f[0] or f[0] in headername: - return - if not first_include: - first_include = f[1] - - error(filename, first_include, 'build/include', 5, - '%s should include its header file %s' % (fileinfo.RepositoryName(), - headername)) - - -def CheckForBadCharacters(filename, lines, error): - """Logs an error for each line containing bad characters. - - Two kinds of bad characters: - - 1. Unicode replacement characters: These indicate that either the file - contained invalid UTF-8 (likely) or Unicode replacement characters (which - it shouldn't). Note that it's possible for this to throw off line - numbering if the invalid UTF-8 occurred adjacent to a newline. - - 2. NUL bytes. These are problematic for some tools. - - Args: - filename: The name of the current file. - lines: An array of strings, each representing a line of the file. - error: The function to call with any errors found. - """ - for linenum, line in enumerate(lines): - if u'\ufffd' in line: - error(filename, linenum, 'readability/utf8', 5, - 'Line contains invalid UTF-8 (or Unicode replacement character).') - if '\0' in line: - error(filename, linenum, 'readability/nul', 5, 'Line contains NUL byte.') - - -def CheckForNewlineAtEOF(filename, lines, error): - """Logs an error if there is no newline char at the end of the file. - - Args: - filename: The name of the current file. - lines: An array of strings, each representing a line of the file. - error: The function to call with any errors found. - """ - - # The array lines() was created by adding two newlines to the - # original file (go figure), then splitting on \n. - # To verify that the file ends in \n, we just have to make sure the - # last-but-two element of lines() exists and is empty. - if len(lines) < 3 or lines[-2]: - error(filename, len(lines) - 2, 'whitespace/ending_newline', 5, - 'Could not find a newline character at the end of the file.') - - -def CheckForMultilineCommentsAndStrings(filename, clean_lines, linenum, error): - """Logs an error if we see /* ... */ or "..." that extend past one line. - - /* ... */ comments are legit inside macros, for one line. - Otherwise, we prefer // comments, so it's ok to warn about the - other. Likewise, it's ok for strings to extend across multiple - lines, as long as a line continuation character (backslash) - terminates each line. Although not currently prohibited by the C++ - style guide, it's ugly and unnecessary. We don't do well with either - in this lint program, so we warn about both. - - Args: - filename: The name of the current file. - clean_lines: A CleansedLines instance containing the file. - linenum: The number of the line to check. - error: The function to call with any errors found. - """ - line = clean_lines.elided[linenum] - - # Remove all \\ (escaped backslashes) from the line. They are OK, and the - # second (escaped) slash may trigger later \" detection erroneously. - line = line.replace('\\\\', '') - - if line.count('/*') > line.count('*/'): - error(filename, linenum, 'readability/multiline_comment', 5, - 'Complex multi-line /*...*/-style comment found. ' - 'Lint may give bogus warnings. ' - 'Consider replacing these with //-style comments, ' - 'with #if 0...#endif, ' - 'or with more clearly structured multi-line comments.') - - if (line.count('"') - line.count('\\"')) % 2: - error(filename, linenum, 'readability/multiline_string', 5, - 'Multi-line string ("...") found. This lint script doesn\'t ' - 'do well with such strings, and may give bogus warnings. ' - 'Use C++11 raw strings or concatenation instead.') - - -# (non-threadsafe name, thread-safe alternative, validation pattern) -# -# The validation pattern is used to eliminate false positives such as: -# _rand(); // false positive due to substring match. -# ->rand(); // some member function rand(). -# ACMRandom rand(seed); // some variable named rand. -# ISAACRandom rand(); // another variable named rand. -# -# Basically we require the return value of these functions to be used -# in some expression context on the same line by matching on some -# operator before the function name. This eliminates constructors and -# member function calls. -_UNSAFE_FUNC_PREFIX = r'(?:[-+*/=%^&|(<]\s*|>\s+)' -_THREADING_LIST = ( - ('asctime(', 'asctime_r(', _UNSAFE_FUNC_PREFIX + r'asctime\([^)]+\)'), - ('ctime(', 'ctime_r(', _UNSAFE_FUNC_PREFIX + r'ctime\([^)]+\)'), - ('getgrgid(', 'getgrgid_r(', _UNSAFE_FUNC_PREFIX + r'getgrgid\([^)]+\)'), - ('getgrnam(', 'getgrnam_r(', _UNSAFE_FUNC_PREFIX + r'getgrnam\([^)]+\)'), - ('getlogin(', 'getlogin_r(', _UNSAFE_FUNC_PREFIX + r'getlogin\(\)'), - ('getpwnam(', 'getpwnam_r(', _UNSAFE_FUNC_PREFIX + r'getpwnam\([^)]+\)'), - ('getpwuid(', 'getpwuid_r(', _UNSAFE_FUNC_PREFIX + r'getpwuid\([^)]+\)'), - ('gmtime(', 'gmtime_r(', _UNSAFE_FUNC_PREFIX + r'gmtime\([^)]+\)'), - ('localtime(', 'localtime_r(', _UNSAFE_FUNC_PREFIX + r'localtime\([^)]+\)'), - ('rand(', 'rand_r(', _UNSAFE_FUNC_PREFIX + r'rand\(\)'), - ('strtok(', 'strtok_r(', - _UNSAFE_FUNC_PREFIX + r'strtok\([^)]+\)'), - ('ttyname(', 'ttyname_r(', _UNSAFE_FUNC_PREFIX + r'ttyname\([^)]+\)'), - ) - - -def CheckPosixThreading(filename, clean_lines, linenum, error): - """Checks for calls to thread-unsafe functions. - - Much code has been originally written without consideration of - multi-threading. Also, engineers are relying on their old experience; - they have learned posix before threading extensions were added. These - tests guide the engineers to use thread-safe functions (when using - posix directly). - - Args: - filename: The name of the current file. - clean_lines: A CleansedLines instance containing the file. - linenum: The number of the line to check. - error: The function to call with any errors found. - """ - line = clean_lines.elided[linenum] - for single_thread_func, multithread_safe_func, pattern in _THREADING_LIST: - # Additional pattern matching check to confirm that this is the - # function we are looking for - if Search(pattern, line): - error(filename, linenum, 'runtime/threadsafe_fn', 2, - 'Consider using ' + multithread_safe_func + - '...) instead of ' + single_thread_func + - '...) for improved thread safety.') - - -def CheckVlogArguments(filename, clean_lines, linenum, error): - """Checks that VLOG() is only used for defining a logging level. - - For example, VLOG(2) is correct. VLOG(INFO), VLOG(WARNING), VLOG(ERROR), and - VLOG(FATAL) are not. - - Args: - filename: The name of the current file. - clean_lines: A CleansedLines instance containing the file. - linenum: The number of the line to check. - error: The function to call with any errors found. - """ - line = clean_lines.elided[linenum] - if Search(r'\bVLOG\((INFO|ERROR|WARNING|DFATAL|FATAL)\)', line): - error(filename, linenum, 'runtime/vlog', 5, - 'VLOG() should be used with numeric verbosity level. ' - 'Use LOG() if you want symbolic severity levels.') - -# Matches invalid increment: *count++, which moves pointer instead of -# incrementing a value. -_RE_PATTERN_INVALID_INCREMENT = re.compile( - r'^\s*\*\w+(\+\+|--);') - - -def CheckInvalidIncrement(filename, clean_lines, linenum, error): - """Checks for invalid increment *count++. - - For example following function: - void increment_counter(int* count) { - *count++; - } - is invalid, because it effectively does count++, moving pointer, and should - be replaced with ++*count, (*count)++ or *count += 1. - - Args: - filename: The name of the current file. - clean_lines: A CleansedLines instance containing the file. - linenum: The number of the line to check. - error: The function to call with any errors found. - """ - line = clean_lines.elided[linenum] - if _RE_PATTERN_INVALID_INCREMENT.match(line): - error(filename, linenum, 'runtime/invalid_increment', 5, - 'Changing pointer instead of value (or unused value of operator*).') - - -def IsMacroDefinition(clean_lines, linenum): - if Search(r'^#define', clean_lines[linenum]): - return True - - if linenum > 0 and Search(r'\\$', clean_lines[linenum - 1]): - return True - - return False - - -def IsForwardClassDeclaration(clean_lines, linenum): - return Match(r'^\s*(\btemplate\b)*.*class\s+\w+;\s*$', clean_lines[linenum]) - - -class _BlockInfo(object): - """Stores information about a generic block of code.""" - - def __init__(self, linenum, seen_open_brace): - self.starting_linenum = linenum - self.seen_open_brace = seen_open_brace - self.open_parentheses = 0 - self.inline_asm = _NO_ASM - self.check_namespace_indentation = False - - def CheckBegin(self, filename, clean_lines, linenum, error): - """Run checks that applies to text up to the opening brace. - - This is mostly for checking the text after the class identifier - and the "{", usually where the base class is specified. For other - blocks, there isn't much to check, so we always pass. - - Args: - filename: The name of the current file. - clean_lines: A CleansedLines instance containing the file. - linenum: The number of the line to check. - error: The function to call with any errors found. - """ - pass - - def CheckEnd(self, filename, clean_lines, linenum, error): - """Run checks that applies to text after the closing brace. - - This is mostly used for checking end of namespace comments. - - Args: - filename: The name of the current file. - clean_lines: A CleansedLines instance containing the file. - linenum: The number of the line to check. - error: The function to call with any errors found. - """ - pass - - def IsBlockInfo(self): - """Returns true if this block is a _BlockInfo. - - This is convenient for verifying that an object is an instance of - a _BlockInfo, but not an instance of any of the derived classes. - - Returns: - True for this class, False for derived classes. - """ - return self.__class__ == _BlockInfo - - -class _ExternCInfo(_BlockInfo): - """Stores information about an 'extern "C"' block.""" - - def __init__(self, linenum): - _BlockInfo.__init__(self, linenum, True) - - -class _ClassInfo(_BlockInfo): - """Stores information about a class.""" - - def __init__(self, name, class_or_struct, clean_lines, linenum): - _BlockInfo.__init__(self, linenum, False) - self.name = name - self.is_derived = False - self.check_namespace_indentation = True - if class_or_struct == 'struct': - self.access = 'public' - self.is_struct = True - else: - self.access = 'private' - self.is_struct = False - - # Remember initial indentation level for this class. Using raw_lines here - # instead of elided to account for leading comments. - self.class_indent = GetIndentLevel(clean_lines.raw_lines[linenum]) - - # Try to find the end of the class. This will be confused by things like: - # class A { - # } *x = { ... - # - # But it's still good enough for CheckSectionSpacing. - self.last_line = 0 - depth = 0 - for i in range(linenum, clean_lines.NumLines()): - line = clean_lines.elided[i] - depth += line.count('{') - line.count('}') - if not depth: - self.last_line = i - break - - def CheckBegin(self, filename, clean_lines, linenum, error): - # Look for a bare ':' - if Search('(^|[^:]):($|[^:])', clean_lines.elided[linenum]): - self.is_derived = True - - def CheckEnd(self, filename, clean_lines, linenum, error): - # If there is a DISALLOW macro, it should appear near the end of - # the class. - seen_last_thing_in_class = False - for i in xrange(linenum - 1, self.starting_linenum, -1): - match = Search( - r'\b(DISALLOW_COPY_AND_ASSIGN|DISALLOW_IMPLICIT_CONSTRUCTORS)\(' + - self.name + r'\)', - clean_lines.elided[i]) - if match: - if seen_last_thing_in_class: - error(filename, i, 'readability/constructors', 3, - match.group(1) + ' should be the last thing in the class') - break - - if not Match(r'^\s*$', clean_lines.elided[i]): - seen_last_thing_in_class = True - - # Check that closing brace is aligned with beginning of the class. - # Only do this if the closing brace is indented by only whitespaces. - # This means we will not check single-line class definitions. - indent = Match(r'^( *)\}', clean_lines.elided[linenum]) - if indent and len(indent.group(1)) != self.class_indent: - if self.is_struct: - parent = 'struct ' + self.name - else: - parent = 'class ' + self.name - error(filename, linenum, 'whitespace/indent', 3, - 'Closing brace should be aligned with beginning of %s' % parent) - - -class _NamespaceInfo(_BlockInfo): - """Stores information about a namespace.""" - - def __init__(self, name, linenum): - _BlockInfo.__init__(self, linenum, False) - self.name = name or '' - self.check_namespace_indentation = True - - def CheckEnd(self, filename, clean_lines, linenum, error): - """Check end of namespace comments.""" - line = clean_lines.raw_lines[linenum] - - # Check how many lines is enclosed in this namespace. Don't issue - # warning for missing namespace comments if there aren't enough - # lines. However, do apply checks if there is already an end of - # namespace comment and it's incorrect. - # - # TODO(unknown): We always want to check end of namespace comments - # if a namespace is large, but sometimes we also want to apply the - # check if a short namespace contained nontrivial things (something - # other than forward declarations). There is currently no logic on - # deciding what these nontrivial things are, so this check is - # triggered by namespace size only, which works most of the time. - if (linenum - self.starting_linenum < 10 - and not Match(r'^\s*};*\s*(//|/\*).*\bnamespace\b', line)): - return - - # Look for matching comment at end of namespace. - # - # Note that we accept C style "/* */" comments for terminating - # namespaces, so that code that terminate namespaces inside - # preprocessor macros can be cpplint clean. - # - # We also accept stuff like "// end of namespace ." with the - # period at the end. - # - # Besides these, we don't accept anything else, otherwise we might - # get false negatives when existing comment is a substring of the - # expected namespace. - if self.name: - # Named namespace - if not Match((r'^\s*};*\s*(//|/\*).*\bnamespace\s+' + - re.escape(self.name) + r'[\*/\.\\\s]*$'), - line): - error(filename, linenum, 'readability/namespace', 5, - 'Namespace should be terminated with "// namespace %s"' % - self.name) - else: - # Anonymous namespace - if not Match(r'^\s*};*\s*(//|/\*).*\bnamespace[\*/\.\\\s]*$', line): - # If "// namespace anonymous" or "// anonymous namespace (more text)", - # mention "// anonymous namespace" as an acceptable form - if Match(r'^\s*}.*\b(namespace anonymous|anonymous namespace)\b', line): - error(filename, linenum, 'readability/namespace', 5, - 'Anonymous namespace should be terminated with "// namespace"' - ' or "// anonymous namespace"') - else: - error(filename, linenum, 'readability/namespace', 5, - 'Anonymous namespace should be terminated with "// namespace"') - - -class _PreprocessorInfo(object): - """Stores checkpoints of nesting stacks when #if/#else is seen.""" - - def __init__(self, stack_before_if): - # The entire nesting stack before #if - self.stack_before_if = stack_before_if - - # The entire nesting stack up to #else - self.stack_before_else = [] - - # Whether we have already seen #else or #elif - self.seen_else = False - - -class NestingState(object): - """Holds states related to parsing braces.""" - - def __init__(self): - # Stack for tracking all braces. An object is pushed whenever we - # see a "{", and popped when we see a "}". Only 3 types of - # objects are possible: - # - _ClassInfo: a class or struct. - # - _NamespaceInfo: a namespace. - # - _BlockInfo: some other type of block. - self.stack = [] - - # Top of the previous stack before each Update(). - # - # Because the nesting_stack is updated at the end of each line, we - # had to do some convoluted checks to find out what is the current - # scope at the beginning of the line. This check is simplified by - # saving the previous top of nesting stack. - # - # We could save the full stack, but we only need the top. Copying - # the full nesting stack would slow down cpplint by ~10%. - self.previous_stack_top = [] - - # Stack of _PreprocessorInfo objects. - self.pp_stack = [] - - def SeenOpenBrace(self): - """Check if we have seen the opening brace for the innermost block. - - Returns: - True if we have seen the opening brace, False if the innermost - block is still expecting an opening brace. - """ - return (not self.stack) or self.stack[-1].seen_open_brace - - def InNamespaceBody(self): - """Check if we are currently one level inside a namespace body. - - Returns: - True if top of the stack is a namespace block, False otherwise. - """ - return self.stack and isinstance(self.stack[-1], _NamespaceInfo) - - def InExternC(self): - """Check if we are currently one level inside an 'extern "C"' block. - - Returns: - True if top of the stack is an extern block, False otherwise. - """ - return self.stack and isinstance(self.stack[-1], _ExternCInfo) - - def InClassDeclaration(self): - """Check if we are currently one level inside a class or struct declaration. - - Returns: - True if top of the stack is a class/struct, False otherwise. - """ - return self.stack and isinstance(self.stack[-1], _ClassInfo) - - def InAsmBlock(self): - """Check if we are currently one level inside an inline ASM block. - - Returns: - True if the top of the stack is a block containing inline ASM. - """ - return self.stack and self.stack[-1].inline_asm != _NO_ASM - - def InTemplateArgumentList(self, clean_lines, linenum, pos): - """Check if current position is inside template argument list. - - Args: - clean_lines: A CleansedLines instance containing the file. - linenum: The number of the line to check. - pos: position just after the suspected template argument. - Returns: - True if (linenum, pos) is inside template arguments. - """ - while linenum < clean_lines.NumLines(): - # Find the earliest character that might indicate a template argument - line = clean_lines.elided[linenum] - match = Match(r'^[^{};=\[\]\.<>]*(.)', line[pos:]) - if not match: - linenum += 1 - pos = 0 - continue - token = match.group(1) - pos += len(match.group(0)) - - # These things do not look like template argument list: - # class Suspect { - # class Suspect x; } - if token in ('{', '}', ';'): return False - - # These things look like template argument list: - # template - # template - # template - # template - if token in ('>', '=', '[', ']', '.'): return True - - # Check if token is an unmatched '<'. - # If not, move on to the next character. - if token != '<': - pos += 1 - if pos >= len(line): - linenum += 1 - pos = 0 - continue - - # We can't be sure if we just find a single '<', and need to - # find the matching '>'. - (_, end_line, end_pos) = CloseExpression(clean_lines, linenum, pos - 1) - if end_pos < 0: - # Not sure if template argument list or syntax error in file - return False - linenum = end_line - pos = end_pos - return False - - def UpdatePreprocessor(self, line): - """Update preprocessor stack. - - We need to handle preprocessors due to classes like this: - #ifdef SWIG - struct ResultDetailsPageElementExtensionPoint { - #else - struct ResultDetailsPageElementExtensionPoint : public Extension { - #endif - - We make the following assumptions (good enough for most files): - - Preprocessor condition evaluates to true from #if up to first - #else/#elif/#endif. - - - Preprocessor condition evaluates to false from #else/#elif up - to #endif. We still perform lint checks on these lines, but - these do not affect nesting stack. - - Args: - line: current line to check. - """ - if Match(r'^\s*#\s*(if|ifdef|ifndef)\b', line): - # Beginning of #if block, save the nesting stack here. The saved - # stack will allow us to restore the parsing state in the #else case. - self.pp_stack.append(_PreprocessorInfo(copy.deepcopy(self.stack))) - elif Match(r'^\s*#\s*(else|elif)\b', line): - # Beginning of #else block - if self.pp_stack: - if not self.pp_stack[-1].seen_else: - # This is the first #else or #elif block. Remember the - # whole nesting stack up to this point. This is what we - # keep after the #endif. - self.pp_stack[-1].seen_else = True - self.pp_stack[-1].stack_before_else = copy.deepcopy(self.stack) - - # Restore the stack to how it was before the #if - self.stack = copy.deepcopy(self.pp_stack[-1].stack_before_if) - else: - # TODO(unknown): unexpected #else, issue warning? - pass - elif Match(r'^\s*#\s*endif\b', line): - # End of #if or #else blocks. - if self.pp_stack: - # If we saw an #else, we will need to restore the nesting - # stack to its former state before the #else, otherwise we - # will just continue from where we left off. - if self.pp_stack[-1].seen_else: - # Here we can just use a shallow copy since we are the last - # reference to it. - self.stack = self.pp_stack[-1].stack_before_else - # Drop the corresponding #if - self.pp_stack.pop() - else: - # TODO(unknown): unexpected #endif, issue warning? - pass - - # TODO(unknown): Update() is too long, but we will refactor later. - def Update(self, filename, clean_lines, linenum, error): - """Update nesting state with current line. - - Args: - filename: The name of the current file. - clean_lines: A CleansedLines instance containing the file. - linenum: The number of the line to check. - error: The function to call with any errors found. - """ - line = clean_lines.elided[linenum] - - # Remember top of the previous nesting stack. - # - # The stack is always pushed/popped and not modified in place, so - # we can just do a shallow copy instead of copy.deepcopy. Using - # deepcopy would slow down cpplint by ~28%. - if self.stack: - self.previous_stack_top = self.stack[-1] - else: - self.previous_stack_top = None - - # Update pp_stack - self.UpdatePreprocessor(line) - - # Count parentheses. This is to avoid adding struct arguments to - # the nesting stack. - if self.stack: - inner_block = self.stack[-1] - depth_change = line.count('(') - line.count(')') - inner_block.open_parentheses += depth_change - - # Also check if we are starting or ending an inline assembly block. - if inner_block.inline_asm in (_NO_ASM, _END_ASM): - if (depth_change != 0 and - inner_block.open_parentheses == 1 and - _MATCH_ASM.match(line)): - # Enter assembly block - inner_block.inline_asm = _INSIDE_ASM - else: - # Not entering assembly block. If previous line was _END_ASM, - # we will now shift to _NO_ASM state. - inner_block.inline_asm = _NO_ASM - elif (inner_block.inline_asm == _INSIDE_ASM and - inner_block.open_parentheses == 0): - # Exit assembly block - inner_block.inline_asm = _END_ASM - - # Consume namespace declaration at the beginning of the line. Do - # this in a loop so that we catch same line declarations like this: - # namespace proto2 { namespace bridge { class MessageSet; } } - while True: - # Match start of namespace. The "\b\s*" below catches namespace - # declarations even if it weren't followed by a whitespace, this - # is so that we don't confuse our namespace checker. The - # missing spaces will be flagged by CheckSpacing. - namespace_decl_match = Match(r'^\s*namespace\b\s*([:\w]+)?(.*)$', line) - if not namespace_decl_match: - break - - new_namespace = _NamespaceInfo(namespace_decl_match.group(1), linenum) - self.stack.append(new_namespace) - - line = namespace_decl_match.group(2) - if line.find('{') != -1: - new_namespace.seen_open_brace = True - line = line[line.find('{') + 1:] - - # Look for a class declaration in whatever is left of the line - # after parsing namespaces. The regexp accounts for decorated classes - # such as in: - # class LOCKABLE API Object { - # }; - class_decl_match = Match( - r'^(\s*(?:template\s*<[\w\s<>,:]*>\s*)?' - r'(class|struct)\s+(?:[A-Z_]+\s+)*(\w+(?:::\w+)*))' - r'(.*)$', line) - if (class_decl_match and - (not self.stack or self.stack[-1].open_parentheses == 0)): - # We do not want to accept classes that are actually template arguments: - # template , - # template class Ignore3> - # void Function() {}; - # - # To avoid template argument cases, we scan forward and look for - # an unmatched '>'. If we see one, assume we are inside a - # template argument list. - end_declaration = len(class_decl_match.group(1)) - if not self.InTemplateArgumentList(clean_lines, linenum, end_declaration): - self.stack.append(_ClassInfo( - class_decl_match.group(3), class_decl_match.group(2), - clean_lines, linenum)) - line = class_decl_match.group(4) - - # If we have not yet seen the opening brace for the innermost block, - # run checks here. - if not self.SeenOpenBrace(): - self.stack[-1].CheckBegin(filename, clean_lines, linenum, error) - - # Update access control if we are inside a class/struct - if self.stack and isinstance(self.stack[-1], _ClassInfo): - classinfo = self.stack[-1] - access_match = Match( - r'^(.*)\b(public|private|protected|signals)(\s+(?:slots\s*)?)?' - r':(?:[^:]|$)', - line) - if access_match: - classinfo.access = access_match.group(2) - - # Check that access keywords are indented +1 space. Skip this - # check if the keywords are not preceded by whitespaces. - indent = access_match.group(1) - if (len(indent) != classinfo.class_indent + 1 and - Match(r'^\s*$', indent)): - if classinfo.is_struct: - parent = 'struct ' + classinfo.name - else: - parent = 'class ' + classinfo.name - slots = '' - if access_match.group(3): - slots = access_match.group(3) - error(filename, linenum, 'whitespace/indent', 3, - '%s%s: should be indented +1 space inside %s' % ( - access_match.group(2), slots, parent)) - - # Consume braces or semicolons from what's left of the line - while True: - # Match first brace, semicolon, or closed parenthesis. - matched = Match(r'^[^{;)}]*([{;)}])(.*)$', line) - if not matched: - break - - token = matched.group(1) - if token == '{': - # If namespace or class hasn't seen a opening brace yet, mark - # namespace/class head as complete. Push a new block onto the - # stack otherwise. - if not self.SeenOpenBrace(): - self.stack[-1].seen_open_brace = True - elif Match(r'^extern\s*"[^"]*"\s*\{', line): - self.stack.append(_ExternCInfo(linenum)) - else: - self.stack.append(_BlockInfo(linenum, True)) - if _MATCH_ASM.match(line): - self.stack[-1].inline_asm = _BLOCK_ASM - - elif token == ';' or token == ')': - # If we haven't seen an opening brace yet, but we already saw - # a semicolon, this is probably a forward declaration. Pop - # the stack for these. - # - # Similarly, if we haven't seen an opening brace yet, but we - # already saw a closing parenthesis, then these are probably - # function arguments with extra "class" or "struct" keywords. - # Also pop these stack for these. - if not self.SeenOpenBrace(): - self.stack.pop() - else: # token == '}' - # Perform end of block checks and pop the stack. - if self.stack: - self.stack[-1].CheckEnd(filename, clean_lines, linenum, error) - self.stack.pop() - line = matched.group(2) - - def InnermostClass(self): - """Get class info on the top of the stack. - - Returns: - A _ClassInfo object if we are inside a class, or None otherwise. - """ - for i in range(len(self.stack), 0, -1): - classinfo = self.stack[i - 1] - if isinstance(classinfo, _ClassInfo): - return classinfo - return None - - def CheckCompletedBlocks(self, filename, error): - """Checks that all classes and namespaces have been completely parsed. - - Call this when all lines in a file have been processed. - Args: - filename: The name of the current file. - error: The function to call with any errors found. - """ - # Note: This test can result in false positives if #ifdef constructs - # get in the way of brace matching. See the testBuildClass test in - # cpplint_unittest.py for an example of this. - for obj in self.stack: - if isinstance(obj, _ClassInfo): - error(filename, obj.starting_linenum, 'build/class', 5, - 'Failed to find complete declaration of class %s' % - obj.name) - elif isinstance(obj, _NamespaceInfo): - error(filename, obj.starting_linenum, 'build/namespaces', 5, - 'Failed to find complete declaration of namespace %s' % - obj.name) - - -def CheckForNonStandardConstructs(filename, clean_lines, linenum, - nesting_state, error): - r"""Logs an error if we see certain non-ANSI constructs ignored by gcc-2. - - Complain about several constructs which gcc-2 accepts, but which are - not standard C++. Warning about these in lint is one way to ease the - transition to new compilers. - - put storage class first (e.g. "static const" instead of "const static"). - - "%lld" instead of %qd" in printf-type functions. - - "%1$d" is non-standard in printf-type functions. - - "\%" is an undefined character escape sequence. - - text after #endif is not allowed. - - invalid inner-style forward declaration. - - >? and ?= and )\?=?\s*(\w+|[+-]?\d+)(\.\d*)?', - line): - error(filename, linenum, 'build/deprecated', 3, - '>? and ))?' - # r'\s*const\s*' + type_name + '\s*&\s*\w+\s*;' - error(filename, linenum, 'runtime/member_string_references', 2, - 'const string& members are dangerous. It is much better to use ' - 'alternatives, such as pointers or simple constants.') - - # Everything else in this function operates on class declarations. - # Return early if the top of the nesting stack is not a class, or if - # the class head is not completed yet. - classinfo = nesting_state.InnermostClass() - if not classinfo or not classinfo.seen_open_brace: - return - - # The class may have been declared with namespace or classname qualifiers. - # The constructor and destructor will not have those qualifiers. - base_classname = classinfo.name.split('::')[-1] - - # Look for single-argument constructors that aren't marked explicit. - # Technically a valid construct, but against style. - explicit_constructor_match = Match( - r'\s+(?:(?:inline|constexpr)\s+)*(explicit\s+)?' - r'(?:(?:inline|constexpr)\s+)*%s\s*' - r'\(((?:[^()]|\([^()]*\))*)\)' - % re.escape(base_classname), - line) - - if explicit_constructor_match: - is_marked_explicit = explicit_constructor_match.group(1) - - if not explicit_constructor_match.group(2): - constructor_args = [] - else: - constructor_args = explicit_constructor_match.group(2).split(',') - - # collapse arguments so that commas in template parameter lists and function - # argument parameter lists don't split arguments in two - i = 0 - while i < len(constructor_args): - constructor_arg = constructor_args[i] - while (constructor_arg.count('<') > constructor_arg.count('>') or - constructor_arg.count('(') > constructor_arg.count(')')): - constructor_arg += ',' + constructor_args[i + 1] - del constructor_args[i + 1] - constructor_args[i] = constructor_arg - i += 1 - - defaulted_args = [arg for arg in constructor_args if '=' in arg] - noarg_constructor = (not constructor_args or # empty arg list - # 'void' arg specifier - (len(constructor_args) == 1 and - constructor_args[0].strip() == 'void')) - onearg_constructor = ((len(constructor_args) == 1 and # exactly one arg - not noarg_constructor) or - # all but at most one arg defaulted - (len(constructor_args) >= 1 and - not noarg_constructor and - len(defaulted_args) >= len(constructor_args) - 1)) - initializer_list_constructor = bool( - onearg_constructor and - Search(r'\bstd\s*::\s*initializer_list\b', constructor_args[0])) - copy_constructor = bool( - onearg_constructor and - Match(r'(const\s+)?%s(\s*<[^>]*>)?(\s+const)?\s*(?:<\w+>\s*)?&' - % re.escape(base_classname), constructor_args[0].strip())) - - if (not is_marked_explicit and - onearg_constructor and - not initializer_list_constructor and - not copy_constructor): - if defaulted_args: - error(filename, linenum, 'runtime/explicit', 5, - 'Constructors callable with one argument ' - 'should be marked explicit.') - else: - error(filename, linenum, 'runtime/explicit', 5, - 'Single-parameter constructors should be marked explicit.') - elif is_marked_explicit and not onearg_constructor: - if noarg_constructor: - error(filename, linenum, 'runtime/explicit', 5, - 'Zero-parameter constructors should not be marked explicit.') - - -def CheckSpacingForFunctionCall(filename, clean_lines, linenum, error): - """Checks for the correctness of various spacing around function calls. - - Args: - filename: The name of the current file. - clean_lines: A CleansedLines instance containing the file. - linenum: The number of the line to check. - error: The function to call with any errors found. - """ - line = clean_lines.elided[linenum] - - # Since function calls often occur inside if/for/while/switch - # expressions - which have their own, more liberal conventions - we - # first see if we should be looking inside such an expression for a - # function call, to which we can apply more strict standards. - fncall = line # if there's no control flow construct, look at whole line - for pattern in (r'\bif\s*\((.*)\)\s*{', - r'\bfor\s*\((.*)\)\s*{', - r'\bwhile\s*\((.*)\)\s*[{;]', - r'\bswitch\s*\((.*)\)\s*{'): - match = Search(pattern, line) - if match: - fncall = match.group(1) # look inside the parens for function calls - break - - # Except in if/for/while/switch, there should never be space - # immediately inside parens (eg "f( 3, 4 )"). We make an exception - # for nested parens ( (a+b) + c ). Likewise, there should never be - # a space before a ( when it's a function argument. I assume it's a - # function argument when the char before the whitespace is legal in - # a function name (alnum + _) and we're not starting a macro. Also ignore - # pointers and references to arrays and functions coz they're too tricky: - # we use a very simple way to recognize these: - # " (something)(maybe-something)" or - # " (something)(maybe-something," or - # " (something)[something]" - # Note that we assume the contents of [] to be short enough that - # they'll never need to wrap. - if ( # Ignore control structures. - not Search(r'\b(if|for|while|switch|return|new|delete|catch|sizeof)\b', - fncall) and - # Ignore pointers/references to functions. - not Search(r' \([^)]+\)\([^)]*(\)|,$)', fncall) and - # Ignore pointers/references to arrays. - not Search(r' \([^)]+\)\[[^\]]+\]', fncall)): - if Search(r'\w\s*\(\s(?!\s*\\$)', fncall): # a ( used for a fn call - error(filename, linenum, 'whitespace/parens', 4, - 'Extra space after ( in function call') - elif Search(r'\(\s+(?!(\s*\\)|\()', fncall): - error(filename, linenum, 'whitespace/parens', 2, - 'Extra space after (') - if (Search(r'\w\s+\(', fncall) and - not Search(r'_{0,2}asm_{0,2}\s+_{0,2}volatile_{0,2}\s+\(', fncall) and - not Search(r'#\s*define|typedef|using\s+\w+\s*=', fncall) and - not Search(r'\w\s+\((\w+::)*\*\w+\)\(', fncall) and - not Search(r'\bcase\s+\(', fncall)): - # TODO(unknown): Space after an operator function seem to be a common - # error, silence those for now by restricting them to highest verbosity. - if Search(r'\boperator_*\b', line): - error(filename, linenum, 'whitespace/parens', 0, - 'Extra space before ( in function call') - else: - error(filename, linenum, 'whitespace/parens', 4, - 'Extra space before ( in function call') - # If the ) is followed only by a newline or a { + newline, assume it's - # part of a control statement (if/while/etc), and don't complain - if Search(r'[^)]\s+\)\s*[^{\s]', fncall): - # If the closing parenthesis is preceded by only whitespaces, - # try to give a more descriptive error message. - if Search(r'^\s+\)', fncall): - error(filename, linenum, 'whitespace/parens', 2, - 'Closing ) should be moved to the previous line') - else: - error(filename, linenum, 'whitespace/parens', 2, - 'Extra space before )') - - -def IsBlankLine(line): - """Returns true if the given line is blank. - - We consider a line to be blank if the line is empty or consists of - only white spaces. - - Args: - line: A line of a string. - - Returns: - True, if the given line is blank. - """ - return not line or line.isspace() - - -def CheckForNamespaceIndentation(filename, nesting_state, clean_lines, line, - error): - is_namespace_indent_item = ( - len(nesting_state.stack) > 1 and - nesting_state.stack[-1].check_namespace_indentation and - isinstance(nesting_state.previous_stack_top, _NamespaceInfo) and - nesting_state.previous_stack_top == nesting_state.stack[-2]) - - if ShouldCheckNamespaceIndentation(nesting_state, is_namespace_indent_item, - clean_lines.elided, line): - CheckItemIndentationInNamespace(filename, clean_lines.elided, - line, error) - - -def CheckForFunctionLengths(filename, clean_lines, linenum, - function_state, error): - """Reports for long function bodies. - - For an overview why this is done, see: - https://google-styleguide.googlecode.com/svn/trunk/cppguide.xml#Write_Short_Functions - - Uses a simplistic algorithm assuming other style guidelines - (especially spacing) are followed. - Only checks unindented functions, so class members are unchecked. - Trivial bodies are unchecked, so constructors with huge initializer lists - may be missed. - Blank/comment lines are not counted so as to avoid encouraging the removal - of vertical space and comments just to get through a lint check. - NOLINT *on the last line of a function* disables this check. - - Args: - filename: The name of the current file. - clean_lines: A CleansedLines instance containing the file. - linenum: The number of the line to check. - function_state: Current function name and lines in body so far. - error: The function to call with any errors found. - """ - lines = clean_lines.lines - line = lines[linenum] - joined_line = '' - - starting_func = False - regexp = r'(\w(\w|::|\*|\&|\s)*)\(' # decls * & space::name( ... - match_result = Match(regexp, line) - if match_result: - # If the name is all caps and underscores, figure it's a macro and - # ignore it, unless it's TEST or TEST_F. - function_name = match_result.group(1).split()[-1] - if function_name == 'TEST' or function_name == 'TEST_F' or ( - not Match(r'[A-Z_]+$', function_name)): - starting_func = True - - if starting_func: - body_found = False - for start_linenum in xrange(linenum, clean_lines.NumLines()): - start_line = lines[start_linenum] - joined_line += ' ' + start_line.lstrip() - if Search(r'(;|})', start_line): # Declarations and trivial functions - body_found = True - break # ... ignore - elif Search(r'{', start_line): - body_found = True - function = Search(r'((\w|:)*)\(', line).group(1) - if Match(r'TEST', function): # Handle TEST... macros - parameter_regexp = Search(r'(\(.*\))', joined_line) - if parameter_regexp: # Ignore bad syntax - function += parameter_regexp.group(1) - else: - function += '()' - function_state.Begin(function) - break - if not body_found: - # No body for the function (or evidence of a non-function) was found. - error(filename, linenum, 'readability/fn_size', 5, - 'Lint failed to find start of function body.') - elif Match(r'^\}\s*$', line): # function end - function_state.Check(error, filename, linenum) - function_state.End() - elif not Match(r'^\s*$', line): - function_state.Count() # Count non-blank/non-comment lines. - - -_RE_PATTERN_TODO = re.compile(r'^//(\s*)TODO(\(.+?\))?:?(\s|$)?') - - -def CheckComment(line, filename, linenum, next_line_start, error): - """Checks for common mistakes in comments. - - Args: - line: The line in question. - filename: The name of the current file. - linenum: The number of the line to check. - next_line_start: The first non-whitespace column of the next line. - error: The function to call with any errors found. - """ - commentpos = line.find('//') - if commentpos != -1: - # Check if the // may be in quotes. If so, ignore it - if re.sub(r'\\.', '', line[0:commentpos]).count('"') % 2 == 0: - # Allow one space for new scopes, two spaces otherwise: - if (not (Match(r'^.*{ *//', line) and next_line_start == commentpos) and - ((commentpos >= 1 and - line[commentpos-1] not in string.whitespace) or - (commentpos >= 2 and - line[commentpos-2] not in string.whitespace))): - error(filename, linenum, 'whitespace/comments', 2, - 'At least two spaces is best between code and comments') - - # Checks for common mistakes in TODO comments. - comment = line[commentpos:] - match = _RE_PATTERN_TODO.match(comment) - if match: - # One whitespace is correct; zero whitespace is handled elsewhere. - leading_whitespace = match.group(1) - if len(leading_whitespace) > 1: - error(filename, linenum, 'whitespace/todo', 2, - 'Too many spaces before TODO') - - username = match.group(2) - if not username: - error(filename, linenum, 'readability/todo', 2, - 'Missing username in TODO; it should look like ' - '"// TODO(my_username): Stuff."') - - middle_whitespace = match.group(3) - # Comparisons made explicit for correctness -- pylint: disable=g-explicit-bool-comparison - if middle_whitespace != ' ' and middle_whitespace != '': - error(filename, linenum, 'whitespace/todo', 2, - 'TODO(my_username) should be followed by a space') - - # If the comment contains an alphanumeric character, there - # should be a space somewhere between it and the // unless - # it's a /// or //! Doxygen comment. - if (Match(r'//[^ ]*\w', comment) and - not Match(r'(///|//\!)(\s+|$)', comment)): - error(filename, linenum, 'whitespace/comments', 4, - 'Should have a space between // and comment') - - -def CheckSpacing(filename, clean_lines, linenum, nesting_state, error): - """Checks for the correctness of various spacing issues in the code. - - Things we check for: spaces around operators, spaces after - if/for/while/switch, no spaces around parens in function calls, two - spaces between code and comment, don't start a block with a blank - line, don't end a function with a blank line, don't add a blank line - after public/protected/private, don't have too many blank lines in a row. - - Args: - filename: The name of the current file. - clean_lines: A CleansedLines instance containing the file. - linenum: The number of the line to check. - nesting_state: A NestingState instance which maintains information about - the current stack of nested blocks being parsed. - error: The function to call with any errors found. - """ - - # Don't use "elided" lines here, otherwise we can't check commented lines. - # Don't want to use "raw" either, because we don't want to check inside C++11 - # raw strings, - raw = clean_lines.lines_without_raw_strings - line = raw[linenum] - - # Before nixing comments, check if the line is blank for no good - # reason. This includes the first line after a block is opened, and - # blank lines at the end of a function (ie, right before a line like '}' - # - # Skip all the blank line checks if we are immediately inside a - # namespace body. In other words, don't issue blank line warnings - # for this block: - # namespace { - # - # } - # - # A warning about missing end of namespace comments will be issued instead. - # - # Also skip blank line checks for 'extern "C"' blocks, which are formatted - # like namespaces. - if (IsBlankLine(line) and - not nesting_state.InNamespaceBody() and - not nesting_state.InExternC()): - elided = clean_lines.elided - prev_line = elided[linenum - 1] - prevbrace = prev_line.rfind('{') - # TODO(unknown): Don't complain if line before blank line, and line after, - # both start with alnums and are indented the same amount. - # This ignores whitespace at the start of a namespace block - # because those are not usually indented. - if prevbrace != -1 and prev_line[prevbrace:].find('}') == -1: - # OK, we have a blank line at the start of a code block. Before we - # complain, we check if it is an exception to the rule: The previous - # non-empty line has the parameters of a function header that are indented - # 4 spaces (because they did not fit in a 80 column line when placed on - # the same line as the function name). We also check for the case where - # the previous line is indented 6 spaces, which may happen when the - # initializers of a constructor do not fit into a 80 column line. - exception = False - if Match(r' {6}\w', prev_line): # Initializer list? - # We are looking for the opening column of initializer list, which - # should be indented 4 spaces to cause 6 space indentation afterwards. - search_position = linenum-2 - while (search_position >= 0 - and Match(r' {6}\w', elided[search_position])): - search_position -= 1 - exception = (search_position >= 0 - and elided[search_position][:5] == ' :') - else: - # Search for the function arguments or an initializer list. We use a - # simple heuristic here: If the line is indented 4 spaces; and we have a - # closing paren, without the opening paren, followed by an opening brace - # or colon (for initializer lists) we assume that it is the last line of - # a function header. If we have a colon indented 4 spaces, it is an - # initializer list. - exception = (Match(r' {4}\w[^\(]*\)\s*(const\s*)?(\{\s*$|:)', - prev_line) - or Match(r' {4}:', prev_line)) - - if not exception: - error(filename, linenum, 'whitespace/blank_line', 2, - 'Redundant blank line at the start of a code block ' - 'should be deleted.') - # Ignore blank lines at the end of a block in a long if-else - # chain, like this: - # if (condition1) { - # // Something followed by a blank line - # - # } else if (condition2) { - # // Something else - # } - if linenum + 1 < clean_lines.NumLines(): - next_line = raw[linenum + 1] - if (next_line - and Match(r'\s*}', next_line) - and next_line.find('} else ') == -1): - error(filename, linenum, 'whitespace/blank_line', 3, - 'Redundant blank line at the end of a code block ' - 'should be deleted.') - - matched = Match(r'\s*(public|protected|private):', prev_line) - if matched: - error(filename, linenum, 'whitespace/blank_line', 3, - 'Do not leave a blank line after "%s:"' % matched.group(1)) - - # Next, check comments - next_line_start = 0 - if linenum + 1 < clean_lines.NumLines(): - next_line = raw[linenum + 1] - next_line_start = len(next_line) - len(next_line.lstrip()) - CheckComment(line, filename, linenum, next_line_start, error) - - # get rid of comments and strings - line = clean_lines.elided[linenum] - - # You shouldn't have spaces before your brackets, except maybe after - # 'delete []' or 'return []() {};' - if Search(r'\w\s+\[', line) and not Search(r'(?:delete|return)\s+\[', line): - error(filename, linenum, 'whitespace/braces', 5, - 'Extra space before [') - - # In range-based for, we wanted spaces before and after the colon, but - # not around "::" tokens that might appear. - if (Search(r'for *\(.*[^:]:[^: ]', line) or - Search(r'for *\(.*[^: ]:[^:]', line)): - error(filename, linenum, 'whitespace/forcolon', 2, - 'Missing space around colon in range-based for loop') - - -def CheckOperatorSpacing(filename, clean_lines, linenum, error): - """Checks for horizontal spacing around operators. - - Args: - filename: The name of the current file. - clean_lines: A CleansedLines instance containing the file. - linenum: The number of the line to check. - error: The function to call with any errors found. - """ - line = clean_lines.elided[linenum] - - # Don't try to do spacing checks for operator methods. Do this by - # replacing the troublesome characters with something else, - # preserving column position for all other characters. - # - # The replacement is done repeatedly to avoid false positives from - # operators that call operators. - while True: - match = Match(r'^(.*\boperator\b)(\S+)(\s*\(.*)$', line) - if match: - line = match.group(1) + ('_' * len(match.group(2))) + match.group(3) - else: - break - - # We allow no-spaces around = within an if: "if ( (a=Foo()) == 0 )". - # Otherwise not. Note we only check for non-spaces on *both* sides; - # sometimes people put non-spaces on one side when aligning ='s among - # many lines (not that this is behavior that I approve of...) - if ((Search(r'[\w.]=', line) or - Search(r'=[\w.]', line)) - and not Search(r'\b(if|while|for) ', line) - # Operators taken from [lex.operators] in C++11 standard. - and not Search(r'(>=|<=|==|!=|&=|\^=|\|=|\+=|\*=|\/=|\%=)', line) - and not Search(r'operator=', line)): - error(filename, linenum, 'whitespace/operators', 4, - 'Missing spaces around =') - - # It's ok not to have spaces around binary operators like + - * /, but if - # there's too little whitespace, we get concerned. It's hard to tell, - # though, so we punt on this one for now. TODO. - - # You should always have whitespace around binary operators. - # - # Check <= and >= first to avoid false positives with < and >, then - # check non-include lines for spacing around < and >. - # - # If the operator is followed by a comma, assume it's be used in a - # macro context and don't do any checks. This avoids false - # positives. - # - # Note that && is not included here. This is because there are too - # many false positives due to RValue references. - match = Search(r'[^<>=!\s](==|!=|<=|>=|\|\|)[^<>=!\s,;\)]', line) - if match: - error(filename, linenum, 'whitespace/operators', 3, - 'Missing spaces around %s' % match.group(1)) - elif not Match(r'#.*include', line): - # Look for < that is not surrounded by spaces. This is only - # triggered if both sides are missing spaces, even though - # technically should should flag if at least one side is missing a - # space. This is done to avoid some false positives with shifts. - match = Match(r'^(.*[^\s<])<[^\s=<,]', line) - if match: - (_, _, end_pos) = CloseExpression( - clean_lines, linenum, len(match.group(1))) - if end_pos <= -1: - error(filename, linenum, 'whitespace/operators', 3, - 'Missing spaces around <') - - # Look for > that is not surrounded by spaces. Similar to the - # above, we only trigger if both sides are missing spaces to avoid - # false positives with shifts. - match = Match(r'^(.*[^-\s>])>[^\s=>,]', line) - if match: - (_, _, start_pos) = ReverseCloseExpression( - clean_lines, linenum, len(match.group(1))) - if start_pos <= -1: - error(filename, linenum, 'whitespace/operators', 3, - 'Missing spaces around >') - - # We allow no-spaces around << when used like this: 10<<20, but - # not otherwise (particularly, not when used as streams) - # - # We also allow operators following an opening parenthesis, since - # those tend to be macros that deal with operators. - match = Search(r'(operator|[^\s(<])(?:L|UL|LL|ULL|l|ul|ll|ull)?<<([^\s,=<])', line) - if (match and not (match.group(1).isdigit() and match.group(2).isdigit()) and - not (match.group(1) == 'operator' and match.group(2) == ';')): - error(filename, linenum, 'whitespace/operators', 3, - 'Missing spaces around <<') - - # We allow no-spaces around >> for almost anything. This is because - # C++11 allows ">>" to close nested templates, which accounts for - # most cases when ">>" is not followed by a space. - # - # We still warn on ">>" followed by alpha character, because that is - # likely due to ">>" being used for right shifts, e.g.: - # value >> alpha - # - # When ">>" is used to close templates, the alphanumeric letter that - # follows would be part of an identifier, and there should still be - # a space separating the template type and the identifier. - # type> alpha - match = Search(r'>>[a-zA-Z_]', line) - if match: - error(filename, linenum, 'whitespace/operators', 3, - 'Missing spaces around >>') - - # There shouldn't be space around unary operators - match = Search(r'(!\s|~\s|[\s]--[\s;]|[\s]\+\+[\s;])', line) - if match: - error(filename, linenum, 'whitespace/operators', 4, - 'Extra space for operator %s' % match.group(1)) - - -def CheckParenthesisSpacing(filename, clean_lines, linenum, error): - """Checks for horizontal spacing around parentheses. - - Args: - filename: The name of the current file. - clean_lines: A CleansedLines instance containing the file. - linenum: The number of the line to check. - error: The function to call with any errors found. - """ - line = clean_lines.elided[linenum] - - # No spaces after an if, while, switch, or for - match = Search(r' (if\(|for\(|while\(|switch\()', line) - if match: - error(filename, linenum, 'whitespace/parens', 5, - 'Missing space before ( in %s' % match.group(1)) - - # For if/for/while/switch, the left and right parens should be - # consistent about how many spaces are inside the parens, and - # there should either be zero or one spaces inside the parens. - # We don't want: "if ( foo)" or "if ( foo )". - # Exception: "for ( ; foo; bar)" and "for (foo; bar; )" are allowed. - match = Search(r'\b(if|for|while|switch)\s*' - r'\(([ ]*)(.).*[^ ]+([ ]*)\)\s*{\s*$', - line) - if match: - if len(match.group(2)) != len(match.group(4)): - if not (match.group(3) == ';' and - len(match.group(2)) == 1 + len(match.group(4)) or - not match.group(2) and Search(r'\bfor\s*\(.*; \)', line)): - error(filename, linenum, 'whitespace/parens', 5, - 'Mismatching spaces inside () in %s' % match.group(1)) - if len(match.group(2)) not in [0, 1]: - error(filename, linenum, 'whitespace/parens', 5, - 'Should have zero or one spaces inside ( and ) in %s' % - match.group(1)) - - -def CheckCommaSpacing(filename, clean_lines, linenum, error): - """Checks for horizontal spacing near commas and semicolons. - - Args: - filename: The name of the current file. - clean_lines: A CleansedLines instance containing the file. - linenum: The number of the line to check. - error: The function to call with any errors found. - """ - raw = clean_lines.lines_without_raw_strings - line = clean_lines.elided[linenum] - - # You should always have a space after a comma (either as fn arg or operator) - # - # This does not apply when the non-space character following the - # comma is another comma, since the only time when that happens is - # for empty macro arguments. - # - # We run this check in two passes: first pass on elided lines to - # verify that lines contain missing whitespaces, second pass on raw - # lines to confirm that those missing whitespaces are not due to - # elided comments. - if (Search(r',[^,\s]', ReplaceAll(r'\boperator\s*,\s*\(', 'F(', line)) and - Search(r',[^,\s]', raw[linenum])): - error(filename, linenum, 'whitespace/comma', 3, - 'Missing space after ,') - - # You should always have a space after a semicolon - # except for few corner cases - # TODO(unknown): clarify if 'if (1) { return 1;}' is requires one more - # space after ; - if Search(r';[^\s};\\)/]', line): - error(filename, linenum, 'whitespace/semicolon', 3, - 'Missing space after ;') - - -def _IsType(clean_lines, nesting_state, expr): - """Check if expression looks like a type name, returns true if so. - - Args: - clean_lines: A CleansedLines instance containing the file. - nesting_state: A NestingState instance which maintains information about - the current stack of nested blocks being parsed. - expr: The expression to check. - Returns: - True, if token looks like a type. - """ - # Keep only the last token in the expression - last_word = Match(r'^.*(\b\S+)$', expr) - if last_word: - token = last_word.group(1) - else: - token = expr - - # Match native types and stdint types - if _TYPES.match(token): - return True - - # Try a bit harder to match templated types. Walk up the nesting - # stack until we find something that resembles a typename - # declaration for what we are looking for. - typename_pattern = (r'\b(?:typename|class|struct)\s+' + re.escape(token) + - r'\b') - block_index = len(nesting_state.stack) - 1 - while block_index >= 0: - if isinstance(nesting_state.stack[block_index], _NamespaceInfo): - return False - - # Found where the opening brace is. We want to scan from this - # line up to the beginning of the function, minus a few lines. - # template - # class C - # : public ... { // start scanning here - last_line = nesting_state.stack[block_index].starting_linenum - - next_block_start = 0 - if block_index > 0: - next_block_start = nesting_state.stack[block_index - 1].starting_linenum - first_line = last_line - while first_line >= next_block_start: - if clean_lines.elided[first_line].find('template') >= 0: - break - first_line -= 1 - if first_line < next_block_start: - # Didn't find any "template" keyword before reaching the next block, - # there are probably no template things to check for this block - block_index -= 1 - continue - - # Look for typename in the specified range - for i in xrange(first_line, last_line + 1, 1): - if Search(typename_pattern, clean_lines.elided[i]): - return True - block_index -= 1 - - return False - - -def CheckBracesSpacing(filename, clean_lines, linenum, nesting_state, error): - """Checks for horizontal spacing near commas. - - Args: - filename: The name of the current file. - clean_lines: A CleansedLines instance containing the file. - linenum: The number of the line to check. - nesting_state: A NestingState instance which maintains information about - the current stack of nested blocks being parsed. - error: The function to call with any errors found. - """ - line = clean_lines.elided[linenum] - - # Except after an opening paren, or after another opening brace (in case of - # an initializer list, for instance), you should have spaces before your - # braces when they are delimiting blocks, classes, namespaces etc. - # And since you should never have braces at the beginning of a line, - # this is an easy test. Except that braces used for initialization don't - # follow the same rule; we often don't want spaces before those. - match = Match(r'^(.*[^ ({>]){', line) - - if match: - # Try a bit harder to check for brace initialization. This - # happens in one of the following forms: - # Constructor() : initializer_list_{} { ... } - # Constructor{}.MemberFunction() - # Type variable{}; - # FunctionCall(type{}, ...); - # LastArgument(..., type{}); - # LOG(INFO) << type{} << " ..."; - # map_of_type[{...}] = ...; - # ternary = expr ? new type{} : nullptr; - # OuterTemplate{}> - # - # We check for the character following the closing brace, and - # silence the warning if it's one of those listed above, i.e. - # "{.;,)<>]:". - # - # To account for nested initializer list, we allow any number of - # closing braces up to "{;,)<". We can't simply silence the - # warning on first sight of closing brace, because that would - # cause false negatives for things that are not initializer lists. - # Silence this: But not this: - # Outer{ if (...) { - # Inner{...} if (...){ // Missing space before { - # }; } - # - # There is a false negative with this approach if people inserted - # spurious semicolons, e.g. "if (cond){};", but we will catch the - # spurious semicolon with a separate check. - leading_text = match.group(1) - (endline, endlinenum, endpos) = CloseExpression( - clean_lines, linenum, len(match.group(1))) - trailing_text = '' - if endpos > -1: - trailing_text = endline[endpos:] - for offset in xrange(endlinenum + 1, - min(endlinenum + 3, clean_lines.NumLines() - 1)): - trailing_text += clean_lines.elided[offset] - # We also suppress warnings for `uint64_t{expression}` etc., as the style - # guide recommends brace initialization for integral types to avoid - # overflow/truncation. - if (not Match(r'^[\s}]*[{.;,)<>\]:]', trailing_text) - and not _IsType(clean_lines, nesting_state, leading_text)): - error(filename, linenum, 'whitespace/braces', 5, - 'Missing space before {') - - # Make sure '} else {' has spaces. - if Search(r'}else', line): - error(filename, linenum, 'whitespace/braces', 5, - 'Missing space before else') - - # You shouldn't have a space before a semicolon at the end of the line. - # There's a special case for "for" since the style guide allows space before - # the semicolon there. - if Search(r':\s*;\s*$', line): - error(filename, linenum, 'whitespace/semicolon', 5, - 'Semicolon defining empty statement. Use {} instead.') - elif Search(r'^\s*;\s*$', line): - error(filename, linenum, 'whitespace/semicolon', 5, - 'Line contains only semicolon. If this should be an empty statement, ' - 'use {} instead.') - elif (Search(r'\s+;\s*$', line) and - not Search(r'\bfor\b', line)): - error(filename, linenum, 'whitespace/semicolon', 5, - 'Extra space before last semicolon. If this should be an empty ' - 'statement, use {} instead.') - - -def IsDecltype(clean_lines, linenum, column): - """Check if the token ending on (linenum, column) is decltype(). - - Args: - clean_lines: A CleansedLines instance containing the file. - linenum: the number of the line to check. - column: end column of the token to check. - Returns: - True if this token is decltype() expression, False otherwise. - """ - (text, _, start_col) = ReverseCloseExpression(clean_lines, linenum, column) - if start_col < 0: - return False - if Search(r'\bdecltype\s*$', text[0:start_col]): - return True - return False - - -def CheckSectionSpacing(filename, clean_lines, class_info, linenum, error): - """Checks for additional blank line issues related to sections. - - Currently the only thing checked here is blank line before protected/private. - - Args: - filename: The name of the current file. - clean_lines: A CleansedLines instance containing the file. - class_info: A _ClassInfo objects. - linenum: The number of the line to check. - error: The function to call with any errors found. - """ - # Skip checks if the class is small, where small means 25 lines or less. - # 25 lines seems like a good cutoff since that's the usual height of - # terminals, and any class that can't fit in one screen can't really - # be considered "small". - # - # Also skip checks if we are on the first line. This accounts for - # classes that look like - # class Foo { public: ... }; - # - # If we didn't find the end of the class, last_line would be zero, - # and the check will be skipped by the first condition. - if (class_info.last_line - class_info.starting_linenum <= 24 or - linenum <= class_info.starting_linenum): - return - - matched = Match(r'\s*(public|protected|private):', clean_lines.lines[linenum]) - if matched: - # Issue warning if the line before public/protected/private was - # not a blank line, but don't do this if the previous line contains - # "class" or "struct". This can happen two ways: - # - We are at the beginning of the class. - # - We are forward-declaring an inner class that is semantically - # private, but needed to be public for implementation reasons. - # Also ignores cases where the previous line ends with a backslash as can be - # common when defining classes in C macros. - prev_line = clean_lines.lines[linenum - 1] - if (not IsBlankLine(prev_line) and - not Search(r'\b(class|struct)\b', prev_line) and - not Search(r'\\$', prev_line)): - # Try a bit harder to find the beginning of the class. This is to - # account for multi-line base-specifier lists, e.g.: - # class Derived - # : public Base { - end_class_head = class_info.starting_linenum - for i in range(class_info.starting_linenum, linenum): - if Search(r'\{\s*$', clean_lines.lines[i]): - end_class_head = i - break - if end_class_head < linenum - 1: - error(filename, linenum, 'whitespace/blank_line', 3, - '"%s:" should be preceded by a blank line' % matched.group(1)) - - -def GetPreviousNonBlankLine(clean_lines, linenum): - """Return the most recent non-blank line and its line number. - - Args: - clean_lines: A CleansedLines instance containing the file contents. - linenum: The number of the line to check. - - Returns: - A tuple with two elements. The first element is the contents of the last - non-blank line before the current line, or the empty string if this is the - first non-blank line. The second is the line number of that line, or -1 - if this is the first non-blank line. - """ - - prevlinenum = linenum - 1 - while prevlinenum >= 0: - prevline = clean_lines.elided[prevlinenum] - if not IsBlankLine(prevline): # if not a blank line... - return (prevline, prevlinenum) - prevlinenum -= 1 - return ('', -1) - - -def CheckBraces(filename, clean_lines, linenum, error): - """Looks for misplaced braces (e.g. at the end of line). - - Args: - filename: The name of the current file. - clean_lines: A CleansedLines instance containing the file. - linenum: The number of the line to check. - error: The function to call with any errors found. - """ - - line = clean_lines.elided[linenum] # get rid of comments and strings - - if Match(r'\s*{\s*$', line): - # We allow an open brace to start a line in the case where someone is using - # braces in a block to explicitly create a new scope, which is commonly used - # to control the lifetime of stack-allocated variables. Braces are also - # used for brace initializers inside function calls. We don't detect this - # perfectly: we just don't complain if the last non-whitespace character on - # the previous non-blank line is ',', ';', ':', '(', '{', or '}', or if the - # previous line starts a preprocessor block. We also allow a brace on the - # following line if it is part of an array initialization and would not fit - # within the 80 character limit of the preceding line. - prevline = GetPreviousNonBlankLine(clean_lines, linenum)[0] - if (not Search(r'[,;:}{(]\s*$', prevline) and - not Match(r'\s*#', prevline) and - not (GetLineWidth(prevline) > _line_length - 2 and '[]' in prevline)): - error(filename, linenum, 'whitespace/braces', 4, - '{ should almost always be at the end of the previous line') - - # An else clause should be on the same line as the preceding closing brace. - if Match(r'\s*else\b\s*(?:if\b|\{|$)', line): - prevline = GetPreviousNonBlankLine(clean_lines, linenum)[0] - if Match(r'\s*}\s*$', prevline): - error(filename, linenum, 'whitespace/newline', 4, - 'An else should appear on the same line as the preceding }') - - # If braces come on one side of an else, they should be on both. - # However, we have to worry about "else if" that spans multiple lines! - if Search(r'else if\s*\(', line): # could be multi-line if - brace_on_left = bool(Search(r'}\s*else if\s*\(', line)) - # find the ( after the if - pos = line.find('else if') - pos = line.find('(', pos) - if pos > 0: - (endline, _, endpos) = CloseExpression(clean_lines, linenum, pos) - brace_on_right = endline[endpos:].find('{') != -1 - if brace_on_left != brace_on_right: # must be brace after if - error(filename, linenum, 'readability/braces', 5, - 'If an else has a brace on one side, it should have it on both') - elif Search(r'}\s*else[^{]*$', line) or Match(r'[^}]*else\s*{', line): - error(filename, linenum, 'readability/braces', 5, - 'If an else has a brace on one side, it should have it on both') - - # Likewise, an else should never have the else clause on the same line - if Search(r'\belse [^\s{]', line) and not Search(r'\belse if\b', line): - error(filename, linenum, 'whitespace/newline', 4, - 'Else clause should never be on same line as else (use 2 lines)') - - # In the same way, a do/while should never be on one line - if Match(r'\s*do [^\s{]', line): - error(filename, linenum, 'whitespace/newline', 4, - 'do/while clauses should not be on a single line') - - # Check single-line if/else bodies. The style guide says 'curly braces are not - # required for single-line statements'. We additionally allow multi-line, - # single statements, but we reject anything with more than one semicolon in - # it. This means that the first semicolon after the if should be at the end of - # its line, and the line after that should have an indent level equal to or - # lower than the if. We also check for ambiguous if/else nesting without - # braces. - if_else_match = Search(r'\b(if\s*\(|else\b)', line) - if if_else_match and not Match(r'\s*#', line): - if_indent = GetIndentLevel(line) - endline, endlinenum, endpos = line, linenum, if_else_match.end() - if_match = Search(r'\bif\s*\(', line) - if if_match: - # This could be a multiline if condition, so find the end first. - pos = if_match.end() - 1 - (endline, endlinenum, endpos) = CloseExpression(clean_lines, linenum, pos) - # Check for an opening brace, either directly after the if or on the next - # line. If found, this isn't a single-statement conditional. - if (not Match(r'\s*{', endline[endpos:]) - and not (Match(r'\s*$', endline[endpos:]) - and endlinenum < (len(clean_lines.elided) - 1) - and Match(r'\s*{', clean_lines.elided[endlinenum + 1]))): - while (endlinenum < len(clean_lines.elided) - and ';' not in clean_lines.elided[endlinenum][endpos:]): - endlinenum += 1 - endpos = 0 - if endlinenum < len(clean_lines.elided): - endline = clean_lines.elided[endlinenum] - # We allow a mix of whitespace and closing braces (e.g. for one-liner - # methods) and a single \ after the semicolon (for macros) - endpos = endline.find(';') - if not Match(r';[\s}]*(\\?)$', endline[endpos:]): - # Semicolon isn't the last character, there's something trailing. - # Output a warning if the semicolon is not contained inside - # a lambda expression. - if not Match(r'^[^{};]*\[[^\[\]]*\][^{}]*\{[^{}]*\}\s*\)*[;,]\s*$', - endline): - error(filename, linenum, 'readability/braces', 4, - 'If/else bodies with multiple statements require braces') - elif endlinenum < len(clean_lines.elided) - 1: - # Make sure the next line is dedented - next_line = clean_lines.elided[endlinenum + 1] - next_indent = GetIndentLevel(next_line) - # With ambiguous nested if statements, this will error out on the - # if that *doesn't* match the else, regardless of whether it's the - # inner one or outer one. - if (if_match and Match(r'\s*else\b', next_line) - and next_indent != if_indent): - error(filename, linenum, 'readability/braces', 4, - 'Else clause should be indented at the same level as if. ' - 'Ambiguous nested if/else chains require braces.') - elif next_indent > if_indent: - error(filename, linenum, 'readability/braces', 4, - 'If/else bodies with multiple statements require braces') - - -def CheckTrailingSemicolon(filename, clean_lines, linenum, error): - """Looks for redundant trailing semicolon. - - Args: - filename: The name of the current file. - clean_lines: A CleansedLines instance containing the file. - linenum: The number of the line to check. - error: The function to call with any errors found. - """ - - line = clean_lines.elided[linenum] - - # Block bodies should not be followed by a semicolon. Due to C++11 - # brace initialization, there are more places where semicolons are - # required than not, so we use an allowlist approach to check these - # rather than a denylist. These are the places where "};" should - # be replaced by just "}": - # 1. Some flavor of block following closing parenthesis: - # for (;;) {}; - # while (...) {}; - # switch (...) {}; - # Function(...) {}; - # if (...) {}; - # if (...) else if (...) {}; - # - # 2. else block: - # if (...) else {}; - # - # 3. const member function: - # Function(...) const {}; - # - # 4. Block following some statement: - # x = 42; - # {}; - # - # 5. Block at the beginning of a function: - # Function(...) { - # {}; - # } - # - # Note that naively checking for the preceding "{" will also match - # braces inside multi-dimensional arrays, but this is fine since - # that expression will not contain semicolons. - # - # 6. Block following another block: - # while (true) {} - # {}; - # - # 7. End of namespaces: - # namespace {}; - # - # These semicolons seems far more common than other kinds of - # redundant semicolons, possibly due to people converting classes - # to namespaces. For now we do not warn for this case. - # - # Try matching case 1 first. - match = Match(r'^(.*\)\s*)\{', line) - if match: - # Matched closing parenthesis (case 1). Check the token before the - # matching opening parenthesis, and don't warn if it looks like a - # macro. This avoids these false positives: - # - macro that defines a base class - # - multi-line macro that defines a base class - # - macro that defines the whole class-head - # - # But we still issue warnings for macros that we know are safe to - # warn, specifically: - # - TEST, TEST_F, TEST_P, MATCHER, MATCHER_P - # - TYPED_TEST - # - INTERFACE_DEF - # - EXCLUSIVE_LOCKS_REQUIRED, SHARED_LOCKS_REQUIRED, LOCKS_EXCLUDED: - # - # We implement an allowlist of safe macros instead of a denylist of - # unsafe macros, even though the latter appears less frequently in - # google code and would have been easier to implement. This is because - # the downside for getting the allowlist wrong means some extra - # semicolons, while the downside for getting the denylist wrong - # would result in compile errors. - # - # In addition to macros, we also don't want to warn on - # - Compound literals - # - Lambdas - # - alignas specifier with anonymous structs - # - decltype - closing_brace_pos = match.group(1).rfind(')') - opening_parenthesis = ReverseCloseExpression( - clean_lines, linenum, closing_brace_pos) - if opening_parenthesis[2] > -1: - line_prefix = opening_parenthesis[0][0:opening_parenthesis[2]] - macro = Search(r'\b([A-Z_][A-Z0-9_]*)\s*$', line_prefix) - func = Match(r'^(.*\])\s*$', line_prefix) - if ((macro and - macro.group(1) not in ( - 'TEST', 'TEST_F', 'MATCHER', 'MATCHER_P', 'TYPED_TEST', - 'EXCLUSIVE_LOCKS_REQUIRED', 'SHARED_LOCKS_REQUIRED', - 'LOCKS_EXCLUDED', 'INTERFACE_DEF')) or - (func and not Search(r'\boperator\s*\[\s*\]', func.group(1))) or - Search(r'\b(?:struct|union)\s+alignas\s*$', line_prefix) or - Search(r'\bdecltype$', line_prefix) or - Search(r'\s+=\s*$', line_prefix)): - match = None - if (match and - opening_parenthesis[1] > 1 and - Search(r'\]\s*$', clean_lines.elided[opening_parenthesis[1] - 1])): - # Multi-line lambda-expression - match = None - - else: - # Try matching cases 2-3. - match = Match(r'^(.*(?:else|\)\s*const)\s*)\{', line) - if not match: - # Try matching cases 4-6. These are always matched on separate lines. - # - # Note that we can't simply concatenate the previous line to the - # current line and do a single match, otherwise we may output - # duplicate warnings for the blank line case: - # if (cond) { - # // blank line - # } - prevline = GetPreviousNonBlankLine(clean_lines, linenum)[0] - if prevline and Search(r'[;{}]\s*$', prevline): - match = Match(r'^(\s*)\{', line) - - # Check matching closing brace - if match: - (endline, endlinenum, endpos) = CloseExpression( - clean_lines, linenum, len(match.group(1))) - if endpos > -1 and Match(r'^\s*;', endline[endpos:]): - # Current {} pair is eligible for semicolon check, and we have found - # the redundant semicolon, output warning here. - # - # Note: because we are scanning forward for opening braces, and - # outputting warnings for the matching closing brace, if there are - # nested blocks with trailing semicolons, we will get the error - # messages in reversed order. - - # We need to check the line forward for NOLINT - raw_lines = clean_lines.raw_lines - ParseNolintSuppressions(filename, raw_lines[endlinenum-1], endlinenum-1, - error) - ParseNolintSuppressions(filename, raw_lines[endlinenum], endlinenum, - error) - - error(filename, endlinenum, 'readability/braces', 4, - "You don't need a ; after a }") - - -def CheckEmptyBlockBody(filename, clean_lines, linenum, error): - """Look for empty loop/conditional body with only a single semicolon. - - Args: - filename: The name of the current file. - clean_lines: A CleansedLines instance containing the file. - linenum: The number of the line to check. - error: The function to call with any errors found. - """ - - # Search for loop keywords at the beginning of the line. Because only - # whitespaces are allowed before the keywords, this will also ignore most - # do-while-loops, since those lines should start with closing brace. - # - # We also check "if" blocks here, since an empty conditional block - # is likely an error. - line = clean_lines.elided[linenum] - matched = Match(r'\s*(for|while|if)\s*\(', line) - if matched: - # Find the end of the conditional expression. - (end_line, end_linenum, end_pos) = CloseExpression( - clean_lines, linenum, line.find('(')) - - # Output warning if what follows the condition expression is a semicolon. - # No warning for all other cases, including whitespace or newline, since we - # have a separate check for semicolons preceded by whitespace. - if end_pos >= 0 and Match(r';', end_line[end_pos:]): - if matched.group(1) == 'if': - error(filename, end_linenum, 'whitespace/empty_conditional_body', 5, - 'Empty conditional bodies should use {}') - else: - error(filename, end_linenum, 'whitespace/empty_loop_body', 5, - 'Empty loop bodies should use {} or continue') - - # Check for if statements that have completely empty bodies (no comments) - # and no else clauses. - if end_pos >= 0 and matched.group(1) == 'if': - # Find the position of the opening { for the if statement. - # Return without logging an error if it has no brackets. - opening_linenum = end_linenum - opening_line_fragment = end_line[end_pos:] - # Loop until EOF or find anything that's not whitespace or opening {. - while not Search(r'^\s*\{', opening_line_fragment): - if Search(r'^(?!\s*$)', opening_line_fragment): - # Conditional has no brackets. - return - opening_linenum += 1 - if opening_linenum == len(clean_lines.elided): - # Couldn't find conditional's opening { or any code before EOF. - return - opening_line_fragment = clean_lines.elided[opening_linenum] - # Set opening_line (opening_line_fragment may not be entire opening line). - opening_line = clean_lines.elided[opening_linenum] - - # Find the position of the closing }. - opening_pos = opening_line_fragment.find('{') - if opening_linenum == end_linenum: - # We need to make opening_pos relative to the start of the entire line. - opening_pos += end_pos - (closing_line, closing_linenum, closing_pos) = CloseExpression( - clean_lines, opening_linenum, opening_pos) - if closing_pos < 0: - return - - # Now construct the body of the conditional. This consists of the portion - # of the opening line after the {, all lines until the closing line, - # and the portion of the closing line before the }. - if (clean_lines.raw_lines[opening_linenum] != - CleanseComments(clean_lines.raw_lines[opening_linenum])): - # Opening line ends with a comment, so conditional isn't empty. - return - if closing_linenum > opening_linenum: - # Opening line after the {. Ignore comments here since we checked above. - body = list(opening_line[opening_pos+1:]) - # All lines until closing line, excluding closing line, with comments. - body.extend(clean_lines.raw_lines[opening_linenum+1:closing_linenum]) - # Closing line before the }. Won't (and can't) have comments. - body.append(clean_lines.elided[closing_linenum][:closing_pos-1]) - body = '\n'.join(body) - else: - # If statement has brackets and fits on a single line. - body = opening_line[opening_pos+1:closing_pos-1] - - # Check if the body is empty - if not _EMPTY_CONDITIONAL_BODY_PATTERN.search(body): - return - # The body is empty. Now make sure there's not an else clause. - current_linenum = closing_linenum - current_line_fragment = closing_line[closing_pos:] - # Loop until EOF or find anything that's not whitespace or else clause. - while Search(r'^\s*$|^(?=\s*else)', current_line_fragment): - if Search(r'^(?=\s*else)', current_line_fragment): - # Found an else clause, so don't log an error. - return - current_linenum += 1 - if current_linenum == len(clean_lines.elided): - break - current_line_fragment = clean_lines.elided[current_linenum] - - # The body is empty and there's no else clause until EOF or other code. - error(filename, end_linenum, 'whitespace/empty_if_body', 4, - ('If statement had no body and no else clause')) - - -def FindCheckMacro(line): - """Find a replaceable CHECK-like macro. - - Args: - line: line to search on. - Returns: - (macro name, start position), or (None, -1) if no replaceable - macro is found. - """ - for macro in _CHECK_MACROS: - i = line.find(macro) - if i >= 0: - # Find opening parenthesis. Do a regular expression match here - # to make sure that we are matching the expected CHECK macro, as - # opposed to some other macro that happens to contain the CHECK - # substring. - matched = Match(r'^(.*\b' + macro + r'\s*)\(', line) - if not matched: - continue - return (macro, len(matched.group(1))) - return (None, -1) - - -def CheckCheck(filename, clean_lines, linenum, error): - """Checks the use of CHECK and EXPECT macros. - - Args: - filename: The name of the current file. - clean_lines: A CleansedLines instance containing the file. - linenum: The number of the line to check. - error: The function to call with any errors found. - """ - - # Decide the set of replacement macros that should be suggested - lines = clean_lines.elided - (check_macro, start_pos) = FindCheckMacro(lines[linenum]) - if not check_macro: - return - - # Find end of the boolean expression by matching parentheses - (last_line, end_line, end_pos) = CloseExpression( - clean_lines, linenum, start_pos) - if end_pos < 0: - return - - # If the check macro is followed by something other than a - # semicolon, assume users will log their own custom error messages - # and don't suggest any replacements. - if not Match(r'\s*;', last_line[end_pos:]): - return - - if linenum == end_line: - expression = lines[linenum][start_pos + 1:end_pos - 1] - else: - expression = lines[linenum][start_pos + 1:] - for i in xrange(linenum + 1, end_line): - expression += lines[i] - expression += last_line[0:end_pos - 1] - - # Parse expression so that we can take parentheses into account. - # This avoids false positives for inputs like "CHECK((a < 4) == b)", - # which is not replaceable by CHECK_LE. - lhs = '' - rhs = '' - operator = None - while expression: - matched = Match(r'^\s*(<<|<<=|>>|>>=|->\*|->|&&|\|\||' - r'==|!=|>=|>|<=|<|\()(.*)$', expression) - if matched: - token = matched.group(1) - if token == '(': - # Parenthesized operand - expression = matched.group(2) - (end, _) = FindEndOfExpressionInLine(expression, 0, ['(']) - if end < 0: - return # Unmatched parenthesis - lhs += '(' + expression[0:end] - expression = expression[end:] - elif token in ('&&', '||'): - # Logical and/or operators. This means the expression - # contains more than one term, for example: - # CHECK(42 < a && a < b); - # - # These are not replaceable with CHECK_LE, so bail out early. - return - elif token in ('<<', '<<=', '>>', '>>=', '->*', '->'): - # Non-relational operator - lhs += token - expression = matched.group(2) - else: - # Relational operator - operator = token - rhs = matched.group(2) - break - else: - # Unparenthesized operand. Instead of appending to lhs one character - # at a time, we do another regular expression match to consume several - # characters at once if possible. Trivial benchmark shows that this - # is more efficient when the operands are longer than a single - # character, which is generally the case. - matched = Match(r'^([^-=!<>()&|]+)(.*)$', expression) - if not matched: - matched = Match(r'^(\s*\S)(.*)$', expression) - if not matched: - break - lhs += matched.group(1) - expression = matched.group(2) - - # Only apply checks if we got all parts of the boolean expression - if not (lhs and operator and rhs): - return - - # Check that rhs do not contain logical operators. We already know - # that lhs is fine since the loop above parses out && and ||. - if rhs.find('&&') > -1 or rhs.find('||') > -1: - return - - # At least one of the operands must be a constant literal. This is - # to avoid suggesting replacements for unprintable things like - # CHECK(variable != iterator) - # - # The following pattern matches decimal, hex integers, strings, and - # characters (in that order). - lhs = lhs.strip() - rhs = rhs.strip() - match_constant = r'^([-+]?(\d+|0[xX][0-9a-fA-F]+)[lLuU]{0,3}|".*"|\'.*\')$' - if Match(match_constant, lhs) or Match(match_constant, rhs): - # Note: since we know both lhs and rhs, we can provide a more - # descriptive error message like: - # Consider using CHECK_EQ(x, 42) instead of CHECK(x == 42) - # Instead of: - # Consider using CHECK_EQ instead of CHECK(a == b) - # - # We are still keeping the less descriptive message because if lhs - # or rhs gets long, the error message might become unreadable. - error(filename, linenum, 'readability/check', 2, - 'Consider using %s instead of %s(a %s b)' % ( - _CHECK_REPLACEMENT[check_macro][operator], - check_macro, operator)) - - -def CheckAltTokens(filename, clean_lines, linenum, error): - """Check alternative keywords being used in boolean expressions. - - Args: - filename: The name of the current file. - clean_lines: A CleansedLines instance containing the file. - linenum: The number of the line to check. - error: The function to call with any errors found. - """ - line = clean_lines.elided[linenum] - - # Avoid preprocessor lines - if Match(r'^\s*#', line): - return - - # Last ditch effort to avoid multi-line comments. This will not help - # if the comment started before the current line or ended after the - # current line, but it catches most of the false positives. At least, - # it provides a way to workaround this warning for people who use - # multi-line comments in preprocessor macros. - # - # TODO(unknown): remove this once cpplint has better support for - # multi-line comments. - if line.find('/*') >= 0 or line.find('*/') >= 0: - return - - for match in _ALT_TOKEN_REPLACEMENT_PATTERN.finditer(line): - error(filename, linenum, 'readability/alt_tokens', 2, - 'Use operator %s instead of %s' % ( - _ALT_TOKEN_REPLACEMENT[match.group(1)], match.group(1))) - - -def GetLineWidth(line): - """Determines the width of the line in column positions. - - Args: - line: A string, which may be a Unicode string. - - Returns: - The width of the line in column positions, accounting for Unicode - combining characters and wide characters. - """ - if isinstance(line, unicode): - width = 0 - for uc in unicodedata.normalize('NFC', line): - if unicodedata.east_asian_width(uc) in ('W', 'F'): - width += 2 - elif not unicodedata.combining(uc): - # Issue 337 - # https://mail.python.org/pipermail/python-list/2012-August/628809.html - if (sys.version_info.major, sys.version_info.minor) <= (3, 2): - # https://github.com/python/cpython/blob/2.7/Include/unicodeobject.h#L81 - is_wide_build = sysconfig.get_config_var("Py_UNICODE_SIZE") >= 4 - # https://github.com/python/cpython/blob/2.7/Objects/unicodeobject.c#L564 - is_low_surrogate = 0xDC00 <= ord(uc) <= 0xDFFF - if not is_wide_build and is_low_surrogate: - width -= 1 - - width += 1 - return width - else: - return len(line) - - -def CheckStyle(filename, clean_lines, linenum, file_extension, nesting_state, - error): - """Checks rules from the 'C++ style rules' section of cppguide.html. - - Most of these rules are hard to test (naming, comment style), but we - do what we can. In particular we check for 2-space indents, line lengths, - tab usage, spaces inside code, etc. - - Args: - filename: The name of the current file. - clean_lines: A CleansedLines instance containing the file. - linenum: The number of the line to check. - file_extension: The extension (without the dot) of the filename. - nesting_state: A NestingState instance which maintains information about - the current stack of nested blocks being parsed. - error: The function to call with any errors found. - """ - - # Don't use "elided" lines here, otherwise we can't check commented lines. - # Don't want to use "raw" either, because we don't want to check inside C++11 - # raw strings, - raw_lines = clean_lines.lines_without_raw_strings - line = raw_lines[linenum] - prev = raw_lines[linenum - 1] if linenum > 0 else '' - - if line.find('\t') != -1: - error(filename, linenum, 'whitespace/tab', 1, - 'Tab found; better to use spaces') - - # One or three blank spaces at the beginning of the line is weird; it's - # hard to reconcile that with 2-space indents. - # NOTE: here are the conditions rob pike used for his tests. Mine aren't - # as sophisticated, but it may be worth becoming so: RLENGTH==initial_spaces - # if(RLENGTH > 20) complain = 0; - # if(match($0, " +(error|private|public|protected):")) complain = 0; - # if(match(prev, "&& *$")) complain = 0; - # if(match(prev, "\\|\\| *$")) complain = 0; - # if(match(prev, "[\",=><] *$")) complain = 0; - # if(match($0, " <<")) complain = 0; - # if(match(prev, " +for \\(")) complain = 0; - # if(prevodd && match(prevprev, " +for \\(")) complain = 0; - scope_or_label_pattern = r'\s*\w+\s*:\s*\\?$' - classinfo = nesting_state.InnermostClass() - initial_spaces = 0 - cleansed_line = clean_lines.elided[linenum] - while initial_spaces < len(line) and line[initial_spaces] == ' ': - initial_spaces += 1 - # There are certain situations we allow one space, notably for - # section labels, and also lines containing multi-line raw strings. - # We also don't check for lines that look like continuation lines - # (of lines ending in double quotes, commas, equals, or angle brackets) - # because the rules for how to indent those are non-trivial. - if (not Search(r'[",=><] *$', prev) and - (initial_spaces == 1 or initial_spaces == 3) and - not Match(scope_or_label_pattern, cleansed_line) and - not (clean_lines.raw_lines[linenum] != line and - Match(r'^\s*""', line))): - error(filename, linenum, 'whitespace/indent', 3, - 'Weird number of spaces at line-start. ' - 'Are you using a 2-space indent?') - - if line and line[-1].isspace(): - error(filename, linenum, 'whitespace/end_of_line', 4, - 'Line ends in whitespace. Consider deleting these extra spaces.') - - # Check if the line is a header guard. - is_header_guard = False - if IsHeaderExtension(file_extension): - cppvar = GetHeaderGuardCPPVariable(filename) - if (line.startswith('#ifndef %s' % cppvar) or - line.startswith('#define %s' % cppvar) or - line.startswith('#endif // %s' % cppvar)): - is_header_guard = True - # #include lines and header guards can be long, since there's no clean way to - # split them. - # - # URLs can be long too. It's possible to split these, but it makes them - # harder to cut&paste. - # - # The "$Id:...$" comment may also get very long without it being the - # developers fault. - if (not line.startswith('#include') and not is_header_guard and - not Match(r'^\s*//.*http(s?)://\S*$', line) and - not Match(r'^\s*//\s*[^\s]*$', line) and - not Match(r'^// \$Id:.*#[0-9]+ \$$', line)): - line_width = GetLineWidth(line) - if line_width > _line_length: - error(filename, linenum, 'whitespace/line_length', 2, - 'Lines should be <= %i characters long' % _line_length) - - if (cleansed_line.count(';') > 1 and - # for loops are allowed two ;'s (and may run over two lines). - cleansed_line.find('for') == -1 and - (GetPreviousNonBlankLine(clean_lines, linenum)[0].find('for') == -1 or - GetPreviousNonBlankLine(clean_lines, linenum)[0].find(';') != -1) and - # It's ok to have many commands in a switch case that fits in 1 line - not ((cleansed_line.find('case ') != -1 or - cleansed_line.find('default:') != -1) and - cleansed_line.find('break;') != -1)): - error(filename, linenum, 'whitespace/newline', 0, - 'More than one command on the same line') - - # Some more style checks - CheckBraces(filename, clean_lines, linenum, error) - CheckTrailingSemicolon(filename, clean_lines, linenum, error) - CheckEmptyBlockBody(filename, clean_lines, linenum, error) - CheckSpacing(filename, clean_lines, linenum, nesting_state, error) - CheckOperatorSpacing(filename, clean_lines, linenum, error) - CheckParenthesisSpacing(filename, clean_lines, linenum, error) - CheckCommaSpacing(filename, clean_lines, linenum, error) - CheckBracesSpacing(filename, clean_lines, linenum, nesting_state, error) - CheckSpacingForFunctionCall(filename, clean_lines, linenum, error) - CheckCheck(filename, clean_lines, linenum, error) - CheckAltTokens(filename, clean_lines, linenum, error) - classinfo = nesting_state.InnermostClass() - if classinfo: - CheckSectionSpacing(filename, clean_lines, classinfo, linenum, error) - - -_RE_PATTERN_INCLUDE = re.compile(r'^\s*#\s*include\s*([<"])([^>"]*)[>"].*$') -# Matches the first component of a filename delimited by -s and _s. That is: -# _RE_FIRST_COMPONENT.match('foo').group(0) == 'foo' -# _RE_FIRST_COMPONENT.match('foo.cc').group(0) == 'foo' -# _RE_FIRST_COMPONENT.match('foo-bar_baz.cc').group(0) == 'foo' -# _RE_FIRST_COMPONENT.match('foo_bar-baz.cc').group(0) == 'foo' -_RE_FIRST_COMPONENT = re.compile(r'^[^-_.]+') - - -def _DropCommonSuffixes(filename): - """Drops common suffixes like _test.cc or -inl.h from filename. - - For example: - >>> _DropCommonSuffixes('foo/foo-inl.h') - 'foo/foo' - >>> _DropCommonSuffixes('foo/bar/foo.cc') - 'foo/bar/foo' - >>> _DropCommonSuffixes('foo/foo_internal.h') - 'foo/foo' - >>> _DropCommonSuffixes('foo/foo_unusualinternal.h') - 'foo/foo_unusualinternal' - - Args: - filename: The input filename. - - Returns: - The filename with the common suffix removed. - """ - for suffix in ('test.cc', 'regtest.cc', 'unittest.cc', - 'inl.h', 'impl.h', 'internal.h'): - if (filename.endswith(suffix) and len(filename) > len(suffix) and - filename[-len(suffix) - 1] in ('-', '_')): - return filename[:-len(suffix) - 1] - return os.path.splitext(filename)[0] - - -def _ClassifyInclude(fileinfo, include, is_system): - """Figures out what kind of header 'include' is. - - Args: - fileinfo: The current file cpplint is running over. A FileInfo instance. - include: The path to a #included file. - is_system: True if the #include used <> rather than "". - - Returns: - One of the _XXX_HEADER constants. - - For example: - >>> _ClassifyInclude(FileInfo('foo/foo.cc'), 'stdio.h', True) - _C_SYS_HEADER - >>> _ClassifyInclude(FileInfo('foo/foo.cc'), 'string', True) - _CPP_SYS_HEADER - >>> _ClassifyInclude(FileInfo('foo/foo.cc'), 'foo/foo.h', False) - _LIKELY_MY_HEADER - >>> _ClassifyInclude(FileInfo('foo/foo_unknown_extension.cc'), - ... 'bar/foo_other_ext.h', False) - _POSSIBLE_MY_HEADER - >>> _ClassifyInclude(FileInfo('foo/foo.cc'), 'foo/bar.h', False) - _OTHER_HEADER - """ - # This is a list of all standard c++ header files, except - # those already checked for above. - is_cpp_h = include in _CPP_HEADERS - - if is_system: - if is_cpp_h: - return _CPP_SYS_HEADER - else: - return _C_SYS_HEADER - - # If the target file and the include we're checking share a - # basename when we drop common extensions, and the include - # lives in . , then it's likely to be owned by the target file. - target_dir, target_base = ( - os.path.split(_DropCommonSuffixes(fileinfo.RepositoryName()))) - include_dir, include_base = os.path.split(_DropCommonSuffixes(include)) - if target_base == include_base and ( - include_dir == target_dir or - include_dir == os.path.normpath(target_dir + '/../public')): - return _LIKELY_MY_HEADER - - # If the target and include share some initial basename - # component, it's possible the target is implementing the - # include, so it's allowed to be first, but we'll never - # complain if it's not there. - target_first_component = _RE_FIRST_COMPONENT.match(target_base) - include_first_component = _RE_FIRST_COMPONENT.match(include_base) - if (target_first_component and include_first_component and - target_first_component.group(0) == - include_first_component.group(0)): - return _POSSIBLE_MY_HEADER - - return _OTHER_HEADER - - - -def CheckIncludeLine(filename, clean_lines, linenum, include_state, error): - """Check rules that are applicable to #include lines. - - Strings on #include lines are NOT removed from elided line, to make - certain tasks easier. However, to prevent false positives, checks - applicable to #include lines in CheckLanguage must be put here. - - Args: - filename: The name of the current file. - clean_lines: A CleansedLines instance containing the file. - linenum: The number of the line to check. - include_state: An _IncludeState instance in which the headers are inserted. - error: The function to call with any errors found. - """ - fileinfo = FileInfo(filename) - line = clean_lines.lines[linenum] - - # "include" should use the new style "foo/bar.h" instead of just "bar.h" - # Only do this check if the included header follows google naming - # conventions. If not, assume that it's a 3rd party API that - # requires special include conventions. - # - # We also make an exception for Lua headers, which follow google - # naming convention but not the include convention. - match = Match(r'#include\s*"([^/]+\.h)"', line) - if match and not _THIRD_PARTY_HEADERS_PATTERN.match(match.group(1)): - error(filename, linenum, 'build/include', 4, - 'Include the directory when naming .h files') - - # we shouldn't include a file more than once. actually, there are a - # handful of instances where doing so is okay, but in general it's - # not. - match = _RE_PATTERN_INCLUDE.search(line) - if match: - include = match.group(2) - is_system = (match.group(1) == '<') - duplicate_line = include_state.FindHeader(include) - if duplicate_line >= 0: - error(filename, linenum, 'build/include', 4, - '"%s" already included at %s:%s' % - (include, filename, duplicate_line)) - elif (include.endswith('.cc') and - os.path.dirname(fileinfo.RepositoryName()) != os.path.dirname(include)): - error(filename, linenum, 'build/include', 4, - 'Do not include .cc files from other packages') - elif not _THIRD_PARTY_HEADERS_PATTERN.match(include): - include_state.include_list[-1].append((include, linenum)) - - # We want to ensure that headers appear in the right order: - # 1) for foo.cc, foo.h (preferred location) - # 2) c system files - # 3) cpp system files - # 4) for foo.cc, foo.h (deprecated location) - # 5) other google headers - # - # We classify each include statement as one of those 5 types - # using a number of techniques. The include_state object keeps - # track of the highest type seen, and complains if we see a - # lower type after that. - error_message = include_state.CheckNextIncludeOrder( - _ClassifyInclude(fileinfo, include, is_system)) - if error_message: - error(filename, linenum, 'build/include_order', 4, - '%s. Should be: %s.h, c system, c++ system, other.' % - (error_message, fileinfo.BaseName())) - canonical_include = include_state.CanonicalizeAlphabeticalOrder(include) - if not include_state.IsInAlphabeticalOrder( - clean_lines, linenum, canonical_include): - error(filename, linenum, 'build/include_alpha', 4, - 'Include "%s" not in alphabetical order' % include) - include_state.SetLastHeader(canonical_include) - - - -def _GetTextInside(text, start_pattern): - r"""Retrieves all the text between matching open and close parentheses. - - Given a string of lines and a regular expression string, retrieve all the text - following the expression and between opening punctuation symbols like - (, [, or {, and the matching close-punctuation symbol. This properly nested - occurrences of the punctuations, so for the text like - printf(a(), b(c())); - a call to _GetTextInside(text, r'printf\(') will return 'a(), b(c())'. - start_pattern must match string having an open punctuation symbol at the end. - - Args: - text: The lines to extract text. Its comments and strings must be elided. - It can be single line and can span multiple lines. - start_pattern: The regexp string indicating where to start extracting - the text. - Returns: - The extracted text. - None if either the opening string or ending punctuation could not be found. - """ - # TODO(unknown): Audit cpplint.py to see what places could be profitably - # rewritten to use _GetTextInside (and use inferior regexp matching today). - - # Give opening punctuations to get the matching close-punctuations. - matching_punctuation = {'(': ')', '{': '}', '[': ']'} - closing_punctuation = set(matching_punctuation.itervalues()) - - # Find the position to start extracting text. - match = re.search(start_pattern, text, re.M) - if not match: # start_pattern not found in text. - return None - start_position = match.end(0) - - assert start_position > 0, ( - 'start_pattern must ends with an opening punctuation.') - assert text[start_position - 1] in matching_punctuation, ( - 'start_pattern must ends with an opening punctuation.') - # Stack of closing punctuations we expect to have in text after position. - punctuation_stack = [matching_punctuation[text[start_position - 1]]] - position = start_position - while punctuation_stack and position < len(text): - if text[position] == punctuation_stack[-1]: - punctuation_stack.pop() - elif text[position] in closing_punctuation: - # A closing punctuation without matching opening punctuations. - return None - elif text[position] in matching_punctuation: - punctuation_stack.append(matching_punctuation[text[position]]) - position += 1 - if punctuation_stack: - # Opening punctuations left without matching close-punctuations. - return None - # punctuations match. - return text[start_position:position - 1] - - -# Patterns for matching call-by-reference parameters. -# -# Supports nested templates up to 2 levels deep using this messy pattern: -# < (?: < (?: < [^<>]* -# > -# | [^<>] )* -# > -# | [^<>] )* -# > -_RE_PATTERN_IDENT = r'[_a-zA-Z]\w*' # =~ [[:alpha:]][[:alnum:]]* -_RE_PATTERN_TYPE = ( - r'(?:const\s+)?(?:typename\s+|class\s+|struct\s+|union\s+|enum\s+)?' - r'(?:\w|' - r'\s*<(?:<(?:<[^<>]*>|[^<>])*>|[^<>])*>|' - r'::)+') -# A call-by-reference parameter ends with '& identifier'. -_RE_PATTERN_REF_PARAM = re.compile( - r'(' + _RE_PATTERN_TYPE + r'(?:\s*(?:\bconst\b|[*]))*\s*' - r'&\s*' + _RE_PATTERN_IDENT + r')\s*(?:=[^,()]+)?[,)]') -# A call-by-const-reference parameter either ends with 'const& identifier' -# or looks like 'const type& identifier' when 'type' is atomic. -_RE_PATTERN_CONST_REF_PARAM = ( - r'(?:.*\s*\bconst\s*&\s*' + _RE_PATTERN_IDENT + - r'|const\s+' + _RE_PATTERN_TYPE + r'\s*&\s*' + _RE_PATTERN_IDENT + r')') -# Stream types. -_RE_PATTERN_REF_STREAM_PARAM = ( - r'(?:.*stream\s*&\s*' + _RE_PATTERN_IDENT + r')') - - -def CheckLanguage(filename, clean_lines, linenum, file_extension, - include_state, nesting_state, error): - """Checks rules from the 'C++ language rules' section of cppguide.html. - - Some of these rules are hard to test (function overloading, using - uint32 inappropriately), but we do the best we can. - - Args: - filename: The name of the current file. - clean_lines: A CleansedLines instance containing the file. - linenum: The number of the line to check. - file_extension: The extension (without the dot) of the filename. - include_state: An _IncludeState instance in which the headers are inserted. - nesting_state: A NestingState instance which maintains information about - the current stack of nested blocks being parsed. - error: The function to call with any errors found. - """ - # If the line is empty or consists of entirely a comment, no need to - # check it. - line = clean_lines.elided[linenum] - if not line: - return - - match = _RE_PATTERN_INCLUDE.search(line) - if match: - CheckIncludeLine(filename, clean_lines, linenum, include_state, error) - return - - # Reset include state across preprocessor directives. This is meant - # to silence warnings for conditional includes. - match = Match(r'^\s*#\s*(if|ifdef|ifndef|elif|else|endif)\b', line) - if match: - include_state.ResetSection(match.group(1)) - - # Make Windows paths like Unix. - fullname = os.path.abspath(filename).replace('\\', '/') - - # Perform other checks now that we are sure that this is not an include line - CheckCasts(filename, clean_lines, linenum, error) - CheckGlobalStatic(filename, clean_lines, linenum, error) - CheckPrintf(filename, clean_lines, linenum, error) - - if IsHeaderExtension(file_extension): - # TODO(unknown): check that 1-arg constructors are explicit. - # How to tell it's a constructor? - # (handled in CheckForNonStandardConstructs for now) - # TODO(unknown): check that classes declare or disable copy/assign - # (level 1 error) - pass - - # Check if people are using the verboten C basic types. The only exception - # we regularly allow is "unsigned short port" for port. - if Search(r'\bshort port\b', line): - if not Search(r'\bunsigned short port\b', line): - error(filename, linenum, 'runtime/int', 4, - 'Use "unsigned short" for ports, not "short"') - else: - match = Search(r'\b(short|long(?! +double)|long long)\b', line) - if match: - error(filename, linenum, 'runtime/int', 4, - 'Use int16/int64/etc, rather than the C type %s' % match.group(1)) - - # Check if some verboten operator overloading is going on - # TODO(unknown): catch out-of-line unary operator&: - # class X {}; - # int operator&(const X& x) { return 42; } // unary operator& - # The trick is it's hard to tell apart from binary operator&: - # class Y { int operator&(const Y& x) { return 23; } }; // binary operator& - if Search(r'\boperator\s*&\s*\(\s*\)', line): - error(filename, linenum, 'runtime/operator', 4, - 'Unary operator& is dangerous. Do not use it.') - - # Check for suspicious usage of "if" like - # } if (a == b) { - if Search(r'\}\s*if\s*\(', line): - error(filename, linenum, 'readability/braces', 4, - 'Did you mean "else if"? If not, start a new line for "if".') - - # Check for potential format string bugs like printf(foo). - # We constrain the pattern not to pick things like DocidForPrintf(foo). - # Not perfect but it can catch printf(foo.c_str()) and printf(foo->c_str()) - # TODO(unknown): Catch the following case. Need to change the calling - # convention of the whole function to process multiple line to handle it. - # printf( - # boy_this_is_a_really_long_variable_that_cannot_fit_on_the_prev_line); - printf_args = _GetTextInside(line, r'(?i)\b(string)?printf\s*\(') - if printf_args: - match = Match(r'([\w.\->()]+)$', printf_args) - if match and match.group(1) != '__VA_ARGS__': - function_name = re.search(r'\b((?:string)?printf)\s*\(', - line, re.I).group(1) - error(filename, linenum, 'runtime/printf', 4, - 'Potential format string bug. Do %s("%%s", %s) instead.' - % (function_name, match.group(1))) - - # Check for potential memset bugs like memset(buf, sizeof(buf), 0). - match = Search(r'memset\s*\(([^,]*),\s*([^,]*),\s*0\s*\)', line) - if match and not Match(r"^''|-?[0-9]+|0x[0-9A-Fa-f]$", match.group(2)): - error(filename, linenum, 'runtime/memset', 4, - 'Did you mean "memset(%s, 0, %s)"?' - % (match.group(1), match.group(2))) - - if Search(r'\busing namespace\b', line): - error(filename, linenum, 'build/namespaces', 5, - 'Do not use namespace using-directives. ' - 'Use using-declarations instead.') - - # Detect variable-length arrays. - match = Match(r'\s*(.+::)?(\w+) [a-z]\w*\[(.+)];', line) - if (match and match.group(2) != 'return' and match.group(2) != 'delete' and - match.group(3).find(']') == -1): - # Split the size using space and arithmetic operators as delimiters. - # If any of the resulting tokens are not compile time constants then - # report the error. - tokens = re.split(r'\s|\+|\-|\*|\/|<<|>>]', match.group(3)) - is_const = True - skip_next = False - for tok in tokens: - if skip_next: - skip_next = False - continue - - if Search(r'sizeof\(.+\)', tok): continue - if Search(r'arraysize\(\w+\)', tok): continue - - tok = tok.lstrip('(') - tok = tok.rstrip(')') - if not tok: continue - if Match(r'\d+', tok): continue - if Match(r'0[xX][0-9a-fA-F]+', tok): continue - if Match(r'k[A-Z0-9]\w*', tok): continue - if Match(r'(.+::)?k[A-Z0-9]\w*', tok): continue - if Match(r'(.+::)?[A-Z][A-Z0-9_]*', tok): continue - # A catch all for tricky sizeof cases, including 'sizeof expression', - # 'sizeof(*type)', 'sizeof(const type)', 'sizeof(struct StructName)' - # requires skipping the next token because we split on ' ' and '*'. - if tok.startswith('sizeof'): - skip_next = True - continue - is_const = False - break - if not is_const: - error(filename, linenum, 'runtime/arrays', 1, - 'Do not use variable-length arrays. Use an appropriately named ' - "('k' followed by CamelCase) compile-time constant for the size.") - - # Check for use of unnamed namespaces in header files. Registration - # macros are typically OK, so we allow use of "namespace {" on lines - # that end with backslashes. - if (IsHeaderExtension(file_extension) - and Search(r'\bnamespace\s*{', line) - and line[-1] != '\\'): - error(filename, linenum, 'build/namespaces', 4, - 'Do not use unnamed namespaces in header files. See ' - 'https://google-styleguide.googlecode.com/svn/trunk/cppguide.xml#Namespaces' - ' for more information.') - - -def CheckGlobalStatic(filename, clean_lines, linenum, error): - """Check for unsafe global or static objects. - - Args: - filename: The name of the current file. - clean_lines: A CleansedLines instance containing the file. - linenum: The number of the line to check. - error: The function to call with any errors found. - """ - line = clean_lines.elided[linenum] - - # Match two lines at a time to support multiline declarations - if linenum + 1 < clean_lines.NumLines() and not Search(r'[;({]', line): - line += clean_lines.elided[linenum + 1].strip() - - # Check for people declaring static/global STL strings at the top level. - # This is dangerous because the C++ language does not guarantee that - # globals with constructors are initialized before the first access, and - # also because globals can be destroyed when some threads are still running. - # TODO(unknown): Generalize this to also find static unique_ptr instances. - # TODO(unknown): File bugs for clang-tidy to find these. - match = Match( - r'((?:|static +)(?:|const +))(?::*std::)?string( +const)? +' - r'([a-zA-Z0-9_:]+)\b(.*)', - line) - - # Remove false positives: - # - String pointers (as opposed to values). - # string *pointer - # const string *pointer - # string const *pointer - # string *const pointer - # - # - Functions and template specializations. - # string Function(... - # string Class::Method(... - # - # - Operators. These are matched separately because operator names - # cross non-word boundaries, and trying to match both operators - # and functions at the same time would decrease accuracy of - # matching identifiers. - # string Class::operator*() - if (match and - not Search(r'\bstring\b(\s+const)?\s*[\*\&]\s*(const\s+)?\w', line) and - not Search(r'\boperator\W', line) and - not Match(r'\s*(<.*>)?(::[a-zA-Z0-9_]+)*\s*\(([^"]|$)', match.group(4))): - if Search(r'\bconst\b', line): - error(filename, linenum, 'runtime/string', 4, - 'For a static/global string constant, use a C style string ' - 'instead: "%schar%s %s[]".' % - (match.group(1), match.group(2) or '', match.group(3))) - else: - error(filename, linenum, 'runtime/string', 4, - 'Static/global string variables are not permitted.') - - if (Search(r'\b([A-Za-z0-9_]*_)\(\1\)', line) or - Search(r'\b([A-Za-z0-9_]*_)\(CHECK_NOTNULL\(\1\)\)', line)): - error(filename, linenum, 'runtime/init', 4, - 'You seem to be initializing a member variable with itself.') - - -def CheckPrintf(filename, clean_lines, linenum, error): - """Check for printf related issues. - - Args: - filename: The name of the current file. - clean_lines: A CleansedLines instance containing the file. - linenum: The number of the line to check. - error: The function to call with any errors found. - """ - line = clean_lines.elided[linenum] - - # When snprintf is used, the second argument shouldn't be a literal. - match = Search(r'snprintf\s*\(([^,]*),\s*([0-9]*)\s*,', line) - if match and match.group(2) != '0': - # If 2nd arg is zero, snprintf is used to calculate size. - error(filename, linenum, 'runtime/printf', 3, - 'If you can, use sizeof(%s) instead of %s as the 2nd arg ' - 'to snprintf.' % (match.group(1), match.group(2))) - - # Check if some verboten C functions are being used. - if Search(r'\bsprintf\s*\(', line): - error(filename, linenum, 'runtime/printf', 5, - 'Never use sprintf. Use snprintf instead.') - match = Search(r'\b(strcpy|strcat)\s*\(', line) - if match: - error(filename, linenum, 'runtime/printf', 4, - 'Almost always, snprintf is better than %s' % match.group(1)) - - -def IsDerivedFunction(clean_lines, linenum): - """Check if current line contains an inherited function. - - Args: - clean_lines: A CleansedLines instance containing the file. - linenum: The number of the line to check. - Returns: - True if current line contains a function with "override" - virt-specifier. - """ - # Scan back a few lines for start of current function - for i in xrange(linenum, max(-1, linenum - 10), -1): - match = Match(r'^([^()]*\w+)\(', clean_lines.elided[i]) - if match: - # Look for "override" after the matching closing parenthesis - line, _, closing_paren = CloseExpression( - clean_lines, i, len(match.group(1))) - return (closing_paren >= 0 and - Search(r'\boverride\b', line[closing_paren:])) - return False - - -def IsOutOfLineMethodDefinition(clean_lines, linenum): - """Check if current line contains an out-of-line method definition. - - Args: - clean_lines: A CleansedLines instance containing the file. - linenum: The number of the line to check. - Returns: - True if current line contains an out-of-line method definition. - """ - # Scan back a few lines for start of current function - for i in xrange(linenum, max(-1, linenum - 10), -1): - if Match(r'^([^()]*\w+)\(', clean_lines.elided[i]): - return Match(r'^[^()]*\w+::\w+\(', clean_lines.elided[i]) is not None - return False - - -def IsInitializerList(clean_lines, linenum): - """Check if current line is inside constructor initializer list. - - Args: - clean_lines: A CleansedLines instance containing the file. - linenum: The number of the line to check. - Returns: - True if current line appears to be inside constructor initializer - list, False otherwise. - """ - for i in xrange(linenum, 1, -1): - line = clean_lines.elided[i] - if i == linenum: - remove_function_body = Match(r'^(.*)\{\s*$', line) - if remove_function_body: - line = remove_function_body.group(1) - - if Search(r'\s:\s*\w+[({]', line): - # A lone colon tend to indicate the start of a constructor - # initializer list. It could also be a ternary operator, which - # also tend to appear in constructor initializer lists as - # opposed to parameter lists. - return True - if Search(r'\}\s*,\s*$', line): - # A closing brace followed by a comma is probably the end of a - # brace-initialized member in constructor initializer list. - return True - if Search(r'[{};]\s*$', line): - # Found one of the following: - # - A closing brace or semicolon, probably the end of the previous - # function. - # - An opening brace, probably the start of current class or namespace. - # - # Current line is probably not inside an initializer list since - # we saw one of those things without seeing the starting colon. - return False - - # Got to the beginning of the file without seeing the start of - # constructor initializer list. - return False - - -def CheckForNonConstReference(filename, clean_lines, linenum, - nesting_state, error): - """Check for non-const references. - - Separate from CheckLanguage since it scans backwards from current - line, instead of scanning forward. - - Args: - filename: The name of the current file. - clean_lines: A CleansedLines instance containing the file. - linenum: The number of the line to check. - nesting_state: A NestingState instance which maintains information about - the current stack of nested blocks being parsed. - error: The function to call with any errors found. - """ - # Do nothing if there is no '&' on current line. - line = clean_lines.elided[linenum] - if '&' not in line: - return - - # If a function is inherited, current function doesn't have much of - # a choice, so any non-const references should not be blamed on - # derived function. - if IsDerivedFunction(clean_lines, linenum): - return - - # Don't warn on out-of-line method definitions, as we would warn on the - # in-line declaration, if it isn't marked with 'override'. - if IsOutOfLineMethodDefinition(clean_lines, linenum): - return - - # Long type names may be broken across multiple lines, usually in one - # of these forms: - # LongType - # ::LongTypeContinued &identifier - # LongType:: - # LongTypeContinued &identifier - # LongType< - # ...>::LongTypeContinued &identifier - # - # If we detected a type split across two lines, join the previous - # line to current line so that we can match const references - # accordingly. - # - # Note that this only scans back one line, since scanning back - # arbitrary number of lines would be expensive. If you have a type - # that spans more than 2 lines, please use a typedef. - if linenum > 1: - previous = None - if Match(r'\s*::(?:[\w<>]|::)+\s*&\s*\S', line): - # previous_line\n + ::current_line - previous = Search(r'\b((?:const\s*)?(?:[\w<>]|::)+[\w<>])\s*$', - clean_lines.elided[linenum - 1]) - elif Match(r'\s*[a-zA-Z_]([\w<>]|::)+\s*&\s*\S', line): - # previous_line::\n + current_line - previous = Search(r'\b((?:const\s*)?(?:[\w<>]|::)+::)\s*$', - clean_lines.elided[linenum - 1]) - if previous: - line = previous.group(1) + line.lstrip() - else: - # Check for templated parameter that is split across multiple lines - endpos = line.rfind('>') - if endpos > -1: - (_, startline, startpos) = ReverseCloseExpression( - clean_lines, linenum, endpos) - if startpos > -1 and startline < linenum: - # Found the matching < on an earlier line, collect all - # pieces up to current line. - line = '' - for i in xrange(startline, linenum + 1): - line += clean_lines.elided[i].strip() - - # Check for non-const references in function parameters. A single '&' may - # found in the following places: - # inside expression: binary & for bitwise AND - # inside expression: unary & for taking the address of something - # inside declarators: reference parameter - # We will exclude the first two cases by checking that we are not inside a - # function body, including one that was just introduced by a trailing '{'. - # TODO(unknown): Doesn't account for 'catch(Exception& e)' [rare]. - if (nesting_state.previous_stack_top and - not (isinstance(nesting_state.previous_stack_top, _ClassInfo) or - isinstance(nesting_state.previous_stack_top, _NamespaceInfo))): - # Not at toplevel, not within a class, and not within a namespace - return - - # Avoid initializer lists. We only need to scan back from the - # current line for something that starts with ':'. - # - # We don't need to check the current line, since the '&' would - # appear inside the second set of parentheses on the current line as - # opposed to the first set. - if linenum > 0: - for i in xrange(linenum - 1, max(0, linenum - 10), -1): - previous_line = clean_lines.elided[i] - if not Search(r'[),]\s*$', previous_line): - break - if Match(r'^\s*:\s+\S', previous_line): - return - - # Avoid preprocessors - if Search(r'\\\s*$', line): - return - - # Avoid constructor initializer lists - if IsInitializerList(clean_lines, linenum): - return - - # We allow non-const references in a few standard places, like functions - # called "swap()" or iostream operators like "<<" or ">>". Do not check - # those function parameters. - # - # We also accept & in static_assert, which looks like a function but - # it's actually a declaration expression. - allowlisted_functions = (r'(?:[sS]wap(?:<\w:+>)?|' - r'operator\s*[<>][<>]|' - r'static_assert|COMPILE_ASSERT' - r')\s*\(') - if Search(allowlisted_functions, line): - return - elif not Search(r'\S+\([^)]*$', line): - # Don't see an allowlisted function on this line. Actually we - # didn't see any function name on this line, so this is likely a - # multi-line parameter list. Try a bit harder to catch this case. - for i in xrange(2): - if (linenum > i and - Search(allowlisted_functions, clean_lines.elided[linenum - i - 1])): - return - - decls = ReplaceAll(r'{[^}]*}', ' ', line) # exclude function body - for parameter in re.findall(_RE_PATTERN_REF_PARAM, decls): - if (not Match(_RE_PATTERN_CONST_REF_PARAM, parameter) and - not Match(_RE_PATTERN_REF_STREAM_PARAM, parameter)): - error(filename, linenum, 'runtime/references', 2, - 'Is this a non-const reference? ' - 'If so, make const or use a pointer: ' + - ReplaceAll(' *<', '<', parameter)) - - -def CheckCasts(filename, clean_lines, linenum, error): - """Various cast related checks. - - Args: - filename: The name of the current file. - clean_lines: A CleansedLines instance containing the file. - linenum: The number of the line to check. - error: The function to call with any errors found. - """ - line = clean_lines.elided[linenum] - - # Check to see if they're using an conversion function cast. - # I just try to capture the most common basic types, though there are more. - # Parameterless conversion functions, such as bool(), are allowed as they are - # probably a member operator declaration or default constructor. - match = Search( - r'(\bnew\s+(?:const\s+)?|\S<\s*(?:const\s+)?)?\b' - r'(int|float|double|bool|char|int32|uint32|int64|uint64)' - r'(\([^)].*)', line) - expecting_function = ExpectingFunctionArgs(clean_lines, linenum) - if match and not expecting_function: - matched_type = match.group(2) - - # matched_new_or_template is used to silence two false positives: - # - New operators - # - Template arguments with function types - # - # For template arguments, we match on types immediately following - # an opening bracket without any spaces. This is a fast way to - # silence the common case where the function type is the first - # template argument. False negative with less-than comparison is - # avoided because those operators are usually followed by a space. - # - # function // bracket + no space = false positive - # value < double(42) // bracket + space = true positive - matched_new_or_template = match.group(1) - - # Avoid arrays by looking for brackets that come after the closing - # parenthesis. - if Match(r'\([^()]+\)\s*\[', match.group(3)): - return - - # Other things to ignore: - # - Function pointers - # - Casts to pointer types - # - Placement new - # - Alias declarations - matched_funcptr = match.group(3) - if (matched_new_or_template is None and - not (matched_funcptr and - (Match(r'\((?:[^() ]+::\s*\*\s*)?[^() ]+\)\s*\(', - matched_funcptr) or - matched_funcptr.startswith('(*)'))) and - not Match(r'\s*using\s+\S+\s*=\s*' + matched_type, line) and - not Search(r'new\(\S+\)\s*' + matched_type, line)): - error(filename, linenum, 'readability/casting', 4, - 'Using deprecated casting style. ' - 'Use reinterpret_cast<%s>(...) instead' % - matched_type) - - if not expecting_function: - CheckCStyleCast(filename, clean_lines, linenum, 'reinterpret_cast', - r'\((int|float|double|bool|char|u?int(16|32|64))\)', error) - - # This doesn't catch all cases. Consider (const char * const)"hello". - # - # (char *) "foo" should always be a const_cast (reinterpret_cast won't - # compile). - if CheckCStyleCast(filename, clean_lines, linenum, 'const_cast', - r'\((char\s?\*+\s?)\)\s*"', error): - pass - else: - # Check pointer casts for other than string constants - CheckCStyleCast(filename, clean_lines, linenum, 'reinterpret_cast', - r'\((\w+\s?\*+\s?)\)', error) - - # In addition, we look for people taking the address of a cast. This - # is dangerous -- casts can assign to temporaries, so the pointer doesn't - # point where you think. - # - # Some non-identifier character is required before the '&' for the - # expression to be recognized as a cast. These are casts: - # expression = &reinterpret_cast(temporary()); - # function(&(int*)(temporary())); - # - # This is not a cast: - # reference_type&(int* function_param); - match = Search( - r'(?:[^\w]&\(([^)*][^)]*)\)[\w(])|' - r'(?:[^\w]&(static|dynamic|down|reinterpret)_cast\b)', line) - if match: - # Try a better error message when the & is bound to something - # dereferenced by the casted pointer, as opposed to the casted - # pointer itself. - parenthesis_error = False - match = Match(r'^(.*&(?:static|dynamic|down|reinterpret)_cast\b)<', line) - if match: - _, y1, x1 = CloseExpression(clean_lines, linenum, len(match.group(1))) - if x1 >= 0 and clean_lines.elided[y1][x1] == '(': - _, y2, x2 = CloseExpression(clean_lines, y1, x1) - if x2 >= 0: - extended_line = clean_lines.elided[y2][x2:] - if y2 < clean_lines.NumLines() - 1: - extended_line += clean_lines.elided[y2 + 1] - if Match(r'\s*(?:->|\[)', extended_line): - parenthesis_error = True - - if parenthesis_error: - error(filename, linenum, 'readability/casting', 4, - ('Are you taking an address of something dereferenced ' - 'from a cast? Wrapping the dereferenced expression in ' - 'parentheses will make the binding more obvious')) - else: - error(filename, linenum, 'runtime/casting', 4, - ('Are you taking an address of a cast? ' - 'This is dangerous: could be a temp var. ' - 'Take the address before doing the cast, rather than after')) - - -def CheckCStyleCast(filename, clean_lines, linenum, cast_type, pattern, error): - """Checks for a C-style cast by looking for the pattern. - - Args: - filename: The name of the current file. - clean_lines: A CleansedLines instance containing the file. - linenum: The number of the line to check. - cast_type: The string for the C++ cast to recommend. This is either - reinterpret_cast, reinterpret_cast, or const_cast, depending. - pattern: The regular expression used to find C-style casts. - error: The function to call with any errors found. - - Returns: - True if an error was emitted. - False otherwise. - """ - line = clean_lines.elided[linenum] - match = Search(pattern, line) - if not match: - return False - - # Exclude lines with keywords that tend to look like casts - context = line[0:match.start(1) - 1] - if Match(r'.*\b(?:sizeof|alignof|alignas|[_A-Z][_A-Z0-9]*)\s*$', context): - return False - - # Try expanding current context to see if we one level of - # parentheses inside a macro. - if linenum > 0: - for i in xrange(linenum - 1, max(0, linenum - 5), -1): - context = clean_lines.elided[i] + context - if Match(r'.*\b[_A-Z][_A-Z0-9]*\s*\((?:\([^()]*\)|[^()])*$', context): - return False - - # operator++(int) and operator--(int) - if context.endswith(' operator++') or context.endswith(' operator--'): - return False - - # A single unnamed argument for a function tends to look like old style cast. - # If we see those, don't issue warnings for deprecated casts. - remainder = line[match.end(0):] - if Match(r'^\s*(?:;|const\b|throw\b|final\b|override\b|[=>{),]|->)', - remainder): - return False - - # At this point, all that should be left is actual casts. - error(filename, linenum, 'readability/casting', 4, - 'Using C-style cast. Use %s<%s>(...) instead' % - (cast_type, match.group(1))) - - return True - - -def ExpectingFunctionArgs(clean_lines, linenum): - """Checks whether where function type arguments are expected. - - Args: - clean_lines: A CleansedLines instance containing the file. - linenum: The number of the line to check. - - Returns: - True if the line at 'linenum' is inside something that expects arguments - of function types. - """ - line = clean_lines.elided[linenum] - return (Match(r'^\s*MOCK_(CONST_)?METHOD\d+(_T)?\(', line) or - (linenum >= 2 and - (Match(r'^\s*MOCK_(?:CONST_)?METHOD\d+(?:_T)?\((?:\S+,)?\s*$', - clean_lines.elided[linenum - 1]) or - Match(r'^\s*MOCK_(?:CONST_)?METHOD\d+(?:_T)?\(\s*$', - clean_lines.elided[linenum - 2]) or - Search(r'\bstd::m?function\s*\<\s*$', - clean_lines.elided[linenum - 1])))) - - -_HEADERS_CONTAINING_TEMPLATES = ( - ('', ('deque',)), - ('', ('unary_function', 'binary_function', - 'plus', 'minus', 'multiplies', 'divides', 'modulus', - 'negate', - 'equal_to', 'not_equal_to', 'greater', 'less', - 'greater_equal', 'less_equal', - 'logical_and', 'logical_or', 'logical_not', - 'unary_negate', 'not1', 'binary_negate', 'not2', - 'bind1st', 'bind2nd', - 'pointer_to_unary_function', - 'pointer_to_binary_function', - 'ptr_fun', - 'mem_fun_t', 'mem_fun', 'mem_fun1_t', 'mem_fun1_ref_t', - 'mem_fun_ref_t', - 'const_mem_fun_t', 'const_mem_fun1_t', - 'const_mem_fun_ref_t', 'const_mem_fun1_ref_t', - 'mem_fun_ref', - )), - ('', ('numeric_limits',)), - ('', ('list',)), - ('', ('map', 'multimap',)), - ('', ('allocator', 'make_shared', 'make_unique', 'shared_ptr', - 'unique_ptr', 'weak_ptr')), - ('', ('queue', 'priority_queue',)), - ('', ('set', 'multiset',)), - ('', ('stack',)), - ('', ('char_traits', 'basic_string',)), - ('', ('tuple',)), - ('', ('unordered_map', 'unordered_multimap')), - ('', ('unordered_set', 'unordered_multiset')), - ('', ('pair',)), - ('', ('vector',)), - - # gcc extensions. - # Note: std::hash is their hash, ::hash is our hash - ('', ('hash_map', 'hash_multimap',)), - ('', ('hash_set', 'hash_multiset',)), - ('', ('slist',)), - ) - -_HEADERS_MAYBE_TEMPLATES = ( - ('', ('copy', 'max', 'min', 'min_element', 'sort', - 'transform', - )), - ('', ('forward', 'make_pair', 'move', 'swap')), - ) - -_RE_PATTERN_STRING = re.compile(r'\bstring\b') - -_re_pattern_headers_maybe_templates = [] -for _header, _templates in _HEADERS_MAYBE_TEMPLATES: - for _template in _templates: - # Match max(..., ...), max(..., ...), but not foo->max, foo.max or - # type::max(). - _re_pattern_headers_maybe_templates.append( - (re.compile(r'[^>.]\b' + _template + r'(<.*?>)?\([^\)]'), - _template, - _header)) - -# Other scripts may reach in and modify this pattern. -_re_pattern_templates = [] -for _header, _templates in _HEADERS_CONTAINING_TEMPLATES: - for _template in _templates: - _re_pattern_templates.append( - (re.compile(r'(\<|\b)' + _template + r'\s*\<'), - _template + '<>', - _header)) - - -def FilesBelongToSameModule(filename_cc, filename_h): - """Check if these two filenames belong to the same module. - - The concept of a 'module' here is a as follows: - foo.h, foo-inl.h, foo.cc, foo_test.cc and foo_unittest.cc belong to the - same 'module' if they are in the same directory. - some/path/public/xyzzy and some/path/internal/xyzzy are also considered - to belong to the same module here. - - If the filename_cc contains a longer path than the filename_h, for example, - '/absolute/path/to/base/sysinfo.cc', and this file would include - 'base/sysinfo.h', this function also produces the prefix needed to open the - header. This is used by the caller of this function to more robustly open the - header file. We don't have access to the real include paths in this context, - so we need this guesswork here. - - Known bugs: tools/base/bar.cc and base/bar.h belong to the same module - according to this implementation. Because of this, this function gives - some false positives. This should be sufficiently rare in practice. - - Args: - filename_cc: is the path for the .cc file - filename_h: is the path for the header path - - Returns: - Tuple with a bool and a string: - bool: True if filename_cc and filename_h belong to the same module. - string: the additional prefix needed to open the header file. - """ - - fileinfo = FileInfo(filename_cc) - if not fileinfo.IsSource(): - return (False, '') - filename_cc = filename_cc[:-len(fileinfo.Extension())] - matched_test_suffix = Search(_TEST_FILE_SUFFIX, fileinfo.BaseName()) - if matched_test_suffix: - filename_cc = filename_cc[:-len(matched_test_suffix.group(1))] - filename_cc = filename_cc.replace('/public/', '/') - filename_cc = filename_cc.replace('/internal/', '/') - - if not filename_h.endswith('.h'): - return (False, '') - filename_h = filename_h[:-len('.h')] - if filename_h.endswith('-inl'): - filename_h = filename_h[:-len('-inl')] - filename_h = filename_h.replace('/public/', '/') - filename_h = filename_h.replace('/internal/', '/') - - files_belong_to_same_module = filename_cc.endswith(filename_h) - common_path = '' - if files_belong_to_same_module: - common_path = filename_cc[:-len(filename_h)] - return files_belong_to_same_module, common_path - - -def UpdateIncludeState(filename, include_dict, io=codecs): - """Fill up the include_dict with new includes found from the file. - - Args: - filename: the name of the header to read. - include_dict: a dictionary in which the headers are inserted. - io: The io factory to use to read the file. Provided for testability. - - Returns: - True if a header was successfully added. False otherwise. - """ - headerfile = None - try: - headerfile = io.open(filename, 'r', 'utf8', 'replace') - except IOError: - return False - linenum = 0 - for line in headerfile: - linenum += 1 - clean_line = CleanseComments(line) - match = _RE_PATTERN_INCLUDE.search(clean_line) - if match: - include = match.group(2) - include_dict.setdefault(include, linenum) - return True - - -def CheckForIncludeWhatYouUse(filename, clean_lines, include_state, error, - io=codecs): - """Reports for missing stl includes. - - This function will output warnings to make sure you are including the headers - necessary for the stl containers and functions that you use. We only give one - reason to include a header. For example, if you use both equal_to<> and - less<> in a .h file, only one (the latter in the file) of these will be - reported as a reason to include the . - - Args: - filename: The name of the current file. - clean_lines: A CleansedLines instance containing the file. - include_state: An _IncludeState instance. - error: The function to call with any errors found. - io: The IO factory to use to read the header file. Provided for unittest - injection. - """ - required = {} # A map of header name to linenumber and the template entity. - # Example of required: { '': (1219, 'less<>') } - - for linenum in xrange(clean_lines.NumLines()): - line = clean_lines.elided[linenum] - if not line or line[0] == '#': - continue - - # String is special -- it is a non-templatized type in STL. - matched = _RE_PATTERN_STRING.search(line) - if matched: - # Don't warn about strings in non-STL namespaces: - # (We check only the first match per line; good enough.) - prefix = line[:matched.start()] - if prefix.endswith('std::') or not prefix.endswith('::'): - required[''] = (linenum, 'string') - - for pattern, template, header in _re_pattern_headers_maybe_templates: - if pattern.search(line): - required[header] = (linenum, template) - - # The following function is just a speed up, no semantics are changed. - if not '<' in line: # Reduces the cpu time usage by skipping lines. - continue - - for pattern, template, header in _re_pattern_templates: - matched = pattern.search(line) - if matched: - # Don't warn about IWYU in non-STL namespaces: - # (We check only the first match per line; good enough.) - prefix = line[:matched.start()] - if prefix.endswith('std::') or not prefix.endswith('::'): - required[header] = (linenum, template) - - # The policy is that if you #include something in foo.h you don't need to - # include it again in foo.cc. Here, we will look at possible includes. - # Let's flatten the include_state include_list and copy it into a dictionary. - include_dict = dict([item for sublist in include_state.include_list - for item in sublist]) - - # Did we find the header for this file (if any) and successfully load it? - header_found = False - - # Use the absolute path so that matching works properly. - abs_filename = FileInfo(filename).FullName() - - # For Emacs's flymake. - # If cpplint is invoked from Emacs's flymake, a temporary file is generated - # by flymake and that file name might end with '_flymake.cc'. In that case, - # restore original file name here so that the corresponding header file can be - # found. - # e.g. If the file name is 'foo_flymake.cc', we should search for 'foo.h' - # instead of 'foo_flymake.h' - abs_filename = re.sub(r'_flymake\.cc$', '.cc', abs_filename) - - # include_dict is modified during iteration, so we iterate over a copy of - # the keys. - header_keys = include_dict.keys() - for header in header_keys: - (same_module, common_path) = FilesBelongToSameModule(abs_filename, header) - fullpath = common_path + header - if same_module and UpdateIncludeState(fullpath, include_dict, io): - header_found = True - - # If we can't find the header file for a .cc, assume it's because we don't - # know where to look. In that case we'll give up as we're not sure they - # didn't include it in the .h file. - # TODO(unknown): Do a better job of finding .h files so we are confident that - # not having the .h file means there isn't one. - if filename.endswith('.cc') and not header_found: - return - - # All the lines have been processed, report the errors found. - for required_header_unstripped in required: - template = required[required_header_unstripped][1] - if required_header_unstripped.strip('<>"') not in include_dict: - error(filename, required[required_header_unstripped][0], - 'build/include_what_you_use', 4, - 'Add #include ' + required_header_unstripped + ' for ' + template) - - -_RE_PATTERN_EXPLICIT_MAKEPAIR = re.compile(r'\bmake_pair\s*<') - - -def CheckMakePairUsesDeduction(filename, clean_lines, linenum, error): - """Check that make_pair's template arguments are deduced. - - G++ 4.6 in C++11 mode fails badly if make_pair's template arguments are - specified explicitly, and such use isn't intended in any case. - - Args: - filename: The name of the current file. - clean_lines: A CleansedLines instance containing the file. - linenum: The number of the line to check. - error: The function to call with any errors found. - """ - line = clean_lines.elided[linenum] - match = _RE_PATTERN_EXPLICIT_MAKEPAIR.search(line) - if match: - error(filename, linenum, 'build/explicit_make_pair', - 4, # 4 = high confidence - 'For C++11-compatibility, omit template arguments from make_pair' - ' OR use pair directly OR if appropriate, construct a pair directly') - - -def CheckRedundantVirtual(filename, clean_lines, linenum, error): - """Check if line contains a redundant "virtual" function-specifier. - - Args: - filename: The name of the current file. - clean_lines: A CleansedLines instance containing the file. - linenum: The number of the line to check. - error: The function to call with any errors found. - """ - # Look for "virtual" on current line. - line = clean_lines.elided[linenum] - virtual = Match(r'^(.*)(\bvirtual\b)(.*)$', line) - if not virtual: return - - # Ignore "virtual" keywords that are near access-specifiers. These - # are only used in class base-specifier and do not apply to member - # functions. - if (Search(r'\b(public|protected|private)\s+$', virtual.group(1)) or - Match(r'^\s+(public|protected|private)\b', virtual.group(3))): - return - - # Ignore the "virtual" keyword from virtual base classes. Usually - # there is a column on the same line in these cases (virtual base - # classes are rare in google3 because multiple inheritance is rare). - if Match(r'^.*[^:]:[^:].*$', line): return - - # Look for the next opening parenthesis. This is the start of the - # parameter list (possibly on the next line shortly after virtual). - # TODO(unknown): doesn't work if there are virtual functions with - # decltype() or other things that use parentheses, but csearch suggests - # that this is rare. - end_col = -1 - end_line = -1 - start_col = len(virtual.group(2)) - for start_line in xrange(linenum, min(linenum + 3, clean_lines.NumLines())): - line = clean_lines.elided[start_line][start_col:] - parameter_list = Match(r'^([^(]*)\(', line) - if parameter_list: - # Match parentheses to find the end of the parameter list - (_, end_line, end_col) = CloseExpression( - clean_lines, start_line, start_col + len(parameter_list.group(1))) - break - start_col = 0 - - if end_col < 0: - return # Couldn't find end of parameter list, give up - - # Look for "override" or "final" after the parameter list - # (possibly on the next few lines). - for i in xrange(end_line, min(end_line + 3, clean_lines.NumLines())): - line = clean_lines.elided[i][end_col:] - match = Search(r'\b(override|final)\b', line) - if match: - error(filename, linenum, 'readability/inheritance', 4, - ('"virtual" is redundant since function is ' - 'already declared as "%s"' % match.group(1))) - - # Set end_col to check whole lines after we are done with the - # first line. - end_col = 0 - if Search(r'[^\w]\s*$', line): - break - - -def CheckRedundantOverrideOrFinal(filename, clean_lines, linenum, error): - """Check if line contains a redundant "override" or "final" virt-specifier. - - Args: - filename: The name of the current file. - clean_lines: A CleansedLines instance containing the file. - linenum: The number of the line to check. - error: The function to call with any errors found. - """ - # Look for closing parenthesis nearby. We need one to confirm where - # the declarator ends and where the virt-specifier starts to avoid - # false positives. - line = clean_lines.elided[linenum] - declarator_end = line.rfind(')') - if declarator_end >= 0: - fragment = line[declarator_end:] - else: - if linenum > 1 and clean_lines.elided[linenum - 1].rfind(')') >= 0: - fragment = line - else: - return - - # Check that at most one of "override" or "final" is present, not both - if Search(r'\boverride\b', fragment) and Search(r'\bfinal\b', fragment): - error(filename, linenum, 'readability/inheritance', 4, - ('"override" is redundant since function is ' - 'already declared as "final"')) - - - - -# Returns true if we are at a new block, and it is directly -# inside of a namespace. -def IsBlockInNameSpace(nesting_state, is_forward_declaration): - """Checks that the new block is directly in a namespace. - - Args: - nesting_state: The _NestingState object that contains info about our state. - is_forward_declaration: If the class is a forward declared class. - Returns: - Whether or not the new block is directly in a namespace. - """ - if is_forward_declaration: - if len(nesting_state.stack) >= 1 and ( - isinstance(nesting_state.stack[-1], _NamespaceInfo)): - return True - else: - return False - - return (len(nesting_state.stack) > 1 and - nesting_state.stack[-1].check_namespace_indentation and - isinstance(nesting_state.stack[-2], _NamespaceInfo)) - - -def ShouldCheckNamespaceIndentation(nesting_state, is_namespace_indent_item, - raw_lines_no_comments, linenum): - """This method determines if we should apply our namespace indentation check. - - Args: - nesting_state: The current nesting state. - is_namespace_indent_item: If we just put a new class on the stack, True. - If the top of the stack is not a class, or we did not recently - add the class, False. - raw_lines_no_comments: The lines without the comments. - linenum: The current line number we are processing. - - Returns: - True if we should apply our namespace indentation check. Currently, it - only works for classes and namespaces inside of a namespace. - """ - - is_forward_declaration = IsForwardClassDeclaration(raw_lines_no_comments, - linenum) - - if not (is_namespace_indent_item or is_forward_declaration): - return False - - # If we are in a macro, we do not want to check the namespace indentation. - if IsMacroDefinition(raw_lines_no_comments, linenum): - return False - - return IsBlockInNameSpace(nesting_state, is_forward_declaration) - - -# Call this method if the line is directly inside of a namespace. -# If the line above is blank (excluding comments) or the start of -# an inner namespace, it cannot be indented. -def CheckItemIndentationInNamespace(filename, raw_lines_no_comments, linenum, - error): - line = raw_lines_no_comments[linenum] - if Match(r'^\s+', line): - error(filename, linenum, 'runtime/indentation_namespace', 4, - 'Do not indent within a namespace') - - -def ProcessLine(filename, file_extension, clean_lines, line, - include_state, function_state, nesting_state, error, - extra_check_functions=[]): - """Processes a single line in the file. - - Args: - filename: Filename of the file that is being processed. - file_extension: The extension (dot not included) of the file. - clean_lines: An array of strings, each representing a line of the file, - with comments stripped. - line: Number of line being processed. - include_state: An _IncludeState instance in which the headers are inserted. - function_state: A _FunctionState instance which counts function lines, etc. - nesting_state: A NestingState instance which maintains information about - the current stack of nested blocks being parsed. - error: A callable to which errors are reported, which takes 4 arguments: - filename, line number, error level, and message - extra_check_functions: An array of additional check functions that will be - run on each source line. Each function takes 4 - arguments: filename, clean_lines, line, error - """ - raw_lines = clean_lines.raw_lines - ParseNolintSuppressions(filename, raw_lines[line], line, error) - nesting_state.Update(filename, clean_lines, line, error) - CheckForNamespaceIndentation(filename, nesting_state, clean_lines, line, - error) - if nesting_state.InAsmBlock(): return - CheckForFunctionLengths(filename, clean_lines, line, function_state, error) - CheckForMultilineCommentsAndStrings(filename, clean_lines, line, error) - CheckStyle(filename, clean_lines, line, file_extension, nesting_state, error) - CheckLanguage(filename, clean_lines, line, file_extension, include_state, - nesting_state, error) - CheckForNonConstReference(filename, clean_lines, line, nesting_state, error) - CheckForNonStandardConstructs(filename, clean_lines, line, - nesting_state, error) - CheckVlogArguments(filename, clean_lines, line, error) - CheckPosixThreading(filename, clean_lines, line, error) - CheckInvalidIncrement(filename, clean_lines, line, error) - CheckMakePairUsesDeduction(filename, clean_lines, line, error) - CheckRedundantVirtual(filename, clean_lines, line, error) - CheckRedundantOverrideOrFinal(filename, clean_lines, line, error) - for check_fn in extra_check_functions: - check_fn(filename, clean_lines, line, error) - -def FlagCxx11Features(filename, clean_lines, linenum, error): - """Flag those c++11 features that we only allow in certain places. - - Args: - filename: The name of the current file. - clean_lines: A CleansedLines instance containing the file. - linenum: The number of the line to check. - error: The function to call with any errors found. - """ - line = clean_lines.elided[linenum] - - include = Match(r'\s*#\s*include\s+[<"]([^<"]+)[">]', line) - - # Flag unapproved C++ TR1 headers. - if include and include.group(1).startswith('tr1/'): - error(filename, linenum, 'build/c++tr1', 5, - ('C++ TR1 headers such as <%s> are unapproved.') % include.group(1)) - - # Flag unapproved C++11 headers. - if include and include.group(1) in ('cfenv', - 'condition_variable', - 'fenv.h', - 'future', - 'mutex', - 'thread', - 'chrono', - 'ratio', - 'regex', - 'system_error', - ): - error(filename, linenum, 'build/c++11', 5, - ('<%s> is an unapproved C++11 header.') % include.group(1)) - - # The only place where we need to worry about C++11 keywords and library - # features in preprocessor directives is in macro definitions. - if Match(r'\s*#', line) and not Match(r'\s*#\s*define\b', line): return - - # These are classes and free functions. The classes are always - # mentioned as std::*, but we only catch the free functions if - # they're not found by ADL. They're alphabetical by header. - for top_name in ( - # type_traits - 'alignment_of', - 'aligned_union', - ): - if Search(r'\bstd::%s\b' % top_name, line): - error(filename, linenum, 'build/c++11', 5, - ('std::%s is an unapproved C++11 class or function. Send c-style ' - 'an example of where it would make your code more readable, and ' - 'they may let you use it.') % top_name) - - -def FlagCxx14Features(filename, clean_lines, linenum, error): - """Flag those C++14 features that we restrict. - - Args: - filename: The name of the current file. - clean_lines: A CleansedLines instance containing the file. - linenum: The number of the line to check. - error: The function to call with any errors found. - """ - line = clean_lines.elided[linenum] - - include = Match(r'\s*#\s*include\s+[<"]([^<"]+)[">]', line) - - # Flag unapproved C++14 headers. - if include and include.group(1) in ('scoped_allocator', 'shared_mutex'): - error(filename, linenum, 'build/c++14', 5, - ('<%s> is an unapproved C++14 header.') % include.group(1)) - - -def ProcessFileData(filename, file_extension, lines, error, - extra_check_functions=[]): - """Performs lint checks and reports any errors to the given error function. - - Args: - filename: Filename of the file that is being processed. - file_extension: The extension (dot not included) of the file. - lines: An array of strings, each representing a line of the file, with the - last element being empty if the file is terminated with a newline. - error: A callable to which errors are reported, which takes 4 arguments: - filename, line number, error level, and message - extra_check_functions: An array of additional check functions that will be - run on each source line. Each function takes 4 - arguments: filename, clean_lines, line, error - """ - lines = (['// marker so line numbers and indices both start at 1'] + lines + - ['// marker so line numbers end in a known way']) - - include_state = _IncludeState() - function_state = _FunctionState() - nesting_state = NestingState() - - ResetNolintSuppressions() - - CheckForCopyright(filename, lines, error) - ProcessGlobalSuppresions(lines) - RemoveMultiLineComments(filename, lines, error) - clean_lines = CleansedLines(lines) - - if IsHeaderExtension(file_extension): - CheckForHeaderGuard(filename, clean_lines, error) - - for line in xrange(clean_lines.NumLines()): - ProcessLine(filename, file_extension, clean_lines, line, - include_state, function_state, nesting_state, error, - extra_check_functions) - FlagCxx11Features(filename, clean_lines, line, error) - nesting_state.CheckCompletedBlocks(filename, error) - - CheckForIncludeWhatYouUse(filename, clean_lines, include_state, error) - - # Check that the .cc file has included its header if it exists. - if _IsSourceExtension(file_extension): - CheckHeaderFileIncluded(filename, include_state, error) - - # We check here rather than inside ProcessLine so that we see raw - # lines rather than "cleaned" lines. - CheckForBadCharacters(filename, lines, error) - - CheckForNewlineAtEOF(filename, lines, error) - -def ProcessConfigOverrides(filename): - """ Loads the configuration files and processes the config overrides. - - Args: - filename: The name of the file being processed by the linter. - - Returns: - False if the current |filename| should not be processed further. - """ - - abs_filename = os.path.abspath(filename) - cfg_filters = [] - keep_looking = True - while keep_looking: - abs_path, base_name = os.path.split(abs_filename) - if not base_name: - break # Reached the root directory. - - cfg_file = os.path.join(abs_path, "CPPLINT.cfg") - abs_filename = abs_path - if not os.path.isfile(cfg_file): - continue - - try: - with open(cfg_file) as file_handle: - for line in file_handle: - line, _, _ = line.partition('#') # Remove comments. - if not line.strip(): - continue - - name, _, val = line.partition('=') - name = name.strip() - val = val.strip() - if name == 'set noparent': - keep_looking = False - elif name == 'filter': - cfg_filters.append(val) - elif name == 'exclude_files': - # When matching exclude_files pattern, use the base_name of - # the current file name or the directory name we are processing. - # For example, if we are checking for lint errors in /foo/bar/baz.cc - # and we found the .cfg file at /foo/CPPLINT.cfg, then the config - # file's "exclude_files" filter is meant to be checked against "bar" - # and not "baz" nor "bar/baz.cc". - if base_name: - pattern = re.compile(val) - if pattern.match(base_name): - if _cpplint_state.quiet: - # Suppress "Ignoring file" warning when using --quiet. - return False - sys.stderr.write('Ignoring "%s": file excluded by "%s". ' - 'File path component "%s" matches ' - 'pattern "%s"\n' % - (filename, cfg_file, base_name, val)) - return False - elif name == 'linelength': - global _line_length - try: - _line_length = int(val) - except ValueError: - sys.stderr.write('Line length must be numeric.') - elif name == 'root': - global _root - # root directories are specified relative to CPPLINT.cfg dir. - _root = os.path.join(os.path.dirname(cfg_file), val) - elif name == 'headers': - ProcessHppHeadersOption(val) - else: - sys.stderr.write( - 'Invalid configuration option (%s) in file %s\n' % - (name, cfg_file)) - - except IOError: - sys.stderr.write( - "Skipping config file '%s': Can't open for reading\n" % cfg_file) - keep_looking = False - - # Apply all the accumulated filters in reverse order (top-level directory - # config options having the least priority). - for filter in reversed(cfg_filters): - _AddFilters(filter) - - return True - - -def ProcessFile(filename, vlevel, extra_check_functions=[]): - """Does google-lint on a single file. - - Args: - filename: The name of the file to parse. - - vlevel: The level of errors to report. Every error of confidence - >= verbose_level will be reported. 0 is a good default. - - extra_check_functions: An array of additional check functions that will be - run on each source line. Each function takes 4 - arguments: filename, clean_lines, line, error - """ - - _SetVerboseLevel(vlevel) - _BackupFilters() - old_errors = _cpplint_state.error_count - - if not ProcessConfigOverrides(filename): - _RestoreFilters() - return - - lf_lines = [] - crlf_lines = [] - try: - # Support the UNIX convention of using "-" for stdin. Note that - # we are not opening the file with universal newline support - # (which codecs doesn't support anyway), so the resulting lines do - # contain trailing '\r' characters if we are reading a file that - # has CRLF endings. - # If after the split a trailing '\r' is present, it is removed - # below. - if filename == '-': - lines = codecs.StreamReaderWriter(sys.stdin, - codecs.getreader('utf8'), - codecs.getwriter('utf8'), - 'replace').read().split('\n') - else: - lines = codecs.open(filename, 'r', 'utf8', 'replace').read().split('\n') - - # Remove trailing '\r'. - # The -1 accounts for the extra trailing blank line we get from split() - for linenum in range(len(lines) - 1): - if lines[linenum].endswith('\r'): - lines[linenum] = lines[linenum].rstrip('\r') - crlf_lines.append(linenum + 1) - else: - lf_lines.append(linenum + 1) - - except IOError: - sys.stderr.write( - "Skipping input '%s': Can't open for reading\n" % filename) - _RestoreFilters() - return - - # Note, if no dot is found, this will give the entire filename as the ext. - file_extension = filename[filename.rfind('.') + 1:] - - # When reading from stdin, the extension is unknown, so no cpplint tests - # should rely on the extension. - if filename != '-' and file_extension not in _valid_extensions: - sys.stderr.write('Ignoring %s; not a valid file name ' - '(%s)\n' % (filename, ', '.join(_valid_extensions))) - else: - ProcessFileData(filename, file_extension, lines, Error, - extra_check_functions) - - # If end-of-line sequences are a mix of LF and CR-LF, issue - # warnings on the lines with CR. - # - # Don't issue any warnings if all lines are uniformly LF or CR-LF, - # since critique can handle these just fine, and the style guide - # doesn't dictate a particular end of line sequence. - # - # We can't depend on os.linesep to determine what the desired - # end-of-line sequence should be, since that will return the - # server-side end-of-line sequence. - if lf_lines and crlf_lines: - # Warn on every line with CR. An alternative approach might be to - # check whether the file is mostly CRLF or just LF, and warn on the - # minority, we bias toward LF here since most tools prefer LF. - for linenum in crlf_lines: - Error(filename, linenum, 'whitespace/newline', 1, - 'Unexpected \\r (^M) found; better to use only \\n') - - # Suppress printing anything if --quiet was passed unless the error - # count has increased after processing this file. - if not _cpplint_state.quiet or old_errors != _cpplint_state.error_count: - sys.stdout.write('Done processing %s\n' % filename) - _RestoreFilters() - - -def PrintUsage(message): - """Prints a brief usage string and exits, optionally with an error message. - - Args: - message: The optional error message. - """ - sys.stderr.write(_USAGE) - if message: - sys.exit('\nFATAL ERROR: ' + message) - else: - sys.exit(1) - - -def PrintCategories(): - """Prints a list of all the error-categories used by error messages. - - These are the categories used to filter messages via --filter. - """ - sys.stderr.write(''.join(' %s\n' % cat for cat in _ERROR_CATEGORIES)) - sys.exit(0) - - -def ParseArguments(args): - """Parses the command line arguments. - - This may set the output format and verbosity level as side-effects. - - Args: - args: The command line arguments: - - Returns: - The list of filenames to lint. - """ - try: - (opts, filenames) = getopt.getopt(args, '', ['help', 'output=', 'verbose=', - 'counting=', - 'filter=', - 'root=', - 'linelength=', - 'extensions=', - 'headers=', - 'quiet']) - except getopt.GetoptError: - PrintUsage('Invalid arguments.') - - verbosity = _VerboseLevel() - output_format = _OutputFormat() - filters = '' - quiet = _Quiet() - counting_style = '' - - for (opt, val) in opts: - if opt == '--help': - PrintUsage(None) - elif opt == '--output': - if val not in ('emacs', 'vs7', 'eclipse'): - PrintUsage('The only allowed output formats are emacs, vs7 and eclipse.') - output_format = val - elif opt == '--quiet': - quiet = True - elif opt == '--verbose': - verbosity = int(val) - elif opt == '--filter': - filters = val - if not filters: - PrintCategories() - elif opt == '--counting': - if val not in ('total', 'toplevel', 'detailed'): - PrintUsage('Valid counting options are total, toplevel, and detailed') - counting_style = val - elif opt == '--root': - global _root - _root = val - elif opt == '--linelength': - global _line_length - try: - _line_length = int(val) - except ValueError: - PrintUsage('Line length must be digits.') - elif opt == '--extensions': - global _valid_extensions - try: - _valid_extensions = set(val.split(',')) - except ValueError: - PrintUsage('Extensions must be comma separated list.') - elif opt == '--headers': - ProcessHppHeadersOption(val) - - if not filenames: - PrintUsage('No files were specified.') - - _SetOutputFormat(output_format) - _SetQuiet(quiet) - _SetVerboseLevel(verbosity) - _SetFilters(filters) - _SetCountingStyle(counting_style) - - return filenames - - -def main(): - filenames = ParseArguments(sys.argv[1:]) - - # Change stderr to write with replacement characters so we don't die - # if we try to print something containing non-ASCII characters. - sys.stderr = codecs.StreamReaderWriter(sys.stderr, - codecs.getreader('utf8'), - codecs.getwriter('utf8'), - 'replace') - - _cpplint_state.ResetErrorCounts() - for filename in filenames: - ProcessFile(filename, _cpplint_state.verbose_level) - # If --quiet is passed, suppress printing error count unless there are errors. - if not _cpplint_state.quiet or _cpplint_state.error_count > 0: - _cpplint_state.PrintErrorCounts() - - sys.exit(_cpplint_state.error_count > 0) - - -if __name__ == '__main__': - main() diff --git a/tfjs-master/tfjs-backend-wasm/tsconfig.json b/tfjs-master/tfjs-backend-wasm/tsconfig.json deleted file mode 100644 index 14e5bcd71..000000000 --- a/tfjs-master/tfjs-backend-wasm/tsconfig.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "extends": "../tsconfig", - "include": [ - "src/" - ], - "exclude": [ - "node_modules/" - ], - "compilerOptions": { - "esModuleInterop": true, - "outDir": "./dist" - } -} diff --git a/tfjs-master/tfjs-backend-wasm/wasm-out/BUILD.bazel b/tfjs-master/tfjs-backend-wasm/wasm-out/BUILD.bazel deleted file mode 100644 index 39a6a2bf0..000000000 --- a/tfjs-master/tfjs-backend-wasm/wasm-out/BUILD.bazel +++ /dev/null @@ -1,118 +0,0 @@ -load("@build_bazel_rules_nodejs//:index.bzl", "js_library") -load("//tfjs-backend-wasm/scripts:create_worker_module.bzl", "create_worker_module") -load("//tfjs-backend-wasm/scripts:patch_threaded_simd_module.bzl", "patch_threaded_simd_module") -load("//tools:copy_to_dist.bzl", "copy_to_dist") -load("//tools:get_extension.bzl", "get_extension") - -package(default_visibility = ["//visibility:public"]) - -copy_to_dist( - name = "copy_wasm", - srcs = [ - "//tfjs-backend-wasm/src/cc:tfjs-backend-wasm", - ], - dest_dir = ".", - root = "../src/cc/tfjs-backend-wasm", -) - -copy_to_dist( - name = "copy_wasm_simd", - srcs = [ - "//tfjs-backend-wasm/src/cc:tfjs-backend-wasm-simd", - ], - dest_dir = ".", - root = "../src/cc/tfjs-backend-wasm-simd", -) - -# Copying the threaded wasm output is more complicated because postprocessing -# of the output is required. -get_extension( - name = "wasm_threaded_js", - srcs = ["//tfjs-backend-wasm/src/cc:tfjs-backend-wasm-threaded-simd"], - include = [ - ".js", - ], - exclude = [ - ".worker.js", - ".fetch.js", - ], -) - -patch_threaded_simd_module( - name = "patch_threaded_simd_module", - out_file = "tfjs-backend-wasm-threaded-simd.js", - threaded_simd_file = ":wasm_threaded_js", -) - -get_extension( - name = "wasm_threaded_worker", - srcs = ["//tfjs-backend-wasm/src/cc:tfjs-backend-wasm-threaded-simd"], - include = [ - ".worker.js", - ], -) - -create_worker_module( - name = "create_worker_module", - cjs = True, - out_file = "tfjs-backend-wasm-threaded-simd.worker.js", - worker_file = ":wasm_threaded_worker", -) - -get_extension( - name = "wasm_threaded_unpatched", - srcs = ["//tfjs-backend-wasm/src/cc:tfjs-backend-wasm-threaded-simd"], - # Exclude all the files that were patched. - exclude = [ - "tfjs-backend-wasm-threaded-simd.js", - "tfjs-backend-wasm-threaded-simd.worker.js", - ], -) - -copy_to_dist( - name = "copy_wasm_threaded", - srcs = [ - ":wasm_threaded_unpatched", - ], - dest_dir = ".", - root = "../src/cc/tfjs-backend-wasm-threaded-simd", -) - -filegroup( - name = "wasm_types", - srcs = glob(["*.d.ts"]), -) - -# This target selects the file extensions that should end up in the -# wasm-out directory in the npm package. -get_extension( - name = "wasm_for_dist", - srcs = [ - ":copy_wasm", - ":copy_wasm_simd", - ":copy_wasm_threaded", - ":create_worker_module", - ":patch_threaded_simd_module", - ], - include = [ - ".js", - ".cjs", - ".wasm", - ], - exclude = [ - ".fetch.js", - ".debug.wasm", - ], -) - -js_library( - name = "wasm-out", - package_name = "@tensorflow/tfjs-backend-wasm/wasm-out", - srcs = [ - ":wasm_for_dist", - ":wasm_types", - ], - deps = [ - "@npm//@types/emscripten", - ], -) diff --git a/tfjs-master/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm-threaded-simd.d.ts b/tfjs-master/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm-threaded-simd.d.ts deleted file mode 100644 index 71ef9ef10..000000000 --- a/tfjs-master/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm-threaded-simd.d.ts +++ /dev/null @@ -1,37 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {BackendWasmModule} from './tfjs-backend-wasm'; - -export interface BackendWasmThreadedSimdModule extends BackendWasmModule { - PThread: { - // Terminates all webworkers - terminateAllThreads(): void, - }; -} - -export interface WasmFactoryConfig { - mainScriptUrlOrBlob?: string|Blob; - locateFile?(path: string, prefix: string): string; - instantiateWasm?: Function; - onRuntimeInitialized?: () => void; - onAbort?: (msg: string) => void; -} - -declare var moduleFactory: (settings: WasmFactoryConfig) => - Promise; -export default moduleFactory; diff --git a/tfjs-master/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm.d.ts b/tfjs-master/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm.d.ts deleted file mode 100644 index f13a93692..000000000 --- a/tfjs-master/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm.d.ts +++ /dev/null @@ -1,42 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -export interface BackendWasmModule extends EmscriptenModule { - // Using the tfjs namespace to avoid conflict with emscripten's API. - tfjs: { - init(): void, - initWithThreadsCount(threadsCount: number): void, - getThreadsCount(): number, - registerTensor(id: number, size: number, memoryOffset: number): void, - // Disposes the data behind the data bucket. - disposeData(id: number): void, - // Disposes the backend and all of its associated data. - dispose(): void, - } -} - -export interface WasmFactoryConfig { - mainScriptUrlOrBlob?: string|Blob; - locateFile?(path: string, prefix: string): string; - instantiateWasm?: Function; - onRuntimeInitialized?: () => void; - onAbort?: (msg: string) => void; -} - -declare var moduleFactory: (settings: WasmFactoryConfig) => - Promise; -export default moduleFactory; diff --git a/tfjs-master/tfjs-backend-wasm/yarn.lock b/tfjs-master/tfjs-backend-wasm/yarn.lock deleted file mode 100644 index b430d866e..000000000 --- a/tfjs-master/tfjs-backend-wasm/yarn.lock +++ /dev/null @@ -1,152 +0,0 @@ -# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. -# yarn lockfile v1 - - -"@babel/polyfill@^7.8.7": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/polyfill/-/polyfill-7.12.1.tgz#1f2d6371d1261bbd961f3c5d5909150e12d0bd96" - integrity sha512-X0pi0V6gxLi6lFZpGmeNa4zxtwEmCs42isWLNjZZDE0Y8yVfgu0T2OAHlzBbdYlqbW/YXVvoBHpATEM+goCj8g== - dependencies: - core-js "^2.6.5" - regenerator-runtime "^0.13.4" - -"@bazel/bazelisk@^1.12.0": - version "1.12.0" - resolved "https://registry.yarnpkg.com/@bazel/bazelisk/-/bazelisk-1.12.0.tgz#f08aebbf4afcb12684422450b0845dd6ef5cfe50" - integrity sha512-7oQusq1e4AIyFgotxVV7Pc40Et0QyvoVjujL+7/qV5Vrbfh0Nj3CfqSgl63weEyI4r0+K6RlGVsjfRuBi05p5w== - -"@tensorflow/tfjs-backend-cpu@link:../link-package/node_modules/@tensorflow/tfjs-backend-cpu": - version "0.0.0" - -"@types/emscripten@~0.0.34": - version "0.0.34" - resolved "https://registry.yarnpkg.com/@types/emscripten/-/emscripten-0.0.34.tgz#12b4a344274fb102ff2f6c877b37587bc3e46008" - integrity sha512-QSb9ojDincskc+uKMI0KXp8e1NALFINCrMlp8VGKGcTSxeEyRTTKyjWw75NYrCZHUsVEEEpr1tYHpbtaC++/sQ== - -async@^1.5.2: - version "1.5.2" - resolved "https://registry.yarnpkg.com/async/-/async-1.5.2.tgz#ec6a61ae56480c0c3cb241c95618e20892f9672a" - integrity sha512-nSVgobk4rv61R9PUSDtYt7mPVB2olxNR5RWJcAsH676/ef11bUZwvu7+RGYrYauVdDPcO519v68wRhXQtxsV9w== - -balanced-match@^1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee" - integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw== - -brace-expansion@^1.1.7: - version "1.1.11" - resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" - integrity sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA== - dependencies: - balanced-match "^1.0.0" - concat-map "0.0.1" - -clang-format@~1.2.4: - version "1.2.4" - resolved "https://registry.yarnpkg.com/clang-format/-/clang-format-1.2.4.tgz#4bb4b0a98180428deb093cf20982e9fc1af20b6c" - integrity sha512-sw+nrGUp3hvmANd1qF8vZPuezSYQAiXgGBiEtkXTtJnnu6b00fCqkkDIsnRKrNgg4nv6NYZE92ejvOMIXZoejw== - dependencies: - async "^1.5.2" - glob "^7.0.0" - resolve "^1.1.6" - -concat-map@0.0.1: - version "0.0.1" - resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" - integrity sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg== - -core-js@^2.6.5: - version "2.6.12" - resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.6.12.tgz#d9333dfa7b065e347cc5682219d6f690859cc2ec" - integrity sha512-Kb2wC0fvsWfQrgk8HU5lW6U/Lcs8+9aaYcy4ZFc6DDlo4nZ7n70dEgE5rtR0oG6ufKDUnrwfWL1mXR5ljDatrQ== - -fs.realpath@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" - integrity sha1-FQStJSMVjKpA20onh8sBQRmU6k8= - -function-bind@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d" - integrity sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A== - -glob@^7.0.0: - version "7.2.0" - resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.0.tgz#d15535af7732e02e948f4c41628bd910293f6023" - integrity sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q== - dependencies: - fs.realpath "^1.0.0" - inflight "^1.0.4" - inherits "2" - minimatch "^3.0.4" - once "^1.3.0" - path-is-absolute "^1.0.0" - -has@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/has/-/has-1.0.3.tgz#722d7cbfc1f6aa8241f16dd814e011e1f41e8796" - integrity sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw== - dependencies: - function-bind "^1.1.1" - -inflight@^1.0.4: - version "1.0.6" - resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" - integrity sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk= - dependencies: - once "^1.3.0" - wrappy "1" - -inherits@2: - version "2.0.4" - resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" - integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== - -is-core-module@^2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.2.0.tgz#97037ef3d52224d85163f5597b2b63d9afed981a" - integrity sha512-XRAfAdyyY5F5cOXn7hYQDqh2Xmii+DEfIcQGxK/uNwMHhIkPWO0g8msXcbzLe+MpGoR951MlqM/2iIlU4vKDdQ== - dependencies: - has "^1.0.3" - -minimatch@^3.0.4: - version "3.1.2" - resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b" - integrity sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw== - dependencies: - brace-expansion "^1.1.7" - -once@^1.3.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" - integrity sha1-WDsap3WWHUsROsF9nFC6753Xa9E= - dependencies: - wrappy "1" - -path-is-absolute@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" - integrity sha1-F0uSaHNVNP+8es5r9TpanhtcX18= - -path-parse@^1.0.6: - version "1.0.7" - resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.7.tgz#fbc114b60ca42b30d9daf5858e4bd68bbedb6735" - integrity sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw== - -regenerator-runtime@^0.13.4: - version "0.13.7" - resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.7.tgz#cac2dacc8a1ea675feaabaeb8ae833898ae46f55" - integrity sha512-a54FxoJDIr27pgf7IgeQGxmqUNYrcV338lf/6gH456HZ/PhX+5BcwHXG9ajESmwe6WRO0tAzRUrRmNONWgkrew== - -resolve@^1.1.6: - version "1.20.0" - resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.20.0.tgz#629a013fb3f70755d6f0b7935cc1c2c5378b1975" - integrity sha512-wENBPt4ySzg4ybFQW2TT1zMQucPK95HSh/nq2CFTZVOGut2+pQvSsgtda4d26YrYcr067wjbmzOG8byDPBX63A== - dependencies: - is-core-module "^2.2.0" - path-parse "^1.0.6" - -wrappy@1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" - integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8= diff --git a/tfjs-master/tfjs-backend-webgl/.npmignore b/tfjs-master/tfjs-backend-webgl/.npmignore deleted file mode 100644 index 6292b5fdb..000000000 --- a/tfjs-master/tfjs-backend-webgl/.npmignore +++ /dev/null @@ -1,27 +0,0 @@ -.babelrc -.DS_Store -.idea/ -.rpt2_cache -.travis.yml -.vscode -*.tgz -*.txt -**.yalc -**yalc.lock -cloudbuild.yml -coverage/ -demo/ -dist/**/*_test.d.ts -dist/**/*_test.js -karma.conf.js -node_modules/ -npm-debug.log -package-lock.json -package/ -rollup.config.js -scripts/ -src/**/*_test.ts -tsconfig.json -tslint.json -yarn-error.log -yarn.lock diff --git a/tfjs-master/tfjs-backend-webgl/.npmrc b/tfjs-master/tfjs-backend-webgl/.npmrc deleted file mode 100644 index 43c97e719..000000000 --- a/tfjs-master/tfjs-backend-webgl/.npmrc +++ /dev/null @@ -1 +0,0 @@ -package-lock=false diff --git a/tfjs-master/tfjs-backend-webgl/BUILD.bazel b/tfjs-master/tfjs-backend-webgl/BUILD.bazel deleted file mode 100644 index cbe8e8c9d..000000000 --- a/tfjs-master/tfjs-backend-webgl/BUILD.bazel +++ /dev/null @@ -1,231 +0,0 @@ -# Copyright 2021 Google LLC. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================= - -load("@bazel_skylib//rules:copy_file.bzl", "copy_file") -load("@build_bazel_rules_nodejs//:index.bzl", "js_library", "pkg_npm") -load("//tools:copy_to_dist.bzl", "copy_to_dist", "copy_ts_library_to_dist") -load("//tools:tfjs_bundle.bzl", "tfjs_bundle") -load("//tools:tfjs_web_test.bzl", "tfjs_web_test") - -package(default_visibility = ["//visibility:public"]) - -tfjs_bundle( - name = "tf-backend-webgl", - entry_point = "//tfjs-backend-webgl/src:index.ts", - external = [ - "crypto", - "@tensorflow/tfjs-core", - "seedrandom", - "@tensorflow/tfjs-backend-cpu", - ], - globals = { - "@tensorflow/tfjs-core": "tf", - "seedrandom": "seedrandom", - }, - umd_name = "tf", - deps = [ - "//tfjs-backend-webgl/src:tfjs-backend-webgl_lib", - "//tfjs-backend-webgl/src:tfjs-backend-webgl_src_lib", - ], -) - -copy_ts_library_to_dist( - name = "copy_src_to_dist", - srcs = [ - "//tfjs-backend-webgl/src:tfjs-backend-webgl_lib", - "//tfjs-backend-webgl/src:tfjs-backend-webgl_src_lib", - ], - root = "src", -) - -copy_to_dist( - name = "copy_bundles", - srcs = [ - ":tf-backend-webgl", - ":tf-backend-webgl.es2017", - ":tf-backend-webgl.es2017.min", - ":tf-backend-webgl.fesm", - ":tf-backend-webgl.fesm.min", - ":tf-backend-webgl.min", - ":tf-backend-webgl.node", - ], -) - -copy_file( - name = "copy_miniprogram", - src = ":tf-backend-webgl.min.js", - out = "dist/miniprogram/index.js", -) - -copy_file( - name = "copy_miniprogram_map", - src = ":tf-backend-webgl.min.js.map", - out = "dist/miniprogram/index.js.map", -) - -pkg_npm( - name = "tfjs-backend-webgl_pkg", - package_name = "@tensorflow/tfjs-backend-webgl", - srcs = [ - "README.md", - "package.json", - ], - tags = ["ci"], - deps = [ - ":copy_bundles", - ":copy_miniprogram", - ":copy_miniprogram_map", - ":copy_src_to_dist", - ], -) - -STATIC_FILES = [ - # Listed here so sourcemaps are served - "//tfjs-backend-webgl/src:tfjs-backend-webgl_test_bundle", -] - -tfjs_web_test( - name = "tfjs-backend-webgl2_test", - srcs = [ - "//tfjs-backend-webgl/src:tfjs-backend-webgl_test_bundle", - ], - args = [ - "--testEnv", - "webgl2", - ], - browsers = [ - "bs_android_10", - "bs_chrome_mac", - "bs_firefox_mac", - "win_10_chrome", - ], - headless = False, - presubmit_browsers = [ - "bs_chrome_mac", - "bs_android_10", - ], - static_files = STATIC_FILES, -) - -tfjs_web_test( - name = "tfjs-backend-webgl1_test", - srcs = [ - "//tfjs-backend-webgl/src:tfjs-backend-webgl_test_bundle", - ], - args = [ - "--testEnv", - "webgl1", - ], - browsers = [ - "bs_ios_12", - "bs_safari_mac", - ], - headless = False, - presubmit_browsers = [ - "bs_safari_mac", - "bs_ios_12", - ], - 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", - ], - headless = False, - 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", - ], - headless = False, - 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", - ], - headless = False, - presubmit_browsers = [], # Only run in nightly - static_files = STATIC_FILES, -) - -tfjs_web_test( - name = "tfjs-backend-webgl_exp_conv_test", - srcs = [ - "//tfjs-backend-webgl/src:tfjs-backend-webgl_test_bundle", - ], - args = [ - "--testEnv", - "webgl2", - "--flags", - '{"WEBGL_EXP_CONV": true}', - ], - browsers = [ - "bs_chrome_mac", - ], - headless = False, - presubmit_browsers = [], # Only run in nightly - static_files = STATIC_FILES, -) - -js_library( - name = "package_json", - srcs = [ - ":package.json", - ], -) - -test_suite( - name = "tests", - tests = [ - ":tfjs-backend-webgl2_test", - ], -) diff --git a/tfjs-master/tfjs-backend-webgl/README.md b/tfjs-master/tfjs-backend-webgl/README.md deleted file mode 100644 index 489782a8d..000000000 --- a/tfjs-master/tfjs-backend-webgl/README.md +++ /dev/null @@ -1,37 +0,0 @@ -# Usage - -This package implements a GPU accelerated WebGL backend for TensorFlow.js. - -## Importing the backend - -Note: this backend is included by default in `@tensorflow/tfjs`. - -### Via NPM - -```js -// Import @tensorflow/tfjs-core -import * as tf from '@tensorflow/tfjs-core'; -// Adds the WebGL backend to the global backend registry. -import '@tensorflow/tfjs-backend-webgl'; -``` - -### Via a script tag - -```html - - - - - -``` - -You can also get ES2017 code using the following links - -```html - - - - - -``` - diff --git a/tfjs-master/tfjs-backend-webgl/package.json b/tfjs-master/tfjs-backend-webgl/package.json deleted file mode 100644 index b7c9d98dd..000000000 --- a/tfjs-master/tfjs-backend-webgl/package.json +++ /dev/null @@ -1,59 +0,0 @@ -{ - "name": "@tensorflow/tfjs-backend-webgl", - "version": "0.0.0", - "description": "GPU accelerated WebGL backend for TensorFlow.js", - "private": false, - "main": "dist/tf-backend-webgl.node.js", - "jsdelivr": "dist/tf-backend-webgl.min.js", - "unpkg": "dist/tf-backend-webgl.min.js", - "types": "dist/index.d.ts", - "jsnext:main": "dist/index.js", - "module": "dist/index.js", - "miniprogram": "dist/miniprogram", - "engines": { - "yarn": ">= 1.3.2" - }, - "repository": { - "type": "git", - "url": "https://github.com/tensorflow/tfjs.git" - }, - "license": "Apache-2.0", - "devDependencies": { - "@babel/polyfill": "^7.8.7", - "@bazel/bazelisk": "^1.12.0" - }, - "scripts": { - "build": "bazel build :tfjs-backend-webgl_pkg", - "publish-npm": "bazel run :tfjs-backend-webgl_pkg.publish", - "test": "bazel test :tests --test_output=streamed", - "test-debug": "bazel run :tests --test_output=streamed", - "run-browserstack": "bazel test :browserstack_bs_chrome_mac_tfjs-backend-webgl2_test" - }, - "dependencies": { - "@tensorflow/tfjs-backend-cpu": "link:../link-package/node_modules/@tensorflow/tfjs-backend-cpu", - "@types/offscreencanvas": "~2019.3.0", - "@types/seedrandom": "^2.4.28", - "seedrandom": "^3.0.5" - }, - "peerDependencies": { - "@tensorflow/tfjs-core": "link:../link-package/node_modules/@tensorflow/tfjs-core" - }, - "browser": { - "util": false, - "crypto": false - }, - "sideEffects": [ - "./dist/register_all_kernels.js", - "./dist/flags_webgl.js", - "./dist/base.js", - "./dist/index.js", - "./dist/register_all_kernels.mjs", - "./dist/flags_webgl.mjs", - "./dist/base.mjs", - "./dist/index.mjs", - "./src/register_all_kernels.mjs", - "./src/flags_webgl.mjs", - "./src/base.mjs", - "./src/index.mjs" - ] -} diff --git a/tfjs-master/tfjs-backend-webgl/src/BUILD.bazel b/tfjs-master/tfjs-backend-webgl/src/BUILD.bazel deleted file mode 100644 index ea3326295..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/BUILD.bazel +++ /dev/null @@ -1,100 +0,0 @@ -# Copyright 2021 Google LLC. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================= - -load("//tools:defaults.bzl", "esbuild", "ts_library") -load("//tools:enumerate_tests.bzl", "enumerate_tests") - -package(default_visibility = ["//visibility:public"]) - -TEST_SRCS = [ - "**/*_test.ts", -] - -filegroup( - name = "all_test_entrypoints", - srcs = glob( - ["**/*_test.ts"], - exclude = [ - "setup_test.ts", - ], - ), -) - -# Generates the 'tests.ts' file that imports all test entrypoints. -enumerate_tests( - name = "tests", - srcs = [":all_test_entrypoints"], - root_path = "tfjs-backend-webgl/src", -) - -ts_library( - name = "tfjs-backend-webgl_src_lib", - srcs = glob( - ["**/*.ts"], - exclude = TEST_SRCS + ["index.ts"], - ), - module_name = "@tensorflow/tfjs-backend-webgl/dist", - deps = [ - "//tfjs-backend-cpu/src:tfjs-backend-cpu_lib", - "//tfjs-backend-cpu/src:tfjs-backend-cpu_src_lib", - "//tfjs-core/src:tfjs-core_lib", - "//tfjs-core/src:tfjs-core_src_lib", - "@npm//@types/offscreencanvas", - "@npm//@types/seedrandom", - ], -) - -ts_library( - name = "tfjs-backend-webgl_lib", - srcs = ["index.ts"], - module_name = "@tensorflow/tfjs-backend-webgl", - deps = [ - ":tfjs-backend-webgl_src_lib", - ], -) - -ts_library( - name = "tfjs-backend-webgl_test_lib", - testonly = True, - srcs = glob(TEST_SRCS) + [":tests"], - module_name = "@tensorflow/tfjs-backend-webgl/dist", - deps = [ - ":tfjs-backend-webgl_lib", - ":tfjs-backend-webgl_src_lib", - "//tfjs-backend-cpu/src:tfjs-backend-cpu_lib", - "//tfjs-core/src:tfjs-core_lib", - "//tfjs-core/src:tfjs-core_src_lib", - "//tfjs-core/src:tfjs-core_test_lib", - ], -) - -esbuild( - name = "tfjs-backend-webgl_test_bundle", - testonly = True, - entry_point = "setup_test.ts", - external = [ - # webworker tests call 'require('@tensorflow/tfjs')', which - # is external to the test bundle. - # Note: This is not a bazel target. It's just a string. - "@tensorflow/tfjs", - "worker_threads", - "util", - ], - sources_content = True, - deps = [ - ":tfjs-backend-webgl_lib", - ":tfjs-backend-webgl_test_lib", - ], -) diff --git a/tfjs-master/tfjs-backend-webgl/src/addn_gpu.ts b/tfjs-master/tfjs-backend-webgl/src/addn_gpu.ts deleted file mode 100644 index 190357b55..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/addn_gpu.ts +++ /dev/null @@ -1,51 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {GPGPUProgram} from './gpgpu_math'; - -export class AddNProgram implements GPGPUProgram { - variableNames: string[]; - outputShape: number[] = []; - userCode: string; - - constructor(outputShape: number[], shapes: number[][]) { - this.outputShape = outputShape; - this.variableNames = shapes.map((_, i) => `T${i}`); - - const snippets: string[] = []; - // Get target elements from every input tensor. - this.variableNames.forEach(variable => { - snippets.push(`float v${variable} = get${variable}AtOutCoords();`); - }); - - // Calculate the sum of all elements. - const operation = this.variableNames - .map(variable => { - return `v${variable}`; - }) - .join(' + '); - - this.userCode = ` - void main() { - ${snippets.join('\n ')} - - float result = ${operation}; - setOutput(result); - } - `; - } -} diff --git a/tfjs-master/tfjs-backend-webgl/src/addn_packed_gpu.ts b/tfjs-master/tfjs-backend-webgl/src/addn_packed_gpu.ts deleted file mode 100644 index d5d9f4d19..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/addn_packed_gpu.ts +++ /dev/null @@ -1,53 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {GPGPUProgram} from './gpgpu_math'; - -export class AddNPackedProgram implements GPGPUProgram { - variableNames: string[]; - outputShape: number[] = []; - userCode: string; - packedInputs = true; - packedOutput = true; - - constructor(outputShape: number[], shapes: number[][]) { - this.outputShape = outputShape; - this.variableNames = shapes.map((_, i) => `T${i}`); - - const snippets: string[] = []; - // Get target elements from every input tensor. - this.variableNames.forEach(variable => { - snippets.push(`vec4 v${variable} = get${variable}AtOutCoords();`); - }); - - // Calculate the sum of all elements. - const operation = this.variableNames - .map(variable => { - return `v${variable}`; - }) - .join(' + '); - - this.userCode = ` - void main() { - ${snippets.join('\n ')} - - vec4 result = ${operation}; - setOutput(result); - } - `; - } -} diff --git a/tfjs-master/tfjs-backend-webgl/src/argminmax_gpu.ts b/tfjs-master/tfjs-backend-webgl/src/argminmax_gpu.ts deleted file mode 100644 index d3e63c0e6..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/argminmax_gpu.ts +++ /dev/null @@ -1,61 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util} from '@tensorflow/tfjs-core'; -import {GPGPUProgram} from './gpgpu_math'; - -export class ArgMinMaxProgram implements GPGPUProgram { - variableNames = ['A']; - outputShape: number[]; - userCode: string; - - constructor( - reduceInfo: backend_util.ReduceInfo, op: 'max'|'min', - firstPass: boolean) { - const {windowSize, batchSize, outSize} = reduceInfo; - if (!firstPass) { - this.variableNames.push('bestIndicesA'); - } - this.outputShape = [batchSize, outSize]; - const compOp = (op === 'max') ? '>' : '<'; - const indexSnippet = firstPass ? - 'inOffset + i;' : - 'round(getBestIndicesA(batch, inOffset + i));'; - - this.userCode = ` - void main() { - ivec2 coords = getOutputCoords(); - int batch = coords[0]; - int outIdx = coords[1]; - int inOffset = outIdx * ${windowSize}; - - int bestIndex = inOffset; - float bestValue = getA(batch, bestIndex); - - for (int i = 0; i < ${windowSize}; i++) { - int inIdx = ${indexSnippet}; - float candidate = getA(batch, inIdx); - if (candidate ${compOp} bestValue) { - bestValue = candidate; - bestIndex = inIdx; - } - } - setOutput(float(bestIndex)); - } - `; - } -} diff --git a/tfjs-master/tfjs-backend-webgl/src/argminmax_packed_gpu.ts b/tfjs-master/tfjs-backend-webgl/src/argminmax_packed_gpu.ts deleted file mode 100644 index 99c66c83f..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/argminmax_packed_gpu.ts +++ /dev/null @@ -1,146 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {util} from '@tensorflow/tfjs-core'; - -import {GPGPUProgram} from './gpgpu_math'; -import {getChannels} from './packing_util'; -import {getCoordsDataType} from './shader_compiler'; - -export class ArgMinMaxPackedProgram implements GPGPUProgram { - variableNames = ['A']; - outputShape: number[]; - userCode: string; - packedInputs = true; - packedOutput = true; - - constructor( - shape: number[], windowSize: number, op: 'max'|'min', - firstPass: boolean) { - util.assert( - shape.length > 2, - () => `Packed arg${ - op.charAt(0).toUpperCase() + - op.slice(1)} supports only inputs with rank above 2.`); - const inSize = shape[shape.length - 1]; - const outSize = Math.ceil(inSize / windowSize); - this.outputShape = shape.slice(0, -1); - if (outSize > 1) { - this.outputShape.push(outSize); - } - if (!firstPass) { - this.variableNames.push('bestIndicesA'); - } - const outShape = this.outputShape; - const rank = outShape.length; - const dtype = getCoordsDataType(rank); - const coords = getChannels('coords', rank); - - let sourceLocSetup; - let sourceRank; - if (outSize === 1) { - sourceRank = rank + 1; - const sourceLocDType = getCoordsDataType(sourceRank); - sourceLocSetup = ` - ${sourceLocDType} sourceLocR = ${sourceLocDType}(${coords.join()}, 0); - ++${coords[rank - 1]}; - ${sourceLocDType} sourceLocG = ${sourceLocDType}(${coords.join()}, 0); - ++${coords[rank - 2]}; - ${sourceLocDType} sourceLocA = ${sourceLocDType}(${coords.join()}, 0); - --${coords[rank - 1]}; - ${sourceLocDType} sourceLocB = ${sourceLocDType}(${coords.join()}, 0); - --${coords[rank - 2]};`; - } else { - sourceRank = rank; - sourceLocSetup = ` - ${dtype} sourceLocR = coords; - ++${coords[rank - 1]}; - ${dtype} sourceLocG = coords; - ++${coords[rank - 2]}; - ${dtype} sourceLocA = coords; - --${coords[rank - 1]}; - ${dtype} sourceLocB = coords; - --${coords[rank - 2]};`; - } - const channels = ['x', 'y', 'z', 'w', 'u', 'v'].slice(0, sourceRank); - const inChannel = '.' + channels[sourceRank - 1]; // e.g. ".b" for rank 3. - const intChannels = channels.map(x => 'int ' + x); - const srcRCoords = - getChannels('sourceLocR', sourceRank - 1).concat('inIdx.r'); - const srcGCoords = - getChannels('sourceLocG', sourceRank - 1).concat('inIdx.g'); - const srcBCoords = - getChannels('sourceLocB', sourceRank - 1).concat('inIdx.b'); - const srcACoords = - getChannels('sourceLocA', sourceRank - 1).concat('inIdx.a'); - - const compOp = (op === 'max') ? 'greaterThan' : 'lessThan'; - const fetchCandidateIdx = firstPass ? '' : ` - inIdx = round(vec4(getBestIndicesAChannel(${srcRCoords.join()}), - getBestIndicesAChannel(${srcGCoords.join()}), - getBestIndicesAChannel(${srcBCoords.join()}), - getBestIndicesAChannel(${srcACoords.join()})));`; - - const fetchValue = `vec4( - getAChannel(${srcRCoords.join()}), - hasNextCol ? getAChannel(${srcGCoords.join()}) : 0., - hasNextRow ? getAChannel(${srcBCoords.join()}) : 0., - hasNextRow && hasNextCol ? getAChannel(${srcACoords.join()}) : 0.)`; - - const getBestIndicesAChannelSnippet = firstPass ? '' : ` - float getBestIndicesAChannel(${intChannels.join()}) { - return getChannel(getBestIndicesA(${channels.join()}), - vec2(${channels.slice(-2).join()})); - }`; - - this.userCode = ` - float getAChannel(${intChannels.join()}) { - return getChannel(getA(${channels.join()}), - vec2(${channels.slice(-2).join()})); - } - ${getBestIndicesAChannelSnippet} - void main() { - ${dtype} coords = getOutputCoords(); - bool hasNextCol = ${coords[rank - 1]} < ${outShape[rank - 1] - 1}; - bool hasNextRow = ${coords[rank - 2]} < ${outShape[rank - 2] - 1}; - ${sourceLocSetup} - ivec4 srcIdx = ivec4(sourceLocR${inChannel}, sourceLocG${inChannel}, - sourceLocB${inChannel}, sourceLocA${inChannel}) * ${windowSize}; - ivec4 inIdx = srcIdx; - vec4 bestIndex = vec4(inIdx); - vec4 bestValue = ${fetchValue}; - - for (int i = 0; i < ${windowSize}; i++) { - inIdx = srcIdx; - ${fetchCandidateIdx} - vec4 candidate = ${fetchValue}; - bvec4 nan = isnan(candidate); - bvec4 replace = bvec4( - vec4(${compOp}(candidate, bestValue)) * (vec4(1.0) - vec4(nan))); - - bestValue = vec4(replace.x ? candidate.x : bestValue.x, - replace.y ? candidate.y : bestValue.y, - replace.z ? candidate.z : bestValue.z, - replace.w ? candidate.w : bestValue.w); - bestIndex = mix(bestIndex, vec4(inIdx), vec4(replace)); - srcIdx++; - } - setOutput(bestIndex); - } - `; - } -} diff --git a/tfjs-master/tfjs-backend-webgl/src/avg_pool_backprop_gpu.ts b/tfjs-master/tfjs-backend-webgl/src/avg_pool_backprop_gpu.ts deleted file mode 100644 index dd542d1fb..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/avg_pool_backprop_gpu.ts +++ /dev/null @@ -1,172 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util} from '@tensorflow/tfjs-core'; -import {GPGPUProgram} from './gpgpu_math'; - -export class AvgPool2DBackpropProgram implements GPGPUProgram { - variableNames = ['dy']; - outputShape: number[]; - userCode: string; - - constructor(convInfo: backend_util.Conv2DInfo) { - this.outputShape = convInfo.inShape; - const filterHeight = convInfo.filterHeight; - const filterWidth = convInfo.filterWidth; - const strideHeight = convInfo.strideHeight; - const strideWidth = convInfo.strideWidth; - const dilationHeight = convInfo.dilationHeight; - const dilationWidth = convInfo.dilationWidth; - const effectiveFilterHeight = convInfo.effectiveFilterHeight; - const effectiveFilterWidth = convInfo.effectiveFilterWidth; - - const padTop = effectiveFilterHeight - 1 - convInfo.padInfo.top; - const padLeft = effectiveFilterWidth - 1 - convInfo.padInfo.left; - - const avgMultiplier = 1 / (filterHeight * filterWidth); - - this.userCode = ` - const ivec2 pads = ivec2(${padTop}, ${padLeft}); - const float avgMultiplier = float(${avgMultiplier}); - - void main() { - ivec4 coords = getOutputCoords(); - int b = coords[0]; - int d = coords[3]; - - ivec2 dyRCCorner = coords.yz - pads; - int dyRCorner = dyRCCorner.x; - int dyCCorner = dyRCCorner.y; - - // Convolve dy(?, ?, d) with pos mask(:, :, d) to get dx(xR, xC, d). - // ? = to be determined. : = across all values in that axis. - float dotProd = 0.0; - for (int wR = 0; wR < ${effectiveFilterHeight}; - wR += ${dilationHeight}) { - float dyR = float(dyRCorner + wR) / ${strideHeight}.0; - - if (dyR < 0.0 || dyR >= ${convInfo.outHeight}.0 || fract(dyR) > 0.0) { - continue; - } - int idyR = int(dyR); - - for (int wC = 0; wC < ${effectiveFilterWidth}; - wC+= ${dilationWidth}) { - float dyC = float(dyCCorner + wC) / ${strideWidth}.0; - - if (dyC < 0.0 || dyC >= ${convInfo.outWidth}.0 || - fract(dyC) > 0.0) { - continue; - } - int idyC = int(dyC); - - float dyValue = getDy(b, idyR, idyC, d); - - dotProd += dyValue * avgMultiplier; - } - } - setOutput(dotProd); - } - `; - } -} - -export class AvgPool3DBackpropProgram implements GPGPUProgram { - variableNames = ['dy']; - outputShape: number[]; - userCode: string; - - constructor(convInfo: backend_util.Conv3DInfo) { - this.outputShape = convInfo.inShape; - const filterDepth = convInfo.filterDepth; - const filterHeight = convInfo.filterHeight; - const filterWidth = convInfo.filterWidth; - const strideDepth = convInfo.strideDepth; - const strideHeight = convInfo.strideHeight; - const strideWidth = convInfo.strideWidth; - const dilationDepth = convInfo.dilationDepth; - const dilationHeight = convInfo.dilationHeight; - const dilationWidth = convInfo.dilationWidth; - const effectiveFilterDepth = convInfo.effectiveFilterDepth; - const effectiveFilterHeight = convInfo.effectiveFilterHeight; - const effectiveFilterWidth = convInfo.effectiveFilterWidth; - - const padFront = effectiveFilterDepth - 1 - convInfo.padInfo.front; - const padTop = effectiveFilterHeight - 1 - convInfo.padInfo.top; - const padLeft = effectiveFilterWidth - 1 - convInfo.padInfo.left; - - const avgMultiplier = 1 / (filterDepth * filterHeight * filterWidth); - - this.userCode = ` - const ivec3 pads = ivec3(${padFront}, ${padTop}, ${padLeft}); - const float avgMultiplier = float(${avgMultiplier}); - - void main() { - ivec5 coords = getOutputCoords(); - int batch = coords.x; - int ch = coords.u; - - ivec3 dyCorner = ivec3(coords.y, coords.z, coords.w) - pads; - int dyDCorner = dyCorner.x; - int dyRCorner = dyCorner.y; - int dyCCorner = dyCorner.z; - - // Convolve dy(?, ?, ?, d) with pos mask(:, :, :, ch) to get - // dx(xD, xR, xC, ch). - // ? = to be determined. : = across all values in that axis. - float dotProd = 0.0; - - for (int wD = 0; wD < ${effectiveFilterDepth}; - wD += ${dilationDepth}) { - float dyD = float(dyDCorner + wD) / ${strideDepth}.0; - - if (dyD < 0.0 || dyD >= ${convInfo.outDepth}.0 || fract(dyD) > 0.0) { - continue; - } - int idyD = int(dyD); - - for (int wR = 0; wR < ${effectiveFilterHeight}; - wR += ${dilationHeight}) { - float dyR = float(dyRCorner + wR) / ${strideHeight}.0; - - if (dyR < 0.0 || dyR >= ${convInfo.outHeight}.0 || - fract(dyR) > 0.0) { - continue; - } - int idyR = int(dyR); - - for (int wC = 0; wC < ${effectiveFilterWidth}; - wC += ${dilationWidth}) { - float dyC = float(dyCCorner + wC) / ${strideWidth}.0; - - if (dyC < 0.0 || dyC >= ${convInfo.outWidth}.0 || - fract(dyC) > 0.0) { - continue; - } - int idyC = int(dyC); - - float dyValue = getDy(batch, idyD, idyR, idyC, ch); - - dotProd += dyValue * avgMultiplier; - } - } - } - setOutput(dotProd); - } - `; - } -} diff --git a/tfjs-master/tfjs-backend-webgl/src/backend_webgl.ts b/tfjs-master/tfjs-backend-webgl/src/backend_webgl.ts deleted file mode 100644 index ecbf01354..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/backend_webgl.ts +++ /dev/null @@ -1,1346 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// Import webgl flags. -import './flags_webgl'; - -import * as tf from '@tensorflow/tfjs-core'; -import {backend_util, BackendValues, buffer, DataId, DataStorage, DataToGPUWebGLOption, DataType, engine, env, GPUData, kernel_impls, KernelBackend, MemoryInfo, nextFrame, NumericDataType, Rank, RecursiveArray, scalar, ShapeMap, Tensor, Tensor2D, TensorBuffer, TensorInfo, tidy, TimingInfo, TypedArray, util, WebGLData} from '@tensorflow/tfjs-core'; -import {getWebGLContext} from './canvas_util'; -import {DecodeMatrixProgram} from './decode_matrix_gpu'; -import {DecodeMatrixPackedProgram} from './decode_matrix_packed_gpu'; -import {EncodeFloatProgram} from './encode_float_gpu'; -import {EncodeFloatPackedProgram} from './encode_float_packed_gpu'; -import {EncodeMatrixProgram} from './encode_matrix_gpu'; -import {EncodeMatrixPackedProgram} from './encode_matrix_packed_gpu'; -import {GPGPUContext} from './gpgpu_context'; -import * as gpgpu_math from './gpgpu_math'; -import {getUniformLocations, GPGPUBinary, GPGPUProgram, TensorData} from './gpgpu_math'; -import {simpleAbsImplCPU} from './kernel_utils/shared'; -import {PackProgram} from './pack_gpu'; -import {ReshapePackedProgram} from './reshape_packed_gpu'; -import * as tex_util from './tex_util'; -import {Texture, TextureData, TextureUsage} from './tex_util'; -import {TextureManager} from './texture_manager'; -import * as unary_op from './unaryop_gpu'; -import {UnaryOpProgram} from './unaryop_gpu'; -import {UnaryOpPackedProgram} from './unaryop_packed_gpu'; -import {UnpackProgram} from './unpack_gpu'; -import * as webgl_util from './webgl_util'; - -const whereImpl = kernel_impls.whereImpl; - -export const EPSILON_FLOAT32 = 1e-7; -export const EPSILON_FLOAT16 = 1e-4; - -type KernelInfo = { - name: string; query: Promise; -}; - -export type TimerNode = RecursiveArray|KernelInfo; -export interface CPUTimerQuery { - startMs: number; - endMs?: number; -} - -export interface WebGLMemoryInfo extends MemoryInfo { - numBytesInGPU: number; - // Tracks the total number of bytes allocated on the GPU, accounting for the - // physical texture type. - numBytesInGPUAllocated: number; - // Tracks byte size of textures that were created and then made available for - // reuse (disposed). - numBytesInGPUFree: number; - unreliable: boolean; -} - -export interface WebGLTimingInfo extends TimingInfo { - uploadWaitMs: number; - downloadWaitMs: number; -} - -const binaryCaches: {[webGLVersion: string]: {[key: string]: GPGPUBinary}} = {}; - -export function getBinaryCache(webGLVersion: number) { - if (webGLVersion in binaryCaches) { - return binaryCaches[webGLVersion]; - } - binaryCaches[webGLVersion] = {}; - return binaryCaches[webGLVersion]; -} - -// Empirically determined constant used to determine size threshold for handing -// off execution to the CPU. -const CPU_HANDOFF_SIZE_THRESHOLD = - env().getNumber('CPU_HANDOFF_SIZE_THRESHOLD'); - -// Empirically determined constant used to decide the number of MB on GPU -// before we warn about high memory use. The MB are this constant * screen area -// * dpi / 1024 / 1024. -const BEFORE_PAGING_CONSTANT = 600; -function numMBBeforeWarning(): number { - if (env().global.screen == null) { - return 1024; // 1 GB. - } - return (env().global.screen.height * env().global.screen.width * - window.devicePixelRatio) * - BEFORE_PAGING_CONSTANT / 1024 / 1024; -} - -export class MathBackendWebGL extends KernelBackend { - texData: DataStorage; - gpgpu: GPGPUContext; - - private static nextDataId = 0; - private nextDataId(): number { - return MathBackendWebGL.nextDataId++; - } - // Maps data ids that have a pending read operation, to list of subscribers. - private pendingRead = new WeakMap void>>(); - // List of data ids that are scheduled for disposal, but are waiting on a - // pending read operation. - private pendingDisposal = new WeakSet(); - - // Used to count the number of 'shallow' sliced tensors that point to the - // same data id. - dataRefCount = new WeakMap(); - private numBytesInGPU = 0; - - private canvas: HTMLCanvasElement|OffscreenCanvas; - - private programTimersStack: TimerNode[]; - private activeTimers: TimerNode[]; - // Accumulated time spent (including blocking) in uploading data to webgl. - private uploadWaitMs = 0; - // Accumulated time spent (including blocking in downloading data from webgl. - private downloadWaitMs = 0; - - // record the last manual GL Flush time. - private lastGlFlushTime = 0; - - // Number of bits of precision of this backend. - private floatPrecisionValue: 32|16; - - private textureManager: TextureManager; - private binaryCache: {[key: string]: GPGPUBinary}; - private gpgpuCreatedLocally: boolean; - private numMBBeforeWarning: number; - private warnedAboutMemory = false; - - constructor(gpuResource?: GPGPUContext|HTMLCanvasElement|OffscreenCanvas) { - super(); - if (!env().getBool('HAS_WEBGL')) { - throw new Error('WebGL is not supported on this device'); - } - - let newGPGPU; - if (gpuResource != null) { - if (gpuResource instanceof GPGPUContext) { - newGPGPU = gpuResource; - } else { - const gl = - getWebGLContext(env().getNumber('WEBGL_VERSION'), gpuResource); - newGPGPU = new GPGPUContext(gl); - } - this.binaryCache = {}; - this.gpgpuCreatedLocally = false; - } else { - const gl = getWebGLContext(env().getNumber('WEBGL_VERSION')); - newGPGPU = new GPGPUContext(gl); - this.binaryCache = getBinaryCache(env().getNumber('WEBGL_VERSION')); - this.gpgpuCreatedLocally = true; - } - - this.gpgpu = newGPGPU; - this.canvas = this.gpgpu.gl.canvas; - this.textureManager = new TextureManager(this.gpgpu); - this.numMBBeforeWarning = numMBBeforeWarning(); - this.texData = new DataStorage(this, engine()); - } - - override numDataIds() { - return this.texData.numDataIds() - this.pendingDeletes; - } - - // Writes a new entry to the data store with a WebGL texture, and registers it - // to the texture manager. - writeTexture( - texture: WebGLTexture, shape: number[], dtype: DataType, - texHeight: number, texWidth: number, channels: string): DataId { - // Temporarily create an tensor info to make the texture compatible with - // the runWebGLProgram's input. - const input = this.makeTensorInfo(shape, dtype); - const inData = this.texData.get(input.dataId); - // Even though the input texture could be unpacked or dense packed, it is - // always considered as unpacked for EncodeMatrixProgram. - inData.isPacked = false; - - // Bind texture to the input tensor. - inData.texture = {texture, texShape: [texHeight, texWidth]}; - inData.texShape = [texHeight, texWidth]; - - const shapeAs3D = webgl_util.getShapeAs3D(shape); - const program = - new EncodeMatrixProgram(shapeAs3D, false /* isByteArray */, channels); - const output = - this.runWebGLProgram(program, [input], dtype, [[texHeight, texWidth]]); - output.shape = shape; - - // Unbind the texture from the input tensor to avoid the texture being - // released. - inData.texture = null; - this.disposeIntermediateTensorInfo(input); - - return output.dataId; - } - - override write(values: BackendValues, shape: number[], dtype: DataType): - DataId { - if (env().getBool('WEBGL_CHECK_NUMERICAL_PROBLEMS') || - env().getBool('DEBUG')) { - this.checkNumericalProblems(values); - } - if (dtype === 'complex64' && values != null) { - throw new Error( - `Cannot write to a complex64 dtype. ` + - `Please use tf.complex(real, imag).`); - } - const dataId = {id: this.nextDataId()}; - this.texData.set( - dataId, - {shape, dtype, values, usage: TextureUsage.UPLOAD, refCount: 1}); - return dataId; - } - - /** Return refCount of a `TensorData`. */ - override refCount(dataId: DataId): number { - if (this.texData.has(dataId)) { - const tensorData = this.texData.get(dataId); - return tensorData.refCount; - } - return 0; - } - - /** Increase refCount of a `TextureData`. */ - override incRef(dataId: DataId): void { - const texData = this.texData.get(dataId); - texData.refCount++; - } - - /** Decrease refCount of a `TextureData`. */ - decRef(dataId: DataId): void { - if (this.texData.has(dataId)) { - const texData = this.texData.get(dataId); - texData.refCount--; - } - } - - override move( - dataId: DataId, values: BackendValues, shape: number[], dtype: DataType, - refCount: number): void { - if (env().getBool('DEBUG')) { - this.checkNumericalProblems(values); - } - if (dtype === 'complex64') { - throw new Error( - `Cannot write to a complex64 dtype. ` + - `Please use tf.complex(real, imag).`); - } - this.texData.set( - dataId, {shape, dtype, values, usage: TextureUsage.UPLOAD, refCount}); - } - - disposeIntermediateTensorInfo(tensorInfo: TensorInfo): void { - this.disposeData(tensorInfo.dataId); - } - - override readSync(dataId: DataId): BackendValues { - const texData = this.texData.get(dataId); - const {values, dtype, complexTensorInfos, slice, shape, isPacked} = texData; - - // The presence of `slice` indicates this tensor is a shallow slice of a - // different tensor, and is using that original tensor's texture. Run - // `clone` in order to copy that texture and read from it. - if (slice != null) { - let program; - if (isPacked) { - program = new UnaryOpPackedProgram(shape, unary_op.CLONE); - } else { - program = new UnaryOpProgram(shape, unary_op.CLONE); - } - const res = - this.runWebGLProgram(program, [{dataId, shape, dtype}], dtype); - const data = this.readSync(res.dataId); - this.disposeIntermediateTensorInfo(res); - return data; - } - if (values != null) { - return this.convertAndCacheOnCPU(dataId); - } - if (dtype === 'string') { - return values; - } - const shouldTimeProgram = this.activeTimers != null; - let start: number; - if (shouldTimeProgram) { - start = util.now(); - } - - let result: Float32Array; - if (dtype === 'complex64') { - const realValues = - this.readSync(complexTensorInfos.real.dataId) as Float32Array; - const imagValues = - this.readSync(complexTensorInfos.imag.dataId) as Float32Array; - result = backend_util.mergeRealAndImagArrays(realValues, imagValues); - } else { - result = this.getValuesFromTexture(dataId); - } - - if (shouldTimeProgram) { - this.downloadWaitMs += util.now() - start; - } - return this.convertAndCacheOnCPU(dataId, result); - } - - override async read(dataId: DataId): Promise { - if (this.pendingRead.has(dataId)) { - const subscribers = this.pendingRead.get(dataId); - return new Promise(resolve => subscribers.push(resolve)); - } - const texData = this.texData.get(dataId); - const {values, shape, slice, dtype, complexTensorInfos, isPacked} = texData; - - // The presence of `slice` indicates this tensor is a shallow slice of a - // different tensor, and is using that original tensor's texture. Run - // `clone` in order to copy that texture and read from it. - if (slice != null) { - let program; - if (isPacked) { - program = new UnaryOpPackedProgram(shape, unary_op.CLONE); - } else { - program = new UnaryOpProgram(shape, unary_op.CLONE); - } - const res = - this.runWebGLProgram(program, [{dataId, shape, dtype}], dtype); - const data = this.read(res.dataId); - this.disposeIntermediateTensorInfo(res); - return data; - } - - if (values != null) { - return this.convertAndCacheOnCPU(dataId); - } - - if (env().getBool('DEBUG')) { - // getBool('WEBGL_DOWNLOAD_FLOAT_ENABLED') caused a blocking GPU call. - // For performance reason, only check it for debugging. In production, - // it doesn't handle this use case anyway, so behavior is not changed. - if (!env().getBool('WEBGL_DOWNLOAD_FLOAT_ENABLED') && - env().getNumber('WEBGL_VERSION') === 2) { - throw new Error( - `tensor.data() with WEBGL_DOWNLOAD_FLOAT_ENABLED=false and ` + - `WEBGL_VERSION=2 not yet supported.`); - } - } - - let buffer: WebGLBuffer = null; - let tmpDownloadTarget: TensorInfo; - - if (dtype !== 'complex64' && env().get('WEBGL_BUFFER_SUPPORTED')) { - // Possibly copy the texture into a buffer before inserting a fence. - tmpDownloadTarget = this.decode(dataId); - const tmpData = this.texData.get(tmpDownloadTarget.dataId); - - buffer = this.gpgpu.createBufferFromTexture( - tmpData.texture.texture, ...tex_util.getDenseTexShape(shape)); - } - - this.pendingRead.set(dataId, []); - - if (dtype !== 'complex64') { - // Create a fence and wait for it to resolve. - await this.gpgpu.createAndWaitForFence(); - } - - // Download the values from the GPU. - let vals: Float32Array; - if (dtype === 'complex64') { - const ps = await Promise.all([ - this.read(complexTensorInfos.real.dataId), - this.read(complexTensorInfos.imag.dataId) - ]); - - const realValues = ps[0]; - const imagValues = ps[1]; - vals = backend_util.mergeRealAndImagArrays( - realValues as Float32Array, imagValues as Float32Array); - } else if (buffer == null) { - vals = this.getValuesFromTexture(dataId); - } else { - const size = util.sizeFromShape(shape); - vals = this.gpgpu.downloadFloat32MatrixFromBuffer(buffer, size); - } - if (tmpDownloadTarget != null) { - this.disposeIntermediateTensorInfo(tmpDownloadTarget); - } - if (buffer != null) { - const gl = this.gpgpu.gl; - webgl_util.callAndCheck(gl, () => gl.deleteBuffer(buffer)); - } - const dTypeVals = this.convertAndCacheOnCPU(dataId, vals); - - const subscribers = this.pendingRead.get(dataId); - this.pendingRead.delete(dataId); - - // Notify all pending reads. - subscribers.forEach(resolve => resolve(dTypeVals)); - if (this.pendingDisposal.has(dataId)) { - this.pendingDisposal.delete(dataId); - if (this.disposeData(dataId)) { - engine().removeDataId(dataId, this); - } - this.pendingDeletes--; - } - return dTypeVals; - } - - /** - * Read tensor to a new texture that is densely packed for ease of use. - * @param dataId The source tensor. - * @param options - * customTexShape: Optional. If set, will use the user defined texture - * shape to create the texture. - */ - override readToGPU(dataId: DataId, options: DataToGPUWebGLOption = {}): - GPUData { - const texData = this.texData.get(dataId); - const {values, shape, slice, dtype, isPacked, texture} = texData; - - if (dtype === 'complex64') { - throw new Error('Does not support reading texture for complex64 dtype.'); - } - - // The presence of `slice` indicates this tensor is a shallow slice of a - // different tensor, and is using that original tensor's texture. Run - // `clone` in order to copy that texture and read from it. - if (slice != null) { - let program; - if (isPacked) { - program = new UnaryOpPackedProgram(shape, unary_op.CLONE); - } else { - program = new UnaryOpProgram(shape, unary_op.CLONE); - } - const res = - this.runWebGLProgram(program, [{dataId, shape, dtype}], dtype); - const gpuResouorce = this.readToGPU(res, options); - this.disposeIntermediateTensorInfo(res); - return gpuResouorce; - } - - if (texture == null) { - if (values != null) { - throw new Error('Data is not on GPU but on CPU.'); - } else { - throw new Error('There is no data on GPU or CPU.'); - } - } - - // Decode the texture so that it is stored densely (using four channels). - const tmpTarget = this.decode(dataId, options.customTexShape); - - // Make engine track this tensor, so that we can dispose it later. - const tensorRef = engine().makeTensorFromTensorInfo(tmpTarget); - - const tmpData = this.texData.get(tmpTarget.dataId); - return {tensorRef, ...tmpData.texture}; - } - - bufferSync(t: TensorInfo): - TensorBuffer { - const data = this.readSync(t.dataId); - if (t.dtype === 'string') { - try { - // Decode the bytes into string. - const strings = (data as Uint8Array[]).map(d => util.decodeString(d)); - return buffer(t.shape as ShapeMap[R], t.dtype, strings) as - TensorBuffer; - } catch { - throw new Error('Failed to decode encoded string bytes into utf-8'); - } - } - return buffer(t.shape as ShapeMap[R], t.dtype, data as TypedArray) as - TensorBuffer; - } - - private checkNumericalProblems(values: BackendValues): void { - if (values == null) { - return; - } - for (let i = 0; i < values.length; i++) { - const num = values[i] as number; - if (!webgl_util.canBeRepresented(num)) { - if (env().getBool('WEBGL_RENDER_FLOAT32_CAPABLE')) { - throw Error( - `The value ${num} cannot be represented with your ` + - `current settings. Consider enabling float32 rendering: ` + - `'tf.env().set('WEBGL_RENDER_FLOAT32_ENABLED', true);'`); - } - throw Error(`The value ${num} cannot be represented on this device.`); - } - } - } - - private getValuesFromTexture(dataId: DataId): Float32Array { - const {shape, dtype, isPacked} = this.texData.get(dataId); - const size = util.sizeFromShape(shape); - if (env().getBool('WEBGL_DOWNLOAD_FLOAT_ENABLED')) { - const tmpTarget = this.decode(dataId); - const tmpData = this.texData.get(tmpTarget.dataId); - const vals = - this.gpgpu - .downloadMatrixFromPackedTexture( - tmpData.texture.texture, ...tex_util.getDenseTexShape(shape)) - .subarray(0, size); - - this.disposeIntermediateTensorInfo(tmpTarget); - - return vals; - } - - const shouldUsePackedProgram = - env().getBool('WEBGL_PACK') && isPacked === true; - const outputShape = - shouldUsePackedProgram ? webgl_util.getShapeAs3D(shape) : shape; - const program = shouldUsePackedProgram ? - new EncodeFloatPackedProgram(outputShape as [number, number, number]) : - new EncodeFloatProgram(outputShape); - const output = this.runWebGLProgram( - program, [{shape: outputShape, dtype, dataId}], 'float32'); - const tmpData = this.texData.get(output.dataId); - const vals = this.gpgpu - .downloadByteEncodedFloatMatrixFromOutputTexture( - tmpData.texture.texture, tmpData.texShape[0], - tmpData.texShape[1]) - .subarray(0, size); - this.disposeIntermediateTensorInfo(output); - - return vals; - } - - override timerAvailable(): boolean { - return env().getNumber('WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE') > 0; - } - - override time(f: () => void): Promise { - const oldActiveTimers = this.activeTimers; - const newActiveTimers: TimerNode[] = []; - - let outerMostTime = false; - if (this.programTimersStack == null) { - this.programTimersStack = newActiveTimers; - outerMostTime = true; - } else { - this.activeTimers.push(newActiveTimers); - } - this.activeTimers = newActiveTimers; - - f(); - - // needing to split these up because util.flatten only accepts certain types - const flattenedActiveTimerQueries = - util.flatten(this.activeTimers.map((d: KernelInfo) => d.query)) - .filter(d => d != null); - const flattenedActiveTimerNames = - util.flatten(this.activeTimers.map((d: KernelInfo) => d.name)) - .filter(d => d != null); - - this.activeTimers = oldActiveTimers; - - if (outerMostTime) { - this.programTimersStack = null; - } - - const res: WebGLTimingInfo = { - uploadWaitMs: this.uploadWaitMs, - downloadWaitMs: this.downloadWaitMs, - kernelMs: null, - wallMs: null // will be filled by the engine - }; - - return (async () => { - if (env().getNumber('WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE') > - 0) { - const kernelMs = await Promise.all(flattenedActiveTimerQueries); - - res['kernelMs'] = util.sum(kernelMs); - res['getExtraProfileInfo'] = () => - kernelMs - .map((d, i) => ({name: flattenedActiveTimerNames[i], ms: d})) - .map(d => `${d.name}: ${d.ms}`) - .join(', '); - } else { - res['kernelMs'] = { - error: 'WebGL query timers are not supported in this environment.' - }; - } - - this.uploadWaitMs = 0; - this.downloadWaitMs = 0; - return res; - })(); - } - override memory(): WebGLMemoryInfo { - return { - unreliable: false, - numBytesInGPU: this.numBytesInGPU, - numBytesInGPUAllocated: this.textureManager.numBytesAllocated, - numBytesInGPUFree: this.textureManager.numBytesFree - } as WebGLMemoryInfo; - } - - private startTimer(): WebGLQuery|CPUTimerQuery { - if (env().getNumber('WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE') > 0) { - return this.gpgpu.beginQuery(); - } - return {startMs: util.now(), endMs: null}; - } - - private endTimer(query: WebGLQuery|CPUTimerQuery): WebGLQuery|CPUTimerQuery { - if (env().getNumber('WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE') > 0) { - this.gpgpu.endQuery(); - return query; - } - (query as CPUTimerQuery).endMs = util.now(); - return query; - } - - private async getQueryTime(query: WebGLQuery|CPUTimerQuery): Promise { - if (env().getNumber('WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE') > 0) { - return this.gpgpu.waitForQueryAndGetTime(query as WebGLQuery); - } - const timerQuery = query as CPUTimerQuery; - return timerQuery.endMs - timerQuery.startMs; - } - - private pendingDeletes = 0; - - /** - * Decrease the RefCount on the dataId and dispose the memory if the dataId - * has 0 refCount. If there are pending read on the data, the disposal would - * added to the pending delete queue. Return true if the dataId is removed - * from backend or the backend does not contain the dataId, false if the - * dataId is not removed. Memory may or may not be released even when dataId - * is removed, which also depends on dataRefCount, see `releaseGPU`. - * @param dataId - * @oaram force Optional, remove the data regardless of refCount - */ - override disposeData(dataId: DataId, force = false): boolean { - if (this.pendingDisposal.has(dataId)) { - return false; - } - - // No-op if already disposed. - if (!this.texData.has(dataId)) { - return true; - } - - // if force flag is set, change refCount to 0, this would ensure disposal - // when added to the pendingDisposal queue. Memory may or may not be - // released, which also depends on dataRefCount, see `releaseGPU`. - if (force) { - this.texData.get(dataId).refCount = 0; - } else { - this.texData.get(dataId).refCount--; - } - - if (!force && this.texData.get(dataId).refCount > 0) { - return false; - } - - if (this.pendingRead.has(dataId)) { - this.pendingDisposal.add(dataId); - this.pendingDeletes++; - return false; - } - - this.releaseGPUData(dataId); - const {complexTensorInfos} = this.texData.get(dataId); - if (complexTensorInfos != null) { - this.disposeData(complexTensorInfos.real.dataId, force); - this.disposeData(complexTensorInfos.imag.dataId, force); - } - - this.texData.delete(dataId); - - return true; - } - - private releaseGPUData(dataId: DataId): void { - const {texture, dtype, texShape, usage, isPacked, slice} = - this.texData.get(dataId); - const key = slice && slice.origDataId || dataId; - const refCount = this.dataRefCount.get(key); - - if (refCount > 1) { - this.dataRefCount.set(key, refCount - 1); - } else { - this.dataRefCount.delete(key); - if (texture != null) { - this.numBytesInGPU -= this.computeBytes(texShape, dtype); - this.textureManager.releaseTexture(texture, texShape, usage, isPacked); - } - } - - const texData = this.texData.get(dataId); - texData.texture = null; - texData.texShape = null; - texData.isPacked = false; - texData.slice = null; - } - - getTexture(dataId: DataId): WebGLTexture { - this.uploadToGPU(dataId); - return this.texData.get(dataId).texture.texture; - } - - /** - * Returns internal information for the specific data bucket. Used in unit - * tests. - */ - getDataInfo(dataId: DataId): TextureData { - return this.texData.get(dataId); - } - - /* - Tests whether all the inputs to an op are small and on the CPU. This heuristic - determines when it would be faster to execute a kernel on the CPU. WebGL - kernels opt into running this check and forwarding when appropriate. - TODO(https://github.com/tensorflow/tfjs/issues/872): Develop a more - sustainable strategy for optimizing backend execution of ops. - */ - shouldExecuteOnCPU( - inputs: TensorInfo[], - sizeThreshold = CPU_HANDOFF_SIZE_THRESHOLD): boolean { - return env().getBool('WEBGL_CPU_FORWARD') && - inputs.every( - input => this.texData.get(input.dataId).texture == null && - util.sizeFromShape(input.shape) < sizeThreshold); - } - - getGPGPUContext(): GPGPUContext { - return this.gpgpu; - } - - where(condition: Tensor): Tensor2D { - backend_util.warn( - 'tf.where() in webgl locks the UI thread. ' + - 'Call tf.whereAsync() instead'); - const condVals = condition.dataSync(); - return whereImpl(condition.shape, condVals); - } - - private packedUnaryOp(x: TensorInfo, op: string, dtype: DataType) { - const program = new UnaryOpPackedProgram(x.shape, op); - const outInfo = this.compileAndRun(program, [x], dtype); - return engine().makeTensorFromTensorInfo(outInfo); - } - - // TODO(msoulanille) remove this once the backend has been modularized - // a copy is needed here to break a circular dependency. - // Also remove the op from unary_op. - abs(x: T): T { - // TODO: handle cases when x is complex. - if (this.shouldExecuteOnCPU([x]) && x.dtype !== 'complex64') { - const outValues = - simpleAbsImplCPU(this.texData.get(x.dataId).values as TypedArray); - return this.makeOutput(x.shape, x.dtype, outValues); - } - - if (env().getBool('WEBGL_PACK_UNARY_OPERATIONS')) { - return this.packedUnaryOp(x, unary_op.ABS, x.dtype) as T; - } - - const program = new UnaryOpProgram(x.shape, unary_op.ABS); - const outInfo = this.compileAndRun(program, [x]); - return engine().makeTensorFromTensorInfo(outInfo) as T; - } - - makeTensorInfo( - shape: number[], dtype: DataType, - values?: BackendValues|string[]): TensorInfo { - let dataId; - if (dtype === 'string' && values != null && values.length > 0 && - util.isString(values[0])) { - const encodedValues = - (values as unknown as string[]).map(d => util.encodeString(d)); - - dataId = this.write(encodedValues, shape, dtype); - } else { - dataId = this.write(values as TypedArray, shape, dtype); - } - - this.texData.get(dataId).usage = null; - return {dataId, shape, dtype}; - } - - private makeOutput( - shape: number[], dtype: DataType, values?: BackendValues): T { - return engine().makeTensorFromTensorInfo( - this.makeTensorInfo(shape, dtype, values), this) as T; - } - - unpackTensor(input: TensorInfo): TensorInfo { - const program = new UnpackProgram(input.shape); - return this.runWebGLProgram(program, [input], input.dtype); - } - - packTensor(input: TensorInfo): TensorInfo { - const program = new PackProgram(input.shape); - const preventEagerUnpackingOutput = true; - return this.runWebGLProgram( - program, [input], input.dtype, null /* customUniformValues */, - preventEagerUnpackingOutput); - } - - private packedReshape(input: TensorInfo, afterShape: number[]): TensorInfo { - const input3DShape = [ - webgl_util.getBatchDim(input.shape), - ...webgl_util.getRowsCols(input.shape) - ] as [number, number, number]; - const input3D: TensorInfo = { - dtype: input.dtype, - shape: input3DShape, - dataId: input.dataId - }; - const afterShapeAs3D = [ - webgl_util.getBatchDim(afterShape), ...webgl_util.getRowsCols(afterShape) - ] as [number, number, number]; - - const program = new ReshapePackedProgram(afterShapeAs3D, input3DShape); - const preventEagerUnpackingOfOutput = true; - const customValues = [input3DShape]; - const output = this.runWebGLProgram( - program, [input3D], input.dtype, customValues, - preventEagerUnpackingOfOutput); - return {dataId: output.dataId, shape: afterShape, dtype: output.dtype}; - } - - private decode(dataId: DataId, customTexShape?: [number, number]): - TensorInfo { - const texData = this.texData.get(dataId); - const {isPacked, shape, dtype} = texData; - if (customTexShape != null) { - const size = util.sizeFromShape(shape); - const texSize = customTexShape[0] * customTexShape[1] * 4; - util.assert( - size <= texSize, - () => 'customTexShape is too small. ' + - 'Row * Column * 4 should be equal or larger than the ' + - 'size of the tensor data.'); - } - const shapeAs3D = - webgl_util.getShapeAs3D(shape) as [number, number, number]; - let program; - if (isPacked) { - program = new DecodeMatrixPackedProgram(shapeAs3D); - } else { - program = new DecodeMatrixProgram(shapeAs3D); - } - const preventEagerUnpackingOfOutput = true; - const customValues = - [customTexShape != null ? customTexShape : - tex_util.getDenseTexShape(shapeAs3D)]; - const out = this.runWebGLProgram( - program, [{shape: shapeAs3D, dtype, dataId}], dtype, customValues, - preventEagerUnpackingOfOutput, customTexShape); - return {dtype, shape, dataId: out.dataId}; - } - - runWebGLProgram( - program: GPGPUProgram, inputs: TensorInfo[], outputDtype: DataType, - customUniformValues?: number[][], preventEagerUnpackingOfOutput = false, - customTexShape?: [number, number]): TensorInfo { - const output = this.makeTensorInfo(program.outputShape, outputDtype); - const outData = this.texData.get(output.dataId); - if (program.packedOutput) { - outData.isPacked = true; - } - if (program.outPackingScheme === tex_util.PackingScheme.DENSE) { - const texelShape = customTexShape != null ? - customTexShape : - tex_util.getDenseTexShape(program.outputShape); - // For a densely packed output, we explicitly set texShape - // so it doesn't get assigned later according to our typical packing - // scheme wherein a single texel can only contain values from adjacent - // rows/cols. - outData.texShape = texelShape.map(d => d * 2) as [number, number]; - } - if (program.outTexUsage != null) { - outData.usage = program.outTexUsage; - } - - if (util.sizeFromShape(output.shape) === 0) { - // Short-circuit the computation since the result is empty (has 0 in its - // shape). - outData.values = - util.getTypedArrayFromDType(output.dtype as 'float32', 0); - return output; - } - - const dataToDispose: TensorInfo[] = []; - const inputsData: TensorData[] = inputs.map(input => { - if (input.dtype === 'complex64') { - throw new Error( - `GPGPUProgram does not support complex64 input. For complex64 ` + - `dtypes, please separate the program into real and imaginary ` + - `parts.`); - } - - let texData = this.texData.get(input.dataId); - - if (texData.texture == null) { - if (!program.packedInputs && - util.sizeFromShape(input.shape) <= - env().getNumber('WEBGL_SIZE_UPLOAD_UNIFORM')) { - // Upload small tensors that live on the CPU as uniforms, not as - // textures. Do this only when the environment supports 32bit floats - // due to problems when comparing 16bit floats with 32bit floats. - // TODO(https://github.com/tensorflow/tfjs/issues/821): Make it - // possible for packed shaders to sample from uniforms. - return { - shape: input.shape, - texData: null, - isUniform: true, - uniformValues: texData.values as TypedArray - }; - } - - // This ensures that if a packed program's inputs have not yet been - // uploaded to the GPU, they get uploaded as packed right off the bat. - if (program.packedInputs) { - texData.isPacked = true; - texData.shape = input.shape; - } - } - - this.uploadToGPU(input.dataId); - if (!!texData.isPacked !== !!program.packedInputs) { - input = texData.isPacked ? this.unpackTensor(input) : - this.packTensor(input); - dataToDispose.push(input); - texData = this.texData.get(input.dataId); - } else if ( - texData.isPacked && - !webgl_util.isReshapeFree(texData.shape, input.shape)) { - // This is a special case where a texture exists for a tensor - // but the shapes are incompatible (due to packing constraints) because - // the tensor did not have a chance to go through the packed reshape - // shader. This only happens when we reshape the *same* tensor to form - // *distinct* inputs to an op, e.g. dotting a vector with itself. This - // case will disappear once packed uploading is the default. - - const savedInput = input; - const targetShape = input.shape; - - input.shape = texData.shape; - input = this.packedReshape(input as Tensor, targetShape); - dataToDispose.push(input); - texData = this.texData.get(input.dataId); - - savedInput.shape = targetShape; - } - - return {shape: input.shape, texData, isUniform: false}; - }); - - this.uploadToGPU(output.dataId); - const outputData: - TensorData = {shape: output.shape, texData: outData, isUniform: false}; - const key = gpgpu_math.makeShaderKey(program, inputsData, outputData); - const binary = this.getAndSaveBinary(key, () => { - return gpgpu_math.compileProgram( - this.gpgpu, program, inputsData, outputData); - }); - const shouldTimeProgram = this.activeTimers != null; - let query: WebGLQuery|CPUTimerQuery; - if (shouldTimeProgram) { - query = this.startTimer(); - } - - if (!env().get('ENGINE_COMPILE_ONLY')) { - gpgpu_math.runProgram( - this.gpgpu, binary, inputsData, outputData, customUniformValues); - } - - dataToDispose.forEach(info => this.disposeIntermediateTensorInfo(info)); - - if (shouldTimeProgram) { - query = this.endTimer(query); - this.activeTimers.push( - {name: program.constructor.name, query: this.getQueryTime(query)}); - } - - const glFlushThreshold = env().getNumber('WEBGL_FLUSH_THRESHOLD'); - // Manually GL flush requested - if (glFlushThreshold > 0) { - const time = util.now(); - if ((time - this.lastGlFlushTime) > glFlushThreshold) { - this.gpgpu.gl.flush(); - this.lastGlFlushTime = time; - } - } - - if (!env().getBool('WEBGL_LAZILY_UNPACK') && outData.isPacked && - preventEagerUnpackingOfOutput === false) { - const unpacked = this.unpackTensor(output); - this.disposeIntermediateTensorInfo(output); - return unpacked; - } - return output; - } - - compileAndRun( - program: GPGPUProgram, inputs: TensorInfo[], outputDtype?: DataType, - customUniformValues?: number[][], - preventEagerUnpackingOfOutput = false): TensorInfo { - outputDtype = outputDtype || inputs[0].dtype; - const outInfo = this.runWebGLProgram( - program, inputs, outputDtype, customUniformValues, - preventEagerUnpackingOfOutput); - return outInfo; - } - - private getAndSaveBinary(key: string, getBinary: () => GPGPUBinary): - GPGPUBinary { - if (!(key in this.binaryCache)) { - this.binaryCache[key] = getBinary(); - } - return this.binaryCache[key]; - } - - getTextureManager(): TextureManager { - return this.textureManager; - } - - private disposed = false; - - override dispose() { - if (this.disposed) { - return; - } - // Avoid disposing the compiled webgl programs during unit testing because - // it slows down test execution. - if (!env().getBool('IS_TEST')) { - const allKeys = Object.keys(this.binaryCache); - allKeys.forEach(key => { - this.gpgpu.deleteProgram(this.binaryCache[key].webGLProgram); - delete this.binaryCache[key]; - }); - } - this.textureManager.dispose(); - if (this.canvas != null && - (typeof (HTMLCanvasElement) !== 'undefined' && - this.canvas instanceof HTMLCanvasElement)) { - this.canvas.remove(); - } else { - this.canvas = null; - } - if (this.gpgpuCreatedLocally) { - this.gpgpu.program = null; - this.gpgpu.dispose(); - } - this.disposed = true; - } - - override floatPrecision(): 16|32 { - if (this.floatPrecisionValue == null) { - this.floatPrecisionValue = tidy(() => { - if (!env().get('WEBGL_RENDER_FLOAT32_ENABLED')) { - // Momentarily switching DEBUG flag to false so we don't throw an - // error trying to upload a small value. - const debugFlag = env().getBool('DEBUG'); - env().set('DEBUG', false); - const underflowCheckValue = this.abs(scalar(1e-8)).dataSync()[0]; - env().set('DEBUG', debugFlag); - - if (underflowCheckValue > 0) { - return 32; - } - } - return 16; - }); - } - return this.floatPrecisionValue; - } - - /** Returns the smallest representable number. */ - override epsilon(): number { - return this.floatPrecision() === 32 ? EPSILON_FLOAT32 : EPSILON_FLOAT16; - } - - uploadToGPU(dataId: DataId): void { - const texData = this.texData.get(dataId); - const {shape, dtype, values, texture, usage, isPacked} = texData; - - if (texture != null) { - // Array is already on GPU. No-op. - return; - } - const shouldTimeProgram = this.activeTimers != null; - let start: number; - if (shouldTimeProgram) { - start = util.now(); - } - - let texShape = texData.texShape; - if (texShape == null) { - // This texShape may not be the final texture shape. For packed or dense - // textures, the texShape will be changed when textures are created. - texShape = webgl_util.getTextureShapeFromLogicalShape(shape, isPacked); - texData.texShape = texShape; - } - - if (values != null) { - const shapeAs3D = webgl_util.getShapeAs3D(shape); - - let program; - let width = texShape[1], height = texShape[0]; - const isByteArray = - values instanceof Uint8Array || values instanceof Uint8ClampedArray; - - // texture for float array is PhysicalTextureType.PACKED_2X2_FLOAT32, we - // need to make sure the upload uses the same packed size - if (isPacked || !isByteArray) { - [width, height] = tex_util.getPackedMatrixTextureShapeWidthHeight( - texShape[0], texShape[1]); - } - - if (isPacked) { - program = new EncodeMatrixPackedProgram(shapeAs3D, isByteArray); - } else { - program = new EncodeMatrixProgram(shapeAs3D, isByteArray); - } - - // TexShape for float array needs to be the original shape, which byte - // array needs to be packed size. This allow the data upload shape to be - // matched with texture creation logic. - const tempDenseInputTexShape: [number, number] = - isByteArray ? [height, width] : texShape; - const tempDenseInputHandle = - this.makeTensorInfo(tempDenseInputTexShape, dtype); - const tempDenseInputTexData = - this.texData.get(tempDenseInputHandle.dataId); - if (isByteArray) { - tempDenseInputTexData.usage = TextureUsage.PIXELS; - } else { - tempDenseInputTexData.usage = TextureUsage.UPLOAD; - } - tempDenseInputTexData.texShape = tempDenseInputTexShape; - this.gpgpu.uploadDenseMatrixToTexture( - this.getTexture(tempDenseInputHandle.dataId), width, height, - values as TypedArray); - - const customValues = [[height, width]]; - // We want the output to remain packed regardless of the value of - // WEBGL_PACK. - const preventEagerUnpacking = true; - const encodedOutputTarget = this.runWebGLProgram( - program, [tempDenseInputHandle], dtype, customValues, - preventEagerUnpacking); - - // Have the original texture assume the identity of the encoded output. - const outputTexData = this.texData.get(encodedOutputTarget.dataId); - texData.texShape = outputTexData.texShape; - texData.isPacked = outputTexData.isPacked; - texData.usage = outputTexData.usage; - - if (!env().get('ENGINE_COMPILE_ONLY')) { - texData.texture = outputTexData.texture; - // Once uploaded, don't store the values on cpu. - texData.values = null; - this.texData.delete(encodedOutputTarget.dataId); - } else { - this.disposeData(encodedOutputTarget.dataId); - } - - this.disposeIntermediateTensorInfo(tempDenseInputHandle); - - if (shouldTimeProgram) { - this.uploadWaitMs += util.now() - start; - } - } else { - const newTexture = this.acquireTexture(texShape, usage, dtype, isPacked); - texData.texture = newTexture; - } - } - - private convertAndCacheOnCPU(dataId: DataId, float32Values?: Float32Array): - TypedArray { - const texData = this.texData.get(dataId); - const {dtype} = texData; - - if (float32Values != null) { - texData.values = float32ToTypedArray(float32Values, dtype as 'float32'); - } - return texData.values as TypedArray; - } - - private acquireTexture( - texShape: [number, number], texType: TextureUsage, dtype: DataType, - isPacked: boolean): Texture { - this.numBytesInGPU += this.computeBytes(texShape, dtype); - if (!this.warnedAboutMemory && - this.numBytesInGPU > this.numMBBeforeWarning * 1024 * 1024) { - const mb = (this.numBytesInGPU / 1024 / 1024).toFixed(2); - this.warnedAboutMemory = true; - console.warn( - `High memory usage in GPU: ${mb} MB, ` + - `most likely due to a memory leak`); - } - return this.textureManager.acquireTexture(texShape, texType, isPacked); - } - - private computeBytes(shape: [number, number], dtype: DataType) { - return shape[0] * shape[1] * util.bytesPerElement(dtype); - } - - checkCompileCompletion() { - for (const [, binary] of Object.entries(this.binaryCache)) { - this.checkCompletion_(binary); - } - } - - async checkCompileCompletionAsync(): Promise { - const ps = []; - if (this.gpgpu.parallelCompilationExtension) { - for (const [, binary] of Object.entries(this.binaryCache)) { - ps.push(this.checkCompletionAsync_(binary)); - } - return Promise.all(ps); - } else { - for (const [, binary] of Object.entries(this.binaryCache)) { - const p: Promise = new Promise((resolve) => { - try { - this.checkCompletion_(binary); - resolve(true); - } catch (error) { - throw error; - } - }); - ps.push(p); - } - return Promise.all(ps); - } - } - - private async checkCompletionAsync_(binary: GPGPUBinary): Promise { - if (this.gpgpu.gl.getProgramParameter( - binary.webGLProgram, - this.gpgpu.parallelCompilationExtension.COMPLETION_STATUS_KHR)) { - return this.checkCompletion_(binary); - } else { - await nextFrame(); - return this.checkCompletionAsync_(binary); - } - } - - private checkCompletion_(binary: GPGPUBinary): boolean { - if (this.gpgpu.gl.getProgramParameter( - binary.webGLProgram, this.gpgpu.gl.LINK_STATUS) === false) { - console.log(this.gpgpu.gl.getProgramInfoLog(binary.webGLProgram)); - if (this.gpgpu.gl.getShaderParameter( - binary.fragmentShader, this.gpgpu.gl.COMPILE_STATUS) === false) { - webgl_util.logShaderSourceAndInfoLog( - binary.source, - this.gpgpu.gl.getShaderInfoLog(binary.fragmentShader)); - throw new Error('Failed to compile fragment shader.'); - } - throw new Error('Failed to link vertex and fragment shaders.'); - } - return true; - } - - getUniformLocations() { - for (const binary of Object.values(this.binaryCache)) { - // TODO: Iterating through all binaries to build VAOs is supposed to be in - // a seperate function, like 'setVaos'. However, to avoid breaking changes - // for the users using parallel compile feature now, buildVao is silently - // added here. - this.gpgpu.buildVao(binary.webGLProgram); - - const { - variablesLocations, - customUniformLocations, - infLoc, - nanLoc, - outShapeLocation, - outShapeStridesLocation, - outTexShapeLocation - } = getUniformLocations(this.gpgpu, binary.program, binary.webGLProgram); - binary.variablesLocations = variablesLocations; - binary.customUniformLocations = customUniformLocations; - binary.infLoc = infLoc; - binary.nanLoc = nanLoc; - binary.outShapeLocation = outShapeLocation; - binary.outShapeStridesLocation = outShapeStridesLocation; - binary.outTexShapeLocation = outTexShapeLocation; - } - } - - /** - * Create a TF.js tensor out of an existing WebGL texture. A new texture will - * be created. - */ - override createTensorFromGPUData( - values: WebGLData, shape: number[], dtype: DataType): Tensor { - values.channels = values.channels || 'RGBA'; - const {texture, height, width, channels} = values; - const backend = engine().backend as MathBackendWebGL; - - // Have to throw an error, otherwise WebGL just warns and returns wrong - // values. - if (!backend.gpgpu.gl.isTexture(texture)) { - throw new Error( - `The texture is invalid. Also, please make sure the texture and ` + - `the TFJS WebGL backend are using the same canvas. If you want to ` + - `use your own custom canvas, you have to create and use the custom ` + - `TFJS WebGL backend created from the canvas through ` + - `'new tf.MathBackendWebGL(customCanvas)'.`); - } - - const dataId = - backend.writeTexture(texture, shape, dtype, height, width, channels); - return engine().makeTensorFromDataId(dataId, shape, dtype, backend); - } -} - -function float32ToTypedArray( - a: Float32Array, dtype: D): tf.DataTypeMap[D] { - if (dtype === 'float32' || dtype === 'complex64') { - return a as tf.DataTypeMap[D]; - } else if (dtype === 'int32' || dtype === 'bool') { - const result = (dtype === 'int32') ? new Int32Array(a.length) : - new Uint8Array(a.length); - for (let i = 0; i < result.length; ++i) { - result[i] = Math.round(a[i]); - } - return result as tf.DataTypeMap[D]; - } else { - throw new Error(`Unknown dtype ${dtype}`); - } -} diff --git a/tfjs-master/tfjs-backend-webgl/src/backend_webgl_test.ts b/tfjs-master/tfjs-backend-webgl/src/backend_webgl_test.ts deleted file mode 100644 index 4587f40e5..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/backend_webgl_test.ts +++ /dev/null @@ -1,1529 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '@tensorflow/tfjs-core'; -import {engine, GPUData, test_util, util} from '@tensorflow/tfjs-core'; -// tslint:disable-next-line: no-imports-from-dist -import {describeWithFlags} from '@tensorflow/tfjs-core/dist/jasmine_util'; - -const {expectArraysClose, expectArraysEqual} = test_util; -const {decodeString} = util; - -import {getBinaryCache, MathBackendWebGL, WebGLMemoryInfo, WebGLTimingInfo} from './backend_webgl'; -import {computeBytes} from './texture_manager'; -import {PhysicalTextureType} from './tex_util'; -import {WEBGL_ENVS} from './backend_webgl_test_registry'; -import {GPGPUContext} from './gpgpu_context'; - -function decodeStrings(bytes: Uint8Array[]): string[] { - return bytes.map(b => decodeString(b)); -} - -const RENDER_FLOAT32_ENVS = { - flags: {'WEBGL_RENDER_FLOAT32_ENABLED': true}, - predicate: WEBGL_ENVS.predicate -}; - -describeWithFlags('forced f16 render', RENDER_FLOAT32_ENVS, () => { - beforeEach(() => { - tf.env().set('WEBGL_RENDER_FLOAT32_ENABLED', false); - }); - afterAll(() => tf.env().reset()); - - it('should overflow if larger than 66k', async () => { - const a = tf.tensor1d([Math.pow(2, 17)], 'float32'); - const b = tf.relu(a); - const data = await b.data(); - if (data && data.length === 1 && !isNaN(data[0])) { // value could be NaN - expect(data).toBeLessThan(Math.pow(2, 17)); - } - }); - - it('should error in debug mode', () => { - // Silence debug warnings. - spyOn(console, 'warn'); - - const debug = tf.env().get('DEBUG'); - tf.env().set('DEBUG', true); - const a = () => tf.tensor1d([2, Math.pow(2, 17)], 'float32'); - expect(a).toThrowError(); - tf.env().set('DEBUG', debug); - }); -}); - -describeWithFlags('lazy packing and unpacking', WEBGL_ENVS, () => { - let webglLazilyUnpackFlagSaved: boolean; - let webglCpuForwardFlagSaved: boolean; - - beforeAll(() => { - webglLazilyUnpackFlagSaved = tf.env().getBool('WEBGL_LAZILY_UNPACK'); - webglCpuForwardFlagSaved = tf.env().getBool('WEBGL_CPU_FORWARD'); - tf.env().set('WEBGL_LAZILY_UNPACK', true); - tf.env().set('WEBGL_CPU_FORWARD', false); - }); - - afterAll(() => { - tf.env().set('WEBGL_LAZILY_UNPACK', webglLazilyUnpackFlagSaved); - tf.env().set('WEBGL_CPU_FORWARD', webglCpuForwardFlagSaved); - }); - - it('should not leak memory when lazily unpacking', () => { - const a = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - const b = tf.tensor2d([0, 1, -3, 2, 2, 1], [3, 2]); - - // c is packed to 1x1 RGBA texture. - const c = tf.matMul(a, b); - - const startNumBytes = tf.memory().numBytes; - const startNumTensors = tf.memory().numTensors; - const startNumBytesInGPU = (tf.memory() as WebGLMemoryInfo).numBytesInGPU; - - const webglPackBinaryOperationsFlagSaved = - tf.env().getBool('WEBGL_PACK_BINARY_OPERATIONS'); - tf.env().set('WEBGL_PACK_BINARY_OPERATIONS', false); - // Add will unpack c before the operation to 2 - tf.add(c, 1); - tf.env().set( - 'WEBGL_PACK_BINARY_OPERATIONS', webglPackBinaryOperationsFlagSaved); - - expect(tf.memory().numBytes - startNumBytes).toEqual(16); - expect(tf.memory().numTensors - startNumTensors).toEqual(1); - // result is unpacked 2x2 R texture. - expect((tf.memory() as WebGLMemoryInfo).numBytesInGPU - startNumBytesInGPU) - .toEqual(4 * tf.util.bytesPerElement(a.dtype)); - }); - - it('should not leak memory when lazily packing', () => { - const a = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - const b = tf.tensor2d([0, 1, -3, 2, 2, 1], [3, 2]); - - const c = tf.add(a, 1); - - const startNumBytes = tf.memory().numBytes; - const startNumTensors = tf.memory().numTensors; - const startNumBytesInGPU = (tf.memory() as WebGLMemoryInfo).numBytesInGPU; - - tf.matMul(b, c); - - expect(tf.memory().numBytes - startNumBytes).toEqual(36); - expect(tf.memory().numTensors - startNumTensors).toEqual(1); - // result [3, 3] is packed to four RGBA pixel texture b is packed to two - // RGBA texels texture: total 6 * 4 = 24 components. - expect((tf.memory() as WebGLMemoryInfo).numBytesInGPU - startNumBytesInGPU) - .toEqual(24 * tf.util.bytesPerElement(a.dtype)); - }); - - it('should work when the same input must be represented by' + - 'different textures', - async () => { - const a = tf.tensor1d([1, 2]); - const res = tf.dot(a, a); - expectArraysClose(await res.data(), [5]); - }); -}); - -describeWithFlags('backendWebGL', WEBGL_ENVS, () => { - let prevBackend: string; - - beforeAll(() => { - prevBackend = tf.getBackend(); - }); - - afterEach(() => { - tf.setBackend(prevBackend); - tf.removeBackend('test-storage'); - }); - - it('register string tensor with values', () => { - const backend = new MathBackendWebGL(); - tf.registerBackend('test-storage', () => backend); - tf.setBackend('test-storage'); - - const t = engine().makeTensor(['a', 'b', 'c'], [3], 'string'); - expectArraysEqual( - decodeStrings(backend.readSync(t.dataId) as Uint8Array[]), - ['a', 'b', 'c']); - }); - - it('register string tensor with values and wrong shape throws error', () => { - const backend = new MathBackendWebGL(); - tf.registerBackend('test-storage', () => backend); - tf.setBackend('test-storage'); - expect(() => tf.tensor(['a', 'b', 'c'], [4], 'string')).toThrowError(); - }); - - it('reading', () => { - const backend = new MathBackendWebGL(null); - tf.registerBackend('test-storage', () => backend); - tf.setBackend('test-storage'); - - const texManager = backend.getTextureManager(); - const t = engine().makeTensor(new Float32Array([1, 2, 3]), [3], 'float32'); - expect(texManager.getNumUsedTextures()).toBe(0); - backend.getTexture(t.dataId); - expect(texManager.getNumUsedTextures()).toBe(1); - expectArraysClose( - backend.readSync(t.dataId) as Float32Array, - new Float32Array([1, 2, 3])); - expect(texManager.getNumUsedTextures()).toBe(1); - backend.getTexture(t.dataId); - expect(texManager.getNumUsedTextures()).toBe(1); - backend.disposeData(t.dataId); - expect(texManager.getNumUsedTextures()).toBe(0); - }); - - it('read packed and then use by an unpacked op', async () => { - const backend = new MathBackendWebGL(null); - tf.registerBackend('test-storage', () => backend); - tf.copyRegisteredKernels('webgl', 'test-storage'); - tf.setBackend('test-storage'); - - const webglPackFlagSaved = tf.env().getBool('WEBGL_PACK'); - tf.env().set('WEBGL_PACK', true); - const webglSizeUploadUniformSaved = - tf.env().getNumber('WEBGL_SIZE_UPLOAD_UNIFORM'); - tf.env().set('WEBGL_SIZE_UPLOAD_UNIFORM', 0); - const a = tf.tensor2d([1, 2], [2, 1]); - const b = tf.tensor2d([1], [1, 1]); - const c = tf.matMul(a, b); - backend.readSync(c.dataId); - tf.env().set('WEBGL_PACK', false); - const d = tf.add(c, 1); - tf.env().set('WEBGL_PACK', webglPackFlagSaved); - tf.env().set('WEBGL_SIZE_UPLOAD_UNIFORM', webglSizeUploadUniformSaved); - expectArraysClose(await d.data(), [2, 3]); - }); - - it('delayed storage, overwriting', () => { - const backend = new MathBackendWebGL(null); - tf.registerBackend('test-storage', () => backend); - tf.setBackend('test-storage'); - - const texManager = backend.getTextureManager(); - const t = engine().makeTensor(new Float32Array([1, 2, 3]), [3], 'float32'); - backend.getTexture(t.dataId); - expect(texManager.getNumUsedTextures()).toBe(1); - expectArraysClose( - backend.readSync(t.dataId) as Float32Array, - new Float32Array([1, 2, 3])); - backend.getTexture(t.dataId); - expect(texManager.getNumUsedTextures()).toBe(1); - expectArraysClose( - backend.readSync(t.dataId) as Float32Array, - new Float32Array([1, 2, 3])); - expect(texManager.getNumUsedTextures()).toBe(1); - }); -}); - -describeWithFlags('Webgl backend disposal', WEBGL_ENVS, () => { - it('register and dispose a backend outside unit test', () => { - // Simulate outside unit test environment. - tf.ENV.set('IS_TEST', false); - - const backend = new MathBackendWebGL(); - tf.registerBackend('test-disposal', () => backend); - tf.copyRegisteredKernels('webgl', 'test-disposal'); - tf.setBackend('test-disposal'); - // Compile and run a program. - tf.zeros([1000]).sqrt().dataSync(); - - // Dispose the backend. - tf.backend().dispose(); - - // Make sure the cache is empty. - const cache = getBinaryCache(tf.ENV.getNumber('WEBGL_VERSION')); - expect(Object.keys(cache).length).toBe(0); - tf.removeBackend('test-disposal'); - }); - - it('register and dispose a backend inside unit test', () => { - // Simulate inside unit test environment. - tf.ENV.set('IS_TEST', true); - - const backend = new MathBackendWebGL(); - tf.registerBackend('test-disposal', () => backend); - tf.copyRegisteredKernels('webgl', 'test-disposal'); - tf.setBackend('test-disposal'); - // Compile and run a program. - tf.zeros([1000]).sqrt().dataSync(); - - // Dispose the backend. - tf.backend().dispose(); - - // Make sure the cache is NOT empty. - const cache = getBinaryCache(tf.ENV.getNumber('WEBGL_VERSION')); - expect(Object.keys(cache).length).toBeGreaterThan(0); - tf.removeBackend('test-disposal'); - }); - - it('register, dispose and re-register a backend outside unit test', () => { - // Simulate outside unit test environment. - tf.ENV.set('IS_TEST', false); - - tf.registerBackend('test-disposal', () => new MathBackendWebGL()); - tf.copyRegisteredKernels('webgl', 'test-disposal'); - tf.setBackend('test-disposal'); - // Compile and run a program. - tf.zeros([1000]).sqrt().dataSync(); - - // Dispose the backend. - tf.backend().dispose(); - tf.removeBackend('test-disposal'); - - // Re-register a backend. - tf.registerBackend('test-disposal', () => new MathBackendWebGL()); - tf.copyRegisteredKernels('webgl', 'test-disposal'); - tf.setBackend('test-disposal'); - // Compile and run a program. - tf.zeros([1000]).sqrt().dataSync(); - - // Dispose the 2nd backend. - tf.backend().dispose(); - - // Make sure the cache is empty. - const cache = getBinaryCache(tf.ENV.getNumber('WEBGL_VERSION')); - expect(Object.keys(cache).length).toBe(0); - tf.removeBackend('test-disposal'); - }); -}); - -describeWithFlags('Custom window size', WEBGL_ENVS, () => { - const customBackendName = 'custom-webgl'; - - beforeAll(() => { - const kernelFunc = tf.getKernel('Square', 'webgl').kernelFunc; - tf.registerKernel( - {kernelName: 'Square', backendName: customBackendName, kernelFunc}); - }); - - afterAll(() => { - tf.unregisterKernel('Square', customBackendName); - }); - - it('Set screen area to be 1x1', () => { - // This will set the screen size to 1x1 to make sure the page limit is - // very small. - spyOnProperty(window, 'screen', 'get') - .and.returnValue({height: 1, width: 1} as unknown as Screen); - - tf.registerBackend(customBackendName, () => new MathBackendWebGL()); - tf.setBackend(customBackendName); - - // Allocate ~40KB. - const a = tf.ones([100, 100]); - // No gpu memory used yet because of delayed storage. - expect((tf.memory() as WebGLMemoryInfo).numBytesInGPU).toBe(0); - - // Expect console.warn() to be called. - let numWarnCalls = 0; - spyOn(console, 'warn').and.callFake(() => { - numWarnCalls++; - }); - - a.square(); - expect(numWarnCalls).toBe(1); - expect((tf.memory() as WebGLMemoryInfo).numBytesInGPU) - .toBe(100 * 100 * 4 * 2); - - // Allocate another 40KB. - a.square(); - - // Expect console.warn() to NOT be called more than once. - expect(numWarnCalls).toBe(1); - expect((tf.memory() as WebGLMemoryInfo).numBytesInGPU) - .toBe(100 * 100 * 4 * 3); - tf.removeBackend(customBackendName); - }); -}); - -const SIZE_UPLOAD_UNIFORM = 4; -// Run only for environments that have 32bit floating point support. -const FLOAT32_WEBGL_ENVS = { - flags: {'WEBGL_RENDER_FLOAT32_ENABLED': true}, - predicate: WEBGL_ENVS.predicate -}; - -describeWithFlags('upload tensors as uniforms', FLOAT32_WEBGL_ENVS, () => { - let savedUploadUniformValue: number; - - beforeAll(() => { - savedUploadUniformValue = - tf.env().get('WEBGL_SIZE_UPLOAD_UNIFORM') as number; - tf.env().set('WEBGL_SIZE_UPLOAD_UNIFORM', SIZE_UPLOAD_UNIFORM); - }); - - afterAll(() => { - tf.env().set('WEBGL_SIZE_UPLOAD_UNIFORM', savedUploadUniformValue); - }); - - it('small tensor gets uploaded as scalar', () => { - let m = tf.memory() as WebGLMemoryInfo; - expect(m.numBytesInGPU).toBe(0); - - const a = tf.zeros([SIZE_UPLOAD_UNIFORM - 1]); - a.square(); - - // Only the result lives on the gpu, the input is gone. - m = tf.memory() as WebGLMemoryInfo; - expect(m.numBytesInGPU).toBe(a.size * 4); - }); - - it('large tensor gets uploaded to gpu', () => { - let m = tf.memory() as WebGLMemoryInfo; - expect(m.numBytesInGPU).toBe(0); - - const a = tf.zeros([SIZE_UPLOAD_UNIFORM + 1]); - a.square(); - - // Both the result and the input live on the gpu. - m = tf.memory() as WebGLMemoryInfo; - expect(m.numBytesInGPU).toBe(a.size * 4 * 2); - }); - - it('download and re-upload an output of a shader', async () => { - const vals = new Float32Array(SIZE_UPLOAD_UNIFORM + 1); - vals.fill(2); - const a = tf.square(vals); - a.dataSync(); // Download to CPU. - const res = a.square(); // Re-upload to GPU. - - const expected = new Float32Array(SIZE_UPLOAD_UNIFORM + 1); - expected.fill(16); - expectArraysClose(await res.data(), expected); - }); -}); - -describeWithFlags('indexing for large tensors', FLOAT32_WEBGL_ENVS, () => { - it('properly indexes large tensors', async () => { - const range = 3000 * 3000; - const aData = new Float32Array(range); - for (let i = 0; i < range; i++) { - aData[i] = i / range; - } - - const a = tf.tensor1d(aData); - const aRelu = a.relu(); - - expectArraysClose(await a.data(), aData); - expectArraysClose(await aRelu.data(), aData); - }); -}); - -describeWithFlags('debug on webgl', WEBGL_ENVS, () => { - beforeAll(() => { - // Silences debug warnings. - spyOn(console, 'warn'); - tf.enableDebugMode(); - }); - - it('debug mode errors when overflow in tensor construction', () => { - const savedRenderFloat32Flag = - tf.env().getBool('WEBGL_RENDER_FLOAT32_ENABLED'); - tf.env().set('WEBGL_RENDER_FLOAT32_ENABLED', false); - const a = () => tf.tensor1d([2, Math.pow(2, 17)], 'float32'); - expect(a).toThrowError(); - tf.env().set('WEBGL_RENDER_FLOAT32_ENABLED', savedRenderFloat32Flag); - }); - - it('debug mode errors when underflow in tensor construction', () => { - const savedRenderFloat32Flag = - tf.env().getBool('WEBGL_RENDER_FLOAT32_ENABLED'); - tf.env().set('WEBGL_RENDER_FLOAT32_ENABLED', false); - const a = () => tf.tensor1d([2, 1e-8], 'float32'); - expect(a).toThrowError(); - tf.env().set('WEBGL_RENDER_FLOAT32_ENABLED', savedRenderFloat32Flag); - }); -}); - -const WEBGL1_ENVS = { - flags: {'WEBGL_VERSION': 1}, - predicate: WEBGL_ENVS.predicate -}; - -const WEBGL2_ENVS = { - flags: {'WEBGL_VERSION': 2}, - predicate: WEBGL_ENVS.predicate -}; - -describeWithFlags('computeBytes counts bytes correctly', WEBGL1_ENVS, () => { - it('for all physical texture types', () => { - const gpgpu = new GPGPUContext(); - - const shapeRC: [number, number] = [2, 3]; - - let bytesForTex = computeBytes( - shapeRC, PhysicalTextureType.UNPACKED_FLOAT16, gpgpu.gl, - gpgpu.textureConfig, false /* isPacked */); - expect(bytesForTex).toBe(96); - - bytesForTex = computeBytes( - shapeRC, PhysicalTextureType.UNPACKED_FLOAT32, gpgpu.gl, - gpgpu.textureConfig, false /* isPacked */); - expect(bytesForTex).toBe(96); - - bytesForTex = computeBytes( - shapeRC, PhysicalTextureType.PACKED_4X1_UNSIGNED_BYTE, gpgpu.gl, - gpgpu.textureConfig, true /* isPacked */); - expect(bytesForTex).toBe(32); - - bytesForTex = computeBytes( - shapeRC, PhysicalTextureType.PACKED_2X2_FLOAT32, gpgpu.gl, - gpgpu.textureConfig, true /* isPacked */); - expect(bytesForTex).toBe(32); - - bytesForTex = computeBytes( - shapeRC, PhysicalTextureType.PACKED_2X2_FLOAT16, gpgpu.gl, - gpgpu.textureConfig, true /* isPacked */); - expect(bytesForTex).toBe(32); - - gpgpu.dispose(); - }); -}); - -describeWithFlags('computeBytes counts bytes correctly', WEBGL2_ENVS, () => { - it('test every physical tex type input to computeBytes', () => { - const gpgpu = new GPGPUContext(); - - const shapeRC: [number, number] = [2, 3]; - - let bytesForTex = computeBytes( - shapeRC, PhysicalTextureType.UNPACKED_FLOAT16, gpgpu.gl, - gpgpu.textureConfig, false /* isPacked */); - expect(bytesForTex).toBe(12); - - bytesForTex = computeBytes( - shapeRC, PhysicalTextureType.UNPACKED_FLOAT32, gpgpu.gl, - gpgpu.textureConfig, false /* isPacked */); - expect(bytesForTex).toBe(24); - - bytesForTex = computeBytes( - shapeRC, PhysicalTextureType.PACKED_4X1_UNSIGNED_BYTE, gpgpu.gl, - gpgpu.textureConfig, true /* isPacked */); - expect(bytesForTex).toBe(8); - - bytesForTex = computeBytes( - shapeRC, PhysicalTextureType.PACKED_2X2_FLOAT32, gpgpu.gl, - gpgpu.textureConfig, true /* isPacked */); - expect(bytesForTex).toBe(32); - - bytesForTex = computeBytes( - shapeRC, PhysicalTextureType.PACKED_2X2_FLOAT16, gpgpu.gl, - gpgpu.textureConfig, true /* isPacked */); - expect(bytesForTex).toBe(16); - - gpgpu.dispose(); - }); -}); - -describeWithFlags('aggressive texture deletion', WEBGL_ENVS, () => { - it('basic', () => { - const savedDeleteThreshold = - tf.env().get('WEBGL_DELETE_TEXTURE_THRESHOLD') as number; - tf.env().set('WEBGL_DELETE_TEXTURE_THRESHOLD', 0); - - const a = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - const b = tf.tensor2d([0, 1, -3, 2, 2, 1], [3, 2]); - - tf.matMul(a, b); - - const startNumBytesAllocated = - (tf.memory() as WebGLMemoryInfo).numBytesInGPUAllocated; - - a.dispose(); - b.dispose(); - - expect( - startNumBytesAllocated - - (tf.memory() as WebGLMemoryInfo).numBytesInGPUAllocated) - .toBeGreaterThan(0); - - tf.env().set('WEBGL_DELETE_TEXTURE_THRESHOLD', savedDeleteThreshold); - }); -}); - -describeWithFlags('memory webgl', WEBGL_ENVS, () => { - it('unreliable is falsy/not present when all tensors are numeric', () => { - tf.tensor(1); - const mem = tf.memory(); - expect(mem.numTensors).toBe(1); - expect(mem.numDataBuffers).toBe(1); - expect(mem.numBytes).toBe(4); - expect(mem.unreliable).toBeFalsy(); - }); -}); - -describeWithFlags('manual gl flush', WEBGL_ENVS, () => { - it('works when manual gl flush is enabled', async () => { - const savedGlThreshold = tf.env().get('WEBGL_FLUSH_THRESHOLD') as number; - tf.env().set('WEBGL_FLUSH_THRESHOLD', 1); - const a = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - const b = tf.tensor2d([1, 1, -3, 2, 2, 1], [2, 3]); - - const result = tf.div(tf.div(tf.mul(a, b), a), b); - expectArraysClose(await result.data(), [1, 1, 1, 1, 1, 1]); - tf.env().set('WEBGL_FLUSH_THRESHOLD', savedGlThreshold); - }); -}); -// We do not yet fully support half float backends. These tests are a starting -// point. -describeWithFlags('backend without render float32 support', WEBGL_ENVS, () => { - const savedRenderFloat32Flag = - tf.env().getBool('WEBGL_RENDER_FLOAT32_ENABLED'); - const customWebGLBackendName = 'half-float-webgl'; - - beforeAll(() => { - tf.env().set('WEBGL_RENDER_FLOAT32_ENABLED', false); - }); - - beforeEach(() => { - tf.copyRegisteredKernels('webgl', customWebGLBackendName); - tf.registerBackend( - customWebGLBackendName, () => new MathBackendWebGL(null)); - }); - - afterEach(() => { - tf.removeBackend(customWebGLBackendName); - }); - - afterAll(() => { - tf.env().set('WEBGL_RENDER_FLOAT32_ENABLED', savedRenderFloat32Flag); - }); - - it('basic usage', async () => { - tf.setBackend(customWebGLBackendName); - - const a = tf.tensor2d([1, 2], [1, 2]); - const b = tf.tensor2d([1, 2], [1, 2]); - const c = tf.add(a, b); - expectArraysClose(await c.data(), [2, 4]); - }); - - it('disposing tensors should not cause errors', () => { - tf.setBackend(customWebGLBackendName); - expect(() => tf.tidy(() => { - const a = tf.tensor2d([1, 2], [1, 2]); - const b = tf.tensor2d([1, 2], [1, 2]); - const c = tf.add(a, b); - c.dataSync(); - return c.add(tf.tensor2d([2, 4], [1, 2])); - })).not.toThrowError(); - }); -}); - -if (tf.env().getBool('WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE')) { - describeWithFlags('time webgl', WEBGL2_ENVS, () => { - it('upload + compute', async () => { - const a = tf.zeros([10, 10]); - const time = await tf.time(() => a.square()) as WebGLTimingInfo; - expect(time.uploadWaitMs > 0); - expect(time.downloadWaitMs === 0); - expect(time.kernelMs).toBeGreaterThan(0); - expect(time.kernelMs).toBeLessThanOrEqual(time.wallMs); - }); - - it('upload + compute + dataSync', async () => { - const a = tf.zeros([10, 10]); - const time = await tf.time(() => a.square() - .dataSync()) as WebGLTimingInfo; - expect(time.uploadWaitMs > 0); - expect(time.downloadWaitMs > 0); - expect(time.kernelMs).toBeGreaterThan(0); - expect(time.kernelMs).toBeLessThanOrEqual(time.wallMs); - }); - - it('upload + compute + data', async () => { - const a = tf.zeros([10, 10]); - const time = - await tf.time(async () => a.square().data()) as WebGLTimingInfo; - expect(time.uploadWaitMs > 0); - expect(time.downloadWaitMs > 0); - expect(time.kernelMs).toBeGreaterThan(0); - expect(time.kernelMs).toBeLessThanOrEqual(time.wallMs); - }); - - it('preupload (not included) + compute + data', async () => { - const a = tf.zeros([10, 10]); - // Pre-upload a on gpu. - a.square(); - const time = await tf.time(() => a.sqrt()) as WebGLTimingInfo; - // The tensor was already on gpu. - expect(time.uploadWaitMs === 0); - expect(time.downloadWaitMs === 0); - expect(time.kernelMs).toBeGreaterThan(0); - expect(time.kernelMs).toBeLessThanOrEqual(time.wallMs); - }); - - it('returns error for kernelMs if query timer extension is unavailable', - async () => { - const savedQueryReliableValue = - tf.env().get('WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE'); - tf.env().set('WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE', false); - - const a = tf.zeros([10, 10]); - const time = await tf.backend().time(() => a.sqrt()) as WebGLTimingInfo; - expect(time.kernelMs).toEqual({ - error: 'WebGL query timers are not supported in this environment.' - }); - - tf.env().set( - 'WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE', - savedQueryReliableValue); - }); - }); -} - -describeWithFlags('keeping data on gpu ', WEBGL2_ENVS, () => { - let flag: boolean; - - beforeAll(() => { - flag = tf.env().getBool('WEBGL_CPU_FORWARD'); - tf.env().set('WEBGL_CPU_FORWARD', false); - }); - - afterAll(() => { - tf.env().set('WEBGL_CPU_FORWARD', flag); - }); - - it('has a valid texture for dtype=float32.', () => { - const data = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]; - const texShape = [2, 2]; - const a = tf.tensor(data, [1, 3, 4]); - const b = tf.add(a, 0); - const res = b.dataToGPU(); - expectArraysEqual(res.texShape, texShape); - - const webGLBackend = tf.backend() as MathBackendWebGL; - const buffer = webGLBackend.gpgpu.createBufferFromTexture( - res.texture, res.texShape[0], res.texShape[1]); - const vals = webGLBackend.gpgpu.downloadFloat32MatrixFromBuffer(buffer, 12); - expectArraysEqual(vals, data); - }); - - it('uses user defined texShape.', () => { - const data = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]; - const a = tf.tensor(data, [1, 3, 4]); - const b = tf.add(a, 0); - const texShape = [1, 3] as [number, number]; - const res = b.dataToGPU({customTexShape: texShape}); - expectArraysEqual(res.texShape, texShape); - - const webGLBackend = tf.backend() as MathBackendWebGL; - const buffer = webGLBackend.gpgpu.createBufferFromTexture( - res.texture, res.texShape[0], res.texShape[1]); - const vals = webGLBackend.gpgpu.downloadFloat32MatrixFromBuffer(buffer, 12); - expectArraysEqual(vals, data); - }); - - it('has a valid texture for dtype=int32.', () => { - const data = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]; - const texShape = [2, 2]; - const a = tf.tensor(data, [1, 3, 4], 'int32'); - const b = tf.add(a, 0); - const res = b.dataToGPU(); - expectArraysEqual(res.texShape, texShape); - - const webGLBackend = tf.backend() as MathBackendWebGL; - - const buffer = webGLBackend.gpgpu.createBufferFromTexture( - res.texture, res.texShape[0], res.texShape[1]); - const vals = webGLBackend.gpgpu.downloadFloat32MatrixFromBuffer(buffer, 12); - - expectArraysEqual(vals, data); - }); - - it('has no memory leak.', () => { - const data = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]; - - const a = tf.tensor(data, [1, 3, 4]); - const b = tf.add(a, 0); - - const webGLBackend = tf.backend() as MathBackendWebGL; - const startNumBytes = (tf.memory() as WebGLMemoryInfo).numBytesInGPU; - const startTensor = tf.memory().numTensors; - const startDataBuckets = webGLBackend.numDataIds(); - - const res = b.dataToGPU(); - res.tensorRef.dispose(); - - const endNumBytes = (tf.memory() as WebGLMemoryInfo).numBytesInGPU; - const endTensor = tf.memory().numTensors; - const endDataBuckets = webGLBackend.numDataIds(); - - expect(endNumBytes).toEqual(startNumBytes); - expect(endTensor).toEqual(startTensor); - expect(endDataBuckets).toEqual(startDataBuckets); - }); - - it('can be used in tidy.', () => { - const data = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]; - - const webGLBackend = tf.backend() as MathBackendWebGL; - const startTensor = tf.memory().numTensors; - const startDataBuckets = webGLBackend.numDataIds(); - - const result = tf.tidy(() => { - const a = tf.tensor(data, [1, 3, 4]); - const b = tf.add(a, 0); - return b.dataToGPU() as unknown as tf.Tensor; - }); - - const endTensor = tf.memory().numTensors; - const endDataBuckets = webGLBackend.numDataIds(); - - expect(endTensor).toEqual(startTensor + 1); - expect(endDataBuckets).toEqual(startDataBuckets + 1); - - const res = result as unknown as GPUData; - const buffer = webGLBackend.gpgpu.createBufferFromTexture( - res.texture, res.texShape[0], res.texShape[1]); - const vals = webGLBackend.gpgpu.downloadFloat32MatrixFromBuffer(buffer, 12); - expectArraysEqual(vals, data); - }); - - it('tidy has no memory leak.', () => { - const data = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]; - - const webGLBackend = tf.backend(); - const startTensor = tf.memory().numTensors; - const startDataBuckets = webGLBackend.numDataIds(); - - tf.tidy(() => { - const a = tf.tensor(data, [1, 3, 4]); - const b = tf.add(a, 0); - b.dataToGPU(); - return b; - }); - - const endTensor = tf.memory().numTensors; - const endDataBuckets = webGLBackend.numDataIds(); - - expect(endTensor).toEqual(startTensor + 1); - expect(endDataBuckets).toEqual(startDataBuckets + 1); - }); - - it('throws error when user defined texShape is too small.', () => { - const data = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]; - const a = tf.tensor(data, [1, 3, 4]); - const b = tf.add(a, 0); - - expect(() => { - b.dataToGPU({customTexShape: [1, 1]}); - }).toThrowError(); - }); -}); - -describeWithFlags('keeping data on gpu ', WEBGL1_ENVS, () => { - let flag: boolean; - const webGLBackend = (tf.backend() as MathBackendWebGL); - - beforeAll(() => { - flag = tf.env().getBool('WEBGL_CPU_FORWARD'); - tf.env().set('WEBGL_CPU_FORWARD', false); - }); - - afterAll(() => { - tf.env().set('WEBGL_CPU_FORWARD', flag); - }); - - it('has a valid texture for dtype=float32.', () => { - const data = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]; - const texShape = [2, 2]; - const size = 12; - const a = tf.tensor(data, [1, 3, 4]); - const b = tf.add(a, 0); - const res = b.dataToGPU(); - expectArraysEqual(res.texShape, texShape); - - if (tf.env().getBool('WEBGL_DOWNLOAD_FLOAT_ENABLED')) { - const tmpData = webGLBackend.texData.get(res.tensorRef.dataId); - const vals = webGLBackend.gpgpu - .downloadMatrixFromPackedTexture( - tmpData.texture.texture, ...tmpData.texture.texShape) - .subarray(0, size); - expectArraysEqual(vals, data); - } - }); - - it('uses user defined texShape.', () => { - const data = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]; - const a = tf.tensor(data, [1, 3, 4]); - const b = tf.add(a, 0); - const texShape = [1, 3] as [number, number]; - const size = 12; - const res = b.dataToGPU({customTexShape: texShape}); - expectArraysEqual(res.texShape, texShape); - - if (tf.env().getBool('WEBGL_DOWNLOAD_FLOAT_ENABLED')) { - const tmpData = webGLBackend.texData.get(res.tensorRef.dataId); - const vals = webGLBackend.gpgpu - .downloadMatrixFromPackedTexture( - tmpData.texture.texture, ...tmpData.texture.texShape) - .subarray(0, size); - expectArraysEqual(vals, data); - } - }); - - it('has a valid texture for dtype=int32.', () => { - const data = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]; - const texShape = [2, 2]; - const size = 12; - const a = tf.tensor(data, [1, 3, 4], 'int32'); - const b = tf.add(a, 0); - const res = b.dataToGPU(); - expectArraysEqual(res.texShape, texShape); - - if (tf.env().getBool('WEBGL_DOWNLOAD_FLOAT_ENABLED')) { - const tmpData = webGLBackend.texData.get(res.tensorRef.dataId); - const vals = webGLBackend.gpgpu - .downloadMatrixFromPackedTexture( - tmpData.texture.texture, ...tmpData.texture.texShape) - .subarray(0, size); - expectArraysEqual(vals, data); - } - }); - - it('has no memory leak.', () => { - const data = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]; - - const a = tf.tensor(data, [1, 3, 4]); - const b = tf.add(a, 0); - - const webGLBackend = tf.backend() as MathBackendWebGL; - const startNumBytes = (tf.memory() as WebGLMemoryInfo).numBytesInGPU; - const startTensor = tf.memory().numTensors; - const startDataBuckets = webGLBackend.numDataIds(); - - const res = b.dataToGPU(); - res.tensorRef.dispose(); - - const endNumBytes = (tf.memory() as WebGLMemoryInfo).numBytesInGPU; - const endTensor = tf.memory().numTensors; - const endDataBuckets = webGLBackend.numDataIds(); - - expect(endNumBytes).toEqual(startNumBytes); - expect(endTensor).toEqual(startTensor); - expect(endDataBuckets).toEqual(startDataBuckets); - }); - - it('throws error when user defined texShape is too small.', () => { - const data = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]; - const a = tf.tensor(data, [1, 3, 4]); - const b = tf.add(a, 0); - - expect(() => { - b.dataToGPU({customTexShape: [1, 1]}); - }).toThrowError(); - }); -}); - -describeWithFlags('caching on cpu', WEBGL_ENVS, () => { - const customBackendName = 'cache-on-cpu'; - - beforeAll(() => { - tf.env().set('WEBGL_CPU_FORWARD', false); - const kernelFunc = tf.getKernel('Square', 'webgl').kernelFunc; - tf.registerKernel( - {kernelName: 'Square', backendName: customBackendName, kernelFunc}); - }); - - afterAll(() => { - tf.unregisterKernel('Square', customBackendName); - }); - - it('caches on cpu after async read', async () => { - const backend = new MathBackendWebGL(); - tf.registerBackend(customBackendName, () => backend); - tf.setBackend(customBackendName); - - const t = tf.square(2); - const info = backend.getDataInfo(t.dataId); - - // Make sure the tensor is on the GPU. - expect(info.values == null).toBe(true); - - await t.data(); - - // Make sure the tensor is cached on CPU. - expect(info.values).not.toBe(null); - - tf.removeBackend(customBackendName); - }); - - it('caches on cpu after sync read', () => { - const backend = new MathBackendWebGL(); - tf.registerBackend(customBackendName, () => backend); - tf.setBackend(customBackendName); - - const t = tf.square(2); - const info = backend.getDataInfo(t.dataId); - - // Make sure the tensor is on the GPU. - expect(info.values == null).toBe(true); - - t.dataSync(); - - // Make sure the tensor is cached on CPU. - expect(info.values).not.toBe(null); - - tf.removeBackend(customBackendName); - }); -}); - -describeWithFlags('WebGL backend has sync init', WEBGL_ENVS, () => { - it('can do matmul without waiting for ready', async () => { - const customWebGLBackendName = 'my-webgl'; - - tf.copyRegisteredKernels('webgl', customWebGLBackendName); - - tf.registerBackend(customWebGLBackendName, () => { - return new MathBackendWebGL(); - }); - tf.setBackend(customWebGLBackendName); - const a = tf.tensor1d([5]); - const b = tf.tensor1d([3]); - const res = tf.dot(a, b); - expectArraysClose(await res.data(), 15); - tf.dispose([a, b, res]); - tf.removeBackend(customWebGLBackendName); - }); -}); - -describeWithFlags('custom canvas ', WEBGL_ENVS, () => { - const customBackendName = 'custom-webgl'; - let flag: boolean; - - beforeAll(() => { - flag = tf.env().getBool('WEBGL_CPU_FORWARD'); - tf.env().set('WEBGL_CPU_FORWARD', false); - const kernelFunc = tf.getKernel('Square', 'webgl').kernelFunc; - tf.registerKernel( - {kernelName: 'Square', backendName: customBackendName, kernelFunc}); - }); - - afterAll(() => { - tf.env().set('WEBGL_CPU_FORWARD', flag); - tf.unregisterKernel('Square', customBackendName); - }); - - it('works.', () => { - const customCanvas = document.createElement('canvas'); - customCanvas.width = 300; - customCanvas.height = 200; - - const backend = new MathBackendWebGL(customCanvas); - tf.registerBackend(customBackendName, () => backend); - tf.setBackend(customBackendName); - - const t = tf.square(2); - const data = t.dataSync(); - - expectArraysEqual(data, [4]); - - tf.removeBackend(customBackendName); - }); -}); -describeWithFlags('Parallel compilation', WEBGL_ENVS, () => { - // TODO(lina128): Also test async after parallel compilation flag is - // implemented in context object. We have to keep the test sync for now, - // because it's a global flag, the async test will affect other tests. - it('does not have memory leak.', () => { - const savedWebGLCPUForward = tf.env().get('WEBGL_CPU_FORWARD'); - tf.env().set('WEBGL_CPU_FORWARD', false); - - const customWebGLBackendName = 'my-webgl'; - tf.copyRegisteredKernels('webgl', customWebGLBackendName); - tf.registerBackend(customWebGLBackendName, () => { - return new MathBackendWebGL(); - }); - tf.setBackend(customWebGLBackendName); - - const a0 = tf.tensor1d([1, 1, 1]); - const b0 = tf.tensor1d([1, 1, 1]); - const c0 = tf.add(a0, b0); - const data = c0.dataSync(); - - expectArraysClose(data, [2, 2, 2]); - tf.dispose([a0, b0, c0]); - tf.removeBackend(customWebGLBackendName); - - // TODO(lina128): Also test use an existing backend after parallel - // compilation flag is implemented in context object. The current approach - // assumes there's no binary cache, and it doesn't check existing cache. - const customWebGLBackendName1 = 'my-webgl1'; - tf.copyRegisteredKernels('webgl', customWebGLBackendName1); - tf.registerBackend(customWebGLBackendName1, () => { - return new MathBackendWebGL(); - }); - tf.setBackend(customWebGLBackendName1); - const webGLBackend = tf.backend() as MathBackendWebGL; - - const startNumBytes = (tf.memory() as WebGLMemoryInfo).numBytesInGPU; - const startTensor = tf.memory().numTensors; - const startDataBuckets = webGLBackend.numDataIds(); - - const a1 = tf.tensor1d([1, 1, 1]); - const b1 = tf.tensor1d([1, 1, 1]); - - // Pre-compile round. - tf.env().set('ENGINE_COMPILE_ONLY', true); - const c1 = tf.add(a1, b1); - webGLBackend.checkCompileCompletion(); - webGLBackend.getUniformLocations(); - - // Warm-up upload and download round. - tf.env().set('ENGINE_COMPILE_ONLY', false); - const c2 = tf.add(a1, b1); - c2.dataSync(); - - // Actual inference. - const c3 = tf.add(a1, b1); - expectArraysEqual(c3.dataSync(), [2, 2, 2]); - - tf.dispose([a1, b1, c1, c2, c3]); - const endNumBytes = (tf.memory() as WebGLMemoryInfo).numBytesInGPU; - const endTensor = tf.memory().numTensors; - const endDataBuckets = webGLBackend.numDataIds(); - - // We only check numBytesInGPU. For parallel compilation, - // numBytesInGPUAllocated will be more because of the two pass uploadToGPU, - // but they will all be freed, resulting in endNumbytes equal to - // startNumBytes. - expect(startNumBytes).toEqual(endNumBytes); - expect(startTensor).toEqual(endTensor); - expect(endDataBuckets).toEqual(startDataBuckets); - - tf.removeBackend(customWebGLBackendName1); - - tf.env().set('WEBGL_CPU_FORWARD', savedWebGLCPUForward); - }); -}); - -describeWithFlags('create tensor from texture', WEBGL_ENVS, () => { - it('basic usage', async () => { - // In this test we create a WebGL texture using the GL context from the - // WebGL backend. Then we create a tensor from that texture, and ensure that - // we can get the expected result. - - const width = 2; - const height = 2; - - const webGlBackend = tf.backend() as MathBackendWebGL; - const gl = webGlBackend.gpgpu.gl; - const texture = gl.createTexture(); - const tex2d = gl.TEXTURE_2D; - // tslint:disable-next-line:no-any - const glany = gl as any; - const internalFormat = - tf.env().getNumber('WEBGL_VERSION') === 1 ? gl.RGBA : glany.RGBA32F; - const textureFormat = glany.RGBA; - const textureType = glany.FLOAT; - const dataForUpload = new Float32Array( - [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]); - - gl.bindTexture(tex2d, texture); - gl.texParameteri(tex2d, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); - gl.texParameteri(tex2d, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); - gl.texParameteri(tex2d, gl.TEXTURE_MIN_FILTER, gl.NEAREST); - gl.texParameteri(tex2d, gl.TEXTURE_MAG_FILTER, gl.NEAREST); - gl.texImage2D( - tex2d, 0, internalFormat, width, height, 0, textureFormat, textureType, - dataForUpload); - - const logicalShape: [number, number] = [4, 4]; - const a = tf.tensor( - {texture, height, width, channels: 'RGBA'}, logicalShape, 'float32'); - - expect(a.shape).toEqual(logicalShape); - expect(a.dtype).toEqual('float32'); - expectArraysClose( - await a.data(), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]); - - gl.deleteTexture(texture); - }); - - it('works for custom canvas', async () => { - const customBackendName = 'custom-webgl'; - const customCanvas = document.createElement('canvas'); - const customBackend = new MathBackendWebGL(customCanvas); - tf.registerBackend(customBackendName, () => customBackend); - const originalBackend = tf.getBackend(); - await tf.setBackend(customBackendName); - - const gl = customBackend.gpgpu.gl; - const width = 2; - const height = 2; - - const texture = gl.createTexture(); - const tex2d = gl.TEXTURE_2D; - // tslint:disable-next-line:no-any - const glany = gl as any; - const internalFormat = - tf.env().getNumber('WEBGL_VERSION') === 1 ? gl.RGBA : glany.RGBA32F; - const textureFormat = glany.RGBA; - const textureType = glany.FLOAT; - const dataForUpload = new Float32Array( - [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]); - - gl.bindTexture(tex2d, texture); - gl.texParameteri(tex2d, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); - gl.texParameteri(tex2d, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); - gl.texParameteri(tex2d, gl.TEXTURE_MIN_FILTER, gl.NEAREST); - gl.texParameteri(tex2d, gl.TEXTURE_MAG_FILTER, gl.NEAREST); - gl.texImage2D( - tex2d, 0, internalFormat, width, height, 0, textureFormat, textureType, - dataForUpload); - - const logicalShape: [number, number] = [4, 4]; - const a = tf.tensor( - {texture, height, width, channels: 'RGBA'}, logicalShape, 'float32'); - - expect(a.shape).toEqual(logicalShape); - expect(a.dtype).toEqual('float32'); - expectArraysClose( - await a.data(), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]); - - gl.deleteTexture(texture); - tf.removeBackend(customBackendName); - await tf.setBackend(originalBackend); - customBackend.dispose(); - }); - - it('default shape is aligned with texture shape and default dtype is float32', - async () => { - // In this test we create a WebGL texture using the GL context from the - // WebGL backend. Then we create a tensor from that texture, and ensure - // that we can get the expected result. - - const width = 2; - const height = 2; - - const webGlBackend = tf.backend() as MathBackendWebGL; - const gl = webGlBackend.gpgpu.gl; - const texture = gl.createTexture(); - const tex2d = gl.TEXTURE_2D; - // tslint:disable-next-line:no-any - const glany = gl as any; - const internalFormat = - tf.env().getNumber('WEBGL_VERSION') === 1 ? gl.RGBA : glany.RGBA32F; - const textureFormat = glany.RGBA; - const textureType = glany.FLOAT; - const dataForUpload = new Float32Array( - [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]); - - gl.bindTexture(tex2d, texture); - gl.texParameteri(tex2d, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); - gl.texParameteri(tex2d, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); - gl.texParameteri(tex2d, gl.TEXTURE_MIN_FILTER, gl.NEAREST); - gl.texParameteri(tex2d, gl.TEXTURE_MAG_FILTER, gl.NEAREST); - gl.texImage2D( - tex2d, 0, internalFormat, width, height, 0, textureFormat, - textureType, dataForUpload); - - const physicalShape: [number, number] = [width, height * 4]; - const a = tf.tensor({texture, height, width, channels: 'RGBA'}); - - expect(a.shape).toEqual(physicalShape); - expect(a.dtype).toEqual('float32'); - expectArraysClose( - await a.data(), - [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]); - - gl.deleteTexture(texture); - }); - - it('default channels is RGBA', async () => { - // In this test we create a WebGL texture using the GL context from the - // WebGL backend. Then we create a tensor from that texture, and ensure - // that we can get the expected result. - - const width = 2; - const height = 2; - - const webGlBackend = tf.backend() as MathBackendWebGL; - const gl = webGlBackend.gpgpu.gl; - const texture = gl.createTexture(); - const tex2d = gl.TEXTURE_2D; - // tslint:disable-next-line:no-any - const glany = gl as any; - const internalFormat = - tf.env().getNumber('WEBGL_VERSION') === 1 ? gl.RGBA : glany.RGBA32F; - const textureFormat = glany.RGBA; - const textureType = glany.FLOAT; - const dataForUpload = new Float32Array( - [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]); - - gl.bindTexture(tex2d, texture); - gl.texParameteri(tex2d, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); - gl.texParameteri(tex2d, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); - gl.texParameteri(tex2d, gl.TEXTURE_MIN_FILTER, gl.NEAREST); - gl.texParameteri(tex2d, gl.TEXTURE_MAG_FILTER, gl.NEAREST); - gl.texImage2D( - tex2d, 0, internalFormat, width, height, 0, textureFormat, textureType, - dataForUpload); - - const logicalShape: [number, number] = [4, 4]; - const a = tf.tensor({texture, height, width}, logicalShape, 'float32'); - - expect(a.shape).toEqual(logicalShape); - expect(a.dtype).toEqual('float32'); - expectArraysClose( - await a.data(), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]); - - gl.deleteTexture(texture); - }); - - it('works for channels GA', async () => { - // In this test we create a WebGL texture using the GL context from the - // WebGL backend. Then we create a tensor from that texture, and ensure - // that we can get the expected result. - - const width = 2; - const height = 2; - - const webGlBackend = tf.backend() as MathBackendWebGL; - const gl = webGlBackend.gpgpu.gl; - const texture = gl.createTexture(); - const tex2d = gl.TEXTURE_2D; - // tslint:disable-next-line:no-any - const glany = gl as any; - const internalFormat = - tf.env().getNumber('WEBGL_VERSION') === 1 ? gl.RGBA : glany.RGBA32F; - const textureFormat = glany.RGBA; - const textureType = glany.FLOAT; - const dataForUpload = new Float32Array( - [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]); - - gl.bindTexture(tex2d, texture); - gl.texParameteri(tex2d, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); - gl.texParameteri(tex2d, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); - gl.texParameteri(tex2d, gl.TEXTURE_MIN_FILTER, gl.NEAREST); - gl.texParameteri(tex2d, gl.TEXTURE_MAG_FILTER, gl.NEAREST); - gl.texImage2D( - tex2d, 0, internalFormat, width, height, 0, textureFormat, textureType, - dataForUpload); - - const logicalShape: [number, number] = [2, 4]; - const a = tf.tensor( - {texture, height, width, channels: 'GA'}, logicalShape, 'float32'); - - expect(a.shape).toEqual(logicalShape); - expect(a.dtype).toEqual('float32'); - expectArraysClose(await a.data(), [1, 3, 5, 7, 9, 11, 13, 15]); - - gl.deleteTexture(texture); - }); - - it('works for channels ABGR', async () => { - // In this test we create a WebGL texture using the GL context from the - // WebGL backend. Then we create a tensor from that texture, and ensure - // that we can get the expected result. - - const width = 2; - const height = 2; - - const webGlBackend = tf.backend() as MathBackendWebGL; - const gl = webGlBackend.gpgpu.gl; - const texture = gl.createTexture(); - const tex2d = gl.TEXTURE_2D; - // tslint:disable-next-line:no-any - const glany = gl as any; - const internalFormat = - tf.env().getNumber('WEBGL_VERSION') === 1 ? gl.RGBA : glany.RGBA32F; - const textureFormat = glany.RGBA; - const textureType = glany.FLOAT; - const dataForUpload = new Float32Array( - [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]); - - gl.bindTexture(tex2d, texture); - gl.texParameteri(tex2d, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); - gl.texParameteri(tex2d, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); - gl.texParameteri(tex2d, gl.TEXTURE_MIN_FILTER, gl.NEAREST); - gl.texParameteri(tex2d, gl.TEXTURE_MAG_FILTER, gl.NEAREST); - gl.texImage2D( - tex2d, 0, internalFormat, width, height, 0, textureFormat, textureType, - dataForUpload); - - const logicalShape: [number, number] = [4, 4]; - const a = tf.tensor( - {texture, height, width, channels: 'ABGR'}, logicalShape, 'float32'); - - expect(a.shape).toEqual(logicalShape); - expect(a.dtype).toEqual('float32'); - expectArraysClose( - await a.data(), [3, 2, 1, 0, 7, 6, 5, 4, 11, 10, 9, 8, 15, 14, 13, 12]); - - gl.deleteTexture(texture); - }); - - it('works for int32 dtype', async () => { - // In this test we create a WebGL texture using the GL context from the - // WebGL backend. Then we create a tensor from that texture, and ensure - // that we can get the expected result. - - const width = 1; - const height = 1; - - const webGlBackend = tf.backend() as MathBackendWebGL; - const gl = webGlBackend.gpgpu.gl; - const texture = gl.createTexture(); - const tex2d = gl.TEXTURE_2D; - // tslint:disable-next-line:no-any - const glany = gl as any; - const internalFormat = - tf.env().getNumber('WEBGL_VERSION') === 1 ? gl.RGBA : glany.RGBA32F; - const textureFormat = glany.RGBA; - const textureType = glany.FLOAT; - const dataForUpload = new Float32Array([-1.2, -0.1, 0.1, 1.2]); - - gl.bindTexture(tex2d, texture); - gl.texParameteri(tex2d, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); - gl.texParameteri(tex2d, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); - gl.texParameteri(tex2d, gl.TEXTURE_MIN_FILTER, gl.NEAREST); - gl.texParameteri(tex2d, gl.TEXTURE_MAG_FILTER, gl.NEAREST); - gl.texImage2D( - tex2d, 0, internalFormat, width, height, 0, textureFormat, textureType, - dataForUpload); - - const logicalShape: [number, number] = [2, 2]; - const a = tf.tensor( - {texture, height, width, channels: 'RGBA'}, logicalShape, 'int32'); - - expect(a.shape).toEqual(logicalShape); - expect(a.dtype).toEqual('int32'); - expectArraysClose(await a.data(), [-1, 0, 0, 1]); - - gl.deleteTexture(texture); - }); - - it('throws for string dtype', async () => { - // In this test we create a WebGL texture using the GL context from the - // WebGL backend. Then we create a tensor from that texture, and ensure that - // we can get the expected result. - - const width = 1; - const height = 2; - - const webGlBackend = tf.backend() as MathBackendWebGL; - const gl = webGlBackend.gpgpu.gl; - const texture = gl.createTexture(); - const tex2d = gl.TEXTURE_2D; - // tslint:disable-next-line:no-any - const glany = gl as any; - const internalFormat = - tf.env().getNumber('WEBGL_VERSION') === 1 ? gl.RGBA : glany.RGBA32F; - const textureFormat = glany.RGBA; - const textureType = glany.FLOAT; - const dataForUpload = new Float32Array([-2, -1, 0, 1, 2, 3, 4, 5]); - - gl.bindTexture(tex2d, texture); - gl.texParameteri(tex2d, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); - gl.texParameteri(tex2d, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); - gl.texParameteri(tex2d, gl.TEXTURE_MIN_FILTER, gl.NEAREST); - gl.texParameteri(tex2d, gl.TEXTURE_MAG_FILTER, gl.NEAREST); - gl.texImage2D( - tex2d, 0, internalFormat, width, height, 0, textureFormat, textureType, - dataForUpload); - - const logicalShape: [number, number] = [height, width]; - const a = () => tf.tensor( - {texture, height, width, channels: 'RGBA'}, logicalShape, 'string'); - - expect(a).toThrowError(); - gl.deleteTexture(texture); - }); - - it('pad zeros at the rear if texture size is smaller than tensor size', - async () => { - // In this test we create a WebGL texture using the GL context from the - // WebGL backend. Then we create a tensor from that texture, and ensure - // that we can get the expected result. - - const width = 1; - const height = 1; - - const webGlBackend = tf.backend() as MathBackendWebGL; - const gl = webGlBackend.gpgpu.gl; - const texture = gl.createTexture(); - const tex2d = gl.TEXTURE_2D; - // tslint:disable-next-line:no-any - const glany = gl as any; - const internalFormat = - tf.env().getNumber('WEBGL_VERSION') === 1 ? gl.RGBA : glany.RGBA32F; - const textureFormat = glany.RGBA; - const textureType = glany.FLOAT; - const dataForUpload = new Float32Array([0, 1, 2, 3]); - - gl.bindTexture(tex2d, texture); - gl.texParameteri(tex2d, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); - gl.texParameteri(tex2d, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); - gl.texParameteri(tex2d, gl.TEXTURE_MIN_FILTER, gl.NEAREST); - gl.texParameteri(tex2d, gl.TEXTURE_MAG_FILTER, gl.NEAREST); - gl.texImage2D( - tex2d, 0, internalFormat, width, height, 0, textureFormat, - textureType, dataForUpload); - - const logicalShape: [number, number] = [3, 3]; - const a = tf.tensor( - {texture, height, width, channels: 'RGBA'}, logicalShape, 'float32'); - - expect(a.shape).toEqual(logicalShape); - expect(a.dtype).toEqual('float32'); - expectArraysClose(await a.data(), [0, 1, 2, 3, 0, 0, 0, 0, 0]); - - gl.deleteTexture(texture); - }); - - it('works if tensor size is smaller than texture size', async () => { - // In this test we create a WebGL texture using the GL context from the - // WebGL backend. Then we create a tensor from that texture, and ensure - // that we can get the expected result. - - const width = 2; - const height = 2; - - const webGlBackend = tf.backend() as MathBackendWebGL; - const gl = webGlBackend.gpgpu.gl; - const texture = gl.createTexture(); - const tex2d = gl.TEXTURE_2D; - // tslint:disable-next-line:no-any - const glany = gl as any; - const internalFormat = - tf.env().getNumber('WEBGL_VERSION') === 1 ? gl.RGBA : glany.RGBA32F; - const textureFormat = glany.RGBA; - const textureType = glany.FLOAT; - const dataForUpload = new Float32Array( - [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]); - - gl.bindTexture(tex2d, texture); - gl.texParameteri(tex2d, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); - gl.texParameteri(tex2d, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); - gl.texParameteri(tex2d, gl.TEXTURE_MIN_FILTER, gl.NEAREST); - gl.texParameteri(tex2d, gl.TEXTURE_MAG_FILTER, gl.NEAREST); - gl.texImage2D( - tex2d, 0, internalFormat, width, height, 0, textureFormat, textureType, - dataForUpload); - - const logicalShape: [number, number] = [3, 3]; - const a = tf.tensor( - {texture, height, width, channels: 'RGBA'}, logicalShape, 'float32'); - - expect(a.shape).toEqual(logicalShape); - expect(a.dtype).toEqual('float32'); - expectArraysClose(await a.data(), [0, 1, 2, 3, 4, 5, 6, 7, 8]); - gl.deleteTexture(texture); - }); -}); diff --git a/tfjs-master/tfjs-backend-webgl/src/backend_webgl_test_registry.ts b/tfjs-master/tfjs-backend-webgl/src/backend_webgl_test_registry.ts deleted file mode 100644 index 0339dd1e8..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/backend_webgl_test_registry.ts +++ /dev/null @@ -1,50 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// tslint:disable-next-line: no-imports-from-dist -import {Constraints, registerTestEnv} from '@tensorflow/tfjs-core/dist/jasmine_util'; - -export const WEBGL_ENVS: Constraints = { - predicate: testEnv => testEnv.backendName === 'webgl' -}; -export const PACKED_ENVS: Constraints = { - flags: {'WEBGL_PACK': true} -}; - -export function registerTestEnvs() { - registerTestEnv({ - name: 'webgl1', - backendName: 'webgl', - flags: { - 'WEBGL_VERSION': 1, - 'WEBGL_CPU_FORWARD': false, - 'WEBGL_SIZE_UPLOAD_UNIFORM': 0 - }, - isDataSync: true - }); - - registerTestEnv({ - name: 'webgl2', - backendName: 'webgl', - flags: { - 'WEBGL_VERSION': 2, - 'WEBGL_CPU_FORWARD': false, - 'WEBGL_SIZE_UPLOAD_UNIFORM': 0 - }, - isDataSync: true - }); -} diff --git a/tfjs-master/tfjs-backend-webgl/src/base.ts b/tfjs-master/tfjs-backend-webgl/src/base.ts deleted file mode 100644 index f2412eab1..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/base.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @license - * Copyright 2020 Google Inc. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// base.ts is the webgl backend without auto kernel registration. - -import {device_util, registerBackend} from '@tensorflow/tfjs-core'; -import {MathBackendWebGL} from './backend_webgl'; -export {version as version_webgl} from './version'; - -if (device_util.isBrowser()) { - registerBackend('webgl', () => new MathBackendWebGL(), 2 /* priority */); -} - -// Export webgl utilities -export * from './webgl'; - -// Export forceHalfFlost under webgl namespace for the union bundle. -import {forceHalfFloat} from './webgl'; -export const webgl = {forceHalfFloat}; diff --git a/tfjs-master/tfjs-backend-webgl/src/batchnorm_gpu.ts b/tfjs-master/tfjs-backend-webgl/src/batchnorm_gpu.ts deleted file mode 100644 index 487453932..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/batchnorm_gpu.ts +++ /dev/null @@ -1,61 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util} from '@tensorflow/tfjs-core'; -import {GPGPUProgram} from './gpgpu_math'; - -export class BatchNormProgram implements GPGPUProgram { - variableNames: string[]; - outputShape: number[] = []; - userCode: string; - - constructor( - xShape: number[], meanShape: number[], varianceShape: number[], - offsetShape: number[]|null, scaleShape: number[]|null, - varianceEpsilon: number) { - this.variableNames = ['x', 'mean', 'variance']; - backend_util.assertAndGetBroadcastShape(xShape, meanShape); - backend_util.assertAndGetBroadcastShape(xShape, varianceShape); - - let offsetSnippet = '0.0'; - if (offsetShape != null) { - backend_util.assertAndGetBroadcastShape(xShape, offsetShape); - this.variableNames.push('offset'); - offsetSnippet = 'getOffsetAtOutCoords()'; - } - - let scaleSnippet = '1.0'; - if (scaleShape != null) { - backend_util.assertAndGetBroadcastShape(xShape, scaleShape); - this.variableNames.push('scale'); - scaleSnippet = 'getScaleAtOutCoords()'; - } - - this.outputShape = xShape; - this.userCode = ` - void main() { - float x = getXAtOutCoords(); - float mean = getMeanAtOutCoords(); - float variance = getVarianceAtOutCoords(); - float offset = ${offsetSnippet}; - float scale = ${scaleSnippet}; - float inv = scale * inversesqrt(variance + float(${varianceEpsilon})); - setOutput(dot(vec3(x, -mean, offset), vec3(inv, inv, 1))); - } - `; - } -} diff --git a/tfjs-master/tfjs-backend-webgl/src/batchnorm_packed_gpu.ts b/tfjs-master/tfjs-backend-webgl/src/batchnorm_packed_gpu.ts deleted file mode 100644 index b5c4f72d6..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/batchnorm_packed_gpu.ts +++ /dev/null @@ -1,66 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util} from '@tensorflow/tfjs-core'; -import {GPGPUProgram} from './gpgpu_math'; - -export class BatchNormPackedProgram implements GPGPUProgram { - variableNames: string[]; - outputShape: number[]; - userCode: string; - packedInputs = true; - packedOutput = true; - - constructor( - xShape: number[], meanShape: number[], varianceShape: number[], - offsetShape: number[]|null, scaleShape: number[]|null, - varianceEpsilon: number) { - this.variableNames = ['x', 'mean', 'variance']; - backend_util.assertAndGetBroadcastShape(xShape, meanShape); - backend_util.assertAndGetBroadcastShape(xShape, varianceShape); - - let offsetSnippet = 'vec4(0.0)'; - if (offsetShape != null) { - backend_util.assertAndGetBroadcastShape(xShape, offsetShape); - this.variableNames.push('offset'); - offsetSnippet = 'getOffsetAtOutCoords()'; - } - - let scaleSnippet = 'vec4(1.0)'; - if (scaleShape != null) { - backend_util.assertAndGetBroadcastShape(xShape, scaleShape); - this.variableNames.push('scale'); - scaleSnippet = 'getScaleAtOutCoords()'; - } - - this.outputShape = xShape; - this.userCode = ` - void main() { - vec4 offset = ${offsetSnippet}; - vec4 scale = ${scaleSnippet}; - - vec4 x = getXAtOutCoords(); - vec4 mean = getMeanAtOutCoords(); - vec4 variance = getVarianceAtOutCoords(); - - vec4 inv = scale * inversesqrt(variance + vec4(${varianceEpsilon})); - - setOutput((x - mean) * inv + offset); - } - `; - } -} diff --git a/tfjs-master/tfjs-backend-webgl/src/binaryop_complex_gpu.ts b/tfjs-master/tfjs-backend-webgl/src/binaryop_complex_gpu.ts deleted file mode 100644 index 3b9d0002d..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/binaryop_complex_gpu.ts +++ /dev/null @@ -1,53 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util} from '@tensorflow/tfjs-core'; -import {GPGPUProgram} from './gpgpu_math'; - -// (Ar + Ai)(Br + Bi) = -// ArBr + ArBi + AiBr + AiBi = ArBr - AB + ArBi + AiBr -// Yr = ArBr - AB -// Yi = ArBi + AiBr -export const COMPLEX_MULTIPLY = { - REAL: 'return areal * breal - aimag * bimag;', - IMAG: 'return areal * bimag + aimag * breal;' -}; - -export class BinaryOpComplexProgram implements GPGPUProgram { - variableNames = ['AReal', 'AImag', 'BReal', 'BImag']; - userCode: string; - outputShape: number[]; - - constructor(op: string, aShape: number[], bShape: number[]) { - this.outputShape = backend_util.assertAndGetBroadcastShape(aShape, bShape); - - this.userCode = ` - float binaryOpComplex( - float areal, float aimag, float breal, float bimag) { - ${op} - } - - void main() { - float areal = getARealAtOutCoords(); - float aimag = getAImagAtOutCoords(); - float breal = getBRealAtOutCoords(); - float bimag = getBImagAtOutCoords(); - setOutput(binaryOpComplex(areal, aimag, breal, bimag)); - } - `; - } -} diff --git a/tfjs-master/tfjs-backend-webgl/src/binaryop_gpu.ts b/tfjs-master/tfjs-backend-webgl/src/binaryop_gpu.ts deleted file mode 100644 index 39fc2858f..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/binaryop_gpu.ts +++ /dev/null @@ -1,49 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util} from '@tensorflow/tfjs-core'; - -import {GPGPUProgram, useShapeUniforms} from './gpgpu_math'; - -export const CHECK_NAN_SNIPPET = ` - if (isnan(a)) return a; - if (isnan(b)) return b; -`; - -export const SQUARED_DIFFERENCE = 'return (a - b) * (a - b);'; -export class BinaryOpProgram implements GPGPUProgram { - variableNames = ['A', 'B']; - outputShape: number[]; - userCode: string; - enableShapeUniforms: boolean; - - constructor(op: string, aShape: number[], bShape: number[]) { - this.outputShape = backend_util.assertAndGetBroadcastShape(aShape, bShape); - this.enableShapeUniforms = useShapeUniforms(this.outputShape.length); - this.userCode = ` - float binaryOperation(float a, float b) { - ${op} - } - - void main() { - float a = getAAtOutCoords(); - float b = getBAtOutCoords(); - setOutput(binaryOperation(a, b)); - } - `; - } -} diff --git a/tfjs-master/tfjs-backend-webgl/src/binaryop_packed_gpu.ts b/tfjs-master/tfjs-backend-webgl/src/binaryop_packed_gpu.ts deleted file mode 100644 index 41928d41e..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/binaryop_packed_gpu.ts +++ /dev/null @@ -1,125 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, util} from '@tensorflow/tfjs-core'; - -import {GPGPUProgram, useShapeUniforms} from './gpgpu_math'; -import {getChannels} from './packing_util'; -import {getCoordsDataType} from './shader_compiler'; - -export const CHECK_NAN_SNIPPET_PACKED = ` - result.r = isNaN.r ? NAN : result.r; - result.g = isNaN.g ? NAN : result.g; - result.b = isNaN.b ? NAN : result.b; - result.a = isNaN.a ? NAN : result.a; -`; - -export const ELU_DER = ` - vec4 bGTEZero = vec4(greaterThanEqual(b, vec4(0.))); - return (bGTEZero * a) + ((vec4(1.0) - bGTEZero) * (a * (b + vec4(1.0)))); -`; - -export const NOT_EQUAL = ` - return vec4(notEqual(a, b)); -`; - -export class BinaryOpPackedProgram implements GPGPUProgram { - variableNames = ['A', 'B']; - outputShape: number[]; - userCode: string; - supportsBroadcasting = true; - packedInputs = true; - packedOutput = true; - enableShapeUniforms: boolean; - - constructor( - op: string, aShape: number[], bShape: number[], - checkOutOfBounds = false) { - this.outputShape = backend_util.assertAndGetBroadcastShape(aShape, bShape); - const rank = this.outputShape.length; - this.enableShapeUniforms = useShapeUniforms(rank); - let checkOutOfBoundsString = ''; - if (checkOutOfBounds) { - if (rank === 0 || util.sizeFromShape(this.outputShape) === 1) { - checkOutOfBoundsString = ` - result.y = 0.; - result.z = 0.; - result.w = 0.; - `; - } else { - const dtype = getCoordsDataType(rank); - checkOutOfBoundsString = ` - ${dtype} coords = getOutputCoords(); - `; - if (rank === 1) { - if (this.enableShapeUniforms) { - checkOutOfBoundsString += ` - result.y = (coords + 1) >= outShape ? 0. : result.y; - result.z = 0.; - result.w = 0.; - `; - } else { - checkOutOfBoundsString += ` - result.y = (coords + 1) >= ${this.outputShape[0]} ? 0. : result.y; - result.z = 0.; - result.w = 0.; - `; - } - } else { - const channels = getChannels('coords', rank); - if (this.enableShapeUniforms) { - checkOutOfBoundsString += ` - bool nextRowOutOfBounds = - (${channels[rank - 2]} + 1) >= outShape[${rank} - 2]; - bool nextColOutOfBounds = - (${channels[rank - 1]} + 1) >= outShape[${rank} - 1]; - result.y = nextColOutOfBounds ? 0. : result.y; - result.z = nextRowOutOfBounds ? 0. : result.z; - result.w = nextColOutOfBounds || nextRowOutOfBounds ? 0. : result.w; - `; - } else { - checkOutOfBoundsString += ` - bool nextRowOutOfBounds = - (${channels[rank - 2]} + 1) >= ${this.outputShape[rank - 2]}; - bool nextColOutOfBounds = - (${channels[rank - 1]} + 1) >= ${this.outputShape[rank - 1]}; - result.y = nextColOutOfBounds ? 0. : result.y; - result.z = nextRowOutOfBounds ? 0. : result.z; - result.w = nextColOutOfBounds || nextRowOutOfBounds ? 0. : result.w; - `; - } - } - } - } - - this.userCode = ` - vec4 binaryOperation(vec4 a, vec4 b) { - ${op} - } - - void main() { - vec4 a = getAAtOutCoords(); - vec4 b = getBAtOutCoords(); - - vec4 result = binaryOperation(a, b); - ${checkOutOfBoundsString} - - setOutput(result); - } - `; - } -} diff --git a/tfjs-master/tfjs-backend-webgl/src/canvas_util.ts b/tfjs-master/tfjs-backend-webgl/src/canvas_util.ts deleted file mode 100644 index 3c44681af..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/canvas_util.ts +++ /dev/null @@ -1,112 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {env} from '@tensorflow/tfjs-core'; - -const contexts: {[key: string]: WebGLRenderingContext} = {}; - -const WEBGL_ATTRIBUTES: WebGLContextAttributes = { - alpha: false, - antialias: false, - premultipliedAlpha: false, - preserveDrawingBuffer: false, - depth: false, - stencil: false, - failIfMajorPerformanceCaveat: true -}; - -export function clearWebGLContext(webGLVersion: number) { - delete contexts[webGLVersion]; -} - -export function setWebGLContext( - webGLVersion: number, gl: WebGLRenderingContext) { - contexts[webGLVersion] = gl; -} - -export function getWebGLContext( - webGLVersion: number, - customCanvas?: HTMLCanvasElement|OffscreenCanvas): WebGLRenderingContext { - if (!(webGLVersion in contexts) || customCanvas != null) { - const newCtx = getWebGLRenderingContext(webGLVersion, customCanvas); - if (newCtx !== null) { - contexts[webGLVersion] = newCtx; - } else { - console.log('Could not get context for WebGL version', webGLVersion); - return null; - } - } - const gl = contexts[webGLVersion]; - if (gl == null || gl.isContextLost()) { - delete contexts[webGLVersion]; - return getWebGLContext(webGLVersion); - } - - gl.disable(gl.DEPTH_TEST); - gl.disable(gl.STENCIL_TEST); - gl.disable(gl.BLEND); - gl.disable(gl.DITHER); - gl.disable(gl.POLYGON_OFFSET_FILL); - gl.disable(gl.SAMPLE_COVERAGE); - gl.enable(gl.SCISSOR_TEST); - gl.enable(gl.CULL_FACE); - gl.cullFace(gl.BACK); - - return contexts[webGLVersion]; -} - -function createCanvas(webGLVersion: number) { - // Use canvas element for Safari, since its offscreen canvas does not support - // fencing. - if (!env().getBool('IS_SAFARI') && typeof OffscreenCanvas !== 'undefined' && - webGLVersion === 2) { - return new OffscreenCanvas(300, 150); - } else if (typeof document !== 'undefined') { - return document.createElement('canvas'); - } else { - throw new Error('Cannot create a canvas in this context'); - } -} - -function getWebGLRenderingContext( - webGLVersion: number, - customCanvas?: HTMLCanvasElement|OffscreenCanvas): WebGLRenderingContext { - if (webGLVersion !== 1 && webGLVersion !== 2) { - throw new Error('Cannot get WebGL rendering context, WebGL is disabled.'); - } - const canvas = - customCanvas == null ? createCanvas(webGLVersion) : customCanvas; - - canvas.addEventListener('webglcontextlost', (ev: Event) => { - ev.preventDefault(); - delete contexts[webGLVersion]; - }, false); - - if (env().getBool('SOFTWARE_WEBGL_ENABLED')) { - WEBGL_ATTRIBUTES.failIfMajorPerformanceCaveat = false; - } - - if (webGLVersion === 1) { - return ( - // tslint:disable-next-line - canvas.getContext('webgl', WEBGL_ATTRIBUTES) as WebGLRenderingContext || - (canvas as HTMLCanvasElement) - .getContext('experimental-webgl', - WEBGL_ATTRIBUTES) as WebGLRenderingContext); - } - return canvas.getContext('webgl2', WEBGL_ATTRIBUTES) as WebGLRenderingContext; -} diff --git a/tfjs-master/tfjs-backend-webgl/src/canvas_util_test.ts b/tfjs-master/tfjs-backend-webgl/src/canvas_util_test.ts deleted file mode 100644 index 6f8b5deab..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/canvas_util_test.ts +++ /dev/null @@ -1,59 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import * as tf from '@tensorflow/tfjs-core'; -// tslint:disable-next-line: no-imports-from-dist -import {BROWSER_ENVS, describeWithFlags} from '@tensorflow/tfjs-core/dist/jasmine_util'; - -import {getWebGLContext} from './canvas_util'; - -describeWithFlags('canvas_util', BROWSER_ENVS, () => { - it('Returns a valid canvas', () => { - const canvas = - getWebGLContext(tf.env().getNumber('WEBGL_VERSION')).canvas as - // tslint:disable-next-line: no-any - any; - expect( - (canvas instanceof HTMLCanvasElement) || - (canvas instanceof OffscreenCanvas)) - .toBe(true); - }); - - it('Returns a valid gl context', () => { - const gl = getWebGLContext(tf.env().getNumber('WEBGL_VERSION')); - expect(gl.isContextLost()).toBe(false); - }); - - it('Returns a valid user defined canvas.', () => { - const webGLVersion = tf.env().getNumber('WEBGL_VERSION'); - - const customCanvas = document.createElement('canvas'); - customCanvas.width = 10; - customCanvas.height = 10; - - const gl = getWebGLContext(webGLVersion, customCanvas); - - expect(gl).not.toBeNull(); - expect(gl.canvas).toBe(customCanvas); - }); -}); - -describeWithFlags('canvas_util webgl2', {flags: {WEBGL_VERSION: 2}}, () => { - it('is ok when the user requests webgl 1 canvas', () => { - const canvas = getWebGLContext(1).canvas; - expect(canvas.getContext != null).toBe(true); - }); -}); diff --git a/tfjs-master/tfjs-backend-webgl/src/clip_gpu.ts b/tfjs-master/tfjs-backend-webgl/src/clip_gpu.ts deleted file mode 100644 index b53aad13c..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/clip_gpu.ts +++ /dev/null @@ -1,45 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {GPGPUProgram} from './gpgpu_math'; -import {UniformType} from './shader_compiler'; - -export class ClipProgram implements GPGPUProgram { - variableNames = ['A']; - userCode: string; - outputShape: number[]; - customUniforms = [ - {name: 'minVal', type: 'float' as UniformType}, - {name: 'maxVal', type: 'float' as UniformType} - ]; - - constructor(aShape: number[]) { - this.outputShape = aShape; - this.userCode = ` - - void main() { - float value = getAAtOutCoords(); - if (isnan(value)) { - setOutput(value); - return; - } - - setOutput(clamp(value, minVal, maxVal)); - } - `; - } -} diff --git a/tfjs-master/tfjs-backend-webgl/src/clip_packed_gpu.ts b/tfjs-master/tfjs-backend-webgl/src/clip_packed_gpu.ts deleted file mode 100644 index 08d78fd32..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/clip_packed_gpu.ts +++ /dev/null @@ -1,47 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {GPGPUProgram} from './gpgpu_math'; -import {UniformType} from './shader_compiler'; - -export class ClipPackedProgram implements GPGPUProgram { - variableNames = ['A']; - packedInputs = true; - packedOutput = true; - userCode: string; - outputShape: number[]; - customUniforms = [ - {name: 'minVal', type: 'float' as UniformType}, - {name: 'maxVal', type: 'float' as UniformType} - ]; - - constructor(aShape: number[]) { - this.outputShape = aShape; - this.userCode = ` - void main() { - vec4 value = getAAtOutCoords(); - - if (any(isnan(value))) { - setOutput(value); - return; - } - - setOutput(clamp(value, vec4(minVal), vec4(maxVal))); - } - `; - } -} diff --git a/tfjs-master/tfjs-backend-webgl/src/complex_abs_gpu.ts b/tfjs-master/tfjs-backend-webgl/src/complex_abs_gpu.ts deleted file mode 100644 index d9c4635d0..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/complex_abs_gpu.ts +++ /dev/null @@ -1,42 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {GPGPUProgram} from './gpgpu_math'; - -export class ComplexAbsProgram implements GPGPUProgram { - variableNames = ['real', 'imag']; - userCode: string; - outputShape: number[]; - - constructor(shape: number[]) { - this.outputShape = shape; - this.userCode = ` - void main() { - float re = abs(getRealAtOutCoords()); - float im = abs(getImagAtOutCoords()); - float mx = max(re, im); - - // sadly the length function in glsl is not underflow-safe - // (at least not on Intel GPUs). So the safe solution is - // to ensure underflow-safety in all cases. - setOutput( - mx == 0.0 ? 0.0 : mx * length(vec2(1, min(re, im)/mx)) - ); - } - `; - } -} diff --git a/tfjs-master/tfjs-backend-webgl/src/concat_gpu.ts b/tfjs-master/tfjs-backend-webgl/src/concat_gpu.ts deleted file mode 100644 index 5b38e8d5d..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/concat_gpu.ts +++ /dev/null @@ -1,58 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util} from '@tensorflow/tfjs-core'; -import {GPGPUProgram} from './gpgpu_math'; - -export class ConcatProgram implements GPGPUProgram { - variableNames: string[]; - outputShape: number[] = []; - userCode: string; - - // Concats 2d tensors along axis=1. See comments in MathBackendWebGL.concat(). - constructor(shapes: Array<[number, number]>) { - this.outputShape = backend_util.computeOutShape(shapes, 1 /* axis */); - this.variableNames = shapes.map((_, i) => `T${i}`); - - const offsets: number[] = new Array(shapes.length - 1); - offsets[0] = shapes[0][1]; - for (let i = 1; i < offsets.length; i++) { - offsets[i] = offsets[i - 1] + shapes[i][1]; - } - - const snippets = [`if (yC < ${offsets[0]}) setOutput(getT0(yR, yC));`]; - for (let i = 1; i < offsets.length; i++) { - const shift = offsets[i - 1]; - snippets.push( - `else if (yC < ${offsets[i]}) ` + - `setOutput(getT${i}(yR, yC-${shift}));`); - } - const lastIndex = offsets.length; - const lastShift = offsets[offsets.length - 1]; - snippets.push(`else setOutput(getT${lastIndex}(yR, yC-${lastShift}));`); - - this.userCode = ` - void main() { - ivec2 coords = getOutputCoords(); - int yR = coords.x; - int yC = coords.y; - - ${snippets.join('\n ')} - } - `; - } -} diff --git a/tfjs-master/tfjs-backend-webgl/src/concat_packed_gpu.ts b/tfjs-master/tfjs-backend-webgl/src/concat_packed_gpu.ts deleted file mode 100644 index 72ab1a94a..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/concat_packed_gpu.ts +++ /dev/null @@ -1,125 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util} from '@tensorflow/tfjs-core'; - -import {GPGPUProgram} from './gpgpu_math'; -import {getChannels} from './packing_util'; -import {getCoordsDataType} from './shader_compiler'; - -export class ConcatPackedProgram implements GPGPUProgram { - variableNames: string[]; - packedInputs = true; - packedOutput = true; - outputShape: number[] = []; - userCode: string; - - constructor(shapes: number[][], axis: number) { - this.outputShape = backend_util.computeOutShape(shapes, axis); - const shape = this.outputShape; - const rank = shape.length; - const dtype = getCoordsDataType(rank); - const coords = getChannels('coords', rank); - const channels = ['x', 'y', 'z', 'w', 'u', 'v'].slice(0, rank); - this.variableNames = shapes.map((_, i) => `T${i}`); - - const offsets: number[] = new Array(shapes.length - 1); - offsets[0] = shapes[0][axis]; - for (let i = 1; i < offsets.length; i++) { - offsets[i] = offsets[i - 1] + shapes[i][axis]; - } - - const channel = channels[axis]; - const lastChannels = channels.slice(-2); - const allChannels = channels.join(); - - let getValueSnippet = `if (${channel} < ${offsets[0]}) { - return getChannel( - getT0(${allChannels}), vec2(${lastChannels.join()})); - }`; - for (let i = 1; i < offsets.length; i++) { - const shift = offsets[i - 1]; - // Note: the >= comparison below may seem unnecessary given the check - // above but is needed to workaround branch execution issues on some - // devices. It makes all the conditions exclusive without relying on - // execution order. - getValueSnippet += ` - if (${channel} < ${offsets[i]} && ${channel} >= ${offsets[i - 1]}) { - return getChannel( - getT${i}(${shiftedChannels(channels, channel, shift)}), - vec2(${shiftedChannels(lastChannels, channel, shift)})); - }`; - } - const lastIndex = offsets.length; - const shift = offsets[offsets.length - 1]; - getValueSnippet += ` - return getChannel( - getT${lastIndex}(${shiftedChannels(channels, channel, shift)}), - vec2(${shiftedChannels(lastChannels, channel, shift)}));`; - - this.userCode = ` - float getValue(${channels.map(x => 'int ' + x)}) { - ${getValueSnippet} - } - - void main() { - ${dtype} coords = getOutputCoords(); - vec4 result = vec4(getValue(${coords}), 0., 0., 0.); - - ${coords[rank - 1]} = ${coords[rank - 1]} + 1; - if (${coords[rank - 1]} < ${shape[rank - 1]}) { - result.g = getValue(${coords}); - } - - ${coords[rank - 2]} = ${coords[rank - 2]} + 1; - if (${coords[rank - 2]} < ${shape[rank - 2]}) { - result.a = getValue(${coords}); - } - - ${coords[rank - 1]} = ${coords[rank - 1]} - 1; - if (${coords[rank - 2]} < ${shape[rank - 2]} && - ${coords[rank - 1]} < ${shape[rank - 1]}) { - result.b = getValue(${coords}); - } - setOutput(result); - } - `; - } -} - -/** - * Return an expression for coordinates into a vector where a given channel - * will be offset by [shift]. - * - * @param channels the channels to consider - * @param channel the channel we want shifted - * @param shift the amount to subtract from the channel. - * - * @returns a string of the form 'x, y-[shift], z' where any one channel can - * have the shift applied. - */ -function shiftedChannels(channels: string[], channel: string, shift: number) { - const channelIdx = channels.indexOf(channel); - const res = channels.map((c, idx) => { - if (idx === channelIdx) { - return `${c} - ${shift}`; - } else { - return c; - } - }); - return res.join(); -} diff --git a/tfjs-master/tfjs-backend-webgl/src/conv_backprop_gpu.ts b/tfjs-master/tfjs-backend-webgl/src/conv_backprop_gpu.ts deleted file mode 100644 index 21cb0e8ba..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/conv_backprop_gpu.ts +++ /dev/null @@ -1,295 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util} from '@tensorflow/tfjs-core'; -import {GPGPUProgram} from './gpgpu_math'; - -export class Conv2DDerFilterProgram implements GPGPUProgram { - variableNames = ['x', 'dy']; - outputShape: number[]; - userCode: string; - - constructor(convInfo: backend_util.Conv2DInfo) { - this.outputShape = convInfo.filterShape; - - const strideHeight = convInfo.strideHeight; - const strideWidth = convInfo.strideWidth; - const padTop = convInfo.padInfo.top; - const padLeft = convInfo.padInfo.left; - const isChannelsLast = convInfo.dataFormat === 'channelsLast'; - - this.userCode = ` - void main() { - ivec4 coords = getOutputCoords(); - int wR = coords.x; - int wC = coords.y; - int d1 = coords.z; - int d2 = coords.w; - - // Convolve x(?, ?, d1) with dy(:, :, d2) to get dw(wR, wC, d1, d2). - // ? = to be determined. : = across all values in that axis. - float dotProd = 0.0; - - for (int b = 0; b < ${convInfo.batchSize}; b++) { - for (int yR = 0; yR < ${convInfo.outHeight}; yR++) { - int xR = wR + yR * ${strideHeight} - ${padTop}; - - if (xR < 0 || xR >= ${convInfo.inHeight}) { - continue; - } - - for (int yC = 0; yC < ${convInfo.outWidth}; yC++) { - int xC = wC + yC * ${strideWidth} - ${padLeft}; - - if (xC < 0 || xC >= ${convInfo.inWidth}) { - continue; - } - - ${isChannelsLast? - `float dyValue = getDy(b, yR, yC, d2); - float xValue = getX(b, xR, xC, d1); - dotProd += (xValue * dyValue);` : - `float dyValue = getDy(b, d2, yR, yC); - float xValue = getX(b, d1, xR, xC); - dotProd += (xValue * dyValue);`} - } - } - } - setOutput(dotProd); - } - `; - } -} - -export class Conv2DDerInputProgram implements GPGPUProgram { - variableNames = ['dy', 'W']; - outputShape: number[]; - userCode: string; - - constructor(convInfo: backend_util.Conv2DInfo) { - this.outputShape = convInfo.inShape; - - const filterHeight = convInfo.filterHeight; - const filterWidth = convInfo.filterWidth; - const strideHeight = convInfo.strideHeight; - const strideWidth = convInfo.strideWidth; - const isChannelsLast = convInfo.dataFormat === 'channelsLast'; - - const padTop = filterHeight - 1 - convInfo.padInfo.top; - const padLeft = filterWidth - 1 - convInfo.padInfo.left; - - const rowDim = isChannelsLast ? 1 : 2; - const colDim = isChannelsLast ? 2 : 3; - const channelDim = isChannelsLast ? 3 : 1; - - this.userCode = ` - const ivec2 pads = ivec2(${padTop}, ${padLeft}); - - void main() { - ivec4 coords = getOutputCoords(); - int batch = coords[0]; - int d1 = coords[${channelDim}]; - - ivec2 dyCorner = ivec2(coords[${rowDim}], coords[${colDim}]) - pads; - int dyRCorner = dyCorner.x; - int dyCCorner = dyCorner.y; - - // Convolve dy(?, ?, d2) with w(:, :, d1, d2) to compute dx(xR, xC, d1). - // ? = to be determined. : = across all values in that axis. - float dotProd = 0.0; - for (int wR = 0; wR < ${filterHeight}; wR++) { - float dyR = float(dyRCorner + wR) / ${strideHeight}.0; - - if (dyR < 0.0 || dyR >= ${convInfo.outHeight}.0 || fract(dyR) > 0.0) { - continue; - } - int idyR = int(dyR); - - int wRPerm = ${filterHeight} - 1 - wR; - - for (int wC = 0; wC < ${filterWidth}; wC++) { - float dyC = float(dyCCorner + wC) / ${strideWidth}.0; - - if (dyC < 0.0 || dyC >= ${convInfo.outWidth}.0 || - fract(dyC) > 0.0) { - continue; - } - int idyC = int(dyC); - - int wCPerm = ${filterWidth} - 1 - wC; - - for (int d2 = 0; d2 < ${convInfo.outChannels}; d2++) { - - if (${isChannelsLast}) { - float xValue = getDy(batch, idyR, idyC, d2); - float wValue = getW(wRPerm, wCPerm, d1, d2); - dotProd += xValue * wValue; - } else { - float xValue = getDy(batch, d2, idyR, idyC); - float wValue = getW(wRPerm, wCPerm, d1, d2); - dotProd += xValue * wValue; - } - - } - } - } - setOutput(dotProd); - } - `; - } -} - -export class Conv3DDerFilterProgram implements GPGPUProgram { - variableNames = ['x', 'dy']; - outputShape: number[]; - userCode: string; - - constructor(convInfo: backend_util.Conv3DInfo) { - this.outputShape = convInfo.filterShape; - - const strideDepth = convInfo.strideDepth; - const strideHeight = convInfo.strideHeight; - const strideWidth = convInfo.strideWidth; - const padFront = convInfo.padInfo.front; - const padTop = convInfo.padInfo.top; - const padLeft = convInfo.padInfo.left; - - this.userCode = ` - void main() { - ivec5 coords = getOutputCoords(); - int wF = coords.x; - int wR = coords.y; - int wC = coords.z; - int d1 = coords.w; - int d2 = coords.u; - - float dotProd = 0.0; - - for (int b = 0; b < ${convInfo.batchSize}; b++) { - for (int yF = 0; yF < ${convInfo.outDepth}; yF++) { - int xF = wF + yF * ${strideDepth} - ${padFront}; - - if (xF < 0 || xF >= ${convInfo.inDepth}) { - continue; - } - - for (int yR = 0; yR < ${convInfo.outHeight}; yR++) { - int xR = wR + yR * ${strideHeight} - ${padTop}; - - if (xR < 0 || xR >= ${convInfo.inHeight}) { - continue; - } - - for (int yC = 0; yC < ${convInfo.outWidth}; yC++) { - int xC = wC + yC * ${strideWidth} - ${padLeft}; - - if (xC < 0 || xC >= ${convInfo.inWidth}) { - continue; - } - - float dyValue = getDy(b, yF, yR, yC, d2); - float xValue = getX(b, xF, xR, xC, d1); - dotProd += (xValue * dyValue); - } - } - } - } - setOutput(dotProd); - } - `; - } -} - -export class Conv3DDerInputProgram implements GPGPUProgram { - variableNames = ['dy', 'W']; - outputShape: number[]; - userCode: string; - - constructor(convInfo: backend_util.Conv3DInfo) { - this.outputShape = convInfo.inShape; - - const filterDepth = convInfo.filterDepth; - const filterHeight = convInfo.filterHeight; - const filterWidth = convInfo.filterWidth; - const strideDepth = convInfo.strideDepth; - const strideHeight = convInfo.strideHeight; - const strideWidth = convInfo.strideWidth; - - const padFront = filterDepth - 1 - convInfo.padInfo.front; - const padTop = filterHeight - 1 - convInfo.padInfo.top; - const padLeft = filterWidth - 1 - convInfo.padInfo.left; - - this.userCode = ` - const ivec3 pads = ivec3(${padFront}, ${padTop}, ${padLeft}); - - void main() { - ivec5 coords = getOutputCoords(); - int batch = coords.x; - int d1 = coords.u; - - - ivec3 dyCorner = ivec3(coords.y, coords.z, coords.w) - pads; - int dyFCorner = dyCorner.x; - int dyRCorner = dyCorner.y; - int dyCCorner = dyCorner.z; - - float dotProd = 0.0; - for (int wF = 0; wF < ${filterDepth}; wF++) { - float dyF = float(dyFCorner + wF) / ${strideDepth}.0; - - if (dyF < 0.0 || dyF >= ${convInfo.outDepth}.0 || fract(dyF) > 0.0) { - continue; - } - int idyF = int(dyF); - - int wFPerm = ${filterDepth} - 1 - wF; - - for (int wR = 0; wR < ${filterHeight}; wR++) { - float dyR = float(dyRCorner + wR) / ${strideHeight}.0; - - if (dyR < 0.0 || dyR >= ${convInfo.outHeight}.0 || - fract(dyR) > 0.0) { - continue; - } - int idyR = int(dyR); - - int wRPerm = ${filterHeight} - 1 - wR; - - for (int wC = 0; wC < ${filterWidth}; wC++) { - float dyC = float(dyCCorner + wC) / ${strideWidth}.0; - - if (dyC < 0.0 || dyC >= ${convInfo.outWidth}.0 || - fract(dyC) > 0.0) { - continue; - } - int idyC = int(dyC); - - int wCPerm = ${filterWidth} - 1 - wC; - - for (int d2 = 0; d2 < ${convInfo.outChannels}; d2++) { - float xValue = getDy(batch, idyF, idyR, idyC, d2); - float wValue = getW(wFPerm, wRPerm, wCPerm, d1, d2); - dotProd += xValue * wValue; - } - } - } - } - setOutput(dotProd); - } - `; - } -} diff --git a/tfjs-master/tfjs-backend-webgl/src/conv_backprop_gpu_depthwise.ts b/tfjs-master/tfjs-backend-webgl/src/conv_backprop_gpu_depthwise.ts deleted file mode 100644 index cf11e3dbf..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/conv_backprop_gpu_depthwise.ts +++ /dev/null @@ -1,138 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util} from '@tensorflow/tfjs-core'; -import {GPGPUProgram} from './gpgpu_math'; - -export class DepthwiseConv2DDerFilterProgram implements GPGPUProgram { - variableNames = ['x', 'dy']; - outputShape: number[]; - userCode: string; - - constructor(convInfo: backend_util.Conv2DInfo) { - this.outputShape = convInfo.filterShape; - - const strideHeight = convInfo.strideHeight; - const strideWidth = convInfo.strideWidth; - const padTop = convInfo.padInfo.top; - const padLeft = convInfo.padInfo.left; - const channelMul = convInfo.outChannels / convInfo.inChannels; - - this.userCode = ` - void main() { - ivec4 coords = getOutputCoords(); - int wR = coords.x; - int wC = coords.y; - int d1 = coords.z; - int dm = coords.w; - int d2 = d1 * ${channelMul} + dm; - - float dotProd = 0.0; - - // TO DO: Vec4 over the batch size - for (int b = 0; b < ${convInfo.batchSize}; b++) { - for (int yR = 0; yR < ${convInfo.outHeight}; yR++) { - int xR = wR + yR * ${strideHeight} - ${padTop}; - - if (xR < 0 || xR >= ${convInfo.inHeight}) { - continue; - } - - for (int yC = 0; yC < ${convInfo.outWidth}; yC++) { - int xC = wC + yC * ${strideWidth} - ${padLeft}; - - if (xC < 0 || xC >= ${convInfo.inWidth}) { - continue; - } - - float dyValue = getDy(b, yR, yC, d2); - float xValue = getX(b, xR, xC, d1); - dotProd += (xValue * dyValue); - } - } - } - setOutput(dotProd); - } - `; - } -} - -export class DepthwiseConv2DDerInputProgram implements GPGPUProgram { - variableNames = ['dy', 'W']; - outputShape: number[]; - userCode: string; - - constructor(convInfo: backend_util.Conv2DInfo) { - this.outputShape = convInfo.inShape; - - const filterHeight = convInfo.filterHeight; - const filterWidth = convInfo.filterWidth; - const strideHeight = convInfo.strideHeight; - const strideWidth = convInfo.strideWidth; - - const padTop = filterHeight - 1 - convInfo.padInfo.top; - const padLeft = filterWidth - 1 - convInfo.padInfo.left; - const channelMul = convInfo.outChannels / convInfo.inChannels; - - this.userCode = ` - const ivec2 pads = ivec2(${padTop}, ${padLeft}); - - void main() { - ivec4 coords = getOutputCoords(); - int batch = coords[0]; - int d1 = coords[3]; - ivec2 dyCorner = coords.yz - pads; - int dyRCorner = dyCorner.x; - int dyCCorner = dyCorner.y; - - float dotProd = 0.0; - - for (int wR = 0; wR < ${filterHeight}; wR++) { - float dyR = float(dyRCorner + wR) / ${strideHeight}.0; - - if (dyR < 0.0 || dyR >= ${convInfo.outHeight}.0 || fract(dyR) > 0.0) { - continue; - } - int idyR = int(dyR); - - int wRPerm = ${filterHeight} - 1 - wR; - - for (int wC = 0; wC < ${filterWidth}; wC++) { - float dyC = float(dyCCorner + wC) / ${strideWidth}.0; - - if (dyC < 0.0 || dyC >= ${convInfo.outWidth}.0 || - fract(dyC) > 0.0) { - continue; - } - int idyC = int(dyC); - - int wCPerm = ${filterWidth} - 1 - wC; - - // TO DO: Vec4 over the channelMul - for (int dm = 0; dm < ${channelMul}; dm++) { - int d2 = d1 * ${channelMul} + dm; - float xValue = getDy(batch, idyR, idyC, d2); - float wValue = getW(wRPerm, wCPerm, d1, dm); - dotProd += xValue * wValue; - } - } - } - setOutput(dotProd); - } - `; - } -} diff --git a/tfjs-master/tfjs-backend-webgl/src/conv_backprop_packed_gpu.ts b/tfjs-master/tfjs-backend-webgl/src/conv_backprop_packed_gpu.ts deleted file mode 100644 index 059d17fa3..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/conv_backprop_packed_gpu.ts +++ /dev/null @@ -1,118 +0,0 @@ -/** - * @license - * Copyright 2023 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util} from '@tensorflow/tfjs-core'; -import {GPGPUProgram, useShapeUniforms} from './gpgpu_math'; - -export class Conv2DDerInputPackedProgram implements GPGPUProgram { - variableNames = ['dy', 'W']; - packedInputs = true; - packedOutput = true; - outputShape: number[]; - userCode: string; - enableShapeUniforms: boolean; - customUniforms = [ - {name: 'strides', type: 'vec2' as const }, - ]; - - constructor(convInfo: backend_util.Conv2DInfo) { - this.outputShape = convInfo.inShape; - this.enableShapeUniforms = useShapeUniforms(this.outputShape.length); - - const filterHeight = convInfo.filterHeight; - const filterWidth = convInfo.filterWidth; - - const padTop = filterHeight - 1 - convInfo.padInfo.top; - const padLeft = filterWidth - 1 - convInfo.padInfo.left; - - this.userCode = ` - const ivec2 pads = ivec2(${padTop}, ${padLeft}); - - void main() { - ivec4 coords = getOutputCoords(); - int batch = coords[0]; - int d1 = coords[3]; - - ivec2 dyCorner = ivec2(coords[1], coords[2]) - pads; - int dyRCorner = dyCorner.x; - int dyCCorner = dyCorner.y; - - vec4 result = vec4(0.); - for (int wR = 0; wR < ${filterHeight}; wR++) { - float dyR = float(dyRCorner + wR) / strides[0]; - if (dyR < 0.0 || dyR >= ${convInfo.outHeight}.0 || fract(dyR) > 0.0) { - continue; - } - int idyR = int(dyR); - int wRPerm = ${filterHeight} - 1 - wR; - - for (int wC = 0; wC < ${filterWidth}; wC++) { - int wCPerm = ${filterWidth} - 1 - wC; - - float dyC = float(dyCCorner + wC) / strides[1]; - bool idyCVal = (dyC >= 0.0) && (dyC < ${convInfo.outWidth}.0) - && (fract(dyC) == 0.0); - int idyC = int(dyC); - - float dyC2 = float(dyCCorner + wC + 1) / strides[1]; - bool idyCVal2 = (dyC2 >= 0.0) && (dyC2 < ${convInfo.outWidth}.0) - && (fract(dyC2) == 0.0); - int idyC2 = int(dyC2); - - if (idyCVal && idyCVal2) { - for (int d2 = 0; d2 < ${convInfo.outChannels}; d2 += 2) { - vec4 wValue = getW(wRPerm, wCPerm, d1, d2); - vec4 dySample = getDy(batch, idyR, idyC, d2); - vec4 dySample2 = (idyC / 2 == idyC2 / 2) ? - dySample : getDy(batch, idyR, idyC2, d2); - - vec2 dyValue = mod(float(idyC), 2.) == 0. ? - dySample.xy : dySample.zw; - result.xy += vec2(dot(dyValue, wValue.xy), - dot(dyValue, wValue.zw)); - - dyValue = mod(float(idyC2), 2.) == 0. ? - dySample2.xy : dySample2.zw; - result.zw += vec2(dot(dyValue, wValue.xy), - dot(dyValue, wValue.zw)); - } - } else if (idyCVal) { - for (int d2 = 0; d2 < ${convInfo.outChannels}; d2 += 2) { - vec4 wValue = getW(wRPerm, wCPerm, d1, d2); - vec4 dySample = getDy(batch, idyR, idyC, d2); - vec2 dyValue = mod(float(idyC), 2.) == 0. ? - dySample.xy : dySample.zw; - result.xy += vec2(dot(dyValue, wValue.xy), - dot(dyValue, wValue.zw)); - } - } else if (idyCVal2) { - for (int d2 = 0; d2 < ${convInfo.outChannels}; d2 += 2) { - vec4 wValue = getW(wRPerm, wCPerm, d1, d2); - vec4 dySample = getDy(batch, idyR, idyC2, d2); - vec2 dyValue = mod(float(idyC2), 2.) == 0. ? - dySample.xy : dySample.zw; - result.zw += vec2(dot(dyValue, wValue.xy), - dot(dyValue, wValue.zw)); - } - } - } - } - setOutput(result); - } - `; - } -} diff --git a/tfjs-master/tfjs-backend-webgl/src/conv_gpu.ts b/tfjs-master/tfjs-backend-webgl/src/conv_gpu.ts deleted file mode 100644 index b998e08be..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/conv_gpu.ts +++ /dev/null @@ -1,326 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util} from '@tensorflow/tfjs-core'; -import {GPGPUProgram} from './gpgpu_math'; - -export class Conv2DProgram implements GPGPUProgram { - variableNames = ['x', 'W']; - outputShape: number[]; - userCode: string; - - constructor( - convInfo: backend_util.Conv2DInfo, addBias = false, - activation: string = null, hasPreluActivationWeights = false, - hasLeakyreluAlpha = false) { - this.outputShape = convInfo.outShape; - const padTop = convInfo.padInfo.top; - const padLeft = convInfo.padInfo.left; - const strideHeight = convInfo.strideHeight; - const strideWidth = convInfo.strideWidth; - const dilationHeight = convInfo.dilationHeight; - const dilationWidth = convInfo.dilationWidth; - const filterHeight = convInfo.filterHeight; - const filterWidth = convInfo.filterWidth; - - const inputDepthNearestVec4 = Math.floor(convInfo.inChannels / 4) * 4; - const inputDepthVec4Remainder = convInfo.inChannels % 4; - const isChannelsLast = convInfo.dataFormat === 'channelsLast'; - - const rowDim = isChannelsLast ? 1 : 2; - const colDim = isChannelsLast ? 2 : 3; - const channelDim = isChannelsLast ? 3 : 1; - - let activationSnippet = '', applyActivationSnippet = ''; - if (activation) { - if (hasPreluActivationWeights) { - activationSnippet = `float activation(float a) { - float b = getPreluActivationWeightsAtOutCoords(); - ${activation} - }`; - } else if (hasLeakyreluAlpha) { - activationSnippet = `float activation(float a) { - float b = getLeakyreluAlphaAtOutCoords(); - ${activation} - }`; - } else { - activationSnippet = ` - float activation(float x) { - ${activation} - } - `; - } - - applyActivationSnippet = `result = activation(result);`; - } - - const addBiasSnippet = addBias ? 'result += getBiasAtOutCoords();' : ''; - if (addBias) { - this.variableNames.push('bias'); - } - - if (hasPreluActivationWeights) { - this.variableNames.push('preluActivationWeights'); - } - - if (hasLeakyreluAlpha) { - this.variableNames.push('leakyreluAlpha'); - } - - this.userCode = ` - ${activationSnippet} - - const ivec2 strides = ivec2(${strideHeight}, ${strideWidth}); - const ivec2 pads = ivec2(${padTop}, ${padLeft}); - - void main() { - ivec4 coords = getOutputCoords(); - int batch = coords[0]; - int d2 = coords[${channelDim}]; - - ivec2 xRCCorner = - ivec2(coords[${rowDim}], coords[${colDim}]) * strides - pads; - int xRCorner = xRCCorner.x; - int xCCorner = xRCCorner.y; - - // Convolve x(?, ?, d1) with w(:, :, d1, d2) to get y(yR, yC, d2). - // ? = to be determined. : = across all values in that axis. - float dotProd = 0.0; - for (int wR = 0; wR < ${filterHeight}; wR++) { - int xR = xRCorner + wR * ${dilationHeight}; - - if (xR < 0 || xR >= ${convInfo.inHeight}) { - continue; - } - - for (int wC = 0; wC < ${filterWidth}; wC++) { - int xC = xCCorner + wC * ${dilationWidth}; - - if (xC < 0 || xC >= ${convInfo.inWidth}) { - continue; - } - - for (int d1 = 0; d1 < ${inputDepthNearestVec4}; d1 += 4) { - vec4 wValues = vec4( - getW(wR, wC, d1, d2), - getW(wR, wC, d1 + 1, d2), - getW(wR, wC, d1 + 2, d2), - getW(wR, wC, d1 + 3, d2) - ); - - if (${isChannelsLast}) { - vec4 xValues = vec4( - getX(batch, xR, xC, d1), - getX(batch, xR, xC, d1 + 1), - getX(batch, xR, xC, d1 + 2), - getX(batch, xR, xC, d1 + 3) - ); - dotProd += dot(xValues, wValues); - } else { - vec4 xValues = vec4( - getX(batch, d1, xR, xC), - getX(batch, d1 + 1, xR, xC), - getX(batch, d1 + 2, xR, xC), - getX(batch, d1 + 3, xR, xC) - ); - dotProd += dot(xValues, wValues); - } - } - - if (${inputDepthVec4Remainder === 1}) { - - if (${isChannelsLast}) { - dotProd += - getX(batch, xR, xC, ${inputDepthNearestVec4}) * - getW(wR, wC, ${inputDepthNearestVec4}, d2); - } else { - dotProd += - getX(batch, ${inputDepthNearestVec4}, xR, xC) * - getW(wR, wC, ${inputDepthNearestVec4}, d2); - } - - } else if (${inputDepthVec4Remainder === 2}) { - vec2 wValues = vec2( - getW(wR, wC, ${inputDepthNearestVec4}, d2), - getW(wR, wC, ${inputDepthNearestVec4} + 1, d2) - ); - - if (${isChannelsLast}) { - vec2 xValues = vec2( - getX(batch, xR, xC, ${inputDepthNearestVec4}), - getX(batch, xR, xC, ${inputDepthNearestVec4} + 1) - ); - dotProd += dot(xValues, wValues); - } else { - vec2 xValues = vec2( - getX(batch, ${inputDepthNearestVec4}, xR, xC), - getX(batch, ${inputDepthNearestVec4} + 1, xR, xC) - ); - dotProd += dot(xValues, wValues); - } - - } else if (${inputDepthVec4Remainder === 3}) { - vec3 wValues = vec3( - getW(wR, wC, ${inputDepthNearestVec4}, d2), - getW(wR, wC, ${inputDepthNearestVec4} + 1, d2), - getW(wR, wC, ${inputDepthNearestVec4} + 2, d2) - ); - - if (${isChannelsLast}) { - vec3 xValues = vec3( - getX(batch, xR, xC, ${inputDepthNearestVec4}), - getX(batch, xR, xC, ${inputDepthNearestVec4} + 1), - getX(batch, xR, xC, ${inputDepthNearestVec4} + 2) - ); - dotProd += dot(xValues, wValues); - } else { - vec3 xValues = vec3( - getX(batch, ${inputDepthNearestVec4}, xR, xC), - getX(batch, ${inputDepthNearestVec4} + 1, xR, xC), - getX(batch, ${inputDepthNearestVec4} + 2, xR, xC) - ); - dotProd += dot(xValues, wValues); - } - - } - } - } - - float result = dotProd; - ${addBiasSnippet} - ${applyActivationSnippet} - setOutput(result); - } - `; - } -} - -export class Conv3DProgram implements GPGPUProgram { - variableNames = ['x', 'W']; - outputShape: number[]; - userCode: string; - - constructor(convInfo: backend_util.Conv3DInfo) { - this.outputShape = convInfo.outShape; - const padFront = convInfo.padInfo.front; - const padTop = convInfo.padInfo.top; - const padLeft = convInfo.padInfo.left; - const strideDepth = convInfo.strideDepth; - const strideHeight = convInfo.strideHeight; - const strideWidth = convInfo.strideWidth; - const dilationDepth = convInfo.dilationDepth; - const dilationHeight = convInfo.dilationHeight; - const dilationWidth = convInfo.dilationWidth; - const filterDepth = convInfo.filterDepth; - const filterHeight = convInfo.filterHeight; - const filterWidth = convInfo.filterWidth; - - const inputDepthNearestVec4 = Math.floor(convInfo.inChannels / 4) * 4; - const inputDepthVec4Remainder = convInfo.inChannels % 4; - - this.userCode = ` - const ivec3 strides = ivec3(${strideDepth}, ${strideHeight}, ${ - strideWidth}); - const ivec3 pads = ivec3(${padFront}, ${padTop}, ${padLeft}); - - void main() { - ivec5 coords = getOutputCoords(); - int batch = coords.x; - int d2 = coords.u; - - ivec3 xFRCCorner = ivec3(coords.y, coords.z, coords.w) * strides - pads; - int xFCorner = xFRCCorner.x; - int xRCorner = xFRCCorner.y; - int xCCorner = xFRCCorner.z; - - // Convolve x(?, ?, ?, d1) with w(:, :, :, d1, d2) to get - // y(yF, yR, yC, d2). ? = to be determined. : = across all - // values in that axis. - float dotProd = 0.0; - for (int wF = 0; wF < ${filterDepth}; wF++) { - int xF = xFCorner + wF * ${dilationDepth}; - - if (xF < 0 || xF >= ${convInfo.inDepth}) { - continue; - } - - for (int wR = 0; wR < ${filterHeight}; wR++) { - int xR = xRCorner + wR * ${dilationHeight}; - - if (xR < 0 || xR >= ${convInfo.inHeight}) { - continue; - } - - for (int wC = 0; wC < ${filterWidth}; wC++) { - int xC = xCCorner + wC * ${dilationWidth}; - - if (xC < 0 || xC >= ${convInfo.inWidth}) { - continue; - } - - for (int d1 = 0; d1 < ${inputDepthNearestVec4}; d1 += 4) { - vec4 xValues = vec4( - getX(batch, xF, xR, xC, d1), - getX(batch, xF, xR, xC, d1 + 1), - getX(batch, xF, xR, xC, d1 + 2), - getX(batch, xF, xR, xC, d1 + 3) - ); - vec4 wValues = vec4( - getW(wF, wR, wC, d1, d2), - getW(wF, wR, wC, d1 + 1, d2), - getW(wF, wR, wC, d1 + 2, d2), - getW(wF, wR, wC, d1 + 3, d2) - ); - - dotProd += dot(xValues, wValues); - } - - if (${inputDepthVec4Remainder === 1}) { - dotProd += - getX(batch, xF, xR, xC, ${inputDepthNearestVec4}) * - getW(wF, wR, wC, ${inputDepthNearestVec4}, d2); - } else if (${inputDepthVec4Remainder === 2}) { - vec2 xValues = vec2( - getX(batch, xF, xR, xC, ${inputDepthNearestVec4}), - getX(batch, xF, xR, xC, ${inputDepthNearestVec4} + 1) - ); - vec2 wValues = vec2( - getW(wF, wR, wC, ${inputDepthNearestVec4}, d2), - getW(wF, wR, wC, ${inputDepthNearestVec4} + 1, d2) - ); - dotProd += dot(xValues, wValues); - } else if (${inputDepthVec4Remainder === 3}) { - vec3 xValues = vec3( - getX(batch, xF, xR, xC, ${inputDepthNearestVec4}), - getX(batch, xF, xR, xC, ${inputDepthNearestVec4} + 1), - getX(batch, xF, xR, xC, ${inputDepthNearestVec4} + 2) - ); - vec3 wValues = vec3( - getW(wF, wR, wC, ${inputDepthNearestVec4}, d2), - getW(wF, wR, wC, ${inputDepthNearestVec4} + 1, d2), - getW(wF, wR, wC, ${inputDepthNearestVec4} + 2, d2) - ); - dotProd += dot(xValues, wValues); - } - } - } - } - setOutput(dotProd); - } - `; - } -} diff --git a/tfjs-master/tfjs-backend-webgl/src/conv_gpu_depthwise.ts b/tfjs-master/tfjs-backend-webgl/src/conv_gpu_depthwise.ts deleted file mode 100644 index a4d13539d..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/conv_gpu_depthwise.ts +++ /dev/null @@ -1,124 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util} from '@tensorflow/tfjs-core'; -import {GPGPUProgram, useShapeUniforms} from './gpgpu_math'; - -export class DepthwiseConv2DProgram implements GPGPUProgram { - variableNames = ['x', 'W']; - outputShape: number[]; - userCode: string; - enableShapeUniforms: boolean; - customUniforms = [ - {name: 'pads', type: 'ivec2' as const }, - {name: 'strides', type: 'ivec2' as const }, - {name: 'dilations', type: 'ivec2' as const }, - {name: 'inDims', type: 'ivec2' as const }, - ]; - - constructor( - convInfo: backend_util.Conv2DInfo, addBias = false, - activation: string = null, hasPreluActivation = false, - hasLeakyReluAlpha = false) { - this.outputShape = convInfo.outShape; - this.enableShapeUniforms = useShapeUniforms(this.outputShape.length); - - const filterHeight = convInfo.filterHeight; - const filterWidth = convInfo.filterWidth; - const channelMul = convInfo.outChannels / convInfo.inChannels; - - let activationSnippet = '', applyActivationSnippet = ''; - if (activation) { - if (hasPreluActivation) { - activationSnippet = `float activation(float a) { - float b = getPreluActivationWeightsAtOutCoords(); - ${activation} - }`; - } else if (hasLeakyReluAlpha) { - activationSnippet = `float activation(float a) { - float b = getLeakyreluAlphaAtOutCoords(); - ${activation} - }`; - } else { - activationSnippet = ` - float activation(float x) { - ${activation} - } - `; - } - - applyActivationSnippet = `result = activation(result);`; - } - - const addBiasSnippet = addBias ? 'result += getBiasAtOutCoords();' : ''; - if (addBias) { - this.variableNames.push('bias'); - } - - if (hasPreluActivation) { - this.variableNames.push('preluActivationWeights'); - } - if (hasLeakyReluAlpha) { - this.variableNames.push('leakyreluAlpha'); - } - - this.userCode = ` - ${activationSnippet} - - void main() { - ivec4 coords = getOutputCoords(); - int batch = coords.x; - ivec2 xRCCorner = coords.yz * strides - pads; - int d2 = coords.w; - int d1 = d2 / ${channelMul}; - int q = d2 - d1 * ${channelMul}; - - int xRCorner = xRCCorner.x; - int xCCorner = xRCCorner.y; - - // Convolve x(?, ?, d1) with w(:, :, d1, q) to get y(yR, yC, d2). - // ? = to be determined. : = across all values in that axis. - float dotProd = 0.0; - // TO DO(dsmilkov): Flatten the two for loops and vec4 the operations. - for (int wR = 0; wR < ${filterHeight}; wR++) { - int xR = xRCorner + wR * dilations[0]; - - if (xR < 0 || xR >= inDims[0]) { - continue; - } - - for (int wC = 0; wC < ${filterWidth}; wC++) { - int xC = xCCorner + wC * dilations[1]; - - if (xC < 0 || xC >= inDims[1]) { - continue; - } - - float xVal = getX(batch, xR, xC, d1); - float wVal = getW(wR, wC, d1, q); - dotProd += xVal * wVal; - } - } - - float result = dotProd; - ${addBiasSnippet} - ${applyActivationSnippet} - setOutput(result); - } - `; - } -} diff --git a/tfjs-master/tfjs-backend-webgl/src/conv_packed_gpu.ts b/tfjs-master/tfjs-backend-webgl/src/conv_packed_gpu.ts deleted file mode 100644 index 12154dfcd..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/conv_packed_gpu.ts +++ /dev/null @@ -1,411 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - - import {backend_util, util} from '@tensorflow/tfjs-core'; - - import {GPGPUProgram, useShapeUniforms} from './gpgpu_math'; - - export class Conv2DPackedProgram implements GPGPUProgram { - variableNames = ['x', 'W']; - packedInputs = true; - packedOutput = true; - outputShape: number[]; - userCode: string; - enableShapeUniforms: boolean; - customUniforms = [ - {name: 'pads', type: 'ivec2' as const }, - {name: 'strides', type: 'ivec2' as const }, - {name: 'dilations', type: 'ivec2' as const }, - {name: 'inDims', type: 'ivec2' as const }, - ]; - - constructor( - convInfo: backend_util.Conv2DInfo, addBias = false, - activation: string = null, hasPreluActivation = false, - hasLeakyReluAlpha = false) { - this.outputShape = convInfo.outShape; - this.enableShapeUniforms = useShapeUniforms(this.outputShape.length); - const padLeft = convInfo.padInfo.left; - const strideWidth = convInfo.strideWidth; - const dilationWidth = convInfo.dilationWidth; - const filterHeight = convInfo.filterHeight; - const filterWidth = convInfo.filterWidth; - const texelsAcross = filterWidth; - - let mainLoop = ` - int xR; int xC; int xCOffset; - vec4 wTexel; vec4 previous; vec4 final;`; - - for (let c = 0; c < filterWidth; c++) { - mainLoop += ` - vec4 xTexelC${c * 2}; - int xTexelC${c * 2}Ready; - vec4 xTexelC${c * 2 + 1}; - int xTexelC${c * 2 + 1}Ready; - vec4 xC${c};`; - } - - /** - * This vectorized implementation works by gathering the values needed for - * each output channel's dot product into vec4's and then multiplying them - * all together (this happens in the final double for-loop below). Most of - * the main loop consists of constructing these vec4's with the minimum - * number of texture2D calls, which means making use of all four returned - * values from a texture2D call at once. - */ - mainLoop += ` - for (int r = 0; r < ${filterHeight}; r++) { - for (int d1 = 0; d1 < ${convInfo.inChannels}; d1 += 2) { - `; - for (let c = 0; c < filterWidth; c++) { - mainLoop += ` - xTexelC${c * 2} = vec4(0.0); - xTexelC${c * 2}Ready = 0; - xTexelC${c * 2 + 1} = vec4(0.0); - xTexelC${c * 2 + 1}Ready = 0; - xC${c} = vec4(0.0);`; - } - mainLoop += ` - xR = xRCorner + r * dilations[0]; - if (xR >=0 && xR < inDims[0]) { - `; - - for (let texelC = 0; texelC < (texelsAcross + 1) / 2; texelC++) { - const colIndex = texelC * 2; - - mainLoop += ` - xC = xCCorner + ${colIndex * dilationWidth}; - `; - - if (strideWidth === 1) { - if (colIndex < filterWidth) { - // If padding is odd, the outer texels have to be composed. - if (padLeft % 2 === 1) { - // TODO: Ensure vec4 previous does not result in redundant sample, - // and avoid setting xTexelRC's that exceed the boundary in the - // first place rather than resetting them to vec4(0)). - - // To compute xCOffset: - // - If padding is odd, we must add 1 to ensure we ask for an - // even-numbered row. - // - We subtract 2 to access the previous texel. - - mainLoop += ` - xCOffset = xC + 1; - if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${ - colIndex}Ready == 0) { - xTexelC${colIndex} = getX(batch, xR, xCOffset, d1); - - // Need to manually clear unused channels in case - // we're reading from recycled texture. - if (xCOffset + 1 >= inDims[1]) { - xTexelC${colIndex}.zw = vec2(0.0); - } - xTexelC${colIndex}Ready = 1; - } - `; - // This texel has been read in previous iteration if the dilation - // is 1. - if (dilationWidth === 1 && colIndex > 0) { - mainLoop += ` - xC${colIndex} = vec4(xTexelC${colIndex - 2}.zw, xTexelC${ - colIndex}.xy); - `; - } else { - mainLoop += ` - xCOffset = xC + 1 - 2; - - if (xCOffset >= 0 && xCOffset < inDims[1]) { - previous = getX(batch, xR, xCOffset, d1); - - // Need to manually clear unused channels in case - // we're reading from recycled texture. - if (xCOffset + 1 >= inDims[1]) { - previous.zw = vec2(0.0); - } - - xC${colIndex} = vec4(previous.zw, xTexelC${colIndex}.xy); - } else { - xC${colIndex} = vec4(0.0, 0.0, xTexelC${colIndex}.xy); - } - `; - } - } else { - // Padding is even, so xRC corresponds to a single texel. - mainLoop += ` - if (xC >= 0 && xC < inDims[1] && xTexelC${colIndex}Ready == 0) { - xTexelC${colIndex} = getX(batch, xR, xC, d1); - if (xC + 1 >= inDims[1]) { - xTexelC${colIndex}.zw = vec2(0.0); - } - xTexelC${colIndex}Ready = 1; - } - - xC${colIndex} = xTexelC${colIndex}; - `; - } - - if (colIndex + 1 < filterWidth) { - // If dilation is even, the second entry should match the first - // (either both are composed or both are single samples). But if - // dilation is odd, then the second entry should be the opposite - // of the first (if the first is composed, the second is a single - // sample, and vice versa.) - - const nextTexelOffset = padLeft % 2 === 0 ? - util.nearestLargerEven(dilationWidth) : - dilationWidth; - - if ((dilationWidth % 2 === 0 && padLeft % 2 === 1) || - (dilationWidth % 2 !== 0 && padLeft % 2 !== 1)) { - mainLoop += ` - xCOffset = xC + imod(pads[1], 2) + ${nextTexelOffset}; - - if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${ - colIndex + 1}Ready == 0) { - xTexelC${colIndex + 1} = getX(batch, xR, xCOffset, d1); - - // Need to manually clear unused channels in case - // we're reading from recycled texture. - if (xCOffset + 1 >= inDims[1]) { - xTexelC${colIndex + 1}.zw = vec2(0.0); - } - xTexelC${colIndex + 1}Ready = 1; - } - `; - - // If dilation > 1 then the xRC's will not be able to share any - // values, so each xRC will require two unique calls to getX. - if (dilationWidth > 1) { - mainLoop += ` - xCOffset -= 2; - if (xCOffset >= 0 && xCOffset < inDims[1]) { - previous = getX(batch, xR, xCOffset, d1); - xC${colIndex + 1} = vec4(previous.zw, xTexelC${ - colIndex + 1}.xy); - } else { - xC${colIndex + 1} = vec4(0.0, 0.0, xTexelC${ - colIndex + 1}.xy); - } - `; - } else { - mainLoop += ` - xC${colIndex + 1} = vec4(xTexelC${colIndex}.zw, xTexelC${ - colIndex + 1}.xy); - `; - } - - } else { - // If dilation is 1 and padding is odd, we have already read the - // texel when constructing the previous x value. Here we can - // simply skip the texture read. - if (nextTexelOffset === 1) { - mainLoop += ` - xC${colIndex + 1} = xTexelC${colIndex}; - `; - } else { - mainLoop += ` - xCOffset = xC + ${nextTexelOffset}; - - if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${ - colIndex + 1}Ready == 0) { - xTexelC${colIndex + 1} = getX(batch, xR, xCOffset, d1); - if (xCOffset + 1 >= inDims[1]) { - xTexelC${colIndex + 1}.zw = vec2(0.0); - } - xTexelC${colIndex + 1}Ready = 1; - } - - xC${colIndex + 1} = xTexelC${colIndex + 1}; - `; - } - } - } - } - } else { // stride === 2 - if (colIndex < filterWidth) { - // Depending on whether padLeft is even or odd, we want either the - // xy or zw channels from X texels for xC${colIndex}. If padLeft is - // even, xC${colIndex +1} is simply the zw channels of texels we've - // already sampled. But if padLeft is odd, xC{$c + 1}.zw will - // need to come from the xy channels of a new texel, hence the ` - // vec4 - // final` initialized below. - if (padLeft % 2 === 1) { - mainLoop += ` - xCOffset = xC + 1 - strides[1]; - if(xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${ - colIndex}Ready == 0) { - xTexelC${colIndex} = getX(batch, xR, xCOffset, d1); - // Need to manually clear unused channels in case - // we're reading from recycled texture. - if (xCOffset + 1 >= inDims[1]) { - xTexelC${colIndex}.zw = vec2(0.0); - } - xTexelC${colIndex}Ready = 1; - } - - if(xC + 1 >= 0 && xC + 1 < inDims[1] && xTexelC${ - colIndex + 1}Ready == 0) { - xTexelC${colIndex + 1} = getX(batch, xR, xC + 1, d1); - // Need to manually clear unused channels in case - // we're reading from recycled texture. - if (xC + 2 >= inDims[1]) { - xTexelC${colIndex + 1}.zw = vec2(0.0); - } - xTexelC${colIndex + 1}Ready = 1; - } - - xC${colIndex} = vec4(xTexelC${colIndex}.zw, xTexelC${ - colIndex + 1}.zw); - `; - - if (colIndex + 1 < filterWidth) { - mainLoop += ` - final = vec4(0.0); - xCOffset = xC + 1 + strides[1]; - if(xCOffset >= 0 && xCOffset < inDims[1]) { - final = getX(batch, xR, xCOffset, d1); - } - xC${colIndex + 1} = vec4(xTexelC${colIndex + 1}.xy, final.xy); - `; - } - } else { - mainLoop += ` - if(xC >= 0 && xC < inDims[1] && xTexelC${colIndex}Ready == 0) { - xTexelC${colIndex} = getX(batch, xR, xC, d1); - if (xC + 1 >= inDims[1]) { - xTexelC${colIndex}.zw = vec2(0.0); - } - xTexelC${colIndex}Ready = 1; - } - - xCOffset = xC + strides[1]; - if(xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${ - colIndex + 1}Ready == 0) { - xTexelC${colIndex + 1} = getX(batch, xR, xCOffset, d1); - if (xCOffset + 1 >= inDims[1]) { - xTexelC${colIndex + 1}.zw = vec2(0.); - } - xTexelC${colIndex + 1}Ready = 1; - } - - xC${colIndex} = vec4( - xTexelC${colIndex}.xy, xTexelC${colIndex + 1}.xy); - `; - - if (colIndex + 1 < filterWidth) { - mainLoop += ` - xC${colIndex + 1} = vec4(xTexelC${colIndex}.zw, xTexelC${ - colIndex + 1}.zw); - `; - } - } - } - } - - // localize the dotProd accumulation within the loop, the theory is for - // GPU with limited cache, accumulate sum across large amount of - // veriables will cause lots of cache misses. (i.e. 5x5 filter will have - // 50 variables) - if (colIndex < filterWidth) { - mainLoop += ` - wTexel = getW(r, ${colIndex}, d1, d2); - dotProd += xC${colIndex}.xxzz * vec4(wTexel.xy, wTexel.xy); - if(d1 + 1 < ${convInfo.inChannels}) { - dotProd += xC${colIndex}.yyww * vec4(wTexel.zw, wTexel.zw); - } - `; - - if (colIndex + 1 < filterWidth) { - mainLoop += ` - wTexel = getW(r, ${colIndex + 1}, d1, d2); - dotProd += xC${colIndex + 1}.xxzz * vec4(wTexel.xy, wTexel.xy); - if(d1 + 1 < ${convInfo.inChannels}) { - dotProd += xC${colIndex + 1}.yyww * vec4(wTexel.zw, wTexel.zw); - } - `; - } - } - } - mainLoop += ` - } - `; - mainLoop += ` - } - `; - mainLoop += ` - } - `; - - let activationSnippet = '', applyActivationSnippet = ''; - if (activation) { - if (hasPreluActivation) { - activationSnippet = `vec4 activation(vec4 a) { - vec4 b = getPreluActivationWeightsAtOutCoords(); - ${activation} - }`; - } else if (hasLeakyReluAlpha) { - activationSnippet = `vec4 activation(vec4 a) { - vec4 b = getLeakyreluAlphaAtOutCoords(); - ${activation} - }`; - } else { - activationSnippet = `vec4 activation(vec4 x) { - ${activation} - }`; - } - - applyActivationSnippet = `result = activation(result);`; - } - - const addBiasSnippet = addBias ? 'result += getBiasAtOutCoords();' : ''; - if (addBias) { - this.variableNames.push('bias'); - } - - if (hasPreluActivation) { - this.variableNames.push('preluActivationWeights'); - } - if (hasLeakyReluAlpha) { - this.variableNames.push('leakyreluAlpha'); - } - - this.userCode = ` - ${activationSnippet} - - void main() { - ivec4 coords = getOutputCoords(); - int batch = coords.x; - ivec2 xRCCorner = coords.yz * strides - pads; - int d2 = coords.w; - int xRCorner = xRCCorner.x; - int xCCorner = xRCCorner.y; - - //intialize dotProd with a small epsilon seems to reduce GPU accuracy loss. - vec4 dotProd = vec4(0.000000000000001); - - ${mainLoop} - - vec4 result = dotProd - vec4(0.000000000000001); - ${addBiasSnippet} - ${applyActivationSnippet} - setOutput(result); - } - `; - } - } diff --git a/tfjs-master/tfjs-backend-webgl/src/conv_packed_gpu_depthwise.ts b/tfjs-master/tfjs-backend-webgl/src/conv_packed_gpu_depthwise.ts deleted file mode 100644 index 8a66f865c..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/conv_packed_gpu_depthwise.ts +++ /dev/null @@ -1,403 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, util} from '@tensorflow/tfjs-core'; - -import {GPGPUProgram, useShapeUniforms} from './gpgpu_math'; - -export class DepthwiseConvPacked2DProgram implements GPGPUProgram { - variableNames = ['x', 'W']; - packedInputs = true; - packedOutput = true; - outputShape: number[]; - userCode: string; - enableShapeUniforms: boolean; - customUniforms = [ - {name: 'pads', type: 'ivec2' as const }, - {name: 'strides', type: 'ivec2' as const }, - {name: 'dilations', type: 'ivec2' as const }, - {name: 'inDims', type: 'ivec2' as const }, - ]; - - constructor( - convInfo: backend_util.Conv2DInfo, addBias = false, - activation: string = null, hasPreluActivation = false, - hasLeakyReluAlpha = false) { - this.outputShape = convInfo.outShape; - this.enableShapeUniforms = useShapeUniforms(this.outputShape.length); - const channelMul = convInfo.outChannels / convInfo.inChannels; - const padLeft = convInfo.padInfo.left; - const strideWidth = convInfo.strideWidth; - const dilationWidth = convInfo.dilationWidth; - const filterHeight = convInfo.filterHeight; - const filterWidth = convInfo.filterWidth; - const texelsAcross = filterWidth; - - let mainLoop = ` - int xR; int xC; int xCOffset; - vec4 wTexel; vec4 previous; vec4 final;`; - - for (let c = 0; c < filterWidth; c++) { - mainLoop += ` - vec4 xTexelC${c * 2}; - int xTexelC${c * 2}Ready; - vec4 xTexelC${c * 2 + 1}; - int xTexelC${c * 2 + 1}Ready; - vec4 xC${c};`; - } - - /** - * This vectorized implementation works by gathering the values needed for - * each output channel's dot product into vec4's and then multiplying them - * all together (this happens in the final double for-loop below). Most of - * the main loop consists of constructing these vec4's with the minimum - * number of texture2D calls, which means making use of all four returned - * values from a texture2D call at once. - */ - mainLoop += ` - for (int r = 0; r < ${filterHeight}; r++) { - `; - for (let c = 0; c < filterWidth; c++) { - mainLoop += ` - xTexelC${c * 2} = vec4(0.0); - xTexelC${c * 2}Ready = 0; - xTexelC${c * 2 + 1} = vec4(0.0); - xTexelC${c * 2 + 1}Ready = 0; - xC${c} = vec4(0.0);`; - } - mainLoop += ` - xR = xRCorner + r * dilations[0]; - if (xR >=0 && xR < inDims[0]) { - `; - - for (let texelC = 0; texelC < (texelsAcross + 1) / 2; texelC++) { - const colIndex = texelC * 2; - - mainLoop += ` - xC = xCCorner + ${colIndex * dilationWidth}; - `; - - if (strideWidth === 1) { - if (colIndex < filterWidth) { - // If padding is odd, the outer texels have to be composed. - if (padLeft % 2 === 1) { - // TODO: Ensure vec4 previous does not result in redundant sample, - // and avoid setting xTexelRC's that exceed the boundary in the - // first place rather than resetting them to vec4(0)). - - // To compute xCOffset: - // - If padding is odd, we must add 1 to ensure we ask for an - // even-numbered row. - // - We subtract 2 to access the previous texel. - - mainLoop += ` - xCOffset = xC + 1; - if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${ - colIndex}Ready == 0) { - xTexelC${colIndex} = getX(batch, xR, xCOffset, d1); - - // Need to manually clear unused channels in case - // we're reading from recycled texture. - if (xCOffset + 1 >= inDims[1]) { - xTexelC${colIndex}.zw = vec2(0.0); - } - xTexelC${colIndex}Ready = 1; - } - `; - // This texel has been read in previous iteration if the dilation - // is 1. - if (dilationWidth === 1 && colIndex > 0) { - mainLoop += ` - xC${colIndex} = vec4(xTexelC${colIndex - 2}.zw, xTexelC${ - colIndex}.xy); - `; - } else { - mainLoop += ` - xCOffset = xC + 1 - 2; - - if (xCOffset >= 0 && xCOffset < inDims[1]) { - previous = getX(batch, xR, xCOffset, d1); - - // Need to manually clear unused channels in case - // we're reading from recycled texture. - if (xCOffset + 1 >= inDims[1]) { - previous.zw = vec2(0.0); - } - - xC${colIndex} = vec4(previous.zw, xTexelC${colIndex}.xy); - } else { - xC${colIndex} = vec4(0.0, 0.0, xTexelC${colIndex}.xy); - } - `; - } - } else { - // Padding is even, so xRC corresponds to a single texel. - mainLoop += ` - if (xC >= 0 && xC < inDims[1] && xTexelC${colIndex}Ready == 0) { - xTexelC${colIndex} = getX(batch, xR, xC, d1); - if (xC + 1 >= inDims[1]) { - xTexelC${colIndex}.zw = vec2(0.0); - } - xTexelC${colIndex}Ready = 1; - } - - xC${colIndex} = xTexelC${colIndex}; - `; - } - - if (colIndex + 1 < filterWidth) { - // If dilation is even, the second entry should match the first - // (either both are composed or both are single samples). But if - // dilation is odd, then the second entry should be the opposite - // of the first (if the first is composed, the second is a single - // sample, and vice versa.) - - const nextTexelOffset = padLeft % 2 === 0 ? - util.nearestLargerEven(dilationWidth) : - dilationWidth; - - if ((dilationWidth % 2 === 0 && padLeft % 2 === 1) || - (dilationWidth % 2 !== 0 && padLeft % 2 !== 1)) { - mainLoop += ` - xCOffset = xC + imod(pads[1], 2) + ${nextTexelOffset}; - - if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${ - colIndex + 1}Ready == 0) { - xTexelC${colIndex + 1} = getX(batch, xR, xCOffset, d1); - - // Need to manually clear unused channels in case - // we're reading from recycled texture. - if (xCOffset + 1 >= inDims[1]) { - xTexelC${colIndex + 1}.zw = vec2(0.0); - } - xTexelC${colIndex + 1}Ready = 1; - } - `; - - // If dilation > 1 then the xRC's will not be able to share any - // values, so each xRC will require two unique calls to getX. - if (dilationWidth > 1) { - mainLoop += ` - xCOffset -= 2; - if (xCOffset >= 0 && xCOffset < inDims[1]) { - previous = getX(batch, xR, xCOffset, d1); - xC${colIndex + 1} = vec4(previous.zw, xTexelC${ - colIndex + 1}.xy); - } else { - xC${colIndex + 1} = vec4(0.0, 0.0, xTexelC${ - colIndex + 1}.xy); - } - `; - } else { - mainLoop += ` - xC${colIndex + 1} = vec4(xTexelC${colIndex}.zw, xTexelC${ - colIndex + 1}.xy); - `; - } - } else { - // If dilation is 1 and padding is odd, we have already read the - // texel when constructing the previous x value. Here we can - // simply skip the texture read. - if (nextTexelOffset === 1) { - mainLoop += ` - xC${colIndex + 1} = xTexelC${colIndex}; - `; - } else { - mainLoop += ` - xCOffset = xC + ${nextTexelOffset}; - - if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${ - colIndex + 1}Ready == 0) { - xTexelC${colIndex + 1} = getX(batch, xR, xCOffset, d1); - if (xCOffset + 1 >= inDims[1]) { - xTexelC${colIndex + 1}.zw = vec2(0.0); - } - xTexelC${colIndex + 1}Ready = 1; - } - - xC${colIndex + 1} = xTexelC${colIndex + 1}; - `; - } - } - } - } - } else { // stride === 2 - if (colIndex < filterWidth) { - // Depending on whether padLeft is even or odd, we want either the - // xy or zw channels from X texels for xC${colIndex}. If padLeft is - // even, xC${colIndex +1} is simply the zw channels of texels we've - // already sampled. But if padLeft is odd, xC{$c + 1}.zw will - // need to come from the xy channels of a new texel, hence the ` - // vec4 - // final` initialized below. - if (padLeft % 2 === 1) { - mainLoop += ` - xCOffset = xC + 1 - strides[1]; - if(xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${ - colIndex}Ready == 0) { - xTexelC${colIndex} = getX(batch, xR, xCOffset, d1); - // Need to manually clear unused channels in case - // we're reading from recycled texture. - if (xCOffset + 1 >= inDims[1]) { - xTexelC${colIndex}.zw = vec2(0.0); - } - xTexelC${colIndex}Ready = 1; - } - - if(xC + 1 >= 0 && xC + 1 < inDims[1] && xTexelC${ - colIndex + 1}Ready == 0) { - xTexelC${colIndex + 1} = getX(batch, xR, xC + 1, d1); - // Need to manually clear unused channels in case - // we're reading from recycled texture. - if (xC + 2 >= inDims[1]) { - xTexelC${colIndex + 1}.zw = vec2(0.0); - } - xTexelC${colIndex + 1}Ready = 1; - } - - xC${colIndex} = vec4(xTexelC${colIndex}.zw, xTexelC${ - colIndex + 1}.zw); - `; - - if (colIndex + 1 < filterWidth) { - mainLoop += ` - final = vec4(0.0); - xCOffset = xC + 1 + strides[1]; - if(xCOffset >= 0 && xCOffset < inDims[1]) { - final = getX(batch, xR, xCOffset, d1); - } - xC${colIndex + 1} = vec4(xTexelC${colIndex + 1}.xy, final.xy); - `; - } - } else { - mainLoop += ` - if(xC >= 0 && xC < inDims[1] && xTexelC${colIndex}Ready == 0) { - xTexelC${colIndex} = getX(batch, xR, xC, d1); - if (xC + 1 >= inDims[1]) { - xTexelC${colIndex}.zw = vec2(0.0); - } - xTexelC${colIndex}Ready = 1; - } - - xCOffset = xC + strides[1]; - if(xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${ - colIndex + 1}Ready == 0) { - xTexelC${colIndex + 1} = getX(batch, xR, xCOffset, d1); - if (xCOffset + 1 >= inDims[1]) { - xTexelC${colIndex + 1}.zw = vec2(0.); - } - xTexelC${colIndex + 1}Ready = 1; - } - - xC${colIndex} = vec4( - xTexelC${colIndex}.xy, xTexelC${colIndex + 1}.xy); - `; - - if (colIndex + 1 < filterWidth) { - mainLoop += ` - xC${colIndex + 1} = vec4(xTexelC${colIndex}.zw, xTexelC${ - colIndex + 1}.zw); - `; - } - } - } - } - - // localize the dotProd accumulation within the loop, the theory is for - // GPU with limited cache, accumulate sum across large amount of - // veriables will cause lots of cache misses. (i.e. 5x5 filter will have - // 50 variables) - if (colIndex < filterWidth) { - mainLoop += ` - wTexel = getW(r, ${colIndex}, d1, q); - dotProd += xC${colIndex} * vec4(wTexel.xz, wTexel.xz); - `; - - if (colIndex + 1 < filterWidth) { - mainLoop += ` - wTexel = getW(r, ${colIndex + 1}, d1, q); - dotProd += xC${colIndex + 1} * vec4(wTexel.xz, wTexel.xz); - `; - } - } - } - mainLoop += ` - } - `; - mainLoop += ` - } - `; - - let activationSnippet = '', applyActivationSnippet = ''; - if (activation) { - if (hasPreluActivation) { - activationSnippet = `vec4 activation(vec4 a) { - vec4 b = getPreluActivationWeightsAtOutCoords(); - ${activation} - }`; - } else if (hasLeakyReluAlpha) { - activationSnippet = `vec4 activation(vec4 a) { - vec4 b = getLeakyreluAlphaAtOutCoords(); - ${activation} - }`; - } else { - activationSnippet = `vec4 activation(vec4 x) { - ${activation} - }`; - } - - applyActivationSnippet = `result = activation(result);`; - } - - const addBiasSnippet = addBias ? 'result += getBiasAtOutCoords();' : ''; - if (addBias) { - this.variableNames.push('bias'); - } - - if (hasPreluActivation) { - this.variableNames.push('preluActivationWeights'); - } - if (hasLeakyReluAlpha) { - this.variableNames.push('leakyreluAlpha'); - } - - this.userCode = ` - ${activationSnippet} - - void main() { - ivec4 coords = getOutputCoords(); - int batch = coords.x; - ivec2 xRCCorner = coords.yz * strides - pads; - int d2 = coords.w; - int d1 = d2 / ${channelMul}; - int q = d2 - d1 * ${channelMul}; - int xRCorner = xRCCorner.x; - int xCCorner = xRCCorner.y; - - //intialize dotProd with a small epsilon seems to reduce GPU accuracy loss. - vec4 dotProd = vec4(0.000000000000001); - - ${mainLoop} - - vec4 result = dotProd - vec4(0.000000000000001); - ${addBiasSnippet} - ${applyActivationSnippet} - setOutput(result); - } - `; - } -} diff --git a/tfjs-master/tfjs-backend-webgl/src/crop_and_resize_gpu.ts b/tfjs-master/tfjs-backend-webgl/src/crop_and_resize_gpu.ts deleted file mode 100644 index 10f779c18..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/crop_and_resize_gpu.ts +++ /dev/null @@ -1,127 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {GPGPUProgram} from './gpgpu_math'; - -export class CropAndResizeProgram implements GPGPUProgram { - variableNames = ['Image', 'Boxes', 'BoxInd']; - outputShape: number[] = []; - userCode: string; - - constructor( - imageShape: [number, number, number, number], boxShape: [number, number], - cropSize: [number, number], method: 'bilinear'|'nearest', - extrapolationValue: number) { - const [batch, imageHeight, imageWidth, depth] = imageShape; - const [numBoxes, ] = boxShape; - const [cropHeight, cropWidth] = cropSize; - this.outputShape = [numBoxes, cropHeight, cropWidth, depth]; - const methodId = method === 'bilinear' ? 1 : 0; - - const [inputHeightFloat, inputWidthFloat] = - [`${imageHeight - 1}.0`, `${imageWidth - 1}.0`]; - - const [heightRatio, heightScale, inY] = cropHeight > 1 ? - [ - `${(imageHeight - 1) / (cropHeight - 1)}`, - '(y2-y1) * height_ratio', - `y1*${inputHeightFloat} + float(y)*(height_scale)`, - ] : - [ - '0.0', - '0.0', - `0.5 * (y1+y2) * ${inputHeightFloat}`, - ]; - const [widthRatio, widthScale, inX] = cropWidth > 1 ? - [ - `${(imageWidth - 1) / (cropWidth - 1)}`, - '(x2-x1) * width_ratio', - `x1*${inputWidthFloat} + float(x)*(width_scale)`, - ] : - [ - '0.0', - '0.0', - `0.5 * (x1+x2) * ${inputWidthFloat}`, - ]; - - // Reference implementation - // tslint:disable-next-line:max-line-length - // https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/kernels/crop_and_resize_op_gpu.cu.cc - this.userCode = ` - const float height_ratio = float(${heightRatio}); - const float width_ratio = float(${widthRatio}); - void main() { - ivec4 coords = getOutputCoords(); - int b = coords[0]; - int y = coords[1]; - int x = coords[2]; - int d = coords[3]; - - // get box vals - float y1 = getBoxes(b,0); - float x1 = getBoxes(b,1); - float y2 = getBoxes(b,2); - float x2 = getBoxes(b,3); - - // get image in batch index - int bInd = round(getBoxInd(b)); - if(bInd < 0 || bInd >= ${batch}) { - return; - } - - float height_scale = ${heightScale}; - float width_scale = ${widthScale}; - - float in_y = ${inY}; - if( in_y < 0.0 || in_y > ${inputHeightFloat} ) { - setOutput(float(${extrapolationValue})); - return; - } - float in_x = ${inX}; - if( in_x < 0.0 || in_x > ${inputWidthFloat} ) { - setOutput(float(${extrapolationValue})); - return; - } - - vec2 sourceFracIndexCR = vec2(in_x,in_y); - if(${methodId} == 1) { - // Compute the four integer indices. - ivec2 sourceFloorCR = ivec2(sourceFracIndexCR); - ivec2 sourceCeilCR = ivec2(ceil(sourceFracIndexCR)); - - float topLeft = getImage(b, sourceFloorCR.y, sourceFloorCR.x, d); - float bottomLeft = getImage(b, sourceCeilCR.y, sourceFloorCR.x, d); - float topRight = getImage(b, sourceFloorCR.y, sourceCeilCR.x, d); - float bottomRight = getImage(b, sourceCeilCR.y, sourceCeilCR.x, d); - - vec2 fracCR = sourceFracIndexCR - vec2(sourceFloorCR); - - float top = topLeft + (topRight - topLeft) * fracCR.x; - float bottom = bottomLeft + (bottomRight - bottomLeft) * fracCR.x; - float newValue = top + (bottom - top) * fracCR.y; - setOutput(newValue); - } else { - // Compute the coordinators of nearest neighbor point. - ivec2 sourceNearestCR = ivec2(floor( - sourceFracIndexCR + vec2(0.5,0.5))); - float newValue = getImage(b, sourceNearestCR.y, sourceNearestCR.x, d); - setOutput(newValue); - } - } - `; - } -} diff --git a/tfjs-master/tfjs-backend-webgl/src/cum_gpu.ts b/tfjs-master/tfjs-backend-webgl/src/cum_gpu.ts deleted file mode 100644 index 9e32dd886..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/cum_gpu.ts +++ /dev/null @@ -1,94 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {GPGPUProgram} from './gpgpu_math'; -import {getCoordsDataType, UniformType} from './shader_compiler'; - -export enum CumOpType { - Prod = '*', - Sum = '+', -} - -export class CumProgram implements GPGPUProgram { - variableNames = ['x']; - userCode: string; - customUniforms = [{name: 'index', type: 'float' as UniformType}]; - - constructor( - public op: CumOpType, public outputShape: number[], exclusive: boolean, - reverse: boolean) { - const rank = this.outputShape.length; - const initVal = this.op === CumOpType.Prod ? '1.0' : '0.0'; - const val = - exclusive ? initVal : `getX(${getCoords(rank, 'coords', this.op)})`; - const length = this.outputShape[this.outputShape.length - 1]; - let condition = ''; - let idxString = ''; - // When exclusive is set, the cum op becomes roll op that copies the - // value from the previous index based on the direction specified by the - // reverse flag. - if (exclusive) { - condition = reverse ? `end != ${length - 1}` : 'end != 0'; - idxString = reverse ? 'end + 1' : 'end - 1'; - } else { - condition = reverse ? `end + pow2 < ${length}` : 'end >= pow2'; - idxString = (reverse ? 'end + pow2' : 'end - pow2'); - } - - this.userCode = ` - void main() { - ${getCoordsDataType(rank)} coords = getOutputCoords(); - int end = ${getFinalCoord(rank, 'coords', this.op)}; - float val = ${val}; - int pow2 = int(pow(2.0, index)); - if (${condition}) { - int idx = ${idxString}; - ${getFinalCoord(rank, 'coords', this.op)} = idx; - val ${this.op}= getX(${getCoords(rank, 'coords', this.op)}); - } - setOutput(val); - } - `; - } -} - -function getCoords(rank: number, name: string, op: CumOpType): string { - if (rank === 1) { - return `${name}`; - } else if (rank === 2) { - return `${name}.x, ${name}.y`; - } else if (rank === 3) { - return `${name}.x, ${name}.y, ${name}.z`; - } else if (rank === 4) { - return `${name}.x, ${name}.y, ${name}.z, ${name}.w`; - } else { - throw new Error(`Cumulative ${op} for rank ${rank} is not yet supported`); - } -} - -function getFinalCoord(rank: number, name: string, op: CumOpType): string { - if (rank === 1) { - return `${name}`; - } else if (rank === 2) { - return `${name}.y`; - } else if (rank === 3) { - return `${name}.z`; - } else if (rank === 4) { - return `${name}.w`; - } else { - throw new Error(`Cumulative ${op} for rank ${rank} is not yet supported`); - } -} diff --git a/tfjs-master/tfjs-backend-webgl/src/decode_matrix_gpu.ts b/tfjs-master/tfjs-backend-webgl/src/decode_matrix_gpu.ts deleted file mode 100644 index 173812691..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/decode_matrix_gpu.ts +++ /dev/null @@ -1,65 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {getGlslDifferences} from './glsl_version'; -import {GPGPUProgram, useShapeUniforms} from './gpgpu_math'; -import * as shader_util from './shader_compiler_util'; -import {PackingScheme} from './tex_util'; - -export class DecodeMatrixProgram implements GPGPUProgram { - variableNames = ['A']; - userCode: string; - outputShape: [number, number, number]; - packedInputs = false; - packedOutput = true; - outPackingScheme = PackingScheme.DENSE; - enableShapeUniforms: boolean; - customUniforms = [{name: 'texShape', type: 'ivec2' as const }]; - - constructor(outputShape: [number, number, number]) { - const glsl = getGlslDifferences(); - this.outputShape = outputShape; - this.enableShapeUniforms = useShapeUniforms(this.outputShape.length); - - this.userCode = ` - ivec3 outCoordsFromFlatIndex(int index) { - ${ - this.enableShapeUniforms ? - shader_util.getOutputLogicalCoordinatesFromFlatIndexByUniform( - ['r', 'c', 'd'], outputShape) : - shader_util.getLogicalCoordinatesFromFlatIndex( - ['r', 'c', 'd'], outputShape)} - return ivec3(r, c, d); - } - - void main() { - ivec2 resTexRC = ivec2(resultUV.yx * vec2(texShape[0], texShape[1])); - int index = 4 * (resTexRC.x * texShape[1] + resTexRC.y); - - vec4 result = vec4(0.); - - for (int i=0; i<4; i++) { - int flatIndex = index + i; - ivec3 rc = outCoordsFromFlatIndex(flatIndex); - result[i] = getA(rc.x, rc.y, rc.z); - } - - ${glsl.output} = result; - } - `; - } -} diff --git a/tfjs-master/tfjs-backend-webgl/src/decode_matrix_packed_gpu.ts b/tfjs-master/tfjs-backend-webgl/src/decode_matrix_packed_gpu.ts deleted file mode 100644 index c3888024f..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/decode_matrix_packed_gpu.ts +++ /dev/null @@ -1,65 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {getGlslDifferences} from './glsl_version'; -import {GPGPUProgram, useShapeUniforms} from './gpgpu_math'; -import * as shader_util from './shader_compiler_util'; -import {PackingScheme} from './tex_util'; - -export class DecodeMatrixPackedProgram implements GPGPUProgram { - variableNames = ['A']; - userCode: string; - packedInputs = true; - packedOutput = true; - outputShape: [number, number, number]; - outPackingScheme = PackingScheme.DENSE; - enableShapeUniforms: boolean; - customUniforms = [{name: 'texShape', type: 'ivec2' as const }]; - - constructor(outputShape: [number, number, number]) { - const glsl = getGlslDifferences(); - this.outputShape = outputShape; - this.enableShapeUniforms = useShapeUniforms(this.outputShape.length); - - this.userCode = ` - ivec3 outCoordsFromFlatIndex(int index) { - ${ - this.enableShapeUniforms ? - shader_util.getOutputLogicalCoordinatesFromFlatIndexByUniform( - ['r', 'c', 'd'], outputShape) : - shader_util.getLogicalCoordinatesFromFlatIndex( - ['r', 'c', 'd'], outputShape)} - return ivec3(r, c, d); - } - - void main() { - ivec2 resTexRC = ivec2(resultUV.yx * vec2(texShape[0], texShape[1])); - int index = 4 * (resTexRC.x * texShape[1] + resTexRC.y); - - vec4 result = vec4(0.); - - for (int i=0; i<4; i++) { - int flatIndex = index + i; - ivec3 rc = outCoordsFromFlatIndex(flatIndex); - result[i] = getChannel(getA(rc.x, rc.y, rc.z), vec2(rc.y, rc.z)); - } - - ${glsl.output} = result; - } - `; - } -} diff --git a/tfjs-master/tfjs-backend-webgl/src/depth_to_space_gpu.ts b/tfjs-master/tfjs-backend-webgl/src/depth_to_space_gpu.ts deleted file mode 100644 index 0575cf4df..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/depth_to_space_gpu.ts +++ /dev/null @@ -1,93 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {GPGPUProgram} from './gpgpu_math'; - -export class DepthToSpaceProgram implements GPGPUProgram { - variableNames = ['x']; - outputShape: number[] = []; - userCode: string; - blockSize: number; - dataFormat: string; - - constructor( - outputShape: number[], blockSize: number, dataFormat: 'NHWC'|'NCHW') { - this.outputShape = outputShape; - this.blockSize = blockSize; - this.dataFormat = dataFormat; - this.userCode = ` - void main() { - ivec4 coords = getOutputCoords(); - int b = coords[0]; - int h = ${this.getHeightCoordString()}; - int w = ${this.getWidthCoordString()}; - int d = ${this.getDepthCoordString()}; - - int in_h = h / ${blockSize}; - int offset_h = imod(h, ${blockSize}); - int in_w = w / ${blockSize}; - int offset_w = imod(w, ${blockSize}); - int offset_d = (offset_h * ${blockSize} + offset_w) * - ${this.getOutputDepthSize()}; - int in_d = d + offset_d; - - float result = ${this.getInputSamplingString()}; - setOutput(result); - } - `; - } - - private getHeightCoordString(): string { - if (this.dataFormat === 'NHWC') { - return `coords[1]`; - } else { - return `coords[2]`; - } - } - - private getWidthCoordString(): string { - if (this.dataFormat === 'NHWC') { - return `coords[2]`; - } else { - return `coords[3]`; - } - } - - private getDepthCoordString(): string { - if (this.dataFormat === 'NHWC') { - return `coords[3]`; - } else { - return `coords[1]`; - } - } - - private getOutputDepthSize(): number { - if (this.dataFormat === 'NHWC') { - return this.outputShape[3]; - } else { - return this.outputShape[1]; - } - } - - private getInputSamplingString(): string { - if (this.dataFormat === 'NHWC') { - return `getX(b, in_h, in_w, in_d)`; - } else { - return `getX(b, in_d, in_h, in_w)`; - } - } -} diff --git a/tfjs-master/tfjs-backend-webgl/src/diag_gpu.ts b/tfjs-master/tfjs-backend-webgl/src/diag_gpu.ts deleted file mode 100644 index 8c38716a0..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/diag_gpu.ts +++ /dev/null @@ -1,35 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {GPGPUProgram} from './gpgpu_math'; - -export class DiagProgram implements GPGPUProgram { - variableNames = ['X']; - outputShape: number[]; - userCode: string; - - constructor(size: number) { - this.outputShape = [size, size]; - this.userCode = ` - void main() { - ivec2 coords = getOutputCoords(); - float val = coords[0] == coords[1] ? getX(coords[0]) : 0.0; - setOutput(val); - } - `; - } -} diff --git a/tfjs-master/tfjs-backend-webgl/src/dilation_gpu.ts b/tfjs-master/tfjs-backend-webgl/src/dilation_gpu.ts deleted file mode 100644 index d0953159a..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/dilation_gpu.ts +++ /dev/null @@ -1,83 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util} from '@tensorflow/tfjs-core'; -import {GPGPUProgram} from './gpgpu_math'; - -export class Dilation2DProgram implements GPGPUProgram { - variableNames = ['x', 'W']; - outputShape: number[]; - userCode: string; - - constructor(convInfo: backend_util.Conv2DInfo) { - this.outputShape = convInfo.outShape; - - const { - inHeight, - inWidth, - padInfo, - strideHeight, - strideWidth, - filterHeight, - filterWidth, - dilationHeight, - dilationWidth - } = convInfo; - - const {top: padTop, left: padLeft} = padInfo; - - this.userCode = ` - const ivec2 strides = ivec2(${strideHeight}, ${strideWidth}); - const ivec2 pads = ivec2(${padTop}, ${padLeft}); - const float neg_infinity = -3.4e38; - - void main() { - ivec4 coords = getOutputCoords(); - int batch = coords.x; - int d1 = coords.w; - ivec2 outTopLeftCorner = - coords.yz * strides - pads; - int hBeg = outTopLeftCorner.x; - int wBeg = outTopLeftCorner.y; - - float curVal = neg_infinity; - for (int h = 0; h < ${filterHeight}; h++) { - int hIn = hBeg + h * ${dilationHeight}; - - if (hIn >= 0 && hIn < ${inHeight}) { - for (int w = 0; w < ${filterWidth}; w++) { - int wIn = wBeg + w * ${dilationWidth}; - - if (wIn >= 0 && wIn < ${inWidth}) { - float xVal = getX(batch, hIn, wIn, d1); - float wVal = getW(h, w, d1); - - float val = xVal + wVal; - if (val > curVal) { - curVal = val; - } - } - } - } - } - - float result = curVal; - setOutput(result); - } - `; - } -} diff --git a/tfjs-master/tfjs-backend-webgl/src/encode_float_gpu.ts b/tfjs-master/tfjs-backend-webgl/src/encode_float_gpu.ts deleted file mode 100644 index d7d8fb193..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/encode_float_gpu.ts +++ /dev/null @@ -1,41 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {getGlslDifferences} from './glsl_version'; -import {GPGPUProgram} from './gpgpu_math'; -import {ENCODE_FLOAT_SNIPPET} from './shader_compiler_util'; -import {TextureUsage} from './tex_util'; - -export class EncodeFloatProgram implements GPGPUProgram { - variableNames = ['A']; - userCode: string; - outputShape: number[]; - outTexUsage = TextureUsage.DOWNLOAD; - - constructor(outputShape: number[]) { - const glsl = getGlslDifferences(); - this.outputShape = outputShape; - this.userCode = ` - ${ENCODE_FLOAT_SNIPPET} - - void main() { - float x = getAAtOutCoords(); - ${glsl.output} = encode_float(x); - } - `; - } -} diff --git a/tfjs-master/tfjs-backend-webgl/src/encode_float_packed_gpu.ts b/tfjs-master/tfjs-backend-webgl/src/encode_float_packed_gpu.ts deleted file mode 100644 index 645e5bed0..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/encode_float_packed_gpu.ts +++ /dev/null @@ -1,44 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {getGlslDifferences} from './glsl_version'; -import {GPGPUProgram} from './gpgpu_math'; -import {ENCODE_FLOAT_SNIPPET} from './shader_compiler_util'; -import {TextureUsage} from './tex_util'; - -export class EncodeFloatPackedProgram implements GPGPUProgram { - variableNames = ['A']; - userCode: string; - outputShape: number[]; - packedInputs = true; - packedOutput = false; - outTexUsage = TextureUsage.DOWNLOAD; - - constructor(outputShape: [number, number, number]) { - const glsl = getGlslDifferences(); - this.outputShape = outputShape; - this.userCode = ` - ${ENCODE_FLOAT_SNIPPET} - - void main() { - ivec3 coords = getOutputCoords(); - float x = getChannel(getAAtOutCoords(), vec2(coords.y, coords.z)); - ${glsl.output} = encode_float(x); - } - `; - } -} diff --git a/tfjs-master/tfjs-backend-webgl/src/encode_matrix_gpu.ts b/tfjs-master/tfjs-backend-webgl/src/encode_matrix_gpu.ts deleted file mode 100644 index 5d3bc4eb5..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/encode_matrix_gpu.ts +++ /dev/null @@ -1,82 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {getGlslDifferences} from './glsl_version'; -import {GPGPUProgram, useShapeUniforms} from './gpgpu_math'; -import * as shader_util from './shader_compiler_util'; - -const CHANNEL_CHAR_TO_INDEX_MAP: Record = { - 'R': 0, - 'G': 1, - 'B': 2, - 'A': 3 -}; - -export class EncodeMatrixProgram implements GPGPUProgram { - variableNames = ['A']; - userCode: string; - outputShape: number[]; - enableShapeUniforms: boolean; - customUniforms = [{name: 'texShape', type: 'ivec2' as const }]; - - constructor( - outputShape: [number, number, number], inputIsUnsignedByte = false, - usedChannels = 'RGBA') { - const glsl = getGlslDifferences(); - this.outputShape = outputShape; - this.enableShapeUniforms = useShapeUniforms(this.outputShape.length); - - let output = `result`; - if (inputIsUnsignedByte) { - output = `floor(result * 255. + 0.5)`; - } - - let mainLoop = ''; - for (let usedChannelIndex = 0; usedChannelIndex < usedChannels.length; - usedChannelIndex++) { - const curChannel = usedChannels[usedChannelIndex]; - mainLoop += ` - if(offset == ${usedChannelIndex}) { - result = values[${CHANNEL_CHAR_TO_INDEX_MAP[curChannel]}]; - }`; - } - - this.userCode = ` - ${ - this.enableShapeUniforms ? shader_util.getFlatIndexFrom3DOutput() : - shader_util.getFlatIndexFrom3D(outputShape)} - - void main() { - ivec3 coords = getOutputCoords(); - int flatIndex = getFlatIndex(coords); - float result = 0.; - int offset = imod(flatIndex, ${usedChannels.length}); - - flatIndex = idiv(flatIndex, ${usedChannels.length}, 1.); - - int r = flatIndex / texShape[1]; - if (r < texShape[0]) { - int c = imod(flatIndex, texShape[1]); - vec2 uv = (vec2(c, r) + halfCR) / vec2(texShape[1], texShape[0]); - vec4 values = ${glsl.texture2D}(A, uv); - ${mainLoop} - } - ${glsl.output} = vec4(${output}, 0., 0., 0.); - } - `; - } -} diff --git a/tfjs-master/tfjs-backend-webgl/src/encode_matrix_packed_gpu.ts b/tfjs-master/tfjs-backend-webgl/src/encode_matrix_packed_gpu.ts deleted file mode 100644 index d22b5bee0..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/encode_matrix_packed_gpu.ts +++ /dev/null @@ -1,117 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {getGlslDifferences} from './glsl_version'; -import {GPGPUProgram, useShapeUniforms} from './gpgpu_math'; -import * as shader_util from './shader_compiler_util'; - -/* -This is how the shader encodes a tensor with shape = [2, 3, 5] -(indices are [batch, row, col]). - -000|001 002|003 004|xxx 020|021 022|023 024|xxx -------- ------- ------- ------- ------- ------- -010|011 012|013 014|xxx xxx|xxx xxx|xxx xxx|xxx - -100|101 102|103 104|xxx 120|121 122|123 124|xxx -------- ------- ------- ------- ------- ------- -110|111 112|113 114|xxx xxx|xxx xxx|xxx xxx|xxx - -Single texels contain only values from the same batch, and from adjacent rows -and columns. - */ - -export class EncodeMatrixPackedProgram implements GPGPUProgram { - variableNames = ['A']; - userCode: string; - outputShape: number[]; - packedInputs = false; - packedOutput = true; - enableShapeUniforms: boolean; - customUniforms = [{name: 'texShape', type: 'ivec2' as const }]; - - constructor( - outputShape: [number, number, number], inputIsUnsignedByte = false) { - const glsl = getGlslDifferences(); - this.outputShape = outputShape; - this.enableShapeUniforms = useShapeUniforms(this.outputShape.length); - - let mainLoop = ''; - let output = 'result'; - if (inputIsUnsignedByte) { - output = 'floor(result * 255. + 0.5)'; - } - - for (let row = 0; row <= 1; row++) { - for (let col = 0; col <= 1; col++) { - const channel = row * 2 + col; - - mainLoop += ` - localCoords = coords; - if(localCoords[2] + ${col} < ${ - this.enableShapeUniforms ? 'outShape[2]' : `${outputShape[2]}`}) { - localCoords[2] += ${col}; - if (localCoords[1] + ${row} < ${ - this.enableShapeUniforms ? 'outShape[1]' : `${outputShape[1]}`}) { - localCoords[1] += ${row}; - - flatIndex = getFlatIndex(localCoords); - offset = imod(flatIndex, 4); - - flatIndex = idiv(flatIndex, 4, 1.); - - int r = flatIndex / texShape[1]; - int c = imod(flatIndex, texShape[1]); - vec2 uv = (vec2(c, r) + halfCR) / vec2(texShape[1], texShape[0]); - values = ${glsl.texture2D}(A, uv); - - if (offset == 0) { - result[${channel}] = values[0]; - } else if (offset == 1) { - result[${channel}] = values[1]; - } else if (offset == 2) { - result[${channel}] = values[2]; - } else { - result[${channel}] = values[3]; - } - } - } - `; - } - } - - this.userCode = ` - ${ - this.enableShapeUniforms ? shader_util.getFlatIndexFrom3DOutput() : - shader_util.getFlatIndexFrom3D(outputShape)} - - void main() { - ivec3 coords = getOutputCoords(); - - vec4 result = vec4(0.); - int flatIndex, r, c, offset; - ivec3 localCoords; - vec2 uv; - vec4 values; - - ${mainLoop} - - ${glsl.output} = ${output}; - } - `; - } -} diff --git a/tfjs-master/tfjs-backend-webgl/src/fft_gpu.ts b/tfjs-master/tfjs-backend-webgl/src/fft_gpu.ts deleted file mode 100644 index 4e6e150a7..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/fft_gpu.ts +++ /dev/null @@ -1,80 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {GPGPUProgram} from './gpgpu_math'; - -export class FFTProgram implements GPGPUProgram { - variableNames = ['real', 'imag']; - outputShape: number[]; - userCode: string; - - constructor( - component: 'real'|'imag', inputShape: [number, number], - inverse: boolean) { - const innerDim = inputShape[1]; - this.outputShape = inputShape; - - const exponentMultiplierSnippet = - inverse ? `2.0 * ${Math.PI}` : `-2.0 * ${Math.PI}`; - const resultDenominator = inverse ? `${innerDim}.0` : '1.0'; - - let opString: string; - if (component === 'real') { - opString = 'return real * expR - imag * expI;'; - } else if (component === 'imag') { - opString = 'return real * expI + imag * expR;'; - } else { - throw new Error( - `FFT component must be either "real" or "imag", got ${component}.`); - } - - this.userCode = ` - const float exponentMultiplier = ${exponentMultiplierSnippet}; - - float unaryOpComplex(float real, float expR, float imag, float expI) { - ${opString} - } - - float mulMatDFT(int batch, int index) { - float indexRatio = float(index) / float(${innerDim}); - float exponentMultiplierTimesIndexRatio = - exponentMultiplier * indexRatio; - - float result = 0.0; - - for (int i = 0; i < ${innerDim}; i++) { - // x = (-2|2 * PI / N) * index * i; - float x = exponentMultiplierTimesIndexRatio * float(i); - float expR = cos(x); - float expI = sin(x); - float real = getReal(batch, i); - float imag = getImag(batch, i); - - result += - unaryOpComplex(real, expR, imag, expI) / ${resultDenominator}; - } - - return result; - } - - void main() { - ivec2 coords = getOutputCoords(); - setOutput(mulMatDFT(coords[0], coords[1])); - } - `; - } -} diff --git a/tfjs-master/tfjs-backend-webgl/src/fill_gpu.ts b/tfjs-master/tfjs-backend-webgl/src/fill_gpu.ts deleted file mode 100644 index b7fc19bc1..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/fill_gpu.ts +++ /dev/null @@ -1,38 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {GPGPUProgram} from './gpgpu_math'; -import {UniformType} from './shader_compiler'; - -export class FillProgram implements GPGPUProgram { - variableNames: string[]; - outputShape: number[] = []; - userCode: string; - customUniforms = [{name: 'value', type: 'float' as UniformType}]; - - constructor(shape: number[], value: number) { - this.variableNames = ['x']; - this.outputShape = shape; - - this.userCode = ` - void main() { - // Input can be obtained from uniform value. - setOutput(value); - } - `; - } -} diff --git a/tfjs-master/tfjs-backend-webgl/src/flags_webgl.ts b/tfjs-master/tfjs-backend-webgl/src/flags_webgl.ts deleted file mode 100644 index 7bf7ad92a..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/flags_webgl.ts +++ /dev/null @@ -1,290 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {device_util, env} from '@tensorflow/tfjs-core'; - -import {getMaxTexturesInShader, getWebGLDisjointQueryTimerVersion, getWebGLMaxTextureSize, isCapableOfRenderingToFloatTexture, isDownloadFloatTextureEnabled, isWebGLFenceEnabled, isWebGLVersionEnabled} from './webgl_util'; - -const ENV = env(); - -/** - * This file contains WebGL-specific flag registrations. - */ - -/** - * True if WebGL is supported. - */ -ENV.registerFlag('HAS_WEBGL', () => ENV.getNumber('WEBGL_VERSION') > 0); - -/** 0: No WebGL, 1: WebGL 1.0, 2: WebGL 2.0. */ -ENV.registerFlag('WEBGL_VERSION', () => { - if (isWebGLVersionEnabled(2)) { - return 2; - } else if (isWebGLVersionEnabled(1)) { - return 1; - } - return 0; -}); - -/** Whether to check for numerical representation problems. */ -ENV.registerFlag('WEBGL_CHECK_NUMERICAL_PROBLEMS', () => false); - -ENV.registerFlag( - 'WEBGL_BUFFER_SUPPORTED', () => ENV.get('WEBGL_VERSION') === 2); - -/** Whether the WebGL backend will sometimes forward ops to the CPU. */ -ENV.registerFlag('WEBGL_CPU_FORWARD', () => true); - -/** Whether the WebGL backend will always use f16 textures for rendering. */ -ENV.registerFlag('WEBGL_FORCE_F16_TEXTURES', () => false); - -/** Whether to turn all packing related flags on. */ -ENV.registerFlag('WEBGL_PACK', () => ENV.getBool('HAS_WEBGL')); - -/** Whether we will pack the batchnormalization op. */ -ENV.registerFlag('WEBGL_PACK_NORMALIZATION', () => ENV.getBool('WEBGL_PACK')); - -/** Whether we will pack the clip op. */ -ENV.registerFlag('WEBGL_PACK_CLIP', () => ENV.getBool('WEBGL_PACK')); - -/** Whether we will pack the depthwise conv op. */ -ENV.registerFlag('WEBGL_PACK_DEPTHWISECONV', () => ENV.getBool('WEBGL_PACK')); - -/** Whether we will pack binary ops. */ -ENV.registerFlag( - 'WEBGL_PACK_BINARY_OPERATIONS', () => ENV.getBool('WEBGL_PACK')); - -/** Whether we will pack unary ops. */ -ENV.registerFlag( - 'WEBGL_PACK_UNARY_OPERATIONS', () => ENV.getBool('WEBGL_PACK')); - -/** Whether we will pack array ops. */ -ENV.registerFlag( - 'WEBGL_PACK_ARRAY_OPERATIONS', () => ENV.getBool('WEBGL_PACK')); - -/** Whether we will pack image ops. */ -ENV.registerFlag( - 'WEBGL_PACK_IMAGE_OPERATIONS', () => ENV.getBool('WEBGL_PACK')); - -/** Whether we will pack reduce ops. */ -ENV.registerFlag('WEBGL_PACK_REDUCE', () => ENV.getBool('WEBGL_PACK')); - -/** Whether packed WebGL kernels lazily unpack their outputs. */ -ENV.registerFlag('WEBGL_LAZILY_UNPACK', () => ENV.getBool('WEBGL_PACK')); - -/** Whether we will use the im2col algorithm to speed up convolutions. */ -ENV.registerFlag('WEBGL_CONV_IM2COL', () => ENV.getBool('WEBGL_PACK')); - -/** Whether we will pack conv2dTranspose op. */ -ENV.registerFlag('WEBGL_PACK_CONV2DTRANSPOSE', () => ENV.getBool('WEBGL_PACK')); - -/** The maximum texture dimension. */ -ENV.registerFlag( - 'WEBGL_MAX_TEXTURE_SIZE', - () => getWebGLMaxTextureSize(ENV.getNumber('WEBGL_VERSION'))); - -/** The maximum texture dimension. */ -ENV.registerFlag( - 'WEBGL_MAX_TEXTURES_IN_SHADER', - () => getMaxTexturesInShader(ENV.getNumber('WEBGL_VERSION'))); - -/** - * The disjoint_query_timer extension version. - * 0: disabled, 1: EXT_disjoint_timer_query, 2: - * EXT_disjoint_timer_query_webgl2. - * In Firefox with WebGL 2.0, - * EXT_disjoint_timer_query_webgl2 is not available, so we must use the - * WebGL 1.0 extension. - */ -ENV.registerFlag('WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION', () => { - const webGLVersion = ENV.getNumber('WEBGL_VERSION'); - - if (webGLVersion === 0) { - return 0; - } - return getWebGLDisjointQueryTimerVersion(webGLVersion); -}); - -/** - * Whether the timer object from the disjoint_query_timer extension gives - * timing information that is reliable. - */ -ENV.registerFlag( - 'WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE', - () => ENV.getNumber('WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION') > 0 && - !device_util.isMobile()); - -/** - * Whether the device is physically capable of rendering to float32 textures. - */ -ENV.registerFlag( - 'WEBGL_RENDER_FLOAT32_CAPABLE', - () => isCapableOfRenderingToFloatTexture(ENV.getNumber('WEBGL_VERSION'))); - -/** - * Whether rendering to float32 textures is enabled. If disabled, renders to - * float16 textures. - */ -ENV.registerFlag('WEBGL_RENDER_FLOAT32_ENABLED', () => { - return ENV.getBool('WEBGL_FORCE_F16_TEXTURES') ? - false : - ENV.getBool('WEBGL_RENDER_FLOAT32_CAPABLE'); -}); - -/** - * Whether downloading float textures is enabled (16 or 32 bit). If disabled, - * uses IEEE 754 encoding of the float32 values to 4 uint8 when downloading. - */ -ENV.registerFlag( - 'WEBGL_DOWNLOAD_FLOAT_ENABLED', - () => isDownloadFloatTextureEnabled(ENV.getNumber('WEBGL_VERSION'))); - -/** Whether the fence API is available. */ -ENV.registerFlag( - 'WEBGL_FENCE_API_ENABLED', - () => isWebGLFenceEnabled(ENV.getNumber('WEBGL_VERSION'))); - -/** - * Tensors with size <= than this will be uploaded as uniforms, not textures. - */ -ENV.registerFlag('WEBGL_SIZE_UPLOAD_UNIFORM', () => { - // Use uniform uploads only when 32bit floats are supported. In - // 16bit - // environments there are problems with comparing a 16bit texture value - // with a 32bit uniform value. - const useUniforms = ENV.getBool('WEBGL_RENDER_FLOAT32_ENABLED'); - return useUniforms ? 4 : 0; -}); - -/** - * If the total number of bytes allocated on the GPU is greater than this - * number, we will aggressively delete textures upon disposal with - * gl.deleteMatrixTexture, rather than making them available for reuse. - * - * Default value -1 indicates that we will never aggressively delete textures. - */ -ENV.registerFlag( - 'WEBGL_DELETE_TEXTURE_THRESHOLD', - () => { - return -1; - }, - threshold => { - if (!(typeof threshold === 'number')) { - throw new Error('WEBGL_DELETE_TEXTURE_THRESHOLD must be a number but ' + - `got ${threshold}.`); - } - if (threshold < 0 && threshold !== -1) { - throw new Error( - `WEBGL_DELETE_TEXTURE_THRESHOLD must be -1 (indicating never ` + - `delete) or at least 0, but got ${threshold}.`); - } - }); - -/** - * Trigger a manual GL command flush if the threshold of time has passed since - * previous Kernel execution. This can be useful for Andorid device where GL - * command flush are delayed un til the end of javascript task. This value is - * measured in millisecond. Typically you want to set this value to close to 1. - * - * Default value 1 for mobile chrome, and -1 for rest cases. -1 indicates that - * we will not enforce manual flush and depend on system default flush schedule. - */ -ENV.registerFlag( - 'WEBGL_FLUSH_THRESHOLD', - () => { - return device_util.isMobile() ? 1 : -1; - }, - threshold => { - if (!(typeof threshold === 'number')) { - throw new Error('WEBGL_FLUSH_THRESHOLD must be a number but got ' + - `${threshold}.`); - } - if (threshold < 0 && threshold !== -1) { - throw new Error( - `WEBGL_FLUSH_THRESHOLD must be -1 (indicating never ` + - `manual flush) or at least 0, but got ${threshold}.`); - } - }); - -/** - * Threshold for input tensor size that determines whether WebGL backend will - * delegate computation to CPU. - * - * Default value is 128. - */ -ENV.registerFlag('CPU_HANDOFF_SIZE_THRESHOLD', () => 128); - -/** Whether we will use shapes uniforms. */ -ENV.registerFlag('WEBGL_USE_SHAPES_UNIFORMS', () => false); - -/** - * Threshold for last dimension of input tensor that determines whether - * WebGL backend for the Top K op will delegate computation to CPU. If input - * is smaller than threshold then CPU will be used - * - * Default value is 100000. - */ -ENV.registerFlag('TOPK_LAST_DIM_CPU_HANDOFF_SIZE_THRESHOLD', () => 100000); - -/** - * Threshold for K that determines whether - * WebGL backend for the Top K op will delegate computation to CPU. If k - * is larger than threshold then CPU will be used - * - * Default value is 128. - */ -ENV.registerFlag('TOPK_K_CPU_HANDOFF_THRESHOLD', () => 128); - -/** Whether we will use the experimental conv op. */ -ENV.registerFlag('WEBGL_EXP_CONV', () => false); - -/** - * If the device performance is low or if no hardware GPU is available, whether - * software WebGL will be used. - */ -ENV.registerFlag('SOFTWARE_WEBGL_ENABLED', () => ENV.getBool('IS_TEST')); - -/** - * For narrow texture (physical height or physical width is 1), if the length of - * any texture edges exceed the threshold, the texture will be reshaped to be - * more squarish. - * - * This flag is used to help some GPUs that could not provide correct - * interpolations for long skinny triangles. We found Mali GPU probably has this - * problem: https://github.com/tensorflow/tfjs/issues/6775. - */ -ENV.registerFlag('WEBGL_MAX_SIZE_FOR_NARROW_TEXTURE', () => Infinity); - -/** - * If the flag is set to true, the max size of the narrow texture will be auto - * computed and it will be considerred as a threshold to reshape the narrow - * texture to be more squarish. - * - * This flag is used to help some GPUs that could not provide correct - * interpolations for long skinny triangles. We found Mali GPU probably has this - * problem: https://github.com/tensorflow/tfjs/issues/6775. - */ -ENV.registerFlag('WEBGL_AUTO_SQUARIFY_NARROW_TEXTURE_SHAPE', () => false); - -/** - * Whether to use the customized isnan. It's only useful for webgl2 since webgl1 - * doesn't have the builtin isnan. - */ -ENV.registerFlag('WEBGL2_ISNAN_CUSTOM', () => false); - -/** Experimental flag, whether enter compile only phase. */ -ENV.registerFlag('ENGINE_COMPILE_ONLY', () => false); diff --git a/tfjs-master/tfjs-backend-webgl/src/flags_webgl_test.ts b/tfjs-master/tfjs-backend-webgl/src/flags_webgl_test.ts deleted file mode 100644 index 3a999c7de..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/flags_webgl_test.ts +++ /dev/null @@ -1,481 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '@tensorflow/tfjs-core'; -import {device_util} from '@tensorflow/tfjs-core'; -// tslint:disable-next-line: no-imports-from-dist -import {describeWithFlags} from '@tensorflow/tfjs-core/dist/jasmine_util'; - -import {WEBGL_ENVS} from './backend_webgl_test_registry'; -import * as canvas_util from './canvas_util'; -import {forceHalfFloat, webgl_util} from './webgl'; - -describe('WEBGL_FORCE_F16_TEXTURES', () => { - afterAll(() => tf.env().reset()); - - it('can be activated via forceHalfFloat utility', () => { - forceHalfFloat(); - expect(tf.env().getBool('WEBGL_FORCE_F16_TEXTURES')).toBe(true); - }); - - it('turns off WEBGL_RENDER_FLOAT32_ENABLED', () => { - tf.env().reset(); - forceHalfFloat(); - expect(tf.env().getBool('WEBGL_RENDER_FLOAT32_ENABLED')).toBe(false); - }); -}); - -const RENDER_FLOAT32_ENVS = { - flags: {'WEBGL_RENDER_FLOAT32_CAPABLE': true}, - predicate: WEBGL_ENVS.predicate -}; - -const RENDER_FLOAT16_ENVS = { - flags: {'WEBGL_RENDER_FLOAT32_CAPABLE': false}, - predicate: WEBGL_ENVS.predicate -}; - -describeWithFlags('WEBGL_RENDER_FLOAT32_CAPABLE', RENDER_FLOAT32_ENVS, () => { - beforeEach(() => { - tf.env().reset(); - }); - - afterAll(() => tf.env().reset()); - - it('should be independent of forcing f16 rendering', () => { - forceHalfFloat(); - expect(tf.env().getBool('WEBGL_RENDER_FLOAT32_CAPABLE')).toBe(true); - }); - - it('if user is not forcing f16, device should render to f32', () => { - expect(tf.env().getBool('WEBGL_RENDER_FLOAT32_ENABLED')).toBe(true); - }); -}); - -describeWithFlags('WEBGL_RENDER_FLOAT32_CAPABLE', RENDER_FLOAT16_ENVS, () => { - beforeEach(() => { - tf.env().reset(); - }); - - afterAll(() => tf.env().reset()); - - it('should be independent of forcing f16 rendering', () => { - forceHalfFloat(); - expect(tf.env().getBool('WEBGL_RENDER_FLOAT32_CAPABLE')).toBe(false); - }); - - it('should be reflected in WEBGL_RENDER_FLOAT32_ENABLED', () => { - expect(tf.env().getBool('WEBGL_RENDER_FLOAT32_ENABLED')).toBe(false); - }); -}); - -describe('HAS_WEBGL', () => { - beforeEach(() => tf.env().reset()); - afterAll(() => tf.env().reset()); - - it('false when version is 0', () => { - tf.env().set('WEBGL_VERSION', 0); - expect(tf.env().getBool('HAS_WEBGL')).toBe(false); - }); - - it('true when version is 1', () => { - tf.env().set('WEBGL_VERSION', 1); - expect(tf.env().getBool('HAS_WEBGL')).toBe(true); - }); - - it('true when version is 2', () => { - tf.env().set('WEBGL_VERSION', 2); - expect(tf.env().getBool('HAS_WEBGL')).toBe(true); - }); -}); - -describe('WEBGL_PACK', () => { - beforeEach(() => tf.env().reset()); - afterAll(() => tf.env().reset()); - - it('true when HAS_WEBGL is true', () => { - tf.env().set('HAS_WEBGL', true); - expect(tf.env().getBool('WEBGL_PACK')).toBe(true); - }); - - it('false when HAS_WEBGL is false', () => { - tf.env().set('HAS_WEBGL', false); - expect(tf.env().getBool('WEBGL_PACK')).toBe(false); - }); -}); - -describe('WEBGL_PACK_NORMALIZATION', () => { - beforeEach(() => tf.env().reset()); - afterAll(() => tf.env().reset()); - - it('true when WEBGL_PACK is true', () => { - tf.env().set('WEBGL_PACK', true); - expect(tf.env().getBool('WEBGL_PACK_NORMALIZATION')).toBe(true); - }); - - it('false when WEBGL_PACK is false', () => { - tf.env().set('WEBGL_PACK', false); - expect(tf.env().getBool('WEBGL_PACK_NORMALIZATION')).toBe(false); - }); -}); - -describe('WEBGL_PACK_CLIP', () => { - beforeEach(() => tf.env().reset()); - afterAll(() => tf.env().reset()); - - it('true when WEBGL_PACK is true', () => { - tf.env().set('WEBGL_PACK', true); - expect(tf.env().getBool('WEBGL_PACK_CLIP')).toBe(true); - }); - - it('false when WEBGL_PACK is false', () => { - tf.env().set('WEBGL_PACK', false); - expect(tf.env().getBool('WEBGL_PACK_CLIP')).toBe(false); - }); -}); - -describe('WEBGL_PACK_DEPTHWISECONV', () => { - beforeEach(() => tf.env().reset()); - afterAll(() => tf.env().reset()); - - it('true when WEBGL_PACK is true', () => { - tf.env().set('WEBGL_PACK', true); - expect(tf.env().getBool('WEBGL_PACK_DEPTHWISECONV')).toBe(true); - }); - - it('false when WEBGL_PACK is false', () => { - tf.env().set('WEBGL_PACK', false); - expect(tf.env().getBool('WEBGL_PACK_DEPTHWISECONV')).toBe(false); - }); -}); - -describe('WEBGL_PACK_BINARY_OPERATIONS', () => { - beforeEach(() => tf.env().reset()); - afterAll(() => tf.env().reset()); - - it('true when WEBGL_PACK is true', () => { - tf.env().set('WEBGL_PACK', true); - expect(tf.env().getBool('WEBGL_PACK_BINARY_OPERATIONS')).toBe(true); - }); - - it('false when WEBGL_PACK is false', () => { - tf.env().set('WEBGL_PACK', false); - expect(tf.env().getBool('WEBGL_PACK_BINARY_OPERATIONS')).toBe(false); - }); -}); - -describe('WEBGL_PACK_ARRAY_OPERATIONS', () => { - beforeEach(() => tf.env().reset()); - afterAll(() => tf.env().reset()); - - it('true when WEBGL_PACK is true', () => { - tf.env().set('WEBGL_PACK', true); - expect(tf.env().getBool('WEBGL_PACK_ARRAY_OPERATIONS')).toBe(true); - }); - - it('false when WEBGL_PACK is false', () => { - tf.env().set('WEBGL_PACK', false); - expect(tf.env().getBool('WEBGL_PACK_ARRAY_OPERATIONS')).toBe(false); - }); -}); - -describe('WEBGL_PACK_IMAGE_OPERATIONS', () => { - beforeEach(() => tf.env().reset()); - afterAll(() => tf.env().reset()); - - it('true when WEBGL_PACK is true', () => { - tf.env().set('WEBGL_PACK', true); - expect(tf.env().getBool('WEBGL_PACK_IMAGE_OPERATIONS')).toBe(true); - }); - - it('false when WEBGL_PACK is false', () => { - tf.env().set('WEBGL_PACK', false); - expect(tf.env().getBool('WEBGL_PACK_IMAGE_OPERATIONS')).toBe(false); - }); -}); - -describe('WEBGL_PACK_REDUCE', () => { - beforeEach(() => tf.env().reset()); - afterAll(() => tf.env().reset()); - - it('true when WEBGL_PACK is true', () => { - tf.env().set('WEBGL_PACK', true); - expect(tf.env().getBool('WEBGL_PACK_REDUCE')).toBe(true); - }); - - it('false when WEBGL_PACK is false', () => { - tf.env().set('WEBGL_PACK', false); - expect(tf.env().getBool('WEBGL_PACK_REDUCE')).toBe(false); - }); -}); - -describe('WEBGL_LAZILY_UNPACK', () => { - beforeEach(() => tf.env().reset()); - afterAll(() => tf.env().reset()); - - it('true when WEBGL_PACK is true', () => { - tf.env().set('WEBGL_PACK', true); - expect(tf.env().getBool('WEBGL_LAZILY_UNPACK')).toBe(true); - }); - - it('false when WEBGL_PACK is false', () => { - tf.env().set('WEBGL_PACK', false); - expect(tf.env().getBool('WEBGL_LAZILY_UNPACK')).toBe(false); - }); -}); - -describe('WEBGL_CONV_IM2COL', () => { - beforeEach(() => tf.env().reset()); - afterAll(() => tf.env().reset()); - - it('true when WEBGL_PACK is true', () => { - tf.env().set('WEBGL_PACK', true); - expect(tf.env().getBool('WEBGL_CONV_IM2COL')).toBe(true); - }); - - it('false when WEBGL_PACK is false', () => { - tf.env().set('WEBGL_PACK', false); - expect(tf.env().getBool('WEBGL_CONV_IM2COL')).toBe(false); - }); -}); - -describe('WEBGL_MAX_TEXTURE_SIZE', () => { - beforeEach(() => { - tf.env().reset(); - webgl_util.resetMaxTextureSize(); - canvas_util.setWebGLContext(2, { - MAX_TEXTURE_SIZE: 101, - isContextLost: () => false, - disable: (cap: number) => {}, - enable: (cap: number) => {}, - cullFace: (mode: number) => {}, - getParameter: (param: number) => { - if (param === 101) { - return 50; - } - throw new Error(`Got undefined param ${param}.`); - } - } as unknown as WebGLRenderingContext); - }); - afterAll(() => { - canvas_util.clearWebGLContext(2); - tf.env().reset(); - webgl_util.resetMaxTextureSize(); - }); - - it('is a function of gl.getParameter(MAX_TEXTURE_SIZE)', () => { - expect(tf.env().getNumber('WEBGL_MAX_TEXTURE_SIZE')).toBe(50); - }); -}); - -describe('WEBGL_MAX_TEXTURES_IN_SHADER', () => { - let maxTextures: number; - beforeEach(() => { - tf.env().reset(); - webgl_util.resetMaxTexturesInShader(); - - canvas_util.setWebGLContext(2, { - MAX_TEXTURE_IMAGE_UNITS: 101, - isContextLost: () => false, - disable: (cap: number) => {}, - enable: (cap: number) => {}, - cullFace: (mode: number) => {}, - getParameter: (param: number) => { - if (param === 101) { - return maxTextures; - } - throw new Error(`Got undefined param ${param}.`); - } - } as unknown as WebGLRenderingContext); - }); - afterAll(() => { - canvas_util.clearWebGLContext(2); - tf.env().reset(); - webgl_util.resetMaxTexturesInShader(); - }); - - it('is a function of gl.getParameter(MAX_TEXTURE_IMAGE_UNITS)', () => { - maxTextures = 10; - expect(tf.env().getNumber('WEBGL_MAX_TEXTURES_IN_SHADER')).toBe(10); - }); - - it('is capped at 16', () => { - maxTextures = 20; - expect(tf.env().getNumber('WEBGL_MAX_TEXTURES_IN_SHADER')).toBe(16); - }); -}); - -describe('WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE', () => { - beforeEach(() => { - tf.env().reset(); - device_util.mockIsMobile(undefined); - }); - afterAll(() => { - tf.env().reset(); - device_util.mockIsMobile(undefined); - }); - - it('disjoint query timer disabled', () => { - tf.env().set('WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION', 0); - - expect(tf.env().getBool('WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE')) - .toBe(false); - }); - - it('disjoint query timer enabled, mobile', () => { - tf.env().set('WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION', 1); - device_util.mockIsMobile(true); - - expect(tf.env().getBool('WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE')) - .toBe(false); - }); - - it('disjoint query timer enabled, not mobile', () => { - tf.env().set('WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION', 1); - device_util.mockIsMobile(false); - - expect(tf.env().getBool('WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE')) - .toBe(true); - }); -}); - -describe('WEBGL_SIZE_UPLOAD_UNIFORM', () => { - beforeEach(() => tf.env().reset()); - afterAll(() => tf.env().reset()); - - it('is 0 when there is no float32 bit support', () => { - tf.env().set('WEBGL_RENDER_FLOAT32_ENABLED', false); - expect(tf.env().getNumber('WEBGL_SIZE_UPLOAD_UNIFORM')).toBe(0); - }); - - it('is > 0 when there is float32 bit support', () => { - tf.env().set('WEBGL_RENDER_FLOAT32_ENABLED', true); - expect(tf.env().getNumber('WEBGL_SIZE_UPLOAD_UNIFORM')).toBeGreaterThan(0); - }); -}); - -describeWithFlags('WEBGL_DELETE_TEXTURE_THRESHOLD', WEBGL_ENVS, () => { - it('should throw an error if given a negative value', () => { - expect(() => tf.env().set('WEBGL_DELETE_TEXTURE_THRESHOLD', -2)).toThrow(); - }); -}); - -describeWithFlags('WEBGL_FLUSH_THRESHOLD', WEBGL_ENVS, () => { - beforeEach(() => tf.env().reset()); - afterAll(() => tf.env().reset()); - - it('should return the correct default value', () => { - if (device_util.isMobile()) { - expect(tf.env().getNumber('WEBGL_FLUSH_THRESHOLD')).toEqual(1); - } else { - expect(tf.env().getNumber('WEBGL_FLUSH_THRESHOLD')).toEqual(-1); - } - }); - it('should throw an error if given a negative value', () => { - expect(() => tf.env().set('WEBGL_FLUSH_THRESHOLD', -2)).toThrow(); - }); -}); - -describe('CPU_HANDOFF_SIZE_THRESHOLD', () => { - beforeEach(() => tf.env().reset()); - afterAll(() => tf.env().reset()); - - it('returns correct value when CPU_HANDOFF_SIZE_THRESHOLD is set', () => { - tf.env().set('CPU_HANDOFF_SIZE_THRESHOLD', 256); - expect(tf.env().getNumber('CPU_HANDOFF_SIZE_THRESHOLD')).toBe(256); - }); - - it('returns default when WEBGL_PACK is not set', () => { - expect(tf.env().getNumber('CPU_HANDOFF_SIZE_THRESHOLD')).toBe(128); - }); -}); - -const LAST_DIM_FLAG = 'TOPK_LAST_DIM_CPU_HANDOFF_SIZE_THRESHOLD'; - -describeWithFlags(LAST_DIM_FLAG, WEBGL_ENVS, () => { - beforeEach(() => tf.env().reset()); - afterAll(() => tf.env().reset()); - - it(`returns correct value when ${LAST_DIM_FLAG} is set`, () => { - tf.env().set(LAST_DIM_FLAG, 256); - expect(tf.env().getNumber(LAST_DIM_FLAG)).toBe(256); - }); - - it(`returns default when ${LAST_DIM_FLAG} is not set`, () => { - expect(tf.env().getNumber(LAST_DIM_FLAG)).toBe(100000); - }); -}); - -const K_FLAG = 'TOPK_K_CPU_HANDOFF_THRESHOLD'; - -describeWithFlags(K_FLAG, WEBGL_ENVS, () => { - beforeEach(() => tf.env().reset()); - afterAll(() => tf.env().reset()); - - it(`returns correct value when ${K_FLAG} is set`, () => { - tf.env().set(K_FLAG, 256); - expect(tf.env().getNumber(K_FLAG)).toBe(256); - }); - - it(`returns default when ${K_FLAG} is not set`, () => { - expect(tf.env().getNumber(K_FLAG)).toBe(128); - }); -}); - -describe('WEBGL_EXP_CONV', () => { - beforeEach(() => tf.env().reset()); - afterAll(() => tf.env().reset()); - - it('true when WEBGL_PACK is true', () => { - expect(tf.env().getBool('WEBGL_EXP_CONV')).toBe(false); - }); -}); - -const MAX_SIZE_FOR_NARROR_TEX_FLAG = 'WEBGL_MAX_SIZE_FOR_NARROW_TEXTURE'; - -describeWithFlags(MAX_SIZE_FOR_NARROR_TEX_FLAG, WEBGL_ENVS, () => { - beforeEach(() => tf.env().reset()); - afterAll(() => tf.env().reset()); - - it(`returns correct value when ${MAX_SIZE_FOR_NARROR_TEX_FLAG} is set`, - () => { - tf.env().set(MAX_SIZE_FOR_NARROR_TEX_FLAG, 2048); - expect(tf.env().getNumber(MAX_SIZE_FOR_NARROR_TEX_FLAG)).toBe(2048); - }); - - it(`returns default when ${MAX_SIZE_FOR_NARROR_TEX_FLAG} is not set`, () => { - expect(tf.env().getNumber(MAX_SIZE_FOR_NARROR_TEX_FLAG)).toBe(Infinity); - }); -}); - -const AUTO_SQUARIFY_NARROW_TEX_FLAG = - 'WEBGL_AUTO_SQUARIFY_NARROW_TEXTURE_SHAPE'; - -describeWithFlags(AUTO_SQUARIFY_NARROW_TEX_FLAG, WEBGL_ENVS, () => { - beforeEach(() => tf.env().reset()); - afterAll(() => tf.env().reset()); - - it(`returns correct value when ${AUTO_SQUARIFY_NARROW_TEX_FLAG} is set`, - () => { - tf.env().set(AUTO_SQUARIFY_NARROW_TEX_FLAG, true); - expect(tf.env().getBool(AUTO_SQUARIFY_NARROW_TEX_FLAG)).toBe(true); - }); - - it(`returns default when ${AUTO_SQUARIFY_NARROW_TEX_FLAG} is not set`, () => { - expect(tf.env().getBool(AUTO_SQUARIFY_NARROW_TEX_FLAG)).toBe(false); - }); -}); diff --git a/tfjs-master/tfjs-backend-webgl/src/flip_left_right_gpu.ts b/tfjs-master/tfjs-backend-webgl/src/flip_left_right_gpu.ts deleted file mode 100644 index 1b7fd05cc..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/flip_left_right_gpu.ts +++ /dev/null @@ -1,45 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {GPGPUProgram} from './gpgpu_math'; - -export class FlipLeftRightProgram implements GPGPUProgram { - variableNames = ['Image']; - outputShape: number[] = []; - userCode: string; - - constructor(imageShape: [number, number, number, number]) { - const imageWidth = imageShape[2]; - this.outputShape = imageShape; - - this.userCode = ` - void main() { - ivec4 coords = getOutputCoords(); - int x = coords[2]; - - int coordX = ${imageWidth} - x - 1; - float outputValue; - if(coordX >= 0 && coordX < ${imageWidth}) { - outputValue = getImage(coords[0], coords[1], coordX, coords[3]); - } else { - outputValue = getImage(coords[0], coords[1], coords[2], coords[3]); - } - setOutput(outputValue); - } - `; - } -} diff --git a/tfjs-master/tfjs-backend-webgl/src/gather_gpu.ts b/tfjs-master/tfjs-backend-webgl/src/gather_gpu.ts deleted file mode 100644 index e867bf4ad..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/gather_gpu.ts +++ /dev/null @@ -1,59 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {GPGPUProgram} from './gpgpu_math'; -import {getCoordsDataType} from './shader_compiler'; - -export type GatherShape = [number, number, number, number]; - -export class GatherProgram implements GPGPUProgram { - variableNames = ['A', 'indices']; - outputShape: number[]; - userCode: string; - rank: number; - - constructor(aShape: GatherShape, outputShape: GatherShape) { - this.outputShape = outputShape; - this.rank = outputShape.length; - const dtype = getCoordsDataType(this.rank); - const sourceCoords = getSourceCoords(aShape, 2); - - this.userCode = ` - void main() { - ${dtype} resRC = getOutputCoords(); - int index = int(getIndices(resRC.x, resRC.z)); - float inBounds = (index >= 0) && (index < ${aShape[2]}) ? 1.0 : 0.0; - setOutput(inBounds * getA(${sourceCoords})); - } - `; - } -} - -// The input and output are always flattened into rank 4 tensors. -function getSourceCoords(aShape: GatherShape, axis: number): string { - const currentCoords = ['resRC.x', 'resRC.y', 'resRC.z', 'resRC.w']; - - const sourceCoords = []; - for (let i = 0; i < aShape.length; i++) { - if (i === 2) { - sourceCoords.push('index'); - } else { - sourceCoords.push(`${currentCoords[i]}`); - } - } - return sourceCoords.join(); -} diff --git a/tfjs-master/tfjs-backend-webgl/src/gather_nd_gpu.ts b/tfjs-master/tfjs-backend-webgl/src/gather_nd_gpu.ts deleted file mode 100644 index 507f9f743..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/gather_nd_gpu.ts +++ /dev/null @@ -1,52 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {GPGPUProgram} from './gpgpu_math'; -import {getCoordsDataType} from './shader_compiler'; - -export class GatherNDProgram implements GPGPUProgram { - variableNames = ['x', 'indices']; - outputShape: number[]; - userCode: string; - constructor( - private sliceDim: number, private strides: number[], shape: number[], - private paramsShape: number[]) { - this.outputShape = shape; - const dtype = getCoordsDataType(shape.length); - - let mainLoop = ` - int index;`; - for (let j = 0; j < this.sliceDim; j++) { - mainLoop += ` - index = round(getIndices(coords[0], ${j})); - out_of_bounds = out_of_bounds || index < 0; - out_of_bounds = out_of_bounds || index >= ${this.paramsShape[j]}; - flattenIndex += index * ${this.strides[j]};`; - } - - this.userCode = ` - void main() { - ${dtype} coords = getOutputCoords(); - int flattenIndex = 0; - bool out_of_bounds = false; - - ${mainLoop} - - setOutput(out_of_bounds ? 0.0 : getX(flattenIndex, coords[1])); - } - `; - } -} diff --git a/tfjs-master/tfjs-backend-webgl/src/glsl_version.ts b/tfjs-master/tfjs-backend-webgl/src/glsl_version.ts deleted file mode 100644 index 9b36a9c7e..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/glsl_version.ts +++ /dev/null @@ -1,143 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {env} from '@tensorflow/tfjs-core'; - -export type GLSL = { - version: string, - attribute: string, - varyingVs: string, - varyingFs: string, - texture2D: string, - output: string, - defineOutput: string, - defineSpecialNaN: string, - defineSpecialInf: string, - defineRound: string -}; - -export function getGlslDifferences(): GLSL { - let version: string; - let attribute: string; - let varyingVs: string; - let varyingFs: string; - let texture2D: string; - let output: string; - let defineOutput: string; - let defineSpecialNaN: string; - let defineSpecialInf: string; - let defineRound: string; - - if (env().getNumber('WEBGL_VERSION') === 2) { - version = '#version 300 es'; - attribute = 'in'; - varyingVs = 'out'; - varyingFs = 'in'; - texture2D = 'texture'; - output = 'outputColor'; - defineOutput = 'out vec4 outputColor;'; - - // Use custom isnan definition to work across differences between - // implementations on various platforms. While this should happen in ANGLE - // we still see differences between android and windows (on chrome) when - // using isnan directly. Since WebGL2 supports uint type and - // floatBitsToUinT built-in function, we could implment isnan following - // IEEE 754 rules. - // NaN defination in IEEE 754-1985 is : - // - sign = either 0 or 1. - // - biased exponent = all 1 bits. - // - fraction = anything except all 0 bits (since all 0 bits represents - // infinity). - // https://en.wikipedia.org/wiki/IEEE_754-1985#Representation_of_non-numbers - defineSpecialNaN = env().getBool('WEBGL2_ISNAN_CUSTOM') ? ` - bool isnan_custom(float val) { - uint floatToUint = floatBitsToUint(val); - return (floatToUint & 0x7fffffffu) > 0x7f800000u; - } - - bvec4 isnan_custom(vec4 val) { - return bvec4(isnan_custom(val.x), - isnan_custom(val.y), isnan_custom(val.z), isnan_custom(val.w)); - } - - #define isnan(value) isnan_custom(value) - ` : - ''; - // In webgl 2 we do not need to specify a custom isinf so there is no - // need for a special INFINITY constant. - defineSpecialInf = ``; - defineRound = ` - #define round(value) newRound(value) - int newRound(float value) { - return int(floor(value + 0.5)); - } - - ivec4 newRound(vec4 value) { - return ivec4(floor(value + vec4(0.5))); - } - `; - } else { - version = ''; - attribute = 'attribute'; - varyingVs = 'varying'; - varyingFs = 'varying'; - texture2D = 'texture2D'; - output = 'gl_FragColor'; - defineOutput = ''; - // WebGL1 has no built in isnan so we define one here. - defineSpecialNaN = ` - #define isnan(value) isnan_custom(value) - bool isnan_custom(float val) { - return (val > 0. || val < 1. || val == 0.) ? false : true; - } - bvec4 isnan_custom(vec4 val) { - return bvec4(isnan(val.x), isnan(val.y), isnan(val.z), isnan(val.w)); - } - `; - defineSpecialInf = ` - uniform float INFINITY; - - bool isinf(float val) { - return abs(val) == INFINITY; - } - bvec4 isinf(vec4 val) { - return equal(abs(val), vec4(INFINITY)); - } - `; - defineRound = ` - int round(float value) { - return int(floor(value + 0.5)); - } - - ivec4 round(vec4 value) { - return ivec4(floor(value + vec4(0.5))); - } - `; - } - - return { - version, - attribute, - varyingVs, - varyingFs, - texture2D, - output, - defineOutput, - defineSpecialNaN, - defineSpecialInf, - defineRound - }; -} diff --git a/tfjs-master/tfjs-backend-webgl/src/gpgpu_context.ts b/tfjs-master/tfjs-backend-webgl/src/gpgpu_context.ts deleted file mode 100644 index 2873b2648..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/gpgpu_context.ts +++ /dev/null @@ -1,710 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {env, PixelData, TypedArray, util} from '@tensorflow/tfjs-core'; - -import {getWebGLContext, setWebGLContext} from './canvas_util'; -import * as gpgpu_util from './gpgpu_util'; -import * as tex_util from './tex_util'; -import {Texture, TextureConfig} from './tex_util'; -import {WebGL1DisjointQueryTimerExtension, WebGL2DisjointQueryTimerExtension, WebGLParallelCompilationExtension} from './webgl_types'; -import * as webgl_util from './webgl_util'; - -export interface FenceContext { - query: WebGLQuery|WebGLSync; - isFencePassed(): boolean; -} - -type WebGLVao = WebGLVertexArrayObject|WebGLVertexArrayObjectOES; - -export interface GPGPUContextProgram extends WebGLProgram { - vao: WebGLVao; -} - -export class GPGPUContext { - gl: WebGLRenderingContext; - textureFloatExtension: {}; - textureHalfFloatExtension: {}; - colorBufferFloatExtension: {}; - colorBufferHalfFloatExtension: {}; - disjointQueryTimerExtension: WebGL2DisjointQueryTimerExtension| - WebGL1DisjointQueryTimerExtension; - parallelCompilationExtension: WebGLParallelCompilationExtension; - vertexBuffer: WebGLBuffer; - indexBuffer: WebGLBuffer; - framebuffer: WebGLFramebuffer; - outputTexture: WebGLTexture|null = null; - program: GPGPUContextProgram|null = null; - private disposed = false; - private disjoint: boolean; - private vertexShader: WebGLShader; - textureConfig: TextureConfig; - - createVertexArray: () => WebGLVao | null; - bindVertexArray: (vao: WebGLVao|null) => void; - deleteVertexArray: (vao: WebGLVao|null) => void; - getVertexArray: () => WebGLVao | null; - - constructor(gl?: WebGLRenderingContext) { - const glVersion = env().getNumber('WEBGL_VERSION'); - if (gl != null) { - this.gl = gl; - setWebGLContext(glVersion, gl); - } else { - this.gl = getWebGLContext(glVersion); - } - gl = this.gl; - - if (env().getNumber('WEBGL_VERSION') === 2) { - const gl2 = gl as WebGL2RenderingContext; - this.createVertexArray = () => { - return webgl_util.callAndCheck(gl2, () => gl2.createVertexArray()); - }; - this.bindVertexArray = (vao: WebGLVao|null) => { - return webgl_util.callAndCheck( - gl2, () => gl2.bindVertexArray(vao as WebGLVertexArrayObject)); - }; - this.deleteVertexArray = (vao: WebGLVao|null) => { - return webgl_util.callAndCheck( - gl2, () => gl2.deleteVertexArray(vao as WebGLVertexArrayObject)); - }; - this.getVertexArray = () => { - return webgl_util.callAndCheck( - gl2, () => gl2.getParameter(gl2.VERTEX_ARRAY_BINDING)); - }; - } else if (gl != null) { - const ext = gl.getExtension('OES_vertex_array_object'); - if (ext == null) { - throw new Error( - 'All WebGL1 implementations are expected to offer' + - ' OES_vertex_array_object.'); - } - this.createVertexArray = () => { - return webgl_util.callAndCheck(gl, () => ext.createVertexArrayOES()); - }; - this.bindVertexArray = (vao: WebGLVao|null) => { - return webgl_util.callAndCheck( - gl, () => ext.bindVertexArrayOES(vao as WebGLVertexArrayObjectOES)); - }; - this.deleteVertexArray = (vao: WebGLVao|null) => { - return webgl_util.callAndCheck( - gl, - () => ext.deleteVertexArrayOES(vao as WebGLVertexArrayObjectOES)); - }; - this.getVertexArray = () => { - return webgl_util.callAndCheck( - gl, () => gl.getParameter(ext.VERTEX_ARRAY_BINDING_OES)); - }; - } - - // WebGL 2.0 enables texture floats without an extension. - let COLOR_BUFFER_FLOAT = 'WEBGL_color_buffer_float'; - const COLOR_BUFFER_HALF_FLOAT = 'EXT_color_buffer_half_float'; - this.parallelCompilationExtension = - this.gl.getExtension('KHR_parallel_shader_compile'); - if (env().getNumber('WEBGL_VERSION') === 1) { - const TEXTURE_FLOAT = 'OES_texture_float'; - const TEXTURE_HALF_FLOAT = 'OES_texture_half_float'; - - this.textureFloatExtension = - webgl_util.getExtensionOrThrow(this.gl, TEXTURE_FLOAT); - if (webgl_util.hasExtension(this.gl, TEXTURE_HALF_FLOAT)) { - this.textureHalfFloatExtension = - webgl_util.getExtensionOrThrow(this.gl, TEXTURE_HALF_FLOAT); - } else if (env().get('WEBGL_FORCE_F16_TEXTURES')) { - throw new Error( - 'GL context does not support half float textures, yet the ' + - 'environment flag WEBGL_FORCE_F16_TEXTURES is set to true.'); - } - - this.colorBufferFloatExtension = this.gl.getExtension(COLOR_BUFFER_FLOAT); - if (webgl_util.hasExtension(this.gl, COLOR_BUFFER_HALF_FLOAT)) { - this.colorBufferHalfFloatExtension = - webgl_util.getExtensionOrThrow(this.gl, COLOR_BUFFER_HALF_FLOAT); - } else if (env().get('WEBGL_FORCE_F16_TEXTURES')) { - throw new Error( - 'GL context does not support color renderable half floats, yet ' + - 'the environment flag WEBGL_FORCE_F16_TEXTURES is set to true.'); - } - } else { - COLOR_BUFFER_FLOAT = 'EXT_color_buffer_float'; - if (webgl_util.hasExtension(this.gl, COLOR_BUFFER_FLOAT)) { - this.colorBufferFloatExtension = - this.gl.getExtension(COLOR_BUFFER_FLOAT); - } else if (webgl_util.hasExtension(this.gl, COLOR_BUFFER_HALF_FLOAT)) { - this.colorBufferHalfFloatExtension = - this.gl.getExtension(COLOR_BUFFER_HALF_FLOAT); - } else { - throw new Error('GL context does not support color renderable floats'); - } - } - - this.vertexBuffer = gpgpu_util.createVertexBuffer(this.gl); - this.indexBuffer = gpgpu_util.createIndexBuffer(this.gl); - this.framebuffer = webgl_util.createFramebuffer(this.gl); - - this.textureConfig = - tex_util.getTextureConfig(this.gl, this.textureHalfFloatExtension); - } - - private get debug(): boolean { - return env().getBool('DEBUG'); - } - - public dispose() { - if (this.disposed) { - return; - } - if (this.program != null) { - console.warn( - 'Disposing a GPGPUContext that still has a bound WebGLProgram.' + - ' This is probably a resource leak, delete the program with ' + - 'GPGPUContext.deleteProgram before disposing.'); - } - if (this.outputTexture != null) { - console.warn( - 'Disposing a GPGPUContext that still has a bound output matrix ' + - 'texture. This is probably a resource leak, delete the output ' + - 'matrix texture with GPGPUContext.deleteMatrixTexture before ' + - 'disposing.'); - } - const gl = this.gl; - webgl_util.callAndCheck(gl, () => gl.finish()); - webgl_util.callAndCheck(gl, () => gl.bindFramebuffer(gl.FRAMEBUFFER, null)); - webgl_util.callAndCheck(gl, () => gl.deleteFramebuffer(this.framebuffer)); - webgl_util.callAndCheck(gl, () => gl.bindBuffer(gl.ARRAY_BUFFER, null)); - webgl_util.callAndCheck( - gl, () => gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null)); - webgl_util.callAndCheck(gl, () => gl.deleteBuffer(this.indexBuffer)); - this.disposed = true; - } - - public createFloat32MatrixTexture(rows: number, columns: number): Texture { - this.throwIfDisposed(); - return gpgpu_util.createFloat32MatrixTexture( - this.gl, rows, columns, this.textureConfig); - } - - public createFloat16MatrixTexture(rows: number, columns: number): Texture { - this.throwIfDisposed(); - return gpgpu_util.createFloat16MatrixTexture( - this.gl, rows, columns, this.textureConfig); - } - - public createUnsignedBytesMatrixTexture(rows: number, columns: number): - Texture { - this.throwIfDisposed(); - return gpgpu_util.createUnsignedBytesMatrixTexture( - this.gl, rows, columns, this.textureConfig); - } - - public uploadPixelDataToTexture( - texture: WebGLTexture, - pixels: PixelData|ImageData|HTMLImageElement|HTMLCanvasElement| - ImageBitmap) { - this.throwIfDisposed(); - gpgpu_util.uploadPixelDataToTexture(this.gl, texture, pixels); - } - - public uploadDenseMatrixToTexture( - texture: WebGLTexture, width: number, height: number, data: TypedArray) { - this.throwIfDisposed(); - gpgpu_util.uploadDenseMatrixToTexture( - this.gl, texture, width, height, data, this.textureConfig); - } - - public createFloat16PackedMatrixTexture(rows: number, columns: number): - Texture { - this.throwIfDisposed(); - return gpgpu_util.createFloat16PackedMatrixTexture( - this.gl, rows, columns, this.textureConfig); - } - - public createPackedMatrixTexture(rows: number, columns: number): Texture { - this.throwIfDisposed(); - return gpgpu_util.createPackedMatrixTexture( - this.gl, rows, columns, this.textureConfig); - } - - public deleteMatrixTexture(texture: WebGLTexture) { - this.throwIfDisposed(); - if (this.outputTexture === texture) { - webgl_util.unbindColorTextureFromFramebuffer(this.gl, this.framebuffer); - this.outputTexture = null; - } - webgl_util.callAndCheck(this.gl, () => this.gl.deleteTexture(texture)); - } - - public downloadByteEncodedFloatMatrixFromOutputTexture( - texture: WebGLTexture, rows: number, columns: number): Float32Array { - return this.downloadMatrixDriver( - texture, - () => gpgpu_util.downloadByteEncodedFloatMatrixFromOutputTexture( - this.gl, rows, columns, this.textureConfig)); - } - - public downloadPackedMatrixFromBuffer( - buffer: WebGLBuffer, batch: number, rows: number, columns: number, - physicalRows: number, physicalCols: number): Float32Array { - return gpgpu_util.downloadPackedMatrixFromBuffer( - this.gl, buffer, batch, rows, columns, physicalRows, physicalCols, - this.textureConfig); - } - - public downloadFloat32MatrixFromBuffer(buffer: WebGLBuffer, size: number): - Float32Array { - return gpgpu_util.downloadFloat32MatrixFromBuffer(this.gl, buffer, size); - } - - public createBufferFromTexture( - texture: WebGLTexture, rows: number, columns: number): WebGLBuffer { - this.bindTextureToFrameBuffer(texture); - const result = gpgpu_util.createBufferFromOutputTexture( - this.gl as WebGL2RenderingContext, rows, columns, this.textureConfig); - this.unbindTextureToFrameBuffer(); - return result; - } - - public createAndWaitForFence(): Promise { - const fenceContext = this.createFence(this.gl); - return this.pollFence(fenceContext); - } - - private createFence(gl: WebGLRenderingContext): FenceContext { - let query: WebGLQuery|WebGLSync; - let isFencePassed: () => boolean; - - if (env().getBool('WEBGL_FENCE_API_ENABLED')) { - const gl2 = gl as WebGL2RenderingContext; - - const sync = gl2.fenceSync(gl2.SYNC_GPU_COMMANDS_COMPLETE, 0); - gl.flush(); - - isFencePassed = () => { - const status = gl2.clientWaitSync(sync, 0, 0); - return status === gl2.ALREADY_SIGNALED || - status === gl2.CONDITION_SATISFIED; - }; - - query = sync; - } else if ( - env().getNumber('WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION') > 0) { - query = this.beginQuery(); - this.endQuery(); - isFencePassed = () => this.isQueryAvailable( - query, - env().getNumber('WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION')); - } else { - // If we have no way to fence, return true immediately. This will fire in - // WebGL 1.0 when there is no disjoint query timer. In this case, because - // the fence passes immediately, we'll immediately ask for a download of - // the texture, which will cause the UI thread to hang. - isFencePassed = () => true; - } - - return {query, isFencePassed}; - } - - public downloadMatrixFromPackedTexture( - texture: WebGLTexture, physicalRows: number, - physicalCols: number): Float32Array { - return this.downloadMatrixDriver( - texture, - () => gpgpu_util.downloadMatrixFromPackedOutputTexture( - this.gl, physicalRows, physicalCols)); - } - - public createProgram(fragmentShader: WebGLShader): GPGPUContextProgram { - this.throwIfDisposed(); - const gl = this.gl; - if (this.vertexShader == null) { - this.vertexShader = gpgpu_util.createVertexShader(gl); - } - const program: WebGLProgram = webgl_util.createProgram(gl); - webgl_util.callAndCheck( - gl, () => gl.attachShader(program, this.vertexShader)); - webgl_util.callAndCheck(gl, () => gl.attachShader(program, fragmentShader)); - webgl_util.linkProgram(gl, program); - - const program2 = Object.assign(program, {vao: this.createVertexArray()}); - if (this.debug) { - webgl_util.validateProgram(gl, program2); - } - return program2; - } - - public buildVao(program: GPGPUContextProgram) { - this.setProgram(program); - this.bindVertexArray(program.vao); - const gl = this.gl; - // Bind index buffer, and vertex buffers based on program attrib - // locations. - webgl_util.callAndCheck( - gl, () => gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.indexBuffer)); - gpgpu_util.bindVertexProgramAttributeStreams( - gl, program, this.vertexBuffer); - } - - public deleteProgram(program: GPGPUContextProgram) { - this.throwIfDisposed(); - if (program === this.program) { - this.program = null; - } - if (program != null) { - webgl_util.callAndCheck(this.gl, () => this.gl.deleteProgram(program)); - this.deleteVertexArray(program.vao); - } - } - - public setProgram(program: GPGPUContextProgram|null) { - this.throwIfDisposed(); - this.program = program; - - if (this.program != null) { - if (this.debug) { - webgl_util.validateProgram(this.gl, this.program); - } - } - webgl_util.callAndCheck(this.gl, () => this.gl.useProgram(program)); - } - - public getUniformLocation( - program: WebGLProgram, uniformName: string, - shouldThrow = true): WebGLUniformLocation { - this.throwIfDisposed(); - if (shouldThrow) { - return webgl_util.getProgramUniformLocationOrThrow( - this.gl, program, uniformName); - } else { - return webgl_util.getProgramUniformLocation( - this.gl, program, uniformName); - } - } - - public getAttributeLocation(program: WebGLProgram, attribute: string): - number { - this.throwIfDisposed(); - return webgl_util.callAndCheck( - this.gl, () => this.gl.getAttribLocation(program, attribute)); - } - - public getUniformLocationNoThrow(program: WebGLProgram, uniformName: string): - WebGLUniformLocation { - this.throwIfDisposed(); - return this.gl.getUniformLocation(program, uniformName); - } - - public setInputMatrixTexture( - inputMatrixTexture: WebGLTexture, uniformLocation: WebGLUniformLocation, - textureUnit: number) { - this.throwIfDisposed(); - this.throwIfNoProgram(); - webgl_util.bindTextureToProgramUniformSampler( - this.gl, inputMatrixTexture, uniformLocation, textureUnit); - } - - public setOutputMatrixTexture( - outputMatrixTexture: WebGLTexture, rows: number, columns: number) { - this.setOutputMatrixTextureDriver(outputMatrixTexture, columns, rows); - } - - public setOutputPackedMatrixTexture( - outputPackedMatrixTexture: WebGLTexture, rows: number, columns: number) { - this.throwIfDisposed(); - const [width, height] = - tex_util.getPackedMatrixTextureShapeWidthHeight(rows, columns); - this.setOutputMatrixTextureDriver(outputPackedMatrixTexture, width, height); - } - - public setOutputMatrixWriteRegion( - startRow: number, numRows: number, startColumn: number, - numColumns: number) { - this.setOutputMatrixWriteRegionDriver( - startColumn, startRow, numColumns, numRows); - } - - public setOutputPackedMatrixWriteRegion( - startRow: number, numRows: number, startColumn: number, - numColumns: number) { - throw new Error('setOutputPackedMatrixWriteRegion not implemented.'); - } - - public debugValidate() { - if (this.program != null) { - webgl_util.validateProgram(this.gl, this.program); - } - webgl_util.validateFramebuffer(this.gl); - } - - public executeProgram() { - this.throwIfDisposed(); - this.throwIfNoProgram(); - const gl = this.gl; - if (this.debug) { - const boundVao = this.getVertexArray(); - console.assert( - boundVao === this.program.vao, - 'VAO changed between setProgram and executeProgram!'); - - this.debugValidate(); - } - webgl_util.callAndCheck( - gl, () => gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, 0)); - } - - public blockUntilAllProgramsCompleted() { - this.throwIfDisposed(); - webgl_util.callAndCheck(this.gl, () => this.gl.finish()); - } - - private getQueryTimerExtension(): WebGL1DisjointQueryTimerExtension - |WebGL2DisjointQueryTimerExtension { - if (this.disjointQueryTimerExtension == null) { - this.disjointQueryTimerExtension = - webgl_util.getExtensionOrThrow( - this.gl, - env().getNumber( - 'WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION') === 2 ? - 'EXT_disjoint_timer_query_webgl2' : - 'EXT_disjoint_timer_query') as - WebGL1DisjointQueryTimerExtension | - WebGL2DisjointQueryTimerExtension; - } - return this.disjointQueryTimerExtension; - } - - private getQueryTimerExtensionWebGL2(): WebGL2DisjointQueryTimerExtension { - return this.getQueryTimerExtension(); - } - - private getQueryTimerExtensionWebGL1(): WebGL1DisjointQueryTimerExtension { - return this.getQueryTimerExtension() as WebGL1DisjointQueryTimerExtension; - } - - beginQuery(): WebGLQuery { - if (env().getNumber('WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION') === 2) { - const gl2 = this.gl as WebGL2RenderingContext; - const ext = this.getQueryTimerExtensionWebGL2(); - - const query = gl2.createQuery(); - gl2.beginQuery(ext.TIME_ELAPSED_EXT, query); - return query; - } - const ext = this.getQueryTimerExtensionWebGL1(); - const query = ext.createQueryEXT() as WebGLQuery; - ext.beginQueryEXT(ext.TIME_ELAPSED_EXT, query); - return query; - } - - endQuery() { - if (env().getNumber('WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION') === 2) { - const gl2 = this.gl as WebGL2RenderingContext; - const ext = this.getQueryTimerExtensionWebGL2(); - gl2.endQuery(ext.TIME_ELAPSED_EXT); - return; - } - const ext = this.getQueryTimerExtensionWebGL1(); - ext.endQueryEXT(ext.TIME_ELAPSED_EXT); - } - - public async waitForQueryAndGetTime(query: WebGLQuery): Promise { - await util.repeatedTry( - () => this.disposed || // while testing contexts are created / disposed - // in rapid succession, so without this check we - // may poll for the query timer indefinitely - this.isQueryAvailable( - query, - env().getNumber( - 'WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION'))); - return this.getQueryTime( - query, env().getNumber('WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION')); - } - - private getQueryTime(query: WebGLQuery, queryTimerVersion: number): number { - if (queryTimerVersion === 0) { - return null; - } - - if (queryTimerVersion === 2) { - const gl2 = this.gl as WebGL2RenderingContext; - - const timeElapsedNanos = gl2.getQueryParameter(query, gl2.QUERY_RESULT); - // Return milliseconds. - return timeElapsedNanos / 1000000; - } else { - const ext = this.getQueryTimerExtensionWebGL1(); - - const timeElapsedNanos = - ext.getQueryObjectEXT(query, ext.QUERY_RESULT_EXT); - // Return milliseconds. - return timeElapsedNanos / 1000000; - } - } - - private isQueryAvailable(query: WebGLQuery, queryTimerVersion: number): - boolean { - if (queryTimerVersion === 0) { - return true; - } - - if (queryTimerVersion === 2) { - const gl2 = this.gl as WebGL2RenderingContext; - const ext = this.getQueryTimerExtensionWebGL2(); - - const available = - gl2.getQueryParameter(query, gl2.QUERY_RESULT_AVAILABLE); - if (this.disjoint == null) { - this.disjoint = this.gl.getParameter(ext.GPU_DISJOINT_EXT); - } - - return available && !this.disjoint; - } else { - const ext = this.getQueryTimerExtensionWebGL1(); - - const available = - ext.getQueryObjectEXT(query, ext.QUERY_RESULT_AVAILABLE_EXT); - if (this.disjoint == null) { - this.disjoint = this.gl.getParameter(ext.GPU_DISJOINT_EXT); - } - - return available && !this.disjoint; - } - } - - pollFence(fenceContext: FenceContext) { - return new Promise(resolve => { - this.addItemToPoll(() => fenceContext.isFencePassed(), () => resolve()); - }); - } - - private itemsToPoll: PollItem[] = []; - - pollItems(): void { - // Find the last query that has finished. - const index = linearSearchLastTrue(this.itemsToPoll.map(x => x.isDoneFn)); - for (let i = 0; i <= index; ++i) { - const {resolveFn} = this.itemsToPoll[i]; - resolveFn(); - } - this.itemsToPoll = this.itemsToPoll.slice(index + 1); - } - - private addItemToPoll(isDoneFn: () => boolean, resolveFn: () => void) { - this.itemsToPoll.push({isDoneFn, resolveFn}); - if (this.itemsToPoll.length > 1) { - // We already have a running loop that polls. - return; - } - // Start a new loop that polls. - let scheduleFn = undefined; - if ('setTimeoutCustom' in env().platform) { - scheduleFn = env().platform.setTimeoutCustom.bind(env().platform); - } - util.repeatedTry(() => { - this.pollItems(); - // End the loop if no more items to poll. - return this.itemsToPoll.length === 0; - }, () => 0, null, scheduleFn); - } - - private bindTextureToFrameBuffer(texture: WebGLTexture) { - this.throwIfDisposed(); - webgl_util.bindColorTextureToFramebuffer( - this.gl, texture, this.framebuffer); - if (this.debug) { - webgl_util.validateFramebuffer(this.gl); - } - } - - private unbindTextureToFrameBuffer() { - if (this.outputTexture != null) { - webgl_util.bindColorTextureToFramebuffer( - this.gl, this.outputTexture, this.framebuffer); - if (this.debug) { - webgl_util.validateFramebuffer(this.gl); - } - } else { - webgl_util.unbindColorTextureFromFramebuffer(this.gl, this.framebuffer); - } - } - - private downloadMatrixDriver( - texture: WebGLTexture, - downloadAndDecode: () => Float32Array): Float32Array { - this.bindTextureToFrameBuffer(texture); - const result = downloadAndDecode(); - this.unbindTextureToFrameBuffer(); - - return result; - } - - private setOutputMatrixTextureDriver( - outputMatrixTextureMaybePacked: WebGLTexture, width: number, - height: number) { - this.throwIfDisposed(); - const gl = this.gl; - webgl_util.bindColorTextureToFramebuffer( - gl, outputMatrixTextureMaybePacked, this.framebuffer); - if (this.debug) { - webgl_util.validateFramebuffer(gl); - } - this.outputTexture = outputMatrixTextureMaybePacked; - webgl_util.callAndCheck(gl, () => gl.viewport(0, 0, width, height)); - webgl_util.callAndCheck(gl, () => gl.scissor(0, 0, width, height)); - } - - private setOutputMatrixWriteRegionDriver( - x: number, y: number, width: number, height: number) { - this.throwIfDisposed(); - webgl_util.callAndCheck( - this.gl, () => this.gl.scissor(x, y, width, height)); - } - - private throwIfDisposed() { - if (this.disposed) { - throw new Error('Attempted to use disposed GPGPUContext.'); - } - } - - private throwIfNoProgram() { - if (this.program == null) { - throw new Error('No GPU program is currently set.'); - } - } -} - -type PollItem = { - isDoneFn: () => boolean, - resolveFn: () => void -}; - -/** - * Finds the index of the last true element using linear search. - * Note: We can't do binary search because Chrome expects us to explicitly - * test all fences before download: - * https://github.com/tensorflow/tfjs/issues/1145 - */ -export function linearSearchLastTrue(arr: Array<() => boolean>): number { - let i = 0; - for (; i < arr.length; ++i) { - const isDone = arr[i](); - if (!isDone) { - break; - } - } - return i - 1; -} diff --git a/tfjs-master/tfjs-backend-webgl/src/gpgpu_context_test.ts b/tfjs-master/tfjs-backend-webgl/src/gpgpu_context_test.ts deleted file mode 100644 index 6eaad6a2d..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/gpgpu_context_test.ts +++ /dev/null @@ -1,282 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '@tensorflow/tfjs-core'; -// tslint:disable-next-line: no-imports-from-dist -import {describeWithFlags} from '@tensorflow/tfjs-core/dist/jasmine_util'; -// tslint:disable-next-line: no-imports-from-dist -import {expectArraysEqual} from '@tensorflow/tfjs-core/dist/test_util'; - -import {WEBGL_ENVS} from './backend_webgl_test_registry'; -import * as canvas_util from './canvas_util'; -import {getGlslDifferences} from './glsl_version'; -import {GPGPUContext, GPGPUContextProgram, linearSearchLastTrue} from './gpgpu_context'; -import * as tex_util from './tex_util'; -import {Texture} from './tex_util'; -import {createFragmentShader} from './webgl_util'; - -const DOWNLOAD_FLOAT_ENVS = { - flags: {'WEBGL_DOWNLOAD_FLOAT_ENABLED': true}, - predicate: WEBGL_ENVS.predicate -}; - -describeWithFlags( - 'GPGPUContext setOutputMatrixTexture', DOWNLOAD_FLOAT_ENVS, () => { - let gpgpu: GPGPUContext; - let texture: WebGLTexture; - let gl: WebGLRenderingContext; - - beforeEach(() => { - canvas_util.clearWebGLContext(tf.env().getNumber('WEBGL_VERSION')); - gl = canvas_util.getWebGLContext(tf.env().getNumber('WEBGL_VERSION')); - gpgpu = new GPGPUContext(gl); - // Silences debug warnings. - spyOn(console, 'warn'); - tf.enableDebugMode(); - }); - - afterEach(() => { - if (texture != null) { - gpgpu.deleteMatrixTexture(texture); - } - gpgpu.dispose(); - }); - - it('sets the output texture property to the output texture', () => { - texture = gpgpu.createFloat32MatrixTexture(1, 1).texture; - gpgpu.setOutputMatrixTexture(texture, 1, 1); - expect(gpgpu.outputTexture).toBe(texture); - }); - - it('sets the gl viewport to the output texture dimensions', () => { - const columns = 456; - const rows = 123; - texture = gpgpu.createFloat32MatrixTexture(rows, columns).texture; - gpgpu.setOutputMatrixTexture(texture, rows, columns); - const expected = new Int32Array([0, 0, columns, rows]); - expect(gpgpu.gl.getParameter(gpgpu.gl.VIEWPORT)).toEqual(expected); - }); - }); - -describeWithFlags( - 'GPGPUContext setOutputPackedMatrixTexture', DOWNLOAD_FLOAT_ENVS, () => { - let gpgpu: GPGPUContext; - let texture: Texture; - let gl: WebGLRenderingContext; - - beforeEach(() => { - canvas_util.clearWebGLContext(tf.env().getNumber('WEBGL_VERSION')); - gl = canvas_util.getWebGLContext(tf.env().getNumber('WEBGL_VERSION')); - gpgpu = new GPGPUContext(gl); - // Silences debug warnings. - spyOn(console, 'warn'); - tf.enableDebugMode(); - }); - - afterEach(() => { - if (texture != null) { - gpgpu.deleteMatrixTexture(texture.texture); - } - gpgpu.dispose(); - }); - - it('sets the output texture property to the output texture', () => { - texture = gpgpu.createPackedMatrixTexture(1, 1); - expectArraysEqual(texture.texShape, [1, 1]); - gpgpu.setOutputPackedMatrixTexture(texture.texture, 1, 1); - expect(gpgpu.outputTexture).toBe(texture.texture); - }); - - it('sets the gl viewport to the output packed texture dimensions', () => { - const columns = 456; - const rows = 123; - texture = gpgpu.createPackedMatrixTexture(rows, columns); - gpgpu.setOutputPackedMatrixTexture(texture.texture, rows, columns); - const [width, height] = - tex_util.getPackedMatrixTextureShapeWidthHeight(rows, columns); - const expected = new Int32Array([0, 0, width, height]); - expect(gpgpu.gl.getParameter(gpgpu.gl.VIEWPORT)).toEqual(expected); - expectArraysEqual(texture.texShape, [height, width]); - }); - }); - -describeWithFlags( - 'GPGPUContext setOutputMatrixWriteRegion', DOWNLOAD_FLOAT_ENVS, () => { - let gpgpu: GPGPUContext; - let program: GPGPUContextProgram; - let output: WebGLTexture; - - beforeEach(() => { - gpgpu = new GPGPUContext(); - // Silences debug warnings. - spyOn(console, 'warn'); - tf.enableDebugMode(); - const glsl = getGlslDifferences(); - const src = `${glsl.version} - precision highp float; - ${glsl.defineOutput} - void main() { - ${glsl.output} = vec4(2,0,0,0); - } - `; - // tslint:disable-next-line: max-line-length - const fragmentShader = createFragmentShader(gpgpu.gl, src); - program = gpgpu.createProgram(fragmentShader); - output = gpgpu.createPackedMatrixTexture(4, 4).texture; - gpgpu.uploadDenseMatrixToTexture(output, 2, 2, new Float32Array(16)); - gpgpu.setOutputMatrixTexture(output, 4, 4); - gpgpu.setProgram(program); - }); - - afterEach(() => { - gpgpu.deleteMatrixTexture(output); - gpgpu.deleteProgram(program); - gpgpu.dispose(); - }); - - it('sets the scissor box to the requested parameters', () => { - gpgpu.setOutputMatrixWriteRegion(0, 1, 2, 3); - const scissorBox = gpgpu.gl.getParameter(gpgpu.gl.SCISSOR_BOX); - expect(scissorBox[0]).toEqual(2); - expect(scissorBox[1]).toEqual(0); - expect(scissorBox[2]).toEqual(3); - expect(scissorBox[3]).toEqual(1); - }); - }); - -describeWithFlags('GPGPUContext', DOWNLOAD_FLOAT_ENVS, () => { - let gpgpu: GPGPUContext; - - beforeEach(() => { - gpgpu = new GPGPUContext(); - // Silences debug warnings. - spyOn(console, 'warn'); - tf.enableDebugMode(); - }); - - afterEach(() => { - gpgpu.dispose(); - }); - - it('throws an error if used after dispose', () => { - const gpgpuContext = new GPGPUContext(); - gpgpuContext.dispose(); - expect(gpgpuContext.dispose).toThrowError(); - }); - - it('throws an error if validation is on and framebuffer incomplete', () => { - const glsl = getGlslDifferences(); - const src = `${glsl.version} - precision highp float; - void main() {} - `; - const fragmentShader = createFragmentShader(gpgpu.gl, src); - const program = gpgpu.createProgram(fragmentShader); - const result = gpgpu.createFloat32MatrixTexture(1, 1).texture; - gpgpu.setOutputMatrixTexture(result, 1, 1); - gpgpu.setProgram(program); - gpgpu.deleteMatrixTexture(result); - expect(gpgpu.executeProgram).toThrowError(); - gpgpu.deleteProgram(program); - }); -}); - -describe('gpgpu_context linearSearchLastTrue', () => { - it('[false]', () => { - const a: boolean[] = [false]; - const arr = a.map(x => () => x); - expect(linearSearchLastTrue(arr)).toBe(-1); - }); - - it('[true]', () => { - const a: boolean[] = [true]; - const arr = a.map(x => () => x); - expect(linearSearchLastTrue(arr)).toBe(0); - }); - - it('[false, false]', () => { - const a: boolean[] = [false, false]; - const arr = a.map(x => () => x); - expect(linearSearchLastTrue(arr)).toBe(-1); - }); - - it('[true, false]', () => { - const a: boolean[] = [true, false]; - const arr = a.map(x => () => x); - expect(linearSearchLastTrue(arr)).toBe(0); - }); - - it('[true, true]', () => { - const a: boolean[] = [true, true]; - const arr = a.map(x => () => x); - expect(linearSearchLastTrue(arr)).toBe(1); - }); - - it('[false, false, false]', () => { - const a: boolean[] = [false, false, false]; - const arr = a.map(x => () => x); - expect(linearSearchLastTrue(arr)).toBe(-1); - }); - - it('[true, false, false]', () => { - const a: boolean[] = [true, false, false]; - const arr = a.map(x => () => x); - expect(linearSearchLastTrue(arr)).toBe(0); - }); - - it('[true, true, false]', () => { - const a: boolean[] = [true, true, false]; - const arr = a.map(x => () => x); - expect(linearSearchLastTrue(arr)).toBe(1); - }); - - it('[true, true, true]', () => { - const a: boolean[] = [true, true, true]; - const arr = a.map(x => () => x); - expect(linearSearchLastTrue(arr)).toBe(2); - }); - - it('[false, false, false, false]', () => { - const a: boolean[] = [false, false, false, false]; - const arr = a.map(x => () => x); - expect(linearSearchLastTrue(arr)).toBe(-1); - }); - - it('[true, false, false, false]', () => { - const a: boolean[] = [true, false, false, false]; - const arr = a.map(x => () => x); - expect(linearSearchLastTrue(arr)).toBe(0); - }); - - it('[true, true, false, false]', () => { - const a: boolean[] = [true, true, false, false]; - const arr = a.map(x => () => x); - expect(linearSearchLastTrue(arr)).toBe(1); - }); - - it('[true, true, true, false]', () => { - const a: boolean[] = [true, true, true, false]; - const arr = a.map(x => () => x); - expect(linearSearchLastTrue(arr)).toBe(2); - }); - - it('[true, true, true, true]', () => { - const a: boolean[] = [true, true, true, true]; - const arr = a.map(x => () => x); - expect(linearSearchLastTrue(arr)).toBe(3); - }); -}); diff --git a/tfjs-master/tfjs-backend-webgl/src/gpgpu_math.ts b/tfjs-master/tfjs-backend-webgl/src/gpgpu_math.ts deleted file mode 100644 index bcf52ff96..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/gpgpu_math.ts +++ /dev/null @@ -1,480 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, env, Tensor, TypedArray, util} from '@tensorflow/tfjs-core'; - -import {GPGPUContext, GPGPUContextProgram} from './gpgpu_context'; -import * as shader_compiler from './shader_compiler'; -import {InputInfo, ShapeInfo, UniformType} from './shader_compiler'; -import {PackingScheme, TextureData, TextureUsage} from './tex_util'; -import {createFragmentShader} from './webgl_util'; - -export interface GPGPUProgram { - variableNames: string[]; - outputShape: number[]; - userCode: string; - enableShapeUniforms?: boolean; - /** If true, this program expects packed input textures. Defaults to false. */ - packedInputs?: boolean; - /** If true, this program produces a packed texture. Defaults to false. */ - packedOutput?: boolean; - /** - * Affects what type of texture we allocate for the output. Defaults to - * `TextureUsage.RENDER`. - */ - outTexUsage?: TextureUsage; - /** - * The type of scheme to use when packing texels for the output values. - * See `PackingScheme` for details. Defaults to `PackingScheme.SHARED_BATCH`. - */ - outPackingScheme?: PackingScheme; - customUniforms?: - Array<{name: string; arrayIndex?: number; type: UniformType;}>; -} - -export interface GPGPUBinary extends GPGPUBinaryLocations { - webGLProgram: GPGPUContextProgram; - program: GPGPUProgram; - source: string; - fragmentShader: WebGLShader; - inShapeInfos: ShapeInfo[]; - outShapeInfo: ShapeInfo; -} - -export interface GPGPUBinaryLocations { - customUniformLocations?: WebGLUniformLocation[]; - infLoc: WebGLUniformLocation; - nanLoc: WebGLUniformLocation; - outShapeLocation?: WebGLUniformLocation; - outShapeStridesLocation?: WebGLUniformLocation; - outTexShapeLocation?: WebGLUniformLocation; - variablesLocations?: GPGPUVariableLocations[]; -} - -export interface GPGPUVariableLocations { - name: string; - uniform: WebGLUniformLocation; - offset: WebGLUniformLocation; - shape?: WebGLUniformLocation; - texShape?: WebGLUniformLocation; -} - -export interface TensorData { - shape: number[]; - texData: TextureData; - isUniform: boolean; - // Available when we decide to upload as uniform instead of texture. - uniformValues?: TypedArray; -} - -export function compileProgram( - gpgpu: GPGPUContext, program: GPGPUProgram, inputs: TensorData[], - output: TensorData): GPGPUBinary { - const inputInfos: InputInfo[] = inputs.map((input, i) => { - const shapeInfo: ShapeInfo = { - logicalShape: input.shape, - texShape: input.isUniform ? null : input.texData.texShape, - isUniform: input.isUniform, - isPacked: input.isUniform ? false : input.texData.isPacked, - flatOffset: null - }; - if (input.texData != null && input.texData.slice != null && - input.texData.slice.flatOffset > 0) { - shapeInfo.flatOffset = input.texData.slice.flatOffset; - } - return {name: program.variableNames[i], shapeInfo}; - }); - const inShapeInfos = inputInfos.map(x => x.shapeInfo); - const outShapeInfo: ShapeInfo = { - logicalShape: output.shape, - texShape: output.texData.texShape, - isUniform: false, - isPacked: output.texData.isPacked, - flatOffset: null - }; - const source = shader_compiler.makeShader(inputInfos, outShapeInfo, program); - const fragmentShader = createFragmentShader(gpgpu.gl, source); - const webGLProgram = gpgpu.createProgram(fragmentShader); - - if (!env().get('ENGINE_COMPILE_ONLY')) { - gpgpu.buildVao(webGLProgram); - return { - program, - fragmentShader, - source, - webGLProgram, - inShapeInfos, - outShapeInfo, - ...getUniformLocations(gpgpu, program, webGLProgram) - }; - } else { - return { - program, - fragmentShader, - source, - webGLProgram, - inShapeInfos, - outShapeInfo, - variablesLocations: null, - customUniformLocations: null, - infLoc: null, - nanLoc: null, - outShapeLocation: null, - outShapeStridesLocation: null, - outTexShapeLocation: null - }; - } -} - -export function getUniformLocations( - gpgpu: GPGPUContext, program: GPGPUProgram, - webGLProgram: WebGLProgram): GPGPUBinaryLocations { - const variablesLocations: GPGPUVariableLocations[] = []; - const customUniformLocations: WebGLUniformLocation[] = []; - let outShapeLocation: WebGLUniformLocation; - let outTexShapeLocation: WebGLUniformLocation; - let outShapeStridesLocation: WebGLUniformLocation; - let infLoc: WebGLUniformLocation = null; - let nanLoc: WebGLUniformLocation = null; - - // Add special uniforms (NAN, INFINITY) - nanLoc = gpgpu.getUniformLocation(webGLProgram, 'NAN', false); - if (env().getNumber('WEBGL_VERSION') === 1) { - infLoc = gpgpu.getUniformLocation(webGLProgram, 'INFINITY', false); - } - - // Add user-defined uniforms - const shouldThrow = false; - for (const varName of program.variableNames) { - const varLocs: GPGPUVariableLocations = { - name: varName, - uniform: gpgpu.getUniformLocation(webGLProgram, varName, shouldThrow), - offset: gpgpu.getUniformLocation( - webGLProgram, `offset${varName}`, shouldThrow), - }; - if (program.enableShapeUniforms) { - varLocs.shape = gpgpu.getUniformLocation( - webGLProgram, `${varName}Shape`, shouldThrow); - varLocs.texShape = gpgpu.getUniformLocation( - webGLProgram, `${varName}TexShape`, shouldThrow); - } - - variablesLocations.push(varLocs); - } - - if (program.enableShapeUniforms) { - outShapeLocation = - gpgpu.getUniformLocation(webGLProgram, 'outShape', shouldThrow); - outShapeStridesLocation = - gpgpu.getUniformLocation(webGLProgram, 'outShapeStrides', shouldThrow); - outTexShapeLocation = - gpgpu.getUniformLocation(webGLProgram, 'outTexShape', shouldThrow); - } - - if (program.customUniforms) { - for (const d of program.customUniforms) { - customUniformLocations.push( - gpgpu.getUniformLocation(webGLProgram, d.name, shouldThrow)); - } - } - - return { - variablesLocations, - customUniformLocations, - infLoc, - nanLoc, - outShapeLocation, - outShapeStridesLocation, - outTexShapeLocation - }; -} - -function validateBinaryAndProgram( - shapeInfos: ShapeInfo[], inputs: TensorData[]) { - if (shapeInfos.length !== inputs.length) { - throw Error( - `Binary was compiled with ${shapeInfos.length} inputs, but ` + - `was executed with ${inputs.length} inputs`); - } - - shapeInfos.forEach((s, i) => { - const shapeA = s.logicalShape; - const input = inputs[i]; - const shapeB = input.shape; - - if (!util.arraysEqual(shapeA, shapeB)) { - throw Error( - `Binary was compiled with different shapes than ` + - `the current args. Shapes ${shapeA} and ${shapeB} must match`); - } - // The input is uploaded as uniform. - if (s.isUniform && input.isUniform) { - return; - } - - const texShapeA = s.texShape; - const texShapeB = input.isUniform ? null : input.texData.texShape; - if (!util.arraysEqual(texShapeA, texShapeB)) { - throw Error( - `Binary was compiled with different texture shapes than the` + - ` current args. Shape ${texShapeA} and ${texShapeB} must match`); - } - }); -} - -export function runProgram( - gpgpu: GPGPUContext, binary: GPGPUBinary, inputs: TensorData[], - output: TensorData, customUniformValues?: number[][]): void { - if (!binary.program.enableShapeUniforms) { - validateBinaryAndProgram(binary.inShapeInfos, inputs); - validateBinaryAndProgram([binary.outShapeInfo], [output]); - } - - const outTex = output.texData.texture; - const outTexShape = output.texData.texShape; - if (output.texData.isPacked) { - gpgpu.setOutputPackedMatrixTexture( - outTex.texture, outTexShape[0], outTexShape[1]); - } else { - gpgpu.setOutputMatrixTexture( - outTex.texture, outTexShape[0], outTexShape[1]); - } - gpgpu.setProgram(binary.webGLProgram); - gpgpu.bindVertexArray(binary.webGLProgram.vao); - - // Set special uniforms (NAN, INFINITY) - if (env().getNumber('WEBGL_VERSION') === 1) { - if (binary.infLoc !== null) { - gpgpu.gl.uniform1f(binary.infLoc, Infinity); - } - } - if (binary.nanLoc !== null) { - gpgpu.gl.uniform1f(binary.nanLoc, NaN); - } - - // Set user-defined inputs - for (let i = 0; i < inputs.length; ++i) { - const input = inputs[i]; - const { - uniform: varLoc, - offset: varOffsetLoc, - shape: varShapeLoc, - texShape: varTexShapeLoc, - } = binary.variablesLocations[i]; - - if (varShapeLoc) { - const {uniformShape} = shader_compiler.getUniformInfoFromShape( - binary.program.packedInputs, input.shape, input.texData.texShape); - switch (uniformShape.length) { - case 1: - gpgpu.gl.uniform1iv(varShapeLoc, new Int32Array(uniformShape)); - break; - case 2: - gpgpu.gl.uniform2iv(varShapeLoc, new Int32Array(uniformShape)); - break; - case 3: - gpgpu.gl.uniform3iv(varShapeLoc, new Int32Array(uniformShape)); - break; - case 4: - gpgpu.gl.uniform4iv(varShapeLoc, new Int32Array(uniformShape)); - break; - default: - break; - } - } - - if (varTexShapeLoc) { - gpgpu.gl.uniform2i( - varTexShapeLoc, input.texData.texShape[0], input.texData.texShape[1]); - } - - if (varLoc == null) { - // The compiler inferred that this variable is not used in this shader. - continue; - } - - if (input.isUniform) { - // Upload the values of the tensor as uniform. - if (util.sizeFromShape(input.shape) < 2) { - gpgpu.gl.uniform1f(varLoc, input.uniformValues[0]); - } else { - let vals = input.uniformValues; - if (!(vals instanceof Float32Array)) { - vals = new Float32Array(vals); - } - gpgpu.gl.uniform1fv(varLoc, vals); - } - continue; - } - - // If the input was sliced, upload the flat offset index. - if (input.texData.slice != null && varOffsetLoc != null) { - gpgpu.gl.uniform1i(varOffsetLoc, input.texData.slice.flatOffset); - } - - gpgpu.setInputMatrixTexture(input.texData.texture.texture, varLoc, i); - } - - const outShapeLoc = binary.outShapeLocation; - if (outShapeLoc) { - switch (output.shape.length) { - case 1: - gpgpu.gl.uniform1iv(outShapeLoc, new Int32Array(output.shape)); - break; - case 2: - gpgpu.gl.uniform2iv(outShapeLoc, new Int32Array(output.shape)); - break; - case 3: - gpgpu.gl.uniform3iv(outShapeLoc, new Int32Array(output.shape)); - break; - case 4: - gpgpu.gl.uniform4iv(outShapeLoc, new Int32Array(output.shape)); - break; - default: - break; - } - } - if (binary.outShapeStridesLocation) { - const strides = util.computeStrides(output.shape); - switch (output.shape.length) { - case 2: - gpgpu.gl.uniform1iv( - binary.outShapeStridesLocation, new Int32Array(strides)); - break; - case 3: - gpgpu.gl.uniform2iv( - binary.outShapeStridesLocation, new Int32Array(strides)); - break; - case 4: - gpgpu.gl.uniform3iv( - binary.outShapeStridesLocation, new Int32Array(strides)); - break; - default: - break; - } - } - if (binary.outTexShapeLocation) { - gpgpu.gl.uniform2i( - binary.outTexShapeLocation, output.texData.texShape[0], - output.texData.texShape[1]); - } - - if (binary.program.customUniforms && customUniformValues) { - for (let i = 0; i < binary.program.customUniforms.length; ++i) { - const d = binary.program.customUniforms[i]; - const customLoc = binary.customUniformLocations[i]; - const customValue = customUniformValues[i]; - if (d.type === 'float') { - gpgpu.gl.uniform1fv(customLoc, customValue); - } else if (d.type === 'vec2') { - gpgpu.gl.uniform2fv(customLoc, customValue); - } else if (d.type === 'vec3') { - gpgpu.gl.uniform3fv(customLoc, customValue); - } else if (d.type === 'vec4') { - gpgpu.gl.uniform4fv(customLoc, customValue); - } else if (d.type === 'int') { - gpgpu.gl.uniform1iv(customLoc, customValue); - } else if (d.type === 'ivec2') { - gpgpu.gl.uniform2iv(customLoc, customValue); - } else if (d.type === 'ivec3') { - gpgpu.gl.uniform3iv(customLoc, customValue); - } else if (d.type === 'ivec4') { - gpgpu.gl.uniform4iv(customLoc, customValue); - } else { - throw Error(`uniform type ${d.type} is not supported yet.`); - } - } - } - gpgpu.executeProgram(); -} - -export function makeShaderKey( - program: GPGPUProgram, inputs: TensorData[], output: TensorData): string { - let keyInputs = ''; - inputs.concat(output).forEach(x => { - const hasOffset = x.texData != null && x.texData.slice != null && - x.texData.slice.flatOffset > 0; - // TODO: Remove the condition of !x.isUniform. - if (program.enableShapeUniforms && !x.isUniform) { - const xTexShape = x.texData.texShape; - const {useSqueezeShape, uniformShape, keptDims} = - shader_compiler.getUniformInfoFromShape( - program.packedInputs, x.shape, xTexShape); - let rank1 = '', rank2 = '', rank34 = ''; - if (uniformShape.length === 1 && program.packedInputs) { - const packedTexShape = - [Math.ceil(xTexShape[0] / 2), Math.ceil(xTexShape[1] / 2)]; - rank1 = `${packedTexShape[0] > 1}_${packedTexShape[1] > 1}`; - } else if (uniformShape.length === 2 && !program.packedInputs) { - rank2 = `${uniformShape[0] > 1}_${uniformShape[1] > 1}`; - } else if (uniformShape.length > 2 && !program.packedInputs) { - const strides = util.computeStrides(uniformShape); - rank34 = `${strides[0] === xTexShape[1]}_${ - strides[strides.length - 1] === xTexShape[1]}`; - } - const xRank = x.shape.length; - const isLogicalShapTexShapeEqual = - uniformShape.length === 2 && util.arraysEqual(x.shape, xTexShape); - const isScalar = util.sizeFromShape(x.shape) === 1; - const broadcastDims = - backend_util.getBroadcastDims(x.shape, output.shape); - const isInOutTexShapeEqual = !program.packedInputs && - xRank === output.shape.length && - util.arraysEqual(xTexShape, output.texData.texShape); - const isTexShapeGreaterThanOne = - program.packedInputs || uniformShape.length > 2 ? - '' : - `${xTexShape[0] > 1}_${xTexShape[1] > 1}`; - // These key components are needed due to shader_compiler is embedding - // them in the shader. - // |xRank| is used to determine the coords length. See - // get[Packed]SamplerAtOutputCoords. - // |isInOutTexShapeEqual| is used to determine whether going to an - // optimization path in getSamplerAtOutputCoords. - // |useSqueezeShape| is extracted from squeezeInputInfo of - // getSampler[2|3|4]D/getPackedSampler3D. - // |isScalar| is extracted from isInputScalar/isOutputScalar in - // getPackedSamplerAtOutputCoords. - // |broadcastDims| is extracted from get[Packed]SamplerAtOutputCoords. - // |isLogicalShapTexShapeEqual| is used in - // getOutput[Packed]2DCoords/get[Packed]Sampler2D. - // |rank1| is used in getOutputPacked1DCoords. - // |rank2| is used in getOutput2DCoords. - // |rank34| is used in getSampler3D/getSampler4D. - // |isTexShapeGreaterThanOne| are used in - // getSampler[Scalar|1D|2D]/getOutput1DCoords. - keyInputs += `${xRank}_${isInOutTexShapeEqual}_${ - useSqueezeShape ? keptDims : ''}_${uniformShape.length}_${isScalar}_${ - broadcastDims}_${isLogicalShapTexShapeEqual}_${rank1}_${rank2}_${ - rank34}_${isTexShapeGreaterThanOne}_${hasOffset}`; - } else { - const texShape = x.isUniform ? 'uniform' : x.texData.texShape; - keyInputs += `${x.shape}_${texShape}_${hasOffset}`; - } - }); - const keyUserCode = program.userCode; - let key = program.constructor.name; - // Fast string concat. See https://jsperf.com/string-concatenation/14. - key += '_' + keyInputs + '_' + keyUserCode + - `${env().getNumber('WEBGL_VERSION')}`; - return key; -} - -export function useShapeUniforms(rank: number) { - // TODO: Remove the limitaion of rank <= 4. - return env().getBool('WEBGL_USE_SHAPES_UNIFORMS') && rank <= 4; -} diff --git a/tfjs-master/tfjs-backend-webgl/src/gpgpu_util.ts b/tfjs-master/tfjs-backend-webgl/src/gpgpu_util.ts deleted file mode 100644 index 3343ac9b6..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/gpgpu_util.ts +++ /dev/null @@ -1,346 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {env, PixelData, TypedArray} from '@tensorflow/tfjs-core'; - -import {getGlslDifferences} from './glsl_version'; -import * as tex_util from './tex_util'; -import {Texture, TextureConfig} from './tex_util'; -import * as webgl_util from './webgl_util'; - -export function createVertexShader(gl: WebGLRenderingContext): WebGLShader { - const glsl = getGlslDifferences(); - const vertexShaderSource = `${glsl.version} - precision highp float; - ${glsl.attribute} vec3 clipSpacePos; - ${glsl.attribute} vec2 uv; - ${glsl.varyingVs} vec2 resultUV; - - void main() { - gl_Position = vec4(clipSpacePos, 1); - resultUV = uv; - }`; - return webgl_util.createVertexShader(gl, vertexShaderSource); -} - -export function createVertexBuffer(gl: WebGLRenderingContext): WebGLBuffer { - // [x y z u v] * [upper-left, lower-left, upper-right, lower-right] - const vertexArray = new Float32Array( - [-1, 1, 0, 0, 1, -1, -1, 0, 0, 0, 1, 1, 0, 1, 1, 1, -1, 0, 1, 0]); - return webgl_util.createStaticVertexBuffer(gl, vertexArray); -} - -export function createIndexBuffer(gl: WebGLRenderingContext): WebGLBuffer { - // OpenGL (and WebGL) have "CCW == front" winding - const triangleVertexIndices = new Uint16Array([0, 1, 2, 2, 1, 3]); - return webgl_util.createStaticIndexBuffer(gl, triangleVertexIndices); -} - -function createAndConfigureTexture( - gl: WebGLRenderingContext, width: number, height: number, - internalFormat: number, textureFormat: number, - textureType: number): Texture { - webgl_util.validateTextureSize(width, height); - const texture = webgl_util.createTexture(gl); - - const tex2d = gl.TEXTURE_2D; - webgl_util.callAndCheck(gl, () => gl.bindTexture(tex2d, texture)); - webgl_util.callAndCheck( - gl, () => gl.texParameteri(tex2d, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE)); - webgl_util.callAndCheck( - gl, () => gl.texParameteri(tex2d, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE)); - webgl_util.callAndCheck( - gl, () => gl.texParameteri(tex2d, gl.TEXTURE_MIN_FILTER, gl.NEAREST)); - webgl_util.callAndCheck( - gl, () => gl.texParameteri(tex2d, gl.TEXTURE_MAG_FILTER, gl.NEAREST)); - if (env().getNumber('WEBGL_VERSION') === 1) { - webgl_util.callAndCheck( - gl, - () => gl.texImage2D( - tex2d, 0, internalFormat, width, height, 0, textureFormat, - textureType, null)); - } else { - webgl_util.callAndCheck( - gl, - () => (gl as WebGL2RenderingContext) - .texStorage2D(tex2d, 1, internalFormat, width, height)); - } - webgl_util.callAndCheck(gl, () => gl.bindTexture(gl.TEXTURE_2D, null)); - - return {texture, texShape: [height, width]}; -} - -export function getInternalFormatForFloat32MatrixTexture( - textureConfig: TextureConfig) { - return textureConfig.internalFormatFloat; -} - -export function createFloat32MatrixTexture( - gl: WebGLRenderingContext, rows: number, columns: number, - textureConfig: TextureConfig): Texture { - const [width, height] = - tex_util.getUnpackedMatrixTextureShapeWidthHeight(rows, columns); - return createAndConfigureTexture( - gl, width, height, - getInternalFormatForFloat32MatrixTexture(textureConfig), - textureConfig.textureFormatFloat, gl.FLOAT); -} - -export function getInternalFormatForFloat16MatrixTexture( - textureConfig: TextureConfig) { - return textureConfig.internalFormatHalfFloat; -} - -export function createFloat16MatrixTexture( - gl: WebGLRenderingContext, rows: number, columns: number, - textureConfig: TextureConfig): Texture { - const [width, height] = - tex_util.getUnpackedMatrixTextureShapeWidthHeight(rows, columns); - return createAndConfigureTexture( - gl, width, height, - getInternalFormatForFloat16MatrixTexture(textureConfig), - textureConfig.textureFormatFloat, textureConfig.textureTypeHalfFloat); -} - -export function getInternalFormatForUnsignedBytesMatrixTexture( - textureConfig: TextureConfig) { - return textureConfig.downloadTextureFormat; -} - -export function createUnsignedBytesMatrixTexture( - gl: WebGLRenderingContext, rows: number, columns: number, - textureConfig: TextureConfig): Texture { - const [width, height] = - tex_util.getUnpackedMatrixTextureShapeWidthHeight(rows, columns); - return createAndConfigureTexture( - gl, width, height, - getInternalFormatForUnsignedBytesMatrixTexture(textureConfig), gl.RGBA, - gl.UNSIGNED_BYTE); -} - -export function getInternalFormatForPackedMatrixTexture( - textureConfig: TextureConfig) { - return textureConfig.internalFormatPackedFloat; -} - -export function createPackedMatrixTexture( - gl: WebGLRenderingContext, rows: number, columns: number, - textureConfig: TextureConfig): Texture { - const [width, height] = - tex_util.getPackedMatrixTextureShapeWidthHeight(rows, columns); - return createAndConfigureTexture( - gl, width, height, getInternalFormatForPackedMatrixTexture(textureConfig), - gl.RGBA, gl.FLOAT); -} - -export function getInternalFormatForFloat16PackedMatrixTexture( - textureConfig: TextureConfig) { - return textureConfig.internalFormatPackedHalfFloat; -} - -export function createFloat16PackedMatrixTexture( - gl: WebGLRenderingContext, rows: number, columns: number, - textureConfig: TextureConfig): Texture { - const [width, height] = - tex_util.getPackedMatrixTextureShapeWidthHeight(rows, columns); - return createAndConfigureTexture( - gl, width, height, - getInternalFormatForFloat16PackedMatrixTexture(textureConfig), gl.RGBA, - textureConfig.textureTypeHalfFloat); -} - -export function bindVertexProgramAttributeStreams( - gl: WebGLRenderingContext, program: WebGLProgram, - vertexBuffer: WebGLBuffer): boolean { - const posOffset = 0; // x is the first buffer element - const uvOffset = 3 * 4; // uv comes after [x y z] - const stride = (3 * 4) + (2 * 4); // xyz + uv, each entry is 4-byte float. - webgl_util.callAndCheck( - gl, () => gl.bindBuffer(gl.ARRAY_BUFFER, vertexBuffer)); - const success = webgl_util.bindVertexBufferToProgramAttribute( - gl, program, 'clipSpacePos', vertexBuffer, 3, stride, posOffset); - return success && - webgl_util.bindVertexBufferToProgramAttribute( - gl, program, 'uv', vertexBuffer, 2, stride, uvOffset); -} - -export function uploadDenseMatrixToTexture( - gl: WebGLRenderingContext, texture: WebGLTexture, width: number, - height: number, data: TypedArray, textureConfig: TextureConfig) { - webgl_util.callAndCheck(gl, () => gl.bindTexture(gl.TEXTURE_2D, texture)); - - let dataForUpload: TypedArray, texelDataType: number, internalFormat: number; - if (data instanceof Uint8Array) { - dataForUpload = new Uint8Array(width * height * 4); - texelDataType = gl.UNSIGNED_BYTE; - internalFormat = gl.RGBA; - } else { - dataForUpload = new Float32Array(width * height * 4); - texelDataType = gl.FLOAT; - internalFormat = textureConfig.internalFormatPackedFloat; - } - - dataForUpload.set(data); - if (env().getNumber('WEBGL_VERSION') === 2) { - webgl_util.callAndCheck( - gl, - () => gl.texSubImage2D( - gl.TEXTURE_2D, 0, 0, 0, width, height, gl.RGBA, texelDataType, - dataForUpload)); - } else { - webgl_util.callAndCheck( - gl, - () => gl.texImage2D( - gl.TEXTURE_2D, 0, internalFormat, width, height, 0, gl.RGBA, - texelDataType, dataForUpload)); - } - - webgl_util.callAndCheck(gl, () => gl.bindTexture(gl.TEXTURE_2D, null)); -} - -export function uploadPixelDataToTexture( - gl: WebGLRenderingContext, texture: WebGLTexture, - pixels: PixelData|ImageData|HTMLImageElement|HTMLCanvasElement| - HTMLVideoElement|ImageBitmap) { - webgl_util.callAndCheck(gl, () => gl.bindTexture(gl.TEXTURE_2D, texture)); - if ((pixels as PixelData).data instanceof Uint8Array) { - if (env().getNumber('WEBGL_VERSION') === 2) { - webgl_util.callAndCheck( - gl, - () => gl.texSubImage2D( - gl.TEXTURE_2D, 0, 0, 0, pixels.width, pixels.height, gl.RGBA, - gl.UNSIGNED_BYTE, (pixels as PixelData).data)); - } else { - webgl_util.callAndCheck( - gl, - () => gl.texImage2D( - gl.TEXTURE_2D, 0, gl.RGBA, pixels.width, pixels.height, 0, - gl.RGBA, gl.UNSIGNED_BYTE, (pixels as PixelData).data)); - } - } else { - if (env().getNumber('WEBGL_VERSION') === 2) { - webgl_util.callAndCheck( - gl, - () => gl.texSubImage2D( - gl.TEXTURE_2D, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, - (pixels as ImageData | HTMLImageElement | HTMLCanvasElement | - HTMLVideoElement | ImageBitmap))); - } else { - webgl_util.callAndCheck( - gl, - () => gl.texImage2D( - gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, - pixels as ImageData | HTMLImageElement | HTMLCanvasElement | - HTMLVideoElement | ImageBitmap)); - } - } - - webgl_util.callAndCheck(gl, () => gl.bindTexture(gl.TEXTURE_2D, null)); -} - -export function createBufferFromOutputTexture( - gl2: WebGL2RenderingContext, rows: number, columns: number, - textureConfig: TextureConfig): WebGLBuffer { - // Create and bind the buffer. - const buffer = gl2.createBuffer(); - webgl_util.callAndCheck( - gl2, () => gl2.bindBuffer(gl2.PIXEL_PACK_BUFFER, buffer)); - - // Initialize the buffer to the size of the texture in bytes. - const bytesPerFloat = 4; - const valuesPerTexel = 4; - const bufferSizeBytes = bytesPerFloat * valuesPerTexel * rows * columns; - - webgl_util.callAndCheck( - gl2, - () => gl2.bufferData( - gl2.PIXEL_PACK_BUFFER, bufferSizeBytes, gl2.STREAM_READ)); - - // Enqueue a command on the GPU command queue to copy of texture into the - // buffer. - webgl_util.callAndCheck( - gl2, () => gl2.readPixels(0, 0, columns, rows, gl2.RGBA, gl2.FLOAT, 0)); - - webgl_util.callAndCheck( - gl2, () => gl2.bindBuffer(gl2.PIXEL_PACK_BUFFER, null)); - - return buffer; -} - -export function downloadFloat32MatrixFromBuffer( - gl: WebGLRenderingContext, buffer: WebGLBuffer, - size: number): Float32Array { - const gl2 = gl as WebGL2RenderingContext; - - const downloadTarget = new Float32Array(size); - - gl2.bindBuffer(gl2.PIXEL_PACK_BUFFER, buffer); - gl2.getBufferSubData(gl2.PIXEL_PACK_BUFFER, 0, downloadTarget); - gl2.bindBuffer(gl2.PIXEL_PACK_BUFFER, null); - - return downloadTarget; -} - -export function downloadByteEncodedFloatMatrixFromOutputTexture( - gl: WebGLRenderingContext, rows: number, columns: number, - textureConfig: TextureConfig) { - const [w, h] = - tex_util.getUnpackedMatrixTextureShapeWidthHeight(rows, columns); - - const numChannels = 4; - const downloadTarget = new Uint8Array( - tex_util.getUnpackedArraySizeFromMatrixSize(rows * columns, numChannels)); - - webgl_util.callAndCheck( - gl, - () => gl.readPixels( - 0, 0, w, h, textureConfig.downloadTextureFormat, gl.UNSIGNED_BYTE, - downloadTarget)); - - // By wrapping the buffer in a Float32Array, we use native browser IEEE 754 - // decoding of the 4 bytes that back each 32 bit float. - return new Float32Array(downloadTarget.buffer); -} - -export function downloadPackedMatrixFromBuffer( - gl: WebGLRenderingContext, buffer: WebGLBuffer, batch: number, rows: number, - cols: number, physicalRows: number, physicalCols: number, - textureConfig: TextureConfig): Float32Array { - const gl2 = gl as WebGL2RenderingContext; - - const downloadTarget = - new Float32Array(tex_util.getPackedRGBAArraySizeFromMatrixShape( - physicalRows, physicalCols)); - - gl2.bindBuffer(gl2.PIXEL_PACK_BUFFER, buffer); - gl2.getBufferSubData(gl2.PIXEL_PACK_BUFFER, 0, downloadTarget); - gl2.bindBuffer(gl2.PIXEL_PACK_BUFFER, null); - - return downloadTarget; -} - -export function downloadMatrixFromPackedOutputTexture( - gl: WebGLRenderingContext, physicalRows: number, - physicalCols: number): Float32Array { - const packedRGBA = new Float32Array(physicalRows * physicalCols * 4); - webgl_util.callAndCheck( - gl, - () => gl.readPixels( - 0, 0, physicalCols, physicalRows, gl.RGBA, gl.FLOAT, packedRGBA)); - - return packedRGBA; -} diff --git a/tfjs-master/tfjs-backend-webgl/src/gpgpu_util_test.ts b/tfjs-master/tfjs-backend-webgl/src/gpgpu_util_test.ts deleted file mode 100644 index e71d462d1..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/gpgpu_util_test.ts +++ /dev/null @@ -1,133 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// tslint:disable-next-line: no-imports-from-dist -import {describeWithFlags} from '@tensorflow/tfjs-core/dist/jasmine_util'; -import {WEBGL_ENVS} from './backend_webgl_test_registry'; -import {GPGPUContext} from './gpgpu_context'; -import * as gpgpu_util from './gpgpu_util'; -import * as tex_util from './tex_util'; - -describeWithFlags('gpgpu_util createWebGLContext', WEBGL_ENVS, () => { - let gpgpu: GPGPUContext; - - beforeEach(() => { - gpgpu = new GPGPUContext(); - }); - - afterEach(() => { - gpgpu.dispose(); - }); - - it('disables DEPTH_TEST and STENCIL_TEST', () => { - expect(gpgpu.gl.getParameter(gpgpu.gl.DEPTH_TEST)).toEqual(false); - expect(gpgpu.gl.getParameter(gpgpu.gl.STENCIL_TEST)).toEqual(false); - }); - - it('disables BLEND', () => { - expect(gpgpu.gl.getParameter(gpgpu.gl.BLEND)).toEqual(false); - }); - - it('disables DITHER, POLYGON_OFFSET_FILL', () => { - expect(gpgpu.gl.getParameter(gpgpu.gl.DITHER)).toEqual(false); - expect(gpgpu.gl.getParameter(gpgpu.gl.POLYGON_OFFSET_FILL)).toEqual(false); - }); - - it('enables CULL_FACE with BACK', () => { - expect(gpgpu.gl.getParameter(gpgpu.gl.CULL_FACE)).toEqual(true); - expect(gpgpu.gl.getParameter(gpgpu.gl.CULL_FACE_MODE)) - .toEqual(gpgpu.gl.BACK); - }); - - it('enables SCISSOR_TEST', () => { - expect(gpgpu.gl.getParameter(gpgpu.gl.SCISSOR_TEST)).toEqual(true); - }); -}); - -describeWithFlags('gpgpu_util createFloat32MatrixTexture', WEBGL_ENVS, () => { - it('sets the TEXTURE_WRAP S+T parameters to CLAMP_TO_EDGE', () => { - const gpgpu = new GPGPUContext(); - const textureConfig = tex_util.getTextureConfig(gpgpu.gl); - const tex = - gpgpu_util.createFloat32MatrixTexture(gpgpu.gl, 32, 32, textureConfig) - .texture; - gpgpu.gl.bindTexture(gpgpu.gl.TEXTURE_2D, tex); - expect( - gpgpu.gl.getTexParameter(gpgpu.gl.TEXTURE_2D, gpgpu.gl.TEXTURE_WRAP_S)) - .toEqual(gpgpu.gl.CLAMP_TO_EDGE); - expect( - gpgpu.gl.getTexParameter(gpgpu.gl.TEXTURE_2D, gpgpu.gl.TEXTURE_WRAP_T)) - .toEqual(gpgpu.gl.CLAMP_TO_EDGE); - gpgpu.gl.bindTexture(gpgpu.gl.TEXTURE_2D, null); - gpgpu.deleteMatrixTexture(tex); - gpgpu.dispose(); - }); - - it('sets the TEXTURE_[MIN|MAG]_FILTER parameters to NEAREST', () => { - const gpgpu = new GPGPUContext(); - const textureConfig = tex_util.getTextureConfig(gpgpu.gl); - const tex = - gpgpu_util.createFloat32MatrixTexture(gpgpu.gl, 32, 32, textureConfig) - .texture; - gpgpu.gl.bindTexture(gpgpu.gl.TEXTURE_2D, tex); - expect(gpgpu.gl.getTexParameter( - gpgpu.gl.TEXTURE_2D, gpgpu.gl.TEXTURE_MIN_FILTER)) - .toEqual(gpgpu.gl.NEAREST); - expect(gpgpu.gl.getTexParameter( - gpgpu.gl.TEXTURE_2D, gpgpu.gl.TEXTURE_MAG_FILTER)) - .toEqual(gpgpu.gl.NEAREST); - gpgpu.gl.bindTexture(gpgpu.gl.TEXTURE_2D, null); - gpgpu.deleteMatrixTexture(tex); - gpgpu.dispose(); - }); -}); - -describeWithFlags('gpgpu_util createPackedMatrixTexture', WEBGL_ENVS, () => { - it('sets the TEXTURE_WRAP S+T parameters to CLAMP_TO_EDGE', () => { - const gpgpu = new GPGPUContext(); - const textureConfig = tex_util.getTextureConfig(gpgpu.gl); - const tex = - gpgpu_util.createPackedMatrixTexture(gpgpu.gl, 32, 32, textureConfig); - gpgpu.gl.bindTexture(gpgpu.gl.TEXTURE_2D, tex.texture); - expect( - gpgpu.gl.getTexParameter(gpgpu.gl.TEXTURE_2D, gpgpu.gl.TEXTURE_WRAP_S)) - .toEqual(gpgpu.gl.CLAMP_TO_EDGE); - expect( - gpgpu.gl.getTexParameter(gpgpu.gl.TEXTURE_2D, gpgpu.gl.TEXTURE_WRAP_T)) - .toEqual(gpgpu.gl.CLAMP_TO_EDGE); - gpgpu.gl.bindTexture(gpgpu.gl.TEXTURE_2D, null); - gpgpu.deleteMatrixTexture(tex.texture); - gpgpu.dispose(); - }); - - it('sets the TEXTURE_[MIN|MAG]_FILTER parameters to NEAREST', () => { - const gpgpu = new GPGPUContext(); - const textureConfig = tex_util.getTextureConfig(gpgpu.gl); - const tex = - gpgpu_util.createPackedMatrixTexture(gpgpu.gl, 32, 32, textureConfig); - gpgpu.gl.bindTexture(gpgpu.gl.TEXTURE_2D, tex.texture); - expect(gpgpu.gl.getTexParameter( - gpgpu.gl.TEXTURE_2D, gpgpu.gl.TEXTURE_MIN_FILTER)) - .toEqual(gpgpu.gl.NEAREST); - expect(gpgpu.gl.getTexParameter( - gpgpu.gl.TEXTURE_2D, gpgpu.gl.TEXTURE_MAG_FILTER)) - .toEqual(gpgpu.gl.NEAREST); - gpgpu.gl.bindTexture(gpgpu.gl.TEXTURE_2D, null); - gpgpu.deleteMatrixTexture(tex.texture); - gpgpu.dispose(); - }); -}); diff --git a/tfjs-master/tfjs-backend-webgl/src/im2col_packed_gpu.ts b/tfjs-master/tfjs-backend-webgl/src/im2col_packed_gpu.ts deleted file mode 100644 index 70596d860..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/im2col_packed_gpu.ts +++ /dev/null @@ -1,108 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util} from '@tensorflow/tfjs-core'; -import {getGlslDifferences} from './glsl_version'; -import {GPGPUProgram, useShapeUniforms} from './gpgpu_math'; - -export class Im2ColPackedProgram implements GPGPUProgram { - variableNames = ['A']; - packedInputs = true; - packedOutput = true; - outputShape: number[]; - userCode: string; - enableShapeUniforms: boolean; - customUniforms = [ - {name: 'inputShape', type: 'ivec4' as const }, - {name: 'pad', type: 'ivec2' as const }, - {name: 'stride', type: 'ivec2' as const }, - {name: 'dilation', type: 'ivec2' as const }, - {name: 'inChannels', type: 'int' as const }, - {name: 'itemsPerBlockRow', type: 'int' as const }, - {name: 'outWidth', type: 'int' as const }, - ]; - - constructor(outputShape: number[], convInfo: backend_util.Conv2DInfo) { - this.outputShape = outputShape; - this.enableShapeUniforms = useShapeUniforms(this.outputShape.length); - const {dataFormat} = convInfo; - const glsl = getGlslDifferences(); - const isChannelsLast = dataFormat === 'channelsLast'; - const rowDim = isChannelsLast ? 1 : 2; - const colDim = isChannelsLast ? 2 : 3; - - const boundsCheckingSnippet = this.enableShapeUniforms ? - 'if(blockIndex < outShape[2] && pos < outShape[1]) {' : - `if(blockIndex < ${outputShape[2]} && pos < ${outputShape[1]}) {`; - let unrolled = ``; - - for (let row = 0; row <= 1; row++) { - for (let col = 0; col <= 1; col++) { - unrolled += ` - blockIndex = rc.z + ${col}; - pos = rc.y + ${row}; - - ${boundsCheckingSnippet} - offsetY = int(blockIndex / outWidth) * stride[0] - pad[0]; - d0 = offsetY + dilation[0] * (pos / itemsPerBlockRow); - - if(d0 < inputShape[${rowDim}] && d0 >= 0) { - // Use custom imod instead mod. On Intel GPU, mod may generate - // unexpected value. - // https://github.com/tensorflow/tfjs/issues/5447 - offsetX = imod(blockIndex, outWidth) * stride[1] - pad[1]; - d1 = offsetX + dilation[1] * (imod(pos, itemsPerBlockRow) / - inChannels); - - if(d1 < inputShape[${colDim}] && d1 >= 0) { - - ch = imod(pos, inChannels); - - if (${isChannelsLast}) { - innerDims = vec2(d1, ch); - result[${row * 2 + col}] = getChannel( - getA(rc.x, d0, int(innerDims.x), - int(innerDims.y)), innerDims); - } else { - innerDims = vec2(d0, d1); - result[${row * 2 + col}] = getChannel( - getA(rc.x, ch, int(innerDims.x), - int(innerDims.y)), innerDims); - } - } - } - } - `; - } - } - - this.userCode = ` - void main() { - ivec3 rc = getOutputCoords(); - - vec4 result = vec4(0); - - int blockIndex, pos, offsetY, d0, offsetX, d1, ch; - vec2 innerDims; - - ${unrolled} - - ${glsl.output} = result; - } - `; - } -} diff --git a/tfjs-master/tfjs-backend-webgl/src/index.ts b/tfjs-master/tfjs-backend-webgl/src/index.ts deleted file mode 100644 index abf89246e..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/index.ts +++ /dev/null @@ -1,20 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// All exports from this package should be in base. -export * from './base'; -import './register_all_kernels'; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernel_utils/arg_min_max.ts b/tfjs-master/tfjs-backend-webgl/src/kernel_utils/arg_min_max.ts deleted file mode 100644 index 57b94a25b..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernel_utils/arg_min_max.ts +++ /dev/null @@ -1,107 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, env, TensorInfo, util} from '@tensorflow/tfjs-core'; - -import {ArgMinMaxProgram} from '../argminmax_gpu'; -import {ArgMinMaxPackedProgram} from '../argminmax_packed_gpu'; -import {MathBackendWebGL} from '../backend_webgl'; -import {reshape} from '../kernels/Reshape'; - -function argReduce( - backend: MathBackendWebGL, x: TensorInfo, reduceType: 'max'|'min', - bestIndicesA: TensorInfo = null): TensorInfo { - let batchSize = x.shape[0]; - let inSize = x.shape[1]; - if (bestIndicesA != null) { - batchSize = bestIndicesA.shape[0]; - inSize = bestIndicesA.shape[1]; - } - const windowSize = backend_util.computeOptimalWindowSize(inSize); - const reduceInfo = - {windowSize, inSize, batchSize, outSize: Math.ceil(inSize / windowSize)}; - const program = - new ArgMinMaxProgram(reduceInfo, reduceType, bestIndicesA == null); - const inputs = [x]; - if (bestIndicesA != null) { - inputs.push(bestIndicesA); - } - const output = backend.runWebGLProgram(program, inputs, 'int32'); - // No need to run another GPGPU program. - if (output.shape[1] === 1) { - return output; - } - const result = argReduce(backend, x, reduceType, output); - backend.disposeIntermediateTensorInfo(output); - return result; -} - -function argReducePacked( - backend: MathBackendWebGL, x: TensorInfo, reduceType: 'max'|'min', - bestIndicesA: TensorInfo = null): TensorInfo { - const inShape = bestIndicesA != null ? bestIndicesA.shape : x.shape; - const inSize = inShape[inShape.length - 1]; - const windowSize = backend_util.computeOptimalWindowSize(inSize); - const program = new ArgMinMaxPackedProgram( - inShape, windowSize, reduceType, bestIndicesA == null); - const inputs = bestIndicesA == null ? [x] : [x, bestIndicesA]; - const output = backend.runWebGLProgram(program, inputs, 'int32'); - if (output.shape.length === x.shape.length) { - const result = argReducePacked(backend, x, reduceType, output); - backend.disposeIntermediateTensorInfo(output); - return result; - } - return output; -} - -export function argMinMaxReduce( - backend: MathBackendWebGL, x: TensorInfo, axis: number, - reduceType: 'min'|'max'): TensorInfo { - const axes = [axis]; - backend_util.assertAxesAreInnerMostDims( - 'arg' + reduceType.charAt(0).toUpperCase() + reduceType.slice(1), axes, - x.shape.length); - if (!env().getBool('WEBGL_PACK_REDUCE') || x.shape.length <= 2) { - const intermediateTensorInfos = []; - // Eagerly unpack x input since it is passed in to all the shaders which - // require unpacked inputs. - const xtexData = backend.texData.get(x.dataId); - const xIsPacked = xtexData !== null && xtexData.isPacked; - let xUnPacked = x; - if (xIsPacked) { - xUnPacked = backend.unpackTensor(x); - intermediateTensorInfos.push(xUnPacked); - } - - const [outShape, reduceShape] = - backend_util.computeOutAndReduceShapes(xUnPacked.shape, axes); - const inSize = util.sizeFromShape(reduceShape); - const a2D = reshape( - {inputs: {x: xUnPacked}, backend, attrs: {shape: [-1, inSize]}}); - intermediateTensorInfos.push(a2D); - - const reduced = argReduce(backend, a2D, reduceType); - intermediateTensorInfos.push(reduced); - const reshaped = - reshape({inputs: {x: reduced}, backend, attrs: {shape: outShape}}); - - intermediateTensorInfos.forEach( - t => backend.disposeIntermediateTensorInfo(t)); - return reshaped; - } - return argReducePacked(backend, x, reduceType); -} diff --git a/tfjs-master/tfjs-backend-webgl/src/kernel_utils/int.ts b/tfjs-master/tfjs-backend-webgl/src/kernel_utils/int.ts deleted file mode 100644 index c7475ded9..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernel_utils/int.ts +++ /dev/null @@ -1,29 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {TensorInfo} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {UnaryOpProgram} from '../unaryop_gpu'; - -const TO_INT = `return float(int(x));`; - -export function int(input: TensorInfo, backend: MathBackendWebGL): TensorInfo { - const program = new UnaryOpProgram(input.shape, TO_INT); - const output = backend.runWebGLProgram(program, [input], 'int32'); - return {dataId: output.dataId, shape: output.shape, dtype: output.dtype}; -} diff --git a/tfjs-master/tfjs-backend-webgl/src/kernel_utils/kernel_funcs_utils.ts b/tfjs-master/tfjs-backend-webgl/src/kernel_utils/kernel_funcs_utils.ts deleted file mode 100644 index 73e073072..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernel_utils/kernel_funcs_utils.ts +++ /dev/null @@ -1,224 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import { backend_util, BinaryInputs, DataType, env, KernelFunc, TypedArray, UnaryInputs, upcastType} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {BinaryOpProgram} from '../binaryop_gpu'; -import {BinaryOpPackedProgram} from '../binaryop_packed_gpu'; -import {complex} from '../kernels/Complex'; -import {LEAKYRELU, LEAKYRELU_PACKED} from '../kernels/LeakyRelu'; -import {PRELU, PRELU_PACKED} from '../kernels/Prelu'; -import * as unary_op from '../unaryop_gpu'; -import {UnaryOpProgram} from '../unaryop_gpu'; -import * as unary_packed_op from '../unaryop_packed_gpu'; -import {UnaryOpPackedProgram} from '../unaryop_packed_gpu'; - -import {SimpleBinaryKernelImplCPU, SimpleUnaryKernelImplCPU} from './shared'; - -export const CHECK_NAN_SNIPPET_UNARY = `if (isnan(x)) return x;`; - -type UnaryKernelFuncConfig = { - opSnippet: string, - packedOpSnippet?: string, - cpuKernelImpl?: SimpleUnaryKernelImplCPU, - dtype?: DataType, -}; - -/** - * Template that creates a `KernelFunc` for unary ops. - * @param opSnippet Op snippet to create `UnaryOpProgram`. - * @param packedOpSnippet Op snippet to create `UnaryOpPackedProgram`. - * @param dtype Optional. If set, the result has this dtype. Otherwise, the - * result has the same dtype as the first input. This is mainly used in - * comparison kernels, such as Equal, Less, Greater, etc. - */ -export function unaryKernelFunc( - {opSnippet, packedOpSnippet, cpuKernelImpl, dtype}: UnaryKernelFuncConfig): - KernelFunc { - return ({inputs, backend}) => { - const {x} = inputs as UnaryInputs; - const webglBackend = backend as MathBackendWebGL; - - const $dtype = dtype || x.dtype; - if (webglBackend.shouldExecuteOnCPU([x]) && cpuKernelImpl != null) { - const xData = webglBackend.texData.get(x.dataId); - const outValues = cpuKernelImpl(xData.values as TypedArray, $dtype); - return webglBackend.makeTensorInfo(x.shape, $dtype, outValues); - } - - const shouldUsePackedProgram = - env().getBool('WEBGL_PACK_UNARY_OPERATIONS') && packedOpSnippet != null; - let program: UnaryOpProgram|UnaryOpPackedProgram; - if (shouldUsePackedProgram) { - program = new UnaryOpPackedProgram(x.shape, packedOpSnippet); - } else { - program = new UnaryOpProgram(x.shape, opSnippet); - } - - return webglBackend.runWebGLProgram(program, [x], $dtype); - }; -} - -type BinaryKernelFuncConfig = { - opSnippet: string, - packedOpSnippet?: string, - checkOutOfBounds?: boolean, - supportsComplex?: boolean, - cpuKernelImpl?: SimpleBinaryKernelImplCPU, - dtype?: DataType -}; - -/** - * Template that creates a `KernelFunc` for binary ops. - * @param opSnippet Op snippet to create `BinaryOpProgram`. - * @param packedOpSnippet Op snippet to create `BinaryOpPackedProgram`. - * @param checkOutOfBoundsForPackedProgram Whether to set checkOutOfBounds=true - * when creating BinaryOpPackedProgram. - * @param dtype Optional. If set, the result has this dtype. Otherwise, the - * result has the same dtype as the first input. This is mainly used in - * comparison kernels, such as Equal, Less, Greater, etc. - */ -export function binaryKernelFunc({ - opSnippet, - packedOpSnippet, - checkOutOfBounds = false, - supportsComplex = false, - cpuKernelImpl, - dtype -}: BinaryKernelFuncConfig): KernelFunc { - return ({inputs, backend}) => { - const {a, b} = inputs as BinaryInputs; - const webglBackend = backend as MathBackendWebGL; - - if (supportsComplex && a.dtype === 'complex64') { - const aData = webglBackend.texData.get(a.dataId); - const bData = webglBackend.texData.get(b.dataId); - - const [real, imag] = [ - [aData.complexTensorInfos.real, bData.complexTensorInfos.real], - [aData.complexTensorInfos.imag, bData.complexTensorInfos.imag] - ].map(complexParts => { - const [aPart, bPart] = complexParts; - - const aHandle = { - dataId: aPart.dataId, - dtype: aPart.dtype, - shape: a.shape - }; - const bHandle = { - dataId: bPart.dataId, - dtype: bPart.dtype, - shape: b.shape - }; - - const program = new BinaryOpProgram(opSnippet, a.shape, b.shape); - return webglBackend.runWebGLProgram( - program, [aHandle, bHandle], upcastType(aPart.dtype, bPart.dtype)); - }); - - const complexOutput = - complex({inputs: {real, imag}, backend: webglBackend}); - - webglBackend.disposeIntermediateTensorInfo(real); - webglBackend.disposeIntermediateTensorInfo(imag); - - // TODO(annxingyuan): Implement CPU forwarding for complex inputs. - - return complexOutput; - } - - const $dtype = dtype || upcastType(a.dtype, b.dtype); - if ((a.dtype === 'string' || b.dtype === 'string' || - webglBackend.shouldExecuteOnCPU([a, b])) && - cpuKernelImpl != null) { - const aVals = webglBackend.texData.get(a.dataId).values as TypedArray; - const bVals = webglBackend.texData.get(b.dataId).values as TypedArray; - - const decodedAVals = a.dtype === 'string' ? - // tslint:disable-next-line: no-any - backend_util.fromUint8ToStringArray(aVals as any as Uint8Array[]) : - aVals; - const decodedBVals = a.dtype === 'string' ? - // tslint:disable-next-line: no-any - backend_util.fromUint8ToStringArray(bVals as any as Uint8Array[]) : - bVals; - const [outValues, outShape] = - cpuKernelImpl(a.shape, b.shape, decodedAVals, decodedBVals, $dtype); - - const out = webglBackend.makeTensorInfo(outShape, $dtype); - const outData = webglBackend.texData.get(out.dataId); - outData.values = outValues; - return out; - } - - const shouldUsePackedProgram = - env().getBool('WEBGL_PACK_BINARY_OPERATIONS') && - packedOpSnippet != null; - let program: BinaryOpProgram|BinaryOpPackedProgram; - if (shouldUsePackedProgram) { - program = new BinaryOpPackedProgram( - packedOpSnippet, a.shape, b.shape, checkOutOfBounds); - } else { - program = new BinaryOpProgram(opSnippet, a.shape, b.shape); - } - - return webglBackend.runWebGLProgram(program, [a, b], $dtype); - }; -} - -export function mapActivationToShaderProgram( - activation: backend_util.Activation, packed = false): string { - if (activation === 'linear') { - if (packed) { - return unary_packed_op.LINEAR; - } - return unary_op.LINEAR; - } else if (activation === 'relu') { - if (packed) { - return unary_packed_op.RELU; - } - return unary_op.RELU; - } else if (activation === 'elu') { - if (packed) { - return unary_packed_op.ELU; - } - return unary_op.ELU; - } else if (activation === 'relu6') { - if (packed) { - return unary_packed_op.RELU6; - } - return unary_op.RELU6; - } else if (activation === 'prelu') { - if (packed) { - return PRELU_PACKED; - } - return PRELU; - } else if (activation === 'leakyrelu') { - if (packed) { - return LEAKYRELU_PACKED; - } - return LEAKYRELU; - } else if (activation === 'sigmoid') { - if (packed) { - return unary_packed_op.SIGMOID; - } - return unary_op.SIGMOID; - } - throw new Error(`Activation ${ - activation} has not been implemented for the WebGL backend.`); -} diff --git a/tfjs-master/tfjs-backend-webgl/src/kernel_utils/reduce.ts b/tfjs-master/tfjs-backend-webgl/src/kernel_utils/reduce.ts deleted file mode 100644 index b36f3374a..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernel_utils/reduce.ts +++ /dev/null @@ -1,76 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, DataType, TensorInfo} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {MeanProgram} from '../mean_gpu'; -import {ReduceProgram} from '../reduce_gpu'; - -type ReduceTypes = 'all'|'any'|'max'|'min'|'sum'|'prod'|'mean'; - -// Returns an array of configuration objects that describe each stage of the -// reduction. -function getReductionStages(inShape: number[]): - Array<{inSize: number, windowSize: number, outSize: number}> { - const stages = []; - - while (stages.length === 0 || stages[stages.length - 1].outSize !== 1) { - const outSize: number = - stages.length ? stages[stages.length - 1].outSize : inShape[1]; - const windowSize = backend_util.computeOptimalWindowSize(outSize); - stages.push({ - inSize: outSize, - windowSize, - outSize: Math.ceil(outSize / windowSize) - }); - } - - return stages; -} - -export function reduce( - x: TensorInfo, dtype: DataType, reductionType: ReduceTypes, - backend: MathBackendWebGL): TensorInfo { - const reductionStages = getReductionStages(x.shape); - - let result = x; - for (let i = 0; i < reductionStages.length; i++) { - const {inSize, windowSize, outSize} = reductionStages[i]; - - let program: ReduceProgram|MeanProgram; - let previousResult: TensorInfo; - if (reductionType === 'mean') { - program = i === 0 ? - new MeanProgram( - {windowSize, inSize, batchSize: x.shape[0], outSize}, inSize) : - new MeanProgram({windowSize, inSize, batchSize: x.shape[0], outSize}); - } else { - program = new ReduceProgram( - {windowSize, inSize, batchSize: x.shape[0], outSize}, reductionType); - } - - previousResult = result; - result = backend.runWebGLProgram(program, [result], dtype); - - if (previousResult.dataId !== x.dataId) { - backend.disposeIntermediateTensorInfo(previousResult); - } - } - - return result; -} diff --git a/tfjs-master/tfjs-backend-webgl/src/kernel_utils/reshape.ts b/tfjs-master/tfjs-backend-webgl/src/kernel_utils/reshape.ts deleted file mode 100644 index 1f3ae73ef..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernel_utils/reshape.ts +++ /dev/null @@ -1,46 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {TensorInfo} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {ReshapePackedProgram} from '../reshape_packed_gpu'; -import {getBatchDim, getRowsCols} from '../webgl_util'; - -export function packedReshape( - input: TensorInfo, afterShape: number[], - backend: MathBackendWebGL): TensorInfo { - const input3DShape = - [getBatchDim(input.shape), - ...getRowsCols(input.shape)] as [number, number, number]; - const input3D: TensorInfo = { - dtype: input.dtype, - shape: input3DShape, - dataId: input.dataId - }; - const afterShapeAs3D = - [getBatchDim(afterShape), - ...getRowsCols(afterShape)] as [number, number, number]; - - const program = new ReshapePackedProgram(afterShapeAs3D, input3DShape); - const preventEagerUnpackingOfOutput = true; - const customValues = [input3DShape]; - const output = backend.runWebGLProgram( - program, [input3D], input.dtype, customValues, - preventEagerUnpackingOfOutput); - return {dataId: output.dataId, shape: afterShape, dtype: output.dtype}; -} diff --git a/tfjs-master/tfjs-backend-webgl/src/kernel_utils/shared.ts b/tfjs-master/tfjs-backend-webgl/src/kernel_utils/shared.ts deleted file mode 100644 index 327a932a8..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernel_utils/shared.ts +++ /dev/null @@ -1,132 +0,0 @@ - -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// Import shared functionality from tfjs-backend-cpu without triggering -// side effects. -// tslint:disable-next-line: no-imports-from-dist -import * as shared from '@tensorflow/tfjs-backend-cpu/dist/shared'; -// tslint:disable-next-line: no-imports-from-dist -import {SimpleBinaryKernelImpl} from '@tensorflow/tfjs-backend-cpu/dist/shared'; -// tslint:disable-next-line: no-imports-from-dist -import {SimpleUnaryImpl} from '@tensorflow/tfjs-backend-cpu/dist/utils/unary_types'; - -export type SimpleBinaryKernelImplCPU = SimpleBinaryKernelImpl; -export type SimpleUnaryKernelImplCPU = SimpleUnaryImpl; -const { - addImpl: addImplCPU, - bincountImpl: bincountImplCPU, - bincountReduceImpl: bincountReduceImplCPU, - bitwiseAndImpl: bitwiseAndImplCPU, - castImpl: castImplCPU, - ceilImpl: ceilImplCPU, - concatImpl: concatImplCPU, - equalImpl: equalImplCPU, - expImpl: expImplCPU, - expm1Impl: expm1ImplCPU, - floorImpl: floorImplCPU, - gatherNdImpl: gatherNdImplCPU, - gatherV2Impl: gatherV2ImplCPU, - greaterImpl: greaterImplCPU, - greaterEqualImpl: greaterEqualImplCPU, - lessImpl: lessImplCPU, - lessEqualImpl: lessEqualImplCPU, - linSpaceImpl: linSpaceImplCPU, - logImpl: logImplCPU, - maxImpl: maxImplCPU, - maximumImpl: maximumImplCPU, - minimumImpl: minimumImplCPU, - multiplyImpl: multiplyImplCPU, - negImpl: negImplCPU, - notEqualImpl: notEqualImplCPU, - prodImpl: prodImplCPU, - raggedGatherImpl: raggedGatherImplCPU, - raggedRangeImpl: raggedRangeImplCPU, - raggedTensorToTensorImpl: raggedTensorToTensorImplCPU, - rangeImpl: rangeImplCPU, - rsqrtImpl: rsqrtImplCPU, - scatterImpl: scatterImplCPU, - sigmoidImpl: sigmoidImplCPU, - simpleAbsImpl: simpleAbsImplCPU, - sliceImpl: sliceImplCPU, - sparseFillEmptyRowsImpl: sparseFillEmptyRowsImplCPU, - sparseReshapeImpl: sparseReshapeImplCPU, - sparseSegmentReductionImpl: sparseSegmentReductionImplCPU, - sqrtImpl: sqrtImplCPU, - staticRegexReplaceImpl: staticRegexReplaceImplCPU, - stridedSliceImpl: stridedSliceImplCPU, - stringNGramsImpl: stringNGramsImplCPU, - stringSplitImpl: stringSplitImplCPU, - stringToHashBucketFastImpl: stringToHashBucketFastImplCPU, - subImpl: subImplCPU, - tileImpl: tileImplCPU, - topKImpl: topKImplCPU, - transposeImpl: transposeImplCPU, - uniqueImpl: uniqueImplCPU, -} = shared; - -export { - addImplCPU, - bincountImplCPU, - bincountReduceImplCPU, - bitwiseAndImplCPU, - castImplCPU, - ceilImplCPU, - concatImplCPU, - equalImplCPU, - expImplCPU, - expm1ImplCPU, - floorImplCPU, - gatherNdImplCPU, - gatherV2ImplCPU, - greaterEqualImplCPU, - greaterImplCPU, - lessEqualImplCPU, - lessImplCPU, - linSpaceImplCPU, - logImplCPU, - maxImplCPU, - maximumImplCPU, - minimumImplCPU, - multiplyImplCPU, - negImplCPU, - notEqualImplCPU, - prodImplCPU, - raggedGatherImplCPU, - raggedRangeImplCPU, - raggedTensorToTensorImplCPU, - scatterImplCPU, - sigmoidImplCPU, - simpleAbsImplCPU, - sliceImplCPU, - sparseFillEmptyRowsImplCPU, - sparseReshapeImplCPU, - sparseSegmentReductionImplCPU, - sqrtImplCPU, - staticRegexReplaceImplCPU, - stridedSliceImplCPU, - stringNGramsImplCPU, - stringSplitImplCPU, - stringToHashBucketFastImplCPU, - subImplCPU, - rangeImplCPU, - rsqrtImplCPU, - tileImplCPU, - topKImplCPU, - transposeImplCPU, - uniqueImplCPU, -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Abs.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Abs.ts deleted file mode 100644 index 010b205db..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Abs.ts +++ /dev/null @@ -1,53 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Abs, AbsInputs, env, KernelConfig, KernelFunc, TensorInfo, TypedArray} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {simpleAbsImplCPU} from '../kernel_utils/shared'; -import {UnaryOpProgram} from '../unaryop_gpu'; -import {UnaryOpPackedProgram} from '../unaryop_packed_gpu'; - -const ABS = `return abs(x);`; - -export function abs(args: {inputs: AbsInputs, backend: MathBackendWebGL}): - TensorInfo { - const {inputs, backend} = args; - const {x} = inputs; - - // TODO: handle cases when x is complex. Once the cpu implementation - // can handle complex values, refactor to use unaryKernelFunc. - if (backend.shouldExecuteOnCPU([x]) && x.dtype !== 'complex64') { - const xData = backend.texData.get(x.dataId); - const outValues = simpleAbsImplCPU(xData.values as TypedArray); - return backend.makeTensorInfo(x.shape, x.dtype, outValues); - } - - let program: UnaryOpProgram|UnaryOpPackedProgram; - if (env().getBool('WEBGL_PACK_UNARY_OPERATIONS')) { - program = new UnaryOpPackedProgram(x.shape, ABS); - } else { - program = new UnaryOpProgram(x.shape, ABS); - } - return backend.runWebGLProgram(program, [x], x.dtype); -} - -export const absConfig: KernelConfig = { - kernelName: Abs, - backendName: 'webgl', - kernelFunc: abs as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Acos.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Acos.ts deleted file mode 100644 index 63d9f0022..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Acos.ts +++ /dev/null @@ -1,36 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Acos, KernelConfig} from '@tensorflow/tfjs-core'; - -import {unaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; -import {CHECK_NAN_SNIPPET} from '../unaryop_gpu'; - -const ACOS = CHECK_NAN_SNIPPET + ` - if (abs(x) > 1.) { - return NAN; - } - return acos(x); -`; - -export const acos = unaryKernelFunc({opSnippet: ACOS}); - -export const acosConfig: KernelConfig = { - kernelName: Acos, - backendName: 'webgl', - kernelFunc: acos, -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Acosh.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Acosh.ts deleted file mode 100644 index 6ed1356ee..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Acosh.ts +++ /dev/null @@ -1,34 +0,0 @@ - -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Acosh, KernelConfig} from '@tensorflow/tfjs-core'; - -import {unaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; -import {CHECK_NAN_SNIPPET} from '../unaryop_gpu'; - -const ACOSH = CHECK_NAN_SNIPPET + ` - if (x < 1.0) return NAN; -return log(x + sqrt(x * x - 1.0));`; - -export const acosh = unaryKernelFunc({opSnippet: ACOSH}); - -export const acoshConfig: KernelConfig = { - kernelName: Acosh, - backendName: 'webgl', - kernelFunc: acosh, -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Add.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Add.ts deleted file mode 100644 index c548b77e0..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Add.ts +++ /dev/null @@ -1,36 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Add, KernelConfig} from '@tensorflow/tfjs-core'; - -import {binaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; -import {addImplCPU as cpuAdd} from '../kernel_utils/shared'; - -const ADD = 'return a + b;'; - -export const addKernelFunc = binaryKernelFunc({ - opSnippet: ADD, - packedOpSnippet: ADD, - supportsComplex: true, - cpuKernelImpl: cpuAdd -}); - -export const addConfig: KernelConfig = { - kernelName: Add, - backendName: 'webgl', - kernelFunc: addKernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/AddN.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/AddN.ts deleted file mode 100644 index 98d83e817..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/AddN.ts +++ /dev/null @@ -1,57 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {AddN, AddNInputs, env, KernelConfig, KernelFunc, TensorInfo, upcastType} from '@tensorflow/tfjs-core'; - -import {AddNProgram} from '../addn_gpu'; -import {AddNPackedProgram} from '../addn_packed_gpu'; -import {MathBackendWebGL} from '../backend_webgl'; -import {identity} from './Identity'; - -export function addN(args: {inputs: AddNInputs, backend: MathBackendWebGL}): - TensorInfo { - const {inputs, backend} = args; - - const tensors = inputs; - if (tensors.length === 1) { - return identity({inputs: {x: tensors[0]}, backend}); - } - - // Limit the number of uploaded textures for optimization. - if (tensors.length > env().getNumber('WEBGL_MAX_TEXTURES_IN_SHADER')) { - const midIndex = Math.floor(tensors.length / 2); - const leftSide = addN({inputs: tensors.slice(0, midIndex), backend}); - const rightSide = addN({inputs: tensors.slice(midIndex), backend}); - return addN({inputs: [leftSide, rightSide], backend}); - } - - const dtype = - tensors.map(t => t.dtype).reduce((d1, d2) => upcastType(d1, d2)); - const shapes = tensors.map(t => t.shape); - // We can make sure shapes are identical in op level. - const usePackedOp = env().getBool('WEBGL_PACK'); - const program = usePackedOp ? - new AddNPackedProgram(tensors[0].shape, shapes) : - new AddNProgram(tensors[0].shape, shapes); - return backend.runWebGLProgram(program, tensors, dtype); -} - -export const addNConfig: KernelConfig = { - kernelName: AddN, - backendName: 'webgl', - kernelFunc: addN as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/All.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/All.ts deleted file mode 100644 index 3b1b8b0c4..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/All.ts +++ /dev/null @@ -1,75 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {All, AllAttrs, AllInputs, backend_util, KernelConfig, KernelFunc, TensorInfo, util} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {reduce} from '../kernel_utils/reduce'; - -import {reshape} from './Reshape'; -import {transpose} from './Transpose'; - -export function all( - args: {inputs: AllInputs, backend: MathBackendWebGL, attrs: AllAttrs}): - TensorInfo { - const {inputs, backend, attrs} = args; - const {x} = inputs; - const {axis, keepDims} = attrs; - - const xRank = x.shape.length; - - const origAxes = util.parseAxisParam(axis, x.shape); - let axes = origAxes; - const permutedAxes = backend_util.getAxesPermutation(axes, xRank); - let permutedX = x; - if (permutedAxes != null) { - permutedX = transpose({inputs: {x}, backend, attrs: {perm: permutedAxes}}); - axes = backend_util.getInnerMostAxes(axes.length, xRank); - } - - backend_util.assertAxesAreInnerMostDims('all', axes, xRank); - const [outShape, reduceShape] = - backend_util.computeOutAndReduceShapes(permutedX.shape, axes); - const inSize = util.sizeFromShape(reduceShape); - - const a2D = - reshape({inputs: {x: permutedX}, backend, attrs: {shape: [-1, inSize]}}); - const reduced = reduce(a2D, a2D.dtype, 'all', backend); - - let res; - if (keepDims) { - const newShape = backend_util.expandShapeToKeepDim(outShape, origAxes); - res = reshape({inputs: {x: reduced}, backend, attrs: {shape: newShape}}); - } else { - res = reshape({inputs: {x: reduced}, backend, attrs: {shape: outShape}}); - } - - backend.disposeIntermediateTensorInfo(a2D); - backend.disposeIntermediateTensorInfo(reduced); - - if (permutedAxes != null) { - backend.disposeIntermediateTensorInfo(permutedX); - } - - return res; -} - -export const allConfig: KernelConfig = { - kernelName: All, - backendName: 'webgl', - kernelFunc: all as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Any.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Any.ts deleted file mode 100644 index 172cdc4d2..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Any.ts +++ /dev/null @@ -1,74 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Any, AnyAttrs, AnyInputs, backend_util, KernelConfig, KernelFunc, TensorInfo, util} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {reduce} from '../kernel_utils/reduce'; -import {reshape} from './Reshape'; -import {transpose} from './Transpose'; - -export function any( - args: {inputs: AnyInputs, backend: MathBackendWebGL, attrs: AnyAttrs}): - TensorInfo { - const {inputs, backend, attrs} = args; - const {x} = inputs; - const {axis, keepDims} = attrs; - - const xRank = x.shape.length; - - const origAxes = util.parseAxisParam(axis, x.shape); - let axes = origAxes; - const permutedAxes = backend_util.getAxesPermutation(axes, xRank); - let permutedX = x; - if (permutedAxes != null) { - permutedX = transpose({inputs: {x}, backend, attrs: {perm: permutedAxes}}); - axes = backend_util.getInnerMostAxes(axes.length, xRank); - } - - backend_util.assertAxesAreInnerMostDims('any', axes, xRank); - const [outShape, reduceShape] = - backend_util.computeOutAndReduceShapes(permutedX.shape, axes); - const inSize = util.sizeFromShape(reduceShape); - - const a2D = - reshape({inputs: {x: permutedX}, backend, attrs: {shape: [-1, inSize]}}); - const reduced = reduce(a2D, a2D.dtype, 'any', backend); - - let res; - if (keepDims) { - const newShape = backend_util.expandShapeToKeepDim(outShape, origAxes); - res = reshape({inputs: {x: reduced}, backend, attrs: {shape: newShape}}); - } else { - res = reshape({inputs: {x: reduced}, backend, attrs: {shape: outShape}}); - } - - backend.disposeIntermediateTensorInfo(a2D); - backend.disposeIntermediateTensorInfo(reduced); - - if (permutedAxes != null) { - backend.disposeIntermediateTensorInfo(permutedX); - } - - return res; -} - -export const anyConfig: KernelConfig = { - kernelName: Any, - backendName: 'webgl', - kernelFunc: any as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/ArgMax.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/ArgMax.ts deleted file mode 100644 index 5a8684966..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/ArgMax.ts +++ /dev/null @@ -1,55 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ArgMax, ArgMaxAttrs, ArgMaxInputs, backend_util, KernelConfig, KernelFunc, TensorInfo, util} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {argMinMaxReduce} from '../kernel_utils/arg_min_max'; - -import {transpose} from './Transpose'; - -export function argMax( - args: - {inputs: ArgMaxInputs, backend: MathBackendWebGL, attrs: ArgMaxAttrs}): - TensorInfo { - const {inputs, backend, attrs} = args; - const {x} = inputs; - const {axis} = attrs; - - let axes = util.parseAxisParam(axis, x.shape); - const permutedAxes = backend_util.getAxesPermutation(axes, x.shape.length); - let $x = x; - const intermediateTensorInfos = []; - if (permutedAxes != null) { - $x = transpose({inputs: {x}, backend, attrs: {perm: permutedAxes}}); - intermediateTensorInfos.push($x); - axes = backend_util.getInnerMostAxes(axes.length, $x.shape.length); - } - - backend_util.assertAxesAreInnerMostDims('argMax', [axes[0]], $x.shape.length); - const out = argMinMaxReduce(backend, $x, axes[0], 'max'); - - intermediateTensorInfos.forEach( - t => backend.disposeIntermediateTensorInfo(t)); - return out; -} - -export const argMaxConfig: KernelConfig = { - kernelName: ArgMax, - backendName: 'webgl', - kernelFunc: argMax as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/ArgMax_test.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/ArgMax_test.ts deleted file mode 100644 index 1b3bf044b..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/ArgMax_test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '@tensorflow/tfjs-core'; -// tslint:disable-next-line: no-imports-from-dist -import {describeWithFlags} from '@tensorflow/tfjs-core/dist/jasmine_util'; - -import {WEBGL_ENVS} from '../backend_webgl_test_registry'; - -describeWithFlags('ArgMax', WEBGL_ENVS, () => { - it('handles packed inputs', async () => { - const a = tf.tensor2d([3, -1, 0, 100, -7, 2], [2, 3]); - - // pack a using the add op which packs outputs - tf.env().set('WEBGL_PACK', true); - const aPacked = tf.addN([a, tf.zeros(a.shape)]); - - tf.test_util.expectArraysEqual(await tf.argMax(aPacked).data(), [1, 0, 1]); - }); -}); diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/ArgMin.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/ArgMin.ts deleted file mode 100644 index a7583ae64..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/ArgMin.ts +++ /dev/null @@ -1,55 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ArgMin, ArgMinAttrs, ArgMinInputs, backend_util, KernelConfig, KernelFunc, TensorInfo, util} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {argMinMaxReduce} from '../kernel_utils/arg_min_max'; -import {transpose} from './Transpose'; - -export function argMin( - args: - {inputs: ArgMinInputs, backend: MathBackendWebGL, attrs: ArgMinAttrs}): - TensorInfo { - const {inputs, backend, attrs} = args; - const {x} = inputs; - const {axis} = attrs; - - let axes = util.parseAxisParam(axis, x.shape); - const permutedAxes = backend_util.getAxesPermutation(axes, x.shape.length); - let $x = x; - const intermediateTensorInfos = []; - if (permutedAxes != null) { - $x = transpose({inputs: {x}, backend, attrs: {perm: permutedAxes}}); - intermediateTensorInfos.push($x); - axes = backend_util.getInnerMostAxes(axes.length, $x.shape.length); - } - - backend_util.assertAxesAreInnerMostDims('argMin', [axes[0]], $x.shape.length); - - const out = argMinMaxReduce(backend, $x, axes[0], 'min'); - - intermediateTensorInfos.forEach( - t => backend.disposeIntermediateTensorInfo(t)); - return out; -} - -export const argMinConfig: KernelConfig = { - kernelName: ArgMin, - backendName: 'webgl', - kernelFunc: argMin as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/ArgMin_test.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/ArgMin_test.ts deleted file mode 100644 index e4ff5ffd1..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/ArgMin_test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '@tensorflow/tfjs-core'; -// tslint:disable-next-line: no-imports-from-dist -import {describeWithFlags} from '@tensorflow/tfjs-core/dist/jasmine_util'; - -import {WEBGL_ENVS} from '../backend_webgl_test_registry'; - -describeWithFlags('ArgMin', WEBGL_ENVS, () => { - it('handles packed inputs', async () => { - const a = tf.tensor2d([3, -1, 0, 100, -7, 2], [2, 3]); - - // pack a using the add op which packs outputs - tf.env().set('WEBGL_PACK', true); - const aPacked = tf.addN([a, tf.zeros(a.shape)]); - - tf.test_util.expectArraysEqual(await tf.argMin(aPacked).data(), [0, 1, 0]); - }); -}); diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Asin.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Asin.ts deleted file mode 100644 index 7291fda48..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Asin.ts +++ /dev/null @@ -1,36 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Asin, KernelConfig} from '@tensorflow/tfjs-core'; - -import {unaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; -import {CHECK_NAN_SNIPPET} from '../unaryop_gpu'; - -const ASIN = CHECK_NAN_SNIPPET + ` - if (abs(x) > 1.) { - return NAN; - } - return asin(x); -`; - -export const asin = unaryKernelFunc({opSnippet: ASIN}); - -export const asinConfig: KernelConfig = { - kernelName: Asin, - backendName: 'webgl', - kernelFunc: asin, -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Asinh.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Asinh.ts deleted file mode 100644 index e02be2f73..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Asinh.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Asinh, KernelConfig} from '@tensorflow/tfjs-core'; - -import {unaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; -import {CHECK_NAN_SNIPPET} from '../unaryop_gpu'; - -const ASINH = CHECK_NAN_SNIPPET + `return log(x + sqrt(x * x + 1.0));`; - -export const asinh = unaryKernelFunc({opSnippet: ASINH}); - -export const asinhConfig: KernelConfig = { - kernelName: Asinh, - backendName: 'webgl', - kernelFunc: asinh, -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Atan.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Atan.ts deleted file mode 100644 index 8fd4bf2ab..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Atan.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Atan, KernelConfig} from '@tensorflow/tfjs-core'; - -import {unaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; -import {CHECK_NAN_SNIPPET} from '../unaryop_gpu'; - -const ATAN = CHECK_NAN_SNIPPET + ` - return atan(x); -`; - -export const atan = unaryKernelFunc({opSnippet: ATAN}); - -export const atanConfig: KernelConfig = { - kernelName: Atan, - backendName: 'webgl', - kernelFunc: atan, -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Atan2.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Atan2.ts deleted file mode 100644 index 539321373..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Atan2.ts +++ /dev/null @@ -1,45 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Atan2} from '@tensorflow/tfjs-core'; -import {KernelConfig} from '@tensorflow/tfjs-core'; -import {CHECK_NAN_SNIPPET} from '../binaryop_gpu'; -import {CHECK_NAN_SNIPPET_PACKED} from '../binaryop_packed_gpu'; -import {binaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; - -const ATAN2 = CHECK_NAN_SNIPPET + ` - return atan(a, b); -`; - -const ATAN2_PACKED = ` - vec4 result = atan(a, b); - bvec4 isNaNA = isnan(a); - bvec4 isNaNB = isnan(b); - bvec4 isNaN = bvec4(isNaNA.x || isNaNB.x, isNaNA.y || isNaNB.y, isNaNA.z || isNaNB.z, isNaNA.w || isNaNB.w); - ` + - CHECK_NAN_SNIPPET_PACKED + ` - return result; -`; - -export const atan2 = - binaryKernelFunc({opSnippet: ATAN2, packedOpSnippet: ATAN2_PACKED}); - -export const atan2Config: KernelConfig = { - kernelName: Atan2, - backendName: 'webgl', - kernelFunc: atan2, -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Atanh.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Atanh.ts deleted file mode 100644 index 582831a7b..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Atanh.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Atanh, KernelConfig} from '@tensorflow/tfjs-core'; - -import {unaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; -import {CHECK_NAN_SNIPPET} from '../unaryop_gpu'; - -const ATANH = CHECK_NAN_SNIPPET + ` - if ((x < -1.0) || (x > 1.0)) return NAN; -return (log(1.0 + x) - log(1.0 - x)) / 2.0;`; - -export const atanh = unaryKernelFunc({opSnippet: ATANH}); - -export const atanhConfig: KernelConfig = { - kernelName: Atanh, - backendName: 'webgl', - kernelFunc: atanh, -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/AvgPool.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/AvgPool.ts deleted file mode 100644 index 3b0e76f7b..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/AvgPool.ts +++ /dev/null @@ -1,55 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {AvgPool, AvgPoolAttrs, AvgPoolInputs, backend_util, KernelConfig, KernelFunc, TensorInfo, util} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {Pool2DProgram} from '../pool_gpu'; -import {assertNotComplex} from '../webgl_util'; -import {identity} from './Identity'; - -export function avgPool(args: { - inputs: AvgPoolInputs, - backend: MathBackendWebGL, - attrs: AvgPoolAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {x} = inputs; - assertNotComplex(x, 'avgPool'); - const {filterSize, strides, pad, dimRoundingMode} = attrs; - const dilations = 1; - - util.assert( - backend_util.eitherStridesOrDilationsAreOne(strides, dilations), - () => 'Error in avgPool: Either strides or dilations must be 1. ' + - `Got strides ${strides} and dilations '${dilations}'`); - - const convInfo = backend_util.computePool2DInfo( - x.shape as [number, number, number, number], filterSize, strides, - dilations, pad, dimRoundingMode); - if (convInfo.filterWidth === 1 && convInfo.filterHeight === 1 && - util.arraysEqual(convInfo.inShape, convInfo.outShape)) { - return identity({inputs: {x}, backend}); - } - const avgPoolProgram = new Pool2DProgram(convInfo, 'avg', false); - return backend.runWebGLProgram(avgPoolProgram, [x], 'float32'); -} - -export const avgPoolConfig: KernelConfig = { - kernelName: AvgPool, - backendName: 'webgl', - kernelFunc: avgPool as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/AvgPool3D.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/AvgPool3D.ts deleted file mode 100644 index 7dd55ea1e..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/AvgPool3D.ts +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {AvgPool3D, AvgPool3DAttrs, AvgPool3DInputs, backend_util, KernelConfig, KernelFunc, TensorInfo} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {Pool3DProgram} from '../pool_gpu'; - -export function avgPool3D(args: { - inputs: AvgPool3DInputs, - backend: MathBackendWebGL, - attrs: AvgPool3DAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {x} = inputs; - const {filterSize, strides, pad, dimRoundingMode, dataFormat} = attrs; - const dilations: [number, number, number] = [1, 1, 1]; - - const convInfo = backend_util.computePool3DInfo( - x.shape as [number, number, number, number, number], filterSize, strides, - dilations, pad, dimRoundingMode, dataFormat); - const avgPoolProgram = new Pool3DProgram(convInfo, 'avg', false); - return backend.runWebGLProgram(avgPoolProgram, [x], 'float32'); -} - -export const avgPool3DConfig: KernelConfig = { - kernelName: AvgPool3D, - backendName: 'webgl', - kernelFunc: avgPool3D as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/AvgPool3DGrad.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/AvgPool3DGrad.ts deleted file mode 100644 index f4c4054c7..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/AvgPool3DGrad.ts +++ /dev/null @@ -1,44 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {AvgPool3DGrad, AvgPool3DGradAttrs, AvgPool3DGradInputs, backend_util, KernelConfig, KernelFunc, TensorInfo} from '@tensorflow/tfjs-core'; - -import {AvgPool3DBackpropProgram} from '../avg_pool_backprop_gpu'; -import {MathBackendWebGL} from '../backend_webgl'; - -export function avgPool3DGrad(args: { - inputs: AvgPool3DGradInputs, - backend: MathBackendWebGL, - attrs: AvgPool3DGradAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {dy, input} = inputs; - const x = input; - const {filterSize, strides, pad, dimRoundingMode} = attrs; - const dilations: [number, number, number] = [1, 1, 1]; - - const convInfo = backend_util.computePool3DInfo( - x.shape as [number, number, number, number, number], filterSize, strides, - dilations, pad, dimRoundingMode); - const avgPoolBackpropProgram = new AvgPool3DBackpropProgram(convInfo); - return backend.runWebGLProgram(avgPoolBackpropProgram, [dy], x.dtype); -} - -export const avgPool3DGradConfig: KernelConfig = { - kernelName: AvgPool3DGrad, - backendName: 'webgl', - kernelFunc: avgPool3DGrad as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/AvgPoolGrad.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/AvgPoolGrad.ts deleted file mode 100644 index e5c80b6e7..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/AvgPoolGrad.ts +++ /dev/null @@ -1,45 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {AvgPoolGrad, AvgPoolGradAttrs, AvgPoolGradInputs, backend_util, KernelConfig, KernelFunc, TensorInfo} from '@tensorflow/tfjs-core'; - -import {AvgPool2DBackpropProgram} from '../avg_pool_backprop_gpu'; -import {MathBackendWebGL} from '../backend_webgl'; -import {assertNotComplex} from '../webgl_util'; - -export function avgPoolGrad(args: { - inputs: AvgPoolGradInputs, - backend: MathBackendWebGL, - attrs: AvgPoolGradAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {dy, input} = inputs; - const x = input; - assertNotComplex([dy, input], 'avgPoolGrad'); - const {filterSize, strides, pad} = attrs; - - const convInfo = backend_util.computePool2DInfo( - x.shape as [number, number, number, number], filterSize, strides, - 1 /* dilations */, pad); - const avgPoolBackpropProgram = new AvgPool2DBackpropProgram(convInfo); - return backend.runWebGLProgram(avgPoolBackpropProgram, [dy], x.dtype); -} - -export const avgPoolGradConfig: KernelConfig = { - kernelName: AvgPoolGrad, - backendName: 'webgl', - kernelFunc: avgPoolGrad as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/BatchMatMul.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/BatchMatMul.ts deleted file mode 100644 index 6c5480e08..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/BatchMatMul.ts +++ /dev/null @@ -1,39 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {BatchMatMul, BatchMatMulAttrs, BatchMatMulInputs, KernelConfig, KernelFunc} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {batchMatMulImpl} from './BatchMatMul_impl'; - -export function batchMatMul(args: { - inputs: BatchMatMulInputs, - attrs: BatchMatMulAttrs, - backend: MathBackendWebGL -}) { - const {inputs, backend, attrs} = args; - const {a, b} = inputs; - const {transposeA, transposeB} = attrs; - - return batchMatMulImpl({a, b, transposeA, transposeB, backend}); -} - -export const batchMatMulConfig: KernelConfig = { - kernelName: BatchMatMul, - backendName: 'webgl', - kernelFunc: batchMatMul as unknown as KernelFunc, -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/BatchMatMul_impl.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/BatchMatMul_impl.ts deleted file mode 100644 index 972bb7295..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/BatchMatMul_impl.ts +++ /dev/null @@ -1,187 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, broadcast_util, TensorInfo, upcastType, util} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {mapActivationToShaderProgram} from '../kernel_utils/kernel_funcs_utils'; -import {MatMulPackedProgram} from '../mulmat_packed_gpu'; - -import {multiply} from './Multiply'; -import {reshape} from './Reshape'; -import {sum} from './Sum'; -import {transpose} from './Transpose'; - -// Empirically determined minimal shared dimension in matmul before we forward -// to a.mul(b).sum() in order to take advantage of GPU parallelism. See -// https://github.com/tensorflow/tfjs-core/pull/1379 for benchmarks. -export const MATMUL_SHARED_DIM_THRESHOLD = 1000; - -type BatchMatMulConfig = { - a: TensorInfo, - b: TensorInfo, - transposeA: boolean, - transposeB: boolean, - backend: MathBackendWebGL, - bias?: TensorInfo, - preluActivationWeights?: TensorInfo, - leakyreluAlpha?: number, - activation?: backend_util.Activation -}; - -export function batchMatMulImpl({ - a, - b, - transposeA, - transposeB, - backend, - bias = null, - preluActivationWeights = null, - leakyreluAlpha = 0, - activation = null -}: BatchMatMulConfig): TensorInfo { - const aRank = a.shape.length; - const bRank = b.shape.length; - - const innerShapeA = transposeA ? a.shape[aRank - 2] : a.shape[aRank - 1]; - const innerShapeB = transposeB ? b.shape[bRank - 1] : b.shape[bRank - 2]; - - const outerShapeA = transposeA ? a.shape[aRank - 1] : a.shape[aRank - 2]; - const outerShapeB = transposeB ? b.shape[bRank - 2] : b.shape[bRank - 1]; - - const outerDimsA = a.shape.slice(0, -2); - const outerDimsB = b.shape.slice(0, -2); - - const batchDimA = util.sizeFromShape(outerDimsA); - const batchDimB = util.sizeFromShape(outerDimsB); - - const outShapeOuterDims = broadcast_util.assertAndGetBroadcastShape( - a.shape.slice(0, -2), b.shape.slice(0, -2)); - const outShape = outShapeOuterDims.concat([outerShapeA, outerShapeB]); - - util.assert( - innerShapeA === innerShapeB, - () => `Error in matMul: inner shapes (${innerShapeA}) and (` + - `${innerShapeB}) of Tensors with shapes ${a.shape} and ` + - `${b.shape} and transposeA=${transposeA}` + - ` and transposeB=${transposeB} must match.`); - - const a3dShape: [number, number, number] = transposeA ? - [batchDimA, innerShapeA, outerShapeA] : - [batchDimA, outerShapeA, innerShapeA]; - const b3dShape: [number, number, number] = transposeB ? - [batchDimB, outerShapeB, innerShapeB] : - [batchDimB, innerShapeB, outerShapeB]; - - // The rest of the implementation is designed to operate on rank-3 tensors - const a3d = reshape({inputs: {x: a}, backend, attrs: {shape: a3dShape}}); - const b3d = reshape({inputs: {x: b}, backend, attrs: {shape: b3dShape}}); - - const intermediates: TensorInfo[] = [a3d, b3d]; - - const batchDim = Math.max(batchDimA, batchDimB); - const sharedDim = transposeA ? a3d.shape[1] : a3d.shape[2]; - - const hasBias = bias != null; - const hasPreluActivationWeights = preluActivationWeights != null; - const hasLeakyreluAlpha = activation === 'leakyrelu'; - const fusedActivation = activation != null ? - mapActivationToShaderProgram(activation, true) : - null; - const containsFusedOps = hasBias || hasPreluActivationWeights || - hasLeakyreluAlpha || fusedActivation != null; - let out: TensorInfo; - - // Since the matrices are vectors, it is faster to call mul().sum() - // because sum() is O(sqrt(N)) due to divide-and-conquer. - if ((outerShapeA === 1 || outerShapeB === 1) && - sharedDim > MATMUL_SHARED_DIM_THRESHOLD && containsFusedOps === false) { - let aVec = a3d; - let bVec = b3d; - if (transposeA) { - aVec = transpose({inputs: {x: a3d}, backend, attrs: {perm: [0, 2, 1]}}); - intermediates.push(aVec); - } - if (transposeB) { - bVec = transpose({inputs: {x: b3d}, backend, attrs: {perm: [0, 2, 1]}}); - intermediates.push(bVec); - } - - const shouldReshapeA = outerShapeB !== 1; - const shouldReshapeB = outerShapeB === 1; - - let aVec3d = aVec; - if (shouldReshapeA) { - aVec3d = reshape({ - inputs: {x: aVec}, - backend, - attrs: {shape: [batchDim, sharedDim, 1]} - }); - - intermediates.push(aVec3d); - } - - const axis = outerShapeB === 1 ? 2 : 1; - - let bVec3d = bVec; - if (shouldReshapeB) { - bVec3d = reshape({ - inputs: {x: bVec}, - backend, - attrs: {shape: [batchDim, 1, sharedDim]} - }); - - intermediates.push(bVec3d); - } - - const product = multiply({inputs: {a: aVec3d, b: bVec3d}, backend}); - out = sum({inputs: {x: product}, backend, attrs: {axis, keepDims: true}}); - intermediates.push(product); - } else { - const dtype = upcastType(a.dtype, b.dtype); - - const program = new MatMulPackedProgram( - a3dShape, b3dShape, [batchDim, outerShapeA, outerShapeB], transposeA, - transposeB, hasBias, fusedActivation, hasPreluActivationWeights, - hasLeakyreluAlpha); - - const inputs: TensorInfo[] = [a3d, b3d]; - if (bias != null) { - inputs.push(bias); - } - if (hasPreluActivationWeights) { - inputs.push(preluActivationWeights); - } - if (hasLeakyreluAlpha) { - const $leakyreluAlpha = backend.makeTensorInfo( - [], 'float32', - util.createScalarValue(leakyreluAlpha as unknown as 'float32', 'float32')); - inputs.push($leakyreluAlpha); - intermediates.push($leakyreluAlpha); - } - - out = backend.runWebGLProgram(program, inputs, dtype); - } - - const outReshaped = - reshape({inputs: {x: out}, backend, attrs: {shape: outShape}}); - intermediates.push(out); - for (const i of intermediates) { - backend.disposeIntermediateTensorInfo(i); - } - return outReshaped; -} diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/BatchNorm.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/BatchNorm.ts deleted file mode 100644 index 57328613b..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/BatchNorm.ts +++ /dev/null @@ -1,81 +0,0 @@ - -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {env, FusedBatchNorm, FusedBatchNormAttrs, FusedBatchNormInputs, KernelConfig, KernelFunc, TensorInfo, util} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {BatchNormProgram} from '../batchnorm_gpu'; -import {BatchNormPackedProgram} from '../batchnorm_packed_gpu'; - -export const batchNorm: (params: { - inputs: FusedBatchNormInputs, - backend: MathBackendWebGL, - attrs: FusedBatchNormAttrs -}) => TensorInfo = ({inputs, backend, attrs}) => { - const {x, mean, variance, offset, scale} = inputs; - - util.assert( - mean.shape.length === variance.shape.length, - () => 'Batch normalization gradient requires mean and variance to have ' + - 'equal ranks.'); - util.assert( - offset == null || mean.shape.length === offset.shape.length, - () => 'Batch normalization gradient requires mean and offset to have ' + - 'equal ranks.'); - util.assert( - scale == null || mean.shape.length === scale.shape.length, - () => 'Batch normalization gradient requires mean and scale to have ' + - 'equal ranks.'); - - let {varianceEpsilon} = attrs; - if (varianceEpsilon == null) { - varianceEpsilon = 0.001; - } - - const finalInputs = [x, mean, variance]; - - let offsetShape = null; - if (offset != null) { - offsetShape = offset.shape; - finalInputs.push(offset); - } - - let scaleShape = null; - if (scale != null) { - scaleShape = scale.shape; - finalInputs.push(scale); - } - - const program = env().getBool('WEBGL_PACK_NORMALIZATION') ? - new BatchNormPackedProgram( - x.shape, mean.shape, variance.shape, offsetShape, scaleShape, - varianceEpsilon) : - new BatchNormProgram( - x.shape, mean.shape, variance.shape, offsetShape, scaleShape, - varianceEpsilon); - const output = - backend.runWebGLProgram(program, finalInputs, finalInputs[0].dtype); - - return output; -}; - -export const batchNormConfig: KernelConfig = { - kernelName: FusedBatchNorm, - backendName: 'webgl', - kernelFunc: batchNorm as unknown as KernelFunc, -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/BatchToSpaceND.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/BatchToSpaceND.ts deleted file mode 100644 index 2e7de7ea5..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/BatchToSpaceND.ts +++ /dev/null @@ -1,80 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, BatchToSpaceND, BatchToSpaceNDAttrs, BatchToSpaceNDInputs, KernelConfig, KernelFunc, TensorInfo, util} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; - -import {reshape} from './Reshape'; -import {slice} from './Slice'; -import {transpose} from './Transpose'; - -export const batchToSpaceND = (args: { - inputs: BatchToSpaceNDInputs, - backend: MathBackendWebGL, - attrs: BatchToSpaceNDAttrs -}): TensorInfo => { - const {inputs, backend, attrs} = args; - const {x} = inputs; - const {blockShape, crops} = attrs; - - util.assert( - x.shape.length <= 4, - () => 'batchToSpaceND for rank > 4 with a WebGL backend not ' + - 'implemented yet'); - const prod = blockShape.reduce((a, b) => a * b); - - const reshaped = backend_util.getReshaped(x.shape, blockShape, prod); - const permuted = backend_util.getPermuted(reshaped.length, blockShape.length); - const reshapedPermuted = - backend_util.getReshapedPermuted(x.shape, blockShape, prod); - const sliceBeginCoords = - backend_util.getSliceBeginCoords(crops, blockShape.length); - const sliceSize = - backend_util.getSliceSize(reshapedPermuted, crops, blockShape.length); - - const toDispose = []; - - const reshapedIntermediate = - reshape({inputs: {x}, backend, attrs: {shape: reshaped}}); - const transposedIntermediate = transpose( - {inputs: {x: reshapedIntermediate}, backend, attrs: {perm: permuted}}); - const reshapedIntermediate2 = reshape({ - inputs: {x: transposedIntermediate}, - backend, - attrs: {shape: reshapedPermuted} - }); - const sliced = slice({ - inputs: {x: reshapedIntermediate2}, - backend, - attrs: {begin: sliceBeginCoords, size: sliceSize} - }); - - toDispose.push(reshapedIntermediate); - toDispose.push(transposedIntermediate); - toDispose.push(reshapedIntermediate2); - - toDispose.forEach(t => backend.disposeIntermediateTensorInfo(t)); - - return sliced; -}; - -export const batchToSpaceNDConfig: KernelConfig = { - kernelName: BatchToSpaceND, - backendName: 'webgl', - kernelFunc: batchToSpaceND as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Bincount.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Bincount.ts deleted file mode 100644 index d5c8620d6..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Bincount.ts +++ /dev/null @@ -1,45 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Bincount, BincountAttrs, BincountInputs, KernelConfig, KernelFunc, TensorInfo, TypedArray} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {bincountImplCPU} from '../kernel_utils/shared'; - -export function bincount(args: { - inputs: BincountInputs, - backend: MathBackendWebGL, - attrs: BincountAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {x, weights} = inputs; - const {size} = attrs; - - const xVals = backend.readSync(x.dataId) as TypedArray; - const weightsVals = backend.readSync(weights.dataId) as TypedArray; - - const outVals = - bincountImplCPU(xVals, weightsVals, weights.dtype, weights.shape, size); - - return backend.makeTensorInfo([size], weights.dtype, outVals); -} - -export const bincountConfig: KernelConfig = { - kernelName: Bincount, - backendName: 'webgl', - kernelFunc: bincount as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/BitwiseAnd.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/BitwiseAnd.ts deleted file mode 100644 index 0c72abeb2..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/BitwiseAnd.ts +++ /dev/null @@ -1,73 +0,0 @@ -/** - * @license - * Copyright 2023 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {BitwiseAnd, BitwiseAndInputs, env, KernelConfig, KernelFunc, TensorInfo, TypedArray} from '@tensorflow/tfjs-core'; -import {MathBackendWebGL} from '../backend_webgl'; -import {BinaryOpProgram} from '../binaryop_gpu'; -import {BinaryOpPackedProgram} from '../binaryop_packed_gpu'; -import {bitwiseAndImplCPU as cpuBitwiseAnd} from '../kernel_utils/shared'; - -export const BITWISEAND = ` - int r = int(a.r) & int(b.r); - int g = int(a.g) & int(b.g); - int rb = int(a.b) & int(b.b); - int ra = int(a.a) & int(b.a); - return vec4(r, g, rb, ra); -`; - -export const BITWISEAND_UNPACKED = ` - return float(int(a.r) & int(b.r)); -`; - -export function bitwiseAnd(args: { - inputs: BitwiseAndInputs, - backend: MathBackendWebGL, -}): TensorInfo { - const {inputs, backend} = args; - const {a, b} = inputs; - const shouldUsePackedProgram = env().getBool('WEBGL_PACK_BINARY_OPERATIONS'); - const versionNumber = env().getNumber('WEBGL_VERSION'); - - // The type of a and b are ensured to be `int32` in core, therefore no need to - // consider other type situations. - if ((backend.shouldExecuteOnCPU([a, b])) || versionNumber === 1) { - const aVals = backend.texData.get(a.dataId).values as TypedArray; - const bVals = backend.texData.get(b.dataId).values as TypedArray; - const [outValues, outShape] = - cpuBitwiseAnd(a.shape, b.shape, aVals, bVals, a.dtype); - - const out = backend.makeTensorInfo(outShape, a.dtype); - const outData = backend.texData.get(out.dataId); - outData.values = outValues; - return out; - } - - let program: BinaryOpProgram|BinaryOpPackedProgram; - if (shouldUsePackedProgram) { - program = new BinaryOpPackedProgram(BITWISEAND, a.shape, b.shape, false); - } else { - program = new BinaryOpProgram(BITWISEAND_UNPACKED, a.shape, b.shape); - } - - return backend.runWebGLProgram(program, [a, b], a.dtype); -} - -export const bitwiseAndConfig: KernelConfig = { - kernelName: BitwiseAnd, - backendName: 'webgl', - kernelFunc: bitwiseAnd as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/BroadcastArgs.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/BroadcastArgs.ts deleted file mode 100644 index 025555d47..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/BroadcastArgs.ts +++ /dev/null @@ -1,42 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, BroadcastArgs, BroadcastArgsInputs, KernelConfig, TensorInfo, TypedArray} from '@tensorflow/tfjs-core'; -import {MathBackendWebGL} from '../backend_webgl'; - -export function broadcastArgs(args: { - inputs: BroadcastArgsInputs, - backend: MathBackendWebGL, -}): TensorInfo { - const {inputs, backend} = args; - const {s0, s1} = inputs; - - const s0Vals = backend.readSync(s0.dataId) as TypedArray; - const s1Vals = backend.readSync(s1.dataId) as TypedArray; - - const broadcastShape = backend_util.assertAndGetBroadcastShape( - Array.from(s0Vals), Array.from(s1Vals)); - - return backend.makeTensorInfo( - [broadcastShape.length], 'int32', Int32Array.from(broadcastShape)); -} - -export const broadcastArgsConfig: KernelConfig = { - kernelName: BroadcastArgs, - backendName: 'webgl', - kernelFunc: broadcastArgs -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Cast.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Cast.ts deleted file mode 100644 index 8a6da6406..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Cast.ts +++ /dev/null @@ -1,99 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import * as tf from '@tensorflow/tfjs-core'; -import {BinaryInputs, Cast, CastAttrs, CastInputs, KernelConfig, KernelFunc, TensorInfo, TypedArray, util} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {castImplCPU} from '../kernel_utils/shared'; -import {complex} from './Complex'; -import {identity} from './Identity'; -import {notEqual} from './NotEqual'; -import {real} from './Real'; - -import {int} from '../kernel_utils/int'; - -export function cast( - args: {inputs: CastInputs, backend: MathBackendWebGL, attrs: CastAttrs}): - TensorInfo { - const {inputs, backend, attrs} = args; - const {x} = inputs; - const {dtype} = attrs; - - // Casting to complex64. - if (dtype === 'complex64') { - if (x.dtype === 'complex64') { - return identity({inputs: {x}, backend}); - } - - // TODO(annxingyuan): Import kernel function once zeros is modularized. - const zerosTensor = tf.zeros(x.shape); - const floatX = cast({inputs: {x}, backend, attrs: {dtype: 'float32'}}); - - const result = - complex({inputs: {real: floatX, imag: zerosTensor}, backend}); - - zerosTensor.dispose(); - backend.disposeIntermediateTensorInfo(floatX); - - return result; - } - - // Casting from complex64 - if (x.dtype === 'complex64') { - const realPart = real({inputs: {input: x}, backend}); - const result = cast({inputs: {x: realPart}, backend, attrs: {dtype}}); - backend.disposeIntermediateTensorInfo(realPart); - return result; - } - - if (!util.hasEncodingLoss(x.dtype, dtype)) { - // We don't change the underlying data, since we cast to higher - // precision. - const result = identity({inputs: {x}, backend}); - return {dataId: result.dataId, shape: result.shape, dtype}; - } - - if (backend.shouldExecuteOnCPU([x])) { - const values = backend.texData.get(x.dataId).values as TypedArray; - const [resultShape, resultType, resultData] = - castImplCPU(values, x.shape, x.dtype, dtype); - return backend.makeTensorInfo(resultShape, resultType, resultData); - } - - if (dtype === 'int32') { - return int(x, backend); - } - - if (dtype === 'bool') { - const zerosTensorInfo = backend.makeTensorInfo( - [], 'bool', util.getTypedArrayFromDType('bool', 1)); - - const binaryInputs: BinaryInputs = {a: x, b: zerosTensorInfo}; - - const result = notEqual({inputs: binaryInputs, backend}) as TensorInfo; - backend.disposeIntermediateTensorInfo(zerosTensorInfo); - return result; - } - - throw new Error(`Error in Cast: failed to cast ${x.dtype} to ${dtype}`); -} - -export const castConfig: KernelConfig = { - kernelName: Cast, - backendName: 'webgl', - kernelFunc: cast as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Ceil.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Ceil.ts deleted file mode 100644 index 22bc06655..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Ceil.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Ceil, KernelConfig, KernelFunc} from '@tensorflow/tfjs-core'; -import {unaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; -import {ceilImplCPU} from '../kernel_utils/shared'; - -const CEIL = `return ceil(x);`; - -export const ceil = unaryKernelFunc( - {opSnippet: CEIL, packedOpSnippet: CEIL, cpuKernelImpl: ceilImplCPU}); - -export const ceilConfig: KernelConfig = { - kernelName: Ceil, - backendName: 'webgl', - kernelFunc: ceil as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/ClipByValue.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/ClipByValue.ts deleted file mode 100644 index 7fb789fdf..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/ClipByValue.ts +++ /dev/null @@ -1,47 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ClipByValue, ClipByValueAttrs, ClipByValueInputs, env, KernelConfig, KernelFunc, TensorInfo} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {ClipProgram} from '../clip_gpu'; -import {ClipPackedProgram} from '../clip_packed_gpu'; - -export function clipByValue(args: { - inputs: ClipByValueInputs, - backend: MathBackendWebGL, - attrs: ClipByValueAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {x} = inputs; - const {clipValueMin, clipValueMax} = attrs; - - let program; - if (env().getBool('WEBGL_PACK_CLIP')) { - program = new ClipPackedProgram(x.shape); - } else { - program = new ClipProgram(x.shape); - } - const customValues = [[clipValueMin], [clipValueMax]]; - return backend.runWebGLProgram(program, [x], x.dtype, customValues); -} - -export const clipByValueConfig: KernelConfig = { - kernelName: ClipByValue, - backendName: 'webgl', - kernelFunc: clipByValue as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Complex.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Complex.ts deleted file mode 100644 index 2900d6670..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Complex.ts +++ /dev/null @@ -1,53 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Complex, ComplexInputs, KernelConfig, KernelFunc, TensorInfo} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {identity} from './Identity'; - -/** - * In WebGL data is stored in GPU textures which can't be efficiently copied, so - * complex tensors share data with their real and imaginary components. Complex - * tensors' reference to the components is tracked by refCount on the individual - * component. The refCounts are increased by the identity call. - * - * When a complex tensor is disposed, it will reduce the refCount on the - * components by calling disposeData on each. - */ -export function complex( - args: {inputs: ComplexInputs, backend: MathBackendWebGL}): TensorInfo { - const {inputs, backend} = args; - const {real, imag} = inputs; - - const complexInfo = backend.makeTensorInfo(real.shape, 'complex64'); - const complex = backend.texData.get(complexInfo.dataId); - - const realTensorInfo = identity({inputs: {x: real}, backend}); - - const imagTensorInfo = identity({inputs: {x: imag}, backend}); - - complex.complexTensorInfos = {real: realTensorInfo, imag: imagTensorInfo}; - - return complexInfo; -} - -export const complexConfig: KernelConfig = { - kernelName: Complex, - backendName: 'webgl', - kernelFunc: complex as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/ComplexAbs.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/ComplexAbs.ts deleted file mode 100644 index 999a36017..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/ComplexAbs.ts +++ /dev/null @@ -1,56 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ComplexAbs, ComplexAbsInputs, KernelConfig, KernelFunc, TensorInfo} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {ComplexAbsProgram} from '../complex_abs_gpu'; - -// Returns a TensorInfo with the complex shape and the dataId of the -// underlying part. We need to do this because a reshaped complex tensor is -// not reflected in its parts. -function makeComplexComponentTensorInfo( - complexTensor: TensorInfo, complexPart: TensorInfo): TensorInfo { - return { - dataId: complexPart.dataId, - dtype: complexPart.dtype, - shape: complexTensor.shape - }; -} - -export function complexAbs( - args: {inputs: ComplexAbsInputs, backend: MathBackendWebGL}): TensorInfo { - const {inputs, backend} = args; - const {x} = inputs; - - const xData = backend.texData.get(x.dataId); - - const program = new ComplexAbsProgram(x.shape); - const programInputs = [ - makeComplexComponentTensorInfo(x, xData.complexTensorInfos.real), - makeComplexComponentTensorInfo(x, xData.complexTensorInfos.imag), - ]; - - return backend.runWebGLProgram( - program, programInputs, programInputs[0].dtype); -} - -export const complexAbsConfig: KernelConfig = { - kernelName: ComplexAbs, - backendName: 'webgl', - kernelFunc: complexAbs as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Complex_test.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Complex_test.ts deleted file mode 100644 index 4fbc5dc1f..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Complex_test.ts +++ /dev/null @@ -1,352 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '@tensorflow/tfjs-core'; -import {test_util} from '@tensorflow/tfjs-core'; - -const {expectArraysClose} = test_util; -// tslint:disable-next-line: no-imports-from-dist -import {describeWithFlags, ALL_ENVS} from '@tensorflow/tfjs-core/dist/jasmine_util'; -import {WebGLMemoryInfo} from '../backend_webgl'; - -const BYTES_PER_COMPLEX_ELEMENT = 4 * 2; -describeWithFlags('complex64 memory', ALL_ENVS, () => { - it('usage', async () => { - const webglSizeUploadUniformFlagSaved = - tf.env().get('WEBGL_SIZE_UPLOAD_UNIFORM'); - tf.env().set('WEBGL_SIZE_UPLOAD_UNIFORM', 4); - - let numTensors = tf.memory().numTensors; - let numBytes = tf.memory().numBytes; - let numDataIds = tf.engine().backend.numDataIds(); - - const startTensors = numTensors; - const startNumBytes = numBytes; - const startNumBytesInGPU = (tf.memory() as WebGLMemoryInfo).numBytesInGPU; - const startDataIds = numDataIds; - - const real1 = tf.tensor1d([1]); - const imag1 = tf.tensor1d([2]); - - // 2 new Tensors: real1, imag1, and two data buckets created. - expect(tf.memory().numTensors).toBe(numTensors + 2); - expect(tf.memory().numBytes).toBe(numBytes + BYTES_PER_COMPLEX_ELEMENT); - expect(tf.engine().backend.numDataIds()).toBe(numDataIds + 2); - numTensors = tf.memory().numTensors; - numBytes = tf.memory().numBytes; - numDataIds = tf.engine().backend.numDataIds(); - - const complex1 = tf.complex(real1, imag1); - - // 1 new complex Tensor and 1 new data bucket created. No new bytes - // allocated. - expect(tf.memory().numTensors).toBe(numTensors + 1); - expect(tf.memory().numBytes).toBe(numBytes); - expect(tf.engine().backend.numDataIds()).toBe(numDataIds + 1); - - numTensors = tf.memory().numTensors; - numBytes = tf.memory().numBytes; - numDataIds = tf.engine().backend.numDataIds(); - - const real2 = tf.tensor1d([3]); - const imag2 = tf.tensor1d([4]); - - // 2 new Tensors: real2, imag2, and 2 new data buckets. - expect(tf.memory().numTensors).toBe(numTensors + 2); - expect(tf.memory().numBytes).toBe(numBytes + BYTES_PER_COMPLEX_ELEMENT); - expect(tf.engine().backend.numDataIds()).toBe(numDataIds + 2); - numTensors = tf.memory().numTensors; - numBytes = tf.memory().numBytes; - numDataIds = tf.engine().backend.numDataIds(); - - const complex2 = tf.complex(real2, imag2); - - // 1 new Tensor and 1 new data bucket. - expect(tf.memory().numTensors).toBe(numTensors + 1); - // numBytes stays the same because it is determined by tensor creation at - // the engine level, and we do not increment memory for complex tensors - // (complex tensors track their own memory). - expect(tf.memory().numBytes).toBe(numBytes); - expect(tf.engine().backend.numDataIds()).toBe(numDataIds + 1); - - numTensors = tf.memory().numTensors; - numBytes = tf.memory().numBytes; - numDataIds = tf.engine().backend.numDataIds(); - - const result = complex1.add(complex2); - - // A complex tensor is created, which is composed of real and imag parts. - // They should not increase tensor count, only complex tensor does. - // 3 new data buckets created for complex, real and imag. - expect(tf.memory().numTensors).toBe(numTensors + 1); - expect(tf.memory().numBytes).toBe(numBytes); - expect(tf.engine().backend.numDataIds()).toBe(numDataIds + 3); - // Two new 1x1 textures are created to compute the sum of real / imag - // components, respectively. No new textures are allocated for the inputs - // because they are beneath the uniform upload threshold. - expect((tf.memory() as WebGLMemoryInfo).numBytesInGPU) - .toBe(startNumBytesInGPU + BYTES_PER_COMPLEX_ELEMENT); - numTensors = tf.memory().numTensors; - numDataIds = tf.engine().backend.numDataIds(); - - expect(result.dtype).toBe('complex64'); - expect(result.shape).toEqual([1]); - expectArraysClose(await result.data(), [4, 6]); - - const real = tf.real(result); - - // A new tensor is created. No new data buckets created. - expect(tf.memory().numTensors).toBe(numTensors + 1); - expect(tf.memory().numBytes).toBe(numBytes + 4); - expect(tf.engine().backend.numDataIds()).toBe(numDataIds); - numTensors = tf.memory().numTensors; - numBytes = tf.memory().numBytes; - numDataIds = tf.engine().backend.numDataIds(); - - expectArraysClose(await real.data(), [4]); - - const imag = tf.imag(result); - - // A new tensor is created. No new data buckets created. - expect(tf.memory().numTensors).toBe(numTensors + 1); - expect(tf.memory().numBytes).toBe(numBytes + 4); - expect(tf.engine().backend.numDataIds()).toBe(numDataIds); - - expectArraysClose(await imag.data(), [6]); - - // After disposing, there should be no tensors. - real1.dispose(); - imag1.dispose(); - real2.dispose(); - imag2.dispose(); - complex1.dispose(); - complex2.dispose(); - result.dispose(); - real.dispose(); - imag.dispose(); - expect(tf.memory().numTensors).toBe(startTensors); - expect(tf.memory().numBytes).toBe(startNumBytes); - expect(tf.engine().backend.numDataIds()).toBe(startDataIds); - expect((tf.memory() as WebGLMemoryInfo).numBytesInGPU) - .toBe(startNumBytesInGPU); - - tf.env().set('WEBGL_SIZE_UPLOAD_UNIFORM', webglSizeUploadUniformFlagSaved); - }); - - it('Creating tf.real, tf.imag from complex.', async () => { - let numTensors = tf.memory().numTensors; - let numDataIds = tf.engine().backend.numDataIds(); - - const startTensors = numTensors; - const startDataIds = numDataIds; - - const complex = tf.complex([3, 30], [4, 40]); - - // 1 new tensor, 3 new data buckets. - expect(tf.memory().numTensors).toBe(numTensors + 1); - expect(tf.engine().backend.numDataIds()).toBe(numDataIds + 3); - numTensors = tf.memory().numTensors; - numDataIds = tf.engine().backend.numDataIds(); - - const real = tf.real(complex); - const imag = tf.imag(complex); - - // 2 new tensors, no new data buckets. - expect(tf.memory().numTensors).toBe(numTensors + 2); - expect(tf.engine().backend.numDataIds()).toBe(numDataIds); - - numTensors = tf.memory().numTensors; - numDataIds = tf.engine().backend.numDataIds(); - - complex.dispose(); - - // 1 fewer tensor, 1 fewer data buckets. - expect(tf.memory().numTensors).toBe(numTensors - 1); - expect(tf.engine().backend.numDataIds()).toBe(numDataIds - 1); - expectArraysClose(await real.data(), [3, 30]); - expectArraysClose(await imag.data(), [4, 40]); - - numTensors = tf.memory().numTensors; - numDataIds = tf.engine().backend.numDataIds(); - - real.dispose(); - imag.dispose(); - - // Zero net tensors / data buckets. - expect(tf.memory().numTensors).toBe(startTensors); - expect(tf.engine().backend.numDataIds()).toBe(startDataIds); - }); - - it('tf.complex disposing underlying tensors', async () => { - const numTensors = tf.memory().numTensors; - const numDataIds = tf.engine().backend.numDataIds(); - - const real = tf.tensor1d([3, 30]); - const imag = tf.tensor1d([4, 40]); - expect(tf.memory().numTensors).toEqual(numTensors + 2); - expect(tf.engine().backend.numDataIds()).toEqual(numDataIds + 2); - - const complex = tf.complex(real, imag); - - // 1 new tensor is created for complex. real and imag data buckets created. - expect(tf.memory().numTensors).toEqual(numTensors + 3); - expect(tf.engine().backend.numDataIds()).toEqual(numDataIds + 3); - - real.dispose(); - imag.dispose(); - - expect(tf.memory().numTensors).toEqual(numTensors + 1); - expect(tf.engine().backend.numDataIds()).toEqual(numDataIds + 3); - - expect(complex.dtype).toBe('complex64'); - expect(complex.shape).toEqual(real.shape); - expectArraysClose(await complex.data(), [3, 4, 30, 40]); - - complex.dispose(); - - expect(tf.memory().numTensors).toEqual(numTensors); - expect(tf.engine().backend.numDataIds()).toEqual(numDataIds); - }); - - it('reshape', async () => { - const memoryBefore = tf.memory(); - const numDataIdsBefore = tf.engine().backend.numDataIds(); - let numTensors = memoryBefore.numTensors; - let numDataIds = numDataIdsBefore; - - const a = tf.complex([[1, 3, 5], [7, 9, 11]], [[2, 4, 6], [8, 10, 12]]); - - // 1 new tensor, the complex64 tensor - expect(tf.memory().numTensors).toBe(memoryBefore.numTensors + 1); - // 1 new tensor and 2 underlying data buckets for real and imag. - expect(tf.engine().backend.numDataIds()).toBe(numDataIdsBefore + 3); - numTensors = tf.memory().numTensors; - numDataIds = tf.engine().backend.numDataIds(); - - const b = a.reshape([6]); - // 1 new tensor from the reshape. - expect(tf.memory().numTensors).toBe(numTensors + 1); - // No new data buckets. - expect(tf.engine().backend.numDataIds()).toBe(numDataIds); - - expect(b.dtype).toBe('complex64'); - expect(b.shape).toEqual([6]); - expectArraysClose(await a.data(), await b.data()); - - b.dispose(); - // 1 complex tensor should be disposed. - expect(tf.memory().numTensors).toBe(numTensors); - // Data buckets not deleted yet. - expect(tf.engine().backend.numDataIds()).toBe(numDataIds); - - a.dispose(); - // All the tensors should now be disposed. - expect(tf.memory().numTensors).toBe(memoryBefore.numTensors); - // The underlying memory should now be released. - expect(tf.engine().backend.numDataIds()).toBe(numDataIdsBefore); - }); - - it('clone', async () => { - const memoryBefore = tf.memory(); - const numDataIdsBefore = tf.engine().backend.numDataIds(); - - const a = tf.complex([[1, 3, 5], [7, 9, 11]], [[2, 4, 6], [8, 10, 12]]); - - // 1 new tensor, the complex64 tensor - expect(tf.memory().numTensors).toBe(memoryBefore.numTensors + 1); - // 1 new tensor and 2 underlying data buckets for real and imag. - expect(tf.engine().backend.numDataIds()).toBe(numDataIdsBefore + 3); - - const b = a.clone(); - - // 1 new tensor from the clone. - expect(tf.memory().numTensors).toBe(memoryBefore.numTensors + 2); - // No new data buckets. - expect(tf.engine().backend.numDataIds()).toBe(numDataIdsBefore + 3); - - expect(b.dtype).toBe('complex64'); - expectArraysClose(await a.data(), await b.data()); - - b.dispose(); - - // 1 complex tensor should be disposed. - expect(tf.memory().numTensors).toBe(memoryBefore.numTensors + 1); - // Data bucket not deleted yet. - expect(tf.engine().backend.numDataIds()).toBe(numDataIdsBefore + 3); - - a.dispose(); - - // All the tensors should now be disposed. - expect(tf.memory().numTensors).toBe(memoryBefore.numTensors); - expect(tf.engine().backend.numDataIds()).toBe(numDataIdsBefore); - }); - - it('Multiple complex tensors sharing same underlying components works', - async () => { - const numTensors = tf.memory().numTensors; - const numDataIds = tf.engine().backend.numDataIds(); - - const real = tf.tensor1d([1]); - const imag = tf.tensor1d([2]); - - expect(tf.memory().numTensors).toEqual(numTensors + 2); - expect(tf.engine().backend.numDataIds()).toEqual(numDataIds + 2); - - const complex1 = tf.complex(real, imag); - const complex2 = tf.complex(real, imag); - - expect(tf.memory().numTensors).toEqual(numTensors + 4); - expect(tf.engine().backend.numDataIds()).toEqual(numDataIds + 4); - - real.dispose(); - expect(tf.memory().numTensors).toEqual(numTensors + 3); - expect(tf.engine().backend.numDataIds()).toEqual(numDataIds + 4); - - complex1.dispose(); - expect(tf.memory().numTensors).toEqual(numTensors + 2); - expect(tf.engine().backend.numDataIds()).toEqual(numDataIds + 3); - - expectArraysClose(await complex2.data(), [1, 2]); - }); - - it('tidy should not have mem leak', async () => { - const numTensors = tf.memory().numTensors; - const numDataIds = tf.engine().backend.numDataIds(); - const complex = tf.tidy(() => { - const real = tf.tensor1d([3, 30]); - const realReshape = tf.reshape(real, [2]); - const imag = tf.tensor1d([4, 40]); - const imagReshape = tf.reshape(imag, [2]); - expect(tf.memory().numTensors).toEqual(numTensors + 4); - expect(tf.engine().backend.numDataIds()).toEqual(numDataIds + 2); - - const complex = tf.complex(realReshape, imagReshape); - - // 1 new tensor is created for complex. real and imag data buckets - // created. - expect(tf.memory().numTensors).toEqual(numTensors + 5); - expect(tf.engine().backend.numDataIds()).toEqual(numDataIds + 3); - - return complex; - }); - - complex.dispose(); - - expect(tf.memory().numTensors).toEqual(numTensors); - expect(tf.engine().backend.numDataIds()).toEqual(numDataIds); - }); -}); diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Concat.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Concat.ts deleted file mode 100644 index 04ee49e82..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Concat.ts +++ /dev/null @@ -1,56 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, Concat, ConcatAttrs, ConcatInputs, KernelConfig, KernelFunc, TensorInfo, util} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {concatImpl} from './Concat_impl'; -import {identity} from './Identity'; - -export function concat( - args: - {inputs: ConcatInputs, attrs: ConcatAttrs, backend: MathBackendWebGL}): - TensorInfo { - const {inputs, backend, attrs} = args; - const {axis} = attrs; - - const $axis = util.parseAxisParam(axis, inputs[0].shape)[0]; - - const shapes = inputs.map(t => t.shape); - backend_util.assertParamsConsistent(shapes, $axis); - - const outShape = - backend_util.computeOutShape(inputs.map(t => t.shape), $axis); - - if (util.sizeFromShape(outShape) === 0) { - return backend.makeTensorInfo(outShape, inputs[0].dtype, []); - } - - // Keep only non-empty tensors (ignore tensors with 0 in their shape). - const $inputs = inputs.filter(t => util.sizeFromShape(t.shape) > 0); - if ($inputs.length === 1) { - return identity({inputs: {x: $inputs[0]}, backend}); - } - - return concatImpl($inputs, $axis, backend); -} - -export const concatConfig: KernelConfig = { - kernelName: Concat, - backendName: 'webgl', - kernelFunc: concat as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Concat_impl.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Concat_impl.ts deleted file mode 100644 index 33ef86e8b..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Concat_impl.ts +++ /dev/null @@ -1,166 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, ConcatInputs, env, TensorInfo, util} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {ConcatProgram} from '../concat_gpu'; -import {ConcatPackedProgram} from '../concat_packed_gpu'; -import {concatImplCPU} from '../kernel_utils/shared'; -import {CLONE, UnaryOpProgram} from '../unaryop_gpu'; -import {UnaryOpPackedProgram} from '../unaryop_packed_gpu'; - -import {complex} from './Complex'; -import {imag} from './Imag'; -import {real} from './Real'; -import {reshape} from './Reshape'; - -export function concatImpl( - inputs: ConcatInputs, axis: number, backend: MathBackendWebGL): TensorInfo { - const dtype = inputs[0].dtype; - if (dtype === 'complex64') { - const reals = inputs.map((t) => real({inputs: {input: t}, backend})); - const imags = inputs.map((t) => imag({inputs: {input: t}, backend})); - - const realConcated = concatImpl(reals, axis, backend); - const imagConcated = concatImpl(imags, axis, backend); - - const result = - complex({inputs: {real: realConcated, imag: imagConcated}, backend}); - - reals.forEach(r => backend.disposeIntermediateTensorInfo(r)); - imags.forEach(i => backend.disposeIntermediateTensorInfo(i)); - backend.disposeIntermediateTensorInfo(realConcated); - backend.disposeIntermediateTensorInfo(imagConcated); - - return result; - } - - let runOnCpu = backend.shouldExecuteOnCPU(inputs); - - // Run on cpu if dtype is string. For string, the backend represents it - // as Uint8Array[], where each Uint8Array is a character. Given that the - // computation is only on the outer array, uploading the whole data onto - // gpu is wasteful. Also, currently webgl doesn't have a design to - // upload and retrieve Uint8Array[] between cpu and gpu. Therefore, we - // just run the kernel on cpu if dtype is string. - if (dtype === 'string') { - runOnCpu = true; - } - - if (runOnCpu) { - // Any concat of n-dimensional tensors across any axis can be reduced to - // a concatenation of two-dimensional tensors across the axis 1 by first - // partitioning the axes of the original tensors into those less than the - // axis to be concatenated and the rest. Then reshape the tensors - // into a two-dimensional tensor by collapsing these two sets of axes and - // concatenate the resulting matrices across the axis 1, finally reshaping - // the result to have the proper shape. - const tensors2D = inputs.map(t => { - const innerSize = util.sizeFromShape(t.shape.slice(axis)); - const shape = [-1, innerSize]; - return reshape({inputs: {x: t}, backend, attrs: {shape}}); - }); - - const inputsValShapes = tensors2D.map(t => { - return {vals: backend.readSync(t.dataId), shape: t.shape}; - }); - - // Concats 2d tensors along axis=1. - const outShape = - backend_util.computeOutShape(tensors2D.map(t => t.shape), 1 /* axis */); - const simplyConcat = tensors2D[0].shape[0] === 1; - const outVals = - concatImplCPU(inputsValShapes, outShape, dtype, simplyConcat); - - const finalOutShape = - backend_util.computeOutShape(inputs.map(t => t.shape), axis); - - const outInfo = backend.makeTensorInfo(finalOutShape, dtype, outVals); - - tensors2D.forEach(t => backend.disposeIntermediateTensorInfo(t)); - - return outInfo; - } - - // Keep only non-empty tensors (ignore tensors with 0 in their shape). - const $inputs = inputs.filter(t => util.sizeFromShape(t.shape) > 0); - - const shouldPack: boolean = env().getBool('WEBGL_PACK_ARRAY_OPERATIONS') && - $inputs[0].shape.length > 1; - - if ($inputs.length === 1) { - // Clone tensor. - const program = shouldPack ? - new UnaryOpProgram(inputs[0].shape, CLONE) : - new UnaryOpPackedProgram(inputs[0].shape, CLONE); - return backend.runWebGLProgram(program, inputs, dtype); - } - - const maxTexturesInShader = env().getNumber('WEBGL_MAX_TEXTURES_IN_SHADER'); - if ($inputs.length > maxTexturesInShader) { - const reducedInputs = []; - for (let i = 0; i < $inputs.length; i += maxTexturesInShader) { - const subArray = $inputs.slice(i, i + maxTexturesInShader); - reducedInputs.push(concatImpl(subArray, axis, backend)); - } - const result = concatImpl(reducedInputs, axis, backend); - - for (const i of reducedInputs) { - backend.disposeIntermediateTensorInfo(i); - } - - return result; - } - - if (shouldPack) { - const program = new ConcatPackedProgram($inputs.map(t => t.shape), axis); - return backend.runWebGLProgram(program, $inputs, dtype); - } - - const {tensors2D, outShape} = computeTensors2D($inputs, axis, backend); - const program = - new ConcatProgram(tensors2D.map(t => t.shape as [number, number])); - const result = backend.runWebGLProgram(program, tensors2D, dtype); - - tensors2D.forEach(r => backend.disposeIntermediateTensorInfo(r)); - const reshapedResult = - reshape({inputs: {x: result}, attrs: {shape: outShape}, backend}); - backend.disposeIntermediateTensorInfo(result); - - return reshapedResult; -} - -function computeTensors2D( - inputs: ConcatInputs, axis: number, backend: MathBackendWebGL) { - // Any concat of n-dimensional tensors across any axis can be reduced to - // a concatenation of two-dimensional tensors across the axis 1 by first - // partitioning the axes of the original tensors into those less than the - // axis to be concatenated and the rest. Then reshape the tensors - // into a two-dimensional tensor by collapsing these two sets of axes and - // concatenate the resulting matrices across the axis 1, finally reshaping - // the result to have the proper shape. - const outShape = backend_util.computeOutShape(inputs.map(t => t.shape), axis); - const tensors2D = inputs.map( - x => reshape({ - inputs: {x}, - attrs: {shape: [-1, util.sizeFromShape(x.shape.slice(axis))]}, - backend - })); - - return {tensors2D, outShape}; -} diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Concat_test.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Concat_test.ts deleted file mode 100644 index 41f621b55..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Concat_test.ts +++ /dev/null @@ -1,40 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '@tensorflow/tfjs-core'; -// tslint:disable-next-line: no-imports-from-dist -import {describeWithFlags} from '@tensorflow/tfjs-core/dist/jasmine_util'; -import {expectArraysClose} from '@tensorflow/tfjs-core/test_util'; - -import {WEBGL_ENVS} from '../backend_webgl_test_registry'; - -describeWithFlags('Concat', WEBGL_ENVS, () => { - it('Works if input size is larger than WEBGL_MAX_TEXTURES_IN_SHADER', - async () => { - const x1 = tf.tensor3d([1, 2, 3, 4], [2, 2, 1]); - const tensorNum = tf.env().getNumber('WEBGL_MAX_TEXTURES_IN_SHADER') + 1; - const input = []; - const expected = []; - for (let i = 0; i < tensorNum; i++) { - input.push(x1); - expected.push(1, 2, 3, 4); - } - const values = tf.concat(input, 0); - expect(values.shape).toEqual([tensorNum * 2, 2, 1]); - expectArraysClose(await values.data(), expected); - }); -}); diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Conv2D.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Conv2D.ts deleted file mode 100644 index ff7b467b9..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Conv2D.ts +++ /dev/null @@ -1,75 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, Conv2D, Conv2DAttrs, Conv2DInputs, env, KernelConfig, KernelFunc, TensorInfo} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {Conv2DProgram} from '../conv_gpu'; -import {Conv2DPackedProgram} from '../conv_packed_gpu'; -import {conv2dByMatMul, conv2dWithIm2Row} from './Conv2D_impl'; -import {reshape} from './Reshape'; - -export function conv2d( - args: - {inputs: Conv2DInputs, attrs: Conv2DAttrs, backend: MathBackendWebGL}) { - const {inputs, backend, attrs} = args; - const {x, filter} = inputs; - const {strides, pad, dataFormat, dilations, dimRoundingMode} = attrs; - - const $dataFormat = backend_util.convertConv2DDataFormat(dataFormat); - const convInfo = backend_util.computeConv2DInfo( - x.shape as [number, number, number, number], - filter.shape as [number, number, number, number], strides, dilations, pad, - dimRoundingMode, false /* depthwise */, $dataFormat); - let out: TensorInfo; - - if (convInfo.filterHeight === 1 && convInfo.filterWidth === 1 && - convInfo.dilationHeight === 1 && convInfo.dilationWidth === 1 && - convInfo.strideHeight === 1 && convInfo.strideWidth === 1 && - (convInfo.padInfo.type === 'SAME' || convInfo.padInfo.type === 'VALID')) { - out = conv2dByMatMul({x, filter, convInfo, backend}); - } else if (convInfo.strideWidth <= 2 && $dataFormat === 'channelsLast' - && env().getBool('WEBGL_EXP_CONV') - ) { - const program = new Conv2DPackedProgram(convInfo); - const customValues = [ - [convInfo.padInfo.top, convInfo.padInfo.left], - [convInfo.strideHeight, convInfo.strideWidth], - [convInfo.dilationHeight, convInfo.dilationWidth], - [convInfo.inHeight, convInfo.inWidth] - ]; - out = - backend.runWebGLProgram(program, [x, filter], 'float32', customValues); - } else if (env().getBool('WEBGL_CONV_IM2COL')) { - out = conv2dWithIm2Row({x, filter, convInfo, backend}); - } else { - const program = new Conv2DProgram(convInfo); - out = backend.runWebGLProgram(program, [x, filter], 'float32'); - } - - const outReshaped = - reshape({inputs: {x: out}, backend, attrs: {shape: convInfo.outShape}}); - backend.disposeIntermediateTensorInfo(out); - - return outReshaped; -} - -export const conv2DConfig: KernelConfig = { - kernelName: Conv2D, - backendName: 'webgl', - kernelFunc: conv2d as unknown as KernelFunc, -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Conv2DBackpropFilter.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Conv2DBackpropFilter.ts deleted file mode 100644 index de6878b9e..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Conv2DBackpropFilter.ts +++ /dev/null @@ -1,46 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, Conv2DBackpropFilter, Conv2DBackpropFilterAttrs, Conv2DBackpropFilterInputs, KernelConfig, KernelFunc} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {Conv2DDerFilterProgram} from '../conv_backprop_gpu'; - -export function conv2DBackpropFilter(args: { - inputs: Conv2DBackpropFilterInputs, - attrs: Conv2DBackpropFilterAttrs, - backend: MathBackendWebGL -}) { - const {inputs, backend, attrs} = args; - const {x, dy} = inputs; - const {strides, pad, dataFormat, dimRoundingMode, filterShape} = attrs; - - const $dataFormat = backend_util.convertConv2DDataFormat(dataFormat); - const convInfo = backend_util.computeConv2DInfo( - x.shape as [number, number, number, number], filterShape, strides, - 1 /* dilations */, pad, dimRoundingMode, false /* depthwise */, - $dataFormat); - - const program = new Conv2DDerFilterProgram(convInfo); - return backend.runWebGLProgram(program, [x, dy], 'float32'); -} - -export const conv2DBackpropFilterConfig: KernelConfig = { - kernelName: Conv2DBackpropFilter, - backendName: 'webgl', - kernelFunc: conv2DBackpropFilter as unknown as KernelFunc, -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Conv2DBackpropInput.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Conv2DBackpropInput.ts deleted file mode 100644 index e01cce7ff..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Conv2DBackpropInput.ts +++ /dev/null @@ -1,56 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, Conv2DBackpropInput, Conv2DBackpropInputAttrs, Conv2DBackpropInputInputs, env, KernelConfig, KernelFunc} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {Conv2DDerInputProgram} from '../conv_backprop_gpu'; -import {Conv2DDerInputPackedProgram} from '../conv_backprop_packed_gpu'; - -export function conv2DBackpropInput(args: { - inputs: Conv2DBackpropInputInputs, - attrs: Conv2DBackpropInputAttrs, - backend: MathBackendWebGL -}) { - const {inputs, backend, attrs} = args; - const {dy, filter} = inputs; - const {inputShape, strides, pad, dataFormat, dimRoundingMode} = attrs; - - const $dataFormat = backend_util.convertConv2DDataFormat(dataFormat); - const convInfo = backend_util.computeConv2DInfo( - inputShape, filter.shape as [number, number, number, number], strides, - 1 /* dilations */, pad, dimRoundingMode, false, $dataFormat); - - if (env().getBool('WEBGL_PACK_CONV2DTRANSPOSE') && - $dataFormat === 'channelsLast') { - const customValues = [ - [convInfo.strideHeight, convInfo.strideWidth], - ]; - const program = new Conv2DDerInputPackedProgram(convInfo); - return backend.runWebGLProgram( - program, [dy, filter], 'float32', customValues); - } else { - const program = new Conv2DDerInputProgram(convInfo); - return backend.runWebGLProgram(program, [dy, filter], 'float32'); - } -} - -export const conv2DBackpropInputConfig: KernelConfig = { - kernelName: Conv2DBackpropInput, - backendName: 'webgl', - kernelFunc: conv2DBackpropInput as unknown as KernelFunc, -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Conv2D_impl.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Conv2D_impl.ts deleted file mode 100644 index 3cc9c41f9..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Conv2D_impl.ts +++ /dev/null @@ -1,361 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, TensorInfo, util} from '@tensorflow/tfjs-core'; - -// import {assertAndGetBroadcastShape} from -// '../../../tfjs-core/src/ops/broadcast_util'; -import {MathBackendWebGL} from '../backend_webgl'; -import {Im2ColPackedProgram} from '../im2col_packed_gpu'; -import {mapActivationToShaderProgram} from '../kernel_utils/kernel_funcs_utils'; -import {MatMulPackedProgram} from '../mulmat_packed_gpu'; -import * as webgl_util from '../webgl_util'; - -import {batchMatMulImpl, MATMUL_SHARED_DIM_THRESHOLD} from './BatchMatMul_impl'; -import {identity} from './Identity'; -import {reshape} from './Reshape'; - -type Conv2DConfig = { - x: TensorInfo, - filter: TensorInfo, - convInfo: backend_util.Conv2DInfo, - backend: MathBackendWebGL, - bias?: TensorInfo, - preluActivationWeights?: TensorInfo, - leakyreluAlpha?: number, - activation?: backend_util.Activation -}; - -// Both conv2dByMatMul and conv2dWithIm2Row fuse height and width into one -// dimension to compute batchMatMul, so bias and activation weights are also -// supposed to fuse the two dimensions into one. -// -// This function computes the target shape for fusing height and width -// dimensions. Returning null means the shape is already compatible. -// -// Even though the bias is not supposed to be a 3-D or a 4-D (including -// batch) tensor and PReLU activiation weights is not supposed to be a 4-D -// tensor, we still need to support them, because we haven't disabled -// them for NHWC format. -// https://github.com/tensorflow/tfjs/blob/b53bd47e880367ae57493f0ea628abaf08db2d5d/tfjs-core/src/ops/fused/conv2d.ts#L181-L196 -function getShapeForBatchMatMul( - shape: number[], isChannelsLast: boolean): number[] { - const length = shape.length; - if (length >= 3) { - return isChannelsLast ? - [ - ...shape.slice(0, -3) /* batch */, - shape[length - 3] * shape[length - 2] /* height * width */, - shape[length - 1] /* channel */ - ] : - [ - ...shape.slice(0, -3) /* batch */, shape[length - 3] /* channel */, - shape[length - 2] * shape[length - 1] /* height * width */ - ]; - } else if (!isChannelsLast && length === 1 && shape[0] > 1) { - return [shape[0], 1]; - } else { - return null; - } -} - -// For 1x1 kernels that iterate through every point in the input, convolution -// can be expressed as matrix multiplication (without need for memory -// remapping). -export function conv2dByMatMul({ - x, - filter, - convInfo, - backend, - bias = null, - preluActivationWeights = null, - leakyreluAlpha = 0, - activation = null -}: Conv2DConfig) { - // Reshapes conv2D input to 2D tensors, uses matMul and then reshape the - // result from 2D to 4D. - const xShape = x.shape; - const xTexData = backend.texData.get(x.dataId); - const sharedMatMulDim = convInfo.inChannels; - const outerShapeX = xShape[0] * xShape[1] * xShape[2]; - const outerShapeFilter = convInfo.outChannels; - const isChannelsLast = convInfo.dataFormat === 'channelsLast'; - const transposeA = false; - const transposeB = false; - - let out: TensorInfo; - const intermediates: TensorInfo[] = []; - - if (preluActivationWeights != null) { - const targetShape = - getShapeForBatchMatMul(preluActivationWeights.shape, isChannelsLast); - if (targetShape != null) { - preluActivationWeights = reshape({ - inputs: {x: preluActivationWeights}, - backend, - attrs: {shape: targetShape} - }); - intermediates.push(preluActivationWeights); - } - } - - if (bias != null) { - const targetShape = getShapeForBatchMatMul(bias.shape, isChannelsLast); - if (targetShape != null) { - bias = reshape({inputs: {x: bias}, backend, attrs: {shape: targetShape}}); - intermediates.push(bias); - } - } - - // TODO: Once reduction ops are packed, batchMatMul will always be packed - // and we can remove this condition. - const batchMatMulWillBeUnpacked = - (outerShapeX === 1 || outerShapeFilter === 1) && - sharedMatMulDim > MATMUL_SHARED_DIM_THRESHOLD; - - // The algorithm in the if condition assumes (1) the output will be packed, - // (2) x is packed, (3) x isChannelsLast, (4) x's packed texture is already - // on GPU, (5) col is odd, (6) the width, height and inChannels are the same - // for xTexData.shape and xShape. - const canOptimize = !batchMatMulWillBeUnpacked && xTexData.isPacked && - isChannelsLast && xTexData.texture != null && xShape[2] % 2 !== 0 && - util.arraysEqual(xTexData.shape.slice(-3), xShape.slice(-3)); - - if (canOptimize) { - // We avoid expensive packed 2x2 reshape by padding col count to next, - // even number. When col is odd, the result of packed batchMatMul is - // the same (has the same texture layout and and values in the texture) as - // it is for next even col. We make the odd-cols tensor to look like - // even-cols tensor before the operation and, after the batchMatMul, - // fix the even-cols result to have odd number of cols. - const targetShape = xShape[0] * xShape[1] * (xShape[2] + 1); - const xReshaped: TensorInfo = { - dataId: x.dataId, - shape: [1, targetShape, convInfo.inChannels], - dtype: x.dtype - }; - // xTexData.shape gets referenced from GPGPUBinary.inShapeInfos. - // Decrementing col count, after batchMatMul->...->compileProgram leads to - // invalid col count within the reference in GPGPUBinary.inShapeInfos. - // Alternative fix would be to provide a copy to GPGPUBinary.inShapeInfos - // in compileProgram method, but that would affect compilation of all - // programs - instead, provide a copy here, with even col count, before - // calling batchMatMul->...->compileProgram and after that, the original - // xTexData.shape is restored. - const originalXTexDataShape = xTexData.shape; - xTexData.shape = xTexData.shape.slice(); - xTexData.shape[xTexData.shape.length - 2]++; - util.assert( - webgl_util.isReshapeFree(xTexData.shape, xReshaped.shape), - () => `packed reshape ${xTexData.shape} to ${ - xReshaped.shape} isn't free`); - const filterReshaped = reshape({ - inputs: {x: filter}, - backend, - attrs: {shape: [1, convInfo.inChannels, convInfo.outChannels]} - }); - intermediates.push(filterReshaped); - const pointwiseConv = batchMatMulImpl({ - a: xReshaped, - b: filterReshaped, - backend, - transposeA, - transposeB, - bias, - activation, - preluActivationWeights, - leakyreluAlpha - }); - - const pointwiseConvTexData = backend.texData.get(pointwiseConv.dataId); - util.assert( - pointwiseConvTexData.isPacked, - () => 'batchMatMul result is expected to be packed'); - // Restore the input shape to original. - xTexData.shape = originalXTexDataShape; - // Set the output shape - there is no need for expensive reshape as data - // layout is already correct. - pointwiseConvTexData.shape = convInfo.outShape; - - out = identity({inputs: {x: pointwiseConv}, backend}); - out.shape = convInfo.outShape; - - intermediates.push(pointwiseConv); - } else { - const numCols = convInfo.outHeight * convInfo.outWidth; - const xReshaped = reshape({ - inputs: {x}, - backend, - attrs: { - shape: isChannelsLast ? - [convInfo.batchSize, numCols, convInfo.inChannels] : - [convInfo.batchSize, convInfo.inChannels, numCols] - } - }); - const filterReshaped = reshape({ - inputs: {x: filter}, - backend, - attrs: {shape: [1, convInfo.inChannels, convInfo.outChannels]} - }); - const result = batchMatMulImpl({ - a: isChannelsLast ? xReshaped : filterReshaped, - b: isChannelsLast ? filterReshaped : xReshaped, - transposeA: !isChannelsLast, - transposeB, - backend, - bias, - activation, - preluActivationWeights, - leakyreluAlpha - }); - - out = reshape( - {inputs: {x: result}, backend, attrs: {shape: convInfo.outShape}}); - - intermediates.push(xReshaped); - intermediates.push(filterReshaped); - intermediates.push(result); - } - - for (const i of intermediates) { - backend.disposeIntermediateTensorInfo(i); - } - - return out; -} - -// Implements the im2row algorithm as outlined in "High Performance -// Convolutional Neural Networks for Document Processing" (Suvisoft, 2006) -export function conv2dWithIm2Row({ - x, - filter, - convInfo, - backend, - bias = null, - preluActivationWeights = null, - leakyreluAlpha = 0, - activation = null -}: Conv2DConfig) { - // Rearranges conv2d input so each block to be convolved over forms the - // column of a new matrix with shape [filterWidth * filterHeight * - // inChannels, outHeight * outWidth]. The filter is also rearranged so each - // output channel forms a row of a new matrix with shape [outChannels, - // filterWidth * filterHeight * inChannels]. The convolution is then - // computed by multiplying these matrices and reshaping the result. - const { - filterWidth, - filterHeight, - inChannels, - outWidth, - outHeight, - dataFormat - } = convInfo; - - const isChannelsLast = dataFormat === 'channelsLast'; - - const sharedDim = filterWidth * filterHeight * inChannels; - const numCols = outHeight * outWidth; - const x2ColShape = [convInfo.batchSize, sharedDim, numCols]; - const transposeA = true; - const transposeB = false; - - const intermediates: TensorInfo[] = []; - - if (preluActivationWeights != null) { - const targetShape = - getShapeForBatchMatMul(preluActivationWeights.shape, isChannelsLast); - if (targetShape != null) { - preluActivationWeights = reshape({ - inputs: {x: preluActivationWeights}, - backend, - attrs: {shape: targetShape} - }); - intermediates.push(preluActivationWeights); - } - } - - if (bias != null) { - const targetShape = getShapeForBatchMatMul(bias.shape, isChannelsLast); - if (targetShape != null) { - bias = reshape({inputs: {x: bias}, backend, attrs: {shape: targetShape}}); - intermediates.push(bias); - } - } - - const w2Row = reshape({ - inputs: {x: filter}, - backend, - attrs: {shape: [1, sharedDim, util.sizeFromShape(filter.shape) / sharedDim]} - }); - intermediates.push(w2Row); - - const im2ColProgram = new Im2ColPackedProgram(x2ColShape, convInfo); - const customValues = [ - x.shape, [convInfo.padInfo.top, convInfo.padInfo.left], - [convInfo.strideHeight, convInfo.strideWidth], - [convInfo.dilationHeight, convInfo.dilationWidth], [convInfo.inChannels], - [convInfo.filterWidth * convInfo.inChannels], [convInfo.outWidth] - ]; - const im2Col = - backend.runWebGLProgram(im2ColProgram, [x], 'float32', customValues); - const im2ColReshaped = - reshape({inputs: {x: im2Col}, backend, attrs: {shape: x2ColShape}}); - - intermediates.push(im2Col); - intermediates.push(im2ColReshaped); - - const hasBias = bias != null; - const hasPreluActivationWeights = preluActivationWeights != null; - const hasLeakyreluAlpha = activation === 'leakyrelu'; - const fusedActivation = - activation ? mapActivationToShaderProgram(activation, true) : null; - const matmulProgram = new MatMulPackedProgram( - isChannelsLast ? im2ColReshaped.shape as [number, number, number] : - w2Row.shape as [number, number, number], - isChannelsLast ? w2Row.shape as [number, number, number] : - im2ColReshaped.shape as [number, number, number], - isChannelsLast ? [convInfo.batchSize, numCols, convInfo.outChannels] : - [convInfo.batchSize, convInfo.outChannels, numCols], - transposeA, transposeB, hasBias, fusedActivation, - hasPreluActivationWeights, hasLeakyreluAlpha); - const inputs: TensorInfo[] = - isChannelsLast ? [im2ColReshaped, w2Row] : [w2Row, im2ColReshaped]; - if (bias) { - inputs.push(bias); - } - if (hasPreluActivationWeights) { - inputs.push(preluActivationWeights); - } - if (hasLeakyreluAlpha) { - const $leakyreluAlpha = backend.makeTensorInfo( - [], 'float32', - util.createScalarValue(leakyreluAlpha as unknown as 'float32', - 'float32')); - inputs.push($leakyreluAlpha); - intermediates.push($leakyreluAlpha); - } - const product = backend.runWebGLProgram(matmulProgram, inputs, 'float32'); - const out = reshape( - {inputs: {x: product}, backend, attrs: {shape: convInfo.outShape}}); - - intermediates.push(product); - for (const i of intermediates) { - backend.disposeIntermediateTensorInfo(i); - } - - return out; -} diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Conv2D_test.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Conv2D_test.ts deleted file mode 100644 index 9c816a30c..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Conv2D_test.ts +++ /dev/null @@ -1,111 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '@tensorflow/tfjs-core'; -import {test_util} from '@tensorflow/tfjs-core'; -// tslint:disable-next-line: no-imports-from-dist -import {ALL_ENVS, describeWithFlags} from '@tensorflow/tfjs-core/dist/jasmine_util'; - -const {expectArraysClose} = test_util; - -describeWithFlags('Conv2D WebGL Implementation ', ALL_ENVS, () => { - it('should work when width is odd and called multiple times.', async () => { - const filter = tf.tensor4d([-1, 3, 2, 1, 3, 4, 4, -2], [1, 1, 4, 2]); - const image = tf.tensor3d( - [ - 111, 112, 113, 114, 121, 122, 123, 124, 131, 132, 133, 134, - 211, 212, 213, 214, 221, 222, 223, 224, 231, 232, 233, 234, - 311, 312, 313, 314, 321, 322, 323, 324, 331, 332, 333, 334, - - ], - [3, 3, 4]); - - tf.conv2d(image, filter, 1, 'valid'); - // tslint:disable-next-line: no-unnecessary-type-assertion - const result = tf.conv2d(image, filter, 1, 'valid'); - const resultData = await result.data(); - - const expected = [ - 908, 669, 988, 729, 1068, 789, 1708, 1269, 1788, 1329, 1868, 1389, 2508, - 1869, 2588, 1929, 2668, 1989 - ]; - - expectArraysClose(resultData, expected); - }); - - it('image is packed and isChannelFirst.', async () => { - const filter = tf.tensor4d([1], [1, 1, 1, 1]); - const image = tf.tensor3d([11, 12, 13, 21, 22, 23, 31, 32, 33], [1, 3, 3]); - - // pack image. - tf.mul(image, 1); - - tf.conv2d(image, filter, 1, 'valid', 'NCHW'); - // tslint:disable-next-line: no-unnecessary-type-assertion - const result = tf.conv2d(image, filter, 1, 'valid', 'NCHW'); - const resultData = await result.data(); - - const expected = [11, 12, 13, 21, 22, 23, 31, 32, 33]; - - expectArraysClose(resultData, expected); - }); - - it('image is unpacked and isChannelFirst.', async () => { - const filter = tf.tensor4d([1], [1, 1, 1, 1]); - const image = tf.tensor3d([11, 12, 13, 21, 22, 23, 31, 32, 33], [1, 3, 3]); - - tf.conv2d(image, filter, 1, 'valid', 'NCHW'); - // tslint:disable-next-line: no-unnecessary-type-assertion - const result = tf.conv2d(image, filter, 1, 'valid', 'NCHW'); - const resultData = await result.data(); - - const expected = [11, 12, 13, 21, 22, 23, 31, 32, 33]; - - expectArraysClose(resultData, expected); - }); - - it('image is packed and isChannelLast.', async () => { - const filter = tf.tensor4d([1], [1, 1, 1, 1]); - const image = tf.tensor3d([11, 12, 13, 21, 22, 23, 31, 32, 33], [3, 3, 1]); - - // pack image. - tf.mul(image, 1); - - tf.conv2d(image, filter, 1, 'valid'); - // tslint:disable-next-line: no-unnecessary-type-assertion - const result = tf.conv2d(image, filter, 1, 'valid'); - const resultData = await result.data(); - - const expected = [11, 12, 13, 21, 22, 23, 31, 32, 33]; - - expectArraysClose(resultData, expected); - }); - - it('image is unpacked and isChannelLast.', async () => { - const filter = tf.tensor4d([1], [1, 1, 1, 1]); - const image = tf.tensor3d([11, 12, 13, 21, 22, 23, 31, 32, 33], [3, 3, 1]); - - tf.conv2d(image, filter, 1, 'valid'); - // tslint:disable-next-line: no-unnecessary-type-assertion - const result = tf.conv2d(image, filter, 1, 'valid'); - const resultData = await result.data(); - - const expected = [11, 12, 13, 21, 22, 23, 31, 32, 33]; - - expectArraysClose(resultData, expected); - }); -}); diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Conv3D.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Conv3D.ts deleted file mode 100644 index fb073b415..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Conv3D.ts +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, Conv3D, Conv3DAttrs, Conv3DInputs, KernelConfig, KernelFunc} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {Conv3DProgram} from '../conv_gpu'; - -export function conv3D( - args: - {inputs: Conv3DInputs, attrs: Conv3DAttrs, backend: MathBackendWebGL}) { - const {inputs, backend, attrs} = args; - const {x, filter} = inputs; - const {strides, pad, dilations} = attrs; - - const convInfo = backend_util.computeConv3DInfo( - x.shape as [number, number, number, number, number], - filter.shape as [number, number, number, number, number], strides, - dilations, pad); - - const program = new Conv3DProgram(convInfo); - return backend.runWebGLProgram(program, [x, filter], 'float32'); -} - -export const conv3DConfig: KernelConfig = { - kernelName: Conv3D, - backendName: 'webgl', - kernelFunc: conv3D as unknown as KernelFunc, -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Conv3DBackpropFilterV2.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Conv3DBackpropFilterV2.ts deleted file mode 100644 index 68a363c9d..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Conv3DBackpropFilterV2.ts +++ /dev/null @@ -1,44 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, Conv3DBackpropFilterV2, Conv3DBackpropFilterV2Attrs, Conv3DBackpropFilterV2Inputs, KernelConfig, KernelFunc} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {Conv3DDerFilterProgram} from '../conv_backprop_gpu'; - -export function conv3DBackpropFilterV2(args: { - inputs: Conv3DBackpropFilterV2Inputs, - attrs: Conv3DBackpropFilterV2Attrs, - backend: MathBackendWebGL -}) { - const {inputs, backend, attrs} = args; - const {x, dy} = inputs; - const {strides, pad, filterShape} = attrs; - - const convInfo = backend_util.computeConv3DInfo( - x.shape as [number, number, number, number, number], filterShape, strides, - 1 /* dilations */, pad); - - const program = new Conv3DDerFilterProgram(convInfo); - return backend.runWebGLProgram(program, [x, dy], 'float32'); -} - -export const conv3DBackpropFilterV2Config: KernelConfig = { - kernelName: Conv3DBackpropFilterV2, - backendName: 'webgl', - kernelFunc: conv3DBackpropFilterV2 as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Conv3DBackpropInputV2.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Conv3DBackpropInputV2.ts deleted file mode 100644 index 8fc7f5fd6..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Conv3DBackpropInputV2.ts +++ /dev/null @@ -1,44 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, Conv3DBackpropInputV2, Conv3DBackpropInputV2Attrs, Conv3DBackpropInputV2Inputs, KernelConfig, KernelFunc} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {Conv3DDerInputProgram} from '../conv_backprop_gpu'; - -export function conv3DBackpropInput(args: { - inputs: Conv3DBackpropInputV2Inputs, - attrs: Conv3DBackpropInputV2Attrs, - backend: MathBackendWebGL -}) { - const {inputs, backend, attrs} = args; - const {dy, filter} = inputs; - const {pad, strides, inputShape} = attrs; - - const convInfo = backend_util.computeConv3DInfo( - inputShape, filter.shape as [number, number, number, number, number], - strides, 1 /* dilations */, pad); - - const program = new Conv3DDerInputProgram(convInfo); - return backend.runWebGLProgram(program, [dy, filter], 'float32'); -} - -export const conv3DBackpropInputConfig: KernelConfig = { - kernelName: Conv3DBackpropInputV2, - backendName: 'webgl', - kernelFunc: conv3DBackpropInput as unknown as KernelFunc, -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Cos.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Cos.ts deleted file mode 100644 index 729f85354..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Cos.ts +++ /dev/null @@ -1,41 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Cos, KernelConfig} from '@tensorflow/tfjs-core'; - -import {CHECK_NAN_SNIPPET_PACKED} from '../binaryop_packed_gpu'; -import {CHECK_NAN_SNIPPET_UNARY, unaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; - -const COS = CHECK_NAN_SNIPPET_UNARY + ` - return cos(x); -`; - -const COS_PACKED = ` - vec4 result = cos(x); - bvec4 isNaN = isnan(x); - ${CHECK_NAN_SNIPPET_PACKED} - return result; -`; - -export const cos = - unaryKernelFunc({opSnippet: COS, packedOpSnippet: COS_PACKED}); - -export const cosConfig: KernelConfig = { - kernelName: Cos, - backendName: 'webgl', - kernelFunc: cos, -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Cosh.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Cosh.ts deleted file mode 100644 index 3ecf2f01e..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Cosh.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Cosh, KernelConfig} from '@tensorflow/tfjs-core'; -import {unaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; - -const COSH = ` - float e2x = exp(-x); - return (e2x + 1.0 / e2x) / 2.0; -`; - -export const cosh = unaryKernelFunc({opSnippet: COSH}); - -export const coshConfig: KernelConfig = { - kernelName: Cosh, - backendName: 'webgl', - kernelFunc: cosh, -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/CropAndResize.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/CropAndResize.ts deleted file mode 100644 index 2949b5b38..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/CropAndResize.ts +++ /dev/null @@ -1,42 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {CropAndResize, CropAndResizeAttrs, CropAndResizeInputs, KernelConfig, KernelFunc, TensorInfo} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {CropAndResizeProgram} from '../crop_and_resize_gpu'; - -export const cropAndResize = (args: { - inputs: CropAndResizeInputs, - backend: MathBackendWebGL, - attrs: CropAndResizeAttrs -}): TensorInfo => { - const {inputs, backend, attrs} = args; - const {image, boxes, boxInd} = inputs; - const {cropSize, method, extrapolationValue} = attrs; - - const program = new CropAndResizeProgram( - image.shape as [number, number, number, number], - boxes.shape as [number, number], cropSize, method, extrapolationValue); - return backend.runWebGLProgram(program, [image, boxes, boxInd], 'float32'); -}; - -export const cropAndResizeConfig: KernelConfig = { - kernelName: CropAndResize, - backendName: 'webgl', - kernelFunc: cropAndResize as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Cum_impl.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Cum_impl.ts deleted file mode 100644 index 2ad5db2eb..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Cum_impl.ts +++ /dev/null @@ -1,79 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, TensorInfo} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {CumOpType, CumProgram} from '../cum_gpu'; - -import {identity} from './Identity'; -import {transpose} from './Transpose'; - -export function cumImpl( - op: CumOpType, x: TensorInfo, backend: MathBackendWebGL, axis: number, - exclusive: boolean, reverse: boolean): TensorInfo { - const xRank = x.shape.length; - const permutation = backend_util.getAxesPermutation([axis], xRank); - let permutedX = x; - if (permutation != null) { - permutedX = transpose({inputs: {x}, backend, attrs: {perm: permutation}}); - } - const permutedAxis = backend_util.getInnerMostAxes(1, xRank)[0]; - - if (permutedAxis !== xRank - 1) { - throw new Error( - `WebGL cumprod shader expects an inner-most axis=${ - x.shape.length - 1} ` + - `but got axis=${axis}`); - } - const size = permutedX.shape[permutedAxis]; - let result = identity({inputs: {x: permutedX}, backend}); - // Use cum parallel algorithm, inspired by: - // https://developer.nvidia.com/gpugems/gpugems3/part-vi-gpu-computing/chapter-39-parallel-prefix-sum-scan-cuda - // Note: although the algorithm is called sum, it works for any associtative - // operator with an identity. - - for (let i = 0; i <= Math.ceil(Math.log2(size)) - 1; i++) { - const program = new CumProgram(op, permutedX.shape, false, reverse); - const customValues = [[i]]; - const prevResult = result; - result = - backend.runWebGLProgram(program, [result], result.dtype, customValues); - backend.disposeIntermediateTensorInfo(prevResult); - } - // For exclusive cum, shift the end result in the direction of product or sum - // and add 1 for product or 0 for sum to the front index. - if (exclusive) { - const program = new CumProgram(op, permutedX.shape, exclusive, reverse); - const prevResult = result; - result = backend.runWebGLProgram(program, [result], result.dtype); - backend.disposeIntermediateTensorInfo(prevResult); - } - - if (permutation != null) { - const reversePermutation = backend_util.getUndoAxesPermutation(permutation); - const reverseTransposedResult = transpose( - {inputs: {x: result}, backend, attrs: {perm: reversePermutation}}); - - backend.disposeIntermediateTensorInfo(result); - backend.disposeIntermediateTensorInfo(permutedX); - - return reverseTransposedResult; - } - - return result; -} diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Cumprod.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Cumprod.ts deleted file mode 100644 index cabe6d1b2..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Cumprod.ts +++ /dev/null @@ -1,40 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Cumprod, CumprodAttrs, CumprodInputs, KernelConfig, KernelFunc, TensorInfo} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {CumOpType} from '../cum_gpu'; -import {cumImpl} from './Cum_impl'; - -export function cumprod(args: { - inputs: CumprodInputs, - backend: MathBackendWebGL, - attrs: CumprodAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {x} = inputs; - const {axis, exclusive, reverse} = attrs; - - return cumImpl(CumOpType.Prod, x, backend, axis, exclusive, reverse); -} - -export const cumprodConfig: KernelConfig = { - kernelName: Cumprod, - backendName: 'webgl', - kernelFunc: cumprod as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Cumsum.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Cumsum.ts deleted file mode 100644 index 64b7772bd..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Cumsum.ts +++ /dev/null @@ -1,38 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Cumsum, CumsumAttrs, CumsumInputs, KernelConfig, KernelFunc, TensorInfo} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {CumOpType} from '../cum_gpu'; -import {cumImpl} from './Cum_impl'; - -export function cumsum( - args: - {inputs: CumsumInputs, backend: MathBackendWebGL, attrs: CumsumAttrs}): - TensorInfo { - const {inputs, backend, attrs} = args; - const {x} = inputs; - const {axis, exclusive, reverse} = attrs; - return cumImpl(CumOpType.Sum, x, backend, axis, exclusive, reverse); -} - -export const cumsumConfig: KernelConfig = { - kernelName: Cumsum, - backendName: 'webgl', - kernelFunc: cumsum as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/DenseBincount.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/DenseBincount.ts deleted file mode 100644 index 17620bfb1..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/DenseBincount.ts +++ /dev/null @@ -1,58 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {DenseBincount, DenseBincountAttrs, DenseBincountInputs, KernelConfig, KernelFunc, Rank, TensorInfo, TypedArray} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {bincountImplCPU, bincountReduceImplCPU} from '../kernel_utils/shared'; - -export function denseBincount(args: { - inputs: DenseBincountInputs, - backend: MathBackendWebGL, - attrs: DenseBincountAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {x, weights} = inputs; - const {size, binaryOutput} = attrs; - - if (x.shape.length === 1) { - const xVals = backend.readSync(x.dataId) as TypedArray; - const weightsVals = backend.readSync(weights.dataId) as TypedArray; - - const outVals = - bincountImplCPU(xVals, weightsVals, weights.dtype, weights.shape, size); - - return backend.makeTensorInfo([size], weights.dtype, outVals); - } else if (x.shape.length === 2) { - const xBuf = backend.bufferSync(x); - const weightsBuf = backend.bufferSync(weights); - - const outBuf = bincountReduceImplCPU(xBuf, weightsBuf, size, binaryOutput); - - return backend.makeTensorInfo(outBuf.shape, weights.dtype, outBuf.values); - } - - throw new Error( - `Error in denseBincount: input must be at most rank 2, but got rank` + - `${x.shape.length}.`); -} - -export const denseBincountConfig: KernelConfig = { - kernelName: DenseBincount, - backendName: 'webgl', - kernelFunc: denseBincount as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/DepthToSpace.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/DepthToSpace.ts deleted file mode 100644 index 85d7dfc9f..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/DepthToSpace.ts +++ /dev/null @@ -1,53 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {DepthToSpace, DepthToSpaceAttrs, DepthToSpaceInputs, KernelConfig, KernelFunc, TensorInfo} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {DepthToSpaceProgram} from '../depth_to_space_gpu'; - -export function depthToSpace(args: { - inputs: DepthToSpaceInputs, - backend: MathBackendWebGL, - attrs: DepthToSpaceAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {x} = inputs; - const {blockSize, dataFormat} = attrs; - - const batchSize = x.shape[0]; - const inputHeight = (dataFormat === 'NHWC') ? x.shape[1] : x.shape[2]; - const inputWidth = (dataFormat === 'NHWC') ? x.shape[2] : x.shape[3]; - const inputDepth = (dataFormat === 'NHWC') ? x.shape[3] : x.shape[1]; - - const outputHeight = inputHeight * blockSize; - const outputWidth = inputWidth * blockSize; - const outputDepth = inputDepth / (blockSize * blockSize); - - const outputShape = (dataFormat === 'NHWC') ? - [batchSize, outputHeight, outputWidth, outputDepth] : - [batchSize, outputDepth, outputHeight, outputWidth]; - - const program = new DepthToSpaceProgram(outputShape, blockSize, dataFormat); - return backend.runWebGLProgram(program, [x], x.dtype); -} - -export const depthToSpaceConfig: KernelConfig = { - kernelName: DepthToSpace, - backendName: 'webgl', - kernelFunc: depthToSpace as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/DepthwiseConv2dNative.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/DepthwiseConv2dNative.ts deleted file mode 100644 index c3900ceb3..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/DepthwiseConv2dNative.ts +++ /dev/null @@ -1,68 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, DepthwiseConv2dNative, DepthwiseConv2dNativeAttrs, DepthwiseConv2dNativeInputs, env, KernelConfig, KernelFunc, util} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {DepthwiseConv2DProgram} from '../conv_gpu_depthwise'; -import {DepthwiseConvPacked2DProgram} from '../conv_packed_gpu_depthwise'; - -export function depthwiseConv2dNative(args: { - inputs: DepthwiseConv2dNativeInputs, - attrs: DepthwiseConv2dNativeAttrs, - backend: MathBackendWebGL -}) { - const {inputs, backend, attrs} = args; - const {x, filter} = inputs; - const {strides, pad, dilations, dimRoundingMode} = attrs; - - let $dilations = dilations; - if ($dilations == null) { - $dilations = [1, 1]; - } - - util.assert( - backend_util.eitherStridesOrDilationsAreOne(strides, $dilations), - () => 'Error in depthwiseConv2d: Either strides or dilations must be ' + - `1. Got strides ${strides} and dilations '${$dilations}'`); - - const convInfo = backend_util.computeConv2DInfo( - x.shape as [number, number, number, number], - filter.shape as [number, number, number, number], strides, $dilations, - pad, dimRoundingMode, true /* depthwise */); - - let program: DepthwiseConv2DProgram|DepthwiseConvPacked2DProgram; - if (env().getBool('WEBGL_PACK_DEPTHWISECONV') && convInfo.strideWidth <= 2 && - convInfo.outChannels / convInfo.inChannels === 1) { - program = new DepthwiseConvPacked2DProgram(convInfo); - } else { - program = new DepthwiseConv2DProgram(convInfo); - } - const customValues = [ - [convInfo.padInfo.top, convInfo.padInfo.left], - [convInfo.strideHeight, convInfo.strideWidth], - [convInfo.dilationHeight, convInfo.dilationWidth], - [convInfo.inHeight, convInfo.inWidth] - ]; - return backend.runWebGLProgram(program, [x, filter], 'float32', customValues); -} - -export const depthwiseConv2dNativeConfig: KernelConfig = { - kernelName: DepthwiseConv2dNative, - backendName: 'webgl', - kernelFunc: depthwiseConv2dNative as unknown as KernelFunc, -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/DepthwiseConv2dNativeBackpropFilter.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/DepthwiseConv2dNativeBackpropFilter.ts deleted file mode 100644 index cafae4f1b..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/DepthwiseConv2dNativeBackpropFilter.ts +++ /dev/null @@ -1,44 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, DepthwiseConv2dNativeBackpropFilter, DepthwiseConv2dNativeBackpropFilterAttrs, DepthwiseConv2dNativeBackpropFilterInputs, KernelConfig, KernelFunc} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {DepthwiseConv2DDerFilterProgram} from '../conv_backprop_gpu_depthwise'; - -export function depthwiseConv2dNativeBackpropFilter(args: { - inputs: DepthwiseConv2dNativeBackpropFilterInputs, - attrs: DepthwiseConv2dNativeBackpropFilterAttrs, - backend: MathBackendWebGL -}) { - const {inputs, backend, attrs} = args; - const {x, dy} = inputs; - const {strides, dilations, pad, dimRoundingMode, filterShape} = attrs; - - const convInfo = backend_util.computeConv2DInfo( - x.shape as [number, number, number, number], filterShape, strides, - dilations, pad, dimRoundingMode, true /* depthwise */); - - const program = new DepthwiseConv2DDerFilterProgram(convInfo); - return backend.runWebGLProgram(program, [x, dy], 'float32'); -} - -export const depthwiseConv2dNativeBackpropFilterConfig: KernelConfig = { - kernelName: DepthwiseConv2dNativeBackpropFilter, - backendName: 'webgl', - kernelFunc: depthwiseConv2dNativeBackpropFilter as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/DepthwiseConv2dNativeBackpropInput.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/DepthwiseConv2dNativeBackpropInput.ts deleted file mode 100644 index cc57122ac..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/DepthwiseConv2dNativeBackpropInput.ts +++ /dev/null @@ -1,44 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, DepthwiseConv2dNativeBackpropInput, DepthwiseConv2dNativeBackpropInputAttrs, DepthwiseConv2dNativeBackpropInputInputs, KernelConfig, KernelFunc} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {DepthwiseConv2DDerInputProgram} from '../conv_backprop_gpu_depthwise'; - -export function depthwiseConv2dNativeBackpropInput(args: { - inputs: DepthwiseConv2dNativeBackpropInputInputs, - attrs: DepthwiseConv2dNativeBackpropInputAttrs, - backend: MathBackendWebGL -}) { - const {inputs, backend, attrs} = args; - const {dy, filter} = inputs; - const {strides, dilations, pad, dimRoundingMode, inputShape} = attrs; - - const convInfo = backend_util.computeConv2DInfo( - inputShape, filter.shape as [number, number, number, number], strides, - dilations, pad, dimRoundingMode, true /* depthwise */); - - const program = new DepthwiseConv2DDerInputProgram(convInfo); - return backend.runWebGLProgram(program, [dy, filter], 'float32'); -} - -export const depthwiseConv2dNativeBackpropInputConfig: KernelConfig = { - kernelName: DepthwiseConv2dNativeBackpropInput, - backendName: 'webgl', - kernelFunc: depthwiseConv2dNativeBackpropInput as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Diag.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Diag.ts deleted file mode 100644 index 6e7ae481f..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Diag.ts +++ /dev/null @@ -1,49 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Diag, DiagInputs, KernelConfig, KernelFunc, TensorInfo, util} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {DiagProgram} from '../diag_gpu'; -import {reshape} from './Reshape'; - -export function diag(args: {inputs: DiagInputs, backend: MathBackendWebGL}): - TensorInfo { - const {inputs, backend} = args; - const {x} = inputs; - - const outShape = [...x.shape, ...x.shape]; - const xSize = util.sizeFromShape(x.shape); - - const flat = reshape({inputs: {x}, backend, attrs: {shape: [xSize]}}); - - const program = new DiagProgram(xSize); - const res = backend.runWebGLProgram(program, [flat], flat.dtype); - - const out = reshape({inputs: {x: res}, backend, attrs: {shape: outShape}}); - - backend.disposeIntermediateTensorInfo(flat); - backend.disposeIntermediateTensorInfo(res); - - return out; -} - -export const diagConfig: KernelConfig = { - kernelName: Diag, - backendName: 'webgl', - kernelFunc: diag as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Dilation2D.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Dilation2D.ts deleted file mode 100644 index 6456aa76f..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Dilation2D.ts +++ /dev/null @@ -1,53 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, Dilation2D, Dilation2DAttrs, Dilation2DInputs, KernelConfig, KernelFunc, TensorInfo} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {Dilation2DProgram} from '../dilation_gpu'; -import {reshape} from './Reshape'; - -export function dilation2D(args: { - inputs: Dilation2DInputs, - attrs: Dilation2DAttrs, - backend: MathBackendWebGL -}) { - const {inputs, backend, attrs} = args; - const {x, filter} = inputs; - const {strides, pad, dilations} = attrs; - - const convInfo = backend_util.computeDilation2DInfo( - x.shape as [number, number, number, number], - filter.shape as [number, number, number], strides, pad, - 'NHWC' /* dataFormat */, dilations); - let out: TensorInfo; - - const program = new Dilation2DProgram(convInfo); - out = backend.runWebGLProgram(program, [x, filter], 'float32'); - - const outReshaped = - reshape({inputs: {x: out}, backend, attrs: {shape: convInfo.outShape}}); - backend.disposeIntermediateTensorInfo(out); - - return outReshaped; -} - -export const dilation2DConfig: KernelConfig = { - kernelName: Dilation2D, - backendName: 'webgl', - kernelFunc: dilation2D as unknown as KernelFunc, -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Einsum.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Einsum.ts deleted file mode 100644 index 738684ff9..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Einsum.ts +++ /dev/null @@ -1,103 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, Einsum, EinsumAttrs, EinsumInputs, KernelConfig, KernelFunc, Tensor, TensorInfo, util} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; - -import {multiply} from './Multiply'; -import {reshape} from './Reshape'; -import {sum} from './Sum'; -import {transpose} from './Transpose'; - -export function einsum( - args: - {inputs: EinsumInputs, backend: MathBackendWebGL, attrs: EinsumAttrs}): - TensorInfo { - const {inputs, backend, attrs} = args; - const {equation} = attrs; - const tensors = inputs as Tensor[]; - - const {allDims, summedDims, idDims} = - backend_util.decodeEinsumEquation(equation, tensors.length); - backend_util.checkEinsumDimSizes(allDims.length, idDims, tensors); - const {path, steps} = backend_util.getEinsumComputePath(summedDims, idDims); - - const nSteps = steps.length; - let out: TensorInfo|null = null; - let numDimsRemaining = allDims.length; - const tensorsToDispose: TensorInfo[] = []; - for (let i = 0; i < nSteps; ++i) { - for (const idTerm of steps[i]) { - const {permutationIndices: perm, expandDims: dimsToExpand} = - backend_util.getEinsumPermutation(numDimsRemaining, idDims[idTerm]); - let x: TensorInfo; - if (backend_util.isIdentityPermutation(perm)) { - x = tensors[idTerm]; - } else { - x = transpose({inputs: {x: tensors[idTerm]}, backend, attrs: {perm}}); - tensorsToDispose.push(x); - } - const targetShape: number[] = x.shape.slice(); - for (let k = 0; k < dimsToExpand.length; ++k) { - targetShape.splice(dimsToExpand[k], 0, 1); - } - - if (!util.arraysEqual(x.shape, targetShape)) { - x = reshape({inputs: {x}, backend, attrs: {shape: targetShape}}); - tensorsToDispose.push(x); - } - if (out === null) { - out = x; - } else { - // tslint:disable-next-line: no-unnecessary-type-assertion - out = multiply({inputs: {a: x, b: out}, backend}) as TensorInfo; - tensorsToDispose.push(out); - } - } - if (i < nSteps - 1) { - if (path[i] >= 0) { - out = sum({ - inputs: {x: out}, - backend, - attrs: { - axis: path[i] - (allDims.length - numDimsRemaining), - keepDims: false - } - }); - tensorsToDispose.push(out); - } - numDimsRemaining--; - } - } - - // Clean up intermediate tensors. - for (const tensorInfo of tensorsToDispose) { - if (tensorInfo === out) { - continue; - } - backend.disposeIntermediateTensorInfo(tensorInfo); - } - - return out; -} - -export const einsumConfig: KernelConfig = { - kernelName: Einsum, - backendName: 'webgl', - kernelFunc: einsum as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Elu.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Elu.ts deleted file mode 100644 index 7a57ef96d..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Elu.ts +++ /dev/null @@ -1,40 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Elu, KernelConfig, KernelFunc} from '@tensorflow/tfjs-core'; -import {unaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; - -const ELU = `return (x >= 0.0) ? x : (exp(x) - 1.0);`; - -const ELU_PACKED = ` - vec4 result; - - result.r = (x.r >= 0.0) ? x.r : (exp(x.r) - 1.0); - result.g = (x.g >= 0.0) ? x.g : (exp(x.g) - 1.0); - result.b = (x.b >= 0.0) ? x.b : (exp(x.b) - 1.0); - result.a = (x.a >= 0.0) ? x.a : (exp(x.a) - 1.0); - - return result; -`; - -const elu = unaryKernelFunc({opSnippet: ELU, packedOpSnippet: ELU_PACKED}); - -export const eluConfig: KernelConfig = { - kernelName: Elu, - backendName: 'webgl', - kernelFunc: elu as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/EluGrad.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/EluGrad.ts deleted file mode 100644 index bf1d21a0b..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/EluGrad.ts +++ /dev/null @@ -1,45 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {EluGrad, EluGradInputs, env, KernelConfig, KernelFunc, TensorInfo} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {BinaryOpProgram} from '../binaryop_gpu'; -import {BinaryOpPackedProgram} from '../binaryop_packed_gpu'; - -const ELU_DER = `return (b >= 0.0) ? a : a * (b + 1.0);`; -const ELU_DER_PACKED = ` - vec4 bGTEZero = vec4(greaterThanEqual(b, vec4(0.))); - return (bGTEZero * a) + ((vec4(1.0) - bGTEZero) * (a * (b + vec4(1.0)))); -`; - -export const eluGrad = - (args: {inputs: EluGradInputs, backend: MathBackendWebGL}): TensorInfo => { - const {inputs, backend} = args; - const {dy, y} = inputs; - - const program = env().getBool('WEBGL_PACK_BINARY_OPERATIONS') ? - new BinaryOpPackedProgram(ELU_DER_PACKED, dy.shape, y.shape) : - new BinaryOpProgram(ELU_DER, dy.shape, y.shape); - return backend.runWebGLProgram(program, [dy, y], dy.dtype); - }; - -export const eluGradConfig: KernelConfig = { - kernelName: EluGrad, - backendName: 'webgl', - kernelFunc: eluGrad as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Equal.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Equal.ts deleted file mode 100644 index 3b64ff82d..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Equal.ts +++ /dev/null @@ -1,38 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Equal, KernelConfig, KernelFunc} from '@tensorflow/tfjs-core'; -import {binaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; -import {equalImplCPU} from '../kernel_utils/shared'; -const PACKED_EQUAL = ` - return vec4(equal(a, b)); -`; - -const EQUAL = `return float(a == b);`; - -export const equal = binaryKernelFunc({ - opSnippet: EQUAL, - packedOpSnippet: PACKED_EQUAL, - dtype: 'bool', - cpuKernelImpl: equalImplCPU, -}); - -export const equalConfig: KernelConfig = { - kernelName: Equal, - backendName: 'webgl', - kernelFunc: equal as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Erf.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Erf.ts deleted file mode 100644 index d4dc3d779..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Erf.ts +++ /dev/null @@ -1,45 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, Erf, KernelConfig} from '@tensorflow/tfjs-core'; - -import {unaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; - -const ERF = ` - // Error function is calculated approximately with elementary function. - // See "Handbook of Mathematical Functions with Formulas, - // Graphs, and Mathematical Tables", Abramowitz and Stegun. - float p = ${backend_util.ERF_P}; - float a1 = ${backend_util.ERF_A1}; - float a2 = ${backend_util.ERF_A2}; - float a3 = ${backend_util.ERF_A3}; - float a4 = ${backend_util.ERF_A4}; - float a5 = ${backend_util.ERF_A5}; - - float sign = sign(x); - x = abs(x); - float t = 1.0 / (1.0 + p * x); - return sign * (1.0 - (((((a5*t + a4)*t) + a3)*t + a2)*t + a1)*t*exp(-x*x)); -`; - -export const erf = unaryKernelFunc({opSnippet: ERF}); - -export const erfConfig: KernelConfig = { - kernelName: Erf, - backendName: 'webgl', - kernelFunc: erf, -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Exp.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Exp.ts deleted file mode 100644 index 0602e7417..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Exp.ts +++ /dev/null @@ -1,49 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Exp, KernelConfig, KernelFunc} from '@tensorflow/tfjs-core'; - -import {CHECK_NAN_SNIPPET_UNARY, unaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; -import {expImplCPU} from '../kernel_utils/shared'; - -export const EXP = CHECK_NAN_SNIPPET_UNARY + ` - return exp(x); -`; - -const EXP_PACKED = ` - vec4 result = exp(x); - bvec4 isNaN = isnan(x); - result.r = isNaN.r ? x.r : result.r; - result.g = isNaN.g ? x.g : result.g; - result.b = isNaN.b ? x.b : result.b; - result.a = isNaN.a ? x.a : result.a; - - return result; -`; - -export const exp = unaryKernelFunc({ - opSnippet: EXP, - packedOpSnippet: EXP_PACKED, - cpuKernelImpl: expImplCPU, - dtype: 'float32', -}); - -export const expConfig: KernelConfig = { - kernelName: Exp, - backendName: 'webgl', - kernelFunc: exp as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/ExpandDims.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/ExpandDims.ts deleted file mode 100644 index 121c97488..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/ExpandDims.ts +++ /dev/null @@ -1,52 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ExpandDims, ExpandDimsAttrs, ExpandDimsInputs, KernelConfig, KernelFunc, TensorInfo, util} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {reshape} from './Reshape'; - -export function expandDims(args: { - inputs: ExpandDimsInputs, - attrs: ExpandDimsAttrs, - backend: MathBackendWebGL -}): TensorInfo { - const {inputs, attrs, backend} = args; - const {dim} = attrs; - const {input} = inputs; - - const inputRank = input.shape.length; - const newShape = input.shape.slice(); - let $dim = dim; - if (dim < 0) { - // Negative value is counted from the tail of rank. - util.assert( - -(inputRank + 1) <= dim, - () => `Axis must be in the interval [${- (inputRank + 1)}, ${ - inputRank}]`); - $dim = inputRank + dim + 1; - } - newShape.splice($dim, 0, 1); - - return reshape({inputs: {x: input}, backend, attrs: {shape: newShape}}); -} - -export const expandDimsConfig: KernelConfig = { - kernelName: ExpandDims, - backendName: 'webgl', - kernelFunc: expandDims as unknown as KernelFunc, -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Expm1.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Expm1.ts deleted file mode 100644 index 78933ae90..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Expm1.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Expm1, KernelConfig, KernelFunc} from '@tensorflow/tfjs-core'; -import {unaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; -import {expm1ImplCPU} from '../kernel_utils/shared'; - -const EXPM1 = `return exp(x) - 1.0;`; - -export const expm1 = unaryKernelFunc( - {opSnippet: EXPM1, packedOpSnippet: EXPM1, cpuKernelImpl: expm1ImplCPU}); - -export const expm1Config: KernelConfig = { - kernelName: Expm1, - backendName: 'webgl', - kernelFunc: expm1 as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/FFT.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/FFT.ts deleted file mode 100644 index 953c1d9e4..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/FFT.ts +++ /dev/null @@ -1,36 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {FFT, FFTInputs, KernelConfig, TensorInfo} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; - -import {fftImpl} from './FFT_impl'; - -export function fft(args: {inputs: FFTInputs, backend: MathBackendWebGL}): - TensorInfo { - const {inputs, backend} = args; - const {input} = inputs; - - return fftImpl(input, false /* inverse */, backend); -} - -export const fftConfig: KernelConfig = { - kernelName: FFT, - backendName: 'webgl', - kernelFunc: fft -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/FFT_impl.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/FFT_impl.ts deleted file mode 100644 index e2f042370..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/FFT_impl.ts +++ /dev/null @@ -1,70 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {TensorInfo, util} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {FFTProgram} from '../fft_gpu'; - -import {complex} from './Complex'; -import {reshape} from './Reshape'; - -export function fftImpl( - x: TensorInfo, inverse: boolean, backend: MathBackendWebGL): TensorInfo { - const xData = backend.texData.get(x.dataId); - - const inputSize = util.sizeFromShape(x.shape); - // Collapse all outer dimensions to a single batch dimension. - const innerDimensionSize = x.shape[x.shape.length - 1]; - const batch = inputSize / innerDimensionSize; - - const input2D = reshape( - {inputs: {x}, backend, attrs: {shape: [batch, innerDimensionSize]}}); - - const xShape = input2D.shape as [number, number]; - const realProgram = new FFTProgram('real', xShape, inverse); - const imagProgram = new FFTProgram('imag', xShape, inverse); - - const inputs = [ - { - dataId: xData.complexTensorInfos.real.dataId, - dtype: xData.complexTensorInfos.real.dtype, - shape: xShape - }, - { - dataId: xData.complexTensorInfos.imag.dataId, - dtype: xData.complexTensorInfos.imag.dtype, - shape: xShape - } - ]; - - const realPart = backend.runWebGLProgram(realProgram, inputs, 'float32'); - const imagPart = backend.runWebGLProgram(imagProgram, inputs, 'float32'); - - const complexOutput = - complex({inputs: {real: realPart, imag: imagPart}, backend}); - - backend.disposeIntermediateTensorInfo(realPart); - backend.disposeIntermediateTensorInfo(imagPart); - - const complexOutputReshaped = - reshape({inputs: {x: complexOutput}, backend, attrs: {shape: x.shape}}); - - backend.disposeIntermediateTensorInfo(input2D); - backend.disposeIntermediateTensorInfo(complexOutput); - return complexOutputReshaped; -} diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Fill.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Fill.ts deleted file mode 100644 index f0d6e6667..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Fill.ts +++ /dev/null @@ -1,47 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Fill, FillAttrs, KernelConfig, KernelFunc, TensorInfo, util} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {FillProgram} from '../fill_gpu'; - -export function fill(args: {backend: MathBackendWebGL, attrs: FillAttrs}): - TensorInfo { - const {backend, attrs} = args; - const {shape, value} = attrs; - let {dtype} = attrs; - - dtype = dtype || util.inferDtype(value); - - if (dtype === 'string') { - // String type should be handled in CPU memory. - const values = util.getArrayFromDType(dtype, util.sizeFromShape(shape)); - values.fill(value as string); - return backend.makeTensorInfo(shape, dtype, values); - } else { - const program = new FillProgram(shape, value as number); - const customValues = [[value as number]]; - return backend.runWebGLProgram(program, [], dtype, customValues); - } -} - -export const fillConfig: KernelConfig = { - kernelName: Fill, - backendName: 'webgl', - kernelFunc: fill as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/FlipLeftRight.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/FlipLeftRight.ts deleted file mode 100644 index 1c58e3094..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/FlipLeftRight.ts +++ /dev/null @@ -1,35 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, Tensor4D} from '@tensorflow/tfjs-core'; -import {FlipLeftRight, FlipLeftRightInputs} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {FlipLeftRightProgram} from '../flip_left_right_gpu'; - -export const flipLeftRightConfig: KernelConfig = { - kernelName: FlipLeftRight, - backendName: 'webgl', - kernelFunc: ({inputs, backend}) => { - const {image} = inputs as FlipLeftRightInputs; - const webglBackend = backend as MathBackendWebGL; - - const program = new FlipLeftRightProgram((image as Tensor4D).shape); - const output = webglBackend.runWebGLProgram(program, [image], image.dtype); - return output; - } -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Floor.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Floor.ts deleted file mode 100644 index 92626f694..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Floor.ts +++ /dev/null @@ -1,32 +0,0 @@ - -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Floor, KernelConfig} from '@tensorflow/tfjs-core'; -import {unaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; -import {floorImplCPU} from '../kernel_utils/shared'; - -const FLOOR = `return floor(x);`; - -export const floor = unaryKernelFunc( - {opSnippet: FLOOR, packedOpSnippet: FLOOR, cpuKernelImpl: floorImplCPU}); - -export const floorConfig: KernelConfig = { - kernelName: Floor, - backendName: 'webgl', - kernelFunc: floor, -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/FloorDiv.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/FloorDiv.ts deleted file mode 100644 index 24c2e3e6a..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/FloorDiv.ts +++ /dev/null @@ -1,68 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {FloorDiv, KernelConfig, KernelFunc} from '@tensorflow/tfjs-core'; - -import {binaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; - -// We use native integer division to deal with floating point imprecision. Since -// we implement floor division and glsl implements truncated division, we -// correct for this by subtracting 1 from result when the result is negative and -// there is a remainder. -const INT_DIV = ` - float s = sign(a) * sign(b); - int ia = round(a); - int ib = round(b); - if (ib != 0) { - // Windows (D3D) wants guaranteed non-zero int division at compile-time. - return float(idiv(ia, ib, s)); - } else { - return NAN; - } -`; - -const INT_DIV_PACKED = ` - ivec4 ia = round(a); - ivec4 ib = round(b); - bvec4 cond = notEqual(ib, ivec4(0)); - ivec4 result = ivec4(0); - vec4 s = sign(a) * sign(b); - - // Windows (D3D) wants guaranteed non-zero int division at compile-time. - if (cond[0]) { - result[0] = idiv(ia[0], ib[0], s[0]); - } - if (cond[1]) { - result[1] = idiv(ia[1], ib[1], s[1]); - } - if (cond[2]) { - result[2] = idiv(ia[2], ib[2], s[2]); - } - if (cond[3]) { - result[3] = idiv(ia[3], ib[3], s[3]); - } - return vec4(result); -`; - -export const floorDiv = binaryKernelFunc( - {opSnippet: INT_DIV, packedOpSnippet: INT_DIV_PACKED, dtype: 'int32'}); - -export const floorDivConfig: KernelConfig = { - kernelName: FloorDiv, - backendName: 'webgl', - kernelFunc: floorDiv as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/FromPixels.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/FromPixels.ts deleted file mode 100644 index b32671dd6..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/FromPixels.ts +++ /dev/null @@ -1,89 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {env, KernelConfig, KernelFunc, TensorInfo} from '@tensorflow/tfjs-core'; -import {FromPixels, FromPixelsAttrs, FromPixelsInputs} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {TextureUsage} from '../tex_util'; - -import {FromPixelsProgram} from './FromPixels_utils/from_pixels_gpu'; -import {FromPixelsPackedProgram} from './FromPixels_utils/from_pixels_packed_gpu'; - -export const fromPixelsConfig: KernelConfig = { - kernelName: FromPixels, - backendName: 'webgl', - kernelFunc: fromPixels as unknown as KernelFunc, -}; - -let fromPixels2DContext: CanvasRenderingContext2D; -let willReadFrequently = env().getBool('CANVAS2D_WILL_READ_FREQUENTLY_FOR_GPU'); - -function fromPixels(args: { - inputs: FromPixelsInputs, - backend: MathBackendWebGL, - attrs: FromPixelsAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - let {pixels} = inputs; - const {numChannels} = attrs; - - const isVideo = typeof (HTMLVideoElement) !== 'undefined' && - pixels instanceof HTMLVideoElement; - const isImage = typeof (HTMLImageElement) !== 'undefined' && - pixels instanceof HTMLImageElement; - const [width, height] = isVideo ? - [ - (pixels as HTMLVideoElement).videoWidth, - (pixels as HTMLVideoElement).videoHeight - ] : - [pixels.width, pixels.height]; - - const texShape: [number, number] = [height, width]; - const outShape = [height, width, numChannels]; - - if (isImage || isVideo) { - const newWillReadFrequently = - env().getBool('CANVAS2D_WILL_READ_FREQUENTLY_FOR_GPU'); - if (fromPixels2DContext == null || - newWillReadFrequently !== willReadFrequently) { - willReadFrequently = newWillReadFrequently; - fromPixels2DContext = - document.createElement('canvas').getContext( - '2d', {willReadFrequently}); - } - - fromPixels2DContext.canvas.width = width; - fromPixels2DContext.canvas.height = height; - fromPixels2DContext.drawImage( - pixels as HTMLVideoElement | HTMLImageElement | ImageBitmap, 0, 0, - width, height); - pixels = fromPixels2DContext.canvas; - } - - const tempPixelHandle = backend.makeTensorInfo(texShape, 'int32'); - // This is a byte texture with pixels. - backend.texData.get(tempPixelHandle.dataId).usage = TextureUsage.PIXELS; - backend.gpgpu.uploadPixelDataToTexture( - backend.getTexture(tempPixelHandle.dataId), pixels as ImageData); - const program = env().getBool('WEBGL_PACK') ? - new FromPixelsPackedProgram(outShape) : - new FromPixelsProgram(outShape); - const res = backend.runWebGLProgram(program, [tempPixelHandle], 'int32'); - backend.disposeData(tempPixelHandle.dataId); - return res; -} diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/FromPixels_utils/from_pixels_gpu.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/FromPixels_utils/from_pixels_gpu.ts deleted file mode 100644 index 8ffd6dcc3..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/FromPixels_utils/from_pixels_gpu.ts +++ /dev/null @@ -1,54 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {getGlslDifferences} from '../../glsl_version'; -import {GPGPUProgram} from '../../gpgpu_math'; - -export class FromPixelsProgram implements GPGPUProgram { - variableNames = ['A']; - userCode: string; - outputShape: number[]; - - constructor(outputShape: number[]) { - const glsl = getGlslDifferences(); - const [height, width, ] = outputShape; - this.outputShape = outputShape; - this.userCode = ` - void main() { - ivec3 coords = getOutputCoords(); - int texR = coords[0]; - int texC = coords[1]; - int depth = coords[2]; - vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${width}.0, ${height}.0); - - vec4 values = ${glsl.texture2D}(A, uv); - float value; - if (depth == 0) { - value = values.r; - } else if (depth == 1) { - value = values.g; - } else if (depth == 2) { - value = values.b; - } else if (depth == 3) { - value = values.a; - } - - setOutput(floor(value * 255.0 + 0.5)); - } - `; - } -} diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/FromPixels_utils/from_pixels_packed_gpu.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/FromPixels_utils/from_pixels_packed_gpu.ts deleted file mode 100644 index dedff6891..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/FromPixels_utils/from_pixels_packed_gpu.ts +++ /dev/null @@ -1,68 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {getGlslDifferences} from '../../glsl_version'; -import {GPGPUProgram} from '../../gpgpu_math'; - -export class FromPixelsPackedProgram implements GPGPUProgram { - variableNames = ['A']; - userCode: string; - outputShape: number[]; - packedInputs = false; - packedOutput = true; - - constructor(outputShape: number[]) { - const glsl = getGlslDifferences(); - const [height, width, ] = outputShape; - this.outputShape = outputShape; - this.userCode = ` - void main() { - ivec3 coords = getOutputCoords(); - int texR = coords[0]; - int texC = coords[1]; - int depth = coords[2]; - - vec4 result = vec4(0.); - - for(int row=0; row<=1; row++) { - for(int col=0; col<=1; col++) { - texC = coords[1] + row; - depth = coords[2] + col; - - vec2 uv = (vec2(texC, texR) + halfCR) / - vec2(${width}.0, ${height}.0); - vec4 values = ${glsl.texture2D}(A, uv); - float value; - if (depth == 0) { - value = values.r; - } else if (depth == 1) { - value = values.g; - } else if (depth == 2) { - value = values.b; - } else if (depth == 3) { - value = values.a; - } - - result[row * 2 + col] = floor(value * 255.0 + 0.5); - } - } - - ${glsl.output} = result; - } - `; - } -} diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/FusedConv2D.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/FusedConv2D.ts deleted file mode 100644 index a142af98d..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/FusedConv2D.ts +++ /dev/null @@ -1,165 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, env, FusedConv2D, FusedConv2DAttrs, FusedConv2DInputs, KernelConfig, KernelFunc, TensorInfo, util} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {Conv2DProgram} from '../conv_gpu'; -import {Conv2DPackedProgram} from '../conv_packed_gpu'; -import {mapActivationToShaderProgram} from '../kernel_utils/kernel_funcs_utils'; - -import {conv2dByMatMul, conv2dWithIm2Row} from './Conv2D_impl'; -import {reshape} from './Reshape'; - -export function fusedConv2d(args: { - inputs: FusedConv2DInputs, - attrs: FusedConv2DAttrs, - backend: MathBackendWebGL -}) { - const {inputs, backend, attrs} = args; - const {x, filter, bias, preluActivationWeights} = inputs; - const { - strides, - pad, - dataFormat, - dilations, - dimRoundingMode, - activation, - leakyreluAlpha - } = attrs; - - const $dataFormat = backend_util.convertConv2DDataFormat(dataFormat); - const convInfo = backend_util.computeConv2DInfo( - x.shape as [number, number, number, number], - filter.shape as [number, number, number, number], strides, dilations, pad, - dimRoundingMode, false /* depthwise */, $dataFormat); - let out: TensorInfo; - const intermediates: TensorInfo[] = []; - - const hasBias = bias != null; - const hasPreluActivationWeights = preluActivationWeights != null; - const hasLeakyreluAlpha = activation === 'leakyrelu'; - - const prepareInputs = (): TensorInfo[] => { - const inputs: TensorInfo[] = [x, filter]; - - // If the input is a 1-D tensor, align it with the channels. - // - // For fusedConv2d, the inputs (x, W, bias, preluActivationWeights) are - // supposed to be aligned with the dataFormat. The 4-D tensor inputs or - // scalar inputs are originally aligned, but the 1-D tensor inputs are - // supposed to be aligned with the channels (only bias and PReLU activation - // weights could be a 1-D tensor). - const alignInputWithDataFormat = - (input: TensorInfo, dataFormat: 'NHWC'|'NCHW'): TensorInfo => { - if (dataFormat === 'NCHW' && input.shape.length === 1 && - input.shape[0] !== 1) { - const alignedInput = reshape({ - inputs: {x: input}, - backend, - attrs: {shape: [input.shape[0], 1, 1]} - }); - intermediates.push(alignedInput); - return alignedInput; - } - return input; - }; - - if (hasBias) { - inputs.push(alignInputWithDataFormat(bias, dataFormat)); - } - - if (hasPreluActivationWeights) { - inputs.push(alignInputWithDataFormat(preluActivationWeights, dataFormat)); - } - - if (hasLeakyreluAlpha) { - const $leakyreluAlpha = backend.makeTensorInfo( - [], 'float32', - util.createScalarValue(leakyreluAlpha as unknown as 'float32', 'float32')); - inputs.push($leakyreluAlpha); - intermediates.push($leakyreluAlpha); - } - return inputs; - }; - - if (convInfo.filterHeight === 1 && convInfo.filterWidth === 1 && - convInfo.dilationHeight === 1 && convInfo.dilationWidth === 1 && - convInfo.strideHeight === 1 && convInfo.strideWidth === 1 && - (convInfo.padInfo.type === 'SAME' || convInfo.padInfo.type === 'VALID')) { - out = conv2dByMatMul({ - x, - filter, - convInfo, - backend, - bias, - activation, - preluActivationWeights, - leakyreluAlpha - }); - } else if (convInfo.strideWidth <= 2 && $dataFormat === 'channelsLast' - && env().getBool('WEBGL_EXP_CONV') - ) { - const fusedActivation = - activation ? mapActivationToShaderProgram(activation, true) : null; - const program = new Conv2DPackedProgram( - convInfo, hasBias, fusedActivation, hasPreluActivationWeights, - hasLeakyreluAlpha); - const customValues = [ - [convInfo.padInfo.top, convInfo.padInfo.left], - [convInfo.strideHeight, convInfo.strideWidth], - [convInfo.dilationHeight, convInfo.dilationWidth], - [convInfo.inHeight, convInfo.inWidth] - ]; - const inputs = prepareInputs(); - out = backend.runWebGLProgram(program, inputs, 'float32', customValues); - } else if (env().getBool('WEBGL_CONV_IM2COL')) { - out = conv2dWithIm2Row({ - x, - filter, - convInfo, - backend, - bias, - activation, - preluActivationWeights, - leakyreluAlpha - }); - } else { - const fusedActivation = - activation ? mapActivationToShaderProgram(activation, false) : null; - const program = new Conv2DProgram( - convInfo, hasBias, fusedActivation, hasPreluActivationWeights, - hasLeakyreluAlpha); - - const inputs = prepareInputs(); - out = backend.runWebGLProgram(program, inputs, 'float32'); - } - - const outReshaped = - reshape({inputs: {x: out}, backend, attrs: {shape: convInfo.outShape}}); - - intermediates.push(out); - intermediates.forEach(t => backend.disposeIntermediateTensorInfo(t)); - - return outReshaped; -} - -export const fusedConv2DConfig: KernelConfig = { - kernelName: FusedConv2D, - backendName: 'webgl', - kernelFunc: fusedConv2d as unknown as KernelFunc, -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/FusedDepthwiseConv2D.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/FusedDepthwiseConv2D.ts deleted file mode 100644 index 0a57fb538..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/FusedDepthwiseConv2D.ts +++ /dev/null @@ -1,107 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, env, FusedDepthwiseConv2D, FusedDepthwiseConv2DAttrs, FusedDepthwiseConv2DInputs, KernelConfig, KernelFunc, TensorInfo, util} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {DepthwiseConv2DProgram} from '../conv_gpu_depthwise'; -import {DepthwiseConvPacked2DProgram} from '../conv_packed_gpu_depthwise'; -import {mapActivationToShaderProgram} from '../kernel_utils/kernel_funcs_utils'; - -export function fusedDepthwiseConv2D(args: { - inputs: FusedDepthwiseConv2DInputs, - attrs: FusedDepthwiseConv2DAttrs, - backend: MathBackendWebGL -}) { - const {inputs, backend, attrs} = args; - const {x, filter, bias, preluActivationWeights} = inputs; - const {strides, pad, dilations, dimRoundingMode, activation, leakyreluAlpha} = - attrs; - - const intermediates: TensorInfo[] = []; - - let $dilations = dilations; - if ($dilations == null) { - $dilations = [1, 1]; - } - - util.assert( - backend_util.eitherStridesOrDilationsAreOne(strides, $dilations), - () => 'Error in depthwiseConv2d: Either strides or dilations must be ' + - `1. Got strides ${strides} and dilations '${$dilations}'`); - - const convInfo = backend_util.computeConv2DInfo( - x.shape as [number, number, number, number], - filter.shape as [number, number, number, number], strides, $dilations, - pad, dimRoundingMode, true /* depthwise */); - - const shouldPackDepthwiseConv = env().getBool('WEBGL_PACK_DEPTHWISECONV') && - convInfo.strideWidth <= 2 && - convInfo.outChannels / convInfo.inChannels === 1; - const fusedActivation = activation ? - mapActivationToShaderProgram(activation, shouldPackDepthwiseConv) : - null; - const programInputs: TensorInfo[] = [x, filter]; - - const hasBias = bias != null; - const hasPreluActivationWeights = preluActivationWeights != null; - const hasLeakyreluAlpha = activation === 'leakyrelu'; - - if (hasBias) { - programInputs.push(bias); - } - if (hasPreluActivationWeights) { - programInputs.push(preluActivationWeights); - } - if (hasLeakyreluAlpha) { - const $leakyreluAlpha = backend.makeTensorInfo( - [], 'float32', - util.createScalarValue(leakyreluAlpha as unknown as 'float32', - 'float32')); - programInputs.push($leakyreluAlpha); - intermediates.push($leakyreluAlpha); - } - - let program: DepthwiseConv2DProgram|DepthwiseConvPacked2DProgram; - if (shouldPackDepthwiseConv) { - program = new DepthwiseConvPacked2DProgram( - convInfo, hasBias, fusedActivation, hasPreluActivationWeights, - hasLeakyreluAlpha); - } else { - program = new DepthwiseConv2DProgram( - convInfo, hasBias, fusedActivation, hasPreluActivationWeights, - hasLeakyreluAlpha); - } - const customValues = [ - [convInfo.padInfo.top, convInfo.padInfo.left], - [convInfo.strideHeight, convInfo.strideWidth], - [convInfo.dilationHeight, convInfo.dilationWidth], - [convInfo.inHeight, convInfo.inWidth] - ]; - const result = - backend.runWebGLProgram(program, programInputs, 'float32', customValues); - - intermediates.forEach(t => backend.disposeIntermediateTensorInfo(t)); - - return result; -} - -export const fusedDepthwiseConv2DConfig: KernelConfig = { - kernelName: FusedDepthwiseConv2D, - backendName: 'webgl', - kernelFunc: fusedDepthwiseConv2D as unknown as KernelFunc, -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/GatherNd.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/GatherNd.ts deleted file mode 100644 index 411b1e3d9..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/GatherNd.ts +++ /dev/null @@ -1,76 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, GatherNd, GatherNdInputs, KernelConfig, KernelFunc, Rank, TensorInfo, TypedArray, util} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {GatherNDProgram} from '../gather_nd_gpu'; -import {gatherNdImplCPU} from '../kernel_utils/shared'; - -import {reshape} from './Reshape'; - -export function gatherNd( - args: {inputs: GatherNdInputs, backend: MathBackendWebGL}): TensorInfo { - const {inputs, backend} = args; - const {params, indices} = inputs; - - const indicesShape = indices.shape; - const sliceRank = indicesShape[indicesShape.length - 1]; - const paramsSize = util.sizeFromShape(params.shape); - - const [resultShape, numSlices, sliceSize, strides] = - backend_util.prepareAndValidate(params, indices); - - const flattenIndices = reshape( - {inputs: {x: indices}, backend, attrs: {shape: [numSlices, sliceRank]}}); - const flattenX = reshape({ - inputs: {x: params}, - backend, - attrs: {shape: [(util.sizeFromShape(params.shape) / sliceSize), sliceSize]} - }); - - if (backend.shouldExecuteOnCPU([params, indices]) || - params.dtype === 'string') { - const indicesData = backend.readSync(indices.dataId) as TypedArray; - const paramsBuf = backend.bufferSync(params); - const outValue = gatherNdImplCPU( - indicesData, paramsBuf, params.dtype, numSlices, sliceRank, sliceSize, - strides, params.shape, paramsSize); - - return backend.makeTensorInfo(resultShape, params.dtype, outValue.values); - } - const program = - new GatherNDProgram(sliceRank, strides, [numSlices, sliceSize], - params.shape); - const res = backend.runWebGLProgram( - program, [flattenX, flattenIndices], flattenX.dtype); - - const reshaped = - reshape({inputs: {x: res}, backend, attrs: {shape: resultShape}}); - - backend.disposeIntermediateTensorInfo(flattenIndices); - backend.disposeIntermediateTensorInfo(flattenX); - backend.disposeIntermediateTensorInfo(res); - - return reshaped; -} - -export const gatherNdConfig: KernelConfig = { - kernelName: GatherNd, - backendName: 'webgl', - kernelFunc: gatherNd as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/GatherV2.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/GatherV2.ts deleted file mode 100644 index d29e984a0..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/GatherV2.ts +++ /dev/null @@ -1,109 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, GatherV2, GatherV2Attrs, GatherV2Inputs, KernelConfig, KernelFunc, TensorInfo, TypedArray, util, env} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {GatherProgram, GatherShape} from '../gather_gpu'; -import {gatherV2ImplCPU} from '../kernel_utils/shared'; - -import {reshape} from './Reshape'; - -export function gatherV2(args: { - inputs: GatherV2Inputs, - backend: MathBackendWebGL, - attrs: GatherV2Attrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {x, indices} = inputs; - const {axis, batchDims} = attrs; - - const parsedAxis = util.parseAxisParam(axis, x.shape)[0]; - if (env().get('DEBUG')) { - // In debug mode, throw error when any index is out of bound. - // Otherwise, just fill out of bounds with zeroes. - const indicesVals = backend.readSync(indices.dataId) as TypedArray; - const axisDim = x.shape[parsedAxis]; - for (let i = 0; i < indicesVals.length; ++i) { - const index = indicesVals[i]; - util.assert( - index <= axisDim - 1 && index >= 0, - () => - `GatherV2: the index value ${index} is not in [0, ${axisDim - 1}]`); - } - } - - const shapeInfo = backend_util.segment_util.collectGatherOpShapeInfo( - x, indices, parsedAxis, batchDims); - - const indicesSize = util.sizeFromShape(indices.shape); - - const toDispose = []; - - const flattenX = reshape({ - inputs: {x}, - backend, - attrs: { - shape: [ - shapeInfo.batchSize, shapeInfo.outerSize, shapeInfo.dimSize, - shapeInfo.sliceSize - ] - } - }); - - const flattenIndex = reshape({ - inputs: {x: indices}, - backend, - attrs: {shape: [shapeInfo.batchSize, indicesSize / shapeInfo.batchSize]} - }); - - toDispose.push(flattenX); - toDispose.push(flattenIndex); - - const flattenOutputShape = [ - shapeInfo.batchSize, shapeInfo.outerSize, indicesSize / shapeInfo.batchSize, - shapeInfo.sliceSize - ]; - - if (backend.shouldExecuteOnCPU([x, indices]) || x.dtype === 'string') { - const indicesBuf = backend.bufferSync(flattenIndex); - const xBuf = backend.bufferSync(flattenX); - const outBuf = gatherV2ImplCPU(xBuf, indicesBuf, flattenOutputShape); - - toDispose.forEach(t => backend.disposeIntermediateTensorInfo(t)); - - return backend.makeTensorInfo( - shapeInfo.outputShape, outBuf.dtype, outBuf.values as TypedArray); - } - - const program = new GatherProgram(flattenX.shape as GatherShape, - flattenOutputShape as GatherShape); - const res = backend.runWebGLProgram( - program, [flattenX, flattenIndex], flattenX.dtype); - toDispose.push(res); - - const reshaped = reshape( - {inputs: {x: res}, backend, attrs: {shape: shapeInfo.outputShape}}); - toDispose.forEach(t => backend.disposeIntermediateTensorInfo(t)); - return reshaped; -} - -export const gatherV2Config: KernelConfig = { - kernelName: GatherV2, - backendName: 'webgl', - kernelFunc: gatherV2 as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Greater.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Greater.ts deleted file mode 100644 index 7633c54f7..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Greater.ts +++ /dev/null @@ -1,39 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Greater, KernelConfig, KernelFunc} from '@tensorflow/tfjs-core'; - -import {binaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; -import {greaterImplCPU} from '../kernel_utils/shared'; - -const GREATER = `return float(a > b);`; -const GREATER_PACKED = ` - return vec4(greaterThan(a, b)); -`; - -export const greater = binaryKernelFunc({ - opSnippet: GREATER, - packedOpSnippet: GREATER_PACKED, - cpuKernelImpl: greaterImplCPU, - dtype: 'bool' -}); - -export const greaterConfig: KernelConfig = { - kernelName: Greater, - backendName: 'webgl', - kernelFunc: greater as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/GreaterEqual.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/GreaterEqual.ts deleted file mode 100644 index ecfb8f0ed..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/GreaterEqual.ts +++ /dev/null @@ -1,38 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {GreaterEqual, KernelConfig, KernelFunc} from '@tensorflow/tfjs-core'; -import {binaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; -import {greaterEqualImplCPU} from '../kernel_utils/shared'; - -const GREATER_EQUAL = `return float(a >= b);`; -const GREATER_EQUAL_PACKED = ` - return vec4(greaterThanEqual(a, b)); -`; - -export const greaterEqual = binaryKernelFunc({ - opSnippet: GREATER_EQUAL, - packedOpSnippet: GREATER_EQUAL_PACKED, - dtype: 'bool', - cpuKernelImpl: greaterEqualImplCPU -}); - -export const greaterEqualConfig: KernelConfig = { - kernelName: GreaterEqual, - backendName: 'webgl', - kernelFunc: greaterEqual as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/IFFT.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/IFFT.ts deleted file mode 100644 index e5775e785..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/IFFT.ts +++ /dev/null @@ -1,36 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {IFFT, IFFTInputs, KernelConfig, TensorInfo} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; - -import {fftImpl} from './FFT_impl'; - -export function ifft(args: {inputs: IFFTInputs, backend: MathBackendWebGL}): - TensorInfo { - const {inputs, backend} = args; - const {input} = inputs; - - return fftImpl(input, true /* inverse */, backend); -} - -export const ifftConfig: KernelConfig = { - kernelName: IFFT, - backendName: 'webgl', - kernelFunc: ifft -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Identity.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Identity.ts deleted file mode 100644 index b3b0b5441..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Identity.ts +++ /dev/null @@ -1,36 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Identity, IdentityInputs, KernelConfig, KernelFunc, TensorInfo} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; - -export function identity( - args: {inputs: IdentityInputs, backend: MathBackendWebGL}): TensorInfo { - const {inputs, backend} = args; - const {x} = inputs; - - backend.incRef(x.dataId); - - return {dataId: x.dataId, shape: x.shape, dtype: x.dtype}; -} - -export const identityConfig: KernelConfig = { - kernelName: Identity, - backendName: 'webgl', - kernelFunc: identity as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Imag.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Imag.ts deleted file mode 100644 index 630706da5..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Imag.ts +++ /dev/null @@ -1,36 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Imag, ImagInputs, KernelConfig, KernelFunc, TensorInfo} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {identity} from './Identity'; - -export function imag(args: {inputs: ImagInputs, backend: MathBackendWebGL}): - TensorInfo { - const {inputs, backend} = args; - const {input} = inputs; - const inputData = backend.texData.get(input.dataId); - - return identity({inputs: {x: inputData.complexTensorInfos.imag}, backend}); -} - -export const imagConfig: KernelConfig = { - kernelName: Imag, - backendName: 'webgl', - kernelFunc: imag as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/IsFinite.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/IsFinite.ts deleted file mode 100644 index 348ab22aa..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/IsFinite.ts +++ /dev/null @@ -1,29 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {IsFinite, KernelConfig} from '@tensorflow/tfjs-core'; -import {unaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; - -const IS_FINITE = `return float(!isnan(x) && !isinf(x));`; - -export const isFinite = unaryKernelFunc({opSnippet: IS_FINITE, dtype: 'bool'}); - -export const isFiniteConfig: KernelConfig = { - kernelName: IsFinite, - backendName: 'webgl', - kernelFunc: isFinite, -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/IsInf.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/IsInf.ts deleted file mode 100644 index 2621023cd..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/IsInf.ts +++ /dev/null @@ -1,29 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {IsInf, KernelConfig} from '@tensorflow/tfjs-core'; -import {unaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; - -const IS_INF = `return float(isinf(x));`; - -export const isInf = unaryKernelFunc({opSnippet: IS_INF, dtype: 'bool'}); - -export const isInfConfig: KernelConfig = { - kernelName: IsInf, - backendName: 'webgl', - kernelFunc: isInf, -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/IsNaN.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/IsNaN.ts deleted file mode 100644 index e0589fdb0..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/IsNaN.ts +++ /dev/null @@ -1,29 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {IsNan, KernelConfig} from '@tensorflow/tfjs-core'; -import {unaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; - -const IS_NAN = `return float(isnan(x));`; - -export const isNaN = unaryKernelFunc({opSnippet: IS_NAN, dtype: 'bool'}); - -export const isNaNConfig: KernelConfig = { - kernelName: IsNan, - backendName: 'webgl', - kernelFunc: isNaN, -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/LRN.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/LRN.ts deleted file mode 100644 index 1e7c5cb3c..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/LRN.ts +++ /dev/null @@ -1,42 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {env, KernelConfig, KernelFunc, LRN, LRNAttrs, LRNInputs, TensorInfo} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {LRNProgram} from '../lrn_gpu'; -import {LRNPackedProgram} from '../lrn_packed_gpu'; - -export const lrn = - (args: {inputs: LRNInputs, backend: MathBackendWebGL, attrs: LRNAttrs}): - TensorInfo => { - const {inputs, backend, attrs} = args; - const {x} = inputs; - const {depthRadius, bias, alpha, beta} = attrs; - - const program = env().getBool('WEBGL_PACK_NORMALIZATION') ? - new LRNPackedProgram(x.shape, depthRadius, bias, alpha, beta) : - new LRNProgram(x.shape, depthRadius, bias, alpha, beta); - return backend.runWebGLProgram(program, [x], x.dtype); - }; - -// tslint:disable-next-line: variable-name -export const LRNConfig: KernelConfig = { - kernelName: LRN, - backendName: 'webgl', - kernelFunc: lrn as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/LRNGrad.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/LRNGrad.ts deleted file mode 100644 index 099bcf2a9..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/LRNGrad.ts +++ /dev/null @@ -1,41 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, LRNGrad, LRNGradAttrs, LRNGradInputs, TensorInfo} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {LRNGradProgram} from '../lrn_grad_gpu'; - -export const lrnGrad = (args: { - inputs: LRNGradInputs, - backend: MathBackendWebGL, - attrs: LRNGradAttrs -}): TensorInfo => { - const {inputs, backend, attrs} = args; - const {x, y, dy} = inputs; - const {depthRadius, bias, alpha, beta} = attrs; - - const program = new LRNGradProgram(x.shape, depthRadius, bias, alpha, beta); - return backend.runWebGLProgram(program, [x, y, dy], x.dtype); -}; - -// tslint:disable-next-line: variable-name -export const LRNGradConfig: KernelConfig = { - kernelName: LRNGrad, - backendName: 'webgl', - kernelFunc: lrnGrad as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/LeakyRelu.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/LeakyRelu.ts deleted file mode 100644 index 69f1b2700..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/LeakyRelu.ts +++ /dev/null @@ -1,56 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {env, KernelConfig, KernelFunc, LeakyRelu, LeakyReluAttrs, LeakyReluInputs, TensorInfo, util} from '@tensorflow/tfjs-core'; -import {MathBackendWebGL} from '../backend_webgl'; -import {BinaryOpProgram} from '../binaryop_gpu'; -import {BinaryOpPackedProgram} from '../binaryop_packed_gpu'; - -export const LEAKYRELU = `return (a < 0.) ? b * a : a;`; -export const LEAKYRELU_PACKED = ` - vec4 aLessThanZero = vec4(lessThan(a, vec4(0.))); - return (aLessThanZero * (b * a)) + ((vec4(1.0) - aLessThanZero) * a); -`; - -export function leakyRelu(args: { - inputs: LeakyReluInputs, - backend: MathBackendWebGL, - attrs: LeakyReluAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {x} = inputs; - const {alpha} = attrs; - - const $alpha = backend.makeTensorInfo( - [], 'float32', - util.createScalarValue(alpha as unknown as 'float32', 'float32')); - - const program = env().getBool('WEBGL_PACK_BINARY_OPERATIONS') ? - new BinaryOpPackedProgram(LEAKYRELU_PACKED, x.shape, $alpha.shape) : - new BinaryOpProgram(LEAKYRELU, x.shape, $alpha.shape); - const result = backend.runWebGLProgram(program, [x, $alpha], 'float32'); - - backend.disposeIntermediateTensorInfo($alpha); - - return result; -} - -export const leakyReluConfig: KernelConfig = { - kernelName: LeakyRelu, - backendName: 'webgl', - kernelFunc: leakyRelu as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Less.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Less.ts deleted file mode 100644 index a3cc1e828..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Less.ts +++ /dev/null @@ -1,39 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, Less} from '@tensorflow/tfjs-core'; - -import {binaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; -import {lessImplCPU} from '../kernel_utils/shared'; - -const LESS = `return float(a < b);`; -const LESS_PACKED = ` - return vec4(lessThan(a, b)); -`; - -export const less = binaryKernelFunc({ - opSnippet: LESS, - packedOpSnippet: LESS_PACKED, - cpuKernelImpl: lessImplCPU, - dtype: 'bool' -}); - -export const lessConfig: KernelConfig = { - kernelName: Less, - backendName: 'webgl', - kernelFunc: less as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/LessEqual.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/LessEqual.ts deleted file mode 100644 index ae8d61947..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/LessEqual.ts +++ /dev/null @@ -1,39 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, LessEqual} from '@tensorflow/tfjs-core'; - -import {binaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; -import {lessEqualImplCPU} from '../kernel_utils/shared'; - -export const LESS_EQUAL = `return float(a <= b);`; -export const LESS_EQUAL_PACKED = ` - return vec4(lessThanEqual(a, b)); -`; - -export const lessEqual = binaryKernelFunc({ - opSnippet: LESS_EQUAL, - packedOpSnippet: LESS_EQUAL_PACKED, - cpuKernelImpl: lessEqualImplCPU, - dtype: 'bool' -}); - -export const lessEqualConfig: KernelConfig = { - kernelName: LessEqual, - backendName: 'webgl', - kernelFunc: lessEqual as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/LinSpace.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/LinSpace.ts deleted file mode 100644 index 759cfae89..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/LinSpace.ts +++ /dev/null @@ -1,37 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, LinSpace, LinSpaceAttrs, TensorInfo} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {linSpaceImplCPU} from '../kernel_utils/shared'; - -export function linSpace( - args: {backend: MathBackendWebGL, attrs: LinSpaceAttrs}): TensorInfo { - const {backend, attrs} = args; - const {start, stop, num} = attrs; - - // TODO: Use CPU implementation due to the precision problem in Safari. - const outVals = linSpaceImplCPU(start, stop, num); - return backend.makeTensorInfo([outVals.length], 'float32', outVals); -} - -export const linSpaceConfig: KernelConfig = { - kernelName: LinSpace, - backendName: 'webgl', - kernelFunc: linSpace as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Log.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Log.ts deleted file mode 100644 index 464aca16e..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Log.ts +++ /dev/null @@ -1,46 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, Log} from '@tensorflow/tfjs-core'; - -import {CHECK_NAN_SNIPPET_UNARY, unaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; -import {logImplCPU} from '../kernel_utils/shared'; - -// Windows chrome return 0 if the input is negative value. We will specifically -// return NaN if the input is 0 to solve compatiblity issue. -const LOG = CHECK_NAN_SNIPPET_UNARY + ` - return x < 0.0 ? 0./0. : log(x); -`; - -const LOG_PACKED = ` - vec4 result = log(x); - bvec4 isNaN = isnan(x); - result.r = isNaN.r ? x.r : (x.r < 0.0 ? 0./0. : result.r); - result.g = isNaN.g ? x.g : (x.g < 0.0 ? 0./0. : result.g); - result.b = isNaN.b ? x.b : (x.b < 0.0 ? 0./0. : result.b); - result.a = isNaN.a ? x.a : (x.a < 0.0 ? 0./0. : result.a); - return result; -`; - -export const log = unaryKernelFunc( - {opSnippet: LOG, packedOpSnippet: LOG_PACKED, cpuKernelImpl: logImplCPU}); - -export const logConfig: KernelConfig = { - kernelName: Log, - backendName: 'webgl', - kernelFunc: log as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Log1p.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Log1p.ts deleted file mode 100644 index 0cae2831c..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Log1p.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, Log1p} from '@tensorflow/tfjs-core'; - -import {CHECK_NAN_SNIPPET_UNARY, unaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; - -const LOG1P = CHECK_NAN_SNIPPET_UNARY + ` - return log(1.0 + x); -`; - -export const log1p = unaryKernelFunc({opSnippet: LOG1P}); - -export const log1pConfig: KernelConfig = { - kernelName: Log1p, - backendName: 'webgl', - kernelFunc: log1p, -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/LogicalAnd.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/LogicalAnd.ts deleted file mode 100644 index ef721ce6d..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/LogicalAnd.ts +++ /dev/null @@ -1,39 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, LogicalAnd} from '@tensorflow/tfjs-core'; - -import {binaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; - -const LOGICAL_AND = `return float(a >= 1.0 && b >= 1.0);`; -const LOGICAL_AND_PACKED = ` - return vec4( - vec4(greaterThanEqual(a, vec4(1.0))) * - vec4(greaterThanEqual(b, vec4(1.0)))); -`; - -export const logicalAnd = binaryKernelFunc({ - opSnippet: LOGICAL_AND, - packedOpSnippet: LOGICAL_AND_PACKED, - dtype: 'bool' -}); - -export const logicalAndConfig: KernelConfig = { - kernelName: LogicalAnd, - backendName: 'webgl', - kernelFunc: logicalAnd as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/LogicalNot.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/LogicalNot.ts deleted file mode 100644 index 8aab1eaa1..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/LogicalNot.ts +++ /dev/null @@ -1,29 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, LogicalNot} from '@tensorflow/tfjs-core'; -import {unaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; - -const LOGICAL_NOT = `return float(!(x >= 1.0));`; - -export const logicalNot = unaryKernelFunc({opSnippet: LOGICAL_NOT}); - -export const logicalNotConfig: KernelConfig = { - kernelName: LogicalNot, - backendName: 'webgl', - kernelFunc: logicalNot, -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/LogicalOr.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/LogicalOr.ts deleted file mode 100644 index a8832c80a..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/LogicalOr.ts +++ /dev/null @@ -1,37 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, LogicalOr} from '@tensorflow/tfjs-core'; - -import {binaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; - -const LOGICAL_OR = `return float(a >= 1.0 || b >= 1.0);`; -const LOGICAL_OR_PACKED = ` - return min( - vec4(greaterThanEqual(a, vec4(1.0))) + - vec4(greaterThanEqual(b, vec4(1.0))), - vec4(1.0)); -`; - -export const logicalOr = binaryKernelFunc( - {opSnippet: LOGICAL_OR, packedOpSnippet: LOGICAL_OR_PACKED, dtype: 'bool'}); - -export const logicalOrConfig: KernelConfig = { - kernelName: LogicalOr, - backendName: 'webgl', - kernelFunc: logicalOr as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Max.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Max.ts deleted file mode 100644 index 100bedeca..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Max.ts +++ /dev/null @@ -1,101 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelFunc, Max, MaxAttrs, MaxInputs, TensorInfo} from '@tensorflow/tfjs-core'; -import {backend_util, KernelConfig, TypedArray, util} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {maxImplCPU} from '../kernel_utils/shared'; - -import {maxImpl} from './Max_impl'; -import {transposeImpl, transposeImplCPU} from './Transpose_impl'; - -export function max( - args: {inputs: MaxInputs, backend: MathBackendWebGL, attrs: MaxAttrs}): - TensorInfo { - const {inputs, backend, attrs} = args; - const {x} = inputs; - const {reductionIndices, keepDims} = attrs; - - const xRank = x.shape.length; - - const origAxes = util.parseAxisParam(reductionIndices, x.shape); - let axes = origAxes; - const permutedAxes = backend_util.getAxesPermutation(axes, xRank); - const maxInputIsTransposed = permutedAxes != null; - const shouldExecuteOnCPU = backend.shouldExecuteOnCPU([x]); - - let maxInput = x; - if (maxInputIsTransposed) { - if (shouldExecuteOnCPU) { - const xTexData = backend.texData.get(maxInput.dataId); - const values = xTexData.values as TypedArray; - - const newShape: number[] = new Array(xRank); - for (let i = 0; i < newShape.length; i++) { - newShape[i] = x.shape[permutedAxes[i]]; - } - const maxInputValues = - transposeImplCPU(values, x.shape, x.dtype, permutedAxes, newShape); - - maxInput = backend.makeTensorInfo(newShape, x.dtype); - const maxInputData = backend.texData.get(maxInput.dataId); - maxInputData.values = maxInputValues; - } else { - maxInput = transposeImpl(x, permutedAxes, backend); - } - - axes = backend_util.getInnerMostAxes(axes.length, xRank); - } - - backend_util.assertAxesAreInnerMostDims('max', axes, xRank); - const [maxOutShape, reduceShape] = - backend_util.computeOutAndReduceShapes(maxInput.shape, axes); - - let outShape = maxOutShape; - if (keepDims) { - // rather than reshape at the end, set the target shape here. - outShape = backend_util.expandShapeToKeepDim(maxOutShape, origAxes); - } - - let out; - if (shouldExecuteOnCPU) { - const xTexData = backend.texData.get(maxInput.dataId); - const values = xTexData.values as TypedArray; - - const outValues = - maxImplCPU(values, util.sizeFromShape(reduceShape), outShape, x.dtype); - - out = backend.makeTensorInfo(outShape, x.dtype); - const outData = backend.texData.get(out.dataId); - outData.values = outValues; - } else { - out = maxImpl(maxInput, reduceShape, outShape, backend); - } - - if (maxInputIsTransposed) { - backend.disposeIntermediateTensorInfo(maxInput); - } - - return out; -} - -export const maxConfig: KernelConfig = { - kernelName: Max, - backendName: 'webgl', - kernelFunc: max as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/MaxPool.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/MaxPool.ts deleted file mode 100644 index ca029ecf7..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/MaxPool.ts +++ /dev/null @@ -1,55 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {backend_util, KernelConfig, KernelFunc, MaxPool, MaxPoolAttrs, MaxPoolInputs, TensorInfo, util} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {Pool2DProgram} from '../pool_gpu'; -import {assertNotComplex} from '../webgl_util'; -import {identity} from './Identity'; - -export function maxPool(args: { - inputs: MaxPoolInputs, - backend: MathBackendWebGL, - attrs: MaxPoolAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {x} = inputs; - assertNotComplex(x, 'maxPool'); - const {filterSize, strides, pad, dimRoundingMode} = attrs; - const dilations = 1; - - util.assert( - backend_util.eitherStridesOrDilationsAreOne(strides, dilations), - () => 'Error in maxPool: Either strides or dilations must be 1. ' + - `Got strides ${strides} and dilations '${dilations}'`); - - const convInfo = backend_util.computePool2DInfo( - x.shape as [number, number, number, number], filterSize, strides, - dilations, pad, dimRoundingMode); - if (convInfo.filterWidth === 1 && convInfo.filterHeight === 1 && - util.arraysEqual(convInfo.inShape, convInfo.outShape)) { - return identity({inputs: {x}, backend}); - } - const maxPoolProgram = new Pool2DProgram(convInfo, 'max', false); - return backend.runWebGLProgram(maxPoolProgram, [x], x.dtype); -} - -export const maxPoolConfig: KernelConfig = { - kernelName: MaxPool, - backendName: 'webgl', - kernelFunc: maxPool as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/MaxPool3D.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/MaxPool3D.ts deleted file mode 100644 index f7ad7eccc..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/MaxPool3D.ts +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {backend_util, KernelConfig, KernelFunc, MaxPool3D, MaxPool3DAttrs, MaxPool3DInputs, TensorInfo} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {Pool3DProgram} from '../pool_gpu'; - -export function maxPool3d(args: { - inputs: MaxPool3DInputs, - backend: MathBackendWebGL, - attrs: MaxPool3DAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {x} = inputs; - const {filterSize, strides, pad, dataFormat, dimRoundingMode} = attrs; - const dilations: [number, number, number] = [1, 1, 1]; - - const convInfo = backend_util.computePool3DInfo( - x.shape as [number, number, number, number, number], filterSize, strides, - dilations, pad, dimRoundingMode, dataFormat); - const maxPoolProgram = new Pool3DProgram(convInfo, 'max', false); - return backend.runWebGLProgram(maxPoolProgram, [x], x.dtype); -} - -export const maxPool3DConfig: KernelConfig = { - kernelName: MaxPool3D, - backendName: 'webgl', - kernelFunc: maxPool3d as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/MaxPool3DGrad.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/MaxPool3DGrad.ts deleted file mode 100644 index f7f83761c..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/MaxPool3DGrad.ts +++ /dev/null @@ -1,53 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {backend_util, KernelConfig, KernelFunc, MaxPool3DGrad, MaxPool3DGradAttrs, MaxPool3DGradInputs, TensorInfo} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {MaxPool3DBackpropProgram} from '../max_pool_backprop_gpu'; -import {Pool3DProgram} from '../pool_gpu'; - -export function maxPool3DGrad(args: { - inputs: MaxPool3DGradInputs, - backend: MathBackendWebGL, - attrs: MaxPool3DGradAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {dy, input} = inputs; - const x = input; - const {filterSize, strides, pad, dimRoundingMode} = attrs; - const dilations: [number, number, number] = [1, 1, 1]; - - const convInfo = backend_util.computePool3DInfo( - x.shape as [number, number, number, number, number], filterSize, strides, - dilations, pad, dimRoundingMode); - - const maxPool3dPositionsProgram = - new Pool3DProgram(convInfo, 'max', true /* get positions */); - const maxPool3dPositions = - backend.runWebGLProgram(maxPool3dPositionsProgram, [x], x.dtype); - const maxPoolBackpropProgram = new MaxPool3DBackpropProgram(convInfo); - const result = backend.runWebGLProgram( - maxPoolBackpropProgram, [dy, maxPool3dPositions], x.dtype); - backend.disposeIntermediateTensorInfo(maxPool3dPositions); - return result; -} - -export const maxPool3DGradConfig: KernelConfig = { - kernelName: MaxPool3DGrad, - backendName: 'webgl', - kernelFunc: maxPool3DGrad as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/MaxPoolGrad.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/MaxPoolGrad.ts deleted file mode 100644 index e8bf41f66..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/MaxPoolGrad.ts +++ /dev/null @@ -1,55 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {backend_util, KernelConfig, KernelFunc, MaxPoolGrad, MaxPoolGradAttrs, MaxPoolGradInputs, TensorInfo} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {MaxPool2DBackpropProgram} from '../max_pool_backprop_gpu'; -import {Pool2DProgram} from '../pool_gpu'; -import {assertNotComplex} from '../webgl_util'; - -export function maxPoolGrad(args: { - inputs: MaxPoolGradInputs, - backend: MathBackendWebGL, - attrs: MaxPoolGradAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {dy, input, output} = inputs; - const x = input; - assertNotComplex([input, output], 'maxPoolGrad'); - const {filterSize, strides, pad, dimRoundingMode} = attrs; - - const convInfo = backend_util.computePool2DInfo( - x.shape as [number, number, number, number], filterSize, strides, - 1 /* dilations */, pad, dimRoundingMode); - const getPositions = true; - const maxPoolPositionsProgram = - new Pool2DProgram(convInfo, 'max', getPositions); - const maxPoolPositions: TensorInfo = - backend.runWebGLProgram(maxPoolPositionsProgram, [x], x.dtype); - - const maxPoolBackPropProgram = new MaxPool2DBackpropProgram(convInfo); - const result = backend.runWebGLProgram( - maxPoolBackPropProgram, [dy, maxPoolPositions], x.dtype); - backend.disposeIntermediateTensorInfo(maxPoolPositions); - return result; -} - -export const maxPoolGradConfig: KernelConfig = { - kernelName: MaxPoolGrad, - backendName: 'webgl', - kernelFunc: maxPoolGrad as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/MaxPoolWithArgmax.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/MaxPoolWithArgmax.ts deleted file mode 100644 index 9012c1d0d..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/MaxPoolWithArgmax.ts +++ /dev/null @@ -1,52 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {MaxPoolWithArgmax, MaxPoolWithArgmaxAttrs, MaxPoolWithArgmaxInputs} from '@tensorflow/tfjs-core'; -import {backend_util, KernelConfig, util} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; - -import {maxPoolWithArgmaxImpl} from './MaxPoolWithArgmax_impl'; - -export const maxPoolWithArgmaxConfig: KernelConfig = { - kernelName: MaxPoolWithArgmax, - backendName: 'webgl', - kernelFunc: ({inputs, attrs, backend}) => { - const {x} = inputs as MaxPoolWithArgmaxInputs; - const {filterSize, strides, pad, includeBatchInIndex} = - attrs as unknown as MaxPoolWithArgmaxAttrs; - const webglBackend = backend as MathBackendWebGL; - - util.assert( - x.shape.length === 4, - () => `Error in maxPool: input must be rank 4 but got rank ${ - x.shape.length}.`); - const dilations: [number, number] = [1, 1]; - util.assert( - backend_util.eitherStridesOrDilationsAreOne(strides, dilations), - () => 'Error in maxPool: Either strides or dilations must be 1. ' + - `Got strides ${strides} and dilations '${dilations}'`); - - const convInfo = backend_util.computePool2DInfo( - x.shape as [number, number, number, number], filterSize, strides, - dilations, pad); - - const [result, indexes] = - maxPoolWithArgmaxImpl(x, includeBatchInIndex, convInfo, webglBackend); - return [result, indexes]; - } -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/MaxPoolWithArgmax_impl.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/MaxPoolWithArgmax_impl.ts deleted file mode 100644 index b6fbf5bff..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/MaxPoolWithArgmax_impl.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, TensorInfo} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {Pool2DProgram} from '../pool_gpu'; - -export function maxPoolWithArgmaxImpl( - x: TensorInfo, includeBatchInIndex: boolean, - convInfo: backend_util.Conv2DInfo, - backend: MathBackendWebGL): TensorInfo[] { - let program = new Pool2DProgram(convInfo, 'max', false); - const poolOutput = backend.runWebGLProgram(program, [x], 'float32'); - - program = new Pool2DProgram(convInfo, 'max', true, true, includeBatchInIndex); - const indexOutput = backend.runWebGLProgram(program, [x], 'float32'); - return [poolOutput, indexOutput]; -} diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Max_impl.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Max_impl.ts deleted file mode 100644 index d71086efd..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Max_impl.ts +++ /dev/null @@ -1,41 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {TensorInfo, util} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {reduce} from '../kernel_utils/reduce'; -import {reshape} from '../kernels/Reshape'; - -export function maxImpl( - x: TensorInfo, reduceShape: number[], outShape: number[], - backend: MathBackendWebGL): TensorInfo { - const inSize = util.sizeFromShape(reduceShape); - const xSize = util.sizeFromShape(x.shape); - const batchSize = xSize / inSize; - const reshapedInput = - reshape({inputs: {x}, attrs: {shape: [batchSize, inSize]}, backend}); - - const reduced = reduce(reshapedInput, x.dtype, 'max', backend); - const reshapedOutput = - reshape({inputs: {x: reduced}, attrs: {shape: outShape}, backend}); - - backend.disposeIntermediateTensorInfo(reshapedInput); - backend.disposeIntermediateTensorInfo(reduced); - - return reshapedOutput; -} diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Max_test.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Max_test.ts deleted file mode 100644 index e323b3c8f..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Max_test.ts +++ /dev/null @@ -1,40 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '@tensorflow/tfjs-core'; -// tslint:disable-next-line: no-imports-from-dist -import {ALL_ENVS, describeWithFlags} from '@tensorflow/tfjs-core/dist/jasmine_util'; - -describeWithFlags('Max', ALL_ENVS, () => { - it('does not have memory leak when calling reduce multiple times.', - async () => { - const beforeDataIds = tf.engine().backend.numDataIds(); - - // Input must be large enough to trigger multi-stage reduction. - const x = tf.ones([100, 100]); - const xMax = x.max(); - - const afterResDataIds = tf.engine().backend.numDataIds(); - expect(afterResDataIds).toEqual(beforeDataIds + 2); - - x.dispose(); - xMax.dispose(); - - const afterDisposeDataIds = tf.engine().backend.numDataIds(); - expect(afterDisposeDataIds).toEqual(beforeDataIds); - }); -}); diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Maximum.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Maximum.ts deleted file mode 100644 index 5c0176ba4..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Maximum.ts +++ /dev/null @@ -1,49 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, Maximum} from '@tensorflow/tfjs-core'; - -import {CHECK_NAN_SNIPPET} from '../binaryop_gpu'; -import {CHECK_NAN_SNIPPET_PACKED} from '../binaryop_packed_gpu'; -import {binaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; -import {maximumImplCPU} from '../kernel_utils/shared'; - -const MAXIMUM = CHECK_NAN_SNIPPET + ` - return max(a, b); -`; - -const MAXIMUM_PACKED = ` - vec4 result = vec4(max(a, b)); - bvec4 isNaNA = isnan(a); - bvec4 isNaNB = isnan(b); - bvec4 isNaN = bvec4(isNaNA.x || isNaNB.x, isNaNA.y || isNaNB.y, isNaNA.z || isNaNB.z, isNaNA.w || isNaNB.w); - ` + - CHECK_NAN_SNIPPET_PACKED + ` - return result; -`; - -export const maximum = binaryKernelFunc({ - opSnippet: MAXIMUM, - packedOpSnippet: MAXIMUM_PACKED, - cpuKernelImpl: maximumImplCPU -}); - -export const maximumConfig: KernelConfig = { - kernelName: Maximum, - backendName: 'webgl', - kernelFunc: maximum as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Mean.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Mean.ts deleted file mode 100644 index 9b0df6680..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Mean.ts +++ /dev/null @@ -1,84 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, KernelConfig, Mean, MeanAttrs, MeanInputs, TensorInfo, TypedArray, util} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; - -import {meanImpl} from './Mean_impl'; -import {transposeImpl, transposeImplCPU} from './Transpose_impl'; - -export const meanConfig: KernelConfig = { - kernelName: Mean, - backendName: 'webgl', - kernelFunc: ({inputs, attrs, backend}) => { - const {x} = inputs as MeanInputs; - const {keepDims, axis} = attrs as unknown as MeanAttrs; - const webglBackend = backend as MathBackendWebGL; - - const xRank = x.shape.length; - const origAxes = util.parseAxisParam(axis, x.shape); - - let axes = origAxes; - const permutedAxes = backend_util.getAxesPermutation(axes, xRank); - const meanInputIsTransposed = permutedAxes != null; - const shouldExecuteOnCPU = webglBackend.shouldExecuteOnCPU([x]); - - const intermediates: TensorInfo[] = []; - - let meanInput = x; - if (meanInputIsTransposed) { - if (shouldExecuteOnCPU) { - const xTexData = webglBackend.texData.get(meanInput.dataId); - const values = xTexData.values as TypedArray; - - const newShape: number[] = new Array(xRank); - for (let i = 0; i < newShape.length; i++) { - newShape[i] = x.shape[permutedAxes[i]]; - } - const meanInputValues = - transposeImplCPU(values, x.shape, x.dtype, permutedAxes, newShape); - - meanInput = webglBackend.makeTensorInfo(newShape, x.dtype); - const meanInputData = webglBackend.texData.get(meanInput.dataId); - meanInputData.values = meanInputValues; - } else { - meanInput = transposeImpl(x, permutedAxes, webglBackend); - } - - intermediates.push(meanInput); - axes = backend_util.getInnerMostAxes(axes.length, xRank); - } - - backend_util.assertAxesAreInnerMostDims('sum', axes, xRank); - const [meanOutShape, reduceShape] = - backend_util.computeOutAndReduceShapes(meanInput.shape, axes); - - let outShape = meanOutShape; - if (keepDims) { - // rather than reshape at the end, set the target shape here. - outShape = backend_util.expandShapeToKeepDim(meanOutShape, origAxes); - } - - const out = meanImpl(meanInput, reduceShape, outShape, webglBackend); - for (const i of intermediates) { - webglBackend.disposeIntermediateTensorInfo(i); - } - - return out; - } -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Mean_impl.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Mean_impl.ts deleted file mode 100644 index bc31918fb..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Mean_impl.ts +++ /dev/null @@ -1,41 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {TensorInfo, util} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {reduce} from '../kernel_utils/reduce'; -import {reshape} from '../kernels/Reshape'; - -export function meanImpl( - x: TensorInfo, reduceShape: number[], outShape: number[], - backend: MathBackendWebGL): TensorInfo { - const inSize = util.sizeFromShape(reduceShape); - const xSize = util.sizeFromShape(x.shape); - const batchSize = xSize / inSize; - const reshapedInput = - reshape({inputs: {x}, attrs: {shape: [batchSize, inSize]}, backend}); - - const reduced = reduce(reshapedInput, 'float32', 'mean', backend); - const reshapedOutput = - reshape({inputs: {x: reduced}, attrs: {shape: outShape}, backend}); - - backend.disposeIntermediateTensorInfo(reshapedInput); - backend.disposeIntermediateTensorInfo(reduced); - - return reshapedOutput; -} diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Mean_test.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Mean_test.ts deleted file mode 100644 index d2cd2f1e2..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Mean_test.ts +++ /dev/null @@ -1,44 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '@tensorflow/tfjs-core'; -import {test_util} from '@tensorflow/tfjs-core'; - -const {expectArraysClose} = test_util; -// tslint:disable-next-line: no-imports-from-dist -import {ALL_ENVS, describeWithFlags} from '@tensorflow/tfjs-core/dist/jasmine_util'; - -describeWithFlags('Mean.', ALL_ENVS, () => { - it('does not have memory leak and works for large dimensions.', async () => { - const beforeDataIds = tf.engine().backend.numDataIds(); - - const a = tf.ones([1, 70000]); - const r = tf.mean(a); - - expect(r.dtype).toBe('float32'); - expectArraysClose(await r.data(), 1); - - const afterResDataIds = tf.engine().backend.numDataIds(); - expect(afterResDataIds).toEqual(beforeDataIds + 2); - - a.dispose(); - r.dispose(); - - const afterDisposeDataIds = tf.engine().backend.numDataIds(); - expect(afterDisposeDataIds).toEqual(beforeDataIds); - }); -}); diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Min.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Min.ts deleted file mode 100644 index c79e000e1..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Min.ts +++ /dev/null @@ -1,74 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, KernelConfig, KernelFunc, Min, MinAttrs, MinInputs, TensorInfo, util} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {reduce} from '../kernel_utils/reduce'; - -import {reshape} from './Reshape'; -import {transpose} from './Transpose'; - -export function min( - args: {inputs: MinInputs, backend: MathBackendWebGL, attrs: MinAttrs}): - TensorInfo { - const {inputs, backend, attrs} = args; - const {x} = inputs; - const {axis, keepDims} = attrs; - - const xRank = x.shape.length; - - const origAxes = util.parseAxisParam(axis, x.shape); - let axes = origAxes; - const permutedAxes = backend_util.getAxesPermutation(axes, xRank); - let permutedX = x; - if (permutedAxes != null) { - permutedX = transpose({inputs: {x}, backend, attrs: {perm: permutedAxes}}); - axes = backend_util.getInnerMostAxes(axes.length, x.shape.length); - } - - backend_util.assertAxesAreInnerMostDims('min', axes, xRank); - const [outShape, reduceShape] = - backend_util.computeOutAndReduceShapes(permutedX.shape, axes); - const inSize = util.sizeFromShape(reduceShape); - const a2D = - reshape({inputs: {x: permutedX}, backend, attrs: {shape: [-1, inSize]}}); - const reduced = reduce(a2D, a2D.dtype, 'min', backend); - - let res; - if (keepDims) { - const newShape = backend_util.expandShapeToKeepDim(outShape, origAxes); - res = reshape({inputs: {x: reduced}, backend, attrs: {shape: newShape}}); - } else { - res = reshape({inputs: {x: reduced}, backend, attrs: {shape: outShape}}); - } - - backend.disposeIntermediateTensorInfo(a2D); - backend.disposeIntermediateTensorInfo(reduced); - - if (permutedAxes != null) { - backend.disposeIntermediateTensorInfo(permutedX); - } - - return res; -} - -export const minConfig: KernelConfig = { - kernelName: Min, - backendName: 'webgl', - kernelFunc: min as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Minimum.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Minimum.ts deleted file mode 100644 index d503982a6..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Minimum.ts +++ /dev/null @@ -1,49 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, Minimum} from '@tensorflow/tfjs-core'; - -import {CHECK_NAN_SNIPPET} from '../binaryop_gpu'; -import {CHECK_NAN_SNIPPET_PACKED} from '../binaryop_packed_gpu'; -import {binaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; -import {minimumImplCPU} from '../kernel_utils/shared'; - -const MINIMUM = CHECK_NAN_SNIPPET + ` - return min(a, b); -`; - -const MINIMUM_PACKED = ` - vec4 result = vec4(min(a, b)); - bvec4 isNaNA = isnan(a); - bvec4 isNaNB = isnan(b); - bvec4 isNaN = bvec4(isNaNA.x || isNaNB.x, isNaNA.y || isNaNB.y, isNaNA.z || isNaNB.z, isNaNA.w || isNaNB.w); - ` + - CHECK_NAN_SNIPPET_PACKED + ` - return result; -`; - -export const minimum = binaryKernelFunc({ - opSnippet: MINIMUM, - packedOpSnippet: MINIMUM_PACKED, - cpuKernelImpl: minimumImplCPU -}); - -export const minimumConfig: KernelConfig = { - kernelName: Minimum, - backendName: 'webgl', - kernelFunc: minimum as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/MirrorPad.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/MirrorPad.ts deleted file mode 100644 index 2c6ac647c..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/MirrorPad.ts +++ /dev/null @@ -1,45 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {env, KernelConfig, KernelFunc, MirrorPad, MirrorPadAttrs, MirrorPadInputs, TensorInfo} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {MirrorPadProgram} from '../mirror_pad_gpu'; -import {MirrorPadPackedProgram} from '../mirror_pad_packed_gpu'; - -export const mirrorPadKernelFunc: (params: { - inputs: MirrorPadInputs, - backend: MathBackendWebGL, - attrs: MirrorPadAttrs -}) => TensorInfo = ({inputs, backend, attrs}) => { - const {x} = inputs; - const {paddings, mode} = attrs; - - const program = env().getBool('WEBGL_PACK_ARRAY_OPERATIONS') ? - new MirrorPadPackedProgram(x.shape, paddings, mode) : - new MirrorPadProgram(x.shape, paddings, mode); - - const output = backend.runWebGLProgram(program, [x], x.dtype); - - return output; -}; - -export const mirrorPadConfig: KernelConfig = { - kernelName: MirrorPad, - backendName: 'webgl', - kernelFunc: mirrorPadKernelFunc as unknown as KernelFunc, -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Mod.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Mod.ts deleted file mode 100644 index c0ebda2f8..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Mod.ts +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, Mod} from '@tensorflow/tfjs-core'; - -import {CHECK_NAN_SNIPPET_PACKED} from '../binaryop_packed_gpu'; -import {binaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; - -const MOD = `if (b == 0.0) return NAN; - return mod(a, b);`; - -const MOD_PACKED = ` - vec4 result = mod(a, b); - bvec4 isNaN = equal(b, vec4(0.0)); - ` + - CHECK_NAN_SNIPPET_PACKED + ` - return result; -`; - -export const mod = binaryKernelFunc({ - opSnippet: MOD, - packedOpSnippet: MOD_PACKED, -}); - -export const modConfig: KernelConfig = { - kernelName: Mod, - backendName: 'webgl', - kernelFunc: mod as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Multinomial.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Multinomial.ts deleted file mode 100644 index 160241d00..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Multinomial.ts +++ /dev/null @@ -1,53 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, Multinomial, MultinomialAttrs, MultinomialInputs, TensorInfo} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {MultinomialProgram} from '../multinomial_gpu'; - -import {softmax} from './Softmax'; - -export function multinomial(args: { - inputs: MultinomialInputs, - backend: MathBackendWebGL, - attrs: MultinomialAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {logits} = inputs; - const {numSamples, seed, normalized} = attrs; - - const probs = normalized ? - logits : - softmax( - {inputs: {logits}, backend, attrs: {dim: logits.shape.length - 1}}); - const batchSize = probs.shape[0]; - const numOutcomes = probs.shape[1]; - const program = new MultinomialProgram(batchSize, numOutcomes, numSamples); - const customValues = [[seed]]; - const res = backend.runWebGLProgram(program, [probs], 'int32', customValues); - if (!normalized) { - backend.disposeIntermediateTensorInfo(probs); - } - return res; -} - -export const multinomialConfig: KernelConfig = { - kernelName: Multinomial, - backendName: 'webgl', - kernelFunc: multinomial as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Multiply.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Multiply.ts deleted file mode 100644 index ec5b94da1..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Multiply.ts +++ /dev/null @@ -1,109 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, BinaryInputs, env, KernelConfig, Multiply, TensorInfo, TypedArray} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import * as binaryop_complex_gpu from '../binaryop_complex_gpu'; -import {BinaryOpComplexProgram} from '../binaryop_complex_gpu'; -import {BinaryOpProgram} from '../binaryop_gpu'; -import {BinaryOpPackedProgram} from '../binaryop_packed_gpu'; -import {multiplyImplCPU as cpuMultiply} from '../kernel_utils/shared'; - -import {complex} from './Complex'; - -const MUL = 'return a * b;'; - -export function multiply( - args: {inputs: BinaryInputs, backend: MathBackendWebGL}): TensorInfo { - const {inputs, backend} = args; - const {a, b} = inputs; - const dtype = backend_util.upcastType(a.dtype, b.dtype); - - if (a.dtype === 'complex64') { - const aData = backend.texData.get(a.dataId); - const bData = backend.texData.get(b.dataId); - - const realProgram = new BinaryOpComplexProgram( - binaryop_complex_gpu.COMPLEX_MULTIPLY.REAL, a.shape, b.shape); - const imagProgram = new BinaryOpComplexProgram( - binaryop_complex_gpu.COMPLEX_MULTIPLY.IMAG, a.shape, b.shape); - - const inputs = [ - { - dataId: aData.complexTensorInfos.real.dataId, - dtype: aData.complexTensorInfos.real.dtype, - shape: a.shape - }, - { - dataId: aData.complexTensorInfos.imag.dataId, - dtype: aData.complexTensorInfos.imag.dtype, - shape: a.shape - }, - { - dataId: bData.complexTensorInfos.real.dataId, - dtype: bData.complexTensorInfos.real.dtype, - shape: b.shape - }, - { - dataId: bData.complexTensorInfos.imag.dataId, - dtype: bData.complexTensorInfos.imag.dtype, - shape: b.shape - } - ]; - - const realPart = backend.runWebGLProgram(realProgram, inputs, 'float32'); - const imagPart = backend.runWebGLProgram(imagProgram, inputs, 'float32'); - - const complexOutput = - complex({inputs: {real: realPart, imag: imagPart}, backend}); - - backend.disposeIntermediateTensorInfo(realPart); - backend.disposeIntermediateTensorInfo(imagPart); - - // TODO(annxingyuan): CPU forwarding for complex inputs. - return complexOutput; - } - - if (backend.shouldExecuteOnCPU([a, b])) { - const aData = backend.texData.get(a.dataId); - const bData = backend.texData.get(b.dataId); - const [outValues, outShape] = cpuMultiply( - a.shape, b.shape, aData.values as TypedArray, - bData.values as TypedArray, dtype); - - const out = backend.makeTensorInfo(outShape, dtype); - const outData = backend.texData.get(out.dataId); - outData.values = outValues; - return out; - } - - let program: BinaryOpProgram|BinaryOpPackedProgram; - if (env().getBool('WEBGL_PACK_BINARY_OPERATIONS')) { - program = new BinaryOpPackedProgram(MUL, a.shape, b.shape); - } else { - program = new BinaryOpProgram(MUL, a.shape, b.shape); - } - - return backend.runWebGLProgram(program, [a, b], dtype); -} - -export const multiplyConfig: KernelConfig = { - kernelName: Multiply, - backendName: 'webgl', - kernelFunc: multiply -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Neg.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Neg.ts deleted file mode 100644 index 9d24ec27b..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Neg.ts +++ /dev/null @@ -1,69 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {env, KernelConfig, KernelFunc, Neg, NegInputs, TensorInfo, TypedArray} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {negImplCPU} from '../kernel_utils/shared'; -import {CHECK_NAN_SNIPPET, UnaryOpProgram} from '../unaryop_gpu'; -import {UnaryOpPackedProgram} from '../unaryop_packed_gpu'; - -const NEG = CHECK_NAN_SNIPPET + ` - return -x; -`; - -const NEG_PACKED = ` - vec4 result = -x; - bvec4 isNaN = isnan(x); - - result.r = isNaN.r ? x.r : result.r; - result.g = isNaN.g ? x.g : result.g; - result.b = isNaN.b ? x.b : result.b; - result.a = isNaN.a ? x.a : result.a; - - return result; -`; - -// This doesn't use unaryKernelFunc because negImplCPU is not of type -// SimpleUnaryKernelImplCPU. -export function neg(args: {inputs: NegInputs, backend: MathBackendWebGL}): - TensorInfo { - const {inputs, backend} = args; - const {x} = inputs; - - if (backend.shouldExecuteOnCPU([x])) { - const xData = backend.texData.get(x.dataId); - const [outValues, newShape] = - negImplCPU(xData.values as TypedArray, x.shape, x.dtype); - return backend.makeTensorInfo(newShape, x.dtype, outValues); - } - - let program: UnaryOpProgram|UnaryOpPackedProgram; - if (env().getBool('WEBGL_PACK_UNARY_OPERATIONS')) { - program = new UnaryOpPackedProgram(x.shape, NEG_PACKED); - } else { - program = new UnaryOpProgram(x.shape, NEG); - } - - return backend.runWebGLProgram(program, [x], x.dtype); -} - -export const negConfig: KernelConfig = { - kernelName: Neg, - backendName: 'webgl', - kernelFunc: neg as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/NonMaxSuppressionV3.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/NonMaxSuppressionV3.ts deleted file mode 100644 index 8dc607551..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/NonMaxSuppressionV3.ts +++ /dev/null @@ -1,50 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, kernel_impls, KernelConfig, KernelFunc, NonMaxSuppressionV3, NonMaxSuppressionV3Attrs, NonMaxSuppressionV3Inputs, TypedArray} from '@tensorflow/tfjs-core'; - -const nonMaxSuppressionV3Impl = kernel_impls.nonMaxSuppressionV3Impl; -import {MathBackendWebGL} from '../backend_webgl'; - -export function nonMaxSuppressionV3(args: { - inputs: NonMaxSuppressionV3Inputs, - backend: MathBackendWebGL, - attrs: NonMaxSuppressionV3Attrs -}) { - backend_util.warn( - 'tf.nonMaxSuppression() in webgl locks the UI thread. ' + - 'Call tf.nonMaxSuppressionAsync() instead'); - - const {inputs, backend, attrs} = args; - const {boxes, scores} = inputs; - const {maxOutputSize, iouThreshold, scoreThreshold} = attrs; - - const boxesVals = backend.readSync(boxes.dataId) as TypedArray; - const scoresVals = backend.readSync(scores.dataId) as TypedArray; - - const {selectedIndices} = nonMaxSuppressionV3Impl( - boxesVals, scoresVals, maxOutputSize, iouThreshold, scoreThreshold); - - return backend.makeTensorInfo( - [selectedIndices.length], 'int32', new Int32Array(selectedIndices)); -} - -export const nonMaxSuppressionV3Config: KernelConfig = { - kernelName: NonMaxSuppressionV3, - backendName: 'webgl', - kernelFunc: nonMaxSuppressionV3 as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/NonMaxSuppressionV4.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/NonMaxSuppressionV4.ts deleted file mode 100644 index 5b537b457..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/NonMaxSuppressionV4.ts +++ /dev/null @@ -1,55 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, kernel_impls, KernelConfig, KernelFunc, NonMaxSuppressionV4, NonMaxSuppressionV4Attrs, NonMaxSuppressionV4Inputs, TensorInfo, TypedArray} from '@tensorflow/tfjs-core'; -const nonMaxSuppressionV4Impl = kernel_impls.nonMaxSuppressionV4Impl; - -import {MathBackendWebGL} from '../backend_webgl'; - -export function nonMaxSuppressionV4(args: { - inputs: NonMaxSuppressionV4Inputs, - backend: MathBackendWebGL, - attrs: NonMaxSuppressionV4Attrs -}): [TensorInfo, TensorInfo] { - backend_util.warn( - 'tf.nonMaxSuppression() in webgl locks the UI thread. ' + - 'Call tf.nonMaxSuppressionAsync() instead'); - - const {inputs, backend, attrs} = args; - const {boxes, scores} = inputs; - const {maxOutputSize, iouThreshold, scoreThreshold, padToMaxOutputSize} = - attrs; - - const boxesVals = backend.readSync(boxes.dataId) as TypedArray; - const scoresVals = backend.readSync(scores.dataId) as TypedArray; - - const {selectedIndices, validOutputs} = nonMaxSuppressionV4Impl( - boxesVals, scoresVals, maxOutputSize, iouThreshold, scoreThreshold, - padToMaxOutputSize); - - return [ - backend.makeTensorInfo( - [selectedIndices.length], 'int32', new Int32Array(selectedIndices)), - backend.makeTensorInfo([], 'int32', new Int32Array([validOutputs])) - ]; -} - -export const nonMaxSuppressionV4Config: KernelConfig = { - kernelName: NonMaxSuppressionV4, - backendName: 'webgl', - kernelFunc: nonMaxSuppressionV4 as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/NonMaxSuppressionV5.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/NonMaxSuppressionV5.ts deleted file mode 100644 index ab947502d..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/NonMaxSuppressionV5.ts +++ /dev/null @@ -1,60 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, kernel_impls, KernelConfig, KernelFunc, NonMaxSuppressionV5, NonMaxSuppressionV5Attrs, NonMaxSuppressionV5Inputs, TensorInfo, TypedArray} from '@tensorflow/tfjs-core'; - -const nonMaxSuppressionV5Impl = kernel_impls.nonMaxSuppressionV5Impl; -import {MathBackendWebGL} from '../backend_webgl'; - -export function nonMaxSuppressionV5(args: { - inputs: NonMaxSuppressionV5Inputs, - backend: MathBackendWebGL, - attrs: NonMaxSuppressionV5Attrs -}): [TensorInfo, TensorInfo] { - backend_util.warn( - 'tf.nonMaxSuppression() in webgl locks the UI thread. ' + - 'Call tf.nonMaxSuppressionAsync() instead'); - - const {inputs, backend, attrs} = args; - const {boxes, scores} = inputs; - const {maxOutputSize, iouThreshold, scoreThreshold, softNmsSigma} = attrs; - - const boxesVals = backend.readSync(boxes.dataId) as TypedArray; - const scoresVals = backend.readSync(scores.dataId) as TypedArray; - - const maxOutputSizeVal = maxOutputSize; - const iouThresholdVal = iouThreshold; - const scoreThresholdVal = scoreThreshold; - const softNmsSigmaVal = softNmsSigma; - - const {selectedIndices, selectedScores} = nonMaxSuppressionV5Impl( - boxesVals, scoresVals, maxOutputSizeVal, iouThresholdVal, - scoreThresholdVal, softNmsSigmaVal); - - return [ - backend.makeTensorInfo( - [selectedIndices.length], 'int32', new Int32Array(selectedIndices)), - backend.makeTensorInfo( - [selectedScores.length], 'float32', new Float32Array(selectedScores)) - ]; -} - -export const nonMaxSuppressionV5Config: KernelConfig = { - kernelName: NonMaxSuppressionV5, - backendName: 'webgl', - kernelFunc: nonMaxSuppressionV5 as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/NotEqual.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/NotEqual.ts deleted file mode 100644 index 283bde4cf..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/NotEqual.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {NotEqual} from '@tensorflow/tfjs-core'; -import {KernelConfig} from '@tensorflow/tfjs-core'; -import {binaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; -import {notEqualImplCPU} from '../kernel_utils/shared'; - -const NOT_EQUAL = `return float(a != b);`; - -export const notEqual = binaryKernelFunc( - {opSnippet: NOT_EQUAL, cpuKernelImpl: notEqualImplCPU, dtype: 'bool'}); - -export const notEqualConfig: KernelConfig = { - kernelName: NotEqual, - backendName: 'webgl', - kernelFunc: notEqual, -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/OneHot.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/OneHot.ts deleted file mode 100644 index 752c3f68b..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/OneHot.ts +++ /dev/null @@ -1,50 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, OneHot, OneHotAttrs, OneHotInputs, TensorInfo, util} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {OneHotProgram} from '../onehot_gpu'; -import {reshape} from './Reshape'; - -export const oneHot = (args: { - inputs: OneHotInputs, - backend: MathBackendWebGL, - attrs: OneHotAttrs -}): TensorInfo => { - const {inputs, backend, attrs} = args; - const {indices} = inputs; - const {dtype, depth, onValue, offValue} = attrs; - - const indicesSize = util.sizeFromShape(indices.shape); - const program = new OneHotProgram(indicesSize, depth, onValue, offValue); - const reshaped = - reshape({inputs: {x: indices}, backend, attrs: {shape: [indicesSize]}}); - const result = backend.runWebGLProgram(program, [reshaped], dtype); - backend.disposeIntermediateTensorInfo(reshaped); - - const outShape = [...indices.shape, depth]; - const out = reshape({inputs: {x: result}, backend, attrs: {shape: outShape}}); - backend.disposeIntermediateTensorInfo(result); - return out; -}; - -export const oneHotConfig: KernelConfig = { - kernelName: OneHot, - backendName: 'webgl', - kernelFunc: oneHot as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/OnesLike.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/OnesLike.ts deleted file mode 100644 index 2f5ac1275..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/OnesLike.ts +++ /dev/null @@ -1,60 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, OnesLike, OnesLikeInputs, TensorInfo} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; - -import {complex} from './Complex'; -import {fill} from './Fill'; -import {imag} from './Imag'; -import {real} from './Real'; -import {zerosLike} from './ZerosLike'; - -export function onesLike( - args: {inputs: OnesLikeInputs, backend: MathBackendWebGL}): TensorInfo { - const {inputs, backend} = args; - const {x} = inputs; - - if (x.dtype === 'string') { - throw new Error('onesLike is not supported under string dtype'); - } else if (x.dtype === 'complex64') { - const realPart = real({inputs: {input: x}, backend}); - const r = onesLike({inputs: {x: realPart}, backend}); - const imagPart = imag({inputs: {input: x}, backend}); - const i = zerosLike({inputs: {x: imagPart}, backend}); - - const result = complex({inputs: {real: r, imag: i}, backend}); - - backend.disposeIntermediateTensorInfo(realPart); - backend.disposeIntermediateTensorInfo(r); - backend.disposeIntermediateTensorInfo(imagPart); - backend.disposeIntermediateTensorInfo(i); - - return result; - } else { - // TODO(cais, smilkov): Add WebGL shader for onesLike: - // https://github.com/tensorflow/tfjs/issues/1293 - return fill({attrs: {shape: x.shape, dtype: x.dtype, value: 1}, backend}); - } -} - -export const onesLikeConfig: KernelConfig = { - kernelName: OnesLike, - backendName: 'webgl', - kernelFunc: onesLike as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Pack.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Pack.ts deleted file mode 100644 index caa7008e2..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Pack.ts +++ /dev/null @@ -1,67 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, Pack, PackAttrs, PackInputs, TensorInfo, util} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {concat} from './Concat'; -import {expandDims} from './ExpandDims'; - -export function pack( - args: {inputs: PackInputs, backend: MathBackendWebGL, attrs: PackAttrs}): - TensorInfo { - const {inputs, backend, attrs} = args; - const {axis} = attrs; - - if (inputs.length === 1) { - return expandDims( - {inputs: {input: inputs[0]}, backend, attrs: {dim: axis}}); - } - - const shape = inputs[0].shape; - const dtype = inputs[0].dtype; - - inputs.forEach(t => { - util.assertShapesMatch( - shape, t.shape, - 'All tensors passed to stack must have matching shapes'); - util.assert( - dtype === t.dtype, - () => 'All tensors passed to stack must have matching dtypes'); - }); - - const intermediateTensorInfos: TensorInfo[] = []; - const expandedTensors = inputs.map(t => { - const expandedT = - expandDims({inputs: {input: t}, backend, attrs: {dim: axis}}); - intermediateTensorInfos.push(expandedT); - return expandedT; - }); - - const result = concat({inputs: expandedTensors, backend, attrs: {axis}}); - - intermediateTensorInfos.forEach( - t => backend.disposeIntermediateTensorInfo(t)); - - return result; -} - -export const packConfig: KernelConfig = { - kernelName: Pack, - backendName: 'webgl', - kernelFunc: pack as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/PadV2.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/PadV2.ts deleted file mode 100644 index e52a66855..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/PadV2.ts +++ /dev/null @@ -1,55 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {env, KernelConfig, KernelFunc, PadV2, PadV2Attrs, PadV2Inputs, TensorInfo, util} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {PadProgram} from '../pad_gpu'; -import {PadPackedProgram} from '../pad_packed_gpu'; -import {fill} from './Fill'; - -export const padV2 = - (args: {inputs: PadV2Inputs, backend: MathBackendWebGL, attrs: PadV2Attrs}): - TensorInfo => { - const {inputs, backend, attrs} = args; - const {x} = inputs; - const {paddings, constantValue} = attrs; - - if (util.sizeFromShape(x.shape) === 0) { - // Short-circuit the computation, since x doesn't have value, only - // the shape is used to compute output shape to pad. - const outputShape = paddings.map( - (p, i) => - p[0] /* beforePad */ + x.shape[i] + p[1] /* afterPad */); - return fill({ - backend, - attrs: {shape: outputShape, value: constantValue, dtype: x.dtype} - }); - } - - const program = env().getBool('WEBGL_PACK_ARRAY_OPERATIONS') ? - new PadPackedProgram(x.shape, paddings, constantValue) : - new PadProgram(x.shape, paddings, constantValue); - const customValues = [[constantValue]]; - return backend.runWebGLProgram(program, [x], x.dtype, customValues); - }; - -export const padV2Config: KernelConfig = { - kernelName: PadV2, - backendName: 'webgl', - kernelFunc: padV2 as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Pow.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Pow.ts deleted file mode 100644 index f5ec3ab2f..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Pow.ts +++ /dev/null @@ -1,62 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, Pow} from '@tensorflow/tfjs-core'; - -import {CHECK_NAN_SNIPPET_PACKED} from '../binaryop_packed_gpu'; -import {binaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; - -const POW = ` - if(a < 0.0 && floor(b) < b){ - return NAN; - } - if (b == 0.0) { - return 1.0; - } - return (round(mod(b, 2.0)) != 1) ? - pow(abs(a), b) : sign(a) * pow(abs(a), b); -`; - -const POW_PACKED = ` - // isModRound1 has 1 for components with round(mod(b, 2.0)) == 1, 0 otherwise. - vec4 isModRound1 = vec4(equal(round(mod(b, 2.0)), ivec4(1))); - vec4 multiplier = sign(a) * isModRound1 + (vec4(1.0) - isModRound1); - vec4 result = multiplier * pow(abs(a), b); - - // Ensure that a^0 = 1, including 0^0 = 1 as this correspond to TF and JS - bvec4 isExpZero = equal(b, vec4(0.0)); - result.r = isExpZero.r ? 1.0 : result.r; - result.g = isExpZero.g ? 1.0 : result.g; - result.b = isExpZero.b ? 1.0 : result.b; - result.a = isExpZero.a ? 1.0 : result.a; - - bvec4 isNaN1 = lessThan(a, vec4(0.0)); - bvec4 isNaN2 = lessThan(floor(b), b); - bvec4 isNaN = bvec4(isNaN1.x && isNaN2.x, isNaN1.y && isNaN2.y, isNaN1.z && isNaN2.z, isNaN1.w && isNaN2.w); - ` + - CHECK_NAN_SNIPPET_PACKED + ` - return result; -`; - -export const pow = - binaryKernelFunc({opSnippet: POW, packedOpSnippet: POW_PACKED}); - -export const powConfig: KernelConfig = { - kernelName: Pow, - backendName: 'webgl', - kernelFunc: pow as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Prelu.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Prelu.ts deleted file mode 100644 index d60d04088..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Prelu.ts +++ /dev/null @@ -1,45 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {env, KernelConfig, KernelFunc, Prelu, PreluInputs, TensorInfo} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {BinaryOpProgram} from '../binaryop_gpu'; -import {BinaryOpPackedProgram} from '../binaryop_packed_gpu'; - -export const PRELU = `return (a < 0.) ? b * a : a;`; -export const PRELU_PACKED = ` - vec4 aLessThanZero = vec4(lessThan(a, vec4(0.))); - return (aLessThanZero * (b * a)) + ((vec4(1.0) - aLessThanZero) * a); -`; - -export function prelu(args: {inputs: PreluInputs, backend: MathBackendWebGL}): - TensorInfo { - const {inputs, backend} = args; - const {x, alpha} = inputs; - - const program = env().getBool('WEBGL_PACK_BINARY_OPERATIONS') ? - new BinaryOpPackedProgram(PRELU_PACKED, x.shape, alpha.shape) : - new BinaryOpProgram(PRELU, x.shape, alpha.shape); - return backend.runWebGLProgram(program, [x, alpha], 'float32'); -} - -export const preluConfig: KernelConfig = { - kernelName: Prelu, - backendName: 'webgl', - kernelFunc: prelu as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Prod.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Prod.ts deleted file mode 100644 index ebf3fb83c..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Prod.ts +++ /dev/null @@ -1,84 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, KernelConfig, KernelFunc, Prod, ProdAttrs, ProdInputs, sumOutType, TensorInfo, TypedArray, util} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {reduce} from '../kernel_utils/reduce'; -import {prodImplCPU} from '../kernel_utils/shared'; - -import {reshape} from './Reshape'; -import {transpose} from './Transpose'; - -export function prod( - args: {inputs: ProdInputs, backend: MathBackendWebGL, attrs: ProdAttrs}): - TensorInfo { - const {inputs, backend, attrs} = args; - const {x} = inputs; - const {axis, keepDims} = attrs; - - const xRank = x.shape.length; - const toDispose = []; - - const origAxes = util.parseAxisParam(axis, x.shape); - let axes = origAxes; - const permutedAxes = backend_util.getAxesPermutation(axes, xRank); - let permutedX = x; - if (permutedAxes != null) { - permutedX = transpose({inputs: {x}, backend, attrs: {perm: permutedAxes}}); - axes = backend_util.getInnerMostAxes(axes.length, xRank); - toDispose.push(permutedX); - } - - backend_util.assertAxesAreInnerMostDims('prod', axes, xRank); - - let res; - if (backend.shouldExecuteOnCPU([permutedX])) { - const xVals = backend.texData.get(permutedX.dataId).values as TypedArray; - const {outVals, outShape, outDtype} = - prodImplCPU(permutedX.shape, permutedX.dtype, xVals, axes); - res = backend.makeTensorInfo(outShape, outDtype, outVals); - } else { - const [outShape, reduceShape] = - backend_util.computeOutAndReduceShapes(permutedX.shape, axes); - const inSize = util.sizeFromShape(reduceShape); - const a2D = reshape( - {inputs: {x: permutedX}, backend, attrs: {shape: [-1, inSize]}}); - const outputDType = sumOutType(x.dtype); - const reduced = reduce(a2D, outputDType, 'prod', backend); - res = reshape({inputs: {x: reduced}, backend, attrs: {shape: outShape}}); - - toDispose.push(a2D); - toDispose.push(reduced); - } - - if (keepDims) { - toDispose.push(res); - const newShape = backend_util.expandShapeToKeepDim(res.shape, origAxes); - res = reshape({inputs: {x: res}, backend, attrs: {shape: newShape}}); - } - - toDispose.forEach(t => backend.disposeIntermediateTensorInfo(t)); - - return res; -} - -export const prodConfig: KernelConfig = { - kernelName: Prod, - backendName: 'webgl', - kernelFunc: prod as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/RaggedGather.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/RaggedGather.ts deleted file mode 100644 index 97e1e187c..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/RaggedGather.ts +++ /dev/null @@ -1,58 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, RaggedGather, RaggedGatherAttrs, RaggedGatherInputs, TensorInfo, TypedArray} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {raggedGatherImplCPU} from '../kernel_utils/shared'; - -export function raggedGather(args: { - inputs: RaggedGatherInputs, - backend: MathBackendWebGL, - attrs: RaggedGatherAttrs -}): TensorInfo[] { - const {inputs, backend, attrs} = args; - const {paramsNestedSplits, paramsDenseValues, indices} = inputs; - const {outputRaggedRank} = attrs; - - const $paramsNestedSplits = - paramsNestedSplits.map(t => backend.readSync(t.dataId) as TypedArray); - const $paramsNestedSplitsShapes = paramsNestedSplits.map(t => t.shape); - const $paramsDenseValues = - backend.readSync(paramsDenseValues.dataId) as TypedArray; - const $indices = backend.readSync(indices.dataId) as TypedArray; - - const [outputNestedSplits, outputDenseValues, outputDenseValuesShape] = - raggedGatherImplCPU( - $paramsNestedSplits, $paramsNestedSplitsShapes, $paramsDenseValues, - paramsDenseValues.shape, paramsDenseValues.dtype, $indices, - indices.shape, outputRaggedRank); - - const outputNestedSplitsTensors = outputNestedSplits.map( - (splits) => backend.makeTensorInfo([splits.length], 'int32', splits)); - - const outputDenseValuesTensor = backend.makeTensorInfo( - outputDenseValuesShape, paramsDenseValues.dtype, outputDenseValues); - - return outputNestedSplitsTensors.concat([outputDenseValuesTensor]); -} - -export const raggedGatherConfig: KernelConfig = { - kernelName: RaggedGather, - backendName: 'webgl', - kernelFunc: raggedGather as unknown as KernelFunc, -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/RaggedRange.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/RaggedRange.ts deleted file mode 100644 index e320a68b1..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/RaggedRange.ts +++ /dev/null @@ -1,49 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, RaggedRange, RaggedRangeInputs, TensorInfo, TypedArray} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {raggedRangeImplCPU} from '../kernel_utils/shared'; - -export function raggedRange( - args: {inputs: RaggedRangeInputs, backend: MathBackendWebGL}): - [TensorInfo, TensorInfo] { - const {inputs, backend} = args; - const {starts, limits, deltas} = inputs; - - const $starts = backend.readSync(starts.dataId) as TypedArray; - const $limits = backend.readSync(limits.dataId) as TypedArray; - const $deltas = backend.readSync(deltas.dataId) as TypedArray; - - const [rtNestedSplitsData, rtDenseValuesData] = raggedRangeImplCPU( - $starts, starts.shape, starts.dtype, $limits, limits.shape, $deltas, - deltas.shape); - - const rtNestedSplits = backend.makeTensorInfo( - [rtNestedSplitsData.length], 'int32', rtNestedSplitsData); - const rtDenseValues = backend.makeTensorInfo( - [rtDenseValuesData.length], starts.dtype, rtDenseValuesData); - - return [rtNestedSplits, rtDenseValues]; -} - -export const raggedRangeConfig: KernelConfig = { - kernelName: RaggedRange, - backendName: 'webgl', - kernelFunc: raggedRange as unknown as KernelFunc, -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/RaggedTensorToTensor.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/RaggedTensorToTensor.ts deleted file mode 100644 index 2c042c412..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/RaggedTensorToTensor.ts +++ /dev/null @@ -1,50 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, RaggedTensorToTensor, RaggedTensorToTensorAttrs, RaggedTensorToTensorInputs, TensorInfo, TypedArray} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {raggedTensorToTensorImplCPU} from '../kernel_utils/shared'; - -export function raggedTensorToTensor(args: { - inputs: RaggedTensorToTensorInputs, - backend: MathBackendWebGL, - attrs: RaggedTensorToTensorAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {shape, values, defaultValue, rowPartitionTensors} = inputs; - const {rowPartitionTypes} = attrs; - - const $shape = backend.readSync(shape.dataId) as TypedArray; - const $values = backend.readSync(values.dataId) as TypedArray; - const $defaultValue = backend.readSync(defaultValue.dataId) as TypedArray; - const $rowPartitionValues = - rowPartitionTensors.map(t => backend.readSync(t.dataId) as TypedArray); - const rowPartitionValuesShapes = rowPartitionTensors.map(t => t.shape); - - const [outputShape, output] = raggedTensorToTensorImplCPU( - $shape, shape.shape, $values, values.shape, values.dtype, $defaultValue, - defaultValue.shape, $rowPartitionValues, rowPartitionValuesShapes, - rowPartitionTypes); - return backend.makeTensorInfo(outputShape, values.dtype, output); -} - -export const raggedTensorToTensorConfig: KernelConfig = { - kernelName: RaggedTensorToTensor, - backendName: 'webgl', - kernelFunc: raggedTensorToTensor as unknown as KernelFunc, -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Range.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Range.ts deleted file mode 100644 index 58c43a056..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Range.ts +++ /dev/null @@ -1,35 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, Range, RangeAttrs, TensorInfo} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {rangeImplCPU} from '../kernel_utils/shared'; - -export const range = - (args: {backend: MathBackendWebGL, attrs: RangeAttrs}): TensorInfo => { - const {backend, attrs} = args; - const {start, stop, step, dtype} = attrs; - const values = rangeImplCPU(start, stop, step, dtype); - return backend.makeTensorInfo([values.length], dtype, values); - }; - -export const rangeConfig: KernelConfig = { - kernelName: Range, - backendName: 'webgl', - kernelFunc: range as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Real.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Real.ts deleted file mode 100644 index bf7e28f93..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Real.ts +++ /dev/null @@ -1,36 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, Real, RealInputs, TensorInfo} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {identity} from './Identity'; - -export function real(args: {inputs: RealInputs, backend: MathBackendWebGL}): - TensorInfo { - const {inputs, backend} = args; - const {input} = inputs; - const inputData = backend.texData.get(input.dataId); - - return identity({inputs: {x: inputData.complexTensorInfos.real}, backend}); -} - -export const realConfig: KernelConfig = { - kernelName: Real, - backendName: 'webgl', - kernelFunc: real as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/RealDiv.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/RealDiv.ts deleted file mode 100644 index d0073d3d4..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/RealDiv.ts +++ /dev/null @@ -1,59 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {RealDiv} from '@tensorflow/tfjs-core'; -import {KernelConfig} from '@tensorflow/tfjs-core'; -import {binaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; - -// Without the equality check div produces 0.9999 for a = b, which when -// floored can cause errors. -const DIV = ` -if (a == b) { - return 1.0; -}; -return a / b;`; - -// We do the same as in ./binaryop_gpu, with vec4 and ivec4. -// On Linux, the vectorized implementation produces NaNs when a and b are 0. -const DIV_PACKED = ` - // vec4 one = vec4(equal(a, b)); - // return one + (vec4(1.0) - one) * a / b; - vec4 result = a / b; - if(a.x == b.x) { - result.x = 1.; - } - if(a.y == b.y) { - result.y = 1.; - } - if(a.z == b.z) { - result.z = 1.; - } - if(a.w == b.w) { - result.w = 1.; - } - - return result; -`; - -export const realDiv = binaryKernelFunc( - {opSnippet: DIV, packedOpSnippet: DIV_PACKED, checkOutOfBounds: true}); - -export const realDivConfig: KernelConfig = { - kernelName: RealDiv, - backendName: 'webgl', - kernelFunc: realDiv, -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Reciprocal.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Reciprocal.ts deleted file mode 100644 index 1cfcf642b..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Reciprocal.ts +++ /dev/null @@ -1,29 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, Reciprocal} from '@tensorflow/tfjs-core'; -import {unaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; - -const RECIPROCAL = `return 1.0 / x;`; - -export const reciprocal = unaryKernelFunc({opSnippet: RECIPROCAL}); - -export const reciprocalConfig: KernelConfig = { - kernelName: Reciprocal, - backendName: 'webgl', - kernelFunc: reciprocal, -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Relu.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Relu.ts deleted file mode 100644 index 3a1e465e2..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Relu.ts +++ /dev/null @@ -1,45 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, Relu} from '@tensorflow/tfjs-core'; -import {unaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; -import {CHECK_NAN_SNIPPET} from '../unaryop_gpu'; - -const RELU = CHECK_NAN_SNIPPET + ` - return (x < 0.0) ? 0.0 : x; -`; - -const RELU_PACKED = ` - vec4 result = x * vec4(greaterThanEqual(x, vec4(0.0))); - bvec4 isNaN = isnan(x); - - result.r = isNaN.r ? x.r : result.r; - result.g = isNaN.g ? x.g : result.g; - result.b = isNaN.b ? x.b : result.b; - result.a = isNaN.a ? x.a : result.a; - - return result; -`; - -export const relu = - unaryKernelFunc({opSnippet: RELU, packedOpSnippet: RELU_PACKED}); - -export const reluConfig: KernelConfig = { - kernelName: Relu, - backendName: 'webgl', - kernelFunc: relu as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Relu6.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Relu6.ts deleted file mode 100644 index 5faa51ba7..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Relu6.ts +++ /dev/null @@ -1,45 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, Relu6} from '@tensorflow/tfjs-core'; -import {unaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; -import {CHECK_NAN_SNIPPET} from '../unaryop_gpu'; - -const RELU6 = CHECK_NAN_SNIPPET + ` - return (x < 0.0) ? 0.0 : min(6.0, x); -`; - -const RELU6_PACKED = ` - vec4 result = min(x, vec4(6.)) * vec4(greaterThanEqual(x, vec4(0.0))); - bvec4 isNaN = isnan(x); - - result.r = isNaN.r ? x.r : result.r; - result.g = isNaN.g ? x.g : result.g; - result.b = isNaN.b ? x.b : result.b; - result.a = isNaN.a ? x.a : result.a; - - return result; -`; - -export const relu6 = - unaryKernelFunc({opSnippet: RELU6, packedOpSnippet: RELU6_PACKED}); - -export const relu6Config: KernelConfig = { - kernelName: Relu6, - backendName: 'webgl', - kernelFunc: relu6 as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Reshape.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Reshape.ts deleted file mode 100644 index f8f5f5322..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Reshape.ts +++ /dev/null @@ -1,59 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, Reshape, ReshapeAttrs, ReshapeInputs, TensorInfo, util} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {packedReshape} from '../kernel_utils/reshape'; -import {isReshapeFree} from '../webgl_util'; - -export function reshape(args: { - inputs: ReshapeInputs, - backend: MathBackendWebGL, - attrs: ReshapeAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {x} = inputs; - const {shape} = attrs; - const webglBackend = backend; - - const xSize = util.sizeFromShape(x.shape); - const $shape = util.inferFromImplicitShape(shape, xSize); - const $xSize = util.sizeFromShape($shape); - - util.assert( - xSize === $xSize, - () => `The new shape (${$shape}) has ${$xSize} elements and the old ` + - `shape (${x.shape}) has ${xSize} elements. The new shape and old ` + - `shape must have the same number of elements.`); - - const xTexData = webglBackend.texData.get(x.dataId); - if (xTexData.isPacked && !isReshapeFree(x.shape, $shape) && - !(xTexData.texture !== null && isReshapeFree(xTexData.shape, $shape))) { - return packedReshape(x, $shape, webglBackend); - } - - webglBackend.incRef(x.dataId); - - return {dataId: x.dataId, shape: $shape, dtype: x.dtype}; -} - -export const reshapeConfig: KernelConfig = { - kernelName: Reshape, - backendName: 'webgl', - kernelFunc: reshape as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Reshape_test.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Reshape_test.ts deleted file mode 100644 index a1a1fc1ad..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Reshape_test.ts +++ /dev/null @@ -1,116 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '@tensorflow/tfjs-core'; -import {Tensor, test_util} from '@tensorflow/tfjs-core'; - -const {expectArraysClose, expectArraysEqual} = test_util; -// tslint:disable-next-line: no-imports-from-dist -import {describeWithFlags, ALL_ENVS} from '@tensorflow/tfjs-core/dist/jasmine_util'; - -describeWithFlags('Reshape.', ALL_ENVS, () => { - it('does not have memory leak.', async () => { - const beforeDataIds = tf.engine().backend.numDataIds(); - - const x = tf.tensor1d([1, 1, 1, 1]); - const res = - // tslint:disable-next-line: no-unnecessary-type-assertion - tf.engine().runKernel('Reshape', {x}, {shape: [2, 2]}) as Tensor; - - expectArraysClose(await res.data(), [1, 1, 1, 1]); - expectArraysEqual(res.shape, [2, 2]); - - const afterResDataIds = tf.engine().backend.numDataIds(); - expect(afterResDataIds).toEqual(beforeDataIds + 1); - - x.dispose(); - res.dispose(); - - const afterDisposeDataIds = tf.engine().backend.numDataIds(); - expect(afterDisposeDataIds).toEqual(beforeDataIds); - }); - - it('does not have memory leak calling reshape twice.', async () => { - const beforeDataIds = tf.engine().backend.numDataIds(); - - // Adding 1 new dataId. - const x = tf.tensor1d([1, 1, 1, 1]); - - // Does not add new dataId; - const res = - // tslint:disable-next-line: no-unnecessary-type-assertion - tf.engine().runKernel('Reshape', {x}, {shape: [2, 2]}) as Tensor; - - expectArraysEqual(res.shape, [2, 2]); - - // Does not add new dataId. - const res2 = - // tslint:disable-next-line: no-unnecessary-type-assertion - tf.engine().runKernel('Reshape', {x: res}, {shape: [1, 4]}) as Tensor; - expectArraysEqual(res2.shape, [1, 4]); - - const afterRes2DataIds = tf.engine().backend.numDataIds(); - expect(afterRes2DataIds).toEqual(beforeDataIds + 1); - - res.dispose(); - - const afterResDataIds = tf.engine().backend.numDataIds(); - expect(afterResDataIds).toEqual(beforeDataIds + 1); - - x.dispose(); - res2.dispose(); - - const afterDisposeDataIds = tf.engine().backend.numDataIds(); - // Should be able to dispose the dataId. - expect(afterDisposeDataIds).toEqual(beforeDataIds); - }); - - it('does not leak when reshaping a shallowly sliced tensor', async () => { - const packedFlagSaved = tf.env().getBool('WEBGL_PACK'); - tf.env().set('WEBGL_PACK', false); - - const nBefore = tf.memory().numTensors; - const nBeforeDataIds = tf.engine().backend.numDataIds(); - - const a = tf.tensor1d([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]); - const b = tf.slice(a, 0, 6); - - await b.data(); - - let nAfter = tf.memory().numTensors; - let nAfterDataIds = tf.engine().backend.numDataIds(); - expect(nAfter).toBe(nBefore + 2); - expect(nAfterDataIds).toBe(nBeforeDataIds + 2); - - const c = tf.reshape(b, [2, 3]); - expectArraysClose(await c.data(), [0, 1, 2, 3, 4, 5]); - - tf.dispose([a, b]); - nAfter = tf.memory().numTensors; - nAfterDataIds = tf.engine().backend.numDataIds(); - expect(nAfter).toBe(nBefore + 1); - expect(nAfterDataIds).toBe(nBeforeDataIds + 1); - - tf.dispose([c]); - nAfter = tf.memory().numTensors; - nAfterDataIds = tf.engine().backend.numDataIds(); - expect(nAfter).toBe(nBefore); - expect(nAfterDataIds).toBe(nBeforeDataIds); - - tf.env().set('WEBGL_PACK', packedFlagSaved); - }); -}); diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/ResizeBilinear.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/ResizeBilinear.ts deleted file mode 100644 index 6b35584fd..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/ResizeBilinear.ts +++ /dev/null @@ -1,49 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {env, KernelConfig, KernelFunc, ResizeBilinear, ResizeBilinearAttrs, ResizeBilinearInputs, TensorInfo} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {ResizeBilinearProgram} from '../resize_bilinear_gpu'; -import {ResizeBilinearPackedProgram} from '../resize_bilinear_packed_gpu'; - -export function resizeBilinear(args: { - inputs: ResizeBilinearInputs, - backend: MathBackendWebGL, - attrs: ResizeBilinearAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {images} = inputs; - const {alignCorners, halfPixelCenters, size} = attrs; - - const [newHeight, newWidth] = size; - - const program = env().getBool('WEBGL_PACK_IMAGE_OPERATIONS') ? - new ResizeBilinearPackedProgram( - images.shape as [number, number, number, number], newHeight, newWidth, - alignCorners, halfPixelCenters) : - new ResizeBilinearProgram( - images.shape as [number, number, number, number], newHeight, newWidth, - alignCorners, halfPixelCenters); - return backend.runWebGLProgram(program, [images], 'float32'); -} - -export const resizeBilinearConfig: KernelConfig = { - kernelName: ResizeBilinear, - backendName: 'webgl', - kernelFunc: resizeBilinear as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/ResizeBilinearGrad.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/ResizeBilinearGrad.ts deleted file mode 100644 index 785a63f50..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/ResizeBilinearGrad.ts +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, ResizeBilinearGrad, ResizeBilinearGradAttrs, ResizeBilinearGradInputs, TensorInfo} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {ResizeBilinearBackpropProgram} from '../resize_bilinear_backprop_gpu'; - -export function resizeBilinearGrad(args: { - inputs: ResizeBilinearGradInputs, - backend: MathBackendWebGL, - attrs: ResizeBilinearGradAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {images, dy} = inputs; - const {alignCorners} = attrs; - - const program = new ResizeBilinearBackpropProgram( - dy.shape as [number, number, number, number], - images.shape as [number, number, number, number], alignCorners); - - return backend.runWebGLProgram(program, [dy], dy.dtype); -} - -export const resizeBilinearGradConfig: KernelConfig = { - kernelName: ResizeBilinearGrad, - backendName: 'webgl', - kernelFunc: resizeBilinearGrad as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/ResizeNearestNeighbor.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/ResizeNearestNeighbor.ts deleted file mode 100644 index ec205a7ab..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/ResizeNearestNeighbor.ts +++ /dev/null @@ -1,49 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {env, KernelConfig, KernelFunc, ResizeNearestNeighbor, ResizeNearestNeighborAttrs, ResizeNearestNeighborInputs, TensorInfo} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {ResizeNearestNeighborProgram} from '../resize_nearest_neighbor_gpu'; -import {ResizeNearestNeighborPackedProgram} from '../resize_nearest_neighbor_packed_gpu'; - -export function resizeNearestNeighbor(args: { - inputs: ResizeNearestNeighborInputs, - backend: MathBackendWebGL, - attrs: ResizeNearestNeighborAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {images} = inputs; - const {alignCorners, halfPixelCenters, size} = attrs; - - const [newHeight, newWidth] = size; - - const program = env().getBool('WEBGL_PACK_IMAGE_OPERATIONS') ? - new ResizeNearestNeighborPackedProgram( - images.shape as [number, number, number, number], newHeight, newWidth, - alignCorners, halfPixelCenters) : - new ResizeNearestNeighborProgram( - images.shape as [number, number, number, number], newHeight, newWidth, - alignCorners, halfPixelCenters); - return backend.runWebGLProgram(program, [images], images.dtype); -} - -export const resizeNearestNeighborConfig: KernelConfig = { - kernelName: ResizeNearestNeighbor, - backendName: 'webgl', - kernelFunc: resizeNearestNeighbor as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/ResizeNearestNeighborGrad.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/ResizeNearestNeighborGrad.ts deleted file mode 100644 index e287a0479..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/ResizeNearestNeighborGrad.ts +++ /dev/null @@ -1,42 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, ResizeNearestNeighborGrad, ResizeNearestNeighborGradAttrs, ResizeNearestNeighborGradInputs, TensorInfo} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {ResizeNearestNeigborBackpropProgram} from '../resize_nearest_neighbor_backprop_gpu'; - -export function resizeNearestNeighborGrad(args: { - inputs: ResizeNearestNeighborGradInputs, - backend: MathBackendWebGL, - attrs: ResizeNearestNeighborGradAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {images, dy} = inputs; - const {alignCorners} = attrs; - - const program = new ResizeNearestNeigborBackpropProgram( - dy.shape as [number, number, number, number], - images.shape as [number, number, number, number], alignCorners); - return backend.runWebGLProgram(program, [dy], dy.dtype); -} - -export const resizeNearestNeighborGradConfig: KernelConfig = { - kernelName: ResizeNearestNeighborGrad, - backendName: 'webgl', - kernelFunc: resizeNearestNeighborGrad as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Reverse.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Reverse.ts deleted file mode 100644 index 7926b43c6..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Reverse.ts +++ /dev/null @@ -1,53 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {env, KernelConfig, KernelFunc, Reverse, ReverseAttrs, ReverseInputs, TensorInfo, util} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {ReverseProgram} from '../reverse_gpu'; -import {ReversePackedProgram} from '../reverse_packed_gpu'; - -import {identity} from './Identity'; - -export function reverse(args: { - inputs: ReverseInputs, - backend: MathBackendWebGL, - attrs: ReverseAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {x} = inputs; - const {dims} = attrs; - - const xRank = x.shape.length; - - const $dims = util.parseAxisParam(dims, x.shape); - if (xRank === 0) { - return identity({inputs: {x}, backend}); - } - - const program = env().getBool('WEBGL_PACK_ARRAY_OPERATIONS') ? - new ReversePackedProgram(x.shape, $dims) : - new ReverseProgram(x.shape, $dims); - - return backend.runWebGLProgram(program, [x], x.dtype); -} - -export const reverseConfig: KernelConfig = { - kernelName: Reverse, - backendName: 'webgl', - kernelFunc: reverse as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/RotateWithOffset.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/RotateWithOffset.ts deleted file mode 100644 index 5bec6d3eb..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/RotateWithOffset.ts +++ /dev/null @@ -1,42 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, KernelConfig, Tensor4D} from '@tensorflow/tfjs-core'; -import {RotateWithOffset, RotateWithOffsetAttrs, RotateWithOffsetInputs} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {RotateProgram} from '../rotate_gpu'; - -export const rotateWithOffsetConfig: KernelConfig = { - kernelName: RotateWithOffset, - backendName: 'webgl', - kernelFunc: ({inputs, attrs, backend}) => { - const {image} = inputs as RotateWithOffsetInputs; - const {radians, fillValue, center} = - attrs as unknown as RotateWithOffsetAttrs; - const webglBackend = backend as MathBackendWebGL; - - const program = new RotateProgram((image as Tensor4D).shape, fillValue); - const [centerX, centerY] = - backend_util.getImageCenter(center, image.shape[1], image.shape[2]); - const customValues = - [[centerX, centerY, Math.sin(radians), Math.cos(radians)]]; - const output = webglBackend.runWebGLProgram( - program, [image], image.dtype, customValues); - return output; - } -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Round.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Round.ts deleted file mode 100644 index c29426364..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Round.ts +++ /dev/null @@ -1,44 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, Round} from '@tensorflow/tfjs-core'; -import {unaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; - -const ROUND = ` - // OpenGL ES does not support round function. - // The algorithm is based on banker's rounding. - float base = floor(x); - if ((x - base) < 0.5) { - return floor(x); - } else if ((x - base) > 0.5) { - return ceil(x); - } else { - if (mod(base, 2.0) == 0.0) { - return base; - } else { - return base + 1.0; - } - } -`; - -export const round = unaryKernelFunc({opSnippet: ROUND}); - -export const roundConfig: KernelConfig = { - kernelName: Round, - backendName: 'webgl', - kernelFunc: round, -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Rsqrt.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Rsqrt.ts deleted file mode 100644 index dcea16dae..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Rsqrt.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, Rsqrt} from '@tensorflow/tfjs-core'; -import {unaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; -import {rsqrtImplCPU} from '../kernel_utils/shared'; - -const RSQRT = `return inversesqrt(x);`; - -export const rsqrt = - unaryKernelFunc({opSnippet: RSQRT, cpuKernelImpl: rsqrtImplCPU}); - -export const rsqrtConfig: KernelConfig = { - kernelName: Rsqrt, - backendName: 'webgl', - kernelFunc: rsqrt as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/STFT_test.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/STFT_test.ts deleted file mode 100644 index dc79027b6..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/STFT_test.ts +++ /dev/null @@ -1,44 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '@tensorflow/tfjs-core'; -// tslint:disable-next-line: no-imports-from-dist -import {ALL_ENVS, describeWithFlags} from '@tensorflow/tfjs-core/dist/jasmine_util'; - -describeWithFlags('stft memory test', ALL_ENVS, () => { - it('should have no mem leak', async () => { - const win = 320; - const fft = 320; - const hop = 160; - const input = tf.zeros([1760]); - - const startTensors = tf.memory().numTensors; - const startDataIds = tf.engine().backend.numDataIds(); - const result = await tf.signal.stft(input, win, hop, fft); - - // 1 new tensor, 3 new data buckets. - expect(tf.memory().numTensors).toBe(startTensors + 1); - expect(tf.engine().backend.numDataIds()).toBe(startTensors + 3); - - result.dispose(); - - // Zero net tensors / data buckets. - expect(tf.memory().numTensors).toBe(startTensors); - expect(tf.engine().backend.numDataIds()).toBe(startDataIds); - input.dispose(); - }); -}); diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/ScatterNd.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/ScatterNd.ts deleted file mode 100644 index 87642887a..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/ScatterNd.ts +++ /dev/null @@ -1,77 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, env, KernelConfig, KernelFunc, ScatterNd, ScatterNdAttrs, ScatterNdInputs, TensorInfo} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {ScatterProgram} from '../scatter_gpu'; -import {ScatterPackedProgram} from '../scatter_packed_gpu'; -import {reshape} from './Reshape'; - -export function scatterNd(args: { - inputs: ScatterNdInputs, - backend: MathBackendWebGL, - attrs: ScatterNdAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {indices, updates} = inputs; - const {shape} = attrs; - - const {sliceRank, numUpdates, sliceSize, strides, outputSize} = - backend_util.calculateShapes(updates, indices, shape); - - const flattenShape = [outputSize / sliceSize, sliceSize]; - - if (outputSize === 0) { - return backend.makeTensorInfo(shape, indices.dtype); - } - - const flattenIndices = reshape( - {inputs: {x: indices}, backend, attrs: {shape: [numUpdates, sliceRank]}}); - const flattenX = reshape( - {inputs: {x: updates}, backend, attrs: {shape: [numUpdates, sliceSize]}}); - - const defaultValue = backend.makeTensorInfo( - [], 'float32', new Float32Array([0])); // scalar(0) - let program; - if (env().getBool('WEBGL_PACK')) { - program = new ScatterPackedProgram( - numUpdates, sliceRank, flattenIndices.shape.length, - flattenX.shape.length, strides, flattenShape); - } else { - program = new ScatterProgram( - numUpdates, sliceRank, flattenIndices.shape.length, - flattenX.shape.length, strides, flattenShape); - } - const res = backend.runWebGLProgram( - program, [flattenX, flattenIndices, defaultValue], flattenX.dtype); - - const reshaped = reshape({inputs: {x: res}, backend, attrs: {shape}}); - - backend.disposeIntermediateTensorInfo(flattenIndices); - backend.disposeIntermediateTensorInfo(flattenX); - backend.disposeIntermediateTensorInfo(res); - backend.disposeIntermediateTensorInfo(defaultValue); - - return reshaped; -} - -export const scatterNdConfig: KernelConfig = { - kernelName: ScatterNd, - backendName: 'webgl', - kernelFunc: scatterNd as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/SearchSorted.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/SearchSorted.ts deleted file mode 100644 index 1a04611af..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/SearchSorted.ts +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, SearchSorted, SearchSortedAttrs, SearchSortedInputs, TensorInfo} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {SearchSortedProgram} from '../search_sorted_gpu'; - -export function searchSorted(args: { - inputs: SearchSortedInputs, - backend: MathBackendWebGL, - attrs: SearchSortedAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {sortedSequence, values} = inputs; - const {side} = attrs; - - const program = new SearchSortedProgram( - sortedSequence.shape[0], sortedSequence.shape[1], values.shape[1], side); - const customValues = [[sortedSequence.shape[1]]]; - return backend.runWebGLProgram( - program, [sortedSequence, values], 'int32', customValues); -} - -export const searchSortedConfig: KernelConfig = { - kernelName: SearchSorted, - backendName: 'webgl', - kernelFunc: searchSorted as unknown as KernelFunc, -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Select.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Select.ts deleted file mode 100644 index 5d6209517..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Select.ts +++ /dev/null @@ -1,38 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, Select, SelectInputs, TensorInfo, upcastType} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {SelectProgram} from '../select_gpu'; - -export function select(args: {inputs: SelectInputs, backend: MathBackendWebGL}): - TensorInfo { - const {inputs, backend} = args; - const {condition, t, e} = inputs; - - const program = - new SelectProgram(condition.shape.length, t.shape, t.shape.length); - return backend.runWebGLProgram( - program, [condition, t, e], upcastType(t.dtype, e.dtype)); -} - -export const selectConfig: KernelConfig = { - kernelName: Select, - backendName: 'webgl', - kernelFunc: select as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Selu.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Selu.ts deleted file mode 100644 index c2303f1b2..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Selu.ts +++ /dev/null @@ -1,36 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, KernelConfig, Selu} from '@tensorflow/tfjs-core'; - -import {unaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; - -const SELU = ` - // Stable and Attracting Fixed Point (0, 1) for Normalized Weights. - // see: https://arxiv.org/abs/1706.02515 - float scaleAlpha = ${backend_util.SELU_SCALEALPHA}; - float scale = ${backend_util.SELU_SCALE}; - return (x >= 0.0) ? scale * x : scaleAlpha * (exp(x) - 1.0); -`; - -export const selu = unaryKernelFunc({opSnippet: SELU}); - -export const seluConfig: KernelConfig = { - kernelName: Selu, - backendName: 'webgl', - kernelFunc: selu, -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Sigmoid.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Sigmoid.ts deleted file mode 100644 index a14808c0a..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Sigmoid.ts +++ /dev/null @@ -1,48 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, Sigmoid} from '@tensorflow/tfjs-core'; - -import {CHECK_NAN_SNIPPET_UNARY, unaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; -import {sigmoidImplCPU} from '../kernel_utils/shared'; - -const SIGMOID = CHECK_NAN_SNIPPET_UNARY + ` - return 1.0 / (1.0 + exp(-1.0 * x)); -`; - -const SIGMOID_PACKED = ` - vec4 result = 1.0 / (1.0 + exp(-1.0 * x)); - bvec4 isNaN = isnan(x); - - result.r = isNaN.r ? x.r : result.r; - result.g = isNaN.g ? x.g : result.g; - result.b = isNaN.b ? x.b : result.b; - result.a = isNaN.a ? x.a : result.a; - - return result; -`; -export const sigmoid = unaryKernelFunc({ - opSnippet: SIGMOID, - packedOpSnippet: SIGMOID_PACKED, - cpuKernelImpl: sigmoidImplCPU -}); - -export const sigmoidConfig: KernelConfig = { - kernelName: Sigmoid, - backendName: 'webgl', - kernelFunc: sigmoid, -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Sign.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Sign.ts deleted file mode 100644 index dc3ad11c6..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Sign.ts +++ /dev/null @@ -1,34 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, Sign} from '@tensorflow/tfjs-core'; - -import {unaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; - -// Sign does not propagate NANs. -const SIGN = ` - if (isnan(x)) { return 0.0; } - return sign(x); -`; - -export const sign = unaryKernelFunc({opSnippet: SIGN}); - -export const signConfig: KernelConfig = { - kernelName: Sign, - backendName: 'webgl', - kernelFunc: sign, -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Sin.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Sin.ts deleted file mode 100644 index 77c7bf0cf..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Sin.ts +++ /dev/null @@ -1,41 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, Sin} from '@tensorflow/tfjs-core'; - -import {CHECK_NAN_SNIPPET_PACKED} from '../binaryop_packed_gpu'; -import {CHECK_NAN_SNIPPET_UNARY, unaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; - -const SIN = CHECK_NAN_SNIPPET_UNARY + ` - return sin(x); -`; - -const SIN_PACKED = ` - vec4 result = sin(x); - bvec4 isNaN = isnan(x); - ${CHECK_NAN_SNIPPET_PACKED} - return result; -`; - -export const sin = - unaryKernelFunc({opSnippet: SIN, packedOpSnippet: SIN_PACKED}); - -export const sinConfig: KernelConfig = { - kernelName: Sin, - backendName: 'webgl', - kernelFunc: sin, -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Sinh.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Sinh.ts deleted file mode 100644 index 30c75f56c..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Sinh.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, Sinh} from '@tensorflow/tfjs-core'; -import {unaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; - -const SINH = ` - float e2x = exp(x); - return (e2x - 1.0 / e2x) / 2.0; -`; - -export const sinh = unaryKernelFunc({opSnippet: SINH}); - -export const sinhConfig: KernelConfig = { - kernelName: Sinh, - backendName: 'webgl', - kernelFunc: sinh, -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Slice.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Slice.ts deleted file mode 100644 index e8c196b75..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Slice.ts +++ /dev/null @@ -1,98 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {env, KernelConfig, KernelFunc, Slice, slice_util, SliceAttrs, SliceInputs, TensorInfo, TypedArray, util} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {sliceImplCPU} from '../kernel_utils/shared'; -import {SliceProgram} from '../slice_gpu'; -import {SlicePackedProgram} from '../slice_packed_gpu'; - -function shallowSlice( - x: TensorInfo, begin: number[], size: number[], backend: MathBackendWebGL) { - const xTexData = backend.texData.get(x.dataId); - const t = backend.makeTensorInfo(size, x.dtype); - const newTexData = backend.texData.get(t.dataId); - // Copy texture data from the original tensor. - Object.assign(newTexData, xTexData); - newTexData.refCount = 1; - newTexData.shape = size; - newTexData.dtype = x.dtype; - let flatOffset = - slice_util.computeFlatOffset(begin, util.computeStrides(x.shape)); - if (xTexData.slice) { - // We are slicing an already sliced tensor, so we have to accumulate - // the offset. - flatOffset += xTexData.slice.flatOffset; - } - newTexData.slice = { - flatOffset, - // Point to the original dataId, which is used to do ref counting. - origDataId: xTexData.slice && xTexData.slice.origDataId || x.dataId - }; - - // Increase the ref count for that data bucket. - const refCount = backend.dataRefCount.get(newTexData.slice.origDataId) || 1; - backend.dataRefCount.set(newTexData.slice.origDataId, refCount + 1); - return t; -} - -export function slice( - args: {inputs: SliceInputs, backend: MathBackendWebGL, attrs: SliceAttrs}): - TensorInfo { - const {inputs, backend, attrs} = args; - const {x} = inputs; - const {begin, size} = attrs; - - const [$begin, $size] = slice_util.parseSliceParams(x, begin, size); - slice_util.assertParamsValid(x, $begin, $size); - - if (util.sizeFromShape($size) === 0) { - return backend.makeTensorInfo($size, x.dtype, []); - } - - // Run on cpu if dtype is string. For string, the backend represents it - // as Uint8Array[], where each Uint8Array is a character. Given that the - // computation is only on the outer array, uploading the whole data onto - // gpu is wasteful. Also, currently webgl doesn't have a design to - // upload and retrieve Uint8Array[] between cpu and gpu. Therefore, we - // just run the kernel on cpu if dtype is string. - if (backend.shouldExecuteOnCPU([x]) || x.dtype === 'string') { - const xTexData = backend.texData.get(x.dataId); - const outValues = sliceImplCPU( - xTexData.values as TypedArray, $begin, $size, x.shape, x.dtype); - return backend.makeTensorInfo($size, x.dtype, outValues); - } - - const {isPacked} = backend.texData.get(x.dataId); - const isContinous = slice_util.isSliceContinous(x.shape, $begin, $size); - if (isPacked || !isContinous) { - const program = env().getBool('WEBGL_PACK_ARRAY_OPERATIONS') ? - new SlicePackedProgram($size) : - new SliceProgram($size); - const customValues = [$begin]; - return backend.runWebGLProgram(program, [x], x.dtype, customValues); - } - backend.uploadToGPU(x.dataId); - return shallowSlice(x, $begin, $size, backend); -} - -export const sliceConfig: KernelConfig = { - kernelName: Slice, - backendName: 'webgl', - kernelFunc: slice as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Softmax.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Softmax.ts deleted file mode 100644 index 9ba5770cb..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Softmax.ts +++ /dev/null @@ -1,75 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, KernelConfig, KernelFunc, Softmax, SoftmaxAttrs, SoftmaxInputs, TensorInfo, util} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; - -import {exp} from './Exp'; -import {max} from './Max'; -import {realDiv} from './RealDiv'; -import {reshape} from './Reshape'; -import {sub} from './Sub'; -import {sum} from './Sum'; - -export function softmax(args: { - inputs: SoftmaxInputs, - backend: MathBackendWebGL, - attrs: SoftmaxAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {logits} = inputs; - const {dim} = attrs; - - const axes = util.parseAxisParam([dim], logits.shape); - - const maxLogit = max({ - inputs: {x: logits}, - backend, - attrs: {reductionIndices: axes, keepDims: false} - }); - - const expandedShape = backend_util.expandShapeToKeepDim(maxLogit.shape, axes); - - const maxLogitsReshaped = - reshape({inputs: {x: maxLogit}, backend, attrs: {shape: expandedShape}}); - const a = - sub({inputs: {a: logits, b: maxLogitsReshaped}, backend}) as TensorInfo; - const b = exp({inputs: {x: a}, backend}) as TensorInfo; - const sumExp = - sum({inputs: {x: b}, backend, attrs: {axis: axes, keepDims: false}}); - const sumExpReshaped = - reshape({inputs: {x: sumExp}, backend, attrs: {shape: expandedShape}}); - - const res = - realDiv({inputs: {a: b, b: sumExpReshaped}, backend}) as TensorInfo; - - backend.disposeIntermediateTensorInfo(maxLogit); - backend.disposeIntermediateTensorInfo(maxLogitsReshaped); - backend.disposeIntermediateTensorInfo(a); - backend.disposeIntermediateTensorInfo(b); - backend.disposeIntermediateTensorInfo(sumExp); - backend.disposeIntermediateTensorInfo(sumExpReshaped); - - return res; -} - -export const softmaxConfig: KernelConfig = { - kernelName: Softmax, - backendName: 'webgl', - kernelFunc: softmax as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Softplus.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Softplus.ts deleted file mode 100644 index 2545658e7..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Softplus.ts +++ /dev/null @@ -1,49 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, Softplus} from '@tensorflow/tfjs-core'; -import {unaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; - -const SOFTPLUS = ` - float epsilon = 1.1920928955078125e-7; - float threshold = log(epsilon) + 2.0; - - bool too_large = x > -threshold; - bool too_small = x < threshold; - - float result; - float exp_x = exp(x); - - if (too_large){ - result = x; - } - else if (too_small){ - result = exp_x; - } - else{ - result = log(exp_x + 1.0); - } - return result; -`; - -export const softplus = unaryKernelFunc({opSnippet: SOFTPLUS}); - -export const softplusConfig: KernelConfig = { - kernelName: Softplus, - backendName: 'webgl', - kernelFunc: softplus, -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/SpaceToBatchND.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/SpaceToBatchND.ts deleted file mode 100644 index 6643b1ec9..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/SpaceToBatchND.ts +++ /dev/null @@ -1,90 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, KernelConfig, KernelFunc, SpaceToBatchND, SpaceToBatchNDAttrs, SpaceToBatchNDInputs, TensorInfo, util} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; - -import {padV2} from './PadV2'; -import {reshape} from './Reshape'; -import {transpose} from './Transpose'; - -export const spaceToBatchND = (args: { - inputs: SpaceToBatchNDInputs, - backend: MathBackendWebGL, - attrs: SpaceToBatchNDAttrs -}): TensorInfo => { - const {inputs, backend, attrs} = args; - const {x} = inputs; - const {blockShape, paddings} = attrs; - - util.assert( - x.shape.length <= 4, - () => 'spaceToBatchND for rank > 4 with a WebGL backend not ' + - 'implemented yet'); - - const prod = blockShape.reduce((a, b) => a * b); - - const completePaddings: Array<[number, number]> = [[0, 0]]; - completePaddings.push(...paddings as Array<[number, number]>); - for (let i = 1 + blockShape.length; i < x.shape.length; ++i) { - completePaddings.push([0, 0]); - } - - const toDispose = []; - - const paddedX = padV2({ - inputs: {x}, - backend, - attrs: {paddings: completePaddings, constantValue: 0} - }); - - const reshapedPaddedShape = - backend_util.getReshaped(paddedX.shape, blockShape, prod, false); - - const permutedReshapedPaddedPermutation = backend_util.getPermuted( - reshapedPaddedShape.length, blockShape.length, false); - - const flattenShape = - backend_util.getReshapedPermuted(paddedX.shape, blockShape, prod, false); - - const reshapedPaddedX = reshape( - {inputs: {x: paddedX}, backend, attrs: {shape: reshapedPaddedShape}}); - - const paddedXT = transpose({ - inputs: {x: reshapedPaddedX}, - backend, - attrs: {perm: permutedReshapedPaddedPermutation} - }); - - const result = - reshape({inputs: {x: paddedXT}, backend, attrs: {shape: flattenShape}}); - - toDispose.push(paddedX); - toDispose.push(reshapedPaddedX); - toDispose.push(paddedXT); - - toDispose.forEach(t => backend.disposeIntermediateTensorInfo(t)); - - return result; -}; - -export const spaceToBatchNDConfig: KernelConfig = { - kernelName: SpaceToBatchND, - backendName: 'webgl', - kernelFunc: spaceToBatchND as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/SparseFillEmptyRows.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/SparseFillEmptyRows.ts deleted file mode 100644 index 437c86951..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/SparseFillEmptyRows.ts +++ /dev/null @@ -1,75 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, SparseFillEmptyRows, SparseFillEmptyRowsInputs, TensorInfo, TypedArray} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {sparseFillEmptyRowsImplCPU} from '../kernel_utils/shared'; - -export function sparseFillEmptyRows(args: { - inputs: SparseFillEmptyRowsInputs, - backend: MathBackendWebGL -}): [TensorInfo, TensorInfo, TensorInfo, TensorInfo] { - const {inputs, backend} = args; - const {indices, values, denseShape, defaultValue} = inputs; - if (denseShape.shape.length !== 1) { - throw new Error(`Dense shape must be a vector, saw: - ${denseShape.shape}`); - } - if (indices.shape.length !== 2) { - throw new Error(`Indices must be a matrix, saw: - ${indices.shape}`); - } - if (values.shape.length !== 1) { - throw new Error(`Values must be a vector, saw: - ${values.shape}`); - } - if (defaultValue.shape.length !== 0) { - throw new Error(`Default value must be a scalar, saw: - ${defaultValue.shape}`); - } - - const $indices = backend.readSync(indices.dataId) as TypedArray; - const $values = backend.readSync(values.dataId) as TypedArray; - const $denseShape = backend.readSync(denseShape.dataId) as TypedArray; - const $defaultValue = - backend.readSync(defaultValue.dataId)[0] as number; - - const [outputIndices, outputIndicesShape, outputValues, - emptyRowIndicator, reverseIndexMap] = - sparseFillEmptyRowsImplCPU( - $indices, indices.shape, indices.dtype, $values, values.dtype, - $denseShape, $defaultValue); - return [ - backend.makeTensorInfo(outputIndicesShape, indices.dtype, outputIndices), - backend.makeTensorInfo( - [outputIndicesShape[0]], values.dtype, outputValues), - backend.makeTensorInfo( - [emptyRowIndicator.length], 'bool', - new Uint8Array( - emptyRowIndicator.map((value: boolean) => Number(value)))), - backend.makeTensorInfo( - [reverseIndexMap.length], indices.dtype, - new Int32Array(reverseIndexMap)), - ]; -} - -export const sparseFillEmptyRowsConfig: KernelConfig = { - kernelName: SparseFillEmptyRows, - backendName: 'webgl', - kernelFunc: sparseFillEmptyRows as unknown as KernelFunc, -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/SparseReshape.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/SparseReshape.ts deleted file mode 100644 index 7a6e5b846..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/SparseReshape.ts +++ /dev/null @@ -1,62 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, SparseReshape, SparseReshapeInputs, TensorInfo, TypedArray} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {sparseReshapeImplCPU} from '../kernel_utils/shared'; - -export function sparseReshape( - args: {inputs: SparseReshapeInputs, backend: MathBackendWebGL}): - [TensorInfo, TensorInfo] { - const {inputs, backend} = args; - const {inputIndices, inputShape, newShape} = inputs; - if (inputIndices.shape.length !== 2) { - throw new Error(`Input indices should be a matrix but received shape ${ - inputIndices.shape}`); - } - if (inputShape.shape.length !== 1) { - throw new Error(`Input shape should be a vector but received shape ${ - inputShape.shape}`); - } - - if (newShape.shape.length !== 1) { - throw new Error( - `Target shape should be a vector but received shape ${newShape.shape}`); - } - - const $inputShape = - Array.from(backend.readSync(inputShape.dataId) as TypedArray); - const $inputIndices = backend.readSync(inputIndices.dataId) as TypedArray; - const targetShape = - Array.from(backend.readSync(newShape.dataId) as TypedArray); - - const [newIndices, indicesShape, outputShape] = sparseReshapeImplCPU( - $inputIndices, inputIndices.shape, inputIndices.dtype, $inputShape, - targetShape); - return [ - backend.makeTensorInfo(indicesShape, inputIndices.dtype, newIndices), - backend.makeTensorInfo( - [outputShape.length], newShape.dtype, new Int32Array(outputShape)), - ]; -} - -export const sparseReshapeConfig: KernelConfig = { - kernelName: SparseReshape, - backendName: 'webgl', - kernelFunc: sparseReshape, -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/SparseSegmentMean.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/SparseSegmentMean.ts deleted file mode 100644 index dcd9dc7de..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/SparseSegmentMean.ts +++ /dev/null @@ -1,54 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, SparseSegmentMean, SparseSegmentMeanInputs, TensorInfo, TypedArray} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {sparseSegmentReductionImplCPU} from '../kernel_utils/shared'; - -export function sparseSegmentMean( - args: {inputs: SparseSegmentMeanInputs, backend: MathBackendWebGL}): - TensorInfo { - const {inputs, backend} = args; - const {data, indices, segmentIds} = inputs; - if (data.shape.length < 1) { - throw new Error( - `Data should be at least 1 dimensional but received scalar`); - } - if (indices.shape.length !== 1) { - throw new Error(`Indices should be a vector but received shape - ${indices.shape}`); - } - if (segmentIds.shape.length !== 1) { - throw new Error(`Segment ids should be a vector but received shape - ${segmentIds.shape}`); - } - - const $data = backend.readSync(data.dataId) as TypedArray; - const $indices = backend.readSync(indices.dataId) as TypedArray; - const $segmentIds = backend.readSync(segmentIds.dataId) as TypedArray; - - const [outputData, outputDataShape] = sparseSegmentReductionImplCPU( - $data, data.shape, data.dtype, $indices, $segmentIds, true); - return backend.makeTensorInfo(outputDataShape, data.dtype, outputData); -} - -export const sparseSegmentMeanConfig: KernelConfig = { - kernelName: SparseSegmentMean, - backendName: 'webgl', - kernelFunc: sparseSegmentMean as unknown as KernelFunc, -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/SparseSegmentSum.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/SparseSegmentSum.ts deleted file mode 100644 index 0421ef204..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/SparseSegmentSum.ts +++ /dev/null @@ -1,54 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, SparseSegmentSum, SparseSegmentSumInputs, TensorInfo, TypedArray} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {sparseSegmentReductionImplCPU} from '../kernel_utils/shared'; - -export function sparseSegmentSum( - args: {inputs: SparseSegmentSumInputs, backend: MathBackendWebGL}): - TensorInfo { - const {inputs, backend} = args; - const {data, indices, segmentIds} = inputs; - if (data.shape.length < 1) { - throw new Error( - `Data should be at least 1 dimensional but received scalar`); - } - if (indices.shape.length !== 1) { - throw new Error(`Indices should be a vector but received shape - ${indices.shape}`); - } - if (segmentIds.shape.length !== 1) { - throw new Error(`Segment ids should be a vector but received shape - ${segmentIds.shape}`); - } - - const $data = backend.readSync(data.dataId) as TypedArray; - const $indices = backend.readSync(indices.dataId) as TypedArray; - const $segmentIds = backend.readSync(segmentIds.dataId) as TypedArray; - - const [outputData, outputDataShape] = sparseSegmentReductionImplCPU( - $data, data.shape, data.dtype, $indices, $segmentIds); - return backend.makeTensorInfo(outputDataShape, data.dtype, outputData); -} - -export const sparseSegmentSumConfig: KernelConfig = { - kernelName: SparseSegmentSum, - backendName: 'webgl', - kernelFunc: sparseSegmentSum as unknown as KernelFunc, -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/SparseToDense.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/SparseToDense.ts deleted file mode 100644 index d0108e2ef..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/SparseToDense.ts +++ /dev/null @@ -1,67 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, KernelConfig, KernelFunc, Rank, SparseToDense, SparseToDenseAttrs, SparseToDenseInputs, TensorInfo, util} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {scatterImplCPU} from '../kernel_utils/shared'; -import {ScatterProgram} from '../scatter_gpu'; - -import {reshape} from './Reshape'; - -export function sparseToDense(args: { - inputs: SparseToDenseInputs, - backend: MathBackendWebGL, - attrs: SparseToDenseAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {sparseIndices, sparseValues, defaultValue} = inputs; - const {outputShape} = attrs; - - const {sliceRank, numUpdates, sliceSize, strides, outputSize} = - backend_util.calculateShapes(sparseValues, sparseIndices, outputShape); - const sumDupeIndices = false; - - if (sparseValues.dtype === 'string') { - const indicesBuf = backend.bufferSync(sparseIndices); - const updatesBuf = backend.bufferSync(sparseValues); - const $defaultValue = util.decodeString( - backend.readSync(defaultValue.dataId)[0] as Uint8Array); - const outBuf = scatterImplCPU( - indicesBuf, updatesBuf, outputShape, outputSize, sliceSize, numUpdates, - sliceRank, strides, $defaultValue, sumDupeIndices); - return backend.makeTensorInfo(outputShape, outBuf.dtype, outBuf.values); - } - const program = new ScatterProgram( - numUpdates, sliceRank, sparseIndices.shape.length, - sparseValues.shape.length, strides, [outputSize, 1], sumDupeIndices); - - const res = backend.runWebGLProgram( - program, [sparseValues, sparseIndices, defaultValue], sparseValues.dtype); - - const reshaped = - reshape({inputs: {x: res}, backend, attrs: {shape: outputShape}}); - - backend.disposeIntermediateTensorInfo(res); - return reshaped; -} - -export const sparseToDenseConfig: KernelConfig = { - kernelName: SparseToDense, - backendName: 'webgl', - kernelFunc: sparseToDense as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/SplitV.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/SplitV.ts deleted file mode 100644 index b8658bca7..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/SplitV.ts +++ /dev/null @@ -1,52 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, KernelConfig, KernelFunc, SplitV, SplitVAttrs, SplitVInputs, TensorInfo, util} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {slice} from './Slice'; - -export function splitV( - args: - {inputs: SplitVInputs, backend: MathBackendWebGL, attrs: SplitVAttrs}): - TensorInfo[] { - const {inputs, backend, attrs} = args; - const {x} = inputs; - const {numOrSizeSplits, axis} = attrs; - - const $axis = util.parseAxisParam(axis, x.shape)[0]; - const splitSizes = backend_util.prepareSplitSize(x, numOrSizeSplits, $axis); - - const xRank = x.shape.length; - const begin = new Array(xRank).fill(0); - const size = x.shape.slice(); - - return splitSizes.map(s => { - const sliceSize = [...size]; - sliceSize[$axis] = s; - const sliceT = - slice({inputs: {x}, backend, attrs: {begin, size: sliceSize}}); - begin[$axis] += s; - return sliceT; - }); -} - -export const splitVConfig: KernelConfig = { - kernelName: SplitV, - backendName: 'webgl', - kernelFunc: splitV as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Sqrt.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Sqrt.ts deleted file mode 100644 index fb461725d..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Sqrt.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, Sqrt} from '@tensorflow/tfjs-core'; - -import {unaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; -import {sqrtImplCPU} from '../kernel_utils/shared'; - -const SQRT = `return sqrt(x);`; - -export const sqrt = unaryKernelFunc( - {opSnippet: SQRT, packedOpSnippet: SQRT, cpuKernelImpl: sqrtImplCPU}); - -export const sqrtConfig: KernelConfig = { - kernelName: Sqrt, - backendName: 'webgl', - kernelFunc: sqrt as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Square.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Square.ts deleted file mode 100644 index 030f7f6e9..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Square.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, Square} from '@tensorflow/tfjs-core'; - -import {unaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; - -const SQUARE = `return x * x;`; - -export const square = unaryKernelFunc({opSnippet: SQUARE}); - -export const squareConfig: KernelConfig = { - kernelName: Square, - backendName: 'webgl', - kernelFunc: square, -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/SquaredDifference.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/SquaredDifference.ts deleted file mode 100644 index e8e658964..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/SquaredDifference.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, SquaredDifference} from '@tensorflow/tfjs-core'; - -import {binaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; - -const SQUARED_DIFFERENCE = 'return (a - b) * (a - b);'; - -export const squaredDifference = binaryKernelFunc( - {opSnippet: SQUARED_DIFFERENCE, packedOpSnippet: SQUARED_DIFFERENCE}); - -export const squaredDifferenceConfig: KernelConfig = { - kernelName: SquaredDifference, - backendName: 'webgl', - kernelFunc: squaredDifference, -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/StaticRegexReplace.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/StaticRegexReplace.ts deleted file mode 100644 index e40ef192c..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/StaticRegexReplace.ts +++ /dev/null @@ -1,47 +0,0 @@ -/** - * @license - * Copyright 2023 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, KernelConfig, KernelFunc, NamedAttrMap, StaticRegexReplace, StaticRegexReplaceAttrs, StaticRegexReplaceInputs, TensorInfo} from '@tensorflow/tfjs-core'; -import {MathBackendWebGL} from '../backend_webgl'; -import {staticRegexReplaceImplCPU} from '../kernel_utils/shared'; - -export function staticRegexReplace(args: { - inputs: StaticRegexReplaceInputs, - backend: MathBackendWebGL, - attrs: StaticRegexReplaceAttrs, -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {x} = inputs; - - if (x.dtype !== 'string') { - throw new Error('Input must be of datatype string'); - } - - const $x = backend.readSync(x.dataId) as Uint8Array[]; - - const stringInput = backend_util.fromUint8ToStringArray($x); - const output = staticRegexReplaceImplCPU(stringInput, 'string', - attrs as unknown as NamedAttrMap); - - return backend.makeTensorInfo(x.shape, 'string', output); -} - -export const staticRegexReplaceConfig: KernelConfig = { - kernelName: StaticRegexReplace, - backendName: 'webgl', - kernelFunc: staticRegexReplace as unknown as KernelFunc, -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Step.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Step.ts deleted file mode 100644 index ea87fb027..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Step.ts +++ /dev/null @@ -1,41 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, Step, StepAttrs, TensorInfo, UnaryInputs} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {CHECK_NAN_SNIPPET, UnaryOpProgram} from '../unaryop_gpu'; - -export function step( - {inputs, attrs, backend}: - {inputs: UnaryInputs, attrs: StepAttrs, backend: MathBackendWebGL}): - TensorInfo { - const {x} = inputs; - const opSnippet = CHECK_NAN_SNIPPET + ` - return x > 0.0 ? 1.0 : float(${attrs.alpha}); - `; - - const program = new UnaryOpProgram(x.shape, opSnippet); - - return backend.runWebGLProgram(program, [x], x.dtype); -} - -export const stepConfig: KernelConfig = { - kernelName: Step, - backendName: 'webgl', - kernelFunc: step as unknown as KernelFunc, -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/StridedSlice.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/StridedSlice.ts deleted file mode 100644 index f7d84af89..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/StridedSlice.ts +++ /dev/null @@ -1,105 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {buffer, KernelConfig, KernelFunc, Rank, slice_util, StridedSlice, StridedSliceAttrs, StridedSliceInputs, TensorBuffer, TensorInfo, TypedArray, util} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {stridedSliceImplCPU} from '../kernel_utils/shared'; -import {StridedSliceProgram} from '../strided_slice_gpu'; - -import {reshape} from './Reshape'; -import {slice} from './Slice'; - -export function stridedSlice(args: { - inputs: StridedSliceInputs, - backend: MathBackendWebGL, - attrs: StridedSliceAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {x} = inputs; - const { - begin, - end, - strides, - beginMask, - endMask, - ellipsisMask, - newAxisMask, - shrinkAxisMask - } = attrs; - - const { - finalShapeSparse, - finalShape, - isIdentity, - sliceDim0, - isSimpleSlice, - begin: $begin, - end: $end, - strides: $strides - } = - slice_util.sliceInfo( - x.shape, begin, end, strides, beginMask, endMask, ellipsisMask, - newAxisMask, shrinkAxisMask); - - let result; - - if (isIdentity) { - // Optimization #1, slice is a no-op plus reshape - result = reshape({inputs: {x}, backend, attrs: {shape: finalShape}}); - } else if (sliceDim0 || isSimpleSlice) { - // Optimization #2, slice is memory contiguous (only occurs in dim 0) - util.assert( - x.shape.length >= 1, - () => `Input must have rank at least 1, got: ${x.shape.length}`); - - const size = slice_util.computeOutShape($begin, $end, $strides); - // To tolerate begin[0] > end[0] (a 0-output slice), we min(begin, end). - const sliced = slice({inputs: {x}, backend, attrs: {begin: $begin, size}}); - result = - reshape({inputs: {x: sliced}, backend, attrs: {shape: finalShape}}); - backend.disposeIntermediateTensorInfo(sliced); - } else { - const shouldExecuteOnCPU = backend.shouldExecuteOnCPU([x]); - if (shouldExecuteOnCPU) { - // tslint:disable-next-line: no-unnecessary-type-assertion - const values = backend.readSync(x.dataId) as TypedArray; - // tslint:disable-next-line: no-unnecessary-type-assertion - const xBuf = buffer(x.shape, x.dtype, values) as TensorBuffer; - const resultValues = - stridedSliceImplCPU(finalShapeSparse, xBuf, $strides, $begin); - result = backend.makeTensorInfo(finalShape, x.dtype, resultValues.values); - } else { - const program = - new StridedSliceProgram($begin, $strides, finalShapeSparse); - result = backend.runWebGLProgram(program, [x], x.dtype); - } - } - - const resultReshaped = - reshape({inputs: {x: result}, backend, attrs: {shape: finalShape}}); - - backend.disposeIntermediateTensorInfo(result); - - return resultReshaped; -} - -export const stridedSliceConfig: KernelConfig = { - kernelName: StridedSlice, - backendName: 'webgl', - kernelFunc: stridedSlice as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/StringNGrams.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/StringNGrams.ts deleted file mode 100644 index 7df34f3c4..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/StringNGrams.ts +++ /dev/null @@ -1,54 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, StringNGrams, StringNGramsAttrs, StringNGramsInputs, TensorInfo} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {stringNGramsImplCPU} from '../kernel_utils/shared'; - -export function stringNGrams(args: { - inputs: StringNGramsInputs, - backend: MathBackendWebGL, - attrs: StringNGramsAttrs -}): [TensorInfo, TensorInfo] { - const {inputs, backend, attrs} = args; - const { - separator, - nGramWidths, - leftPad, - rightPad, - padWidth, - preserveShortSequences - } = attrs; - const {data, dataSplits} = inputs; - const $data = backend.readSync(data.dataId) as Uint8Array[]; - const $dataSplits = backend.readSync(dataSplits.dataId) as Int32Array; - - const [nGrams, nGramsSplits] = stringNGramsImplCPU( - $data, $dataSplits, separator, nGramWidths, leftPad, rightPad, padWidth, - preserveShortSequences); - return [ - backend.makeTensorInfo([nGrams.length], 'string', nGrams), - backend.makeTensorInfo(dataSplits.shape, 'int32', nGramsSplits), - ]; -} - -export const stringNGramsConfig: KernelConfig = { - kernelName: StringNGrams, - backendName: 'webgl', - kernelFunc: stringNGrams as unknown as KernelFunc, -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/StringSplit.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/StringSplit.ts deleted file mode 100644 index 0373d34d6..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/StringSplit.ts +++ /dev/null @@ -1,60 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, StringSplit, StringSplitAttrs, StringSplitInputs, TensorInfo} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {stringSplitImplCPU} from '../kernel_utils/shared'; - -export function stringSplit(args: { - inputs: StringSplitInputs, - backend: MathBackendWebGL, - attrs: StringSplitAttrs -}): [TensorInfo, TensorInfo, TensorInfo] { - const {inputs, backend, attrs} = args; - const {skipEmpty} = attrs; - const {input, delimiter} = inputs; - - if (input.dtype !== 'string') { - throw new Error('Input must be of datatype string'); - } - if (input.shape.length !== 1) { - throw new Error(`Input must be a vector, got shape: ${input.shape}`); - } - if (delimiter.shape.length !== 0) { - throw new Error( - `Delimiter must be a scalar, got shape: ${delimiter.shape}`); - } - - const $input = backend.readSync(input.dataId) as Uint8Array[]; - const $delimiter = backend.readSync(delimiter.dataId)[0] as Uint8Array; - - const [indices, values, shape] = - stringSplitImplCPU($input, $delimiter, skipEmpty); - const outputSize = values.length; - return [ - backend.makeTensorInfo([outputSize, 2], 'int32', indices), - backend.makeTensorInfo([outputSize], 'string', values), - backend.makeTensorInfo([2], 'int32', new Int32Array(shape)) - ]; -} - -export const stringSplitConfig: KernelConfig = { - kernelName: StringSplit, - backendName: 'webgl', - kernelFunc: stringSplit as unknown as KernelFunc, -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/StringToHashBucketFast.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/StringToHashBucketFast.ts deleted file mode 100644 index 442acae9a..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/StringToHashBucketFast.ts +++ /dev/null @@ -1,49 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, StringToHashBucketFast, StringToHashBucketFastAttrs, StringToHashBucketFastInputs, TensorInfo} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {stringToHashBucketFastImplCPU} from '../kernel_utils/shared'; - -export function stringToHashBucketFast(args: { - inputs: StringToHashBucketFastInputs, - backend: MathBackendWebGL, - attrs: StringToHashBucketFastAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {numBuckets} = attrs; - const {input} = inputs; - - if (input.dtype !== 'string') { - throw new Error('Input must be of datatype string'); - } - if (numBuckets <= 0) { - throw new Error(`Number of buckets must be at least 1`); - } - - const $input = backend.readSync(input.dataId) as Uint8Array[]; - - const output = stringToHashBucketFastImplCPU($input, numBuckets); - return backend.makeTensorInfo(input.shape, 'int32', output); -} - -export const stringToHashBucketFastConfig: KernelConfig = { - kernelName: StringToHashBucketFast, - backendName: 'webgl', - kernelFunc: stringToHashBucketFast as unknown as KernelFunc, -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Sub.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Sub.ts deleted file mode 100644 index 8d5ec7b7b..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Sub.ts +++ /dev/null @@ -1,36 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, Sub} from '@tensorflow/tfjs-core'; - -import {binaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; -import {subImplCPU as cpuSub} from '../kernel_utils/shared'; - -const SUB = 'return a - b;'; - -export const sub = binaryKernelFunc({ - opSnippet: SUB, - packedOpSnippet: SUB, - supportsComplex: true, - cpuKernelImpl: cpuSub -}); - -export const subConfig: KernelConfig = { - kernelName: Sub, - backendName: 'webgl', - kernelFunc: sub -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Sum.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Sum.ts deleted file mode 100644 index 986b30e7b..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Sum.ts +++ /dev/null @@ -1,38 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, Sum, SumAttrs, SumInputs} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; - -import {sumImpl} from './Sum_impl'; - -export function sum( - args: {inputs: SumInputs, attrs: SumAttrs, backend: MathBackendWebGL}) { - const {inputs, backend, attrs} = args; - - const {x} = inputs; - const {axis, keepDims} = attrs; - - return sumImpl(x, axis, keepDims, backend); -} - -export const sumConfig: KernelConfig = { - kernelName: Sum, - backendName: 'webgl', - kernelFunc: sum as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Sum_impl.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Sum_impl.ts deleted file mode 100644 index 5ac9d6084..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Sum_impl.ts +++ /dev/null @@ -1,74 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, sumOutType, TensorInfo, util} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {reduce} from '../kernel_utils/reduce'; -import {reshape} from './Reshape'; - -import {transposeImpl} from './Transpose_impl'; - -export function sumImpl( - x: TensorInfo, axis: number|number[], keepDims: boolean, - backend: MathBackendWebGL): TensorInfo { - const reductionIndices = axis; - - const xRank = x.shape.length; - - const origAxes = util.parseAxisParam(reductionIndices, x.shape); - let axes = origAxes; - const permutedAxes = backend_util.getAxesPermutation(axes, xRank); - const sumInputIsTransposed = permutedAxes != null; - - let sumInput = x; - if (sumInputIsTransposed) { - sumInput = transposeImpl(x, permutedAxes, backend); - - axes = backend_util.getInnerMostAxes(axes.length, xRank); - } - - backend_util.assertAxesAreInnerMostDims('sum', axes, xRank); - const [sumOutShape, reduceShape] = - backend_util.computeOutAndReduceShapes(sumInput.shape, axes); - - let outShape = sumOutShape; - if (keepDims) { - // rather than reshape at the end, set the target shape here. - outShape = backend_util.expandShapeToKeepDim(sumOutShape, origAxes); - } - - const inSize = util.sizeFromShape(reduceShape); - const xSize = util.sizeFromShape(x.shape); - const batchSize = xSize / inSize; - const reshapedInput = reshape( - {inputs: {x: sumInput}, attrs: {shape: [batchSize, inSize]}, backend}); - - const outType = sumOutType(x.dtype); - - const reduced = reduce(reshapedInput, outType, 'sum', backend); - const out = - reshape({inputs: {x: reduced}, attrs: {shape: outShape}, backend}); - - backend.disposeIntermediateTensorInfo(reshapedInput); - backend.disposeIntermediateTensorInfo(reduced); - if (sumInputIsTransposed) { - backend.disposeIntermediateTensorInfo(sumInput); - } - - return out; -} diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Tan.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Tan.ts deleted file mode 100644 index 6a050045e..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Tan.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, Tan} from '@tensorflow/tfjs-core'; - -import {unaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; - -const TAN = `return tan(x);`; - -export const tan = unaryKernelFunc({opSnippet: TAN}); - -export const tanConfig: KernelConfig = { - kernelName: Tan, - backendName: 'webgl', - kernelFunc: tan, -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Tanh.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Tanh.ts deleted file mode 100644 index 8866b54b7..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Tanh.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, Tanh} from '@tensorflow/tfjs-core'; -import {unaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; - -const TANH = ` - float e2x = exp(-2.0 * abs(x)); - return sign(x) * (1.0 - e2x) / (1.0 + e2x); -`; - -export const tanh = unaryKernelFunc({opSnippet: TANH}); - -export const tanhConfig: KernelConfig = { - kernelName: Tanh, - backendName: 'webgl', - kernelFunc: tanh, -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/TensorScatterUpdate.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/TensorScatterUpdate.ts deleted file mode 100644 index e719c2447..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/TensorScatterUpdate.ts +++ /dev/null @@ -1,70 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, KernelConfig, KernelFunc, TensorInfo, TensorScatterUpdate, TensorScatterUpdateAttrs, TensorScatterUpdateInputs} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {ScatterProgram} from '../scatter_gpu'; - -import {reshape} from './Reshape'; - -export function tensorScatterUpdate(args: { - inputs: TensorScatterUpdateInputs, - backend: MathBackendWebGL, - attrs: TensorScatterUpdateAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {tensor, indices, updates} = inputs; - const {} = attrs; - - const {sliceRank, numUpdates, sliceSize, strides, outputSize} = - backend_util.calculateShapes(updates, indices, tensor.shape); - - const flattenShape = [outputSize / sliceSize, sliceSize]; - - if (outputSize === 0) { - return backend.makeTensorInfo(tensor.shape, indices.dtype); - } - - const flattenIndices = reshape( - {inputs: {x: indices}, backend, attrs: {shape: [numUpdates, sliceRank]}}); - const flattenX = reshape( - {inputs: {x: updates}, backend, attrs: {shape: [numUpdates, sliceSize]}}); - const flattenTensor = - reshape({inputs: {x: tensor}, backend, attrs: {shape: flattenShape}}); - const program = new ScatterProgram( - numUpdates, sliceRank, flattenIndices.shape.length, flattenX.shape.length, - strides, flattenShape, false, true); - const res = backend.runWebGLProgram( - program, [flattenX, flattenIndices, flattenTensor], flattenTensor.dtype); - - const reshaped = - reshape({inputs: {x: res}, backend, attrs: {shape: tensor.shape}}); - - backend.disposeIntermediateTensorInfo(flattenIndices); - backend.disposeIntermediateTensorInfo(flattenX); - backend.disposeIntermediateTensorInfo(flattenTensor); - backend.disposeIntermediateTensorInfo(res); - - return reshaped; -} - -export const tensorScatterUpdateConfig: KernelConfig = { - kernelName: TensorScatterUpdate, - backendName: 'webgl', - kernelFunc: tensorScatterUpdate as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Tile.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Tile.ts deleted file mode 100644 index 5438a2590..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Tile.ts +++ /dev/null @@ -1,54 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {buffer, KernelConfig, KernelFunc, TensorInfo, Tile, TileAttrs, TileInputs, TypedArray, util} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {tileImplCPU} from '../kernel_utils/shared'; -import {TileProgram} from '../tile_gpu'; - -export function tile( - params: {inputs: TileInputs, backend: MathBackendWebGL, attrs: TileAttrs}): - TensorInfo { - const {inputs, backend, attrs} = params; - const {x} = inputs; - const {reps} = attrs; - - // tile gpu program cannot handle rank > 5 case. - if (x.dtype === 'string' || x.shape.length > 5) { - // Even thought string tensor is always on CPU, just to be consistent on how - // to access tensor data. - const data = backend.readSync(x.dataId); - const value = x.dtype === 'string' ? - (data as Uint8Array[]).map(d => util.decodeString(d)) : - data as TypedArray; - const buf = buffer(x.shape, x.dtype, value); - const outBuf = tileImplCPU(buf, reps); - return backend.makeTensorInfo(outBuf.shape, outBuf.dtype, outBuf.values); - } - - const program = new TileProgram(x.shape, reps); - const output = backend.runWebGLProgram(program, [x], x.dtype); - - return output; -} - -export const tileConfig: KernelConfig = { - kernelName: Tile, - backendName: 'webgl', - kernelFunc: tile as unknown as KernelFunc, -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/TopK.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/TopK.ts deleted file mode 100644 index 27afd36e4..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/TopK.ts +++ /dev/null @@ -1,193 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {env, KernelConfig, KernelFunc, NumericDataType, TensorInfo, TopK, TopKAttrs, TopKInputs, TypedArray, util} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {topKImplCPU} from '../kernel_utils/shared'; -import {MergeProgram, SwapProgram} from '../top_k_gpu'; -import {fill} from './Fill'; -import {gatherV2} from './GatherV2'; -import {reshape} from './Reshape'; -import {slice} from './Slice'; - -function disposeIntermediateTensorInfoOrNull( - backend: MathBackendWebGL, tensorInfo: TensorInfo) { - if (tensorInfo !== null) { - backend.disposeIntermediateTensorInfo(tensorInfo); - } -} - -function roundUpToPow2(num: number) { - let pow2 = 1; - while (pow2 < num) { - pow2 *= 2; - } - return pow2; -} - -// Based on Algorithm 2 of Bitonic Top K, ref: -// https://anilshanbhag.in/static/papers/gputopk_sigmod18.pdf -export function topK( - args: {inputs: TopKInputs, backend: MathBackendWebGL, attrs: TopKAttrs}): - TensorInfo[] { - const {inputs, backend, attrs} = args; - const {x} = inputs; - const {k, sorted} = attrs; - - // Empirically determined constant used to determine last dim threshold for - // handing off execution to the CPU. - const TOPK_LAST_DIM_CPU_HANDOFF_SIZE_THRESHOLD = - env().getNumber('TOPK_LAST_DIM_CPU_HANDOFF_SIZE_THRESHOLD'); - - // Empirically determined constant used to determine k threshold for handing - // off execution to the CPU. - const TOPK_K_CPU_HANDOFF_THRESHOLD = - env().getNumber('TOPK_K_CPU_HANDOFF_THRESHOLD'); - - const xShape = x.shape; - const lastDim = xShape[xShape.length - 1]; - - if (backend.shouldExecuteOnCPU([x]) || - lastDim < TOPK_LAST_DIM_CPU_HANDOFF_SIZE_THRESHOLD || - k > TOPK_K_CPU_HANDOFF_THRESHOLD) { - const xVals = backend.readSync(x.dataId) as TypedArray; - const [allTopKVals, allTopKIndices] = - topKImplCPU(xVals, xShape, x.dtype as NumericDataType, k, sorted); - - return [ - backend.makeTensorInfo( - allTopKVals.shape, allTopKVals.dtype, allTopKVals.values), - backend.makeTensorInfo( - allTopKIndices.shape, allTopKIndices.dtype, allTopKIndices.values) - ]; - } - - if (k === 0) { - xShape[xShape.length - 1] = 0; - return [ - backend.makeTensorInfo(xShape, x.dtype, []), - backend.makeTensorInfo(xShape, 'int32', []) - ]; - } - - if (lastDim === 1 /* firstPass */) { - return [ - x, fill({attrs: {shape: xShape, dtype: 'int32', value: 0}, backend}) - ]; - } - - // Eagerly unpack x input since it is passed in to all the shaders which - // require unpacked inputs. - const xtexData = backend.texData.get(x.dataId); - const xIsPacked = xtexData !== null && xtexData.isPacked; - const xUnPacked = xIsPacked ? backend.unpackTensor(x) : x; - - // Reshape into a 2d tensor [batch, lastDim] and compute topk along lastDim. - const xSize = util.sizeFromShape(xShape); - const batch = xSize / lastDim; - const x2D = reshape( - {inputs: {x: xUnPacked}, attrs: {shape: [batch, lastDim]}, backend}); - - if (xIsPacked) { - disposeIntermediateTensorInfoOrNull(backend, xUnPacked); - } - - const kPow2 = roundUpToPow2(k); - const lastDimPow2 = roundUpToPow2(lastDim); - - // Only the indices containing the top K are kept at every step to reduce - // number of outputs in the GPU algorithms, so once the final set of indices - // is computed then gather is used to grab the corresponding values - // from the original input. - let indices: TensorInfo = null; - - // GPU algorithm always takes in an indices input but this input is not used - // on the first run of a GPU algorithm, therefore if indices is null we simply - // pass in x2D instead of it but the value will not actually be used - const getInputs = () => indices === null ? [x2D, x2D] : [x2D, indices]; - - const runSwap = (dir: number, inc: number, shape: number[]) => { - const inputs = getInputs(); - const program = new SwapProgram(shape); - const fistPass = indices === null ? 1 : 0; - const customValues = - [[lastDim], [fistPass], [Number.NEGATIVE_INFINITY], [dir], [inc]]; - const prevIndices = indices; - indices = backend.runWebGLProgram(program, inputs, 'int32', customValues); - disposeIntermediateTensorInfoOrNull(backend, prevIndices); - }; - - // Step 1: local sort - for (let len = 1; len < kPow2; len *= 2) { - const dir = len * 2; - for (let inc = len; inc >= 1; inc /= 2) { - runSwap(dir, inc, [batch, lastDimPow2]); - } - } - - // Step 2: merge - for (let indicesSize = lastDimPow2; indicesSize > kPow2; indicesSize /= 2) { - const inputs = getInputs(); - const mergeProgram = new MergeProgram([batch, indicesSize / 2]); - const firstPass = indices === null ? 1 : 0; - const customValues = [[lastDim], [firstPass], [kPow2]]; - const prevIndices = indices; - indices = - backend.runWebGLProgram(mergeProgram, inputs, 'int32', customValues); - disposeIntermediateTensorInfoOrNull(backend, prevIndices); - - // Step 3: rebuild - const len = kPow2 / 2; - const dir = len * 2; - for (let inc = len; inc >= 1; inc /= 2) { - runSwap(dir, inc, indices.shape); - } - } - - // Keep only the requested top K results instead of kPow2 - let prevIndices = indices; - indices = slice( - {inputs: {x: indices}, backend, attrs: {begin: 0, size: [batch, k]}}); - disposeIntermediateTensorInfoOrNull(backend, prevIndices); - - // Gather values on last dimension - let values = gatherV2( - {inputs: {x: x2D, indices}, backend, attrs: {axis: 1, batchDims: 1}}); - disposeIntermediateTensorInfoOrNull(backend, x2D); - - // Reshape back to the original input shape, except that the last - // dimension is k. - const newShape = xShape.slice(0, -1); - newShape.push(k); - - prevIndices = indices; - indices = reshape({inputs: {x: indices}, attrs: {shape: newShape}, backend}); - disposeIntermediateTensorInfoOrNull(backend, prevIndices); - - const prevValues = values; - values = reshape({inputs: {x: values}, attrs: {shape: newShape}, backend}); - disposeIntermediateTensorInfoOrNull(backend, prevValues); - - return [values, indices]; -} - -export const topKConfig: KernelConfig = { - kernelName: TopK, - backendName: 'webgl', - kernelFunc: topK as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/TopK_test.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/TopK_test.ts deleted file mode 100644 index 4f213ae99..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/TopK_test.ts +++ /dev/null @@ -1,56 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '@tensorflow/tfjs-core'; -// tslint:disable-next-line: no-imports-from-dist -import {describeWithFlags} from '@tensorflow/tfjs-core/dist/jasmine_util'; - -import {WEBGL_ENVS} from '../backend_webgl_test_registry'; - -describeWithFlags('TopK', WEBGL_ENVS, () => { - it('handles packed inputs', async () => { - const a = tf.tensor1d([ - 1, 1, 2, 1, 2, 1, 1, 1, 2, 2, 1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 2, - 1, 2, 1, 1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 1, 1, 2, 1, 2, 2, 2, 2, - 1, 2, 1, 2, 2, 2, 1, 2, 2, 1, 2, 2, 1, 2, 1, 1, 1, 2, 1, 2, 1 - ]); - - // pack a using the add op which packs outputs - tf.env().set('WEBGL_PACK', true); - const aPacked = tf.addN([a, tf.zeros(a.shape)]); - - const k = a.shape[0]; - const {values, indices} = tf.topk(aPacked, k); - - expect(values.shape).toEqual([k]); - expect(indices.shape).toEqual([k]); - expect(values.dtype).toBe('float32'); - expect(indices.dtype).toBe('int32'); - - tf.test_util.expectArraysEqual(await values.data(), [ - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 - ]); - tf.test_util.expectArraysEqual(await indices.data(), [ - 2, 4, 8, 9, 12, 15, 18, 21, 23, 27, 30, 33, 38, 40, 41, 42, 43, - 45, 47, 48, 49, 51, 52, 54, 55, 57, 61, 63, 0, 1, 3, 5, 6, 7, - 10, 11, 13, 14, 16, 17, 19, 20, 22, 24, 25, 26, 28, 29, 31, 32, 34, - 35, 36, 37, 39, 44, 46, 50, 53, 56, 58, 59, 60, 62, 64 - ]); - }); -}); diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Transform.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Transform.ts deleted file mode 100644 index fdd094754..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Transform.ts +++ /dev/null @@ -1,48 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, TensorInfo, Transform, TransformAttrs, TransformInputs} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {TransformProgram} from '../transform_gpu'; - -export function transform(args: { - inputs: TransformInputs, - backend: MathBackendWebGL, - attrs: TransformAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {image, transforms} = inputs; - const {interpolation, fillMode, fillValue, outputShape} = attrs; - - const [batch, imageHeight, imageWidth, numChannels] = image.shape; - const [outHeight, outWidth] = - outputShape != null ? outputShape : [imageHeight, imageWidth]; - const outShape = - [batch, outHeight, outWidth, - numChannels] as [number, number, number, number]; - - const program = new TransformProgram( - imageHeight, imageWidth, interpolation, fillMode, fillValue, outShape); - return backend.runWebGLProgram(program, [image, transforms], 'float32'); -} - -export const transformConfig: KernelConfig = { - kernelName: Transform, - backendName: 'webgl', - kernelFunc: transform as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Transpose.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Transpose.ts deleted file mode 100644 index 60466ccb3..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Transpose.ts +++ /dev/null @@ -1,61 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, TensorInfo, Transpose, TransposeAttrs, TransposeInputs, TypedArray} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; - -import {transposeImpl} from './Transpose_impl'; -import {transposeImplCPU as cpuTranspose} from './Transpose_impl'; - -export function transpose(args: { - inputs: TransposeInputs, - attrs: TransposeAttrs, - backend: MathBackendWebGL -}) { - const {inputs, backend, attrs} = args; - const {x} = inputs; - const {perm} = attrs; - const webglBackend = backend; - - const xRank = x.shape.length; - - const newShape: number[] = new Array(xRank); - for (let i = 0; i < newShape.length; i++) { - newShape[i] = x.shape[perm[i]]; - } - - let out: TensorInfo; - if (webglBackend.shouldExecuteOnCPU([x])) { - const xTexData = webglBackend.texData.get(x.dataId); - const values = xTexData.values as TypedArray; - const outValues = cpuTranspose(values, x.shape, x.dtype, perm, newShape); - - out = webglBackend.makeTensorInfo(newShape, x.dtype); - const outData = webglBackend.texData.get(out.dataId); - outData.values = outValues; - } else { - out = transposeImpl(x, perm, webglBackend); - } - return out; -} - -export const transposeConfig: KernelConfig = { - kernelName: Transpose, - backendName: 'webgl', - kernelFunc: transpose as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Transpose_impl.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Transpose_impl.ts deleted file mode 100644 index 1b0680bc7..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Transpose_impl.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {env, TensorInfo} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {transposeImplCPU} from '../kernel_utils/shared'; -import {TransposeProgram} from '../transpose_gpu'; -import {TransposePackedProgram} from '../transpose_packed_gpu'; - -export function transposeImpl( - x: TensorInfo, perm: number[], backend: MathBackendWebGL): TensorInfo { - const program = env().getBool('WEBGL_PACK_ARRAY_OPERATIONS') ? - new TransposePackedProgram(x.shape, perm) : - new TransposeProgram(x.shape, perm); - return backend.runWebGLProgram(program, [x], x.dtype); -} - -export {transposeImplCPU}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Unique.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Unique.ts deleted file mode 100644 index aa6dfcf42..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Unique.ts +++ /dev/null @@ -1,50 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, TensorInfo, Unique, UniqueAttrs, UniqueInputs} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {uniqueImplCPU} from '../kernel_utils/shared'; -import {assertNotComplex} from '../webgl_util'; - -export function unique( - args: - {inputs: UniqueInputs, attrs: UniqueAttrs, backend: MathBackendWebGL}): - TensorInfo[] { - const {inputs, attrs, backend} = args; - const {axis} = attrs; - const {x} = inputs; - assertNotComplex(x, 'unique'); - - // For now, always forward calculation to the CPU backend. - console.warn( - 'WARNING: ', - 'UI might be locked temporarily as data is being downloaded'); - const values = backend.readSync(x.dataId); - const {outputValues, outputShape, indices} = - uniqueImplCPU(values, axis, x.shape, x.dtype); - return [ - backend.makeTensorInfo(outputShape, x.dtype, outputValues), - backend.makeTensorInfo([indices.length], 'int32', indices), - ]; -} - -export const uniqueConfig: KernelConfig = { - kernelName: Unique, - backendName: 'webgl', - kernelFunc: unique as unknown as KernelFunc, -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/Unpack.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/Unpack.ts deleted file mode 100644 index 6300bc032..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/Unpack.ts +++ /dev/null @@ -1,73 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, TensorInfo, Unpack, UnpackAttrs, UnpackInputs} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; - -import {reshape} from './Reshape'; -import {slice} from './Slice'; - -export function unpack( - args: - {inputs: UnpackInputs, backend: MathBackendWebGL, attrs: UnpackAttrs}): - TensorInfo[] { - const {inputs, backend, attrs} = args; - const {value} = inputs; - let {axis} = attrs; - - if (axis < 0) { - axis += value.shape.length; - } - - const x = value; - const xRank = x.shape.length; - - const num = value.shape[axis]; - const outShape: number[] = new Array(xRank - 1); - let outIndex = 0; - for (let i = 0; i < xRank; i++) { - if (i !== axis) { - outShape[outIndex++] = x.shape[i]; - } - } - - const toDispose = []; - - const begin = new Array(xRank).fill(0); - const size = x.shape.slice(); - size[axis] = 1; - const res: TensorInfo[] = new Array(num); - for (let i = 0; i < res.length; i++) { - begin[axis] = i; - const sliced = slice({inputs: {x}, backend, attrs: {begin, size}}); - const reshaped = - reshape({inputs: {x: sliced}, backend, attrs: {shape: outShape}}); - res[i] = reshaped; - - toDispose.push(sliced); - } - - toDispose.forEach(t => backend.disposeIntermediateTensorInfo(t)); - return res; -} - -export const unpackConfig: KernelConfig = { - kernelName: Unpack, - backendName: 'webgl', - kernelFunc: unpack as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/UnsortedSegmentSum.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/UnsortedSegmentSum.ts deleted file mode 100644 index df41fc993..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/UnsortedSegmentSum.ts +++ /dev/null @@ -1,114 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, DataType, KernelConfig, KernelFunc, sumOutType, TensorInfo, UnsortedSegmentSum, UnsortedSegmentSumAttrs, UnsortedSegmentSumInputs, util} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {SegmentOpProgram} from '../segment_gpu'; - -import {range} from './Range'; -import {reshape} from './Reshape'; -import {tile} from './Tile'; -import {transpose} from './Transpose'; - -export function unsortedSegmentSum(args: { - inputs: UnsortedSegmentSumInputs, - backend: MathBackendWebGL, - attrs: UnsortedSegmentSumAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {x, segmentIds} = inputs; - const {numSegments} = attrs; - - const xRank = x.shape.length; - - const toDispose = []; - - let axis = 0; - const permutation = backend_util.getAxesPermutation([axis], xRank); - let permutedX = x; - if (permutation != null) { - permutedX = transpose({inputs: {x}, backend, attrs: {perm: permutation}}); - toDispose.push(permutedX); - axis = backend_util.getInnerMostAxes(1, xRank)[0]; - } - - const outShape = backend_util.segment_util.computeOutShape( - permutedX.shape, axis, numSegments); - const inSize = util.sizeFromShape([permutedX.shape[axis]]); - const a2D = - reshape({inputs: {x: permutedX}, backend, attrs: {shape: [-1, inSize]}}); - toDispose.push(a2D); - - const outputDType = sumOutType(x.dtype); - - const segOpCompute = - (x: TensorInfo, segOpType: 'unsortedSegmentSum', segmentIds: TensorInfo, - dtype: DataType, numSegments: number): TensorInfo => { - const batchSize = x.shape[0]; - const inSize = x.shape[1]; - const windowSize = - backend_util.segment_util.segOpComputeOptimalWindowSize( - inSize, numSegments); - const segOpInfo = {windowSize, inSize, batchSize, numSegments}; - const program = new SegmentOpProgram(segOpInfo, segOpType); - const output = backend.compileAndRun(program, [x, segmentIds], dtype); - toDispose.push(output); - // No need to run another GPGPU program. - if (output.shape[1] === numSegments) { - return output; - } - const rangeInfo = range({ - backend, - attrs: {start: 0, stop: numSegments, step: 1, dtype: 'float32'} - }); - const tileInfo = tile({ - inputs: {x: rangeInfo}, - backend, - attrs: {reps: [inSize / windowSize]} - }); - - toDispose.push(rangeInfo); - toDispose.push(tileInfo); - - const result = - segOpCompute(output, segOpType, tileInfo, dtype, numSegments); - return result; - }; - - const segOpResult = segOpCompute( - a2D, 'unsortedSegmentSum', segmentIds, outputDType, numSegments); - - const reshaped = - reshape({inputs: {x: segOpResult}, backend, attrs: {shape: outShape}}); - - let result = reshaped; - if (permutation != null) { - toDispose.push(reshaped); - const perm = backend_util.getUndoAxesPermutation(permutation); - result = transpose({inputs: {x: result}, backend, attrs: {perm}}); - } - - toDispose.forEach(t => backend.disposeIntermediateTensorInfo(t)); - return result; -} - -export const unsortedSegmentSumConfig: KernelConfig = { - kernelName: UnsortedSegmentSum, - backendName: 'webgl', - kernelFunc: unsortedSegmentSum as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/ZerosLike.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/ZerosLike.ts deleted file mode 100644 index f40620be8..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/ZerosLike.ts +++ /dev/null @@ -1,62 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, TensorInfo, ZerosLike, ZerosLikeInputs} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; - -import {complex} from './Complex'; -import {fill} from './Fill'; -import {imag} from './Imag'; -import {real} from './Real'; - -export function zerosLike( - args: {inputs: ZerosLikeInputs, backend: MathBackendWebGL}): TensorInfo { - const {inputs, backend} = args; - const {x} = inputs; - - if (x.dtype === 'complex64') { - const realPart = real({inputs: {input: x}, backend}); - const r = zerosLike({inputs: {x: realPart}, backend}); - const imagPart = imag({inputs: {input: x}, backend}); - const i = zerosLike({inputs: {x: imagPart}, backend}); - - const result = complex({inputs: {real: r, imag: i}, backend}); - - backend.disposeIntermediateTensorInfo(realPart); - backend.disposeIntermediateTensorInfo(r); - backend.disposeIntermediateTensorInfo(imagPart); - backend.disposeIntermediateTensorInfo(i); - - return result; - } else { - return fill({ - attrs: { - shape: x.shape, - dtype: x.dtype, - value: x.dtype === 'string' ? '' : 0 - }, - backend - }); - } -} - -export const zerosLikeConfig: KernelConfig = { - kernelName: ZerosLike, - backendName: 'webgl', - kernelFunc: zerosLike as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/kernels/_FusedMatMul.ts b/tfjs-master/tfjs-backend-webgl/src/kernels/_FusedMatMul.ts deleted file mode 100644 index 90ac1aa51..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/kernels/_FusedMatMul.ts +++ /dev/null @@ -1,49 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {_FusedMatMul, _FusedMatMulAttrs, _FusedMatMulInputs, KernelConfig, KernelFunc} from '@tensorflow/tfjs-core'; - -import {MathBackendWebGL} from '../backend_webgl'; -import {batchMatMulImpl} from './BatchMatMul_impl'; - -export function _fusedMatMul(args: { - inputs: _FusedMatMulInputs, - attrs: _FusedMatMulAttrs, - backend: MathBackendWebGL -}) { - const {inputs, backend, attrs} = args; - const {a, b, bias, preluActivationWeights} = inputs; - const {transposeA, transposeB, activation, leakyreluAlpha} = attrs; - - return batchMatMulImpl({ - a, - b, - transposeA, - transposeB, - backend, - bias, - preluActivationWeights, - leakyreluAlpha, - activation - }); -} - -export const _fusedMatMulConfig: KernelConfig = { - kernelName: _FusedMatMul, - backendName: 'webgl', - kernelFunc: _fusedMatMul as unknown as KernelFunc, -}; diff --git a/tfjs-master/tfjs-backend-webgl/src/lrn_gpu.ts b/tfjs-master/tfjs-backend-webgl/src/lrn_gpu.ts deleted file mode 100644 index 6cde2205d..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/lrn_gpu.ts +++ /dev/null @@ -1,67 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {GPGPUProgram} from './gpgpu_math'; - -export class LRNProgram implements GPGPUProgram { - variableNames = ['x']; - outputShape: number[] = []; - userCode: string; - - constructor( - xShape: number[], radius: number, bias: number, alpha: number, - beta: number) { - const rad = radius; - const maxD = xShape[3] - 1; - this.outputShape = xShape; - - // optimize pow(bias + alpha * sum, -beta) - // src: https://github.com/tensorflow/tensorflow/.. - // blob/26033a1644a9c4a5fbe3170ab2e864b6a4ccd4ca/.. - // tensorflow/core/kernels/mkl_lrn_op.cc#L320 - let powOperator; - const basis = `float(${bias}) + float(${alpha}) * sum`; - if (beta === 0.5) { - powOperator = `inversesqrt(${basis})`; - } else if (beta === 1.0) { - powOperator = `1.0/(${basis})`; - } else { - powOperator = `exp(log(${basis}) * float(-${beta}));`; - } - - this.userCode = ` - void main() { - ivec4 coords = getOutputCoords(); - int b = coords[0]; - int r = coords[1]; - int c = coords[2]; - int d = coords[3]; - float x = getX(b, r, c, d); - float sum = 0.0; - for (int j = -${rad}; j <= ${rad}; j++) { - int idx = d + j; - if (idx >= 0 && idx <= ${maxD}) { - float z = getX(b, r, c, idx); - sum += z * z; - } - } - float val = x * ${powOperator}; - setOutput(val); - } - `; - } -} diff --git a/tfjs-master/tfjs-backend-webgl/src/lrn_grad_gpu.ts b/tfjs-master/tfjs-backend-webgl/src/lrn_grad_gpu.ts deleted file mode 100644 index 998f535c8..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/lrn_grad_gpu.ts +++ /dev/null @@ -1,96 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {GPGPUProgram} from './gpgpu_math'; - -export class LRNGradProgram implements GPGPUProgram { - variableNames = ['inputImage', 'outputImage', 'dy']; - outputShape: number[] = []; - userCode: string; - depthRadius: number; - bias: number; - alpha: number; - beta: number; - depth: number; - - constructor( - inputShape: number[], depthRadius: number, bias: number, alpha: number, - beta: number) { - this.outputShape = inputShape; - this.depth = inputShape[3]; - this.depthRadius = depthRadius; - this.bias = bias; - this.alpha = alpha; - this.beta = beta; - this.userCode = ` - void main() { - ivec4 coords = getOutputCoords(); - int b = coords[0]; - int r = coords[1]; - int c = coords[2]; - - float result = 0.0; - for (int d = 0; d < ${this.depth}; ++d) { - int depthBegin = int(max(0.0, float(d - ${depthRadius}))); - int depthEnd = int(min(float(${this.depth}), - float(d + ${depthRadius} + 1))); - - const int MIN_DEPTH_BEGIN = 0; - const int MAX_DEPTH_END = ${this.depth}; - - float norm = 0.0; - for (int k = MIN_DEPTH_BEGIN; k < MAX_DEPTH_END; ++k) { - if (k < depthBegin){ - continue; - } - else if (k >= depthBegin && k < depthEnd) { - norm += getInputImage(b, r, c, k) * getInputImage(b, r, c, k); - } - else { - break; - } - } - - norm = float(${alpha}) * norm + float(${bias}); - - for(int k = MIN_DEPTH_BEGIN; k < MAX_DEPTH_END; ++k){ - if (k < depthBegin){ - continue; - } - else if (k >= depthBegin && k < depthEnd){ - float dyi = -2.0 * float(${alpha}) - * float(${beta}) - * getInputImage(b, r, c, k) * getOutputImage(b, r, c, d) - / norm; - if (k == d) { - dyi += pow(norm, -1.0 * ${beta}); - } - if (k == coords[3]) { - dyi *= getDy(b, r, c, d); - result += dyi; - } - } - else { - break; - } - } - } - setOutput(result); - } - `; - } -} diff --git a/tfjs-master/tfjs-backend-webgl/src/lrn_packed_gpu.ts b/tfjs-master/tfjs-backend-webgl/src/lrn_packed_gpu.ts deleted file mode 100644 index b2d83c863..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/lrn_packed_gpu.ts +++ /dev/null @@ -1,112 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {GPGPUProgram} from './gpgpu_math'; - -export class LRNPackedProgram implements GPGPUProgram { - variableNames = ['x']; - outputShape: number[] = []; - userCode: string; - packedInputs = true; - packedOutput = true; - - constructor( - xShape: number[], radius: number, bias: number, alpha: number, - beta: number) { - const rad = radius; - const maxD = xShape[3] - 1; - this.outputShape = xShape; - - // optimize pow(bias + alpha * sum, -beta) - // src: https://github.com/tensorflow/tensorflow/.. - // blob/26033a1644a9c4a5fbe3170ab2e864b6a4ccd4ca/.. - // tensorflow/core/kernels/mkl_lrn_op.cc#L320 - let powOperator; - const basis = `float(${bias}) + float(${alpha}) * sum`; - if (beta === 0.5) { - powOperator = `inversesqrt(${basis})`; - } else if (beta === 1.0) { - powOperator = `1.0/(${basis})`; - } else { - powOperator = `exp(log(${basis}) * float(-${beta}));`; - } - - this.userCode = ` - void main() { - ivec4 coords = getOutputCoords(); - int b = coords.x; - int r = coords.y; - int c = coords.z; - int d = coords.w; - - bool hasNextCol = d < ${this.outputShape[3]}; - bool hasNextRow = c < ${this.outputShape[2]}; - - vec4 sum = vec4(0.); - vec4 xFragAtOutputCoords = getX(b, r, c, d); - - vec4 xAtOutputCoords = vec4( - getChannel(xFragAtOutputCoords, vec2(c, d)), - hasNextCol ? - getChannel(xFragAtOutputCoords, vec2(c, d + 1)) : 0.0, - hasNextRow ? - getChannel(xFragAtOutputCoords , vec2(c + 1, d)) : 0.0, - (hasNextRow && hasNextCol) ? - getChannel(xFragAtOutputCoords, vec2(c + 1, d + 1)) : 0.0 - ); - - int firstChannel = d - ${rad}; - vec2 cache = vec2(0.); - if(firstChannel >= 0){ - vec4 firstChannelFrag = getX(b, r, c, firstChannel); - cache.x = getChannel(firstChannelFrag, vec2(c, firstChannel)); - if(hasNextRow){ - cache.y = getChannel(firstChannelFrag, vec2(c + 1, firstChannel)); - } - } - - ivec2 depth = ivec2(d, d + 1); - for (int j = - ${rad}; j <= ${rad}; j++) { - ivec2 idx = depth + j; - bvec2 aboveLowerBound = greaterThanEqual(idx, ivec2(0)); - bvec2 belowUpperBound = lessThanEqual(idx, ivec2(${maxD})); - - bool depthInRange = aboveLowerBound.x && belowUpperBound.x; - bool depthPlusOneInRange = aboveLowerBound.y && belowUpperBound.y; - - if(depthInRange || depthPlusOneInRange){ - vec4 z = vec4(0.); - vec4 xFragAtCurrentDepth; - z.xz = cache.xy; - if(depthPlusOneInRange && hasNextCol){ - xFragAtCurrentDepth = idx.y != d ? - getX(b, r, c, idx.y) : xFragAtOutputCoords; - z.y = getChannel(xFragAtCurrentDepth, vec2(c, idx.y)); - if(hasNextRow){ - z.w = getChannel(xFragAtCurrentDepth, vec2(c + 1, idx.y)); - } - } - cache.xy = z.yw; - sum += z * z; - } - } - vec4 result = xAtOutputCoords * ${powOperator}; - setOutput(result); - } - `; - } -} diff --git a/tfjs-master/tfjs-backend-webgl/src/max_pool_backprop_gpu.ts b/tfjs-master/tfjs-backend-webgl/src/max_pool_backprop_gpu.ts deleted file mode 100644 index 69df54299..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/max_pool_backprop_gpu.ts +++ /dev/null @@ -1,177 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util} from '@tensorflow/tfjs-core'; -import {GPGPUProgram} from './gpgpu_math'; - -export class MaxPool2DBackpropProgram implements GPGPUProgram { - variableNames = ['dy', 'maxPos']; - outputShape: number[]; - userCode: string; - - constructor(convInfo: backend_util.Conv2DInfo) { - this.outputShape = convInfo.inShape; - const strideHeight = convInfo.strideHeight; - const strideWidth = convInfo.strideWidth; - const dilationHeight = convInfo.dilationHeight; - const effectiveFilterHeight = convInfo.effectiveFilterHeight; - const effectiveFilterWidth = convInfo.effectiveFilterWidth; - - const padTop = effectiveFilterHeight - 1 - convInfo.padInfo.top; - const padLeft = effectiveFilterWidth - 1 - convInfo.padInfo.left; - - const lastIndex = effectiveFilterHeight * effectiveFilterWidth - 1; - this.userCode = ` - const ivec2 pads = ivec2(${padTop}, ${padLeft}); - - void main() { - ivec4 coords = getOutputCoords(); - int b = coords[0]; - int d = coords[3]; - - ivec2 dyRCCorner = coords.yz - pads; - int dyRCorner = dyRCCorner.x; - int dyCCorner = dyRCCorner.y; - - // Convolve dy(?, ?, d) with pos mask(:, :, d) to get dx(xR, xC, d). - // ? = to be determined. : = across all values in that axis. - float dotProd = 0.0; - for (int wR = 0; wR < ${effectiveFilterHeight}; - wR += ${dilationHeight}) { - float dyR = float(dyRCorner + wR) / ${strideHeight}.0; - - if (dyR < 0.0 || dyR >= ${convInfo.outHeight}.0 || fract(dyR) > 0.0) { - continue; - } - int idyR = int(dyR); - - for (int wC = 0; wC < ${effectiveFilterWidth}; wC++) { - float dyC = float(dyCCorner + wC) / ${strideWidth}.0; - - if (dyC < 0.0 || dyC >= ${convInfo.outWidth}.0 || - fract(dyC) > 0.0) { - continue; - } - int idyC = int(dyC); - - float dyValue = getDy(b, idyR, idyC, d); - int maxPosValue = ${lastIndex} - int(getMaxPos(b, idyR, idyC, d)); - - // Get the current value, check it against the value from the - // position matrix. - int curPosValue = wR * ${effectiveFilterWidth} + wC; - float mask = float(maxPosValue == curPosValue ? 1.0 : 0.0); - - dotProd += dyValue * mask; - } - } - setOutput(dotProd); - } - `; - } -} - -export class MaxPool3DBackpropProgram implements GPGPUProgram { - variableNames = ['dy', 'maxPos']; - outputShape: number[]; - userCode: string; - - constructor(convInfo: backend_util.Conv3DInfo) { - this.outputShape = convInfo.inShape; - const strideDepth = convInfo.strideDepth; - const strideHeight = convInfo.strideHeight; - const strideWidth = convInfo.strideWidth; - const dilationDepth = convInfo.dilationDepth; - const dilationHeight = convInfo.dilationHeight; - const dilationWidth = convInfo.dilationWidth; - const effectiveFilterDepth = convInfo.effectiveFilterDepth; - const effectiveFilterHeight = convInfo.effectiveFilterHeight; - const effectiveFilterWidth = convInfo.effectiveFilterWidth; - - const padFront = effectiveFilterDepth - 1 - convInfo.padInfo.front; - const padTop = effectiveFilterHeight - 1 - convInfo.padInfo.top; - const padLeft = effectiveFilterWidth - 1 - convInfo.padInfo.left; - - const lastIndex = - effectiveFilterDepth * effectiveFilterHeight * effectiveFilterWidth - 1; - this.userCode = ` - const ivec3 pads = ivec3(${padFront}, ${padTop}, ${padLeft}); - - void main() { - ivec5 coords = getOutputCoords(); - int batch = coords.x; - int ch = coords.u; - - ivec3 dyCorner = ivec3(coords.y, coords.z, coords.w) - pads; - int dyDCorner = dyCorner.x; - int dyRCorner = dyCorner.y; - int dyCCorner = dyCorner.z; - - // Convolve dy(?, ?, ?, ch) with pos mask(:, :, :, d) to get - // dx(xD, xR, xC, ch). - // ? = to be determined. : = across all values in that axis. - float dotProd = 0.0; - - for (int wD = 0; wD < ${effectiveFilterDepth}; - wD += ${dilationDepth}) { - float dyD = float(dyDCorner + wD) / ${strideDepth}.0; - - if (dyD < 0.0 || dyD >= ${convInfo.outDepth}.0 || fract(dyD) > 0.0) { - continue; - } - int idyD = int(dyD); - - for (int wR = 0; wR < ${effectiveFilterHeight}; - wR += ${dilationHeight}) { - float dyR = float(dyRCorner + wR) / ${strideHeight}.0; - - if (dyR < 0.0 || dyR >= ${convInfo.outHeight}.0 || - fract(dyR) > 0.0) { - continue; - } - int idyR = int(dyR); - - for (int wC = 0; wC < ${effectiveFilterWidth}; - wC += ${dilationWidth}) { - float dyC = float(dyCCorner + wC) / ${strideWidth}.0; - - if (dyC < 0.0 || dyC >= ${convInfo.outWidth}.0 || - fract(dyC) > 0.0) { - continue; - } - int idyC = int(dyC); - - float dyValue = getDy(batch, idyD, idyR, idyC, ch); - int maxPosValue = ${lastIndex} - - int(getMaxPos(batch, idyD, idyR, idyC, ch)); - - // Get the current value, check it against the value from the - // position matrix. - int curPosValue = - wD * ${effectiveFilterHeight} * ${effectiveFilterWidth} + - wR * ${effectiveFilterWidth} + wC; - float mask = float(maxPosValue == curPosValue ? 1.0 : 0.0); - - dotProd += dyValue * mask; - } - } - } - setOutput(dotProd); - } - `; - } -} diff --git a/tfjs-master/tfjs-backend-webgl/src/mean_gpu.ts b/tfjs-master/tfjs-backend-webgl/src/mean_gpu.ts deleted file mode 100644 index bc695e7d4..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/mean_gpu.ts +++ /dev/null @@ -1,101 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, util} from '@tensorflow/tfjs-core'; -import {GPGPUProgram} from './gpgpu_math'; - -export class MeanProgram implements GPGPUProgram { - variableNames = ['x']; - outputShape: number[]; - userCode: string; - - constructor(reduceInfo: backend_util.ReduceInfo, divisor?: number) { - const {windowSize, batchSize, inSize, outSize} = reduceInfo; - this.outputShape = [batchSize, outSize]; - - const windowSizeNearestVec4 = Math.floor(windowSize / 4) * 4; - const windowSizeVec4Remainder = windowSize % 4; - - let updateSnippet = `sumValue += dot(values, ones);`; - if (divisor != null) { - const denominator = 1 / divisor; - updateSnippet = `sumValue += dot(values * ${ - util.isInt(denominator) ? denominator.toPrecision(2) : - denominator}, ones);`; - } - - let checkOutOfBounds = ''; - if (inSize % windowSize > 0) { - checkOutOfBounds = ` - if (inIdx < 0 || inIdx >= ${inSize}) { - return 0.0; - } - `; - } - - this.userCode = ` - const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0); - - float getValue(int batch, int inIdx) { - ${checkOutOfBounds} - return getX(batch, inIdx); - } - - void main() { - ivec2 coords = getOutputCoords(); - int batch = coords[0]; - int outIdx = coords[1]; - int inOffset = outIdx * ${windowSize}; - - float sumValue = 0.0; - - for (int i = 0; i < ${windowSizeNearestVec4}; i += 4) { - int inIdx = inOffset + i; - vec4 values = vec4( - getValue(batch, inIdx), - getValue(batch, inIdx + 1), - getValue(batch, inIdx + 2), - getValue(batch, inIdx + 3) - ); - - ${updateSnippet} - } - - int inIdx = inOffset + ${windowSizeNearestVec4}; - if (${windowSizeVec4Remainder === 1}) { - vec4 values = vec4(getValue(batch, inIdx), 0.0, 0.0, 0.0); - - ${updateSnippet} - } else if (${windowSizeVec4Remainder === 2}) { - vec4 values = vec4( - getValue(batch, inIdx), - getValue(batch, inIdx + 1), 0.0, 0.0); - - ${updateSnippet} - } else if (${windowSizeVec4Remainder === 3}) { - vec4 values = vec4( - getValue(batch, inIdx), - getValue(batch, inIdx + 1), - getValue(batch, inIdx + 2), 0.0); - - ${updateSnippet} - } - setOutput(sumValue); - } - `; - } -} diff --git a/tfjs-master/tfjs-backend-webgl/src/mirror_pad_gpu.ts b/tfjs-master/tfjs-backend-webgl/src/mirror_pad_gpu.ts deleted file mode 100644 index f9f4faaf4..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/mirror_pad_gpu.ts +++ /dev/null @@ -1,75 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {GPGPUProgram} from './gpgpu_math'; -import {getCoordsDataType} from './shader_compiler'; - -export class MirrorPadProgram implements GPGPUProgram { - variableNames = ['x']; - outputShape: number[]; - userCode: string; - - constructor( - xShape: number[], paddings: Array<[number, number]>, - mode: 'reflect'|'symmetric') { - this.outputShape = paddings.map( - (p, i) => p[0] /* beforePad */ + xShape[i] + p[1] /* afterPad */); - const rank = xShape.length; - const dtype = getCoordsDataType(rank); - - const start = paddings.map(p => p[0]).join(','); - const end = paddings.map((p, i) => p[0] + xShape[i]).join(','); - const unpackedCoords = - ['coords[0]', 'coords[1]', 'coords[2]', 'coords[3]'].slice(0, rank); - const offset = mode === 'reflect' ? 0 : 1; - - if (rank === 1) { - this.userCode = ` - int start = ${start}; - int end = ${end}; - - void main() { - int outC = getOutputCoords(); - if (outC < start) { - outC = start * 2 - outC - ${offset}; - } else if(outC >= end) { - outC = (end - 1) * 2 - outC + ${offset}; - } - setOutput(getX(outC - start)); - } - `; - return; - } - this.userCode = ` - ${dtype} start = ${dtype}(${start}); - ${dtype} end = ${dtype}(${end}); - - void main() { - ${dtype} outC = getOutputCoords(); - for (int i = 0; i < ${rank}; i++) { - if (outC[i] < start[i]) { - outC[i] = start[i] * 2 - outC[i] - ${offset}; - } else if(outC[i] >= end[i]) { - outC[i] = (end[i] - 1) * 2 - outC[i] + ${offset}; - } - } - ${dtype} coords = outC - start; - setOutput(getX(${unpackedCoords})); - } - `; - } -} diff --git a/tfjs-master/tfjs-backend-webgl/src/mirror_pad_packed_gpu.ts b/tfjs-master/tfjs-backend-webgl/src/mirror_pad_packed_gpu.ts deleted file mode 100644 index e684c1516..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/mirror_pad_packed_gpu.ts +++ /dev/null @@ -1,153 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {GPGPUProgram} from './gpgpu_math'; -import {getChannels} from './packing_util'; -import {getCoordsDataType} from './shader_compiler'; - -/** - * Example shader code for - * `mirrorPad(tf.tensor1d([1, 2, 3], 'int32'), [[2, 2]], 'reflect')` - * ``` - * const int start = int(2); - * const int end = int(5); - * - * void main() { - * int outputLoc = getOutputCoords(); - * vec4 result = vec4(0.); - * - * int rc = outputLoc; - * - * int source = rc; - * if (source < start) { - * source = start * 2 - source - 0; - * } else if (source >= end) { - * source = (end - 1) * 2 - source + 0; - * } - * source -= start; - * - * result[0] = getChannel(getX(source), source); - * rc += 1; - * if(rc < 6) { - * int source = rc; - * if (source < start) { - * source = start * 2 - source - 0; - * } else if (source >= end) { - * source = (end - 1) * 2 - source + 0; - * } - * source -= start; - * - * result[1] = getChannel(getX(source), source); - * } - * - * setOutput(result); - * } - * ``` - */ -export class MirrorPadPackedProgram implements GPGPUProgram { - variableNames = ['x']; - packedInputs = true; - packedOutput = true; - outputShape: number[]; - userCode: string; - - constructor( - xShape: number[], paddings: Array<[number, number]>, - mode: 'reflect'|'symmetric') { - this.outputShape = paddings.map( - (p, i) => p[0] /* beforePad */ + xShape[i] + p[1] /* afterPad */); - const rank = xShape.length; - const dtype = getCoordsDataType(rank); - - const start = paddings.map(p => p[0]).join(','); - const end = paddings.map((p, i) => p[0] + xShape[i]).join(','); - const coords = getChannels('rc', rank); - const source = getChannels('source', rank); - const cLimit = `${coords[rank - 1]} < ${this.outputShape[rank - 1]}`; - const innerDims = - rank === 1 ? 'source' : `vec2(${source.slice(-2).join()})`; - const offset = mode === 'reflect' ? 0 : 1; - - let mainLoop = ''; - if (rank === 1) { - const padSetup = ` - ${dtype} source = rc; - if (source < start) { - source = start * 2 - source - ${offset}; - } else if (source >= end) { - source = (end - 1) * 2 - source + ${offset}; - } - source -= start; - `; - mainLoop = ` - ${dtype} rc = outputLoc; - ${padSetup} - result[0] = getChannel(getX(${source.join()}), ${innerDims}); - ${coords[rank - 1]} += 1; - if(${cLimit}) { - ${padSetup} - result[1] = getChannel(getX(${source.join()}), ${innerDims}); - } - `; - } else { - const padSetup = ` - ${dtype} source = rc; - ${dtype} lt = ${dtype}(lessThan(source, start)); - ${dtype} gte = ${dtype}(greaterThanEqual(source, end)); - ${dtype} orig = 1 - (lt + gte); - source = orig * source + - lt * (start * 2 - source - ${offset}) + - gte * ((end - 1) * 2 - source + ${offset}); - source -= start; - `; - - mainLoop = ` - ${dtype} rc = outputLoc; - ${padSetup} - result[0] = getChannel(getX(${source.join()}), ${innerDims}); - ${coords[rank - 1]} += 1; - if(${cLimit}) { - ${padSetup} - result[1] = getChannel(getX(${source.join()}), ${innerDims}); - } - rc = outputLoc; - ${coords[rank - 2]} += 1; - if(${coords[rank - 2]} < ${this.outputShape[rank - 2]}) { - ${padSetup} - result[2] = getChannel(getX(${source.join()}), ${innerDims}); - ${coords[rank - 1]} += 1; - if(${cLimit}) { - ${padSetup} - result[3] = getChannel(getX(${source.join()}), ${innerDims}); - } - } - `; - } - - this.userCode = ` - const ${dtype} start = ${dtype}(${start}); - const ${dtype} end = ${dtype}(${end}); - - void main() { - ${dtype} outputLoc = getOutputCoords(); - vec4 result = vec4(0.); - ${mainLoop} - setOutput(result); - } - `; - } -} diff --git a/tfjs-master/tfjs-backend-webgl/src/mulmat_packed_gpu.ts b/tfjs-master/tfjs-backend-webgl/src/mulmat_packed_gpu.ts deleted file mode 100644 index 3a19ded1e..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/mulmat_packed_gpu.ts +++ /dev/null @@ -1,119 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {GPGPUProgram, useShapeUniforms} from './gpgpu_math'; - -export class MatMulPackedProgram implements GPGPUProgram { - variableNames = ['matrixA', 'matrixB']; - packedInputs = true; - packedOutput = true; - outputShape: number[]; - userCode: string; - enableShapeUniforms: boolean; - - constructor( - aShape: [number, number, number], bShape: [number, number, number], - outputShape: [number, number, number], transposeA = false, - transposeB = false, addBias = false, activation: string = null, - hasPreluActivation = false, hasLeakyreluActivation = false) { - this.outputShape = outputShape; - this.enableShapeUniforms = useShapeUniforms(this.outputShape.length); - - const sharedDim = transposeA ? aShape[1] : aShape[2]; - const sharedDimensionPacked = Math.ceil(sharedDim / 2); - - const aSample = transposeA ? 'i * 2, rc.y' : 'rc.y, i * 2'; - const bSample = transposeB ? 'rc.z, i * 2' : 'i * 2, rc.z'; - const aSwizzle = transposeA ? ['a.xxyy', 'a.zzww'] : ['a.xxzz', 'a.yyww']; - const bSwizzle = transposeB ? ['b.xzxz', 'b.ywyw'] : ['b.xyxy', 'b.zwzw']; - - let activationSnippet = '', applyActivationSnippet = ''; - if (activation) { - if (hasPreluActivation) { - activationSnippet = `vec4 activation(vec4 a) { - vec4 b = getPreluActivationWeightsAtOutCoords(); - ${activation} - }`; - } else if (hasLeakyreluActivation) { - activationSnippet = `vec4 activation(vec4 a) { - vec4 b = getLeakyreluAlphaAtOutCoords(); - ${activation} - }`; - } else { - activationSnippet = `vec4 activation(vec4 x) { - ${activation} - }`; - } - - applyActivationSnippet = `result = activation(result);`; - } - - const addBiasSnippet = addBias ? 'result += getBiasAtOutCoords();' : ''; - if (addBias) { - this.variableNames.push('bias'); - } - - if (hasPreluActivation) { - this.variableNames.push('preluActivationWeights'); - } - - if (hasLeakyreluActivation) { - this.variableNames.push('leakyreluAlpha'); - } - - let batchASnippet = 'rc.x'; - let batchBSnippet = 'rc.x'; - if (aShape[0] < bShape[0]) { - batchASnippet = `imod(rc.x, ${aShape[0]})`; - } else if (bShape[0] < aShape[0]) { - batchBSnippet = `imod(rc.x, ${bShape[0]})`; - } - - this.userCode = ` - ${activationSnippet} - // Don't use uniform for sharedDimensionPacked for performance. - const float sharedDimension = ${sharedDimensionPacked}.0; - - vec4 dot2x2ARowBCol(ivec3 rc) { - vec4 result = vec4(0); - int batchA = ${batchASnippet}; - int batchB = ${batchBSnippet}; - for (int i = 0; i < ${sharedDimensionPacked}; i++) { - vec4 a = getMatrixA(batchA, ${aSample}); - vec4 b = getMatrixB(batchB, ${bSample}); - - // These swizzled products need to be separately added. - // See: https://github.com/tensorflow/tfjs/issues/1735 - result += (${aSwizzle[0]} * ${bSwizzle[0]}); - result += (${aSwizzle[1]} * ${bSwizzle[1]}); - } - return result; - } - - void main() { - ivec3 rc = getOutputCoords(); - vec4 result = dot2x2ARowBCol(rc); - - ${addBiasSnippet} - - ${applyActivationSnippet} - - setOutput(result); - } - `; - } -} diff --git a/tfjs-master/tfjs-backend-webgl/src/multinomial_gpu.ts b/tfjs-master/tfjs-backend-webgl/src/multinomial_gpu.ts deleted file mode 100644 index 429cb05e5..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/multinomial_gpu.ts +++ /dev/null @@ -1,52 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {GPGPUProgram} from './gpgpu_math'; -import {UniformType} from './shader_compiler'; - -export class MultinomialProgram implements GPGPUProgram { - variableNames = ['probs']; - outputShape: number[]; - userCode: string; - customUniforms = [{name: 'seed', type: 'float' as UniformType}]; - - constructor(batchSize: number, numOutcomes: number, numSamples: number) { - this.outputShape = [batchSize, numSamples]; - - this.userCode = ` - void main() { - ivec2 coords = getOutputCoords(); - int batch = coords[0]; - - float r = random(seed); - float cdf = 0.0; - - for (int i = 0; i < ${numOutcomes - 1}; i++) { - cdf += getProbs(batch, i); - - if (r < cdf) { - setOutput(float(i)); - return; - } - } - - // If no other event happened, last event happened. - setOutput(float(${numOutcomes - 1})); - } - `; - } -} diff --git a/tfjs-master/tfjs-backend-webgl/src/onehot_gpu.ts b/tfjs-master/tfjs-backend-webgl/src/onehot_gpu.ts deleted file mode 100644 index 9f1519857..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/onehot_gpu.ts +++ /dev/null @@ -1,41 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {GPGPUProgram} from './gpgpu_math'; - -export class OneHotProgram implements GPGPUProgram { - variableNames = ['indices']; - outputShape: number[]; - userCode: string; - - // Caching uniform location for speed. - seedLoc: WebGLUniformLocation; - - constructor( - numIndices: number, depth: number, onValue: number, offValue: number) { - this.outputShape = [numIndices, depth]; - - this.userCode = ` - void main() { - ivec2 coords = getOutputCoords(); - int index = round(getIndices(coords.x)); - setOutput(mix(float(${offValue}), float(${onValue}), - float(index == coords.y))); - } - `; - } -} diff --git a/tfjs-master/tfjs-backend-webgl/src/pack_gpu.ts b/tfjs-master/tfjs-backend-webgl/src/pack_gpu.ts deleted file mode 100644 index 5180732e3..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/pack_gpu.ts +++ /dev/null @@ -1,138 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {GPGPUProgram, useShapeUniforms} from './gpgpu_math'; -import {getChannels} from './packing_util'; -import {getCoordsDataType} from './shader_compiler'; - -export class PackProgram implements GPGPUProgram { - variableNames = ['A']; - outputShape: number[]; - userCode: string; - packedInputs = false; - packedOutput = true; - enableShapeUniforms: boolean; - rank: number; - - constructor( - outputShape: - number[]) { // TODO(https://github.com/tensorflow/tfjs/issues/893): - // Only input / output 3D tensors. - this.outputShape = outputShape; - this.rank = outputShape.length; - this.enableShapeUniforms = useShapeUniforms(this.outputShape.length); - - if (this.rank === 0) { - this.userCode = ` - void main() { - setOutput(vec4(getA(), 0., 0., 0.)); - } - `; - } else { - const channels = getChannels('rc', this.rank); - const dtype = getCoordsDataType(this.rank); - const outOfBoundsCondition = this.getOutOfBoundsCondition(channels); - const setup = this.getSetup(channels); - const output = this.getOutput(channels); - - this.userCode = ` - void main() { - ${dtype} rc = getOutputCoords(); - - if(${outOfBoundsCondition}) { - setOutput(vec4(0)); - } else { - ${setup} - - setOutput(vec4(${output})); - } - } - `; - } - } - - private getSourceCoordsArr(dims: string[]): string[] { - const coords = []; - - for (let row = 0; row <= 1; row++) { - for (let col = 0; col <= 1; col++) { - let coord = `${row === 0 ? 'r' : 'rp1'}, ${col === 0 ? 'c' : 'cp1'}`; - - for (let d = 2; d < this.rank; d++) { - coord = `${dims[dims.length - 1 - d]},` + coord; - } - - coords.push(coord); - } - } - return coords; - } - - private getOutOfBoundsCondition(dims: string[]): string { - if (this.rank === 1) { - return `rc > ${ - this.enableShapeUniforms ? 'outShape' : this.outputShape[0]}`; - } - - let cond = ''; - for (let i = this.rank - 2; i < this.rank; i++) { - cond += `${dims[i]} >= ${ - this.enableShapeUniforms ? `outShape[${i}]` : this.outputShape[i]}`; - if (i < this.rank - 1) { - cond += '||'; - } - } - - return cond; - } - - private getSetup(dims: string[]): string { - if (this.rank === 1) { - return ''; - } - - const innerDims = dims.slice(-2); - const col = this.enableShapeUniforms ? `outShape[${this.rank} - 1]` : - this.outputShape[this.rank - 1]; - const row = this.enableShapeUniforms ? `outShape[${this.rank} - 2]` : - this.outputShape[this.rank - 2]; - - return ` - int r = ${innerDims[0]}; - int c = ${innerDims[1]}; - int rp1 = r + 1; - int cp1 = c + 1; - - bool cEdge = cp1 >= ${col}; - bool rEdge = rp1 >= ${row}; - `; - } - - private getOutput(dims: string[]): string { - const sourceCoords = this.getSourceCoordsArr(dims); - if (this.rank === 1) { - const outShape = - this.enableShapeUniforms ? 'outShape' : this.outputShape[0]; - return `getA(rc), (rc + 1 >= ${outShape} ? 0. : getA(rc + 1)), 0, 0`; - } - - return `getA(${sourceCoords[0]}), - cEdge ? 0. : getA(${sourceCoords[1]}), - rEdge ? 0. : getA(${sourceCoords[2]}), - rEdge || cEdge ? 0. : getA(${sourceCoords[3]})`; - } -} diff --git a/tfjs-master/tfjs-backend-webgl/src/packing_util.ts b/tfjs-master/tfjs-backend-webgl/src/packing_util.ts deleted file mode 100644 index cd0350708..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/packing_util.ts +++ /dev/null @@ -1,42 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -export function getVecChannels(name: string, rank: number): string[] { - return ['x', 'y', 'z', 'w', 'u', 'v'].slice(0, rank).map(d => `${name}.${d}`); -} - -export function getChannels(name: string, rank: number): string[] { - if (rank === 1) { - return [name]; - } - return getVecChannels(name, rank); -} - -export function getSourceCoords(rank: number, dims: string[]): string { - if (rank === 1) { - return 'rc'; - } - - let coords = ''; - for (let i = 0; i < rank; i++) { - coords += dims[i]; - if (i < rank - 1) { - coords += ','; - } - } - return coords; -} \ No newline at end of file diff --git a/tfjs-master/tfjs-backend-webgl/src/pad_gpu.ts b/tfjs-master/tfjs-backend-webgl/src/pad_gpu.ts deleted file mode 100644 index eb0d2b2d0..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/pad_gpu.ts +++ /dev/null @@ -1,71 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {GPGPUProgram} from './gpgpu_math'; -import {getCoordsDataType, UniformType} from './shader_compiler'; - -export class PadProgram implements GPGPUProgram { - variableNames = ['x']; - outputShape: number[]; - userCode: string; - customUniforms = [{name: 'value', type: 'float' as UniformType}]; - - constructor( - xShape: number[], paddings: Array<[number, number]>, - constantValue: number) { - this.outputShape = paddings.map( - (p, i) => p[0] /* beforePad */ + xShape[i] + p[1] /* afterPad */); - const rank = xShape.length; - const type = getCoordsDataType(rank); - - const start = paddings.map(p => p[0]).join(','); - const end = paddings.map((p, i) => p[0] + xShape[i]).join(','); - const unpackedCoords = - ['coords[0]', 'coords[1]', 'coords[2]', 'coords[3]'].slice(0, rank); - - if (rank === 1) { - this.userCode = ` - int start = ${start}; - int end = ${end}; - - void main() { - int outC = getOutputCoords(); - if (outC < start || outC >= end) { - setOutput(value); - } else { - setOutput(getX(outC - start)); - } - } - `; - return; - } - this.userCode = ` - ${type} start = ${type}(${start}); - ${type} end = ${type}(${end}); - - void main() { - ${type} outC = getOutputCoords(); - if (any(lessThan(outC, start)) || any(greaterThanEqual(outC, end))) { - setOutput(value); - } else { - ${type} coords = outC - start; - setOutput(getX(${unpackedCoords})); - } - } - `; - } -} diff --git a/tfjs-master/tfjs-backend-webgl/src/pad_packed_gpu.ts b/tfjs-master/tfjs-backend-webgl/src/pad_packed_gpu.ts deleted file mode 100644 index 4f7c67ddf..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/pad_packed_gpu.ts +++ /dev/null @@ -1,87 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {GPGPUProgram} from './gpgpu_math'; -import {getChannels} from './packing_util'; -import {getCoordsDataType, UniformType} from './shader_compiler'; - -export class PadPackedProgram implements GPGPUProgram { - variableNames = ['x']; - packedInputs = true; - packedOutput = true; - outputShape: number[]; - userCode: string; - customUniforms = [{name: 'value', type: 'float' as UniformType}]; - - constructor( - xShape: number[], paddings: Array<[number, number]>, - constantValue: number) { - this.outputShape = paddings.map( - (p, i) => p[0] /* beforePad */ + xShape[i] + p[1] /* afterPad */); - const rank = xShape.length; - const dtype = getCoordsDataType(rank); - - const start = paddings.map(p => p[0]).join(','); - const end = paddings.map((p, i) => p[0] + xShape[i]).join(','); - const coords = getChannels('rc', rank); - const source = getChannels('source', rank); - const cLimit = `${coords[rank - 1]} < ${this.outputShape[rank - 1]}`; - const innerDims = - rank === 1 ? 'source' : `vec2(${source.slice(-2).join()})`; - - const componentSetup = [ - `${dtype} rc = outputLoc;`, `${coords[rank - 1]} += 1; - if(${cLimit}) { - `, - rank === 1 ? '' : `} - rc = outputLoc; - ${coords[rank - 2]} += 1; - if(${coords[rank - 2]} < ${this.outputShape[rank - 2]}) {`, - rank === 1 ? '' : ` ${coords[rank - 1]} += 1; - if(${cLimit}) {` - ]; - - const paddingArea = rank === 1 ? - 'rc < start || rc >= end' : - 'any(lessThan(rc, start)) || any(greaterThanEqual(rc, end))'; - let mainLoop = ''; - for (let i = 0, j = rank === 1 ? 2 : 4; i < j; i++) { - mainLoop += ` - ${componentSetup[i]} - if (${paddingArea}) { - result[${i}] = float(value); - } else { - ${dtype} source = rc - start; - result[${i}] = getChannel(getX(${source.join()}), ${innerDims}); - } - `; - } - mainLoop += (rank === 1 ? `} ` : `}}`); - - this.userCode = ` - const ${dtype} start = ${dtype}(${start}); - const ${dtype} end = ${dtype}(${end}); - - void main() { - ${dtype} outputLoc = getOutputCoords(); - vec4 result = vec4(0.); - ${mainLoop} - setOutput(result); - } - `; - } -} diff --git a/tfjs-master/tfjs-backend-webgl/src/pool_gpu.ts b/tfjs-master/tfjs-backend-webgl/src/pool_gpu.ts deleted file mode 100644 index f3ea8e4d7..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/pool_gpu.ts +++ /dev/null @@ -1,459 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util} from '@tensorflow/tfjs-core'; -import {GPGPUProgram} from './gpgpu_math'; - -export class Pool2DProgram implements GPGPUProgram { - variableNames = ['x']; - outputShape: number[]; - userCode: string; - - constructor( - convInfo: backend_util.Conv2DInfo, poolType: 'max'|'avg', - computePositions: boolean, flattenPositions = false, - includeBatchInIndex = false) { - if (poolType === 'avg' && computePositions) { - throw new Error('Cannot compute positions for average pool.'); - } - - const filterWidth = convInfo.filterWidth; - const strideHeight = convInfo.strideHeight; - const strideWidth = convInfo.strideWidth; - const dilationHeight = convInfo.dilationHeight; - const dilationWidth = convInfo.dilationWidth; - const effectiveFilterHeight = convInfo.effectiveFilterHeight; - const effectiveFilterWidth = convInfo.effectiveFilterWidth; - - const padTop = convInfo.padInfo.top; - const padLeft = convInfo.padInfo.left; - this.outputShape = convInfo.outShape; - - const isAvgPool = poolType === 'avg'; - const batchFlattenPositionStr = `((batch * ${convInfo.inHeight} + xR) * ${ - convInfo.inWidth} + xC) * ${convInfo.inChannels} + d`; - const flattenPositionStr = - `(xR * ${convInfo.inWidth} + xC) * ${convInfo.inChannels} + d`; - - let initializationValue = '0.0'; - if (!isAvgPool) { - // WebGL on Firefox Linux can't compile 1/0 so we do 1/eps. - initializationValue = '-1.0 / 1e-20'; - } - - if (computePositions) { - const compareOp = '>='; - - this.userCode = ` - const ivec2 strides = ivec2(${strideHeight}, ${strideWidth}); - const ivec2 pads = ivec2(${padTop}, ${padLeft}); - - void main() { - ivec4 coords = getOutputCoords(); - int batch = coords[0]; - int d = coords[3]; - - ivec2 xRCCorner = coords.yz * strides - pads; - int xRCorner = xRCCorner.x; - int xCCorner = xRCCorner.y; - - // max/min x(?, ?, d) to get y(yR, yC, d). - // ? = to be determined - float minMaxValue = 0.0; - float minMaxValueFound = 0.0; - int minMaxPosition = 0; - float avgValue = 0.0; - - for (int wR = 0; wR < ${effectiveFilterHeight}; - wR += ${dilationHeight}) { - int xR = xRCorner + wR; - - if (xR < 0 || xR >= ${convInfo.inHeight}) { - continue; - } - - for (int wC = 0; wC < ${effectiveFilterWidth}; - wC += ${dilationWidth}) { - int xC = xCCorner + wC; - - if (xC < 0 || xC >= ${convInfo.inWidth}) { - continue; - } - - float value = getX(batch, xR, xC, d); - - // If a min / max value has already been found, use it. If not, - // use the current value. - float currMinMaxValue = mix( - value, minMaxValue, minMaxValueFound); - if (value ${compareOp} currMinMaxValue) { - minMaxValue = value; - minMaxValueFound = 1.0; - minMaxPosition = ${ - flattenPositions ? (includeBatchInIndex ? batchFlattenPositionStr : - flattenPositionStr) : - `wR * ${effectiveFilterWidth} + wC`}; - } - } - } - setOutput(float(minMaxPosition)); - } - `; - return; - } - - const compareOp = 'max'; - - let returnValue = `${poolType}(${poolType}(${poolType}(` + - 'minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])'; - if (poolType === 'avg') { - returnValue = `avgValue / max(count, 1.0)`; - } - - const filterWidthNearestVec4 = Math.floor(filterWidth / 4) * 4; - const filterWidthVec4Remainder = filterWidth % 4; - - const updateSnippet = ` - if (${isAvgPool}) { - avgValue += dot(values, ones); - } else { - minMaxValue = ${compareOp}(values, minMaxValue); - } - `; - - this.userCode = ` - const ivec2 strides = ivec2(${strideHeight}, ${strideWidth}); - const ivec2 pads = ivec2(${padTop}, ${padLeft}); - const float initializationValue = ${initializationValue}; - const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0); - - float count = 0.0; - - float getValue(int batch, int xR, int xC, int d) { - if (xC < 0 || xC >= ${convInfo.inWidth}) { - return initializationValue; - } - count += 1.0; - return getX(batch, xR, xC, d); - } - - void main() { - ivec4 coords = getOutputCoords(); - int batch = coords[0]; - int d = coords[3]; - - ivec2 xRCCorner = coords.yz * strides - pads; - int xRCorner = xRCCorner.x; - int xCCorner = xRCCorner.y; - - // max/min x(?, ?, d) to get y(yR, yC, d). - // ? = to be determined - vec4 minMaxValue = vec4(${initializationValue}); - float avgValue = 0.0; - count = 0.0; - - for (int wR = 0; wR < ${effectiveFilterHeight}; - wR += ${dilationHeight}) { - int xR = xRCorner + wR; - - if (xR < 0 || xR >= ${convInfo.inHeight}) { - continue; - } - - for (int wC = 0; wC < ${filterWidthNearestVec4}; wC += 4) { - int xC = xCCorner + wC * ${dilationWidth}; - - vec4 values = vec4( - getValue(batch, xR, xC, d), - getValue(batch, xR, xC + ${dilationWidth}, d), - getValue(batch, xR, xC + 2 * ${dilationWidth}, d), - getValue(batch, xR, xC + 3 * ${dilationWidth}, d) - ); - - ${updateSnippet} - } - - int xC = xCCorner + ${filterWidthNearestVec4}; - if (${filterWidthVec4Remainder === 1}) { - vec4 values = vec4( - getValue(batch, xR, xC, d), - initializationValue, - initializationValue, - initializationValue - ); - - ${updateSnippet} - } else if (${filterWidthVec4Remainder === 2}) { - vec4 values = vec4( - getValue(batch, xR, xC, d), - getValue(batch, xR, xC + ${dilationWidth}, d), - initializationValue, - initializationValue - ); - - ${updateSnippet} - } else if (${filterWidthVec4Remainder === 3}) { - vec4 values = vec4( - getValue(batch, xR, xC, d), - getValue(batch, xR, xC + ${dilationWidth}, d), - getValue(batch, xR, xC + 2 * ${dilationWidth}, d), - initializationValue - ); - - ${updateSnippet} - } - } - setOutput(${returnValue}); - } - `; - } -} - -export class Pool3DProgram implements GPGPUProgram { - variableNames = ['x']; - outputShape: number[]; - userCode: string; - - constructor( - convInfo: backend_util.Conv3DInfo, poolType: 'max'|'avg', - computePositions: boolean, flattenPositions = false, - includeBatchInIndex = false) { - if (poolType === 'avg' && computePositions) { - throw new Error('Cannot compute positions for average pool.'); - } - - const filterWidth = convInfo.filterWidth; - const strideDepth = convInfo.strideDepth; - const strideHeight = convInfo.strideHeight; - const strideWidth = convInfo.strideWidth; - const dilationDepth = convInfo.dilationDepth; - const dilationHeight = convInfo.dilationHeight; - const dilationWidth = convInfo.dilationWidth; - const effectiveFilterDepth = convInfo.effectiveFilterDepth; - const effectiveFilterHeight = convInfo.effectiveFilterHeight; - const effectiveFilterWidth = convInfo.effectiveFilterWidth; - - const padFront = convInfo.padInfo.front; - const padTop = convInfo.padInfo.top; - const padLeft = convInfo.padInfo.left; - this.outputShape = convInfo.outShape; - - const isAvgPool = poolType === 'avg'; - - let initializationValue = '0.0'; - if (!isAvgPool) { - // WebGL on Firefox Linux can't compile 1/0 so we do 1/eps. - initializationValue = '-1.0 / 1e-20'; - } - - if (computePositions) { - const compareOp = '>='; - - this.userCode = ` - const ivec3 strides = - ivec3(${strideDepth}, ${strideHeight}, ${strideWidth}); - const ivec3 pads = ivec3(${padFront}, ${padTop}, ${padLeft}); - - void main() { - ivec5 coords = getOutputCoords(); - int batch = coords.x; - int ch = coords.u; - - ivec3 xCorner = ivec3(coords.y, coords.z, coords.w) * strides - pads; - int xDCorner = xCorner.x; - int xRCorner = xCorner.y; - int xCCorner = xCorner.z; - - // max/min x(?, ?, ?, ch) to get y(yD, yR, yC, ch). - // ? = to be determined - float minMaxValue = 0.0; - float minMaxValueFound = 0.0; - int minMaxPosition = 0; - - for (int wD = 0; wD < ${effectiveFilterDepth}; - wD += ${dilationDepth}) { - int xD = xDCorner + wD; - - if (xD < 0 || xD >= ${convInfo.inDepth}) { - continue; - } - - for (int wR = 0; wR < ${effectiveFilterHeight}; - wR += ${dilationHeight}) { - int xR = xRCorner + wR; - - if (xR < 0 || xR >= ${convInfo.inHeight}) { - continue; - } - - for (int wC = 0; wC < ${effectiveFilterWidth}; - wC += ${dilationWidth}) { - int xC = xCCorner + wC; - - if (xC < 0 || xC >= ${convInfo.inWidth}) { - continue; - } - - float value = getX(batch, xD, xR, xC, ch); - - // If a min / max value has already been found, use it. If not, - // use the current value. - float currMinMaxValue = mix( - value, minMaxValue, minMaxValueFound); - if (value ${compareOp} currMinMaxValue) { - minMaxValue = value; - minMaxValueFound = 1.0; - minMaxPosition = ${ - flattenPositions ? - (includeBatchInIndex ? - `(((batch * ${convInfo.inDepth} + xD) * ${ - convInfo.inHeight} + xR) * ${convInfo.inWidth} + xC) * ${ - convInfo.inChannels} + ch` : - `((xD * ${convInfo.inHeight} + xR) * ${ - convInfo.inWidth} + xC) * ${convInfo.inChannels} + ch`) : - `wD * ${effectiveFilterHeight} * ${effectiveFilterWidth} + - wR * ${effectiveFilterWidth} + wC`}; - } - } - } - } - setOutput(float(minMaxPosition)); - } - `; - return; - } - - const compareOp = 'max'; - - let returnValue = `${poolType}(${poolType}(${poolType}(` + - 'minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])'; - if (poolType === 'avg') { - // Use `max(count, 1.0)` instead of `count` in case count === 0.0. - // If count === 0.0, `avgValue` is always 0.0 and we change `count`'s - // value to avoid dividing zero. - returnValue = `avgValue / max(count, 1.0)`; - } - - const filterWidthNearestVec4 = Math.floor(filterWidth / 4) * 4; - const filterWidthVec4Remainder = filterWidth % 4; - - const updateSnippet = ` - if (${isAvgPool}) { - avgValue += dot(values, ones); - } else { - minMaxValue = ${compareOp}(values, minMaxValue); - } - `; - - this.userCode = ` - const ivec3 strides = - ivec3(${strideDepth}, ${strideHeight}, ${strideWidth}); - const ivec3 pads = ivec3(${padFront}, ${padTop}, ${padLeft}); - const float initializationValue = ${initializationValue}; - const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0); - - float count = 0.0; - - float getValue(int batch, int xD, int xR, int xC, int ch) { - if (xC < 0 || xC >= ${convInfo.inWidth}) { - return initializationValue; - } - count += 1.0; - return getX(batch, xD, xR, xC, ch); - } - - void main() { - ivec5 coords = getOutputCoords(); - int batch = coords.x; - int ch = coords.u; - - ivec3 xCorner = ivec3(coords.y, coords.z, coords.w) * strides - pads; - int xDCorner = xCorner.x; - int xRCorner = xCorner.y; - int xCCorner = xCorner.z; - - // max/min x(?, ?, ?, d) to get y(yD, yR, yC, ch). - // ? = to be determined - vec4 minMaxValue = vec4(${initializationValue}); - float avgValue = 0.0; - count = 0.0; - - for (int wD = 0; wD < ${effectiveFilterDepth}; - wD += ${dilationDepth}) { - int xD = xDCorner + wD; - - if (xD < 0 || xD >= ${convInfo.inDepth}) { - continue; - } - - for (int wR = 0; wR < ${effectiveFilterHeight}; - wR += ${dilationHeight}) { - int xR = xRCorner + wR; - - if (xR < 0 || xR >= ${convInfo.inHeight}) { - continue; - } - - for (int wC = 0; wC < ${filterWidthNearestVec4}; wC += 4) { - int xC = xCCorner + wC * ${dilationWidth}; - - vec4 values = vec4( - getValue(batch, xD, xR, xC, ch), - getValue(batch, xD, xR, xC + ${dilationWidth}, ch), - getValue(batch, xD, xR, xC + 2 * ${dilationWidth}, ch), - getValue(batch, xD, xR, xC + 3 * ${dilationWidth}, ch) - ); - - ${updateSnippet} - } - - int xC = xCCorner + ${filterWidthNearestVec4}; - if (${filterWidthVec4Remainder === 1}) { - vec4 values = vec4( - getValue(batch, xD, xR, xC, ch), - initializationValue, - initializationValue, - initializationValue - ); - - ${updateSnippet} - } else if (${filterWidthVec4Remainder === 2}) { - vec4 values = vec4( - getValue(batch, xD, xR, xC, ch), - getValue(batch, xD, xR, xC + ${dilationWidth}, ch), - initializationValue, - initializationValue - ); - - ${updateSnippet} - } else if (${filterWidthVec4Remainder === 3}) { - vec4 values = vec4( - getValue(batch, xD, xR, xC, ch), - getValue(batch, xD, xR, xC + ${dilationWidth}, ch), - getValue(batch, xD, xR, xC + 2 * ${dilationWidth}, ch), - initializationValue - ); - - ${updateSnippet} - } - } - } - setOutput(${returnValue}); - } - `; - } -} diff --git a/tfjs-master/tfjs-backend-webgl/src/reduce_gpu.ts b/tfjs-master/tfjs-backend-webgl/src/reduce_gpu.ts deleted file mode 100644 index 86e748008..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/reduce_gpu.ts +++ /dev/null @@ -1,175 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util} from '@tensorflow/tfjs-core'; -import {GPGPUProgram} from './gpgpu_math'; - -export class ReduceProgram implements GPGPUProgram { - variableNames = ['x']; - outputShape: number[]; - userCode: string; - - constructor( - reduceInfo: backend_util.ReduceInfo, - reduceType: 'all'|'any'|'max'|'min'|'sum'|'prod') { - const {windowSize, batchSize, inSize, outSize} = reduceInfo; - this.outputShape = [batchSize, outSize]; - - let initializationValue = '0.0'; - let compareOp = ``; - - if (reduceType === 'prod') { - initializationValue = '1.0'; - } else if (reduceType === 'min') { - // WebGL on Firefox Linux can't compile 1/0 so we do 1/eps. - initializationValue = '1.0 / 1e-20'; - compareOp = `min`; - } else if (reduceType === 'max') { - // WebGL on Firefox Linux can't compile 1/0 so we do 1/eps. - initializationValue = '-1.0 / 1e-20'; - compareOp = `max`; - } - - let returnValue = `${reduceType}(${reduceType}(${reduceType}(` + - 'minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])'; - - if (reduceType === 'sum') { - returnValue = `sumValue`; - } else if (reduceType === 'prod') { - returnValue = `prodValue`; - } else if (reduceType === 'all') { - returnValue = `allValue`; - } else if (reduceType === 'any') { - returnValue = `anyValue`; - } - - const windowSizeNearestVec4 = Math.floor(windowSize / 4) * 4; - const windowSizeVec4Remainder = windowSize % 4; - - let updateSnippet = ` - if (${reduceType === 'sum'}) { - sumValue += dot(values, ones); - } else if (${reduceType === 'prod'}) { - vec2 tmp = vec2(values[0], values[1]) * vec2(values[2], values[3]); - prodValue *= tmp[0] * tmp[1]; - } else { - minMaxValue = ${compareOp}(values, minMaxValue); - if (${reduceType === 'min'} || ${reduceType === 'max'}) { - minMaxValue = ${compareOp}(values, minMaxValue); - bvec4 isNaN = isnan(values); - if (isNaN.r || isNaN.g || isNaN.b || isNaN.a) { - minMaxValue = vec4(NAN); - } - } - } - `; - - let vecType = `vec4`; - - if (reduceType === 'all') { - initializationValue = '1.0'; - updateSnippet = ` - bool reducedAllValue = all(values); - float floatedReducedAllValue = float(reducedAllValue); - allValue = float(allValue >= 1.0 && floatedReducedAllValue >= 1.0); - `; - vecType = `bvec4`; - } else if (reduceType === 'any') { - initializationValue = '0.0'; - updateSnippet = ` - bool reducedAnyValue = any(values); - float floatedReducedAnyValue = float(reducedAnyValue); - anyValue = float(anyValue >= 1.0 || floatedReducedAnyValue >= 1.0); - `; - vecType = `bvec4`; - } - - let checkOutOfBounds = ''; - if (inSize % windowSize > 0) { - checkOutOfBounds = ` - if (inIdx < 0 || inIdx >= ${inSize}) { - return initializationValue; - } - `; - } - this.userCode = ` - const float initializationValue = ${initializationValue}; - const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0); - - float getValue(int batch, int inIdx) { - ${checkOutOfBounds} - return getX(batch, inIdx); - } - - void main() { - ivec2 coords = getOutputCoords(); - int batch = coords[0]; - int outIdx = coords[1]; - int inOffset = outIdx * ${windowSize}; - - vec4 minMaxValue = vec4(${initializationValue}); - float prodValue = 1.0; - float sumValue = 0.0; - float allValue = 1.0; - float anyValue = 0.0; - - for (int i = 0; i < ${windowSizeNearestVec4}; i += 4) { - int inIdx = inOffset + i; - ${vecType} values = ${vecType}( - getValue(batch, inIdx), - getValue(batch, inIdx + 1), - getValue(batch, inIdx + 2), - getValue(batch, inIdx + 3) - ); - - ${updateSnippet} - } - - int inIdx = inOffset + ${windowSizeNearestVec4}; - if (${windowSizeVec4Remainder === 1}) { - ${vecType} values = ${vecType}( - getValue(batch, inIdx), - initializationValue, - initializationValue, - initializationValue - ); - - ${updateSnippet} - } else if (${windowSizeVec4Remainder === 2}) { - ${vecType} values = ${vecType}( - getValue(batch, inIdx), - getValue(batch, inIdx + 1), - initializationValue, - initializationValue - ); - - ${updateSnippet} - } else if (${windowSizeVec4Remainder === 3}) { - ${vecType} values = ${vecType}( - getValue(batch, inIdx), - getValue(batch, inIdx + 1), - getValue(batch, inIdx + 2), - initializationValue - ); - - ${updateSnippet} - } - setOutput(${returnValue}); - } - `; - } -} diff --git a/tfjs-master/tfjs-backend-webgl/src/register_all_kernels.ts b/tfjs-master/tfjs-backend-webgl/src/register_all_kernels.ts deleted file mode 100644 index 42b1e0e9a..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/register_all_kernels.ts +++ /dev/null @@ -1,366 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {KernelConfig, registerKernel} from '@tensorflow/tfjs-core'; - -import {_fusedMatMulConfig} from './kernels/_FusedMatMul'; -import {absConfig} from './kernels/Abs'; -import {acosConfig} from './kernels/Acos'; -import {acoshConfig} from './kernels/Acosh'; -import {addConfig} from './kernels/Add'; -import {addNConfig} from './kernels/AddN'; -import {allConfig} from './kernels/All'; -import {anyConfig} from './kernels/Any'; -import {argMaxConfig} from './kernels/ArgMax'; -import {argMinConfig} from './kernels/ArgMin'; -import {asinConfig} from './kernels/Asin'; -import {asinhConfig} from './kernels/Asinh'; -import {atanConfig} from './kernels/Atan'; -import {atan2Config} from './kernels/Atan2'; -import {atanhConfig} from './kernels/Atanh'; -import {avgPoolConfig} from './kernels/AvgPool'; -import {avgPool3DConfig} from './kernels/AvgPool3D'; -import {avgPool3DGradConfig} from './kernels/AvgPool3DGrad'; -import {avgPoolGradConfig} from './kernels/AvgPoolGrad'; -import {batchMatMulConfig} from './kernels/BatchMatMul'; -import {batchNormConfig} from './kernels/BatchNorm'; -import {batchToSpaceNDConfig} from './kernels/BatchToSpaceND'; -import {bincountConfig} from './kernels/Bincount'; -import {bitwiseAndConfig} from './kernels/BitwiseAnd'; -import {broadcastArgsConfig} from './kernels/BroadcastArgs'; -import {castConfig} from './kernels/Cast'; -import {ceilConfig} from './kernels/Ceil'; -import {clipByValueConfig} from './kernels/ClipByValue'; -import {complexConfig} from './kernels/Complex'; -import {complexAbsConfig} from './kernels/ComplexAbs'; -import {concatConfig} from './kernels/Concat'; -import {conv2DConfig} from './kernels/Conv2D'; -import {conv2DBackpropFilterConfig} from './kernels/Conv2DBackpropFilter'; -import {conv2DBackpropInputConfig} from './kernels/Conv2DBackpropInput'; -import {conv3DConfig} from './kernels/Conv3D'; -import {conv3DBackpropFilterV2Config} from './kernels/Conv3DBackpropFilterV2'; -import {conv3DBackpropInputConfig} from './kernels/Conv3DBackpropInputV2'; -import {cosConfig} from './kernels/Cos'; -import {coshConfig} from './kernels/Cosh'; -import {cropAndResizeConfig} from './kernels/CropAndResize'; -import {cumprodConfig} from './kernels/Cumprod'; -import {cumsumConfig} from './kernels/Cumsum'; -import {denseBincountConfig} from './kernels/DenseBincount'; -import {depthToSpaceConfig} from './kernels/DepthToSpace'; -import {depthwiseConv2dNativeConfig} from './kernels/DepthwiseConv2dNative'; -import {depthwiseConv2dNativeBackpropFilterConfig} from './kernels/DepthwiseConv2dNativeBackpropFilter'; -import {depthwiseConv2dNativeBackpropInputConfig} from './kernels/DepthwiseConv2dNativeBackpropInput'; -import {diagConfig} from './kernels/Diag'; -import {dilation2DConfig} from './kernels/Dilation2D'; -import {einsumConfig} from './kernels/Einsum'; -import {eluConfig} from './kernels/Elu'; -import {eluGradConfig} from './kernels/EluGrad'; -import {equalConfig} from './kernels/Equal'; -import {erfConfig} from './kernels/Erf'; -import {expConfig} from './kernels/Exp'; -import {expandDimsConfig} from './kernels/ExpandDims'; -import {expm1Config} from './kernels/Expm1'; -import {fftConfig} from './kernels/FFT'; -import {fillConfig} from './kernels/Fill'; -import {flipLeftRightConfig} from './kernels/FlipLeftRight'; -import {floorConfig} from './kernels/Floor'; -import {floorDivConfig} from './kernels/FloorDiv'; -import {fromPixelsConfig} from './kernels/FromPixels'; -import {fusedConv2DConfig} from './kernels/FusedConv2D'; -import {fusedDepthwiseConv2DConfig} from './kernels/FusedDepthwiseConv2D'; -import {gatherNdConfig} from './kernels/GatherNd'; -import {gatherV2Config} from './kernels/GatherV2'; -import {greaterConfig} from './kernels/Greater'; -import {greaterEqualConfig} from './kernels/GreaterEqual'; -import {identityConfig} from './kernels/Identity'; -import {ifftConfig} from './kernels/IFFT'; -import {imagConfig} from './kernels/Imag'; -import {isFiniteConfig} from './kernels/IsFinite'; -import {isInfConfig} from './kernels/IsInf'; -import {isNaNConfig} from './kernels/IsNaN'; -import {leakyReluConfig} from './kernels/LeakyRelu'; -import {lessConfig} from './kernels/Less'; -import {lessEqualConfig} from './kernels/LessEqual'; -import {linSpaceConfig} from './kernels/LinSpace'; -import {logConfig} from './kernels/Log'; -import {log1pConfig} from './kernels/Log1p'; -import {logicalAndConfig} from './kernels/LogicalAnd'; -import {logicalNotConfig} from './kernels/LogicalNot'; -import {logicalOrConfig} from './kernels/LogicalOr'; -import {LRNConfig} from './kernels/LRN'; -import {LRNGradConfig} from './kernels/LRNGrad'; -import {maxConfig} from './kernels/Max'; -import {maximumConfig} from './kernels/Maximum'; -import {maxPoolConfig} from './kernels/MaxPool'; -import {maxPool3DConfig} from './kernels/MaxPool3D'; -import {maxPool3DGradConfig} from './kernels/MaxPool3DGrad'; -import {maxPoolGradConfig} from './kernels/MaxPoolGrad'; -import {maxPoolWithArgmaxConfig} from './kernels/MaxPoolWithArgmax'; -import {meanConfig} from './kernels/Mean'; -import {minConfig} from './kernels/Min'; -import {minimumConfig} from './kernels/Minimum'; -import {mirrorPadConfig} from './kernels/MirrorPad'; -import {modConfig} from './kernels/Mod'; -import {multinomialConfig} from './kernels/Multinomial'; -import {multiplyConfig} from './kernels/Multiply'; -import {negConfig} from './kernels/Neg'; -import {nonMaxSuppressionV3Config} from './kernels/NonMaxSuppressionV3'; -import {nonMaxSuppressionV4Config} from './kernels/NonMaxSuppressionV4'; -import {nonMaxSuppressionV5Config} from './kernels/NonMaxSuppressionV5'; -import {notEqualConfig} from './kernels/NotEqual'; -import {oneHotConfig} from './kernels/OneHot'; -import {onesLikeConfig} from './kernels/OnesLike'; -import {packConfig} from './kernels/Pack'; -import {padV2Config} from './kernels/PadV2'; -import {powConfig} from './kernels/Pow'; -import {preluConfig} from './kernels/Prelu'; -import {prodConfig} from './kernels/Prod'; -import {raggedGatherConfig} from './kernels/RaggedGather'; -import {raggedRangeConfig} from './kernels/RaggedRange'; -import {raggedTensorToTensorConfig} from './kernels/RaggedTensorToTensor'; -import {rangeConfig} from './kernels/Range'; -import {realConfig} from './kernels/Real'; -import {realDivConfig} from './kernels/RealDiv'; -import {reciprocalConfig} from './kernels/Reciprocal'; -import {reluConfig} from './kernels/Relu'; -import {relu6Config} from './kernels/Relu6'; -import {reshapeConfig} from './kernels/Reshape'; -import {resizeBilinearConfig} from './kernels/ResizeBilinear'; -import {resizeBilinearGradConfig} from './kernels/ResizeBilinearGrad'; -import {resizeNearestNeighborConfig} from './kernels/ResizeNearestNeighbor'; -import {resizeNearestNeighborGradConfig} from './kernels/ResizeNearestNeighborGrad'; -import {reverseConfig} from './kernels/Reverse'; -import {rotateWithOffsetConfig} from './kernels/RotateWithOffset'; -import {roundConfig} from './kernels/Round'; -import {rsqrtConfig} from './kernels/Rsqrt'; -import {scatterNdConfig} from './kernels/ScatterNd'; -import {searchSortedConfig} from './kernels/SearchSorted'; -import {selectConfig} from './kernels/Select'; -import {seluConfig} from './kernels/Selu'; -import {sigmoidConfig} from './kernels/Sigmoid'; -import {signConfig} from './kernels/Sign'; -import {sinConfig} from './kernels/Sin'; -import {sinhConfig} from './kernels/Sinh'; -import {sliceConfig} from './kernels/Slice'; -import {softmaxConfig} from './kernels/Softmax'; -import {softplusConfig} from './kernels/Softplus'; -import {spaceToBatchNDConfig} from './kernels/SpaceToBatchND'; -import {sparseFillEmptyRowsConfig} from './kernels/SparseFillEmptyRows'; -import {sparseReshapeConfig} from './kernels/SparseReshape'; -import {sparseSegmentMeanConfig} from './kernels/SparseSegmentMean'; -import {sparseSegmentSumConfig} from './kernels/SparseSegmentSum'; -import {sparseToDenseConfig} from './kernels/SparseToDense'; -import {splitVConfig} from './kernels/SplitV'; -import {sqrtConfig} from './kernels/Sqrt'; -import {squareConfig} from './kernels/Square'; -import {squaredDifferenceConfig} from './kernels/SquaredDifference'; -import {staticRegexReplaceConfig} from './kernels/StaticRegexReplace'; -import {stepConfig} from './kernels/Step'; -import {stridedSliceConfig} from './kernels/StridedSlice'; -import {stringNGramsConfig} from './kernels/StringNGrams'; -import {stringSplitConfig} from './kernels/StringSplit'; -import {stringToHashBucketFastConfig} from './kernels/StringToHashBucketFast'; -import {subConfig} from './kernels/Sub'; -import {sumConfig} from './kernels/Sum'; -import {tanConfig} from './kernels/Tan'; -import {tanhConfig} from './kernels/Tanh'; -import {tensorScatterUpdateConfig} from './kernels/TensorScatterUpdate'; -import {tileConfig} from './kernels/Tile'; -import {topKConfig} from './kernels/TopK'; -import {transformConfig} from './kernels/Transform'; -import {transposeConfig} from './kernels/Transpose'; -import {uniqueConfig} from './kernels/Unique'; -import {unpackConfig} from './kernels/Unpack'; -import {unsortedSegmentSumConfig} from './kernels/UnsortedSegmentSum'; -import {zerosLikeConfig} from './kernels/ZerosLike'; - -// List all kernel configs here -const kernelConfigs: KernelConfig[] = [ - _fusedMatMulConfig, - absConfig, - acosConfig, - acoshConfig, - addConfig, - addNConfig, - allConfig, - anyConfig, - argMaxConfig, - argMinConfig, - asinConfig, - asinhConfig, - atanConfig, - atan2Config, - atanhConfig, - avgPoolConfig, - avgPool3DConfig, - avgPool3DGradConfig, - avgPoolGradConfig, - batchMatMulConfig, - batchNormConfig, - batchToSpaceNDConfig, - bincountConfig, - bitwiseAndConfig, - broadcastArgsConfig, - castConfig, - ceilConfig, - clipByValueConfig, - complexConfig, - complexAbsConfig, - concatConfig, - conv2DConfig, - conv2DBackpropFilterConfig, - conv2DBackpropInputConfig, - conv3DConfig, - conv3DBackpropFilterV2Config, - conv3DBackpropInputConfig, - cosConfig, - coshConfig, - cropAndResizeConfig, - cumprodConfig, - cumsumConfig, - denseBincountConfig, - depthToSpaceConfig, - depthwiseConv2dNativeConfig, - depthwiseConv2dNativeBackpropFilterConfig, - depthwiseConv2dNativeBackpropInputConfig, - diagConfig, - dilation2DConfig, - einsumConfig, - eluConfig, - eluGradConfig, - equalConfig, - erfConfig, - expConfig, - expandDimsConfig, - expm1Config, - fftConfig, - fillConfig, - flipLeftRightConfig, - floorConfig, - floorDivConfig, - fromPixelsConfig, - fusedConv2DConfig, - fusedDepthwiseConv2DConfig, - gatherNdConfig, - gatherV2Config, - greaterConfig, - greaterEqualConfig, - identityConfig, - ifftConfig, - imagConfig, - isFiniteConfig, - isInfConfig, - isNaNConfig, - leakyReluConfig, - lessConfig, - lessEqualConfig, - linSpaceConfig, - logConfig, - log1pConfig, - logicalAndConfig, - logicalNotConfig, - logicalOrConfig, - LRNConfig, - LRNGradConfig, - maxConfig, - maximumConfig, - maxPoolConfig, - maxPool3DConfig, - maxPool3DGradConfig, - maxPoolGradConfig, - maxPoolWithArgmaxConfig, - meanConfig, - minConfig, - minimumConfig, - mirrorPadConfig, - modConfig, - multinomialConfig, - multiplyConfig, - negConfig, - nonMaxSuppressionV3Config, - nonMaxSuppressionV4Config, - nonMaxSuppressionV5Config, - notEqualConfig, - oneHotConfig, - onesLikeConfig, - packConfig, - padV2Config, - powConfig, - preluConfig, - prodConfig, - raggedGatherConfig, - raggedRangeConfig, - raggedTensorToTensorConfig, - rangeConfig, - realConfig, - realDivConfig, - reciprocalConfig, - reluConfig, - relu6Config, - reshapeConfig, - resizeBilinearConfig, - resizeBilinearGradConfig, - resizeNearestNeighborConfig, - resizeNearestNeighborGradConfig, - reverseConfig, - rotateWithOffsetConfig, - roundConfig, - rsqrtConfig, - scatterNdConfig, - searchSortedConfig, - selectConfig, - seluConfig, - sigmoidConfig, - signConfig, - sinConfig, - sinhConfig, - sliceConfig, - softmaxConfig, - softplusConfig, - spaceToBatchNDConfig, - sparseFillEmptyRowsConfig, - sparseReshapeConfig, - sparseSegmentMeanConfig, - sparseSegmentSumConfig, - sparseToDenseConfig, - splitVConfig, - sqrtConfig, - squareConfig, - squaredDifferenceConfig, - staticRegexReplaceConfig, - stepConfig, - stridedSliceConfig, - stringNGramsConfig, - stringSplitConfig, - stringToHashBucketFastConfig, - subConfig, - sumConfig, - tanConfig, - tanhConfig, - tensorScatterUpdateConfig, - tileConfig, - topKConfig, - transformConfig, - transposeConfig, - uniqueConfig, - unpackConfig, - unsortedSegmentSumConfig, - zerosLikeConfig -]; - -for (const kernelConfig of kernelConfigs) { - registerKernel(kernelConfig); -} diff --git a/tfjs-master/tfjs-backend-webgl/src/reshape_packed_gpu.ts b/tfjs-master/tfjs-backend-webgl/src/reshape_packed_gpu.ts deleted file mode 100644 index 29cae9cb0..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/reshape_packed_gpu.ts +++ /dev/null @@ -1,96 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {GPGPUProgram, useShapeUniforms} from './gpgpu_math'; -import * as shader_util from './shader_compiler_util'; - -export class ReshapePackedProgram implements GPGPUProgram { - variableNames = ['A']; - packedInputs = true; - packedOutput = true; - outputShape: number[]; - userCode: string; - enableShapeUniforms: boolean; - customUniforms = [{name: 'inputShape', type: 'ivec3' as const }]; - - constructor(outputShape: [number, number, number], inputShape: [ - number, number, number - ]) { - this.outputShape = outputShape; - this.enableShapeUniforms = useShapeUniforms(this.outputShape.length); - - let mainLoop = ``; - for (let i = 0; i < 4; i++) { - let thisRC = `thisRC = rc;`; - if (i % 2 === 1) { - thisRC += `thisRC.z += 1;`; - } - if (i > 1) { - thisRC += `thisRC.y += 1;`; - } - - mainLoop += ` - ${thisRC} - ${i > 0 ? `if(thisRC.y < rows && thisRC.z < cols){` : ''} - int flatIndex = getFlatIndex(thisRC); - - ivec3 inputRC = inputCoordsFromReshapedOutCoords(flatIndex); - vec2 inputRCInnerDims = vec2(float(inputRC.y),float(inputRC.z)); - - result[${i}] = - getChannel(getA(inputRC.x, inputRC.y, inputRC.z), inputRCInnerDims); - ${i > 0 ? '}' : ''} - `; - } - - this.userCode = ` - ${getReshapedInputCoords(inputShape, this.enableShapeUniforms)} - ${ - this.enableShapeUniforms ? shader_util.getFlatIndexFrom3DOutput() : - shader_util.getFlatIndexFrom3D(outputShape)} - - void main() { - ivec3 rc = getOutputCoords(); - - vec4 result = vec4(0.); - - ivec3 thisRC; - int rows = ${this.enableShapeUniforms ? 'outShape[1]' : outputShape[1]}; - int cols = ${this.enableShapeUniforms ? 'outShape[2]' : outputShape[2]}; - - ${mainLoop} - - setOutput(result); - } - `; - } -} - -function getReshapedInputCoords( - shape: [number, number, number], enableShapeUniforms: boolean): string { - const coordsFromIndexSnippet = enableShapeUniforms ? - shader_util.getLogicalCoordinatesFromFlatIndexByUniform( - ['r', 'c', 'd'], 'inputShape') : - shader_util.getLogicalCoordinatesFromFlatIndex(['r', 'c', 'd'], shape); - - return ` - ivec3 inputCoordsFromReshapedOutCoords(int index) { - ${coordsFromIndexSnippet} - return ivec3(r, c, d); - } - `; -} diff --git a/tfjs-master/tfjs-backend-webgl/src/reshape_packed_test.ts b/tfjs-master/tfjs-backend-webgl/src/reshape_packed_test.ts deleted file mode 100644 index 047177448..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/reshape_packed_test.ts +++ /dev/null @@ -1,100 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '@tensorflow/tfjs-core'; -import {test_util} from '@tensorflow/tfjs-core'; -const {expectArraysClose} = test_util; -// tslint:disable-next-line: no-imports-from-dist -import {describeWithFlags} from '@tensorflow/tfjs-core/dist/jasmine_util'; -import {PACKED_ENVS} from './backend_webgl_test_registry'; - -describeWithFlags('expensive reshape', PACKED_ENVS, () => { - const cValues = - [46, 52, 58, 64, 70, 100, 115, 130, 145, 160, 154, 178, 202, 226, 250]; - let c: tf.Tensor; - - beforeEach(() => { - const a = tf.tensor2d([1, 2, 3, 4, 5, 6, 7, 8, 9], [3, 3]); - const b = tf.tensor2d( - [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], [3, 5]); - c = tf.matMul(a, b); - }); - - it('6d --> 1d', async () => { - const cAs6D = tf.reshape(c, [1, 1, 1, 3, 1, 5]); - const cAs1D = tf.reshape(cAs6D, [-1, cValues.length]); - expectArraysClose(await cAs1D.data(), cValues); - }); - it('1d --> 2d', async () => { - const cAs1D = tf.reshape(c, [cValues.length]); - const cAs2D = tf.reshape(cAs1D, [5, -1]); - expectArraysClose(await cAs2D.data(), cValues); - }); - it('2d --> 3d', async () => { - const cAs3D = tf.reshape(c, [3, 1, 5]); - expectArraysClose(await cAs3D.data(), cValues); - }); - it('3d --> 4d', async () => { - const cAs3D = tf.reshape(c, [3, 1, 5]); - const cAs4D = tf.reshape(cAs3D, [3, 5, 1, 1]); - expectArraysClose(await cAs4D.data(), cValues); - }); - it('4d --> 5d', async () => { - const cAs4D = tf.reshape(c, [3, 5, 1, 1]); - const cAs5D = tf.reshape(cAs4D, [1, 1, 1, 5, 3]); - expectArraysClose(await cAs5D.data(), cValues); - }); - it('5d --> 6d', async () => { - const cAs5D = tf.reshape(c, [1, 1, 1, 5, 3]); - const cAs6D = tf.reshape(cAs5D, [3, 5, 1, 1, 1, 1]); - expectArraysClose(await cAs6D.data(), cValues); - }); -}); - -describeWithFlags('expensive reshape with even columns', PACKED_ENVS, () => { - it('2 --> 4 columns', async () => { - const maxTextureSize = tf.env().getNumber('WEBGL_MAX_TEXTURE_SIZE'); - - let values: number[] = new Array(16).fill(0); - values = values.map((d, i) => i + 1); - const a = tf.tensor2d(values, [8, 2]); - const b = tf.tensor2d([1, 2, 3, 4], [2, 2]); - - tf.env().set('WEBGL_MAX_TEXTURE_SIZE', 2); - // Setting WEBGL_MAX_TEXTURE_SIZE to 2 makes that [8, 2] tensor is packed - // to texture of width 2 by height 2. Indices are packed as: - // ------------- - // | 0 1 | 4 5 | // First row's four - // | 2 3 | 6 7 | // pixels. - // ------------- - // ... - const c = tf.matMul(a, b); - let cAs4D = c.reshape([2, 1, 2, 4]); - tf.env().set('WEBGL_MAX_TEXTURE_SIZE', maxTextureSize); - - // Execute non-packed operations to unpack tensor. - const webglPackFlagSaved = tf.env().getBool('WEBGL_PACK'); - tf.env().set('WEBGL_PACK', false); - cAs4D = cAs4D.add(1); - cAs4D = cAs4D.add(-1); - tf.env().set('WEBGL_PACK', webglPackFlagSaved); - - const result = - [7, 10, 15, 22, 23, 34, 31, 46, 39, 58, 47, 70, 55, 82, 63, 94]; - expectArraysClose(await cAs4D.data(), result); - }); -}); diff --git a/tfjs-master/tfjs-backend-webgl/src/resize_bilinear_backprop_gpu.ts b/tfjs-master/tfjs-backend-webgl/src/resize_bilinear_backprop_gpu.ts deleted file mode 100644 index 948727580..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/resize_bilinear_backprop_gpu.ts +++ /dev/null @@ -1,140 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {GPGPUProgram} from './gpgpu_math'; - -export class ResizeBilinearBackpropProgram implements GPGPUProgram { - variableNames = ['dy']; - outputShape: number[] = []; - userCode: string; - - constructor( - dyShape: [number, number, number, number], - inputShape: [number, number, number, number], alignCorners: boolean) { - this.outputShape = inputShape; - const [, xHeight, xWidth, ] = inputShape; - const [, yHeight, yWidth] = dyShape; - - // In the backwards pass, we want to find the pixels that were generated for - // each pixel in the input image the forward pass and add the corresponding - // coefficient from dy to the gradient (with some interpolation). - - const effectiveXSize: [number, number] = [ - (alignCorners && yHeight > 1) ? xHeight - 1 : xHeight, - (alignCorners && yWidth > 1) ? xWidth - 1 : xWidth - ]; - - const effectiveYSize: [number, number] = [ - (alignCorners && yHeight > 1) ? yHeight - 1 : yHeight, - (alignCorners && yWidth > 1) ? yWidth - 1 : yWidth - ]; - - const heightScale = effectiveXSize[0] / effectiveYSize[0]; - const widthScale = effectiveXSize[1] / effectiveYSize[1]; - - const invHeightScale = 1 / heightScale; - const invWidthScale = 1 / widthScale; - - // This defines the size of the window of values around a particular - // index in dy that we want to search for contributions to dx. - const winHeight = (Math.ceil(invHeightScale) * 2) + 2; - const winWidth = (Math.ceil(invWidthScale) * 2) + 2; - - this.userCode = ` - void main() { - ivec4 coords = getOutputCoords(); - int b = coords[0]; - int d = coords[3]; - int r = coords[1]; - int c = coords[2]; - - float accumulator = 0.0; - - const float heightScale = float(${heightScale}); - const float widthScale = float(${widthScale}); - - const float invHeightScale = float(${invHeightScale}); - const float invWidthScale = float(${invWidthScale}); - - const int winHeight = int(${winHeight}); - const int winWidth = int(${winWidth}); - - // Compute bounds for where in dy we will look - float startRLerp = floor(float(r) * invHeightScale); - int startDyR = int(startRLerp - float(winHeight / 2)); - - float startCLerp = floor(float(c) * invWidthScale); - int startDyC = int(startCLerp - float(winWidth / 2)); - - // Loop over dy - for (int dyROffset = 0; dyROffset < winHeight; dyROffset++) { - int dyR = dyROffset + startDyR; - - // Guard against the window exceeding the bounds of dy - if (dyR < 0 || dyR >= ${yHeight}) { - continue; - } - - for (int dyCOffset = 0; dyCOffset < winWidth; dyCOffset++) { - int dyC = dyCOffset + startDyC; - - // Guard against the window exceeding the bounds of dy - if (dyC < 0 || dyC >= ${yWidth}) { - continue; - } - - float dxR = float(dyR) * heightScale; - int topDxRIndex = int(floor(dxR)); - int bottomDxRIndex = int(min(ceil(dxR), ${xHeight - 1}.0)); - float dxRLerp = dxR - float(topDxRIndex); - float inverseDxRLerp = 1.0 - dxRLerp; - - float dxC = float(dyC) * widthScale; - int leftDxCIndex = int(floor(dxC)); - int rightDxCIndex = int(min(ceil(dxC), ${xWidth - 1}.0)); - float dxCLerp = dxC - float(leftDxCIndex); - float inverseDxCLerp = 1.0 - dxCLerp; - - if (r == topDxRIndex && c == leftDxCIndex) { - // topLeft - accumulator += - getDy(b, dyR, dyC, d) * inverseDxRLerp * inverseDxCLerp; - } - - if (r == topDxRIndex && c == rightDxCIndex) { - // topRight - accumulator += getDy(b, dyR, dyC, d) * inverseDxRLerp * dxCLerp; - } - - if (r == bottomDxRIndex && c == leftDxCIndex) { - // bottomLeft - accumulator += getDy(b, dyR, dyC, d) * dxRLerp * inverseDxCLerp; - } - - if (r == bottomDxRIndex && c == rightDxCIndex) { - // bottomRight - accumulator += getDy(b, dyR, dyC, d) * dxRLerp * dxCLerp; - } - } - } - // End loop over dy - - setOutput(accumulator); - } - `; - } -} diff --git a/tfjs-master/tfjs-backend-webgl/src/resize_bilinear_gpu.ts b/tfjs-master/tfjs-backend-webgl/src/resize_bilinear_gpu.ts deleted file mode 100644 index d19b54ec1..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/resize_bilinear_gpu.ts +++ /dev/null @@ -1,85 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {GPGPUProgram} from './gpgpu_math'; - -export class ResizeBilinearProgram implements GPGPUProgram { - variableNames = ['A']; - outputShape: number[] = []; - userCode: string; - - constructor( - inputShape: [number, number, number, number], newHeight: number, - newWidth: number, alignCorners: boolean, halfPixelCenters: boolean) { - const [batch, oldHeight, oldWidth, depth] = inputShape; - this.outputShape = [batch, newHeight, newWidth, depth]; - - const effectiveInSize: [number, number] = [ - (alignCorners && newHeight > 1) ? oldHeight - 1 : oldHeight, - (alignCorners && newWidth > 1) ? oldWidth - 1 : oldWidth - ]; - - const effectiveOutSize: [number, number] = [ - (alignCorners && newHeight > 1) ? newHeight - 1 : newHeight, - (alignCorners && newWidth > 1) ? newWidth - 1 : newWidth - ]; - - let sourceFracIndexRC: string; - if (halfPixelCenters) { - sourceFracIndexRC = - `(vec2(yRC) + vec2(0.5)) * effectiveInputOverOutputRatioRC` + - ` - vec2(0.5)`; - } else { - sourceFracIndexRC = `vec2(yRC) * effectiveInputOverOutputRatioRC`; - } - - this.userCode = ` - const vec2 effectiveInputOverOutputRatioRC = vec2( - ${effectiveInSize[0] / effectiveOutSize[0]}, - ${effectiveInSize[1] / effectiveOutSize[1]}); - const vec2 inputShapeRC = vec2(${oldHeight}.0, ${oldWidth}.0); - - void main() { - ivec4 coords = getOutputCoords(); - int b = coords[0]; - int d = coords[3]; - ivec2 yRC = coords.yz; - - // Fractional source index. - vec2 sourceFracIndexRC = ${sourceFracIndexRC}; - - // Compute the four integer indices. - ivec2 sourceFloorRC = ivec2(max(sourceFracIndexRC, vec2(0.0))); - ivec2 sourceCeilRC = ivec2( - min(inputShapeRC - 1.0, ceil(sourceFracIndexRC))); - - float topLeft = getA(b, sourceFloorRC.x, sourceFloorRC.y, d); - float bottomLeft = getA(b, sourceCeilRC.x, sourceFloorRC.y, d); - float topRight = getA(b, sourceFloorRC.x, sourceCeilRC.y, d); - float bottomRight = getA(b, sourceCeilRC.x, sourceCeilRC.y, d); - - vec2 fracRC = sourceFracIndexRC - vec2(sourceFloorRC); - - float top = topLeft + (topRight - topLeft) * fracRC.y; - float bottom = bottomLeft + (bottomRight - bottomLeft) * fracRC.y; - float newValue = top + (bottom - top) * fracRC.x; - - setOutput(newValue); - } - `; - } -} diff --git a/tfjs-master/tfjs-backend-webgl/src/resize_bilinear_packed_gpu.ts b/tfjs-master/tfjs-backend-webgl/src/resize_bilinear_packed_gpu.ts deleted file mode 100644 index c734363ec..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/resize_bilinear_packed_gpu.ts +++ /dev/null @@ -1,130 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {GPGPUProgram} from './gpgpu_math'; - -export class ResizeBilinearPackedProgram implements GPGPUProgram { - variableNames = ['A']; - packedInputs = true; - packedOutput = true; - outputShape: number[] = []; - userCode: string; - - constructor( - inputShape: [number, number, number, number], newHeight: number, - newWidth: number, alignCorners: boolean, halfPixelCenters: boolean) { - const [batch, oldHeight, oldWidth, depth] = inputShape; - this.outputShape = [batch, newHeight, newWidth, depth]; - - const effectiveInSize: [number, number] = [ - (alignCorners && newHeight > 1) ? oldHeight - 1 : oldHeight, - (alignCorners && newWidth > 1) ? oldWidth - 1 : oldWidth - ]; - - const effectiveOutSize: [number, number] = [ - (alignCorners && newHeight > 1) ? newHeight - 1 : newHeight, - (alignCorners && newWidth > 1) ? newWidth - 1 : newWidth - ]; - - let sourceFracIndexRC: string; - if (halfPixelCenters) { - sourceFracIndexRC = `(vec3(yRC) + vec3(0.5)) * ` + - `effectiveInputOverOutputRatioRC - vec3(0.5)`; - } else { - sourceFracIndexRC = `vec3(yRC) * effectiveInputOverOutputRatioRC`; - } - - this.userCode = ` - const vec3 effectiveInputOverOutputRatioRC = vec3( - ${effectiveInSize[0] / effectiveOutSize[0]}, - ${effectiveInSize[1] / effectiveOutSize[1]}, - ${effectiveInSize[1] / effectiveOutSize[1]}); - const vec3 inputShapeRC = vec3(${oldHeight}.0, ${oldWidth}.0, - ${oldWidth}.0); - - float getAValue(int b, int r, int c, int d) { - return getChannel(getA(b, r, c, d), vec2(c, d)); - } - - void main() { - ivec4 coords = getOutputCoords(); - int b = coords[0]; - int d = coords[3]; - // Calculate values for next column in yRC.z. - ivec3 yRC = coords.yzz + ivec3(0, 0, 1); - - // Fractional source index. - vec3 sourceFracIndexRC = ${sourceFracIndexRC}; - - // Compute the four integer indices. - ivec3 sourceFloorRC = ivec3(max(sourceFracIndexRC, vec3(0.0))); - ivec3 sourceCeilRC = ivec3( - min(inputShapeRC - 1.0, ceil(sourceFracIndexRC))); - - // Should we calculate next column and row elements in 2x2 packed cell. - bool hasNextCol = d < ${depth - 1}; - bool hasNextRow = coords.z < ${newWidth - 1}; - - // In parallel, construct four corners for all four components in - // packed 2x2 cell. - vec4 topLeft = vec4( - getAValue(b, sourceFloorRC.x, sourceFloorRC.y, d), - hasNextCol ? getAValue(b, sourceFloorRC.x, sourceFloorRC.y, d + 1) - : 0.0, - hasNextRow ? getAValue(b, sourceFloorRC.x, sourceFloorRC.z, d) - : 0.0, - (hasNextRow && hasNextCol) ? - getAValue(b, sourceFloorRC.x, sourceFloorRC.z, d + 1) : 0.0); - - vec4 bottomLeft = vec4( - getAValue(b, sourceCeilRC.x, sourceFloorRC.y, d), - hasNextCol ? getAValue(b, sourceCeilRC.x, sourceFloorRC.y, d + 1) - : 0.0, - hasNextRow ? getAValue(b, sourceCeilRC.x, sourceFloorRC.z, d) - : 0.0, - (hasNextRow && hasNextCol) ? - getAValue(b, sourceCeilRC.x, sourceFloorRC.z, d + 1) : 0.0); - - vec4 topRight = vec4( - getAValue(b, sourceFloorRC.x, sourceCeilRC.y, d), - hasNextCol ? getAValue(b, sourceFloorRC.x, sourceCeilRC.y, d + 1) - : 0.0, - hasNextRow ? getAValue(b, sourceFloorRC.x, sourceCeilRC.z, d) - : 0.0, - (hasNextRow && hasNextCol) ? - getAValue(b, sourceFloorRC.x, sourceCeilRC.z, d + 1) : 0.0); - - vec4 bottomRight = vec4( - getAValue(b, sourceCeilRC.x, sourceCeilRC.y, d), - hasNextCol ? getAValue(b, sourceCeilRC.x, sourceCeilRC.y, d + 1) - : 0.0, - hasNextRow ? getAValue(b, sourceCeilRC.x, sourceCeilRC.z, d) - : 0.0, - (hasNextRow && hasNextCol) ? - getAValue(b, sourceCeilRC.x, sourceCeilRC.z, d + 1) : 0.0); - - vec3 fracRC = sourceFracIndexRC - vec3(sourceFloorRC); - - vec4 top = mix(topLeft, topRight, fracRC.yyzz); - vec4 bottom = mix(bottomLeft, bottomRight, fracRC.yyzz); - vec4 newValue = mix(top, bottom, fracRC.x); - - setOutput(newValue); - } - `; - } -} diff --git a/tfjs-master/tfjs-backend-webgl/src/resize_nearest_neighbor_backprop_gpu.ts b/tfjs-master/tfjs-backend-webgl/src/resize_nearest_neighbor_backprop_gpu.ts deleted file mode 100644 index c711f6b7e..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/resize_nearest_neighbor_backprop_gpu.ts +++ /dev/null @@ -1,129 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {GPGPUProgram} from './gpgpu_math'; - -export class ResizeNearestNeigborBackpropProgram implements GPGPUProgram { - variableNames = ['dy']; - outputShape: number[] = []; - userCode: string; - - constructor( - dyShape: [number, number, number, number], - inputShape: [number, number, number, number], alignCorners: boolean) { - this.outputShape = inputShape; - const [, xHeight, xWidth, ] = inputShape; - const [, yHeight, yWidth] = dyShape; - - // In the backwards pass, we want to find the pixels that were generated for - // each pixel in the input image the forward pass and add the corresponding - // coefficient from dy to the gradient (with some interpolation). - - const effectiveXSize: [number, number] = [ - (alignCorners && yHeight > 1) ? xHeight - 1 : xHeight, - (alignCorners && yWidth > 1) ? xWidth - 1 : xWidth - ]; - - const effectiveYSize: [number, number] = [ - (alignCorners && yHeight > 1) ? yHeight - 1 : yHeight, - (alignCorners && yWidth > 1) ? yWidth - 1 : yWidth - ]; - - const heightScale = effectiveXSize[0] / effectiveYSize[0]; - const widthScale = effectiveXSize[1] / effectiveYSize[1]; - - const invHeightScale = 1 / heightScale; - const invWidthScale = 1 / widthScale; - - // This defines the size of the window of values around a particular - // index in dy that we want to search for contributions to dx. - const winHeight = (Math.ceil(invHeightScale) * 2) + 2; - const winWidth = (Math.ceil(invWidthScale) * 2) + 2; - - this.userCode = ` - void main() { - ivec4 coords = getOutputCoords(); - int b = coords[0]; - int d = coords[3]; - int r = coords[1]; - int c = coords[2]; - - float accumulator = 0.0; - - const float heightScale = float(${heightScale}); - const float widthScale = float(${widthScale}); - - const float invHeightScale = float(${invHeightScale}); - const float invWidthScale = float(${invWidthScale}); - - const int winHeight = int(${winHeight}); - const int winWidth = int(${winWidth}); - - // Compute bounds for where in dy we will look - float startRLerp = floor(float(r) * invHeightScale); - int startDyR = int(floor(startRLerp - float(winHeight / 2))); - - float startCLerp = floor(float(c) * invWidthScale); - int startDyC = int(floor(startCLerp - float(winWidth / 2))); - - // Loop over dy - for (int dyROffset = 0; dyROffset < winHeight; dyROffset++) { - int dyR = dyROffset + startDyR; - - // Guard against the window exceeding the bounds of dy - if (dyR < 0 || dyR >= ${yHeight}) { - continue; - } - - for (int dyCOffset = 0; dyCOffset < winWidth; dyCOffset++) { - int dyC = dyCOffset + startDyC; - - // Guard against the window exceeding the bounds of dy - if (dyC < 0 || dyC >= ${yWidth}) { - continue; - } - - float sourceFracRow = - float(${effectiveXSize[0]}) * - (float(dyR) / float(${effectiveYSize[0]})); - - float sourceFracCol = - float(${effectiveXSize[1]}) * - (float(dyC) / float(${effectiveYSize[1]})); - - int sourceNearestRow = int(min( - float(int(${xHeight}) - 1), - ${alignCorners} ? float(round(sourceFracRow)) : - float(floor(sourceFracRow)))); - - int sourceNearestCol = int(min( - float(int(${xWidth}) - 1), - ${alignCorners} ? float(round(sourceFracCol)) : - float(floor(sourceFracCol)))); - - if (r == sourceNearestRow && c == sourceNearestCol) { - accumulator += getDy(b, dyR, dyC, d); - } - } - } - // End loop over dy - - setOutput(accumulator); - } - `; - } -} diff --git a/tfjs-master/tfjs-backend-webgl/src/resize_nearest_neighbor_gpu.ts b/tfjs-master/tfjs-backend-webgl/src/resize_nearest_neighbor_gpu.ts deleted file mode 100644 index 44a470966..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/resize_nearest_neighbor_gpu.ts +++ /dev/null @@ -1,76 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {GPGPUProgram} from './gpgpu_math'; - -export class ResizeNearestNeighborProgram implements GPGPUProgram { - variableNames = ['A']; - outputShape: number[] = []; - userCode: string; - - constructor( - inputShape: [number, number, number, number], newHeight: number, - newWidth: number, alignCorners: boolean, halfPixelCenters: boolean) { - const [batch, oldHeight, oldWidth, depth] = inputShape; - this.outputShape = [batch, newHeight, newWidth, depth]; - - const effectiveInSize: [number, number] = [ - (alignCorners && newHeight > 1) ? oldHeight - 1 : oldHeight, - (alignCorners && newWidth > 1) ? oldWidth - 1 : oldWidth - ]; - - const effectiveOutSize: [number, number] = [ - (alignCorners && newHeight > 1) ? newHeight - 1 : newHeight, - (alignCorners && newWidth > 1) ? newWidth - 1 : newWidth - ]; - - // When align corners is false, we rounds the value with floor. - const roundBase = alignCorners ? '0.5' : '0.0'; - - let sourceFracIndexRC: string; - if (halfPixelCenters) { - sourceFracIndexRC = - `max((vec2(yRC) + vec2(0.5)) * effectiveInputOverOutputRatioRC` + - `, vec2(0.0))`; - } else { - sourceFracIndexRC = `vec2(yRC) * effectiveInputOverOutputRatioRC`; - } - this.userCode = ` - const vec2 effectiveInputOverOutputRatioRC = vec2( - ${effectiveInSize[0] / effectiveOutSize[0]}, - ${effectiveInSize[1] / effectiveOutSize[1]}); - const vec2 inputShapeRC = vec2(${oldHeight}.0, ${oldWidth}.0); - - void main() { - ivec4 coords = getOutputCoords(); - int b = coords[0]; - int d = coords[3]; - ivec2 yRC = coords.yz; - - // Fractional source index. - vec2 sourceFracIndexRC = ${sourceFracIndexRC}; - - // Compute the coordinators of nearest neighbor point. - ivec2 sourceNearestRC = ivec2( - min(inputShapeRC - 1.0, floor(sourceFracIndexRC + ${roundBase}))); - float newValue = getA(b, sourceNearestRC.x, sourceNearestRC.y, d); - - setOutput(newValue); - } - `; - } -} diff --git a/tfjs-master/tfjs-backend-webgl/src/resize_nearest_neighbor_packed_gpu.ts b/tfjs-master/tfjs-backend-webgl/src/resize_nearest_neighbor_packed_gpu.ts deleted file mode 100644 index fa691cf67..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/resize_nearest_neighbor_packed_gpu.ts +++ /dev/null @@ -1,96 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {GPGPUProgram} from './gpgpu_math'; - -export class ResizeNearestNeighborPackedProgram implements GPGPUProgram { - variableNames = ['A']; - packedInputs = true; - packedOutput = true; - outputShape: number[] = []; - userCode: string; - - constructor( - inputShape: [number, number, number, number], newHeight: number, - newWidth: number, alignCorners: boolean, halfPixelCenters: boolean) { - const [batch, oldHeight, oldWidth, depth] = inputShape; - this.outputShape = [batch, newHeight, newWidth, depth]; - - const effectiveInSize: [number, number] = [ - (alignCorners && newHeight > 1) ? oldHeight - 1 : oldHeight, - (alignCorners && newWidth > 1) ? oldWidth - 1 : oldWidth - ]; - - const effectiveOutSize: [number, number] = [ - (alignCorners && newHeight > 1) ? newHeight - 1 : newHeight, - (alignCorners && newWidth > 1) ? newWidth - 1 : newWidth - ]; - - // When align corners is false, we rounds the value with floor. - const roundBase = alignCorners ? '0.5' : '0.0'; - let sourceFracIndexRC: string; - if (halfPixelCenters) { - sourceFracIndexRC = `max((vec3(yRC) + vec3(0.5)) * ` + - `effectiveInputOverOutputRatioRC, vec3(0.0))`; - } else { - sourceFracIndexRC = `vec3(yRC) * effectiveInputOverOutputRatioRC`; - } - - this.userCode = ` - const vec3 effectiveInputOverOutputRatioRC = vec3( - ${effectiveInSize[0] / effectiveOutSize[0]}, - ${effectiveInSize[1] / effectiveOutSize[1]}, - ${effectiveInSize[1] / effectiveOutSize[1]}); - const vec3 inputShapeRC = vec3(${oldHeight}.0, ${oldWidth}.0, - ${oldWidth}.0); - - float getAValue(int b, int r, int c, int d) { - return getChannel(getA(b, r, c, d), vec2(c, d)); - } - - void main() { - ivec4 coords = getOutputCoords(); - int b = coords[0]; - int d = coords[3]; - // Calculate values for next column in yRC.z. - ivec3 yRC = coords.yzz + ivec3(0, 0, 1); - - // Fractional source index. - vec3 sourceFracIndexRC = ${sourceFracIndexRC}; - - // Compute the coordinators of nearest neighbor point. - ivec3 sourceNearestRC = ivec3( - min(inputShapeRC - 1.0, floor(sourceFracIndexRC + ${roundBase}))); - - // Should we calculate next column and row elements in 2x2 packed cell. - bool hasNextCol = d < ${depth - 1}; - bool hasNextRow = coords.z < ${newWidth - 1}; - - vec4 newValue = vec4( - getAValue(b, sourceNearestRC.x, sourceNearestRC.y, d), - hasNextCol ? getAValue(b, sourceNearestRC.x, sourceNearestRC.y, d + 1) - : 0.0, - hasNextRow ? getAValue(b, sourceNearestRC.x, sourceNearestRC.z, d) - : 0.0, - (hasNextRow && hasNextCol) ? - getAValue(b, sourceNearestRC.x, sourceNearestRC.z, d + 1) : 0.0); - - setOutput(newValue); - } - `; - } -} diff --git a/tfjs-master/tfjs-backend-webgl/src/reverse_gpu.ts b/tfjs-master/tfjs-backend-webgl/src/reverse_gpu.ts deleted file mode 100644 index 0f5a40ee3..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/reverse_gpu.ts +++ /dev/null @@ -1,59 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {GPGPUProgram} from './gpgpu_math'; -import {getCoordsDataType} from './shader_compiler'; - -export class ReverseProgram implements GPGPUProgram { - variableNames = ['x']; - outputShape: number[]; - userCode: string; - - constructor(xShape: number[], axis: number[]) { - const rank = xShape.length; - if (rank > 4) { - throw new Error( - `WebGL backend: Reverse of rank-${rank} tensor is not yet supported`); - } - this.outputShape = xShape; - - if (rank === 1) { - this.userCode = ` - void main() { - int coord = getOutputCoords(); - setOutput(getX(${xShape[0]} - coord - 1)); - } - `; - return; - } - const getInCoord = (i: number) => { - if (axis.indexOf(i) !== -1 && xShape[i] !== 1) { - return `${xShape[i]} - coords[${i}] - 1`; - } - return `coords[${i}]`; - }; - const inCoords = xShape.map((_, i) => getInCoord(i)).join(','); - const type = getCoordsDataType(rank); - - this.userCode = ` - void main() { - ${type} coords = getOutputCoords(); - setOutput(getX(${inCoords})); - } - `; - } -} diff --git a/tfjs-master/tfjs-backend-webgl/src/reverse_packed_gpu.ts b/tfjs-master/tfjs-backend-webgl/src/reverse_packed_gpu.ts deleted file mode 100644 index 2e25744ff..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/reverse_packed_gpu.ts +++ /dev/null @@ -1,110 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {GPGPUProgram} from './gpgpu_math'; -import {getChannels} from './packing_util'; -import {getCoordsDataType} from './shader_compiler'; - -export class ReversePackedProgram implements GPGPUProgram { - variableNames = ['x']; - outputShape: number[]; - userCode: string; - packedInputs = true; - packedOutput = true; - - constructor(xShape: number[], axis: number[]) { - const rank = xShape.length; - if (rank > 4) { - throw new Error( - `WebGL backend: Reverse of rank-${rank} tensor is not yet supported`); - } - this.outputShape = xShape; - const channels = getChannels('rc', rank); - const nextColumn = - `${channels[rank - 1]} + 1 < ${this.outputShape[rank - 1]}`; - const nextRow = `${channels[rank - 2]} + 1 < ${this.outputShape[rank - 2]}`; - const type = getCoordsDataType(rank); - if (rank === 1) { - this.userCode = ` - void main(){ - int rc = getOutputCoords(); - vec4 result = vec4(0.); - result.r = getChannel(getX(${xShape[0]} - rc - 1), - ${xShape[0]} - rc - 1); - if(${nextColumn}){ - result.g = getChannel(getX(${xShape[0]} - (rc + 1) - 1), - ${xShape[0]} - (rc + 1) - 1); - } - setOutput(result); - } - `; - } else { - this.userCode = ` - void main() { - ${type} rc = getOutputCoords(); - vec4 result = vec4(0.); - result.r = ${getR(channels.slice())}; - if(${nextColumn}){ - result.g = ${getG(channels.slice())}; - } - if(${nextRow}) { - result.b = ${getB(channels.slice())}; - if(${nextColumn}) { - result.a = ${getA(channels.slice())}; - } - } - setOutput(result); - } - `; - } - - function getR(channels: string[]): string { - return getChannel(channels); - } - - function getG(channels: string[]): string { - channels[rank - 1] = '(' + channels[rank - 1] + ` + 1)`; - return getChannel(channels); - } - - function getB(channels: string[]): string { - channels[rank - 2] = '(' + channels[rank - 2] + ` + 1)`; - return getChannel(channels); - } - - function getA(channels: string[]): string { - channels[rank - 1] = '(' + channels[rank - 1] + ` + 1)`; - channels[rank - 2] = '(' + channels[rank - 2] + ` + 1)`; - return getChannel(channels); - } - - function getChannel(channels: string[]): string { - const inCoordsArray = xShape.map((_, i) => getInCoord(i, channels)); - const inCoords = inCoordsArray.join(','); - const innerDims = inCoordsArray.slice(-2).join(','); - return `getChannel(getX(${inCoords}), vec2(${innerDims}))`; - } - - function getInCoord(i: number, channels1: string[]): string { - if (axis.indexOf(i) !== -1 && xShape[i] !== 1) { - return `${xShape[i]} - ${channels1[i]} - 1`; - } else { - return `${channels1[i]}`; - } - } - } -} diff --git a/tfjs-master/tfjs-backend-webgl/src/rotate_gpu.ts b/tfjs-master/tfjs-backend-webgl/src/rotate_gpu.ts deleted file mode 100644 index d1b8e0bae..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/rotate_gpu.ts +++ /dev/null @@ -1,62 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {GPGPUProgram} from './gpgpu_math'; -import {UniformType} from './shader_compiler'; - -export class RotateProgram implements GPGPUProgram { - variableNames = ['Image']; - outputShape: number[] = []; - userCode: string; - customUniforms = [{name: 'params', type: 'vec4' as UniformType}]; - constructor( - imageShape: [number, number, number, number], - fillValue: number|[number, number, number]) { - const imageHeight = imageShape[1]; - const imageWidth = imageShape[2]; - this.outputShape = imageShape; - - let fillSnippet = ''; - if (typeof fillValue === 'number') { - fillSnippet = `float outputValue = ${fillValue.toFixed(2)};`; - } else { - fillSnippet = ` - vec3 fill = vec3(${fillValue.join(',')}); - float outputValue = fill[coords[3]];`; - } - - this.userCode = ` - void main() { - ivec4 coords = getOutputCoords(); - int x = coords[2]; - int y = coords[1]; - float coordXFloat = (float(x) - params[0]) * params[3] - - (float(y) - params[1]) * params[2]; - float coordYFloat = (float(x) - params[0]) * params[2] + - (float(y) - params[1]) * params[3]; - int coordX = int(round(coordXFloat + params[0])); - int coordY = int(round(coordYFloat + params[1])); - ${fillSnippet} - if(coordX >= 0 && coordX < ${imageWidth} && coordY >= 0 && coordY < ${ - imageHeight}) { - outputValue = getImage(coords[0], coordY, coordX, coords[3]); - } - setOutput(outputValue); - } - `; - } -} diff --git a/tfjs-master/tfjs-backend-webgl/src/scatter_gpu.ts b/tfjs-master/tfjs-backend-webgl/src/scatter_gpu.ts deleted file mode 100644 index 0ed3a8048..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/scatter_gpu.ts +++ /dev/null @@ -1,78 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {GPGPUProgram} from './gpgpu_math'; -import {getCoordsDataType} from './shader_compiler'; - -export class ScatterProgram implements GPGPUProgram { - variableNames = ['updates', 'indices', 'defaultValue']; - outputShape: number[]; - userCode: string; - - constructor( - updateSize: number, sliceDim: number, indicesRank: number, - updatesRank: number, strides: number[], shape: number[], - summingDupeIndex = true, defaultIsTensor = false) { - this.outputShape = shape; - const stridesType = getCoordsDataType(strides.length); - const dtype = getCoordsDataType(shape.length); - let indicesString = ''; - if (indicesRank === 1) { - indicesString = 'i'; - } else if (indicesRank === 2) { - indicesString = 'i, j'; - } - const indicesSnippet = `getIndices(${indicesString})`; - - let updatesString = ''; - if (updatesRank === 1) { - updatesString = 'i'; - } else if (updatesRank === 2) { - updatesString = 'i, coords[1]'; - } - const updatesSnippet = `getUpdates(${updatesString})`; - - let defaultValuesString = ''; - if (defaultIsTensor) { - defaultValuesString = 'coords[0], coords[1]'; - } - const defaultValueSnippet = `getDefaultValue(${defaultValuesString})`; - - const strideString = sliceDim > 1 ? 'strides[j]' : 'strides'; - this.userCode = ` - ${stridesType} strides = ${stridesType}(${strides}); - - void main() { - ${dtype} coords = getOutputCoords(); - float sum = 0.0; - bool found = false; - for (int i = 0; i < ${updateSize}; i++) { - int flattenedIndex = 0; - for (int j = 0; j < ${sliceDim}; j++) { - int index = round(${indicesSnippet}); - flattenedIndex += index * ${strideString}; - } - if (flattenedIndex == coords[0]) { - sum += ${updatesSnippet}; - found = true; - } - } - setOutput(mix(${defaultValueSnippet}, sum, float(found))); - } - `; - } -} diff --git a/tfjs-master/tfjs-backend-webgl/src/scatter_packed_gpu.ts b/tfjs-master/tfjs-backend-webgl/src/scatter_packed_gpu.ts deleted file mode 100644 index 278e1be90..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/scatter_packed_gpu.ts +++ /dev/null @@ -1,99 +0,0 @@ -/** - * @license - * Copyright 2023 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {GPGPUProgram} from './gpgpu_math'; -import {getCoordsDataType} from './shader_compiler'; - -export class ScatterPackedProgram implements GPGPUProgram { - variableNames = ['updates', 'indices', 'defaultValue']; - outputShape: number[]; - packedInputs = true; - packedOutput = true; - userCode: string; - - constructor( - updateSize: number, sliceDim: number, indicesRank: number, - updatesRank: number, strides: number[], shape: number[], - summingDupeIndex = true, defaultIsTensor = false) { - this.outputShape = shape; - const stridesType = getCoordsDataType(strides.length); - const dtype = getCoordsDataType(shape.length); - let indicesString = ''; - if (indicesRank === 1) { - indicesString = 'i'; - } else if (indicesRank === 2) { - indicesString = 'i, j'; - } - const indicesSnippet = `getIndices(${indicesString})`; - - let updatesString = ''; - if (updatesRank === 1) { - updatesString = 'i'; - } else if (updatesRank === 2) { - updatesString = 'i, coords[1]'; - } - const updatesSnippet = `getUpdates(${updatesString})`; - - let defaultValuesString = ''; - if (defaultIsTensor) { - defaultValuesString = 'coords[0], coords[1]'; - } - const defaultValueSnippet = `getDefaultValue(${defaultValuesString})`; - - const strideString = sliceDim > 1 ? 'strides[j]' : 'strides'; - const strideString2 = sliceDim > 1 ? 'strides[j + 1]' : 'strides'; - - this.userCode = ` - ${stridesType} strides = ${stridesType}(${strides}); - - void main() { - ${dtype} coords = getOutputCoords(); - vec4 sum = vec4(0.); - vec4 found = vec4(0.); - for (int i = 0; i < ${updateSize}; i+=2) { - ivec2 flattenedIndex = ivec2(0); - for (int j = 0; j < ${sliceDim}; j+=2) { - ivec4 index = round(${indicesSnippet}); - flattenedIndex += index.xz * ${strideString}; - if (j + 1 < ${sliceDim}) { - flattenedIndex += index.yw * ${strideString2}; - } - } - if (flattenedIndex[0] == coords[0] || flattenedIndex[1] == coords[0] || - flattenedIndex[0] == coords[0] + 1 || flattenedIndex[1] == coords[0] + 1) { - vec4 updVals = ${updatesSnippet}; - if (flattenedIndex[0] == coords[0]) { - sum.xy += updVals.xy; - found.xy = vec2(1.); - } else if (flattenedIndex[0] == coords[0] + 1) { - sum.zw += updVals.xy; - found.zw = vec2(1.); - } - if (flattenedIndex[1] == coords[0]) { - sum.xy += updVals.zw; - found.xy = vec2(1.); - } else if (flattenedIndex[1] == coords[0] + 1) { - sum.zw += updVals.zw; - found.zw = vec2(1.); - } - } - } - setOutput(mix(${defaultValueSnippet}, sum, found)); - } - `; - } -} diff --git a/tfjs-master/tfjs-backend-webgl/src/search_sorted_gpu.ts b/tfjs-master/tfjs-backend-webgl/src/search_sorted_gpu.ts deleted file mode 100644 index 3a9c01005..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/search_sorted_gpu.ts +++ /dev/null @@ -1,70 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {env} from '@tensorflow/tfjs-core'; -import {GPGPUProgram} from './gpgpu_math'; -import {UniformType} from './shader_compiler'; - -export class SearchSortedProgram implements GPGPUProgram { - variableNames = ['sortedSequence', 'values']; - outputShape: number[]; - userCode: string; - customUniforms = [{name: 'numInputs', type: 'int' as UniformType}]; - - constructor( - batchSize: number, numInputs: number, numValues: number, - side: 'left'|'right') { - this.outputShape = [batchSize, numValues]; - - const webGL2LoopHead = 'while (left < right) {'; - // WebGL1 doesn't accept non constant loop conditions, so upper bound loop - // iterations. - const webGL1LoopHead = `for (int i = 0; i < ${ - Math.ceil(Math.log2(numInputs + 1))}; ++i) { if (left >= right) break;`; - const loopHead = env().getNumber('WEBGL_VERSION') === 2 ? webGL2LoopHead : - webGL1LoopHead; - - // left corresponds to lower bound and right to upper bound. - const boundComparator = side === 'left' ? '<' : '<='; - this.userCode = ` - int findBound(int batch, float value) { - int left = 0; - int right = numInputs; - int mid; - ${loopHead} - mid = (left + right) / 2; - if (getSortedSequence(batch, mid) ${boundComparator} value) { - left = mid + 1; - } else { - right = mid; - } - } - return right; - } - - void main() { - ivec2 coords = getOutputCoords(); - int batch = coords[0]; - int valueIndex = coords[1]; - - float value = getValues(batch, valueIndex); - - setOutput(float(findBound(batch, value))); - } - `; - } -} diff --git a/tfjs-master/tfjs-backend-webgl/src/segment_gpu.ts b/tfjs-master/tfjs-backend-webgl/src/segment_gpu.ts deleted file mode 100644 index f9cc32ac9..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/segment_gpu.ts +++ /dev/null @@ -1,162 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util} from '@tensorflow/tfjs-core'; -import {GPGPUProgram} from './gpgpu_math'; - -export class SegmentOpProgram implements GPGPUProgram { - variableNames = ['x', 'segmentIds']; - outputShape: number[]; - userCode: string; - - constructor( - segOpInfo: backend_util.segment_util.SegOpInfo, - segOpType: 'unsortedSegmentSum') { - const windowSize = segOpInfo.windowSize; - const batchSize = segOpInfo.batchSize; - const inSize = segOpInfo.inSize; - const numSegments = segOpInfo.numSegments; - const outSize = numSegments * Math.ceil(inSize / windowSize); - this.outputShape = [batchSize, outSize]; - - const initializationValue = '0.0'; - const returnValue = `sumValue`; - - const windowSizeNearestVec4 = Math.floor(windowSize / 4) * 4; - const windowSizeVec4Remainder = windowSize % 4; - - const updateSnippet = ` - sumValue += dot(values, segFilter); - `; - - let checkValueOutOfBounds = ''; - if (inSize % windowSize > 0) { - checkValueOutOfBounds = ` - if (inIdx < 0 || inIdx >= ${inSize}) { - return initializationValue; - } - `; - } - - let checkSegmentIdOutOfBounds = ''; - if (inSize % windowSize > 0) { - checkSegmentIdOutOfBounds = ` - if (inIdx < 0 || inIdx >= ${inSize}) { - return -1.0; - } - `; - } - - this.userCode = ` - const float initializationValue = ${initializationValue}; - - float getValue(int batch, int inIdx) { - ${checkValueOutOfBounds} - return getX(batch, inIdx); - } - - float getSegmentIdAtIndex(int inIdx) { - ${checkSegmentIdOutOfBounds} - return getSegmentIds(inIdx); - } - - void main() { - ivec2 coords = getOutputCoords(); - int batch = coords[0]; - int outIdx = coords[1]; - int inOffset = int(floor(float(outIdx) / float( - ${numSegments})) * float(${windowSize})); - int currentSeg = int(mod(float(outIdx), float(${numSegments}))); - - float sumValue = 0.0; - - for (int i = 0; i < ${windowSizeNearestVec4}; i += 4) { - int inIdx = inOffset + i; - vec4 values = vec4( - getValue(batch, inIdx), - getValue(batch, inIdx + 1), - getValue(batch, inIdx + 2), - getValue(batch, inIdx + 3) - ); - - vec4 segFilter = vec4( - int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0, - int(getSegmentIdAtIndex(inIdx + 1)) == currentSeg ? 1 : 0, - int(getSegmentIdAtIndex(inIdx + 2)) == currentSeg ? 1 : 0, - int(getSegmentIdAtIndex(inIdx + 3)) == currentSeg ? 1 : 0 - ); - - ${updateSnippet} - } - - int inIdx = inOffset + ${windowSizeNearestVec4}; - if (${windowSizeVec4Remainder === 1}) { - vec4 values = vec4( - getValue(batch, inIdx), - initializationValue, - initializationValue, - initializationValue - ); - - int inIdxSeg = int(getSegmentIdAtIndex(inIdx)); - - vec4 segFilter = vec4( - int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0, - 0, - 0, - 0 - ); - - ${updateSnippet} - } else if (${windowSizeVec4Remainder === 2}) { - vec4 values = vec4( - getValue(batch, inIdx), - getValue(batch, inIdx + 1), - initializationValue, - initializationValue - ); - - vec4 segFilter = vec4( - int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0, - int(getSegmentIdAtIndex(inIdx + 1)) == currentSeg ? 1 : 0, - 0, - 0 - ); - - ${updateSnippet} - } else if (${windowSizeVec4Remainder === 3}) { - vec4 values = vec4( - getValue(batch, inIdx), - getValue(batch, inIdx + 1), - getValue(batch, inIdx + 2), - initializationValue - ); - - vec4 segFilter = vec4( - int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0, - int(getSegmentIdAtIndex(inIdx + 1)) == currentSeg ? 1 : 0, - int(getSegmentIdAtIndex(inIdx + 2)) == currentSeg ? 1 : 0, - 0 - ); - - ${updateSnippet} - } - setOutput(${returnValue}); - } - `; - } -} diff --git a/tfjs-master/tfjs-backend-webgl/src/select_gpu.ts b/tfjs-master/tfjs-backend-webgl/src/select_gpu.ts deleted file mode 100644 index 8cea29053..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/select_gpu.ts +++ /dev/null @@ -1,66 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {GPGPUProgram} from './gpgpu_math'; -import {getCoordsDataType} from './shader_compiler'; - -export class SelectProgram implements GPGPUProgram { - variableNames = ['c', 'a', 'b']; - outputShape: number[]; - userCode: string; - - constructor(cRank: number, shape: number[], rank: number) { - this.outputShape = shape; - - let cCoords; - let abCoords; - if (rank > 4) { - throw Error(`Where for rank ${rank} is not yet supported`); - } - - if (rank === 1) { - abCoords = `resRC`; - cCoords = `resRC`; - } else { - const currentCoords = ['resRC.x', 'resRC.y', 'resRC.z', 'resRC.w']; - const cCoordVars = []; - const abCoordVars = []; - for (let i = 0; i < shape.length; i++) { - abCoordVars.push(`${currentCoords[i]}`); - if (i < cRank) { - cCoordVars.push(`${currentCoords[i]}`); - } - } - cCoords = cCoordVars.join(); - abCoords = abCoordVars.join(); - } - - const dtype = getCoordsDataType(rank); - - this.userCode = ` - void main() { - ${dtype} resRC = getOutputCoords(); - float cVal = getC(${cCoords}); - if (cVal >= 1.0) { - setOutput(getA(${abCoords})); - } else { - setOutput(getB(${abCoords})); - } - } - `; - } -} diff --git a/tfjs-master/tfjs-backend-webgl/src/setup_test.ts b/tfjs-master/tfjs-backend-webgl/src/setup_test.ts deleted file mode 100644 index 0faa95d5a..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/setup_test.ts +++ /dev/null @@ -1,77 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import '@tensorflow/tfjs-backend-cpu'; -// Register the backend. -import './index'; -// tslint:disable-next-line: no-imports-from-dist -import '@tensorflow/tfjs-core/dist/public/chained_ops/register_all_chained_ops'; -// tslint:disable-next-line: no-imports-from-dist -import '@tensorflow/tfjs-core/dist/register_all_gradients'; - -// tslint:disable-next-line: no-imports-from-dist -import {parseTestEnvFromKarmaFlags, setTestEnvs, setupTestFilters, TEST_ENVS, TestFilter} from '@tensorflow/tfjs-core/dist/jasmine_util'; - -import {registerTestEnvs} from './backend_webgl_test_registry'; - -registerTestEnvs(); - -const TEST_FILTERS: TestFilter[] = []; - -const customInclude = (testName: string) => { - const toExclude = [ - 'isBrowser: false', - 'dilation gradient', - 'throws when index is out of bound', - // otsu tests for threshold op is failing on windows - 'method otsu', - 'draw on canvas context', - // https://github.com/tensorflow/tfjs/issues/7618 - 'numbers exceed float32 precision', - // float32 inputs with nonzero fractional part should not be rounded - 'floorDiv float32', - ]; - for (const subStr of toExclude) { - if (testName.includes(subStr)) { - return false; - } - } - // TODO(msoulanille): Prefer TEST_FILTERS over customInclude. - return true; -}; -setupTestFilters(TEST_FILTERS, customInclude); - -// Allow flags to override test envs -// tslint:disable-next-line:no-any -declare let __karma__: any; -if (typeof __karma__ !== 'undefined') { - const testEnv = parseTestEnvFromKarmaFlags(__karma__.config.args, TEST_ENVS); - if (testEnv != null) { - setTestEnvs([testEnv]); - } -} - -// These use 'require' because they must not be hoisted above -// the preceding snippet that parses test environments. -// Import and run tests from core. -// tslint:disable-next-line:no-imports-from-dist -// tslint:disable-next-line:no-require-imports -require('@tensorflow/tfjs-core/dist/tests'); -// Import and run tests from webgl. -// tslint:disable-next-line:no-imports-from-dist -// tslint:disable-next-line:no-require-imports -require('./tests'); diff --git a/tfjs-master/tfjs-backend-webgl/src/shader_compiler.ts b/tfjs-master/tfjs-backend-webgl/src/shader_compiler.ts deleted file mode 100644 index b051e0974..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/shader_compiler.ts +++ /dev/null @@ -1,1915 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// Please make sure the shaker key in makeShaderKey in gpgpu_math.ts is well -// mapped if any shader source code is changed in this file. - -import {backend_util, util} from '@tensorflow/tfjs-core'; -const {getBroadcastDims} = backend_util; -import {getGlslDifferences, GLSL} from './glsl_version'; -import * as shader_util from './shader_compiler_util'; - -export type ShapeInfo = { - logicalShape: number[], - texShape: [number, number], - isUniform: boolean, - isPacked: boolean, - flatOffset: number -}; - -export type InputInfo = { - name: string, - shapeInfo: ShapeInfo -}; - -export type UniformType = - 'float'|'vec2'|'vec3'|'vec4'|'int'|'ivec2'|'ivec3'|'ivec4'; - -interface ProgramParams { - userCode: string; - enableShapeUniforms?: boolean; - packedInputs?: boolean; - customUniforms?: - Array<{name: string; arrayIndex?: number; type: UniformType;}>; -} - -export function makeShader( - inputsInfo: InputInfo[], outputShape: ShapeInfo, - program: ProgramParams): string { - const prefixSnippets: string[] = []; - inputsInfo.forEach(x => { - const size = util.sizeFromShape(x.shapeInfo.logicalShape); - - // Snippet when we decided to upload the values as uniform. - if (x.shapeInfo.isUniform) { - prefixSnippets.push( - `uniform float ${x.name}${size > 1 ? `[${size}]` : ''};`); - } else { - prefixSnippets.push(`uniform sampler2D ${x.name};`); - prefixSnippets.push(`uniform int offset${x.name};`); - } - - if (program.enableShapeUniforms) { - const {uniformShape} = getUniformInfoFromShape( - program.packedInputs, x.shapeInfo.logicalShape, x.shapeInfo.texShape); - switch (uniformShape.length) { - case 1: - prefixSnippets.push(`uniform int ${x.name}Shape;`); - break; - case 2: - prefixSnippets.push(`uniform ivec2 ${x.name}Shape;`); - break; - case 3: - prefixSnippets.push(`uniform ivec3 ${x.name}Shape;`); - break; - case 4: - prefixSnippets.push(`uniform ivec4 ${x.name}Shape;`); - break; - default: - break; - } - prefixSnippets.push(`uniform ivec2 ${x.name}TexShape;`); - } - }); - - if (program.enableShapeUniforms) { - switch (outputShape.logicalShape.length) { - case 1: - prefixSnippets.push(`uniform int outShape;`); - break; - case 2: - prefixSnippets.push(`uniform ivec2 outShape;`); - prefixSnippets.push(`uniform int outShapeStrides;`); - break; - case 3: - prefixSnippets.push(`uniform ivec3 outShape;`); - prefixSnippets.push(`uniform ivec2 outShapeStrides;`); - break; - case 4: - prefixSnippets.push(`uniform ivec4 outShape;`); - prefixSnippets.push(`uniform ivec3 outShapeStrides;`); - break; - default: - break; - } - prefixSnippets.push(`uniform ivec2 outTexShape;`); - } - if (program.customUniforms) { - program.customUniforms.forEach((d) => { - prefixSnippets.push(`uniform ${d.type} ${d.name}${ - d.arrayIndex ? `[${d.arrayIndex}]` : ''};`); - }); - } - const inputPrefixSnippet = prefixSnippets.join('\n'); - - const inputSamplingSnippet = inputsInfo - .map( - x => getInputSamplingSnippet( - x, outputShape, program.packedInputs, - program.enableShapeUniforms)) - .join('\n'); - const outTexShape = outputShape.texShape; - const glsl = getGlslDifferences(); - const floatTextureSampleSnippet = getFloatTextureSampleSnippet(glsl); - let outputSamplingSnippet: string; - let floatTextureSetOutputSnippet: string; - let shaderPrefix = getShaderPrefix(glsl); - - if (outputShape.isPacked) { - outputSamplingSnippet = getPackedOutputSamplingSnippet( - outputShape.logicalShape, outTexShape, program.enableShapeUniforms); - floatTextureSetOutputSnippet = getFloatTextureSetRGBASnippet(glsl); - } else { - outputSamplingSnippet = getOutputSamplingSnippet( - outputShape.logicalShape, outTexShape, program.enableShapeUniforms); - floatTextureSetOutputSnippet = getFloatTextureSetRSnippet(glsl); - } - - if (program.packedInputs) { - shaderPrefix += SHADER_PACKED_PREFIX; - } - - const source = [ - shaderPrefix, floatTextureSampleSnippet, floatTextureSetOutputSnippet, - inputPrefixSnippet, outputSamplingSnippet, inputSamplingSnippet, - program.userCode - ].join('\n'); - return source; -} - -function getSamplerFromInInfo( - inInfo: InputInfo, enableShapeUniforms = false): string { - const shape = inInfo.shapeInfo.logicalShape; - switch (shape.length) { - case 0: - return getSamplerScalar(inInfo, enableShapeUniforms); - case 1: - return getSampler1D(inInfo, enableShapeUniforms); - case 2: - return getSampler2D(inInfo, enableShapeUniforms); - case 3: - return getSampler3D(inInfo, enableShapeUniforms); - case 4: - return getSampler4D(inInfo, enableShapeUniforms); - case 5: - return getSampler5D(inInfo); - case 6: - return getSampler6D(inInfo); - default: - throw new Error( - `${shape.length}-D input sampling` + - ` is not yet supported`); - } -} - -function getPackedSamplerFromInInfo( - inInfo: InputInfo, enableShapeUniforms: boolean): string { - const shape = inInfo.shapeInfo.logicalShape; - switch (shape.length) { - case 0: - return getPackedSamplerScalar(inInfo); - case 1: - return getPackedSampler1D(inInfo, enableShapeUniforms); - case 2: - return getPackedSampler2D(inInfo, enableShapeUniforms); - case 3: - return getPackedSampler3D(inInfo, enableShapeUniforms); - default: - return getPackedSamplerND(inInfo, enableShapeUniforms); - } -} - -function getInputSamplingSnippet( - inInfo: InputInfo, outShapeInfo: ShapeInfo, usesPackedTextures = false, - enableShapeUniforms: boolean): string { - let res = ''; - if (usesPackedTextures) { - res += getPackedSamplerFromInInfo(inInfo, enableShapeUniforms); - } else { - res += getSamplerFromInInfo(inInfo, enableShapeUniforms); - } - - const inShape = inInfo.shapeInfo.logicalShape; - const outShape = outShapeInfo.logicalShape; - if (inShape.length <= outShape.length) { - if (usesPackedTextures) { - res += getPackedSamplerAtOutputCoords(inInfo, outShapeInfo); - } else { - res += getSamplerAtOutputCoords(inInfo, outShapeInfo); - } - } - return res; -} - -function getPackedOutputSamplingSnippet( - outShape: number[], outTexShape: [number, number], - enableShapeUniforms: boolean): string { - switch (outShape.length) { - case 0: - return getOutputScalarCoords(); - case 1: - return getOutputPacked1DCoords( - outShape as [number], outTexShape, enableShapeUniforms); - case 2: - return getOutputPacked2DCoords( - outShape as [number, number], outTexShape, enableShapeUniforms); - case 3: - return getOutputPacked3DCoords( - outShape as [number, number, number], outTexShape, - enableShapeUniforms); - default: - return getOutputPackedNDCoords( - outShape, outTexShape, enableShapeUniforms); - } -} - -function getOutputSamplingSnippet( - outShape: number[], outTexShape: [number, number], - enableShapeUniforms: boolean): string { - switch (outShape.length) { - case 0: - return getOutputScalarCoords(); - case 1: - return getOutput1DCoords( - outShape as [number], outTexShape, enableShapeUniforms); - case 2: - return getOutput2DCoords( - outShape as [number, number], outTexShape, enableShapeUniforms); - case 3: - return getOutput3DCoords( - outShape as [number, number, number], outTexShape, - enableShapeUniforms); - case 4: - return getOutput4DCoords( - outShape as [number, number, number, number], outTexShape, - enableShapeUniforms); - case 5: - return getOutput5DCoords( - outShape as [number, number, number, number, number], outTexShape); - case 6: - return getOutput6DCoords( - outShape as [number, number, number, number, number, number], - outTexShape); - default: - throw new Error( - `${outShape.length}-D output sampling is not yet supported`); - } -} - -function getFloatTextureSampleSnippet(glsl: GLSL): string { - return ` - float sampleTexture(sampler2D textureSampler, vec2 uv) { - return ${glsl.texture2D}(textureSampler, uv).r; - } - `; -} - -function getFloatTextureSetRSnippet(glsl: GLSL): string { - return ` - void setOutput(float val) { - ${glsl.output} = vec4(val, 0, 0, 0); - } - `; -} - -function getFloatTextureSetRGBASnippet(glsl: GLSL): string { - return ` - void setOutput(vec4 val) { - ${glsl.output} = val; - } - `; -} - -function getShaderPrefix(glsl: GLSL): string { - const SHADER_PREFIX = `${glsl.version} - precision highp float; - precision highp int; - precision highp sampler2D; - ${glsl.varyingFs} vec2 resultUV; - ${glsl.defineOutput} - const vec2 halfCR = vec2(0.5, 0.5); - - struct ivec5 - { - int x; - int y; - int z; - int w; - int u; - }; - - struct ivec6 - { - int x; - int y; - int z; - int w; - int u; - int v; - }; - - uniform float NAN; - ${glsl.defineSpecialNaN} - ${glsl.defineSpecialInf} - ${glsl.defineRound} - - int imod(int x, int y) { - return x - y * (x / y); - } - - int idiv(int a, int b, float sign) { - int res = a / b; - int mod = imod(a, b); - if (sign < 0. && mod != 0) { - res -= 1; - } - return res; - } - - //Based on the work of Dave Hoskins - //https://www.shadertoy.com/view/4djSRW - #define HASHSCALE1 443.8975 - float random(float seed){ - vec2 p = resultUV * seed; - vec3 p3 = fract(vec3(p.xyx) * HASHSCALE1); - p3 += dot(p3, p3.yzx + 19.19); - return fract((p3.x + p3.y) * p3.z); - } - - ${SAMPLE_1D_SNIPPET} - ${SAMPLE_2D_SNIPPET} - ${SAMPLE_3D_SNIPPET} - `; - - return SHADER_PREFIX; -} - -const SAMPLE_1D_SNIPPET = ` -vec2 uvFromFlat(int texNumR, int texNumC, int index) { - int texR = index / texNumC; - int texC = index - texR * texNumC; - return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR); -} -vec2 packedUVfrom1D(int texNumR, int texNumC, int index) { - int texelIndex = index / 2; - int texR = texelIndex / texNumC; - int texC = texelIndex - texR * texNumC; - return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR); -} -`; - -const SAMPLE_2D_SNIPPET = ` -vec2 packedUVfrom2D(int texelsInLogicalRow, int texNumR, - int texNumC, int row, int col) { - int texelIndex = (row / 2) * texelsInLogicalRow + (col / 2); - int texR = texelIndex / texNumC; - int texC = texelIndex - texR * texNumC; - return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR); -} -`; - -const SAMPLE_3D_SNIPPET = ` -vec2 packedUVfrom3D(int texNumR, int texNumC, - int texelsInBatch, int texelsInLogicalRow, int b, - int row, int col) { - int index = b * texelsInBatch + (row / 2) * texelsInLogicalRow + (col / 2); - int texR = index / texNumC; - int texC = index - texR * texNumC; - return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR); -} -`; - -const SHADER_PACKED_PREFIX = ` - float getChannel(vec4 frag, vec2 innerDims) { - vec2 modCoord = mod(innerDims, 2.); - return modCoord.x == 0. ? - (modCoord.y == 0. ? frag.r : frag.g) : - (modCoord.y == 0. ? frag.b : frag.a); - } - float getChannel(vec4 frag, int dim) { - float modCoord = mod(float(dim), 2.); - return modCoord == 0. ? frag.r : frag.g; - } -`; - -function getOutputScalarCoords() { - return ` - int getOutputCoords() { - return 0; - } - `; -} - -function getOutputPacked1DCoords( - shape: [number], texShape: [number, number], - enableShapeUniforms: boolean): string { - const packedTexShape = - [Math.ceil(texShape[0] / 2), Math.ceil(texShape[1] / 2)]; - if (packedTexShape[0] === 1) { - if (enableShapeUniforms) { - return ` - int getOutputCoords() { - return 2 * int(resultUV.x * ceil(float(outTexShape[1]) / 2.0)); - } - `; - } - - return ` - int getOutputCoords() { - return 2 * int(resultUV.x * ${packedTexShape[1]}.0); - } - `; - } - - if (packedTexShape[1] === 1) { - if (enableShapeUniforms) { - return ` - int getOutputCoords() { - return 2 * int(resultUV.y * ceil(float(outTexShape[0]) / 2.0)); - } - `; - } - - return ` - int getOutputCoords() { - return 2 * int(resultUV.y * ${packedTexShape[0]}.0); - } - `; - } - - if (enableShapeUniforms) { - return ` - int getOutputCoords() { - ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0)); - ivec2 resTexRC = ivec2(resultUV.yx * - vec2(packedTexShape[0], packedTexShape[1])); - return 2 * (resTexRC.x * packedTexShape[1] + resTexRC.y); - } - `; - } - - return ` - int getOutputCoords() { - ivec2 resTexRC = ivec2(resultUV.yx * - vec2(${packedTexShape[0]}, ${packedTexShape[1]})); - return 2 * (resTexRC.x * ${packedTexShape[1]} + resTexRC.y); - } - `; -} - -function getOutput1DCoords( - shape: [number], texShape: [number, number], - enableShapeUniforms: boolean): string { - if (texShape[0] === 1) { - if (enableShapeUniforms) { - return ` - int getOutputCoords() { - return int(resultUV.x * float(outTexShape[1])); - } - `; - } - return ` - int getOutputCoords() { - return int(resultUV.x * ${texShape[1]}.0); - } - `; - } - if (texShape[1] === 1) { - if (enableShapeUniforms) { - return ` - int getOutputCoords() { - return int(resultUV.y * float(outTexShape[0])); - } - `; - } - return ` - int getOutputCoords() { - return int(resultUV.y * ${texShape[0]}.0); - } - `; - } - if (enableShapeUniforms) { - return ` - int getOutputCoords() { - ivec2 resTexRC = ivec2(resultUV.yx * - vec2(outTexShape[0], outTexShape[1])); - return resTexRC.x * outTexShape[1] + resTexRC.y; - } - `; - } - return ` - int getOutputCoords() { - ivec2 resTexRC = ivec2(resultUV.yx * - vec2(${texShape[0]}, ${texShape[1]})); - return resTexRC.x * ${texShape[1]} + resTexRC.y; - } - `; -} - -function getOutputPacked3DCoords( - shape: [number, number, number], texShape: [number, number], - enableShapeUniforms: boolean): string { - if (enableShapeUniforms) { - return ` - ivec3 getOutputCoords() { - ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0)); - int texelsInLogicalRow = int(ceil(float(outShape[2]) / 2.0)); - int texelsInBatch = texelsInLogicalRow * int(ceil(float(outShape[1]) / 2.0)); - ivec2 resTexRC = ivec2(resultUV.yx * - vec2(packedTexShape[0], packedTexShape[1])); - int index = resTexRC.x * packedTexShape[1] + resTexRC.y; - - int b = index / texelsInBatch; - index -= b * texelsInBatch; - - int r = 2 * (index / texelsInLogicalRow); - int c = imod(index, texelsInLogicalRow) * 2; - - return ivec3(b, r, c); - } - `; - } - - const packedTexShape = - [Math.ceil(texShape[0] / 2), Math.ceil(texShape[1] / 2)]; - const texelsInLogicalRow = Math.ceil(shape[2] / 2); - const texelsInBatch = texelsInLogicalRow * Math.ceil(shape[1] / 2); - - return ` - ivec3 getOutputCoords() { - ivec2 resTexRC = ivec2(resultUV.yx * - vec2(${packedTexShape[0]}, ${packedTexShape[1]})); - int index = resTexRC.x * ${packedTexShape[1]} + resTexRC.y; - - int b = index / ${texelsInBatch}; - index -= b * ${texelsInBatch}; - - int r = 2 * (index / ${texelsInLogicalRow}); - int c = imod(index, ${texelsInLogicalRow}) * 2; - - return ivec3(b, r, c); - } - `; -} - -function getOutput3DCoords( - shape: [number, number, number], texShape: [number, number], - enableShapeUniforms: boolean): string { - if (enableShapeUniforms) { - const coordsFromIndexSnippet = - shader_util.getOutputLogicalCoordinatesFromFlatIndexByUniform( - ['r', 'c', 'd'], shape); - - return ` - ivec3 getOutputCoords() { - ivec2 resTexRC = ivec2(resultUV.yx * - vec2(outTexShape[0], outTexShape[1])); - int index = resTexRC.x * outTexShape[1] + resTexRC.y; - ${coordsFromIndexSnippet} - return ivec3(r, c, d); - } -`; - } - const coordsFromIndexSnippet = - shader_util.getLogicalCoordinatesFromFlatIndex(['r', 'c', 'd'], shape); - - return ` - ivec3 getOutputCoords() { - ivec2 resTexRC = ivec2(resultUV.yx * - vec2(${texShape[0]}, ${texShape[1]})); - int index = resTexRC.x * ${texShape[1]} + resTexRC.y; - ${coordsFromIndexSnippet} - return ivec3(r, c, d); - } - `; -} - -function getOutputPackedNDCoords( - shape: number[], texShape: [number, number], - enableShapeUniforms: boolean): string { - if (enableShapeUniforms) { - // TODO: support 5d and 6d - return ` - ivec4 getOutputCoords() { - ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0)); - ivec2 resTexRC = ivec2(resultUV.yx * - vec2(packedTexShape[0], packedTexShape[1])); - int index = resTexRC.x * packedTexShape[1] + resTexRC.y; - - int texelsInLogicalRow = int(ceil(float(outShape[3]) / 2.0)); - int texelsInBatch = texelsInLogicalRow * int(ceil(float(outShape[2]) / 2.0)); - int texelsInBatchN = texelsInBatch * outShape[1]; - - int b2 = index / texelsInBatchN; - index -= b2 * texelsInBatchN; - - int b = index / texelsInBatch; - index -= b * texelsInBatch; - - int r = 2 * (index / texelsInLogicalRow); - int c = imod(index, texelsInLogicalRow) * 2; - - return ivec4(b2, b, r, c); - } - `; - } - const packedTexShape = - [Math.ceil(texShape[0] / 2), Math.ceil(texShape[1] / 2)]; - - const texelsInLogicalRow = Math.ceil(shape[shape.length - 1] / 2); - const texelsInBatch = - texelsInLogicalRow * Math.ceil(shape[shape.length - 2] / 2); - let texelsInBatchN = texelsInBatch; - let batches = ``; - let coords = 'b, r, c'; - - for (let b = 2; b < shape.length - 1; b++) { - texelsInBatchN *= shape[shape.length - b - 1]; - batches = ` - int b${b} = index / ${texelsInBatchN}; - index -= b${b} * ${texelsInBatchN}; - ` + batches; - coords = `b${b}, ` + coords; - } - - return ` - ivec${shape.length} getOutputCoords() { - ivec2 resTexRC = ivec2(resultUV.yx * - vec2(${packedTexShape[0]}, ${packedTexShape[1]})); - int index = resTexRC.x * ${packedTexShape[1]} + resTexRC.y; - - ${batches} - - int b = index / ${texelsInBatch}; - index -= b * ${texelsInBatch}; - - int r = 2 * (index / ${texelsInLogicalRow}); - int c = imod(index, ${texelsInLogicalRow}) * 2; - - return ivec${shape.length}(${coords}); - } - `; -} - -function getOutput4DCoords( - shape: [number, number, number, number], texShape: [number, number], - enableShapeUniforms: boolean): string { - if (enableShapeUniforms) { - const coordsFromIndexSnippet = - shader_util.getOutputLogicalCoordinatesFromFlatIndexByUniform( - ['r', 'c', 'd', 'd2'], shape); - - return ` - ivec4 getOutputCoords() { - ivec2 resTexRC = ivec2(resultUV.yx * - vec2(outTexShape[0], outTexShape[1])); - int index = resTexRC.x * outTexShape[1] + resTexRC.y; - ${coordsFromIndexSnippet} - return ivec4(r, c, d, d2); - } - `; - } - const coordsFromIndexSnippet = shader_util.getLogicalCoordinatesFromFlatIndex( - ['r', 'c', 'd', 'd2'], shape); - - return ` - ivec4 getOutputCoords() { - ivec2 resTexRC = ivec2(resultUV.yx * - vec2(${texShape[0]}, ${texShape[1]})); - int index = resTexRC.x * ${texShape[1]} + resTexRC.y; - ${coordsFromIndexSnippet} - return ivec4(r, c, d, d2); - } - `; -} - -function getOutput5DCoords( - shape: [number, number, number, number, number], - texShape: [number, number]): string { - const coordsFromIndexSnippet = shader_util.getLogicalCoordinatesFromFlatIndex( - ['r', 'c', 'd', 'd2', 'd3'], shape); - - return ` - ivec5 getOutputCoords() { - ivec2 resTexRC = ivec2(resultUV.yx * vec2(${texShape[0]}, - ${texShape[1]})); - - int index = resTexRC.x * ${texShape[1]} + resTexRC.y; - - ${coordsFromIndexSnippet} - - ivec5 outShape = ivec5(r, c, d, d2, d3); - return outShape; - } - `; -} - -function getOutput6DCoords( - shape: [number, number, number, number, number, number], - texShape: [number, number]): string { - const coordsFromIndexSnippet = shader_util.getLogicalCoordinatesFromFlatIndex( - ['r', 'c', 'd', 'd2', 'd3', 'd4'], shape); - - return ` - ivec6 getOutputCoords() { - ivec2 resTexRC = ivec2(resultUV.yx * - vec2(${texShape[0]}, ${texShape[1]})); - int index = resTexRC.x * ${texShape[1]} + resTexRC.y; - - ${coordsFromIndexSnippet} - - ivec6 result = ivec6(r, c, d, d2, d3, d4); - return result; - } - `; -} - -function getOutputPacked2DCoords( - shape: [number, number], texShape: [number, number], - enableShapeUniforms: boolean): string { - const packedTexShape = - [Math.ceil(texShape[0] / 2), Math.ceil(texShape[1] / 2)]; - if (util.arraysEqual(shape, texShape)) { - if (enableShapeUniforms) { - return ` - ivec2 getOutputCoords() { - ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0)); - return 2 * ivec2(resultUV.yx * vec2(packedTexShape[0], packedTexShape[1])); - } - `; - } - - return ` - ivec2 getOutputCoords() { - return 2 * ivec2(resultUV.yx * vec2(${packedTexShape[0]}, ${ - packedTexShape[1]})); - } - `; - } - - // texels needed to accommodate a logical row - const texelsInLogicalRow = Math.ceil(shape[1] / 2); - - /** - * getOutputCoords - * - * resTexRC: The rows and columns of the texels. If you move over one - * texel to the right in the packed texture, you are moving over one column - * (not two). - * - * index: The texel index - */ - if (enableShapeUniforms) { - return ` - ivec2 getOutputCoords() { - ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0)); - int texelsInLogicalRow = int(ceil(float(outShape[1]) / 2.0)); - ivec2 resTexRC = ivec2(resultUV.yx * - vec2(packedTexShape[0], packedTexShape[1])); - - int index = resTexRC.x * packedTexShape[1] + resTexRC.y; - int r = 2 * (index / texelsInLogicalRow); - int c = imod(index, texelsInLogicalRow) * 2; - - return ivec2(r, c); - } - `; - } - - return ` - ivec2 getOutputCoords() { - ivec2 resTexRC = ivec2(resultUV.yx * - vec2(${packedTexShape[0]}, ${packedTexShape[1]})); - - int index = resTexRC.x * ${packedTexShape[1]} + resTexRC.y; - int r = 2 * (index / ${texelsInLogicalRow}); - int c = imod(index, ${texelsInLogicalRow}) * 2; - - return ivec2(r, c); - } - `; -} - -function getOutput2DCoords( - shape: [number, number], texShape: [number, number], - enableShapeUniforms: boolean): string { - if (util.arraysEqual(shape, texShape)) { - if (enableShapeUniforms) { - return ` - ivec2 getOutputCoords() { - return ivec2(resultUV.yx * vec2(outTexShape[0], outTexShape[1])); - } - `; - } - return ` - ivec2 getOutputCoords() { - return ivec2(resultUV.yx * vec2(${texShape[0]}, ${texShape[1]})); - } - `; - } - if (shape[1] === 1) { - if (enableShapeUniforms) { - return ` - ivec2 getOutputCoords() { - ivec2 resTexRC = ivec2(resultUV.yx * - vec2(outTexShape[0], outTexShape[1])); - int index = resTexRC.x * outTexShape[1] + resTexRC.y; - return ivec2(index, 0); - } - `; - } - return ` - ivec2 getOutputCoords() { - ivec2 resTexRC = ivec2(resultUV.yx * - vec2(${texShape[0]}, ${texShape[1]})); - int index = resTexRC.x * ${texShape[1]} + resTexRC.y; - return ivec2(index, 0); - } - `; - } - if (shape[0] === 1) { - if (enableShapeUniforms) { - return ` - ivec2 getOutputCoords() { - ivec2 resTexRC = ivec2(resultUV.yx * - vec2(outTexShape[0], outTexShape[1])); - int index = resTexRC.x * outTexShape[1] + resTexRC.y; - return ivec2(0, index); - } - `; - } - return ` - ivec2 getOutputCoords() { - ivec2 resTexRC = ivec2(resultUV.yx * - vec2(${texShape[0]}, ${texShape[1]})); - int index = resTexRC.x * ${texShape[1]} + resTexRC.y; - return ivec2(0, index); - } - `; - } - if (enableShapeUniforms) { - return ` - ivec2 getOutputCoords() { - ivec2 resTexRC = ivec2(resultUV.yx * - vec2(outTexShape[0], outTexShape[1])); - int index = resTexRC.x * outTexShape[1] + resTexRC.y; - int r = index / outShape[1]; - int c = index - r * outShape[1]; - return ivec2(r, c); - } - `; - } - return ` - ivec2 getOutputCoords() { - ivec2 resTexRC = ivec2(resultUV.yx * - vec2(${texShape[0]}, ${texShape[1]})); - int index = resTexRC.x * ${texShape[1]} + resTexRC.y; - int r = index / ${shape[1]}; - int c = index - r * ${shape[1]}; - return ivec2(r, c); - } - `; -} - -function getFlatOffsetUniformName(texName: string): string { - return `offset${texName}`; -} - -function getPackedSamplerScalar(inputInfo: InputInfo): string { - const texName = inputInfo.name; - const funcName = 'get' + texName.charAt(0).toUpperCase() + texName.slice(1); - const glsl = getGlslDifferences(); - return ` - vec4 ${funcName}() { - return ${glsl.texture2D}(${texName}, halfCR); - } - `; -} - -function getSamplerScalar( - inputInfo: InputInfo, enableShapeUniforms: boolean): string { - const texName = inputInfo.name; - const funcName = 'get' + texName.charAt(0).toUpperCase() + texName.slice(1); - if (inputInfo.shapeInfo.isUniform) { - return `float ${funcName}() {return ${texName};}`; - } - const [texNumR, texNumC] = inputInfo.shapeInfo.texShape; - if (texNumR === 1 && texNumC === 1) { - return ` - float ${funcName}() { - return sampleTexture(${texName}, halfCR); - } - `; - } - - const offset = getFlatOffsetUniformName(texName); - if (enableShapeUniforms) { - return ` - float ${funcName}() { - vec2 uv = uvFromFlat(${texName}TexShape[0], ${texName}TexShape[1], ${ - offset}); - return sampleTexture(${texName}, uv); - } - `; - } - - const [tNumR, tNumC] = inputInfo.shapeInfo.texShape; - return ` - float ${funcName}() { - vec2 uv = uvFromFlat(${tNumR}, ${tNumC}, ${offset}); - return sampleTexture(${texName}, uv); - } - `; -} - -function getPackedSampler1D( - inputInfo: InputInfo, enableShapeUniforms: boolean): string { - const texName = inputInfo.name; - const funcName = 'get' + texName.charAt(0).toUpperCase() + texName.slice(1); - const texShape = inputInfo.shapeInfo.texShape; - const glsl = getGlslDifferences(); - if (enableShapeUniforms) { - return ` - vec4 ${funcName}(int index) { - ivec2 packedTexShape = ivec2(ceil(float(${ - texName}TexShape[0]) / 2.0), ceil(float(${texName}TexShape[1]) / 2.0)); - vec2 uv = packedUVfrom1D( - packedTexShape[0], packedTexShape[1], index); - return ${glsl.texture2D}(${texName}, uv); - } - `; - } - const packedTexShape = - [Math.ceil(texShape[0] / 2), Math.ceil(texShape[1] / 2)]; - return ` - vec4 ${funcName}(int index) { - vec2 uv = packedUVfrom1D( - ${packedTexShape[0]}, ${packedTexShape[1]}, index); - return ${glsl.texture2D}(${texName}, uv); - } - `; -} - -function getSampler1D( - inputInfo: InputInfo, enableShapeUniforms: boolean): string { - const texName = inputInfo.name; - const funcName = 'get' + texName.charAt(0).toUpperCase() + texName.slice(1); - - if (inputInfo.shapeInfo.isUniform) { - // Uniform arrays will be less than 65505 (no risk of float16 overflow). - return ` - float ${funcName}(int index) { - ${getUniformSampler(inputInfo)} - } - `; - } - - const texShape = inputInfo.shapeInfo.texShape; - const tNumR = texShape[0]; - const tNumC = texShape[1]; - - if (tNumC === 1 && tNumR === 1) { - return ` - float ${funcName}(int index) { - return sampleTexture(${texName}, halfCR); - } - `; - } - const offset = getFlatOffsetUniformName(texName); - if (tNumC === 1) { - if (enableShapeUniforms) { - return ` - float ${funcName}(int index) { - vec2 uv = vec2(0.5, (float(index + ${offset}) + 0.5) / float(${ - texName}TexShape[0])); - return sampleTexture(${texName}, uv); - } - `; - } - - return ` - float ${funcName}(int index) { - vec2 uv = vec2(0.5, (float(index + ${offset}) + 0.5) / ${tNumR}.0); - return sampleTexture(${texName}, uv); - } - `; - } - if (tNumR === 1) { - if (enableShapeUniforms) { - return ` - float ${funcName}(int index) { - vec2 uv = vec2((float(index + ${offset}) + 0.5) / float(${ - texName}TexShape[1]), 0.5); - return sampleTexture(${texName}, uv); - } - `; - } - - return ` - float ${funcName}(int index) { - vec2 uv = vec2((float(index + ${offset}) + 0.5) / ${tNumC}.0, 0.5); - return sampleTexture(${texName}, uv); - } - `; - } - - if (enableShapeUniforms) { - return ` - float ${funcName}(int index) { - vec2 uv = uvFromFlat(${texName}TexShape[0], ${ - texName}TexShape[1], index + ${offset}); - return sampleTexture(${texName}, uv); - } - `; - } - - return ` - float ${funcName}(int index) { - vec2 uv = uvFromFlat(${tNumR}, ${tNumC}, index + ${offset}); - return sampleTexture(${texName}, uv); - } - `; -} - -function getPackedSampler2D( - inputInfo: InputInfo, enableShapeUniforms: boolean): string { - const shape = inputInfo.shapeInfo.logicalShape; - const texName = inputInfo.name; - const funcName = 'get' + texName.charAt(0).toUpperCase() + texName.slice(1); - const texShape = inputInfo.shapeInfo.texShape; - - const texNumR = texShape[0]; - const texNumC = texShape[1]; - const glsl = getGlslDifferences(); - if (texShape != null && util.arraysEqual(shape, texShape)) { - if (enableShapeUniforms) { - return ` - vec4 ${funcName}(int row, int col) { - vec2 uv = (vec2(col, row) + halfCR) / vec2(${texName}TexShape[1], ${ - texName}TexShape[0]); - - return ${glsl.texture2D}(${texName}, uv); - } - `; - } - return ` - vec4 ${funcName}(int row, int col) { - vec2 uv = (vec2(col, row) + halfCR) / vec2(${texNumC}.0, ${texNumR}.0); - - return ${glsl.texture2D}(${texName}, uv); - } - `; - } - - if (enableShapeUniforms) { - return ` - vec4 ${funcName}(int row, int col) { - ivec2 packedTexShape = ivec2(ceil(float(${ - texName}TexShape[0]) / 2.0), ceil(float(${texName}TexShape[1]) / 2.0)); - int valuesPerRow = int(ceil(float(${texName}Shape[1]) / 2.0)); - vec2 uv = packedUVfrom2D(valuesPerRow, packedTexShape[0], packedTexShape[1], row, col); - return ${glsl.texture2D}(${texName}, uv); - } - `; - } - const packedTexShape = - [Math.ceil(texShape[0] / 2), Math.ceil(texShape[1] / 2)]; - const valuesPerRow = Math.ceil(shape[1] / 2); - - return ` - vec4 ${funcName}(int row, int col) { - vec2 uv = packedUVfrom2D(${valuesPerRow}, ${packedTexShape[0]}, ${ - packedTexShape[1]}, row, col); - return ${glsl.texture2D}(${texName}, uv); - } - `; -} - -function getSampler2D( - inputInfo: InputInfo, enableShapeUniforms: boolean): string { - const shape = inputInfo.shapeInfo.logicalShape; - const texName = inputInfo.name; - const funcName = 'get' + texName.charAt(0).toUpperCase() + texName.slice(1); - const texShape = inputInfo.shapeInfo.texShape; - - if (texShape != null && util.arraysEqual(shape, texShape)) { - if (enableShapeUniforms) { - return ` - float ${funcName}(int row, int col) { - vec2 uv = (vec2(col, row) + halfCR) / vec2(${texName}TexShape[1], ${ - texName}TexShape[0]); - return sampleTexture(${texName}, uv); - } - `; - } - - const texNumR = texShape[0]; - const texNumC = texShape[1]; - return ` - float ${funcName}(int row, int col) { - vec2 uv = (vec2(col, row) + halfCR) / vec2(${texNumC}.0, ${texNumR}.0); - return sampleTexture(${texName}, uv); - } - `; - } - - const {newShape, keptDims} = util.squeezeShape(shape); - const squeezedShape = newShape; - if (squeezedShape.length < shape.length) { - const newInputInfo = squeezeInputInfo(inputInfo, squeezedShape); - const params = ['row', 'col']; - return ` - ${getSamplerFromInInfo(newInputInfo, enableShapeUniforms)} - float ${funcName}(int row, int col) { - return ${funcName}(${getSqueezedParams(params, keptDims)}); - } - `; - } - - if (inputInfo.shapeInfo.isUniform) { - // Uniform arrays will be less than 65505 (no risk of float16 overflow). - return ` - float ${funcName}(int row, int col) { - int index = round(dot(vec2(row, col), vec2(${shape[1]}, 1))); - ${getUniformSampler(inputInfo)} - } - `; - } - - const texNumR = texShape[0]; - const texNumC = texShape[1]; - const offset = getFlatOffsetUniformName(texName); - if (texNumC === 1) { - // index is used directly as physical (no risk of float16 overflow). - if (enableShapeUniforms) { - return ` - float ${funcName}(int row, int col) { - float index = dot(vec3(row, col, ${offset}), vec3(${ - texName}Shape[1], 1, 1)); - vec2 uv = vec2(0.5, (index + 0.5) / float(${texName}TexShape[0])); - return sampleTexture(${texName}, uv); - } - `; - } - return ` - float ${funcName}(int row, int col) { - float index = dot(vec3(row, col, ${offset}), vec3(${shape[1]}, 1, 1)); - vec2 uv = vec2(0.5, (index + 0.5) / ${texNumR}.0); - return sampleTexture(${texName}, uv); - } - `; - } - if (texNumR === 1) { - // index is used directly as physical (no risk of float16 overflow). - if (enableShapeUniforms) { - return ` - float ${funcName}(int row, int col) { - float index = dot(vec3(row, col, ${offset}), vec3(${ - texName}Shape[1], 1, 1)); - vec2 uv = vec2((index + 0.5) / float(${texName}TexShape[1]), 0.5); - return sampleTexture(${texName}, uv); - } - `; - } - return ` - float ${funcName}(int row, int col) { - float index = dot(vec3(row, col, ${offset}), vec3(${shape[1]}, 1, 1)); - vec2 uv = vec2((index + 0.5) / ${texNumC}.0, 0.5); - return sampleTexture(${texName}, uv); - } - `; - } - - if (enableShapeUniforms) { - return ` - float ${funcName}(int row, int col) { - // Explicitly use integer operations as dot() only works on floats. - int index = row * ${texName}Shape[1] + col + ${offset}; - vec2 uv = uvFromFlat(${texName}TexShape[0], ${ - texName}TexShape[1], index); - return sampleTexture(${texName}, uv); - } - `; - } - return ` - float ${funcName}(int row, int col) { - // Explicitly use integer operations as dot() only works on floats. - int index = row * ${shape[1]} + col + ${offset}; - vec2 uv = uvFromFlat(${texNumR}, ${texNumC}, index); - return sampleTexture(${texName}, uv); - } -`; -} - -function getPackedSampler3D( - inputInfo: InputInfo, enableShapeUniforms: boolean): string { - const shape = inputInfo.shapeInfo.logicalShape; - const texName = inputInfo.name; - const funcName = 'get' + texName.charAt(0).toUpperCase() + texName.slice(1); - const texShape = inputInfo.shapeInfo.texShape; - const packedTexShape = - [Math.ceil(texShape[0] / 2), Math.ceil(texShape[1] / 2)]; - - if (shape[0] === 1) { - const squeezedShape = shape.slice(1); - const keptDims = [1, 2]; - const newInputInfo = squeezeInputInfo(inputInfo, squeezedShape); - const params = ['b', 'row', 'col']; - return ` - ${getPackedSamplerFromInInfo(newInputInfo, enableShapeUniforms)} - vec4 ${funcName}(int b, int row, int col) { - return ${funcName}(${getSqueezedParams(params, keptDims)}); - } - `; - } - - const glsl = getGlslDifferences(); - if (enableShapeUniforms) { - return ` - vec4 ${funcName}(int b, int row, int col) { - ivec2 packedTexShape = ivec2(ceil(float(${ - texName}TexShape[0]) / 2.0), ceil(float(${texName}TexShape[1]) / 2.0)); - int valuesPerRow = int(ceil(float(${texName}Shape[2]) / 2.0)); - int texelsInBatch = valuesPerRow * int(ceil(float(${ - texName}Shape[1]) / 2.0)); - vec2 uv = packedUVfrom3D( - packedTexShape[0], packedTexShape[1], texelsInBatch, valuesPerRow, b, row, col); - return ${glsl.texture2D}(${texName}, uv); - } - `; - } - - const texNumR = packedTexShape[0]; - const texNumC = packedTexShape[1]; - - const valuesPerRow = Math.ceil(shape[2] / 2); - const texelsInBatch = valuesPerRow * Math.ceil(shape[1] / 2); - - return ` - vec4 ${funcName}(int b, int row, int col) { - vec2 uv = packedUVfrom3D( - ${texNumR}, ${texNumC}, ${texelsInBatch}, ${valuesPerRow}, b, row, col); - return ${glsl.texture2D}(${texName}, uv); - } - `; -} - -function getSampler3D( - inputInfo: InputInfo, enableShapeUniforms: boolean): string { - const shape = inputInfo.shapeInfo.logicalShape; - const texName = inputInfo.name; - const funcName = 'get' + texName.charAt(0).toUpperCase() + texName.slice(1); - const stride0 = shape[1] * shape[2]; - const stride1 = shape[2]; - - const {newShape, keptDims} = util.squeezeShape(shape); - const squeezedShape = newShape; - if (squeezedShape.length < shape.length) { - const newInputInfo = squeezeInputInfo(inputInfo, squeezedShape); - const params = ['row', 'col', 'depth']; - return ` - ${getSamplerFromInInfo(newInputInfo, enableShapeUniforms)} - float ${funcName}(int row, int col, int depth) { - return ${funcName}(${getSqueezedParams(params, keptDims)}); - } - `; - } - - if (inputInfo.shapeInfo.isUniform) { - // Uniform arrays will be less than 65505 (no risk of float16 overflow). - return ` - float ${funcName}(int row, int col, int depth) { - int index = round(dot(vec3(row, col, depth), - vec3(${stride0}, ${stride1}, 1))); - ${getUniformSampler(inputInfo)} - } - `; - } - - const texShape = inputInfo.shapeInfo.texShape; - const texNumR = texShape[0]; - const texNumC = texShape[1]; - const flatOffset = inputInfo.shapeInfo.flatOffset; - if (texNumC === stride0 && flatOffset == null) { - // texC is used directly as physical (no risk of float16 overflow). - if (enableShapeUniforms) { - return ` - float ${funcName}(int row, int col, int depth) { - int stride1 = ${texName}Shape[2]; - float texR = float(row); - float texC = dot(vec2(col, depth), vec2(stride1, 1)); - vec2 uv = (vec2(texC, texR) + halfCR) / - vec2(${texName}TexShape[1], ${texName}TexShape[0]); - return sampleTexture(${texName}, uv); - } - `; - } - return ` - float ${funcName}(int row, int col, int depth) { - float texR = float(row); - float texC = dot(vec2(col, depth), vec2(${stride1}, 1)); - vec2 uv = (vec2(texC, texR) + halfCR) / - vec2(${texNumC}.0, ${texNumR}.0); - return sampleTexture(${texName}, uv); - } - `; - } - - if (texNumC === stride1 && flatOffset == null) { - // texR is used directly as physical (no risk of float16 overflow). - if (enableShapeUniforms) { - return ` - float ${funcName}(int row, int col, int depth) { - float texR = dot(vec2(row, col), vec2(${texName}Shape[1], 1)); - float texC = float(depth); - vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${texName}TexShape[1], ${ - texName}TexShape[0]); - return sampleTexture(${texName}, uv); - } - `; - } - return ` - float ${funcName}(int row, int col, int depth) { - float texR = dot(vec2(row, col), vec2(${shape[1]}, 1)); - float texC = float(depth); - vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${texNumC}.0, ${texNumR}.0); - return sampleTexture(${texName}, uv); - } - `; - } - - const offset = getFlatOffsetUniformName(texName); - if (enableShapeUniforms) { - return ` - float ${funcName}(int row, int col, int depth) { - // Explicitly use integer operations as dot() only works on floats. - int stride0 = ${texName}Shape[1] * ${texName}Shape[2]; - int stride1 = ${texName}Shape[2]; - int index = row * stride0 + col * stride1 + depth + ${offset}; - vec2 uv = uvFromFlat(${texName}TexShape[0], ${texName}TexShape[1], index); - return sampleTexture(${texName}, uv); - } - `; - } - return ` - float ${funcName}(int row, int col, int depth) { - // Explicitly use integer operations as dot() only works on floats. - int index = row * ${stride0} + col * ${stride1} + depth + ${offset}; - vec2 uv = uvFromFlat(${texNumR}, ${texNumC}, index); - return sampleTexture(${texName}, uv); - } - `; -} - -function getPackedSamplerND( - inputInfo: InputInfo, enableShapeUniforms: boolean): string { - const texName = inputInfo.name; - const funcName = 'get' + texName.charAt(0).toUpperCase() + texName.slice(1); - const glsl = getGlslDifferences(); - if (enableShapeUniforms) { - // TODO: support 5d and 6d - return ` - vec4 ${funcName}(int b2, int b, int row, int col) { - int valuesPerRow = int(ceil(float(${texName}Shape[3]) / 2.0)); - int texelsInBatch = valuesPerRow * int(ceil(float(${ - texName}Shape[2]) / 2.0)); - int index = b * texelsInBatch + (row / 2) * valuesPerRow + (col / 2); - texelsInBatch *= ${texName}Shape[1]; - index = b2 * texelsInBatch + index; - ivec2 packedTexShape = ivec2(ceil(float(${ - texName}TexShape[0]) / 2.0), ceil(float(${texName}TexShape[1]) / 2.0)); - int texR = index / packedTexShape[1]; - int texC = index - texR * packedTexShape[1]; - vec2 uv = (vec2(texC, texR) + halfCR) / vec2(packedTexShape[1], packedTexShape[0]); return ${ - glsl.texture2D}(${texName}, uv); - } - `; - } - const shape = inputInfo.shapeInfo.logicalShape; - const rank = shape.length; - const texShape = inputInfo.shapeInfo.texShape; - const packedTexShape = - [Math.ceil(texShape[0] / 2), Math.ceil(texShape[1] / 2)]; - const texNumR = packedTexShape[0]; - const texNumC = packedTexShape[1]; - - const valuesPerRow = Math.ceil(shape[rank - 1] / 2); - let texelsInBatch = valuesPerRow * Math.ceil(shape[rank - 2] / 2); - let params = `int b, int row, int col`; - let index = `b * ${texelsInBatch} + (row / 2) * ${valuesPerRow} + (col / 2)`; - for (let b = 2; b < rank - 1; b++) { - params = `int b${b}, ` + params; - texelsInBatch *= shape[rank - b - 1]; - index = `b${b} * ${texelsInBatch} + ` + index; - } - return ` - vec4 ${funcName}(${params}) { - int index = ${index}; - int texR = index / ${texNumC}; - int texC = index - texR * ${texNumC}; - vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${texNumC}, ${texNumR}); - return ${glsl.texture2D}(${texName}, uv); - } - `; -} - -function getSampler4D( - inputInfo: InputInfo, enableShapeUniforms: boolean): string { - const shape = inputInfo.shapeInfo.logicalShape; - const texName = inputInfo.name; - const funcName = 'get' + texName.charAt(0).toUpperCase() + texName.slice(1); - const stride2 = shape[3]; - const stride1 = shape[2] * stride2; - const stride0 = shape[1] * stride1; - - const {newShape, keptDims} = util.squeezeShape(shape); - if (newShape.length < shape.length) { - const newInputInfo = squeezeInputInfo(inputInfo, newShape); - const params = ['row', 'col', 'depth', 'depth2']; - return ` - ${getSamplerFromInInfo(newInputInfo, enableShapeUniforms)} - float ${funcName}(int row, int col, int depth, int depth2) { - return ${funcName}(${getSqueezedParams(params, keptDims)}); - } - `; - } - - if (inputInfo.shapeInfo.isUniform) { - // Uniform arrays will be less than 65505 (no risk of float16 overflow). - return ` - float ${funcName}(int row, int col, int depth, int depth2) { - int index = round(dot(vec4(row, col, depth, depth2), - vec4(${stride0}, ${stride1}, ${stride2}, 1))); - ${getUniformSampler(inputInfo)} - } - `; - } - - const flatOffset = inputInfo.shapeInfo.flatOffset; - const texShape = inputInfo.shapeInfo.texShape; - const texNumR = texShape[0]; - const texNumC = texShape[1]; - - const stride2Str = `int stride2 = ${texName}Shape[3];`; - const stride1Str = `int stride1 = ${texName}Shape[2] * stride2;`; - const stride0Str = `int stride0 = ${texName}Shape[1] * stride1;`; - if (texNumC === stride0 && flatOffset == null) { - // texC is used directly as physical (no risk of float16 overflow). - if (enableShapeUniforms) { - return ` - float ${funcName}(int row, int col, int depth, int depth2) { - ${stride2Str} - ${stride1Str} - float texR = float(row); - float texC = - dot(vec3(col, depth, depth2), - vec3(stride1, stride2, 1)); - vec2 uv = (vec2(texC, texR) + halfCR) / - vec2(${texName}TexShape[1], ${texName}TexShape[0]); - return sampleTexture(${texName}, uv); - } - `; - } - return ` - float ${funcName}(int row, int col, int depth, int depth2) { - float texR = float(row); - float texC = - dot(vec3(col, depth, depth2), - vec3(${stride1}, ${stride2}, 1)); - vec2 uv = (vec2(texC, texR) + halfCR) / - vec2(${texNumC}.0, ${texNumR}.0); - return sampleTexture(${texName}, uv); - } - `; - } - if (texNumC === stride2 && flatOffset == null) { - // texR is used directly as physical (no risk of float16 overflow). - if (enableShapeUniforms) { - return ` - float ${funcName}(int row, int col, int depth, int depth2) { - float texR = dot(vec3(row, col, depth), - vec3(${texName}Shape[1] * ${texName}Shape[2], ${ - texName}Shape[2], 1)); - float texC = float(depth2); - vec2 uv = (vec2(texC, texR) + halfCR) / - vec2(${texName}TexShape[1], ${texName}TexShape[0]); - return sampleTexture(${texName}, uv); - } - `; - } - return ` - float ${funcName}(int row, int col, int depth, int depth2) { - float texR = dot(vec3(row, col, depth), - vec3(${shape[1] * shape[2]}, ${shape[2]}, 1)); - float texC = float(depth2); - vec2 uv = (vec2(texC, texR) + halfCR) / - vec2(${texNumC}.0, ${texNumR}.0); - return sampleTexture(${texName}, uv); - } - `; - } - - const offset = getFlatOffsetUniformName(texName); - if (enableShapeUniforms) { - return ` - float ${funcName}(int row, int col, int depth, int depth2) { - // Explicitly use integer operations as dot() only works on floats. - ${stride2Str} - ${stride1Str} - ${stride0Str} - int index = row * stride0 + col * stride1 + - depth * stride2 + depth2; - vec2 uv = uvFromFlat(${texName}TexShape[0], ${ - texName}TexShape[1], index + ${offset}); - return sampleTexture(${texName}, uv); - } - `; - } - return ` - float ${funcName}(int row, int col, int depth, int depth2) { - // Explicitly use integer operations as dot() only works on floats. - int index = row * ${stride0} + col * ${stride1} + - depth * ${stride2} + depth2; - vec2 uv = uvFromFlat(${texNumR}, ${texNumC}, index + ${offset}); - return sampleTexture(${texName}, uv); - } - `; -} - -function getSampler5D(inputInfo: InputInfo): string { - const shape = inputInfo.shapeInfo.logicalShape; - const texName = inputInfo.name; - const funcName = 'get' + texName.charAt(0).toUpperCase() + texName.slice(1); - const stride3 = shape[4]; - const stride2 = shape[3] * stride3; - const stride1 = shape[2] * stride2; - const stride0 = shape[1] * stride1; - - const {newShape, keptDims} = util.squeezeShape(shape); - if (newShape.length < shape.length) { - const newInputInfo = squeezeInputInfo(inputInfo, newShape); - const params = ['row', 'col', 'depth', 'depth2', 'depth3']; - return ` - ${getSamplerFromInInfo(newInputInfo)} - float ${funcName}(int row, int col, int depth, int depth2, int depth3) { - return ${funcName}(${getSqueezedParams(params, keptDims)}); - } - `; - } - - if (inputInfo.shapeInfo.isUniform) { - // Uniform arrays will be less than 65505 (no risk of float16 overflow). - return ` - float ${funcName}(int row, int col, int depth, int depth2, int depth3) { - float index = dot( - vec4(row, col, depth, depth2), - vec4(${stride0}, ${stride1}, ${stride2}, ${stride3})) + - depth3; - ${getUniformSampler(inputInfo)} - } - `; - } - - const flatOffset = inputInfo.shapeInfo.flatOffset; - const texShape = inputInfo.shapeInfo.texShape; - const texNumR = texShape[0]; - const texNumC = texShape[1]; - - if (texNumC === stride0 && flatOffset == null) { - // texC is used directly as physical (no risk of float16 overflow). - return ` - float ${funcName}(int row, int col, int depth, int depth2, int depth3) { - int texR = row; - float texC = dot(vec4(col, depth, depth2, depth3), - vec4(${stride1}, ${stride2}, ${stride3}, 1)); - vec2 uv = (vec2(texC, texR) + halfCR) / - vec2(${texNumC}.0, ${texNumR}.0); - return sampleTexture(${texName}, uv); - } - `; - } - - if (texNumC === stride3 && flatOffset == null) { - // texR is used directly as physical (no risk of float16 overflow). - return ` - float ${funcName}(int row, int col, int depth, int depth2, int depth3) { - float texR = dot( - vec4(row, col, depth, depth2), - vec4(${shape[1] * shape[2] * shape[3]}, - ${shape[2] * shape[3]}, ${shape[3]}, 1)); - int texC = depth3; - vec2 uv = (vec2(texC, texR) + halfCR) / - vec2(${texNumC}.0, ${texNumR}.0); - return sampleTexture(${texName}, uv); - } - `; - } - - const offset = getFlatOffsetUniformName(texName); - return ` - float ${funcName}(int row, int col, int depth, int depth2, int depth3) { - // Explicitly use integer operations as dot() only works on floats. - int index = row * ${stride0} + col * ${stride1} + depth * ${stride2} + - depth2 * ${stride3} + depth3 + ${offset}; - vec2 uv = uvFromFlat(${texNumR}, ${texNumC}, index); - return sampleTexture(${texName}, uv); - } - `; -} - -function getSampler6D(inputInfo: InputInfo): string { - const shape = inputInfo.shapeInfo.logicalShape; - const texName = inputInfo.name; - const funcName = 'get' + texName.charAt(0).toUpperCase() + texName.slice(1); - - const {newShape, keptDims} = util.squeezeShape(shape); - if (newShape.length < shape.length) { - const newInputInfo = squeezeInputInfo(inputInfo, newShape); - const params = ['row', 'col', 'depth', 'depth2', 'depth3', 'depth4']; - return ` - ${getSamplerFromInInfo(newInputInfo)} - float ${funcName}(int row, int col, int depth, - int depth2, int depth3, int depth4) { - return ${funcName}(${getSqueezedParams(params, keptDims)}); - } - `; - } - - const stride4 = shape[5]; - const stride3 = shape[4] * stride4; - const stride2 = shape[3] * stride3; - const stride1 = shape[2] * stride2; - const stride0 = shape[1] * stride1; - - if (inputInfo.shapeInfo.isUniform) { - // Uniform arrays will be less than 65505 (no risk of float16 overflow). - return ` - float ${funcName}(int row, int col, int depth, - int depth2, int depth3, int depth4) { - int index = round(dot( - vec4(row, col, depth, depth2), - vec4(${stride0}, ${stride1}, ${stride2}, ${stride3})) + - dot( - vec2(depth3, depth4), - vec2(${stride4}, 1))); - ${getUniformSampler(inputInfo)} - } - `; - } - - const flatOffset = inputInfo.shapeInfo.flatOffset; - const texShape = inputInfo.shapeInfo.texShape; - const texNumR = texShape[0]; - const texNumC = texShape[1]; - if (texNumC === stride0 && flatOffset == null) { - // texC is used directly as physical (no risk of float16 overflow). - return ` - float ${funcName}(int row, int col, int depth, - int depth2, int depth3, int depth4) { - int texR = row; - float texC = dot(vec4(col, depth, depth2, depth3), - vec4(${stride1}, ${stride2}, ${stride3}, ${stride4})) + - float(depth4); - vec2 uv = (vec2(texC, texR) + halfCR) / - vec2(${texNumC}.0, ${texNumR}.0); - return sampleTexture(${texName}, uv); - } - `; - } - if (texNumC === stride4 && flatOffset == null) { - // texR is used directly as physical (no risk of float16 overflow). - return ` - float ${funcName}(int row, int col, int depth, - int depth2, int depth3, int depth4) { - float texR = dot(vec4(row, col, depth, depth2), - vec4(${shape[1] * shape[2] * shape[3] * shape[4]}, - ${shape[2] * shape[3] * shape[4]}, - ${shape[3] * shape[4]}, - ${shape[4]})) + float(depth3); - int texC = depth4; - vec2 uv = (vec2(texC, texR) + halfCR) / - vec2(${texNumC}.0, ${texNumR}.0); - return sampleTexture(${texName}, uv); - } - `; - } - const offset = getFlatOffsetUniformName(texName); - return ` - float ${funcName}(int row, int col, int depth, - int depth2, int depth3, int depth4) { - // Explicitly use integer operations as dot() only works on floats. - int index = row * ${stride0} + col * ${stride1} + depth * ${stride2} + - depth2 * ${stride3} + depth3 * ${stride4} + depth4 + ${offset}; - vec2 uv = uvFromFlat(${texNumR}, ${texNumC}, index); - return sampleTexture(${texName}, uv); - } - `; -} - -function getUniformSampler(inputInfo: InputInfo): string { - const texName = inputInfo.name; - const inSize = util.sizeFromShape(inputInfo.shapeInfo.logicalShape); - - if (inSize < 2) { - return `return ${texName};`; - } - - return ` - for (int i = 0; i < ${inSize}; i++) { - if (i == index) { - return ${texName}[i]; - } - } - `; -} - -function getPackedSamplerAtOutputCoords( - inputInfo: InputInfo, outShapeInfo: ShapeInfo) { - const texName = inputInfo.name; - const texFuncSnippet = texName.charAt(0).toUpperCase() + texName.slice(1); - const funcName = 'get' + texFuncSnippet + 'AtOutCoords'; - const inRank = inputInfo.shapeInfo.logicalShape.length; - const outRank = outShapeInfo.logicalShape.length; - - const broadcastDims = getBroadcastDims( - inputInfo.shapeInfo.logicalShape, outShapeInfo.logicalShape); - - const type = getCoordsDataType(outRank); - const rankDiff = outRank - inRank; - let coordsSnippet: string; - const fields = ['x', 'y', 'z', 'w', 'u', 'v']; - - if (inRank === 0) { - coordsSnippet = ''; - } else if (outRank < 2 && broadcastDims.length >= 1) { - coordsSnippet = 'coords = 0;'; - } else { - coordsSnippet = - broadcastDims.map(d => `coords.${fields[d + rankDiff]} = 0;`) - .join('\n'); - } - let unpackedCoordsSnippet = ''; - if (outRank < 2 && inRank > 0) { - unpackedCoordsSnippet = 'coords'; - } else { - unpackedCoordsSnippet = inputInfo.shapeInfo.logicalShape - .map((s, i) => `coords.${fields[i + rankDiff]}`) - .join(', '); - } - - let output = `return outputValue;`; - const inSize = util.sizeFromShape(inputInfo.shapeInfo.logicalShape); - const isInputScalar = inSize === 1; - const outSize = util.sizeFromShape(outShapeInfo.logicalShape); - const isOutputScalar = outSize === 1; - - if (inRank === 1 && !isInputScalar && !isOutputScalar) { - output = ` - return vec4(outputValue.xy, outputValue.xy); - `; - } else if (isInputScalar && !isOutputScalar) { - if (outRank === 1) { - output = ` - return vec4(outputValue.x, outputValue.x, 0., 0.); - `; - } else { - output = ` - return vec4(outputValue.x); - `; - } - } else if (broadcastDims.length) { - const rows = inRank - 2; - const cols = inRank - 1; - - if (broadcastDims.indexOf(rows) > -1 && broadcastDims.indexOf(cols) > -1) { - output = `return vec4(outputValue.x);`; - } else if (broadcastDims.indexOf(rows) > -1) { - output = `return vec4(outputValue.x, outputValue.y, ` + - `outputValue.x, outputValue.y);`; - } else if (broadcastDims.indexOf(cols) > -1) { - output = `return vec4(outputValue.xx, outputValue.zz);`; - } - } - - return ` - vec4 ${funcName}() { - ${type} coords = getOutputCoords(); - ${coordsSnippet} - vec4 outputValue = get${texFuncSnippet}(${unpackedCoordsSnippet}); - ${output} - } - `; -} - -function getSamplerAtOutputCoords( - inputInfo: InputInfo, outShapeInfo: ShapeInfo) { - const texName = inputInfo.name; - const texFuncSnippet = texName.charAt(0).toUpperCase() + texName.slice(1); - const funcName = 'get' + texFuncSnippet + 'AtOutCoords'; - const outTexShape = outShapeInfo.texShape; - const inTexShape = inputInfo.shapeInfo.texShape; - const inRank = inputInfo.shapeInfo.logicalShape.length; - const outRank = outShapeInfo.logicalShape.length; - - if (!inputInfo.shapeInfo.isUniform && inRank === outRank && - inputInfo.shapeInfo.flatOffset == null && - util.arraysEqual(inTexShape, outTexShape)) { - return ` - float ${funcName}() { - return sampleTexture(${texName}, resultUV); - } - `; - } - - const type = getCoordsDataType(outRank); - const broadcastDims = getBroadcastDims( - inputInfo.shapeInfo.logicalShape, outShapeInfo.logicalShape); - const rankDiff = outRank - inRank; - let coordsSnippet: string; - const fields = ['x', 'y', 'z', 'w', 'u', 'v']; - - if (inRank === 0) { - coordsSnippet = ''; - } else if (outRank < 2 && broadcastDims.length >= 1) { - coordsSnippet = 'coords = 0;'; - } else { - coordsSnippet = - broadcastDims.map(d => `coords.${fields[d + rankDiff]} = 0;`) - .join('\n'); - } - let unpackedCoordsSnippet = ''; - if (outRank < 2 && inRank > 0) { - unpackedCoordsSnippet = 'coords'; - } else { - unpackedCoordsSnippet = inputInfo.shapeInfo.logicalShape - .map((s, i) => `coords.${fields[i + rankDiff]}`) - .join(', '); - } - - return ` - float ${funcName}() { - ${type} coords = getOutputCoords(); - ${coordsSnippet} - return get${texFuncSnippet}(${unpackedCoordsSnippet}); - } - `; -} - -export function getCoordsDataType(rank: number): string { - if (rank <= 1) { - return 'int'; - } else if (rank === 2) { - return 'ivec2'; - } else if (rank === 3) { - return 'ivec3'; - } else if (rank === 4) { - return 'ivec4'; - } else if (rank === 5) { - return 'ivec5'; - } else if (rank === 6) { - return 'ivec6'; - } else { - throw Error(`GPU for rank ${rank} is not yet supported`); - } -} - -export function getUniformInfoFromShape( - isPacked: boolean, shape: number[], texShape: number[]) { - const {newShape, keptDims} = util.squeezeShape(shape); - const rank = shape.length; - const useSqueezePackedShape = isPacked && rank === 3 && shape[0] === 1; - const squeezeShape = useSqueezePackedShape ? shape.slice(1) : newShape; - const useSqueezeShape = - (!isPacked && rank > 1 && !util.arraysEqual(shape, texShape) && - newShape.length < rank) || - useSqueezePackedShape; - const uniformShape = useSqueezeShape ? squeezeShape : shape; - return {useSqueezeShape, uniformShape, keptDims}; -} - -/** Returns a new input info (a copy) that has a squeezed logical shape. */ -export function squeezeInputInfo( - inInfo: InputInfo, squeezedShape: number[]): InputInfo { - // Deep copy. - const newInputInfo: InputInfo = JSON.parse(JSON.stringify(inInfo)); - newInputInfo.shapeInfo.logicalShape = squeezedShape; - return newInputInfo; -} - -function getSqueezedParams(params: string[], keptDims: number[]): string { - return keptDims.map(d => params[d]).join(', '); -} diff --git a/tfjs-master/tfjs-backend-webgl/src/shader_compiler_util.ts b/tfjs-master/tfjs-backend-webgl/src/shader_compiler_util.ts deleted file mode 100644 index 7e744c73a..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/shader_compiler_util.ts +++ /dev/null @@ -1,184 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {util} from '@tensorflow/tfjs-core'; - -/** - * Produces GLSL code that derives logical coordinates from a flat - * index. The code performs integer division with each stride and decrements - * the index until the index equals the final dimension coordinate. - */ -export function getLogicalCoordinatesFromFlatIndex( - coords: string[], shape: number[], index = 'index'): string { - const strides = util.computeStrides(shape); - return strides - .map((stride, i) => { - const line1 = `int ${coords[i]} = ${index} / ${stride}`; - const line2 = i === strides.length - 1 ? - `int ${coords[i + 1]} = ${index} - ${coords[i]} * ${stride}` : - `index -= ${coords[i]} * ${stride}`; - return `${line1}; ${line2};`; - }) - .join(''); -} - -export function getOutputLogicalCoordinatesFromFlatIndexByUniform( - coords: string[], shape: number[], index = 'index'): string { - const strides = util.computeStrides(shape); - return strides - .map((_, i) => { - const line1 = `int ${coords[i]} = ${index} / outShapeStrides[${i}]`; - const line2 = i === strides.length - 1 ? - `int ${coords[i + 1]} = ${index} - ${coords[i]} * outShapeStrides[${ - i}]` : - `index -= ${coords[i]} * outShapeStrides[${i}]`; - return `${line1}; ${line2};`; - }) - .join(''); -} - -// Produces GLSL code that computes strides. -function symbolicallyComputeStrides( - indicesArr: number[], variableName: string): string[] { - const numCoords = indicesArr.length; - const shape = indicesArr.map(d => `${variableName}[${d}]`); - const strides = new Array(numCoords - 1); - strides[numCoords - 2] = shape[numCoords - 1]; - for (let i = numCoords - 3; i >= 0; --i) { - strides[i] = `(${strides[i + 1]} * ${shape[i + 1]})`; - } - - return strides; -} - -export function getLogicalCoordinatesFromFlatIndexByUniform( - coords: string[], variableName: string, index = 'index'): string { - const indicesArray = coords.map((_, i) => i); - const strides = symbolicallyComputeStrides(indicesArray, variableName); - return strides - .map((_, i) => { - const line1 = `int ${coords[i]} = ${index} / ${strides[i]}`; - const line2 = i === strides.length - 1 ? - `int ${coords[i + 1]} = ${index} - ${coords[i]} * ${strides[i]}` : - `index -= ${coords[i]} * ${strides[i]}`; - return `${line1}; ${line2};`; - }) - .join(''); -} - -function buildVec(x: string[]): string { - if (x.length === 1) { - return `${x[0]}`; - } - return `vec${x.length}(${x.join(',')})`; -} - -/** - * Produces GLSL code that computes the dot product of the input x and y - * vectors. Handles splitting inputs into increments of vec4s when necessary. - */ -export function dotify(x: string[], y: string[]): string { - if (x.length !== y.length) { - throw new Error( - `Vectors to be dotted must be of the same length -` + - `got ${x.length} and ${y.length}`); - } - - const slices: string[] = []; - const nearestVec4 = Math.floor(x.length / 4); - const nearestVec4Remainder = x.length % 4; - - for (let i = 0; i < nearestVec4; i++) { - const xSlice = x.slice(i * 4, i * 4 + 4); - const ySlice = y.slice(i * 4, i * 4 + 4); - slices.push(`${buildVec(xSlice)}, ${buildVec(ySlice)}`); - } - - if (nearestVec4Remainder !== 0) { - let xSlice = x.slice(nearestVec4 * 4); - let ySlice = y.slice(nearestVec4 * 4); - if (xSlice.length === 1) { - xSlice = xSlice.map(d => `float(${d})`); - ySlice = ySlice.map(d => `float(${d})`); - } - slices.push(`${buildVec(xSlice)}, ${buildVec(ySlice)}`); - } - - return slices.map((d, i) => `dot(${d})`).join('+'); -} - -/** - * Produces GLSL that computes the flat index from 3D coordinates. - */ -export function getFlatIndexFrom3D(shape: [number, number, number]): string { - const strides = util.computeStrides(shape).map(d => d.toString()); - - return ` - int getFlatIndex(ivec3 coords) { - return coords.x * ${strides[0]} + coords.y * ${strides[1]} + coords.z; - } -`; -} - -export function getFlatIndexFrom3DOutput(): string { - return ` - int getFlatIndex(ivec3 coords) { - return coords.x * outShapeStrides[0] + coords.y * outShapeStrides[1] + coords.z; - } -`; -} - -export const ENCODE_FLOAT_SNIPPET = ` - const float FLOAT_MAX = 1.70141184e38; - const float FLOAT_MIN = 1.17549435e-38; - - lowp vec4 encode_float(highp float v) { - if (isnan(v)) { - return vec4(255, 255, 255, 255); - } - - highp float av = abs(v); - - if(av < FLOAT_MIN) { - return vec4(0.0, 0.0, 0.0, 0.0); - } else if(v > FLOAT_MAX) { - return vec4(0.0, 0.0, 128.0, 127.0) / 255.0; - } else if(v < -FLOAT_MAX) { - return vec4(0.0, 0.0, 128.0, 255.0) / 255.0; - } - - highp vec4 c = vec4(0,0,0,0); - - highp float e = floor(log2(av)); - highp float m = exp2(fract(log2(av))) - 1.0; - - c[2] = floor(128.0 * m); - m -= c[2] / 128.0; - c[1] = floor(32768.0 * m); - m -= c[1] / 32768.0; - c[0] = floor(8388608.0 * m); - - highp float ebias = e + 127.0; - c[3] = floor(ebias / 2.0); - ebias -= c[3] * 2.0; - c[2] += floor(ebias) * 128.0; - - c[3] += 128.0 * step(0.0, -v); - - return c / 255.0; - } -`; diff --git a/tfjs-master/tfjs-backend-webgl/src/shader_compiler_util_test.ts b/tfjs-master/tfjs-backend-webgl/src/shader_compiler_util_test.ts deleted file mode 100644 index 8613b5512..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/shader_compiler_util_test.ts +++ /dev/null @@ -1,54 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// tslint:disable-next-line: no-imports-from-dist -import {describeWithFlags} from '@tensorflow/tfjs-core/dist/jasmine_util'; -import {WEBGL_ENVS} from './backend_webgl_test_registry'; -import {dotify, getLogicalCoordinatesFromFlatIndex} from './shader_compiler_util'; - -describeWithFlags('shader compiler', WEBGL_ENVS, () => { - it('dotify takes two arrays of coordinates and produces' + - 'the glsl that finds the dot product of those coordinates', - () => { - const coords1 = ['r', 'g', 'b', 'a']; - const coords2 = ['x', 'y', 'z', 'w']; - - expect(dotify(coords1, coords2)) - .toEqual('dot(vec4(r,g,b,a), vec4(x,y,z,w))'); - }); - - it('dotify should split up arrays into increments of vec4s', () => { - const coords1 = ['a', 'b', 'c', 'd', 'e', 'f', 'g']; - const coords2 = ['h', 'i', 'j', 'k', 'l', 'm', 'n']; - - expect(dotify(coords1, coords2)) - .toEqual( - 'dot(vec4(a,b,c,d), vec4(h,i,j,k))+dot(vec3(e,f,g), vec3(l,m,n))'); - }); - - it('getLogicalCoordinatesFromFlatIndex produces glsl that takes' + - 'a flat index and finds its coordinates within that shape', - () => { - const coords = ['r', 'c', 'd']; - const shape = [1, 2, 3]; - - expect(getLogicalCoordinatesFromFlatIndex(coords, shape)) - .toEqual( - 'int r = index / 6; index -= r * 6;' + - 'int c = index / 3; int d = index - c * 3;'); - }); -}); diff --git a/tfjs-master/tfjs-backend-webgl/src/slice_gpu.ts b/tfjs-master/tfjs-backend-webgl/src/slice_gpu.ts deleted file mode 100644 index a55d06e2f..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/slice_gpu.ts +++ /dev/null @@ -1,64 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {GPGPUProgram} from './gpgpu_math'; -import {getCoordsDataType, UniformType} from './shader_compiler'; - -export class SliceProgram implements GPGPUProgram { - variableNames = ['source']; - outputShape: number[]; - userCode: string; - rank: number; - customUniforms: Array<{name: string; arrayIndex: number; type: UniformType;}>; - - constructor(destSize: number[]) { - this.outputShape = destSize; - this.rank = destSize.length; - - const dtype = getCoordsDataType(this.rank); - this.customUniforms = [{name: 'start', arrayIndex: this.rank, type: 'int'}]; - const sourceCoords = getCoords(this.rank); - - let body: string; - const coordSum = destSize.map((_, i) => { - return `sourceLoc.${coords[i]} = start[${i}] + coords.${coords[i]};`; - }); - body = ` - ${dtype} sourceLoc; - ${dtype} coords = getOutputCoords(); - ${coordSum.join('\n')} - `; - this.userCode = ` - void main() { - ${body} - setOutput(getSource(${sourceCoords})); - } - `; - } -} - -const coords = ['x', 'y', 'z', 'w', 'u', 'v']; - -function getCoords(rank: number): string { - if (rank === 1) { - return 'sourceLoc'; - } else if (rank <= 6) { - return coords.slice(0, rank).map(x => 'sourceLoc.' + x).join(','); - } else { - throw Error(`Slicing for rank ${rank} is not yet supported`); - } -} diff --git a/tfjs-master/tfjs-backend-webgl/src/slice_packed_gpu.ts b/tfjs-master/tfjs-backend-webgl/src/slice_packed_gpu.ts deleted file mode 100644 index de0203980..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/slice_packed_gpu.ts +++ /dev/null @@ -1,80 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {GPGPUProgram} from './gpgpu_math'; -import {getChannels} from './packing_util'; -import {getCoordsDataType, UniformType} from './shader_compiler'; - -export class SlicePackedProgram implements GPGPUProgram { - variableNames = ['source']; - packedInputs = true; - packedOutput = true; - outputShape: number[]; - userCode: string; - rank: number; - customUniforms: Array<{name: string; arrayIndex: number; type: UniformType;}>; - - constructor(destSize: number[]) { - this.outputShape = destSize; - this.rank = destSize.length; - this.customUniforms = [{name: 'start', arrayIndex: this.rank, type: 'int'}]; - const dtype = getCoordsDataType(this.rank); - const coords = getChannels('coords', this.rank); - const sourceLoc = getChannels('sourceLoc', this.rank); - - const innerDims = - this.rank === 1 ? 'sourceLoc' : `vec2(${sourceLoc.slice(-2).join()})`; - const getChannel = - `getChannel(getSource(${sourceLoc.join()}), ${innerDims})`; - const upperRow = ` - result.x = ${getChannel}; - if (++${coords[this.rank - 1]} < ${destSize[this.rank - 1]}) { - ++${sourceLoc[this.rank - 1]}; - result.y = ${getChannel}; - --${sourceLoc[this.rank - 1]}; - } - `; - const lowerRow = this.rank === 1 ? '' : ` - --${coords[this.rank - 1]}; - if (++${coords[this.rank - 2]} < ${destSize[this.rank - 2]}) { - ++${sourceLoc[this.rank - 2]}; - result.z = ${getChannel}; - if (++${coords[this.rank - 1]} < ${destSize[this.rank - 1]}) { - ++${sourceLoc[this.rank - 1]}; - result.w = ${getChannel}; - } - } - `; - - const sourceLocSetup = this.rank <= 4 ? - `sourceLoc = coords + - ${dtype}(${destSize.map((_, i) => `start[${i}]`).join()});` : - destSize.map((_, i) => `${sourceLoc[i]} = ${coords[i]} + start[${i}];`) - .join('\n'); - this.userCode = ` - void main() { - ${dtype} coords = getOutputCoords(); - ${dtype} sourceLoc; - ${sourceLocSetup} - vec4 result = vec4(0.); - ${upperRow} - ${lowerRow} - setOutput(result); - } - `; - } -} diff --git a/tfjs-master/tfjs-backend-webgl/src/strided_slice_gpu.ts b/tfjs-master/tfjs-backend-webgl/src/strided_slice_gpu.ts deleted file mode 100644 index fd90b4340..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/strided_slice_gpu.ts +++ /dev/null @@ -1,57 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {GPGPUProgram} from './gpgpu_math'; -import {getCoordsDataType} from './shader_compiler'; - -export class StridedSliceProgram implements GPGPUProgram { - variableNames = ['x']; - outputShape: number[]; - userCode: string; - - constructor(begin: number[], strides: number[], size: number[]) { - this.outputShape = size; - const rank = size.length; - const inputDtype = getCoordsDataType(size.length); - const dtype = getCoordsDataType(size.length); - - let newCoords = ''; - if (rank === 1) { - newCoords = 'coords * strides + begin'; - } else { - let outputAxis = 0; - newCoords = - size.map((_, i) => { - outputAxis++; - return size.length === 1 ? - `coords * strides[${i}] + begin[${i}]` : - `coords[${outputAxis - 1}] * strides[${i}] + begin[${i}]`; - }) - .join(','); - } - - this.userCode = ` - ${inputDtype} begin = ${inputDtype}(${begin}); - ${inputDtype} strides = ${inputDtype}(${strides}); - - void main() { - ${dtype} coords = getOutputCoords(); - setOutput(getX(${newCoords})); - } - `; - } -} diff --git a/tfjs-master/tfjs-backend-webgl/src/tex_util.ts b/tfjs-master/tfjs-backend-webgl/src/tex_util.ts deleted file mode 100644 index 3c04ddc3b..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/tex_util.ts +++ /dev/null @@ -1,240 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, DataId, DataType, env, TensorInfo, util} from '@tensorflow/tfjs-core'; - -export enum PackingScheme { - /** - * All values in a single texel are densely packed without any constraints. - * - * This is how the shader encodes a tensor with shape = [2, 3, 4] - * (indices are [batch, row, col]). - * - * 000|001 010|011 020|021 - * ------- ------- ------- - * 002|003 012|013 022|023 - * - * 100|101 110|111 120|121 - * ------- ------- ------- - * 102|103 112|113 122|123 - * - */ - DENSE, - - /** - * Single texels contain only values from the same batch, and from adjacent - * rows and columns. - * - * This is how the shader encodes a tensor with shape = [2, 3, 5] - * (indices are [batch, row, col]). - * - * 000|001 002|003 004|xxx 020|021 022|023 024|xxx - * ------- ------- ------- ------- ------- ------- - * 010|011 012|013 014|xxx xxx|xxx xxx|xxx xxx|xxx - * - * 100|101 102|103 104|xxx 120|121 122|123 124|xxx - * ------- ------- ------- ------- ------- ------- - * 110|111 112|113 114|xxx xxx|xxx xxx|xxx xxx|xxx - * - */ - SHARED_BATCH -} - -export enum TextureUsage { - RENDER, - UPLOAD, - PIXELS, - DOWNLOAD -} - -export enum PhysicalTextureType { - UNPACKED_FLOAT16, - UNPACKED_FLOAT32, - PACKED_4X1_UNSIGNED_BYTE, - PACKED_2X2_FLOAT32, - PACKED_2X2_FLOAT16 -} - -export interface Texture { - texture: WebGLTexture; - texShape: [number, number]; -} -export interface TextureData { - // Required. - shape: number[]; - dtype: DataType; - - // Optional. - values?: backend_util.BackendValues; - texture?: Texture; - // For complex numbers, the real and imaginary parts are stored as their own - // individual tensorInfos, with a parent joining the two with the - // complexTensors field. When this is defined, texture will be null. - complexTensorInfos?: {real: TensorInfo, imag: TensorInfo}; - /** [rows, columns] shape of the texture. */ - texShape?: [number, number]; - usage?: TextureUsage; - isPacked?: boolean; - - refCount: number; - - // Available when the tensor has been sliced. - slice?: { - // Offset in the 'flat index' space. - flatOffset: number; - // Used for counting how many sliced tensors point to the same texture. - origDataId: DataId; - }; -} - -export function getUnpackedMatrixTextureShapeWidthHeight( - rows: number, columns: number): [number, number] { - return [columns, rows]; -} - -export function getUnpackedArraySizeFromMatrixSize( - matrixSize: number, channelsPerTexture: number): number { - return matrixSize * channelsPerTexture; -} - -export function getColorMatrixTextureShapeWidthHeight( - rows: number, columns: number): [number, number] { - return [columns * 4, rows]; -} - -/** - * Get shape for densely packed RGBA texture. - */ -export function getDenseTexShape(shape: number[]): [number, number] { - const size = util.sizeFromShape(shape); - const texelsNeeded = Math.ceil(size / 4); - return util.sizeToSquarishShape(texelsNeeded); -} - -export function getMatrixSizeFromUnpackedArraySize( - unpackedSize: number, channelsPerTexture: number): number { - if (unpackedSize % channelsPerTexture !== 0) { - throw new Error( - `unpackedSize (${unpackedSize}) must be a multiple of ` + - `${channelsPerTexture}`); - } - return unpackedSize / channelsPerTexture; -} - -export function decodeMatrixFromUnpackedColorRGBAArray( - unpackedArray: Float32Array, matrix: Float32Array, channels: number) { - const requiredSize = unpackedArray.length * channels / 4; - if (matrix.length < requiredSize) { - throw new Error( - `matrix length (${matrix.length}) must be >= ${requiredSize}`); - } - let dst = 0; - for (let src = 0; src < unpackedArray.length; src += 4) { - for (let c = 0; c < channels; c++) { - matrix[dst++] = unpackedArray[src + c]; - } - } -} - -export function getPackedMatrixTextureShapeWidthHeight( - rows: number, columns: number): [number, number] { - return [ - Math.max(1, Math.ceil(columns / 2)), Math.max(1, Math.ceil(rows / 2)) - ]; -} - -export function getPackedRGBAArraySizeFromMatrixShape( - rows: number, columns: number): number { - const [w, h] = getPackedMatrixTextureShapeWidthHeight(rows, columns); - return w * h * 4; -} - -export interface TextureConfig { - internalFormatFloat: number; - textureFormatFloat: number; - internalFormatPackedHalfFloat: number; - internalFormatHalfFloat: number; - internalFormatPackedFloat: number; - - // The format to use during a gl.readPixels call. - downloadTextureFormat: number; - // How many channels need to be unpacked after a gl.readPixels call. - downloadUnpackNumChannels: number; - - defaultNumChannels: number; - textureTypeHalfFloat: number; - textureTypeFloat: number; -} - -export function getTextureConfig( - // tslint:disable-next-line:no-any - gl: WebGLRenderingContext, textureHalfFloatExtension?: any): TextureConfig { - // tslint:disable-next-line:no-any - const glany = gl as any; - - let internalFormatFloat: number; - let internalFormatHalfFloat: number; - let internalFormatPackedHalfFloat: number; - let internalFormatPackedFloat: number; - let textureFormatFloat: number; - - let downloadTextureFormat: number; - let downloadUnpackNumChannels: number; - - let defaultNumChannels: number; - let textureTypeHalfFloat: number; - let textureTypeFloat: number; - - if (env().getNumber('WEBGL_VERSION') === 2) { - internalFormatFloat = glany.R32F; - internalFormatHalfFloat = glany.R16F; - internalFormatPackedHalfFloat = glany.RGBA16F; - internalFormatPackedFloat = glany.RGBA32F; - textureFormatFloat = glany.RED; - downloadUnpackNumChannels = 4; - defaultNumChannels = 1; - textureTypeHalfFloat = glany.HALF_FLOAT; - textureTypeFloat = glany.FLOAT; - downloadTextureFormat = glany.RGBA8; - } else { - internalFormatFloat = gl.RGBA; - internalFormatHalfFloat = gl.RGBA; - internalFormatPackedHalfFloat = gl.RGBA; - internalFormatPackedFloat = glany.RGBA; - textureFormatFloat = gl.RGBA; - downloadUnpackNumChannels = 4; - defaultNumChannels = 4; - textureTypeHalfFloat = textureHalfFloatExtension != null ? - textureHalfFloatExtension.HALF_FLOAT_OES : - null; - textureTypeFloat = gl.FLOAT; - downloadTextureFormat = gl.RGBA; - } - - return { - internalFormatFloat, - internalFormatHalfFloat, - internalFormatPackedHalfFloat, - internalFormatPackedFloat, - textureFormatFloat, - downloadTextureFormat, - downloadUnpackNumChannels, - defaultNumChannels, - textureTypeHalfFloat, - textureTypeFloat - }; -} diff --git a/tfjs-master/tfjs-backend-webgl/src/tex_util_test.ts b/tfjs-master/tfjs-backend-webgl/src/tex_util_test.ts deleted file mode 100644 index 867466552..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/tex_util_test.ts +++ /dev/null @@ -1,100 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// tslint:disable-next-line: no-imports-from-dist -import {test_util} from '@tensorflow/tfjs-core'; -// tslint:disable-next-line: no-imports-from-dist -import {describeWithFlags} from '@tensorflow/tfjs-core/dist/jasmine_util'; - -const {expectArraysClose} = test_util; -import {WEBGL_ENVS} from './backend_webgl_test_registry'; -import * as tex_util from './tex_util'; - -describe('tex_util getUnpackedMatrixTextureShapeWidthHeight', () => { - it('[1x1] => [1x1]', () => { - expect(tex_util.getUnpackedMatrixTextureShapeWidthHeight(1, 1)).toEqual([ - 1, 1 - ]); - }); - - it('[MxN] => [NxM]', () => { - expect(tex_util.getUnpackedMatrixTextureShapeWidthHeight(123, 456)) - .toEqual([456, 123]); - }); -}); - -describe('tex_util getPackedMatrixTextureShapeWidthHeight', () => { - it('[1x1] => [1x1]', () => { - const shape = tex_util.getPackedMatrixTextureShapeWidthHeight(1, 1); - expect(shape).toEqual([1, 1]); - }); - - it('[1x2] => [1x1]', () => { - const shape = tex_util.getPackedMatrixTextureShapeWidthHeight(1, 2); - expect(shape).toEqual([1, 1]); - }); - - it('[2x1] => [1x1]', () => { - const shape = tex_util.getPackedMatrixTextureShapeWidthHeight(2, 1); - expect(shape).toEqual([1, 1]); - }); - - it('[2x2] => [1x1]', () => { - const shape = tex_util.getPackedMatrixTextureShapeWidthHeight(2, 2); - expect(shape).toEqual([1, 1]); - }); - - it('[3x3] => [2x2]', () => { - const shape = tex_util.getPackedMatrixTextureShapeWidthHeight(3, 3); - expect(shape).toEqual([2, 2]); - }); - - it('[4x3] => [2x2]', () => { - const shape = tex_util.getPackedMatrixTextureShapeWidthHeight(4, 3); - expect(shape).toEqual([2, 2]); - }); - - it('[3x4] => [2x2]', () => { - const shape = tex_util.getPackedMatrixTextureShapeWidthHeight(3, 4); - expect(shape).toEqual([2, 2]); - }); - - it('[4x4] => [2x2]', () => { - const shape = tex_util.getPackedMatrixTextureShapeWidthHeight(4, 4); - expect(shape).toEqual([2, 2]); - }); - - it('[1024x1024] => [512x512]', () => { - const shape = tex_util.getPackedMatrixTextureShapeWidthHeight(1024, 1024); - expect(shape).toEqual([512, 512]); - }); - - it('[MxN] => [ceil(N/2)xceil(M/2)]', () => { - const M = 123; - const N = 5013; - const shape = tex_util.getPackedMatrixTextureShapeWidthHeight(M, N); - expect(shape).toEqual([Math.ceil(N / 2), Math.ceil(M / 2)]); - }); -}); - -describeWithFlags('tex_util getDenseTexShape', WEBGL_ENVS, () => { - it('basic', () => { - const shape = [1, 3, 3, 4]; - const denseShape = tex_util.getDenseTexShape(shape); - expectArraysClose(denseShape, [3, 3]); - }); -}); diff --git a/tfjs-master/tfjs-backend-webgl/src/texture_manager.ts b/tfjs-master/tfjs-backend-webgl/src/texture_manager.ts deleted file mode 100644 index feecad280..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/texture_manager.ts +++ /dev/null @@ -1,287 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {env} from '@tensorflow/tfjs-core'; - -import {GPGPUContext} from './gpgpu_context'; -import {getInternalFormatForFloat16MatrixTexture, getInternalFormatForFloat16PackedMatrixTexture, getInternalFormatForFloat32MatrixTexture, getInternalFormatForPackedMatrixTexture, getInternalFormatForUnsignedBytesMatrixTexture} from './gpgpu_util'; -import {getPackedMatrixTextureShapeWidthHeight, getUnpackedMatrixTextureShapeWidthHeight, PhysicalTextureType, Texture, TextureConfig, TextureUsage} from './tex_util'; - -export class TextureManager { - private numUsedTextures = 0; - private numFreeTextures = 0; - private _numBytesAllocated = 0; - // Number of bytes that have been allocated and available for reuse. - private _numBytesFree = 0; - private freeTextures: Record = {}; - private usedTextures: Record = {}; - private logEnabled = false; - - constructor(private readonly gpgpu: GPGPUContext) {} - - acquireTexture( - shapeRC: [number, number], usage: TextureUsage, - isPacked: boolean): Texture { - const physicalTexType = getPhysicalFromLogicalTextureType(usage, isPacked); - - const shapeKey = getKeyFromTextureShape(shapeRC, physicalTexType, isPacked); - if (!(shapeKey in this.freeTextures)) { - this.freeTextures[shapeKey] = []; - } - if (!(shapeKey in this.usedTextures)) { - this.usedTextures[shapeKey] = []; - } - - const texBytes = computeBytes( - shapeRC, physicalTexType, this.gpgpu.gl, this.gpgpu.textureConfig, - isPacked); - - if (this.freeTextures[shapeKey].length > 0) { - this.numFreeTextures--; - this.numUsedTextures++; - this._numBytesFree -= texBytes; - this.log(); - const newTexture = this.freeTextures[shapeKey].pop(); - this.usedTextures[shapeKey].push(newTexture); - return newTexture; - } - - let newTexture: Texture; - if (physicalTexType === PhysicalTextureType.PACKED_2X2_FLOAT32) { - newTexture = this.gpgpu.createPackedMatrixTexture(shapeRC[0], shapeRC[1]); - } else if (physicalTexType === PhysicalTextureType.PACKED_2X2_FLOAT16) { - newTexture = - this.gpgpu.createFloat16PackedMatrixTexture(shapeRC[0], shapeRC[1]); - } else if (physicalTexType === PhysicalTextureType.UNPACKED_FLOAT32) { - newTexture = - this.gpgpu.createFloat32MatrixTexture(shapeRC[0], shapeRC[1]); - } else if (physicalTexType === PhysicalTextureType.UNPACKED_FLOAT16) { - newTexture = - this.gpgpu.createFloat16MatrixTexture(shapeRC[0], shapeRC[1]); - } else if ( - physicalTexType === PhysicalTextureType.PACKED_4X1_UNSIGNED_BYTE) { - newTexture = - this.gpgpu.createUnsignedBytesMatrixTexture(shapeRC[0], shapeRC[1]); - } - this.usedTextures[shapeKey].push(newTexture); - - this.numUsedTextures++; - this._numBytesAllocated += texBytes; - this.log(); - - return newTexture; - } - - releaseTexture( - texture: Texture, shape: [number, number], logicalTexType: TextureUsage, - isPacked: boolean): void { - if (this.freeTextures == null) { - // Already disposed. - return; - } - const physicalTexType = - getPhysicalFromLogicalTextureType(logicalTexType, isPacked); - const shapeKey = getKeyFromTextureShape(shape, physicalTexType, isPacked); - if (!(shapeKey in this.freeTextures)) { - this.freeTextures[shapeKey] = []; - } - - const texBytes = computeBytes( - shape, physicalTexType, this.gpgpu.gl, this.gpgpu.textureConfig, - isPacked); - const deleteTexThreshold = env() - .getNumber('WEBGL_DELETE_TEXTURE_THRESHOLD'); - if (deleteTexThreshold !== -1 && - this._numBytesAllocated > deleteTexThreshold) { - this.gpgpu.deleteMatrixTexture(texture.texture); - this._numBytesAllocated -= texBytes; - } else { - this.freeTextures[shapeKey].push(texture); - this.numFreeTextures++; - this._numBytesFree += texBytes; - } - - this.numUsedTextures--; - - const texList = this.usedTextures[shapeKey]; - const texIndex = texList && texList.indexOf(texture); - if (texIndex == null || texIndex < 0) { - throw new Error( - 'Cannot release a texture that was never provided by this ' + - 'texture manager'); - } - texList[texIndex] = texList[texList.length - 1]; - texList.pop(); - this.log(); - } - - private log() { - if (!this.logEnabled) { - return; - } - const total = this.numFreeTextures + this.numUsedTextures; - console.log( - 'Free/Used', `${this.numFreeTextures} / ${this.numUsedTextures}`, - `(${total})`); - const freeRatio = this._numBytesFree / this._numBytesAllocated; - console.log(`Bytes allocated: ${this._numBytesAllocated}`); - console.log(`Bytes unused: ${this._numBytesFree} (${ - Math.round(100 * freeRatio)}%)`); - } - - get numBytesAllocated(): number { - return this._numBytesAllocated; - } - - get numBytesFree(): number { - return this._numBytesFree; - } - - getNumUsedTextures(): number { - return this.numUsedTextures; - } - - getNumFreeTextures(): number { - return this.numFreeTextures; - } - - dispose() { - if (this.freeTextures == null) { - // Already disposed. - return; - } - for (const texShape in this.freeTextures) { - this.freeTextures[texShape].forEach(tex => { - this.gpgpu.deleteMatrixTexture(tex.texture); - }); - } - for (const texShape in this.usedTextures) { - this.usedTextures[texShape].forEach(tex => { - this.gpgpu.deleteMatrixTexture(tex.texture); - }); - } - // TODO: Assign non-null value (empty object) to textures after disposed. - this.freeTextures = null; - this.usedTextures = null; - this.numUsedTextures = 0; - this.numFreeTextures = 0; - this._numBytesAllocated = 0; - this._numBytesFree = 0; - } -} - -function numBytesForInternalFormat( - gl: WebGLRenderingContext, internalFormat: number): number { - // tslint:disable-next-line:no-any - const glany = gl as any; - if (internalFormat === glany.R32F) { - return 4; - } else if (internalFormat === glany.R16F) { - return 2; - } else if (internalFormat === glany.RGBA32F) { - return 16; - } else if (internalFormat === gl.RGBA) { - return 16; - } else if (internalFormat === glany.RGBA16F) { - return 8; - } else if (internalFormat === glany.RGBA8) { - return 4; - } - throw new Error(`Unknown internal format ${internalFormat}`); -} - -export function computeBytes( - shape: [number, number], physicalTexType: PhysicalTextureType, - gl: WebGLRenderingContext, textureConfig: TextureConfig, - isPacked: boolean): number { - // It is not possible to infer packed status from the texture type because - // depending on the textureConfig, different texture types may resolve to the - // same internal format (e.g. in WebGL1, the internal format for - // UNPACKED_FLOAT16 textures is gl.RGBA). Therefore we pass in `isPacked` - // explicitly. - const internalFormat = - internalFormatForPhysicalTexType(physicalTexType, textureConfig); - - let numElements: number; - if (isPacked) { - const [packedWidth, packedHeight] = - getPackedMatrixTextureShapeWidthHeight(shape[0], shape[1]); - numElements = packedWidth * packedHeight; - - } else { - const [width, height] = - getUnpackedMatrixTextureShapeWidthHeight(shape[0], shape[1]); - numElements = width * height; - } - - const bytesPerElement = numBytesForInternalFormat(gl, internalFormat); - return numElements * bytesPerElement; -} - -function internalFormatForPhysicalTexType( - physicalTexType: PhysicalTextureType, - textureConfig: TextureConfig): number { - switch (physicalTexType) { - case PhysicalTextureType.PACKED_2X2_FLOAT32: - return getInternalFormatForPackedMatrixTexture(textureConfig); - case PhysicalTextureType.PACKED_2X2_FLOAT16: - return getInternalFormatForFloat16PackedMatrixTexture(textureConfig); - case PhysicalTextureType.UNPACKED_FLOAT32: - return getInternalFormatForFloat32MatrixTexture(textureConfig); - case PhysicalTextureType.UNPACKED_FLOAT16: - return getInternalFormatForFloat16MatrixTexture(textureConfig); - case PhysicalTextureType.PACKED_4X1_UNSIGNED_BYTE: - return getInternalFormatForUnsignedBytesMatrixTexture(textureConfig); - default: - throw new Error(`Unknown physical texture type ${physicalTexType}`); - } -} - -function getPhysicalTextureForRendering(isPacked: boolean): - PhysicalTextureType { - if (env().getBool('WEBGL_RENDER_FLOAT32_ENABLED')) { - if (isPacked) { - return PhysicalTextureType.PACKED_2X2_FLOAT32; - } - return PhysicalTextureType.UNPACKED_FLOAT32; - } - - if (isPacked) { - return PhysicalTextureType.PACKED_2X2_FLOAT16; - } - return PhysicalTextureType.UNPACKED_FLOAT16; -} - -function getPhysicalFromLogicalTextureType( - logicalTexType: TextureUsage, isPacked: boolean): PhysicalTextureType { - if (logicalTexType === TextureUsage.UPLOAD) { - return PhysicalTextureType.PACKED_2X2_FLOAT32; - } else if (logicalTexType === TextureUsage.RENDER || logicalTexType == null) { - return getPhysicalTextureForRendering(isPacked); - } else if ( - logicalTexType === TextureUsage.DOWNLOAD || - logicalTexType === TextureUsage.PIXELS) { - return PhysicalTextureType.PACKED_4X1_UNSIGNED_BYTE; - } - throw new Error(`Unknown logical texture type ${logicalTexType}`); -} - -function getKeyFromTextureShape( - shapeRowsCol: [number, number], physicalTexType: PhysicalTextureType, - isPacked: boolean): string { - return `${shapeRowsCol[0]}_${shapeRowsCol[1]}_${physicalTexType}_${isPacked}`; -} diff --git a/tfjs-master/tfjs-backend-webgl/src/tile_gpu.ts b/tfjs-master/tfjs-backend-webgl/src/tile_gpu.ts deleted file mode 100644 index 7ab7505b3..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/tile_gpu.ts +++ /dev/null @@ -1,62 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {GPGPUProgram} from './gpgpu_math'; -import {getCoordsDataType} from './shader_compiler'; - -export class TileProgram implements GPGPUProgram { - variableNames = ['A']; - outputShape: number[]; - userCode: string; - rank: number; - - constructor(aShape: number[], reps: number[]) { - const outputShape: number[] = new Array(aShape.length); - for (let i = 0; i < outputShape.length; i++) { - outputShape[i] = aShape[i] * reps[i]; - } - this.outputShape = outputShape; - this.rank = outputShape.length; - const dtype = getCoordsDataType(this.rank); - const sourceCoords = getSourceCoords(aShape); - - this.userCode = ` - void main() { - ${dtype} resRC = getOutputCoords(); - setOutput(getA(${sourceCoords})); - } - `; - } -} - -function getSourceCoords(aShape: number[]): string { - const rank = aShape.length; - if (rank > 5) { - throw Error(`Tile for rank ${rank} is not yet supported`); - } - if (rank === 1) { - return `imod(resRC, ${aShape[0]})`; - } - - const currentCoords = ['resRC.x', 'resRC.y', 'resRC.z', 'resRC.w', 'resRC.u']; - - const sourceCoords = []; - for (let i = 0; i < aShape.length; i++) { - sourceCoords.push(`imod(${currentCoords[i]}, ${aShape[i]})`); - } - return sourceCoords.join(); -} diff --git a/tfjs-master/tfjs-backend-webgl/src/top_k_gpu.ts b/tfjs-master/tfjs-backend-webgl/src/top_k_gpu.ts deleted file mode 100644 index 3d66e167e..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/top_k_gpu.ts +++ /dev/null @@ -1,152 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {GPGPUProgram} from './gpgpu_math'; -import {UniformType} from './shader_compiler'; - -// Based on Algorithm 2 of Bitonic Top K, ref: -// https://anilshanbhag.in/static/papers/gputopk_sigmod18.pdf -// The original algorithm is based on computing the top K only, however -// since for TFJS we require the indices of the top K values as well then the -// algorithm found here is a bit modified. Rather than producing the values -// at each step, the indices containing the top K are generated instead. -// The output values are not generated to reduce the number of outputs in the -// GPU, the values can easily be retrieved from the indices using a gather -// op. -export class SwapProgram implements GPGPUProgram { - variableNames = ['x', 'indices']; - outputShape: number[]; - userCode: string; - // |n| Size of the original input of TopK. - // |firstPass|indicates if this is the first time swap is being used which - // means no indices input containing the top K is present yet. - // |inc| Swaps pairs of indices (0, inc), (1, inc + 1), (2, inc + 2) ... - customUniforms = [ - {name: 'n', type: 'int' as UniformType}, - {name: 'firstPass', type: 'int' as UniformType}, - {name: 'negativeInf', type: 'float' as UniformType}, - {name: 'dir', type: 'int' as UniformType}, - {name: 'inc', type: 'int' as UniformType} - ]; - - /** - * @param shape desired output shape (can be larger than input shape, output - * will be padded with -Infinity) - */ - constructor(shape: number[]) { - this.outputShape = shape; - - this.userCode = ` - void main() { - ivec2 coords = getOutputCoords(); - int batch = coords[0]; - int elemIdx = coords[1]; - - // We compare elements pair-wise within a group of size 2 * inc. - // The comparing rule for each group alternates between ascending - // and descending. Within each group, we compare each pair at - // positions i and i+inc. To decide whether an element at position i - // is x0 or x1, we mod it by 2 * inc, if the result is smaller than - // inc, it is in the first half of the group, we denote it as x0, - // otherwise we denote it as x1. - // For example, as shown in the Bitonic top K paper referenced above, - // Figure5(a) shows that element[1] is in the - // second half of the group when group size is 2, but it is in the - // first half of the group when group size is 4. - - bool isFirstInPair = imod(elemIdx, 2 * inc) < inc; - int i = isFirstInPair ? elemIdx : elemIdx - inc; - - int i0 = firstPass == 1 ? i : int(getIndices(batch, i)); - int i1 = firstPass == 1 ? i + inc : int(getIndices(batch, i + inc)); - float x0 = i0 < n ? getX(batch, i0) : negativeInf; - float x1 = i1 < n ? getX(batch, i1) : negativeInf; - - // Denotes which direction indices are in (ascending or descending). - bool reverse = imod(elemIdx, 2 * dir) >= dir; - bool isGreater = x0 > x1 || (x0 == x1 && i1 > i0); - if (reverse == isGreater) { // Elements in opposite order of direction - int iTemp = i0; - i0 = i1; - i1 = iTemp; - } - if (isFirstInPair) { - setOutput(float(i0)); - } else { - setOutput(float(i1)); - } - } - `; - } -} - -export class MergeProgram implements GPGPUProgram { - variableNames = ['x', 'indices']; - outputShape: number[]; - userCode: string; - // |n| Size of the original input of TopK - // |firstPass| indicates if this is the first time swap is being used which - // means no indices input containing the top K is present yet. - // |k| Top k elements desired - customUniforms = [ - {name: 'n', type: 'int' as UniformType}, - {name: 'firstPass', type: 'int' as UniformType}, - {name: 'k', type: 'int' as UniformType} - ]; - - /** - * @param shape desired output shape (must be half of the input size) - */ - constructor(shape: number[]) { - this.outputShape = shape; - - this.userCode = ` - void main() { - // Takes max of indices (0, k), (1, k + 1), (2, k + 2) ... - ivec2 coords = getOutputCoords(); - int batch = coords[0]; - int elemIdx = coords[1]; - - // The output size is half of the previous size. - // If the previous sequence is | | | | _ _ _ _ | | | | _ _ _ _ (k=4), - // we only need to output the indices at positions |, the indices at - // positions _ can be thrown away, see Figure5(b) After Phase 2 - // (Merge phase) in the Bitonic Top K paper referenced above. - // For example, the paper shows we only need to output the orange bars. - // The output sequence should look like this | | | | | | | |. - // Because the sequence is halved, to map the output index back - // to the previous sequence to find the corresponding value, - // we need to double the index. When we double the index, - // we basically interpolate a position, so 2i looks like - // | _ | _ | _ | _ | _ | _ | _. We move the | to the first k position - // of each 2k positions by - elemIdx % k. E.g. for output at - // index 4,5,6,7, we want to get the corresponding element at - // original index 8,9,10,11, for output at index 8,9,10,11, - // we want to get the corresponding element at original index - // 16,17,18,19, so on and so forth. - - int i = elemIdx < k ? elemIdx : (elemIdx * 2 - imod(elemIdx, k)); - int i0 = firstPass == 1 ? i : int(getIndices(batch, i)); - int i1 = firstPass == 1 ? i + k : int(getIndices(batch, i + k)); - - float x0 = getX(batch, i0); - float x1 = i1 < n ? getX(batch, i1) : x0; - - setOutput(x0 >= x1 ? float(i0) : float(i1)); - } - `; - } -} diff --git a/tfjs-master/tfjs-backend-webgl/src/transform_gpu.ts b/tfjs-master/tfjs-backend-webgl/src/transform_gpu.ts deleted file mode 100644 index 8b364933c..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/transform_gpu.ts +++ /dev/null @@ -1,165 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {GPGPUProgram} from './gpgpu_math'; - -export class TransformProgram implements GPGPUProgram { - variableNames = ['Image', 'Transforms']; - outputShape: number[]; - userCode: string; - - constructor( - imageHeight: number, imageWidth: number, - interpolation: 'nearest'|'bilinear', - fillMode: 'constant'|'reflect'|'wrap'|'nearest', fillValue: number, - outShape: [number, number, number, number]) { - this.outputShape = outShape; - const interpolationModeId = interpolation === 'nearest' ? 1 : 2; - let fillModeId; - switch (fillMode) { - case 'constant': - fillModeId = 1; - break; - case 'reflect': - fillModeId = 2; - break; - case 'wrap': - fillModeId = 3; - break; - case 'nearest': - fillModeId = 4; - break; - default: - fillModeId = 1; - break; - } - this.userCode = ` - float mapCoord(float outCoord, float len) { - float inCoord = outCoord; - if(${fillModeId} == 2) { - if (inCoord < 0.0) { - if (len <= 1.0) { - inCoord = 0.0; - } else { - float sz2 = 2.0 * len; - if (inCoord < sz2) { - inCoord = sz2 * float(int(float(-inCoord / sz2))) + - inCoord; - } - inCoord = inCoord < -len ? inCoord + sz2 : -inCoord - 1.0; - } - } else if (inCoord > len - 1.0) { - if (len <= 1.0) { - inCoord = 0.0; - } else { - float sz2 = 2.0 * len; - inCoord -= sz2 * float(int(float(inCoord / sz2))); - if (inCoord >= len) { - inCoord = sz2 - inCoord - 1.0; - } - } - } - return clamp(inCoord, 0.0, len - 1.0); - } else if (${fillModeId} == 3) { - if (inCoord < 0.0) { - if (len <= 1.0) { - inCoord = 0.0; - } else { - float sz = len - 1.0; - inCoord += len * (float(int(float(-inCoord / sz))) + 1.0); - } - } else if (inCoord > len - 1.0) { - if (len <= 1.0) { - inCoord = 0.0; - } else { - float sz = len - 1.0; - inCoord -= len * float(int(float(inCoord / sz))); - } - } - return clamp(inCoord, 0.0, len - 1.0); - } else if (${fillModeId} == 4) { - return clamp(outCoord, 0.0, len - 1.0); - } else { - return outCoord; - } - } - - float readWithFillValue(int batch, int coordY, int coordX, - int channel) { - float outputValue; - if (0 <= coordY && coordY < ${ - imageHeight} && 0 <= coordX && coordX < ${imageWidth}) { - outputValue = getImage(batch, coordY, coordX, channel); - } else { - outputValue = float(${fillValue}); - } - return outputValue; - } - - void main() { - ivec4 coords = getOutputCoords(); - float outputValue; - int batch = coords[0]; - int x = coords[2]; - int y = coords[1]; - int channel = coords[3]; - float xf = float(x); - float yf = float(y); - float a1 = getTransforms(batch, 0); - float a2 = getTransforms(batch, 1); - float a3 = getTransforms(batch, 2); - float b1 = getTransforms(batch, 3); - float b2 = getTransforms(batch, 4); - float b3 = getTransforms(batch, 5); - float c1 = getTransforms(batch, 6); - float c2 = getTransforms(batch, 7); - float projection = c1 * xf + c2 * yf + 1.0; - if (projection == 0.0) { - outputValue = float(${fillValue}); - } else { - float inX = (a1 * xf + a2 * yf + a3) / projection; - float inY = (b1 * xf + b2 * yf + b3) / projection; - float mapX = mapCoord(inX, float(${imageWidth})); - float mapY = mapCoord(inY, float(${imageHeight})); - - if (${interpolationModeId} == 1) { - int coordY = int(round(mapY)); - int coordX = int(round(mapX)); - outputValue = readWithFillValue(batch, coordY, coordX, - channel); - } else { - float yFloor = floor(mapY); - float xFloor = floor(mapX); - float yCeil = yFloor + 1.0; - float xCeil = xFloor + 1.0; - float valueYFloor = (xCeil - mapX) * - readWithFillValue(batch, int(yFloor), int(xFloor), channel) + - (mapX - xFloor) * - readWithFillValue(batch, int(yFloor), int(xCeil), channel); - float valueYCeil = (xCeil - mapX) * - readWithFillValue(batch, int(yCeil), int(xFloor), channel) + - (mapX - xFloor) * - readWithFillValue(batch, int(yCeil), int(xCeil), channel); - outputValue = (yCeil - mapY) * valueYFloor + - (mapY - yFloor) * valueYCeil; - } - } - setOutput(outputValue); - } - `; - } -} diff --git a/tfjs-master/tfjs-backend-webgl/src/transpose_gpu.ts b/tfjs-master/tfjs-backend-webgl/src/transpose_gpu.ts deleted file mode 100644 index b6da972a1..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/transpose_gpu.ts +++ /dev/null @@ -1,58 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {GPGPUProgram} from './gpgpu_math'; -import {getCoordsDataType} from './shader_compiler'; - -export class TransposeProgram implements GPGPUProgram { - variableNames = ['A']; - outputShape: number[]; - userCode: string; - rank: number; - - constructor(aShape: number[], newDim: number[]) { - const outputShape: number[] = new Array(aShape.length); - for (let i = 0; i < outputShape.length; i++) { - outputShape[i] = aShape[newDim[i]]; - } - this.outputShape = outputShape; - this.rank = outputShape.length; - const dtype = getCoordsDataType(this.rank); - const switched = getSwitchedCoords(newDim); - - this.userCode = ` - void main() { - ${dtype} resRC = getOutputCoords(); - setOutput(getA(${switched})); - } - `; - } -} - -function getSwitchedCoords(newDim: number[]): string { - const rank = newDim.length; - if (rank > 6) { - throw Error(`Transpose for rank ${rank} is not yet supported`); - } - const originalOrder = - ['resRC.x', 'resRC.y', 'resRC.z', 'resRC.w', 'resRC.u', 'resRC.v']; - const switchedCoords = new Array(rank); - for (let i = 0; i < newDim.length; i++) { - switchedCoords[newDim[i]] = originalOrder[i]; - } - return switchedCoords.join(); -} diff --git a/tfjs-master/tfjs-backend-webgl/src/transpose_packed_gpu.ts b/tfjs-master/tfjs-backend-webgl/src/transpose_packed_gpu.ts deleted file mode 100644 index 07312cf54..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/transpose_packed_gpu.ts +++ /dev/null @@ -1,72 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {GPGPUProgram} from './gpgpu_math'; -import {getVecChannels} from './packing_util'; -import {getCoordsDataType} from './shader_compiler'; - -export class TransposePackedProgram implements GPGPUProgram { - variableNames = ['A']; - outputShape: number[]; - userCode: string; - rank: number; - packedInputs = true; - packedOutput = true; - - constructor(aShape: number[], newDim: number[]) { - const outputShape: number[] = new Array(aShape.length); - for (let i = 0; i < outputShape.length; i++) { - outputShape[i] = aShape[newDim[i]]; - } - this.outputShape = outputShape; - this.rank = outputShape.length; - if (this.rank > 6) { - throw Error( - `Packed transpose for rank ${this.rank} is not yet supported.`); - } - const dtype = getCoordsDataType(this.rank); - - const outputOrder = getVecChannels('rc', this.rank); - const switchedOrder = new Array(this.rank); - for (let i = 0; i < newDim.length; i++) { - switchedOrder[newDim[i]] = outputOrder[i]; - } - const innerDims = `vec2(${switchedOrder.slice(-2).join()})`; - const nextColumn = - `++${outputOrder[this.rank - 1]} < ${outputShape[this.rank - 1]}`; - const getc = `getChannel(getA(${switchedOrder.join()}), ${innerDims})`; - - this.userCode = ` - void main() { - ${dtype} rc = getOutputCoords(); - vec4 result = vec4(0.); - result[0] = ${getc}; - if(${nextColumn}) { - result[1] = ${getc}; - } - --${outputOrder[this.rank - 1]}; - if(++${outputOrder[this.rank - 2]} < ${outputShape[this.rank - 2]}) { - result[2] = ${getc}; - if(${nextColumn}) { - result[3] = ${getc}; - } - } - setOutput(result); - } - `; - } -} diff --git a/tfjs-master/tfjs-backend-webgl/src/unaryop_gpu.ts b/tfjs-master/tfjs-backend-webgl/src/unaryop_gpu.ts deleted file mode 100644 index 63b453fd1..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/unaryop_gpu.ts +++ /dev/null @@ -1,67 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {GPGPUProgram, useShapeUniforms} from './gpgpu_math'; - -export class UnaryOpProgram implements GPGPUProgram { - variableNames = ['A']; - userCode: string; - outputShape: number[]; - enableShapeUniforms: boolean; - - constructor(aShape: number[], opSnippet: string) { - this.outputShape = aShape; - this.enableShapeUniforms = useShapeUniforms(this.outputShape.length); - this.userCode = ` - float unaryOperation(float x) { - ${opSnippet} - } - - void main() { - float x = getAAtOutCoords(); - float y = unaryOperation(x); - - setOutput(y); - } - `; - } -} - -export const CHECK_NAN_SNIPPET = `if (isnan(x)) return x;`; - -export const LINEAR = `return x;`; - -export const ABS = `return abs(x);`; - -export function STEP(alpha = 0.0) { - return CHECK_NAN_SNIPPET + ` - return x > 0.0 ? 1.0 : float(${alpha}); - `; -} - -export const ELU = `return (x >= 0.0) ? x : (exp(x) - 1.0);`; -export const RELU = CHECK_NAN_SNIPPET + ` - return (x < 0.0) ? 0.0 : x; -`; - -export const RELU6 = CHECK_NAN_SNIPPET + ` - return (x < 0.0) ? 0.0 : min(6.0, x); -`; - -export const CLONE = 'return x;'; - -export const SIGMOID = `return 1.0 / (1.0 + exp(-1.0 * x));`; diff --git a/tfjs-master/tfjs-backend-webgl/src/unaryop_packed_gpu.ts b/tfjs-master/tfjs-backend-webgl/src/unaryop_packed_gpu.ts deleted file mode 100644 index 1e2ccf039..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/unaryop_packed_gpu.ts +++ /dev/null @@ -1,83 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {GPGPUProgram, useShapeUniforms} from './gpgpu_math'; - -export const LINEAR = `return x;`; - -export const ELU = ` - vec4 result; - - result.r = (x.r >= 0.0) ? x.r : (exp(x.r) - 1.0); - result.g = (x.g >= 0.0) ? x.g : (exp(x.g) - 1.0); - result.b = (x.b >= 0.0) ? x.b : (exp(x.b) - 1.0); - result.a = (x.a >= 0.0) ? x.a : (exp(x.a) - 1.0); - - return result; -`; - -export const RELU = ` - vec4 result = x * vec4(greaterThanEqual(x, vec4(0.0))); - bvec4 isNaN = isnan(x); - - result.r = isNaN.r ? x.r : result.r; - result.g = isNaN.g ? x.g : result.g; - result.b = isNaN.b ? x.b : result.b; - result.a = isNaN.a ? x.a : result.a; - - return result; -`; - -export const RELU6 = ` - vec4 result = min(x, vec4(6.)) * vec4(greaterThanEqual(x, vec4(0.0))); - bvec4 isNaN = isnan(x); - - result.r = isNaN.r ? x.r : result.r; - result.g = isNaN.g ? x.g : result.g; - result.b = isNaN.b ? x.b : result.b; - result.a = isNaN.a ? x.a : result.a; - - return result; -`; - -export const SIGMOID = `return 1.0 / (1.0 + exp(-1.0 * x));`; - -export class UnaryOpPackedProgram implements GPGPUProgram { - variableNames = ['A']; - userCode: string; - enableShapeUniforms: boolean; - outputShape: number[]; - packedInputs = true; - packedOutput = true; - - constructor(aShape: number[], opSnippet: string) { - this.outputShape = aShape; - this.enableShapeUniforms = useShapeUniforms(this.outputShape.length); - this.userCode = ` - vec4 unaryOperation(vec4 x) { - ${opSnippet} - } - - void main() { - vec4 x = getAAtOutCoords(); - vec4 y = unaryOperation(x); - - setOutput(y); - } - `; - } -} diff --git a/tfjs-master/tfjs-backend-webgl/src/unpack_gpu.ts b/tfjs-master/tfjs-backend-webgl/src/unpack_gpu.ts deleted file mode 100644 index 79bb34475..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/unpack_gpu.ts +++ /dev/null @@ -1,50 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {GPGPUProgram, useShapeUniforms} from './gpgpu_math'; -import {getChannels, getSourceCoords} from './packing_util'; -import {getCoordsDataType} from './shader_compiler'; - -export class UnpackProgram implements GPGPUProgram { - variableNames = ['A']; - packedInputs = true; - packedOutput = false; - outputShape: number[]; - userCode: string; - enableShapeUniforms: boolean; - - constructor(outputShape: number[]) { - this.outputShape = outputShape; - this.enableShapeUniforms = useShapeUniforms(this.outputShape.length); - const rank = outputShape.length; - - const channels = getChannels('rc', rank); - const dtype = getCoordsDataType(rank); - const sourceCoords = getSourceCoords(rank, channels); - const innerDims = channels.slice(-2); - const coords = rank <= 1 ? 'rc' : `vec2(${innerDims.join(',')})`; - - this.userCode = ` - void main() { - ${dtype} rc = getOutputCoords(); - vec4 packedInput = getA(${sourceCoords}); - - setOutput(getChannel(packedInput, ${coords})); - } - `; - } -} diff --git a/tfjs-master/tfjs-backend-webgl/src/version.ts b/tfjs-master/tfjs-backend-webgl/src/version.ts deleted file mode 100644 index 5fa574e7d..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/version.ts +++ /dev/null @@ -1,5 +0,0 @@ -/** @license See the LICENSE file. */ - -// This code is auto-generated, do not modify this file! -const version = '0.0.0'; -export {version}; diff --git a/tfjs-master/tfjs-backend-webgl/src/webgl.ts b/tfjs-master/tfjs-backend-webgl/src/webgl.ts deleted file mode 100644 index 48b29b9ec..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/webgl.ts +++ /dev/null @@ -1,37 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {env} from '@tensorflow/tfjs-core'; - -import * as gpgpu_util from './gpgpu_util'; -import * as webgl_util from './webgl_util'; - -export {MathBackendWebGL, WebGLMemoryInfo, WebGLTimingInfo} from './backend_webgl'; -export {setWebGLContext} from './canvas_util'; -export {GPGPUContext} from './gpgpu_context'; -export {GPGPUProgram} from './gpgpu_math'; -// WebGL specific utils. -export {gpgpu_util, webgl_util}; - -/** - * Enforce use of half precision textures if available on the platform. - * - * @doc {heading: 'Environment', namespace: 'webgl'} - */ -export function forceHalfFloat(): void { - env().set('WEBGL_FORCE_F16_TEXTURES', true); -} diff --git a/tfjs-master/tfjs-backend-webgl/src/webgl_batchnorm_test.ts b/tfjs-master/tfjs-backend-webgl/src/webgl_batchnorm_test.ts deleted file mode 100644 index 94857209c..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/webgl_batchnorm_test.ts +++ /dev/null @@ -1,83 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '@tensorflow/tfjs-core'; -import {test_util} from '@tensorflow/tfjs-core'; -const {expectArraysClose} = test_util; -// tslint:disable-next-line: no-imports-from-dist -import {describeWithFlags} from '@tensorflow/tfjs-core/dist/jasmine_util'; -import {PACKED_ENVS, WEBGL_ENVS} from './backend_webgl_test_registry'; - -describeWithFlags('batchNorm', WEBGL_ENVS, () => { - it('should work for broadcasted inputs', async () => { - const x = tf.tensor4d([2, 4, 9, 23], [2, 1, 1, 2]); - const mean = tf.tensor4d([1], [1, 1, 1, 1]); - const variance = tf.tensor4d([1], [1, 1, 1, 1]); - - const result = tf.batchNorm4d(x, mean, variance); - expectArraysClose( - await result.data(), [0.9995003, 2.9985011, 7.9960027, 21.9890079]); - }); - - it('should work when squarification results in zero padding', async () => { - const maxTextureSize = tf.env().getNumber('WEBGL_MAX_TEXTURE_SIZE'); - tf.env().set('WEBGL_MAX_TEXTURE_SIZE', 5); - - const x = tf.tensor3d( - [ - 0.49955603, 0.04158615, -1.09440524, 2.03854165, -0.61578344, - 2.87533573, 1.18105987, 0.807462, 1.87888837, 2.26563962, -0.37040935, - 1.35848753, -0.75347094, 0.15683117, 0.91925946, 0.34121279, - 0.92717143, 1.89683965 - ], - [2, 3, 3]); - const mean = tf.tensor1d([0.39745062, -0.48062894, 0.4847822]); - const variance = tf.tensor1d([0.32375343, 0.67117643, 1.08334653]); - const offset = tf.tensor1d([0.69398749, -1.29056387, 0.9429723]); - const scale = tf.tensor1d([-0.5607271, 0.9878457, 0.25181573]); - const varianceEpsilon = .001; - - const result = - tf.batchNorm3d(x, mean, variance, offset, scale, varianceEpsilon); - - tf.env().set('WEBGL_MAX_TEXTURE_SIZE', maxTextureSize); - - expectArraysClose(await result.data(), [ - 0.59352049, -0.66135202, 0.5610874, -0.92077015, -1.45341019, 1.52106473, - -0.07704776, 0.26144429, 1.28010017, -1.14422404, -1.15776136, 1.15425493, - 1.82644104, -0.52249442, 1.04803919, 0.74932291, 0.40568101, 1.2844412 - ]); - }); -}); - -describeWithFlags('batchnorm packed', PACKED_ENVS, () => { - it('should not leak memory', () => { - const x = tf.tensor4d([2, 4, 9, 23], [2, 1, 1, 2]); - const mean = tf.tensor1d([1, 2]); - const variance = tf.tensor1d([2, 3]); - const varianceEpsilon = .001; - - const startNumBytes = tf.memory().numBytes; - const startNumTensors = tf.memory().numTensors; - tf.batchNorm4d(x, mean, variance, undefined, undefined, varianceEpsilon); - const endNumBytes = tf.memory().numBytes; - const endNumTensors = tf.memory().numTensors; - - expect(endNumBytes - startNumBytes).toEqual(16); - expect(endNumTensors - startNumTensors).toEqual(1); - }); -}); diff --git a/tfjs-master/tfjs-backend-webgl/src/webgl_custom_op_test.ts b/tfjs-master/tfjs-backend-webgl/src/webgl_custom_op_test.ts deleted file mode 100644 index fcfbae0e3..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/webgl_custom_op_test.ts +++ /dev/null @@ -1,110 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '@tensorflow/tfjs-core'; -import {engine, Tensor, TensorInfo, test_util} from '@tensorflow/tfjs-core'; -// tslint:disable-next-line: no-imports-from-dist -import {describeWithFlags} from '@tensorflow/tfjs-core/dist/jasmine_util'; - -import {WEBGL_ENVS} from './backend_webgl_test_registry'; -import {GPGPUProgram, MathBackendWebGL} from './webgl'; - -describeWithFlags('custom-op webgl', WEBGL_ENVS, () => { - class SquareAndAddKernel implements GPGPUProgram { - variableNames = ['X']; - outputShape: number[]; - userCode: string; - constructor(inputShape: number[]) { - this.outputShape = inputShape.slice(); - - this.userCode = ` - void main() { - float x = getXAtOutCoords(); - float value = x * x + x; - setOutput(value); - } - `; - } - } - - class SquareAndAddBackpropKernel implements GPGPUProgram { - variableNames = ['X']; - outputShape: number[]; - userCode: string; - constructor(inputShape: number[]) { - this.outputShape = inputShape.slice(); - - this.userCode = ` - void main() { - float x = getXAtOutCoords(); - float value = 2.0 * x + 1.0; - setOutput(value); - } - `; - } - } - - function squareAndAdd(x: T): T { - const fn = tf.customGrad((x: T, save: tf.GradSaveFunc) => { - save([x]); - const webglBackend = tf.backend() as MathBackendWebGL; - const program = new SquareAndAddKernel(x.shape); - const backpropProgram = new SquareAndAddBackpropKernel(x.shape); - - const outInfo: TensorInfo = webglBackend.compileAndRun(program, [x]); - const value = engine().makeTensorFromTensorInfo(outInfo) as T; - - const gradFunc = (dy: T, saved: Tensor[]) => { - const [x] = saved; - const backInfo = webglBackend.compileAndRun(backpropProgram, [x]); - const back: T = engine().makeTensorFromTensorInfo(backInfo) as T; - return back.mul(dy); - }; - return {value, gradFunc}; - }); - return fn(x); - } - - it('lets users use custom operations', async () => { - const inputArr = [1, 2, 3, 4]; - const input = tf.tensor(inputArr); - const output = squareAndAdd(input); - test_util.expectArraysClose( - await output.data(), inputArr.map(x => x * x + x)); - }); - - it('lets users define gradients for operations', async () => { - const inputArr = [1, 2, 3, 4]; - const input = tf.tensor(inputArr); - const grads = tf.valueAndGrad(x => squareAndAdd(x)); - const {value, grad} = grads(input); - test_util.expectArraysClose( - await value.data(), inputArr.map(x => x * x + x)); - test_util.expectArraysClose( - await grad.data(), inputArr.map(x => 2 * x + 1)); - }); - - it('multiplies by dy parameter when it is passed', async () => { - const inputArr = [1, 2, 3, 4]; - const input = tf.tensor(inputArr); - const grads = tf.valueAndGrad(x => squareAndAdd(x)); - const {value, grad} = grads(input, tf.zerosLike(input)); - test_util.expectArraysClose( - await value.data(), inputArr.map(x => x * x + x)); - test_util.expectArraysClose(await grad.data(), inputArr.map(() => 0.0)); - }); -}); diff --git a/tfjs-master/tfjs-backend-webgl/src/webgl_ops_test.ts b/tfjs-master/tfjs-backend-webgl/src/webgl_ops_test.ts deleted file mode 100644 index 48ff09f25..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/webgl_ops_test.ts +++ /dev/null @@ -1,1063 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Rank, Tensor2D, Tensor3D, Tensor4D, test_util} from '@tensorflow/tfjs-core'; -const expectArraysClose = test_util.expectArraysClose; -const expectArraysEqual = test_util.expectArraysEqual; -// tslint:disable-next-line: no-imports-from-dist -import {describeWithFlags} from '@tensorflow/tfjs-core/dist/jasmine_util'; -import * as tf from '@tensorflow/tfjs-core'; - -import {WebGLMemoryInfo} from './backend_webgl'; -import {PACKED_ENVS, WEBGL_ENVS} from './backend_webgl_test_registry'; - -describeWithFlags('fromPixels + regular math op', WEBGL_ENVS, () => { - it('fromPixels + add', async () => { - const pixels = new ImageData(2, 2); - for (let i = 0; i < 8; i++) { - pixels.data[i] = 100; - } - for (let i = 8; i < 16; i++) { - pixels.data[i] = 250; - } - - const a = tf.browser.fromPixels(pixels, 4); - const b = tf.scalar(20, 'int32'); - - const res = tf.add(a, b); - - expectArraysEqual(await res.data(), [ - 120, 120, 120, 120, 120, 120, 120, 120, 270, 270, 270, 270, 270, 270, 270, - 270 - ]); - }); -}); - -describeWithFlags('toPixels', WEBGL_ENVS, () => { - it('draws a rank-2 float32 tensor, canvas', done => { - const x = tf.tensor2d([.15, .2], [2, 1], 'float32'); - const canvas = document.createElement('canvas'); - - tf.browser.toPixels(x, canvas).then(data => { - const expected = new Uint8ClampedArray([ - Math.round(.15 * 255), Math.round(.15 * 255), Math.round(.15 * 255), - 255, Math.round(.2 * 255), Math.round(.2 * 255), Math.round(.2 * 255), - 255 - ]); - expect(data).toEqual(expected); - - const ctx = canvas.getContext('2d'); - const imgData = ctx.getImageData(0, 0, 1, 2); - - expect(imgData.data).toEqual(expected); - done(); - }); - }); - - it('draws a rank-2 int32 tensor, canvas', done => { - const x = tf.tensor2d([10, 20], [2, 1], 'int32'); - const canvas = document.createElement('canvas'); - - tf.browser.toPixels(x, canvas).then(data => { - const expected = - new Uint8ClampedArray([10, 10, 10, 255, 20, 20, 20, 255]); - expect(data).toEqual(expected); - - const ctx = canvas.getContext('2d'); - const imgData = ctx.getImageData(0, 0, 1, 2); - - expect(imgData.data).toEqual(expected); - done(); - }); - }); - - it('draws a rank-3 float32 tensor, 1 channel, canvas', done => { - const x = tf.tensor3d([.15, .2], [2, 1, 1], 'float32'); - const canvas = document.createElement('canvas'); - - tf.browser.toPixels(x, canvas).then(data => { - const expected = new Uint8ClampedArray([ - Math.round(.15 * 255), Math.round(.15 * 255), Math.round(.15 * 255), - 255, Math.round(.2 * 255), Math.round(.2 * 255), Math.round(.2 * 255), - 255 - ]); - expect(data).toEqual(expected); - - const ctx = canvas.getContext('2d'); - const imgData = ctx.getImageData(0, 0, 1, 2); - - expect(imgData.data).toEqual(expected); - done(); - }); - }); - - it('draws a rank-3 int32 tensor, 1 channel, canvas', done => { - const x = tf.tensor3d([10, 20], [2, 1, 1], 'int32'); - const canvas = document.createElement('canvas'); - - tf.browser.toPixels(x, canvas).then(data => { - const expected = - new Uint8ClampedArray([10, 10, 10, 255, 20, 20, 20, 255]); - expect(data).toEqual(expected); - - const ctx = canvas.getContext('2d'); - const imgData = ctx.getImageData(0, 0, 1, 2); - - expect(imgData.data).toEqual(expected); - done(); - }); - }); - - it('draws a rank-3 float32 tensor, 3 channel, canvas', done => { - const x = - tf.tensor3d([.05, .1001, .15, .20, .25, .3001], [2, 1, 3], 'float32'); - const canvas = document.createElement('canvas'); - - tf.browser.toPixels(x, canvas).then(data => { - const expected = new Uint8ClampedArray([ - Math.round(.05 * 255), Math.round(.1001 * 255), Math.round(.15 * 255), - 255, Math.round(.2 * 255), Math.round(.25 * 255), - Math.round(.3001 * 255), 255 - ]); - expect(data).toEqual(expected); - - const ctx = canvas.getContext('2d'); - const imgData = ctx.getImageData(0, 0, 1, 2); - - expect(imgData.data).toEqual(expected); - done(); - }); - }); - - it('draws a rank-3 int32 tensor, 3 channel, canvas', done => { - const x = tf.tensor3d([10, 20, 30, 40, 50, 60], [2, 1, 3], 'int32'); - const canvas = document.createElement('canvas'); - - tf.browser.toPixels(x, canvas).then(data => { - const expected = - new Uint8ClampedArray([10, 20, 30, 255, 40, 50, 60, 255]); - expect(data).toEqual(expected); - - const ctx = canvas.getContext('2d'); - const imgData = ctx.getImageData(0, 0, 1, 2); - expect(imgData.data).toEqual(expected); - done(); - }); - }); - - it('draws a rank-3 float32 tensor, 4 channel, canvas', done => { - // ImageData roundtrips are lossy because of pre-multiplied alphas, so we - // use an alpha = 1 to avoid losing precision on r, g, b channels in these - // tests https://www.w3.org/TR/2dcontext/ - const x = tf.tensor3d( - [.05, .1001, .15, 1, .20, .25, .3001, 1], [2, 1, 4], 'float32'); - const canvas = document.createElement('canvas'); - - tf.browser.toPixels(x, canvas).then(data => { - const expected = new Uint8ClampedArray([ - Math.round(.05 * 255), Math.round(.1001 * 255), Math.round(.15 * 255), - 255, Math.round(.20 * 255), Math.round(.25 * 255), - Math.round(.3001 * 255), 255 - ]); - expect(data).toEqual(expected); - - const ctx = canvas.getContext('2d'); - const imgData = ctx.getImageData(0, 0, 1, 2); - - expect(imgData.data).toEqual(expected); - done(); - }); - }); - - it('draws a rank-3 int32 tensor, 4 channel, canvas', done => { - // ImageData roundtrips are lossy because of pre-multiplied alphas, so we - // use an alpha = 1 to avoid losing precision on r, g, b channels in these - // tests https://www.w3.org/TR/2dcontext/ - const x = - tf.tensor3d([10, 20, 30, 255, 50, 60, 70, 255], [2, 1, 4], 'int32'); - const canvas = document.createElement('canvas'); - - tf.browser.toPixels(x, canvas).then(data => { - const expected = - new Uint8ClampedArray([10, 20, 30, 255, 50, 60, 70, 255]); - expect(data).toEqual(expected); - - const ctx = canvas.getContext('2d'); - const imgData = ctx.getImageData(0, 0, 1, 2); - - expect(imgData.data).toEqual(expected); - done(); - }); - }); - - it('accepts a tensor-like object', async () => { - const x = [[127], [100]]; // 2x1; - const canvas = document.createElement('canvas'); - - const data = await tf.browser.toPixels(x, canvas); - const expected = - new Uint8ClampedArray([127, 127, 127, 255, 100, 100, 100, 255]); - expect(data).toEqual(expected); - - const ctx = canvas.getContext('2d'); - const imgData = ctx.getImageData(0, 0, 1, 2); - - expect(imgData.data).toEqual(expected); - }); -}); - -describeWithFlags('depthToSpace', WEBGL_ENVS, () => { - it('tensor4d, input shape=[1, 4, 1, 1], blockSize=2, format=NCHW', - async () => { - const t = tf.tensor4d([1, 2, 3, 4], [1, 4, 1, 1]); - const blockSize = 2; - const dataFormat = 'NCHW'; - - const res = tf.depthToSpace(t, blockSize, dataFormat); - expect(res.shape).toEqual([1, 1, 2, 2]); - expectArraysClose(await res.data(), [1, 2, 3, 4]); - }); - - it('tensor4d, input shape=[1, 12, 1, 1], blockSize=2, format=NCHW', - async () => { - const t = - tf.tensor4d([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [1, 12, 1, 1]); - const blockSize = 2; - const dataFormat = 'NCHW'; - - const res = tf.depthToSpace(t, blockSize, dataFormat); - expect(res.shape).toEqual([1, 3, 2, 2]); - expectArraysClose( - await res.data(), [1, 4, 7, 10, 2, 5, 8, 11, 3, 6, 9, 12]); - }); - - it('tensor4d, input shape=[1, 4, 2, 2], blockSize=2, format=NCHW', - async () => { - const t = tf.tensor4d( - [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], - [1, 4, 2, 2]); - const blockSize = 2; - const dataFormat = 'NCHW'; - - const res = tf.depthToSpace(t, blockSize, dataFormat); - expect(res.shape).toEqual([1, 1, 4, 4]); - expectArraysClose( - await res.data(), - [1, 5, 2, 6, 9, 13, 10, 14, 3, 7, 4, 8, 11, 15, 12, 16]); - }); - - it('tensor4d, input shape=[1, 8, 2, 2], blockSize=2, format=NCHW', - async () => { - const t = tf.tensor4d( - [ - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, - 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32 - ], - [1, 8, 2, 2]); - const blockSize = 2; - const dataFormat = 'NCHW'; - - const res = tf.depthToSpace(t, blockSize, dataFormat); - expect(res.shape).toEqual([1, 2, 4, 4]); - expectArraysClose(await res.data(), [ - 1, 9, 2, 10, 17, 25, 18, 26, 3, 11, 4, 12, 19, 27, 20, 28, - 5, 13, 6, 14, 21, 29, 22, 30, 7, 15, 8, 16, 23, 31, 24, 32 - ]); - }); -}); - -describeWithFlags('maximum', WEBGL_ENVS, () => { - it('works with squarification for large dimension', async () => { - const maxTextureSize = tf.env().getNumber('WEBGL_MAX_TEXTURE_SIZE'); - tf.env().set('WEBGL_MAX_TEXTURE_SIZE', 5); - const a = - tf.tensor2d([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13], [2, 7]); - const b = - tf.tensor2d([-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [2, 7]); - - const result = tf.maximum(a, b); - tf.env().set('WEBGL_MAX_TEXTURE_SIZE', maxTextureSize); - expectArraysClose( - await result.data(), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]); - }); -}); - -describeWithFlags('div', PACKED_ENVS, () => { - it('works when unused channels are divided', async () => { - // Tests that the 0's in unused channels for input textures do not corrupt - // the result when swizzled with 3 / 3. - const a = tf.tensor2d([1], [1, 1]); - const b = tf.tensor2d([1], [1, 1]); - - const c = tf.add(a, b).div(a); - const d = tf.add(a, b).div(a); - - const result = c.matMul(d); - expectArraysClose(await result.data(), [4]); - }); - - it('works when unused channels in tensors with size > 1 are divided', - async () => { - const a = tf.tensor2d([1, 2, 3], [3, 1]); - const b = tf.tensor2d([1, 2, 3], [3, 1]); - const c = a.div(b); - - const d = tf.tensor1d([1, 2, 3]); - const e = tf.tensor1d([1, 2, 3]); - const f = d.div(e).reshape([1, 3]); - - const result = c.matMul(f); - expectArraysClose(await result.data(), [1, 1, 1, 1, 1, 1, 1, 1, 1]); - }); -}); - -describeWithFlags('conv2d webgl', WEBGL_ENVS, () => { - it('packed input x=[2,1,2] f=[1,1,2,2] s=1 d=1 p=0', async () => { - const inputShape: [number, number, number] = [2, 1, 2]; - const fSize = 1; - const pad = 0; - const stride = 1; - - const x = tf.tensor3d([1, 2, 3, 4], inputShape); - const w = tf.tensor4d([1, 2, 3, 4], [fSize, fSize, 2, 2]); - - const webglLazilyUnpackFlagSaved = tf.env().getBool('WEBGL_LAZILY_UNPACK'); - tf.env().set('WEBGL_LAZILY_UNPACK', true); - const webglPackBinaryOperationsFlagSaved = - tf.env().getBool('WEBGL_PACK_BINARY_OPERATIONS'); - tf.env().set('WEBGL_PACK_BINARY_OPERATIONS', true); - - // First conv2D tests conv2D with non-packed input |x|, and the second uses - // packed input |result|. - const result = tf.conv2d(x, w, stride, pad); - const result1 = tf.conv2d(result, w, stride, pad); - - tf.env().set('WEBGL_LAZILY_UNPACK', webglLazilyUnpackFlagSaved); - tf.env().set( - 'WEBGL_PACK_BINARY_OPERATIONS', webglPackBinaryOperationsFlagSaved); - - expectArraysClose(await result.data(), [7, 10, 15, 22]); - expectArraysClose(await result1.data(), [37, 54, 81, 118]); - }); - - it('tf.memory() packed input x=[1,1,1,2] f=[1,1,2,2] s=1 d=1 p=0', - async () => { - const startNumBytesInGPU = - (tf.memory() as WebGLMemoryInfo).numBytesInGPU; - const startNumBytes = tf.memory().numBytes; - - const inputShape: [number, number, number, number] = [1, 1, 1, 2]; - const fSize = 1; - const pad = 0; - const stride = 1; - - const xInit = tf.tensor4d([0, 1], inputShape); - const w = tf.tensor4d([1, 2, 3, 4], [fSize, fSize, 2, 2]); - - const webglLazilyUnpackFlagSaved = - tf.env().getBool('WEBGL_LAZILY_UNPACK'); - tf.env().set('WEBGL_LAZILY_UNPACK', true); - const webglPackBinaryOperationsFlagSaved = - tf.env().getBool('WEBGL_PACK_BINARY_OPERATIONS'); - tf.env().set('WEBGL_PACK_BINARY_OPERATIONS', true); - - const x = xInit.add(1); - const result = tf.conv2d(x, w, stride, pad); - - tf.env().set('WEBGL_LAZILY_UNPACK', webglLazilyUnpackFlagSaved); - tf.env().set( - 'WEBGL_PACK_BINARY_OPERATIONS', webglPackBinaryOperationsFlagSaved); - - expectArraysClose(await result.data(), [7, 10]); - result.dispose(); - x.dispose(); - xInit.dispose(); - w.dispose(); - expect( - (tf.memory() as WebGLMemoryInfo).numBytesInGPU - startNumBytesInGPU) - .toBe(0); - expect(tf.memory().numBytes - startNumBytes).toBe(0); - }); -}); - -describeWithFlags('conv to matmul', PACKED_ENVS, () => { - it('im2col should not leak memory', () => { - const inputDepth = 1; - const inputShape: [number, number, number] = [2, 2, inputDepth]; - const outputDepth = 1; - const fSize = 2; - const pad = 0; - const stride = 1; - const dataFormat = 'NHWC'; - const dilation = 1; - - const x = tf.tensor3d([1, 2, 3, 4], inputShape); - const w = - tf.tensor4d([3, 1, 5, 0], [fSize, fSize, inputDepth, outputDepth]); - - const startNumBytes = tf.memory().numBytes; - tf.conv2d(x, w, stride, pad, dataFormat, dilation); - const endNumBytes = tf.memory().numBytes; - - expect(endNumBytes - startNumBytes).toEqual(4); - }); - - it('pointwise conv should work when matmul is unpacked', () => { - const inputDepth = - 1001; // this number must be greater than MATMUL_SHARED_DIM_THRESHOLD - // for matmul to be unpacked - const inputShape: [number, number, number] = [3, 3, inputDepth]; - const outputDepth = 1; - const fSize = 1; - const pad = 'same'; - const stride: [number, number] = [1, 1]; - - let x: tf.Tensor3D = tf.randomNormal(inputShape); - x = x.add(1); // this packs x so we can test the case where we mistakenly - // want to avoid expensive reshape in pointwise conv2d even - // though matmul is unpacked - const w: tf.Tensor4D = - tf.randomNormal([fSize, fSize, inputDepth, outputDepth]); - - expect(() => tf.conv2d(x, w, stride, pad)).not.toThrow(); - }); -}); - -// For operations on non-trivial matrix sizes, we skip the CPU-only ENV and use -// only WebGL ENVs. -describeWithFlags('gramSchmidt-non-tiny', WEBGL_ENVS, () => { - it('8x16', async () => { - // Part of this test's point is that operation on a matrix of this size - // can complete in the timeout limit of the unit test. - const xs: Tensor2D = tf.randomUniform([8, 16]); - const y = tf.linalg.gramSchmidt(xs) as Tensor2D; - const yTransposed: Tensor2D = y.transpose(); - expectArraysClose( - await y.matMul(yTransposed).data(), await tf.eye(8).data()); - }); -}); - -describeWithFlags('matmul webgl-only', WEBGL_ENVS, () => { - it('Matrix times vector, large matrix', async () => { - const maxTexSize = 16000; - const sharedDim = maxTexSize + 4; - const matrix = tf.buffer([2, sharedDim], 'float32'); - matrix.set(1, 0, sharedDim - 3); - matrix.set(1, 0, sharedDim - 2); - - const v = tf.buffer([sharedDim], 'float32'); - v.set(1, sharedDim - 3); - v.set(1, sharedDim - 2); - - const result = tf.dot(matrix.toTensor(), v.toTensor()); - const expected = [2, 0]; - expectArraysClose(await result.data(), expected); - }); -}); - -describeWithFlags('matmul', PACKED_ENVS, () => { - it('should not leak memory', () => { - const a = tf.tensor2d([1, 2, 3, 4, 5, 6, 7, 8, 9], [3, 3]); - const b = tf.tensor2d( - [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], [3, 5]); - - const startNumBytes = tf.memory().numBytes; - tf.matMul(a, b); - const endNumBytes = tf.memory().numBytes; - - expect(endNumBytes - startNumBytes).toEqual(60); - }); - - it('should work when input matrix dimensions are not divisible by 2', - async () => { - const a = tf.tensor2d([1, 2, 3, 4, 5, 6, 7, 8, 9], [3, 3]); - const b = tf.tensor2d( - [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], [3, 5]); - - const c = tf.matMul(a, b); - - expect(c.shape).toEqual([3, 5]); - expectArraysClose(await c.data(), [ - 46, 52, 58, 64, 70, 100, 115, 130, 145, 160, 154, 178, 202, 226, 250 - ]); - }); - - it('should work when output texture shape != physical shape', async () => { - const sharedDim = 16000; - const a = tf.buffer([2, sharedDim], 'float32'); - const b = tf.buffer([sharedDim, 2], 'float32'); - - a.set(1, 0, sharedDim - 1); - a.set(1, 0, sharedDim - 2); - a.set(1, 1, sharedDim - 1); - b.set(1, sharedDim - 1, 0); - b.set(1, sharedDim - 2, 0); - - const c = tf.matMul(a.toTensor(), b.toTensor()); - const expected = [2, 0, 1, 0]; - expectArraysClose(await c.data(), expected); - }); - - it('should work when input texture shapes != physical shape', async () => { - const maxTextureSize = tf.env().getNumber('WEBGL_MAX_TEXTURE_SIZE'); - tf.env().set('WEBGL_MAX_TEXTURE_SIZE', 5); - const a = tf.tensor2d([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [1, 12]); - const b = tf.tensor2d([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [12, 1]); - - const c = tf.matMul(a, b); - - tf.env().set('WEBGL_MAX_TEXTURE_SIZE', maxTextureSize); - - expectArraysClose(await c.data(), [572]); - }); - - it('should work when squarification results in zero padding', async () => { - const maxTextureSize = tf.env().getNumber('WEBGL_MAX_TEXTURE_SIZE'); - tf.env().set('WEBGL_MAX_TEXTURE_SIZE', 3); - const a = tf.tensor2d([1, 2], [1, 2]); - const b = tf.tensor2d( - [[0, 1, 2, 3, 4, 5, 6, 7, 8], [9, 10, 11, 12, 13, 14, 15, 16, 17]]); - - const c = tf.matMul(a, b); - - tf.env().set('WEBGL_MAX_TEXTURE_SIZE', maxTextureSize); - - expectArraysClose(await c.data(), [18, 21, 24, 27, 30, 33, 36, 39, 42]); - }); - - it('A x B', async () => { - const a = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - const b = tf.tensor2d([0, 1, -3, 2, 2, 1], [3, 2]); - - const c = tf.matMul(a, b); - - expect(c.shape).toEqual([2, 2]); - expectArraysClose(await c.data(), [0, 8, -3, 20]); - }); - - it('A x B^t', async () => { - const a = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - const b = tf.tensor2d([1, 0, 2, 4, 3, 0], [2, 3]); - - const transposeA = false; - const transposeB = true; - const c = tf.matMul(a, b, transposeA, transposeB); - - const expected = [7, 10, 16, 31]; - expectArraysClose(await c.data(), expected); - }); - - it('A^t x B', async () => { - const a = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - const b = tf.tensor2d([1, 0, 2, 4, 3, 0], [2, 3]); - - const transposeA = true; - const transposeB = false; - const c = tf.matMul(a, b, transposeA, transposeB); - - const expected = [17, 12, 2, 22, 15, 4, 27, 18, 6]; - expectArraysClose(await c.data(), expected); - }); - - it('A^t x B^t', async () => { - const a = tf.tensor2d([1, 2, 3, 4, 5, 6], [3, 2]); - const b = tf.tensor2d([1, 0, 2, 4, 3, 0], [2, 3]); - - const transposeA = true; - const transposeB = true; - const c = tf.matMul(a, b, transposeA, transposeB); - - const expected = [11, 13, 14, 20]; - expectArraysClose(await c.data(), expected); - }); - - it('works when followed by an op that requires unpacked inputs', async () => { - const a = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - const b = tf.tensor2d([0, 1, -3, 2, 2, 1], [3, 2]); - - const c = tf.matMul(a, b); - - const webglPackBinarySaved = - tf.env().getBool('WEBGL_PACK_BINARY_OPERATIONS'); - tf.env().set('WEBGL_PACK_BINARY_OPERATIONS', false); - const d = tf.add(c, 1); - tf.env().set('WEBGL_PACK_BINARY_OPERATIONS', webglPackBinarySaved); - - expectArraysClose(await d.data(), [1, 9, -2, 21]); - }); - - // tslint:disable-next-line:max-line-length - it('works when followed by a packed reshape that changes texture layout, and then an unpacked op', - async () => { - const a = tf.tensor2d([1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 1]); - const b = tf.tensor2d([1], [1, 1]); - const c = tf.matMul(a, b); - - const d = tf.reshape(c, [1, 3, 3, 1]); - - const webglPackBinarySaved = - tf.env().getBool('WEBGL_PACK_BINARY_OPERATIONS'); - tf.env().set('WEBGL_PACK_BINARY_OPERATIONS', false); - const e = tf.add(d, 1); - tf.env().set('WEBGL_PACK_BINARY_OPERATIONS', webglPackBinarySaved); - - expectArraysClose(await e.data(), [2, 3, 4, 5, 6, 7, 8, 9, 10]); - }); - - it('works when preceded by an op that requires packed inputs', async () => { - const a = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - const b = tf.tensor2d([0, 1, -3, 2, 2, 1], [3, 2]); - - const c = tf.add(a, 1); - const d = tf.matMul(b, c); - - expectArraysClose(await d.data(), [5, 6, 7, 4, 3, 2, 9, 12, 15]); - }); -}); - -describeWithFlags('Reduction: webgl packed input', WEBGL_ENVS, () => { - it('argmax 3D, odd number of rows, axis = -1', async () => { - const webglLazilyUnpackFlagSaved = tf.env().getBool('WEBGL_LAZILY_UNPACK'); - tf.env().set('WEBGL_LAZILY_UNPACK', true); - const webglPackBinaryOperationsFlagSaved = - tf.env().getBool('WEBGL_PACK_BINARY_OPERATIONS'); - tf.env().set('WEBGL_PACK_BINARY_OPERATIONS', true); - - const a = tf.tensor3d([3, 2, 5, 100, -7, 2], [2, 1, 3]).add(1); - const r = tf.argMax(a, -1); - tf.env().set('WEBGL_LAZILY_UNPACK', webglLazilyUnpackFlagSaved); - tf.env().set( - 'WEBGL_PACK_BINARY_OPERATIONS', webglPackBinaryOperationsFlagSaved); - - expect(r.dtype).toBe('int32'); - expectArraysEqual(await r.data(), [2, 0]); - }); - - it('argmin 4D, odd number of rows, axis = -1', async () => { - const webglLazilyUnpackFlagSaved = tf.env().getBool('WEBGL_LAZILY_UNPACK'); - tf.env().set('WEBGL_LAZILY_UNPACK', true); - const webglPackBinaryOperationsFlagSaved = - tf.env().getBool('WEBGL_PACK_BINARY_OPERATIONS'); - tf.env().set('WEBGL_PACK_BINARY_OPERATIONS', true); - - const a = - tf.tensor4d( - [3, 2, 5, 100, -7, 2, 8, 7, -5, 101, 7, -2, 100, -7, 2, 8, 7, -5], - [1, 2, 3, 3]) - .add(1); - const r = tf.argMin(a, -1); - tf.env().set('WEBGL_LAZILY_UNPACK', webglLazilyUnpackFlagSaved); - tf.env().set( - 'WEBGL_PACK_BINARY_OPERATIONS', webglPackBinaryOperationsFlagSaved); - - expect(r.dtype).toBe('int32'); - expectArraysEqual(await r.data(), [1, 1, 2, 2, 1, 2]); - }); - - it('should not leak memory when called after unpacked op', async () => { - const webglPackBinaryOperationsFlagSaved = - tf.env().getBool('WEBGL_PACK_BINARY_OPERATIONS'); - tf.env().set('WEBGL_PACK_BINARY_OPERATIONS', false); - - const a = - tf.tensor5d( - [3, 2, 5, 100, -7, 2, 8, 7, -5, 101, 7, -2, 100, -7, 2, 8, 7, -5], - [1, 2, 3, 1, 3]) - .add(1); - const startNumBytes = tf.memory().numBytes; - const startNumTensors = tf.memory().numTensors; - const r = tf.argMin(a, -1); - tf.env().set( - 'WEBGL_PACK_BINARY_OPERATIONS', webglPackBinaryOperationsFlagSaved); - const endNumBytes = tf.memory().numBytes; - const endNumTensors = tf.memory().numTensors; - expect(endNumBytes - startNumBytes).toEqual(24); - expect(endNumTensors - startNumTensors).toEqual(1); - expect(r.dtype).toBe('int32'); - expectArraysEqual(await r.data(), [1, 1, 2, 2, 1, 2]); - }); -}); - -describeWithFlags('slice and memory usage', WEBGL_ENVS, () => { - let webglUploadUniformFlagSaved: boolean; - let webglCpuForwardFlagSaved: boolean; - beforeAll(() => { - webglUploadUniformFlagSaved = tf.env().getBool('WEBGL_SIZE_UPLOAD_UNIFORM'); - webglCpuForwardFlagSaved = tf.env().getBool('WEBGL_CPU_FORWARD'); - tf.env().set('WEBGL_SIZE_UPLOAD_UNIFORM', 0); - tf.env().set('WEBGL_CPU_FORWARD', false); - }); - - afterAll(() => { - tf.env().set('WEBGL_SIZE_UPLOAD_UNIFORM', webglUploadUniformFlagSaved); - tf.env().set('WEBGL_CPU_FORWARD', webglCpuForwardFlagSaved); - }); - - it('slice a tensor, read it and check memory', async () => { - const getMem = () => tf.memory() as WebGLMemoryInfo; - expect(getMem().numBytesInGPU).toBe(0); - - // Lazy upload won't increase gpu memory. - const a = tf.tensor([2, 3]); - expect(getMem().numBytesInGPU).toBe(0); - - // Upload a to the GPU by running an op. - a.square().dispose(); - expect(getMem().numBytesInGPU).toBe(8); - - // Slicing does not allocate new memory. - const b = a.slice(0); - expect(getMem().numBytesInGPU).toBe(8); - - // Download a to the CPU but the texture remains on GPU - // since b points to it. - await a.data(); - expect(getMem().numBytesInGPU).toBe(8); - - // Dispose a, but the texture should still remain on the GPU - // since b points to it. - a.dispose(); - expect(getMem().numBytesInGPU).toBe(8); - - // Dispose b and expect 0 memory on GPU. - b.dispose(); - expect(getMem().numBytesInGPU).toBe(0); - }); - - it('slice a tensor twice, read it and check memory', async () => { - const getMem = () => tf.memory() as WebGLMemoryInfo; - expect(getMem().numBytesInGPU).toBe(0); - - // Lazy upload won't increase gpu memory. - const a = tf.tensor([2, 3]); - expect(getMem().numBytesInGPU).toBe(0); - - // Upload a to the GPU by running an op. - a.square().dispose(); - expect(getMem().numBytesInGPU).toBe(8); - - // Slicing does not allocate new memory. - const b = a.slice(0); - const c = a.slice(0); - expect(getMem().numBytesInGPU).toBe(8); - - // Download a to the CPU but the texture remains on GPU - // since b points to it. - await a.data(); - expect(getMem().numBytesInGPU).toBe(8); - - // Dispose a, but the texture should still remain on the GPU - // since b points to it. - a.dispose(); - expect(getMem().numBytesInGPU).toBe(8); - - // Dispose b, but the texture should still remain on the GPU - // since c points to it. - b.dispose(); - expect(getMem().numBytesInGPU).toBe(8); - - // Download c to the CPU but the texture remains on GPU - // since c points to it. - await c.data(); - expect(getMem().numBytesInGPU).toBe(8); - - // Dispose c and expect 0 memory on GPU. - c.dispose(); - expect(getMem().numBytesInGPU).toBe(0); - }); - - it('slice a sliced tensor, read it and check memory', async () => { - const getMem = () => tf.memory() as WebGLMemoryInfo; - expect(getMem().numBytesInGPU).toBe(0); - - // Lazy upload won't increase gpu memory. - const a = tf.tensor([2, 3]); - expect(getMem().numBytesInGPU).toBe(0); - - // Upload a to the GPU by running an op. - a.square().dispose(); - expect(getMem().numBytesInGPU).toBe(8); - - // Slicing does not allocate new memory. - const b = a.slice(0); - const c = b.slice(0); - expect(getMem().numBytesInGPU).toBe(8); - - // Download a to the CPU but the texture remains on GPU - // since b points to it. - await a.data(); - expect(getMem().numBytesInGPU).toBe(8); - - // Dispose a, but the texture should still remain on the GPU - // since b points to it. - a.dispose(); - expect(getMem().numBytesInGPU).toBe(8); - - // Dispose b, but the texture should still remain on the GPU - // since c points to it. - b.dispose(); - expect(getMem().numBytesInGPU).toBe(8); - - // Download c to the CPU but the texture remains on GPU - // since c points to it. - await c.data(); - expect(getMem().numBytesInGPU).toBe(8); - - // Dispose c and expect 0 memory on GPU. - c.dispose(); - expect(getMem().numBytesInGPU).toBe(0); - }); -}); - -describeWithFlags('slice a packed texture', WEBGL_ENVS, () => { - beforeAll(() => { - tf.env().set('WEBGL_PACK', true); - }); - - it('slice after a matmul', async () => { - const a = [[1, 2], [3, 4]]; - const b = [[5, 6], [7, 8]]; - // Matmul gives a packed tensor in webgl. - // [19, 22] - // [43, 50] - const c = tf.matMul(a, b); - expectArraysClose(await c.slice([0, 0]).data(), [19, 22, 43, 50]); - expectArraysClose(await c.slice([0, 1]).data(), [22, 50]); - expectArraysClose(await c.slice([1, 0]).data(), [43, 50]); - expectArraysClose(await c.slice([1, 1]).data(), [50]); - }); -}); - -describeWithFlags('pointwise conv2d packed', WEBGL_ENVS, () => { - beforeAll(() => { - tf.env().set('WEBGL_SIZE_UPLOAD_UNIFORM', 0); - }); - - it('pointwise conv2d optimization with odd input size', async () => { - // We do special optimization in the webl backend which avoids an expensive - // reshape, when the following 3 conditions are met: - // 1) the input width/height is odd-shaped. - // 2) the input is already packed. - // 3) the filter size is 1x1, i.e. pointwise. - const inChannels = 1; - const outChannels = 2; - const oddInputSize = 3; - const x: Tensor3D = tf.ones([oddInputSize, oddInputSize, inChannels]); - const xPacked = tf.relu(x); - const pointwiseFilter: Tensor4D = tf.ones([1, 1, inChannels, outChannels]); - const strides = 1; - const pad = 'same'; - const c = tf.conv2d(xPacked, pointwiseFilter, strides, pad); - expectArraysClose( - await c.data(), [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]); - }); -}); - -describeWithFlags('relu', WEBGL_ENVS, () => { - it('works with squarification for prime number length vector', async () => { - const maxTextureSize = tf.env().getNumber('WEBGL_MAX_TEXTURE_SIZE'); - tf.env().set('WEBGL_MAX_TEXTURE_SIZE', 5); - const a = tf.tensor1d([1, -2, 5, -3, -1, 4, 7]); - const result = tf.relu(a); - - tf.env().set('WEBGL_MAX_TEXTURE_SIZE', maxTextureSize); - expectArraysClose(await result.data(), [1, 0, 5, 0, 0, 4, 7]); - }); -}); - -describeWithFlags('packed clip', PACKED_ENVS, () => { - it('should not leak memory', () => { - const a = tf.tensor1d([3, -1, 0, 100, -7, 2]); - const min = -1; - const max = 50; - - const startNumBytes = tf.memory().numBytes; - const startNumTensors = tf.memory().numTensors; - tf.clipByValue(a, min, max); - const endNumBytes = tf.memory().numBytes; - const endNumTensors = tf.memory().numTensors; - - expect(endNumBytes - startNumBytes).toEqual(24); - expect(endNumTensors - startNumTensors).toEqual(1); - }); - - it('basic', async () => { - const a = tf.tensor1d([3, -1, 0, 100, -7, 2]); - const min = -1; - const max = 50; - - const result = tf.clipByValue(a, min, max); - - expectArraysClose(await result.data(), [3, -1, 0, 50, -1, 2]); - }); - - it('using extreme values', async () => { - const a = tf.tensor1d([3, -1, 0, 100, -7, 2]); - let result = - tf.clipByValue(a, Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY); - expectArraysClose(await result.data(), [3, -1, 0, 100, -7, 2]); - - result = tf.clipByValue(a, Number.MIN_VALUE, Number.MAX_VALUE); - expectArraysClose( - await result.data(), - [3, Number.MIN_VALUE, Number.MIN_VALUE, 100, Number.MIN_VALUE, 2]); - }); - - it('should work for scalars', async () => { - const a = tf.scalar(-4); - const min = -1; - const max = 50; - - const result = tf.clipByValue(a, min, max); - - expectArraysClose(await result.data(), [min]); - }); - - it('derivative: 1D tensor with max or min value', async () => { - const min = -1; - const max = 2; - const x = tf.tensor1d([-1, 1, 2, 3]); - const dy = tf.tensor1d([1, 10, 100, 1000]); - const gradients = tf.grad(x => x.clipByValue(min, max))(x, dy); - - expect(gradients.shape).toEqual(x.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), [1, 10, 100, 0]); - }); -}); - -describeWithFlags('depthwiseConv2d packed', PACKED_ENVS, () => { - it('should not leak memory', () => { - const x = tf.tensor4d( - [ - 0.230664, 0.987388, 0.0685208, 0.419224, 0.887861, 0.731641, - 0.0741907, 0.409265, 0.351377 - ], - [1, 3, 3, 1]); - const w = tf.tensor4d( - [0.303873, 0.229223, 0.144333, 0.803373], - [2, 2, 1, 1], - ); - - const startNumBytes = tf.memory().numBytes; - const startNumTensors = tf.memory().numTensors; - - tf.depthwiseConv2d(x, w, 1, 'valid'); - - const endNumBytes = tf.memory().numBytes; - const endNumTensors = tf.memory().numTensors; - - expect(endNumBytes - startNumBytes).toEqual(16); - expect(endNumTensors - startNumTensors).toEqual(1); - }); -}); - -describeWithFlags('gather debug', WEBGL_ENVS, () => { - it('throws if index is out of bound if in debug mode', async () => { - const t = tf.tensor2d([1, 11, 2, 22], [2, 2]); - tf.enableDebugMode(); - expect(() => tf.gather(t, tf.tensor1d([100], 'int32'))) - .toThrowError(/GatherV2: the index value 100 is not in \[0, 1\]/); - expect(() => tf.gather(t, tf.tensor1d([-1], 'int32'))) - .toThrowError(/GatherV2: the index value -1 is not in \[0, 1\]/); - }); -}); - -describeWithFlags('gatherNd', WEBGL_ENVS, () => { - let webglCpuForwardFlagSaved: boolean; - beforeAll(() => { - webglCpuForwardFlagSaved = tf.env().getBool('WEBGL_CPU_FORWARD'); - tf.env().set('WEBGL_CPU_FORWARD', false); - }); - - afterAll(() => { - tf.env().set('WEBGL_CPU_FORWARD', webglCpuForwardFlagSaved); - }); - it('throws for zero-rank input', async () => { - const x = tf.scalar(5, 'int32'); - const ind = tf.tensor1d([5, 2, 1], 'int32'); - expect(() => tf.gatherND(x, ind)) - .toThrowError( - /expects the input to be rank 1 or higher, but the rank was 0/); - }); - - it('works for out of bounds indices', async () => { - const x = tf.tensor1d([1, 2], 'int32'); - const ind = tf.tensor2d([-1, 0, 1, 2], [4, 1], 'int32'); - const g = tf.gatherND(x, ind); - expectArraysEqual(await g.data(), [0, 1, 2, 0]); - }); - - it('works for out of bounds indices 1d', async () => { - const x = tf.tensor1d([...Array(4).keys()].map(e => e + 1), 'int32'); - const indices = [0, 1, 2, 5]; - const ind = tf.tensor2d(indices, [4, 1], 'int32'); - const g = tf.gatherND(x, ind); - const expected = [1, 2, 3, 0]; - expectArraysEqual(await g.data(), expected); - }); - - it('works for out of bounds indices 2d', async () => { - const x = - tf.tensor2d([...Array(4).keys()].map(e => e + 1), [2, 2], 'int32'); - const indices = []; - for (let y = -1; y !== 3; y += 1) { - for (let x = -1; x !== 3; x += 1) { - indices.push(y); - indices.push(x); - } - } - const ind = tf.tensor2d(indices, [16, 2], 'int32'); - const g = tf.gatherND(x, ind); - const expected = [0, 0, 0, 0, 0, 1, 2, 0, 0, 3, 4, 0, 0, 0, 0, 0]; - expect(g.shape).toEqual([16]); - expectArraysEqual(await g.data(), expected); - }); - - it('works for out of bounds indices 3d', async () => { - const x = - tf.tensor3d([...Array(8).keys()].map(e => e + 1), [2, 2, 2], 'int32'); - const indices = []; - for (let z = -1; z !== 3; z += 1) { - for (let y = -1; y !== 3; y += 1) { - for (let x = -1; x !== 3; x += 1) { - indices.push(z); - indices.push(y); - indices.push(x); - } - } - } - const ind = tf.tensor2d(indices, [64, 3], 'int32'); - const g = tf.gatherND(x, ind); - const expected = [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, - 2, 0, 0, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 6, 0, 0, 7, 8, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ]; - expectArraysEqual(await g.data(), expected); - }); - - it('works for out of bounds indices 5d', async () => { - const x = tf.tensor5d( - [...Array(32).keys()].map(e => e + 1), [2, 2, 2, 2, 2], 'int32'); - const indices = [0, 0, 0, 0, 0, 2, 1, 1, 1, 1]; - const ind = tf.tensor2d(indices, [2, 5], 'int32'); - const g = tf.gatherND(x, ind); - const expected = [1, 0]; - expectArraysEqual(await g.data(), expected); - }); -}); diff --git a/tfjs-master/tfjs-backend-webgl/src/webgl_topixels_test.ts b/tfjs-master/tfjs-backend-webgl/src/webgl_topixels_test.ts deleted file mode 100644 index e0dc2bb91..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/webgl_topixels_test.ts +++ /dev/null @@ -1,41 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '@tensorflow/tfjs-core'; -// tslint:disable-next-line: no-imports-from-dist -import {describeWithFlags} from '@tensorflow/tfjs-core/dist/jasmine_util'; - -import {WebGLMemoryInfo} from './backend_webgl'; -import {WEBGL_ENVS} from './backend_webgl_test_registry'; - -describeWithFlags('toPixels', WEBGL_ENVS, () => { - it('does not leak memory', async () => { - const x = tf.tensor2d([[.1], [.2]], [2, 1]); - const startNumBytesInGPU = (tf.memory() as WebGLMemoryInfo).numBytesInGPU; - await tf.browser.toPixels(x); - expect((tf.memory() as WebGLMemoryInfo).numBytesInGPU) - .toEqual(startNumBytesInGPU); - }); - - it('does not leak memory given a tensor-like object', async () => { - const x = [[10], [20]]; // 2x1; - const startNumBytesInGPU = (tf.memory() as WebGLMemoryInfo).numBytesInGPU; - await tf.browser.toPixels(x); - expect((tf.memory() as WebGLMemoryInfo).numBytesInGPU) - .toEqual(startNumBytesInGPU); - }); -}); diff --git a/tfjs-master/tfjs-backend-webgl/src/webgl_types.ts b/tfjs-master/tfjs-backend-webgl/src/webgl_types.ts deleted file mode 100644 index 2e340eef9..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/webgl_types.ts +++ /dev/null @@ -1,50 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// TODO(nsthorat): Move these to the webgl official typings. -export interface WebGL2DisjointQueryTimerExtension { - TIME_ELAPSED_EXT: number; - GPU_DISJOINT_EXT: number; -} - -export interface WebGL1DisjointQueryTimerExtension { - TIME_ELAPSED_EXT: number; - QUERY_RESULT_AVAILABLE_EXT: number; - GPU_DISJOINT_EXT: number; - QUERY_RESULT_EXT: number; - createQueryEXT: () => {}; - beginQueryEXT: (ext: number, query: WebGLQuery) => void; - endQueryEXT: (ext: number) => void; - deleteQueryEXT: (query: WebGLQuery) => void; - isQueryEXT: (query: WebGLQuery) => boolean; - getQueryObjectEXT: - (query: WebGLQuery, queryResultAvailableExt: number) => number; -} - -export interface WebGLContextAttributes { - alpha?: boolean; - antialias?: boolean; - premultipliedAlpha?: boolean; - preserveDrawingBuffer?: boolean; - depth?: boolean; - stencil?: boolean; - failIfMajorPerformanceCaveat?: boolean; -} - -export interface WebGLParallelCompilationExtension { - COMPLETION_STATUS_KHR: number; -} diff --git a/tfjs-master/tfjs-backend-webgl/src/webgl_util.ts b/tfjs-master/tfjs-backend-webgl/src/webgl_util.ts deleted file mode 100644 index b9c621585..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/webgl_util.ts +++ /dev/null @@ -1,723 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {env, TensorInfo, util} from '@tensorflow/tfjs-core'; - -import {getWebGLContext} from './canvas_util'; -import {getTextureConfig} from './tex_util'; - -export function callAndCheck(gl: WebGLRenderingContext, func: () => T): T { - const returnValue = func(); - if (env().getBool('DEBUG')) { - checkWebGLError(gl); - } - return returnValue; -} - -function checkWebGLError(gl: WebGLRenderingContext) { - const error = gl.getError(); - if (error !== gl.NO_ERROR) { - throw new Error('WebGL Error: ' + getWebGLErrorMessage(gl, error)); - } -} - -// https://en.wikipedia.org/wiki/Half-precision_floating-point_format -const MIN_FLOAT16 = 5.96e-8; -const MAX_FLOAT16 = 65504; - -export function canBeRepresented(num: number): boolean { - if (env().getBool('WEBGL_RENDER_FLOAT32_ENABLED') || num === 0 || - (MIN_FLOAT16 < Math.abs(num) && Math.abs(num) < MAX_FLOAT16)) { - return true; - } - return false; -} - -export function getWebGLErrorMessage( - gl: WebGLRenderingContext, status: number): string { - switch (status) { - case gl.NO_ERROR: - return 'NO_ERROR'; - case gl.INVALID_ENUM: - return 'INVALID_ENUM'; - case gl.INVALID_VALUE: - return 'INVALID_VALUE'; - case gl.INVALID_OPERATION: - return 'INVALID_OPERATION'; - case gl.INVALID_FRAMEBUFFER_OPERATION: - return 'INVALID_FRAMEBUFFER_OPERATION'; - case gl.OUT_OF_MEMORY: - return 'OUT_OF_MEMORY'; - case gl.CONTEXT_LOST_WEBGL: - return 'CONTEXT_LOST_WEBGL'; - default: - return `Unknown error code ${status}`; - } -} - -export function getExtensionOrThrow( - gl: WebGLRenderingContext, extensionName: string): {} { - return throwIfNull<{}>( - gl, () => gl.getExtension(extensionName), - 'Extension "' + extensionName + '" not supported on this browser.'); -} - -export function createVertexShader( - gl: WebGLRenderingContext, vertexShaderSource: string): WebGLShader { - const vertexShader: WebGLShader = throwIfNull( - gl, () => gl.createShader(gl.VERTEX_SHADER), - 'Unable to create vertex WebGLShader.'); - callAndCheck(gl, () => gl.shaderSource(vertexShader, vertexShaderSource)); - callAndCheck(gl, () => gl.compileShader(vertexShader)); - if (gl.getShaderParameter(vertexShader, gl.COMPILE_STATUS) === false) { - console.log(gl.getShaderInfoLog(vertexShader)); - throw new Error('Failed to compile vertex shader.'); - } - return vertexShader; -} - -export function createFragmentShader( - gl: WebGLRenderingContext, fragmentShaderSource: string): WebGLShader { - const fragmentShader: WebGLShader = throwIfNull( - gl, () => gl.createShader(gl.FRAGMENT_SHADER), - 'Unable to create fragment WebGLShader.'); - callAndCheck(gl, () => gl.shaderSource(fragmentShader, fragmentShaderSource)); - callAndCheck(gl, () => gl.compileShader(fragmentShader)); - if (env().get('ENGINE_COMPILE_ONLY')) { - return fragmentShader; - } - if (gl.getShaderParameter(fragmentShader, gl.COMPILE_STATUS) === false) { - logShaderSourceAndInfoLog( - fragmentShaderSource, gl.getShaderInfoLog(fragmentShader)); - throw new Error('Failed to compile fragment shader.'); - } - return fragmentShader; -} - -const lineNumberRegex = /ERROR: [0-9]+:([0-9]+):/g; -export function logShaderSourceAndInfoLog( - shaderSource: string, shaderInfoLog: string) { - const lineNumberRegexResult = lineNumberRegex.exec(shaderInfoLog); - if (lineNumberRegexResult == null) { - console.log(`Couldn't parse line number in error: ${shaderInfoLog}`); - console.log(shaderSource); - return; - } - - const lineNumber = +lineNumberRegexResult[1]; - - const shaderLines = shaderSource.split('\n'); - const pad = shaderLines.length.toString().length + 2; - const linesWithLineNumbers = shaderLines.map( - (line, lineNumber) => - util.rightPad((lineNumber + 1).toString(), pad) + line); - let maxLineLength = 0; - for (let i = 0; i < linesWithLineNumbers.length; i++) { - maxLineLength = Math.max(linesWithLineNumbers[i].length, maxLineLength); - } - - const beforeErrorLines = linesWithLineNumbers.slice(0, lineNumber - 1); - const errorLine = linesWithLineNumbers.slice(lineNumber - 1, lineNumber); - const afterErrorLines = linesWithLineNumbers.slice(lineNumber); - - console.log(beforeErrorLines.join('\n')); - console.log(shaderInfoLog.split('\n')[0]); - console.log( - `%c ${util.rightPad(errorLine[0], maxLineLength)}`, - 'border:1px solid red; background-color:#e3d2d2; color:#a61717'); - console.log(afterErrorLines.join('\n')); -} - -export function createProgram(gl: WebGLRenderingContext): WebGLProgram { - return throwIfNull( - gl, () => gl.createProgram(), 'Unable to create WebGLProgram.'); -} - -export function linkProgram(gl: WebGLRenderingContext, program: WebGLProgram) { - callAndCheck(gl, () => gl.linkProgram(program)); - if (env().get('ENGINE_COMPILE_ONLY')) { - return; - } - if (gl.getProgramParameter(program, gl.LINK_STATUS) === false) { - console.log(gl.getProgramInfoLog(program)); - throw new Error('Failed to link vertex and fragment shaders.'); - } -} - -/// validateProgram is effectively "If we `useProgram(program); drawArrays();`, -/// give feedback in log about perf/correctness warnings or errors that would -/// occur." -/// So make sure we set up all vertex/texture/sampler/uniform data before -/// calling validateProgram! -export function validateProgram( - gl: WebGLRenderingContext, program: WebGLProgram) { - callAndCheck(gl, () => gl.validateProgram(program)); - if (gl.getProgramParameter(program, gl.VALIDATE_STATUS) === false) { - console.log(gl.getProgramInfoLog(program)); - throw new Error('Shader program validation failed.'); - } -} - -export function createStaticVertexBuffer( - gl: WebGLRenderingContext, data: Float32Array): WebGLBuffer { - const buffer: WebGLBuffer = throwIfNull( - gl, () => gl.createBuffer(), 'Unable to create WebGLBuffer'); - callAndCheck(gl, () => gl.bindBuffer(gl.ARRAY_BUFFER, buffer)); - callAndCheck(gl, () => gl.bufferData(gl.ARRAY_BUFFER, data, gl.STATIC_DRAW)); - return buffer; -} - -export function createStaticIndexBuffer( - gl: WebGLRenderingContext, data: Uint16Array): WebGLBuffer { - const buffer: WebGLBuffer = throwIfNull( - gl, () => gl.createBuffer(), 'Unable to create WebGLBuffer'); - callAndCheck(gl, () => gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, buffer)); - callAndCheck( - gl, () => gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, data, gl.STATIC_DRAW)); - return buffer; -} - -export function getNumChannels(): number { - if (env().getNumber('WEBGL_VERSION') === 2) { - return 1; - } - return 4; -} - -export function createTexture(gl: WebGLRenderingContext): WebGLTexture { - return throwIfNull( - gl, () => gl.createTexture(), 'Unable to create WebGLTexture.'); -} - -export function validateTextureSize(width: number, height: number) { - const maxTextureSize = env().getNumber('WEBGL_MAX_TEXTURE_SIZE'); - if ((width <= 0) || (height <= 0)) { - const requested = `[${width}x${height}]`; - throw new Error('Requested texture size ' + requested + ' is invalid.'); - } - if ((width > maxTextureSize) || (height > maxTextureSize)) { - const requested = `[${width}x${height}]`; - const max = `[${maxTextureSize}x${maxTextureSize}]`; - throw new Error( - 'Requested texture size ' + requested + - ' greater than WebGL maximum on this browser / GPU ' + max + '.'); - } -} - -export function createFramebuffer(gl: WebGLRenderingContext): WebGLFramebuffer { - return throwIfNull( - gl, () => gl.createFramebuffer(), 'Unable to create WebGLFramebuffer.'); -} - -export function bindVertexBufferToProgramAttribute( - gl: WebGLRenderingContext, program: WebGLProgram, attribute: string, - buffer: WebGLBuffer, arrayEntriesPerItem: number, itemStrideInBytes: number, - itemOffsetInBytes: number): boolean { - const loc = gl.getAttribLocation(program, attribute); - if (loc === -1) { - // The GPU compiler decided to strip out this attribute because it's unused, - // thus no need to bind. - return false; - } - callAndCheck(gl, () => gl.bindBuffer(gl.ARRAY_BUFFER, buffer)); - callAndCheck( - gl, - () => gl.vertexAttribPointer( - loc, arrayEntriesPerItem, gl.FLOAT, false, itemStrideInBytes, - itemOffsetInBytes)); - callAndCheck(gl, () => gl.enableVertexAttribArray(loc)); - return true; -} - -export function bindTextureUnit( - gl: WebGLRenderingContext, texture: WebGLTexture, textureUnit: number) { - validateTextureUnit(gl, textureUnit); - callAndCheck(gl, () => gl.activeTexture(gl.TEXTURE0 + textureUnit)); - callAndCheck(gl, () => gl.bindTexture(gl.TEXTURE_2D, texture)); -} - -export function unbindTextureUnit( - gl: WebGLRenderingContext, textureUnit: number) { - validateTextureUnit(gl, textureUnit); - callAndCheck(gl, () => gl.activeTexture(gl.TEXTURE0 + textureUnit)); - callAndCheck(gl, () => gl.bindTexture(gl.TEXTURE_2D, null)); -} - -export function getProgramUniformLocationOrThrow( - gl: WebGLRenderingContext, program: WebGLProgram, - uniformName: string): WebGLUniformLocation { - return throwIfNull( - gl, () => gl.getUniformLocation(program, uniformName), - 'uniform "' + uniformName + '" not present in program.'); -} - -export function getProgramUniformLocation( - gl: WebGLRenderingContext, program: WebGLProgram, - uniformName: string): WebGLUniformLocation { - return gl.getUniformLocation(program, uniformName); -} - -export function bindTextureToProgramUniformSampler( - gl: WebGLRenderingContext, texture: WebGLTexture, - uniformSamplerLocation: WebGLUniformLocation, textureUnit: number) { - callAndCheck(gl, () => bindTextureUnit(gl, texture, textureUnit)); - callAndCheck(gl, () => gl.uniform1i(uniformSamplerLocation, textureUnit)); -} - -export function bindCanvasToFramebuffer(gl: WebGLRenderingContext) { - callAndCheck(gl, () => gl.bindFramebuffer(gl.FRAMEBUFFER, null)); - callAndCheck(gl, () => gl.viewport(0, 0, gl.canvas.width, gl.canvas.height)); - callAndCheck(gl, () => gl.scissor(0, 0, gl.canvas.width, gl.canvas.height)); -} - -export function bindColorTextureToFramebuffer( - gl: WebGLRenderingContext, texture: WebGLTexture, - framebuffer: WebGLFramebuffer) { - callAndCheck(gl, () => gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer)); - callAndCheck( - gl, - () => gl.framebufferTexture2D( - gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0)); -} - -export function unbindColorTextureFromFramebuffer( - gl: WebGLRenderingContext, framebuffer: WebGLFramebuffer) { - callAndCheck(gl, () => gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer)); - callAndCheck( - gl, - () => gl.framebufferTexture2D( - gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, null, 0)); -} - -export function validateFramebuffer(gl: WebGLRenderingContext) { - const status = gl.checkFramebufferStatus(gl.FRAMEBUFFER); - if (status !== gl.FRAMEBUFFER_COMPLETE) { - throw new Error( - 'Error binding framebuffer: ' + getFramebufferErrorMessage(gl, status)); - } -} - -export function getFramebufferErrorMessage( - gl: WebGLRenderingContext, status: number): string { - switch (status) { - case gl.FRAMEBUFFER_INCOMPLETE_ATTACHMENT: - return 'FRAMEBUFFER_INCOMPLETE_ATTACHMENT'; - case gl.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: - return 'FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT'; - case gl.FRAMEBUFFER_INCOMPLETE_DIMENSIONS: - return 'FRAMEBUFFER_INCOMPLETE_DIMENSIONS'; - case gl.FRAMEBUFFER_UNSUPPORTED: - return 'FRAMEBUFFER_UNSUPPORTED'; - default: - return `unknown error ${status}`; - } -} - -function throwIfNull( - gl: WebGLRenderingContext, returnTOrNull: () => T | null, - failureMessage: string): T { - const tOrNull: T|null = callAndCheck(gl, () => returnTOrNull()); - if (tOrNull == null) { - throw new Error(failureMessage); - } - return tOrNull; -} - -function validateTextureUnit(gl: WebGLRenderingContext, textureUnit: number) { - const maxTextureUnit = gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS - 1; - const glTextureUnit = textureUnit + gl.TEXTURE0; - if (glTextureUnit < gl.TEXTURE0 || glTextureUnit > maxTextureUnit) { - const textureUnitRange = `[gl.TEXTURE0, gl.TEXTURE${maxTextureUnit}]`; - throw new Error(`textureUnit must be in ${textureUnitRange}.`); - } -} - -export function getBatchDim(shape: number[], dimsToSkip = 2): number { - return util.sizeFromShape(shape.slice(0, shape.length - dimsToSkip)); -} - -export function getRowsCols(shape: number[]): [number, number] { - if (shape.length === 0) { - throw Error('Cannot get rows and columns of an empty shape array.'); - } - - return [ - shape.length > 1 ? shape[shape.length - 2] : 1, shape[shape.length - 1] - ]; -} - -export function getShapeAs3D(shape: number[]): [number, number, number] { - let shapeAs3D: [number, number, number] = [1, 1, 1]; - const isScalar = shape.length === 0 || (shape.length === 1 && shape[0] === 1); - if (!isScalar) { - shapeAs3D = - [getBatchDim(shape), ...getRowsCols(shape)] as [number, number, number]; - } - return shapeAs3D; -} - -export function getTextureShapeFromLogicalShape( - logShape: number[], isPacked = false): [number, number] { - let maxTexSize = env().getNumber('WEBGL_MAX_TEXTURE_SIZE'); - let maxSizeForNarrowTex = - env().getNumber('WEBGL_MAX_SIZE_FOR_NARROW_TEXTURE'); - if (maxSizeForNarrowTex === Infinity && - env().getBool('WEBGL_AUTO_SQUARIFY_NARROW_TEXTURE_SHAPE')) { - maxSizeForNarrowTex = maxTexSize / 2; - } - - if (isPacked) { - maxTexSize = maxTexSize * 2; - maxSizeForNarrowTex = maxSizeForNarrowTex * 2; - - // This logic ensures we accurately count the number of packed texels needed - // to accommodate the tensor. We can only pack values in the same texel if - // they are from adjacent pairs of rows/cols within the same batch. So if a - // tensor has 3 rows, we pretend it has 4 rows in order to account for the - // fact that the texels containing the third row are half empty. - logShape = logShape.map( - (d, i) => i >= logShape.length - 2 ? - util.nearestLargerEven(logShape[i]) : - logShape[i]); - - // Packed texture height is at least 2 (the channel height of a single - // texel). - if (logShape.length === 1) { - logShape = [2, logShape[0]]; - } - } - - // If logical shape is 2, we don't squeeze, since we want to match physical. - if (logShape.length !== 2) { - const squeezeResult = util.squeezeShape(logShape); - logShape = squeezeResult.newShape; - } - - let size = util.sizeFromShape(logShape); - let textureShape: [number, number] = null; - if (logShape.length <= 1 && size <= maxTexSize) { - textureShape = [1, size]; - } else if ( - logShape.length === 2 && logShape[0] <= maxTexSize && - logShape[1] <= maxTexSize) { - textureShape = logShape as [number, number]; - } else if ( - logShape.length === 3 && logShape[0] * logShape[1] <= maxTexSize && - logShape[2] <= maxTexSize) { - textureShape = [logShape[0] * logShape[1], logShape[2]]; - } else if ( - logShape.length === 3 && logShape[0] <= maxTexSize && - logShape[1] * logShape[2] <= maxTexSize) { - textureShape = [logShape[0], logShape[1] * logShape[2]]; - } else if ( - logShape.length === 4 && - logShape[0] * logShape[1] * logShape[2] <= maxTexSize && - logShape[3] <= maxTexSize) { - textureShape = [logShape[0] * logShape[1] * logShape[2], logShape[3]]; - } else if ( - logShape.length === 4 && logShape[0] <= maxTexSize && - logShape[1] * logShape[2] * logShape[3] <= maxTexSize) { - textureShape = [logShape[0], logShape[1] * logShape[2] * logShape[3]]; - } - - // true if one edge length is 1 (1 or 2, if packed), while another edge - // length exceeds maxSizeForNarrowTex. - const isLongNarrowTex = textureShape != null && - Math.max(...textureShape) > maxSizeForNarrowTex && - Math.min(...textureShape) <= (isPacked ? 2 : 1) && - Math.min(...textureShape) > 0; - - if (textureShape == null || isLongNarrowTex) { - if (isPacked) { - // For packed textures size equals the number of channels required to - // accommodate the texture data. However in order to squarify such that - // inner dimensions stay even, we rewrite size to equal the number of - // texels. Then in the return statement we rehydrate the squarified - // dimensions to channel units. - - const batchDim = getBatchDim(logShape); - let rows = 2, cols = 2; - if (logShape.length) { - [rows, cols] = getRowsCols(logShape); - } - size = batchDim * (rows / 2) * (cols / 2); - textureShape = - util.sizeToSquarishShape(size).map(d => d * 2) as [number, number]; - } else { - textureShape = util.sizeToSquarishShape(size); - } - } - - return textureShape; -} - -function isEven(n: number): boolean { - return n % 2 === 0; -} - -/** - * This determines whether reshaping a packed texture requires rearranging - * the data within the texture, assuming 2x2 packing. - */ -export function isReshapeFree(shape1: number[], shape2: number[]): boolean { - shape1 = shape1.slice(-2); - shape2 = shape2.slice(-2); - - if (util.arraysEqual(shape1, shape2)) { - return true; - } - - if (!shape1.length || !shape2.length) { // One of the shapes is a scalar. - return true; - } - - if (shape1[0] === 0 || shape1[1] === 0 || shape2[0] === 0 || - shape2[1] === 0) { - return true; - } - - if (shape1.length !== shape2.length) { // One of the shapes is a vector. - const shape1Cols = shape1[shape1.length - 1]; - const shape2Cols = shape2[shape2.length - 1]; - if (shape1Cols === shape2Cols) { - return true; - } - - if (isEven(shape1Cols) && isEven(shape2Cols) && - (shape1[0] === 1 || shape2[0] === 1)) { - return true; - } - } - return shape1[1] === shape2[1] && isEven(shape1[0]) && isEven(shape2[0]); -} - -// We cache webgl params because the environment gets reset between -// unit tests and we don't want to constantly query the WebGLContext for -// MAX_TEXTURE_SIZE. -let MAX_TEXTURE_SIZE: number; -let MAX_TEXTURES_IN_SHADER: number; - -export function getWebGLMaxTextureSize(webGLVersion: number): number { - if (MAX_TEXTURE_SIZE == null) { - const gl = getWebGLContext(webGLVersion); - MAX_TEXTURE_SIZE = gl.getParameter(gl.MAX_TEXTURE_SIZE); - } - return MAX_TEXTURE_SIZE; -} - -export function resetMaxTextureSize() { - MAX_TEXTURE_SIZE = null; -} -export function resetMaxTexturesInShader() { - MAX_TEXTURES_IN_SHADER = null; -} - -export function getMaxTexturesInShader(webGLVersion: number): number { - if (MAX_TEXTURES_IN_SHADER == null) { - const gl = getWebGLContext(webGLVersion); - MAX_TEXTURES_IN_SHADER = gl.getParameter(gl.MAX_TEXTURE_IMAGE_UNITS); - } - // We cap at 16 to avoid spurious runtime "memory exhausted" error. - return Math.min(16, MAX_TEXTURES_IN_SHADER); -} - -export function getWebGLDisjointQueryTimerVersion(webGLVersion: number): - number { - if (webGLVersion === 0) { - return 0; - } - - let queryTimerVersion: number; - const gl = getWebGLContext(webGLVersion); - - if (hasExtension(gl, 'EXT_disjoint_timer_query_webgl2') && - webGLVersion === 2) { - queryTimerVersion = 2; - } else if (hasExtension(gl, 'EXT_disjoint_timer_query')) { - queryTimerVersion = 1; - } else { - queryTimerVersion = 0; - } - return queryTimerVersion; -} - -export function hasExtension(gl: WebGLRenderingContext, extensionName: string) { - const ext = gl.getExtension(extensionName); - return ext != null; -} - -export function isWebGLVersionEnabled(webGLVersion: 1|2) { - try { - const gl = getWebGLContext(webGLVersion); - if (gl != null) { - return true; - } - } catch (e) { - console.log('Error when getting WebGL context: ', e); - return false; - } - return false; -} - -export function isCapableOfRenderingToFloatTexture(webGLVersion: number): - boolean { - if (webGLVersion === 0) { - return false; - } - - const gl = getWebGLContext(webGLVersion); - - if (webGLVersion === 1) { - if (!hasExtension(gl, 'OES_texture_float')) { - return false; - } - } else { - if (!hasExtension(gl, 'EXT_color_buffer_float')) { - return false; - } - } - - const isFrameBufferComplete = createFloatTextureAndBindToFramebuffer(gl); - return isFrameBufferComplete; -} - -/** - * Check if we can download values from a float/half-float texture. - * - * Note that for performance reasons we use binding a texture to a framebuffer - * as a proxy for ability to download float values later using readPixels. The - * texture params of this texture will not match those in readPixels exactly - * but if we are unable to bind some kind of float texture to the frameBuffer - * then we definitely will not be able to read float values from it. - */ -export function isDownloadFloatTextureEnabled(webGLVersion: number): boolean { - if (webGLVersion === 0) { - return false; - } - - const gl = getWebGLContext(webGLVersion); - - if (webGLVersion === 1) { - if (!hasExtension(gl, 'OES_texture_float')) { - return false; - } - if (!hasExtension(gl, 'WEBGL_color_buffer_float')) { - return false; - } - } else { - if (hasExtension(gl, 'EXT_color_buffer_float')) { - return createFloatTextureAndBindToFramebuffer(gl); - } - - const COLOR_BUFFER_HALF_FLOAT = 'EXT_color_buffer_half_float'; - if (hasExtension(gl, COLOR_BUFFER_HALF_FLOAT)) { - const textureHalfFloatExtension = - gl.getExtension(COLOR_BUFFER_HALF_FLOAT); - return createHalfFloatTextureAndBindToFramebuffer( - gl, textureHalfFloatExtension); - } - - return false; - } - - const isFrameBufferComplete = createFloatTextureAndBindToFramebuffer(gl); - return isFrameBufferComplete; -} - -function createFloatTextureAndBindToFramebuffer(gl: WebGLRenderingContext): - boolean { - const texConfig = getTextureConfig(gl); - - const texture = gl.createTexture(); - gl.bindTexture(gl.TEXTURE_2D, texture); - - const width = 1; - const height = 1; - gl.texImage2D( - gl.TEXTURE_2D, 0, texConfig.internalFormatFloat, width, height, 0, - texConfig.textureFormatFloat, texConfig.textureTypeFloat, null); - - const frameBuffer = gl.createFramebuffer(); - gl.bindFramebuffer(gl.FRAMEBUFFER, frameBuffer); - gl.framebufferTexture2D( - gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0); - - const isFrameBufferComplete = - gl.checkFramebufferStatus(gl.FRAMEBUFFER) === gl.FRAMEBUFFER_COMPLETE; - - gl.bindTexture(gl.TEXTURE_2D, null); - gl.bindFramebuffer(gl.FRAMEBUFFER, null); - gl.deleteTexture(texture); - gl.deleteFramebuffer(frameBuffer); - - return isFrameBufferComplete; -} - -function createHalfFloatTextureAndBindToFramebuffer( - // tslint:disable-next-line:no-any - gl: WebGLRenderingContext, textureHalfFloatExtension: any): boolean { - const texConfig = getTextureConfig(gl, textureHalfFloatExtension); - const texture = gl.createTexture(); - gl.bindTexture(gl.TEXTURE_2D, texture); - - const width = 1; - const height = 1; - gl.texImage2D( - gl.TEXTURE_2D, 0, texConfig.internalFormatHalfFloat, width, height, 0, - texConfig.textureFormatFloat, texConfig.textureTypeHalfFloat, null); - - const frameBuffer = gl.createFramebuffer(); - gl.bindFramebuffer(gl.FRAMEBUFFER, frameBuffer); - gl.framebufferTexture2D( - gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0); - - const isFrameBufferComplete = - gl.checkFramebufferStatus(gl.FRAMEBUFFER) === gl.FRAMEBUFFER_COMPLETE; - - gl.bindTexture(gl.TEXTURE_2D, null); - gl.bindFramebuffer(gl.FRAMEBUFFER, null); - gl.deleteTexture(texture); - gl.deleteFramebuffer(frameBuffer); - - return isFrameBufferComplete; -} - -export function isWebGLFenceEnabled(webGLVersion: number) { - if (webGLVersion !== 2) { - return false; - } - const gl = getWebGLContext(webGLVersion); - - // tslint:disable-next-line:no-any - const isEnabled = (gl as any).fenceSync != null; - return isEnabled; -} - -export function assertNotComplex( - tensor: TensorInfo|TensorInfo[], opName: string): void { - if (!Array.isArray(tensor)) { - tensor = [tensor]; - } - tensor.forEach(t => { - if (t != null) { - util.assert( - t.dtype !== 'complex64', - () => `${opName} does not support complex64 tensors ` + - 'in the WebGL backend.'); - } - }); -} diff --git a/tfjs-master/tfjs-backend-webgl/src/webgl_util_test.ts b/tfjs-master/tfjs-backend-webgl/src/webgl_util_test.ts deleted file mode 100644 index d57d0b181..000000000 --- a/tfjs-master/tfjs-backend-webgl/src/webgl_util_test.ts +++ /dev/null @@ -1,214 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '@tensorflow/tfjs-core'; -import {util} from '@tensorflow/tfjs-core'; -// tslint:disable-next-line: no-imports-from-dist -import {describeWithFlags} from '@tensorflow/tfjs-core/dist/jasmine_util'; - -import {WEBGL_ENVS} from './backend_webgl_test_registry'; -import * as webgl_util from './webgl_util'; - -describeWithFlags('getTextureShapeFromLogicalShape', WEBGL_ENVS, () => { - it('scalar', () => { - const texShape = webgl_util.getTextureShapeFromLogicalShape([]); - expect(texShape).toEqual([1, 1]); - }); - - it('1d', () => { - const texShape = webgl_util.getTextureShapeFromLogicalShape([4]); - expect(texShape).toEqual([1, 4]); - }); - - it('2d stays same', () => { - let texShape = webgl_util.getTextureShapeFromLogicalShape([5, 2]); - expect(texShape).toEqual([5, 2]); - - texShape = webgl_util.getTextureShapeFromLogicalShape([5, 1]); - expect(texShape).toEqual([5, 1]); - - texShape = webgl_util.getTextureShapeFromLogicalShape([1, 5]); - expect(texShape).toEqual([1, 5]); - }); - - it('3d 2x3x4', () => { - const texShape = webgl_util.getTextureShapeFromLogicalShape([2, 3, 4]); - expect(texShape).toEqual([6, 4]); - }); - - it('3d 3x256x256', () => { - const texShape = webgl_util.getTextureShapeFromLogicalShape([3, 256, 256]); - expect(texShape).toEqual([3 * 256, 256]); - }); - - it('3d 2x1x4 got squeezed', () => { - const texShape = webgl_util.getTextureShapeFromLogicalShape([2, 1, 4]); - expect(texShape).toEqual([2, 4]); - }); - - it('3d 1x8x2 got squeezed', () => { - const texShape = webgl_util.getTextureShapeFromLogicalShape([1, 8, 2]); - expect(texShape).toEqual([8, 2]); - }); - - it('4d 2x2x256x256 got squeezed', () => { - const texShape = - webgl_util.getTextureShapeFromLogicalShape([2, 2, 256, 256]); - expect(texShape).toEqual([2 * 2 * 256, 256]); - }); - - it('4d 1x8x1x3 got squeezed', () => { - const texShape = webgl_util.getTextureShapeFromLogicalShape([1, 8, 1, 3]); - expect(texShape).toEqual([8, 3]); - }); - - it('4d 1x3x1x8 got squeezed', () => { - const texShape = webgl_util.getTextureShapeFromLogicalShape([1, 3, 1, 8]); - expect(texShape).toEqual([3, 8]); - }); -}); - -describeWithFlags('getTextureShapeFromLogicalShape packed', WEBGL_ENVS, () => { - it('textures less than 2x max size of platform preserve their shapes', () => { - const isPacked = true; - const logicalShape = [ - 2, - util.nearestLargerEven(tf.env().getNumber('WEBGL_MAX_TEXTURE_SIZE') + 1) - ]; - const texShape = - webgl_util.getTextureShapeFromLogicalShape(logicalShape, isPacked); - expect(texShape).toEqual(logicalShape); - }); - - it('rows/columns do not get squeezed', () => { - const isPacked = true; - const logicalShape = [1, 1, 1]; - const texShape = - webgl_util.getTextureShapeFromLogicalShape(logicalShape, isPacked); - expect(texShape).toEqual([2, 2]); - }); - - it('squarified texture shapes account for packing constraints', () => { - const isPacked = true; - const max = tf.env().getNumber('WEBGL_MAX_TEXTURE_SIZE'); - - tf.env().set('WEBGL_MAX_TEXTURE_SIZE', 5); - const logicalShape = [1, 12]; - const texShape = - webgl_util.getTextureShapeFromLogicalShape(logicalShape, isPacked); - - tf.env().set('WEBGL_MAX_TEXTURE_SIZE', max); - expect(texShape).toEqual([6, 4]); - }); - - it('squarified long narrow texture shapes', () => { - const isPacked = true; - const max = tf.env().getNumber('WEBGL_MAX_SIZE_FOR_NARROW_TEXTURE'); - - tf.env().set('WEBGL_MAX_SIZE_FOR_NARROW_TEXTURE', 5); - const logicalShape = [1, 16]; - const texShape = - webgl_util.getTextureShapeFromLogicalShape(logicalShape, isPacked); - - tf.env().set('WEBGL_MAX_SIZE_FOR_NARROW_TEXTURE', max); - expect(texShape).toEqual([6, 6]); - }); - - it('auto squarified long narrow texture shapes', () => { - const isPacked = true; - const max = tf.env().getNumber('WEBGL_MAX_TEXTURE_SIZE'); - const maxForNarrowTex = - tf.env().getNumber('WEBGL_MAX_SIZE_FOR_NARROW_TEXTURE'); - const autoSquarify = - tf.env().getNumber('WEBGL_AUTO_SQUARIFY_NARROW_TEXTURE_SHAPE'); - - tf.env().set('WEBGL_MAX_TEXTURE_SIZE', 6); - tf.env().set('WEBGL_AUTO_SQUARIFY_NARROW_TEXTURE_SHAPE', true); - tf.env().set('WEBGL_MAX_SIZE_FOR_NARROW_TEXTURE', Infinity); - const logicalShape = [1, 16]; - const texShape = - webgl_util.getTextureShapeFromLogicalShape(logicalShape, isPacked); - - tf.env().set('WEBGL_MAX_TEXTURE_SIZE', max); - tf.env().set('WEBGL_MAX_SIZE_FOR_NARROW_TEXTURE', maxForNarrowTex); - tf.env().set('WEBGL_AUTO_SQUARIFY_NARROW_TEXTURE_SHAPE', autoSquarify); - expect(texShape).toEqual([6, 6]); - }); -}); - -describeWithFlags('isReshapeFree', WEBGL_ENVS, () => { - it('is free when shapes have the same inner dimensions', () => { - const before = [1, 2, 3]; - const after = [5, 2, 3]; - expect(webgl_util.isReshapeFree(before, after)).toBe(true); - }); - - it('is free when one of the shapes is a scalar', () => { - const before: number[] = []; - const after = [1, 2, 3]; - expect(webgl_util.isReshapeFree(before, after)).toBe(true); - }); - - it('is free when one of the dimensions equals 0', () => { - const before = [1, 0]; - const after = [1, 2, 3]; - expect(webgl_util.isReshapeFree(before, after)).toBe(true); - }); - - it('is free when one shape is a vector and the final dimensions match', - () => { - const before = [9]; - const after = [1, 1, 9]; - expect(webgl_util.isReshapeFree(before, after)).toBe(true); - }); - - it('is free when one shape is a vector and the other has 1 row' + - 'in every batch and the final dimensions are even', - () => { - const before = [10]; - const after = [5, 1, 2]; - expect(webgl_util.isReshapeFree(before, after)).toBe(true); - }); - - it('is not free when one shape is a vector and the final dimensions' + - 'do not match and are not even', - () => { - const before = [18]; - const after = [2, 1, 9]; - expect(webgl_util.isReshapeFree(before, after)).toBe(false); - }); - - it('is free if the rows are divisible by two and the columns are the same', - () => { - const before = [1, 2, 3]; - const after = [1, 4, 3]; - expect(webgl_util.isReshapeFree(before, after)).toBe(true); - }); - - it('is not free when the inner dimensions are different and even', () => { - const before = [1, 2, 4]; - const after = [1, 8, 10]; - expect(webgl_util.isReshapeFree(before, after)).toBe(false); - }); - - it('is not free when the inner dimensions are different and not all even', - () => { - const before = [1, 2, 3]; - const after = [1, 3, 2]; - expect(webgl_util.isReshapeFree(before, after)).toBe(false); - }); -}); diff --git a/tfjs-master/tfjs-backend-webgl/tsconfig.json b/tfjs-master/tfjs-backend-webgl/tsconfig.json deleted file mode 100644 index ecb732e21..000000000 --- a/tfjs-master/tfjs-backend-webgl/tsconfig.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "extends": "../tsconfig", - "include": [ - "src/" - ], - "exclude": [ - "node_modules/" - ], - "compilerOptions": { - "outDir": "./dist" - } -} diff --git a/tfjs-master/tfjs-backend-webgl/yarn.lock b/tfjs-master/tfjs-backend-webgl/yarn.lock deleted file mode 100644 index 2968534de..000000000 --- a/tfjs-master/tfjs-backend-webgl/yarn.lock +++ /dev/null @@ -1,50 +0,0 @@ -# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. -# yarn lockfile v1 - - -"@babel/polyfill@^7.8.7": - version "7.12.1" - resolved "https://registry.npmjs.org/@babel/polyfill/-/polyfill-7.12.1.tgz#1f2d6371d1261bbd961f3c5d5909150e12d0bd96" - integrity sha512-X0pi0V6gxLi6lFZpGmeNa4zxtwEmCs42isWLNjZZDE0Y8yVfgu0T2OAHlzBbdYlqbW/YXVvoBHpATEM+goCj8g== - dependencies: - core-js "^2.6.5" - regenerator-runtime "^0.13.4" - -"@bazel/bazelisk@^1.12.0": - version "1.12.0" - resolved "https://registry.yarnpkg.com/@bazel/bazelisk/-/bazelisk-1.12.0.tgz#f08aebbf4afcb12684422450b0845dd6ef5cfe50" - integrity sha512-7oQusq1e4AIyFgotxVV7Pc40Et0QyvoVjujL+7/qV5Vrbfh0Nj3CfqSgl63weEyI4r0+K6RlGVsjfRuBi05p5w== - -"@tensorflow/tfjs-backend-cpu@link:../link-package/node_modules/@tensorflow/tfjs-backend-cpu": - version "0.0.0" - uid "" - -"@types/offscreencanvas@~2019.3.0": - version "2019.3.0" - resolved "https://registry.npmjs.org/@types/offscreencanvas/-/offscreencanvas-2019.3.0.tgz#3336428ec7e9180cf4566dfea5da04eb586a6553" - integrity sha512-esIJx9bQg+QYF0ra8GnvfianIY8qWB0GBx54PK5Eps6m+xTj86KLavHv6qDhzKcu5UUOgNfJ2pWaIIV7TRUd9Q== - -"@types/seedrandom@^2.4.28": - version "2.4.30" - resolved "https://registry.yarnpkg.com/@types/seedrandom/-/seedrandom-2.4.30.tgz#d2efe425869b84163c2d56e779dddadb9372cbfa" - integrity sha512-AnxLHewubLVzoF/A4qdxBGHCKifw8cY32iro3DQX9TPcetE95zBeVt3jnsvtvAUf1vwzMfwzp4t/L2yqPlnjkQ== - -"@types/webgl-ext@0.0.30": - version "0.0.30" - resolved "https://registry.npmjs.org/@types/webgl-ext/-/webgl-ext-0.0.30.tgz#0ce498c16a41a23d15289e0b844d945b25f0fb9d" - integrity sha512-LKVgNmBxN0BbljJrVUwkxwRYqzsAEPcZOe6S2T6ZaBDIrFp0qu4FNlpc5sM1tGbXUYFgdVQIoeLk1Y1UoblyEg== - -core-js@^2.6.5: - version "2.6.12" - resolved "https://registry.npmjs.org/core-js/-/core-js-2.6.12.tgz#d9333dfa7b065e347cc5682219d6f690859cc2ec" - integrity sha512-Kb2wC0fvsWfQrgk8HU5lW6U/Lcs8+9aaYcy4ZFc6DDlo4nZ7n70dEgE5rtR0oG6ufKDUnrwfWL1mXR5ljDatrQ== - -regenerator-runtime@^0.13.4: - version "0.13.7" - resolved "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.7.tgz#cac2dacc8a1ea675feaabaeb8ae833898ae46f55" - integrity sha512-a54FxoJDIr27pgf7IgeQGxmqUNYrcV338lf/6gH456HZ/PhX+5BcwHXG9ajESmwe6WRO0tAzRUrRmNONWgkrew== - -seedrandom@^3.0.5: - version "3.0.5" - resolved "https://registry.yarnpkg.com/seedrandom/-/seedrandom-3.0.5.tgz#54edc85c95222525b0c7a6f6b3543d8e0b3aa0a7" - integrity sha512-8OwmbklUNzwezjGInmZ+2clQmExQPvomqjL7LFqOYqtmuxRgQYqOD3mHaU+MvZn5FLUeVxVfQjwLZW/n/JFuqg== diff --git a/tfjs-master/tfjs-backend-webgpu/.npmignore b/tfjs-master/tfjs-backend-webgpu/.npmignore deleted file mode 100644 index 6292b5fdb..000000000 --- a/tfjs-master/tfjs-backend-webgpu/.npmignore +++ /dev/null @@ -1,27 +0,0 @@ -.babelrc -.DS_Store -.idea/ -.rpt2_cache -.travis.yml -.vscode -*.tgz -*.txt -**.yalc -**yalc.lock -cloudbuild.yml -coverage/ -demo/ -dist/**/*_test.d.ts -dist/**/*_test.js -karma.conf.js -node_modules/ -npm-debug.log -package-lock.json -package/ -rollup.config.js -scripts/ -src/**/*_test.ts -tsconfig.json -tslint.json -yarn-error.log -yarn.lock diff --git a/tfjs-master/tfjs-backend-webgpu/.npmrc b/tfjs-master/tfjs-backend-webgpu/.npmrc deleted file mode 100644 index 43c97e719..000000000 --- a/tfjs-master/tfjs-backend-webgpu/.npmrc +++ /dev/null @@ -1 +0,0 @@ -package-lock=false diff --git a/tfjs-master/tfjs-backend-webgpu/.vscode/settings.json b/tfjs-master/tfjs-backend-webgpu/.vscode/settings.json deleted file mode 100644 index 5f30a3cfd..000000000 --- a/tfjs-master/tfjs-backend-webgpu/.vscode/settings.json +++ /dev/null @@ -1 +0,0 @@ -../../.vscode/settings.json \ No newline at end of file diff --git a/tfjs-master/tfjs-backend-webgpu/BUILD.bazel b/tfjs-master/tfjs-backend-webgpu/BUILD.bazel deleted file mode 100644 index b38b970e8..000000000 --- a/tfjs-master/tfjs-backend-webgpu/BUILD.bazel +++ /dev/null @@ -1,118 +0,0 @@ -# Copyright 2021 Google LLC. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================= - -load("@bazel_skylib//rules:copy_file.bzl", "copy_file") -load("@build_bazel_rules_nodejs//:index.bzl", "pkg_npm") -load("//tools:copy_to_dist.bzl", "copy_to_dist", "copy_ts_library_to_dist") -load("//tools:tfjs_bundle.bzl", "tfjs_bundle") -load("//tools:tfjs_web_test.bzl", "tfjs_web_test") - -package(default_visibility = ["//visibility:public"]) - -tfjs_bundle( - name = "tf-backend-webgpu", - entry_point = "//tfjs-backend-webgpu/src:index.ts", - external = [ - "@tensorflow/tfjs-core", - "@webgpu/types", - "node-fetch", - "util", - ], - globals = { - "@tensorflow/tfjs-core": "tf", - }, - umd_name = "tf", - deps = [ - "//tfjs-backend-webgpu/src:tfjs-backend-webgpu_lib", - "//tfjs-backend-webgpu/src:tfjs-backend-webgpu_src_lib", - ], -) - -copy_ts_library_to_dist( - name = "copy_src_to_dist", - srcs = [ - "//tfjs-backend-webgpu/src:tfjs-backend-webgpu_lib", - "//tfjs-backend-webgpu/src:tfjs-backend-webgpu_src_lib", - ], - root = "src", -) - -copy_to_dist( - name = "copy_bundles", - srcs = [ - ":tf-backend-webgpu", - ":tf-backend-webgpu.es2017", - ":tf-backend-webgpu.es2017.min", - ":tf-backend-webgpu.fesm", - ":tf-backend-webgpu.fesm.min", - ":tf-backend-webgpu.min", - ":tf-backend-webgpu.node", - ], -) - -copy_file( - name = "copy_miniprogram", - src = ":tf-backend-webgpu.min.js", - out = "dist/miniprogram/index.js", -) - -copy_file( - name = "copy_miniprogram_map", - src = ":tf-backend-webgpu.min.js.map", - out = "dist/miniprogram/index.js.map", -) - -pkg_npm( - name = "tfjs-backend-webgpu_pkg", - package_name = "@tensorflow/tfjs-backend-webgpu", - srcs = [ - "README.md", - "package.json", - ], - tags = ["ci"], - deps = [ - ":copy_bundles", - ":copy_miniprogram", - ":copy_miniprogram_map", - ":copy_src_to_dist", - ], -) - -STATIC_FILES = [ - # Listed here so sourcemaps are served - "//tfjs-backend-webgpu/src:tfjs-backend-webgpu_test_bundle", -] - -tfjs_web_test( - name = "tfjs-backend-webgpu_test", - srcs = [ - "//tfjs-backend-webgpu/src:tfjs-backend-webgpu_test_bundle", - ], - args = [ - "--testEnv", - "webgpu", - "--flags", - '{"WEBGPU_CPU_FORWARD": false}', - ], - browsers = [ - "bs_chrome_mac_webgpu", - ], - local_browser = select({ - "@bazel_tools//src/conditions:linux_x86_64": "chrome_webgpu_linux", - "@bazel_tools//src/conditions:windows": "chrome_webgpu", - "//conditions:default": "chrome_webgpu", - }), - static_files = STATIC_FILES, -) diff --git a/tfjs-master/tfjs-backend-webgpu/README.md b/tfjs-master/tfjs-backend-webgpu/README.md deleted file mode 100644 index 7f3975072..000000000 --- a/tfjs-master/tfjs-backend-webgpu/README.md +++ /dev/null @@ -1,87 +0,0 @@ -# Usage - -This package adds a GPU accelerated [WebGPU](https://www.w3.org/TR/webgpu/) -backend to TensorFlow.js. It currently supports -the following models: -- BlazeFace -- BodyPix -- Face landmarks detection -- HandPose -- MobileNet -- PoseDetection -- Universal sentence encoder -- AutoML Image classification -- AutoML Object detection -- Speech commands - -Google Chrome started to support WebGPU by default in M113 on May 2, 2023. - - -## Importing the backend - -### Via NPM - -```js -// Import @tensorflow/tfjs or @tensorflow/tfjs-core -import * as tf from '@tensorflow/tfjs'; -// Add the WebGPU backend to the global backend registry. -import '@tensorflow/tfjs-backend-webgpu'; -// Set the backend to WebGPU and wait for the module to be ready. -tf.setBackend('webgpu').then(() => main()); -``` - -### Via a script tag - -```html - - - - - - -``` - -# FAQ - -### When should I use the WebGPU backend? -The mission of WebGPU backend is to achieve the best performance among all -approaches. However, this target can not be met overnight, but we are committed -to supporting it with rapid and continuous performance improvement. Many -exciting features, like FP16, DP4A, will be brought in soon. - -### How many ops have you implemented? -See [`register_all_kernels.ts`](https://github.com/tensorflow/tfjs/blob/master/tfjs-backend-webgpu/src/register_all_kernels.ts) -for an up-to-date list of supported ops. We love contributions. See the -[contributing](https://github.com/tensorflow/tfjs/blob/master/CONTRIBUTING.md#adding-functionality) -document for more info. - -### Do you support training? -Maybe. There are still a decent number of ops that we are missing in WebGPU that -are needed for gradient computation. At this point we are focused on making -inference as fast as possible. - -### Do you work in node? -Yes. If you run into issues, please let us know. - -### How do I give feedback? -We'd love your feedback as we develop this backend! Please file an issue -[here](https://github.com/tensorflow/tfjs/issues/new). - -# Development - -## Building - -```sh -yarn build -``` - -## Testing -Currently the Canary channel of Chrome is used for testing of the WebGPU -backend: - -```sh -yarn test # --test_env=CHROME_CANARY_BIN=/path/to/chrome -``` diff --git a/tfjs-master/tfjs-backend-webgpu/benchmarks/config.js b/tfjs-master/tfjs-backend-webgpu/benchmarks/config.js deleted file mode 100644 index 64063ff58..000000000 --- a/tfjs-master/tfjs-backend-webgpu/benchmarks/config.js +++ /dev/null @@ -1,36 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -const SWATCHES = { - 'webgpu_min': '#F1523E', - 'webgpu_mean': '#F1523E', - 'webgl_min': '#3f51b5', - 'webgl_mean': '#3f51b5' -}; - -const STROKES = { - 'webgpu_min': '2', - 'webgpu_mean': '0', - 'webgl_min': '2', - 'webgl_mean': '0' -}; - -const TARGETS = ['canary']; -const MOMENT_DISPLAY_FORMAT = 'MM/DD/YYYY'; -const MAX_NUM_LOGS = 50; -const START_LOGGING_DATE = '2019-08-16'; -const CHART_HEIGHT = 200; diff --git a/tfjs-master/tfjs-backend-webgpu/benchmarks/index.html b/tfjs-master/tfjs-backend-webgpu/benchmarks/index.html deleted file mode 100644 index 711bb0767..000000000 --- a/tfjs-master/tfjs-backend-webgpu/benchmarks/index.html +++ /dev/null @@ -1,70 +0,0 @@ - - - - - - - - - - - - - - - - -
-

Tensorflow.js / WebGPU Benchmarks

-
-
-
Showing benchmarks for:
-
-
to
-
-
-
Edit
-
-
-
-
-
-
-
- - -
- - - - - - - diff --git a/tfjs-master/tfjs-backend-webgpu/benchmarks/main.css b/tfjs-master/tfjs-backend-webgpu/benchmarks/main.css deleted file mode 100644 index 8ef52beef..000000000 --- a/tfjs-master/tfjs-backend-webgpu/benchmarks/main.css +++ /dev/null @@ -1,235 +0,0 @@ -/* Copyright 2019 Google LLC. All Rights Reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -============================================================================== */ - -#container { - margin-left: auto; - margin-right: auto; - max-width: 960px; -} - -.color { - display: inline-block; - height: 2px; - vertical-align: middle; - width: 20px; -} - -.detail-panel { - height: 100%; - left: 0; - opacity: 0; - pointer-events: none; - position: absolute; - top: 0; - transition: opacity 250ms; -} - -.detail-panel .contents { - background: rgba(255, 255, 255, 0.8); - padding: 0 7px; -} - -.detail-panel .label-wrapper { - white-space: nowrap; -} - -.detail-panel .line { - background: black; - height: 100%; - position: absolute; - top: 0; - width: 1px; -} - -.edit-time-wrapper { - font-size: 16px; - line-height: 1.75; -} - -.edit-time-wrapper .range { - margin: 30px 0 40px 0; -} - -.edit-time-wrapper .range > * { - display: inline-block; -} - -.edit-time-wrapper input { - font-size: 15px; - letter-spacing: 0.5px; - margin-right: 10px; - padding: 5px; - width: 100px; -} - -.graph-container { - margin: 30px auto; - position: relative; -} - -.graph-container:hover .detail-panel { - opacity: 1; -} - -.instructions span { - font-weight: bold; - letter-spacing: 0.5px; -} - -.label { - display: inline-block; - vertical-align: middle; -} - -.modal-cancel-button { - margin-right: 15px; -} - -.modal-contents { - background: white; - border: solid 1px #ccc; - left: 50%; - padding: 35px; - position: absolute; - top: 50%; - transform: translate3d(-50%, -50%, 0); -} - -.modal-contents .controls { - text-align: right; -} - -.show-modal + .time-selection-modal { - display: block; -} - -.swatch { - display: inline-block; - margin-right: 10px; -} - -.test { - margin: 50px auto 80px auto; -} - -.time-selection { - margin: 50px 0 20px 0; -} - -.time-selection .start-date, -.time-selection .end-date { - font-weight: bold; - letter-spacing: 0.5px; -} - -.time-selection-edit-button { - margin-left: 15px; -} - -.time-selection-edit-button, -.modal-cancel-button, -.modal-submit-button { - background: steelblue; - border-radius: 3px; - color: white; - cursor: pointer; - display: inline-block; - line-height: 1; - padding: 10px 15px; - text-transform: uppercase; -} - -.time-selection-label { - font-size: 18px; -} - -.time-selection-label, -.time-selection-edit-button, -.time-selection-label > * { - display: inline-block; -} - -.time-selection-modal { - bottom: 0; - display: none; - left: 0; - position: fixed; - right: 0; - top: 0; -} - -.time-selection-modal .modal-backdrop { - background: rgba(255, 255, 255, 0.75); - height: 100%; - width: 100%; -} - -.x-axis-labels { - position: relative; - white-space: nowrap; -} - -.x-label { - font-size: 10px; - position: absolute; - transform: translate3d(12px, 5px, 0) rotate(58deg); - transform-origin: top left; -} - -.y-axis-labels { - position: absolute; - right: 100%; - text-align: right; - top: 0; -} - -.y-max { - top: 0; - transform: translateY(-50%); -} - -.y-max, -.y-min { - font-size: 11px; - position: absolute; - right: 8px; -} - -.y-min { - bottom: 0; - transform: translateY(50%); -} - -body { - background: #fafafa; - margin: 0; - padding: 20px; -} - -h2 { - margin-bottom: 40px; - margin-top: 40px; -} - -path { - fill: none; - stroke-width: 2px; -} - -svg { - border-bottom: solid 1px #ccc; - border-left: solid 1px #ccc; - overflow: visible; -} diff --git a/tfjs-master/tfjs-backend-webgpu/benchmarks/main.js b/tfjs-master/tfjs-backend-webgpu/benchmarks/main.js deleted file mode 100644 index 4478f2503..000000000 --- a/tfjs-master/tfjs-backend-webgpu/benchmarks/main.js +++ /dev/null @@ -1,193 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// Create handles to DOM elements. -const container = document.querySelector('#container'); -const tabsContainer = document.querySelector('.mdl-tabs__tab-bar'); -const tabs = document.querySelector('.mdl-tabs'); -const timeSelectionInstructions = - document.querySelector('.edit-time-wrapper .instructions'); -const editTimeButton = document.querySelector('.time-selection-edit-button'); -const cancelEditTimeButton = document.querySelector('.modal-cancel-button'); -const submitEditTimeButton = document.querySelector('.modal-submit-button'); -const startDateEl = document.querySelector('.start-date'); -const endDateEl = document.querySelector('.end-date'); -const startDateInput = document.querySelector('.editable-start-date'); -const endDateInput = document.querySelector('.editable-end-date'); -const modalBackdrop = document.querySelector('.modal-backdrop'); - -const CHART_WIDTH = container.offsetWidth; -const state = { - 'activeTarget': 0, - 'activeTest': 0 -}; - -let startDate = moment(START_LOGGING_DATE, 'YYYY-MM-DD'), - endDate = moment(), - graphOffsetLeft = 0, - data = []; - -function resize() { - graphOffsetLeft = document.querySelector('.graph-container').offsetLeft; -}; -window.addEventListener('resize', resize); - -function templateBenchmarksForTimePeriod(start, end) { - const logFiles = getLogFiles(start, end); - const files = logFiles['results']; - - clearDisplay(); - - getDataForFiles(files).then(allResponses => { - const responses = [], dateFormats = []; - for (let i = 0; i < allResponses.length; i++) { - if (allResponses[i] != null) { - responses.push(allResponses[i]); - dateFormats.push(logFiles['formatted'][i]); - } - } - - const processedResponses = []; - for (let i = 0; i < responses.length; i++) { - const response = responses[i]; - const processedResponse = []; - - for (let idx = 0; idx < response.length; idx++) { - const {name, backend, min, mean} = response[idx]; - let testIndex = processedResponse.map(d => d.name).indexOf(name); - - if (testIndex === -1) { - processedResponse.push({name: name, params: []}); - testIndex = processedResponse.length - 1; - } - - processedResponse[testIndex].params.push( - {name: `${backend}_min`, ms: min}); - processedResponse[testIndex].params.push( - {name: `${backend}_mean`, ms: mean}); - } - processedResponses.push(processedResponse); - } - - data = TARGETS.map(name => ({name, tests: []})); - const targetIndex = 0; // Hard coded - Canary is the only target for now. - - // populate data - for (let i = 0; i < processedResponses.length; i++) { - const response = processedResponses[i]; - - for (let idx = 0; idx < response.length; idx++) { - const {name, params} = response[idx]; - let testIndex = data[targetIndex].tests.map(d => d.name).indexOf(name); - - if (testIndex === -1) { - data[targetIndex].tests.push({name: name, entries: []}); - testIndex = data[targetIndex].tests.length - 1; - } - - const timestamp = dateFormats[i]; - data[targetIndex].tests[testIndex].entries.push({timestamp, params}); - } - } - - data.forEach((target, i) => { - const tab = getOrCreateTab(target.name); - const panel = getOrCreatePanel(`${name}-panel`); - if (i === 0) { - tab.classList.add('is-active'); - panel.classList.add('is-active'); - } - - target.tests = target.tests.filter(test => test.entries.length > 1) - .sort((a, b) => a.name.localeCompare(b.name)); - - target.tests.forEach((test, i) => { - const params = {}; - test.entries.forEach(entry => { - entry.params.forEach(({name, ms}) => { - if (params[name] == null) { - params[name] = []; - } - - params[name].push({ms}) - }); - }); - - const msArray = flatten(test.entries.map(d => d.params.map(p => p.ms))); - const max = Math.max(...msArray); - const increment = getIncrementForWidth( - CHART_WIDTH, test.entries.length, 20 /* minimum increment width */); - const xIncrement = CHART_WIDTH / (test.entries.length - 1); - panel.innerHTML += - getTrendlinesHTML(test, params, max, increment, xIncrement, i); - }); - - tabsContainer.appendChild(tab); - tabs.appendChild(panel); - - resize(); - }); - }); -} - -document.addEventListener('mousemove', e => { - if (e.target.classList.contains('graph')) { - state.activeTest = +e.target.getAttribute('data-index'); - - const entries = - data[state.activeTarget].tests[state.activeTest].entries; - const left = e.clientX - graphOffsetLeft; - const entryIndex = Math.max( - 0, - Math.min( - entries.length - 1, - Math.floor((left / CHART_WIDTH) * entries.length))); - - const parentNode = e.target.parentNode; - parentNode.querySelector('.detail-panel').style.left = left + 'px'; - parentNode.querySelector('.detail-panel .contents').innerHTML = - `${entries[entryIndex].params.map(d => - `
-
-
-
${d.ms}
-
`).join(' ')}`; - } -}); - -timeSelectionInstructions.innerHTML = `Enter dates in the format ${ - MOMENT_DISPLAY_FORMAT}, within the time range ${ - startDate.format(MOMENT_DISPLAY_FORMAT)} to ${ - endDate.format(MOMENT_DISPLAY_FORMAT)}.`; - -editTimeButton.addEventListener('click', () => openModal(startDate, endDate)); - -cancelEditTimeButton.addEventListener('click', closeModal); -submitEditTimeButton.addEventListener('click', () => { - closeModal(); - startDate = moment(startDateInput.value, MOMENT_DISPLAY_FORMAT); - endDate = moment(endDateInput.value, MOMENT_DISPLAY_FORMAT); - - templateTimeSelection(startDate, endDate); - templateBenchmarksForTimePeriod(startDate, endDate); -}); -modalBackdrop.addEventListener('click', closeModal); - -templateTimeSelection(startDate, endDate); -templateBenchmarksForTimePeriod(startDate, endDate); diff --git a/tfjs-master/tfjs-backend-webgpu/benchmarks/util.js b/tfjs-master/tfjs-backend-webgpu/benchmarks/util.js deleted file mode 100644 index 0fab0aba7..000000000 --- a/tfjs-master/tfjs-backend-webgpu/benchmarks/util.js +++ /dev/null @@ -1,156 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -function getSwatchBackground(swatch, stroke) { - let background = swatch; - if (stroke > 0) { - background = `repeating-linear-gradient( - to right, - ${swatch}, - ${swatch} 2px, - white 2px, - white 4px - );`; - } - return background; -} - -function getLogFiles(start, end) { - const daysElapsed = end.diff(start, 'd'); - const results = []; - const formatted = []; - let interval = 1; - while (daysElapsed / interval > MAX_NUM_LOGS) { - interval += 1; - } - - for (let i = 0; i <= daysElapsed; i += interval) { - const current = endDate.clone().subtract(i, 'days'); - results.unshift(`${current.format('MM_DD_YYYY')}`); - formatted.unshift(current.format('M/DD')); - } - - return {results, formatted}; -} - -async function getDataForFiles(files) { - return Promise.all(files.map( - d => - fetch( - `https://storage.googleapis.com/learnjs-data/webgpu_benchmark_logs/${ - d}.json`) - .then(d => d.json()) - .catch(err => console.log(err)))); -} - -function templateTimeSelection(start, end) { - startDateEl.innerHTML = start.format(MOMENT_DISPLAY_FORMAT); - endDateEl.innerHTML = end.format(MOMENT_DISPLAY_FORMAT); -} - -function closeModal() { - container.classList.remove('show-modal'); -} - -function openModal(start, end) { - container.classList.add('show-modal'); - startDateInput.value = start.format(MOMENT_DISPLAY_FORMAT); - endDateInput.value = end.format(MOMENT_DISPLAY_FORMAT); -} - -function clearDisplay() { - tabsContainer.innerHTML = ''; - // remove all panels - [].slice.call(document.querySelectorAll('.mdl-tabs__panel')).forEach(el => { - el.parentNode.removeChild(el); - }); -} - -function getOrCreateTab(name) { - let tab = document.querySelector(`[href='#${name}']`); - if (tab == null) { - tab = document.createElement('a'); - tab.setAttribute('href', '#' + name); - tab.textContent = name; - tab.classList.add('mdl-tabs__tab'); - } - return tab; -} - -function getOrCreatePanel(id) { - let panel = document.querySelector(id); - if (panel == null) { - panel = document.createElement('div'); - panel.classList.add('mdl-tabs__panel'); - panel.id = id; - } - return panel; -} - -function flatten(arr) { - return arr.reduce((acc, curr) => acc.concat(curr), []); -} - -function getIncrementForWidth(width, length, minWidth) { - let increment = 1; - while ((width / ((length - 1) / increment)) < minWidth) { - increment *= 2; - } - return increment; -} - -function getTrendlinesHTML(test, params, max, increment, xIncrement, i) { - return `
-

${test.name}

-
${Object.keys(params).map(param => { - const backgroundColor = - getSwatchBackground(SWATCHES[param], STROKES[param]); - return `
-
-
${param}
-
`;}).join(' ')}
-
-
-
${max}ms
-
0ms
-
- - ${Object.keys(params).map((param) => - ``)} - -
- ${test.entries.map((d, i) => { - if (i % increment === 0) { - const left = (i / increment) * - (CHART_WIDTH / ((test.entries.length - 1) / increment)); - return `
- ${d.timestamp}
`; - } - return ''; - }).join(' ')}
-
-
-
-
-
-
`; -} diff --git a/tfjs-master/tfjs-backend-webgpu/karma.conf.js b/tfjs-master/tfjs-backend-webgpu/karma.conf.js deleted file mode 100644 index 5f781b6ba..000000000 --- a/tfjs-master/tfjs-backend-webgpu/karma.conf.js +++ /dev/null @@ -1,83 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -const karmaTypescriptConfig = { - tsconfig: 'tsconfig.test.json', - // Disable coverage reports and instrumentation by default for tests - coverageOptions: {instrumentation: false}, - reports: {}, - bundlerOptions: { - transforms: [require('karma-typescript-es6-transform')({ - presets: [ - // ensure we get es5 by adding IE 11 as a target - ['@babel/env', {'targets': {'ie': '11'}, 'loose': true}] - ] - })], - // worker_node_test in tfjs-core contains a conditional require statement - // that confuses the bundler of karma-typescript. - ignore: ['./worker_node_test'] - } -}; - -const devConfig = { - frameworks: ['jasmine', 'karma-typescript'], - files: [ - {pattern: './node_modules/@babel/polyfill/dist/polyfill.js'}, - 'src/setup_test.ts', - {pattern: 'src/**/*.ts'}, - ], - preprocessors: {'src/**/*.ts': ['karma-typescript']}, - karmaTypescriptConfig, -}; - -module.exports = function(config) { - const args = []; - if (config.grep) { - args.push('--grep', config.grep); - } - if (config.flags) { - args.push('--flags', config.flags); - } - let exclude = []; - if (config.excludeTest != null) { - exclude.push(config.excludeTest); - } - - config.set({ - ...devConfig, - reporters: ['dots', 'karma-typescript'], - plugins: [ - require('karma-chrome-launcher'), - require('karma-typescript'), - require('karma-jasmine'), - require('karma-jasmine-html-reporter'), - ], - exclude, - port: 9200, - colors: true, - autoWatch: false, - browsers: ['Chrome', 'chrome_webgpu'], - singleRun: true, - customLaunchers: { - chrome_webgpu: { - base: 'ChromeCanary', - flags: ['--disable-dawn-features=disallow_unsafe_apis'], - } - }, - client: {jasmine: {random: false}, args: args} - }) -} diff --git a/tfjs-master/tfjs-backend-webgpu/package.json b/tfjs-master/tfjs-backend-webgpu/package.json deleted file mode 100644 index 06c7ec90a..000000000 --- a/tfjs-master/tfjs-backend-webgpu/package.json +++ /dev/null @@ -1,48 +0,0 @@ -{ - "name": "@tensorflow/tfjs-backend-webgpu", - "version": "0.0.1-alpha.4", - "main": "dist/tf-backend-webgpu.node.js", - "types": "dist/index.d.ts", - "jsnext:main": "dist/index.js", - "module": "dist/index.js", - "unpkg": "dist/tf-backend-webgpu.min.js", - "jsdelivr": "dist/tf-backend-webgpu.min.js", - "miniprogram": "dist/miniprogram", - "scripts": { - "benchmark": "yarn test --//:grep=benchmark", - "build-ci": "yarn build", - "build": "yarn --cwd .. bazel build tfjs-backend-webgpu:tfjs-backend-webgpu_pkg", - "bundle": "yarn build", - "bundle-ci": "yarn bundle", - "build-npm": "yarn build", - "publish-npm": "yarn --cwd .. bazel run tfjs-backend-webgpu:tfjs-backend-webgpu_pkg.publish", - "test": "yarn --cwd .. bazel test tfjs-backend-webgpu:tfjs-backend-webgpu_test --test_output=streamed", - "test-dev": "yarn --cwd .. bazel run tfjs-backend-webgpu:tfjs-backend-webgpu_test --test_output=streamed" - }, - "license": "Apache-2.0", - "repository": { - "type": "git", - "url": "https://github.com/tensorflow/tfjs.git", - "directory": "tfjs-backend-webgpu" - }, - "devDependencies": { - "@babel/polyfill": "^7.8.7", - "@tensorflow/tfjs-core": "link:../link-package/node_modules/@tensorflow/tfjs-core", - "jasmine": "link:../node_modules/jasmine", - "jasmine-core": "link:../node_modules/jasmine-core", - "karma": "~6.4.0", - "karma-browserstack-launcher": "~1.6.0", - "karma-chrome-launcher": "~3.1.1", - "karma-commonjs": "^1.0.0", - "karma-jasmine": "~5.1.0", - "karma-typescript": "~5.5.3", - "karma-jasmine-html-reporter": "^2.0.0", - "karma-typescript-es6-transform": "^5.0.2" - }, - "dependencies": { - "@tensorflow/tfjs-backend-cpu": "link:../link-package/node_modules/@tensorflow/tfjs-backend-cpu" - }, - "peerDependencies": { - "@tensorflow/tfjs-core": "link:../link-package/node_modules/@tensorflow/tfjs-core" - } -} diff --git a/tfjs-master/tfjs-backend-webgpu/perf/tune.html b/tfjs-master/tfjs-backend-webgpu/perf/tune.html deleted file mode 100644 index 0b4c55057..000000000 --- a/tfjs-master/tfjs-backend-webgpu/perf/tune.html +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - Document - - - - - - - - - - diff --git a/tfjs-master/tfjs-backend-webgpu/perf/tune.js b/tfjs-master/tfjs-backend-webgpu/perf/tune.js deleted file mode 100644 index 8d691190f..000000000 --- a/tfjs-master/tfjs-backend-webgpu/perf/tune.js +++ /dev/null @@ -1,458 +0,0 @@ -window.addEventListener("DOMContentLoaded", initPage); -// append row to the HTML table -function appendRow(result) { - let tbl = document.getElementById('my-table'), // table reference - rowNum = tbl.rows.length - 1, - row = tbl.insertRow(tbl.rows.length); // append table row - // insert table cells to the new row - // 'Kernel name', 'Input', 'WebGPU', 'WebGL', 'WebGLComp', 'WebGPUProgram', 'WebGLProgram', 'Scale', - createCell(row.insertCell(0), result.name, result.name, `${result.name}-${rowNum}`); - createCell(row.insertCell(1), result.input, result.input, `input-${rowNum}`); - createCell(row.insertCell(2), result.webgpu, 'webgpu', `webgpu-${rowNum}`); - createCell(row.insertCell(3), result.webgl, 'webgl', `webgl-${rowNum}`); - createCell(row.insertCell(4), result.webglComp, 'webglComp', `webglComp-${rowNum}`); - createCell(row.insertCell(5), result.webgpuProgram, 'webgpuProgram', `webgpuProgram-${rowNum}`); - createCell(row.insertCell(6), result.webglProgram, 'webglProgram', `webglProgram-${rowNum}`); - createCell(row.insertCell(7), result.scale, `scale-${result.scale}`, `scale-${rowNum}`); - createCell(row.insertCell(8), 'Rerun', 'rerun', `rerun-${rowNum}`, rerun); -} - -// Update result table by rerun -function updateRow(result, rowNum) { - document.getElementById(`webgpu-${rowNum}`).innerHTML = result.webgpu; - document.getElementById(`webgl-${rowNum}`).innerHTML = result.webgl; - document.getElementById(`webglComp-${rowNum}`).innerHTML = result.webglComp; -} - -// create DIV element and append to the table cell -function createCell(cell, text, classes, id, onclick) { - let div = document.createElement('div'), // create DIV element - txt = document.createTextNode(text); // create text node - div.appendChild(txt); // append text node to the DIV - div.setAttribute('class', classes); // set DIV class attribute - div.setAttribute('id', id); - div.setAttribute('value', text); - if (onclick) { - div.setAttribute('type', 'button'); - let rowNum = id.split('-')[1]; - div.onclick = function () { onclick(rowNum) }; - } - cell.appendChild(div); // append DIV to the table cell -} - -function initPage() { - // get the reference for the body - const mybody = document.getElementsByTagName("body")[0]; - mybody.innerHTML = ''; - const myMessage = document.createElement("p"); - myMessage.id = 'message'; - mybody.appendChild(myMessage); - - // creates INFO labels - for (let info of INFO) { - const labelDiv = document.createElement('div'); - const label = document.createElement('label'); - label.innerHTML = `${info}`; - labelDiv.appendChild(label); - mybody.appendChild(labelDiv); - } - - // creates Scales labels and checkbox - for (let item of [SCALES]) { - let backendDiv = document.createElement('div'); - let labelClass = document.createElement("label"); - labelClass.innerHTML = 'Scales'; - backendDiv.appendChild(labelClass); - for (let i of item) { - let checkbox = document.createElement('input'); - checkbox.type = 'checkbox'; - if (currentScale.includes(i)) { - checkbox.checked = true; - } - checkbox.name = `scale-${i}`; - checkbox.value = i; - checkbox.className = `scaleCheckBox`; - checkbox.addEventListener('change', (event) => hideOrPresent(event)); - let label = document.createElement("label"); - label.innerHTML = i; - backendDiv.appendChild(checkbox); - backendDiv.appendChild(label); - } - mybody.appendChild(backendDiv); - } - - // creates run button - let btn = document.createElement("button"); - btn.id = 'run'; - btn.innerHTML = "Run"; - btn.style.background = 'orange'; - btn.onclick = function () { - run(); - }; - document.body.appendChild(btn); - - // creates and elements - const mytable = document.createElement("table"); - mytable.id = 'my-table'; - mytablebody = document.createElement("tbody"); - - // creates a element - mycurrent_row = document.createElement("tr"); - mycurrent_row.style = 'background-color:#BDB76B;color:#ffffff;'; - // creating all cells - ['Kernel name', 'Input', 'WebGPU', 'WebGL', 'WebGLComp %', 'WebGPUProgram', 'WebGLProgram', 'Scale(m*k*n)'].forEach((i) => { - // creates a - mycurrent_row.appendChild(mycurrent_cell); - }); - // appends the row into - mytablebody.appendChild(mycurrent_row); - - // appends into
element - mycurrent_cell = document.createElement("th"); - // creates a Text Node - currenttext = document.createTextNode(i); - // appends the Text Node we created into the cell - mycurrent_cell.appendChild(currenttext); - // appends the cell into the row
- mytable.appendChild(mytablebody); - // appends
into - mybody.appendChild(mytable); - // sets the border attribute of mytable to 2; - mytable.setAttribute("border", "2"); - - // Add sorting for tr - document.querySelectorAll('th').forEach(th => th.addEventListener('click', (() => { - const table = th.closest('table'); - Array.from(table.querySelectorAll('tr:nth-child(n+2)')) - .sort(comparer(Array.from(th.parentNode.children).indexOf(th), this.asc = !this.asc)) - .forEach(tr => table.appendChild(tr)); - }))); - - run(); -} - -async function timeMatmul(backend, rowNum) { - await tf.setBackend(backend); - let tensors = []; - let tensorsWarmUp = []; - let tensorsToDispose = []; - let inputs = []; - - // Prepare data - const warmA = tf.tensor2d( - Array.from({ length: warmUpSize * warmUpSize }, () => Math.floor(Math.random())), - [warmUpSize, warmUpSize] - ); - const warmB = tf.tensor2d( - Array.from({ length: warmUpSize * warmUpSize }, () => Math.floor(Math.random())), - [warmUpSize, warmUpSize] - ); - tensorsWarmUp = { tensorA: warmA, tensorB: warmB }; - tensorsToDispose.push(warmA); - tensorsToDispose.push(warmB); - if (rowNum !== undefined) { - let input = document.getElementById(`input-${rowNum}`).getAttribute('value'); - let m = input.split('[')[1].split(',')[0]; - let k = input.split('[')[2].split(']')[0].split(',')[0]; - let n = input.split('[')[2].split(']')[0].split(',')[1]; - inputs = [`${m},${k},${n}`]; - } - else { - inputs = INPUTS; - } - for (let i = 0; i < inputs.length; i++) { - let dimAOuter = parseInt(inputs[i].split(',')[0]); - let dimInner = parseInt(inputs[i].split(',')[1]); - let dimBOuter = parseInt(inputs[i].split(',')[2]); - const tensorA = tf.tensor2d( - Array.from({ length: dimAOuter * dimInner }, () => Math.floor(Math.random())), - [dimAOuter, dimInner] - ); - const tensorB = tf.tensor2d( - Array.from({ length: dimInner * dimBOuter }, () => Math.floor(Math.random())), - [dimInner, dimBOuter] - ); - tensors.push({ tensorA, tensorB }); - tensorsToDispose.push(tensorA); - tensorsToDispose.push(tensorB); - } - - tf.env().set('CHECK_COMPUTATION_FOR_ERRORS', false); - // Warmup, first run of each matmul shapes - for (let i = 0; i < inputs.length; i++) { - let result = tf.matMul(tensors[i].tensorA, tensors[i].tensorB); - await result.data(); - result.dispose(); - } - const profile_data = await tf.profile(() => { - // Warmup gpu and keep gpu frequency at a high level - document.getElementById('message').innerHTML = - `Warming up testing on ${backend} ...`; - for (let i = 0; i < numWarmUp; i++) { - let m = tf.matMul(tensorsWarmUp.tensorA, tensorsWarmUp.tensorB); - m.dispose(); - } - // Collect result from here - for (let i = 0; i < inputs.length; i++) { - document.getElementById('message').innerHTML = - `Testing on ${backend} ...`; - for (let j = 0; j < numAvg; j++) { - const result = tf.matMul(tensors[i].tensorA, tensors[i].tensorB); - // Insert large shape between each test to keep gpu high frequency - const m = tf.matMul(tensorsWarmUp.tensorA, tensorsWarmUp.tensorB); - result.dispose(); - m.dispose(); - } - } - }); - const profile_kernels = profile_data.kernels; - - for (let tensor of tensorsToDispose) { - tensor.dispose(); - } - return profile_kernels; -} - -function drawTable(webgpu_kernels, webgl_kernels, rowNum) { - for (let i = numWarmUp; i < webgpu_kernels.length; i += numAvg * 2) { - let inputInfo; - webgpu_kernels[i].inputShapes.forEach((inputShape, index) => { - if (inputInfo == null) { - inputInfo = ''; - } else { - inputInfo += '\n'; - } - if (inputShape == null) { - inputInfo += `input${index}: null`; - } else { - inputInfo += `input${index}: ${inputShape.length}D[${inputShape}]`; - } - }); - - let mkn = webgpu_kernels[i].inputShapes[0][0] * webgpu_kernels[i].inputShapes[0][1] * webgpu_kernels[i].inputShapes[1][1]; - - const avgWebgpu = getAvgKernelTime(webgpu_kernels.slice(i, i + 2 * numAvg)); - const avgWebgl = getAvgKernelTime(webgl_kernels.slice(i, i + 2 * numAvg)); - - const result = {}; - result.name = webgpu_kernels[i].name; - result.input = `${inputInfo}`; - result.webgpu = `${parseFloat(avgWebgpu).toFixed(2)}`; // WebGPU - result.webgl = `${parseFloat(avgWebgl).toFixed(2)}`; // WebGL - result.webglComp = `${parseFloat((result.webgl / result.webgpu) * 100).toFixed(0)}`; // WebGLComp - result.scale = `${parseInt(mkn)}`; // Scale - result.webgpuProgram = `${webgpu_kernels[i].extraInfo.split(',').map(x => x.split(':')[0])}`; // WebGPUProgram - result.webglProgram = `${webgl_kernels[i].extraInfo.split(',').map(x => x.split(':')[0])}`; // WebGLProgram - - if (rowNum !== undefined) { - updateRow(result, rowNum); - // update gpu result - webglCompResults[rowNum] = result.webglComp; - } else { - appendRow(result); - // store gpu result - webglCompResults.push(result.webglComp); - } - } -} - -function updateTable(avgWebgpu, avgWebgl, rowNum) { - const webglComp = `${parseFloat((avgWebgl / avgWebgpu) * 100).toFixed(0)}`; - const result = {}; - result.webgpu = `${parseFloat(avgWebgpu).toFixed(2)}`; - result.webgl = `${parseFloat(avgWebgl).toFixed(2)}`; - result.webglComp = webglComp; - updateRow(result, rowNum); - webglCompResults[rowNum] = webglComp; - -} - -function updateColor() { - for (let i = 0; i <= webglCompResults.length - 1; i++) { - const webglCompValue = webglCompResults[i]; - let r, g, b; - if (webglCompValue < 100) { - r = 255; - g = Math.floor(255 - 255 * ((100 - webglCompValue)) / 100); - b = Math.floor(255 - 255 * ((100 - webglCompValue)) / 100); - } else { - g = 255; - r = Math.floor(255 - 255 * ((webglCompValue - 100)) / 100); - b = Math.floor(255 - 255 * ((webglCompValue - 100)) / 100); - } - document.getElementById(`webglComp-${i}`).style = `background-color: rgb(${r}, ${g}, ${b})`; - } -} - -function hideOrPresent(event) { - const value = event.target.name; - const nodes = document.getElementsByClassName(value); - for (let i = 0; i <= nodes.length - 1; i++) { - if (event.target.checked) { - nodes[i].parentNode.parentNode.style = ``; - } else { - nodes[i].parentNode.parentNode.style = `display:none`; - } - } -} - -async function run() { - document.getElementById('run').disabled = true; - // remove results - let tableHeaderRowCount = 1; - let table = document.getElementById('my-table'); - let rowCount = table.rows.length; - for (let i = rowCount; i > tableHeaderRowCount; i--) { - table.deleteRow(i - 1); - } - const scaleSelected = []; - - // clear compared result - webglCompResults = []; - - // define scale suite - let scales = document.querySelectorAll('.scaleCheckBox:checked'); - for (let s of scales) { - scaleSelected.push(s.value); - } - - INPUTS = defaultInputs; - for (let scale of scaleSelected) { - let mySet = getTestSet(scale); - INPUTS = INPUTS.concat([...mySet]); - } - const profile_webgl = await timeMatmul('webgl'); - const profile_webgpu = await timeMatmul('webgpu'); - drawTable(profile_webgpu, profile_webgl); - document.getElementById('message').innerHTML = 'Done!'; - updateColor(); - document.getElementById('run').disabled = false; -} - -async function rerun(rowNum) { - const profile_webgl = await timeMatmul('webgl', rowNum); - const profile_webgpu = await timeMatmul('webgpu', rowNum); - const avgWebgl = getAvgKernelTime(profile_webgl.slice(-numAvg * 2)); - const avgWebgpu = getAvgKernelTime(profile_webgpu.slice(-numAvg * 2)); - updateTable(avgWebgpu, avgWebgl, rowNum); - document.getElementById('message').innerHTML = 'Done!'; - updateColor(); -} - -const getCellValue = (tr, idx) => tr.children[idx].innerText || tr.children[idx].textContent; - -const comparer = (idx, asc) => (a, b) => ((v1, v2) => - v1 !== '' && v2 !== '' && !isNaN(v1) && !isNaN(v2) ? v1 - v2 : v1.toString().localeCompare(v2) -)(getCellValue(asc ? a : b, idx), getCellValue(asc ? b : a, idx)); - -function getFactors(c) { - const y = []; - let min = 1; - let max = c; - while (min < max && min * min <= c) { - if (c % min === 0) { - y.push(min, c / min); - max = c / min; - } - min++; - } - return y; -} - -function getTestSet(num) { - const factors = getFactors(num); - const mySet = new Set(); - for (let i = 0; i < factors.length; i++) { - for (let j = 0; j < factors.length; j++) { - if (factors[i] * factors[j] < num && num % (factors[i] * factors[j]) === 0) { - let m = factors[i]; - let n = factors[j]; - let k = num / factors[i] / factors[j]; - if (m > 15 && n > 15 && k > 15 - && n < 2048 && k < 2048 - && Math.sqrt(m) % 1 === 0) { - mySet.add(`${m},${k},${n}`); - } - } - } - } - return mySet; -} - -function getPrimeFactor(num) { - const prime_factor = []; - for (let i = 2; i < num; i++) { - if (num % i == 0) { - prime_factor.push(i); - num /= i; - i -= 1; - } - } - prime_factor.push(num); - return prime_factor; -} - -function getAvgKernelTime(kernels) { - const avg = kernels.reduce( - (a, b, index) => { - if (index % 2 === 0) { - return a + b.kernelTimeMs; - } - return a; - }, - 0, - ) / numAvg; - return avg; -} - -let webglCompResults = []; - -let SCALES = [1016064, 5013504, 10838016, 33554432]; -let currentScale = []; -let defaultInputs = [ - '1, 1280, 1001', - '12544, 16, 64', - '196, 672, 112', - '1, 960, 1280', - '196, 112, 672', - '196, 480, 112', - '49, 960, 160', - '784, 40, 240', - '49, 672, 160', - '3136, 24, 72', - '3136, 72, 24', - '49, 160, 960', - '196, 80, 480', - '784, 120, 40', - '784, 40, 120', - '3136, 64, 24', - '784, 72, 40', - '1, 240, 960', - '196, 80, 200', - '1, 960, 240', - '196, 240, 80', - '12544, 16, 16', - '196, 200, 80', - '196, 80, 184', - '196, 184, 80', - '1, 672, 168', - '1, 168, 672', - '1, 480, 120', - '1, 32, 120', - '1, 120, 480', - '1, 120, 32', - '1, 24, 72', - '1, 72, 24', -]; - -let INPUTS = []; -const numWarmUp = 1000; -const numAvg = 20; -const warmUpSize = 512; -const INFO = [ - '0. Run under flag: --enable-unsafe-webgpu --disable-dawn-features=disallow_unsafe_apis', - '1. Sortable by clicking table column title', - '2. Rerunable for every single line', - '3. Set checkBox below to define new test suite', - '4. Default workloads are used for MobileNetV3', -]; diff --git a/tfjs-master/tfjs-backend-webgpu/rollup.config.js b/tfjs-master/tfjs-backend-webgpu/rollup.config.js deleted file mode 100644 index 35ba82bba..000000000 --- a/tfjs-master/tfjs-backend-webgpu/rollup.config.js +++ /dev/null @@ -1,121 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import commonjs from '@rollup/plugin-commonjs'; -import resolve from '@rollup/plugin-node-resolve'; -import typescript from '@rollup/plugin-typescript'; -import visualizer from 'rollup-plugin-visualizer'; -import {getBrowserBundleConfigOptions} from '../rollup.config.helpers'; - -const PREAMBLE = `/** - * @license - * Copyright ${(new Date).getFullYear()} Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */`; - -function config({ - plugins = [], - output = {}, - external = [], - visualize = false, - tsCompilerOptions = {} -}) { - if (visualize) { - const filename = output.file + '.html'; - plugins.push(visualizer( - {sourcemap: true, filename, template: 'sunburst', gzipSize: true})); - console.log(`Will output a bundle visualization in ${filename}`); - } - - const defaultTsOptions = { - include: ['src/**/*.ts'], - module: 'ES2015', - }; - const tsoptions = Object.assign({}, defaultTsOptions, tsCompilerOptions); - - return { - input: 'src/index.ts', - plugins: [ - typescript(tsoptions), resolve(), - // Polyfill require() from dependencies. - commonjs({ - ignore: ['crypto'], - include: 'node_modules/**', - }), - ...plugins - ], - output: { - banner: PREAMBLE, - sourcemap: true, - globals: {'@tensorflow/tfjs-core': 'tf'}, - ...output, - }, - external: ['@tensorflow/tfjs-core'], - onwarn: warning => { - let {code} = warning; - if (code === 'CIRCULAR_DEPENDENCY' || code === 'CIRCULAR' || - code === 'THIS_IS_UNDEFINED') { - return; - } - console.warn('WARNING: ', warning.toString()); - } - }; -} - -module.exports = cmdOptions => { - const bundles = []; - const name = 'tf'; - const extend = true; - const fileName = 'tf-backend-webgpu'; - - // Node - bundles.push(config({ - output: { - format: 'cjs', - name, - extend, - file: `dist/${fileName}.node.js`, - freeze: false - }, - tsCompilerOptions: {target: 'es5'} - })); - - if (cmdOptions.ci) { - const browserBundles = getBrowserBundleConfigOptions( - config, name, fileName, PREAMBLE, cmdOptions.visualize, true /* CI */); - bundles.push(...browserBundles); - } - - if (cmdOptions.npm) { - const browserBundles = getBrowserBundleConfigOptions( - config, name, fileName, PREAMBLE, cmdOptions.visualize, false /* CI */); - bundles.push(...browserBundles); - } - - return bundles; -}; diff --git a/tfjs-master/tfjs-backend-webgpu/scripts/build-npm.sh b/tfjs-master/tfjs-backend-webgpu/scripts/build-npm.sh deleted file mode 100644 index 0b772cdd9..000000000 --- a/tfjs-master/tfjs-backend-webgpu/scripts/build-npm.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/env bash -# Copyright 2021 Google LLC. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================= - -set -e - -yarn rimraf dist/ -yarn - -yarn build -yarn rollup -c --visualize --npm - -# Use minified files for miniprogram -mkdir dist/miniprogram -cp dist/tf-backend-webgpu.min.js dist/miniprogram/index.js -cp dist/tf-backend-webgpu.min.js.map dist/miniprogram/index.js.map - -echo "Stored standalone library at dist/tf-backend-webgpu(.min).js" diff --git a/tfjs-master/tfjs-backend-webgpu/scripts/publish-npm.sh b/tfjs-master/tfjs-backend-webgpu/scripts/publish-npm.sh deleted file mode 100644 index 4c3edf8d4..000000000 --- a/tfjs-master/tfjs-backend-webgpu/scripts/publish-npm.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env bash -# Copyright 2019 Google LLC. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================= - -yarn build -rollup -c -npm publish --tag beta diff --git a/tfjs-master/tfjs-backend-webgpu/src/BUILD.bazel b/tfjs-master/tfjs-backend-webgpu/src/BUILD.bazel deleted file mode 100644 index 4d3da28cd..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/BUILD.bazel +++ /dev/null @@ -1,98 +0,0 @@ -# Copyright 2021 Google LLC. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================= - -load("//tools:defaults.bzl", "esbuild", "ts_library") -load("//tools:enumerate_tests.bzl", "enumerate_tests") - -package(default_visibility = ["//visibility:public"]) - -TEST_SRCS = [ - "**/*_test.ts", -] - -filegroup( - name = "all_test_entrypoints", - srcs = glob( - ["**/*_test.ts"], - exclude = [ - "setup_test.ts", - ], - ), -) - -# Generates the 'tests.ts' file that imports all test entrypoints. -enumerate_tests( - name = "tests", - srcs = [":all_test_entrypoints"], - root_path = "tfjs-backend-webgpu/src", -) - -ts_library( - name = "tfjs-backend-webgpu_src_lib", - srcs = glob( - ["**/*.ts"], - exclude = TEST_SRCS + ["index.ts"], - ), - module_name = "@tensorflow/tfjs-backend-webgpu/dist", - deps = [ - "//tfjs-backend-cpu/src:tfjs-backend-cpu_lib", - "//tfjs-backend-cpu/src:tfjs-backend-cpu_src_lib", - "//tfjs-core/src:tfjs-core_lib", - "//tfjs-core/src:tfjs-core_src_lib", - "@npm//@types/offscreencanvas", - "@npm//@webgpu/types", - ], -) - -ts_library( - name = "tfjs-backend-webgpu_lib", - srcs = ["index.ts"], - module_name = "@tensorflow/tfjs-backend-webgpu", - deps = [ - ":tfjs-backend-webgpu_src_lib", - "//tfjs-core/src:tfjs-core_lib", - "//tfjs-core/src:tfjs-core_src_lib", - ], -) - -ts_library( - name = "tfjs-backend-webgpu_test_lib", - # testonly = True, - srcs = glob(TEST_SRCS) + [":tests"], - module_name = "@tensorflow/tfjs-backend-webgpu/dist", - deps = [ - ":tfjs-backend-webgpu_lib", - ":tfjs-backend-webgpu_src_lib", - "//tfjs-backend-cpu/src:tfjs-backend-cpu_lib", - "//tfjs-core/src:tfjs-core_lib", - "//tfjs-core/src:tfjs-core_src_lib", - "//tfjs-core/src:tfjs-core_test_lib", - "@npm//@webgpu/types", - ], -) - -esbuild( - name = "tfjs-backend-webgpu_test_bundle", - testonly = True, - entry_point = "setup_test.ts", - external = [ - "util", - ], - sources_content = True, - deps = [ - ":tfjs-backend-webgpu_lib", - ":tfjs-backend-webgpu_test_lib", - ], -) diff --git a/tfjs-master/tfjs-backend-webgpu/src/activation_util.ts b/tfjs-master/tfjs-backend-webgpu/src/activation_util.ts deleted file mode 100644 index bda3917a2..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/activation_util.ts +++ /dev/null @@ -1,76 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util} from '@tensorflow/tfjs-core'; - -import {BinaryOpType, getBinaryOpString} from './binary_op_util'; -import {getUnaryOpString, UnaryOpType} from './unary_op_util'; -import {typeSnippet} from './webgpu_program'; - -export function activationFnSnippet( - activation: backend_util.Activation, hasPreluActivationWeights = false, - packed = false, coordsLength = 3): string { - if (activation === null) { - return ''; - } - - let activationOpSnippet = ''; - if (activation === 'linear') { - activationOpSnippet = getUnaryOpString(UnaryOpType.LINEAR); - } else if (activation === 'relu') { - activationOpSnippet = getUnaryOpString(UnaryOpType.RELU, packed); - } else if (activation === 'elu') { - activationOpSnippet = getUnaryOpString(UnaryOpType.ELU, packed); - } else if (activation === 'relu6') { - activationOpSnippet = getUnaryOpString(UnaryOpType.RELU6, packed); - } else if (activation === 'prelu') { - activationOpSnippet = getBinaryOpString(BinaryOpType.PRELU, packed); - } else if (activation === 'sigmoid') { - activationOpSnippet = getUnaryOpString(UnaryOpType.SIGMOID, packed); - } else if (activation === 'leakyrelu') { - activationOpSnippet = getUnaryOpString(UnaryOpType.LEAKYRELU, packed); - } else { - throw new Error(`Activation ${ - activation} has not been implemented for the WebGPU backend.`); - } - const elementSize = packed ? 4 : 1; - const dataType = typeSnippet(elementSize); - let activationFnSnippet = ''; - if (hasPreluActivationWeights) { - activationFnSnippet = ` - fn activation(a : ${dataType}, coords : vec${coordsLength}) -> ${ - dataType} { - let b = getPreluActivationWeightsByOutputCoords(coords); - ${activationOpSnippet} - }`; - } else { - activationFnSnippet = ` - fn activation(a : ${dataType}, coords : vec${coordsLength}) -> ${ - dataType} { - ${activationOpSnippet} - }`; - } - return activationFnSnippet; -} - -export function biasActivationSnippet( - hasBias: boolean, activation: backend_util.Activation): string { - return ` - ${hasBias ? 'value = value + getBiasByOutputCoords(coords);' : ''} - ${activation ? 'value = activation(value, coords);' : ''} - `; -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/adapter_info.ts b/tfjs-master/tfjs-backend-webgpu/src/adapter_info.ts deleted file mode 100644 index fa124b57c..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/adapter_info.ts +++ /dev/null @@ -1,45 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -export class AdapterInfo { - private vendor: string; - private architecture: string; - public intelGPUGeneration: number; - - constructor(adapterInfo: GPUAdapterInfo) { - if (adapterInfo) { - this.vendor = adapterInfo.vendor; - this.architecture = adapterInfo.architecture; - this.intelGPUGeneration = this.getIntelGPUGeneration(); - } - } - - private getIntelGPUGeneration() { - if (this.isIntel()) { - if (this.architecture.startsWith('gen')) { - return Number(this.architecture.match(/\d+/)); - } else if (this.architecture.startsWith('xe')) { - return 12; - } - } - return 0; - } - - isIntel(): boolean { - return this.vendor === 'intel'; - } -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/addn_packed_webgpu.ts b/tfjs-master/tfjs-backend-webgpu/src/addn_packed_webgpu.ts deleted file mode 100644 index 30494fffb..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/addn_packed_webgpu.ts +++ /dev/null @@ -1,68 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {getMainHeaderString as main, WebGPUProgram} from './webgpu_program'; -import {computeDispatch, flatDispatchLayout} from './webgpu_util'; - -export class AddNPackedProgram implements WebGPUProgram { - outputShape: number[]; - shaderKey: string; - dispatchLayout: {x: number[]}; - dispatch: [number, number, number]; - variableNames: string[]; - workPerThread = 1; - workgroupSize: [number, number, number] = [64, 1, 1]; - size = true; - - constructor(shapes: number[][]) { - this.outputShape = shapes[0]; - this.variableNames = shapes.map((_, i) => `T${i}`); - this.dispatchLayout = flatDispatchLayout(this.outputShape); - this.dispatch = computeDispatch( - this.dispatchLayout, this.outputShape, this.workgroupSize, - [this.workPerThread, 1, 1]); - this.shaderKey = 'addN'; - } - - getUserCode(): string { - const snippets: string[] = []; - // Get target elements from every input tensor. - this.variableNames.forEach(variable => { - snippets.push(`let v${variable} = get${variable}ByOutputCoords(coords);`); - }); - // Calculate the sum of all elements. - const operation = this.variableNames - .map(variable => { - return `v${variable}`; - }) - .join(' + '); - - const userCode = ` - ${main('index')} { - for (var i = 0; i < ${this.workPerThread}; i = i + 1) { - let flatIndex = index * ${this.workPerThread} + i; - if (flatIndex < uniforms.size) { - let coords = getCoordsFromIndex(flatIndex); - ${snippets.join('\n ')} - setOutputAtIndex(flatIndex, ${operation}); - } - } - } - `; - return userCode; - } -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/argminmax_webgpu.ts b/tfjs-master/tfjs-backend-webgpu/src/argminmax_webgpu.ts deleted file mode 100644 index f70598ecd..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/argminmax_webgpu.ts +++ /dev/null @@ -1,167 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, util} from '@tensorflow/tfjs-core'; -import {getCoordsXYZ, getMainHeaderString as main, WebGPUProgram} from './webgpu_program'; -import {computeDispatch, flatDispatchLayout} from './webgpu_util'; - -export class ArgMinMaxProgram implements WebGPUProgram { - outputShape: number[]; - shaderKey: string; - dispatchLayout: {x: number[]}; - dispatch: [number, number, number]; - workgroupSize: [number, number, number] = [64, 1, 1]; - variableNames = ['x']; - uniforms = 'infinityValue : f32,'; - inputShape: number[]; - reductionFactor: number; - op: string; - size = true; - private type: string; - - constructor(inputShape: number[], axis: number, reduceType: 'min'|'max') { - const axes = [axis]; - - this.op = reduceType === 'min' ? '<' : '>'; - - // |outShape| is the shape with the removed axis - const [outputShape, reduceShape] = - backend_util.computeOutAndReduceShapes(inputShape, axes); - - this.outputShape = outputShape.length === 0 ? [1] : outputShape; - this.dispatchLayout = flatDispatchLayout(this.outputShape); - // The shared algorithm is mainly used for large reduce size. It fully - // utilizes the threads in one workgroup to do the reduction. However, - // when the reduce size is very small, it's better to use the plain - // algorithm to reduce the number of workgroups to speedup. The threthold - // can be further tuned. - if (util.sizeFromShape(reduceShape) < 32) { - this.type = 'plain'; - this.dispatch = computeDispatch( - this.dispatchLayout, this.outputShape, this.workgroupSize); - } else { - this.type = 'shared'; - // A work group only outputs a data, so we transfer [1, 1, 1] to compute - // dispatch size. - this.dispatch = - computeDispatch(this.dispatchLayout, this.outputShape, [1, 1, 1]); - } - - this.inputShape = inputShape; - this.shaderKey = `argMinMax_${this.op}_${this.type}`; - } - - getUserCode(): string { - const workgroupSizeX = this.workgroupSize[0]; - const getInputShapeLastDim = () => { - if (this.inputShape.length === 1) { - return 'uniforms.xShape'; - } else { - return `uniforms.xShape.${getCoordsXYZ(this.inputShape.length - 1)}`; - } - }; - - const splitOutputCoords = () => { - let snippet = ''; - if (this.outputShape.length === 1) { - if (this.inputShape.length !== 1) { - snippet += 'outputCoords,'; - } - } else { - for (let i = 0; i < this.outputShape.length; i++) { - snippet += `outputCoords.${getCoordsXYZ(i)},`; - } - } - return snippet; - }; - - if (this.type === 'shared') { - const sharedMemorySnippet = ` - var xBestIndices : array; - var xBestValues : array; - `; - const userCode = ` - fn DIV_CEIL(a : u32, b : u32) -> u32 { - return ((a - 1u) / b + 1u); - } - - ${sharedMemorySnippet} - - ${main('index')} { - let outputIndex = index / ${workgroupSizeX}; - let reduceLength = ${getInputShapeLastDim()}; - - var bestIndex = i32(localId.x); - var bestValue = uniforms.infinityValue; - let outputCoords = getCoordsFromIndex(outputIndex); - for (var k = i32(localId.x); k < reduceLength && outputIndex < uniforms.size; - k = k + ${workgroupSizeX}) { - let candidate = getX(${splitOutputCoords()} k); - if (!isnan(candidate) && candidate ${this.op} bestValue) { - bestValue = candidate; - bestIndex = k; - } - } - xBestValues[localId.x] = bestValue; - xBestIndices[localId.x] = bestIndex; - workgroupBarrier(); - - var reduceSize = min(u32(reduceLength), ${workgroupSizeX}u); - for (var currentSize = reduceSize / 2u; reduceSize > 1u; - currentSize = reduceSize / 2u) { - let interval = DIV_CEIL(reduceSize, 2u); - if (localId.x < currentSize) { - let candidate = xBestValues[localId.x + interval]; - if (candidate ${this.op} bestValue) { - bestValue = candidate; - xBestValues[localId.x] = bestValue; - xBestIndices[localId.x] = xBestIndices[localId.x + interval]; - } - } - reduceSize = interval; - workgroupBarrier(); - } - - if (localId.x == 0u && outputIndex < uniforms.size) { - setOutputAtIndexI32(outputIndex, xBestIndices[localId.x]); - } - } - `; - return userCode; - } else { - const userCode = ` - ${main('index')} { - if (index < uniforms.size) { - let outputCoords = getCoordsFromIndex(index); - var bestIndex = 0; - var bestValue = getX(${splitOutputCoords()} 0); - let reduceLength = ${getInputShapeLastDim()}; - for (var i = 1; i < reduceLength; i++) { - let candidate = getX(${splitOutputCoords()} i); - if (candidate ${this.op} bestValue) { - bestValue = candidate; - bestIndex = i; - } - } - setOutputAtIndexI32(index, bestIndex); - } - } - `; - return userCode; - } - } -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/avg_pool_backprop_webgpu.ts b/tfjs-master/tfjs-backend-webgpu/src/avg_pool_backprop_webgpu.ts deleted file mode 100644 index 3e70c96f9..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/avg_pool_backprop_webgpu.ts +++ /dev/null @@ -1,163 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util} from '@tensorflow/tfjs-core'; -import {getMainHeaderString as main, WebGPUProgram} from './webgpu_program'; -import {computeDispatch, flatDispatchLayout} from './webgpu_util'; - -export class AvgPool2DBackpropProgram implements WebGPUProgram { - outputShape: number[]; - shaderKey: string; - dispatchLayout: {x: number[]}; - dispatch: [number, number, number]; - variableNames = ['dy']; - uniforms = - `strides : vec2, pads : vec2, dilations : vec2, filterDims : vec2, - outHeight : i32, outWidth : i32, avgMultiplier : f32,`; - workgroupSize: [number, number, number] = [64, 1, 1]; - size = true; - - constructor(convInfo: backend_util.Conv2DInfo) { - this.outputShape = convInfo.inShape; - - this.dispatchLayout = flatDispatchLayout(this.outputShape); - - this.dispatch = computeDispatch( - this.dispatchLayout, this.outputShape, this.workgroupSize); - - this.shaderKey = `avgPool2DBackprop`; - } - - getUserCode(): string { - const userCode = ` - ${main('index')} { - if (index < uniforms.size) { - let coords = getCoordsFromIndex(index); - let batch = coords[0]; - let d = coords[3]; - - let dyRCCorner = vec2(coords.yz) - uniforms.pads; - let dyRCorner = dyRCCorner.x; - let dyCCorner = dyRCCorner.y; - - // Convolve dy(?, ?, d) with pos mask(:, :, d) to get dx(xR, xC, d). - // ? = to be determined. : = across all values in that axis. - var dotProd = 0.0; - for (var wR = 0; wR < uniforms.filterDims[0]; wR = wR + uniforms.dilations[0]) { - let dyR = f32(dyRCorner + wR) / f32(uniforms.strides[0]); - - if (dyR < 0.0 || dyR >= f32(uniforms.outHeight) || fract(dyR) > 0.0) { - continue; - } - let idyR = i32(dyR); - - for (var wC = 0; wC < uniforms.filterDims[1]; wC = wC + uniforms.dilations[1]) { - let dyC = f32(dyCCorner + wC) / f32(uniforms.strides[1]); - - if (dyC < 0.0 || dyC >= f32(uniforms.outWidth) || fract(dyC) > 0.0) { - continue; - } - let idyC = i32(dyC); - - let dyValue = getDy(batch, idyR, idyC, d); - - dotProd = dotProd + dyValue * uniforms.avgMultiplier; - } - } - setOutputAtIndex(index, dotProd); - } - } - `; - return userCode; - } -} - -export class AvgPool3DBackpropProgram implements WebGPUProgram { - outputShape: number[]; - shaderKey: string; - dispatchLayout: {x: number[]}; - dispatch: [number, number, number]; - variableNames = ['dy']; - uniforms = `strides : vec3, pads : vec3, filterDims : vec3, - outDepth : i32, outHeight : i32, outWidth : i32, avgMultiplier : f32,`; - workgroupSize: [number, number, number] = [64, 1, 1]; - size = true; - - constructor(convInfo: backend_util.Conv3DInfo) { - this.outputShape = convInfo.inShape; - - this.dispatchLayout = flatDispatchLayout(this.outputShape); - - this.dispatch = computeDispatch( - this.dispatchLayout, this.outputShape, this.workgroupSize); - - this.shaderKey = `avgPool3DBackprop`; - } - - getUserCode(): string { - const userCode = ` - ${main('index')} { - if (index < uniforms.size) { - let coords = getCoordsFromIndex(index); - let batch = coords.x; - let ch = coords.u; - - let dyCorner = vec3(coords.y, coords.z, coords.w) - uniforms.pads; - let dyDCorner = dyCorner.x; - let dyRCorner = dyCorner.y; - let dyCCorner = dyCorner.z; - - // Convolve dy(?, ?, ?, d) with pos mask(:, :, :, ch) to get - // dx(xD, xR, xC, ch). - // ? = to be determined. : = across all values in that axis. - var dotProd = 0.0; - for (var wD = 0; wD < uniforms.filterDims[0]; wD++) { - let dyD = f32(dyDCorner + wD) / f32(uniforms.strides[0]); - - if (dyD < 0.0 || dyD >= f32(uniforms.outDepth) || fract(dyD) > 0.0) { - continue; - } - let idyD = i32(dyD); - - for (var wR = 0; wR < uniforms.filterDims[1]; wR++) { - let dyR = f32(dyRCorner + wR) / f32(uniforms.strides[1]); - - if (dyR < 0.0 || dyR >= f32(uniforms.outHeight) || fract(dyR) > 0.0) { - continue; - } - let idyR = i32(dyR); - - for (var wC = 0; wC < uniforms.filterDims[2]; wC++) { - let dyC = f32(dyCCorner + wC) / f32(uniforms.strides[2]); - - if (dyC < 0.0 || dyC >= f32(uniforms.outWidth) || fract(dyC) > 0.0) { - continue; - } - let idyC = i32(dyC); - - let dyValue = getDy(batch, idyD, idyR, idyC, ch); - dotProd += dyValue * uniforms.avgMultiplier; - } - } - } - setOutputAtIndex(index, dotProd); - } - } - `; - return userCode; - } -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/backend_webgpu.ts b/tfjs-master/tfjs-backend-webgpu/src/backend_webgpu.ts deleted file mode 100644 index ceae66c51..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/backend_webgpu.ts +++ /dev/null @@ -1,1053 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import './flags_webgpu'; - -import {backend_util, BackendValues, buffer, DataStorage, DataType, engine, env, GPUData, KernelBackend, Rank, RecursiveArray, ShapeMap, Tensor, TensorBuffer, TensorInfo, TimingInfo, TypedArray, util, WebGPUData} from '@tensorflow/tfjs-core'; - -import {AdapterInfo} from './adapter_info'; -import {BufferManager} from './buffer_manager'; -import {TextureManager} from './texture_manager'; -import * as webgpu_program from './webgpu_program'; -import * as webgpu_util from './webgpu_util'; - -export interface WebGPUMemoryInfo extends backend_util.MemoryInfo { - numBytesInGPU: number; - numBytesAllocatedInGPU: number; - unreliable: boolean; -} - -type TensorData = { - values: BackendValues, - dtype: DataType, - shape: number[], - refCount: number, - resource?: GPUBuffer|GPUTexture|GPUExternalTexture, - // external is true means we use the resource provided by users directly - // (without a copy), so users should be responsible for its release. - external?: boolean, - // For complex numbers, the real and imaginary parts are stored as their own - // individual tensors, with a parent joining the two with the - // complexTensorInfos field. - complexTensorInfos?: {real: TensorInfo, imag: TensorInfo} -}; - -interface DataId {} - -export type WebGPUKernelInfo = { - name: string, - query: Promise, -}; - -export type TimerNode = RecursiveArray|WebGPUKernelInfo; - -export interface WebGPUTimingInfo extends TimingInfo { - uploadWaitMs: number; - downloadWaitMs: number; -} - -type ProgramUniform = Array<{type: string; data: number[]}>; - -// Empirically determined constant used to determine size threshold for handing -// off execution to the CPU. -const CPU_HANDOFF_SIZE_THRESHOLD = - env().getNumber('WEBGPU_CPU_HANDOFF_SIZE_THRESHOLD'); - -// Reshape dispatch, not to exceed device limits. -const reshapeDispatch = - (device: GPUDevice, - program: webgpu_program.WebGPUProgram): [number, number, number] => { - const MAX_COMPUTE_PER_DIMENSION_DISPATCH_SIZE = - device.limits.maxComputeWorkgroupsPerDimension; - const layout = program['dispatchLayout']; - const dispatch = program['dispatch']; - if (dispatch.every((d) => d <= MAX_COMPUTE_PER_DIMENSION_DISPATCH_SIZE)) { - return dispatch; - } - - util.assert( - dispatch[0] > MAX_COMPUTE_PER_DIMENSION_DISPATCH_SIZE && - layout.y === undefined && layout.z === undefined, - () => 'Dispatch size exceeds WebGPU limits in Y or Z dimension.'); - - let dispatchAverage = Math.ceil(Math.sqrt(dispatch[0])); - if (dispatchAverage > MAX_COMPUTE_PER_DIMENSION_DISPATCH_SIZE) { - dispatchAverage = Math.ceil(Math.cbrt(dispatch[0])); - util.assert( - dispatchAverage <= MAX_COMPUTE_PER_DIMENSION_DISPATCH_SIZE, - () => 'Total dispatch size exceeds WebGPU maximum.'); - return [dispatchAverage, dispatchAverage, dispatchAverage]; - } else { - return [dispatchAverage, dispatchAverage, 1]; - } - }; - -export class WebGPUBackend extends KernelBackend { - bufferManager: BufferManager; - adapterInfo: AdapterInfo; - device: GPUDevice; - queue: GPUQueue; - tensorMap: DataStorage; - textureManager: TextureManager; - thresholdToIncreaseWorkgroups: number; - - private activeTimers: TimerNode[]; - private commandEncoder: GPUCommandEncoder; - private computePassEncoder: GPUComputePassEncoder; - private commandQueueOwnedIds = new WeakSet(); - private dispatchCountInPass = 0; - private disposed = false; - private downloadWaitMs = 0; - private dummyCanvas: HTMLCanvasElement; - private dummyContext: GPUCanvasContext; - private tensorDataPendingDisposal: DataId[] = []; - private static nextDataId = 0; - private pipelineCache: - {[key: string]: GPUComputePipeline|Promise}; - private programTimersStack: TimerNode[]; - private queryResolveBuffer: GPUBuffer = null; - private querySet: GPUQuerySet = null; - private querySetCount = 2; - private stagingPendingDisposal: GPUBuffer[] = []; - private supportTimestampQuery: boolean; - private uniformPendingDisposal: GPUBuffer[] = []; - private uploadWaitMs = 0; - private hasReadSyncWarned = false; - private hasTimestampQueryWarned = false; - - private nextDataId(): number { - return WebGPUBackend.nextDataId++; - } - - constructor(device: GPUDevice, adapterInfo?: GPUAdapterInfo) { - super(); - if (!webgpu_util.isWebGPUSupported()) { - throw new Error('WebGPU is not supported on this device'); - } - this.pipelineCache = {}; - this.device = device; - this.queue = device.queue; - this.commandEncoder = null; - this.computePassEncoder = null; - this.adapterInfo = new AdapterInfo(adapterInfo); - this.supportTimestampQuery = this.device.features.has('timestamp-query'); - this.thresholdToIncreaseWorkgroups = - this.adapterInfo.intelGPUGeneration >= 12 ? 16 : 8; - - this.bufferManager = new BufferManager(this.device); - this.textureManager = new TextureManager(this.device); - this.tensorMap = new DataStorage(this, engine()); - - // Profiling tools like PIX needs this dummy canvas to - // trigger capturing a frame. - if (env().getBool('WEBGPU_USE_PROFILE_TOOL')) { - this.dummyCanvas = document.createElement('canvas'); - this.dummyCanvas.width = 1; - this.dummyCanvas.height = 1; - - this.dummyContext = this.dummyCanvas.getContext('webgpu'); - this.dummyContext.configure({ - device, - format: 'bgra8unorm', - }); - - document.body.appendChild(this.dummyCanvas); - } - } - - override floatPrecision(): 32 { - return 32; - } - - /** - * Dispose the memory if the dataId has 0 refCount. Return true if the memory - * is released or delayed in this backend, false if there are still - * references. - * @param dataId - * @oaram force Optional, remove the data regardless of refCount - */ - override disposeData(dataId: DataId, force = false): boolean { - // No-op if already disposed. - if (!this.tensorMap.has(dataId)) { - return true; - } - - const tensorData = this.tensorMap.get(dataId); - if (force) { - tensorData.refCount = 0; - } else { - tensorData.refCount--; - } - - if (tensorData.refCount > 0) { - return false; - } - - if (tensorData.complexTensorInfos != null) { - this.disposeData(tensorData.complexTensorInfos.real.dataId); - this.disposeData(tensorData.complexTensorInfos.imag.dataId); - } - - if (this.commandQueueOwnedIds.has(dataId)) { - this.tensorDataPendingDisposal.push(dataId); - return true; - } - - this.releaseResource(dataId); - this.tensorMap.delete(dataId); - - return true; - } - - override memory(): WebGPUMemoryInfo { - return { - numBytesInGPU: this.bufferManager.numBytesUsed, - numBytesAllocatedInGPU: this.bufferManager.numBytesAllocated, - unreliable: false - } as WebGPUMemoryInfo; - } - - private releaseResource(dataId: DataId) { - const tensorData = this.tensorMap.get(dataId); - if (!tensorData || !tensorData.resource) { - return; - } - - // If tensor's resource is from external, do not release. - if (tensorData.external) { - tensorData.resource = null; - return; - } - if (tensorData.resource instanceof GPUBuffer) { - this.bufferManager.releaseBuffer(tensorData.resource); - } else if (tensorData.resource instanceof GPUTexture) { - this.textureManager.releaseTexture(tensorData.resource); - } - tensorData.resource = null; - } - - /** Return refCount of a `TensorData`. */ - override refCount(dataId: DataId): number { - if (this.tensorMap.has(dataId)) { - const tensorData = this.tensorMap.get(dataId); - return tensorData.refCount; - } - return 0; - } - - /** Increase refCount of a `TensorData`. */ - override incRef(dataId: DataId): void { - const tensorData = this.tensorMap.get(dataId); - tensorData.refCount++; - } - - /** Decrease refCount of a `TensorData`. */ - decRef(dataId: DataId): void { - if (this.tensorMap.has(dataId)) { - const tensorData = this.tensorMap.get(dataId); - tensorData.refCount--; - } - } - - override write(values: BackendValues, shape: number[], dtype: DataType): - DataId { - if (dtype === 'complex64' && values != null) { - throw new Error( - `Cannot write to a complex64 dtype. ` + - `Please use tf.complex(real, imag).`); - } - const dataId = {id: this.nextDataId()}; - this.tensorMap.set(dataId, {dtype, shape, values, refCount: 1}); - return dataId; - } - - override move( - dataId: DataId, values: BackendValues, shape: number[], dtype: DataType, - refCount: number): void { - if (dtype === 'complex64') { - throw new Error( - `Cannot write to a complex64 dtype. ` + - `Please use tf.complex(real, imag).`); - } - this.tensorMap.set(dataId, {dtype, shape, values, refCount}); - } - - submitQueue() { - this.queue.submit([this.commandEncoder.finish()]); - this.commandEncoder = null; - this.dispatchCountInPass = 0; - - this.commandQueueOwnedIds = new WeakSet(); - - this.tensorDataPendingDisposal.forEach(d => { - this.releaseResource(d); - this.tensorMap.delete(d); - }); - - this.uniformPendingDisposal.forEach( - b => this.bufferManager.releaseBuffer(b)); - this.stagingPendingDisposal.forEach( - b => this.bufferManager.releaseBuffer(b, false)); - - this.tensorDataPendingDisposal = []; - this.uniformPendingDisposal = []; - this.stagingPendingDisposal = []; - } - - ensureCommandEncoderReady() { - if (!this.commandEncoder) { - this.commandEncoder = this.device.createCommandEncoder(); - } - } - - endComputePassEncoder() { - if (this.computePassEncoder) { - this.computePassEncoder.end(); - this.computePassEncoder = null; - } - } - - // Check if parallel compilation is done. - async checkCompileCompletionAsync() { - let pipelines: GPUComputePipeline[]; - try { - pipelines = await Promise.all(Object.values(this.pipelineCache)); - } catch (e) { - // TODO: Add test case to catch this exception. - throw new Error(e.message); - } - Object.keys(this.pipelineCache).map((key, i) => { - this.pipelineCache[key] = pipelines[i]; - }); - } - - public async getBufferData(buffer: GPUBuffer): Promise { - if (env().getBool('WEBGPU_ENGINE_COMPILE_ONLY')) { - console.warn( - 'The data may be invalid since WEBGPU_ENGINE_COMPILE_ONLY is true, this can only be called when WEBGPU_ENGINE_COMPILE_ONLY is false'); - return null; - } - const size = buffer.size; - const stagingBuffer = this.bufferManager.acquireBuffer( - size, GPUBufferUsage.COPY_DST | GPUBufferUsage.MAP_READ); - this.ensureCommandEncoderReady(); - this.endComputePassEncoder(); - this.commandEncoder.copyBufferToBuffer(buffer, 0, stagingBuffer, 0, size); - this.submitQueue(); - - await stagingBuffer.mapAsync(GPUMapMode.READ); - const values = stagingBuffer.getMappedRange().slice(0); - - stagingBuffer.unmap(); - if (stagingBuffer != null) { - this.bufferManager.releaseBuffer(stagingBuffer); - } - - // Need to get texture from swapChain to enable profiling tool - // to capture a frame - if (env().getBool('WEBGPU_USE_PROFILE_TOOL')) { - util.assert( - this.dummyContext !== undefined, - () => `Fail to get context for profiling tool`); - this.dummyContext.getCurrentTexture(); - } - - return values; - } - - private convertAndCacheOnCPU(dataId: DataId, data: BackendValues): - BackendValues { - const tensorData = this.tensorMap.get(dataId); - tensorData.values = data; - return tensorData.values; - } - - override readSync(dataId: object): BackendValues { - const tensorData = this.tensorMap.get(dataId); - const {values, complexTensorInfos} = tensorData; - - if (values != null || tensorData.dtype === 'string') { - return values; - } - - if (tensorData.dtype === 'complex64') { - const realValues = - this.readSync(complexTensorInfos.real.dataId) as Float32Array; - const imagValues = - this.readSync(complexTensorInfos.imag.dataId) as Float32Array; - const complexVals = util.convertBackendValuesAndArrayBuffer( - backend_util.mergeRealAndImagArrays(realValues, imagValues).buffer, - 'float32'); - this.convertAndCacheOnCPU(dataId, complexVals); - return complexVals; - } - - if (!this.hasReadSyncWarned) { - this.hasReadSyncWarned = true; - console.warn( - `The performance of synchronously reading data from GPU to CPU is ` + - `poor on the webgpu backend, please use asynchronous APIs instead.`); - } - - const alphaModes: GPUCanvasAlphaMode[] = ['opaque', 'premultiplied']; - - const buffer = tensorData.resource as GPUBuffer; - const bufferSize = buffer.size; - util.assert( - bufferSize % 4 === 0, - () => 'Because there is 4 bytes for ' + - 'one pixel, buffer size must be multiple of 4.'); - const pixelsSize = bufferSize / 4; - const valsGPU = new ArrayBuffer(bufferSize); - // TODO: adjust the reading window size according the `bufferSize`. - const canvasWidth = 256, canvasHeight = 256; - const stagingDeviceStorage: OffscreenCanvas[] = - alphaModes.map(_ => new OffscreenCanvas(canvasWidth, canvasHeight)); - const stagingHostStorage = new OffscreenCanvas(canvasWidth, canvasHeight); - - this.endComputePassEncoder(); - stagingDeviceStorage - .map((storage, index) => { - const context = storage.getContext('webgpu'); - // TODO: use rgba8unorm format when this format is supported on Mac. - // https://bugs.chromium.org/p/chromium/issues/detail?id=1298618 - context.configure({ - device: this.device, - format: 'bgra8unorm', - usage: GPUTextureUsage.COPY_DST, - alphaMode: alphaModes[index], - }); - return context.getCurrentTexture(); - }) - .map((texture, index) => { - const bytesPerRow = canvasWidth * 4; - const readDataGPUToCPU = - (width: number, height: number, offset: number) => { - this.ensureCommandEncoderReady(); - this.commandEncoder.copyBufferToTexture( - { - buffer, - bytesPerRow, - offset, - }, - { - texture, - }, - { - width, - height, - }); - this.submitQueue(); - - const context = stagingHostStorage.getContext('2d', { - willReadFrequently: true, - }); - context.clearRect(0, 0, width, height); - context.drawImage(stagingDeviceStorage[index], 0, 0); - const stagingValues = - context.getImageData(0, 0, width, height).data; - const alphaMode = alphaModes[index]; - const span = - new Uint8ClampedArray(valsGPU, offset, width * height * 4); - for (let k = 0; k < span.length; k += 4) { - if (alphaMode === 'premultiplied') { - span[k + 3] = stagingValues[k + 3]; - } else { - const value = stagingValues[k]; - span[k] = stagingValues[k + 2]; - span[k + 1] = stagingValues[k + 1]; - span[k + 2] = value; - } - } - }; - - const fullyReadCount = - Math.floor(pixelsSize / (canvasWidth * canvasHeight)); - let width = canvasWidth, height = canvasHeight, offset = 0; - for (let i = 0; i < fullyReadCount; i++) { - // Read the buffer data, which fully fill the whole canvas. - readDataGPUToCPU(width, height, offset); - offset += canvasWidth * canvasHeight * 4; - } - - const remainSize = pixelsSize % (canvasWidth * canvasHeight); - height = Math.floor(remainSize / canvasWidth); - if (height > 0) { - // Read the buffer data, which fully fill certain rows of canvas. - readDataGPUToCPU(width, height, offset); - offset += height * (canvasWidth * 4); - } - - width = remainSize % canvasWidth; - if (width > 0) { - // Read the buffer data, which not fully fill one row of canvas. - readDataGPUToCPU(width, 1, offset); - } - }); - - const vals = - util.convertBackendValuesAndArrayBuffer(valsGPU, tensorData.dtype); - this.convertAndCacheOnCPU(dataId, vals); - return vals; - } - - override async read(dataId: object): Promise { - if (!this.tensorMap.has(dataId)) { - throw new Error(`Tensor ${dataId} was not registered!`); - } - const tensorData = this.tensorMap.get(dataId); - - const {values} = tensorData; - - if (values != null) { - return values; - } - - // Download the values from the GPU. - let vals: BackendValues; - if (tensorData.dtype === 'complex64') { - const ps = await Promise.all([ - this.read(tensorData.complexTensorInfos.real.dataId), - this.read(tensorData.complexTensorInfos.imag.dataId) - ]); - - const realValues = ps[0]; - const imagValues = ps[1]; - vals = backend_util.mergeRealAndImagArrays( - realValues as Float32Array, imagValues as Float32Array); - } else { - const data = await this.getBufferData(tensorData.resource as GPUBuffer); - vals = util.convertBackendValuesAndArrayBuffer(data, tensorData.dtype); - } - this.convertAndCacheOnCPU(dataId, vals); - return vals; - } - - // The source GPUBuffer and destination GPUBuffer have the same size and - // usage. - private copyBuffer(srcBuffer: GPUBuffer) { - const size = srcBuffer.size; - const usage = srcBuffer.usage; - const dstBuffer = this.bufferManager.acquireBuffer(size, usage); - this.ensureCommandEncoderReady(); - this.endComputePassEncoder(); - this.commandEncoder.copyBufferToBuffer(srcBuffer, 0, dstBuffer, 0, size); - this.submitQueue(); - return dstBuffer; - } - - /** - * Create a TF.js tensor out of an existing WebGPU buffer. - */ - override createTensorFromGPUData( - webGPUData: WebGPUData, shape: number[], dtype: DataType): Tensor { - let buffer = webGPUData.buffer; - if (dtype === 'complex64') { - throw new Error(`Cannot write to a complex64 dtype. `); - } - const dataId = {id: this.nextDataId()}; - this.tensorMap.set(dataId, { - dtype, - shape, - values: null, - refCount: 1, - external: webGPUData.zeroCopy - }); - const tensorData = this.tensorMap.get(dataId); - const size = webgpu_util.GPUBytesPerElement(tensorData.dtype) * - util.sizeFromShape(tensorData.shape); - if (webGPUData.buffer.size < size) { - throw new Error(`GPUBuffer size(${ - webGPUData.buffer.size}) is smaller than tensor size(${size})!`); - } else if ( - (webGPUData.buffer.usage & - (GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_SRC)) !== - (GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_SRC)) { - throw new Error( - 'GPUBuffer.usage should include GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_SRC!'); - } - - // Do buffer copy by default. - if (webGPUData.zeroCopy !== true) { - buffer = this.copyBuffer(buffer); - } - tensorData.resource = buffer; - return engine().makeTensorFromDataId(dataId, shape, dtype, this); - } - - /** - * Read tensor to a new GPUBuffer. - * @param dataId The source tensor. - */ - override readToGPU(dataId: DataId): GPUData { - const srcTensorData = this.tensorMap.get(dataId); - const {values, dtype, shape, resource} = srcTensorData; - - if (dtype === 'complex64') { - throw new Error('Does not support reading buffer for complex64 dtype.'); - } - - if (resource == null) { - if (values != null) { - throw new Error('Data is not on GPU but on CPU.'); - } else { - throw new Error('There is no data on GPU or CPU.'); - } - } - - const srcBuffer = resource as GPUBuffer; - const size = srcBuffer.size; - const usage = srcBuffer.usage; - const buffer = this.bufferManager.acquireBuffer(size, usage); - this.ensureCommandEncoderReady(); - this.endComputePassEncoder(); - this.commandEncoder.copyBufferToBuffer( - resource as GPUBuffer, 0, buffer, 0, size); - this.submitQueue(); - - const tensorInfo = this.makeTensorInfo(shape, dtype); - // Make engine track this tensor, so that we can dispose it later. - const tensorRef = engine().makeTensorFromTensorInfo(tensorInfo); - - const tensorData = this.tensorMap.get(tensorInfo.dataId); - tensorData.resource = buffer; - - return {tensorRef, buffer}; - } - - bufferSync(t: TensorInfo): - TensorBuffer { - const data = this.readSync(t.dataId); - if (t.dtype === 'string') { - try { - // Decode the bytes into string. - const strings = (data as Uint8Array[]).map(d => util.decodeString(d)); - return buffer(t.shape as ShapeMap[R], t.dtype, strings) as - TensorBuffer; - } catch { - throw new Error('Failed to decode encoded string bytes into utf-8'); - } - } - return buffer(t.shape as ShapeMap[R], t.dtype, data as TypedArray) as - TensorBuffer; - } - - override async time(f: () => void): Promise { - if (!this.supportTimestampQuery && !this.hasTimestampQueryWarned) { - console.warn( - `This device doesn't support timestamp-query extension. ` + - `Start Chrome browser with flag ` + - `--enable-dawn-features=allow_unsafe_apis to try it again. ` + - `Otherwise, zero will be shown for the kernel time when profiling ` + - `mode is enabled.`); - this.hasTimestampQueryWarned = true; - } - - const oldActiveTimers = this.activeTimers; - const newActiveTimers: TimerNode[] = []; - - let outerMostTime = false; - if (this.programTimersStack == null) { - this.programTimersStack = newActiveTimers; - outerMostTime = true; - } else { - this.activeTimers.push(newActiveTimers); - } - this.activeTimers = newActiveTimers; - - f(); - - const flattenedActiveTimerQueries = - util.flatten(this.activeTimers.map((d: WebGPUKernelInfo) => d.query)) - .filter(d => d != null); - const flattenedActiveTimerNames = - util.flatten(this.activeTimers.map((d: WebGPUKernelInfo) => d.name)) - .filter(d => d != null); - - this.activeTimers = oldActiveTimers; - - if (outerMostTime) { - this.programTimersStack = null; - } - const res: WebGPUTimingInfo = { - uploadWaitMs: this.uploadWaitMs, - downloadWaitMs: this.downloadWaitMs, - kernelMs: null, - wallMs: null - }; - - const kernelMs = await Promise.all(flattenedActiveTimerQueries); - res['kernelMs'] = util.sum(kernelMs); - res['getExtraProfileInfo'] = () => - kernelMs.map((d, i) => ({name: flattenedActiveTimerNames[i], ms: d})) - .map(d => `${d.name}: ${d.ms}`) - .join(', '); - this.uploadWaitMs = 0; - this.downloadWaitMs = 0; - return res; - } - - makeTensorInfo( - shape: number[], dtype: DataType, - values?: BackendValues|string[]): TensorInfo { - if (dtype === 'string' && values != null && values.length > 0 && - util.isString(values[0])) { - values = (values as unknown as string[]).map(d => util.encodeString(d)); - } - const dataId = this.write(values as BackendValues, shape, dtype); - return {dataId, shape, dtype}; - } - - private tensorToBinding(tensor?: TensorInfo): GPUBindingResource { - if (!tensor) { - return null; - } - - const tensorData = this.tensorMap.get(tensor.dataId); - const resource = tensorData.resource; - - if (resource instanceof GPUBuffer) { - return {buffer: resource}; - } - if (resource instanceof GPUTexture) { - return resource.createView(); - } - // GPUExternalTexture - return resource; - } - - uploadToGPU(dataId: DataId): void { - const tensorData = this.tensorMap.get(dataId); - // Already on the GPU. - if (tensorData.resource != null) { - return; - } - - const size = webgpu_util.GPUBytesPerElement(tensorData.dtype) * - util.sizeFromShape(tensorData.shape); - let buffer; - const usage = GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_SRC | - GPUBufferUsage.COPY_DST; - if (tensorData.values) { - buffer = this.bufferManager.acquireBuffer(size, usage, true); - if (buffer.mapState === 'unmapped') { - const stagingBuffer = this.bufferManager.acquireBuffer( - size, GPUBufferUsage.MAP_WRITE | GPUBufferUsage.COPY_SRC, true, - false); - const arrayBuffer = stagingBuffer.getMappedRange(); - if (tensorData.dtype === 'int32' || tensorData.dtype === 'bool') { - new Int32Array(arrayBuffer).set(tensorData.values as TypedArray); - } else { - new Float32Array(arrayBuffer).set(tensorData.values as Float32Array); - } - stagingBuffer.unmap(); - this.ensureCommandEncoderReady(); - this.endComputePassEncoder(); - this.commandEncoder.copyBufferToBuffer( - stagingBuffer, 0, buffer, 0, size); - - this.stagingPendingDisposal.push(stagingBuffer); - } else { - const arrayBuffer = buffer.getMappedRange(); - if (tensorData.dtype === 'int32' || tensorData.dtype === 'bool') { - new Int32Array(arrayBuffer).set(tensorData.values as TypedArray); - } else { - new Float32Array(arrayBuffer).set(tensorData.values as Float32Array); - } - buffer.unmap(); - } - - // Once uploaded, don't store the values on cpu. - tensorData.values = null; - } else { - buffer = this.bufferManager.acquireBuffer(size, usage); - } - tensorData.resource = buffer; - } - - private makeUniforms(programUniform: ProgramUniform): GPUBindingResource { - let currentOffset = 0; - let preLength = 0; - const offsets: number[] = []; - let maxAlignmentOfField = 1; - programUniform.forEach((d) => { - if (d.data.length === 0) { - d.data = [1]; - } - // https://www.w3.org/TR/WGSL/#alignof - let baseAlignment: number; - switch (d.data.length) { - case 1: - baseAlignment = 4; - break; - case 2: - baseAlignment = 8; - break; - case 3: - baseAlignment = 16; - break; - case 4: - baseAlignment = 16; - break; - case 5: - baseAlignment = 16; - break; - case 6: - baseAlignment = 16; - break; - default: - util.assert(false, () => `Unsupported ${d.data.length}D shape`); - } - - if (preLength === 5 || preLength === 6) { - baseAlignment = 16; - } - if (baseAlignment > maxAlignmentOfField) { - maxAlignmentOfField = baseAlignment; - } - currentOffset = Math.ceil(currentOffset / baseAlignment) * baseAlignment; - preLength = d.data.length; - offsets.push(currentOffset); - currentOffset += d.data.length * 4; - }); - - currentOffset = - Math.ceil(currentOffset / maxAlignmentOfField) * maxAlignmentOfField; - const arrayBuffer = new ArrayBuffer(currentOffset); - programUniform.forEach((d, i) => { - const offset = offsets[i]; - if (d.type === 'int32') { - new Int32Array(arrayBuffer, offset, d.data.length).set(d.data); - } else if (d.type === 'uint32') { - new Uint32Array(arrayBuffer, offset, d.data.length).set(d.data); - } else { - new Float32Array(arrayBuffer, offset, d.data.length).set(d.data); - } - }); - - const uniformBuffer = this.bufferManager.acquireBuffer( - currentOffset, GPUBufferUsage.COPY_DST | GPUBufferUsage.UNIFORM); - this.queue.writeBuffer(uniformBuffer, 0, arrayBuffer, 0, currentOffset); - this.uniformPendingDisposal.push(uniformBuffer); - - return {offset: 0, size: currentOffset, buffer: uniformBuffer}; - } - - public runWebGPUProgram( - program: webgpu_program.WebGPUProgram, inputs: TensorInfo[], - outputDtype: DataType, programDefinedUniform?: ProgramUniform, - output?: TensorInfo): TensorInfo { - if (!output) { - output = this.makeTensorInfo(program.outputShape, outputDtype); - } - if (util.sizeFromShape(output.shape) === 0) { - // Short-circuit the computation since the result is empty (has 0 in its - // shape). - this.tensorMap.get(output.dataId).values = - util.getTypedArrayFromDType(output.dtype as 'float32', 0); - return output; - } - this.uploadToGPU(output.dataId); - program.dispatch = reshapeDispatch(this.device, program); - - const inputsData = inputs.map((input: TensorInfo, i: number) => { - if (input.dtype === 'complex64') { - throw new Error( - `GPGPUProgram does not support complex64 input. For complex64 ` + - `dtypes, please separate the program into real and imaginary ` + - `parts.`); - } - this.uploadToGPU(input.dataId); - - return { - // Returning dtype from tensorMap because it reflects dtype - // of underlying buffer, rather than abstract dtype. - dtype: this.tensorMap.get(input.dataId).dtype, - shape: input.shape, - name: program.variableNames[i] - }; - }); - - program.shaderKey = - webgpu_program.makeShaderKey(program, inputsData, output); - - const parallelCompilation = env().getBool('WEBGPU_ENGINE_COMPILE_ONLY'); - if (!(program.shaderKey in this.pipelineCache)) { - this.pipelineCache[program.shaderKey] = webgpu_program.compileProgram( - this.device, program, inputsData, output, parallelCompilation); - } - program.pipeline = this.pipelineCache[program.shaderKey]; - - if (!parallelCompilation) { - this.recordAndSubmit(program, output, inputs, programDefinedUniform); - } - return output; - } - - private recordAndSubmit( - program: webgpu_program.WebGPUProgram, output: TensorInfo, - inputs: TensorInfo[], programDefinedUniform?: ProgramUniform) { - if (program.pipeline instanceof Promise) { - throw new Error( - 'Please call checkCompileCompletionAsync to ensure parallel compilation is done!'); - } - // There are six kinds of uniforms: NAN, INFINITY, shapes, shape strides, - // program size, program defined uniforms. - let programUniform: ProgramUniform = []; - let bufferShapes: number[][] = []; - const uniformsType = 'int32'; - if (program.pixelsOpType == null) { - programUniform.push( - {type: 'float32', data: [NaN]}, {type: 'float32', data: [Infinity]}); - bufferShapes = inputs.concat(output).map(d => d.shape); - const uniformsType = 'int32'; - bufferShapes.map(d => { - programUniform.push({type: uniformsType, data: d}); - const strides = util.computeStrides(d); - programUniform.push({type: uniformsType, data: strides}); - }); - } else { - const strides = util.computeStrides(output.shape); - programUniform.push({type: uniformsType, data: strides}); - } - if (program.size) { - const size = util.sizeFromShape(program.outputShape); - programUniform.push({ - type: uniformsType, - data: [program.outputComponent ? size / program.outputComponent : size] - }); - } - - if (programDefinedUniform) { - programUniform = [...programUniform, ...programDefinedUniform]; - } - const bindings = [ - this.tensorToBinding(output), ...inputs.map(t => this.tensorToBinding(t)), - this.makeUniforms(programUniform) - ]; - - inputs.forEach(input => { - this.commandQueueOwnedIds.add(input.dataId); - }); - this.commandQueueOwnedIds.add(output.dataId); - - const bindGroup = this.device.createBindGroup({ - layout: program.pipeline.getBindGroupLayout(0), - entries: bindings.map((b, i) => ({binding: i, resource: b})), - }); - - const shouldTimeProgram = this.activeTimers != null; - this.ensureCommandEncoderReady(); - - const computePassDescriptor: GPUComputePassDescriptor = {}; - if (shouldTimeProgram && this.supportTimestampQuery) { - this.endComputePassEncoder(); - if (this.querySet == null) { - this.querySet = this.device.createQuerySet({ - type: 'timestamp', - count: this.querySetCount, - }); - } - computePassDescriptor.timestampWrites = { - querySet: this.querySet, - beginningOfPassWriteIndex: 0, - endOfPassWriteIndex: 1, - }; - this.computePassEncoder = - this.commandEncoder.beginComputePass(computePassDescriptor); - } else if (!this.computePassEncoder) { - this.computePassEncoder = - this.commandEncoder.beginComputePass(computePassDescriptor); - } - - this.computePassEncoder.setPipeline(program.pipeline); - this.computePassEncoder.setBindGroup(0, bindGroup); - this.computePassEncoder.dispatchWorkgroups( - program.dispatch[0], program.dispatch[1], program.dispatch[2]); - this.dispatchCountInPass++; - - if (shouldTimeProgram || - env().get('WEBGPU_DEFERRED_SUBMIT_BATCH_SIZE') as - number <= this.dispatchCountInPass || - program.pixelsOpType === webgpu_program.PixelsOpType.DRAW) { - this.endComputePassEncoder(); - if (shouldTimeProgram) { - this.activeTimers.push( - {name: program.constructor.name, query: this.getQueryTime()}); - } else { - this.submitQueue(); - } - } - } - - async getQueryTime(): Promise { - if (!this.supportTimestampQuery) { - return 0; - } - - if (this.queryResolveBuffer == null) { - this.queryResolveBuffer = this.bufferManager.acquireBuffer( - this.querySetCount * 8, - GPUBufferUsage.COPY_SRC | GPUBufferUsage.COPY_DST | - GPUBufferUsage.QUERY_RESOLVE); - } - this.commandEncoder.resolveQuerySet( - this.querySet, 0, this.querySetCount, this.queryResolveBuffer, 0); - - const queryStagingBuffer = this.bufferManager.acquireBuffer( - this.querySetCount * 8, - GPUBufferUsage.MAP_READ | GPUBufferUsage.COPY_DST); - - this.commandEncoder.copyBufferToBuffer( - this.queryResolveBuffer, 0, queryStagingBuffer, 0, - this.querySetCount * 8); - - this.submitQueue(); - - await queryStagingBuffer.mapAsync(GPUMapMode.READ); - const arrayBuffer = new BigUint64Array(queryStagingBuffer.getMappedRange()); - const time = Number(arrayBuffer[1] - arrayBuffer[0]) / 1000000; - queryStagingBuffer.unmap(); - this.bufferManager.releaseBuffer(queryStagingBuffer); - return time; - } - - shouldExecuteOnCPU( - inputs: TensorInfo[], - sizeThreshold = CPU_HANDOFF_SIZE_THRESHOLD): boolean { - return env().getBool('WEBGPU_CPU_FORWARD') && - inputs.every( - input => this.tensorMap.get(input.dataId).resource == null && - util.sizeFromShape(input.shape) < sizeThreshold); - } - - override numDataIds() { - return this.tensorMap.numDataIds() - this.tensorDataPendingDisposal.length; - } - - override dispose() { - if (this.disposed) { - return; - } - if (this.querySet != null) { - this.querySet.destroy(); - } - this.bufferManager.dispose(); - this.textureManager.dispose(); - this.disposed = true; - } -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/backend_webgpu_test.ts b/tfjs-master/tfjs-backend-webgpu/src/backend_webgpu_test.ts deleted file mode 100644 index ed8149f40..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/backend_webgpu_test.ts +++ /dev/null @@ -1,688 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '@tensorflow/tfjs-core'; - -import {GPUData, test_util} from '@tensorflow/tfjs-core'; -const {expectArraysEqual, expectArraysClose} = test_util; - -import {WebGPUBackend, WebGPUMemoryInfo} from './backend_webgpu'; -import {describeWebGPU} from './test_util'; - -describeWebGPU('backend webgpu cpu forwarding turned on', () => { - let cpuForwardFlagSaved: boolean; - - beforeAll(() => { - cpuForwardFlagSaved = tf.env().getBool('WEBGPU_CPU_FORWARD'); - - tf.env().set('WEBGPU_CPU_FORWARD', true); - }); - - afterAll(() => { - tf.env().set('WEBGPU_CPU_FORWARD', cpuForwardFlagSaved); - }); - - it('should not allocate GPU memory when CPU forwarding', async () => { - const a = tf.tensor2d([2, 4, 6, 8], [2, 2]); - const b = tf.tensor2d([0.5, 0.5, 0.5, 0.5], [2, 2]); - - const c = tf.mul(a, b); - - const startNumBytes = tf.memory().numBytes; - const startNumTensors = tf.memory().numTensors; - const startNumBytesInGPU = (tf.memory() as WebGPUMemoryInfo).numBytesInGPU; - - expect(startNumBytes).toEqual(48); - expect(startNumTensors).toEqual(3); - expect(startNumBytesInGPU).toEqual(0); - - const f = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - const d = tf.matMul(c, f); - - const dData = await d.data(); - const endNumBytes = tf.memory().numBytes; - const endNumTensors = tf.memory().numTensors; - const endNumBytesInGPU = (tf.memory() as WebGPUMemoryInfo).numBytesInGPU; - - expect(endNumBytes - startNumBytes).toEqual(48); - expect(endNumTensors - startNumTensors).toEqual(2); - expect(endNumBytesInGPU - startNumBytesInGPU).toEqual(64); - - expectArraysClose(dData, new Float32Array([9, 12, 15, 19, 26, 33])); - }); -}); - -describeWebGPU('backend webgpu', () => { - it('should not leak memory in delayed mode', async () => { - const savedFlag = tf.env().get('WEBGPU_DEFERRED_SUBMIT_BATCH_SIZE'); - tf.env().set('WEBGPU_DEFERRED_SUBMIT_BATCH_SIZE', 15); - const a = tf.tensor2d([2, 4, 6, 8], [2, 2]); - const b = tf.tensor2d([0.5, 0.5, 0.5, 0.5], [2, 2]); - - const c = tf.mul(a, b); - - const startNumBytes = tf.memory().numBytes; - const startNumTensors = tf.memory().numTensors; - - const f = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - const d = tf.matMul(c, f); - - const dData = await d.data(); - const endNumBytes = tf.memory().numBytes; - const endNumTensors = tf.memory().numTensors; - - expect(endNumBytes - startNumBytes).toEqual(48); - expect(endNumTensors - startNumTensors).toEqual(2); - - expectArraysClose(dData, new Float32Array([9, 12, 15, 19, 26, 33])); - tf.env().set('WEBGPU_DEFERRED_SUBMIT_BATCH_SIZE', savedFlag); - }); - - it('should not leak memory in immediate mode', async () => { - const savedFlag = tf.env().get('WEBGPU_DEFERRED_SUBMIT_BATCH_SIZE'); - tf.env().set('WEBGPU_DEFERRED_SUBMIT_BATCH_SIZE', 1); - const a = tf.tensor2d([2, 4, 6, 8], [2, 2]); - const b = tf.tensor2d([0.5, 0.5, 0.5, 0.5], [2, 2]); - - const c = tf.mul(a, b); - - const startNumBytes = tf.memory().numBytes; - const startNumTensors = tf.memory().numTensors; - - const f = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - const d = tf.matMul(c, f); - - const dData = await d.data(); - const endNumBytes = tf.memory().numBytes; - const endNumTensors = tf.memory().numTensors; - - expect(endNumBytes - startNumBytes).toEqual(48); - expect(endNumTensors - startNumTensors).toEqual(2); - - expectArraysClose(dData, new Float32Array([9, 12, 15, 19, 26, 33])); - tf.env().set('WEBGPU_DEFERRED_SUBMIT_BATCH_SIZE', savedFlag); - }); - - it('should recycle buffers in immediate mode', () => { - const savedFlag = tf.env().get('WEBGPU_DEFERRED_SUBMIT_BATCH_SIZE'); - tf.env().set('WEBGPU_DEFERRED_SUBMIT_BATCH_SIZE', 1); - const backend = tf.backend() as WebGPUBackend; - const bufferManager = backend.bufferManager; - bufferManager.dispose(); - - const a = tf.tensor2d([2, 4, 6, 8], [2, 2]); - const b = tf.tensor2d([0.5, 0.5, 0.5, 0.5], [2, 2]); - - const c = tf.mul(a, b); - const freeBuffersAfterFirstMul = bufferManager.getNumFreeBuffers(); - const usedBuffersAfterFirstMul = bufferManager.getNumUsedBuffers(); - - const f = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - tf.matMul(c, f); - const freeBuffersAfterFirstMatMul = bufferManager.getNumFreeBuffers(); - const usedBuffersAfterFirstMatMul = bufferManager.getNumUsedBuffers(); - expect(freeBuffersAfterFirstMatMul - freeBuffersAfterFirstMul) - .toEqual(1); // from released uniform - expect(usedBuffersAfterFirstMatMul - usedBuffersAfterFirstMul).toEqual(2); - - const a2 = tf.tensor2d([2, 4, 6, 8], [2, 2]); - const b2 = tf.tensor2d([0.5, 0.5, 0.5, 0.5], [2, 2]); - - const c2 = tf.mul(a2, b2); - const freeBuffersAfterSecondMul = bufferManager.getNumFreeBuffers(); - const usedBuffersAfterSecondMul = bufferManager.getNumUsedBuffers(); - expect(freeBuffersAfterSecondMul - freeBuffersAfterFirstMatMul) - .toEqual(0); // released a uniform buffer and reused a buffer - expect(usedBuffersAfterSecondMul - usedBuffersAfterFirstMatMul).toEqual(3); - - const f2 = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - tf.matMul(c2, f2); - const freeBuffersAfterSecondMatMul = bufferManager.getNumFreeBuffers(); - const usedBuffersAfterSecondMatMul = bufferManager.getNumUsedBuffers(); - expect(freeBuffersAfterSecondMatMul - freeBuffersAfterSecondMul).toEqual(0); - expect(usedBuffersAfterSecondMatMul - usedBuffersAfterSecondMul).toEqual(2); - tf.env().set('WEBGPU_DEFERRED_SUBMIT_BATCH_SIZE', savedFlag); - }); - - it('should not recycle buffers in delayed mode', async () => { - const savedFlag = tf.env().get('WEBGPU_DEFERRED_SUBMIT_BATCH_SIZE'); - tf.env().set('WEBGPU_DEFERRED_SUBMIT_BATCH_SIZE', 15); - const backend = tf.backend() as WebGPUBackend; - const bufferManager = backend.bufferManager; - bufferManager.dispose(); - - const a = tf.tensor2d([2, 4, 6, 8], [2, 2]); - const b = tf.tensor2d([0.5, 0.5, 0.5, 0.5], [2, 2]); - - const c = tf.mul(a, b); - const freeBuffersAfterFirstMul = bufferManager.getNumFreeBuffers(); - const usedBuffersAfterFirstMul = bufferManager.getNumUsedBuffers(); - - const f = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - tf.matMul(c, f); - const freeBuffersAfterFirstMatMul = bufferManager.getNumFreeBuffers(); - const usedBuffersAfterFirstMatMul = bufferManager.getNumUsedBuffers(); - expect(freeBuffersAfterFirstMatMul - freeBuffersAfterFirstMul).toEqual(0); - expect(usedBuffersAfterFirstMatMul - usedBuffersAfterFirstMul).toEqual(3); - - const a2 = tf.tensor2d([2, 4, 6, 8], [2, 2]); - const b2 = tf.tensor2d([0.5, 0.5, 0.5, 0.5], [2, 2]); - - const c2 = tf.mul(a2, b2); - const freeBuffersAfterSecondMul = bufferManager.getNumFreeBuffers(); - const usedBuffersAfterSecondMul = bufferManager.getNumUsedBuffers(); - expect(freeBuffersAfterSecondMul - freeBuffersAfterFirstMatMul).toEqual(0); - expect(usedBuffersAfterSecondMul - usedBuffersAfterFirstMatMul).toEqual(4); - - const f2 = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - const c3 = tf.matMul(c2, f2); - const freeBuffersAfterSecondMatMul = bufferManager.getNumFreeBuffers(); - const usedBuffersAfterSecondMatMul = bufferManager.getNumUsedBuffers(); - expect(freeBuffersAfterSecondMatMul - freeBuffersAfterSecondMul).toEqual(0); - expect(usedBuffersAfterSecondMatMul - usedBuffersAfterSecondMul).toEqual(3); - - // Tests happen within a tidy so we need to read a tensor at the end of a - // test in delayed mode in order to force flush the disposal queue. - await c3.data(); - tf.env().set('WEBGPU_DEFERRED_SUBMIT_BATCH_SIZE', savedFlag); - }); -}); - -describeWebGPU('backendWebGPU', () => { - let prevBackend: string; - - beforeAll(() => { - prevBackend = tf.getBackend(); - }); - - afterEach(() => { - tf.setBackend(prevBackend); - tf.removeBackend('test-storage'); - }); - - it('lazily upload', async () => { - const adapter = await navigator.gpu.requestAdapter({}); - const device = await adapter.requestDevice({}); - const backend = new WebGPUBackend(device); - tf.registerBackend('test-storage', () => backend); - tf.setBackend('test-storage'); - - const bufferManager = backend.bufferManager; - const t = tf.tensor1d([1, 2, 3], 'float32'); - - expect(bufferManager.getNumUsedBuffers()).toBe(0); - - backend.uploadToGPU(t.dataId); - expect(bufferManager.getNumUsedBuffers()).toBe(1); - }); -}); - -describeWebGPU('keeping data on gpu ', () => { - let flag: boolean; - - beforeAll(() => { - flag = tf.env().getBool('WEBGPU_CPU_FORWARD'); - tf.env().set('WEBGPU_CPU_FORWARD', false); - }); - - afterAll(() => { - tf.env().set('WEBGPU_CPU_FORWARD', flag); - }); - - it('has a valid buffer for dtype=float32.', async () => { - const webGPUBackend = (tf.backend() as WebGPUBackend); - const data = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]; - const size = 48; - const a = tf.tensor(data, [1, 3, 4]); - const b = tf.add(a, 0); - const res = b.dataToGPU(); - expectArraysEqual(res.buffer.size, size); - if (res.tensorRef.dtype !== 'float32') { - throw new Error( - `Unexpected type. Actual: ${res.tensorRef.dtype}. ` + - `Expected: float32`); - } - const resData = await webGPUBackend.getBufferData(res.buffer); - const values = tf.util.convertBackendValuesAndArrayBuffer( - resData, res.tensorRef.dtype); - expectArraysEqual(values, data); - }); - - it('has a valid buffer for dtype=int32.', async () => { - const webGPUBackend = (tf.backend() as WebGPUBackend); - const data = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]; - const size = 48; - const a = tf.tensor(data, [1, 3, 4], 'int32'); - const b = tf.tensor([0], [1], 'int32'); - const c = tf.add(a, b); - const res = c.dataToGPU(); - expectArraysEqual(res.buffer.size, size); - if (res.tensorRef.dtype !== 'int32') { - throw new Error( - `Unexpected type. Actual: ${res.tensorRef.dtype}. ` + - `Expected: float32`); - } - const resData = await webGPUBackend.getBufferData(res.buffer); - const values = tf.util.convertBackendValuesAndArrayBuffer( - resData, res.tensorRef.dtype); - expectArraysEqual(values, data); - }); - - it('has no memory leak.', () => { - const data = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]; - - const a = tf.tensor(data, [1, 3, 4]); - const b = tf.add(a, 0); - - const webGPUBackend = tf.backend() as WebGPUBackend; - const startTensor = tf.memory().numTensors; - const startDataBuckets = webGPUBackend.numDataIds(); - - const res = b.dataToGPU(); - res.tensorRef.dispose(); - - const endTensor = tf.memory().numTensors; - const endDataBuckets = webGPUBackend.numDataIds(); - - expect(endTensor).toEqual(startTensor); - expect(endDataBuckets).toEqual(startDataBuckets); - }); - - it('can be used in tidy.', async () => { - const data = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]; - - const webGPUBackend = tf.backend() as WebGPUBackend; - const startTensor = tf.memory().numTensors; - const startDataBuckets = webGPUBackend.numDataIds(); - - const result = tf.tidy(() => { - const a = tf.tensor(data, [1, 3, 4]); - const b = tf.add(a, 0); - return b.dataToGPU() as unknown as tf.Tensor; - }); - - const endTensor = tf.memory().numTensors; - const endDataBuckets = webGPUBackend.numDataIds(); - - expect(endTensor).toEqual(startTensor + 1); - expect(endDataBuckets).toEqual(startDataBuckets + 1); - - const res = result as unknown as GPUData; - const resData = await webGPUBackend.getBufferData(res.buffer); - const values = tf.util.convertBackendValuesAndArrayBuffer( - resData, res.tensorRef.dtype); - expectArraysEqual(values, data); - }); - - it('tidy has no memory leak.', () => { - const data = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]; - - const webGPUBackend = tf.backend() as WebGPUBackend; - const startTensor = tf.memory().numTensors; - const startDataBuckets = webGPUBackend.numDataIds(); - - tf.tidy(() => { - const a = tf.tensor(data, [1, 3, 4]); - const b = tf.add(a, 0); - b.dataToGPU(); - return b; - }); - - const endTensor = tf.memory().numTensors; - const endDataBuckets = webGPUBackend.numDataIds(); - - expect(endTensor).toEqual(startTensor + 1); - expect(endDataBuckets).toEqual(startDataBuckets + 1); - }); -}); - -async function parallelCompilationCommon(webGPUBackend: WebGPUBackend) { - const startNumBytes = (tf.memory() as WebGPUMemoryInfo).numBytesInGPU; - const startTensor = tf.memory().numTensors; - const startDataBuckets = webGPUBackend.numDataIds(); - - const a1 = tf.tensor1d([1, 1, 1]); - const b1 = tf.tensor1d([1, 1, 1]); - - // Parallel compile. - tf.env().set('WEBGPU_ENGINE_COMPILE_ONLY', true); - const c1 = tf.add(a1, b1); - await webGPUBackend.checkCompileCompletionAsync(); - - // Actual inference. - tf.env().set('WEBGPU_ENGINE_COMPILE_ONLY', false); - const c2 = tf.add(a1, b1); - expectArraysEqual(await c2.data(), [2, 2, 2]); - - tf.dispose([a1, b1, c1, c2]); - const endNumBytes = (tf.memory() as WebGPUMemoryInfo).numBytesInGPU; - const endTensor = tf.memory().numTensors; - const endDataBuckets = webGPUBackend.numDataIds(); - - // We only check numBytesInGPU. For parallel compilation, - // numBytesInGPUAllocated will be more because of the two pass - // uploadToGPU, but they will all be freed, resulting in endNumbytes equal - // to startNumBytes. - expect(startNumBytes).toEqual(endNumBytes); - expect(startTensor).toEqual(endTensor); - expect(endDataBuckets).toEqual(startDataBuckets); -} - -describeWebGPU('parallel compilation', () => { - let prevBackend: string; - let savedWebGPUCPUForward: boolean; - let savedEngineCompileOnly: boolean; - let webGPUBackend: WebGPUBackend; - const customWebGPUBackendName = 'test-parallel'; - - beforeAll(() => { - prevBackend = tf.getBackend(); - }); - - beforeEach(async () => { - const adapter = await navigator.gpu.requestAdapter({}); - const device = await adapter.requestDevice({}); - webGPUBackend = new WebGPUBackend(device); - - tf.copyRegisteredKernels('webgpu', customWebGPUBackendName); - tf.registerBackend(customWebGPUBackendName, () => webGPUBackend); - tf.setBackend('test-parallel'); - - savedWebGPUCPUForward = tf.env().get('WEBGPU_CPU_FORWARD') as boolean; - savedEngineCompileOnly = - tf.env().get('WEBGPU_ENGINE_COMPILE_ONLY') as boolean; - tf.env().set('WEBGPU_CPU_FORWARD', false); - await tf.ready(); - }); - - afterEach(() => { - tf.env().set('WEBGPU_CPU_FORWARD', savedWebGPUCPUForward); - tf.env().set('WEBGPU_ENGINE_COMPILE_ONLY', savedEngineCompileOnly); - tf.setBackend(prevBackend); - tf.removeBackend(customWebGPUBackendName); - }); - - it('should work if pipeline cache not exist.', async () => { - await parallelCompilationCommon(webGPUBackend); - }); - - it('should work if pipeline cache exists.', async () => { - // This will create pipeline cache. - const a0 = tf.tensor1d([1, 1, 1]); - const b0 = tf.tensor1d([1, 1, 1]); - const c0 = tf.add(a0, b0); - const data = await c0.data(); - expectArraysClose(data, [2, 2, 2]); - - await parallelCompilationCommon(webGPUBackend); - }); - - it('should work when running parallel compile again', async () => { - // This will create pipeline cache. - const a0 = tf.tensor1d([1, 1, 1]); - const b0 = tf.tensor1d([1, 1, 1]); - const c0 = tf.add(a0, b0); - const data = await c0.data(); - expectArraysClose(data, [2, 2, 2]); - - await parallelCompilationCommon(webGPUBackend); - await parallelCompilationCommon(webGPUBackend); - }); - - it('should not work if not call checkCompileCompletionAsync', async () => { - const a1 = tf.tensor1d([1, 1, 1]); - const b1 = tf.tensor1d([1, 1, 1]); - - // Parallel compile but not call await (tf.backend() as - // WebGPUBackend).checkCompileCompletionAsync(). - tf.env().set('WEBGPU_ENGINE_COMPILE_ONLY', true); - tf.add(a1, b1); - - // Actual inference. - tf.env().set('WEBGPU_ENGINE_COMPILE_ONLY', false); - expect(() => tf.add(a1, b1)) - .toThrowError( - 'Please call checkCompileCompletionAsync to ensure parallel compilation is done!'); - }); - - it('read data is invalid if parallel compilation is true', async () => { - const a1 = tf.tensor1d([1, 1, 1]); - const b1 = tf.tensor1d([1, 1, 1]); - - // Parallel compile. - tf.env().set('WEBGPU_ENGINE_COMPILE_ONLY', true); - const c1 = tf.add(a1, b1); - await (tf.backend() as WebGPUBackend).checkCompileCompletionAsync(); - // Read data is invalid. - expectArraysClose((await c1.data()).length, 0); - }); - - it('checkCompileCompletionAsync is nop if parallel compilation is false', - async () => { - const a1 = tf.tensor1d([1, 1, 1]); - const b1 = tf.tensor1d([1, 1, 1]); - // If parallel compilation is false, checkCompileCompletionAsync is nop. - tf.env().set('WEBGPU_ENGINE_COMPILE_ONLY', false); - const c1 = tf.add(a1, b1); - await (tf.backend() as WebGPUBackend).checkCompileCompletionAsync(); - expectArraysClose(await c1.data(), [2, 2, 2]); - }); -}); - -function createStagingGPUBufferFromData( - device: GPUDevice, data: number[], dtype: tf.DataType) { - const bytesPerElement = 4; - const sizeInBytes = data.length * bytesPerElement; - - const gpuWriteBuffer = device.createBuffer({ - mappedAtCreation: true, - size: sizeInBytes, - usage: GPUBufferUsage.MAP_WRITE | GPUBufferUsage.COPY_SRC - }); - const arrayBuffer = gpuWriteBuffer.getMappedRange(); - if (dtype === 'float32') { - new Float32Array(arrayBuffer).set(data); - } else if (dtype === 'int32') { - new Int32Array(arrayBuffer).set(data); - } else { - throw new Error( - `Creating tensor from GPUBuffer only supports` + - `'float32'|'int32' dtype, while the dtype is ${dtype}.`); - } - gpuWriteBuffer.unmap(); - return gpuWriteBuffer; -} - -function createGPUBufferFromData( - device: GPUDevice, data: number[], dtype: tf.DataType, - bufferUsage = GPUBufferUsage.COPY_DST | GPUBufferUsage.STORAGE | - GPUBufferUsage.COPY_SRC) { - const bytesPerElement = 4; - const sizeInBytes = data.length * bytesPerElement; - - const gpuWriteBuffer = createStagingGPUBufferFromData(device, data, dtype); - const gpuReadBuffer = device.createBuffer( - {mappedAtCreation: false, size: sizeInBytes, usage: bufferUsage}); - - const copyEncoder = device.createCommandEncoder(); - copyEncoder.copyBufferToBuffer( - gpuWriteBuffer, 0, gpuReadBuffer, 0, sizeInBytes); - const copyCommands = copyEncoder.finish(); - device.queue.submit([copyCommands]); - gpuWriteBuffer.destroy(); - return gpuReadBuffer; -} - -async function testCreateTensorFromGPUBuffer( - dtype: tf.DataType, useDefaultShapeAndType = false, zeroCopy = false) { - const webGPUBackend = tf.backend() as WebGPUBackend; - const device = webGPUBackend.device; - const aData = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]; - const bData = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4]; - const expected = [2, 4, 6, 8, 6, 8, 10, 12, 10, 12, 14, 16, 14, 16, 18, 20]; - const aBuffer = createGPUBufferFromData(device, aData, dtype); - const shape: number[] = [aData.length]; - const startNumBytes = tf.memory().numBytes; - const startNumTensors = tf.memory().numTensors; - const webGPUData = {buffer: aBuffer, zeroCopy}; - const a = useDefaultShapeAndType ? tf.tensor(webGPUData) : - tf.tensor(webGPUData, shape, dtype); - if (zeroCopy !== true) { - aBuffer.destroy(); - } - const b = tf.tensor(bData, shape, dtype); - const result = tf.add(a, b); - tf.test_util.expectArraysClose(await result.data(), expected); - a.dispose(); - b.dispose(); - result.dispose(); - const endNumBytes = tf.memory().numBytes; - const endNumTensors = tf.memory().numTensors; - expect(endNumBytes - startNumBytes).toEqual(0); - expect(endNumTensors - startNumTensors).toEqual(0); - if (zeroCopy === true) { - aBuffer.destroy(); - } -} - -function createTensorFromGPUTest(zeroCopy = false) { - it('use default shape and data type(float32)', async () => { - await testCreateTensorFromGPUBuffer('float32', true, zeroCopy); - }); - - it('work for float32', async () => { - await testCreateTensorFromGPUBuffer('float32', false, zeroCopy); - }); - - it('work for int32', async () => { - await testCreateTensorFromGPUBuffer('int32', false, zeroCopy); - }); - - it('work for read', async () => { - const webGPUBackend = tf.backend() as WebGPUBackend; - const device = webGPUBackend.device; - const aData = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]; - const dtype = 'float32'; - const aBuffer = createGPUBufferFromData(device, aData, dtype); - const shape: number[] = [aData.length]; - const a = tf.tensor({buffer: aBuffer, zeroCopy}, shape, dtype); - if (zeroCopy !== true) { - aBuffer.destroy(); - } - await a.data(); - if (zeroCopy === true) { - aBuffer.destroy(); - } - }); - - it('two tensors share the same GPUBuffer', async () => { - const webGPUBackend = tf.backend() as WebGPUBackend; - const device = webGPUBackend.device; - const aData = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]; - const dtype = 'float32'; - const aBuffer = createGPUBufferFromData(device, aData, dtype); - const startNumBytes = tf.memory().numBytes; - const startNumTensors = tf.memory().numTensors; - const shape: number[] = [aData.length]; - const webGPUData = {buffer: aBuffer, zeroCopy}; - const a = tf.tensor(webGPUData, shape, dtype); - const b = tf.tensor(webGPUData, shape, dtype); - if (zeroCopy !== true) { - aBuffer.destroy(); - } - const result = tf.add(a, b); - const expected = - [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32]; - tf.test_util.expectArraysClose(await result.data(), expected); - a.dispose(); - b.dispose(); - result.dispose(); - const endNumBytes = tf.memory().numBytes; - const endNumTensors = tf.memory().numTensors; - expect(endNumBytes - startNumBytes).toEqual(0); - expect(endNumTensors - startNumTensors).toEqual(0); - if (zeroCopy === true) { - aBuffer.destroy(); - } - }); - - it('GPUBuffer size is bigger than tensor size', async () => { - const webGPUBackend = tf.backend() as WebGPUBackend; - const device = webGPUBackend.device; - const aData = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]; - const dtype = 'float32'; - const aBuffer = createGPUBufferFromData(device, aData, dtype); - const startNumBytes = tf.memory().numBytes; - const startNumTensors = tf.memory().numTensors; - // GPUBuffer.size is bigger than shape size - const shape: number[] = [aData.length - 1]; - const webGPUData = {buffer: aBuffer, zeroCopy}; - const a = tf.tensor(webGPUData, shape, dtype); - const b = tf.tensor(webGPUData, shape, dtype); - if (zeroCopy !== true) { - aBuffer.destroy(); - } - const result = tf.add(a, b); - const expected = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]; - tf.test_util.expectArraysClose(await result.data(), expected); - a.dispose(); - b.dispose(); - result.dispose(); - const endNumBytes = tf.memory().numBytes; - const endNumTensors = tf.memory().numTensors; - expect(endNumBytes - startNumBytes).toEqual(0); - expect(endNumTensors - startNumTensors).toEqual(0); - if (zeroCopy === true) { - aBuffer.destroy(); - } - }); - - it('throw when GPUBuffer size is smaller than tensor size', async () => { - const webGPUBackend = tf.backend() as WebGPUBackend; - const device = webGPUBackend.device; - const aData = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]; - const dtype = 'float32'; - const aBuffer = createGPUBufferFromData(device, aData, dtype); - // Throw when GPUBuffer.size is smaller than shape size - const shape: number[] = [aData.length + 1]; - const a = () => tf.tensor({buffer: aBuffer}, shape, dtype); - expect(a).toThrowError(); - aBuffer.destroy(); - }); - - it('throw when GPUBuffer usage is not correct', async () => { - const webGPUBackend = tf.backend() as WebGPUBackend; - const device = webGPUBackend.device; - const aData = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]; - const dtype = 'float32'; - // Create a GPUBuffer without GPUBufferUsage.STORAGE. - const aBuffer = createStagingGPUBufferFromData(device, aData, dtype); - // Throw when GPUBuffer usage is not correct. - const shape: number[] = [aData.length]; - const a = () => tf.tensor({buffer: aBuffer, zeroCopy}, shape, dtype); - expect(a).toThrowError(); - aBuffer.destroy(); - }); -} - -describeWebGPU('create tensor from GPUBuffer', () => { - createTensorFromGPUTest(); -}); - -describeWebGPU('create tensor from GPUBuffer with zero copy', () => { - createTensorFromGPUTest(true); -}); diff --git a/tfjs-master/tfjs-backend-webgpu/src/backend_webgpu_test_registry.ts b/tfjs-master/tfjs-backend-webgpu/src/backend_webgpu_test_registry.ts deleted file mode 100644 index 461af317b..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/backend_webgpu_test_registry.ts +++ /dev/null @@ -1,28 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// tslint:disable-next-line: no-imports-from-dist -import {registerTestEnv} from '@tensorflow/tfjs-core/dist/jasmine_util'; - -registerTestEnv({ - name: 'webgpu', - backendName: 'webgpu', - flags: { - 'WEBGPU_CPU_FORWARD': false, - }, - isDataSync: true -}); diff --git a/tfjs-master/tfjs-backend-webgpu/src/base.ts b/tfjs-master/tfjs-backend-webgpu/src/base.ts deleted file mode 100644 index 1de43149b..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/base.ts +++ /dev/null @@ -1,66 +0,0 @@ -/** - * @license - * Copyright 2022 Google Inc. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import './flags_webgpu'; - -import {env, registerBackend} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from './backend_webgpu'; -import {isWebGPUSupported} from './webgpu_util'; - -if (isWebGPUSupported()) { - registerBackend('webgpu', async () => { - const gpuDescriptor: GPURequestAdapterOptions = { - powerPreference: env().get('WEBGPU_USE_LOW_POWER_GPU') ? - 'low-power' : - 'high-performance' - }; - - const adapter = await navigator.gpu.requestAdapter(gpuDescriptor); - const deviceDescriptor: GPUDeviceDescriptor = {}; - - const requiredFeatures = []; - if (adapter.features.has('timestamp-query')) { - requiredFeatures.push('timestamp-query'); - } - if (adapter.features.has('bgra8unorm-storage')) { - requiredFeatures.push(['bgra8unorm-storage']); - } - deviceDescriptor.requiredFeatures = - requiredFeatures as Iterable; - - const adapterLimits = adapter.limits; - deviceDescriptor.requiredLimits = { - 'maxComputeWorkgroupStorageSize': - adapterLimits.maxComputeWorkgroupStorageSize, - 'maxComputeWorkgroupsPerDimension': - adapterLimits.maxComputeWorkgroupsPerDimension, - 'maxStorageBufferBindingSize': adapterLimits.maxStorageBufferBindingSize, - 'maxBufferSize': adapterLimits.maxBufferSize, - 'maxComputeWorkgroupSizeX': adapterLimits.maxComputeWorkgroupSizeX, - 'maxComputeInvocationsPerWorkgroup': - adapterLimits.maxComputeInvocationsPerWorkgroup, - }; - - const device: GPUDevice = await adapter.requestDevice(deviceDescriptor); - const adapterInfo = await adapter.requestAdapterInfo(); - return new WebGPUBackend(device, adapterInfo); - }, 3 /*priority*/); -} - -// Export webgpu utilities -export * from './webgpu'; diff --git a/tfjs-master/tfjs-backend-webgpu/src/batchnorm_webgpu.ts b/tfjs-master/tfjs-backend-webgpu/src/batchnorm_webgpu.ts deleted file mode 100644 index 9f5199ded..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/batchnorm_webgpu.ts +++ /dev/null @@ -1,87 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util} from '@tensorflow/tfjs-core'; -import {getMainHeaderString as main, WebGPUProgram} from './webgpu_program'; -import {computeDispatch, flatDispatchLayout} from './webgpu_util'; - -export class BatchNormProgram implements WebGPUProgram { - outputShape: number[]; - shaderKey: string; - dispatchLayout: {x: number[], y?: number[], z?: number[]}; - dispatch: [number, number, number]; - variableNames: string[]; - uniforms = 'varianceEpsilon : f32,'; - // This is an experimental value. - workgroupSize: [number, number, number] = [128, 1, 1]; - offsetShape: number[]|null; - scaleShape: number[]|null; - varianceEpsilon: number; - size = true; - - constructor( - xShape: number[], meanShape: number[], varianceShape: number[], - offsetShape: number[]|null, scaleShape: number[]|null) { - this.variableNames = ['x', 'mean', 'variance']; - backend_util.assertAndGetBroadcastShape(xShape, meanShape); - backend_util.assertAndGetBroadcastShape(xShape, varianceShape); - this.outputShape = xShape; - this.dispatchLayout = flatDispatchLayout(this.outputShape); - this.dispatch = computeDispatch( - this.dispatchLayout, this.outputShape, this.workgroupSize); - - if (offsetShape != null) { - backend_util.assertAndGetBroadcastShape(xShape, offsetShape); - this.variableNames.push('offset'); - } - if (scaleShape != null) { - backend_util.assertAndGetBroadcastShape(xShape, scaleShape); - this.variableNames.push('scale'); - } - this.offsetShape = offsetShape; - this.scaleShape = scaleShape; - this.shaderKey = 'batchNorm'; - } - - getUserCode(): string { - let offsetSnippet = '0.0'; - if (this.offsetShape != null) { - offsetSnippet = 'getOffsetByOutputIndex(index)'; - } - - let scaleSnippet = '1.0'; - if (this.scaleShape != null) { - scaleSnippet = 'getScaleByOutputIndex(index)'; - } - - const userCode = ` - ${main('index')} { - if (index < uniforms.size) - { - let xValue = getXByOutputIndex(index); - let meanValue = getMeanByOutputIndex(index); - let varianValue = getVarianceByOutputIndex(index); - let offsetValue = ${offsetSnippet}; - let scaleValue = ${scaleSnippet}; - let inv = scaleValue * inverseSqrt(varianValue + f32(uniforms.varianceEpsilon)); - setOutputAtIndex(index,dot(vec3(xValue, -meanValue, offsetValue), vec3(inv, inv, 1.0))); - } - } - `; - return userCode; - } -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/binary_op_complex_webgpu.ts b/tfjs-master/tfjs-backend-webgpu/src/binary_op_complex_webgpu.ts deleted file mode 100644 index 2b11c0093..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/binary_op_complex_webgpu.ts +++ /dev/null @@ -1,63 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util} from '@tensorflow/tfjs-core'; -import {BinaryOpType, getBinaryOpString} from './binary_op_util'; -import {getMainHeaderString as main, WebGPUProgram} from './webgpu_program'; -import {computeDispatch, flatDispatchLayout} from './webgpu_util'; - -export class BinaryOpComplexProgram implements WebGPUProgram { - variableNames = ['AReal', 'AImag', 'BReal', 'BImag']; - outputShape: number[]; - shaderKey: string; - dispatchLayout: {x: number[]}; - dispatch: [number, number, number]; - workgroupSize: [number, number, number] = [128, 1, 1]; - op: BinaryOpType; - size = true; - - constructor(op: BinaryOpType, aShape: number[], bShape: number[]) { - this.outputShape = backend_util.assertAndGetBroadcastShape(aShape, bShape); - this.dispatchLayout = flatDispatchLayout(this.outputShape); - this.dispatch = computeDispatch( - this.dispatchLayout, this.outputShape, this.workgroupSize); - - this.shaderKey = `binaryOpComplex_${op}`; - this.op = op; - } - - getUserCode(): string { - const opStr = getBinaryOpString(this.op, false); - const userCode = ` - fn binaryOpComplex( - areal : f32, aimag : f32, breal : f32, bimag : f32) -> f32 { - ${opStr} - } - - ${main('index')} { - if(index < uniforms.size) { - let areal = getARealByOutputIndex(index); - let aimag = getAImagByOutputIndex(index); - let breal = getBRealByOutputIndex(index); - let bimag = getBImagByOutputIndex(index); - setOutputAtIndex(index, binaryOpComplex(areal, aimag, breal, bimag)); - } - } - `; - return userCode; - } -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/binary_op_util.ts b/tfjs-master/tfjs-backend-webgpu/src/binary_op_util.ts deleted file mode 100644 index d462ed1ac..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/binary_op_util.ts +++ /dev/null @@ -1,282 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -export enum BinaryOpType { - ADD, - ATAN2, - COMPLEX_MULTIPLY_IMAG, - COMPLEX_MULTIPLY_REAL, - DIV, - ELU_DER, - EQUAL, - FLOOR_DIV, - GREATER, - GREATER_EQUAL, - LESS, - LESS_EQUAL, - LOGICAL_AND, - LOGICAL_OR, - MAX, - MIN, - MOD, - MUL, - NOT_EQUAL, - POW, - PRELU, - SQUARED_DIFFERENCE, - SUB -} - -const ADD = 'let resultTemp = a + b;'; -const ATAN2 = 'let resultTemp = atan2(a, b);'; -// (Ar + Ai)(Br + Bi) = -// ArBr + ArBi + AiBr + AiBi = ArBr - AB + ArBi + AiBr -// Yr = ArBr - AB -// Yi = ArBi + AiBr -const COMPLEX_MULTIPLY_REAL = 'let resultTemp = areal * breal - aimag * bimag;'; -const COMPLEX_MULTIPLY_IMAG = 'let resultTemp = areal * bimag + aimag * breal;'; -const DIV = 'let resultTemp = a / b;'; -const ELU_DER = 'let resultTemp = select(a * (b + 1.0), a, b >= b - b);'; -const EQUAL = ` - let zero = sign(a) * 0 + 0; - let one = sign(b) * 0 + 1; - let resultTemp = select(zero, one, a == b); -`; -const FLOOR_DIV = ` - let remainder = - select(a % b, round(a % b), (round(a) == a) & (round(b) == b)); - let quotient = (a - remainder) / b; - let resultTemp = - round(select(quotient, quotient - 1, sign(remainder) == -sign(b))); -`; -const GREATER = ` - let zero = sign(a) * 0 + 0; - let one = sign(b) * 0 + 1; - let resultTemp = select(zero, one, a > b); -`; -const GREATER_EQUAL = ` - let zero = sign(a) * 0 + 0; - let one = sign(b) * 0 + 1; - let resultTemp = select(zero, one, a >= b); -`; -const LESS = ` - let zero = sign(a) * 0 + 0; - let one = sign(b) * 0 + 1; - let resultTemp = select(zero, one, a < b); -`; -const LESS_EQUAL = ` - let zero = sign(a) * 0 + 0; - let one = sign(b) * 0 + 1; - let resultTemp = select(zero, one, a <= b); -`; -const LOGICAL_AND = 'return f32(a >= 1.0 && b >= 1.0);'; -const LOGICAL_AND_VEC4 = `return (vec4(a >= vec4(1.0)) * - vec4(b >= vec4(1.0)));`; -const LOGICAL_OR = 'return f32(a >= 1.0 || b >= 1.0);'; -const LOGICAL_OR_VEC4 = `return min(vec4(a >= vec4(1.0)) + - vec4(b >= vec4(1.0)), vec4(1.0));`; -const MAX = 'let resultTemp = max(a, b);'; -const MIN = 'let resultTemp = min(a, b);'; -const MOD = ` - let isNaN = b == 0.; - var resultTemp = a % b; - resultTemp = select((resultTemp + b) % b, resultTemp, - (a < 0. && b < 0.) || (a >= 0. && b > 0.)); -`; -const MOD_VEC4 = ` - let isNaN = !vec4(b); - var resultTemp = vec4(a % b); - if (!((a[0] < 0. && b[0] < 0.) || (a[0] >= 0. && b[0] > 0.))) { - resultTemp[0] = (resultTemp[0] + b[0]) % b[0]; - } - if (!((a[1] < 0. && b[1] < 0.) || (a[1] >= 0. && b[1] > 0.))) { - resultTemp[1] = (resultTemp[1] + b[1]) % b[1]; - } - if (!((a[2] < 0. && b[2] < 0.) || (a[2] >= 0. && b[2] > 0.))) { - resultTemp[2] = (resultTemp[2] + b[2]) % b[2]; - } - if (!((a[3] < 0. && b[3] < 0.) || (a[3] >= 0. && b[3] > 0.))) { - resultTemp[3] = (resultTemp[3] + b[3]) % b[3]; - } -`; -const MUL = 'let resultTemp = a * b;'; -const NOT_EQUAL = ` - var resultTemp = f32(a != b); - let valueForNaN = 1.0; -`; -const NOT_EQUAL_VEC4 = ` - var resultTemp = vec4(a != b); - let valueForNaN = 1.0; -`; - -const POW = ` - let isNaN = a < 0.0 && floor(b) < b; - if (b == 0.0) { - return 1.0; - } - var resultTemp = select(sign(a) * pow(abs(a), b), pow(abs(a), b), - round(abs(b) % 2.0) != 1.0); -`; -const POW_VEC4 = ` - let isModRound1Bool = vec4(round(abs(b) % vec4(2.0))) == vec4(1); - let isModRound1 = vec4(isModRound1Bool); - let multiplier = sign(a) * isModRound1 + (vec4(1.0) - isModRound1); - var resultTemp = multiplier * pow(abs(a), b); - - // Ensure that a^0 = 1, including 0^0 = 1 as this correspond to TF and JS - let isExpZero = b == vec4(0.0); - if (isExpZero.r) { - resultTemp.r = 1.0; - } - if (isExpZero.g) { - resultTemp.g = 1.0; - } - if (isExpZero.b) { - resultTemp.b = 1.0; - } - if (isExpZero.a) { - resultTemp.a = 1.0; - } - let isNaN = (a < vec4(0.0)) & (floor(b) < b); -`; - -const PRELU = `if (a < 0.0) { return b * a; } return a;`; -const PRELU_VEC4 = ` - let aLessThanZero = vec4(a < vec4(0.0)); - return (aLessThanZero * (b * a)) + ((vec4(1.0) - aLessThanZero) * a); -`; -const SQUARED_DIFFERENCE = 'let resultTemp = (a - b) * (a - b);'; -const SUB = 'let resultTemp = a - b;'; - -export function getBinaryOpString( - type: BinaryOpType, useVec4?: boolean): string { - let doOpSnippet: string; - - // Ops with NaN check - do { - switch (type) { - case BinaryOpType.ATAN2: - doOpSnippet = ATAN2; - break; - case BinaryOpType.MAX: - doOpSnippet = MAX; - break; - case BinaryOpType.MIN: - doOpSnippet = MIN; - break; - case BinaryOpType.MOD: - doOpSnippet = useVec4 ? MOD_VEC4 : MOD; - break; - case BinaryOpType.NOT_EQUAL: - doOpSnippet = useVec4 ? NOT_EQUAL_VEC4 : NOT_EQUAL; - break; - case BinaryOpType.POW: - doOpSnippet = useVec4 ? POW_VEC4 : POW; - break; - default: - continue; - } - - let isNaN: string; - let dTypeN: string; - let boolN: string; - if (useVec4) { - isNaN = 'isnanVec4'; - dTypeN = 'vec4'; - boolN = 'vec4'; - } else { - isNaN = 'isnan'; - dTypeN = 'f32'; - boolN = 'bool'; - } - - return ` - let aIsNaN = ${isNaN}(a); - let aPostLegalization = select(a, ${dTypeN}(42), aIsNaN); - let bIsNaN = ${isNaN}(b); - let bPostLegalization = select(b, ${dTypeN}(42), bIsNaN); - let isNaN = false; - let valueForNaN = uniforms.NAN; - { - let a = aPostLegalization; - let b = bPostLegalization; - ${doOpSnippet} - return select( - resultTemp, ${dTypeN}(valueForNaN), - ${boolN}(isNaN) | aIsNaN | bIsNaN); - } - `; - } while (false); - - // Ops without NaN check - switch (type) { - case BinaryOpType.ADD: - doOpSnippet = ADD; - break; - case BinaryOpType.COMPLEX_MULTIPLY_IMAG: - doOpSnippet = COMPLEX_MULTIPLY_IMAG; - break; - case BinaryOpType.COMPLEX_MULTIPLY_REAL: - doOpSnippet = COMPLEX_MULTIPLY_REAL; - break; - case BinaryOpType.DIV: - doOpSnippet = DIV; - break; - case BinaryOpType.ELU_DER: - doOpSnippet = ELU_DER; - break; - case BinaryOpType.EQUAL: - doOpSnippet = EQUAL; - break; - case BinaryOpType.FLOOR_DIV: - doOpSnippet = FLOOR_DIV; - break; - case BinaryOpType.GREATER: - doOpSnippet = GREATER; - break; - case BinaryOpType.GREATER_EQUAL: - doOpSnippet = GREATER_EQUAL; - break; - case BinaryOpType.LESS: - doOpSnippet = LESS; - break; - case BinaryOpType.LESS_EQUAL: - doOpSnippet = LESS_EQUAL; - break; - case BinaryOpType.LOGICAL_AND: - return useVec4 ? LOGICAL_AND_VEC4 : LOGICAL_AND; - case BinaryOpType.LOGICAL_OR: - return useVec4 ? LOGICAL_OR_VEC4 : LOGICAL_OR; - case BinaryOpType.MUL: - doOpSnippet = MUL; - break; - case BinaryOpType.PRELU: - return useVec4 ? PRELU_VEC4 : PRELU; - case BinaryOpType.SQUARED_DIFFERENCE: - doOpSnippet = SQUARED_DIFFERENCE; - break; - case BinaryOpType.SUB: - doOpSnippet = SUB; - break; - default: - // throw new Error(`BinaryType ${type} is not implemented!`); - } - return ` - ${doOpSnippet} - return resultTemp; - `; -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/binary_op_webgpu.ts b/tfjs-master/tfjs-backend-webgpu/src/binary_op_webgpu.ts deleted file mode 100644 index 588fe9282..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/binary_op_webgpu.ts +++ /dev/null @@ -1,146 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, util} from '@tensorflow/tfjs-core'; - -import {BinaryOpType, getBinaryOpString} from './binary_op_util'; -import {getMainHeaderString as main, WebGPUProgram} from './webgpu_program'; -import {computeDispatch, flatDispatchLayout} from './webgpu_util'; - -export class BinaryOpProgram implements WebGPUProgram { - dispatch: [number, number, number]; - dispatchLayout: {x: number[]}; - outputComponent: number; - op: BinaryOpType; - outputShape: number[]; - shaderKey: string; - size = true; - variableNames = ['A', 'B']; - workgroupSize: [number, number, number]; - variableComponents: number[]; - - private lastDimensionSize: number; - private useSharedMemoryWithA: boolean; - private useSharedMemoryWithB: boolean; - private type: string; - - constructor(op: BinaryOpType, aShape: number[], bShape: number[]) { - this.outputShape = backend_util.assertAndGetBroadcastShape(aShape, bShape); - this.dispatchLayout = flatDispatchLayout(this.outputShape); - this.op = op; - - this.useSharedMemoryWithA = - aShape.length <= 1 && bShape.length > 1 && aShape[0] < 128; - this.useSharedMemoryWithB = - bShape.length <= 1 && aShape.length > 1 && bShape[0] < 128; - - if (this.useSharedMemoryWithA || this.useSharedMemoryWithB) { - this.outputComponent = 1; - this.variableComponents = [1, 1]; - // lastDimensionSize is used as sharedBuf array size, so can not be - // used as uniform. - this.lastDimensionSize = - this.useSharedMemoryWithB ? bShape[0] : aShape[0]; - this.shaderKey = `binary_${op}_${this.lastDimensionSize}`; - this.type = 'shared'; - // This is an experimental value when using shared memory. - // Note that the maximum of workgroup X dimension is 256. - this.workgroupSize = [256, 1, 1]; - } else { - const aDivisibleBy4 = - aShape.length > 0 && aShape[aShape.length - 1] % 4 === 0; - const bDivisibleBy4 = - bShape.length > 0 && bShape[bShape.length - 1] % 4 === 0; - if (aDivisibleBy4 && bDivisibleBy4) { - this.outputComponent = 4; - this.variableComponents = [4, 4]; - } else if ( - (aDivisibleBy4 && - (util.isScalarShape(bShape) || bShape[bShape.length - 1] === 1)) || - (bDivisibleBy4 && - (util.isScalarShape(aShape) || aShape[aShape.length - 1] === 1))) { - this.outputComponent = 4; - this.variableComponents = aDivisibleBy4 ? [4, 1] : [1, 4]; - } else { - this.outputComponent = 1; - this.variableComponents = [1, 1]; - } - this.type = 'nonshared'; - this.shaderKey = `binary_${op}_${this.variableComponents}`; - // TODO(jiajia.qin@intel.com): Heuristically select a good work group - // size. - this.workgroupSize = [128, 1, 1]; - } - this.dispatch = computeDispatch( - this.dispatchLayout, this.outputShape, this.workgroupSize, - [this.outputComponent, 1, 1]); - } - - getUserCode(): string { - let userCode; - const dType = this.outputComponent === 4 ? 'vec4' : 'f32'; - const opFnStr = ` - fn binaryOperation(a : ${dType}, b : ${dType}) -> ${dType} { - ${getBinaryOpString(this.op, this.outputComponent === 4)} - }; - `; - - if (this.type === 'shared') { - const sharedIndexSnippet = this.lastDimensionSize > 1 ? - `coords[${this.outputShape.length - 1}]` : - '0'; - const accessDataSnippet = this.useSharedMemoryWithB ? - `let a = getAByOutputIndex(index); - let b = sharedBuf[${sharedIndexSnippet}];` : - `let a = sharedBuf[${sharedIndexSnippet}]; - let b = getBByOutputIndex(index);`; - userCode = ` - ${opFnStr} - var sharedBuf : array; - ${main('index')} { - // Fill in the shared memory buffer. - let localIndex = i32(localId.x); - if(localIndex < ${this.lastDimensionSize}) { - sharedBuf[localIndex] = f32(${ - this.useSharedMemoryWithB ? 'B' : 'A'}[localIndex]); - } - workgroupBarrier(); - - if(index < uniforms.size) { - let coords = getCoordsFromIndex(index); - ${accessDataSnippet} - setOutputAtIndex(index, binaryOperation(a, b)); - } - } - `; - } else { - userCode = ` - ${opFnStr} - ${main('index')} { - if (index < uniforms.size) { - let coords = getCoordsFromIndex(index * ${this.outputComponent}); - let a = ${dType}(getAByOutputCoords(coords)); - let b = ${dType}(getBByOutputCoords(coords)); - setOutputAtIndex(index, binaryOperation(a, b)); - } - } - `; - } - - return userCode; - } -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/bincount_webgpu.ts b/tfjs-master/tfjs-backend-webgpu/src/bincount_webgpu.ts deleted file mode 100644 index 22ca01513..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/bincount_webgpu.ts +++ /dev/null @@ -1,98 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {atomicAddSnippet} from './shader_util'; -import {getMainHeaderString as main, WebGPUProgram} from './webgpu_program'; -import {computeDispatch, flatDispatchLayout} from './webgpu_util'; - -const writeSnippet = ` - fn bincount_write(index: i32, value: f32) { - ${atomicAddSnippet('&result[index]', 'value', 'float32')} - } -`; - -const binaryWriteSnippet = ` - fn bincount_write(index: i32, value: f32) { - atomicStore(&result[index], bitcast(value)); - } -`; - -export class BincountProgram implements WebGPUProgram { - outputShape: number[] = []; - shaderKey: string; - dispatchLayout: {x: number[]}; - dispatch: [number, number, number]; - variableNames = ['x']; - uniforms = 'binCountSize : i32,'; - workgroupSize: [number, number, number] = [64, 1, 1]; - atomic = true; - hasWeights = true; - binaryOutput = false; - rank: number; - - constructor( - shape: [number]|[number, number], hasWeights: boolean, - binaryOutput = false) { - this.outputShape = shape; - this.rank = shape.length; - this.dispatchLayout = flatDispatchLayout(this.outputShape); - this.dispatch = computeDispatch( - this.dispatchLayout, this.outputShape, this.workgroupSize); - - this.binaryOutput = binaryOutput; - if (binaryOutput) { - this.atomic = false; - } - this.hasWeights = hasWeights; - if (this.hasWeights) { - this.variableNames.push('w'); - } - this.shaderKey = - `bincount_${this.hasWeights}_${this.binaryOutput}_${this.rank}`; - } - - getUserCode(): string { - const userCode = ` - ${this.binaryOutput ? binaryWriteSnippet : writeSnippet} - ${main('index')} { - ${ - this.rank === 1 ? - `if (index < uniforms.xShape) { - let indexVal = i32(getX(index)); - if (indexVal < uniforms.binCountSize) { - let value = ${ - this.binaryOutput ? 1. : - (this.hasWeights ? 'getW(index)' : '1.')}; - bincount_write(indexVal, value); - } - }` : - `let coord = getCoordsFromIndex(index); - if (coordsInBounds2D(coord, uniforms.xShape)) { - let indexVal = i32(getX(coord[0], coord[1])); - if (indexVal < uniforms.binCountSize) { - let value = ${ - this.binaryOutput ? - 1. : - (this.hasWeights ? 'getW(coord[0], coord[1])' : '1.')}; - bincount_write(coord.x * uniforms.binCountSize + indexVal, value); - } - }`} - } - `; - return userCode; - } -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/broadcast_args_webgpu.ts b/tfjs-master/tfjs-backend-webgpu/src/broadcast_args_webgpu.ts deleted file mode 100644 index 1e0075437..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/broadcast_args_webgpu.ts +++ /dev/null @@ -1,69 +0,0 @@ -/** - * @license - * Copyright 2023 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {getMainHeaderString as main, WebGPUProgram} from './webgpu_program'; -import {computeDispatch, flatDispatchLayout} from './webgpu_util'; - -export class BroadcastArgsProgram implements WebGPUProgram { - outputShape: number[] = []; - shaderKey: string; - dispatchLayout: {x: number[]}; - dispatch: [number, number, number]; - variableNames = ['s0', 's1']; - uniforms = 's0Size : i32, s1Size : i32, '; - workgroupSize: [number, number, number] = [64, 1, 1]; - size = true; - - constructor(shape: number) { - this.outputShape = [shape]; - this.dispatchLayout = flatDispatchLayout(this.outputShape); - this.dispatch = computeDispatch( - this.dispatchLayout, this.outputShape, this.workgroupSize); - - this.shaderKey = 'broadcastArgs'; - } - - getUserCode(): string { - const userCode = ` - ${main('index')} { - if (index < uniforms.size) { - var s0 = 1.0; - var s1 = 1.0; - let indexS0 = index - uniforms.size + uniforms.s0Size; - let indexS1 = index - uniforms.size + uniforms.s1Size; - if (indexS0 >= 0) { - s0 = getS0(indexS0); - } - if (indexS1 >= 0) { - s1 = getS1(indexS1); - } - - if (s0 == 1.0) { - setOutputAtIndex(index, s1); - } else if (s1 == 1.0) { - setOutputAtIndex(index, s0); - } else if (s0 != s1) { - setOutputAtIndex(index, uniforms.NAN); - } else { - setOutputAtIndex(index, s0); - } - } - } - `; - return userCode; - } -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/buffer_manager.ts b/tfjs-master/tfjs-backend-webgpu/src/buffer_manager.ts deleted file mode 100644 index bafcebcc3..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/buffer_manager.ts +++ /dev/null @@ -1,122 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -export class BufferManager { - private numUsedBuffers = 0; - private numFreeBuffers = 0; - private freeBuffers: Map = new Map(); - private usedBuffers: Map = new Map(); - - public numBytesUsed = 0; - public numBytesAllocated = 0; - - constructor(private device: GPUDevice) {} - - acquireBuffer( - size: number, usage: GPUBufferUsageFlags, mappedAtCreation = false, - reuse = true) { - let buffer; - const key = getBufferKey(size, usage); - - if (reuse) { - if (!this.freeBuffers.has(key)) { - this.freeBuffers.set(key, []); - } - - if (this.freeBuffers.get(key).length > 0) { - buffer = this.freeBuffers.get(key).pop(); - this.numFreeBuffers--; - } else { - buffer = this.device.createBuffer({size, usage, mappedAtCreation}); - this.numBytesAllocated += size; - } - } else { - buffer = this.device.createBuffer({size, usage, mappedAtCreation}); - this.numBytesAllocated += size; - } - - if (!this.usedBuffers.has(key)) { - this.usedBuffers.set(key, []); - } - this.usedBuffers.get(key).push(buffer); - this.numUsedBuffers++; - this.numBytesUsed += size; - - return buffer; - } - - releaseBuffer(buffer: GPUBuffer, reuse = true) { - if (this.freeBuffers.size === 0) { - return; - } - - const size = buffer.size; - const usage = buffer.usage; - - const key = getBufferKey(size, usage); - const bufferArray = this.usedBuffers.get(key); - const index = bufferArray.indexOf(buffer); - if (index < 0) { - throw new Error('Cannot find the buffer in buffer manager'); - } - bufferArray[index] = bufferArray[bufferArray.length - 1]; - bufferArray.pop(); - this.numUsedBuffers--; - this.numBytesUsed -= size; - - if (reuse) { - this.freeBuffers.get(key).push(buffer); - this.numFreeBuffers++; - } else { - buffer.destroy(); - this.numBytesAllocated -= size; - } - } - - getNumUsedBuffers(): number { - return this.numUsedBuffers; - } - - getNumFreeBuffers(): number { - return this.numFreeBuffers; - } - - dispose() { - this.freeBuffers.forEach((buffers, key) => { - buffers.forEach(buffer => { - buffer.destroy(); - }); - }); - - this.usedBuffers.forEach((buffers, key) => { - buffers.forEach(buffer => { - buffer.destroy(); - }); - }); - - this.freeBuffers = new Map(); - this.usedBuffers = new Map(); - this.numUsedBuffers = 0; - this.numFreeBuffers = 0; - this.numBytesUsed = 0; - this.numBytesAllocated = 0; - } -} - -function getBufferKey(size: number, usage: GPUBufferUsageFlags) { - return `${size}_${usage}`; -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/clip_vec4_webgpu.ts b/tfjs-master/tfjs-backend-webgpu/src/clip_vec4_webgpu.ts deleted file mode 100644 index 1cb5a2a0d..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/clip_vec4_webgpu.ts +++ /dev/null @@ -1,56 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {getMainHeaderString as main, WebGPUProgram} from './webgpu_program'; -import {computeDispatch, flatDispatchLayout} from './webgpu_util'; - -export class ClipVec4Program implements WebGPUProgram { - outputShape: number[]; - shaderKey: string; - variableNames = ['A']; - uniforms = 'minVal : f32, maxVal : f32,'; - dispatchLayout: {x: number[]}; - dispatch: [number, number, number]; - workPerThread = 4; - workgroupSize: [number, number, number] = [64, 1, 1]; - outputComponent = 4; - size = true; - - constructor(outputShape: number[]) { - this.outputShape = outputShape; - this.dispatchLayout = flatDispatchLayout(this.outputShape); - this.dispatch = computeDispatch( - this.dispatchLayout, this.outputShape, this.workgroupSize, - [this.workPerThread, 1, 1]); - this.shaderKey = 'clipVec4'; - } - - getUserCode(): string { - const userCode = ` - ${main('index')} { - if(index < uniforms.size) { - let value = getAByOutputIndex(index); - var clampedValue = clamp( - value, vec4(uniforms.minVal), vec4(uniforms.maxVal)); - clampedValue = select(clampedValue, value, isnanVec4(value)); - setOutputAtIndex(index, clampedValue); - } - } - `; - return userCode; - } -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/clip_webgpu.ts b/tfjs-master/tfjs-backend-webgpu/src/clip_webgpu.ts deleted file mode 100644 index 7e0746b64..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/clip_webgpu.ts +++ /dev/null @@ -1,57 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {getMainHeaderString as main, WebGPUProgram} from './webgpu_program'; -import {computeDispatch, flatDispatchLayout} from './webgpu_util'; - -export class ClipProgram implements WebGPUProgram { - outputShape: number[]; - shaderKey: string; - variableNames = ['A']; - uniforms = 'minVal : f32, maxVal : f32,'; - dispatchLayout: {x: number[]}; - dispatch: [number, number, number]; - workgroupSize: [number, number, number] = [64, 1, 1]; - minVal: number; - maxVal: number; - size = true; - - constructor(outputShape: number[]) { - this.outputShape = outputShape; - this.dispatchLayout = flatDispatchLayout(this.outputShape); - this.dispatch = computeDispatch( - this.dispatchLayout, this.outputShape, this.workgroupSize); - - this.shaderKey = 'clip'; - } - - getUserCode(): string { - const userCode = ` - ${main('index')} { - if(index < uniforms.size) { - let value = getAByOutputIndex(index); - if (isnan(value)) { - setOutputAtIndex(index, value); - return; - } - setOutputAtIndex(index, clamp(value, uniforms.minVal, uniforms.maxVal)); - } - } - `; - return userCode; - } -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/complex_abs_webgpu.ts b/tfjs-master/tfjs-backend-webgpu/src/complex_abs_webgpu.ts deleted file mode 100644 index b0c8482ba..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/complex_abs_webgpu.ts +++ /dev/null @@ -1,55 +0,0 @@ -/** - * @license - * Copyright 2023 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {getMainHeaderString as main, WebGPUProgram} from './webgpu_program'; -import {computeDispatch, flatDispatchLayout} from './webgpu_util'; - -export class ComplexAbsProgram implements WebGPUProgram { - outputShape: number[] = []; - shaderKey: string; - dispatchLayout: {x: number[]}; - dispatch: [number, number, number]; - variableNames = ['real', 'imag']; - workgroupSize: [number, number, number] = [64, 1, 1]; - size = true; - - constructor(shape: number[]) { - this.outputShape = shape; - this.dispatchLayout = flatDispatchLayout(this.outputShape); - this.dispatch = computeDispatch( - this.dispatchLayout, this.outputShape, this.workgroupSize); - - this.shaderKey = 'complexAbs'; - } - - getUserCode(): string { - const userCode = ` - ${main('index')} { - if (index < uniforms.size) { - let re = abs(getRealByOutputIndex(index)); - let im = abs(getImagByOutputIndex(index)); - let mx = max(re, im); - - // The length function in wgsl may be not underflow-safe on some GPUs. - // So the safe solution is to ensure underflow-safety in all cases. - setOutputAtIndex(index, select(mx * length(vec2(1, min(re, im)/mx)), 0.0, mx == 0.0)); - } - } - `; - return userCode; - } -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/concat_webgpu.ts b/tfjs-master/tfjs-backend-webgpu/src/concat_webgpu.ts deleted file mode 100644 index d3485d838..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/concat_webgpu.ts +++ /dev/null @@ -1,85 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util} from '@tensorflow/tfjs-core'; -import {getMainHeaderString as main, WebGPUProgram} from './webgpu_program'; -import {computeDispatch, flatDispatchLayout} from './webgpu_util'; - -export class ConcatProgram implements WebGPUProgram { - outputShape: number[]; - shaderKey: string; - dispatchLayout: {x: number[]}; - dispatch: [number, number, number]; - variableNames: string[]; - uniforms = ''; - workPerThread = 1; - workgroupSize: [number, number, number] = [64, 1, 1]; - size = true; - offsetLength: number; - - constructor(shapes: Array<[number, number]>) { - this.outputShape = - backend_util.computeOutShape(shapes, 1 /* axis */) as [number, number]; - this.variableNames = shapes.map((_, i) => `T${i}`); - this.dispatchLayout = flatDispatchLayout(this.outputShape); - this.dispatch = computeDispatch( - this.dispatchLayout, this.outputShape, this.workgroupSize, - [this.workPerThread, 1, 1]); - - this.offsetLength = shapes.length - 1; - for (let i = 0; i < this.offsetLength; i++) { - this.uniforms += `offset${i} : i32,`; - } - this.shaderKey = 'concat'; - } - - getUserCode(): string { - const snippets: string[] = []; - if (this.offsetLength > 0) { - snippets.push( - `if (yC < uniforms.offset0){ setOutputAtCoords(coords.x, coords.y, getT0(yR, yC)); }`); - for (let i = 1; i < this.offsetLength; i++) { - snippets.push( - `else if (yC < uniforms.offset${[i]}){ ` + - `setOutputAtCoords(coords.x, coords.y, getT${ - i}(yR, yC - uniforms.offset${i - 1})); }`); - } - const lastIndex = this.offsetLength; - const lastShiftIndex = this.offsetLength - 1; - snippets.push(`else { setOutputAtCoords(coords.x, coords.y, getT${ - lastIndex}(yR, yC - uniforms.offset${lastShiftIndex})); }`); - } else { - snippets.push(`setOutputAtCoords(coords.x, coords.y, getT0(yR, yC));`); - } - - const userCode = ` - ${main('index')} { - for(var i = 0; i < ${this.workPerThread}; i = i + 1) { - let flatIndex = index * ${this.workPerThread} + i; - if(flatIndex < uniforms.size) { - let coords = getCoordsFromIndex(flatIndex); - let yR = coords.x; - let yC = coords.y; - - ${snippets.join('\n ')} - } - } - } - `; - return userCode; - } -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/conv2d_mm_webgpu.ts b/tfjs-master/tfjs-backend-webgpu/src/conv2d_mm_webgpu.ts deleted file mode 100644 index 32791a0dd..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/conv2d_mm_webgpu.ts +++ /dev/null @@ -1,270 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util} from '@tensorflow/tfjs-core'; - -import {activationFnSnippet, biasActivationSnippet} from './activation_util'; -import {makeMatMulPackedSource, makeMatMulPackedVec4Source} from './matmul_packed_webgpu'; -import {typeSnippet, WebGPUProgram} from './webgpu_program'; -import {computeDispatch, computeWorkgroupSizeForConv2d, computeWorkPerThreadForConv2d} from './webgpu_util'; - -function conv2dCommonSnippet( - isChannelsLast: boolean, fitAOuter: boolean, fitBOuter: boolean, - fitInner: boolean, addBias = false, - activation: backend_util.Activation = null, - hasPreluActivationWeights = false, innerElementSizeX = 4, - innerElementSizeW = 4, innerElementSize = 4) { - const getXSnippet = (innerElementSize: number) => { - switch (innerElementSize) { - case 1: - return 'resData = f32(x[xIndex]);'; - case 3: - return 'resData = vec3(x[xIndex], x[xIndex + 1], x[xIndex + 2]);'; - case 4: - return 'resData = vec4(x[xIndex / 4]);'; - default: - throw new Error( - `innerElementSize ${innerElementSize} is not supported.`); - } - }; - const getWSnippet = (innerElementSize: number) => { - switch (innerElementSize) { - case 1: - return 'return f32(W[row * uniforms.wShape[3] + col]);'; - case 4: - return 'return vec4(W[(row * uniforms.wShape[3] + col) / 4]);'; - default: - throw new Error( - `innerElementSize ${innerElementSize} is not supported.`); - } - }; - const coordASnippet = isChannelsLast ? ` - let coord = vec4(batch, xRow, xCol, xCh); - ` : - ` - let coord = vec4(batch, xCh, xRow, xCol); - `; - - const coordResSnippet = isChannelsLast ? ` - let coords = vec4( - batch, - row / outWidth, - row % outWidth, - col); - ` : - ` - let coords = vec4( - batch, - row, - col / outWidth, - col % outWidth); - `; - - const xHight = isChannelsLast ? 'uniforms.xShape[1]' : 'uniforms.xShape[2]'; - const xWidth = isChannelsLast ? 'uniforms.xShape[2]' : 'uniforms.xShape[3]'; - const row = isChannelsLast ? 'row' : 'col'; - const col = isChannelsLast ? 'col' : 'row'; - const readXSnippet = ` - let inChannels = uniforms.wShape[2]; - let outWidth = ${ - isChannelsLast ? 'uniforms.outShape[2]' : 'uniforms.outShape[3]'}; - let outRow = ${row} / outWidth; - let outCol = ${row} % outWidth; - - let WRow = ${col} / (uniforms.filterDims[1] * inChannels); - let WCol = ${col} / inChannels % uniforms.filterDims[1]; - let xRow = outRow * uniforms.strides[0] + uniforms.dilations[0] * WRow - uniforms.pads[0]; - let xCol = outCol * uniforms.strides[1] + uniforms.dilations[1] * WCol - uniforms.pads[1]; - let xCh = ${col} % inChannels; - var resData = ${typeSnippet(innerElementSizeX)}(0.0); - // The bounds checking is always needed since we use it to pad zero for - // the 'same' padding type. - if (xRow >= 0 && xRow < ${xHight} && xCol >= 0 && xCol < ${xWidth}) { - ${coordASnippet} - let xIndex = getIndexFromCoords4D(coord, uniforms.xShape); - ${getXSnippet(innerElementSizeX)} - } - return resData;`; - - const sampleX = isChannelsLast ? (fitAOuter && fitInner ? ` - ${readXSnippet}` : - ` - if (row < uniforms.dimAOuter && col < uniforms.dimInner) { - ${readXSnippet} - } - return ${typeSnippet(innerElementSizeX)}(0.0);`) : - (fitInner && fitBOuter ? ` - ${readXSnippet}` : - ` - if (row < uniforms.dimInner && col < uniforms.dimBOuter) { - ${readXSnippet} - } - return ${typeSnippet(innerElementSizeX)}(0.0);`); - - const sampleW = `${getWSnippet(innerElementSizeW)}`; - - const resType = typeSnippet(innerElementSize); - const aType = isChannelsLast ? typeSnippet(innerElementSizeX) : - typeSnippet(innerElementSizeW); - const bType = isChannelsLast ? typeSnippet(innerElementSizeW) : - typeSnippet(innerElementSizeX); - const userCode = ` - ${ - activationFnSnippet( - activation, hasPreluActivationWeights, innerElementSize === 4, 4)} - fn mm_readA(batch: i32, row : i32, col : i32) -> ${aType} { - ${isChannelsLast ? sampleX : sampleW} - } - - fn mm_readB(batch: i32, row : i32, col : i32) -> ${bType} { - ${isChannelsLast ? sampleW : sampleX} - } - - fn mm_write(batch: i32, row : i32, col : i32, valueIn : ${resType}) { - if (row < uniforms.dimAOuter && col < uniforms.dimBOuter) - { - var value = valueIn; - let outWidth = ${ - isChannelsLast ? 'uniforms.outShape[2]' : 'uniforms.outShape[3]'}; - ${coordResSnippet} - ${biasActivationSnippet(addBias, activation)} - setOutputAtCoords(coords[0], coords[1], coords[2], coords[3], value); - } - }`; - return userCode; -} - -export class Conv2DMMProgram implements WebGPUProgram { - outputShape: number[]; - shaderKey: string; - dispatchLayout: {x: number[], y: number[], z: number[]}; - dispatch: [number, number, number]; - variableNames = ['x', 'W']; - variableComponents: number[]; - uniforms = - `filterDims : vec2, pads : vec2, strides : vec2, dilations : vec2, dimAOuter : i32, dimBOuter : i32, dimInner : i32,`; - workgroupSize: [number, number, number]; - elementsPerThread: [number, number, number]; - addBias: boolean; - activation: backend_util.Activation; - hasPreluActivationWeights: boolean; - isChannelsLast: boolean; - fitAOuter: boolean; - fitBOuter: boolean; - fitInner: boolean; - tileAOuter: number; - tileBOuter: number; - tileInner: number; - innerElementSize: number; - isVec4?: boolean; - outputComponent: number; - private sequentialAccessByThreads: boolean; - - constructor( - convInfo: backend_util.Conv2DInfo, dimAOuter: number, dimBOuter: number, - dimInner: number, addBias = false, - activation: backend_util.Activation = null, - hasPreluActivationWeights = false, sequentialAccessByThreads = false) { - this.outputShape = convInfo.outShape; - this.isChannelsLast = convInfo.dataFormat === 'channelsLast'; - this.isVec4 = - (((convInfo.inChannels % 4 === 0 || convInfo.inChannels % 3 === 0) && - this.isChannelsLast) || - (convInfo.outWidth % 4 === 0 && !this.isChannelsLast)) && - convInfo.outChannels % 4 === 0; - this.dispatchLayout = this.isChannelsLast ? {x: [3], y: [1, 2], z: [0]} : - {x: [2, 3], y: [1], z: [0]}; - this.workgroupSize = computeWorkgroupSizeForConv2d( - this.dispatchLayout, this.outputShape, this.isVec4); - this.elementsPerThread = computeWorkPerThreadForConv2d( - this.dispatchLayout, this.outputShape, this.isVec4); - - this.dispatch = computeDispatch( - this.dispatchLayout, this.outputShape, this.workgroupSize, - this.elementsPerThread); - - if (this.isVec4) { - this.outputComponent = 4; - if (this.isChannelsLast && convInfo.inChannels % 4 !== 0) { - this.innerElementSize = 3; - this.variableComponents = [1, 4]; - } else { - this.innerElementSize = 4; - this.variableComponents = [4, 4]; - } - - if (addBias) { - this.variableNames.push('bias'); - this.variableComponents.push(4); - } - - if (hasPreluActivationWeights) { - this.variableNames.push('preluActivationWeights'); - this.variableComponents.push(4); - } - } else { - this.innerElementSize = this.elementsPerThread[0]; - if (addBias) { - this.variableNames.push('bias'); - } - - if (hasPreluActivationWeights) { - this.variableNames.push('preluActivationWeights'); - } - } - - this.sequentialAccessByThreads = sequentialAccessByThreads; - this.addBias = addBias; - this.activation = activation; - this.hasPreluActivationWeights = hasPreluActivationWeights; - - this.tileAOuter = this.workgroupSize[1] * this.elementsPerThread[1]; - this.tileBOuter = this.workgroupSize[0] * this.elementsPerThread[0]; - this.tileInner = Math.max( - this.workgroupSize[0] * this.innerElementSize, this.workgroupSize[1]); - - this.fitAOuter = dimAOuter % this.tileAOuter === 0; - this.fitBOuter = dimBOuter % this.tileBOuter === 0; - this.fitInner = dimInner % this.tileInner === 0; - - this.shaderKey = `conv2DMM_${this.elementsPerThread}_${this.activation}}_${ - this.fitAOuter}_${this.fitBOuter}_${this.fitInner}_${this.isVec4}_${ - this.innerElementSize}_${this.isChannelsLast}_${ - this.sequentialAccessByThreads}`; - } - - getUserCode(): string { - const matMulSource = this.isVec4 ? - makeMatMulPackedVec4Source( - this.elementsPerThread, this.workgroupSize, !this.isChannelsLast, - this.tileInner) : - makeMatMulPackedSource( - this.elementsPerThread, this.workgroupSize, !this.isChannelsLast, - this.tileInner, false, null, this.sequentialAccessByThreads); - const elementsSize = - this.isVec4 ? [this.innerElementSize, 4, 4] : [1, 1, 1]; - const userCode = ` - ${ - conv2dCommonSnippet( - this.isChannelsLast, this.fitAOuter, this.fitBOuter, this.fitInner, - this.addBias, this.activation, this.hasPreluActivationWeights, - elementsSize[0], elementsSize[1], elementsSize[2])} - ${matMulSource} - `; - return userCode; - } -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/conv2d_naive_webgpu.ts b/tfjs-master/tfjs-backend-webgpu/src/conv2d_naive_webgpu.ts deleted file mode 100644 index 90d936f6f..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/conv2d_naive_webgpu.ts +++ /dev/null @@ -1,121 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util} from '@tensorflow/tfjs-core'; - -import {activationFnSnippet, biasActivationSnippet} from './activation_util'; -import {getMainHeaderString as main, WebGPUProgram} from './webgpu_program'; -import {computeDispatch} from './webgpu_util'; - -export class Conv2DNaiveProgram implements WebGPUProgram { - outputShape: number[]; - shaderKey: string; - dispatchLayout: {x: number[], y: number[], z: number[]}; - dispatch: [number, number, number]; - variableNames = ['x', 'W']; - uniforms = - 'filterDims: vec2, pads: vec2, strides: vec2, dilations: vec2,'; - workgroupSize: [number, number, number] = [4, 4, 8]; - addBias: boolean; - activation: backend_util.Activation; - hasPreluActivationWeights: boolean; - isChannelsLast: boolean; - - constructor( - convInfo: backend_util.Conv2DInfo, addBias = false, - activation: backend_util.Activation = null, - hasPreluActivationWeights = false) { - this.outputShape = convInfo.outShape; - this.isChannelsLast = convInfo.dataFormat === 'channelsLast'; - this.dispatchLayout = this.isChannelsLast ? {x: [2], y: [1], z: [0, 3]} : - {x: [3], y: [2], z: [0, 1]}; - this.dispatch = computeDispatch( - this.dispatchLayout, this.outputShape, this.workgroupSize); - this.addBias = addBias; - this.activation = activation; - this.hasPreluActivationWeights = hasPreluActivationWeights; - - if (addBias) { - this.variableNames.push('bias'); - } - - if (hasPreluActivationWeights) { - this.variableNames.push('preluActivationWeights'); - } - - this.shaderKey = `conv2dnaive_${this.activation}_${this.isChannelsLast}`; - } - - getUserCode(): string { - const userCode = ` - ${ - activationFnSnippet( - this.activation, this.hasPreluActivationWeights, false, 4)} - fn readInp(batch : i32, row : i32, col : i32, chan : i32) -> f32{ - let coords = vec4(batch, row, col, chan); - if (coordsInBounds4D(coords, uniforms.xShape)) { - return getX(batch, row, col, chan); - } else { - return 0.0; - } - } - fn readFilt(row : i32, col : i32, xChannel : i32, outChannel : i32) -> f32{ - let coords = vec4(row, col, xChannel, outChannel); - if(coordsInBounds4D(coords, uniforms.wShape)) { - return getW(row, col, xChannel, outChannel); - } else { - return 0.0; - } - } - fn writeResult(batch : i32, row : i32, col : i32, chan : i32, valueIn : f32) { - let coords = ${ - this.isChannelsLast ? `vec4(batch, row, col, chan);` : - `vec4(batch, chan, row, col);`} - if (coordsInBounds4D(coords, uniforms.outShape)) { - var value = valueIn; - ${biasActivationSnippet(this.addBias, this.activation)} - setOutputAtCoords(coords.x, coords.y, coords.z, coords.w, value); - } - } - ${main('index')} { - let coords = getOutputCoords(); - let batch = coords[0]; - let outChannel = ${this.isChannelsLast ? `coords[3];` : `coords[1];`} - let outRow = ${this.isChannelsLast ? `coords[1];` : `coords[2];`} - let outCol = ${this.isChannelsLast ? `coords[2];` : `coords[3];`} - var acc : f32 = 0.0; - for (var row = 0; row < uniforms.filterDims[0]; row = row + 1) { - for (var col = 0; col < uniforms.filterDims[1]; col = col + 1) { - let xRow = outRow * uniforms.strides[0] + uniforms.dilations[0] * row - uniforms.pads[0]; - let xCol = outCol * uniforms.strides[1] + uniforms.dilations[1] * col - uniforms.pads[1]; - for (var xChannel = 0; xChannel < ${ - this.isChannelsLast ? `uniforms.xShape[3];` : - `uniforms.xShape[1];`} xChannel = xChannel + 1) { - ${ - this.isChannelsLast ? `let v = readInp(batch, xRow, xCol, xChannel);` : - `let v = readInp(batch, xChannel, xRow, xCol);`} - let f = readFilt(row, col, xChannel, outChannel); - acc = acc + v * f; - } - } - } - writeResult(batch, outRow, outCol, outChannel, acc); - } - `; - return userCode; - } -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/conv3d_naive_webgpu.ts b/tfjs-master/tfjs-backend-webgpu/src/conv3d_naive_webgpu.ts deleted file mode 100644 index cb86c15a6..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/conv3d_naive_webgpu.ts +++ /dev/null @@ -1,129 +0,0 @@ -/** - * @license - * Copyright 2023 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util} from '@tensorflow/tfjs-core'; - -import {getMainHeaderString as main, WebGPUProgram} from './webgpu_program'; -import {computeDispatch, flatDispatchLayout} from './webgpu_util'; - -export class Conv3DNaiveProgram implements WebGPUProgram { - outputShape: number[]; - shaderKey: string; - dispatchLayout: {x: number[]}; - dispatch: [number, number, number]; - variableNames = ['x', 'W']; - uniforms = - 'filterDims: vec3, pads: vec3, strides: vec3, dilations: vec3,'; - workgroupSize: [number, number, number] = [64, 1, 1]; - size = true; - - constructor(convInfo: backend_util.Conv3DInfo) { - this.outputShape = convInfo.outShape; - this.dispatchLayout = flatDispatchLayout(this.outputShape); - this.dispatch = computeDispatch( - this.dispatchLayout, this.outputShape, this.workgroupSize); - - this.shaderKey = `conv3dnaive`; - } - - getUserCode(): string { - const userCode = ` - ${main('index')} { - if (index < uniforms.size) { - let coords = getOutputCoords(); - let batch = coords.x; - let d2 = coords.u; - - let xFRCCorner = vec3(coords.y, coords.z, coords.w) * uniforms.strides - uniforms.pads; - let xFCorner = xFRCCorner.x; - let xRCorner = xFRCCorner.y; - let xCCorner = xFRCCorner.z; - - let inputDepthNearestVec4 = (uniforms.xShape.u / 4) * 4; - let inputDepthVec4Remainder = uniforms.xShape.u % 4; - - var dotProd = 0.0; - for (var wF = 0; wF < uniforms.filterDims[0]; wF++) { - let xF = xFCorner + wF * uniforms.dilations[0]; - if (xF < 0 || xF >= uniforms.xShape.y) { - continue; - } - - for (var wR = 0; wR < uniforms.filterDims[1]; wR++) { - let xR = xRCorner + wR * uniforms.dilations[1]; - if (xR < 0 || xR >= uniforms.xShape.z) { - continue; - } - - for (var wC = 0; wC < uniforms.filterDims[2]; wC++) { - let xC = xCCorner + wC * uniforms.dilations[2]; - if (xC < 0 || xC >= uniforms.xShape.w) { - continue; - } - - for (var d1 = 0; d1 < inputDepthNearestVec4; d1 += 4) { - let xValues = vec4( - getX(batch, xF, xR, xC, d1), - getX(batch, xF, xR, xC, d1 + 1), - getX(batch, xF, xR, xC, d1 + 2), - getX(batch, xF, xR, xC, d1 + 3) - ); - let wValues = vec4( - getW(wF, wR, wC, d1, d2), - getW(wF, wR, wC, d1 + 1, d2), - getW(wF, wR, wC, d1 + 2, d2), - getW(wF, wR, wC, d1 + 3, d2) - ); - - dotProd += dot(xValues, wValues); - } - - if (inputDepthVec4Remainder == 1) { - dotProd += getX(batch, xF, xR, xC, inputDepthNearestVec4) * - getW(wF, wR, wC, inputDepthNearestVec4, d2); - } else if (inputDepthVec4Remainder == 2) { - let xValues = vec2( - getX(batch, xF, xR, xC, inputDepthNearestVec4), - getX(batch, xF, xR, xC, inputDepthNearestVec4 + 1) - ); - let wValues = vec2( - getW(wF, wR, wC, inputDepthNearestVec4, d2), - getW(wF, wR, wC, inputDepthNearestVec4 + 1, d2) - ); - dotProd += dot(xValues, wValues); - } else if (inputDepthVec4Remainder == 3) { - let xValues = vec3( - getX(batch, xF, xR, xC, inputDepthNearestVec4), - getX(batch, xF, xR, xC, inputDepthNearestVec4 + 1), - getX(batch, xF, xR, xC, inputDepthNearestVec4 + 2) - ); - let wValues = vec3( - getW(wF, wR, wC, inputDepthNearestVec4, d2), - getW(wF, wR, wC, inputDepthNearestVec4 + 1, d2), - getW(wF, wR, wC, inputDepthNearestVec4 + 2, d2) - ); - dotProd += dot(xValues, wValues); - } - } - } - } - setOutputAtIndex(index, dotProd); - } - }`; - return userCode; - } -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/conv_backprop_depthwise_webgpu.ts b/tfjs-master/tfjs-backend-webgpu/src/conv_backprop_depthwise_webgpu.ts deleted file mode 100644 index 7d3cf269f..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/conv_backprop_depthwise_webgpu.ts +++ /dev/null @@ -1,154 +0,0 @@ -/** - * @license - * Copyright 2023 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util} from '@tensorflow/tfjs-core'; -import {getMainHeaderString as main, WebGPUProgram} from './webgpu_program'; -import {computeDispatch, flatDispatchLayout} from './webgpu_util'; - -export class DepthwiseConv2DDerFilterProgram implements WebGPUProgram { - outputShape: number[]; - shaderKey: string; - dispatchLayout: {x: number[]}; - dispatch: [number, number, number]; - variableNames = ['x', 'dy']; - uniforms = - `strides : vec2, pads : vec2, filterDims : vec2, outHeight : i32, - outWidth : i32, inHeight : i32, inWidth : i32, batchSize : i32, channelMul : i32,`; - workgroupSize: [number, number, number] = [64, 1, 1]; - size = true; - - constructor(convInfo: backend_util.Conv2DInfo) { - this.outputShape = convInfo.filterShape; - - this.dispatchLayout = flatDispatchLayout(this.outputShape); - - this.dispatch = computeDispatch( - this.dispatchLayout, this.outputShape, this.workgroupSize); - - this.shaderKey = `depthwise_conv2d_backprop_filter`; - } - - getUserCode(): string { - const userCode = ` - ${main('index')} { - if (index < uniforms.size) { - let coords = getCoordsFromIndex(index); - let wR = coords[0]; - let wC = coords[1]; - let d1 = coords[2]; - let dm = coords[3]; - let d2 = d1 * uniforms.channelMul + dm; - - var dotProd = 0.0; - for (var b = 0; b < uniforms.batchSize; b++) { - for (var yR = 0; yR < uniforms.outHeight; yR++) { - let xR = wR + yR * uniforms.strides[0] - uniforms.pads[0]; - - if (xR < 0 || xR >= uniforms.inHeight) { - continue; - } - - for (var yC = 0; yC < uniforms.outWidth; yC++) { - let xC = wC + yC * uniforms.strides[1] - uniforms.pads[1]; - - if (xC < 0 || xC >= uniforms.inWidth) { - continue; - } - - let dyValue = getDy(b, yR, yC, d2); - let xValue = getX(b, xR, xC, d1); - dotProd += xValue * dyValue; - } - } - } - setOutputAtIndex(index, dotProd); - } - } - `; - return userCode; - } -} - -export class DepthwiseConv2DDerInputProgram implements WebGPUProgram { - outputShape: number[]; - shaderKey: string; - dispatchLayout: {x: number[]}; - dispatch: [number, number, number]; - variableNames = ['dy', 'W']; - uniforms = `strides : vec2, pads : vec2, filterDims : vec2, - outHeight : i32, outWidth : i32, channelMul : i32,`; - workgroupSize: [number, number, number] = [64, 1, 1]; - size = true; - - constructor(convInfo: backend_util.Conv2DInfo) { - this.outputShape = convInfo.inShape; - - this.dispatchLayout = flatDispatchLayout(this.outputShape); - - this.dispatch = computeDispatch( - this.dispatchLayout, this.outputShape, this.workgroupSize); - - this.shaderKey = `depthwise_conv2d_backprop_input`; - } - - getUserCode(): string { - const userCode = ` - ${main('index')} { - if (index < uniforms.size) { - let coords = getCoordsFromIndex(index); - let batch = coords[0]; - let d1 = coords[3]; - let dyCorner = coords.yz - uniforms.pads; - let dyRCorner = dyCorner.x; - let dyCCorner = dyCorner.y; - - var dotProd = 0.0; - for (var wR = 0; wR < uniforms.filterDims[0]; wR++) { - let dyR = f32(dyRCorner + wR) / f32(uniforms.strides[0]); - - if (dyR < 0.0 || dyR >= f32(uniforms.outHeight) || fract(dyR) > 0.0) { - continue; - } - - let idyR = i32(dyR); - let wRPerm = uniforms.filterDims[0] - 1 - wR; - - for (var wC = 0; wC < uniforms.filterDims[1]; wC++) { - let dyC = f32(dyCCorner + wC) / f32(uniforms.strides[1]); - - if (dyC < 0.0 || dyC >= f32(uniforms.outWidth) || fract(dyC) > 0.0) { - continue; - } - - let idyC = i32(dyC); - let wCPerm = uniforms.filterDims[1] - 1 - wC; - - for (var dm = 0; dm < uniforms.channelMul; dm++) { - let d2 = d1 * uniforms.channelMul + dm; - let xValue = getDy(batch, idyR, idyC, d2); - let wValue = getW(wRPerm, wCPerm, d1, dm); - dotProd += xValue * wValue; - } - } - } - setOutputAtIndex(index, dotProd); - } - } - `; - return userCode; - } -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/conv_backprop_mm_webgpu.ts b/tfjs-master/tfjs-backend-webgpu/src/conv_backprop_mm_webgpu.ts deleted file mode 100644 index 492449f59..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/conv_backprop_mm_webgpu.ts +++ /dev/null @@ -1,161 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, util} from '@tensorflow/tfjs-core'; - -import {makeMatMulPackedSource, makeMatMulPackedVec4Source} from './matmul_packed_webgpu'; -import {typeSnippet, WebGPUProgram} from './webgpu_program'; -import {computeDispatch, computeWorkgroupSizeForConv2d, computeWorkPerThreadForConv2d} from './webgpu_util'; - -function conv2dTransposeCommonSnippet(innerElementSize = 4) { - const getWSnippet = (innerElementSize: number) => { - switch (innerElementSize) { - case 1: - return 'return W[getIndexFromCoords4D(coord, uniforms.wShape)];'; - case 4: - return ` - let coord1 = vec4(coordX, coordY, col + 1, rowInner); - let coord2 = vec4(coordX, coordY, col + 2, rowInner); - let coord3 = vec4(coordX, coordY, col + 3, rowInner); - let v0 = W[getIndexFromCoords4D(coord, uniforms.wShape)]; - let v1 = W[getIndexFromCoords4D(coord1, uniforms.wShape)]; - let v2 = W[getIndexFromCoords4D(coord2, uniforms.wShape)]; - let v3 = W[getIndexFromCoords4D(coord3, uniforms.wShape)]; - return vec4(v0, v1, v2, v3); - `; - default: - throw new Error( - `innerElementSize ${innerElementSize} is not supported.`); - } - }; - - const readASnippet = ` - let outRow = row / uniforms.outShape[2]; - let outCol = row % uniforms.outShape[2]; - - let WRow = col / (uniforms.filterDims[1] * uniforms.outBackprop[3]); - let WCol = col / uniforms.outBackprop[3] % uniforms.filterDims[1]; - let xR = f32(outRow - uniforms.pads[0] + WRow) / f32(uniforms.strides[0]); - let xC = f32(outCol - uniforms.pads[1] + WCol) / f32(uniforms.strides[1]); - if (xR < 0.0 || xR >= f32(uniforms.outBackprop[1]) || fract(xR) > 0.0) { - return ${typeSnippet(innerElementSize)}(0.0); - } - if (xC < 0.0 || xC >= f32(uniforms.outBackprop[2]) || fract(xC) > 0.0) { - return ${typeSnippet(innerElementSize)}(0.0); - } - let coord = vec4( - batch, - i32(xR), - i32(xC), - col % uniforms.outBackprop[3]); - return x[getIndexFromCoords4D(coord, uniforms.xShape)/${ - innerElementSize}];`; - - const sampleA = `if (row < uniforms.dimAOuter && col < uniforms.dimInner) { - ${readASnippet} - } - return ${typeSnippet(innerElementSize)}(0.0);`; - - const userCode = ` - fn mm_readA(batch: i32, row : i32, col : i32) -> ${ - typeSnippet(innerElementSize)} { - ${sampleA} - } - - fn mm_readB(batch: i32, row : i32, col : i32) -> ${ - typeSnippet(innerElementSize)} { - let coordX = uniforms.filterDims.x - 1 - - row / (uniforms.filterDims[1] * uniforms.outBackprop[3]); - let coordY = uniforms.filterDims.y - 1 - - (row / uniforms.outBackprop[3]) % uniforms.filterDims[1]; - if (row < uniforms.dimInner && col < uniforms.dimBOuter && - coordX >= 0 && coordY >= 0) { - let rowInner = row % uniforms.outBackprop[3]; - let coord = vec4(coordX, coordY, col, rowInner); - ${getWSnippet(innerElementSize)} - } - return ${typeSnippet(innerElementSize)}(0.0); - } - - fn mm_write(batch: i32, row : i32, col : i32, valueInput : ${ - typeSnippet(innerElementSize)}) { - if (row < uniforms.dimAOuter && col < uniforms.dimBOuter) { - var value = valueInput; - let outCoord = vec4( - batch, - row / uniforms.outShape[2], - row % uniforms.outShape[2], - col); - result[getIndexFromCoords4D(outCoord, uniforms.outShape)/${ - innerElementSize}] = value; - } - }`; - return userCode; -} - -export class Conv2DDerInputMMProgram implements WebGPUProgram { - outputShape: number[]; - shaderKey: string; - dispatchLayout: {x: number[], y: number[], z: number[]}; - dispatch: [number, number, number]; - variableNames = ['x', 'W']; - variableComponents: number[]; - uniforms = - 'filterDims : vec2, pads : vec2, strides : vec2, outBackprop : vec4, dimAOuter : i32, dimBOuter : i32, dimInner : i32,'; - workgroupSize: [number, number, number]; - elementsPerThread: [number, number, number]; - isVec4?: boolean; - outputComponent: number; - - constructor(convInfo: backend_util.Conv2DInfo) { - this.outputShape = convInfo.inShape; - - util.assert( - convInfo.dataFormat === 'channelsLast', - () => 'TODO: NCHW is unimplemented'); - this.isVec4 = - convInfo.inChannels % 4 === 0 && convInfo.outChannels % 4 === 0; - this.dispatchLayout = {x: [3], y: [1, 2], z: [0]}; - this.workgroupSize = computeWorkgroupSizeForConv2d( - this.dispatchLayout, this.outputShape, this.isVec4); - this.elementsPerThread = computeWorkPerThreadForConv2d( - this.dispatchLayout, this.outputShape, this.isVec4); - - this.dispatch = computeDispatch( - this.dispatchLayout, this.outputShape, this.workgroupSize, - this.elementsPerThread); - - if (this.isVec4) { - this.outputComponent = 4; - this.variableComponents = [4, 1]; - } - - this.shaderKey = - `conv2DDerInputMM_${this.isVec4}_${this.elementsPerThread}`; - } - - getUserCode(): string { - const matMulSource = this.isVec4 ? - makeMatMulPackedVec4Source(this.elementsPerThread, this.workgroupSize) : - makeMatMulPackedSource(this.elementsPerThread, this.workgroupSize); - const userCode = ` - ${conv2dTransposeCommonSnippet(this.isVec4 ? 4 : 1)} - ${matMulSource} - `; - return userCode; - } -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/conv_backprop_webgpu.ts b/tfjs-master/tfjs-backend-webgpu/src/conv_backprop_webgpu.ts deleted file mode 100644 index 1257c2cbe..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/conv_backprop_webgpu.ts +++ /dev/null @@ -1,428 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util} from '@tensorflow/tfjs-core'; -import {getMainHeaderString as main, WebGPUProgram} from './webgpu_program'; -import {computeDispatch, flatDispatchLayout} from './webgpu_util'; - -export class Conv2DDerInputProgram implements WebGPUProgram { - variableNames = ['dy', 'W']; - uniforms = - 'filterDims : vec2, pads : vec2, strides : vec2, outBackprop : vec4,'; - outputShape: number[]; - shaderKey: string; - dispatchLayout: {x: number[], y?: number[], z?: number[]}; - dispatch: [number, number, number]; - workgroupSize: [number, number, number] = [64, 1, 1]; - isChannelsLast: boolean; - size = false; - isVec4 = false; - workPerThread = 1; - outputComponent: number; - - constructor(convInfo: backend_util.Conv2DInfo) { - this.outputShape = convInfo.inShape; - this.isChannelsLast = convInfo.dataFormat === 'channelsLast'; - this.isVec4 = this.isChannelsLast && convInfo.outChannels % 4 === 0 && - convInfo.inChannels % 4 === 0; - if (this.isVec4) { - // TODO: Expand to any value. - this.workPerThread = 2; - this.outputComponent = 4; - this.workgroupSize = [4, 4, 4]; - this.dispatchLayout = {x: [3], y: [2], z: [0, 1]}; - this.dispatch = computeDispatch( - this.dispatchLayout, this.outputShape, this.workgroupSize, - [4, this.workPerThread, 1]); - } else { - this.size = true; - this.workPerThread = 1; - this.workgroupSize = [64, 1, 1]; - this.dispatchLayout = flatDispatchLayout(this.outputShape); - this.dispatch = computeDispatch( - this.dispatchLayout, this.outputShape, this.workgroupSize); - } - this.shaderKey = `conv2DDerInput_${this.isChannelsLast}_${this.isVec4}_${ - this.workPerThread}`; - } - - getUserCode(): string { - const rowDim = this.isChannelsLast ? 1 : 2; - const colDim = this.isChannelsLast ? 2 : 3; - const channelDim = this.isChannelsLast ? 3 : 1; - - const vec4Snippet = ` - ${main()} { - let batch = i32(globalId.z) / uniforms.outShape[1]; - let r = i32(globalId.z) % uniforms.outShape[1]; - let c = i32(globalId.y) * ${this.workPerThread}; - let d1 = i32(globalId.x) * 4; - - let dyCorner = vec2(r, c) - uniforms.pads; - - // Convolve dy(?, ?, d2) with w(:, :, d1, d2) to compute dx(xR, xC, d1). - // ? = to be determined. : = across all values in that axis. - var dotProd: array, ${this.workPerThread}>; - for (var i = 0; i < ${this.workPerThread}; i++) { - dotProd[i] = vec4(0.0); - } - for (var wR = 0; wR < uniforms.filterDims.x; wR = wR + 1) { - let dyR = f32(dyCorner.x + wR) / f32(uniforms.strides.x); - let wRPerm = uniforms.filterDims.x - 1 - wR; - if (dyR < 0.0 || dyR >= f32(uniforms.outBackprop[1]) || - fract(dyR) > 0.0) { - continue; - } - let idyR = i32(dyR); - - for (var wC = 0; wC < uniforms.filterDims.y; wC = wC + 1) { - let dyC = f32(dyCorner.y + wC) / f32(uniforms.strides.y); - let dyC2 = f32(dyCorner.y + 1 + wC) / f32(uniforms.strides.y); - let wCPerm = uniforms.filterDims.y - 1 - wC; - var bDyCVal = true; - var bDyCVal2 = true; - if (dyC < 0.0 || dyC >= f32(uniforms.outBackprop[2]) || - fract(dyC) > 0.0) { - bDyCVal = false; - } - if (dyC2 < 0.0 || dyC2 >= f32(uniforms.outBackprop[2]) || - fract(dyC2) > 0.0) { - bDyCVal2 = false; - } - - let idyC = i32(dyC); - let idyC2 = i32(dyC2); - if (bDyCVal && bDyCVal2) { - let d2Length = uniforms.outBackprop[3]; - for (var d2 = 0; d2 < d2Length; d2 = d2 + 4) { - let wValue0 = getW(wRPerm, wCPerm, d1, d2); - let wValue1 = getW(wRPerm, wCPerm, d1 + 1, d2); - let wValue2 = getW(wRPerm, wCPerm, d1 + 2, d2); - let wValue3 = getW(wRPerm, wCPerm, d1 + 3, d2); - var xValue = getDy(batch, idyR, idyC, d2); - let tmpval = vec4(dot(xValue, wValue0), - dot(xValue, wValue1), - dot(xValue, wValue2), - dot(xValue, wValue3)); - dotProd[0] = dotProd[0] + tmpval; - xValue = getDy(batch, idyR, idyC2, d2); - dotProd[1] = dotProd[1] + vec4(dot(xValue, wValue0), - dot(xValue, wValue1), - dot(xValue, wValue2), - dot(xValue, wValue3)); - } - } else if (bDyCVal) { - let d2Length = uniforms.outBackprop[3]; - for (var d2 = 0; d2 < d2Length; d2 = d2 + 4) { - let wValue0 = getW(wRPerm, wCPerm, d1, d2); - let wValue1 = getW(wRPerm, wCPerm, d1 + 1, d2); - let wValue2 = getW(wRPerm, wCPerm, d1 + 2, d2); - let wValue3 = getW(wRPerm, wCPerm, d1 + 3, d2); - var xValue = getDy(batch, idyR, idyC, d2); - let tmpval = vec4(dot(xValue, wValue0), - dot(xValue, wValue1), - dot(xValue, wValue2), - dot(xValue, wValue3)); - dotProd[0] = dotProd[0] + tmpval; - } - } else if (bDyCVal2) { - let d2Length = uniforms.outBackprop[3]; - for (var d2 = 0; d2 < d2Length; d2 = d2 + 4) { - let wValue0 = getW(wRPerm, wCPerm, d1, d2); - let wValue1 = getW(wRPerm, wCPerm, d1 + 1, d2); - let wValue2 = getW(wRPerm, wCPerm, d1 + 2, d2); - let wValue3 = getW(wRPerm, wCPerm, d1 + 3, d2); - var xValue = getDy(batch, idyR, idyC2, d2); - let tmpval = vec4(dot(xValue, wValue0), - dot(xValue, wValue1), - dot(xValue, wValue2), - dot(xValue, wValue3)); - dotProd[1] = dotProd[1] + tmpval; - } - } - } - } - - for (var i = 0; i < ${this.workPerThread}; i = i + 1) { - let coords = vec4(batch, r, c + i, d1); - if (coordsInBounds4D(coords, uniforms.outShape)) { - setOutputAtCoords(coords[0], coords[1], coords[2], coords[3], dotProd[i]); - } - } - } - `; - return this.isVec4 ? - ` - ${vec4Snippet} - ` : - ` - ${main('index')} { - if(index < uniforms.size) { - let coords = getCoordsFromIndex(index); - let batch = coords[0]; - let d1 = coords[${channelDim}]; - - let dyCorner = vec2(coords[${rowDim}], coords[${ - colDim}]) - uniforms.pads; - let dyRCorner = dyCorner.x; - let dyCCorner = dyCorner.y; - - // Convolve dy(?, ?, d2) with w(:, :, d1, d2) to compute dx(xR, xC, d1). - // ? = to be determined. : = across all values in that axis. - var dotProd = 0.0; - for (var wR = 0; wR < uniforms.filterDims.x; wR = wR + 1) { - let dyR = (f32(dyRCorner) + f32(wR)) / f32(uniforms.strides.x); - let wRPerm = uniforms.filterDims.x - 1 - wR; - if (dyR < 0.0 || dyR >= f32(uniforms.outBackprop[1]) || fract(dyR) > 0.0 || - wRPerm < 0) { - continue; - } - let idyR = i32(dyR); - - for (var wC = 0; wC < uniforms.filterDims.y; wC = wC + 1) { - let dyC = (f32(dyCCorner) + f32(wC)) / f32(uniforms.strides.y); - let wCPerm = uniforms.filterDims.y - 1 - wC; - if (dyC < 0.0 || dyC >= f32(uniforms.outBackprop[2]) || - fract(dyC) > 0.0 || wCPerm < 0) { - continue; - } - let idyC = i32(dyC); - - for (var d2 = 0; d2 < uniforms.outBackprop[3]; d2 = d2 + 1) { - let xValue = ${ - this.isChannelsLast ? 'getDy(batch, idyR, idyC, d2)' : - 'getDy(batch, d2, idyR, idyC)'}; - let wValue = getW(wRPerm, wCPerm, d1, d2); - dotProd = dotProd + xValue * wValue; - } - } - } - setOutputAtIndex(index, dotProd); - } - } - `; - } -} - -export class Conv2DDerFilterProgram implements WebGPUProgram { - variableNames = ['x', 'dy']; - uniforms = - 'pads : vec2, strides : vec2, batchSize : i32, outHeight : i32, outWidth : i32, inHeight : i32, inWidth : i32,'; - outputShape: number[]; - shaderKey: string; - dispatchLayout: {x: number[]}; - dispatch: [number, number, number]; - workgroupSize: [number, number, number] = [64, 1, 1]; - isChannelsLast: boolean; - size = true; - - constructor(convInfo: backend_util.Conv2DInfo) { - this.outputShape = convInfo.filterShape; - this.dispatchLayout = flatDispatchLayout(this.outputShape); - this.dispatch = computeDispatch( - this.dispatchLayout, this.outputShape, this.workgroupSize); - this.isChannelsLast = convInfo.dataFormat === 'channelsLast'; - this.shaderKey = `conv2DDerFilter_${this.isChannelsLast}`; - } - - getUserCode(): string { - return ` - ${main('index')} { - if(index < uniforms.size) { - let coords = getCoordsFromIndex(index); - let wR = coords[0]; - let wC = coords[1]; - let d1 = coords[2]; - let d2 = coords[3]; - - // Convolve x(?, ?, d1) with dy(:, :, d2) to get dw(wR, wC, d1, d2). - // ? = to be determined. : = across all values in that axis. - var dotProd = 0.0; - for (var b = 0; b < uniforms.batchSize; b = b + 1) { - for (var yR = 0; yR < uniforms.outHeight; yR = yR + 1) { - let xR = wR + yR * uniforms.strides[0] - uniforms.pads[0]; - if (xR < 0 || xR >= uniforms.inHeight) { - continue; - } - - for (var yC = 0; yC < uniforms.outWidth; yC = yC + 1) { - let xC = wC + yC * uniforms.strides[1] - uniforms.pads[1]; - - if (xC < 0 || xC >= uniforms.inWidth) { - continue; - } - - if (${this.isChannelsLast}) { - let dyValue = getDy(b, yR, yC, d2); - let xValue = getX(b, xR, xC, d1); - dotProd = dotProd + xValue * dyValue; - } else { - let dyValue = getDy(b, d2, yR, yC); - let xValue = getX(b, d1, xR, xC); - dotProd = dotProd + xValue * dyValue; - } - } - } - } - setOutputAtIndex(index, dotProd); - } - } - `; - } -} - -export class Conv3DDerFilterProgram implements WebGPUProgram { - variableNames = ['x', 'dy']; - uniforms = - `pads : vec3, strides : vec3, batchSize : i32, outDepth : i32, - outHeight : i32, outWidth : i32, inDepth : i32, inHeight : i32, inWidth : i32,`; - outputShape: number[]; - shaderKey: string; - dispatchLayout: {x: number[]}; - dispatch: [number, number, number]; - workgroupSize: [number, number, number] = [64, 1, 1]; - size = true; - - constructor(convInfo: backend_util.Conv3DInfo) { - this.outputShape = convInfo.filterShape; - this.dispatchLayout = flatDispatchLayout(this.outputShape); - this.dispatch = computeDispatch( - this.dispatchLayout, this.outputShape, this.workgroupSize); - this.shaderKey = `conv3DDerFilter`; - } - - getUserCode(): string { - return ` - ${main('index')} { - if(index < uniforms.size) { - let coords = getCoordsFromIndex(index); - let wF = coords.x; - let wR = coords.y; - let wC = coords.z; - let d1 = coords.w; - let d2 = coords.u; - - var dotProd = 0.0; - for (var b = 0; b < uniforms.batchSize; b++) { - for (var yF = 0; yF < uniforms.outDepth; yF++) { - let xF = wF + yF * uniforms.strides[0] - uniforms.pads[0]; - if (xF < 0 || xF >= uniforms.inDepth) { - continue; - } - - for (var yR = 0; yR < uniforms.outHeight; yR++) { - let xR = wR + yR * uniforms.strides[1] - uniforms.pads[1]; - if (xR < 0 || xR >= uniforms.inHeight) { - continue; - } - - for (var yC = 0; yC < uniforms.outWidth; yC++) { - let xC = wC + yC * uniforms.strides[2] - uniforms.pads[2]; - if (xC < 0 || xC >= uniforms.inWidth) { - continue; - } - - let dyValue = getDy(b, yF, yR, yC, d2); - let xValue = getX(b, xF, xR, xC, d1); - dotProd += xValue * dyValue; - } - } - } - } - setOutputAtIndex(index, dotProd); - } - } - `; - } -} - -export class Conv3DDerInputProgram implements WebGPUProgram { - variableNames = ['dy', 'W']; - uniforms = `filterDims : vec3, pads : vec3, strides : vec3, - outDepth : i32, outHeight : i32, outWidth : i32, outChannels : i32,`; - outputShape: number[]; - shaderKey: string; - dispatchLayout: {x: number[]}; - dispatch: [number, number, number]; - workgroupSize: [number, number, number] = [64, 1, 1]; - size = true; - - constructor(convInfo: backend_util.Conv3DInfo) { - this.outputShape = convInfo.inShape; - this.dispatchLayout = flatDispatchLayout(this.outputShape); - this.dispatch = computeDispatch( - this.dispatchLayout, this.outputShape, this.workgroupSize); - this.shaderKey = `conv3DDerInput`; - } - - getUserCode(): string { - return ` - ${main('index')} { - if(index < uniforms.size) { - let coords = getCoordsFromIndex(index); - let batch = coords.x; - let d1 = coords.u; - - let dyCorner = vec3(coords.y, coords.z, coords.w) - uniforms.pads; - let dyFCorner = dyCorner.x; - let dyRCorner = dyCorner.y; - let dyCCorner = dyCorner.z; - - var dotProd = 0.0; - for (var wF = 0; wF < uniforms.filterDims[0]; wF++) { - let dyF = f32(dyFCorner + wF) / f32(uniforms.strides[0]); - if (dyF < 0.0 || dyF >= f32(uniforms.outDepth) || fract(dyF) > 0.0) { - continue; - } - let idyF = i32(dyF); - - let wFPerm = uniforms.filterDims[0] - 1 - wF; - - for (var wR = 0; wR < uniforms.filterDims[1]; wR++) { - let dyR = f32(dyRCorner + wR) / f32(uniforms.strides[1]); - - if (dyR < 0.0 || dyR >= f32(uniforms.outHeight) || fract(dyR) > 0.0) { - continue; - } - let idyR = i32(dyR); - - let wRPerm = uniforms.filterDims[1] - 1 - wR; - - for (var wC = 0; wC < uniforms.filterDims[2]; wC++) { - let dyC = f32(dyCCorner + wC) / f32(uniforms.strides[2]); - - if (dyC < 0.0 || dyC >= f32(uniforms.outWidth) || fract(dyC) > 0.0) { - continue; - } - let idyC = i32(dyC); - - let wCPerm = uniforms.filterDims[2] - 1 - wC; - - for (var d2 = 0; d2 < uniforms.outChannels; d2++) { - let xValue = getDy(batch, idyF, idyR, idyC, d2); - let wValue = getW(wFPerm, wRPerm, wCPerm, d1, d2); - dotProd += xValue * wValue; - } - } - } - } - setOutputAtIndex(index, dotProd); - } - } - `; - } -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/crop_and_resize_webgpu.ts b/tfjs-master/tfjs-backend-webgpu/src/crop_and_resize_webgpu.ts deleted file mode 100644 index 20a8276e4..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/crop_and_resize_webgpu.ts +++ /dev/null @@ -1,139 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {getMainHeaderString as main, WebGPUProgram} from './webgpu_program'; -import {computeDispatch, flatDispatchLayout} from './webgpu_util'; - -export class CropAndResizeProgram implements WebGPUProgram { - outputShape: number[]; - shaderKey: string; - dispatchLayout: {x: number[]}; - dispatch: [number, number, number]; - variableNames = ['Image', 'Boxes', 'BoxInd']; - uniforms = 'extrapolationValue : f32,'; - workgroupSize: [number, number, number] = [64, 1, 1]; - methodId: number; - cropHeightBiggerThan1: boolean; - cropWidthBiggerThan1: boolean; - size = true; - - constructor( - channnel: number, boxShape: [number, number], cropSize: [number, number], - method: 'bilinear'|'nearest') { - const [numBoxes, ] = boxShape; - this.outputShape = [numBoxes, cropSize[0], cropSize[1], channnel]; - this.dispatchLayout = flatDispatchLayout(this.outputShape); - this.dispatch = computeDispatch( - this.dispatchLayout, this.outputShape, this.workgroupSize); - - this.methodId = method === 'bilinear' ? 1 : 0; - this.cropHeightBiggerThan1 = this.outputShape[1] > 1; - this.cropWidthBiggerThan1 = this.outputShape[2] > 1; - this.shaderKey = `cropAndResize_${this.methodId}_${ - this.cropHeightBiggerThan1}_${this.cropWidthBiggerThan1}`; - } - - getUserCode(): string { - const [inputHeightFloat, inputWidthFloat] = - [`f32(uniforms.imageShape[1] - 1)`, `f32(uniforms.imageShape[2] - 1)`]; - - const [heightRatio, heightScale, inY] = this.cropHeightBiggerThan1 ? - [ - `(${inputHeightFloat} / f32(uniforms.outShape[1] - 1))`, - '(y2-y1) * height_ratio', - `y1*${inputHeightFloat} + f32(y)*(height_scale)`, - ] : - [ - '0.0', - '0.0', - `0.5 * (y1+y2) * ${inputHeightFloat}`, - ]; - const [widthRatio, widthScale, inX] = this.cropWidthBiggerThan1 ? - [ - `(${inputWidthFloat} / f32(uniforms.outShape[2] - 1))`, - '(x2-x1) * width_ratio', - `x1*${inputWidthFloat} + f32(x)*(width_scale)`, - ] : - [ - '0.0', - '0.0', - `0.5 * (x1+x2) * ${inputWidthFloat}`, - ]; - - // Reference implementation - // tslint:disable-next-line:max-line-length - // https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/kernels/crop_and_resize_op_gpu.cu.cc - const userCode = ` - ${main('index')} { - if (index < uniforms.size) { - let coords = getCoordsFromIndex(index); - let height_ratio = f32(${heightRatio}); - let width_ratio = f32(${widthRatio}); - let b = coords[0]; - let y = coords[1]; - let x = coords[2]; - let d = coords[3]; - // get box vals - let y1 = getBoxes(b, 0); - let x1 = getBoxes(b, 1); - let y2 = getBoxes(b, 2); - let x2 = getBoxes(b, 3); - // get image in batch index - let bInd = i32(round(getBoxInd(b))); - if(bInd < 0 || bInd >= uniforms.outShape[0]) { - return; - } - let height_scale = ${heightScale}; - let width_scale = ${widthScale}; - let in_y = ${inY}; - if( in_y < 0.0 || in_y > ${inputHeightFloat} ) { - setOutputAtIndex(index, uniforms.extrapolationValue); - return; - } - let in_x = ${inX}; - if( in_x < 0.0 || in_x > ${inputWidthFloat} ) { - setOutputAtIndex(index, uniforms.extrapolationValue); - return; - } - let sourceFracIndexCR = vec2(in_x,in_y); - if(${this.methodId} == 1) { - // Compute the four integer indices. - let sourceFloorCR = vec2(sourceFracIndexCR); - let sourceCeilCR = vec2(ceil(sourceFracIndexCR)); - let topLeft = getImage(bInd, sourceFloorCR.y, sourceFloorCR.x, d); - let bottomLeft = getImage(bInd, sourceCeilCR.y, sourceFloorCR.x, d); - let topRight = getImage(bInd, sourceFloorCR.y, sourceCeilCR.x, d); - let bottomRight = getImage(bInd, sourceCeilCR.y, sourceCeilCR.x, d); - let fracCR = sourceFracIndexCR - vec2(sourceFloorCR); - let top = topLeft + (topRight - topLeft) * fracCR.x; - let bottom = bottomLeft + (bottomRight - bottomLeft) * fracCR.x; - let newValue = top + (bottom - top) * fracCR.y; - setOutputAtIndex(index, newValue); - } else { - // Compute the coordinators of nearest neighbor point. - let sourceNearestCR = vec2(floor( - sourceFracIndexCR + vec2(0.5,0.5))); - let newValue = getImage( - bInd, sourceNearestCR.y, sourceNearestCR.x, d); - setOutputAtIndex(index, newValue); - } - } - } - `; - return userCode; - } -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/cum_webgpu.ts b/tfjs-master/tfjs-backend-webgpu/src/cum_webgpu.ts deleted file mode 100644 index a7362f5a0..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/cum_webgpu.ts +++ /dev/null @@ -1,117 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {getMainHeaderString as main, WebGPUProgram} from './webgpu_program'; -import {computeDispatch, flatDispatchLayout} from './webgpu_util'; - -export enum CumOpType { - Prod = '*', - Sum = '+', -} - -export class CumProgram implements WebGPUProgram { - outputShape: number[]; - shaderKey: string; - dispatchLayout: {x: number[]}; - dispatch: [number, number, number]; - variableNames = ['x']; - workgroupSize: [number, number, number]; - // pow(i32, i32) is not supported, use pow(f32, f32) instead. - uniforms = 'index : f32,'; - size = true; - exclusive: boolean; - reverse: boolean; - op: CumOpType; - - constructor( - op: CumOpType, shape: number[], exclusive: boolean, reverse: boolean) { - this.workgroupSize = [128, 1, 1]; - this.outputShape = shape; - this.dispatchLayout = flatDispatchLayout(this.outputShape); - this.dispatch = computeDispatch( - this.dispatchLayout, this.outputShape, this.workgroupSize); - this.exclusive = exclusive; - this.reverse = reverse; - this.op = op; - this.shaderKey = `cum_${this.op}_${this.exclusive}_${this.reverse}`; - } - - getUserCode(): string { - const rank = this.outputShape.length; - const initVal = this.op === CumOpType.Prod ? '1.0' : '0.0'; - const val = this.exclusive ? initVal : - `getX(${getCoords(rank, 'coords', this.op)})`; - const length = this.outputShape[this.outputShape.length - 1]; - let condition = ''; - let idxString = ''; - // When exclusive is set, the cum op becomes roll op that copies the - // value from the previous index based on the direction specified by the - // reverse flag. - if (this.exclusive) { - condition = this.reverse ? `end != ${length - 1}` : 'end != 0'; - idxString = this.reverse ? 'end + 1' : 'end - 1'; - } else { - condition = this.reverse ? `end + pow2 < ${length}` : 'end >= pow2'; - idxString = (this.reverse ? 'end + pow2' : 'end - pow2'); - } - return ` - ${main('index')} { - if (index < uniforms.size) { - var coords = getCoordsFromIndex(index); - - let end = ${getFinalCoord(rank, 'coords', this.op)}; - var val = ${val}; - let pow2 = i32(pow(2.0, uniforms.index)); - if (${condition}) { - let idx = ${idxString}; - ${getFinalCoord(rank, 'coords', this.op)} = idx; - val ${this.op}= getX(${getCoords(rank, 'coords', this.op)}); - } - setOutputAtIndex(index, val); - } - } - `; - } -} - -function getCoords(rank: number, name: string, op: CumOpType): string { - if (rank === 1) { - return `${name}`; - } else if (rank === 2) { - return `${name}.x, ${name}.y`; - } else if (rank === 3) { - return `${name}.x, ${name}.y, ${name}.z`; - } else if (rank === 4) { - return `${name}.x, ${name}.y, ${name}.z, ${name}.w`; - } else { - throw Error(`Cumulative ${op} for rank ${rank} is not yet supported`); - } -} - -function getFinalCoord(rank: number, name: string, op: CumOpType): string { - if (rank === 1) { - return `${name}`; - } else if (rank === 2) { - return `${name}.y`; - } else if (rank === 3) { - return `${name}.z`; - } else if (rank === 4) { - return `${name}.w`; - } else { - throw Error(`Cumulative ${op} for rank ${rank} is not yet supported`); - } -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/depth_to_space_webgpu.ts b/tfjs-master/tfjs-backend-webgpu/src/depth_to_space_webgpu.ts deleted file mode 100644 index cb9c9bbb6..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/depth_to_space_webgpu.ts +++ /dev/null @@ -1,105 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {getMainHeaderString as main, WebGPUProgram} from './webgpu_program'; -import {computeDispatch, flatDispatchLayout} from './webgpu_util'; - -export class DepthToSpaceProgram implements WebGPUProgram { - variableNames = ['x']; - outputShape: number[]; - dataFormat: string; - shaderKey: string; - dispatchLayout: {x: number[]}; - dispatch: [number, number, number]; - workgroupSize: [number, number, number] = [64, 1, 1]; - size = true; - uniforms = 'blockSize : i32,'; - - constructor(outputShape: number[], dataFormat: 'NHWC'|'NCHW') { - this.outputShape = outputShape; - this.dispatchLayout = flatDispatchLayout(this.outputShape); - this.dispatch = computeDispatch( - this.dispatchLayout, this.outputShape, this.workgroupSize); - this.shaderKey = `depthToSpace_${dataFormat}`; - this.dataFormat = dataFormat; - } - - getUserCode(): string { - const userCode = ` - ${main('index')} { - if (index < uniforms.size) { - let coords = getCoordsFromIndex(index); - let b = coords[0]; - let h = ${this.getHeightCoordString()}; - let w = ${this.getWidthCoordString()}; - let d = ${this.getDepthCoordString()}; - - let in_h = h / uniforms.blockSize; - let offset_h = h % uniforms.blockSize; - let in_w = w / uniforms.blockSize; - let offset_w = w % uniforms.blockSize; - let offset_d = (offset_h * uniforms.blockSize + offset_w) * - ${this.getOutputDepthSize()}; - let in_d = d + offset_d; - - let rlt = ${this.getInputSamplingString()}; - setOutputAtIndex(index, rlt); - } - }`; - return userCode; - } - - private getHeightCoordString(): string { - if (this.dataFormat === 'NHWC') { - return `coords[1]`; - } else { - return `coords[2]`; - } - } - - private getWidthCoordString(): string { - if (this.dataFormat === 'NHWC') { - return `coords[2]`; - } else { - return `coords[3]`; - } - } - - private getDepthCoordString(): string { - if (this.dataFormat === 'NHWC') { - return `coords[3]`; - } else { - return `coords[1]`; - } - } - - private getOutputDepthSize(): string { - if (this.dataFormat === 'NHWC') { - return `uniforms.outShape[3]`; - } else { - return `uniforms.outShape[1]`; - } - } - - private getInputSamplingString(): string { - if (this.dataFormat === 'NHWC') { - return `getX(b, in_h, in_w, in_d)`; - } else { - return `getX(b, in_d, in_h, in_w)`; - } - } -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/depthwise_conv2d_nchw_shared_webgpu.ts b/tfjs-master/tfjs-backend-webgpu/src/depthwise_conv2d_nchw_shared_webgpu.ts deleted file mode 100644 index ef1df6ea8..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/depthwise_conv2d_nchw_shared_webgpu.ts +++ /dev/null @@ -1,142 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util} from '@tensorflow/tfjs-core'; - -import {activationFnSnippet, biasActivationSnippet} from './activation_util'; -import {getMainHeaderString as main, WebGPUProgram} from './webgpu_program'; -import {computeDispatch} from './webgpu_util'; - -export class DepthwiseConv2DNCHWSharedProgram implements WebGPUProgram { - outputShape: number[]; - shaderKey: string; - dispatchLayout: {x: number[], y: number[], z: number[]}; - dispatch: [number, number, number]; - variableNames = ['x', 'W']; - uniforms = `pads : vec2, inDims : vec2,`; - workgroupSize: [number, number, number] = [16, 16, 1]; - addBias: boolean; - activation: backend_util.Activation; - hasPreluActivation: boolean; - filterHeight: number; - filterWidth: number; - - constructor( - outputShape: number[], filterHeight: number, filterWidth: number, - addBias = false, activation: backend_util.Activation = null, - hasPreluActivation = false) { - this.outputShape = outputShape; - this.dispatchLayout = {x: [3], y: [2], z: [0, 1]}; - this.dispatch = computeDispatch( - this.dispatchLayout, this.outputShape, this.workgroupSize); - - if (addBias) { - this.variableNames.push('bias'); - } - if (hasPreluActivation) { - this.variableNames.push('preluActivationWeights'); - } - - this.addBias = addBias; - this.activation = activation; - this.hasPreluActivation = hasPreluActivation; - this.filterHeight = filterHeight; - this.filterWidth = filterWidth; - this.shaderKey = `depthwiseNCHW_${this.activation}_${this.filterHeight}_${ - this.filterWidth}`; - } - - getUserCode(): string { - const filterSize = this.filterWidth * this.filterHeight; - const flatWorkgroupSize = - this.workgroupSize[0] * this.workgroupSize[1] * this.workgroupSize[2]; - const tileAHeight = this.workgroupSize[1] + this.filterHeight - 1; - const tileAWidth = this.workgroupSize[0] + this.filterWidth - 1; - - const userCode = ` - ${activationFnSnippet(this.activation, this.hasPreluActivation, false, 4)} - - var mm_Asub : array, ${tileAHeight}>; - var mm_Bsub : array, ${ - this.filterHeight}>; - fn readX(batch : i32, channel : i32, row : i32, col : i32) -> f32 { - var value = 0.0; - if (row >=0 && row < uniforms.inDims[0] && col >=0 && col < uniforms.inDims[1]) - { - value = getX(batch, channel, row, col); - } - return value; - } - - ${main()} { - let coords = getOutputCoords(); - let batch = coords[0]; - let xRCCorner = vec2(coords.zw) - uniforms.pads; - let channelMul = uniforms.wShape[3]; - let d1 = coords[1] / channelMul; - let q = coords[1] % channelMul; - - let inputRowStart = xRCCorner.x; - let inputColStart = xRCCorner.y; - - let localRow = i32(localId.y); - let localCol = i32(localId.x); - - // Load one tile of X into local memory. - for (var inputRow = localRow; inputRow < ${ - tileAHeight}; inputRow = inputRow + ${this.workgroupSize[1]}) { - for (var inputCol = localCol; inputCol < ${ - tileAWidth}; inputCol = inputCol + ${this.workgroupSize[0]}) { - let rowOffset = inputRow - localRow; - let colOffset = inputCol - localCol; - mm_Asub[inputRow][inputCol] = readX(batch, d1, inputRowStart + rowOffset, inputColStart + colOffset); - } - } - - // Load one tile of W into local memory. - var wIndex = i32(localIndex); - ${ - filterSize < flatWorkgroupSize ? - `if (wIndex < ${filterSize})` : - `for(; wIndex < ${filterSize}; wIndex = wIndex + ${ - flatWorkgroupSize})`} - - { - let wRow = wIndex / ${this.filterWidth}; - let wCol = wIndex % ${this.filterWidth}; - mm_Bsub[wRow][wCol] = getW(wRow, wCol, d1, q); - } - - workgroupBarrier(); - - var value = 0.0; - for (var wR = 0; wR < ${this.filterHeight}; wR = wR + 1) { - for (var wC = 0; wC < ${this.filterWidth}; wC = wC + 1) { - let xVal = mm_Asub[localRow + wR][localCol + wC]; - let wVal = mm_Bsub[wR][wC]; - value = fma(xVal, wVal, value); - } - } - ${biasActivationSnippet(this.addBias, this.activation)} - if (coordsInBounds4D(coords, uniforms.outShape)) { - setOutputAtCoords(coords[0], coords[1], coords[2], coords[3], value); - } - } - `; - return userCode; - } -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/depthwise_conv2d_vec4_webgpu.ts b/tfjs-master/tfjs-backend-webgpu/src/depthwise_conv2d_vec4_webgpu.ts deleted file mode 100644 index 70ed0645b..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/depthwise_conv2d_vec4_webgpu.ts +++ /dev/null @@ -1,143 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, util} from '@tensorflow/tfjs-core'; -import {activationFnSnippet, biasActivationSnippet} from './activation_util'; -import {getMainHeaderString as main, WebGPUProgram} from './webgpu_program'; -import {computeDispatch, flatDispatchLayout} from './webgpu_util'; - -export class DepthwiseConv2DVec4Program implements WebGPUProgram { - outputShape: number[]; - shaderKey: string; - dispatchLayout: {x: number[]}; - dispatch: [number, number, number]; - variableNames = ['x', 'W']; - uniforms = 'pads : vec2, inDims : vec2, virtualWidth : i32,'; - workgroupSize: [number, number, number] = [64, 1, 1]; - workPerThread = 4; - convInfo: backend_util.Conv2DInfo; - addBias: boolean; - activation: backend_util.Activation; - hasPreluActivation: boolean; - outputComponent = 4; - virtualWidth: number; - - constructor( - convInfo: backend_util.Conv2DInfo, addBias = false, - activation: backend_util.Activation = null, hasPreluActivation = false) { - this.outputShape = convInfo.outShape; - this.virtualWidth = Math.ceil(this.outputShape[2] / this.workPerThread) * - this.workPerThread; - const virtualOutputShape = [ - this.outputShape[0], this.outputShape[1], this.virtualWidth, - this.outputShape[3] - ]; - this.dispatchLayout = flatDispatchLayout(virtualOutputShape); - - this.dispatch = computeDispatch( - this.dispatchLayout, virtualOutputShape, this.workgroupSize, - [this.outputComponent * this.workPerThread, 1, 1]); - - util.assert( - convInfo.dataFormat === 'channelsLast', - () => 'TODO: NCHW is unimplemented'); - - if (addBias) { - this.variableNames.push('bias'); - } - if (hasPreluActivation) { - this.variableNames.push('preluActivationWeights'); - } - - this.convInfo = convInfo; - this.addBias = addBias; - this.activation = activation; - this.hasPreluActivation = hasPreluActivation; - - this.shaderKey = - `depthwiseVec4_${activation}_${this.convInfo.filterHeight}_${ - this.convInfo.filterWidth}_${this.convInfo.strideHeight}_${ - this.convInfo.strideWidth}_${this.workPerThread}`; - } - - getUserCode(): string { - const xNumber = (this.workPerThread - 1) * this.convInfo.strideWidth + - this.convInfo.filterWidth; - const strideHeight = this.convInfo.strideHeight; - const strideWidth = this.convInfo.strideWidth; - - const userCode = ` - ${activationFnSnippet(this.activation, this.hasPreluActivation, true, 4)} - fn readX(batch : i32, row : i32, col : i32, channel : i32) -> vec4 { - var value = vec4(0.0); - if (col >=0 && col < uniforms.inDims[1]) { - value = getX(batch, row, col, channel); - } - return value; - } - - ${main('index')} { - let width0 = uniforms.outShape[3] / ${this.outputComponent}; - let d1 = (index % width0) * ${this.outputComponent}; - var index1 = index / width0; - let width1 = uniforms.virtualWidth / ${this.workPerThread}; - let c = (index1 % width1) * ${this.workPerThread}; - index1 = index1 / width1; - let r = index1 % uniforms.outShape[1]; - let batch = index1 / uniforms.outShape[1]; - - let xRCCorner = vec2(r, c) * vec2(${strideHeight}, ${ - strideWidth}) - uniforms.pads; - - let xRCorner = xRCCorner.x; - let xCCorner = xRCCorner.y; - var xVals : array, ${xNumber}>; - var dotProd : array, ${this.workPerThread}>; - for (var i = 0; i < ${this.workPerThread}; i++) { - dotProd[i] = vec4(0.0); - } - - // Use constant instead of uniform can give better performance. - for (var wR = 0; wR < ${this.convInfo.filterHeight}; wR = wR + 1) { - let xR = xRCorner + wR; - if (xR >=0 && xR < uniforms.inDims[0]) { - for (var i = 0; i < ${xNumber}; i++) { - xVals[i] = readX(batch, xR, xCCorner + i, d1); - } - for (var wC = 0; wC < ${this.convInfo.filterWidth}; wC = wC + 1) { - let wValue = getW(wR, wC, d1, 0); - for (var i = 0; i < ${this.workPerThread}; i++) { - dotProd[i] = fma(xVals[i * ${ - strideWidth} + wC], wValue, dotProd[i]); - } - } - } - } - - for (var i = 0; i < ${this.workPerThread}; i = i + 1) { - let coords = vec4(batch, r, c + i, d1); - if (coordsInBounds4D(coords, uniforms.outShape)) { - var value = dotProd[i]; - ${biasActivationSnippet(this.addBias, this.activation)} - setOutputAtCoords(coords[0], coords[1], coords[2], coords[3], value); - } - } - } - `; - return userCode; - } -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/depthwise_conv2d_webgpu.ts b/tfjs-master/tfjs-backend-webgpu/src/depthwise_conv2d_webgpu.ts deleted file mode 100644 index 6325962e8..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/depthwise_conv2d_webgpu.ts +++ /dev/null @@ -1,138 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util} from '@tensorflow/tfjs-core'; - -import {activationFnSnippet, biasActivationSnippet} from './activation_util'; -import {getMainHeaderString as main, WebGPUProgram} from './webgpu_program'; -import {computeDispatch, flatDispatchLayout} from './webgpu_util'; - -export class DepthwiseConv2DProgram implements WebGPUProgram { - outputShape: number[]; - shaderKey: string; - dispatchLayout: {x: number[], y?: number[], z?: number[]}; - dispatch: [number, number, number]; - variableNames = ['x', 'W']; - uniforms = `pads : vec2, inDims : vec2, filterHeight : i32, - filterWidth : i32, strides : vec2, dilations : vec2,`; - // This is an experimental value. - workgroupSize: [number, number, number] = [256, 1, 1]; - convInfo: backend_util.Conv2DInfo; - addBias: boolean; - activation: backend_util.Activation; - hasPreluActivation: boolean; - isChannelsLast: boolean; - size = true; - - constructor( - convInfo: backend_util.Conv2DInfo, addBias = false, - activation: backend_util.Activation = null, hasPreluActivation = false) { - this.outputShape = convInfo.outShape; - this.dispatchLayout = flatDispatchLayout(this.outputShape); - this.dispatch = computeDispatch( - this.dispatchLayout, this.outputShape, this.workgroupSize); - this.isChannelsLast = convInfo.dataFormat === 'channelsLast'; - - if (addBias) { - this.variableNames.push('bias'); - } - if (hasPreluActivation) { - this.variableNames.push('preluActivationWeights'); - } - - this.convInfo = convInfo; - this.addBias = addBias; - this.activation = activation; - this.hasPreluActivation = hasPreluActivation; - this.shaderKey = `depthwise_${this.activation}_${this.isChannelsLast}`; - } - - getUserCode(): string { - const getXSnippet = this.isChannelsLast ? 'getX(batch, xR, xC, d1);' : - 'getX(batch, d1, xR, xC);'; - - const userCode = ` - ${activationFnSnippet(this.activation, this.hasPreluActivation, false, 4)} - - ${main('index')} { - if (index < uniforms.size) { - let coords = getOutputCoords(); - let batch = coords[0]; - let xRCCorner = vec2(coords.${ - this.isChannelsLast ? 'yz' : 'zw'}) * uniforms.strides - uniforms.pads; - let d2 = coords[${this.isChannelsLast ? 3 : 1}]; - let channelMul = uniforms.wShape[3]; - let d1 = d2 / channelMul; - let q = d2 % channelMul; - - let inputRowStart = xRCCorner.x; - let inputColStart = xRCCorner.y; - let inputRowEnd = inputRowStart + uniforms.filterHeight * - uniforms.dilations[0]; - let inputColEnd = inputColStart + uniforms.filterWidth * - uniforms.dilations[1]; - - // Convolve x(?, ?, d1)|x(d1, ?, ?) with w(:, :, d1, q) to get - // y(yR, yC, d2)|y(d2, yR, yC). ? = to be determined. : = across all - // values in that axis. x(?, ?, d1) and y(yR, yC, d2) is for NHWC. - // x(d1, ?, ?) and y(d2, yR, yC) is for NCHW. - var value = 0.0; - - // Extract if checking out of for loop for performance. - if (inputRowStart >= 0 && inputColStart >= 0 && - inputRowEnd < uniforms.inDims[0] && - inputColEnd < uniforms.inDims[1]) { - for (var wR = 0; wR < uniforms.filterHeight; wR = wR + 1) { - let xR = inputRowStart + wR * uniforms.dilations[0]; - - for (var wC = 0; wC < uniforms.filterWidth; wC = wC + 1) { - let xC = inputColStart + wC * uniforms.dilations[1]; - - let xVal = ${getXSnippet}; - let wVal = getW(wR, wC, d1, q); - value = value + xVal * wVal; - } - } - } else { - for (var wR = 0; wR < uniforms.filterHeight; wR = wR + 1) { - let xR = inputRowStart + wR * uniforms.dilations[0]; - - if (xR < 0 || xR >= uniforms.inDims[0]) { - continue; - } - - for (var wC = 0; wC < uniforms.filterWidth; wC = wC + 1) { - let xC = inputColStart + wC * uniforms.dilations[1]; - - if (xC < 0 || xC >= uniforms.inDims[1]) { - continue; - } - - let xVal = ${getXSnippet}; - let wVal = getW(wR, wC, d1, q); - value = value + xVal * wVal; - } - } - } - ${biasActivationSnippet(this.addBias, this.activation)} - setOutputAtCoords(coords[0], coords[1], coords[2], coords[3], value); - } - } - `; - return userCode; - } -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/diag_webgpu.ts b/tfjs-master/tfjs-backend-webgpu/src/diag_webgpu.ts deleted file mode 100644 index 2896967e1..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/diag_webgpu.ts +++ /dev/null @@ -1,51 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {getMainHeaderString as main, WebGPUProgram} from './webgpu_program'; -import {computeDispatch, flatDispatchLayout} from './webgpu_util'; - -export class DiagProgram implements WebGPUProgram { - outputShape: number[]; - shaderKey: string; - dispatchLayout: {x: number[]}; - dispatch: [number, number, number]; - variableNames = ['x']; - workgroupSize: [number, number, number] = [64, 1, 1]; - size = true; - - constructor(size: number) { - this.outputShape = [size, size]; - this.dispatchLayout = flatDispatchLayout(this.outputShape); - this.dispatch = computeDispatch( - this.dispatchLayout, this.outputShape, this.workgroupSize); - - this.shaderKey = 'diag'; - } - - getUserCode(): string { - const userCode = ` - ${main('index')} { - if (index < uniforms.size) { - let coords = getOutputCoords(); - let value = select(0.0, getX(coords[0]), coords[0] == coords[1]); - setOutputAtIndex(index, value); - } - } - `; - return userCode; - } -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/dilation_backprop_webgpu.ts b/tfjs-master/tfjs-backend-webgpu/src/dilation_backprop_webgpu.ts deleted file mode 100644 index 8fc61f88c..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/dilation_backprop_webgpu.ts +++ /dev/null @@ -1,181 +0,0 @@ -/** - * @license - * Copyright 2023 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, DataType} from '@tensorflow/tfjs-core'; - -import {atomicAddSnippet} from './shader_util'; -import {getMainHeaderString as main, WebGPUProgram} from './webgpu_program'; -import {computeDispatch, flatDispatchLayout} from './webgpu_util'; - -export class Dilation2DBackpropInputProgram implements WebGPUProgram { - outputShape: number[]; - shaderKey: string; - dispatchLayout: {x: number[]}; - dispatch: [number, number, number]; - variableNames = ['x', 'w', 'dy']; - uniforms = - 'filterDims: vec2, pads: vec2, strides: vec2, dilations: vec2, dySize: i32,'; - workgroupSize: [number, number, number] = [64, 1, 1]; - atomic = true; - type: DataType; - - constructor(convInfo: backend_util.Conv2DInfo, outputDtype: DataType) { - this.outputShape = convInfo.inShape; - this.dispatchLayout = flatDispatchLayout(convInfo.outShape); - this.dispatch = computeDispatch( - this.dispatchLayout, convInfo.outShape, this.workgroupSize); - - if (outputDtype !== 'float32' && outputDtype !== 'int32') { - throw new Error(`Dilation2DBackpropInput only supports float32 and int32 - types, does not support ${outputDtype} type.`); - } - this.type = outputDtype; - this.shaderKey = 'dilation2DBackpropInput'; - } - - getUserCode(): string { - // This implementation follows the TF c++ cuda implementation: - // https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/kernels/dilation_ops_gpu.cu.cc - const userCode = ` - ${main('index')} { - if (index < uniforms.dySize) { - let coords = getDyCoordsFromIndex(index); - let b = coords[0]; - let r = coords[1]; - let c = coords[2]; - let d = coords[3]; - - let dyCorner = vec2(r, c) * uniforms.strides - uniforms.pads; - var curVal = -3.4e38; // neg_infinity - var xRMax = 0; - var xCMax = 0; - - // In the case of multiple argmax branches, we only back-propagate - // along the last branch, i.e., the one with largest value of - // 'wR * uniforms.filterDims[1] + wC', similarly to the max-pooling - // backward routines. - for (var wR = 0; wR < uniforms.filterDims[0]; wR++) { - let xR = dyCorner.x + wR * uniforms.dilations[0]; - - if (xR >= 0 && xR < uniforms.xShape[1]) { - for (var wC = 0; wC < uniforms.filterDims[1]; wC++) { - let xC = dyCorner.y + wC * uniforms.dilations[1]; - - if (xC >= 0 && xC < uniforms.xShape[2]) { - let val = getX(b, xR, xC, d) + getW(wR, wC, d); - if (val > curVal) { - curVal = val; - xRMax = xR; - xCMax = xC; - } - } - } - } - } - - let flatIndexIn = d + uniforms.xShape[3] * - (xCMax + uniforms.xShape[2] * (xRMax + uniforms.xShape[1] * b)); - let value = getDy(b, r, c, d); - ${ - atomicAddSnippet( - '&result[flatIndexIn]', 'value', this.type as 'float32' | 'int32')} - } - } - `; - return userCode; - } -} - -export class Dilation2DBackpropFilterProgram implements WebGPUProgram { - outputShape: number[]; - shaderKey: string; - dispatchLayout: {x: number[]}; - dispatch: [number, number, number]; - variableNames = ['x', 'w', 'dy']; - uniforms = - 'filterDims: vec2, pads: vec2, strides: vec2, dilations: vec2, dySize: i32,'; - workgroupSize: [number, number, number] = [64, 1, 1]; - atomic = true; - type: DataType; - - constructor( - convInfo: backend_util.Conv2DInfo, shape: number[], - outputDtype: DataType) { - this.outputShape = convInfo.filterShape; - this.dispatchLayout = flatDispatchLayout(convInfo.outShape); - this.dispatch = computeDispatch( - this.dispatchLayout, convInfo.outShape, this.workgroupSize); - - if (outputDtype !== 'float32' && outputDtype !== 'int32') { - throw new Error(`Dilation2DBackpropFilter only supports float32 and int32 - types, does not support ${outputDtype} type.`); - } - this.type = outputDtype; - this.shaderKey = 'dilation2DBackpropFilter'; - } - - getUserCode(): string { - // This implementation follows the TF c++ cuda implementation: - // https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/kernels/dilation_ops_gpu.cu.cc - const userCode = ` - ${main('index')} { - if (index < uniforms.dySize) { - let coords = getDyCoordsFromIndex(index); - let b = coords[0]; - let r = coords[1]; - let c = coords[2]; - let d = coords[3]; - - let dyCorner = vec2(r, c) * uniforms.strides - uniforms.pads; - var curVal = -3.4e38; // neg_infinity - var wRMax = 0; - var wCMax = 0; - - // In the case of multiple argmax branches, we only back-propagate - // along the last branch, i.e., the one with largest value of - // 'wR * uniforms.filterDims[1] + wC', similarly to the max-pooling - // backward routines. - for (var wR = 0; wR < uniforms.filterDims[0]; wR++) { - let xR = dyCorner.x + wR * uniforms.dilations[0]; - - if (xR >= 0 && xR < uniforms.xShape[1]) { - for (var wC = 0; wC < uniforms.filterDims[1]; wC++) { - let xC = dyCorner.y + wC * uniforms.dilations[1]; - - if (xC >= 0 && xC < uniforms.xShape[2]) { - let val = getX(b, xR, xC, d) + getW(wR, wC, d); - if (val > curVal) { - curVal = val; - wRMax = wR; - wCMax = wC; - } - } - } - } - } - - let flatIndexIn = d + uniforms.wShape[2] * (wCMax + wRMax * uniforms.wShape[1]); - let value = getDy(b, r, c, d); - ${ - atomicAddSnippet( - '&result[flatIndexIn]', 'value', this.type as 'float32' | 'int32')} - } - } - `; - return userCode; - } -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/dilation_webgpu.ts b/tfjs-master/tfjs-backend-webgpu/src/dilation_webgpu.ts deleted file mode 100644 index fd46bbd5b..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/dilation_webgpu.ts +++ /dev/null @@ -1,79 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util} from '@tensorflow/tfjs-core'; - -import {getMainHeaderString as main, WebGPUProgram} from './webgpu_program'; -import {computeDispatch, flatDispatchLayout} from './webgpu_util'; - -export class Dilation2DProgram implements WebGPUProgram { - outputShape: number[]; - shaderKey: string; - dispatchLayout: {x: number[]}; - dispatch: [number, number, number]; - variableNames = ['x', 'w']; - uniforms = - 'filterDims: vec2, pads: vec2, strides: vec2, dilations: vec2'; - workgroupSize: [number, number, number] = [64, 1, 1]; - size = true; - - constructor(convInfo: backend_util.Conv2DInfo) { - this.outputShape = convInfo.outShape; - this.dispatchLayout = flatDispatchLayout(this.outputShape); - this.dispatch = computeDispatch( - this.dispatchLayout, this.outputShape, this.workgroupSize); - - this.shaderKey = 'dilation2d'; - } - - getUserCode(): string { - const userCode = ` - ${main('index')} { - if (index < uniforms.size) { - let neg_infinity = -3.4e38; - let coords = getOutputCoords(); - let batch = coords.x; - let d1 = coords.w; - let outTopLeftCorner = coords.yz * uniforms.strides - uniforms.pads; - let hBeg = outTopLeftCorner.x; - let wBeg = outTopLeftCorner.y; - - var curVal = neg_infinity; - for (var h = 0; h < uniforms.filterDims[0]; h = h + 1) { - let hIn = hBeg + h * uniforms.dilations[0]; - - if (hIn >= 0 && hIn < uniforms.xShape[1]) { - for (var w = 0; w < uniforms.filterDims[1]; w = w + 1) { - let wIn = wBeg + w * uniforms.dilations[1]; - - if (wIn >= 0 && wIn < uniforms.xShape[2]) { - let val = getX(batch, hIn, wIn, d1) + getW(h, w, d1); - if (val > curVal) { - curVal = val; - } - } - } - } - } - - setOutputAtIndex(index, curVal); - } - } - `; - return userCode; - } -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/draw_webgpu.ts b/tfjs-master/tfjs-backend-webgpu/src/draw_webgpu.ts deleted file mode 100644 index 608e8099d..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/draw_webgpu.ts +++ /dev/null @@ -1,79 +0,0 @@ -/** - * @license - * Copyright 2023 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {DataType} from '@tensorflow/tfjs-core'; - -import {getMainHeaderString as main, PixelsOpType, WebGPUProgram} from './webgpu_program'; -import {computeDispatch, flatDispatchLayout} from './webgpu_util'; - -export class DrawProgram implements WebGPUProgram { - variableNames = ['Image']; - uniforms = 'alpha: f32,'; - outputShape: number[]; - shaderKey: string; - dispatchLayout: {x: number[]}; - dispatch: [number, number, number]; - workgroupSize: [number, number, number] = [64, 1, 1]; - type: DataType; - textureFormat: GPUTextureFormat; - pixelsOpType = PixelsOpType.DRAW; - size = true; - - constructor( - outShape: number[], type: DataType, textureFormat: GPUTextureFormat) { - this.outputShape = outShape; - this.dispatchLayout = flatDispatchLayout(this.outputShape); - this.dispatch = computeDispatch( - this.dispatchLayout, this.outputShape, this.workgroupSize); - this.type = type; - this.textureFormat = textureFormat; - this.shaderKey = `draw_${type}_${textureFormat}`; - } - - getUserCode(): string { - let calculateResult; - const value = this.type === 'float32' ? 'value' : 'value / 255.0'; - calculateResult = ` - if (uniforms.numChannels == 1) { - rgba[0] = ${value}; - rgba[1] = ${value}; - rgba[2] = ${value}; - } else { - rgba[d] = ${value}; - }`; - - const userCode = ` - @group(0) @binding(0) var outImage : texture_storage_2d<${ - this.textureFormat}, write>; - ${main('index')} { - if (index < uniforms.size) { - var rgba = vec4(0.0, 0.0, 0.0, uniforms.alpha); - for (var d = 0; d < uniforms.numChannels; d = d + 1) { - let value = f32(inBuf[index * uniforms.numChannels + d]); - ${calculateResult} - } - rgba.x = rgba.x * rgba.w; - rgba.y = rgba.y * rgba.w; - rgba.z = rgba.z * rgba.w; - let coords = getCoordsFromIndex(index); - textureStore(outImage, vec2(coords.yx), rgba); - } - } - `; - return userCode; - } -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/fft_webgpu.ts b/tfjs-master/tfjs-backend-webgpu/src/fft_webgpu.ts deleted file mode 100644 index 30d977cc9..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/fft_webgpu.ts +++ /dev/null @@ -1,82 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {getMainHeaderString as main, WebGPUProgram} from './webgpu_program'; -import {computeDispatch, flatDispatchLayout} from './webgpu_util'; - -export class FFTProgram implements WebGPUProgram { - variableNames: string[] = ['real', 'imag']; - outputShape: number[] = []; - shaderKey: string; - dispatchLayout: {x: number[]}; - dispatch: [number, number, number]; - uniforms = 'exponentMultiplier : f32, denominator: f32,'; - workgroupSize: [number, number, number] = [64, 1, 1]; - size = true; - component: string; - - constructor(component: 'real'|'imag', shape: [number, number]) { - this.outputShape = shape; - this.dispatchLayout = flatDispatchLayout(this.outputShape); - this.dispatch = computeDispatch( - this.dispatchLayout, this.outputShape, this.workgroupSize); - - this.component = component; - this.shaderKey = `fft_${component}`; - } - - getUserCode(): string { - const opString = this.component === 'real' ? - 'return real * expR - imag * expI;' : - 'return real * expI + imag * expR;'; - const userCode = ` - fn unaryOpComplex(real: f32, expR: f32, imag: f32, expI: f32) -> f32 { - ${opString} - } - - fn mulMatDFT(batch: i32, index: i32) -> f32 { - let indexRatio = f32(index) / f32(uniforms.realShape[1]); - let exponentMultiplierTimesIndexRatio = - uniforms.exponentMultiplier * indexRatio; - - var result = 0.0; - - for (var i = 0; i < uniforms.realShape[1]; i = i + 1) { - // x = (-2|2 * PI / N) * index * i; - let x = exponentMultiplierTimesIndexRatio * f32(i); - let expR = cos(x); - let expI = sin(x); - let real = getReal(batch, i); - let imag = getImag(batch, i); - - result = result + - unaryOpComplex(real, expR, imag, expI) / uniforms.denominator; - } - - return result; - } - - ${main('index')} { - if (index < uniforms.size) { - let coords = getOutputCoords(); - setOutputAtIndex(index, mulMatDFT(coords[0], coords[1])); - } - } - `; - return userCode; - } -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/fill_webgpu.ts b/tfjs-master/tfjs-backend-webgpu/src/fill_webgpu.ts deleted file mode 100644 index 808a3e1b4..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/fill_webgpu.ts +++ /dev/null @@ -1,50 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {getMainHeaderString as main, WebGPUProgram} from './webgpu_program'; -import {computeDispatch, flatDispatchLayout} from './webgpu_util'; - -export class FillProgram implements WebGPUProgram { - variableNames: string[] = []; - outputShape: number[] = []; - shaderKey: string; - dispatchLayout: {x: number[]}; - dispatch: [number, number, number]; - uniforms = 'value : f32,'; - workgroupSize: [number, number, number] = [64, 1, 1]; - size = true; - - constructor(shape: number[]) { - this.outputShape = shape; - this.dispatchLayout = flatDispatchLayout(this.outputShape); - this.dispatch = computeDispatch( - this.dispatchLayout, this.outputShape, this.workgroupSize); - - this.shaderKey = 'fill'; - } - - getUserCode(): string { - const userCode = ` - ${main('index')} { - if (index < uniforms.size) { - setOutputAtIndex(index, uniforms.value); - } - } - `; - return userCode; - } -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/flags_webgpu.ts b/tfjs-master/tfjs-backend-webgpu/src/flags_webgpu.ts deleted file mode 100644 index 959c93066..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/flags_webgpu.ts +++ /dev/null @@ -1,95 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {env} from '@tensorflow/tfjs-core'; - -const ENV = env(); - -/** The batched dispatching calls size in the device queue. */ -ENV.registerFlag('WEBGPU_DEFERRED_SUBMIT_BATCH_SIZE', () => 15); - -/** - * Whether we forward execution to the CPU backend if tensors are small and - * reside on the CPU. - */ -ENV.registerFlag('WEBGPU_CPU_FORWARD', () => true); - -/** - * This flag is used to test different types of matmul programs. - * - * See MatMulProgramType in webgpu_util.ts for a list of available values. - */ -ENV.registerFlag('WEBGPU_MATMUL_PROGRAM_TYPE', () => -1); - -/** - * Whether to use conv2dTranspose_naive which directly implement the - * conv2dTranspose logic rather than using a matmul to simulate. - */ -ENV.registerFlag('WEBGPU_USE_NAIVE_CONV2D_TRANSPOSE', () => true); - -/** - * Whether we use low power GPU. Otherwise, a high performance GPU will be - * requested. - */ -ENV.registerFlag('WEBGPU_USE_LOW_POWER_GPU', () => false); - -/** - * Threshold for input tensor size that determines whether WebGPU backend will - * delegate computation to CPU. - * - * Default value is 1000. - */ -ENV.registerFlag('WEBGPU_CPU_HANDOFF_SIZE_THRESHOLD', () => 1000); - -/** - * Whether to use a dummy canvas to make profiling tools like PIX work with - * TFJS webgpu backend. - */ -ENV.registerFlag('WEBGPU_USE_PROFILE_TOOL', () => false); - -/** - * Whether to use import API. - */ -ENV.registerFlag('WEBGPU_IMPORT_EXTERNAL_TEXTURE', () => true); - -/** - * Whether to use conv2dNaive for debugging. - */ -ENV.registerFlag('WEBGPU_USE_NAIVE_CONV2D_DEBUG', () => false); - -/** - * Threshold to increase dispatched workgroups for matmul. If too few workgroups - * are dispatched, it means the hardware may be in low occupancy. - * -1 means it's not set by the user. A default strategy will be applied. - */ -ENV.registerFlag( - 'WEBGPU_THRESHOLD_TO_INCREASE_WORKGROUPS_FOR_MATMUL', () => -1); - -/** - * Whether we will run im2col as a separate shader for convolution. - */ -ENV.registerFlag('WEBGPU_CONV_SEPARATE_IM2COL_SHADER', () => false); - -/** - * A string used to match shader key. If any matches, print the related shader. - * Seperated by comma. 'all' to print all. 'binary' to print binary(add, mul, - * etc.). 'unary,conv2d' to print both unary and conv2d. - */ -ENV.registerFlag('WEBGPU_PRINT_SHADER', () => ''); - -/** Experimental flag, whether enter compile only phase. */ -ENV.registerFlag('WEBGPU_ENGINE_COMPILE_ONLY', () => false); diff --git a/tfjs-master/tfjs-backend-webgpu/src/flip_left_right_webgpu.ts b/tfjs-master/tfjs-backend-webgpu/src/flip_left_right_webgpu.ts deleted file mode 100644 index 11adbe272..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/flip_left_right_webgpu.ts +++ /dev/null @@ -1,51 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {getMainHeaderString as main, WebGPUProgram} from './webgpu_program'; -import {computeDispatch, flatDispatchLayout} from './webgpu_util'; - -export class FlipLeftRightProgram implements WebGPUProgram { - outputShape: number[] = []; - shaderKey: string; - dispatchLayout: {x: number[]}; - dispatch: [number, number, number]; - variableNames = ['x']; - workgroupSize: [number, number, number] = [64, 1, 1]; - size = true; - - constructor(imageShape: [number, number, number, number]) { - this.outputShape = imageShape; - this.dispatchLayout = flatDispatchLayout(this.outputShape); - this.dispatch = computeDispatch( - this.dispatchLayout, this.outputShape, this.workgroupSize); - this.shaderKey = 'flipLeftRight'; - } - - getUserCode(): string { - const userCode = ` - ${main('index')} { - if (index < uniforms.size) { - let coords = getCoordsFromIndex(index); - let coordX = uniforms.xShape[2] - coords[2] - 1; - let outputValue = getX(coords[0], coords[1], coordX, coords[3]); - setOutputAtIndex(index, outputValue); - } - } - `; - return userCode; - } -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/from_pixels_webgpu.ts b/tfjs-master/tfjs-backend-webgpu/src/from_pixels_webgpu.ts deleted file mode 100644 index 92a720f02..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/from_pixels_webgpu.ts +++ /dev/null @@ -1,63 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {getMainHeaderString as main, PixelsOpType, WebGPUProgram} from './webgpu_program'; -import {computeDispatch, flatDispatchLayout} from './webgpu_util'; - -export class FromPixelsProgram implements WebGPUProgram { - dispatch: [number, number, number]; - dispatchLayout: {x: number[]}; - pixelsOpType = PixelsOpType.FROM_PIXELS; - outputShape: number[] = [0]; - shaderKey: string; - importVideo: boolean; - variableNames: string[] = []; - workgroupSize: [number, number, number] = - [256, 1, 1]; // The empirical value. - - constructor(outputShape: number[], numChannels: number, importVideo = false) { - this.outputShape = outputShape; - this.dispatchLayout = flatDispatchLayout(this.outputShape); - this.dispatch = computeDispatch( - this.dispatchLayout, this.outputShape, this.workgroupSize, - [numChannels, 1, 1]); - - this.importVideo = importVideo; - this.shaderKey = `fromPixels_${this.importVideo}`; - } - - getUserCode(): string { - const textureLoad = this.importVideo ? - 'textureLoad(src, vec2(coords.yx));' : - 'textureLoad(src, vec2(coords.yx), 0)'; - const textureType = - this.importVideo ? 'texture_external' : 'texture_2d'; - return ` - @binding(1) @group(0) var src: ${textureType}; - ${main('index')} { - let flatIndex = index * uniforms.numChannels; - if (flatIndex < uniforms.size) { - let coords = getCoordsFromIndex(flatIndex); - let values = ${textureLoad}; - for (var i = 0; i < uniforms.numChannels; i = i + 1) { - result[flatIndex + i] = i32(floor(255.0 * values[i])); - } - } - } - `; - } -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/from_pixels_webgpu_test.ts b/tfjs-master/tfjs-backend-webgpu/src/from_pixels_webgpu_test.ts deleted file mode 100644 index 5c1af6f0b..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/from_pixels_webgpu_test.ts +++ /dev/null @@ -1,133 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '@tensorflow/tfjs-core'; -import {test_util} from '@tensorflow/tfjs-core'; -import {WebGPUBackend} from './backend_webgpu'; -import {describeWebGPU} from './test_util'; - -describeWebGPU('fromPixels', () => { - let originalTimeout: number; - beforeAll(() => { - originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL; - jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000000; - }); - afterAll(() => { - jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout; - }); - - // Device is lost on Linux - // tslint:disable-next-line: ban - xit('should behave well if WEBGPU_IMPORT_EXTERNAL_TEXTURE is true or false', - async () => { - const oldImportExternalTexture = - tf.env().getBool('WEBGPU_IMPORT_EXTERNAL_TEXTURE'); - const backend = tf.backend() as WebGPUBackend; - const textureManager = backend.textureManager; - textureManager.dispose(); - - const source = document.createElement('source'); - source.src = - // tslint:disable-next-line:max-line-length - 'data:video/mp4;base64,AAAAIGZ0eXBpc29tAAACAGlzb21pc28yYXZjMW1wNDEAAAAIZnJlZQAAAu1tZGF0AAACrQYF//+p3EXpvebZSLeWLNgg2SPu73gyNjQgLSBjb3JlIDE1NSByMjkwMSA3ZDBmZjIyIC0gSC4yNjQvTVBFRy00IEFWQyBjb2RlYyAtIENvcHlsZWZ0IDIwMDMtMjAxOCAtIGh0dHA6Ly93d3cudmlkZW9sYW4ub3JnL3gyNjQuaHRtbCAtIG9wdGlvbnM6IGNhYmFjPTEgcmVmPTMgZGVibG9jaz0xOjA6MCBhbmFseXNlPTB4MzoweDExMyBtZT1oZXggc3VibWU9NyBwc3k9MSBwc3lfcmQ9MS4wMDowLjAwIG1peGVkX3JlZj0xIG1lX3JhbmdlPTE2IGNocm9tYV9tZT0xIHRyZWxsaXM9MSA4eDhkY3Q9MSBjcW09MCBkZWFkem9uZT0yMSwxMSBmYXN0X3Bza2lwPTEgY2hyb21hX3FwX29mZnNldD0tMiB0aHJlYWRzPTMgbG9va2FoZWFkX3RocmVhZHM9MSBzbGljZWRfdGhyZWFkcz0wIG5yPTAgZGVjaW1hdGU9MSBpbnRlcmxhY2VkPTAgYmx1cmF5X2NvbXBhdD0wIGNvbnN0cmFpbmVkX2ludHJhPTAgYmZyYW1lcz0zIGJfcHlyYW1pZD0yIGJfYWRhcHQ9MSBiX2JpYXM9MCBkaXJlY3Q9MSB3ZWlnaHRiPTEgb3Blbl9nb3A9MCB3ZWlnaHRwPTIga2V5aW50PTI1MCBrZXlpbnRfbWluPTEgc2NlbmVjdXQ9NDAgaW50cmFfcmVmcmVzaD0wIHJjX2xvb2thaGVhZD00MCByYz1jcmYgbWJ0cmVlPTEgY3JmPTI4LjAgcWNvbXA9MC42MCBxcG1pbj0wIHFwbWF4PTY5IHFwc3RlcD00IGlwX3JhdGlvPTEuNDAgYXE9MToxLjAwAIAAAAAwZYiEAD//8m+P5OXfBeLGOfKE3xkODvFZuBflHv/+VwJIta6cbpIo4ABLoKBaYTkTAAAC7m1vb3YAAABsbXZoZAAAAAAAAAAAAAAAAAAAA+gAAAPoAAEAAAEAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAIYdHJhawAAAFx0a2hkAAAAAwAAAAAAAAAAAAAAAQAAAAAAAAPoAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAQAAAAACgAAAAWgAAAAAAJGVkdHMAAAAcZWxzdAAAAAAAAAABAAAD6AAAAAAAAQAAAAABkG1kaWEAAAAgbWRoZAAAAAAAAAAAAAAAAAAAQAAAAEAAVcQAAAAAAC1oZGxyAAAAAAAAAAB2aWRlAAAAAAAAAAAAAAAAVmlkZW9IYW5kbGVyAAAAATttaW5mAAAAFHZtaGQAAAABAAAAAAAAAAAAAAAkZGluZgAAABxkcmVmAAAAAAAAAAEAAAAMdXJsIAAAAAEAAAD7c3RibAAAAJdzdHNkAAAAAAAAAAEAAACHYXZjMQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAACgAFoASAAAAEgAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABj//wAAADFhdmNDAWQACv/hABhnZAAKrNlCjfkhAAADAAEAAAMAAg8SJZYBAAZo6+JLIsAAAAAYc3R0cwAAAAAAAAABAAAAAQAAQAAAAAAcc3RzYwAAAAAAAAABAAAAAQAAAAEAAAABAAAAFHN0c3oAAAAAAAAC5QAAAAEAAAAUc3RjbwAAAAAAAAABAAAAMAAAAGJ1ZHRhAAAAWm1ldGEAAAAAAAAAIWhkbHIAAAAAAAAAAG1kaXJhcHBsAAAAAAAAAAAAAAAALWlsc3QAAAAlqXRvbwAAAB1kYXRhAAAAAQAAAABMYXZmNTguMTIuMTAw'; - source.type = 'video/mp4'; - - const video = await test_util.createVideoElement(source); - document.body.appendChild(video); - await test_util.play(video); - - { - tf.env().set('WEBGPU_IMPORT_EXTERNAL_TEXTURE', true); - const res = tf.browser.fromPixels(video); - expect(res.shape).toEqual([90, 160, 3]); - const data = await res.data(); - expect(data.length).toEqual(90 * 160 * 3); - const freeTexturesAfterFromPixels = - textureManager.getNumFreeTextures(); - expect(freeTexturesAfterFromPixels).toEqual(0); - const usedTexturesAfterFromPixels = - textureManager.getNumUsedTextures(); - expect(usedTexturesAfterFromPixels).toEqual(0); - } - - { - tf.env().set('WEBGPU_IMPORT_EXTERNAL_TEXTURE', false); - const res = tf.browser.fromPixels(video); - expect(res.shape).toEqual([90, 160, 3]); - const data = await res.data(); - expect(data.length).toEqual(90 * 160 * 3); - const freeTexturesAfterFromPixels = - textureManager.getNumFreeTextures(); - expect(freeTexturesAfterFromPixels).toEqual(1); - const usedTexturesAfterFromPixels = - textureManager.getNumUsedTextures(); - expect(usedTexturesAfterFromPixels).toEqual(0); - } - - document.body.removeChild(video); - tf.env().set( - 'WEBGPU_IMPORT_EXTERNAL_TEXTURE', oldImportExternalTexture); - }); - - // Failing on Linux - // tslint:disable-next-line: ban - xit('should reuse texture when fromPixels have same input size', async () => { - const backend = tf.backend() as WebGPUBackend; - const textureManager = backend.textureManager; - textureManager.dispose(); - - { - const img = new Image(10, 10); - img.src = 'data:image/gif;base64' + - ',R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=='; - - await new Promise(resolve => { - img.onload = () => resolve(img); - }); - - const resImage = tf.browser.fromPixels(img); - expect(resImage.shape).toEqual([10, 10, 3]); - - const dataImage = await resImage.data(); - expect(dataImage[0]).toEqual(0); - expect(dataImage.length).toEqual(10 * 10 * 3); - const freeTexturesAfterFromPixels = textureManager.getNumFreeTextures(); - expect(freeTexturesAfterFromPixels).toEqual(1); - const usedTexturesAfterFromPixels = textureManager.getNumUsedTextures(); - expect(usedTexturesAfterFromPixels).toEqual(0); - } - - { - const img = new Image(10, 10); - img.src = - 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAIAAAACUFjqAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAAEnQAABJ0Ad5mH3gAAABfSURBVChTY/gPBu8NLd/KqLxT1oZw4QAqDZSDoPeWDj9WrYUIAgG6NBAhm4FFGoIgxuCUBiKgMfikv1bW4pQGav334wdUGshBk/6SVQAUh0p/mzIDTQ6oFSGNHfz/DwAwi8mNzTi6rwAAAABJRU5ErkJggg=='; - await new Promise(resolve => { - img.onload = () => resolve(img); - }); - const resImage = tf.browser.fromPixels(img); - expect(resImage.shape).toEqual([10, 10, 3]); - - const dataImage = await resImage.data(); - expect(dataImage[0]).toEqual(255); - expect(dataImage.length).toEqual(10 * 10 * 3); - const freeTexturesAfterFromPixels = textureManager.getNumFreeTextures(); - expect(freeTexturesAfterFromPixels).toEqual(1); - const usedTexturesAfterFromPixels = textureManager.getNumUsedTextures(); - expect(usedTexturesAfterFromPixels).toEqual(0); - } - }); -}); diff --git a/tfjs-master/tfjs-backend-webgpu/src/gather_nd_webgpu.ts b/tfjs-master/tfjs-backend-webgpu/src/gather_nd_webgpu.ts deleted file mode 100644 index c2a348631..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/gather_nd_webgpu.ts +++ /dev/null @@ -1,65 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {getCoordsDataType, getMainHeaderString as main, WebGPUProgram} from './webgpu_program'; -import {computeDispatch, flatDispatchLayout} from './webgpu_util'; - -export class GatherNDProgram implements WebGPUProgram { - outputShape: number[]; - shaderKey: string; - dispatchLayout: {x: number[]}; - dispatch: [number, number, number]; - variableNames: string[] = ['A', 'indices']; - uniforms: string; - workgroupSize: [number, number, number] = [64, 1, 1]; - size = true; - sliceDim: number; - constructor(sliceDim: number, shape: number[]) { - this.outputShape = shape; - this.dispatchLayout = flatDispatchLayout(this.outputShape); - this.dispatch = computeDispatch( - this.dispatchLayout, this.outputShape, this.workgroupSize); - this.shaderKey = `gathernd_${sliceDim}`; - this.sliceDim = sliceDim; - this.uniforms = `sliceDim : i32, strides : ${getCoordsDataType(sliceDim)},`; - } - - getUserCode(): string { - let strideString; - if (this.sliceDim > 1) { - strideString = 'uniforms.strides[j]'; - } else { - strideString = 'uniforms.strides'; - } - const userCode = ` - ${main('index')} { - if (index < uniforms.size) { - let coords = getCoordsFromIndex(index); - var flattenIndex = 0; - for (var j = 0; j < uniforms.sliceDim; j = j + 1) { - let indexTemp = i32(round(getIndices(coords[0], j))); - let strideNum = ${strideString}; - flattenIndex = flattenIndex + indexTemp * strideNum; - } - - setOutputAtIndex(index, getA(flattenIndex, coords[1])); - } - } - `; - return userCode; - } -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/gather_webgpu.ts b/tfjs-master/tfjs-backend-webgpu/src/gather_webgpu.ts deleted file mode 100644 index 5dac58069..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/gather_webgpu.ts +++ /dev/null @@ -1,69 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {getMainHeaderString as main, WebGPUProgram} from './webgpu_program'; -import {computeDispatch, flatDispatchLayout} from './webgpu_util'; - -export class GatherProgram implements WebGPUProgram { - outputShape: number[]; - shaderKey: string; - dispatchLayout: {x: number[]}; - dispatch: [number, number, number]; - variableNames: string[] = ['A', 'indices']; - workgroupSize: [number, number, number] = [64, 1, 1]; - aShape: number[]; - size = true; - - constructor(aShape: number[], outputShape: number[]) { - this.outputShape = aShape.slice(); - this.aShape = aShape; - this.outputShape = outputShape; - this.dispatchLayout = flatDispatchLayout(this.outputShape); - this.dispatch = computeDispatch( - this.dispatchLayout, this.outputShape, this.workgroupSize); - this.shaderKey = `gather`; - } - - getUserCode(): string { - const sourceCoords = getSourceCoords(this.aShape); - const userCode = ` - ${main('index')} { - if (index < uniforms.size) { - let resRC = getCoordsFromIndex(index); - let indexZ = i32(getIndices(resRC.x, resRC.z)); - let inBounds = select(0.0, 1.0, indexZ >= 0 && indexZ < uniforms.aShape[2]); - setOutputAtIndex(index, inBounds * getA(${sourceCoords})); - } - } - `; - return userCode; - } -} - -// The input and output are always flattened into rank 4 tensors. -function getSourceCoords(aShape: number[]): string { - const currentCoords = ['resRC.x', 'resRC.y', 'resRC.z', 'resRC.w']; - const sourceCoords = []; - for (let i = 0; i < aShape.length; i++) { - if (i === 2) { - sourceCoords.push('indexZ'); - } else { - sourceCoords.push(`${currentCoords[i]}`); - } - } - return sourceCoords.join(); -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/im2col_webgpu.ts b/tfjs-master/tfjs-backend-webgpu/src/im2col_webgpu.ts deleted file mode 100644 index 9069cf717..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/im2col_webgpu.ts +++ /dev/null @@ -1,78 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {getMainHeaderString as main, WebGPUProgram} from './webgpu_program'; -import {computeDispatch, flatDispatchLayout} from './webgpu_util'; - -export class Im2ColProgram implements WebGPUProgram { - variableNames = ['x']; - uniforms = - `pads : vec2, strides : vec2, dilations : vec2, outWidth : i32, itemsPerBlockRow : i32, - inChannels : i32,`; - outputShape: number[]; - shaderKey: string; - dispatchLayout: {x: number[]}; - dispatch: [number, number, number]; - workgroupSize: [number, number, number] = [64, 1, 1]; - isChannelsLast: boolean; - size = true; - - constructor(outputShape: number[], isChannelsLast: boolean) { - this.outputShape = outputShape; - this.dispatchLayout = flatDispatchLayout(this.outputShape); - this.dispatch = computeDispatch( - this.dispatchLayout, this.outputShape, this.workgroupSize); - this.isChannelsLast = isChannelsLast; - this.shaderKey = `im2col_${this.isChannelsLast}`; - } - - getUserCode(): string { - const rowDim = this.isChannelsLast ? 1 : 2; - const colDim = this.isChannelsLast ? 2 : 3; - - const row = this.isChannelsLast ? 'coords[1]' : 'coords[2]'; - const col = this.isChannelsLast ? 'coords[2]' : 'coords[1]'; - const getXSnippet = this.isChannelsLast ? 'getX(batch, xRow, xCol, ch)' : - 'getX(batch, ch, xRow, xCol)'; - - const userCode = ` - ${main('index')} { - let coords = getCoordsFromIndex(index); - if(index < uniforms.size) { - let batch = coords[0]; - let row = ${row}; - let col = ${col}; - let offsetY = (row / uniforms.outWidth) * uniforms.strides[0] - uniforms.pads[0]; - let xRow = offsetY + uniforms.dilations[0] * (col / uniforms.itemsPerBlockRow); - var value = 0.0; - if(xRow < uniforms.xShape[${rowDim}] && xRow >= 0) { - let offsetX = (row % uniforms.outWidth) * uniforms.strides[1] - - uniforms.pads[1]; - let xCol = offsetX + uniforms.dilations[1] * ((col % - uniforms.itemsPerBlockRow) / uniforms.inChannels); - let ch = col % uniforms.inChannels; - if(xCol < uniforms.xShape[${colDim}] && xCol >= 0) { - value = ${getXSnippet}; - } - } - setOutputAtIndex(index, value); - } - } - `; - return userCode; - } -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/index.ts b/tfjs-master/tfjs-backend-webgpu/src/index.ts deleted file mode 100644 index 4bfecbe97..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/index.ts +++ /dev/null @@ -1,19 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -export * from './base'; -import './register_all_kernels'; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernel_utils/int.ts b/tfjs-master/tfjs-backend-webgpu/src/kernel_utils/int.ts deleted file mode 100644 index 0211f703f..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernel_utils/int.ts +++ /dev/null @@ -1,27 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {TensorInfo} from '@tensorflow/tfjs-core'; -import {WebGPUBackend} from '../backend_webgpu'; -import {UnaryOpType} from '../unary_op_util'; -import {UnaryOpProgram} from '../unary_op_webgpu'; - -export function int(input: TensorInfo, backend: WebGPUBackend): TensorInfo { - const program = new UnaryOpProgram(input.shape, UnaryOpType.TO_INT); - const output = backend.runWebGPUProgram(program, [input], 'int32'); - return {dataId: output.dataId, shape: output.shape, dtype: output.dtype}; -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernel_utils/kernel_funcs_utils.ts b/tfjs-master/tfjs-backend-webgpu/src/kernel_utils/kernel_funcs_utils.ts deleted file mode 100644 index 82e0fd4df..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernel_utils/kernel_funcs_utils.ts +++ /dev/null @@ -1,179 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, BinaryInputs, DataType, KernelFunc, TensorInfo, TypedArray, UnaryInputs, upcastType} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {BinaryOpComplexProgram} from '../binary_op_complex_webgpu'; -import {BinaryOpType} from '../binary_op_util'; -import {BinaryOpProgram} from '../binary_op_webgpu'; -import {complex} from '../kernels/Complex'; -import {UnaryOpType} from '../unary_op_util'; -import {UnaryOpProgram} from '../unary_op_webgpu'; - -import {SimpleBinaryKernelImplCPU, SimpleUnaryKernelImplCPU} from './shared'; - -type UnaryKernelFuncConfig = { - opType: UnaryOpType, - cpuKernelImpl?: SimpleUnaryKernelImplCPU, - dtype?: DataType -}; - -/** - * Template that creates a `KernelFunc` for unary ops. - * @param opType Op type to create `UnaryOpProgram`. - * @param cpuKernelImpl Optional. Shared functionality from tfjs-backend-cpu, it - * will be involved when necessary. - * @param dtype Optional. If set, the result has this dtype. Otherwise, the - * result has the same dtype as the first input. This is mainly used in - * comparison kernels, such as Equal, Less, Greater, etc. - */ -export function unaryKernelFunc( - {opType, cpuKernelImpl, dtype}: UnaryKernelFuncConfig): KernelFunc { - return ({inputs, backend}) => { - const {x} = inputs as UnaryInputs; - const webgpuBackend = backend as WebGPUBackend; - - const $dtype = dtype || x.dtype; - if (webgpuBackend.shouldExecuteOnCPU([x]) && cpuKernelImpl != null) { - const xData = webgpuBackend.tensorMap.get(x.dataId); - const outValues = cpuKernelImpl(xData.values as TypedArray, $dtype); - return webgpuBackend.makeTensorInfo(x.shape, $dtype, outValues); - } - - const program: UnaryOpProgram = new UnaryOpProgram(x.shape, opType); - return webgpuBackend.runWebGPUProgram(program, [x], $dtype); - }; -} - -type BinaryKernelFuncConfig = { - opType: BinaryOpType, - cpuKernelImpl?: SimpleBinaryKernelImplCPU, - supportsComplex?: boolean, - dtype?: DataType -}; - -/** - * Template that creates a `KernelFunc` for binary ops. - * @param opType Op type to create `BinaryOpProgram`. - * @param cpuKernelImpl Optional. Shared functionality from tfjs-backend-cpu, it - * will be involved when necessary. - * @param dtype Optional. If set, the result has this dtype. Otherwise, the - * result has the same dtype as the first input. This is mainly used in - * comparison kernels, such as Equal, Less, Greater, etc. - */ -export function binaryKernelFunc( - {opType, cpuKernelImpl, supportsComplex = false, dtype}: - BinaryKernelFuncConfig): KernelFunc { - return ({inputs, backend}) => { - const {a, b} = inputs as BinaryInputs; - const webgpuBackend = backend as WebGPUBackend; - - if (supportsComplex && a.dtype === 'complex64') { - const aData = webgpuBackend.tensorMap.get(a.dataId); - const bData = webgpuBackend.tensorMap.get(b.dataId); - let real: TensorInfo, imag: TensorInfo; - if (opType !== BinaryOpType.MUL) { - [real, imag] = [ - [aData.complexTensorInfos.real, bData.complexTensorInfos.real], - [aData.complexTensorInfos.imag, bData.complexTensorInfos.imag] - ].map(complexParts => { - const [aPart, bPart] = complexParts; - - const aHandle = { - dataId: aPart.dataId, - dtype: aPart.dtype, - shape: a.shape - }; - const bHandle = { - dataId: bPart.dataId, - dtype: bPart.dtype, - shape: b.shape - }; - - const program = new BinaryOpProgram(opType, a.shape, b.shape); - return webgpuBackend.runWebGPUProgram( - program, [aHandle, bHandle], - upcastType(aPart.dtype, bPart.dtype)); - }); - } else { - const realProgram = new BinaryOpComplexProgram( - BinaryOpType.COMPLEX_MULTIPLY_REAL, a.shape, b.shape); - const imagProgram = new BinaryOpComplexProgram( - BinaryOpType.COMPLEX_MULTIPLY_IMAG, a.shape, b.shape); - - const inputs = [ - { - dataId: aData.complexTensorInfos.real.dataId, - dtype: aData.complexTensorInfos.real.dtype, - shape: a.shape - }, - { - dataId: aData.complexTensorInfos.imag.dataId, - dtype: aData.complexTensorInfos.imag.dtype, - shape: a.shape - }, - { - dataId: bData.complexTensorInfos.real.dataId, - dtype: bData.complexTensorInfos.real.dtype, - shape: b.shape - }, - { - dataId: bData.complexTensorInfos.imag.dataId, - dtype: bData.complexTensorInfos.imag.dtype, - shape: b.shape - } - ]; - - real = webgpuBackend.runWebGPUProgram(realProgram, inputs, 'float32'); - imag = webgpuBackend.runWebGPUProgram(imagProgram, inputs, 'float32'); - } - - const complexOutput = - complex({inputs: {real, imag}, backend: webgpuBackend}); - - webgpuBackend.disposeData(real.dataId); - webgpuBackend.disposeData(imag.dataId); - - // TODO: Implement CPU forwarding for complex inputs. - - return complexOutput; - } - - const $dtype = dtype || upcastType(a.dtype, b.dtype); - if ((a.dtype === 'string' || b.dtype === 'string' || - webgpuBackend.shouldExecuteOnCPU([a, b])) && - cpuKernelImpl != null) { - const aData = webgpuBackend.tensorMap.get(a.dataId).values as TypedArray; - const bData = webgpuBackend.tensorMap.get(b.dataId).values as TypedArray; - const decodedAVals = a.dtype === 'string' ? - // tslint:disable-next-line: no-any - backend_util.fromUint8ToStringArray(aData as any as Uint8Array[]) : - aData; - const decodedBVals = a.dtype === 'string' ? - // tslint:disable-next-line: no-any - backend_util.fromUint8ToStringArray(bData as any as Uint8Array[]) : - bData; - const [outValues, outShape] = - cpuKernelImpl(a.shape, b.shape, decodedAVals, decodedBVals, $dtype); - - return webgpuBackend.makeTensorInfo(outShape, $dtype, outValues); - } - const program = new BinaryOpProgram(opType, a.shape, b.shape); - return webgpuBackend.runWebGPUProgram(program, [a, b], $dtype); - }; -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernel_utils/reduce.ts b/tfjs-master/tfjs-backend-webgpu/src/kernel_utils/reduce.ts deleted file mode 100644 index f6c82a5df..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernel_utils/reduce.ts +++ /dev/null @@ -1,103 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, DataType, sumOutType, TensorInfo, TypedArray, util} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {reshape} from '../kernels/Reshape'; -import {transpose} from '../kernels/Transpose'; -import {ReduceProgram} from '../reduce_webgpu'; - -import {maxImplCPU} from './shared'; -import {prodImplCPU} from './shared'; - -type ReduceTypes = 'all'|'any'|'max'|'mean'|'min'|'prod'|'sum'; -const RETURN_TYPES: {[key in ReduceTypes]?: DataType} = { - 'mean': 'float32', - 'all': 'bool', - 'any': 'bool', -}; - -export function reduce( - x: TensorInfo, axis: number|number[], keepDims: boolean, - reduceType: ReduceTypes, backend: WebGPUBackend): TensorInfo { - const xRank = x.shape.length; - const toDispose = []; - - const origAxes = util.parseAxisParam(axis, x.shape); - let axes = origAxes; - const permutedAxes = backend_util.getAxesPermutation(axes, xRank); - - let input = x; - if (permutedAxes != null) { - input = transpose({inputs: {x}, attrs: {perm: permutedAxes}, backend}); - axes = backend_util.getInnerMostAxes(axes.length, xRank); - toDispose.push(input); - } - - backend_util.assertAxesAreInnerMostDims(reduceType, axes, xRank); - - const [reduceOutShape, reduceShape] = - backend_util.computeOutAndReduceShapes(input.shape, axes); - let resOutShape = reduceOutShape; - if (keepDims) { - // rather than reshape at the end, set the target shape here. - resOutShape = backend_util.expandShapeToKeepDim(reduceOutShape, origAxes); - } - - let res; - if ((reduceType === 'max' || reduceType === 'prod') && - backend.shouldExecuteOnCPU([input])) { - const xVals = backend.tensorMap.get(input.dataId).values as TypedArray; - switch (reduceType) { - case 'max': - const outValues = maxImplCPU( - xVals, util.sizeFromShape(reduceShape), resOutShape, x.dtype); - res = backend.makeTensorInfo(resOutShape, x.dtype, outValues); - break; - case 'prod': - const {outVals, outShape, outDtype} = - prodImplCPU(input.shape, input.dtype, xVals, axes); - res = backend.makeTensorInfo(outShape, outDtype, outVals); - break; - default: - throw new Error( - `${reduceType} CPU implementation is not yet supported.`); - } - } else { - const inSize = util.sizeFromShape(reduceShape); - const xSize = util.sizeFromShape(input.shape); - const batchSize = xSize / inSize; - - const reduceInfo = {windowSize: inSize, inSize, batchSize, outSize: 1}; - const dtype = RETURN_TYPES[reduceType] || sumOutType(x.dtype); - const uniformData = [ - {type: 'int32', data: [inSize]}, - ]; - const program = new ReduceProgram( - reduceInfo, reduceType, backend.device.limits.maxComputeWorkgroupSizeX); - const reduced = - backend.runWebGPUProgram(program, [input], dtype, uniformData); - toDispose.push(reduced); - - res = reshape({inputs: {x: reduced}, attrs: {shape: resOutShape}, backend}); - } - - toDispose.forEach(t => backend.disposeData(t.dataId)); - - return res; -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernel_utils/shared.ts b/tfjs-master/tfjs-backend-webgpu/src/kernel_utils/shared.ts deleted file mode 100644 index 2d7cbf1aa..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernel_utils/shared.ts +++ /dev/null @@ -1,103 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// Import shared functionality from tfjs-backend-cpu without triggering -// side effects. -// tslint:disable-next-line: no-imports-from-dist -import * as shared from '@tensorflow/tfjs-backend-cpu/dist/shared'; -// tslint:disable-next-line: no-imports-from-dist -import {SimpleBinaryKernelImpl} from '@tensorflow/tfjs-backend-cpu/dist/shared'; -// tslint:disable-next-line: no-imports-from-dist -import {SimpleUnaryImpl} from '@tensorflow/tfjs-backend-cpu/dist/utils/unary_types'; - -export type SimpleBinaryKernelImplCPU = SimpleBinaryKernelImpl; -export type SimpleUnaryKernelImplCPU = SimpleUnaryImpl; -const { - addImpl: addImplCPU, - castImpl: castImplCPU, - ceilImpl: ceilImplCPU, - concatImpl: concatImplCPU, - equalImpl: equalImplCPU, - expImpl: expImplCPU, - expm1Impl: expm1ImplCPU, - floorImpl: floorImplCPU, - floorDivImpl: floorDivImplCPU, - gatherNdImpl: gatherNdImplCPU, - gatherV2Impl: gatherV2ImplCPU, - greaterEqualImpl: greaterEqualImplCPU, - greaterImpl: greaterImplCPU, - lessEqualImpl: lessEqualImplCPU, - lessImpl: lessImplCPU, - logImpl: logImplCPU, - maxImpl: maxImplCPU, - maximumImpl: maximumImplCPU, - minimumImpl: minimumImplCPU, - multiplyImpl: multiplyImplCPU, - negImpl: negImplCPU, - notEqualImpl: notEqualImplCPU, - prodImpl: prodImplCPU, - rangeImpl: rangeImplCPU, - rsqrtImpl: rsqrtImplCPU, - scatterImpl: scatterImplCPU, - simpleAbsImpl: simpleAbsImplCPU, - sliceImpl: sliceImplCPU, - stridedSliceImpl: stridedSliceImplCPU, - stringNGramsImpl: stringNGramsImplCPU, - subImpl: subImplCPU, - tileImpl: tileImplCPU, - topKImpl: topKImplCPU, - transposeImpl: transposeImplCPU, - uniqueImpl: uniqueImplCPU, -} = shared; - -export { - addImplCPU, - castImplCPU, - ceilImplCPU, - concatImplCPU, - equalImplCPU, - expImplCPU, - expm1ImplCPU, - floorImplCPU, - floorDivImplCPU, - gatherNdImplCPU, - gatherV2ImplCPU, - greaterEqualImplCPU, - greaterImplCPU, - lessEqualImplCPU, - lessImplCPU, - logImplCPU, - maxImplCPU, - maximumImplCPU, - minimumImplCPU, - multiplyImplCPU, - prodImplCPU, - negImplCPU, - notEqualImplCPU, - scatterImplCPU, - simpleAbsImplCPU, - sliceImplCPU, - stridedSliceImplCPU, - stringNGramsImplCPU, - subImplCPU, - rangeImplCPU, - rsqrtImplCPU, - tileImplCPU, - topKImplCPU, - transposeImplCPU, - uniqueImplCPU, -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernel_utils/sparse_segment_reduce.ts b/tfjs-master/tfjs-backend-webgpu/src/kernel_utils/sparse_segment_reduce.ts deleted file mode 100644 index b14f175b3..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernel_utils/sparse_segment_reduce.ts +++ /dev/null @@ -1,76 +0,0 @@ -/** - * @license - * Copyright 2023 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {TensorInfo, TypedArray, util} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {fill} from '../kernels/Fill'; -import {SparseSegmentIdCountProgram, SparseSegmentMeanProgram, SparseSegmentSumProgram} from '../sparse_segment_reduce_webgpu'; -import {WebGPUProgram} from '../webgpu_program'; - -export function sparseSegmentReduce( - input: TensorInfo, indices: TensorInfo, segmentIds: TensorInfo, - isSum = false, backend: WebGPUBackend): TensorInfo { - const inputSize = util.sizeFromShape(input.shape); - const segmentSize = inputSize / input.shape[0]; - const dtype = input.dtype; - - // Note that the current implementation assumes that segmentIds values are - // sorted. - const numIndices = util.sizeFromShape(indices.shape); - const $segmentIds = backend.readSync(segmentIds.dataId) as TypedArray; - const lastSegmentIdPlusOne = - numIndices > 0 ? $segmentIds[numIndices - 1] + 1 : 0; - const outputRows = lastSegmentIdPlusOne; - - let program: WebGPUProgram; - const outputShape = input.shape.slice(); - outputShape[0] = outputRows; - - const sparseSize = numIndices * segmentSize; - const sparseSegmentSum = - fill({backend, attrs: {shape: outputShape, value: 0, dtype}}); - program = new SparseSegmentSumProgram(outputShape, sparseSize, dtype); - let uniformData = [ - {type: 'int32', data: [segmentSize]}, {type: 'int32', data: [sparseSize]} - ]; - const $sparseSegmentSum = backend.runWebGPUProgram( - program, [input, indices, segmentIds], dtype, uniformData, - sparseSegmentSum); - - if (isSum) { - return $sparseSegmentSum; - } - - const sparseSegmentIdCount = - fill({backend, attrs: {shape: [outputRows], value: 0, dtype: 'int32'}}); - program = new SparseSegmentIdCountProgram(outputRows, segmentIds.shape); - const $sparseSegmentIdCount = backend.runWebGPUProgram( - program, [segmentIds], 'int32', null, sparseSegmentIdCount); - - const sparseSegmentMean = - fill({backend, attrs: {shape: outputShape, value: 0, dtype}}); - program = new SparseSegmentMeanProgram(outputShape, dtype); - uniformData = [{type: 'int32', data: [segmentSize]}]; - const $sparseSegmentMean = backend.runWebGPUProgram( - program, [$sparseSegmentSum, $sparseSegmentIdCount], dtype, uniformData, - sparseSegmentMean); - - backend.disposeData($sparseSegmentSum.dataId); - backend.disposeData($sparseSegmentIdCount.dataId); - return $sparseSegmentMean; -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Abs.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Abs.ts deleted file mode 100644 index 1ef3f0218..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Abs.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Abs, KernelConfig} from '@tensorflow/tfjs-core'; -import {unaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; -import {simpleAbsImplCPU} from '../kernel_utils/shared'; -import {UnaryOpType} from '../unary_op_util'; - -export const abs = - unaryKernelFunc({opType: UnaryOpType.ABS, cpuKernelImpl: simpleAbsImplCPU}); - -export const absConfig: KernelConfig = { - kernelName: Abs, - backendName: 'webgpu', - kernelFunc: abs -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Acos.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Acos.ts deleted file mode 100644 index 757cdb632..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Acos.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Acos, KernelConfig} from '@tensorflow/tfjs-core'; - -import {unaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; - -import {UnaryOpType} from '../unary_op_util'; - -export const acos = unaryKernelFunc({opType: UnaryOpType.ACOS}); - -export const acosConfig: KernelConfig = { - kernelName: Acos, - backendName: 'webgpu', - kernelFunc: acos -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Acosh.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Acosh.ts deleted file mode 100644 index f0b2403bb..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Acosh.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Acosh, KernelConfig} from '@tensorflow/tfjs-core'; - -import {unaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; - -import {UnaryOpType} from '../unary_op_util'; - -export const acosh = unaryKernelFunc({opType: UnaryOpType.ACOSH}); - -export const acoshConfig: KernelConfig = { - kernelName: Acosh, - backendName: 'webgpu', - kernelFunc: acosh -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Add.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Add.ts deleted file mode 100644 index 6e9f60858..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Add.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Add, KernelConfig} from '@tensorflow/tfjs-core'; - -import {BinaryOpType} from '../binary_op_util'; -import {binaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; -import {addImplCPU as cpuAdd} from '../kernel_utils/shared'; - -export const addKernelFunc = binaryKernelFunc( - {opType: BinaryOpType.ADD, cpuKernelImpl: cpuAdd, supportsComplex: true}); - -export const addConfig: KernelConfig = { - kernelName: Add, - backendName: 'webgpu', - kernelFunc: addKernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/AddN.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/AddN.ts deleted file mode 100644 index 4a3bf3dc3..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/AddN.ts +++ /dev/null @@ -1,45 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {AddN, AddNInputs, KernelConfig, KernelFunc, TensorInfo, upcastType} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; - -import {AddNPackedProgram} from '../addn_packed_webgpu'; -import {identity} from './Identity'; - -export function addN(args: {inputs: AddNInputs, backend: WebGPUBackend}): - TensorInfo { - const {inputs, backend} = args; - - const tensors = inputs; - if (tensors.length === 1) { - return identity({inputs: {x: tensors[0]}, backend}); - } - - const dtype = - tensors.map(t => t.dtype).reduce((d1, d2) => upcastType(d1, d2)); - const shapes = tensors.map(t => t.shape); - const program = new AddNPackedProgram(shapes); - return backend.runWebGPUProgram(program, tensors, dtype); -} - -export const addNConfig: KernelConfig = { - kernelName: AddN, - backendName: 'webgpu', - kernelFunc: addN as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/All.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/All.ts deleted file mode 100644 index dd7f3c76f..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/All.ts +++ /dev/null @@ -1,37 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {All, AllAttrs, AllInputs, KernelConfig, KernelFunc, TensorInfo} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {reduce} from '../kernel_utils/reduce'; - -export function all( - args: {inputs: AllInputs, attrs: AllAttrs, backend: WebGPUBackend}): - TensorInfo { - const {inputs, backend, attrs} = args; - const {x} = inputs; - const {keepDims, axis} = attrs; - - return reduce(x, axis, keepDims, 'all', backend); -} - -export const allConfig: KernelConfig = { - kernelName: All, - backendName: 'webgpu', - kernelFunc: all as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Any.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Any.ts deleted file mode 100644 index 3af616240..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Any.ts +++ /dev/null @@ -1,37 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Any, AnyAttrs, AnyInputs, KernelConfig, KernelFunc, TensorInfo} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {reduce} from '../kernel_utils/reduce'; - -export function any( - args: {inputs: AnyInputs, attrs: AnyAttrs, backend: WebGPUBackend}): - TensorInfo { - const {inputs, backend, attrs} = args; - const {x} = inputs; - const {keepDims, axis} = attrs; - - return reduce(x, axis, keepDims, 'any', backend); -} - -export const anyConfig: KernelConfig = { - kernelName: Any, - backendName: 'webgpu', - kernelFunc: any as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/ArgMax.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/ArgMax.ts deleted file mode 100644 index 70311832f..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/ArgMax.ts +++ /dev/null @@ -1,54 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ArgMax, ArgMaxAttrs, ArgMaxInputs, backend_util, KernelConfig, KernelFunc, TensorInfo, util} from '@tensorflow/tfjs-core'; - -import {ArgMinMaxProgram} from '../argminmax_webgpu'; -import {WebGPUBackend} from '../backend_webgpu'; - -import {transpose} from './Transpose'; - -export function argMax( - args: {inputs: ArgMaxInputs, backend: WebGPUBackend, attrs: ArgMaxAttrs}): - TensorInfo { - const {inputs, backend, attrs} = args; - const {x} = inputs; - const {axis} = attrs; - - let axes = util.parseAxisParam(axis, x.shape); - const permutedAxes = backend_util.getAxesPermutation(axes, x.shape.length); - let $x = x; - const intermediateTensorInfos = []; - if (permutedAxes != null) { - $x = transpose({inputs: {x}, backend, attrs: {perm: permutedAxes}}); - intermediateTensorInfos.push($x); - axes = backend_util.getInnerMostAxes(axes.length, $x.shape.length); - } - - backend_util.assertAxesAreInnerMostDims('argMax', [axes[0]], $x.shape.length); - const program = new ArgMinMaxProgram($x.shape, axes[0], 'max'); - const uniformData = [{type: 'float32', data: [Number.NEGATIVE_INFINITY]}]; - const out = backend.runWebGPUProgram(program, [$x], 'int32', uniformData); - intermediateTensorInfos.forEach(t => backend.disposeData(t.dataId)); - return out; -} - -export const argMaxConfig: KernelConfig = { - kernelName: ArgMax, - backendName: 'webgpu', - kernelFunc: argMax as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/ArgMin.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/ArgMin.ts deleted file mode 100644 index 61c504c9d..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/ArgMin.ts +++ /dev/null @@ -1,54 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ArgMin, ArgMinAttrs, ArgMinInputs, backend_util, KernelConfig, KernelFunc, TensorInfo, util} from '@tensorflow/tfjs-core'; - -import {ArgMinMaxProgram} from '../argminmax_webgpu'; -import {WebGPUBackend} from '../backend_webgpu'; - -import {transpose} from './Transpose'; - -export function argMin( - args: {inputs: ArgMinInputs, backend: WebGPUBackend, attrs: ArgMinAttrs}): - TensorInfo { - const {inputs, backend, attrs} = args; - const {x} = inputs; - const {axis} = attrs; - - let axes = util.parseAxisParam(axis, x.shape); - const permutedAxes = backend_util.getAxesPermutation(axes, x.shape.length); - let $x = x; - const intermediateTensorInfos = []; - if (permutedAxes != null) { - $x = transpose({inputs: {x}, backend, attrs: {perm: permutedAxes}}); - intermediateTensorInfos.push($x); - axes = backend_util.getInnerMostAxes(axes.length, $x.shape.length); - } - - backend_util.assertAxesAreInnerMostDims('argMin', [axes[0]], $x.shape.length); - const program = new ArgMinMaxProgram($x.shape, axes[0], 'min'); - const uniformData = [{type: 'float32', data: [Number.POSITIVE_INFINITY]}]; - const out = backend.runWebGPUProgram(program, [$x], 'int32', uniformData); - intermediateTensorInfos.forEach(t => backend.disposeData(t.dataId)); - return out; -} - -export const argMinConfig: KernelConfig = { - kernelName: ArgMin, - backendName: 'webgpu', - kernelFunc: argMin as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Asin.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Asin.ts deleted file mode 100644 index 61dd375fc..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Asin.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Asin, KernelConfig} from '@tensorflow/tfjs-core'; - -import {unaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; - -import {UnaryOpType} from '../unary_op_util'; - -export const asin = unaryKernelFunc({opType: UnaryOpType.ASIN}); - -export const asinConfig: KernelConfig = { - kernelName: Asin, - backendName: 'webgpu', - kernelFunc: asin -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Asinh.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Asinh.ts deleted file mode 100644 index 1997d479e..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Asinh.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Asinh, KernelConfig} from '@tensorflow/tfjs-core'; - -import {unaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; - -import {UnaryOpType} from '../unary_op_util'; - -export const asinh = unaryKernelFunc({opType: UnaryOpType.ASINH}); - -export const asinhConfig: KernelConfig = { - kernelName: Asinh, - backendName: 'webgpu', - kernelFunc: asinh -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Atan.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Atan.ts deleted file mode 100644 index 98537fb33..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Atan.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Atan, KernelConfig} from '@tensorflow/tfjs-core'; - -import {unaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; - -import {UnaryOpType} from '../unary_op_util'; - -export const atan = unaryKernelFunc({opType: UnaryOpType.ATAN}); - -export const atanConfig: KernelConfig = { - kernelName: Atan, - backendName: 'webgpu', - kernelFunc: atan -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Atan2.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Atan2.ts deleted file mode 100644 index ca4c4884f..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Atan2.ts +++ /dev/null @@ -1,28 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Atan2, KernelConfig} from '@tensorflow/tfjs-core'; -import {BinaryOpType} from '../binary_op_util'; -import {binaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; - -export const atan2 = binaryKernelFunc({opType: BinaryOpType.ATAN2}); - -export const atan2Config: KernelConfig = { - kernelName: Atan2, - backendName: 'webgpu', - kernelFunc: atan2 -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Atanh.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Atanh.ts deleted file mode 100644 index d08bccdbd..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Atanh.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Atanh, KernelConfig} from '@tensorflow/tfjs-core'; - -import {unaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; - -import {UnaryOpType} from '../unary_op_util'; - -export const atanh = unaryKernelFunc({opType: UnaryOpType.ATANH}); - -export const atanhConfig: KernelConfig = { - kernelName: Atanh, - backendName: 'webgpu', - kernelFunc: atanh -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/AvgPool.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/AvgPool.ts deleted file mode 100644 index b05f214a1..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/AvgPool.ts +++ /dev/null @@ -1,40 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {AvgPool, AvgPoolAttrs, AvgPoolInputs, backend_util, KernelConfig, KernelFunc, TensorInfo} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {poolImpl} from './Pool_impl'; - -export function avgPool( - args: {inputs: AvgPoolInputs, backend: WebGPUBackend, attrs: AvgPoolAttrs}): - TensorInfo { - const {inputs, backend, attrs} = args; - const {x} = inputs; - const {filterSize, strides, pad, dimRoundingMode} = attrs; - const dilations = 1; - const convInfo = backend_util.computePool2DInfo( - x.shape as [number, number, number, number], filterSize, strides, - dilations, pad, dimRoundingMode); - - return poolImpl(x, convInfo, 'avg', backend); -} - -export const avgPoolConfig: KernelConfig = { - kernelName: AvgPool, - backendName: 'webgpu', - kernelFunc: avgPool as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/AvgPool3D.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/AvgPool3D.ts deleted file mode 100644 index 909437b61..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/AvgPool3D.ts +++ /dev/null @@ -1,65 +0,0 @@ -/** - * @license - * Copyright 2023 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {AvgPool3D, AvgPool3DAttrs, AvgPool3DInputs, backend_util, KernelConfig, KernelFunc, TensorInfo} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {Pool3DProgram} from '../pool_webgpu'; - -export function avgPool3D(args: { - inputs: AvgPool3DInputs, - backend: WebGPUBackend, - attrs: AvgPool3DAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {x} = inputs; - const {filterSize, strides, pad, dataFormat, dimRoundingMode} = attrs; - const dilations: [number, number, number] = [1, 1, 1]; - - const convInfo = backend_util.computePool3DInfo( - x.shape as [number, number, number, number, number], filterSize, strides, - dilations, pad, dimRoundingMode, dataFormat); - const avgPoolProgram = new Pool3DProgram(convInfo, 'avg'); - const dimensions = [ - { - type: 'int32', - data: [convInfo.strideDepth, convInfo.strideHeight, convInfo.strideWidth] - }, - { - type: 'int32', - data: - [convInfo.padInfo.front, convInfo.padInfo.top, convInfo.padInfo.left] - }, - { - type: 'int32', - data: [convInfo.inDepth, convInfo.inHeight, convInfo.inWidth] - }, - { - type: 'int32', - data: [ - convInfo.effectiveFilterDepth, convInfo.effectiveFilterHeight, - convInfo.effectiveFilterWidth - ] - } - ]; - return backend.runWebGPUProgram(avgPoolProgram, [x], x.dtype, dimensions); -} - -export const avgPool3DConfig: KernelConfig = { - kernelName: AvgPool3D, - backendName: 'webgpu', - kernelFunc: avgPool3D as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/AvgPool3DGrad.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/AvgPool3DGrad.ts deleted file mode 100644 index ae9280fec..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/AvgPool3DGrad.ts +++ /dev/null @@ -1,71 +0,0 @@ -/** - * @license - * Copyright 2023 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {AvgPool3DGrad, AvgPool3DGradAttrs, AvgPool3DGradInputs, backend_util, KernelConfig, KernelFunc, TensorInfo} from '@tensorflow/tfjs-core'; - -import {AvgPool3DBackpropProgram} from '../avg_pool_backprop_webgpu'; -import {WebGPUBackend} from '../backend_webgpu'; - -export function avgPool3DGrad(args: { - inputs: AvgPool3DGradInputs, - backend: WebGPUBackend, - attrs: AvgPool3DGradAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {dy, input} = inputs; - const x = input; - const {filterSize, strides, pad, dimRoundingMode} = attrs; - - const convInfo = backend_util.computePool3DInfo( - x.shape as [number, number, number, number, number], filterSize, strides, - 1 /* dilations */, pad, dimRoundingMode); - const program = new AvgPool3DBackpropProgram(convInfo); - const avgMultiplier = - 1 / (convInfo.filterDepth * convInfo.filterHeight * convInfo.filterWidth); - const uniformData = [ - { - type: 'int32', - data: [convInfo.strideDepth, convInfo.strideHeight, convInfo.strideWidth] - }, - { - type: 'int32', - data: [ - convInfo.effectiveFilterDepth - 1 - convInfo.padInfo.front, - convInfo.effectiveFilterHeight - 1 - convInfo.padInfo.top, - convInfo.effectiveFilterWidth - 1 - convInfo.padInfo.left - ] - }, - { - type: 'int32', - data: [ - convInfo.effectiveFilterDepth, convInfo.effectiveFilterHeight, - convInfo.effectiveFilterWidth - ] - }, - {type: 'int32', data: [convInfo.outDepth]}, - {type: 'int32', data: [convInfo.outHeight]}, - {type: 'int32', data: [convInfo.outWidth]}, - {type: 'float32', data: [avgMultiplier]} - ]; - return backend.runWebGPUProgram(program, [dy], x.dtype, uniformData); -} - -export const avgPool3DGradConfig: KernelConfig = { - kernelName: AvgPool3DGrad, - backendName: 'webgpu', - kernelFunc: avgPool3DGrad as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/AvgPoolGrad.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/AvgPoolGrad.ts deleted file mode 100644 index b021bcff8..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/AvgPoolGrad.ts +++ /dev/null @@ -1,63 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {AvgPoolGrad, AvgPoolGradAttrs, AvgPoolGradInputs, backend_util, KernelConfig, KernelFunc, TensorInfo} from '@tensorflow/tfjs-core'; - -import {AvgPool2DBackpropProgram} from '../avg_pool_backprop_webgpu'; -import {WebGPUBackend} from '../backend_webgpu'; -import {assertNotComplex} from '../webgpu_util'; - -export function avgPoolGrad(args: { - inputs: AvgPoolGradInputs, - backend: WebGPUBackend, - attrs: AvgPoolGradAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {dy, input} = inputs; - const x = input; - assertNotComplex([dy, input], 'avgPoolGrad'); - const {filterSize, strides, pad} = attrs; - - const convInfo = backend_util.computePool2DInfo( - x.shape as [number, number, number, number], filterSize, strides, - 1 /* dilations */, pad); - const program = new AvgPool2DBackpropProgram(convInfo); - const avgMultiplier = 1 / (convInfo.filterHeight * convInfo.filterWidth); - const uniformData = [ - {type: 'int32', data: [convInfo.strideHeight, convInfo.strideWidth]}, { - type: 'int32', - data: [ - convInfo.effectiveFilterHeight - 1 - convInfo.padInfo.top, - convInfo.effectiveFilterWidth - 1 - convInfo.padInfo.left - ] - }, - {type: 'int32', data: [convInfo.dilationHeight, convInfo.dilationWidth]}, { - type: 'int32', - data: [convInfo.effectiveFilterHeight, convInfo.effectiveFilterWidth] - }, - {type: 'int32', data: [convInfo.outHeight]}, - {type: 'int32', data: [convInfo.outWidth]}, - {type: 'float32', data: [avgMultiplier]} - ]; - return backend.runWebGPUProgram(program, [dy], x.dtype, uniformData); -} - -export const avgPoolGradConfig: KernelConfig = { - kernelName: AvgPoolGrad, - backendName: 'webgpu', - kernelFunc: avgPoolGrad as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/BatchMatMul.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/BatchMatMul.ts deleted file mode 100644 index 573dd38de..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/BatchMatMul.ts +++ /dev/null @@ -1,39 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {BatchMatMul, BatchMatMulAttrs, BatchMatMulInputs, KernelConfig, KernelFunc} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {batchMatMulImpl} from './BatchMatMul_impl'; - -export function batchMatMul(args: { - inputs: BatchMatMulInputs, - attrs: BatchMatMulAttrs, - backend: WebGPUBackend -}) { - const {inputs, backend, attrs} = args; - const {a, b} = inputs; - const {transposeA, transposeB} = attrs; - - return batchMatMulImpl({a, b, transposeA, transposeB, backend}); -} - -export const batchMatMulConfig: KernelConfig = { - kernelName: BatchMatMul, - backendName: 'webgpu', - kernelFunc: batchMatMul as unknown as KernelFunc, -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/BatchMatMul_impl.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/BatchMatMul_impl.ts deleted file mode 100644 index f2db26387..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/BatchMatMul_impl.ts +++ /dev/null @@ -1,218 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, broadcast_util, env, TensorInfo, util} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {MatMulPackedProgram} from '../matmul_packed_webgpu'; -import {MatMulReduceProgram} from '../matmul_reduce_webgpu'; -import {MatMulSmallOutputSizeProgram} from '../matmul_small_output_size_webgpu'; -import {BiasActivationProgram, MatMulSplitKProgram} from '../matmul_splitK_webgpu'; -import {WebGPUProgram} from '../webgpu_program'; -import {MatMulProgramType} from '../webgpu_util'; - -import {fill} from './Fill'; -import {reshape} from './Reshape'; - -type BatchMatMulConfig = { - a: TensorInfo, - b: TensorInfo, - transposeA: boolean, - transposeB: boolean, - backend: WebGPUBackend, - bias?: TensorInfo, - preluActivationWeights?: TensorInfo, - leakyreluAlpha?: number, - activation?: backend_util.Activation -}; - -export function batchMatMulImpl({ - a, - b, - transposeA, - transposeB, - backend, - bias = null, - preluActivationWeights = null, - leakyreluAlpha = 0, - activation = null -}: BatchMatMulConfig): TensorInfo { - const aRank = a.shape.length; - const bRank = b.shape.length; - - const innerShapeA = transposeA ? a.shape[aRank - 2] : a.shape[aRank - 1]; - const innerShapeB = transposeB ? b.shape[bRank - 1] : b.shape[bRank - 2]; - - const outerShapeA = transposeA ? a.shape[aRank - 1] : a.shape[aRank - 2]; - const outerShapeB = transposeB ? b.shape[bRank - 2] : b.shape[bRank - 1]; - - const outerDimsA = a.shape.slice(0, -2); - const outerDimsB = b.shape.slice(0, -2); - - const batchDimA = util.sizeFromShape(outerDimsA); - const batchDimB = util.sizeFromShape(outerDimsB); - - const outShapeOuterDims = broadcast_util.assertAndGetBroadcastShape( - a.shape.slice(0, -2), b.shape.slice(0, -2)); - const outShape = outShapeOuterDims.concat([outerShapeA, outerShapeB]); - - util.assert( - innerShapeA === innerShapeB, - () => `Error in matMul: inner shapes (${innerShapeA}) and (` + - `${innerShapeB}) of Tensors with shapes ${a.shape} and ` + - `${b.shape} and transposeA=${transposeA}` + - ` and transposeB=${transposeB} must match.`); - - const a3dShape: [number, number, number] = transposeA ? - [batchDimA, innerShapeA, outerShapeA] : - [batchDimA, outerShapeA, innerShapeA]; - const b3dShape: [number, number, number] = transposeB ? - [batchDimB, outerShapeB, innerShapeB] : - [batchDimB, innerShapeB, outerShapeB]; - - // The rest of the implementation is designed to operate on rank-3 tensors - const a3d = reshape({inputs: {x: a}, backend, attrs: {shape: a3dShape}}); - const b3d = reshape({inputs: {x: b}, backend, attrs: {shape: b3dShape}}); - const intermediates: TensorInfo[] = [a3d, b3d]; - - const batchDim = Math.max(batchDimA, batchDimB); - - const inputs: TensorInfo[] = [a3d, b3d]; - const dimensions = [ - {type: 'int32', data: [outerShapeA]}, {type: 'int32', data: [outerShapeB]}, - {type: 'int32', data: [innerShapeA]} - ]; - - let program: WebGPUProgram; - let out: TensorInfo; - const outputShape: [number, number, number] = - [batchDim, outerShapeA, outerShapeB]; - let matmulProgramType = env().get('WEBGPU_MATMUL_PROGRAM_TYPE') as number; - if (matmulProgramType < 0) { - // Usually increasing workgroups is a good way to gain more performance for - // few workgroups by tiling 32x32 (default matmul algorithm). Currently, - // there are three ways to increase workgroups. 1) MatMulReduceProgram, - // which is used only when the output size is very small (128 for now). 2) - // MatMulSplitKProgram, increasing workgroups by spliting K. 3) - // MatMulSmallOutputSizeProgram, increasing workgroups by small tile size. - // For different devices, the minimum optimal workgroups may be different. - // So here we set a |thresholdToIncreaseWorkgroups| to indicate whether we - // need to increase workgroups. And the literal number is an empirical - // value. - const thresholdFlagValue = - env().getNumber('WEBGPU_THRESHOLD_TO_INCREASE_WORKGROUPS_FOR_MATMUL'); - const thresholdToIncreaseWorkgroups = thresholdFlagValue > 0 ? - thresholdFlagValue : - backend.thresholdToIncreaseWorkgroups; - const workgroupsBy32x32 = - batchDim * Math.ceil(outerShapeA / 32) * Math.ceil(outerShapeB / 32); - const hasFewWorkgroups = - workgroupsBy32x32 <= thresholdToIncreaseWorkgroups || - (outerShapeA <= 8 && - workgroupsBy32x32 <= thresholdToIncreaseWorkgroups * 2); - if (hasFewWorkgroups) { - if (batchDim * outerShapeA * outerShapeB <= 128) { - matmulProgramType = MatMulProgramType.MatMulReduceProgram; - } else if (batchDim === 1 && innerShapeB >= 2000) { - matmulProgramType = MatMulProgramType.MatMulSplitKProgram; - } else { - matmulProgramType = MatMulProgramType.MatMulSmallOutputSizeProgram; - } - } else { - matmulProgramType = MatMulProgramType.MatMulPackedProgram; - } - } - - switch (matmulProgramType) { - case MatMulProgramType.MatMulReduceProgram: - program = new MatMulReduceProgram( - outputShape, transposeA, transposeB, bias, activation, - preluActivationWeights); - break; - case MatMulProgramType.MatMulSplitKProgram: { - // The output buffer must be initailzed to zero before using since we - // use atomicAdd in MatMulSplitKProgram. - out = fill( - {backend, attrs: {shape: outputShape, value: 0, dtype: a.dtype}}); - program = new MatMulSplitKProgram( - outputShape, innerShapeB, transposeA, transposeB); - if (bias || activation) { - out = - backend.runWebGPUProgram(program, inputs, a.dtype, dimensions, out); - const biasActivationProgram = new BiasActivationProgram( - out.shape, bias, activation, preluActivationWeights); - let uniformData = null; - const activationInputs: TensorInfo[] = [out]; - if (bias) { - activationInputs.push(bias); - } - if (preluActivationWeights) { - activationInputs.push(preluActivationWeights); - } - if (activation === 'leakyrelu') { - uniformData = [{type: 'float32', data: [leakyreluAlpha]}]; - biasActivationProgram.uniforms += ' alpha : f32,'; - } - const outActivated = backend.runWebGPUProgram( - biasActivationProgram, activationInputs, out.dtype, uniformData); - intermediates.push(out); - const outReshaped = reshape( - {inputs: {x: outActivated}, backend, attrs: {shape: outShape}}); - intermediates.push(outActivated); - for (const i of intermediates) { - backend.disposeData(i.dataId); - } - return outReshaped; - } - break; - } - case MatMulProgramType.MatMulSmallOutputSizeProgram: - program = new MatMulSmallOutputSizeProgram( - a3dShape, b3dShape, outputShape, transposeA, transposeB, bias, - activation, preluActivationWeights); - break; - case MatMulProgramType.MatMulPackedProgram: - // Experiments show that sequential access is more friendly for Intel - // GPUs. - const sequentialAccessByThreads = backend.adapterInfo.isIntel(); - program = new MatMulPackedProgram( - a3dShape, outputShape, transposeA, transposeB, bias, activation, - preluActivationWeights, sequentialAccessByThreads); - break; - default: - throw new Error(`Unsupported MatMulProgramType ${matmulProgramType}.`); - } - - if (bias) { - inputs.push(bias); - } - if (preluActivationWeights) { - inputs.push(preluActivationWeights); - } - if (activation === 'leakyrelu') { - dimensions.push({type: 'float32', data: [leakyreluAlpha]}); - program.uniforms += ' alpha : f32,'; - } - out = backend.runWebGPUProgram(program, inputs, a.dtype, dimensions, out); - const outReshaped = - reshape({inputs: {x: out}, backend, attrs: {shape: outShape}}); - intermediates.push(out); - for (const i of intermediates) { - backend.disposeData(i.dataId); - } - return outReshaped; -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/BatchToSpaceND.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/BatchToSpaceND.ts deleted file mode 100644 index 44e684af5..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/BatchToSpaceND.ts +++ /dev/null @@ -1,80 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, BatchToSpaceND, BatchToSpaceNDAttrs, BatchToSpaceNDInputs, KernelConfig, KernelFunc, TensorInfo, util} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; - -import {reshape} from './Reshape'; -import {slice} from './Slice'; -import {transpose} from './Transpose'; - -export const batchToSpaceND = (args: { - inputs: BatchToSpaceNDInputs, - backend: WebGPUBackend, - attrs: BatchToSpaceNDAttrs -}): TensorInfo => { - const {inputs, backend, attrs} = args; - const {x} = inputs; - const {blockShape, crops} = attrs; - - util.assert( - x.shape.length <= 4, - () => 'batchToSpaceND for rank > 4 with a WebGPU backend not ' + - 'implemented yet'); - const prod = blockShape.reduce((a, b) => a * b); - - const reshaped = backend_util.getReshaped(x.shape, blockShape, prod); - const permuted = backend_util.getPermuted(reshaped.length, blockShape.length); - const reshapedPermuted = - backend_util.getReshapedPermuted(x.shape, blockShape, prod); - const sliceBeginCoords = - backend_util.getSliceBeginCoords(crops, blockShape.length); - const sliceSize = - backend_util.getSliceSize(reshapedPermuted, crops, blockShape.length); - - const toDispose = []; - - const reshapedIntermediate = - reshape({inputs: {x}, backend, attrs: {shape: reshaped}}); - const transposedIntermediate = transpose( - {inputs: {x: reshapedIntermediate}, backend, attrs: {perm: permuted}}); - const reshapedIntermediate2 = reshape({ - inputs: {x: transposedIntermediate}, - backend, - attrs: {shape: reshapedPermuted} - }); - const sliced = slice({ - inputs: {x: reshapedIntermediate2}, - backend, - attrs: {begin: sliceBeginCoords, size: sliceSize} - }); - - toDispose.push(reshapedIntermediate); - toDispose.push(transposedIntermediate); - toDispose.push(reshapedIntermediate2); - - toDispose.forEach(t => backend.disposeData(t.dataId)); - - return sliced; -}; - -export const batchToSpaceNDConfig: KernelConfig = { - kernelName: BatchToSpaceND, - backendName: 'webgpu', - kernelFunc: batchToSpaceND as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Bincount.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Bincount.ts deleted file mode 100644 index a287ecfb8..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Bincount.ts +++ /dev/null @@ -1,53 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Bincount, BincountAttrs, BincountInputs, KernelConfig, KernelFunc, TensorInfo, util} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {BincountProgram} from '../bincount_webgpu'; - -import {fill} from './Fill'; - -export function bincount( - args: - {inputs: BincountInputs, backend: WebGPUBackend, attrs: BincountAttrs}): - TensorInfo { - const {inputs, backend, attrs} = args; - const {x, weights} = inputs; - const {size} = attrs; - - const xSize = util.sizeFromShape(x.shape); - const weightsSize = util.sizeFromShape(weights.shape); - const hasWeights = weightsSize > 0; - const outputSize: [number] = [size]; - const dtype = weights.dtype; - - const output = fill({backend, attrs: {shape: outputSize, value: 0, dtype}}); - const program = new BincountProgram([xSize], hasWeights); - const uniformData = [{type: 'int32', data: [size]}]; - const bincountInputs: TensorInfo[] = hasWeights ? [x, weights] : [x]; - const res = backend.runWebGPUProgram( - program, bincountInputs, dtype, uniformData, output); - - return res; -} - -export const bincountConfig: KernelConfig = { - kernelName: Bincount, - backendName: 'webgpu', - kernelFunc: bincount as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/BroadcastArgs.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/BroadcastArgs.ts deleted file mode 100644 index 6340995c0..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/BroadcastArgs.ts +++ /dev/null @@ -1,55 +0,0 @@ -/** - * @license - * Copyright 2023 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, BroadcastArgs, BroadcastArgsInputs, KernelConfig, KernelFunc, TensorInfo, TypedArray, util} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {BroadcastArgsProgram} from '../broadcast_args_webgpu'; - -export function broadcastArgs(args: { - inputs: BroadcastArgsInputs, - backend: WebGPUBackend, -}): TensorInfo { - const {inputs, backend} = args; - const {s0, s1} = inputs; - - if (backend.shouldExecuteOnCPU([s0, s1])) { - const s0TensorInfo = backend.tensorMap.get(s0.dataId); - const s1TensorInfo = backend.tensorMap.get(s1.dataId); - const s0Vals = s0TensorInfo.values as TypedArray; - const s1Vals = s1TensorInfo.values as TypedArray; - const broadcastShape = backend_util.assertAndGetBroadcastShape( - Array.from(s0Vals), Array.from(s1Vals)); - return backend.makeTensorInfo( - [broadcastShape.length], 'int32', Int32Array.from(broadcastShape)); - } - - const s0Size = util.sizeFromShape(s0.shape); - const s1Size = util.sizeFromShape(s1.shape); - const outputSize = Math.max(s0Size, s1Size); - - const program = new BroadcastArgsProgram(outputSize); - const uniformData = - [{type: 'int32', data: [s0Size]}, {type: 'int32', data: [s1Size]}]; - return backend.runWebGPUProgram(program, [s0, s1], 'int32', uniformData); -} - -export const broadcastArgsConfig: KernelConfig = { - kernelName: BroadcastArgs, - backendName: 'webgpu', - kernelFunc: broadcastArgs as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Cast.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Cast.ts deleted file mode 100644 index 57388b8b0..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Cast.ts +++ /dev/null @@ -1,100 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import * as tf from '@tensorflow/tfjs-core'; -import {BinaryInputs, Cast, CastAttrs, CastInputs, KernelConfig, KernelFunc, TensorInfo, TypedArray, util} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {castImplCPU} from '../kernel_utils/shared'; - -import {complex} from './Complex'; -import {identity} from './Identity'; -import {notEqual} from './NotEqual'; -import {real} from './Real'; - -import {int} from '../kernel_utils/int'; - -export function cast( - args: {inputs: CastInputs, backend: WebGPUBackend, attrs: CastAttrs}): - TensorInfo { - const {inputs, backend, attrs} = args; - const {x} = inputs; - const {dtype} = attrs; - - // Casting to complex64. - if (dtype === 'complex64') { - if (x.dtype === 'complex64') { - return identity({inputs: {x}, backend}); - } - - // TODO: Import kernel function once zeros is modularized. - const zerosTensor = tf.zeros(x.shape); - const floatX = cast({inputs: {x}, backend, attrs: {dtype: 'float32'}}); - - const result = - complex({inputs: {real: floatX, imag: zerosTensor}, backend}); - - zerosTensor.dispose(); - backend.disposeData(floatX.dataId); - - return result; - } - - // Casting from complex64 - if (x.dtype === 'complex64') { - const realPart = real({inputs: {input: x}, backend}); - const result = cast({inputs: {x: realPart}, backend, attrs: {dtype}}); - backend.disposeData(realPart.dataId); - return result; - } - - if (!util.hasEncodingLoss(x.dtype, dtype)) { - // We don't change the underlying data, since we cast to higher - // precision. - const result = identity({inputs: {x}, backend}); - return {dataId: result.dataId, shape: result.shape, dtype}; - } - - if (backend.shouldExecuteOnCPU([x])) { - const values = backend.tensorMap.get(x.dataId).values as TypedArray; - const [resultShape, resultType, resultData] = - castImplCPU(values, x.shape, x.dtype, dtype); - return backend.makeTensorInfo(resultShape, resultType, resultData); - } - - if (dtype === 'int32') { - return int(x, backend); - } - - if (dtype === 'bool') { - const zerosTensorInfo = backend.makeTensorInfo( - [], 'bool', util.getTypedArrayFromDType('bool', 1)); - - const binaryInputs: BinaryInputs = {a: x, b: zerosTensorInfo}; - - const result = notEqual({inputs: binaryInputs, backend}) as TensorInfo; - backend.disposeData(zerosTensorInfo.dataId); - return result; - } - - throw new Error(`Error in Cast: failed to cast ${x.dtype} to ${dtype}`); -} - -export const castConfig: KernelConfig = { - kernelName: Cast, - backendName: 'webgpu', - kernelFunc: cast as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Ceil.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Ceil.ts deleted file mode 100644 index d1c443f88..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Ceil.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Ceil, KernelConfig} from '@tensorflow/tfjs-core'; -import {unaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; -import {ceilImplCPU} from '../kernel_utils/shared'; -import {UnaryOpType} from '../unary_op_util'; - -export const ceil = - unaryKernelFunc({opType: UnaryOpType.CEIL, cpuKernelImpl: ceilImplCPU}); - -export const ceilConfig: KernelConfig = { - kernelName: Ceil, - backendName: 'webgpu', - kernelFunc: ceil -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/ClipByValue.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/ClipByValue.ts deleted file mode 100644 index 03f9de350..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/ClipByValue.ts +++ /dev/null @@ -1,51 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ClipByValue, ClipByValueAttrs, ClipByValueInputs, KernelConfig, KernelFunc, TensorInfo, util} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; - -import {ClipVec4Program} from '../clip_vec4_webgpu'; -import {ClipProgram} from '../clip_webgpu'; - -export function clipByValue(args: { - inputs: ClipByValueInputs, - backend: WebGPUBackend, - attrs: ClipByValueAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {x} = inputs; - const {clipValueMin, clipValueMax} = attrs; - - let program: ClipProgram|ClipVec4Program; - const uniformData = [ - {type: 'float32', data: [clipValueMin]}, - {type: 'float32', data: [clipValueMax]} - ]; - if (util.sizeFromShape(x.shape) % 4 === 0) { - program = new ClipVec4Program(x.shape); - } else { - program = new ClipProgram(x.shape); - } - return backend.runWebGPUProgram(program, [x], x.dtype, uniformData); -} - -export const clipByValueConfig: KernelConfig = { - kernelName: ClipByValue, - backendName: 'webgpu', - kernelFunc: clipByValue as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Complex.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Complex.ts deleted file mode 100644 index e2ed33c70..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Complex.ts +++ /dev/null @@ -1,52 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Complex, ComplexInputs, KernelConfig, KernelFunc, TensorInfo} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {identity} from './Identity'; - -/** - * Complex tensors share data with their real and imaginary components. Complex - * tensors' reference to the components is tracked by refCount on the individual - * component. The refCounts are increased by the identity call. - * - * When a complex tensor is disposed, it will reduce the refCount on the - * components by calling disposeData on each. - */ -export function complex(args: {inputs: ComplexInputs, backend: WebGPUBackend}): - TensorInfo { - const {inputs, backend} = args; - const {real, imag} = inputs; - - const complexInfo = backend.makeTensorInfo(real.shape, 'complex64'); - const complex = backend.tensorMap.get(complexInfo.dataId); - - const realTensorInfo = identity({inputs: {x: real}, backend}); - - const imagTensorInfo = identity({inputs: {x: imag}, backend}); - - complex.complexTensorInfos = {real: realTensorInfo, imag: imagTensorInfo}; - - return complexInfo; -} - -export const complexConfig: KernelConfig = { - kernelName: Complex, - backendName: 'webgpu', - kernelFunc: complex as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/ComplexAbs.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/ComplexAbs.ts deleted file mode 100644 index ea27ad0af..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/ComplexAbs.ts +++ /dev/null @@ -1,56 +0,0 @@ -/** - * @license - * Copyright 2023 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ComplexAbs, ComplexAbsInputs, KernelConfig, KernelFunc, TensorInfo} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {ComplexAbsProgram} from '../complex_abs_webgpu'; - -// Returns a TensorInfo with the complex shape and the dataId of the -// underlying part. We need to do this because a reshaped complex tensor is -// not reflected in its parts. -function makeComplexComponentTensorInfo( - complexTensor: TensorInfo, complexPart: TensorInfo): TensorInfo { - return { - dataId: complexPart.dataId, - dtype: complexPart.dtype, - shape: complexTensor.shape - }; -} - -export function complexAbs( - args: {inputs: ComplexAbsInputs, backend: WebGPUBackend}): TensorInfo { - const {inputs, backend} = args; - const {x} = inputs; - - const xData = backend.tensorMap.get(x.dataId); - - const program = new ComplexAbsProgram(x.shape); - const programInputs = [ - makeComplexComponentTensorInfo(x, xData.complexTensorInfos.real), - makeComplexComponentTensorInfo(x, xData.complexTensorInfos.imag), - ]; - - return backend.runWebGPUProgram( - program, programInputs, programInputs[0].dtype); -} - -export const complexAbsConfig: KernelConfig = { - kernelName: ComplexAbs, - backendName: 'webgpu', - kernelFunc: complexAbs as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Concat.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Concat.ts deleted file mode 100644 index 7d1866463..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Concat.ts +++ /dev/null @@ -1,55 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, Concat, ConcatAttrs, ConcatInputs, KernelConfig, KernelFunc, TensorInfo, util} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; - -import {concatImpl} from './Concat_impl'; -import {identity} from './Identity'; - -export function concat( - args: {inputs: ConcatInputs, attrs: ConcatAttrs, backend: WebGPUBackend}): - TensorInfo { - const {inputs, backend, attrs} = args; - const {axis} = attrs; - - const $axis = util.parseAxisParam(axis, inputs[0].shape)[0]; - - const shapes = inputs.map(t => t.shape); - backend_util.assertParamsConsistent(shapes, $axis); - - const outShape = - backend_util.computeOutShape(inputs.map(t => t.shape), $axis); - if (util.sizeFromShape(outShape) === 0) { - return backend.makeTensorInfo(outShape, inputs[0].dtype, []); - } - - // Keep only non-empty tensors (ignore tensors with 0 in their shape). - const $inputs = inputs.filter(t => util.sizeFromShape(t.shape) > 0); - if ($inputs.length === 1) { - return identity({inputs: {x: $inputs[0]}, backend}); - } - - return concatImpl($inputs, $axis, backend); -} - -export const concatConfig: KernelConfig = { - kernelName: Concat, - backendName: 'webgpu', - kernelFunc: concat as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Concat_impl.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Concat_impl.ts deleted file mode 100644 index 2d98f35bb..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Concat_impl.ts +++ /dev/null @@ -1,155 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, ConcatInputs, TensorInfo, util} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {ConcatProgram} from '../concat_webgpu'; -import {concatImplCPU} from '../kernel_utils/shared'; - -import {complex} from './Complex'; -import {imag} from './Imag'; -import {real} from './Real'; -import {reshape} from './Reshape'; - -export function concatImpl( - inputs: ConcatInputs, axis: number, backend: WebGPUBackend): TensorInfo { - const dtype = inputs[0].dtype; - if (dtype === 'complex64') { - const reals = inputs.map((t) => real({inputs: {input: t}, backend})); - const imags = inputs.map((t) => imag({inputs: {input: t}, backend})); - - const realConcated = concatImpl(reals, axis, backend); - const imagConcated = concatImpl(imags, axis, backend); - - const result = - complex({inputs: {real: realConcated, imag: imagConcated}, backend}); - - reals.forEach(r => backend.disposeData(r.dataId)); - imags.forEach(i => backend.disposeData(i.dataId)); - backend.disposeData(realConcated.dataId); - backend.disposeData(imagConcated.dataId); - - return result; - } - - let runOnCpu = backend.shouldExecuteOnCPU(inputs); - - // Run on cpu if dtype is string. For string, the backend represents it - // as Uint8Array[], where each Uint8Array is a character. Given that the - // computation is only on the outer array, uploading the whole data onto - // gpu is wasteful. Also, currently webgpu doesn't have a design to - // upload and retrieve Uint8Array[] between cpu and gpu. Therefore, we - // just run the kernel on cpu if dtype is string. - if (dtype === 'string') { - runOnCpu = true; - } - - if (runOnCpu) { - // Any concat of n-dimensional tensors across any axis can be reduced to - // a concatenation of two-dimensional tensors across the axis 1 by first - // partitioning the axes of the original tensors into those less than the - // axis to be concatenated and the rest. Then reshape the tensors - // into a two-dimensional tensor by collapsing these two sets of axes and - // concatenate the resulting matrices across the axis 1, finally reshaping - // the result to have the proper shape. - const tensors2D = inputs.map(t => { - const innerSize = util.sizeFromShape(t.shape.slice(axis)); - const shape = [-1, innerSize]; - return reshape({inputs: {x: t}, backend, attrs: {shape}}); - }); - - const inputsValShapes = tensors2D.map(t => { - return {vals: backend.readSync(t.dataId), shape: t.shape}; - }); - - // Concats 2d tensors along axis=1. - const outShape = - backend_util.computeOutShape(tensors2D.map(t => t.shape), 1 /* axis */); - const simplyConcat = tensors2D[0].shape[0] === 1; - const outVals = - concatImplCPU(inputsValShapes, outShape, dtype, simplyConcat); - - const finalOutShape = - backend_util.computeOutShape(inputs.map(t => t.shape), axis); - - const outInfo = backend.makeTensorInfo(finalOutShape, dtype, outVals); - - tensors2D.forEach(t => backend.disposeData(t.dataId)); - - return outInfo; - } - - // There is a storage buffer limitation in compute stage, one for output so - // the maximum for input is limits.maxStorageBuffersPerShaderStage - 1 - const maxInputNum = backend.device.limits.maxStorageBuffersPerShaderStage - 1; - if (inputs.length > maxInputNum) { - const reducedInputs = []; - for (let i = 0; i < inputs.length; i += maxInputNum) { - const subArray = inputs.slice(i, i + maxInputNum); - reducedInputs.push(concatImpl(subArray, axis, backend)); - } - const result = concatImpl(reducedInputs, axis, backend); - - for (const i of reducedInputs) { - backend.disposeData(i.dataId); - } - - return result; - } - - const {tensors2D, outShape} = computeTensors2D(inputs, axis, backend); - const shapes = (tensors2D).map(t => t.shape as [number, number]); - const program = new ConcatProgram(shapes); - - const uniformData: Array<{type: string; data: number[]}> = []; - const offsets: number[] = new Array(shapes.length - 1); - if (offsets.length > 0) { - offsets[0] = shapes[0][1]; - uniformData.push({type: 'int32', data: [offsets[0]]}); - for (let i = 1; i < offsets.length; i++) { - offsets[i] = offsets[i - 1] + shapes[i][1]; - uniformData.push({type: 'int32', data: [offsets[i]]}); - } - } - - const res = backend.runWebGPUProgram( - program, tensors2D, tensors2D[0].dtype, uniformData); - tensors2D.forEach(r => backend.disposeData(r.dataId)); - - const reshapedResult = - reshape({inputs: {x: res}, backend, attrs: {shape: outShape}}); - backend.disposeData(res.dataId); - return reshapedResult; -} - -function computeTensors2D( - inputs: ConcatInputs, axis: number, backend: WebGPUBackend) { - const outShape = backend_util.computeOutShape(inputs.map(t => t.shape), axis); - const tensors2D = inputs.map(t => reshape({ - inputs: {x: t}, - backend, - attrs: { - shape: [ - util.sizeFromShape(t.shape.slice(0, axis)), - util.sizeFromShape(t.shape.slice(axis)) - ] - } - })); - - return {tensors2D, outShape}; -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Conv2D.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Conv2D.ts deleted file mode 100644 index 5ec5b4103..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Conv2D.ts +++ /dev/null @@ -1,41 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, Conv2D, Conv2DAttrs, Conv2DInputs, KernelConfig, KernelFunc} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; - -import {conv2DImpl} from './Conv2D_impl'; - -export function conv2d( - args: {inputs: Conv2DInputs, attrs: Conv2DAttrs, backend: WebGPUBackend}) { - const {inputs, attrs, backend} = args; - const {x, filter} = inputs; - const {strides, pad, dataFormat, dilations, dimRoundingMode} = attrs; - const $dataFormat = backend_util.convertConv2DDataFormat(dataFormat); - const convInfo = backend_util.computeConv2DInfo( - x.shape as [number, number, number, number], - filter.shape as [number, number, number, number], strides, dilations, pad, - dimRoundingMode, false /* depthwise */, $dataFormat); - return conv2DImpl({x, filter, convInfo, backend}); -} - -export const conv2DConfig: KernelConfig = { - kernelName: Conv2D, - backendName: 'webgpu', - kernelFunc: conv2d as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Conv2DBackpropFilter.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Conv2DBackpropFilter.ts deleted file mode 100644 index 0783eeb8e..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Conv2DBackpropFilter.ts +++ /dev/null @@ -1,55 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, Conv2DBackpropFilter, Conv2DBackpropFilterAttrs, Conv2DBackpropFilterInputs, KernelConfig, KernelFunc, TensorInfo} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {Conv2DDerFilterProgram} from '../conv_backprop_webgpu'; - -export function conv2DBackpropFilter(args: { - inputs: Conv2DBackpropFilterInputs, - backend: WebGPUBackend, - attrs: Conv2DBackpropFilterAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {x, dy} = inputs; - const {strides, pad, dataFormat, dimRoundingMode, filterShape} = attrs; - - const $dataFormat = backend_util.convertConv2DDataFormat(dataFormat); - const convInfo = backend_util.computeConv2DInfo( - x.shape as [number, number, number, number], filterShape, strides, - 1 /* dilations */, pad, dimRoundingMode, false /* depthwise */, - $dataFormat); - - const program = new Conv2DDerFilterProgram(convInfo); - const uniformData = [ - {type: 'int32', data: [convInfo.padInfo.top, convInfo.padInfo.left]}, - {type: 'int32', data: [convInfo.strideHeight, convInfo.strideWidth]}, - {type: 'int32', data: [convInfo.batchSize]}, - {type: 'int32', data: [convInfo.outHeight]}, - {type: 'int32', data: [convInfo.outWidth]}, - {type: 'int32', data: [convInfo.inHeight]}, - {type: 'int32', data: [convInfo.inWidth]} - ]; - return backend.runWebGPUProgram(program, [x, dy], x.dtype, uniformData); -} - -export const conv2DBackpropFilterConfig: KernelConfig = { - kernelName: Conv2DBackpropFilter, - backendName: 'webgpu', - kernelFunc: conv2DBackpropFilter as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Conv2DBackpropInput.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Conv2DBackpropInput.ts deleted file mode 100644 index 3c99755cb..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Conv2DBackpropInput.ts +++ /dev/null @@ -1,79 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, Conv2DBackpropInput, Conv2DBackpropInputAttrs, Conv2DBackpropInputInputs, env, KernelConfig, KernelFunc} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {Conv2DDerInputMMProgram} from '../conv_backprop_mm_webgpu'; -import {Conv2DDerInputProgram} from '../conv_backprop_webgpu'; - -export function conv2DBackpropInput(args: { - inputs: Conv2DBackpropInputInputs, - attrs: Conv2DBackpropInputAttrs, - backend: WebGPUBackend -}) { - const {inputs, backend, attrs} = args; - const {dy, filter} = inputs; - const {inputShape, strides, pad, dataFormat, dimRoundingMode} = attrs; - - const $dataFormat = backend_util.convertConv2DDataFormat(dataFormat); - const convInfo = backend_util.computeConv2DInfo( - inputShape, filter.shape as [number, number, number, number], strides, - 1 /* dilations */, pad, dimRoundingMode, false, $dataFormat); - - const dimensions = [ - {type: 'int32', data: [convInfo.filterHeight, convInfo.filterWidth]}, - { - type: 'int32', - data: [ - convInfo.filterHeight - 1 - convInfo.padInfo.top, - convInfo.filterWidth - 1 - convInfo.padInfo.left - ] - }, - {type: 'int32', data: [convInfo.strideHeight, convInfo.strideWidth]}, - { - type: 'int32', - data: [ - convInfo.batchSize, convInfo.outHeight, convInfo.outWidth, - convInfo.outChannels - ] - }, - ]; - let program: Conv2DDerInputProgram|Conv2DDerInputMMProgram; - // TODO: Experiment when to use Conv2DDerInputMMProgram algorithm. - if (env().getBool('WEBGPU_USE_NAIVE_CONV2D_TRANSPOSE') || - convInfo.dataFormat !== 'channelsLast') { - program = new Conv2DDerInputProgram(convInfo); - } else { - program = new Conv2DDerInputMMProgram(convInfo); - const dimAOuter = convInfo.inHeight * convInfo.inWidth; - const dimBOuter = convInfo.inChannels; - const dimInner = - convInfo.filterHeight * convInfo.filterWidth * convInfo.outChannels; - dimensions.push( - {type: 'uint32', data: [dimAOuter]}, - {type: 'uint32', data: [dimBOuter]}, - {type: 'uint32', data: [dimInner]}); - } - return backend.runWebGPUProgram(program, [dy, filter], 'float32', dimensions); -} - -export const conv2DBackpropInputConfig: KernelConfig = { - kernelName: Conv2DBackpropInput, - backendName: 'webgpu', - kernelFunc: conv2DBackpropInput as unknown as KernelFunc, -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Conv2D_impl.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Conv2D_impl.ts deleted file mode 100644 index 05c4c4d94..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Conv2D_impl.ts +++ /dev/null @@ -1,394 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, env, TensorInfo} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {Conv2DMMProgram} from '../conv2d_mm_webgpu'; -import {Conv2DNaiveProgram} from '../conv2d_naive_webgpu'; -import {Im2ColProgram} from '../im2col_webgpu'; -import {WebGPUProgram} from '../webgpu_program'; - -import {batchMatMulImpl} from './BatchMatMul_impl'; -import {reshape} from './Reshape'; - -type Conv2DConfig = { - x: TensorInfo, - filter: TensorInfo, - convInfo: backend_util.Conv2DInfo, - backend: WebGPUBackend, - bias?: TensorInfo, - preluActivationWeights?: TensorInfo, - leakyreluAlpha?: number, - activation?: backend_util.Activation -}; - -// conv2dByMatMul fuses height and width into one dimension to compute -// batchMatMul, so bias and activation weights are also supposed to fuse the two -// dimensions into one. -// -// This function computes the target shape for fusing height and width -// dimensions. Returning null means the shape is already compatible. -function getShapeForBatchMatMul( - shape: number[], isChannelsLast: boolean): number[] { - const length = shape.length; - if (length >= 3) { - return isChannelsLast ? - [ - ...shape.slice(0, -3) /* batch */, - shape[length - 3] * shape[length - 2] /* height * width */, - shape[length - 1] /* channel */ - ] : - [ - ...shape.slice(0, -3) /* batch */, shape[length - 3] /* channel */, - shape[length - 2] * shape[length - 1] /* height * width */ - ]; - } else if (!isChannelsLast && length === 1 && shape[0] > 1) { - return [shape[0], 1]; - } else { - return null; - } -} - -// For 1x1 kernels that iterate through every point in the input, convolution -// can be expressed as matrix multiplication (without need for memory -// remapping). -function conv2dByMatMul({ - x, - filter, - convInfo, - backend, - bias = null, - preluActivationWeights = null, - leakyreluAlpha = 0, - activation = null -}: Conv2DConfig) { - const isChannelsLast = convInfo.dataFormat === 'channelsLast'; - const transposeA = isChannelsLast ? false : true; - const transposeB = false; - - const sameSize = isChannelsLast && - convInfo.filterHeight === convInfo.inHeight && - convInfo.filterWidth === convInfo.inWidth && - convInfo.padInfo.type === 'VALID'; - const intermediates: TensorInfo[] = []; - let xReshaped; - let filterReshaped; - - if (sameSize) { - const sharedDim = - convInfo.inHeight * convInfo.inWidth * convInfo.inChannels; - xReshaped = reshape({ - inputs: {x}, - backend, - attrs: {shape: [1, convInfo.batchSize, sharedDim]} - }); - filterReshaped = reshape({ - inputs: {x: filter}, - backend, - attrs: {shape: [1, sharedDim, convInfo.outChannels]} - }); - } else { - xReshaped = reshape({ - inputs: {x}, - backend, - attrs: { - shape: isChannelsLast ? - [ - convInfo.batchSize, convInfo.inHeight * convInfo.inWidth, - convInfo.inChannels - ] : - [ - convInfo.batchSize, convInfo.inChannels, - convInfo.inHeight * convInfo.inWidth - ] - } - }); - filterReshaped = reshape({ - inputs: {x: filter}, - backend, - attrs: {shape: [1, convInfo.inChannels, convInfo.outChannels]} - }); - } - intermediates.push(xReshaped); - intermediates.push(filterReshaped); - - if (preluActivationWeights != null) { - const targetShape = - getShapeForBatchMatMul(preluActivationWeights.shape, isChannelsLast); - if (targetShape != null) { - preluActivationWeights = reshape({ - inputs: {x: preluActivationWeights}, - backend, - attrs: {shape: targetShape} - }); - intermediates.push(preluActivationWeights); - } - } - - if (bias != null) { - const targetShape = getShapeForBatchMatMul(bias.shape, isChannelsLast); - if (targetShape != null) { - bias = reshape({inputs: {x: bias}, backend, attrs: {shape: targetShape}}); - intermediates.push(bias); - } - } - - const result = batchMatMulImpl({ - a: isChannelsLast ? xReshaped : filterReshaped, - b: isChannelsLast ? filterReshaped : xReshaped, - transposeA, - transposeB, - backend, - bias, - activation, - preluActivationWeights, - leakyreluAlpha - }); - const out = reshape( - {inputs: {x: result}, backend, attrs: {shape: convInfo.outShape}}); - intermediates.push(result); - - for (const i of intermediates) { - backend.disposeData(i.dataId); - } - - return out; -} - -// Implements the im2col algorithm as outlined in "High Performance -// Convolutional Neural Networks for Document Processing" (Suvisoft, 2006) -function conv2dWithIm2Col({ - x, - filter, - convInfo, - backend, - bias = null, - preluActivationWeights = null, - leakyreluAlpha = 0, - activation = null -}: Conv2DConfig) { - // Rearranges conv2d input so each block to be convolved over forms the - // row of a new matrix with shape [outHeight * outWidth, - // filterWidth * filterHeight * inChannels]. The filter is also rearranged so - // each output channel forms a col of a new matrix with shape [ - // filterWidth * filterHeight * inChannels, outChannels]. The convolution is - // then computed by multiplying these matrices and reshaping the result. - const { - filterWidth, - filterHeight, - inChannels, - strideWidth, - strideHeight, - padInfo, - outWidth, - outHeight, - dilationWidth, - dilationHeight, - dataFormat - } = convInfo; - - const isChannelsLast = dataFormat === 'channelsLast'; - - const sharedDim = filterWidth * filterHeight * inChannels; - const numCols = outHeight * outWidth; - const x2ColShape = isChannelsLast ? [convInfo.batchSize, numCols, sharedDim] : - [convInfo.batchSize, sharedDim, numCols]; - - const im2ColProgram = new Im2ColProgram(x2ColShape, isChannelsLast); - const dimensions = [ - {type: 'int32', data: [padInfo.top, padInfo.left]}, // Padding. - {type: 'int32', data: [strideHeight, strideWidth]}, // Stride. - {type: 'int32', data: [dilationHeight, dilationWidth]}, // Dilation. - {type: 'int32', data: [outWidth]}, - {type: 'int32', data: [inChannels * filterWidth]}, // itemsPerBlockRow. - {type: 'int32', data: [inChannels]} - ]; - const x2Col = - backend.runWebGPUProgram(im2ColProgram, [x], x.dtype, dimensions); - - const intermediates: TensorInfo[] = []; - intermediates.push(x2Col); - - const filterReshaped = reshape( - {inputs: {x: filter}, backend, attrs: {shape: [1, sharedDim, -1]}}); - intermediates.push(filterReshaped); - - if (preluActivationWeights != null) { - const targetShape = - getShapeForBatchMatMul(preluActivationWeights.shape, isChannelsLast); - if (targetShape != null) { - preluActivationWeights = reshape({ - inputs: {x: preluActivationWeights}, - backend, - attrs: {shape: targetShape} - }); - intermediates.push(preluActivationWeights); - } - } - - if (bias != null) { - const targetShape = getShapeForBatchMatMul(bias.shape, isChannelsLast); - if (targetShape != null) { - bias = reshape({inputs: {x: bias}, backend, attrs: {shape: targetShape}}); - intermediates.push(bias); - } - } - - const transposeA = isChannelsLast ? false : true; - const transposeB = false; - const result = batchMatMulImpl({ - a: isChannelsLast ? x2Col : filterReshaped, - b: isChannelsLast ? filterReshaped : x2Col, - transposeA, - transposeB, - backend, - bias, - activation, - preluActivationWeights, - leakyreluAlpha - }); - const out = reshape( - {inputs: {x: result}, backend, attrs: {shape: convInfo.outShape}}); - intermediates.push(result); - for (const i of intermediates) { - backend.disposeData(i.dataId); - } - - return out; -} - -export function conv2DImpl({ - x, - filter, - convInfo, - backend, - bias = null, - preluActivationWeights = null, - leakyreluAlpha = 0, - activation = null -}: Conv2DConfig) { - const hasBias = bias != null; - const hasPreluActivationWeights = preluActivationWeights != null; - const isChannelsLast = convInfo.dataFormat === 'channelsLast'; - const sameSize = isChannelsLast && - convInfo.filterHeight === convInfo.inHeight && - convInfo.filterWidth === convInfo.inWidth && - convInfo.padInfo.type === 'VALID'; - const useNaiveConv2d = env().getBool('WEBGPU_USE_NAIVE_CONV2D_DEBUG'); - - if (!useNaiveConv2d && - (sameSize || - (convInfo.filterHeight === 1 && convInfo.filterWidth === 1 && - convInfo.dilationHeight === 1 && convInfo.dilationWidth === 1 && - convInfo.strideHeight === 1 && convInfo.strideWidth === 1 && - (convInfo.padInfo.type === 'SAME' || - convInfo.padInfo.type === 'VALID')))) { - return conv2dByMatMul({ - x, - filter, - convInfo, - backend, - bias, - activation, - preluActivationWeights, - leakyreluAlpha - }); - } - - const thresholdFlagValue = - env().getNumber('WEBGPU_THRESHOLD_TO_INCREASE_WORKGROUPS_FOR_MATMUL'); - const thresholdToIncreaseWorkgroups = thresholdFlagValue > -1 ? - thresholdFlagValue : - backend.thresholdToIncreaseWorkgroups; - const workgroupsBy32x32 = convInfo.batchSize * - Math.ceil((convInfo.outHeight * convInfo.outWidth) / 32) * - Math.ceil(convInfo.outChannels / 32); - if (env().getBool('WEBGPU_CONV_SEPARATE_IM2COL_SHADER') || - workgroupsBy32x32 <= thresholdToIncreaseWorkgroups) { - return conv2dWithIm2Col({ - x, - filter, - convInfo, - backend, - bias, - preluActivationWeights, - leakyreluAlpha, - activation - }); - } - - let program: WebGPUProgram; - const padInfo = [convInfo.padInfo.top, convInfo.padInfo.left]; - const dimensions = [ - {type: 'int32', data: [convInfo.filterHeight, convInfo.filterWidth]}, - {type: 'int32', data: [...padInfo]}, - {type: 'int32', data: [convInfo.strideHeight, convInfo.strideWidth]}, - {type: 'int32', data: [convInfo.dilationHeight, convInfo.dilationWidth]} - ]; - if (useNaiveConv2d) { - program = new Conv2DNaiveProgram( - convInfo, hasBias, activation, hasPreluActivationWeights); - } else { - const dimAOuter = isChannelsLast ? convInfo.outHeight * convInfo.outWidth : - convInfo.outChannels; - const dimBOuter = isChannelsLast ? convInfo.outChannels : - convInfo.outHeight * convInfo.outWidth; - const dimInner = - convInfo.filterHeight * convInfo.filterWidth * convInfo.inChannels; - dimensions.push( - {type: 'int32', data: [dimAOuter]}, {type: 'int32', data: [dimBOuter]}, - {type: 'int32', data: [dimInner]}); - - // Experiments show that sequential access is more friendly for Intel GPUs. - const sequentialAccessByThreads = backend.adapterInfo.isIntel(); - program = new Conv2DMMProgram( - convInfo, dimAOuter, dimBOuter, dimInner, hasBias, activation, - hasPreluActivationWeights, sequentialAccessByThreads); - } - - const intermediates: TensorInfo[] = []; - const inputVar: TensorInfo[] = [x, filter]; - if (hasBias) { - if (!isChannelsLast && bias.shape.length === 1) { - bias = reshape( - {inputs: {x: bias}, backend, attrs: {shape: [bias.shape[0], 1, 1]}}); - intermediates.push(bias); - } - inputVar.push(bias); - } - if (hasPreluActivationWeights) { - if (!isChannelsLast && preluActivationWeights.shape.length === 1) { - preluActivationWeights = reshape({ - inputs: {x: preluActivationWeights}, - backend, - attrs: {shape: [preluActivationWeights.shape[0], 1, 1]} - }); - intermediates.push(preluActivationWeights); - } - inputVar.push(preluActivationWeights); - } - if (activation === 'leakyrelu') { - dimensions.push({type: 'float32', data: [leakyreluAlpha]}); - program.uniforms += ' alpha : f32,'; - } - const out = backend.runWebGPUProgram(program, inputVar, x.dtype, dimensions); - for (const i of intermediates) { - backend.disposeData(i.dataId); - } - return out; -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Conv3D.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Conv3D.ts deleted file mode 100644 index a8bc7a6da..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Conv3D.ts +++ /dev/null @@ -1,61 +0,0 @@ -/** - * @license - * Copyright 2023 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, Conv3D, Conv3DAttrs, Conv3DInputs, KernelConfig, KernelFunc, upcastType} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {Conv3DNaiveProgram} from '../conv3d_naive_webgpu'; - -export function conv3D( - args: {inputs: Conv3DInputs, attrs: Conv3DAttrs, backend: WebGPUBackend}) { - const {inputs, backend, attrs} = args; - const {x, filter} = inputs; - const {strides, pad, dilations} = attrs; - - const convInfo = backend_util.computeConv3DInfo( - x.shape as [number, number, number, number, number], - filter.shape as [number, number, number, number, number], strides, - dilations, pad); - - const padInfo = - [convInfo.padInfo.front, convInfo.padInfo.top, convInfo.padInfo.left]; - const dimensions = [ - { - type: 'int32', - data: [convInfo.filterDepth, convInfo.filterHeight, convInfo.filterWidth] - }, - {type: 'int32', data: [...padInfo]}, { - type: 'int32', - data: [convInfo.strideDepth, convInfo.strideHeight, convInfo.strideWidth] - }, - { - type: 'int32', - data: [ - convInfo.dilationDepth, convInfo.dilationHeight, convInfo.dilationWidth - ] - } - ]; - const program = new Conv3DNaiveProgram(convInfo); - const dtype = upcastType(x.dtype, filter.dtype); - return backend.runWebGPUProgram(program, [x, filter], dtype, dimensions); -} - -export const conv3DConfig: KernelConfig = { - kernelName: Conv3D, - backendName: 'webgpu', - kernelFunc: conv3D as {} as KernelFunc, -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Conv3DBackpropFilterV2.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Conv3DBackpropFilterV2.ts deleted file mode 100644 index 22c22f026..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Conv3DBackpropFilterV2.ts +++ /dev/null @@ -1,62 +0,0 @@ -/** - * @license - * Copyright 2023 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, Conv3DBackpropFilterV2, Conv3DBackpropFilterV2Attrs, Conv3DBackpropFilterV2Inputs, KernelConfig, KernelFunc, TensorInfo} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {Conv3DDerFilterProgram} from '../conv_backprop_webgpu'; - -export function conv3DBackpropFilterV2(args: { - inputs: Conv3DBackpropFilterV2Inputs, - attrs: Conv3DBackpropFilterV2Attrs, - backend: WebGPUBackend, -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {x, dy} = inputs; - const {strides, pad, filterShape} = attrs; - - const convInfo = backend_util.computeConv3DInfo( - x.shape as [number, number, number, number, number], filterShape, strides, - 1 /* dilations */, pad); - - const program = new Conv3DDerFilterProgram(convInfo); - const uniformData = [ - { - type: 'int32', - data: - [convInfo.padInfo.front, convInfo.padInfo.top, convInfo.padInfo.left] - }, - { - type: 'int32', - data: [convInfo.strideDepth, convInfo.strideHeight, convInfo.strideWidth] - }, - {type: 'int32', data: [convInfo.batchSize]}, - {type: 'int32', data: [convInfo.outDepth]}, - {type: 'int32', data: [convInfo.outHeight]}, - {type: 'int32', data: [convInfo.outWidth]}, - {type: 'int32', data: [convInfo.inDepth]}, - {type: 'int32', data: [convInfo.inHeight]}, - {type: 'int32', data: [convInfo.inWidth]} - ]; - return backend.runWebGPUProgram(program, [x, dy], dy.dtype, uniformData); -} - -export const conv3DBackpropFilterV2Config: KernelConfig = { - kernelName: Conv3DBackpropFilterV2, - backendName: 'webgpu', - kernelFunc: conv3DBackpropFilterV2 as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Conv3DBackpropInputV2.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Conv3DBackpropInputV2.ts deleted file mode 100644 index ce64a916a..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Conv3DBackpropInputV2.ts +++ /dev/null @@ -1,67 +0,0 @@ -/** - * @license - * Copyright 2023 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, Conv3DBackpropInputV2, Conv3DBackpropInputV2Attrs, Conv3DBackpropInputV2Inputs, KernelConfig, KernelFunc, TensorInfo} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {Conv3DDerInputProgram} from '../conv_backprop_webgpu'; - -export function conv3DBackpropInputV2(args: { - inputs: Conv3DBackpropInputV2Inputs, - attrs: Conv3DBackpropInputV2Attrs, - backend: WebGPUBackend -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {dy, filter} = inputs; - const {strides, pad, inputShape} = attrs; - - const convInfo = backend_util.computeConv3DInfo( - inputShape, filter.shape as [number, number, number, number, number], - strides, 1 /* dilations */, pad); - - const program = new Conv3DDerInputProgram(convInfo); - const uniformData = [ - { - type: 'int32', - data: [convInfo.filterDepth, convInfo.filterHeight, convInfo.filterWidth] - }, - { - type: 'int32', - data: [ - convInfo.filterDepth - 1 - convInfo.padInfo.front, - convInfo.filterHeight - 1 - convInfo.padInfo.top, - convInfo.filterWidth - 1 - convInfo.padInfo.left - ] - }, - { - type: 'int32', - data: [convInfo.strideDepth, convInfo.strideHeight, convInfo.strideWidth] - }, - {type: 'int32', data: [convInfo.outDepth]}, - {type: 'int32', data: [convInfo.outHeight]}, - {type: 'int32', data: [convInfo.outWidth]}, - {type: 'int32', data: [convInfo.outChannels]} - ]; - - return backend.runWebGPUProgram(program, [dy, filter], dy.dtype, uniformData); -} - -export const conv3DBackpropInputV2Config: KernelConfig = { - kernelName: Conv3DBackpropInputV2, - backendName: 'webgpu', - kernelFunc: conv3DBackpropInputV2 as unknown as KernelFunc, -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Cos.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Cos.ts deleted file mode 100644 index 7c81be74b..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Cos.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Cos, KernelConfig} from '@tensorflow/tfjs-core'; - -import {unaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; - -import {UnaryOpType} from '../unary_op_util'; - -export const cos = unaryKernelFunc({opType: UnaryOpType.COS}); - -export const cosConfig: KernelConfig = { - kernelName: Cos, - backendName: 'webgpu', - kernelFunc: cos -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Cosh.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Cosh.ts deleted file mode 100644 index 52cf7dba2..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Cosh.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Cosh, KernelConfig} from '@tensorflow/tfjs-core'; - -import {unaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; - -import {UnaryOpType} from '../unary_op_util'; - -export const cosh = unaryKernelFunc({opType: UnaryOpType.COSH}); - -export const coshConfig: KernelConfig = { - kernelName: Cosh, - backendName: 'webgpu', - kernelFunc: cosh -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/CropAndResize.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/CropAndResize.ts deleted file mode 100644 index 19d89afda..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/CropAndResize.ts +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {CropAndResize, CropAndResizeAttrs, CropAndResizeInputs, KernelConfig, KernelFunc, TensorInfo} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {CropAndResizeProgram} from '../crop_and_resize_webgpu'; - -export const cropAndResize = (args: { - inputs: CropAndResizeInputs, - backend: WebGPUBackend, - attrs: CropAndResizeAttrs -}): TensorInfo => { - const {inputs, backend, attrs} = args; - const {image, boxes, boxInd} = inputs; - const {cropSize, method, extrapolationValue} = attrs; - - const program = new CropAndResizeProgram( - image.shape[3], boxes.shape as [number, number], cropSize, method); - const uniformData = [{type: 'float32', data: [extrapolationValue]}]; - return backend.runWebGPUProgram( - program, [image, boxes, boxInd], 'float32', uniformData); -}; - -export const cropAndResizeConfig: KernelConfig = { - kernelName: CropAndResize, - backendName: 'webgpu', - kernelFunc: cropAndResize as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Cum_impl.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Cum_impl.ts deleted file mode 100644 index e6deaa612..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Cum_impl.ts +++ /dev/null @@ -1,81 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, TensorInfo} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {CumOpType, CumProgram} from '../cum_webgpu'; - -import {identity} from './Identity'; -import {transpose} from './Transpose'; - -export function cumImpl( - op: CumOpType, x: TensorInfo, backend: WebGPUBackend, axis: number, - exclusive: boolean, reverse: boolean): TensorInfo { - const xRank = x.shape.length; - const permutation = backend_util.getAxesPermutation([axis], xRank); - let permutedX = x; - if (permutation != null) { - permutedX = transpose({inputs: {x}, backend, attrs: {perm: permutation}}); - } - const permutedAxis = backend_util.getInnerMostAxes(1, xRank)[0]; - - if (permutedAxis !== xRank - 1) { - throw new Error( - `WebGPU cumprod shader expects an inner-most axis=${ - x.shape.length - 1} ` + - `but got axis=${axis}`); - } - const size = permutedX.shape[permutedAxis]; - let result = identity({inputs: {x: permutedX}, backend}); - // Use cum parallel algorithm, inspired by: - // https://developer.nvidia.com/gpugems/gpugems3/part-vi-gpu-computing/chapter-39-parallel-prefix-sum-scan-cuda - // Note: although the algorithm is called sum, it works for any associtative - // operator with an identity. - - for (let i = 0; i <= Math.ceil(Math.log2(size)) - 1; i++) { - const program = new CumProgram(op, permutedX.shape, false, reverse); - const prevResult = result; - const uniformData = [{type: 'float32', data: [i]}]; - result = - backend.runWebGPUProgram(program, [result], result.dtype, uniformData); - backend.disposeData(prevResult.dataId); - } - // For exclusive cum, shift the end result in the direction of product or sum - // and add 1 for product or 0 for sum to the front index. - if (exclusive) { - const program = new CumProgram(op, permutedX.shape, exclusive, reverse); - const prevResult = result; - const uniformData = [{type: 'float32', data: [0]}]; - result = - backend.runWebGPUProgram(program, [result], result.dtype, uniformData); - backend.disposeData(prevResult.dataId); - } - - if (permutation != null) { - const reversePermutation = backend_util.getUndoAxesPermutation(permutation); - const reverseTransposedResult = transpose( - {inputs: {x: result}, backend, attrs: {perm: reversePermutation}}); - - backend.disposeData(result.dataId); - backend.disposeData(permutedX.dataId); - - return reverseTransposedResult; - } - - return result; -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Cumprod.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Cumprod.ts deleted file mode 100644 index 22f6a3c73..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Cumprod.ts +++ /dev/null @@ -1,37 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Cumprod, CumprodAttrs, CumprodInputs, KernelConfig, KernelFunc, TensorInfo} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {CumOpType} from '../cum_webgpu'; -import {cumImpl} from './Cum_impl'; - -export function cumprod( - args: {inputs: CumprodInputs, backend: WebGPUBackend, attrs: CumprodAttrs}): - TensorInfo { - const {inputs, backend, attrs} = args; - const {x} = inputs; - const {axis, exclusive, reverse} = attrs; - return cumImpl(CumOpType.Prod, x, backend, axis, exclusive, reverse); -} - -export const cumprodConfig: KernelConfig = { - kernelName: Cumprod, - backendName: 'webgpu', - kernelFunc: cumprod as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Cumsum.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Cumsum.ts deleted file mode 100644 index ab25a4bf2..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Cumsum.ts +++ /dev/null @@ -1,37 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Cumsum, CumsumAttrs, CumsumInputs, KernelConfig, KernelFunc, TensorInfo} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {CumOpType} from '../cum_webgpu'; -import {cumImpl} from './Cum_impl'; - -export function cumsum( - args: {inputs: CumsumInputs, backend: WebGPUBackend, attrs: CumsumAttrs}): - TensorInfo { - const {inputs, backend, attrs} = args; - const {x} = inputs; - const {axis, exclusive, reverse} = attrs; - return cumImpl(CumOpType.Sum, x, backend, axis, exclusive, reverse); -} - -export const cumsumConfig: KernelConfig = { - kernelName: Cumsum, - backendName: 'webgpu', - kernelFunc: cumsum as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/DenseBincount.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/DenseBincount.ts deleted file mode 100644 index 5152d7cb8..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/DenseBincount.ts +++ /dev/null @@ -1,57 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {DenseBincount, DenseBincountAttrs, DenseBincountInputs, KernelConfig, KernelFunc, TensorInfo, util} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {BincountProgram} from '../bincount_webgpu'; - -import {fill} from './Fill'; - -export function denseBincount(args: { - inputs: DenseBincountInputs, - backend: WebGPUBackend, - attrs: DenseBincountAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {x, weights} = inputs; - const {size, binaryOutput} = attrs; - - const xRankOne = x.shape.length === 1; - const weightsSize = util.sizeFromShape(weights.shape); - const hasWeights = weightsSize > 0; - const dtype = weights.dtype; - const xSize: [number]|[number, number] = - xRankOne ? [x.shape[0]] : [x.shape[0], x.shape[1]]; - const outputSize: [number]|[number, number] = - xRankOne ? [size] : [x.shape[0], size]; - - const output = fill({backend, attrs: {shape: outputSize, value: 0, dtype}}); - const program = new BincountProgram(xSize, hasWeights, binaryOutput); - const uniformData = [{type: 'int32', data: [size]}]; - const bincountInputs: TensorInfo[] = hasWeights ? [x, weights] : [x]; - const res = backend.runWebGPUProgram( - program, bincountInputs, dtype, uniformData, output); - - return res; -} - -export const denseBincountConfig: KernelConfig = { - kernelName: DenseBincount, - backendName: 'webgpu', - kernelFunc: denseBincount as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/DepthToSpace.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/DepthToSpace.ts deleted file mode 100644 index 62fff9bf9..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/DepthToSpace.ts +++ /dev/null @@ -1,57 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {DepthToSpace, DepthToSpaceAttrs, DepthToSpaceInputs, KernelConfig, KernelFunc, TensorInfo} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {DepthToSpaceProgram} from '../depth_to_space_webgpu'; - -export function depthToSpace(args: { - inputs: DepthToSpaceInputs, - backend: WebGPUBackend, - attrs: DepthToSpaceAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {x} = inputs; - const {blockSize, dataFormat} = attrs; - - const batchSize = x.shape[0]; - const inputHeight = (dataFormat === 'NHWC') ? x.shape[1] : x.shape[2]; - const inputWidth = (dataFormat === 'NHWC') ? x.shape[2] : x.shape[3]; - const inputDepth = (dataFormat === 'NHWC') ? x.shape[3] : x.shape[1]; - - const outputHeight = inputHeight * blockSize; - const outputWidth = inputWidth * blockSize; - const outputDepth = inputDepth / (blockSize * blockSize); - - const outputShape = (dataFormat === 'NHWC') ? - [batchSize, outputHeight, outputWidth, outputDepth] : - [batchSize, outputDepth, outputHeight, outputWidth]; - - const uniformData = [ - {type: 'int32', data: [blockSize]}, - ]; - - const program = new DepthToSpaceProgram(outputShape, dataFormat); - return backend.runWebGPUProgram(program, [x], x.dtype, uniformData); -} - -export const depthToSpaceConfig: KernelConfig = { - kernelName: DepthToSpace, - backendName: 'webgpu', - kernelFunc: depthToSpace as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/DepthwiseConv2dNative.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/DepthwiseConv2dNative.ts deleted file mode 100644 index 28fa2226b..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/DepthwiseConv2dNative.ts +++ /dev/null @@ -1,83 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, DepthwiseConv2dNative, DepthwiseConv2dNativeAttrs, DepthwiseConv2dNativeInputs, KernelConfig, KernelFunc} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {DepthwiseConv2DNCHWSharedProgram} from '../depthwise_conv2d_nchw_shared_webgpu'; -import {DepthwiseConv2DVec4Program} from '../depthwise_conv2d_vec4_webgpu'; -import {DepthwiseConv2DProgram} from '../depthwise_conv2d_webgpu'; - -export function depthwiseConv2dNative(args: { - inputs: DepthwiseConv2dNativeInputs, - attrs: DepthwiseConv2dNativeAttrs, - backend: WebGPUBackend -}) { - const {inputs, backend, attrs} = args; - const {x, filter} = inputs; - const {strides, pad, dataFormat, dilations, dimRoundingMode} = attrs; - const $dataFormat = backend_util.convertConv2DDataFormat(dataFormat); - let $dilations = dilations; - if ($dilations == null) { - $dilations = [1, 1]; - } - - const convInfo = backend_util.computeConv2DInfo( - x.shape as [number, number, number, number], - filter.shape as [number, number, number, number], strides, $dilations, - pad, dimRoundingMode, true /* depthwise */, $dataFormat); - const dimensions = [ - {type: 'int32', data: [convInfo.padInfo.top, convInfo.padInfo.left]}, - {type: 'int32', data: [convInfo.inHeight, convInfo.inWidth]}, - ]; - - const isChannelsLast = convInfo.dataFormat === 'channelsLast'; - let program: DepthwiseConv2DProgram|DepthwiseConv2DVec4Program| - DepthwiseConv2DNCHWSharedProgram; - if (!isChannelsLast && convInfo.inHeight > 16 && convInfo.inWidth > 16 && - convInfo.strideHeight === 1 && convInfo.strideWidth === 1 && - convInfo.dilationWidth === 1 && convInfo.dilationHeight === 1 && - convInfo.inChannels === convInfo.outChannels) { - program = new DepthwiseConv2DNCHWSharedProgram( - convInfo.outShape, convInfo.filterHeight, convInfo.filterWidth); - } else if ( - isChannelsLast && convInfo.outHeight > 4 && convInfo.outWidth > 4 && - convInfo.strideWidth <= 2 && - convInfo.inChannels === convInfo.outChannels && - convInfo.dilationHeight === 1 && convInfo.dilationWidth === 1 && - convInfo.inChannels % 4 === 0) { - program = new DepthwiseConv2DVec4Program(convInfo); - dimensions.push({type: 'int32', data: [program.virtualWidth]}); - } else { - program = new DepthwiseConv2DProgram(convInfo); - dimensions.push( - {type: 'int32', data: [convInfo.filterHeight]}, - {type: 'int32', data: [convInfo.filterWidth]}, - {type: 'int32', data: [convInfo.strideHeight, convInfo.strideWidth]}, { - type: 'int32', - data: [convInfo.dilationHeight, convInfo.dilationWidth] - }); - } - - return backend.runWebGPUProgram(program, [x, filter], x.dtype, dimensions); -} - -export const depthwiseConv2dNativeConfig: KernelConfig = { - kernelName: DepthwiseConv2dNative, - backendName: 'webgpu', - kernelFunc: depthwiseConv2dNative as unknown as KernelFunc, -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/DepthwiseConv2dNativeBackpropFilter.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/DepthwiseConv2dNativeBackpropFilter.ts deleted file mode 100644 index 385a0af48..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/DepthwiseConv2dNativeBackpropFilter.ts +++ /dev/null @@ -1,55 +0,0 @@ -/** - * @license - * Copyright 2023 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, DepthwiseConv2dNativeBackpropFilter, DepthwiseConv2dNativeBackpropFilterAttrs, DepthwiseConv2dNativeBackpropFilterInputs, KernelConfig, KernelFunc} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {DepthwiseConv2DDerFilterProgram} from '../conv_backprop_depthwise_webgpu'; - -export function depthwiseConv2dNativeBackpropFilter(args: { - inputs: DepthwiseConv2dNativeBackpropFilterInputs, - attrs: DepthwiseConv2dNativeBackpropFilterAttrs, - backend: WebGPUBackend -}) { - const {inputs, backend, attrs} = args; - const {x, dy} = inputs; - const {strides, dilations, pad, dimRoundingMode, filterShape} = attrs; - - const convInfo = backend_util.computeConv2DInfo( - x.shape as [number, number, number, number], filterShape, strides, - dilations, pad, dimRoundingMode, true /* depthwise */); - - const program = new DepthwiseConv2DDerFilterProgram(convInfo); - const uniformData = [ - {type: 'int32', data: [convInfo.strideHeight, convInfo.strideWidth]}, - {type: 'int32', data: [convInfo.padInfo.top, convInfo.padInfo.left]}, - {type: 'int32', data: [convInfo.filterHeight, convInfo.filterWidth]}, - {type: 'int32', data: [convInfo.outHeight]}, - {type: 'int32', data: [convInfo.outWidth]}, - {type: 'int32', data: [convInfo.inHeight]}, - {type: 'int32', data: [convInfo.inWidth]}, - {type: 'int32', data: [convInfo.batchSize]}, - {type: 'int32', data: [convInfo.outChannels / convInfo.inChannels]} - ]; - return backend.runWebGPUProgram(program, [x, dy], 'float32', uniformData); -} - -export const depthwiseConv2dNativeBackpropFilterConfig: KernelConfig = { - kernelName: DepthwiseConv2dNativeBackpropFilter, - backendName: 'webgpu', - kernelFunc: depthwiseConv2dNativeBackpropFilter as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/DepthwiseConv2dNativeBackpropInput.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/DepthwiseConv2dNativeBackpropInput.ts deleted file mode 100644 index 67a91a970..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/DepthwiseConv2dNativeBackpropInput.ts +++ /dev/null @@ -1,57 +0,0 @@ -/** - * @license - * Copyright 2023 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, DepthwiseConv2dNativeBackpropInput, DepthwiseConv2dNativeBackpropInputAttrs, DepthwiseConv2dNativeBackpropInputInputs, KernelConfig, KernelFunc} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {DepthwiseConv2DDerInputProgram} from '../conv_backprop_depthwise_webgpu'; - -export function depthwiseConv2dNativeBackpropInput(args: { - inputs: DepthwiseConv2dNativeBackpropInputInputs, - attrs: DepthwiseConv2dNativeBackpropInputAttrs, - backend: WebGPUBackend -}) { - const {inputs, backend, attrs} = args; - const {dy, filter} = inputs; - const {strides, dilations, pad, dimRoundingMode, inputShape} = attrs; - - const convInfo = backend_util.computeConv2DInfo( - inputShape, filter.shape as [number, number, number, number], strides, - dilations, pad, dimRoundingMode, true /* depthwise */); - - const program = new DepthwiseConv2DDerInputProgram(convInfo); - const uniformData = [ - {type: 'int32', data: [convInfo.strideHeight, convInfo.strideWidth]}, { - type: 'int32', - data: [ - convInfo.filterHeight - 1 - convInfo.padInfo.top, - convInfo.filterWidth - 1 - convInfo.padInfo.left - ] - }, - {type: 'int32', data: [convInfo.filterHeight, convInfo.filterWidth]}, - {type: 'int32', data: [convInfo.outHeight]}, - {type: 'int32', data: [convInfo.outWidth]}, - {type: 'int32', data: [convInfo.outChannels / convInfo.inChannels]} - ]; - return backend.runWebGPUProgram(program, [dy, filter], dy.dtype, uniformData); -} - -export const depthwiseConv2dNativeBackpropInputConfig: KernelConfig = { - kernelName: DepthwiseConv2dNativeBackpropInput, - backendName: 'webgpu', - kernelFunc: depthwiseConv2dNativeBackpropInput as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Diag.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Diag.ts deleted file mode 100644 index 776d42eac..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Diag.ts +++ /dev/null @@ -1,49 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Diag, DiagInputs, KernelConfig, KernelFunc, TensorInfo, util} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {DiagProgram} from '../diag_webgpu'; -import {reshape} from './Reshape'; - -export function diag(args: {inputs: DiagInputs, backend: WebGPUBackend}): - TensorInfo { - const {inputs, backend} = args; - const {x} = inputs; - - const outShape = [...x.shape, ...x.shape]; - const xSize = util.sizeFromShape(x.shape); - - const flat = reshape({inputs: {x}, backend, attrs: {shape: [xSize]}}); - - const program = new DiagProgram(xSize); - const res = backend.runWebGPUProgram(program, [flat], flat.dtype); - - const out = reshape({inputs: {x: res}, backend, attrs: {shape: outShape}}); - - backend.disposeData(flat.dataId); - backend.disposeData(res.dataId); - - return out; -} - -export const diagConfig: KernelConfig = { - kernelName: Diag, - backendName: 'webgpu', - kernelFunc: diag as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Dilation2D.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Dilation2D.ts deleted file mode 100644 index ea47a2bf9..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Dilation2D.ts +++ /dev/null @@ -1,55 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, Dilation2D, Dilation2DAttrs, Dilation2DInputs, KernelConfig, KernelFunc, TensorInfo} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {Dilation2DProgram} from '../dilation_webgpu'; - -export function dilation2D(args: { - inputs: Dilation2DInputs, - attrs: Dilation2DAttrs, - backend: WebGPUBackend -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {x, filter} = inputs; - const {strides, pad, dilations} = attrs; - - const convInfo = backend_util.computeDilation2DInfo( - x.shape as [number, number, number, number], - filter.shape as [number, number, number], strides, pad, - 'NHWC' /* dataFormat */, dilations); - const padInfo = [convInfo.padInfo.top, convInfo.padInfo.left]; - const uniformData = [ - {type: 'int32', data: [convInfo.filterHeight, convInfo.filterWidth]}, - {type: 'int32', data: [...padInfo]}, - {type: 'int32', data: [convInfo.strideHeight, convInfo.strideWidth]}, - {type: 'int32', data: [convInfo.dilationHeight, convInfo.dilationWidth]} - ]; - - const program = new Dilation2DProgram(convInfo); - const out = - backend.runWebGPUProgram(program, [x, filter], x.dtype, uniformData); - - return out; -} - -export const dilation2DConfig: KernelConfig = { - kernelName: Dilation2D, - backendName: 'webgpu', - kernelFunc: dilation2D as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Dilation2DBackpropFilter.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Dilation2DBackpropFilter.ts deleted file mode 100644 index 3ade8ffd6..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Dilation2DBackpropFilter.ts +++ /dev/null @@ -1,57 +0,0 @@ -/** - * @license - * Copyright 2023 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, Dilation2DAttrs, Dilation2DBackpropFilter, Dilation2DBackpropFilterInputs, KernelConfig, KernelFunc, TensorInfo, util} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {Dilation2DBackpropFilterProgram} from '../dilation_backprop_webgpu'; -import {fill} from './Fill'; - -export function dilation2DBackpropFilter(args: { - inputs: Dilation2DBackpropFilterInputs, - attrs: Dilation2DAttrs, - backend: WebGPUBackend -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {x, filter, dy} = inputs; - const {strides, pad, dilations} = attrs; - - const convInfo = backend_util.computeDilation2DInfo( - x.shape as [number, number, number, number], - filter.shape as [number, number, number], strides, pad, - 'NHWC' /* dataFormat */, dilations); - - const dtype = filter.dtype; - const program = - new Dilation2DBackpropFilterProgram(convInfo, filter.shape, dtype); - const uniformData = [ - {type: 'int32', data: [convInfo.filterHeight, convInfo.filterWidth]}, - {type: 'int32', data: [convInfo.padInfo.top, convInfo.padInfo.left]}, - {type: 'int32', data: [convInfo.strideHeight, convInfo.strideWidth]}, - {type: 'int32', data: [convInfo.dilationHeight, convInfo.dilationWidth]}, - {type: 'int32', data: [util.sizeFromShape(convInfo.outShape)]} - ]; - const output = fill({backend, attrs: {shape: filter.shape, value: 0, dtype}}); - return backend.runWebGPUProgram( - program, [x, filter, dy], dtype, uniformData, output); -} - -export const dilation2DBackpropFilterConfig: KernelConfig = { - kernelName: Dilation2DBackpropFilter, - backendName: 'webgpu', - kernelFunc: dilation2DBackpropFilter as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Dilation2DBackpropInput.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Dilation2DBackpropInput.ts deleted file mode 100644 index db4d14c7a..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Dilation2DBackpropInput.ts +++ /dev/null @@ -1,57 +0,0 @@ -/** - * @license - * Copyright 2023 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, Dilation2DAttrs, Dilation2DBackpropInput, Dilation2DBackpropInputInputs, KernelConfig, KernelFunc, TensorInfo, util} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {Dilation2DBackpropInputProgram} from '../dilation_backprop_webgpu'; -import {fill} from './Fill'; - -export function dilation2DBackpropInput(args: { - inputs: Dilation2DBackpropInputInputs, - attrs: Dilation2DAttrs, - backend: WebGPUBackend -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {x, filter, dy} = inputs; - const {strides, pad, dilations} = attrs; - - const convInfo = backend_util.computeDilation2DInfo( - x.shape as [number, number, number, number], - filter.shape as [number, number, number], strides, pad, - 'NHWC' /* dataFormat */, dilations); - - const dtype = x.dtype; - const program = new Dilation2DBackpropInputProgram(convInfo, dtype); - const uniformData = [ - {type: 'int32', data: [convInfo.filterHeight, convInfo.filterWidth]}, - {type: 'int32', data: [convInfo.padInfo.top, convInfo.padInfo.left]}, - {type: 'int32', data: [convInfo.strideHeight, convInfo.strideWidth]}, - {type: 'int32', data: [convInfo.dilationHeight, convInfo.dilationWidth]}, - {type: 'int32', data: [util.sizeFromShape(convInfo.outShape)]} - ]; - const output = - fill({backend, attrs: {shape: convInfo.inShape, value: 0, dtype}}); - return backend.runWebGPUProgram( - program, [x, filter, dy], dtype, uniformData, output); -} - -export const dilation2DBackpropInputConfig: KernelConfig = { - kernelName: Dilation2DBackpropInput, - backendName: 'webgpu', - kernelFunc: dilation2DBackpropInput as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Draw.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Draw.ts deleted file mode 100644 index 6ccbb7b36..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Draw.ts +++ /dev/null @@ -1,85 +0,0 @@ -/** - * @license - * Copyright 2023 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use backend file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, TensorInfo} from '@tensorflow/tfjs-core'; -import {Draw, DrawAttrs, DrawInputs,} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {DrawProgram} from '../draw_webgpu'; - -export function draw( - args: {inputs: DrawInputs, backend: WebGPUBackend, attrs: DrawAttrs}): - TensorInfo { - const {inputs, backend, attrs} = args; - const {image} = inputs; - const {canvas, options} = attrs; - const [height, width] = image.shape.slice(0, 2); - const {imageOptions} = options || {}; - const alpha = imageOptions ?.alpha || 1; - - // 'rgba8unorm' should work on macOS according to - // https://bugs.chromium.org/p/chromium/issues/detail?id=1298618. But - // failed on macOS/M2. So use 'bgra8unorm' first when available. - const format = backend.device.features.has('bgra8unorm-storage') ? - 'bgra8unorm' : - 'rgba8unorm'; - const outShape = [height, width]; - const program = new DrawProgram(outShape, image.dtype, format); - canvas.width = width; - canvas.height = height; - const backendName = 'webgpu'; - let gpuContext = canvas.getContext(backendName); - let canvasWebGPU; - if (!gpuContext) { - canvasWebGPU = new OffscreenCanvas(width, height); - gpuContext = canvasWebGPU.getContext(backendName); - } - const numChannels = image.shape.length === 3 ? image.shape[2] : 1; - gpuContext.configure({ - device: backend.device, - format, - usage: GPUTextureUsage.STORAGE_BINDING, - alphaMode: 'premultiplied' - }); - - const outputDtype = 'int32'; - const output = backend.makeTensorInfo(outShape, outputDtype); - const info = backend.tensorMap.get(output.dataId); - info.resource = gpuContext.getCurrentTexture(); - info.external = true; - - const uniformData = - [{type: 'uint32', data: [numChannels]}, {type: 'float32', data: [alpha]}]; - backend.runWebGPUProgram(program, [image], outputDtype, uniformData, output); - - if (canvasWebGPU) { - const canvas2dContext = canvas.getContext('2d'); - if (!canvas2dContext) { - throw new Error( - `Please make sure this canvas has only been used for 2d or webgpu context!`); - } - canvas2dContext.drawImage(canvasWebGPU, 0, 0); - } - backend.disposeData(output.dataId); - return image; -} - -export const drawConfig: KernelConfig = { - kernelName: Draw, - backendName: 'webgpu', - kernelFunc: draw as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Einsum.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Einsum.ts deleted file mode 100644 index 3641514ea..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Einsum.ts +++ /dev/null @@ -1,103 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, Einsum, EinsumAttrs, EinsumInputs, KernelConfig, KernelFunc, Tensor, TensorInfo, util} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; - -import {multiplyKernelFunc} from './Multiply'; -import {reshape} from './Reshape'; -import {sum} from './Sum'; -import {transpose} from './Transpose'; - -export function einsum( - args: {inputs: EinsumInputs, backend: WebGPUBackend, attrs: EinsumAttrs}): - TensorInfo { - const {inputs, backend, attrs} = args; - const {equation} = attrs; - const tensors = inputs as Tensor[]; - - const {allDims, summedDims, idDims} = - backend_util.decodeEinsumEquation(equation, tensors.length); - backend_util.checkEinsumDimSizes(allDims.length, idDims, tensors); - const {path, steps} = backend_util.getEinsumComputePath(summedDims, idDims); - - const nSteps = steps.length; - let out: TensorInfo|null = null; - let numDimsRemaining = allDims.length; - const tensorsToDispose: TensorInfo[] = []; - for (let i = 0; i < nSteps; ++i) { - for (const idTerm of steps[i]) { - const {permutationIndices: perm, expandDims: dimsToExpand} = - backend_util.getEinsumPermutation(numDimsRemaining, idDims[idTerm]); - let x: TensorInfo; - if (backend_util.isIdentityPermutation(perm)) { - x = tensors[idTerm]; - } else { - x = transpose({inputs: {x: tensors[idTerm]}, backend, attrs: {perm}}); - tensorsToDispose.push(x); - } - const targetShape: number[] = x.shape.slice(); - for (let k = 0; k < dimsToExpand.length; ++k) { - targetShape.splice(dimsToExpand[k], 0, 1); - } - - if (!util.arraysEqual(x.shape, targetShape)) { - x = reshape({inputs: {x}, backend, attrs: {shape: targetShape}}); - tensorsToDispose.push(x); - } - if (out === null) { - out = x; - } else { - // tslint:disable-next-line: no-unnecessary-type-assertion - out = - multiplyKernelFunc({inputs: {a: x, b: out}, backend}) as TensorInfo; - tensorsToDispose.push(out); - } - } - if (i < nSteps - 1) { - if (path[i] >= 0) { - out = sum({ - inputs: {x: out}, - backend, - attrs: { - axis: path[i] - (allDims.length - numDimsRemaining), - keepDims: false - } - }); - tensorsToDispose.push(out); - } - numDimsRemaining--; - } - } - - // Clean up intermediate tensors. - for (const tensorInfo of tensorsToDispose) { - if (tensorInfo === out) { - continue; - } - backend.disposeData(tensorInfo.dataId); - } - - return out; -} - -export const einsumConfig: KernelConfig = { - kernelName: Einsum, - backendName: 'webgpu', - kernelFunc: einsum as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Elu.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Elu.ts deleted file mode 100644 index 88eb23bea..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Elu.ts +++ /dev/null @@ -1,28 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Elu, KernelConfig} from '@tensorflow/tfjs-core'; -import {unaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; -import {UnaryOpType} from '../unary_op_util'; - -export const elu = unaryKernelFunc({opType: UnaryOpType.ELU}); - -export const eluConfig: KernelConfig = { - kernelName: Elu, - backendName: 'webgpu', - kernelFunc: elu -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/EluGrad.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/EluGrad.ts deleted file mode 100644 index ed5b387b5..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/EluGrad.ts +++ /dev/null @@ -1,38 +0,0 @@ -/** - * @license - * Copyright 2023 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {EluGrad, EluGradInputs, KernelConfig, KernelFunc, TensorInfo} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {BinaryOpType} from '../binary_op_util'; -import {BinaryOpProgram} from '../binary_op_webgpu'; - -export const eluGrad = - (args: {inputs: EluGradInputs, backend: WebGPUBackend}): TensorInfo => { - const {inputs, backend} = args; - const {dy, y} = inputs; - - const program = - new BinaryOpProgram(BinaryOpType.ELU_DER, dy.shape, y.shape); - return backend.runWebGPUProgram(program, [dy, y], dy.dtype); - }; - -export const eluGradConfig: KernelConfig = { - kernelName: EluGrad, - backendName: 'webgpu', - kernelFunc: eluGrad as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Equal.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Equal.ts deleted file mode 100644 index dbd2db08c..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Equal.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Equal, KernelConfig} from '@tensorflow/tfjs-core'; - -import {BinaryOpType} from '../binary_op_util'; -import {binaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; -import {equalImplCPU as cpuEqual} from '../kernel_utils/shared'; - -export const equal = binaryKernelFunc( - {opType: BinaryOpType.EQUAL, dtype: 'bool', cpuKernelImpl: cpuEqual}); - -export const equalConfig: KernelConfig = { - kernelName: Equal, - backendName: 'webgpu', - kernelFunc: equal -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Erf.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Erf.ts deleted file mode 100644 index fdec94925..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Erf.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Erf, KernelConfig} from '@tensorflow/tfjs-core'; - -import {unaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; - -import {UnaryOpType} from '../unary_op_util'; - -export const erf = unaryKernelFunc({opType: UnaryOpType.ERF}); - -export const erfConfig: KernelConfig = { - kernelName: Erf, - backendName: 'webgpu', - kernelFunc: erf -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Exp.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Exp.ts deleted file mode 100644 index ddee16237..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Exp.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Exp, KernelConfig} from '@tensorflow/tfjs-core'; -import {unaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; -import {expImplCPU} from '../kernel_utils/shared'; -import {UnaryOpType} from '../unary_op_util'; - -export const exp = unaryKernelFunc({ - opType: UnaryOpType.EXP, - cpuKernelImpl: expImplCPU, - dtype: 'float32', -}); - -export const expConfig: KernelConfig = { - kernelName: Exp, - backendName: 'webgpu', - kernelFunc: exp -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/ExpandDims.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/ExpandDims.ts deleted file mode 100644 index 75a7e0416..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/ExpandDims.ts +++ /dev/null @@ -1,52 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ExpandDims, ExpandDimsAttrs, ExpandDimsInputs, KernelConfig, KernelFunc, TensorInfo, util} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {reshape} from './Reshape'; - -export function expandDims(args: { - inputs: ExpandDimsInputs, - attrs: ExpandDimsAttrs, - backend: WebGPUBackend -}): TensorInfo { - const {inputs, attrs, backend} = args; - const {dim} = attrs; - const {input} = inputs; - - const inputRank = input.shape.length; - const newShape = input.shape.slice(); - let $dim = dim; - if (dim < 0) { - // Negative value is counted from the tail of rank. - util.assert( - -(inputRank + 1) <= dim, - () => `Axis must be in the interval [${- (inputRank + 1)}, ${ - inputRank}]`); - $dim = inputRank + dim + 1; - } - newShape.splice($dim, 0, 1); - - return reshape({inputs: {x: input}, backend, attrs: {shape: newShape}}); -} - -export const expandDimsConfig: KernelConfig = { - kernelName: ExpandDims, - backendName: 'webgpu', - kernelFunc: expandDims as unknown as KernelFunc, -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Expm1.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Expm1.ts deleted file mode 100644 index 8832fe635..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Expm1.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Expm1, KernelConfig} from '@tensorflow/tfjs-core'; -import {unaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; -import {expm1ImplCPU} from '../kernel_utils/shared'; -import {UnaryOpType} from '../unary_op_util'; - -export const expm1 = - unaryKernelFunc({opType: UnaryOpType.EXPM1, cpuKernelImpl: expm1ImplCPU}); - -export const expm1Config: KernelConfig = { - kernelName: Expm1, - backendName: 'webgpu', - kernelFunc: expm1 -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/FFT.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/FFT.ts deleted file mode 100644 index cb91cd66f..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/FFT.ts +++ /dev/null @@ -1,36 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {FFT, FFTInputs, KernelConfig, TensorInfo} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; - -import {fftImpl} from './FFT_impl'; - -export function fft(args: {inputs: FFTInputs, backend: WebGPUBackend}): - TensorInfo { - const {inputs, backend} = args; - const {input} = inputs; - - return fftImpl(input, false /* inverse */, backend); -} - -export const fftConfig: KernelConfig = { - kernelName: FFT, - backendName: 'webgpu', - kernelFunc: fft -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/FFT_impl.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/FFT_impl.ts deleted file mode 100644 index 4aa894a31..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/FFT_impl.ts +++ /dev/null @@ -1,81 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {TensorInfo, util} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {FFTProgram} from '../fft_webgpu'; - -import {complex} from './Complex'; -import {reshape} from './Reshape'; - -export function fftImpl( - x: TensorInfo, inverse: boolean, backend: WebGPUBackend): TensorInfo { - const xData = backend.tensorMap.get(x.dataId); - - const inputSize = util.sizeFromShape(x.shape); - // Collapse all outer dimensions to a single batch dimension. - const innerDimensionSize = x.shape[x.shape.length - 1]; - const batch = inputSize / innerDimensionSize; - - const toDispose = []; - const input2D = reshape( - {inputs: {x}, backend, attrs: {shape: [batch, innerDimensionSize]}}); - toDispose.push(input2D); - - const xShape = input2D.shape as [number, number]; - const realProgram = new FFTProgram('real', xShape); - const imagProgram = new FFTProgram('imag', xShape); - - const inputs = [ - { - dataId: xData.complexTensorInfos.real.dataId, - dtype: xData.complexTensorInfos.real.dtype, - shape: xShape - }, - { - dataId: xData.complexTensorInfos.imag.dataId, - dtype: xData.complexTensorInfos.imag.dtype, - shape: xShape - } - ]; - - const exponentMultiplier = inverse ? 2.0 * Math.PI : -2.0 * Math.PI; - const denominator = inverse ? xShape[1] : 1.0; - const uniformData = [ - {type: 'float32', data: [exponentMultiplier]}, - {type: 'float32', data: [denominator]} - ]; - - const realPart = - backend.runWebGPUProgram(realProgram, inputs, 'float32', uniformData); - toDispose.push(realPart); - const imagPart = - backend.runWebGPUProgram(imagProgram, inputs, 'float32', uniformData); - toDispose.push(imagPart); - - const complexOutput = - complex({inputs: {real: realPart, imag: imagPart}, backend}); - toDispose.push(complexOutput); - - const complexOutputReshaped = - reshape({inputs: {x: complexOutput}, backend, attrs: {shape: x.shape}}); - - toDispose.forEach(t => backend.disposeData(t.dataId)); - - return complexOutputReshaped; -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Fill.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Fill.ts deleted file mode 100644 index b7e1bee27..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Fill.ts +++ /dev/null @@ -1,47 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Fill, FillAttrs, KernelConfig, KernelFunc, TensorInfo, util} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {FillProgram} from '../fill_webgpu'; - -export function fill(args: {backend: WebGPUBackend, attrs: FillAttrs}): - TensorInfo { - const {backend, attrs} = args; - const {shape, value} = attrs; - let {dtype} = attrs; - - dtype = dtype || util.inferDtype(value); - - if (dtype === 'string') { - // String type should be handled in CPU memory. - const values = util.getArrayFromDType(dtype, util.sizeFromShape(shape)); - values.fill(value as string); - return backend.makeTensorInfo(shape, dtype, values); - } else { - const program = new FillProgram(shape); - const uniformData = [{type: 'float32', data: [value as number]}]; - return backend.runWebGPUProgram(program, [], dtype, uniformData); - } -} - -export const fillConfig: KernelConfig = { - kernelName: Fill, - backendName: 'webgpu', - kernelFunc: fill as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/FlipLeftRight.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/FlipLeftRight.ts deleted file mode 100644 index b4140bb41..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/FlipLeftRight.ts +++ /dev/null @@ -1,36 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, Tensor4D} from '@tensorflow/tfjs-core'; -import {FlipLeftRight, FlipLeftRightInputs} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {FlipLeftRightProgram} from '../flip_left_right_webgpu'; - -export const flipLeftRightConfig: KernelConfig = { - kernelName: FlipLeftRight, - backendName: 'webgpu', - kernelFunc: ({inputs, backend}) => { - const {image} = inputs as FlipLeftRightInputs; - const webgpuBackend = backend as WebGPUBackend; - - const program = new FlipLeftRightProgram((image as Tensor4D).shape); - const output = - webgpuBackend.runWebGPUProgram(program, [image], image.dtype); - return output; - } -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Floor.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Floor.ts deleted file mode 100644 index 546d1f40f..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Floor.ts +++ /dev/null @@ -1,31 +0,0 @@ - -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Floor, KernelConfig} from '@tensorflow/tfjs-core'; -import {unaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; -import {floorImplCPU} from '../kernel_utils/shared'; -import {UnaryOpType} from '../unary_op_util'; - -export const floor = - unaryKernelFunc({opType: UnaryOpType.FLOOR, cpuKernelImpl: floorImplCPU}); - -export const floorConfig: KernelConfig = { - kernelName: Floor, - backendName: 'webgpu', - kernelFunc: floor -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/FloorDiv.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/FloorDiv.ts deleted file mode 100644 index b57b552f9..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/FloorDiv.ts +++ /dev/null @@ -1,34 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {FloorDiv, KernelConfig} from '@tensorflow/tfjs-core'; - -import {BinaryOpType} from '../binary_op_util'; -import {binaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; -import {floorDivImplCPU} from '../kernel_utils/shared'; - -export const floorDiv = binaryKernelFunc({ - opType: BinaryOpType.FLOOR_DIV, - cpuKernelImpl: floorDivImplCPU, - dtype: 'int32' -}); - -export const floorDivConfig: KernelConfig = { - kernelName: FloorDiv, - backendName: 'webgpu', - kernelFunc: floorDiv -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/FromPixels.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/FromPixels.ts deleted file mode 100644 index 6c37aecd3..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/FromPixels.ts +++ /dev/null @@ -1,141 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use backend file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {env, KernelConfig, KernelFunc} from '@tensorflow/tfjs-core'; -import {FromPixels, FromPixelsAttrs, FromPixelsInputs, util} from '@tensorflow/tfjs-core'; -import {backend_util, TensorInfo} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {FromPixelsProgram} from '../from_pixels_webgpu'; - -export const fromPixelsConfig: KernelConfig = { - kernelName: FromPixels, - backendName: 'webgpu', - kernelFunc: fromPixels as unknown as KernelFunc, -}; - -let fromPixels2DContext: CanvasRenderingContext2D; -let willReadFrequently = env().getBool('CANVAS2D_WILL_READ_FREQUENTLY_FOR_GPU'); - -export function fromPixels(args: { - inputs: FromPixelsInputs, - backend: WebGPUBackend, - attrs: FromPixelsAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - let {pixels} = inputs; - const {numChannels} = attrs; - - if (pixels == null) { - throw new Error('pixels passed to tf.browser.fromPixels() can not be null'); - } - - const isVideo = typeof (HTMLVideoElement) !== 'undefined' && - pixels instanceof HTMLVideoElement; - const isImage = typeof (HTMLImageElement) !== 'undefined' && - pixels instanceof HTMLImageElement; - const isCanvas = (typeof (HTMLCanvasElement) !== 'undefined' && - pixels instanceof HTMLCanvasElement) || - (typeof (OffscreenCanvas) !== 'undefined' && - pixels instanceof OffscreenCanvas); - const isImageBitmap = - typeof (ImageBitmap) !== 'undefined' && pixels instanceof ImageBitmap; - - const [width, height] = isVideo ? - [ - (pixels as HTMLVideoElement).videoWidth, - (pixels as HTMLVideoElement).videoHeight - ] : - [pixels.width, pixels.height]; - const outputShape = [height, width, numChannels]; - - const importVideo = - env().getBool('WEBGPU_IMPORT_EXTERNAL_TEXTURE') && isVideo; - const isVideoOrImage = isVideo || isImage; - if (isImageBitmap || isCanvas || isVideoOrImage) { - let resource; - if (importVideo) { - resource = backend.device.importExternalTexture( - {source: pixels as HTMLVideoElement}); - } else { - if (isVideoOrImage) { - const newWillReadFrequently = - env().getBool('CANVAS2D_WILL_READ_FREQUENTLY_FOR_GPU'); - if (fromPixels2DContext == null || - newWillReadFrequently !== willReadFrequently) { - willReadFrequently = newWillReadFrequently; - fromPixels2DContext = document.createElement('canvas').getContext( - '2d', {willReadFrequently}); - } - fromPixels2DContext.canvas.width = width; - fromPixels2DContext.canvas.height = height; - fromPixels2DContext.drawImage( - pixels as HTMLVideoElement | HTMLImageElement, 0, 0, width, height); - pixels = fromPixels2DContext.canvas; - } - - const usage = GPUTextureUsage.COPY_DST | - GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING; - const format = 'rgba8unorm' as GPUTextureFormat; - const texture = backend.textureManager.acquireTexture( - outputShape[1], outputShape[0], format, usage); - backend.queue.copyExternalImageToTexture( - {source: pixels as HTMLCanvasElement | ImageBitmap}, {texture}, - [outputShape[1], outputShape[0]]); - resource = texture; - } - - const size = util.sizeFromShape(outputShape); - const strides = util.computeStrides(outputShape); - const program = - new FromPixelsProgram(outputShape, numChannels, importVideo); - - const uniformData = [ - {type: 'uint32', data: [size]}, {type: 'uint32', data: [numChannels]}, - {type: 'uint32', data: [...strides]} - ]; - const input = backend.makeTensorInfo([height, width], 'int32'); - const info = backend.tensorMap.get(input.dataId); - info.resource = resource; - - const result = - backend.runWebGPUProgram(program, [input], 'int32', uniformData); - backend.disposeData(input.dataId); - return result; - } - - // TODO: Encoding should happen on GPU once we no longer have to download - // image data to the CPU. - const imageData = (pixels as ImageData | backend_util.PixelData).data; - let pixelArray = imageData; - if (numChannels != null && numChannels !== 4) { - pixelArray = new Uint8Array(pixels.width * pixels.height * numChannels); - - const dataLength = imageData.length; - let j = 0; - for (let i = 0; i < dataLength; i++) { - if (i % 4 < numChannels) { - pixelArray[j++] = imageData[i]; - } - } - } - - const output = - backend.makeTensorInfo(outputShape, 'int32', new Int32Array(pixelArray)); - backend.uploadToGPU(output.dataId); - return output; -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/FusedBatchNorm.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/FusedBatchNorm.ts deleted file mode 100644 index 05fbe2835..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/FusedBatchNorm.ts +++ /dev/null @@ -1,48 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {FusedBatchNorm, FusedBatchNormAttrs, FusedBatchNormInputs, KernelConfig, Tensor} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; - -import {BatchNormProgram} from '../batchnorm_webgpu'; - -export const fusedBatchNormConfig: KernelConfig = { - kernelName: FusedBatchNorm, - backendName: 'webgpu', - kernelFunc: ({inputs, attrs, backend}) => { - const {x, scale, offset, mean, variance} = inputs as FusedBatchNormInputs; - const {varianceEpsilon} = attrs as unknown as FusedBatchNormAttrs; - const webGPUBackend = backend as WebGPUBackend; - const batchNormInputs = [x as Tensor, mean as Tensor, variance as Tensor]; - let offsetShape = null; - if (offset != null) { - offsetShape = offset.shape; - batchNormInputs.push(offset as Tensor); - } - let scaleShape = null; - if (scale != null) { - scaleShape = scale.shape; - batchNormInputs.push(scale as Tensor); - } - const program = new BatchNormProgram( - x.shape, mean.shape, variance.shape, offsetShape, scaleShape); - const uniformData = [{type: 'float32', data: [varianceEpsilon]}]; - return webGPUBackend.runWebGPUProgram( - program, batchNormInputs, x.dtype, uniformData); - } -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/FusedConv2D.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/FusedConv2D.ts deleted file mode 100644 index b2ce41f66..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/FusedConv2D.ts +++ /dev/null @@ -1,63 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, FusedConv2D, FusedConv2DAttrs, FusedConv2DInputs, KernelConfig, KernelFunc} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; - -import {conv2DImpl} from './Conv2D_impl'; - -export function fusedConv2d(args: { - inputs: FusedConv2DInputs, - attrs: FusedConv2DAttrs, - backend: WebGPUBackend -}) { - const {inputs, backend, attrs} = args; - const {x, filter, bias, preluActivationWeights} = inputs; - const { - strides, - pad, - dataFormat, - dilations, - dimRoundingMode, - activation, - leakyreluAlpha - } = attrs; - - const $dataFormat = backend_util.convertConv2DDataFormat(dataFormat); - const convInfo = backend_util.computeConv2DInfo( - x.shape as [number, number, number, number], - filter.shape as [number, number, number, number], strides, dilations, pad, - dimRoundingMode, false /* depthwise */, $dataFormat); - - return conv2DImpl({ - x, - filter, - convInfo, - backend, - bias, - preluActivationWeights, - leakyreluAlpha, - activation - }); -} - -export const fusedConv2DConfig: KernelConfig = { - kernelName: FusedConv2D, - backendName: 'webgpu', - kernelFunc: fusedConv2d as unknown as KernelFunc, -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/FusedDepthwiseConv2D.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/FusedDepthwiseConv2D.ts deleted file mode 100644 index 9660d1367..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/FusedDepthwiseConv2D.ts +++ /dev/null @@ -1,100 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, FusedDepthwiseConv2D, FusedDepthwiseConv2DAttrs, FusedDepthwiseConv2DInputs, KernelConfig, KernelFunc, TensorInfo, util} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {DepthwiseConv2DVec4Program} from '../depthwise_conv2d_vec4_webgpu'; -import {DepthwiseConv2DProgram} from '../depthwise_conv2d_webgpu'; - -export function fusedDepthwiseConv2D(args: { - inputs: FusedDepthwiseConv2DInputs, - attrs: FusedDepthwiseConv2DAttrs, - backend: WebGPUBackend -}) { - const {inputs, backend, attrs} = args; - const {x, filter, bias, preluActivationWeights} = inputs; - const {strides, pad, dilations, dimRoundingMode, activation, leakyreluAlpha} = - attrs; - - let $dilations = dilations; - if ($dilations == null) { - $dilations = [1, 1]; - } - - util.assert( - backend_util.eitherStridesOrDilationsAreOne(strides, $dilations), - () => 'Error in depthwiseConv2d: Either strides or dilations must be ' + - `1. Got strides ${strides} and dilations '${$dilations}'`); - - const convInfo = backend_util.computeConv2DInfo( - x.shape as [number, number, number, number], - filter.shape as [number, number, number, number], strides, $dilations, - pad, dimRoundingMode, true /* depthwise */); - - const programInputs: TensorInfo[] = [x, filter]; - - const hasBias = bias != null; - const hasPreluActivationWeights = preluActivationWeights != null; - - if (hasBias) { - programInputs.push(bias); - } - if (hasPreluActivationWeights) { - programInputs.push(preluActivationWeights); - } - - const dimensions = [ - {type: 'int32', data: [convInfo.padInfo.top, convInfo.padInfo.left]}, - {type: 'int32', data: [convInfo.inHeight, convInfo.inWidth]}, - ]; - - let program: DepthwiseConv2DProgram|DepthwiseConv2DVec4Program; - if (convInfo.outHeight > 4 && convInfo.outWidth > 4 && - convInfo.strideWidth <= 2 && - convInfo.inChannels === convInfo.outChannels && - convInfo.dilationHeight === 1 && convInfo.dilationWidth === 1 && - convInfo.inChannels % 4 === 0) { - program = new DepthwiseConv2DVec4Program( - convInfo, hasBias, activation, hasPreluActivationWeights); - dimensions.push({type: 'int32', data: [program.virtualWidth]}); - } else { - program = new DepthwiseConv2DProgram( - convInfo, hasBias, activation, hasPreluActivationWeights); - dimensions.push( - {type: 'int32', data: [convInfo.filterHeight]}, - {type: 'int32', data: [convInfo.filterWidth]}, - {type: 'int32', data: [convInfo.strideHeight, convInfo.strideWidth]}, { - type: 'int32', - data: [convInfo.dilationHeight, convInfo.dilationWidth] - }); - } - if (activation === 'leakyrelu') { - dimensions.push({type: 'float32', data: [leakyreluAlpha]}); - program.uniforms += ' alpha : f32,'; - } - const result = - backend.runWebGPUProgram(program, programInputs, 'float32', dimensions); - - return result; -} - -export const fusedDepthwiseConv2DConfig: KernelConfig = { - kernelName: FusedDepthwiseConv2D, - backendName: 'webgpu', - kernelFunc: fusedDepthwiseConv2D as unknown as KernelFunc, -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/GatherNd.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/GatherNd.ts deleted file mode 100644 index 558953388..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/GatherNd.ts +++ /dev/null @@ -1,75 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, GatherNd, GatherNdInputs, KernelConfig, KernelFunc, Rank, TensorInfo, TypedArray, util} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {GatherNDProgram} from '../gather_nd_webgpu'; -import {gatherNdImplCPU} from '../kernel_utils/shared'; - -import {reshape} from './Reshape'; - -export function gatherNd( - args: {inputs: GatherNdInputs, backend: WebGPUBackend}): TensorInfo { - const {inputs, backend} = args; - const {params, indices} = inputs; - - const indicesShape = indices.shape; - const sliceRank = indicesShape[indicesShape.length - 1]; - const paramsSize = util.sizeFromShape(params.shape); - - const [resultShape, numSlices, sliceSize, strides] = - backend_util.prepareAndValidate(params, indices); - - const flattenIndices = reshape( - {inputs: {x: indices}, backend, attrs: {shape: [numSlices, sliceRank]}}); - const flattenX = reshape({ - inputs: {x: params}, - backend, - attrs: {shape: [(util.sizeFromShape(params.shape) / sliceSize), sliceSize]} - }); - if (backend.shouldExecuteOnCPU([params, indices]) || - params.dtype === 'string') { - const indicesData = backend.readSync(indices.dataId) as TypedArray; - const paramsBuf = backend.bufferSync(params); - const outValue = gatherNdImplCPU( - indicesData, paramsBuf, params.dtype, numSlices, sliceRank, sliceSize, - strides, params.shape, paramsSize); - - return backend.makeTensorInfo(resultShape, params.dtype, outValue.values); - } - const program = new GatherNDProgram(sliceRank, [numSlices, sliceSize]); - const uniformData = - [{type: 'int32', data: [sliceRank]}, {type: 'int32', data: strides}]; - const res = backend.runWebGPUProgram( - program, [flattenX, flattenIndices], flattenX.dtype, uniformData); - - const reshaped = - reshape({inputs: {x: res}, backend, attrs: {shape: resultShape}}); - - backend.disposeData(flattenIndices.dataId); - backend.disposeData(flattenX.dataId); - backend.disposeData(res.dataId); - - return reshaped; -} - -export const gatherNdConfig: KernelConfig = { - kernelName: GatherNd, - backendName: 'webgpu', - kernelFunc: gatherNd as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/GatherV2.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/GatherV2.ts deleted file mode 100644 index 000057ccf..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/GatherV2.ts +++ /dev/null @@ -1,103 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, buffer, GatherV2, GatherV2Attrs, GatherV2Inputs, KernelConfig, KernelFunc, Rank, TensorBuffer, TensorInfo, TypedArray, util} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {GatherProgram} from '../gather_webgpu'; -import {gatherV2ImplCPU} from '../kernel_utils/shared'; - -import {reshape} from './Reshape'; - -export function gatherV2( - args: - {inputs: GatherV2Inputs, backend: WebGPUBackend, attrs: GatherV2Attrs}): - TensorInfo { - const {inputs, backend, attrs} = args; - const {x, indices} = inputs; - const {axis, batchDims} = attrs; - - // Unlike WebGL, WebGPU won't check if index is out of bound by calling - // backend.readSync() function in debug mode. - const parsedAxis = util.parseAxisParam(axis, x.shape)[0]; - - const shapeInfo = backend_util.segment_util.collectGatherOpShapeInfo( - x, indices, parsedAxis, batchDims); - - const indicesSize = util.sizeFromShape(indices.shape); - - const toDispose = []; - - const flattenX = reshape({ - inputs: {x}, - backend, - attrs: { - shape: [ - shapeInfo.batchSize, shapeInfo.outerSize, shapeInfo.dimSize, - shapeInfo.sliceSize - ] - } - }); - - const flattenIndex = reshape({ - inputs: {x: indices}, - backend, - attrs: {shape: [shapeInfo.batchSize, indicesSize / shapeInfo.batchSize]} - }); - - toDispose.push(flattenX); - toDispose.push(flattenIndex); - - const flattenOutputShape = [ - shapeInfo.batchSize, shapeInfo.outerSize, indicesSize / shapeInfo.batchSize, - shapeInfo.sliceSize - ]; - - if (backend.shouldExecuteOnCPU([x, indices])) { - const indicesTensorData = backend.tensorMap.get(flattenIndex.dataId); - const indicesValues = indicesTensorData.values as TypedArray; - const indicesBuffer = - buffer(flattenIndex.shape, flattenIndex.dtype, indicesValues) as - TensorBuffer; - const flattenXTensorData = backend.tensorMap.get(flattenX.dataId); - const xValues = flattenXTensorData.values as TypedArray; - const xBuffer = - buffer(flattenX.shape, flattenX.dtype, xValues) as TensorBuffer; - const outBuf = gatherV2ImplCPU(xBuffer, indicesBuffer, flattenOutputShape); - - toDispose.forEach(t => backend.disposeData(t.dataId)); - - return backend.makeTensorInfo( - shapeInfo.outputShape, outBuf.dtype, outBuf.values as TypedArray); - } - - const program = new GatherProgram(flattenX.shape, flattenOutputShape); - const res = backend.runWebGPUProgram( - program, [flattenX, flattenIndex], flattenX.dtype); - toDispose.push(res); - - const reshaped = reshape( - {inputs: {x: res}, backend, attrs: {shape: shapeInfo.outputShape}}); - toDispose.forEach(t => backend.disposeData(t.dataId)); - return reshaped; -} - -export const gatherV2Config: KernelConfig = { - kernelName: GatherV2, - backendName: 'webgpu', - kernelFunc: gatherV2 as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Greater.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Greater.ts deleted file mode 100644 index 30dc419b7..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Greater.ts +++ /dev/null @@ -1,34 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Greater, KernelConfig} from '@tensorflow/tfjs-core'; - -import {BinaryOpType} from '../binary_op_util'; -import {binaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; -import {greaterImplCPU as cpuGreater} from '../kernel_utils/shared'; - -export const greater = binaryKernelFunc({ - opType: BinaryOpType.GREATER, - cpuKernelImpl: cpuGreater, - dtype: 'bool', -}); - -export const greaterConfig: KernelConfig = { - kernelName: Greater, - backendName: 'webgpu', - kernelFunc: greater -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/GreaterEqual.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/GreaterEqual.ts deleted file mode 100644 index 1bdeca26a..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/GreaterEqual.ts +++ /dev/null @@ -1,34 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {GreaterEqual, KernelConfig} from '@tensorflow/tfjs-core'; - -import {BinaryOpType} from '../binary_op_util'; -import {binaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; -import {greaterEqualImplCPU as cpuGreaterEqual} from '../kernel_utils/shared'; - -export const greaterEqual = binaryKernelFunc({ - opType: BinaryOpType.GREATER_EQUAL, - dtype: 'bool', - cpuKernelImpl: cpuGreaterEqual -}); - -export const greaterEqualConfig: KernelConfig = { - kernelName: GreaterEqual, - backendName: 'webgpu', - kernelFunc: greaterEqual -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/IFFT.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/IFFT.ts deleted file mode 100644 index b5c29e885..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/IFFT.ts +++ /dev/null @@ -1,36 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {IFFT, IFFTInputs, KernelConfig, TensorInfo} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; - -import {fftImpl} from './FFT_impl'; - -export function ifft(args: {inputs: IFFTInputs, backend: WebGPUBackend}): - TensorInfo { - const {inputs, backend} = args; - const {input} = inputs; - - return fftImpl(input, true /* inverse */, backend); -} - -export const ifftConfig: KernelConfig = { - kernelName: IFFT, - backendName: 'webgpu', - kernelFunc: ifft -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Identity.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Identity.ts deleted file mode 100644 index 362d07e8a..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Identity.ts +++ /dev/null @@ -1,34 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Identity, IdentityInputs, KernelConfig, KernelFunc, TensorInfo} from '@tensorflow/tfjs-core'; -import {WebGPUBackend} from '../backend_webgpu'; - -export function identity( - args: {inputs: IdentityInputs, backend: WebGPUBackend}): TensorInfo { - const {inputs} = args; - const {x} = inputs; - - args.backend.incRef(x.dataId); - return {dataId: x.dataId, shape: x.shape, dtype: x.dtype}; -} - -export const identityConfig: KernelConfig = { - kernelName: Identity, - backendName: 'webgpu', - kernelFunc: identity as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Imag.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Imag.ts deleted file mode 100644 index 0c98652da..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Imag.ts +++ /dev/null @@ -1,36 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Imag, ImagInputs, KernelConfig, KernelFunc, TensorInfo} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {identity} from './Identity'; - -export function imag(args: {inputs: ImagInputs, backend: WebGPUBackend}): - TensorInfo { - const {inputs, backend} = args; - const {input} = inputs; - const inputData = backend.tensorMap.get(input.dataId); - - return identity({inputs: {x: inputData.complexTensorInfos.imag}, backend}); -} - -export const imagConfig: KernelConfig = { - kernelName: Imag, - backendName: 'webgpu', - kernelFunc: imag as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/IsFinite.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/IsFinite.ts deleted file mode 100644 index 4f4eb88e4..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/IsFinite.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {IsFinite, KernelConfig} from '@tensorflow/tfjs-core'; - -import {unaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; - -import {UnaryOpType} from '../unary_op_util'; - -export const isFinite = - unaryKernelFunc({opType: UnaryOpType.IS_FINITE, dtype: 'bool'}); - -export const isFiniteConfig: KernelConfig = { - kernelName: IsFinite, - backendName: 'webgpu', - kernelFunc: isFinite -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/IsInf.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/IsInf.ts deleted file mode 100644 index 3d9d3c7e0..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/IsInf.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {IsInf, KernelConfig} from '@tensorflow/tfjs-core'; - -import {unaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; - -import {UnaryOpType} from '../unary_op_util'; - -export const isInf = - unaryKernelFunc({opType: UnaryOpType.IS_INF, dtype: 'bool'}); - -export const isInfConfig: KernelConfig = { - kernelName: IsInf, - backendName: 'webgpu', - kernelFunc: isInf -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/IsNaN.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/IsNaN.ts deleted file mode 100644 index e70592c29..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/IsNaN.ts +++ /dev/null @@ -1,29 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {IsNan, KernelConfig} from '@tensorflow/tfjs-core'; -import {unaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; -import {UnaryOpType} from '../unary_op_util'; - -export const isNaN = - unaryKernelFunc({opType: UnaryOpType.IS_NAN, dtype: 'bool'}); - -export const isNaNConfig: KernelConfig = { - kernelName: IsNan, - backendName: 'webgpu', - kernelFunc: isNaN -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/LRN.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/LRN.ts deleted file mode 100644 index 3290a9adc..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/LRN.ts +++ /dev/null @@ -1,54 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, LRN, LRNAttrs, LRNInputs, TensorInfo} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {LRNProgram, LRNSharedProgram} from '../lrn_webgpu'; - -export function lrn( - args: {inputs: LRNInputs, backend: WebGPUBackend, attrs: LRNAttrs}): - TensorInfo { - const {inputs, backend, attrs} = args; - const {x} = inputs; - const {depthRadius, bias, alpha, beta} = attrs; - - // When the adjacent channels is less than or equal to 16, which could cover - // most cases, we use shared memory version to get better performance. - // The theoretical adjacent channels may be very large, but the shared memory - // size of hardware is limited, so we use the naive version when the adjacent - // channels is large. - let program: LRNProgram|LRNSharedProgram; - if (depthRadius > 16) { - program = new LRNProgram(x.shape); - } else { - program = new LRNSharedProgram(x.shape, depthRadius); - } - const uniformData = [ - {type: 'int32', data: [depthRadius]}, {type: 'float32', data: [bias]}, - {type: 'float32', data: [alpha]}, {type: 'float32', data: [beta]} - ]; - const res = backend.runWebGPUProgram(program, [x], x.dtype, uniformData); - - return res; -} - -export const lrnConfig: KernelConfig = { - kernelName: LRN, - backendName: 'webgpu', - kernelFunc: lrn as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/LRNGrad.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/LRNGrad.ts deleted file mode 100644 index 63fcfccf2..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/LRNGrad.ts +++ /dev/null @@ -1,45 +0,0 @@ -/** - * @license - * Copyright 2023 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, LRNGrad, LRNGradAttrs, LRNGradInputs, TensorInfo} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {LRNGradProgram} from '../lrn_grad_webgpu'; - -export function lrnGrad( - args: {inputs: LRNGradInputs, backend: WebGPUBackend, attrs: LRNGradAttrs}): - TensorInfo { - const {inputs, backend, attrs} = args; - const {x, y, dy} = inputs; - const {depthRadius, bias, alpha, beta} = attrs; - - const program = new LRNGradProgram(x.shape); - const uniformData = [ - {type: 'int32', data: [depthRadius]}, {type: 'float32', data: [bias]}, - {type: 'float32', data: [alpha]}, {type: 'float32', data: [beta]} - ]; - const res = - backend.runWebGPUProgram(program, [x, y, dy], x.dtype, uniformData); - - return res; -} - -export const lrnGradConfig: KernelConfig = { - kernelName: LRNGrad, - backendName: 'webgpu', - kernelFunc: lrnGrad as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/LeakyRelu.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/LeakyRelu.ts deleted file mode 100644 index 61d4bc812..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/LeakyRelu.ts +++ /dev/null @@ -1,42 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, LeakyRelu, LeakyReluAttrs, LeakyReluInputs, TensorInfo} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {UnaryOpType} from '../unary_op_util'; -import {UnaryOpProgram} from '../unary_op_webgpu'; - -export function leakyRelu(args: { - inputs: LeakyReluInputs, - backend: WebGPUBackend, - attrs: LeakyReluAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {x} = inputs; - const {alpha} = attrs; - const uniformData = [{type: 'float32', data: [alpha]}]; - const program = - new UnaryOpProgram(x.shape, UnaryOpType.LEAKYRELU, 'alpha : f32,'); - return backend.runWebGPUProgram(program, [x], 'float32', uniformData); -} - -export const leakyReluConfig: KernelConfig = { - kernelName: LeakyRelu, - backendName: 'webgpu', - kernelFunc: leakyRelu as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Less.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Less.ts deleted file mode 100644 index 470a978be..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Less.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, Less} from '@tensorflow/tfjs-core'; - -import {BinaryOpType} from '../binary_op_util'; -import {binaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; -import {lessImplCPU as cpuLess} from '../kernel_utils/shared'; - -export const less = binaryKernelFunc( - {opType: BinaryOpType.LESS, dtype: 'bool', cpuKernelImpl: cpuLess}); - -export const lessConfig: KernelConfig = { - kernelName: Less, - backendName: 'webgpu', - kernelFunc: less -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/LessEqual.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/LessEqual.ts deleted file mode 100644 index a56f6774a..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/LessEqual.ts +++ /dev/null @@ -1,34 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, LessEqual} from '@tensorflow/tfjs-core'; - -import {BinaryOpType} from '../binary_op_util'; -import {binaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; -import {lessEqualImplCPU as cpuLessEqual} from '../kernel_utils/shared'; - -export const lessEqual = binaryKernelFunc({ - opType: BinaryOpType.LESS_EQUAL, - dtype: 'bool', - cpuKernelImpl: cpuLessEqual -}); - -export const lessEqualConfig: KernelConfig = { - kernelName: LessEqual, - backendName: 'webgpu', - kernelFunc: lessEqual -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/LinSpace.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/LinSpace.ts deleted file mode 100644 index 15f4699a0..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/LinSpace.ts +++ /dev/null @@ -1,39 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, LinSpace, LinSpaceAttrs, TensorInfo} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {LinSpaceProgram} from '../lin_space_webgpu'; - -export function linSpace(args: {backend: WebGPUBackend, attrs: LinSpaceAttrs}): - TensorInfo { - const {backend, attrs} = args; - const {start, stop, num} = attrs; - const step = (stop - start) / (num - 1); - - const program = new LinSpaceProgram(num); - const uniformData = - [{type: 'float32', data: [start]}, {type: 'float32', data: [step]}]; - return backend.runWebGPUProgram(program, [], 'float32', uniformData); -} - -export const linSpaceConfig: KernelConfig = { - kernelName: LinSpace, - backendName: 'webgpu', - kernelFunc: linSpace as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Log.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Log.ts deleted file mode 100644 index a5fc64583..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Log.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, Log} from '@tensorflow/tfjs-core'; -import {unaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; -import {logImplCPU} from '../kernel_utils/shared'; -import {UnaryOpType} from '../unary_op_util'; - -export const log = - unaryKernelFunc({opType: UnaryOpType.LOG, cpuKernelImpl: logImplCPU}); - -export const logConfig: KernelConfig = { - kernelName: Log, - backendName: 'webgpu', - kernelFunc: log -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Log1p.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Log1p.ts deleted file mode 100644 index 2a9e68eb1..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Log1p.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, Log1p} from '@tensorflow/tfjs-core'; - -import {unaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; - -import {UnaryOpType} from '../unary_op_util'; - -export const log1p = unaryKernelFunc({opType: UnaryOpType.LOG1P}); - -export const log1pConfig: KernelConfig = { - kernelName: Log1p, - backendName: 'webgpu', - kernelFunc: log1p -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/LogicalAnd.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/LogicalAnd.ts deleted file mode 100644 index e8931f0d5..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/LogicalAnd.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, LogicalAnd} from '@tensorflow/tfjs-core'; - -import {BinaryOpType} from '../binary_op_util'; -import {binaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; - -export const logicalAnd = - binaryKernelFunc({opType: BinaryOpType.LOGICAL_AND, dtype: 'bool'}); - -export const logicalAndConfig: KernelConfig = { - kernelName: LogicalAnd, - backendName: 'webgpu', - kernelFunc: logicalAnd -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/LogicalNot.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/LogicalNot.ts deleted file mode 100644 index 44b5c9a2c..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/LogicalNot.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, LogicalNot} from '@tensorflow/tfjs-core'; - -import {unaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; - -import {UnaryOpType} from '../unary_op_util'; - -export const logicalNot = unaryKernelFunc({opType: UnaryOpType.LOGICAL_NOT}); - -export const logicalNotConfig: KernelConfig = { - kernelName: LogicalNot, - backendName: 'webgpu', - kernelFunc: logicalNot -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/LogicalOr.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/LogicalOr.ts deleted file mode 100644 index 543ecf4b5..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/LogicalOr.ts +++ /dev/null @@ -1,29 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, LogicalOr} from '@tensorflow/tfjs-core'; - -import {BinaryOpType} from '../binary_op_util'; -import {binaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; - -export const logicalOr = binaryKernelFunc({opType: BinaryOpType.LOGICAL_OR}); - -export const logicalOrConfig: KernelConfig = { - kernelName: LogicalOr, - backendName: 'webgpu', - kernelFunc: logicalOr -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Max.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Max.ts deleted file mode 100644 index 544abd3d7..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Max.ts +++ /dev/null @@ -1,37 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, Max, MaxAttrs, MaxInputs, TensorInfo} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {reduce} from '../kernel_utils/reduce'; - -export function max( - args: {inputs: MaxInputs, backend: WebGPUBackend, attrs: MaxAttrs}): - TensorInfo { - const {inputs, backend, attrs} = args; - const {x} = inputs; - const {reductionIndices, keepDims} = attrs; - - return reduce(x, reductionIndices, keepDims, 'max', backend); -} - -export const maxConfig: KernelConfig = { - kernelName: Max, - backendName: 'webgpu', - kernelFunc: max as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/MaxPool.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/MaxPool.ts deleted file mode 100644 index f8715ee02..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/MaxPool.ts +++ /dev/null @@ -1,40 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {backend_util, KernelConfig, KernelFunc, MaxPool, MaxPoolAttrs, MaxPoolInputs, TensorInfo} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {poolImpl} from './Pool_impl'; - -export function maxPool( - args: {inputs: MaxPoolInputs, backend: WebGPUBackend, attrs: MaxPoolAttrs}): - TensorInfo { - const {inputs, backend, attrs} = args; - const {x} = inputs; - const {filterSize, strides, pad, dimRoundingMode} = attrs; - const dilations = 1; - const convInfo = backend_util.computePool2DInfo( - x.shape as [number, number, number, number], filterSize, strides, - dilations, pad, dimRoundingMode); - - return poolImpl(x, convInfo, 'max', backend); -} - -export const maxPoolConfig: KernelConfig = { - kernelName: MaxPool, - backendName: 'webgpu', - kernelFunc: maxPool as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/MaxPool3D.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/MaxPool3D.ts deleted file mode 100644 index 0fbec5f7e..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/MaxPool3D.ts +++ /dev/null @@ -1,65 +0,0 @@ -/** - * @license - * Copyright 2023 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {backend_util, KernelConfig, KernelFunc, MaxPool3D, MaxPool3DAttrs, MaxPool3DInputs, TensorInfo} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {Pool3DProgram} from '../pool_webgpu'; - -export function maxPool3d(args: { - inputs: MaxPool3DInputs, - backend: WebGPUBackend, - attrs: MaxPool3DAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {x} = inputs; - const {filterSize, strides, pad, dataFormat, dimRoundingMode} = attrs; - const dilations: [number, number, number] = [1, 1, 1]; - - const convInfo = backend_util.computePool3DInfo( - x.shape as [number, number, number, number, number], filterSize, strides, - dilations, pad, dimRoundingMode, dataFormat); - const maxPoolProgram = new Pool3DProgram(convInfo, 'max'); - const dimensions = [ - { - type: 'int32', - data: [convInfo.strideDepth, convInfo.strideHeight, convInfo.strideWidth] - }, - { - type: 'int32', - data: - [convInfo.padInfo.front, convInfo.padInfo.top, convInfo.padInfo.left] - }, - { - type: 'int32', - data: [convInfo.inDepth, convInfo.inHeight, convInfo.inWidth] - }, - { - type: 'int32', - data: [ - convInfo.effectiveFilterDepth, convInfo.effectiveFilterHeight, - convInfo.effectiveFilterWidth - ] - } - ]; - return backend.runWebGPUProgram(maxPoolProgram, [x], x.dtype, dimensions); -} - -export const maxPool3DConfig: KernelConfig = { - kernelName: MaxPool3D, - backendName: 'webgpu', - kernelFunc: maxPool3d as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/MaxPool3DGrad.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/MaxPool3DGrad.ts deleted file mode 100644 index 41d8c3afb..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/MaxPool3DGrad.ts +++ /dev/null @@ -1,102 +0,0 @@ -/** - * @license - * Copyright 2023 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, KernelConfig, KernelFunc, MaxPool3DGrad, MaxPool3DGradAttrs, MaxPool3DGradInputs, TensorInfo} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {MaxPool3DBackpropProgram} from '../max_pool_backprop_webgpu'; -import {Pool3DProgram} from '../pool_webgpu'; - -export function maxPool3DGrad(args: { - inputs: MaxPool3DGradInputs, - backend: WebGPUBackend, - attrs: MaxPool3DGradAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {dy, input} = inputs; - const x = input; - const {filterSize, strides, pad, dimRoundingMode} = attrs; - const dilations: [number, number, number] = [1, 1, 1]; - - const convInfo = backend_util.computePool3DInfo( - x.shape as [number, number, number, number, number], filterSize, strides, - dilations, pad, dimRoundingMode); - - const maxPool3dPositionsProgram = - new Pool3DProgram(convInfo, 'max', true /* get positions */); - let uniformData = [ - { - type: 'int32', - data: [convInfo.strideDepth, convInfo.strideHeight, convInfo.strideWidth] - }, - { - type: 'int32', - data: - [convInfo.padInfo.front, convInfo.padInfo.top, convInfo.padInfo.left] - }, - { - type: 'int32', - data: [convInfo.inDepth, convInfo.inHeight, convInfo.inWidth] - }, - { - type: 'int32', - data: [ - convInfo.effectiveFilterDepth, convInfo.effectiveFilterHeight, - convInfo.effectiveFilterWidth - ] - } - ]; - const maxPool3dPositions = backend.runWebGPUProgram( - maxPool3dPositionsProgram, [x], 'int32', uniformData); - - const maxPool3dBackpropProgram = new MaxPool3DBackpropProgram(convInfo); - uniformData = [ - { - type: 'int32', - data: [convInfo.strideDepth, convInfo.strideHeight, convInfo.strideWidth] - }, - { - type: 'int32', - data: [ - convInfo.effectiveFilterDepth - 1 - convInfo.padInfo.front, - convInfo.effectiveFilterHeight - 1 - convInfo.padInfo.top, - convInfo.effectiveFilterWidth - 1 - convInfo.padInfo.left - ] - }, - { - type: 'int32', - data: [ - convInfo.effectiveFilterDepth, convInfo.effectiveFilterHeight, - convInfo.effectiveFilterWidth - ] - }, - {type: 'int32', data: [convInfo.outDepth]}, - {type: 'int32', data: [convInfo.outHeight]}, - {type: 'int32', data: [convInfo.outWidth]} - ]; - const result = backend.runWebGPUProgram( - maxPool3dBackpropProgram, [dy, maxPool3dPositions], x.dtype, uniformData); - backend.disposeData(maxPool3dPositions.dataId); - - return result; -} - -export const maxPool3DGradConfig: KernelConfig = { - kernelName: MaxPool3DGrad, - backendName: 'webgpu', - kernelFunc: maxPool3DGrad as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/MaxPoolGrad.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/MaxPoolGrad.ts deleted file mode 100644 index f1deb622c..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/MaxPoolGrad.ts +++ /dev/null @@ -1,80 +0,0 @@ -/** - * @license - * Copyright 2023 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, KernelConfig, KernelFunc, MaxPoolGrad, MaxPoolGradAttrs, MaxPoolGradInputs, TensorInfo} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {MaxPool2DBackpropProgram} from '../max_pool_backprop_webgpu'; -import {Pool2DProgram} from '../pool_webgpu'; -import {assertNotComplex} from '../webgpu_util'; - -export function maxPoolGrad(args: { - inputs: MaxPoolGradInputs, - backend: WebGPUBackend, - attrs: MaxPoolGradAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {dy, input, output} = inputs; - const x = input; - assertNotComplex([input, output], 'maxPoolGrad'); - const {filterSize, strides, pad, dimRoundingMode} = attrs; - - const convInfo = backend_util.computePool2DInfo( - x.shape as [number, number, number, number], filterSize, strides, - 1 /* dilations */, pad, dimRoundingMode); - - const maxPoolPositionsProgram = new Pool2DProgram(convInfo, 'max', true); - let uniformData = [ - {type: 'int32', data: [convInfo.strideHeight, convInfo.strideWidth]}, - {type: 'int32', data: [convInfo.padInfo.top, convInfo.padInfo.left]}, - {type: 'int32', data: [convInfo.dilationHeight, convInfo.dilationWidth]}, - {type: 'int32', data: [convInfo.inHeight, convInfo.inWidth]}, { - type: 'int32', - data: [convInfo.effectiveFilterHeight, convInfo.effectiveFilterWidth] - } - ]; - const maxPoolPositions = backend.runWebGPUProgram( - maxPoolPositionsProgram, [x], 'int32', uniformData); - - const maxPoolBackpropProgram = new MaxPool2DBackpropProgram(convInfo); - uniformData = [ - {type: 'int32', data: [convInfo.strideHeight, convInfo.strideWidth]}, { - type: 'int32', - data: [ - convInfo.effectiveFilterHeight - 1 - convInfo.padInfo.top, - convInfo.effectiveFilterWidth - 1 - convInfo.padInfo.left - ] - }, - {type: 'int32', data: [convInfo.dilationHeight, convInfo.dilationWidth]}, { - type: 'int32', - data: [convInfo.effectiveFilterHeight, convInfo.effectiveFilterWidth] - }, - {type: 'int32', data: [convInfo.outHeight]}, - {type: 'int32', data: [convInfo.outWidth]} - ]; - const result = backend.runWebGPUProgram( - maxPoolBackpropProgram, [dy, maxPoolPositions], x.dtype, uniformData); - backend.disposeData(maxPoolPositions.dataId); - - return result; -} - -export const maxPoolGradConfig: KernelConfig = { - kernelName: MaxPoolGrad, - backendName: 'webgpu', - kernelFunc: maxPoolGrad as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/MaxPoolWithArgmax.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/MaxPoolWithArgmax.ts deleted file mode 100644 index e5006ba7a..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/MaxPoolWithArgmax.ts +++ /dev/null @@ -1,70 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {MaxPoolWithArgmax, MaxPoolWithArgmaxAttrs, MaxPoolWithArgmaxInputs} from '@tensorflow/tfjs-core'; -import {backend_util, KernelConfig, KernelFunc, TensorInfo, util} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {Pool2DProgram} from '../pool_webgpu'; - -export function maxPoolWithArgmax(args: { - inputs: MaxPoolWithArgmaxInputs, - attrs: MaxPoolWithArgmaxAttrs, - backend: WebGPUBackend -}): TensorInfo[] { - const {inputs, backend, attrs} = args; - const {filterSize, strides, pad, includeBatchInIndex} = attrs; - const {x} = inputs; - - util.assert( - x.shape.length === 4, - () => `Error in maxPool: input must be rank 4 but got rank ${ - x.shape.length}.`); - const dilations: [number, number] = [1, 1]; - util.assert( - backend_util.eitherStridesOrDilationsAreOne(strides, dilations), - () => 'Error in maxPool: Either strides or dilations must be 1. ' + - `Got strides ${strides} and dilations '${dilations}'`); - - const convInfo = backend_util.computePool2DInfo( - x.shape as [number, number, number, number], filterSize, strides, - dilations, pad); - - const uniformData = [ - {type: 'int32', data: [convInfo.strideHeight, convInfo.strideWidth]}, - {type: 'int32', data: [convInfo.padInfo.top, convInfo.padInfo.left]}, - {type: 'int32', data: [convInfo.dilationHeight, convInfo.dilationWidth]}, - {type: 'int32', data: [convInfo.inHeight, convInfo.inWidth]}, { - type: 'int32', - data: [convInfo.effectiveFilterHeight, convInfo.effectiveFilterWidth] - } - ]; - let program = new Pool2DProgram(convInfo, 'max', false); - const poolOutput = - backend.runWebGPUProgram(program, [x], x.dtype, uniformData); - - program = new Pool2DProgram(convInfo, 'max', true, true, includeBatchInIndex); - const indexOutput = - backend.runWebGPUProgram(program, [x], 'int32', uniformData); - return [poolOutput, indexOutput]; -} - -export const maxPoolWithArgmaxConfig: KernelConfig = { - kernelName: MaxPoolWithArgmax, - backendName: 'webgpu', - kernelFunc: maxPoolWithArgmax as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Maximum.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Maximum.ts deleted file mode 100644 index 85a8bce83..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Maximum.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, Maximum} from '@tensorflow/tfjs-core'; - -import {BinaryOpType} from '../binary_op_util'; -import {binaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; -import {maximumImplCPU as cpuMaximum} from '../kernel_utils/shared'; - -export const maximum = binaryKernelFunc({ - opType: BinaryOpType.MAX, - cpuKernelImpl: cpuMaximum, -}); - -export const maximumConfig: KernelConfig = { - kernelName: Maximum, - backendName: 'webgpu', - kernelFunc: maximum -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Mean.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Mean.ts deleted file mode 100644 index 80c1b418f..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Mean.ts +++ /dev/null @@ -1,37 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, Mean, MeanAttrs, MeanInputs, TensorInfo} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {reduce} from '../kernel_utils/reduce'; - -export function mean( - args: {inputs: MeanInputs, attrs: MeanAttrs, backend: WebGPUBackend}): - TensorInfo { - const {inputs, backend, attrs} = args; - const {x} = inputs; - const {keepDims, axis} = attrs; - - return reduce(x, axis, keepDims, 'mean', backend); -} - -export const meanConfig: KernelConfig = { - kernelName: Mean, - backendName: 'webgpu', - kernelFunc: mean as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Min.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Min.ts deleted file mode 100644 index 0ce7d7919..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Min.ts +++ /dev/null @@ -1,37 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, Min, MinAttrs, MinInputs, TensorInfo} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {reduce} from '../kernel_utils/reduce'; - -export function min( - args: {inputs: MinInputs, backend: WebGPUBackend, attrs: MinAttrs}): - TensorInfo { - const {inputs, backend, attrs} = args; - const {x} = inputs; - const {axis, keepDims} = attrs; - - return reduce(x, axis, keepDims, 'min', backend); -} - -export const minConfig: KernelConfig = { - kernelName: Min, - backendName: 'webgpu', - kernelFunc: min as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Minimum.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Minimum.ts deleted file mode 100644 index 2d2c79745..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Minimum.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, Minimum} from '@tensorflow/tfjs-core'; - -import {BinaryOpType} from '../binary_op_util'; -import {binaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; -import {minimumImplCPU as cpuMinimum} from '../kernel_utils/shared'; - -export const minimum = binaryKernelFunc({ - opType: BinaryOpType.MIN, - cpuKernelImpl: cpuMinimum, -}); - -export const minimumConfig: KernelConfig = { - kernelName: Minimum, - backendName: 'webgpu', - kernelFunc: minimum -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/MirrorPad.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/MirrorPad.ts deleted file mode 100644 index 0a85ef33b..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/MirrorPad.ts +++ /dev/null @@ -1,41 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, MirrorPad, MirrorPadAttrs, MirrorPadInputs} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; - -import {MirrorPadProgram} from '../mirror_pad_webgpu'; - -export const mirrorPadConfig: KernelConfig = { - kernelName: MirrorPad, - backendName: 'webgpu', - kernelFunc: ({inputs, attrs, backend}) => { - const {x} = inputs as MirrorPadInputs; - const {paddings, mode} = attrs as unknown as MirrorPadAttrs; - const webGPUBackend = backend as WebGPUBackend; - - const uniformData = paddings.map(p => { - return {type: 'int32', data: [p[0], p[1]]}; - }); - const program = new MirrorPadProgram(x.shape, paddings, mode); - const output = - webGPUBackend.runWebGPUProgram(program, [x], x.dtype, uniformData); - - return output; - } -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Mod.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Mod.ts deleted file mode 100644 index 7a2a4f6f8..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Mod.ts +++ /dev/null @@ -1,29 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, Mod} from '@tensorflow/tfjs-core'; - -import {BinaryOpType} from '../binary_op_util'; -import {binaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; - -export const mod = binaryKernelFunc({opType: BinaryOpType.MOD}); - -export const modConfig: KernelConfig = { - kernelName: Mod, - backendName: 'webgpu', - kernelFunc: mod -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Multinomial.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Multinomial.ts deleted file mode 100644 index 3f5b0d4de..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Multinomial.ts +++ /dev/null @@ -1,54 +0,0 @@ -/** - * @license - * Copyright 2023 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, Multinomial, MultinomialAttrs, MultinomialInputs, TensorInfo} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {MultinomialProgram} from '../multinomial_webgpu'; - -import {softmax} from './Softmax'; - -export function multinomial(args: { - inputs: MultinomialInputs, - backend: WebGPUBackend, - attrs: MultinomialAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {logits} = inputs; - const {numSamples, seed, normalized} = attrs; - - const probs = normalized ? - logits : - softmax( - {inputs: {logits}, backend, attrs: {dim: logits.shape.length - 1}}); - const batchSize = probs.shape[0]; - const numOutcomes = probs.shape[1]; - const program = new MultinomialProgram(batchSize, numSamples); - const uniformData = - [{type: 'float32', data: [seed]}, {type: 'int32', data: [numOutcomes]}]; - const res = backend.runWebGPUProgram(program, [probs], 'int32', uniformData); - if (!normalized) { - backend.disposeData(probs.dataId); - } - return res; -} - -export const multinomialConfig: KernelConfig = { - kernelName: Multinomial, - backendName: 'webgpu', - kernelFunc: multinomial as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Multiply.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Multiply.ts deleted file mode 100644 index 4a125a3e6..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Multiply.ts +++ /dev/null @@ -1,34 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, Multiply} from '@tensorflow/tfjs-core'; - -import {BinaryOpType} from '../binary_op_util'; -import {binaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; -import {multiplyImplCPU as cpuMultiply} from '../kernel_utils/shared'; - -export const multiplyKernelFunc = binaryKernelFunc({ - opType: BinaryOpType.MUL, - cpuKernelImpl: cpuMultiply, - supportsComplex: true -}); - -export const multiplyConfig: KernelConfig = { - kernelName: Multiply, - backendName: 'webgpu', - kernelFunc: multiplyKernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Neg.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Neg.ts deleted file mode 100644 index 6b348e421..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Neg.ts +++ /dev/null @@ -1,49 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, Neg, NegInputs, TensorInfo, TypedArray} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {negImplCPU} from '../kernel_utils/shared'; - -import {UnaryOpType} from '../unary_op_util'; -import {UnaryOpProgram} from '../unary_op_webgpu'; - -// This doesn't use unaryKernelFunc because negImplCPU is not of type -// SimpleUnaryKernelImplCPU. -export function neg(args: {inputs: NegInputs, backend: WebGPUBackend}): - TensorInfo { - const {inputs, backend} = args; - const {x} = inputs; - - if (backend.shouldExecuteOnCPU([x])) { - const xData = backend.tensorMap.get(x.dataId); - const [outValues, newShape] = - negImplCPU(xData.values as TypedArray, x.shape, x.dtype); - return backend.makeTensorInfo(newShape, x.dtype, outValues); - } - - const program = new UnaryOpProgram(x.shape, UnaryOpType.NEG); - - return backend.runWebGPUProgram(program, [x], x.dtype); -} - -export const negConfig: KernelConfig = { - kernelName: Neg, - backendName: 'webgpu', - kernelFunc: neg as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/NonMaxSuppressionV3.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/NonMaxSuppressionV3.ts deleted file mode 100644 index 2ea2e3716..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/NonMaxSuppressionV3.ts +++ /dev/null @@ -1,48 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {kernel_impls, KernelConfig, KernelFunc, NonMaxSuppressionV3, NonMaxSuppressionV3Attrs, NonMaxSuppressionV3Inputs, TypedArray} from '@tensorflow/tfjs-core'; -import {WebGPUBackend} from '../backend_webgpu'; - -export function nonMaxSuppressionV3(args: { - inputs: NonMaxSuppressionV3Inputs, - backend: WebGPUBackend, - attrs: NonMaxSuppressionV3Attrs -}) { - console.warn( - 'tf.nonMaxSuppression() in webgpu locks the UI thread. ' + - 'Call tf.nonMaxSuppressionAsync() instead'); - - const {inputs, backend, attrs} = args; - const {boxes, scores} = inputs; - const {maxOutputSize, iouThreshold, scoreThreshold} = attrs; - - const boxesVals = backend.readSync(boxes.dataId) as TypedArray; - const scoresVals = backend.readSync(scores.dataId) as TypedArray; - - const {selectedIndices} = kernel_impls.nonMaxSuppressionV3Impl( - boxesVals, scoresVals, maxOutputSize, iouThreshold, scoreThreshold); - - return backend.makeTensorInfo( - [selectedIndices.length], 'int32', new Int32Array(selectedIndices)); -} - -export const nonMaxSuppressionV3Config: KernelConfig = { - kernelName: NonMaxSuppressionV3, - backendName: 'webgpu', - kernelFunc: nonMaxSuppressionV3 as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/NonMaxSuppressionV5.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/NonMaxSuppressionV5.ts deleted file mode 100644 index 5b7b42887..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/NonMaxSuppressionV5.ts +++ /dev/null @@ -1,60 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {kernel_impls, KernelConfig, KernelFunc, NonMaxSuppressionV5, NonMaxSuppressionV5Attrs, NonMaxSuppressionV5Inputs, TensorInfo} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -export type TypedArray = Float32Array|Int32Array|Uint8Array; - -export function nonMaxSuppressionV5(args: { - inputs: NonMaxSuppressionV5Inputs, - backend: WebGPUBackend, - attrs: NonMaxSuppressionV5Attrs -}): [TensorInfo, TensorInfo] { - console.warn( - 'tf.nonMaxSuppression() in webgpu locks the UI thread. ' + - 'Call tf.nonMaxSuppressionAsync() instead'); - - const {inputs, backend, attrs} = args; - const {boxes, scores} = inputs; - const {maxOutputSize, iouThreshold, scoreThreshold, softNmsSigma} = attrs; - - const boxesVals = backend.readSync(boxes.dataId) as TypedArray; - const scoresVals = backend.readSync(scores.dataId) as TypedArray; - - const maxOutputSizeVal = maxOutputSize; - const iouThresholdVal = iouThreshold; - const scoreThresholdVal = scoreThreshold; - const softNmsSigmaVal = softNmsSigma; - - const {selectedIndices, selectedScores} = - kernel_impls.nonMaxSuppressionV5Impl( - boxesVals, scoresVals, maxOutputSizeVal, iouThresholdVal, - scoreThresholdVal, softNmsSigmaVal); - - return [ - backend.makeTensorInfo( - [selectedIndices.length], 'int32', new Int32Array(selectedIndices)), - backend.makeTensorInfo( - [selectedScores.length], 'float32', new Float32Array(selectedScores)) - ]; -} - -export const nonMaxSuppressionV5Config: KernelConfig = { - kernelName: NonMaxSuppressionV5, - backendName: 'webgpu', - kernelFunc: nonMaxSuppressionV5 as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/NotEqual.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/NotEqual.ts deleted file mode 100644 index b563e51a9..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/NotEqual.ts +++ /dev/null @@ -1,34 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, NotEqual} from '@tensorflow/tfjs-core'; - -import {BinaryOpType} from '../binary_op_util'; -import {binaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; -import {notEqualImplCPU as cpuNotEqual} from '../kernel_utils/shared'; - -export const notEqual = binaryKernelFunc({ - opType: BinaryOpType.NOT_EQUAL, - dtype: 'bool', - cpuKernelImpl: cpuNotEqual -}); - -export const notEqualConfig: KernelConfig = { - kernelName: NotEqual, - backendName: 'webgpu', - kernelFunc: notEqual -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/OneHot.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/OneHot.ts deleted file mode 100644 index 084ce524d..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/OneHot.ts +++ /dev/null @@ -1,53 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, OneHot, OneHotAttrs, OneHotInputs, TensorInfo, util} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {OneHotProgram} from '../onehot_webgpu'; -import {reshape} from './Reshape'; - -export function oneHot( - args: {inputs: OneHotInputs, backend: WebGPUBackend, attrs: OneHotAttrs}): - TensorInfo { - const {inputs, backend, attrs} = args; - const {indices} = inputs; - const {dtype, depth, onValue, offValue} = attrs; - - const indicesSize = util.sizeFromShape(indices.shape); - const program = new OneHotProgram(indicesSize, depth); - const reshaped = - reshape({inputs: {x: indices}, backend, attrs: {shape: [indicesSize]}}); - - const uniformData = - [{type: 'float32', data: [onValue]}, {type: 'float32', data: [offValue]}]; - const result = - backend.runWebGPUProgram(program, [reshaped], dtype, uniformData); - backend.disposeData(reshaped.dataId); - - const outShape = [...indices.shape, depth]; - const out = reshape({inputs: {x: result}, backend, attrs: {shape: outShape}}); - backend.disposeData(result.dataId); - - return out; -} - -export const oneHotConfig: KernelConfig = { - kernelName: OneHot, - backendName: 'webgpu', - kernelFunc: oneHot as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/OnesLike.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/OnesLike.ts deleted file mode 100644 index ff7478e6a..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/OnesLike.ts +++ /dev/null @@ -1,58 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, OnesLike, OnesLikeInputs, TensorInfo} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; - -import {complex} from './Complex'; -import {fill} from './Fill'; -import {imag} from './Imag'; -import {real} from './Real'; -import {zerosLike} from './ZerosLike'; - -export function onesLike( - args: {inputs: OnesLikeInputs, backend: WebGPUBackend}): TensorInfo { - const {inputs, backend} = args; - const {x} = inputs; - - if (x.dtype === 'string') { - throw new Error('onesLike is not supported under string dtype'); - } else if (x.dtype === 'complex64') { - const realPart = real({inputs: {input: x}, backend}); - const r = onesLike({inputs: {x: realPart}, backend}); - const imagPart = imag({inputs: {input: x}, backend}); - const i = zerosLike({inputs: {x: imagPart}, backend}); - - const result = complex({inputs: {real: r, imag: i}, backend}); - - backend.disposeData(realPart.dataId); - backend.disposeData(r.dataId); - backend.disposeData(imagPart.dataId); - backend.disposeData(i.dataId); - - return result; - } else { - return fill({attrs: {shape: x.shape, dtype: x.dtype, value: 1}, backend}); - } -} - -export const onesLikeConfig: KernelConfig = { - kernelName: OnesLike, - backendName: 'webgpu', - kernelFunc: onesLike as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Pack.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Pack.ts deleted file mode 100644 index a801db914..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Pack.ts +++ /dev/null @@ -1,66 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, Pack, PackAttrs, PackInputs, TensorInfo, util} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {concat} from './Concat'; -import {expandDims} from './ExpandDims'; - -export function pack( - args: {inputs: PackInputs, backend: WebGPUBackend, attrs: PackAttrs}): - TensorInfo { - const {inputs, backend, attrs} = args; - const {axis} = attrs; - - if (inputs.length === 1) { - return expandDims( - {inputs: {input: inputs[0]}, backend, attrs: {dim: axis}}); - } - - const shape = inputs[0].shape; - const dtype = inputs[0].dtype; - - inputs.forEach(t => { - util.assertShapesMatch( - shape, t.shape, - 'All tensors passed to stack must have matching shapes'); - util.assert( - dtype === t.dtype, - () => 'All tensors passed to stack must have matching dtypes'); - }); - - const intermediateTensorInfos: TensorInfo[] = []; - const expandedTensors = inputs.map(t => { - const expandedT = - expandDims({inputs: {input: t}, backend, attrs: {dim: axis}}); - intermediateTensorInfos.push(expandedT); - return expandedT; - }); - - const result = concat({inputs: expandedTensors, backend, attrs: {axis}}); - - intermediateTensorInfos.forEach(t => backend.disposeData(t.dataId)); - - return result; -} - -export const packConfig: KernelConfig = { - kernelName: Pack, - backendName: 'webgpu', - kernelFunc: pack as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/PadV2.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/PadV2.ts deleted file mode 100644 index 3ea31229c..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/PadV2.ts +++ /dev/null @@ -1,56 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, PadV2, PadV2Attrs, PadV2Inputs, TensorInfo, util} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {identity} from './Identity'; -import {PadProgram} from '../pad_webgpu'; -import {fill} from './Fill'; - -export const padV2 = - (args: {inputs: PadV2Inputs, - backend: WebGPUBackend, - attrs: PadV2Attrs}): TensorInfo => { - const {inputs, backend, attrs} = args; - const {x} = inputs; - const {paddings, constantValue} = attrs; - if (paddings.every(p => util.arraysEqual(p, [0, 0]))) { - return identity({inputs: {x}, backend}); - } - if (util.sizeFromShape(x.shape) === 0) { - // Short-circuit the computation, since x doesn't have value, only - // the shape is used to compute output shape to pad. - const outputShape = paddings.map( - (p, i) => - p[0] /* beforePad */ + x.shape[i] + p[1] /* afterPad */); - return fill({ - backend, - attrs: {shape: outputShape, value: constantValue, dtype: x.dtype} - }); - } - const uniformData = [{type: 'float32', data: [constantValue]}]; - paddings.map(p => uniformData.push({type: 'int32', data: [p[0], p[1]]})); - const program = new PadProgram(x.shape, paddings); - return backend.runWebGPUProgram(program, [x], x.dtype, uniformData); - }; - -export const padV2Config: KernelConfig = { - kernelName: PadV2, - backendName: 'webgpu', - kernelFunc: padV2 as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Pool_impl.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Pool_impl.ts deleted file mode 100644 index be41c060f..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Pool_impl.ts +++ /dev/null @@ -1,96 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {backend_util, TensorInfo, util} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {PoolWithFilterSizeEqualsOneProgram} from '../pool_filtersizeone_webgpu'; -import {Pool2DProgram} from '../pool_webgpu'; - -import {identity} from './Identity'; -import {max} from './Max'; -import {mean} from './Mean'; -import {reshape} from './Reshape'; - -type PoolType = 'max'|'avg'; -export function poolImpl( - x: TensorInfo, convInfo: backend_util.Conv2DInfo, poolType: PoolType, - backend: WebGPUBackend): TensorInfo { - if (convInfo.filterWidth === 1 && convInfo.filterHeight === 1 && - util.arraysEqual(convInfo.inShape, convInfo.outShape)) { - return identity({inputs: {x}, backend}); - } - - if (convInfo.filterWidth === convInfo.inWidth && - convInfo.filterHeight === convInfo.inHeight && convInfo.batchSize === 1 && - convInfo.padInfo.type === 'VALID') { - const length = x.shape.length; - const reshapeX = reshape({ - inputs: {x}, - backend, - attrs: { - shape: [ - x.shape[length - 3] * x.shape[length - 2] /* height * width */, - x.shape[length - 1] /* channel */ - ] - } - }); - let reduceX; - if (poolType === 'avg') { - reduceX = mean( - {inputs: {x: reshapeX}, backend, attrs: {axis: 0, keepDims: false}}); - } else { - util.assert(poolType === 'max', () => `Invalid pool type ${poolType}`); - reduceX = max({ - inputs: {x: reshapeX}, - backend, - attrs: {reductionIndices: 0, keepDims: false} - }); - } - - const result = reshape( - {inputs: {x: reduceX}, backend, attrs: {shape: convInfo.outShape}}); - backend.disposeData(reshapeX.dataId); - backend.disposeData(reduceX.dataId); - return result; - } - - let program: Pool2DProgram|PoolWithFilterSizeEqualsOneProgram; - const dimensions = - [{type: 'int32', data: [convInfo.strideHeight, convInfo.strideWidth]}]; - if (convInfo.filterHeight === 1 && convInfo.filterWidth === 1) { - program = new PoolWithFilterSizeEqualsOneProgram(convInfo); - } else { - if (poolType === 'avg') { - program = new Pool2DProgram(convInfo, 'avg'); - } else { - util.assert(poolType === 'max', () => `Invalid pool type ${poolType}`); - program = new Pool2DProgram(convInfo, 'max'); - } - - dimensions.push( - {type: 'int32', data: [convInfo.padInfo.top, convInfo.padInfo.left]}, { - type: 'int32', - data: [convInfo.dilationHeight, convInfo.dilationWidth] - }, - {type: 'int32', data: [convInfo.inHeight, convInfo.inWidth]}, { - type: 'int32', - data: [convInfo.effectiveFilterHeight, convInfo.effectiveFilterWidth] - }); - } - - return backend.runWebGPUProgram(program, [x], x.dtype, dimensions); -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Pow.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Pow.ts deleted file mode 100644 index 0064645cd..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Pow.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, Pow} from '@tensorflow/tfjs-core'; - -import {BinaryOpType} from '../binary_op_util'; -import {binaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; - -export const pow = binaryKernelFunc({ - opType: BinaryOpType.POW, -}); - -export const powConfig: KernelConfig = { - kernelName: Pow, - backendName: 'webgpu', - kernelFunc: pow -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Prelu.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Prelu.ts deleted file mode 100644 index 4b1a384ce..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Prelu.ts +++ /dev/null @@ -1,38 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, Prelu, PreluInputs, TensorInfo} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; - -import {BinaryOpType} from '../binary_op_util'; -import {BinaryOpProgram} from '../binary_op_webgpu'; - -export function prelu(args: {inputs: PreluInputs, backend: WebGPUBackend}): - TensorInfo { - const {inputs, backend} = args; - const {x, alpha} = inputs; - - const program = new BinaryOpProgram(BinaryOpType.PRELU, x.shape, alpha.shape); - return backend.runWebGPUProgram(program, [x, alpha], 'float32'); -} - -export const preluConfig: KernelConfig = { - kernelName: Prelu, - backendName: 'webgpu', - kernelFunc: prelu as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Prod.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Prod.ts deleted file mode 100644 index 33f9df15d..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Prod.ts +++ /dev/null @@ -1,37 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, Prod, ProdAttrs, ProdInputs, TensorInfo} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {reduce} from '../kernel_utils/reduce'; - -export function prod( - args: {inputs: ProdInputs, backend: WebGPUBackend, attrs: ProdAttrs}): - TensorInfo { - const {inputs, backend, attrs} = args; - const {x} = inputs; - const {axis, keepDims} = attrs; - - return reduce(x, axis, keepDims, 'prod', backend); -} - -export const prodConfig: KernelConfig = { - kernelName: Prod, - backendName: 'webgpu', - kernelFunc: prod as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Range.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Range.ts deleted file mode 100644 index 2cc96047f..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Range.ts +++ /dev/null @@ -1,35 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, Range, RangeAttrs, TensorInfo} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {rangeImplCPU} from '../kernel_utils/shared'; - -export const range = - (args: {backend: WebGPUBackend, attrs: RangeAttrs}): TensorInfo => { - const {backend, attrs} = args; - const {start, stop, step, dtype} = attrs; - const values = rangeImplCPU(start, stop, step, dtype); - return backend.makeTensorInfo([values.length], dtype, values); - }; - -export const rangeConfig: KernelConfig = { - kernelName: Range, - backendName: 'webgpu', - kernelFunc: range as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Real.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Real.ts deleted file mode 100644 index d93959823..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Real.ts +++ /dev/null @@ -1,36 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, Real, RealInputs, TensorInfo} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {identity} from './Identity'; - -export function real(args: {inputs: RealInputs, backend: WebGPUBackend}): - TensorInfo { - const {inputs, backend} = args; - const {input} = inputs; - const inputData = backend.tensorMap.get(input.dataId); - - return identity({inputs: {x: inputData.complexTensorInfos.real}, backend}); -} - -export const realConfig: KernelConfig = { - kernelName: Real, - backendName: 'webgpu', - kernelFunc: real as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/RealDiv.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/RealDiv.ts deleted file mode 100644 index e11888b7c..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/RealDiv.ts +++ /dev/null @@ -1,29 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, RealDiv} from '@tensorflow/tfjs-core'; - -import {BinaryOpType} from '../binary_op_util'; -import {binaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; - -export const realDiv = binaryKernelFunc({opType: BinaryOpType.DIV}); - -export const realDivConfig: KernelConfig = { - kernelName: RealDiv, - backendName: 'webgpu', - kernelFunc: realDiv as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Reciprocal.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Reciprocal.ts deleted file mode 100644 index f5cc4c88b..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Reciprocal.ts +++ /dev/null @@ -1,28 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, Reciprocal} from '@tensorflow/tfjs-core'; -import {unaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; -import {UnaryOpType} from '../unary_op_util'; - -export const reciprocal = unaryKernelFunc({opType: UnaryOpType.RECIPROCAL}); - -export const reciprocalConfig: KernelConfig = { - kernelName: Reciprocal, - backendName: 'webgpu', - kernelFunc: reciprocal -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Relu.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Relu.ts deleted file mode 100644 index e8543576e..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Relu.ts +++ /dev/null @@ -1,28 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, Relu} from '@tensorflow/tfjs-core'; -import {unaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; -import {UnaryOpType} from '../unary_op_util'; - -export const relu = unaryKernelFunc({opType: UnaryOpType.RELU}); - -export const reluConfig: KernelConfig = { - kernelName: Relu, - backendName: 'webgpu', - kernelFunc: relu -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Relu6.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Relu6.ts deleted file mode 100644 index 5b6234365..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Relu6.ts +++ /dev/null @@ -1,28 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, Relu6} from '@tensorflow/tfjs-core'; -import {unaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; -import {UnaryOpType} from '../unary_op_util'; - -export const relu6 = unaryKernelFunc({opType: UnaryOpType.RELU6}); - -export const relu6Config: KernelConfig = { - kernelName: Relu6, - backendName: 'webgpu', - kernelFunc: relu6 -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Reshape.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Reshape.ts deleted file mode 100644 index 81329caba..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Reshape.ts +++ /dev/null @@ -1,48 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, Reshape, ReshapeAttrs, ReshapeInputs, TensorInfo, util} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; - -export function reshape( - args: {inputs: ReshapeInputs, backend: WebGPUBackend, attrs: ReshapeAttrs}): - TensorInfo { - const {inputs, attrs} = args; - const {x} = inputs; - const {shape} = attrs; - - const xSize = util.sizeFromShape(x.shape); - const $shape = util.inferFromImplicitShape(shape, xSize); - const $xSize = util.sizeFromShape($shape); - - util.assert( - xSize === $xSize, - () => `The new shape (${$shape}) has ${$xSize} elements and the old ` + - `shape (${x.shape}) has ${xSize} elements. The new shape and old ` + - `shape must have the same number of elements.`); - - // Backend needs to track refCount for the dataId for reshape op - args.backend.incRef(x.dataId); - return {dataId: x.dataId, shape: $shape, dtype: x.dtype}; -} - -export const reshapeConfig: KernelConfig = { - kernelName: Reshape, - backendName: 'webgpu', - kernelFunc: reshape as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/ResizeBilinear.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/ResizeBilinear.ts deleted file mode 100644 index 84b7a5d87..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/ResizeBilinear.ts +++ /dev/null @@ -1,51 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, ResizeBilinear, ResizeBilinearAttrs, ResizeBilinearInputs, TensorInfo} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {ResizeBilinearProgram} from '../resize_bilinear_webgpu'; - -export function resizeBilinear(args: { - inputs: ResizeBilinearInputs, - backend: WebGPUBackend, - attrs: ResizeBilinearAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {images} = inputs; - const {alignCorners, size, halfPixelCenters} = attrs; - - const [newHeight, newWidth] = size; - const adjustHeight = alignCorners && newHeight > 1 ? 1.0 : 0.0; - const adjustWidth = alignCorners && newWidth > 1 ? 1.0 : 0.0; - const halfPixelCentersValue = halfPixelCenters ? 0.5 : 0.0; - const uniformData = [ - {type: 'float32', data: [adjustHeight, adjustWidth]}, - {type: 'float32', data: [halfPixelCentersValue]} - ]; - - const program = new ResizeBilinearProgram( - images.shape as [number, number, number, number], newHeight, newWidth); - - return backend.runWebGPUProgram(program, [images], 'float32', uniformData); -} - -export const resizeBilinearConfig: KernelConfig = { - kernelName: ResizeBilinear, - backendName: 'webgpu', - kernelFunc: resizeBilinear as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/ResizeBilinearGrad.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/ResizeBilinearGrad.ts deleted file mode 100644 index 7af86c719..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/ResizeBilinearGrad.ts +++ /dev/null @@ -1,75 +0,0 @@ -/** - * @license - * Copyright 2023 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, ResizeBilinearGrad, ResizeBilinearGradAttrs, ResizeBilinearGradInputs, TensorInfo} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {ResizeBilinearBackpropProgram} from '../resize_bilinear_backprop_webgpu'; - -export function resizeBilinearGrad(args: { - inputs: ResizeBilinearGradInputs, - backend: WebGPUBackend, - attrs: ResizeBilinearGradAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {images, dy} = inputs; - const {alignCorners} = attrs; - - const [, xHeight, xWidth, ] = - images.shape as [number, number, number, number]; - const [, yHeight, yWidth] = dy.shape as [number, number, number, number]; - - const effectiveXSize: [number, number] = [ - (alignCorners && yHeight > 1) ? xHeight - 1 : xHeight, - (alignCorners && yWidth > 1) ? xWidth - 1 : xWidth - ]; - - const effectiveYSize: [number, number] = [ - (alignCorners && yHeight > 1) ? yHeight - 1 : yHeight, - (alignCorners && yWidth > 1) ? yWidth - 1 : yWidth - ]; - - const heightScale = effectiveXSize[0] / effectiveYSize[0]; - const widthScale = effectiveXSize[1] / effectiveYSize[1]; - - const invHeightScale = 1 / heightScale; - const invWidthScale = 1 / widthScale; - - // This defines the size of the window of values around a particular - // index in dy that we want to search for contributions to dx. - const winHeight = (Math.ceil(invHeightScale) * 2) + 2; - const winWidth = (Math.ceil(invWidthScale) * 2) + 2; - - const program = new ResizeBilinearBackpropProgram( - images.shape as [number, number, number, number], alignCorners); - const uniformData = [ - {type: 'int32', data: effectiveXSize}, - {type: 'int32', data: effectiveYSize}, - {type: 'float32', data: [heightScale]}, - {type: 'float32', data: [widthScale]}, - {type: 'float32', data: [invHeightScale]}, - {type: 'float32', data: [invWidthScale]}, - {type: 'int32', data: [winHeight]}, {type: 'int32', data: [winWidth]} - ]; - return backend.runWebGPUProgram(program, [dy], dy.dtype, uniformData); -} - -export const resizeBilinearGradConfig: KernelConfig = { - kernelName: ResizeBilinearGrad, - backendName: 'webgpu', - kernelFunc: resizeBilinearGrad as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/ResizeNearestNeighbor.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/ResizeNearestNeighbor.ts deleted file mode 100644 index c860f888c..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/ResizeNearestNeighbor.ts +++ /dev/null @@ -1,52 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, ResizeNearestNeighbor, ResizeNearestNeighborAttrs, ResizeNearestNeighborInputs, TensorInfo} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {ResizeNearestNeighborProgram} from '../resize_nearest_neighbor_webgpu'; - -export function resizeNearestNeighbor(args: { - inputs: ResizeNearestNeighborInputs, - backend: WebGPUBackend, - attrs: ResizeNearestNeighborAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {images} = inputs; - const {alignCorners, halfPixelCenters, size} = attrs; - - const [newHeight, newWidth] = size; - const adjustHeight = alignCorners && newHeight > 1 ? 1.0 : 0.0; - const adjustWidth = alignCorners && newWidth > 1 ? 1.0 : 0.0; - // When align corners is false, we rounds the value with floor. - const roundBase = alignCorners ? 0.5 : 0.0; - const uniformData = [ - {type: 'float32', data: [adjustHeight, adjustWidth]}, - {type: 'float32', data: [roundBase]} - ]; - - const program = new ResizeNearestNeighborProgram( - images.shape as [number, number, number, number], newHeight, newWidth, - halfPixelCenters); - return backend.runWebGPUProgram(program, [images], images.dtype, uniformData); -} - -export const resizeNearestNeighborConfig: KernelConfig = { - kernelName: ResizeNearestNeighbor, - backendName: 'webgpu', - kernelFunc: resizeNearestNeighbor as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/ResizeNearestNeighborGrad.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/ResizeNearestNeighborGrad.ts deleted file mode 100644 index 19df64f0d..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/ResizeNearestNeighborGrad.ts +++ /dev/null @@ -1,72 +0,0 @@ -/** - * @license - * Copyright 2023 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, ResizeNearestNeighborGrad, ResizeNearestNeighborGradAttrs, ResizeNearestNeighborGradInputs, TensorInfo} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {ResizeNearestNeigborBackpropProgram} from '../resize_nearest_neighbor_backprop_webgpu'; - -export function resizeNearestNeighborGrad(args: { - inputs: ResizeNearestNeighborGradInputs, - backend: WebGPUBackend, - attrs: ResizeNearestNeighborGradAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {images, dy} = inputs; - const {alignCorners} = attrs; - - const [, xHeight, xWidth] = images.shape as [number, number, number, number]; - const [, yHeight, yWidth] = dy.shape as [number, number, number, number]; - - const effectiveXSize: [number, number] = [ - (alignCorners && yHeight > 1) ? xHeight - 1 : xHeight, - (alignCorners && yWidth > 1) ? xWidth - 1 : xWidth - ]; - - const effectiveYSize: [number, number] = [ - (alignCorners && yHeight > 1) ? yHeight - 1 : yHeight, - (alignCorners && yWidth > 1) ? yWidth - 1 : yWidth - ]; - - const heightScale = effectiveXSize[0] / effectiveYSize[0]; - const widthScale = effectiveXSize[1] / effectiveYSize[1]; - - const invHeightScale = 1 / heightScale; - const invWidthScale = 1 / widthScale; - - // This defines the size of the window of values around a particular - // index in dy that we want to search for contributions to dx. - const winHeight = (Math.ceil(invHeightScale) * 2) + 2; - const winWidth = (Math.ceil(invWidthScale) * 2) + 2; - - const program = new ResizeNearestNeigborBackpropProgram( - images.shape as [number, number, number, number], alignCorners); - const uniformData = [ - {type: 'int32', data: effectiveXSize}, - {type: 'int32', data: effectiveYSize}, - {type: 'float32', data: [invHeightScale]}, - {type: 'float32', data: [invWidthScale]}, - {type: 'int32', data: [winHeight]}, {type: 'int32', data: [winWidth]} - ]; - return backend.runWebGPUProgram(program, [dy], dy.dtype, uniformData); -} - -export const resizeNearestNeighborGradConfig: KernelConfig = { - kernelName: ResizeNearestNeighborGrad, - backendName: 'webgpu', - kernelFunc: resizeNearestNeighborGrad as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Reverse.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Reverse.ts deleted file mode 100644 index 5a6f26812..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Reverse.ts +++ /dev/null @@ -1,71 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, Reverse, ReverseAttrs, ReverseInputs, TensorInfo, util} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {ReverseProgram} from '../reverse_webgpu'; - -import {identity} from './Identity'; -import {reshape} from './Reshape'; - -export function reverse( - args: {inputs: ReverseInputs, backend: WebGPUBackend, attrs: ReverseAttrs}): - TensorInfo { - const {inputs, backend, attrs} = args; - const {x} = inputs; - const {dims} = attrs; - - const xRank = x.shape.length; - if (xRank === 0) { - return identity({inputs: {x}, backend}); - } - - const xShape = x.shape; - const xShape4D: [number, number, number, number] = [1, 1, 1, 1]; - xShape.forEach((d, i) => { - const index = i + 4 - xRank; - xShape4D[index] = d; - }); - - const axes = util.parseAxisParam(dims, x.shape); - const dims4D: [number, number, number, number] = [0, 0, 0, 0]; - axes.forEach(ax => { - const index = ax + 4 - xRank; - dims4D[index] = 1; - }); - const uniformData = [{type: 'int32', data: dims4D}]; - - const xReshaped = reshape({inputs: {x}, backend, attrs: {shape: xShape4D}}); - - const program = new ReverseProgram(xShape4D); - const values = backend.runWebGPUProgram( - program, [xReshaped], xReshaped.dtype, uniformData); - backend.disposeData(xReshaped.dataId); - - const result = - reshape({inputs: {x: values}, backend, attrs: {shape: xShape}}); - backend.disposeData(values.dataId); - - return result; -} - -export const reverseConfig: KernelConfig = { - kernelName: Reverse, - backendName: 'webgpu', - kernelFunc: reverse as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/RotateWithOffset.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/RotateWithOffset.ts deleted file mode 100644 index fd8da3b3a..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/RotateWithOffset.ts +++ /dev/null @@ -1,54 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, KernelConfig, Tensor4D} from '@tensorflow/tfjs-core'; -import {RotateWithOffset, RotateWithOffsetAttrs, RotateWithOffsetInputs} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {RotateProgram} from '../rotate_webgpu'; - -export const rotateWithOffsetConfig: KernelConfig = { - kernelName: RotateWithOffset, - backendName: 'webgpu', - kernelFunc: ({inputs, attrs, backend}) => { - const {image} = inputs as RotateWithOffsetInputs; - const {radians, fillValue, center} = - attrs as unknown as RotateWithOffsetAttrs; - const webgpuBackend = backend as WebGPUBackend; - - const program = new RotateProgram((image as Tensor4D).shape, fillValue); - const [centerX, centerY] = - backend_util.getImageCenter(center, image.shape[1], image.shape[2]); - const uniformData = [ - {type: 'float32', data: [centerX]}, - {type: 'float32', data: [centerY]}, - {type: 'float32', data: [Math.sin(radians)]}, - {type: 'float32', data: [Math.cos(radians)]} - ]; - - if (typeof fillValue === 'number') { - uniformData.push( - {type: 'float32', data: [Number.parseFloat(fillValue.toFixed(2))]}); - } else { - uniformData.push({type: 'float32', data: fillValue}); - } - - const output = webgpuBackend.runWebGPUProgram( - program, [image], image.dtype, uniformData); - return output; - } - }; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Round.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Round.ts deleted file mode 100644 index de95f634b..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Round.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, Round} from '@tensorflow/tfjs-core'; - -import {unaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; - -import {UnaryOpType} from '../unary_op_util'; - -export const round = unaryKernelFunc({opType: UnaryOpType.ROUND}); - -export const roundConfig: KernelConfig = { - kernelName: Round, - backendName: 'webgpu', - kernelFunc: round -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Rsqrt.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Rsqrt.ts deleted file mode 100644 index a6cba8cc5..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Rsqrt.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, Rsqrt} from '@tensorflow/tfjs-core'; -import {unaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; -import {rsqrtImplCPU} from '../kernel_utils/shared'; -import {UnaryOpType} from '../unary_op_util'; - -export const rsqrt = - unaryKernelFunc({opType: UnaryOpType.RSQRT, cpuKernelImpl: rsqrtImplCPU}); - -export const rsqrtConfig: KernelConfig = { - kernelName: Rsqrt, - backendName: 'webgpu', - kernelFunc: rsqrt -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/ScatterNd.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/ScatterNd.ts deleted file mode 100644 index 9c148b420..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/ScatterNd.ts +++ /dev/null @@ -1,76 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, KernelConfig, KernelFunc, ScatterNd, ScatterNdAttrs, ScatterNdInputs, TensorInfo, util} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {ScatterProgram} from '../scatter_webgpu'; - -import {fill} from './Fill'; -import {reshape} from './Reshape'; - -export function scatterNd(args: { - inputs: ScatterNdInputs, - backend: WebGPUBackend, - attrs: ScatterNdAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {indices, updates} = inputs; - const {shape} = attrs; - - const {sliceRank, numUpdates, sliceSize, strides, outputSize} = - backend_util.calculateShapes(updates, indices, shape); - - const flattenShape = [outputSize / sliceSize, sliceSize]; - - if (outputSize === 0) { - return backend.makeTensorInfo(shape, indices.dtype); - } - - const flattenIndices = reshape( - {inputs: {x: indices}, backend, attrs: {shape: [numUpdates, sliceRank]}}); - const flattenX = reshape( - {inputs: {x: updates}, backend, attrs: {shape: [numUpdates, sliceSize]}}); - - const type = flattenX.dtype; - const output = - fill({backend, attrs: {shape: flattenShape, value: 0, dtype: type}}); - const size = util.sizeFromShape(flattenX.shape); - const uniformData = [ - {type: 'int32', data: [sliceRank]}, {type: 'int32', data: strides}, - {type: 'int32', data: [size]} - ]; - const program = new ScatterProgram( - flattenX.shape, sliceRank, flattenIndices.shape.length, - flattenX.shape.length, strides, flattenShape, type); - const res = backend.runWebGPUProgram( - program, [flattenX, flattenIndices], type, uniformData, output); - - const reshaped = reshape({inputs: {x: res}, backend, attrs: {shape}}); - - backend.disposeData(flattenIndices.dataId); - backend.disposeData(flattenX.dataId); - backend.disposeData(res.dataId); - - return reshaped; -} - -export const scatterNdConfig: KernelConfig = { - kernelName: ScatterNd, - backendName: 'webgpu', - kernelFunc: scatterNd as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/SearchSorted.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/SearchSorted.ts deleted file mode 100644 index b7ef60bf6..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/SearchSorted.ts +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, SearchSorted, SearchSortedAttrs, SearchSortedInputs, TensorInfo} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {SearchSortedProgram} from '../search_sorted_webgpu'; - -export function searchSorted(args: { - inputs: SearchSortedInputs, - backend: WebGPUBackend, - attrs: SearchSortedAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {sortedSequence, values} = inputs; - const {side} = attrs; - - const program = - new SearchSortedProgram([values.shape[0], values.shape[1]], side); - const uniformData = [{type: 'int32', data: [sortedSequence.shape[1]]}]; - return backend.runWebGPUProgram( - program, [sortedSequence, values], 'int32', uniformData); -} - -export const searchSortedConfig: KernelConfig = { - kernelName: SearchSorted, - backendName: 'webgpu', - kernelFunc: searchSorted as unknown as KernelFunc, -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Select.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Select.ts deleted file mode 100644 index 1dc8256cf..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Select.ts +++ /dev/null @@ -1,38 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, Select, SelectInputs, TensorInfo, upcastType} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {SelectProgram} from '../select_webgpu'; - -export function select(args: {inputs: SelectInputs, backend: WebGPUBackend}): - TensorInfo { - const {inputs, backend} = args; - const {condition, t, e} = inputs; - - const program = - new SelectProgram(condition.shape.length, t.shape, t.shape.length); - return backend.runWebGPUProgram( - program, [condition, t, e], upcastType(t.dtype, e.dtype)); -} - -export const selectConfig: KernelConfig = { - kernelName: Select, - backendName: 'webgpu', - kernelFunc: select as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Selu.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Selu.ts deleted file mode 100644 index 612778efb..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Selu.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, Selu} from '@tensorflow/tfjs-core'; - -import {unaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; - -import {UnaryOpType} from '../unary_op_util'; - -export const selu = unaryKernelFunc({opType: UnaryOpType.SELU}); - -export const seluConfig: KernelConfig = { - kernelName: Selu, - backendName: 'webgpu', - kernelFunc: selu -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Sigmoid.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Sigmoid.ts deleted file mode 100644 index 4d415a446..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Sigmoid.ts +++ /dev/null @@ -1,28 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, Sigmoid} from '@tensorflow/tfjs-core'; -import {unaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; -import {UnaryOpType} from '../unary_op_util'; - -export const sigmoid = unaryKernelFunc({opType: UnaryOpType.SIGMOID}); - -export const sigmoidConfig: KernelConfig = { - kernelName: Sigmoid, - backendName: 'webgpu', - kernelFunc: sigmoid, -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Sign.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Sign.ts deleted file mode 100644 index f1cd3dfe9..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Sign.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, Sign} from '@tensorflow/tfjs-core'; - -import {unaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; - -import {UnaryOpType} from '../unary_op_util'; - -export const sign = unaryKernelFunc({opType: UnaryOpType.SIGN}); - -export const signConfig: KernelConfig = { - kernelName: Sign, - backendName: 'webgpu', - kernelFunc: sign -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Sin.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Sin.ts deleted file mode 100644 index 008df3822..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Sin.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, Sin} from '@tensorflow/tfjs-core'; - -import {unaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; - -import {UnaryOpType} from '../unary_op_util'; - -export const sin = unaryKernelFunc({opType: UnaryOpType.SIN}); - -export const sinConfig: KernelConfig = { - kernelName: Sin, - backendName: 'webgpu', - kernelFunc: sin -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Sinh.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Sinh.ts deleted file mode 100644 index 068125a2e..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Sinh.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, Sinh} from '@tensorflow/tfjs-core'; - -import {unaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; - -import {UnaryOpType} from '../unary_op_util'; - -export const sinh = unaryKernelFunc({opType: UnaryOpType.SINH}); - -export const sinhConfig: KernelConfig = { - kernelName: Sinh, - backendName: 'webgpu', - kernelFunc: sinh -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Slice.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Slice.ts deleted file mode 100644 index d96826501..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Slice.ts +++ /dev/null @@ -1,55 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, Slice, slice_util, SliceAttrs, SliceInputs, TensorInfo, TypedArray, util} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {sliceImplCPU} from '../kernel_utils/shared'; -import {SliceProgram} from '../slice_webgpu'; - -export function slice( - args: {inputs: SliceInputs, backend: WebGPUBackend, attrs: SliceAttrs}): - TensorInfo { - const {inputs, backend, attrs} = args; - const {x} = inputs; - const {begin, size} = attrs; - - const [$begin, $size] = slice_util.parseSliceParams(x, begin, size); - slice_util.assertParamsValid(x, $begin, $size); - - if (backend.shouldExecuteOnCPU([x]) || x.dtype === 'string') { - const xTensorData = backend.tensorMap.get(x.dataId); - const outValues = sliceImplCPU( - xTensorData.values as TypedArray, $begin, $size, x.shape, x.dtype); - return backend.makeTensorInfo($size, x.dtype, outValues); - } - - if (util.sizeFromShape($size) === 0) { - return backend.makeTensorInfo($size, x.dtype, []); - } - - // TODO(xing.xu): Add shadow slice support. - const program = new SliceProgram($begin, $size); - const uniformData = [{type: 'int32', data: $begin}]; - return backend.runWebGPUProgram(program, [x], x.dtype, uniformData); -} - -export const sliceConfig: KernelConfig = { - kernelName: Slice, - backendName: 'webgpu', - kernelFunc: slice as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Softmax.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Softmax.ts deleted file mode 100644 index 5ebd5beb5..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Softmax.ts +++ /dev/null @@ -1,54 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, Softmax, SoftmaxAttrs, SoftmaxInputs, TensorInfo, util} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {SoftmaxProgram} from '../softmax_webgpu'; - -import {reshape} from './Reshape'; - -export function softmax( - args: {inputs: SoftmaxInputs, backend: WebGPUBackend, attrs: SoftmaxAttrs}): - TensorInfo { - const {inputs, backend, attrs} = args; - const {logits} = inputs; - const {dim} = attrs; - - const logitsReshaped = reshape({ - inputs: {x: logits}, - backend, - attrs: { - shape: [ - util.sizeFromShape(logits.shape) / logits.shape[dim], logits.shape[dim] - ] - } - }); - const program = new SoftmaxProgram(logitsReshaped.shape); - const res = backend.runWebGPUProgram(program, [logitsReshaped], logits.dtype); - const resReshaped = - reshape({inputs: {x: res}, backend, attrs: {shape: logits.shape}}); - backend.disposeData(logitsReshaped.dataId); - backend.disposeData(res.dataId); - return resReshaped; -} - -export const softmaxConfig: KernelConfig = { - kernelName: Softmax, - backendName: 'webgpu', - kernelFunc: softmax as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Softplus.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Softplus.ts deleted file mode 100644 index 6c8a74c2a..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Softplus.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, Softplus} from '@tensorflow/tfjs-core'; - -import {unaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; - -import {UnaryOpType} from '../unary_op_util'; - -export const softplus = unaryKernelFunc({opType: UnaryOpType.SOFTPLUS}); - -export const softplusConfig: KernelConfig = { - kernelName: Softplus, - backendName: 'webgpu', - kernelFunc: softplus -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/SpaceToBatchND.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/SpaceToBatchND.ts deleted file mode 100644 index c5d695afc..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/SpaceToBatchND.ts +++ /dev/null @@ -1,79 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, KernelConfig, KernelFunc, SpaceToBatchND, SpaceToBatchNDAttrs, SpaceToBatchNDInputs, TensorInfo, util} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {SpaceToBatchNDProgram} from '../space_to_batchND_webgpu'; - -import {reshape} from './Reshape'; - -export const spaceToBatchND = (args: { - inputs: SpaceToBatchNDInputs, - backend: WebGPUBackend, - attrs: SpaceToBatchNDAttrs -}): TensorInfo => { - const {inputs, backend, attrs} = args; - const {x} = inputs; - const {blockShape, paddings} = attrs; - - util.assert( - x.shape.length <= 4, - () => 'spaceToBatchND for rank > 4 with a WebGPU backend not ' + - 'implemented yet'); - - const prod = blockShape.reduce((a, b) => a * b); - - const completePaddings: Array<[number, number]> = [[0, 0]]; - completePaddings.push(...paddings as Array<[number, number]>); - for (let i = 1 + blockShape.length; i < x.shape.length; ++i) { - completePaddings.push([0, 0]); - } - - const paddedXShape = completePaddings.map( - (p, i) => p[0] /* beforePad */ + x.shape[i] + p[1] /* afterPad */); - const reshapedPaddedShape = - backend_util.getReshaped(paddedXShape, blockShape, prod, false); - - const permutedReshapedPaddedPermutation = backend_util.getPermuted( - reshapedPaddedShape.length, blockShape.length, false); - - const flattenShape = - backend_util.getReshapedPermuted(paddedXShape, blockShape, prod, false); - - const paddedXShapeStrides = util.computeStrides(paddedXShape); - const program = new SpaceToBatchNDProgram( - x.shape, paddedXShape, completePaddings, reshapedPaddedShape, - permutedReshapedPaddedPermutation, paddedXShapeStrides.length); - const uniformData = [ - {type: 'int32', data: reshapedPaddedShape}, - {type: 'int32', data: paddedXShapeStrides} - ]; - completePaddings.map( - p => uniformData.push({type: 'int32', data: [p[0], p[1]]})); - const paddedXT = backend.runWebGPUProgram(program, [x], x.dtype, uniformData); - const result = - reshape({inputs: {x: paddedXT}, backend, attrs: {shape: flattenShape}}); - backend.disposeData(paddedXT.dataId); - return result; -}; - -export const spaceToBatchNDConfig: KernelConfig = { - kernelName: SpaceToBatchND, - backendName: 'webgpu', - kernelFunc: spaceToBatchND as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/SparseSegmentMean.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/SparseSegmentMean.ts deleted file mode 100644 index 599595942..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/SparseSegmentMean.ts +++ /dev/null @@ -1,36 +0,0 @@ -/** - * @license - * Copyright 2023 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, SparseSegmentMean, SparseSegmentMeanInputs, TensorInfo} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {sparseSegmentReduce} from '../kernel_utils/sparse_segment_reduce'; - -export function sparseSegmentMean( - args: {inputs: SparseSegmentMeanInputs, backend: WebGPUBackend}): - TensorInfo { - const {inputs, backend} = args; - const {data, indices, segmentIds} = inputs; - - return sparseSegmentReduce(data, indices, segmentIds, false, backend); -} - -export const sparseSegmentMeanConfig: KernelConfig = { - kernelName: SparseSegmentMean, - backendName: 'webgpu', - kernelFunc: sparseSegmentMean as unknown as KernelFunc, -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/SparseSegmentSum.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/SparseSegmentSum.ts deleted file mode 100644 index 0d572efcc..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/SparseSegmentSum.ts +++ /dev/null @@ -1,36 +0,0 @@ -/** - * @license - * Copyright 2023 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, SparseSegmentSum, SparseSegmentSumInputs, TensorInfo} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {sparseSegmentReduce} from '../kernel_utils/sparse_segment_reduce'; - -export function sparseSegmentSum( - args: {inputs: SparseSegmentSumInputs, backend: WebGPUBackend}): - TensorInfo { - const {inputs, backend} = args; - const {data, indices, segmentIds} = inputs; - - return sparseSegmentReduce(data, indices, segmentIds, true, backend); -} - -export const sparseSegmentSumConfig: KernelConfig = { - kernelName: SparseSegmentSum, - backendName: 'webgpu', - kernelFunc: sparseSegmentSum as unknown as KernelFunc, -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/SparseToDense.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/SparseToDense.ts deleted file mode 100644 index e784f3975..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/SparseToDense.ts +++ /dev/null @@ -1,136 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, KernelConfig, KernelFunc, Rank, SparseToDense, SparseToDenseAttrs, SparseToDenseInputs, TensorInfo, util} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {scatterImplCPU} from '../kernel_utils/shared'; -import {ScatterProgram} from '../scatter_webgpu'; - -import {identity} from './Identity'; -import {reshape} from './Reshape'; -import {tile} from './Tile'; - -export function sparseToDense(args: { - inputs: SparseToDenseInputs, - backend: WebGPUBackend, - attrs: SparseToDenseAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {sparseIndices, sparseValues, defaultValue} = inputs; - const {outputShape} = attrs; - - const {sliceRank, numUpdates, sliceSize, strides, outputSize} = - backend_util.calculateShapes(sparseValues, sparseIndices, outputShape); - - const sumDupeIndices = false; - if (sparseValues.dtype === 'string') { - const indicesBuf = backend.bufferSync(sparseIndices); - const updatesBuf = backend.bufferSync(sparseValues); - const $defaultValue = util.decodeString( - backend.readSync(defaultValue.dataId)[0] as Uint8Array); - const outBuf = scatterImplCPU( - indicesBuf, updatesBuf, outputShape, outputSize, sliceSize, numUpdates, - sliceRank, strides, $defaultValue, sumDupeIndices); - return backend.makeTensorInfo(outputShape, outBuf.dtype, outBuf.values); - } - - const flattenShape = [outputSize / sliceSize, sliceSize]; - - const $sparseIndices = reshape({ - inputs: {x: sparseIndices}, - backend, - attrs: {shape: [numUpdates, sliceRank]} - }); - const $sparseValues = sparseValues.shape.length ? - reshape({ - inputs: {x: sparseValues}, - backend, - attrs: {shape: [numUpdates, sliceSize]} - }) : - identity({inputs: {x: sparseValues}, backend}); - - const type = $sparseValues.dtype; - const zero = - backend.makeTensorInfo([], type, util.makeZerosTypedArray(1, type)); - - // Fill output tensor with the default value. - const $defaultValue = reshape({ - inputs: {x: defaultValue}, - backend, - attrs: {shape: Array(flattenShape.length).fill(1)} - }); - const $denseValues = - tile({inputs: {x: $defaultValue}, backend, attrs: {reps: flattenShape}}); - - const size = util.sizeFromShape([numUpdates, sliceSize]); - const uniformData = [ - {type: 'int32', data: [sliceRank]}, - {type: 'int32', data: strides}, - {type: 'int32', data: [size]}, - ]; - - switch (numUpdates) { - case 0: - break; - case 1: - if (true) { - const program = new ScatterProgram( - [numUpdates, sliceSize], sliceRank, $sparseIndices.shape.length, - $sparseValues.shape.length, strides, flattenShape, type, - sumDupeIndices); - backend.runWebGPUProgram( - program, [$sparseValues, $sparseIndices], type, uniformData, - $denseValues); - } - break; - default: - if (true) { - // First replace the default value with 0 at indices. - const program = new ScatterProgram( - [numUpdates, sliceSize], sliceRank, $sparseIndices.shape.length, - zero.shape.length, strides, flattenShape, type, sumDupeIndices); - backend.runWebGPUProgram( - program, [zero, $sparseIndices], type, uniformData, $denseValues); - } - { - // Then replace 0 with the (sum of) sparse value(s) at indices. - const program = new ScatterProgram( - [numUpdates, sliceSize], sliceRank, $sparseIndices.shape.length, - $sparseValues.shape.length, strides, flattenShape, type); - backend.runWebGPUProgram( - program, [$sparseValues, $sparseIndices], type, uniformData, - $denseValues); - } - } - - const denseValues = reshape( - {inputs: {x: $denseValues}, backend, attrs: {shape: outputShape}}); - - backend.disposeData($sparseIndices.dataId); - backend.disposeData($sparseValues.dataId); - backend.disposeData($defaultValue.dataId); - backend.disposeData(zero.dataId); - backend.disposeData($denseValues.dataId); - return denseValues; -} - -export const sparseToDenseConfig: KernelConfig = { - kernelName: SparseToDense, - backendName: 'webgpu', - kernelFunc: sparseToDense as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/SplitV.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/SplitV.ts deleted file mode 100644 index 78f627f89..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/SplitV.ts +++ /dev/null @@ -1,51 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, KernelConfig, KernelFunc, SplitV, SplitVAttrs, SplitVInputs, TensorInfo, util} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {slice} from './Slice'; - -export function splitV( - args: {inputs: SplitVInputs, backend: WebGPUBackend, attrs: SplitVAttrs}): - TensorInfo[] { - const {inputs, backend, attrs} = args; - const {x} = inputs; - const {numOrSizeSplits, axis} = attrs; - - const $axis = util.parseAxisParam(axis, x.shape)[0]; - const splitSizes = backend_util.prepareSplitSize(x, numOrSizeSplits, $axis); - - const xRank = x.shape.length; - const begin = new Array(xRank).fill(0); - const size = x.shape.slice(); - - return splitSizes.map(s => { - const sliceSize = [...size]; - sliceSize[$axis] = s; - const sliceT = - slice({inputs: {x}, backend, attrs: {begin, size: sliceSize}}); - begin[$axis] += s; - return sliceT; - }); -} - -export const splitVConfig: KernelConfig = { - kernelName: SplitV, - backendName: 'webgpu', - kernelFunc: splitV as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Sqrt.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Sqrt.ts deleted file mode 100644 index 327b033c1..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Sqrt.ts +++ /dev/null @@ -1,28 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, Sqrt} from '@tensorflow/tfjs-core'; -import {unaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; -import {UnaryOpType} from '../unary_op_util'; - -export const sqrt = unaryKernelFunc({opType: UnaryOpType.SQRT}); - -export const sqrtConfig: KernelConfig = { - kernelName: Sqrt, - backendName: 'webgpu', - kernelFunc: sqrt -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Square.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Square.ts deleted file mode 100644 index 9251e75e4..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Square.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, Square, SquareInputs} from '@tensorflow/tfjs-core'; -import {WebGPUBackend} from '../backend_webgpu'; -import {UnaryOpProgram} from '../unary_op_webgpu'; -import {UnaryOpType} from '../unary_op_util'; - -export const squareConfig: KernelConfig = { - kernelName: Square, - backendName: 'webgpu', - kernelFunc: ({inputs, backend}) => { - const {x} = inputs as SquareInputs; - const webGPUBackend = backend as WebGPUBackend; - const program = new UnaryOpProgram(x.shape, UnaryOpType.SQUARE); - return webGPUBackend.runWebGPUProgram(program, [x], x.dtype); - } -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/SquaredDifference.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/SquaredDifference.ts deleted file mode 100644 index 54f31aef8..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/SquaredDifference.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, SquaredDifference} from '@tensorflow/tfjs-core'; - -import {BinaryOpType} from '../binary_op_util'; -import {binaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; - -export const squaredDifference = binaryKernelFunc({ - opType: BinaryOpType.SQUARED_DIFFERENCE, -}); - -export const squaredDifferenceConfig: KernelConfig = { - kernelName: SquaredDifference, - backendName: 'webgpu', - kernelFunc: squaredDifference -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Step.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Step.ts deleted file mode 100644 index a497b34e4..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Step.ts +++ /dev/null @@ -1,39 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, Step, StepAttrs, TensorInfo, UnaryInputs} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {UnaryOpType} from '../unary_op_util'; -import {UnaryOpProgram} from '../unary_op_webgpu'; - -export function step( - {inputs, attrs, backend}: - {inputs: UnaryInputs, attrs: StepAttrs, backend: WebGPUBackend}): - TensorInfo { - const {x} = inputs; - const program = - new UnaryOpProgram(x.shape, UnaryOpType.STEP, 'stepAlpha : f32,'); - const uniformData = [{type: 'float32', data: [attrs.alpha]}]; - return backend.runWebGPUProgram(program, [x], x.dtype, uniformData); -} - -export const stepConfig: KernelConfig = { - kernelName: Step, - backendName: 'webgpu', - kernelFunc: step as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/StridedSlice.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/StridedSlice.ts deleted file mode 100644 index 48dd4b349..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/StridedSlice.ts +++ /dev/null @@ -1,103 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {buffer, KernelConfig, KernelFunc, Rank, slice_util, StridedSlice, StridedSliceAttrs, StridedSliceInputs, TensorBuffer, TensorInfo, TypedArray, util} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {stridedSliceImplCPU} from '../kernel_utils/shared'; - -import {reshape} from './Reshape'; -import {slice} from './Slice'; -import {StridedSliceProgram} from '../strided_slice_webgpu'; - -export function stridedSlice(args: { - inputs: StridedSliceInputs, - backend: WebGPUBackend, - attrs: StridedSliceAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {x} = inputs; - const { - begin, - end, - strides, - beginMask, - endMask, - ellipsisMask, - newAxisMask, - shrinkAxisMask - } = attrs; - - const { - finalShapeSparse, - finalShape, - isIdentity, - sliceDim0, - isSimpleSlice, - begin: $begin, - end: $end, - strides: $strides - } = - slice_util.sliceInfo( - x.shape, begin, end, strides, beginMask, endMask, ellipsisMask, - newAxisMask, shrinkAxisMask); - - let result; - - if (isIdentity) { - // Optimization #1, slice is a no-op plus reshape - result = reshape({inputs: {x}, backend, attrs: {shape: finalShape}}); - } else if (sliceDim0 || isSimpleSlice) { - // Optimization #2, slice is memory contiguous (only occurs in dim 0) - util.assert( - x.shape.length >= 1, - () => `Input must have rank at least 1, got: ${x.shape.length}`); - - const size = slice_util.computeOutShape($begin, $end, $strides); - // To tolerate begin[0] > end[0] (a 0-output slice), we min(begin, end). - const sliced = slice({inputs: {x}, backend, attrs: {begin: $begin, size}}); - result = - reshape({inputs: {x: sliced}, backend, attrs: {shape: finalShape}}); - backend.disposeData(sliced.dataId); - } else { - const shouldExecuteOnCPU = backend.shouldExecuteOnCPU([x]); - if (shouldExecuteOnCPU) { - const values = backend.readSync(x.dataId) as TypedArray; - const xBuf = buffer(x.shape, x.dtype, values) as TensorBuffer; - const resultValues = - stridedSliceImplCPU(finalShapeSparse, xBuf, $strides, $begin); - result = backend.makeTensorInfo(finalShape, x.dtype, resultValues.values); - } else { - const program = new StridedSliceProgram(finalShapeSparse); - const uniformData = - [{type: 'int32', data: $begin}, {type: 'int32', data: $strides}]; - const resultValues = - backend.runWebGPUProgram(program, [x], x.dtype, uniformData); - result = reshape( - {inputs: {x: resultValues}, backend, attrs: {shape: finalShape}}); - backend.disposeData(resultValues.dataId); - } - } - - return result; -} - -export const stridedSliceConfig: KernelConfig = { - kernelName: StridedSlice, - backendName: 'webgpu', - kernelFunc: stridedSlice as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/StringNGrams.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/StringNGrams.ts deleted file mode 100644 index d784f2699..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/StringNGrams.ts +++ /dev/null @@ -1,54 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, StringNGrams, StringNGramsAttrs, StringNGramsInputs, TensorInfo} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {stringNGramsImplCPU} from '../kernel_utils/shared'; - -export function stringNGrams(args: { - inputs: StringNGramsInputs, - backend: WebGPUBackend, - attrs: StringNGramsAttrs -}): [TensorInfo, TensorInfo] { - const {inputs, backend, attrs} = args; - const { - separator, - nGramWidths, - leftPad, - rightPad, - padWidth, - preserveShortSequences - } = attrs; - const {data, dataSplits} = inputs; - const $data = backend.readSync(data.dataId) as Uint8Array[]; - const $dataSplits = backend.readSync(dataSplits.dataId) as Int32Array; - - const [nGrams, nGramsSplits] = stringNGramsImplCPU( - $data, $dataSplits, separator, nGramWidths, leftPad, rightPad, padWidth, - preserveShortSequences); - return [ - backend.makeTensorInfo([nGrams.length], 'string', nGrams), - backend.makeTensorInfo(dataSplits.shape, 'int32', nGramsSplits), - ]; -} - -export const stringNGramsConfig: KernelConfig = { - kernelName: StringNGrams, - backendName: 'webgpu', - kernelFunc: stringNGrams as unknown as KernelFunc, -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Sub.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Sub.ts deleted file mode 100644 index eedf4f4be..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Sub.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, Sub} from '@tensorflow/tfjs-core'; - -import {BinaryOpType} from '../binary_op_util'; -import {binaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; -import {subImplCPU as cpuSub} from '../kernel_utils/shared'; - -export const sub = binaryKernelFunc( - {opType: BinaryOpType.SUB, cpuKernelImpl: cpuSub, supportsComplex: true}); - -export const subConfig: KernelConfig = { - kernelName: Sub, - backendName: 'webgpu', - kernelFunc: sub -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Sum.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Sum.ts deleted file mode 100644 index 9ac537dc3..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Sum.ts +++ /dev/null @@ -1,37 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, Sum, SumAttrs, SumInputs, TensorInfo} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {reduce} from '../kernel_utils/reduce'; - -export function sum( - args: {inputs: SumInputs, backend: WebGPUBackend, attrs: SumAttrs}): - TensorInfo { - const {inputs, backend, attrs} = args; - const {x} = inputs; - const {axis, keepDims} = attrs; - - return reduce(x, axis, keepDims, 'sum', backend); -} - -export const sumConfig: KernelConfig = { - kernelName: Sum, - backendName: 'webgpu', - kernelFunc: sum as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Tan.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Tan.ts deleted file mode 100644 index 54ad016e3..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Tan.ts +++ /dev/null @@ -1,29 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, Tan} from '@tensorflow/tfjs-core'; - -import {unaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; -import {UnaryOpType} from '../unary_op_util'; - -export const tan = unaryKernelFunc({opType: UnaryOpType.TAN}); - -export const tanConfig: KernelConfig = { - kernelName: Tan, - backendName: 'webgpu', - kernelFunc: tan -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Tanh.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Tanh.ts deleted file mode 100644 index 19555c8ec..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Tanh.ts +++ /dev/null @@ -1,28 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, Tanh} from '@tensorflow/tfjs-core'; -import {unaryKernelFunc} from '../kernel_utils/kernel_funcs_utils'; -import {UnaryOpType} from '../unary_op_util'; - -export const tanh = unaryKernelFunc({opType: UnaryOpType.TANH}); - -export const tanhConfig: KernelConfig = { - kernelName: Tanh, - backendName: 'webgpu', - kernelFunc: tanh -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/TensorScatterUpdate.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/TensorScatterUpdate.ts deleted file mode 100644 index 9043f5013..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/TensorScatterUpdate.ts +++ /dev/null @@ -1,86 +0,0 @@ -/** - * @license - * Copyright 2023 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, KernelConfig, KernelFunc, TensorInfo, TensorScatterUpdate, TensorScatterUpdateAttrs, TensorScatterUpdateInputs, util} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {ScatterProgram} from '../scatter_webgpu'; - -import {reshape} from './Reshape'; -import {tile} from './Tile'; - -export function tensorScatterUpdate(args: { - inputs: TensorScatterUpdateInputs, - backend: WebGPUBackend, - attrs: TensorScatterUpdateAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {tensor, indices, updates} = inputs; - const {} = attrs; - - const {sliceRank, numUpdates, sliceSize, strides, outputSize} = - backend_util.calculateShapes(updates, indices, tensor.shape); - - const flattenShape = [outputSize / sliceSize, sliceSize]; - - if (outputSize === 0) { - return backend.makeTensorInfo(tensor.shape, indices.dtype); - } - - const toDispose = []; - - const flattenIndices = reshape( - {inputs: {x: indices}, backend, attrs: {shape: [numUpdates, sliceRank]}}); - toDispose.push(flattenIndices); - const flattenX = reshape( - {inputs: {x: updates}, backend, attrs: {shape: [numUpdates, sliceSize]}}); - toDispose.push(flattenX); - const flattenTensor = - reshape({inputs: {x: tensor}, backend, attrs: {shape: flattenShape}}); - toDispose.push(flattenTensor); - const output = tile({ - inputs: {x: flattenTensor}, - backend, - attrs: {reps: Array(flattenShape.length).fill(1)} - }); - const program = new ScatterProgram( - [numUpdates, sliceSize], sliceRank, flattenIndices.shape.length, - flattenX.shape.length, strides, flattenShape, tensor.dtype, false); - const size = util.sizeFromShape([numUpdates, sliceSize]); - const uniformData = [ - {type: 'int32', data: [sliceRank]}, - {type: 'int32', data: strides}, - {type: 'int32', data: [size]}, - ]; - const res = backend.runWebGPUProgram( - program, [flattenX, flattenIndices], flattenTensor.dtype, uniformData, - output); - toDispose.push(res); - - const reshaped = - reshape({inputs: {x: res}, backend, attrs: {shape: tensor.shape}}); - - toDispose.forEach(t => backend.disposeData(t.dataId)); - - return reshaped; -} - -export const tensorScatterUpdateConfig: KernelConfig = { - kernelName: TensorScatterUpdate, - backendName: 'webgpu', - kernelFunc: tensorScatterUpdate as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Tile.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Tile.ts deleted file mode 100644 index 0ea3ff488..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Tile.ts +++ /dev/null @@ -1,55 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {buffer, KernelConfig, KernelFunc, TensorInfo, Tile, TileAttrs, TileInputs, TypedArray, util} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {tileImplCPU} from '../kernel_utils/shared'; -import {TileProgram} from '../tile_webgpu'; - -export function tile( - params: {inputs: TileInputs, backend: WebGPUBackend, attrs: TileAttrs}): - TensorInfo { - const {inputs, backend, attrs} = params; - const {x} = inputs; - const {reps} = attrs; - - // tile gpu program cannot handle rank >= 5 case. - if (backend.shouldExecuteOnCPU([x]) || x.dtype === 'string' || - x.shape.length >= 5) { - // Even thought string tensor is always on CPU, just to be consistent on how - // to access tensor data. - const data = backend.readSync(x.dataId); - const value = x.dtype === 'string' ? - (data as Uint8Array[]).map(d => util.decodeString(d)) : - data as TypedArray; - const buf = buffer(x.shape, x.dtype, value); - const outBuf = tileImplCPU(buf, reps); - return backend.makeTensorInfo(outBuf.shape, outBuf.dtype, outBuf.values); - } - - const program = new TileProgram(x.shape, reps); - const output = backend.runWebGPUProgram(program, [x], x.dtype); - - return output; -} - -export const tileConfig: KernelConfig = { - kernelName: Tile, - backendName: 'webgpu', - kernelFunc: tile as unknown as KernelFunc, -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/TopK.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/TopK.ts deleted file mode 100644 index 7a6085732..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/TopK.ts +++ /dev/null @@ -1,180 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, NumericDataType, TensorInfo, TopK, TopKAttrs, TopKInputs, TypedArray, util} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {topKImplCPU} from '../kernel_utils/shared'; -import {MergeProgram, SwapProgram} from '../top_k_webgpu'; -import {fill} from './Fill'; -import {gatherV2} from './GatherV2'; -import {reshape} from './Reshape'; -import {slice} from './Slice'; - -function disposeIntermediateTensorInfoOrNull( - backend: WebGPUBackend, tensorInfo: TensorInfo) { - if (tensorInfo !== null) { - backend.disposeData(tensorInfo.dataId); - } -} - -function roundUpToPow2(num: number) { - let pow2 = 1; - while (pow2 < num) { - pow2 *= 2; - } - return pow2; -} - -// Based on Algorithm 2 of Bitonic Top K, ref: -// https://anilshanbhag.in/static/papers/gputopk_sigmod18.pdf -export function topK( - args: {inputs: TopKInputs, backend: WebGPUBackend, attrs: TopKAttrs}): - TensorInfo[] { - const {inputs, backend, attrs} = args; - const {x} = inputs; - const {k, sorted}= attrs; - - const xShape = x.shape; - const lastDim = xShape[xShape.length - 1]; - - if (backend.shouldExecuteOnCPU([x])) { - const xVals = backend.readSync(x.dataId) as TypedArray; - const [allTopKVals, allTopKIndices] = - topKImplCPU(xVals, xShape, x.dtype as NumericDataType, k, sorted); - - return [ - backend.makeTensorInfo( - allTopKVals.shape, allTopKVals.dtype, allTopKVals.values), - backend.makeTensorInfo( - allTopKIndices.shape, allTopKIndices.dtype, allTopKIndices.values) - ]; - } - - if (k === 0) { - xShape[xShape.length - 1] = 0; - return [ - backend.makeTensorInfo(xShape, x.dtype, []), - backend.makeTensorInfo(xShape, 'int32', []) - ]; - } - - if (lastDim === 1 /* firstPass */) { - return [ - x, fill({attrs: {shape: xShape, dtype: 'int32', value: 0}, backend}) - ]; - } - - // Reshape into a 2d tensor [batch, lastDim] and compute topk along lastDim. - const xSize = util.sizeFromShape(xShape); - const batch = xSize / lastDim; - const x2D = reshape({inputs: {x}, attrs: {shape: [batch, lastDim]}, backend}); - - const kPow2 = roundUpToPow2(k); - const lastDimPow2 = roundUpToPow2(lastDim); - - // Only the indices containing the top K are kept at every step to reduce - // number of outputs in the GPU algorithms, so once the final set of indices - // is computed then gather is used to grab the corresponding values - // from the original input. - let indices: TensorInfo = null; - - // GPU algorithm always takes in an indices input but this input is not used - // on the first run of a GPU algorithm, therefore if indices is null we simply - // pass in x2D instead of it but the value will not actually be used - const getInputs = () => indices === null ? [x2D, x2D] : [x2D, indices]; - - const runSwap = (dir: number, inc: number, shape: number[]) => { - const inputs = getInputs(); - const program = new SwapProgram(shape); - const firstPass = indices === null ? 1 : 0; - const uniformDataSwap = [ - {type: 'int32', data: [lastDim]}, - {type: 'int32', data: [firstPass]}, - {type: 'float32', data: [Number.NEGATIVE_INFINITY]}, - {type: 'int32', data: [dir]}, - {type: 'int32', data: [inc]} - ]; - const prevIndices = indices; - indices = backend.runWebGPUProgram( - program, inputs, 'int32', uniformDataSwap); - disposeIntermediateTensorInfoOrNull(backend, prevIndices); - }; - - // Step 1: local sort - for (let len = 1; len < kPow2; len *= 2) { - const dir = len * 2; - for (let inc = len; inc >= 1; inc /= 2) { - runSwap(dir, inc, [batch, lastDimPow2]); - } - } - - // Step 2: merge - for (let indicesSize = lastDimPow2; indicesSize > kPow2; indicesSize /= 2) { - const inputs = getInputs(); - const mergeProgram = new MergeProgram([batch, indicesSize / 2]); - const firstPass = indices === null ? 1 : 0; - const uniformDataMerge = [ - {type: 'int32', data: [lastDim]}, - {type: 'int32', data: [firstPass]}, - {type: 'int32', data: [kPow2]} - ]; - const prevIndices = indices; - indices = backend.runWebGPUProgram( - mergeProgram, inputs, 'int32', uniformDataMerge); - disposeIntermediateTensorInfoOrNull(backend, prevIndices); - - // Step 3: rebuild - const len = kPow2 / 2; - const dir = len * 2; - for (let inc = len; inc >= 1; inc /= 2) { - runSwap(dir, inc, indices.shape); - } - } - - // Keep only the requested top K results instead of kPow2 - let prevIndices = indices; - indices = slice( - {inputs: {x: indices}, backend, attrs: {begin: 0, size: [batch, k]}}); - disposeIntermediateTensorInfoOrNull(backend, prevIndices); - - // Gather values on last dimension - let values = gatherV2( - {inputs: {x: x2D, indices}, backend, attrs: {axis: 1, batchDims: 1}}); - disposeIntermediateTensorInfoOrNull(backend, x2D); - - // Reshape back to the original input shape, except that the last - // dimension is k. - const newShape = xShape.slice(0, -1); - newShape.push(k); - - prevIndices = indices; - indices = reshape({inputs: {x: indices}, attrs: {shape: newShape}, backend}); - disposeIntermediateTensorInfoOrNull(backend, prevIndices); - - const prevValues = values; - values = reshape({inputs: {x: values}, attrs: {shape: newShape}, backend}); - disposeIntermediateTensorInfoOrNull(backend, prevValues); - - return [values, indices]; -} - -export const topKConfig: KernelConfig = { - kernelName: TopK, - backendName: 'webgpu', - kernelFunc: topK as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Transform.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Transform.ts deleted file mode 100644 index b3d6fd160..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Transform.ts +++ /dev/null @@ -1,71 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, TensorInfo, Transform, TransformAttrs, TransformInputs} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {TransformProgram} from '../transform_webgpu'; - -export function transform(args: { - inputs: TransformInputs, - backend: WebGPUBackend, - attrs: TransformAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {image, transforms} = inputs; - const {interpolation, fillMode, fillValue, outputShape} = attrs; - - const [batch, imageHeight, imageWidth, numChannels] = image.shape; - const [outHeight, outWidth] = - outputShape != null ? outputShape : [imageHeight, imageWidth]; - const outShape = - [batch, outHeight, outWidth, - numChannels] as [number, number, number, number]; - - const program = new TransformProgram(outShape); - const interpolationModeId = interpolation === 'nearest' ? 1 : 2; - let fillModeId: number; - switch (fillMode) { - case 'constant': - fillModeId = 1; - break; - case 'reflect': - fillModeId = 2; - break; - case 'wrap': - fillModeId = 3; - break; - case 'nearest': - fillModeId = 4; - break; - default: - fillModeId = 1; - break; - } - const uniformData = [ - {type: 'int32', data: [interpolationModeId]}, - {type: 'int32', data: [fillModeId]}, {type: 'float32', data: [fillValue]} - ]; - return backend.runWebGPUProgram( - program, [image, transforms], 'float32', uniformData); -} - -export const transformConfig: KernelConfig = { - kernelName: Transform, - backendName: 'webgpu', - kernelFunc: transform as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Transpose.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Transpose.ts deleted file mode 100644 index 2f3a6ead3..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Transpose.ts +++ /dev/null @@ -1,59 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, Transpose, TransposeAttrs, TransposeInputs, TypedArray, util} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {transposeImplCPU as cpuTranspose} from '../kernel_utils/shared'; - -import {TransposeSharedProgram} from '../transpose_shared_webgpu'; -import {TransposeProgram} from '../transpose_webgpu'; - -export function transpose(args: { - inputs: TransposeInputs, - attrs: TransposeAttrs, - backend: WebGPUBackend -}) { - const {inputs, backend, attrs} = args; - const {x} = inputs; - const {perm} = attrs; - const webgpuBackend = backend; - - const xRank = x.shape.length; - const newShape: number[] = new Array(xRank); - for (let i = 0; i < newShape.length; i++) { - newShape[i] = x.shape[perm[i]]; - } - if (backend.shouldExecuteOnCPU([x])) { - const xData = webgpuBackend.tensorMap.get(x.dataId); - const values = xData.values as TypedArray; - const outValues = cpuTranspose(values, x.shape, x.dtype, perm, newShape); - return backend.makeTensorInfo(newShape, x.dtype, outValues); - } - if (x.shape.length === 2 && util.arraysEqual(perm, [1, 0])) { - const program = new TransposeSharedProgram(x.shape, perm); - return webgpuBackend.runWebGPUProgram(program, [x], x.dtype); - } - const program = new TransposeProgram(x.shape, perm); - return webgpuBackend.runWebGPUProgram(program, [x], x.dtype); -} - -export const transposeConfig: KernelConfig = { - kernelName: Transpose, - backendName: 'webgpu', - kernelFunc: transpose as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/Unpack.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/Unpack.ts deleted file mode 100644 index e77026967..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/Unpack.ts +++ /dev/null @@ -1,73 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, TensorInfo, Unpack, UnpackAttrs, UnpackInputs} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; - -import {reshape} from './Reshape'; -import {slice} from './Slice'; - -export function unpack( - args: - {inputs: UnpackInputs, backend: WebGPUBackend, attrs: UnpackAttrs}): - TensorInfo[] { - const {inputs, backend, attrs} = args; - const {value} = inputs; - let {axis} = attrs; - - if (axis < 0) { - axis += value.shape.length; - } - - const x = value; - const xRank = x.shape.length; - - const num = value.shape[axis]; - const outShape: number[] = new Array(xRank - 1); - let outIndex = 0; - for (let i = 0; i < xRank; i++) { - if (i !== axis) { - outShape[outIndex++] = x.shape[i]; - } - } - - const toDispose = []; - - const begin = new Array(xRank).fill(0); - const size = x.shape.slice(); - size[axis] = 1; - const res: TensorInfo[] = new Array(num); - for (let i = 0; i < res.length; i++) { - begin[axis] = i; - const sliced = slice({inputs: {x}, backend, attrs: {begin, size}}); - const reshaped = - reshape({inputs: {x: sliced}, backend, attrs: {shape: outShape}}); - res[i] = reshaped; - - toDispose.push(sliced); - } - - toDispose.forEach(t => backend.disposeData(t.dataId)); - return res; -} - -export const unpackConfig: KernelConfig = { - kernelName: Unpack, - backendName: 'webgpu', - kernelFunc: unpack as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/UnsortedSegmentSum.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/UnsortedSegmentSum.ts deleted file mode 100644 index 670a5382e..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/UnsortedSegmentSum.ts +++ /dev/null @@ -1,85 +0,0 @@ -/** - * @license - * Copyright 2023 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, KernelConfig, KernelFunc, TensorInfo, UnsortedSegmentSum, UnsortedSegmentSumAttrs, UnsortedSegmentSumInputs, util} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {UnsortedSegmentSumProgram} from '../unsorted_segment_sum_webgpu'; - -import {fill} from './Fill'; -import {reshape} from './Reshape'; -import {transpose} from './Transpose'; - -export function unsortedSegmentSum(args: { - inputs: UnsortedSegmentSumInputs, - backend: WebGPUBackend, - attrs: UnsortedSegmentSumAttrs -}): TensorInfo { - const {inputs, backend, attrs} = args; - const {x, segmentIds} = inputs; - const {numSegments} = attrs; - - const xRank = x.shape.length; - - const toDispose = []; - - let axis = 0; - const permutation = backend_util.getAxesPermutation([axis], xRank); - let permutedX = x; - if (permutation != null) { - permutedX = transpose({inputs: {x}, backend, attrs: {perm: permutation}}); - toDispose.push(permutedX); - axis = backend_util.getInnerMostAxes(1, xRank)[0]; - } - - const outShape = backend_util.segment_util.computeOutShape( - permutedX.shape, axis, numSegments); - const inSize = util.sizeFromShape([permutedX.shape[axis]]); - const a2D = - reshape({inputs: {x: permutedX}, backend, attrs: {shape: [-1, inSize]}}); - toDispose.push(a2D); - - const dtype = x.dtype; - const shape = [a2D.shape[0], numSegments]; - const output = fill({backend, attrs: {shape, value: 0, dtype}}); - const program = new UnsortedSegmentSumProgram(a2D.shape, shape, dtype); - const uniformData = [ - {type: 'int32', data: [numSegments]}, - {type: 'int32', data: [util.sizeFromShape(a2D.shape)]} - ]; - const segResult = backend.runWebGPUProgram( - program, [a2D, segmentIds], dtype, uniformData, output); - - const reshaped = - reshape({inputs: {x: segResult}, backend, attrs: {shape: outShape}}); - toDispose.push(segResult); - let result = reshaped; - if (permutation != null) { - toDispose.push(reshaped); - const perm = backend_util.getUndoAxesPermutation(permutation); - result = transpose({inputs: {x: result}, backend, attrs: {perm}}); - } - - toDispose.forEach(t => backend.disposeData(t.dataId)); - return result; -} - -export const unsortedSegmentSumConfig: KernelConfig = { - kernelName: UnsortedSegmentSum, - backendName: 'webgpu', - kernelFunc: unsortedSegmentSum as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/ZerosLike.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/ZerosLike.ts deleted file mode 100644 index ad64794b1..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/ZerosLike.ts +++ /dev/null @@ -1,61 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelConfig, KernelFunc, TensorInfo, ZerosLike, ZerosLikeInputs} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; - -import {complex} from './Complex'; -import {fill} from './Fill'; -import {imag} from './Imag'; -import {real} from './Real'; - -export function zerosLike( - args: {inputs: ZerosLikeInputs, backend: WebGPUBackend}): TensorInfo { - const {inputs, backend} = args; - const {x} = inputs; - if (x.dtype === 'complex64') { - const realPart = real({inputs: {input: x}, backend}); - const r = zerosLike({inputs: {x: realPart}, backend}); - const imagPart = imag({inputs: {input: x}, backend}); - const i = zerosLike({inputs: {x: imagPart}, backend}); - - const result = complex({inputs: {real: r, imag: i}, backend}); - - backend.disposeData(realPart.dataId); - backend.disposeData(r.dataId); - backend.disposeData(imagPart.dataId); - backend.disposeData(i.dataId); - - return result; - } else { - return fill({ - attrs: { - shape: x.shape, - dtype: x.dtype, - value: x.dtype === 'string' ? '' : 0 - }, - backend - }); - } -} - -export const zerosLikeConfig: KernelConfig = { - kernelName: ZerosLike, - backendName: 'webgpu', - kernelFunc: zerosLike as unknown as KernelFunc -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/_FusedMatMul.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/_FusedMatMul.ts deleted file mode 100644 index d377480b1..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/_FusedMatMul.ts +++ /dev/null @@ -1,49 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {_FusedMatMul, _FusedMatMulAttrs, _FusedMatMulInputs, KernelConfig, KernelFunc} from '@tensorflow/tfjs-core'; - -import {WebGPUBackend} from '../backend_webgpu'; -import {batchMatMulImpl} from './BatchMatMul_impl'; - -export function _fusedMatMul(args: { - inputs: _FusedMatMulInputs, - attrs: _FusedMatMulAttrs, - backend: WebGPUBackend -}) { - const {inputs, backend, attrs} = args; - const {a, b, bias, preluActivationWeights} = inputs; - const {transposeA, transposeB, activation, leakyreluAlpha} = attrs; - - return batchMatMulImpl({ - a, - b, - transposeA, - transposeB, - backend, - bias, - preluActivationWeights, - leakyreluAlpha, - activation - }); -} - -export const _fusedMatMulConfig: KernelConfig = { - kernelName: _FusedMatMul, - backendName: 'webgpu', - kernelFunc: _fusedMatMul as unknown as KernelFunc, -}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/conv2d_webgpu_test.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/conv2d_webgpu_test.ts deleted file mode 100644 index 0eb818715..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/conv2d_webgpu_test.ts +++ /dev/null @@ -1,861 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '@tensorflow/tfjs-core'; -import {test_util} from '@tensorflow/tfjs-core'; -import {describeWebGPU} from '../test_util'; - -function generateCaseInputs(totalSizeTensor: number, totalSizeFilter: number) { - const inp = new Array(totalSizeTensor); - const filt = new Array(totalSizeFilter); - - for (let i = 0; i < totalSizeTensor; i++) { - inp[i] = i + 1; - } - for (let i = 0; i < totalSizeFilter; i++) { - filt[i] = i + 1; - } - - return {input: inp, filter: filt}; -} - -describeWebGPU('im2col as separate shader', () => { - let flag: boolean; - beforeAll(() => { - flag = tf.env().getBool('WEBGPU_CONV_SEPARATE_IM2COL_SHADER'); - tf.env().set('WEBGPU_CONV_SEPARATE_IM2COL_SHADER', true); - }); - - afterAll(() => { - tf.env().set('WEBGPU_CONV_SEPARATE_IM2COL_SHADER', flag); - }); - - it('x=[4,4,1] f=[2,2,1,1] s=1 d=2 p=0', async () => { - const inputDepth = 1; - const inputShape: [number, number, number] = [4, 4, inputDepth]; - const outputDepth = 1; - const fSize = 2; - const fSizeDilated = 3; - const pad = 0; - const stride = 1; - const dataFormat = 'NHWC'; - const dilation = 2; - const noDilation = 1; - - const x = tf.tensor3d( - [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], inputShape); - const w = - tf.tensor4d([3, 1, 5, 2], [fSize, fSize, inputDepth, outputDepth]); - // adding a dilation rate is equivalent to using a filter - // with 0s for the dilation rate - const wDilated = tf.tensor4d( - [3, 0, 1, 0, 0, 0, 5, 0, 2], - [fSizeDilated, fSizeDilated, inputDepth, outputDepth]); - - const result = tf.conv2d(x, w, stride, pad, dataFormat, dilation); - const expectedResult = - tf.conv2d(x, wDilated, stride, pad, dataFormat, noDilation); - - expect(result.shape).toEqual(expectedResult.shape); - test_util.expectArraysClose( - await result.data(), await expectedResult.data()); - expect(result.shape).toEqual(expectedResult.shape); - expect(result.dtype).toBe(expectedResult.dtype); - }); - - it('x=[1,4,4,1] f=[1,1,1,3] s=2 d=1 p=same', async () => { - const inputDepth = 1; - const inputShape: [number, number, number] = [4, 4, inputDepth]; - const outputDepth = 3; - const fSize = 1; - const pad = 'same'; - const stride: [number, number] = [2, 2]; - - const x = tf.tensor3d( - [ - 10, 30, 50, 70, 20, 40, 60, 80, -10, -30, -50, -70, -20, -40, -60, -80 - ], - inputShape); - const w = tf.tensor4d([1, 0.5, 1], [fSize, fSize, inputDepth, outputDepth]); - - const result = tf.conv2d(x, w, stride, pad); - test_util.expectArraysClose( - await result.data(), - [10, 5, 10, 50, 25, 50, -10, -5, -10, -50, -25, -50]); - }); - - it('x=[2,2,1] f=[1,1,1,2] s=1 d=1 p=0', async () => { - const inputDepth = 1; - const inputShape: [number, number, number] = [2, 2, inputDepth]; - const outputDepth = 1; - const fSize = 1; - const pad = 0; - const stride = 1; - - const x = tf.tensor3d([1, 2, 3, 4], inputShape); - const w = tf.tensor4d([2], [fSize, fSize, inputDepth, outputDepth]); - - const result = tf.conv2d(x, w, stride, pad); - test_util.expectArraysClose(await result.data(), [2, 4, 6, 8]); - }); - - it('x=[3,3,2] f=[2,2,2,1] s=1 d=1 p=valid', async () => { - const pad = 'valid'; - const stride = 1; - - const x = tf.tensor3d( - [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 60, 70, 80, 90], - [3, 3, 2]); - const w = tf.tensor4d([.1, .2, .3, .4, .5, .6, .7, .8], [2, 2, 2, 1]); - const result = tf.conv2d(x, w, stride, pad); - - const resultData = await result.data(); - expect(result.shape).toEqual([2, 2, 1]); - test_util.expectArraysClose( - resultData, new Float32Array([25.6, 53.5, 157.0, 220.9])); - }); - - it('x=[4,2,1] f=[4,2,1,1] s=1 d=1 p=same', async () => { - const inputDepth = 1; - const outputDepth = 1; - const pad = 'same'; - const stride = 1; - const dataFormat = 'NHWC'; - const dilation = 1; - - const x = tf.tensor3d([1, 2, 3, 4, 5, 6, 7, 8], [4, 2, inputDepth]); - const w = - tf.tensor4d([3, 1, 5, 0, 2, 7, 8, 9], [4, 2, inputDepth, outputDepth]); - - const result = tf.conv2d(x, w, stride, pad, dataFormat, dilation); - const resultData = await result.data(); - expect(result.shape).toEqual([4, 2, 1]); - test_util.expectArraysClose( - resultData, [133, 66, 200, 102, 108, 58, 56, 58]); - }); - - it('x=[2,2,1] f=[2,2,1,1] s=1 d=1 p=same', async () => { - const inputDepth = 1; - const inputShape: [number, number, number] = [2, 2, inputDepth]; - const outputDepth = 1; - const fSize = 2; - const pad = 'same'; - const stride = 1; - const dataFormat = 'NHWC'; - const dilation = 1; - - const x = tf.tensor3d([1, 2, 3, 4], inputShape); - const w = - tf.tensor4d([3, 1, 5, 0], [fSize, fSize, inputDepth, outputDepth]); - - const result = tf.conv2d(x, w, stride, pad, dataFormat, dilation); - - const resultData = await result.data(); - expect(result.shape).toEqual([2, 2, 1]); - test_util.expectArraysClose(resultData, new Float32Array([20, 26, 13, 12])); - }); - - it('x=[2,2,1] f=[2,2,1,1] s=1 d=1 p=0', async () => { - const inputDepth = 1; - const inputShape: [number, number, number] = [2, 2, inputDepth]; - const outputDepth = 1; - const fSize = 2; - const pad = 0; - const stride = 1; - const dataFormat = 'NHWC'; - const dilation = 1; - - const x = tf.tensor3d([1, 2, 3, 4], inputShape); - const w = - tf.tensor4d([3, 1, 5, 0], [fSize, fSize, inputDepth, outputDepth]); - - const result = tf.conv2d(x, w, stride, pad, dataFormat, dilation); - test_util.expectArraysClose(await result.data(), [20]); - }); - - it('x=[1,3,6,1] f=[2,2,1,1] s=[1,2] d=1 p=valid', async () => { - const inputDepth = 1; - const inputShape: [number, number, number, number] = [1, 3, 6, inputDepth]; - const outputDepth = 1; - const fSize = 2; - const pad = 'valid'; - const stride: [number, number] = [1, 2]; - - const inputs = generateCaseInputs(1 * 3 * 6 * inputDepth, fSize * fSize); - const x = tf.tensor4d(inputs.input, inputShape); - const w = - tf.tensor4d(inputs.filter, [fSize, fSize, inputDepth, outputDepth]); - - const result = tf.conv2d(x, w, stride, pad); - test_util.expectArraysClose( - await result.data(), [58.0, 78.0, 98.0, 118.0, 138.0, 158.0]); - }); -}); - -describeWebGPU('conv2d vec4', () => { - it('conv2d vec4 follows a conv2d vec4 with inChannels=3', async () => { - const pad = 'valid'; - const stride = 1; - - const inputData = []; - for (let i = 0; i < 4 * 4 * 3; i++) { - inputData.push(i % 5); - } - const wData1 = []; - for (let i = 0; i < 2 * 2 * 3 * 4; i++) { - wData1.push(i % 5); - } - const wData2 = []; - for (let i = 0; i < 2 * 2 * 4 * 4; i++) { - wData2.push(i % 5); - } - - const x = tf.tensor3d(inputData, [4, 4, 3]); - const w = tf.tensor4d(wData1, [2, 2, 3, 4]); - const result = tf.conv2d(x, w, stride, pad); - const resultData = await result.data(); - expect(result.shape).toEqual([3, 3, 4]); - test_util.expectArraysClose( - resultData, new Float32Array([ - 53, 50, 47, 34, 30, 33, 51, 59, 62, 46, 35, 39, - 61, 32, 38, 59, 53, 50, 47, 34, 30, 33, 51, 59, - 34, 49, 59, 59, 61, 32, 38, 59, 53, 50, 47, 34 - ])); - - const w2 = tf.tensor4d(wData2, [2, 2, 4, 4]); - const result2 = tf.conv2d(result, w2, stride, pad); - expect(result2.shape).toEqual([2, 2, 4]); - const result2Data = await result2.data(); - test_util.expectArraysClose( - result2Data, new Float32Array([ - 1516, 1447, 1383, 1389, 1221, 1423, 1535, 1522, 1341, 1416, 1516, - 1656, 1516, 1447, 1383, 1389 - ])); - }); - - it('x=[1,9,9,3] f=[3,3,3,4] s=[2,2] d=1 p=same', async () => { - const inputDepth = 3; - const xSize = 9; - const inputShape: [number, number, number, number] = - [1, xSize, xSize, inputDepth]; - const outputDepth = 4; - const fSize = 3; - const pad = 'same'; - const stride: [number, number] = [2, 2]; - - const inputData = []; - for (let i = 0; i < xSize * xSize * inputDepth; i++) { - inputData.push(i % 5); - } - - const wData = []; - for (let i = 0; i < fSize * fSize * inputDepth * outputDepth; i++) { - wData.push(i % 5); - } - - const x = tf.tensor4d(inputData, inputShape); - const w = tf.tensor4d(wData, [fSize, fSize, inputDepth, outputDepth]); - - const result = tf.conv2d(x, w, stride, pad); - expect(result.shape).toEqual([1, 5, 5, 4]); - const resData = await result.data(); - test_util.expectArraysClose( - resData, new Float32Array([ - 53, 35, 42, 39, 54, 58, 62, 86, 74, 61, 78, 90, 59, - 74, 74, 69, 52, 56, 50, 44, 75, 87, 69, 71, 115, 97, - 114, 91, 104, 108, 102, 106, 123, 99, 95, 126, 59, 64, 79, - 69, 66, 70, 69, 63, 101, 116, 111, 116, 115, 97, 114, 91, - 104, 108, 102, 106, 71, 68, 75, 87, 87, 63, 59, 75, 97, - 90, 108, 111, 101, 116, 111, 116, 115, 97, 114, 91, 63, 72, - 66, 70, 46, 61, 61, 36, 83, 79, 55, 76, 80, 54, 58, - 62, 67, 74, 61, 78, 42, 39, 51, 53 - ])); - }); - - it('bool cast float32 + conv2d', async () => { - const im2colFlag = tf.env().getBool('WEBGPU_CONV_SEPARATE_IM2COL_SHADER'); - const thresholdFlag = - tf.env().getBool('WEBGPU_THRESHOLD_TO_INCREASE_WORKGROUPS_FOR_MATMUL'); - tf.env().set('WEBGPU_CONV_SEPARATE_IM2COL_SHADER', false); - // Setting the threshold to 0 is like skipping the corresponding - // optimization. - tf.env().set('WEBGPU_THRESHOLD_TO_INCREASE_WORKGROUPS_FOR_MATMUL', 0); - const a1 = tf.tensor4d([3, 2, 3, 4, 3, 2], [1, 2, 3, 1]); - const b1 = tf.tensor4d([2, 2, 2, 1, 4, 1], [1, 2, 3, 1]); - // Generate a bool tensor and have data in GPU. - const a = tf.greater(a1, b1); - // Cast the bool tensor to a float32 tensor. - const x = tf.cast(a, 'float32') as tf.Tensor4D; - const w = tf.tensor4d([1, 2, 3, 4, 5, 6, 7, 8], [2, 2, 1, 2]); - const res = tf.conv2d(x, w, 1, 0); - const resData = await res.data(); - test_util.expectArraysClose(resData, new Float32Array([6, 8, 10, 12])); - tf.env().set('WEBGPU_CONV_SEPARATE_IM2COL_SHADER', im2colFlag); - tf.env().set( - 'WEBGPU_THRESHOLD_TO_INCREASE_WORKGROUPS_FOR_MATMUL', thresholdFlag); - }); - - it('x=[1,9,9,3] f=[3,3,3,4] s=[2,2] d=1 p=valid NCHW', async () => { - const inputDepth = 3; - const xSize = 9; - const inputShape: [number, number, number, number] = - [1, xSize, xSize, inputDepth]; - const outputDepth = 4; - const fSize = 3; - const pad = 'valid'; - const stride: [number, number] = [2, 2]; - - const inputData = []; - for (let i = 0; i < xSize * xSize * inputDepth; i++) { - inputData.push(i % 5); - } - - const wData = []; - for (let i = 0; i < fSize * fSize * inputDepth * outputDepth; i++) { - wData.push(i % 5); - } - - const x = tf.tensor4d(inputData, inputShape); - const w = tf.tensor4d(wData, [fSize, fSize, inputDepth, outputDepth]); - - const result = tf.conv2d(x, w, stride, pad); - expect(result.shape).toEqual([1, 4, 4, 4]); - const resData = await result.data(); - test_util.expectArraysClose( - resData, new Float32Array([ - 115, 97, 114, 91, 104, 108, 102, 106, 123, 99, 95, 126, 97, - 90, 108, 111, 101, 116, 111, 116, 115, 97, 114, 91, 104, 108, - 102, 106, 123, 99, 95, 126, 97, 90, 108, 111, 101, 116, 111, - 116, 115, 97, 114, 91, 104, 108, 102, 106, 123, 99, 95, 126, - 97, 90, 108, 111, 101, 116, 111, 116, 115, 97, 114, 91 - ])); - }); - - it('x=[1,5,5,6] f=[3,3,6,4] s=[2,2] d=1 p=same', async () => { - const inputDepth = 6; - const xSize = 5; - const inputShape: [number, number, number, number] = - [1, xSize, xSize, inputDepth]; - const outputDepth = 4; - const fSize = 3; - const pad = 'same'; - const stride: [number, number] = [2, 2]; - - const inputData = []; - for (let i = 0; i < xSize * xSize * inputDepth; i++) { - inputData.push(i % 5); - } - - const wData = []; - for (let i = 0; i < fSize * fSize * inputDepth * outputDepth; i++) { - wData.push(i % 5); - } - - const x = tf.tensor4d(inputData, inputShape); - const w = tf.tensor4d(wData, [fSize, fSize, inputDepth, outputDepth]); - - const result = tf.conv2d(x, w, stride, pad); - expect(result.shape).toEqual([1, 3, 3, 4]); - const resData = await result.data(); - test_util.expectArraysClose( - resData, new Float32Array([ - 92, 74, 86, 73, 140, 132, 164, 156, 124, 123, 97, 106, - 115, 118, 136, 124, 232, 220, 228, 196, 180, 146, 147, 173, - 73, 95, 92, 74, 156, 128, 140, 132, 106, 90, 124, 123 - ])); - }); - - it('conv2d x=[1,8,8,3] f=[3,3,3,64] s=[2,2] d=1 p=valid Conv2DMMVec4Program remainder != 0', - async () => { - const inputDepth = 3; - const xSize = 8; - const inputShape: [number, number, number, number] = - [1, xSize, xSize, inputDepth]; - const outputDepth = 64; - const fSize = 3; - const pad = 'valid'; - const stride: [number, number] = [2, 2]; - - const inputData = []; - for (let i = 0; i < xSize * xSize * inputDepth; i++) { - inputData.push(i % 5); - } - - const wData = []; - for (let i = 0; i < fSize * fSize * inputDepth * outputDepth; i++) { - wData.push(i % 5); - } - - const x = tf.tensor4d(inputData, inputShape); - const w = tf.tensor4d(wData, [fSize, fSize, inputDepth, outputDepth]); - - const result = tf.conv2d(x, w, stride, pad); - expect(result.shape).toEqual([1, 3, 3, 64]); - test_util.expectArraysClose( - await result.data(), new Float32Array([ - 104, 125, 126, 102, 53, 104, 125, 126, 102, 53, 104, 125, 126, - 102, 53, 104, 125, 126, 102, 53, 104, 125, 126, 102, 53, 104, - 125, 126, 102, 53, 104, 125, 126, 102, 53, 104, 125, 126, 102, - 53, 104, 125, 126, 102, 53, 104, 125, 126, 102, 53, 104, 125, - 126, 102, 53, 104, 125, 126, 102, 53, 104, 125, 126, 102, 133, - 126, 104, 57, 110, 133, 126, 104, 57, 110, 133, 126, 104, 57, - 110, 133, 126, 104, 57, 110, 133, 126, 104, 57, 110, 133, 126, - 104, 57, 110, 133, 126, 104, 57, 110, 133, 126, 104, 57, 110, - 133, 126, 104, 57, 110, 133, 126, 104, 57, 110, 133, 126, 104, - 57, 110, 133, 126, 104, 57, 110, 133, 126, 104, 57, 137, 102, - 57, 112, 142, 137, 102, 57, 112, 142, 137, 102, 57, 112, 142, - 137, 102, 57, 112, 142, 137, 102, 57, 112, 142, 137, 102, 57, - 112, 142, 137, 102, 57, 112, 142, 137, 102, 57, 112, 142, 137, - 102, 57, 112, 142, 137, 102, 57, 112, 142, 137, 102, 57, 112, - 142, 137, 102, 57, 112, 142, 137, 102, 57, 112, 116, 53, 110, - 142, 149, 116, 53, 110, 142, 149, 116, 53, 110, 142, 149, 116, - 53, 110, 142, 149, 116, 53, 110, 142, 149, 116, 53, 110, 142, - 149, 116, 53, 110, 142, 149, 116, 53, 110, 142, 149, 116, 53, - 110, 142, 149, 116, 53, 110, 142, 149, 116, 53, 110, 142, 149, - 116, 53, 110, 142, 149, 116, 53, 110, 142, 50, 104, 133, 137, - 116, 50, 104, 133, 137, 116, 50, 104, 133, 137, 116, 50, 104, - 133, 137, 116, 50, 104, 133, 137, 116, 50, 104, 133, 137, 116, - 50, 104, 133, 137, 116, 50, 104, 133, 137, 116, 50, 104, 133, - 137, 116, 50, 104, 133, 137, 116, 50, 104, 133, 137, 116, 50, - 104, 133, 137, 116, 50, 104, 133, 137, 104, 125, 126, 102, 53, - 104, 125, 126, 102, 53, 104, 125, 126, 102, 53, 104, 125, 126, - 102, 53, 104, 125, 126, 102, 53, 104, 125, 126, 102, 53, 104, - 125, 126, 102, 53, 104, 125, 126, 102, 53, 104, 125, 126, 102, - 53, 104, 125, 126, 102, 53, 104, 125, 126, 102, 53, 104, 125, - 126, 102, 53, 104, 125, 126, 102, 133, 126, 104, 57, 110, 133, - 126, 104, 57, 110, 133, 126, 104, 57, 110, 133, 126, 104, 57, - 110, 133, 126, 104, 57, 110, 133, 126, 104, 57, 110, 133, 126, - 104, 57, 110, 133, 126, 104, 57, 110, 133, 126, 104, 57, 110, - 133, 126, 104, 57, 110, 133, 126, 104, 57, 110, 133, 126, 104, - 57, 110, 133, 126, 104, 57, 137, 102, 57, 112, 142, 137, 102, - 57, 112, 142, 137, 102, 57, 112, 142, 137, 102, 57, 112, 142, - 137, 102, 57, 112, 142, 137, 102, 57, 112, 142, 137, 102, 57, - 112, 142, 137, 102, 57, 112, 142, 137, 102, 57, 112, 142, 137, - 102, 57, 112, 142, 137, 102, 57, 112, 142, 137, 102, 57, 112, - 142, 137, 102, 57, 112, 116, 53, 110, 142, 149, 116, 53, 110, - 142, 149, 116, 53, 110, 142, 149, 116, 53, 110, 142, 149, 116, - 53, 110, 142, 149, 116, 53, 110, 142, 149, 116, 53, 110, 142, - 149, 116, 53, 110, 142, 149, 116, 53, 110, 142, 149, 116, 53, - 110, 142, 149, 116, 53, 110, 142, 149, 116, 53, 110, 142, 149, - 116, 53, 110, 142 - ])); - }); - - it('conv2d x=[1,8,8,64] f=[3,3,64,64] s=[1,1] d=1 p=same Conv2DMMVec4Program fitA == true and fitB == true', - async () => { - const inputDepth = 64; - const xSize = 8; - const inputShape: [number, number, number, number] = - [1, xSize, xSize, inputDepth]; - const outputDepth = 64; - const fSize = 3; - const pad = 'same'; - const stride: [number, number] = [1, 1]; - - const inputData = []; - for (let i = 0; i < xSize * xSize * inputDepth; i++) { - inputData.push(i % 5); - } - - const wData = []; - for (let i = 0; i < fSize * fSize * inputDepth * outputDepth; i++) { - wData.push(i % 5); - } - - const x = tf.tensor4d(inputData, inputShape); - const w = tf.tensor4d(wData, [fSize, fSize, inputDepth, outputDepth]); - - const result = tf.conv2d(x, w, stride, pad); - expect(result.shape).toEqual([1, 8, 8, 64]); - test_util.expectArraysClose( - await result.data(), new Float32Array([ - 514, 1026, 1283, 1275, 1022, 514, 1026, 1283, 1275, 1022, 514, - 1026, 1283, 1275, 1022, 514, 1026, 1283, 1275, 1022, 514, 1026, - 1283, 1275, 1022, 514, 1026, 1283, 1275, 1022, 514, 1026, 1283, - 1275, 1022, 514, 1026, 1283, 1275, 1022, 514, 1026, 1283, 1275, - 1022, 514, 1026, 1283, 1275, 1022, 514, 1026, 1283, 1275, 1022, - 514, 1026, 1283, 1275, 1022, 514, 1026, 1283, 1275, 1524, 770, - 1536, 1917, 1913, 1524, 770, 1536, 1917, 1913, 1524, 770, 1536, - 1917, 1913, 1524, 770, 1536, 1917, 1913, 1524, 770, 1536, 1917, - 1913, 1524, 770, 1536, 1917, 1913, 1524, 770, 1536, 1917, 1913, - 1524, 770, 1536, 1917, 1913, 1524, 770, 1536, 1917, 1913, 1524, - 770, 1536, 1917, 1913, 1524, 770, 1536, 1917, 1913, 1524, 770, - 1536, 1917, 1913, 1524, 770, 1536, 1917, 1913, 1540, 767, 1534, - 1916, 1913, 1540, 767, 1534, 1916, 1913, 1540, 767, 1534, 1916, - 1913, 1540, 767, 1534, 1916, 1913, 1540, 767, 1534, 1916, 1913, - 1540, 767, 1534, 1916, 1913, 1540, 767, 1534, 1916, 1913, 1540, - 767, 1534, 1916, 1913, 1540, 767, 1534, 1916, 1913, 1540, 767, - 1534, 1916, 1913, 1540, 767, 1534, 1916, 1913, 1540, 767, 1534, - 1916, 1913, 1540, 767, 1534, 1917, 1925, 1538, 766, 1534, 1917, - 1925, 1538, 766, 1534, 1917, 1925, 1538, 766, 1534, 1917, 1925, - 1538, 766, 1534, 1917, 1925, 1538, 766, 1534, 1917, 1925, 1538, - 766, 1534, 1917, 1925, 1538, 766, 1534, 1917, 1925, 1538, 766, - 1534, 1917, 1925, 1538, 766, 1534, 1917, 1925, 1538, 766, 1534, - 1917, 1925, 1538, 766, 1534, 1917, 1925, 1538, 766, 1534, 1917, - 1925, 1538, 766, 1536, 1925, 1924, 1538, 767, 1536, 1925, 1924, - 1538, 767, 1536, 1925, 1924, 1538, 767, 1536, 1925, 1924, 1538, - 767, 1536, 1925, 1924, 1538, 767, 1536, 1925, 1924, 1538, 767, - 1536, 1925, 1924, 1538, 767, 1536, 1925, 1924, 1538, 767, 1536, - 1925, 1924, 1538, 767, 1536, 1925, 1924, 1538, 767, 1536, 1925, - 1924, 1538, 767, 1536, 1925, 1924, 1538, 767, 1536, 1925, 1924, - 1538, 770, 1540, 1925, 1925, 1540, 770, 1540, 1925, 1925, 1540, - 770, 1540, 1925, 1925, 1540, 770, 1540, 1925, 1925, 1540, 770, - 1540, 1925, 1925, 1540, 770, 1540, 1925, 1925, 1540, 770, 1540, - 1925, 1925, 1540, 770, 1540, 1925, 1925, 1540, 770, 1540, 1925, - 1925, 1540, 770, 1540, 1925, 1925, 1540, 770, 1540, 1925, 1925, - 1540, 770, 1540, 1925, 1925, 1540, 770, 1540, 1925, 1925, 1524, - 770, 1536, 1917, 1913, 1524, 770, 1536, 1917, 1913, 1524, 770, - 1536, 1917, 1913, 1524, 770, 1536, 1917, 1913, 1524, 770, 1536, - 1917, 1913, 1524, 770, 1536, 1917, 1913, 1524, 770, 1536, 1917, - 1913, 1524, 770, 1536, 1917, 1913, 1524, 770, 1536, 1917, 1913, - 1524, 770, 1536, 1917, 1913, 1524, 770, 1536, 1917, 1913, 1524, - 770, 1536, 1917, 1913, 1524, 770, 1536, 1917, 1276, 1022, 513, - 1024, 1275, 1276, 1022, 513, 1024, 1275, 1276, 1022, 513, 1024, - 1275, 1276, 1022, 513, 1024, 1275, 1276, 1022, 513, 1024, 1275, - 1276, 1022, 513, 1024, 1275, 1276, 1022, 513, 1024, 1275, 1276, - 1022, 513, 1024, 1275, 1276, 1022, 513, 1024, 1275, 1276, 1022, - 513, 1024, 1275, 1276, 1022, 513, 1024, 1275, 1276, 1022, 513, - 1024, 1275, 1276, 1022, 513, 1024, 1916, 1913, 1540, 767, 1534, - 1916, 1913, 1540, 767, 1534, 1916, 1913, 1540, 767, 1534, 1916, - 1913, 1540, 767, 1534, 1916, 1913, 1540, 767, 1534, 1916, 1913, - 1540, 767, 1534, 1916, 1913, 1540, 767, 1534, 1916, 1913, 1540, - 767, 1534, 1916, 1913, 1540, 767, 1534, 1916, 1913, 1540, 767, - 1534, 1916, 1913, 1540, 767, 1534, 1916, 1913, 1540, 767, 1534, - 1916, 1913, 1540, 767, 2300, 2875, 2875, 2300, 1150, 2300, 2875, - 2875, 2300, 1150, 2300, 2875, 2875, 2300, 1150, 2300, 2875, 2875, - 2300, 1150, 2300, 2875, 2875, 2300, 1150, 2300, 2875, 2875, 2300, - 1150, 2300, 2875, 2875, 2300, 1150, 2300, 2875, 2875, 2300, 1150, - 2300, 2875, 2875, 2300, 1150, 2300, 2875, 2875, 2300, 1150, 2300, - 2875, 2875, 2300, 1150, 2300, 2875, 2875, 2300, 1150, 2300, 2875, - 2875, 2300, 1150, 2304, 2883, 2887, 2316, 1150, 2304, 2883, 2887, - 2316, 1150, 2304, 2883, 2887, 2316, 1150, 2304, 2883, 2887, 2316, - 1150, 2304, 2883, 2887, 2316, 1150, 2304, 2883, 2887, 2316, 1150, - 2304, 2883, 2887, 2316, 1150, 2304, 2883, 2887, 2316, 1150, 2304, - 2883, 2887, 2316, 1150, 2304, 2883, 2887, 2316, 1150, 2304, 2883, - 2887, 2316, 1150, 2304, 2883, 2887, 2316, 1150, 2304, 2883, 2887, - 2300, 1153, 2306, 2884, 2887, 2300, 1153, 2306, 2884, 2887, 2300, - 1153, 2306, 2884, 2887, 2300, 1153, 2306, 2884, 2887, 2300, 1153, - 2306, 2884, 2887, 2300, 1153, 2306, 2884, 2887, 2300, 1153, 2306, - 2884, 2887, 2300, 1153, 2306, 2884, 2887, 2300, 1153, 2306, 2884, - 2887, 2300, 1153, 2306, 2884, 2887, 2300, 1153, 2306, 2884, 2887, - 2300, 1153, 2306, 2884, 2887, 2300, 1153, 2306, 2884, 2875, 2302, - 1154, 2306, 2883, 2875, 2302, 1154, 2306, 2883, 2875, 2302, 1154, - 2306, 2883, 2875, 2302, 1154, 2306, 2883, 2875, 2302, 1154, 2306, - 2883, 2875, 2302, 1154, 2306, 2883, 2875, 2302, 1154, 2306, 2883, - 2875, 2302, 1154, 2306, 2883, 2875, 2302, 1154, 2306, 2883, 2875, - 2302, 1154, 2306, 2883, 2875, 2302, 1154, 2306, 2883, 2875, 2302, - 1154, 2306, 2883, 2875, 2302, 1154, 2306, 2875, 2876, 2302, 1153, - 2304, 2875, 2876, 2302, 1153, 2304, 2875, 2876, 2302, 1153, 2304, - 2875, 2876, 2302, 1153, 2304, 2875, 2876, 2302, 1153, 2304, 2875, - 2876, 2302, 1153, 2304, 2875, 2876, 2302, 1153, 2304, 2875, 2876, - 2302, 1153, 2304, 2875, 2876, 2302, 1153, 2304, 2875, 2876, 2302, - 1153, 2304, 2875, 2876, 2302, 1153, 2304, 2875, 2876, 2302, 1153, - 2304, 2875, 2876, 2302, 1153, 2300, 2875, 2875, 2300, 1150, 2300, - 2875, 2875, 2300, 1150, 2300, 2875, 2875, 2300, 1150, 2300, 2875, - 2875, 2300, 1150, 2300, 2875, 2875, 2300, 1150, 2300, 2875, 2875, - 2300, 1150, 2300, 2875, 2875, 2300, 1150, 2300, 2875, 2875, 2300, - 1150, 2300, 2875, 2875, 2300, 1150, 2300, 2875, 2875, 2300, 1150, - 2300, 2875, 2875, 2300, 1150, 2300, 2875, 2875, 2300, 1150, 2300, - 2875, 2875, 2300, 766, 1534, 1917, 1925, 1538, 766, 1534, 1917, - 1925, 1538, 766, 1534, 1917, 1925, 1538, 766, 1534, 1917, 1925, - 1538, 766, 1534, 1917, 1925, 1538, 766, 1534, 1917, 1925, 1538, - 766, 1534, 1917, 1925, 1538, 766, 1534, 1917, 1925, 1538, 766, - 1534, 1917, 1925, 1538, 766, 1534, 1917, 1925, 1538, 766, 1534, - 1917, 1925, 1538, 766, 1534, 1917, 1925, 1538, 766, 1534, 1917, - 1925, 1540, 770, 1540, 1925, 1925, 1540, 770, 1540, 1925, 1925, - 1540, 770, 1540, 1925, 1925, 1540, 770, 1540, 1925, 1925, 1540, - 770, 1540, 1925, 1925, 1540, 770, 1540, 1925, 1925, 1540, 770, - 1540, 1925, 1925, 1540, 770, 1540, 1925, 1925, 1540, 770, 1540, - 1925, 1925, 1540, 770, 1540, 1925, 1925, 1540, 770, 1540, 1925, - 1925, 1540, 770, 1540, 1925, 1925, 1540, 770, 1540, 1925, 2875, - 2302, 1154, 2306, 2883, 2875, 2302, 1154, 2306, 2883, 2875, 2302, - 1154, 2306, 2883, 2875, 2302, 1154, 2306, 2883, 2875, 2302, 1154, - 2306, 2883, 2875, 2302, 1154, 2306, 2883, 2875, 2302, 1154, 2306, - 2883, 2875, 2302, 1154, 2306, 2883, 2875, 2302, 1154, 2306, 2883, - 2875, 2302, 1154, 2306, 2883, 2875, 2302, 1154, 2306, 2883, 2875, - 2302, 1154, 2306, 2883, 2875, 2302, 1154, 2306, 2875, 2876, 2302, - 1153, 2304, 2875, 2876, 2302, 1153, 2304, 2875, 2876, 2302, 1153, - 2304, 2875, 2876, 2302, 1153, 2304, 2875, 2876, 2302, 1153, 2304, - 2875, 2876, 2302, 1153, 2304, 2875, 2876, 2302, 1153, 2304, 2875, - 2876, 2302, 1153, 2304, 2875, 2876, 2302, 1153, 2304, 2875, 2876, - 2302, 1153, 2304, 2875, 2876, 2302, 1153, 2304, 2875, 2876, 2302, - 1153, 2304, 2875, 2876, 2302, 1153, 2300, 2875, 2875, 2300, 1150, - 2300, 2875, 2875, 2300, 1150, 2300, 2875, 2875, 2300, 1150, 2300, - 2875, 2875, 2300, 1150, 2300, 2875, 2875, 2300, 1150, 2300, 2875, - 2875, 2300, 1150, 2300, 2875, 2875, 2300, 1150, 2300, 2875, 2875, - 2300, 1150, 2300, 2875, 2875, 2300, 1150, 2300, 2875, 2875, 2300, - 1150, 2300, 2875, 2875, 2300, 1150, 2300, 2875, 2875, 2300, 1150, - 2300, 2875, 2875, 2300, 1150, 2304, 2883, 2887, 2316, 1150, 2304, - 2883, 2887, 2316, 1150, 2304, 2883, 2887, 2316, 1150, 2304, 2883, - 2887, 2316, 1150, 2304, 2883, 2887, 2316, 1150, 2304, 2883, 2887, - 2316, 1150, 2304, 2883, 2887, 2316, 1150, 2304, 2883, 2887, 2316, - 1150, 2304, 2883, 2887, 2316, 1150, 2304, 2883, 2887, 2316, 1150, - 2304, 2883, 2887, 2316, 1150, 2304, 2883, 2887, 2316, 1150, 2304, - 2883, 2887, 2300, 1153, 2306, 2884, 2887, 2300, 1153, 2306, 2884, - 2887, 2300, 1153, 2306, 2884, 2887, 2300, 1153, 2306, 2884, 2887, - 2300, 1153, 2306, 2884, 2887, 2300, 1153, 2306, 2884, 2887, 2300, - 1153, 2306, 2884, 2887, 2300, 1153, 2306, 2884, 2887, 2300, 1153, - 2306, 2884, 2887, 2300, 1153, 2306, 2884, 2887, 2300, 1153, 2306, - 2884, 2887, 2300, 1153, 2306, 2884, 2887, 2300, 1153, 2306, 2884, - 2875, 2302, 1154, 2306, 2883, 2875, 2302, 1154, 2306, 2883, 2875, - 2302, 1154, 2306, 2883, 2875, 2302, 1154, 2306, 2883, 2875, 2302, - 1154, 2306, 2883, 2875, 2302, 1154, 2306, 2883, 2875, 2302, 1154, - 2306, 2883, 2875, 2302, 1154, 2306, 2883, 2875, 2302, 1154, 2306, - 2883, 2875, 2302, 1154, 2306, 2883, 2875, 2302, 1154, 2306, 2883, - 2875, 2302, 1154, 2306, 2883, 2875, 2302, 1154, 2306, 1917, 1913, - 1524, 770, 1536, 1917, 1913, 1524, 770, 1536, 1917, 1913, 1524, - 770, 1536, 1917, 1913, 1524, 770, 1536, 1917, 1913, 1524, 770, - 1536, 1917, 1913, 1524, 770, 1536, 1917, 1913, 1524, 770, 1536, - 1917, 1913, 1524, 770, 1536, 1917, 1913, 1524, 770, 1536, 1917, - 1913, 1524, 770, 1536, 1917, 1913, 1524, 770, 1536, 1917, 1913, - 1524, 770, 1536, 1917, 1913, 1524, 770, 1534, 1917, 1925, 1538, - 766, 1534, 1917, 1925, 1538, 766, 1534, 1917, 1925, 1538, 766, - 1534, 1917, 1925, 1538, 766, 1534, 1917, 1925, 1538, 766, 1534, - 1917, 1925, 1538, 766, 1534, 1917, 1925, 1538, 766, 1534, 1917, - 1925, 1538, 766, 1534, 1917, 1925, 1538, 766, 1534, 1917, 1925, - 1538, 766, 1534, 1917, 1925, 1538, 766, 1534, 1917, 1925, 1538, - 766, 1534, 1917, 1925, 1538, 1150, 2304, 2883, 2887, 2316, 1150, - 2304, 2883, 2887, 2316, 1150, 2304, 2883, 2887, 2316, 1150, 2304, - 2883, 2887, 2316, 1150, 2304, 2883, 2887, 2316, 1150, 2304, 2883, - 2887, 2316, 1150, 2304, 2883, 2887, 2316, 1150, 2304, 2883, 2887, - 2316, 1150, 2304, 2883, 2887, 2316, 1150, 2304, 2883, 2887, 2316, - 1150, 2304, 2883, 2887, 2316, 1150, 2304, 2883, 2887, 2316, 1150, - 2304, 2883, 2887, 2300, 1153, 2306, 2884, 2887, 2300, 1153, 2306, - 2884, 2887, 2300, 1153, 2306, 2884, 2887, 2300, 1153, 2306, 2884, - 2887, 2300, 1153, 2306, 2884, 2887, 2300, 1153, 2306, 2884, 2887, - 2300, 1153, 2306, 2884, 2887, 2300, 1153, 2306, 2884, 2887, 2300, - 1153, 2306, 2884, 2887, 2300, 1153, 2306, 2884, 2887, 2300, 1153, - 2306, 2884, 2887, 2300, 1153, 2306, 2884, 2887, 2300, 1153, 2306, - 2884, 2875, 2302, 1154, 2306, 2883, 2875, 2302, 1154, 2306, 2883, - 2875, 2302, 1154, 2306, 2883, 2875, 2302, 1154, 2306, 2883, 2875, - 2302, 1154, 2306, 2883, 2875, 2302, 1154, 2306, 2883, 2875, 2302, - 1154, 2306, 2883, 2875, 2302, 1154, 2306, 2883, 2875, 2302, 1154, - 2306, 2883, 2875, 2302, 1154, 2306, 2883, 2875, 2302, 1154, 2306, - 2883, 2875, 2302, 1154, 2306, 2883, 2875, 2302, 1154, 2306, 2875, - 2876, 2302, 1153, 2304, 2875, 2876, 2302, 1153, 2304, 2875, 2876, - 2302, 1153, 2304, 2875, 2876, 2302, 1153, 2304, 2875, 2876, 2302, - 1153, 2304, 2875, 2876, 2302, 1153, 2304, 2875, 2876, 2302, 1153, - 2304, 2875, 2876, 2302, 1153, 2304, 2875, 2876, 2302, 1153, 2304, - 2875, 2876, 2302, 1153, 2304, 2875, 2876, 2302, 1153, 2304, 2875, - 2876, 2302, 1153, 2304, 2875, 2876, 2302, 1153, 2300, 2875, 2875, - 2300, 1150, 2300, 2875, 2875, 2300, 1150, 2300, 2875, 2875, 2300, - 1150, 2300, 2875, 2875, 2300, 1150, 2300, 2875, 2875, 2300, 1150, - 2300, 2875, 2875, 2300, 1150, 2300, 2875, 2875, 2300, 1150, 2300, - 2875, 2875, 2300, 1150, 2300, 2875, 2875, 2300, 1150, 2300, 2875, - 2875, 2300, 1150, 2300, 2875, 2875, 2300, 1150, 2300, 2875, 2875, - 2300, 1150, 2300, 2875, 2875, 2300, 1150, 2304, 2883, 2887, 2316, - 1150, 2304, 2883, 2887, 2316, 1150, 2304, 2883, 2887, 2316, 1150, - 2304, 2883, 2887, 2316, 1150, 2304, 2883, 2887, 2316, 1150, 2304, - 2883, 2887, 2316, 1150, 2304, 2883, 2887, 2316, 1150, 2304, 2883, - 2887, 2316, 1150, 2304, 2883, 2887, 2316, 1150, 2304, 2883, 2887, - 2316, 1150, 2304, 2883, 2887, 2316, 1150, 2304, 2883, 2887, 2316, - 1150, 2304, 2883, 2887, 1538, 767, 1536, 1925, 1924, 1538, 767, - 1536, 1925, 1924, 1538, 767, 1536, 1925, 1924, 1538, 767, 1536, - 1925, 1924, 1538, 767, 1536, 1925, 1924, 1538, 767, 1536, 1925, - 1924, 1538, 767, 1536, 1925, 1924, 1538, 767, 1536, 1925, 1924, - 1538, 767, 1536, 1925, 1924, 1538, 767, 1536, 1925, 1924, 1538, - 767, 1536, 1925, 1924, 1538, 767, 1536, 1925, 1924, 1538, 767, - 1536, 1925, 1913, 1524, 770, 1536, 1917, 1913, 1524, 770, 1536, - 1917, 1913, 1524, 770, 1536, 1917, 1913, 1524, 770, 1536, 1917, - 1913, 1524, 770, 1536, 1917, 1913, 1524, 770, 1536, 1917, 1913, - 1524, 770, 1536, 1917, 1913, 1524, 770, 1536, 1917, 1913, 1524, - 770, 1536, 1917, 1913, 1524, 770, 1536, 1917, 1913, 1524, 770, - 1536, 1917, 1913, 1524, 770, 1536, 1917, 1913, 1524, 770, 1536, - 2875, 2876, 2302, 1153, 2304, 2875, 2876, 2302, 1153, 2304, 2875, - 2876, 2302, 1153, 2304, 2875, 2876, 2302, 1153, 2304, 2875, 2876, - 2302, 1153, 2304, 2875, 2876, 2302, 1153, 2304, 2875, 2876, 2302, - 1153, 2304, 2875, 2876, 2302, 1153, 2304, 2875, 2876, 2302, 1153, - 2304, 2875, 2876, 2302, 1153, 2304, 2875, 2876, 2302, 1153, 2304, - 2875, 2876, 2302, 1153, 2304, 2875, 2876, 2302, 1153, 2300, 2875, - 2875, 2300, 1150, 2300, 2875, 2875, 2300, 1150, 2300, 2875, 2875, - 2300, 1150, 2300, 2875, 2875, 2300, 1150, 2300, 2875, 2875, 2300, - 1150, 2300, 2875, 2875, 2300, 1150, 2300, 2875, 2875, 2300, 1150, - 2300, 2875, 2875, 2300, 1150, 2300, 2875, 2875, 2300, 1150, 2300, - 2875, 2875, 2300, 1150, 2300, 2875, 2875, 2300, 1150, 2300, 2875, - 2875, 2300, 1150, 2300, 2875, 2875, 2300, 1150, 2304, 2883, 2887, - 2316, 1150, 2304, 2883, 2887, 2316, 1150, 2304, 2883, 2887, 2316, - 1150, 2304, 2883, 2887, 2316, 1150, 2304, 2883, 2887, 2316, 1150, - 2304, 2883, 2887, 2316, 1150, 2304, 2883, 2887, 2316, 1150, 2304, - 2883, 2887, 2316, 1150, 2304, 2883, 2887, 2316, 1150, 2304, 2883, - 2887, 2316, 1150, 2304, 2883, 2887, 2316, 1150, 2304, 2883, 2887, - 2316, 1150, 2304, 2883, 2887, 2300, 1153, 2306, 2884, 2887, 2300, - 1153, 2306, 2884, 2887, 2300, 1153, 2306, 2884, 2887, 2300, 1153, - 2306, 2884, 2887, 2300, 1153, 2306, 2884, 2887, 2300, 1153, 2306, - 2884, 2887, 2300, 1153, 2306, 2884, 2887, 2300, 1153, 2306, 2884, - 2887, 2300, 1153, 2306, 2884, 2887, 2300, 1153, 2306, 2884, 2887, - 2300, 1153, 2306, 2884, 2887, 2300, 1153, 2306, 2884, 2887, 2300, - 1153, 2306, 2884, 2875, 2302, 1154, 2306, 2883, 2875, 2302, 1154, - 2306, 2883, 2875, 2302, 1154, 2306, 2883, 2875, 2302, 1154, 2306, - 2883, 2875, 2302, 1154, 2306, 2883, 2875, 2302, 1154, 2306, 2883, - 2875, 2302, 1154, 2306, 2883, 2875, 2302, 1154, 2306, 2883, 2875, - 2302, 1154, 2306, 2883, 2875, 2302, 1154, 2306, 2883, 2875, 2302, - 1154, 2306, 2883, 2875, 2302, 1154, 2306, 2883, 2875, 2302, 1154, - 2306, 2875, 2876, 2302, 1153, 2304, 2875, 2876, 2302, 1153, 2304, - 2875, 2876, 2302, 1153, 2304, 2875, 2876, 2302, 1153, 2304, 2875, - 2876, 2302, 1153, 2304, 2875, 2876, 2302, 1153, 2304, 2875, 2876, - 2302, 1153, 2304, 2875, 2876, 2302, 1153, 2304, 2875, 2876, 2302, - 1153, 2304, 2875, 2876, 2302, 1153, 2304, 2875, 2876, 2302, 1153, - 2304, 2875, 2876, 2302, 1153, 2304, 2875, 2876, 2302, 1153, 1534, - 1916, 1913, 1540, 767, 1534, 1916, 1913, 1540, 767, 1534, 1916, - 1913, 1540, 767, 1534, 1916, 1913, 1540, 767, 1534, 1916, 1913, - 1540, 767, 1534, 1916, 1913, 1540, 767, 1534, 1916, 1913, 1540, - 767, 1534, 1916, 1913, 1540, 767, 1534, 1916, 1913, 1540, 767, - 1534, 1916, 1913, 1540, 767, 1534, 1916, 1913, 1540, 767, 1534, - 1916, 1913, 1540, 767, 1534, 1916, 1913, 1540, 767, 1536, 1925, - 1924, 1538, 767, 1536, 1925, 1924, 1538, 767, 1536, 1925, 1924, - 1538, 767, 1536, 1925, 1924, 1538, 767, 1536, 1925, 1924, 1538, - 767, 1536, 1925, 1924, 1538, 767, 1536, 1925, 1924, 1538, 767, - 1536, 1925, 1924, 1538, 767, 1536, 1925, 1924, 1538, 767, 1536, - 1925, 1924, 1538, 767, 1536, 1925, 1924, 1538, 767, 1536, 1925, - 1924, 1538, 767, 1536, 1925, 1924, 2300, 1153, 2306, 2884, 2887, - 2300, 1153, 2306, 2884, 2887, 2300, 1153, 2306, 2884, 2887, 2300, - 1153, 2306, 2884, 2887, 2300, 1153, 2306, 2884, 2887, 2300, 1153, - 2306, 2884, 2887, 2300, 1153, 2306, 2884, 2887, 2300, 1153, 2306, - 2884, 2887, 2300, 1153, 2306, 2884, 2887, 2300, 1153, 2306, 2884, - 2887, 2300, 1153, 2306, 2884, 2887, 2300, 1153, 2306, 2884, 2887, - 2300, 1153, 2306, 2884, 2875, 2302, 1154, 2306, 2883, 2875, 2302, - 1154, 2306, 2883, 2875, 2302, 1154, 2306, 2883, 2875, 2302, 1154, - 2306, 2883, 2875, 2302, 1154, 2306, 2883, 2875, 2302, 1154, 2306, - 2883, 2875, 2302, 1154, 2306, 2883, 2875, 2302, 1154, 2306, 2883, - 2875, 2302, 1154, 2306, 2883, 2875, 2302, 1154, 2306, 2883, 2875, - 2302, 1154, 2306, 2883, 2875, 2302, 1154, 2306, 2883, 2875, 2302, - 1154, 2306, 2875, 2876, 2302, 1153, 2304, 2875, 2876, 2302, 1153, - 2304, 2875, 2876, 2302, 1153, 2304, 2875, 2876, 2302, 1153, 2304, - 2875, 2876, 2302, 1153, 2304, 2875, 2876, 2302, 1153, 2304, 2875, - 2876, 2302, 1153, 2304, 2875, 2876, 2302, 1153, 2304, 2875, 2876, - 2302, 1153, 2304, 2875, 2876, 2302, 1153, 2304, 2875, 2876, 2302, - 1153, 2304, 2875, 2876, 2302, 1153, 2304, 2875, 2876, 2302, 1153, - 2300, 2875, 2875, 2300, 1150, 2300, 2875, 2875, 2300, 1150, 2300, - 2875, 2875, 2300, 1150, 2300, 2875, 2875, 2300, 1150, 2300, 2875, - 2875, 2300, 1150, 2300, 2875, 2875, 2300, 1150, 2300, 2875, 2875, - 2300, 1150, 2300, 2875, 2875, 2300, 1150, 2300, 2875, 2875, 2300, - 1150, 2300, 2875, 2875, 2300, 1150, 2300, 2875, 2875, 2300, 1150, - 2300, 2875, 2875, 2300, 1150, 2300, 2875, 2875, 2300, 1150, 2304, - 2883, 2887, 2316, 1150, 2304, 2883, 2887, 2316, 1150, 2304, 2883, - 2887, 2316, 1150, 2304, 2883, 2887, 2316, 1150, 2304, 2883, 2887, - 2316, 1150, 2304, 2883, 2887, 2316, 1150, 2304, 2883, 2887, 2316, - 1150, 2304, 2883, 2887, 2316, 1150, 2304, 2883, 2887, 2316, 1150, - 2304, 2883, 2887, 2316, 1150, 2304, 2883, 2887, 2316, 1150, 2304, - 2883, 2887, 2316, 1150, 2304, 2883, 2887, 2300, 1153, 2306, 2884, - 2887, 2300, 1153, 2306, 2884, 2887, 2300, 1153, 2306, 2884, 2887, - 2300, 1153, 2306, 2884, 2887, 2300, 1153, 2306, 2884, 2887, 2300, - 1153, 2306, 2884, 2887, 2300, 1153, 2306, 2884, 2887, 2300, 1153, - 2306, 2884, 2887, 2300, 1153, 2306, 2884, 2887, 2300, 1153, 2306, - 2884, 2887, 2300, 1153, 2306, 2884, 2887, 2300, 1153, 2306, 2884, - 2887, 2300, 1153, 2306, 2884, 1925, 1540, 770, 1540, 1925, 1925, - 1540, 770, 1540, 1925, 1925, 1540, 770, 1540, 1925, 1925, 1540, - 770, 1540, 1925, 1925, 1540, 770, 1540, 1925, 1925, 1540, 770, - 1540, 1925, 1925, 1540, 770, 1540, 1925, 1925, 1540, 770, 1540, - 1925, 1925, 1540, 770, 1540, 1925, 1925, 1540, 770, 1540, 1925, - 1925, 1540, 770, 1540, 1925, 1925, 1540, 770, 1540, 1925, 1925, - 1540, 770, 1540, 1916, 1913, 1540, 767, 1534, 1916, 1913, 1540, - 767, 1534, 1916, 1913, 1540, 767, 1534, 1916, 1913, 1540, 767, - 1534, 1916, 1913, 1540, 767, 1534, 1916, 1913, 1540, 767, 1534, - 1916, 1913, 1540, 767, 1534, 1916, 1913, 1540, 767, 1534, 1916, - 1913, 1540, 767, 1534, 1916, 1913, 1540, 767, 1534, 1916, 1913, - 1540, 767, 1534, 1916, 1913, 1540, 767, 1534, 1916, 1913, 1540, - 767, 2300, 2875, 2875, 2300, 1150, 2300, 2875, 2875, 2300, 1150, - 2300, 2875, 2875, 2300, 1150, 2300, 2875, 2875, 2300, 1150, 2300, - 2875, 2875, 2300, 1150, 2300, 2875, 2875, 2300, 1150, 2300, 2875, - 2875, 2300, 1150, 2300, 2875, 2875, 2300, 1150, 2300, 2875, 2875, - 2300, 1150, 2300, 2875, 2875, 2300, 1150, 2300, 2875, 2875, 2300, - 1150, 2300, 2875, 2875, 2300, 1150, 2300, 2875, 2875, 2300, 1150, - 2304, 2883, 2887, 2316, 1150, 2304, 2883, 2887, 2316, 1150, 2304, - 2883, 2887, 2316, 1150, 2304, 2883, 2887, 2316, 1150, 2304, 2883, - 2887, 2316, 1150, 2304, 2883, 2887, 2316, 1150, 2304, 2883, 2887, - 2316, 1150, 2304, 2883, 2887, 2316, 1150, 2304, 2883, 2887, 2316, - 1150, 2304, 2883, 2887, 2316, 1150, 2304, 2883, 2887, 2316, 1150, - 2304, 2883, 2887, 2316, 1150, 2304, 2883, 2887, 2300, 1153, 2306, - 2884, 2887, 2300, 1153, 2306, 2884, 2887, 2300, 1153, 2306, 2884, - 2887, 2300, 1153, 2306, 2884, 2887, 2300, 1153, 2306, 2884, 2887, - 2300, 1153, 2306, 2884, 2887, 2300, 1153, 2306, 2884, 2887, 2300, - 1153, 2306, 2884, 2887, 2300, 1153, 2306, 2884, 2887, 2300, 1153, - 2306, 2884, 2887, 2300, 1153, 2306, 2884, 2887, 2300, 1153, 2306, - 2884, 2887, 2300, 1153, 2306, 2884, 2875, 2302, 1154, 2306, 2883, - 2875, 2302, 1154, 2306, 2883, 2875, 2302, 1154, 2306, 2883, 2875, - 2302, 1154, 2306, 2883, 2875, 2302, 1154, 2306, 2883, 2875, 2302, - 1154, 2306, 2883, 2875, 2302, 1154, 2306, 2883, 2875, 2302, 1154, - 2306, 2883, 2875, 2302, 1154, 2306, 2883, 2875, 2302, 1154, 2306, - 2883, 2875, 2302, 1154, 2306, 2883, 2875, 2302, 1154, 2306, 2883, - 2875, 2302, 1154, 2306, 2875, 2876, 2302, 1153, 2304, 2875, 2876, - 2302, 1153, 2304, 2875, 2876, 2302, 1153, 2304, 2875, 2876, 2302, - 1153, 2304, 2875, 2876, 2302, 1153, 2304, 2875, 2876, 2302, 1153, - 2304, 2875, 2876, 2302, 1153, 2304, 2875, 2876, 2302, 1153, 2304, - 2875, 2876, 2302, 1153, 2304, 2875, 2876, 2302, 1153, 2304, 2875, - 2876, 2302, 1153, 2304, 2875, 2876, 2302, 1153, 2304, 2875, 2876, - 2302, 1153, 2300, 2875, 2875, 2300, 1150, 2300, 2875, 2875, 2300, - 1150, 2300, 2875, 2875, 2300, 1150, 2300, 2875, 2875, 2300, 1150, - 2300, 2875, 2875, 2300, 1150, 2300, 2875, 2875, 2300, 1150, 2300, - 2875, 2875, 2300, 1150, 2300, 2875, 2875, 2300, 1150, 2300, 2875, - 2875, 2300, 1150, 2300, 2875, 2875, 2300, 1150, 2300, 2875, 2875, - 2300, 1150, 2300, 2875, 2875, 2300, 1150, 2300, 2875, 2875, 2300, - 766, 1534, 1917, 1925, 1538, 766, 1534, 1917, 1925, 1538, 766, - 1534, 1917, 1925, 1538, 766, 1534, 1917, 1925, 1538, 766, 1534, - 1917, 1925, 1538, 766, 1534, 1917, 1925, 1538, 766, 1534, 1917, - 1925, 1538, 766, 1534, 1917, 1925, 1538, 766, 1534, 1917, 1925, - 1538, 766, 1534, 1917, 1925, 1538, 766, 1534, 1917, 1925, 1538, - 766, 1534, 1917, 1925, 1538, 766, 1534, 1917, 1925, 1036, 510, - 1024, 1283, 1287, 1036, 510, 1024, 1283, 1287, 1036, 510, 1024, - 1283, 1287, 1036, 510, 1024, 1283, 1287, 1036, 510, 1024, 1283, - 1287, 1036, 510, 1024, 1283, 1287, 1036, 510, 1024, 1283, 1287, - 1036, 510, 1024, 1283, 1287, 1036, 510, 1024, 1283, 1287, 1036, - 510, 1024, 1283, 1287, 1036, 510, 1024, 1283, 1287, 1036, 510, - 1024, 1283, 1287, 1036, 510, 1024, 1283, 1924, 1538, 767, 1536, - 1925, 1924, 1538, 767, 1536, 1925, 1924, 1538, 767, 1536, 1925, - 1924, 1538, 767, 1536, 1925, 1924, 1538, 767, 1536, 1925, 1924, - 1538, 767, 1536, 1925, 1924, 1538, 767, 1536, 1925, 1924, 1538, - 767, 1536, 1925, 1924, 1538, 767, 1536, 1925, 1924, 1538, 767, - 1536, 1925, 1924, 1538, 767, 1536, 1925, 1924, 1538, 767, 1536, - 1925, 1924, 1538, 767, 1536, 1925, 1925, 1540, 770, 1540, 1925, - 1925, 1540, 770, 1540, 1925, 1925, 1540, 770, 1540, 1925, 1925, - 1540, 770, 1540, 1925, 1925, 1540, 770, 1540, 1925, 1925, 1540, - 770, 1540, 1925, 1925, 1540, 770, 1540, 1925, 1925, 1540, 770, - 1540, 1925, 1925, 1540, 770, 1540, 1925, 1925, 1540, 770, 1540, - 1925, 1925, 1540, 770, 1540, 1925, 1925, 1540, 770, 1540, 1925, - 1925, 1540, 770, 1536, 1917, 1913, 1524, 770, 1536, 1917, 1913, - 1524, 770, 1536, 1917, 1913, 1524, 770, 1536, 1917, 1913, 1524, - 770, 1536, 1917, 1913, 1524, 770, 1536, 1917, 1913, 1524, 770, - 1536, 1917, 1913, 1524, 770, 1536, 1917, 1913, 1524, 770, 1536, - 1917, 1913, 1524, 770, 1536, 1917, 1913, 1524, 770, 1536, 1917, - 1913, 1524, 770, 1536, 1917, 1913, 1524, 770, 1536, 1917, 1913, - 1524, 767, 1534, 1916, 1913, 1540, 767, 1534, 1916, 1913, 1540, - 767, 1534, 1916, 1913, 1540, 767, 1534, 1916, 1913, 1540, 767, - 1534, 1916, 1913, 1540, 767, 1534, 1916, 1913, 1540, 767, 1534, - 1916, 1913, 1540, 767, 1534, 1916, 1913, 1540, 767, 1534, 1916, - 1913, 1540, 767, 1534, 1916, 1913, 1540, 767, 1534, 1916, 1913, - 1540, 767, 1534, 1916, 1913, 1540, 767, 1534, 1916, 1913, 1538, - 766, 1534, 1917, 1925, 1538, 766, 1534, 1917, 1925, 1538, 766, - 1534, 1917, 1925, 1538, 766, 1534, 1917, 1925, 1538, 766, 1534, - 1917, 1925, 1538, 766, 1534, 1917, 1925, 1538, 766, 1534, 1917, - 1925, 1538, 766, 1534, 1917, 1925, 1538, 766, 1534, 1917, 1925, - 1538, 766, 1534, 1917, 1925, 1538, 766, 1534, 1917, 1925, 1538, - 766, 1534, 1917, 1925, 1538, 766, 1534, 1917, 1924, 1538, 767, - 1536, 1925, 1924, 1538, 767, 1536, 1925, 1924, 1538, 767, 1536, - 1925, 1924, 1538, 767, 1536, 1925, 1924, 1538, 767, 1536, 1925, - 1924, 1538, 767, 1536, 1925, 1924, 1538, 767, 1536, 1925, 1924, - 1538, 767, 1536, 1925, 1924, 1538, 767, 1536, 1925, 1924, 1538, - 767, 1536, 1925, 1924, 1538, 767, 1536, 1925, 1924, 1538, 767, - 1536, 1925, 1924, 1538, 767, 1536, 1284, 1287, 1020, 513, 1026, - 1284, 1287, 1020, 513, 1026, 1284, 1287, 1020, 513, 1026, 1284, - 1287, 1020, 513, 1026, 1284, 1287, 1020, 513, 1026, 1284, 1287, - 1020, 513, 1026, 1284, 1287, 1020, 513, 1026, 1284, 1287, 1020, - 513, 1026, 1284, 1287, 1020, 513, 1026, 1284, 1287, 1020, 513, - 1026, 1284, 1287, 1020, 513, 1026, 1284, 1287, 1020, 513, 1026, - 1284, 1287, 1020, 513 - ])); - }); -}); diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/depthwise_conv2d_webgpu_test.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/depthwise_conv2d_webgpu_test.ts deleted file mode 100644 index 2f20699d7..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/depthwise_conv2d_webgpu_test.ts +++ /dev/null @@ -1,101 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '@tensorflow/tfjs-core'; -import {test_util} from '@tensorflow/tfjs-core'; -import {describeWebGPU} from '../test_util'; - -const expectArraysClose = test_util.expectArraysClose; - -describeWebGPU('depthwise conv2d nchw', () => { - it('input=1x1x3x3,f=2,s=1,d=1,p=valid,chMul=1', async () => { - const fSize = 2; - const pad = 'valid'; - const stride = 1; - const chMul = 1; - const inDepth = 1; - - const x = tf.tensor4d([0, 1, 2, 3, 4, 5, 6, 7, 8], [1, inDepth, 3, 3]); - const w = tf.tensor4d( - [2, 3, 4, 5], - [fSize, fSize, inDepth, chMul], - ); - - const result = tf.depthwiseConv2d(x, w, stride, pad, 'NCHW'); - expect(result.shape).toEqual([1, 1, 2, 2]); - const expected = [35, 49, 77, 91]; - const resValue = await result.data(); - expectArraysClose(resValue, expected); - }); - - it('input=1x1x3x3,f=2,s=1,d=2,p=valid,chMul=1', async () => { - const fSize = 2; - const pad = 'valid'; - const stride = 1; - const chMul = 1; - const inDepth = 2; - - const x = tf.tensor4d( - [0, 1, 2, 3, 4, 5, 6, 7, 8, 2, 4, 6, 8, 0, 1, 3, 5, 7], - [1, inDepth, 3, 3]); - const w = tf.tensor4d( - [2, 6, 3, 7, 4, 8, 5, 9], - [fSize, fSize, inDepth, chMul], - ); - - const result = tf.depthwiseConv2d(x, w, stride, pad, 'NCHW'); - expect(result.shape).toEqual([1, 2, 2, 2]); - const expected = [35, 49, 77, 91, 104, 75, 117, 110]; - const resValue = await result.data(); - expectArraysClose(resValue, expected); - }); - - it('input=1x1x5x5,f=5,s=1,d=2,p=same,chMul=1', async () => { - const fSize = 5; - const pad = 'same'; - const stride = 1; - const chMul = 1; - const inDepth = 2; - - const x = tf.tensor4d( - [ - 0, 1, 2, 3, 4, 5, 6, 7, 8, 0, 1, 2, 3, 4, 5, 6, 7, - 8, 0, 1, 2, 3, 4, 5, 6, 4, 5, 6, 7, 8, 0, 1, 2, 3, - 4, 5, 6, 0, 1, 2, 3, 4, 5, 6, 7, 8, 0, 1, 2, 3 - ], - [1, inDepth, 5, 5]); - const w = tf.tensor4d( - [ - 3, 2, 1, 0, 3, 2, 1, 0, 4, 5, 3, 2, 1, 0, 3, 4, 2, - 1, 0, 5, 4, 3, 2, 1, 0, 0, 3, 4, 2, 1, 0, 5, 4, 3, - 2, 1, 0, 3, 2, 1, 0, 3, 2, 1, 0, 4, 5, 3, 2, 1 - ], - [fSize, fSize, inDepth, chMul], - ); - - const result = tf.depthwiseConv2d(x, w, stride, pad, 'NCHW'); - expect(result.shape).toEqual([1, 2, 5, 5]); - const resValue = await result.data(); - const expected = [ - 47, 85, 91, 95, 54, 93, 122, 109, 101, 91, 99, 145, 203, - 166, 82, 105, 135, 144, 153, 121, 66, 95, 128, 95, 81, 69, - 75, 97, 107, 57, 109, 134, 202, 166, 107, 126, 119, 212, 148, - 116, 66, 104, 139, 85, 55, 52, 82, 122, 66, 47 - ]; - expectArraysClose(resValue, expected); - }); -}); diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/pool_webgpu_test.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/pool_webgpu_test.ts deleted file mode 100644 index 7dc3b7a3f..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/pool_webgpu_test.ts +++ /dev/null @@ -1,44 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '@tensorflow/tfjs-core'; -import {test_util} from '@tensorflow/tfjs-core'; -import {describeWebGPU} from '../test_util'; - -const expectArraysClose = test_util.expectArraysClose; - -describeWebGPU('pool', () => { - // For PoolWithFilterSizeEqualsOneProgram. This case will fail wasm, so keep - // it here. Wasm bug: https://github.com/tensorflow/tfjs/issues/5471. - // TODO(xing.xu): https://github.com/tensorflow/tfjs/issues/5506. - it('x=[4,4,1] f=[1,1] s=2 d=1', async () => { - // Feed forward. - const a = tf.tensor3d( - [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], [4, 4, 1]); - - const windowShape = 1; - const padding = 0; - const dilationRate: number = undefined; - const strides = 2; - - const result = - tf.pool(a, windowShape, 'avg', padding, dilationRate, strides); - - expect(result.shape).toEqual([2, 2, 1]); - expectArraysClose(await result.data(), [0, 2, 8, 10]); - }); -}); diff --git a/tfjs-master/tfjs-backend-webgpu/src/kernels/precision_webgpu_test.ts b/tfjs-master/tfjs-backend-webgpu/src/kernels/precision_webgpu_test.ts deleted file mode 100644 index 9c9eacfd5..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/kernels/precision_webgpu_test.ts +++ /dev/null @@ -1,50 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '@tensorflow/tfjs-core'; -import {test_util} from '@tensorflow/tfjs-core'; -import {describeWebGPU} from '../test_util'; - -const expectArraysClose = test_util.expectArraysClose; - -describeWebGPU('precision', () => { - it('float precision', async () => { - const batch = 262145; - const size = batch * 4 * 4 * 4; - - const aData = new Float32Array(size); - const bData = new Float32Array(size / 4); - for (let i = 0; i < size; i++) { - aData[i] = i - 100; - if (i % 4 === 0) { - const iB = i / 4; - bData[iB] = iB - 100; - } - } - - const aTensor = tf.tensor4d(aData, [batch, 4, 4, 4]); - const bTensor = tf.tensor4d(bData, [batch, 4, 4, 1]); - - const gpuData = await tf.add(aTensor, bTensor).data(); - const expected = [ - 20971312, 20971312, 20971316, 20971316, 20971316, 20971318, 20971320, - 20971320, 20971322, 20971324, 20971324, 20971326, 20971328, 20971328, - 20971330, 20971332, 20971332, 20971332, 20971336, 20971336 - ]; - expectArraysClose(Array.from(gpuData).slice(16777210, 16777230), expected); - }); -}); diff --git a/tfjs-master/tfjs-backend-webgpu/src/lin_space_webgpu.ts b/tfjs-master/tfjs-backend-webgpu/src/lin_space_webgpu.ts deleted file mode 100644 index 07668c2b4..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/lin_space_webgpu.ts +++ /dev/null @@ -1,50 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {getMainHeaderString as main, WebGPUProgram} from './webgpu_program'; -import {computeDispatch, flatDispatchLayout} from './webgpu_util'; - -export class LinSpaceProgram implements WebGPUProgram { - variableNames: string[] = []; - outputShape: number[] = []; - shaderKey: string; - dispatchLayout: {x: number[]}; - dispatch: [number, number, number]; - uniforms = 'start : f32, step : f32,'; - workgroupSize: [number, number, number] = [64, 1, 1]; - size = true; - - constructor(shape: number) { - this.outputShape = [shape]; - this.dispatchLayout = flatDispatchLayout(this.outputShape); - this.dispatch = computeDispatch( - this.dispatchLayout, this.outputShape, this.workgroupSize); - - this.shaderKey = 'linSpace'; - } - - getUserCode(): string { - const userCode = ` - ${main('index')} { - if (index < uniforms.size) { - setOutputAtIndex(index, uniforms.start + f32(index) * uniforms.step); - } - } - `; - return userCode; - } -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/lrn_grad_webgpu.ts b/tfjs-master/tfjs-backend-webgpu/src/lrn_grad_webgpu.ts deleted file mode 100644 index b065477f5..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/lrn_grad_webgpu.ts +++ /dev/null @@ -1,93 +0,0 @@ -/** - * @license - * Copyright 2023 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {getMainHeaderString as main, WebGPUProgram} from './webgpu_program'; -import {computeDispatch, flatDispatchLayout} from './webgpu_util'; - -export class LRNGradProgram implements WebGPUProgram { - outputShape: number[] = []; - shaderKey: string; - dispatchLayout: {x: number[]}; - dispatch: [number, number, number]; - variableNames = ['inputImage', 'outputImage', 'dy']; - uniforms = 'depthRadius : i32, bias : f32, alpha : f32, beta : f32,'; - workgroupSize: [number, number, number] = [64, 1, 1]; - size = true; - - constructor(inputShape: number[]) { - this.outputShape = inputShape; - this.dispatchLayout = flatDispatchLayout(this.outputShape); - this.dispatch = computeDispatch( - this.dispatchLayout, this.outputShape, this.workgroupSize); - this.shaderKey = 'lrn_grad'; - } - - getUserCode(): string { - const userCode = ` - ${main('index')} { - if (index < uniforms.size) { - let coords = getOutputCoords(); - let b = coords[0]; - let r = coords[1]; - let c = coords[2]; - - let MIN_DEPTH_BEGIN = 0; - let MAX_DEPTH_END = uniforms.outShape[3]; - var result = 0.0; - for (var d = MIN_DEPTH_BEGIN; d < MAX_DEPTH_END; d++) { - let depthBegin = max(MIN_DEPTH_BEGIN, d - uniforms.depthRadius); - let depthEnd = min(MAX_DEPTH_END, d + uniforms.depthRadius + 1); - - var norm = 0.0; - for (var k = MIN_DEPTH_BEGIN; k < MAX_DEPTH_END; k++) { - if (k < depthBegin) { - continue; - } else if (k >= depthBegin && k < depthEnd) { - norm += getInputImage(b, r, c, k) * getInputImage(b, r, c, k); - } else { - break; - } - } - - norm = uniforms.alpha * norm + uniforms.bias; - - for (var k = MIN_DEPTH_BEGIN; k < MAX_DEPTH_END; k++) { - if (k < depthBegin) { - continue; - } else if (k >= depthBegin && k < depthEnd) { - var dyi = -2.0 * uniforms.alpha * uniforms.beta - * getInputImage(b, r, c, k) * getOutputImage(b, r, c, d) / norm; - if (k == d) { - dyi += pow(norm, -1.0 * uniforms.beta); - } - if (k == coords[3]) { - dyi *= getDy(b, r, c, d); - result += dyi; - } - } else { - break; - } - } - } - - setOutputAtIndex(index, result); - } - } - `; - return userCode; - } -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/lrn_webgpu.ts b/tfjs-master/tfjs-backend-webgpu/src/lrn_webgpu.ts deleted file mode 100644 index 75773872d..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/lrn_webgpu.ts +++ /dev/null @@ -1,146 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {util} from '@tensorflow/tfjs-core'; -import {getMainHeaderString as main, WebGPUProgram} from './webgpu_program'; -import {computeDispatch, flatDispatchLayout} from './webgpu_util'; - -const powOperatorSnippet = ` - var powValue = 0.0; - let basis = uniforms.bias + uniforms.alpha * sum; - if (uniforms.beta == 0.5) { - powValue = inverseSqrt(basis); - } else if (uniforms.beta == 1.0) { - powValue = 1.0 / basis; - } else { - powValue = exp(log(basis) * (-uniforms.beta)); - } -`; - -export class LRNProgram implements WebGPUProgram { - outputShape: number[] = []; - shaderKey: string; - dispatchLayout: {x: number[]}; - dispatch: [number, number, number]; - variableNames = ['x']; - uniforms = 'radius : i32, bias : f32, alpha : f32, beta : f32,'; - workgroupSize: [number, number, number] = [64, 1, 1]; - size = true; - - constructor(xShape: number[]) { - this.outputShape = xShape; - this.dispatchLayout = flatDispatchLayout(this.outputShape); - this.dispatch = computeDispatch( - this.dispatchLayout, this.outputShape, this.workgroupSize); - this.shaderKey = 'lrn'; - } - - getUserCode(): string { - const userCode = ` - ${main('index')} { - if (index < uniforms.size) { - let coords = getOutputCoords(); - let b = coords[0]; - let r = coords[1]; - let c = coords[2]; - let d = coords[3]; - - let x = getX(b, r, c, d); - var sum = 0.0; - for (var i = -uniforms.radius; i <= uniforms.radius; i = i + 1) { - let idx = d + i; - if (idx >= 0 && idx < uniforms.xShape[3]) { - let z = getX(b, r, c, idx); - sum = sum + z * z; - } - } - ${powOperatorSnippet} - - setOutputAtIndex(index, x * powValue); - } - } - `; - return userCode; - } -} - -export class LRNSharedProgram implements WebGPUProgram { - outputShape: number[] = []; - shaderKey: string; - dispatchLayout: {x: number[], y: number[], z: number[]}; - dispatch: [number, number, number]; - variableNames = ['x']; - uniforms = 'radius : i32, bias : f32, alpha : f32, beta : f32,'; - workgroupSize: [number, number, number] = [256, 1, 1]; - maxAllowRadius = 16; - elementsPerWorkgroup: number; - - constructor(xShape: number[], radius: number) { - util.assert( - radius <= this.maxAllowRadius, - () => `Radius must be less than or equal to ${ - this.maxAllowRadius}, current radius is ${radius}`); - - this.outputShape = xShape; - // The reason why not using this.workgroupSize[0] + 2 * maxAllowRadius here - // is to make sure that there is only one time global memory load access for - // each thread. - this.elementsPerWorkgroup = this.workgroupSize[0] - 2 * this.maxAllowRadius; - this.dispatchLayout = {x: [3], y: [2], z: [0, 1]}; - this.dispatch = computeDispatch(this.dispatchLayout, this.outputShape, [ - this.elementsPerWorkgroup, this.workgroupSize[1], this.workgroupSize[2] - ]); - this.shaderKey = 'lrn_shared'; - } - - getUserCode(): string { - const userCode = ` - var lrnSub: array; - const elementsPerWorkgroup = ${this.elementsPerWorkgroup}; - const maxAllowRadius = ${this.maxAllowRadius}; - - ${main()} { - let localDepth = i32(localId.x); - let workgroupDepth = i32(workgroupId.x) * elementsPerWorkgroup; - let xDepth = workgroupDepth + localDepth - maxAllowRadius; - let b = i32(globalId.z) / uniforms.xShape[1]; - let r = i32(globalId.z) - b * uniforms.xShape[1]; - let c = i32(globalId.y); - let d = workgroupDepth + localDepth; - - var x = 0.0; - if (xDepth >= 0 && xDepth < uniforms.xShape[3]) { - x = getX(b, r, c, xDepth); - } - lrnSub[localDepth] = x; - workgroupBarrier(); - - if (localDepth < elementsPerWorkgroup && d < uniforms.outShape[3]) { - var sum = 0.0; - let index = localDepth + maxAllowRadius; - for (var i = -uniforms.radius; i <= uniforms.radius; i = i + 1) { - let z = lrnSub[index + i]; - sum = sum + z * z; - } - ${powOperatorSnippet} - - setOutputAtCoords(b, r, c, d, lrnSub[index] * powValue); - } - } `; - return userCode; - } -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/matmul_packed_webgpu.ts b/tfjs-master/tfjs-backend-webgpu/src/matmul_packed_webgpu.ts deleted file mode 100644 index bfcf25bc3..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/matmul_packed_webgpu.ts +++ /dev/null @@ -1,600 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, TensorInfo, util} from '@tensorflow/tfjs-core'; - -import {activationFnSnippet, biasActivationSnippet} from './activation_util'; -import {getMainHeaderString as main, typeSnippet, WebGPUProgram} from './webgpu_program'; -import {computeDispatch, computeWorkgroupInfoForMatMul} from './webgpu_util'; - -export function matMulReadFnSource( - transposeA: boolean, transposeB: boolean, fitAOuter = false, - fitBOuter = false, fitInner = false, component = 1) { - util.assert( - transposeA && component === 1 || !transposeA, - () => `transposeA ${transposeA} is not compatible with component size ${ - component}`); - const sampleA = ` - ${ - transposeA ? `value = getA(batch, col, row);` : - `value = getA(batch, row, col);`} - - `; - const sampleB = transposeB ? `value = getB(batch, col, row);` : - `value = getB(batch, row, col);`; - - return ` - fn mm_readA(batch: i32, row: i32, col: i32) -> ${typeSnippet(component)} { - var value = ${typeSnippet(component)}(0.0); - ${ - fitAOuter && fitInner ? - sampleA : - ` - ${ - transposeA ? - `if(row < uniforms.dimAOuter && col < uniforms.dimInner)` : - `if(row < uniforms.aShape[1] && col < uniforms.aShape[2])`} - { - ${sampleA} - } - `} - return value; - } - - fn mm_readB(batch: i32, row: i32, col: i32) -> ${typeSnippet(component)} { - var value = ${typeSnippet(component)}(0.0); - ${sampleB} - return value; - } - `; -} - -export function matMulReadWriteFnSource( - hasBias: boolean, activation: backend_util.Activation, transposeA: boolean, - transposeB: boolean, fitAOuter = false, fitBOuter = false, fitInner = false, - component = 1) { - return ` - ${ - matMulReadFnSource( - transposeA, transposeB, fitAOuter, fitBOuter, fitInner, component)} - fn mm_write(batch: i32, row: i32, col: i32, valueIn: ${ - typeSnippet(component)}) { - ${ - fitAOuter && fitBOuter ? - '' : - 'if (row < uniforms.dimAOuter && col < uniforms.dimBOuter)'} - { - var value = valueIn; - let coords = vec3(batch, row, col); - ${biasActivationSnippet(hasBias, activation)} - setOutputAtCoords(coords[0], coords[1], coords[2], value); - } - } - `; -} - -const writeDataToSubAVec4Snippet = - (transpose: boolean, innerElementSize: number) => { - if (transpose) { - return ` - mm_Asub[inputRow][inputCol] = mm_readA(batchA, - kStart + inputRow, - globalRowStart + inputCol * ${innerElementSize}); - `; - - } else { - return ` - mm_Asub[inputRow][inputCol] = mm_readA(batchA, - globalRow + innerRow, - kStart + inputCol * ${innerElementSize}); - `; - } - }; - -const calculateResultSnippet = - (transposeA: boolean, innerElementSize: number, rowPerThread: number, - tileInner: number) => { - if (transposeA) { - return ` - for (var k = 0; k < ${tileInner}; k++) { - let BCached0 = mm_Bsub[k][tileCol]; - let ACached0 = mm_Asub[k][localRow]; - for (var i = 0; i < ${rowPerThread}; i++) { - acc[i] = fma(BCached0, vec4(ACached0[i]), acc[i]); - } - }`; - } else { - let bCachedStr = ''; - let accStr = ''; - for (let i = 0; i < innerElementSize; i++) { - bCachedStr += `let BCached${i} = mm_Bsub[k * ${innerElementSize} + ${ - i}][tileCol];`; - accStr += - `acc[i] = fma(BCached${i}, vec4(ACached[${i}]), acc[i]);`; - } - return ` - for (var k = 0; k < ${tileInner / innerElementSize}; k++) { - ${bCachedStr} - for (var i = 0; i < ${rowPerThread}; i++) { - let ACached = mm_Asub[tileRow + i][k]; - ${accStr} - } - }`; - } - }; - -export function makeMatMulPackedVec4Source( - workPerThread: number[], workgroupSize: [number, number, number], - transposeA = false, tileInner = 32, splitK = false, splitedDimInner = 32, - broadcastBatch = false): string { - const tileAOuter = workgroupSize[1] * workPerThread[1]; - const tileBOuter = workgroupSize[0] * workPerThread[0]; - const tileAWidth = transposeA ? tileAOuter : tileInner; - const tileAHight = transposeA ? tileInner : tileAOuter; - const innerElementSize = tileAWidth / workgroupSize[0]; - const rowPerThreadB = tileInner / workgroupSize[1]; - const rowPerThread = workPerThread[1]; - const colPerThread = workPerThread[0]; - util.assert( - ((transposeA && innerElementSize === 4 && workPerThread[1] === 4) || - (!transposeA && (innerElementSize === 3 || innerElementSize === 4))) && - tileAWidth % workgroupSize[0] === 0 && - tileInner % workgroupSize[1] === 0 && workPerThread[0] === 4, - () => `If transposeA ${transposeA} is true, innerElementSize ${ - innerElementSize} and workPerThread[1] ${workPerThread[1]} must be 4. - Otherwise, innerElementSize ${innerElementSize} must be 3 or 4. - tileAWidth ${tileAWidth} must be divisible by workgroupSize[0]${ - workgroupSize[0]}. tileInner ${ - tileInner} must be divisible by workgroupSize[1] ${ - workgroupSize[1]}. colPerThread ${workPerThread[0]} must be 4.`); - return ` - var mm_Asub : array, ${ - tileAWidth / innerElementSize}>, ${tileAHight}>; - var mm_Bsub : array, ${ - tileBOuter / workPerThread[0]}>, ${tileInner}>; - - ${main()} { - let localRow = i32(localId.y); - let tileRow = localRow * ${rowPerThread}; - let tileCol = i32(localId.x); - - let globalRow = i32(globalId.y) * ${rowPerThread}; - let globalCol = i32(globalId.x) * ${colPerThread}; - let batch = ${splitK ? '0' : 'i32(globalId.z)'}; - let batchA = ${ - splitK || !broadcastBatch ? 'batch' : 'batch % uniforms.aShape[0]'}; - let batchB = ${ - splitK || !broadcastBatch ? 'batch' : 'batch % uniforms.bShape[0]'}; - let globalRowStart = i32(workgroupId.y) * ${tileAOuter}; - - let numTiles = ${ - splitK ? `${Math.ceil(splitedDimInner / tileInner)}` : - `(uniforms.dimInner - 1) / ${tileInner} + 1`}; - var kStart = ${splitK ? `i32(globalId.z) * ${splitedDimInner}` : '0'}; - - var acc: array, ${rowPerThread}>; - - // Loop over shared dimension. - let tileRowB = localRow * ${rowPerThreadB}; - for (var t = 0; t < numTiles; t++) { - // Load one tile of A into local memory. - for (var innerRow = 0; innerRow < ${rowPerThread}; innerRow++) { - let inputRow = tileRow + innerRow; - let inputCol = tileCol; - ${writeDataToSubAVec4Snippet(transposeA, innerElementSize)} - } - - // Load one tile of B into local memory. - for (var innerRow = 0; innerRow < ${rowPerThreadB}; innerRow++) { - let inputRow = tileRowB + innerRow; - let inputCol = tileCol; - mm_Bsub[inputRow][inputCol] = mm_readB(batchB, kStart + inputRow, globalCol); - } - kStart = kStart + ${tileInner}; - workgroupBarrier(); - - // Compute acc values for a single thread. - ${ - calculateResultSnippet( - transposeA, innerElementSize, rowPerThread, tileInner)} - workgroupBarrier(); - } - - for (var innerRow = 0; innerRow < ${rowPerThread}; innerRow++) { - mm_write(batch, globalRow + innerRow, globalCol, acc[innerRow]); - } - }`; -} - -const writeDataToSubASnippet = (transpose: boolean) => { - if (transpose) { - return ` - mm_Asub[inputRow][inputCol] = mm_readA(batchA, - kStart + inputRow, - globalRowStart + inputCol); - `; - - } else { - return ` - mm_Asub[inputRow][inputCol] = mm_readA(batchA, - globalRowStart + inputRow, - kStart + inputCol); - `; - } -}; - -const readDataFromSubASnippet = (transposeA: boolean) => { - return transposeA ? 'let ACached = mm_Asub[k][tileRow + innerRow];' : - - 'let ACached = mm_Asub[tileRow + innerRow][k];'; -}; - -// sequentialAccessByThreads means sequential data in memory is accessed by -// threads, instead of a single thread (default behavior). -export function makeMatMulPackedSource( - workPerThread: number[], workgroupSize: [number, number, number], - transposeA = false, tileInner = 32, splitK = false, splitedDimInner = 32, - sequentialAccessByThreads = false, broadcastBatch = false): string { - const tileAOuter = workPerThread[1] * workgroupSize[1]; - const tileBOuter = workPerThread[0] * workgroupSize[0]; - const tileAWidth = transposeA ? tileAOuter : tileInner; - const tileAHight = transposeA ? tileInner : tileAOuter; - util.assert( - tileAHight % workgroupSize[1] === 0 && - tileAWidth % workgroupSize[0] === 0 && - tileInner % workgroupSize[1] === 0, - () => `tileAHight ${tileAHight} must be divisible by workgroupSize[1]${ - workgroupSize[1]}, tileAWidth ${ - tileAWidth} must be divisible by workgroupSize[0]${ - workgroupSize[0]}, tileInner ${ - tileInner} must be divisible by workgroupSize[1]${workgroupSize[1]}`); - const rowPerThreadA = tileAHight / workgroupSize[1]; - const colPerThreadA = tileAWidth / workgroupSize[0]; - const rowPerThreadB = tileInner / workgroupSize[1]; - const rowPerThread = workPerThread[1]; - const colPerThread = workPerThread[0]; - const matmulSnippet = sequentialAccessByThreads ? - ` - let localRow = i32(localId.y); - let localCol = i32(localId.x); - let globalRowStart = i32(workgroupId.y) * ${tileAOuter}; - let globalColStart = i32(workgroupId.x) * ${tileBOuter}; - - // Loop over shared dimension. - for (var t = 0; t < numTiles; t++) { - // Load one tile of A into local memory. - for (var inputRow = localRow; inputRow < ${ - tileAHight}; inputRow = inputRow + ${workgroupSize[1]}) { - for (var inputCol = localCol; inputCol < ${ - tileAWidth}; inputCol = inputCol + ${workgroupSize[0]}) { - ${writeDataToSubASnippet(transposeA)} - } - } - // Load one tile of B into local memory. - for (var inputRow = localRow; inputRow < ${ - tileInner}; inputRow = inputRow + ${workgroupSize[1]}) { - for (var inputCol = localCol; inputCol < ${ - tileBOuter}; inputCol = inputCol + ${workgroupSize[0]}) { - mm_Bsub[inputRow][inputCol] = mm_readB(batchB, - kStart + inputRow, - globalColStart + inputCol); - } - } - kStart = kStart + ${tileInner}; - workgroupBarrier(); - - // Compute acc values for a single thread. - var BCached : array; - for (var k = 0; k < ${tileInner}; k++) { - for (var inner = 0; inner < ${colPerThread}; inner++) { - BCached[inner] = mm_Bsub[k][localCol + inner * ${workgroupSize[0]}]; - } - for (var innerRow = 0; innerRow < ${rowPerThread}; innerRow++) { - let ACached = ${ - transposeA ? - `mm_Asub[k][localRow + innerRow * ${workgroupSize[1]}];` : - `mm_Asub[localRow + innerRow * ${workgroupSize[1]}][k];`} - for (var innerCol = 0; innerCol < ${colPerThread}; innerCol++) { - acc[innerRow][innerCol] = - fma(ACached, BCached[innerCol], acc[innerRow][innerCol]); - } - } - } - workgroupBarrier(); - } - for (var innerRow = 0; innerRow < ${rowPerThread}; innerRow++) { - let gRow = globalRowStart + localRow + innerRow * ${workgroupSize[1]}; - for (var innerCol = 0; innerCol < ${colPerThread}; innerCol++) { - let gCol = globalColStart + localCol + innerCol * ${workgroupSize[0]}; - mm_write(batch, gRow, gCol, acc[innerRow][innerCol]); - } - } - ` : - ` - let tileRow = i32(localId.y) * ${rowPerThread}; - let tileCol = i32(localId.x) * ${colPerThread}; - - let globalRow = i32(globalId.y) * ${rowPerThread}; - let globalCol = i32(globalId.x) * ${colPerThread}; - let globalRowStart = i32(workgroupId.y) * ${tileAOuter}; - - let tileRowA = i32(localId.y) * ${rowPerThreadA}; - let tileColA = i32(localId.x) * ${colPerThreadA}; - let tileRowB = i32(localId.y) * ${rowPerThreadB}; - // Loop over shared dimension. - for (var t = 0; t < numTiles; t++) { - // Load one tile of A into local memory. - for (var innerRow = 0; innerRow < ${rowPerThreadA}; innerRow++) { - for (var innerCol = 0; innerCol < ${colPerThreadA}; innerCol++) { - let inputRow = tileRowA + innerRow; - let inputCol = tileColA + innerCol; - ${writeDataToSubASnippet(transposeA)} - } - } - - // Load one tile of B into local memory. - for (var innerRow = 0; innerRow < ${rowPerThreadB}; innerRow++) { - for (var innerCol = 0; innerCol < ${colPerThread}; innerCol++) { - let inputRow = tileRowB + innerRow; - let inputCol = tileCol + innerCol; - mm_Bsub[inputRow][inputCol] = mm_readB(batchB, - kStart + inputRow, - globalCol + innerCol); - } - } - kStart = kStart + ${tileInner}; - workgroupBarrier(); - - // Compute acc values for a single thread. - var BCached : array; - for (var k = 0; k < ${tileInner}; k++) { - for (var inner = 0; inner < ${colPerThread}; inner++) { - BCached[inner] = mm_Bsub[k][tileCol + inner]; - } - - for (var innerRow = 0; innerRow < ${rowPerThread}; innerRow++) { - ${readDataFromSubASnippet(transposeA)} - for (var innerCol = 0; innerCol < ${colPerThread}; innerCol++) { - acc[innerRow][innerCol] = - fma(ACached, BCached[innerCol], acc[innerRow][innerCol]); - } - } - } - - workgroupBarrier(); - } - - for (var innerRow = 0; innerRow < ${rowPerThread}; innerRow++) { - for (var innerCol = 0; innerCol < ${colPerThread}; innerCol++) { - mm_write(batch, globalRow + innerRow, globalCol + innerCol, - acc[innerRow][innerCol]); - } - } - `; - - return ` - var mm_Asub : array, ${tileAHight}>; - var mm_Bsub : array, ${tileInner}>; - - ${main()} { - let batch = ${splitK ? '0' : 'i32(globalId.z)'}; - let batchA = ${ - splitK || !broadcastBatch ? 'batch' : 'batch % uniforms.aShape[0]'}; - let batchB = ${ - splitK || !broadcastBatch ? 'batch' : 'batch % uniforms.bShape[0]'}; - let numTiles = ${ - splitK ? `${Math.ceil(splitedDimInner / tileInner)}` : - `(uniforms.dimInner - 1) / ${tileInner} + 1`}; - var kStart = ${splitK ? `i32(globalId.z) * ${splitedDimInner}` : '0'}; - - var acc : array, ${rowPerThread}>; - - // Without this initialization strange values show up in acc. - for (var innerRow = 0; innerRow < ${rowPerThread}; innerRow++) { - for (var innerCol = 0; innerCol < ${colPerThread}; innerCol++) { - acc[innerRow][innerCol] = 0.0; - } - } - ${matmulSnippet} - } - `; -} - -const readVectorASnippet = (transpose: boolean) => { - return transpose ? ` - mm_readA(batchA, colA, globalRow), - mm_readA(batchA, colA + 1, globalRow), - mm_readA(batchA, colA + 2, globalRow), - mm_readA(batchA, colA + 3, globalRow) - ` : - ` - mm_readA(batchA, globalRow, colA), - mm_readA(batchA, globalRow, colA + 1), - mm_readA(batchA, globalRow, colA + 2), - mm_readA(batchA, globalRow, colA + 3) - `; -}; - -export function makeVectorMatrixProductSource( - workgroupSize: [number, number, number], transposeA = false): string { - util.assert( - workgroupSize[1] === 1 && workgroupSize[2] === 1, - () => `A linear work group size is required. But got ${workgroupSize}.`); - const tileSize = workgroupSize[0] * 4; - return ` - var mm_Asub : array, ${workgroupSize[0]}>; - - ${main()} { - let tileCol = i32(localId.x); - let globalCol = i32(globalId.x); - let globalRow = i32(globalId.y); - - let numTiles = (uniforms.dimInner - 1) / ${tileSize} + 1; - let batch = i32(globalId.z); - let batchA = batch % uniforms.aShape[0]; - let batchB = batch % uniforms.bShape[0]; - // Without this initialization strange values show up in acc. - var acc = 0.0; - - // Loop over shared dimension. - for (var t = 0; t < numTiles; t++) { - // Load one tile of A into local memory. - let colA = t * ${tileSize} + tileCol * 4; - mm_Asub[tileCol] = vec4(${readVectorASnippet(transposeA)}); - workgroupBarrier(); - - // Compute acc values for a single thread. - for (var k = 0; k < ${tileSize / 4}; k++) { - let rowB = t * ${tileSize} + k * 4; - let BCached = vec4(mm_readB(batchB, rowB, globalCol), - mm_readB(batchB, rowB + 1, globalCol), - mm_readB(batchB, rowB + 2, globalCol), - mm_readB(batchB, rowB + 3, globalCol)); - - let ACached = mm_Asub[k]; - acc = acc + dot(ACached, BCached); - } - - workgroupBarrier(); - } - - mm_write(batch, globalRow, globalCol, acc); - } - `; -} - -export class MatMulPackedProgram implements WebGPUProgram { - outputShape: number[]; - shaderKey: string; - dispatchLayout: {x: number[], y: number[], z: number[]}; - dispatch: [number, number, number]; - variableNames = ['A', 'B']; - uniforms = `dimAOuter : i32, dimBOuter : i32, dimInner : i32,`; - workgroupSize: [number, number, number]; - elementsPerThread: [number, number, number]; - transposeA: boolean; - transposeB: boolean; - addBias: boolean; - activation: backend_util.Activation; - hasPreluActivationWeights: boolean; - fitAOuter: boolean; - fitBOuter: boolean; - fitInner: boolean; - tileInner: number; - isVectorA: boolean; - isVec4: boolean; - outputComponent: number; - private sequentialAccessByThreads: boolean; - - constructor( - aShape: [number, number, number], outputShape: [number, number, number], - transposeA = false, transposeB = false, bias: TensorInfo = null, - activation: backend_util.Activation = null, - preluActivationWeights: TensorInfo = null, - sequentialAccessByThreads = false) { - this.outputShape = outputShape; - this.dispatchLayout = {x: [2], y: [1], z: [0]}; - const dimInner = transposeA ? aShape[1] : aShape[2]; - this.isVec4 = ((dimInner % 4 === 0 && !transposeA) || - (outputShape[1] % 4 === 0 && transposeA)) && - outputShape[2] % 4 === 0 && !transposeB; - this.outputComponent = this.isVec4 ? 4 : 1; - this.isVectorA = outputShape[1] === 1 && !transposeA; - - if (!this.isVec4 && this.isVectorA) { - // For makeVectorMatrixProductSource - this.elementsPerThread = [1, 1, 1]; - this.workgroupSize = [32, 1, 1]; - } else { - const workgroupInfo = computeWorkgroupInfoForMatMul( - outputShape[1], dimInner, outputShape[2], transposeA); - this.workgroupSize = workgroupInfo.workgroupSize; - this.elementsPerThread = workgroupInfo.elementsPerThread; - } - - this.dispatch = computeDispatch( - this.dispatchLayout, this.outputShape, this.workgroupSize, - this.elementsPerThread); - - const addBias = bias != null; - const hasPreluActivationWeights = preluActivationWeights != null; - if (addBias) { - this.variableNames.push('bias'); - } - - if (hasPreluActivationWeights) { - this.variableNames.push('preluActivationWeights'); - } - - this.sequentialAccessByThreads = sequentialAccessByThreads; - this.transposeA = transposeA; - this.transposeB = transposeB; - this.addBias = addBias; - this.activation = activation; - this.hasPreluActivationWeights = hasPreluActivationWeights; - [this.fitAOuter, this.fitBOuter, this.fitInner] = - this.getShapeFit(outputShape[1], outputShape[2], dimInner); - this.shaderKey = `matMulPacked_${this.elementsPerThread}_${transposeA}_${ - transposeB}_${this.activation}_${this.fitAOuter}_${this.fitBOuter}_${ - this.fitInner}_${this.isVec4}_${this.isVectorA}_${ - this.sequentialAccessByThreads}`; - } - - getShapeFit(dimAOuter: number, dimBOuter: number, dimInner: number): - boolean[] { - const tileAOuter = this.workgroupSize[1] * this.elementsPerThread[1]; - const tileBOuter = this.workgroupSize[0] * this.elementsPerThread[0]; - - if (!this.isVec4 && this.isVectorA) { - // For makeVectorMatrixProductSource - this.tileInner = this.workgroupSize[0] * 4; - } else { - this.tileInner = tileBOuter; - } - - const fitAOuter = dimAOuter % tileAOuter === 0; - const fitBOuter = dimBOuter % tileBOuter === 0; - const fitInner = dimInner % this.tileInner === 0; - return [fitAOuter, fitBOuter, fitInner]; - } - - getUserCode(): string { - const userCode = ` - ${ - activationFnSnippet( - this.activation, this.hasPreluActivationWeights, this.isVec4)} - ${ - matMulReadWriteFnSource( - this.addBias, this.activation, - false /* transposeA is implemented in makeMatMulPackedSource */, - this.transposeB, this.fitAOuter, this.fitBOuter, this.fitInner, - this.isVec4 ? 4 : 1)} - ${ - this.isVec4 ? - makeMatMulPackedVec4Source( - this.elementsPerThread, this.workgroupSize, this.transposeA, - this.tileInner, false, null, true) : - (this.isVectorA ? makeVectorMatrixProductSource( - this.workgroupSize, this.transposeA) : - makeMatMulPackedSource( - this.elementsPerThread, this.workgroupSize, - this.transposeA, this.tileInner, false, null, - this.sequentialAccessByThreads, true))} - `; - return userCode; - } -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/matmul_reduce_webgpu.ts b/tfjs-master/tfjs-backend-webgpu/src/matmul_reduce_webgpu.ts deleted file mode 100644 index 7392ef353..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/matmul_reduce_webgpu.ts +++ /dev/null @@ -1,115 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, TensorInfo} from '@tensorflow/tfjs-core'; - -import {activationFnSnippet} from './activation_util'; -import {matMulReadWriteFnSource} from './matmul_packed_webgpu'; -import {getMainHeaderString as main, WebGPUProgram} from './webgpu_program'; -import {computeDispatch} from './webgpu_util'; - -export function makeMatMulReduceSource(workgroupSizeX: number): string { - return ` - var sumValues : array; - ${main()} { - let coords = getOutputCoords(); - let batch = coords[0]; - let batchA = batch % uniforms.aShape[0]; - let batchB = batch % uniforms.bShape[0]; - let row = coords[1]; - let col = coords[2]; - var sum = 0.0; - let Length = uniforms.dimInner; - for (var k = i32(localId.x); k < Length; k = k + ${workgroupSizeX}) { - let dataA = mm_readA(batchA, row, k); - let dataB = mm_readB(batchB, k, col); - sum = sum + dataA * dataB; - } - sumValues[localId.x] = sum; - workgroupBarrier(); - - for(var currentSize = ${workgroupSizeX / 2}u; currentSize > 1u; - currentSize = currentSize / 2u) { - if (localId.x < currentSize) - { - sumValues[localId.x] = sumValues[localId.x] + sumValues[localId.x + currentSize]; - } - workgroupBarrier(); - } - - if (localId.x == 0u) { - sum = sumValues[0] + sumValues[1]; - mm_write(batch, row, col, sum); - } - } - `; -} - -export class MatMulReduceProgram implements WebGPUProgram { - outputShape: number[]; - shaderKey: string; - dispatchLayout: {x: number[], y: number[], z: number[]}; - dispatch: [number, number, number]; - variableNames = ['A', 'B']; - uniforms = `dimAOuter : i32, dimBOuter : i32, dimInner : i32,`; - workgroupSize: [number, number, number] = [256, 1, 1]; - transposeA: boolean; - transposeB: boolean; - addBias: boolean; - activation: backend_util.Activation; - hasPreluActivationWeights: boolean; - - constructor( - outputShape: [number, number, number], transposeA = false, - transposeB = false, bias: TensorInfo = null, - activation: backend_util.Activation = null, - preluActivationWeights: TensorInfo = null) { - this.outputShape = outputShape; - this.dispatchLayout = {x: [], y: [1, 2], z: [0]}; - this.dispatch = computeDispatch( - this.dispatchLayout, this.outputShape, this.workgroupSize); - - const addBias = bias != null; - const hasPreluActivationWeights = preluActivationWeights != null; - if (addBias) { - this.variableNames.push('bias'); - } - - if (hasPreluActivationWeights) { - this.variableNames.push('preluActivationWeights'); - } - - this.transposeA = transposeA; - this.transposeB = transposeB; - this.addBias = addBias; - this.activation = activation; - this.hasPreluActivationWeights = hasPreluActivationWeights; - this.shaderKey = - `matMulReduce_${this.activation}_${transposeA}_${transposeB}`; - } - - getUserCode(): string { - const userCode = ` - ${activationFnSnippet(this.activation, this.hasPreluActivationWeights)} - ${ - matMulReadWriteFnSource( - this.addBias, this.activation, this.transposeA, this.transposeB)} - ${makeMatMulReduceSource(this.workgroupSize[0])} - `; - return userCode; - } -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/matmul_small_output_size_webgpu.ts b/tfjs-master/tfjs-backend-webgpu/src/matmul_small_output_size_webgpu.ts deleted file mode 100644 index 5aae1d45f..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/matmul_small_output_size_webgpu.ts +++ /dev/null @@ -1,140 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, TensorInfo} from '@tensorflow/tfjs-core'; -import {activationFnSnippet} from './activation_util'; -import {matMulReadWriteFnSource} from './matmul_packed_webgpu'; -import {getMainHeaderString as main, WebGPUProgram} from './webgpu_program'; - -export function makeMatMulSmallOutputSizeSource( - workgroupSize: [number, number, number]): string { - const tileAOuter = workgroupSize[1]; - const tileBOuter = workgroupSize[0]; - const tileInner = tileAOuter > tileBOuter ? tileAOuter : tileBOuter; - return ` - var mm_Asub : array, ${tileAOuter}>; - var mm_Bsub : array, ${tileInner}>; - - // If the output size is small for matrix multiplication, avoid to use vec4 - // and handle some elements per thread to optimally utilize the ALU. - // Read data from global memory to registers firstly, then store them into - // shared memory, so it is instruction-Level parallelism for arithmetic - // operations and others handle IO operations between barrier api, makes ALU - // and load/store units work simultaneously, could improves the performance. - ${main()} { - let tileRow = i32(localId.y); - let tileCol = i32(localId.x); - let globalRow = i32(globalId.y); - let globalCol = i32(globalId.x); - let batch = i32(globalId.z); - let batchA = batch % uniforms.aShape[0]; - let batchB = batch % uniforms.bShape[0]; - - // uniforms.dimInner should be greater than 0. - let numTiles = (uniforms.dimInner - 1) / ${tileInner} + 1; - var acc = 0.0; - - var globalColA = tileCol; - var globalRowB = 0; - var regA = mm_readA(batchA, globalRow, globalColA); - var regB0 = mm_readB(batchB, globalRowB + 2 * tileRow, globalCol); - var regB1 = mm_readB(batchB, globalRowB + 2 * tileRow + 1, globalCol); - globalColA = globalColA + ${tileInner}; - globalRowB = globalRowB + ${tileInner}; - - for (var t = 0; t < numTiles; t = t + 1) { - mm_Asub[tileRow][tileCol] = regA; - mm_Bsub[2 * tileRow][tileCol] = regB0; - mm_Bsub[2 * tileRow + 1][tileCol] = regB1; - - workgroupBarrier(); - - regA = mm_readA(batchA, globalRow, globalColA); - regB0 = mm_readB(batchB, globalRowB + 2 * tileRow, globalCol); - regB1 = mm_readB(batchB, globalRowB + 2 * tileRow + 1, globalCol); - globalColA = globalColA + ${tileInner}; - globalRowB = globalRowB + ${tileInner}; - - for (var k = 0; k < ${tileInner}; k = k + 1) { - acc = acc + mm_Asub[tileRow][k] * mm_Bsub[k][tileCol]; - } - workgroupBarrier(); - } - - mm_write(batch, globalRow, globalCol, acc); - } - `; -} - -export class MatMulSmallOutputSizeProgram implements WebGPUProgram { - outputShape: number[]; - shaderKey: string; - dispatchLayout: {x: number[], y: number[], z: number[]}; - dispatch: [number, number, number]; - variableNames = ['A', 'B']; - uniforms = `dimAOuter : i32, dimBOuter : i32, dimInner : i32,`; - workgroupSize: [number, number, number] = [16, 8, 1]; - transposeA: boolean; - transposeB: boolean; - addBias: boolean; - activation: backend_util.Activation; - hasPreluActivationWeights: boolean; - - constructor( - aShape: [number, number, number], bShape: [number, number, number], - outputShape: [number, number, number], transposeA = false, - transposeB = false, bias: TensorInfo = null, - activation: backend_util.Activation = null, - preluActivationWeights: TensorInfo = null) { - this.outputShape = outputShape; - - this.dispatchLayout = {x: [2], y: [1], z: [0]}; - this.dispatch = [ - Math.ceil(outputShape[2] / this.workgroupSize[0]), - Math.ceil(outputShape[1] / this.workgroupSize[1]), outputShape[0] - ]; - - const addBias = bias != null; - if (addBias) { - this.variableNames.push('bias'); - } - - const hasPreluActivationWeights = preluActivationWeights != null; - if (hasPreluActivationWeights) { - this.variableNames.push('preluActivationWeights'); - } - - this.transposeA = transposeA; - this.transposeB = transposeB; - this.addBias = addBias; - this.activation = activation; - this.hasPreluActivationWeights = hasPreluActivationWeights; - this.shaderKey = - `matMulSmallOutputSize_${this.activation}_${transposeA}_${transposeB}`; - } - - getUserCode(): string { - const userCode = ` - ${activationFnSnippet(this.activation, this.hasPreluActivationWeights)} - ${ - matMulReadWriteFnSource( - this.addBias, this.activation, this.transposeA, this.transposeB)} - ${makeMatMulSmallOutputSizeSource(this.workgroupSize)} - `; - return userCode; - } -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/matmul_splitK_webgpu.ts b/tfjs-master/tfjs-backend-webgpu/src/matmul_splitK_webgpu.ts deleted file mode 100644 index 65d42ef81..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/matmul_splitK_webgpu.ts +++ /dev/null @@ -1,158 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, TensorInfo, util} from '@tensorflow/tfjs-core'; - -import {activationFnSnippet, biasActivationSnippet} from './activation_util'; -import {makeMatMulPackedSource, makeMatMulPackedVec4Source, matMulReadFnSource} from './matmul_packed_webgpu'; -import {atomicAddSnippet} from './shader_util'; -import {getMainHeaderString as main, typeSnippet, WebGPUProgram} from './webgpu_program'; -import {computeDispatch, flatDispatchLayout} from './webgpu_util'; - -export class MatMulSplitKProgram implements WebGPUProgram { - outputShape: number[]; - shaderKey: string; - dispatchLayout: {x: number[], y: number[], z: number[]}; - dispatch: [number, number, number]; - variableNames = ['A', 'B']; - uniforms = `dimAOuter : i32, dimBOuter : i32, dimInner : i32,`; - workgroupSize: [number, number, number] = [8, 8, 1]; - elementsPerThread: [number, number, number]; - transposeA: boolean; - transposeB: boolean; - atomic = true; - outputComponent: number; - splitedDimInner = 128; - - constructor( - outputShape: [number, number, number], dimInner: number, - transposeA = false, transposeB = false) { - util.assert( - outputShape[0] === 1, - () => 'MatMulSplitKProgram only supports batch = 1.'); - this.outputShape = outputShape; - this.dispatchLayout = {x: [2], y: [1], z: [0, 3]}; - const isVec4 = (transposeA && this.outputShape[1] % 4 === 0 || - !transposeA && dimInner % 4 === 0) && - this.outputShape[2] % 4 === 0; - this.elementsPerThread = [4, 4, this.splitedDimInner]; - this.outputComponent = isVec4 ? 4 : 1; - if (!isVec4) { - if (this.outputShape[1] < 16) { - this.elementsPerThread[1] = 1; - } - if (this.outputShape[2] < 16) { - this.elementsPerThread[0] = 1; - } - } - - this.dispatch = computeDispatch( - this.dispatchLayout, - [ - this.outputShape[0], this.outputShape[1], this.outputShape[2], - dimInner - ], - this.workgroupSize, this.elementsPerThread); - - this.transposeA = transposeA; - this.transposeB = transposeB; - this.shaderKey = `matMulSplitK_${transposeA}_${transposeB}_${ - this.elementsPerThread}_${this.outputComponent}`; - } - - getUserCode(): string { - const component = this.outputComponent; - const userCode = ` - ${ - matMulReadFnSource( - false, this.transposeB, false, false, false, component)} - fn mm_write(batch: i32, row : i32, col : i32, value : ${ - typeSnippet(component)}) { - if (row < uniforms.dimAOuter && col < uniforms.dimBOuter) { - let coords = vec3(batch, row, col); - let flatIndex = getOutputIndexFromCoords(coords); - // The problem is that we should initialize output to zero before using. - // Otherwise, the original value will be added to the result. - for (var i = 0; i < ${component}; i = i + 1) { - ${ - atomicAddSnippet( - '&result[flatIndex + i]', `${component > 1 ? 'value[i]' : 'value'}`, - 'float32')} - } - } - } - ${ - component === 4 ? makeMatMulPackedVec4Source( - this.elementsPerThread, this.workgroupSize, - this.transposeA, 32, true, this.splitedDimInner) : - makeMatMulPackedSource( - this.elementsPerThread, this.workgroupSize, - this.transposeA, 32, true, this.splitedDimInner)} - `; - return userCode; - } -} - -export class BiasActivationProgram implements WebGPUProgram { - outputShape: number[]; - shaderKey: string; - uniforms = ''; - dispatchLayout: {x: number[]}; - dispatch: [number, number, number]; - variableNames = ['x']; - workgroupSize: [number, number, number] = [64, 1, 1]; - size = true; - private addBias: boolean; - private activation: backend_util.Activation; - private hasPreluActivationWeights: boolean; - - constructor( - outputShape: number[], bias: TensorInfo = null, - activation: backend_util.Activation = null, - preluActivationWeights: TensorInfo = null) { - this.outputShape = outputShape; - this.dispatchLayout = flatDispatchLayout(this.outputShape); - this.dispatch = computeDispatch( - this.dispatchLayout, this.outputShape, this.workgroupSize); - this.addBias = bias != null; - this.hasPreluActivationWeights = preluActivationWeights != null; - this.activation = activation; - if (this.addBias) { - this.variableNames.push('bias'); - } - - if (this.hasPreluActivationWeights) { - this.variableNames.push('preluActivationWeights'); - } - - this.shaderKey = `biasActivation_${activation}`; - } - - getUserCode(): string { - return ` - ${activationFnSnippet(this.activation, this.hasPreluActivationWeights)} - ${main('index')} { - if (index < uniforms.size) { - let coords = getCoordsFromIndex(index); - var value = getXByOutputIndex(index); - ${biasActivationSnippet(this.addBias, this.activation)} - setOutputAtIndex(index, value); - } - } - `; - } -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/matmul_test.ts b/tfjs-master/tfjs-backend-webgpu/src/matmul_test.ts deleted file mode 100644 index ad7312af0..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/matmul_test.ts +++ /dev/null @@ -1,1971 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '@tensorflow/tfjs-core'; -import {test_util} from '@tensorflow/tfjs-core'; -// tslint:disable-next-line: no-imports-from-dist -import {ALL_ENVS, describeWithFlags} from '@tensorflow/tfjs-core/dist/jasmine_util'; - -import {MatMulProgramType} from './webgpu_util'; - -const {expectArraysClose} = test_util; -const MATMUL_SHARED_DIM_THRESHOLD = 1000; -function matmulTest(programType: MatMulProgramType) { - return () => { - let savedMatmulFlag = -1; - beforeAll(() => { - savedMatmulFlag = tf.env().get('WEBGPU_MATMUL_PROGRAM_TYPE') as number; - tf.env().set('WEBGPU_MATMUL_PROGRAM_TYPE', programType); - }); - afterAll(() => { - tf.env().set('WEBGPU_MATMUL_PROGRAM_TYPE', savedMatmulFlag); - }); - - it('it works in delayed mode.', async () => { - const savedFlag = tf.env().get('WEBGPU_DEFERRED_SUBMIT_BATCH_SIZE'); - tf.env().set('WEBGPU_DEFERRED_SUBMIT_BATCH_SIZE', 15); - const a = tf.tensor2d([1, 2, 3, 4], [2, 2]); - const b = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - - const c = tf.matMul(a, b); - - const f = tf.tensor2d([0, 1, 0.5, 0, 0.25, 2], [2, 3]); - const d = tf.mul(c, f); - - const dData = await d.data(); - test_util.expectArraysClose( - dData, new Float32Array([0, 12, 7.5, 0, 6.5, 66])); - tf.env().set('WEBGPU_DEFERRED_SUBMIT_BATCH_SIZE', savedFlag); - }); - - it('it works in immediate mode.', async () => { - const savedFlag = tf.env().get('WEBGPU_DEFERRED_SUBMIT_BATCH_SIZE'); - tf.env().set('WEBGPU_DEFERRED_SUBMIT_BATCH_SIZE', 1); - const a = tf.tensor2d([1, 2, 3, 4], [2, 2]); - const b = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - - const c = tf.matMul(a, b); - - const f = tf.tensor2d([0, 1, 0.5, 0, 0.25, 2], [2, 3]); - const d = tf.mul(c, f); - - const dData = await d.data(); - test_util.expectArraysClose( - dData, new Float32Array([0, 12, 7.5, 0, 6.5, 66])); - tf.env().set('WEBGPU_DEFERRED_SUBMIT_BATCH_SIZE', savedFlag); - }); - - // tslint:disable-next-line:max-line-length - it('matMul works when we do not check coords because tiles fit perfectly into input dimensions', - async () => { - const inputData = [ - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, - 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, - 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, - 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, - 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, - 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, - 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, - 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, - 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, - 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, - 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, - 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, - 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, - 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, - 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, - 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, - 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, - 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, - 252, 253, 254, 255 - ]; - const a = tf.tensor2d(inputData, [16, 16]); - const b = tf.tensor2d(inputData, [16, 16]); - const expected = new Float32Array([ - 19840, 19960, 20080, 20200, 20320, 20440, 20560, 20680, - 20800, 20920, 21040, 21160, 21280, 21400, 21520, 21640, - 50560, 50936, 51312, 51688, 52064, 52440, 52816, 53192, - 53568, 53944, 54320, 54696, 55072, 55448, 55824, 56200, - 81280, 81912, 82544, 83176, 83808, 84440, 85072, 85704, - 86336, 86968, 87600, 88232, 88864, 89496, 90128, 90760, - 112000, 112888, 113776, 114664, 115552, 116440, 117328, 118216, - 119104, 119992, 120880, 121768, 122656, 123544, 124432, 125320, - 142720, 143864, 145008, 146152, 147296, 148440, 149584, 150728, - 151872, 153016, 154160, 155304, 156448, 157592, 158736, 159880, - 173440, 174840, 176240, 177640, 179040, 180440, 181840, 183240, - 184640, 186040, 187440, 188840, 190240, 191640, 193040, 194440, - 204160, 205816, 207472, 209128, 210784, 212440, 214096, 215752, - 217408, 219064, 220720, 222376, 224032, 225688, 227344, 229000, - 234880, 236792, 238704, 240616, 242528, 244440, 246352, 248264, - 250176, 252088, 254000, 255912, 257824, 259736, 261648, 263560, - 265600, 267768, 269936, 272104, 274272, 276440, 278608, 280776, - 282944, 285112, 287280, 289448, 291616, 293784, 295952, 298120, - 296320, 298744, 301168, 303592, 306016, 308440, 310864, 313288, - 315712, 318136, 320560, 322984, 325408, 327832, 330256, 332680, - 327040, 329720, 332400, 335080, 337760, 340440, 343120, 345800, - 348480, 351160, 353840, 356520, 359200, 361880, 364560, 367240, - 357760, 360696, 363632, 366568, 369504, 372440, 375376, 378312, - 381248, 384184, 387120, 390056, 392992, 395928, 398864, 401800, - 388480, 391672, 394864, 398056, 401248, 404440, 407632, 410824, - 414016, 417208, 420400, 423592, 426784, 429976, 433168, 436360, - 419200, 422648, 426096, 429544, 432992, 436440, 439888, 443336, - 446784, 450232, 453680, 457128, 460576, 464024, 467472, 470920, - 449920, 453624, 457328, 461032, 464736, 468440, 472144, 475848, - 479552, 483256, 486960, 490664, 494368, 498072, 501776, 505480, - 480640, 484600, 488560, 492520, 496480, 500440, 504400, 508360, - 512320, 516280, 520240, 524200, 528160, 532120, 536080, 540040 - ]); - - const c = tf.matMul(a, b); - const cData = await c.data(); - test_util.expectArraysClose(cData, expected); - }); - - // TODO: Make this test much smaller by controlling tile size with a flag. - it('matMul A x B multiple tiles', async () => { - const a = tf.tensor2d( - [ - 2, 7, 5, 1, 5, 1, 3, 2, 8, 8, 2, 0, 0, 0, 4, 0, 8, 4, 0, 5, 4, 1, 4, - 4, 2, 4, 3, 4, 4, 7, 4, 5, 0, 1, 4, 5, 5, 6, 6, 1, 9, 0, 0, 9, 0, 0, - 5, 3, 2, 2, 3, 4, 1, 1, 2, 4, 3, 4, 1, 6, 9, 2, 6, 5, 6, 5, 3, 6, 9, - 9, 7, 8, 8, 4, 8, 1, 4, 5, 1, 5, 8, 1, 9, 3, 7, 2, 2, 0, 5, 4, 3, 1, - 6, 1, 8, 4, 2, 9, 9, 6, 9, 0, 2, 3, 2, 3, 3, 9, 4, 8, 5, 6, 9, 0, 2, - 1, 5, 5, 8, 4, 9, 9, 2, 1, 5, 9, 6, 7, 9, 9, 3, 5, 3, 5, 7, 9, 8, 8, - 9, 0, 5, 8, 4, 5, 6, 1, 7, 8, 7, 2, 9, 9, 1, 1, 7, 9, 0, 4, 7, 7, 8, - 8, 2, 3, 8, 3, 3, 8, 7, 8, 3, 2, 5, 9, 1, 4, 4, 6, 4, 5, 8, 7, 9, 7, - 4, 4, 5, 6, 7, 1, 2, 0, 9, 9, 0, 3, 4, 7, 3, 6, 9, 3, 6, 0, 7, 0, 9, - 5, 4, 0, 2, 8, 4, 7, 6, 9, 6, 4, 2, 9, 8, 2, 5, 6, 2, 6, 2, 3, 3, 4, - 2, 5, 0, 3, 3, 2, 5, 4, 7, 3, 3, 8, 1, 4, 7, 8, 5, 3, 0, 0, 7, 7, 0, - 4, 1, 8, 3, 6, 9, 2, 6, 8, 8, 6, 1, 6, 0, 9, 2, 1, 4, 7, 4, 1, 5, 1, - 5, 4, 8, 0, 3, 3, 0, 6, 9, 3, 0, 6, 5, 3, 6, 4, 6, 1, 0, 2, 8, 1, 4, - 3, 9, 9, 3, 4, 1, 1, 1, 1, 9, 4, 0, 4, 1, 3, 3, 4, 3, 2, 3, 9, 6, 2, - 1, 3, 3, 8, 0, 9, 4, 0, 6, 8, 5, 7, 3, 1, 2, 3, 5, 4, 3, 9, 1, 6, 4, - 0, 6, 7, 8, 0, 2, 2, 0, 1, 8, 6, 6, 3, 6, 7, 2, 3, 2, 7, 9, 0, 1, 9, - 8, 7, 8, 4, 6, 4, 6, 5, 8, 8, 9, 5, 5, 1, 7, 3, 0, 2, 2, 3, 8, 1, 8, - 1, 2, 3, 6, 0, 1, 3, 0, 8, 9, 9, 6, 8, 8, 1, 5, 1, 7, 8, 8, 3, 3, 4, - 7, 3, 9, 3, 3, 7, 9, 8, 3, 8, 6, 8, 4, 2, 2, 5, 0, 4, 0, 7, 7, 0, 0, - 3, 1, 8, 3, 2, 0, 1, 6, 5, 3, 9, 6, 7, 5, 6, 5, 4, 2, 7, 0, 3, 2, 8, - 3, 5, 8, 3, 5, 1, 3, 8, 2, 1, 5, 3, 3, 3, 5, 8, 3, 2, 0, 7, 4, 9, 4, - 5, 0, 8, 7, 3, 2, 1, 8, 4, 5, 7, 0, 7, 0, 7, 4, 6, 1, 6, 1, 9, 7, 2, - 5, 6, 0, 6, 3, 5, 3, 9, 9, 5, 8, 2, 9, 2, 8, 6, 3, 1, 9, 7, 4, 7, 8, - 6, 3, 6, 1, 5, 5, 6, 0, 6, 6, 3, 1, 8, 9, 1, 2, 0, 3, 8, 4, 0, 0, 5, - 1, 0, 7, 2, 5, 3, 7, 7, 8, 1, 3, 4, 5, 8, 4, 7, 6, 4, 7, 6, 9, 9, 2, - 9, 1, 7, 3, 2, 3, 0, 1, 6, 8, 5, 9, 2, 4, 4, 9, 5, 0, 2, 2, 7, 5, 3, - 6, 2, 0, 8, 3, 8, 2, 0, 1, 5, 8, 5, 2, 8, 6, 0, 2, 3, 7, 0, 9, 2, 0, - 7, 0, 9, 4, 0, 2, 5, 4, 2, 7, 3, 2, 9, 1, 2, 6, 3, 3, 5, 3, 6, 5, 4, - 0, 8, 6, 9, 8, 5, 3, 1, 5, 1, 2, 3, 2, 9, 7, 3, 1, 0, 6, 5, 6, 2, 7, - 5, 1, 4, 9, 0, 9, 7, 1, 7, 5, 0, 5, 7, 7, 9, 0, 0, 7, 7, 6, 3, 3, 0, - 0, 8, 6, 4, 8, 2, 9, 2, 3, 4, 1, 4, 5, 3, 1, 6, 4, 5, 1, 7, 0, 5, 6, - 4, 1, 4, 4, 9, 1, 1, 6, 1, 2, 9, 4, 7, 7, 7, 7, 5, 5, 0, 5, 1, 0, 6, - 1, 6, 1, 7, 4, 0, 5, 3, 4, 4, 4, 7, 9, 1, 6, 8, 6, 4, 7, 7, 3, 6, 5, - 8, 0, 0, 1, 4, 6, 7, 4, 7, 5, 3, 3, 4, 5, 9, 8, 8, 6, 3, 2, 8, 7, 2, - 7, 5, 9, 9, 2, 6, 9, 4, 0, 5, 8, 0, 3, 0, 1, 3, 1, 7, 2, 1, 9, 2, 3, - 4, 5, 6, 5, 2, 7, 9, 4, 9, 8, 8, 0, 8, 3, 4, 6, 6, 6, 6, 7, 8, 8, 3, - 3, 3, 2, 0, 7, 6, 4, 9, 5, 1, 0, 1, 7, 9, 3, 4, 2, 9, 7, 0, 5, 5, 6, - 3, 1, 9, 2, 7, 2, 8, 5, 9, 7, 9, 1, 9, 4, 4, 4, 0, 1, 1, 1, 8, 5, 3, - 3, 4, 7, 9, 3, 3, 6, 4, 4, 5, 0, 5, 6, 4, 4, 5, 5, 9, 7, 8, 6, 0, 6, - 3, 4, 4, 9, 6, 7, 7, 7, 5, 3, 2, 3, 3, 7, 0, 5, 9, 5, 6, 7, 6, 0, 6, - 2, 7, 7, 0, 7, 6, 6, 7, 3, 6, 8, 9, 7, 8, 1, 7, 8, 9, 0, 0, 3, 8, 2, - 2, 9, 1, 0, 7, 7, 3, 4, 2, 4, 7, 0, 2, 4, 2, 3, 5, 8, 5, 4, 4, 2, 3, - 1, 7, 0, 4, 1, 8, 8, 2, 9, 7, 2, 1, 8, 1, 8, 6, 2, 8, 9, 9, 2, 4, 3, - 6, 1, 3, 7, 4, 1, 1, 3, 2, 0, 1, 6, 2, 1, 5, 0, 9, 9, 1, 8, 4, 8, 7, - 9, 5, 9, 8, 8, 1, 3, 4, 7, 5, 4, 9, 0, 9, 9, 3, 5, 1, 6, 6, 8, 9, 0, - 0, 0, 7, 5, 1, 3, 7, 9, 0, 4, 6, 3, 7, 7, 3, 8, 6, 4, 5, 7, 1, 0, 0, - 8, 0, 2, 1, 5, 4, 0, 3, 0, 0, 7, 2, 2, 3, 0, 9, 0, 4, 4, 8, 9, 1, 5, - 8, 3, 2, 1, 8, 9, 8, 1, 1, 0, 8, 3, 2, 3, 0, 6, 2, 2, 3, 9, 5, 7, 0, - 1, 0, 3, 5, 4, 4, 5, 5, 1, 0, 2, 6, 3, 4, 7, 0, 7, 7, 9, 0, 1, 4, 9, - 9, 2, 1, 7, 4, 2, 1, 1, 1, 0, 2, 7, 4, 1, 8, 1, 7, 8, 1, 1, 5, 3, 5, - 4, 2, 1, 0, 5, 9, 9, 6, 8, 4, 9, 9, 0, 5, 2, 9, 8, 1, 4, 0, 2, 9, 6, - 7, 2, 0, 4, 0, 1, 1, 9, 5, 9, 0, 4, 0, 7, 1, 3, 8, 0, 5, 3, 4, 9, 8, - 7, 8, 8, 5, 6, 8, 6, 6, 6, 1, 3, 4, 7, 6, 9, 6, 3, 1, 3, 8, 4, 4, 0, - 1, 9, 5, 9, 1, 6, 8, 6, 0, 1, 8, 1, 8, 9, 9, 0, 6, 0, 2, 6, 2, 6, 9, - 1, 0, 2, 7, 0, 9, 2, 3, 9, 0, 2, 9, 9, 5, 4, 1, 3, 5, 4, 2, 6, 5, 9, - 8, 0, 8, 3, 4, 7, 4, 4, 5, 6, 8, 4, 7, 4, 1, 9, 5, 6, 3, 8, 3, 4, 0, - 3, 6, 1, 1, 6, 8, 6, 6, 4, 8, 9, 8, 8, 9, 0, 1, 5, 9, 7, 9, 0, 6, 4, - 4, 5, 8, 4, 2, 8, 1, 3, 2, 1, 5, 6, 6, 6, 2, 9, 0, 8, 1, 8, 2, 6, 4, - 3, 0, 3, 8, 6, 5, 7, 6, 8, 1, 5, 6, 7, 7, 5, 6, 7, 0, 0, 8, 3, 6, 0, - 7, 2, 8, 8, 4, 7, 8, 7, 5, 6, 2, 7, 3, 0, 1, 0, 1, 9, 7, 7, 0, 1, 8, - 0, 2, 6, 2, 6, 4, 6, 0, 0, 8, 9, 7, 4, 1, 5, 6, 2, 5, 3, 8, 4, 0, 4, - 1, 5, 9, 8, 1, 8, 0, 0, 0, 0, 3, 8, 8, 9, 6, 1, 2, 3, 3, 9, 9, 6, 4, - 3, 1, 7, 2, 8, 4, 5, 6, 6, 3, 6, 7, 6, 5, 5, 7, 9, 7, 9, 9, 9, 8, 8, - 0, 7, 0, 6, 6, 9, 6, 3, 5, 2, 3, 2, 6, 8, 1, 6, 0, 8, 6, 8, 6, 0, 4, - 6, 8, 1, 7, 2, 5, 3, 2, 2, 5, 1, 5, 2, 6, 8, 5, 0, 5, 3, 9, 2, 4, 1, - 6, 5, 5, 7, 7, 8, 2, 1, 7, 5, 7, 2, 8, 0, 6, 7, 2, 7, 0, 6, 9, 9, 7, - 7, 5, 1, 4, 5, 3, 0, 3, 2, 0, 0, 0, 7, 7, 8, 9, 0, 0, 7, 8, 5, 2, 9, - 6, 2, 2, 1, 8, 3, 1, 1, 7, 7, 1, 0, 7, 3, 4, 0, 3, 7, 6, 2, 7, 2, 6, - 9, 4, 9, 5, 4, 6, 6, 6, 5, 6, 9, 6, 8, 6, 1, 3, 3, 2, 2, 7, 4, 6, 8, - 3, 3, 1, 3, 4, 8, 7, 6, 7, 6, 0, 7, 2, 0, 1, 6, 3, 3, 9, 2, 0, 3, 9, - 3, 9, 2, 8, 6, 2, 8, 0, 2, 2, 5, 6, 5, 7, 4, 2, 5, 6, 4, 8, 9, 0, 6, - 5, 2, 7, 3, 9, 0, 4, 2, 4, 5, 2, 8, 9, 1, 2, 3, 7, 2, 7, 2, 5, 0, 1, - 5, 0, 5, 1, 7, 4, 4, 5, 7, 0, 7, 2, 7, 1, 6, 5, 6, 2, 1, 6, 1, 3, 0, - 4, 6, 3, 9, 5, 1, 1, 3, 9, 5, 5, 8, 6, 9, 0, 4, 0, 6, 8, 7, 3, 6, 4, - 5, 6, 2, 4, 5, 1, 0, 7, 3, 3, 3, 5, 2, 0, 2, 7, 5, 6, 2, 0, 4, 8, 0, - 8, 6, 9, 5, 3, 0, 5, 0, 5, 3, 9, 5, 6, 8, 2, 9, 9, 6, 1, 5, 9, 5, 6, - 2, 8, 9, 3, 5, 4, 0, 1, 8, 2, 4, 4, 6, 4, 5, 8, 6, 0, 1, 3, 3, 6, 8, - 6, 1, 7, 1, 5, 5, 7, 2, 3, 2, 0, 2, 0, 7, 4, 6, 0, 0, 5, 6, 6, 0, 2, - 2, 0, 5, 3, 9, 9, 5, 1, 5, 9, 8, 4, 3, 4, 2, 1, 4, 7, 9, 5, 5, 9, 9, - 1, 8, 2, 8, 0, 7, 9, 8, 8, 8, 0, 8, 1, 3, 9, 2, 0, 9, 5, 5, 6, 2, 5, - 5, 6, 7, 0, 4, 9, 5, 3, 0, 6, 6, 2, 1, 6, 7, 4, 5, 3, 0, 9, 7, 8, 5, - 7, 9, 0, 8, 6, 9, 6, 7, 3, 2, 2, 1, 0, 6, 7, 3, 7, 7, 4, 6, 7, 6, 3, - 3, 9, 9, 4, 7, 9, 2, 6, 1, 5, 5, 9, 3, 5, 8, 3, 8, 5, 8, 5, 3, 2, 7, - 0, 6, 5, 5, 5, 9, 2, 1, 2, 4, 9, 8, 8, 7, 3, 7, 5, 6, 3, 6, 5, 9, 2, - 6, 4, 4, 7, 3, 0, 5, 3, 6, 6, 6, 9, 4, 3, 3, 0, 0, 3, 6, 7, 8, 6, 6, - 6, 8, 4, 9, 4, 2, 6, 5, 5, 1, 5, 5, 7, 0, 5, 5, 5, 0, 8, 9, 9, 0, 7, - 6, 5, 5, 8, 7, 8, 3, 1, 8, 4, 6, 6, 6, 1, 7, 0, 9, 5, 8, 7, 7, 4, 5, - 3, 1, 7, 4, 6, 6, 6, 5, 7, 5, 3, 1, 0, 2, 7, 8, 8, 4, 6, 3, 2, 3, 6, - 3, 2, 0, 0, 1, 4, 7, 4, 3, 7, 9, 0, 9, 3, 4, 3, 8, 6, 3, 5, 8, 1, 0, - 1, 6, 0, 1, 8, 9, 5, 8, 2, 7, 7, 1, 6, 7, 4, 1, 0, 3, 1, 6, 5, 5, 0, - 9, 4, 7, 1, 4, 3, 4, 2, 4, 5, 0, 6, 4, 8, 7, 0, 6, 5, 3, 9, 3, 1, 3, - 9, 3, 5, 1, 8, 2, 7, 1, 3, 8, 7, 3, 5, 6, 6, 2, 7, 7, 1, 3, 7, 1, 6, - 5, 6, 3, 1, 7, 0, 5, 2, 6, 7, 3, 2, 5, 9, 4, 8, 1, 8, 0, 0, 0, 8, 5, - 2, 0, 8, 3, 6, 6, 3, 7, 8, 0, 0, 7, 3, 9, 1, 6, 0, 0, 2, 4, 3, 3, 9, - 0, 8, 3, 3, 9, 5, 4, 5, 3, 8, 4, 7, 2, 2, 9, 9, 7, 6, 4, 4, 4, 5, 2, - 6, 3, 9, 5, 3, 5, 8, 2, 9, 9, 4, 4, 7, 3, 3, 9, 0, 3, 3, 3, 5, 5, 8, - 3, 9, 2, 0, 9, 3, 6, 8, 0, 2, 6, 0, 6, 6, 0, 5, 9, 6, 5, 7, 0, 4, 3, - 1, 9, 6, 4, 0, 6, 6, 7, 3, 7, 9, 7, 7, 3, 1, 4, 2, 9, 9, 5, 5, 3, 3, - 1, 8, 2, 0, 5, 7, 4, 9, 3, 3, 0, 5, 7, 0, 9, 0, 9, 9, 2, 4, 2, 3, 7, - 1, 3, 1, 2, 5, 0, 3, 8, 6, 3, 1, 5, 1, 1, 0, 1, 7, 9, 4, 8, 0, 1, 7, - 9, 3, 8, 3, 0, 5, 1, 1, 5, 5, 7, 6, 3, 6, 0, 4, 6, 5, 2, 2, 3, 6, 6, - 2, 7, 1, 9, 9, 1, 1, 8, 0, 1, 2, 1, 4, 4, 3, 9, 3, 6, 1, 4, 3, 3, 9, - 3, 4, 8, 1, 7, 8, 8, 8, 2, 3, 7, 4, 4, 2, 8, 1, 5, 6, 1, 1, 3, 0, 7, - 1, 8, 4, 7, 2, 6, 9, 1, 9, 0, 0, 5, 1, 7, 3, 4, 1, 9, 8, 7, 4, 0, 8, - 3, 6, 8, 5, 7, 6, 6, 0, 2, 8, 8, 2, 6, 6, 8, 3, 5, 9, 9, 9, 2, 4, 2, - 1, 1, 0, 1, 8, 4, 5, 6, 9, 5, 8, 3, 1, 1, 6, 7, 5, 3, 0, 6, 3, 0, 1, - 9, 9, 1, 7, 9, 4, 0, 3, 1, 9, 7, 3, 8, 5, 9, 6, 5, 6, 8, 6, 2, 4, 8, - 3, 5, 5, 3, 4, 0, 1, 4, 0, 0, 7, 4, 0, 4, 0, 8, 3, 4, 6, 1, 1, 9, 0, - 0, 7, 7, 0, 3, 0, 8, 5, 7, 3, 3, 4, 3, 1, 2, 2, 0, 5, 4, 2, 8, 0, 9, - 0, 2, 6, 1, 9, 3, 1, 9, 3, 5, 4, 1, 1, 3, 4, 5, 9, 8, 3, 6, 3, 2, 4, - 9, 0, 3, 5, 4, 9, 7, 0, 3, 9, 8, 9, 2, 9, 5, 8, 5, 6, 5, 2, 2, 5, 9, - 9, 2, 3, 5, 2, 2, 4, 0, 6, 7, 0, 8, 5, 9, 4, 9, 8, 2, 5, 0, 2, 1, 1, - 0, 0, 0, 3, 7, 0, 7, 9, 8, 1, 1, 4, 8, 6, 2, 6, 9, 7, 7, 9, 0, 4, 5, - 9, 8, 4, 3, 8, 1, 1, 1, 5, 9, 0, 1, 2, 2, 4, 9, 1, 4, 7, 8, 4, 7, 3, - 4, 5, 8, 6, 0, 9, 2, 6, 9, 5, 8, 8, 1, 3, 6, 2, 0, 8, 1, 0, 1, 8, 7, - 5, 7, 4, 0, 4, 8, 9, 7, 3, 5, 2, 4, 6, 8, 2, 0, 9, 7, 9, 5, 4, 8, 4, - 2, 2, 8, 7, 3, 0, 6, 6, 1, 4, 9, 7, 7, 1, 8, 2, 2, 0, 1, 8, 2, 5, 7, - 4, 7, 7, 1, 8, 5, 5, 6, 8, 2, 7, 5, 3, 1, 7, 9, 9, 1, 9, 6, 8, 7, 7, - 8, 1, 9, 5, 5, 5, 2, 4, 6, 2, 7, 7, 3, 2, 1, 4, 0, 7, 7, 4, 6, 9, 5, - 0, 7, 0, 0, 1, 3, 1, 7, 8, 7, 3, 2, 3, 9, 0, 5, 6, 9, 9, 1, 4, 2, 3, - 5, 0, 7, 5, 6, 5, 1, 6, 8, 7, 8, 3, 2, 3, 4, 2, 1, 9, 2, 8, 9, 9, 4, - 4, 8, 6, 3, 0, 4, 5, 7, 9, 2, 3, 8, 0, 8, 3, 3, 8, 1, 2, 2, 8, 1, 5, - 1, 3, 1, 3, 7, 8, 6, 3, 2, 8, 8, 3, 1, 0, 7, 2, 3, 1, 1, 5, 1, 7, 0, - 1, 1, 5, 9, 6, 8, 3, 7, 3, 9, 0, 3, 5, 4, 9, 0, 6, 9, 5, 9, 6, 4, 2, - 3, 7, 9, 3, 4, 0, 9, 2, 2, 1, 9, 9, 8, 2, 3, 2, 5, 6, 3, 7, 6, 3, 5, - 5, 7, 6, 3, 1, 6, 8, 3, 9, 1, 8, 2, 6, 5, 9, 1, 0, 1, 0, 3, 6, 4, 1, - 2, 1, 0, 4, 9, 8, 6, 3, 1, 2, 4, 2, 5, 9, 6, 6, 4, 3, 0, 1, 0, 6, 7, - 2, 7, 9, 5, 4, 0, 4, 6, 6, 5, 2, 4, 2, 4, 5, 1, 6, 0, 3, 2, 0, 0, 1, - 3, 0, 3, 7, 5, 8, 1, 3, 8, 3, 7, 0, 1, 1, 0, 4, 5, 6, 2, 6, 5, 6, 6, - 4, 8, 8, 8, 5, 2, 7, 1, 2, 2, 3, 2, 8, 3, 4, 3, 2, 3, 9, 7, 6, 3, 9, - 8, 1, 2, 6, 7, 0, 2, 1, 5, 1, 4, 3, 3, 4, 8, 6, 6, 5, 8, 0, 0, 8, 5, - 6, 3, 5, 4, 5, 6, 7, 6, 9, 5, 0, 0, 2, 1, 3, 0, 0, 0, 4, 0, 9, 1, 1, - 7, 0, 6, 0, 7, 3, 6, 7, 0, 9, 3, 2, 0, 0, 3, 9, 2, 0, 5, 2, 0, 1, 6, - 2, 8, 6, 8, 0, 8, 1, 2, 6, 4, 7, 0, 7, 3, 4, 8, 5, 1, 8, 8, 4, 0, 9, - 1, 5, 6, 0, 9, 2, 7, 6, 9, 5, 5, 6, 0, 4, 3, 9, 6, 5, 7, 7, 7, 7, 1, - 0, 1, 3, 8, 3, 6, 4, 6, 5, 9, 9, 8, 4, 6, 0, 7, 3, 0, 8, 5, 5, 2, 4, - 5, 8, 6, 3, 5, 8, 5, 4, 8, 0, 8, 3, 4, 5, 7, 2, 0, 1, 3, 2, 5, 4, 5, - 0, 3, 3, 2, 9, 9, 5, 8, 4, 7, 7, 6, 4, 9, 3, 5, 8, 0, 6, 8, 7, 0, 6, - 9, 1, 3, 4, 9, 5, 2, 7, 3, 4, 0, 0, 2, 0, 6, 0, 8, 4, 9, 3, 2, 4, 3, - 4, 9, 7, 6, 1, 5, 5, 0, 2, 7, 2, 4, 3, 9, 2, 6, 5, 9, 3, 9, 3, 6, 6, - 8, 8, 5, 7, 7, 3, 0, 8, 9, 9, 0, 8, 6, 2, 4, 6, 1, 1, 0, 0, 5, 6, 0, - 3, 5, 1, 0, 7, 6, 9, 3, 1, 0, 4, 4, 9, 2, 6, 4, 3, 2, 8, 5, 9, 0, 3, - 8, 0, 9, 6, 1, 8, 7, 3, 6, 3, 9, 8, 4, 5, 6, 7, 6, 5, 6, 0, 3, 8, 9, - 1, 9, 5, 0, 3, 3, 0, 5, 9, 2, 4, 2, 6, 3, 4, 7, 2, 1, 8, 1, 4, 9, 9, - 9, 2, 9, 6, 9, 9, 6, 4, 5, 4, 7, 3, 8, 3, 5, 5, 5, 3, 7, 4, 5, 0, 0, - 6, 5, 0, 3, 5, 4, 7, 3, 2, 1, 4, 3, 5, 6, 3, 3, 2, 9, 6, 0, 8, 5, 6, - 8, 3, 7, 6, 4, 2, 7, 1, 2, 4, 7, 2, 0, 4, 2, 7, 5, 7, 3, 0, 0, 4, 7, - 9, 0, 6, 3, 8, 5, 3, 8, 0, 2, 4, 0, 9, 6, 4, 4, 8, 0, 5, 9, 5, 8, 2, - 3, 8, 8, 5, 2, 2, 1, 3, 3, 2, 0, 6, 4, 6, 3, 4, 2, 0, 2, 6, 6, 6, 2, - 5, 0, 0, 5, 6, 0, 8, 7, 4, 2, 7, 4, 9, 8, 3, 2, 2, 7, 7, 5, 7, 3, 4, - 7, 4, 8, 0, 5, 2, 0, 1, 0, 2, 2, 5, 7, 5, 4, 1, 9, 4, 6, 9, 8, 3, 2, - 9, 4, 0, 7, 6, 8, 7, 1, 5, 1, 9, 1, 5, 1, 0, 4, 9, 5, 3, 6, 6, 4, 0, - 8, 1, 9, 6, 8, 3, 3, 0, 0, 7, 6, 5, 5, 7, 4, 8, 1, 2, 3, 4, 2, 5, 1, - 7, 4, 6, 5, 5, 0, 4, 5, 8, 5, 2, 6, 5, 4, 5, 1, 4, 3, 8, 8, 2, 9, 4, - 6, 7, 3, 3, 3, 5, 2, 5, 7, 1, 7, 0, 2, 1, 0, 1, 3, 9, 6, 3, 7, 6, 7, - 4, 5, 2, 5, 4, 5, 6, 5, 3, 0, 8, 3, 4, 7, 5, 6, 8, 4, 1, 3, 6, 0, 0, - 7, 6, 2, 4, 0, 1, 9, 5, 2, 3, 1, 0, 3, 2, 4, 7, 4, 1, 3, 8, 0, 7, 3, - 4, 3, 8, 6, 9, 8, 0, 2, 9, 2, 1, 6, 7, 5, 2, 4, 6, 9, 6, 1, 4, 3, 5, - 0, 4, 8, 9, 4, 8, 9, 9, 6, 1, 0, 4, 4, 2, 4, 6, 4, 5, 8, 9, 7, 4, 1, - 6, 2, 7, 9, 7, 6, 4, 1, 1, 5, 9, 3, 4, 8, 3, 5, 6, 3, 5, 6, 0, 8, 7, - 1, 7, 9, 8, 3, 8, 8, 2, 9, 8, 5, 9, 9, 3, 5, 7, 1, 6, 7, 8, 5, 0, 8, - 8, 9, 8, 3, 4, 1, 8, 7, 9, 9, 7, 5, 6, 2, 5, 1, 5, 5, 8, 1, 0, 5, 9, - 8, 5, 4, 8, 3, 8, 2, 2, 0, 4, 3, 3, 6, 9, 5, 2, 2, 4, 0, 7, 6, 1, 4, - 9, 9, 9, 5, 3, 8, 1, 7, 7, 3, 2, 2, 5, 7, 7, 3, 4, 0, 0, 9, 5, 1, 4, - 8, 4, 3, 3, 4, 1, 2, 9, 1, 6, 4, 4, 3, 8, 1, 3, 4, 0, 3, 7, 8, 6, 1, - 5, 9, 6, 2, 0, 5, 6, 8, 8, 5, 0, 5, 0, 3, 5, 8, 8, 3, 8, 1, 0, 0, 6, - 1, 5, 5, 3, 3, 4, 7, 8, 8, 8, 5, 4, 9, 6, 1, 3, 2, 0, 0, 1, 0, 8, 4, - 7, 0, 5, 9, 7, 5, 1, 4, 1, 0, 1, 1, 8, 1, 7, 6, 0, 8, 2, 4, 3, 5, 2, - 1, 3, 8, 6, 1, 8, 7, 7, 9, 7, 9, 6, 1, 0, 0, 9, 8, 6, 8, 4, 8, 1, 2, - 1, 0, 5, 4, 3, 8, 6, 8, 1, 7, 8, 0, 5, 7, 5, 3, 3, 1, 4, 4, 8, 2, 2, - 0, 3, 0, 1, 9, 5, 5, 3, 0, 4, 1, 8, 7, 1, 3, 9, 7, 2, 8, 3, 4, 8, 8, - 8, 4, 0, 7, 5, 4, 0, 2, 7, 7, 2, 8, 2, 9, 3, 7, 5, 5, 0, 0, 9, 9, 8, - 2, 9, 3, 8, 6, 0, 6, 0, 1, 8, 5, 3, 8, 8, 5, 4, 1, 2, 0, 2, 7, 7, 0, - 0, 1, 8, 6, 6, 6, 5, 4, 9, 6, 4, 3, 6, 7, 2, 3, 5, 1, 7, 2, 0, 8, 6, - 7, 4, 4, 1, 5, 2, 7, 1, 7, 4, 8, 5, 9, 9, 7, 1, 7, 7, 4, 1, 2, 1, 7, - 3, 0, 9, 7, 1, 1, 1, 1, 6, 4, 1, 4, 4, 4, 9, 3, 0, 5, 1, 0, 9, 6, 4, - 8, 6, 2, 2, 3, 0, 4, 5, 4, 6, 8, 1, 7, 8, 1, 4, 2, 7, 5, 7, 2, 2, 4, - 0, 1, 6, 9, 5, 4, 9, 6, 8, 7, 6, 5, 1, 4, 4, 0, 7, 9, 9, 6, 5, 4, 5, - 7, 4, 2, 5, 2, 9, 1, 1, 6, 3, 5, 1, 9, 9, 9, 4, 9, 4, 1, 2, 5, 3, 9, - 5, 8, 2, 9, 3, 6, 6, 7, 6, 1, 5, 8, 1, 1, 9, 0, 3, 3, 8, 1, 2, 7, 1, - 7, 1, 8, 7, 8, 5, 9, 4, 7, 1, 8, 7, 5, 6, 2, 5, 6, 0, 2, 9, 0, 7, 3, - 6, 4, 0, 0, 9, 2, 9, 8, 1, 3, 6, 7, 0, 6, 1, 8, 0, 1, 1, 9, 6, 6, 6, - 7, 8, 6, 5, 2, 4, 2, 9, 6, 2, 8, 8, 3, 4, 9, 0, 9, 5, 4, 6, 2, 1, 0, - 7, 9, 3, 7, 0, 2, 1, 5, 8, 4, 9, 5, 2, 5, 4, 4, 6, 6, 7, 2, 5, 2, 6, - 2, 3, 0, 8, 0, 9, 8, 7, 4, 9, 3, 9, 4, 9, 8, 0, 4, 4, 8, 6, 8, 3, 3, - 3, 0, 7, 8, 3, 3, 8, 3, 7, 4, 7, 6, 0, 3, 7, 8, 5, 6, 0, 3, 8, 0, 4, - 8, 8, 8, 4, 3, 9, 2, 3, 4, 0, 8, 7, 6, 7, 2, 1, 0, 7, 6, 9, 1, 6, 0, - 5, 7, 5, 9, 0, 4, 8, 7, 8, 2, 1, 4, 8, 2, 8, 5, 4, 3, 4, 6, 1, 2, 3, - 3, 1, 2, 2, 4, 6, 2, 3, 5, 6, 0, 5, 0, 8, 6, 7, 5, 2, 3, 4, 8, 7, 7, - 3, 8, 8, 2, 4, 8, 0, 1 - ], - [65, 67]); - - const b = tf.tensor2d( - [ - 0, 3, 3, 3, 7, 3, 3, 3, 2, 9, 8, 4, 8, 5, 2, 5, 3, 0, 7, 0, 7, 9, 3, - 5, 7, 9, 6, 1, 0, 2, 9, 5, 6, 0, 9, 2, 6, 1, 1, 1, 6, 8, 6, 8, 8, 7, - 2, 0, 8, 5, 7, 3, 4, 7, 0, 1, 5, 8, 1, 5, 0, 3, 3, 4, 9, 1, 6, 9, 0, - 7, 9, 7, 5, 2, 6, 2, 0, 0, 3, 7, 2, 8, 8, 6, 8, 3, 6, 0, 3, 3, 2, 6, - 2, 0, 3, 5, 8, 9, 9, 1, 6, 6, 0, 3, 7, 0, 9, 9, 7, 0, 2, 9, 7, 6, 9, - 1, 1, 7, 9, 7, 2, 0, 6, 4, 2, 3, 6, 6, 3, 3, 9, 0, 1, 3, 4, 2, 2, 3, - 7, 4, 8, 4, 2, 1, 5, 5, 6, 1, 1, 2, 1, 1, 0, 7, 3, 8, 2, 8, 1, 3, 9, - 4, 8, 0, 3, 6, 7, 9, 2, 5, 4, 6, 1, 9, 6, 1, 4, 2, 3, 2, 7, 7, 0, 3, - 6, 1, 2, 8, 4, 3, 4, 1, 4, 3, 1, 3, 2, 8, 2, 5, 6, 0, 7, 0, 3, 4, 7, - 3, 9, 9, 0, 1, 0, 9, 3, 6, 5, 9, 7, 2, 3, 5, 1, 9, 3, 5, 2, 4, 5, 6, - 2, 1, 5, 5, 6, 8, 6, 0, 8, 1, 8, 6, 6, 8, 7, 6, 9, 7, 9, 4, 9, 8, 2, - 9, 8, 5, 3, 1, 3, 2, 4, 6, 4, 8, 7, 5, 3, 0, 0, 9, 1, 7, 6, 3, 1, 3, - 6, 2, 0, 2, 3, 3, 7, 1, 5, 8, 4, 6, 5, 9, 8, 8, 5, 9, 1, 0, 4, 6, 2, - 4, 9, 9, 2, 6, 6, 9, 9, 8, 9, 9, 8, 0, 5, 8, 4, 8, 3, 9, 2, 0, 6, 4, - 9, 9, 5, 5, 7, 9, 3, 3, 8, 9, 3, 2, 2, 8, 8, 8, 8, 8, 5, 2, 9, 4, 0, - 0, 2, 2, 8, 5, 1, 3, 8, 5, 6, 7, 4, 4, 0, 2, 1, 4, 9, 4, 8, 9, 6, 7, - 9, 2, 9, 6, 1, 5, 8, 4, 9, 1, 0, 0, 6, 2, 8, 5, 8, 7, 0, 5, 8, 4, 8, - 5, 4, 7, 1, 7, 9, 0, 4, 3, 5, 3, 9, 8, 7, 8, 0, 7, 8, 1, 9, 3, 6, 6, - 9, 1, 4, 6, 3, 6, 3, 2, 1, 7, 8, 3, 4, 4, 7, 0, 0, 1, 9, 0, 8, 8, 3, - 8, 8, 3, 3, 7, 0, 6, 6, 9, 9, 7, 5, 6, 4, 2, 1, 2, 0, 2, 4, 4, 3, 7, - 3, 8, 0, 9, 0, 1, 5, 0, 5, 2, 1, 5, 4, 2, 6, 0, 9, 1, 2, 1, 7, 4, 4, - 3, 9, 9, 8, 4, 4, 8, 0, 0, 9, 0, 9, 8, 7, 4, 5, 4, 4, 9, 1, 1, 9, 6, - 0, 8, 3, 4, 5, 5, 2, 1, 9, 8, 8, 0, 3, 1, 5, 7, 3, 0, 2, 7, 9, 2, 5, - 9, 1, 1, 1, 3, 1, 1, 4, 7, 3, 2, 4, 3, 3, 9, 7, 0, 9, 4, 2, 5, 6, 2, - 0, 0, 3, 2, 3, 8, 0, 7, 0, 9, 9, 0, 6, 8, 2, 7, 3, 9, 6, 5, 5, 1, 3, - 1, 9, 2, 0, 8, 3, 2, 6, 6, 8, 4, 6, 6, 1, 5, 5, 9, 0, 0, 1, 4, 0, 6, - 4, 4, 7, 4, 9, 8, 1, 6, 5, 5, 6, 3, 5, 7, 9, 2, 7, 1, 1, 5, 3, 3, 6, - 6, 9, 6, 2, 0, 1, 5, 0, 8, 7, 6, 9, 9, 1, 3, 9, 4, 5, 4, 0, 8, 3, 3, - 1, 4, 6, 7, 0, 6, 3, 8, 8, 4, 9, 8, 8, 5, 0, 8, 7, 1, 5, 0, 8, 0, 8, - 7, 0, 2, 8, 6, 3, 4, 2, 3, 6, 0, 3, 5, 7, 1, 6, 1, 8, 0, 0, 0, 4, 6, - 7, 5, 3, 2, 2, 3, 5, 9, 4, 0, 3, 5, 0, 4, 7, 4, 1, 9, 6, 9, 7, 2, 3, - 3, 3, 0, 9, 3, 1, 2, 3, 5, 9, 6, 2, 6, 8, 3, 1, 8, 1, 1, 0, 7, 3, 4, - 2, 9, 0, 6, 9, 5, 6, 2, 4, 3, 0, 5, 6, 2, 1, 4, 5, 1, 5, 2, 3, 5, 5, - 0, 5, 2, 9, 4, 4, 0, 8, 4, 3, 9, 6, 5, 9, 0, 2, 9, 3, 1, 0, 5, 9, 9, - 3, 5, 6, 0, 7, 0, 3, 6, 6, 7, 5, 2, 0, 8, 3, 6, 2, 4, 6, 5, 1, 0, 6, - 5, 6, 3, 2, 0, 8, 5, 9, 7, 7, 1, 8, 2, 6, 1, 7, 4, 2, 8, 6, 1, 3, 1, - 3, 4, 7, 2, 0, 5, 5, 6, 4, 8, 9, 2, 9, 9, 1, 4, 3, 2, 2, 3, 3, 0, 1, - 1, 0, 9, 2, 8, 3, 0, 5, 5, 6, 3, 9, 9, 2, 6, 2, 3, 8, 4, 3, 7, 7, 1, - 4, 7, 2, 4, 4, 5, 5, 8, 2, 9, 8, 4, 9, 4, 0, 9, 8, 1, 9, 6, 8, 4, 8, - 5, 6, 2, 9, 7, 3, 7, 2, 7, 9, 2, 8, 4, 3, 5, 7, 5, 1, 6, 9, 0, 0, 7, - 3, 9, 6, 0, 6, 9, 2, 9, 0, 9, 1, 8, 8, 8, 9, 4, 3, 8, 7, 8, 5, 9, 1, - 1, 9, 1, 7, 3, 3, 7, 1, 5, 5, 9, 6, 1, 8, 6, 7, 1, 9, 0, 1, 4, 4, 4, - 6, 9, 4, 7, 2, 9, 5, 9, 9, 2, 0, 5, 4, 5, 3, 7, 5, 2, 7, 4, 2, 4, 0, - 9, 0, 1, 7, 0, 3, 2, 3, 9, 9, 6, 7, 4, 6, 8, 1, 2, 5, 2, 2, 3, 4, 3, - 7, 7, 4, 6, 9, 9, 1, 6, 1, 9, 4, 5, 4, 7, 3, 0, 0, 6, 0, 7, 8, 3, 4, - 5, 6, 1, 6, 8, 0, 8, 5, 5, 7, 4, 2, 6, 0, 4, 2, 9, 7, 3, 9, 8, 6, 8, - 4, 4, 9, 1, 8, 9, 1, 3, 3, 5, 9, 5, 0, 9, 5, 5, 5, 6, 2, 1, 4, 3, 9, - 5, 1, 8, 9, 7, 8, 7, 3, 1, 9, 3, 7, 3, 2, 9, 4, 5, 8, 7, 9, 6, 7, 2, - 3, 9, 6, 2, 3, 1, 0, 2, 7, 2, 9, 2, 5, 5, 9, 4, 4, 7, 4, 4, 6, 9, 2, - 1, 8, 7, 7, 8, 8, 4, 3, 1, 6, 2, 2, 2, 8, 1, 5, 5, 5, 3, 5, 0, 8, 1, - 1, 9, 2, 9, 4, 8, 3, 4, 3, 5, 1, 2, 6, 4, 5, 6, 6, 8, 9, 1, 4, 9, 1, - 3, 1, 5, 5, 0, 1, 8, 6, 9, 3, 0, 9, 4, 7, 4, 4, 8, 5, 9, 8, 8, 4, 5, - 9, 7, 7, 0, 6, 0, 0, 7, 6, 4, 8, 2, 0, 0, 6, 8, 8, 1, 4, 7, 8, 5, 5, - 3, 9, 6, 8, 7, 8, 2, 4, 9, 0, 5, 3, 3, 5, 9, 8, 1, 9, 8, 2, 7, 2, 1, - 7, 4, 3, 5, 4, 9, 8, 1, 2, 0, 2, 7, 8, 4, 3, 2, 8, 7, 2, 6, 6, 2, 9, - 2, 9, 1, 3, 4, 8, 2, 2, 0, 8, 3, 2, 3, 9, 3, 0, 1, 3, 4, 2, 9, 5, 4, - 0, 5, 9, 4, 8, 5, 8, 4, 5, 3, 7, 2, 1, 8, 2, 8, 9, 0, 4, 3, 9, 3, 6, - 3, 5, 1, 1, 1, 0, 5, 0, 8, 2, 7, 4, 3, 4, 0, 5, 3, 4, 0, 8, 5, 3, 1, - 1, 9, 3, 1, 8, 6, 1, 2, 2, 2, 6, 8, 3, 7, 7, 8, 9, 1, 0, 1, 9, 0, 1, - 6, 7, 3, 6, 2, 7, 0, 7, 8, 2, 8, 8, 5, 0, 4, 3, 8, 5, 0, 1, 8, 0, 7, - 1, 1, 8, 3, 7, 7, 1, 6, 1, 4, 9, 3, 3, 0, 0, 0, 2, 7, 8, 6, 4, 7, 7, - 2, 0, 9, 7, 8, 4, 2, 3, 7, 2, 2, 7, 4, 0, 4, 8, 8, 8, 8, 3, 8, 4, 4, - 4, 7, 8, 0, 3, 4, 5, 8, 1, 5, 5, 7, 8, 9, 7, 1, 7, 3, 4, 3, 5, 0, 8, - 7, 1, 4, 5, 0, 6, 3, 9, 4, 4, 8, 9, 6, 3, 0, 5, 7, 1, 4, 9, 2, 0, 9, - 1, 3, 1, 2, 7, 8, 9, 6, 2, 8, 3, 4, 7, 9, 2, 7, 4, 1, 0, 7, 2, 1, 1, - 9, 5, 6, 9, 5, 8, 4, 6, 3, 1, 9, 6, 1, 9, 1, 6, 0, 4, 5, 7, 9, 3, 5, - 4, 4, 7, 2, 1, 8, 2, 7, 6, 6, 1, 8, 4, 6, 4, 7, 4, 7, 9, 9, 7, 5, 7, - 2, 4, 0, 7, 2, 3, 2, 0, 1, 0, 7, 8, 4, 1, 0, 2, 8, 8, 0, 8, 9, 9, 8, - 4, 3, 2, 4, 5, 4, 5, 5, 1, 6, 3, 6, 5, 1, 4, 9, 9, 5, 6, 0, 9, 9, 8, - 2, 6, 3, 3, 4, 1, 2, 9, 3, 7, 2, 2, 0, 7, 6, 4, 6, 7, 8, 7, 9, 8, 0, - 9, 4, 7, 2, 5, 0, 6, 7, 7, 0, 4, 0, 0, 0, 4, 1, 8, 3, 5, 9, 8, 5, 5, - 1, 4, 6, 3, 5, 3, 5, 1, 8, 5, 3, 4, 2, 8, 3, 4, 9, 1, 8, 4, 4, 4, 8, - 7, 5, 3, 0, 1, 4, 6, 3, 3, 0, 3, 1, 5, 8, 6, 6, 7, 3, 9, 9, 2, 4, 1, - 1, 9, 9, 5, 1, 9, 4, 9, 4, 7, 2, 8, 0, 6, 0, 3, 7, 2, 7, 6, 9, 6, 8, - 5, 8, 9, 7, 4, 1, 5, 5, 2, 7, 8, 6, 6, 7, 3, 6, 9, 1, 9, 4, 9, 9, 2, - 6, 3, 2, 9, 8, 9, 4, 8, 3, 0, 5, 9, 9, 2, 1, 7, 2, 2, 1, 8, 8, 7, 0, - 9, 8, 8, 0, 8, 4, 3, 2, 2, 7, 9, 9, 7, 5, 8, 9, 8, 7, 4, 7, 9, 1, 0, - 7, 6, 2, 4, 4, 0, 1, 9, 7, 4, 5, 9, 2, 2, 5, 1, 3, 2, 2, 9, 2, 2, 8, - 7, 6, 0, 7, 5, 6, 5, 6, 0, 0, 5, 6, 7, 2, 7, 1, 2, 1, 7, 0, 0, 2, 6, - 3, 8, 1, 7, 1, 8, 7, 7, 5, 1, 0, 8, 4, 7, 8, 9, 1, 5, 4, 1, 9, 3, 3, - 8, 4, 5, 7, 9, 4, 7, 3, 8, 9, 5, 3, 2, 7, 3, 9, 7, 9, 8, 2, 8, 0, 1, - 7, 8, 2, 1, 0, 7, 5, 1, 3, 7, 2, 4, 8, 8, 4, 6, 8, 2, 7, 6, 8, 2, 0, - 9, 5, 4, 0, 2, 2, 1, 1, 4, 4, 9, 3, 0, 7, 1, 6, 4, 4, 9, 9, 2, 3, 6, - 3, 8, 7, 3, 3, 1, 0, 0, 1, 9, 6, 7, 5, 5, 8, 4, 1, 3, 6, 3, 6, 5, 6, - 3, 7, 8, 1, 4, 0, 0, 2, 4, 1, 3, 6, 8, 1, 2, 9, 3, 9, 7, 8, 4, 0, 6, - 4, 3, 3, 9, 8, 9, 1, 7, 1, 5, 8, 1, 4, 3, 2, 0, 6, 5, 9, 2, 6, 2, 5, - 8, 8, 8, 0, 7, 4, 1, 1, 3, 6, 0, 8, 3, 6, 2, 4, 6, 1, 7, 5, 3, 8, 0, - 6, 3, 7, 5, 5, 2, 3, 2, 7, 6, 9, 3, 8, 4, 5, 5, 4, 0, 9, 9, 7, 8, 6, - 7, 1, 8, 7, 1, 5, 0, 0, 9, 5, 8, 7, 7, 3, 4, 2, 1, 4, 1, 9, 1, 1, 9, - 8, 6, 3, 5, 5, 0, 8, 9, 1, 7, 5, 1, 7, 8, 0, 0, 4, 0, 3, 7, 1, 4, 4, - 7, 4, 3, 3, 8, 7, 1, 5, 1, 1, 0, 9, 5, 0, 5, 9, 7, 0, 5, 7, 4, 6, 0, - 2, 4, 0, 4, 8, 1, 6, 1, 5, 7, 5, 5, 1, 8, 2, 3, 8, 5, 8, 8, 9, 0, 4, - 1, 2, 5, 9, 0, 0, 8, 1, 7, 4, 8, 8, 3, 3, 2, 4, 8, 1, 7, 6, 0, 1, 6, - 6, 7, 1, 5, 9, 1, 7, 8, 1, 5, 9, 5, 8, 2, 4, 6, 0, 3, 4, 2, 3, 8, 4, - 4, 9, 7, 3, 7, 3, 8, 9, 1, 7, 2, 2, 6, 5, 1, 9, 2, 8, 1, 6, 4, 3, 1, - 0, 6, 4, 3, 1, 0, 5, 0, 5, 9, 9, 2, 7, 1, 0, 0, 3, 4, 7, 1, 5, 9, 2, - 8, 7, 8, 0, 9, 0, 8, 8, 6, 8, 3, 1, 3, 5, 4, 3, 9, 5, 2, 5, 5, 1, 2, - 4, 7, 8, 3, 1, 9, 2, 4, 9, 1, 2, 8, 9, 9, 6, 1, 5, 8, 8, 4, 2, 3, 8, - 3, 8, 7, 0, 7, 0, 1, 6, 3, 2, 5, 0, 0, 5, 6, 0, 6, 8, 4, 9, 9, 3, 8, - 5, 7, 3, 5, 4, 7, 3, 4, 7, 8, 2, 3, 8, 5, 1, 4, 3, 4, 8, 0, 7, 5, 8, - 5, 4, 0, 7, 0, 7, 2, 2, 0, 0, 0, 1, 6, 9, 8, 2, 9, 5, 1, 2, 9, 3, 9, - 1, 7, 3, 7, 2, 9, 8, 6, 1, 7, 2, 4, 2, 3, 2, 7, 8, 0, 0, 9, 0, 8, 2, - 1, 1, 7, 6, 7, 5, 4, 7, 0, 2, 8, 4, 8, 2, 0, 0, 5, 5, 3, 6, 5, 9, 4, - 6, 1, 6, 1, 1, 3, 6, 2, 5, 4, 1, 7, 6, 9, 7, 4, 6, 2, 7, 8, 0, 8, 6, - 7, 0, 3, 8, 7, 4, 0, 8, 4, 9, 0, 1, 6, 8, 7, 4, 2, 7, 8, 5, 2, 9, 4, - 4, 2, 0, 2, 8, 0, 8, 1, 2, 4, 1, 3, 1, 8, 2, 9, 8, 6, 9, 6, 5, 1, 9, - 5, 4, 2, 1, 5, 9, 2, 2, 2, 6, 4, 4, 8, 4, 0, 1, 4, 2, 7, 4, 6, 1, 8, - 8, 3, 4, 1, 6, 2, 2, 4, 9, 5, 8, 5, 2, 7, 0, 9, 4, 5, 2, 3, 2, 4, 8, - 0, 3, 3, 4, 4, 0, 3, 6, 8, 6, 4, 3, 1, 9, 9, 8, 0, 3, 3, 5, 0, 6, 8, - 4, 0, 2, 5, 7, 0, 0, 5, 8, 2, 5, 3, 5, 9, 5, 8, 3, 9, 5, 0, 6, 7, 9, - 4, 5, 8, 7, 8, 9, 8, 2, 9, 0, 4, 6, 5, 5, 8, 9, 7, 7, 7, 4, 9, 3, 9, - 3, 4, 0, 9, 3, 5, 3, 4, 3, 9, 3, 4, 1, 3, 5, 8, 0, 6, 8, 1, 3, 6, 5, - 5, 9, 9, 6, 9, 7, 8, 2, 6, 0, 4, 3, 3, 7, 2, 9, 2, 3, 6, 0, 3, 0, 2, - 7, 4, 5, 2, 3, 5, 7, 9, 9, 8, 0, 9, 3, 1, 6, 1, 7, 6, 4, 9, 0, 8, 5, - 8, 8, 4, 3, 1, 5, 8, 4, 8, 0, 3, 8, 3, 2, 8, 7, 9, 0, 0, 3, 3, 4, 5, - 2, 5, 7, 3, 7, 8, 1, 7, 1, 6, 6, 7, 7, 8, 8, 1, 2, 2, 7, 6, 6, 7, 2, - 6, 8, 7, 1, 6, 2, 5, 9, 9, 1, 3, 7, 1, 0, 6, 3, 8, 5, 9, 8, 3, 3, 9, - 0, 8, 4, 0, 6, 0, 6, 1, 9, 2, 7, 5, 7, 5, 2, 3, 6, 2, 7, 4, 6, 3, 9, - 5, 4, 7, 3, 1, 7, 4, 6, 3, 4, 3, 1, 9, 7, 5, 2, 0, 9, 1, 6, 3, 9, 1, - 9, 8, 0, 7, 0, 9, 9, 1, 2, 2, 4, 1, 5, 7, 7, 5, 7, 8, 2, 6, 0, 9, 3, - 9, 8, 6, 4, 4, 7, 4, 0, 6, 0, 3, 0, 9, 4, 6, 8, 9, 4, 2, 8, 5, 7, 9, - 3, 5, 3, 1, 1, 7, 2, 5, 7, 1, 6, 2, 6, 5, 5, 9, 1, 4, 4, 8, 6, 8, 1, - 2, 8, 6, 7, 1, 8, 7, 6, 9, 4, 6, 4, 1, 8, 9, 9, 4, 6, 3, 1, 0, 1, 4, - 7, 8, 1, 0, 4, 6, 5, 6, 4, 2, 8, 8, 0, 3, 8, 6, 6, 1, 2, 8, 7, 6, 8, - 6, 0, 4, 2, 2, 7, 9, 4, 3, 2, 7, 7, 5, 1, 5, 5, 6, 6, 2, 7, 2, 0, 3, - 7, 2, 5, 7, 1, 2, 8, 6, 6, 7, 8, 1, 0, 0, 1, 9, 7, 8, 7, 1, 2, 6, 1, - 8, 4, 2, 6, 5, 1, 5, 7, 7, 7, 3, 3, 0, 8, 7, 9, 9, 8, 9, 8, 3, 3, 1, - 9, 9, 1, 9, 2, 5, 2, 2, 7, 8, 7, 3, 0, 2, 3, 4, 8, 6, 4, 2, 8, 8, 0, - 8, 9, 3, 1, 1, 0, 9, 5, 1, 3, 7, 4, 8, 7, 3, 7, 8, 0, 1, 1, 9, 4, 3, - 9, 7, 3, 4, 1, 8, 5, 2, 9, 1, 6, 8, 6, 3, 2, 1, 4, 8, 9, 7, 9, 2, 1, - 6, 8, 9, 0, 2, 3, 9, 6, 1, 4, 0, 2, 2, 2, 3, 5, 5, 4, 0, 2, 7, 8, 2, - 5, 9, 3, 9, 5, 0, 5, 2, 8, 5, 7, 5, 2, 3, 5, 4, 2, 9, 4, 1, 0, 7, 0, - 7, 3, 1, 3, 8, 8, 3, 2, 2, 1, 4, 8, 8, 3, 9, 7, 4, 2, 6, 4, 8, 1, 6, - 3, 3, 2, 3, 0, 2, 0, 0, 3, 8, 9, 1, 7, 7, 5, 5, 2, 7, 6, 7, 7, 0, 2, - 8, 1, 5, 0, 7, 9, 3, 9, 6, 8, 7, 1, 3, 6, 8, 4, 7, 8, 2, 9, 8, 9, 2, - 3, 9, 4, 8, 8, 9, 4, 7, 1, 3, 9, 2, 4, 8, 8, 2, 8, 1, 3, 2, 3, 6, 6, - 4, 7, 5, 3, 9, 2, 0, 8, 2, 9, 9, 0, 5, 5, 3, 5, 5, 6, 7, 0, 3, 0, 6, - 5, 8, 7, 0, 4, 3, 9, 7, 7, 1, 2, 2, 8, 8, 4, 3, 1, 8, 7, 2, 7, 2, 6, - 5, 6, 4, 7, 8, 0, 6, 6, 2, 3, 0, 3, 3, 7, 2, 6, 9, 7, 6, 4, 8, 5, 5, - 9, 3, 7, 9, 5, 3, 1, 1, 9, 2, 4, 8, 1, 7, 3, 5, 9, 8, 5, 6, 6, 5, 7, - 5, 7, 4, 5, 6, 1, 2, 7, 9, 0, 6, 0, 2, 3, 9, 8, 7, 4, 3, 1, 2, 4, 9, - 7, 4, 8, 3, 0, 3, 2, 7, 7, 0, 0, 7, 2, 0, 6, 0, 2, 9, 2, 6, 5, 7, 8, - 9, 8, 3, 4, 7, 2, 0, 0, 7, 5, 9, 9, 6, 7, 5, 2, 7, 4, 2, 9, 6, 6, 3, - 1, 2, 0, 8, 3, 2, 8, 0, 5, 1, 0, 9, 1, 6, 3, 1, 3, 7, 7, 5, 7, 4, 4, - 4, 1, 9, 2, 6, 7, 1, 3, 6, 2, 5, 8, 2, 4, 0, 7, 4, 3, 6, 7, 4, 9, 4, - 9, 5, 0, 5, 1, 0, 0, 9, 1, 4, 8, 2, 9, 6, 7, 5, 3, 5, 0, 8, 3, 4, 0, - 7, 5, 8, 5, 9, 4, 0, 2, 7, 1, 9, 9, 6, 1, 2, 8, 5, 7, 8, 5, 0, 4, 9, - 6, 7, 6, 6, 5, 6, 2, 6, 8, 0, 9, 7, 3, 3, 3, 4, 6, 5, 9, 0, 1, 6, 8, - 9, 3, 3, 9, 2, 0, 2, 1, 0, 0, 8, 7, 6, 3, 4, 4, 9, 7, 5, 8, 5, 1, 5, - 2, 3, 6, 2, 0, 9, 1, 3, 0, 3, 3, 6, 9, 4, 2, 0, 2, 3, 1, 9, 0, 2, 5, - 2, 0, 8, 6, 0, 9, 8, 8, 8, 3, 1, 4, 5, 0, 3, 0, 4, 5, 4, 9, 2, 8, 2, - 1, 9, 0, 8, 2, 2, 3, 2, 5, 6, 3, 1, 5, 1, 9, 0, 4, 6, 4, 4, 8, 3, 8, - 9, 9, 3, 9, 9, 2, 2, 1, 7, 3, 8, 7, 6, 9, 0, 4, 2, 7, 8, 4, 9, 3, 1, - 3, 6, 1, 3, 7, 8, 0, 5, 7, 3, 3, 2, 8, 9, 4, 8, 6, 6, 9, 4, 2, 5, 7, - 9, 3, 8, 2, 5, 6, 9, 3, 4, 3, 3, 2, 0, 0, 4, 7, 7, 5, 9, 5, 5, 6, 9, - 4, 9, 3, 1, 5, 3, 1, 5, 3, 2, 2, 3, 4, 4, 7, 5, 0, 5, 4, 3, 3, 2, 1, - 4, 1, 8, 5, 1, 7, 7, 7, 8, 6, 5, 2, 3, 2, 1, 3, 1, 0, 2, 0, 9, 8, 6, - 5, 3, 4, 6, 6, 7, 5, 8, 1, 4, 8, 1, 4, 5, 7, 2, 1, 9, 1, 7, 1, 4, 5, - 9, 8, 3, 1, 3, 8, 6, 3, 0, 0, 0, 6, 7, 4, 3, 4, 3, 6, 5, 0, 9, 0, 9, - 4, 2, 8, 4, 1, 7, 3, 9, 7, 6, 5, 2, 8, 0, 8, 3, 8, 6, 2, 3, 3, 0, 8, - 0, 2, 9, 7, 7, 1, 4, 7, 3, 8, 2, 0, 1, 6, 2, 4, 1, 5, 1, 2, 7, 2, 0, - 3, 1, 6, 0, 4, 4, 5, 5, 6, 6, 5, 1, 7, 7, 0, 8, 6, 3, 5, 8, 4, 4, 8, - 2, 6, 3, 8, 1, 2, 9, 4, 3, 7, 4, 2, 9, 4, 0, 1, 4, 7, 8, 0, 3, 1, 2, - 0, 8, 5, 6, 5, 7, 6, 3, 9, 8, 7, 1, 2, 4, 2, 4, 2, 2, 3, 2, 3, 3, 2, - 5, 7, 5, 5, 1, 0, 6, 2, 2, 3, 6, 3, 3, 4, 2, 1, 8, 4, 2, 8, 7, 6, 1, - 2, 2, 5, 9, 7, 1, 5, 2, 8, 6, 5, 5, 1, 7, 2, 6, 5, 7, 8, 3, 3, 5, 8, - 6, 4, 8, 0, 0, 4, 2, 6, 3, 2, 8, 3, 1, 6, 8, 4, 8, 9, 3, 8, 3, 3, 6, - 5, 3, 4, 9, 0, 3, 4, 2, 8, 1, 9, 8, 0, 6, 6, 5, 7, 9, 3, 0, 3, 9, 2, - 9, 1, 1, 3, 2, 7, 7, 6, 8, 2, 8, 9, 0, 6, 2, 5, 1, 6, 5, 7, 9, 2, 1, - 2, 1, 3, 8, 2, 9, 9, 8, 0, 4, 7, 3, 6, 3, 8, 4, 4, 3, 9, 7, 1, 5, 0, - 1, 3, 4, 7, 0, 6, 9, 6, 2, 1, 1, 2, 3, 2, 0, 9, 8, 8, 2, 9, 4, 8, 1, - 7, 9, 7, 8, 2, 6, 2, 5, 6, 1, 5, 7, 4, 4, 4, 4, 0, 1, 4, 9, 1, 5, 4, - 4, 7, 1, 8, 3, 3, 8, 6, 9, 4, 4, 0, 6, 6, 9, 4, 2, 8, 5, 6, 7, 2, 3, - 2, 2, 9, 9, 7, 6, 1, 4, 0, 2, 4, 4, 7, 2, 2, 7, 5, 5, 4, 1, 9, 0, 9, - 4, 1, 8, 6, 9, 6, 3, 6, 4, 9, 5, 1, 0, 4, 0, 4, 6, 7, 1, 6, 3, 3, 1, - 5, 3, 7, 7, 4, 4, 7, 4, 3, 5, 5, 9, 6, 3, 3, 3, 6, 8, 3, 5, 7, 2, 7, - 6, 4, 3, 1, 6, 8, 8, 4, 9, 5, 9, 1, 0, 4, 8, 5, 7, 5, 7, 1, 8, 2, 3, - 1, 5, 1, 9, 7, 9, 0, 3, 9, 3, 2, 5, 1, 9, 9, 9, 9, 4, 8, 7, 4, 2, 4, - 9, 3, 4, 6, 7, 9, 0, 0, 3, 6, 9, 8, 1, 8, 1, 9, 1, 5, 1, 3, 5, 2, 4, - 8, 8, 7, 8, 0, 3, 0, 6, 9, 4, 5, 9, 3, 8, 8, 7, 9, 7, 9, 7, 6, 7, 5, - 5, 4, 0, 9, 9, 1, 0, 7, 5, 9, 7, 8, 0, 2, 0, 2, 4, 4, 0, 4, 7, 5, 1, - 9, 7, 1, 2, 6, 7, 4, 1, 5, 8, 6, 8, 6, 6, 1, 9, 4, 4, 9, 9, 7, 6, 8, - 4, 9, 3, 6, 6, 1, 1, 9, 6, 9, 1, 9, 2, 5, 1, 5, 6, 0, 1, 1, 2, 1, 1, - 6, 8, 6, 6, 9, 1, 6, 1, 3, 2, 2, 5, 4, 2, 6, 0, 2, 2, 5, 0, 1, 2, 5, - 4, 7, 2, 4, 8, 6, 5, 0, 8, 1, 0, 8, 1, 4, 3, 9, 0, 6, 3, 7, 3, 4, 5, - 6, 0, 9, 7, 3, 1, 5, 7, 8, 0, 3, 2, 9, 3, 0, 3, 3, 1, 6, 4, 0, 6, 9, - 4, 9, 9, 1, 9, 6, 7, 3, 3, 3, 5, 8, 8, 9, 3, 6, 9, 1, 7, 1, 5, 8, 4, - 2, 3, 8, 7, 1, 3, 4, 0, 7, 5, 5, 5, 1, 4, 4, 2, 7, 8, 1, 9, 3, 1, 5, - 9, 6, 0, 6, 4, 7, 2, 1, 2, 3, 2, 4, 5, 6, 1, 5, 0, 1, 2, 7, 2, 5, 7, - 6, 9, 9, 5, 9, 4, 5, 4, 1, 4, 0, 3, 9, 9, 1, 0, 4, 5, 4, 7, 7, 1, 0, - 3, 5, 3, 5, 0, 9, 9, 7, 8, 9, 3, 0, 2, 0, 5, 3, 1, 3, 4, 0, 2, 6, 4, - 6, 4, 7, 4, 1, 8, 4, 8, 6, 1, 1, 0, 2, 3, 0, 5, 1, 9, 2, 1, 0, 9, 3, - 0, 0, 4, 4, 7, 5 - ], - [67, 66]); - - const c = tf.matMul(a, b); - const cData = await c.data(); - - expect(c.shape).toEqual([65, 66]); - test_util.expectArraysClose(cData, [ - 1017, 1086, 958, 925, 1117, 1018, 1092, 1180, 1055, 1141, 1061, 970, - 1200, 969, 1066, 1007, 1241, 909, 980, 1141, 1084, 889, 971, 1042, - 1087, 985, 1019, 929, 1112, 1239, 1155, 966, 984, 1154, 1146, 1117, - 1264, 1059, 960, 1265, 1024, 1071, 1288, 1086, 1219, 1070, 1168, 962, - 1098, 1041, 937, 1002, 1102, 1110, 940, 1120, 1028, 1062, 1162, 1049, - 904, 1065, 1056, 1230, 853, 1013, 1579, 1519, 1552, 1377, 1478, 1375, - 1397, 1820, 1672, 1626, 1633, 1374, 1514, 1420, 1371, 1357, 1689, 1346, - 1378, 1497, 1424, 1387, 1495, 1601, 1455, 1594, 1716, 1375, 1459, 1523, - 1601, 1615, 1583, 1462, 1669, 1600, 1879, 1527, 1370, 1692, 1496, 1541, - 1894, 1470, 1784, 1530, 1792, 1410, 1615, 1713, 1465, 1420, 1671, 1637, - 1472, 1473, 1421, 1389, 1638, 1330, 1329, 1531, 1475, 1720, 1592, 1416, - 1759, 1748, 1467, 1582, 1749, 1484, 1636, 1844, 1601, 1643, 1683, 1514, - 1721, 1438, 1580, 1511, 1716, 1480, 1477, 1671, 1765, 1478, 1577, 1617, - 1638, 1612, 1633, 1449, 1690, 1733, 1758, 1591, 1810, 1655, 1911, 1447, - 1939, 1687, 1401, 1655, 1669, 1624, 2213, 1648, 1867, 1745, 1872, 1551, - 1799, 1824, 1505, 1542, 1635, 1826, 1590, 1596, 1598, 1416, 1645, 1470, - 1352, 1511, 1773, 1780, 1593, 1534, 1424, 1329, 1326, 1238, 1426, 1276, - 1175, 1584, 1398, 1429, 1525, 1254, 1505, 1137, 1213, 1242, 1575, 1174, - 1169, 1379, 1433, 1121, 1357, 1371, 1322, 1193, 1412, 1197, 1294, 1392, - 1362, 1403, 1576, 1291, 1458, 1340, 1664, 1247, 1186, 1359, 1283, 1290, - 1624, 1326, 1520, 1423, 1613, 1339, 1417, 1480, 1399, 1185, 1427, 1356, - 1397, 1303, 1248, 1208, 1419, 1125, 1158, 1330, 1203, 1532, 1220, 1325, - 1231, 1121, 1095, 974, 1179, 953, 1085, 1392, 1102, 1154, 1314, 1045, - 1204, 999, 1059, 1089, 1305, 1053, 973, 1190, 1200, 937, 1097, 1184, - 1143, 1131, 1182, 1121, 1219, 1233, 1134, 1251, 1063, 1151, 1209, 1144, - 1362, 1261, 1026, 1398, 1007, 1093, 1363, 1082, 1316, 1070, 1237, 1068, - 1220, 1238, 1094, 1076, 1152, 1202, 1114, 1221, 1159, 1184, 1200, 983, - 905, 1127, 1203, 1310, 924, 1198, 1435, 1411, 1119, 1250, 1485, 1265, - 1245, 1584, 1370, 1411, 1452, 1162, 1425, 1150, 1254, 1227, 1508, 1200, - 1171, 1468, 1419, 1218, 1239, 1186, 1198, 1255, 1368, 1223, 1478, 1354, - 1299, 1267, 1336, 1300, 1620, 1226, 1577, 1435, 1317, 1482, 1259, 1231, - 1568, 1326, 1524, 1329, 1477, 1231, 1404, 1388, 1254, 1184, 1301, 1414, - 1385, 1393, 1283, 1292, 1357, 1211, 1062, 1243, 1309, 1487, 1240, 1286, - 1508, 1506, 1214, 1284, 1419, 1317, 1234, 1545, 1556, 1442, 1439, 1175, - 1441, 1304, 1355, 1308, 1519, 1154, 1267, 1275, 1411, 1240, 1460, 1292, - 1292, 1197, 1451, 1181, 1371, 1391, 1339, 1293, 1392, 1465, 1514, 1363, - 1644, 1279, 1137, 1500, 1311, 1502, 1699, 1402, 1518, 1464, 1522, 1181, - 1545, 1604, 1299, 1460, 1273, 1425, 1256, 1251, 1342, 1278, 1416, 1213, - 1231, 1246, 1322, 1521, 1200, 1295, 1665, 1411, 1342, 1406, 1607, 1287, - 1335, 1776, 1378, 1636, 1504, 1329, 1573, 1227, 1453, 1305, 1655, 1318, - 1224, 1443, 1547, 1345, 1425, 1369, 1400, 1191, 1581, 1284, 1484, 1511, - 1430, 1342, 1553, 1520, 1580, 1386, 1709, 1419, 1258, 1477, 1379, 1567, - 1765, 1446, 1611, 1399, 1693, 1281, 1469, 1561, 1331, 1398, 1403, 1473, - 1353, 1394, 1426, 1348, 1403, 1235, 1166, 1333, 1390, 1653, 1174, 1298, - 1620, 1389, 1235, 1201, 1390, 1262, 1361, 1576, 1483, 1387, 1324, 1099, - 1354, 1125, 1234, 1196, 1394, 1142, 1135, 1366, 1253, 1085, 1226, 1238, - 1221, 1155, 1295, 1242, 1355, 1375, 1379, 1277, 1474, 1359, 1552, 1296, - 1469, 1220, 1141, 1337, 1206, 1230, 1476, 1198, 1483, 1465, 1536, 1115, - 1447, 1378, 1203, 1311, 1280, 1305, 1345, 1361, 1277, 1292, 1220, 1231, - 1135, 1270, 1280, 1362, 1185, 1240, 1250, 1243, 1229, 1124, 1187, 1209, - 1044, 1315, 1281, 1378, 1319, 1148, 1331, 1043, 1075, 1152, 1410, 1077, - 1234, 1224, 1159, 1124, 1192, 1244, 1225, 1205, 1436, 1178, 1158, 1239, - 1225, 1214, 1334, 1206, 1427, 1202, 1473, 1268, 1066, 1366, 1225, 1302, - 1523, 1167, 1418, 1158, 1397, 1043, 1281, 1254, 1078, 1199, 1326, 1370, - 1295, 1212, 1054, 1196, 1233, 1148, 1066, 1250, 1185, 1411, 1196, 1096, - 1375, 1351, 1218, 1097, 1459, 1128, 1351, 1564, 1357, 1400, 1371, 1180, - 1343, 1277, 1168, 1242, 1487, 1079, 1065, 1292, 1304, 1169, 1262, 1131, - 1224, 1213, 1317, 1118, 1298, 1396, 1314, 1160, 1294, 1368, 1568, 1263, - 1668, 1198, 981, 1346, 1113, 1362, 1544, 1403, 1545, 1254, 1492, 1206, - 1403, 1467, 1234, 1263, 1216, 1249, 1214, 1370, 1332, 1327, 1287, 1101, - 1083, 1192, 1464, 1396, 1112, 1380, 1572, 1428, 1350, 1355, 1516, 1294, - 1407, 1742, 1510, 1569, 1602, 1191, 1450, 1302, 1421, 1338, 1574, 1213, - 1125, 1440, 1362, 1199, 1307, 1322, 1422, 1449, 1479, 1335, 1427, 1526, - 1547, 1321, 1502, 1483, 1598, 1440, 1669, 1406, 1233, 1483, 1331, 1409, - 1575, 1450, 1561, 1422, 1530, 1231, 1587, 1621, 1258, 1295, 1338, 1465, - 1495, 1489, 1454, 1504, 1375, 1264, 1249, 1235, 1371, 1548, 1235, 1260, - 1578, 1523, 1356, 1263, 1589, 1304, 1291, 1747, 1575, 1527, 1549, 1407, - 1424, 1201, 1369, 1408, 1645, 1203, 1322, 1370, 1488, 1225, 1387, 1362, - 1296, 1398, 1553, 1328, 1459, 1621, 1399, 1497, 1568, 1522, 1556, 1517, - 1872, 1516, 1257, 1576, 1393, 1467, 1766, 1468, 1617, 1512, 1512, 1312, - 1678, 1615, 1444, 1448, 1438, 1550, 1513, 1298, 1487, 1466, 1514, 1263, - 1266, 1271, 1474, 1747, 1270, 1418, 1704, 1559, 1474, 1575, 1725, 1490, - 1461, 1846, 1711, 1777, 1693, 1471, 1652, 1478, 1447, 1557, 1734, 1361, - 1398, 1645, 1604, 1397, 1644, 1460, 1488, 1497, 1639, 1450, 1546, 1625, - 1611, 1644, 1671, 1655, 1753, 1536, 1912, 1628, 1449, 1774, 1562, 1618, - 1928, 1526, 1843, 1649, 1800, 1510, 1694, 1791, 1477, 1531, 1564, 1718, - 1643, 1452, 1569, 1442, 1670, 1525, 1425, 1476, 1623, 1747, 1486, 1595, - 1248, 1134, 1095, 972, 1315, 1142, 1148, 1371, 1321, 1256, 1176, 1080, - 1188, 1024, 1138, 1098, 1351, 1086, 1039, 1286, 1181, 892, 975, 1051, - 1118, 1131, 1258, 1088, 1197, 1231, 1238, 994, 1228, 1203, 1176, 1218, - 1446, 1103, 1053, 1160, 1056, 1068, 1314, 1191, 1275, 1269, 1291, 1075, - 1228, 1265, 1185, 1204, 1111, 1287, 1124, 1257, 1115, 1196, 1051, 981, - 1001, 1261, 1155, 1245, 1051, 1148, 1350, 1655, 1178, 1205, 1437, 1279, - 1376, 1558, 1514, 1487, 1483, 1280, 1492, 1181, 1209, 1460, 1621, 1113, - 1453, 1345, 1425, 1138, 1307, 1335, 1380, 1369, 1429, 1251, 1365, 1479, - 1469, 1342, 1461, 1258, 1722, 1327, 1687, 1380, 1233, 1386, 1341, 1386, - 1641, 1441, 1515, 1497, 1570, 1275, 1566, 1550, 1290, 1408, 1483, 1568, - 1340, 1378, 1353, 1363, 1272, 1241, 1227, 1266, 1557, 1501, 1354, 1345, - 1440, 1161, 1078, 1038, 1201, 1212, 1115, 1370, 1272, 1340, 1242, 1054, - 1261, 931, 1079, 1078, 1378, 1039, 1018, 1073, 1285, 991, 1110, 1133, - 1119, 997, 1212, 1060, 1122, 1303, 1114, 1206, 1330, 1235, 1266, 1165, - 1395, 1046, 1052, 1124, 1183, 1131, 1495, 1132, 1310, 1250, 1293, 1200, - 1218, 1193, 1060, 1139, 1208, 1298, 1317, 1053, 1086, 1079, 1120, 1006, - 1070, 1108, 1159, 1322, 985, 1136, 1524, 1463, 1256, 1184, 1500, 1327, - 1405, 1638, 1388, 1430, 1444, 1176, 1537, 1318, 1180, 1245, 1594, 1107, - 1070, 1370, 1322, 1272, 1309, 1325, 1465, 1258, 1487, 1339, 1404, 1587, - 1466, 1395, 1427, 1467, 1601, 1377, 1794, 1464, 1106, 1529, 1206, 1482, - 1660, 1415, 1680, 1351, 1658, 1304, 1435, 1596, 1260, 1319, 1378, 1387, - 1400, 1406, 1397, 1327, 1561, 1345, 1131, 1272, 1510, 1472, 1181, 1443, - 1491, 1531, 1197, 1316, 1411, 1354, 1403, 1749, 1527, 1462, 1493, 1290, - 1571, 1331, 1162, 1305, 1458, 1271, 1269, 1367, 1448, 1107, 1377, 1314, - 1331, 1333, 1375, 1366, 1412, 1537, 1480, 1293, 1423, 1420, 1601, 1243, - 1804, 1414, 1279, 1431, 1413, 1392, 1804, 1420, 1630, 1359, 1579, 1302, - 1557, 1609, 1430, 1263, 1343, 1480, 1324, 1517, 1437, 1213, 1466, 1322, - 1262, 1352, 1555, 1436, 1238, 1477, 1546, 1674, 1285, 1258, 1479, 1313, - 1358, 1631, 1482, 1504, 1530, 1354, 1575, 1221, 1376, 1298, 1658, 1189, - 1237, 1485, 1489, 1310, 1366, 1486, 1493, 1446, 1520, 1335, 1522, 1539, - 1647, 1452, 1474, 1498, 1815, 1379, 1763, 1537, 1363, 1582, 1335, 1341, - 1827, 1449, 1611, 1515, 1611, 1328, 1594, 1618, 1361, 1347, 1524, 1630, - 1521, 1509, 1447, 1298, 1568, 1349, 1259, 1320, 1590, 1690, 1301, 1392, - 1548, 1330, 1358, 1253, 1601, 1308, 1364, 1610, 1476, 1547, 1485, 1290, - 1564, 1083, 1348, 1145, 1482, 1172, 1212, 1272, 1545, 1226, 1316, 1378, - 1328, 1273, 1417, 1211, 1304, 1404, 1395, 1335, 1530, 1552, 1600, 1395, - 1528, 1330, 1260, 1402, 1288, 1405, 1762, 1336, 1495, 1487, 1400, 1337, - 1521, 1490, 1204, 1326, 1362, 1521, 1447, 1251, 1320, 1343, 1483, 1258, - 1073, 1324, 1438, 1557, 1247, 1255, 1541, 1590, 1368, 1439, 1673, 1432, - 1545, 1754, 1526, 1555, 1574, 1355, 1641, 1368, 1523, 1466, 1738, 1378, - 1319, 1694, 1605, 1289, 1527, 1396, 1491, 1268, 1520, 1423, 1547, 1672, - 1586, 1487, 1640, 1597, 1761, 1497, 1831, 1477, 1291, 1750, 1398, 1467, - 1912, 1509, 1732, 1555, 1734, 1354, 1625, 1596, 1400, 1428, 1588, 1584, - 1557, 1535, 1529, 1450, 1563, 1544, 1309, 1516, 1582, 1660, 1412, 1317, - 1238, 1298, 1211, 1321, 1435, 1212, 1218, 1685, 1275, 1379, 1385, 1214, - 1436, 1289, 1298, 1102, 1498, 1175, 1127, 1497, 1508, 1267, 1307, 1357, - 1330, 1335, 1438, 1127, 1374, 1441, 1279, 1375, 1413, 1289, 1377, 1323, - 1622, 1468, 1121, 1406, 1389, 1246, 1665, 1427, 1511, 1402, 1584, 1283, - 1393, 1325, 1158, 1219, 1421, 1358, 1380, 1430, 1261, 1234, 1448, 1066, - 1037, 1192, 1370, 1480, 1300, 1296, 1378, 1382, 1300, 1243, 1254, 1325, - 1216, 1541, 1417, 1472, 1382, 1139, 1390, 1134, 1231, 1234, 1539, 1151, - 1300, 1322, 1408, 1149, 1190, 1198, 1321, 1288, 1522, 1226, 1310, 1471, - 1408, 1253, 1301, 1401, 1563, 1203, 1568, 1376, 1231, 1465, 1256, 1250, - 1565, 1369, 1517, 1334, 1501, 1121, 1494, 1462, 1191, 1292, 1257, 1490, - 1300, 1374, 1312, 1330, 1414, 1261, 1144, 1370, 1345, 1485, 1256, 1217, - 1326, 1396, 1122, 1061, 1434, 1331, 1255, 1483, 1400, 1373, 1299, 1049, - 1382, 1213, 1148, 1297, 1493, 1072, 1131, 1346, 1333, 1124, 1228, 1302, - 1303, 1364, 1332, 1205, 1225, 1497, 1301, 1323, 1370, 1245, 1595, 1253, - 1561, 1303, 1146, 1298, 1197, 1275, 1478, 1258, 1444, 1447, 1529, 1252, - 1429, 1345, 1255, 1269, 1344, 1373, 1341, 1393, 1265, 1255, 1267, 1192, - 1081, 1266, 1280, 1393, 1233, 1315, 1449, 1368, 1300, 1266, 1373, 1245, - 1280, 1623, 1384, 1554, 1432, 1176, 1451, 1283, 1370, 1104, 1390, 1101, - 1143, 1336, 1441, 1339, 1422, 1415, 1483, 1312, 1499, 1260, 1257, 1384, - 1324, 1351, 1391, 1392, 1474, 1338, 1513, 1310, 1147, 1528, 1253, 1241, - 1701, 1310, 1501, 1409, 1467, 1155, 1400, 1499, 1203, 1231, 1252, 1378, - 1335, 1333, 1238, 1188, 1423, 1209, 1105, 1304, 1452, 1556, 1258, 1178, - 1272, 1456, 1125, 1095, 1353, 1133, 1121, 1383, 1313, 1381, 1451, 1144, - 1380, 1146, 1012, 1212, 1417, 1018, 1085, 1287, 1239, 1032, 1191, 1217, - 1283, 1199, 1366, 1226, 1288, 1428, 1415, 1169, 1331, 1280, 1396, 1245, - 1596, 1280, 1146, 1361, 1268, 1253, 1551, 1302, 1338, 1246, 1431, 1130, - 1486, 1373, 1185, 1241, 1189, 1384, 1184, 1296, 1352, 1259, 1363, 1177, - 1050, 1180, 1210, 1436, 1114, 1256, 1632, 1461, 1415, 1322, 1474, 1415, - 1471, 1916, 1663, 1626, 1569, 1387, 1541, 1310, 1530, 1386, 1726, 1309, - 1341, 1427, 1481, 1333, 1438, 1519, 1468, 1545, 1523, 1466, 1426, 1619, - 1545, 1535, 1585, 1446, 1656, 1575, 1943, 1491, 1364, 1645, 1397, 1431, - 1841, 1485, 1650, 1508, 1649, 1436, 1559, 1813, 1608, 1347, 1557, 1641, - 1586, 1569, 1463, 1450, 1587, 1246, 1373, 1437, 1516, 1746, 1383, 1616, - 1719, 1645, 1450, 1405, 1522, 1454, 1419, 1883, 1583, 1691, 1617, 1492, - 1800, 1442, 1633, 1457, 1722, 1304, 1379, 1552, 1825, 1495, 1611, 1524, - 1519, 1485, 1752, 1437, 1532, 1630, 1553, 1544, 1653, 1736, 1781, 1452, - 1795, 1614, 1389, 1532, 1589, 1568, 2020, 1577, 1753, 1714, 1848, 1433, - 1722, 1693, 1430, 1602, 1618, 1739, 1640, 1563, 1544, 1501, 1522, 1388, - 1409, 1443, 1634, 1807, 1467, 1484, 1611, 1589, 1547, 1421, 1635, 1359, - 1402, 1797, 1567, 1662, 1769, 1438, 1587, 1414, 1611, 1496, 1788, 1359, - 1363, 1486, 1676, 1319, 1491, 1553, 1557, 1430, 1785, 1403, 1576, 1666, - 1585, 1495, 1540, 1595, 1742, 1432, 1890, 1444, 1354, 1781, 1362, 1530, - 1879, 1630, 1769, 1504, 1661, 1296, 1730, 1593, 1382, 1456, 1566, 1629, - 1566, 1626, 1519, 1559, 1449, 1407, 1258, 1467, 1503, 1766, 1416, 1372, - 1406, 1337, 1185, 1092, 1354, 1131, 1090, 1465, 1212, 1393, 1363, 1183, - 1386, 1217, 1246, 1043, 1421, 1150, 1052, 1209, 1351, 1155, 1181, 1267, - 1228, 1126, 1332, 1168, 1278, 1209, 1325, 1155, 1323, 1338, 1342, 1149, - 1574, 1166, 1163, 1313, 1215, 1266, 1658, 1260, 1380, 1296, 1346, 1250, - 1385, 1203, 1165, 1255, 1282, 1291, 1228, 1304, 1202, 1134, 1277, 1069, - 1009, 1166, 1271, 1434, 1057, 1104, 1301, 1347, 1176, 1160, 1377, 1129, - 1359, 1574, 1328, 1359, 1261, 1018, 1411, 1174, 1305, 1218, 1485, 1083, - 1120, 1398, 1329, 1168, 1258, 1314, 1389, 1347, 1352, 1224, 1391, 1404, - 1494, 1281, 1342, 1323, 1454, 1148, 1570, 1355, 1211, 1519, 1106, 1106, - 1605, 1237, 1521, 1431, 1500, 1200, 1494, 1460, 1194, 1169, 1304, 1362, - 1353, 1263, 1203, 1143, 1354, 1293, 1149, 1347, 1392, 1470, 1250, 1270, - 1505, 1545, 1340, 1220, 1514, 1245, 1442, 1607, 1501, 1546, 1570, 1300, - 1454, 1279, 1390, 1392, 1654, 1325, 1183, 1435, 1576, 1125, 1301, 1327, - 1337, 1381, 1455, 1303, 1410, 1497, 1569, 1474, 1412, 1591, 1595, 1312, - 1751, 1441, 1255, 1485, 1367, 1321, 1703, 1422, 1537, 1376, 1543, 1323, - 1657, 1503, 1385, 1307, 1384, 1494, 1471, 1495, 1454, 1313, 1436, 1347, - 1163, 1447, 1509, 1579, 1248, 1342, 1489, 1378, 1253, 1272, 1442, 1287, - 1278, 1624, 1429, 1389, 1398, 1172, 1462, 1345, 1301, 1217, 1510, 1282, - 1106, 1457, 1433, 1176, 1341, 1331, 1331, 1343, 1397, 1347, 1405, 1457, - 1459, 1389, 1471, 1406, 1566, 1489, 1645, 1404, 1204, 1511, 1294, 1417, - 1751, 1263, 1530, 1434, 1563, 1356, 1530, 1583, 1384, 1389, 1468, 1443, - 1278, 1315, 1451, 1237, 1422, 1206, 1191, 1331, 1358, 1641, 1187, 1236, - 1272, 1202, 1111, 1073, 1256, 943, 1118, 1375, 1158, 1163, 1271, 1059, - 1342, 1032, 1034, 1015, 1248, 1014, 969, 1202, 1144, 991, 1162, 1228, - 1217, 1029, 1290, 1125, 1158, 1129, 1188, 1146, 1292, 1183, 1315, 1054, - 1359, 1128, 901, 1336, 1102, 1160, 1476, 1138, 1284, 1212, 1441, 1017, - 1244, 1276, 1090, 1198, 1154, 1278, 1107, 1167, 1162, 951, 1171, 1062, - 1044, 1045, 1155, 1273, 1056, 1253, 1536, 1525, 1348, 1385, 1478, 1268, - 1375, 1726, 1509, 1669, 1621, 1462, 1534, 1350, 1497, 1311, 1606, 1205, - 1390, 1567, 1582, 1373, 1628, 1604, 1285, 1410, 1569, 1298, 1349, 1452, - 1515, 1627, 1557, 1517, 1667, 1411, 1847, 1610, 1296, 1620, 1490, 1511, - 1895, 1504, 1609, 1448, 1630, 1247, 1726, 1654, 1439, 1375, 1584, 1561, - 1569, 1634, 1442, 1329, 1621, 1432, 1246, 1413, 1500, 1752, 1393, 1406, - 1240, 1157, 1171, 1294, 1313, 1073, 1179, 1589, 1288, 1423, 1360, 1112, - 1350, 1178, 1357, 1113, 1422, 1147, 1118, 1353, 1242, 1059, 1270, 1228, - 1201, 1245, 1297, 1008, 1256, 1346, 1245, 1179, 1345, 1368, 1385, 1191, - 1517, 1296, 1145, 1336, 1273, 1191, 1502, 1384, 1391, 1262, 1523, 1224, - 1417, 1361, 1173, 972, 1294, 1239, 1282, 1329, 1195, 1104, 1351, 1162, - 1115, 1133, 1235, 1430, 1156, 1067, 1250, 1201, 1268, 1283, 1299, 1070, - 1086, 1462, 1265, 1336, 1417, 1296, 1300, 1233, 1302, 1236, 1427, 1185, - 1142, 1433, 1299, 1114, 1425, 1298, 1116, 1263, 1457, 1220, 1211, 1165, - 1303, 1307, 1263, 1221, 1380, 1134, 1596, 1255, 1248, 1396, 1298, 1255, - 1556, 1321, 1302, 1222, 1442, 1120, 1424, 1448, 1300, 1109, 1366, 1358, - 1339, 1408, 1270, 1225, 1403, 1122, 1072, 1253, 1169, 1420, 1233, 1154, - 1368, 1426, 1245, 1048, 1401, 1242, 1266, 1481, 1397, 1321, 1256, 1221, - 1433, 1103, 1123, 1238, 1465, 1067, 1243, 1320, 1220, 1097, 1172, 1234, - 1334, 1312, 1503, 1281, 1276, 1348, 1453, 1178, 1479, 1304, 1441, 1257, - 1602, 1284, 1166, 1415, 1283, 1277, 1613, 1311, 1495, 1455, 1409, 1056, - 1500, 1419, 1311, 1347, 1309, 1413, 1325, 1232, 1239, 1177, 1244, 1154, - 1129, 1286, 1262, 1394, 1245, 1139, 1707, 1657, 1377, 1465, 1391, 1324, - 1401, 1842, 1617, 1663, 1545, 1338, 1506, 1325, 1483, 1395, 1627, 1353, - 1336, 1422, 1585, 1300, 1451, 1407, 1435, 1416, 1544, 1432, 1506, 1646, - 1604, 1475, 1611, 1519, 1689, 1300, 1840, 1557, 1299, 1537, 1513, 1452, - 1859, 1569, 1827, 1640, 1769, 1358, 1543, 1728, 1411, 1316, 1479, 1572, - 1553, 1438, 1506, 1269, 1560, 1387, 1420, 1294, 1472, 1660, 1415, 1370, - 1492, 1410, 1263, 1313, 1665, 1278, 1329, 1687, 1492, 1574, 1431, 1245, - 1518, 1314, 1449, 1300, 1586, 1203, 1134, 1458, 1571, 1264, 1307, 1403, - 1494, 1402, 1546, 1279, 1434, 1504, 1590, 1362, 1458, 1481, 1734, 1388, - 1758, 1511, 1298, 1546, 1265, 1427, 1734, 1461, 1594, 1440, 1542, 1272, - 1520, 1660, 1308, 1293, 1431, 1508, 1523, 1487, 1499, 1330, 1447, 1320, - 1113, 1380, 1420, 1625, 1469, 1385, 1410, 1520, 1232, 1170, 1427, 1109, - 1281, 1567, 1371, 1503, 1385, 1274, 1453, 1228, 1350, 1230, 1557, 1212, - 1208, 1482, 1421, 1137, 1228, 1440, 1329, 1361, 1463, 1402, 1336, 1410, - 1456, 1391, 1366, 1475, 1673, 1258, 1577, 1436, 1195, 1546, 1275, 1346, - 1699, 1387, 1456, 1327, 1510, 1195, 1467, 1419, 1208, 1280, 1413, 1493, - 1463, 1540, 1445, 1251, 1335, 1187, 1071, 1364, 1387, 1599, 1273, 1263, - 1522, 1385, 1268, 1340, 1510, 1267, 1283, 1559, 1429, 1447, 1563, 1152, - 1455, 1100, 1255, 1308, 1508, 1304, 1175, 1278, 1372, 1083, 1236, 1424, - 1273, 1169, 1540, 1263, 1473, 1487, 1466, 1315, 1535, 1383, 1545, 1344, - 1636, 1303, 1225, 1402, 1262, 1322, 1717, 1223, 1510, 1482, 1598, 1234, - 1599, 1397, 1262, 1408, 1330, 1399, 1354, 1337, 1278, 1282, 1297, 1331, - 1092, 1186, 1297, 1409, 1264, 1330, 1232, 1201, 984, 1019, 1146, 996, - 963, 1329, 1181, 1239, 1177, 972, 1150, 1087, 1042, 1056, 1201, 1006, - 929, 1144, 1170, 1049, 1058, 1128, 1024, 1219, 1219, 1007, 1104, 1219, - 1149, 1097, 1197, 1311, 1254, 1061, 1378, 1164, 836, 1294, 1110, 1146, - 1510, 1129, 1325, 1160, 1190, 1000, 1327, 1143, 1033, 1101, 1103, 1214, - 1206, 1056, 1146, 998, 1111, 1002, 929, 987, 1226, 1343, 1015, 966, - 1361, 1307, 1148, 1274, 1428, 1312, 1165, 1505, 1407, 1348, 1288, 1118, - 1335, 1191, 1258, 1232, 1487, 1072, 1174, 1287, 1389, 1219, 1257, 1296, - 1311, 1343, 1396, 1261, 1258, 1489, 1249, 1410, 1405, 1150, 1504, 1331, - 1612, 1316, 1050, 1450, 1231, 1326, 1589, 1251, 1512, 1411, 1482, 1198, - 1433, 1429, 1249, 1337, 1218, 1426, 1365, 1257, 1296, 1219, 1299, 1203, - 1103, 1207, 1410, 1473, 1257, 1278, 1234, 1158, 1162, 984, 1187, 1163, - 1142, 1360, 1207, 1173, 1058, 1164, 1287, 927, 1099, 1142, 1279, 1023, - 1036, 1177, 1197, 1067, 1135, 1255, 1183, 1159, 1151, 1012, 1097, 1124, - 1157, 1130, 1189, 1230, 1232, 1233, 1442, 1113, 992, 1331, 1178, 1195, - 1454, 1201, 1348, 1138, 1298, 992, 1154, 1209, 1066, 1188, 1305, 1215, - 1188, 1221, 1104, 1053, 1191, 1002, 968, 1131, 1140, 1302, 1052, 1055, - 1579, 1537, 1246, 1301, 1496, 1260, 1336, 1718, 1460, 1499, 1491, 1246, - 1512, 1275, 1439, 1351, 1648, 1175, 1188, 1337, 1471, 1236, 1371, 1454, - 1359, 1368, 1394, 1346, 1493, 1608, 1488, 1526, 1476, 1547, 1576, 1289, - 1795, 1563, 1278, 1619, 1290, 1455, 1834, 1285, 1598, 1462, 1533, 1292, - 1649, 1571, 1284, 1440, 1353, 1424, 1636, 1414, 1432, 1337, 1446, 1345, - 1230, 1322, 1538, 1550, 1210, 1393, 1463, 1526, 1243, 1299, 1427, 1263, - 1319, 1546, 1461, 1499, 1497, 1269, 1379, 1281, 1331, 1223, 1534, 1171, - 1248, 1352, 1486, 1169, 1395, 1347, 1247, 1324, 1472, 1367, 1384, 1425, - 1496, 1567, 1531, 1475, 1484, 1288, 1716, 1412, 1208, 1424, 1239, 1289, - 1703, 1298, 1482, 1542, 1553, 1273, 1643, 1560, 1259, 1406, 1347, 1607, - 1532, 1294, 1294, 1212, 1447, 1322, 1250, 1340, 1445, 1578, 1303, 1296, - 1555, 1566, 1232, 1283, 1518, 1393, 1293, 1631, 1575, 1520, 1523, 1184, - 1416, 1279, 1344, 1293, 1574, 1270, 1229, 1286, 1449, 1368, 1471, 1482, - 1449, 1443, 1552, 1430, 1420, 1368, 1455, 1511, 1476, 1268, 1685, 1437, - 1921, 1412, 1299, 1643, 1257, 1430, 1818, 1447, 1685, 1381, 1608, 1158, - 1562, 1625, 1354, 1363, 1320, 1504, 1482, 1507, 1359, 1260, 1560, 1369, - 1225, 1434, 1425, 1659, 1419, 1419, 1531, 1696, 1102, 1243, 1486, 1364, - 1261, 1619, 1443, 1455, 1517, 1151, 1503, 1255, 1215, 1286, 1515, 1283, - 1136, 1332, 1478, 1104, 1301, 1333, 1390, 1355, 1434, 1335, 1396, 1486, - 1485, 1231, 1476, 1414, 1738, 1286, 1749, 1386, 1224, 1433, 1375, 1349, - 1649, 1449, 1520, 1401, 1656, 1209, 1498, 1343, 1317, 1336, 1263, 1528, - 1376, 1468, 1399, 1337, 1427, 1354, 1205, 1263, 1390, 1507, 1324, 1346, - 1366, 1368, 1219, 1130, 1323, 1177, 1246, 1517, 1321, 1418, 1329, 1211, - 1279, 1151, 1384, 1083, 1433, 1181, 1126, 1336, 1451, 1116, 1312, 1242, - 1306, 1255, 1264, 1142, 1303, 1344, 1346, 1160, 1334, 1351, 1458, 1305, - 1604, 1304, 1164, 1377, 1258, 1199, 1555, 1351, 1427, 1311, 1388, 1140, - 1359, 1326, 1176, 1116, 1304, 1309, 1432, 1466, 1236, 1194, 1362, 1096, - 1196, 1276, 1203, 1529, 1063, 1233, 1412, 1333, 1315, 1207, 1375, 1122, - 1180, 1513, 1390, 1444, 1399, 1305, 1355, 1109, 1248, 1330, 1534, 1252, - 1190, 1368, 1317, 1090, 1336, 1314, 1246, 1181, 1440, 1177, 1324, 1375, - 1347, 1255, 1365, 1412, 1473, 1271, 1590, 1248, 1194, 1526, 1368, 1279, - 1705, 1348, 1472, 1277, 1476, 1153, 1481, 1412, 1320, 1215, 1227, 1384, - 1251, 1251, 1242, 1229, 1497, 1190, 1134, 1347, 1318, 1524, 1238, 1294, - 1437, 1465, 1218, 1282, 1365, 1284, 1280, 1539, 1428, 1407, 1296, 1229, - 1463, 1299, 1215, 1230, 1509, 1138, 1244, 1448, 1432, 1125, 1389, 1249, - 1351, 1250, 1424, 1177, 1318, 1447, 1283, 1307, 1461, 1400, 1494, 1221, - 1643, 1325, 1123, 1467, 1290, 1322, 1627, 1380, 1476, 1307, 1565, 1210, - 1401, 1396, 1286, 1246, 1317, 1374, 1363, 1357, 1284, 1163, 1432, 1145, - 1215, 1406, 1461, 1522, 1199, 1286, 1266, 1313, 1081, 1091, 1227, 1095, - 1082, 1344, 1166, 1319, 1199, 1105, 1274, 1183, 1232, 1097, 1437, 1075, - 1039, 1225, 1245, 1038, 1117, 1212, 1236, 1148, 1352, 1136, 1265, 1296, - 1282, 1183, 1152, 1325, 1395, 1119, 1471, 1202, 1132, 1296, 1170, 1209, - 1496, 1208, 1306, 1151, 1417, 1165, 1274, 1249, 998, 1132, 1150, 1326, - 1201, 1348, 1186, 1155, 1250, 1129, 1044, 1185, 1204, 1450, 1142, 1174, - 1708, 1579, 1418, 1431, 1637, 1474, 1386, 1708, 1633, 1650, 1654, 1333, - 1540, 1327, 1383, 1312, 1789, 1259, 1333, 1449, 1590, 1277, 1367, 1499, - 1490, 1379, 1642, 1351, 1473, 1700, 1496, 1524, 1631, 1453, 1683, 1451, - 1699, 1543, 1288, 1647, 1415, 1455, 1704, 1494, 1672, 1532, 1664, 1409, - 1554, 1592, 1340, 1373, 1481, 1706, 1544, 1521, 1514, 1439, 1579, 1368, - 1332, 1494, 1468, 1620, 1355, 1405, 1692, 1700, 1486, 1480, 1806, 1522, - 1557, 1823, 1703, 1790, 1883, 1414, 1765, 1355, 1531, 1542, 1806, 1318, - 1570, 1560, 1795, 1430, 1576, 1619, 1663, 1551, 1613, 1422, 1530, 1734, - 1738, 1571, 1743, 1592, 1891, 1502, 1942, 1586, 1521, 1624, 1463, 1502, - 1952, 1580, 1751, 1784, 1820, 1606, 1829, 1805, 1601, 1425, 1716, 1821, - 1640, 1581, 1562, 1546, 1563, 1641, 1328, 1494, 1700, 1806, 1567, 1569, - 1447, 1238, 1155, 1199, 1268, 1088, 1217, 1544, 1316, 1332, 1333, 1164, - 1339, 1135, 1184, 1154, 1342, 1146, 1156, 1226, 1242, 1085, 1201, 1226, - 1192, 1252, 1302, 1121, 1303, 1295, 1380, 1249, 1291, 1232, 1395, 1161, - 1563, 1369, 1117, 1195, 1288, 1256, 1551, 1153, 1506, 1254, 1555, 1219, - 1320, 1408, 1265, 1034, 1219, 1345, 1255, 1242, 1200, 1096, 1412, 1127, - 1209, 1253, 1339, 1436, 1226, 1177, 1449, 1488, 1239, 1163, 1459, 1295, - 1434, 1414, 1402, 1489, 1337, 1173, 1321, 1226, 1360, 1292, 1522, 1112, - 1288, 1372, 1330, 1216, 1324, 1272, 1371, 1398, 1436, 1276, 1260, 1459, - 1530, 1236, 1491, 1399, 1588, 1221, 1686, 1401, 1257, 1407, 1130, 1322, - 1580, 1292, 1491, 1409, 1470, 1201, 1534, 1527, 1281, 1287, 1376, 1490, - 1402, 1442, 1272, 1255, 1311, 1409, 1143, 1352, 1431, 1555, 1234, 1191, - 1341, 1206, 1169, 1179, 1426, 1222, 1235, 1566, 1237, 1410, 1442, 1143, - 1339, 1115, 1274, 1323, 1555, 1135, 1102, 1279, 1277, 1113, 1267, 1226, - 1243, 1276, 1297, 1188, 1203, 1373, 1252, 1263, 1323, 1333, 1398, 1284, - 1662, 1244, 1115, 1416, 1191, 1322, 1535, 1319, 1415, 1155, 1415, 1267, - 1371, 1429, 1189, 1224, 1212, 1377, 1378, 1334, 1331, 1271, 1235, 1187, - 1064, 1171, 1333, 1473, 1134, 1220, 1592, 1529, 1386, 1437, 1543, 1418, - 1423, 1742, 1590, 1687, 1604, 1302, 1567, 1287, 1299, 1281, 1536, 1403, - 1353, 1352, 1502, 1325, 1422, 1499, 1447, 1350, 1647, 1499, 1578, 1529, - 1581, 1429, 1600, 1461, 1599, 1519, 1728, 1372, 1300, 1684, 1394, 1555, - 1914, 1459, 1677, 1555, 1644, 1115, 1657, 1588, 1263, 1475, 1417, 1547, - 1309, 1357, 1379, 1428, 1466, 1383, 1189, 1446, 1399, 1601, 1362, 1292, - 1243, 1332, 1139, 1040, 1241, 1272, 1185, 1448, 1242, 1319, 1317, 1027, - 1398, 1068, 1168, 1157, 1443, 942, 1070, 1196, 1218, 1161, 1217, 1127, - 1279, 1128, 1313, 1212, 1145, 1388, 1349, 1206, 1277, 1323, 1454, 1238, - 1656, 1206, 1063, 1342, 1165, 1187, 1459, 1255, 1448, 1219, 1453, 1120, - 1383, 1316, 1258, 1203, 1214, 1292, 1300, 1219, 1250, 1176, 1283, 1266, - 1012, 1167, 1228, 1390, 1104, 1080, 1470, 1543, 1305, 1416, 1610, 1364, - 1374, 1670, 1606, 1678, 1648, 1409, 1593, 1392, 1395, 1445, 1721, 1255, - 1479, 1643, 1629, 1384, 1537, 1521, 1502, 1499, 1546, 1373, 1536, 1714, - 1550, 1528, 1584, 1494, 1729, 1532, 1746, 1698, 1435, 1656, 1511, 1556, - 1842, 1476, 1681, 1523, 1729, 1313, 1658, 1629, 1486, 1329, 1611, 1682, - 1546, 1539, 1543, 1401, 1497, 1395, 1289, 1419, 1530, 1754, 1438, 1507, - 1497, 1526, 1234, 1248, 1584, 1325, 1324, 1619, 1346, 1517, 1615, 1066, - 1484, 1226, 1263, 1220, 1529, 1252, 1106, 1380, 1432, 1038, 1318, 1453, - 1424, 1348, 1527, 1373, 1444, 1498, 1440, 1401, 1495, 1456, 1565, 1394, - 1617, 1386, 1207, 1602, 1272, 1291, 1664, 1363, 1476, 1329, 1545, 1301, - 1480, 1300, 1084, 1281, 1342, 1481, 1473, 1423, 1385, 1349, 1426, 1303, - 1166, 1293, 1393, 1520, 1253, 1365, 1679, 1597, 1419, 1337, 1438, 1364, - 1396, 1821, 1586, 1580, 1537, 1285, 1580, 1269, 1246, 1364, 1607, 1272, - 1351, 1503, 1378, 1211, 1363, 1419, 1447, 1383, 1556, 1393, 1467, 1652, - 1626, 1461, 1487, 1555, 1600, 1402, 1798, 1397, 1191, 1467, 1488, 1423, - 1715, 1407, 1730, 1639, 1720, 1395, 1584, 1628, 1438, 1493, 1380, 1516, - 1384, 1385, 1454, 1433, 1489, 1295, 1279, 1375, 1481, 1587, 1311, 1414, - 1316, 1458, 1177, 1206, 1404, 1185, 1172, 1516, 1389, 1400, 1466, 1256, - 1398, 1235, 1235, 1363, 1604, 1178, 1142, 1250, 1410, 1141, 1289, 1417, - 1268, 1381, 1399, 1276, 1308, 1426, 1502, 1389, 1282, 1317, 1560, 1305, - 1742, 1300, 1216, 1397, 1255, 1352, 1747, 1263, 1471, 1287, 1396, 1297, - 1534, 1502, 1306, 1252, 1380, 1464, 1356, 1397, 1359, 1291, 1445, 1183, - 1164, 1281, 1375, 1472, 1217, 1327 - ]); - }); - - it('A x B vec4', async () => { - const a = tf.tensor3d( - [ - 2, 1, 3, 2, 1, 1, 1, 5, 6, 7, 8, 1, 2, 2, 1, 9, 11, 10, 1, - 1, 3, 2, 1, 1, 2, 1, 3, 2, 1, 1, 1, 5, 6, 7, 8, 1, 2, 2, - 1, 9, 11, 10, 1, 1, 3, 2, 1, 1, 2, 1, 3, 2, 1, 1, 1, 5, 6, - 7, 8, 1, 2, 2, 1, 9, 11, 10, 1, 1, 3, 2, 1, 1, 2, 1, 3, 2, - 1, 1, 1, 5, 6, 7, 8, 1, 2, 2, 1, 9, 11, 10, 1, 1, 3, 2, 1, - 1, 2, 1, 3, 2, 1, 1, 1, 5, 6, 7, 8, 1, 2, 2, 1, 9, 11, 10, - 1, 1, 3, 2, 1, 1, 2, 1, 3, 2, 1, 1, 1, 5 - ], - [1, 32, 4]); - - const b = tf.tensor3d( - [ - 2, 1, 3, 2, 1, 1, 1, 5, 6, 7, 8, 1, 2, 2, 1, 9, 11, 10, 1, - 1, 3, 2, 1, 1, 2, 1, 3, 2, 1, 1, 1, 5, 6, 7, 8, 1, 2, 2, - 1, 9, 11, 10, 1, 1, 3, 2, 1, 1, 2, 1, 3, 2, 1, 1, 1, 5, 6, - 7, 8, 1, 2, 2, 1, 9, 11, 10, 1, 1, 3, 2, 1, 1, 2, 1, 3, 2, - 1, 1, 1, 5, 6, 7, 8, 1, 2, 2, 1, 9, 11, 10, 1, 1, 3, 2, 1, - 1, 2, 1, 3, 2, 1, 1, 1, 5, 6, 7, 8, 1, 2, 2, 1, 9, 11, 10, - 1, 1, 3, 2, 1, 1, 2, 1, 3, 2, 1, 1, 1, 5 - ], - [1, 4, 32]); - const c = tf.matMul(a, b); - expect(c.shape).toEqual([1, 32, 32]); - test_util.expectArraysClose(await c.data(), [ - 47, 41, 23, 12, 15, 12, 8, 32, 41, 41, 42, 11, 14, 13, 8, 52, - 64, 62, 31, 9, 19, 15, 8, 36, 47, 41, 23, 12, 15, 12, 8, 32, - 29, 23, 27, 14, 11, 10, 8, 40, 49, 53, 52, 9, 16, 15, 8, 60, - 74, 68, 17, 9, 21, 15, 8, 20, 29, 23, 27, 14, 11, 10, 8, 40, - 144, 136, 85, 29, 45, 37, 22, 106, 135, 127, 87, 30, 43, 36, 22, 110, - 139, 133, 92, 29, 44, 37, 22, 114, 144, 136, 85, 29, 45, 37, 22, 106, - 45, 35, 50, 25, 18, 17, 14, 74, 90, 98, 93, 15, 29, 27, 14, 106, - 131, 119, 25, 16, 37, 26, 14, 30, 45, 35, 50, 25, 18, 17, 14, 74, - 95, 92, 117, 35, 35, 34, 23, 151, 184, 185, 109, 24, 55, 45, 23, 123, - 158, 137, 50, 33, 48, 36, 23, 71, 95, 92, 117, 35, 35, 34, 23, 151, - 31, 28, 29, 11, 11, 10, 7, 39, 48, 49, 37, 8, 15, 13, 7, 43, - 54, 49, 18, 9, 16, 12, 7, 23, 31, 28, 29, 11, 11, 10, 7, 39, - 47, 41, 23, 12, 15, 12, 8, 32, 41, 41, 42, 11, 14, 13, 8, 52, - 64, 62, 31, 9, 19, 15, 8, 36, 47, 41, 23, 12, 15, 12, 8, 32, - 29, 23, 27, 14, 11, 10, 8, 40, 49, 53, 52, 9, 16, 15, 8, 60, - 74, 68, 17, 9, 21, 15, 8, 20, 29, 23, 27, 14, 11, 10, 8, 40, - 144, 136, 85, 29, 45, 37, 22, 106, 135, 127, 87, 30, 43, 36, 22, 110, - 139, 133, 92, 29, 44, 37, 22, 114, 144, 136, 85, 29, 45, 37, 22, 106, - 45, 35, 50, 25, 18, 17, 14, 74, 90, 98, 93, 15, 29, 27, 14, 106, - 131, 119, 25, 16, 37, 26, 14, 30, 45, 35, 50, 25, 18, 17, 14, 74, - 95, 92, 117, 35, 35, 34, 23, 151, 184, 185, 109, 24, 55, 45, 23, 123, - 158, 137, 50, 33, 48, 36, 23, 71, 95, 92, 117, 35, 35, 34, 23, 151, - 31, 28, 29, 11, 11, 10, 7, 39, 48, 49, 37, 8, 15, 13, 7, 43, - 54, 49, 18, 9, 16, 12, 7, 23, 31, 28, 29, 11, 11, 10, 7, 39, - 47, 41, 23, 12, 15, 12, 8, 32, 41, 41, 42, 11, 14, 13, 8, 52, - 64, 62, 31, 9, 19, 15, 8, 36, 47, 41, 23, 12, 15, 12, 8, 32, - 29, 23, 27, 14, 11, 10, 8, 40, 49, 53, 52, 9, 16, 15, 8, 60, - 74, 68, 17, 9, 21, 15, 8, 20, 29, 23, 27, 14, 11, 10, 8, 40, - 144, 136, 85, 29, 45, 37, 22, 106, 135, 127, 87, 30, 43, 36, 22, 110, - 139, 133, 92, 29, 44, 37, 22, 114, 144, 136, 85, 29, 45, 37, 22, 106, - 45, 35, 50, 25, 18, 17, 14, 74, 90, 98, 93, 15, 29, 27, 14, 106, - 131, 119, 25, 16, 37, 26, 14, 30, 45, 35, 50, 25, 18, 17, 14, 74, - 95, 92, 117, 35, 35, 34, 23, 151, 184, 185, 109, 24, 55, 45, 23, 123, - 158, 137, 50, 33, 48, 36, 23, 71, 95, 92, 117, 35, 35, 34, 23, 151, - 31, 28, 29, 11, 11, 10, 7, 39, 48, 49, 37, 8, 15, 13, 7, 43, - 54, 49, 18, 9, 16, 12, 7, 23, 31, 28, 29, 11, 11, 10, 7, 39, - 47, 41, 23, 12, 15, 12, 8, 32, 41, 41, 42, 11, 14, 13, 8, 52, - 64, 62, 31, 9, 19, 15, 8, 36, 47, 41, 23, 12, 15, 12, 8, 32, - 29, 23, 27, 14, 11, 10, 8, 40, 49, 53, 52, 9, 16, 15, 8, 60, - 74, 68, 17, 9, 21, 15, 8, 20, 29, 23, 27, 14, 11, 10, 8, 40, - 144, 136, 85, 29, 45, 37, 22, 106, 135, 127, 87, 30, 43, 36, 22, 110, - 139, 133, 92, 29, 44, 37, 22, 114, 144, 136, 85, 29, 45, 37, 22, 106, - 45, 35, 50, 25, 18, 17, 14, 74, 90, 98, 93, 15, 29, 27, 14, 106, - 131, 119, 25, 16, 37, 26, 14, 30, 45, 35, 50, 25, 18, 17, 14, 74, - 95, 92, 117, 35, 35, 34, 23, 151, 184, 185, 109, 24, 55, 45, 23, 123, - 158, 137, 50, 33, 48, 36, 23, 71, 95, 92, 117, 35, 35, 34, 23, 151, - 31, 28, 29, 11, 11, 10, 7, 39, 48, 49, 37, 8, 15, 13, 7, 43, - 54, 49, 18, 9, 16, 12, 7, 23, 31, 28, 29, 11, 11, 10, 7, 39, - 47, 41, 23, 12, 15, 12, 8, 32, 41, 41, 42, 11, 14, 13, 8, 52, - 64, 62, 31, 9, 19, 15, 8, 36, 47, 41, 23, 12, 15, 12, 8, 32, - 29, 23, 27, 14, 11, 10, 8, 40, 49, 53, 52, 9, 16, 15, 8, 60, - 74, 68, 17, 9, 21, 15, 8, 20, 29, 23, 27, 14, 11, 10, 8, 40, - 144, 136, 85, 29, 45, 37, 22, 106, 135, 127, 87, 30, 43, 36, 22, 110, - 139, 133, 92, 29, 44, 37, 22, 114, 144, 136, 85, 29, 45, 37, 22, 106, - 45, 35, 50, 25, 18, 17, 14, 74, 90, 98, 93, 15, 29, 27, 14, 106, - 131, 119, 25, 16, 37, 26, 14, 30, 45, 35, 50, 25, 18, 17, 14, 74, - 95, 92, 117, 35, 35, 34, 23, 151, 184, 185, 109, 24, 55, 45, 23, 123, - 158, 137, 50, 33, 48, 36, 23, 71, 95, 92, 117, 35, 35, 34, 23, 151, - 31, 28, 29, 11, 11, 10, 7, 39, 48, 49, 37, 8, 15, 13, 7, 43, - 54, 49, 18, 9, 16, 12, 7, 23, 31, 28, 29, 11, 11, 10, 7, 39, - 47, 41, 23, 12, 15, 12, 8, 32, 41, 41, 42, 11, 14, 13, 8, 52, - 64, 62, 31, 9, 19, 15, 8, 36, 47, 41, 23, 12, 15, 12, 8, 32, - 29, 23, 27, 14, 11, 10, 8, 40, 49, 53, 52, 9, 16, 15, 8, 60, - 74, 68, 17, 9, 21, 15, 8, 20, 29, 23, 27, 14, 11, 10, 8, 40 - ]); - }); - - it('A x B vec4 A is a vector', async () => { - const a = tf.tensor3d([2, 1, 3, 2], [1, 1, 4]); - - const b = tf.tensor3d( - [ - 2, 1, 3, 2, 1, 1, 1, 5, 6, 7, 8, 1, 2, 2, 1, 9, 11, 10, 1, - 1, 3, 2, 1, 1, 2, 1, 3, 2, 1, 1, 1, 5, 6, 7, 8, 1, 2, 2, - 1, 9, 11, 10, 1, 1, 3, 2, 1, 1, 2, 1, 3, 2, 1, 1, 1, 5, 6, - 7, 8, 1, 2, 2, 1, 9, 11, 10, 1, 1, 3, 2, 1, 1, 2, 1, 3, 2, - 1, 1, 1, 5, 6, 7, 8, 1, 2, 2, 1, 9, 11, 10, 1, 1, 3, 2, 1, - 1, 2, 1, 3, 2, 1, 1, 1, 5, 6, 7, 8, 1, 2, 2, 1, 9, 11, 10, - 1, 1, 3, 2, 1, 1, 2, 1, 3, 2, 1, 1, 1, 5 - ], - [1, 4, 32]); - const c = tf.matMul(a, b); - expect(c.shape).toEqual([1, 1, 32]); - test_util.expectArraysClose(await c.data(), [ - 47, 41, 23, 12, 15, 12, 8, 32, 41, 41, 42, 11, 14, 13, 8, 52, - 64, 62, 31, 9, 19, 15, 8, 36, 47, 41, 23, 12, 15, 12, 8, 32 - ]); - }); - - it('A^t x B vec4', async () => { - const a = tf.tensor2d([1, 2, 3, 4, 5, 6, 7, 8], [2, 4]); - const b = tf.tensor2d([1, 0, 2, 4, 3, 0, 5, 6], [2, 4]); - - const transposeA = true; - const transposeB = false; - const c = tf.matMul(a, b, transposeA, transposeB); - const result = await c.data(); - const expected = - [16, 0, 27, 34, 20, 0, 34, 44, 24, 0, 41, 54, 28, 0, 48, 64]; - test_util.expectArraysClose(result, expected); - }); - - it('fused A x B vec4 with relu', async () => { - const a = tf.tensor2d([1, 2, 3, 4, 5, 6, 7, 8], [2, 4]); - const b = tf.tensor2d( - [0, 1, -3, 2, 2, 1, 1, 0, 2, 4, 3, 0, 5, -6, 7, -8], [4, 4]); - const transposeA = false; - const transposeB = false; - - const c = tf.fused.matMul( - {a, b, transposeA, transposeB, bias: null, activation: 'relu'}); - - expect(c.shape).toEqual([2, 4]); - expectArraysClose(await c.data(), [30, 0, 36, 0, 66, 0, 68, 0]); - }); - - it('fused A x B vec4 with elu', async () => { - const a = tf.tensor2d([1, 2, 3, 4, 5, 6, 7, 8], [2, 4]); - const b = tf.tensor2d( - [0, 1, -3, 2, 2, 1, 1, 0, 2, 4, 3, 0, 5, -6, 7, -8], [4, 4]); - const transposeA = false; - const transposeB = false; - - const c = tf.fused.matMul( - {a, b, transposeA, transposeB, bias: null, activation: 'elu'}); - - expect(c.shape).toEqual([2, 4]); - expectArraysClose( - await c.data(), [30, -0.9999, 36, -1, 66, -0.9999, 68, -1]); - }); - - it('fused A x B vec4 with relu6', async () => { - const a = tf.tensor2d([1, 2, 3, 4, 5, 6, 7, 8], [2, 4]); - const b = tf.tensor2d( - [0, 1, -3, 2, 2, 1, 1, 0, 2, 4, 3, 0, 5, -6, 7, -8], [4, 4]); - const transposeA = false; - const transposeB = false; - - const c = tf.fused.matMul( - {a, b, transposeA, transposeB, bias: null, activation: 'relu6'}); - - expect(c.shape).toEqual([2, 4]); - expectArraysClose(await c.data(), [6, 0, 6, 0, 6, 0, 6, 0]); - }); - - it('fused A x B vec4 with prelu', async () => { - const a = tf.tensor2d([1, 2, 3, 4, 5, 6, 7, 8], [2, 4]); - const b = tf.tensor2d( - [0, 1, -3, 2, 2, 1, 1, 0, 2, 4, 3, 0, 5, -6, 7, -8], [4, 4]); - const alpha = tf.tensor2d([0.5, 0.5, 0.5, 0.5], [1, 4]); - const transposeA = false; - const transposeB = false; - - const c = tf.fused.matMul({ - a, - b, - transposeA, - transposeB, - bias: null, - activation: 'prelu', - preluActivationWeights: alpha - }); - - expect(c.shape).toEqual([2, 4]); - expectArraysClose(await c.data(), [30, -4.5, 36, -15, 66, -4.5, 68, -27]); - }); - - it('fused A x B vec4 with leakyrelu', async () => { - const a = tf.tensor2d([1, 2, 3, 4, 5, 6, 7, 8], [2, 4]); - const b = tf.tensor2d( - [0, 1, -3, 2, 2, 1, 1, 0, 2, 4, 3, 0, 5, -6, 7, -8], [4, 4]); - const alpha = 0.3; - const transposeA = false; - const transposeB = false; - - const c = tf.fused.matMul({ - a, - b, - transposeA, - transposeB, - bias: null, - activation: 'leakyrelu', - leakyreluAlpha: alpha - }); - - expect(c.shape).toEqual([2, 4]); - expectArraysClose(await c.data(), [ - 30, -2.700000047683716, 36, -9, 66, -2.700000047683716, 68, - -16.200000762939453 - ]); - }); - - it('fused A x B vec4 with leakyrelu not provided.', async () => { - const a = tf.tensor2d([1, 2, 3, 4, 5, 6, 7, 8], [2, 4]); - const b = tf.tensor2d( - [0, 1, -3, 2, 2, 1, 1, 0, 2, 4, 3, 0, 5, -6, 7, -8], [4, 4]); - const transposeA = false; - const transposeB = false; - - const c = tf.fused.matMul( - {a, b, transposeA, transposeB, bias: null, activation: 'leakyrelu'}); - - expect(c.shape).toEqual([2, 4]); - // leakyRelu should use default alpha=0.2. - expectArraysClose(await c.data(), [ - 30, -1.8000000715255737, 36, -6, 66, -1.8000000715255737, 68, - -10.800000190734863 - ]); - }); - - it('fused A x B with sigmoid', async () => { - const a = tf.tensor2d([1, 2, 3, 4, 5, 6, 7, 8], [2, 4]); - const b = tf.tensor2d( - [0, 1, -3, 2, 2, 1, 1, 0, 2, 4, 3, 0, 5, -6, 7, -8], [4, 4]); - const transposeA = false; - const transposeB = false; - - const c = tf.fused.matMul( - {a, b, transposeA, transposeB, bias: null, activation: 'sigmoid'}); - - expect(c.shape).toEqual([2, 4]); - expectArraysClose(await c.data(), [ - 1, 0.00012339462409727275, 1, 9.35763443186792e-14, 1, - 0.00012339462409727275, 1, 3.5326268130932535e-24 - ]); - }); - - it('fused A x B vec4 with 2d bias and relu', async () => { - const a = tf.tensor2d([1, 2, 3, 4, 5, 6, 7, 8], [2, 4]); - const b = tf.tensor2d( - [0, 1, -3, 2, 2, 1, 1, 0, 2, 4, 3, 0, 5, -6, 7, -8], [4, 4]); - const c = tf.tensor2d([1, 1, 1, 1, 1, 1, 1, 1], [2, 4]); - const transposeA = false; - const transposeB = false; - - const d = tf.fused.matMul( - {a, b, transposeA, transposeB, bias: c, activation: 'relu'}); - - expect(d.shape).toEqual([2, 4]); - expectArraysClose(await d.data(), [31, 0, 37, 0, 67, 0, 69, 0]); - }); - - it('fused A x B vec4 with relu and broadcasted bias', async () => { - const a = tf.tensor2d([1, 2, 3, 4, 5, 6, 7, 8], [2, 4]); - const b = tf.tensor2d( - [0, 1, -3, 2, 2, 1, 1, 0, 2, 4, 3, 0, 5, -6, 7, -8], [4, 4]); - const c = tf.tensor1d([1, 1, 1, 1]); - const act: tf.fused.Activation = 'relu'; - const transposeA = false; - const transposeB = false; - - const d = tf.fused.matMul( - {a, b, transposeA, transposeB, bias: c, activation: act}); - - expect(d.shape).toEqual([2, 4]); - expectArraysClose(await d.data(), [31, 0, 37, 0, 67, 0, 69, 0]); - }); - - // Below cases are from mat_mul_test.ts in tfjs-core. - it('A x B', async () => { - const a = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - const b = tf.tensor2d([0, 1, -3, 2, 2, 1], [3, 2]); - - const c = tf.matMul(a, b); - - expect(c.shape).toEqual([2, 2]); - expectArraysClose(await c.data(), [0, 8, -3, 20]); - }); - - it('A x B with M/N/K divisible by 4. [8,4]x[4,8]', async () => { - const a = tf.tensor2d( - [ - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, - 17, 18, 19, 20, 21, 22, 23, 24, 1, 2, 3, 4, 5, 6, 7, 8 - ], - [8, 4]); - const b = tf.tensor2d( - [ - 0, 1, -3, 2, 1, -1, 0, 5, 6, 7, 8, 0, -2, -2, 1, 9, - 11, 10, 0, 1, -3, 2, 1, -1, 1, 2, 3, 4, 5, 6, 7, 8 - ], - [4, 8]); - - const c = tf.matMul(a, b); - const cData = await c.data(); - - expect(c.shape).toEqual([8, 8]); - expectArraysClose(cData, [ - 49, 53, 25, 21, 8, 25, 33, 52, 121, 133, 57, 49, 12, - 45, 69, 136, 193, 213, 89, 77, 16, 65, 105, 220, 265, 293, - 121, 105, 20, 85, 141, 304, 337, 373, 153, 133, 24, 105, 177, - 388, 409, 453, 185, 161, 28, 125, 213, 472, 49, 53, 25, 21, - 8, 25, 33, 52, 121, 133, 57, 49, 12, 45, 69, 136 - ]); - }); - - it('A x B with large K. [16,2048]x[2048,16]', async () => { - const a = tf.tensor2d(new Array(16 * 2048).fill(1), [16, 2048]); - const b = tf.tensor2d(new Array(2048 * 16).fill(1), [2048, 16]); - - const c = tf.matMul(a, b); - const cData = await c.data(); - - expect(c.shape).toEqual([16, 16]); - expectArraysClose(cData, new Array(16 * 16).fill(2048)); - }); - - it('matmul followed by mul', async () => { - const a = tf.tensor2d([1, 2, 3, 4], [2, 2]); - const b = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - - const c = tf.matMul(a, b); - - const f = tf.tensor2d([0, 1, 0.5, 0, 0.25, 2], [2, 3]); - const d = tf.mul(c, f); - - const dData = await d.data(); - - expect(d.shape).toEqual([2, 3]); - expectArraysClose(dData, [0, 12, 7.5, 0, 6.5, 66]); - }); - - it('A x B^t', async () => { - const a = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - const b = tf.tensor2d([1, 0, 2, 4, 3, 0], [2, 3]); - - const transposeA = false; - const transposeB = true; - const c = tf.matMul(a, b, transposeA, transposeB); - - const expected = [7, 10, 16, 31]; - expectArraysClose(await c.data(), expected); - }); - - it('A^t x B', async () => { - const a = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - const b = tf.tensor2d([1, 0, 2, 4, 3, 0], [2, 3]); - - const transposeA = true; - const transposeB = false; - const c = tf.matMul(a, b, transposeA, transposeB); - - const expected = [17, 12, 2, 22, 15, 4, 27, 18, 6]; - expectArraysClose(await c.data(), expected); - }); - - it('A^t x B^t', async () => { - const a = tf.tensor2d([1, 2, 3, 4, 5, 6], [3, 2]); - const b = tf.tensor2d([1, 0, 2, 4, 3, 0], [2, 3]); - - const transposeA = true; - const transposeB = true; - const c = tf.matMul(a, b, transposeA, transposeB); - - const expected = [11, 13, 14, 20]; - expectArraysClose(await c.data(), expected); - }); - - it('Vector times matrix', async () => { - const v = tf.tensor1d([2, 3]); - const matrix = tf.tensor2d([1, 2, 3, 4], [2, 2]); - const result = tf.dot(v, matrix); - - const expected = [11, 16]; - expectArraysClose(await result.data(), expected); - }); - - it('Vector times matrix with implicit reshape', async () => { - const v = tf.tensor1d([2, 3]); - - const matrix = tf.tensor2d([1, 2, 3, 4], [2, 2]); - const result = tf.dot(v, matrix); - - const expected = [11, 16]; - expectArraysClose(await result.data(), expected); - }); - - it('Matrix times vector', async () => { - const matrix = tf.tensor2d([1, 2, 3, 4], [2, 2]); - const v = tf.tensor1d([2, 3]); - const result = tf.dot(matrix, v); - - const expected = [8, 18]; - expectArraysClose(await result.data(), expected); - }); - - it('accepts a tensor-like object', async () => { - const a = [[1, 2, 3], [4, 5, 6]]; // 2x3 - const b = [[0, 1], [-3, 2], [2, 1]]; // 3x2 - const c = tf.matMul(a, b); - - expect(c.shape).toEqual([2, 2]); - expectArraysClose(await c.data(), [0, 8, -3, 20]); - }); - - it('accepts a tensor-like object chained', async () => { - const a = tf.tensor2d([[1, 2, 3], [4, 5, 6]], [2, 3]); // 2x3 - const b = [[0, 1], [-3, 2], [2, 1]]; // 3x2 - const c = a.matMul(b); - - expect(c.shape).toEqual([2, 2]); - expectArraysClose(await c.data(), [0, 8, -3, 20]); - }); - - it('a * b where a has zero in its shape', async () => { - const a = tf.tensor2d([], [0, 3]); - const b = tf.tensor2d([1, 2, 3, 4, 5, 6], [3, 2]); - const c = tf.matMul(a, b); - expect(c.shape).toEqual([0, 2]); - expect(c.rank).toBe(2); - expect(c.size).toBe(0); - expectArraysClose(await c.data(), []); - }); - - it('(a * b) * c where a has zero in its shape, so a*b does also', - async () => { - const a = tf.tensor2d([], [0, 3]); - const b = tf.tensor2d([1, 2, 3, 4, 5, 6], [3, 2]); - const ab = tf.matMul(a, b); - expect(ab.shape).toEqual([0, 2]); - expectArraysClose(await ab.data(), []); - const c = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - const res = tf.matMul(ab, c); - expect(res.shape).toEqual([0, 3]); - expectArraysClose(await res.data(), []); - }); - - it('fused A x B', async () => { - const a = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - const b = tf.tensor2d([0, 1, -3, 2, 2, 1], [3, 2]); - - const c = tf.fused.matMul({a, b}); - - expect(c.shape).toEqual([2, 2]); - expectArraysClose(await c.data(), [0, 8, -3, 20]); - }); - - it('fused A x B with relu', async () => { - const a = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - const b = tf.tensor2d([0, 1, -3, 2, 2, 1], [3, 2]); - const transposeA = false; - const transposeB = false; - - const c = tf.fused.matMul( - {a, b, transposeA, transposeB, bias: null, activation: 'relu'}); - - expect(c.shape).toEqual([2, 2]); - expectArraysClose(await c.data(), [0, 8, 0, 20]); - }); - - it('fused A x B with elu', async () => { - const a = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - const b = tf.tensor2d([0, 1, -3, 2, 2, 1], [3, 2]); - const transposeA = false; - const transposeB = false; - - const c = tf.fused.matMul( - {a, b, transposeA, transposeB, bias: null, activation: 'elu'}); - - expect(c.shape).toEqual([2, 2]); - expectArraysClose(await c.data(), [0, 8, -0.9502, 20]); - }); - - it('fused A x B with relu6', async () => { - const a = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - const b = tf.tensor2d([0, 1, -3, 2, 2, 1], [3, 2]); - const transposeA = false; - const transposeB = false; - - const c = tf.fused.matMul( - {a, b, transposeA, transposeB, bias: null, activation: 'relu6'}); - - expect(c.shape).toEqual([2, 2]); - expectArraysClose(await c.data(), [0, 6, 0, 6]); - }); - - it('fused A x B with prelu', async () => { - const a = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - const b = tf.tensor2d([0, 1, -3, 2, 2, 1], [3, 2]); - const alpha = tf.tensor2d([0.5, 0.5], [1, 2]); - const transposeA = false; - const transposeB = false; - - const c = tf.fused.matMul({ - a, - b, - transposeA, - transposeB, - bias: null, - activation: 'prelu', - preluActivationWeights: alpha - }); - - expect(c.shape).toEqual([2, 2]); - expectArraysClose(await c.data(), [0, 8, -1.5, 20]); - }); - - it('fused A x B with leakyrelu', async () => { - const a = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - const b = tf.tensor2d([0, 1, -3, 2, 2, 1], [3, 2]); - const alpha = 0.3; - const transposeA = false; - const transposeB = false; - - const c = tf.fused.matMul({ - a, - b, - transposeA, - transposeB, - bias: null, - activation: 'leakyrelu', - leakyreluAlpha: alpha - }); - - expect(c.shape).toEqual([2, 2]); - expectArraysClose(await c.data(), [0, 8, -0.9000000357627869, 20]); - }); - - it('fused A x B with leakyrelu not provided.', async () => { - const a = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - const b = tf.tensor2d([0, 1, -3, 2, 2, 1], [3, 2]); - const transposeA = false; - const transposeB = false; - - const c = tf.fused.matMul( - {a, b, transposeA, transposeB, bias: null, activation: 'leakyrelu'}); - - expect(c.shape).toEqual([2, 2]); - // leakyRelu should use default alpha=0.2. - expectArraysClose(await c.data(), [0, 8, -0.6000000238418579, 20]); - }); - - it('fused A x B with sigmoid', async () => { - const a = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - const b = tf.tensor2d([0, 1, -3, 2, 2, 1], [3, 2]); - const transposeA = false; - const transposeB = false; - - const c = tf.fused.matMul( - {a, b, transposeA, transposeB, bias: null, activation: 'sigmoid'}); - - expect(c.shape).toEqual([2, 2]); - expectArraysClose(await c.data(), [0.5, 0.99966455, 0.04742587, 1]); - }); - - it('fused A x B with relu transpose', async () => { - const a = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - const b = tf.tensor2d([0, 1, -3, 2, 2, 1], [2, 3]); - const transposeA = false; - const transposeB = true; - - const c = tf.fused.matMul( - {a, b, transposeA, transposeB, bias: null, activation: 'relu'}); - - expect(c.shape).toEqual([2, 2]); - expectArraysClose(await c.data(), [0, 9, 0, 24]); - }); - - it('fused A x B with 2d bias and relu', async () => { - const a = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - const b = tf.tensor2d([0, 1, -3, 2, 2, 1], [3, 2]); - const c = tf.tensor2d([1, 1, 1, 1], [2, 2]); - const transposeA = false; - const transposeB = false; - - const d = tf.fused.matMul( - {a, b, transposeA, transposeB, bias: c, activation: 'relu'}); - - expect(d.shape).toEqual([2, 2]); - expectArraysClose(await d.data(), [1, 9, 0, 21]); - }); - - it('fused A x B with relu and broadcasted bias', async () => { - const a = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - const b = tf.tensor2d([0, 1, -3, 2, 2, 1], [3, 2]); - const c = tf.tensor1d([1, 1]); - const act: tf.fused.Activation = 'relu'; - const transposeA = false; - const transposeB = false; - - const d = tf.fused.matMul( - {a, b, transposeA, transposeB, bias: c, activation: act}); - - expect(d.shape).toEqual([2, 2]); - expectArraysClose(await d.data(), [1, 9, 0, 21]); - }); - - it('fused A x B with elu and broadcasted bias', async () => { - const a = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - const b = tf.tensor2d([0, 1, -3, 2, 2, 1], [3, 2]); - const c = tf.tensor1d([1, 1]); - const act: tf.fused.Activation = 'elu'; - const transposeA = false; - const transposeB = false; - - const d = tf.fused.matMul( - {a, b, transposeA, transposeB, bias: c, activation: act}); - - expect(d.shape).toEqual([2, 2]); - expectArraysClose(await d.data(), [1, 9, -0.8647, 21]); - }); - - it('fused A x B with elu and broadcasted shape', async () => { - const a = tf.tensor3d([1, 2, 3, 4, 5, 6], [1, 2, 3]); - const b = tf.tensor2d([0, 1, -3, 2, 2, 1], [3, 2]); - const c = tf.tensor1d([1, 1]); - const act: tf.fused.Activation = 'elu'; - const transposeA = false; - const transposeB = false; - - const d = tf.fused.matMul( - {a, b, transposeA, transposeB, bias: c, activation: act}); - - expect(d.shape).toEqual([1, 2, 2]); - expectArraysClose(await d.data(), [1, 9, -0.8647, 21]); - }); - - it('fused A x B with 2d bias only', async () => { - const a = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - const b = tf.tensor2d([0, 1, -3, 2, 2, 1], [3, 2]); - const c = tf.tensor2d([1, 1, 1, 1], [2, 2]); - const transposeA = false; - const transposeB = false; - - const d = tf.fused.matMul( - {a, b, transposeA, transposeB, bias: c, activation: 'linear'}); - - expect(d.shape).toEqual([2, 2]); - expectArraysClose(await d.data(), [1, 9, -2, 21]); - }); - }; -} - -// Below cases are from [fused_]mat_mul_test.ts in tfjs-core. -function matmulBatchTest(programType: MatMulProgramType) { - return () => { - let savedMatmulFlag = -1; - beforeAll(() => { - savedMatmulFlag = tf.env().get('WEBGPU_MATMUL_PROGRAM_TYPE') as number; - tf.env().set('WEBGPU_MATMUL_PROGRAM_TYPE', programType); - }); - afterAll(() => { - tf.env().set('WEBGPU_MATMUL_PROGRAM_TYPE', savedMatmulFlag); - }); - - it('fused A x B with relu and broadcasted bias different rank', - async () => { - const a = - tf.tensor3d([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [2, 2, 3]); - const b = - tf.tensor3d([0, 1, -3, 2, 2, 1, 0, 1, -3, 2, 2, 1], [2, 3, 2]); - const c = tf.tensor2d([1, 2], [1, 2]); - const act: tf.fused.Activation = 'relu'; - const transposeA = false; - const transposeB = false; - - const d = tf.fused.matMul( - {a, b, transposeA, transposeB, bias: c, activation: act}); - - expect(d.shape).toEqual([2, 2, 2]); - expectArraysClose(await d.data(), [2, 6, 0, 18, 0, 30, 0, 42]); - }); - - it('broadcast with unequal batch dims', async () => { - const a = tf.tensor3d( - [ - 2, 1, 3, 2, 1, 1, 1, 5, 6, 7, 8, 1, - 2, 2, 1, 9, 11, 10, 1, 1, 3, 2, 1, 1 - ], - [4, 3, 2]); - const b = tf.tensor3d([1, 0.5], [1, 2, 1]); - const c = tf.matMul(a, b); - expect(c.shape).toEqual([4, 3, 1]); - expectArraysClose( - await c.data(), - [2.5, 4, 1.5, 3.5, 9.5, 8.5, 3, 5.5, 16, 1.5, 4, 1.5]); - }); - - it('broadcast with unequal ranks', async () => { - const a = tf.tensor5d( - [ - 2, 1, 3, 2, 1, 1, 1, 5, 6, 7, 8, 1, - 2, 2, 1, 9, 11, 10, 1, 1, 3, 2, 1, 1 - ], - [1, 2, 2, 3, 2]); - const b = tf.tensor2d([1, 0.5], [2, 1]); - const c = tf.matMul(a, b); - expect(c.shape).toEqual([1, 2, 2, 3, 1]); - expectArraysClose( - await c.data(), - [2.5, 4, 1.5, 3.5, 9.5, 8.5, 3, 5.5, 16, 1.5, 4, 1.5]); - }); - - it('batched matmul with the matrices being vectors', async () => { - const batch = 3; - const sharedDim = MATMUL_SHARED_DIM_THRESHOLD + 1; - const values = new Float32Array(batch * sharedDim); - values[10] = 2; - - const a = tf.tensor(values, [batch, 1, sharedDim]); - const b = tf.tensor(values, [batch, sharedDim, 1]); - const result = tf.matMul(a, b); - expect(result.shape).toEqual([batch, 1, 1]); - expectArraysClose(await result.data(), [4, 0, 0]); - }); - - it('batched matmul called twice so memory of output is reused', - async () => { - const batch = 3; - const n = 2; - const vals = new Float32Array(batch * n * n); - vals[0] = 2; - vals[4] = 3; - vals[8] = 4; - - const a = tf.tensor(vals, [batch, n, n]); - const b = tf.tensor(vals, [batch, n, n]); - const result = tf.matMul(a, b); - expect(result.shape).toEqual([batch, n, n]); - expectArraysClose( - await result.data(), [4, 0, 0, 0, 9, 0, 0, 0, 16, 0, 0, 0]); - // Dispose the first output, so memory of the second output (which has - // the same shape), could be reused. - result.dispose(); - - const vals2 = new Float32Array(batch * n * n); - vals2[3] = 2; - vals2[7] = 3; - vals2[11] = 4; - const a2 = tf.tensor(vals2, [batch, n, n]); - const b2 = tf.tensor(vals2, [batch, n, n]); - const result2 = tf.matMul(a2, b2); - expect(result2.shape).toEqual([batch, n, n]); - expectArraysClose( - await result2.data(), [0, 0, 0, 4, 0, 0, 0, 9, 0, 0, 0, 16]); - }); - - it('batched matmul with the matrices being vectors transposedA', - async () => { - const batch = 3; - const sharedDim = MATMUL_SHARED_DIM_THRESHOLD + 1; - const values = new Float32Array(batch * sharedDim); - values[10] = 2; - - const a = tf.tensor(values, [batch, sharedDim, 1]); - const b = tf.tensor(values, [batch, sharedDim, 1]); - const transposeA = true; - const transposeB = false; - const result = tf.matMul(a, b, transposeA, transposeB); - expect(result.shape).toEqual([batch, 1, 1]); - expectArraysClose(await result.data(), [4, 0, 0]); - }); - - it('batched matmul with the matrices being vectors transposedB', - async () => { - const batch = 3; - const sharedDim = MATMUL_SHARED_DIM_THRESHOLD + 1; - const values = new Float32Array(batch * sharedDim); - values[10] = 2; - - const a = tf.tensor(values, [batch, 1, sharedDim]); - const b = tf.tensor(values, [batch, 1, sharedDim]); - const transposeA = false; - const transposeB = true; - const result = tf.matMul(a, b, transposeA, transposeB); - expect(result.shape).toEqual([batch, 1, 1]); - expectArraysClose(await result.data(), [4, 0, 0]); - }); - - it('batched matmul with matrix x vector', async () => { - const batch = 3; - const sharedDim = MATMUL_SHARED_DIM_THRESHOLD + 1; - const values = new Float32Array(batch * sharedDim); - values[10] = 2; - - const a = tf.ones([batch, 2, sharedDim]); - const b = tf.tensor(values, [batch, sharedDim, 1]); - const result = tf.matMul(a, b); - expect(result.shape).toEqual([batch, 2, 1]); - expectArraysClose(await result.data(), [2, 2, 0, 0, 0, 0]); - }); - - it('batched matmul with matrix x vector transposedA', async () => { - const batch = 3; - const sharedDim = MATMUL_SHARED_DIM_THRESHOLD + 1; - const values = new Float32Array(batch * sharedDim); - values[10] = 2; - - const a = tf.ones([batch, sharedDim, 2]); - const b = tf.tensor(values, [batch, sharedDim, 1]); - const transposeA = true; - const transposeB = false; - const result = tf.matMul(a, b, transposeA, transposeB); - expect(result.shape).toEqual([batch, 2, 1]); - expectArraysClose(await result.data(), [2, 2, 0, 0, 0, 0]); - }); - - it('batched matmul with matrix x vector transposedB', async () => { - const batch = 3; - const sharedDim = MATMUL_SHARED_DIM_THRESHOLD + 1; - const values = new Float32Array(batch * sharedDim); - values[10] = 2; - - const a = tf.ones([batch, 2, sharedDim]); - const b = tf.tensor(values, [batch, 1, sharedDim]); - const transposeA = false; - const transposeB = true; - const result = tf.matMul(a, b, transposeA, transposeB); - expect(result.shape).toEqual([batch, 2, 1]); - expectArraysClose(await result.data(), [2, 2, 0, 0, 0, 0]); - }); - - it('batched matmul with vector x matrix', async () => { - const batch = 3; - const sharedDim = MATMUL_SHARED_DIM_THRESHOLD + 1; - const values = new Float32Array(batch * sharedDim); - values[10] = 2; - - const a = tf.tensor(values, [batch, 1, sharedDim]); - const b = tf.ones([batch, sharedDim, 2]); - const result = tf.matMul(a, b); - expect(result.shape).toEqual([batch, 1, 2]); - expectArraysClose(await result.data(), [2, 2, 0, 0, 0, 0]); - }); - - it('batched matmul with vector x matrix transposedA', async () => { - const batch = 3; - const sharedDim = MATMUL_SHARED_DIM_THRESHOLD + 1; - const values = new Float32Array(batch * sharedDim); - values[10] = 2; - - const a = tf.tensor(values, [batch, sharedDim, 1]); - const b = tf.ones([batch, sharedDim, 2]); - const transposeA = true; - const transposeB = false; - const result = tf.matMul(a, b, transposeA, transposeB); - expect(result.shape).toEqual([batch, 1, 2]); - expectArraysClose(await result.data(), [2, 2, 0, 0, 0, 0]); - }); - - it('batched matmul with vector x matrix transposedB', async () => { - const batch = 3; - const sharedDim = MATMUL_SHARED_DIM_THRESHOLD + 1; - const values = new Float32Array(batch * sharedDim); - values[10] = 2; - - const a = tf.tensor(values, [batch, 1, sharedDim]); - const b = tf.ones([batch, 2, sharedDim]); - const transposeA = false; - const transposeB = true; - const result = tf.matMul(a, b, transposeA, transposeB); - expect(result.shape).toEqual([batch, 1, 2]); - expectArraysClose(await result.data(), [2, 2, 0, 0, 0, 0]); - }); - - it('A x B', async () => { - const a = tf.tensor3d( - [ - -5, -5, -6, 8, -2, -8, 4, -7, -6, -9, -1, 3, 7, -2, 5, - -6, 3, 8, 7, -8, 1, 4, -4, 6, 4, -4, -9, -5, 2, -2 - ], - [5, 2, 3]); - const b = tf.tensor3d( - [ - -8, -4, -1, 0, -7, 0, 3, 3, 6, 2, -1, 8, -4, 9, -6, - 5, 8, 9, -9, 7, 0, -1, -1, -10, -7, 3, 4, 6, 3, -4 - ], - [5, 3, 2]); - - const c = tf.matMul(a, b); - expect(c.shape).toEqual([5, 2, 2]); - expectArraysClose(await c.data(), [ - 87, 20, -6, -32, -24, -50, -36, -5, 24, 98, - 70, 33, -64, 47, -42, -28, -71, 24, 37, 5 - ]); - }); - - it('A x B in 4D', async () => { - const a = tf.tensor4d( - [ - -2, 3, 5, -5, 3, 9, -3, -5, 1, 1, -9, 9, -6, 6, -8, - -7, -1, 3, 9, -7, -7, 2, 10, -6, -8, -6, 9, -6, 4, -1, - 9, -6, 10, 8, -9, 5, -8, -7, 0, 2, -5, -1, -9, -4, 3, - -2, 6, -4, 7, 1, -5, -4, 9, -8, -6, -8, 4, -1, 4, 3, - -7, 8, -7, 5, -3, -2, -4, 9, 2, -1, 1, -10, -3, 5, -4, - 6, -8, -8, 9, -3, -5, 10, 3, -3, -3, 9, 3, -3, 2, -8, - 10, 1, 9, -2, -2, -3, -4, 6, -10, -1, 8, -8, 7, 3, -2, - 3, 6, -2, -2, -4, 1, -5, -4, 0, 5, 1, 9, -8, -2, -1 - ], - [4, 5, 2, 3]); - const b = tf.tensor4d( - [ - -4, -3, -2, -6, 6, -1, -4, -1, 7, -4, 8, -9, -9, 0, -1, - -4, -6, -7, -3, -4, -7, 6, -8, 1, -2, 1, -1, -3, 8, -5, - 9, -2, 5, 9, -2, 2, -5, -5, -8, -1, -2, -3, -2, -10, 6, - -3, 0, 1, 6, 7, 1, 2, -4, -5, 2, -5, -7, 9, 3, -6, - 6, 4, -4, 6, 10, -3, -2, 8, 10, -8, 10, -1, -9, -7, -8, - -3, 1, 1, -2, -9, -7, -6, -1, 0, 7, -9, -7, -5, 0, -4, - -4, -7, 2, 4, 6, 6, -4, -6, -8, 3, -8, -9, 6, 9, -4, - 1, -1, 0, 8, 9, 0, -5, 3, -1, 5, 0, -10, 7, -2, 6 - ], - [4, 5, 3, 2]); - - const transposeA = false; - const transposeB = false; - const c = tf.matMul(a, b, transposeA, transposeB); - - expectArraysClose(await c.data(), [ - 32, -17, 68, -12, -15, 14, 5, -46, 96, 32, 46, -17, 78, -85, - -28, 46, 94, -35, 0, -13, 31, -52, 17, -87, 96, 47, 32, -2, - -6, 105, 40, -2, 63, 76, 17, 30, 56, -66, -21, 23, -144, 41, - 22, 8, 118, -106, -88, -6, -17, 2, 2, -26, 8, -63, -38, -108, - -84, -30, -35, 49, 16, -12, -14, -12, 48, 132, 4, 102, 32, 66, - -4, 33, -13, 1, -40, -25, -3, 61, -18, -20 - ]); - }); - - it('A x B^t', async () => { - const a = tf.tensor3d( - [ - -5, -5, -6, 8, -2, -8, 4, -7, -6, -9, -1, 3, 7, -2, 5, - -6, 3, 8, 7, -8, 1, 4, -4, 6, 4, -4, -9, -5, 2, -2 - ], - [5, 2, 3]); - const b = tf.tensor3d( - [ - -8, -4, -1, 0, -7, 0, 3, 3, 6, 2, -1, 8, -4, 9, -6, - 5, 8, 9, -9, 7, 0, -1, -1, -10, -7, 3, 4, 6, 3, -4 - ], - [5, 2, 3]); - - const transposeA = false; - const transposeB = true; - const c = tf.matMul(a, b, transposeA, transposeB); - expect(c.shape).toEqual([5, 2, 2]); - expectArraysClose(await c.data(), [ - 66, 35, -48, 14, -45, -33, -12, 7, -76, 64, - 3, 66, -119, -9, -64, -60, -76, 48, 33, -16 - ]); - }); - - it('A^t x B', async () => { - const a = tf.tensor3d( - [ - -5, -5, -6, 8, -2, -8, 4, -7, -6, -9, -1, 3, 7, -2, 5, - -6, 3, 8, 7, -8, 1, 4, -4, 6, 4, -4, -9, -5, 2, -2 - ], - [5, 2, 3]); - const b = tf.tensor3d( - [ - -8, -4, -1, 0, -7, 0, 3, 3, 6, 2, -1, 8, -4, 9, -6, - 5, 8, 9, -9, 7, 0, -1, -1, -10, -7, 3, 4, 6, 3, -4 - ], - [5, 2, 3]); - - const transposeA = true; - const transposeB = false; - const c = tf.matMul(a, b, transposeA, transposeB); - - expectArraysClose(await c.data(), [ - 40, -36, 5, 40, 34, 5, 48, 80, 6, -6, 21, -48, -23, -20, -50, - -12, -21, -12, -58, 15, -96, 23, 6, 39, 20, 109, 42, -67, 45, -40, - 76, -52, 40, -15, 1, -60, -58, -3, 36, 40, -6, -24, 51, -33, -28 - ]); - }); - - it('A^t x B in 4D', async () => { - const a = tf.tensor4d( - [ - -2, 3, 5, -5, 3, 9, -3, -5, 1, 1, -9, 9, -6, 6, -8, - -7, -1, 3, 9, -7, -7, 2, 10, -6, -8, -6, 9, -6, 4, -1, - 9, -6, 10, 8, -9, 5, -8, -7, 0, 2, -5, -1, -9, -4, 3, - -2, 6, -4, 7, 1, -5, -4, 9, -8, -6, -8, 4, -1, 4, 3, - -7, 8, -7, 5, -3, -2, -4, 9, 2, -1, 1, -10, -3, 5, -4, - 6, -8, -8, 9, -3, -5, 10, 3, -3, -3, 9, 3, -3, 2, -8, - 10, 1, 9, -2, -2, -3, -4, 6, -10, -1, 8, -8, 7, 3, -2, - 3, 6, -2, -2, -4, 1, -5, -4, 0, 5, 1, 9, -8, -2, -1 - ], - [4, 5, 2, 3]); - const b = tf.tensor4d( - [ - -4, -3, -2, -6, 6, -1, -4, -1, 7, -4, 8, -9, -9, 0, -1, - -4, -6, -7, -3, -4, -7, 6, -8, 1, -2, 1, -1, -3, 8, -5, - 9, -2, 5, 9, -2, 2, -5, -5, -8, -1, -2, -3, -2, -10, 6, - -3, 0, 1, 6, 7, 1, 2, -4, -5, 2, -5, -7, 9, 3, -6, - 6, 4, -4, 6, 10, -3, -2, 8, 10, -8, 10, -1, -9, -7, -8, - -3, 1, 1, -2, -9, -7, -6, -1, 0, 7, -9, -7, -5, 0, -4, - -4, -7, 2, 4, 6, 6, -4, -6, -8, 3, -8, -9, 6, 9, -4, - 1, -1, 0, 8, 9, 0, -5, 3, -1, 5, 0, -10, 7, -2, 6 - ], - [4, 5, 2, 3]); - - const transposeA = true; - const transposeB = false; - const c = tf.matMul(a, b, transposeA, transposeB); - - expectArraysClose(await c.data(), [ - 38, -24, 9, -30, 9, -9, -74, 39, -19, 8, 11, -30, 56, -67, - 46, -40, 71, -74, 82, 42, 55, -50, 6, 1, 60, -18, -13, -15, - -52, -61, 81, -52, 59, -15, 76, 43, 34, -56, 38, 0, 26, -14, - -15, 1, -4, 153, -34, 61, -135, 30, -48, 135, -30, 60, 38, 36, - 58, 40, 45, 71, 1, 2, 3, 24, 90, -56, -10, 40, -18, 6, - -30, 14, 34, 65, 27, 24, -29, -44, -46, -3, 35, -21, 27, 48, - 20, 52, 32, 35, -11, -46, -12, 22, 13, 30, 2, -23, -54, -48, - 34, 16, -42, -39, -26, 82, 89, 76, -84, 30, 9, 27, 30, -21, - -43, -48, 60, 20, 24, -78, -91, -63, -12, 24, 21, 28, 48, 35, - -6, 27, 33, 53, -81, -71, 61, -27, 11, -48, -82, 8, -12, -19, - -10, -48, -81, 0, 13, 32, 41, 0, -100, -120, 16, 124, 152, 45, - 60, -28, 24, 21, -12, -14, -16, 8, 9, -33, 5, -12, -48, 4, - 8, 9, 0, -31, 16, -98, -9, 4, -22, 38, 2, -96 - ]); - }); - - it('A^t x B^t', async () => { - const a = tf.tensor3d( - [ - -5, -5, -6, 8, -2, -8, 4, -7, -6, -9, -1, 3, 7, -2, 5, - -6, 3, 8, 7, -8, 1, 4, -4, 6, 4, -4, -9, -5, 2, -2 - ], - [5, 3, 2]); - const b = tf.tensor3d( - [ - -8, -4, -1, 0, -7, 0, 3, 3, 6, 2, -1, 8, -4, 9, -6, - 5, 8, 9, -9, 7, 0, -1, -1, -10, -7, 3, 4, 6, 3, -4 - ], - [5, 2, 3]); - - const transposeA = true; - const transposeB = true; - const c = tf.matMul(a, b, transposeA, transposeB); - expectArraysClose(await c.data(), [ - 66, 42, 16, -56, -12, 6, -30, 19, -1, 102, - -94, 14, -56, 32, 100, -56, -47, -11, 5, -31 - ]); - }); - }; -} - -for (let i = 0; i < MatMulProgramType.MatMulMax; i++) { - describeWithFlags(`matmul ${MatMulProgramType[i]}`, ALL_ENVS, matmulTest(i)); - // Skip MatMulSplitKProgram since it doesn't support batch > 1; - if (i !== MatMulProgramType.MatMulSplitKProgram) { - describeWithFlags( - `matmulBatch ${MatMulProgramType[i]}`, ALL_ENVS, matmulBatchTest(i)); - } -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/max_pool_backprop_webgpu.ts b/tfjs-master/tfjs-backend-webgpu/src/max_pool_backprop_webgpu.ts deleted file mode 100644 index 94089af1f..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/max_pool_backprop_webgpu.ts +++ /dev/null @@ -1,178 +0,0 @@ -/** - * @license - * Copyright 2023 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util} from '@tensorflow/tfjs-core'; -import {getMainHeaderString as main, WebGPUProgram} from './webgpu_program'; -import {computeDispatch, flatDispatchLayout} from './webgpu_util'; - -export class MaxPool2DBackpropProgram implements WebGPUProgram { - outputShape: number[]; - shaderKey: string; - dispatchLayout: {x: number[]}; - dispatch: [number, number, number]; - variableNames = ['dy', 'maxPos']; - uniforms = - `strides : vec2, pads : vec2, dilations : vec2, filterDims : vec2, - outHeight : i32, outWidth : i32`; - workgroupSize: [number, number, number] = [64, 1, 1]; - size = true; - - constructor(convInfo: backend_util.Conv2DInfo) { - this.outputShape = convInfo.inShape; - - this.dispatchLayout = flatDispatchLayout(this.outputShape); - - this.dispatch = computeDispatch( - this.dispatchLayout, this.outputShape, this.workgroupSize); - - this.shaderKey = 'maxPool2DBackprop'; - } - - getUserCode(): string { - const userCode = ` - ${main('index')} { - if (index < uniforms.size) { - let coords = getCoordsFromIndex(index); - let batch = coords[0]; - let d = coords[3]; - - let dyRCCorner = vec2(coords.yz) - uniforms.pads; - let dyRCorner = dyRCCorner.x; - let dyCCorner = dyRCCorner.y; - - // Convolve dy(?, ?, d) with pos mask(:, :, d) to get dx(xR, xC, d). - // ? = to be determined. : = across all values in that axis. - var dotProd = 0.0; - let lastIndex = uniforms.filterDims[0] * uniforms.filterDims[1] - 1; - for (var wR = 0; wR < uniforms.filterDims[0]; wR += uniforms.dilations[0]) { - let dyR = f32(dyRCorner + wR) / f32(uniforms.strides[0]); - - if (dyR < 0.0 || dyR >= f32(uniforms.outHeight) || fract(dyR) > 0.0) { - continue; - } - let idyR = i32(dyR); - - for (var wC = 0; wC < uniforms.filterDims[1]; wC += uniforms.dilations[1]) { - let dyC = f32(dyCCorner + wC) / f32(uniforms.strides[1]); - - if (dyC < 0.0 || dyC >= f32(uniforms.outWidth) || fract(dyC) > 0.0) { - continue; - } - let idyC = i32(dyC); - - let dyValue = getDy(batch, idyR, idyC, d); - let maxPosValue = lastIndex - i32(getMaxPos(batch, idyR, idyC, d)); - - // Get the current value, check it against the value from the - // position matrix. - let curPosValue = wR * uniforms.filterDims[1] + wC; - let mask = select(0.0, 1.0, maxPosValue == curPosValue); - dotProd += dyValue * mask; - } - } - setOutputAtIndex(index, dotProd); - } - } - `; - return userCode; - } -} - -export class MaxPool3DBackpropProgram implements WebGPUProgram { - outputShape: number[]; - shaderKey: string; - dispatchLayout: {x: number[]}; - dispatch: [number, number, number]; - variableNames = ['dy', 'maxPos']; - uniforms = `strides : vec3, pads : vec3, filterDims : vec3, - outDepth : i32, outHeight : i32, outWidth : i32`; - workgroupSize: [number, number, number] = [64, 1, 1]; - size = true; - - constructor(convInfo: backend_util.Conv3DInfo) { - this.outputShape = convInfo.inShape; - - this.dispatchLayout = flatDispatchLayout(this.outputShape); - - this.dispatch = computeDispatch( - this.dispatchLayout, this.outputShape, this.workgroupSize); - - this.shaderKey = 'maxPool3DBackprop'; - } - - getUserCode(): string { - const userCode = ` - ${main('index')} { - if (index < uniforms.size) { - let coords = getCoordsFromIndex(index); - let batch = coords.x; - let ch = coords.u; - - let dyCorner = vec3(coords.y, coords.z, coords.w) - uniforms.pads; - let dyDCorner = dyCorner.x; - let dyRCorner = dyCorner.y; - let dyCCorner = dyCorner.z; - - // Convolve dy(?, ?, ?, ch) with pos mask(:, :, :, d) to get - // dx(xD, xR, xC, ch). - // ? = to be determined. : = across all values in that axis. - var dotProd = 0.0; - let lastIndex = uniforms.filterDims[0] * uniforms.filterDims[1] * uniforms.filterDims[2] - 1; - - for (var wD = 0; wD < uniforms.filterDims[0]; wD++) { - let dyD = f32(dyDCorner + wD) / f32(uniforms.strides[0]); - - if (dyD < 0.0 || dyD >= f32(uniforms.outDepth) || fract(dyD) > 0.0) { - continue; - } - let idyD = i32(dyD); - - for (var wR = 0; wR < uniforms.filterDims[1]; wR++) { - let dyR = f32(dyRCorner + wR) / f32(uniforms.strides[1]); - - if (dyR < 0.0 || dyR >= f32(uniforms.outHeight) || fract(dyR) > 0.0) { - continue; - } - let idyR = i32(dyR); - - for (var wC = 0; wC < uniforms.filterDims[2]; wC++) { - let dyC = f32(dyCCorner + wC) / f32(uniforms.strides[2]); - - if (dyC < 0.0 || dyC >= f32(uniforms.outWidth) || fract(dyC) > 0.0) { - continue; - } - let idyC = i32(dyC); - - let dyValue = getDy(batch, idyD, idyR, idyC, ch); - let maxPosValue = lastIndex - i32(getMaxPos(batch, idyD, idyR, idyC, ch)); - - // Get the current value, check it against the value from the - // position matrix. - let curPosValue = wD * uniforms.filterDims[1] * uniforms.filterDims[2] + wR * uniforms.filterDims[2] + wC; - let mask = select(0.0, 1.0, maxPosValue == curPosValue); - dotProd += dyValue * mask; - } - } - } - - setOutputAtIndex(index, dotProd); - } - } - `; - return userCode; - } -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/mirror_pad_webgpu.ts b/tfjs-master/tfjs-backend-webgpu/src/mirror_pad_webgpu.ts deleted file mode 100644 index c92a9db6f..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/mirror_pad_webgpu.ts +++ /dev/null @@ -1,89 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {getCoordsDataType, getMainHeaderString as main, WebGPUProgram} from './webgpu_program'; -import {computeDispatch, flatDispatchLayout} from './webgpu_util'; - -export class MirrorPadProgram implements WebGPUProgram { - outputShape: number[]; - shaderKey: string; - uniforms = ''; - dispatchLayout: {x: number[]}; - dispatch: [number, number, number]; - variableNames = ['x']; - workgroupSize: [number, number, number] = [64, 1, 1]; - xShape: number[]; - offset: number; - size = true; - - constructor( - xShape: number[], paddings: Array<[number, number]>, - mode: 'reflect'|'symmetric') { - this.outputShape = paddings.map( - (p, i) => p[0] /* beforePad */ + xShape[i] + p[1] /* afterPad */); - this.dispatchLayout = flatDispatchLayout(this.outputShape); - this.dispatch = computeDispatch( - this.dispatchLayout, this.outputShape, this.workgroupSize); - - this.xShape = xShape; - paddings.map((_, i) => { - this.uniforms += ` pad${i} : vec2,`; - }); - this.offset = mode === 'reflect' ? 0 : 1; - this.shaderKey = `mirrorPad_${mode}`; - } - - getUserCode(): string { - const rank = this.xShape.length; - // The length of paddings are same with the rank of the input tensor. - const start = this.xShape.map((_, i) => `uniforms.pad${i}[0]`).join(','); - const end = this.xShape - .map( - (_, i) => `uniforms.pad${i}[0] + uniforms.xShape${ - rank > 1 ? `[${i}]` : ''}`) - .join(','); - - const shaderStart = rank === 1 ? 'start' : 'start[i]'; - const shaderEnd = rank === 1 ? 'end' : 'end[i]'; - const shaderOutC = rank === 1 ? 'outC' : 'outC[i]'; - const dtype = getCoordsDataType(rank); - const unpackedCoords = rank > 1 ? - ['coords[0]', 'coords[1]', 'coords[2]', 'coords[3]'].slice(0, rank) : - 'coords'; - - return ` - ${main('index')} { - if (index < uniforms.size) { - let start = ${dtype}(${start}); - let end = ${dtype}(${end}); - var outC = getCoordsFromIndex(index); - for (var i = 0; i < ${rank}; i = i + 1) { - if (${shaderOutC} < ${shaderStart}) { - ${shaderOutC} = ${shaderStart} * 2 - ${shaderOutC} - ${ - this.offset}; - } else if(${shaderOutC} >= ${shaderEnd}) { - ${shaderOutC} = (${shaderEnd} - 1) * 2 - ${shaderOutC} + ${ - this.offset}; - } - } - let coords = outC - start; - setOutputAtIndex(index, getX(${unpackedCoords})); - } - } - `; - } -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/multinomial_webgpu.ts b/tfjs-master/tfjs-backend-webgpu/src/multinomial_webgpu.ts deleted file mode 100644 index 2f50abdc3..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/multinomial_webgpu.ts +++ /dev/null @@ -1,77 +0,0 @@ -/** - * @license - * Copyright 2023 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {getMainHeaderString as main, WebGPUProgram} from './webgpu_program'; -import {computeDispatch, flatDispatchLayout} from './webgpu_util'; - -export class MultinomialProgram implements WebGPUProgram { - variableNames: string[] = ['probs']; - outputShape: number[] = []; - shaderKey: string; - dispatchLayout: {x: number[]}; - dispatch: [number, number, number]; - uniforms = 'seed : f32, numOutcomes: i32,'; - workgroupSize: [number, number, number] = [64, 1, 1]; - size = true; - - constructor(batchSize: number, numSamples: number) { - this.outputShape = [batchSize, numSamples]; - this.dispatchLayout = flatDispatchLayout(this.outputShape); - this.dispatch = computeDispatch( - this.dispatchLayout, this.outputShape, this.workgroupSize); - - this.shaderKey = 'multinomial'; - } - - getUserCode(): string { - const userCode = ` - //Based on the work of Dave Hoskins - //https://www.shadertoy.com/view/4djSRW - fn random (seed : f32, resultUV : vec2) -> f32 { - let HASHSCALE1 = 443.8975; - let p = resultUV * seed; - var p3 = fract(vec3(p.xyx) * HASHSCALE1); - p3 = p3 + dot(p3, p3.yzx + 19.19); - return fract((p3.x + p3.y) * p3.z); - } - - ${main('index')} { - if (index < uniforms.size) { - let coords = getOutputCoords(); - let batch = coords[0]; - - let resUV = vec2(f32(coords[1]) / f32(uniforms.outShape[1]), - f32(coords[0]) / f32(uniforms.outShape[0])); - let r = random(uniforms.seed, resUV); - var cdf = 0.0; - for (var i = 0; i < uniforms.numOutcomes - 1; i = i + 1) { - cdf = cdf + getProbs(batch, i); - - if (r < cdf) { - setOutputAtIndexI32(index, i); - return; - } - } - - // If no other event happened, last event happened. - setOutputAtIndexI32(index, uniforms.numOutcomes - 1); - } - } - `; - return userCode; - } -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/onehot_webgpu.ts b/tfjs-master/tfjs-backend-webgpu/src/onehot_webgpu.ts deleted file mode 100644 index aced559bc..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/onehot_webgpu.ts +++ /dev/null @@ -1,52 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {getMainHeaderString as main, WebGPUProgram} from './webgpu_program'; -import {computeDispatch, flatDispatchLayout} from './webgpu_util'; - -export class OneHotProgram implements WebGPUProgram { - outputShape: number[]; - shaderKey: string; - dispatchLayout: {x: number[]}; - dispatch: [number, number, number]; - variableNames = ['x']; - uniforms = 'onValue : f32, offValue : f32,'; - workgroupSize: [number, number, number] = [64, 1, 1]; - size = true; - - constructor(numIndices: number, depth: number) { - this.outputShape = [numIndices, depth]; - this.dispatchLayout = flatDispatchLayout(this.outputShape); - this.dispatch = computeDispatch( - this.dispatchLayout, this.outputShape, this.workgroupSize); - this.shaderKey = 'onehot'; - } - - getUserCode(): string { - const userCode = ` - ${main('index')} { - if(index < uniforms.size) { - let coords = getCoordsFromIndex(index); - setOutputAtIndex(index, mix(uniforms.offValue, uniforms.onValue, - f32(i32(round(getX(coords.x))) == coords.y))); - } - } - `; - - return userCode; - } -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/pad_webgpu.ts b/tfjs-master/tfjs-backend-webgpu/src/pad_webgpu.ts deleted file mode 100644 index f999a4538..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/pad_webgpu.ts +++ /dev/null @@ -1,88 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {getCoordsDataType, getMainHeaderString as main, WebGPUProgram} from './webgpu_program'; -import {computeDispatch, flatDispatchLayout} from './webgpu_util'; - -export function padCommon(shape: number[], fillZero = false): string { - const rank = shape.length; - const type = getCoordsDataType(rank); - const start = shape.map((_, i) => `uniforms.pad${i}[0]`).join(','); - const end = shape - .map( - (_, i) => `uniforms.pad${i}[0] + uniforms.xShape${ - rank > 1 ? `[${i}]` : ''}`) - .join(','); - const startValue = rank > 1 ? `${type}(${start})` : `${start}`; - const endValue = rank > 1 ? `${type}(${end})` : `${end}`; - - const leftPadCondition = - rank > 1 ? `any(paddedCoords < start)` : `paddedCoords < start`; - const rightPadCondition = - rank > 1 ? `any(paddedCoords >= end)` : `paddedCoords >= end`; - - const unpackedCoords = rank > 1 ? - ['coords[0]', 'coords[1]', 'coords[2]', 'coords[3]'].slice(0, rank) : - 'coords'; - return ` - let start = ${startValue}; - let end = ${endValue}; - if (${leftPadCondition} || ${rightPadCondition}) { - setOutputAtIndex(index, ${fillZero ? 0.0 : 'uniforms.constantValue'}); - } else { - let coords = paddedCoords - start; - setOutputAtIndex(index, getX(${unpackedCoords})); - } - `; -} - -export class PadProgram implements WebGPUProgram { - outputShape: number[]; - shaderKey: string; - dispatchLayout: {x: number[]}; - dispatch: [number, number, number]; - variableNames = ['x']; - uniforms = 'constantValue : f32,'; - workgroupSize: [number, number, number] = [64, 1, 1]; - xShape: number[]; - size = true; - - constructor(xShape: number[], paddings: Array<[number, number]>) { - this.outputShape = paddings.map( - (p, i) => p[0] /* beforePad */ + xShape[i] + p[1] /* afterPad */); - this.dispatchLayout = flatDispatchLayout(this.outputShape); - this.dispatch = computeDispatch( - this.dispatchLayout, this.outputShape, this.workgroupSize); - paddings.map((_, i) => { - this.uniforms += ` pad${i} : vec2,`; - }); - this.xShape = xShape; - this.shaderKey = 'pad'; - } - - getUserCode(): string { - const userCode = ` - ${main('index')} { - if (index < uniforms.size) { - let paddedCoords = getCoordsFromIndex(index); - ${padCommon(this.xShape)} - } - } - `; - return userCode; - } -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/pool_filtersizeone_webgpu.ts b/tfjs-master/tfjs-backend-webgpu/src/pool_filtersizeone_webgpu.ts deleted file mode 100644 index ccd7e47e9..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/pool_filtersizeone_webgpu.ts +++ /dev/null @@ -1,61 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util} from '@tensorflow/tfjs-core'; -import {getMainHeaderString as main, WebGPUProgram} from './webgpu_program'; -import {computeDispatch, flatDispatchLayout} from './webgpu_util'; - -export class PoolWithFilterSizeEqualsOneProgram implements WebGPUProgram { - outputShape: number[]; - shaderKey: string; - dispatchLayout: {x: number[]}; - dispatch: [number, number, number]; - variableNames = ['x']; - uniforms = `strides : vec2,`; - workgroupSize: [number, number, number] = [256, 1, 1]; - size = true; - - constructor(convInfo: backend_util.Conv2DInfo) { - this.outputShape = convInfo.outShape; - this.dispatchLayout = flatDispatchLayout(this.outputShape); - - this.dispatch = computeDispatch( - this.dispatchLayout, this.outputShape, this.workgroupSize); - - this.shaderKey = 'poolWithFilterSizeEqualsOne'; - } - - getUserCode(): string { - const userCode = ` - ${main('index')} { - if (index < uniforms.size) { - let coords = getCoordsFromIndex(index); - let batch = coords[0]; - let d = coords[3]; - - let xRCCorner = coords.yz * uniforms.strides; - let xRCorner = xRCCorner.x; - let xCCorner = xRCCorner.y; - - let value = getX(batch, xRCorner, xCCorner, d); - setOutputAtIndex(index, value); - } - } - `; - return userCode; - } -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/pool_webgpu.ts b/tfjs-master/tfjs-backend-webgpu/src/pool_webgpu.ts deleted file mode 100644 index 78b74ee4c..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/pool_webgpu.ts +++ /dev/null @@ -1,246 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util} from '@tensorflow/tfjs-core'; -import {getMainHeaderString as main, WebGPUProgram} from './webgpu_program'; -import {computeDispatch, flatDispatchLayout} from './webgpu_util'; - -export class Pool2DProgram implements WebGPUProgram { - outputShape: number[]; - shaderKey: string; - dispatchLayout: {x: number[]}; - dispatch: [number, number, number]; - variableNames = ['x']; - uniforms = - `strides : vec2, pads : vec2, dilations : vec2, convDims : vec2, filterDims : vec2,`; - // TODO(jiajia.qin@intel.com): Dynamically choose different workgroupSize for - // different output shapes. - workgroupSize: [number, number, number] = [128, 1, 1]; - poolType: 'max'|'avg'; - size = true; - computePositions: boolean; - flattenPositions: boolean; - includeBatchIndex: boolean; - - constructor( - convInfo: backend_util.Conv2DInfo, poolType: 'max'|'avg', - computePositions = false, flattenPositions = false, - includeBatchIndex = false) { - if (poolType === 'avg' && computePositions) { - throw new Error('Cannot compute positions for average pool.'); - } - - this.outputShape = convInfo.outShape; - this.dispatchLayout = flatDispatchLayout(this.outputShape); - this.dispatch = computeDispatch( - this.dispatchLayout, this.outputShape, this.workgroupSize); - - this.poolType = poolType; - this.computePositions = computePositions; - this.flattenPositions = flattenPositions; - this.includeBatchIndex = includeBatchIndex; - this.shaderKey = `pool2D_${poolType}_${computePositions}_${ - flattenPositions}_${includeBatchIndex}`; - } - - getUserCode(): string { - let updateSnippet: string; - if (this.poolType === 'avg') { - updateSnippet = `resultValue = resultValue + value; count = count + 1.0;`; - } else if (this.computePositions) { - const positionStr = this.flattenPositions ? - (this.includeBatchIndex ? - `((batch * uniforms.xShape[1] + xR) * uniforms.xShape[2] + xC) * uniforms.xShape[3] + d` : - `(xR * uniforms.xShape[2] + xC) * uniforms.xShape[3] + d`) : - `wR * uniforms.filterDims.y + wC`; - updateSnippet = `let currMaxValue = mix(value, maxValue, maxValueFound); - if (value >= currMaxValue) { - maxValue = value; - maxValueFound = 1.0; - maxPosition = ${positionStr}; - }`; - } else { - updateSnippet = `resultValue = max(value, resultValue);`; - } - - let returnValue = `resultValue`; - if (this.poolType === 'avg') { - returnValue = `resultValue / max(count, 1.0)`; - } - - const userCode = ` - ${main('index')} { - if (index < uniforms.size) { - let coords = getCoordsFromIndex(index); - let batch = coords[0]; - let d = coords[3]; - let xRCCorner = vec2(coords.yz) * uniforms.strides - uniforms.pads; - let xRCorner = xRCCorner.x; - let xCCorner = xRCCorner.y; - - ${ - this.computePositions ? - `var maxValue = 0.0; - var maxValueFound = 0.0; - var maxPosition = 0;` : - `var resultValue = ${ - this.poolType === 'avg' ? '0.0' : '-1.0 / pow(10.0, -20.0)'};`} - - var count = 0.0; - for (var wR = 0; wR < uniforms.filterDims.x; wR = wR + uniforms.dilations.x) { - let xR = xRCorner + wR; - - if (xR < 0 || xR >= uniforms.convDims.x) { - continue; - } - - for (var wC = 0; wC < uniforms.filterDims.y; wC = wC + uniforms.dilations.y) { - let xC = xCCorner + wC; - if (xC < 0 || xC >= uniforms.convDims.y) { - continue; - } - - let value = getX(batch, xR, xC, d); - ${updateSnippet} - } - } - - ${ - this.computePositions ? `setOutputAtIndexI32(index, maxPosition);` : - `setOutputAtIndex(index, ${returnValue});`} - } - } - `; - return userCode; - } -} - -export class Pool3DProgram implements WebGPUProgram { - outputShape: number[]; - shaderKey: string; - dispatchLayout: {x: number[]}; - dispatch: [number, number, number]; - variableNames = ['x']; - uniforms = - `strides : vec3, pads : vec3, convDims : vec3, filterDims : vec3,`; - workgroupSize: [number, number, number] = [128, 1, 1]; - poolType: 'max'|'avg'; - size = true; - computePositions: boolean; - flattenPositions: boolean; - includeBatchIndex: boolean; - - constructor( - convInfo: backend_util.Conv3DInfo, poolType: 'max'|'avg', - computePositions = false, flattenPositions = false, - includeBatchIndex = false) { - if (poolType === 'avg' && computePositions) { - throw new Error('Cannot compute positions for average pool.'); - } - - this.outputShape = convInfo.outShape; - this.dispatchLayout = flatDispatchLayout(this.outputShape); - this.dispatch = computeDispatch( - this.dispatchLayout, this.outputShape, this.workgroupSize); - - this.poolType = poolType; - this.computePositions = computePositions; - this.flattenPositions = flattenPositions; - this.includeBatchIndex = includeBatchIndex; - this.shaderKey = `pool3D_${poolType}_${computePositions}_${ - flattenPositions}_${includeBatchIndex}`; - } - - getUserCode(): string { - let updateSnippet: string; - if (this.poolType === 'avg') { - updateSnippet = `resultValue += value; count += 1.0;`; - } else if (this.computePositions) { - const positionStr = this.flattenPositions ? - (this.includeBatchIndex ? - `(((batch * uniforms.xShape.y + xD) * uniforms.xShape.z + xR) * uniforms.xShape.w + xC) * uniforms.xShape.u + ch` : - `((xD * uniforms.xShape.z + xR) * uniforms.xShape.w + xC) * uniforms.xShape.u + ch`) : - `wD * uniforms.filterDims.y * uniforms.filterDims.y + wR * uniforms.filterDims.z + wC`; - updateSnippet = `let currMaxValue = mix(value, maxValue, maxValueFound); - if (value >= currMaxValue) { - maxValue = value; - maxValueFound = 1.0; - maxPosition = ${positionStr}; - }`; - } else { - updateSnippet = `resultValue = max(value, resultValue);`; - } - - let returnValue = `resultValue`; - if (this.poolType === 'avg') { - returnValue = `resultValue / max(count, 1.0)`; - } - - const userCode = ` - ${main('index')} { - if (index < uniforms.size) { - let coords = getCoordsFromIndex(index); - let batch = coords.x; - let ch = coords.u; - - let xCorner = vec3(coords.y, coords.z, coords.w) * uniforms.strides - uniforms.pads; - let xDCorner = xCorner.x; - let xRCorner = xCorner.y; - let xCCorner = xCorner.z; - - ${ - this.computePositions ? - `var maxValue = 0.0; - var maxValueFound = 0.0; - var maxPosition = 0;` : - `var resultValue = ${ - this.poolType === 'avg' ? '0.0' : '-1.0 / pow(10.0, -20.0)'};`} - - var count = 0.0; - for (var wD = 0; wD < uniforms.filterDims.x; wD++) { - let xD = xDCorner + wD; - if (xD < 0 || xD >= uniforms.convDims.x) { - continue; - } - - for (var wR = 0; wR < uniforms.filterDims.y; wR++) { - let xR = xRCorner + wR; - if (xR < 0 || xR >= uniforms.convDims.y) { - continue; - } - - for (var wC = 0; wC < uniforms.filterDims.z; wC++) { - let xC = xCCorner + wC; - if (xC < 0 || xC >= uniforms.convDims.z) { - continue; - } - - let value = getX(batch, xD, xR, xC, ch); - ${updateSnippet} - } - } - } - - ${ - this.computePositions ? `setOutputAtIndexI32(index, maxPosition);` : - `setOutputAtIndex(index, ${returnValue});`} - } - } - `; - return userCode; - } -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/reduce_webgpu.ts b/tfjs-master/tfjs-backend-webgpu/src/reduce_webgpu.ts deleted file mode 100644 index ab0d86207..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/reduce_webgpu.ts +++ /dev/null @@ -1,145 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util} from '@tensorflow/tfjs-core'; -import {getMainHeaderString as main, WebGPUProgram} from './webgpu_program'; -import {computeDispatch, flatDispatchLayout} from './webgpu_util'; - -export class ReduceProgram implements WebGPUProgram { - outputShape: number[]; - shaderKey: string; - dispatchLayout: {x: number[]}; - dispatch: [number, number, number]; - workgroupSize: [number, number, number]; - variableNames = ['x']; - uniforms = 'reduceSize : i32,'; - reduceType: 'all'|'any'|'max'|'mean'|'min'|'prod'|'sum'; - inputShape: number[]; - size = true; - - constructor( - reduceInfo: backend_util.ReduceInfo, - reduceType: 'all'|'any'|'max'|'mean'|'min'|'prod'|'sum', - maxComputeWorkgroupSizeX: number) { - this.inputShape = [reduceInfo.batchSize, reduceInfo.inSize]; - const [outputShape, ] = - backend_util.computeOutAndReduceShapes(this.inputShape, [1]); - this.outputShape = outputShape.length === 0 ? [1] : outputShape; - // If reduceSize |reduceInfo.inSize| is very large, the I/O accessing will - // become the bottleneck. Increasing workgroupSize can reduce the times of - // accessing global memory. The threshold value is just to make sure the - // reduceSize is large enough for a bigger workgroupSize. - if (reduceInfo.inSize >= 32768 && maxComputeWorkgroupSizeX >= 512) { - this.workgroupSize = [512, 1, 1]; - } else if (reduceInfo.inSize >= 4096) { - this.workgroupSize = [256, 1, 1]; - } else { - this.workgroupSize = [64, 1, 1]; - } - this.dispatchLayout = flatDispatchLayout(this.outputShape); - // A work group only outputs a data, so we transfer [1, 1, 1] to compute - // dispatch size. - this.dispatch = - computeDispatch(this.dispatchLayout, this.outputShape, [1, 1, 1]); - - this.reduceType = reduceType; - this.shaderKey = `reduce_${reduceType}`; - } - - getUserCode(): string { - let reduceOp = ``; - let initValue = '0.0'; - const workgroupSizeX = this.workgroupSize[0]; - if (this.reduceType === 'min' || this.reduceType === 'max') { - reduceOp = ` - if (isnan(candidate)) { - bestValue = uniforms.NAN; - } else if (!isnan(bestValue) && candidate ${ - this.reduceType === 'min' ? '<' : '>'} bestValue) - { bestValue = candidate; }`; - initValue = 'f32(x[offset])'; - } else if (this.reduceType === 'sum' || this.reduceType === 'mean') { - reduceOp = ' bestValue = bestValue + candidate; '; - } else if (this.reduceType === 'prod') { - reduceOp = ' bestValue = bestValue * candidate; '; - initValue = '1.0'; - } else if (this.reduceType === 'all') { - reduceOp = ' bestValue = f32(bestValue >= 1.0 && candidate >= 1.0); '; - initValue = '1.0'; - } else if (this.reduceType === 'any') { - reduceOp = ' bestValue = f32(bestValue >= 1.0 || candidate >= 1.0); '; - initValue = '0.0'; - } - - const outputSnippet = this.reduceType === 'mean' ? - // tslint:disable-next-line:max-line-length - `setOutputAtIndex(outputIndex, bestValue / f32(uniforms.reduceSize));` : - `setOutputAtIndex(outputIndex, bestValue);`; - - const sharedMemorySnippet = ` - var xBestValues : array; - `; - - const userCode = ` - fn DIV_CEIL(a : u32, b : u32) -> u32 { - return ((a - 1u) / b + 1u); - } - - ${sharedMemorySnippet} - fn getOffset(outputIndex : i32) -> i32 { - let outputCoords = getCoordsFromIndex(outputIndex); - let offset = ${ - this.outputShape.length === 1 ? - 'outputCoords' : - 'outputCoords[0]'} * uniforms.reduceSize; - return offset; - } - ${main('index')} { - let outputIndex = index / ${workgroupSizeX}; - let offset = getOffset(outputIndex); - var bestValue = ${initValue}; - let Length = uniforms.reduceSize; - let WorkPerThread = DIV_CEIL(u32(Length), ${workgroupSizeX}u); - for (var k = i32(localId.x); k < Length && outputIndex < uniforms.size; - k = k + ${workgroupSizeX}) { - let candidate = f32(x[offset + k]); - ${reduceOp} - } - xBestValues[localId.x] = bestValue; - workgroupBarrier(); - - var reduceSize = min(u32(Length), ${workgroupSizeX}u); - for (var currentSize = reduceSize / 2u; reduceSize > 1u; - currentSize = reduceSize / 2u) { - let interval = DIV_CEIL(reduceSize, 2u); - if (localId.x < currentSize) { - let candidate = xBestValues[localId.x + interval]; - ${reduceOp} - xBestValues[localId.x] = bestValue; - } - reduceSize = interval; - workgroupBarrier(); - } - - if (localId.x == 0u && outputIndex < uniforms.size) { - ${outputSnippet} - } - } - `; - return userCode; - } -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/register_all_kernels.ts b/tfjs-master/tfjs-backend-webgpu/src/register_all_kernels.ts deleted file mode 100644 index 26d2ef3a1..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/register_all_kernels.ts +++ /dev/null @@ -1,350 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {KernelConfig, registerKernel} from '@tensorflow/tfjs-core'; - -import {_fusedMatMulConfig} from './kernels/_FusedMatMul'; -import {absConfig} from './kernels/Abs'; -import {acosConfig} from './kernels/Acos'; -import {acoshConfig} from './kernels/Acosh'; -import {addConfig} from './kernels/Add'; -import {addNConfig} from './kernels/AddN'; -import {allConfig} from './kernels/All'; -import {anyConfig} from './kernels/Any'; -import {argMaxConfig} from './kernels/ArgMax'; -import {argMinConfig} from './kernels/ArgMin'; -import {asinConfig} from './kernels/Asin'; -import {asinhConfig} from './kernels/Asinh'; -import {atanConfig} from './kernels/Atan'; -import {atan2Config} from './kernels/Atan2'; -import {atanhConfig} from './kernels/Atanh'; -import {avgPoolConfig} from './kernels/AvgPool'; -import {avgPool3DConfig} from './kernels/AvgPool3D'; -import {avgPool3DGradConfig} from './kernels/AvgPool3DGrad'; -import {avgPoolGradConfig} from './kernels/AvgPoolGrad'; -import {batchMatMulConfig} from './kernels/BatchMatMul'; -import {batchToSpaceNDConfig} from './kernels/BatchToSpaceND'; -import {bincountConfig} from './kernels/Bincount'; -import {broadcastArgsConfig} from './kernels/BroadcastArgs'; -import {castConfig} from './kernels/Cast'; -import {ceilConfig} from './kernels/Ceil'; -import {clipByValueConfig} from './kernels/ClipByValue'; -import {complexConfig} from './kernels/Complex'; -import {complexAbsConfig} from './kernels/ComplexAbs'; -import {concatConfig} from './kernels/Concat'; -import {conv2DConfig} from './kernels/Conv2D'; -import {conv2DBackpropFilterConfig} from './kernels/Conv2DBackpropFilter'; -import {conv2DBackpropInputConfig} from './kernels/Conv2DBackpropInput'; -import {conv3DConfig} from './kernels/Conv3D'; -import {conv3DBackpropFilterV2Config} from './kernels/Conv3DBackpropFilterV2'; -import {conv3DBackpropInputV2Config} from './kernels/Conv3DBackpropInputV2'; -import {cosConfig} from './kernels/Cos'; -import {coshConfig} from './kernels/Cosh'; -import {cropAndResizeConfig} from './kernels/CropAndResize'; -import {cumprodConfig} from './kernels/Cumprod'; -import {cumsumConfig} from './kernels/Cumsum'; -import {denseBincountConfig} from './kernels/DenseBincount'; -import {depthToSpaceConfig} from './kernels/DepthToSpace'; -import {depthwiseConv2dNativeConfig} from './kernels/DepthwiseConv2dNative'; -import {depthwiseConv2dNativeBackpropFilterConfig} from './kernels/DepthwiseConv2dNativeBackpropFilter'; -import {depthwiseConv2dNativeBackpropInputConfig} from './kernels/DepthwiseConv2dNativeBackpropInput'; -import {diagConfig} from './kernels/Diag'; -import {dilation2DConfig} from './kernels/Dilation2D'; -import {dilation2DBackpropFilterConfig} from './kernels/Dilation2DBackpropFilter'; -import {dilation2DBackpropInputConfig} from './kernels/Dilation2DBackpropInput'; -import {drawConfig} from './kernels/Draw'; -import {einsumConfig} from './kernels/Einsum'; -import {eluConfig} from './kernels/Elu'; -import {eluGradConfig} from './kernels/EluGrad'; -import {equalConfig} from './kernels/Equal'; -import {erfConfig} from './kernels/Erf'; -import {expConfig} from './kernels/Exp'; -import {expandDimsConfig} from './kernels/ExpandDims'; -import {expm1Config} from './kernels/Expm1'; -import {fftConfig} from './kernels/FFT'; -import {fillConfig} from './kernels/Fill'; -import {flipLeftRightConfig} from './kernels/FlipLeftRight'; -import {floorConfig} from './kernels/Floor'; -import {floorDivConfig} from './kernels/FloorDiv'; -import {fromPixelsConfig} from './kernels/FromPixels'; -import {fusedBatchNormConfig} from './kernels/FusedBatchNorm'; -import {fusedConv2DConfig} from './kernels/FusedConv2D'; -import {fusedDepthwiseConv2DConfig} from './kernels/FusedDepthwiseConv2D'; -import {gatherNdConfig} from './kernels/GatherNd'; -import {gatherV2Config} from './kernels/GatherV2'; -import {greaterConfig} from './kernels/Greater'; -import {greaterEqualConfig} from './kernels/GreaterEqual'; -import {identityConfig} from './kernels/Identity'; -import {ifftConfig} from './kernels/IFFT'; -import {imagConfig} from './kernels/Imag'; -import {isFiniteConfig} from './kernels/IsFinite'; -import {isInfConfig} from './kernels/IsInf'; -import {isNaNConfig} from './kernels/IsNaN'; -import {leakyReluConfig} from './kernels/LeakyRelu'; -import {lessConfig} from './kernels/Less'; -import {lessEqualConfig} from './kernels/LessEqual'; -import {linSpaceConfig} from './kernels/LinSpace'; -import {logConfig} from './kernels/Log'; -import {log1pConfig} from './kernels/Log1p'; -import {logicalAndConfig} from './kernels/LogicalAnd'; -import {logicalNotConfig} from './kernels/LogicalNot'; -import {logicalOrConfig} from './kernels/LogicalOr'; -import {lrnConfig} from './kernels/LRN'; -import {lrnGradConfig} from './kernels/LRNGrad'; -import {maxConfig} from './kernels/Max'; -import {maximumConfig} from './kernels/Maximum'; -import {maxPoolConfig} from './kernels/MaxPool'; -import {maxPool3DConfig} from './kernels/MaxPool3D'; -import {maxPool3DGradConfig} from './kernels/MaxPool3DGrad'; -import {maxPoolGradConfig} from './kernels/MaxPoolGrad'; -import {maxPoolWithArgmaxConfig} from './kernels/MaxPoolWithArgmax'; -import {meanConfig} from './kernels/Mean'; -import {minConfig} from './kernels/Min'; -import {minimumConfig} from './kernels/Minimum'; -import {mirrorPadConfig} from './kernels/MirrorPad'; -import {modConfig} from './kernels/Mod'; -import {multinomialConfig} from './kernels/Multinomial'; -import {multiplyConfig} from './kernels/Multiply'; -import {negConfig} from './kernels/Neg'; -import {nonMaxSuppressionV3Config} from './kernels/NonMaxSuppressionV3'; -import {nonMaxSuppressionV5Config} from './kernels/NonMaxSuppressionV5'; -import {notEqualConfig} from './kernels/NotEqual'; -import {oneHotConfig} from './kernels/OneHot'; -import {onesLikeConfig} from './kernels/OnesLike'; -import {packConfig} from './kernels/Pack'; -import {padV2Config} from './kernels/PadV2'; -import {powConfig} from './kernels/Pow'; -import {preluConfig} from './kernels/Prelu'; -import {prodConfig} from './kernels/Prod'; -import {rangeConfig} from './kernels/Range'; -import {realConfig} from './kernels/Real'; -import {realDivConfig} from './kernels/RealDiv'; -import {reciprocalConfig} from './kernels/Reciprocal'; -import {reluConfig} from './kernels/Relu'; -import {relu6Config} from './kernels/Relu6'; -import {reshapeConfig} from './kernels/Reshape'; -import {resizeBilinearConfig} from './kernels/ResizeBilinear'; -import {resizeBilinearGradConfig} from './kernels/ResizeBilinearGrad'; -import {resizeNearestNeighborConfig} from './kernels/ResizeNearestNeighbor'; -import {resizeNearestNeighborGradConfig} from './kernels/ResizeNearestNeighborGrad'; -import {reverseConfig} from './kernels/Reverse'; -import {rotateWithOffsetConfig} from './kernels/RotateWithOffset'; -import {roundConfig} from './kernels/Round'; -import {rsqrtConfig} from './kernels/Rsqrt'; -import {scatterNdConfig} from './kernels/ScatterNd'; -import {searchSortedConfig} from './kernels/SearchSorted'; -import {selectConfig} from './kernels/Select'; -import {seluConfig} from './kernels/Selu'; -import {sigmoidConfig} from './kernels/Sigmoid'; -import {signConfig} from './kernels/Sign'; -import {sinConfig} from './kernels/Sin'; -import {sinhConfig} from './kernels/Sinh'; -import {sliceConfig} from './kernels/Slice'; -import {softmaxConfig} from './kernels/Softmax'; -import {softplusConfig} from './kernels/Softplus'; -import {spaceToBatchNDConfig} from './kernels/SpaceToBatchND'; -import {sparseSegmentMeanConfig} from './kernels/SparseSegmentMean'; -import {sparseSegmentSumConfig} from './kernels/SparseSegmentSum'; -import {sparseToDenseConfig} from './kernels/SparseToDense'; -import {splitVConfig} from './kernels/SplitV'; -import {sqrtConfig} from './kernels/Sqrt'; -import {squareConfig} from './kernels/Square'; -import {squaredDifferenceConfig} from './kernels/SquaredDifference'; -import {stepConfig} from './kernels/Step'; -import {stridedSliceConfig} from './kernels/StridedSlice'; -import {stringNGramsConfig} from './kernels/StringNGrams'; -import {subConfig} from './kernels/Sub'; -import {sumConfig} from './kernels/Sum'; -import {tanConfig} from './kernels/Tan'; -import {tanhConfig} from './kernels/Tanh'; -import {tensorScatterUpdateConfig} from './kernels/TensorScatterUpdate'; -import {tileConfig} from './kernels/Tile'; -import {topKConfig} from './kernels/TopK'; -import {transformConfig} from './kernels/Transform'; -import {transposeConfig} from './kernels/Transpose'; -import {unpackConfig} from './kernels/Unpack'; -import {unsortedSegmentSumConfig} from './kernels/UnsortedSegmentSum'; -import {zerosLikeConfig} from './kernels/ZerosLike'; - -// List all kernel configs here -const kernelConfigs: KernelConfig[] = [ - _fusedMatMulConfig, - absConfig, - acosConfig, - acoshConfig, - addConfig, - addNConfig, - allConfig, - anyConfig, - argMaxConfig, - argMinConfig, - asinConfig, - asinhConfig, - atanConfig, - atan2Config, - atanhConfig, - avgPoolConfig, - avgPool3DConfig, - avgPool3DGradConfig, - avgPoolGradConfig, - batchMatMulConfig, - batchToSpaceNDConfig, - bincountConfig, - broadcastArgsConfig, - castConfig, - ceilConfig, - clipByValueConfig, - complexConfig, - complexAbsConfig, - concatConfig, - conv2DConfig, - conv2DBackpropFilterConfig, - conv2DBackpropInputConfig, - conv3DConfig, - conv3DBackpropFilterV2Config, - conv3DBackpropInputV2Config, - cosConfig, - coshConfig, - cropAndResizeConfig, - cumprodConfig, - cumsumConfig, - denseBincountConfig, - depthToSpaceConfig, - depthwiseConv2dNativeBackpropFilterConfig, - depthwiseConv2dNativeBackpropInputConfig, - depthwiseConv2dNativeConfig, - diagConfig, - dilation2DConfig, - dilation2DBackpropFilterConfig, - dilation2DBackpropInputConfig, - drawConfig, - einsumConfig, - eluConfig, - eluGradConfig, - equalConfig, - erfConfig, - expConfig, - expandDimsConfig, - expm1Config, - fftConfig, - fillConfig, - flipLeftRightConfig, - fromPixelsConfig, - floorConfig, - floorDivConfig, - fusedBatchNormConfig, - fusedConv2DConfig, - fusedDepthwiseConv2DConfig, - gatherNdConfig, - gatherV2Config, - greaterConfig, - greaterEqualConfig, - identityConfig, - ifftConfig, - imagConfig, - isFiniteConfig, - isInfConfig, - isNaNConfig, - leakyReluConfig, - lessConfig, - lessEqualConfig, - linSpaceConfig, - log1pConfig, - logConfig, - logicalAndConfig, - logicalNotConfig, - logicalOrConfig, - lrnConfig, - lrnGradConfig, - maxConfig, - maximumConfig, - maxPoolConfig, - maxPoolGradConfig, - maxPool3DConfig, - maxPool3DGradConfig, - maxPoolWithArgmaxConfig, - meanConfig, - minConfig, - minimumConfig, - mirrorPadConfig, - modConfig, - multinomialConfig, - multiplyConfig, - negConfig, - nonMaxSuppressionV3Config, - nonMaxSuppressionV5Config, - notEqualConfig, - oneHotConfig, - onesLikeConfig, - packConfig, - padV2Config, - powConfig, - preluConfig, - prodConfig, - rangeConfig, - realConfig, - realDivConfig, - reciprocalConfig, - reluConfig, - relu6Config, - reshapeConfig, - resizeBilinearConfig, - resizeBilinearGradConfig, - resizeNearestNeighborConfig, - resizeNearestNeighborGradConfig, - reverseConfig, - rotateWithOffsetConfig, - roundConfig, - rsqrtConfig, - scatterNdConfig, - searchSortedConfig, - selectConfig, - seluConfig, - sigmoidConfig, - signConfig, - sinConfig, - sinhConfig, - sliceConfig, - stepConfig, - stridedSliceConfig, - stringNGramsConfig, - softmaxConfig, - softplusConfig, - spaceToBatchNDConfig, - sparseSegmentMeanConfig, - sparseSegmentSumConfig, - sparseToDenseConfig, - splitVConfig, - sqrtConfig, - squareConfig, - squaredDifferenceConfig, - subConfig, - sumConfig, - tanConfig, - tanhConfig, - tensorScatterUpdateConfig, - tileConfig, - topKConfig, - transformConfig, - transposeConfig, - unpackConfig, - unsortedSegmentSumConfig, - zerosLikeConfig -]; - -for (const kernelConfig of kernelConfigs) { - registerKernel(kernelConfig); -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/resize_bilinear_backprop_webgpu.ts b/tfjs-master/tfjs-backend-webgpu/src/resize_bilinear_backprop_webgpu.ts deleted file mode 100644 index d24a46ed3..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/resize_bilinear_backprop_webgpu.ts +++ /dev/null @@ -1,124 +0,0 @@ -/** - * @license - * Copyright 2023 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {getMainHeaderString as main, WebGPUProgram} from './webgpu_program'; -import {computeDispatch, flatDispatchLayout} from './webgpu_util'; - -export class ResizeBilinearBackpropProgram implements WebGPUProgram { - outputShape: number[]; - shaderKey: string; - dispatchLayout: {x: number[]}; - dispatch: [number, number, number]; - variableNames = ['dy']; - uniforms = - `effectiveXSize : vec2, effectiveYSize : vec2, heightScale : f32, widthScale : f32, - invHeightScale : f32, invWidthScale : f32, winHeight : i32, winWidth : i32,`; - workgroupSize: [number, number, number] = [64, 1, 1]; - alignCorners: boolean; - size = true; - - constructor( - inputShape: [number, number, number, number], alignCorners: boolean) { - this.outputShape = inputShape; - - this.dispatchLayout = flatDispatchLayout(this.outputShape); - this.dispatch = computeDispatch( - this.dispatchLayout, this.outputShape, this.workgroupSize); - - this.alignCorners = alignCorners; - this.shaderKey = `resizeBilinearBackprop_${alignCorners}`; - } - - getUserCode(): string { - const userCode = ` - ${main('index')} { - if (index < uniforms.size) { - let coords = getOutputCoords(); - let b = coords[0]; - let d = coords[3]; - let r = coords[1]; - let c = coords[2]; - - var accumulator = 0.0; - - // Compute bounds for where in dy we will look - let startRLerp = floor(f32(r) * uniforms.invHeightScale); - let startDyR = i32(startRLerp - f32(uniforms.winHeight / 2)); - - let startCLerp = floor(f32(c) * uniforms.invWidthScale); - let startDyC = i32(startCLerp - f32(uniforms.winWidth / 2)); - - // Loop over dy - for (var dyROffset = 0; dyROffset < uniforms.winHeight; dyROffset++) { - let dyR = startDyR + dyROffset; - - // Guard against the window exceeding the bounds of dy - if (dyR < 0 || dyR >= uniforms.dyShape[1]) { - continue; - } - - for (var dyCOffset = 0; dyCOffset < uniforms.winWidth; dyCOffset++) { - let dyC = startDyC + dyCOffset; - - // Guard against the window exceeding the bounds of dy - if (dyC < 0 || dyC >= uniforms.dyShape[2]) { - continue; - } - - let dxR = f32(dyR) * uniforms.heightScale; - let topDxRIndex = i32(floor(dxR)); - let bottomDxRIndex = i32(min(ceil(dxR), f32(uniforms.outShape[1] - 1))); - let dxRLerp = dxR - f32(topDxRIndex); - let inverseDxRLerp = 1.0 - dxRLerp; - - let dxC = f32(dyC) * uniforms.widthScale; - let leftDxCIndex = i32(floor(dxC)); - let rightDxCIndex = i32(min(ceil(dxC), f32(uniforms.outShape[2] - 1))); - let dxCLerp = dxC - f32(leftDxCIndex); - let inverseDxCLerp = 1.0 - dxCLerp; - - if (r == topDxRIndex && c == leftDxCIndex) { - // topLeft - accumulator += - getDy(b, dyR, dyC, d) * inverseDxRLerp * inverseDxCLerp; - } - - if (r == topDxRIndex && c == rightDxCIndex) { - // topRight - accumulator += getDy(b, dyR, dyC, d) * inverseDxRLerp * dxCLerp; - } - - if (r == bottomDxRIndex && c == leftDxCIndex) { - // bottomLeft - accumulator += getDy(b, dyR, dyC, d) * dxRLerp * inverseDxCLerp; - } - - if (r == bottomDxRIndex && c == rightDxCIndex) { - // bottomRight - accumulator += getDy(b, dyR, dyC, d) * dxRLerp * dxCLerp; - } - } - } - // End loop over dy - - setOutputAtIndex(index, accumulator); - } - } - `; - return userCode; - } -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/resize_bilinear_webgpu.ts b/tfjs-master/tfjs-backend-webgpu/src/resize_bilinear_webgpu.ts deleted file mode 100644 index ca07e81a6..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/resize_bilinear_webgpu.ts +++ /dev/null @@ -1,91 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {getMainHeaderString as main, WebGPUProgram} from './webgpu_program'; -import {computeDispatch, flatDispatchLayout} from './webgpu_util'; - -export class ResizeBilinearProgram implements WebGPUProgram { - outputShape: number[]; - shaderKey: string; - dispatchLayout: {x: number[]}; - dispatch: [number, number, number]; - variableNames = ['x']; - uniforms = 'adjustHeightWidth : vec2, halfPixelCenters : f32,'; - workgroupSize: [number, number, number] = [64, 1, 1]; - size = true; - - constructor( - inputShape: [number, number, number, number], newHeight: number, - newWidth: number) { - this.outputShape = [inputShape[0], newHeight, newWidth, inputShape[3]]; - - this.dispatchLayout = flatDispatchLayout(this.outputShape); - - this.dispatch = computeDispatch( - this.dispatchLayout, this.outputShape, this.workgroupSize); - - this.shaderKey = `resizeBilinear`; - } - - getUserCode(): string { - const userCode = ` - ${main('index')} { - if (index < uniforms.size) { - let coords = getCoordsFromIndex(index); - let b = coords[0]; - let d = coords[3]; - let rc = coords.yz; - - let effectiveInSize = vec2( - f32(uniforms.xShape.y) - uniforms.adjustHeightWidth[0], - f32(uniforms.xShape.z) - uniforms.adjustHeightWidth[1]); - - let effectiveOutSize = vec2( - f32(uniforms.outShape.y) - uniforms.adjustHeightWidth[0], - f32(uniforms.outShape.z) - uniforms.adjustHeightWidth[1]); - - let effectiveInputOverOutputRatioRC = - effectiveInSize / effectiveOutSize; - - // Fractional source index - let sourceFracIndexRC = - (vec2(rc) + vec2(uniforms.halfPixelCenters)) * - effectiveInputOverOutputRatioRC - vec2(uniforms.halfPixelCenters); - - // Compute the four integer indices. - let sourceFloorRC = vec2(sourceFracIndexRC); - let sourceCeilRC = vec2( - min(vec2(uniforms.xShape.yz) - vec2(1.0), ceil(sourceFracIndexRC))); - - let topLeft = getX(b, sourceFloorRC.x, sourceFloorRC.y, d); - let bottomLeft = getX(b, sourceCeilRC.x, sourceFloorRC.y, d); - let topRight = getX(b, sourceFloorRC.x, sourceCeilRC.y, d); - let bottomRight = getX(b, sourceCeilRC.x, sourceCeilRC.y, d); - - let fracRC = sourceFracIndexRC - vec2(sourceFloorRC); - - let top = topLeft + (topRight - topLeft) * fracRC.y; - let bottom = bottomLeft + (bottomRight - bottomLeft) * fracRC.y; - let newValue = top + (bottom - top) * fracRC.x; - - setOutputAtIndex(index, newValue); - } - } - `; - return userCode; - } -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/resize_nearest_neighbor_backprop_webgpu.ts b/tfjs-master/tfjs-backend-webgpu/src/resize_nearest_neighbor_backprop_webgpu.ts deleted file mode 100644 index ec44ce575..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/resize_nearest_neighbor_backprop_webgpu.ts +++ /dev/null @@ -1,113 +0,0 @@ -/** - * @license - * Copyright 2023 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {getMainHeaderString as main, WebGPUProgram} from './webgpu_program'; -import {computeDispatch, flatDispatchLayout} from './webgpu_util'; - -export class ResizeNearestNeigborBackpropProgram implements WebGPUProgram { - outputShape: number[]; - shaderKey: string; - dispatchLayout: {x: number[]}; - dispatch: [number, number, number]; - variableNames = ['dy']; - uniforms = - `effectiveXSize : vec2, effectiveYSize : vec2, invHeightScale : f32, invWidthScale : f32, - winHeight : i32, winWidth : i32,`; - workgroupSize: [number, number, number] = [64, 1, 1]; - alignCorners: boolean; - size = true; - - constructor( - inputShape: [number, number, number, number], alignCorners: boolean) { - this.outputShape = inputShape; - - this.dispatchLayout = flatDispatchLayout(this.outputShape); - this.dispatch = computeDispatch( - this.dispatchLayout, this.outputShape, this.workgroupSize); - - this.alignCorners = alignCorners; - this.shaderKey = `resizeNearestNeigborBackprop_${alignCorners}`; - } - - getUserCode(): string { - const userCode = ` - ${main('index')} { - if (index < uniforms.size) { - let coords = getOutputCoords(); - let b = coords[0]; - let d = coords[3]; - let r = coords[1]; - let c = coords[2]; - - var accumulator = 0.0; - - // Compute bounds for where in dy we will look - let startRLerp = floor(f32(r) * uniforms.invHeightScale); - let startDyR = i32(floor(startRLerp - f32(uniforms.winHeight / 2))); - - let startCLerp = floor(f32(c) * uniforms.invWidthScale); - let startDyC = i32(floor(startCLerp - f32(uniforms.winWidth / 2))); - - // Loop over dy - for (var dyROffset = 0; dyROffset < uniforms.winHeight; dyROffset++) { - let dyR = startDyR + dyROffset; - - // Guard against the window exceeding the bounds of dy - if (dyR < 0 || dyR >= uniforms.dyShape[1]) { - continue; - } - - for (var dyCOffset = 0; dyCOffset < uniforms.winWidth; dyCOffset++) { - let dyC = startDyC + dyCOffset; - - // Guard against the window exceeding the bounds of dy - if (dyC < 0 || dyC >= uniforms.dyShape[2]) { - continue; - } - - let sourceFracRow = f32(uniforms.effectiveXSize[0]) * - (f32(dyR) / f32(uniforms.effectiveYSize[0])); - - let sourceFracCol = f32(uniforms.effectiveXSize[1]) * - (f32(dyC) / f32(uniforms.effectiveYSize[1])); - - let sourceNearestRow = - i32(min(f32(uniforms.outShape[1] - 1), - ${ - this.alignCorners ? 'floor(sourceFracRow + 0.5)' : - 'floor(sourceFracRow)'})); - - let sourceNearestCol = - i32(min(f32(uniforms.outShape[2] - 1), - ${ - this.alignCorners ? 'floor(sourceFracCol + 0.5)' : - 'floor(sourceFracCol)'})); - - if (r == sourceNearestRow && c == sourceNearestCol) { - accumulator += getDy(b, dyR, dyC, d); - } - } - } - // End loop over dy - - setOutputAtIndex(index, accumulator); - } - } - `; - return userCode; - } -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/resize_nearest_neighbor_webgpu.ts b/tfjs-master/tfjs-backend-webgpu/src/resize_nearest_neighbor_webgpu.ts deleted file mode 100644 index 5076a008a..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/resize_nearest_neighbor_webgpu.ts +++ /dev/null @@ -1,90 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {getMainHeaderString as main, WebGPUProgram} from './webgpu_program'; -import {computeDispatch, flatDispatchLayout} from './webgpu_util'; - -export class ResizeNearestNeighborProgram implements WebGPUProgram { - outputShape: number[]; - shaderKey: string; - dispatchLayout: {x: number[]}; - dispatch: [number, number, number]; - variableNames = ['x']; - uniforms = 'adjustHeightWidth : vec2, roundBase : f32,'; - workgroupSize: [number, number, number] = [64, 1, 1]; - halfPixelCenters: boolean; - size = true; - - constructor( - inputShape: [number, number, number, number], newHeight: number, - newWidth: number, halfPixelCenters: boolean) { - this.outputShape = [inputShape[0], newHeight, newWidth, inputShape[3]]; - - this.dispatchLayout = flatDispatchLayout(this.outputShape); - - this.dispatch = computeDispatch( - this.dispatchLayout, this.outputShape, this.workgroupSize); - - this.halfPixelCenters = halfPixelCenters; - this.shaderKey = `resizeNearest_${halfPixelCenters}`; - } - - getUserCode(): string { - let sourceFracIndexRC: string; - if (this.halfPixelCenters) { - sourceFracIndexRC = - `max((vec2(rc) + vec2(0.5)) * effectiveInputOverOutputRatioRC` + - `, vec2(0.0))`; - } else { - sourceFracIndexRC = `vec2(rc) * effectiveInputOverOutputRatioRC`; - } - - const userCode = ` - ${main('index')} { - if (index < uniforms.size) { - let coords = getCoordsFromIndex(index); - let b = coords[0]; - let d = coords[3]; - let rc = coords.yz; - - let effectiveInSize = vec2( - f32(uniforms.xShape.y) - uniforms.adjustHeightWidth[0], - f32(uniforms.xShape.z) - uniforms.adjustHeightWidth[1]); - - let effectiveOutSize = vec2( - f32(uniforms.outShape.y) - uniforms.adjustHeightWidth[0], - f32(uniforms.outShape.z) - uniforms.adjustHeightWidth[1]); - - let effectiveInputOverOutputRatioRC = - effectiveInSize / effectiveOutSize; - - // Fractional source index - let sourceFracIndexRC = ${sourceFracIndexRC}; - - // Compute the coordinators of nearest neighbor point. - let inputShapeRC = vec2(f32(uniforms.xShape.y), f32(uniforms.xShape.z)); - let sourceNearestRC = vec2( - min(inputShapeRC - 1.0, floor(sourceFracIndexRC + uniforms.roundBase))); - let newValue = getX(b, sourceNearestRC.x, sourceNearestRC.y, d); - - setOutputAtIndex(index, newValue); - } - } - `; - return userCode; - } -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/reverse_webgpu.ts b/tfjs-master/tfjs-backend-webgpu/src/reverse_webgpu.ts deleted file mode 100644 index e76c086ed..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/reverse_webgpu.ts +++ /dev/null @@ -1,75 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {getMainHeaderString as main, WebGPUProgram} from './webgpu_program'; -import {computeDispatch, flatDispatchLayout} from './webgpu_util'; - -export class ReverseProgram implements WebGPUProgram { - outputShape: number[]; - shaderKey: string; - dispatchLayout: {x: number[]}; - dispatch: [number, number, number]; - variableNames = ['x']; - uniforms: string; - workgroupSize: [number, number, number] = [64, 1, 1]; - size = true; - - constructor(xShape: [number, number, number, number]) { - this.outputShape = xShape; - this.dispatchLayout = flatDispatchLayout(this.outputShape); - this.dispatch = computeDispatch( - this.dispatchLayout, this.outputShape, this.workgroupSize); - this.uniforms = ` axis : vec4,`; - this.shaderKey = 'reverse'; - } - - getUserCode(): string { - const reverseCoordsSnippet = ` - // Using uniform variables as judging conditions, so the function has - // coherent execution within all threads. - fn getReverseCoords(coords : vec4) -> vec4 { - var reverseCoords = coords; - if (uniforms.axis[0] == 1) { - reverseCoords[0] = uniforms.xShape[0] - coords[0] - 1; - } - if (uniforms.axis[1] == 1) { - reverseCoords[1] = uniforms.xShape[1] - coords[1] - 1; - } - if (uniforms.axis[2] == 1) { - reverseCoords[2] = uniforms.xShape[2] - coords[2] - 1; - } - if (uniforms.axis[3] == 1) { - reverseCoords[3] = uniforms.xShape[3] - coords[3] - 1; - } - - return reverseCoords; - } - `; - const userCode = ` - ${reverseCoordsSnippet} - ${main('index')} { - if (index < uniforms.size) { - let coords = getCoordsFromIndex(index); - let reverseCoords = getReverseCoords(coords); - setOutputAtIndex(index, getX(reverseCoords[0], - reverseCoords[1], reverseCoords[2], reverseCoords[3])); - } - } - `; - return userCode; - } -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/rotate_webgpu.ts b/tfjs-master/tfjs-backend-webgpu/src/rotate_webgpu.ts deleted file mode 100644 index 8755c1681..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/rotate_webgpu.ts +++ /dev/null @@ -1,79 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {getMainHeaderString as main, WebGPUProgram} from './webgpu_program'; -import {computeDispatch, flatDispatchLayout} from './webgpu_util'; - -export class RotateProgram implements WebGPUProgram { - outputShape: number[] = []; - shaderKey: string; - dispatchLayout: {x: number[]}; - dispatch: [number, number, number]; - variableNames = ['x']; - uniforms: string; - workgroupSize: [number, number, number] = [64, 1, 1]; - fillSnippet: string; - size = true; - - constructor( - imageShape: [number, number, number, number], - fillValue: number|[number, number, number]) { - this.outputShape = imageShape; - this.dispatchLayout = flatDispatchLayout(this.outputShape); - this.dispatch = computeDispatch( - this.dispatchLayout, this.outputShape, this.workgroupSize); - this.uniforms = `centerX : f32, centerY : f32, sinRadians : f32, - cosRadians : f32,`; - this.shaderKey = 'rotate'; - this.outputShape = imageShape; - - if (typeof fillValue === 'number') { - this.uniforms += ` fillValue : f32,`; - this.fillSnippet = `var outputValue = uniforms.fillValue;`; - this.shaderKey += '_float'; - } else { - this.uniforms += ` fillValue : vec3,`; - this.fillSnippet = `var outputValue = uniforms.fillValue[coords[3]];`; - this.shaderKey += '_vec3'; - } - } - - getUserCode(): string { - const userCode = ` - ${main('index')} { - if (index < uniforms.size) { - let coords = getCoordsFromIndex(index); - let coordXFloat = (f32(coords[2]) - uniforms.centerX) * - uniforms.cosRadians - (f32(coords[1]) - uniforms.centerY) * - uniforms.sinRadians; - let coordYFloat = (f32(coords[2]) - uniforms.centerX) * - uniforms.sinRadians + (f32(coords[1]) - uniforms.centerY) * - uniforms.cosRadians; - let coordX = i32(round(coordXFloat + uniforms.centerX)); - let coordY = i32(round(coordYFloat + uniforms.centerY)); - ${this.fillSnippet} - if(coordX >= 0 && coordX < uniforms.xShape[2] && coordY >= 0 && - coordY < uniforms.xShape[1]) { - outputValue = getX(coords[0], coordY, coordX, coords[3]); - } - setOutputAtIndex(index, outputValue); - } - } - `; - return userCode; - } -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/scatter_webgpu.ts b/tfjs-master/tfjs-backend-webgpu/src/scatter_webgpu.ts deleted file mode 100644 index 224020303..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/scatter_webgpu.ts +++ /dev/null @@ -1,125 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {DataType} from '@tensorflow/tfjs-core'; - -import {atomicAddSnippet} from './shader_util'; -import {dataTypeToGPUType, getCoordsDataType, getMainHeaderString as main, WebGPUProgram} from './webgpu_program'; -import {computeDispatch, flatDispatchLayout} from './webgpu_util'; - -export class ScatterProgram implements WebGPUProgram { - variableNames = ['updates', 'indices']; - uniforms: string; - outputShape: number[]; - sumDupeIndices: boolean; - shaderKey: string; - dispatchLayout: {x: number[]}; - dispatch: [number, number, number]; - workgroupSize: [number, number, number] = [64, 1, 1]; - updatesRank: number; - indicesRank: number; - sliceDimGreaterThanOne: boolean; - atomic = true; - type: DataType; - - constructor( - flattenXShape: number[], sliceDim: number, indicesRank: number, - updatesRank: number, strides: number[], shape: number[], - outputDtype: DataType, sumDupeIndices = true) { - this.outputShape = shape; - this.type = outputDtype; - this.sumDupeIndices = sumDupeIndices; - this.dispatchLayout = flatDispatchLayout(flattenXShape); - // Dispatching based on |updates| shape instead of output shape. - this.dispatch = - computeDispatch(this.dispatchLayout, flattenXShape, this.workgroupSize); - this.sliceDimGreaterThanOne = sliceDim > 1; - this.shaderKey = - `scatter_${indicesRank}_${updatesRank}_${this.sliceDimGreaterThanOne}_${ - outputDtype}_${sumDupeIndices}_${strides.length}`; - const stridesType = getCoordsDataType(strides.length); - this.uniforms = - `sliceDim : i32, strides: ${stridesType}, updatesSize: i32,`; - this.updatesRank = updatesRank; - this.indicesRank = indicesRank; - } - - getUserCode(): string { - let indicesString = ''; - if (this.indicesRank === 1) { - indicesString = 'coords[0]'; - } else if (this.indicesRank === 2) { - indicesString = 'coords[0], j'; - } - const indicesSnippet = `getIndices(${indicesString})`; - - const strideString = this.sliceDimGreaterThanOne ? 'uniforms.strides[j]' : - 'uniforms.strides'; - - let outCoordsString = ''; - let getUpdatesCoordsFromFlatIndex = ''; - if (this.dispatchLayout.x.length === 1) { - outCoordsString = 'flattenedIndex'; - getUpdatesCoordsFromFlatIndex = ` - fn getUpdatesCoordsFromFlatIndex(index : i32) -> i32 { - return index; - } - `; - } else if (this.dispatchLayout.x.length === 2) { - outCoordsString = 'vec2(flattenedIndex, coords[1])'; - getUpdatesCoordsFromFlatIndex = ` - fn getUpdatesCoordsFromFlatIndex(index : i32) -> vec2 { - // N.B. |updates| could be a scalar tensor, conceptually representing a - // 2D tensor with all values equal to that. By design, its size must be - // the same as |outShape[1]| in one dimension, and |indicesShape[0]| - // gives the other. - let sliceSize = uniforms.outShape[1]; - let d0 = index / sliceSize; - let d1 = index - d0 * sliceSize; - return vec2(d0, d1); - } - `; - } - const updatesString = - Array.from({length: this.updatesRank}, (_, idx) => `coords[${idx}]`); - const updatesSnippet = `getUpdates(${updatesString.join(', ')})`; - - const userCode = ` - ${getUpdatesCoordsFromFlatIndex} - ${main('index')} { - if (index < uniforms.updatesSize) { - let coords = getUpdatesCoordsFromFlatIndex(index); - var flattenedIndex = 0; - for (var j = 0; j < uniforms.sliceDim; j = j + 1) { - let indexInside = i32(round(${indicesSnippet})); - flattenedIndex = flattenedIndex + indexInside * ${strideString}; - } - let updateValue = - ${dataTypeToGPUType(this.type)}(${updatesSnippet}); - let flatIndex = getOutputIndexFromCoords(${outCoordsString}); - - ${ - this.sumDupeIndices ? - atomicAddSnippet( - '&result[flatIndex]', 'updateValue', - this.type as 'float32' | 'int32') : - `atomicStore(&result[flatIndex], bitcast(updateValue));`} - } - }`; - return userCode; - } -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/search_sorted_webgpu.ts b/tfjs-master/tfjs-backend-webgpu/src/search_sorted_webgpu.ts deleted file mode 100644 index 4d17667ac..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/search_sorted_webgpu.ts +++ /dev/null @@ -1,70 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {getMainHeaderString as main, WebGPUProgram} from './webgpu_program'; -import {computeDispatch, flatDispatchLayout} from './webgpu_util'; - -export class SearchSortedProgram implements WebGPUProgram { - outputShape: number[] = []; - shaderKey: string; - dispatchLayout: {x: number[]}; - dispatch: [number, number, number]; - variableNames = ['sortedSequence', 'values']; - uniforms = 'numInputs : i32,'; - workgroupSize: [number, number, number] = [64, 1, 1]; - size = true; - side: string; - - constructor(outputShape: [number, number], side: 'left'|'right') { - this.outputShape = outputShape; - this.dispatchLayout = flatDispatchLayout(this.outputShape); - this.dispatch = computeDispatch( - this.dispatchLayout, this.outputShape, this.workgroupSize); - - this.side = side; - this.shaderKey = `search_sorted_${side}`; - } - - getUserCode(): string { - const boundComparator = this.side === 'left' ? '<' : '<='; - const userCode = ` - fn findBound(batch: i32, value: f32) -> i32 { - var left = i32(0); - var right = uniforms.numInputs; - while (left < right) { - var mid = (left + right) / 2; - if (getSortedSequence(batch, mid) ${boundComparator} value) { - left = mid + 1; - } else { - right = mid; - } - } - return right; - } - - ${main('index')} { - if (index < uniforms.size) { - let coords = getCoordsFromIndex(index); - let value = getValuesByOutputIndex(index); - setOutputAtIndexI32(index, findBound(coords[0], value)); - } - } - `; - - return userCode; - } -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/select_webgpu.ts b/tfjs-master/tfjs-backend-webgpu/src/select_webgpu.ts deleted file mode 100644 index 324e9fba6..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/select_webgpu.ts +++ /dev/null @@ -1,83 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {getMainHeaderString as main, WebGPUProgram} from './webgpu_program'; -import {computeDispatch, flatDispatchLayout} from './webgpu_util'; - -export class SelectProgram implements WebGPUProgram { - variableNames = ['c', 'a', 'b']; - outputShape: number[]; - shaderKey: string; - dispatchLayout: {x: number[]}; - dispatch: [number, number, number]; - workgroupSize: [number, number, number] = [64, 1, 1]; - cRank: number; - rank: number; - size = true; - - constructor(cRank: number, shape: number[], rank: number) { - this.outputShape = shape; - this.dispatchLayout = flatDispatchLayout(this.outputShape); - this.dispatch = computeDispatch( - this.dispatchLayout, this.outputShape, this.workgroupSize); - - this.cRank = cRank; - this.rank = rank; - this.shaderKey = 'select'; - } - - getUserCode(): string { - // TODO(WGSL): below code can be merged with getUserCode. - let cCoords; - let abCoords; - if (this.rank > 4) { - throw Error(`Where for rank ${this.rank} is not yet supported`); - } - - if (this.rank === 1) { - abCoords = `resRC`; - cCoords = `resRC`; - } else { - const currentCoords = ['resRC.x', 'resRC.y', 'resRC.z', 'resRC.w']; - const cCoordVars = []; - const abCoordVars = []; - for (let i = 0; i < this.outputShape.length; i++) { - abCoordVars.push(`${currentCoords[i]}`); - if (i < this.cRank) { - cCoordVars.push(`${currentCoords[i]}`); - } - } - cCoords = cCoordVars.join(); - abCoords = abCoordVars.join(); - } - - const userCode = ` - ${main('index')} { - if (index < uniforms.size) { - let resRC = getCoordsFromIndex(index); - let cVal = getC(${cCoords}); - if (cVal >= 1.0) { - setOutputAtIndex(index, getA(${abCoords})); - } else { - setOutputAtIndex(index, getB(${abCoords})); - } - } - } - `; - return userCode; - } -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/setup_test.ts b/tfjs-master/tfjs-backend-webgpu/src/setup_test.ts deleted file mode 100644 index f881a35fb..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/setup_test.ts +++ /dev/null @@ -1,218 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// Register the backend. -import './index'; -// tslint:disable-next-line: no-imports-from-dist -import '@tensorflow/tfjs-core/dist/public/chained_ops/register_all_chained_ops'; -// tslint:disable-next-line: no-imports-from-dist -import '@tensorflow/tfjs-core/dist/register_all_gradients'; -import './backend_webgpu_test_registry'; -// tslint:disable-next-line: no-imports-from-dist -import {parseTestEnvFromKarmaFlags, setTestEnvs, setupTestFilters, TEST_ENVS, TestFilter} from '@tensorflow/tfjs-core/dist/jasmine_util'; - -const TEST_FILTERS: TestFilter[] = [ - // skip specific test cases for supported kernels - { - startsWith: 'cumsum ', - excludes: [ - 'gradient', // gradient function not found. - ] - }, - { - startsWith: 'exp ', - excludes: [ - 'int32', // TODO: fix precision problem. - ] - }, - { - startsWith: 'gather ', - excludes: [ - 'throws when index is out of bound', - ] - }, - { - startsWith: 'nonMaxSuppression ', - excludes: [ - 'NonMaxSuppressionPadded' // NonMaxSuppressionV4 not yet implemented. - ] - }, - { - startsWith: 'prod ', - excludes: [ - 'gradients', // Not yet implemented - ] - }, - { - startsWith: 'cos ', - excludes: [ - 'gradients', // Failing on MacOS - 'gradient with clones', // Failing on MacOS - ], - }, - { - startsWith: 'tan ', - excludes: [ - 'gradients', // Failing on MacOS - //'gradient with clones', // Failing on MacOS - // https://github.com/tensorflow/tfjs/issues/7618 - 'numbers exceed float32 precision', - ], - }, - { - startsWith: 'acosh ', - excludes: [ - 'propagates NaNs', // Failing on MacOS - 'gradient with clones', // Failing on MacOS - ], - }, - { - startsWith: 'asinh ', - excludes: [ - 'propagates NaNs', // Failing on MacOS - //'gradient with clones', // Failing on MacOS - ], - }, - { - startsWith: 'atanh ', - excludes: [ - 'propagates NaNs', // Failing on MacOS - //'gradient with clones', // Failing on MacOS - ], - }, - { - startsWith: 'sigmoid ', - excludes: [ - 'propagates NaNs', // Failing on MacOS - //'gradient with clones', // Failing on MacOS - ], - }, - { - startsWith: 'unsortedSegmentSum ', - excludes: [ - 'ignores negative segmentIds', // Failing on MacOS - ], - }, - { - startsWith: 'log ', - excludes: [ - 'log propagates NaNs', // Failing on MacOS - ], - }, - { - startsWith: 'softmax ', - excludes: [ - 'Propagates NaNs', // Failing on MacOS - ], - }, - { - startsWith: 'fromPixels ', - excludes: [ - 'HTMLVideoElement', // Device is lost on Linux - 'canvas and image match', // Failing on Linux - ], - }, - { - startsWith: 'sign ', - excludes: [ - // Failing on Linux - 'basic', - 'does not propagate NaNs', - 'accepts a tensor-like object', - ], - }, - { - startsWith: 'broadcastArgs ', - excludes: [ - 'error', // Currently, cannot transfer the error from gpu to cpu - ], - }, - { - startsWith: 'tensor.data ', - excludes: [ - '.data() postpones disposal of tensor', - 'calling .data() twice works', - ], - }, - { - startsWith: 'bitwiseAnd', - excludes: [ - 'bitwiseAnd', - ], - }, - { - startsWith: 'sparseSegmentMean', - excludes: [ - 'throw error', // Currently, cannot transfer the error from gpu to cpu - ], - }, - { - startsWith: 'sparseSegmentSum', - excludes: [ - // Currently, cannot transfer the error from gpu to cpu - 'segments invalid', - 'indices invalid', - ], - }, - - // exclude unsupported kernels and to be fixed cases - { - include: ' webgpu ', - excludes: [ - 'raggedGather ', - 'raggedRange ', - 'raggedTensorToTensor ', - 'method otsu', // round - 'sparseFillEmptyRows ', - 'sparseReshape ', - 'staticRegexReplace ', - 'stringSplit ', - 'stringToHashBucketFast ', - 'unique ', - ] - }, -]; - -const customInclude = (testName: string) => { - // Include webgpu specific tests. - if (testName.startsWith('webgpu')) { - return true; - } - return false; -}; -setupTestFilters(TEST_FILTERS, customInclude); - -// Allow flags to override test envs -// tslint:disable-next-line:no-any -declare let __karma__: any; -if (typeof __karma__ !== 'undefined') { - const testEnv = parseTestEnvFromKarmaFlags(__karma__.config.args, TEST_ENVS); - if (testEnv != null) { - setTestEnvs([testEnv]); - } -} - -// These use 'require' because they must not be hoisted above -// the preceding snippet that parses test environments. -// Import and run tests from core. -// tslint:disable-next-line:no-imports-from-dist -// tslint:disable-next-line:no-require-imports -require('@tensorflow/tfjs-core/dist/tests'); -// Import and run tests from webgpu. -// tslint:disable-next-line:no-imports-from-dist -// tslint:disable-next-line:no-require-imports -require('./tests'); diff --git a/tfjs-master/tfjs-backend-webgpu/src/shader_util.ts b/tfjs-master/tfjs-backend-webgpu/src/shader_util.ts deleted file mode 100644 index 98a5782e3..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/shader_util.ts +++ /dev/null @@ -1,58 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// Generates WGSL that computes strides. -export function symbolicallyComputeStrides( - indicesArr: number[], variableName: string): string[] { - if (Math.max(...indicesArr) > 5) { - throw new Error('Cannot symbolically compute strides for rank > 6 tensor.'); - } - - const numCoords = indicesArr.length; - const indicesStr = 'xyzwuv'; - const shape = indicesArr.map(d => `${variableName}.${indicesStr[d]}`); - const strides = new Array(numCoords - 1); - strides[numCoords - 2] = shape[numCoords - 1]; - for (let i = numCoords - 3; i >= 0; --i) { - strides[i] = `(${strides[i + 1]} * ${shape[i + 1]})`; - } - - return strides; -} - -export const atomicAddSnippet = - (ptr: string, v: string, type: 'int32'|'float32') => { - if (type === 'int32') { - return `atomicAdd(${ptr}, bitcast(${v}));`; - } else { - // atomicAdd only supports uint/int type. For float, we use - // atomicCompareExchangeWeak to simulate. - return ` - { - var oldValue = 0; - loop { - let newValueF32 = bitcast(oldValue) + (${v}); - let newValue = bitcast(newValueF32); - let res = atomicCompareExchangeWeak(${ptr}, oldValue, newValue); - if res.exchanged { - break; - } - oldValue = res.old_value; - } - }`; - } - }; diff --git a/tfjs-master/tfjs-backend-webgpu/src/shader_util_test.ts b/tfjs-master/tfjs-backend-webgpu/src/shader_util_test.ts deleted file mode 100644 index 161e335dd..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/shader_util_test.ts +++ /dev/null @@ -1,37 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {symbolicallyComputeStrides} from './shader_util'; - -describe('shader util', () => { - it('symbolicallyComputeStrides takes in array of dimensions ' + - 'and returns GLSL to compute strides for those dimensions', - () => { - const layout = [0, 2, 1]; - const strides = symbolicallyComputeStrides(layout, 'output'); - expect(strides[0]).toEqual('(output[1] * output[2])'); - expect(strides[1]).toEqual('output[1]'); - }); - - it('symbolicallyComputeStrides throws if given a dimension ' + - 'that cannot be accessed from a GLSL data type', - () => { - const layout = [0, 5, 2]; - expect(() => symbolicallyComputeStrides(layout, 'output')) - .toThrowError(); - }); -}); \ No newline at end of file diff --git a/tfjs-master/tfjs-backend-webgpu/src/slice_webgpu.ts b/tfjs-master/tfjs-backend-webgpu/src/slice_webgpu.ts deleted file mode 100644 index e8d15af66..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/slice_webgpu.ts +++ /dev/null @@ -1,86 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {getCoordsDataType, getCoordsXYZ, getMainHeaderString as main, WebGPUProgram} from './webgpu_program'; -import {computeDispatch, flatDispatchLayout} from './webgpu_util'; - -export class SliceProgram implements WebGPUProgram { - variableNames = ['source']; - uniforms: string; - outputShape: number[]; - shaderKey: string; - rank: number; - dispatchLayout: {x: number[]}; - dispatch: [number, number, number]; - workPerThread = 1; - workgroupSize: [number, number, number] = [64, 1, 1]; - start: number[]; - size = true; - - constructor(start: number[], destSize: number[]) { - this.outputShape = destSize; - this.rank = destSize.length; - this.dispatchLayout = flatDispatchLayout(this.outputShape); - this.dispatch = computeDispatch( - this.dispatchLayout, this.outputShape, this.workgroupSize, - [this.workPerThread, 1, 1]); - - this.start = start; - this.uniforms = `start : ${getCoordsDataType(start.length)}, `; - this.shaderKey = 'slice'; - } - - getUserCode(): string { - const dtype = getCoordsDataType(this.rank); - const sourceCoords = getCoords(this.rank); - let coordSum; - if (this.start.length === 1) { - coordSum = this.outputShape.map((_, i) => { - return `sourceLoc = uniforms.start + coords;`; - }); - } else { - coordSum = this.outputShape.map((_, i) => { - return `sourceLoc.${coords[i]} = uniforms.start.${ - getCoordsXYZ(i)} + coords.${coords[i]};`; - }); - } - - const userCode = ` - ${main('index')} { - if (index < uniforms.size) { - var sourceLoc : ${dtype}; - let coords = getCoordsFromIndex(index); - ${coordSum.join('\n')} - setOutputAtIndex(index, getSource(${sourceCoords})); - } - } - `; - return userCode; - } -} - -const coords = ['x', 'y', 'z', 'w', 'u', 'v']; - -function getCoords(rank: number): string { - if (rank === 1) { - return 'sourceLoc'; - } else if (rank <= 6) { - return coords.slice(0, rank).map(coord => `sourceLoc.${coord}`).join(','); - } else { - throw Error(`Slicing for rank ${rank} is not yet supported`); - } -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/softmax_webgpu.ts b/tfjs-master/tfjs-backend-webgpu/src/softmax_webgpu.ts deleted file mode 100644 index fed491dbb..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/softmax_webgpu.ts +++ /dev/null @@ -1,104 +0,0 @@ -/** - * @license - * Copyright 2023 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {getMainHeaderString as main, WebGPUProgram} from './webgpu_program'; -import {flatDispatchLayout} from './webgpu_util'; - -export class SoftmaxProgram implements WebGPUProgram { - variableNames = ['logits']; - outputShape: number[]; - shaderKey: string; - dispatchLayout: {x: number[]}; - dispatch: [number, number, number]; - workgroupSize: [number, number, number]; - - constructor(outputShape: number[]) { - this.outputShape = outputShape; // [rows, cols] - this.dispatchLayout = flatDispatchLayout(this.outputShape); - this.dispatch = [this.outputShape[0], 1, 1]; - if (this.outputShape[1] >= 4096) { - this.workgroupSize = [256, 1, 1]; - } else { - this.workgroupSize = [64, 1, 1]; - } - this.shaderKey = 'softmax'; - } - - getUserCode(): string { - const userCode = ` - var buf : array; - var rowMaxShared : f32; - var rowSumShared : f32; - const blockSize = ${this.workgroupSize[0]}; - ${main('index')} { - let row = index / blockSize; - let tid = i32(localId.x); - let cols = uniforms.outShape[1]; - - var threadMax = -3.402823e+38f; - for (var col = tid; col < cols; col += blockSize) { - let value = getLogits(row, col); - threadMax = max(threadMax, value); - } - if (tid < cols) { - buf[tid] = threadMax; - } - workgroupBarrier(); - - var reduceSize = min(cols, blockSize); - for (var currSize = reduceSize >> 1; currSize > 0; currSize = reduceSize >> 1) { - reduceSize = currSize + (reduceSize & 1); - if (tid < currSize) { - buf[tid] = max(buf[tid], buf[tid + reduceSize]); - } - workgroupBarrier(); - } - - if (tid == 0) { - rowMaxShared = buf[0]; - } - workgroupBarrier(); - - var threadSum = 0.0; - for (var col = tid; col < cols; col += blockSize) { - let subExp = exp(getLogits(row, col) - rowMaxShared); - threadSum += subExp; - } - buf[tid] = threadSum; - workgroupBarrier(); - - for (var currSize = blockSize >> 1; currSize > 0; currSize = currSize >> 1) { - if (tid < currSize) { - buf[tid] = buf[tid] + buf[tid + currSize]; - } - workgroupBarrier(); - } - - if (tid == 0) { - rowSumShared = buf[0]; - } - workgroupBarrier(); - - for (var col = tid; col < cols; col += blockSize) { - let value = exp(getLogits(row, col) - rowMaxShared) / rowSumShared; - setOutputAtCoords(row, col, value); - } - } - `; - return userCode; - } -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/space_to_batchND_webgpu.ts b/tfjs-master/tfjs-backend-webgpu/src/space_to_batchND_webgpu.ts deleted file mode 100644 index 72b5f24b2..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/space_to_batchND_webgpu.ts +++ /dev/null @@ -1,79 +0,0 @@ -/** - * @license - * Copyright 2023 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {padCommon} from './pad_webgpu'; -import {getSwitchedCoords} from './transpose_webgpu'; -import {getCoordsDataType, getCoordsFromIndexSnippet, getMainHeaderString as main, WebGPUProgram} from './webgpu_program'; -import {computeDispatch, flatDispatchLayout} from './webgpu_util'; - -export class SpaceToBatchNDProgram implements WebGPUProgram { - variableNames = ['x']; - outputShape: number[] = []; - shaderKey: string; - dispatchLayout: {x: number[]}; - dispatch: [number, number, number]; - uniforms = ''; - workgroupSize: [number, number, number] = [64, 1, 1]; - newDim: number[]; - xShape: number[]; - paddedXShape: number[]; - size = true; - - constructor( - xShape: number[], paddedXShape: number[], - paddings: Array<[number, number]>, reshapedPaddedXShape: number[], - newDim: number[], paddedXShapeStridesShapeLength: number) { - const outputShape: number[] = new Array(reshapedPaddedXShape.length); - for (let i = 0; i < outputShape.length; i++) { - outputShape[i] = reshapedPaddedXShape[newDim[i]]; - } - this.outputShape = outputShape; - this.newDim = newDim; - this.dispatchLayout = flatDispatchLayout(this.outputShape); - this.dispatch = computeDispatch( - this.dispatchLayout, this.outputShape, this.workgroupSize); - this.xShape = xShape; - this.paddedXShape = paddedXShape; - this.uniforms += `reshapedPaddedXShape : ${ - getCoordsDataType( - reshapedPaddedXShape.length)}, paddedXShapeStrides : ${ - getCoordsDataType(paddedXShapeStridesShapeLength)}, `; - paddings.map((_, i) => { - this.uniforms += ` pad${i} : vec2,`; - }); - this.shaderKey = `spaceToBatchND_${newDim}`; - } - - getUserCode(): string { - const dtype = getCoordsDataType(this.outputShape.length); - const switched = getSwitchedCoords(this.newDim); - - const userCode = ` - ${getCoordsFromIndexSnippet(this.paddedXShape, 'PaddedX')} - ${main('index')} { - if(index < uniforms.size) { - let coords = getCoordsFromIndex(index); - let switchedIndex = getIndexFromCoords${this.outputShape.length}D(${ - dtype}(${switched}), uniforms.reshapedPaddedXShape); - let paddedCoords = getPaddedXCoordsFromIndex(switchedIndex); - ${padCommon(this.xShape, true)} - } - } - `; - return userCode; - } -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/sparse_segment_reduce_webgpu.ts b/tfjs-master/tfjs-backend-webgpu/src/sparse_segment_reduce_webgpu.ts deleted file mode 100644 index a25cd81ed..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/sparse_segment_reduce_webgpu.ts +++ /dev/null @@ -1,135 +0,0 @@ -/** - * @license - * Copyright 2023 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {DataType} from '@tensorflow/tfjs-core'; - -import {atomicAddSnippet} from './shader_util'; -import {getMainHeaderString as main, WebGPUProgram} from './webgpu_program'; -import {computeDispatch, flatDispatchLayout} from './webgpu_util'; - -export class SparseSegmentSumProgram implements WebGPUProgram { - variableNames = ['input', 'indices', 'segmentIds']; - outputShape: number[] = []; - shaderKey: string; - dispatchLayout: {x: number[]}; - dispatch: [number, number, number]; - uniforms = 'segmentSize : i32, sparseSize : i32,'; - workgroupSize: [number, number, number] = [64, 1, 1]; - atomic = true; - type: DataType; - - constructor(outShape: number[], sparseSize: number, outputDtype: DataType) { - this.outputShape = outShape; - this.type = outputDtype; - this.dispatchLayout = flatDispatchLayout([sparseSize]); - this.dispatch = - computeDispatch(this.dispatchLayout, [sparseSize], this.workgroupSize); - - this.shaderKey = 'sparseSegmentSum'; - } - - getUserCode(): string { - const userCode = ` - ${main('index')} { - if (index < uniforms.sparseSize) { - let indexInSegmentIds = index / uniforms.segmentSize; - let indexInSegment = index % uniforms.segmentSize; - let indexInInput = indices[indexInSegmentIds]; - let segmentId = segmentIds[indexInSegmentIds]; - - let value = input[indexInInput * uniforms.segmentSize + indexInSegment]; - let outIndex = segmentId * uniforms.segmentSize + indexInSegment; - ${ - atomicAddSnippet( - '&result[outIndex]', 'value', this.type as 'float32' | 'int32')} - } - } - `; - return userCode; - } -} - -export class SparseSegmentIdCountProgram implements WebGPUProgram { - variableNames = ['segmentIds']; - outputShape: number[] = []; - shaderKey: string; - dispatchLayout: {x: number[]}; - dispatch: [number, number, number]; - workgroupSize: [number, number, number] = [64, 1, 1]; - atomic = true; - - constructor(outShape: number, segmentIdsShape: number[]) { - this.outputShape = [outShape]; - this.dispatchLayout = flatDispatchLayout(segmentIdsShape); - this.dispatch = computeDispatch( - this.dispatchLayout, segmentIdsShape, this.workgroupSize); - - this.shaderKey = 'sparseSegmentIdCountProgram'; - } - - getUserCode(): string { - const userCode = ` - ${main('index')} { - if (index < uniforms.segmentIdsShape) { - let segmentId = segmentIds[index]; - ${atomicAddSnippet('&result[segmentId]', '1', 'int32')} - } - } - `; - return userCode; - } -} - -export class SparseSegmentMeanProgram implements WebGPUProgram { - variableNames = ['segmentSum', 'sameSegmentIdCount']; - outputShape: number[] = []; - shaderKey: string; - dispatchLayout: {x: number[]}; - dispatch: [number, number, number]; - uniforms = 'segmentSize : i32'; - workgroupSize: [number, number, number] = [64, 1, 1]; - size = true; - type: DataType; - - constructor(outShape: number[], outputDtype: DataType) { - this.outputShape = outShape; - this.type = outputDtype; - this.dispatchLayout = flatDispatchLayout(outShape); - this.dispatch = - computeDispatch(this.dispatchLayout, outShape, this.workgroupSize); - - this.shaderKey = 'sparseSegmentMean'; - } - - getUserCode(): string { - const userCode = ` - ${main('index')} { - if (index < uniforms.size) { - let segmentId = index / uniforms.segmentSize; - let count = sameSegmentIdCount[segmentId]; - if (count != 0) { - ${ - this.type === 'float32' ? - 'setOutputAtIndex(index, segmentSum[index] / f32(count));' : - 'setOutputAtIndexI32(index, segmentSum[index] / count);'} - } - } - } - `; - return userCode; - } -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/strided_slice_webgpu.ts b/tfjs-master/tfjs-backend-webgpu/src/strided_slice_webgpu.ts deleted file mode 100644 index 707906dad..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/strided_slice_webgpu.ts +++ /dev/null @@ -1,74 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {getCoordsDataType, getMainHeaderString as main, WebGPUProgram} from './webgpu_program'; -import {computeDispatch, flatDispatchLayout} from './webgpu_util'; - -export class StridedSliceProgram implements WebGPUProgram { - variableNames = ['x']; - uniforms: string; - outputShape: number[]; - shaderKey: string; - dispatchLayout: {x: number[]}; - dispatch: [number, number, number]; - // TODO(xing.xu): Increase the workPerThread. - workPerThread = 1; - workgroupSize: [number, number, number] = [64, 1, 1]; - size = true; - - constructor(destSize: number[]) { - this.outputShape = destSize; - this.dispatchLayout = flatDispatchLayout(this.outputShape); - this.dispatch = computeDispatch( - this.dispatchLayout, this.outputShape, this.workgroupSize, - [this.workPerThread, 1, 1]); - - const dtype = getCoordsDataType(this.outputShape.length); - this.uniforms = `begin : ${dtype}, strides : ${dtype}, `; - this.shaderKey = 'stridedSlice'; - } - - getUserCode(): string { - const rank = this.outputShape.length; - let newCoords = ''; - if (rank === 1) { - newCoords = 'coords * uniforms.strides + uniforms.begin'; - } else { - let outputAxis = 0; - newCoords = - this.outputShape - .map((_, i) => { - outputAxis++; - return this.outputShape.length === 1 ? - `coords * uniforms.strides[${i}] + uniforms.begin[${i}]` : - `coords[${outputAxis - 1}] * uniforms.strides[${ - i}] + uniforms.begin[${i}]`; - }) - .join(','); - } - - const userCode = ` - ${main('index')} { - if (index < uniforms.size) { - let coords = getCoordsFromIndex(index); - setOutputAtIndex(index, getX(${newCoords})); - } - } - `; - return userCode; - } -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/test_util.ts b/tfjs-master/tfjs-backend-webgpu/src/test_util.ts deleted file mode 100644 index 77fefed75..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/test_util.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// tslint:disable-next-line: no-imports-from-dist -import {ALL_ENVS, describeWithFlags, TestEnv} from '@tensorflow/tfjs-core/dist/jasmine_util'; - -export function describeWebGPU(name: string, tests: (env: TestEnv) => void) { - describeWithFlags('webgpu ' + name, ALL_ENVS, tests); -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/texture_manager.ts b/tfjs-master/tfjs-backend-webgpu/src/texture_manager.ts deleted file mode 100644 index 0bdc27612..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/texture_manager.ts +++ /dev/null @@ -1,140 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -export class TextureManager { - private numUsedTextures = 0; - private numFreeTextures = 0; - private freeTextures: Map = new Map(); - private usedTextures: Map = new Map(); - - public numBytesUsed = 0; - public numBytesAllocated = 0; - - constructor(private device: GPUDevice) {} - - acquireTexture( - width: number, height: number, format: GPUTextureFormat, - usage: GPUTextureUsageFlags) { - const bytesPerElement = getBytesPerElement(format); - const byteSize = width * height * bytesPerElement; - const key = getTextureKey(width, height, format, usage); - if (!this.freeTextures.has(key)) { - this.freeTextures.set(key, []); - } - - if (!this.usedTextures.has(key)) { - this.usedTextures.set(key, []); - } - - this.numBytesUsed += byteSize; - this.numUsedTextures++; - - if (this.freeTextures.get(key).length > 0) { - this.numFreeTextures--; - - const newTexture = this.freeTextures.get(key).shift(); - this.usedTextures.get(key).push(newTexture); - return newTexture; - } - - this.numBytesAllocated += byteSize; - - const newTexture = this.device.createTexture({ - size: [width, height], - format, - usage, - }); - this.usedTextures.get(key).push(newTexture); - - return newTexture; - } - - releaseTexture(texture: GPUTexture) { - if (this.freeTextures.size === 0) { - return; - } - - const width = texture.width; - const height = texture.height; - const format = texture.format; - const usage = texture.usage; - - const key = getTextureKey(width, height, format, usage); - if (!this.freeTextures.has(key)) { - this.freeTextures.set(key, []); - } - - this.freeTextures.get(key).push(texture); - this.numFreeTextures++; - this.numUsedTextures--; - - const textureList = this.usedTextures.get(key); - const textureIndex = textureList.indexOf(texture); - if (textureIndex < 0) { - throw new Error( - 'Cannot release a texture that was never provided by this ' + - 'texture manager'); - } - textureList.splice(textureIndex, 1); - const bytesPerElement = getBytesPerElement(format); - const byteSize = width * height * bytesPerElement; - this.numBytesUsed -= byteSize; - } - - getNumUsedTextures(): number { - return this.numUsedTextures; - } - - getNumFreeTextures(): number { - return this.numFreeTextures; - } - - dispose() { - this.freeTextures.forEach((textures, key) => { - textures.forEach(texture => { - texture.destroy(); - }); - }); - - this.usedTextures.forEach((textures, key) => { - textures.forEach(texture => { - texture.destroy(); - }); - }); - - this.freeTextures = new Map(); - this.usedTextures = new Map(); - this.numUsedTextures = 0; - this.numFreeTextures = 0; - this.numBytesUsed = 0; - this.numBytesAllocated = 0; - } -} - -function getTextureKey( - width: number, height: number, format: GPUTextureFormat, - usage: GPUTextureUsageFlags) { - return `${width}_${height}_${format}_${usage}`; -} - -function getBytesPerElement(format: GPUTextureFormat) { - if (format === 'rgba8unorm') { - return 16; - } else { - throw new Error(`${format} is not supported!`); - } -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/tile_webgpu.ts b/tfjs-master/tfjs-backend-webgpu/src/tile_webgpu.ts deleted file mode 100644 index 9ac75c4e2..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/tile_webgpu.ts +++ /dev/null @@ -1,73 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {getMainHeaderString as main, WebGPUProgram} from './webgpu_program'; -import {computeDispatch, flatDispatchLayout} from './webgpu_util'; - -export class TileProgram implements WebGPUProgram { - variableNames = ['A']; - outputShape: number[]; - shaderKey: string; - dispatchLayout: {x: number[]}; - dispatch: [number, number, number]; - workgroupSize: [number, number, number] = [64, 1, 1]; - size = true; - rank: number; - - constructor(aShape: number[], reps: number[]) { - const outputShape: number[] = new Array(aShape.length); - for (let i = 0; i < outputShape.length; i++) { - outputShape[i] = aShape[i] * reps[i]; - } - this.outputShape = outputShape; - this.dispatchLayout = flatDispatchLayout(this.outputShape); - this.dispatch = computeDispatch( - this.dispatchLayout, this.outputShape, this.workgroupSize); - this.rank = this.outputShape.length; - this.shaderKey = 'tile'; - } - - getUserCode(): string { - const sourceCoords = getSourceCoords(this.rank, 'uniforms.'); - - const userCode = ` - ${main('index')} { - if (index < uniforms.size) { - let resRC = getCoordsFromIndex(index); - setOutputAtIndex(index, getA(${sourceCoords})); - } - } - `; - return userCode; - } -} - -function getSourceCoords(rank: number, uniformPrefix = ''): string { - if (rank >= 5) { - throw Error(`Tile for rank ${rank} is not yet supported`); - } - if (rank === 1) { - return `(resRC % ${uniformPrefix}aShape)`; - } - - const currentCoords = ['resRC.x', 'resRC.y', 'resRC.z', 'resRC.w']; - const sourceCoords = []; - for (let i = 0; i < rank; i++) { - sourceCoords.push(`(${currentCoords[i]} % ${uniformPrefix}aShape[${i}])`); - } - return sourceCoords.join(); -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/top_k_webgpu.ts b/tfjs-master/tfjs-backend-webgpu/src/top_k_webgpu.ts deleted file mode 100644 index 1858a17ec..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/top_k_webgpu.ts +++ /dev/null @@ -1,210 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {getMainHeaderString as main, WebGPUProgram} from './webgpu_program'; -import {computeDispatch, flatDispatchLayout} from './webgpu_util'; - -// Based on Algorithm 2 of Bitonic Top K, ref: -// https://anilshanbhag.in/static/papers/gputopk_sigmod18.pdf -// The original algorithm is based on computing the top K only, however -// since for TFJS we require the indices of the top K values as well then the -// algorithm found here is a bit modified. Rather than producing the values -// at each step, the indices containing the top K are generated instead. -// The output values are not generated to reduce the number of outputs in the -// GPU, the values can easily be retrieved from the indices using a gather -// op. - -export class SwapProgram implements WebGPUProgram { - outputShape: number[]; - shaderKey: string; - dispatchLayout: {x: number[]}; - dispatch: [number, number, number]; - variableNames = ['x', 'indices']; - uniforms: string; - workgroupSize: [number, number, number] = [256, 1, 1]; - size = true; - - constructor(shape: number[]) { - this.outputShape = shape; - this.dispatchLayout = flatDispatchLayout(this.outputShape); - this.dispatch = computeDispatch( - this.dispatchLayout, this.outputShape, this.workgroupSize); - this.uniforms = `inputSize : i32, firstPass : i32, negativeInf : f32, - dir : i32, inc : i32,`; - this.shaderKey = 'swap'; - } - - getUserCode(): string { - const userCode = ` - ${main('index')} { - if (index < uniforms.size) { - let outC = getCoordsFromIndex(index); - let batch = outC[0]; - let elemIdx = outC[1]; - // We compare elements pair-wise within a group of size 2 * inc. - // The comparing rule for each group alternates between ascending - // and descending. Within each group, we compare each pair at - // positions i and i+inc. To decide whether an element at position i - // is x0 or x1, we mod it by 2 * inc, if the result is smaller than - // inc, it is in the first half of the group, we denote it as x0, - // otherwise we denote it as x1. - // For example, as shown in the Bitonic top K paper referenced - // above, Figure5(a) shows that element[1] is in the second half of - // the group when group size is 2, but it is in the first half of - // the group when group size is 4. - let isFirstInPair = elemIdx % (2 * uniforms.inc) < uniforms.inc; - var i = 0; - if (isFirstInPair) { - i = elemIdx; - } else { - i = elemIdx - uniforms.inc; - } - - var i0 = 0; - if (uniforms.firstPass == 1) { - i0 = i; - } else { - i0 = i32(getIndices(batch, i)); - } - - var i1 = 0; - if (uniforms.firstPass == 1) { - i1 = i + uniforms.inc; - } else { - i1 = i32(getIndices(batch, i + uniforms.inc)); - } - - var x0 = f32(0.0); - var x1 = f32(0.0); - if (i0 < uniforms.inputSize) { - x0 = getX(batch, i0); - } else { - x0 = uniforms.negativeInf; - } - if (i1 < uniforms.inputSize) { - x1 = getX(batch, i1); - } else { - x1 = uniforms.negativeInf; - } - - let reverse = elemIdx % (2 * uniforms.dir) >= uniforms.dir; - let isGreater = x0 > x1 || (x0 == x1 && i1 > i0); - if (reverse == isGreater) { - // Elements in opposite order of direction - let iTemp = i0; - i0 = i1; - i1 = iTemp; - } - if (isFirstInPair) { - setOutputAtIndex(index, f32(i0)); - } else { - setOutputAtIndex(index, f32(i1)); - } - } - } - `; - return userCode; - } -} - -export class MergeProgram implements WebGPUProgram { - outputShape: number[]; - shaderKey: string; - dispatchLayout: {x: number[]}; - dispatch: [number, number, number]; - variableNames = ['x', 'indices']; - uniforms: string; - workgroupSize: [number, number, number] = [256, 1, 1]; - size = true; - - constructor(shape: number[]) { - this.outputShape = shape; - this.dispatchLayout = flatDispatchLayout(this.outputShape); - this.dispatch = computeDispatch( - this.dispatchLayout, this.outputShape, this.workgroupSize); - // |n| Size of the original input of TopK - // |firstPass| indicates if this is the first time swap is being used which - // means no indices input containing the top K is present yet. - // |k| Top k elements desired - this.uniforms = `inputSize : i32, firstPass : i32, k : i32,`; - this.shaderKey = 'merge'; - } - - getUserCode(): string { - const userCode = ` - ${main('index')} { - if (index < uniforms.size) { - let outC = getCoordsFromIndex(index); - let batch = outC[0]; - let elemIdx = outC[1]; - // The output size is half of the previous size. - // If the previous sequence is | | | | _ _ _ _ | | | | _ _ _ _ - // (k=4), we only need to output the indices at positions |, the - // indices at positions _ can be thrown away, see Figure5(b) After - // Phase 2 (Merge phase) in the Bitonic Top K paper referenced - // above. - // For example, the paper shows we only need to output the orange - // bars. The output sequence should look like this | | | | | | | |. - // Because the sequence is halved, to map the output index back to - // the previous sequence to find the corresponding value, we need - // to double the index. When we double the index, we basically - // interpolate a position, so 2i looks like - // | _ | _ | _ | _ | _ | _ | _. We move the | to the first k - // position of each 2k positions by - elemIdx % k. E.g. for output - // at index 4,5,6,7, we want to get the corresponding element at - // original index 8,9,10,11, for output at index 8,9,10,11, - // we want to get the corresponding element at original index - // 16,17,18,19, so on and so forth. - - var i = 0; - if (elemIdx < uniforms.k) { - i = elemIdx; - } else { - i = elemIdx * 2 - elemIdx % uniforms.k; - } - var i0 = 0; - if (uniforms.firstPass == 1) { - i0 = i; - } else { - i0 = i32(getIndices(batch, i)); - } - var i1 = 0; - if (uniforms.firstPass == 1) { - i1 = i + uniforms.k; - } else { - i1 = i32(getIndices(batch, i + uniforms.k)); - } - - let x0 = getX(batch, i0); - var x1 = f32(0.0); - if (i1 < uniforms.inputSize) { - x1 = getX(batch, i1); - } else { - x1 = x0; - } - - if (x0 >= x1) { - setOutputAtIndex(index, f32(i0)); - } else { - setOutputAtIndex(index, f32(i1)); - } - } - } - `; - return userCode; - } -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/transform_webgpu.ts b/tfjs-master/tfjs-backend-webgpu/src/transform_webgpu.ts deleted file mode 100644 index 8cd780c6e..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/transform_webgpu.ts +++ /dev/null @@ -1,159 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {getMainHeaderString as main, WebGPUProgram} from './webgpu_program'; -import {computeDispatch, flatDispatchLayout} from './webgpu_util'; - -export class TransformProgram implements WebGPUProgram { - variableNames = ['Image', 'Transforms']; - outputShape: number[]; - uniforms = 'interpolationModeId : i32, fillModeId : i32, fillValue : f32,'; - shaderKey: string; - dispatchLayout: {x: number[]}; - dispatch: [number, number, number]; - workgroupSize: [number, number, number] = [64, 1, 1]; - size = true; - - constructor(outShape: [number, number, number, number]) { - this.outputShape = outShape; - this.dispatchLayout = flatDispatchLayout(this.outputShape); - this.dispatch = computeDispatch( - this.dispatchLayout, this.outputShape, this.workgroupSize); - this.shaderKey = 'transform'; - } - - getUserCode(): string { - const userCode = ` - fn mapCoord(outCoord : f32, len : f32) -> f32{ - var inCoord = outCoord; - if(uniforms.fillModeId == 2) { - if (inCoord < 0.0) { - if (len <= 1.0) { - inCoord = 0.0; - } else { - let sz2 = 2.0 * len; - if (inCoord < sz2) { - inCoord = sz2 * f32(i32(f32(-inCoord / sz2))) + - inCoord; - } - if (inCoord < -len) { - inCoord = inCoord + sz2; - } else { - inCoord = -inCoord - 1.0; - } - } - } else if (inCoord > len - 1.0) { - if (len <= 1.0) { - inCoord = 0.0; - } else { - let sz2 = 2.0 * len; - inCoord = inCoord - sz2 * f32(i32(f32(inCoord / sz2))); - if (inCoord >= len) { - inCoord = sz2 - inCoord - 1.0; - } - } - } - return clamp(inCoord, 0.0, len - 1.0); - } else if (uniforms.fillModeId == 3) { - if (inCoord < 0.0) { - if (len <= 1.0) { - inCoord = 0.0; - } else { - let sz = len - 1.0; - inCoord = inCoord + len * (f32(i32(f32(-inCoord / sz))) + 1.0); - } - } else if (inCoord > len - 1.0) { - if (len <= 1.0) { - inCoord = 0.0; - } else { - let sz = len - 1.0; - inCoord = inCoord - len * f32(i32(f32(inCoord / sz))); - } - } - return clamp(inCoord, 0.0, len - 1.0); - } else if (uniforms.fillModeId == 4) { - return clamp(outCoord, 0.0, len - 1.0); - } - return outCoord; - } - fn readWithFillValue(batch : i32, coordY : i32, coordX : i32, - channel : i32) -> f32 { - var outputValue : f32; - if (0 <= coordY && coordY < uniforms.imageShape[1] && 0 <= coordX && coordX < uniforms.imageShape[2]) { - outputValue = getImage(batch, coordY, coordX, channel); - } else { - outputValue = uniforms.fillValue; - } - return outputValue; - } - - ${main('index')} { - if (index < uniforms.size) { - let coords = getCoordsFromIndex(index); - var outputValue : f32; - let batch = coords[0]; - let x = coords[2]; - let y = coords[1]; - let channel = coords[3]; - let xf = f32(x); - let yf = f32(y); - let a1 = getTransforms(batch, 0); - let a2 = getTransforms(batch, 1); - let a3 = getTransforms(batch, 2); - let b1 = getTransforms(batch, 3); - let b2 = getTransforms(batch, 4); - let b3 = getTransforms(batch, 5); - let c1 = getTransforms(batch, 6); - let c2 = getTransforms(batch, 7); - let projection = c1 * xf + c2 * yf + 1.0; - if (projection == 0.0) { - outputValue = uniforms.fillValue; - } else { - let inX = (a1 * xf + a2 * yf + a3) / projection; - let inY = (b1 * xf + b2 * yf + b3) / projection; - let mapX = mapCoord(inX, f32(uniforms.imageShape[2])); - let mapY = mapCoord(inY, f32(uniforms.imageShape[1])); - - if (uniforms.interpolationModeId == 1) { - let coordY = i32(round(mapY)); - let coordX = i32(round(mapX)); - outputValue = readWithFillValue(batch, coordY, coordX, - channel); - } else { - let yFloor = floor(mapY); - let xFloor = floor(mapX); - let yCeil = yFloor + 1.0; - let xCeil = xFloor + 1.0; - let valueYFloor = (xCeil - mapX) * - readWithFillValue(batch, i32(yFloor), i32(xFloor), channel) + - (mapX - xFloor) * - readWithFillValue(batch, i32(yFloor), i32(xCeil), channel); - let valueYCeil = (xCeil - mapX) * - readWithFillValue(batch, i32(yCeil), i32(xFloor), channel) + - (mapX - xFloor) * - readWithFillValue(batch, i32(yCeil), i32(xCeil), channel); - outputValue = (yCeil - mapY) * valueYFloor + - (mapY - yFloor) * valueYCeil; - } - } - setOutputAtIndex(index, outputValue); - } - } - `; - return userCode; - } -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/transpose_shared_webgpu.ts b/tfjs-master/tfjs-backend-webgpu/src/transpose_shared_webgpu.ts deleted file mode 100644 index 26a92ad3a..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/transpose_shared_webgpu.ts +++ /dev/null @@ -1,73 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {util} from '@tensorflow/tfjs-core'; -import {getMainHeaderString as main, WebGPUProgram} from './webgpu_program'; -import {computeDispatch} from './webgpu_util'; - -export class TransposeSharedProgram implements WebGPUProgram { - variableNames = ['A']; - outputShape: number[]; - shaderKey: string; - dispatchLayout: {x: number[], y: number[]}; - dispatch: [number, number, number]; - // Note that the maximum number of workgroup invocations by webgpu is 256. - workgroupSize: [number, number, number] = [16, 16, 1]; - - constructor(aShape: number[], newDim: number[]) { - const outputShape: number[] = new Array(aShape.length); - for (let i = 0; i < outputShape.length; i++) { - outputShape[i] = aShape[newDim[i]]; - } - this.outputShape = outputShape; - this.dispatchLayout = {x: [0], y: [1]}; - this.dispatch = computeDispatch( - this.dispatchLayout, this.outputShape, this.workgroupSize, [1, 1, 1]); - - this.shaderKey = 'transposeShared'; - } - - getUserCode(): string { - util.assert( - this.workgroupSize[0] === this.workgroupSize[1], - () => `Must be a square tile, current tile shape is ${ - this.workgroupSize[0]} x ${this.workgroupSize[1]}`); - const tileSize = this.workgroupSize[0]; - const userCode = ` - var tile : array, ${ - this.workgroupSize[0]}>; - ${main()} { - var x = i32(workgroupId.x) * ${tileSize} + i32(localId.x); - var y = i32(workgroupId.y) * ${tileSize} + i32(localId.y); - let width = uniforms.outShape[0]; - let height = uniforms.outShape[1]; - if (x < width && y < height) { - tile[localId.y][localId.x] = f32(A[y * width + x]); - } - workgroupBarrier(); - - x = i32(workgroupId.y) * ${tileSize} + i32(localId.x); - y = i32(workgroupId.x) * ${tileSize} + i32(localId.y); - if (x < height && y < width) { - setOutputAtIndex((y * height + x), tile[localId.x] - [localId.y]); - } - } - `; - return userCode; - } -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/transpose_webgpu.ts b/tfjs-master/tfjs-backend-webgpu/src/transpose_webgpu.ts deleted file mode 100644 index 8c86b4f30..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/transpose_webgpu.ts +++ /dev/null @@ -1,79 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {getCoordsDataType, getCoordsXYZ, getMainHeaderString as main, WebGPUProgram} from './webgpu_program'; -import {computeDispatch, flatDispatchLayout} from './webgpu_util'; - -export class TransposeProgram implements WebGPUProgram { - variableNames = ['A']; - shaderKey: string; - outputShape: number[]; - dispatchLayout: {x: number[]}; - dispatch: [number, number, number]; - workPerThread = 1; - workgroupSize: [number, number, number] = [64, 1, 1]; - newDim: number[]; - size = true; - - constructor(aShape: number[], newDim: number[]) { - const outputShape: number[] = new Array(aShape.length); - for (let i = 0; i < outputShape.length; i++) { - outputShape[i] = aShape[newDim[i]]; - } - this.outputShape = outputShape; - this.dispatchLayout = flatDispatchLayout(this.outputShape); - this.dispatch = computeDispatch( - this.dispatchLayout, this.outputShape, this.workgroupSize, - [this.workPerThread, 1, 1]); - - this.newDim = newDim; - this.shaderKey = `transpose_${newDim}`; - } - - getUserCode(): string { - const dtype = getCoordsDataType(this.outputShape.length); - const switched = getSwitchedCoords(this.newDim); - - const userCode = ` - ${main('index')} { - for(var i = 0; i < ${this.workPerThread}; i = i + 1) { - let flatIndex = index * ${this.workPerThread} + i; - if(flatIndex < uniforms.size) { - let coords = getCoordsFromIndex(flatIndex); - setOutputAtIndex(flatIndex, A[getIndexFromCoords${ - this.outputShape.length}D( - ${dtype}(${switched}), uniforms.aShape)]); - } - } - } - `; - return userCode; - } -} - -export function getSwitchedCoords(newDim: number[]): string { - const rank = newDim.length; - if (rank > 6) { - throw Error(`Transpose for rank ${rank} is not yet supported`); - } - const switchedCoords = new Array(rank); - for (let i = 0; i < newDim.length; i++) { - switchedCoords[newDim[i]] = `coords.${getCoordsXYZ(i)}`; - } - - return switchedCoords.join(); -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/unary_op_util.ts b/tfjs-master/tfjs-backend-webgpu/src/unary_op_util.ts deleted file mode 100644 index debf2a014..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/unary_op_util.ts +++ /dev/null @@ -1,307 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util} from '@tensorflow/tfjs-core'; - -export enum UnaryOpType { - ABS, - ACOS, - ACOSH, - ASIN, - ASINH, - ATAN, - ATANH, - CEIL, - COS, - COSH, - ELU, - ERF, - EXP, - EXPM1, - FLOOR, - IS_FINITE, - IS_INF, - IS_NAN, - LINEAR, - LOG, - LOG1P, - LOGICAL_NOT, - NEG, - RELU, - RELU6, - LEAKYRELU, - RECIPROCAL, - ROUND, - RSQRT, - SELU, - SIGMOID, - SIGN, - SIN, - SINH, - SOFTPLUS, - SQRT, - SQUARE, - STEP, - TAN, - TANH, - TO_INT -} - -const ABS = `return abs(a);`; -const ACOS = ` - if (abs(a) > 1.) { - return uniforms.NAN; - } - return acos(a); -`; -const ACOSH = ` - if (a < 1.) { - return uniforms.NAN; - } - return acosh(a); -`; -const ASIN = ` - if (abs(a) > 1.) { - return uniforms.NAN; - } - return asin(a); -`; -const ASINH = `return asinh(a);`; -const ATAN = ` - if (isnan(a)) { - return uniforms.NAN; - } - return atan(a); -`; -const ATANH = ` - if (abs(a) > 1.) { - return uniforms.NAN; - } - if (a == 1.) { - return uniforms.INFINITY; - } - if (a == -1.) { - return -uniforms.INFINITY; - } - return atanh(a); -`; -const CEIL = `return ceil(a);`; -const COS = `return cos(a);`; -const COSH = ` - let e2x = exp(-a); - return (e2x + 1.0 / e2x) / 2.0; -`; -const EXPM1 = `return exp(a) - 1.0;`; -const ELU = `if (a >= 0.0) { return a; } return (exp(a) - 1.0);`; -const ELU_VEC4 = ` - var resFloat = exp(a) - vec4(1.0); - if (a.r >= 0.0) { - resFloat.r = a.r; - } - if (a.g >= 0.0) { - resFloat.g = a.g; - } - if (a.b >= 0.0) { - resFloat.b = a.b; - } - if (a.a >= 0.0) { - resFloat.a = a.a; - } - return resFloat; -`; -const ERF = ` - // Error function is calculated approximately with elementary function. - // See "Handbook of Mathematical Functions with Formulas, - // Graphs, and Mathematical Tables", Abramowitz and Stegun. - let p = ${backend_util.ERF_P}; - let a1 = ${backend_util.ERF_A1}; - let a2 = ${backend_util.ERF_A2}; - let a3 = ${backend_util.ERF_A3}; - let a4 = ${backend_util.ERF_A4}; - let a5 = ${backend_util.ERF_A5}; - - let sign = sign(a); - let absA = abs(a); - let t = 1.0 / (1.0 + p * absA); - return sign * (1.0 - (((((a5 * t + a4) * t) + a3) * t + a2) * t + a1) * t * exp(-absA * absA)); -`; -const EXP = `return exp(a);`; -const FLOOR = `return floor(a);`; -const IS_FINITE = `return f32(!isnan(a) && !isinf(a));`; -const IS_INF = `return f32(isinf(a));`; -const IS_NAN = `return f32(isnan(a));`; -const LINEAR = `return a;`; -const LOG = `if (a < 0.0) { return uniforms.NAN; } - return log(a);`; -const LOG1P = ` - if (isnan(a)) { return a; } - return log(1.0 + a); -`; -const LOGICAL_NOT = `return f32(!(a >= 1.0));`; -const NEG = `return -a;`; -const LEAKYRELU = `if (a < 0.0) { return uniforms.alpha * a; } return a;`; -const LEAKYRELU_VEC4 = ` - let aLessThanZero = vec4(a < vec4(0.0)); - return (aLessThanZero * (uniforms.alpha * a)) + ((vec4(1.0) - aLessThanZero) * a); -`; -const RECIPROCAL = `return 1.0 / a;`; -const RELU = `return select(a, 0.0, a < 0.0);`; -const RELU6 = 'return clamp(a, 0.0, 6.0);'; -const RELU6_VEC4 = - 'return clamp(a, vec4(0.0, 0.0, 0.0, 0.0), vec4(6.0, 6.0, 6.0, 6.0));'; -const RELU_VEC4 = ` - return select(a, vec4(0.0), a < vec4(0.0)); -`; -const ROUND = `return round(a);`; -const RSQRT = `return inverseSqrt(a);`; -// Stable and Attracting Fixed Point (0, 1) for Normalized Weights. -// See: https://arxiv.org/abs/1706.02515 -const SELU = ` - if (a >= 0.0) { - return ${backend_util.SELU_SCALE} * a; - } else { - return ${backend_util.SELU_SCALEALPHA} * (exp(a) - 1.0); - } -`; -const SIGMOID = `return 1.0 / (1.0 + exp(-1.0 * a));`; -const SIGN = `return sign(a);`; -const SIN = `return sin(a);`; -const SINH = ` - let e2x = exp(a); - return (e2x - 1.0 / e2x) / 2.0; -`; -const SOFTPLUS = ` - let epsilon = 1.1920928955078125e-7; - let threshold = log(epsilon) + 2.0; - - let too_large = a > -threshold; - let too_small = a < threshold; - let exp_a = exp(a); - - if (too_large) { - return a; - } else if (too_small) { - return exp_a; - } else { - return log(exp_a + 1.0); - } -`; -const SQRT = `return sqrt(a);`; -const SQUARE = `return a * a;`; -const STEP = ` - if (isnan(a)) { - return a; - } - - return select(uniforms.stepAlpha, 1.0, a > 0.0); -`; -const TAN = `return tan(a);`; -const TANH = ` - let e2x = exp(-2.0 * abs(a)); - return sign(a) * (1.0 - e2x) / (1.0 + e2x); -`; -const TO_INT = `return f32(i32((a)));`; - -export function getUnaryOpString(type: UnaryOpType, useVec4?: boolean): string { - switch (type) { - case UnaryOpType.ABS: - return ABS; - case UnaryOpType.ACOS: - return ACOS; - case UnaryOpType.ACOSH: - return ACOSH; - case UnaryOpType.ASIN: - return ASIN; - case UnaryOpType.ASINH: - return ASINH; - case UnaryOpType.ATAN: - return ATAN; - case UnaryOpType.ATANH: - return ATANH; - case UnaryOpType.COS: - return COS; - case UnaryOpType.COSH: - return COSH; - case UnaryOpType.CEIL: - return CEIL; - case UnaryOpType.ELU: - return useVec4 ? ELU_VEC4 : ELU; - case UnaryOpType.ERF: - return ERF; - case UnaryOpType.EXP: - return EXP; - case UnaryOpType.EXPM1: - return EXPM1; - case UnaryOpType.FLOOR: - return FLOOR; - case UnaryOpType.IS_FINITE: - return IS_FINITE; - case UnaryOpType.IS_INF: - return IS_INF; - case UnaryOpType.IS_NAN: - return IS_NAN; - case UnaryOpType.LINEAR: - return LINEAR; - case UnaryOpType.LOG: - return LOG; - case UnaryOpType.LOG1P: - return LOG1P; - case UnaryOpType.LOGICAL_NOT: - return LOGICAL_NOT; - case UnaryOpType.NEG: - return NEG; - case UnaryOpType.LEAKYRELU: - return useVec4 ? LEAKYRELU_VEC4 : LEAKYRELU; - case UnaryOpType.RECIPROCAL: - return RECIPROCAL; - case UnaryOpType.RELU: - return useVec4 ? RELU_VEC4 : RELU; - case UnaryOpType.RELU6: - return useVec4 ? RELU6_VEC4 : RELU6; - case UnaryOpType.ROUND: - return ROUND; - case UnaryOpType.RSQRT: - return RSQRT; - case UnaryOpType.SELU: - return SELU; - case UnaryOpType.SIGMOID: - return SIGMOID; - case UnaryOpType.SIGN: - return SIGN; - case UnaryOpType.SIN: - return SIN; - case UnaryOpType.SINH: - return SINH; - case UnaryOpType.SOFTPLUS: - return SOFTPLUS; - case UnaryOpType.SQRT: - return SQRT; - case UnaryOpType.SQUARE: - return SQUARE; - case UnaryOpType.STEP: - return STEP; - case UnaryOpType.TAN: - return TAN; - case UnaryOpType.TANH: - return TANH; - case UnaryOpType.TO_INT: - return TO_INT; - - default: - throw new Error(`BinaryType ${type} is not implemented!`); - } -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/unary_op_webgpu.ts b/tfjs-master/tfjs-backend-webgpu/src/unary_op_webgpu.ts deleted file mode 100644 index ad41e0d7f..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/unary_op_webgpu.ts +++ /dev/null @@ -1,61 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {getUnaryOpString, UnaryOpType} from './unary_op_util'; -import {getMainHeaderString as main, WebGPUProgram} from './webgpu_program'; -import {computeDispatch, flatDispatchLayout} from './webgpu_util'; - -export class UnaryOpProgram implements WebGPUProgram { - outputShape: number[]; - shaderKey: string; - dispatchLayout: {x: number[]}; - dispatch: [number, number, number]; - variableNames = ['A']; - workgroupSize: [number, number, number]; - op: UnaryOpType; - uniforms?: string; - size = true; - - constructor(outputShape: number[], op: UnaryOpType, uniforms = '') { - // TODO(jiajia.qin@intel.com): Heuristically select a good work group size. - const workgroupSizeX = 128; - this.workgroupSize = [workgroupSizeX, 1, 1]; - this.outputShape = outputShape; - this.dispatchLayout = flatDispatchLayout(this.outputShape); - this.dispatch = computeDispatch( - this.dispatchLayout, this.outputShape, this.workgroupSize); - this.op = op; - if (uniforms !== '') { - this.uniforms = uniforms; - } - this.shaderKey = `unary_${op}`; - } - - getUserCode(): string { - return ` - fn unaryOperation(a : f32) -> f32 { - ${getUnaryOpString(this.op, false)} - } - ${main('index')} { - if (index < uniforms.size) { - let a = getAByOutputIndex(index); - setOutputAtIndex(index, unaryOperation(a)); - } - } - `; - } -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/unsorted_segment_sum_webgpu.ts b/tfjs-master/tfjs-backend-webgpu/src/unsorted_segment_sum_webgpu.ts deleted file mode 100644 index d6c82842a..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/unsorted_segment_sum_webgpu.ts +++ /dev/null @@ -1,70 +0,0 @@ -/** - * @license - * Copyright 2023 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {DataType} from '@tensorflow/tfjs-core'; - -import {atomicAddSnippet} from './shader_util'; -import {getMainHeaderString as main, WebGPUProgram} from './webgpu_program'; -import {computeDispatch, flatDispatchLayout} from './webgpu_util'; - -export class UnsortedSegmentSumProgram implements WebGPUProgram { - outputShape: number[] = []; - shaderKey: string; - dispatchLayout: {x: number[]}; - dispatch: [number, number, number]; - variableNames = ['x', 'segmentIds']; - uniforms = 'numSegments : i32, xSize: i32,'; - workgroupSize: [number, number, number] = [64, 1, 1]; - atomic = true; - type: DataType; - - constructor(inShape: number[], outShape: number[], outputDtype: DataType) { - this.outputShape = outShape; - this.dispatchLayout = flatDispatchLayout(inShape); - this.dispatch = - computeDispatch(this.dispatchLayout, inShape, this.workgroupSize); - if (outputDtype !== 'float32' && outputDtype !== 'int32') { - throw new Error(`UnsortedSegmentSum only supports float32 and int32 - types, does not support ${outputDtype} type.`); - } - this.type = outputDtype; - this.shaderKey = 'unsortedSegmentSum'; - } - - getUserCode(): string { - const userCode = ` - ${main('index')} { - if (index < uniforms.xSize) { - let coords = getXCoordsFromIndex(index); - let b = coords[0]; - let inCol = coords[1]; - - let segmentId = i32(getSegmentIds(inCol)); - if (segmentId >= 0) { - let flatIndex = b * uniforms.numSegments + segmentId % uniforms.numSegments; - let value = getX(b, inCol); - - ${ - atomicAddSnippet( - '&result[flatIndex]', 'value', this.type as 'float32' | 'int32')} - } - } - } - `; - return userCode; - } -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/webgpu.ts b/tfjs-master/tfjs-backend-webgpu/src/webgpu.ts deleted file mode 100644 index 8c484e1b0..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/webgpu.ts +++ /dev/null @@ -1,21 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as webgpu_util from './webgpu_util'; -export {WebGPUBackend} from './backend_webgpu'; -export {WebGPUProgram} from './webgpu_program'; -export {webgpu_util}; diff --git a/tfjs-master/tfjs-backend-webgpu/src/webgpu_program.ts b/tfjs-master/tfjs-backend-webgpu/src/webgpu_program.ts deleted file mode 100644 index ddaeddc6b..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/webgpu_program.ts +++ /dev/null @@ -1,853 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util, DataType, DataTypeMap, env, Rank, TensorInfo, util} from '@tensorflow/tfjs-core'; - -import {symbolicallyComputeStrides} from './shader_util'; - -export enum PixelsOpType { - FROM_PIXELS, - DRAW -} - -export interface WebGPUProgram { - // Whether to use atomic built-in functions. - atomic?: boolean; - // dispatch specifies geometry of thread groups - derived from dispatchLayout. - dispatch: [number, number, number]; - // dispatchLayout enumerates how tensor dimensions are distributed among - // dispatch x,y,z dimensions. - dispatchLayout: {x: number[], y?: number[], z?: number[]}; - // By default, the output data component is 1. - outputComponent?: number; - outputShape: number[]; - pixelsOpType?: PixelsOpType; - // The unique key to distinguish different shader source code. - shaderKey: string; - // Whether to use output size for bounds checking. - size?: boolean; - uniforms?: string; - variableNames: string[]; - // Describe each variable's component and must have one-one mapping with - // variableNames. If not set, all variables component will be same with output - // component member. - variableComponents?: number[]; - // workgroupSize.x * workgroupSize.y * workgroupSize.z = the number of threads - // in a thread group. Individual dimensions determines thread layout within - // the group. - workgroupSize: [number, number, number]; - // Size of register cache in one dimension (assumes square cache). - // Each thread writes to workPerThread * workPerThread locations in the output - // buffer. - workPerThread?: number; - pipeline?: GPUComputePipeline|Promise; - getUserCode: () => string; -} - -export const compileProgram = - (device: GPUDevice, program: WebGPUProgram, inputsData: InputInfo[], - output: TensorInfo, parallelCompilation: boolean): GPUComputePipeline| - Promise => { - const outputData = {dtype: output.dtype, shape: output.shape}; - const source = makeShader(inputsData, outputData, program); - const module = device.createShaderModule( - {code: source, label: program.constructor.name}); - - let printShaderString = env().get('WEBGPU_PRINT_SHADER') as string; - if (printShaderString !== '') { - printShaderString = printShaderString.toLowerCase(); - const printShaderArray = printShaderString.split(','); - if (printShaderString === 'all' || - printShaderArray.some( - item => program.shaderKey.toLowerCase().includes(item))) { - console.group(program.shaderKey); - console.debug(source); - console.groupEnd(); - } - } - - if (parallelCompilation) { - return device.createComputePipelineAsync({ - compute: {module, entryPoint: '_start'}, - label: program.constructor.name, - layout: 'auto' - }); - } else { - return device.createComputePipeline({ - compute: {module, entryPoint: '_start'}, - label: program.constructor.name, - layout: 'auto' - }); - } - }; - -export const typeSnippet = (component: number, type = 'f32') => { - switch (component) { - case 1: - return `${type}`; - case 2: - return `vec2<${type}>`; - case 3: - return `vec3<${type}>`; - case 4: - return `vec4<${type}>`; - default: - throw new Error(`${component}-component ${type} is not supported.`); - } -}; - -export function getCoordsDataType(rank: number): string { - if (rank <= 1) { - return 'i32'; - } else if (rank === 2) { - return `vec2`; - } else if (rank === 3) { - return `vec3`; - } else if (rank === 4) { - return `vec4`; - } else if (rank === 5) { - return `vec5`; - } else if (rank === 6) { - return `vec6`; - } else { - throw Error(`GPU for rank ${rank} is not yet supported`); - } -} - -export function getCoordsXYZ(index: number): string { - if (index === 0) { - return 'x'; - } else if (index === 1) { - return 'y'; - } else if (index === 2) { - return 'z'; - } else if (index === 3) { - return 'w'; - } else if (index === 4) { - return 'u'; - } else if (index === 5) { - return 'v'; - } else { - throw Error(`Index ${index} is not yet supported`); - } -} - -export function getMainHeaderString(): string; -export function getMainHeaderString(index: string): string; -export function getMainHeaderString(...params: string[]): string { - let snippet: string; - switch (params.length) { - case 0: - snippet = ` - fn main() - `; - break; - case 1: - snippet = ` - fn main(${params[0]} : i32) - `; - break; - default: - throw Error('Unreachable'); - } - return snippet; -} - -export function getStartHeaderString( - useGlobalIndex: boolean, program: WebGPUProgram): string { - let snippet: string; - snippet = ` - ${getWorkgroupSizeString(program)} - fn _start(@builtin(local_invocation_id) LocalId : vec3, - @builtin(global_invocation_id) GlobalId : vec3, - @builtin(local_invocation_index) LocalIndex: u32, - @builtin(workgroup_id) WorkgroupId : vec3, - @builtin(num_workgroups) NumWorkgroups : vec3) { - localId = LocalId; - localIndex = LocalIndex; - globalId = GlobalId; - numWorkgroups = NumWorkgroups; - workgroupId = WorkgroupId; - ${useGlobalIndex ? `main(getGlobalIndex());` : `main();`}; - } - `; - return snippet; -} - -export function getWorkgroupSizeString(program: WebGPUProgram): string { - return ` - @compute @workgroup_size(${program.workgroupSize[0]}, ${ - program.workgroupSize[1]}, ${program.workgroupSize[2]}) -`; -} - -function makeShader( - inputInfo: InputInfo[], outputData: {dtype: DataType, shape: number[]}, - program: WebGPUProgram): string { - const prefixSnippets: string[] = []; - const flatWorkgroupSize = program.workgroupSize[0] * - program.workgroupSize[1] * program.workgroupSize[2]; - program.outputComponent = - program.outputComponent ? program.outputComponent : 1; - prefixSnippets.push(` - - var localId: vec3; - var localIndex: u32; - var globalId: vec3; - var numWorkgroups: vec3; - var workgroupId: vec3; - - // Only used when the y/z dimension of workgroup size is 1. - fn getGlobalIndex() -> i32 { - ${ - isFlatDispatch(program) ? - ` return i32(globalId.x);` : - ` return i32((workgroupId.z * numWorkgroups.x * numWorkgroups.y + - workgroupId.y * numWorkgroups.x + workgroupId.x) * ${ - flatWorkgroupSize}u + - localIndex); - `} - } - `); - - if (program.pixelsOpType != null) { - const inoutSnippet = program.pixelsOpType === PixelsOpType.FROM_PIXELS ? - `@group(0) @binding(0) var result: array<${ - dataTypeToGPUType(outputData.dtype, program.outputComponent)}>;` : - `@group(0) @binding(1) var inBuf : array<${ - dataTypeToGPUType(inputInfo[0].dtype, program.outputComponent)}>;`; - const outShapeStridesType = - outputData.shape.length === 3 ? 'vec2' : 'i32'; - prefixSnippets.push(` - struct Uniform { - outShapeStrides : ${outShapeStridesType}, - size : i32, - numChannels : i32, - alpha : f32, - }; - - ${inoutSnippet} - @group(0) @binding(2) var uniforms: Uniform; - `); - const useGlobalIndex = isFlatDispatchLayout(program); - return [ - commonSnippet, - prefixSnippets.join('\n'), - getCoordsFromIndexSnippet(outputData.shape), - program.getUserCode(), - getStartHeaderString(useGlobalIndex, program), - ].join('\n'); - } - - let stridesLength: number; - let stridesDataType: string; - let uniformDeclaration = 'struct Uniforms { NAN : f32, INFINITY : f32, '; - program.variableNames.forEach((x, i) => { - const perDataType = getCoordsDataType(inputInfo[i].shape.length); - uniformDeclaration += - `${x.charAt(0).toLowerCase() + x.slice(1)}Shape : ${perDataType}, `; - stridesLength = inputInfo[i].shape.length - 1; - stridesDataType = getCoordsDataType(stridesLength); - uniformDeclaration += - `${x.charAt(0).toLowerCase() + x.slice(1)}ShapeStrides: ${ - stridesDataType}, `; - }); - const outputDataType = getCoordsDataType(outputData.shape.length); - uniformDeclaration += `outShape : ${outputDataType}, `; - stridesLength = outputData.shape.length - 1; - stridesDataType = getCoordsDataType(stridesLength); - uniformDeclaration += ` - outShapeStrides: ${stridesDataType}, `; - - if (program.size) { - uniformDeclaration += 'size : i32, '; - } - - if (program.uniforms) { - uniformDeclaration += program.uniforms; - } - uniformDeclaration += '};'; - uniformDeclaration = insertAlignment(uniformDeclaration); - - prefixSnippets.push(uniformDeclaration); - - // Output buffer. - if (program.atomic) { - prefixSnippets.push(` - @group(0) @binding(0) var result: array>; - `); - } else { - prefixSnippets.push(` - @group(0) @binding(0) var result: array<${ - dataTypeToGPUType(outputData.dtype, program.outputComponent)}>; - `); - } - program.variableNames.forEach((x, i) => { - prefixSnippets.push(` - @group(0) @binding(${1 + i}) var ${x}: array<${ - program.variableComponents ? - dataTypeToGPUType( - inputInfo[i].dtype, program.variableComponents[i]) : - dataTypeToGPUType(inputInfo[i].dtype, program.outputComponent)}>; - `); - }); - - if (uniformDeclaration !== '') { - prefixSnippets.push(` - @group(0) @binding(${ - 1 + program.variableNames.length}) var uniforms: Uniforms; - `); - } - - const coordsSnippet = - getOutputCoordsSnippet(outputData.shape, program.dispatchLayout); - - const sources = [ - commonSnippet, prefixSnippets.join('\n') + isInfSnippet, - getCoordsFromIndexSnippet(outputData.shape), coordsSnippet, - getOutputIndexFromCoordsSnippet(outputData.shape.length) - ]; - if (!program.atomic) { - sources.push(setOutputSnippet( - outputData.shape, outputData.dtype, program.outputComponent)); - } - - program.variableNames.forEach((x, i) => { - sources.push(`${getCoordsFromIndexSnippet(inputInfo[i].shape, x)}`); - }); - - const inputSnippet = - inputInfo - .map( - (x, i) => getInputSnippet( - x, outputData.shape, - program.variableComponents ? program.variableComponents[i] : - program.outputComponent, - program.dispatchLayout.x.length === outputData.shape.length)) - .join('\n'); - sources.push(inputSnippet); - sources.push(program.getUserCode()); - const useGlobalIndex = isFlatDispatchLayout(program); - sources.push(getStartHeaderString(useGlobalIndex, program)); - const source = sources.join('\n'); - return source; -} - -export function makeShaderKey( - program: WebGPUProgram, inputsData: InputInfo[], - output: TensorInfo): string { - let key = program.shaderKey; - if (program.pixelsOpType != null) { - return key; - } - - const shapes: number[][] = []; - const types: Array = []; - inputsData.forEach(element => { - shapes.push(element.shape); - types.push(element.dtype); - }); - shapes.push(output.shape); - types.push(output.dtype); - - const broadcastDims = - inputsData.map(d => backend_util.getBroadcastDims(d.shape, output.shape)); - const inputShapesEqualsOutShape = - inputsData.map(d => util.arraysEqual(d.shape, output.shape)).join('_'); - const broadcastDimsKey = broadcastDims.map(d => d.join('_')).join(';'); - - const flatDispatchString = isFlatDispatch(program) ? 'flatDispatch' : ''; - - key += '_' + (program.workgroupSize ? program.workgroupSize.join(',') : '') + - shapes.map(shape => shape.length).join(',') + types.join(',') + - program.variableNames.join(',') + broadcastDimsKey + - inputShapesEqualsOutShape + flatDispatchString; - - return key; -} - -const commonSnippet = ` - struct vec5 {x: i32, y: i32, z: i32, w: i32, u: i32}; - struct vec6 {x: i32, y: i32, z: i32, w: i32, u: i32, v: i32}; - - // Checks whether coordinates lie within the bounds of the shape. - fn coordsInBounds2D(coord : vec2, shape : vec2) -> bool { - return all(coord >= vec2(0)) && all(coord < shape); - } - fn coordsInBounds3D(coord : vec3, shape : vec3) -> bool { - return all(coord >= vec3(0)) && all(coord < shape); - } - fn coordsInBounds4D(coord : vec4, shape : vec4) -> bool { - return all(coord >= vec4(0)) && all(coord < shape); - } - - fn getIndexFromCoords1D(coord : i32, shape : i32) -> i32 { - return coord; - } - fn getIndexFromCoords2D(coords : vec2, shape : vec2) -> i32 { - return dot(coords, vec2(shape.y, 1)); - } - fn getIndexFromCoords3D(coords : vec3, shape : vec3) -> i32 { - return dot(coords, vec3(shape.y * shape.z, shape.z, 1)); - } - fn getIndexFromCoords4D(coords : vec4, shape : vec4) -> i32 { - return dot(coords, vec4( - shape.y * shape.z * shape.w, shape.z * shape.w, shape.w, 1)); - } - fn getIndexFromCoords5D(coords : vec5, shape : vec5) -> i32 { - let shapeStrides: vec5 = vec5(shape.y * shape.z * shape.w * shape.u, shape.z * shape.w * shape.u, shape.w * shape.u, shape.u, 1); - return coords.x*shapeStrides.x + coords.y*shapeStrides.y + coords.z*shapeStrides.z + coords.w*shapeStrides.w + coords.u*shapeStrides.u; - } - fn getIndexFromCoords6D(coords : vec6, shape : vec6) -> i32 { - let shapeStrides: vec6 = vec6(shape.y * shape.z * shape.w * shape.u * shape.v, shape.z * shape.w * shape.u * shape.v, shape.w * shape.u * shape.v, shape.u * shape.v, shape.v, 1); - return coords.x*shapeStrides.x + coords.y*shapeStrides.y + coords.z*shapeStrides.z + coords.w*shapeStrides.w + coords.u*shapeStrides.u + coords.v*shapeStrides.v; - } - - // NaN defination in IEEE 754-1985 is : - // - sign = either 0 or 1. - // - biased exponent = all 1 bits. - // - fraction = anything except all 0 bits (since all 0 bits represents infinity). - // https://en.wikipedia.org/wiki/IEEE_754-1985#Representation_of_non-numbers - fn isnan(val: f32) -> bool { - let floatToUint: u32 = bitcast(val); - return (floatToUint & 0x7fffffffu) > 0x7f800000u; - } - fn isnanVec4(val : vec4) -> vec4 { - let floatToUint: vec4 = bitcast>(val); - return (floatToUint & vec4(0x7fffffffu)) > vec4(0x7f800000u); - } -`; - -const isInfSnippet = ` - fn isinf(val: f32) -> bool { - return abs(val) == uniforms.INFINITY; - } -`; - -type InputInfo = { - dtype: DataType; shape: number[]; name: string; -}; - -/** - * Derives logical coordinates from a flat index. Performs integer division - * with each stride and decrements the index until the index equals the final - * dimension coordinate. - */ -export function getCoordsFromIndexSnippet(shape: number[], name = ''): string { - const rank = shape.length; - const funcName = name !== '' ? - `get${name.charAt(0).toUpperCase() + name.slice(1)}CoordsFromIndex` : - 'getCoordsFromIndex'; - const stridesName = name !== '' ? - `${name.charAt(0).toLowerCase() + name.slice(1)}ShapeStrides` : - `outShapeStrides`; - - if (rank <= 1) { - return `fn ${funcName}(index : i32) -> i32 { return index; }`; - } - - const strides = util.computeStrides(shape); - const dtype = getCoordsDataType(rank); - - const coords: string[] = []; - for (let i = 0; i < rank; i++) { - coords.push(`d${i}`); - } - - if (strides.length === 1) { - return ` fn ${funcName}(index : i32) -> vec2 { - let d0 = index / uniforms.${ - stridesName}; let d1 = index - d0 * uniforms.${stridesName}; - return vec2(d0, d1); - }`; - } - let snippet; - snippet = 'var index2 = index;' + - strides - .map((_, i) => { - const line1 = `let ${coords[i]} = index2 / uniforms.${ - stridesName}.${getCoordsXYZ(i)}`; - const line2 = i === strides.length - 1 ? - `let ${coords[i + 1]} = index2 - ${coords[i]} * uniforms.${ - stridesName}.${getCoordsXYZ(i)}` : - `index2 = index2 - ${coords[i]} * uniforms.${stridesName}.${ - getCoordsXYZ(i)}`; - return `${line1}; ${line2};`; - }) - .join(''); - - return ` - fn ${funcName}(index : i32) -> ${dtype} { - ${snippet} - return ${dtype}(${coords.join(',')}); - } - `; -} - -function getInputAtCoordsSnippet( - inputInfo: InputInfo, component: number): string { - const texName = inputInfo.name; - const rank = inputInfo.shape.length; - const type = getCoordsDataType(rank); - const funcName = 'get' + texName.charAt(0).toUpperCase() + texName.slice(1); - const dims = ['d0', 'd1', 'd2', 'd3', 'd4', 'd5'].slice(0, rank); - const inputs = dims.map(d => `${d} : i32`).join(', '); - - if (rank < 1) { - return ` - fn ${funcName}() -> ${typeSnippet(component)} { - return ${typeSnippet(component)}(${texName}[0]); - } - `; - } - - const shapeStr = - `uniforms.${texName.charAt(0).toLowerCase() + texName.slice(1)}Shape`; - let rankStr = `${rank}D`; - if (rank === 0) { - rankStr = '1D'; - } - - return ` - fn ${funcName}(${inputs}) -> ${typeSnippet(component)} { - return ${typeSnippet(component)}(${texName}[getIndexFromCoords${ - rankStr}(${type}(${dims.join(',')}), - ${shapeStr})${component === 1 ? '' : ` / ${component}`}]); - } - `; -} - -function getInputByOutputSnippet( - inputInfo: InputInfo, outShape: number[], component: number, - isFlatDispatchLayout: boolean): string { - const texName = inputInfo.name; - const texFuncSnippet = texName.charAt(0).toUpperCase() + texName.slice(1); - - const funcName = 'get' + texFuncSnippet + 'ByOutput'; - - const inRank = inputInfo.shape.length; - const outRank = outShape.length; - const type = getCoordsDataType(outRank); - - // If the inShape equals the outShape and the dispatch layout is flat, we can - // directly use |gl_GlobalInvocationID.x| as the index and don't need coords - // conversion between these two shapes. - if (util.arraysEqual(inputInfo.shape, outShape) && isFlatDispatchLayout) { - return ` - fn ${funcName}Index(globalIndex : i32) -> ${typeSnippet(component)} { - return ${typeSnippet(component)}(${texName}[globalIndex]); - } - - fn ${funcName}Coords(coords : ${type}) -> ${typeSnippet(component)} { - return ${typeSnippet(component)}(${texName}[${ - outRank > 1 ? 'getOutputIndexFromCoords(coords)' : - 'coords'}${component === 1 ? '' : ` / ${component}`}]); - } - `; - } - - const broadcastDims = - backend_util.getBroadcastDims(inputInfo.shape, outShape); - const rankDiff = outRank - inRank; - - let coordsSnippet = ''; - - if (inRank === 0) { - return ` - fn ${funcName}Index(globalIndex : i32) -> ${typeSnippet(component)}{ - return get${texFuncSnippet}(); - } - - fn ${funcName}Coords(coords : ${type}) -> ${typeSnippet(component)}{ - return get${texFuncSnippet}(); - } - `; - } else { - if (outRank < 2 && broadcastDims.length >= 1) { - coordsSnippet = 'coords = 0;'; - } else { - coordsSnippet = - broadcastDims.map(d => `coords.${getCoordsXYZ(d + rankDiff)} = 0;`) - .join('\n'); - } - } - - let unpackedCoordsSnippet = ''; - if (outRank < 2 && inRank > 0) { - unpackedCoordsSnippet = 'coords'; - } else { - if (outRank > 1) { - const coordsType = getCoordsDataType(inRank); - const coordsValues = - inputInfo.shape.map((s, i) => `coords.${getCoordsXYZ(i + rankDiff)}`) - .join(', '); - unpackedCoordsSnippet = `${coordsType}(${coordsValues})`; - } else { - unpackedCoordsSnippet = 'coords'; - } - } - - const shapeStr = - `uniforms.${texName.charAt(0).toLowerCase() + texName.slice(1)}Shape`; - const rankStr = `${inRank}D`; - - return ` - fn ${funcName}Index(globalIndex : i32) -> ${typeSnippet(component)} { - var coords = getCoordsFromIndex(globalIndex); - ${coordsSnippet} - return ${typeSnippet(component)}(${texName}[getIndexFromCoords${rankStr}(${ - unpackedCoordsSnippet}, ${shapeStr})${ - component === 1 ? '' : ` / ${component}`}]); - } - - fn ${funcName}Coords(coordsIn : ${type}) -> ${typeSnippet(component)} { - var coords = coordsIn; - ${coordsSnippet} - return ${typeSnippet(component)}(${texName}[getIndexFromCoords${rankStr}(${ - unpackedCoordsSnippet}, ${shapeStr})${ - component === 1 ? '' : ` / ${component}`}]); - } -`; -} - -function getInputSnippet( - inputInfo: InputInfo, outShape: number[], component: number, - isFlatDispatchLayout: boolean): string { - let res = getInputAtCoordsSnippet(inputInfo, component); - - const inShape = inputInfo.shape; - if (inShape.length <= outShape.length) { - res += getInputByOutputSnippet( - inputInfo, outShape, component, isFlatDispatchLayout); - } - - return res; -} - -/** - * Generates getOutputCoords() function that computes output coordinates - * from dispatch geometry to reduce arithmetic. - */ -function getOutputCoordsSnippet( - outShape: number[], - dispatchLayout: {x: number[], y?: number[], z?: number[]}): string { - const {x, y = [], z = []} = dispatchLayout; - - const outRank = outShape.length; - const rank = x.length + y.length + z.length; - // getOutputCoords is only meaningful when the output rank is same with - // dispatch layout rank. - if (rank !== outRank) { - return ''; - } - - if (x.length === outRank) { - const dtype = getCoordsDataType(outRank); - const snippet = `fn getOutputCoords() -> ${dtype}{ - let globalIndex = getGlobalIndex(); - return getCoordsFromIndex(globalIndex); - } - `; - return snippet; - } - - let gatherDimensionsStr = ''; - const dims = [x, y, z]; - - for (let i = 0; i < dims.length; i++) { - const arr = dims[i]; - - if (arr.length === 0) { - continue; - } - - if (arr.length === 1) { - gatherDimensionsStr += `let d${arr[0]} = i32(globalId[${i}]);`; - } else { - const strides = symbolicallyComputeStrides(arr, 'uniforms.outShape'); - gatherDimensionsStr += `var index${i} = i32(globalId[${i}]);`; - for (let j = 0; j < strides.length; j++) { - gatherDimensionsStr += `let d${arr[j]} = index${i} / ${strides[j]};`; - - if (j === strides.length - 1) { - gatherDimensionsStr += `let d${arr[j + 1]} = ` + - `index${i} - d${arr[j]} * ${strides[j]};`; - } else { - gatherDimensionsStr += - `index${i} = index${i} - d${arr[j]} * ${strides[j]};`; - } - } - } - } - - const dimensions = []; - for (let i = 0; i < rank; i++) { - dimensions.push(`d${i}`); - } - - const dtype = getCoordsDataType(rank); - let snippet = `fn getOutputCoords() -> ${dtype} { - ${gatherDimensionsStr} -`; - if (dimensions.length === 0) { - snippet += `return ${dtype}(0); }`; - } else { - snippet += `return ${dtype}(${dimensions.join(',')}); }`; - } - - return snippet; -} - -function getOutputIndexFromCoordsSnippet(outRank: number) { - let snippet = ''; - switch (outRank) { - case 0: - case 1: - snippet += ` - fn getOutputIndexFromCoords(coords : i32) -> i32 { - return coords; - } - `; - break; - case 2: - snippet += ` - fn getOutputIndexFromCoords(coords : vec2) -> i32 { - return dot(coords, vec2(uniforms.outShapeStrides, 1)); - } - `; - break; - case 3: - snippet += ` - fn getOutputIndexFromCoords(coords : vec3) -> i32 { - return dot(coords, vec3(uniforms.outShapeStrides.x, uniforms.outShapeStrides.y, 1)); - } - `; - break; - case 4: - snippet += ` - fn getOutputIndexFromCoords(coords : vec4) -> i32 { - return dot(coords, vec4( - uniforms.outShapeStrides.x, uniforms.outShapeStrides.y, uniforms.outShapeStrides.z, 1)); - } - `; - break; - case 5: - snippet += ` - fn getOutputIndexFromCoords(coords : vec5) -> i32 { - return coords.x * uniforms.outShapeStrides.x + - coords.y * uniforms.outShapeStrides.y + - coords.z * uniforms.outShapeStrides.z + - coords.w * uniforms.outShapeStrides.w + - coords.u; - } - `; - break; - case 6: - snippet += ` - fn getOutputIndexFromCoords(coords : vec6) -> i32 { - return coords.x * uniforms.outShapeStrides.x + - coords.y * uniforms.outShapeStrides.y + - coords.z * uniforms.outShapeStrides.z + - coords.w * uniforms.outShapeStrides.w + - coords.u * uniforms.outShapeStrides.u + - coords.v; - } - `; - break; - default: - util.assert(false, () => `Unsupported ${outRank}D shape`); - break; - } - return snippet; -} - -function isFlatDispatch(program: WebGPUProgram): boolean { - return program.dispatch[1] === 1 && program.dispatch[2] === 1; -} - -export function dataTypeToGPUType(type: DataType, component = 1) { - if (type === 'float32') { - return typeSnippet(component, 'f32'); - } else if (type === 'int32' || type === 'bool') { - return typeSnippet(component, 'i32'); - } - throw new Error(`type ${type} is not supported.`); -} - -function setOutputSnippet( - outShape: number[], outBufferType: DataType, component: number): string { - const outRank = outShape.length; - const gpuType = dataTypeToGPUType(outBufferType, component); - let snippet = - `fn setOutputAtIndex(flatIndex : i32, value : ${typeSnippet(component)}) { - result[flatIndex] = ${gpuType}(value); - } - - fn setOutputAtIndexI32(flatIndex : i32, value : ${ - typeSnippet(component, 'i32')}) { - result[flatIndex] = ${gpuType}(value); - } - `; - if (outRank >= 2) { - const dims = ['d0', 'd1', 'd2', 'd3', 'd4', 'd5'].slice(0, outRank); - const type = getCoordsDataType(outRank); - - snippet += ` - fn setOutputAtCoords(${dims.map(d => `${d} : i32`).join(', ')}, value : ${ - typeSnippet(component)}) { - let flatIndex = getOutputIndexFromCoords(${type}(${dims.join(', ')})); - setOutputAtIndex(flatIndex${ - component === 1 ? '' : ` / ${component}`}, value); - } - fn setOutputAtCoordsI32(${ - dims.map(d => `${d} : i32`).join(', ')}, value : ${ - typeSnippet(component, 'i32')}) { - let flatIndex = getOutputIndexFromCoords(${type}(${dims.join(', ')})); - setOutputAtIndexI32(flatIndex${ - component === 1 ? '' : ` / ${component}`}, value); - } - `; - } - - return snippet; -} - -function insertAlignment(uniformShader: string) { - // insert alignment when current pattern is vec5 or vec6 - const curInsertRe = /(\w+)\s*:\s*vec(5|6)/g; - uniformShader = uniformShader.replace(curInsertRe, (match) => { - return '@align(16) ' + match; - }); - - // insert alignment when previous pattern is vec5 or vec6 - const preInsertRe = /vec(5|6)\s*,\s*(\w+)/g; - uniformShader = uniformShader.replace(preInsertRe, (_, p1, p2) => { - return `vec${p1}, @align(16) ${p2}`; - }); - return uniformShader; -} -function isFlatDispatchLayout(program: WebGPUProgram): boolean { - if (program.dispatchLayout.hasOwnProperty('y') && - program.dispatchLayout.y.length !== 0) { - return false; - } - if (program.dispatchLayout.hasOwnProperty('z') && - program.dispatchLayout.z.length !== 0) { - return false; - } - return true; -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/webgpu_util.ts b/tfjs-master/tfjs-backend-webgpu/src/webgpu_util.ts deleted file mode 100644 index bf0f01d73..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/webgpu_util.ts +++ /dev/null @@ -1,183 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {DataType, TensorInfo, util} from '@tensorflow/tfjs-core'; - -const arrayProduct = (arr: number[]) => { - let product = 1; - for (let i = 0; i < arr.length; i++) { - product *= arr[i]; - } - return product; -}; - -export function tilesFitEvenlyIntoShape( - tileSize: number[], shape: number[]): boolean { - if (tileSize.length !== shape.length) { - throw new Error( - `Cannot compute whether rank ${tileSize.length}` + - ` tiles fit evenly into rank ${shape.length} shape` + - ` - ranks must match.`); - } - return shape.every( - (dim: number, dimIdx: number) => dim % tileSize[dimIdx] === 0); -} - -// Computes dispatch geometry based on layout of output dimensions and -// workgroupSize. -export function computeDispatch( - layout: {x: number[], y?: number[], z?: number[]}, outputShape: number[], - workgroupSize: [number, number, number] = [1, 1, 1], - elementsPerThread: [number, number, number] = - [1, 1, 1]): [number, number, number] { - const [dispatchX, dispatchY, dispatchZ] = [ - Math.ceil( - arrayProduct(layout.x.map(d => outputShape[d])) / - (workgroupSize[0] * elementsPerThread[0])), - layout.y ? Math.ceil( - arrayProduct(layout.y.map(d => outputShape[d])) / - (workgroupSize[1] * elementsPerThread[1])) : - 1, - layout.z ? Math.ceil( - arrayProduct(layout.z.map(d => outputShape[d])) / - (workgroupSize[2] * elementsPerThread[2])) : - 1 - ]; - return [dispatchX, dispatchY, dispatchZ]; -} - -export type WorkgroupInfo = { - workgroupSize: [number, number, number], - elementsPerThread: [number, number, number], -}; - -export function computeWorkgroupInfoForMatMul( - dimAOuter: number, dimInner: number, dimBOuter: number, - transposeA = false): WorkgroupInfo { - // These are experimental values. Usually, we need to adjust the work group - // size based on the input shapes to improve the EU occupancy. - // TODO: WebGPU limits the maximum allowed shared memory size as 16K. To make - // sure it doesn't exceed this limitations. Temporarily reduce the work group - // size to [8, 8, 1] and the work per thread size is [4, 4, 1]. But we should - // revisit it and find the balance between work group size and work per thread - // size. - const workgroupSize: [number, number, number] = [8, 8, 1]; - const elementsPerThread: [number, number, number] = [4, 4, 1]; - - if (!transposeA) { - if (dimAOuter <= 8) { - elementsPerThread[1] = 1; - } - - if (dimInner <= 16 && dimBOuter <= 16) { - workgroupSize[0] = 4; - } - } - - return {workgroupSize, elementsPerThread}; -} - -export function computeWorkgroupSizeForConv2d( - layout: {x: number[], y?: number[], z?: number[]}, outputShape: number[], - isVec4 = false): [number, number, number] { - if (isVec4) { - return [8, 8, 1]; - } - - const dim0 = arrayProduct(layout.x.map(d => outputShape[d])); - const dim1 = arrayProduct(layout.y.map(d => outputShape[d])); - // TODO(jiajia.qin@intel.com): More fine tune based on outputShape. - // These are experimental values. Usually, we need to adjust the work group - // size based on the output shape. For example, when one dimension is smaller - // than 4, it will be wasteful if we assign a larger size for this dimension, - // which results lots of threads doing useless work and reduces parallelism - // of hardware threads. But it is always a balance between work group size - // and shared memory. If one dimension is too small, such as 1, shared memory - // will won't be fully utilized. - if (dim0 <= 4) { - return [4, 16, 1]; - } - if (dim1 <= 4) { - return [16, 4, 1]; - } - - return [16, 16, 1]; -} - -export function computeWorkPerThreadForConv2d( - layout: {x: number[], y?: number[], z?: number[]}, outputShape: number[], - isVec4 = false): [number, number, number] { - if (isVec4) { - return [4, 4, 1]; - } - - const dim0 = arrayProduct(layout.x.map(d => outputShape[d])); - const dim1 = arrayProduct(layout.y.map(d => outputShape[d])); - // TODO(jiajia.qin@intel.com): More fine tune based on outputShape. - // The following conditions correspond to the values set in - // computeWorkgroupSizeForConv2d. - if (dim0 <= 4) { - return [1, 2, 1]; - } - if (dim1 <= 4) { - return [2, 1, 1]; - } - - return [2, 2, 1]; -} - -export function flatDispatchLayout(shape: number[]) { - return {x: shape.map((d, i) => i)}; -} - -export function GPUBytesPerElement(dtype: DataType): number { - if (dtype === 'float32' || dtype === 'int32' || dtype === 'bool' || - dtype === 'string') { - return 4; - } else if (dtype === 'complex64') { - return 8; - } else { - throw new Error(`Unknown dtype ${dtype}`); - } -} - -export function isWebGPUSupported(): boolean { - return !!(typeof globalThis !== 'undefined' && (globalThis.navigator) - && (globalThis.navigator.gpu)); -} - -export function assertNotComplex( - tensor: TensorInfo|TensorInfo[], opName: string): void { - if (!Array.isArray(tensor)) { - tensor = [tensor]; - } - tensor.forEach(t => { - if (t != null) { - util.assert( - t.dtype !== 'complex64', - () => `${opName} does not support complex64 tensors ` + - 'in the WebGPU backend.'); - } - }); -} - -export enum MatMulProgramType { - MatMulReduceProgram, - MatMulSplitKProgram, - MatMulSmallOutputSizeProgram, - MatMulPackedProgram, - MatMulMax -} diff --git a/tfjs-master/tfjs-backend-webgpu/src/webgpu_util_test.ts b/tfjs-master/tfjs-backend-webgpu/src/webgpu_util_test.ts deleted file mode 100644 index c2a50b5c1..000000000 --- a/tfjs-master/tfjs-backend-webgpu/src/webgpu_util_test.ts +++ /dev/null @@ -1,46 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {computeDispatch} from './webgpu_util'; - -describe('webgpu util', () => { - it('computeDispatch returns dispatch dimensions based on layout of ' + - 'output dimensions and workgroupSize.', - () => { - const layout = {x: [0], y: [1], z: [2, 3]}; - const outputShape = [1, 2, 3, 2]; - - const workgroupSize = [2, 2, 1] as [number, number, number]; - - const dispatch = computeDispatch(layout, outputShape, workgroupSize); - expect(dispatch).toEqual([1, 1, 6]); - }); - - it('computeDispatch returns dispatch dimensions based on layout of ' + - 'output dimensions, workgroupSize, and elementsPerThread.', - () => { - const layout = {x: [0], y: [1], z: [2, 3]}; - const outputShape = [4, 8, 12, 2]; - - const workgroupSize = [2, 1, 1] as [number, number, number]; - const elementsPerThread = [2, 2, 3] as [number, number, number]; - - const dispatch = computeDispatch( - layout, outputShape, workgroupSize, elementsPerThread); - expect(dispatch).toEqual([1, 4, 8]); - }); -}); diff --git a/tfjs-master/tfjs-backend-webgpu/tsconfig.json b/tfjs-master/tfjs-backend-webgpu/tsconfig.json deleted file mode 100644 index 37483bf58..000000000 --- a/tfjs-master/tfjs-backend-webgpu/tsconfig.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "extends": "../tsconfig_base.json", - "include": [ - "src/" - ], - "exclude": [ - "node_modules/" - ], - "compilerOptions": { - "baseUrl": ".", - "paths": {}, - "outDir": "./dist", - "target": "es2017" - } -} diff --git a/tfjs-master/tfjs-backend-webgpu/tsconfig.test.json b/tfjs-master/tfjs-backend-webgpu/tsconfig.test.json deleted file mode 100644 index 646e86c21..000000000 --- a/tfjs-master/tfjs-backend-webgpu/tsconfig.test.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "extends": "../tsconfig_ts_library", - "include": [ - "src/" - ], - "exclude": [ - "node_modules/" - ], - "compilerOptions": { - "module": "commonjs", - "baseUrl": ".", - "paths": {}, - "outDir": "./dist" - } -} diff --git a/tfjs-master/tfjs-backend-webgpu/yarn.lock b/tfjs-master/tfjs-backend-webgpu/yarn.lock deleted file mode 100644 index 7332b5f63..000000000 --- a/tfjs-master/tfjs-backend-webgpu/yarn.lock +++ /dev/null @@ -1,3198 +0,0 @@ -# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. -# yarn lockfile v1 - - -"@babel/code-frame@^7.14.5": - version "7.14.5" - resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.14.5.tgz#23b08d740e83f49c5e59945fbf1b43e80bbf4edb" - integrity sha512-9pzDqyc6OLDaqe+zbACgFkb6fKMNG6CObKpnYXChRsvYGyEdc7CA2BaqeOM+vOtCS5ndmJicPJhKAwYRI6UfFw== - dependencies: - "@babel/highlight" "^7.14.5" - -"@babel/compat-data@^7.13.11", "@babel/compat-data@^7.14.7", "@babel/compat-data@^7.15.0": - version "7.15.0" - resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.15.0.tgz#2dbaf8b85334796cafbb0f5793a90a2fc010b176" - integrity sha512-0NqAC1IJE0S0+lL1SWFMxMkz1pKCNCjI4tr2Zx4LJSXxCLAdr6KyArnY+sno5m3yH9g737ygOyPABDsnXkpxiA== - -"@babel/core@^7.11.1", "@babel/core@^7.7.5": - version "7.15.0" - resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.15.0.tgz#749e57c68778b73ad8082775561f67f5196aafa8" - integrity sha512-tXtmTminrze5HEUPn/a0JtOzzfp0nk+UEXQ/tqIJo3WDGypl/2OFQEMll/zSFU8f/lfmfLXvTaORHF3cfXIQMw== - dependencies: - "@babel/code-frame" "^7.14.5" - "@babel/generator" "^7.15.0" - "@babel/helper-compilation-targets" "^7.15.0" - "@babel/helper-module-transforms" "^7.15.0" - "@babel/helpers" "^7.14.8" - "@babel/parser" "^7.15.0" - "@babel/template" "^7.14.5" - "@babel/traverse" "^7.15.0" - "@babel/types" "^7.15.0" - convert-source-map "^1.7.0" - debug "^4.1.0" - gensync "^1.0.0-beta.2" - json5 "^2.1.2" - semver "^6.3.0" - source-map "^0.5.0" - -"@babel/generator@^7.15.0": - version "7.15.0" - resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.15.0.tgz#a7d0c172e0d814974bad5aa77ace543b97917f15" - integrity sha512-eKl4XdMrbpYvuB505KTta4AV9g+wWzmVBW69tX0H2NwKVKd2YJbKgyK6M8j/rgLbmHOYJn6rUklV677nOyJrEQ== - dependencies: - "@babel/types" "^7.15.0" - jsesc "^2.5.1" - source-map "^0.5.0" - -"@babel/helper-annotate-as-pure@^7.14.5": - version "7.14.5" - resolved "https://registry.yarnpkg.com/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.14.5.tgz#7bf478ec3b71726d56a8ca5775b046fc29879e61" - integrity sha512-EivH9EgBIb+G8ij1B2jAwSH36WnGvkQSEC6CkX/6v6ZFlw5fVOHvsgGF4uiEHO2GzMvunZb6tDLQEQSdrdocrA== - dependencies: - "@babel/types" "^7.14.5" - -"@babel/helper-builder-binary-assignment-operator-visitor@^7.14.5": - version "7.14.5" - resolved "https://registry.yarnpkg.com/@babel/helper-builder-binary-assignment-operator-visitor/-/helper-builder-binary-assignment-operator-visitor-7.14.5.tgz#b939b43f8c37765443a19ae74ad8b15978e0a191" - integrity sha512-YTA/Twn0vBXDVGJuAX6PwW7x5zQei1luDDo2Pl6q1qZ7hVNl0RZrhHCQG/ArGpR29Vl7ETiB8eJyrvpuRp300w== - dependencies: - "@babel/helper-explode-assignable-expression" "^7.14.5" - "@babel/types" "^7.14.5" - -"@babel/helper-compilation-targets@^7.13.0", "@babel/helper-compilation-targets@^7.14.5", "@babel/helper-compilation-targets@^7.15.0": - version "7.15.0" - resolved "https://registry.yarnpkg.com/@babel/helper-compilation-targets/-/helper-compilation-targets-7.15.0.tgz#973df8cbd025515f3ff25db0c05efc704fa79818" - integrity sha512-h+/9t0ncd4jfZ8wsdAsoIxSa61qhBYlycXiHWqJaQBCXAhDCMbPRSMTGnZIkkmt1u4ag+UQmuqcILwqKzZ4N2A== - dependencies: - "@babel/compat-data" "^7.15.0" - "@babel/helper-validator-option" "^7.14.5" - browserslist "^4.16.6" - semver "^6.3.0" - -"@babel/helper-create-class-features-plugin@^7.14.5": - version "7.15.0" - resolved "https://registry.yarnpkg.com/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.15.0.tgz#c9a137a4d137b2d0e2c649acf536d7ba1a76c0f7" - integrity sha512-MdmDXgvTIi4heDVX/e9EFfeGpugqm9fobBVg/iioE8kueXrOHdRDe36FAY7SnE9xXLVeYCoJR/gdrBEIHRC83Q== - dependencies: - "@babel/helper-annotate-as-pure" "^7.14.5" - "@babel/helper-function-name" "^7.14.5" - "@babel/helper-member-expression-to-functions" "^7.15.0" - "@babel/helper-optimise-call-expression" "^7.14.5" - "@babel/helper-replace-supers" "^7.15.0" - "@babel/helper-split-export-declaration" "^7.14.5" - -"@babel/helper-create-regexp-features-plugin@^7.14.5": - version "7.14.5" - resolved "https://registry.yarnpkg.com/@babel/helper-create-regexp-features-plugin/-/helper-create-regexp-features-plugin-7.14.5.tgz#c7d5ac5e9cf621c26057722fb7a8a4c5889358c4" - integrity sha512-TLawwqpOErY2HhWbGJ2nZT5wSkR192QpN+nBg1THfBfftrlvOh+WbhrxXCH4q4xJ9Gl16BGPR/48JA+Ryiho/A== - dependencies: - "@babel/helper-annotate-as-pure" "^7.14.5" - regexpu-core "^4.7.1" - -"@babel/helper-define-polyfill-provider@^0.2.2": - version "0.2.3" - resolved "https://registry.yarnpkg.com/@babel/helper-define-polyfill-provider/-/helper-define-polyfill-provider-0.2.3.tgz#0525edec5094653a282688d34d846e4c75e9c0b6" - integrity sha512-RH3QDAfRMzj7+0Nqu5oqgO5q9mFtQEVvCRsi8qCEfzLR9p2BHfn5FzhSB2oj1fF7I2+DcTORkYaQ6aTR9Cofew== - dependencies: - "@babel/helper-compilation-targets" "^7.13.0" - "@babel/helper-module-imports" "^7.12.13" - "@babel/helper-plugin-utils" "^7.13.0" - "@babel/traverse" "^7.13.0" - debug "^4.1.1" - lodash.debounce "^4.0.8" - resolve "^1.14.2" - semver "^6.1.2" - -"@babel/helper-explode-assignable-expression@^7.14.5": - version "7.14.5" - resolved "https://registry.yarnpkg.com/@babel/helper-explode-assignable-expression/-/helper-explode-assignable-expression-7.14.5.tgz#8aa72e708205c7bb643e45c73b4386cdf2a1f645" - integrity sha512-Htb24gnGJdIGT4vnRKMdoXiOIlqOLmdiUYpAQ0mYfgVT/GDm8GOYhgi4GL+hMKrkiPRohO4ts34ELFsGAPQLDQ== - dependencies: - "@babel/types" "^7.14.5" - -"@babel/helper-function-name@^7.14.5": - version "7.14.5" - resolved "https://registry.yarnpkg.com/@babel/helper-function-name/-/helper-function-name-7.14.5.tgz#89e2c474972f15d8e233b52ee8c480e2cfcd50c4" - integrity sha512-Gjna0AsXWfFvrAuX+VKcN/aNNWonizBj39yGwUzVDVTlMYJMK2Wp6xdpy72mfArFq5uK+NOuexfzZlzI1z9+AQ== - dependencies: - "@babel/helper-get-function-arity" "^7.14.5" - "@babel/template" "^7.14.5" - "@babel/types" "^7.14.5" - -"@babel/helper-get-function-arity@^7.14.5": - version "7.14.5" - resolved "https://registry.yarnpkg.com/@babel/helper-get-function-arity/-/helper-get-function-arity-7.14.5.tgz#25fbfa579b0937eee1f3b805ece4ce398c431815" - integrity sha512-I1Db4Shst5lewOM4V+ZKJzQ0JGGaZ6VY1jYvMghRjqs6DWgxLCIyFt30GlnKkfUeFLpJt2vzbMVEXVSXlIFYUg== - dependencies: - "@babel/types" "^7.14.5" - -"@babel/helper-hoist-variables@^7.14.5": - version "7.14.5" - resolved "https://registry.yarnpkg.com/@babel/helper-hoist-variables/-/helper-hoist-variables-7.14.5.tgz#e0dd27c33a78e577d7c8884916a3e7ef1f7c7f8d" - integrity sha512-R1PXiz31Uc0Vxy4OEOm07x0oSjKAdPPCh3tPivn/Eo8cvz6gveAeuyUUPB21Hoiif0uoPQSSdhIPS3352nvdyQ== - dependencies: - "@babel/types" "^7.14.5" - -"@babel/helper-member-expression-to-functions@^7.15.0": - version "7.15.0" - resolved "https://registry.yarnpkg.com/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.15.0.tgz#0ddaf5299c8179f27f37327936553e9bba60990b" - integrity sha512-Jq8H8U2kYiafuj2xMTPQwkTBnEEdGKpT35lJEQsRRjnG0LW3neucsaMWLgKcwu3OHKNeYugfw+Z20BXBSEs2Lg== - dependencies: - "@babel/types" "^7.15.0" - -"@babel/helper-module-imports@^7.12.13", "@babel/helper-module-imports@^7.14.5": - version "7.14.5" - resolved "https://registry.yarnpkg.com/@babel/helper-module-imports/-/helper-module-imports-7.14.5.tgz#6d1a44df6a38c957aa7c312da076429f11b422f3" - integrity sha512-SwrNHu5QWS84XlHwGYPDtCxcA0hrSlL2yhWYLgeOc0w7ccOl2qv4s/nARI0aYZW+bSwAL5CukeXA47B/1NKcnQ== - dependencies: - "@babel/types" "^7.14.5" - -"@babel/helper-module-transforms@^7.14.5", "@babel/helper-module-transforms@^7.15.0": - version "7.15.0" - resolved "https://registry.yarnpkg.com/@babel/helper-module-transforms/-/helper-module-transforms-7.15.0.tgz#679275581ea056373eddbe360e1419ef23783b08" - integrity sha512-RkGiW5Rer7fpXv9m1B3iHIFDZdItnO2/BLfWVW/9q7+KqQSDY5kUfQEbzdXM1MVhJGcugKV7kRrNVzNxmk7NBg== - dependencies: - "@babel/helper-module-imports" "^7.14.5" - "@babel/helper-replace-supers" "^7.15.0" - "@babel/helper-simple-access" "^7.14.8" - "@babel/helper-split-export-declaration" "^7.14.5" - "@babel/helper-validator-identifier" "^7.14.9" - "@babel/template" "^7.14.5" - "@babel/traverse" "^7.15.0" - "@babel/types" "^7.15.0" - -"@babel/helper-optimise-call-expression@^7.14.5": - version "7.14.5" - resolved "https://registry.yarnpkg.com/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.14.5.tgz#f27395a8619e0665b3f0364cddb41c25d71b499c" - integrity sha512-IqiLIrODUOdnPU9/F8ib1Fx2ohlgDhxnIDU7OEVi+kAbEZcyiF7BLU8W6PfvPi9LzztjS7kcbzbmL7oG8kD6VA== - dependencies: - "@babel/types" "^7.14.5" - -"@babel/helper-plugin-utils@^7.0.0", "@babel/helper-plugin-utils@^7.10.4", "@babel/helper-plugin-utils@^7.12.13", "@babel/helper-plugin-utils@^7.13.0", "@babel/helper-plugin-utils@^7.14.5", "@babel/helper-plugin-utils@^7.8.0", "@babel/helper-plugin-utils@^7.8.3": - version "7.14.5" - resolved "https://registry.yarnpkg.com/@babel/helper-plugin-utils/-/helper-plugin-utils-7.14.5.tgz#5ac822ce97eec46741ab70a517971e443a70c5a9" - integrity sha512-/37qQCE3K0vvZKwoK4XU/irIJQdIfCJuhU5eKnNxpFDsOkgFaUAwbv+RYw6eYgsC0E4hS7r5KqGULUogqui0fQ== - -"@babel/helper-remap-async-to-generator@^7.14.5": - version "7.14.5" - resolved "https://registry.yarnpkg.com/@babel/helper-remap-async-to-generator/-/helper-remap-async-to-generator-7.14.5.tgz#51439c913612958f54a987a4ffc9ee587a2045d6" - integrity sha512-rLQKdQU+HYlxBwQIj8dk4/0ENOUEhA/Z0l4hN8BexpvmSMN9oA9EagjnhnDpNsRdWCfjwa4mn/HyBXO9yhQP6A== - dependencies: - "@babel/helper-annotate-as-pure" "^7.14.5" - "@babel/helper-wrap-function" "^7.14.5" - "@babel/types" "^7.14.5" - -"@babel/helper-replace-supers@^7.14.5", "@babel/helper-replace-supers@^7.15.0": - version "7.15.0" - resolved "https://registry.yarnpkg.com/@babel/helper-replace-supers/-/helper-replace-supers-7.15.0.tgz#ace07708f5bf746bf2e6ba99572cce79b5d4e7f4" - integrity sha512-6O+eWrhx+HEra/uJnifCwhwMd6Bp5+ZfZeJwbqUTuqkhIT6YcRhiZCOOFChRypOIe0cV46kFrRBlm+t5vHCEaA== - dependencies: - "@babel/helper-member-expression-to-functions" "^7.15.0" - "@babel/helper-optimise-call-expression" "^7.14.5" - "@babel/traverse" "^7.15.0" - "@babel/types" "^7.15.0" - -"@babel/helper-simple-access@^7.14.8": - version "7.14.8" - resolved "https://registry.yarnpkg.com/@babel/helper-simple-access/-/helper-simple-access-7.14.8.tgz#82e1fec0644a7e775c74d305f212c39f8fe73924" - integrity sha512-TrFN4RHh9gnWEU+s7JloIho2T76GPwRHhdzOWLqTrMnlas8T9O7ec+oEDNsRXndOmru9ymH9DFrEOxpzPoSbdg== - dependencies: - "@babel/types" "^7.14.8" - -"@babel/helper-skip-transparent-expression-wrappers@^7.14.5": - version "7.14.5" - resolved "https://registry.yarnpkg.com/@babel/helper-skip-transparent-expression-wrappers/-/helper-skip-transparent-expression-wrappers-7.14.5.tgz#96f486ac050ca9f44b009fbe5b7d394cab3a0ee4" - integrity sha512-dmqZB7mrb94PZSAOYtr+ZN5qt5owZIAgqtoTuqiFbHFtxgEcmQlRJVI+bO++fciBunXtB6MK7HrzrfcAzIz2NQ== - dependencies: - "@babel/types" "^7.14.5" - -"@babel/helper-split-export-declaration@^7.14.5": - version "7.14.5" - resolved "https://registry.yarnpkg.com/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.14.5.tgz#22b23a54ef51c2b7605d851930c1976dd0bc693a" - integrity sha512-hprxVPu6e5Kdp2puZUmvOGjaLv9TCe58E/Fl6hRq4YiVQxIcNvuq6uTM2r1mT/oPskuS9CgR+I94sqAYv0NGKA== - dependencies: - "@babel/types" "^7.14.5" - -"@babel/helper-validator-identifier@^7.14.5", "@babel/helper-validator-identifier@^7.14.9": - version "7.14.9" - resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.14.9.tgz#6654d171b2024f6d8ee151bf2509699919131d48" - integrity sha512-pQYxPY0UP6IHISRitNe8bsijHex4TWZXi2HwKVsjPiltzlhse2znVcm9Ace510VT1kxIHjGJCZZQBX2gJDbo0g== - -"@babel/helper-validator-option@^7.14.5": - version "7.14.5" - resolved "https://registry.yarnpkg.com/@babel/helper-validator-option/-/helper-validator-option-7.14.5.tgz#6e72a1fff18d5dfcb878e1e62f1a021c4b72d5a3" - integrity sha512-OX8D5eeX4XwcroVW45NMvoYaIuFI+GQpA2a8Gi+X/U/cDUIRsV37qQfF905F0htTRCREQIB4KqPeaveRJUl3Ow== - -"@babel/helper-wrap-function@^7.14.5": - version "7.14.5" - resolved "https://registry.yarnpkg.com/@babel/helper-wrap-function/-/helper-wrap-function-7.14.5.tgz#5919d115bf0fe328b8a5d63bcb610f51601f2bff" - integrity sha512-YEdjTCq+LNuNS1WfxsDCNpgXkJaIyqco6DAelTUjT4f2KIWC1nBcaCaSdHTBqQVLnTBexBcVcFhLSU1KnYuePQ== - dependencies: - "@babel/helper-function-name" "^7.14.5" - "@babel/template" "^7.14.5" - "@babel/traverse" "^7.14.5" - "@babel/types" "^7.14.5" - -"@babel/helpers@^7.14.8": - version "7.14.8" - resolved "https://registry.yarnpkg.com/@babel/helpers/-/helpers-7.14.8.tgz#839f88f463025886cff7f85a35297007e2da1b77" - integrity sha512-ZRDmI56pnV+p1dH6d+UN6GINGz7Krps3+270qqI9UJ4wxYThfAIcI5i7j5vXC4FJ3Wap+S9qcebxeYiqn87DZw== - dependencies: - "@babel/template" "^7.14.5" - "@babel/traverse" "^7.14.8" - "@babel/types" "^7.14.8" - -"@babel/highlight@^7.14.5": - version "7.14.5" - resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.14.5.tgz#6861a52f03966405001f6aa534a01a24d99e8cd9" - integrity sha512-qf9u2WFWVV0MppaL877j2dBtQIDgmidgjGk5VIMw3OadXvYaXn66U1BFlH2t4+t3i+8PhedppRv+i40ABzd+gg== - dependencies: - "@babel/helper-validator-identifier" "^7.14.5" - chalk "^2.0.0" - js-tokens "^4.0.0" - -"@babel/parser@^7.14.5", "@babel/parser@^7.15.0": - version "7.15.0" - resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.15.0.tgz#b6d6e29058ca369127b0eeca2a1c4b5794f1b6b9" - integrity sha512-0v7oNOjr6YT9Z2RAOTv4T9aP+ubfx4Q/OhVtAet7PFDt0t9Oy6Jn+/rfC6b8HJ5zEqrQCiMxJfgtHpmIminmJQ== - -"@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining@^7.14.5": - version "7.14.5" - resolved "https://registry.yarnpkg.com/@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining/-/plugin-bugfix-v8-spread-parameters-in-optional-chaining-7.14.5.tgz#4b467302e1548ed3b1be43beae2cc9cf45e0bb7e" - integrity sha512-ZoJS2XCKPBfTmL122iP6NM9dOg+d4lc9fFk3zxc8iDjvt8Pk4+TlsHSKhIPf6X+L5ORCdBzqMZDjL/WHj7WknQ== - dependencies: - "@babel/helper-plugin-utils" "^7.14.5" - "@babel/helper-skip-transparent-expression-wrappers" "^7.14.5" - "@babel/plugin-proposal-optional-chaining" "^7.14.5" - -"@babel/plugin-proposal-async-generator-functions@^7.14.9": - version "7.14.9" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-async-generator-functions/-/plugin-proposal-async-generator-functions-7.14.9.tgz#7028dc4fa21dc199bbacf98b39bab1267d0eaf9a" - integrity sha512-d1lnh+ZnKrFKwtTYdw320+sQWCTwgkB9fmUhNXRADA4akR6wLjaruSGnIEUjpt9HCOwTr4ynFTKu19b7rFRpmw== - dependencies: - "@babel/helper-plugin-utils" "^7.14.5" - "@babel/helper-remap-async-to-generator" "^7.14.5" - "@babel/plugin-syntax-async-generators" "^7.8.4" - -"@babel/plugin-proposal-class-properties@^7.14.5": - version "7.14.5" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-class-properties/-/plugin-proposal-class-properties-7.14.5.tgz#40d1ee140c5b1e31a350f4f5eed945096559b42e" - integrity sha512-q/PLpv5Ko4dVc1LYMpCY7RVAAO4uk55qPwrIuJ5QJ8c6cVuAmhu7I/49JOppXL6gXf7ZHzpRVEUZdYoPLM04Gg== - dependencies: - "@babel/helper-create-class-features-plugin" "^7.14.5" - "@babel/helper-plugin-utils" "^7.14.5" - -"@babel/plugin-proposal-class-static-block@^7.14.5": - version "7.14.5" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-class-static-block/-/plugin-proposal-class-static-block-7.14.5.tgz#158e9e10d449c3849ef3ecde94a03d9f1841b681" - integrity sha512-KBAH5ksEnYHCegqseI5N9skTdxgJdmDoAOc0uXa+4QMYKeZD0w5IARh4FMlTNtaHhbB8v+KzMdTgxMMzsIy6Yg== - dependencies: - "@babel/helper-create-class-features-plugin" "^7.14.5" - "@babel/helper-plugin-utils" "^7.14.5" - "@babel/plugin-syntax-class-static-block" "^7.14.5" - -"@babel/plugin-proposal-dynamic-import@^7.14.5": - version "7.14.5" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-dynamic-import/-/plugin-proposal-dynamic-import-7.14.5.tgz#0c6617df461c0c1f8fff3b47cd59772360101d2c" - integrity sha512-ExjiNYc3HDN5PXJx+bwC50GIx/KKanX2HiggnIUAYedbARdImiCU4RhhHfdf0Kd7JNXGpsBBBCOm+bBVy3Gb0g== - dependencies: - "@babel/helper-plugin-utils" "^7.14.5" - "@babel/plugin-syntax-dynamic-import" "^7.8.3" - -"@babel/plugin-proposal-export-namespace-from@^7.14.5": - version "7.14.5" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-export-namespace-from/-/plugin-proposal-export-namespace-from-7.14.5.tgz#dbad244310ce6ccd083072167d8cea83a52faf76" - integrity sha512-g5POA32bXPMmSBu5Dx/iZGLGnKmKPc5AiY7qfZgurzrCYgIztDlHFbznSNCoQuv57YQLnQfaDi7dxCtLDIdXdA== - dependencies: - "@babel/helper-plugin-utils" "^7.14.5" - "@babel/plugin-syntax-export-namespace-from" "^7.8.3" - -"@babel/plugin-proposal-json-strings@^7.14.5": - version "7.14.5" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-json-strings/-/plugin-proposal-json-strings-7.14.5.tgz#38de60db362e83a3d8c944ac858ddf9f0c2239eb" - integrity sha512-NSq2fczJYKVRIsUJyNxrVUMhB27zb7N7pOFGQOhBKJrChbGcgEAqyZrmZswkPk18VMurEeJAaICbfm57vUeTbQ== - dependencies: - "@babel/helper-plugin-utils" "^7.14.5" - "@babel/plugin-syntax-json-strings" "^7.8.3" - -"@babel/plugin-proposal-logical-assignment-operators@^7.14.5": - version "7.14.5" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-logical-assignment-operators/-/plugin-proposal-logical-assignment-operators-7.14.5.tgz#6e6229c2a99b02ab2915f82571e0cc646a40c738" - integrity sha512-YGn2AvZAo9TwyhlLvCCWxD90Xq8xJ4aSgaX3G5D/8DW94L8aaT+dS5cSP+Z06+rCJERGSr9GxMBZ601xoc2taw== - dependencies: - "@babel/helper-plugin-utils" "^7.14.5" - "@babel/plugin-syntax-logical-assignment-operators" "^7.10.4" - -"@babel/plugin-proposal-nullish-coalescing-operator@^7.14.5": - version "7.14.5" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-nullish-coalescing-operator/-/plugin-proposal-nullish-coalescing-operator-7.14.5.tgz#ee38589ce00e2cc59b299ec3ea406fcd3a0fdaf6" - integrity sha512-gun/SOnMqjSb98Nkaq2rTKMwervfdAoz6NphdY0vTfuzMfryj+tDGb2n6UkDKwez+Y8PZDhE3D143v6Gepp4Hg== - dependencies: - "@babel/helper-plugin-utils" "^7.14.5" - "@babel/plugin-syntax-nullish-coalescing-operator" "^7.8.3" - -"@babel/plugin-proposal-numeric-separator@^7.14.5": - version "7.14.5" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-numeric-separator/-/plugin-proposal-numeric-separator-7.14.5.tgz#83631bf33d9a51df184c2102a069ac0c58c05f18" - integrity sha512-yiclALKe0vyZRZE0pS6RXgjUOt87GWv6FYa5zqj15PvhOGFO69R5DusPlgK/1K5dVnCtegTiWu9UaBSrLLJJBg== - dependencies: - "@babel/helper-plugin-utils" "^7.14.5" - "@babel/plugin-syntax-numeric-separator" "^7.10.4" - -"@babel/plugin-proposal-object-rest-spread@^7.14.7": - version "7.14.7" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-object-rest-spread/-/plugin-proposal-object-rest-spread-7.14.7.tgz#5920a2b3df7f7901df0205974c0641b13fd9d363" - integrity sha512-082hsZz+sVabfmDWo1Oct1u1AgbKbUAyVgmX4otIc7bdsRgHBXwTwb3DpDmD4Eyyx6DNiuz5UAATT655k+kL5g== - dependencies: - "@babel/compat-data" "^7.14.7" - "@babel/helper-compilation-targets" "^7.14.5" - "@babel/helper-plugin-utils" "^7.14.5" - "@babel/plugin-syntax-object-rest-spread" "^7.8.3" - "@babel/plugin-transform-parameters" "^7.14.5" - -"@babel/plugin-proposal-optional-catch-binding@^7.14.5": - version "7.14.5" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-optional-catch-binding/-/plugin-proposal-optional-catch-binding-7.14.5.tgz#939dd6eddeff3a67fdf7b3f044b5347262598c3c" - integrity sha512-3Oyiixm0ur7bzO5ybNcZFlmVsygSIQgdOa7cTfOYCMY+wEPAYhZAJxi3mixKFCTCKUhQXuCTtQ1MzrpL3WT8ZQ== - dependencies: - "@babel/helper-plugin-utils" "^7.14.5" - "@babel/plugin-syntax-optional-catch-binding" "^7.8.3" - -"@babel/plugin-proposal-optional-chaining@^7.14.5": - version "7.14.5" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-optional-chaining/-/plugin-proposal-optional-chaining-7.14.5.tgz#fa83651e60a360e3f13797eef00b8d519695b603" - integrity sha512-ycz+VOzo2UbWNI1rQXxIuMOzrDdHGrI23fRiz/Si2R4kv2XZQ1BK8ccdHwehMKBlcH/joGW/tzrUmo67gbJHlQ== - dependencies: - "@babel/helper-plugin-utils" "^7.14.5" - "@babel/helper-skip-transparent-expression-wrappers" "^7.14.5" - "@babel/plugin-syntax-optional-chaining" "^7.8.3" - -"@babel/plugin-proposal-private-methods@^7.14.5": - version "7.14.5" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-private-methods/-/plugin-proposal-private-methods-7.14.5.tgz#37446495996b2945f30f5be5b60d5e2aa4f5792d" - integrity sha512-838DkdUA1u+QTCplatfq4B7+1lnDa/+QMI89x5WZHBcnNv+47N8QEj2k9I2MUU9xIv8XJ4XvPCviM/Dj7Uwt9g== - dependencies: - "@babel/helper-create-class-features-plugin" "^7.14.5" - "@babel/helper-plugin-utils" "^7.14.5" - -"@babel/plugin-proposal-private-property-in-object@^7.14.5": - version "7.14.5" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-private-property-in-object/-/plugin-proposal-private-property-in-object-7.14.5.tgz#9f65a4d0493a940b4c01f8aa9d3f1894a587f636" - integrity sha512-62EyfyA3WA0mZiF2e2IV9mc9Ghwxcg8YTu8BS4Wss4Y3PY725OmS9M0qLORbJwLqFtGh+jiE4wAmocK2CTUK2Q== - dependencies: - "@babel/helper-annotate-as-pure" "^7.14.5" - "@babel/helper-create-class-features-plugin" "^7.14.5" - "@babel/helper-plugin-utils" "^7.14.5" - "@babel/plugin-syntax-private-property-in-object" "^7.14.5" - -"@babel/plugin-proposal-unicode-property-regex@^7.14.5", "@babel/plugin-proposal-unicode-property-regex@^7.4.4": - version "7.14.5" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-unicode-property-regex/-/plugin-proposal-unicode-property-regex-7.14.5.tgz#0f95ee0e757a5d647f378daa0eca7e93faa8bbe8" - integrity sha512-6axIeOU5LnY471KenAB9vI8I5j7NQ2d652hIYwVyRfgaZT5UpiqFKCuVXCDMSrU+3VFafnu2c5m3lrWIlr6A5Q== - dependencies: - "@babel/helper-create-regexp-features-plugin" "^7.14.5" - "@babel/helper-plugin-utils" "^7.14.5" - -"@babel/plugin-syntax-async-generators@^7.8.4": - version "7.8.4" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-async-generators/-/plugin-syntax-async-generators-7.8.4.tgz#a983fb1aeb2ec3f6ed042a210f640e90e786fe0d" - integrity sha512-tycmZxkGfZaxhMRbXlPXuVFpdWlXpir2W4AMhSJgRKzk/eDlIXOhb2LHWoLpDF7TEHylV5zNhykX6KAgHJmTNw== - dependencies: - "@babel/helper-plugin-utils" "^7.8.0" - -"@babel/plugin-syntax-class-properties@^7.12.13": - version "7.12.13" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-class-properties/-/plugin-syntax-class-properties-7.12.13.tgz#b5c987274c4a3a82b89714796931a6b53544ae10" - integrity sha512-fm4idjKla0YahUNgFNLCB0qySdsoPiZP3iQE3rky0mBUtMZ23yDJ9SJdg6dXTSDnulOVqiF3Hgr9nbXvXTQZYA== - dependencies: - "@babel/helper-plugin-utils" "^7.12.13" - -"@babel/plugin-syntax-class-static-block@^7.14.5": - version "7.14.5" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-class-static-block/-/plugin-syntax-class-static-block-7.14.5.tgz#195df89b146b4b78b3bf897fd7a257c84659d406" - integrity sha512-b+YyPmr6ldyNnM6sqYeMWE+bgJcJpO6yS4QD7ymxgH34GBPNDM/THBh8iunyvKIZztiwLH4CJZ0RxTk9emgpjw== - dependencies: - "@babel/helper-plugin-utils" "^7.14.5" - -"@babel/plugin-syntax-dynamic-import@^7.8.3": - version "7.8.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-dynamic-import/-/plugin-syntax-dynamic-import-7.8.3.tgz#62bf98b2da3cd21d626154fc96ee5b3cb68eacb3" - integrity sha512-5gdGbFon+PszYzqs83S3E5mpi7/y/8M9eC90MRTZfduQOYW76ig6SOSPNe41IG5LoP3FGBn2N0RjVDSQiS94kQ== - dependencies: - "@babel/helper-plugin-utils" "^7.8.0" - -"@babel/plugin-syntax-export-namespace-from@^7.8.3": - version "7.8.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-export-namespace-from/-/plugin-syntax-export-namespace-from-7.8.3.tgz#028964a9ba80dbc094c915c487ad7c4e7a66465a" - integrity sha512-MXf5laXo6c1IbEbegDmzGPwGNTsHZmEy6QGznu5Sh2UCWvueywb2ee+CCE4zQiZstxU9BMoQO9i6zUFSY0Kj0Q== - dependencies: - "@babel/helper-plugin-utils" "^7.8.3" - -"@babel/plugin-syntax-json-strings@^7.8.3": - version "7.8.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-json-strings/-/plugin-syntax-json-strings-7.8.3.tgz#01ca21b668cd8218c9e640cb6dd88c5412b2c96a" - integrity sha512-lY6kdGpWHvjoe2vk4WrAapEuBR69EMxZl+RoGRhrFGNYVK8mOPAW8VfbT/ZgrFbXlDNiiaxQnAtgVCZ6jv30EA== - dependencies: - "@babel/helper-plugin-utils" "^7.8.0" - -"@babel/plugin-syntax-logical-assignment-operators@^7.10.4": - version "7.10.4" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-logical-assignment-operators/-/plugin-syntax-logical-assignment-operators-7.10.4.tgz#ca91ef46303530448b906652bac2e9fe9941f699" - integrity sha512-d8waShlpFDinQ5MtvGU9xDAOzKH47+FFoney2baFIoMr952hKOLp1HR7VszoZvOsV/4+RRszNY7D17ba0te0ig== - dependencies: - "@babel/helper-plugin-utils" "^7.10.4" - -"@babel/plugin-syntax-nullish-coalescing-operator@^7.8.3": - version "7.8.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-nullish-coalescing-operator/-/plugin-syntax-nullish-coalescing-operator-7.8.3.tgz#167ed70368886081f74b5c36c65a88c03b66d1a9" - integrity sha512-aSff4zPII1u2QD7y+F8oDsz19ew4IGEJg9SVW+bqwpwtfFleiQDMdzA/R+UlWDzfnHFCxxleFT0PMIrR36XLNQ== - dependencies: - "@babel/helper-plugin-utils" "^7.8.0" - -"@babel/plugin-syntax-numeric-separator@^7.10.4": - version "7.10.4" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-numeric-separator/-/plugin-syntax-numeric-separator-7.10.4.tgz#b9b070b3e33570cd9fd07ba7fa91c0dd37b9af97" - integrity sha512-9H6YdfkcK/uOnY/K7/aA2xpzaAgkQn37yzWUMRK7OaPOqOpGS1+n0H5hxT9AUw9EsSjPW8SVyMJwYRtWs3X3ug== - dependencies: - "@babel/helper-plugin-utils" "^7.10.4" - -"@babel/plugin-syntax-object-rest-spread@^7.8.3": - version "7.8.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-object-rest-spread/-/plugin-syntax-object-rest-spread-7.8.3.tgz#60e225edcbd98a640332a2e72dd3e66f1af55871" - integrity sha512-XoqMijGZb9y3y2XskN+P1wUGiVwWZ5JmoDRwx5+3GmEplNyVM2s2Dg8ILFQm8rWM48orGy5YpI5Bl8U1y7ydlA== - dependencies: - "@babel/helper-plugin-utils" "^7.8.0" - -"@babel/plugin-syntax-optional-catch-binding@^7.8.3": - version "7.8.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-optional-catch-binding/-/plugin-syntax-optional-catch-binding-7.8.3.tgz#6111a265bcfb020eb9efd0fdfd7d26402b9ed6c1" - integrity sha512-6VPD0Pc1lpTqw0aKoeRTMiB+kWhAoT24PA+ksWSBrFtl5SIRVpZlwN3NNPQjehA2E/91FV3RjLWoVTglWcSV3Q== - dependencies: - "@babel/helper-plugin-utils" "^7.8.0" - -"@babel/plugin-syntax-optional-chaining@^7.8.3": - version "7.8.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-optional-chaining/-/plugin-syntax-optional-chaining-7.8.3.tgz#4f69c2ab95167e0180cd5336613f8c5788f7d48a" - integrity sha512-KoK9ErH1MBlCPxV0VANkXW2/dw4vlbGDrFgz8bmUsBGYkFRcbRwMh6cIJubdPrkxRwuGdtCk0v/wPTKbQgBjkg== - dependencies: - "@babel/helper-plugin-utils" "^7.8.0" - -"@babel/plugin-syntax-private-property-in-object@^7.14.5": - version "7.14.5" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-private-property-in-object/-/plugin-syntax-private-property-in-object-7.14.5.tgz#0dc6671ec0ea22b6e94a1114f857970cd39de1ad" - integrity sha512-0wVnp9dxJ72ZUJDV27ZfbSj6iHLoytYZmh3rFcxNnvsJF3ktkzLDZPy/mA17HGsaQT3/DQsWYX1f1QGWkCoVUg== - dependencies: - "@babel/helper-plugin-utils" "^7.14.5" - -"@babel/plugin-syntax-top-level-await@^7.14.5": - version "7.14.5" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-top-level-await/-/plugin-syntax-top-level-await-7.14.5.tgz#c1cfdadc35a646240001f06138247b741c34d94c" - integrity sha512-hx++upLv5U1rgYfwe1xBQUhRmU41NEvpUvrp8jkrSCdvGSnM5/qdRMtylJ6PG5OFkBaHkbTAKTnd3/YyESRHFw== - dependencies: - "@babel/helper-plugin-utils" "^7.14.5" - -"@babel/plugin-transform-arrow-functions@^7.14.5": - version "7.14.5" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-arrow-functions/-/plugin-transform-arrow-functions-7.14.5.tgz#f7187d9588a768dd080bf4c9ffe117ea62f7862a" - integrity sha512-KOnO0l4+tD5IfOdi4x8C1XmEIRWUjNRV8wc6K2vz/3e8yAOoZZvsRXRRIF/yo/MAOFb4QjtAw9xSxMXbSMRy8A== - dependencies: - "@babel/helper-plugin-utils" "^7.14.5" - -"@babel/plugin-transform-async-to-generator@^7.14.5": - version "7.14.5" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-async-to-generator/-/plugin-transform-async-to-generator-7.14.5.tgz#72c789084d8f2094acb945633943ef8443d39e67" - integrity sha512-szkbzQ0mNk0rpu76fzDdqSyPu0MuvpXgC+6rz5rpMb5OIRxdmHfQxrktL8CYolL2d8luMCZTR0DpIMIdL27IjA== - dependencies: - "@babel/helper-module-imports" "^7.14.5" - "@babel/helper-plugin-utils" "^7.14.5" - "@babel/helper-remap-async-to-generator" "^7.14.5" - -"@babel/plugin-transform-block-scoped-functions@^7.14.5": - version "7.14.5" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-block-scoped-functions/-/plugin-transform-block-scoped-functions-7.14.5.tgz#e48641d999d4bc157a67ef336aeb54bc44fd3ad4" - integrity sha512-dtqWqdWZ5NqBX3KzsVCWfQI3A53Ft5pWFCT2eCVUftWZgjc5DpDponbIF1+c+7cSGk2wN0YK7HGL/ezfRbpKBQ== - dependencies: - "@babel/helper-plugin-utils" "^7.14.5" - -"@babel/plugin-transform-block-scoping@^7.14.5": - version "7.14.5" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-block-scoping/-/plugin-transform-block-scoping-7.14.5.tgz#8cc63e61e50f42e078e6f09be775a75f23ef9939" - integrity sha512-LBYm4ZocNgoCqyxMLoOnwpsmQ18HWTQvql64t3GvMUzLQrNoV1BDG0lNftC8QKYERkZgCCT/7J5xWGObGAyHDw== - dependencies: - "@babel/helper-plugin-utils" "^7.14.5" - -"@babel/plugin-transform-classes@^7.14.9": - version "7.14.9" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-classes/-/plugin-transform-classes-7.14.9.tgz#2a391ffb1e5292710b00f2e2c210e1435e7d449f" - integrity sha512-NfZpTcxU3foGWbl4wxmZ35mTsYJy8oQocbeIMoDAGGFarAmSQlL+LWMkDx/tj6pNotpbX3rltIA4dprgAPOq5A== - dependencies: - "@babel/helper-annotate-as-pure" "^7.14.5" - "@babel/helper-function-name" "^7.14.5" - "@babel/helper-optimise-call-expression" "^7.14.5" - "@babel/helper-plugin-utils" "^7.14.5" - "@babel/helper-replace-supers" "^7.14.5" - "@babel/helper-split-export-declaration" "^7.14.5" - globals "^11.1.0" - -"@babel/plugin-transform-computed-properties@^7.14.5": - version "7.14.5" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-computed-properties/-/plugin-transform-computed-properties-7.14.5.tgz#1b9d78987420d11223d41195461cc43b974b204f" - integrity sha512-pWM+E4283UxaVzLb8UBXv4EIxMovU4zxT1OPnpHJcmnvyY9QbPPTKZfEj31EUvG3/EQRbYAGaYEUZ4yWOBC2xg== - dependencies: - "@babel/helper-plugin-utils" "^7.14.5" - -"@babel/plugin-transform-destructuring@^7.14.7": - version "7.14.7" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-destructuring/-/plugin-transform-destructuring-7.14.7.tgz#0ad58ed37e23e22084d109f185260835e5557576" - integrity sha512-0mDE99nK+kVh3xlc5vKwB6wnP9ecuSj+zQCa/n0voENtP/zymdT4HH6QEb65wjjcbqr1Jb/7z9Qp7TF5FtwYGw== - dependencies: - "@babel/helper-plugin-utils" "^7.14.5" - -"@babel/plugin-transform-dotall-regex@^7.14.5", "@babel/plugin-transform-dotall-regex@^7.4.4": - version "7.14.5" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-dotall-regex/-/plugin-transform-dotall-regex-7.14.5.tgz#2f6bf76e46bdf8043b4e7e16cf24532629ba0c7a" - integrity sha512-loGlnBdj02MDsFaHhAIJzh7euK89lBrGIdM9EAtHFo6xKygCUGuuWe07o1oZVk287amtW1n0808sQM99aZt3gw== - dependencies: - "@babel/helper-create-regexp-features-plugin" "^7.14.5" - "@babel/helper-plugin-utils" "^7.14.5" - -"@babel/plugin-transform-duplicate-keys@^7.14.5": - version "7.14.5" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-duplicate-keys/-/plugin-transform-duplicate-keys-7.14.5.tgz#365a4844881bdf1501e3a9f0270e7f0f91177954" - integrity sha512-iJjbI53huKbPDAsJ8EmVmvCKeeq21bAze4fu9GBQtSLqfvzj2oRuHVx4ZkDwEhg1htQ+5OBZh/Ab0XDf5iBZ7A== - dependencies: - "@babel/helper-plugin-utils" "^7.14.5" - -"@babel/plugin-transform-exponentiation-operator@^7.14.5": - version "7.14.5" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-exponentiation-operator/-/plugin-transform-exponentiation-operator-7.14.5.tgz#5154b8dd6a3dfe6d90923d61724bd3deeb90b493" - integrity sha512-jFazJhMBc9D27o9jDnIE5ZErI0R0m7PbKXVq77FFvqFbzvTMuv8jaAwLZ5PviOLSFttqKIW0/wxNSDbjLk0tYA== - dependencies: - "@babel/helper-builder-binary-assignment-operator-visitor" "^7.14.5" - "@babel/helper-plugin-utils" "^7.14.5" - -"@babel/plugin-transform-for-of@^7.14.5": - version "7.14.5" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-for-of/-/plugin-transform-for-of-7.14.5.tgz#dae384613de8f77c196a8869cbf602a44f7fc0eb" - integrity sha512-CfmqxSUZzBl0rSjpoQSFoR9UEj3HzbGuGNL21/iFTmjb5gFggJp3ph0xR1YBhexmLoKRHzgxuFvty2xdSt6gTA== - dependencies: - "@babel/helper-plugin-utils" "^7.14.5" - -"@babel/plugin-transform-function-name@^7.14.5": - version "7.14.5" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-function-name/-/plugin-transform-function-name-7.14.5.tgz#e81c65ecb900746d7f31802f6bed1f52d915d6f2" - integrity sha512-vbO6kv0fIzZ1GpmGQuvbwwm+O4Cbm2NrPzwlup9+/3fdkuzo1YqOZcXw26+YUJB84Ja7j9yURWposEHLYwxUfQ== - dependencies: - "@babel/helper-function-name" "^7.14.5" - "@babel/helper-plugin-utils" "^7.14.5" - -"@babel/plugin-transform-literals@^7.14.5": - version "7.14.5" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-literals/-/plugin-transform-literals-7.14.5.tgz#41d06c7ff5d4d09e3cf4587bd3ecf3930c730f78" - integrity sha512-ql33+epql2F49bi8aHXxvLURHkxJbSmMKl9J5yHqg4PLtdE6Uc48CH1GS6TQvZ86eoB/ApZXwm7jlA+B3kra7A== - dependencies: - "@babel/helper-plugin-utils" "^7.14.5" - -"@babel/plugin-transform-member-expression-literals@^7.14.5": - version "7.14.5" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-member-expression-literals/-/plugin-transform-member-expression-literals-7.14.5.tgz#b39cd5212a2bf235a617d320ec2b48bcc091b8a7" - integrity sha512-WkNXxH1VXVTKarWFqmso83xl+2V3Eo28YY5utIkbsmXoItO8Q3aZxN4BTS2k0hz9dGUloHK26mJMyQEYfkn/+Q== - dependencies: - "@babel/helper-plugin-utils" "^7.14.5" - -"@babel/plugin-transform-modules-amd@^7.14.5": - version "7.14.5" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-amd/-/plugin-transform-modules-amd-7.14.5.tgz#4fd9ce7e3411cb8b83848480b7041d83004858f7" - integrity sha512-3lpOU8Vxmp3roC4vzFpSdEpGUWSMsHFreTWOMMLzel2gNGfHE5UWIh/LN6ghHs2xurUp4jRFYMUIZhuFbody1g== - dependencies: - "@babel/helper-module-transforms" "^7.14.5" - "@babel/helper-plugin-utils" "^7.14.5" - babel-plugin-dynamic-import-node "^2.3.3" - -"@babel/plugin-transform-modules-commonjs@^7.15.0": - version "7.15.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.15.0.tgz#3305896e5835f953b5cdb363acd9e8c2219a5281" - integrity sha512-3H/R9s8cXcOGE8kgMlmjYYC9nqr5ELiPkJn4q0mypBrjhYQoc+5/Maq69vV4xRPWnkzZuwJPf5rArxpB/35Cig== - dependencies: - "@babel/helper-module-transforms" "^7.15.0" - "@babel/helper-plugin-utils" "^7.14.5" - "@babel/helper-simple-access" "^7.14.8" - babel-plugin-dynamic-import-node "^2.3.3" - -"@babel/plugin-transform-modules-systemjs@^7.14.5": - version "7.14.5" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-systemjs/-/plugin-transform-modules-systemjs-7.14.5.tgz#c75342ef8b30dcde4295d3401aae24e65638ed29" - integrity sha512-mNMQdvBEE5DcMQaL5LbzXFMANrQjd2W7FPzg34Y4yEz7dBgdaC+9B84dSO+/1Wba98zoDbInctCDo4JGxz1VYA== - dependencies: - "@babel/helper-hoist-variables" "^7.14.5" - "@babel/helper-module-transforms" "^7.14.5" - "@babel/helper-plugin-utils" "^7.14.5" - "@babel/helper-validator-identifier" "^7.14.5" - babel-plugin-dynamic-import-node "^2.3.3" - -"@babel/plugin-transform-modules-umd@^7.14.5": - version "7.14.5" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-umd/-/plugin-transform-modules-umd-7.14.5.tgz#fb662dfee697cce274a7cda525190a79096aa6e0" - integrity sha512-RfPGoagSngC06LsGUYyM9QWSXZ8MysEjDJTAea1lqRjNECE3y0qIJF/qbvJxc4oA4s99HumIMdXOrd+TdKaAAA== - dependencies: - "@babel/helper-module-transforms" "^7.14.5" - "@babel/helper-plugin-utils" "^7.14.5" - -"@babel/plugin-transform-named-capturing-groups-regex@^7.14.9": - version "7.14.9" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-named-capturing-groups-regex/-/plugin-transform-named-capturing-groups-regex-7.14.9.tgz#c68f5c5d12d2ebaba3762e57c2c4f6347a46e7b2" - integrity sha512-l666wCVYO75mlAtGFfyFwnWmIXQm3kSH0C3IRnJqWcZbWkoihyAdDhFm2ZWaxWTqvBvhVFfJjMRQ0ez4oN1yYA== - dependencies: - "@babel/helper-create-regexp-features-plugin" "^7.14.5" - -"@babel/plugin-transform-new-target@^7.14.5": - version "7.14.5" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-new-target/-/plugin-transform-new-target-7.14.5.tgz#31bdae8b925dc84076ebfcd2a9940143aed7dbf8" - integrity sha512-Nx054zovz6IIRWEB49RDRuXGI4Gy0GMgqG0cII9L3MxqgXz/+rgII+RU58qpo4g7tNEx1jG7rRVH4ihZoP4esQ== - dependencies: - "@babel/helper-plugin-utils" "^7.14.5" - -"@babel/plugin-transform-object-super@^7.14.5": - version "7.14.5" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-object-super/-/plugin-transform-object-super-7.14.5.tgz#d0b5faeac9e98597a161a9cf78c527ed934cdc45" - integrity sha512-MKfOBWzK0pZIrav9z/hkRqIk/2bTv9qvxHzPQc12RcVkMOzpIKnFCNYJip00ssKWYkd8Sf5g0Wr7pqJ+cmtuFg== - dependencies: - "@babel/helper-plugin-utils" "^7.14.5" - "@babel/helper-replace-supers" "^7.14.5" - -"@babel/plugin-transform-parameters@^7.14.5": - version "7.14.5" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-parameters/-/plugin-transform-parameters-7.14.5.tgz#49662e86a1f3ddccac6363a7dfb1ff0a158afeb3" - integrity sha512-Tl7LWdr6HUxTmzQtzuU14SqbgrSKmaR77M0OKyq4njZLQTPfOvzblNKyNkGwOfEFCEx7KeYHQHDI0P3F02IVkA== - dependencies: - "@babel/helper-plugin-utils" "^7.14.5" - -"@babel/plugin-transform-property-literals@^7.14.5": - version "7.14.5" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-property-literals/-/plugin-transform-property-literals-7.14.5.tgz#0ddbaa1f83db3606f1cdf4846fa1dfb473458b34" - integrity sha512-r1uilDthkgXW8Z1vJz2dKYLV1tuw2xsbrp3MrZmD99Wh9vsfKoob+JTgri5VUb/JqyKRXotlOtwgu4stIYCmnw== - dependencies: - "@babel/helper-plugin-utils" "^7.14.5" - -"@babel/plugin-transform-regenerator@^7.14.5": - version "7.14.5" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-regenerator/-/plugin-transform-regenerator-7.14.5.tgz#9676fd5707ed28f522727c5b3c0aa8544440b04f" - integrity sha512-NVIY1W3ITDP5xQl50NgTKlZ0GrotKtLna08/uGY6ErQt6VEQZXla86x/CTddm5gZdcr+5GSsvMeTmWA5Ii6pkg== - dependencies: - regenerator-transform "^0.14.2" - -"@babel/plugin-transform-reserved-words@^7.14.5": - version "7.14.5" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-reserved-words/-/plugin-transform-reserved-words-7.14.5.tgz#c44589b661cfdbef8d4300dcc7469dffa92f8304" - integrity sha512-cv4F2rv1nD4qdexOGsRQXJrOcyb5CrgjUH9PKrrtyhSDBNWGxd0UIitjyJiWagS+EbUGjG++22mGH1Pub8D6Vg== - dependencies: - "@babel/helper-plugin-utils" "^7.14.5" - -"@babel/plugin-transform-shorthand-properties@^7.14.5": - version "7.14.5" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-shorthand-properties/-/plugin-transform-shorthand-properties-7.14.5.tgz#97f13855f1409338d8cadcbaca670ad79e091a58" - integrity sha512-xLucks6T1VmGsTB+GWK5Pl9Jl5+nRXD1uoFdA5TSO6xtiNjtXTjKkmPdFXVLGlK5A2/or/wQMKfmQ2Y0XJfn5g== - dependencies: - "@babel/helper-plugin-utils" "^7.14.5" - -"@babel/plugin-transform-spread@^7.14.6": - version "7.14.6" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-spread/-/plugin-transform-spread-7.14.6.tgz#6bd40e57fe7de94aa904851963b5616652f73144" - integrity sha512-Zr0x0YroFJku7n7+/HH3A2eIrGMjbmAIbJSVv0IZ+t3U2WUQUA64S/oeied2e+MaGSjmt4alzBCsK9E8gh+fag== - dependencies: - "@babel/helper-plugin-utils" "^7.14.5" - "@babel/helper-skip-transparent-expression-wrappers" "^7.14.5" - -"@babel/plugin-transform-sticky-regex@^7.14.5": - version "7.14.5" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-sticky-regex/-/plugin-transform-sticky-regex-7.14.5.tgz#5b617542675e8b7761294381f3c28c633f40aeb9" - integrity sha512-Z7F7GyvEMzIIbwnziAZmnSNpdijdr4dWt+FJNBnBLz5mwDFkqIXU9wmBcWWad3QeJF5hMTkRe4dAq2sUZiG+8A== - dependencies: - "@babel/helper-plugin-utils" "^7.14.5" - -"@babel/plugin-transform-template-literals@^7.14.5": - version "7.14.5" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-template-literals/-/plugin-transform-template-literals-7.14.5.tgz#a5f2bc233937d8453885dc736bdd8d9ffabf3d93" - integrity sha512-22btZeURqiepOfuy/VkFr+zStqlujWaarpMErvay7goJS6BWwdd6BY9zQyDLDa4x2S3VugxFb162IZ4m/S/+Gg== - dependencies: - "@babel/helper-plugin-utils" "^7.14.5" - -"@babel/plugin-transform-typeof-symbol@^7.14.5": - version "7.14.5" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-typeof-symbol/-/plugin-transform-typeof-symbol-7.14.5.tgz#39af2739e989a2bd291bf6b53f16981423d457d4" - integrity sha512-lXzLD30ffCWseTbMQzrvDWqljvZlHkXU+CnseMhkMNqU1sASnCsz3tSzAaH3vCUXb9PHeUb90ZT1BdFTm1xxJw== - dependencies: - "@babel/helper-plugin-utils" "^7.14.5" - -"@babel/plugin-transform-unicode-escapes@^7.14.5": - version "7.14.5" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-unicode-escapes/-/plugin-transform-unicode-escapes-7.14.5.tgz#9d4bd2a681e3c5d7acf4f57fa9e51175d91d0c6b" - integrity sha512-crTo4jATEOjxj7bt9lbYXcBAM3LZaUrbP2uUdxb6WIorLmjNKSpHfIybgY4B8SRpbf8tEVIWH3Vtm7ayCrKocA== - dependencies: - "@babel/helper-plugin-utils" "^7.14.5" - -"@babel/plugin-transform-unicode-regex@^7.14.5": - version "7.14.5" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-unicode-regex/-/plugin-transform-unicode-regex-7.14.5.tgz#4cd09b6c8425dd81255c7ceb3fb1836e7414382e" - integrity sha512-UygduJpC5kHeCiRw/xDVzC+wj8VaYSoKl5JNVmbP7MadpNinAm3SvZCxZ42H37KZBKztz46YC73i9yV34d0Tzw== - dependencies: - "@babel/helper-create-regexp-features-plugin" "^7.14.5" - "@babel/helper-plugin-utils" "^7.14.5" - -"@babel/polyfill@^7.8.7": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/polyfill/-/polyfill-7.12.1.tgz#1f2d6371d1261bbd961f3c5d5909150e12d0bd96" - integrity sha512-X0pi0V6gxLi6lFZpGmeNa4zxtwEmCs42isWLNjZZDE0Y8yVfgu0T2OAHlzBbdYlqbW/YXVvoBHpATEM+goCj8g== - dependencies: - core-js "^2.6.5" - regenerator-runtime "^0.13.4" - -"@babel/preset-env@^7.11.0": - version "7.15.0" - resolved "https://registry.yarnpkg.com/@babel/preset-env/-/preset-env-7.15.0.tgz#e2165bf16594c9c05e52517a194bf6187d6fe464" - integrity sha512-FhEpCNFCcWW3iZLg0L2NPE9UerdtsCR6ZcsGHUX6Om6kbCQeL5QZDqFDmeNHC6/fy6UH3jEge7K4qG5uC9In0Q== - dependencies: - "@babel/compat-data" "^7.15.0" - "@babel/helper-compilation-targets" "^7.15.0" - "@babel/helper-plugin-utils" "^7.14.5" - "@babel/helper-validator-option" "^7.14.5" - "@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining" "^7.14.5" - "@babel/plugin-proposal-async-generator-functions" "^7.14.9" - "@babel/plugin-proposal-class-properties" "^7.14.5" - "@babel/plugin-proposal-class-static-block" "^7.14.5" - "@babel/plugin-proposal-dynamic-import" "^7.14.5" - "@babel/plugin-proposal-export-namespace-from" "^7.14.5" - "@babel/plugin-proposal-json-strings" "^7.14.5" - "@babel/plugin-proposal-logical-assignment-operators" "^7.14.5" - "@babel/plugin-proposal-nullish-coalescing-operator" "^7.14.5" - "@babel/plugin-proposal-numeric-separator" "^7.14.5" - "@babel/plugin-proposal-object-rest-spread" "^7.14.7" - "@babel/plugin-proposal-optional-catch-binding" "^7.14.5" - "@babel/plugin-proposal-optional-chaining" "^7.14.5" - "@babel/plugin-proposal-private-methods" "^7.14.5" - "@babel/plugin-proposal-private-property-in-object" "^7.14.5" - "@babel/plugin-proposal-unicode-property-regex" "^7.14.5" - "@babel/plugin-syntax-async-generators" "^7.8.4" - "@babel/plugin-syntax-class-properties" "^7.12.13" - "@babel/plugin-syntax-class-static-block" "^7.14.5" - "@babel/plugin-syntax-dynamic-import" "^7.8.3" - "@babel/plugin-syntax-export-namespace-from" "^7.8.3" - "@babel/plugin-syntax-json-strings" "^7.8.3" - "@babel/plugin-syntax-logical-assignment-operators" "^7.10.4" - "@babel/plugin-syntax-nullish-coalescing-operator" "^7.8.3" - "@babel/plugin-syntax-numeric-separator" "^7.10.4" - "@babel/plugin-syntax-object-rest-spread" "^7.8.3" - "@babel/plugin-syntax-optional-catch-binding" "^7.8.3" - "@babel/plugin-syntax-optional-chaining" "^7.8.3" - "@babel/plugin-syntax-private-property-in-object" "^7.14.5" - "@babel/plugin-syntax-top-level-await" "^7.14.5" - "@babel/plugin-transform-arrow-functions" "^7.14.5" - "@babel/plugin-transform-async-to-generator" "^7.14.5" - "@babel/plugin-transform-block-scoped-functions" "^7.14.5" - "@babel/plugin-transform-block-scoping" "^7.14.5" - "@babel/plugin-transform-classes" "^7.14.9" - "@babel/plugin-transform-computed-properties" "^7.14.5" - "@babel/plugin-transform-destructuring" "^7.14.7" - "@babel/plugin-transform-dotall-regex" "^7.14.5" - "@babel/plugin-transform-duplicate-keys" "^7.14.5" - "@babel/plugin-transform-exponentiation-operator" "^7.14.5" - "@babel/plugin-transform-for-of" "^7.14.5" - "@babel/plugin-transform-function-name" "^7.14.5" - "@babel/plugin-transform-literals" "^7.14.5" - "@babel/plugin-transform-member-expression-literals" "^7.14.5" - "@babel/plugin-transform-modules-amd" "^7.14.5" - "@babel/plugin-transform-modules-commonjs" "^7.15.0" - "@babel/plugin-transform-modules-systemjs" "^7.14.5" - "@babel/plugin-transform-modules-umd" "^7.14.5" - "@babel/plugin-transform-named-capturing-groups-regex" "^7.14.9" - "@babel/plugin-transform-new-target" "^7.14.5" - "@babel/plugin-transform-object-super" "^7.14.5" - "@babel/plugin-transform-parameters" "^7.14.5" - "@babel/plugin-transform-property-literals" "^7.14.5" - "@babel/plugin-transform-regenerator" "^7.14.5" - "@babel/plugin-transform-reserved-words" "^7.14.5" - "@babel/plugin-transform-shorthand-properties" "^7.14.5" - "@babel/plugin-transform-spread" "^7.14.6" - "@babel/plugin-transform-sticky-regex" "^7.14.5" - "@babel/plugin-transform-template-literals" "^7.14.5" - "@babel/plugin-transform-typeof-symbol" "^7.14.5" - "@babel/plugin-transform-unicode-escapes" "^7.14.5" - "@babel/plugin-transform-unicode-regex" "^7.14.5" - "@babel/preset-modules" "^0.1.4" - "@babel/types" "^7.15.0" - babel-plugin-polyfill-corejs2 "^0.2.2" - babel-plugin-polyfill-corejs3 "^0.2.2" - babel-plugin-polyfill-regenerator "^0.2.2" - core-js-compat "^3.16.0" - semver "^6.3.0" - -"@babel/preset-modules@^0.1.4": - version "0.1.4" - resolved "https://registry.yarnpkg.com/@babel/preset-modules/-/preset-modules-0.1.4.tgz#362f2b68c662842970fdb5e254ffc8fc1c2e415e" - integrity sha512-J36NhwnfdzpmH41M1DrnkkgAqhZaqr/NBdPfQ677mLzlaXo+oDiv1deyCDtgAhz8p328otdob0Du7+xgHGZbKg== - dependencies: - "@babel/helper-plugin-utils" "^7.0.0" - "@babel/plugin-proposal-unicode-property-regex" "^7.4.4" - "@babel/plugin-transform-dotall-regex" "^7.4.4" - "@babel/types" "^7.4.4" - esutils "^2.0.2" - -"@babel/runtime@^7.8.4": - version "7.14.8" - resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.14.8.tgz#7119a56f421018852694290b9f9148097391b446" - integrity sha512-twj3L8Og5SaCRCErB4x4ajbvBIVV77CGeFglHpeg5WC5FF8TZzBWXtTJ4MqaD9QszLYTtr+IsaAL2rEUevb+eg== - dependencies: - regenerator-runtime "^0.13.4" - -"@babel/template@^7.14.5": - version "7.14.5" - resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.14.5.tgz#a9bc9d8b33354ff6e55a9c60d1109200a68974f4" - integrity sha512-6Z3Po85sfxRGachLULUhOmvAaOo7xCvqGQtxINai2mEGPFm6pQ4z5QInFnUrRpfoSV60BnjyF5F3c+15fxFV1g== - dependencies: - "@babel/code-frame" "^7.14.5" - "@babel/parser" "^7.14.5" - "@babel/types" "^7.14.5" - -"@babel/traverse@^7.13.0", "@babel/traverse@^7.14.5", "@babel/traverse@^7.14.8", "@babel/traverse@^7.15.0": - version "7.15.0" - resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.15.0.tgz#4cca838fd1b2a03283c1f38e141f639d60b3fc98" - integrity sha512-392d8BN0C9eVxVWd8H6x9WfipgVH5IaIoLp23334Sc1vbKKWINnvwRpb4us0xtPaCumlwbTtIYNA0Dv/32sVFw== - dependencies: - "@babel/code-frame" "^7.14.5" - "@babel/generator" "^7.15.0" - "@babel/helper-function-name" "^7.14.5" - "@babel/helper-hoist-variables" "^7.14.5" - "@babel/helper-split-export-declaration" "^7.14.5" - "@babel/parser" "^7.15.0" - "@babel/types" "^7.15.0" - debug "^4.1.0" - globals "^11.1.0" - -"@babel/types@^7.14.5", "@babel/types@^7.14.8", "@babel/types@^7.15.0", "@babel/types@^7.4.4": - version "7.15.0" - resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.15.0.tgz#61af11f2286c4e9c69ca8deb5f4375a73c72dcbd" - integrity sha512-OBvfqnllOIdX4ojTHpwZbpvz4j3EWyjkZEdmjH0/cgsd6QOdSgU8rLSk6ard/pcW7rlmjdVSX/AWOaORR1uNOQ== - dependencies: - "@babel/helper-validator-identifier" "^7.14.9" - to-fast-properties "^2.0.0" - -"@colors/colors@1.5.0": - version "1.5.0" - resolved "https://registry.yarnpkg.com/@colors/colors/-/colors-1.5.0.tgz#bb504579c1cae923e6576a4f5da43d25f97bdbd9" - integrity sha512-ooWCrlZP11i8GImSjTHYHLkvFDP48nS4+204nGb1RiX/WXYHmJA2III9/e2DWVabCESdW7hBAEzHRqUn9OUVvQ== - -"@istanbuljs/schema@^0.1.2": - version "0.1.3" - resolved "https://registry.yarnpkg.com/@istanbuljs/schema/-/schema-0.1.3.tgz#e45e384e4b8ec16bce2fd903af78450f6bf7ec98" - integrity sha512-ZXRY4jNvVgSVQ8DL3LTcakaAtXwTVUxE81hslsyD2AtoXW/wVob10HkOJ1X/pAlcI7D+2YoZKg5do8G/w6RYgA== - -"@tensorflow/tfjs-backend-cpu@link:../link-package/node_modules/@tensorflow/tfjs-backend-cpu": - version "0.0.0" - -"@tensorflow/tfjs-core@link:../link-package/node_modules/@tensorflow/tfjs-core": - version "0.0.0" - -"@types/component-emitter@^1.2.10": - version "1.2.11" - resolved "https://registry.yarnpkg.com/@types/component-emitter/-/component-emitter-1.2.11.tgz#50d47d42b347253817a39709fef03ce66a108506" - integrity sha512-SRXjM+tfsSlA9VuG8hGO2nft2p8zjXCK1VcC6N4NXbBbYbSia9kzCChYQajIjzIqOOOuh5Ock6MmV2oux4jDZQ== - -"@types/cookie@^0.4.1": - version "0.4.1" - resolved "https://registry.yarnpkg.com/@types/cookie/-/cookie-0.4.1.tgz#bfd02c1f2224567676c1545199f87c3a861d878d" - integrity sha512-XW/Aa8APYr6jSVVA1y/DEIZX0/GMKLEVekNG727R8cs56ahETkRAy/3DR7+fJyh7oUgGwNQaRfXCun0+KbWY7Q== - -"@types/cors@^2.8.12": - version "2.8.12" - resolved "https://registry.yarnpkg.com/@types/cors/-/cors-2.8.12.tgz#6b2c510a7ad7039e98e7b8d3d6598f4359e5c080" - integrity sha512-vt+kDhq/M2ayberEtJcIN/hxXy1Pk+59g2FV/ZQceeaTyCtCucjL2Q7FXlFjtWn4n15KCr1NE2lNNFhp0lEThw== - -"@types/node@>=10.0.0": - version "18.11.9" - resolved "https://registry.yarnpkg.com/@types/node/-/node-18.11.9.tgz#02d013de7058cea16d36168ef2fc653464cfbad4" - integrity sha512-CRpX21/kGdzjOpFsZSkcrXMGIBWMGNIHXXBVFSH+ggkftxg+XYP20TESbh+zFvFj3EQOl5byk0HTRn1IL6hbqg== - -accepts@~1.3.4: - version "1.3.8" - resolved "https://registry.yarnpkg.com/accepts/-/accepts-1.3.8.tgz#0bf0be125b67014adcb0b0921e62db7bffe16b2e" - integrity sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw== - dependencies: - mime-types "~2.1.34" - negotiator "0.6.3" - -acorn-walk@^8.0.2: - version "8.1.1" - resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-8.1.1.tgz#3ddab7f84e4a7e2313f6c414c5b7dac85f4e3ebc" - integrity sha512-FbJdceMlPHEAWJOILDk1fXD8lnTlEIWFkqtfk+MvmL5q/qlHfN7GEHcsFZWt/Tea9jRNPWUZG4G976nqAAmU9w== - -acorn@^8.1.0: - version "8.4.1" - resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.4.1.tgz#56c36251fc7cabc7096adc18f05afe814321a28c" - integrity sha512-asabaBSkEKosYKMITunzX177CXxQ4Q8BSSzMTKD+FefUhipQC70gfW5SiUDhYQ3vk8G+81HqQk7Fv9OXwwn9KA== - -agent-base@5: - version "5.1.1" - resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-5.1.1.tgz#e8fb3f242959db44d63be665db7a8e739537a32c" - integrity sha512-TMeqbNl2fMW0nMjTEPOwe3J/PRFP4vqeoNuQMG0HlMrtm5QxKqdvAkZ1pRBQ/ulIyDD5Yq0nJ7YbdD8ey0TO3g== - -agent-base@^4.3.0: - version "4.3.0" - resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-4.3.0.tgz#8165f01c436009bccad0b1d122f05ed770efc6ee" - integrity sha512-salcGninV0nPrwpGNn4VTXBb1SOuXQBiqbrNXoeizJsHrsL6ERFM2Ne3JUSBWRE6aeNJI2ROP/WEEIDUiDe3cg== - dependencies: - es6-promisify "^5.0.0" - -ansi-regex@^5.0.0: - version "5.0.1" - resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.1.tgz#082cb2c89c9fe8659a311a53bd6a4dc5301db304" - integrity sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ== - -ansi-styles@^3.2.1: - version "3.2.1" - resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d" - integrity sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA== - dependencies: - color-convert "^1.9.0" - -ansi-styles@^4.0.0: - version "4.3.0" - resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-4.3.0.tgz#edd803628ae71c04c85ae7a0906edad34b648937" - integrity sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg== - dependencies: - color-convert "^2.0.1" - -anymatch@~3.1.2: - version "3.1.2" - resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-3.1.2.tgz#c0557c096af32f106198f4f4e2a383537e378716" - integrity sha512-P43ePfOAIupkguHUycrc4qJ9kz8ZiuOUijaETwX7THt0Y/GNK7v0aa8rY816xWjZ7rJdA5XdMcpVFTKMq+RvWg== - dependencies: - normalize-path "^3.0.0" - picomatch "^2.0.4" - -asn1.js@^5.2.0: - version "5.4.1" - resolved "https://registry.yarnpkg.com/asn1.js/-/asn1.js-5.4.1.tgz#11a980b84ebb91781ce35b0fdc2ee294e3783f07" - integrity sha512-+I//4cYPccV8LdmBLiX8CYvf9Sp3vQsrqu2QNXRcrbiWvcx/UdlFiqUJJzxRQxgsZmvhXhn4cSKeSmoFjVdupA== - dependencies: - bn.js "^4.0.0" - inherits "^2.0.1" - minimalistic-assert "^1.0.0" - safer-buffer "^2.1.0" - -assert@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/assert/-/assert-2.0.0.tgz#95fc1c616d48713510680f2eaf2d10dd22e02d32" - integrity sha512-se5Cd+js9dXJnu6Ag2JFc00t+HmHOen+8Q+L7O9zI0PqQXr20uk2J0XQqMxZEeo5U50o8Nvmmx7dZrl+Ufr35A== - dependencies: - es6-object-assign "^1.1.0" - is-nan "^1.2.1" - object-is "^1.0.1" - util "^0.12.0" - -async@^3.0.1: - version "3.2.3" - resolved "https://registry.yarnpkg.com/async/-/async-3.2.3.tgz#ac53dafd3f4720ee9e8a160628f18ea91df196c9" - integrity sha512-spZRyzKL5l5BZQrr/6m/SqFdBN0q3OCI0f9rjfBzCMBIP4p75P620rR3gTmaksNOhmzgdxcaxdNfMy6anrbM0g== - -available-typed-arrays@^1.0.2: - version "1.0.4" - resolved "https://registry.yarnpkg.com/available-typed-arrays/-/available-typed-arrays-1.0.4.tgz#9e0ae84ecff20caae6a94a1c3bc39b955649b7a9" - integrity sha512-SA5mXJWrId1TaQjfxUYghbqQ/hYioKmLJvPJyDuYRtXXenFNMjj4hSSt1Cf1xsuXSXrtxrVC5Ot4eU6cOtBDdA== - -babel-plugin-dynamic-import-node@^2.3.3: - version "2.3.3" - resolved "https://registry.yarnpkg.com/babel-plugin-dynamic-import-node/-/babel-plugin-dynamic-import-node-2.3.3.tgz#84fda19c976ec5c6defef57f9427b3def66e17a3" - integrity sha512-jZVI+s9Zg3IqA/kdi0i6UDCybUI3aSBLnglhYbSSjKlV7yF1F/5LWv8MakQmvYpnbJDS6fcBL2KzHSxNCMtWSQ== - dependencies: - object.assign "^4.1.0" - -babel-plugin-polyfill-corejs2@^0.2.2: - version "0.2.2" - resolved "https://registry.yarnpkg.com/babel-plugin-polyfill-corejs2/-/babel-plugin-polyfill-corejs2-0.2.2.tgz#e9124785e6fd94f94b618a7954e5693053bf5327" - integrity sha512-kISrENsJ0z5dNPq5eRvcctITNHYXWOA4DUZRFYCz3jYCcvTb/A546LIddmoGNMVYg2U38OyFeNosQwI9ENTqIQ== - dependencies: - "@babel/compat-data" "^7.13.11" - "@babel/helper-define-polyfill-provider" "^0.2.2" - semver "^6.1.1" - -babel-plugin-polyfill-corejs3@^0.2.2: - version "0.2.4" - resolved "https://registry.yarnpkg.com/babel-plugin-polyfill-corejs3/-/babel-plugin-polyfill-corejs3-0.2.4.tgz#68cb81316b0e8d9d721a92e0009ec6ecd4cd2ca9" - integrity sha512-z3HnJE5TY/j4EFEa/qpQMSbcUJZ5JQi+3UFjXzn6pQCmIKc5Ug5j98SuYyH+m4xQnvKlMDIW4plLfgyVnd0IcQ== - dependencies: - "@babel/helper-define-polyfill-provider" "^0.2.2" - core-js-compat "^3.14.0" - -babel-plugin-polyfill-regenerator@^0.2.2: - version "0.2.2" - resolved "https://registry.yarnpkg.com/babel-plugin-polyfill-regenerator/-/babel-plugin-polyfill-regenerator-0.2.2.tgz#b310c8d642acada348c1fa3b3e6ce0e851bee077" - integrity sha512-Goy5ghsc21HgPDFtzRkSirpZVW35meGoTmTOb2bxqdl60ghub4xOidgNTHaZfQ2FaxQsKmwvXtOAkcIS4SMBWg== - dependencies: - "@babel/helper-define-polyfill-provider" "^0.2.2" - -balanced-match@^1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee" - integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw== - -base64-js@^1.3.1: - version "1.5.1" - resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a" - integrity sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA== - -base64id@2.0.0, base64id@~2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/base64id/-/base64id-2.0.0.tgz#2770ac6bc47d312af97a8bf9a634342e0cd25cb6" - integrity sha512-lGe34o6EHj9y3Kts9R4ZYs/Gr+6N7MCaMlIFA3F1R2O5/m7K06AxfSeO5530PEERE6/WyEg3lsuyw4GHlPZHog== - -binary-extensions@^2.0.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.2.0.tgz#75f502eeaf9ffde42fc98829645be4ea76bd9e2d" - integrity sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA== - -bn.js@^4.0.0, bn.js@^4.1.0, bn.js@^4.11.9: - version "4.12.0" - resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-4.12.0.tgz#775b3f278efbb9718eec7361f483fb36fbbfea88" - integrity sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA== - -bn.js@^5.0.0, bn.js@^5.1.1: - version "5.2.0" - resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-5.2.0.tgz#358860674396c6997771a9d051fcc1b57d4ae002" - integrity sha512-D7iWRBvnZE8ecXiLj/9wbxH7Tk79fAh8IHaTNq1RWRixsS02W+5qS+iE9yq6RYl0asXx5tw0bLhmT5pIfbSquw== - -body-parser@^1.19.0: - version "1.19.0" - resolved "https://registry.yarnpkg.com/body-parser/-/body-parser-1.19.0.tgz#96b2709e57c9c4e09a6fd66a8fd979844f69f08a" - integrity sha512-dhEPs72UPbDnAQJ9ZKMNTP6ptJaionhP5cBb541nXPlW60Jepo9RV/a4fX4XWW9CuFNK22krhrj1+rgzifNCsw== - dependencies: - bytes "3.1.0" - content-type "~1.0.4" - debug "2.6.9" - depd "~1.1.2" - http-errors "1.7.2" - iconv-lite "0.4.24" - on-finished "~2.3.0" - qs "6.7.0" - raw-body "2.4.0" - type-is "~1.6.17" - -brace-expansion@^1.1.7: - version "1.1.11" - resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" - integrity sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA== - dependencies: - balanced-match "^1.0.0" - concat-map "0.0.1" - -braces@^3.0.2, braces@~3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107" - integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A== - dependencies: - fill-range "^7.0.1" - -brorand@^1.0.1, brorand@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/brorand/-/brorand-1.1.0.tgz#12c25efe40a45e3c323eb8675a0a0ce57b22371f" - integrity sha1-EsJe/kCkXjwyPrhnWgoM5XsiNx8= - -browser-resolve@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/browser-resolve/-/browser-resolve-2.0.0.tgz#99b7304cb392f8d73dba741bb2d7da28c6d7842b" - integrity sha512-7sWsQlYL2rGLy2IWm8WL8DCTJvYLc/qlOnsakDac87SOoCd16WLsaAMdCiAqsTNHIe+SXfaqyxyo6THoWqs8WQ== - dependencies: - resolve "^1.17.0" - -browserify-aes@^1.0.0, browserify-aes@^1.0.4: - version "1.2.0" - resolved "https://registry.yarnpkg.com/browserify-aes/-/browserify-aes-1.2.0.tgz#326734642f403dabc3003209853bb70ad428ef48" - integrity sha512-+7CHXqGuspUn/Sl5aO7Ea0xWGAtETPXNSAjHo48JfLdPWcMng33Xe4znFvQweqc/uzk5zSOI3H52CYnjCfb5hA== - dependencies: - buffer-xor "^1.0.3" - cipher-base "^1.0.0" - create-hash "^1.1.0" - evp_bytestokey "^1.0.3" - inherits "^2.0.1" - safe-buffer "^5.0.1" - -browserify-cipher@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/browserify-cipher/-/browserify-cipher-1.0.1.tgz#8d6474c1b870bfdabcd3bcfcc1934a10e94f15f0" - integrity sha512-sPhkz0ARKbf4rRQt2hTpAHqn47X3llLkUGn+xEJzLjwY8LRs2p0v7ljvI5EyoRO/mexrNunNECisZs+gw2zz1w== - dependencies: - browserify-aes "^1.0.4" - browserify-des "^1.0.0" - evp_bytestokey "^1.0.0" - -browserify-des@^1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/browserify-des/-/browserify-des-1.0.2.tgz#3af4f1f59839403572f1c66204375f7a7f703e9c" - integrity sha512-BioO1xf3hFwz4kc6iBhI3ieDFompMhrMlnDFC4/0/vd5MokpuAc3R+LYbwTA9A5Yc9pq9UYPqffKpW2ObuwX5A== - dependencies: - cipher-base "^1.0.1" - des.js "^1.0.0" - inherits "^2.0.1" - safe-buffer "^5.1.2" - -browserify-rsa@^4.0.0, browserify-rsa@^4.0.1: - version "4.1.0" - resolved "https://registry.yarnpkg.com/browserify-rsa/-/browserify-rsa-4.1.0.tgz#b2fd06b5b75ae297f7ce2dc651f918f5be158c8d" - integrity sha512-AdEER0Hkspgno2aR97SAf6vi0y0k8NuOpGnVH3O99rcA5Q6sh8QxcngtHuJ6uXwnfAXNM4Gn1Gb7/MV1+Ymbog== - dependencies: - bn.js "^5.0.0" - randombytes "^2.0.1" - -browserify-sign@^4.0.0: - version "4.2.1" - resolved "https://registry.yarnpkg.com/browserify-sign/-/browserify-sign-4.2.1.tgz#eaf4add46dd54be3bb3b36c0cf15abbeba7956c3" - integrity sha512-/vrA5fguVAKKAVTNJjgSm1tRQDHUU6DbwO9IROu/0WAzC8PKhucDSh18J0RMvVeHAn5puMd+QHC2erPRNf8lmg== - dependencies: - bn.js "^5.1.1" - browserify-rsa "^4.0.1" - create-hash "^1.2.0" - create-hmac "^1.1.7" - elliptic "^6.5.3" - inherits "^2.0.4" - parse-asn1 "^5.1.5" - readable-stream "^3.6.0" - safe-buffer "^5.2.0" - -browserify-zlib@^0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/browserify-zlib/-/browserify-zlib-0.2.0.tgz#2869459d9aa3be245fe8fe2ca1f46e2e7f54d73f" - integrity sha512-Z942RysHXmJrhqk88FmKBVq/v5tqmSkDz7p54G/MGyjMnCFFnC79XWNbg+Vta8W6Wb2qtSZTSxIGkJrRpCFEiA== - dependencies: - pako "~1.0.5" - -browserslist@^4.16.6: - version "4.16.7" - resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.16.7.tgz#108b0d1ef33c4af1b587c54f390e7041178e4335" - integrity sha512-7I4qVwqZltJ7j37wObBe3SoTz+nS8APaNcrBOlgoirb6/HbEU2XxW/LpUDTCngM6iauwFqmRTuOMfyKnFGY5JA== - dependencies: - caniuse-lite "^1.0.30001248" - colorette "^1.2.2" - electron-to-chromium "^1.3.793" - escalade "^3.1.1" - node-releases "^1.1.73" - -browserstack-local@^1.3.7: - version "1.4.8" - resolved "https://registry.yarnpkg.com/browserstack-local/-/browserstack-local-1.4.8.tgz#07f74a19b324cf2de69ffe65f9c2baa3a2dd9a0e" - integrity sha512-s+mc3gTOJwELdLWi4qFVKtGwMbb5JWsR+JxKlMaJkRJxoZ0gg3WREgPxAN0bm6iU5+S4Bi0sz0oxBRZT8BiNsQ== - dependencies: - https-proxy-agent "^4.0.0" - is-running "^2.1.0" - ps-tree "=1.2.0" - temp-fs "^0.9.9" - -browserstack@~1.5.1: - version "1.5.3" - resolved "https://registry.yarnpkg.com/browserstack/-/browserstack-1.5.3.tgz#93ab48799a12ef99dbd074dd595410ddb196a7ac" - integrity sha512-AO+mECXsW4QcqC9bxwM29O7qWa7bJT94uBFzeb5brylIQwawuEziwq20dPYbins95GlWzOawgyDNdjYAo32EKg== - dependencies: - https-proxy-agent "^2.2.1" - -buffer-xor@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/buffer-xor/-/buffer-xor-1.0.3.tgz#26e61ed1422fb70dd42e6e36729ed51d855fe8d9" - integrity sha1-JuYe0UIvtw3ULm42cp7VHYVf6Nk= - -buffer@^5.4.3: - version "5.7.1" - resolved "https://registry.yarnpkg.com/buffer/-/buffer-5.7.1.tgz#ba62e7c13133053582197160851a8f648e99eed0" - integrity sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ== - dependencies: - base64-js "^1.3.1" - ieee754 "^1.1.13" - -builtin-status-codes@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz#85982878e21b98e1c66425e03d0174788f569ee8" - integrity sha1-hZgoeOIbmOHGZCXgPQF0eI9Wnug= - -bytes@3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/bytes/-/bytes-3.1.0.tgz#f6cf7933a360e0588fa9fde85651cdc7f805d1f6" - integrity sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg== - -call-bind@^1.0.0, call-bind@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/call-bind/-/call-bind-1.0.2.tgz#b1d4e89e688119c3c9a903ad30abb2f6a919be3c" - integrity sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA== - dependencies: - function-bind "^1.1.1" - get-intrinsic "^1.0.2" - -caniuse-lite@^1.0.30001248: - version "1.0.30001249" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001249.tgz#90a330057f8ff75bfe97a94d047d5e14fabb2ee8" - integrity sha512-vcX4U8lwVXPdqzPWi6cAJ3FnQaqXbBqy/GZseKNQzRj37J7qZdGcBtxq/QLFNLLlfsoXLUdHw8Iwenri86Tagw== - -chalk@^2.0.0: - version "2.4.2" - resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" - integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ== - dependencies: - ansi-styles "^3.2.1" - escape-string-regexp "^1.0.5" - supports-color "^5.3.0" - -chokidar@^3.5.1: - version "3.5.2" - resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.5.2.tgz#dba3976fcadb016f66fd365021d91600d01c1e75" - integrity sha512-ekGhOnNVPgT77r4K/U3GDhu+FQ2S8TnK/s2KbIGXi0SZWuwkZ2QNyfWdZW+TVfn84DpEP7rLeCt2UI6bJ8GwbQ== - dependencies: - anymatch "~3.1.2" - braces "~3.0.2" - glob-parent "~5.1.2" - is-binary-path "~2.1.0" - is-glob "~4.0.1" - normalize-path "~3.0.0" - readdirp "~3.6.0" - optionalDependencies: - fsevents "~2.3.2" - -cipher-base@^1.0.0, cipher-base@^1.0.1, cipher-base@^1.0.3: - version "1.0.4" - resolved "https://registry.yarnpkg.com/cipher-base/-/cipher-base-1.0.4.tgz#8760e4ecc272f4c363532f926d874aae2c1397de" - integrity sha512-Kkht5ye6ZGmwv40uUDZztayT2ThLQGfnj/T71N/XzeZeo3nf8foyW7zGTsPYkEya3m5f3cAypH+qe7YOrM1U2Q== - dependencies: - inherits "^2.0.1" - safe-buffer "^5.0.1" - -cliui@^7.0.2: - version "7.0.4" - resolved "https://registry.yarnpkg.com/cliui/-/cliui-7.0.4.tgz#a0265ee655476fc807aea9df3df8df7783808b4f" - integrity sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ== - dependencies: - string-width "^4.2.0" - strip-ansi "^6.0.0" - wrap-ansi "^7.0.0" - -clone@^1.0.2: - version "1.0.4" - resolved "https://registry.yarnpkg.com/clone/-/clone-1.0.4.tgz#da309cc263df15994c688ca902179ca3c7cd7c7e" - integrity sha1-2jCcwmPfFZlMaIypAheco8fNfH4= - -color-convert@^1.9.0: - version "1.9.3" - resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8" - integrity sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg== - dependencies: - color-name "1.1.3" - -color-convert@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-2.0.1.tgz#72d3a68d598c9bdb3af2ad1e84f21d896abd4de3" - integrity sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ== - dependencies: - color-name "~1.1.4" - -color-name@1.1.3: - version "1.1.3" - resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25" - integrity sha1-p9BVi9icQveV3UIyj3QIMcpTvCU= - -color-name@~1.1.4: - version "1.1.4" - resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2" - integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA== - -colorette@^1.2.2: - version "1.2.2" - resolved "https://registry.yarnpkg.com/colorette/-/colorette-1.2.2.tgz#cbcc79d5e99caea2dbf10eb3a26fd8b3e6acfa94" - integrity sha512-MKGMzyfeuutC/ZJ1cba9NqcNpfeqMUcYmyF1ZFY6/Cn7CNSAKx6a+s48sqLqyAiZuaP2TcqMhoo+dlwFnVxT9w== - -combine-source-map@^0.8.0: - version "0.8.0" - resolved "https://registry.yarnpkg.com/combine-source-map/-/combine-source-map-0.8.0.tgz#a58d0df042c186fcf822a8e8015f5450d2d79a8b" - integrity sha1-pY0N8ELBhvz4IqjoAV9UUNLXmos= - dependencies: - convert-source-map "~1.1.0" - inline-source-map "~0.6.0" - lodash.memoize "~3.0.3" - source-map "~0.5.3" - -component-emitter@~1.3.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/component-emitter/-/component-emitter-1.3.0.tgz#16e4070fba8ae29b679f2215853ee181ab2eabc0" - integrity sha512-Rd3se6QB+sO1TwqZjscQrurpEPIfO0/yYnSin6Q/rD3mOutHvUrCAhJub3r90uNb+SESBuE0QYoB90YdfatsRg== - -concat-map@0.0.1: - version "0.0.1" - resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" - integrity sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg== - -connect@^3.7.0: - version "3.7.0" - resolved "https://registry.yarnpkg.com/connect/-/connect-3.7.0.tgz#5d49348910caa5e07a01800b030d0c35f20484f8" - integrity sha512-ZqRXc+tZukToSNmh5C2iWMSoV3X1YUcPbqEM4DkEG5tNQXrQUZCNVGGv3IuicnkMtPfGf3Xtp8WCXs295iQ1pQ== - dependencies: - debug "2.6.9" - finalhandler "1.1.2" - parseurl "~1.3.3" - utils-merge "1.0.1" - -console-browserify@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/console-browserify/-/console-browserify-1.2.0.tgz#67063cef57ceb6cf4993a2ab3a55840ae8c49336" - integrity sha512-ZMkYO/LkF17QvCPqM0gxw8yUzigAOZOSWSHg91FH6orS7vcEj5dVZTidN2fQ14yBSdg97RqhSNwLUXInd52OTA== - -constants-browserify@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/constants-browserify/-/constants-browserify-1.0.0.tgz#c20b96d8c617748aaf1c16021760cd27fcb8cb75" - integrity sha1-wguW2MYXdIqvHBYCF2DNJ/y4y3U= - -content-type@~1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/content-type/-/content-type-1.0.4.tgz#e138cc75e040c727b1966fe5e5f8c9aee256fe3b" - integrity sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA== - -convert-source-map@^1.7.0: - version "1.8.0" - resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.8.0.tgz#f3373c32d21b4d780dd8004514684fb791ca4369" - integrity sha512-+OQdjP49zViI/6i7nIJpA8rAl4sV/JdPfU9nZs3VqOwGIgizICvuN2ru6fMd+4llL0tar18UYJXfZ/TWtmhUjA== - dependencies: - safe-buffer "~5.1.1" - -convert-source-map@~1.1.0: - version "1.1.3" - resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.1.3.tgz#4829c877e9fe49b3161f3bf3673888e204699860" - integrity sha1-SCnId+n+SbMWHzvzZziI4gRpmGA= - -cookie@~0.4.1: - version "0.4.2" - resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.4.2.tgz#0e41f24de5ecf317947c82fc789e06a884824432" - integrity sha512-aSWTXFzaKWkvHO1Ny/s+ePFpvKsPnjc551iI41v3ny/ow6tBG5Vd+FuqGNhh1LxOmVzOlGUriIlOaokOvhaStA== - -core-js-compat@^3.14.0, core-js-compat@^3.16.0: - version "3.16.0" - resolved "https://registry.yarnpkg.com/core-js-compat/-/core-js-compat-3.16.0.tgz#fced4a0a534e7e02f7e084bff66c701f8281805f" - integrity sha512-5D9sPHCdewoUK7pSUPfTF7ZhLh8k9/CoJXWUEo+F1dZT5Z1DVgcuRqUKhjeKW+YLb8f21rTFgWwQJiNw1hoZ5Q== - dependencies: - browserslist "^4.16.6" - semver "7.0.0" - -core-js@^2.6.5: - version "2.6.12" - resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.6.12.tgz#d9333dfa7b065e347cc5682219d6f690859cc2ec" - integrity sha512-Kb2wC0fvsWfQrgk8HU5lW6U/Lcs8+9aaYcy4ZFc6DDlo4nZ7n70dEgE5rtR0oG6ufKDUnrwfWL1mXR5ljDatrQ== - -cors@~2.8.5: - version "2.8.5" - resolved "https://registry.yarnpkg.com/cors/-/cors-2.8.5.tgz#eac11da51592dd86b9f06f6e7ac293b3df875d29" - integrity sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g== - dependencies: - object-assign "^4" - vary "^1" - -create-ecdh@^4.0.0: - version "4.0.4" - resolved "https://registry.yarnpkg.com/create-ecdh/-/create-ecdh-4.0.4.tgz#d6e7f4bffa66736085a0762fd3a632684dabcc4e" - integrity sha512-mf+TCx8wWc9VpuxfP2ht0iSISLZnt0JgWlrOKZiNqyUZWnjIaCIVNQArMHnCZKfEYRg6IM7A+NeJoN8gf/Ws0A== - dependencies: - bn.js "^4.1.0" - elliptic "^6.5.3" - -create-hash@^1.1.0, create-hash@^1.1.2, create-hash@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/create-hash/-/create-hash-1.2.0.tgz#889078af11a63756bcfb59bd221996be3a9ef196" - integrity sha512-z00bCGNHDG8mHAkP7CtT1qVu+bFQUPjYq/4Iv3C3kWjTFV10zIjfSoeqXo9Asws8gwSHDGj/hl2u4OGIjapeCg== - dependencies: - cipher-base "^1.0.1" - inherits "^2.0.1" - md5.js "^1.3.4" - ripemd160 "^2.0.1" - sha.js "^2.4.0" - -create-hmac@^1.1.0, create-hmac@^1.1.4, create-hmac@^1.1.7: - version "1.1.7" - resolved "https://registry.yarnpkg.com/create-hmac/-/create-hmac-1.1.7.tgz#69170c78b3ab957147b2b8b04572e47ead2243ff" - integrity sha512-MJG9liiZ+ogc4TzUwuvbER1JRdgvUFSB5+VR/g5h82fGaIRWMWddtKBHi7/sVhfjQZ6SehlyhvQYrcYkaUIpLg== - dependencies: - cipher-base "^1.0.3" - create-hash "^1.1.0" - inherits "^2.0.1" - ripemd160 "^2.0.0" - safe-buffer "^5.0.1" - sha.js "^2.4.8" - -crypto-browserify@^3.12.0: - version "3.12.0" - resolved "https://registry.yarnpkg.com/crypto-browserify/-/crypto-browserify-3.12.0.tgz#396cf9f3137f03e4b8e532c58f698254e00f80ec" - integrity sha512-fz4spIh+znjO2VjL+IdhEpRJ3YN6sMzITSBijk6FK2UvTqruSQW+/cCZTSNsMiZNvUeq0CqurF+dAbyiGOY6Wg== - dependencies: - browserify-cipher "^1.0.0" - browserify-sign "^4.0.0" - create-ecdh "^4.0.0" - create-hash "^1.1.0" - create-hmac "^1.1.0" - diffie-hellman "^5.0.0" - inherits "^2.0.1" - pbkdf2 "^3.0.3" - public-encrypt "^4.0.0" - randombytes "^2.0.0" - randomfill "^1.0.3" - -custom-event@~1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/custom-event/-/custom-event-1.0.1.tgz#5d02a46850adf1b4a317946a3928fccb5bfd0425" - integrity sha1-XQKkaFCt8bSjF5RqOSj8y1v9BCU= - -date-format@^4.0.3: - version "4.0.3" - resolved "https://registry.yarnpkg.com/date-format/-/date-format-4.0.3.tgz#f63de5dc08dc02efd8ef32bf2a6918e486f35873" - integrity sha512-7P3FyqDcfeznLZp2b+OMitV9Sz2lUnsT87WaTat9nVwqsBkTzPG3lPLNwW3en6F4pHUiWzr6vb8CLhjdK9bcxQ== - -debug@2.6.9: - version "2.6.9" - resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" - integrity sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA== - dependencies: - ms "2.0.0" - -debug@4, debug@^4.1.0, debug@^4.1.1, debug@^4.3.3, debug@~4.3.1, debug@~4.3.2: - version "4.3.4" - resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865" - integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ== - dependencies: - ms "2.1.2" - -debug@^3.1.0: - version "3.2.7" - resolved "https://registry.yarnpkg.com/debug/-/debug-3.2.7.tgz#72580b7e9145fb39b6676f9c5e5fb100b934179a" - integrity sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ== - dependencies: - ms "^2.1.1" - -defaults@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/defaults/-/defaults-1.0.3.tgz#c656051e9817d9ff08ed881477f3fe4019f3ef7d" - integrity sha1-xlYFHpgX2f8I7YgUd/P+QBnz730= - dependencies: - clone "^1.0.2" - -define-properties@^1.1.3: - version "1.1.3" - resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.1.3.tgz#cf88da6cbee26fe6db7094f61d870cbd84cee9f1" - integrity sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ== - dependencies: - object-keys "^1.0.12" - -depd@~1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/depd/-/depd-1.1.2.tgz#9bcd52e14c097763e749b274c4346ed2e560b5a9" - integrity sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak= - -des.js@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/des.js/-/des.js-1.0.1.tgz#5382142e1bdc53f85d86d53e5f4aa7deb91e0843" - integrity sha512-Q0I4pfFrv2VPd34/vfLrFOoRmlYj3OV50i7fskps1jZWK1kApMWWT9G6RRUeYedLcBDIhnSDaUvJMb3AhUlaEA== - dependencies: - inherits "^2.0.1" - minimalistic-assert "^1.0.0" - -di@^0.0.1: - version "0.0.1" - resolved "https://registry.yarnpkg.com/di/-/di-0.0.1.tgz#806649326ceaa7caa3306d75d985ea2748ba913c" - integrity sha1-gGZJMmzqp8qjMG112YXqJ0i6kTw= - -diff@^4.0.1: - version "4.0.2" - resolved "https://registry.yarnpkg.com/diff/-/diff-4.0.2.tgz#60f3aecb89d5fae520c11aa19efc2bb982aade7d" - integrity sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A== - -diffie-hellman@^5.0.0: - version "5.0.3" - resolved "https://registry.yarnpkg.com/diffie-hellman/-/diffie-hellman-5.0.3.tgz#40e8ee98f55a2149607146921c63e1ae5f3d2875" - integrity sha512-kqag/Nl+f3GwyK25fhUMYj81BUOrZ9IuJsjIcDE5icNM9FJHAVm3VcUDxdLPoQtTuUylWm6ZIknYJwwaPxsUzg== - dependencies: - bn.js "^4.1.0" - miller-rabin "^4.0.0" - randombytes "^2.0.0" - -dom-serialize@^2.2.1: - version "2.2.1" - resolved "https://registry.yarnpkg.com/dom-serialize/-/dom-serialize-2.2.1.tgz#562ae8999f44be5ea3076f5419dcd59eb43ac95b" - integrity sha1-ViromZ9Evl6jB29UGdzVnrQ6yVs= - dependencies: - custom-event "~1.0.0" - ent "~2.2.0" - extend "^3.0.0" - void-elements "^2.0.0" - -domain-browser@^4.16.0: - version "4.22.0" - resolved "https://registry.yarnpkg.com/domain-browser/-/domain-browser-4.22.0.tgz#6ddd34220ec281f9a65d3386d267ddd35c491f9f" - integrity sha512-IGBwjF7tNk3cwypFNH/7bfzBcgSCbaMOD3GsaY1AU/JRrnHnYgEM0+9kQt52iZxjNsjBtJYtao146V+f8jFZNw== - -duplexer@~0.1.1: - version "0.1.2" - resolved "https://registry.yarnpkg.com/duplexer/-/duplexer-0.1.2.tgz#3abe43aef3835f8ae077d136ddce0f276b0400e6" - integrity sha512-jtD6YG370ZCIi/9GTaJKQxWTZD045+4R4hTk/x1UyoqadyJ9x9CgSi1RlVDQF8U2sxLLSnFkCaMihqljHIWgMg== - -ee-first@1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d" - integrity sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0= - -electron-to-chromium@^1.3.793: - version "1.3.796" - resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.796.tgz#bd74a4367902c9d432d129f265bf4542cddd9f54" - integrity sha512-agwJFgM0FUC1UPPbQ4aII3HamaaJ09fqWGAWYHmzxDWqdmTleCHyyA0kt3fJlTd5M440IaeuBfzXzXzCotnZcQ== - -elliptic@^6.5.3: - version "6.5.4" - resolved "https://registry.yarnpkg.com/elliptic/-/elliptic-6.5.4.tgz#da37cebd31e79a1367e941b592ed1fbebd58abbb" - integrity sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ== - dependencies: - bn.js "^4.11.9" - brorand "^1.1.0" - hash.js "^1.0.0" - hmac-drbg "^1.0.1" - inherits "^2.0.4" - minimalistic-assert "^1.0.1" - minimalistic-crypto-utils "^1.0.1" - -emoji-regex@^8.0.0: - version "8.0.0" - resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37" - integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A== - -encodeurl@~1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/encodeurl/-/encodeurl-1.0.2.tgz#ad3ff4c86ec2d029322f5a02c3a9a606c95b3f59" - integrity sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k= - -engine.io-parser@~5.0.3: - version "5.0.4" - resolved "https://registry.yarnpkg.com/engine.io-parser/-/engine.io-parser-5.0.4.tgz#0b13f704fa9271b3ec4f33112410d8f3f41d0fc0" - integrity sha512-+nVFp+5z1E3HcToEnO7ZIj3g+3k9389DvWtvJZz0T6/eOCPIyyxehFcedoYrZQrp0LgQbD9pPXhpMBKMd5QURg== - -engine.io@~6.2.0: - version "6.2.1" - resolved "https://registry.yarnpkg.com/engine.io/-/engine.io-6.2.1.tgz#e3f7826ebc4140db9bbaa9021ad6b1efb175878f" - integrity sha512-ECceEFcAaNRybd3lsGQKas3ZlMVjN3cyWwMP25D2i0zWfyiytVbTpRPa34qrr+FHddtpBVOmq4H/DCv1O0lZRA== - dependencies: - "@types/cookie" "^0.4.1" - "@types/cors" "^2.8.12" - "@types/node" ">=10.0.0" - accepts "~1.3.4" - base64id "2.0.0" - cookie "~0.4.1" - cors "~2.8.5" - debug "~4.3.1" - engine.io-parser "~5.0.3" - ws "~8.2.3" - -ent@~2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/ent/-/ent-2.2.0.tgz#e964219325a21d05f44466a2f686ed6ce5f5dd1d" - integrity sha1-6WQhkyWiHQX0RGai9obtbOX13R0= - -es-abstract@^1.18.0-next.1, es-abstract@^1.18.0-next.2: - version "1.18.5" - resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.18.5.tgz#9b10de7d4c206a3581fd5b2124233e04db49ae19" - integrity sha512-DDggyJLoS91CkJjgauM5c0yZMjiD1uK3KcaCeAmffGwZ+ODWzOkPN4QwRbsK5DOFf06fywmyLci3ZD8jLGhVYA== - dependencies: - call-bind "^1.0.2" - es-to-primitive "^1.2.1" - function-bind "^1.1.1" - get-intrinsic "^1.1.1" - has "^1.0.3" - has-symbols "^1.0.2" - internal-slot "^1.0.3" - is-callable "^1.2.3" - is-negative-zero "^2.0.1" - is-regex "^1.1.3" - is-string "^1.0.6" - object-inspect "^1.11.0" - object-keys "^1.1.1" - object.assign "^4.1.2" - string.prototype.trimend "^1.0.4" - string.prototype.trimstart "^1.0.4" - unbox-primitive "^1.0.1" - -es-to-primitive@^1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/es-to-primitive/-/es-to-primitive-1.2.1.tgz#e55cd4c9cdc188bcefb03b366c736323fc5c898a" - integrity sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA== - dependencies: - is-callable "^1.1.4" - is-date-object "^1.0.1" - is-symbol "^1.0.2" - -es6-object-assign@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/es6-object-assign/-/es6-object-assign-1.1.0.tgz#c2c3582656247c39ea107cb1e6652b6f9f24523c" - integrity sha1-wsNYJlYkfDnqEHyx5mUrb58kUjw= - -es6-promise@^4.0.3: - version "4.2.8" - resolved "https://registry.yarnpkg.com/es6-promise/-/es6-promise-4.2.8.tgz#4eb21594c972bc40553d276e510539143db53e0a" - integrity sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w== - -es6-promisify@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/es6-promisify/-/es6-promisify-5.0.0.tgz#5109d62f3e56ea967c4b63505aef08291c8a5203" - integrity sha1-UQnWLz5W6pZ8S2NQWu8IKRyKUgM= - dependencies: - es6-promise "^4.0.3" - -escalade@^3.1.1: - version "3.1.1" - resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.1.1.tgz#d8cfdc7000965c5a0174b4a82eaa5c0552742e40" - integrity sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw== - -escape-html@~1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/escape-html/-/escape-html-1.0.3.tgz#0258eae4d3d0c0974de1c169188ef0051d1d1988" - integrity sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg= - -escape-string-regexp@^1.0.5: - version "1.0.5" - resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" - integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ= - -esutils@^2.0.2: - version "2.0.3" - resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.3.tgz#74d2eb4de0b8da1293711910d50775b9b710ef64" - integrity sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g== - -event-stream@=3.3.4: - version "3.3.4" - resolved "https://registry.yarnpkg.com/event-stream/-/event-stream-3.3.4.tgz#4ab4c9a0f5a54db9338b4c34d86bfce8f4b35571" - integrity sha1-SrTJoPWlTbkzi0w02Gv86PSzVXE= - dependencies: - duplexer "~0.1.1" - from "~0" - map-stream "~0.1.0" - pause-stream "0.0.11" - split "0.3" - stream-combiner "~0.0.4" - through "~2.3.1" - -eventemitter3@^4.0.0: - version "4.0.7" - resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-4.0.7.tgz#2de9b68f6528d5644ef5c59526a1b4a07306169f" - integrity sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw== - -events@^3.2.0: - version "3.3.0" - resolved "https://registry.yarnpkg.com/events/-/events-3.3.0.tgz#31a95ad0a924e2d2c419a813aeb2c4e878ea7400" - integrity sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q== - -evp_bytestokey@^1.0.0, evp_bytestokey@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/evp_bytestokey/-/evp_bytestokey-1.0.3.tgz#7fcbdb198dc71959432efe13842684e0525acb02" - integrity sha512-/f2Go4TognH/KvCISP7OUsHn85hT9nUkxxA9BEWxFn+Oj9o8ZNLm/40hdlgSLyuOimsrTKLUMEorQexp/aPQeA== - dependencies: - md5.js "^1.3.4" - safe-buffer "^5.1.1" - -extend@^3.0.0: - version "3.0.2" - resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.2.tgz#f8b1136b4071fbd8eb140aff858b1019ec2915fa" - integrity sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g== - -fill-range@^7.0.1: - version "7.0.1" - resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.0.1.tgz#1919a6a7c75fe38b2c7c77e5198535da9acdda40" - integrity sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ== - dependencies: - to-regex-range "^5.0.1" - -finalhandler@1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/finalhandler/-/finalhandler-1.1.2.tgz#b7e7d000ffd11938d0fdb053506f6ebabe9f587d" - integrity sha512-aAWcW57uxVNrQZqFXjITpW3sIUQmHGG3qSb9mUah9MgMC4NeWhNOlNjXEYq3HjRAvL6arUviZGGJsBg6z0zsWA== - dependencies: - debug "2.6.9" - encodeurl "~1.0.2" - escape-html "~1.0.3" - on-finished "~2.3.0" - parseurl "~1.3.3" - statuses "~1.5.0" - unpipe "~1.0.0" - -flatted@^3.2.4: - version "3.2.4" - resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.2.4.tgz#28d9969ea90661b5134259f312ab6aa7929ac5e2" - integrity sha512-8/sOawo8tJ4QOBX8YlQBMxL8+RLZfxMQOif9o0KUKTNTjMYElWPE0r/m5VNFxTRd0NSw8qSy8dajrwX4RYI1Hw== - -follow-redirects@^1.0.0: - version "1.14.8" - resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.8.tgz#016996fb9a11a100566398b1c6839337d7bfa8fc" - integrity sha512-1x0S9UVJHsQprFcEC/qnNzBLcIxsjAV905f/UkQxbclCsoTWlacCNOpQa/anodLl2uaEKFhfWOvM2Qg77+15zA== - -foreach@^2.0.5: - version "2.0.5" - resolved "https://registry.yarnpkg.com/foreach/-/foreach-2.0.5.tgz#0bee005018aeb260d0a3af3ae658dd0136ec1b99" - integrity sha1-C+4AUBiusmDQo6865ljdATbsG5k= - -from@~0: - version "0.1.7" - resolved "https://registry.yarnpkg.com/from/-/from-0.1.7.tgz#83c60afc58b9c56997007ed1a768b3ab303a44fe" - integrity sha1-g8YK/Fi5xWmXAH7Rp2izqzA6RP4= - -fs-extra@^10.0.0: - version "10.0.0" - resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-10.0.0.tgz#9ff61b655dde53fb34a82df84bb214ce802e17c1" - integrity sha512-C5owb14u9eJwizKGdchcDUQeFtlSHHthBk8pbX9Vc1PFZrLombudjDnNns88aYslCyF6IY5SUw3Roz6xShcEIQ== - dependencies: - graceful-fs "^4.2.0" - jsonfile "^6.0.1" - universalify "^2.0.0" - -fs.realpath@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" - integrity sha1-FQStJSMVjKpA20onh8sBQRmU6k8= - -fsevents@~2.3.2: - version "2.3.2" - resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a" - integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA== - -function-bind@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d" - integrity sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A== - -gensync@^1.0.0-beta.2: - version "1.0.0-beta.2" - resolved "https://registry.yarnpkg.com/gensync/-/gensync-1.0.0-beta.2.tgz#32a6ee76c3d7f52d46b2b1ae5d93fea8580a25e0" - integrity sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg== - -get-caller-file@^2.0.5: - version "2.0.5" - resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e" - integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg== - -get-intrinsic@^1.0.2, get-intrinsic@^1.1.0, get-intrinsic@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/get-intrinsic/-/get-intrinsic-1.1.1.tgz#15f59f376f855c446963948f0d24cd3637b4abc6" - integrity sha512-kWZrnVM42QCiEA2Ig1bG8zjoIMOgxWwYCEeNdwY6Tv/cOSeGpcoX4pXHfKUxNKVoArnrEr2e9srnAxxGIraS9Q== - dependencies: - function-bind "^1.1.1" - has "^1.0.3" - has-symbols "^1.0.1" - -glob-parent@~5.1.2: - version "5.1.2" - resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4" - integrity sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow== - dependencies: - is-glob "^4.0.1" - -glob@^7.0.5, glob@^7.1.3, glob@^7.1.6, glob@^7.1.7: - version "7.1.7" - resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.7.tgz#3b193e9233f01d42d0b3f78294bbeeb418f94a90" - integrity sha512-OvD9ENzPLbegENnYP5UUfJIirTg4+XwMWGaQfQTY0JenxNvvIKP3U3/tAQSPIu/lHxXYSZmpXlUHeqAIdKzBLQ== - dependencies: - fs.realpath "^1.0.0" - inflight "^1.0.4" - inherits "2" - minimatch "^3.0.4" - once "^1.3.0" - path-is-absolute "^1.0.0" - -globals@^11.1.0: - version "11.12.0" - resolved "https://registry.yarnpkg.com/globals/-/globals-11.12.0.tgz#ab8795338868a0babd8525758018c2a7eb95c42e" - integrity sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA== - -graceful-fs@^4.1.6, graceful-fs@^4.2.0, graceful-fs@^4.2.6: - version "4.2.9" - resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.9.tgz#041b05df45755e587a24942279b9d113146e1c96" - integrity sha512-NtNxqUcXgpW2iMrfqSfR73Glt39K+BLwWsPs94yR63v45T0Wbej7eRmL5cWfwEgqXnmjQp3zaJTshdRW/qC2ZQ== - -has-bigints@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/has-bigints/-/has-bigints-1.0.1.tgz#64fe6acb020673e3b78db035a5af69aa9d07b113" - integrity sha512-LSBS2LjbNBTf6287JEbEzvJgftkF5qFkmCo9hDRpAzKhUOlJ+hx8dd4USs00SgsUNwc4617J9ki5YtEClM2ffA== - -has-flag@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd" - integrity sha1-tdRU3CGZriJWmfNGfloH87lVuv0= - -has-flag@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b" - integrity sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ== - -has-symbols@^1.0.1, has-symbols@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/has-symbols/-/has-symbols-1.0.2.tgz#165d3070c00309752a1236a479331e3ac56f1423" - integrity sha512-chXa79rL/UC2KlX17jo3vRGz0azaWEx5tGqZg5pO3NUyEJVB17dMruQlzCCOfUvElghKcm5194+BCRvi2Rv/Gw== - -has@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/has/-/has-1.0.3.tgz#722d7cbfc1f6aa8241f16dd814e011e1f41e8796" - integrity sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw== - dependencies: - function-bind "^1.1.1" - -hash-base@^3.0.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/hash-base/-/hash-base-3.1.0.tgz#55c381d9e06e1d2997a883b4a3fddfe7f0d3af33" - integrity sha512-1nmYp/rhMDiE7AYkDw+lLwlAzz0AntGIe51F3RfFfEqyQ3feY2eI/NcwC6umIQVOASPMsWJLJScWKSSvzL9IVA== - dependencies: - inherits "^2.0.4" - readable-stream "^3.6.0" - safe-buffer "^5.2.0" - -hash.js@^1.0.0, hash.js@^1.0.3: - version "1.1.7" - resolved "https://registry.yarnpkg.com/hash.js/-/hash.js-1.1.7.tgz#0babca538e8d4ee4a0f8988d68866537a003cf42" - integrity sha512-taOaskGt4z4SOANNseOviYDvjEJinIkRgmp7LbKP2YTTmVxWBl87s/uzK9r+44BclBSp2X7K1hqeNfz9JbBeXA== - dependencies: - inherits "^2.0.3" - minimalistic-assert "^1.0.1" - -hmac-drbg@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/hmac-drbg/-/hmac-drbg-1.0.1.tgz#d2745701025a6c775a6c545793ed502fc0c649a1" - integrity sha1-0nRXAQJabHdabFRXk+1QL8DGSaE= - dependencies: - hash.js "^1.0.3" - minimalistic-assert "^1.0.0" - minimalistic-crypto-utils "^1.0.1" - -html-escaper@^2.0.0: - version "2.0.2" - resolved "https://registry.yarnpkg.com/html-escaper/-/html-escaper-2.0.2.tgz#dfd60027da36a36dfcbe236262c00a5822681453" - integrity sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg== - -http-errors@1.7.2: - version "1.7.2" - resolved "https://registry.yarnpkg.com/http-errors/-/http-errors-1.7.2.tgz#4f5029cf13239f31036e5b2e55292bcfbcc85c8f" - integrity sha512-uUQBt3H/cSIVfch6i1EuPNy/YsRSOUBXTVfZ+yR7Zjez3qjBz6i9+i4zjNaoqcoFVI4lQJ5plg63TvGfRSDCRg== - dependencies: - depd "~1.1.2" - inherits "2.0.3" - setprototypeof "1.1.1" - statuses ">= 1.5.0 < 2" - toidentifier "1.0.0" - -http-proxy@^1.18.1: - version "1.18.1" - resolved "https://registry.yarnpkg.com/http-proxy/-/http-proxy-1.18.1.tgz#401541f0534884bbf95260334e72f88ee3976549" - integrity sha512-7mz/721AbnJwIVbnaSv1Cz3Am0ZLT/UBwkC92VlxhXv/k/BBQfM2fXElQNC27BVGr0uwUpplYPQM9LnaBMR5NQ== - dependencies: - eventemitter3 "^4.0.0" - follow-redirects "^1.0.0" - requires-port "^1.0.0" - -https-browserify@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/https-browserify/-/https-browserify-1.0.0.tgz#ec06c10e0a34c0f2faf199f7fd7fc78fffd03c73" - integrity sha1-7AbBDgo0wPL68Zn3/X/Hj//QPHM= - -https-proxy-agent@^2.2.1: - version "2.2.4" - resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-2.2.4.tgz#4ee7a737abd92678a293d9b34a1af4d0d08c787b" - integrity sha512-OmvfoQ53WLjtA9HeYP9RNrWMJzzAz1JGaSFr1nijg0PVR1JaD/xbJq1mdEIIlxGpXp9eSe/O2LgU9DJmTPd0Eg== - dependencies: - agent-base "^4.3.0" - debug "^3.1.0" - -https-proxy-agent@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-4.0.0.tgz#702b71fb5520a132a66de1f67541d9e62154d82b" - integrity sha512-zoDhWrkR3of1l9QAL8/scJZyLu8j/gBkcwcaQOZh7Gyh/+uJQzGVETdgT30akuwkpL8HTRfssqI3BZuV18teDg== - dependencies: - agent-base "5" - debug "4" - -iconv-lite@0.4.24: - version "0.4.24" - resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.24.tgz#2022b4b25fbddc21d2f524974a474aafe733908b" - integrity sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA== - dependencies: - safer-buffer ">= 2.1.2 < 3" - -ieee754@^1.1.13: - version "1.2.1" - resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.2.1.tgz#8eb7a10a63fff25d15a57b001586d177d1b0d352" - integrity sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA== - -inflight@^1.0.4: - version "1.0.6" - resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" - integrity sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk= - dependencies: - once "^1.3.0" - wrappy "1" - -inherits@2, inherits@^2.0.1, inherits@^2.0.3, inherits@^2.0.4, inherits@~2.0.4: - version "2.0.4" - resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" - integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== - -inherits@2.0.3: - version "2.0.3" - resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" - integrity sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4= - -inline-source-map@~0.6.0: - version "0.6.2" - resolved "https://registry.yarnpkg.com/inline-source-map/-/inline-source-map-0.6.2.tgz#f9393471c18a79d1724f863fa38b586370ade2a5" - integrity sha1-+Tk0ccGKedFyT4Y/o4tYY3Ct4qU= - dependencies: - source-map "~0.5.3" - -internal-slot@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/internal-slot/-/internal-slot-1.0.3.tgz#7347e307deeea2faac2ac6205d4bc7d34967f59c" - integrity sha512-O0DB1JC/sPyZl7cIo78n5dR7eUSwwpYPiXRhTzNxZVAMUuB8vlnRFyLxdrVToks6XPLVnFfbzaVd5WLjhgg+vA== - dependencies: - get-intrinsic "^1.1.0" - has "^1.0.3" - side-channel "^1.0.4" - -is-arguments@^1.0.4: - version "1.1.0" - resolved "https://registry.yarnpkg.com/is-arguments/-/is-arguments-1.1.0.tgz#62353031dfbee07ceb34656a6bde59efecae8dd9" - integrity sha512-1Ij4lOMPl/xB5kBDn7I+b2ttPMKa8szhEIrXDuXQD/oe3HJLTLhqhgGspwgyGd6MOywBUqVvYicF72lkgDnIHg== - dependencies: - call-bind "^1.0.0" - -is-bigint@^1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/is-bigint/-/is-bigint-1.0.2.tgz#ffb381442503235ad245ea89e45b3dbff040ee5a" - integrity sha512-0JV5+SOCQkIdzjBK9buARcV804Ddu7A0Qet6sHi3FimE9ne6m4BGQZfRn+NZiXbBk4F4XmHfDZIipLj9pX8dSA== - -is-binary-path@~2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/is-binary-path/-/is-binary-path-2.1.0.tgz#ea1f7f3b80f064236e83470f86c09c254fb45b09" - integrity sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw== - dependencies: - binary-extensions "^2.0.0" - -is-boolean-object@^1.1.0: - version "1.1.1" - resolved "https://registry.yarnpkg.com/is-boolean-object/-/is-boolean-object-1.1.1.tgz#3c0878f035cb821228d350d2e1e36719716a3de8" - integrity sha512-bXdQWkECBUIAcCkeH1unwJLIpZYaa5VvuygSyS/c2lf719mTKZDU5UdDRlpd01UjADgmW8RfqaP+mRaVPdr/Ng== - dependencies: - call-bind "^1.0.2" - -is-callable@^1.1.4, is-callable@^1.2.3: - version "1.2.3" - resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.2.3.tgz#8b1e0500b73a1d76c70487636f368e519de8db8e" - integrity sha512-J1DcMe8UYTBSrKezuIUTUwjXsho29693unXM2YhJUTR2txK/eG47bvNa/wipPFmZFgr/N6f1GA66dv0mEyTIyQ== - -is-core-module@^2.2.0: - version "2.5.0" - resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.5.0.tgz#f754843617c70bfd29b7bd87327400cda5c18491" - integrity sha512-TXCMSDsEHMEEZ6eCA8rwRDbLu55MRGmrctljsBX/2v1d9/GzqHOxW5c5oPSgrUt2vBFXebu9rGqckXGPWOlYpg== - dependencies: - has "^1.0.3" - -is-date-object@^1.0.1: - version "1.0.4" - resolved "https://registry.yarnpkg.com/is-date-object/-/is-date-object-1.0.4.tgz#550cfcc03afada05eea3dd30981c7b09551f73e5" - integrity sha512-/b4ZVsG7Z5XVtIxs/h9W8nvfLgSAyKYdtGWQLbqy6jA1icmgjf8WCoTKgeS4wy5tYaPePouzFMANbnj94c2Z+A== - -is-extglob@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2" - integrity sha1-qIwCU1eR8C7TfHahueqXc8gz+MI= - -is-fullwidth-code-point@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz#f116f8064fe90b3f7844a38997c0b75051269f1d" - integrity sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg== - -is-generator-function@^1.0.7: - version "1.0.9" - resolved "https://registry.yarnpkg.com/is-generator-function/-/is-generator-function-1.0.9.tgz#e5f82c2323673e7fcad3d12858c83c4039f6399c" - integrity sha512-ZJ34p1uvIfptHCN7sFTjGibB9/oBg17sHqzDLfuwhvmN/qLVvIQXRQ8licZQ35WJ8KuEQt/etnnzQFI9C9Ue/A== - -is-glob@^4.0.1, is-glob@~4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.1.tgz#7567dbe9f2f5e2467bc77ab83c4a29482407a5dc" - integrity sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg== - dependencies: - is-extglob "^2.1.1" - -is-nan@^1.2.1: - version "1.3.2" - resolved "https://registry.yarnpkg.com/is-nan/-/is-nan-1.3.2.tgz#043a54adea31748b55b6cd4e09aadafa69bd9e1d" - integrity sha512-E+zBKpQ2t6MEo1VsonYmluk9NxGrbzpeeLC2xIViuO2EjU2xsXsBPwTr3Ykv9l08UYEVEdWeRZNouaZqF6RN0w== - dependencies: - call-bind "^1.0.0" - define-properties "^1.1.3" - -is-negative-zero@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/is-negative-zero/-/is-negative-zero-2.0.1.tgz#3de746c18dda2319241a53675908d8f766f11c24" - integrity sha512-2z6JzQvZRa9A2Y7xC6dQQm4FSTSTNWjKIYYTt4246eMTJmIo0Q+ZyOsU66X8lxK1AbB92dFeglPLrhwpeRKO6w== - -is-number-object@^1.0.4: - version "1.0.5" - resolved "https://registry.yarnpkg.com/is-number-object/-/is-number-object-1.0.5.tgz#6edfaeed7950cff19afedce9fbfca9ee6dd289eb" - integrity sha512-RU0lI/n95pMoUKu9v1BZP5MBcZuNSVJkMkAG2dJqC4z2GlkGUNeH68SuHuBKBD/XFe+LHZ+f9BKkLET60Niedw== - -is-number@^7.0.0: - version "7.0.0" - resolved "https://registry.yarnpkg.com/is-number/-/is-number-7.0.0.tgz#7535345b896734d5f80c4d06c50955527a14f12b" - integrity sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng== - -is-regex@^1.1.3: - version "1.1.3" - resolved "https://registry.yarnpkg.com/is-regex/-/is-regex-1.1.3.tgz#d029f9aff6448b93ebbe3f33dac71511fdcbef9f" - integrity sha512-qSVXFz28HM7y+IWX6vLCsexdlvzT1PJNFSBuaQLQ5o0IEw8UDYW6/2+eCMVyIsbM8CNLX2a/QWmSpyxYEHY7CQ== - dependencies: - call-bind "^1.0.2" - has-symbols "^1.0.2" - -is-running@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/is-running/-/is-running-2.1.0.tgz#30a73ff5cc3854e4fc25490809e9f5abf8de09e0" - integrity sha1-MKc/9cw4VOT8JUkICen1q/jeCeA= - -is-string@^1.0.5, is-string@^1.0.6: - version "1.0.6" - resolved "https://registry.yarnpkg.com/is-string/-/is-string-1.0.6.tgz#3fe5d5992fb0d93404f32584d4b0179a71b54a5f" - integrity sha512-2gdzbKUuqtQ3lYNrUTQYoClPhm7oQu4UdpSZMp1/DGgkHBT8E2Z1l0yMdb6D4zNAxwDiMv8MdulKROJGNl0Q0w== - -is-symbol@^1.0.2, is-symbol@^1.0.3: - version "1.0.4" - resolved "https://registry.yarnpkg.com/is-symbol/-/is-symbol-1.0.4.tgz#a6dac93b635b063ca6872236de88910a57af139c" - integrity sha512-C/CPBqKWnvdcxqIARxyOh4v1UUEOCHpgDa0WYgpKDFMszcrPcffg5uhwSgPCLD2WWxmq6isisz87tzT01tuGhg== - dependencies: - has-symbols "^1.0.2" - -is-typed-array@^1.1.3: - version "1.1.5" - resolved "https://registry.yarnpkg.com/is-typed-array/-/is-typed-array-1.1.5.tgz#f32e6e096455e329eb7b423862456aa213f0eb4e" - integrity sha512-S+GRDgJlR3PyEbsX/Fobd9cqpZBuvUS+8asRqYDMLCb2qMzt1oz5m5oxQCxOgUDxiWsOVNi4yaF+/uvdlHlYug== - dependencies: - available-typed-arrays "^1.0.2" - call-bind "^1.0.2" - es-abstract "^1.18.0-next.2" - foreach "^2.0.5" - has-symbols "^1.0.1" - -isbinaryfile@^4.0.8: - version "4.0.8" - resolved "https://registry.yarnpkg.com/isbinaryfile/-/isbinaryfile-4.0.8.tgz#5d34b94865bd4946633ecc78a026fc76c5b11fcf" - integrity sha512-53h6XFniq77YdW+spoRrebh0mnmTxRPTlcuIArO57lmMdq4uBKFKaeTjnb92oYWrSn/LVL+LT+Hap2tFQj8V+w== - -isexe@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" - integrity sha1-6PvzdNxVb/iUehDcsFctYz8s+hA= - -istanbul-lib-coverage@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/istanbul-lib-coverage/-/istanbul-lib-coverage-3.0.0.tgz#f5944a37c70b550b02a78a5c3b2055b280cec8ec" - integrity sha512-UiUIqxMgRDET6eR+o5HbfRYP1l0hqkWOs7vNxC/mggutCMUIhWMm8gAHb8tHlyfD3/l6rlgNA5cKdDzEAf6hEg== - -istanbul-lib-instrument@^4.0.0: - version "4.0.3" - resolved "https://registry.yarnpkg.com/istanbul-lib-instrument/-/istanbul-lib-instrument-4.0.3.tgz#873c6fff897450118222774696a3f28902d77c1d" - integrity sha512-BXgQl9kf4WTCPCCpmFGoJkz/+uhvm7h7PFKUYxh7qarQd3ER33vHG//qaE8eN25l07YqZPpHXU9I09l/RD5aGQ== - dependencies: - "@babel/core" "^7.7.5" - "@istanbuljs/schema" "^0.1.2" - istanbul-lib-coverage "^3.0.0" - semver "^6.3.0" - -istanbul-lib-report@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/istanbul-lib-report/-/istanbul-lib-report-3.0.0.tgz#7518fe52ea44de372f460a76b5ecda9ffb73d8a6" - integrity sha512-wcdi+uAKzfiGT2abPpKZ0hSU1rGQjUQnLvtY5MpQ7QCTahD3VODhcu4wcfY1YtkGaDD5yuydOLINXsfbus9ROw== - dependencies: - istanbul-lib-coverage "^3.0.0" - make-dir "^3.0.0" - supports-color "^7.1.0" - -istanbul-lib-source-maps@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/istanbul-lib-source-maps/-/istanbul-lib-source-maps-4.0.0.tgz#75743ce6d96bb86dc7ee4352cf6366a23f0b1ad9" - integrity sha512-c16LpFRkR8vQXyHZ5nLpY35JZtzj1PQY1iZmesUbf1FZHbIupcWfjgOXBY9YHkLEQ6puz1u4Dgj6qmU/DisrZg== - dependencies: - debug "^4.1.1" - istanbul-lib-coverage "^3.0.0" - source-map "^0.6.1" - -istanbul-reports@^3.0.0: - version "3.0.2" - resolved "https://registry.yarnpkg.com/istanbul-reports/-/istanbul-reports-3.0.2.tgz#d593210e5000683750cb09fc0644e4b6e27fd53b" - integrity sha512-9tZvz7AiR3PEDNGiV9vIouQ/EAcqMXFmkcA1CDFTwOB98OZVDL0PH9glHotf5Ugp6GCOTypfzGWI/OqjWNCRUw== - dependencies: - html-escaper "^2.0.0" - istanbul-lib-report "^3.0.0" - -jasmine-core@^4.1.0: - version "4.5.0" - resolved "https://registry.yarnpkg.com/jasmine-core/-/jasmine-core-4.5.0.tgz#1a6bd0bde3f60996164311c88a0995d67ceda7c3" - integrity sha512-9PMzyvhtocxb3aXJVOPqBDswdgyAeSB81QnLop4npOpbqnheaTEwPc9ZloQeVswugPManznQBjD8kWDTjlnHuw== - -"jasmine-core@link:../node_modules/jasmine-core": - version "0.0.0" - -"jasmine@link:../node_modules/jasmine": - version "0.0.0" - -js-tokens@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" - integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ== - -jsesc@^2.5.1: - version "2.5.2" - resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-2.5.2.tgz#80564d2e483dacf6e8ef209650a67df3f0c283a4" - integrity sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA== - -jsesc@~0.5.0: - version "0.5.0" - resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-0.5.0.tgz#e7dee66e35d6fc16f710fe91d5cf69f70f08911d" - integrity sha1-597mbjXW/Bb3EP6R1c9p9w8IkR0= - -json-stringify-safe@^5.0.1: - version "5.0.1" - resolved "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb" - integrity sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus= - -json5@^2.1.2: - version "2.2.3" - resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.3.tgz#78cd6f1a19bdc12b73db5ad0c61efd66c1e29283" - integrity sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg== - -jsonfile@^6.0.1: - version "6.1.0" - resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-6.1.0.tgz#bc55b2634793c679ec6403094eb13698a6ec0aae" - integrity sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ== - dependencies: - universalify "^2.0.0" - optionalDependencies: - graceful-fs "^4.1.6" - -karma-browserstack-launcher@~1.6.0: - version "1.6.0" - resolved "https://registry.yarnpkg.com/karma-browserstack-launcher/-/karma-browserstack-launcher-1.6.0.tgz#2f6000647073e77ae296653b8830b279669766ef" - integrity sha512-Y/UWPdHZkHIVH2To4GWHCTzmrsB6H7PBWy6pw+TWz5sr4HW2mcE+Uj6qWgoVNxvQU1Pfn5LQQzI6EQ65p8QbiQ== - dependencies: - browserstack "~1.5.1" - browserstack-local "^1.3.7" - q "~1.5.0" - -karma-chrome-launcher@~3.1.1: - version "3.1.1" - resolved "https://registry.yarnpkg.com/karma-chrome-launcher/-/karma-chrome-launcher-3.1.1.tgz#baca9cc071b1562a1db241827257bfe5cab597ea" - integrity sha512-hsIglcq1vtboGPAN+DGCISCFOxW+ZVnIqhDQcCMqqCp+4dmJ0Qpq5QAjkbA0X2L9Mi6OBkHi2Srrbmm7pUKkzQ== - dependencies: - which "^1.2.1" - -karma-commonjs@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/karma-commonjs/-/karma-commonjs-1.0.0.tgz#8681d5d7d606628c5f00a36e6aef3cf943c6b0a9" - integrity sha1-hoHV19YGYoxfAKNuau88+UPGsKk= - -karma-jasmine-html-reporter@^2.0.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/karma-jasmine-html-reporter/-/karma-jasmine-html-reporter-2.1.0.tgz#f951ad00b08d61d03595402c914d1a589c4930e3" - integrity sha512-sPQE1+nlsn6Hwb5t+HHwyy0A1FNCVKuL1192b+XNauMYWThz2kweiBVW1DqloRpVvZIJkIoHVB7XRpK78n1xbQ== - -karma-jasmine@~5.1.0: - version "5.1.0" - resolved "https://registry.yarnpkg.com/karma-jasmine/-/karma-jasmine-5.1.0.tgz#3af4558a6502fa16856a0f346ec2193d4b884b2f" - integrity sha512-i/zQLFrfEpRyQoJF9fsCdTMOF5c2dK7C7OmsuKg2D0YSsuZSfQDiLuaiktbuio6F2wiCsZSnSnieIQ0ant/uzQ== - dependencies: - jasmine-core "^4.1.0" - -karma-typescript-es6-transform@^5.0.2: - version "5.5.1" - resolved "https://registry.yarnpkg.com/karma-typescript-es6-transform/-/karma-typescript-es6-transform-5.5.1.tgz#bb1061279e22b0259496c037e3014719cc6b3344" - integrity sha512-5iCFir1hLGdWlFEZk5+hfHKu9sDlSEAt1fJO46v8oqElszlMLVjoGQtSzb9E4uWg9fHo7mlRnjFhwM+WKScQHQ== - dependencies: - "@babel/core" "^7.11.1" - "@babel/preset-env" "^7.11.0" - acorn-walk "^8.0.2" - log4js "^6.3.0" - magic-string "^0.25.7" - -karma-typescript@~5.5.3: - version "5.5.3" - resolved "https://registry.yarnpkg.com/karma-typescript/-/karma-typescript-5.5.3.tgz#29c04d9677f8bd78dfacd89e8fa6f475dd25aba2" - integrity sha512-l1FHurolXEBIzRa9ExpNtjzysAhsi/vLpTazpwLHWWK86mknvVpqor6pRZ5Nid7jvOPrTBqAq0JRuLgiCdRkFw== - dependencies: - acorn "^8.1.0" - acorn-walk "^8.0.2" - assert "^2.0.0" - async "^3.0.1" - browser-resolve "^2.0.0" - browserify-zlib "^0.2.0" - buffer "^5.4.3" - combine-source-map "^0.8.0" - console-browserify "^1.2.0" - constants-browserify "^1.0.0" - convert-source-map "^1.7.0" - crypto-browserify "^3.12.0" - diff "^4.0.1" - domain-browser "^4.16.0" - events "^3.2.0" - glob "^7.1.6" - https-browserify "^1.0.0" - istanbul-lib-coverage "^3.0.0" - istanbul-lib-instrument "^4.0.0" - istanbul-lib-report "^3.0.0" - istanbul-lib-source-maps "^4.0.0" - istanbul-reports "^3.0.0" - json-stringify-safe "^5.0.1" - lodash "^4.17.19" - log4js "^6.3.0" - minimatch "^3.0.4" - os-browserify "^0.3.0" - pad "^3.2.0" - path-browserify "^1.0.0" - process "^0.11.10" - punycode "^2.1.1" - querystring-es3 "^0.2.1" - readable-stream "^3.1.1" - source-map "^0.7.3" - stream-browserify "^3.0.0" - stream-http "^3.1.0" - string_decoder "^1.3.0" - timers-browserify "^2.0.11" - tmp "^0.2.1" - tty-browserify "^0.0.1" - url "^0.11.0" - util "^0.12.1" - vm-browserify "^1.1.2" - -karma@~6.4.0: - version "6.4.0" - resolved "https://registry.yarnpkg.com/karma/-/karma-6.4.0.tgz#82652dfecdd853ec227b74ed718a997028a99508" - integrity sha512-s8m7z0IF5g/bS5ONT7wsOavhW4i4aFkzD4u4wgzAQWT4HGUeWI3i21cK2Yz6jndMAeHETp5XuNsRoyGJZXVd4w== - dependencies: - "@colors/colors" "1.5.0" - body-parser "^1.19.0" - braces "^3.0.2" - chokidar "^3.5.1" - connect "^3.7.0" - di "^0.0.1" - dom-serialize "^2.2.1" - glob "^7.1.7" - graceful-fs "^4.2.6" - http-proxy "^1.18.1" - isbinaryfile "^4.0.8" - lodash "^4.17.21" - log4js "^6.4.1" - mime "^2.5.2" - minimatch "^3.0.4" - mkdirp "^0.5.5" - qjobs "^1.2.0" - range-parser "^1.2.1" - rimraf "^3.0.2" - socket.io "^4.4.1" - source-map "^0.6.1" - tmp "^0.2.1" - ua-parser-js "^0.7.30" - yargs "^16.1.1" - -lodash.debounce@^4.0.8: - version "4.0.8" - resolved "https://registry.yarnpkg.com/lodash.debounce/-/lodash.debounce-4.0.8.tgz#82d79bff30a67c4005ffd5e2515300ad9ca4d7af" - integrity sha1-gteb/zCmfEAF/9XiUVMArZyk168= - -lodash.memoize@~3.0.3: - version "3.0.4" - resolved "https://registry.yarnpkg.com/lodash.memoize/-/lodash.memoize-3.0.4.tgz#2dcbd2c287cbc0a55cc42328bd0c736150d53e3f" - integrity sha1-LcvSwofLwKVcxCMovQxzYVDVPj8= - -lodash@^4.17.19, lodash@^4.17.21: - version "4.17.21" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c" - integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg== - -log4js@^6.3.0, log4js@^6.4.1: - version "6.4.1" - resolved "https://registry.yarnpkg.com/log4js/-/log4js-6.4.1.tgz#9d3a8bf2c31c1e213fe3fc398a6053f7a2bc53e8" - integrity sha512-iUiYnXqAmNKiIZ1XSAitQ4TmNs8CdZYTAWINARF3LjnsLN8tY5m0vRwd6uuWj/yNY0YHxeZodnbmxKFUOM2rMg== - dependencies: - date-format "^4.0.3" - debug "^4.3.3" - flatted "^3.2.4" - rfdc "^1.3.0" - streamroller "^3.0.2" - -magic-string@^0.25.7: - version "0.25.7" - resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.25.7.tgz#3f497d6fd34c669c6798dcb821f2ef31f5445051" - integrity sha512-4CrMT5DOHTDk4HYDlzmwu4FVCcIYI8gauveasrdCu2IKIFOJ3f0v/8MDGJCDL9oD2ppz/Av1b0Nj345H9M+XIA== - dependencies: - sourcemap-codec "^1.4.4" - -make-dir@^3.0.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-3.1.0.tgz#415e967046b3a7f1d185277d84aa58203726a13f" - integrity sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw== - dependencies: - semver "^6.0.0" - -map-stream@~0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/map-stream/-/map-stream-0.1.0.tgz#e56aa94c4c8055a16404a0674b78f215f7c8e194" - integrity sha1-5WqpTEyAVaFkBKBnS3jyFffI4ZQ= - -md5.js@^1.3.4: - version "1.3.5" - resolved "https://registry.yarnpkg.com/md5.js/-/md5.js-1.3.5.tgz#b5d07b8e3216e3e27cd728d72f70d1e6a342005f" - integrity sha512-xitP+WxNPcTTOgnTJcrhM0xvdPepipPSf3I8EIpGKeFLjt3PlJLIDG3u8EX53ZIubkb+5U2+3rELYpEhHhzdkg== - dependencies: - hash-base "^3.0.0" - inherits "^2.0.1" - safe-buffer "^5.1.2" - -media-typer@0.3.0: - version "0.3.0" - resolved "https://registry.yarnpkg.com/media-typer/-/media-typer-0.3.0.tgz#8710d7af0aa626f8fffa1ce00168545263255748" - integrity sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g= - -miller-rabin@^4.0.0: - version "4.0.1" - resolved "https://registry.yarnpkg.com/miller-rabin/-/miller-rabin-4.0.1.tgz#f080351c865b0dc562a8462966daa53543c78a4d" - integrity sha512-115fLhvZVqWwHPbClyntxEVfVDfl9DLLTuJvq3g2O/Oxi8AiNouAHvDSzHS0viUJc+V5vm3eq91Xwqn9dp4jRA== - dependencies: - bn.js "^4.0.0" - brorand "^1.0.1" - -mime-db@1.51.0: - version "1.51.0" - resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.51.0.tgz#d9ff62451859b18342d960850dc3cfb77e63fb0c" - integrity sha512-5y8A56jg7XVQx2mbv1lu49NR4dokRnhZYTtL+KGfaa27uq4pSTXkwQkFJl4pkRMyNFz/EtYDSkiiEHx3F7UN6g== - -mime-db@1.52.0: - version "1.52.0" - resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.52.0.tgz#bbabcdc02859f4987301c856e3387ce5ec43bf70" - integrity sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg== - -mime-types@~2.1.24: - version "2.1.34" - resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.34.tgz#5a712f9ec1503511a945803640fafe09d3793c24" - integrity sha512-6cP692WwGIs9XXdOO4++N+7qjqv0rqxxVvJ3VHPh/Sc9mVZcQP+ZGhkKiTvWMQRr2tbHkJP/Yn7Y0npb3ZBs4A== - dependencies: - mime-db "1.51.0" - -mime-types@~2.1.34: - version "2.1.35" - resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.35.tgz#381a871b62a734450660ae3deee44813f70d959a" - integrity sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw== - dependencies: - mime-db "1.52.0" - -mime@^2.5.2: - version "2.5.2" - resolved "https://registry.yarnpkg.com/mime/-/mime-2.5.2.tgz#6e3dc6cc2b9510643830e5f19d5cb753da5eeabe" - integrity sha512-tqkh47FzKeCPD2PUiPB6pkbMzsCasjxAfC62/Wap5qrUWcb+sFasXUC5I3gYM5iBM8v/Qpn4UK0x+j0iHyFPDg== - -minimalistic-assert@^1.0.0, minimalistic-assert@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz#2e194de044626d4a10e7f7fbc00ce73e83e4d5c7" - integrity sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A== - -minimalistic-crypto-utils@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz#f6c00c1c0b082246e5c4d99dfb8c7c083b2b582a" - integrity sha1-9sAMHAsIIkblxNmd+4x8CDsrWCo= - -minimatch@^3.0.4: - version "3.1.2" - resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b" - integrity sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw== - dependencies: - brace-expansion "^1.1.7" - -minimist@^1.2.5: - version "1.2.6" - resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.6.tgz#8637a5b759ea0d6e98702cfb3a9283323c93af44" - integrity sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q== - -mkdirp@^0.5.5: - version "0.5.5" - resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.5.tgz#d91cefd62d1436ca0f41620e251288d420099def" - integrity sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ== - dependencies: - minimist "^1.2.5" - -ms@2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" - integrity sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g= - -ms@2.1.2: - version "2.1.2" - resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" - integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== - -ms@^2.1.1: - version "2.1.3" - resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2" - integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA== - -negotiator@0.6.3: - version "0.6.3" - resolved "https://registry.yarnpkg.com/negotiator/-/negotiator-0.6.3.tgz#58e323a72fedc0d6f9cd4d31fe49f51479590ccd" - integrity sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg== - -node-releases@^1.1.73: - version "1.1.73" - resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-1.1.73.tgz#dd4e81ddd5277ff846b80b52bb40c49edf7a7b20" - integrity sha512-uW7fodD6pyW2FZNZnp/Z3hvWKeEW1Y8R1+1CnErE8cXFXzl5blBOoVB41CvMer6P6Q0S5FXDwcHgFd1Wj0U9zg== - -normalize-path@^3.0.0, normalize-path@~3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-3.0.0.tgz#0dcd69ff23a1c9b11fd0978316644a0388216a65" - integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA== - -object-assign@^4: - version "4.1.1" - resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" - integrity sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg== - -object-inspect@^1.11.0, object-inspect@^1.9.0: - version "1.11.0" - resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.11.0.tgz#9dceb146cedd4148a0d9e51ab88d34cf509922b1" - integrity sha512-jp7ikS6Sd3GxQfZJPyH3cjcbJF6GZPClgdV+EFygjFLQ5FmW/dRUnTd9PQ9k0JhoNDabWFbpF1yCdSWCC6gexg== - -object-is@^1.0.1: - version "1.1.5" - resolved "https://registry.yarnpkg.com/object-is/-/object-is-1.1.5.tgz#b9deeaa5fc7f1846a0faecdceec138e5778f53ac" - integrity sha512-3cyDsyHgtmi7I7DfSSI2LDp6SK2lwvtbg0p0R1e0RvTqF5ceGx+K2dfSjm1bKDMVCFEDAQvy+o8c6a7VujOddw== - dependencies: - call-bind "^1.0.2" - define-properties "^1.1.3" - -object-keys@^1.0.12, object-keys@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.1.1.tgz#1c47f272df277f3b1daf061677d9c82e2322c60e" - integrity sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA== - -object.assign@^4.1.0, object.assign@^4.1.2: - version "4.1.2" - resolved "https://registry.yarnpkg.com/object.assign/-/object.assign-4.1.2.tgz#0ed54a342eceb37b38ff76eb831a0e788cb63940" - integrity sha512-ixT2L5THXsApyiUPYKmW+2EHpXXe5Ii3M+f4e+aJFAHao5amFRW6J0OO6c/LU8Be47utCx2GL89hxGB6XSmKuQ== - dependencies: - call-bind "^1.0.0" - define-properties "^1.1.3" - has-symbols "^1.0.1" - object-keys "^1.1.1" - -on-finished@~2.3.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/on-finished/-/on-finished-2.3.0.tgz#20f1336481b083cd75337992a16971aa2d906947" - integrity sha1-IPEzZIGwg811M3mSoWlxqi2QaUc= - dependencies: - ee-first "1.1.1" - -once@^1.3.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" - integrity sha1-WDsap3WWHUsROsF9nFC6753Xa9E= - dependencies: - wrappy "1" - -os-browserify@^0.3.0: - version "0.3.0" - resolved "https://registry.yarnpkg.com/os-browserify/-/os-browserify-0.3.0.tgz#854373c7f5c2315914fc9bfc6bd8238fdda1ec27" - integrity sha1-hUNzx/XCMVkU/Jv8a9gjj92h7Cc= - -pad@^3.2.0: - version "3.2.0" - resolved "https://registry.yarnpkg.com/pad/-/pad-3.2.0.tgz#be7a1d1cb6757049b4ad5b70e71977158fea95d1" - integrity sha512-2u0TrjcGbOjBTJpyewEl4hBO3OeX5wWue7eIFPzQTg6wFSvoaHcBTTUY5m+n0hd04gmTCPuY0kCpVIVuw5etwg== - dependencies: - wcwidth "^1.0.1" - -pako@~1.0.5: - version "1.0.11" - resolved "https://registry.yarnpkg.com/pako/-/pako-1.0.11.tgz#6c9599d340d54dfd3946380252a35705a6b992bf" - integrity sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw== - -parse-asn1@^5.0.0, parse-asn1@^5.1.5: - version "5.1.6" - resolved "https://registry.yarnpkg.com/parse-asn1/-/parse-asn1-5.1.6.tgz#385080a3ec13cb62a62d39409cb3e88844cdaed4" - integrity sha512-RnZRo1EPU6JBnra2vGHj0yhp6ebyjBZpmUCLHWiFhxlzvBCCpAuZ7elsBp1PVAbQN0/04VD/19rfzlBSwLstMw== - dependencies: - asn1.js "^5.2.0" - browserify-aes "^1.0.0" - evp_bytestokey "^1.0.0" - pbkdf2 "^3.0.3" - safe-buffer "^5.1.1" - -parseurl@~1.3.3: - version "1.3.3" - resolved "https://registry.yarnpkg.com/parseurl/-/parseurl-1.3.3.tgz#9da19e7bee8d12dff0513ed5b76957793bc2e8d4" - integrity sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ== - -path-browserify@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/path-browserify/-/path-browserify-1.0.1.tgz#d98454a9c3753d5790860f16f68867b9e46be1fd" - integrity sha512-b7uo2UCUOYZcnF/3ID0lulOJi/bafxa1xPe7ZPsammBSpjSWQkjNxlt635YGS2MiR9GjvuXCtz2emr3jbsz98g== - -path-is-absolute@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" - integrity sha1-F0uSaHNVNP+8es5r9TpanhtcX18= - -path-parse@^1.0.6: - version "1.0.7" - resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.7.tgz#fbc114b60ca42b30d9daf5858e4bd68bbedb6735" - integrity sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw== - -pause-stream@0.0.11: - version "0.0.11" - resolved "https://registry.yarnpkg.com/pause-stream/-/pause-stream-0.0.11.tgz#fe5a34b0cbce12b5aa6a2b403ee2e73b602f1445" - integrity sha1-/lo0sMvOErWqaitAPuLnO2AvFEU= - dependencies: - through "~2.3" - -pbkdf2@^3.0.3: - version "3.1.2" - resolved "https://registry.yarnpkg.com/pbkdf2/-/pbkdf2-3.1.2.tgz#dd822aa0887580e52f1a039dc3eda108efae3075" - integrity sha512-iuh7L6jA7JEGu2WxDwtQP1ddOpaJNC4KlDEFfdQajSGgGPNi4OyDc2R7QnbY2bR9QjBVGwgvTdNJZoE7RaxUMA== - dependencies: - create-hash "^1.1.2" - create-hmac "^1.1.4" - ripemd160 "^2.0.1" - safe-buffer "^5.0.1" - sha.js "^2.4.8" - -picomatch@^2.0.4, picomatch@^2.2.1: - version "2.3.0" - resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.0.tgz#f1f061de8f6a4bf022892e2d128234fb98302972" - integrity sha512-lY1Q/PiJGC2zOv/z391WOTD+Z02bCgsFfvxoXXf6h7kv9o+WmsmzYqrAwY63sNgOxE4xEdq0WyUnXfKeBrSvYw== - -process@^0.11.10: - version "0.11.10" - resolved "https://registry.yarnpkg.com/process/-/process-0.11.10.tgz#7332300e840161bda3e69a1d1d91a7d4bc16f182" - integrity sha1-czIwDoQBYb2j5podHZGn1LwW8YI= - -ps-tree@=1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/ps-tree/-/ps-tree-1.2.0.tgz#5e7425b89508736cdd4f2224d028f7bb3f722ebd" - integrity sha512-0VnamPPYHl4uaU/nSFeZZpR21QAWRz+sRv4iW9+v/GS/J5U5iZB5BNN6J0RMoOvdx2gWM2+ZFMIm58q24e4UYA== - dependencies: - event-stream "=3.3.4" - -public-encrypt@^4.0.0: - version "4.0.3" - resolved "https://registry.yarnpkg.com/public-encrypt/-/public-encrypt-4.0.3.tgz#4fcc9d77a07e48ba7527e7cbe0de33d0701331e0" - integrity sha512-zVpa8oKZSz5bTMTFClc1fQOnyyEzpl5ozpi1B5YcvBrdohMjH2rfsBtyXcuNuwjsDIXmBYlF2N5FlJYhR29t8Q== - dependencies: - bn.js "^4.1.0" - browserify-rsa "^4.0.0" - create-hash "^1.1.0" - parse-asn1 "^5.0.0" - randombytes "^2.0.1" - safe-buffer "^5.1.2" - -punycode@1.3.2: - version "1.3.2" - resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.3.2.tgz#9653a036fb7c1ee42342f2325cceefea3926c48d" - integrity sha1-llOgNvt8HuQjQvIyXM7v6jkmxI0= - -punycode@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec" - integrity sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A== - -q@~1.5.0: - version "1.5.1" - resolved "https://registry.yarnpkg.com/q/-/q-1.5.1.tgz#7e32f75b41381291d04611f1bf14109ac00651d7" - integrity sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc= - -qjobs@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/qjobs/-/qjobs-1.2.0.tgz#c45e9c61800bd087ef88d7e256423bdd49e5d071" - integrity sha512-8YOJEHtxpySA3fFDyCRxA+UUV+fA+rTWnuWvylOK/NCjhY+b4ocCtmu8TtsWb+mYeU+GCHf/S66KZF/AsteKHg== - -qs@6.7.0: - version "6.7.0" - resolved "https://registry.yarnpkg.com/qs/-/qs-6.7.0.tgz#41dc1a015e3d581f1621776be31afb2876a9b1bc" - integrity sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ== - -querystring-es3@^0.2.1: - version "0.2.1" - resolved "https://registry.yarnpkg.com/querystring-es3/-/querystring-es3-0.2.1.tgz#9ec61f79049875707d69414596fd907a4d711e73" - integrity sha1-nsYfeQSYdXB9aUFFlv2Qek1xHnM= - -querystring@0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/querystring/-/querystring-0.2.0.tgz#b209849203bb25df820da756e747005878521620" - integrity sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA= - -randombytes@^2.0.0, randombytes@^2.0.1, randombytes@^2.0.5: - version "2.1.0" - resolved "https://registry.yarnpkg.com/randombytes/-/randombytes-2.1.0.tgz#df6f84372f0270dc65cdf6291349ab7a473d4f2a" - integrity sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ== - dependencies: - safe-buffer "^5.1.0" - -randomfill@^1.0.3: - version "1.0.4" - resolved "https://registry.yarnpkg.com/randomfill/-/randomfill-1.0.4.tgz#c92196fc86ab42be983f1bf31778224931d61458" - integrity sha512-87lcbR8+MhcWcUiQ+9e+Rwx8MyR2P7qnt15ynUlbm3TU/fjbgz4GsvfSUDTemtCCtVCqb4ZcEFlyPNTh9bBTLw== - dependencies: - randombytes "^2.0.5" - safe-buffer "^5.1.0" - -range-parser@^1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/range-parser/-/range-parser-1.2.1.tgz#3cf37023d199e1c24d1a55b84800c2f3e6468031" - integrity sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg== - -raw-body@2.4.0: - version "2.4.0" - resolved "https://registry.yarnpkg.com/raw-body/-/raw-body-2.4.0.tgz#a1ce6fb9c9bc356ca52e89256ab59059e13d0332" - integrity sha512-4Oz8DUIwdvoa5qMJelxipzi/iJIi40O5cGV1wNYp5hvZP8ZN0T+jiNkL0QepXs+EsQ9XJ8ipEDoiH70ySUJP3Q== - dependencies: - bytes "3.1.0" - http-errors "1.7.2" - iconv-lite "0.4.24" - unpipe "1.0.0" - -readable-stream@^3.1.1, readable-stream@^3.5.0, readable-stream@^3.6.0: - version "3.6.0" - resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-3.6.0.tgz#337bbda3adc0706bd3e024426a286d4b4b2c9198" - integrity sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA== - dependencies: - inherits "^2.0.3" - string_decoder "^1.1.1" - util-deprecate "^1.0.1" - -readdirp@~3.6.0: - version "3.6.0" - resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-3.6.0.tgz#74a370bd857116e245b29cc97340cd431a02a6c7" - integrity sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA== - dependencies: - picomatch "^2.2.1" - -regenerate-unicode-properties@^8.2.0: - version "8.2.0" - resolved "https://registry.yarnpkg.com/regenerate-unicode-properties/-/regenerate-unicode-properties-8.2.0.tgz#e5de7111d655e7ba60c057dbe9ff37c87e65cdec" - integrity sha512-F9DjY1vKLo/tPePDycuH3dn9H1OTPIkVD9Kz4LODu+F2C75mgjAJ7x/gwy6ZcSNRAAkhNlJSOHRe8k3p+K9WhA== - dependencies: - regenerate "^1.4.0" - -regenerate@^1.4.0: - version "1.4.2" - resolved "https://registry.yarnpkg.com/regenerate/-/regenerate-1.4.2.tgz#b9346d8827e8f5a32f7ba29637d398b69014848a" - integrity sha512-zrceR/XhGYU/d/opr2EKO7aRHUeiBI8qjtfHqADTwZd6Szfy16la6kqD0MIUs5z5hx6AaKa+PixpPrR289+I0A== - -regenerator-runtime@^0.13.4: - version "0.13.9" - resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.9.tgz#8925742a98ffd90814988d7566ad30ca3b263b52" - integrity sha512-p3VT+cOEgxFsRRA9X4lkI1E+k2/CtnKtU4gcxyaCUreilL/vqI6CdZ3wxVUx3UOUg+gnUOQQcRI7BmSI656MYA== - -regenerator-transform@^0.14.2: - version "0.14.5" - resolved "https://registry.yarnpkg.com/regenerator-transform/-/regenerator-transform-0.14.5.tgz#c98da154683671c9c4dcb16ece736517e1b7feb4" - integrity sha512-eOf6vka5IO151Jfsw2NO9WpGX58W6wWmefK3I1zEGr0lOD0u8rwPaNqQL1aRxUaxLeKO3ArNh3VYg1KbaD+FFw== - dependencies: - "@babel/runtime" "^7.8.4" - -regexpu-core@^4.7.1: - version "4.7.1" - resolved "https://registry.yarnpkg.com/regexpu-core/-/regexpu-core-4.7.1.tgz#2dea5a9a07233298fbf0db91fa9abc4c6e0f8ad6" - integrity sha512-ywH2VUraA44DZQuRKzARmw6S66mr48pQVva4LBeRhcOltJ6hExvWly5ZjFLYo67xbIxb6W1q4bAGtgfEl20zfQ== - dependencies: - regenerate "^1.4.0" - regenerate-unicode-properties "^8.2.0" - regjsgen "^0.5.1" - regjsparser "^0.6.4" - unicode-match-property-ecmascript "^1.0.4" - unicode-match-property-value-ecmascript "^1.2.0" - -regjsgen@^0.5.1: - version "0.5.2" - resolved "https://registry.yarnpkg.com/regjsgen/-/regjsgen-0.5.2.tgz#92ff295fb1deecbf6ecdab2543d207e91aa33733" - integrity sha512-OFFT3MfrH90xIW8OOSyUrk6QHD5E9JOTeGodiJeBS3J6IwlgzJMNE/1bZklWz5oTg+9dCMyEetclvCVXOPoN3A== - -regjsparser@^0.6.4: - version "0.6.9" - resolved "https://registry.yarnpkg.com/regjsparser/-/regjsparser-0.6.9.tgz#b489eef7c9a2ce43727627011429cf833a7183e6" - integrity sha512-ZqbNRz1SNjLAiYuwY0zoXW8Ne675IX5q+YHioAGbCw4X96Mjl2+dcX9B2ciaeyYjViDAfvIjFpQjJgLttTEERQ== - dependencies: - jsesc "~0.5.0" - -require-directory@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42" - integrity sha1-jGStX9MNqxyXbiNE/+f3kqam30I= - -requires-port@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/requires-port/-/requires-port-1.0.0.tgz#925d2601d39ac485e091cf0da5c6e694dc3dcaff" - integrity sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8= - -resolve@^1.14.2, resolve@^1.17.0: - version "1.20.0" - resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.20.0.tgz#629a013fb3f70755d6f0b7935cc1c2c5378b1975" - integrity sha512-wENBPt4ySzg4ybFQW2TT1zMQucPK95HSh/nq2CFTZVOGut2+pQvSsgtda4d26YrYcr067wjbmzOG8byDPBX63A== - dependencies: - is-core-module "^2.2.0" - path-parse "^1.0.6" - -rfdc@^1.3.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/rfdc/-/rfdc-1.3.0.tgz#d0b7c441ab2720d05dc4cf26e01c89631d9da08b" - integrity sha512-V2hovdzFbOi77/WajaSMXk2OLm+xNIeQdMMuB7icj7bk6zi2F8GGAxigcnDFpJHbNyNcgyJDiP+8nOrY5cZGrA== - -rimraf@^3.0.0, rimraf@^3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-3.0.2.tgz#f1a5402ba6220ad52cc1282bac1ae3aa49fd061a" - integrity sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA== - dependencies: - glob "^7.1.3" - -rimraf@~2.5.2: - version "2.5.4" - resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.5.4.tgz#96800093cbf1a0c86bd95b4625467535c29dfa04" - integrity sha1-loAAk8vxoMhr2VtGJUZ1NcKd+gQ= - dependencies: - glob "^7.0.5" - -ripemd160@^2.0.0, ripemd160@^2.0.1: - version "2.0.2" - resolved "https://registry.yarnpkg.com/ripemd160/-/ripemd160-2.0.2.tgz#a1c1a6f624751577ba5d07914cbc92850585890c" - integrity sha512-ii4iagi25WusVoiC4B4lq7pbXfAp3D9v5CwfkY33vffw2+pkDjY1D8GaN7spsxvCSx8dkPqOZCEZyfxcmJG2IA== - dependencies: - hash-base "^3.0.0" - inherits "^2.0.1" - -safe-buffer@^5.0.1, safe-buffer@^5.1.0, safe-buffer@^5.1.1, safe-buffer@^5.1.2, safe-buffer@^5.2.0, safe-buffer@~5.2.0: - version "5.2.1" - resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" - integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== - -safe-buffer@~5.1.1: - version "5.1.2" - resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" - integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g== - -"safer-buffer@>= 2.1.2 < 3", safer-buffer@^2.1.0: - version "2.1.2" - resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a" - integrity sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg== - -semver@7.0.0: - version "7.0.0" - resolved "https://registry.yarnpkg.com/semver/-/semver-7.0.0.tgz#5f3ca35761e47e05b206c6daff2cf814f0316b8e" - integrity sha512-+GB6zVA9LWh6zovYQLALHwv5rb2PHGlJi3lfiqIHxR0uuwCgefcOJc59v9fv1w8GbStwxuuqqAjI9NMAOOgq1A== - -semver@^6.0.0, semver@^6.1.1, semver@^6.1.2, semver@^6.3.0: - version "6.3.1" - resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.1.tgz#556d2ef8689146e46dcea4bfdd095f3434dffcb4" - integrity sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA== - -setimmediate@^1.0.4: - version "1.0.5" - resolved "https://registry.yarnpkg.com/setimmediate/-/setimmediate-1.0.5.tgz#290cbb232e306942d7d7ea9b83732ab7856f8285" - integrity sha1-KQy7Iy4waULX1+qbg3Mqt4VvgoU= - -setprototypeof@1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/setprototypeof/-/setprototypeof-1.1.1.tgz#7e95acb24aa92f5885e0abef5ba131330d4ae683" - integrity sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw== - -sha.js@^2.4.0, sha.js@^2.4.8: - version "2.4.11" - resolved "https://registry.yarnpkg.com/sha.js/-/sha.js-2.4.11.tgz#37a5cf0b81ecbc6943de109ba2960d1b26584ae7" - integrity sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ== - dependencies: - inherits "^2.0.1" - safe-buffer "^5.0.1" - -side-channel@^1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/side-channel/-/side-channel-1.0.4.tgz#efce5c8fdc104ee751b25c58d4290011fa5ea2cf" - integrity sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw== - dependencies: - call-bind "^1.0.0" - get-intrinsic "^1.0.2" - object-inspect "^1.9.0" - -socket.io-adapter@~2.4.0: - version "2.4.0" - resolved "https://registry.yarnpkg.com/socket.io-adapter/-/socket.io-adapter-2.4.0.tgz#b50a4a9ecdd00c34d4c8c808224daa1a786152a6" - integrity sha512-W4N+o69rkMEGVuk2D/cvca3uYsvGlMwsySWV447y99gUPghxq42BxqLNMndb+a1mm/5/7NeXVQS7RLa2XyXvYg== - -socket.io-parser@~4.0.4: - version "4.0.5" - resolved "https://registry.yarnpkg.com/socket.io-parser/-/socket.io-parser-4.0.5.tgz#cb404382c32324cc962f27f3a44058cf6e0552df" - integrity sha512-sNjbT9dX63nqUFIOv95tTVm6elyIU4RvB1m8dOeZt+IgWwcWklFDOdmGcfo3zSiRsnR/3pJkjY5lfoGqEe4Eig== - dependencies: - "@types/component-emitter" "^1.2.10" - component-emitter "~1.3.0" - debug "~4.3.1" - -socket.io@^4.4.1: - version "4.5.1" - resolved "https://registry.yarnpkg.com/socket.io/-/socket.io-4.5.1.tgz#aa7e73f8a6ce20ee3c54b2446d321bbb6b1a9029" - integrity sha512-0y9pnIso5a9i+lJmsCdtmTTgJFFSvNQKDnPQRz28mGNnxbmqYg2QPtJTLFxhymFZhAIn50eHAKzJeiNaKr+yUQ== - dependencies: - accepts "~1.3.4" - base64id "~2.0.0" - debug "~4.3.2" - engine.io "~6.2.0" - socket.io-adapter "~2.4.0" - socket.io-parser "~4.0.4" - -source-map@^0.5.0, source-map@~0.5.3: - version "0.5.7" - resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" - integrity sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w= - -source-map@^0.6.1: - version "0.6.1" - resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" - integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== - -source-map@^0.7.3: - version "0.7.3" - resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.7.3.tgz#5302f8169031735226544092e64981f751750383" - integrity sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ== - -sourcemap-codec@^1.4.4: - version "1.4.8" - resolved "https://registry.yarnpkg.com/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz#ea804bd94857402e6992d05a38ef1ae35a9ab4c4" - integrity sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA== - -split@0.3: - version "0.3.3" - resolved "https://registry.yarnpkg.com/split/-/split-0.3.3.tgz#cd0eea5e63a211dfff7eb0f091c4133e2d0dd28f" - integrity sha1-zQ7qXmOiEd//frDwkcQTPi0N0o8= - dependencies: - through "2" - -"statuses@>= 1.5.0 < 2", statuses@~1.5.0: - version "1.5.0" - resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.5.0.tgz#161c7dac177659fd9811f43771fa99381478628c" - integrity sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow= - -stream-browserify@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/stream-browserify/-/stream-browserify-3.0.0.tgz#22b0a2850cdf6503e73085da1fc7b7d0c2122f2f" - integrity sha512-H73RAHsVBapbim0tU2JwwOiXUj+fikfiaoYAKHF3VJfA0pe2BCzkhAHBlLG6REzE+2WNZcxOXjK7lkso+9euLA== - dependencies: - inherits "~2.0.4" - readable-stream "^3.5.0" - -stream-combiner@~0.0.4: - version "0.0.4" - resolved "https://registry.yarnpkg.com/stream-combiner/-/stream-combiner-0.0.4.tgz#4d5e433c185261dde623ca3f44c586bcf5c4ad14" - integrity sha1-TV5DPBhSYd3mI8o/RMWGvPXErRQ= - dependencies: - duplexer "~0.1.1" - -stream-http@^3.1.0: - version "3.2.0" - resolved "https://registry.yarnpkg.com/stream-http/-/stream-http-3.2.0.tgz#1872dfcf24cb15752677e40e5c3f9cc1926028b5" - integrity sha512-Oq1bLqisTyK3TSCXpPbT4sdeYNdmyZJv1LxpEm2vu1ZhK89kSE5YXwZc3cWk0MagGaKriBh9mCFbVGtO+vY29A== - dependencies: - builtin-status-codes "^3.0.0" - inherits "^2.0.4" - readable-stream "^3.6.0" - xtend "^4.0.2" - -streamroller@^3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/streamroller/-/streamroller-3.0.2.tgz#30418d0eee3d6c93ec897f892ed098e3a81e68b7" - integrity sha512-ur6y5S5dopOaRXBuRIZ1u6GC5bcEXHRZKgfBjfCglMhmIf+roVCECjvkEYzNQOXIN2/JPnkMPW/8B3CZoKaEPA== - dependencies: - date-format "^4.0.3" - debug "^4.1.1" - fs-extra "^10.0.0" - -string-width@^4.1.0, string-width@^4.2.0: - version "4.2.2" - resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.2.tgz#dafd4f9559a7585cfba529c6a0a4f73488ebd4c5" - integrity sha512-XBJbT3N4JhVumXE0eoLU9DCjcaF92KLNqTmFCnG1pf8duUxFGwtP6AD6nkjw9a3IdiRtL3E2w3JDiE/xi3vOeA== - dependencies: - emoji-regex "^8.0.0" - is-fullwidth-code-point "^3.0.0" - strip-ansi "^6.0.0" - -string.prototype.trimend@^1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/string.prototype.trimend/-/string.prototype.trimend-1.0.4.tgz#e75ae90c2942c63504686c18b287b4a0b1a45f80" - integrity sha512-y9xCjw1P23Awk8EvTpcyL2NIr1j7wJ39f+k6lvRnSMz+mz9CGz9NYPelDk42kOz6+ql8xjfK8oYzy3jAP5QU5A== - dependencies: - call-bind "^1.0.2" - define-properties "^1.1.3" - -string.prototype.trimstart@^1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/string.prototype.trimstart/-/string.prototype.trimstart-1.0.4.tgz#b36399af4ab2999b4c9c648bd7a3fb2bb26feeed" - integrity sha512-jh6e984OBfvxS50tdY2nRZnoC5/mLFKOREQfw8t5yytkoUsJRNxvI/E39qu1sD0OtWI3OC0XgKSmcWwziwYuZw== - dependencies: - call-bind "^1.0.2" - define-properties "^1.1.3" - -string_decoder@^1.1.1, string_decoder@^1.3.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.3.0.tgz#42f114594a46cf1a8e30b0a84f56c78c3edac21e" - integrity sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA== - dependencies: - safe-buffer "~5.2.0" - -strip-ansi@^6.0.0: - version "6.0.0" - resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.0.tgz#0b1571dd7669ccd4f3e06e14ef1eed26225ae532" - integrity sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w== - dependencies: - ansi-regex "^5.0.0" - -supports-color@^5.3.0: - version "5.5.0" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f" - integrity sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow== - dependencies: - has-flag "^3.0.0" - -supports-color@^7.1.0: - version "7.2.0" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-7.2.0.tgz#1b7dcdcb32b8138801b3e478ba6a51caa89648da" - integrity sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw== - dependencies: - has-flag "^4.0.0" - -temp-fs@^0.9.9: - version "0.9.9" - resolved "https://registry.yarnpkg.com/temp-fs/-/temp-fs-0.9.9.tgz#8071730437870720e9431532fe2814364f8803d7" - integrity sha1-gHFzBDeHByDpQxUy/igUNk+IA9c= - dependencies: - rimraf "~2.5.2" - -through@2, through@~2.3, through@~2.3.1: - version "2.3.8" - resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5" - integrity sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU= - -timers-browserify@^2.0.11: - version "2.0.12" - resolved "https://registry.yarnpkg.com/timers-browserify/-/timers-browserify-2.0.12.tgz#44a45c11fbf407f34f97bccd1577c652361b00ee" - integrity sha512-9phl76Cqm6FhSX9Xe1ZUAMLtm1BLkKj2Qd5ApyWkXzsMRaA7dgr81kf4wJmQf/hAvg8EEyJxDo3du/0KlhPiKQ== - dependencies: - setimmediate "^1.0.4" - -tmp@^0.2.1: - version "0.2.1" - resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.2.1.tgz#8457fc3037dcf4719c251367a1af6500ee1ccf14" - integrity sha512-76SUhtfqR2Ijn+xllcI5P1oyannHNHByD80W1q447gU3mp9G9PSpGdWmjUOHRDPiHYacIk66W7ubDTuPF3BEtQ== - dependencies: - rimraf "^3.0.0" - -to-fast-properties@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/to-fast-properties/-/to-fast-properties-2.0.0.tgz#dc5e698cbd079265bc73e0377681a4e4e83f616e" - integrity sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4= - -to-regex-range@^5.0.1: - version "5.0.1" - resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-5.0.1.tgz#1648c44aae7c8d988a326018ed72f5b4dd0392e4" - integrity sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ== - dependencies: - is-number "^7.0.0" - -toidentifier@1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/toidentifier/-/toidentifier-1.0.0.tgz#7e1be3470f1e77948bc43d94a3c8f4d7752ba553" - integrity sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw== - -tty-browserify@^0.0.1: - version "0.0.1" - resolved "https://registry.yarnpkg.com/tty-browserify/-/tty-browserify-0.0.1.tgz#3f05251ee17904dfd0677546670db9651682b811" - integrity sha512-C3TaO7K81YvjCgQH9Q1S3R3P3BtN3RIM8n+OvX4il1K1zgE8ZhI0op7kClgkxtutIE8hQrcrHBXvIheqKUUCxw== - -type-is@~1.6.17: - version "1.6.18" - resolved "https://registry.yarnpkg.com/type-is/-/type-is-1.6.18.tgz#4e552cd05df09467dcbc4ef739de89f2cf37c131" - integrity sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g== - dependencies: - media-typer "0.3.0" - mime-types "~2.1.24" - -ua-parser-js@^0.7.30: - version "0.7.33" - resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.33.tgz#1d04acb4ccef9293df6f70f2c3d22f3030d8b532" - integrity sha512-s8ax/CeZdK9R/56Sui0WM6y9OFREJarMRHqLB2EwkovemBxNQ+Bqu8GAsUnVcXKgphb++ghr/B2BZx4mahujPw== - -unbox-primitive@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/unbox-primitive/-/unbox-primitive-1.0.1.tgz#085e215625ec3162574dc8859abee78a59b14471" - integrity sha512-tZU/3NqK3dA5gpE1KtyiJUrEB0lxnGkMFHptJ7q6ewdZ8s12QrODwNbhIJStmJkd1QDXa1NRA8aF2A1zk/Ypyw== - dependencies: - function-bind "^1.1.1" - has-bigints "^1.0.1" - has-symbols "^1.0.2" - which-boxed-primitive "^1.0.2" - -unicode-canonical-property-names-ecmascript@^1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-1.0.4.tgz#2619800c4c825800efdd8343af7dd9933cbe2818" - integrity sha512-jDrNnXWHd4oHiTZnx/ZG7gtUTVp+gCcTTKr8L0HjlwphROEW3+Him+IpvC+xcJEFegapiMZyZe02CyuOnRmbnQ== - -unicode-match-property-ecmascript@^1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/unicode-match-property-ecmascript/-/unicode-match-property-ecmascript-1.0.4.tgz#8ed2a32569961bce9227d09cd3ffbb8fed5f020c" - integrity sha512-L4Qoh15vTfntsn4P1zqnHulG0LdXgjSO035fEpdtp6YxXhMT51Q6vgM5lYdG/5X3MjS+k/Y9Xw4SFCY9IkR0rg== - dependencies: - unicode-canonical-property-names-ecmascript "^1.0.4" - unicode-property-aliases-ecmascript "^1.0.4" - -unicode-match-property-value-ecmascript@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/unicode-match-property-value-ecmascript/-/unicode-match-property-value-ecmascript-1.2.0.tgz#0d91f600eeeb3096aa962b1d6fc88876e64ea531" - integrity sha512-wjuQHGQVofmSJv1uVISKLE5zO2rNGzM/KCYZch/QQvez7C1hUhBIuZ701fYXExuufJFMPhv2SyL8CyoIfMLbIQ== - -unicode-property-aliases-ecmascript@^1.0.4: - version "1.1.0" - resolved "https://registry.yarnpkg.com/unicode-property-aliases-ecmascript/-/unicode-property-aliases-ecmascript-1.1.0.tgz#dd57a99f6207bedff4628abefb94c50db941c8f4" - integrity sha512-PqSoPh/pWetQ2phoj5RLiaqIk4kCNwoV3CI+LfGmWLKI3rE3kl1h59XpX2BjgDrmbxD9ARtQobPGU1SguCYuQg== - -universalify@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/universalify/-/universalify-2.0.0.tgz#75a4984efedc4b08975c5aeb73f530d02df25717" - integrity sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ== - -unpipe@1.0.0, unpipe@~1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/unpipe/-/unpipe-1.0.0.tgz#b2bf4ee8514aae6165b4817829d21b2ef49904ec" - integrity sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw= - -url@^0.11.0: - version "0.11.0" - resolved "https://registry.yarnpkg.com/url/-/url-0.11.0.tgz#3838e97cfc60521eb73c525a8e55bfdd9e2e28f1" - integrity sha1-ODjpfPxgUh63PFJajlW/3Z4uKPE= - dependencies: - punycode "1.3.2" - querystring "0.2.0" - -util-deprecate@^1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" - integrity sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8= - -util@^0.12.0, util@^0.12.1: - version "0.12.4" - resolved "https://registry.yarnpkg.com/util/-/util-0.12.4.tgz#66121a31420df8f01ca0c464be15dfa1d1850253" - integrity sha512-bxZ9qtSlGUWSOy9Qa9Xgk11kSslpuZwaxCg4sNIDj6FLucDab2JxnHwyNTCpHMtK1MjoQiWQ6DiUMZYbSrO+Sw== - dependencies: - inherits "^2.0.3" - is-arguments "^1.0.4" - is-generator-function "^1.0.7" - is-typed-array "^1.1.3" - safe-buffer "^5.1.2" - which-typed-array "^1.1.2" - -utils-merge@1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/utils-merge/-/utils-merge-1.0.1.tgz#9f95710f50a267947b2ccc124741c1028427e713" - integrity sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM= - -vary@^1: - version "1.1.2" - resolved "https://registry.yarnpkg.com/vary/-/vary-1.1.2.tgz#2299f02c6ded30d4a5961b0b9f74524a18f634fc" - integrity sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg== - -vm-browserify@^1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/vm-browserify/-/vm-browserify-1.1.2.tgz#78641c488b8e6ca91a75f511e7a3b32a86e5dda0" - integrity sha512-2ham8XPWTONajOR0ohOKOHXkm3+gaBmGut3SRuu75xLd/RRaY6vqgh8NBYYk7+RW3u5AtzPQZG8F10LHkl0lAQ== - -void-elements@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/void-elements/-/void-elements-2.0.1.tgz#c066afb582bb1cb4128d60ea92392e94d5e9dbec" - integrity sha1-wGavtYK7HLQSjWDqkjkulNXp2+w= - -wcwidth@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/wcwidth/-/wcwidth-1.0.1.tgz#f0b0dcf915bc5ff1528afadb2c0e17b532da2fe8" - integrity sha1-8LDc+RW8X/FSivrbLA4XtTLaL+g= - dependencies: - defaults "^1.0.3" - -which-boxed-primitive@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/which-boxed-primitive/-/which-boxed-primitive-1.0.2.tgz#13757bc89b209b049fe5d86430e21cf40a89a8e6" - integrity sha512-bwZdv0AKLpplFY2KZRX6TvyuN7ojjr7lwkg6ml0roIy9YeuSr7JS372qlNW18UQYzgYK9ziGcerWqZOmEn9VNg== - dependencies: - is-bigint "^1.0.1" - is-boolean-object "^1.1.0" - is-number-object "^1.0.4" - is-string "^1.0.5" - is-symbol "^1.0.3" - -which-typed-array@^1.1.2: - version "1.1.4" - resolved "https://registry.yarnpkg.com/which-typed-array/-/which-typed-array-1.1.4.tgz#8fcb7d3ee5adf2d771066fba7cf37e32fe8711ff" - integrity sha512-49E0SpUe90cjpoc7BOJwyPHRqSAd12c10Qm2amdEZrJPCY2NDxaW01zHITrem+rnETY3dwrbH3UUrUwagfCYDA== - dependencies: - available-typed-arrays "^1.0.2" - call-bind "^1.0.0" - es-abstract "^1.18.0-next.1" - foreach "^2.0.5" - function-bind "^1.1.1" - has-symbols "^1.0.1" - is-typed-array "^1.1.3" - -which@^1.2.1: - version "1.3.1" - resolved "https://registry.yarnpkg.com/which/-/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a" - integrity sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ== - dependencies: - isexe "^2.0.0" - -wrap-ansi@^7.0.0: - version "7.0.0" - resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" - integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== - dependencies: - ansi-styles "^4.0.0" - string-width "^4.1.0" - strip-ansi "^6.0.0" - -wrappy@1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" - integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8= - -ws@~8.2.3: - version "8.2.3" - resolved "https://registry.yarnpkg.com/ws/-/ws-8.2.3.tgz#63a56456db1b04367d0b721a0b80cae6d8becbba" - integrity sha512-wBuoj1BDpC6ZQ1B7DWQBYVLphPWkm8i9Y0/3YdHjHKHiohOJ1ws+3OccDWtH+PoC9DZD5WOTrJvNbWvjS6JWaA== - -xtend@^4.0.2: - version "4.0.2" - resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.2.tgz#bb72779f5fa465186b1f438f674fa347fdb5db54" - integrity sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ== - -y18n@^5.0.5: - version "5.0.8" - resolved "https://registry.yarnpkg.com/y18n/-/y18n-5.0.8.tgz#7f4934d0f7ca8c56f95314939ddcd2dd91ce1d55" - integrity sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA== - -yargs-parser@^20.2.2: - version "20.2.9" - resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.9.tgz#2eb7dc3b0289718fc295f362753845c41a0c94ee" - integrity sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w== - -yargs@^16.1.1: - version "16.2.0" - resolved "https://registry.yarnpkg.com/yargs/-/yargs-16.2.0.tgz#1c82bf0f6b6a66eafce7ef30e376f49a12477f66" - integrity sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw== - dependencies: - cliui "^7.0.2" - escalade "^3.1.1" - get-caller-file "^2.0.5" - require-directory "^2.1.1" - string-width "^4.2.0" - y18n "^5.0.5" - yargs-parser "^20.2.2" diff --git a/tfjs-master/tfjs-converter/.babelrc b/tfjs-master/tfjs-converter/.babelrc deleted file mode 100644 index 9772b939a..000000000 --- a/tfjs-master/tfjs-converter/.babelrc +++ /dev/null @@ -1,13 +0,0 @@ -{ - "presets": [ - [ - "env", - { - "modules": false - } - ] - ], - "plugins": [ - "external-helpers" - ] -} diff --git a/tfjs-master/tfjs-converter/.npmignore b/tfjs-master/tfjs-converter/.npmignore deleted file mode 100644 index 43a845310..000000000 --- a/tfjs-master/tfjs-converter/.npmignore +++ /dev/null @@ -1,35 +0,0 @@ -.babelrc -.DS_Store -.idea/ -.pylintrc -.rpt2_cache -.travis.yml -.vscode -*.tgz -*.txt -**.yalc -**yalc.lock -cloudbuild.yml -coverage/ -demo/ -DEVELOPMENT.md -dist/**/*_test.d.ts -dist/**/*_test.js -docs/ -ISSUE_TEMPLATE.md -karma.conf.js -node_modules/ -npm-debug.log -package-lock.json -package/ -python/ -rollup.config.google.js -rollup.config.js -scripts/ -src/**/*_test.ts -test_results -tsconfig.json -tslint.json -yarn-error.log -yarn.lock -.git diff --git a/tfjs-master/tfjs-converter/.vscode/launch.json b/tfjs-master/tfjs-converter/.vscode/launch.json deleted file mode 100644 index df98d811f..000000000 --- a/tfjs-master/tfjs-converter/.vscode/launch.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "version": "0.2.0", - "configurations": [ - { - "name": "Python: Attach", - "type": "python", - "request": "attach", - "port": 5724, - "host": "localhost" - } - ], - "compounds": [] -} diff --git a/tfjs-master/tfjs-converter/.vscode/settings.json b/tfjs-master/tfjs-converter/.vscode/settings.json deleted file mode 100644 index 5f30a3cfd..000000000 --- a/tfjs-master/tfjs-converter/.vscode/settings.json +++ /dev/null @@ -1 +0,0 @@ -../../.vscode/settings.json \ No newline at end of file diff --git a/tfjs-master/tfjs-converter/.vscode/tasks.json b/tfjs-master/tfjs-converter/.vscode/tasks.json deleted file mode 100644 index 5edb3db96..000000000 --- a/tfjs-master/tfjs-converter/.vscode/tasks.json +++ /dev/null @@ -1 +0,0 @@ -../../.vscode/tasks.json \ No newline at end of file diff --git a/tfjs-master/tfjs-converter/BUILD.bazel b/tfjs-master/tfjs-converter/BUILD.bazel deleted file mode 100644 index ade7cd6c1..000000000 --- a/tfjs-master/tfjs-converter/BUILD.bazel +++ /dev/null @@ -1,149 +0,0 @@ -# Copyright 2021 Google LLC. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================= - -load("@bazel_skylib//rules:copy_file.bzl", "copy_file") -load("@build_bazel_rules_nodejs//:index.bzl", "js_library", "nodejs_test", "pkg_npm") -load("//tools:copy_to_dist.bzl", "copy_to_dist", "copy_ts_library_to_dist") -load("//tools:tfjs_bundle.bzl", "tfjs_bundle") - -package(default_visibility = ["//visibility:public"]) - -# Allow typescript rules in any package to reference this file -exports_files([ - "package.json", - "README.md", -]) - -nodejs_test( - name = "tfjs-converter_test", - data = [ - ":package_json", - "//tfjs-backend-cpu/src:tfjs-backend-cpu_lib", - "//tfjs-converter/metadata:kernels_to_ops", - "//tfjs-converter/src:tfjs-converter_test_lib", - ], - entry_point = "//tfjs-converter/src:run_tests.ts", - link_workspace_root = True, - tags = ["ci"], - # This fixes a race condition between this test and test_snippets_test where - # the wrong runfiles will be linked to node_modules/@tensorflow/tfjs-converter/dist. - # TODO(mattSoulanille): Assess whether we should apply this to all nodejs_test targets. - templated_args = ["--bazel_patch_module_resolver"], -) - -# Defined here because chdir must be a subdirectory of the directory the rule is -# defined in. -nodejs_test( - name = "test_snippets_test", - chdir = "tfjs-converter", - data = [ - ":tsconfig.json", - "//:tsconfig.json", - "//tfjs-backend-cpu/src:tfjs-backend-cpu_lib", - "//tfjs-converter/scripts:test_snippets_lib", - "//tfjs-converter/src:all_srcs", - ], - entry_point = "//tfjs-converter/scripts:test_snippets.ts", - link_workspace_root = True, - tags = [ - "ci", - # Run the test locally since it makes http requests. - "no-remote-exec", - "requires-network", - ], -) - -tfjs_bundle( - name = "tf-converter", - entry_point = "//tfjs-converter/src:index.ts", - external = [ - "@tensorflow/tfjs-core", - ], - globals = { - "@tensorflow/tfjs-core": "tf", - }, - umd_name = "tf", - deps = [ - "//tfjs-converter/src:tfjs-converter_lib", - "//tfjs-converter/src:tfjs-converter_src_lib", - ], -) - -copy_ts_library_to_dist( - name = "copy_src_to_dist", - srcs = [ - "//tfjs-converter/src:tfjs-converter_lib", - "//tfjs-converter/src:tfjs-converter_src_lib", - ], - root = "src", -) - -copy_to_dist( - name = "copy_bundles", - srcs = [ - ":tf-converter", - ":tf-converter.es2017", - ":tf-converter.es2017.min", - ":tf-converter.fesm", - ":tf-converter.fesm.min", - ":tf-converter.min", - ":tf-converter.node", - ], -) - -copy_file( - name = "copy_miniprogram", - src = ":tf-converter.min.js", - out = "dist/miniprogram/index.js", -) - -copy_file( - name = "copy_miniprogram_map", - src = ":tf-converter.min.js.map", - out = "dist/miniprogram/index.js.map", -) - -pkg_npm( - name = "tfjs-converter_pkg", - package_name = "@tensorflow/tfjs-converter", - srcs = [ - "README.md", - "package.json", - ], - tags = ["ci"], - deps = [ - ":copy_bundles", - ":copy_miniprogram", - ":copy_miniprogram_map", - ":copy_src_to_dist", - "//tfjs-converter/metadata:kernels_to_ops", - ], -) - -js_library( - name = "package_json", - package_name = "tfjs-converter", - srcs = [ - ":package.json", - ], -) - -test_suite( - name = "tests", - tests = [ - ":test_snippets_test", - ":tfjs-converter_test", - ], -) diff --git a/tfjs-master/tfjs-converter/DEVELOPMENT.md b/tfjs-master/tfjs-converter/DEVELOPMENT.md deleted file mode 100644 index 1f8b3b7f9..000000000 --- a/tfjs-master/tfjs-converter/DEVELOPMENT.md +++ /dev/null @@ -1,67 +0,0 @@ -# Notes for TensorFlow.js-Converter Developers - -## Python Development - -There are some Python libraries, binary and tests in the `python/` directory. - -It is recommended to do your Python development and testing in a -[virtualenv](https://virtualenv.pypa.io/en/stable/) or -[pipenv](https://docs.pipenv.org/). - -As a prerequisite, install the following dependencies for python testing -```sh -cd python -pip install -r requirements.txt -``` - -For Python linter, install `pylint`, e.g., -* `apt-get install -y pylint` - -To run the Python linter: -```sh -cd python -pylint tensorflowjs -``` - -To run the python unit tests, there are two options. You can choose the one that -you prefer. - -1. Run the tests using the `run-python-tests.sh` script: - - ```sh - cd python - ./run-python-tests.sh - ``` - -2. Run the tests using Bazel. See bazel installation guide - [here](https://docs.bazel.build/versions/master/install.html). Once bazel - is installed, do: - - ```sh - cd python - bazel test tensorflowjs/... - ``` - -Be sure to run the tests under **both** Python 2 and Python 3. - -### Building and testing the tensorflowjs pip package - -```sh -cd python - -# You need to specify a folder where the pip wheel file will be stored, e.g., -./build-pip-package.sh /tmp/my_tensorflowjs_pip - -# If the script succeeds, you can use `pip install` to install the pip package: - -pip install --force-reinstall \ - /tmp/my_tensorflowjs_pip/tensorflowjs-0.0.1-py2-none-any.whl -``` - -`build-pip-package.sh` provides a flag (`--test`) with which you can run a -test-on-install after building the pip package. Make sure you are using a -`virutalenv` or `pipenv` to avoid changing your base environmnet. - -```sh -./build-pip-package.sh --test /tmp/my_tensorflowjs_pip -``` diff --git a/tfjs-master/tfjs-converter/README.md b/tfjs-master/tfjs-converter/README.md deleted file mode 100644 index 6b4d69e81..000000000 --- a/tfjs-master/tfjs-converter/README.md +++ /dev/null @@ -1,563 +0,0 @@ -# Getting started - -**TensorFlow.js converter** is an open source library to load a pretrained -TensorFlow -[SavedModel](https://www.tensorflow.org/guide/saved_model) -or [TensorFlow Hub module](https://www.tensorflow.org/hub/) -into the browser and run inference through -[TensorFlow.js](https://js.tensorflow.org). - -__Note__: _Session bundle format have been deprecated. - -A 2-step process to import your model: - -1. A python pip package to convert a TensorFlow SavedModel or TensorFlow Hub -module to a web friendly format. If you already have a converted model, or are -using an already hosted model (e.g. MobileNet), skip this step. -2. [JavaScript API](./src/executor/graph_model.ts), for loading and running -inference. - -## Step 1: Converting a [TensorFlow SavedModel](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/saved_model/README.md), [TensorFlow Hub module](https://www.tensorflow.org/hub/), [Keras HDF5](https://keras.io/getting_started/faq/#what-are-my-options-for-saving-models), [tf.keras SavedModel](https://www.tensorflow.org/api_docs/python/tf/keras/saving/save_model), or [Flax/JAX model](http://github.com/google/flax) to a web-friendly format - -__0. Please make sure that you run in a Docker container or a virtual environment.__ - - The script pulls its own subset of TensorFlow, which might conflict with the - existing TensorFlow/Keras installation. - -__Note__: *Check that [`tf-nightly-cpu-2.0-preview`](https://pypi.org/project/tf-nightly-cpu-2.0-preview/#files) is available for your platform.* - -Most of the times, this means that you have to use Python 3.6.8 in your local -environment. To force Python 3.6.8 in your local project, you can install -[`pyenv`](https://github.com/pyenv/pyenv) and proceed as follows in the target -directory: - -```bash -pyenv install 3.6.8 -pyenv local 3.6.8 -``` - -Now, you can -[create and activate](https://packaging.python.org/guides/installing-using-pip-and-virtual-environments/) -a `venv` virtual environment in your current folder: - -```bash -virtualenv --no-site-packages venv -. venv/bin/activate -``` - -__1. Install the TensorFlow.js pip package:__ - -Install the library with interactive CLI: -```bash - pip install tensorflowjs[wizard] -``` - -__2. Run the converter script provided by the pip package:__ - -There are three way to trigger the model conversion, explain below: - -- The conversion wizard: `tensorflowjs_wizard` ([go to section](https://github.com/tensorflow/tfjs/blob/master/tfjs-converter/README.md#conversion-wizard-tensorflowjs_wizard)) -- Regular conversion script: `tensorflowjs_converter` ([go to section](https://github.com/tensorflow/tfjs/tree/master/tfjs-converter#regular-conversion-script-tensorflowjs_converter)) -- Calling a converter function in Python (Flax/JAX) ([go to section](https://github.com/tensorflow/tfjs/tree/master/tfjs-converter#calling-a-converter-function-in-python-flaxjax)) - -## Conversion wizard: `tensorflowjs_wizard` - -To start the conversion wizard: -```bash -tensorflowjs_wizard -``` - -This tool will walk you through the conversion process and provide you with -details explanations for each choice you need to make. Behind the scene it calls -the converter script (`tensorflowjs_converter`) in pip package. This is the -recommended way to convert a single model. - -There is also a dry run mode for the wizard, which will not perform the actual -conversion but only generate the command for `tensorflowjs_converter` command. -This generated command can be used in your own shell script. - -Here is an screen capture of the wizard in action. ![wizard](./tensorflowjs_wizard.gif) -```bash -tensorflowjs_wizard --dryrun -``` - -To convert a batch of models or integrate the conversion process into your own -script, you should use the tensorflowjs_converter script. - -## Regular conversion script: `tensorflowjs_converter` - -The converter expects a __TensorFlow SavedModel__, __TensorFlow Hub module__, -__TensorFlow.js JSON__ format, __Keras HDF5 model__, or __tf.keras SavedModel__ -for input. - -* __TensorFlow SavedModel__ example: - -```bash -tensorflowjs_converter \ - --input_format=tf_saved_model \ - --output_format=tfjs_graph_model \ - --signature_name=serving_default \ - --saved_model_tags=serve \ - /mobilenet/saved_model \ - /mobilenet/web_model -``` -* __TensorFlow Frozen Model__ example: - -__Note:__ Frozen model is a deprecated format and support is added for backward compatibility purpose. - -```bash -$ tensorflowjs_converter \ - --input_format=tf_frozen_model \ - --output_node_names='MobilenetV1/Predictions/Reshape_1' \ - /mobilenet/frozen_model.pb \ - /mobilenet/web_model -``` - -* __Tensorflow Hub module__ example: - -```bash -tensorflowjs_converter \ - --input_format=tf_hub \ - 'https://tfhub.dev/google/imagenet/mobilenet_v1_100_224/classification/1' \ - /mobilenet/web_model -``` - -* __Keras HDF5 model__ example: - -```bash -tensorflowjs_converter \ - --input_format=keras \ - /tmp/my_keras_model.h5 \ - /tmp/my_tfjs_model -``` - -* __tf.keras SavedModel__ example: - -```bash -tensorflowjs_converter \ - --input_format=keras_saved_model \ - /tmp/my_tf_keras_saved_model/1542211770 \ - /tmp/my_tfjs_model -``` - -Note that the input path used above is a subfolder that has a Unix epoch -time (1542211770) and is generated automatically by tensorflow when it -saved a tf.keras model in the SavedModel format. - -### Conversion Flags - -|Positional Arguments | Description | -|---|---| -|`input_path` | Full path of the saved model directory or TensorFlow Hub module handle or path.| -|`output_path` | Path for all output artifacts.| - - -| Options | Description -|---|---| -|`--input_format` | The format of input model, use `tf_saved_model` for SavedModel, `tf_hub` for TensorFlow Hub module, `tfjs_layers_model` for TensorFlow.js JSON format, and `keras` for Keras HDF5. | -|`--output_format`| The desired output format. Must be `tfjs_layers_model`, `tfjs_graph_model` or `keras`. Not all pairs of input-output formats are supported. Please file a [github issue](https://github.com/tensorflow/tfjs/issues) if your desired input-output pair is not supported.| -|`--saved_model_tags` | Only applicable to SavedModel conversion. Tags of the MetaGraphDef to load, in comma separated format. If there are no tags defined in the saved model, set it to empty string `saved_model_tags=''`. Defaults to `serve`.| -|`--signature_name` | Only applicable to TensorFlow SavedModel and Hub module conversion, signature to load. Defaults to `serving_default` for SavedModel and `default` for Hub module. See https://www.tensorflow.org/hub/common_signatures/.| -|`--strip_debug_ops` | Strips out TensorFlow debug operations `Print`, `Assert`, `CheckNumerics`. Defaults to `True`.| -|`--quantization_bytes` | (Deprecated) How many bytes to optionally quantize/compress the weights to. Valid values are 1 and 2. which will quantize int32 and float32 to 1 or 2 bytes respectively. The default (unquantized) size is 4 bytes.| -|`--quantize_float16` | Comma separated list of node names to apply float16 quantization. You can also use wildcard symbol (\*) to apply quantization to multiple nodes (e.g., conv/\*/weights). When the flag is provided without any nodes the default behavior will match all nodes. | -|`--quantize_uint8` | Comma separated list of node names to apply 1-byte affine quantization. You can also use wildcard symbol (\*) to apply quantization to multiple nodes (e.g., conv/\*/weights). When the flag is provided without any nodes the default behavior will match all nodes. | -|`--quantize_uint16` | Comma separated list of node names to apply 2-byte affine quantization. You can also use wildcard symbol (\*) to apply quantization to multiple nodes (e.g., conv/\*/weights). When the flag is provided without any nodes the default behavior will match all nodes. | -|`--weight_shard_size_bytes` | Shard size (in bytes) of the weight files. Only supported when `output_format` is `tfjs_layers_model` or `tfjs_graph_model`. Default size is 4 MB (4194304 bytes).| -|`--output_node_names`| Only applicable to Frozen Model. The names of the output nodes, separated by commas.| -|`--control_flow_v2`| Only applicable to TF 2.x Saved Model. This flag improve performance on models with control flow ops, default to False.| -|`--metadata`| Comma separated list of metadata json file paths, indexed by name. Prefer absolute path. Example: 'metadata1:/metadata1.json,metadata2:/metadata2.json'.| -|`--use_structured_outputs_names`| Changes output of graph model to match the structured_outputs format instead of list format. Defaults to `False`.| - -__Note: If you want to convert TensorFlow session bundle, you can install older versions of the tensorflowjs pip package, i.e. `pip install tensorflowjs==0.8.6`.__ - -### Format Conversion Support Tables - -Note: Unless stated otherwise, we can infer the value of `--output_format` from the -value of `--input_format`. So the `--output_format` flag can be omitted in -most cases. - -#### Python-to-JavaScript - -| `--input_format` | `--output_format` | Description | -|---|---|---| -| `keras` | `tfjs_layers_model` | Convert a keras or tf.keras HDF5 model file to TensorFlow.js Layers model format. Use [`tf.loadLayersModel()`](https://js.tensorflow.org/api/latest/#loadLayersModel) to load the model in JavaScript. The loaded model supports the full inference and training (e.g., transfer learning) features of the original keras or tf.keras model. | -| `keras` | `tfjs_graph_model` | Convert a keras or tf.keras HDF5 model file to TensorFlow.js Graph model format. Use [`tf.loadGraphModel()`](https://js.tensorflow.org/api/latest/#loadGraphModel) to load the converted model in JavaScript. The loaded model supports only inference, but the speed of inference is generally faster than that of a tfjs_layers_model (see above row) thanks to the graph optimization performed by TensorFlow. Another limitation of this conversion route is that it does not support some layer types (e.g., recurrent layers such as LSTM) yet. | -| `keras_saved_model` | `tfjs_layers_model` | Convert a tf.keras SavedModel model file (from [`tf.contrib.saved_model.save_keras_model`](https://www.tensorflow.org/api_docs/python/tf/contrib/saved_model/save_keras_model)) to TensorFlow.js Layers model format. Use [`tf.loadLayersModel()`](https://js.tensorflow.org/api/latest/#loadLayersModel) to load the model in JavaScript. | -| `tf_hub` | `tfjs_graph_model` | Convert a [TF-Hub](https://www.tensorflow.org/hub) model file to TensorFlow.js graph model format. Use [`tf.loadGraphModel()`](https://js.tensorflow.org/api/latest/#loadGraphModel) to load the converted model in JavaScript. | -| `tf_saved_model` | `tfjs_graph_model` | Convert a [TensorFlow SavedModel](https://www.tensorflow.org/guide/saved_model#build_and_load_a_savedmodel) to TensorFlow.js graph model format. Use [`tf.loadGraphModel()`](https://js.tensorflow.org/api/latest/#loadGraphModel) to load the converted model in JavaScript. | -| `tf_frozen_model` | `tfjs_graph_model` | Convert a [Frozen Model](https://medium.com/@sebastingarcaacosta/how-to-export-a-tensorflow-2-x-keras-model-to-a-frozen-and-optimized-graph-39740846d9eb) to TensorFlow.js graph model format. Use [`tf.loadGraphModel()`](https://js.tensorflow.org/api/latest/#loadGraphModel) to load the converted model in JavaScript. | - -#### JavaScript-to-Python - -| `--input_format` | `--output_format` | Description | -|---|---|---| -| `tfjs_layers_model` | `keras` | Convert a TensorFlow.js Layers model (JSON + binary weight file(s)) to a Keras HDF5 model file. Use [`keras.model.load_model()`](https://keras.io/getting-started/faq/#savingloading-whole-models-architecture-weights-optimizer-state) or [`tf.keras.models.load_model()`](https://www.tensorflow.org/api_docs/python/tf/keras/models/load_model) to load the converted model in Python. | -| `tfjs_layers_model` | `keras_saved_model` | Convert a TensorFlow.js Layers model (JSON + binary weight file(s)) to the tf.keras SavedModel format. This format is useful for subsequent uses such as [TensorFlow Serving](https://www.tensorflow.org/tfx/serving/serving_basic) and [conversion to TFLite](https://www.tensorflow.org/lite/convert). | - -#### JavaScript-to-JavaScript - -##### Converting tfjs_layers_model to tfjs_layers_model with weight sharding and quantization - -The tfjs_layers_model-to-tfjs_layer_model conversion option serves the following -purposes: - -1. It allows you to shard the binary weight file into multiple small shards - to facilitate browser caching. This step is necessary for models with - large-sized weights saved from TensorFlow.js (either browser or Node.js), - because TensorFlow.js puts all weights in a single weight file - ('group1-shard1of1.bin'). To shard the weight file, do - - ```sh - tensorflowjs_converter \ - --input_format tfjs_layers_model \ - --output_format tfjs_layers_model \ - original_model/model.json \ - sharded_model/ - ``` - - The command above creates shards of size 4 MB (4194304 bytes) by default. - Alternative shard sizes can be specified using the - `--weight_shard_size_bytes` flag. - -2. It allows you to reduce the on-the-wire size of the weights through - 16- or 8-bit quantization. For example: - - ```sh - tensorflowjs_converter \ - --input_format tfjs_layers_model \ - --output_format tfjs_layers_model \ - --quantize_uint16 \ - original_model/model.json - quantized_model/ - ``` - -##### Converting tfjs_layers_model to tfjs_graph_model - -Converting a `tfjs_layers_model` to a `tfjs_graph_model` usually leads to -faster inference speed in the browser and Node.js, thanks to the graph -optimization that goes into generating the tfjs_graph_models. For more details, -see the following document on TensorFlow's Grappler: -["TensorFlow Graph Optimizations" by R. Larsen an T. Shpeisman](https://ai.google/research/pubs/pub48051). - -There are two caveats: - -1. The model that results from this conversion does not support further - training. -2. Certain layer types (e.g., recurrent layers such as LSTM) are not supported - yet. - -See example command below: - -```sh - tensorflowjs_converter \ - --input_format tfjs_layers_model \ - --output_format tfjs_graph_model \ - my_layers_model/model.json - my_graph_model/ -``` - -tfjs_layers_model-to-tfjs_graph_model also support weight quantization. - -### Web-friendly format - -The conversion script above produces 2 types of files: - -* `model.json` (the dataflow graph and weight manifest file) -* `group1-shard\*of\*` (collection of binary weight files) - -For example, here is the MobileNet model converted and served in -following location: - -```html - https://storage.cloud.google.com/tfjs-models/savedmodel/mobilenet_v1_1.0_224/model.json - https://storage.cloud.google.com/tfjs-models/savedmodel/mobilenet_v1_1.0_224/group1-shard1of5 - ... - https://storage.cloud.google.com/tfjs-models/savedmodel/mobilenet_v1_1.0_224/group1-shard5of5 -``` - -## Calling a Converter Function in Python (Flax/JAX) - -You can also convert your model to web format in Python by calling one of the -conversion functions. This is currently the only way to convert a Flax or JAX -model, since no standard serialization format exists to store a Module (only the -checkpoints). - -Here we provide an example of how to convert a Flax function using the -conversion function `tfjs.jax_conversion.convert_jax()`. - -```py -import numpy as np -from flax import linen as nn -from jax import random -import jax.numpy as jnp -from tensorflowjs.converters import jax_conversion - -module = nn.Dense(features=4) -inputs = jnp.ones((3, 4)) -params = module.init(random.PRNKey(0), inputs)['params'] - -jax_conversion.convert_jax( - apply_fn=module.apply, - params=params, - input_signatures=[((3, 4), np.float32)], - model_dir=tfjs_model_dir) -``` - -Note that when using dynamic shapes, an additional argument `polymorphic_shapes` -should be provided specifying values for the dynamic ("polymorphic") -dimensions). So in order to convert the same model as before, but now with a -dynamic first dimension, one should call `convert_jax` as follows: - -```py -jax_conversion.convert_jax( - apply_fn=module.apply, - params=params, - input_signatures=[((None, 4), np.float32)], - polymorphic_shapes=["(b, 4)"], - model_dir=tfjs_model_dir) -``` - -See -[here](https://github.com/google/jax/tree/main/jax/experimental/jax2tf#shape-polymorphic-conversion) -for more details on the exact syntax for this argument. - -When converting JAX models, you can also pass any [options that -`convert_tf_saved_model` -uses](https://github.com/tensorflow/tfjs/blob/master/tfjs-converter/python/tensorflowjs/converters/tf_saved_model_conversion_v2.py#L951-L974). -For example, to quantize a model's weights, pass the `quantization_dtype_map` -option listing the weights that should be quantized. - -```py -jax_conversion.convert_jax( - apply_fn=module.apply, - params=params, - input_signatures=[((3, 4), np.float32)], - model_dir=tfjs_model_dir, - quantization_dtype_map={'float16': '*'}) -``` - -## Step 2: Loading and running in the browser - -If the original model was a `SavedModel`, use -[`tf.loadGraphModel()`](https://js.tensorflow.org/api/latest/#loadGraphModel). -If it was Keras, use -[`tf.loadLayersModel()`](https://js.tensorflow.org/api/latest/#loadLayersModel): - -```typescript -import * as tf from '@tensorflow/tfjs'; - -const MODEL_URL = 'https://.../mobilenet/model.json'; - -// For Keras use tf.loadLayersModel(). -const model = await tf.loadGraphModel(MODEL_URL); -const cat = document.getElementById('cat'); -model.predict(tf.browser.fromPixels(cat)); -``` - -See our API docs for the -[`predict()`](https://js.tensorflow.org/api/latest/#tf.GraphModel.predict) -method. To see what other methods exist on a `Model`, see -[`tf.LayersModel`](https://js.tensorflow.org/api/latest/#class:LayersModel) -and [`tf.GraphModel`](https://js.tensorflow.org/api/latest/#class:GraphModel). -Also check out our working [MobileNet demo](./demo/mobilenet/README.md). - -If your server requests credentials for accessing the model files, you can -provide the optional RequestOption param. - -```typescript -const model = await loadGraphModel(MODEL_URL, - {credentials: 'include'}); -``` - -Please see -[fetch() documentation](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch) -for details. - -### Native File System - -TensorFlow.js can be used from Node.js. See the -[tfjs-node project](https://github.com/tensorflow/tfjs-node) for more details. -Unlike web browsers, Node.js can access the local file system directly. -Therefore, you can load the same frozen model from local file system into -a Node.js program running TensorFlow.js. This is done by calling -`loadGraphModel` with the path to the model files: - -```js -// Load the tfjs-node binding -import * as tf from '@tensorflow/tfjs-node'; - -const MODEL_PATH = 'file:///tmp/mobilenet/model.json'; -const model = await tf.loadGraphModel(MODEL_PATH); -``` - -You can also load the remote model files the same way as in browser, but you -might need to polyfill -the fetch() method. - -## Supported operations - -Currently TensorFlow.js only supports a limited set of TensorFlow Ops. See the -[full list](./docs/supported_ops.md). -If your model uses unsupported ops, the `tensorflowjs_converter` script will -fail and produce a list of the unsupported ops in your model. Please file issues -to let us know what ops you need support with. - -## Manual forward pass and direct weights loading - -If you want to manually write the forward pass with the ops API, you can load -the weights directly as a map from weight names to tensors: - -```js -import * as tf from '@tensorflow/tfjs'; - -const modelUrl = "https://example.org/model/model.json"; - -const response = await fetch(modelUrl); -this.weightManifest = (await response.json())['weightsManifest']; -const weightMap = await tf.io.loadWeights( - this.weightManifest, "https://example.org/model"); -``` - -`weightMap` maps a weight name to a tensor. You can use it to manually implement -the forward pass of the model: - -```js -const input = tf.tensor(...); -tf.matMul(weightMap['fc1/weights'], input).add(weightMap['fc1/bias']); -``` - -## FAQ - -__1. What TensorFlow models does the converter currently support?__ - -Image-based models (MobileNet, SqueezeNet, add more if you tested) are the most -supported. Models with control flow ops (e.g. RNNs) are also supported. -The tensorflowjs_converter script will validate the model you have and show a -list of unsupported ops in your model. See [this list](./docs/supported_ops.md) -for which ops are currently supported. - -__2. Will model with large weights work?__ - -While the browser supports loading 100-500MB models, the page load time, -the inference time and the user experience would not be great. We recommend -using models that are designed for edge devices (e.g. phones). These models are -usually smaller than 30MB. - -__3. Will the model and weight files be cached in the browser?__ - -Yes, we are splitting the weights into files of 4MB chunks, which enable the -browser to cache them automatically. If the model architecture is less than 4MB -(most models are), it will also be cached. - -__4. Can I quantize the weights over the wire?__ - -Yes, you can use the --quantize_{float16, uint8, uint16} flags to compress -weights with 1 byte integer quantization (`uint8`) or 2 byte integer -(`uint16`)/float (`float16`) quantization. -Quantizing to float16 may provide better accuracy over -2 byte affine integer scaling (`uint16`). 1-byte affine quantization, -i.e., `uint8` provides a 4x size reduction at the cost of accuracy. -For example, we can quantize our MobileNet model using float16 quantization: - -``` -tensorflowjs_converter - --quantize_float16 \ - --input_format=tf_hub \ - 'https://tfhub.dev/google/imagenet/mobilenet_v1_100_224/classification/1' \ - /mobilenet/web_model -``` - -You can also quantize specific weights as well as weight groupings using -a wildcard replacement. For example, -``` -tensorflowjs_converter - --quantize_float16="conv/*/weights" -``` -which will quantize all weights that match the pattern conv/*/weights. -This will exclude biases and any weights that don't begin with conv/. -This can be a powerful tool to reduce model size while trying to maximize -performance. - -__5. Why is the predict() method for inference so much slower on the first call than the subsequent calls?__ - -The time of first call also includes the compilation time of WebGL shader -programs for the model. After the first call the shader programs are cached, -which makes the subsequent calls much faster. You can warm up the cache by -calling the predict method with an all zero inputs, right after the completion -of the model loading. - -__6. I have a model converted with a previous version of TensorFlow.js converter (0.15.x), that is in .pb format. How do I convert it to the new JSON format?__ - -You can use the built-in migration tool to convert the models generated by -previous versions. Here are the steps: - -```bash -git clone git@github.com:tensorflow/tfjs-converter.git -cd tfjs-converter -yarn -yarn ts-node tools/pb2json_converter.ts pb_model_directory/ json_model_directory/ -``` - -`pb_model_directory` is the directory where the model generated by previous -version is located. -`json_model_directory` is the destination directory for the converted model. - - -## Development - -To build **TensorFlow.js converter** from source, we need to prepare the dev environment and clone the project. - -Bazel builds Python from source, so we install the dependencies required to build it. Since we will be using pip and C extensions, we also install the ssl, foreign functions, and zlib development packages. On debian, this is done with: - -```bash -sudo apt-get build-dep python3 -sudo apt install libssl-dev libffi-dev zlib1g-dev -``` - -See the [python developer guide](https://devguide.python.org/setup/#install-dependencies) for instructions on installing these for other platforms. - -Then, we clone the project and install dependencies with: - -```bash -git clone https://github.com/tensorflow/tfjs.git -cd tfjs -yarn # Installs dependencies. -``` - -We recommend using [Visual Studio Code](https://code.visualstudio.com/) for -development. Make sure to install -[TSLint VSCode extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode.vscode-typescript-tslint-plugin) -and the npm [clang-format](https://github.com/angular/clang-format) `1.2.2` -or later with the -[Clang-Format VSCode extension](https://marketplace.visualstudio.com/items?itemName=xaver.clang-format) -for auto-formatting. - -Before submitting a pull request, make sure the code passes all the tests and is -clean of lint errors: - -```bash -cd tfjs-converter -yarn test -yarn lint -``` - -To run a subset of tests and/or on a specific browser: - -```bash -yarn test --browsers=Chrome --grep='execute' -> ... -> Chrome 64.0.3282 (Linux 0.0.0): Executed 39 of 39 SUCCESS (0.129 secs / 0 secs) -``` - -To run the tests once and exit the karma process (helpful on Windows): - -```bash -yarn test --single-run -``` - -To run all the python tests - -```bash -yarn run-python-tests -``` diff --git a/tfjs-master/tfjs-converter/cloudbuild.yml b/tfjs-master/tfjs-converter/cloudbuild.yml deleted file mode 100644 index d3bd56ed5..000000000 --- a/tfjs-master/tfjs-converter/cloudbuild.yml +++ /dev/null @@ -1,41 +0,0 @@ - -steps: - -# Install common dependencies. -- name: 'gcr.io/learnjs-174218/release' - entrypoint: 'yarn' - id: 'yarn-common' - args: ['install'] - -# Install tfjs-converter dependencies. -- name: 'gcr.io/learnjs-174218/release' - dir: 'tfjs-converter' - entrypoint: 'yarn' - id: 'yarn' - args: ['install'] - waitFor: ['yarn-common'] - -# Create python pips -- name: 'gcr.io/learnjs-174218/release' - id: 'create-pips' - entrypoint: 'bash' - args: - - './tfjs-converter/scripts/create_python_pips.sh' - waitFor: ['yarn-common'] - -# Run python tests. -- name: 'gcr.io/learnjs-174218/release' - dir: 'tfjs-converter/python' - entrypoint: 'bash' - id: 'test-python-pip' - args: ['./build-pip-package.sh', '--test', '/tmp/tfjs-pips'] - waitFor: ['create-pips'] - -timeout: 1800s -logsBucket: 'gs://tfjs-build-logs' -substitutions: - _NIGHTLY: '' -options: - logStreamingOption: 'STREAM_ON' - substitution_option: 'ALLOW_LOOSE' - machineType: 'N1_HIGHCPU_8' diff --git a/tfjs-master/tfjs-converter/cloudbuild_nightly.yml b/tfjs-master/tfjs-converter/cloudbuild_nightly.yml deleted file mode 100644 index 658b37a1a..000000000 --- a/tfjs-master/tfjs-converter/cloudbuild_nightly.yml +++ /dev/null @@ -1,37 +0,0 @@ -steps: - -# Install common dependencies. -- name: 'gcr.io/learnjs-174218/release' - entrypoint: 'yarn' - id: 'yarn-common' - args: ['install'] - -# Install converter dependencies -- name: 'gcr.io/learnjs-174218/release' - dir: 'tfjs-converter' - entrypoint: 'yarn' - id: 'yarn' - args: ['install'] - waitFor: ['yarn-common'] - -- name: 'gcr.io/learnjs-174218/release' - id: 'create-pips' - entrypoint: 'bash' - args: - - './tfjs-converter/scripts/create_python_pips.sh' - waitFor: ['yarn-common'] - -# Run python tests. -- name: 'gcr.io/learnjs-174218/release' - dir: 'tfjs-converter/python' - entrypoint: 'bash' - args: ['./build-pip-package.sh', '--test-nightly', '/tmp/tfjs-pips'] - waitFor: ['create-pips'] - -timeout: 4800s -logsBucket: 'gs://tfjs-build-logs' -substitutions: - _NIGHTLY: '' -options: - logStreamingOption: 'STREAM_ON' - substitution_option: 'ALLOW_LOOSE' diff --git a/tfjs-master/tfjs-converter/demo/control_flow/README.md b/tfjs-master/tfjs-converter/demo/control_flow/README.md deleted file mode 100644 index f83cb360a..000000000 --- a/tfjs-master/tfjs-converter/demo/control_flow/README.md +++ /dev/null @@ -1,17 +0,0 @@ -# TensorFlow SavedModel Import Demo - -This demo imports a TensorFlow model that is generated by tf.while_loop -for inference in the browser. The model was pre-converted to TensorFlow.js -format and hosted on Google Cloud, using the steps in -the repo's [README.md](../../README.md). - -The following commands will start a web server on `localhost:1234` and open -a browser page with the demo. - -The demo allows you to change the conditions of the loop interactively and observe the execution result right in the browser. - -```bash -cd demo # If not already in the demo directory. -yarn # Installs dependencies. -yarn control_flow # Starts a web server and opens a page. Also watches for changes. -``` diff --git a/tfjs-master/tfjs-converter/demo/control_flow/index.html b/tfjs-master/tfjs-converter/demo/control_flow/index.html deleted file mode 100644 index 0f2ce4410..000000000 --- a/tfjs-master/tfjs-converter/demo/control_flow/index.html +++ /dev/null @@ -1,55 +0,0 @@ - - - - - - - - - - - - -

TensorFlow.js Converter: ControlFlow

-

This example uses a Tensorflow model that is generated by tf.while_loop method.

- -

- You can change the conditions of the loop and press the run button to - observe the execution result. -

- -
-        
-        var output = 0; 
- ; ; i++) {
- ; j++) {
- ;
- }
- console.log(output+1);
-
- -
- - - - - diff --git a/tfjs-master/tfjs-converter/demo/control_flow/loop_model.js b/tfjs-master/tfjs-converter/demo/control_flow/loop_model.js deleted file mode 100644 index 9d7b76b73..000000000 --- a/tfjs-master/tfjs-converter/demo/control_flow/loop_model.js +++ /dev/null @@ -1,72 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '@tensorflow/tfjs'; -const GOOGLE_CLOUD_STORAGE_DIR = - 'https://storage.googleapis.com/tfjs-models/savedmodel/'; -const MODEL_FILE_URL = 'nested_loop/model.json'; -const OUTPUT_NODE_NAME = 'Add'; - -export class LoopModel { - constructor() {} - - async load() { - this.model = await tf.loadGraphModel( - GOOGLE_CLOUD_STORAGE_DIR + MODEL_FILE_URL); - } - - dispose() { - if (this.model) { - this.model.dispose(); - } - } - - async predict(init, loop, loop2, inc) { - const dict = { - 'init': tf.scalar(init, 'int32'), - 'times': tf.scalar(loop, 'int32'), - 'times2': tf.scalar(loop2, 'int32'), - 'inc': tf.scalar(inc, 'int32') - }; - return this.model.executeAsync(dict, OUTPUT_NODE_NAME); - } -} - -window.onload = async () => { - const resultElement = document.getElementById('result'); - - resultElement.innerText = 'Loading Control Flow model...'; - - const loopModel = new LoopModel(); - console.time('Loading of model'); - await loopModel.load(); - console.timeEnd('Loading of model'); - resultElement.innerText = 'Model loaded.'; - - const runBtn = document.getElementById('run'); - runBtn.onclick = async () => { - const init = document.getElementById('init').value; - const loop = document.getElementById('loop').value; - const loop2 = document.getElementById('loop2').value; - const inc = document.getElementById('inc').value; - console.time('prediction'); - const result = await loopModel.predict(init, loop, loop2, inc); - console.timeEnd('prediction'); - - resultElement.innerText = "output = " + result.dataSync()[0]; - }; -}; diff --git a/tfjs-master/tfjs-converter/demo/mobilenet/README.md b/tfjs-master/tfjs-converter/demo/mobilenet/README.md deleted file mode 100644 index 795f8dd7a..000000000 --- a/tfjs-master/tfjs-converter/demo/mobilenet/README.md +++ /dev/null @@ -1,16 +0,0 @@ -# TensorFlow SavedModel Import Demo - -This demo imports the -[MobileNet v2.0](https://www.tensorflow.org/hub/modules/google/imagenet/mobilenet_v2_100_224/classification/1) -model for inference in the browser. The model was pre-converted to TensorFlow.js -format and hosted on Google Cloud, using the steps in -the repo's [README.md](../../README.md). - -The following commands will start a web server on `localhost:1234` and open -a browser page with the demo. - -```bash -cd demo # If not already in the demo directory. -yarn # Installs dependencies. -yarn mobilenet # Starts a web server and opens a page. Also watches for changes. -``` diff --git a/tfjs-master/tfjs-converter/demo/mobilenet/cat.jpg b/tfjs-master/tfjs-converter/demo/mobilenet/cat.jpg deleted file mode 100644 index fe0ccb13c..000000000 Binary files a/tfjs-master/tfjs-converter/demo/mobilenet/cat.jpg and /dev/null differ diff --git a/tfjs-master/tfjs-converter/demo/mobilenet/imagenet_classes.js b/tfjs-master/tfjs-converter/demo/mobilenet/imagenet_classes.js deleted file mode 100644 index c1ab1ff48..000000000 --- a/tfjs-master/tfjs-converter/demo/mobilenet/imagenet_classes.js +++ /dev/null @@ -1,1041 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -export const IMAGENET_CLASSES = { - 0: 'background', - 1: 'tench, Tinca tinca', - 2: 'goldfish, Carassius auratus', - 3: 'great white shark, white shark, man-eater,' + - ' man-eating shark, Carcharodon carcharias', - 4: 'tiger shark, Galeocerdo cuvieri', - 5: 'hammerhead, hammerhead shark', - 6: 'electric ray, crampfish, numbfish, torpedo', - 7: 'stingray', - 8: 'cock', - 9: 'hen', - 10: 'ostrich, Struthio camelus', - 11: 'brambling, Fringilla montifringilla', - 12: 'goldfinch, Carduelis carduelis', - 13: 'house finch, linnet, Carpodacus mexicanus', - 14: 'junco, snowbird', - 15: 'indigo bunting, indigo finch, indigo bird, Passerina cyanea', - 16: 'robin, American robin, Turdus migratorius', - 17: 'bulbul', - 18: 'jay', - 19: 'magpie', - 20: 'chickadee', - 21: 'water ouzel, dipper', - 22: 'kite', - 23: 'bald eagle, American eagle, Haliaeetus leucocephalus', - 24: 'vulture', - 25: 'great grey owl, great gray owl, Strix nebulosa', - 26: 'European fire salamander, Salamandra salamandra', - 27: 'common newt, Triturus vulgaris', - 28: 'eft', - 29: 'spotted salamander, Ambystoma maculatum', - 30: 'axolotl, mud puppy, Ambystoma mexicanum', - 31: 'bullfrog, Rana catesbeiana', - 32: 'tree frog, tree-frog', - 33: 'tailed frog, bell toad, ribbed toad, tailed toad, Ascaphus trui', - 34: 'loggerhead, loggerhead turtle, Caretta caretta', - 35: 'leatherback turtle, leatherback, leathery turtle, Dermochelys coriacea', - 36: 'mud turtle', - 37: 'terrapin', - 38: 'box turtle, box tortoise', - 39: 'banded gecko', - 40: 'common iguana, iguana, Iguana iguana', - 41: 'American chameleon, anole, Anolis carolinensis', - 42: 'whiptail, whiptail lizard', - 43: 'agama', - 44: 'frilled lizard, Chlamydosaurus kingi', - 45: 'alligator lizard', - 46: 'Gila monster, Heloderma suspectum', - 47: 'green lizard, Lacerta viridis', - 48: 'African chameleon, Chamaeleo chamaeleon', - 49: 'Komodo dragon, Komodo lizard, dragon lizard,' + - ' giant lizard, Varanus komodoensis', - 50: 'African crocodile, Nile crocodile, Crocodylus niloticus', - 51: 'American alligator, Alligator mississipiensis', - 52: 'triceratops', - 53: 'thunder snake, worm snake, Carphophis amoenus', - 54: 'ringneck snake, ring-necked snake, ring snake', - 55: 'hognose snake, puff adder, sand viper', - 56: 'green snake, grass snake', - 57: 'king snake, kingsnake', - 58: 'garter snake, grass snake', - 59: 'water snake', - 60: 'vine snake', - 61: 'night snake, Hypsiglena torquata', - 62: 'boa constrictor, Constrictor constrictor', - 63: 'rock python, rock snake, Python sebae', - 64: 'Indian cobra, Naja naja', - 65: 'green mamba', - 66: 'sea snake', - 67: 'horned viper, cerastes, sand viper, horned asp, Cerastes cornutus', - 68: 'diamondback, diamondback rattlesnake, Crotalus adamanteus', - 69: 'sidewinder, horned rattlesnake, Crotalus cerastes', - 70: 'trilobite', - 71: 'harvestman, daddy longlegs, Phalangium opilio', - 72: 'scorpion', - 73: 'black and gold garden spider, Argiope aurantia', - 74: 'barn spider, Araneus cavaticus', - 75: 'garden spider, Aranea diademata', - 76: 'black widow, Latrodectus mactans', - 77: 'tarantula', - 78: 'wolf spider, hunting spider', - 79: 'tick', - 80: 'centipede', - 81: 'black grouse', - 82: 'ptarmigan', - 83: 'ruffed grouse, partridge, Bonasa umbellus', - 84: 'prairie chicken, prairie grouse, prairie fowl', - 85: 'peacock', - 86: 'quail', - 87: 'partridge', - 88: 'African grey, African gray, Psittacus erithacus', - 89: 'macaw', - 90: 'sulphur-crested cockatoo, Kakatoe galerita, Cacatua galerita', - 91: 'lorikeet', - 92: 'coucal', - 93: 'bee eater', - 94: 'hornbill', - 95: 'hummingbird', - 96: 'jacamar', - 97: 'toucan', - 98: 'drake', - 99: 'red-breasted merganser, Mergus serrator', - 100: 'goose', - 101: 'black swan, Cygnus atratus', - 102: 'tusker', - 103: 'echidna, spiny anteater, anteater', - 104: 'platypus, duckbill, duckbilled platypus, duck-billed platypus,' + - ' Ornithorhynchus anatinus', - 105: 'wallaby, brush kangaroo', - 106: 'koala, koala bear, kangaroo bear, native bear, Phascolarctos cinereus', - 107: 'wombat', - 108: 'jelly fish', - 109: 'sea anemone, anemone', - 110: 'brain coral', - 111: 'flatworm, platyhelminth', - 112: 'nematode, nematode worm, roundworm', - 113: 'conch', - 114: 'snail', - 115: 'slug', - 116: 'sea slug, nudibranch', - 117: 'chiton, coat-of-mail shell, sea cradle, polyplacophore', - 118: 'chambered nautilus, pearly nautilus, nautilus', - 119: 'Dungeness crab, Cancer magister', - 120: 'rock crab, Cancer irroratus', - 121: 'fiddler crab', - 122: 'king crab, Alaska crab, Alaskan king crab, Alaska king crab,' + - ' Paralithodes camtschatica', - 123: 'American lobster, Northern lobster, Maine lobster, Homarus americanus', - 124: 'spiny lobster, langouste, rock lobster, crawfish, crayfish,' + - ' sea crawfish', - 125: 'crayfish, crawfish, crawdad, crawdaddy', - 126: 'hermit crab', - 127: 'isopod', - 128: 'white stork, Ciconia ciconia', - 129: 'black stork, Ciconia nigra', - 130: 'spoonbill', - 131: 'flamingo', - 132: 'little blue heron, Egretta caerulea', - 133: 'American egret, great white heron, Egretta albus', - 134: 'bittern', - 135: 'crane', - 136: 'limpkin, Aramus pictus', - 137: 'European gallinule, Porphyrio porphyrio', - 138: 'American coot, marsh hen, mud hen, water hen, Fulica americana', - 139: 'bustard', - 140: 'ruddy turnstone, Arenaria interpres', - 141: 'red-backed sandpiper, dunlin, Erolia alpina', - 142: 'redshank, Tringa totanus', - 143: 'dowitcher', - 144: 'oystercatcher, oyster catcher', - 145: 'pelican', - 146: 'king penguin, Aptenodytes patagonica', - 147: 'albatross, mollymawk', - 148: 'grey whale, gray whale, devilfish, Eschrichtius gibbosus,' + - ' Eschrichtius robustus', - 149: 'killer whale, killer, orca, grampus, sea wolf, Orcinus orca', - 150: 'dugong, Dugong dugon', - 151: 'sea lion', - 152: 'Chihuahua', - 153: 'Japanese spaniel', - 154: 'Maltese dog, Maltese terrier, Maltese', - 155: 'Pekinese, Pekingese, Peke', - 156: 'Shih-Tzu', - 157: 'Blenheim spaniel', - 158: 'papillon', - 159: 'toy terrier', - 160: 'Rhodesian ridgeback', - 161: 'Afghan hound, Afghan', - 162: 'basset, basset hound', - 163: 'beagle', - 164: 'bloodhound, sleuthhound', - 165: 'bluetick', - 166: 'black-and-tan coonhound', - 167: 'Walker hound, Walker foxhound', - 168: 'English foxhound', - 169: 'redbone', - 170: 'borzoi, Russian wolfhound', - 171: 'Irish wolfhound', - 172: 'Italian greyhound', - 173: 'whippet', - 174: 'Ibizan hound, Ibizan Podenco', - 175: 'Norwegian elkhound, elkhound', - 176: 'otterhound, otter hound', - 177: 'Saluki, gazelle hound', - 178: 'Scottish deerhound, deerhound', - 179: 'Weimaraner', - 180: 'Staffordshire bullterrier, Staffordshire bull terrier', - 181: 'American Staffordshire terrier, Staffordshire terrier,' + - ' American pit bull terrier, pit bull terrier', - 182: 'Bedlington terrier', - 183: 'Border terrier', - 184: 'Kerry blue terrier', - 185: 'Irish terrier', - 186: 'Norfolk terrier', - 187: 'Norwich terrier', - 188: 'Yorkshire terrier', - 189: 'wire-haired fox terrier', - 190: 'Lakeland terrier', - 191: 'Sealyham terrier, Sealyham', - 192: 'Airedale, Airedale terrier', - 193: 'cairn, cairn terrier', - 194: 'Australian terrier', - 195: 'Dandie Dinmont, Dandie Dinmont terrier', - 196: 'Boston bull, Boston terrier', - 197: 'miniature schnauzer', - 198: 'giant schnauzer', - 199: 'standard schnauzer', - 200: 'Scotch terrier, Scottish terrier, Scottie', - 201: 'Tibetan terrier, chrysanthemum dog', - 202: 'silky terrier, Sydney silky', - 203: 'soft-coated wheaten terrier', - 204: 'West Highland white terrier', - 205: 'Lhasa, Lhasa apso', - 206: 'flat-coated retriever', - 207: 'curly-coated retriever', - 208: 'golden retriever', - 209: 'Labrador retriever', - 210: 'Chesapeake Bay retriever', - 211: 'German short-haired pointer', - 212: 'vizsla, Hungarian pointer', - 213: 'English setter', - 214: 'Irish setter, red setter', - 215: 'Gordon setter', - 216: 'Brittany spaniel', - 217: 'clumber, clumber spaniel', - 218: 'English springer, English springer spaniel', - 219: 'Welsh springer spaniel', - 220: 'cocker spaniel, English cocker spaniel, cocker', - 221: 'Sussex spaniel', - 222: 'Irish water spaniel', - 223: 'kuvasz', - 224: 'schipperke', - 225: 'groenendael', - 226: 'malinois', - 227: 'briard', - 228: 'kelpie', - 229: 'komondor', - 230: 'Old English sheepdog, bobtail', - 231: 'Shetland sheepdog, Shetland sheep dog, Shetland', - 232: 'collie', - 233: 'Border collie', - 234: 'Bouvier des Flandres, Bouviers des Flandres', - 235: 'Rottweiler', - 236: 'German shepherd, German shepherd dog, German police dog, alsatian', - 237: 'Doberman, Doberman pinscher', - 238: 'miniature pinscher', - 239: 'Greater Swiss Mountain dog', - 240: 'Bernese mountain dog', - 241: 'Appenzeller', - 242: 'EntleBucher', - 243: 'boxer', - 244: 'bull mastiff', - 245: 'Tibetan mastiff', - 246: 'French bulldog', - 247: 'Great Dane', - 248: 'Saint Bernard, St Bernard', - 249: 'Eskimo dog, husky', - 250: 'malamute, malemute, Alaskan malamute', - 251: 'Siberian husky', - 252: 'dalmatian, coach dog, carriage dog', - 253: 'affenpinscher, monkey pinscher, monkey dog', - 254: 'basenji', - 255: 'pug, pug-dog', - 256: 'Leonberg', - 257: 'Newfoundland, Newfoundland dog', - 258: 'Great Pyrenees', - 259: 'Samoyed, Samoyede', - 260: 'Pomeranian', - 261: 'chow, chow chow', - 262: 'keeshond', - 263: 'Brabancon griffon', - 264: 'Pembroke, Pembroke Welsh corgi', - 265: 'Cardigan, Cardigan Welsh corgi', - 266: 'toy poodle', - 267: 'miniature poodle', - 268: 'standard poodle', - 269: 'Mexican hairless', - 270: 'timber wolf, grey wolf, gray wolf, Canis lupus', - 271: 'white wolf, Arctic wolf, Canis lupus tundrarum', - 272: 'red wolf, maned wolf, Canis rufus, Canis niger', - 273: 'coyote, prairie wolf, brush wolf, Canis latrans', - 274: 'dingo, warrigal, warragal, Canis dingo', - 275: 'dhole, Cuon alpinus', - 276: 'African hunting dog, hyena dog, Cape hunting dog, Lycaon pictus', - 277: 'hyena, hyaena', - 278: 'red fox, Vulpes vulpes', - 279: 'kit fox, Vulpes macrotis', - 280: 'Arctic fox, white fox, Alopex lagopus', - 281: 'grey fox, gray fox, Urocyon cinereoargenteus', - 282: 'tabby, tabby cat', - 283: 'tiger cat', - 284: 'Persian cat', - 285: 'Siamese cat, Siamese', - 286: 'Egyptian cat', - 287: 'cougar, puma, catamount, mountain lion, painter, panther,' + - ' Felis concolor', - 288: 'lynx, catamount', - 289: 'leopard, Panthera pardus', - 290: 'snow leopard, ounce, Panthera uncia', - 291: 'jaguar, panther, Panthera onca, Felis onca', - 292: 'lion, king of beasts, Panthera leo', - 293: 'tiger, Panthera tigris', - 294: 'cheetah, chetah, Acinonyx jubatus', - 295: 'brown bear, bruin, Ursus arctos', - 296: 'American black bear, black bear, Ursus americanus,' + - ' Euarctos americanus', - 297: 'ice bear, polar bear, Ursus Maritimus, Thalarctos maritimus', - 298: 'sloth bear, Melursus ursinus, Ursus ursinus', - 299: 'mongoose', - 300: 'meerkat, mierkat', - 301: 'tiger beetle', - 302: 'ladybug, ladybeetle, lady beetle, ladybird, ladybird beetle', - 303: 'ground beetle, carabid beetle', - 304: 'long-horned beetle, longicorn, longicorn beetle', - 305: 'leaf beetle, chrysomelid', - 306: 'dung beetle', - 307: 'rhinoceros beetle', - 308: 'weevil', - 309: 'fly', - 310: 'bee', - 311: 'ant, emmet, pismire', - 312: 'grasshopper, hopper', - 313: 'cricket', - 314: 'walking stick, walkingstick, stick insect', - 315: 'cockroach, roach', - 316: 'mantis, mantid', - 317: 'cicada, cicala', - 318: 'leafhopper', - 319: 'lacewing, lacewing fly', - 320: 'dragonfly, darning needle, devil\'s darning needle, sewing' + - 'needle, snake feeder, snake doctor, mosquito hawk, skeeter hawk', - 321: 'damselfly', - 322: 'admiral', - 323: 'ringlet, ringlet butterfly', - 324: 'monarch, monarch butterfly, milkweed butterfly, Danaus plexippus', - 325: 'cabbage butterfly', - 326: 'sulphur butterfly, sulfur butterfly', - 327: 'lycaenid, lycaenid butterfly', - 328: 'starfish, sea star', - 329: 'sea urchin', - 330: 'sea cucumber, holothurian', - 331: 'wood rabbit, cottontail, cottontail rabbit', - 332: 'hare', - 333: 'Angora, Angora rabbit', - 334: 'hamster', - 335: 'porcupine, hedgehog', - 336: 'fox squirrel, eastern fox squirrel, Sciurus niger', - 337: 'marmot', - 338: 'beaver', - 339: 'guinea pig, Cavia cobaya', - 340: 'sorrel', - 341: 'zebra', - 342: 'hog, pig, grunter, squealer, Sus scrofa', - 343: 'wild boar, boar, Sus scrofa', - 344: 'warthog', - 345: 'hippopotamus, hippo, river horse, Hippopotamus amphibius', - 346: 'ox', - 347: 'water buffalo, water ox, Asiatic buffalo, Bubalus bubalis', - 348: 'bison', - 349: 'ram, tup', - 350: 'bighorn, bighorn sheep, cimarron, Rocky Mountain bighorn, Rocky ' + - 'Mountain sheep, Ovis canadensis', - 351: 'ibex, Capra ibex', - 352: 'hartebeest', - 353: 'impala, Aepyceros melampus', - 354: 'gazelle', - 355: 'Arabian camel, dromedary, Camelus dromedarius', - 356: 'llama', - 357: 'weasel', - 358: 'mink', - 359: 'polecat, fitch, foulmart, foumart, Mustela putorius', - 360: 'black-footed ferret, ferret, Mustela nigripes', - 361: 'otter', - 362: 'skunk, polecat, wood pussy', - 363: 'badger', - 364: 'armadillo', - 365: 'three-toed sloth, ai, Bradypus tridactylus', - 366: 'orangutan, orang, orangutang, Pongo pygmaeus', - 367: 'gorilla, Gorilla gorilla', - 368: 'chimpanzee, chimp, Pan troglodytes', - 369: 'gibbon, Hylobates lar', - 370: 'siamang, Hylobates syndactylus, Symphalangus syndactylus', - 371: 'guenon, guenon monkey', - 372: 'patas, hussar monkey, Erythrocebus patas', - 373: 'baboon', - 374: 'macaque', - 375: 'langur', - 376: 'colobus, colobus monkey', - 377: 'proboscis monkey, Nasalis larvatus', - 378: 'marmoset', - 379: 'capuchin, ringtail, Cebus capucinus', - 380: 'howler monkey, howler', - 381: 'titi, titi monkey', - 382: 'spider monkey, Ateles geoffroyi', - 383: 'squirrel monkey, Saimiri sciureus', - 384: 'Madagascar cat, ring-tailed lemur, Lemur catta', - 385: 'indri, indris, Indri indri, Indri brevicaudatus', - 386: 'Indian elephant, Elephas maximus', - 387: 'African elephant, Loxodonta africana', - 388: 'lesser panda, red panda, panda, bear cat, cat bear, Ailurus fulgens', - 389: 'giant panda, panda, panda bear, coon bear, Ailuropoda melanoleuca', - 390: 'barracouta, snoek', - 391: 'eel', - 392: 'coho, cohoe, coho salmon, blue jack, silver salmon, ' + - 'Oncorhynchus kisutch', - 393: 'rock beauty, Holocanthus tricolor', - 394: 'anemone fish', - 395: 'sturgeon', - 396: 'gar, garfish, garpike, billfish, Lepisosteus osseus', - 397: 'lionfish', - 398: 'puffer, pufferfish, blowfish, globefish', - 399: 'abacus', - 400: 'abaya', - 401: 'academic gown, academic robe, judge\'s robe', - 402: 'accordion, piano accordion, squeeze box', - 403: 'acoustic guitar', - 404: 'aircraft carrier, carrier, flattop, attack aircraft carrier', - 405: 'airliner', - 406: 'airship, dirigible', - 407: 'altar', - 408: 'ambulance', - 409: 'amphibian, amphibious vehicle', - 410: 'analog clock', - 411: 'apiary, bee house', - 412: 'apron', - 413: 'ashcan, trash can, garbage can, wastebin, ash bin, ash-bin,' + - ' ashbin, dustbin, trash barrel, trash bin', - 414: 'assault rifle, assault gun', - 415: 'backpack, back pack, knapsack, packsack, rucksack, haversack', - 416: 'bakery, bakeshop, bakehouse', - 417: 'balance beam, beam', - 418: 'balloon', - 419: 'ballpoint, ballpoint pen, ballpen, Biro', - 420: 'Band Aid', - 421: 'banjo', - 422: 'bannister, banister, balustrade, balusters, handrail', - 423: 'barbell', - 424: 'barber chair', - 425: 'barbershop', - 426: 'barn', - 427: 'barometer', - 428: 'barrel, cask', - 429: 'barrow, garden cart, lawn cart, wheelbarrow', - 430: 'baseball', - 431: 'basketball', - 432: 'bassinet', - 433: 'bassoon', - 434: 'bathing cap, swimming cap', - 435: 'bath towel', - 436: 'bathtub, bathing tub, bath, tub', - 437: 'beach wagon, station wagon, wagon, estate car, beach waggon,' + - ' station waggon, waggon', - 438: 'beacon, lighthouse, beacon light, pharos', - 439: 'beaker', - 440: 'bearskin, busby, shako', - 441: 'beer bottle', - 442: 'beer glass', - 443: 'bell cote, bell cot', - 444: 'bib', - 445: 'bicycle-built-for-two, tandem bicycle, tandem', - 446: 'bikini, two-piece', - 447: 'binder, ring-binder', - 448: 'binoculars, field glasses, opera glasses', - 449: 'birdhouse', - 450: 'boathouse', - 451: 'bobsled, bobsleigh, bob', - 452: 'bolo tie, bolo, bola tie, bola', - 453: 'bonnet, poke bonnet', - 454: 'bookcase', - 455: 'bookshop, bookstore, bookstall', - 456: 'bottlecap', - 457: 'bow', - 458: 'bow tie, bow-tie, bowtie', - 459: 'brass, memorial tablet, plaque', - 460: 'brassiere, bra, bandeau', - 461: 'breakwater, groin, groyne, mole, bulwark, seawall, jetty', - 462: 'breastplate, aegis, egis', - 463: 'broom', - 464: 'bucket, pail', - 465: 'buckle', - 466: 'bulletproof vest', - 467: 'bullet train, bullet', - 468: 'butcher shop, meat market', - 469: 'cab, hack, taxi, taxicab', - 470: 'caldron, cauldron', - 471: 'candle, taper, wax light', - 472: 'cannon', - 473: 'canoe', - 474: 'can opener, tin opener', - 475: 'cardigan', - 476: 'car mirror', - 477: 'carousel, carrousel, merry-go-round, roundabout, whirligig', - 478: 'carpenter\'s kit, tool kit', - 479: 'carton', - 480: 'car wheel', - 481: 'cash machine, cash dispenser, automated teller machine, automatic' + - ' teller machine, automated teller, automatic teller, ATM', - 482: 'cassette', - 483: 'cassette player', - 484: 'castle', - 485: 'catamaran', - 486: 'CD player', - 487: 'cello, violoncello', - 488: 'cellular telephone, cellular phone, cellphone, cell, mobile phone', - 489: 'chain', - 490: 'chainlink fence', - 491: 'chain mail, ring mail, mail, chain armor, chain armour,' + - ' ring armor, ring armour', - 492: 'chain saw, chainsaw', - 493: 'chest', - 494: 'chiffonier, commode', - 495: 'chime, bell, gong', - 496: 'china cabinet, china closet', - 497: 'Christmas stocking', - 498: 'church, church building', - 499: 'cinema, movie theater, movie theatre, movie house, picture palace', - 500: 'cleaver, meat cleaver, chopper', - 501: 'cliff dwelling', - 502: 'cloak', - 503: 'clog, geta, patten, sabot', - 504: 'cocktail shaker', - 505: 'coffee mug', - 506: 'coffeepot', - 507: 'coil, spiral, volute, whorl, helix', - 508: 'combination lock', - 509: 'computer keyboard, keypad', - 510: 'confectionery, confectionary, candy store', - 511: 'container ship, containership, container vessel', - 512: 'convertible', - 513: 'corkscrew, bottle screw', - 514: 'cornet, horn, trumpet, trump', - 515: 'cowboy boot', - 516: 'cowboy hat, ten-gallon hat', - 517: 'cradle', - 518: 'crane', - 519: 'crash helmet', - 520: 'crate', - 521: 'crib, cot', - 522: 'Crock Pot', - 523: 'croquet ball', - 524: 'crutch', - 525: 'cuirass', - 526: 'dam, dike, dyke', - 527: 'desk', - 528: 'desktop computer', - 529: 'dial telephone, dial phone', - 530: 'diaper, nappy, napkin', - 531: 'digital clock', - 532: 'digital watch', - 533: 'dining table, board', - 534: 'dishrag, dishcloth', - 535: 'dishwasher, dish washer, dishwashing machine', - 536: 'disk brake, disc brake', - 537: 'dock, dockage, docking facility', - 538: 'dogsled, dog sled, dog sleigh', - 539: 'dome', - 540: 'doormat, welcome mat', - 541: 'drilling platform, offshore rig', - 542: 'drum, membranophone, tympan', - 543: 'drumstick', - 544: 'dumbbell', - 545: 'Dutch oven', - 546: 'electric fan, blower', - 547: 'electric guitar', - 548: 'electric locomotive', - 549: 'entertainment center', - 550: 'envelope', - 551: 'espresso maker', - 552: 'face powder', - 553: 'feather boa, boa', - 554: 'file, file cabinet, filing cabinet', - 555: 'fireboat', - 556: 'fire engine, fire truck', - 557: 'fire screen, fireguard', - 558: 'flagpole, flagstaff', - 559: 'flute, transverse flute', - 560: 'folding chair', - 561: 'football helmet', - 562: 'forklift', - 563: 'fountain', - 564: 'fountain pen', - 565: 'four-poster', - 566: 'freight car', - 567: 'French horn, horn', - 568: 'frying pan, frypan, skillet', - 569: 'fur coat', - 570: 'garbage truck, dustcart', - 571: 'gasmask, respirator, gas helmet', - 572: 'gas pump, gasoline pump, petrol pump, island dispenser', - 573: 'goblet', - 574: 'go-kart', - 575: 'golf ball', - 576: 'golfcart, golf cart', - 577: 'gondola', - 578: 'gong, tam-tam', - 579: 'gown', - 580: 'grand piano, grand', - 581: 'greenhouse, nursery, glasshouse', - 582: 'grille, radiator grille', - 583: 'grocery store, grocery, food market, market', - 584: 'guillotine', - 585: 'hair slide', - 586: 'hair spray', - 587: 'half track', - 588: 'hammer', - 589: 'hamper', - 590: 'hand blower, blow dryer, blow drier, hair dryer, hair drier', - 591: 'hand-held computer, hand-held microcomputer', - 592: 'handkerchief, hankie, hanky, hankey', - 593: 'hard disc, hard disk, fixed disk', - 594: 'harmonica, mouth organ, harp, mouth harp', - 595: 'harp', - 596: 'harvester, reaper', - 597: 'hatchet', - 598: 'holster', - 599: 'home theater, home theatre', - 600: 'honeycomb', - 601: 'hook, claw', - 602: 'hoopskirt, crinoline', - 603: 'horizontal bar, high bar', - 604: 'horse cart, horse-cart', - 605: 'hourglass', - 606: 'iPod', - 607: 'iron, smoothing iron', - 608: 'jack-o\'-lantern', - 609: 'jean, blue jean, denim', - 610: 'jeep, landrover', - 611: 'jersey, T-shirt, tee shirt', - 612: 'jigsaw puzzle', - 613: 'jinrikisha, ricksha, rickshaw', - 614: 'joystick', - 615: 'kimono', - 616: 'knee pad', - 617: 'knot', - 618: 'lab coat, laboratory coat', - 619: 'ladle', - 620: 'lampshade, lamp shade', - 621: 'laptop, laptop computer', - 622: 'lawn mower, mower', - 623: 'lens cap, lens cover', - 624: 'letter opener, paper knife, paperknife', - 625: 'library', - 626: 'lifeboat', - 627: 'lighter, light, igniter, ignitor', - 628: 'limousine, limo', - 629: 'liner, ocean liner', - 630: 'lipstick, lip rouge', - 631: 'Loafer', - 632: 'lotion', - 633: 'loudspeaker, speaker, speaker unit, loudspeaker system, ' + - 'speaker system', - 634: 'loupe, jeweler\'s loupe', - 635: 'lumbermill, sawmill', - 636: 'magnetic compass', - 637: 'mailbag, postbag', - 638: 'mailbox, letter box', - 639: 'maillot', - 640: 'maillot, tank suit', - 641: 'manhole cover', - 642: 'maraca', - 643: 'marimba, xylophone', - 644: 'mask', - 645: 'matchstick', - 646: 'maypole', - 647: 'maze, labyrinth', - 648: 'measuring cup', - 649: 'medicine chest, medicine cabinet', - 650: 'megalith, megalithic structure', - 651: 'microphone, mike', - 652: 'microwave, microwave oven', - 653: 'military uniform', - 654: 'milk can', - 655: 'minibus', - 656: 'miniskirt, mini', - 657: 'minivan', - 658: 'missile', - 659: 'mitten', - 660: 'mixing bowl', - 661: 'mobile home, manufactured home', - 662: 'Model T', - 663: 'modem', - 664: 'monastery', - 665: 'monitor', - 666: 'moped', - 667: 'mortar', - 668: 'mortarboard', - 669: 'mosque', - 670: 'mosquito net', - 671: 'motor scooter, scooter', - 672: 'mountain bike, all-terrain bike, off-roader', - 673: 'mountain tent', - 674: 'mouse, computer mouse', - 675: 'mousetrap', - 676: 'moving van', - 677: 'muzzle', - 678: 'nail', - 679: 'neck brace', - 680: 'necklace', - 681: 'nipple', - 682: 'notebook, notebook computer', - 683: 'obelisk', - 684: 'oboe, hautboy, hautbois', - 685: 'ocarina, sweet potato', - 686: 'odometer, hodometer, mileometer, milometer', - 687: 'oil filter', - 688: 'organ, pipe organ', - 689: 'oscilloscope, scope, cathode-ray oscilloscope, CRO', - 690: 'overskirt', - 691: 'oxcart', - 692: 'oxygen mask', - 693: 'packet', - 694: 'paddle, boat paddle', - 695: 'paddlewheel, paddle wheel', - 696: 'padlock', - 697: 'paintbrush', - 698: 'pajama, pyjama, pj\'s, jammies', - 699: 'palace', - 700: 'panpipe, pandean pipe, syrinx', - 701: 'paper towel', - 702: 'parachute, chute', - 703: 'parallel bars, bars', - 704: 'park bench', - 705: 'parking meter', - 706: 'passenger car, coach, carriage', - 707: 'patio, terrace', - 708: 'pay-phone, pay-station', - 709: 'pedestal, plinth, footstall', - 710: 'pencil box, pencil case', - 711: 'pencil sharpener', - 712: 'perfume, essence', - 713: 'Petri dish', - 714: 'photocopier', - 715: 'pick, plectrum, plectron', - 716: 'pickelhaube', - 717: 'picket fence, paling', - 718: 'pickup, pickup truck', - 719: 'pier', - 720: 'piggy bank, penny bank', - 721: 'pill bottle', - 722: 'pillow', - 723: 'ping-pong ball', - 724: 'pinwheel', - 725: 'pirate, pirate ship', - 726: 'pitcher, ewer', - 727: 'plane, carpenter\'s plane, woodworking plane', - 728: 'planetarium', - 729: 'plastic bag', - 730: 'plate rack', - 731: 'plow, plough', - 732: 'plunger, plumber\'s helper', - 733: 'Polaroid camera, Polaroid Land camera', - 734: 'pole', - 735: 'police van, police wagon, paddy wagon, patrol wagon, wagon,' + - ' black Maria', - 736: 'poncho', - 737: 'pool table, billiard table, snooker table', - 738: 'pop bottle, soda bottle', - 739: 'pot, flowerpot', - 740: 'potter\'s wheel', - 741: 'power drill', - 742: 'prayer rug, prayer mat', - 743: 'printer', - 744: 'prison, prison house', - 745: 'projectile, missile', - 746: 'projector', - 747: 'puck, hockey puck', - 748: 'punching bag, punch bag, punching ball, punchball', - 749: 'purse', - 750: 'quill, quill pen', - 751: 'quilt, comforter, comfort, puff', - 752: 'racer, race car, racing car', - 753: 'racket, racquet', - 754: 'radiator', - 755: 'radio, wireless', - 756: 'radio telescope, radio reflector', - 757: 'rain barrel', - 758: 'recreational vehicle, RV, R.V.', - 759: 'reel', - 760: 'reflex camera', - 761: 'refrigerator, icebox', - 762: 'remote control, remote', - 763: 'restaurant, eating house, eating place, eatery', - 764: 'revolver, six-gun, six-shooter', - 765: 'rifle', - 766: 'rocking chair, rocker', - 767: 'rotisserie', - 768: 'rubber eraser, rubber, pencil eraser', - 769: 'rugby ball', - 770: 'rule, ruler', - 771: 'running shoe', - 772: 'safe', - 773: 'safety pin', - 774: 'saltshaker, salt shaker', - 775: 'sandal', - 776: 'sarong', - 777: 'sax, saxophone', - 778: 'scabbard', - 779: 'scale, weighing machine', - 780: 'school bus', - 781: 'schooner', - 782: 'scoreboard', - 783: 'screen, CRT screen', - 784: 'screw', - 785: 'screwdriver', - 786: 'seat belt, seatbelt', - 787: 'sewing machine', - 788: 'shield, buckler', - 789: 'shoe shop, shoe-shop, shoe store', - 790: 'shoji', - 791: 'shopping basket', - 792: 'shopping cart', - 793: 'shovel', - 794: 'shower cap', - 795: 'shower curtain', - 796: 'ski', - 797: 'ski mask', - 798: 'sleeping bag', - 799: 'slide rule, slipstick', - 800: 'sliding door', - 801: 'slot, one-armed bandit', - 802: 'snorkel', - 803: 'snowmobile', - 804: 'snowplow, snowplough', - 805: 'soap dispenser', - 806: 'soccer ball', - 807: 'sock', - 808: 'solar dish, solar collector, solar furnace', - 809: 'sombrero', - 810: 'soup bowl', - 811: 'space bar', - 812: 'space heater', - 813: 'space shuttle', - 814: 'spatula', - 815: 'speedboat', - 816: 'spider web, spider\'s web', - 817: 'spindle', - 818: 'sports car, sport car', - 819: 'spotlight, spot', - 820: 'stage', - 821: 'steam locomotive', - 822: 'steel arch bridge', - 823: 'steel drum', - 824: 'stethoscope', - 825: 'stole', - 826: 'stone wall', - 827: 'stopwatch, stop watch', - 828: 'stove', - 829: 'strainer', - 830: 'streetcar, tram, tramcar, trolley, trolley car', - 831: 'stretcher', - 832: 'studio couch, day bed', - 833: 'stupa, tope', - 834: 'submarine, pigboat, sub, U-boat', - 835: 'suit, suit of clothes', - 836: 'sundial', - 837: 'sunglass', - 838: 'sunglasses, dark glasses, shades', - 839: 'sunscreen, sunblock, sun blocker', - 840: 'suspension bridge', - 841: 'swab, swob, mop', - 842: 'sweatshirt', - 843: 'swimming trunks, bathing trunks', - 844: 'swing', - 845: 'switch, electric switch, electrical switch', - 846: 'syringe', - 847: 'table lamp', - 848: 'tank, army tank, armored combat vehicle, armoured combat vehicle', - 849: 'tape player', - 850: 'teapot', - 851: 'teddy, teddy bear', - 852: 'television, television system', - 853: 'tennis ball', - 854: 'thatch, thatched roof', - 855: 'theater curtain, theatre curtain', - 856: 'thimble', - 857: 'thresher, thrasher, threshing machine', - 858: 'throne', - 859: 'tile roof', - 860: 'toaster', - 861: 'tobacco shop, tobacconist shop, tobacconist', - 862: 'toilet seat', - 863: 'torch', - 864: 'totem pole', - 865: 'tow truck, tow car, wrecker', - 866: 'toyshop', - 867: 'tractor', - 868: 'trailer truck, tractor trailer, trucking rig, rig,' + - ' articulated lorry, semi', - 869: 'tray', - 870: 'trench coat', - 871: 'tricycle, trike, velocipede', - 872: 'trimaran', - 873: 'tripod', - 874: 'triumphal arch', - 875: 'trolleybus, trolley coach, trackless trolley', - 876: 'trombone', - 877: 'tub, vat', - 878: 'turnstile', - 879: 'typewriter keyboard', - 880: 'umbrella', - 881: 'unicycle, monocycle', - 882: 'upright, upright piano', - 883: 'vacuum, vacuum cleaner', - 884: 'vase', - 885: 'vault', - 886: 'velvet', - 887: 'vending machine', - 888: 'vestment', - 889: 'viaduct', - 890: 'violin, fiddle', - 891: 'volleyball', - 892: 'waffle iron', - 893: 'wall clock', - 894: 'wallet, billfold, notecase, pocketbook', - 895: 'wardrobe, closet, press', - 896: 'warplane, military plane', - 897: 'washbasin, handbasin, washbowl, lavabo, wash-hand basin', - 898: 'washer, automatic washer, washing machine', - 899: 'water bottle', - 900: 'water jug', - 901: 'water tower', - 902: 'whiskey jug', - 903: 'whistle', - 904: 'wig', - 905: 'window screen', - 906: 'window shade', - 907: 'Windsor tie', - 908: 'wine bottle', - 909: 'wing', - 910: 'wok', - 911: 'wooden spoon', - 912: 'wool, woolen, woollen', - 913: 'worm fence, snake fence, snake-rail fence, Virginia fence', - 914: 'wreck', - 915: 'yawl', - 916: 'yurt', - 917: 'web site, website, internet site, site', - 918: 'comic book', - 919: 'crossword puzzle, crossword', - 920: 'street sign', - 921: 'traffic light, traffic signal, stoplight', - 922: 'book jacket, dust cover, dust jacket, dust wrapper', - 923: 'menu', - 924: 'plate', - 925: 'guacamole', - 926: 'consomme', - 927: 'hot pot, hotpot', - 928: 'trifle', - 929: 'ice cream, icecream', - 930: 'ice lolly, lolly, lollipop, popsicle', - 931: 'French loaf', - 932: 'bagel, beigel', - 933: 'pretzel', - 934: 'cheeseburger', - 935: 'hotdog, hot dog, red hot', - 936: 'mashed potato', - 937: 'head cabbage', - 938: 'broccoli', - 939: 'cauliflower', - 940: 'zucchini, courgette', - 941: 'spaghetti squash', - 942: 'acorn squash', - 943: 'butternut squash', - 944: 'cucumber, cuke', - 945: 'artichoke, globe artichoke', - 946: 'bell pepper', - 947: 'cardoon', - 948: 'mushroom', - 949: 'Granny Smith', - 950: 'strawberry', - 951: 'orange', - 952: 'lemon', - 953: 'fig', - 954: 'pineapple, ananas', - 955: 'banana', - 956: 'jackfruit, jak, jack', - 957: 'custard apple', - 958: 'pomegranate', - 959: 'hay', - 960: 'carbonara', - 961: 'chocolate sauce, chocolate syrup', - 962: 'dough', - 963: 'meat loaf, meatloaf', - 964: 'pizza, pizza pie', - 965: 'potpie', - 966: 'burrito', - 967: 'red wine', - 968: 'espresso', - 969: 'cup', - 970: 'eggnog', - 971: 'alp', - 972: 'bubble', - 973: 'cliff, drop, drop-off', - 974: 'coral reef', - 975: 'geyser', - 976: 'lakeside, lakeshore', - 977: 'promontory, headland, head, foreland', - 978: 'sandbar, sand bar', - 979: 'seashore, coast, seacoast, sea-coast', - 980: 'valley, vale', - 981: 'volcano', - 982: 'ballplayer, baseball player', - 983: 'groom, bridegroom', - 984: 'scuba diver', - 985: 'rapeseed', - 986: 'daisy', - 987: 'yellow lady\'s slipper, yellow lady-slipper, Cypripedium' + - ' calceolus, Cypripedium parviflorum', - 988: 'corn', - 989: 'acorn', - 990: 'hip, rose hip, rosehip', - 991: 'buckeye, horse chestnut, conker', - 992: 'coral fungus', - 993: 'agaric', - 994: 'gyromitra', - 995: 'stinkhorn, carrion fungus', - 996: 'earthstar', - 997: 'hen-of-the-woods, hen of the woods, Polyporus' + - ' frondosus, Grifola frondosa', - 998: 'bolete', - 999: 'ear, spike, capitulum', - 1000: 'toilet tissue, toilet paper, bathroom tissue' -}; diff --git a/tfjs-master/tfjs-converter/demo/mobilenet/index.html b/tfjs-master/tfjs-converter/demo/mobilenet/index.html deleted file mode 100644 index 8811f9424..000000000 --- a/tfjs-master/tfjs-converter/demo/mobilenet/index.html +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - -

TensorFlow.js Converter: MobileNet

- -
- - - - diff --git a/tfjs-master/tfjs-converter/demo/mobilenet/index.js b/tfjs-master/tfjs-converter/demo/mobilenet/index.js deleted file mode 100644 index 341309770..000000000 --- a/tfjs-master/tfjs-converter/demo/mobilenet/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import 'babel-polyfill'; -import * as tf from '@tensorflow/tfjs'; -import {MobileNet} from './mobilenet'; -import imageURL from './cat.jpg'; - -const cat = document.getElementById('cat'); -cat.onload = async () => { - const resultElement = document.getElementById('result'); - - resultElement.innerText = 'Loading MobileNet...'; - - const mobileNet = new MobileNet(); - console.time('Loading of model'); - await mobileNet.load(); - console.timeEnd('Loading of model'); - - const pixels = tf.browser.fromPixels(cat); - - console.time('First prediction'); - let result = mobileNet.predict(pixels); - const topK = mobileNet.getTopKClasses(result, 5); - console.timeEnd('First prediction'); - - resultElement.innerText = ''; - topK.forEach(x => { - resultElement.innerText += `${x.value.toFixed(3)}: ${x.label}\n`; - }); - - console.time('Subsequent predictions'); - result = mobileNet.predict(pixels); - mobileNet.getTopKClasses(result, 5); - console.timeEnd('Subsequent predictions'); - - mobileNet.dispose(); -}; -cat.src = imageURL; diff --git a/tfjs-master/tfjs-converter/demo/mobilenet/mobilenet.js b/tfjs-master/tfjs-converter/demo/mobilenet/mobilenet.js deleted file mode 100644 index 061c85649..000000000 --- a/tfjs-master/tfjs-converter/demo/mobilenet/mobilenet.js +++ /dev/null @@ -1,82 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '@tensorflow/tfjs'; - -import {IMAGENET_CLASSES} from './imagenet_classes'; - -const GOOGLE_CLOUD_STORAGE_DIR = - 'https://storage.googleapis.com/tfjs-models/savedmodel/'; -const MODEL_FILE_URL = 'mobilenet_v2_1.0_224/model.json'; -const INPUT_NODE_NAME = 'images'; -const OUTPUT_NODE_NAME = 'module_apply_default/MobilenetV2/Logits/output'; -const PREPROCESS_DIVISOR = tf.scalar(255 / 2); - -export class MobileNet { - constructor() {} - - async load() { - this.model = await tf.loadGraphModel( - GOOGLE_CLOUD_STORAGE_DIR + MODEL_FILE_URL); - } - - dispose() { - if (this.model) { - this.model.dispose(); - } - } - /** - * Infer through MobileNet. This does standard ImageNet pre-processing before - * inferring through the model. This method returns named activations as well - * as softmax logits. - * - * @param input un-preprocessed input Array. - * @return The softmax logits. - */ - predict(input) { - const preprocessedInput = tf.div( - tf.sub(input.asType('float32'), PREPROCESS_DIVISOR), - PREPROCESS_DIVISOR); - const reshapedInput = - preprocessedInput.reshape([1, ...preprocessedInput.shape]); - return this.model.execute( - {[INPUT_NODE_NAME]: reshapedInput}, OUTPUT_NODE_NAME); - } - - getTopKClasses(logits, topK) { - const predictions = tf.tidy(() => { - return tf.softmax(logits); - }); - - const values = predictions.dataSync(); - predictions.dispose(); - - let predictionList = []; - for (let i = 0; i < values.length; i++) { - predictionList.push({value: values[i], index: i}); - } - predictionList = predictionList - .sort((a, b) => { - return b.value - a.value; - }) - .slice(0, topK); - - return predictionList.map(x => { - return {label: IMAGENET_CLASSES[x.index], value: x.value}; - }); - } -} diff --git a/tfjs-master/tfjs-converter/demo/package.json b/tfjs-master/tfjs-converter/demo/package.json deleted file mode 100644 index ae249255b..000000000 --- a/tfjs-master/tfjs-converter/demo/package.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "name": "tfjs-converter-demo", - "version": "0.0.1", - "description": "Imports mobilenet model using the tfc.js converter", - "main": "index.js", - "license": "Apache-2.0", - "private": true, - "dependencies": { - "@tensorflow/tfjs": "0.15.3", - "babel-polyfill": "^6.26.0" - }, - "scripts": { - "mobilenet": "NODE_ENV=development parcel mobilenet/index.html --no-hmr --open", - "ssd": "NODE_ENV=development parcel ssd/index.html --no-hmr --open", - "control_flow": "NODE_ENV=development parcel control_flow/index.html --no-hmr --open" - }, - "devDependencies": { - "@babel/core": "^7.0.0-0", - "@babel/plugin-transform-runtime": "^7.3.4", - "@babel/polyfill": "~7.2.5", - "@babel/preset-env": "~7.3.4", - "@babel/runtime": "~7.3.4", - "buffer": "^6.0.3", - "clang-format": "~1.2.2", - "crypto-browserify": "^3.12.0", - "events": "^3.3.0", - "parcel": "~2.3.2", - "process": "^0.11.10", - "stream-browserify": "^3.0.0" - }, - "browserslist": "> 0.25%, not dead" -} diff --git a/tfjs-master/tfjs-converter/demo/ssd/classes.js b/tfjs-master/tfjs-converter/demo/ssd/classes.js deleted file mode 100644 index b814deaaf..000000000 --- a/tfjs-master/tfjs-converter/demo/ssd/classes.js +++ /dev/null @@ -1,400 +0,0 @@ -export const CLASSES = [{ - name: "/m/01g317", - id: 1, - display_name: "person", -}, -{ - name: "/m/0199g", - id: 2, - display_name: "bicycle", -}, -{ - name: "/m/0k4j", - id: 3, - display_name: "car", -}, -{ - name: "/m/04_sv", - id: 4, - display_name: "motorcycle", -}, -{ - name: "/m/05czz6l", - id: 5, - display_name: "airplane", -}, -{ - name: "/m/01bjv", - id: 6, - display_name: "bus", -}, -{ - name: "/m/07jdr", - id: 7, - display_name: "train", -}, -{ - name: "/m/07r04", - id: 8, - display_name: "truck", -}, -{ - name: "/m/019jd", - id: 9, - display_name: "boat", -}, -{ - name: "/m/015qff", - id: 10, - display_name: "traffic light", -}, -{ - name: "/m/01pns0", - id: 11, - display_name: "fire hydrant", -}, -{ - name: "/m/02pv19", - id: 13, - display_name: "stop sign", -}, -{ - name: "/m/015qbp", - id: 14, - display_name: "parking meter", -}, -{ - name: "/m/0cvnqh", - id: 15, - display_name: "bench", -}, -{ - name: "/m/015p6", - id: 16, - display_name: "bird", -}, -{ - name: "/m/01yrx", - id: 17, - display_name: "cat", -}, -{ - name: "/m/0bt9lr", - id: 18, - display_name: "dog", -}, -{ - name: "/m/03k3r", - id: 19, - display_name: "horse", -}, -{ - name: "/m/07bgp", - id: 20, - display_name: "sheep", -}, -{ - name: "/m/01xq0k1", - id: 21, - display_name: "cow", -}, -{ - name: "/m/0bwd_0j", - id: 22, - display_name: "elephant", -}, -{ - name: "/m/01dws", - id: 23, - display_name: "bear", -}, -{ - name: "/m/0898b", - id: 24, - display_name: "zebra", -}, -{ - name: "/m/03bk1", - id: 25, - display_name: "giraffe", -}, -{ - name: "/m/01940j", - id: 27, - display_name: "backpack", -}, -{ - name: "/m/0hnnb", - id: 28, - display_name: "umbrella", -}, -{ - name: "/m/080hkjn", - id: 31, - display_name: "handbag", -}, -{ - name: "/m/01rkbr", - id: 32, - display_name: "tie", -}, -{ - name: "/m/01s55n", - id: 33, - display_name: "suitcase", -}, -{ - name: "/m/02wmf", - id: 34, - display_name: "frisbee", -}, -{ - name: "/m/071p9", - id: 35, - display_name: "skis", -}, -{ - name: "/m/06__v", - id: 36, - display_name: "snowboard", -}, -{ - name: "/m/018xm", - id: 37, - display_name: "sports ball", -}, -{ - name: "/m/02zt3", - id: 38, - display_name: "kite", -}, -{ - name: "/m/03g8mr", - id: 39, - display_name: "baseball bat", -}, -{ - name: "/m/03grzl", - id: 40, - display_name: "baseball glove", -}, -{ - name: "/m/06_fw", - id: 41, - display_name: "skateboard", -}, -{ - name: "/m/019w40", - id: 42, - display_name: "surfboard", -}, -{ - name: "/m/0dv9c", - id: 43, - display_name: "tennis racket", -}, -{ - name: "/m/04dr76w", - id: 44, - display_name: "bottle", -}, -{ - name: "/m/09tvcd", - id: 46, - display_name: "wine glass", -}, -{ - name: "/m/08gqpm", - id: 47, - display_name: "cup", -}, -{ - name: "/m/0dt3t", - id: 48, - display_name: "fork", -}, -{ - name: "/m/04ctx", - id: 49, - display_name: "knife", -}, -{ - name: "/m/0cmx8", - id: 50, - display_name: "spoon", -}, -{ - name: "/m/04kkgm", - id: 51, - display_name: "bowl", -}, -{ - name: "/m/09qck", - id: 52, - display_name: "banana", -}, -{ - name: "/m/014j1m", - id: 53, - display_name: "apple", -}, -{ - name: "/m/0l515", - id: 54, - display_name: "sandwich", -}, -{ - name: "/m/0cyhj_", - id: 55, - display_name: "orange", -}, -{ - name: "/m/0hkxq", - id: 56, - display_name: "broccoli", -}, -{ - name: "/m/0fj52s", - id: 57, - display_name: "carrot", -}, -{ - name: "/m/01b9xk", - id: 58, - display_name: "hot dog", -}, -{ - name: "/m/0663v", - id: 59, - display_name: "pizza", -}, -{ - name: "/m/0jy4k", - id: 60, - display_name: "donut", -}, -{ - name: "/m/0fszt", - id: 61, - display_name: "cake", -}, -{ - name: "/m/01mzpv", - id: 62, - display_name: "chair", -}, -{ - name: "/m/02crq1", - id: 63, - display_name: "couch", -}, -{ - name: "/m/03fp41", - id: 64, - display_name: "potted plant", -}, -{ - name: "/m/03ssj5", - id: 65, - display_name: "bed", -}, -{ - name: "/m/04bcr3", - id: 67, - display_name: "dining table", -}, -{ - name: "/m/09g1w", - id: 70, - display_name: "toilet", -}, -{ - name: "/m/07c52", - id: 72, - display_name: "tv", -}, -{ - name: "/m/01c648", - id: 73, - display_name: "laptop", -}, -{ - name: "/m/020lf", - id: 74, - display_name: "mouse", -}, -{ - name: "/m/0qjjc", - id: 75, - display_name: "remote", -}, -{ - name: "/m/01m2v", - id: 76, - display_name: "keyboard", -}, -{ - name: "/m/050k8", - id: 77, - display_name: "cell phone", -}, -{ - name: "/m/0fx9l", - id: 78, - display_name: "microwave", -}, -{ - name: "/m/029bxz", - id: 79, - display_name: "oven", -}, -{ - name: "/m/01k6s3", - id: 80, - display_name: "toaster", -}, -{ - name: "/m/0130jx", - id: 81, - display_name: "sink", -}, -{ - name: "/m/040b_t", - id: 82, - display_name: "refrigerator", -}, -{ - name: "/m/0bt_c3", - id: 84, - display_name: "book", -}, -{ - name: "/m/01x3z", - id: 85, - display_name: "clock", -}, -{ - name: "/m/02s195", - id: 86, - display_name: "vase", -}, -{ - name: "/m/01lsmm", - id: 87, - display_name: "scissors", -}, -{ - name: "/m/0kmg4", - id: 88, - display_name: "teddy bear", -}, -{ - name: "/m/03wvsk", - id: 89, - display_name: "hair drier", -}, -{ - name: "/m/012xff", - id: 90, - display_name: "toothbrush", -}]; diff --git a/tfjs-master/tfjs-converter/demo/ssd/image1.jpg b/tfjs-master/tfjs-converter/demo/ssd/image1.jpg deleted file mode 100644 index 8886504c2..000000000 Binary files a/tfjs-master/tfjs-converter/demo/ssd/image1.jpg and /dev/null differ diff --git a/tfjs-master/tfjs-converter/demo/ssd/image2.jpg b/tfjs-master/tfjs-converter/demo/ssd/image2.jpg deleted file mode 100644 index 2ff570d1c..000000000 Binary files a/tfjs-master/tfjs-converter/demo/ssd/image2.jpg and /dev/null differ diff --git a/tfjs-master/tfjs-converter/demo/ssd/index.html b/tfjs-master/tfjs-converter/demo/ssd/index.html deleted file mode 100644 index 303916875..000000000 --- a/tfjs-master/tfjs-converter/demo/ssd/index.html +++ /dev/null @@ -1,29 +0,0 @@ - - - - - -

TensorFlow.js converter: ssd_mobilenet_v1_coco_2018_01_28

- - -
- - -
- - - - diff --git a/tfjs-master/tfjs-converter/demo/ssd/index.js b/tfjs-master/tfjs-converter/demo/ssd/index.js deleted file mode 100644 index 302aa8a6e..000000000 --- a/tfjs-master/tfjs-converter/demo/ssd/index.js +++ /dev/null @@ -1,53 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import 'babel-polyfill'; -import * as tf from '@tensorflow/tfjs'; -import {CLASSES} from './classes'; -import imageURL from './image1.jpg'; -import image2URL from './image2.jpg'; - -const GOOGLE_CLOUD_STORAGE_DIR = - 'https://storage.googleapis.com/tfjs-models/savedmodel/'; -const MODEL_URL = GOOGLE_CLOUD_STORAGE_DIR + 'ssdlite_mobilenet_v2/model.json'; - -let modelPromise; - -window.onload = () => modelPromise = tf.loadGraphModel(MODEL_URL); - -const button = document.getElementById('toggle'); -button.onclick = () => { - image.src = image.src.endsWith(imageURL) ? image2URL : imageURL; -}; - -const image = document.getElementById('image'); -image.src = imageURL; - -const runButton = document.getElementById('run'); -runButton.onclick = async () => { - const model = await modelPromise; - const pixels = tf.browser.fromPixels(image); - console.log('model loaded'); - console.time('predict1'); - const res1 = await model.executeAsync(pixels.reshape([1, ...pixels.shape])); - res1.map(t => t.dataSync()); - console.timeEnd('predict1'); - console.time('predict2'); - const res2 = await model.executeAsync(pixels.reshape([1, ...pixels.shape])); - const boxes = res2[0].dataSync(); - const scores = res2[1].dataSync(); - console.timeEnd('predict2'); -}; diff --git a/tfjs-master/tfjs-converter/demo/yarn.lock b/tfjs-master/tfjs-converter/demo/yarn.lock deleted file mode 100644 index 1b4692858..000000000 --- a/tfjs-master/tfjs-converter/demo/yarn.lock +++ /dev/null @@ -1,3083 +0,0 @@ -# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. -# yarn lockfile v1 - - -"@babel/code-frame@^7.0.0", "@babel/code-frame@^7.16.7": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.16.7.tgz#44416b6bd7624b998f5b1af5d470856c40138789" - integrity sha512-iAXqUn8IIeBTNd72xsFlgaXHkMBMt6y4HJp1tIaK465CWLT/fG1aqB7ykr95gHHmlBdGbFeWWfyB4NJJ0nmeIg== - dependencies: - "@babel/highlight" "^7.16.7" - -"@babel/core@^7.0.0-0": - version "7.3.4" - resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.3.4.tgz#921a5a13746c21e32445bf0798680e9d11a6530b" - integrity sha512-jRsuseXBo9pN197KnDwhhaaBzyZr2oIcLHHTt2oDdQrej5Qp57dCCJafWx5ivU8/alEYDpssYqv1MUqcxwQlrA== - dependencies: - "@babel/code-frame" "^7.0.0" - "@babel/generator" "^7.3.4" - "@babel/helpers" "^7.2.0" - "@babel/parser" "^7.3.4" - "@babel/template" "^7.2.2" - "@babel/traverse" "^7.3.4" - "@babel/types" "^7.3.4" - convert-source-map "^1.1.0" - debug "^4.1.0" - json5 "^2.1.0" - lodash "^4.17.11" - resolve "^1.3.2" - semver "^5.4.1" - source-map "^0.5.0" - -"@babel/generator@^7.17.3": - version "7.17.7" - resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.17.7.tgz#8da2599beb4a86194a3b24df6c085931d9ee45ad" - integrity sha512-oLcVCTeIFadUoArDTwpluncplrYBmTCCZZgXCbgNGvOBBiSDDK3eWO4b/+eOTli5tKv1lg+a5/NAXg+nTcei1w== - dependencies: - "@babel/types" "^7.17.0" - jsesc "^2.5.1" - source-map "^0.5.0" - -"@babel/generator@^7.3.4": - version "7.3.4" - resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.3.4.tgz#9aa48c1989257877a9d971296e5b73bfe72e446e" - integrity sha512-8EXhHRFqlVVWXPezBW5keTiQi/rJMQTg/Y9uVCEZ0CAF3PKtCCaVRnp64Ii1ujhkoDhhF1fVsImoN4yJ2uz4Wg== - dependencies: - "@babel/types" "^7.3.4" - jsesc "^2.5.1" - lodash "^4.17.11" - source-map "^0.5.0" - trim-right "^1.0.1" - -"@babel/helper-annotate-as-pure@^7.16.7": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.16.7.tgz#bb2339a7534a9c128e3102024c60760a3a7f3862" - integrity sha512-s6t2w/IPQVTAET1HitoowRGXooX8mCgtuP5195wD/QJPV6wYjpujCGF7JuMODVX2ZAJOf1GT6DT9MHEZvLOFSw== - dependencies: - "@babel/types" "^7.16.7" - -"@babel/helper-builder-binary-assignment-operator-visitor@^7.16.7": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/helper-builder-binary-assignment-operator-visitor/-/helper-builder-binary-assignment-operator-visitor-7.16.7.tgz#38d138561ea207f0f69eb1626a418e4f7e6a580b" - integrity sha512-C6FdbRaxYjwVu/geKW4ZeQ0Q31AftgRcdSnZ5/jsH6BzCJbtvXvhpfkbkThYSuutZA7nCXpPR6AD9zd1dprMkA== - dependencies: - "@babel/helper-explode-assignable-expression" "^7.16.7" - "@babel/types" "^7.16.7" - -"@babel/helper-environment-visitor@^7.16.7": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/helper-environment-visitor/-/helper-environment-visitor-7.16.7.tgz#ff484094a839bde9d89cd63cba017d7aae80ecd7" - integrity sha512-SLLb0AAn6PkUeAfKJCCOl9e1R53pQlGAfc4y4XuMRZfqeMYLE0dM1LMhqbGAlGQY0lfw5/ohoYWAe9V1yibRag== - dependencies: - "@babel/types" "^7.16.7" - -"@babel/helper-explode-assignable-expression@^7.16.7": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/helper-explode-assignable-expression/-/helper-explode-assignable-expression-7.16.7.tgz#12a6d8522fdd834f194e868af6354e8650242b7a" - integrity sha512-KyUenhWMC8VrxzkGP0Jizjo4/Zx+1nNZhgocs+gLzyZyB8SHidhoq9KK/8Ato4anhwsivfkBLftky7gvzbZMtQ== - dependencies: - "@babel/types" "^7.16.7" - -"@babel/helper-function-name@^7.16.7": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/helper-function-name/-/helper-function-name-7.16.7.tgz#f1ec51551fb1c8956bc8dd95f38523b6cf375f8f" - integrity sha512-QfDfEnIUyyBSR3HtrtGECuZ6DAyCkYFp7GHl75vFtTnn6pjKeK0T1DB5lLkFvBea8MdaiUABx3osbgLyInoejA== - dependencies: - "@babel/helper-get-function-arity" "^7.16.7" - "@babel/template" "^7.16.7" - "@babel/types" "^7.16.7" - -"@babel/helper-get-function-arity@^7.16.7": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/helper-get-function-arity/-/helper-get-function-arity-7.16.7.tgz#ea08ac753117a669f1508ba06ebcc49156387419" - integrity sha512-flc+RLSOBXzNzVhcLu6ujeHUrD6tANAOU5ojrRx/as+tbzf8+stUCj7+IfRRoAbEZqj/ahXEMsjhOhgeZsrnTw== - dependencies: - "@babel/types" "^7.16.7" - -"@babel/helper-hoist-variables@^7.16.7": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/helper-hoist-variables/-/helper-hoist-variables-7.16.7.tgz#86bcb19a77a509c7b77d0e22323ef588fa58c246" - integrity sha512-m04d/0Op34H5v7pbZw6pSKP7weA6lsMvfiIAMeIvkY/R4xQtBSMFEigu9QTZ2qB/9l22vsxtM8a+Q8CzD255fg== - dependencies: - "@babel/types" "^7.16.7" - -"@babel/helper-member-expression-to-functions@^7.16.7": - version "7.17.7" - resolved "https://registry.yarnpkg.com/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.17.7.tgz#a34013b57d8542a8c4ff8ba3f747c02452a4d8c4" - integrity sha512-thxXgnQ8qQ11W2wVUObIqDL4p148VMxkt5T/qpN5k2fboRyzFGFmKsTGViquyM5QHKUy48OZoca8kw4ajaDPyw== - dependencies: - "@babel/types" "^7.17.0" - -"@babel/helper-module-imports@^7.0.0": - version "7.0.0" - resolved "https://registry.yarnpkg.com/@babel/helper-module-imports/-/helper-module-imports-7.0.0.tgz#96081b7111e486da4d2cd971ad1a4fe216cc2e3d" - integrity sha512-aP/hlLq01DWNEiDg4Jn23i+CXxW/owM4WpDLFUbpjxe4NS3BhLVZQ5i7E0ZrxuQ/vwekIeciyamgB1UIYxxM6A== - dependencies: - "@babel/types" "^7.0.0" - -"@babel/helper-module-imports@^7.16.7": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/helper-module-imports/-/helper-module-imports-7.16.7.tgz#25612a8091a999704461c8a222d0efec5d091437" - integrity sha512-LVtS6TqjJHFc+nYeITRo6VLXve70xmq7wPhWTqDJusJEgGmkAACWwMiTNrvfoQo6hEhFwAIixNkvB0jPXDL8Wg== - dependencies: - "@babel/types" "^7.16.7" - -"@babel/helper-module-transforms@^7.16.7", "@babel/helper-module-transforms@^7.17.7": - version "7.17.7" - resolved "https://registry.yarnpkg.com/@babel/helper-module-transforms/-/helper-module-transforms-7.17.7.tgz#3943c7f777139e7954a5355c815263741a9c1cbd" - integrity sha512-VmZD99F3gNTYB7fJRDTi+u6l/zxY0BE6OIxPSU7a50s6ZUQkHwSDmV92FfM+oCG0pZRVojGYhkR8I0OGeCVREw== - dependencies: - "@babel/helper-environment-visitor" "^7.16.7" - "@babel/helper-module-imports" "^7.16.7" - "@babel/helper-simple-access" "^7.17.7" - "@babel/helper-split-export-declaration" "^7.16.7" - "@babel/helper-validator-identifier" "^7.16.7" - "@babel/template" "^7.16.7" - "@babel/traverse" "^7.17.3" - "@babel/types" "^7.17.0" - -"@babel/helper-optimise-call-expression@^7.16.7": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.16.7.tgz#a34e3560605abbd31a18546bd2aad3e6d9a174f2" - integrity sha512-EtgBhg7rd/JcnpZFXpBy0ze1YRfdm7BnBX4uKMBd3ixa3RGAE002JZB66FJyNH7g0F38U05pXmA5P8cBh7z+1w== - dependencies: - "@babel/types" "^7.16.7" - -"@babel/helper-plugin-utils@^7.0.0": - version "7.0.0" - resolved "https://registry.yarnpkg.com/@babel/helper-plugin-utils/-/helper-plugin-utils-7.0.0.tgz#bbb3fbee98661c569034237cc03967ba99b4f250" - integrity sha512-CYAOUCARwExnEixLdB6sDm2dIJ/YgEAKDM1MOeMeZu9Ld/bDgVo8aiWrXwcY7OBh+1Ea2uUcVRcxKk0GJvW7QA== - -"@babel/helper-plugin-utils@^7.16.7", "@babel/helper-plugin-utils@^7.8.0": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/helper-plugin-utils/-/helper-plugin-utils-7.16.7.tgz#aa3a8ab4c3cceff8e65eb9e73d87dc4ff320b2f5" - integrity sha512-Qg3Nk7ZxpgMrsox6HreY1ZNKdBq7K72tDSliA6dCl5f007jR4ne8iD5UzuNnCJH2xBf2BEEVGr+/OL6Gdp7RxA== - -"@babel/helper-remap-async-to-generator@^7.16.8": - version "7.16.8" - resolved "https://registry.yarnpkg.com/@babel/helper-remap-async-to-generator/-/helper-remap-async-to-generator-7.16.8.tgz#29ffaade68a367e2ed09c90901986918d25e57e3" - integrity sha512-fm0gH7Flb8H51LqJHy3HJ3wnE1+qtYR2A99K06ahwrawLdOFsCEWjZOrYricXJHoPSudNKxrMBUPEIPxiIIvBw== - dependencies: - "@babel/helper-annotate-as-pure" "^7.16.7" - "@babel/helper-wrap-function" "^7.16.8" - "@babel/types" "^7.16.8" - -"@babel/helper-replace-supers@^7.16.7": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/helper-replace-supers/-/helper-replace-supers-7.16.7.tgz#e9f5f5f32ac90429c1a4bdec0f231ef0c2838ab1" - integrity sha512-y9vsWilTNaVnVh6xiJfABzsNpgDPKev9HnAgz6Gb1p6UUwf9NepdlsV7VXGCftJM+jqD5f7JIEubcpLjZj5dBw== - dependencies: - "@babel/helper-environment-visitor" "^7.16.7" - "@babel/helper-member-expression-to-functions" "^7.16.7" - "@babel/helper-optimise-call-expression" "^7.16.7" - "@babel/traverse" "^7.16.7" - "@babel/types" "^7.16.7" - -"@babel/helper-simple-access@^7.17.7": - version "7.17.7" - resolved "https://registry.yarnpkg.com/@babel/helper-simple-access/-/helper-simple-access-7.17.7.tgz#aaa473de92b7987c6dfa7ce9a7d9674724823367" - integrity sha512-txyMCGroZ96i+Pxr3Je3lzEJjqwaRC9buMUgtomcrLe5Nd0+fk1h0LLA+ixUF5OW7AhHuQ7Es1WcQJZmZsz2XA== - dependencies: - "@babel/types" "^7.17.0" - -"@babel/helper-skip-transparent-expression-wrappers@^7.16.0": - version "7.16.0" - resolved "https://registry.yarnpkg.com/@babel/helper-skip-transparent-expression-wrappers/-/helper-skip-transparent-expression-wrappers-7.16.0.tgz#0ee3388070147c3ae051e487eca3ebb0e2e8bb09" - integrity sha512-+il1gTy0oHwUsBQZyJvukbB4vPMdcYBrFHa0Uc4AizLxbq6BOYC51Rv4tWocX9BLBDLZ4kc6qUFpQ6HRgL+3zw== - dependencies: - "@babel/types" "^7.16.0" - -"@babel/helper-split-export-declaration@^7.16.7": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.16.7.tgz#0b648c0c42da9d3920d85ad585f2778620b8726b" - integrity sha512-xbWoy/PFoxSWazIToT9Sif+jJTlrMcndIsaOKvTA6u7QEo7ilkRZpjew18/W3c7nm8fXdUDXh02VXTbZ0pGDNw== - dependencies: - "@babel/types" "^7.16.7" - -"@babel/helper-validator-identifier@^7.16.7": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz#e8c602438c4a8195751243da9031d1607d247cad" - integrity sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw== - -"@babel/helper-wrap-function@^7.16.8": - version "7.16.8" - resolved "https://registry.yarnpkg.com/@babel/helper-wrap-function/-/helper-wrap-function-7.16.8.tgz#58afda087c4cd235de92f7ceedebca2c41274200" - integrity sha512-8RpyRVIAW1RcDDGTA+GpPAwV22wXCfKOoM9bet6TLkGIFTkRQSkH1nMQ5Yet4MpoXe1ZwHPVtNasc2w0uZMqnw== - dependencies: - "@babel/helper-function-name" "^7.16.7" - "@babel/template" "^7.16.7" - "@babel/traverse" "^7.16.8" - "@babel/types" "^7.16.8" - -"@babel/helpers@^7.2.0": - version "7.3.1" - resolved "https://registry.yarnpkg.com/@babel/helpers/-/helpers-7.3.1.tgz#949eec9ea4b45d3210feb7dc1c22db664c9e44b9" - integrity "sha1-lJ7snqS0XTIQ/rfcHCLbZkyeRLk= sha512-Q82R3jKsVpUV99mgX50gOPCWwco9Ec5Iln/8Vyu4osNIOQgSrd9RFrQeUvmvddFNoLwMyOUWU+5ckioEKpDoGA==" - dependencies: - "@babel/template" "^7.1.2" - "@babel/traverse" "^7.1.5" - "@babel/types" "^7.3.0" - -"@babel/highlight@^7.16.7": - version "7.16.10" - resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.16.10.tgz#744f2eb81579d6eea753c227b0f570ad785aba88" - integrity sha512-5FnTQLSLswEj6IkgVw5KusNUUFY9ZGqe/TRFnP/BKYHYgfh7tc+C7mwiy95/yNP7Dh9x580Vv8r7u7ZfTBFxdw== - dependencies: - "@babel/helper-validator-identifier" "^7.16.7" - chalk "^2.0.0" - js-tokens "^4.0.0" - -"@babel/parser@^7.16.7", "@babel/parser@^7.17.3", "@babel/parser@^7.3.4": - version "7.17.8" - resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.17.8.tgz#2817fb9d885dd8132ea0f8eb615a6388cca1c240" - integrity sha512-BoHhDJrJXqcg+ZL16Xv39H9n+AqJ4pcDrQBGZN+wHxIysrLZ3/ECwCBUch/1zUNhnsXULcONU3Ei5Hmkfk6kiQ== - -"@babel/plugin-proposal-async-generator-functions@^7.2.0": - version "7.16.8" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-async-generator-functions/-/plugin-proposal-async-generator-functions-7.16.8.tgz#3bdd1ebbe620804ea9416706cd67d60787504bc8" - integrity sha512-71YHIvMuiuqWJQkebWJtdhQTfd4Q4mF76q2IX37uZPkG9+olBxsX+rH1vkhFto4UeJZ9dPY2s+mDvhDm1u2BGQ== - dependencies: - "@babel/helper-plugin-utils" "^7.16.7" - "@babel/helper-remap-async-to-generator" "^7.16.8" - "@babel/plugin-syntax-async-generators" "^7.8.4" - -"@babel/plugin-proposal-json-strings@^7.2.0": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-json-strings/-/plugin-proposal-json-strings-7.16.7.tgz#9732cb1d17d9a2626a08c5be25186c195b6fa6e8" - integrity sha512-lNZ3EEggsGY78JavgbHsK9u5P3pQaW7k4axlgFLYkMd7UBsiNahCITShLjNQschPyjtO6dADrL24757IdhBrsQ== - dependencies: - "@babel/helper-plugin-utils" "^7.16.7" - "@babel/plugin-syntax-json-strings" "^7.8.3" - -"@babel/plugin-proposal-object-rest-spread@^7.3.4": - version "7.3.4" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-object-rest-spread/-/plugin-proposal-object-rest-spread-7.3.4.tgz#47f73cf7f2a721aad5c0261205405c642e424654" - integrity "sha1-R/c89/KnIarVwCYSBUBcZC5CRlQ= sha512-j7VQmbbkA+qrzNqbKHrBsW3ddFnOeva6wzSe/zB7T+xaxGc+RCpwo44wCmRixAIGRoIpmVgvzFzNJqQcO3/9RA==" - dependencies: - chalk "^4.1.0" - -"@babel/plugin-proposal-optional-catch-binding@^7.2.0": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-optional-catch-binding/-/plugin-proposal-optional-catch-binding-7.16.7.tgz#c623a430674ffc4ab732fd0a0ae7722b67cb74cf" - integrity sha512-eMOH/L4OvWSZAE1VkHbr1vckLG1WUcHGJSLqqQwl2GaUqG6QjddvrOaTUMNYiv77H5IKPMZ9U9P7EaHwvAShfA== - dependencies: - "@babel/helper-plugin-utils" "^7.16.7" - "@babel/plugin-syntax-optional-catch-binding" "^7.8.3" - -"@babel/plugin-proposal-unicode-property-regex@^7.2.0": - version "7.2.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-unicode-property-regex/-/plugin-proposal-unicode-property-regex-7.2.0.tgz#abe7281fe46c95ddc143a65e5358647792039520" - integrity "sha1-q+coH+Rsld3BQ6ZeU1hkd5IDlSA= sha512-LvRVYb7kikuOtIoUeWTkOxQEV1kYvL5B6U3iWEGCzPNRus1MzJweFqORTj+0jkxozkTSYNJozPOddxmqdqsRpw==" - dependencies: - "@parcel/bundler-default" "2.3.2" - "@parcel/compressor-raw" "2.3.2" - "@parcel/namer-default" "2.3.2" - "@parcel/optimizer-cssnano" "2.3.2" - "@parcel/optimizer-htmlnano" "2.3.2" - "@parcel/optimizer-image" "2.3.2" - "@parcel/optimizer-svgo" "2.3.2" - "@parcel/optimizer-terser" "2.3.2" - "@parcel/packager-css" "2.3.2" - "@parcel/packager-html" "2.3.2" - "@parcel/packager-js" "2.3.2" - "@parcel/packager-raw" "2.3.2" - "@parcel/packager-svg" "2.3.2" - "@parcel/reporter-dev-server" "2.3.2" - "@parcel/resolver-default" "2.3.2" - "@parcel/runtime-browser-hmr" "2.3.2" - "@parcel/runtime-js" "2.3.2" - "@parcel/runtime-react-refresh" "2.3.2" - "@parcel/runtime-service-worker" "2.3.2" - "@parcel/transformer-babel" "2.3.2" - "@parcel/transformer-css" "2.3.2" - "@parcel/transformer-html" "2.3.2" - "@parcel/transformer-image" "2.3.2" - "@parcel/transformer-js" "2.3.2" - "@parcel/transformer-json" "2.3.2" - "@parcel/transformer-postcss" "2.3.2" - "@parcel/transformer-posthtml" "2.3.2" - "@parcel/transformer-raw" "2.3.2" - "@parcel/transformer-react-refresh-wrap" "2.3.2" - "@parcel/transformer-svg" "2.3.2" - -"@babel/plugin-syntax-async-generators@^7.2.0", "@babel/plugin-syntax-async-generators@^7.8.4": - version "7.8.4" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-async-generators/-/plugin-syntax-async-generators-7.8.4.tgz#a983fb1aeb2ec3f6ed042a210f640e90e786fe0d" - integrity sha512-tycmZxkGfZaxhMRbXlPXuVFpdWlXpir2W4AMhSJgRKzk/eDlIXOhb2LHWoLpDF7TEHylV5zNhykX6KAgHJmTNw== - dependencies: - "@babel/helper-plugin-utils" "^7.8.0" - -"@babel/plugin-syntax-json-strings@^7.2.0", "@babel/plugin-syntax-json-strings@^7.8.3": - version "7.8.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-json-strings/-/plugin-syntax-json-strings-7.8.3.tgz#01ca21b668cd8218c9e640cb6dd88c5412b2c96a" - integrity sha512-lY6kdGpWHvjoe2vk4WrAapEuBR69EMxZl+RoGRhrFGNYVK8mOPAW8VfbT/ZgrFbXlDNiiaxQnAtgVCZ6jv30EA== - dependencies: - "@babel/helper-plugin-utils" "^7.8.0" - -"@babel/plugin-syntax-object-rest-spread@^7.2.0": - version "7.8.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-object-rest-spread/-/plugin-syntax-object-rest-spread-7.8.3.tgz#60e225edcbd98a640332a2e72dd3e66f1af55871" - integrity sha512-XoqMijGZb9y3y2XskN+P1wUGiVwWZ5JmoDRwx5+3GmEplNyVM2s2Dg8ILFQm8rWM48orGy5YpI5Bl8U1y7ydlA== - dependencies: - "@babel/helper-plugin-utils" "^7.8.0" - -"@babel/plugin-syntax-optional-catch-binding@^7.2.0", "@babel/plugin-syntax-optional-catch-binding@^7.8.3": - version "7.8.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-optional-catch-binding/-/plugin-syntax-optional-catch-binding-7.8.3.tgz#6111a265bcfb020eb9efd0fdfd7d26402b9ed6c1" - integrity sha512-6VPD0Pc1lpTqw0aKoeRTMiB+kWhAoT24PA+ksWSBrFtl5SIRVpZlwN3NNPQjehA2E/91FV3RjLWoVTglWcSV3Q== - dependencies: - "@babel/helper-plugin-utils" "^7.8.0" - -"@babel/plugin-transform-arrow-functions@^7.2.0": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-arrow-functions/-/plugin-transform-arrow-functions-7.16.7.tgz#44125e653d94b98db76369de9c396dc14bef4154" - integrity sha512-9ffkFFMbvzTvv+7dTp/66xvZAWASuPD5Tl9LK3Z9vhOmANo6j94rik+5YMBt4CwHVMWLWpMsriIc2zsa3WW3xQ== - dependencies: - "@babel/helper-plugin-utils" "^7.16.7" - -"@babel/plugin-transform-async-to-generator@^7.3.4": - version "7.3.4" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-async-to-generator/-/plugin-transform-async-to-generator-7.3.4.tgz#4e45408d3c3da231c0e7b823f407a53a7eb3048c" - integrity "sha1-TkVAjTw9ojHA57gj9AelOn6zBIw= sha512-Y7nCzv2fw/jEZ9f678MuKdMo99MFDJMT/PvD9LisrR5JDFcJH6vYeH6RnjVt3p5tceyGRvTtEN0VOlU+rgHZjA==" - dependencies: - chalk "^4.1.0" - -"@babel/plugin-transform-block-scoped-functions@^7.2.0": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-block-scoped-functions/-/plugin-transform-block-scoped-functions-7.16.7.tgz#4d0d57d9632ef6062cdf354bb717102ee042a620" - integrity sha512-JUuzlzmF40Z9cXyytcbZEZKckgrQzChbQJw/5PuEHYeqzCsvebDx0K0jWnIIVcmmDOAVctCgnYs0pMcrYj2zJg== - dependencies: - "@babel/helper-plugin-utils" "^7.16.7" - -"@babel/plugin-transform-block-scoping@^7.3.4": - version "7.3.4" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-block-scoping/-/plugin-transform-block-scoping-7.3.4.tgz#5c22c339de234076eee96c8783b2fed61202c5c4" - integrity "sha1-XCLDOd4jQHbu6WyHg7L+1hICxcQ= sha512-blRr2O8IOZLAOJklXLV4WhcEzpYafYQKSGT3+R26lWG41u/FODJuBggehtOwilVAcFu393v3OFj+HmaE6tVjhA==" - dependencies: - "@parcel/diagnostic" "2.3.2" - "@parcel/utils" "2.3.2" - nullthrows "^1.1.1" - -"@babel/plugin-transform-classes@^7.3.4": - version "7.3.4" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-classes/-/plugin-transform-classes-7.3.4.tgz#dc173cb999c6c5297e0b5f2277fdaaec3739d0cc" - integrity "sha1-3Bc8uZnGxSl+C18id/2q7Dc50Mw= sha512-J9fAvCFBkXEvBimgYxCjvaVDzL6thk0j0dBvCeZmIUDBwyt+nv6HfbImsSrWsYXfDNDivyANgJlFXDUWRTZBuA==" - dependencies: - "@parcel/plugin" "2.3.2" - "@parcel/source-map" "^2.0.0" - cssnano "^5.0.15" - postcss "^8.4.5" - -"@babel/plugin-transform-computed-properties@^7.2.0": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-computed-properties/-/plugin-transform-computed-properties-7.16.7.tgz#66dee12e46f61d2aae7a73710f591eb3df616470" - integrity sha512-gN72G9bcmenVILj//sv1zLNaPyYcOzUho2lIJBMh/iakJ9ygCo/hEF9cpGb61SCMEDxbbyBoVQxrt+bWKu5KGw== - dependencies: - "@babel/helper-plugin-utils" "^7.16.7" - -"@babel/plugin-transform-destructuring@^7.2.0": - version "7.3.2" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-destructuring/-/plugin-transform-destructuring-7.3.2.tgz#f2f5520be055ba1c38c41c0e094d8a461dd78f2d" - integrity "sha1-8vVSC+BVuhw4xBwOCU2KRh3Xjy0= sha512-Lrj/u53Ufqxl/sGxyjsJ2XNtNuEjDyjpqdhMNh5aZ+XFOdThL46KBj27Uem4ggoezSYBxKWAil6Hu8HtwqesYw==" - dependencies: - "@parcel/diagnostic" "2.3.2" - "@parcel/plugin" "2.3.2" - "@parcel/utils" "2.3.2" - "@parcel/workers" "2.3.2" - detect-libc "^1.0.3" - -"@babel/plugin-transform-dotall-regex@^7.2.0": - version "7.2.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-dotall-regex/-/plugin-transform-dotall-regex-7.2.0.tgz#f0aabb93d120a8ac61e925ea0ba440812dbe0e49" - integrity "sha1-8Kq7k9EgqKxh6SXqC6RAgS2+Dkk= sha512-sKxnyHfizweTgKZf7XsXu/CNupKhzijptfTM+bozonIuyVrLWVUvYjE2bhuSBML8VQeMxq4Mm63Q9qvcvUcciQ==" - dependencies: - "@parcel/diagnostic" "2.3.2" - "@parcel/plugin" "2.3.2" - "@parcel/utils" "2.3.2" - svgo "^2.4.0" - -"@babel/plugin-transform-duplicate-keys@^7.2.0": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-duplicate-keys/-/plugin-transform-duplicate-keys-7.16.7.tgz#2207e9ca8f82a0d36a5a67b6536e7ef8b08823c9" - integrity sha512-03DvpbRfvWIXyK0/6QiR1KMTWeT6OcQ7tbhjrXyFS02kjuX/mu5Bvnh5SDSWHxyawit2g5aWhKwI86EE7GUnTw== - dependencies: - "@babel/helper-plugin-utils" "^7.16.7" - -"@babel/plugin-transform-exponentiation-operator@^7.2.0": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-exponentiation-operator/-/plugin-transform-exponentiation-operator-7.16.7.tgz#efa9862ef97e9e9e5f653f6ddc7b665e8536fe9b" - integrity sha512-8UYLSlyLgRixQvlYH3J2ekXFHDFLQutdy7FfFAMm3CPZ6q9wHCwnUyiXpQCe3gVVnQlHc5nsuiEVziteRNTXEA== - dependencies: - "@babel/helper-builder-binary-assignment-operator-visitor" "^7.16.7" - "@babel/helper-plugin-utils" "^7.16.7" - -"@babel/plugin-transform-for-of@^7.2.0": - version "7.2.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-for-of/-/plugin-transform-for-of-7.2.0.tgz#ab7468befa80f764bb03d3cb5eef8cc998e1cad9" - integrity "sha1-q3RovvqA92S7A9PLXu+MyZjhytk= sha512-Kz7Mt0SsV2tQk6jG5bBv5phVbkd0gd27SgYD4hH1aLMJRchM0dzHaXvrWhVZ+WxAlDoAKZ7Uy3jVTW2mKXQ1WQ==" - dependencies: - "@parcel/plugin" "2.3.2" - "@parcel/types" "2.3.2" - "@parcel/utils" "2.3.2" - nullthrows "^1.1.1" - posthtml "^0.16.5" - -"@babel/plugin-transform-function-name@^7.2.0": - version "7.2.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-function-name/-/plugin-transform-function-name-7.2.0.tgz#f7930362829ff99a3174c39f0afcc024ef59731a" - integrity "sha1-95MDYoKf+ZoxdMOfCvzAJO9Zcxo= sha512-kWgksow9lHdvBC2Z4mxTsvc7YdY7w/V6B2vy9cTIPtLEE9NhwoWivaxdNM/S37elu5bqlLP/qOY906LukO9lkQ==" - dependencies: - "@parcel/diagnostic" "2.3.2" - "@parcel/hash" "2.3.2" - "@parcel/plugin" "2.3.2" - "@parcel/source-map" "^2.0.0" - "@parcel/utils" "2.3.2" - globals "^13.2.0" - nullthrows "^1.1.1" - -"@babel/plugin-transform-literals@^7.2.0": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-literals/-/plugin-transform-literals-7.16.7.tgz#254c9618c5ff749e87cb0c0cef1a0a050c0bdab1" - integrity sha512-6tH8RTpTWI0s2sV6uq3e/C9wPo4PTqqZps4uF0kzQ9/xPLFQtipynvmT1g/dOfEJ+0EQsHhkQ/zyRId8J2b8zQ== - dependencies: - "@babel/helper-plugin-utils" "^7.16.7" - -"@babel/plugin-transform-modules-amd@^7.2.0": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-amd/-/plugin-transform-modules-amd-7.16.7.tgz#b28d323016a7daaae8609781d1f8c9da42b13186" - integrity sha512-KaaEtgBL7FKYwjJ/teH63oAmE3lP34N3kshz8mm4VMAw7U3PxjVwwUmxEFksbgsNUaO3wId9R2AVQYSEGRa2+g== - dependencies: - "@babel/helper-module-transforms" "^7.16.7" - "@babel/helper-plugin-utils" "^7.16.7" - babel-plugin-dynamic-import-node "^2.3.3" - -"@babel/plugin-transform-modules-commonjs@^7.2.0": - version "7.17.7" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.17.7.tgz#d86b217c8e45bb5f2dbc11eefc8eab62cf980d19" - integrity sha512-ITPmR2V7MqioMJyrxUo2onHNC3e+MvfFiFIR0RP21d3PtlVb6sfzoxNKiphSZUOM9hEIdzCcZe83ieX3yoqjUA== - dependencies: - "@babel/helper-module-transforms" "^7.17.7" - "@babel/helper-plugin-utils" "^7.16.7" - "@babel/helper-simple-access" "^7.17.7" - babel-plugin-dynamic-import-node "^2.3.3" - -"@babel/plugin-transform-modules-systemjs@^7.3.4": - version "7.3.4" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-systemjs/-/plugin-transform-modules-systemjs-7.3.4.tgz#813b34cd9acb6ba70a84939f3680be0eb2e58861" - integrity "sha1-gTs0zZrLa6cKhJOfNoC+DrLliGE= sha512-VZ4+jlGOF36S7TjKs8g4ojp4MEI+ebCQZdswWb/T9I4X84j8OtFAyjXjt/M16iIm5RIZn0UMQgg/VgIwo/87vw==" - dependencies: - "@parcel/plugin" "2.3.2" - "@parcel/types" "2.3.2" - "@parcel/utils" "2.3.2" - chalk "^4.1.0" - -"@babel/plugin-transform-modules-umd@^7.2.0": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-umd/-/plugin-transform-modules-umd-7.16.7.tgz#23dad479fa585283dbd22215bff12719171e7618" - integrity sha512-EMh7uolsC8O4xhudF2F6wedbSHm1HHZ0C6aJ7K67zcDNidMzVcxWdGr+htW9n21klm+bOn+Rx4CBsAntZd3rEQ== - dependencies: - "@babel/helper-module-transforms" "^7.16.7" - "@babel/helper-plugin-utils" "^7.16.7" - -"@babel/plugin-transform-named-capturing-groups-regex@^7.3.0": - version "7.3.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-named-capturing-groups-regex/-/plugin-transform-named-capturing-groups-regex-7.3.0.tgz#140b52985b2d6ef0cb092ef3b29502b990f9cd50" - integrity "sha1-FAtSmFstbvDLCS7zspUCuZD5zVA= sha512-NxIoNVhk9ZxS+9lSoAQ/LM0V2UEvARLttEHUrRDGKFaAxOYQcrkN/nLRE+BbbicCAvZPl7wMP0X60HsHE5DtQw==" - dependencies: - "@parcel/node-resolver-core" "2.3.2" - "@parcel/plugin" "2.3.2" - -"@babel/plugin-transform-new-target@^7.0.0": - version "7.0.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-new-target/-/plugin-transform-new-target-7.0.0.tgz#ae8fbd89517fa7892d20e6564e641e8770c3aa4a" - integrity "sha1-ro+9iVF/p4ktIOZWTmQeh3DDqko= sha512-yin069FYjah+LbqfGeTfzIBODex/e++Yfa0rH0fpfam9uTbuEeEOx5GLGr210ggOV77mVRNoeqSYqeuaqSzVSw==" - dependencies: - "@parcel/plugin" "2.3.2" - "@parcel/utils" "2.3.2" - -"@babel/plugin-transform-object-super@^7.2.0": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-object-super/-/plugin-transform-object-super-7.16.7.tgz#ac359cf8d32cf4354d27a46867999490b6c32a94" - integrity sha512-14J1feiQVWaGvRxj2WjyMuXS2jsBkgB3MdSN5HuC2G5nRspa5RK9COcs82Pwy5BuGcjb+fYaUj94mYcOj7rCvw== - dependencies: - "@babel/helper-plugin-utils" "^7.16.7" - "@babel/helper-replace-supers" "^7.16.7" - -"@babel/plugin-transform-parameters@^7.2.0": - version "7.3.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-parameters/-/plugin-transform-parameters-7.3.3.tgz#3a873e07114e1a5bee17d04815662c8317f10e30" - integrity "sha1-Ooc+BxFOGlvuF9BIFWYsgxfxDjA= sha512-IrIP25VvXWu/VlBWTpsjGptpomtIkYrN/3aDp4UKm7xK6UxZY88kcJ1UwETbzHAlwN21MnNfwlar0u8y3KpiXw==" - dependencies: - "@parcel/plugin" "2.3.2" - "@parcel/utils" "2.3.2" - react-refresh "^0.9.0" - -"@babel/plugin-transform-regenerator@^7.3.4": - version "7.3.4" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-regenerator/-/plugin-transform-regenerator-7.3.4.tgz#1601655c362f5b38eead6a52631f5106b29fa46a" - integrity "sha1-FgFlXDYvWzjurWpSYx9RBrKfpGo= sha512-hvJg8EReQvXT6G9H2MvNPXkv9zK36Vxa1+csAVTpE1J3j0zlHplw76uudEbJxgvqZzAq9Yh45FLD4pk5mKRFQA==" - dependencies: - detect-libc "^1.0.3" - -"@babel/plugin-transform-runtime@^7.3.4": - version "7.3.4" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-runtime/-/plugin-transform-runtime-7.3.4.tgz#57805ac8c1798d102ecd75c03b024a5b3ea9b431" - integrity "sha1-V4BayMF5jRAuzXXAOwJKWz6ptDE= sha512-PaoARuztAdd5MgeVjAxnIDAIUet5KpogqaefQvPOmPYCxYoaPhautxDh3aO8a4xHsKgT/b9gSxR0BKK1MIewPA==" - dependencies: - "@parcel/diagnostic" "2.3.2" - "@parcel/plugin" "2.3.2" - "@parcel/source-map" "^2.0.0" - "@parcel/utils" "2.3.2" - browserslist "^4.6.6" - json5 "^2.2.0" - nullthrows "^1.1.1" - semver "^5.7.0" - -"@babel/plugin-transform-shorthand-properties@^7.2.0": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-shorthand-properties/-/plugin-transform-shorthand-properties-7.16.7.tgz#e8549ae4afcf8382f711794c0c7b6b934c5fbd2a" - integrity sha512-hah2+FEnoRoATdIb05IOXf+4GzXYTq75TVhIn1PewihbpyrNWUt2JbudKQOETWw6QpLe+AIUpJ5MVLYTQbeeUg== - dependencies: - "@babel/helper-plugin-utils" "^7.16.7" - -"@babel/plugin-transform-spread@^7.2.0": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-spread/-/plugin-transform-spread-7.16.7.tgz#a303e2122f9f12e0105daeedd0f30fb197d8ff44" - integrity sha512-+pjJpgAngb53L0iaA5gU/1MLXJIfXcYepLgXB3esVRf4fqmj8f2cxM3/FKaHsZms08hFQJkFccEWuIpm429TXg== - dependencies: - "@babel/helper-plugin-utils" "^7.16.7" - "@babel/helper-skip-transparent-expression-wrappers" "^7.16.0" - -"@babel/plugin-transform-sticky-regex@^7.2.0": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-sticky-regex/-/plugin-transform-sticky-regex-7.16.7.tgz#c84741d4f4a38072b9a1e2e3fd56d359552e8660" - integrity sha512-NJa0Bd/87QV5NZZzTuZG5BPJjLYadeSZ9fO6oOUoL4iQx+9EEuw/eEM92SrsT19Yc2jgB1u1hsjqDtH02c3Drw== - dependencies: - "@babel/helper-plugin-utils" "^7.16.7" - -"@babel/plugin-transform-template-literals@^7.2.0": - version "7.2.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-template-literals/-/plugin-transform-template-literals-7.2.0.tgz#d87ed01b8eaac7a92473f608c97c089de2ba1e5b" - integrity "sha1-2H7QG46qx6kkc/YIyXwIneK6Hls= sha512-FkPix00J9A/XWXv4VoKJBMeSkyY9x/TqIh76wzcdfl57RJJcf8CehQ08uwfhCDNtRQYtHQKBTwKZDEyjE13Lwg==" - dependencies: - "@parcel/diagnostic" "2.3.2" - "@parcel/plugin" "2.3.2" - "@parcel/source-map" "^2.0.0" - "@parcel/utils" "2.3.2" - "@parcel/workers" "2.3.2" - "@swc/helpers" "^0.2.11" - browserslist "^4.6.6" - detect-libc "^1.0.3" - nullthrows "^1.1.1" - regenerator-runtime "^0.13.7" - semver "^5.7.1" - -"@babel/plugin-transform-typeof-symbol@^7.2.0": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-typeof-symbol/-/plugin-transform-typeof-symbol-7.16.7.tgz#9cdbe622582c21368bd482b660ba87d5545d4f7e" - integrity sha512-p2rOixCKRJzpg9JB4gjnG4gjWkWa89ZoYUnl9snJ1cWIcTH/hvxZqfO+WjG6T8DRBpctEol5jw1O5rA8gkCokQ== - dependencies: - "@babel/helper-plugin-utils" "^7.16.7" - -"@babel/plugin-transform-unicode-regex@^7.2.0": - version "7.2.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-unicode-regex/-/plugin-transform-unicode-regex-7.2.0.tgz#4eb8db16f972f8abb5062c161b8b115546ade08b" - integrity "sha1-TrjbFvly+Ku1BiwWG4sRVUat4Is= sha512-m48Y0lMhrbXEJnVUaYly29jRXbQ3ksxPrS1Tg8t+MHqzXhtBYAvI51euOBaoAlZLPHsieY9XPVMf80a5x0cPcA==" - dependencies: - "@parcel/hash" "2.3.2" - "@parcel/plugin" "2.3.2" - "@parcel/utils" "2.3.2" - clone "^2.1.1" - nullthrows "^1.1.1" - postcss-value-parser "^4.2.0" - semver "^5.7.1" - -"@babel/polyfill@~7.2.5": - version "7.2.5" - resolved "https://registry.yarnpkg.com/@babel/polyfill/-/polyfill-7.2.5.tgz#6c54b964f71ad27edddc567d065e57e87ed7fa7d" - integrity "sha1-bFS5ZPca0n7d3FZ9Bl5X6H7X+n0= sha512-8Y/t3MWThtMLYr0YNC/Q76tqN1w30+b0uQMeFUYauG2UGTR19zyUtFrAzT23zNtBxPp+LbE5E/nwV/q/r3y6ug==" - dependencies: - "@parcel/plugin" "2.3.2" - "@parcel/utils" "2.3.2" - nullthrows "^1.1.1" - posthtml "^0.16.5" - posthtml-parser "^0.10.1" - posthtml-render "^3.0.0" - semver "^5.7.1" - -"@babel/preset-env@~7.3.4": - version "7.3.4" - resolved "https://registry.yarnpkg.com/@babel/preset-env/-/preset-env-7.3.4.tgz#887cf38b6d23c82f19b5135298bdb160062e33e1" - integrity sha512-2mwqfYMK8weA0g0uBKOt4FE3iEodiHy9/CW0b+nWXcbL+pGzLx8ESYc+j9IIxr6LTDHWKgPm71i9smo02bw+gA== - dependencies: - "@babel/helper-module-imports" "^7.0.0" - "@babel/helper-plugin-utils" "^7.0.0" - "@babel/plugin-proposal-async-generator-functions" "^7.2.0" - "@babel/plugin-proposal-json-strings" "^7.2.0" - "@babel/plugin-proposal-object-rest-spread" "^7.3.4" - "@babel/plugin-proposal-optional-catch-binding" "^7.2.0" - "@babel/plugin-proposal-unicode-property-regex" "^7.2.0" - "@babel/plugin-syntax-async-generators" "^7.2.0" - "@babel/plugin-syntax-json-strings" "^7.2.0" - "@babel/plugin-syntax-object-rest-spread" "^7.2.0" - "@babel/plugin-syntax-optional-catch-binding" "^7.2.0" - "@babel/plugin-transform-arrow-functions" "^7.2.0" - "@babel/plugin-transform-async-to-generator" "^7.3.4" - "@babel/plugin-transform-block-scoped-functions" "^7.2.0" - "@babel/plugin-transform-block-scoping" "^7.3.4" - "@babel/plugin-transform-classes" "^7.3.4" - "@babel/plugin-transform-computed-properties" "^7.2.0" - "@babel/plugin-transform-destructuring" "^7.2.0" - "@babel/plugin-transform-dotall-regex" "^7.2.0" - "@babel/plugin-transform-duplicate-keys" "^7.2.0" - "@babel/plugin-transform-exponentiation-operator" "^7.2.0" - "@babel/plugin-transform-for-of" "^7.2.0" - "@babel/plugin-transform-function-name" "^7.2.0" - "@babel/plugin-transform-literals" "^7.2.0" - "@babel/plugin-transform-modules-amd" "^7.2.0" - "@babel/plugin-transform-modules-commonjs" "^7.2.0" - "@babel/plugin-transform-modules-systemjs" "^7.3.4" - "@babel/plugin-transform-modules-umd" "^7.2.0" - "@babel/plugin-transform-named-capturing-groups-regex" "^7.3.0" - "@babel/plugin-transform-new-target" "^7.0.0" - "@babel/plugin-transform-object-super" "^7.2.0" - "@babel/plugin-transform-parameters" "^7.2.0" - "@babel/plugin-transform-regenerator" "^7.3.4" - "@babel/plugin-transform-shorthand-properties" "^7.2.0" - "@babel/plugin-transform-spread" "^7.2.0" - "@babel/plugin-transform-sticky-regex" "^7.2.0" - "@babel/plugin-transform-template-literals" "^7.2.0" - "@babel/plugin-transform-typeof-symbol" "^7.2.0" - "@babel/plugin-transform-unicode-regex" "^7.2.0" - browserslist "^4.3.4" - invariant "^2.2.2" - js-levenshtein "^1.1.3" - semver "^5.3.0" - -"@babel/runtime@~7.3.4": - version "7.3.4" - resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.3.4.tgz#73d12ba819e365fcf7fd152aed56d6df97d21c83" - integrity sha512-IvfvnMdSaLBateu0jfsYIpZTxAc2cKEXEMiezGGN75QcBcecDUKd3PgLAncT0oOgxKy8dd8hrJKj9MfzgfZd6g== - dependencies: - regenerator-runtime "^0.12.0" - -"@babel/template@^7.1.2", "@babel/template@^7.16.7", "@babel/template@^7.2.2": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.16.7.tgz#8d126c8701fde4d66b264b3eba3d96f07666d155" - integrity sha512-I8j/x8kHUrbYRTUxXrrMbfCa7jxkE7tZre39x3kjr9hvI82cK1FfqLygotcWN5kdPGWcLdWMHpSBavse5tWw3w== - dependencies: - "@babel/code-frame" "^7.16.7" - "@babel/parser" "^7.16.7" - "@babel/types" "^7.16.7" - -"@babel/traverse@^7.1.5", "@babel/traverse@^7.16.7", "@babel/traverse@^7.16.8", "@babel/traverse@^7.17.3", "@babel/traverse@^7.3.4": - version "7.17.3" - resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.17.3.tgz#0ae0f15b27d9a92ba1f2263358ea7c4e7db47b57" - integrity sha512-5irClVky7TxRWIRtxlh2WPUUOLhcPN06AGgaQSB8AEwuyEBgJVuJ5imdHm5zxk8w0QS5T+tDfnDxAlhWjpb7cw== - dependencies: - "@babel/code-frame" "^7.16.7" - "@babel/generator" "^7.17.3" - "@babel/helper-environment-visitor" "^7.16.7" - "@babel/helper-function-name" "^7.16.7" - "@babel/helper-hoist-variables" "^7.16.7" - "@babel/helper-split-export-declaration" "^7.16.7" - "@babel/parser" "^7.17.3" - "@babel/types" "^7.17.0" - debug "^4.1.0" - globals "^11.1.0" - -"@babel/types@^7.0.0", "@babel/types@^7.16.0", "@babel/types@^7.16.7", "@babel/types@^7.16.8", "@babel/types@^7.17.0", "@babel/types@^7.3.0", "@babel/types@^7.3.4": - version "7.17.0" - resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.17.0.tgz#a826e368bccb6b3d84acd76acad5c0d87342390b" - integrity sha512-TmKSNO4D5rzhL5bjWFcVHHLETzfQ/AmbKpKPOSjlP0WoHZ6L911fgoOKY4Alp/emzG4cHJdyN49zpgkbXFEHHw== - dependencies: - "@babel/helper-validator-identifier" "^7.16.7" - to-fast-properties "^2.0.0" - -"@jridgewell/gen-mapping@^0.3.0": - version "0.3.2" - resolved "https://registry.yarnpkg.com/@jridgewell/gen-mapping/-/gen-mapping-0.3.2.tgz#c1aedc61e853f2bb9f5dfe6d4442d3b565b253b9" - integrity sha512-mh65xKQAzI6iBcFzwv28KVWSmCkdRBWoOh+bYQGW3+6OZvbbN3TqMGo5hqYxQniRcH9F2VZIoJCm4pa3BPDK/A== - dependencies: - "@jridgewell/set-array" "^1.0.1" - "@jridgewell/sourcemap-codec" "^1.4.10" - "@jridgewell/trace-mapping" "^0.3.9" - -"@jridgewell/resolve-uri@^3.0.3": - version "3.1.0" - resolved "https://registry.yarnpkg.com/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz#2203b118c157721addfe69d47b70465463066d78" - integrity sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w== - -"@jridgewell/set-array@^1.0.1": - version "1.1.2" - resolved "https://registry.yarnpkg.com/@jridgewell/set-array/-/set-array-1.1.2.tgz#7c6cf998d6d20b914c0a55a91ae928ff25965e72" - integrity sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw== - -"@jridgewell/source-map@^0.3.2": - version "0.3.2" - resolved "https://registry.yarnpkg.com/@jridgewell/source-map/-/source-map-0.3.2.tgz#f45351aaed4527a298512ec72f81040c998580fb" - integrity sha512-m7O9o2uR8k2ObDysZYzdfhb08VuEml5oWGiosa1VdaPZ/A6QyPkAJuwN0Q1lhULOf6B7MtQmHENS743hWtCrgw== - dependencies: - "@jridgewell/gen-mapping" "^0.3.0" - "@jridgewell/trace-mapping" "^0.3.9" - -"@jridgewell/sourcemap-codec@^1.4.10": - version "1.4.14" - resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz#add4c98d341472a289190b424efbdb096991bb24" - integrity sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw== - -"@jridgewell/trace-mapping@^0.3.9": - version "0.3.14" - resolved "https://registry.yarnpkg.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.14.tgz#b231a081d8f66796e475ad588a1ef473112701ed" - integrity sha512-bJWEfQ9lPTvm3SneWwRFVLzrh6nhjwqw7TUFFBEMzwvg7t7PCDenf2lDwqo4NQXzdpgBXyFgDWnQA+2vkruksQ== - dependencies: - "@jridgewell/resolve-uri" "^3.0.3" - "@jridgewell/sourcemap-codec" "^1.4.10" - -"@parcel/bundler-default@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/bundler-default/-/bundler-default-2.3.2.tgz#329f171e210dfb22beaa52ae706ccde1dae384c1" - integrity sha512-JUrto4mjSD0ic9dEqRp0loL5o3HVYHja1ZIYSq+rBl2UWRV6/9cGTb07lXOCqqm0BWE+hQ4krUxB76qWaF0Lqw== - dependencies: - "@parcel/diagnostic" "2.3.2" - "@parcel/hash" "2.3.2" - "@parcel/plugin" "2.3.2" - "@parcel/utils" "2.3.2" - nullthrows "^1.1.1" - -"@parcel/cache@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/cache/-/cache-2.3.2.tgz#ba8c2af02fd45b90c7bc6f829bfc566d1ded0a13" - integrity sha512-Xxq+ekgcFEme6Fn1v7rEOBkyMOUOUu7eNqQw0l6HQS+INZ2Q7YzzfdW7pI8rEOAAICVg5BWKpmBQZpgJlT+HxQ== - dependencies: - "@parcel/fs" "2.3.2" - "@parcel/logger" "2.3.2" - "@parcel/utils" "2.3.2" - lmdb "^2.0.2" - -"@parcel/codeframe@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/codeframe/-/codeframe-2.3.2.tgz#73fb5a89910b977342808ca8f6ece61fa01b7690" - integrity sha512-ireQALcxxrTdIEpzTOoMo/GpfbFm1qlyezeGl3Hce3PMvHLg3a5S6u/Vcy7SAjdld5GfhHEqVY+blME6Z4CyXQ== - dependencies: - chalk "^4.1.0" - -"@parcel/compressor-raw@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/compressor-raw/-/compressor-raw-2.3.2.tgz#1a808ae9e61ed86f655935e1d2a984383b3c00a7" - integrity sha512-8dIoFwinYK6bOTpnZOAwwIv0v73y0ezsctPmfMnIqVQPn7wJwfhw/gbKVcmK5AkgQMkyid98hlLZoaZtGF1Mdg== - dependencies: - "@parcel/plugin" "2.3.2" - -"@parcel/config-default@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/config-default/-/config-default-2.3.2.tgz#3f21a37fa07b22de9cd6b1aea19bc310a02d4abb" - integrity sha512-E7/iA7fGCYvXU3u6zF9nxjeDVsgjCN6MVvDjymjaxYMoDWTIsPV245SBEXqzgtmzbMAV+VAl4rVWLMB4pzMt9g== - dependencies: - "@parcel/bundler-default" "2.3.2" - "@parcel/compressor-raw" "2.3.2" - "@parcel/namer-default" "2.3.2" - "@parcel/optimizer-cssnano" "2.3.2" - "@parcel/optimizer-htmlnano" "2.3.2" - "@parcel/optimizer-image" "2.3.2" - "@parcel/optimizer-svgo" "2.3.2" - "@parcel/optimizer-terser" "2.3.2" - "@parcel/packager-css" "2.3.2" - "@parcel/packager-html" "2.3.2" - "@parcel/packager-js" "2.3.2" - "@parcel/packager-raw" "2.3.2" - "@parcel/packager-svg" "2.3.2" - "@parcel/reporter-dev-server" "2.3.2" - "@parcel/resolver-default" "2.3.2" - "@parcel/runtime-browser-hmr" "2.3.2" - "@parcel/runtime-js" "2.3.2" - "@parcel/runtime-react-refresh" "2.3.2" - "@parcel/runtime-service-worker" "2.3.2" - "@parcel/transformer-babel" "2.3.2" - "@parcel/transformer-css" "2.3.2" - "@parcel/transformer-html" "2.3.2" - "@parcel/transformer-image" "2.3.2" - "@parcel/transformer-js" "2.3.2" - "@parcel/transformer-json" "2.3.2" - "@parcel/transformer-postcss" "2.3.2" - "@parcel/transformer-posthtml" "2.3.2" - "@parcel/transformer-raw" "2.3.2" - "@parcel/transformer-react-refresh-wrap" "2.3.2" - "@parcel/transformer-svg" "2.3.2" - -"@parcel/core@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/core/-/core-2.3.2.tgz#1b9a79c1ff96dba5e0f53d4277bed4e7ab4590d0" - integrity sha512-gdJzpsgeUhv9H8T0UKVmyuptiXdduEfKIUx0ci+/PGhq8cCoiFnlnuhW6H7oLr79OUc+YJStabDJuG4U2A6ysw== - dependencies: - "@parcel/cache" "2.3.2" - "@parcel/diagnostic" "2.3.2" - "@parcel/events" "2.3.2" - "@parcel/fs" "2.3.2" - "@parcel/graph" "2.3.2" - "@parcel/hash" "2.3.2" - "@parcel/logger" "2.3.2" - "@parcel/package-manager" "2.3.2" - "@parcel/plugin" "2.3.2" - "@parcel/source-map" "^2.0.0" - "@parcel/types" "2.3.2" - "@parcel/utils" "2.3.2" - "@parcel/workers" "2.3.2" - abortcontroller-polyfill "^1.1.9" - base-x "^3.0.8" - browserslist "^4.6.6" - clone "^2.1.1" - dotenv "^7.0.0" - dotenv-expand "^5.1.0" - json-source-map "^0.6.1" - json5 "^2.2.0" - msgpackr "^1.5.1" - nullthrows "^1.1.1" - semver "^5.7.1" - -"@parcel/diagnostic@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/diagnostic/-/diagnostic-2.3.2.tgz#1d3f0b55bfd9839c6f41d704ebbc89a96cca88dc" - integrity sha512-/xW93Az4AOiifuYW/c4CDbUcu3lx5FcUDAj9AGiR9NSTsF/ROC/RqnxvQ3AGtqa14R7vido4MXEpY3JEp6FsqA== - dependencies: - json-source-map "^0.6.1" - nullthrows "^1.1.1" - -"@parcel/events@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/events/-/events-2.3.2.tgz#b6bcfbbc96d883716ee9d0e6ab232acdee862790" - integrity sha512-WiYIwXMo4Vd+pi58vRoHkul8TPE5VEfMY+3FYwVCKPl/LYqSD+vz6wMx9uG18mEbB1d/ofefv5ZFQNtPGKO4tQ== - -"@parcel/fs-search@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/fs-search/-/fs-search-2.3.2.tgz#18611877ac1b370932c71987c2ec0e93a4a7e53d" - integrity sha512-u3DTEFnPtKuZvEtgGzfVjQUytegSSn3POi7WfwMwPIaeDPfYcyyhfl+c96z7VL9Gk/pqQ99/cGyAwFdFsnxxXA== - dependencies: - detect-libc "^1.0.3" - -"@parcel/fs@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/fs/-/fs-2.3.2.tgz#9628441a84c2582e1f6e69549feb0da0cc143e40" - integrity sha512-XV+OsnRpN01QKU37lBN0TFKvv7uPKfQGbqFqYOrMbXH++Ae8rBU0Ykz+Yu4tv2h7shMlde+AMKgRnRTAJZpWEQ== - dependencies: - "@parcel/fs-search" "2.3.2" - "@parcel/types" "2.3.2" - "@parcel/utils" "2.3.2" - "@parcel/watcher" "^2.0.0" - "@parcel/workers" "2.3.2" - -"@parcel/graph@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/graph/-/graph-2.3.2.tgz#4194816952ab322ab22a17f7d9ea17befbade64d" - integrity sha512-ltTBM3IEqumgmy4ABBFETT8NtAwSsjD9mY3WCyJ5P8rUshfVCg093rvBPbpuJYMaH/TV1AHVaWfZqaZ4JQDIQQ== - dependencies: - "@parcel/utils" "2.3.2" - nullthrows "^1.1.1" - -"@parcel/hash@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/hash/-/hash-2.3.2.tgz#33b8ff04bb44f6661bdc1054b302ef1b6bd3acb3" - integrity sha512-SMtYTsHihws/wqdVnOr0QAGyGYsW9rJSJkkoRujUxo8l2ctnBN1ztv89eOUrdtgHsmcnj/oz1yw6sN38X+BUng== - dependencies: - detect-libc "^1.0.3" - xxhash-wasm "^0.4.2" - -"@parcel/logger@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/logger/-/logger-2.3.2.tgz#b5fc7a9c1664ee0286d0f67641c7c81c8fec1561" - integrity sha512-jIWd8TXDQf+EnNWSa7Q10lSQ6C1LSH8OZkTlaINrfVIw7s+3tVxO3I4pjp7/ARw7RX2gdNPlw6fH4Gn/HvvYbw== - dependencies: - "@parcel/diagnostic" "2.3.2" - "@parcel/events" "2.3.2" - -"@parcel/markdown-ansi@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/markdown-ansi/-/markdown-ansi-2.3.2.tgz#2a5be7ce76a506a9d238ea2257cb28e43abe4902" - integrity sha512-l01ggmag5QScCk9mYA0xHh5TWSffR84uPFP2KvaAMQQ9NLNufcFiU0mn/Mtr3pCb5L5dSzmJ+Oo9s7P1Kh/Fmg== - dependencies: - chalk "^4.1.0" - -"@parcel/namer-default@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/namer-default/-/namer-default-2.3.2.tgz#84e17abfc84fd293b23b3f405280ed2e279c75d8" - integrity sha512-3QUMC0+5+3KMKfoAxYAbpZtuRqTgyZKsGDWzOpuqwemqp6P8ahAvNPwSCi6QSkGcTmvtYwBu9/NHPSONxIFOfg== - dependencies: - "@parcel/diagnostic" "2.3.2" - "@parcel/plugin" "2.3.2" - nullthrows "^1.1.1" - -"@parcel/node-resolver-core@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/node-resolver-core/-/node-resolver-core-2.3.2.tgz#dd360f405949fdcd62980cd44825052ab28f6135" - integrity sha512-wmrnMNzJN4GuHw2Ftho+BWgSWR6UCkW3XoMdphqcxpw/ieAdS2a+xYSosYkZgQZ6lGutSvLyJ1CkVvP6RLIdQQ== - dependencies: - "@parcel/diagnostic" "2.3.2" - "@parcel/utils" "2.3.2" - nullthrows "^1.1.1" - -"@parcel/optimizer-cssnano@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/optimizer-cssnano/-/optimizer-cssnano-2.3.2.tgz#70758f6646fd4debc26a90ae7dddf398928c0ce1" - integrity sha512-wTBOxMiBI38NAB9XIlQZRCjS59+EWjWR9M04D3TWyxl+dL5gYMc1cl4GNynUnmcPdz+3s1UbOdo5/8V90wjiiw== - dependencies: - "@parcel/plugin" "2.3.2" - "@parcel/source-map" "^2.0.0" - cssnano "^5.0.15" - postcss "^8.4.5" - -"@parcel/optimizer-htmlnano@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/optimizer-htmlnano/-/optimizer-htmlnano-2.3.2.tgz#4086736866621182f5dd1a8abe78e9f5764e1a28" - integrity sha512-U8C0TDSxsx8HmHaLW0Zc7ha1fXQynzhvBjCRMGYnOiLiw0MOfLQxzQ2WKVSeCotmdlF63ayCwxWsd6BuqStiKQ== - dependencies: - "@parcel/plugin" "2.3.2" - htmlnano "^2.0.0" - nullthrows "^1.1.1" - posthtml "^0.16.5" - svgo "^2.4.0" - -"@parcel/optimizer-image@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/optimizer-image/-/optimizer-image-2.3.2.tgz#0549cc1abc99fdd6f46bd44ce8551eb135e44d4f" - integrity sha512-HOk3r5qdvY/PmI7Q3i2qEgFH3kP2QWG4Wq3wmC4suaF1+c2gpiQc+HKHWp4QvfbH3jhT00c5NxQyqPhbXeNI9Q== - dependencies: - "@parcel/diagnostic" "2.3.2" - "@parcel/plugin" "2.3.2" - "@parcel/utils" "2.3.2" - "@parcel/workers" "2.3.2" - detect-libc "^1.0.3" - -"@parcel/optimizer-svgo@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/optimizer-svgo/-/optimizer-svgo-2.3.2.tgz#ebf2f48f356ad557d2bbfae361520d3d29bc1c37" - integrity sha512-l7WvZ5+e7D1mVmLUxMVaSb29cviXzuvSY2OpQs0ukdPACDqag+C65hWMzwTiOSSRGPMIu96kQKpeVru2YjibhA== - dependencies: - "@parcel/diagnostic" "2.3.2" - "@parcel/plugin" "2.3.2" - "@parcel/utils" "2.3.2" - svgo "^2.4.0" - -"@parcel/optimizer-terser@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/optimizer-terser/-/optimizer-terser-2.3.2.tgz#790b69e6ecc6ef0d8f25b57e9a13806e1f1c2943" - integrity sha512-dOapHhfy0xiNZa2IoEyHGkhhla07xsja79NPem14e5jCqY6Oi40jKNV4ab5uu5u1elWUjJuw69tiYbkDZWbKQw== - dependencies: - "@parcel/diagnostic" "2.3.2" - "@parcel/plugin" "2.3.2" - "@parcel/source-map" "^2.0.0" - "@parcel/utils" "2.3.2" - nullthrows "^1.1.1" - terser "^5.2.0" - -"@parcel/package-manager@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/package-manager/-/package-manager-2.3.2.tgz#380f0741c9d0c79c170c437efae02506484df315" - integrity sha512-pAQfywKVORY8Ee+NHAyKzzQrKbnz8otWRejps7urwhDaTVLfAd5C/1ZV64ATZ9ALYP9jyoQ8bTaxVd4opcSuwg== - dependencies: - "@parcel/diagnostic" "2.3.2" - "@parcel/fs" "2.3.2" - "@parcel/logger" "2.3.2" - "@parcel/types" "2.3.2" - "@parcel/utils" "2.3.2" - "@parcel/workers" "2.3.2" - semver "^5.7.1" - -"@parcel/packager-css@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/packager-css/-/packager-css-2.3.2.tgz#4994d872449843c1c0cda524b6df3327e2f0a121" - integrity sha512-ByuF9xDnQnpVL1Hdu9aY6SpxOuZowd3TH7joh1qdRPLeMHTEvUywHBXoiAyNdrhnLGum8uPEdY8Ra5Xuo1U7kg== - dependencies: - "@parcel/plugin" "2.3.2" - "@parcel/source-map" "^2.0.0" - "@parcel/utils" "2.3.2" - nullthrows "^1.1.1" - -"@parcel/packager-html@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/packager-html/-/packager-html-2.3.2.tgz#e54085fbaa49bed4258ffef80bc36b421895965f" - integrity sha512-YqAptdU+uqfgwSii76mRGcA/3TpuC6yHr8xG+11brqj/tEFLsurmX0naombzd7FgmrTE9w+kb0HUIMl2vRBn0A== - dependencies: - "@parcel/plugin" "2.3.2" - "@parcel/types" "2.3.2" - "@parcel/utils" "2.3.2" - nullthrows "^1.1.1" - posthtml "^0.16.5" - -"@parcel/packager-js@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/packager-js/-/packager-js-2.3.2.tgz#2d2566bde0da921042b79aa827c71109665d795c" - integrity sha512-3OP0Ro9M1J+PIKZK4Ec2N5hjIPiqk++B2kMFeiUqvaNZjJgKrPPEICBhjS52rma4IE/NgmIMB3aI5pWqE/KwNA== - dependencies: - "@parcel/diagnostic" "2.3.2" - "@parcel/hash" "2.3.2" - "@parcel/plugin" "2.3.2" - "@parcel/source-map" "^2.0.0" - "@parcel/utils" "2.3.2" - globals "^13.2.0" - nullthrows "^1.1.1" - -"@parcel/packager-raw@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/packager-raw/-/packager-raw-2.3.2.tgz#869cc3e7bee8ff3655891a0af400cf4e7dd4f144" - integrity sha512-RnoZ7WgNAFWkEPrEefvyDqus7xfv9XGprHyTbfLittPaVAZpl+4eAv43nXyMfzk77Cgds6KcNpkosj3acEpNIQ== - dependencies: - "@parcel/plugin" "2.3.2" - -"@parcel/packager-svg@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/packager-svg/-/packager-svg-2.3.2.tgz#a7a02e22642ae93f42b8bfd7d122b4a159988743" - integrity sha512-iIC0VeczOXynS7M5jCi3naMBRyAznBVJ3iMg92/GaI9duxPlUMGAlHzLAKNtoXkc00HMXDH7rrmMb04VX6FYSg== - dependencies: - "@parcel/plugin" "2.3.2" - "@parcel/types" "2.3.2" - "@parcel/utils" "2.3.2" - posthtml "^0.16.4" - -"@parcel/plugin@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/plugin/-/plugin-2.3.2.tgz#7701c40567d2eddd5d5b2b6298949cd03a2a22fa" - integrity sha512-SaLZAJX4KH+mrAmqmcy9KJN+V7L+6YNTlgyqYmfKlNiHu7aIjLL+3prX8QRcgGtjAYziCxvPj0cl1CCJssaiGg== - dependencies: - "@parcel/types" "2.3.2" - -"@parcel/reporter-cli@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/reporter-cli/-/reporter-cli-2.3.2.tgz#0617e088aac5ef7fa255d088e7016bb4f9d66a53" - integrity sha512-VYetmTXqW83npsvVvqlQZTbF3yVL3k/FCCl3kSWvOr9LZA0lmyqJWPjMHq37yIIOszQN/p5guLtgCjsP0UQw1Q== - dependencies: - "@parcel/plugin" "2.3.2" - "@parcel/types" "2.3.2" - "@parcel/utils" "2.3.2" - chalk "^4.1.0" - -"@parcel/reporter-dev-server@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/reporter-dev-server/-/reporter-dev-server-2.3.2.tgz#46ee4c53ad08c8b8afd2c79fb37381b6ba55cfb5" - integrity sha512-E7LtnjAX4iiWMw2qKUyFBi3+bDz0UGjqgHoPQylUYYLi6opXjJz/oC+cCcCy4e3RZlkrl187XonvagS59YjDxA== - dependencies: - "@parcel/plugin" "2.3.2" - "@parcel/utils" "2.3.2" - -"@parcel/resolver-default@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/resolver-default/-/resolver-default-2.3.2.tgz#286070412ad7fe506f7c88409f39b362d2041798" - integrity sha512-y3r+xOwWsATrNGUWuZ6soA7q24f8E5tY1AZ9lHCufnkK2cdKZJ5O1cyd7ohkAiKZx2/pMd+FgmVZ/J3oxetXkA== - dependencies: - "@parcel/node-resolver-core" "2.3.2" - "@parcel/plugin" "2.3.2" - -"@parcel/runtime-browser-hmr@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/runtime-browser-hmr/-/runtime-browser-hmr-2.3.2.tgz#cb23a850324ea792168438a9be6a345ebb66eb6d" - integrity sha512-nRD6uOyF1+HGylP9GASbYmvUDOsDaNwvaxuGTSh8+5M0mmCgib+hVBiPEKbwdmKjGbUPt9wRFPyMa/JpeQZsIQ== - dependencies: - "@parcel/plugin" "2.3.2" - "@parcel/utils" "2.3.2" - -"@parcel/runtime-js@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/runtime-js/-/runtime-js-2.3.2.tgz#c0e14251ce43f95977577e23bb9ac5c2487f3bb1" - integrity sha512-SJepcHvYO/7CEe/Q85sngk+smcJ6TypuPh4D2R8kN+cAJPi5WvbQEe7+x5BEgbN+5Jumi/Uo3FfOOE5mYh+F6g== - dependencies: - "@parcel/plugin" "2.3.2" - "@parcel/utils" "2.3.2" - nullthrows "^1.1.1" - -"@parcel/runtime-react-refresh@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/runtime-react-refresh/-/runtime-react-refresh-2.3.2.tgz#11961d7429ae3333b7efe14c4f57515df57eb5f2" - integrity sha512-P+GRPO2XVDSBQ4HmRSj2xfbHSQvL9+ahTE/AB74IJExLTITv5l4SHAV3VsiKohuHYUAYHW3A/Oe7tEFCAb6Cug== - dependencies: - "@parcel/plugin" "2.3.2" - "@parcel/utils" "2.3.2" - react-refresh "^0.9.0" - -"@parcel/runtime-service-worker@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/runtime-service-worker/-/runtime-service-worker-2.3.2.tgz#aa91797e57d1bb5b2aac04ac62c5410709ae0a27" - integrity sha512-iREHj/eapphC4uS/zGUkiTJvG57q+CVbTrfE42kB8ECtf/RYNo5YC9htdvPZjRSXDPrEPc5NCoKp4X09ENNikw== - dependencies: - "@parcel/plugin" "2.3.2" - "@parcel/utils" "2.3.2" - nullthrows "^1.1.1" - -"@parcel/source-map@^2.0.0": - version "2.0.2" - resolved "https://registry.yarnpkg.com/@parcel/source-map/-/source-map-2.0.2.tgz#9aa0b00518cee31d5634de6e9c924a5539b142c1" - integrity sha512-NnUrPYLpYB6qyx2v6bcRPn/gVigmGG6M6xL8wIg/i0dP1GLkuY1nf+Hqdf63FzPTqqT7K3k6eE5yHPQVMO5jcA== - dependencies: - detect-libc "^1.0.3" - -"@parcel/transformer-babel@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/transformer-babel/-/transformer-babel-2.3.2.tgz#2d8c0d1f95d9747936d132dc4c34edb0b6b80d39" - integrity sha512-QpWfH2V6jJ+kcUBIMM/uBBG8dGFvNaOGS+8jD6b+eTP+1owzm83RoWgqhRV2D/hhv2qMXEQzIljoc/wg2y+X4g== - dependencies: - "@parcel/diagnostic" "2.3.2" - "@parcel/plugin" "2.3.2" - "@parcel/source-map" "^2.0.0" - "@parcel/utils" "2.3.2" - browserslist "^4.6.6" - json5 "^2.2.0" - nullthrows "^1.1.1" - semver "^5.7.0" - -"@parcel/transformer-css@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/transformer-css/-/transformer-css-2.3.2.tgz#968826e42d7cac9963dc0a67a30d393ef996e48c" - integrity sha512-8lzvDny+78DIAqhcXam2Bf9FyaUoqzHdUQdNFn+PuXTHroG/QGPvln1kvqngJjn4/cpJS9vYmAPVXe+nai3P8g== - dependencies: - "@parcel/hash" "2.3.2" - "@parcel/plugin" "2.3.2" - "@parcel/source-map" "^2.0.0" - "@parcel/utils" "2.3.2" - nullthrows "^1.1.1" - postcss "^8.4.5" - postcss-value-parser "^4.2.0" - semver "^5.7.1" - -"@parcel/transformer-html@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/transformer-html/-/transformer-html-2.3.2.tgz#c240f09369445d287d16beba207407c925532d90" - integrity sha512-idT1I/8WM65IFYBqzRwpwT7sf0xGur4EDQDHhuPX1w+pIVZnh0lkLMAnEqs6ar1SPRMys4chzkuDNnqh0d76hg== - dependencies: - "@parcel/diagnostic" "2.3.2" - "@parcel/hash" "2.3.2" - "@parcel/plugin" "2.3.2" - nullthrows "^1.1.1" - posthtml "^0.16.5" - posthtml-parser "^0.10.1" - posthtml-render "^3.0.0" - semver "^5.7.1" - -"@parcel/transformer-image@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/transformer-image/-/transformer-image-2.3.2.tgz#24b6eda51a6b07c195886bbb67fb2ade14c325f3" - integrity sha512-0K7cJHXysli6hZsUz/zVGO7WCoaaIeVdzAxKpLA1Yl3LKw/ODiMyXKt08LiV/ljQ2xT5qb9EsXUWDRvcZ0b96A== - dependencies: - "@parcel/plugin" "2.3.2" - "@parcel/workers" "2.3.2" - nullthrows "^1.1.1" - -"@parcel/transformer-js@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/transformer-js/-/transformer-js-2.3.2.tgz#24bcb488d5f82678343a5630fe4bbe822789ac33" - integrity sha512-U1fbIoAoqR5P49S+DMhH8BUd9IHRPwrTTv6ARYGsYnhuNsjTFhNYE0kkfRYboe/e0z7vEbeJICZXjnZ7eQDw5A== - dependencies: - "@parcel/diagnostic" "2.3.2" - "@parcel/plugin" "2.3.2" - "@parcel/source-map" "^2.0.0" - "@parcel/utils" "2.3.2" - "@parcel/workers" "2.3.2" - "@swc/helpers" "^0.2.11" - browserslist "^4.6.6" - detect-libc "^1.0.3" - nullthrows "^1.1.1" - regenerator-runtime "^0.13.7" - semver "^5.7.1" - -"@parcel/transformer-json@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/transformer-json/-/transformer-json-2.3.2.tgz#4c470e86659e87ee13b1f31e75a3621d3615b6bd" - integrity sha512-Pv2iPaxKINtFwOk5fDbHjQlSm2Vza/NLimQY896FLxiXPNAJxWGvMwdutgOPEBKksxRx9LZPyIOHiRVZ0KcA3w== - dependencies: - "@parcel/plugin" "2.3.2" - json5 "^2.2.0" - -"@parcel/transformer-postcss@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/transformer-postcss/-/transformer-postcss-2.3.2.tgz#a428c81569dd66758c5fab866dca69b4c6e59743" - integrity sha512-Rpdxc1rt2aJFCh/y/ccaBc9J1crDjNY5o44xYoOemBoUNDMREsmg5sR5iO81qKKO5GxfoosGb2zh59aeTmywcg== - dependencies: - "@parcel/hash" "2.3.2" - "@parcel/plugin" "2.3.2" - "@parcel/utils" "2.3.2" - clone "^2.1.1" - nullthrows "^1.1.1" - postcss-value-parser "^4.2.0" - semver "^5.7.1" - -"@parcel/transformer-posthtml@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/transformer-posthtml/-/transformer-posthtml-2.3.2.tgz#5da3f24bf240c3c49b2fdb17dcda5988d3057a30" - integrity sha512-tMdVExfdM+1G8A9KSHDsjg+S9xEGbhH5mApF2NslPnNZ4ciLKRNuHU2sSV/v8i0a6kacKvDTrwQXYBQJGOodBw== - dependencies: - "@parcel/plugin" "2.3.2" - "@parcel/utils" "2.3.2" - nullthrows "^1.1.1" - posthtml "^0.16.5" - posthtml-parser "^0.10.1" - posthtml-render "^3.0.0" - semver "^5.7.1" - -"@parcel/transformer-raw@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/transformer-raw/-/transformer-raw-2.3.2.tgz#40d21773e295bae3b16bfe7a89e414ccf534b9c5" - integrity sha512-lY7eOCaALZ90+GH+4PZRmAPGQRXoZ66NakSdhEtH6JSSAYOmZKDvNLGTMRo/vK1oELzWMuAHGdqvbcPDtNLLVw== - dependencies: - "@parcel/plugin" "2.3.2" - -"@parcel/transformer-react-refresh-wrap@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/transformer-react-refresh-wrap/-/transformer-react-refresh-wrap-2.3.2.tgz#43ecfe6f4567b88abb81db9fe56b8d860d6a69f7" - integrity sha512-FZaderyCExn0SBZ6D+zHPWc8JSn9YDcbfibv0wkCl+D7sYfeWZ22i7MRp5NwCe/TZ21WuxDWySCggEp/Waz2xg== - dependencies: - "@parcel/plugin" "2.3.2" - "@parcel/utils" "2.3.2" - react-refresh "^0.9.0" - -"@parcel/transformer-svg@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/transformer-svg/-/transformer-svg-2.3.2.tgz#9a66aef5011c7bbb1fa3ce9bb52ca56d8f0f964d" - integrity sha512-k9My6bePsaGgUh+tidDjFbbVgKPTzwCAQfoloZRMt7y396KgUbvCfqDruk04k6k+cJn7Jl1o/5lUpTEruBze7g== - dependencies: - "@parcel/diagnostic" "2.3.2" - "@parcel/hash" "2.3.2" - "@parcel/plugin" "2.3.2" - nullthrows "^1.1.1" - posthtml "^0.16.5" - posthtml-parser "^0.10.1" - posthtml-render "^3.0.0" - semver "^5.7.1" - -"@parcel/types@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/types/-/types-2.3.2.tgz#7eb6925bc852a518dd75b742419e51292418769f" - integrity sha512-C77Ct1xNM7LWjPTfe/dQ/9rq1efdsX5VJu2o8/TVi6qoFh64Wp/c5/vCHwKInOTBZUTchVO6z4PGJNIZoUVJuA== - dependencies: - "@parcel/cache" "2.3.2" - "@parcel/diagnostic" "2.3.2" - "@parcel/fs" "2.3.2" - "@parcel/package-manager" "2.3.2" - "@parcel/source-map" "^2.0.0" - "@parcel/workers" "2.3.2" - utility-types "^3.10.0" - -"@parcel/utils@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/utils/-/utils-2.3.2.tgz#4aab052fc9f3227811a504da7b9663ca75004f55" - integrity sha512-xzZ+0vWhrXlLzGoz7WlANaO5IPtyWGeCZruGtepUL3yheRWb1UU4zFN9xz7Z+j++Dmf1Fgkc3qdk/t4O8u9HLQ== - dependencies: - "@parcel/codeframe" "2.3.2" - "@parcel/diagnostic" "2.3.2" - "@parcel/hash" "2.3.2" - "@parcel/logger" "2.3.2" - "@parcel/markdown-ansi" "2.3.2" - "@parcel/source-map" "^2.0.0" - chalk "^4.1.0" - -"@parcel/watcher@^2.0.0": - version "2.0.5" - resolved "https://registry.yarnpkg.com/@parcel/watcher/-/watcher-2.0.5.tgz#f913a54e1601b0aac972803829b0eece48de215b" - integrity sha512-x0hUbjv891omnkcHD7ZOhiyyUqUUR6MNjq89JhEI3BxppeKWAm6NPQsqqRrAkCJBogdT/o/My21sXtTI9rJIsw== - dependencies: - node-addon-api "^3.2.1" - node-gyp-build "^4.3.0" - -"@parcel/workers@2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@parcel/workers/-/workers-2.3.2.tgz#05ffa2da9169bfb83335892c2b8abce55686ceb1" - integrity sha512-JbOm+Ceuyymd1SuKGgodC2EXAiPuFRpaNUSJpz3NAsS3lVIt2TDAPMOWBivS7sML/KltspUfl/Q9YwO0TPUFNw== - dependencies: - "@parcel/diagnostic" "2.3.2" - "@parcel/logger" "2.3.2" - "@parcel/types" "2.3.2" - "@parcel/utils" "2.3.2" - chrome-trace-event "^1.0.2" - nullthrows "^1.1.1" - -"@protobufjs/aspromise@^1.1.1", "@protobufjs/aspromise@^1.1.2": - version "1.1.2" - resolved "https://registry.yarnpkg.com/@protobufjs/aspromise/-/aspromise-1.1.2.tgz#9b8b0cc663d669a7d8f6f5d0893a14d348f30fbf" - integrity sha1-m4sMxmPWaafY9vXQiToU00jzD78= - -"@protobufjs/base64@^1.1.2": - version "1.1.2" - resolved "https://registry.yarnpkg.com/@protobufjs/base64/-/base64-1.1.2.tgz#4c85730e59b9a1f1f349047dbf24296034bb2735" - integrity sha512-AZkcAA5vnN/v4PDqKyMR5lx7hZttPDgClv83E//FMNhR2TMcLUhfRUBHCmSl0oi9zMgDDqRUJkSxO3wm85+XLg== - -"@protobufjs/codegen@^2.0.4": - version "2.0.4" - resolved "https://registry.yarnpkg.com/@protobufjs/codegen/-/codegen-2.0.4.tgz#7ef37f0d010fb028ad1ad59722e506d9262815cb" - integrity sha512-YyFaikqM5sH0ziFZCN3xDC7zeGaB/d0IUb9CATugHWbd1FRFwWwt4ld4OYMPWu5a3Xe01mGAULCdqhMlPl29Jg== - -"@protobufjs/eventemitter@^1.1.0": - version "1.1.0" - resolved "https://registry.yarnpkg.com/@protobufjs/eventemitter/-/eventemitter-1.1.0.tgz#355cbc98bafad5978f9ed095f397621f1d066b70" - integrity sha1-NVy8mLr61ZePntCV85diHx0Ga3A= - -"@protobufjs/fetch@^1.1.0": - version "1.1.0" - resolved "https://registry.yarnpkg.com/@protobufjs/fetch/-/fetch-1.1.0.tgz#ba99fb598614af65700c1619ff06d454b0d84c45" - integrity sha1-upn7WYYUr2VwDBYZ/wbUVLDYTEU= - dependencies: - "@protobufjs/aspromise" "^1.1.1" - "@protobufjs/inquire" "^1.1.0" - -"@protobufjs/float@^1.0.2": - version "1.0.2" - resolved "https://registry.yarnpkg.com/@protobufjs/float/-/float-1.0.2.tgz#5e9e1abdcb73fc0a7cb8b291df78c8cbd97b87d1" - integrity sha1-Xp4avctz/Ap8uLKR33jIy9l7h9E= - -"@protobufjs/inquire@^1.1.0": - version "1.1.0" - resolved "https://registry.yarnpkg.com/@protobufjs/inquire/-/inquire-1.1.0.tgz#ff200e3e7cf2429e2dcafc1140828e8cc638f089" - integrity sha1-/yAOPnzyQp4tyvwRQIKOjMY48Ik= - -"@protobufjs/path@^1.1.2": - version "1.1.2" - resolved "https://registry.yarnpkg.com/@protobufjs/path/-/path-1.1.2.tgz#6cc2b20c5c9ad6ad0dccfd21ca7673d8d7fbf68d" - integrity sha1-bMKyDFya1q0NzP0hynZz2Nf79o0= - -"@protobufjs/pool@^1.1.0": - version "1.1.0" - resolved "https://registry.yarnpkg.com/@protobufjs/pool/-/pool-1.1.0.tgz#09fd15f2d6d3abfa9b65bc366506d6ad7846ff54" - integrity sha1-Cf0V8tbTq/qbZbw2ZQbWrXhG/1Q= - -"@protobufjs/utf8@^1.1.0": - version "1.1.0" - resolved "https://registry.yarnpkg.com/@protobufjs/utf8/-/utf8-1.1.0.tgz#a777360b5b39a1a2e5106f8e858f2fd2d060c570" - integrity sha1-p3c2C1s5oaLlEG+OhY8v0tBgxXA= - -"@swc/helpers@^0.2.11": - version "0.2.14" - resolved "https://registry.yarnpkg.com/@swc/helpers/-/helpers-0.2.14.tgz#20288c3627442339dd3d743c944f7043ee3590f0" - integrity sha512-wpCQMhf5p5GhNg2MmGKXzUNwxe7zRiCsmqYsamez2beP7mKPCSiu+BjZcdN95yYSzO857kr0VfQewmGpS77nqA== - -"@tensorflow/tfjs-converter@0.8.4": - version "0.8.4" - resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-converter/-/tfjs-converter-0.8.4.tgz#7c1326e9858c6c3a6d23947e31a73e9458450a9b" - integrity "sha1-fBMm6YWMbDptI5R+Mac+lFhFCps= sha512-hHTyQiQOeYvFB/zL/jDT51hx+voOoKOVHSAWzPG10G8+H7ljQsRzxj19X/PIk8EUo9TXJT2Aj+/WW0guK+0wJg==" - dependencies: - "@types/long" "~3.0.32" - protobufjs "~6.8.6" - -"@tensorflow/tfjs-core@0.15.4": - version "0.15.4" - resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-core/-/tfjs-core-0.15.4.tgz#aaf52acd209476ebde7bd9a37a7c60ec9d067b65" - integrity "sha1-qvUqzSCUduvee9mjenxg7J0Ge2U= sha512-CWi6PuWOBfFRRzn4gl4rcCtwHkimYexGaQi5rwF2jPntknT8TIhonkacvuBROEfeq2PEvqKzCWJTU5+AmCj2HQ==" - dependencies: - "@types/seedrandom" "2.4.27" - "@types/webgl-ext" "0.0.30" - "@types/webgl2" "0.0.4" - seedrandom "2.4.3" - -"@tensorflow/tfjs-data@0.2.3": - version "0.2.3" - resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-data/-/tfjs-data-0.2.3.tgz#67c0cd505485c9b0b6a83cb1c8a24559c5adfa68" - integrity "sha1-Z8DNUFSFybC2qDyxyKJFWcWt+mg= sha512-U9eDD35i0jFQtbm90XMP+dVEwaE0hCrhbt6OEpDCTYxdCLOMDnKVmx+q2TOoCPvTxToC6jHOMPKXO23bLAJsxw==" - dependencies: - "@types/node-fetch" "^2.1.2" - node-fetch "~2.1.2" - seedrandom "~2.4.3" - -"@tensorflow/tfjs-layers@0.10.3": - version "0.10.3" - resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-layers/-/tfjs-layers-0.10.3.tgz#cf4001b5b7566b1526e65e615439e85070a1012c" - integrity "sha1-z0ABtbdWaxUm5l5hVDnoUHChASw= sha512-Xhaz4+ZuL2SEm3S0u4x04dMYMrcG4w4dhMOjoQW8GhAJU4p7LkmP9TmwMEHp7CIVJiJzzQy7Hg8E5fESEnJinA==" - -"@tensorflow/tfjs@0.15.3": - version "0.15.3" - resolved "https://registry.yarnpkg.com/@tensorflow/tfjs/-/tfjs-0.15.3.tgz#6608833952858c8984f20962eb86624f99196f06" - integrity "sha1-ZgiDOVKFjImE8gli64ZiT5kZbwY= sha512-NBAs+iGBNBxprm98mk488EfTDl2kA/lzNguoQGEMeIPWVHTbadSn2QV5xXKAf/fcOat+JwVfqe2vxHBbTjHMOw==" - dependencies: - "@tensorflow/tfjs-converter" "0.8.4" - "@tensorflow/tfjs-core" "0.15.4" - "@tensorflow/tfjs-data" "0.2.3" - "@tensorflow/tfjs-layers" "0.10.3" - -"@trysound/sax@0.2.0": - version "0.2.0" - resolved "https://registry.yarnpkg.com/@trysound/sax/-/sax-0.2.0.tgz#cccaab758af56761eb7bf37af6f03f326dd798ad" - integrity sha512-L7z9BgrNEcYyUYtF+HaEfiS5ebkh9jXqbszz7pC0hRBPaatV0XjSD3+eHrpqFemQfgwiFF0QPIarnIihIDn7OA== - -"@types/long@^4.0.0": - version "4.0.1" - resolved "https://registry.yarnpkg.com/@types/long/-/long-4.0.1.tgz#459c65fa1867dafe6a8f322c4c51695663cc55e9" - integrity sha512-5tXH6Bx/kNGd3MgffdmP4dy2Z+G4eaXw0SE81Tq3BNadtnMR5/ySMzX4SLEzHJzSmPNn4HIdpQsBvXMUykr58w== - -"@types/long@~3.0.32": - version "3.0.32" - resolved "https://registry.yarnpkg.com/@types/long/-/long-3.0.32.tgz#f4e5af31e9e9b196d8e5fca8a5e2e20aa3d60b69" - integrity sha512-ZXyOOm83p7X8p3s0IYM3VeueNmHpkk/yMlP8CLeOnEcu6hIwPH7YjZBvhQkR0ZFS2DqZAxKtJ/M5fcuv3OU5BA== - -"@types/node-fetch@^2.1.2": - version "2.6.1" - resolved "https://registry.yarnpkg.com/@types/node-fetch/-/node-fetch-2.6.1.tgz#8f127c50481db65886800ef496f20bbf15518975" - integrity sha512-oMqjURCaxoSIsHSr1E47QHzbmzNR5rK8McHuNb11BOM9cHcIK3Avy0s/b2JlXHoQGTYS3NsvWzV1M0iK7l0wbA== - dependencies: - "@types/node" "*" - form-data "^3.0.0" - -"@types/node@*": - version "17.0.21" - resolved "https://registry.yarnpkg.com/@types/node/-/node-17.0.21.tgz#864b987c0c68d07b4345845c3e63b75edd143644" - integrity sha512-DBZCJbhII3r90XbQxI8Y9IjjiiOGlZ0Hr32omXIZvwwZ7p4DMMXGrKXVyPfuoBOri9XNtL0UK69jYIBIsRX3QQ== - -"@types/node@^10.1.0": - version "10.17.60" - resolved "https://registry.yarnpkg.com/@types/node/-/node-10.17.60.tgz#35f3d6213daed95da7f0f73e75bcc6980e90597b" - integrity sha512-F0KIgDJfy2nA3zMLmWGKxcH2ZVEtCZXHHdOQs2gSaQ27+lNeEfGxzkIw90aXswATX7AZ33tahPbzy6KAfUreVw== - -"@types/parse-json@^4.0.0": - version "4.0.0" - resolved "https://registry.yarnpkg.com/@types/parse-json/-/parse-json-4.0.0.tgz#2f8bb441434d163b35fb8ffdccd7138927ffb8c0" - integrity sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA== - -"@types/seedrandom@2.4.27": - version "2.4.27" - resolved "https://registry.yarnpkg.com/@types/seedrandom/-/seedrandom-2.4.27.tgz#9db563937dd86915f69092bc43259d2f48578e41" - integrity sha1-nbVjk33YaRX2kJK8QyWdL0hXjkE= - -"@types/webgl-ext@0.0.30": - version "0.0.30" - resolved "https://registry.yarnpkg.com/@types/webgl-ext/-/webgl-ext-0.0.30.tgz#0ce498c16a41a23d15289e0b844d945b25f0fb9d" - integrity sha512-LKVgNmBxN0BbljJrVUwkxwRYqzsAEPcZOe6S2T6ZaBDIrFp0qu4FNlpc5sM1tGbXUYFgdVQIoeLk1Y1UoblyEg== - -"@types/webgl2@0.0.4": - version "0.0.4" - resolved "https://registry.yarnpkg.com/@types/webgl2/-/webgl2-0.0.4.tgz#c3b0f9d6b465c66138e84e64cb3bdf8373c2c279" - integrity sha512-PACt1xdErJbMUOUweSrbVM7gSIYm1vTncW2hF6Os/EeWi6TXYAYMPp+8v6rzHmypE5gHrxaxZNXgMkJVIdZpHw== - -abortcontroller-polyfill@^1.1.9: - version "1.7.3" - resolved "https://registry.yarnpkg.com/abortcontroller-polyfill/-/abortcontroller-polyfill-1.7.3.tgz#1b5b487bd6436b5b764fd52a612509702c3144b5" - integrity sha512-zetDJxd89y3X99Kvo4qFx8GKlt6GsvN3UcRZHwU6iFA/0KiOmhkTVhe8oRoTBiTVPZu09x3vCra47+w8Yz1+2Q== - -acorn@^8.5.0: - version "8.7.1" - resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.7.1.tgz#0197122c843d1bf6d0a5e83220a788f278f63c30" - integrity sha512-Xx54uLJQZ19lKygFXOWsscKUbsBZW0CPykPhVQdhIeIwrbPmJzqeASDInc8nKBnp/JT6igTs82qPXz069H8I/A== - -ansi-styles@^3.2.1: - version "3.2.1" - resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d" - integrity sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA== - dependencies: - color-convert "^1.9.0" - -ansi-styles@^4.1.0: - version "4.3.0" - resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-4.3.0.tgz#edd803628ae71c04c85ae7a0906edad34b648937" - integrity sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg== - dependencies: - color-convert "^2.0.1" - -asn1.js@^5.2.0: - version "5.4.1" - resolved "https://registry.yarnpkg.com/asn1.js/-/asn1.js-5.4.1.tgz#11a980b84ebb91781ce35b0fdc2ee294e3783f07" - integrity sha512-+I//4cYPccV8LdmBLiX8CYvf9Sp3vQsrqu2QNXRcrbiWvcx/UdlFiqUJJzxRQxgsZmvhXhn4cSKeSmoFjVdupA== - dependencies: - bn.js "^4.0.0" - inherits "^2.0.1" - minimalistic-assert "^1.0.0" - safer-buffer "^2.1.0" - -async@^1.5.2: - version "1.5.2" - resolved "https://registry.yarnpkg.com/async/-/async-1.5.2.tgz#ec6a61ae56480c0c3cb241c95618e20892f9672a" - integrity sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo= - -asynckit@^0.4.0: - version "0.4.0" - resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" - integrity sha1-x57Zf380y48robyXkLzDZkdLS3k= - -babel-plugin-dynamic-import-node@^2.3.3: - version "2.3.3" - resolved "https://registry.yarnpkg.com/babel-plugin-dynamic-import-node/-/babel-plugin-dynamic-import-node-2.3.3.tgz#84fda19c976ec5c6defef57f9427b3def66e17a3" - integrity sha512-jZVI+s9Zg3IqA/kdi0i6UDCybUI3aSBLnglhYbSSjKlV7yF1F/5LWv8MakQmvYpnbJDS6fcBL2KzHSxNCMtWSQ== - dependencies: - object.assign "^4.1.0" - -babel-polyfill@^6.26.0: - version "6.26.0" - resolved "https://registry.yarnpkg.com/babel-polyfill/-/babel-polyfill-6.26.0.tgz#379937abc67d7895970adc621f284cd966cf2153" - integrity sha1-N5k3q8Z9eJWXCtxiHyhM2WbPIVM= - dependencies: - babel-runtime "^6.26.0" - core-js "^2.5.0" - regenerator-runtime "^0.10.5" - -babel-runtime@^6.26.0: - version "6.26.0" - resolved "https://registry.yarnpkg.com/babel-runtime/-/babel-runtime-6.26.0.tgz#965c7058668e82b55d7bfe04ff2337bc8b5647fe" - integrity sha1-llxwWGaOgrVde/4E/yM3vItWR/4= - dependencies: - core-js "^2.4.0" - regenerator-runtime "^0.11.0" - -balanced-match@^1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee" - integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw== - -base-x@^3.0.8: - version "3.0.9" - resolved "https://registry.yarnpkg.com/base-x/-/base-x-3.0.9.tgz#6349aaabb58526332de9f60995e548a53fe21320" - integrity sha512-H7JU6iBHTal1gp56aKoaa//YUxEaAOUiydvrV/pILqIHXTtqxSkATOnDA2u+jZ/61sD+L/412+7kzXRtWukhpQ== - dependencies: - safe-buffer "^5.0.1" - -base64-js@^1.3.1: - version "1.5.1" - resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a" - integrity sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA== - -bn.js@^4.0.0, bn.js@^4.1.0, bn.js@^4.11.9: - version "4.12.0" - resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-4.12.0.tgz#775b3f278efbb9718eec7361f483fb36fbbfea88" - integrity sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA== - -bn.js@^5.0.0, bn.js@^5.1.1: - version "5.2.0" - resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-5.2.0.tgz#358860674396c6997771a9d051fcc1b57d4ae002" - integrity sha512-D7iWRBvnZE8ecXiLj/9wbxH7Tk79fAh8IHaTNq1RWRixsS02W+5qS+iE9yq6RYl0asXx5tw0bLhmT5pIfbSquw== - -boolbase@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/boolbase/-/boolbase-1.0.0.tgz#68dff5fbe60c51eb37725ea9e3ed310dcc1e776e" - integrity sha1-aN/1++YMUes3cl6p4+0xDcwed24= - -brace-expansion@^1.1.7: - version "1.1.11" - resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" - integrity sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA== - dependencies: - balanced-match "^1.0.0" - concat-map "0.0.1" - -brorand@^1.0.1, brorand@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/brorand/-/brorand-1.1.0.tgz#12c25efe40a45e3c323eb8675a0a0ce57b22371f" - integrity sha1-EsJe/kCkXjwyPrhnWgoM5XsiNx8= - -browserify-aes@^1.0.0, browserify-aes@^1.0.4: - version "1.2.0" - resolved "https://registry.yarnpkg.com/browserify-aes/-/browserify-aes-1.2.0.tgz#326734642f403dabc3003209853bb70ad428ef48" - integrity sha512-+7CHXqGuspUn/Sl5aO7Ea0xWGAtETPXNSAjHo48JfLdPWcMng33Xe4znFvQweqc/uzk5zSOI3H52CYnjCfb5hA== - dependencies: - buffer-xor "^1.0.3" - cipher-base "^1.0.0" - create-hash "^1.1.0" - evp_bytestokey "^1.0.3" - inherits "^2.0.1" - safe-buffer "^5.0.1" - -browserify-cipher@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/browserify-cipher/-/browserify-cipher-1.0.1.tgz#8d6474c1b870bfdabcd3bcfcc1934a10e94f15f0" - integrity sha512-sPhkz0ARKbf4rRQt2hTpAHqn47X3llLkUGn+xEJzLjwY8LRs2p0v7ljvI5EyoRO/mexrNunNECisZs+gw2zz1w== - dependencies: - browserify-aes "^1.0.4" - browserify-des "^1.0.0" - evp_bytestokey "^1.0.0" - -browserify-des@^1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/browserify-des/-/browserify-des-1.0.2.tgz#3af4f1f59839403572f1c66204375f7a7f703e9c" - integrity sha512-BioO1xf3hFwz4kc6iBhI3ieDFompMhrMlnDFC4/0/vd5MokpuAc3R+LYbwTA9A5Yc9pq9UYPqffKpW2ObuwX5A== - dependencies: - cipher-base "^1.0.1" - des.js "^1.0.0" - inherits "^2.0.1" - safe-buffer "^5.1.2" - -browserify-rsa@^4.0.0, browserify-rsa@^4.0.1: - version "4.1.0" - resolved "https://registry.yarnpkg.com/browserify-rsa/-/browserify-rsa-4.1.0.tgz#b2fd06b5b75ae297f7ce2dc651f918f5be158c8d" - integrity sha512-AdEER0Hkspgno2aR97SAf6vi0y0k8NuOpGnVH3O99rcA5Q6sh8QxcngtHuJ6uXwnfAXNM4Gn1Gb7/MV1+Ymbog== - dependencies: - bn.js "^5.0.0" - randombytes "^2.0.1" - -browserify-sign@^4.0.0: - version "4.2.1" - resolved "https://registry.yarnpkg.com/browserify-sign/-/browserify-sign-4.2.1.tgz#eaf4add46dd54be3bb3b36c0cf15abbeba7956c3" - integrity sha512-/vrA5fguVAKKAVTNJjgSm1tRQDHUU6DbwO9IROu/0WAzC8PKhucDSh18J0RMvVeHAn5puMd+QHC2erPRNf8lmg== - dependencies: - bn.js "^5.1.1" - browserify-rsa "^4.0.1" - create-hash "^1.2.0" - create-hmac "^1.1.7" - elliptic "^6.5.3" - inherits "^2.0.4" - parse-asn1 "^5.1.5" - readable-stream "^3.6.0" - safe-buffer "^5.2.0" - -browserslist@^4.0.0, browserslist@^4.16.6, browserslist@^4.3.4, browserslist@^4.6.6: - version "4.20.0" - resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.20.0.tgz#35951e3541078c125d36df76056e94738a52ebe9" - integrity sha512-bnpOoa+DownbciXj0jVGENf8VYQnE2LNWomhYuCsMmmx9Jd9lwq0WXODuwpSsp8AVdKM2/HorrzxAfbKvWTByQ== - dependencies: - caniuse-lite "^1.0.30001313" - electron-to-chromium "^1.4.76" - escalade "^3.1.1" - node-releases "^2.0.2" - picocolors "^1.0.0" - -buffer-from@^1.0.0: - version "1.1.2" - resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.2.tgz#2b146a6fd72e80b4f55d255f35ed59a3a9a41bd5" - integrity sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ== - -buffer-xor@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/buffer-xor/-/buffer-xor-1.0.3.tgz#26e61ed1422fb70dd42e6e36729ed51d855fe8d9" - integrity sha1-JuYe0UIvtw3ULm42cp7VHYVf6Nk= - -buffer@^6.0.3: - version "6.0.3" - resolved "https://registry.yarnpkg.com/buffer/-/buffer-6.0.3.tgz#2ace578459cc8fbe2a70aaa8f52ee63b6a74c6c6" - integrity sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA== - dependencies: - base64-js "^1.3.1" - ieee754 "^1.2.1" - -call-bind@^1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/call-bind/-/call-bind-1.0.2.tgz#b1d4e89e688119c3c9a903ad30abb2f6a919be3c" - integrity sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA== - dependencies: - function-bind "^1.1.1" - get-intrinsic "^1.0.2" - -callsites@^3.0.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/callsites/-/callsites-3.1.0.tgz#b3630abd8943432f54b3f0519238e33cd7df2f73" - integrity sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ== - -caniuse-api@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/caniuse-api/-/caniuse-api-3.0.0.tgz#5e4d90e2274961d46291997df599e3ed008ee4c0" - integrity sha512-bsTwuIg/BZZK/vreVTYYbSWoe2F+71P7K5QGEX+pT250DZbfU1MQ5prOKpPR+LL6uWKK3KMwMCAS74QB3Um1uw== - dependencies: - browserslist "^4.0.0" - caniuse-lite "^1.0.0" - lodash.memoize "^4.1.2" - lodash.uniq "^4.5.0" - -caniuse-lite@^1.0.0, caniuse-lite@^1.0.30001313: - version "1.0.30001317" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001317.tgz#0548fb28fd5bc259a70b8c1ffdbe598037666a1b" - integrity sha512-xIZLh8gBm4dqNX0gkzrBeyI86J2eCjWzYAs40q88smG844YIrN4tVQl/RhquHvKEKImWWFIVh1Lxe5n1G/N+GQ== - -chalk@^2.0.0: - version "2.4.2" - resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" - integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ== - dependencies: - ansi-styles "^3.2.1" - escape-string-regexp "^1.0.5" - supports-color "^5.3.0" - -chalk@^4.1.0: - version "4.1.2" - resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01" - integrity sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA== - dependencies: - ansi-styles "^4.1.0" - supports-color "^7.1.0" - -chrome-trace-event@^1.0.2: - version "1.0.3" - resolved "https://registry.yarnpkg.com/chrome-trace-event/-/chrome-trace-event-1.0.3.tgz#1015eced4741e15d06664a957dbbf50d041e26ac" - integrity sha512-p3KULyQg4S7NIHixdwbGX+nFHkoBiA4YQmyWtjb8XngSKV124nJmRysgAeujbUVb15vh+RvFUfCPqU7rXk+hZg== - -cipher-base@^1.0.0, cipher-base@^1.0.1, cipher-base@^1.0.3: - version "1.0.4" - resolved "https://registry.yarnpkg.com/cipher-base/-/cipher-base-1.0.4.tgz#8760e4ecc272f4c363532f926d874aae2c1397de" - integrity sha512-Kkht5ye6ZGmwv40uUDZztayT2ThLQGfnj/T71N/XzeZeo3nf8foyW7zGTsPYkEya3m5f3cAypH+qe7YOrM1U2Q== - dependencies: - inherits "^2.0.1" - safe-buffer "^5.0.1" - -clang-format@~1.2.2: - version "1.2.4" - resolved "https://registry.yarnpkg.com/clang-format/-/clang-format-1.2.4.tgz#4bb4b0a98180428deb093cf20982e9fc1af20b6c" - integrity sha512-sw+nrGUp3hvmANd1qF8vZPuezSYQAiXgGBiEtkXTtJnnu6b00fCqkkDIsnRKrNgg4nv6NYZE92ejvOMIXZoejw== - dependencies: - async "^1.5.2" - glob "^7.0.0" - resolve "^1.1.6" - -clone@^2.1.1: - version "2.1.2" - resolved "https://registry.yarnpkg.com/clone/-/clone-2.1.2.tgz#1b7f4b9f591f1e8f83670401600345a02887435f" - integrity sha1-G39Ln1kfHo+DZwQBYANFoCiHQ18= - -color-convert@^1.9.0: - version "1.9.3" - resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8" - integrity sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg== - dependencies: - color-name "1.1.3" - -color-convert@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-2.0.1.tgz#72d3a68d598c9bdb3af2ad1e84f21d896abd4de3" - integrity sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ== - dependencies: - color-name "~1.1.4" - -color-name@1.1.3: - version "1.1.3" - resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25" - integrity sha1-p9BVi9icQveV3UIyj3QIMcpTvCU= - -color-name@~1.1.4: - version "1.1.4" - resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2" - integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA== - -colord@^2.9.1: - version "2.9.2" - resolved "https://registry.yarnpkg.com/colord/-/colord-2.9.2.tgz#25e2bacbbaa65991422c07ea209e2089428effb1" - integrity sha512-Uqbg+J445nc1TKn4FoDPS6ZZqAvEDnwrH42yo8B40JSOgSLxMZ/gt3h4nmCtPLQeXhjJJkqBx7SCY35WnIixaQ== - -combined-stream@^1.0.8: - version "1.0.8" - resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.8.tgz#c3d45a8b34fd730631a110a8a2520682b31d5a7f" - integrity sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg== - dependencies: - delayed-stream "~1.0.0" - -commander@^2.20.0: - version "2.20.3" - resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33" - integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ== - -commander@^7.0.0, commander@^7.2.0: - version "7.2.0" - resolved "https://registry.yarnpkg.com/commander/-/commander-7.2.0.tgz#a36cb57d0b501ce108e4d20559a150a391d97ab7" - integrity sha512-QrWXB+ZQSVPmIWIhtEO9H+gwHaMGYiF5ChvoJ+K9ZGHG/sVsa6yiesAD1GC/x46sET00Xlwo1u49RVVVzvcSkw== - -concat-map@0.0.1: - version "0.0.1" - resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" - integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s= - -convert-source-map@^1.1.0: - version "1.6.0" - resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.6.0.tgz#51b537a8c43e0f04dec1993bffcdd504e758ac20" - integrity sha512-eFu7XigvxdZ1ETfbgPBohgyQ/Z++C0eEhTor0qRwBw9unw+L0/6V8wkSuGgzdThkiS5lSpdptOQPD8Ak40a+7A== - dependencies: - safe-buffer "~5.1.1" - -core-js@^2.4.0, core-js@^2.5.0: - version "2.6.12" - resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.6.12.tgz#d9333dfa7b065e347cc5682219d6f690859cc2ec" - integrity sha512-Kb2wC0fvsWfQrgk8HU5lW6U/Lcs8+9aaYcy4ZFc6DDlo4nZ7n70dEgE5rtR0oG6ufKDUnrwfWL1mXR5ljDatrQ== - -cosmiconfig@^7.0.1: - version "7.0.1" - resolved "https://registry.yarnpkg.com/cosmiconfig/-/cosmiconfig-7.0.1.tgz#714d756522cace867867ccb4474c5d01bbae5d6d" - integrity sha512-a1YWNUV2HwGimB7dU2s1wUMurNKjpx60HxBB6xUM8Re+2s1g1IIfJvFR0/iCF+XHdE0GMTKTuLR32UQff4TEyQ== - dependencies: - "@types/parse-json" "^4.0.0" - import-fresh "^3.2.1" - parse-json "^5.0.0" - path-type "^4.0.0" - yaml "^1.10.0" - -create-ecdh@^4.0.0: - version "4.0.4" - resolved "https://registry.yarnpkg.com/create-ecdh/-/create-ecdh-4.0.4.tgz#d6e7f4bffa66736085a0762fd3a632684dabcc4e" - integrity sha512-mf+TCx8wWc9VpuxfP2ht0iSISLZnt0JgWlrOKZiNqyUZWnjIaCIVNQArMHnCZKfEYRg6IM7A+NeJoN8gf/Ws0A== - dependencies: - bn.js "^4.1.0" - elliptic "^6.5.3" - -create-hash@^1.1.0, create-hash@^1.1.2, create-hash@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/create-hash/-/create-hash-1.2.0.tgz#889078af11a63756bcfb59bd221996be3a9ef196" - integrity sha512-z00bCGNHDG8mHAkP7CtT1qVu+bFQUPjYq/4Iv3C3kWjTFV10zIjfSoeqXo9Asws8gwSHDGj/hl2u4OGIjapeCg== - dependencies: - cipher-base "^1.0.1" - inherits "^2.0.1" - md5.js "^1.3.4" - ripemd160 "^2.0.1" - sha.js "^2.4.0" - -create-hmac@^1.1.0, create-hmac@^1.1.4, create-hmac@^1.1.7: - version "1.1.7" - resolved "https://registry.yarnpkg.com/create-hmac/-/create-hmac-1.1.7.tgz#69170c78b3ab957147b2b8b04572e47ead2243ff" - integrity sha512-MJG9liiZ+ogc4TzUwuvbER1JRdgvUFSB5+VR/g5h82fGaIRWMWddtKBHi7/sVhfjQZ6SehlyhvQYrcYkaUIpLg== - dependencies: - cipher-base "^1.0.3" - create-hash "^1.1.0" - inherits "^2.0.1" - ripemd160 "^2.0.0" - safe-buffer "^5.0.1" - sha.js "^2.4.8" - -crypto-browserify@^3.12.0: - version "3.12.0" - resolved "https://registry.yarnpkg.com/crypto-browserify/-/crypto-browserify-3.12.0.tgz#396cf9f3137f03e4b8e532c58f698254e00f80ec" - integrity sha512-fz4spIh+znjO2VjL+IdhEpRJ3YN6sMzITSBijk6FK2UvTqruSQW+/cCZTSNsMiZNvUeq0CqurF+dAbyiGOY6Wg== - dependencies: - browserify-cipher "^1.0.0" - browserify-sign "^4.0.0" - create-ecdh "^4.0.0" - create-hash "^1.1.0" - create-hmac "^1.1.0" - diffie-hellman "^5.0.0" - inherits "^2.0.1" - pbkdf2 "^3.0.3" - public-encrypt "^4.0.0" - randombytes "^2.0.0" - randomfill "^1.0.3" - -css-declaration-sorter@^6.0.3: - version "6.1.4" - resolved "https://registry.yarnpkg.com/css-declaration-sorter/-/css-declaration-sorter-6.1.4.tgz#b9bfb4ed9a41f8dcca9bf7184d849ea94a8294b4" - integrity sha512-lpfkqS0fctcmZotJGhnxkIyJWvBXgpyi2wsFd4J8VB7wzyrT6Ch/3Q+FMNJpjK4gu1+GN5khOnpU2ZVKrLbhCw== - dependencies: - timsort "^0.3.0" - -css-select@^4.1.3: - version "4.2.1" - resolved "https://registry.yarnpkg.com/css-select/-/css-select-4.2.1.tgz#9e665d6ae4c7f9d65dbe69d0316e3221fb274cdd" - integrity sha512-/aUslKhzkTNCQUB2qTX84lVmfia9NyjP3WpDGtj/WxhwBzWBYUV3DgUpurHTme8UTPcPlAD1DJ+b0nN/t50zDQ== - dependencies: - boolbase "^1.0.0" - css-what "^5.1.0" - domhandler "^4.3.0" - domutils "^2.8.0" - nth-check "^2.0.1" - -css-tree@^1.1.2, css-tree@^1.1.3, define-properties@^1.1.3: - name css-tree - version "1.1.3" - resolved "https://registry.yarnpkg.com/css-tree/-/css-tree-1.1.3.tgz#eb4870fb6fd7707327ec95c2ff2ab09b5e8db91d" - integrity sha512-tRpdppF7TRazZrjJ6v3stzv93qxRcSsFmW6cX0Zm2NVKpxE1WV1HblnghVv9TreireHkqI/VDEsfolRF1p6y7Q== - dependencies: - mdn-data "2.0.14" - source-map "^0.6.1" - -css-what@^5.1.0: - version "5.1.0" - resolved "https://registry.yarnpkg.com/css-what/-/css-what-5.1.0.tgz#3f7b707aadf633baf62c2ceb8579b545bb40f7fe" - integrity sha512-arSMRWIIFY0hV8pIxZMEfmMI47Wj3R/aWpZDDxWYCPEiOMv6tfOrnpDtgxBYPEQD4V0Y/958+1TdC3iWTFcUPw== - -cssesc@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/cssesc/-/cssesc-3.0.0.tgz#37741919903b868565e1c09ea747445cd18983ee" - integrity sha512-/Tb/JcjK111nNScGob5MNtsntNM1aCNUDipB/TkwZFhyDrrE47SOx/18wF2bbjgc3ZzCSKW1T5nt5EbFoAz/Vg== - -cssnano-preset-default@^*: - version "5.2.4" - resolved "https://registry.yarnpkg.com/cssnano-preset-default/-/cssnano-preset-default-5.2.4.tgz#eced79bbc1ab7270337c4038a21891daac2329bc" - integrity sha512-w1Gg8xsebln6/axZ6qDFQHuglrGfbIHOIx0g4y9+etRlRab8CGpSpe6UMsrgJe4zhCaJ0LwLmc+PhdLRTwnhIA== - dependencies: - css-declaration-sorter "^6.0.3" - cssnano-utils "^*" - postcss-calc "^8.2.3" - postcss-colormin "^*" - postcss-convert-values "^*" - postcss-discard-comments "^*" - postcss-discard-duplicates "^*" - postcss-discard-empty "^*" - postcss-discard-overridden "^*" - postcss-merge-longhand "^*" - postcss-merge-rules "^*" - postcss-minify-font-values "^*" - postcss-minify-gradients "^*" - postcss-minify-params "^*" - postcss-minify-selectors "^*" - postcss-normalize-charset "^*" - postcss-normalize-display-values "^*" - postcss-normalize-positions "^*" - postcss-normalize-repeat-style "^*" - postcss-normalize-string "^*" - postcss-normalize-timing-functions "^*" - postcss-normalize-unicode "^*" - postcss-normalize-url "^*" - postcss-normalize-whitespace "^*" - postcss-ordered-values "^*" - postcss-reduce-initial "^*" - postcss-reduce-transforms "^*" - postcss-svgo "^*" - postcss-unique-selectors "^*" - -cssnano-utils@^*, cssnano-utils@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/cssnano-utils/-/cssnano-utils-3.1.0.tgz#95684d08c91511edfc70d2636338ca37ef3a6861" - integrity sha512-JQNR19/YZhz4psLX/rQ9M83e3z2Wf/HdJbryzte4a3NSuafyp9w/I4U+hx5C2S9g41qlstH7DEWnZaaj83OuEA== - -cssnano@^5.0.15: - version "5.1.4" - resolved "https://registry.yarnpkg.com/cssnano/-/cssnano-5.1.4.tgz#c648192e8e2f1aacb7d839e6aa3706b50cc7f8e4" - integrity sha512-hbfhVZreEPyzl+NbvRsjNo54JOX80b+j6nqG2biLVLaZHJEiqGyMh4xDGHtwhUKd5p59mj2GlDqlUBwJUuIu5A== - dependencies: - cssnano-preset-default "^*" - lilconfig "^2.0.3" - yaml "^1.10.2" - -csso@^4.2.0: - version "4.2.0" - resolved "https://registry.yarnpkg.com/csso/-/csso-4.2.0.tgz#ea3a561346e8dc9f546d6febedd50187cf389529" - integrity sha512-wvlcdIbf6pwKEk7vHj8/Bkc0B4ylXZruLvOgs9doS5eOsOpuodOV2zJChSpkp+pRpYQLQMeF04nr3Z68Sta9jA== - dependencies: - css-tree "^1.1.2" - -debug@^4.1.0: - version "4.1.1" - resolved "https://registry.yarnpkg.com/debug/-/debug-4.1.1.tgz#3b72260255109c6b589cee050f1d516139664791" - integrity sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw== - dependencies: - ms "^2.1.1" - -delayed-stream@~1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" - integrity sha1-3zrhmayt+31ECqrgsp4icrJOxhk= - -des.js@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/des.js/-/des.js-1.0.1.tgz#5382142e1bdc53f85d86d53e5f4aa7deb91e0843" - integrity sha512-Q0I4pfFrv2VPd34/vfLrFOoRmlYj3OV50i7fskps1jZWK1kApMWWT9G6RRUeYedLcBDIhnSDaUvJMb3AhUlaEA== - dependencies: - inherits "^2.0.1" - minimalistic-assert "^1.0.0" - -detect-libc@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/detect-libc/-/detect-libc-1.0.3.tgz#fa137c4bd698edf55cd5cd02ac559f91a4c4ba9b" - integrity sha1-+hN8S9aY7fVc1c0CrFWfkaTEups= - -diffie-hellman@^5.0.0: - version "5.0.3" - resolved "https://registry.yarnpkg.com/diffie-hellman/-/diffie-hellman-5.0.3.tgz#40e8ee98f55a2149607146921c63e1ae5f3d2875" - integrity sha512-kqag/Nl+f3GwyK25fhUMYj81BUOrZ9IuJsjIcDE5icNM9FJHAVm3VcUDxdLPoQtTuUylWm6ZIknYJwwaPxsUzg== - dependencies: - bn.js "^4.1.0" - miller-rabin "^4.0.0" - randombytes "^2.0.0" - -dom-serializer@^1.0.1: - version "1.3.2" - resolved "https://registry.yarnpkg.com/dom-serializer/-/dom-serializer-1.3.2.tgz#6206437d32ceefaec7161803230c7a20bc1b4d91" - integrity sha512-5c54Bk5Dw4qAxNOI1pFEizPSjVsx5+bpJKmL2kPn8JhBUq2q09tTCa3mjijun2NfK78NMouDYNMBkOrPZiS+ig== - dependencies: - domelementtype "^2.0.1" - domhandler "^4.2.0" - entities "^2.0.0" - -domelementtype@^2.0.1, domelementtype@^2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/domelementtype/-/domelementtype-2.2.0.tgz#9a0b6c2782ed6a1c7323d42267183df9bd8b1d57" - integrity sha512-DtBMo82pv1dFtUmHyr48beiuq792Sxohr+8Hm9zoxklYPfa6n0Z3Byjj2IV7bmr2IyqClnqEQhfgHJJ5QF0R5A== - -domhandler@^4.2.0, domhandler@^4.2.2, domhandler@^4.3.0: - version "4.3.0" - resolved "https://registry.yarnpkg.com/domhandler/-/domhandler-4.3.0.tgz#16c658c626cf966967e306f966b431f77d4a5626" - integrity sha512-fC0aXNQXqKSFTr2wDNZDhsEYjCiYsDWl3D01kwt25hm1YIPyDGHvvi3rw+PLqHAl/m71MaiF7d5zvBr0p5UB2g== - dependencies: - domelementtype "^2.2.0" - -domutils@^2.8.0: - version "2.8.0" - resolved "https://registry.yarnpkg.com/domutils/-/domutils-2.8.0.tgz#4437def5db6e2d1f5d6ee859bd95ca7d02048135" - integrity sha512-w96Cjofp72M5IIhpjgobBimYEfoPjx1Vx0BSX9P30WBdZW2WIKU0T1Bd0kz2eNZ9ikjKgHbEyKx8BB6H1L3h3A== - dependencies: - dom-serializer "^1.0.1" - domelementtype "^2.2.0" - domhandler "^4.2.0" - -dotenv-expand@^5.1.0: - version "5.1.0" - resolved "https://registry.yarnpkg.com/dotenv-expand/-/dotenv-expand-5.1.0.tgz#3fbaf020bfd794884072ea26b1e9791d45a629f0" - integrity sha512-YXQl1DSa4/PQyRfgrv6aoNjhasp/p4qs9FjJ4q4cQk+8m4r6k4ZSiEyytKG8f8W9gi8WsQtIObNmKd+tMzNTmA== - -dotenv@^7.0.0: - version "7.0.0" - resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-7.0.0.tgz#a2be3cd52736673206e8a85fb5210eea29628e7c" - integrity sha512-M3NhsLbV1i6HuGzBUH8vXrtxOk+tWmzWKDMbAVSUp3Zsjm7ywFeuwrUXhmhQyRK1q5B5GGy7hcXPbj3bnfZg2g== - -electron-to-chromium@^1.4.76: - version "1.4.84" - resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.84.tgz#2700befbcb49c42c4ee162e137ff392c07658249" - integrity sha512-b+DdcyOiZtLXHdgEG8lncYJdxbdJWJvclPNMg0eLUDcSOSO876WA/pYjdSblUTd7eJdIs4YdIxHWGazx7UPSJw== - -elliptic@^6.5.3: - version "6.5.4" - resolved "https://registry.yarnpkg.com/elliptic/-/elliptic-6.5.4.tgz#da37cebd31e79a1367e941b592ed1fbebd58abbb" - integrity sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ== - dependencies: - bn.js "^4.11.9" - brorand "^1.1.0" - hash.js "^1.0.0" - hmac-drbg "^1.0.1" - inherits "^2.0.4" - minimalistic-assert "^1.0.1" - minimalistic-crypto-utils "^1.0.1" - -entities@^2.0.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/entities/-/entities-2.2.0.tgz#098dc90ebb83d8dffa089d55256b351d34c4da55" - integrity sha512-p92if5Nz619I0w+akJrLZH0MX0Pb5DX39XOwQTtXSdQQOaYH03S1uIQp4mhOZtAXrxq4ViO67YTiLBo2638o9A== - -entities@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/entities/-/entities-3.0.1.tgz#2b887ca62585e96db3903482d336c1006c3001d4" - integrity sha512-WiyBqoomrwMdFG1e0kqvASYfnlb0lp8M5o5Fw2OFq1hNZxxcNk8Ik0Xm7LxzBhuidnZB/UtBqVCgUz3kBOP51Q== - -error-ex@^1.3.1: - version "1.3.2" - resolved "https://registry.yarnpkg.com/error-ex/-/error-ex-1.3.2.tgz#b4ac40648107fdcdcfae242f428bea8a14d4f1bf" - integrity sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g== - dependencies: - is-arrayish "^0.2.1" - -escalade@^3.1.1: - version "3.1.1" - resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.1.1.tgz#d8cfdc7000965c5a0174b4a82eaa5c0552742e40" - integrity sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw== - -escape-string-regexp@^1.0.5: - version "1.0.5" - resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" - integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ= - -events@^3.3.0: - version "3.3.0" - resolved "https://registry.yarnpkg.com/events/-/events-3.3.0.tgz#31a95ad0a924e2d2c419a813aeb2c4e878ea7400" - integrity sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q== - -evp_bytestokey@^1.0.0, evp_bytestokey@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/evp_bytestokey/-/evp_bytestokey-1.0.3.tgz#7fcbdb198dc71959432efe13842684e0525acb02" - integrity sha512-/f2Go4TognH/KvCISP7OUsHn85hT9nUkxxA9BEWxFn+Oj9o8ZNLm/40hdlgSLyuOimsrTKLUMEorQexp/aPQeA== - dependencies: - md5.js "^1.3.4" - safe-buffer "^5.1.1" - -form-data@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/form-data/-/form-data-3.0.1.tgz#ebd53791b78356a99af9a300d4282c4d5eb9755f" - integrity sha512-RHkBKtLWUVwd7SqRIvCZMEvAMoGUp0XU+seQiZejj0COz3RI3hWP4sCv3gZWWLjJTd7rGwcsF5eKZGii0r/hbg== - dependencies: - asynckit "^0.4.0" - combined-stream "^1.0.8" - mime-types "^2.1.12" - -fs.realpath@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" - integrity sha1-FQStJSMVjKpA20onh8sBQRmU6k8= - -function-bind@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d" - integrity sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A== - -get-intrinsic@^1.0.2: - version "1.1.1" - resolved "https://registry.yarnpkg.com/get-intrinsic/-/get-intrinsic-1.1.1.tgz#15f59f376f855c446963948f0d24cd3637b4abc6" - integrity sha512-kWZrnVM42QCiEA2Ig1bG8zjoIMOgxWwYCEeNdwY6Tv/cOSeGpcoX4pXHfKUxNKVoArnrEr2e9srnAxxGIraS9Q== - dependencies: - function-bind "^1.1.1" - has "^1.0.3" - has-symbols "^1.0.1" - -get-port@^4.2.0: - version "4.2.0" - resolved "https://registry.yarnpkg.com/get-port/-/get-port-4.2.0.tgz#e37368b1e863b7629c43c5a323625f95cf24b119" - integrity sha512-/b3jarXkH8KJoOMQc3uVGHASwGLPq3gSFJ7tgJm2diza+bydJPTGOibin2steecKeOylE8oY2JERlVWkAJO6yw== - -glob@^7.0.0: - version "7.2.0" - resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.0.tgz#d15535af7732e02e948f4c41628bd910293f6023" - integrity sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q== - dependencies: - fs.realpath "^1.0.0" - inflight "^1.0.4" - inherits "2" - minimatch "^3.0.4" - once "^1.3.0" - path-is-absolute "^1.0.0" - -globals@^11.1.0: - version "11.11.0" - resolved "https://registry.yarnpkg.com/globals/-/globals-11.11.0.tgz#dcf93757fa2de5486fbeed7118538adf789e9c2e" - integrity "sha1-3Pk3V/ot5Uhvvu1xGFOK33ienC4= sha512-WHq43gS+6ufNOEqlrDBxVEbb8ntfXrfAUU2ZOpCxrBdGKW3gyv8mCxAfIBD0DroPKGrJ2eSsXsLtY9MPntsyTw==" - -globals@^13.2.0: - version "13.12.1" - resolved "https://registry.yarnpkg.com/globals/-/globals-13.12.1.tgz#ec206be932e6c77236677127577aa8e50bf1c5cb" - integrity sha512-317dFlgY2pdJZ9rspXDks7073GpDmXdfbM3vYYp0HAMKGDh1FfWPleI2ljVNLQX5M5lXcAslTcPTrOrMEFOjyw== - dependencies: - type-fest "^0.20.2" - -has-flag@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd" - integrity sha1-tdRU3CGZriJWmfNGfloH87lVuv0= - -has-flag@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b" - integrity sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ== - -has-symbols@^1.0.1: - version "1.0.3" - resolved "https://registry.yarnpkg.com/has-symbols/-/has-symbols-1.0.3.tgz#bb7b2c4349251dce87b125f7bdf874aa7c8b39f8" - integrity sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A== - -has@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/has/-/has-1.0.3.tgz#722d7cbfc1f6aa8241f16dd814e011e1f41e8796" - integrity sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw== - dependencies: - function-bind "^1.1.1" - -hash-base@^3.0.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/hash-base/-/hash-base-3.1.0.tgz#55c381d9e06e1d2997a883b4a3fddfe7f0d3af33" - integrity sha512-1nmYp/rhMDiE7AYkDw+lLwlAzz0AntGIe51F3RfFfEqyQ3feY2eI/NcwC6umIQVOASPMsWJLJScWKSSvzL9IVA== - dependencies: - inherits "^2.0.4" - readable-stream "^3.6.0" - safe-buffer "^5.2.0" - -hash.js@^1.0.0, hash.js@^1.0.3: - version "1.1.7" - resolved "https://registry.yarnpkg.com/hash.js/-/hash.js-1.1.7.tgz#0babca538e8d4ee4a0f8988d68866537a003cf42" - integrity sha512-taOaskGt4z4SOANNseOviYDvjEJinIkRgmp7LbKP2YTTmVxWBl87s/uzK9r+44BclBSp2X7K1hqeNfz9JbBeXA== - dependencies: - inherits "^2.0.3" - minimalistic-assert "^1.0.1" - -hmac-drbg@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/hmac-drbg/-/hmac-drbg-1.0.1.tgz#d2745701025a6c775a6c545793ed502fc0c649a1" - integrity sha1-0nRXAQJabHdabFRXk+1QL8DGSaE= - dependencies: - hash.js "^1.0.3" - minimalistic-assert "^1.0.0" - minimalistic-crypto-utils "^1.0.1" - -htmlnano@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/htmlnano/-/htmlnano-2.0.0.tgz#07376faa064f7e1e832dfd91e1a9f606b0bc9b78" - integrity sha512-thKQfhcp2xgtsWNE27A2bliEeqVL5xjAgGn0wajyttvFFsvFWWah1ntV9aEX61gz0T6MBQ5xK/1lXuEumhJTcg== - dependencies: - cosmiconfig "^7.0.1" - posthtml "^0.16.5" - timsort "^0.3.0" - -htmlparser2@^7.1.1: - version "7.2.0" - resolved "https://registry.yarnpkg.com/htmlparser2/-/htmlparser2-7.2.0.tgz#8817cdea38bbc324392a90b1990908e81a65f5a5" - integrity sha512-H7MImA4MS6cw7nbyURtLPO1Tms7C5H602LRETv95z1MxO/7CP7rDVROehUYeYBUYEON94NXXDEPmZuq+hX4sog== - dependencies: - domelementtype "^2.0.1" - domhandler "^4.2.2" - domutils "^2.8.0" - entities "^3.0.1" - -ieee754@^1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.2.1.tgz#8eb7a10a63fff25d15a57b001586d177d1b0d352" - integrity sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA== - -import-fresh@^3.2.1: - version "3.3.0" - resolved "https://registry.yarnpkg.com/import-fresh/-/import-fresh-3.3.0.tgz#37162c25fcb9ebaa2e6e53d5b4d88ce17d9e0c2b" - integrity sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw== - dependencies: - parent-module "^1.0.0" - resolve-from "^4.0.0" - -inflight@^1.0.4: - version "1.0.6" - resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" - integrity sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk= - dependencies: - once "^1.3.0" - wrappy "1" - -inherits@2, inherits@^2.0.1, inherits@^2.0.3, inherits@^2.0.4, inherits@~2.0.4: - version "2.0.4" - resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" - integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== - -invariant@^2.2.2: - version "2.2.4" - resolved "https://registry.yarnpkg.com/invariant/-/invariant-2.2.4.tgz#610f3c92c9359ce1db616e538008d23ff35158e6" - integrity sha512-phJfQVBuaJM5raOpJjSfkiD6BpbCE4Ns//LaXl6wGYtUBY83nWS6Rf9tXm2e8VaK60JEjYldbPif/A2B1C2gNA== - dependencies: - loose-envify "^1.0.0" - -is-arrayish@^0.2.1: - version "0.2.1" - resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.2.1.tgz#77c99840527aa8ecb1a8ba697b80645a7a926a9d" - integrity sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0= - -is-core-module@^2.8.1: - version "2.8.1" - resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.8.1.tgz#f59fdfca701d5879d0a6b100a40aa1560ce27211" - integrity sha512-SdNCUs284hr40hFTFP6l0IfZ/RSrMXF3qgoRHd3/79unUTvrFO/JoXwkGm+5J/Oe3E/b5GsnG330uUNgRpu1PA== - dependencies: - has "^1.0.3" - -is-json@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/is-json/-/is-json-2.0.1.tgz#6be166d144828a131d686891b983df62c39491ff" - integrity sha1-a+Fm0USCihMdaGiRuYPfYsOUkf8= - -js-levenshtein@^1.1.3: - version "1.1.6" - resolved "https://registry.yarnpkg.com/js-levenshtein/-/js-levenshtein-1.1.6.tgz#c6cee58eb3550372df8deb85fad5ce66ce01d59d" - integrity sha512-X2BB11YZtrRqY4EnQcLX5Rh373zbK4alC1FW7D7MBhL2gtcC17cTnr6DmfHZeS0s2rTHjUTMMHfG7gO8SSdw+g== - -"js-tokens@^3.0.0 || ^4.0.0", js-tokens@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" - integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ== - -jsesc@^2.5.1: - version "2.5.2" - resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-2.5.2.tgz#80564d2e483dacf6e8ef209650a67df3f0c283a4" - integrity sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA== - -json-parse-even-better-errors@^2.3.0: - version "2.3.1" - resolved "https://registry.yarnpkg.com/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz#7c47805a94319928e05777405dc12e1f7a4ee02d" - integrity sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w== - -json-source-map@^0.6.1: - version "0.6.1" - resolved "https://registry.yarnpkg.com/json-source-map/-/json-source-map-0.6.1.tgz#e0b1f6f4ce13a9ad57e2ae165a24d06e62c79a0f" - integrity sha512-1QoztHPsMQqhDq0hlXY5ZqcEdUzxQEIxgFkKl4WUp2pgShObl+9ovi4kRh2TfvAfxAoHOJ9vIMEqk3k4iex7tg== - -json5@^2.1.0, json5@^2.2.0: - version "2.2.3" - resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.3.tgz#78cd6f1a19bdc12b73db5ad0c61efd66c1e29283" - integrity sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg== - -lilconfig@^2.0.3: - version "2.0.4" - resolved "https://registry.yarnpkg.com/lilconfig/-/lilconfig-2.0.4.tgz#f4507d043d7058b380b6a8f5cb7bcd4b34cee082" - integrity sha512-bfTIN7lEsiooCocSISTWXkiWJkRqtL9wYtYy+8EK3Y41qh3mpwPU0ycTOgjdY9ErwXCc8QyrQp82bdL0Xkm9yA== - -lines-and-columns@^1.1.6: - version "1.2.4" - resolved "https://registry.yarnpkg.com/lines-and-columns/-/lines-and-columns-1.2.4.tgz#eca284f75d2965079309dc0ad9255abb2ebc1632" - integrity sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg== - -lmdb@^2.0.2: - version "2.2.5" - resolved "https://registry.yarnpkg.com/lmdb/-/lmdb-2.2.5.tgz#37f08b5963a1b81da67f378c7084f59b84c3d443" - integrity sha512-yx+jtqSgp9uzp+2b3U3VTvS/g5hw4jXqvTAX+QU4Izdueq5O6MUTLwp/94R4F7SYq96zOfaGN/IUgiz6AWo+yg== - dependencies: - msgpackr "^1.5.4" - nan "^2.14.2" - node-gyp-build "^4.2.3" - ordered-binary "^1.2.4" - weak-lru-cache "^1.2.2" - -lodash.memoize@^4.1.2: - version "4.1.2" - resolved "https://registry.yarnpkg.com/lodash.memoize/-/lodash.memoize-4.1.2.tgz#bcc6c49a42a2840ed997f323eada5ecd182e0bfe" - integrity sha1-vMbEmkKihA7Zl/Mj6tpezRguC/4= - -lodash.uniq@^4.5.0: - version "4.5.0" - resolved "https://registry.yarnpkg.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773" - integrity sha1-0CJTc662Uq3BvILklFM5qEJ1R3M= - -lodash@^4.17.11: - version "4.17.21" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c" - integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg== - -long@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/long/-/long-4.0.0.tgz#9a7b71cfb7d361a194ea555241c92f7468d5bf28" - integrity sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA== - -loose-envify@^1.0.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.4.0.tgz#71ee51fa7be4caec1a63839f7e682d8132d30caf" - integrity sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q== - dependencies: - js-tokens "^3.0.0 || ^4.0.0" - -md5.js@^1.3.4: - version "1.3.5" - resolved "https://registry.yarnpkg.com/md5.js/-/md5.js-1.3.5.tgz#b5d07b8e3216e3e27cd728d72f70d1e6a342005f" - integrity sha512-xitP+WxNPcTTOgnTJcrhM0xvdPepipPSf3I8EIpGKeFLjt3PlJLIDG3u8EX53ZIubkb+5U2+3rELYpEhHhzdkg== - dependencies: - hash-base "^3.0.0" - inherits "^2.0.1" - safe-buffer "^5.1.2" - -mdn-data@2.0.14: - version "2.0.14" - resolved "https://registry.yarnpkg.com/mdn-data/-/mdn-data-2.0.14.tgz#7113fc4281917d63ce29b43446f701e68c25ba50" - integrity sha512-dn6wd0uw5GsdswPFfsgMp5NSB0/aDe6fK94YJV/AJDYXL6HVLWBsxeq7js7Ad+mU2K9LAlwpk6kN2D5mwCPVow== - -miller-rabin@^4.0.0: - version "4.0.1" - resolved "https://registry.yarnpkg.com/miller-rabin/-/miller-rabin-4.0.1.tgz#f080351c865b0dc562a8462966daa53543c78a4d" - integrity sha512-115fLhvZVqWwHPbClyntxEVfVDfl9DLLTuJvq3g2O/Oxi8AiNouAHvDSzHS0viUJc+V5vm3eq91Xwqn9dp4jRA== - dependencies: - bn.js "^4.0.0" - brorand "^1.0.1" - -mime-db@1.52.0: - version "1.52.0" - resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.52.0.tgz#bbabcdc02859f4987301c856e3387ce5ec43bf70" - integrity sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg== - -mime-types@^2.1.12: - version "2.1.35" - resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.35.tgz#381a871b62a734450660ae3deee44813f70d959a" - integrity sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw== - dependencies: - mime-db "1.52.0" - -minimalistic-assert@^1.0.0, minimalistic-assert@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz#2e194de044626d4a10e7f7fbc00ce73e83e4d5c7" - integrity sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A== - -minimalistic-crypto-utils@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz#f6c00c1c0b082246e5c4d99dfb8c7c083b2b582a" - integrity sha1-9sAMHAsIIkblxNmd+4x8CDsrWCo= - -minimatch@^3.0.4: - version "3.1.2" - resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b" - integrity sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw== - dependencies: - brace-expansion "^1.1.7" - -ms@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.1.tgz#30a5864eb3ebb0a66f2ebe6d727af06a09d86e0a" - integrity sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg== - -msgpackr-extract@^1.0.14: - version "1.0.16" - resolved "https://registry.yarnpkg.com/msgpackr-extract/-/msgpackr-extract-1.0.16.tgz#701c4f6e6f25c100ae84557092274e8fffeefe45" - integrity sha512-fxdRfQUxPrL/TizyfYfMn09dK58e+d65bRD/fcaVH4052vj30QOzzqxcQIS7B0NsqlypEQ/6Du3QmP2DhWFfCA== - dependencies: - nan "^2.14.2" - node-gyp-build "^4.2.3" - -msgpackr@^1.5.1, msgpackr@^1.5.4: - version "1.5.5" - resolved "https://registry.yarnpkg.com/msgpackr/-/msgpackr-1.5.5.tgz#c0562abc2951d7e29f75d77a8656b01f103a042c" - integrity sha512-JG0V47xRIQ9pyUnx6Hb4+3TrQoia2nA3UIdmyTldhxaxtKFkekkKpUW/N6fwHwod9o4BGuJGtouxOk+yCP5PEA== - optionalDependencies: - msgpackr-extract "^1.0.14" - -nan@^2.14.2: - version "2.15.0" - resolved "https://registry.yarnpkg.com/nan/-/nan-2.15.0.tgz#3f34a473ff18e15c1b5626b62903b5ad6e665fee" - integrity sha512-8ZtvEnA2c5aYCZYd1cvgdnU6cqwixRoYg70xPLWUws5ORTa/lnw+u4amixRS/Ac5U5mQVgp9pnlSUnbNWFaWZQ== - -nanoid@^3.3.1: - version "3.3.1" - resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.1.tgz#6347a18cac88af88f58af0b3594b723d5e99bb35" - integrity sha512-n6Vs/3KGyxPQd6uO0eH4Bv0ojGSUvuLlIHtC3Y0kEO23YRge8H9x1GCzLn28YX0H66pMkxuaeESFq4tKISKwdw== - -node-addon-api@^3.2.1: - version "3.2.1" - resolved "https://registry.yarnpkg.com/node-addon-api/-/node-addon-api-3.2.1.tgz#81325e0a2117789c0128dab65e7e38f07ceba161" - integrity sha512-mmcei9JghVNDYydghQmeDX8KoAm0FAiYyIcUt/N4nhyAipB17pllZQDOJD2fotxABnt4Mdz+dKTO7eftLg4d0A== - -node-fetch@~2.1.2: - version "2.1.2" - resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.1.2.tgz#ab884e8e7e57e38a944753cec706f788d1768bb5" - integrity sha1-q4hOjn5X44qUR1POxwb3iNF2i7U= - -node-gyp-build@^4.2.3, node-gyp-build@^4.3.0: - version "4.3.0" - resolved "https://registry.yarnpkg.com/node-gyp-build/-/node-gyp-build-4.3.0.tgz#9f256b03e5826150be39c764bf51e993946d71a3" - integrity sha512-iWjXZvmboq0ja1pUGULQBexmxq8CV4xBhX7VDOTbL7ZR4FOowwY/VOtRxBN/yKxmdGoIp4j5ysNT4u3S2pDQ3Q== - -node-releases@^2.0.2: - version "2.0.2" - resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-2.0.2.tgz#7139fe71e2f4f11b47d4d2986aaf8c48699e0c01" - integrity sha512-XxYDdcQ6eKqp/YjI+tb2C5WM2LgjnZrfYg4vgQt49EK268b6gYCHsBLrK2qvJo4FmCtqmKezb0WZFK4fkrZNsg== - -normalize-url@^6.0.1: - version "6.1.0" - resolved "https://registry.yarnpkg.com/normalize-url/-/normalize-url-6.1.0.tgz#40d0885b535deffe3f3147bec877d05fe4c5668a" - integrity sha512-DlL+XwOy3NxAQ8xuC0okPgK46iuVNAK01YN7RueYBqqFeGsBjV9XmCAzAdgt+667bCl5kPh9EqKKDwnaPG1I7A== - -nth-check@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/nth-check/-/nth-check-2.0.1.tgz#2efe162f5c3da06a28959fbd3db75dbeea9f0fc2" - integrity sha512-it1vE95zF6dTT9lBsYbxvqh0Soy4SPowchj0UBGj/V6cTPnXXtQOPUbhZ6CmGzAD/rW22LQK6E96pcdJXk4A4w== - dependencies: - boolbase "^1.0.0" - -nullthrows@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/nullthrows/-/nullthrows-1.1.1.tgz#7818258843856ae971eae4208ad7d7eb19a431b1" - integrity sha512-2vPPEi+Z7WqML2jZYddDIfy5Dqb0r2fze2zTxNNknZaFpVHU3mFB3R+DWeJWGVx0ecvttSGlJTI+WG+8Z4cDWw== - -object-keys@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.1.1.tgz#1c47f272df277f3b1daf061677d9c82e2322c60e" - integrity sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA== - -object.assign@^4.1.0: - version "4.1.2" - resolved "https://registry.yarnpkg.com/object.assign/-/object.assign-4.1.2.tgz#0ed54a342eceb37b38ff76eb831a0e788cb63940" - integrity sha512-ixT2L5THXsApyiUPYKmW+2EHpXXe5Ii3M+f4e+aJFAHao5amFRW6J0OO6c/LU8Be47utCx2GL89hxGB6XSmKuQ== - dependencies: - call-bind "^1.0.0" - define-properties "^1.1.3" - has-symbols "^1.0.1" - object-keys "^1.1.1" - -once@^1.3.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" - integrity sha1-WDsap3WWHUsROsF9nFC6753Xa9E= - dependencies: - wrappy "1" - -ordered-binary@^1.2.4: - version "1.2.4" - resolved "https://registry.yarnpkg.com/ordered-binary/-/ordered-binary-1.2.4.tgz#51d3a03af078a0bdba6c7bc8f4fedd1f5d45d83e" - integrity sha512-A/csN0d3n+igxBPfUrjbV5GC69LWj2pjZzAAeeHXLukQ4+fytfP4T1Lg0ju7MSPSwq7KtHkGaiwO8URZN5IpLg== - -parcel@~2.3.2: - version "2.3.2" - resolved "https://registry.yarnpkg.com/parcel/-/parcel-2.3.2.tgz#d1cb475f27edae981edea7a7104e04d3a35a87ca" - integrity sha512-4jhgoBcQaiGKmnmBvNyKyOvZrxCgzgUzdEoVup/fRCOP99hNmvYIN5IErIIJxsU9ObcG/RGCFF8wa4kVRsWfIg== - dependencies: - "@parcel/config-default" "2.3.2" - "@parcel/core" "2.3.2" - "@parcel/diagnostic" "2.3.2" - "@parcel/events" "2.3.2" - "@parcel/fs" "2.3.2" - "@parcel/logger" "2.3.2" - "@parcel/package-manager" "2.3.2" - "@parcel/reporter-cli" "2.3.2" - "@parcel/reporter-dev-server" "2.3.2" - "@parcel/utils" "2.3.2" - chalk "^4.1.0" - commander "^7.0.0" - get-port "^4.2.0" - v8-compile-cache "^2.0.0" - -parent-module@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/parent-module/-/parent-module-1.0.1.tgz#691d2709e78c79fae3a156622452d00762caaaa2" - integrity sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g== - dependencies: - callsites "^3.0.0" - -parse-asn1@^5.0.0, parse-asn1@^5.1.5: - version "5.1.6" - resolved "https://registry.yarnpkg.com/parse-asn1/-/parse-asn1-5.1.6.tgz#385080a3ec13cb62a62d39409cb3e88844cdaed4" - integrity sha512-RnZRo1EPU6JBnra2vGHj0yhp6ebyjBZpmUCLHWiFhxlzvBCCpAuZ7elsBp1PVAbQN0/04VD/19rfzlBSwLstMw== - dependencies: - asn1.js "^5.2.0" - browserify-aes "^1.0.0" - evp_bytestokey "^1.0.0" - pbkdf2 "^3.0.3" - safe-buffer "^5.1.1" - -parse-json@^5.0.0: - version "5.2.0" - resolved "https://registry.yarnpkg.com/parse-json/-/parse-json-5.2.0.tgz#c76fc66dee54231c962b22bcc8a72cf2f99753cd" - integrity sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg== - dependencies: - "@babel/code-frame" "^7.0.0" - error-ex "^1.3.1" - json-parse-even-better-errors "^2.3.0" - lines-and-columns "^1.1.6" - -path-is-absolute@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" - integrity sha1-F0uSaHNVNP+8es5r9TpanhtcX18= - -path-parse@^1.0.6, path-parse@^1.0.7: - version "1.0.7" - resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.7.tgz#fbc114b60ca42b30d9daf5858e4bd68bbedb6735" - integrity sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw== - -path-type@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/path-type/-/path-type-4.0.0.tgz#84ed01c0a7ba380afe09d90a8c180dcd9d03043b" - integrity sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw== - -pbkdf2@^3.0.3: - version "3.1.2" - resolved "https://registry.yarnpkg.com/pbkdf2/-/pbkdf2-3.1.2.tgz#dd822aa0887580e52f1a039dc3eda108efae3075" - integrity sha512-iuh7L6jA7JEGu2WxDwtQP1ddOpaJNC4KlDEFfdQajSGgGPNi4OyDc2R7QnbY2bR9QjBVGwgvTdNJZoE7RaxUMA== - dependencies: - create-hash "^1.1.2" - create-hmac "^1.1.4" - ripemd160 "^2.0.1" - safe-buffer "^5.0.1" - sha.js "^2.4.8" - -picocolors@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/picocolors/-/picocolors-1.0.0.tgz#cb5bdc74ff3f51892236eaf79d68bc44564ab81c" - integrity sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ== - -postcss-calc@^8.2.3: - version "8.2.4" - resolved "https://registry.yarnpkg.com/postcss-calc/-/postcss-calc-8.2.4.tgz#77b9c29bfcbe8a07ff6693dc87050828889739a5" - integrity sha512-SmWMSJmB8MRnnULldx0lQIyhSNvuDl9HfrZkaqqE/WHAhToYsAvDq+yAsA/kIyINDszOp3Rh0GFoNuH5Ypsm3Q== - dependencies: - postcss-selector-parser "^6.0.9" - postcss-value-parser "^4.2.0" - -postcss-colormin@^*: - version "5.3.0" - resolved "https://registry.yarnpkg.com/postcss-colormin/-/postcss-colormin-5.3.0.tgz#3cee9e5ca62b2c27e84fce63affc0cfb5901956a" - integrity sha512-WdDO4gOFG2Z8n4P8TWBpshnL3JpmNmJwdnfP2gbk2qBA8PWwOYcmjmI/t3CmMeL72a7Hkd+x/Mg9O2/0rD54Pg== - dependencies: - browserslist "^4.16.6" - caniuse-api "^3.0.0" - colord "^2.9.1" - postcss-value-parser "^4.2.0" - -postcss-convert-values@^*: - version "5.1.0" - resolved "https://registry.yarnpkg.com/postcss-convert-values/-/postcss-convert-values-5.1.0.tgz#f8d3abe40b4ce4b1470702a0706343eac17e7c10" - integrity sha512-GkyPbZEYJiWtQB0KZ0X6qusqFHUepguBCNFi9t5JJc7I2OTXG7C0twbTLvCfaKOLl3rSXmpAwV7W5txd91V84g== - dependencies: - postcss-value-parser "^4.2.0" - -postcss-discard-comments@^*: - version "5.1.1" - resolved "https://registry.yarnpkg.com/postcss-discard-comments/-/postcss-discard-comments-5.1.1.tgz#e90019e1a0e5b99de05f63516ce640bd0df3d369" - integrity sha512-5JscyFmvkUxz/5/+TB3QTTT9Gi9jHkcn8dcmmuN68JQcv3aQg4y88yEHHhwFB52l/NkaJ43O0dbksGMAo49nfQ== - -postcss-discard-duplicates@^*: - version "5.1.0" - resolved "https://registry.yarnpkg.com/postcss-discard-duplicates/-/postcss-discard-duplicates-5.1.0.tgz#9eb4fe8456706a4eebd6d3b7b777d07bad03e848" - integrity sha512-zmX3IoSI2aoenxHV6C7plngHWWhUOV3sP1T8y2ifzxzbtnuhk1EdPwm0S1bIUNaJ2eNbWeGLEwzw8huPD67aQw== - -postcss-discard-empty@^*: - version "5.1.1" - resolved "https://registry.yarnpkg.com/postcss-discard-empty/-/postcss-discard-empty-5.1.1.tgz#e57762343ff7f503fe53fca553d18d7f0c369c6c" - integrity sha512-zPz4WljiSuLWsI0ir4Mcnr4qQQ5e1Ukc3i7UfE2XcrwKK2LIPIqE5jxMRxO6GbI3cv//ztXDsXwEWT3BHOGh3A== - -postcss-discard-overridden@^*: - version "5.1.0" - resolved "https://registry.yarnpkg.com/postcss-discard-overridden/-/postcss-discard-overridden-5.1.0.tgz#7e8c5b53325747e9d90131bb88635282fb4a276e" - integrity sha512-21nOL7RqWR1kasIVdKs8HNqQJhFxLsyRfAnUDm4Fe4t4mCWL9OJiHvlHPjcd8zc5Myu89b/7wZDnOSjFgeWRtw== - -postcss-merge-longhand@^*: - version "5.1.2" - resolved "https://registry.yarnpkg.com/postcss-merge-longhand/-/postcss-merge-longhand-5.1.2.tgz#fe3002f38ad5827c1d6f7d5bb3f71d2566a2a138" - integrity sha512-18/bp9DZnY1ai9RlahOfLBbmIUKfKFPASxRCiZ1vlpZqWPCn8qWPFlEozqmWL+kBtcEQmG8W9YqGCstDImvp/Q== - dependencies: - postcss-value-parser "^4.2.0" - stylehacks "^*" - -postcss-merge-rules@^*: - version "5.1.0" - resolved "https://registry.yarnpkg.com/postcss-merge-rules/-/postcss-merge-rules-5.1.0.tgz#a2d5117eba09c8686a5471d97bd9afcf30d1b41f" - integrity sha512-NecukEJovQ0mG7h7xV8wbYAkXGTO3MPKnXvuiXzOKcxoOodfTTKYjeo8TMhAswlSkjcPIBlnKbSFcTuVSDaPyQ== - dependencies: - browserslist "^4.16.6" - caniuse-api "^3.0.0" - cssnano-utils "^3.1.0" - postcss-selector-parser "^6.0.5" - -postcss-minify-font-values@^*: - version "5.1.0" - resolved "https://registry.yarnpkg.com/postcss-minify-font-values/-/postcss-minify-font-values-5.1.0.tgz#f1df0014a726083d260d3bd85d7385fb89d1f01b" - integrity sha512-el3mYTgx13ZAPPirSVsHqFzl+BBBDrXvbySvPGFnQcTI4iNslrPaFq4muTkLZmKlGk4gyFAYUBMH30+HurREyA== - dependencies: - postcss-value-parser "^4.2.0" - -postcss-minify-gradients@^*: - version "5.1.0" - resolved "https://registry.yarnpkg.com/postcss-minify-gradients/-/postcss-minify-gradients-5.1.0.tgz#de0260a67a13b7b321a8adc3150725f2c6612377" - integrity sha512-J/TMLklkONn3LuL8wCwfwU8zKC1hpS6VcxFkNUNjmVt53uKqrrykR3ov11mdUYyqVMEx67slMce0tE14cE4DTg== - dependencies: - colord "^2.9.1" - cssnano-utils "^3.1.0" - postcss-value-parser "^4.2.0" - -postcss-minify-params@^*: - version "5.1.1" - resolved "https://registry.yarnpkg.com/postcss-minify-params/-/postcss-minify-params-5.1.1.tgz#c5f8e7dac565e577dd99904787fbec576cbdbfb2" - integrity sha512-WCpr+J9Uz8XzMpAfg3UL8z5rde6MifBbh5L8bn8S2F5hq/YDJJzASYCnCHvAB4Fqb94ys8v95ULQkW2EhCFvNg== - dependencies: - browserslist "^4.16.6" - cssnano-utils "^3.1.0" - postcss-value-parser "^4.2.0" - -postcss-minify-selectors@^*: - version "5.2.0" - resolved "https://registry.yarnpkg.com/postcss-minify-selectors/-/postcss-minify-selectors-5.2.0.tgz#17c2be233e12b28ffa8a421a02fc8b839825536c" - integrity sha512-vYxvHkW+iULstA+ctVNx0VoRAR4THQQRkG77o0oa4/mBS0OzGvvzLIvHDv/nNEM0crzN2WIyFU5X7wZhaUK3RA== - dependencies: - postcss-selector-parser "^6.0.5" - -postcss-normalize-charset@^*: - version "5.1.0" - resolved "https://registry.yarnpkg.com/postcss-normalize-charset/-/postcss-normalize-charset-5.1.0.tgz#9302de0b29094b52c259e9b2cf8dc0879879f0ed" - integrity sha512-mSgUJ+pd/ldRGVx26p2wz9dNZ7ji6Pn8VWBajMXFf8jk7vUoSrZ2lt/wZR7DtlZYKesmZI680qjr2CeFF2fbUg== - -postcss-normalize-display-values@^*: - version "5.1.0" - resolved "https://registry.yarnpkg.com/postcss-normalize-display-values/-/postcss-normalize-display-values-5.1.0.tgz#72abbae58081960e9edd7200fcf21ab8325c3da8" - integrity sha512-WP4KIM4o2dazQXWmFaqMmcvsKmhdINFblgSeRgn8BJ6vxaMyaJkwAzpPpuvSIoG/rmX3M+IrRZEz2H0glrQNEA== - dependencies: - postcss-value-parser "^4.2.0" - -postcss-normalize-positions@^*: - version "5.1.0" - resolved "https://registry.yarnpkg.com/postcss-normalize-positions/-/postcss-normalize-positions-5.1.0.tgz#902a7cb97cf0b9e8b1b654d4a43d451e48966458" - integrity sha512-8gmItgA4H5xiUxgN/3TVvXRoJxkAWLW6f/KKhdsH03atg0cB8ilXnrB5PpSshwVu/dD2ZsRFQcR1OEmSBDAgcQ== - dependencies: - postcss-value-parser "^4.2.0" - -postcss-normalize-repeat-style@^*: - version "5.1.0" - resolved "https://registry.yarnpkg.com/postcss-normalize-repeat-style/-/postcss-normalize-repeat-style-5.1.0.tgz#f6d6fd5a54f51a741cc84a37f7459e60ef7a6398" - integrity sha512-IR3uBjc+7mcWGL6CtniKNQ4Rr5fTxwkaDHwMBDGGs1x9IVRkYIT/M4NelZWkAOBdV6v3Z9S46zqaKGlyzHSchw== - dependencies: - postcss-value-parser "^4.2.0" - -postcss-normalize-string@^*: - version "5.1.0" - resolved "https://registry.yarnpkg.com/postcss-normalize-string/-/postcss-normalize-string-5.1.0.tgz#411961169e07308c82c1f8c55f3e8a337757e228" - integrity sha512-oYiIJOf4T9T1N4i+abeIc7Vgm/xPCGih4bZz5Nm0/ARVJ7K6xrDlLwvwqOydvyL3RHNf8qZk6vo3aatiw/go3w== - dependencies: - postcss-value-parser "^4.2.0" - -postcss-normalize-timing-functions@^*: - version "5.1.0" - resolved "https://registry.yarnpkg.com/postcss-normalize-timing-functions/-/postcss-normalize-timing-functions-5.1.0.tgz#d5614410f8f0b2388e9f240aa6011ba6f52dafbb" - integrity sha512-DOEkzJ4SAXv5xkHl0Wa9cZLF3WCBhF3o1SKVxKQAa+0pYKlueTpCgvkFAHfk+Y64ezX9+nITGrDZeVGgITJXjg== - dependencies: - postcss-value-parser "^4.2.0" - -postcss-normalize-unicode@^*: - version "5.1.0" - resolved "https://registry.yarnpkg.com/postcss-normalize-unicode/-/postcss-normalize-unicode-5.1.0.tgz#3d23aede35e160089a285e27bf715de11dc9db75" - integrity sha512-J6M3MizAAZ2dOdSjy2caayJLQT8E8K9XjLce8AUQMwOrCvjCHv24aLC/Lps1R1ylOfol5VIDMaM/Lo9NGlk1SQ== - dependencies: - browserslist "^4.16.6" - postcss-value-parser "^4.2.0" - -postcss-normalize-url@^*: - version "5.1.0" - resolved "https://registry.yarnpkg.com/postcss-normalize-url/-/postcss-normalize-url-5.1.0.tgz#ed9d88ca82e21abef99f743457d3729a042adcdc" - integrity sha512-5upGeDO+PVthOxSmds43ZeMeZfKH+/DKgGRD7TElkkyS46JXAUhMzIKiCa7BabPeIy3AQcTkXwVVN7DbqsiCew== - dependencies: - normalize-url "^6.0.1" - postcss-value-parser "^4.2.0" - -postcss-normalize-whitespace@^*: - version "5.1.1" - resolved "https://registry.yarnpkg.com/postcss-normalize-whitespace/-/postcss-normalize-whitespace-5.1.1.tgz#08a1a0d1ffa17a7cc6efe1e6c9da969cc4493cfa" - integrity sha512-83ZJ4t3NUDETIHTa3uEg6asWjSBYL5EdkVB0sDncx9ERzOKBVJIUeDO9RyA9Zwtig8El1d79HBp0JEi8wvGQnA== - dependencies: - postcss-value-parser "^4.2.0" - -postcss-ordered-values@^*: - version "5.1.0" - resolved "https://registry.yarnpkg.com/postcss-ordered-values/-/postcss-ordered-values-5.1.0.tgz#04ef429e0991b0292bc918b135cd4c038f7b889f" - integrity sha512-wU4Z4D4uOIH+BUKkYid36gGDJNQtkVJT7Twv8qH6UyfttbbJWyw4/xIPuVEkkCtQLAJ0EdsNSh8dlvqkXb49TA== - dependencies: - cssnano-utils "^3.1.0" - postcss-value-parser "^4.2.0" - -postcss-reduce-initial@^*: - version "5.1.0" - resolved "https://registry.yarnpkg.com/postcss-reduce-initial/-/postcss-reduce-initial-5.1.0.tgz#fc31659ea6e85c492fb2a7b545370c215822c5d6" - integrity sha512-5OgTUviz0aeH6MtBjHfbr57tml13PuedK/Ecg8szzd4XRMbYxH4572JFG067z+FqBIf6Zp/d+0581glkvvWMFw== - dependencies: - browserslist "^4.16.6" - caniuse-api "^3.0.0" - -postcss-reduce-transforms@^*: - version "5.1.0" - resolved "https://registry.yarnpkg.com/postcss-reduce-transforms/-/postcss-reduce-transforms-5.1.0.tgz#333b70e7758b802f3dd0ddfe98bb1ccfef96b6e9" - integrity sha512-2fbdbmgir5AvpW9RLtdONx1QoYG2/EtqpNQbFASDlixBbAYuTcJ0dECwlqNqH7VbaUnEnh8SrxOe2sRIn24XyQ== - dependencies: - postcss-value-parser "^4.2.0" - -postcss-selector-parser@^6.0.4, postcss-selector-parser@^6.0.5, postcss-selector-parser@^6.0.9: - version "6.0.9" - resolved "https://registry.yarnpkg.com/postcss-selector-parser/-/postcss-selector-parser-6.0.9.tgz#ee71c3b9ff63d9cd130838876c13a2ec1a992b2f" - integrity sha512-UO3SgnZOVTwu4kyLR22UQ1xZh086RyNZppb7lLAKBFK8a32ttG5i87Y/P3+2bRSjZNyJ1B7hfFNo273tKe9YxQ== - dependencies: - cssesc "^3.0.0" - util-deprecate "^1.0.2" - -postcss-svgo@^*: - version "5.1.0" - resolved "https://registry.yarnpkg.com/postcss-svgo/-/postcss-svgo-5.1.0.tgz#0a317400ced789f233a28826e77523f15857d80d" - integrity sha512-D75KsH1zm5ZrHyxPakAxJWtkyXew5qwS70v56exwvw542d9CRtTo78K0WeFxZB4G7JXKKMbEZtZayTGdIky/eA== - dependencies: - postcss-value-parser "^4.2.0" - svgo "^2.7.0" - -postcss-unique-selectors@^*: - version "5.1.1" - resolved "https://registry.yarnpkg.com/postcss-unique-selectors/-/postcss-unique-selectors-5.1.1.tgz#a9f273d1eacd09e9aa6088f4b0507b18b1b541b6" - integrity sha512-5JiODlELrz8L2HwxfPnhOWZYWDxVHWL83ufOv84NrcgipI7TaeRsatAhK4Tr2/ZiYldpK/wBvw5BD3qfaK96GA== - dependencies: - postcss-selector-parser "^6.0.5" - -postcss-value-parser@^4.2.0: - version "4.2.0" - resolved "https://registry.yarnpkg.com/postcss-value-parser/-/postcss-value-parser-4.2.0.tgz#723c09920836ba6d3e5af019f92bc0971c02e514" - integrity sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ== - -postcss@^8.4.5: - version "8.4.8" - resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.4.8.tgz#dad963a76e82c081a0657d3a2f3602ce10c2e032" - integrity sha512-2tXEqGxrjvAO6U+CJzDL2Fk2kPHTv1jQsYkSoMeOis2SsYaXRO2COxTdQp99cYvif9JTXaAk9lYGc3VhJt7JPQ== - dependencies: - nanoid "^3.3.1" - picocolors "^1.0.0" - source-map-js "^1.0.2" - -posthtml-parser@^0.10.1: - version "0.10.2" - resolved "https://registry.yarnpkg.com/posthtml-parser/-/posthtml-parser-0.10.2.tgz#df364d7b179f2a6bf0466b56be7b98fd4e97c573" - integrity sha512-PId6zZ/2lyJi9LiKfe+i2xv57oEjJgWbsHGGANwos5AvdQp98i6AtamAl8gzSVFGfQ43Glb5D614cvZf012VKg== - dependencies: - htmlparser2 "^7.1.1" - -posthtml-parser@^0.11.0: - version "0.11.0" - resolved "https://registry.yarnpkg.com/posthtml-parser/-/posthtml-parser-0.11.0.tgz#25d1c7bf811ea83559bc4c21c189a29747a24b7a" - integrity sha512-QecJtfLekJbWVo/dMAA+OSwY79wpRmbqS5TeXvXSX+f0c6pW4/SE6inzZ2qkU7oAMCPqIDkZDvd/bQsSFUnKyw== - dependencies: - htmlparser2 "^7.1.1" - -posthtml-render@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/posthtml-render/-/posthtml-render-3.0.0.tgz#97be44931496f495b4f07b99e903cc70ad6a3205" - integrity sha512-z+16RoxK3fUPgwaIgH9NGnK1HKY9XIDpydky5eQGgAFVXTCSezalv9U2jQuNV+Z9qV1fDWNzldcw4eK0SSbqKA== - dependencies: - is-json "^2.0.1" - -posthtml@^0.16.4, posthtml@^0.16.5: - version "0.16.6" - resolved "https://registry.yarnpkg.com/posthtml/-/posthtml-0.16.6.tgz#e2fc407f67a64d2fa3567afe770409ffdadafe59" - integrity sha512-JcEmHlyLK/o0uGAlj65vgg+7LIms0xKXe60lcDOTU7oVX/3LuEuLwrQpW3VJ7de5TaFKiW4kWkaIpJL42FEgxQ== - dependencies: - posthtml-parser "^0.11.0" - posthtml-render "^3.0.0" - -process@^0.11.10: - version "0.11.10" - resolved "https://registry.yarnpkg.com/process/-/process-0.11.10.tgz#7332300e840161bda3e69a1d1d91a7d4bc16f182" - integrity sha1-czIwDoQBYb2j5podHZGn1LwW8YI= - -protobufjs@~6.8.6: - version "6.8.9" - resolved "https://registry.yarnpkg.com/protobufjs/-/protobufjs-6.8.9.tgz#0b1adbcdaa983d369c3d9108a97c814edc030754" - integrity sha512-j2JlRdUeL/f4Z6x4aU4gj9I2LECglC+5qR2TrWb193Tla1qfdaNQTZ8I27Pt7K0Ajmvjjpft7O3KWTGciz4gpw== - dependencies: - "@protobufjs/aspromise" "^1.1.2" - "@protobufjs/base64" "^1.1.2" - "@protobufjs/codegen" "^2.0.4" - "@protobufjs/eventemitter" "^1.1.0" - "@protobufjs/fetch" "^1.1.0" - "@protobufjs/float" "^1.0.2" - "@protobufjs/inquire" "^1.1.0" - "@protobufjs/path" "^1.1.2" - "@protobufjs/pool" "^1.1.0" - "@protobufjs/utf8" "^1.1.0" - "@types/long" "^4.0.0" - "@types/node" "^10.1.0" - long "^4.0.0" - -public-encrypt@^4.0.0: - version "4.0.3" - resolved "https://registry.yarnpkg.com/public-encrypt/-/public-encrypt-4.0.3.tgz#4fcc9d77a07e48ba7527e7cbe0de33d0701331e0" - integrity sha512-zVpa8oKZSz5bTMTFClc1fQOnyyEzpl5ozpi1B5YcvBrdohMjH2rfsBtyXcuNuwjsDIXmBYlF2N5FlJYhR29t8Q== - dependencies: - bn.js "^4.1.0" - browserify-rsa "^4.0.0" - create-hash "^1.1.0" - parse-asn1 "^5.0.0" - randombytes "^2.0.1" - safe-buffer "^5.1.2" - -randombytes@^2.0.0, randombytes@^2.0.1, randombytes@^2.0.5: - version "2.1.0" - resolved "https://registry.yarnpkg.com/randombytes/-/randombytes-2.1.0.tgz#df6f84372f0270dc65cdf6291349ab7a473d4f2a" - integrity sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ== - dependencies: - safe-buffer "^5.1.0" - -randomfill@^1.0.3: - version "1.0.4" - resolved "https://registry.yarnpkg.com/randomfill/-/randomfill-1.0.4.tgz#c92196fc86ab42be983f1bf31778224931d61458" - integrity sha512-87lcbR8+MhcWcUiQ+9e+Rwx8MyR2P7qnt15ynUlbm3TU/fjbgz4GsvfSUDTemtCCtVCqb4ZcEFlyPNTh9bBTLw== - dependencies: - randombytes "^2.0.5" - safe-buffer "^5.1.0" - -react-refresh@^0.9.0: - version "0.9.0" - resolved "https://registry.yarnpkg.com/react-refresh/-/react-refresh-0.9.0.tgz#71863337adc3e5c2f8a6bfddd12ae3bfe32aafbf" - integrity sha512-Gvzk7OZpiqKSkxsQvO/mbTN1poglhmAV7gR/DdIrRrSMXraRQQlfikRJOr3Nb9GTMPC5kof948Zy6jJZIFtDvQ== - -readable-stream@^3.5.0, readable-stream@^3.6.0: - version "3.6.0" - resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-3.6.0.tgz#337bbda3adc0706bd3e024426a286d4b4b2c9198" - integrity sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA== - dependencies: - inherits "^2.0.3" - string_decoder "^1.1.1" - util-deprecate "^1.0.1" - -regenerator-runtime@^0.10.5: - version "0.10.5" - resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.10.5.tgz#336c3efc1220adcedda2c9fab67b5a7955a33658" - integrity sha1-M2w+/BIgrc7dosn6tntaeVWjNlg= - -regenerator-runtime@^0.11.0: - version "0.11.1" - resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz#be05ad7f9bf7d22e056f9726cee5017fbf19e2e9" - integrity sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg== - -regenerator-runtime@^0.12.0: - version "0.12.1" - resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.12.1.tgz#fa1a71544764c036f8c49b13a08b2594c9f8a0de" - integrity sha512-odxIc1/vDlo4iZcfXqRYFj0vpXFNoGdKMAUieAlFYO6m/nl5e9KR/beGf41z4a1FI+aQgtjhuaSlDxQ0hmkrHg== - -regenerator-runtime@^0.13.7: - version "0.13.9" - resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.9.tgz#8925742a98ffd90814988d7566ad30ca3b263b52" - integrity sha512-p3VT+cOEgxFsRRA9X4lkI1E+k2/CtnKtU4gcxyaCUreilL/vqI6CdZ3wxVUx3UOUg+gnUOQQcRI7BmSI656MYA== - -resolve-from@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-4.0.0.tgz#4abcd852ad32dd7baabfe9b40e00a36db5f392e6" - integrity sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g== - -resolve@^1.1.6: - version "1.22.0" - resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.22.0.tgz#5e0b8c67c15df57a89bdbabe603a002f21731198" - integrity sha512-Hhtrw0nLeSrFQ7phPp4OOcVjLPIeMnRlr5mcnVuMe7M/7eBn98A3hmFRLoFo3DLZkivSYwhRUJTyPyWAk56WLw== - dependencies: - is-core-module "^2.8.1" - path-parse "^1.0.7" - supports-preserve-symlinks-flag "^1.0.0" - -resolve@^1.3.2: - version "1.10.0" - resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.10.0.tgz#3bdaaeaf45cc07f375656dfd2e54ed0810b101ba" - integrity "sha1-O9qur0XMB/N1ZW39LlTtCBCxAbo= sha512-3sUr9aq5OfSg2S9pNtPA9hL1FVEAjvfOC4leW0SNf/mpnaakz2a9femSd6LqAww2RaFctwyf1lCqnTHuF1rxDg==" - dependencies: - path-parse "^1.0.6" - -ripemd160@^2.0.0, ripemd160@^2.0.1: - version "2.0.2" - resolved "https://registry.yarnpkg.com/ripemd160/-/ripemd160-2.0.2.tgz#a1c1a6f624751577ba5d07914cbc92850585890c" - integrity sha512-ii4iagi25WusVoiC4B4lq7pbXfAp3D9v5CwfkY33vffw2+pkDjY1D8GaN7spsxvCSx8dkPqOZCEZyfxcmJG2IA== - dependencies: - hash-base "^3.0.0" - inherits "^2.0.1" - -safe-buffer@^5.0.1, safe-buffer@^5.1.0, safe-buffer@^5.1.1, safe-buffer@^5.1.2, safe-buffer@^5.2.0, safe-buffer@~5.2.0: - version "5.2.1" - resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" - integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== - -safe-buffer@~5.1.1: - version "5.1.2" - resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" - integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g== - -safer-buffer@^2.1.0: - version "2.1.2" - resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a" - integrity sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg== - -seedrandom@2.4.3: - version "2.4.3" - resolved "https://registry.yarnpkg.com/seedrandom/-/seedrandom-2.4.3.tgz#2438504dad33917314bff18ac4d794f16d6aaecc" - integrity sha1-JDhQTa0zkXMUv/GKxNeU8W1qrsw= - -seedrandom@~2.4.3: - version "2.4.4" - resolved "https://registry.yarnpkg.com/seedrandom/-/seedrandom-2.4.4.tgz#b25ea98632c73e45f58b77cfaa931678df01f9ba" - integrity "sha1-sl6phjLHPkX1i3fPqpMWeN8B+bo= sha512-9A+PDmgm+2du77B5i0Ip2cxOqqHjgNxnBgglxLcX78A2D6c2rTo61z4jnVABpF4cKeDMDG+cmXXvdnqse2VqMA==" - -semver@^5.3.0, semver@^5.4.1: - version "5.6.0" - resolved "https://registry.yarnpkg.com/semver/-/semver-5.6.0.tgz#7e74256fbaa49c75aa7c7a205cc22799cac80004" - integrity sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg== - -semver@^5.7.0, semver@^5.7.1: - version "5.7.1" - resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" - integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ== - -sha.js@^2.4.0, sha.js@^2.4.8: - version "2.4.11" - resolved "https://registry.yarnpkg.com/sha.js/-/sha.js-2.4.11.tgz#37a5cf0b81ecbc6943de109ba2960d1b26584ae7" - integrity sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ== - dependencies: - inherits "^2.0.1" - safe-buffer "^5.0.1" - -source-map-js@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/source-map-js/-/source-map-js-1.0.2.tgz#adbc361d9c62df380125e7f161f71c826f1e490c" - integrity sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw== - -source-map-support@~0.5.20: - version "0.5.21" - resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.21.tgz#04fe7c7f9e1ed2d662233c28cb2b35b9f63f6e4f" - integrity sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w== - dependencies: - buffer-from "^1.0.0" - source-map "^0.6.0" - -source-map@^0.5.0: - version "0.5.7" - resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" - integrity sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w= - -source-map@^0.6.0, source-map@^0.6.1: - version "0.6.1" - resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" - integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== - -stable@^0.1.8: - version "0.1.8" - resolved "https://registry.yarnpkg.com/stable/-/stable-0.1.8.tgz#836eb3c8382fe2936feaf544631017ce7d47a3cf" - integrity sha512-ji9qxRnOVfcuLDySj9qzhGSEFVobyt1kIOSkj1qZzYLzq7Tos/oUUWvotUPQLlrsidqsK6tBH89Bc9kL5zHA6w== - -stream-browserify@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/stream-browserify/-/stream-browserify-3.0.0.tgz#22b0a2850cdf6503e73085da1fc7b7d0c2122f2f" - integrity sha512-H73RAHsVBapbim0tU2JwwOiXUj+fikfiaoYAKHF3VJfA0pe2BCzkhAHBlLG6REzE+2WNZcxOXjK7lkso+9euLA== - dependencies: - inherits "~2.0.4" - readable-stream "^3.5.0" - -string_decoder@^1.1.1: - version "1.3.0" - resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.3.0.tgz#42f114594a46cf1a8e30b0a84f56c78c3edac21e" - integrity sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA== - dependencies: - safe-buffer "~5.2.0" - -stylehacks@^*: - version "5.1.0" - resolved "https://registry.yarnpkg.com/stylehacks/-/stylehacks-5.1.0.tgz#a40066490ca0caca04e96c6b02153ddc39913520" - integrity sha512-SzLmvHQTrIWfSgljkQCw2++C9+Ne91d/6Sp92I8c5uHTcy/PgeHamwITIbBW9wnFTY/3ZfSXR9HIL6Ikqmcu6Q== - dependencies: - browserslist "^4.16.6" - postcss-selector-parser "^6.0.4" - -supports-color@^5.3.0: - version "5.5.0" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f" - integrity sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow== - dependencies: - has-flag "^3.0.0" - -supports-color@^7.1.0: - version "7.2.0" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-7.2.0.tgz#1b7dcdcb32b8138801b3e478ba6a51caa89648da" - integrity sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw== - dependencies: - has-flag "^4.0.0" - -supports-preserve-symlinks-flag@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz#6eda4bd344a3c94aea376d4cc31bc77311039e09" - integrity sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w== - -svgo@^2.4.0, svgo@^2.7.0: - version "2.8.0" - resolved "https://registry.yarnpkg.com/svgo/-/svgo-2.8.0.tgz#4ff80cce6710dc2795f0c7c74101e6764cfccd24" - integrity sha512-+N/Q9kV1+F+UeWYoSiULYo4xYSDQlTgb+ayMobAXPwMnLvop7oxKMo9OzIrX5x3eS4L4f2UHhc9axXwY8DpChg== - dependencies: - "@trysound/sax" "0.2.0" - commander "^7.2.0" - css-select "^4.1.3" - css-tree "^1.1.3" - csso "^4.2.0" - picocolors "^1.0.0" - stable "^0.1.8" - -terser@^5.2.0: - version "5.14.2" - resolved "https://registry.yarnpkg.com/terser/-/terser-5.14.2.tgz#9ac9f22b06994d736174f4091aa368db896f1c10" - integrity sha512-oL0rGeM/WFQCUd0y2QrWxYnq7tfSuKBiqTjRPWrRgB46WD/kiwHwF8T23z78H6Q6kGCuuHcPB+KULHRdxvVGQA== - dependencies: - "@jridgewell/source-map" "^0.3.2" - acorn "^8.5.0" - commander "^2.20.0" - source-map-support "~0.5.20" - -timsort@^0.3.0: - version "0.3.0" - resolved "https://registry.yarnpkg.com/timsort/-/timsort-0.3.0.tgz#405411a8e7e6339fe64db9a234de11dc31e02bd4" - integrity sha1-QFQRqOfmM5/mTbmiNN4R3DHgK9Q= - -to-fast-properties@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/to-fast-properties/-/to-fast-properties-2.0.0.tgz#dc5e698cbd079265bc73e0377681a4e4e83f616e" - integrity sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4= - -trim-right@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/trim-right/-/trim-right-1.0.1.tgz#cb2e1203067e0c8de1f614094b9fe45704ea6003" - integrity sha1-yy4SAwZ+DI3h9hQJS5/kVwTqYAM= - -type-fest@^0.20.2: - version "0.20.2" - resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.20.2.tgz#1bf207f4b28f91583666cb5fbd327887301cd5f4" - integrity sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ== - -util-deprecate@^1.0.1, util-deprecate@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" - integrity sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8= - -utility-types@^3.10.0: - version "3.10.0" - resolved "https://registry.yarnpkg.com/utility-types/-/utility-types-3.10.0.tgz#ea4148f9a741015f05ed74fd615e1d20e6bed82b" - integrity sha512-O11mqxmi7wMKCo6HKFt5AhO4BwY3VV68YU07tgxfz8zJTIxr4BpsezN49Ffwy9j3ZpwwJp4fkRwjRzq3uWE6Rg== - -v8-compile-cache@^2.0.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz#2de19618c66dc247dcfb6f99338035d8245a2cee" - integrity sha512-l8lCEmLcLYZh4nbunNZvQCJc5pv7+RCwa8q/LdUx8u7lsWvPDKmpodJAJNwkAhJC//dFY48KuIEmjtd4RViDrA== - -weak-lru-cache@^1.2.2: - version "1.2.2" - resolved "https://registry.yarnpkg.com/weak-lru-cache/-/weak-lru-cache-1.2.2.tgz#fdbb6741f36bae9540d12f480ce8254060dccd19" - integrity sha512-DEAoo25RfSYMuTGc9vPJzZcZullwIqRDSI9LOy+fkCJPi6hykCnfKaXTuPBDuXAUcqHXyOgFtHNp/kB2FjYHbw== - -wrappy@1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" - integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8= - -xxhash-wasm@^0.4.2: - version "0.4.2" - resolved "https://registry.yarnpkg.com/xxhash-wasm/-/xxhash-wasm-0.4.2.tgz#752398c131a4dd407b5132ba62ad372029be6f79" - integrity sha512-/eyHVRJQCirEkSZ1agRSCwriMhwlyUcFkXD5TPVSLP+IPzjsqMVzZwdoczLp1SoQU0R3dxz1RpIK+4YNQbCVOA== - -yaml@^1.10.0, yaml@^1.10.2: - version "1.10.2" - resolved "https://registry.yarnpkg.com/yaml/-/yaml-1.10.2.tgz#2301c5ffbf12b467de8da2333a459e29e7920e4b" - integrity sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg== diff --git a/tfjs-master/tfjs-converter/docs/supported_ops.md b/tfjs-master/tfjs-converter/docs/supported_ops.md deleted file mode 100644 index 43ae0fe40..000000000 --- a/tfjs-master/tfjs-converter/docs/supported_ops.md +++ /dev/null @@ -1,381 +0,0 @@ -# Supported Tensorflow Ops - -## Operations - Arithmetic - -|Tensorflow Op Name|Tensorflow.js Op Name| -|---|---| -|Add|add| -|AddN|addN| -|AddV2|AddV2| -|BiasAdd|BiasAdd| -|Div|div| -|DivNoNan|divNoNan| -|FloorDiv|floorDiv| -|FloorMod|FloorMod| -|Maximum|maximum| -|Minimum|minimum| -|Mod|mod| -|Mul|mul| -|Pow|pow| -|RealDiv|RealDiv| -|SquaredDifference|squaredDifference| -|Sub|sub| - -## Operations - Basic math - -|Tensorflow Op Name|Tensorflow.js Op Name| -|---|---| -|Abs|abs| -|Acos|acos| -|Acosh|acosh| -|Asin|asin| -|Asinh|asinh| -|Atan|atan| -|Atan2|atan2| -|Atanh|atanh| -|Ceil|ceil| -|ClipByValue|clipByValue| -|Complex|Complex| -|ComplexAbs|ComplexAbs| -|Cos|cos| -|Cosh|cosh| -|Elu|elu| -|Erf|erf| -|Exp|exp| -|Expm1|expm1| -|Floor|floor| -|Imag|Imag| -|LeakyRelu|leakyRelu| -|Log|log| -|Log1p|log1p| -|Neg|neg| -|Prelu|prelu| -|Prod|Prod| -|Real|Real| -|Reciprocal|reciprocal| -|Relu|relu| -|Relu6|relu6| -|Round|round| -|Rsqrt|rsqrt| -|Selu|selu| -|Sigmoid|sigmoid| -|Sign|sign| -|Sin|sin| -|Sinh|sinh| -|Softplus|softplus| -|Sqrt|sqrt| -|Square|square| -|Tan|tan| -|Tanh|tanh| -|IsFinite|isFinite| -|IsInf|isInf| -|IsNan|isNaN| -|Not mapped|logSigmoid| -|Not mapped|step| - -## Operations - Control Flow - -|Tensorflow Op Name|Tensorflow.js Op Name| -|---|---| -|EmptyTensorList|EmptyTensorList| -|Enter|Enter| -|Exit|Exit| -|If|If| -|LoopCond|LoopCond| -|Merge|Merge| -|NextIteration|NextIteration| -|StatelessIf|StatelessIf| -|StatelessWhile|StatelessWhile| -|Switch|Switch| -|TensorArrayCloseV3|TensorArrayCloseV3| -|TensorArrayConcatV3|TensorArrayConcatV3| -|TensorArrayGatherV3|TensorArrayGatherV3| -|TensorArrayReadV3|TensorArrayReadV3| -|TensorArrayScatterV3|TensorArrayScatterV3| -|TensorArraySizeV3|TensorArraySizeV3| -|TensorArraySplitV3|TensorArraySplitV3| -|TensorArrayV3|TensorArrayV3| -|TensorArrayWriteV3|TensorArrayWriteV3| -|TensorListConcat|TensorListConcat| -|TensorListConcatV2|TensorListConcatV2| -|TensorListFromTensor|TensorListFromTensor| -|TensorListGather|TensorListGather| -|TensorListGetItem|TensorListGetItem| -|TensorListLength|TensorListLength| -|TensorListPopBack|TensorListPopBack| -|TensorListPushBack|TensorListPushBack| -|TensorListReserve|TensorListReserve| -|TensorListResize|TensorListResize| -|TensorListScatter|TensorListScatter| -|TensorListScatterV2|TensorListScatterV2| -|TensorListSetItem|TensorListSetItem| -|TensorListSplit|TensorListSplit| -|TensorListStack|TensorListStack| -|While|While| - -## Operations - Convolution - -|Tensorflow Op Name|Tensorflow.js Op Name| -|---|---| -|_FusedConv2D|_FusedConv2D| -|AvgPool|AvgPool| -|AvgPool3D|avgPool3d| -|Conv1D|conv1d| -|Conv2D|conv2d| -|Conv2DBackpropInput|Conv2DBackpropInput| -|Conv3D|conv3d| -|DepthwiseConv2d|depthwiseConv2d| -|DepthwiseConv2dNative|DepthwiseConv2dNative| -|Dilation2D|Dilation2D| -|FusedDepthwiseConv2dNative|FusedDepthwiseConv2dNative| -|MaxPool|MaxPool| -|MaxPool3D|maxPool3d| -|MaxPoolWithArgmax|maxPoolWithArgmax| -|Not mapped|conv2dTranspose| -|Not mapped|conv3dTranspose| -|Not mapped|pool| -|Not mapped|separableConv2d| - -## Tensors - Creation - -|Tensorflow Op Name|Tensorflow.js Op Name| -|---|---| -|Fill|fill| -|LinSpace|linspace| -|Multinomial|Multinomial| -|OneHot|oneHot| -|Ones|ones| -|OnesLike|onesLike| -|RandomStandardNormal|RandomStandardNormal| -|RandomUniform|RandomUniform| -|Range|range| -|TruncatedNormal|truncatedNormal| -|Zeros|zeros| -|ZerosLike|zerosLike| -|Not mapped|eye| - -## Operations - Dynamic - -|Tensorflow Op Name|Tensorflow.js Op Name| -|---|---| -|ListDiff|ListDiff| -|NonMaxSuppressionV2|NonMaxSuppressionV2| -|NonMaxSuppressionV3|NonMaxSuppressionV3| -|NonMaxSuppressionV4|NonMaxSuppressionV4| -|NonMaxSuppressionV5|NonMaxSuppressionV5| -|Where|Where| - -## Operations - Evaluation - -|Tensorflow Op Name|Tensorflow.js Op Name| -|---|---| -|LowerBound|LowerBound| -|TopKV2|TopKV2| -|Unique|Unique| -|UniqueV2|UniqueV2| -|UpperBound|UpperBound| -|Not mapped|confusionMatrix| -|Not mapped|inTopKAsync| -|Not mapped|topk| - -## Tensorflow - Graph - -|Tensorflow Op Name|Tensorflow.js Op Name| -|---|---| -|Const|Const| -|FakeQuantWithMinMaxVars|FakeQuantWithMinMaxVars| -|Identity|Identity| -|IdentityN|IdentityN| -|NoOp|NoOp| -|Placeholder|Placeholder| -|PlaceholderWithDefault|PlaceholderWithDefault| -|Print|Print| -|Rank|Rank| -|Shape|Shape| -|ShapeN|ShapeN| -|Size|Size| -|Snapshot|Snapshot| -|StopGradient|StopGradient| - -## Operations - Logical - -|Tensorflow Op Name|Tensorflow.js Op Name| -|---|---| -|BitwiseAnd|bitwiseAnd| -|Equal|equal| -|Greater|greater| -|GreaterEqual|greaterEqual| -|Less|less| -|LessEqual|lessEqual| -|LogicalAnd|logicalAnd| -|LogicalNot|logicalNot| -|LogicalOr|logicalOr| -|NotEqual|notEqual| -|Select|Select| -|SelectV2|SelectV2| -|Not mapped|logicalXor| - -## Operations - Hashtable - -|Tensorflow Op Name|Tensorflow.js Op Name| -|---|---| -|HashTable|HashTable| -|HashTableV2|HashTableV2| -|LookupTableFind|LookupTableFind| -|LookupTableFindV2|LookupTableFindV2| -|LookupTableImport|LookupTableImport| -|LookupTableImportV2|LookupTableImportV2| -|LookupTableSize|LookupTableSize| -|LookupTableSizeV2|LookupTableSizeV2| - -## Operations - Images - -|Tensorflow Op Name|Tensorflow.js Op Name| -|---|---| -|CropAndResize|cropAndResize| -|ResizeBilinear|resizeBilinear| -|ResizeNearestNeighbor|resizeNearestNeighbor| -|Not mapped|flipLeftRight| -|Not mapped|rotateWithOffset| -|ImageProjectiveTransformV3|transform| - -## Operations - Matrices - -|Tensorflow Op Name|Tensorflow.js Op Name| -|---|---| -|_FusedMatMul|_FusedMatMul| -|BatchMatMul|BatchMatMul| -|BatchMatMulV2|BatchMatMulV2| -|Einsum|Einsum| -|MatMul|matMul| -|Transpose|transpose| -|MatrixBandPart|MatrixBandPart| -|Not mapped|dot| -|Not mapped|norm| -|Not mapped|outerProduct| - -## Operations - Moving Average - -|Tensorflow Op Name|Tensorflow.js Op Name| -|---|---| -|Not mapped|movingAverage| - -## Operations - Normalization - -|Tensorflow Op Name|Tensorflow.js Op Name| -|---|---| -|EuclideanNorm|EuclideanNorm| -|FusedBatchNorm|FusedBatchNorm| -|FusedBatchNormV2|FusedBatchNormV2| -|FusedBatchNormV3|FusedBatchNormV3| -|LogSoftmax|logSoftmax| -|LRN|LRN| -|Softmax|softmax| -|SparseToDense|sparseToDense| -|Not mapped|batchNorm| -|Not mapped|moments| - -## Operations - Reduction - -|Tensorflow Op Name|Tensorflow.js Op Name| -|---|---| -|All|all| -|Any|any| -|ArgMax|argMax| -|ArgMin|argMin| -|Bincount|bincount| -|DenseBincount|denseBincount| -|Max|max| -|Mean|mean| -|Min|min| -|Prod|prod| -|Sum|sum| -|Not mapped|logSumExp| - -## Tensors - RNN - -|Tensorflow Op Name|Tensorflow.js Op Name| -|---|---| - -## Operations - Scan - -|Tensorflow Op Name|Tensorflow.js Op Name| -|---|---| -|Cumprod|cumprod| -|Cumsum|cumsum| - -## Operations - Segment - -|Tensorflow Op Name|Tensorflow.js Op Name| -|---|---| -|Not mapped|unsortedSegmentSum| - -## Tensors - Slicing and Joining - -|Tensorflow Op Name|Tensorflow.js Op Name| -|---|---| -|Concat|concat| -|ConcatV2|ConcatV2| -|Gather|gather| -|GatherNd|GatherNd| -|GatherV2|GatherV2| -|Pack|Pack| -|Reverse|reverse| -|ReverseV2|ReverseV2| -|ScatterNd|ScatterNd| -|Slice|slice| -|SparseToDense|SparseToDense| -|Split|split| -|SplitV|SplitV| -|StridedSlice|StridedSlice| -|Tile|tile| -|Unpack|Unpack| -|Not mapped|booleanMaskAsync| -|Not mapped|stack| -|Not mapped|unstack| - -## Operations - Spectral - -|Tensorflow Op Name|Tensorflow.js Op Name| -|---|---| -|FFT|fft| -|IFFT|ifft| -|IRFFT|irfft| -|RFFT|rfft| - -## Operations - Signal - -|Tensorflow Op Name|Tensorflow.js Op Name| -|---|---| -|Not mapped|frame| -|Not mapped|hammingWindow| -|Not mapped|hannWindow| -|Not mapped|stft| - -## Operations - Linear Algebra - -|Tensorflow Op Name|Tensorflow.js Op Name| -|---|---| -|Not mapped|bandPart| -|Not mapped|gramSchmidt| -|Not mapped|qr| - -## Tensors - Transformations - -|Tensorflow Op Name|Tensorflow.js Op Name| -|---|---| -|BatchToSpaceND|batchToSpaceND| -|BroadcastArgs|broadcastArgs| -|BroadcastTo|broadcastTo| -|Cast|cast| -|DepthToSpace|depthToSpace| -|ExpandDims|expandDims| -|MirrorPad|MirrorPad| -|Pad|pad| -|PadV2|PadV2| -|Reshape|reshape| -|EnsureShape|ensureShape| -|SpaceToBatchND|spaceToBatchND| -|Squeeze|squeeze| -|Not mapped|setdiff1dAsync| - diff --git a/tfjs-master/tfjs-converter/metadata/BUILD.bazel b/tfjs-master/tfjs-converter/metadata/BUILD.bazel deleted file mode 100644 index 2d31cf5ff..000000000 --- a/tfjs-master/tfjs-converter/metadata/BUILD.bazel +++ /dev/null @@ -1,11 +0,0 @@ -load("//tfjs-converter/scripts:kernels_to_ops.bzl", "kernels_to_ops") - -package(default_visibility = ["//visibility:public"]) - -kernels_to_ops( - name = "kernels_to_ops", - srcs = [ - "//tfjs-converter/src:all_srcs", - ], - out = "kernel2op.json", -) diff --git a/tfjs-master/tfjs-converter/package.json b/tfjs-master/tfjs-converter/package.json deleted file mode 100644 index b350a90b2..000000000 --- a/tfjs-master/tfjs-converter/package.json +++ /dev/null @@ -1,55 +0,0 @@ -{ - "name": "@tensorflow/tfjs-converter", - "version": "0.0.0", - "description": "Tensorflow model converter for javascript", - "main": "dist/tf-converter.node.js", - "jsnext:main": "dist/index.js", - "module": "dist/index.js", - "types": "dist/index.d.ts", - "unpkg": "dist/tf-converter.min.js", - "jsdelivr": "dist/tf-converter.min.js", - "miniprogram": "dist/miniprogram", - "repository": { - "type": "git", - "url": "https://github.com/tensorflow/tfjs.git", - "directory": "tfjs-converter" - }, - "license": "Apache-2.0", - "peerDependencies": { - "@tensorflow/tfjs-core": "link:../link-package/node_modules/@tensorflow/tfjs-core" - }, - "devDependencies": { - "@bazel/bazelisk": "^1.12.0", - "@bazel/ibazel": "^0.16.2", - "@tensorflow/tfjs-backend-cpu": "link:../link-package/node_modules/@tensorflow/tfjs-backend-cpu", - "@tensorflow/tfjs-core": "link:../link-package/node_modules/@tensorflow/tfjs-core", - "@types/argparse": "^1.0.38", - "@types/long": "~3.0.32", - "@types/node-fetch": "1.6.9", - "argparse": "^1.0.10", - "node-fetch": "~2.6.1", - "opn": "~5.1.0", - "protobufjs": "~7.2.4", - "ts-node": "~8.8.2", - "typescript": "5.0.4", - "yalc": "~1.0.0-pre.50" - }, - "scripts": { - "build": "bazel build :tfjs-converter_pkg", - "publish-npm": "bazel run :tfjs-converter_pkg.publish", - "test": "bazel test :tests", - "test-dev": "ibazel test :tests", - "test-debug": "bazel run :tfjs-converter_test --config=debug", - "test-converter": "bazel test :tfjs-converter_test", - "test-converter-debug": "yarn test-debug", - "test-snippets": "bazel test :test_snippets_test --test_output=all", - "gen-doc": "ts-node -s ./scripts/gen_doc.ts", - "model-summary": "ts-node -s ./tools/model_summary.ts", - "pb2json": "ts-node -s ./tools/pb2json_converter.ts", - "build-pip-package": "cd python && ./build-pip-package.sh --test /tmp/tfjs-pips", - "run-python-tests": "bazel test python/..." - }, - "resolutions": { - "minimist": "1.2.6" - } -} diff --git a/tfjs-master/tfjs-converter/python/.pylintrc b/tfjs-master/tfjs-converter/python/.pylintrc deleted file mode 100644 index be7b93763..000000000 --- a/tfjs-master/tfjs-converter/python/.pylintrc +++ /dev/null @@ -1,425 +0,0 @@ -[MASTER] - -# A comma-separated list of package or module names from where C extensions may -# be loaded. Extensions are loading into the active Python interpreter and may -# run arbitrary code -extension-pkg-whitelist= - -# Add files or directories to the blacklist. They should be base names, not -# paths. -ignore=CVS - -# Add files or directories matching the regex patterns to the blacklist. The -# regex matches against base names, not paths. -ignore-patterns=.*_pb2 - -# Python code to execute, usually for sys.path manipulation such as -# pygtk.require(). -#init-hook= - -# Use multiple processes to speed up Pylint. -jobs=1 - -# List of plugins (as comma separated values of python modules names) to load, -# usually to register additional checkers. -load-plugins= - -# Pickle collected data for later comparisons. -persistent=yes - -# Specify a configuration file. -#rcfile= - -# Allow loading of arbitrary C extensions. Extensions are imported into the -# active Python interpreter and may run arbitrary code. -unsafe-load-any-extension=no - - -[MESSAGES CONTROL] - -# Only show warnings with the listed confidence levels. Leave empty to show -# all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED -confidence= - -# Disable the message, report, category or checker with the given id(s). You -# can either give multiple identifiers separated by comma (,) or put this -# option multiple times (only on the command line, not in the configuration -# file where it should appear only once).You can also use "--disable=all" to -# disable everything first and then reenable specific checks. For example, if -# you want to run only the similarities checker, you can use "--disable=all -# --enable=similarities". If you want to run only the classes checker, but have -# no Warning level messages displayed, use"--disable=all --enable=classes -# --disable=W" -disable=print-statement,parameter-unpacking,unpacking-in-except,old-raise-syntax,backtick,long-suffix,old-ne-operator,old-octal-literal,import-star-module-level,raw-checker-failed,bad-inline-option,locally-disabled,locally-enabled,file-ignored,suppressed-message,useless-suppression,deprecated-pragma,apply-builtin,basestring-builtin,buffer-builtin,cmp-builtin,coerce-builtin,execfile-builtin,file-builtin,long-builtin,raw_input-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,no-absolute-import,old-division,dict-iter-method,dict-view-method,next-method-called,metaclass-assignment,indexing-exception,raising-string,reload-builtin,oct-method,hex-method,nonzero-method,cmp-method,input-builtin,round-builtin,intern-builtin,unichr-builtin,map-builtin-not-iterating,zip-builtin-not-iterating,range-builtin-not-iterating,filter-builtin-not-iterating,using-cmp-argument,eq-without-hash,div-method,idiv-method,rdiv-method,exception-message-attribute,invalid-str-codec,sys-max-int,bad-python3-import,deprecated-string-function,deprecated-str-translate-call,duplicate-code,invalid-name,missing-docstring,fixme,no-member,protected-access,no-self-use,no-name-in-module,bad-option-value,no-else-return,too-few-public-methods,too-many-branches,too-many-arguments,too-many-public-methods,too-many-locals,too-many-return-statements,too-many-instance-attributes,not-context-manager,blacklisted-name,import-error - -# Enable the message, report, category or checker with the given id(s). You can -# either give multiple identifier separated by comma (,) or put this option -# multiple time (only on the command line, not in the configuration file where -# it should appear only once). See also the "--disable" option for examples. -enable= - - -[REPORTS] - -# Python expression which should return a note less than 10 (10 is the highest -# note). You have access to the variables errors warning, statement which -# respectively contain the number of errors / warnings messages and the total -# number of statements analyzed. This is used by the global evaluation report -# (RP0004). -evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10) - -# Template used to display messages. This is a python new-style format string -# used to format the message information. See doc for all details -#msg-template= - -# Set the output format. Available formats are text, parseable, colorized, json -# and msvs (visual studio).You can also give a reporter class, eg -# mypackage.mymodule.MyReporterClass. -output-format=text - -# Tells whether to display a full report or only the messages -reports=no - -# Activate the evaluation score. -score=yes - - -[REFACTORING] - -# Maximum number of nested blocks for function / method body -max-nested-blocks=5 - - -[BASIC] - -# Naming hint for argument names -argument-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ - -# Regular expression matching correct argument names -argument-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ - -# Naming hint for attribute names -attr-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ - -# Regular expression matching correct attribute names -attr-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ - -# Bad variable names which should always be refused, separated by a comma -bad-names=foo,bar,baz,toto,tutu,tata - -# Naming hint for class attribute names -class-attribute-name-hint=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$ - -# Regular expression matching correct class attribute names -class-attribute-rgx=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$ - -# Naming hint for class names -class-name-hint=[A-Z_][a-zA-Z0-9]+$ - -# Regular expression matching correct class names -class-rgx=[A-Z_][a-zA-Z0-9]+$ - -# Naming hint for constant names -const-name-hint=(([A-Z_][A-Z0-9_]*)|(__.*__))$ - -# Regular expression matching correct constant names -const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__))$ - -# Minimum line length for functions/classes that require docstrings, shorter -# ones are exempt. -docstring-min-length=10 - -# Naming hint for function names -function-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ - -# Regular expression matching correct function names -function-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ - -# Good variable names which should always be accepted, separated by a comma -good-names=i,j,k,ex,Run,_ - -# Include a hint for the correct naming format with invalid-name -include-naming-hint=yes - -# Naming hint for inline iteration names -inlinevar-name-hint=[A-Za-z_][A-Za-z0-9_]*$ - -# Regular expression matching correct inline iteration names -inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$ - -# Naming hint for method names -method-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ - -# Regular expression matching correct method names -method-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ - -# Naming hint for module names -module-name-hint=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$ - -# Regular expression matching correct module names -module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$ - -# Colon-delimited sets of names that determine each other's naming style when -# the name regexes allow several styles. -name-group= - -# Regular expression which should only match function or class names that do -# not require a docstring. -no-docstring-rgx=^_ - -# List of decorators that produce properties, such as abc.abstractproperty. Add -# to this list to register other decorators that produce valid properties. -property-classes=abc.abstractproperty - -# Naming hint for variable names -variable-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ - -# Regular expression matching correct variable names -variable-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ - - -[TYPECHECK] - -# List of decorators that produce context managers, such as -# contextlib.contextmanager. Add to this list to register other decorators that -# produce valid context managers. -contextmanager-decorators=contextlib.contextmanager,tensorflow.python.util.tf_contextlib.contextmanager - -# List of members which are set dynamically and missed by pylint inference -# system, and so shouldn't trigger E1101 when accessed. Python regular -# expressions are accepted. -generated-members= - -# Tells whether missing members accessed in mixin class should be ignored. A -# mixin class is detected if its name ends with "mixin" (case insensitive). -ignore-mixin-members=yes - -# This flag controls whether pylint should warn about no-member and similar -# checks whenever an opaque object is returned when inferring. The inference -# can return multiple potential results while evaluating a Python object, but -# some branches might not be evaluated, which results in partial inference. In -# that case, it might be useful to still emit no-member and other checks for -# the rest of the inferred objects. -ignore-on-opaque-inference=yes - -# List of class names for which member attributes should not be checked (useful -# for classes with dynamically set attributes). This supports the use of -# qualified names. -ignored-classes=optparse.Values,thread._local,_thread._local - -# List of module names for which member attributes should not be checked -# (useful for modules/projects where namespaces are manipulated during runtime -# and thus existing member attributes cannot be deduced by static analysis. It -# supports qualified module names, as well as Unix pattern matching. -ignored-modules=six,six.moves,*_pb2 - -# Show a hint with possible names when a member name was not found. The aspect -# of finding the hint is based on edit distance. -missing-member-hint=yes - -# The minimum edit distance a name should have in order to be considered a -# similar match for a missing member name. -missing-member-hint-distance=1 - -# The total number of similar names that should be taken in consideration when -# showing a hint for a missing member. -missing-member-max-choices=1 - - -[MISCELLANEOUS] - -# List of note tags to take in consideration, separated by a comma. -notes=FIXME,XXX,TODO - - -[VARIABLES] - -# List of additional names supposed to be defined in builtins. Remember that -# you should avoid to define new builtins when possible. -additional-builtins= - -# Tells whether unused global variables should be treated as a violation. -allow-global-unused-variables=yes - -# List of strings which can identify a callback function by name. A callback -# name must start or end with one of those strings. -callbacks=cb_,_cb - -# A regular expression matching the name of dummy variables (i.e. expectedly -# not used). -dummy-variables-rgx=_+$|(_[a-zA-Z0-9_]*[a-zA-Z0-9]+?$)|dummy|^ignored_|^unused_ - -# Argument names that match this expression will be ignored. Default to name -# with leading underscore -ignored-argument-names=_.*|^ignored_|^unused_ - -# Tells whether we should check for unused import in __init__ files. -init-import=no - -# List of qualified module names which can have objects that can redefine -# builtins. -redefining-builtins-modules=six.moves,future.builtins - - -[FORMAT] - -# Expected format of line ending, e.g. empty (any line ending), LF or CRLF. -expected-line-ending-format= - -# Regexp for a line that is allowed to be longer than the limit. -ignore-long-lines=^\s*(# )??$ - -# Number of spaces of indent required inside a hanging or continued line. -indent-after-paren=4 - -# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1 -# tab). -indent-string=' ' - -# Maximum number of characters on a single line. -max-line-length=80 - -# Maximum number of lines in a module -max-module-lines=10000 - -# List of optional constructs for which whitespace checking is disabled. `dict- -# separator` is used to allow tabulation in dicts, etc.: {1 : 1,\n222: 2}. -# `trailing-comma` allows a space between comma and closing bracket: (a, ). -# `empty-line` allows space-only lines. -no-space-check=trailing-comma,dict-separator - -# Allow the body of a class to be on the same line as the declaration if body -# contains single statement. -single-line-class-stmt=no - -# Allow the body of an if to be on the same line as the test if there is no -# else. -single-line-if-stmt=no - - -[SPELLING] - -# Spelling dictionary name. Available dictionaries: none. To make it working -# install python-enchant package. -spelling-dict= - -# List of comma separated words that should not be checked. -spelling-ignore-words= - -# A path to a file that contains private dictionary; one word per line. -spelling-private-dict-file= - -# Tells whether to store unknown words to indicated private dictionary in -# --spelling-private-dict-file option instead of raising a message. -spelling-store-unknown-words=no - - -[LOGGING] - -# Logging modules to check that the string format arguments are in logging -# function parameter format -logging-modules=logging - - -[SIMILARITIES] - -# Ignore comments when computing similarities. -ignore-comments=yes - -# Ignore docstrings when computing similarities. -ignore-docstrings=yes - -# Ignore imports when computing similarities. -ignore-imports=yes - -# Minimum lines number of a similarity. -min-similarity-lines=4 - - -[CLASSES] - -# List of method names used to declare (i.e. assign) instance attributes. -defining-attr-methods=__init__,__new__,setUp - -# List of member names, which should be excluded from the protected access -# warning. -exclude-protected=_asdict,_fields,_replace,_source,_make - -# List of valid names for the first argument in a class method. -valid-classmethod-first-arg=cls - -# List of valid names for the first argument in a metaclass class method. -valid-metaclass-classmethod-first-arg=mcs - - -[IMPORTS] - -# Allow wildcard imports from modules that define __all__. -allow-wildcard-with-all=no - -# Analyse import fallback blocks. This can be used to support both Python 2 and -# 3 compatible code, which means that the block might have code that exists -# only in one or another interpreter, leading to false positives when analysed. -analyse-fallback-blocks=no - -# Deprecated modules which should not be used, separated by a comma -deprecated-modules=regsub,TERMIOS,Bastion,rexec - -# Create a graph of external dependencies in the given file (report RP0402 must -# not be disabled) -ext-import-graph= - -# Create a graph of every (i.e. internal and external) dependencies in the -# given file (report RP0402 must not be disabled) -import-graph= - -# Create a graph of internal dependencies in the given file (report RP0402 must -# not be disabled) -int-import-graph= - -# Force import order to recognize a module as part of the standard -# compatibility libraries. -known-standard-library= - -# Force import order to recognize a module as part of a third party library. -known-third-party=enchant - - -[DESIGN] - -# Maximum number of arguments for function / method -max-args=5 - -# Maximum number of attributes for a class (see R0902). -max-attributes=7 - -# Maximum number of boolean expressions in a if statement -max-bool-expr=5 - -# Maximum number of branch for function / method body -max-branches=12 - -# Maximum number of locals for function / method body -max-locals=15 - -# Maximum number of parents for a class (see R0901). -max-parents=7 - -# Maximum number of public methods for a class (see R0904). -max-public-methods=20 - -# Maximum number of return / yield for function / method body -max-returns=6 - -# Maximum number of statements in function / method body -max-statements=80 - -# Minimum number of public methods for a class (see R0903). -min-public-methods=2 - - -[EXCEPTIONS] - -# Exceptions that will emit a warning when being caught. Defaults to -# "Exception" -overgeneral-exceptions=Exception diff --git a/tfjs-master/tfjs-converter/python/BUILD.bazel b/tfjs-master/tfjs-converter/python/BUILD.bazel deleted file mode 100644 index 3df31fc75..000000000 --- a/tfjs-master/tfjs-converter/python/BUILD.bazel +++ /dev/null @@ -1,88 +0,0 @@ -load("@rules_python//python:packaging.bzl", "py_package", "py_wheel") -load("@rules_python//python:pip.bzl", "compile_pip_requirements") - -package(default_visibility = ["//visibility:public"]) - -licenses(["notice"]) # Apache 2.0 - -CONSOLE_SCRIPTS = { - "tensorflowjs_converter": "tensorflowjs.converters.converter:pip_main", - "tensorflowjs_wizard": "tensorflowjs.converters.wizard:pip_main", -} - -compile_pip_requirements( - name = "tensorflowjs_deps_requirements", - extra_args = ["--allow-unsafe"], # Allow pinning setuptools - requirements_in = "requirements.txt", - requirements_txt = "requirements_lock.txt", -) - -compile_pip_requirements( - name = "tensorflowjs_dev_deps_requirements", - data = [ - ":requirements.txt", - ], - extra_args = ["--allow-unsafe"], # Allow pinning setuptools - requirements_in = "requirements-dev.txt", - requirements_txt = "requirements-dev_lock.txt", -) - -py_package( - name = "tensorflowjs_pkg", - # Only include these Python packages. - packages = ["tfjs-converter/python/tensorflowjs"], - deps = ["//tfjs-converter/python/tensorflowjs"], -) - -py_wheel( - name = "python3_wheel", - author = "Google LLC", - author_email = "opensource@google.com", - classifiers = [ - "Development Status :: 3 - Alpha", - "Intended Audience :: Developers", - "Intended Audience :: Education", - "Intended Audience :: Science/Research", - "License :: OSI Approved :: Apache Software License", - "Programming Language :: JavaScript", - "Programming Language :: Python :: 2", - "Programming Language :: Python :: 3", - "Topic :: Scientific/Engineering", - "Topic :: Scientific/Engineering :: Mathematics", - "Topic :: Scientific/Engineering :: Artificial Intelligence", - "Topic :: Software Development", - "Topic :: Software Development :: Libraries", - "Topic :: Software Development :: Libraries :: Python Modules", - ], - console_scripts = CONSOLE_SCRIPTS, - description_file = ":README.md", - distribution = "tensorflowjs", - extra_requires = { - "PyInquirer": ["PyInquirer==1.0.3"], - "all": ["PyInquirer==1.0.3"], - "wizard": ["PyInquirer==1.0.3"], - }, - homepage = "https://js.tensorflow.org/", - license = "Apache 2.0", - python_tag = "py3", - requires = [ - "flax>=0.7.2", - "importlib_resources>=5.9.0", - "jax>=0.4.13", - "jaxlib>=0.4.13", - "tensorflow>=2.13.0,<3", - "tensorflow-decision-forests>=1.5.0", - "six>=1.16.0,<2", - "tensorflow-hub>=0.14.0", - "packaging~=23.1", - ], - strip_path_prefixes = [ - "tfjs-converter/python", - ], - version = "0.0.0", - #keywords='tensorflow javascript machine deep learning converter', - deps = [ - ":tensorflowjs_pkg", - "//tfjs-converter/python/tensorflowjs", - ], -) diff --git a/tfjs-master/tfjs-converter/python/MANIFEST.in b/tfjs-master/tfjs-converter/python/MANIFEST.in deleted file mode 100644 index f9bd1455b..000000000 --- a/tfjs-master/tfjs-converter/python/MANIFEST.in +++ /dev/null @@ -1 +0,0 @@ -include requirements.txt diff --git a/tfjs-master/tfjs-converter/python/README.md b/tfjs-master/tfjs-converter/python/README.md deleted file mode 100644 index 25849cd7c..000000000 --- a/tfjs-master/tfjs-converter/python/README.md +++ /dev/null @@ -1,63 +0,0 @@ -# tensorflowjs: The Python Package for TensorFlow.js - -The **tensorflowjs** pip package contains libraries and tools for -[TensorFlow.js](https://js.tensorflow.org). - -Use following command to install the library with support of interactive CLI: -```bash -pip install tensorflowjs[wizard] -``` - -Then, run the following to see a list of CLI options - -```bash -tensorflowjs_converter --help -``` - -or, use the wizard - -```bash -tensorflowjs_wizard -``` - -Alternatively, run the converter via its Bazel target. This must be run from withing the tfjs repo: - -```bash -yarn bazel run //tfjs-converter/python/tensorflowjs/converters:converter -- --help -``` - -## Development - -The python tests are run with Bazel. - -```bash -yarn bazel test //tfjs-converter/python/... -``` - -Alternatively, run `yarn run-python-tests` to run the above command. - -To debug a specific test case, use the `--test_filter` option. For example, - -```bash -yarn bazel test //tfjs-converter/python/tensorflowjs/converters:tf_saved_model_conversion_v2_test --test_filter=ConvertTest.test_convert_saved_model_v1 -``` - -Interactive debugging with breakpoints is supported by `debugpy` in VSCode. -To enable debugging, put this code at the top of the test file you want to -debug. - -```python -import debugpy -debugpy.listen(('localhost', 5724)) -print("Waiting for debugger to connect. See tfjs-converter python README") -debugpy.wait_for_client() -``` - -You may also need to add the following dependency to the test target in the -Bazel `BUILD` file if it's not already present. -```starlark -"//tfjs-converter/python/tensorflowjs:expect_debugpy_installed" -``` - -Then, run the test with `bazel run --config=debugpy` and connect -the VSCode debugger by selecting the `Python: Attach (Converter)` option. diff --git a/tfjs-master/tfjs-converter/python/build-pip-package.sh b/tfjs-master/tfjs-converter/python/build-pip-package.sh deleted file mode 100644 index 130e69b06..000000000 --- a/tfjs-master/tfjs-converter/python/build-pip-package.sh +++ /dev/null @@ -1,262 +0,0 @@ -#!/usr/bin/env bash -# Copyright 2018 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================== - -# Build pip package for keras_model_converter. -# -# Run this script outside a virtualenv, as this script will activate a -# virtualenv for python3 to generate the wheel files. -# -# Usage: -# build-pip-package.sh \ -# [--test] [--upload] [--upload-to-test] [--confirm-upload] -# -# Positional arguments: -# DEST_DIR: Destination directory for writing the pip wheels. -# -# Optional argumnets: -# --test: Test the pip packages by installing it (inside virtualenv) -# and running test_pip_package.py against the install. -# --test-nightly: Test the pip packages by installing it (inside virtualenv) -# and running test_pip_package.py and test_pip_nightly_package.py -# against the install. -# --build: Create the pip packages. -# --upload: Upload the py2 and py3 wheels to prod PyPI. -# --upload-to-test: Upload the py2 and py3 wheels to test PyPI, mutually -# exclusive with --upload. -# --confirm-upload: Do not prompt for yes/no before uploading to test or -# prod PyPI. Use with care! -# -# N.B. For pypi/twine authentication, you need to have the file ~/.pypirc, -# with content formatted like below: -# ``` -# [distutils] -# index-servers = -# pypi-warehouse -# test-warehouse -# -# [test-warehouse] -# repository = https://test.pypi.org/legacy/ -# username: -# password: -# -# [pypi-warehouse] -# repository = https://upload.pypi.org/legacy/ -# username: -# password: -# ``` - -set -e - -function print_usage() { - echo "Usage:" - echo " build-pip-packages.sh \\" - echo " [--test] [--test-nightly] [--build] [--upload] [--upload-to-test] [--confirm-upload] " - echo -} - -SCRIPTS_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" - -if [[ $# == 0 ]]; then - print_usage - exit 1 -fi - -RUN_TEST=0 -RUN_TEST_NIGHTLY=0 -UPLOAD_TO_PROD_PYPI=0 -UPLOAD_TO_TEST_PYPI=0 -CONFIRM_UPLOAD=0 -BUILD=0 -DEST_DIR="" -while true; do - if [[ "$1" == "--test" ]]; then - RUN_TEST=1 - elif [[ "$1" == "--test-nightly" ]]; then - RUN_TEST_NIGHTLY=1 - elif [[ "$1" == "--upload" ]]; then - UPLOAD_TO_PROD_PYPI=1 - elif [[ "$1" == "--upload-to-test" ]]; then - UPLOAD_TO_TEST_PYPI=1 - elif [[ "$1" == "--confirm-upload" ]]; then - CONFIRM_UPLOAD=1 - elif [[ "$1" == "--build" ]]; then - BUILD=1 - elif [[ "$1" != --* ]]; then - DEST_DIR="$1" - else - print_usage - exit 1 - fi - shift - - if [[ -z "$1" ]]; then - break - fi -done - -if [[ "${UPLOAD_TO_TEST_PYPI}" == 1 && "${UPLOAD_TO_PROD_PYPI}" == 1 ]]; then - echo "ERROR: Do not use --upload and --upload-to-test together." - exit 1 -fi - -if [[ -z "${DEST_DIR}" ]]; then - print_usage - exit 1 -fi - -if [[ -f "${DEST_DIR}" || -d "${DEST_DIR}" ]]; then - echo "ERROR: ${DEST_DIR} already exists. Please specify a new DEST_DIR." - exit 1 -fi - -mkdir -p "${DEST_DIR}" -DEST_DIR="$(cd "${DEST_DIR}" 2>/dev/null && pwd -P)" - -pip install virtualenv - -# Check virtualenv is on path. -if [[ -z "$(which virtualenv)" ]]; then - echo "ERROR: Cannot find virtualenv on path. Install virtualenv first." - exit 1 -fi - -# Create virtualenv for python3; build (and test) the wheel inside it. -VENV_PYTHON_BINS="python3" -for VENV_PYTHON_BIN in ${VENV_PYTHON_BINS}; do - if [[ -z "$(which "${VENV_PYTHON_BIN}")" ]]; then - echo "ERROR: Unable to find ${VENV_PYTHON_BIN} on path." - exit 1 - fi - - TMP_VENV_DIR="$(mktemp -d)" - virtualenv -p "${VENV_PYTHON_BIN}" "${TMP_VENV_DIR}" - source "${TMP_VENV_DIR}/bin/activate" - - echo - echo "Looking for wheel for ${VENV_PYTHON_BIN}: $(python --version 2>&1) ..." - echo "The wheel should be build with 'bazel build python3_wheel' command" - echo - - pushd "${TMP_DIR}" > /dev/null - echo - - WHEELS=$(ls ../../dist/bin/tfjs-converter/python/*py${VENV_PYTHON_BIN: -1}*.whl) - cp ../../dist/bin/tfjs-converter/python/*py${VENV_PYTHON_BIN: -1}*.whl "${DEST_DIR}/" - - WHEEL_PATH="" - echo - echo "Generated wheel file(s) in ${DEST_DIR} :" - for WHEEL in ${WHEELS}; do - WHEEL_BASE_NAME="$(basename "${WHEEL}")" - echo " ${WHEEL_BASE_NAME}" - WHEEL_PATH="${DEST_DIR}/${WHEEL_BASE_NAME}" - done - - # Run test on install. - if [[ "${RUN_TEST}" == "1" || "${RUN_TEST_NIGHTLY}" == 1 ]]; then - echo - echo "Running test-on-install for $(python --version 2>&1) ..." - echo - - pip uninstall -y tensorflowjs || \ - echo "It appears that tensorflowjs is not installed." - - echo - echo "Installing tensorflowjs from wheel at path: ${WHEEL_PATH} ..." - echo - - TEST_ON_INSTALL_DIR="$(mktemp -d)" - - cp "${SCRIPTS_DIR}/test_pip_package.py" "${TEST_ON_INSTALL_DIR}" - if [[ "${RUN_TEST_NIGHTLY}" == 1 ]]; then - cp "${SCRIPTS_DIR}/test_nightly_pip_package.py" "${TEST_ON_INSTALL_DIR}" - fi - - pushd "${TEST_ON_INSTALL_DIR}" > /dev/null - - pip install "${WHEEL_PATH}[wizard]" - echo "Successfully installed ${WHEEL_PATH} for $(python --version 2>&1)." - echo - - python test_pip_package.py - - if [[ "${RUN_TEST_NIGHTLY}" == 1 ]]; then - python test_nightly_pip_package.py - fi - - popd > /dev/null - - rm -rf "${TEST_ON_INSTALL_DIR}" - - echo - echo "Test-on-install for $(python --version 2>&1) PASSED." - echo - echo "Your pip wheel for $(python --version 2>&1) is at:" - echo " ${WHEEL_PATH}" - fi - - popd > /dev/null - - deactivate - rm -rf "${TMP_VENV_DIR}" -done - -if [[ "${UPLOAD_TO_PROD_PYPI}" == 1 || "${UPLOAD_TO_TEST_PYPI}" == 1 ]]; then - if [[ "${UPLOAD_TO_PROD_PYPI}" == 1 ]]; then - UPLOAD_DEST="pypi-warehouse" - else - UPLOAD_DEST="test-warehouse" - fi - - pushd "${DEST_DIR}" > /dev/null - echo "Found wheel files to upload to ${UPLOAD_DEST}:" - ls ./*.whl - echo - - TO_UPLOAD=0 - if [[ "${CONFIRM_UPLOAD}" == 0 ]]; then - while true; do - read -r -p "Do you wish to proceed with the upload to ${UPLOAD_DEST}? (y/n): " yn - case $yn in - [Yy]* ) TO_UPLOAD=1; break;; - [Nn]* ) exit;; - * ) echo "Please answer y or n.";; - esac - done - else - TO_UPLOAD=1 - fi - - if [[ "${TO_UPLOAD}" == 1 ]]; then - echo "Proceeding with the upload ..." - echo - - # Create a virtualenv and install twine in it for uploading. - TMP_VENV_DIR="$(mktemp -d)" - virtualenv -p "${VENV_PYTHON_BIN}" "${TMP_VENV_DIR}" - source "${TMP_VENV_DIR}/bin/activate" - pip install twine - - twine upload -r "${UPLOAD_DEST}" ./*.whl - - deactivate - rm -rf "${TMP_VENV_DIR}" - fi - - popd > /dev/null -fi - -rm -rf "${TMP_DIR}" diff --git a/tfjs-master/tfjs-converter/python/extra-requirements.txt b/tfjs-master/tfjs-converter/python/extra-requirements.txt deleted file mode 100644 index 25f974647..000000000 --- a/tfjs-master/tfjs-converter/python/extra-requirements.txt +++ /dev/null @@ -1 +0,0 @@ -PyInquirer==1.0.3: wizard diff --git a/tfjs-master/tfjs-converter/python/requirements-dev.txt b/tfjs-master/tfjs-converter/python/requirements-dev.txt deleted file mode 100644 index adcb0732e..000000000 --- a/tfjs-master/tfjs-converter/python/requirements-dev.txt +++ /dev/null @@ -1,5 +0,0 @@ --r requirements.txt -PyInquirer==1.0.3 -pylint==2.5.0; python_version > '3.0' -setuptools==65.6.3 -debugpy==1.6.5 diff --git a/tfjs-master/tfjs-converter/python/requirements-dev_lock.txt b/tfjs-master/tfjs-converter/python/requirements-dev_lock.txt deleted file mode 100644 index f99ce9fce..000000000 --- a/tfjs-master/tfjs-converter/python/requirements-dev_lock.txt +++ /dev/null @@ -1,905 +0,0 @@ -# -# This file is autogenerated by pip-compile with Python 3.8 -# by the following command: -# -# bazel run //tfjs-converter/python:tensorflowjs_dev_deps_requirements.update -# -absl-py==1.3.0 \ - --hash=sha256:34995df9bd7a09b3b8749e230408f5a2a2dd7a68a0d33c12a3d0cb15a041a507 \ - --hash=sha256:463c38a08d2e4cef6c498b76ba5bd4858e4c6ef51da1a5a1f27139a022e20248 - # via - # chex - # optax - # orbax-checkpoint - # tensorboard - # tensorflow - # tensorflow-decision-forests -astroid==2.5 \ - --hash=sha256:87ae7f2398b8a0ae5638ddecf9987f081b756e0e9fc071aeebdca525671fc4dc \ - --hash=sha256:b31c92f545517dcc452f284bc9c044050862fbe6d93d2b3de4a215a6b384bf0d - # via pylint -astunparse==1.6.3 \ - --hash=sha256:5ad93a8456f0d084c3456d059fd9a92cce667963232cbf763eac3bc5b7940872 \ - --hash=sha256:c2652417f2c8b5bb325c885ae329bdf3f86424075c4fd1a128674bc6fba4b8e8 - # via tensorflow -cached-property==1.5.2 \ - --hash=sha256:9fa5755838eecbb2d234c3aa390bd80fbd3ac6b6869109bfc1b499f7bd89a130 \ - --hash=sha256:df4f613cf7ad9a588cc381aaf4a512d26265ecebd5eb9e1ba12f1319eb85a6a0 - # via orbax-checkpoint -cachetools==5.2.0 \ - --hash=sha256:6a94c6402995a99c3970cc7e4884bb60b4a8639938157eeed436098bf9831757 \ - --hash=sha256:f9f17d2aec496a9aa6b76f53e3b614c965223c061982d434d160f930c698a9db - # via google-auth -certifi==2022.12.7 \ - --hash=sha256:35824b4c3a97115964b408844d64aa14db1cc518f6562e8d7261699d1350a9e3 \ - --hash=sha256:4ad3232f5e926d6718ec31cfc1fcadfde020920e278684144551c91769c7bc18 - # via requests -charset-normalizer==2.1.1 \ - --hash=sha256:5a3d016c7c547f69d6f81fb0db9449ce888b418b5b9952cc5e6e66843e9dd845 \ - --hash=sha256:83e9a75d1911279afd89352c68b45348559d1fc0506b054b346651b5e7fee29f - # via requests -chex==0.1.5 \ - --hash=sha256:686858320f8f220c82a6c7eeb54dcdcaa4f3d7f66690dacd13a24baa1ee8299e \ - --hash=sha256:b3321184850d5fc29b2eca63087cdbdd83a1b3e4f33c1314ff8b3b8bd67abbca - # via optax -commonmark==0.9.1 \ - --hash=sha256:452f9dc859be7f06631ddcb328b6919c67984aca654e5fefb3914d54691aed60 \ - --hash=sha256:da2f38c92590f83de410ba1a3cbceafbc74fee9def35f9251ba9a971d6d66fd9 - # via rich -debugpy==1.6.5 \ - --hash=sha256:048368f121c08b00bbded161e8583817af5055982d2722450a69efe2051621c2 \ - --hash=sha256:0f9afcc8cad6424695f3356dc9a7406d5b18e37ee2e73f34792881a44b02cc50 \ - --hash=sha256:15bc5febe0edc79726517b1f8d57d7ac7c784567b5ba804aab8b1c9d07a57018 \ - --hash=sha256:17039e392d6f38388a68bd02c5f823b32a92142a851e96ba3ec52aeb1ce9d900 \ - --hash=sha256:286ae0c2def18ee0dc8a61fa76d51039ca8c11485b6ed3ef83e3efe8a23926ae \ - --hash=sha256:377391341c4b86f403d93e467da8e2d05c22b683f08f9af3e16d980165b06b90 \ - --hash=sha256:500dd4a9ff818f5c52dddb4a608c7de5371c2d7d905c505eb745556c579a9f11 \ - --hash=sha256:5e55e6c79e215239dd0794ee0bf655412b934735a58e9d705e5c544f596f1603 \ - --hash=sha256:62a06eb78378292ba6c427d861246574dc8b84471904973797b29dd33c7c2495 \ - --hash=sha256:696165f021a6a17da08163eaae84f3faf5d8be68fb78cd78488dd347e625279c \ - --hash=sha256:74e4eca42055759032e3f1909d1374ba1d729143e0c2729bb8cb5e8b5807c458 \ - --hash=sha256:7e84d9e4420122384cb2cc762a00b4e17cbf998022890f89b195ce178f78ff47 \ - --hash=sha256:8116e40a1cd0593bd2aba01d4d560ee08f018da8e8fbd4cbd24ff09b5f0e41ef \ - --hash=sha256:8f3fab217fe7e2acb2d90732af1a871947def4e2b6654945ba1ebd94bd0bea26 \ - --hash=sha256:947c686e8adb46726f3d5f19854f6aebf66c2edb91225643c7f44b40b064a235 \ - --hash=sha256:9984fc00ab372c97f63786c400107f54224663ea293daab7b365a5b821d26309 \ - --hash=sha256:9e809ef787802c808995e5b6ade714a25fa187f892b41a412d418a15a9c4a432 \ - --hash=sha256:b5a74ecebe5253344501d9b23f74459c46428b30437fa9254cfb8cb129943242 - # via -r tfjs-converter/python/requirements-dev.txt -dm-tree==0.1.7 \ - --hash=sha256:0f01743cc2247170e64798c6b4b31853717054bf9ceec47a1b1b8c2a4baf5792 \ - --hash=sha256:1379a02df36e2bbff9819ceafa55ccd436b15af398803f781f372f8ead7ed871 \ - --hash=sha256:1410fa2f2cc8dc7c01386f4e93ddeeb56765574ffafb632a9b6bd96496195b10 \ - --hash=sha256:20f24cad4decbf4c1f176a959d16e877c73df33b07d7d1f078a5b8abe72f79f8 \ - --hash=sha256:2a843608e078d1622ebb5e50962a8c718d3fa1ab9461b95a12395a803545b2f5 \ - --hash=sha256:30fec8aca5b92823c0e796a2f33b875b4dccd470b57e91e6c542405c5f77fd2a \ - --hash=sha256:3166304411d14c50a5da1c583e24d6069b44de0c9e06479cb36cdf048a466945 \ - --hash=sha256:3b00885c21267934a3d3c68660811d3f891c9539fd53712f5b2423c6d74bf1e6 \ - --hash=sha256:3ca0a58e219b7b0bc201fea4679971188d0a9028a2543c16803a84e8f8c7eb2c \ - --hash=sha256:3fae437135b6cbbdd51e96488a35e78c3617defa0b65265e7e8752d506f933fd \ - --hash=sha256:4992ac5c42af1d73042cd2d3af4e7892d3750e6c1bb8e5a4f81534aa6515f350 \ - --hash=sha256:51b9bdf1109b47cc22884b1919e6fe38edf28b5aa02e7c661bb760a0e7cf0157 \ - --hash=sha256:57edb6fbd88fcdd9908547cbf21045a9d663c0d9e5983dca7e6f9cf8b6584bb5 \ - --hash=sha256:7f1f3dca9d669f3c09654ff6d69cfafd86a7f967c3095405b2692ee8d8ef3cfd \ - --hash=sha256:7fa0740b7fbae2c3a43a3114a514891b5d6c383050828f36aa1816cf40f73a6a \ - --hash=sha256:91c6240e47c9d80dbd7de5a29a2ca663143717a72c613130ba8ac4354fa741a9 \ - --hash=sha256:98fce150ceebb0a818f0eace1616004031cfa5e3375f50599ad790ff52414ba9 \ - --hash=sha256:9edc1783a08d87c4e130781f55cbd904d6a564f7cce7dfb63f9ef3bee8e38209 \ - --hash=sha256:a085f500b295a6bf439c538e9058c7798ecb8c7d0dc916291f3d8d79d6124d17 \ - --hash=sha256:b4364fc9a5721a2b840ac8ea75b8f58b430bec9fdc8b99304d2aecb3cfe46b1b \ - --hash=sha256:d377bd621b485db42c4aeea0eabbd8f6274b89a9c338c2c1bf69a40c3b86a1fd \ - --hash=sha256:f3e2bd9b9c05d1a0039f7c128d8b055c8a05708ef569cdbbeec0a2946e425bd4 - # via chex -etils==1.3.0 \ - --hash=sha256:0a695ec45a982ae7c9deb437f1f251346d88b43ca59be67e961f61fe8bc8cae4 \ - --hash=sha256:809a92ff72f12149441492cf4d9a26b56a4741dffb4dfb9c4c7b7afe055c2d28 - # via orbax-checkpoint -flatbuffers==23.5.26 \ - --hash=sha256:9ea1144cac05ce5d86e2859f431c6cd5e66cd9c78c558317c7955fb8d4c78d89 \ - --hash=sha256:c0ff356da363087b915fde4b8b45bdda73432fc17cddb3c8157472eab1422ad1 - # via tensorflow -flax==0.7.2 \ - --hash=sha256:261c7b93e6d15ad80e2cedd2edb797d41b0b3c7805a54254de72a2366dc80148 \ - --hash=sha256:7f023ece0b8b0d03019d2841dbe780e33b81ec42268bdc3e5d24c8fb0582fd7b - # via -r tfjs-converter/python/requirements.txt -gast==0.4.0 \ - --hash=sha256:40feb7b8b8434785585ab224d1568b857edb18297e5a3047f1ba012bc83b42c1 \ - --hash=sha256:b7adcdd5adbebf1adf17378da5ba3f543684dbec47b1cda1f3997e573cd542c4 - # via tensorflow -google-auth==2.15.0 \ - --hash=sha256:6897b93556d8d807ad70701bb89f000183aea366ca7ed94680828b37437a4994 \ - --hash=sha256:72f12a6cfc968d754d7bdab369c5c5c16032106e52d32c6dfd8484e4c01a6d1f - # via - # google-auth-oauthlib - # tensorboard -google-auth-oauthlib==1.0.0 \ - --hash=sha256:95880ca704928c300f48194d1770cf5b1462835b6e49db61445a520f793fd5fb \ - --hash=sha256:e375064964820b47221a7e1b7ee1fd77051b6323c3f9e3e19785f78ab67ecfc5 - # via tensorboard -google-pasta==0.2.0 \ - --hash=sha256:4612951da876b1a10fe3960d7226f0c7682cf901e16ac06e473b267a5afa8954 \ - --hash=sha256:b32482794a366b5366a32c92a9a9201b107821889935a02b3e51f6b432ea84ed \ - --hash=sha256:c9f2c8dfc8f96d0d5808299920721be30c9eec37f2389f28904f454565c8a16e - # via tensorflow -grpcio==1.51.1 \ - --hash=sha256:094e64236253590d9d4075665c77b329d707b6fca864dd62b144255e199b4f87 \ - --hash=sha256:0dc5354e38e5adf2498312f7241b14c7ce3484eefa0082db4297189dcbe272e6 \ - --hash=sha256:0e1a9e1b4a23808f1132aa35f968cd8e659f60af3ffd6fb00bcf9a65e7db279f \ - --hash=sha256:0fb93051331acbb75b49a2a0fd9239c6ba9528f6bdc1dd400ad1cb66cf864292 \ - --hash=sha256:16c71740640ba3a882f50b01bf58154681d44b51f09a5728180a8fdc66c67bd5 \ - --hash=sha256:172405ca6bdfedd6054c74c62085946e45ad4d9cec9f3c42b4c9a02546c4c7e9 \ - --hash=sha256:17ec9b13cec4a286b9e606b48191e560ca2f3bbdf3986f91e480a95d1582e1a7 \ - --hash=sha256:22b011674090594f1f3245960ced7386f6af35485a38901f8afee8ad01541dbd \ - --hash=sha256:24ac1154c4b2ab4a0c5326a76161547e70664cd2c39ba75f00fc8a2170964ea2 \ - --hash=sha256:257478300735ce3c98d65a930bbda3db172bd4e00968ba743e6a1154ea6edf10 \ - --hash=sha256:29cb97d41a4ead83b7bcad23bdb25bdd170b1e2cba16db6d3acbb090bc2de43c \ - --hash=sha256:2b170eaf51518275c9b6b22ccb59450537c5a8555326fd96ff7391b5dd75303c \ - --hash=sha256:31bb6bc7ff145e2771c9baf612f4b9ebbc9605ccdc5f3ff3d5553de7fc0e0d79 \ - --hash=sha256:3c2b3842dcf870912da31a503454a33a697392f60c5e2697c91d133130c2c85d \ - --hash=sha256:3f9b0023c2c92bebd1be72cdfca23004ea748be1813a66d684d49d67d836adde \ - --hash=sha256:471d39d3370ca923a316d49c8aac66356cea708a11e647e3bdc3d0b5de4f0a40 \ - --hash=sha256:49d680356a975d9c66a678eb2dde192d5dc427a7994fb977363634e781614f7c \ - --hash=sha256:4c4423ea38a7825b8fed8934d6d9aeebdf646c97e3c608c3b0bcf23616f33877 \ - --hash=sha256:506b9b7a4cede87d7219bfb31014d7b471cfc77157da9e820a737ec1ea4b0663 \ - --hash=sha256:538d981818e49b6ed1e9c8d5e5adf29f71c4e334e7d459bf47e9b7abb3c30e09 \ - --hash=sha256:59dffade859f157bcc55243714d57b286da6ae16469bf1ac0614d281b5f49b67 \ - --hash=sha256:5a6ebcdef0ef12005d56d38be30f5156d1cb3373b52e96f147f4a24b0ddb3a9d \ - --hash=sha256:5dca372268c6ab6372d37d6b9f9343e7e5b4bc09779f819f9470cd88b2ece3c3 \ - --hash=sha256:6df3b63538c362312bc5fa95fb965069c65c3ea91d7ce78ad9c47cab57226f54 \ - --hash=sha256:6f0b89967ee11f2b654c23b27086d88ad7bf08c0b3c2a280362f28c3698b2896 \ - --hash=sha256:75e29a90dc319f0ad4d87ba6d20083615a00d8276b51512e04ad7452b5c23b04 \ - --hash=sha256:7942b32a291421460d6a07883033e392167d30724aa84987e6956cd15f1a21b9 \ - --hash=sha256:9235dcd5144a83f9ca6f431bd0eccc46b90e2c22fe27b7f7d77cabb2fb515595 \ - --hash=sha256:97d67983189e2e45550eac194d6234fc38b8c3b5396c153821f2d906ed46e0ce \ - --hash=sha256:9ff42c5620b4e4530609e11afefa4a62ca91fa0abb045a8957e509ef84e54d30 \ - --hash=sha256:a8a0b77e992c64880e6efbe0086fe54dfc0bbd56f72a92d9e48264dcd2a3db98 \ - --hash=sha256:aacb54f7789ede5cbf1d007637f792d3e87f1c9841f57dd51abf89337d1b8472 \ - --hash=sha256:bc59f7ba87972ab236f8669d8ca7400f02a0eadf273ca00e02af64d588046f02 \ - --hash=sha256:cc2bece1737b44d878cc1510ea04469a8073dbbcdd762175168937ae4742dfb3 \ - --hash=sha256:cd3baccea2bc5c38aeb14e5b00167bd4e2373a373a5e4d8d850bd193edad150c \ - --hash=sha256:dad6533411d033b77f5369eafe87af8583178efd4039c41d7515d3336c53b4f1 \ - --hash=sha256:e223a9793522680beae44671b9ed8f6d25bbe5ddf8887e66aebad5e0686049ef \ - --hash=sha256:e473525c28251558337b5c1ad3fa969511e42304524a4e404065e165b084c9e4 \ - --hash=sha256:e4ef09f8997c4be5f3504cefa6b5c6cc3cf648274ce3cede84d4342a35d76db6 \ - --hash=sha256:e6dfc2b6567b1c261739b43d9c59d201c1b89e017afd9e684d85aa7a186c9f7a \ - --hash=sha256:eacad297ea60c72dd280d3353d93fb1dcca952ec11de6bb3c49d12a572ba31dd \ - --hash=sha256:f1158bccbb919da42544a4d3af5d9296a3358539ffa01018307337365a9a0c64 \ - --hash=sha256:f1fec3abaf274cdb85bf3878167cfde5ad4a4d97c68421afda95174de85ba813 \ - --hash=sha256:f96ace1540223f26fbe7c4ebbf8a98e3929a6aa0290c8033d12526847b291c0f \ - --hash=sha256:fbdbe9a849854fe484c00823f45b7baab159bdd4a46075302281998cb8719df5 - # via - # tensorboard - # tensorflow -h5py==3.7.0 \ - --hash=sha256:03d64fb86bb86b978928bad923b64419a23e836499ec6363e305ad28afd9d287 \ - --hash=sha256:04e2e1e2fc51b8873e972a08d2f89625ef999b1f2d276199011af57bb9fc7851 \ - --hash=sha256:0798a9c0ff45f17d0192e4d7114d734cac9f8b2b2c76dd1d923c4d0923f27bb6 \ - --hash=sha256:0a047fddbe6951bce40e9cde63373c838a978c5e05a011a682db9ba6334b8e85 \ - --hash=sha256:0d8de8cb619fc597da7cf8cdcbf3b7ff8c5f6db836568afc7dc16d21f59b2b49 \ - --hash=sha256:1fcb11a2dc8eb7ddcae08afd8fae02ba10467753a857fa07a404d700a93f3d53 \ - --hash=sha256:3fcf37884383c5da64846ab510190720027dca0768def34dd8dcb659dbe5cbf3 \ - --hash=sha256:43fed4d13743cf02798a9a03a360a88e589d81285e72b83f47d37bb64ed44881 \ - --hash=sha256:63beb8b7b47d0896c50de6efb9a1eaa81dbe211f3767e7dd7db159cea51ba37a \ - --hash=sha256:6776d896fb90c5938de8acb925e057e2f9f28755f67ec3edcbc8344832616c38 \ - --hash=sha256:9e2ad2aa000f5b1e73b5dfe22f358ca46bf1a2b6ca394d9659874d7fc251731a \ - --hash=sha256:9e7535df5ee3dc3e5d1f408fdfc0b33b46bc9b34db82743c82cd674d8239b9ad \ - --hash=sha256:a9351d729ea754db36d175098361b920573fdad334125f86ac1dd3a083355e20 \ - --hash=sha256:c038399ce09a58ff8d89ec3e62f00aa7cb82d14f34e24735b920e2a811a3a426 \ - --hash=sha256:d77af42cb751ad6cc44f11bae73075a07429a5cf2094dfde2b1e716e059b3911 \ - --hash=sha256:e5b7820b75f9519499d76cc708e27242ccfdd9dfb511d6deb98701961d0445aa \ - --hash=sha256:ed43e2cc4f511756fd664fb45d6b66c3cbed4e3bd0f70e29c37809b2ae013c44 \ - --hash=sha256:f084bbe816907dfe59006756f8f2d16d352faff2d107f4ffeb1d8de126fc5dc7 \ - --hash=sha256:f514b24cacdd983e61f8d371edac8c1b780c279d0acb8485639e97339c866073 \ - --hash=sha256:f73307c876af49aa869ec5df1818e9bb0bdcfcf8a5ba773cc45a4fba5a286a5c - # via tensorflow -idna==3.4 \ - --hash=sha256:814f528e8dead7d329833b91c5faa87d60bf71824cd12a7530b5526063d02cb4 \ - --hash=sha256:90b77e79eaa3eba6de819a0c442c0b4ceefc341a7a2ab77d7562bf49f425c5c2 - # via requests -importlib-metadata==5.1.0 \ - --hash=sha256:d5059f9f1e8e41f80e9c56c2ee58811450c31984dfa625329ffd7c0dad88a73b \ - --hash=sha256:d84d17e21670ec07990e1044a99efe8d615d860fd176fc29ef5c306068fda313 - # via - # jax - # markdown -importlib-resources==5.10.1 \ - --hash=sha256:32bb095bda29741f6ef0e5278c42df98d135391bee5f932841efc0041f748dc3 \ - --hash=sha256:c09b067d82e72c66f4f8eb12332f5efbebc9b007c0b6c40818108c9870adc363 - # via - # -r tfjs-converter/python/requirements.txt - # orbax-checkpoint -isort==4.3.21 \ - --hash=sha256:54da7e92468955c4fceacd0c86bd0ec997b0e1ee80d97f67c35a78b719dccab1 \ - --hash=sha256:6e811fcb295968434526407adb8796944f1988c5b65e8139058f2014cbe100fd - # via pylint -jax==0.4.13 \ - --hash=sha256:03bfe6749dfe647f16f15f6616638adae6c4a7ca7167c75c21961ecfd3a3baaa - # via - # -r tfjs-converter/python/requirements.txt - # chex - # flax - # optax - # orbax-checkpoint -jaxlib==0.4.13 \ - --hash=sha256:19ae4c316b17a49342432c69f7f89f190b975333f3f9e9e175f686a651bc7347 \ - --hash=sha256:411334d903df07dc1ace8d52fc53c17f6bc1d55aff7f6e0e5cf61ec149f758a0 \ - --hash=sha256:49690fcdd26560515fd15399fc3a44777e0bfc5db5c48fe76ff7bc7228e8b2fb \ - --hash=sha256:522635d5e159401a386c79f1236c218c1f68fbb4ca6648115c3ad3c2c3f518ab \ - --hash=sha256:532ebc4fb11386282ad63b83941d4557f4038c1144acf026f1f8565f64c7e9c0 \ - --hash=sha256:8000c0d15c107328e8f7b7b3ac91dd822f5c287a80231882b620503ed141fa89 \ - --hash=sha256:839173b2e9593f5e9a6d3c42852cd15070fe80a939246efbb5cf40eec815de89 \ - --hash=sha256:a259bb35429bfbd3b76e43019dfc8f7d6ea94bb217400b78f7d0824ce07a58ac \ - --hash=sha256:b5c0a9737efd95fe18fd7715ce30dfce476546705ea8934aad6731777a9631a5 \ - --hash=sha256:bebb4cf001f180dc431f9604daf930c2d9cc778e4dda26f401ac939b7bac912e \ - --hash=sha256:c230ef85712e608d0f048869766a5a63afeb2e72309943db0df9f959ab17307f \ - --hash=sha256:d19c05c15f962e098d49b45e2758aacf19330d192ec5395f9ef136f62db90edc \ - --hash=sha256:ea1bc9811ef7d73a15e3213115e88fe7f5d14b59d95027bea9fccc98e5a14af8 \ - --hash=sha256:f4e9e34e5d8a6556f62fead14aee0b1614c2c6296f0078d8e6139d6aff109649 \ - --hash=sha256:fde66a93e9be89d99e5792f677ed8e319667d6b2396865b1c52c1312844c47f9 - # via - # -r tfjs-converter/python/requirements.txt - # chex - # optax - # orbax-checkpoint -keras==2.13.1 \ - --hash=sha256:5ce5f706f779fa7330e63632f327b75ce38144a120376b2ae1917c00fa6136af \ - --hash=sha256:5df12cc241a015a11b65ddb452c0eeb2744fce21d9b54ba48db87492568ccc68 - # via tensorflow -lazy-object-proxy==1.8.0 \ - --hash=sha256:0c1c7c0433154bb7c54185714c6929acc0ba04ee1b167314a779b9025517eada \ - --hash=sha256:14010b49a2f56ec4943b6cf925f597b534ee2fe1f0738c84b3bce0c1a11ff10d \ - --hash=sha256:4e2d9f764f1befd8bdc97673261b8bb888764dfdbd7a4d8f55e4fbcabb8c3fb7 \ - --hash=sha256:4fd031589121ad46e293629b39604031d354043bb5cdf83da4e93c2d7f3389fe \ - --hash=sha256:5b51d6f3bfeb289dfd4e95de2ecd464cd51982fe6f00e2be1d0bf94864d58acd \ - --hash=sha256:6850e4aeca6d0df35bb06e05c8b934ff7c533734eb51d0ceb2d63696f1e6030c \ - --hash=sha256:6f593f26c470a379cf7f5bc6db6b5f1722353e7bf937b8d0d0b3fba911998858 \ - --hash=sha256:71d9ae8a82203511a6f60ca5a1b9f8ad201cac0fc75038b2dc5fa519589c9288 \ - --hash=sha256:7e1561626c49cb394268edd00501b289053a652ed762c58e1081224c8d881cec \ - --hash=sha256:8f6ce2118a90efa7f62dd38c7dbfffd42f468b180287b748626293bf12ed468f \ - --hash=sha256:ae032743794fba4d171b5b67310d69176287b5bf82a21f588282406a79498891 \ - --hash=sha256:afcaa24e48bb23b3be31e329deb3f1858f1f1df86aea3d70cb5c8578bfe5261c \ - --hash=sha256:b70d6e7a332eb0217e7872a73926ad4fdc14f846e85ad6749ad111084e76df25 \ - --hash=sha256:c219a00245af0f6fa4e95901ed28044544f50152840c5b6a3e7b2568db34d156 \ - --hash=sha256:ce58b2b3734c73e68f0e30e4e725264d4d6be95818ec0a0be4bb6bf9a7e79aa8 \ - --hash=sha256:d176f392dbbdaacccf15919c77f526edf11a34aece58b55ab58539807b85436f \ - --hash=sha256:e20bfa6db17a39c706d24f82df8352488d2943a3b7ce7d4c22579cb89ca8896e \ - --hash=sha256:eac3a9a5ef13b332c059772fd40b4b1c3d45a3a2b05e33a361dee48e54a4dad0 \ - --hash=sha256:eb329f8d8145379bf5dbe722182410fe8863d186e51bf034d2075eb8d85ee25b - # via astroid -libclang==14.0.6 \ - --hash=sha256:206d2789e4450a37d054e63b70451a6fc1873466397443fa13de2b3d4adb2796 \ - --hash=sha256:2e4303e04517fcd11173cb2e51a7070eed71e16ef45d4e26a82c5e881cac3d27 \ - --hash=sha256:5dd3c6fca1b007d308a4114afa8e4e9d32f32b2572520701d45fcc626ac5cd6c \ - --hash=sha256:7b06fc76bd1e67c8b04b5719bf2ac5d6a323b289b245dfa9e468561d99538188 \ - --hash=sha256:8791cf3c3b087c373a6d61e9199da7a541da922c9ddcfed1122090586b996d6e \ - --hash=sha256:9052a8284d8846984f6fa826b1d7460a66d3b23a486d782633b42b6e3b418789 \ - --hash=sha256:cfb0e892ebb5dff6bd498ab5778adb8581f26a00fd8347b3c76c989fe2fd04f7 \ - --hash=sha256:e2add1703129b2abe066fb1890afa880870a89fd6ab4ec5d2a7a8dc8d271677e \ - --hash=sha256:e429853939423f276a25140b0b702442d7da9a09e001c05e48df888336947614 \ - --hash=sha256:ea03c12675151837660cdd5dce65bd89320896ac3421efef43a36678f113ce95 - # via tensorflow -markdown==3.4.1 \ - --hash=sha256:08fb8465cffd03d10b9dd34a5c3fea908e20391a2a90b88d66362cb05beed186 \ - --hash=sha256:3b809086bb6efad416156e00a0da66fe47618a5d6918dd688f53f40c8e4cfeff - # via tensorboard -markupsafe==2.1.1 \ - --hash=sha256:0212a68688482dc52b2d45013df70d169f542b7394fc744c02a57374a4207003 \ - --hash=sha256:089cf3dbf0cd6c100f02945abeb18484bd1ee57a079aefd52cffd17fba910b88 \ - --hash=sha256:10c1bfff05d95783da83491be968e8fe789263689c02724e0c691933c52994f5 \ - --hash=sha256:33b74d289bd2f5e527beadcaa3f401e0df0a89927c1559c8566c066fa4248ab7 \ - --hash=sha256:3799351e2336dc91ea70b034983ee71cf2f9533cdff7c14c90ea126bfd95d65a \ - --hash=sha256:3ce11ee3f23f79dbd06fb3d63e2f6af7b12db1d46932fe7bd8afa259a5996603 \ - --hash=sha256:421be9fbf0ffe9ffd7a378aafebbf6f4602d564d34be190fc19a193232fd12b1 \ - --hash=sha256:43093fb83d8343aac0b1baa75516da6092f58f41200907ef92448ecab8825135 \ - --hash=sha256:46d00d6cfecdde84d40e572d63735ef81423ad31184100411e6e3388d405e247 \ - --hash=sha256:4a33dea2b688b3190ee12bd7cfa29d39c9ed176bda40bfa11099a3ce5d3a7ac6 \ - --hash=sha256:4b9fe39a2ccc108a4accc2676e77da025ce383c108593d65cc909add5c3bd601 \ - --hash=sha256:56442863ed2b06d19c37f94d999035e15ee982988920e12a5b4ba29b62ad1f77 \ - --hash=sha256:671cd1187ed5e62818414afe79ed29da836dde67166a9fac6d435873c44fdd02 \ - --hash=sha256:694deca8d702d5db21ec83983ce0bb4b26a578e71fbdbd4fdcd387daa90e4d5e \ - --hash=sha256:6a074d34ee7a5ce3effbc526b7083ec9731bb3cbf921bbe1d3005d4d2bdb3a63 \ - --hash=sha256:6d0072fea50feec76a4c418096652f2c3238eaa014b2f94aeb1d56a66b41403f \ - --hash=sha256:6fbf47b5d3728c6aea2abb0589b5d30459e369baa772e0f37a0320185e87c980 \ - --hash=sha256:7f91197cc9e48f989d12e4e6fbc46495c446636dfc81b9ccf50bb0ec74b91d4b \ - --hash=sha256:86b1f75c4e7c2ac2ccdaec2b9022845dbb81880ca318bb7a0a01fbf7813e3812 \ - --hash=sha256:8dc1c72a69aa7e082593c4a203dcf94ddb74bb5c8a731e4e1eb68d031e8498ff \ - --hash=sha256:8e3dcf21f367459434c18e71b2a9532d96547aef8a871872a5bd69a715c15f96 \ - --hash=sha256:8e576a51ad59e4bfaac456023a78f6b5e6e7651dcd383bcc3e18d06f9b55d6d1 \ - --hash=sha256:96e37a3dc86e80bf81758c152fe66dbf60ed5eca3d26305edf01892257049925 \ - --hash=sha256:97a68e6ada378df82bc9f16b800ab77cbf4b2fada0081794318520138c088e4a \ - --hash=sha256:99a2a507ed3ac881b975a2976d59f38c19386d128e7a9a18b7df6fff1fd4c1d6 \ - --hash=sha256:a49907dd8420c5685cfa064a1335b6754b74541bbb3706c259c02ed65b644b3e \ - --hash=sha256:b09bf97215625a311f669476f44b8b318b075847b49316d3e28c08e41a7a573f \ - --hash=sha256:b7bd98b796e2b6553da7225aeb61f447f80a1ca64f41d83612e6139ca5213aa4 \ - --hash=sha256:b87db4360013327109564f0e591bd2a3b318547bcef31b468a92ee504d07ae4f \ - --hash=sha256:bcb3ed405ed3222f9904899563d6fc492ff75cce56cba05e32eff40e6acbeaa3 \ - --hash=sha256:d4306c36ca495956b6d568d276ac11fdd9c30a36f1b6eb928070dc5360b22e1c \ - --hash=sha256:d5ee4f386140395a2c818d149221149c54849dfcfcb9f1debfe07a8b8bd63f9a \ - --hash=sha256:dda30ba7e87fbbb7eab1ec9f58678558fd9a6b8b853530e176eabd064da81417 \ - --hash=sha256:e04e26803c9c3851c931eac40c695602c6295b8d432cbe78609649ad9bd2da8a \ - --hash=sha256:e1c0b87e09fa55a220f058d1d49d3fb8df88fbfab58558f1198e08c1e1de842a \ - --hash=sha256:e72591e9ecd94d7feb70c1cbd7be7b3ebea3f548870aa91e2732960fa4d57a37 \ - --hash=sha256:e8c843bbcda3a2f1e3c2ab25913c80a3c5376cd00c6e8c4a86a89a28c8dc5452 \ - --hash=sha256:efc1913fd2ca4f334418481c7e595c00aad186563bbc1ec76067848c7ca0a933 \ - --hash=sha256:f121a1420d4e173a5d96e47e9a0c0dcff965afdf1626d28de1460815f7c4ee7a \ - --hash=sha256:fc7b548b17d238737688817ab67deebb30e8073c95749d55538ed473130ec0c7 - # via werkzeug -mccabe==0.6.1 \ - --hash=sha256:ab8a6258860da4b6677da4bd2fe5dc2c659cff31b3ee4f7f5d64e79735b80d42 \ - --hash=sha256:dd8d182285a0fe56bace7f45b5e7d1a6ebcbf524e8f3bd87eb0f125271b8831f - # via pylint -ml-dtypes==0.2.0 \ - --hash=sha256:022d5a4ee6be14569c2a9d1549e16f1ec87ca949681d0dca59995445d5fcdd5b \ - --hash=sha256:1749b60348da71fd3c2ab303fdbc1965958dc50775ead41f5669c932a341cafd \ - --hash=sha256:32107e7fa9f62db9a5281de923861325211dfff87bd23faefb27b303314635ab \ - --hash=sha256:35b984cddbe8173b545a0e3334fe56ea1a5c3eb67c507f60d0cfde1d3fa8f8c2 \ - --hash=sha256:36d28b8861a8931695e5a31176cad5ae85f6504906650dea5598fbec06c94606 \ - --hash=sha256:50845af3e9a601810751b55091dee6c2562403fa1cb4e0123675cf3a4fc2c17a \ - --hash=sha256:6488eb642acaaf08d8020f6de0a38acee7ac324c1e6e92ee0c0fea42422cb797 \ - --hash=sha256:75015818a7fccf99a5e8ed18720cb430f3e71a8838388840f4cdf225c036c983 \ - --hash=sha256:80d304c836d73f10605c58ccf7789c171cc229bfb678748adfb7cea2510dfd0e \ - --hash=sha256:832a019a1b6db5c4422032ca9940a990fa104eee420f643713241b3a518977fa \ - --hash=sha256:8faaf0897942c8253dd126662776ba45f0a5861968cf0f06d6d465f8a7bc298a \ - --hash=sha256:bc29a0524ef5e23a7fbb8d881bdecabeb3fc1d19d9db61785d077a86cb94fab2 \ - --hash=sha256:df6a76e1c8adf484feb138ed323f9f40a7b6c21788f120f7c78bec20ac37ee81 \ - --hash=sha256:e70047ec2c83eaee01afdfdabee2c5b0c133804d90d0f7db4dd903360fcc537c \ - --hash=sha256:e85ba8e24cf48d456e564688e981cf379d4c8e644db0a2f719b78de281bac2ca \ - --hash=sha256:f00c71c8c63e03aff313bc6a7aeaac9a4f1483a921a6ffefa6d4404efd1af3d0 \ - --hash=sha256:f08c391c2794f2aad358e6f4c70785a9a7b1df980ef4c232b3ccd4f6fe39f719 - # via - # jax - # jaxlib -msgpack==1.0.4 \ - --hash=sha256:002b5c72b6cd9b4bafd790f364b8480e859b4712e91f43014fe01e4f957b8467 \ - --hash=sha256:0a68d3ac0104e2d3510de90a1091720157c319ceeb90d74f7b5295a6bee51bae \ - --hash=sha256:0df96d6eaf45ceca04b3f3b4b111b86b33785683d682c655063ef8057d61fd92 \ - --hash=sha256:0dfe3947db5fb9ce52aaea6ca28112a170db9eae75adf9339a1aec434dc954ef \ - --hash=sha256:0e3590f9fb9f7fbc36df366267870e77269c03172d086fa76bb4eba8b2b46624 \ - --hash=sha256:11184bc7e56fd74c00ead4f9cc9a3091d62ecb96e97653add7a879a14b003227 \ - --hash=sha256:112b0f93202d7c0fef0b7810d465fde23c746a2d482e1e2de2aafd2ce1492c88 \ - --hash=sha256:1276e8f34e139aeff1c77a3cefb295598b504ac5314d32c8c3d54d24fadb94c9 \ - --hash=sha256:1576bd97527a93c44fa856770197dec00d223b0b9f36ef03f65bac60197cedf8 \ - --hash=sha256:1e91d641d2bfe91ba4c52039adc5bccf27c335356055825c7f88742c8bb900dd \ - --hash=sha256:26b8feaca40a90cbe031b03d82b2898bf560027160d3eae1423f4a67654ec5d6 \ - --hash=sha256:2999623886c5c02deefe156e8f869c3b0aaeba14bfc50aa2486a0415178fce55 \ - --hash=sha256:2a2df1b55a78eb5f5b7d2a4bb221cd8363913830145fad05374a80bf0877cb1e \ - --hash=sha256:2bb8cdf50dd623392fa75525cce44a65a12a00c98e1e37bf0fb08ddce2ff60d2 \ - --hash=sha256:2cc5ca2712ac0003bcb625c96368fd08a0f86bbc1a5578802512d87bc592fe44 \ - --hash=sha256:35bc0faa494b0f1d851fd29129b2575b2e26d41d177caacd4206d81502d4c6a6 \ - --hash=sha256:3c11a48cf5e59026ad7cb0dc29e29a01b5a66a3e333dc11c04f7e991fc5510a9 \ - --hash=sha256:449e57cc1ff18d3b444eb554e44613cffcccb32805d16726a5494038c3b93dab \ - --hash=sha256:462497af5fd4e0edbb1559c352ad84f6c577ffbbb708566a0abaaa84acd9f3ae \ - --hash=sha256:4733359808c56d5d7756628736061c432ded018e7a1dff2d35a02439043321aa \ - --hash=sha256:48f5d88c99f64c456413d74a975bd605a9b0526293218a3b77220a2c15458ba9 \ - --hash=sha256:49565b0e3d7896d9ea71d9095df15b7f75a035c49be733051c34762ca95bbf7e \ - --hash=sha256:4ab251d229d10498e9a2f3b1e68ef64cb393394ec477e3370c457f9430ce9250 \ - --hash=sha256:4d5834a2a48965a349da1c5a79760d94a1a0172fbb5ab6b5b33cbf8447e109ce \ - --hash=sha256:4dea20515f660aa6b7e964433b1808d098dcfcabbebeaaad240d11f909298075 \ - --hash=sha256:545e3cf0cf74f3e48b470f68ed19551ae6f9722814ea969305794645da091236 \ - --hash=sha256:63e29d6e8c9ca22b21846234913c3466b7e4ee6e422f205a2988083de3b08cae \ - --hash=sha256:6916c78f33602ecf0509cc40379271ba0f9ab572b066bd4bdafd7434dee4bc6e \ - --hash=sha256:6a4192b1ab40f8dca3f2877b70e63799d95c62c068c84dc028b40a6cb03ccd0f \ - --hash=sha256:6c9566f2c39ccced0a38d37c26cc3570983b97833c365a6044edef3574a00c08 \ - --hash=sha256:76ee788122de3a68a02ed6f3a16bbcd97bc7c2e39bd4d94be2f1821e7c4a64e6 \ - --hash=sha256:7760f85956c415578c17edb39eed99f9181a48375b0d4a94076d84148cf67b2d \ - --hash=sha256:77ccd2af37f3db0ea59fb280fa2165bf1b096510ba9fe0cc2bf8fa92a22fdb43 \ - --hash=sha256:81fc7ba725464651190b196f3cd848e8553d4d510114a954681fd0b9c479d7e1 \ - --hash=sha256:85f279d88d8e833ec015650fd15ae5eddce0791e1e8a59165318f371158efec6 \ - --hash=sha256:9667bdfdf523c40d2511f0e98a6c9d3603be6b371ae9a238b7ef2dc4e7a427b0 \ - --hash=sha256:a75dfb03f8b06f4ab093dafe3ddcc2d633259e6c3f74bb1b01996f5d8aa5868c \ - --hash=sha256:ac5bd7901487c4a1dd51a8c58f2632b15d838d07ceedaa5e4c080f7190925bff \ - --hash=sha256:aca0f1644d6b5a73eb3e74d4d64d5d8c6c3d577e753a04c9e9c87d07692c58db \ - --hash=sha256:b17be2478b622939e39b816e0aa8242611cc8d3583d1cd8ec31b249f04623243 \ - --hash=sha256:c1683841cd4fa45ac427c18854c3ec3cd9b681694caf5bff04edb9387602d661 \ - --hash=sha256:c23080fdeec4716aede32b4e0ef7e213c7b1093eede9ee010949f2a418ced6ba \ - --hash=sha256:d5b5b962221fa2c5d3a7f8133f9abffc114fe218eb4365e40f17732ade576c8e \ - --hash=sha256:d603de2b8d2ea3f3bcb2efe286849aa7a81531abc52d8454da12f46235092bcb \ - --hash=sha256:e83f80a7fec1a62cf4e6c9a660e39c7f878f603737a0cdac8c13131d11d97f52 \ - --hash=sha256:eb514ad14edf07a1dbe63761fd30f89ae79b42625731e1ccf5e1f1092950eaa6 \ - --hash=sha256:eba96145051ccec0ec86611fe9cf693ce55f2a3ce89c06ed307de0e085730ec1 \ - --hash=sha256:ed6f7b854a823ea44cf94919ba3f727e230da29feb4a99711433f25800cf747f \ - --hash=sha256:f0029245c51fd9473dc1aede1160b0a29f4a912e6b1dd353fa6d317085b219da \ - --hash=sha256:f5d869c18f030202eb412f08b28d2afeea553d6613aee89e200d7aca7ef01f5f \ - --hash=sha256:fb62ea4b62bfcb0b380d5680f9a4b3f9a2d166d9394e9bbd9666c0ee09a3645c \ - --hash=sha256:fcb8a47f43acc113e24e910399376f7277cf8508b27e5b88499f053de6b115a8 - # via - # flax - # orbax-checkpoint -nest-asyncio==1.5.7 \ - --hash=sha256:5301c82941b550b3123a1ea772ba9a1c80bad3a182be8c1a5ae6ad3be57a9657 \ - --hash=sha256:6a80f7b98f24d9083ed24608977c09dd608d83f91cccc24c9d2cba6d10e01c10 - # via orbax-checkpoint -numpy==1.23.5 \ - --hash=sha256:01dd17cbb340bf0fc23981e52e1d18a9d4050792e8fb8363cecbf066a84b827d \ - --hash=sha256:06005a2ef6014e9956c09ba07654f9837d9e26696a0470e42beedadb78c11b07 \ - --hash=sha256:09b7847f7e83ca37c6e627682f145856de331049013853f344f37b0c9690e3df \ - --hash=sha256:0aaee12d8883552fadfc41e96b4c82ee7d794949e2a7c3b3a7201e968c7ecab9 \ - --hash=sha256:0cbe9848fad08baf71de1a39e12d1b6310f1d5b2d0ea4de051058e6e1076852d \ - --hash=sha256:1b1766d6f397c18153d40015ddfc79ddb715cabadc04d2d228d4e5a8bc4ded1a \ - --hash=sha256:33161613d2269025873025b33e879825ec7b1d831317e68f4f2f0f84ed14c719 \ - --hash=sha256:5039f55555e1eab31124a5768898c9e22c25a65c1e0037f4d7c495a45778c9f2 \ - --hash=sha256:522e26bbf6377e4d76403826ed689c295b0b238f46c28a7251ab94716da0b280 \ - --hash=sha256:56e454c7833e94ec9769fa0f86e6ff8e42ee38ce0ce1fa4cbb747ea7e06d56aa \ - --hash=sha256:58f545efd1108e647604a1b5aa809591ccd2540f468a880bedb97247e72db387 \ - --hash=sha256:5e05b1c973a9f858c74367553e236f287e749465f773328c8ef31abe18f691e1 \ - --hash=sha256:7903ba8ab592b82014713c491f6c5d3a1cde5b4a3bf116404e08f5b52f6daf43 \ - --hash=sha256:8969bfd28e85c81f3f94eb4a66bc2cf1dbdc5c18efc320af34bffc54d6b1e38f \ - --hash=sha256:92c8c1e89a1f5028a4c6d9e3ccbe311b6ba53694811269b992c0b224269e2398 \ - --hash=sha256:9c88793f78fca17da0145455f0d7826bcb9f37da4764af27ac945488116efe63 \ - --hash=sha256:a7ac231a08bb37f852849bbb387a20a57574a97cfc7b6cabb488a4fc8be176de \ - --hash=sha256:abdde9f795cf292fb9651ed48185503a2ff29be87770c3b8e2a14b0cd7aa16f8 \ - --hash=sha256:af1da88f6bc3d2338ebbf0e22fe487821ea4d8e89053e25fa59d1d79786e7481 \ - --hash=sha256:b2a9ab7c279c91974f756c84c365a669a887efa287365a8e2c418f8b3ba73fb0 \ - --hash=sha256:bf837dc63ba5c06dc8797c398db1e223a466c7ece27a1f7b5232ba3466aafe3d \ - --hash=sha256:ca51fcfcc5f9354c45f400059e88bc09215fb71a48d3768fb80e357f3b457e1e \ - --hash=sha256:ce571367b6dfe60af04e04a1834ca2dc5f46004ac1cc756fb95319f64c095a96 \ - --hash=sha256:d208a0f8729f3fb790ed18a003f3a57895b989b40ea4dce4717e9cf4af62c6bb \ - --hash=sha256:dbee87b469018961d1ad79b1a5d50c0ae850000b639bcb1b694e9981083243b6 \ - --hash=sha256:e9f4c4e51567b616be64e05d517c79a8a22f3606499941d97bb76f2ca59f982d \ - --hash=sha256:f063b69b090c9d918f9df0a12116029e274daf0181df392839661c4c7ec9018a \ - --hash=sha256:f9a909a8bae284d46bbfdefbdd4a262ba19d3bc9921b1e76126b1d21c3c34135 - # via - # chex - # flax - # h5py - # jax - # jaxlib - # ml-dtypes - # opt-einsum - # optax - # orbax-checkpoint - # pandas - # scipy - # tensorboard - # tensorflow - # tensorflow-decision-forests - # tensorflow-hub - # tensorstore -oauthlib==3.2.2 \ - --hash=sha256:8139f29aac13e25d502680e9e19963e83f16838d48a0d71c287fe40e7067fbca \ - --hash=sha256:9859c40929662bec5d64f34d01c99e093149682a3f38915dc0655d5a633dd918 - # via requests-oauthlib -opt-einsum==3.3.0 \ - --hash=sha256:2455e59e3947d3c275477df7f5205b30635e266fe6dc300e3d9f9646bfcea147 \ - --hash=sha256:59f6475f77bbc37dcf7cd748519c0ec60722e91e63ca114e68821c0c54a46549 - # via - # jax - # tensorflow -optax==0.1.4 \ - --hash=sha256:12fcf33bd682f9a162a3deb097f864130c3224d76771af2ba09410de80399a9b \ - --hash=sha256:fb7a0550d57a6636164a3de25986a8a19be8ff6431fcdf1225b4e05175810f22 - # via flax -orbax-checkpoint==0.2.3 \ - --hash=sha256:155e0a2dceef2901122e66585171e1dff4f4a4d9d2abe43a2b514279b9a3dabd \ - --hash=sha256:a001bf48f1cebc635b07263fa546473ea48be3e278c50d5ade880b9aafb96f8a - # via flax -packaging==23.1 \ - --hash=sha256:994793af429502c4ea2ebf6bf664629d07c1a9fe974af92966e4b8d2df7edc61 \ - --hash=sha256:a392980d2b6cffa644431898be54b0045151319d1e7ec34f0cfed48767dd334f - # via - # -r tfjs-converter/python/requirements.txt - # tensorflow -pandas==1.5.2 \ - --hash=sha256:0183cb04a057cc38fde5244909fca9826d5d57c4a5b7390c0cc3fa7acd9fa883 \ - --hash=sha256:1fc87eac0541a7d24648a001d553406f4256e744d92df1df8ebe41829a915028 \ - --hash=sha256:220b98d15cee0b2cd839a6358bd1f273d0356bf964c1a1aeb32d47db0215488b \ - --hash=sha256:2552bffc808641c6eb471e55aa6899fa002ac94e4eebfa9ec058649122db5824 \ - --hash=sha256:315e19a3e5c2ab47a67467fc0362cb36c7c60a93b6457f675d7d9615edad2ebe \ - --hash=sha256:344021ed3e639e017b452aa8f5f6bf38a8806f5852e217a7594417fb9bbfa00e \ - --hash=sha256:375262829c8c700c3e7cbb336810b94367b9c4889818bbd910d0ecb4e45dc261 \ - --hash=sha256:457d8c3d42314ff47cc2d6c54f8fc0d23954b47977b2caed09cd9635cb75388b \ - --hash=sha256:4aed257c7484d01c9a194d9a94758b37d3d751849c05a0050c087a358c41ad1f \ - --hash=sha256:530948945e7b6c95e6fa7aa4be2be25764af53fba93fe76d912e35d1c9ee46f5 \ - --hash=sha256:5ae7e989f12628f41e804847a8cc2943d362440132919a69429d4dea1f164da0 \ - --hash=sha256:71f510b0efe1629bf2f7c0eadb1ff0b9cf611e87b73cd017e6b7d6adb40e2b3a \ - --hash=sha256:73f219fdc1777cf3c45fde7f0708732ec6950dfc598afc50588d0d285fddaefc \ - --hash=sha256:8092a368d3eb7116e270525329a3e5c15ae796ccdf7ccb17839a73b4f5084a39 \ - --hash=sha256:82ae615826da838a8e5d4d630eb70c993ab8636f0eff13cb28aafc4291b632b5 \ - --hash=sha256:9608000a5a45f663be6af5c70c3cbe634fa19243e720eb380c0d378666bc7702 \ - --hash=sha256:a40dd1e9f22e01e66ed534d6a965eb99546b41d4d52dbdb66565608fde48203f \ - --hash=sha256:b4f5a82afa4f1ff482ab8ded2ae8a453a2cdfde2001567b3ca24a4c5c5ca0db3 \ - --hash=sha256:c009a92e81ce836212ce7aa98b219db7961a8b95999b97af566b8dc8c33e9519 \ - --hash=sha256:c218796d59d5abd8780170c937b812c9637e84c32f8271bbf9845970f8c1351f \ - --hash=sha256:cc3cd122bea268998b79adebbb8343b735a5511ec14efb70a39e7acbc11ccbdc \ - --hash=sha256:d0d8fd58df5d17ddb8c72a5075d87cd80d71b542571b5f78178fb067fa4e9c72 \ - --hash=sha256:e18bc3764cbb5e118be139b3b611bc3fbc5d3be42a7e827d1096f46087b395eb \ - --hash=sha256:e2b83abd292194f350bb04e188f9379d36b8dfac24dd445d5c87575f3beaf789 \ - --hash=sha256:e7469271497960b6a781eaa930cba8af400dd59b62ec9ca2f4d31a19f2f91090 \ - --hash=sha256:e9dbacd22555c2d47f262ef96bb4e30880e5956169741400af8b306bbb24a273 \ - --hash=sha256:f6257b314fc14958f8122779e5a1557517b0f8e500cfb2bd53fa1f75a8ad0af2 - # via tensorflow-decision-forests -prompt-toolkit==1.0.14 \ - --hash=sha256:7281b5199235adaef6980942840c43753e4ab20dfe41338da634fb41c194f9d8 \ - --hash=sha256:82c7f8e07d7a0411ff5367a5a8ff520f0112b9179f3e599ee8ad2ad9b943d911 \ - --hash=sha256:cc66413b1b4b17021675d9f2d15d57e640b06ddfd99bb724c73484126d22622f - # via pyinquirer -protobuf==4.22.3 \ - --hash=sha256:13233ee2b9d3bd9a5f216c1fa2c321cd564b93d8f2e4f521a85b585447747997 \ - --hash=sha256:23452f2fdea754a8251d0fc88c0317735ae47217e0d27bf330a30eec2848811a \ - --hash=sha256:52f0a78141078077cfe15fe333ac3e3a077420b9a3f5d1bf9b5fe9d286b4d881 \ - --hash=sha256:70659847ee57a5262a65954538088a1d72dfc3e9882695cab9f0c54ffe71663b \ - --hash=sha256:7760730063329d42a9d4c4573b804289b738d4931e363ffbe684716b796bde51 \ - --hash=sha256:7cf56e31907c532e460bb62010a513408e6cdf5b03fb2611e4b67ed398ad046d \ - --hash=sha256:8b54f56d13ae4a3ec140076c9d937221f887c8f64954673d46f63751209e839a \ - --hash=sha256:d14fc1a41d1a1909998e8aff7e80d2a7ae14772c4a70e4bf7db8a36690b54425 \ - --hash=sha256:d4b66266965598ff4c291416be429cef7989d8fae88b55b62095a2331511b3fa \ - --hash=sha256:e0e630d8e6a79f48c557cd1835865b593d0547dce221c66ed1b827de59c66c97 \ - --hash=sha256:ecae944c6c2ce50dda6bf76ef5496196aeb1b85acb95df5843cd812615ec4b61 \ - --hash=sha256:f08aa300b67f1c012100d8eb62d47129e53d1150f4469fd78a29fa3cb68c66f2 \ - --hash=sha256:f2f4710543abec186aee332d6852ef5ae7ce2e9e807a3da570f36de5a732d88e - # via - # tensorboard - # tensorflow - # tensorflow-hub -pyasn1==0.4.8 \ - --hash=sha256:39c7e2ec30515947ff4e87fb6f456dfc6e84857d34be479c9d4a4ba4bf46aa5d \ - --hash=sha256:aef77c9fb94a3ac588e87841208bdec464471d9871bd5050a287cc9a475cd0ba - # via - # pyasn1-modules - # rsa -pyasn1-modules==0.2.8 \ - --hash=sha256:905f84c712230b2c592c19470d3ca8d552de726050d1d1716282a1f6146be65e \ - --hash=sha256:a50b808ffeb97cb3601dd25981f6b016cbb3d31fbf57a8b8a87428e6158d0c74 - # via google-auth -pygments==2.13.0 \ - --hash=sha256:56a8508ae95f98e2b9bdf93a6be5ae3f7d8af858b43e02c5a2ff083726be40c1 \ - --hash=sha256:f643f331ab57ba3c9d89212ee4a2dabc6e94f117cf4eefde99a0574720d14c42 - # via - # pyinquirer - # rich -pyinquirer==1.0.3 \ - --hash=sha256:c9a92d68d7727fbd886a7908c08fd9e9773e5dc211bf5cbf836ba90d366dee51 - # via -r tfjs-converter/python/requirements-dev.txt -pylint==2.5.0 ; python_version > "3.0" \ - --hash=sha256:588e114e3f9a1630428c35b7dd1c82c1c93e1b0e78ee312ae4724c5e1a1e0245 \ - --hash=sha256:bd556ba95a4cf55a1fc0004c00cf4560b1e70598a54a74c6904d933c8f3bd5a8 - # via -r tfjs-converter/python/requirements-dev.txt -python-dateutil==2.8.2 \ - --hash=sha256:0123cacc1627ae19ddf3c27a5de5bd67ee4586fbdd6440d9748f8abb483d3e86 \ - --hash=sha256:961d03dc3453ebbc59dbdea9e4e11c5651520a876d0f4db161e8674aae935da9 - # via pandas -pytz==2022.6 \ - --hash=sha256:222439474e9c98fced559f1709d89e6c9cbf8d79c794ff3eb9f8800064291427 \ - --hash=sha256:e89512406b793ca39f5971bc999cc538ce125c0e51c27941bef4568b460095e2 - # via pandas -pyyaml==6.0 \ - --hash=sha256:01b45c0191e6d66c470b6cf1b9531a771a83c1c4208272ead47a3ae4f2f603bf \ - --hash=sha256:0283c35a6a9fbf047493e3a0ce8d79ef5030852c51e9d911a27badfde0605293 \ - --hash=sha256:055d937d65826939cb044fc8c9b08889e8c743fdc6a32b33e2390f66013e449b \ - --hash=sha256:07751360502caac1c067a8132d150cf3d61339af5691fe9e87803040dbc5db57 \ - --hash=sha256:0b4624f379dab24d3725ffde76559cff63d9ec94e1736b556dacdfebe5ab6d4b \ - --hash=sha256:0ce82d761c532fe4ec3f87fc45688bdd3a4c1dc5e0b4a19814b9009a29baefd4 \ - --hash=sha256:1e4747bc279b4f613a09eb64bba2ba602d8a6664c6ce6396a4d0cd413a50ce07 \ - --hash=sha256:213c60cd50106436cc818accf5baa1aba61c0189ff610f64f4a3e8c6726218ba \ - --hash=sha256:231710d57adfd809ef5d34183b8ed1eeae3f76459c18fb4a0b373ad56bedcdd9 \ - --hash=sha256:277a0ef2981ca40581a47093e9e2d13b3f1fbbeffae064c1d21bfceba2030287 \ - --hash=sha256:2cd5df3de48857ed0544b34e2d40e9fac445930039f3cfe4bcc592a1f836d513 \ - --hash=sha256:40527857252b61eacd1d9af500c3337ba8deb8fc298940291486c465c8b46ec0 \ - --hash=sha256:432557aa2c09802be39460360ddffd48156e30721f5e8d917f01d31694216782 \ - --hash=sha256:473f9edb243cb1935ab5a084eb238d842fb8f404ed2193a915d1784b5a6b5fc0 \ - --hash=sha256:48c346915c114f5fdb3ead70312bd042a953a8ce5c7106d5bfb1a5254e47da92 \ - --hash=sha256:50602afada6d6cbfad699b0c7bb50d5ccffa7e46a3d738092afddc1f9758427f \ - --hash=sha256:68fb519c14306fec9720a2a5b45bc9f0c8d1b9c72adf45c37baedfcd949c35a2 \ - --hash=sha256:77f396e6ef4c73fdc33a9157446466f1cff553d979bd00ecb64385760c6babdc \ - --hash=sha256:81957921f441d50af23654aa6c5e5eaf9b06aba7f0a19c18a538dc7ef291c5a1 \ - --hash=sha256:819b3830a1543db06c4d4b865e70ded25be52a2e0631ccd2f6a47a2822f2fd7c \ - --hash=sha256:897b80890765f037df3403d22bab41627ca8811ae55e9a722fd0392850ec4d86 \ - --hash=sha256:98c4d36e99714e55cfbaaee6dd5badbc9a1ec339ebfc3b1f52e293aee6bb71a4 \ - --hash=sha256:9df7ed3b3d2e0ecfe09e14741b857df43adb5a3ddadc919a2d94fbdf78fea53c \ - --hash=sha256:9fa600030013c4de8165339db93d182b9431076eb98eb40ee068700c9c813e34 \ - --hash=sha256:a80a78046a72361de73f8f395f1f1e49f956c6be882eed58505a15f3e430962b \ - --hash=sha256:afa17f5bc4d1b10afd4466fd3a44dc0e245382deca5b3c353d8b757f9e3ecb8d \ - --hash=sha256:b3d267842bf12586ba6c734f89d1f5b871df0273157918b0ccefa29deb05c21c \ - --hash=sha256:b5b9eccad747aabaaffbc6064800670f0c297e52c12754eb1d976c57e4f74dcb \ - --hash=sha256:bfaef573a63ba8923503d27530362590ff4f576c626d86a9fed95822a8255fd7 \ - --hash=sha256:c5687b8d43cf58545ade1fe3e055f70eac7a5a1a0bf42824308d868289a95737 \ - --hash=sha256:cba8c411ef271aa037d7357a2bc8f9ee8b58b9965831d9e51baf703280dc73d3 \ - --hash=sha256:d15a181d1ecd0d4270dc32edb46f7cb7733c7c508857278d3d378d14d606db2d \ - --hash=sha256:d4b0ba9512519522b118090257be113b9468d804b19d63c71dbcf4a48fa32358 \ - --hash=sha256:d4db7c7aef085872ef65a8fd7d6d09a14ae91f691dec3e87ee5ee0539d516f53 \ - --hash=sha256:d4eccecf9adf6fbcc6861a38015c2a64f38b9d94838ac1810a9023a0609e1b78 \ - --hash=sha256:d67d839ede4ed1b28a4e8909735fc992a923cdb84e618544973d7dfc71540803 \ - --hash=sha256:daf496c58a8c52083df09b80c860005194014c3698698d1a57cbcfa182142a3a \ - --hash=sha256:dbad0e9d368bb989f4515da330b88a057617d16b6a8245084f1b05400f24609f \ - --hash=sha256:e61ceaab6f49fb8bdfaa0f92c4b57bcfbea54c09277b1b4f7ac376bfb7a7c174 \ - --hash=sha256:f84fbc98b019fef2ee9a1cb3ce93e3187a6df0b2538a651bfb890254ba9f90b5 - # via - # flax - # orbax-checkpoint -regex==2022.10.31 \ - --hash=sha256:052b670fafbe30966bbe5d025e90b2a491f85dfe5b2583a163b5e60a85a321ad \ - --hash=sha256:0653d012b3bf45f194e5e6a41df9258811ac8fc395579fa82958a8b76286bea4 \ - --hash=sha256:0a069c8483466806ab94ea9068c34b200b8bfc66b6762f45a831c4baaa9e8cdd \ - --hash=sha256:0cf0da36a212978be2c2e2e2d04bdff46f850108fccc1851332bcae51c8907cc \ - --hash=sha256:131d4be09bea7ce2577f9623e415cab287a3c8e0624f778c1d955ec7c281bd4d \ - --hash=sha256:144486e029793a733e43b2e37df16a16df4ceb62102636ff3db6033994711066 \ - --hash=sha256:1ddf14031a3882f684b8642cb74eea3af93a2be68893901b2b387c5fd92a03ec \ - --hash=sha256:1eba476b1b242620c266edf6325b443a2e22b633217a9835a52d8da2b5c051f9 \ - --hash=sha256:20f61c9944f0be2dc2b75689ba409938c14876c19d02f7585af4460b6a21403e \ - --hash=sha256:22960019a842777a9fa5134c2364efaed5fbf9610ddc5c904bd3a400973b0eb8 \ - --hash=sha256:22e7ebc231d28393dfdc19b185d97e14a0f178bedd78e85aad660e93b646604e \ - --hash=sha256:23cbb932cc53a86ebde0fb72e7e645f9a5eec1a5af7aa9ce333e46286caef783 \ - --hash=sha256:29c04741b9ae13d1e94cf93fca257730b97ce6ea64cfe1eba11cf9ac4e85afb6 \ - --hash=sha256:2bde29cc44fa81c0a0c8686992c3080b37c488df167a371500b2a43ce9f026d1 \ - --hash=sha256:2cdc55ca07b4e70dda898d2ab7150ecf17c990076d3acd7a5f3b25cb23a69f1c \ - --hash=sha256:370f6e97d02bf2dd20d7468ce4f38e173a124e769762d00beadec3bc2f4b3bc4 \ - --hash=sha256:395161bbdbd04a8333b9ff9763a05e9ceb4fe210e3c7690f5e68cedd3d65d8e1 \ - --hash=sha256:44136355e2f5e06bf6b23d337a75386371ba742ffa771440b85bed367c1318d1 \ - --hash=sha256:44a6c2f6374e0033873e9ed577a54a3602b4f609867794c1a3ebba65e4c93ee7 \ - --hash=sha256:4919899577ba37f505aaebdf6e7dc812d55e8f097331312db7f1aab18767cce8 \ - --hash=sha256:4b4b1fe58cd102d75ef0552cf17242705ce0759f9695334a56644ad2d83903fe \ - --hash=sha256:4bdd56ee719a8f751cf5a593476a441c4e56c9b64dc1f0f30902858c4ef8771d \ - --hash=sha256:4bf41b8b0a80708f7e0384519795e80dcb44d7199a35d52c15cc674d10b3081b \ - --hash=sha256:4cac3405d8dda8bc6ed499557625585544dd5cbf32072dcc72b5a176cb1271c8 \ - --hash=sha256:4fe7fda2fe7c8890d454f2cbc91d6c01baf206fbc96d89a80241a02985118c0c \ - --hash=sha256:50921c140561d3db2ab9f5b11c5184846cde686bb5a9dc64cae442926e86f3af \ - --hash=sha256:5217c25229b6a85049416a5c1e6451e9060a1edcf988641e309dbe3ab26d3e49 \ - --hash=sha256:5352bea8a8f84b89d45ccc503f390a6be77917932b1c98c4cdc3565137acc714 \ - --hash=sha256:542e3e306d1669b25936b64917285cdffcd4f5c6f0247636fec037187bd93542 \ - --hash=sha256:543883e3496c8b6d58bd036c99486c3c8387c2fc01f7a342b760c1ea3158a318 \ - --hash=sha256:586b36ebda81e6c1a9c5a5d0bfdc236399ba6595e1397842fd4a45648c30f35e \ - --hash=sha256:597f899f4ed42a38df7b0e46714880fb4e19a25c2f66e5c908805466721760f5 \ - --hash=sha256:5a260758454580f11dd8743fa98319bb046037dfab4f7828008909d0aa5292bc \ - --hash=sha256:5aefb84a301327ad115e9d346c8e2760009131d9d4b4c6b213648d02e2abe144 \ - --hash=sha256:5e6a5567078b3eaed93558842346c9d678e116ab0135e22eb72db8325e90b453 \ - --hash=sha256:5ff525698de226c0ca743bfa71fc6b378cda2ddcf0d22d7c37b1cc925c9650a5 \ - --hash=sha256:61edbca89aa3f5ef7ecac8c23d975fe7261c12665f1d90a6b1af527bba86ce61 \ - --hash=sha256:659175b2144d199560d99a8d13b2228b85e6019b6e09e556209dfb8c37b78a11 \ - --hash=sha256:6a9a19bea8495bb419dc5d38c4519567781cd8d571c72efc6aa959473d10221a \ - --hash=sha256:6b30bddd61d2a3261f025ad0f9ee2586988c6a00c780a2fb0a92cea2aa702c54 \ - --hash=sha256:6ffd55b5aedc6f25fd8d9f905c9376ca44fcf768673ffb9d160dd6f409bfda73 \ - --hash=sha256:702d8fc6f25bbf412ee706bd73019da5e44a8400861dfff7ff31eb5b4a1276dc \ - --hash=sha256:74bcab50a13960f2a610cdcd066e25f1fd59e23b69637c92ad470784a51b1347 \ - --hash=sha256:75f591b2055523fc02a4bbe598aa867df9e953255f0b7f7715d2a36a9c30065c \ - --hash=sha256:763b64853b0a8f4f9cfb41a76a4a85a9bcda7fdda5cb057016e7706fde928e66 \ - --hash=sha256:76c598ca73ec73a2f568e2a72ba46c3b6c8690ad9a07092b18e48ceb936e9f0c \ - --hash=sha256:78d680ef3e4d405f36f0d6d1ea54e740366f061645930072d39bca16a10d8c93 \ - --hash=sha256:7b280948d00bd3973c1998f92e22aa3ecb76682e3a4255f33e1020bd32adf443 \ - --hash=sha256:7db345956ecce0c99b97b042b4ca7326feeec6b75facd8390af73b18e2650ffc \ - --hash=sha256:7dbdce0c534bbf52274b94768b3498abdf675a691fec5f751b6057b3030f34c1 \ - --hash=sha256:7ef6b5942e6bfc5706301a18a62300c60db9af7f6368042227ccb7eeb22d0892 \ - --hash=sha256:7f5a3ffc731494f1a57bd91c47dc483a1e10048131ffb52d901bfe2beb6102e8 \ - --hash=sha256:8a45b6514861916c429e6059a55cf7db74670eaed2052a648e3e4d04f070e001 \ - --hash=sha256:8ad241da7fac963d7573cc67a064c57c58766b62a9a20c452ca1f21050868dfa \ - --hash=sha256:8b0886885f7323beea6f552c28bff62cbe0983b9fbb94126531693ea6c5ebb90 \ - --hash=sha256:8ca88da1bd78990b536c4a7765f719803eb4f8f9971cc22d6ca965c10a7f2c4c \ - --hash=sha256:8e0caeff18b96ea90fc0eb6e3bdb2b10ab5b01a95128dfeccb64a7238decf5f0 \ - --hash=sha256:957403a978e10fb3ca42572a23e6f7badff39aa1ce2f4ade68ee452dc6807692 \ - --hash=sha256:9af69f6746120998cd9c355e9c3c6aec7dff70d47247188feb4f829502be8ab4 \ - --hash=sha256:9c94f7cc91ab16b36ba5ce476f1904c91d6c92441f01cd61a8e2729442d6fcf5 \ - --hash=sha256:a37d51fa9a00d265cf73f3de3930fa9c41548177ba4f0faf76e61d512c774690 \ - --hash=sha256:a3a98921da9a1bf8457aeee6a551948a83601689e5ecdd736894ea9bbec77e83 \ - --hash=sha256:a3c1ebd4ed8e76e886507c9eddb1a891673686c813adf889b864a17fafcf6d66 \ - --hash=sha256:a5f9505efd574d1e5b4a76ac9dd92a12acb2b309551e9aa874c13c11caefbe4f \ - --hash=sha256:a8ff454ef0bb061e37df03557afda9d785c905dab15584860f982e88be73015f \ - --hash=sha256:a9d0b68ac1743964755ae2d89772c7e6fb0118acd4d0b7464eaf3921c6b49dd4 \ - --hash=sha256:aa62a07ac93b7cb6b7d0389d8ef57ffc321d78f60c037b19dfa78d6b17c928ee \ - --hash=sha256:ac741bf78b9bb432e2d314439275235f41656e189856b11fb4e774d9f7246d81 \ - --hash=sha256:ae1e96785696b543394a4e3f15f3f225d44f3c55dafe3f206493031419fedf95 \ - --hash=sha256:b683e5fd7f74fb66e89a1ed16076dbab3f8e9f34c18b1979ded614fe10cdc4d9 \ - --hash=sha256:b7a8b43ee64ca8f4befa2bea4083f7c52c92864d8518244bfa6e88c751fa8fff \ - --hash=sha256:b8e38472739028e5f2c3a4aded0ab7eadc447f0d84f310c7a8bb697ec417229e \ - --hash=sha256:bfff48c7bd23c6e2aec6454aaf6edc44444b229e94743b34bdcdda2e35126cf5 \ - --hash=sha256:c14b63c9d7bab795d17392c7c1f9aaabbffd4cf4387725a0ac69109fb3b550c6 \ - --hash=sha256:c27cc1e4b197092e50ddbf0118c788d9977f3f8f35bfbbd3e76c1846a3443df7 \ - --hash=sha256:c28d3309ebd6d6b2cf82969b5179bed5fefe6142c70f354ece94324fa11bf6a1 \ - --hash=sha256:c670f4773f2f6f1957ff8a3962c7dd12e4be54d05839b216cb7fd70b5a1df394 \ - --hash=sha256:ce6910b56b700bea7be82c54ddf2e0ed792a577dfaa4a76b9af07d550af435c6 \ - --hash=sha256:d0213671691e341f6849bf33cd9fad21f7b1cb88b89e024f33370733fec58742 \ - --hash=sha256:d03fe67b2325cb3f09be029fd5da8df9e6974f0cde2c2ac6a79d2634e791dd57 \ - --hash=sha256:d0e5af9a9effb88535a472e19169e09ce750c3d442fb222254a276d77808620b \ - --hash=sha256:d243b36fbf3d73c25e48014961e83c19c9cc92530516ce3c43050ea6276a2ab7 \ - --hash=sha256:d26166acf62f731f50bdd885b04b38828436d74e8e362bfcb8df221d868b5d9b \ - --hash=sha256:d403d781b0e06d2922435ce3b8d2376579f0c217ae491e273bab8d092727d244 \ - --hash=sha256:d8716f82502997b3d0895d1c64c3b834181b1eaca28f3f6336a71777e437c2af \ - --hash=sha256:e4f781ffedd17b0b834c8731b75cce2639d5a8afe961c1e58ee7f1f20b3af185 \ - --hash=sha256:e613a98ead2005c4ce037c7b061f2409a1a4e45099edb0ef3200ee26ed2a69a8 \ - --hash=sha256:ef4163770525257876f10e8ece1cf25b71468316f61451ded1a6f44273eedeb5 - # via pyinquirer -requests==2.28.1 \ - --hash=sha256:7c5599b102feddaa661c826c56ab4fee28bfd17f5abca1ebbe3e7f19d7c97983 \ - --hash=sha256:8fefa2a1a1365bf5520aac41836fbee479da67864514bdb821f31ce07ce65349 - # via - # requests-oauthlib - # tensorboard -requests-oauthlib==1.3.1 \ - --hash=sha256:2577c501a2fb8d05a304c09d090d6e47c306fef15809d102b327cf8364bddab5 \ - --hash=sha256:75beac4a47881eeb94d5ea5d6ad31ef88856affe2332b9aafb52c6452ccf0d7a - # via google-auth-oauthlib -rich==12.6.0 \ - --hash=sha256:a4eb26484f2c82589bd9a17c73d32a010b1e29d89f1604cd9bf3a2097b81bb5e \ - --hash=sha256:ba3a3775974105c221d31141f2c116f4fd65c5ceb0698657a11e9f295ec93fd0 - # via flax -rsa==4.9 \ - --hash=sha256:90260d9058e514786967344d0ef75fa8727eed8a7d2e43ce9f4bcf1b536174f7 \ - --hash=sha256:e38464a49c6c85d7f1351b0126661487a7e0a14a50f1675ec50eb34d4f20ef21 - # via google-auth -scipy==1.9.3 \ - --hash=sha256:06d2e1b4c491dc7d8eacea139a1b0b295f74e1a1a0f704c375028f8320d16e31 \ - --hash=sha256:0d54222d7a3ba6022fdf5773931b5d7c56efe41ede7f7128c7b1637700409108 \ - --hash=sha256:1884b66a54887e21addf9c16fb588720a8309a57b2e258ae1c7986d4444d3bc0 \ - --hash=sha256:1a72d885fa44247f92743fc20732ae55564ff2a519e8302fb7e18717c5355a8b \ - --hash=sha256:2318bef588acc7a574f5bfdff9c172d0b1bf2c8143d9582e05f878e580a3781e \ - --hash=sha256:4db5b30849606a95dcf519763dd3ab6fe9bd91df49eba517359e450a7d80ce2e \ - --hash=sha256:545c83ffb518094d8c9d83cce216c0c32f8c04aaf28b92cc8283eda0685162d5 \ - --hash=sha256:5a04cd7d0d3eff6ea4719371cbc44df31411862b9646db617c99718ff68d4840 \ - --hash=sha256:5b88e6d91ad9d59478fafe92a7c757d00c59e3bdc3331be8ada76a4f8d683f58 \ - --hash=sha256:68239b6aa6f9c593da8be1509a05cb7f9efe98b80f43a5861cd24c7557e98523 \ - --hash=sha256:83b89e9586c62e787f5012e8475fbb12185bafb996a03257e9675cd73d3736dd \ - --hash=sha256:83c06e62a390a9167da60bedd4575a14c1f58ca9dfde59830fc42e5197283dab \ - --hash=sha256:90453d2b93ea82a9f434e4e1cba043e779ff67b92f7a0e85d05d286a3625df3c \ - --hash=sha256:abaf921531b5aeaafced90157db505e10345e45038c39e5d9b6c7922d68085cb \ - --hash=sha256:b41bc822679ad1c9a5f023bc93f6d0543129ca0f37c1ce294dd9d386f0a21096 \ - --hash=sha256:c68db6b290cbd4049012990d7fe71a2abd9ffbe82c0056ebe0f01df8be5436b0 \ - --hash=sha256:cff3a5295234037e39500d35316a4c5794739433528310e117b8a9a0c76d20fc \ - --hash=sha256:d01e1dd7b15bd2449c8bfc6b7cc67d630700ed655654f0dfcf121600bad205c9 \ - --hash=sha256:d644a64e174c16cb4b2e41dfea6af722053e83d066da7343f333a54dae9bc31c \ - --hash=sha256:da8245491d73ed0a994ed9c2e380fd058ce2fa8a18da204681f2fe1f57f98f95 \ - --hash=sha256:fbc5c05c85c1a02be77b1ff591087c83bc44579c6d2bd9fb798bb64ea5e1a027 - # via - # jax - # jaxlib -setuptools==65.6.3 \ - --hash=sha256:57f6f22bde4e042978bcd50176fdb381d7c21a9efa4041202288d3737a0c6a54 \ - --hash=sha256:a7620757bf984b58deaf32fc8a4577a9bbc0850cf92c20e1ce41c38c19e5fb75 - # via - # -r tfjs-converter/python/requirements-dev.txt - # tensorboard - # tensorflow -six==1.16.0 \ - --hash=sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926 \ - --hash=sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254 - # via - # -r tfjs-converter/python/requirements.txt - # astunparse - # google-auth - # google-pasta - # prompt-toolkit - # python-dateutil - # tensorflow - # tensorflow-decision-forests -tensorboard==2.13.0 \ - --hash=sha256:ab69961ebddbddc83f5fa2ff9233572bdad5b883778c35e4fe94bf1798bd8481 - # via tensorflow -tensorboard-data-server==0.7.0 \ - --hash=sha256:64aa1be7c23e80b1a42c13b686eb0875bb70f5e755f4d2b8de5c1d880cf2267f \ - --hash=sha256:753d4214799b31da7b6d93837959abebbc6afa86e69eacf1e9a317a48daa31eb \ - --hash=sha256:eb7fa518737944dbf4f0cf83c2e40a7ac346bf91be2e6a0215de98be74e85454 - # via tensorboard -tensorflow==2.13.0 \ - --hash=sha256:00060c5516a61e30c51936084ebc37091d116efe9ae74b2818cbd8b2006218e7 \ - --hash=sha256:06559eeaa69e6561cccbe2d02b015bcec663e875c8bbc4643f55692476e52147 \ - --hash=sha256:076d953a1508dc58bf95f30f58bcc9ee364b1353c61e143cb20c2dada91afb05 \ - --hash=sha256:11ad6a7ff49b4a690fbf37a5adaf28ba2686350a859c5f13c58dc8d2cc670375 \ - --hash=sha256:19ee67901702b26787ad685cca65730c163c101c0c2f238a2584d714e0fa8c25 \ - --hash=sha256:2822ac48c38d69b7fb104e606dacbd763c4bf5d3b20791f25be16a5076d01912 \ - --hash=sha256:5e0fdadec59de3d11c5b5129ddc38e739bde7aa13095b82e19d4380e14d04999 \ - --hash=sha256:6fff426661d286a4c634da44275d2ea2b951f392f3e65c8603681e7cb040586a \ - --hash=sha256:72d68b8c2f382e2d01b956c8ba516c0a7d5dad98111dd351bf82bfa646aa1c72 \ - --hash=sha256:7a08c0e2938ed5b642a8787678123827477b81d316055d5073fff82fa183eb82 \ - --hash=sha256:89125443e998548059c4e4a129dfab2b1ff7f2fd4c8eaed97842c3cd9b663101 \ - --hash=sha256:948003b5a23b72b3d89746d729e62ec5f01e47460f05521b2211d95069f569ba \ - --hash=sha256:9c04bc3023b6c4cfb9ee9759c3f03f21993891b4c345df52eb5519204fbf28c0 \ - --hash=sha256:b2978b39e8b3919059b5fd9e28508d50a77965d06ed0b537ed71c97de22dabdf \ - --hash=sha256:cbb83561bb7d55859eaefc70c674e58713d4e10c10927423ed836a5289bbfa86 \ - --hash=sha256:de77306c0c22c9d8754f54700752ac3a1efee895c5357308e6594436404bfbc0 \ - --hash=sha256:e0cf94d36ceaba8f158c6e15404a81fd5b3aa4cb04147c674cf55bd1aec78154 \ - --hash=sha256:e8f0b69ee2f800399fc6bc7ec55fecfa33662d136e425485959d90638f32a32a \ - --hash=sha256:fa7abe265cc3ebccc9b405a280bf674824c6d85df5e6ccfa985987b3c9d265b4 \ - --hash=sha256:fb2ff1129c93e853c19897d6a22ed0ec56387f5c6290ec03dec1c6f7b80bc396 - # via - # -r tfjs-converter/python/requirements.txt - # tensorflow-decision-forests -tensorflow-decision-forests==1.5.0 \ - --hash=sha256:04fd913627d08fe54514b179c612e87eebf55f1448bf01951660985dfa14a6e1 \ - --hash=sha256:1209a2832ac65f8f74bd9d0c1d58f3f8b771e7fa5c9d504c547842311647b7d4 \ - --hash=sha256:22e3835acbfbd5356bb2f8e0c973dfc40ef80a7924b793e90c811158448cfe77 \ - --hash=sha256:43ffd4fba1c3376f58a9dcee943df80f0cff6e47224d109ad0389a723c74947c \ - --hash=sha256:4a0df3a3be5751594d49f5a8f99977b553cf1c42f320b952ac2a2f67b85283f5 \ - --hash=sha256:5ec4297eb5e7c4110cf8aae89e9b08b9ad2cb725e3e63c89c78304c0d7235d24 \ - --hash=sha256:804f6bed277b5c5b6d2bd85738a64973d5d3e8e6ac06abf6098545740245cedc \ - --hash=sha256:a43af2a5a8c34e550bf549c6cad96da271979efc5a8ec988f6f76cc90770415a \ - --hash=sha256:d137241dad8e884d0c937aa8769fe0768324804e9ba666a78b7b5f2f536a0bd2 \ - --hash=sha256:d685e92abe44920ee6d89394ec4e075bb1ada7402f673566146e1b476a576e96 \ - --hash=sha256:f5d8c3730578bda55a8f520ae39b0c9b2560d69bd53b57882e5371c1a82ba098 \ - --hash=sha256:fbd403acf736bb9b4afd2985d9056e6d5043fc4b9a31bd05e5fcae2b1d413dc3 - # via -r tfjs-converter/python/requirements.txt -tensorflow-estimator==2.13.0 \ - --hash=sha256:6f868284eaa654ae3aa7cacdbef2175d0909df9fcf11374f5166f8bf475952aa - # via tensorflow -tensorflow-hub==0.14.0 \ - --hash=sha256:519c6b56c4d304667fbd8ce66bd637e6a750c901215468db2cc6bfd0739bb0b0 - # via -r tfjs-converter/python/requirements.txt -tensorflow-io-gcs-filesystem==0.28.0 \ - --hash=sha256:00cf6a92f1f9f90b2ba2d728870bcd2a70b116316d0817ab0b91dd390c25b3fd \ - --hash=sha256:22753dc28c949bfaf29b573ee376370762c88d80330fe95cfb291261eb5e927a \ - --hash=sha256:366e1eff8dbd6b64333d7061e2a8efd081ae4742614f717ced08d8cc9379eb50 \ - --hash=sha256:52988659f405166df79905e9859bc84ae2a71e3ff61522ba32a95e4dce8e66d2 \ - --hash=sha256:5fbef5836e70026245d8d9e692c44dae2c6dbc208c743d01f5b7a2978d6b6bc6 \ - --hash=sha256:698d7f89e09812b9afeb47c3860797343a22f997c64ab9dab98132c61daa8a7d \ - --hash=sha256:6d95f306ff225c5053fd06deeab3e3a2716357923cb40c44d566c11be779caa3 \ - --hash=sha256:9484893779324b2d34874b0aacf3b824eb4f22d782e75df029cbccab2e607974 \ - --hash=sha256:a6670e0da16c884267e896ea5c3334d6fd319bd6ff7cf917043a9f3b2babb1b3 \ - --hash=sha256:b6e2d275020fb4d1a952cd3fa546483f4e46ad91d64e90d3458e5ca3d12f6477 \ - --hash=sha256:bbf245883aa52ec687b66d0fcbe0f5f0a92d98c0b1c53e6a736039a3548d29a1 \ - --hash=sha256:bfed720fc691d3f45802a7bed420716805aef0939c11cebf25798906201f626e \ - --hash=sha256:c5d99f56c12a349905ff684142e4d2df06ae68ecf50c4aad5449a5f81731d858 \ - --hash=sha256:cc062ce13ec95fb64b1fd426818a6d2b0e5be9692bc0e43a19cce115b6da4336 \ - --hash=sha256:f76cbe1a784841c223f6861e5f6c7e53aa6232cb626d57e76881a0638c365de6 - # via tensorflow -tensorstore==0.1.41 \ - --hash=sha256:025a62bb9122364885e90469af05fec2f62ad05f46ff46d9eae1d76ad9125563 \ - --hash=sha256:2aa81581f768382a38584698a3fcb07a533fc391067467326656f24ab019cba1 \ - --hash=sha256:2c4c578e82866b8f764de871ff7e0a81fe0949ac3565d8d2eb10f29e43020a52 \ - --hash=sha256:2d65ea0fd5ac96a9d577f16bb917ae8a0a121d2093472bfb7bd762b1e32c753b \ - --hash=sha256:5168f7f71e51da7d6cc85a11cd5d102d9eae750d5f5a3ee90cc9ebae10226621 \ - --hash=sha256:620ad460023eeeae721e2e25a2a3e2b608f09cd169c1f68af7043c6d44e88cbf \ - --hash=sha256:634c78fd62cd6e5357291ccb9671e43262f818f9cf7cc58f701b5bd80d1c1ef7 \ - --hash=sha256:6b3b14616f9141b12e61c0c46d1c954927f7f307498d8b9d2261ff2bd4005bbd \ - --hash=sha256:74e317ef7cba8c0208c5d8d9f1406eac37f58e8f92b3f7caa9a72b8b118b1c09 \ - --hash=sha256:803fa2bcbc93f43fe0b3b5b70d78882d3b266a70d419acfc7fdd515f89cba79b \ - --hash=sha256:8b5dbc0e809c90377527e0f65829d6abcdf5c69f892f433ed2cb8508d4ba519a \ - --hash=sha256:8df13f990acc58889160eff5b2e1df029cdfffdf020ce5044e655242c1016bb1 \ - --hash=sha256:91549a16b1ef2d6bc5ac8f28eed32737001fcfe33309f1ba126cd4c1e08b971b \ - --hash=sha256:96fb62a880bf25da7e12ad4bba00a82deb2daf6f59050e8db6f0b04107120799 \ - --hash=sha256:a99b87b65dfca65a830503bdfd2e5168a69b5290807cb8e922fa5a1acea2edec \ - --hash=sha256:bbd58cedddce29216703a63ea42db010b6151c7bc05ac741af50aa31e31491fb \ - --hash=sha256:c400aa46fc814edd69c72fcdf202dbd8c666ae684b534e81350a3a30ab16bdfc - # via - # flax - # orbax-checkpoint -termcolor==2.1.1 \ - --hash=sha256:67cee2009adc6449c650f6bcf3bdeed00c8ba53a8cda5362733c53e0a39fb70b \ - --hash=sha256:fa852e957f97252205e105dd55bbc23b419a70fec0085708fc0515e399f304fd - # via tensorflow -toml==0.10.2 \ - --hash=sha256:806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b \ - --hash=sha256:b3bda1d108d5dd99f4a20d24d9c348e91c4db7ab1b749200bded2f839ccbe68f - # via pylint -toolz==0.12.0 \ - --hash=sha256:2059bd4148deb1884bb0eb770a3cde70e7f954cfbbdc2285f1f2de01fd21eb6f \ - --hash=sha256:88c570861c440ee3f2f6037c4654613228ff40c93a6c25e0eba70d17282c6194 - # via chex -typing-extensions==4.4.0 \ - --hash=sha256:1511434bb92bf8dd198c12b1cc812e800d4181cfcb867674e0f8279cc93087aa \ - --hash=sha256:16fa4864408f655d35ec496218b85f79b3437c829e93320c7c9215ccfd92489e - # via - # flax - # optax - # orbax-checkpoint - # rich - # tensorflow -urllib3==1.26.13 \ - --hash=sha256:47cc05d99aaa09c9e72ed5809b60e7ba354e64b59c9c173ac3018642d8bb41fc \ - --hash=sha256:c083dd0dce68dbfbe1129d5271cb90f9447dea7d52097c6e0126120c521ddea8 - # via requests -wcwidth==0.2.5 \ - --hash=sha256:beb4802a9cebb9144e99086eff703a642a13d6a0052920003a230f3294bbe784 \ - --hash=sha256:c4d647b99872929fdb7bdcaa4fbe7f01413ed3d98077df798530e5b04f116c83 - # via prompt-toolkit -werkzeug==2.2.2 \ - --hash=sha256:7ea2d48322cc7c0f8b3a215ed73eabd7b5d75d0b50e31ab006286ccff9e00b8f \ - --hash=sha256:f979ab81f58d7318e064e99c4506445d60135ac5cd2e177a2de0089bfd4c9bd5 - # via tensorboard -wheel==0.38.4 \ - --hash=sha256:965f5259b566725405b05e7cf774052044b1ed30119b5d586b2703aafe8719ac \ - --hash=sha256:b60533f3f5d530e971d6737ca6d58681ee434818fab630c83a734bb10c083ce8 - # via - # astunparse - # tensorboard - # tensorflow-decision-forests -wrapt==1.12.1 \ - --hash=sha256:b62ffa81fb85f4332a4f609cab4ac40709470da05643a082ec1eb88e6d9b97d7 - # via - # astroid - # tensorflow -wurlitzer==3.0.3 \ - --hash=sha256:224f5fe70618be3872c05dfddc8c457191ec1870654596279fcc1edadebe3e5b \ - --hash=sha256:ffcc584109f5ecd5244abfde4534f22140f8735a4890ce1abd90b4e503f5f427 - # via tensorflow-decision-forests -zipp==3.11.0 \ - --hash=sha256:83a28fcb75844b5c0cdaf5aa4003c2d728c77e05f5aeabe8e95e56727005fbaa \ - --hash=sha256:a7a22e05929290a67401440b39690ae6563279bced5f314609d9d03798f56766 - # via - # importlib-metadata - # importlib-resources diff --git a/tfjs-master/tfjs-converter/python/requirements.txt b/tfjs-master/tfjs-converter/python/requirements.txt deleted file mode 100644 index 81b412a90..000000000 --- a/tfjs-master/tfjs-converter/python/requirements.txt +++ /dev/null @@ -1,9 +0,0 @@ -flax>=0.7.2 -importlib_resources>=5.9.0 -jax>=0.4.13 -jaxlib>=0.4.13 -tensorflow>=2.13.0,<3 -tensorflow-decision-forests>=1.5.0 -six>=1.16.0,<2 -tensorflow-hub>=0.14.0 -packaging~=23.1 diff --git a/tfjs-master/tfjs-converter/python/requirements_lock.txt b/tfjs-master/tfjs-converter/python/requirements_lock.txt deleted file mode 100644 index 88cc454e8..000000000 --- a/tfjs-master/tfjs-converter/python/requirements_lock.txt +++ /dev/null @@ -1,802 +0,0 @@ -# -# This file is autogenerated by pip-compile with Python 3.8 -# by the following command: -# -# bazel run //tfjs-converter/python:tensorflowjs_deps_requirements.update -# -absl-py==1.3.0 \ - --hash=sha256:34995df9bd7a09b3b8749e230408f5a2a2dd7a68a0d33c12a3d0cb15a041a507 \ - --hash=sha256:463c38a08d2e4cef6c498b76ba5bd4858e4c6ef51da1a5a1f27139a022e20248 - # via - # chex - # optax - # orbax-checkpoint - # tensorboard - # tensorflow - # tensorflow-decision-forests -astunparse==1.6.3 \ - --hash=sha256:5ad93a8456f0d084c3456d059fd9a92cce667963232cbf763eac3bc5b7940872 \ - --hash=sha256:c2652417f2c8b5bb325c885ae329bdf3f86424075c4fd1a128674bc6fba4b8e8 - # via tensorflow -cached-property==1.5.2 \ - --hash=sha256:9fa5755838eecbb2d234c3aa390bd80fbd3ac6b6869109bfc1b499f7bd89a130 \ - --hash=sha256:df4f613cf7ad9a588cc381aaf4a512d26265ecebd5eb9e1ba12f1319eb85a6a0 - # via orbax-checkpoint -cachetools==5.2.0 \ - --hash=sha256:6a94c6402995a99c3970cc7e4884bb60b4a8639938157eeed436098bf9831757 \ - --hash=sha256:f9f17d2aec496a9aa6b76f53e3b614c965223c061982d434d160f930c698a9db - # via google-auth -certifi==2022.12.7 \ - --hash=sha256:35824b4c3a97115964b408844d64aa14db1cc518f6562e8d7261699d1350a9e3 \ - --hash=sha256:4ad3232f5e926d6718ec31cfc1fcadfde020920e278684144551c91769c7bc18 - # via requests -charset-normalizer==2.1.1 \ - --hash=sha256:5a3d016c7c547f69d6f81fb0db9449ce888b418b5b9952cc5e6e66843e9dd845 \ - --hash=sha256:83e9a75d1911279afd89352c68b45348559d1fc0506b054b346651b5e7fee29f - # via requests -chex==0.1.5 \ - --hash=sha256:686858320f8f220c82a6c7eeb54dcdcaa4f3d7f66690dacd13a24baa1ee8299e \ - --hash=sha256:b3321184850d5fc29b2eca63087cdbdd83a1b3e4f33c1314ff8b3b8bd67abbca - # via optax -colorama==0.4.6 \ - --hash=sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44 \ - --hash=sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6 - # via rich -commonmark==0.9.1 \ - --hash=sha256:452f9dc859be7f06631ddcb328b6919c67984aca654e5fefb3914d54691aed60 \ - --hash=sha256:da2f38c92590f83de410ba1a3cbceafbc74fee9def35f9251ba9a971d6d66fd9 - # via rich -dm-tree==0.1.7 \ - --hash=sha256:0f01743cc2247170e64798c6b4b31853717054bf9ceec47a1b1b8c2a4baf5792 \ - --hash=sha256:1379a02df36e2bbff9819ceafa55ccd436b15af398803f781f372f8ead7ed871 \ - --hash=sha256:1410fa2f2cc8dc7c01386f4e93ddeeb56765574ffafb632a9b6bd96496195b10 \ - --hash=sha256:20f24cad4decbf4c1f176a959d16e877c73df33b07d7d1f078a5b8abe72f79f8 \ - --hash=sha256:2a843608e078d1622ebb5e50962a8c718d3fa1ab9461b95a12395a803545b2f5 \ - --hash=sha256:30fec8aca5b92823c0e796a2f33b875b4dccd470b57e91e6c542405c5f77fd2a \ - --hash=sha256:3166304411d14c50a5da1c583e24d6069b44de0c9e06479cb36cdf048a466945 \ - --hash=sha256:3b00885c21267934a3d3c68660811d3f891c9539fd53712f5b2423c6d74bf1e6 \ - --hash=sha256:3ca0a58e219b7b0bc201fea4679971188d0a9028a2543c16803a84e8f8c7eb2c \ - --hash=sha256:3fae437135b6cbbdd51e96488a35e78c3617defa0b65265e7e8752d506f933fd \ - --hash=sha256:4992ac5c42af1d73042cd2d3af4e7892d3750e6c1bb8e5a4f81534aa6515f350 \ - --hash=sha256:51b9bdf1109b47cc22884b1919e6fe38edf28b5aa02e7c661bb760a0e7cf0157 \ - --hash=sha256:57edb6fbd88fcdd9908547cbf21045a9d663c0d9e5983dca7e6f9cf8b6584bb5 \ - --hash=sha256:7f1f3dca9d669f3c09654ff6d69cfafd86a7f967c3095405b2692ee8d8ef3cfd \ - --hash=sha256:7fa0740b7fbae2c3a43a3114a514891b5d6c383050828f36aa1816cf40f73a6a \ - --hash=sha256:91c6240e47c9d80dbd7de5a29a2ca663143717a72c613130ba8ac4354fa741a9 \ - --hash=sha256:98fce150ceebb0a818f0eace1616004031cfa5e3375f50599ad790ff52414ba9 \ - --hash=sha256:9edc1783a08d87c4e130781f55cbd904d6a564f7cce7dfb63f9ef3bee8e38209 \ - --hash=sha256:a085f500b295a6bf439c538e9058c7798ecb8c7d0dc916291f3d8d79d6124d17 \ - --hash=sha256:b4364fc9a5721a2b840ac8ea75b8f58b430bec9fdc8b99304d2aecb3cfe46b1b \ - --hash=sha256:d377bd621b485db42c4aeea0eabbd8f6274b89a9c338c2c1bf69a40c3b86a1fd \ - --hash=sha256:f3e2bd9b9c05d1a0039f7c128d8b055c8a05708ef569cdbbeec0a2946e425bd4 - # via chex -etils==0.9.0 \ - --hash=sha256:489103e9e499a566765c60458ee15d185cf0065f2060a4d16a68f8f46962ed0d \ - --hash=sha256:635d6f7d1c519eb194304228543a4c5c7df0e6b58243302473e34c18cf720588 - # via orbax-checkpoint -flatbuffers==23.5.26 \ - --hash=sha256:9ea1144cac05ce5d86e2859f431c6cd5e66cd9c78c558317c7955fb8d4c78d89 \ - --hash=sha256:c0ff356da363087b915fde4b8b45bdda73432fc17cddb3c8157472eab1422ad1 - # via tensorflow -flax==0.7.2 \ - --hash=sha256:261c7b93e6d15ad80e2cedd2edb797d41b0b3c7805a54254de72a2366dc80148 \ - --hash=sha256:7f023ece0b8b0d03019d2841dbe780e33b81ec42268bdc3e5d24c8fb0582fd7b - # via -r tfjs-converter/python/requirements.txt -gast==0.4.0 \ - --hash=sha256:40feb7b8b8434785585ab224d1568b857edb18297e5a3047f1ba012bc83b42c1 \ - --hash=sha256:b7adcdd5adbebf1adf17378da5ba3f543684dbec47b1cda1f3997e573cd542c4 - # via tensorflow -google-auth==2.15.0 \ - --hash=sha256:6897b93556d8d807ad70701bb89f000183aea366ca7ed94680828b37437a4994 \ - --hash=sha256:72f12a6cfc968d754d7bdab369c5c5c16032106e52d32c6dfd8484e4c01a6d1f - # via - # google-auth-oauthlib - # tensorboard -google-auth-oauthlib==1.0.0 \ - --hash=sha256:95880ca704928c300f48194d1770cf5b1462835b6e49db61445a520f793fd5fb \ - --hash=sha256:e375064964820b47221a7e1b7ee1fd77051b6323c3f9e3e19785f78ab67ecfc5 - # via tensorboard -google-pasta==0.2.0 \ - --hash=sha256:4612951da876b1a10fe3960d7226f0c7682cf901e16ac06e473b267a5afa8954 \ - --hash=sha256:b32482794a366b5366a32c92a9a9201b107821889935a02b3e51f6b432ea84ed \ - --hash=sha256:c9f2c8dfc8f96d0d5808299920721be30c9eec37f2389f28904f454565c8a16e - # via tensorflow -grpcio==1.51.1 \ - --hash=sha256:094e64236253590d9d4075665c77b329d707b6fca864dd62b144255e199b4f87 \ - --hash=sha256:0dc5354e38e5adf2498312f7241b14c7ce3484eefa0082db4297189dcbe272e6 \ - --hash=sha256:0e1a9e1b4a23808f1132aa35f968cd8e659f60af3ffd6fb00bcf9a65e7db279f \ - --hash=sha256:0fb93051331acbb75b49a2a0fd9239c6ba9528f6bdc1dd400ad1cb66cf864292 \ - --hash=sha256:16c71740640ba3a882f50b01bf58154681d44b51f09a5728180a8fdc66c67bd5 \ - --hash=sha256:172405ca6bdfedd6054c74c62085946e45ad4d9cec9f3c42b4c9a02546c4c7e9 \ - --hash=sha256:17ec9b13cec4a286b9e606b48191e560ca2f3bbdf3986f91e480a95d1582e1a7 \ - --hash=sha256:22b011674090594f1f3245960ced7386f6af35485a38901f8afee8ad01541dbd \ - --hash=sha256:24ac1154c4b2ab4a0c5326a76161547e70664cd2c39ba75f00fc8a2170964ea2 \ - --hash=sha256:257478300735ce3c98d65a930bbda3db172bd4e00968ba743e6a1154ea6edf10 \ - --hash=sha256:29cb97d41a4ead83b7bcad23bdb25bdd170b1e2cba16db6d3acbb090bc2de43c \ - --hash=sha256:2b170eaf51518275c9b6b22ccb59450537c5a8555326fd96ff7391b5dd75303c \ - --hash=sha256:31bb6bc7ff145e2771c9baf612f4b9ebbc9605ccdc5f3ff3d5553de7fc0e0d79 \ - --hash=sha256:3c2b3842dcf870912da31a503454a33a697392f60c5e2697c91d133130c2c85d \ - --hash=sha256:3f9b0023c2c92bebd1be72cdfca23004ea748be1813a66d684d49d67d836adde \ - --hash=sha256:471d39d3370ca923a316d49c8aac66356cea708a11e647e3bdc3d0b5de4f0a40 \ - --hash=sha256:49d680356a975d9c66a678eb2dde192d5dc427a7994fb977363634e781614f7c \ - --hash=sha256:4c4423ea38a7825b8fed8934d6d9aeebdf646c97e3c608c3b0bcf23616f33877 \ - --hash=sha256:506b9b7a4cede87d7219bfb31014d7b471cfc77157da9e820a737ec1ea4b0663 \ - --hash=sha256:538d981818e49b6ed1e9c8d5e5adf29f71c4e334e7d459bf47e9b7abb3c30e09 \ - --hash=sha256:59dffade859f157bcc55243714d57b286da6ae16469bf1ac0614d281b5f49b67 \ - --hash=sha256:5a6ebcdef0ef12005d56d38be30f5156d1cb3373b52e96f147f4a24b0ddb3a9d \ - --hash=sha256:5dca372268c6ab6372d37d6b9f9343e7e5b4bc09779f819f9470cd88b2ece3c3 \ - --hash=sha256:6df3b63538c362312bc5fa95fb965069c65c3ea91d7ce78ad9c47cab57226f54 \ - --hash=sha256:6f0b89967ee11f2b654c23b27086d88ad7bf08c0b3c2a280362f28c3698b2896 \ - --hash=sha256:75e29a90dc319f0ad4d87ba6d20083615a00d8276b51512e04ad7452b5c23b04 \ - --hash=sha256:7942b32a291421460d6a07883033e392167d30724aa84987e6956cd15f1a21b9 \ - --hash=sha256:9235dcd5144a83f9ca6f431bd0eccc46b90e2c22fe27b7f7d77cabb2fb515595 \ - --hash=sha256:97d67983189e2e45550eac194d6234fc38b8c3b5396c153821f2d906ed46e0ce \ - --hash=sha256:9ff42c5620b4e4530609e11afefa4a62ca91fa0abb045a8957e509ef84e54d30 \ - --hash=sha256:a8a0b77e992c64880e6efbe0086fe54dfc0bbd56f72a92d9e48264dcd2a3db98 \ - --hash=sha256:aacb54f7789ede5cbf1d007637f792d3e87f1c9841f57dd51abf89337d1b8472 \ - --hash=sha256:bc59f7ba87972ab236f8669d8ca7400f02a0eadf273ca00e02af64d588046f02 \ - --hash=sha256:cc2bece1737b44d878cc1510ea04469a8073dbbcdd762175168937ae4742dfb3 \ - --hash=sha256:cd3baccea2bc5c38aeb14e5b00167bd4e2373a373a5e4d8d850bd193edad150c \ - --hash=sha256:dad6533411d033b77f5369eafe87af8583178efd4039c41d7515d3336c53b4f1 \ - --hash=sha256:e223a9793522680beae44671b9ed8f6d25bbe5ddf8887e66aebad5e0686049ef \ - --hash=sha256:e473525c28251558337b5c1ad3fa969511e42304524a4e404065e165b084c9e4 \ - --hash=sha256:e4ef09f8997c4be5f3504cefa6b5c6cc3cf648274ce3cede84d4342a35d76db6 \ - --hash=sha256:e6dfc2b6567b1c261739b43d9c59d201c1b89e017afd9e684d85aa7a186c9f7a \ - --hash=sha256:eacad297ea60c72dd280d3353d93fb1dcca952ec11de6bb3c49d12a572ba31dd \ - --hash=sha256:f1158bccbb919da42544a4d3af5d9296a3358539ffa01018307337365a9a0c64 \ - --hash=sha256:f1fec3abaf274cdb85bf3878167cfde5ad4a4d97c68421afda95174de85ba813 \ - --hash=sha256:f96ace1540223f26fbe7c4ebbf8a98e3929a6aa0290c8033d12526847b291c0f \ - --hash=sha256:fbdbe9a849854fe484c00823f45b7baab159bdd4a46075302281998cb8719df5 - # via - # tensorboard - # tensorflow -h5py==3.7.0 \ - --hash=sha256:03d64fb86bb86b978928bad923b64419a23e836499ec6363e305ad28afd9d287 \ - --hash=sha256:04e2e1e2fc51b8873e972a08d2f89625ef999b1f2d276199011af57bb9fc7851 \ - --hash=sha256:0798a9c0ff45f17d0192e4d7114d734cac9f8b2b2c76dd1d923c4d0923f27bb6 \ - --hash=sha256:0a047fddbe6951bce40e9cde63373c838a978c5e05a011a682db9ba6334b8e85 \ - --hash=sha256:0d8de8cb619fc597da7cf8cdcbf3b7ff8c5f6db836568afc7dc16d21f59b2b49 \ - --hash=sha256:1fcb11a2dc8eb7ddcae08afd8fae02ba10467753a857fa07a404d700a93f3d53 \ - --hash=sha256:3fcf37884383c5da64846ab510190720027dca0768def34dd8dcb659dbe5cbf3 \ - --hash=sha256:43fed4d13743cf02798a9a03a360a88e589d81285e72b83f47d37bb64ed44881 \ - --hash=sha256:63beb8b7b47d0896c50de6efb9a1eaa81dbe211f3767e7dd7db159cea51ba37a \ - --hash=sha256:6776d896fb90c5938de8acb925e057e2f9f28755f67ec3edcbc8344832616c38 \ - --hash=sha256:9e2ad2aa000f5b1e73b5dfe22f358ca46bf1a2b6ca394d9659874d7fc251731a \ - --hash=sha256:9e7535df5ee3dc3e5d1f408fdfc0b33b46bc9b34db82743c82cd674d8239b9ad \ - --hash=sha256:a9351d729ea754db36d175098361b920573fdad334125f86ac1dd3a083355e20 \ - --hash=sha256:c038399ce09a58ff8d89ec3e62f00aa7cb82d14f34e24735b920e2a811a3a426 \ - --hash=sha256:d77af42cb751ad6cc44f11bae73075a07429a5cf2094dfde2b1e716e059b3911 \ - --hash=sha256:e5b7820b75f9519499d76cc708e27242ccfdd9dfb511d6deb98701961d0445aa \ - --hash=sha256:ed43e2cc4f511756fd664fb45d6b66c3cbed4e3bd0f70e29c37809b2ae013c44 \ - --hash=sha256:f084bbe816907dfe59006756f8f2d16d352faff2d107f4ffeb1d8de126fc5dc7 \ - --hash=sha256:f514b24cacdd983e61f8d371edac8c1b780c279d0acb8485639e97339c866073 \ - --hash=sha256:f73307c876af49aa869ec5df1818e9bb0bdcfcf8a5ba773cc45a4fba5a286a5c - # via tensorflow -idna==3.4 \ - --hash=sha256:814f528e8dead7d329833b91c5faa87d60bf71824cd12a7530b5526063d02cb4 \ - --hash=sha256:90b77e79eaa3eba6de819a0c442c0b4ceefc341a7a2ab77d7562bf49f425c5c2 - # via requests -importlib-metadata==5.1.0 \ - --hash=sha256:d5059f9f1e8e41f80e9c56c2ee58811450c31984dfa625329ffd7c0dad88a73b \ - --hash=sha256:d84d17e21670ec07990e1044a99efe8d615d860fd176fc29ef5c306068fda313 - # via - # jax - # markdown -importlib-resources==5.9.0 \ - --hash=sha256:5481e97fb45af8dcf2f798952625591c58fe599d0735d86b10f54de086a61681 \ - --hash=sha256:f78a8df21a79bcc30cfd400bdc38f314333de7c0fb619763f6b9dabab8268bb7 - # via - # -r tfjs-converter/python/requirements.txt - # orbax-checkpoint -jax==0.4.13 \ - --hash=sha256:03bfe6749dfe647f16f15f6616638adae6c4a7ca7167c75c21961ecfd3a3baaa - # via - # -r tfjs-converter/python/requirements.txt - # chex - # flax - # optax - # orbax-checkpoint -jaxlib==0.4.13 \ - --hash=sha256:19ae4c316b17a49342432c69f7f89f190b975333f3f9e9e175f686a651bc7347 \ - --hash=sha256:411334d903df07dc1ace8d52fc53c17f6bc1d55aff7f6e0e5cf61ec149f758a0 \ - --hash=sha256:49690fcdd26560515fd15399fc3a44777e0bfc5db5c48fe76ff7bc7228e8b2fb \ - --hash=sha256:522635d5e159401a386c79f1236c218c1f68fbb4ca6648115c3ad3c2c3f518ab \ - --hash=sha256:532ebc4fb11386282ad63b83941d4557f4038c1144acf026f1f8565f64c7e9c0 \ - --hash=sha256:8000c0d15c107328e8f7b7b3ac91dd822f5c287a80231882b620503ed141fa89 \ - --hash=sha256:839173b2e9593f5e9a6d3c42852cd15070fe80a939246efbb5cf40eec815de89 \ - --hash=sha256:a259bb35429bfbd3b76e43019dfc8f7d6ea94bb217400b78f7d0824ce07a58ac \ - --hash=sha256:b5c0a9737efd95fe18fd7715ce30dfce476546705ea8934aad6731777a9631a5 \ - --hash=sha256:bebb4cf001f180dc431f9604daf930c2d9cc778e4dda26f401ac939b7bac912e \ - --hash=sha256:c230ef85712e608d0f048869766a5a63afeb2e72309943db0df9f959ab17307f \ - --hash=sha256:d19c05c15f962e098d49b45e2758aacf19330d192ec5395f9ef136f62db90edc \ - --hash=sha256:ea1bc9811ef7d73a15e3213115e88fe7f5d14b59d95027bea9fccc98e5a14af8 \ - --hash=sha256:f4e9e34e5d8a6556f62fead14aee0b1614c2c6296f0078d8e6139d6aff109649 \ - --hash=sha256:fde66a93e9be89d99e5792f677ed8e319667d6b2396865b1c52c1312844c47f9 - # via - # -r tfjs-converter/python/requirements.txt - # chex - # optax - # orbax-checkpoint -keras==2.13.1 \ - --hash=sha256:5ce5f706f779fa7330e63632f327b75ce38144a120376b2ae1917c00fa6136af \ - --hash=sha256:5df12cc241a015a11b65ddb452c0eeb2744fce21d9b54ba48db87492568ccc68 - # via tensorflow -libclang==14.0.6 \ - --hash=sha256:206d2789e4450a37d054e63b70451a6fc1873466397443fa13de2b3d4adb2796 \ - --hash=sha256:2e4303e04517fcd11173cb2e51a7070eed71e16ef45d4e26a82c5e881cac3d27 \ - --hash=sha256:5dd3c6fca1b007d308a4114afa8e4e9d32f32b2572520701d45fcc626ac5cd6c \ - --hash=sha256:7b06fc76bd1e67c8b04b5719bf2ac5d6a323b289b245dfa9e468561d99538188 \ - --hash=sha256:8791cf3c3b087c373a6d61e9199da7a541da922c9ddcfed1122090586b996d6e \ - --hash=sha256:9052a8284d8846984f6fa826b1d7460a66d3b23a486d782633b42b6e3b418789 \ - --hash=sha256:cfb0e892ebb5dff6bd498ab5778adb8581f26a00fd8347b3c76c989fe2fd04f7 \ - --hash=sha256:e2add1703129b2abe066fb1890afa880870a89fd6ab4ec5d2a7a8dc8d271677e \ - --hash=sha256:e429853939423f276a25140b0b702442d7da9a09e001c05e48df888336947614 \ - --hash=sha256:ea03c12675151837660cdd5dce65bd89320896ac3421efef43a36678f113ce95 - # via tensorflow -markdown==3.4.1 \ - --hash=sha256:08fb8465cffd03d10b9dd34a5c3fea908e20391a2a90b88d66362cb05beed186 \ - --hash=sha256:3b809086bb6efad416156e00a0da66fe47618a5d6918dd688f53f40c8e4cfeff - # via tensorboard -markupsafe==2.1.1 \ - --hash=sha256:0212a68688482dc52b2d45013df70d169f542b7394fc744c02a57374a4207003 \ - --hash=sha256:089cf3dbf0cd6c100f02945abeb18484bd1ee57a079aefd52cffd17fba910b88 \ - --hash=sha256:10c1bfff05d95783da83491be968e8fe789263689c02724e0c691933c52994f5 \ - --hash=sha256:33b74d289bd2f5e527beadcaa3f401e0df0a89927c1559c8566c066fa4248ab7 \ - --hash=sha256:3799351e2336dc91ea70b034983ee71cf2f9533cdff7c14c90ea126bfd95d65a \ - --hash=sha256:3ce11ee3f23f79dbd06fb3d63e2f6af7b12db1d46932fe7bd8afa259a5996603 \ - --hash=sha256:421be9fbf0ffe9ffd7a378aafebbf6f4602d564d34be190fc19a193232fd12b1 \ - --hash=sha256:43093fb83d8343aac0b1baa75516da6092f58f41200907ef92448ecab8825135 \ - --hash=sha256:46d00d6cfecdde84d40e572d63735ef81423ad31184100411e6e3388d405e247 \ - --hash=sha256:4a33dea2b688b3190ee12bd7cfa29d39c9ed176bda40bfa11099a3ce5d3a7ac6 \ - --hash=sha256:4b9fe39a2ccc108a4accc2676e77da025ce383c108593d65cc909add5c3bd601 \ - --hash=sha256:56442863ed2b06d19c37f94d999035e15ee982988920e12a5b4ba29b62ad1f77 \ - --hash=sha256:671cd1187ed5e62818414afe79ed29da836dde67166a9fac6d435873c44fdd02 \ - --hash=sha256:694deca8d702d5db21ec83983ce0bb4b26a578e71fbdbd4fdcd387daa90e4d5e \ - --hash=sha256:6a074d34ee7a5ce3effbc526b7083ec9731bb3cbf921bbe1d3005d4d2bdb3a63 \ - --hash=sha256:6d0072fea50feec76a4c418096652f2c3238eaa014b2f94aeb1d56a66b41403f \ - --hash=sha256:6fbf47b5d3728c6aea2abb0589b5d30459e369baa772e0f37a0320185e87c980 \ - --hash=sha256:7f91197cc9e48f989d12e4e6fbc46495c446636dfc81b9ccf50bb0ec74b91d4b \ - --hash=sha256:86b1f75c4e7c2ac2ccdaec2b9022845dbb81880ca318bb7a0a01fbf7813e3812 \ - --hash=sha256:8dc1c72a69aa7e082593c4a203dcf94ddb74bb5c8a731e4e1eb68d031e8498ff \ - --hash=sha256:8e3dcf21f367459434c18e71b2a9532d96547aef8a871872a5bd69a715c15f96 \ - --hash=sha256:8e576a51ad59e4bfaac456023a78f6b5e6e7651dcd383bcc3e18d06f9b55d6d1 \ - --hash=sha256:96e37a3dc86e80bf81758c152fe66dbf60ed5eca3d26305edf01892257049925 \ - --hash=sha256:97a68e6ada378df82bc9f16b800ab77cbf4b2fada0081794318520138c088e4a \ - --hash=sha256:99a2a507ed3ac881b975a2976d59f38c19386d128e7a9a18b7df6fff1fd4c1d6 \ - --hash=sha256:a49907dd8420c5685cfa064a1335b6754b74541bbb3706c259c02ed65b644b3e \ - --hash=sha256:b09bf97215625a311f669476f44b8b318b075847b49316d3e28c08e41a7a573f \ - --hash=sha256:b7bd98b796e2b6553da7225aeb61f447f80a1ca64f41d83612e6139ca5213aa4 \ - --hash=sha256:b87db4360013327109564f0e591bd2a3b318547bcef31b468a92ee504d07ae4f \ - --hash=sha256:bcb3ed405ed3222f9904899563d6fc492ff75cce56cba05e32eff40e6acbeaa3 \ - --hash=sha256:d4306c36ca495956b6d568d276ac11fdd9c30a36f1b6eb928070dc5360b22e1c \ - --hash=sha256:d5ee4f386140395a2c818d149221149c54849dfcfcb9f1debfe07a8b8bd63f9a \ - --hash=sha256:dda30ba7e87fbbb7eab1ec9f58678558fd9a6b8b853530e176eabd064da81417 \ - --hash=sha256:e04e26803c9c3851c931eac40c695602c6295b8d432cbe78609649ad9bd2da8a \ - --hash=sha256:e1c0b87e09fa55a220f058d1d49d3fb8df88fbfab58558f1198e08c1e1de842a \ - --hash=sha256:e72591e9ecd94d7feb70c1cbd7be7b3ebea3f548870aa91e2732960fa4d57a37 \ - --hash=sha256:e8c843bbcda3a2f1e3c2ab25913c80a3c5376cd00c6e8c4a86a89a28c8dc5452 \ - --hash=sha256:efc1913fd2ca4f334418481c7e595c00aad186563bbc1ec76067848c7ca0a933 \ - --hash=sha256:f121a1420d4e173a5d96e47e9a0c0dcff965afdf1626d28de1460815f7c4ee7a \ - --hash=sha256:fc7b548b17d238737688817ab67deebb30e8073c95749d55538ed473130ec0c7 - # via werkzeug -ml-dtypes==0.2.0 \ - --hash=sha256:022d5a4ee6be14569c2a9d1549e16f1ec87ca949681d0dca59995445d5fcdd5b \ - --hash=sha256:1749b60348da71fd3c2ab303fdbc1965958dc50775ead41f5669c932a341cafd \ - --hash=sha256:32107e7fa9f62db9a5281de923861325211dfff87bd23faefb27b303314635ab \ - --hash=sha256:35b984cddbe8173b545a0e3334fe56ea1a5c3eb67c507f60d0cfde1d3fa8f8c2 \ - --hash=sha256:36d28b8861a8931695e5a31176cad5ae85f6504906650dea5598fbec06c94606 \ - --hash=sha256:50845af3e9a601810751b55091dee6c2562403fa1cb4e0123675cf3a4fc2c17a \ - --hash=sha256:6488eb642acaaf08d8020f6de0a38acee7ac324c1e6e92ee0c0fea42422cb797 \ - --hash=sha256:75015818a7fccf99a5e8ed18720cb430f3e71a8838388840f4cdf225c036c983 \ - --hash=sha256:80d304c836d73f10605c58ccf7789c171cc229bfb678748adfb7cea2510dfd0e \ - --hash=sha256:832a019a1b6db5c4422032ca9940a990fa104eee420f643713241b3a518977fa \ - --hash=sha256:8faaf0897942c8253dd126662776ba45f0a5861968cf0f06d6d465f8a7bc298a \ - --hash=sha256:bc29a0524ef5e23a7fbb8d881bdecabeb3fc1d19d9db61785d077a86cb94fab2 \ - --hash=sha256:df6a76e1c8adf484feb138ed323f9f40a7b6c21788f120f7c78bec20ac37ee81 \ - --hash=sha256:e70047ec2c83eaee01afdfdabee2c5b0c133804d90d0f7db4dd903360fcc537c \ - --hash=sha256:e85ba8e24cf48d456e564688e981cf379d4c8e644db0a2f719b78de281bac2ca \ - --hash=sha256:f00c71c8c63e03aff313bc6a7aeaac9a4f1483a921a6ffefa6d4404efd1af3d0 \ - --hash=sha256:f08c391c2794f2aad358e6f4c70785a9a7b1df980ef4c232b3ccd4f6fe39f719 - # via - # jax - # jaxlib -msgpack==1.0.4 \ - --hash=sha256:002b5c72b6cd9b4bafd790f364b8480e859b4712e91f43014fe01e4f957b8467 \ - --hash=sha256:0a68d3ac0104e2d3510de90a1091720157c319ceeb90d74f7b5295a6bee51bae \ - --hash=sha256:0df96d6eaf45ceca04b3f3b4b111b86b33785683d682c655063ef8057d61fd92 \ - --hash=sha256:0dfe3947db5fb9ce52aaea6ca28112a170db9eae75adf9339a1aec434dc954ef \ - --hash=sha256:0e3590f9fb9f7fbc36df366267870e77269c03172d086fa76bb4eba8b2b46624 \ - --hash=sha256:11184bc7e56fd74c00ead4f9cc9a3091d62ecb96e97653add7a879a14b003227 \ - --hash=sha256:112b0f93202d7c0fef0b7810d465fde23c746a2d482e1e2de2aafd2ce1492c88 \ - --hash=sha256:1276e8f34e139aeff1c77a3cefb295598b504ac5314d32c8c3d54d24fadb94c9 \ - --hash=sha256:1576bd97527a93c44fa856770197dec00d223b0b9f36ef03f65bac60197cedf8 \ - --hash=sha256:1e91d641d2bfe91ba4c52039adc5bccf27c335356055825c7f88742c8bb900dd \ - --hash=sha256:26b8feaca40a90cbe031b03d82b2898bf560027160d3eae1423f4a67654ec5d6 \ - --hash=sha256:2999623886c5c02deefe156e8f869c3b0aaeba14bfc50aa2486a0415178fce55 \ - --hash=sha256:2a2df1b55a78eb5f5b7d2a4bb221cd8363913830145fad05374a80bf0877cb1e \ - --hash=sha256:2bb8cdf50dd623392fa75525cce44a65a12a00c98e1e37bf0fb08ddce2ff60d2 \ - --hash=sha256:2cc5ca2712ac0003bcb625c96368fd08a0f86bbc1a5578802512d87bc592fe44 \ - --hash=sha256:35bc0faa494b0f1d851fd29129b2575b2e26d41d177caacd4206d81502d4c6a6 \ - --hash=sha256:3c11a48cf5e59026ad7cb0dc29e29a01b5a66a3e333dc11c04f7e991fc5510a9 \ - --hash=sha256:449e57cc1ff18d3b444eb554e44613cffcccb32805d16726a5494038c3b93dab \ - --hash=sha256:462497af5fd4e0edbb1559c352ad84f6c577ffbbb708566a0abaaa84acd9f3ae \ - --hash=sha256:4733359808c56d5d7756628736061c432ded018e7a1dff2d35a02439043321aa \ - --hash=sha256:48f5d88c99f64c456413d74a975bd605a9b0526293218a3b77220a2c15458ba9 \ - --hash=sha256:49565b0e3d7896d9ea71d9095df15b7f75a035c49be733051c34762ca95bbf7e \ - --hash=sha256:4ab251d229d10498e9a2f3b1e68ef64cb393394ec477e3370c457f9430ce9250 \ - --hash=sha256:4d5834a2a48965a349da1c5a79760d94a1a0172fbb5ab6b5b33cbf8447e109ce \ - --hash=sha256:4dea20515f660aa6b7e964433b1808d098dcfcabbebeaaad240d11f909298075 \ - --hash=sha256:545e3cf0cf74f3e48b470f68ed19551ae6f9722814ea969305794645da091236 \ - --hash=sha256:63e29d6e8c9ca22b21846234913c3466b7e4ee6e422f205a2988083de3b08cae \ - --hash=sha256:6916c78f33602ecf0509cc40379271ba0f9ab572b066bd4bdafd7434dee4bc6e \ - --hash=sha256:6a4192b1ab40f8dca3f2877b70e63799d95c62c068c84dc028b40a6cb03ccd0f \ - --hash=sha256:6c9566f2c39ccced0a38d37c26cc3570983b97833c365a6044edef3574a00c08 \ - --hash=sha256:76ee788122de3a68a02ed6f3a16bbcd97bc7c2e39bd4d94be2f1821e7c4a64e6 \ - --hash=sha256:7760f85956c415578c17edb39eed99f9181a48375b0d4a94076d84148cf67b2d \ - --hash=sha256:77ccd2af37f3db0ea59fb280fa2165bf1b096510ba9fe0cc2bf8fa92a22fdb43 \ - --hash=sha256:81fc7ba725464651190b196f3cd848e8553d4d510114a954681fd0b9c479d7e1 \ - --hash=sha256:85f279d88d8e833ec015650fd15ae5eddce0791e1e8a59165318f371158efec6 \ - --hash=sha256:9667bdfdf523c40d2511f0e98a6c9d3603be6b371ae9a238b7ef2dc4e7a427b0 \ - --hash=sha256:a75dfb03f8b06f4ab093dafe3ddcc2d633259e6c3f74bb1b01996f5d8aa5868c \ - --hash=sha256:ac5bd7901487c4a1dd51a8c58f2632b15d838d07ceedaa5e4c080f7190925bff \ - --hash=sha256:aca0f1644d6b5a73eb3e74d4d64d5d8c6c3d577e753a04c9e9c87d07692c58db \ - --hash=sha256:b17be2478b622939e39b816e0aa8242611cc8d3583d1cd8ec31b249f04623243 \ - --hash=sha256:c1683841cd4fa45ac427c18854c3ec3cd9b681694caf5bff04edb9387602d661 \ - --hash=sha256:c23080fdeec4716aede32b4e0ef7e213c7b1093eede9ee010949f2a418ced6ba \ - --hash=sha256:d5b5b962221fa2c5d3a7f8133f9abffc114fe218eb4365e40f17732ade576c8e \ - --hash=sha256:d603de2b8d2ea3f3bcb2efe286849aa7a81531abc52d8454da12f46235092bcb \ - --hash=sha256:e83f80a7fec1a62cf4e6c9a660e39c7f878f603737a0cdac8c13131d11d97f52 \ - --hash=sha256:eb514ad14edf07a1dbe63761fd30f89ae79b42625731e1ccf5e1f1092950eaa6 \ - --hash=sha256:eba96145051ccec0ec86611fe9cf693ce55f2a3ce89c06ed307de0e085730ec1 \ - --hash=sha256:ed6f7b854a823ea44cf94919ba3f727e230da29feb4a99711433f25800cf747f \ - --hash=sha256:f0029245c51fd9473dc1aede1160b0a29f4a912e6b1dd353fa6d317085b219da \ - --hash=sha256:f5d869c18f030202eb412f08b28d2afeea553d6613aee89e200d7aca7ef01f5f \ - --hash=sha256:fb62ea4b62bfcb0b380d5680f9a4b3f9a2d166d9394e9bbd9666c0ee09a3645c \ - --hash=sha256:fcb8a47f43acc113e24e910399376f7277cf8508b27e5b88499f053de6b115a8 - # via - # flax - # orbax-checkpoint -nest-asyncio==1.5.7 \ - --hash=sha256:5301c82941b550b3123a1ea772ba9a1c80bad3a182be8c1a5ae6ad3be57a9657 \ - --hash=sha256:6a80f7b98f24d9083ed24608977c09dd608d83f91cccc24c9d2cba6d10e01c10 - # via orbax-checkpoint -numpy==1.23.5 \ - --hash=sha256:01dd17cbb340bf0fc23981e52e1d18a9d4050792e8fb8363cecbf066a84b827d \ - --hash=sha256:06005a2ef6014e9956c09ba07654f9837d9e26696a0470e42beedadb78c11b07 \ - --hash=sha256:09b7847f7e83ca37c6e627682f145856de331049013853f344f37b0c9690e3df \ - --hash=sha256:0aaee12d8883552fadfc41e96b4c82ee7d794949e2a7c3b3a7201e968c7ecab9 \ - --hash=sha256:0cbe9848fad08baf71de1a39e12d1b6310f1d5b2d0ea4de051058e6e1076852d \ - --hash=sha256:1b1766d6f397c18153d40015ddfc79ddb715cabadc04d2d228d4e5a8bc4ded1a \ - --hash=sha256:33161613d2269025873025b33e879825ec7b1d831317e68f4f2f0f84ed14c719 \ - --hash=sha256:5039f55555e1eab31124a5768898c9e22c25a65c1e0037f4d7c495a45778c9f2 \ - --hash=sha256:522e26bbf6377e4d76403826ed689c295b0b238f46c28a7251ab94716da0b280 \ - --hash=sha256:56e454c7833e94ec9769fa0f86e6ff8e42ee38ce0ce1fa4cbb747ea7e06d56aa \ - --hash=sha256:58f545efd1108e647604a1b5aa809591ccd2540f468a880bedb97247e72db387 \ - --hash=sha256:5e05b1c973a9f858c74367553e236f287e749465f773328c8ef31abe18f691e1 \ - --hash=sha256:7903ba8ab592b82014713c491f6c5d3a1cde5b4a3bf116404e08f5b52f6daf43 \ - --hash=sha256:8969bfd28e85c81f3f94eb4a66bc2cf1dbdc5c18efc320af34bffc54d6b1e38f \ - --hash=sha256:92c8c1e89a1f5028a4c6d9e3ccbe311b6ba53694811269b992c0b224269e2398 \ - --hash=sha256:9c88793f78fca17da0145455f0d7826bcb9f37da4764af27ac945488116efe63 \ - --hash=sha256:a7ac231a08bb37f852849bbb387a20a57574a97cfc7b6cabb488a4fc8be176de \ - --hash=sha256:abdde9f795cf292fb9651ed48185503a2ff29be87770c3b8e2a14b0cd7aa16f8 \ - --hash=sha256:af1da88f6bc3d2338ebbf0e22fe487821ea4d8e89053e25fa59d1d79786e7481 \ - --hash=sha256:b2a9ab7c279c91974f756c84c365a669a887efa287365a8e2c418f8b3ba73fb0 \ - --hash=sha256:bf837dc63ba5c06dc8797c398db1e223a466c7ece27a1f7b5232ba3466aafe3d \ - --hash=sha256:ca51fcfcc5f9354c45f400059e88bc09215fb71a48d3768fb80e357f3b457e1e \ - --hash=sha256:ce571367b6dfe60af04e04a1834ca2dc5f46004ac1cc756fb95319f64c095a96 \ - --hash=sha256:d208a0f8729f3fb790ed18a003f3a57895b989b40ea4dce4717e9cf4af62c6bb \ - --hash=sha256:dbee87b469018961d1ad79b1a5d50c0ae850000b639bcb1b694e9981083243b6 \ - --hash=sha256:e9f4c4e51567b616be64e05d517c79a8a22f3606499941d97bb76f2ca59f982d \ - --hash=sha256:f063b69b090c9d918f9df0a12116029e274daf0181df392839661c4c7ec9018a \ - --hash=sha256:f9a909a8bae284d46bbfdefbdd4a262ba19d3bc9921b1e76126b1d21c3c34135 - # via - # chex - # flax - # h5py - # jax - # jaxlib - # ml-dtypes - # opt-einsum - # optax - # orbax-checkpoint - # pandas - # scipy - # tensorboard - # tensorflow - # tensorflow-decision-forests - # tensorflow-hub - # tensorstore -oauthlib==3.2.2 \ - --hash=sha256:8139f29aac13e25d502680e9e19963e83f16838d48a0d71c287fe40e7067fbca \ - --hash=sha256:9859c40929662bec5d64f34d01c99e093149682a3f38915dc0655d5a633dd918 - # via requests-oauthlib -opt-einsum==3.3.0 \ - --hash=sha256:2455e59e3947d3c275477df7f5205b30635e266fe6dc300e3d9f9646bfcea147 \ - --hash=sha256:59f6475f77bbc37dcf7cd748519c0ec60722e91e63ca114e68821c0c54a46549 - # via - # jax - # tensorflow -optax==0.1.4 \ - --hash=sha256:12fcf33bd682f9a162a3deb097f864130c3224d76771af2ba09410de80399a9b \ - --hash=sha256:fb7a0550d57a6636164a3de25986a8a19be8ff6431fcdf1225b4e05175810f22 - # via flax -orbax-checkpoint==0.2.3 \ - --hash=sha256:155e0a2dceef2901122e66585171e1dff4f4a4d9d2abe43a2b514279b9a3dabd \ - --hash=sha256:a001bf48f1cebc635b07263fa546473ea48be3e278c50d5ade880b9aafb96f8a - # via flax -packaging==23.1 \ - --hash=sha256:994793af429502c4ea2ebf6bf664629d07c1a9fe974af92966e4b8d2df7edc61 \ - --hash=sha256:a392980d2b6cffa644431898be54b0045151319d1e7ec34f0cfed48767dd334f - # via - # -r tfjs-converter/python/requirements.txt - # tensorflow -pandas==1.5.2 \ - --hash=sha256:0183cb04a057cc38fde5244909fca9826d5d57c4a5b7390c0cc3fa7acd9fa883 \ - --hash=sha256:1fc87eac0541a7d24648a001d553406f4256e744d92df1df8ebe41829a915028 \ - --hash=sha256:220b98d15cee0b2cd839a6358bd1f273d0356bf964c1a1aeb32d47db0215488b \ - --hash=sha256:2552bffc808641c6eb471e55aa6899fa002ac94e4eebfa9ec058649122db5824 \ - --hash=sha256:315e19a3e5c2ab47a67467fc0362cb36c7c60a93b6457f675d7d9615edad2ebe \ - --hash=sha256:344021ed3e639e017b452aa8f5f6bf38a8806f5852e217a7594417fb9bbfa00e \ - --hash=sha256:375262829c8c700c3e7cbb336810b94367b9c4889818bbd910d0ecb4e45dc261 \ - --hash=sha256:457d8c3d42314ff47cc2d6c54f8fc0d23954b47977b2caed09cd9635cb75388b \ - --hash=sha256:4aed257c7484d01c9a194d9a94758b37d3d751849c05a0050c087a358c41ad1f \ - --hash=sha256:530948945e7b6c95e6fa7aa4be2be25764af53fba93fe76d912e35d1c9ee46f5 \ - --hash=sha256:5ae7e989f12628f41e804847a8cc2943d362440132919a69429d4dea1f164da0 \ - --hash=sha256:71f510b0efe1629bf2f7c0eadb1ff0b9cf611e87b73cd017e6b7d6adb40e2b3a \ - --hash=sha256:73f219fdc1777cf3c45fde7f0708732ec6950dfc598afc50588d0d285fddaefc \ - --hash=sha256:8092a368d3eb7116e270525329a3e5c15ae796ccdf7ccb17839a73b4f5084a39 \ - --hash=sha256:82ae615826da838a8e5d4d630eb70c993ab8636f0eff13cb28aafc4291b632b5 \ - --hash=sha256:9608000a5a45f663be6af5c70c3cbe634fa19243e720eb380c0d378666bc7702 \ - --hash=sha256:a40dd1e9f22e01e66ed534d6a965eb99546b41d4d52dbdb66565608fde48203f \ - --hash=sha256:b4f5a82afa4f1ff482ab8ded2ae8a453a2cdfde2001567b3ca24a4c5c5ca0db3 \ - --hash=sha256:c009a92e81ce836212ce7aa98b219db7961a8b95999b97af566b8dc8c33e9519 \ - --hash=sha256:c218796d59d5abd8780170c937b812c9637e84c32f8271bbf9845970f8c1351f \ - --hash=sha256:cc3cd122bea268998b79adebbb8343b735a5511ec14efb70a39e7acbc11ccbdc \ - --hash=sha256:d0d8fd58df5d17ddb8c72a5075d87cd80d71b542571b5f78178fb067fa4e9c72 \ - --hash=sha256:e18bc3764cbb5e118be139b3b611bc3fbc5d3be42a7e827d1096f46087b395eb \ - --hash=sha256:e2b83abd292194f350bb04e188f9379d36b8dfac24dd445d5c87575f3beaf789 \ - --hash=sha256:e7469271497960b6a781eaa930cba8af400dd59b62ec9ca2f4d31a19f2f91090 \ - --hash=sha256:e9dbacd22555c2d47f262ef96bb4e30880e5956169741400af8b306bbb24a273 \ - --hash=sha256:f6257b314fc14958f8122779e5a1557517b0f8e500cfb2bd53fa1f75a8ad0af2 - # via tensorflow-decision-forests -protobuf==4.22.3 \ - --hash=sha256:13233ee2b9d3bd9a5f216c1fa2c321cd564b93d8f2e4f521a85b585447747997 \ - --hash=sha256:23452f2fdea754a8251d0fc88c0317735ae47217e0d27bf330a30eec2848811a \ - --hash=sha256:52f0a78141078077cfe15fe333ac3e3a077420b9a3f5d1bf9b5fe9d286b4d881 \ - --hash=sha256:70659847ee57a5262a65954538088a1d72dfc3e9882695cab9f0c54ffe71663b \ - --hash=sha256:7760730063329d42a9d4c4573b804289b738d4931e363ffbe684716b796bde51 \ - --hash=sha256:7cf56e31907c532e460bb62010a513408e6cdf5b03fb2611e4b67ed398ad046d \ - --hash=sha256:8b54f56d13ae4a3ec140076c9d937221f887c8f64954673d46f63751209e839a \ - --hash=sha256:d14fc1a41d1a1909998e8aff7e80d2a7ae14772c4a70e4bf7db8a36690b54425 \ - --hash=sha256:d4b66266965598ff4c291416be429cef7989d8fae88b55b62095a2331511b3fa \ - --hash=sha256:e0e630d8e6a79f48c557cd1835865b593d0547dce221c66ed1b827de59c66c97 \ - --hash=sha256:ecae944c6c2ce50dda6bf76ef5496196aeb1b85acb95df5843cd812615ec4b61 \ - --hash=sha256:f08aa300b67f1c012100d8eb62d47129e53d1150f4469fd78a29fa3cb68c66f2 \ - --hash=sha256:f2f4710543abec186aee332d6852ef5ae7ce2e9e807a3da570f36de5a732d88e - # via - # tensorboard - # tensorflow - # tensorflow-hub -pyasn1==0.4.8 \ - --hash=sha256:39c7e2ec30515947ff4e87fb6f456dfc6e84857d34be479c9d4a4ba4bf46aa5d \ - --hash=sha256:aef77c9fb94a3ac588e87841208bdec464471d9871bd5050a287cc9a475cd0ba - # via - # pyasn1-modules - # rsa -pyasn1-modules==0.2.8 \ - --hash=sha256:905f84c712230b2c592c19470d3ca8d552de726050d1d1716282a1f6146be65e \ - --hash=sha256:a50b808ffeb97cb3601dd25981f6b016cbb3d31fbf57a8b8a87428e6158d0c74 - # via google-auth -pygments==2.13.0 \ - --hash=sha256:56a8508ae95f98e2b9bdf93a6be5ae3f7d8af858b43e02c5a2ff083726be40c1 \ - --hash=sha256:f643f331ab57ba3c9d89212ee4a2dabc6e94f117cf4eefde99a0574720d14c42 - # via rich -python-dateutil==2.8.2 \ - --hash=sha256:0123cacc1627ae19ddf3c27a5de5bd67ee4586fbdd6440d9748f8abb483d3e86 \ - --hash=sha256:961d03dc3453ebbc59dbdea9e4e11c5651520a876d0f4db161e8674aae935da9 - # via pandas -pytz==2022.6 \ - --hash=sha256:222439474e9c98fced559f1709d89e6c9cbf8d79c794ff3eb9f8800064291427 \ - --hash=sha256:e89512406b793ca39f5971bc999cc538ce125c0e51c27941bef4568b460095e2 - # via pandas -pyyaml==6.0 \ - --hash=sha256:01b45c0191e6d66c470b6cf1b9531a771a83c1c4208272ead47a3ae4f2f603bf \ - --hash=sha256:0283c35a6a9fbf047493e3a0ce8d79ef5030852c51e9d911a27badfde0605293 \ - --hash=sha256:055d937d65826939cb044fc8c9b08889e8c743fdc6a32b33e2390f66013e449b \ - --hash=sha256:07751360502caac1c067a8132d150cf3d61339af5691fe9e87803040dbc5db57 \ - --hash=sha256:0b4624f379dab24d3725ffde76559cff63d9ec94e1736b556dacdfebe5ab6d4b \ - --hash=sha256:0ce82d761c532fe4ec3f87fc45688bdd3a4c1dc5e0b4a19814b9009a29baefd4 \ - --hash=sha256:1e4747bc279b4f613a09eb64bba2ba602d8a6664c6ce6396a4d0cd413a50ce07 \ - --hash=sha256:213c60cd50106436cc818accf5baa1aba61c0189ff610f64f4a3e8c6726218ba \ - --hash=sha256:231710d57adfd809ef5d34183b8ed1eeae3f76459c18fb4a0b373ad56bedcdd9 \ - --hash=sha256:277a0ef2981ca40581a47093e9e2d13b3f1fbbeffae064c1d21bfceba2030287 \ - --hash=sha256:2cd5df3de48857ed0544b34e2d40e9fac445930039f3cfe4bcc592a1f836d513 \ - --hash=sha256:40527857252b61eacd1d9af500c3337ba8deb8fc298940291486c465c8b46ec0 \ - --hash=sha256:432557aa2c09802be39460360ddffd48156e30721f5e8d917f01d31694216782 \ - --hash=sha256:473f9edb243cb1935ab5a084eb238d842fb8f404ed2193a915d1784b5a6b5fc0 \ - --hash=sha256:48c346915c114f5fdb3ead70312bd042a953a8ce5c7106d5bfb1a5254e47da92 \ - --hash=sha256:50602afada6d6cbfad699b0c7bb50d5ccffa7e46a3d738092afddc1f9758427f \ - --hash=sha256:68fb519c14306fec9720a2a5b45bc9f0c8d1b9c72adf45c37baedfcd949c35a2 \ - --hash=sha256:77f396e6ef4c73fdc33a9157446466f1cff553d979bd00ecb64385760c6babdc \ - --hash=sha256:81957921f441d50af23654aa6c5e5eaf9b06aba7f0a19c18a538dc7ef291c5a1 \ - --hash=sha256:819b3830a1543db06c4d4b865e70ded25be52a2e0631ccd2f6a47a2822f2fd7c \ - --hash=sha256:897b80890765f037df3403d22bab41627ca8811ae55e9a722fd0392850ec4d86 \ - --hash=sha256:98c4d36e99714e55cfbaaee6dd5badbc9a1ec339ebfc3b1f52e293aee6bb71a4 \ - --hash=sha256:9df7ed3b3d2e0ecfe09e14741b857df43adb5a3ddadc919a2d94fbdf78fea53c \ - --hash=sha256:9fa600030013c4de8165339db93d182b9431076eb98eb40ee068700c9c813e34 \ - --hash=sha256:a80a78046a72361de73f8f395f1f1e49f956c6be882eed58505a15f3e430962b \ - --hash=sha256:afa17f5bc4d1b10afd4466fd3a44dc0e245382deca5b3c353d8b757f9e3ecb8d \ - --hash=sha256:b3d267842bf12586ba6c734f89d1f5b871df0273157918b0ccefa29deb05c21c \ - --hash=sha256:b5b9eccad747aabaaffbc6064800670f0c297e52c12754eb1d976c57e4f74dcb \ - --hash=sha256:bfaef573a63ba8923503d27530362590ff4f576c626d86a9fed95822a8255fd7 \ - --hash=sha256:c5687b8d43cf58545ade1fe3e055f70eac7a5a1a0bf42824308d868289a95737 \ - --hash=sha256:cba8c411ef271aa037d7357a2bc8f9ee8b58b9965831d9e51baf703280dc73d3 \ - --hash=sha256:d15a181d1ecd0d4270dc32edb46f7cb7733c7c508857278d3d378d14d606db2d \ - --hash=sha256:d4b0ba9512519522b118090257be113b9468d804b19d63c71dbcf4a48fa32358 \ - --hash=sha256:d4db7c7aef085872ef65a8fd7d6d09a14ae91f691dec3e87ee5ee0539d516f53 \ - --hash=sha256:d4eccecf9adf6fbcc6861a38015c2a64f38b9d94838ac1810a9023a0609e1b78 \ - --hash=sha256:d67d839ede4ed1b28a4e8909735fc992a923cdb84e618544973d7dfc71540803 \ - --hash=sha256:daf496c58a8c52083df09b80c860005194014c3698698d1a57cbcfa182142a3a \ - --hash=sha256:dbad0e9d368bb989f4515da330b88a057617d16b6a8245084f1b05400f24609f \ - --hash=sha256:e61ceaab6f49fb8bdfaa0f92c4b57bcfbea54c09277b1b4f7ac376bfb7a7c174 \ - --hash=sha256:f84fbc98b019fef2ee9a1cb3ce93e3187a6df0b2538a651bfb890254ba9f90b5 - # via - # flax - # orbax-checkpoint -requests==2.28.1 \ - --hash=sha256:7c5599b102feddaa661c826c56ab4fee28bfd17f5abca1ebbe3e7f19d7c97983 \ - --hash=sha256:8fefa2a1a1365bf5520aac41836fbee479da67864514bdb821f31ce07ce65349 - # via - # requests-oauthlib - # tensorboard -requests-oauthlib==1.3.1 \ - --hash=sha256:2577c501a2fb8d05a304c09d090d6e47c306fef15809d102b327cf8364bddab5 \ - --hash=sha256:75beac4a47881eeb94d5ea5d6ad31ef88856affe2332b9aafb52c6452ccf0d7a - # via google-auth-oauthlib -rich==11.2.0 \ - --hash=sha256:1a6266a5738115017bb64a66c59c717e7aa047b3ae49a011ede4abdeffc6536e \ - --hash=sha256:d5f49ad91fb343efcae45a2b2df04a9755e863e50413623ab8c9e74f05aee52b - # via flax -rsa==4.9 \ - --hash=sha256:90260d9058e514786967344d0ef75fa8727eed8a7d2e43ce9f4bcf1b536174f7 \ - --hash=sha256:e38464a49c6c85d7f1351b0126661487a7e0a14a50f1675ec50eb34d4f20ef21 - # via google-auth -scipy==1.9.3 \ - --hash=sha256:06d2e1b4c491dc7d8eacea139a1b0b295f74e1a1a0f704c375028f8320d16e31 \ - --hash=sha256:0d54222d7a3ba6022fdf5773931b5d7c56efe41ede7f7128c7b1637700409108 \ - --hash=sha256:1884b66a54887e21addf9c16fb588720a8309a57b2e258ae1c7986d4444d3bc0 \ - --hash=sha256:1a72d885fa44247f92743fc20732ae55564ff2a519e8302fb7e18717c5355a8b \ - --hash=sha256:2318bef588acc7a574f5bfdff9c172d0b1bf2c8143d9582e05f878e580a3781e \ - --hash=sha256:4db5b30849606a95dcf519763dd3ab6fe9bd91df49eba517359e450a7d80ce2e \ - --hash=sha256:545c83ffb518094d8c9d83cce216c0c32f8c04aaf28b92cc8283eda0685162d5 \ - --hash=sha256:5a04cd7d0d3eff6ea4719371cbc44df31411862b9646db617c99718ff68d4840 \ - --hash=sha256:5b88e6d91ad9d59478fafe92a7c757d00c59e3bdc3331be8ada76a4f8d683f58 \ - --hash=sha256:68239b6aa6f9c593da8be1509a05cb7f9efe98b80f43a5861cd24c7557e98523 \ - --hash=sha256:83b89e9586c62e787f5012e8475fbb12185bafb996a03257e9675cd73d3736dd \ - --hash=sha256:83c06e62a390a9167da60bedd4575a14c1f58ca9dfde59830fc42e5197283dab \ - --hash=sha256:90453d2b93ea82a9f434e4e1cba043e779ff67b92f7a0e85d05d286a3625df3c \ - --hash=sha256:abaf921531b5aeaafced90157db505e10345e45038c39e5d9b6c7922d68085cb \ - --hash=sha256:b41bc822679ad1c9a5f023bc93f6d0543129ca0f37c1ce294dd9d386f0a21096 \ - --hash=sha256:c68db6b290cbd4049012990d7fe71a2abd9ffbe82c0056ebe0f01df8be5436b0 \ - --hash=sha256:cff3a5295234037e39500d35316a4c5794739433528310e117b8a9a0c76d20fc \ - --hash=sha256:d01e1dd7b15bd2449c8bfc6b7cc67d630700ed655654f0dfcf121600bad205c9 \ - --hash=sha256:d644a64e174c16cb4b2e41dfea6af722053e83d066da7343f333a54dae9bc31c \ - --hash=sha256:da8245491d73ed0a994ed9c2e380fd058ce2fa8a18da204681f2fe1f57f98f95 \ - --hash=sha256:fbc5c05c85c1a02be77b1ff591087c83bc44579c6d2bd9fb798bb64ea5e1a027 - # via - # jax - # jaxlib -setuptools==65.6.3 \ - --hash=sha256:57f6f22bde4e042978bcd50176fdb381d7c21a9efa4041202288d3737a0c6a54 \ - --hash=sha256:a7620757bf984b58deaf32fc8a4577a9bbc0850cf92c20e1ce41c38c19e5fb75 - # via - # tensorboard - # tensorflow -six==1.16.0 \ - --hash=sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926 \ - --hash=sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254 - # via - # -r tfjs-converter/python/requirements.txt - # astunparse - # google-auth - # google-pasta - # python-dateutil - # tensorflow - # tensorflow-decision-forests -tensorboard==2.13.0 \ - --hash=sha256:ab69961ebddbddc83f5fa2ff9233572bdad5b883778c35e4fe94bf1798bd8481 - # via tensorflow -tensorboard-data-server==0.7.0 \ - --hash=sha256:64aa1be7c23e80b1a42c13b686eb0875bb70f5e755f4d2b8de5c1d880cf2267f \ - --hash=sha256:753d4214799b31da7b6d93837959abebbc6afa86e69eacf1e9a317a48daa31eb \ - --hash=sha256:eb7fa518737944dbf4f0cf83c2e40a7ac346bf91be2e6a0215de98be74e85454 - # via tensorboard -tensorflow==2.13.0 \ - --hash=sha256:00060c5516a61e30c51936084ebc37091d116efe9ae74b2818cbd8b2006218e7 \ - --hash=sha256:06559eeaa69e6561cccbe2d02b015bcec663e875c8bbc4643f55692476e52147 \ - --hash=sha256:076d953a1508dc58bf95f30f58bcc9ee364b1353c61e143cb20c2dada91afb05 \ - --hash=sha256:11ad6a7ff49b4a690fbf37a5adaf28ba2686350a859c5f13c58dc8d2cc670375 \ - --hash=sha256:19ee67901702b26787ad685cca65730c163c101c0c2f238a2584d714e0fa8c25 \ - --hash=sha256:2822ac48c38d69b7fb104e606dacbd763c4bf5d3b20791f25be16a5076d01912 \ - --hash=sha256:5e0fdadec59de3d11c5b5129ddc38e739bde7aa13095b82e19d4380e14d04999 \ - --hash=sha256:6fff426661d286a4c634da44275d2ea2b951f392f3e65c8603681e7cb040586a \ - --hash=sha256:72d68b8c2f382e2d01b956c8ba516c0a7d5dad98111dd351bf82bfa646aa1c72 \ - --hash=sha256:7a08c0e2938ed5b642a8787678123827477b81d316055d5073fff82fa183eb82 \ - --hash=sha256:89125443e998548059c4e4a129dfab2b1ff7f2fd4c8eaed97842c3cd9b663101 \ - --hash=sha256:948003b5a23b72b3d89746d729e62ec5f01e47460f05521b2211d95069f569ba \ - --hash=sha256:9c04bc3023b6c4cfb9ee9759c3f03f21993891b4c345df52eb5519204fbf28c0 \ - --hash=sha256:b2978b39e8b3919059b5fd9e28508d50a77965d06ed0b537ed71c97de22dabdf \ - --hash=sha256:cbb83561bb7d55859eaefc70c674e58713d4e10c10927423ed836a5289bbfa86 \ - --hash=sha256:de77306c0c22c9d8754f54700752ac3a1efee895c5357308e6594436404bfbc0 \ - --hash=sha256:e0cf94d36ceaba8f158c6e15404a81fd5b3aa4cb04147c674cf55bd1aec78154 \ - --hash=sha256:e8f0b69ee2f800399fc6bc7ec55fecfa33662d136e425485959d90638f32a32a \ - --hash=sha256:fa7abe265cc3ebccc9b405a280bf674824c6d85df5e6ccfa985987b3c9d265b4 \ - --hash=sha256:fb2ff1129c93e853c19897d6a22ed0ec56387f5c6290ec03dec1c6f7b80bc396 - # via - # -r tfjs-converter/python/requirements.txt - # tensorflow-decision-forests -tensorflow-decision-forests==1.5.0 \ - --hash=sha256:04fd913627d08fe54514b179c612e87eebf55f1448bf01951660985dfa14a6e1 \ - --hash=sha256:1209a2832ac65f8f74bd9d0c1d58f3f8b771e7fa5c9d504c547842311647b7d4 \ - --hash=sha256:22e3835acbfbd5356bb2f8e0c973dfc40ef80a7924b793e90c811158448cfe77 \ - --hash=sha256:43ffd4fba1c3376f58a9dcee943df80f0cff6e47224d109ad0389a723c74947c \ - --hash=sha256:4a0df3a3be5751594d49f5a8f99977b553cf1c42f320b952ac2a2f67b85283f5 \ - --hash=sha256:5ec4297eb5e7c4110cf8aae89e9b08b9ad2cb725e3e63c89c78304c0d7235d24 \ - --hash=sha256:804f6bed277b5c5b6d2bd85738a64973d5d3e8e6ac06abf6098545740245cedc \ - --hash=sha256:a43af2a5a8c34e550bf549c6cad96da271979efc5a8ec988f6f76cc90770415a \ - --hash=sha256:d137241dad8e884d0c937aa8769fe0768324804e9ba666a78b7b5f2f536a0bd2 \ - --hash=sha256:d685e92abe44920ee6d89394ec4e075bb1ada7402f673566146e1b476a576e96 \ - --hash=sha256:f5d8c3730578bda55a8f520ae39b0c9b2560d69bd53b57882e5371c1a82ba098 \ - --hash=sha256:fbd403acf736bb9b4afd2985d9056e6d5043fc4b9a31bd05e5fcae2b1d413dc3 - # via -r tfjs-converter/python/requirements.txt -tensorflow-estimator==2.13.0 \ - --hash=sha256:6f868284eaa654ae3aa7cacdbef2175d0909df9fcf11374f5166f8bf475952aa - # via tensorflow -tensorflow-hub==0.14.0 \ - --hash=sha256:519c6b56c4d304667fbd8ce66bd637e6a750c901215468db2cc6bfd0739bb0b0 - # via -r tfjs-converter/python/requirements.txt -tensorflow-io-gcs-filesystem==0.28.0 \ - --hash=sha256:00cf6a92f1f9f90b2ba2d728870bcd2a70b116316d0817ab0b91dd390c25b3fd \ - --hash=sha256:22753dc28c949bfaf29b573ee376370762c88d80330fe95cfb291261eb5e927a \ - --hash=sha256:366e1eff8dbd6b64333d7061e2a8efd081ae4742614f717ced08d8cc9379eb50 \ - --hash=sha256:52988659f405166df79905e9859bc84ae2a71e3ff61522ba32a95e4dce8e66d2 \ - --hash=sha256:5fbef5836e70026245d8d9e692c44dae2c6dbc208c743d01f5b7a2978d6b6bc6 \ - --hash=sha256:698d7f89e09812b9afeb47c3860797343a22f997c64ab9dab98132c61daa8a7d \ - --hash=sha256:6d95f306ff225c5053fd06deeab3e3a2716357923cb40c44d566c11be779caa3 \ - --hash=sha256:9484893779324b2d34874b0aacf3b824eb4f22d782e75df029cbccab2e607974 \ - --hash=sha256:a6670e0da16c884267e896ea5c3334d6fd319bd6ff7cf917043a9f3b2babb1b3 \ - --hash=sha256:b6e2d275020fb4d1a952cd3fa546483f4e46ad91d64e90d3458e5ca3d12f6477 \ - --hash=sha256:bbf245883aa52ec687b66d0fcbe0f5f0a92d98c0b1c53e6a736039a3548d29a1 \ - --hash=sha256:bfed720fc691d3f45802a7bed420716805aef0939c11cebf25798906201f626e \ - --hash=sha256:c5d99f56c12a349905ff684142e4d2df06ae68ecf50c4aad5449a5f81731d858 \ - --hash=sha256:cc062ce13ec95fb64b1fd426818a6d2b0e5be9692bc0e43a19cce115b6da4336 \ - --hash=sha256:f76cbe1a784841c223f6861e5f6c7e53aa6232cb626d57e76881a0638c365de6 - # via tensorflow -tensorstore==0.1.41 \ - --hash=sha256:025a62bb9122364885e90469af05fec2f62ad05f46ff46d9eae1d76ad9125563 \ - --hash=sha256:2aa81581f768382a38584698a3fcb07a533fc391067467326656f24ab019cba1 \ - --hash=sha256:2c4c578e82866b8f764de871ff7e0a81fe0949ac3565d8d2eb10f29e43020a52 \ - --hash=sha256:2d65ea0fd5ac96a9d577f16bb917ae8a0a121d2093472bfb7bd762b1e32c753b \ - --hash=sha256:5168f7f71e51da7d6cc85a11cd5d102d9eae750d5f5a3ee90cc9ebae10226621 \ - --hash=sha256:620ad460023eeeae721e2e25a2a3e2b608f09cd169c1f68af7043c6d44e88cbf \ - --hash=sha256:634c78fd62cd6e5357291ccb9671e43262f818f9cf7cc58f701b5bd80d1c1ef7 \ - --hash=sha256:6b3b14616f9141b12e61c0c46d1c954927f7f307498d8b9d2261ff2bd4005bbd \ - --hash=sha256:74e317ef7cba8c0208c5d8d9f1406eac37f58e8f92b3f7caa9a72b8b118b1c09 \ - --hash=sha256:803fa2bcbc93f43fe0b3b5b70d78882d3b266a70d419acfc7fdd515f89cba79b \ - --hash=sha256:8b5dbc0e809c90377527e0f65829d6abcdf5c69f892f433ed2cb8508d4ba519a \ - --hash=sha256:8df13f990acc58889160eff5b2e1df029cdfffdf020ce5044e655242c1016bb1 \ - --hash=sha256:91549a16b1ef2d6bc5ac8f28eed32737001fcfe33309f1ba126cd4c1e08b971b \ - --hash=sha256:96fb62a880bf25da7e12ad4bba00a82deb2daf6f59050e8db6f0b04107120799 \ - --hash=sha256:a99b87b65dfca65a830503bdfd2e5168a69b5290807cb8e922fa5a1acea2edec \ - --hash=sha256:bbd58cedddce29216703a63ea42db010b6151c7bc05ac741af50aa31e31491fb \ - --hash=sha256:c400aa46fc814edd69c72fcdf202dbd8c666ae684b534e81350a3a30ab16bdfc - # via - # flax - # orbax-checkpoint -termcolor==2.1.1 \ - --hash=sha256:67cee2009adc6449c650f6bcf3bdeed00c8ba53a8cda5362733c53e0a39fb70b \ - --hash=sha256:fa852e957f97252205e105dd55bbc23b419a70fec0085708fc0515e399f304fd - # via tensorflow -toolz==0.12.0 \ - --hash=sha256:2059bd4148deb1884bb0eb770a3cde70e7f954cfbbdc2285f1f2de01fd21eb6f \ - --hash=sha256:88c570861c440ee3f2f6037c4654613228ff40c93a6c25e0eba70d17282c6194 - # via chex -typing-extensions==4.4.0 \ - --hash=sha256:1511434bb92bf8dd198c12b1cc812e800d4181cfcb867674e0f8279cc93087aa \ - --hash=sha256:16fa4864408f655d35ec496218b85f79b3437c829e93320c7c9215ccfd92489e - # via - # flax - # optax - # orbax-checkpoint - # tensorflow -urllib3==1.26.13 \ - --hash=sha256:47cc05d99aaa09c9e72ed5809b60e7ba354e64b59c9c173ac3018642d8bb41fc \ - --hash=sha256:c083dd0dce68dbfbe1129d5271cb90f9447dea7d52097c6e0126120c521ddea8 - # via requests -werkzeug==2.2.2 \ - --hash=sha256:7ea2d48322cc7c0f8b3a215ed73eabd7b5d75d0b50e31ab006286ccff9e00b8f \ - --hash=sha256:f979ab81f58d7318e064e99c4506445d60135ac5cd2e177a2de0089bfd4c9bd5 - # via tensorboard -wheel==0.38.4 \ - --hash=sha256:965f5259b566725405b05e7cf774052044b1ed30119b5d586b2703aafe8719ac \ - --hash=sha256:b60533f3f5d530e971d6737ca6d58681ee434818fab630c83a734bb10c083ce8 - # via - # astunparse - # tensorboard - # tensorflow-decision-forests -wrapt==1.14.1 \ - --hash=sha256:00b6d4ea20a906c0ca56d84f93065b398ab74b927a7a3dbd470f6fc503f95dc3 \ - --hash=sha256:01c205616a89d09827986bc4e859bcabd64f5a0662a7fe95e0d359424e0e071b \ - --hash=sha256:02b41b633c6261feff8ddd8d11c711df6842aba629fdd3da10249a53211a72c4 \ - --hash=sha256:07f7a7d0f388028b2df1d916e94bbb40624c59b48ecc6cbc232546706fac74c2 \ - --hash=sha256:11871514607b15cfeb87c547a49bca19fde402f32e2b1c24a632506c0a756656 \ - --hash=sha256:1b376b3f4896e7930f1f772ac4b064ac12598d1c38d04907e696cc4d794b43d3 \ - --hash=sha256:21ac0156c4b089b330b7666db40feee30a5d52634cc4560e1905d6529a3897ff \ - --hash=sha256:257fd78c513e0fb5cdbe058c27a0624c9884e735bbd131935fd49e9fe719d310 \ - --hash=sha256:2b39d38039a1fdad98c87279b48bc5dce2c0ca0d73483b12cb72aa9609278e8a \ - --hash=sha256:2cf71233a0ed05ccdabe209c606fe0bac7379fdcf687f39b944420d2a09fdb57 \ - --hash=sha256:2fe803deacd09a233e4762a1adcea5db5d31e6be577a43352936179d14d90069 \ - --hash=sha256:3232822c7d98d23895ccc443bbdf57c7412c5a65996c30442ebe6ed3df335383 \ - --hash=sha256:34aa51c45f28ba7f12accd624225e2b1e5a3a45206aa191f6f9aac931d9d56fe \ - --hash=sha256:36f582d0c6bc99d5f39cd3ac2a9062e57f3cf606ade29a0a0d6b323462f4dd87 \ - --hash=sha256:380a85cf89e0e69b7cfbe2ea9f765f004ff419f34194018a6827ac0e3edfed4d \ - --hash=sha256:40e7bc81c9e2b2734ea4bc1aceb8a8f0ceaac7c5299bc5d69e37c44d9081d43b \ - --hash=sha256:43ca3bbbe97af00f49efb06e352eae40434ca9d915906f77def219b88e85d907 \ - --hash=sha256:4fcc4649dc762cddacd193e6b55bc02edca674067f5f98166d7713b193932b7f \ - --hash=sha256:5a0f54ce2c092aaf439813735584b9537cad479575a09892b8352fea5e988dc0 \ - --hash=sha256:5a9a0d155deafd9448baff28c08e150d9b24ff010e899311ddd63c45c2445e28 \ - --hash=sha256:5b02d65b9ccf0ef6c34cba6cf5bf2aab1bb2f49c6090bafeecc9cd81ad4ea1c1 \ - --hash=sha256:60db23fa423575eeb65ea430cee741acb7c26a1365d103f7b0f6ec412b893853 \ - --hash=sha256:642c2e7a804fcf18c222e1060df25fc210b9c58db7c91416fb055897fc27e8cc \ - --hash=sha256:6a9a25751acb379b466ff6be78a315e2b439d4c94c1e99cb7266d40a537995d3 \ - --hash=sha256:6b1a564e6cb69922c7fe3a678b9f9a3c54e72b469875aa8018f18b4d1dd1adf3 \ - --hash=sha256:6d323e1554b3d22cfc03cd3243b5bb815a51f5249fdcbb86fda4bf62bab9e164 \ - --hash=sha256:6e743de5e9c3d1b7185870f480587b75b1cb604832e380d64f9504a0535912d1 \ - --hash=sha256:709fe01086a55cf79d20f741f39325018f4df051ef39fe921b1ebe780a66184c \ - --hash=sha256:7b7c050ae976e286906dd3f26009e117eb000fb2cf3533398c5ad9ccc86867b1 \ - --hash=sha256:7d2872609603cb35ca513d7404a94d6d608fc13211563571117046c9d2bcc3d7 \ - --hash=sha256:7ef58fb89674095bfc57c4069e95d7a31cfdc0939e2a579882ac7d55aadfd2a1 \ - --hash=sha256:80bb5c256f1415f747011dc3604b59bc1f91c6e7150bd7db03b19170ee06b320 \ - --hash=sha256:81b19725065dcb43df02b37e03278c011a09e49757287dca60c5aecdd5a0b8ed \ - --hash=sha256:833b58d5d0b7e5b9832869f039203389ac7cbf01765639c7309fd50ef619e0b1 \ - --hash=sha256:88bd7b6bd70a5b6803c1abf6bca012f7ed963e58c68d76ee20b9d751c74a3248 \ - --hash=sha256:8ad85f7f4e20964db4daadcab70b47ab05c7c1cf2a7c1e51087bfaa83831854c \ - --hash=sha256:8c0ce1e99116d5ab21355d8ebe53d9460366704ea38ae4d9f6933188f327b456 \ - --hash=sha256:8d649d616e5c6a678b26d15ece345354f7c2286acd6db868e65fcc5ff7c24a77 \ - --hash=sha256:903500616422a40a98a5a3c4ff4ed9d0066f3b4c951fa286018ecdf0750194ef \ - --hash=sha256:9736af4641846491aedb3c3f56b9bc5568d92b0692303b5a305301a95dfd38b1 \ - --hash=sha256:988635d122aaf2bdcef9e795435662bcd65b02f4f4c1ae37fbee7401c440b3a7 \ - --hash=sha256:9cca3c2cdadb362116235fdbd411735de4328c61425b0aa9f872fd76d02c4e86 \ - --hash=sha256:9e0fd32e0148dd5dea6af5fee42beb949098564cc23211a88d799e434255a1f4 \ - --hash=sha256:9f3e6f9e05148ff90002b884fbc2a86bd303ae847e472f44ecc06c2cd2fcdb2d \ - --hash=sha256:a85d2b46be66a71bedde836d9e41859879cc54a2a04fad1191eb50c2066f6e9d \ - --hash=sha256:a9a52172be0b5aae932bef82a79ec0a0ce87288c7d132946d645eba03f0ad8a8 \ - --hash=sha256:aa31fdcc33fef9eb2552cbcbfee7773d5a6792c137b359e82879c101e98584c5 \ - --hash=sha256:b014c23646a467558be7da3d6b9fa409b2c567d2110599b7cf9a0c5992b3b471 \ - --hash=sha256:b21bb4c09ffabfa0e85e3a6b623e19b80e7acd709b9f91452b8297ace2a8ab00 \ - --hash=sha256:b5901a312f4d14c59918c221323068fad0540e34324925c8475263841dbdfe68 \ - --hash=sha256:b9b7a708dd92306328117d8c4b62e2194d00c365f18eff11a9b53c6f923b01e3 \ - --hash=sha256:d1967f46ea8f2db647c786e78d8cc7e4313dbd1b0aca360592d8027b8508e24d \ - --hash=sha256:d52a25136894c63de15a35bc0bdc5adb4b0e173b9c0d07a2be9d3ca64a332735 \ - --hash=sha256:d77c85fedff92cf788face9bfa3ebaa364448ebb1d765302e9af11bf449ca36d \ - --hash=sha256:d79d7d5dc8a32b7093e81e97dad755127ff77bcc899e845f41bf71747af0c569 \ - --hash=sha256:dbcda74c67263139358f4d188ae5faae95c30929281bc6866d00573783c422b7 \ - --hash=sha256:ddaea91abf8b0d13443f6dac52e89051a5063c7d014710dcb4d4abb2ff811a59 \ - --hash=sha256:dee0ce50c6a2dd9056c20db781e9c1cfd33e77d2d569f5d1d9321c641bb903d5 \ - --hash=sha256:dee60e1de1898bde3b238f18340eec6148986da0455d8ba7848d50470a7a32fb \ - --hash=sha256:e2f83e18fe2f4c9e7db597e988f72712c0c3676d337d8b101f6758107c42425b \ - --hash=sha256:e3fb1677c720409d5f671e39bac6c9e0e422584e5f518bfd50aa4cbbea02433f \ - --hash=sha256:ee2b1b1769f6707a8a445162ea16dddf74285c3964f605877a20e38545c3c462 \ - --hash=sha256:ee6acae74a2b91865910eef5e7de37dc6895ad96fa23603d1d27ea69df545015 \ - --hash=sha256:ef3f72c9666bba2bab70d2a8b79f2c6d2c1a42a7f7e2b0ec83bb2f9e383950af - # via tensorflow -wurlitzer==3.0.3 \ - --hash=sha256:224f5fe70618be3872c05dfddc8c457191ec1870654596279fcc1edadebe3e5b \ - --hash=sha256:ffcc584109f5ecd5244abfde4534f22140f8735a4890ce1abd90b4e503f5f427 - # via tensorflow-decision-forests -zipp==3.11.0 \ - --hash=sha256:83a28fcb75844b5c0cdaf5aa4003c2d728c77e05f5aeabe8e95e56727005fbaa \ - --hash=sha256:a7a22e05929290a67401440b39690ae6563279bced5f314609d9d03798f56766 - # via - # importlib-metadata - # importlib-resources diff --git a/tfjs-master/tfjs-converter/python/run-python-tests.sh b/tfjs-master/tfjs-converter/python/run-python-tests.sh deleted file mode 100644 index 24c86a311..000000000 --- a/tfjs-master/tfjs-converter/python/run-python-tests.sh +++ /dev/null @@ -1,74 +0,0 @@ -#!/usr/bin/env bash -# Copyright 2018 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================== - -# A script that runs all Python unit tests in tfjs-layers. - -function print_usage() { - echo "Usage:" - echo " run-python-tests.sh " - echo -} - -set -e - -SCRIPTS_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" - -TEST_FILES="$(find "${SCRIPTS_DIR}" -name '*_test.py')" - -pip install virtualenv - -TMP_VENV_DIR="$(mktemp -u).venv" -virtualenv -p "python" "${TMP_VENV_DIR}" -source "${TMP_VENV_DIR}/local/bin/activate" - -# There is one argument (requirements_file), please update this constant when -# you adding more arguments. -ARGS_COUNT=1 - -# Default requirements file name. -REQ_FILE="${SCRIPTS_DIR}/requirements-dev.txt" - -# Show the usage message if there are too many arguments. -if [[ $# > ARGS_COUNT ]]; then - print_usage - exit 1 -fi - -# Use the user specified requirements file name. -if [[ $# == 1 ]]; then - REQ_FILE=$1 -fi -pip install -r "${REQ_FILE}" - -# Run pylint for tensorflowjs directory -cd "${SCRIPTS_DIR}" -pylint --rcfile=.pylintrc tensorflowjs - -export PYTHONPATH=".:${PYTHONPATH}" -for TEST_FILE in ${TEST_FILES}; do - echo - echo "====== Running test: ${TEST_FILE} ======" - echo - python "${TEST_FILE}" -done - -echo -echo "All tests passed." -echo - -# Clean up -deactivate -rm -rf "${TMP_VENV_DIR}" diff --git a/tfjs-master/tfjs-converter/python/setup.cfg b/tfjs-master/tfjs-converter/python/setup.cfg deleted file mode 100644 index b88034e41..000000000 --- a/tfjs-master/tfjs-converter/python/setup.cfg +++ /dev/null @@ -1,2 +0,0 @@ -[metadata] -description-file = README.md diff --git a/tfjs-master/tfjs-converter/python/setup.py b/tfjs-master/tfjs-converter/python/setup.py deleted file mode 100644 index d04a2e1e8..000000000 --- a/tfjs-master/tfjs-converter/python/setup.py +++ /dev/null @@ -1,110 +0,0 @@ -# Copyright 2018 Google LLC. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================== -"""Build pip wheel for model_converter.""" - -import os -import setuptools -from tensorflowjs import version - -DIR_NAME = os.path.dirname(__file__) - -def _get_requirements(file): - "Reads the requirements file and returns the packages" - with open(os.path.join(DIR_NAME, file), 'r') as requirements: - return requirements.readlines() - -def get_extra_requires(path, add_all=True): - import re - from collections import defaultdict - - with open(path) as fp: - extra_deps = defaultdict(set) - for k in fp: - if k.strip() and not k.startswith('#'): - tags = set() - if ':' in k: - k, v = k.split(':') - tags.update(vv.strip() for vv in v.split(',')) - tags.add(re.split('[<=>]', k)[0]) - for t in tags: - extra_deps[t].add(k) - - # add tag `all` at the end - if add_all: - extra_deps['all'] = set(vv for v in extra_deps.values() for vv in v) - - return extra_deps - -CONSOLE_SCRIPTS = [ - 'tensorflowjs_converter = tensorflowjs.converters.converter:pip_main', - 'tensorflowjs_wizard = tensorflowjs.converters.wizard:pip_main', -] - -setuptools.setup( - name='tensorflowjs', - version=version.version, - description='Python Libraries and Tools for TensorFlow.js', - url='https://js.tensorflow.org/', - author='Google LLC', - author_email='opensource@google.com', - classifiers=[ - 'Development Status :: 3 - Alpha', - 'Intended Audience :: Developers', - 'Intended Audience :: Education', - 'Intended Audience :: Science/Research', - 'License :: OSI Approved :: Apache Software License', - 'Programming Language :: JavaScript', - 'Programming Language :: Python :: 2', - 'Programming Language :: Python :: 3', - 'Topic :: Scientific/Engineering', - 'Topic :: Scientific/Engineering :: Mathematics', - 'Topic :: Scientific/Engineering :: Artificial Intelligence', - 'Topic :: Software Development', - 'Topic :: Software Development :: Libraries', - 'Topic :: Software Development :: Libraries :: Python Modules', - ], - py_modules=[ - 'tensorflowjs', - 'tensorflowjs.version', - 'tensorflowjs.quantization', - 'tensorflowjs.read_weights', - 'tensorflowjs.resource_loader', - 'tensorflowjs.write_weights', - 'tensorflowjs.converters', - 'tensorflowjs.converters.common', - 'tensorflowjs.converters.converter', - 'tensorflowjs.converters.fold_batch_norms', - 'tensorflowjs.converters.fuse_depthwise_conv2d', - 'tensorflowjs.converters.fuse_prelu', - 'tensorflowjs.converters.graph_rewrite_util', - 'tensorflowjs.converters.keras_h5_conversion', - 'tensorflowjs.converters.keras_tfjs_loader', - 'tensorflowjs.converters.jax_conversion', - 'tensorflowjs.converters.tf_saved_model_conversion_v2', - 'tensorflowjs.converters.wizard', - ], - include_package_data=True, - packages=['tensorflowjs/op_list'], - package_data={ - 'tensorflowjs/op_list': ['*.json'] - }, - install_requires=_get_requirements('requirements.txt'), - extras_require=get_extra_requires('extra-requirements.txt'), - entry_points={ - 'console_scripts': CONSOLE_SCRIPTS, - }, - license='Apache 2.0', - keywords='tensorflow javascript machine deep learning converter', -) diff --git a/tfjs-master/tfjs-converter/python/tensorflowjs/BUILD.bazel b/tfjs-master/tfjs-converter/python/tensorflowjs/BUILD.bazel deleted file mode 100644 index 2c3f02d7b..000000000 --- a/tfjs-master/tfjs-converter/python/tensorflowjs/BUILD.bazel +++ /dev/null @@ -1,212 +0,0 @@ -load("@rules_python//python:defs.bzl", "py_library", "py_test") -load("@tensorflowjs_dev_deps//:requirements.bzl", "requirement") - -package( - default_visibility = [ - ":__subpackages__", - ], -) - -licenses(["notice"]) - -exports_files([ - "LICENSE", -]) - -py_library( - name = "tensorflowjs", - srcs = ["__init__.py"], - data = [ - "//tfjs-converter/python/tensorflowjs/op_list:ops", - ], - srcs_version = "PY3", - visibility = ["//visibility:public"], - deps = [ - ":resource_loader", - ":version", - ":write_weights", - "//tfjs-converter/python/tensorflowjs/converters", - ], -) - -py_library( - name = "expect_flax_installed", - # This is a dummy rule used as a Flax dependency in open-source. - # We expect JAX to already be installed on the system, e.g. via - # `pip install flax`. - deps = [requirement("flax")], -) - -py_library( - name = "expect_h5py_installed", - # This is a dummy rule used as a h5py dependency in open-source. - # We expect h5py to already be installed on the system, e.g. via - # `pip install h5py`. - deps = [requirement("h5py")], -) - -py_library( - name = "expect_jax_installed", - # This is a dummy rule used as a JAX dependency in open-source. - # We expect JAX to already be installed on the system, e.g. via - # `pip install jax`. - deps = [ - requirement("jax"), - requirement("importlib_resources"), - ], -) - -py_library( - name = "expect_jax2tf_installed", - # This is a dummy rule used as a jax2tf dependency in open-source. - # We expect jax2tf to already be installed on the system, e.g. via - # `pip install jax`. - deps = [requirement("jax")], -) - -py_library( - name = "expect_numpy_installed", - # This is a dummy rule used as a numpy dependency in open-source. - # We expect numpy to already be installed on the system, e.g. via - # `pip install numpy`. - deps = [requirement("numpy")], -) - -py_library( - name = "expect_tensorflow_installed", - # This is a dummy rule used as a tensorflow dependency in open-source. - # We expect tensorflow to already be installed on the system, e.g. via - # `pip install tensorflow` or `pip install tensorflow-gpu`. - deps = [requirement("tensorflow")], -) - -py_library( - name = "expect_tensorflow_decision_forests_installed", - # This is a dummy rule used as a tensorflow dependency in open-source. - # We expect tensorflow-decision-forests to already be installed on - # the system, e.g. via - # `pip install tensorflow-decision-forests`. - deps = [requirement("tensorflow-decision-forests")], -) - -py_library( - name = "expect_tensorflow_hub_installed", - # This is a dummy rule used as a tensorflow_hub dependency in open-source. - # We expect tensorflow to already be installed on the system, e.g. via - # `pip install tensorflow` or `pip install tensorflow-gpu`. - deps = [requirement("tensorflow-hub")], -) - -py_library( - name = "expect_PyInquirer_installed", - # This is a dummy rule used as a PyInquirer dependency in open-source. - # We expect PyInquirer to already be installed on the system, e.g. via - # `pip install PyInquirer`. - deps = [requirement("PyInquirer")], -) - -py_library( - name = "expect_packaging_installed", - deps = [requirement("packaging")], -) - -py_library( - name = "expect_debugpy_installed", - # debugpy is used for interactive debugging with vscode - deps = [requirement("debugpy")], -) - -py_library( - name = "quantization", - srcs = ["quantization.py"], - srcs_version = "PY3", - deps = [ - ":expect_numpy_installed", - ], -) - -py_library( - name = "write_weights", - srcs = ["write_weights.py"], - srcs_version = "PY3", - deps = [ - ":expect_numpy_installed", - ":expect_tensorflow_installed", - ":quantization", - ":read_weights", - ], -) - -py_library( - name = "read_weights", - srcs = ["read_weights.py"], - srcs_version = "PY3", - deps = [ - ":expect_numpy_installed", - ":quantization", - ], -) - -py_library( - name = "resource_loader", - srcs = ["resource_loader.py"], - srcs_version = "PY3", -) - -py_library( - name = "version", - srcs = ["version.py"], - srcs_version = "PY3", - deps = [], -) - -py_test( - name = "quantization_test", - srcs = ["quantization_test.py"], - imports = [".."], - srcs_version = "PY3", - tags = ["ci"], - deps = [ - ":expect_numpy_installed", - ":quantization", - ], -) - -py_test( - name = "write_weights_test", - srcs = ["write_weights_test.py"], - imports = [".."], - srcs_version = "PY3", - tags = ["ci"], - deps = [ - ":expect_numpy_installed", - ":expect_tensorflow_installed", - ":write_weights", - ], -) - -py_test( - name = "read_weights_test", - srcs = ["read_weights_test.py"], - imports = [".."], - srcs_version = "PY3", - tags = ["ci"], - deps = [ - ":expect_numpy_installed", - ":expect_tensorflow_installed", - ":read_weights", - ":write_weights", - ], -) - -py_test( - name = "resource_loader_test", - srcs = ["resource_loader_test.py"], - data = ["//tfjs-converter/python/tensorflowjs/op_list:ops"], - imports = [".."], - srcs_version = "PY3", - tags = ["ci"], - deps = [ - ":resource_loader", - ], -) diff --git a/tfjs-master/tfjs-converter/python/tensorflowjs/__init__.py b/tfjs-master/tfjs-converter/python/tensorflowjs/__init__.py deleted file mode 100644 index 946f94954..000000000 --- a/tfjs-master/tfjs-converter/python/tensorflowjs/__init__.py +++ /dev/null @@ -1,25 +0,0 @@ -# Copyright 2018 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================== - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -# pylint: disable=unused-imports -from tensorflowjs import converters -from tensorflowjs import quantization -from tensorflowjs import version - -__version__ = version.version diff --git a/tfjs-master/tfjs-converter/python/tensorflowjs/converters/BUILD.bazel b/tfjs-master/tfjs-converter/python/tensorflowjs/converters/BUILD.bazel deleted file mode 100644 index df2bfac33..000000000 --- a/tfjs-master/tfjs-converter/python/tensorflowjs/converters/BUILD.bazel +++ /dev/null @@ -1,354 +0,0 @@ -load("@rules_python//python:defs.bzl", "py_library", "py_test") - -package( - default_visibility = [ - "//tfjs-converter/python/tensorflowjs:__subpackages__", - ], - licenses = ["notice"], # Apache 2.0 -) - -py_library( - name = "converters", - srcs = ["__init__.py"], - srcs_version = "PY3", - visibility = ["//visibility:public"], - deps = [ - ":converter", - ":jax_conversion", - ":keras_h5_conversion", - ":keras_tfjs_loader", - ":tf_saved_model_conversion_v2", - ":wizard", - ], -) - -py_library( - name = "common", - srcs = ["common.py"], - srcs_version = "PY3", - deps = ["//tfjs-converter/python/tensorflowjs:version"], -) - -py_library( - name = "tf_module_mapper", - srcs = ["tf_module_mapper.py"], - srcs_version = "PY3", - deps = [], -) - -py_library( - name = "keras_h5_conversion", - srcs = ["keras_h5_conversion.py"], - srcs_version = "PY3", - deps = [ - ":common", - "//tfjs-converter/python/tensorflowjs:expect_h5py_installed", - "//tfjs-converter/python/tensorflowjs:expect_numpy_installed", - "//tfjs-converter/python/tensorflowjs:write_weights", - ], -) - -py_test( - name = "keras_h5_conversion_test", - srcs = ["keras_h5_conversion_test.py"], - imports = ["../.."], - srcs_version = "PY3", - tags = ["ci"], - deps = [ - ":keras_h5_conversion", - "//tfjs-converter/python/tensorflowjs:expect_h5py_installed", - "//tfjs-converter/python/tensorflowjs:expect_numpy_installed", - "//tfjs-converter/python/tensorflowjs:expect_tensorflow_installed", - "//tfjs-converter/python/tensorflowjs:version", - ], -) - -py_library( - name = "keras_tfjs_loader", - srcs = ["keras_tfjs_loader.py"], - srcs_version = "PY3", - deps = [ - ":keras_h5_conversion", - ":tf_module_mapper", - "//tfjs-converter/python/tensorflowjs:expect_numpy_installed", - "//tfjs-converter/python/tensorflowjs:read_weights", - ], -) - -py_test( - name = "keras_tfjs_loader_test", - srcs = ["keras_tfjs_loader_test.py"], - imports = ["../.."], - srcs_version = "PY3", - tags = ["ci"], - deps = [ - ":keras_h5_conversion", - ":keras_tfjs_loader", - ":tf_module_mapper", - "//tfjs-converter/python/tensorflowjs:expect_numpy_installed", - "//tfjs-converter/python/tensorflowjs:expect_tensorflow_installed", - ], -) - -py_library( - name = "graph_rewrite_util", - srcs = ["graph_rewrite_util.py"], - srcs_version = "PY3", - deps = ["//tfjs-converter/python/tensorflowjs:version"], -) - -py_library( - name = "fuse_prelu", - srcs = ["fuse_prelu.py"], - srcs_version = "PY3", - deps = [ - ":graph_rewrite_util", - "//tfjs-converter/python/tensorflowjs:expect_numpy_installed", - "//tfjs-converter/python/tensorflowjs:expect_tensorflow_installed", - ], -) - -py_test( - name = "fuse_prelu_test", - srcs = ["fuse_prelu_test.py"], - imports = ["../.."], - srcs_version = "PY3", - tags = ["ci"], - deps = [ - ":fuse_prelu", - ":tf_saved_model_conversion_v2", - "//tfjs-converter/python/tensorflowjs:expect_numpy_installed", - "//tfjs-converter/python/tensorflowjs:expect_tensorflow_installed", - ], -) - -py_library( - name = "fold_batch_norms", - srcs = ["fold_batch_norms.py"], - srcs_version = "PY3", - deps = [ - ":graph_rewrite_util", - "//tfjs-converter/python/tensorflowjs:expect_numpy_installed", - "//tfjs-converter/python/tensorflowjs:expect_tensorflow_installed", - ], -) - -py_test( - name = "fold_batch_norms_test", - srcs = ["fold_batch_norms_test.py"], - imports = ["../.."], - srcs_version = "PY3", - tags = ["ci"], - deps = [ - ":fold_batch_norms", - "//tfjs-converter/python/tensorflowjs:expect_numpy_installed", - "//tfjs-converter/python/tensorflowjs:expect_tensorflow_installed", - ], -) - -py_library( - name = "fuse_depthwise_conv2d", - srcs = ["fuse_depthwise_conv2d.py"], - srcs_version = "PY3", - deps = [ - ":graph_rewrite_util", - "//tfjs-converter/python/tensorflowjs:expect_numpy_installed", - "//tfjs-converter/python/tensorflowjs:expect_tensorflow_installed", - ], -) - -py_test( - name = "fuse_depthwise_conv2d_test", - srcs = ["fuse_depthwise_conv2d_test.py"], - imports = ["../.."], - srcs_version = "PY3", - tags = ["ci"], - deps = [ - ":fuse_depthwise_conv2d", - ":graph_rewrite_util", - ":tf_saved_model_conversion_v2", - "//tfjs-converter/python/tensorflowjs:expect_numpy_installed", - "//tfjs-converter/python/tensorflowjs:expect_tensorflow_installed", - ], -) - -py_library( - name = "normalize_bias_add", - srcs = ["normalize_bias_add.py"], - srcs_version = "PY3", - deps = [ - ":graph_rewrite_util", - "//tfjs-converter/python/tensorflowjs:expect_numpy_installed", - "//tfjs-converter/python/tensorflowjs:expect_tensorflow_installed", - ], -) - -py_test( - name = "normalize_bias_add_test", - srcs = ["normalize_bias_add_test.py"], - imports = ["../.."], - srcs_version = "PY3", - tags = ["ci"], - deps = [ - ":graph_rewrite_util", - ":normalize_bias_add", - ":tf_saved_model_conversion_v2", - "//tfjs-converter/python/tensorflowjs:expect_numpy_installed", - "//tfjs-converter/python/tensorflowjs:expect_tensorflow_installed", - ], -) - -py_test( - name = "tf_saved_model_conversion_v2_test", - srcs = ["tf_saved_model_conversion_v2_test.py"], - data = ["//tfjs-converter/python/tensorflowjs/op_list:ops"], - imports = ["../.."], - srcs_version = "PY3", - tags = ["ci"], - deps = [ - ":tf_saved_model_conversion_v2", - "//tfjs-converter/python/tensorflowjs:expect_tensorflow_hub_installed", - "//tfjs-converter/python/tensorflowjs:expect_tensorflow_installed", - ], -) - -py_library( - name = "tf_saved_model_conversion_v2", - srcs = ["tf_saved_model_conversion_v2.py"], - data = ["//tfjs-converter/python/tensorflowjs/op_list:ops"], - srcs_version = "PY3", - deps = [ - ":common", - ":fold_batch_norms", - ":fuse_depthwise_conv2d", - ":fuse_prelu", - ":graph_rewrite_util", - ":normalize_bias_add", - "//tfjs-converter/python/tensorflowjs:expect_numpy_installed", - "//tfjs-converter/python/tensorflowjs:expect_packaging_installed", - "//tfjs-converter/python/tensorflowjs:expect_tensorflow_decision_forests_installed", - "//tfjs-converter/python/tensorflowjs:expect_tensorflow_hub_installed", - "//tfjs-converter/python/tensorflowjs:expect_tensorflow_installed", - "//tfjs-converter/python/tensorflowjs:resource_loader", - "//tfjs-converter/python/tensorflowjs:version", - "//tfjs-converter/python/tensorflowjs:write_weights", - ], -) - -py_test( - name = "jax_conversion_test", - srcs = ["jax_conversion_test.py"], - imports = ["../.."], - srcs_version = "PY3", - tags = ["ci"], - deps = [ - ":jax_conversion", - "//tfjs-converter/python/tensorflowjs:expect_flax_installed", - "//tfjs-converter/python/tensorflowjs:expect_jax_installed", - "//tfjs-converter/python/tensorflowjs:expect_tensorflow_installed", - ], -) - -py_library( - name = "jax_conversion", - srcs = ["jax_conversion.py"], - srcs_version = "PY3", - deps = [ - ":tf_saved_model_conversion_v2", - "//tfjs-converter/python/tensorflowjs:expect_jax2tf_installed", - "//tfjs-converter/python/tensorflowjs:expect_jax_installed", - "//tfjs-converter/python/tensorflowjs:expect_tensorflow_installed", - ], -) - -py_test( - name = "wizard_test", - srcs = ["wizard_test.py"], - imports = ["../.."], - srcs_version = "PY3", - tags = ["ci"], - deps = [ - ":wizard", - "//tfjs-converter/python/tensorflowjs:expect_numpy_installed", - ], -) - -py_binary( - name = "wizard", - srcs = ["wizard.py"], - srcs_version = "PY3", - deps = [ - ":common", - ":converter", - "//tfjs-converter/python/tensorflowjs:expect_PyInquirer_installed", - "//tfjs-converter/python/tensorflowjs:expect_h5py_installed", - "//tfjs-converter/python/tensorflowjs:expect_tensorflow_installed", - ], -) - -py_library( - name = "converter_lib", - srcs = ["converter.py"], - srcs_version = "PY3", - visibility = ["//visibility:public"], - deps = [ - ":common", - ":keras_h5_conversion", - ":keras_tfjs_loader", - ":tf_saved_model_conversion_v2", - "//tfjs-converter/python/tensorflowjs:version", - ], -) - -py_binary( - name = "converter", - srcs = ["converter.py"], - imports = ["../.."], - srcs_version = "PY3", - visibility = ["//visibility:public"], - deps = [ - ":common", - ":keras_h5_conversion", - ":keras_tfjs_loader", - ":tf_module_mapper", - ":tf_saved_model_conversion_v2", - "//tfjs-converter/python/tensorflowjs:expect_h5py_installed", - "//tfjs-converter/python/tensorflowjs:expect_tensorflow_installed", - "//tfjs-converter/python/tensorflowjs:version", - ], -) - -py_binary( - name = "generate_test_model", - testonly = True, - srcs = ["generate_test_model.py"], - srcs_version = "PY3", - deps = [ - "//tfjs-converter/python/tensorflowjs:expect_tensorflow_installed", - ], -) - -py_test( - name = "converter_test", - srcs = ["converter_test.py"], - imports = ["../.."], - srcs_version = "PY3", - tags = ["ci"], - deps = [ - ":converter", - ":keras_tfjs_loader", - "//tfjs-converter/python/tensorflowjs:expect_numpy_installed", - "//tfjs-converter/python/tensorflowjs:expect_tensorflow_installed", - "//tfjs-converter/python/tensorflowjs:version", - ], -) - -sh_test( - name = "converter_binary_test", - srcs = ["converter_binary_test.sh"], - data = [ - ":converter", - ":generate_test_model", - ], - tags = ["ci"], -) diff --git a/tfjs-master/tfjs-converter/python/tensorflowjs/converters/__init__.py b/tfjs-master/tfjs-converter/python/tensorflowjs/converters/__init__.py deleted file mode 100644 index 96cb3e358..000000000 --- a/tfjs-master/tfjs-converter/python/tensorflowjs/converters/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -# Copyright 2018 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================== - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -# pylint: disable=unused-imports,line-too-long -from tensorflowjs.converters.converter import convert -from tensorflowjs.converters.keras_h5_conversion import save_keras_model -from tensorflowjs.converters.keras_tfjs_loader import deserialize_keras_model -from tensorflowjs.converters.keras_tfjs_loader import load_keras_model -from tensorflowjs.converters.tf_saved_model_conversion_v2 import convert_tf_saved_model -from tensorflowjs.converters.jax_conversion import convert_jax diff --git a/tfjs-master/tfjs-converter/python/tensorflowjs/converters/common.py b/tfjs-master/tfjs-converter/python/tensorflowjs/converters/common.py deleted file mode 100644 index 0dc4d6695..000000000 --- a/tfjs-master/tfjs-converter/python/tensorflowjs/converters/common.py +++ /dev/null @@ -1,74 +0,0 @@ -# Copyright 2019 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================== -from tensorflowjs import version - - -# File name for the indexing JSON file in an artifact directory. -ARTIFACT_MODEL_JSON_FILE_NAME = 'model.json' -ASSETS_DIRECTORY_NAME = 'assets' - -# JSON string keys for fields of the indexing JSON. -ARTIFACT_MODEL_TOPOLOGY_KEY = 'modelTopology' -ARTIFACT_MODEL_INITIALIZER = 'modelInitializer' -ARTIFACT_WEIGHTS_MANIFEST_KEY = 'weightsManifest' - -FORMAT_KEY = 'format' -TFJS_GRAPH_MODEL_FORMAT = 'graph-model' -TFJS_LAYERS_MODEL_FORMAT = 'layers-model' - -GENERATED_BY_KEY = 'generatedBy' -CONVERTED_BY_KEY = 'convertedBy' - -SIGNATURE_KEY = 'signature' -INITIALIZER_SIGNATURE_KEY = 'initializerSignature' -USER_DEFINED_METADATA_KEY = 'userDefinedMetadata' -STRUCTURED_OUTPUTS_KEYS_KEY = 'structuredOutputKeys' -RESOURCE_ID_KEY = 'resourceId' - -# Model formats. -KERAS_SAVED_MODEL = 'keras_saved_model' -KERAS_MODEL = 'keras' -KERAS_KERAS_MODEL = 'keras_keras' -TF_SAVED_MODEL = 'tf_saved_model' -TF_HUB_MODEL = 'tf_hub' -TFJS_GRAPH_MODEL = 'tfjs_graph_model' -TFJS_LAYERS_MODEL = 'tfjs_layers_model' -TF_FROZEN_MODEL = 'tf_frozen_model' - -# CLI argument strings. -INPUT_PATH = 'input_path' -OUTPUT_PATH = 'output_path' -INPUT_FORMAT = 'input_format' -OUTPUT_FORMAT = 'output_format' -OUTPUT_NODE = 'output_node_names' -SIGNATURE_NAME = 'signature_name' -SAVED_MODEL_TAGS = 'saved_model_tags' -QUANTIZATION_BYTES = 'quantization_bytes' -QUANTIZATION_TYPE_FLOAT16 = 'quantize_float16' -QUANTIZATION_TYPE_UINT8 = 'quantize_uint8' -QUANTIZATION_TYPE_UINT16 = 'quantize_uint16' -SPLIT_WEIGHTS_BY_LAYER = 'split_weights_by_layer' -VERSION = 'version' -SKIP_OP_CHECK = 'skip_op_check' -STRIP_DEBUG_OPS = 'strip_debug_ops' -USE_STRUCTURED_OUTPUTS_NAMES = 'use_structured_outputs_names' -WEIGHT_SHARD_SIZE_BYTES = 'weight_shard_size_bytes' -CONTROL_FLOW_V2 = 'control_flow_v2' -EXPERIMENTS = 'experiments' -METADATA = 'metadata' - -def get_converted_by(): - """Get the convertedBy string for storage in model artifacts.""" - return 'TensorFlow.js Converter v%s' % version.version diff --git a/tfjs-master/tfjs-converter/python/tensorflowjs/converters/converter.py b/tfjs-master/tfjs-converter/python/tensorflowjs/converters/converter.py deleted file mode 100644 index d0100e28d..000000000 --- a/tfjs-master/tfjs-converter/python/tensorflowjs/converters/converter.py +++ /dev/null @@ -1,966 +0,0 @@ -# Copyright 2018 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================== -"""Artifact conversion to and from Python TensorFlow and tf.keras.""" - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -import argparse -import json -import os -import shutil -import sys -import tempfile - -import h5py -import tensorflow.compat.v1 as tf1 -import tensorflow.compat.v2 as tf - -from tensorflowjs import quantization -from tensorflowjs import version -from tensorflowjs.converters import common -from tensorflowjs.converters import keras_h5_conversion as conversion -from tensorflowjs.converters import keras_tfjs_loader -from tensorflowjs.converters import tf_saved_model_conversion_v2 -from zipfile import ZipFile, is_zipfile - - -def dispatch_keras_h5_to_tfjs_layers_model_conversion( - h5_path, output_dir=None, quantization_dtype_map=None, - split_weights_by_layer=False, - weight_shard_size_bytes=1024 * 1024 * 4, - metadata=None): - """Converts a Keras HDF5 saved-model file to TensorFlow.js format. - - Auto-detects saved_model versus weights-only and generates the correct - json in either case. This function accepts Keras HDF5 files in two formats: - - A weights-only HDF5 (e.g., generated with Keras Model's `save_weights()` - method), - - A topology+weights combined HDF5 (e.g., generated with - `tf.keras.model.save_model`). - - Args: - h5_path: path to an HDF5 file containing keras model data as a `str`. - output_dir: Output directory to which the TensorFlow.js-format model JSON - file and weights files will be written. If the directory does not exist, - it will be created. - quantization_dtype_map: A mapping from dtype (`uint8`, `uint16`, `float16`) - to weights. The weight mapping supports wildcard substitution. - split_weights_by_layer: Whether to split the weights into separate weight - groups (corresponding to separate binary weight files) layer by layer - (Default: `False`). - weight_shard_size_bytes: Shard size (in bytes) of the weight files. - The size of each weight file will be <= this value. - metadata: User defined metadata map. - - Returns: - (model_json, groups) - model_json: a json dictionary (empty if unused) for model topology. - If `h5_path` points to a weights-only HDF5 file, this return value - will be `None`. - groups: an array of weight_groups as defined in tfjs weights_writer. - """ - if not os.path.exists(h5_path): - raise ValueError('Nonexistent path to HDF5 file: %s' % h5_path) - if os.path.isdir(h5_path): - raise ValueError( - 'Expected path to point to an HDF5 file, but it points to a ' - 'directory: %s' % h5_path) - - h5_file = h5py.File(h5_path, 'r') - if 'layer_names' in h5_file.attrs: - model_json = None - groups = conversion.h5_weights_to_tfjs_format( - h5_file, split_by_layer=split_weights_by_layer) - else: - model_json, groups = conversion.h5_merged_saved_model_to_tfjs_format( - h5_file, split_by_layer=split_weights_by_layer) - - if output_dir: - if os.path.isfile(output_dir): - raise ValueError( - 'Output path "%s" already exists as a file' % output_dir) - if not os.path.isdir(output_dir): - os.makedirs(output_dir) - conversion.write_artifacts( - model_json, groups, output_dir, quantization_dtype_map, - weight_shard_size_bytes=weight_shard_size_bytes, metadata=metadata) - - return model_json, groups - -def dispatch_keras_keras_to_tfjs_layers_model_conversion( - v3_path, - output_dir=None, - quantization_dtype_map=None, - split_weights_by_layer=False, - weight_shard_size_bytes=1024 * 1024 * 4, - metadata=None, -): - """Converts a Keras v3 .keras file to TensorFlow.js format. - - Args: - v3_path: path to an .keras file containing keras model data as a `str`. - output_dir: Output directory to which the TensorFlow.js-format model JSON - file and weights files will be written. If the directory does not exist, - it will be created. - quantization_dtype_map: A mapping from dtype (`uint8`, `uint16`, `float16`) - to weights. The weight mapping supports wildcard substitution. - split_weights_by_layer: Whether to split the weights into separate weight - groups (corresponding to separate binary weight files) layer by layer - (Default: `False`). - weight_shard_size_bytes: Shard size (in bytes) of the weight files. - The size of each weight file will be <= this value. - metadata: User defined metadata map. - - Returns: - (model_json, groups) - model_json: a json dictionary (empty if unused) for model topology. - groups: an array of weight_groups as defined in tfjs weights_writer. - """ - if not os.path.exists(v3_path): - raise ValueError("Nonexistent path to .keras file: %s" % v3_path) - if os.path.isdir(v3_path): - raise ValueError( - "Expected path to point to an .keras file, but it points to a " - "directory: %s" % v3_path - ) - file_path = str(v3_path) - if not file_path.endswith(".keras"): - raise ValueError( - "Invalid `filepath` argument: expected a `.keras` extension. " - f"Received: filepath={file_path}" - ) - with ZipFile(v3_path, "r") as zip_file: - zip_file.extractall(path=os.path.dirname(v3_path)) - dir_path = os.path.dirname(file_path) - meta_data_json_path = os.path.join(dir_path, "metadata.json") - config_json_path = os.path.join(dir_path, "config.json") - model_weights_path = os.path.join(dir_path, "model.weights.h5") - h5_file = h5py.File(model_weights_path, "r") - with open(config_json_path, "rt") as conf: - try: - config_file = json.load(conf) - except (ValueError, IOError): - raise ValueError( - "The input path is expected to contain valid JSON content, " - "but cannot read valid JSON content from %s." % config_json_path - ) - - with open(meta_data_json_path, "rt") as meta_json: - try: - meta_file = json.load(meta_json) - except (ValueError, IOError): - raise ValueError( - "The input path is expected to contain valid JSON content, " - "but cannot read valid JSON content from %s." % meta_data_json_path - ) - - model_json, groups = conversion.h5_v3_merged_saved_model_to_tfjs_format( - h5_file, meta_file, config_file, split_by_layer=split_weights_by_layer - ) - - if output_dir: - if os.path.isfile(output_dir): - raise ValueError( - 'Output path "%s" already exists as a file' % output_dir) - if not os.path.isdir(output_dir): - os.makedirs(output_dir) - conversion.write_artifacts( - model_json, groups, output_dir, quantization_dtype_map, - weight_shard_size_bytes=weight_shard_size_bytes, metadata=metadata) - - return model_json, groups - -def dispatch_keras_h5_to_tfjs_graph_model_conversion( - h5_path, output_dir=None, - quantization_dtype_map=None, - skip_op_check=False, - strip_debug_ops=False, - use_structured_outputs_names=False, - weight_shard_size_bytes=1024 * 1024 * 4, - control_flow_v2=False, - experiments=False, - metadata=None): - """ - Convert a keras HDF5-format model to tfjs GraphModel artifacts. - - Args: - h5_path: Path to the HDF5-format file that contains the model saved from - keras or tf.keras. - output_dir: The destination to which the tfjs GraphModel artifacts will be - written. - quantization_dtype_map: A mapping from dtype (`uint8`, `uint16`, `float16`) - to weights. The weight mapping supports wildcard substitution. - skip_op_check: Bool whether to skip the op check. - strip_debug_ops: Bool whether to allow unsupported debug ops. - use_structured_outputs_names: Bool whether output of graph model will follow - the structured_outputs format. - weight_shard_size_bytes: Shard size (in bytes) of the weight files. - The size of each weight file will be <= this value. - control_flow_v2: Bool whether to enable control flow v2 ops. - experiments: Bool enable experimental features. - metadata: User defined metadata map. - """ - - if not os.path.exists(h5_path): - raise ValueError('Nonexistent path to HDF5 file: %s' % h5_path) - if os.path.isdir(h5_path): - raise ValueError( - 'Expected path to point to an HDF5 file, but it points to a ' - 'directory: %s' % h5_path) - - temp_savedmodel_dir = tempfile.mktemp(suffix='.savedmodel') - model = tf.keras.models.load_model(h5_path, compile=False) - model.save(temp_savedmodel_dir, include_optimizer=False, save_format='tf') - - # NOTE(cais): This cannot use `tf.compat.v1` because - # `convert_tf_saved_model()` works only in v2. - tf_saved_model_conversion_v2.convert_tf_saved_model( - temp_savedmodel_dir, output_dir, - signature_def='serving_default', - saved_model_tags='serve', - quantization_dtype_map=quantization_dtype_map, - skip_op_check=skip_op_check, - strip_debug_ops=strip_debug_ops, - use_structured_outputs_names=use_structured_outputs_names, - weight_shard_size_bytes=weight_shard_size_bytes, - control_flow_v2=control_flow_v2, - experiments=experiments, - metadata=metadata) - - # Clean up the temporary SavedModel directory. - shutil.rmtree(temp_savedmodel_dir) - - -def dispatch_keras_saved_model_to_tensorflowjs_conversion( - keras_saved_model_path, output_dir, quantization_dtype_map=None, - split_weights_by_layer=False, - weight_shard_size_bytes=1024 * 1024 * 4, - metadata=None): - """Converts keras model saved in the SavedModel format to tfjs format. - - Note that the SavedModel format exists in keras, but not in - keras-team/tf.keras. - - Args: - keras_saved_model_path: path to a folder in which the - assets/saved_model.json can be found. This is usually a subfolder - that is under the folder passed to - `tf.keras.models.save_model()` and has a Unix epoch time - as its name (e.g., 1542212752). - output_dir: Output directory to which the TensorFlow.js-format model JSON - file and weights files will be written. If the directory does not exist, - it will be created. - quantization_dtype_map: A mapping from dtype (`uint8`, `uint16`, `float16`) - to weights. The weight mapping supports wildcard substitution. - split_weights_by_layer: Whether to split the weights into separate weight - groups (corresponding to separate binary weight files) layer by layer - (Default: `False`). - weight_shard_size_bytes: Shard size (in bytes) of the weight files. - The size of each weight file will be <= this value. - metadata: User defined metadata map. - """ - with tf.Graph().as_default(), tf.compat.v1.Session(): - model = tf.keras.models.load_model(keras_saved_model_path) - - # Save model temporarily in HDF5 format. - temp_h5_path = tempfile.mktemp(suffix='.h5') - model.save(temp_h5_path, save_format='h5') - assert os.path.isfile(temp_h5_path) - - dispatch_keras_h5_to_tfjs_layers_model_conversion( - temp_h5_path, - output_dir, - quantization_dtype_map=quantization_dtype_map, - split_weights_by_layer=split_weights_by_layer, - weight_shard_size_bytes=weight_shard_size_bytes, - metadata=metadata) - - # Delete temporary .h5 file. - os.remove(temp_h5_path) - -def dispatch_tensorflowjs_to_keras_h5_conversion(config_json_path, h5_path): - """Converts a TensorFlow.js Layers model format to Keras H5. - - Args: - config_json_path: Path to the JSON file that includes the model's - topology and weights manifest, in tensorflowjs format. - h5_path: Path for the to-be-created Keras HDF5 model file. - - Raises: - ValueError, if `config_json_path` is not a path to a valid JSON - file, or if h5_path points to an existing directory. - """ - if os.path.isdir(config_json_path): - raise ValueError( - 'For input_type=tfjs_layers_model & output_format=keras, ' - 'the input path should be a model.json ' - 'file, but received a directory.') - if os.path.isdir(h5_path): - raise ValueError( - 'For input_type=tfjs_layers_model & output_format=keras, ' - 'the output path should be the path to an HDF5 file, ' - 'but received an existing directory (%s).' % h5_path) - - # Verify that config_json_path points to a JSON file. - with open(config_json_path, 'rt') as f: - try: - json.load(f) - except (ValueError, IOError): - raise ValueError( - 'For input_type=tfjs_layers_model & output_format=keras, ' - 'the input path is expected to contain valid JSON content, ' - 'but cannot read valid JSON content from %s.' % config_json_path) - - with tf.Graph().as_default(), tf.compat.v1.Session(): - model = keras_tfjs_loader.load_keras_model(config_json_path) - model.save(h5_path) - -def dispatch_tensorflowjs_to_keras_keras_conversion(config_json_path, v3_path): - """Converts a TensorFlow.js Layers model format to Keras V3 format. - - Args: - config_json_path: Path to the JSON file that includes the model's - topology and weights manifest, in tensorflowjs format. - v3_path: Path for the to-be-created Keras V3 model file. - - Raises: - ValueError, if `config_json_path` is not a path to a valid JSON - file. - """ - if os.path.isdir(config_json_path): - raise ValueError( - 'For input_type=tfjs_layers_model & output_format=keras_keras, ' - 'the input path should be a model.json ' - 'file, but received a directory.') - if os.path.isdir(v3_path): - raise ValueError( - 'For input_type=tfjs_layers_model & output_format=keras_keras, ' - 'the output path should be the path to a .keras file, ' - 'but received an existing directory (%s).' % v3_path) - - # Verify that config_json_path points to a JSON file. - with open(config_json_path, 'rt') as f: - try: - json.load(f) - except (ValueError, IOError): - raise ValueError( - 'For input_type=tfjs_layers_model & output_format=keras_keras, ' - 'the input path is expected to contain valid JSON content, ' - 'but cannot read valid JSON content from %s.' % config_json_path) - - model = keras_tfjs_loader.load_keras_keras_model(config_json_path) - tf.keras.saving.save_model(model, v3_path, save_format="keras") - - -def dispatch_tensorflowjs_to_keras_saved_model_conversion( - config_json_path, keras_saved_model_path): - """Converts a TensorFlow.js Layers model format to a tf.keras SavedModel. - - Args: - config_json_path: Path to the JSON file that includes the model's - topology and weights manifest, in tensorflowjs format. - keras_saved_model_path: Path for the to-be-created Keras SavedModel. - - Raises: - ValueError, if `config_json_path` is not a path to a valid JSON - file, or if h5_path points to an existing directory. - """ - if os.path.isdir(config_json_path): - raise ValueError( - 'For input_type=tfjs_layers_model & output_format=keras_saved_model, ' - 'the input path should be a model.json ' - 'file, but received a directory.') - - # Verify that config_json_path points to a JSON file. - with open(config_json_path, 'rt') as f: - try: - json.load(f) - except (ValueError, IOError): - raise ValueError( - 'For input_type=tfjs_layers_model & output_format=keras, ' - 'the input path is expected to contain valid JSON content, ' - 'but cannot read valid JSON content from %s.' % config_json_path) - - with tf.Graph().as_default(), tf.compat.v1.Session(): - model = keras_tfjs_loader.load_keras_model(config_json_path) - tf.keras.models.save_model( - model, keras_saved_model_path, save_format='tf') - - -def dispatch_tensorflowjs_to_tensorflowjs_conversion( - config_json_path, - output_dir_path, - quantization_dtype_map=None, - weight_shard_size_bytes=1024 * 1024 * 4): - """Converts a Keras Model from tensorflowjs format to H5. - - Args: - config_json_path: Path to the JSON file that includes the model's - topology and weights manifest, in tensorflowjs format. - output_dir_path: Path to output directory in which the result of the - conversion will be saved. - quantization_dtype_map: A mapping from dtype (`uint8`, `uint16`, `float16`) - to weights. The weight mapping supports wildcard substitution. - weight_shard_size_bytes: Shard size (in bytes) of the weight files. - The size of each weight file will be <= this value. - - Raises: - ValueError, if `config_json_path` is not a path to a valid JSON - file, or if h5_path points to an existing directory. - ValueError, if `output_dir_path` exists and is a file (instead of - a directory). - """ - if os.path.isdir(config_json_path): - raise ValueError( - 'For input_type=tfjs_layers_model, ' - 'the input path should be a model.json ' - 'file, but received a directory.') - # TODO(cais): Assert output_dir_path doesn't exist or is the path to - # a directory (not a file). - - # Verify that config_json_path points to a JSON file. - with open(config_json_path, 'rt') as f: - try: - json.load(f) - except (ValueError, IOError): - raise ValueError( - 'For input_type=tfjs_layers_model, ' - 'the input path is expected to contain valid JSON content, ' - 'but cannot read valid JSON content from %s.' % config_json_path) - - temp_h5_path = tempfile.mktemp(suffix='.h5') - with tf.Graph().as_default(), tf.compat.v1.Session(): - model = keras_tfjs_loader.load_keras_model(config_json_path) - model.save(temp_h5_path) - dispatch_tensorflowjs_to_keras_h5_conversion(config_json_path, temp_h5_path) - - with tf.Graph().as_default(), tf.compat.v1.Session(): - dispatch_keras_h5_to_tfjs_layers_model_conversion( - temp_h5_path, output_dir_path, - quantization_dtype_map=quantization_dtype_map, - weight_shard_size_bytes=weight_shard_size_bytes) - # TODO(cais): Support weight quantization. - - # Clean up the temporary H5 file. - os.remove(temp_h5_path) - - -def dispatch_tfjs_layers_model_to_tfjs_graph_conversion( - config_json_path, - output_dir_path, - quantization_dtype_map=None, - skip_op_check=False, - strip_debug_ops=False, - weight_shard_size_bytes=1024 * 1024 * 4, - control_flow_v2=False, - experiments=False, - metadata=None): - """Converts a TensorFlow.js Layers Model to TensorFlow.js Graph Model. - - This conversion often benefits speed of inference, due to the graph - optimization that goes into generating the Graph Model. - - Args: - config_json_path: Path to the JSON file that includes the model's - topology and weights manifest, in tensorflowjs format. - output_dir_path: Path to output directory in which the result of the - conversion will be saved. - quantization_dtype_map: A mapping from dtype (`uint8`, `uint16`, `float16`) - to weights. The weight mapping supports wildcard substitution. - skip_op_check: Bool whether to skip the op check. - strip_debug_ops: Bool whether to allow unsupported debug ops. - weight_shard_size_bytes: Shard size (in bytes) of the weight files. - The size of each weight file will be <= this value. - control_flow_v2: Bool whether to enable control flow v2 ops. - experiments: Bool enable experimental features. - metadata: User defined metadata map. - Raises: - ValueError, if `config_json_path` is not a path to a valid JSON - file, or if h5_path points to an existing directory. - ValueError, if `output_dir_path` exists and is a file (instead of - a directory). - """ - if os.path.isdir(config_json_path): - raise ValueError( - 'For input_type=tfjs_layers_model, ' - 'the input path should be a model.json ' - 'file, but received a directory.') - # TODO(cais): Assert output_dir_path doesn't exist or is the path to - # a directory (not a file). - - # Verify that config_json_path points to a JSON file. - with open(config_json_path, 'rt') as f: - try: - json.load(f) - except (ValueError, IOError): - raise ValueError( - 'For input_type=tfjs_layers_model, ' - 'the input path is expected to contain valid JSON content, ' - 'but cannot read valid JSON content from %s.' % config_json_path) - - temp_h5_path = tempfile.mktemp(suffix='.h5') - - model = keras_tfjs_loader.load_keras_model(config_json_path) - model.save(temp_h5_path) - dispatch_keras_h5_to_tfjs_graph_model_conversion( - temp_h5_path, output_dir_path, - quantization_dtype_map=quantization_dtype_map, - skip_op_check=skip_op_check, - strip_debug_ops=strip_debug_ops, - weight_shard_size_bytes=weight_shard_size_bytes, - control_flow_v2=control_flow_v2, - experiments=experiments, - metadata=metadata) - - # Clean up temporary HDF5 file. - os.remove(temp_h5_path) - - -def _standardize_input_output_formats(input_format, output_format): - """Standardize input and output formats. - - Args: - input_format: Input format as a string. - output_format: Output format as a string. - - Returns: - A `tuple` of two strings: - (standardized_input_format, standardized_output_format). - """ - input_format_is_keras = ( - input_format in [common.KERAS_MODEL, common.KERAS_SAVED_MODEL]) - input_format_is_tf = ( - input_format in [common.TF_SAVED_MODEL, - common.TF_FROZEN_MODEL, common.TF_HUB_MODEL]) - if output_format is None: - # If no explicit output_format is provided, infer it from input format. - if input_format_is_keras: - output_format = common.TFJS_LAYERS_MODEL - elif input_format_is_tf: - output_format = common.TFJS_GRAPH_MODEL - elif input_format == common.TFJS_LAYERS_MODEL: - output_format = common.KERAS_MODEL - - return (input_format, output_format) - -def _parse_quantization_dtype_map(float16, uint8, uint16, quantization_bytes): - quantization_dtype_map = {} - - if quantization_bytes: - print( - 'Warning: --quantization_bytes will be deprecated in a future release\n' - 'Please consider using --quantize_uint8, --quantize_uint16, ' - '--quantize_float16.', file=sys.stderr) - if float16 is not None or uint8 is not None or uint16 is not None: - raise ValueError( - '--quantization_bytes cannot be used with the new quantization flags') - - dtype = quantization.QUANTIZATION_BYTES_TO_DTYPES[quantization_bytes] - quantization_dtype_map[dtype] = True - - if float16 is not None: - quantization_dtype_map[quantization.QUANTIZATION_DTYPE_FLOAT16] = \ - float16.split(',') if isinstance(float16, str) else float16 - if uint8 is not None: - quantization_dtype_map[quantization.QUANTIZATION_DTYPE_UINT8] = \ - uint8.split(',') if isinstance(uint8, str) else uint8 - if uint16 is not None: - quantization_dtype_map[quantization.QUANTIZATION_DTYPE_UINT16] = \ - uint16.split(',') if isinstance(uint16, str) else uint16 - - return quantization_dtype_map - -def _parse_metadata_map(metadata_arg): - if metadata_arg: - metadata_map = {} - metadata_list = metadata_arg.split(',') - for metadata in metadata_list: - [key, path] = metadata.split(':') - with open(path, 'rt') as f: - try: - metadata_json = json.load(f) - metadata_map[key] = metadata_json - except (ValueError, IOError): - raise ValueError( - 'Loading metadata error: ' - 'the path is expected to contain valid JSON content, ' - 'but cannot read valid JSON content from %s.' % path) - if not metadata_map: - metadata_map = None - return metadata_map - - return None - -def _dispatch_converter(input_format, - output_format, - args, - quantization_dtype_map, - weight_shard_size_bytes, - metadata_map): - # TODO(cais, piyu): More conversion logics can be added as additional - # branches below. - if (input_format == common.KERAS_MODEL and - output_format == common.TFJS_LAYERS_MODEL): - dispatch_keras_h5_to_tfjs_layers_model_conversion( - args.input_path, output_dir=args.output_path, - quantization_dtype_map=quantization_dtype_map, - split_weights_by_layer=args.split_weights_by_layer, - weight_shard_size_bytes=weight_shard_size_bytes, - metadata=metadata_map) - elif (input_format == common.KERAS_KERAS_MODEL and - output_format == common.TFJS_LAYERS_MODEL): - dispatch_keras_keras_to_tfjs_layers_model_conversion( - args.input_path, output_dir=args.output_path, - quantization_dtype_map=quantization_dtype_map, - split_weights_by_layer=args.split_weights_by_layer, - weight_shard_size_bytes=weight_shard_size_bytes, - metadata=metadata_map) - elif (input_format == common.KERAS_MODEL and - output_format == common.TFJS_GRAPH_MODEL): - dispatch_keras_h5_to_tfjs_graph_model_conversion( - args.input_path, output_dir=args.output_path, - quantization_dtype_map=quantization_dtype_map, - skip_op_check=args.skip_op_check, - strip_debug_ops=args.strip_debug_ops, - use_structured_outputs_names=args.use_structured_outputs_names, - weight_shard_size_bytes=weight_shard_size_bytes, - control_flow_v2=args.control_flow_v2, - experiments=args.experiments, - metadata=metadata_map) - elif (input_format == common.KERAS_SAVED_MODEL and - output_format == common.TFJS_LAYERS_MODEL): - dispatch_keras_saved_model_to_tensorflowjs_conversion( - args.input_path, args.output_path, - quantization_dtype_map=quantization_dtype_map, - split_weights_by_layer=args.split_weights_by_layer, - weight_shard_size_bytes=weight_shard_size_bytes, - metadata=metadata_map) - elif (input_format == common.TF_SAVED_MODEL and - output_format == common.TFJS_GRAPH_MODEL): - tf_saved_model_conversion_v2.convert_tf_saved_model( - args.input_path, args.output_path, - signature_def=args.signature_name, - saved_model_tags=args.saved_model_tags, - quantization_dtype_map=quantization_dtype_map, - skip_op_check=args.skip_op_check, - strip_debug_ops=args.strip_debug_ops, - use_structured_outputs_names=args.use_structured_outputs_names, - weight_shard_size_bytes=weight_shard_size_bytes, - control_flow_v2=args.control_flow_v2, - experiments=args.experiments, - metadata=metadata_map) - elif (input_format == common.TF_HUB_MODEL and - output_format == common.TFJS_GRAPH_MODEL): - tf_saved_model_conversion_v2.convert_tf_hub_module( - args.input_path, args.output_path, - signature=args.signature_name, - saved_model_tags=args.saved_model_tags, - quantization_dtype_map=quantization_dtype_map, - skip_op_check=args.skip_op_check, - strip_debug_ops=args.strip_debug_ops, - use_structured_outputs_names=args.use_structured_outputs_names, - weight_shard_size_bytes=weight_shard_size_bytes, - control_flow_v2=args.control_flow_v2, - experiments=args.experiments, - metadata=metadata_map) - elif (input_format == common.TFJS_LAYERS_MODEL and - output_format == common.KERAS_MODEL): - dispatch_tensorflowjs_to_keras_h5_conversion(args.input_path, - args.output_path) - elif (input_format == common.TFJS_LAYERS_MODEL and - output_format == common.KERAS_KERAS_MODEL): - dispatch_tensorflowjs_to_keras_keras_conversion(args.input_path, - args.output_path) - elif (input_format == common.TFJS_LAYERS_MODEL and - output_format == common.KERAS_SAVED_MODEL): - dispatch_tensorflowjs_to_keras_saved_model_conversion(args.input_path, - args.output_path) - elif (input_format == common.TFJS_LAYERS_MODEL and - output_format == common.TFJS_LAYERS_MODEL): - dispatch_tensorflowjs_to_tensorflowjs_conversion( - args.input_path, args.output_path, - quantization_dtype_map=quantization_dtype_map, - weight_shard_size_bytes=weight_shard_size_bytes) - elif (input_format == common.TFJS_LAYERS_MODEL and - output_format == common.TFJS_GRAPH_MODEL): - dispatch_tfjs_layers_model_to_tfjs_graph_conversion( - args.input_path, args.output_path, - quantization_dtype_map=quantization_dtype_map, - skip_op_check=args.skip_op_check, - strip_debug_ops=args.strip_debug_ops, - weight_shard_size_bytes=weight_shard_size_bytes, - control_flow_v2=args.control_flow_v2, - experiments=args.experiments, - metadata=metadata_map) - elif (input_format == common.TF_FROZEN_MODEL and - output_format == common.TFJS_GRAPH_MODEL): - tf_saved_model_conversion_v2.convert_tf_frozen_model( - args.input_path, args.output_node_names, args.output_path, - quantization_dtype_map=quantization_dtype_map, - skip_op_check=args.skip_op_check, - strip_debug_ops=args.strip_debug_ops, - weight_shard_size_bytes=weight_shard_size_bytes, - experiments=args.experiments, - metadata=metadata_map) - else: - raise ValueError( - 'Unsupported input_format - output_format pair: %s - %s' % - (input_format, output_format)) - -def get_arg_parser(): - """ - Create the argument parser for the converter binary. - """ - - parser = argparse.ArgumentParser('TensorFlow.js model converters.') - parser.add_argument( - common.INPUT_PATH, - nargs='?', - type=str, - help='Path to the input file or directory. For input format "keras", ' - 'an HDF5 (.h5) file is expected. For input format "tensorflow", ' - 'a SavedModel directory, frozen model file, ' - 'or TF-Hub module is expected.') - parser.add_argument( - common.OUTPUT_PATH, - nargs='?', - type=str, - help='Path for all output artifacts.') - parser.add_argument( - '--%s' % common.INPUT_FORMAT, - type=str, - required=False, - default=common.TF_SAVED_MODEL, - choices=set([common.KERAS_MODEL, common.KERAS_SAVED_MODEL, common.KERAS_KERAS_MODEL, - common.TF_SAVED_MODEL, common.TF_HUB_MODEL, - common.TFJS_LAYERS_MODEL, common.TF_FROZEN_MODEL]), - help='Input format. ' - 'For "keras", the input path can be one of the two following formats:\n' - ' - A topology+weights combined HDF5 (e.g., generated with' - ' `tf.keras.model.save_model()` method).\n' - ' - A weights-only HDF5 (e.g., generated with Keras Model\'s ' - ' `save_weights()` method). \n' - 'For "keras_saved_model", the input_path must point to a subfolder ' - 'under the saved model folder that is passed as the argument ' - 'to tf.contrib.save_model.save_keras_model(). ' - 'The subfolder is generated automatically by tensorflow when ' - 'saving keras model in the SavedModel format. It is usually named ' - 'as a Unix epoch time (e.g., 1542212752).\n' - 'For "tf" formats, a SavedModel, frozen model, ' - ' or TF-Hub module is expected.') - parser.add_argument( - '--%s' % common.OUTPUT_FORMAT, - type=str, - required=False, - choices=set([common.KERAS_MODEL, common.KERAS_SAVED_MODEL, - common.TFJS_LAYERS_MODEL, common.TFJS_GRAPH_MODEL, common.KERAS_KERAS_MODEL]), - help='Output format. Default: tfjs_graph_model.') - parser.add_argument( - '--%s' % common.SIGNATURE_NAME, - type=str, - default=None, - help='Signature of the SavedModel Graph or TF-Hub module to load. ' - 'Applicable only if input format is "tf_hub" or "tf_saved_model".') - parser.add_argument( - '--%s' % common.SAVED_MODEL_TAGS, - type=str, - default='serve', - help='Tags of the MetaGraphDef to load, in comma separated string ' - 'format. Defaults to "serve". Applicable only if input format is ' - '"tf_saved_model".') - parser.add_argument( - '--%s' % common.QUANTIZATION_TYPE_FLOAT16, - type=str, - default=None, - const=True, - nargs='?', - help='Comma separated list of node names to apply float16 quantization. ' - 'You can also use wildcard symbol (*) to apply quantization to multiple ' - 'nodes (e.g., conv/*/weights). When the flag is provided without any ' - 'nodes the default behavior will match all nodes.') - parser.add_argument( - '--%s' % common.QUANTIZATION_TYPE_UINT8, - type=str, - default=None, - const=True, - nargs='?', - help='Comma separated list of node names to apply 1-byte affine ' - 'quantization. You can also use wildcard symbol (*) to apply ' - 'quantization to multiple nodes (e.g., conv/*/weights). When the flag is ' - 'provided without any nodes the default behavior will match all nodes.') - parser.add_argument( - '--%s' % common.QUANTIZATION_TYPE_UINT16, - type=str, - default=None, - const=True, - nargs='?', - help='Comma separated list of node names to apply 2-byte affine ' - 'quantization. You can also use wildcard symbol (*) to apply ' - 'quantization to multiple nodes (e.g., conv/*/weights). When the flag is ' - 'provided without any nodes the default behavior will match all nodes.') - parser.add_argument( - '--%s' % common.QUANTIZATION_BYTES, - type=int, - choices=set(quantization.QUANTIZATION_BYTES_TO_DTYPES.keys()), - help='(Deprecated) How many bytes to optionally quantize/compress the ' - 'weights to. 1- and 2-byte quantizaton is supported. The default ' - '(unquantized) size is 4 bytes.') - parser.add_argument( - '--%s' % common.SPLIT_WEIGHTS_BY_LAYER, - action='store_true', - help='Applicable to keras input_format only: Whether the weights from ' - 'different layers are to be stored in separate weight groups, ' - 'corresponding to separate binary weight files. Default: False.') - parser.add_argument( - '--%s' % common.VERSION, - '-v', - dest='show_version', - action='store_true', - help='Show versions of tensorflowjs and its dependencies') - parser.add_argument( - '--%s' % common.SKIP_OP_CHECK, - action='store_true', - help='Skip op validation for TensorFlow model conversion.') - parser.add_argument( - '--%s' % common.STRIP_DEBUG_OPS, - type=bool, - default=True, - help='Strip debug ops (Print, Assert, CheckNumerics) from graph.') - parser.add_argument( - '--%s' % common.USE_STRUCTURED_OUTPUTS_NAMES, - type=bool, - default=False, - help='TFJS graph outputs become a tensor map with the same structure as ' - 'the TF graph structured_outputs (only supported for structured_outputs ' - 'of the form {key1: tensor1, key2: tensor2...})') - parser.add_argument( - '--%s' % common.WEIGHT_SHARD_SIZE_BYTES, - type=int, - default=None, - help='Shard size (in bytes) of the weight files. Currently applicable ' - 'only when output_format is tfjs_layers_model or tfjs_graph_model.') - parser.add_argument( - '--output_node_names', - type=str, - help='The names of the output nodes, separated by commas. E.g., ' - '"logits,activations". Applicable only if input format is ' - '"tf_frozen_model".') - parser.add_argument( - '--%s' % common.CONTROL_FLOW_V2, - type=bool, - default=False, - help='Enable control flow v2 ops, this would improve inference ' - 'performance on models with branches or loops.') - parser.add_argument( - '--%s' % common.EXPERIMENTS, - type=bool, - default=False, - help='Enable experimental features, you should only enable this flag ' - 'when using Python3 and TensorFlow nightly build.') - parser.add_argument( - '--%s' % common.METADATA, - type=str, - help='Attach user defined metadata in format key:path/metadata.json ' - 'Separate multiple metadata files by comma.' - ) - return parser - -def convert(arguments): - args = get_arg_parser().parse_args(arguments) - - if args.show_version: - print('\ntensorflowjs %s\n' % version.version) - print('Dependency versions:') - print(' keras %s' % tf.keras.__version__) - print(' tensorflow %s' % tf.__version__) - return - - if not args.input_path: - raise ValueError( - 'Missing input_path argument. For usage, use the --help flag.') - if not args.output_path: - raise ValueError( - 'Missing output_path argument. For usage, use the --help flag.') - - if args.input_path is None: - raise ValueError( - 'Error: The input_path argument must be set. ' - 'Run with --help flag for usage information.') - - input_format, output_format = _standardize_input_output_formats( - args.input_format, args.output_format) - - weight_shard_size_bytes = 1024 * 1024 * 4 - if args.weight_shard_size_bytes is not None: - if (output_format not in - (common.TFJS_LAYERS_MODEL, common.TFJS_GRAPH_MODEL)): - raise ValueError( - 'The --weight_shard_size_bytes flag is only supported when ' - 'output_format is tfjs_layers_model or tfjs_graph_model.') - - if not (isinstance(args.weight_shard_size_bytes, int) and - args.weight_shard_size_bytes > 0): - raise ValueError( - 'Expected weight_shard_size_bytes to be a positive integer, ' - 'but got %s' % args.weight_shard_size_bytes) - weight_shard_size_bytes = args.weight_shard_size_bytes - - quantization_dtype_map = _parse_quantization_dtype_map( - args.quantize_float16, - args.quantize_uint8, - args.quantize_uint16, - args.quantization_bytes - ) - - if (not args.output_node_names and input_format == common.TF_FROZEN_MODEL): - raise ValueError( - 'The --output_node_names flag is required for "tf_frozen_model"') - - if (args.signature_name and input_format not in - (common.TF_SAVED_MODEL, common.TF_HUB_MODEL)): - raise ValueError( - 'The --signature_name flag is applicable only to "tf_saved_model" and ' - '"tf_hub" input format, but the current input format is ' - '"%s".' % input_format) - - if (args.control_flow_v2 and output_format != common.TFJS_GRAPH_MODEL): - raise ValueError( - 'The --control_flow_v2 flag is applicable only to "tfjs_graph_model" ' - 'as output format, but the current output format ' - 'is "%s"' % input_format, output_format) - - metadata_map = _parse_metadata_map(args.metadata) - - _dispatch_converter(input_format, output_format, args, quantization_dtype_map, - weight_shard_size_bytes, metadata_map) - -def pip_main(): - """Entry point for pip-packaged binary. - - Note that pip-packaged binary calls the entry method without - any arguments, which is why this method is needed in addition to the - `main` method below. - """ - main([' '.join(sys.argv[1:])]) - - -def main(argv): - convert(argv[0].split(' ')) - - -if __name__ == '__main__': - tf1.app.run(main=main, argv=[' '.join(sys.argv[1:])]) diff --git a/tfjs-master/tfjs-converter/python/tensorflowjs/converters/converter_binary_test.sh b/tfjs-master/tfjs-converter/python/tensorflowjs/converters/converter_binary_test.sh deleted file mode 100644 index 75cdb6ff7..000000000 --- a/tfjs-master/tfjs-converter/python/tensorflowjs/converters/converter_binary_test.sh +++ /dev/null @@ -1,61 +0,0 @@ -# Copyright 2019 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================== - -set -e - -GENERATE_BIN="${TEST_SRCDIR}/tfjs/tfjs-converter/python/tensorflowjs/converters/generate_test_model" -CONVERTER_BIN="${TEST_SRCDIR}/tfjs/tfjs-converter/python/tensorflowjs/converters/converter" - -# 1. Test tf_saved_model --> tfjs_graph_model conversion. -SAVED_MODEL_DIR="$(mktemp -d)" -echo "Genearting TF SavedModel for testing..." -"${GENERATE_BIN}" "${SAVED_MODEL_DIR}" --model_type tf_saved_model -echo "Done genearting TF SavedModel for testing at ${SAVED_MODEL_DIR}" - -OUTPUT_DIR="${SAVED_MODEL_DIR}_converted" -"${CONVERTER_BIN}" \ - --input_format tf_saved_model \ - --output_format tfjs_graph_model \ - "${SAVED_MODEL_DIR}" \ - "${OUTPUT_DIR}" - -if [[ ! -d "${OUTPUT_DIR}" ]]; then - echo "ERROR: Failed to find conversion output directory: ${OUTPUT_DIR}" 1>&2 - exit 1 -fi - -# Clean up files. -rm -rf "${SAVED_MODEL_DIR}" "${OUTPUT_DIR}" - -# 2. Test keras HDF5 --> tfjs_layers_model conversion. -KERAS_H5_PATH="$(mktemp).h5" -echo "Genearting Keras HDF5 model for testing..." -"${GENERATE_BIN}" "${KERAS_H5_PATH}" --model_type tf_keras_h5 -echo "Done genearting Keras HDF5 model for testing at ${KERAS_H5_PATH}" - -OUTPUT_H5_PATH="${KERAS_H5_PATH}_converted.h5" -"${CONVERTER_BIN}" \ - --input_format keras \ - --output_format tfjs_layers_model \ - "${KERAS_H5_PATH}" \ - "${OUTPUT_H5_PATH}" - -if [[ ! -d "${OUTPUT_H5_PATH}" ]]; then - echo "ERROR: Failed to find conversion output directory: ${OUTPUT_H5_PATH}" 1>&2 - exit 1 -fi - -# Clean up files. -rm -rf "${KERAS_H5_PATH}" "${OUTPUT_H5_PATH}" diff --git a/tfjs-master/tfjs-converter/python/tensorflowjs/converters/converter_test.py b/tfjs-master/tfjs-converter/python/tensorflowjs/converters/converter_test.py deleted file mode 100644 index 397e94d2c..000000000 --- a/tfjs-master/tfjs-converter/python/tensorflowjs/converters/converter_test.py +++ /dev/null @@ -1,804 +0,0 @@ -# Copyright 2018 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================== -"""Unit tests for artifact conversion to and from Python tf.keras.""" - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -import glob -import json -import os -import shutil -import tempfile -import unittest -import keras - -import numpy as np -import tensorflow.compat.v2 as tf - -from tensorflowjs import version -from tensorflowjs.converters import converter -from tensorflowjs.converters import keras_tfjs_loader - - -# TODO(adarob): Add tests for quantization option. - - -class ConvertH5WeightsTest(unittest.TestCase): - - def setUp(self): - self._tmp_dir = tempfile.mkdtemp() - super(ConvertH5WeightsTest, self).setUp() - - def tearDown(self): - if os.path.isdir(self._tmp_dir): - shutil.rmtree(self._tmp_dir) - super(ConvertH5WeightsTest, self).tearDown() - - def testWeightsOnly(self): - with tf.Graph().as_default(), tf.compat.v1.Session(): - input_tensor = tf.keras.layers.Input((3,)) - dense1 = tf.keras.layers.Dense( - 4, use_bias=True, kernel_initializer='ones', bias_initializer='zeros', - name='MyDense1')(input_tensor) - output = tf.keras.layers.Dense( - 2, use_bias=False, kernel_initializer='ones', name='MyDense2')(dense1) - model = tf.keras.models.Model(inputs=[input_tensor], outputs=[output]) - h5_path = os.path.join(self._tmp_dir, 'MyModel.h5') - model.save_weights(h5_path) - - # Load the saved weights as a JSON string. - model_json, groups = ( - converter.dispatch_keras_h5_to_tfjs_layers_model_conversion( - h5_path, output_dir=self._tmp_dir)) - self.assertIsNone(model_json) - - # Check the loaded weights. - self.assertEqual(1, len(groups)) - self.assertEqual(3, len(groups[0])) - # contents of weights are verified in tests of the library code - - # Check the content of the output directory. - output_json = json.load( - open(os.path.join(self._tmp_dir, 'model.json'), 'rt')) - self.assertEqual(model_json, output_json['modelTopology']) - self.assertIsInstance(output_json['weightsManifest'], list) - self.assertTrue(glob.glob(os.path.join(self._tmp_dir, 'group*-*'))) - - def testConvertSavedKerasModelNoSplitByLayer(self): - with tf.Graph().as_default(), tf.compat.v1.Session(): - input_tensor = tf.keras.layers.Input((3,)) - dense1 = tf.keras.layers.Dense( - 4, use_bias=True, kernel_initializer='ones', bias_initializer='zeros', - name='MergedDense1')(input_tensor) - output = tf.keras.layers.Dense( - 2, use_bias=False, - kernel_initializer='ones', name='MergedDense2')(dense1) - model = tf.keras.models.Model(inputs=[input_tensor], outputs=[output]) - h5_path = os.path.join(self._tmp_dir, 'MyModelMerged.h5') - model.save(h5_path) - - # Load the saved weights as a JSON string. - model_json, groups = ( - converter.dispatch_keras_h5_to_tfjs_layers_model_conversion( - h5_path, output_dir=self._tmp_dir)) - # check the model topology was stored - self.assertIsInstance(model_json['model_config'], dict) - self.assertIsInstance(model_json['model_config']['config'], dict) - self.assertIn('layers', model_json['model_config']['config']) - # Check the loaded weights. - self.assertEqual(keras.__version__, model_json['keras_version']) - self.assertEqual('tensorflow', model_json['backend']) - self.assertEqual(1, len(groups)) - self.assertEqual(3, len(groups[0])) - # contents of weights are verified in tests of the library code - - # Check the content of the output directory. - output_json = json.load( - open(os.path.join(self._tmp_dir, 'model.json'), 'rt')) - self.assertEqual(model_json, output_json['modelTopology']) - self.assertIsInstance(output_json['weightsManifest'], list) - self.assertTrue(glob.glob(os.path.join(self._tmp_dir, 'group*-*'))) - - def testConvertSavedKerasModelSplitByLayer(self): - with tf.Graph().as_default(), tf.compat.v1.Session(): - input_tensor = tf.keras.layers.Input((3,)) - dense1 = tf.keras.layers.Dense( - 4, use_bias=True, kernel_initializer='ones', bias_initializer='zeros', - name='MergedDense1')(input_tensor) - output = tf.keras.layers.Dense( - 2, use_bias=False, - kernel_initializer='ones', name='MergedDense2')(dense1) - model = tf.keras.models.Model(inputs=[input_tensor], outputs=[output]) - h5_path = os.path.join(self._tmp_dir, 'MyModelMerged.h5') - model.save(h5_path) - - # Load the saved weights as a JSON string. - model_json, groups = ( - converter.dispatch_keras_h5_to_tfjs_layers_model_conversion( - h5_path, output_dir=self._tmp_dir, split_weights_by_layer=True)) - # check the model topology was stored - self.assertIsInstance(model_json['model_config'], dict) - self.assertIsInstance(model_json['model_config']['config'], dict) - self.assertIn('layers', model_json['model_config']['config']) - - # Check the loaded weights. - self.assertEqual(keras.__version__, model_json['keras_version']) - self.assertEqual('tensorflow', model_json['backend']) - self.assertEqual(2, len(groups)) - self.assertEqual(2, len(groups[0])) - self.assertEqual(1, len(groups[1])) - # contents of weights are verified in tests of the library code - - # Check the content of the output directory. - output_json = json.load( - open(os.path.join(self._tmp_dir, 'model.json'), 'rt')) - self.assertEqual(model_json, output_json['modelTopology']) - self.assertIsInstance(output_json['weightsManifest'], list) - self.assertTrue(glob.glob(os.path.join(self._tmp_dir, 'group*-*'))) - - def testConvertSavedKerasModeltoTfLayersModelSharded(self): - with tf.Graph().as_default(), tf.compat.v1.Session(): - sequential_model = tf.keras.models.Sequential([ - tf.keras.layers.Dense( - 3, input_shape=(2,), use_bias=True, kernel_initializer='ones', - name='Dense1')]) - h5_path = os.path.join(self._tmp_dir, 'SequentialModel.h5') - sequential_model.save(h5_path) - - weights = sequential_model.get_weights() - total_weight_bytes = sum(np.size(w) for w in weights) * 4 - - # Due to the shard size, there ought to be 4 shards after conversion. - weight_shard_size_bytes = int(total_weight_bytes * 0.3) - - # Convert Keras model to tfjs_layers_model format. - output_dir = os.path.join(self._tmp_dir, 'sharded_tfjs') - converter.dispatch_keras_h5_to_tfjs_layers_model_conversion( - h5_path, output_dir, - weight_shard_size_bytes=weight_shard_size_bytes) - - weight_files = sorted(glob.glob(os.path.join(output_dir, 'group*.bin'))) - self.assertEqual(len(weight_files), 4) - weight_file_sizes = [os.path.getsize(f) for f in weight_files] - self.assertEqual(sum(weight_file_sizes), total_weight_bytes) - self.assertEqual(weight_file_sizes[0], weight_file_sizes[1]) - self.assertEqual(weight_file_sizes[0], weight_file_sizes[2]) - self.assertLess(weight_file_sizes[3], weight_file_sizes[0]) - - def testConvertWeightsFromSequentialModel(self): - with tf.Graph().as_default(), tf.compat.v1.Session(): - sequential_model = tf.keras.models.Sequential([ - tf.keras.layers.Dense( - 3, input_shape=(2,), use_bias=True, kernel_initializer='ones', - name='Dense1'), - tf.keras.layers.Dense( - 1, use_bias=False, kernel_initializer='ones', name='Dense2')]) - h5_path = os.path.join(self._tmp_dir, 'SequentialModel.h5') - sequential_model.save_weights(h5_path) - - # Load the saved weights as a JSON string. - model_json, groups = ( - converter.dispatch_keras_h5_to_tfjs_layers_model_conversion( - h5_path, output_dir=self._tmp_dir)) - self.assertIsNone(model_json) - - # Check the loaded weights. - self.assertEqual(1, len(groups)) - self.assertEqual(3, len(groups[0])) - # contents of weights are verified in tests of the library code - - # Check the content of the output directory. - output_json = json.load( - open(os.path.join(self._tmp_dir, 'model.json'), 'rt')) - self.assertEqual(model_json, output_json['modelTopology']) - self.assertIsInstance(output_json['weightsManifest'], list) - self.assertTrue(glob.glob(os.path.join(self._tmp_dir, 'group*-*'))) - - def testUserDefinedMetadata(self): - with tf.Graph().as_default(), tf.compat.v1.Session(): - sequential_model = tf.keras.models.Sequential([ - tf.keras.layers.Dense( - 3, input_shape=(2,), use_bias=True, kernel_initializer='ones', - name='Dense1'), - tf.keras.layers.Dense( - 1, use_bias=False, kernel_initializer='ones', name='Dense2')]) - h5_path = os.path.join(self._tmp_dir, 'SequentialModel.h5') - sequential_model.save_weights(h5_path) - - metadata_json = {'a': 1} - converter.dispatch_keras_h5_to_tfjs_layers_model_conversion( - h5_path, output_dir=self._tmp_dir, metadata={'key': metadata_json}) - - # Check the content of the output directory. - output_json = json.load( - open(os.path.join(self._tmp_dir, 'model.json'), 'rt')) - self.assertEqual(metadata_json, output_json['userDefinedMetadata']['key']) - - def testConvertModelForNonexistentDirCreatesDir(self): - with tf.Graph().as_default(), tf.compat.v1.Session(): - output_dir = os.path.join(self._tmp_dir, 'foo_model') - sequential_model = tf.keras.models.Sequential([ - tf.keras.layers.Dense( - 3, input_shape=(2,), use_bias=True, kernel_initializer='ones', - name='Dense1')]) - h5_path = os.path.join(self._tmp_dir, 'SequentialModel.h5') - sequential_model.save_weights(h5_path) - converter.dispatch_keras_h5_to_tfjs_layers_model_conversion( - h5_path, output_dir=output_dir) - - # Check the content of the output directory. - output_json = json.load( - open(os.path.join(output_dir, 'model.json'), 'rt')) - self.assertIsNone(output_json['modelTopology']) - self.assertIsInstance(output_json['weightsManifest'], list) - self.assertTrue(glob.glob(os.path.join(output_dir, 'group*-*'))) - - def testOutpuDirAsAnExistingFileLeadsToValueError(self): - output_path = os.path.join(self._tmp_dir, 'foo_model') - with open(output_path, 'wt') as f: - f.write('\n') - - with tf.Graph().as_default(), tf.compat.v1.Session(): - sequential_model = tf.keras.models.Sequential([ - tf.keras.layers.Dense( - 3, input_shape=(2,), use_bias=True, kernel_initializer='ones', - name='Dense1')]) - h5_path = os.path.join(self._tmp_dir, 'SequentialModel.h5') - sequential_model.save_weights(h5_path) - - with self.assertRaisesRegexp( # pylint: disable=deprecated-method - ValueError, r'already exists as a file'): - converter.dispatch_keras_h5_to_tfjs_layers_model_conversion( - h5_path, output_dir=output_path) - - def testTensorflowjsToKerasConversionSucceeds(self): - with tf.Graph().as_default(), tf.compat.v1.Session(): - sequential_model = tf.keras.models.Sequential([ - tf.keras.layers.Dense( - 3, input_shape=(2,), use_bias=True, kernel_initializer='ones', - name='Dense1'), - tf.keras.layers.Dense( - 1, use_bias=False, kernel_initializer='ones', name='Dense2')]) - h5_path = os.path.join(self._tmp_dir, 'SequentialModel.h5') - sequential_model.use_legacy_config = True - sequential_model.save(h5_path) - converter.dispatch_keras_h5_to_tfjs_layers_model_conversion( - h5_path, output_dir=self._tmp_dir) - old_model_json = sequential_model.to_json() - - # Convert the tensorflowjs artifacts to a new H5 file. - new_h5_path = os.path.join(self._tmp_dir, 'new.h5') - converter.dispatch_tensorflowjs_to_keras_h5_conversion( - os.path.join(self._tmp_dir, 'model.json'), new_h5_path) - - # Load the new H5 and compare the model JSONs. - with tf.Graph().as_default(), tf.compat.v1.Session(): - new_model = tf.keras.models.load_model(new_h5_path) - new_model.use_legacy_config = True - self.assertEqual(old_model_json, new_model.to_json()) - - def testTensorflowjsToKerasConversionFailsOnDirInputPath(self): - with self.assertRaisesRegexp( # pylint: disable=deprecated-method - ValueError, r'input path should be a model\.json file'): - converter.dispatch_tensorflowjs_to_keras_h5_conversion( - self._tmp_dir, os.path.join(self._tmp_dir, 'new.h5')) - - def testTensorflowjsToKerasConversionFailsOnExistingDirOutputPath(self): - with tf.Graph().as_default(), tf.compat.v1.Session(): - sequential_model = tf.keras.models.Sequential([ - tf.keras.layers.Dense( - 3, input_shape=(2,), use_bias=True, kernel_initializer='ones', - name='Dense1'), - tf.keras.layers.Dense( - 1, use_bias=False, kernel_initializer='ones', name='Dense2')]) - h5_path = os.path.join(self._tmp_dir, 'SequentialModel.h5') - sequential_model.save(h5_path) - converter.dispatch_keras_h5_to_tfjs_layers_model_conversion( - h5_path, output_dir=self._tmp_dir) - - with self.assertRaisesRegexp( # pylint: disable=deprecated-method - ValueError, r'but received an existing directory'): - converter.dispatch_tensorflowjs_to_keras_h5_conversion( - os.path.join(self._tmp_dir, 'model.json'), self._tmp_dir) - - def testTensorflowjsToKerasConversionFailsOnInvalidJsonFile(self): - fake_json_path = os.path.join(self._tmp_dir, 'fake.json') - with open(fake_json_path, 'wt') as f: - f.write('__invalid_json_content__') - - with self.assertRaisesRegexp( # pylint: disable=deprecated-method - ValueError, r'cannot read valid JSON content from'): - converter.dispatch_tensorflowjs_to_keras_h5_conversion( - fake_json_path, os.path.join(self._tmp_dir, 'model.h5')) - - -class ConvertKerasToTfGraphModelTest(tf.test.TestCase): - - def setUp(self): - super(ConvertKerasToTfGraphModelTest, self).setUp() - self._tmp_dir = tempfile.mkdtemp() - - def tearDown(self): - if os.path.isdir(self._tmp_dir): - shutil.rmtree(self._tmp_dir) - super(ConvertKerasToTfGraphModelTest, self).tearDown() - - def testConvertKerasModelToTfGraphModel(self): - output_dir = os.path.join(self._tmp_dir, 'foo_model') - sequential_model = tf.keras.models.Sequential([ - tf.keras.layers.Dense( - 3, input_shape=(2,), use_bias=True, kernel_initializer='ones', - name='Dense1')]) - h5_path = os.path.join(self._tmp_dir, 'SequentialModel.h5') - sequential_model.save(h5_path) - converter.dispatch_keras_h5_to_tfjs_graph_model_conversion( - h5_path, output_dir=output_dir) - - # Check model.json and weights manifest. - with open(os.path.join(output_dir, 'model.json'), 'rt') as f: - model_json = json.load(f) - self.assertTrue(model_json['modelTopology']) - self.assertIsNot(model_json['modelTopology']['versions'], None) - signature = model_json['signature'] - self.assertIsNot(signature, None) - self.assertIsNot(signature['inputs'], None) - self.assertIsNot(signature['outputs'], None) - weights_manifest = model_json['weightsManifest'] - self.assertEqual(len(weights_manifest), 1) - # Check meta-data in the artifact JSON. - self.assertEqual(model_json['format'], 'graph-model') - self.assertEqual( - model_json['convertedBy'], - 'TensorFlow.js Converter v%s' % version.version) - self.assertEqual(model_json['generatedBy'], - tf.__version__) - self.assertTrue(glob.glob(os.path.join(output_dir, 'group*-*'))) - - def testConvertKerasModelToTfGraphModelSharded(self): - output_dir = os.path.join(self._tmp_dir, 'foo_model') - sequential_model = tf.keras.models.Sequential([ - tf.keras.layers.Dense( - 3, input_shape=(2,), use_bias=True, kernel_initializer='ones', - name='Dense1')]) - h5_path = os.path.join(self._tmp_dir, 'SequentialModel.h5') - sequential_model.save(h5_path) - - # Do initial conversion without sharding. - converter.dispatch_keras_h5_to_tfjs_graph_model_conversion( - h5_path, output_dir) - weight_files = glob.glob(os.path.join(output_dir, 'group*.bin')) - - # Get size of weights in bytes after graph optimizations. - optimized_total_weight = sum([os.path.getsize(f) for f in weight_files]) - - # Due to the shard size, there ought to be 4 shards after conversion. - weight_shard_size_bytes = int(optimized_total_weight * 0.3) - - output_dir = os.path.join(self._tmp_dir, 'sharded_model') - # Convert Keras model again with shard argument set. - converter.dispatch_keras_h5_to_tfjs_graph_model_conversion( - h5_path, output_dir, - weight_shard_size_bytes=weight_shard_size_bytes) - - weight_files = sorted(glob.glob(os.path.join(output_dir, 'group*.bin'))) - self.assertEqual(len(weight_files), 4) - weight_file_sizes = [os.path.getsize(f) for f in weight_files] - self.assertEqual(sum(weight_file_sizes), optimized_total_weight) - self.assertEqual(weight_file_sizes[0], weight_file_sizes[1]) - self.assertEqual(weight_file_sizes[0], weight_file_sizes[2]) - self.assertLess(weight_file_sizes[3], weight_file_sizes[0]) - - def testUserDefinedMetadata(self): - output_dir = os.path.join(self._tmp_dir, 'foo_model') - sequential_model = tf.keras.models.Sequential([ - tf.keras.layers.Dense( - 3, input_shape=(2,), use_bias=True, kernel_initializer='ones', - name='Dense1')]) - h5_path = os.path.join(self._tmp_dir, 'SequentialModel.h5') - sequential_model.save(h5_path) - metadata_json = {'a': 1} - converter.dispatch_keras_h5_to_tfjs_graph_model_conversion( - h5_path, output_dir=output_dir, metadata={'key': metadata_json}) - - # Check model.json and weights manifest. - with open(os.path.join(output_dir, 'model.json'), 'rt') as f: - model_json = json.load(f) - self.assertEqual(metadata_json, model_json['userDefinedMetadata']['key']) - -class ConvertTfKerasSavedModelTest(tf.test.TestCase): - - def setUp(self): - super(ConvertTfKerasSavedModelTest, self).setUp() - self._tmp_dir = tempfile.mkdtemp() - - def tearDown(self): - if os.path.isdir(self._tmp_dir): - shutil.rmtree(self._tmp_dir) - super(ConvertTfKerasSavedModelTest, self).tearDown() - - def _createSimpleSequentialModel(self): - model = tf.keras.Sequential() - model.add(tf.keras.layers.Reshape([2, 3], input_shape=[6])) - model.add(tf.keras.layers.LSTM(10)) - model.add(tf.keras.layers.Dense(1, activation='sigmoid')) - model.compile(optimizer='adam', loss='binary_crossentropy') - model.predict(tf.ones((1, 6)), steps=1) - tf.keras.backend.set_learning_phase(0) - return model - - def _createNestedSequentialModel(self): - model = tf.keras.Sequential() - model.add(tf.keras.layers.Dense(6, input_shape=[10], activation='relu')) - model.add(self._createSimpleSequentialModel()) - model.compile(optimizer='adam', loss='binary_crossentropy') - model.predict(tf.ones((1, 10)), steps=1) - return model - - def _createFunctionalModelWithWeights(self): - input1 = tf.keras.Input(shape=[8]) - input2 = tf.keras.Input(shape=[10]) - y = tf.keras.layers.Concatenate()([input1, input2]) - y = tf.keras.layers.Dense(4, activation='softmax')(y) - model = tf.keras.Model([input1, input2], y) - model.compile(optimizer='adam', loss='binary_crossentropy') - model.predict([tf.ones((1, 8)), tf.ones((1, 10))], steps=1) - return model - - def testConvertTfKerasSequentialSavedAsSavedModel(self): - with tf.Graph().as_default(), tf.compat.v1.Session(): - model = self._createSimpleSequentialModel() - old_model_json = json.loads(model.to_json()) - old_weights = model.get_weights() - tf.keras.models.save_model(model, self._tmp_dir, save_format='tf') - - # Convert the keras SavedModel to tfjs format. - tfjs_output_dir = os.path.join(self._tmp_dir, 'tfjs') - converter.dispatch_keras_saved_model_to_tensorflowjs_conversion( - self._tmp_dir, tfjs_output_dir) - - # Verify the size of the weight file. - weight_path = glob.glob(os.path.join(tfjs_output_dir, 'group*-*'))[0] - weight_file_bytes = os.path.getsize(weight_path) - model_weight_bytes = sum(w.size * 4 for w in model.get_weights()) - self.assertEqual(weight_file_bytes, model_weight_bytes) - - with tf.Graph().as_default(), tf.compat.v1.Session(): - # Load the converted mode back. - model_json_path = os.path.join(tfjs_output_dir, 'model.json') - model_prime = keras_tfjs_loader.load_keras_model(model_json_path) - new_weights = model_prime.get_weights() - - # Check the equality of the old and new model JSONs. - self.assertEqual(old_model_json, json.loads(model_prime.to_json())) - - # Check the equality of the old and new weights. - self.assertAllClose(old_weights, new_weights) - - def testConvertTfKerasSequentialCompiledAndSavedAsSavedModel(self): - with tf.Graph().as_default(), tf.compat.v1.Session(): - model = self._createSimpleSequentialModel() - - old_model_json = json.loads(model.to_json()) - old_weights = model.get_weights() - tf.keras.models.save_model(model, self._tmp_dir, save_format='tf') - - # Convert the keras SavedModel to tfjs format. - tfjs_output_dir = os.path.join(self._tmp_dir, 'tfjs') - converter.dispatch_keras_saved_model_to_tensorflowjs_conversion( - self._tmp_dir, tfjs_output_dir) - - # Verify the size of the weight file. - weight_path = glob.glob(os.path.join(tfjs_output_dir, 'group*-*'))[0] - weight_file_bytes = os.path.getsize(weight_path) - model_weight_bytes = sum(w.size * 4 for w in model.get_weights()) - self.assertEqual(weight_file_bytes, model_weight_bytes) - - with tf.Graph().as_default(), tf.compat.v1.Session(): - # Load the converted mode back. - model_json_path = os.path.join(tfjs_output_dir, 'model.json') - model_prime = keras_tfjs_loader.load_keras_model(model_json_path) - new_weights = model_prime.get_weights() - - # Check the equality of the old and new model JSONs. - self.assertEqual(old_model_json, json.loads(model_prime.to_json())) - - # Check the equality of the old and new weights. - self.assertAllClose(old_weights, new_weights) - - def testWrongConverterRaisesCorrectErrorMessage(self): - with tf.Graph().as_default(), tf.compat.v1.Session(): - model = self._createSimpleSequentialModel() - tf.keras.models.save_model(model, self._tmp_dir, save_format='tf') - - # Convert the keras SavedModel to tfjs format. - tfjs_output_dir = os.path.join(self._tmp_dir, 'tfjs') - # Use wrong dispatcher. - with self.assertRaisesRegexp( # pylint: disable=deprecated-method - ValueError, - r'Expected path to point to an HDF5 file, but it points to a ' - r'directory'): - converter.dispatch_keras_h5_to_tfjs_layers_model_conversion( - self._tmp_dir, tfjs_output_dir) - - def testConvertTfKerasNestedSequentialSavedAsSavedModel(self): - with tf.Graph().as_default(), tf.compat.v1.Session(): - model = self._createNestedSequentialModel() - old_model_json = json.loads(model.to_json()) - old_weights = model.get_weights() - tf.keras.models.save_model(model, self._tmp_dir, save_format='tf') - - # Convert the keras SavedModel to tfjs format. - tfjs_output_dir = os.path.join(self._tmp_dir, 'tfjs') - converter.dispatch_keras_saved_model_to_tensorflowjs_conversion( - self._tmp_dir, tfjs_output_dir) - - # Verify the size of the weight file. - weight_path = glob.glob(os.path.join(tfjs_output_dir, 'group*-*'))[0] - weight_file_bytes = os.path.getsize(weight_path) - model_weight_bytes = sum(w.size * 4 for w in model.get_weights()) - self.assertEqual(weight_file_bytes, model_weight_bytes) - - with tf.Graph().as_default(), tf.compat.v1.Session(): - # Load the converted mode back. - model_json_path = os.path.join(tfjs_output_dir, 'model.json') - model_prime = keras_tfjs_loader.load_keras_model(model_json_path) - new_weights = model_prime.get_weights() - - # Check the equality of the old and new model JSONs. - self.assertEqual(old_model_json, json.loads(model_prime.to_json())) - - # Check the equality of the old and new weights. - self.assertAllClose(old_weights, new_weights) - - def testConvertTfKerasFunctionalModelWithWeightsSavedAsSavedModel(self): - with tf.Graph().as_default(), tf.compat.v1.Session(): - model = self._createFunctionalModelWithWeights() - old_model_json = json.loads(model.to_json()) - old_weights = model.get_weights() - tf.keras.models.save_model(model, self._tmp_dir, save_format='tf') - - # Convert the keras SavedModel to tfjs format. - tfjs_output_dir = os.path.join(self._tmp_dir, 'tfjs') - converter.dispatch_keras_saved_model_to_tensorflowjs_conversion( - self._tmp_dir, tfjs_output_dir) - - # Verify the size of the weight file. - weight_path = glob.glob(os.path.join(tfjs_output_dir, 'group*-*'))[0] - weight_file_bytes = os.path.getsize(weight_path) - model_weight_bytes = sum(w.size * 4 for w in model.get_weights()) - self.assertEqual(weight_file_bytes, model_weight_bytes) - - with tf.Graph().as_default(), tf.compat.v1.Session(): - # Load the converted mode back. - model_json_path = os.path.join(tfjs_output_dir, 'model.json') - model_prime = keras_tfjs_loader.load_keras_model(model_json_path) - new_weights = model_prime.get_weights() - - # Check the equality of the old and new model JSONs. - self.assertEqual(old_model_json, json.loads(model_prime.to_json())) - - # Check the equality of the old and new weights. - self.assertAllClose(old_weights, new_weights) - - def testConvertTfKerasSequentialSavedAsSavedModelWithQuantization(self): - with tf.Graph().as_default(), tf.compat.v1.Session(): - model = self._createSimpleSequentialModel() - tf.keras.models.save_model(model, self._tmp_dir, save_format='tf') - - # Convert the keras SavedModel to tfjs format. - tfjs_output_dir = os.path.join(self._tmp_dir, 'tfjs') - converter.dispatch_keras_saved_model_to_tensorflowjs_conversion( - self._tmp_dir, tfjs_output_dir, - quantization_dtype_map={'uint16': '*'}) - - # Verify the size of the weight file. - weight_path = glob.glob(os.path.join(tfjs_output_dir, 'group*-*'))[0] - weight_file_bytes = os.path.getsize(weight_path) - # Each uint16 number has 2 bytes. - bytes_per_num = 2 - model_weight_bytes = sum( - w.size * bytes_per_num for w in model.get_weights()) - self.assertEqual(weight_file_bytes, model_weight_bytes) - - def testConvertTfjsLayersModelToShardedWeights(self): - with tf.Graph().as_default(), tf.compat.v1.Session(): - model = self._createSimpleSequentialModel() - weights = model.get_weights() - total_weight_bytes = sum(np.size(w) for w in weights) * 4 - - # Save the keras model to a .h5 file. - h5_path = os.path.join(self._tmp_dir, 'model.h5') - model.save(h5_path) - - # Convert the keras SavedModel to tfjs format. - tfjs_output_dir = os.path.join(self._tmp_dir, 'tfjs') - converter.dispatch_keras_h5_to_tfjs_layers_model_conversion( - h5_path, tfjs_output_dir) - - weight_shard_size_bytes = int(total_weight_bytes * 0.3) - # Due to the shard size, there ought to be 4 shards after conversion. - - # Convert the tfjs model to another tfjs model, with a specified weight - # shard size. - sharded_model_path = os.path.join(self._tmp_dir, 'sharded_model') - converter.dispatch_tensorflowjs_to_tensorflowjs_conversion( - os.path.join(tfjs_output_dir, 'model.json'), sharded_model_path, - weight_shard_size_bytes=weight_shard_size_bytes) - - # Check the number of sharded files and their sizes. - weight_files = sorted( - glob.glob(os.path.join(sharded_model_path, 'group*.bin'))) - self.assertEqual(len(weight_files), 4) - weight_file_sizes = [os.path.getsize(f) for f in weight_files] - self.assertEqual(sum(weight_file_sizes), total_weight_bytes) - self.assertEqual(weight_file_sizes[0], weight_file_sizes[1]) - self.assertEqual(weight_file_sizes[0], weight_file_sizes[2]) - self.assertLess(weight_file_sizes[3], weight_file_sizes[0]) - - def testConvertTfjsLayersModelWithShardSizeGreaterThanTotalWeightSize(self): - with tf.Graph().as_default(), tf.compat.v1.Session(): - model = self._createSimpleSequentialModel() - weights = model.get_weights() - total_weight_bytes = sum(np.size(w) for w in weights) * 4 - - # Save the keras model to a .h5 file. - h5_path = os.path.join(self._tmp_dir, 'model.h5') - model.save(h5_path) - - # Convert the keras SavedModel to tfjs format. - tfjs_output_dir = os.path.join(self._tmp_dir, 'tfjs') - converter.dispatch_keras_h5_to_tfjs_layers_model_conversion( - h5_path, tfjs_output_dir) - - weight_shard_size_bytes = int(total_weight_bytes * 2) - # Due to the shard size, there ought to be 1 shard after conversion. - - # Convert the tfjs model to another tfjs model, with a specified weight - # shard size. - sharded_model_path = os.path.join(self._tmp_dir, 'sharded_model') - converter.dispatch_tensorflowjs_to_tensorflowjs_conversion( - os.path.join(tfjs_output_dir, 'model.json'), sharded_model_path, - weight_shard_size_bytes=weight_shard_size_bytes) - - # Check the number of sharded files and their sizes. - weight_files = sorted( - glob.glob(os.path.join(sharded_model_path, 'group*.bin'))) - self.assertEqual(len(weight_files), 1) - weight_file_sizes = [os.path.getsize(f) for f in weight_files] - self.assertEqual(sum(weight_file_sizes), total_weight_bytes) - - def testTfjsLayer2TfjsLayersConversionWithExistingFilePathFails(self): - with tf.Graph().as_default(), tf.compat.v1.Session(): - model = self._createSimpleSequentialModel() - - # Save the keras model to a .h5 file. - h5_path = os.path.join(self._tmp_dir, 'model.h5') - model.save(h5_path) - - # Convert the keras SavedModel to tfjs format. - tfjs_output_dir = os.path.join(self._tmp_dir, 'tfjs') - converter.dispatch_keras_h5_to_tfjs_layers_model_conversion( - h5_path, tfjs_output_dir) - - # Convert the tfjs model to another tfjs model, with a specified weight - # shard size. - sharded_model_path = os.path.join(self._tmp_dir, 'sharded_model') - with open(sharded_model_path, 'wt') as f: - # Create a fie at the path to elicit the error. - f.write('hello') - with self.assertRaisesRegexp( # pylint: disable=deprecated-method - ValueError, r'already exists as a file'): - converter.dispatch_tensorflowjs_to_tensorflowjs_conversion( - os.path.join(tfjs_output_dir, 'model.json'), sharded_model_path) - - def testConvertTfjsLayersModelWithUint16Quantization(self): - with tf.Graph().as_default(), tf.compat.v1.Session(): - model = self._createSimpleSequentialModel() - weights = model.get_weights() - total_weight_bytes = sum(np.size(w) for w in weights) * 4 - - # Save the keras model to a .h5 file. - h5_path = os.path.join(self._tmp_dir, 'model.h5') - model.save(h5_path) - - # Convert the keras SavedModel to tfjs format. - tfjs_output_dir = os.path.join(self._tmp_dir, 'tfjs') - converter.dispatch_keras_h5_to_tfjs_layers_model_conversion( - h5_path, tfjs_output_dir) - - weight_shard_size_bytes = int(total_weight_bytes * 2) - # Due to the shard size, there ought to be 1 shard after conversion. - - # Convert the tfjs model to another tfjs model, with quantization. - sharded_model_path = os.path.join(self._tmp_dir, 'sharded_model') - converter.dispatch_tensorflowjs_to_tensorflowjs_conversion( - os.path.join(tfjs_output_dir, 'model.json'), sharded_model_path, - quantization_dtype_map={'uint16': '*'}, - weight_shard_size_bytes=weight_shard_size_bytes) - - # Check the number of quantized files and their sizes. - weight_files = sorted( - glob.glob(os.path.join(sharded_model_path, 'group*.bin'))) - self.assertEqual(len(weight_files), 1) - weight_file_size = os.path.getsize(weight_files[0]) - - # The size of the saved weight file should reflect the result of the - # uint16 quantization. - self.assertEqual(weight_file_size, total_weight_bytes / 2) - - def testConvertTfjsLayersModelWithUint8Quantization(self): - with tf.Graph().as_default(), tf.compat.v1.Session(): - model = self._createSimpleSequentialModel() - weights = model.get_weights() - total_weight_bytes = sum(np.size(w) for w in weights) * 4 - - # Save the keras model to a .h5 file. - h5_path = os.path.join(self._tmp_dir, 'model.h5') - model.save(h5_path) - - # Convert the keras SavedModel to tfjs format. - tfjs_output_dir = os.path.join(self._tmp_dir, 'tfjs') - converter.dispatch_keras_h5_to_tfjs_layers_model_conversion( - h5_path, tfjs_output_dir) - - weight_shard_size_bytes = int(total_weight_bytes * 2) - # Due to the shard size, there ought to be 1 shard after conversion. - - # Convert the tfjs model to another tfjs model, with quantization. - sharded_model_path = os.path.join(self._tmp_dir, 'sharded_model') - converter.dispatch_tensorflowjs_to_tensorflowjs_conversion( - os.path.join(tfjs_output_dir, 'model.json'), sharded_model_path, - quantization_dtype_map={'uint8': '*'}, - weight_shard_size_bytes=weight_shard_size_bytes) - - # Check the number of quantized files and their sizes. - weight_files = sorted( - glob.glob(os.path.join(sharded_model_path, 'group*.bin'))) - self.assertEqual(len(weight_files), 1) - weight_file_size = os.path.getsize(weight_files[0]) - - # The size of the saved weight file should reflect the result of the - # uint16 quantization. - self.assertEqual(weight_file_size, total_weight_bytes / 4) - - def testConvertTfjsLayersModelToKerasSavedModel(self): - with tf.Graph().as_default(), tf.compat.v1.Session(): - model = self._createSimpleSequentialModel() - - # Save the keras model to a .h5 file. - h5_path = os.path.join(self._tmp_dir, 'model.h5') - model.save(h5_path) - - # Convert the keras SavedModel to tfjs format. - tfjs_output_dir = os.path.join(self._tmp_dir, 'tfjs') - converter.dispatch_keras_h5_to_tfjs_layers_model_conversion( - h5_path, tfjs_output_dir) - - # Convert the tfjs LayersModel to tf.keras SavedModel. - keras_saved_model_dir = os.path.join(self._tmp_dir, 'saved_model') - converter.dispatch_tensorflowjs_to_keras_saved_model_conversion( - os.path.join(tfjs_output_dir, 'model.json'), keras_saved_model_dir) - - # Check the files of the keras SavedModel. - files = glob.glob(os.path.join(keras_saved_model_dir, '*')) - self.assertIn(os.path.join(keras_saved_model_dir, 'saved_model.pb'), files) - self.assertIn(os.path.join(keras_saved_model_dir, 'variables'), files) - self.assertIn(os.path.join(keras_saved_model_dir, 'assets'), files) - - -if __name__ == '__main__': - tf.test.main() diff --git a/tfjs-master/tfjs-converter/python/tensorflowjs/converters/fold_batch_norms.py b/tfjs-master/tfjs-converter/python/tensorflowjs/converters/fold_batch_norms.py deleted file mode 100644 index f76079001..000000000 --- a/tfjs-master/tfjs-converter/python/tensorflowjs/converters/fold_batch_norms.py +++ /dev/null @@ -1,272 +0,0 @@ -# Copyright 2019 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================== -"""Folding the BatchNorm op into Conv2D.""" - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -import math - -import numpy as np -from tensorflow.core.framework import attr_value_pb2 -from tensorflow.core.framework import graph_pb2 -from tensorflow.core.framework import node_def_pb2 -from tensorflow.python.framework import tensor_util -from tensorflow.python.platform import tf_logging - -from tensorflowjs.converters import graph_rewrite_util - -INPUT_ORDER = { - # Order of inputs for BatchNormWithGlobalNormalization. - "BatchNormWithGlobalNormalization": [ - "conv_op", "mean_op", "var_op", "beta_op", "gamma_op" - ], - # Order of inputs for FusedBatchNorm. - "FusedBatchNorm": ["conv_op", "gamma_op", "beta_op", "mean_op", "var_op"], - # Order of inputs for FusedBatchNormV3. - "FusedBatchNormV3": ["conv_op", "gamma_op", "beta_op", "mean_op", "var_op"] -} -# Name of the attribute epsilon value is stored in. -EPSILON_ATTR = { - "BatchNormWithGlobalNormalization": "variance_epsilon", - "FusedBatchNorm": "epsilon", - "FusedBatchNormV3": "epsilon" -} - -# pylint: disable=R0915 -def fold_batch_norms(input_graph_def): - """Removes batch normalization ops by folding them into convolutions. - - Batch normalization during training has multiple dynamic parameters that are - updated, but once the graph is finalized these become constants. That means - there's an opportunity to reduce the computations down to a scale and - addition, rather than the more expensive multiple ops, and even bake the - scaling into the convolution weights. This function identifies the typical - pattern of batch normalization subgraphs, and performs the transformation to - fold the computations down into a simpler form. It currently only supports - batch normalization that's performed by the BatchNormWithGlobalNormalization - FusedBatchNorm and FusedBatchNormV3 ops, and will need to be extended in the - future to handle the newer style. - - Args: - input_graph_def: A GraphDef containing a model. - - Returns: - Modified graph with BN ops removed, and modified weights. - - Raises: - ValueError: If the graph is badly formed with duplicate node names. - """ - input_node_map = {} - for node in input_graph_def.node: - if node.name not in input_node_map: - input_node_map[node.name] = node - else: - raise ValueError("Duplicate node names detected for ", node.name) - - nodes_to_skip = {} - new_ops = [] - for node in input_graph_def.node: - if (node.op not in ("BatchNormWithGlobalNormalization", - "FusedBatchNorm", "FusedBatchNormV3")): - continue - - bias = None - conv_op = graph_rewrite_util.node_from_map( - input_node_map, - node.input[INPUT_ORDER[node.op].index("conv_op")]) - # There might be an Add/BiasAdd op between the conv and the batchnorm, - # which we can fold into the mean param of the batchnorm. - if conv_op.op in ['BiasAdd', 'Add', 'AddV2']: - add_op = conv_op - # Follow the first input of the add to get to the conv. - conv_op = graph_rewrite_util.node_from_map( - input_node_map, add_op.input[0]) - bias = graph_rewrite_util.node_from_map(input_node_map, add_op.input[1]) - if conv_op.op not in ["Conv2D", "DepthwiseConv2dNative"]: - # Follow the second input of the add to get to the conv. - conv_op = graph_rewrite_util.node_from_map( - input_node_map, add_op.input[1]) - bias = graph_rewrite_util.node_from_map(input_node_map, add_op.input[0]) - if bias and bias.op != 'Const': - tf_logging.warning("The bias %s after the conv %s was not a constant. " - "Maybe because freeze_graph wasn't " - "run first?" % (bias.name, conv_op.name)) - continue - if conv_op.op not in ["Conv2D", "DepthwiseConv2dNative"]: - tf_logging.warning("Didn't find expected Conv2D or DepthwiseConv2dNative" - " input to '%s'" % node.name) - continue - weights_op = graph_rewrite_util.node_from_map( - input_node_map, conv_op.input[1]) - if weights_op.op != "Const": - tf_logging.warning("Didn't find expected conv Constant input to '%s'," - " found %s instead. Maybe because freeze_graph wasn't" - " run first?" % (conv_op.name, weights_op)) - continue - weights = graph_rewrite_util.values_from_const(weights_op) - if conv_op.op == "Conv2D": - channel_count = weights.shape[3] - elif conv_op.op == "DepthwiseConv2dNative": - channel_count = weights.shape[2] * weights.shape[3] - - mean_op = graph_rewrite_util.node_from_map( - input_node_map, - node.input[INPUT_ORDER[node.op].index("mean_op")]) - if mean_op.op != "Const": - tf_logging.warning("Didn't find expected mean Constant input to '%s'," - " found %s instead. Maybe because freeze_graph wasn't" - " run first?" % (node.name, mean_op)) - continue - mean_value = graph_rewrite_util.values_from_const(mean_op) - if bias is not None: - # Adjust the mean of the batchnorm based on the add op in-between the conv - # and the batchnorm. - mean_value = mean_value - graph_rewrite_util.values_from_const(bias) - if mean_value.shape != (channel_count,): - tf_logging.warning("Incorrect shape for mean, found %s, expected %s," - " for node %s" % (str(mean_value.shape), str( - (channel_count,)), node.name)) - continue - - var_op = graph_rewrite_util.node_from_map( - input_node_map, - node.input[INPUT_ORDER[node.op].index("var_op")]) - if var_op.op != "Const": - tf_logging.warning("Didn't find expected var Constant input to '%s'," - " found %s instead. Maybe because freeze_graph wasn't" - " run first?" % (node.name, var_op)) - continue - var_value = graph_rewrite_util.values_from_const(var_op) - if var_value.shape != (channel_count,): - tf_logging.warning("Incorrect shape for var, found %s, expected %s," - " for node %s" % (str(var_value.shape), str( - (channel_count,)), node.name)) - continue - - beta_op = graph_rewrite_util.node_from_map( - input_node_map, - node.input[INPUT_ORDER[node.op].index("beta_op")]) - if beta_op.op != "Const": - tf_logging.warning("Didn't find expected beta Constant input to '%s'," - " found %s instead. Maybe because freeze_graph wasn't" - " run first?" % (node.name, beta_op)) - continue - beta_value = graph_rewrite_util.values_from_const(beta_op) - if beta_value.shape != (channel_count,): - tf_logging.warning("Incorrect shape for beta, found %s, expected %s," - " for node %s" % (str(beta_value.shape), str( - (channel_count,)), node.name)) - continue - - gamma_op = graph_rewrite_util.node_from_map( - input_node_map, - node.input[INPUT_ORDER[node.op].index("gamma_op")]) - if gamma_op.op != "Const": - tf_logging.warning("Didn't find expected gamma Constant input to '%s'," - " found %s instead. Maybe because freeze_graph wasn't" - " run first?" % (node.name, gamma_op)) - continue - gamma_value = graph_rewrite_util.values_from_const(gamma_op) - if gamma_value.shape != (channel_count,): - tf_logging.warning("Incorrect shape for gamma, found %s, expected %s," - " for node %s" % (str(gamma_value.shape), str( - (channel_count,)), node.name)) - continue - - variance_epsilon_value = node.attr[EPSILON_ATTR[node.op]].f - nodes_to_skip[node.name] = True - nodes_to_skip[weights_op.name] = True - nodes_to_skip[conv_op.name] = True - if bias is not None: - nodes_to_skip[add_op.name] = True - - if scale_after_normalization(node): - scale_value = ( - (1.0 / np.vectorize(math.sqrt)(var_value + variance_epsilon_value)) * - gamma_value) - else: - scale_value = ( - 1.0 / np.vectorize(math.sqrt)(var_value + variance_epsilon_value)) - offset_value = (-mean_value * scale_value) + beta_value - scaled_weights = np.copy(weights) - it = np.nditer( - scaled_weights, flags=["multi_index"], op_flags=["readwrite"]) - if conv_op.op == "Conv2D": - while not it.finished: - current_scale = scale_value[it.multi_index[3]] - it[0] *= current_scale - it.iternext() - elif conv_op.op == "DepthwiseConv2dNative": - channel_multiplier = weights.shape[3] - while not it.finished: - current_scale = scale_value[it.multi_index[2] * channel_multiplier + - it.multi_index[3]] - it[0] *= current_scale - it.iternext() - scaled_weights_op = node_def_pb2.NodeDef() - scaled_weights_op.op = "Const" - scaled_weights_op.name = conv_op.name + '_weights' - scaled_weights_op.attr["dtype"].CopyFrom(weights_op.attr["dtype"]) - scaled_weights_op.attr["value"].CopyFrom( - attr_value_pb2.AttrValue(tensor=tensor_util.make_tensor_proto( - scaled_weights, weights.dtype.type, weights.shape))) - # Replace the weights node with scaled weights node - for i, weights_node in enumerate(conv_op.input): - if weights_node == weights_op.name: - conv_op.input[i] = scaled_weights_op.name - - new_conv_op = node_def_pb2.NodeDef() - new_conv_op.CopyFrom(conv_op) - offset_op = node_def_pb2.NodeDef() - offset_op.op = "Const" - offset_op.name = conv_op.name + "_bn_offset" - offset_op.attr["dtype"].CopyFrom(mean_op.attr["dtype"]) - offset_op.attr["value"].CopyFrom( - attr_value_pb2.AttrValue(tensor=tensor_util.make_tensor_proto( - offset_value, mean_value.dtype.type, offset_value.shape))) - bias_add_op = node_def_pb2.NodeDef() - bias_add_op.op = "BiasAdd" - bias_add_op.name = node.name - bias_add_op.attr["T"].CopyFrom(conv_op.attr["T"]) - bias_add_op.attr["data_format"].CopyFrom(conv_op.attr["data_format"]) - bias_add_op.input.extend([new_conv_op.name, offset_op.name]) - new_ops.extend([scaled_weights_op, new_conv_op, offset_op, bias_add_op]) - - result_graph_def = graph_pb2.GraphDef() - for node in input_graph_def.node: - if node.name in nodes_to_skip: - continue - new_node = node_def_pb2.NodeDef() - new_node.CopyFrom(node) - retained_input = [] - for input_node in new_node.input: - if not input_node.startswith('^') or input_node[1:] not in nodes_to_skip: - retained_input.append(input_node) - new_node.input[:] = retained_input - - result_graph_def.node.extend([new_node]) - - result_graph_def.node.extend(new_ops) - result_graph_def.library.CopyFrom(input_graph_def.library) - result_graph_def.versions.CopyFrom(input_graph_def.versions) - return result_graph_def - -# Whether to scale by gamma after normalization. -def scale_after_normalization(node): - if node.op == "BatchNormWithGlobalNormalization": - return node.attr["scale_after_normalization"].b - return True diff --git a/tfjs-master/tfjs-converter/python/tensorflowjs/converters/fold_batch_norms_test.py b/tfjs-master/tfjs-converter/python/tensorflowjs/converters/fold_batch_norms_test.py deleted file mode 100644 index c641e0abb..000000000 --- a/tfjs-master/tfjs-converter/python/tensorflowjs/converters/fold_batch_norms_test.py +++ /dev/null @@ -1,269 +0,0 @@ -# Copyright 2018 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================== -"""Unit tests for batch norm folding.""" - -import os -import shutil -import tempfile - -import numpy as np -import tensorflow.compat.v1 as tf1 -import tensorflow.compat.v2 as tf -from tensorflow.python.framework import constant_op -from tensorflow.python.framework import dtypes -from tensorflow.python.framework import importer -from tensorflow.python.framework import ops -from tensorflow.python.framework import test_util -from tensorflow.python.ops import gen_nn_ops -from tensorflow.python.ops import nn_ops -from tensorflowjs.converters import fold_batch_norms - -class FoldBatchNormsTest(tf.test.TestCase): - def setUp(self): - super(FoldBatchNormsTest, self).setUp() - self._tmp_dir = tempfile.mkdtemp() - - def tearDown(self): - if os.path.isdir(self._tmp_dir): - shutil.rmtree(self._tmp_dir) - super(FoldBatchNormsTest, self).tearDown() - - def testFoldBatchNorms(self): - with tf1.Session() as sess: - inputs = [1, 4, 2, 5, 3, 6, -1, -4, -2, -5, -3, -6] - input_op = constant_op.constant( - np.array(inputs), shape=[1, 1, 6, 2], dtype=dtypes.float32) - weights = [1, 2, 3, 4, 0.1, 0.2, 0.3, 0.4] - weights_op = constant_op.constant( - np.array(weights), shape=[1, 2, 2, 2], dtype=dtypes.float32) - conv_op = nn_ops.conv2d( - input_op, weights_op, [1, 1, 1, 1], padding="SAME", name="conv_op") - mean_op = constant_op.constant( - np.array([10, 20]), shape=[2], dtype=dtypes.float32) - variance_op = constant_op.constant( - np.array([0.25, 0.5]), shape=[2], dtype=dtypes.float32) - beta_op = constant_op.constant( - np.array([0.1, 0.6]), shape=[2], dtype=dtypes.float32) - gamma_op = constant_op.constant( - np.array([1.0, 2.0]), shape=[2], dtype=dtypes.float32) - test_util.set_producer_version(ops.get_default_graph(), 8) - gen_nn_ops._batch_norm_with_global_normalization( - conv_op, - mean_op, - variance_op, - beta_op, - gamma_op, - 0.00001, - False, - name="output") - original_graph_def = sess.graph_def - original_result = sess.run(["output:0"]) - optimized_graph_def = fold_batch_norms.fold_batch_norms( - original_graph_def) - with tf1.Session() as sess: - _ = importer.import_graph_def( - optimized_graph_def, input_map={}, name="optimized") - optimized_result = sess.run(["optimized/output:0"]) - - self.assertAllClose(original_result, optimized_result) - - for node in optimized_graph_def.node: - self.assertNotEqual("BatchNormWithGlobalNormalization", node.op) - - def testFoldFusedBatchNorms(self): - for data_format, conv2d_func in [ - ("NHWC", nn_ops.conv2d), ("NCHW", nn_ops.conv2d), - ("NHWC", nn_ops.depthwise_conv2d_native), - ("NCHW", nn_ops.depthwise_conv2d_native) - ]: - with tf1.Session() as sess: - inputs = [1, 4, 2, 5, 3, 6, -1, -4, -2, -5, -3, -6] - input_op = constant_op.constant( - np.array(inputs), - shape=[1, 1, 6, 2] if data_format == "NHWC" else [1, 2, 1, 6], - dtype=dtypes.float32) - if conv2d_func == nn_ops.conv2d: - weights = [1, 2, 3, 4, 0.1, 0.2, 0.3, 0.4] - weights_op = constant_op.constant( - np.array(weights), shape=[1, 2, 2, 2], dtype=dtypes.float32) - else: - weights = [1, 2, 0.3, 0.4] - weights_op = constant_op.constant( - np.array(weights), shape=[1, 2, 2, 1], dtype=dtypes.float32) - conv_op = conv2d_func( - input_op, - weights_op, [1, 1, 1, 1], - padding="SAME", - data_format=data_format, - name="conv_op") - mean_op = constant_op.constant( - np.array([10, 20]), shape=[2], dtype=dtypes.float32) - variance_op = constant_op.constant( - np.array([0.25, 0.5]), shape=[2], dtype=dtypes.float32) - beta_op = constant_op.constant( - np.array([0.1, 0.6]), shape=[2], dtype=dtypes.float32) - gamma_op = constant_op.constant( - np.array([1.0, 2.0]), shape=[2], dtype=dtypes.float32) - ops.get_default_graph().graph_def_versions.producer = 9 - gen_nn_ops._fused_batch_norm( - conv_op, - gamma_op, - beta_op, - mean_op, - variance_op, - 0.00001, - is_training=False, - data_format=data_format, - name="output") - original_graph_def = sess.graph_def - original_result = sess.run(["output:0"]) - optimized_graph_def = fold_batch_norms.fold_batch_norms( - original_graph_def) - with tf1.Session() as sess: - _ = importer.import_graph_def( - optimized_graph_def, input_map={}, name="optimized") - optimized_result = sess.run(["optimized/output:0"]) - - self.assertAllClose( - original_result, optimized_result, rtol=1e-04, atol=1e-06) - - for node in optimized_graph_def.node: - self.assertNotEqual("FusedBatchNorm", node.op) - - def testFoldFusedBatchNormsV3(self): - for data_format, conv2d_func in [ - ("NHWC", nn_ops.conv2d), ("NCHW", nn_ops.conv2d), - ("NHWC", nn_ops.depthwise_conv2d_native), - ("NCHW", nn_ops.depthwise_conv2d_native) - ]: - with tf1.Session() as sess: - _generate_fused_batchnorm(data_format, conv2d_func) - original_graph_def = sess.graph_def - original_result = sess.run(["output:0"]) - optimized_graph_def = fold_batch_norms.fold_batch_norms( - original_graph_def) - with tf1.Session() as sess: - _ = importer.import_graph_def( - optimized_graph_def, input_map={}, name="optimized") - optimized_result = sess.run(["optimized/output:0"]) - - self.assertAllClose( - original_result, optimized_result, rtol=1e-04, atol=1e-06) - - for node in optimized_graph_def.node: - self.assertNotEqual("FusedBatchNormV3", node.op) - - - def testFoldFusedBatchNormWithBias(self): - for data_format, conv2d_func in [ - ("NHWC", nn_ops.conv2d), - ("NHWC", nn_ops.depthwise_conv2d_native), - ]: - graph = tf1.Graph() - with tf1.Session(graph=graph) as sess: - count = 1 - add_bias = True - _generate_fused_batchnorm(data_format, conv2d_func, count, add_bias) - original_graph_def = sess.graph_def - original_result = sess.run(["output:0"]) - optimized_graph_def = fold_batch_norms.fold_batch_norms( - original_graph_def) - with tf1.Session() as sess: - _ = importer.import_graph_def( - optimized_graph_def, input_map={}, name="optimized") - optimized_result = sess.run(["optimized/output:0"]) - - self.assertAllClose( - original_result, optimized_result, rtol=1e-04, atol=1e-06) - - bias_nodes = [ - node for node in optimized_graph_def.node if node.op == 'BiasAdd' - ] - self.assertEqual(len(bias_nodes), 1) - for node in optimized_graph_def.node: - self.assertNotEqual("FusedBatchNormV3", node.op) - - def testFoldFusedBatchNormsWithSharedWeights(self): - for data_format, conv2d_func in [ - ("NHWC", nn_ops.conv2d), ("NCHW", nn_ops.conv2d), - ("NHWC", nn_ops.depthwise_conv2d_native), - ("NCHW", nn_ops.depthwise_conv2d_native) - ]: - with tf1.Session() as sess: - _generate_fused_batchnorm(data_format, conv2d_func, 2) - original_graph_def = sess.graph_def - original_result = sess.run(["output:0"]) - optimized_graph_def = fold_batch_norms.fold_batch_norms( - original_graph_def) - with tf1.Session() as sess: - _ = importer.import_graph_def( - optimized_graph_def, input_map={}, name="optimized") - optimized_result = sess.run(["optimized/output:0"]) - - self.assertAllClose( - original_result, optimized_result, rtol=1e-04, atol=1e-06) - - for node in optimized_graph_def.node: - self.assertNotEqual("FusedBatchNormV3", node.op) - -def _generate_fused_batchnorm(data_format, conv2d_func, count=1, - add_bias=False): - inputs = [1, 4, 2, 5, 3, 6, -1, -4, -2, -5, -3, -6] - input_op = constant_op.constant( - np.array(inputs), - shape=[1, 1, 6, 2] if data_format == "NHWC" else [1, 2, 1, 6], - dtype=dtypes.float32) - if conv2d_func == nn_ops.conv2d: # pylint: disable=W0143 - weights = [1, 2, 3, 4, 0.1, 0.2, 0.3, 0.4] - weights_op = constant_op.constant( - np.array(weights), shape=[1, 2, 2, 2], dtype=dtypes.float32) - else: - weights = [1, 2, 0.3, 0.4] - weights_op = constant_op.constant( - np.array(weights), shape=[1, 2, 2, 1], dtype=dtypes.float32) - mean_op = constant_op.constant( - np.array([10, 20]), shape=[2], dtype=dtypes.float32) - variance_op = constant_op.constant( - np.array([0.25, 0.5]), shape=[2], dtype=dtypes.float32) - beta_op = constant_op.constant( - np.array([0.1, 0.6]), shape=[2], dtype=dtypes.float32) - gamma_op = constant_op.constant( - np.array([1.0, 2.0]), shape=[2], dtype=dtypes.float32) - ops.get_default_graph().graph_def_versions.producer = 9 - for _ in range(count): - conv_op = conv2d_func( - input_op, - weights_op, [1, 1, 1, 1], - padding="SAME", - data_format=data_format, - name="conv_op") - if add_bias: - out_channels = conv_op.shape[3] - bias = constant_op.constant( - np.array([1.0]*out_channels), - shape=[out_channels], dtype=dtypes.float32) - conv_op = nn_ops.bias_add(conv_op, bias) - gen_nn_ops.fused_batch_norm_v3( - conv_op, - gamma_op, - beta_op, - mean_op, - variance_op, - 0.00001, - is_training=False, - data_format=data_format, - name="output") -if __name__ == '__main__': - tf.test.main() diff --git a/tfjs-master/tfjs-converter/python/tensorflowjs/converters/fuse_depthwise_conv2d.py b/tfjs-master/tfjs-converter/python/tensorflowjs/converters/fuse_depthwise_conv2d.py deleted file mode 100644 index 8276f80c9..000000000 --- a/tfjs-master/tfjs-converter/python/tensorflowjs/converters/fuse_depthwise_conv2d.py +++ /dev/null @@ -1,164 +0,0 @@ -# Copyright 2019 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the 'License'); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an 'AS IS' BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================== -""" - This transformation rule tries to identify following transformation - DepthwiseConv2dNative + BiasAdd + Activation => FusedDepthwiseConv2dNative -""" - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -from tensorflowjs.converters import graph_rewrite_util - -def _is_supported_activation(node): - return node.op == 'Relu' or node.op == 'Relu6' or node.op == 'Elu' - -def _find_contraction_with_activation(node, node_map): - if not _is_supported_activation(node): - return False - - # And input to the activation node must match ContractionWithBiasAdd pattern. - if len(node.input) != 1: - return False - - conv2d_node = graph_rewrite_util.node_from_map(node_map, node.input[0]) - if conv2d_node.op != 'DepthwiseConv2dNative': - return False - - return {'contraction': conv2d_node, 'bias': None, 'activation': node} - -def _find_contraction_with_bias(node, node_map): - if node.op != 'BiasAdd': - return False - - # Input to the BiasAdd must be a DepthwiseConv2dNative. - if not node.input: - return False - - conv2d_node = graph_rewrite_util.node_from_map(node_map, node.input[0]) - if conv2d_node.op != 'DepthwiseConv2dNative': - return False - - return {'contraction': conv2d_node, 'bias': node, 'activation': None} - -def _find_contraction_with_bias_and_activation(node, node_map): - if not _is_supported_activation(node): - return False - - # And input to the activation node must match ContractionWithBiasAdd pattern. - if len(node.input) != 1: - return False - - bias_add = graph_rewrite_util.node_from_map(node_map, node.input[0]) - - match = _find_contraction_with_bias(bias_add, node_map) - if not match: - return False - - match['activation'] = node - return match - -def _add_fused_contraction_node(contraction, bias_add, activation, - inputs_to_remove, nodes_to_skip): - fused_op = contraction - fused_op.op = graph_rewrite_util.FUSED_DEPTHWISE_CONV2D - fused_op.attr['num_args'].i = 0 - if bias_add: - fused_op.input.extend([bias_add.input[1]]) - - fused_op.attr['fused_ops'].list.s.extend([b'BiasAdd']) - fused_op.attr['num_args'].i = fused_op.attr['num_args'].i + 1 - bias_add.input[:] = [contraction.name] - inputs_to_remove.append(bias_add) - nodes_to_skip[bias_add.name] = True - else: - fused_op.attr['fused_ops'].list.s.extend([b'NoOp']) - - if activation: - fused_op.attr['fused_ops'].list.s.extend([activation.op.encode('ascii')]) - nodes_to_skip[activation.name] = True - activation.input[:] = [contraction.name] - inputs_to_remove.append(activation) - - -def fuse_depthwise_conv2d(input_graph_def): - """Modifies the provided graph by fusing a set of ops into a single - _FusedDepthwiseConv2d op. - - DepthwiseConv2dNative + BiasAdd + Activation => _FusedDepthwiseConv2dNative - - Args: - input_graph_def: A GraphDef containing a model. - - Returns: - Modified graph with FusedDepthwiseConv2dNative ops generated, and modified - weights. - - Raises: - ValueError: If the graph is badly formed with duplicate node names. - """ - # Two passes approach, first find pattern of - # DepthwiseConv2dNative + BiasAdd + Activation - # Then find pattern of - # DepthwiseConv2dNative + BiasAdd - graph_def = _fuse_depthwise_conv2d_with_match_function( - input_graph_def, _find_contraction_with_bias_and_activation) - graph_def = _fuse_depthwise_conv2d_with_match_function( - graph_def, _find_contraction_with_bias) - graph_def = _fuse_depthwise_conv2d_with_match_function( - graph_def, _find_contraction_with_activation) - return graph_def - -def _fuse_depthwise_conv2d_with_match_function(input_graph_def, match_function): - """Modifies the provided graph by fusing a set of ops into a single - _FusedDepthwiseConv2d op. - - DepthwiseConv2dNative + BiasAdd + Activation => _FusedDepthwiseConv2dNative - - Args: - input_graph_def: A GraphDef containing a model. - match_function: A Function that matches the pattern and return a dict of - contraction, bias_add and activation nodes. - - Returns: - Modified graph with FusedDepthwiseConv2dNative ops generated, and modified - weights. - - Raises: - ValueError: If the graph is badly formed with duplicate node names. - """ - input_node_map = {} - for node in input_graph_def.node: - if node.name not in input_node_map: - input_node_map[node.name] = node - else: - raise ValueError('Duplicate node names detected for ', node.name) - - nodes_to_skip = {} - inputs_to_remove = [] - for node in input_graph_def.node: - nodes = match_function(node, input_node_map) - if nodes: - _add_fused_contraction_node(nodes['contraction'], nodes['bias'], - nodes['activation'], inputs_to_remove, - nodes_to_skip) - - if nodes_to_skip or inputs_to_remove: - return graph_rewrite_util.cleanup_graph_def( - input_graph_def, nodes_to_skip, inputs_to_remove) - - # No pattern detected - return input_graph_def diff --git a/tfjs-master/tfjs-converter/python/tensorflowjs/converters/fuse_depthwise_conv2d_test.py b/tfjs-master/tfjs-converter/python/tensorflowjs/converters/fuse_depthwise_conv2d_test.py deleted file mode 100644 index b86850df7..000000000 --- a/tfjs-master/tfjs-converter/python/tensorflowjs/converters/fuse_depthwise_conv2d_test.py +++ /dev/null @@ -1,134 +0,0 @@ -# Copyright 2019 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================== -"""Unit tests for depthwise conv2d op fusing.""" - -import os -import shutil -import tempfile - -import tensorflow.compat.v2 as tf - -from tensorflowjs.converters import fuse_depthwise_conv2d -from tensorflowjs.converters import graph_rewrite_util -from tensorflowjs.converters import tf_saved_model_conversion_v2 - - -class FuseDepthwiseConv2dTest(tf.test.TestCase): - def setUp(self): - super(FuseDepthwiseConv2dTest, self).setUp() - self._tmp_dir = tempfile.mkdtemp() - - def tearDown(self): - if os.path.isdir(self._tmp_dir): - shutil.rmtree(self._tmp_dir) - super(FuseDepthwiseConv2dTest, self).tearDown() - - def testFuseDepthwiseConv2dNativeWithBias(self): - layers = [ - tf.keras.layers.DepthwiseConv2D( - 1, bias_initializer=tf.initializers.constant(0.25)) - ] - model = tf.keras.Sequential(layers) - tf.keras.backend.set_learning_phase(0) - input_tensor = tf.constant([1.0, 1.0], shape=[1, 1, 1, 2]) - - @tf.function - def execute_model(tensor): - return model(tensor) - - graph = tf_saved_model_conversion_v2._freeze_saved_model_v2( - execute_model.get_concrete_function(input_tensor)) - graph_def = graph.as_graph_def() - - optimized_graph_def = fuse_depthwise_conv2d.fuse_depthwise_conv2d(graph_def) - - depthwise_conv2d_count = 0 - depthwise_conv2d = None - for node in optimized_graph_def.node: - self.assertNotEqual("BiasAdd", node.op) - self.assertNotEqual("DepthwiseConv2dNative", node.op) - if node.op == graph_rewrite_util.FUSED_DEPTHWISE_CONV2D: - depthwise_conv2d_count += 1 - depthwise_conv2d = node - self.assertEqual(depthwise_conv2d_count, 1) - self.assertEqual(depthwise_conv2d.attr['fused_ops'].list.s, [b'BiasAdd']) - self.assertEqual(depthwise_conv2d.attr['num_args'].i, 1) - - def testFuseDepthwiseConv2dNativeWithBiasAndActivation(self): - layers = [ - tf.keras.layers.DepthwiseConv2D( - 1, bias_initializer=tf.initializers.constant(0.25)), - tf.keras.layers.ReLU() - ] - model = tf.keras.Sequential(layers) - tf.keras.backend.set_learning_phase(0) - input_tensor = tf.constant([1.0, 1.0], shape=[1, 1, 1, 2]) - - @tf.function - def execute_model(tensor): - return model(tensor) - - graph = tf_saved_model_conversion_v2._freeze_saved_model_v2( - execute_model.get_concrete_function(input_tensor)) - graph_def = graph.as_graph_def() - - optimized_graph_def = fuse_depthwise_conv2d.fuse_depthwise_conv2d(graph_def) - depthwise_conv2d_count = 0 - depthwise_conv2d = None - for node in optimized_graph_def.node: - self.assertNotEqual("BiasAdd", node.op) - self.assertNotEqual("DepthwiseConv2dNative", node.op) - self.assertNotEqual("Relu", node.op) - if node.op == graph_rewrite_util.FUSED_DEPTHWISE_CONV2D: - depthwise_conv2d_count += 1 - depthwise_conv2d = node - self.assertEqual(depthwise_conv2d_count, 1) - self.assertEqual( - depthwise_conv2d.attr['fused_ops'].list.s, [b'BiasAdd', b'Relu']) - self.assertEqual(depthwise_conv2d.attr['num_args'].i, 1) - - def testFuseDepthwiseConv2dNativeWithActivation(self): - layers = [ - tf.keras.layers.DepthwiseConv2D(1, use_bias=False), - tf.keras.layers.ReLU() - ] - model = tf.keras.Sequential(layers) - tf.keras.backend.set_learning_phase(0) - input_tensor = tf.constant([1.0, 1.0], shape=[1, 1, 1, 2]) - - @tf.function - def execute_model(tensor): - return model(tensor) - - graph = tf_saved_model_conversion_v2._freeze_saved_model_v2( - execute_model.get_concrete_function(input_tensor)) - graph_def = graph.as_graph_def() - - optimized_graph_def = fuse_depthwise_conv2d.fuse_depthwise_conv2d(graph_def) - depthwise_conv2d_count = 0 - depthwise_conv2d = None - for node in optimized_graph_def.node: - self.assertNotEqual("BiasAdd", node.op) - self.assertNotEqual("DepthwiseConv2dNative", node.op) - self.assertNotEqual("Relu", node.op) - if node.op == graph_rewrite_util.FUSED_DEPTHWISE_CONV2D: - depthwise_conv2d_count += 1 - depthwise_conv2d = node - self.assertEqual(depthwise_conv2d_count, 1) - self.assertEqual( - depthwise_conv2d.attr['fused_ops'].list.s, [b'NoOp', b'Relu']) - self.assertEqual(depthwise_conv2d.attr['num_args'].i, 0) -if __name__ == '__main__': - tf.test.main() diff --git a/tfjs-master/tfjs-converter/python/tensorflowjs/converters/fuse_prelu.py b/tfjs-master/tfjs-converter/python/tensorflowjs/converters/fuse_prelu.py deleted file mode 100644 index 764bf56cc..000000000 --- a/tfjs-master/tfjs-converter/python/tensorflowjs/converters/fuse_prelu.py +++ /dev/null @@ -1,191 +0,0 @@ -# Copyright 2019 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the 'License'); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an 'AS IS' BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================== -""" - This transformation rule tries to identify the PRelu structure generated by - Keras, and convert it to a single op. -""" - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -from tensorflow.core.framework import attr_value_pb2 -from tensorflow.python.framework import tensor_util - -from tensorflowjs.converters import graph_rewrite_util - -def fuse_ops_for_prelu(input_graph_def): - """Modifies the provided graph by fusing a set of ops into a single Prelu op. - The formula of PReLU is: - f(x) = alpha * x for x < 0, f(x) = x for x >= 0. - - `x` is the input, and `alpha` is a trainable tensor which can be broadcasted - to the shape of `x`. - - There's no native PRelu op in TensorFlow, so Keras generates the following - structure which does the equivalent calculation: - f(x) = Relu(x) + (-alpha * Relu(-x)) - - Practically, alpha is always a constant in the inference graph, and grappler - can have other graph transformations which fold the activation functions to - other ops. Therefore, we're looking for the structure: - - f(x) = Relu(x) + (negative_alpha * Neg(x, activation=Relu)) - - Args: - input_graph_def: A GraphDef containing a model. - - Returns: - Modified graph with Prelu ops generated, and modified weights. - - Raises: - ValueError: If the graph is badly formed with duplicate node names. - """ - input_node_map = {} - for node in input_graph_def.node: - if node.name not in input_node_map: - input_node_map[node.name] = node - else: - raise ValueError('Duplicate node names detected for ', node.name) - - nodes_to_skip = {} - inputs_to_remove = [] - updated_alpha = [] - for node in input_graph_def.node: - if (node.op not in ('Add', 'AddV2') or len(node.input) != 2): - continue - - relu_input_op = graph_rewrite_util.node_from_map( - input_node_map, node.input[0]) - if (not relu_input_op or relu_input_op.op != 'Relu'): - continue - - mul_op = graph_rewrite_util.node_from_map(input_node_map, node.input[1]) - if (not mul_op or mul_op.op != 'Mul'): - continue - - neg_alpha_op = None - for name in mul_op.input: - op = graph_rewrite_util.node_from_map(input_node_map, name) - if op.op == 'Const': - neg_alpha_op = op - break - - if not neg_alpha_op: - continue - - alpha_tensor_name = neg_alpha_op.name - - relu_neg_input_op = None - for name in mul_op.input: - op = graph_rewrite_util.node_from_map(input_node_map, name) - if op.op == 'Relu': - relu_neg_input_op = op - break - - if (not relu_neg_input_op or len(relu_neg_input_op.input) != 1 or - relu_neg_input_op.op != 'Relu'): - continue - - # This detects a Neg op followed by a separated Relu op. - neg_input_op = graph_rewrite_util.node_from_map( - input_node_map, relu_neg_input_op.input[0]) - if (not neg_input_op or len(neg_input_op.input) != 1 or - neg_input_op.op != 'Neg'): - continue - final_input_op = neg_input_op - - if relu_input_op.input[0] != final_input_op.input[0]: - continue - - relu_input_op.op = 'Prelu' - relu_input_op.input.extend([alpha_tensor_name]) - # Remove the T attr that is defined in Relu op, since our custom Prelu op - # definition does not have that. - del relu_input_op.attr['T'] - - node.op = 'Identity' - del node.input[:] - node.input.append(relu_input_op.name) - _create_alpha_node(neg_alpha_op, updated_alpha) - - nodes_to_skip[mul_op.name] = True - nodes_to_skip[relu_neg_input_op.name] = True - nodes_to_skip[neg_input_op.name] = True - nodes_to_skip[node.name] = True - inputs_to_remove.append(node) - - return graph_rewrite_util.cleanup_graph_def( - input_graph_def, nodes_to_skip, inputs_to_remove) - -def _create_alpha_node(neg_alpha_op, updated_alpha): - if neg_alpha_op.name not in updated_alpha: - alpha_value = -graph_rewrite_util.values_from_const(neg_alpha_op) - neg_alpha_op.attr['value'].CopyFrom( - attr_value_pb2.AttrValue(tensor=tensor_util.make_tensor_proto( - alpha_value, alpha_value.dtype.type, alpha_value.shape))) - updated_alpha.append(neg_alpha_op.name) - -def fuse_prelu_with_fused_conv2d_or_matmul(input_graph_def): - """Tensorflow does not support Prelu op, and the grappler remap optimizer - will not fuse the prelu op with _FusedConv2D op. This method searches for - the pattern and fuse the (_FusedConv2D||FusedDepthwiseConv2dNative + Prelu) - nodes into a single _FusedConv2D||FusedDepthwiseConv2dNative op with - activation information. - - Args: - input_graph_def: A GraphDef containing a model. - - Returns: - Modified graph with Prelu ops fused with _FusedConv2D or - FusedDepthwiseConv2dNative as activation function - - Raises: - ValueError: If the graph is badly formed with duplicate node names. - """ - input_node_map = {} - nodes_to_skip = {} - inputs_to_remove = [] - for node in input_graph_def.node: - if node.name not in input_node_map: - input_node_map[node.name] = node - else: - raise ValueError('Duplicate node names detected for ', node.name) - - for node in input_graph_def.node: - if node.op != 'Prelu': - continue - - fused_op = graph_rewrite_util.node_from_map( - input_node_map, node.input[0]) - if (not fused_op or - (fused_op.op != '_FusedConv2D' - and fused_op.op != '_FusedMatMul' - and fused_op.op != 'FusedDepthwiseConv2dNative') or - len(fused_op.attr['fused_ops'].list.s) > 1): - continue - - alpha_tensor_name = node.input[1] - - fused_op.input.extend([alpha_tensor_name]) - fused_op.attr['fused_ops'].list.s.extend([b'Prelu']) - fused_op.attr['num_args'].i = fused_op.attr['num_args'].i + 1 - node.op = 'Identity' - node.input[:] = [node.input[0]] - nodes_to_skip[node.name] = True - inputs_to_remove.append(node) - - return graph_rewrite_util.cleanup_graph_def( - input_graph_def, nodes_to_skip, inputs_to_remove) diff --git a/tfjs-master/tfjs-converter/python/tensorflowjs/converters/fuse_prelu_test.py b/tfjs-master/tfjs-converter/python/tensorflowjs/converters/fuse_prelu_test.py deleted file mode 100644 index ffceb14d1..000000000 --- a/tfjs-master/tfjs-converter/python/tensorflowjs/converters/fuse_prelu_test.py +++ /dev/null @@ -1,264 +0,0 @@ -# Copyright 2019 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================== -"""Unit tests for prelu op fusing.""" - -import os -import shutil -import tempfile - -import tensorflow.compat.v2 as tf -from tensorflow.core.protobuf import config_pb2 -from tensorflow.core.protobuf import meta_graph_pb2 -from tensorflow.python.eager import def_function -from tensorflow.python.framework import constant_op -from tensorflow.python.ops import variables -from tensorflow.python.trackable import autotrackable - -from tensorflowjs.converters import fuse_depthwise_conv2d -from tensorflowjs.converters import fuse_prelu -from tensorflowjs.converters import tf_saved_model_conversion_v2 -from tensorflowjs.converters import graph_rewrite_util - -class FusePreluTest(tf.test.TestCase): - def setUp(self): - super(FusePreluTest, self).setUp() - self._tmp_dir = tempfile.mkdtemp() - - def tearDown(self): - if os.path.isdir(self._tmp_dir): - shutil.rmtree(self._tmp_dir) - super(FusePreluTest, self).tearDown() - - def testFusePrelu(self): - layers = [ - tf.keras.layers.PReLU( - alpha_initializer=tf.initializers.constant(0.25)), - tf.keras.layers.PReLU( - alpha_initializer=tf.initializers.constant(0.25)) - ] - model = tf.keras.Sequential(layers) - tf.keras.backend.set_learning_phase(0) - input_tensor = tf.constant([1.0, 1.0]) - - @tf.function - def execute_model(tensor): - return model(tensor) - - graph = tf_saved_model_conversion_v2._freeze_saved_model_v2( - execute_model.get_concrete_function(input_tensor)) - graph_def = graph.as_graph_def() - for node in graph_def.node: - if node.op == 'Conv2D': - node.device = "/CPU:0" - - config = config_pb2.ConfigProto() - rewriter_config = config.graph_options.rewrite_options - rewriter_config.optimizers[:] = [ - 'pruning', 'constfold', 'arithmetic', 'dependency', 'pruning', - 'remap', 'constfold', 'arithmetic', 'dependency' - ] - - for output in ['Identity']: - graph.add_to_collection('train_op', graph.get_operation_by_name(output)) - - signature = meta_graph_pb2.SignatureDef() - graph_def = tf_saved_model_conversion_v2._run_grappler( - config, graph_def, graph, signature) - - optimized_graph_def = fuse_prelu.fuse_ops_for_prelu(graph_def) - - prelu_op_count = 0 - value = None - for node in optimized_graph_def.node: - self.assertNotEqual("Relu", node.op) - if node.op == 'Prelu': - prelu_op_count += 1 - if node.op == 'Const': - value = graph_rewrite_util.values_from_const(node) - self.assertEqual(prelu_op_count, 2) - self.assertEqual(value, [0.25]) - - def testFusePreluWithConv2d(self): - layers = [ - tf.keras.layers.Conv2D( - 16, [3, 3], padding='same', use_bias=True, - bias_initializer=tf.initializers.constant(0.25)), - tf.keras.layers.PReLU() - ] - model = tf.keras.Sequential(layers) - tf.keras.backend.set_learning_phase(0) - input_tensor = tf.constant([1.0, 1.0], shape=[1, 2, 1, 1]) - - @tf.function - def execute_model(tensor): - return model(tensor) - - graph = tf_saved_model_conversion_v2._freeze_saved_model_v2( - execute_model.get_concrete_function(input_tensor)) - graph_def = graph.as_graph_def() - - for node in graph_def.node: - if node.op == 'Conv2D': - node.device = "/CPU:0" - - config = config_pb2.ConfigProto() - rewriter_config = config.graph_options.rewrite_options - rewriter_config.optimizers[:] = [ - 'pruning', 'constfold', 'arithmetic', 'dependency', 'pruning', 'remap', - 'constfold', 'arithmetic', 'dependency' - ] - - for output in ['Identity']: - graph.add_to_collection('train_op', graph.get_operation_by_name(output)) - - signature = meta_graph_pb2.SignatureDef() - graph_def = tf_saved_model_conversion_v2._run_grappler( - config, graph_def, graph, signature) - graph_def = fuse_prelu.fuse_ops_for_prelu(graph_def) - - optimized_graph_def = fuse_prelu.fuse_prelu_with_fused_conv2d_or_matmul( - graph_def) - - conv2d_op = None - for node in optimized_graph_def.node: - self.assertNotEqual("Prelu", node.op) - if node.op == '_FusedConv2D': - conv2d_op = node - self.assertNotEqual(conv2d_op, None) - self.assertEqual(conv2d_op.attr['fused_ops'].list.s, [b'BiasAdd', b'Prelu']) - self.assertEqual(conv2d_op.attr['num_args'].i, 2) - - def testFusePreluWithMatMul(self): - layers = [ - tf.keras.layers.Dense( - 2, use_bias=True, - kernel_initializer=tf.initializers.constant(0.25), - bias_initializer=tf.initializers.constant(0.25)), - tf.keras.layers.PReLU() - ] - model = tf.keras.Sequential(layers) - tf.keras.backend.set_learning_phase(0) - input_tensor = tf.constant([1.0, 1.0], shape=[1, 2]) - - @tf.function - def execute_model(tensor): - return model(tensor) - - graph = tf_saved_model_conversion_v2._freeze_saved_model_v2( - execute_model.get_concrete_function(input_tensor)) - graph_def = graph.as_graph_def() - for node in graph_def.node: - if node.op == 'MatMul': - node.device = "/CPU:0" - - config = config_pb2.ConfigProto() - rewriter_config = config.graph_options.rewrite_options - rewriter_config.optimizers[:] = [ - 'pruning', 'constfold', 'arithmetic', 'dependency', 'pruning', 'remap', - 'constfold', 'arithmetic', 'dependency' - ] - - for output in ['Identity']: - graph.add_to_collection('train_op', graph.get_operation_by_name(output)) - - signature = meta_graph_pb2.SignatureDef() - graph_def = tf_saved_model_conversion_v2._run_grappler( - config, graph_def, graph, signature) - graph_def = fuse_prelu.fuse_ops_for_prelu(graph_def) - optimized_graph_def = fuse_prelu.fuse_prelu_with_fused_conv2d_or_matmul( - graph_def) - - matmul_op = None - for node in optimized_graph_def.node: - self.assertNotEqual("Prelu", node.op) - if node.op == '_FusedMatMul': - matmul_op = node - self.assertNotEqual(matmul_op, None) - self.assertEqual(matmul_op.attr['fused_ops'].list.s, [b'BiasAdd', b'Prelu']) - self.assertEqual(matmul_op.attr['num_args'].i, 2) - - def testFusePreluWithDepthwiseConv2d(self): - layers = [ - tf.keras.layers.DepthwiseConv2D( - 1, bias_initializer=tf.initializers.constant(0.25)), - tf.keras.layers.PReLU() - ] - model = tf.keras.Sequential(layers) - tf.keras.backend.set_learning_phase(0) - input_tensor = tf.constant([1.0, 1.0], shape=[1, 2, 1, 1]) - - @tf.function - def execute_model(tensor): - return model(tensor) - - graph = tf_saved_model_conversion_v2._freeze_saved_model_v2( - execute_model.get_concrete_function(input_tensor)) - graph_def = graph.as_graph_def() - - for node in graph_def.node: - if node.op == 'Conv2D': - node.device = "/CPU:0" - - config = config_pb2.ConfigProto() - rewriter_config = config.graph_options.rewrite_options - rewriter_config.optimizers[:] = [ - 'pruning', 'constfold', 'arithmetic', 'dependency', 'pruning', 'remap', - 'constfold', 'arithmetic', 'dependency' - ] - - for output in ['Identity']: - graph.add_to_collection('train_op', graph.get_operation_by_name(output)) - - signature = meta_graph_pb2.SignatureDef() - graph_def = tf_saved_model_conversion_v2._run_grappler( - config, graph_def, graph, signature) - graph_def = fuse_prelu.fuse_ops_for_prelu(graph_def) - graph_def = fuse_depthwise_conv2d.fuse_depthwise_conv2d(graph_def) - - optimized_graph_def = fuse_prelu.fuse_prelu_with_fused_conv2d_or_matmul( - graph_def) - - conv2d_op = None - for node in optimized_graph_def.node: - self.assertNotEqual("Prelu", node.op) - if node.op == 'FusedDepthwiseConv2dNative': - conv2d_op = node - self.assertNotEqual(conv2d_op, None) - self.assertEqual(conv2d_op.attr['fused_ops'].list.s, [b'BiasAdd', b'Prelu']) - self.assertEqual(conv2d_op.attr['num_args'].i, 2) - - def testNonPreluPattern(self): - """Test a basic model with functions to make sure functions are inlined.""" - input_data = constant_op.constant(1., shape=[1]) - root = autotrackable.AutoTrackable() - root.v1 = variables.Variable(3.) - root.v2 = variables.Variable(2.) - - root.f = def_function.function(lambda x: tf.nn.relu(root.v1) + root.v2 * 2.0) - to_save = root.f.get_concrete_function(input_data) - graph = tf_saved_model_conversion_v2._freeze_saved_model_v2( - root.f.get_concrete_function(input_data)) - graph_def = graph.as_graph_def() - graph_def = fuse_prelu.fuse_ops_for_prelu(graph_def) - const_op = None - for node in graph_def.node: - self.assertNotEqual("Prelu", node.op) - if node.op == 'Const': - const_op = node - self.assertNotEqual(const_op, None) - self.assertEqual(const_op.attr['value'].tensor.float_val, [2.0]) - -if __name__ == '__main__': - tf.test.main() diff --git a/tfjs-master/tfjs-converter/python/tensorflowjs/converters/generate_test_model.py b/tfjs-master/tfjs-converter/python/tensorflowjs/converters/generate_test_model.py deleted file mode 100644 index ab8e990fc..000000000 --- a/tfjs-master/tfjs-converter/python/tensorflowjs/converters/generate_test_model.py +++ /dev/null @@ -1,65 +0,0 @@ -# Copyright 2019 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================== -"""A binary that generates saved model artifacts for testing.""" - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -import argparse -import os -import sys - -import tensorflow.compat.v2 as tf - -def parse_args(): - parser = argparse.ArgumentParser( - 'Generates saved model artifacts for testing.') - parser.add_argument( - 'output_path', - type=str, - help='Model output path.') - parser.add_argument( - '--model_type', - type=str, - required=True, - choices=set(['tf_keras_h5', 'tf_saved_model']), - help='Model format to generate.') - return parser.parse_known_args() - - -def main(_): - - if args.model_type == 'tf_keras_h5': - model = tf.keras.Sequential() - model.add(tf.keras.layers.Dense(5, activation='relu', input_shape=(8,))) - model.add(tf.keras.layers.Dense(1, activation='sigmoid')) - model.save(os.path.join(args.output_path)) - elif args.model_type == 'tf_saved_model': - class TimesThreePlusOne(tf.Module): - - @tf.function(input_signature=[ - tf.TensorSpec(shape=None, dtype=tf.float32)]) - def compute(self, x): - return x * 3.0 + 1.0 - - tf.saved_model.save(TimesThreePlusOne(), args.output_path) - else: - raise ValueError('Unrecognized model type: %s' % args.model_type) - - -if __name__ == '__main__': - args, unparsed = parse_args() - tf.compat.v1.app.run(main=main, argv=[sys.argv[0]] + unparsed) diff --git a/tfjs-master/tfjs-converter/python/tensorflowjs/converters/graph_rewrite_util.py b/tfjs-master/tfjs-converter/python/tensorflowjs/converters/graph_rewrite_util.py deleted file mode 100644 index b2816d3d7..000000000 --- a/tfjs-master/tfjs-converter/python/tensorflowjs/converters/graph_rewrite_util.py +++ /dev/null @@ -1,139 +0,0 @@ -# Copyright 2019 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================== -import re - -from tensorflow.core.framework import graph_pb2 -from tensorflow.core.framework import node_def_pb2 -from tensorflow.python.framework import tensor_util - -# Custom op name for fused depthwise conv2d -FUSED_DEPTHWISE_CONV2D = 'FusedDepthwiseConv2dNative' -# The grappler op name for fused MatMul which starts with '_' -FUSED_MATMUL = '_FusedMatMul' -FUSED_CONV2D = '_FusedConv2D' - -def node_from_map(node_map, name): - """Pulls a node def from a dictionary for a given name. - - Args: - node_map: Dictionary containing an entry indexed by name for every node. - name: Identifies the node we want to find. - - Returns: - NodeDef of the node with the given name. - - Raises: - ValueError: If the node isn't present in the dictionary. - """ - stripped_name = node_name_from_input(name) - if stripped_name not in node_map: - raise ValueError("No node named '%s' found in map." % name) - return node_map[stripped_name] - - -def values_from_const(node_def): - """Extracts the values from a const NodeDef as a numpy ndarray. - - Args: - node_def: Const NodeDef that has the values we want to access. - - Returns: - Numpy ndarray containing the values. - - Raises: - ValueError: If the node isn't a Const. - """ - if node_def.op != "Const": - raise ValueError( - "Node named '%s' should be a Const op for values_from_const." % - node_def.name) - input_tensor = node_def.attr["value"].tensor - tensor_value = tensor_util.MakeNdarray(input_tensor) - return tensor_value - -# Whether to scale by gamma after normalization. -def scale_after_normalization(node): - if node.op == "BatchNormWithGlobalNormalization": - return node.attr["scale_after_normalization"].b - return True - -def node_name_from_input(node_name): - """Strips off ports and other decorations to get the underlying node name.""" - if node_name.startswith("^"): - node_name = node_name[1:] - m = re.search(r"(.*):\d+$", node_name) - if m: - node_name = m.group(1) - return node_name - -def cleanup_graph_def(input_graph_def, nodes_to_skip, inputs_to_remove): - """Clean up the graph def by removing the skipped nodes and clean up the nodes - with inputs that have been removed. - - Args: - input_graph_def: GraphDef object to be cleaned. - node_to_skip: Dict with node names to be skipped. - inputs_to_remove: List of nodes to be removed from inputs of all nodes. - Returns: - GraphDef that has been cleaned. - - """ - result_graph_def = graph_pb2.GraphDef() - for node in input_graph_def.node: - if node.name in nodes_to_skip: - continue - new_node = node_def_pb2.NodeDef() - new_node.CopyFrom(node) - for value in inputs_to_remove: - for i, input_node in enumerate(new_node.input): - if input_node == value.name: - new_node.input[i] = value.input[0] - result_graph_def.node.extend([new_node]) - result_graph_def.library.CopyFrom(input_graph_def.library) - result_graph_def.versions.CopyFrom(input_graph_def.versions) - return result_graph_def - -def rename_constants(node_list, prefix): - """Update all constants name by adding a prefix. - - Args: - node_list: NodeDef list to update. - prefix: string to add to the constant name. - Returns: - NodeDef list that has been updated. - - """ - nodes = [] - constant_names = [node.name for node in node_list if node.op == 'Const'] - for node in node_list: - new_node = node_def_pb2.NodeDef() - new_node.CopyFrom(node) - nodes.append(new_node) - if node.op == 'Const': - new_node.name = prefix + '/' + node.name - else: - for i, input_node in enumerate(new_node.input): - for name in constant_names: - if input_node.startswith(name): - new_node.input[i] = prefix + '/' + input_node - return nodes - -def get_output_node_names(node_map, target): - output_node_names = [] - for name, node in node_map.items(): - for input_name in node.input: - if target == input_name: - output_node_names.append(name) - return output_node_names diff --git a/tfjs-master/tfjs-converter/python/tensorflowjs/converters/jax_conversion.py b/tfjs-master/tfjs-converter/python/tensorflowjs/converters/jax_conversion.py deleted file mode 100644 index ea0c7004d..000000000 --- a/tfjs-master/tfjs-converter/python/tensorflowjs/converters/jax_conversion.py +++ /dev/null @@ -1,151 +0,0 @@ -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================== -"""Converts a JAX function to TensorFlow.js web format.""" -import tempfile -from typing import Any, Callable, Optional, Sequence, Tuple, Union - -from jax.experimental import jax2tf -from jax.experimental.jax2tf import shape_poly -import tensorflow as tf -from tensorflowjs.converters import tf_saved_model_conversion_v2 as saved_model_conversion - - -_TF_SERVING_KEY = tf.saved_model.DEFAULT_SERVING_SIGNATURE_DEF_KEY -Array = Any -DType = Any -PolyShape = shape_poly.PolyShape - - -class _ReusableSavedModelWrapper(tf.train.Checkpoint): - """Wraps a function and its parameters for saving to a SavedModel. - - Implements the interface described at - https://www.tensorflow.org/hub/reusable_saved_models. - """ - - def __init__(self, tf_graph, param_vars): - """Initializes a _ReusableSavedModelWrapper. - - Args: - tf_graph: a tf.function taking one argument (the inputs), which can be - be tuples/lists/dictionaries of np.ndarray or tensors. The function - may have references to the tf.Variables in `param_vars`. - param_vars: the parameters, as tuples/lists/dictionaries of tf.Variable, - to be saved as the variables of the SavedModel. - """ - super().__init__() - self.variables = tf.nest.flatten(param_vars) - self.trainable_variables = [v for v in self.variables if v.trainable] - # If you intend to prescribe regularization terms for users of the model, - # add them as @tf.functions with no inputs to this list. Else drop this. - self.regularization_losses = [] - self.__call__ = tf_graph - - -def convert_jax( - apply_fn: Callable[..., Any], - params: Array, - *, - input_signatures: Sequence[Tuple[Sequence[Union[int, None]], DType]], - model_dir: str, - polymorphic_shapes: Optional[Sequence[Union[str, PolyShape]]] = None, - **tfjs_converter_params): - """Converts a JAX function `jax_apply_fn` and model parameters to a TensorflowJS model. - - Example usage for a Flax Module: - - ``` - import numpy as np - from flax import linen as nn - from jax import random - import jax.numpy as jnp - from tensorflowjs.converters.jax_conversion import convert_jax - - module = nn.Dense(features=4) - inputs = jnp.ones((3, 4)) - params = module.init(random.PRNKey(0), inputs)['params'] - - convert_jax( - apply_fn=module.apply, - params=params, - input_signatures=[((3, 4), np.float32)], - model_dir=tfjs_model_dir) - ``` - - Note that when using dynamic shapes, an additional argument - `polymorphic_shapes` should be provided specifying values for the dynamic - ("polymorphic") dimensions). See here for more details: - https://github.com/google/jax/tree/main/jax/experimental/jax2tf#shape-polymorphic-conversion - - This is an adaption of the original implementation in jax2tf here: - https://github.com/google/jax/blob/main/jax/experimental/jax2tf/examples/saved_model_lib.py - - Arguments: - apply_fn: A JAX function that has one or more arguments, of which the first - argument are the model parameters. This function typically is the forward - pass of the network (e.g., `Module.apply()` in Flax). - params: A Pytree containing the parameters of the module. These will all be - converted to TF.Variables. - input_signatures: the input signatures for the second and remaining - arguments to `apply_fn` (the input). A signature must be a - `tensorflow.TensorSpec` instance, or a (nested) tuple/list/dictionary - thereof with a structure matching the second argument of `apply_fn`. - model_dir: Directory where the TensorflowJS model will be written to. - polymorphic_shapes: If given then it will be used as the - `polymorphic_shapes` argument for the second parameter of `apply_fn`. In - this case, a single `input_signatures` is supported, and should have - `None` in the polymorphic (dynamic) dimensions. - """ - if polymorphic_shapes is not None: - # If polymorphic shapes are provided, add a polymorphic spec for the - # first argument to `apply_fn`, which are the parameters. - polymorphic_shapes = [None, *polymorphic_shapes] - - tf_fn = jax2tf.convert( - apply_fn, - # Gradients must be included as 'PreventGradient' is not supported. - with_gradient=True, - polymorphic_shapes=polymorphic_shapes, - # Do not use TFXLA Ops because these aren't supported by TFjs, but use - # workarounds instead. More information: - # https://github.com/google/jax/tree/main/jax/experimental/jax2tf#tensorflow-xla-ops - enable_xla=False) - - # Create tf.Variables for the parameters. If you want more useful variable - # names, you can use `tree.map_structure_with_path` from the `dm-tree` - # package. - param_vars = tf.nest.map_structure( - lambda param: tf.Variable(param, trainable=True), params) - # Do not use TF's jit compilation on the function. - tf_graph = tf.function( - lambda *xs: tf_fn(param_vars, *xs), autograph=False, jit_compile=False) - - # This signature is needed for TensorFlow Serving use. - signatures = { - _TF_SERVING_KEY: tf_graph.get_concrete_function(*input_signatures) - } - - wrapper = _ReusableSavedModelWrapper(tf_graph, param_vars) - saved_model_options = tf.saved_model.SaveOptions( - experimental_custom_gradients=True) - - with tempfile.TemporaryDirectory() as saved_model_dir: - tf.saved_model.save( - wrapper, - saved_model_dir, - signatures=signatures, - options=saved_model_options) - saved_model_conversion.convert_tf_saved_model(saved_model_dir, model_dir, - **tfjs_converter_params) diff --git a/tfjs-master/tfjs-converter/python/tensorflowjs/converters/jax_conversion_test.py b/tfjs-master/tfjs-converter/python/tensorflowjs/converters/jax_conversion_test.py deleted file mode 100644 index cf7e49a14..000000000 --- a/tfjs-master/tfjs-converter/python/tensorflowjs/converters/jax_conversion_test.py +++ /dev/null @@ -1,168 +0,0 @@ -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================== -"""Unit tests for converting JAX to TensorFlow.js web format.""" -import functools - -from flax import linen as nn -from jax import random -import jax.numpy as jnp -import tensorflow as tf -from tensorflowjs.converters import jax_conversion -import os -import json - -class FlaxModule(nn.Module): - """A simple Flax Module containing a few Dense layers and ReLUs.""" - - @nn.compact - def __call__(self, x): - x = nn.Dense(features=20)(x) - x = nn.relu(x) - for _ in range(5): - x = nn.Dense(features=10)(x) - x = nn.relu(x) - - x = nn.Dense(features=2)(x) - x = nn.sigmoid(x) - return x - - -class FlaxModuleBatchNorm(nn.Module): - """A simple CNN-like Flax model with BatchNorm.""" - - @nn.compact - def __call__(self, x, *, training=True): - x = nn.Conv(features=32, kernel_size=(3, 3))(x) - x = nn.BatchNorm(use_running_average=not training)(x) - x = nn.relu(x) - x = nn.avg_pool(x, window_shape=(2, 2), strides=(2, 2)) - x = nn.Conv(features=64, kernel_size=(3, 3))(x) - x = nn.BatchNorm(use_running_average=not training)(x) - x = nn.relu(x) - x = nn.avg_pool(x, window_shape=(2, 2), strides=(2, 2)) - x = x.reshape((x.shape[0], -1)) # flatten - x = nn.Dense(features=256)(x) - x = nn.relu(x) - x = nn.Dense(features=10)(x) - return x - - -class JaxConversionTest(tf.test.TestCase): - - def test_convert_simple(self): - apply_fn = lambda params, x: jnp.sum(x) * params['w'] - jax_conversion.convert_jax( - apply_fn, - {'w': 0.5}, - input_signatures=[tf.TensorSpec((2, 3), tf.float32)], - model_dir=self.get_temp_dir()) - - def test_convert_quantize(self): - apply_fn = lambda params, x: jnp.sum(x) * params['w'] - model_dir = self.get_temp_dir() - jax_conversion.convert_jax( - apply_fn, - {'w': 0.5}, - input_signatures=[tf.TensorSpec((2, 3), tf.float32)], - model_dir=model_dir, - quantization_dtype_map = {'float16': '*'}) - - with open(os.path.join(model_dir, 'model.json'), 'rt') as model: - model_json = json.load(model) - quantization = model_json['weightsManifest'][0]['weights'][1]['quantization'] - self.assertEqual(quantization['dtype'], 'float16') - - def test_convert_poly(self): - apply_fn = lambda params, x: jnp.sum(x) * params['w'] - jax_conversion.convert_jax( - apply_fn, - {'w': 0.5}, - input_signatures=[tf.TensorSpec((None, 3), tf.float32)], - polymorphic_shapes=['(b, 3)'], - model_dir=self.get_temp_dir(), - strip_debug_ops=True) - - def test_convert_tf_poly_mismatch_raises(self): - apply_fn = lambda params, x: jnp.sum(x) * params['w'] - with self.assertRaisesRegex( - ValueError, 'syntax error in polymorphic shape.* in dimension.* Parsed.*, remaining.*'): - jax_conversion.convert_jax( - apply_fn, - {'w': 0.5}, - input_signatures=[tf.TensorSpec((None, 3), tf.float32)], - polymorphic_shapes=['(b, 4)'], - model_dir=self.get_temp_dir()) - - def test_convert_multiargs(self): - apply_fn = lambda params, x, y: jnp.sum(x) * jnp.sum(y) * params['w'] - jax_conversion.convert_jax( - apply_fn, - {'w': 0.5}, - input_signatures=[tf.TensorSpec((2, 3), tf.float32), - tf.TensorSpec((5, 6), tf.float32)], - model_dir=self.get_temp_dir()) - - def test_convert_multiarg_poly(self): - apply_fn = lambda params, x, y: jnp.sum(x) * jnp.sum(y) * params['w'] - jax_conversion.convert_jax( - apply_fn, - {'w': 0.5}, - input_signatures=[tf.TensorSpec((None, 3), tf.float32), - tf.TensorSpec((None, 6), tf.float32)], - polymorphic_shapes=['(b, 3)', '(b, 6)'], - model_dir=self.get_temp_dir(), - strip_debug_ops=True) - - def test_convert_flax(self): - m, x = FlaxModule(), jnp.zeros((3, 4)) - variables = m.init(random.PRNGKey(0), x) - jax_conversion.convert_jax( - m.apply, - variables, - input_signatures=[tf.TensorSpec((3, 4), tf.float32)], - model_dir=self.get_temp_dir()) - - def test_convert_flax_poly(self): - m, x = FlaxModule(), jnp.zeros((3, 4)) - variables = m.init(random.PRNGKey(0), x) - jax_conversion.convert_jax( - m.apply, - variables, - input_signatures=[tf.TensorSpec((None, 4), tf.float32)], - polymorphic_shapes=['(b, 4)'], - model_dir=self.get_temp_dir(), - strip_debug_ops=True) - - # TODO(marcvanzee): This test currently fails due to - # https://github.com/google/jax/issues/11804. - # This issue is fixed in JAX, but only will be part of jax>0.3.16. Once JAX - # releases a new version we can re-enable this test. If you install JAX from - # Github this will work fine. - # def test_convert_flax_bn(self): - # m, x = FlaxModuleBatchNorm(), jnp.zeros((1, 32, 32, 3)) - # variables = m.init(random.PRNGKey(0), x) - # # Note: if we don't pass training=False here, we will get an error during - # # conversion since `batch_stats` is mutated while it is not passed as a - # # mutable variable collections (we currently do not support this). - # apply_fn = functools.partial(m.apply, training=False) - # jax_conversion.convert_jax( - # apply_fn, - # variables, - # input_signatures=[tf.TensorSpec((1, 32, 32, 3), tf.float32)], - # model_dir=self.get_temp_dir()) - - -if __name__ == '__main__': - tf.test.main() diff --git a/tfjs-master/tfjs-converter/python/tensorflowjs/converters/keras_h5_conversion.py b/tfjs-master/tfjs-converter/python/tensorflowjs/converters/keras_h5_conversion.py deleted file mode 100644 index cb0219b21..000000000 --- a/tfjs-master/tfjs-converter/python/tensorflowjs/converters/keras_h5_conversion.py +++ /dev/null @@ -1,472 +0,0 @@ -# Copyright 2018 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================== -"""Library for converting from hdf5 to json + binary weights. - -Used primarily to convert saved weights, or saved_models from their -hdf5 format to a JSON + binary weights format that the TS codebase can use. -""" - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -import json -import os -import tempfile - -import six -import h5py -import numpy as np - -from tensorflowjs import write_weights # pylint: disable=import-error -from tensorflowjs.converters import common - - -def normalize_weight_name(weight_name): - """Remove suffix ":0" (if present) from weight name.""" - name = as_text(weight_name) - if name.endswith(':0'): - # Python TensorFlow weight names ends with the output slot, which is - # not applicable to TensorFlow.js. - name = name[:-2] - return name - - -def as_text(bytes_or_text, encoding='utf-8'): - if isinstance(bytes_or_text, six.text_type): - return bytes_or_text - elif isinstance(bytes_or_text, bytes): - return bytes_or_text.decode(encoding) - else: - raise TypeError('Expected binary or unicode string, got %r' % - bytes_or_text) - - -def _convert_h5_group(group): - """Construct a weights group entry. - - Args: - group: The HDF5 group data, possibly nested. - - Returns: - An array of weight groups (see `write_weights` in TensorFlow.js). - """ - group_out = [] - if 'weight_names' in group.attrs: - # This is a leaf node in namespace (e.g., 'Dense' in 'foo/bar/Dense'). - names = group.attrs['weight_names'].tolist() - - if not names: - return group_out - - names = [as_text(name) for name in names] - weight_values = [ - np.array(group[weight_name]) for weight_name in names] - group_out += [{ - 'name': normalize_weight_name(weight_name), - 'data': weight_value - } for (weight_name, weight_value) in zip(names, weight_values)] - else: - # This is *not* a leaf level in the namespace (e.g., 'foo' in - # 'foo/bar/Dense'). - for key in group.keys(): - # Call this method recursively. - group_out += _convert_h5_group(group[key]) - - return group_out - -def _convert_v3_group(group, actual_layer_name): - """Construct a weights group entry. - - Args: - group: The HDF5 group data, possibly nested. - - Returns: - An array of weight groups (see `write_weights` in TensorFlow.js). - """ - group_out = [] - list_of_folder = [as_text(name) for name in group] - if 'vars' in list_of_folder: - names = group['vars'] - if not names: - return group_out - name_list = [as_text(name) for name in names] - weight_values = [np.array(names[weight_name]) for weight_name in name_list] - name_list = [os.path.join(actual_layer_name, item) for item in name_list] - group_out += [{ - 'name': normalize_weight_name(weight_name), - 'data': weight_value - } for (weight_name, weight_value) in zip(name_list, weight_values)] - else: - for key in list_of_folder: - group_out += _convert_v3_group(group[key], actual_layer_name) - return group_out - - -def _check_version(h5file): - """Check version compatiility. - - Args: - h5file: An h5file object. - - Raises: - ValueError: if the KerasVersion of the HDF5 file is unsupported. - """ - keras_version = as_text(h5file.attrs['keras_version']) - if keras_version.split('.')[0] != '2': - raise ValueError( - 'Expected Keras version 2; got Keras version %s' % keras_version) - - -def _initialize_output_dictionary(h5file): - """Prepopulate required fields for all data foramts. - - Args: - h5file: Valid h5file object. - - Returns: - A dictionary with common fields sets, shared across formats. - """ - out = dict() - out['keras_version'] = as_text(h5file.attrs['keras_version']) - out['backend'] = as_text(h5file.attrs['backend']) - return out - - -def _ensure_h5file(h5file): - if not isinstance(h5file, h5py.File): - return h5py.File(h5file, "r") - else: - return h5file - - -def _ensure_json_dict(item): - return item if isinstance(item, dict) else json.loads(as_text(item)) - -def _discard_v3_keys(json_dict, keys_to_delete): - if isinstance(json_dict, dict): - keys = list(json_dict.keys()) - for key in keys: - if key in keys_to_delete: - del json_dict[key] - else: - _discard_v3_keys(json_dict[key], keys_to_delete) - elif isinstance(json_dict, list): - for item in json_dict: - _discard_v3_keys(item, keys_to_delete) - - -# https://github.com/tensorflow/tfjs/issues/1255, b/124791387 -# In tensorflow version 1.13 and some alpha and nightly-preview versions, -# the following layers have different class names in their serialization. -# This issue should be fixed in later releases. But we include the logic -# to translate them anyway, for users who use those versions of tensorflow. -_CLASS_NAME_MAP = { - 'BatchNormalizationV1': 'BatchNormalization', - 'UnifiedGRU': 'GRU', - 'UnifiedLSTM': 'LSTM' -} - - -def translate_class_names(input_object): - """Perform class name replacement. - - Beware that this method modifies the input object in-place. - """ - if not isinstance(input_object, dict): - return - for key in input_object: - value = input_object[key] - if key == 'class_name' and value in _CLASS_NAME_MAP: - input_object[key] = _CLASS_NAME_MAP[value] - elif isinstance(value, dict): - translate_class_names(value) - elif isinstance(value, (tuple, list)): - for item in value: - translate_class_names(item) - - -def h5_merged_saved_model_to_tfjs_format(h5file, split_by_layer=False): - """Load topology & weight values from HDF5 file and convert. - - The HDF5 file is one generated by Keras' save_model method or model.save() - - N.B.: - 1) This function works only on HDF5 values from Keras version 2. - 2) This function does not perform conversion for special weights including - ConvLSTM2D and CuDNNLSTM. - - Args: - h5file: An instance of h5py.File, or the path to an h5py file. - split_by_layer: (Optional) whether the weights of different layers are - to be stored in separate weight groups (Default: `False`). - - Returns: - (model_json, groups) - model_json: a JSON dictionary holding topology and system metadata. - group: an array of group_weights as defined in tfjs write_weights. - - Raises: - ValueError: If the Keras version of the HDF5 file is not supported. - """ - h5file = _ensure_h5file(h5file) - try: - _check_version(h5file) - except ValueError: - print("""failed to lookup keras version from the file, - this is likely a weight only file""") - model_json = _initialize_output_dictionary(h5file) - - model_json['model_config'] = _ensure_json_dict( - h5file.attrs['model_config']) - translate_class_names(model_json['model_config']) - if 'training_config' in h5file.attrs: - model_json['training_config'] = _ensure_json_dict( - h5file.attrs['training_config']) - - groups = [] if split_by_layer else [[]] - - model_weights = h5file['model_weights'] - layer_names = [as_text(n) for n in model_weights] - for layer_name in layer_names: - layer = model_weights[layer_name] - group = _convert_h5_group(layer) - if group: - if split_by_layer: - groups.append(group) - else: - groups[0] += group - return model_json, groups - -def h5_v3_merged_saved_model_to_tfjs_format(h5file, meta_file, config_file,split_by_layer=False): - """Load topology & weight values from HDF5 file and convert. - - The HDF5 weights file is one generated by Keras's save_model method or model.save() - - N.B.: - 1) This function works only on HDF5 values from Keras version 3. - 2) This function does not perform conversion for special weights including - ConvLSTM2D and CuDNNLSTM. - - Args: - h5file: An instance of h5py.File, or the path to an h5py file. - split_by_layer: (Optional) whether the weights of different layers are - to be stored in separate weight groups (Default: `False`). - - Returns: - (model_json, groups) - model_json: a JSON dictionary holding topology and system metadata. - group: an array of group_weights as defined in tfjs write_weights. - - Raises: - ValueError: If the Keras version of the HDF5 file is not supported. - """ - h5file = _ensure_h5file(h5file) - model_json = dict() - model_json['keras_version'] = meta_file['keras_version'] - - keys_to_remove = ["module", "registered_name", "date_saved"] - config = _ensure_json_dict(config_file) - _discard_v3_keys(config, keys_to_remove) - model_json['model_config'] = config - translate_class_names(model_json['model_config']) - if 'training_config' in h5file.attrs: - model_json['training_config'] = _ensure_json_dict( - h5file.attrs['training_config']) - - groups = [] if split_by_layer else [[]] - - _convert_v3_group_structure_to_weights(groups=groups, group=h5file, split_by_layer=split_by_layer) - return model_json, groups - -def _convert_v3_group_structure_to_weights(groups, group, split_by_layer, indent=""): - for key in group.keys(): - if isinstance(group[key], h5py.Group): - _convert_v3_group_structure_to_weights(groups, group[key], split_by_layer, indent + key + "/") - elif isinstance(group[key], h5py.Dataset): - group_of_weights = dict() - for key in group.keys(): - group_of_weights[str(indent + key)] = group[key] - group_out = _convert_group(group_of_weights) - if split_by_layer: - groups.append(group_out) - else: - groups[0] += group_out - break - - -def _convert_group(group_dict): - group_out = [] - for key in group_dict.keys(): - name = key - weights_value = np.array(group_dict[key]) - group_out += [{'name': name, 'data' : weights_value}] - - return group_out - - -def h5_weights_to_tfjs_format(h5file, split_by_layer=False): - """Load weight values from a Keras HDF5 file and to a binary format. - - The HDF5 file is one generated by Keras' Model.save_weights() method. - - N.B.: - 1) This function works only on HDF5 values from Keras version 2. - 2) This function does not perform conversion for special weights including - ConvLSTM2D and CuDNNLSTM. - - Args: - h5file: An instance of h5py.File, or the path to an h5py file. - split_by_layer: (Optional) whether the weights of different layers are - to be stored in separate weight groups (Default: `False`). - - Returns: - An array of group_weights as defined in tfjs write_weights. - - Raises: - ValueError: If the Keras version of the HDF5 file is not supported - """ - h5file = _ensure_h5file(h5file) - try: - _check_version(h5file) - except ValueError: - print("""failed to lookup keras version from the file, - this is likely a weight only file""") - - groups = [] if split_by_layer else [[]] - - # pylint: disable=not-an-iterable - layer_names = [as_text(n) for n in h5file.attrs['layer_names']] - # pylint: enable=not-an-iterable - for layer_name in layer_names: - layer = h5file[layer_name] - group = _convert_h5_group(layer) - if group: - if split_by_layer: - groups.append(group) - else: - groups[0] += group - return groups - - -def _get_generated_by(topology): - if topology is None: - return None - elif 'keras_version' in topology: - return 'keras v%s' % topology['keras_version'] - else: - return None - - -def write_artifacts(topology, - weights, - output_dir, - quantization_dtype_map=None, - weight_shard_size_bytes=1024 * 1024 * 4, - metadata=None): - """Writes weights and topology to the output_dir. - - If `topology` is Falsy (e.g., `None`), only emit weights to output_dir. - - Args: - topology: a JSON dictionary, representing the Keras config. - weights: an array of weight groups (as defined in tfjs write_weights). - output_dir: the directory to hold all the contents. - quantization_dtype_map: (Optional) A mapping from dtype - (`uint8`, `uint16`, `float16`) to weights names. The weight mapping - supports wildcard substitution. - weight_shard_size_bytes: Shard size (in bytes) of the weight files. - The size of each weight file will be <= this value. - metadata: User defined metadata map. - """ - # TODO(cais, nielsene): This method should allow optional arguments of - # `write_weights.write_weights` (e.g., shard size) and forward them. - # We write the topology after since write_weights makes no promises about - # preserving directory contents. - if not (isinstance(weight_shard_size_bytes, int) and - weight_shard_size_bytes > 0): - raise ValueError( - 'Expected weight_shard_size_bytes to be a positive integer, ' - 'but got %s' % weight_shard_size_bytes) - - if os.path.isfile(output_dir): - raise ValueError( - 'Path "%d" already exists as a file (not a directory).' % output_dir) - - model_json = { - common.FORMAT_KEY: common.TFJS_LAYERS_MODEL_FORMAT, - common.GENERATED_BY_KEY: _get_generated_by(topology), - common.CONVERTED_BY_KEY: common.get_converted_by() - } - - if metadata: - model_json[common.USER_DEFINED_METADATA_KEY] = metadata - - model_json[common.ARTIFACT_MODEL_TOPOLOGY_KEY] = topology or None - weights_manifest = write_weights.write_weights( - weights, output_dir, write_manifest=False, - quantization_dtype_map=quantization_dtype_map, - shard_size_bytes=weight_shard_size_bytes) - assert isinstance(weights_manifest, list) - model_json[common.ARTIFACT_WEIGHTS_MANIFEST_KEY] = weights_manifest - - model_json_path = os.path.join( - output_dir, common.ARTIFACT_MODEL_JSON_FILE_NAME) - with open(model_json_path, 'wt') as f: - json.dump(model_json, f) - - -def save_keras_model(model, artifacts_dir, quantization_dtype_map=None, - weight_shard_size_bytes=1024 * 1024 * 4, metadata=None): - r"""Save a Keras model and its weights in TensorFlow.js format. - - Args: - model: An instance of `keras.Model`. - artifacts_dir: The directory in which the artifacts will be saved. - The artifacts to be saved include: - - model.json: A JSON representing the model. It has the following - fields: - - 'modelTopology': A JSON object describing the topology of the model, - along with additional information such as training. It is obtained - through calling `model.save()`. - - 'weightsManifest': A TensorFlow.js-format JSON manifest for the - model's weights. - - files containing weight values in groups, with the file name pattern - group(\d+)-shard(\d+)of(\d+). - If the directory does not exist, this function will attempt to create it. - quantization_dtype_map: (Optional) A mapping from dtype - (`uint8`, `uint16`, `float16`) to weights names. The weight mapping - supports wildcard substitution. - weight_shard_size_bytes: Shard size (in bytes) of the weight files. - The size of each weight file will be <= this value. - metadata: User defined metadata map. - - Raises: - ValueError: If `artifacts_dir` already exists as a file (not a directory). - """ - temp_h5_path = tempfile.mktemp() + '.h5' - model.save(temp_h5_path) - topology_json, weight_groups = ( - h5_merged_saved_model_to_tfjs_format(temp_h5_path)) - if os.path.isfile(artifacts_dir): - raise ValueError('Path "%s" already exists as a file.' % artifacts_dir) - if not os.path.isdir(artifacts_dir): - os.makedirs(artifacts_dir) - write_artifacts( - topology_json, weight_groups, artifacts_dir, - quantization_dtype_map=quantization_dtype_map, - weight_shard_size_bytes=weight_shard_size_bytes, - metadata=metadata) - os.remove(temp_h5_path) diff --git a/tfjs-master/tfjs-converter/python/tensorflowjs/converters/keras_h5_conversion_test.py b/tfjs-master/tfjs-converter/python/tensorflowjs/converters/keras_h5_conversion_test.py deleted file mode 100644 index f3c95e3aa..000000000 --- a/tfjs-master/tfjs-converter/python/tensorflowjs/converters/keras_h5_conversion_test.py +++ /dev/null @@ -1,549 +0,0 @@ -# Copyright 2018 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================== -"""Unit tests for artifact conversion to and from Python keras.""" - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -import glob -import json -import os -import shutil -import tempfile -import unittest -import six -import keras - -import h5py -import numpy as np -import tensorflow.compat.v2 as tf - -from tensorflowjs import version -from tensorflowjs.converters import keras_h5_conversion as conversion - - -class ConvertH5WeightsTest(unittest.TestCase): - - def setUp(self): - self._tmp_dir = tempfile.mkdtemp() - super(ConvertH5WeightsTest, self).setUp() - - def tearDown(self): - if os.path.isdir(self._tmp_dir): - shutil.rmtree(self._tmp_dir) - super(ConvertH5WeightsTest, self).tearDown() - - def testConvertWeightsFromSimpleModelNoSplitByLayer(self): - input_tensor = tf.keras.layers.Input((3,)) - dense1 = tf.keras.layers.Dense( - 4, use_bias=True, kernel_initializer='ones', bias_initializer='zeros', - name='MyDense10')(input_tensor) - output = tf.keras.layers.Dense( - 2, use_bias=False, kernel_initializer='ones', name='MyDense20')(dense1) - model = tf.keras.models.Model(inputs=[input_tensor], outputs=[output]) - h5_path = os.path.join(self._tmp_dir, 'MyModel.h5') - model.save_weights(h5_path) - - # Load the saved weights as a JSON string. - groups = conversion.h5_weights_to_tfjs_format(h5py.File(h5_path)) - - # Check the loaded weights. - # Due to the default `split_by_layer=True`, there should be only one weight - # group. - self.assertEqual(1, len(groups)) - self.assertEqual(3, len(groups[0])) - kernel1 = groups[0][0] - self.assertEqual('MyDense10/kernel', kernel1['name']) - self.assertEqual('float32', kernel1['data'].dtype) - self.assertEqual((3, 4), kernel1['data'].shape) - self.assertTrue(np.allclose(np.ones([3, 4]), kernel1['data'])) - bias1 = groups[0][1] - self.assertEqual('MyDense10/bias', bias1['name']) - self.assertEqual('float32', bias1['data'].dtype) - self.assertEqual((4,), bias1['data'].shape) - self.assertTrue(np.allclose(np.zeros([4]), bias1['data'])) - kernel2 = groups[0][2] - self.assertEqual('MyDense20/kernel', kernel2['name']) - self.assertEqual('float32', kernel2['data'].dtype) - self.assertEqual((4, 2), kernel2['data'].shape) - self.assertTrue(np.allclose(np.ones([4, 2]), kernel2['data'])) - - def testConvertWeightsFromSimpleModelSplitByLayer(self): - input_tensor = tf.keras.layers.Input((3,)) - dense1 = tf.keras.layers.Dense( - 4, use_bias=True, kernel_initializer='ones', bias_initializer='zeros', - name='MyDense30')(input_tensor) - output = tf.keras.layers.Dense( - 2, use_bias=False, kernel_initializer='ones', name='MyDense40')(dense1) - model = tf.keras.models.Model(inputs=[input_tensor], outputs=[output]) - h5_path = os.path.join(self._tmp_dir, 'MyModel.h5') - model.save_weights(h5_path) - - # Load the saved weights as a JSON string. - groups = conversion.h5_weights_to_tfjs_format(h5py.File(h5_path), - split_by_layer=True) - - # Check the loaded weights. - # Due to `split_by_layer=True` and the fact that the model has two layers, - # there should be two weight groups. - self.assertEqual(2, len(groups)) - self.assertEqual(2, len(groups[0])) - kernel1 = groups[0][0] - self.assertEqual('MyDense30/kernel', kernel1['name']) - self.assertEqual('float32', kernel1['data'].dtype) - self.assertEqual((3, 4), kernel1['data'].shape) - self.assertTrue(np.allclose(np.ones([3, 4]), kernel1['data'])) - bias1 = groups[0][1] - self.assertEqual('MyDense30/bias', bias1['name']) - self.assertEqual('float32', bias1['data'].dtype) - self.assertEqual((4,), bias1['data'].shape) - self.assertTrue(np.allclose(np.zeros([4]), bias1['data'])) - - self.assertEqual(1, len(groups[1])) - kernel2 = groups[1][0] - self.assertEqual('MyDense40/kernel', kernel2['name']) - self.assertEqual('float32', kernel2['data'].dtype) - self.assertEqual((4, 2), kernel2['data'].shape) - self.assertTrue(np.allclose(np.ones([4, 2]), kernel2['data'])) - - def testConvertModelWithNestedLayerNames(self): - model = tf.keras.Sequential() - - # Add a layer with a nested layer name, i.e., a layer name with slash(es) - # in it. - model.add(tf.keras.layers.Dense(2, input_shape=[12], name='dense')) - model.add(tf.keras.layers.Dense(8, name='foo/dense')) - model.add(tf.keras.layers.Dense(4, name='foo/bar/dense')) - tfjs_path = os.path.join(self._tmp_dir, 'nested_layer_names_model') - conversion.save_keras_model(model, tfjs_path) - - # Check model.json and weights manifest. - with open(os.path.join(tfjs_path, 'model.json'), 'rt') as f: - model_json = json.load(f) - - # Check meta-data in the artifact JSON. - self.assertEqual(model_json['format'], 'layers-model') - self.assertEqual(model_json['generatedBy'], - 'keras v%s' % keras.__version__) - self.assertEqual( - model_json['convertedBy'], - 'TensorFlow.js Converter v%s' % version.version) - - self.assertTrue(model_json['modelTopology']) - weights_manifest = model_json['weightsManifest'] - weight_shapes = dict() - for group in weights_manifest: - for weight in group['weights']: - weight_shapes[weight['name']] = weight['shape'] - self.assertEqual( - sorted(['dense/kernel', 'dense/bias', 'foo/dense/kernel', - 'foo/dense/bias', 'foo/bar/dense/kernel', - 'foo/bar/dense/bias']), - sorted(list(weight_shapes.keys()))) - self.assertEqual([12, 2], weight_shapes['dense/kernel']) - self.assertEqual([2], weight_shapes['dense/bias']) - self.assertEqual([2, 8], weight_shapes['foo/dense/kernel']) - self.assertEqual([8], weight_shapes['foo/dense/bias']) - self.assertEqual([8, 4], weight_shapes['foo/bar/dense/kernel']) - self.assertEqual([4], weight_shapes['foo/bar/dense/bias']) - - def testConvertMergedModelFromSimpleModelNoSplitByLayer(self): - input_tensor = tf.keras.layers.Input((3,)) - dense1 = tf.keras.layers.Dense( - 4, use_bias=True, kernel_initializer='ones', bias_initializer='zeros', - name='MergedDense10')(input_tensor) - output = tf.keras.layers.Dense( - 2, use_bias=False, - kernel_initializer='ones', name='MergedDense20')(dense1) - model = tf.keras.models.Model(inputs=[input_tensor], outputs=[output]) - h5_path = os.path.join(self._tmp_dir, 'MyModelMerged.h5') - model.save(h5_path) - # Ensure matching legacy serialization format - model.use_legacy_config = True - - if six.PY3: - config_json = json.loads(model.to_json()) - else: - config_json = json.loads(model.to_json(), encoding='utf8') - - # Load the saved weights as a JSON string. - out, groups = conversion.h5_merged_saved_model_to_tfjs_format( - h5py.File(h5_path)) - saved_topology = out['model_config'] - - # check the model topology was stored - self.assertEqual(config_json['class_name'], saved_topology['class_name']) - self.assertEqual(config_json['config'], saved_topology['config']) - - # Check the loaded weights. - # By default, all weights of the model ought to be put in the same group. - self.assertEqual(1, len(groups)) - self.assertEqual(keras.__version__, out['keras_version']) - self.assertEqual('tensorflow', out['backend']) - weight_group = groups[0] - self.assertEqual(3, len(weight_group)) - kernel1 = weight_group[0] - self.assertEqual('MergedDense10/kernel', kernel1['name']) - self.assertEqual('float32', kernel1['data'].dtype) - self.assertEqual((3, 4), kernel1['data'].shape) - self.assertTrue(np.allclose(np.ones([3, 4]), kernel1['data'])) - bias1 = weight_group[1] - self.assertEqual('MergedDense10/bias', bias1['name']) - self.assertEqual('float32', bias1['data'].dtype) - self.assertEqual((4,), bias1['data'].shape) - self.assertTrue(np.allclose(np.zeros([4]), bias1['data'])) - kernel2 = weight_group[2] - self.assertEqual('MergedDense20/kernel', kernel2['name']) - self.assertEqual('float32', kernel2['data'].dtype) - self.assertEqual((4, 2), kernel2['data'].shape) - self.assertTrue(np.allclose(np.ones([4, 2]), kernel2['data'])) - - def testConvertMergedModelFromSimpleModelSplitByLayer(self): - input_tensor = tf.keras.layers.Input((3,)) - dense1 = tf.keras.layers.Dense( - 4, use_bias=True, kernel_initializer='ones', bias_initializer='zeros', - name='MergedDense30')(input_tensor) - output = tf.keras.layers.Dense( - 2, use_bias=False, - kernel_initializer='ones', name='MergedDense40')(dense1) - model = tf.keras.models.Model(inputs=[input_tensor], outputs=[output]) - h5_path = os.path.join(self._tmp_dir, 'MyModelMerged.h5') - model.save(h5_path) - # Ensure matching legacy serialization format - model.use_legacy_config = True - - if six.PY3: - config_json = json.loads(model.to_json()) - else: - config_json = json.loads(model.to_json(), encoding='utf8') - - # Load the saved weights as a JSON string. - out, groups = conversion.h5_merged_saved_model_to_tfjs_format( - h5py.File(h5_path), split_by_layer=True) - saved_topology = out['model_config'] - - # check the model topology was stored - self.assertEqual(config_json['class_name'], saved_topology['class_name']) - self.assertEqual(config_json['config'], saved_topology['config']) - - # Check the loaded weights. - # Due to `split_by_layer=True`, there ought to be two weight groups, - # because the model has two layers. - self.assertEqual(2, len(groups)) - self.assertEqual(keras.__version__, out['keras_version']) - self.assertEqual('tensorflow', out['backend']) - self.assertEqual(2, len(groups[0])) - kernel1 = groups[0][0] - self.assertEqual('MergedDense30/kernel', kernel1['name']) - self.assertEqual('float32', kernel1['data'].dtype) - self.assertEqual((3, 4), kernel1['data'].shape) - self.assertTrue(np.allclose(np.ones([3, 4]), kernel1['data'])) - bias1 = groups[0][1] - self.assertEqual('MergedDense30/bias', bias1['name']) - self.assertEqual('float32', bias1['data'].dtype) - self.assertEqual((4,), bias1['data'].shape) - self.assertTrue(np.allclose(np.zeros([4]), bias1['data'])) - self.assertEqual(1, len(groups[1])) - kernel2 = groups[1][0] - self.assertEqual('MergedDense40/kernel', kernel2['name']) - self.assertEqual('float32', kernel2['data'].dtype) - self.assertEqual((4, 2), kernel2['data'].shape) - self.assertTrue(np.allclose(np.ones([4, 2]), kernel2['data'])) - - def testConvertWeightsFromSequentialModelNoSplitByLayer(self): - sequential_model = tf.keras.models.Sequential([ - tf.keras.layers.Dense( - 3, input_shape=(2,), use_bias=True, kernel_initializer='ones', - name='Dense10'), - tf.keras.layers.Dense( - 1, use_bias=False, kernel_initializer='ones', name='Dense20')]) - h5_path = os.path.join(self._tmp_dir, 'SequentialModel.h5') - sequential_model.save_weights(h5_path) - - # Load the saved weights as a JSON string. - groups = conversion.h5_weights_to_tfjs_format(h5py.File(h5_path)) - - # Check the loaded weights. - # Due to the default `split_by_layer=False`, there should be only one weight - # group. - self.assertEqual(1, len(groups)) - self.assertEqual(3, len(groups[0])) - kernel1 = groups[0][0] - self.assertEqual('Dense10/kernel', kernel1['name']) - self.assertEqual('float32', kernel1['data'].dtype) - self.assertEqual((2, 3), kernel1['data'].shape) - self.assertTrue(np.allclose(np.ones([2, 3]).tolist(), kernel1['data'])) - bias1 = groups[0][1] - self.assertEqual('Dense10/bias', bias1['name']) - self.assertEqual('float32', bias1['data'].dtype) - self.assertEqual((3,), bias1['data'].shape) - self.assertTrue(np.allclose(np.zeros([3]).tolist(), bias1['data'])) - kernel2 = groups[0][2] - self.assertEqual('Dense20/kernel', kernel2['name']) - self.assertEqual('float32', kernel2['data'].dtype) - self.assertEqual((3, 1), kernel2['data'].shape) - self.assertTrue(np.allclose(np.ones([3, 1]).tolist(), kernel2['data'])) - - def testConvertWeightsFromSequentialModelSplitByLayer(self): - sequential_model = tf.keras.models.Sequential([ - tf.keras.layers.Dense( - 3, input_shape=(2,), use_bias=True, kernel_initializer='ones', - name='Dense30'), - tf.keras.layers.Dense( - 1, use_bias=False, kernel_initializer='ones', name='Dense40')]) - h5_path = os.path.join(self._tmp_dir, 'SequentialModel.h5') - sequential_model.save_weights(h5_path) - - # Load the saved weights as a JSON string. - groups = conversion.h5_weights_to_tfjs_format(h5py.File(h5_path), - split_by_layer=True) - - # Check the loaded weights. - # Due to the default `split_by_layer=True`, there should be two weight - # gropus, because the model has two layers. - self.assertEqual(2, len(groups)) - self.assertEqual(2, len(groups[0])) - kernel1 = groups[0][0] - self.assertEqual('Dense30/kernel', kernel1['name']) - self.assertEqual('float32', kernel1['data'].dtype) - self.assertEqual((2, 3), kernel1['data'].shape) - self.assertTrue(np.allclose(np.ones([2, 3]).tolist(), kernel1['data'])) - bias1 = groups[0][1] - self.assertEqual('Dense30/bias', bias1['name']) - self.assertEqual('float32', bias1['data'].dtype) - self.assertEqual((3,), bias1['data'].shape) - self.assertTrue(np.allclose(np.zeros([3]).tolist(), bias1['data'])) - - self.assertEqual(1, len(groups[1])) - kernel2 = groups[1][0] - self.assertEqual('Dense40/kernel', kernel2['name']) - self.assertEqual('float32', kernel2['data'].dtype) - self.assertEqual((3, 1), kernel2['data'].shape) - self.assertTrue(np.allclose(np.ones([3, 1]).tolist(), kernel2['data'])) - - def testSaveModelSucceedsForNonSequentialModel(self): - t_input = tf.keras.Input([2]) - dense_layer = tf.keras.layers.Dense(3) - t_output = dense_layer(t_input) - model = tf.keras.Model(t_input, t_output) - conversion.save_keras_model(model, self._tmp_dir) - - # Verify the content of the artifacts output directory. - self.assertTrue( - os.path.isfile(os.path.join(self._tmp_dir, 'group1-shard1of1.bin'))) - model_json = json.load( - open(os.path.join(self._tmp_dir, 'model.json'), 'rt')) - - topology_json = model_json['modelTopology'] - self.assertIn('keras_version', topology_json) - self.assertIn('backend', topology_json) - self.assertIn('model_config', topology_json) - - weights_manifest = model_json['weightsManifest'] - self.assertIsInstance(weights_manifest, list) - self.assertEqual(1, len(weights_manifest)) - self.assertIn('paths', weights_manifest[0]) - - def testSaveModelSucceedsForTfKerasNonSequentialModel(self): - t_input = tf.keras.Input([2]) - dense_layer = tf.keras.layers.Dense(3) - t_output = dense_layer(t_input) - model = tf.keras.Model(t_input, t_output) - - # `tf.keras.Model`s must be compiled before they can be saved. - model.compile(loss='mean_squared_error', optimizer='sgd') - - conversion.save_keras_model(model, self._tmp_dir) - - # Verify the content of the artifacts output directory. - self.assertTrue( - os.path.isfile(os.path.join(self._tmp_dir, 'group1-shard1of1.bin'))) - model_json = json.load( - open(os.path.join(self._tmp_dir, 'model.json'), 'rt')) - - topology_json = model_json['modelTopology'] - self.assertIn('keras_version', topology_json) - self.assertIn('backend', topology_json) - self.assertIn('model_config', topology_json) - - weights_manifest = model_json['weightsManifest'] - self.assertIsInstance(weights_manifest, list) - self.assertEqual(1, len(weights_manifest)) - self.assertIn('paths', weights_manifest[0]) - - def testSaveModelSucceedsForNestedKerasModel(self): - inner_model = tf.keras.Sequential([ - tf.keras.layers.Dense(4, input_shape=[3], activation='relu'), - tf.keras.layers.Dense(3, activation='tanh')]) - outer_model = tf.keras.Sequential() - outer_model.add(inner_model) - outer_model.add(tf.keras.layers.Dense(1, activation='sigmoid')) - - conversion.save_keras_model(outer_model, self._tmp_dir) - - # Verify the content of the artifacts output directory. - self.assertTrue( - os.path.isfile(os.path.join(self._tmp_dir, 'group1-shard1of1.bin'))) - model_json = json.load( - open(os.path.join(self._tmp_dir, 'model.json'), 'rt')) - - topology_json = model_json['modelTopology'] - self.assertIn('keras_version', topology_json) - self.assertIn('backend', topology_json) - self.assertIn('model_config', topology_json) - - # Verify that all the layers' weights are present. - weights_manifest = model_json['weightsManifest'] - self.assertIsInstance(weights_manifest, list) - weight_entries = [] - for group in weights_manifest: - weight_entries.extend(group['weights']) - self.assertEqual(6, len(weight_entries)) - - def testSaveModelSucceedsForTfKerasSequentialModel(self): - model = tf.keras.Sequential([tf.keras.layers.Dense(1, input_shape=[2])]) - - # `tf.keras.Model`s must be compiled before they can be saved. - model.compile(loss='mean_squared_error', optimizer='sgd') - - conversion.save_keras_model(model, self._tmp_dir) - - # Verify the content of the artifacts output directory. - self.assertTrue( - os.path.isfile(os.path.join(self._tmp_dir, 'group1-shard1of1.bin'))) - model_json = json.load( - open(os.path.join(self._tmp_dir, 'model.json'), 'rt')) - - topology_json = model_json['modelTopology'] - self.assertIn('keras_version', topology_json) - self.assertIn('backend', topology_json) - self.assertIn('model_config', topology_json) - - weights_manifest = model_json['weightsManifest'] - self.assertIsInstance(weights_manifest, list) - self.assertEqual(1, len(weights_manifest)) - self.assertIn('paths', weights_manifest[0]) - - def testSavedModelSucceedsForExistingDirAndSequential(self): - artifacts_dir = os.path.join(self._tmp_dir, 'artifacts') - os.makedirs(artifacts_dir) - model = tf.keras.Sequential() - model.add(tf.keras.layers.Dense(3, input_shape=[2])) - conversion.save_keras_model(model, artifacts_dir) - - # Verify the content of the artifacts output directory. - self.assertTrue( - os.path.isfile(os.path.join(artifacts_dir, 'group1-shard1of1.bin'))) - model_json = json.load( - open(os.path.join(artifacts_dir, 'model.json'), 'rt')) - - topology_json = model_json['modelTopology'] - self.assertIn('keras_version', topology_json) - self.assertIn('backend', topology_json) - self.assertIn('model_config', topology_json) - - weights_manifest = model_json['weightsManifest'] - self.assertIsInstance(weights_manifest, list) - self.assertEqual(1, len(weights_manifest)) - self.assertIn('paths', weights_manifest[0]) - - def testSavedModelSucceedsForCustomShardSize(self): - model = tf.keras.Sequential([ - tf.keras.layers.Dense(1, input_shape=[2], activation='relu'), - tf.keras.layers.Dense(3, activation='tanh') - ]) - - weights = model.get_weights() - total_weight_bytes = sum(np.size(w) for w in weights) * 4 - - # Due to the shard size, there ought to be 4 shards after conversion. - weight_shard_size_bytes = int(total_weight_bytes * 0.3) - - # Convert Keras model to tfjs_layers_model format. - conversion.save_keras_model(model, self._tmp_dir, - weight_shard_size_bytes=weight_shard_size_bytes) - - weight_files = sorted(glob.glob(os.path.join(self._tmp_dir, 'group*.bin'))) - self.assertEqual(len(weight_files), 4) - weight_file_sizes = [os.path.getsize(f) for f in weight_files] - self.assertEqual(sum(weight_file_sizes), total_weight_bytes) - self.assertEqual(weight_file_sizes[0], weight_file_sizes[1]) - self.assertEqual(weight_file_sizes[0], weight_file_sizes[2]) - self.assertLess(weight_file_sizes[3], weight_file_sizes[0]) - - def testSavedModelRaisesErrorIfArtifactsDirExistsAsAFile(self): - artifacts_dir = os.path.join(self._tmp_dir, 'artifacts') - with open(artifacts_dir, 'wt') as f: - f.write('foo\n') - t_input = tf.keras.Input([2]) - dense_layer = tf.keras.layers.Dense(3) - t_output = dense_layer(t_input) - model = tf.keras.Model(t_input, t_output) - with self.assertRaisesRegexp( # pylint: disable=deprecated-method - ValueError, r'already exists as a file'): - conversion.save_keras_model(model, artifacts_dir) - - def testTranslateBatchNormalizationV1ClassName(self): - # The config JSON of a model consisting of a "BatchNormalizationV1" layer. - # pylint: disable=line-too-long - json_object = json.loads( - '{"class_name": "Sequential", "keras_version": "2.2.4-tf", "config": {"layers": [{"class_name": "Dense", "config": {"kernel_initializer": {"class_name": "GlorotUniform", "config": {"dtype": "float32", "seed": null}}, "name": "dense", "kernel_constraint": null, "bias_regularizer": null, "bias_constraint": null, "dtype": "float32", "activation": "relu", "trainable": true, "kernel_regularizer": null, "bias_initializer": {"class_name": "Zeros", "config": {"dtype": "float32"}}, "units": 10, "batch_input_shape": [null, 3], "use_bias": true, "activity_regularizer": null}}, {"class_name": "BatchNormalizationV1", "config": {"beta_constraint": null, "gamma_initializer": {"class_name": "Ones", "config": {"dtype": "float32"}}, "moving_mean_initializer": {"class_name": "Zeros", "config": {"dtype": "float32"}}, "name": "batch_normalization_v1", "dtype": "float32", "trainable": true, "moving_variance_initializer": {"class_name": "Ones", "config": {"dtype": "float32"}}, "beta_initializer": {"class_name": "Zeros", "config": {"dtype": "float32"}}, "scale": true, "axis": [1], "epsilon": 0.001, "gamma_constraint": null, "gamma_regularizer": null, "beta_regularizer": null, "momentum": 0.99, "center": true}}, {"class_name": "Dense", "config": {"kernel_initializer": {"class_name": "GlorotUniform", "config": {"dtype": "float32", "seed": null}}, "name": "dense_1", "kernel_constraint": null, "bias_regularizer": null, "bias_constraint": null, "dtype": "float32", "activation": "linear", "trainable": true, "kernel_regularizer": null, "bias_initializer": {"class_name": "Zeros", "config": {"dtype": "float32"}}, "units": 1, "use_bias": true, "activity_regularizer": null}}], "name": "sequential"}, "backend": "tensorflow"}') - # pylint: enable=line-too-long - conversion.translate_class_names(json_object) - # Some class names should not have been changed be translate_class_names(). - self.assertEqual(json_object['class_name'], 'Sequential') - self.assertEqual(json_object['keras_version'], '2.2.4-tf') - self.assertEqual(json_object['config']['layers'][0]['class_name'], 'Dense') - # The translation should have happend: - # BatchNormalizationV1 --> BatchNormalization. - self.assertEqual( - json_object['config']['layers'][1]['class_name'], 'BatchNormalization') - self.assertEqual(json_object['config']['layers'][2]['class_name'], 'Dense') - - # Assert that converted JSON can be reconstituted as a model object. - model = tf.keras.models.model_from_json(json.dumps(json_object)) - self.assertIsInstance(model, tf.keras.Sequential) - self.assertEqual(model.input_shape, (None, 3)) - self.assertEqual(model.output_shape, (None, 1)) - self.assertEqual(model.layers[0].units, 10) - self.assertEqual(model.layers[2].units, 1) - - def testTranslateUnifiedGRUAndLSTMClassName(self): - # The config JSON of a model consisting of a "UnifiedGRU" layer - # and a "UnifiedLSTM" layer. - # pylint: disable=line-too-long - json_object = json.loads( - '{"class_name": "Sequential", "keras_version": "2.2.4-tf", "config": {"layers": [{"class_name": "UnifiedGRU", "config": {"recurrent_activation": "sigmoid", "dtype": "float32", "trainable": true, "recurrent_initializer": {"class_name": "Orthogonal", "config": {"seed": null, "gain": 1.0}}, "use_bias": true, "bias_regularizer": null, "return_state": false, "unroll": false, "activation": "tanh", "bias_initializer": {"class_name": "Zeros", "config": {}}, "units": 10, "batch_input_shape": [null, 4, 3], "activity_regularizer": null, "recurrent_dropout": 0.0, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}}, "kernel_constraint": null, "time_major": false, "dropout": 0.0, "stateful": false, "reset_after": true, "recurrent_regularizer": null, "name": "unified_gru", "bias_constraint": null, "go_backwards": false, "implementation": 1, "kernel_regularizer": null, "return_sequences": true, "recurrent_constraint": null}}, {"class_name": "UnifiedLSTM", "config": {"recurrent_activation": "sigmoid", "dtype": "float32", "trainable": true, "recurrent_initializer": {"class_name": "Orthogonal", "config": {"seed": null, "gain": 1.0}}, "use_bias": true, "bias_regularizer": null, "return_state": false, "unroll": false, "activation": "tanh", "bias_initializer": {"class_name": "Zeros", "config": {}}, "units": 2, "unit_forget_bias": true, "activity_regularizer": null, "recurrent_dropout": 0.0, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}}, "kernel_constraint": null, "time_major": false, "dropout": 0.0, "stateful": false, "recurrent_regularizer": null, "name": "unified_lstm", "bias_constraint": null, "go_backwards": false, "implementation": 1, "kernel_regularizer": null, "return_sequences": false, "recurrent_constraint": null}}], "name": "sequential"}, "backend": "tensorflow"}') - # pylint: enable=line-too-long - conversion.translate_class_names(json_object) - # Some class names should not have been changed be translate_class_names(). - self.assertEqual(json_object['class_name'], 'Sequential') - self.assertEqual(json_object['keras_version'], '2.2.4-tf') - # The translation should have happend: - # UnifiedGRU --> GRU. - # UnifiedLSTM --> LSTM. - self.assertEqual(json_object['config']['layers'][0]['class_name'], 'GRU') - self.assertEqual(json_object['config']['layers'][1]['class_name'], 'LSTM') - - # Assert that converted JSON can be reconstituted as a model object. - model = tf.keras.models.model_from_json(json.dumps(json_object)) - self.assertIsInstance(model, tf.keras.Sequential) - self.assertEqual(model.input_shape, (None, 4, 3)) - self.assertEqual(model.output_shape, (None, 2)) - - -if __name__ == '__main__': - tf.test.main() diff --git a/tfjs-master/tfjs-converter/python/tensorflowjs/converters/keras_tfjs_loader.py b/tfjs-master/tfjs-converter/python/tensorflowjs/converters/keras_tfjs_loader.py deleted file mode 100644 index c6b1a5f6b..000000000 --- a/tfjs-master/tfjs-converter/python/tensorflowjs/converters/keras_tfjs_loader.py +++ /dev/null @@ -1,368 +0,0 @@ -# Copyright 2018 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================== -"""Library for loading a Keras model from TensorFlow.js format.""" - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -import json -import os -import uuid -import zipfile -import datetime -import six -import tensorflow.compat.v2 as tf -from tensorflowjs.converters import tf_module_mapper -from tensorflowjs.converters import keras_h5_conversion -from tensorflowjs.converters.tf_module_mapper import TFCLASS_MODULE_MAP -from tensorflowjs import read_weights - -_CONFIG_FILENAME = "config.json" -_METADATA_FILENAME = "metadata.json" -_VARS_FNAME = "model.weights" - - -def _deserialize_keras_model(model_topology_json, - weight_entries=None, - use_unique_name_scope=False): - """Internal helper method for deserializing a Keras Model. - - Args: - model_topology_json: content of the JSON containing model topology, in - Keras (i.e., tfjs-layers) format. It can be any of the following types: - - A JSON object, i.e., a `dict`. - - A `str` or `buffer`, in which case it will be parsed as a JSON object. - - A `file` object or `file`-like object containing the JSON, in which - case it will be read with the `read()` method and the content parsed - as a JSON object. - weight_entries: Weight entries, in tensorflow.js format, as a `list`. - use_unique_name_scope: Use a unique ID as the name scope for the loaded - model. This may facilitate loading of multiple Keras models in the - same TensorFlow Graph or Session context. Default: `False`. - """ - if isinstance(model_topology_json, (six.string_types, bytes)): - model_topology_json = json.loads(tf.compat.as_text(model_topology_json)) - elif not isinstance(model_topology_json, dict): - model_topology_json = json.load(model_topology_json) - - if 'model_config' in model_topology_json: - model_topology_json = model_topology_json['model_config'] - unique_name_scope = uuid.uuid4().hex if use_unique_name_scope else None - with tf.compat.v1.name_scope(unique_name_scope): - model = tf.keras.models.model_from_json(json.dumps(model_topology_json)) - - if weight_entries: - weights_dict = dict() - for weight_entry in weight_entries: - weights_dict[weight_entry['name']] = weight_entry['data'] - - # Collect weight names from the model, in the same order as the internal - # ordering of model.set_weights() used below. - weight_names = [] - for layer in model.layers: - for w in layer.weights: - weight_names.append( - keras_h5_conversion.normalize_weight_name( - w.name[len(unique_name_scope) + 1:]) - if use_unique_name_scope - else keras_h5_conversion.normalize_weight_name(w.name)) - - # Prepare list of weight values for calling set_weights(). - weights_list = [] - - for name in weight_names: - if name in weights_dict: - weights_list.append(weights_dict[name]) - else: - # TF 2.2.0 added cell name to the weight name in the format of - # layer_name/cell_name/weight_name, we need to remove - # the inner cell name. - tokens = name.split('/') - shorten_name = '/'.join(tokens[0:-2] + [tokens[-1]]) - weights_list.append(weights_dict[shorten_name]) - - model.set_weights(weights_list) - - return model - -def _deserialize_keras_keras_model(model_topology_json, - weight_entries=None, - use_unique_name_scope=False): - """Internal helper method for deserializing a Keras V3 Model. - - Args: - model_topology_json: content of the JSON containing model topology, in - Keras (i.e., tfjs-layers) format. It can be any of the following types: - - A JSON object, i.e., a `dict`. - - A `str` or `buffer`, in which case it will be parsed as a JSON object. - - A `file` object or `file`-like object containing the JSON, in which - case it will be read with the `read()` method and the content parsed - as a JSON object. - weight_entries: Weight entries, in tensorflow.js format, as a `list`. - use_unique_name_scope: Use a unique ID as the name scope for the loaded - model. This may facilitate loading of multiple Keras models in the - same TensorFlow Graph or Session context. Default: `False`. - """ - if isinstance(model_topology_json, (six.string_types, bytes)): - model_topology_json = json.loads(tf.compat.as_text(model_topology_json)) - elif not isinstance(model_topology_json, dict): - model_topology_json = json.load(model_topology_json) - - if 'model_config' in model_topology_json: - # Build the map between class and its corresponding module in TF. - _generate_v3_keys(model_topology_json['model_config']) - model_topology_json = model_topology_json['model_config'] - - model = tf.keras.models.model_from_json(json.dumps(model_topology_json)) - - if weight_entries: - weights_dict = dict() - for weight_entry in weight_entries: - weights_dict[weight_entry['name']] = weight_entry['data'] - - # Collect weight names from the model, in the same order as the internal - # ordering of model.set_weights() used below. - - weight_names = [] - for layer in model.layers: - for index, w in enumerate(layer.weights): - weight_names.append(layer.name + '/' + str(index)) - - - # Prepare list of weight values for calling set_weights(). - weights_list = [] - - for name in weight_names: - if name in weights_dict: - weights_list.append(weights_dict[name]) - else: - raise Exception(f"${name} does not exist in weights entries.") - - model.set_weights(weights_list) - - return model - -def _check_config_json(config_json): - if not isinstance(config_json, dict): - raise TypeError( - 'The JSON content is required to be a `dict`, but found %s.' % - type(config_json)) - if 'modelTopology' not in config_json: - raise KeyError('Field "modelTopology" is missing from the JSON content.') - - -def _get_weights_manifest_from_config_json(config_json): - if 'weightsManifest' not in config_json: - raise KeyError( - 'Field "weightsManifest" is missing from the JSON content.') - return config_json['weightsManifest'] - -def _generate_v3_keys(config): - if isinstance(config, dict): - list_of_keys = list(config.keys()) - for key in list_of_keys: - _generate_v3_keys(config[key]) - if 'class_name' in list_of_keys: - config['module'] = tf_module_mapper.get_module_path(config['class_name']) - # Put registred name as None since we do not support - # custom object saving when we save the model. - config['registered_name'] = None - - elif isinstance(config, list): - for item in config: - _generate_v3_keys(item) - - -def deserialize_keras_model(config_json, - weight_data=None, - use_unique_name_scope=False): - """Deserialize a Keras Model from buffers or file-like objects. - - Args: - config: content of the JSON containing model topology and weights manifest, - in Keras (i.e., tfjs-layers) format. It can be one of the following - types: - - A JSON object, i.e., a `dict`. - - A `str` or `buffer`, in which case it will be parsed as a JSON object. - - A `file` object or `file`-like object containing the JSON, in which - case it will be read with the `read()` method and the content parsed - as a JSON object. - weight_data: a `list` of `buffer`s or a `list` of `file`-like objects - (e.g., `io.BytesIO`) containing the binary weight values. - If `None`, the weights of the model will not be loaded (i.e., only the - topology of the model will be loaded). - use_unique_name_scope: Use a unique ID as the name scope for the loaded - model. This may facilitate loading of multiple Keras models in the - same TensorFlow Graph or Session context. Default: `False`. - """ - if isinstance(config_json, (six.string_types, bytes)): - config_json = json.loads(tf.compat.as_text(config_json)) - elif not isinstance(config_json, dict): - config_json = json.load(config_json) - _check_config_json(config_json) - model_topology_json = config_json['modelTopology'] - - weight_entries = None - if weight_data: - weights_manifest = _get_weights_manifest_from_config_json(config_json) - if not isinstance(weight_data, list): - raise ValueError( - 'weight_data must be a list, but is %s' % type(weight_data)) - if hasattr(weight_data[0], 'read'): - # weight_data is a list of file-like objects. - weight_data = [d.read() for d in weight_data] - weight_entries = read_weights.decode_weights(weights_manifest, - weight_data, - flatten=True) - - return _deserialize_keras_model(model_topology_json, - weight_entries=weight_entries, - use_unique_name_scope=use_unique_name_scope) - - -def load_keras_model(config_json_path, - weights_path_prefix=None, - weights_data_buffers=None, - load_weights=True, - use_unique_name_scope=False): - """Load a Keras Model from TensorFlow.js-format artifacts from file system - - Args: - config_json_path: Path to the TensorFlow.js-format JSON file that includes - the model topology and weights manifest. - weights_path_prefix: Optional path prefix for the weights files. - If not specified (`None`), will assume the prefix is the same directory - as the dirname of `config_json_path`. - weights_data_buffers: A buffer of a `list` of buffers containing the weight - values concatenated and sharded in the order as specified by the - weights manifest at `config_json_path`. This argument is mutually - exclusive with `weights_path_prefix`. - load_weights: Whether the weights are to be loaded according - to the weights manifest at `config_json_path`. Default: `True`. - use_unique_name_scope: Use a unique ID as the name scope for the loaded - model. This may facilitate loading of multiple Keras models in the - same TensorFlow Graph or Session context. Default: `False`. - - Returns: - The loaded instance of `tf.keras.Model`. - - Raises: - TypeError, if the format of the JSON content of `config_json_path` has an - invalid format. - KeyError, if required keys do not exist in the JSON content of - `config_json_path`. - ValueError, if both `weights_data_buffers` and `weights_path_prefix` are - provided. - """ - if weights_data_buffers and weights_path_prefix: - raise ValueError( - 'The arguments weights_data_buffers and weights_path_prefix are ' - 'mutually exclusive and should not be both specified.') - - with open(config_json_path, 'rt') as f: - config_json = json.load(f) - _check_config_json(config_json) - - weight_entries = None - if load_weights: - weights_manifest = _get_weights_manifest_from_config_json(config_json) - - if not weights_data_buffers and not weights_path_prefix: - weights_path_prefix = os.path.dirname( - os.path.realpath(config_json_path)) - if not os.path.isdir(weights_path_prefix): - raise ValueError( - 'Weights path prefix is not an existing directory: %s' % - weights_path_prefix) - if weights_path_prefix: - weight_entries = read_weights.read_weights(weights_manifest, - weights_path_prefix, - flatten=True) - else: - weight_entries = read_weights.decode_weights(weights_manifest, - weights_data_buffers, - flatten=True) - - return _deserialize_keras_model(config_json['modelTopology'], - weight_entries=weight_entries, - use_unique_name_scope=use_unique_name_scope) - -def load_keras_keras_model(config_json_path, - weights_path_prefix=None, - weights_data_buffers=None, - load_weights=True, - use_unique_name_scope=False): - """Load a Keras Model from TensorFlow.js-format artifacts from file system - - Args: - config_json_path: Path to the TensorFlow.js-format JSON file that includes - the model topology and weights manifest. - weights_path_prefix: Optional path prefix for the weights files. - If not specified (`None`), will assume the prefix is the same directory - as the dirname of `config_json_path`. - weights_data_buffers: A buffer of a `list` of buffers containing the weight - values concatenated and sharded in the order as specified by the - weights manifest at `config_json_path`. This argument is mutually - exclusive with `weights_path_prefix`. - load_weights: Whether the weights are to be loaded according - to the weights manifest at `config_json_path`. Default: `True`. - use_unique_name_scope: Use a unique ID as the name scope for the loaded - model. This may facilitate loading of multiple Keras models in the - same TensorFlow Graph or Session context. Default: `False`. - - Returns: - The loaded instance of `tf.keras.Model`. - - Raises: - TypeError, if the format of the JSON content of `config_json_path` has an - invalid format. - KeyError, if required keys do not exist in the JSON content of - `config_json_path`. - ValueError, if both `weights_data_buffers` and `weights_path_prefix` are - provided. - """ - if weights_data_buffers and weights_path_prefix: - raise ValueError( - 'The arguments weights_data_buffers and weights_path_prefix are ' - 'mutually exclusive and should not be both specified.') - - with open(config_json_path, 'rt') as f: - config_json = json.load(f) - _check_config_json(config_json) - - weight_entries = None - if load_weights: - weights_manifest = _get_weights_manifest_from_config_json(config_json) - - if not weights_data_buffers and not weights_path_prefix: - weights_path_prefix = os.path.dirname( - os.path.realpath(config_json_path)) - if not os.path.isdir(weights_path_prefix): - raise ValueError( - 'Weights path prefix is not an existing directory: %s' % - weights_path_prefix) - if weights_path_prefix: - weight_entries = read_weights.read_weights(weights_manifest, - weights_path_prefix, - flatten=True) - else: - weight_entries = read_weights.decode_weights(weights_manifest, - weights_data_buffers, - flatten=True) - - return _deserialize_keras_keras_model(config_json['modelTopology'], - weight_entries=weight_entries, - use_unique_name_scope=use_unique_name_scope) diff --git a/tfjs-master/tfjs-converter/python/tensorflowjs/converters/keras_tfjs_loader_test.py b/tfjs-master/tfjs-converter/python/tensorflowjs/converters/keras_tfjs_loader_test.py deleted file mode 100644 index a9a166d71..000000000 --- a/tfjs-master/tfjs-converter/python/tensorflowjs/converters/keras_tfjs_loader_test.py +++ /dev/null @@ -1,486 +0,0 @@ -# Copyright 2018 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================== -"""Unit tests for keras_tfjs_loader.""" - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -import glob -import io -import json -import os -import shutil -import tempfile - -import numpy as np -import tensorflow.compat.v2 as tf - -from tensorflowjs.converters import keras_h5_conversion -from tensorflowjs.converters import keras_tfjs_loader - - -class LoadKerasModelTest(tf.test.TestCase): - - def setUp(self): - self._tmp_dir = tempfile.mkdtemp() - super(LoadKerasModelTest, self).setUp() - - def tearDown(self): - if os.path.isdir(self._tmp_dir): - shutil.rmtree(self._tmp_dir) - tf.compat.v1.reset_default_graph() - super(LoadKerasModelTest, self).tearDown() - - def _saveKerasModelForTest(self, path): - model = tf.keras.Sequential() - model.use_legacy_config = True - model.add(tf.keras.layers.Dense( - 2, input_shape=[12], bias_initializer='random_normal', name='dense')) - model.add(tf.keras.layers.Dense( - 8, bias_initializer='random_normal', name='foo/dense')) - model.add(tf.keras.layers.Dense( - 4, bias_initializer='random_normal', name='foo/bar/dense')) - keras_h5_conversion.save_keras_model(model, path) - return model - - - def _saveRNNKerasModelForTest(self, path): - model = tf.keras.Sequential() - model.use_legacy_config = True - model.add(tf.keras.layers.Embedding(100, 20, input_shape=[10])) - model.add(tf.keras.layers.SimpleRNN(4)) - keras_h5_conversion.save_keras_model(model, path) - return model - - def testLoadKerasModelAndWeights(self): - """Test loading of model and its weights.""" - # Use separate tf.Graph and tf.compat.v1.Session contexts to - # prevent name collision. - with tf.Graph().as_default(), tf.compat.v1.Session(): - tfjs_path = os.path.join(self._tmp_dir, 'model_for_test') - model1 = self._saveKerasModelForTest(tfjs_path) - model1_weight_values = model1.get_weights() - - with tf.Graph().as_default(), tf.compat.v1.Session(): - model2 = keras_tfjs_loader.load_keras_model( - os.path.join(tfjs_path, 'model.json')) - model2.use_legacy_config = True - # Verify the equality of all the weight values. - model2_weight_values = model2.get_weights() - self.assertEqual(len(model1_weight_values), len(model2_weight_values)) - for model1_weight_value, model2_weight_value in zip( - model1_weight_values, model2_weight_values): - self.assertAllClose(model1_weight_value, model2_weight_value) - - # The two model JSONs should match exactly. - self.assertEqual(model1.to_json(), model2.to_json()) - - def testLoadKerasRNNModelAndWeights(self): - """Test loading of model and its weights.""" - # Use separate tf.Graph and tf.compat.v1.Session contexts to - # prevent name collision. - with tf.Graph().as_default(), tf.compat.v1.Session(): - tfjs_path = os.path.join(self._tmp_dir, 'model_for_test') - model1 = self._saveRNNKerasModelForTest(tfjs_path) - model1_weight_values = model1.get_weights() - - with tf.Graph().as_default(), tf.compat.v1.Session(): - model2 = keras_tfjs_loader.load_keras_model( - os.path.join(tfjs_path, 'model.json')) - model2.use_legacy_config = True - # Verify the equality of all the weight values. - model2_weight_values = model2.get_weights() - self.assertEqual(len(model1_weight_values), len(model2_weight_values)) - for model1_weight_value, model2_weight_value in zip( - model1_weight_values, model2_weight_values): - self.assertAllClose(model1_weight_value, model2_weight_value) - - # The two model JSONs should match exactly. - self.assertEqual(model1.to_json(), model2.to_json()) - - def testDeserializeKerasModelTopologyOnlyFromBytesIO(self): - """Test loading of model (only topology) from a BytesIO object.""" - # Use separate tf.Graph and tf.compat.v1.Session contexts to prevent - # name collision. - with tf.Graph().as_default(), tf.compat.v1.Session(): - tfjs_path = os.path.join(self._tmp_dir, 'model_for_test') - model1 = self._saveKerasModelForTest(tfjs_path) - - # Read the content of model.json into a BytesIO - buff = io.BytesIO() - buff_writer = io.BufferedWriter(buff) - with open(os.path.join(tfjs_path, 'model.json'), 'rb') as f: - buff_writer.write(f.read()) - buff_writer.flush() - buff_writer.seek(0) - - with tf.Graph().as_default(), tf.compat.v1.Session(): - model2 = keras_tfjs_loader.deserialize_keras_model(buff.read()) - model2.use_legacy_config = True - - # The two model JSONs should match exactly. - self.assertEqual(model1.to_json(), model2.to_json()) - - def testDeserializeKerasModelTopologyOnlyFromJSONDict(self): - """Test loading of model (only topology) from a JSON Dict.""" - # Use separate tf.Graph and tf.compat.v1.Session contexts to prevent - # name collision. - with tf.Graph().as_default(), tf.compat.v1.Session(): - tfjs_path = os.path.join(self._tmp_dir, 'model_for_test') - model1 = self._saveKerasModelForTest(tfjs_path) - - # Read the content of model.json into a BytesIO - with open(os.path.join(tfjs_path, 'model.json'), 'rt') as f: - config_json = json.load(f) - - with tf.Graph().as_default(), tf.compat.v1.Session(): - model2 = keras_tfjs_loader.deserialize_keras_model(config_json) - model2.use_legacy_config = True - # The two model JSONs should match exactly. - self.assertEqual(model1.to_json(), model2.to_json()) - - def testDeserializeKerasModelTopologyAndWeightsFromBuffers(self): - """Test loading of model and its weights from buffers.""" - # Use separate tf.Graph and tf.compat.v1.Session contexts to prevent - # name collision. - with tf.Graph().as_default(), tf.compat.v1.Session(): - tfjs_path = os.path.join(self._tmp_dir, 'model_for_test') - model1 = self._saveKerasModelForTest(tfjs_path) - model1_weight_values = model1.get_weights() - - # Read the content of model.json into a BytesIO object. - with open(os.path.join(tfjs_path, 'model.json'), 'rb') as f: - json_buff = f.read() - - weight_paths = sorted(glob.glob(os.path.join(tfjs_path, 'group*'))) - weight_buffers = [] - for path in weight_paths: - with open(path, 'rb') as f: - weight_buffers.append(f.read()) - - with tf.Graph().as_default(), tf.compat.v1.Session(): - model2 = keras_tfjs_loader.deserialize_keras_model( - json_buff, weight_data=weight_buffers) - model2.use_legacy_config = True - - # Verify the equality of all the weight values. - model2_weight_values = model2.get_weights() - self.assertEqual(len(model1_weight_values), len(model2_weight_values)) - for model1_weight_value, model2_weight_value in zip( - model1_weight_values, model2_weight_values): - self.assertAllClose(model1_weight_value, model2_weight_value) - - # The two model JSONs should match exactly. - self.assertEqual(model1.to_json(), model2.to_json()) - - def testDeserializeKerasModelTopologyAndWeightsFromFileObjects(self): - """Test loading of model and its weights using file objects.""" - # Use separate tf.Graph and tf.compat.v1.Session contexts to prevent - # name collision. - with tf.Graph().as_default(), tf.compat.v1.Session(): - tfjs_path = os.path.join(self._tmp_dir, 'model_for_test') - model1 = self._saveKerasModelForTest(tfjs_path) - model1_weight_values = model1.get_weights() - - # Read the content of model.json into a file object. - json_file = open(os.path.join(tfjs_path, 'model.json'), 'rt') - - weight_paths = sorted(glob.glob(os.path.join(tfjs_path, 'group*'))) - weight_files = [open(path, 'rb') for path in weight_paths] - - with tf.Graph().as_default(), tf.compat.v1.Session(): - model2 = keras_tfjs_loader.deserialize_keras_model( - json_file, weight_files) - model2.use_legacy_config = True - - # Verify the equality of all the weight values. - model2_weight_values = model2.get_weights() - self.assertEqual(len(model1_weight_values), len(model2_weight_values)) - for model1_weight_value, model2_weight_value in zip( - model1_weight_values, model2_weight_values): - self.assertAllClose(model1_weight_value, model2_weight_value) - - # The two model JSONs should match exactly. - self.assertEqual(model1.to_json(), model2.to_json()) - - json_file.close() - for f in weight_files: - f.close() - - def testLoadKerasModelWithCurrentWorkingDirectoryRelativePath(self): - with tf.Graph().as_default(), tf.compat.v1.Session(): - tfjs_path = os.path.join(self._tmp_dir, 'model_for_test') - model1 = self._saveKerasModelForTest(tfjs_path) - model1_weight_values = model1.get_weights() - - os.chdir(tfjs_path) - with tf.Graph().as_default(), tf.compat.v1.Session(): - # Use a relative path under the current working directory. - model2 = keras_tfjs_loader.load_keras_model('model.json') - model2.use_legacy_config = True - # Verify the equality of all the weight values. - model2_weight_values = model2.get_weights() - self.assertEqual(len(model1_weight_values), len(model2_weight_values)) - for model1_weight_value, model2_weight_value in zip( - model1_weight_values, model2_weight_values): - self.assertAllClose(model1_weight_value, model2_weight_value) - - # The two model JSONs should match exactly. - self.assertEqual(model1.to_json(), model2.to_json()) - os.chdir("/") - - def testLoadKerasModelWithoutWeights(self): - """Test loading of model topology only, without loading weight values.""" - with tf.Graph().as_default(), tf.compat.v1.Session(): - tfjs_path = os.path.join(self._tmp_dir, 'model_for_test') - model1 = self._saveKerasModelForTest(tfjs_path) - model1_weight_values = model1.get_weights() - - with tf.Graph().as_default(), tf.compat.v1.Session(): - model2 = keras_tfjs_loader.load_keras_model( - os.path.join(tfjs_path, 'model.json'), load_weights=False) - model2.use_legacy_config = True - model2_weight_values = model2.get_weights() - self.assertEqual(len(model1_weight_values), len(model2_weight_values)) - for model1_weight_value, model2_weight_value in zip( - model1_weight_values, model2_weight_values): - self.assertEqual(model1_weight_value.dtype, - model2_weight_value.dtype) - self.assertEqual(model1_weight_value.shape, - model2_weight_value.shape) - # The weights should be unequal, because `load_weights=False`. - self.assertNotEqual(model1_weight_value.tobytes(), - model2_weight_value.tobytes()) - - self.assertEqual(model1.to_json(), model2.to_json()) - - def testLoadKerasModelFromNonDefaultWeightsPathWorks(self): - with tf.Graph().as_default(), tf.compat.v1.Session(): - tfjs_path = os.path.join(self._tmp_dir, 'model_for_test') - model1 = self._saveKerasModelForTest(tfjs_path) - model1_weight_values = model1.get_weights() - - # Move the model.json file to a different folder. - model_json_dir = os.path.join(tfjs_path, 'model_json_dir') - os.makedirs(model_json_dir) - new_model_json_path = os.path.join(model_json_dir, 'model.json') - shutil.move(os.path.join(tfjs_path, 'model.json'), new_model_json_path) - - with tf.Graph().as_default(), tf.compat.v1.Session(): - model2 = keras_tfjs_loader.load_keras_model( - new_model_json_path, weights_path_prefix=tfjs_path) - model2.use_legacy_config = True - # Verify the equality of all the weight values. - model2_weight_values = model2.get_weights() - self.assertEqual(len(model1_weight_values), len(model2_weight_values)) - for model1_weight_value, model2_weight_value in zip( - model1_weight_values, model2_weight_values): - self.assertAllClose(model1_weight_value, model2_weight_value) - - self.assertEqual(model1.to_json(), model2.to_json()) - - def testLoadKerasModelWithUniqueNameScopeInTheSameGraphContext(self): - """Test enabling unique name scope during model loading.""" - with tf.Graph().as_default(), tf.compat.v1.Session(): - tfjs_path = os.path.join(self._tmp_dir, 'model_for_test') - model1 = self._saveKerasModelForTest(tfjs_path) - model1_weight_values = model1.get_weights() - - model2 = keras_tfjs_loader.load_keras_model( - os.path.join(tfjs_path, 'model.json'), use_unique_name_scope=True) - - model2_weight_values = model2.get_weights() - self.assertEqual(len(model1_weight_values), len(model2_weight_values)) - for model1_weight_value, model2_weight_value in zip( - model1_weight_values, model2_weight_values): - self.assertAllClose(model1_weight_value, model2_weight_value) - - # Verify that model1's weight names are suffixes of model2's weight names. - model1_weight_names = [w.name for w in model1.weights] - model2_weight_names = [w.name for w in model2.weights] - self.assertEqual(len(model1_weight_names), len(model2_weight_names)) - for name1, name2 in zip(model1_weight_names, model2_weight_names): - self.assertTrue(name2.endswith(name1)) - - def testLoadKerasModelFromDataBuffers(self): - with tf.Graph().as_default(), tf.compat.v1.Session(): - tfjs_path = os.path.join(self._tmp_dir, 'model_for_test') - model1 = self._saveKerasModelForTest(tfjs_path) - model1_weight_values = model1.get_weights() - - with open(os.path.join(tfjs_path, 'model.json'), 'rt') as f: - weights_manifest = json.load(f)['weightsManifest'] - - data_buffers = [] - for group in weights_manifest: - data_buffer = b'' - for path in group['paths']: - with open(os.path.join(tfjs_path, path), 'rb') as f: - data_buffer += f.read() - - with tf.Graph().as_default(), tf.compat.v1.Session(): - model2 = keras_tfjs_loader.load_keras_model( - os.path.join(tfjs_path, 'model.json'), - weights_data_buffers=data_buffers) - model2.use_legacy_config = True - # Verify the equality of all the weight values. - model2_weight_values = model2.get_weights() - self.assertEqual(len(model1_weight_values), len(model2_weight_values)) - for model1_weight_value, model2_weight_value in zip( - model1_weight_values, model2_weight_values): - self.assertAllClose(model1_weight_value, model2_weight_value) - - self.assertEqual(model1.to_json(), model2.to_json()) - - def testLoadNestedKerasModel(self): - with tf.Graph().as_default(), tf.compat.v1.Session(): - inner_model = tf.keras.Sequential([ - tf.keras.layers.Dense(4, input_shape=[3], activation='relu'), - tf.keras.layers.Dense(3, activation='tanh')]) - outer_model = tf.keras.Sequential() - outer_model.add(inner_model) - outer_model.add(tf.keras.layers.Dense(1, activation='sigmoid')) - - x = np.ones([1, 3], dtype=np.float32) - predict_out = outer_model.predict(x) - - save_dir = os.path.join(self._tmp_dir, 'nested_model') - keras_h5_conversion.save_keras_model(outer_model, save_dir) - - with tf.Graph().as_default(), tf.compat.v1.Session(): - model2 = keras_tfjs_loader.load_keras_model( - os.path.join(save_dir, 'model.json'), use_unique_name_scope=True) - self.assertAllClose(predict_out, model2.predict(x)) - - def testLoadNestedTfKerasModel(self): - with tf.Graph().as_default(), tf.compat.v1.Session(): - inner_model = tf.keras.Sequential([ - tf.keras.layers.Dense(4, input_shape=[3], activation='relu'), - tf.keras.layers.Dense(3, activation='tanh')]) - outer_model = tf.keras.Sequential() - outer_model.add(inner_model) - outer_model.add(tf.keras.layers.Dense(1, activation='sigmoid')) - outer_model.compile(loss='binary_crossentropy', optimizer='sgd') - - x = np.ones([1, 3], dtype=np.float32) - predict_out = outer_model.predict(x) - - save_dir = os.path.join(self._tmp_dir, 'nested_model') - keras_h5_conversion.save_keras_model(outer_model, save_dir) - - with tf.Graph().as_default(), tf.compat.v1.Session(): - model2 = keras_tfjs_loader.load_keras_model( - os.path.join(save_dir, 'model.json'), use_unique_name_scope=True) - self.assertAllClose(predict_out, model2.predict(x)) - - def testLoadKerasModeFromNonexistentWeightsPathRaisesError(self): - with tf.Graph().as_default(), tf.compat.v1.Session(): - tfjs_path = os.path.join(self._tmp_dir, 'model_for_test') - self._saveKerasModelForTest(tfjs_path) - with self.assertRaises(ValueError): - keras_tfjs_loader.load_keras_model( - os.path.join(tfjs_path, 'model.json'), - weights_path_prefix=os.path.join(self._tmp_dir, 'nonexistent')) - - def testUsingBothWeightsDataBuffersAndWeightsPathPrefixRaisesError(self): - with tf.Graph().as_default(), tf.compat.v1.Session(): - tfjs_path = os.path.join(self._tmp_dir, 'model_for_test') - self._saveKerasModelForTest(tfjs_path) - - with self.assertRaises(ValueError): - keras_tfjs_loader.load_keras_model( - os.path.join(tfjs_path, 'model.json'), - weights_data_buffers=[b'foo'], weights_path_prefix='bar') - - def testInvalidJSONRaisesError(self): - with tf.Graph().as_default(), tf.compat.v1.Session(): - tfjs_path = os.path.join(self._tmp_dir, 'model_for_test') - self._saveKerasModelForTest(tfjs_path) - - # Make some changes to the model.json file content to create an invalid - # file content. - model_json_path = os.path.join(tfjs_path, 'model.json') - with open(model_json_path, 'rt') as f: - model_json_content = f.read() - with open(model_json_path, 'wt') as f: - f.write('[' + model_json_content + ']') - - with self.assertRaises(ValueError): - keras_tfjs_loader.load_keras_model( - model_json_path, - weights_data_buffers=[b'foo'], weights_path_prefix='bar') - - def testLoadFunctionalKerasModel(self): - with tf.Graph().as_default(), tf.compat.v1.Session(): - input1 = tf.keras.Input([4]) - x1 = tf.keras.layers.Dense(2, activation='relu')(input1) - x1 = tf.keras.layers.BatchNormalization()(x1) - - input2 = tf.keras.Input([10]) - x2 = tf.keras.layers.Dense(5, activation='relu')(input2) - x2 = tf.keras.layers.BatchNormalization()(x2) - - y = tf.keras.layers.Concatenate()([x1, x2]) - y = tf.keras.layers.Dense(1, activation='sigmoid')(y) - - model = tf.keras.Model([input1, input2], y) - model.compile(loss='binary_crossentropy', optimizer='sgd') - - input1_val = np.ones([1, 4]) - input2_val = np.ones([1, 10]) - predict_out = model.predict([input1_val, input2_val]) - - save_dir = os.path.join(self._tmp_dir, 'functional_model') - keras_h5_conversion.save_keras_model(model, save_dir) - - with tf.Graph().as_default(), tf.compat.v1.Session(): - model2 = keras_tfjs_loader.load_keras_model( - os.path.join(save_dir, 'model.json')) - self.assertAllClose( - predict_out, model2.predict([input1_val, input2_val])) - - def testLoadFunctionalTfKerasModel(self): - with tf.Graph().as_default(), tf.compat.v1.Session(): - input1 = tf.keras.Input([4]) - x1 = tf.keras.layers.Dense(2, activation='relu')(input1) - x1 = tf.keras.layers.BatchNormalization()(x1) - - input2 = tf.keras.Input([10]) - x2 = tf.keras.layers.Dense(5, activation='relu')(input2) - x2 = tf.keras.layers.BatchNormalization()(x2) - - y = tf.keras.layers.Concatenate()([x1, x2]) - y = tf.keras.layers.Dense(1, activation='sigmoid')(y) - - model = tf.keras.Model([input1, input2], y) - model.compile(loss='binary_crossentropy', optimizer='sgd') - - input1_val = np.ones([1, 4]) - input2_val = np.ones([1, 10]) - predict_out = model.predict([input1_val, input2_val]) - - save_dir = os.path.join(self._tmp_dir, 'functional_model') - keras_h5_conversion.save_keras_model(model, save_dir) - - with tf.Graph().as_default(), tf.compat.v1.Session(): - model2 = keras_tfjs_loader.load_keras_model( - os.path.join(save_dir, 'model.json')) - self.assertAllClose( - predict_out, model2.predict([input1_val, input2_val])) - - -if __name__ == '__main__': - tf.test.main() diff --git a/tfjs-master/tfjs-converter/python/tensorflowjs/converters/normalize_bias_add.py b/tfjs-master/tfjs-converter/python/tensorflowjs/converters/normalize_bias_add.py deleted file mode 100644 index 328ed564c..000000000 --- a/tfjs-master/tfjs-converter/python/tensorflowjs/converters/normalize_bias_add.py +++ /dev/null @@ -1,64 +0,0 @@ -# Copyright 2023 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================== -"""Normalize BiasAdd op to be fused.""" - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -from tensorflowjs.converters import graph_rewrite_util - -def normalize_bias_add_op(input_graph_def): - """Convert AddV2 ops and Add ops to BiasAdd if they could be fused with the - ancestor node. - - Grappler and the TFJS's fusing pass for DepthwiseConv2D can only fuse the - BiasAdd op, but some AddV2 ops in the graph have the same functionality and - can be fused with MatMul, Conv2D and DepthwiseConv2D ops. This function - finds which AddV2 and Add ops in the graph can be fused and converts them - to BiasAdd, which will be fused in the following passes. The AddV2 and Add ops - must satisfy the following conditions to be fused: - * The parent node has to be MatMul, Conv2D or DepthwiseConv. - * The current node is the only child of the parent node (MatMul, Conv2D or - DepthwiseConv). - - Args: - input_graph_def: A GraphDef containing a model. - - Returns: - Modified graph with fusable AddV2 and Add converted to BiasAdd. - - Raises: - ValueError: If the graph is badly formed with duplicate node names. - """ - input_node_map = {} - for node in input_graph_def.node: - if node.name not in input_node_map: - input_node_map[node.name] = node - else: - raise ValueError('Duplicate node names detected for ', node.name) - - for node in input_graph_def.node: - if node.op == 'AddV2' or node.op == 'Add': - ancestor_node_name = node.input[0] - ancestor_node = graph_rewrite_util.node_from_map(input_node_map, - ancestor_node_name) - if (ancestor_node.op == 'Conv2D' \ - or ancestor_node.op == 'DepthwiseConv2dNative' - or ancestor_node.op == 'MatMul') \ - and len(graph_rewrite_util.get_output_node_names(input_node_map, ancestor_node_name)) == 1: - node.op = 'BiasAdd' - node.attr['data_format'].s = bytes('NHWC', 'utf-8') - return input_graph_def diff --git a/tfjs-master/tfjs-converter/python/tensorflowjs/converters/normalize_bias_add_test.py b/tfjs-master/tfjs-converter/python/tensorflowjs/converters/normalize_bias_add_test.py deleted file mode 100644 index 6ef32902c..000000000 --- a/tfjs-master/tfjs-converter/python/tensorflowjs/converters/normalize_bias_add_test.py +++ /dev/null @@ -1,119 +0,0 @@ -# Copyright 2023 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================== -"""Unit tests for depthwise conv2d op fusing.""" - -import os -import shutil -import tempfile - -import tensorflow.compat.v2 as tf -from tensorflow.python.framework import dtypes - -from tensorflowjs.converters import normalize_bias_add -from tensorflowjs.converters import graph_rewrite_util -from tensorflowjs.converters import tf_saved_model_conversion_v2 - - -class NormalizeBiasAddTest(tf.test.TestCase): - def setUp(self): - super(NormalizeBiasAddTest, self).setUp() - self._tmp_dir = tempfile.mkdtemp() - - def tearDown(self): - if os.path.isdir(self._tmp_dir): - shutil.rmtree(self._tmp_dir) - super(NormalizeBiasAddTest, self).tearDown() - - def testFuseConv2DWithAddV2(self): - @tf.function - def conv2d_addV2(x): - filter = tf.ones([1, 1, 1, 1]) - bias = tf.constant([100], dtype=dtypes.float32) - res = tf.raw_ops.Conv2D( - input=x, filter=filter, strides=[1, 1, 1, 1], padding="VALID") - res = tf.raw_ops.AddV2(x=res, y=bias) - return res - - input_tensor = tf.constant([1.0], shape=[1, 1, 1, 1]) - graph = tf_saved_model_conversion_v2._freeze_saved_model_v2( - conv2d_addV2.get_concrete_function(input_tensor)) - graph_def = graph.as_graph_def() - - optimized_graph_def = normalize_bias_add.normalize_bias_add_op(graph_def) - - bias_add_count = 0 - bias_add = None - for node in optimized_graph_def.node: - self.assertNotEqual("AddV2", node.op) - if node.op == "BiasAdd": - bias_add_count += 1 - bias_add = node - self.assertEqual(bias_add_count, 1) - self.assertEqual(bias_add.attr['data_format'].s, b'NHWC') - - def testFuseDepthwiseConv2dNativeWithAddV2(self): - @tf.function - def depthwise_addV2(x): - filter = tf.ones([1, 1, 1, 1]) - bias = tf.constant([100], dtype=dtypes.float32) - res = tf.raw_ops.DepthwiseConv2dNative( - input=x, filter=filter, strides=[1, 1, 1, 1], padding="VALID") - res = tf.raw_ops.AddV2(x=res, y=bias) - return res - - input_tensor = tf.constant([1.0], shape=[1, 1, 1, 1]) - graph = tf_saved_model_conversion_v2._freeze_saved_model_v2( - depthwise_addV2.get_concrete_function(input_tensor)) - graph_def = graph.as_graph_def() - - optimized_graph_def = normalize_bias_add.normalize_bias_add_op(graph_def) - - bias_add_count = 0 - bias_add = None - for node in optimized_graph_def.node: - self.assertNotEqual("AddV2", node.op) - if node.op == "BiasAdd": - bias_add_count += 1 - bias_add = node - self.assertEqual(bias_add_count, 1) - self.assertEqual(bias_add.attr['data_format'].s, b'NHWC') - - def testMatmulWithAddV2(self): - @tf.function - def matmul_addV2(x): - y = tf.ones([1, 1]) - bias = tf.constant([100], dtype=dtypes.float32) - res = tf.raw_ops.MatMul(a=x, b=y) - res = tf.raw_ops.AddV2(x=res, y=bias) - return res - - input_tensor = tf.constant([1.0], shape=[1, 1]) - graph = tf_saved_model_conversion_v2._freeze_saved_model_v2( - matmul_addV2.get_concrete_function(input_tensor)) - graph_def = graph.as_graph_def() - - optimized_graph_def = normalize_bias_add.normalize_bias_add_op(graph_def) - - bias_add_count = 0 - bias_add = None - for node in optimized_graph_def.node: - self.assertNotEqual("AddV2", node.op) - if node.op == "BiasAdd": - bias_add_count += 1 - bias_add = node - self.assertEqual(bias_add_count, 1) - self.assertEqual(bias_add.attr['data_format'].s, b'NHWC') -if __name__ == '__main__': - tf.test.main() diff --git a/tfjs-master/tfjs-converter/python/tensorflowjs/converters/tf_module_mapper.py b/tfjs-master/tfjs-converter/python/tensorflowjs/converters/tf_module_mapper.py deleted file mode 100644 index 9f7c79bb8..000000000 --- a/tfjs-master/tfjs-converter/python/tensorflowjs/converters/tf_module_mapper.py +++ /dev/null @@ -1,52 +0,0 @@ -# Copyright 2023 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================== -import tensorflow.keras as keras -import inspect - -from tensorflow.python.util import tf_export - - -TFCLASS_MODULE_MAP = {} -MODULE = keras - -def _build_class_module_map(keras_module): - """Build the map between TFJS classes and corresponding module path in TF. - - Args: - keras_module: keras module used to go through all the classes - """ - for name, obj in inspect.getmembers(keras_module): - if inspect.isclass(obj): - # Retrive the module path from tensorflow. - parts = str(tf_export.get_canonical_name_for_symbol(obj, api_name='keras')).split(".") - # Map the class name with module path exclude the class name. - TFCLASS_MODULE_MAP[name] = ".".join(parts[:-1]) - - elif inspect.ismodule(obj): - _build_class_module_map(obj) - -def get_module_path(key): - """Get the module path base on input key - - Args: - key: The name of the class we want to get module path. - Return: - RESULT_MAP[key]: the corresponding module path in TF. - """ - if not TFCLASS_MODULE_MAP: - _build_class_module_map(MODULE) - if key not in TFCLASS_MODULE_MAP: - raise KeyError(f"Cannot find the module path for {key} class.") - return TFCLASS_MODULE_MAP[key] diff --git a/tfjs-master/tfjs-converter/python/tensorflowjs/converters/tf_module_mapper_test.py b/tfjs-master/tfjs-converter/python/tensorflowjs/converters/tf_module_mapper_test.py deleted file mode 100644 index c62bc779c..000000000 --- a/tfjs-master/tfjs-converter/python/tensorflowjs/converters/tf_module_mapper_test.py +++ /dev/null @@ -1,43 +0,0 @@ -# Copyright 2018 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================== -"""Unit tests for build_module_map.""" -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -import tensorflowjs.converters.tf_module_mapper as bm -import tensorflow.compat.v2 as tf - -class TfModuleMapperTest(tf.test.TestCase): - def setUp(self): - bm.build_map() - super(TfModuleMapperTest, self).setUp() - - def tearDown(self): - super(TfModuleMapperTest, self).tearDown() - - def testUnsupportClassInMap(self): - non_exist_class_name = 'FakeClass' - - with self.assertRaises(KeyError): - bm.get_module_path(non_exist_class_name) - - def testDenseClassInMap(self): - class_name = 'Dense' - - self.assertEqual('keras.layers', bm.get_module_path(class_name)) - -if __name__ == '__main__': - tf.test.main() diff --git a/tfjs-master/tfjs-converter/python/tensorflowjs/converters/tf_saved_model_conversion_v2.py b/tfjs-master/tfjs-converter/python/tensorflowjs/converters/tf_saved_model_conversion_v2.py deleted file mode 100644 index 014abe2b7..000000000 --- a/tfjs-master/tfjs-converter/python/tensorflowjs/converters/tf_saved_model_conversion_v2.py +++ /dev/null @@ -1,1229 +0,0 @@ -# Copyright 2018 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================== -"""Convert Tensorflow SavedModel to TensorFlow.js web format.""" - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -import json -import os -import shutil -import tempfile -from zipfile import ZipFile - -# Required to load saved models that use TFDF. -import tensorflow_decision_forests -import tensorflow as tf -from tensorflow.core.framework import function_pb2 -from tensorflow.core.framework import graph_pb2 -from tensorflow.core.framework import node_def_pb2 -from tensorflow.core.protobuf import config_pb2 -from tensorflow.core.protobuf import device_properties_pb2 -from tensorflow.core.protobuf import meta_graph_pb2 -from tensorflow.io import gfile -from tensorflow.python.checkpoint.trackable_view import TrackableView -from tensorflow.python.eager import context -from tensorflow.python.framework import convert_to_constants -from tensorflow.python.grappler import cluster as gcluster -from tensorflow.python.grappler import tf_optimizer -from tensorflow.python.keras.saving.saving_utils import trace_model_call -from tensorflow.python.keras.saving.saving_utils import def_function -from tensorflow.python.keras.saving.saving_utils import model_input_signature -from tensorflow.python.saved_model.load import load -from tensorflow.python.saved_model import loader -from tensorflow.python.tools.saved_model_utils import get_meta_graph_def -from tensorflow.python.training.saver import export_meta_graph -from tensorflow.saved_model.experimental import TrackableResource -from google.protobuf.json_format import MessageToDict -import tensorflow_hub as hub -from packaging import version - -from tensorflowjs import write_weights -from tensorflowjs.converters import common -from tensorflowjs.converters import normalize_bias_add -from tensorflowjs.converters import fold_batch_norms -from tensorflowjs.converters import fuse_prelu -from tensorflowjs.converters import fuse_depthwise_conv2d -from tensorflowjs.converters import graph_rewrite_util -from tensorflowjs import resource_loader - -CLEARED_TENSOR_FIELDS = ( - 'tensor_content', 'half_val', 'float_val', 'double_val', 'int_val', - 'string_val', 'scomplex_val', 'int64_val', 'bool_val', - 'resource_handle_val', 'variant_val', 'uint32_val', 'uint64_val') - -_HUB_V1_MODULE_PB = "tfhub_module.pb" - -def load_graph(graph_filename): - """Loads GraphDef. Returns Python Graph object. - - Args: - graph_filename: string File name for the frozen graph. - """ - with tf.compat.v1.gfile.Open(graph_filename, 'rb') as f: - graph_def = tf.compat.v1.GraphDef() - graph_def.ParseFromString(f.read()) - - with tf.Graph().as_default() as graph: - # Set name to empty to avoid using the default name 'import'. - tf.import_graph_def(graph_def, name='') - - return graph - -def get_cluster(): - """Grappler optimization configuration for GPU.""" - named_device = device_properties_pb2.NamedDevice() - named_device.name = '/GPU:0' - named_device.properties.type = 'GPU' - named_device.properties.environment['architecture'] = '4' - cluster = gcluster.Cluster(devices=[named_device]) - return cluster - -def validate(graph_def, skip_op_check, strip_debug_ops): - """Validate if the node's op is compatible with TensorFlow.js. - - Args: - graph_def: tf.GraphDef TensorFlow GraphDef proto object, which represents - the model topology. - skip_op_check: Bool whether to skip the op check. - strip_debug_ops: Bool whether to allow unsupported debug ops. - """ - nodes = [] + list(graph_def.node) - for func in graph_def.library.function: - nodes.extend(list(func.node_def)) - - if skip_op_check: - return set() - ops = [] - for filename in resource_loader.list_dir('op_list'): - if os.path.splitext(filename)[1] == '.json': - with resource_loader.open_file(os.path.join('op_list', - filename)) as json_data: - ops += json.load(json_data) - - names = {x['tfOpName'] for x in ops} - if strip_debug_ops: - names = names.union({'Assert', 'CheckNumerics', 'Print'}) - not_supported = {x.op for x in [x for x in nodes if x.op not in names]} - return not_supported - -def _run_grappler(config, graph_def, graph, signature_def): - meta_graph = export_meta_graph( - graph_def=graph_def, graph=graph) - - meta_graph.signature_def["not_used_key"].CopyFrom(signature_def) - - return tf_optimizer.OptimizeGraph( - config, meta_graph, cluster=get_cluster()) - -def optimize_graph(graph, signature_def, - skip_op_check=False, strip_debug_ops=False, - experiments=False): - """Takes a Python Graph object and optimizes the graph. - - Args: - graph: The frozen graph to optimize. - skip_op_check: Bool whether to skip the op check. - strip_debug_ops: Bool whether to strip debug ops. - """ - - # Add a collection 'train_op' so that Grappler knows the outputs. - for _, output in signature_def.outputs.items(): - name = output.name.split(':')[0] - graph.add_to_collection('train_op', graph.get_operation_by_name(name)) - - graph_def = graph.as_graph_def() - - unsupported = validate(graph_def, skip_op_check, - strip_debug_ops) - if unsupported: - raise ValueError('Unsupported Ops in the model before optimization\n' + - ', '.join(unsupported)) - - # first pass of grappler optimization, this is needed for batch norm folding. - config = config_pb2.ConfigProto() - rewriter_config = config.graph_options.rewrite_options - rewriter_config.optimizers[:] = [ - 'pruning', 'constfold', 'arithmetic', 'dependency', 'pruning', - 'constfold', 'arithmetic', 'dependency' - ] - if experiments: - rewriter_config.experimental_disable_compressed_tensor_optimization = True - - if strip_debug_ops: - rewriter_config.optimizers.insert(0, 'debug_stripper') - - optimized_graph = _run_grappler(config, graph_def, graph, signature_def) - - # batch norm folding - optimized_graph = fold_batch_norms.fold_batch_norms(optimized_graph) - - optimized_graph = normalize_bias_add.normalize_bias_add_op(optimized_graph) - - # set the device to CPU for all Conv2d and MatMul nodes, since grappler - # remap optimizer only support FusedConv2D and FusedMatMul for CPU. - for node in optimized_graph.node: - if node.op == 'Conv2D' or node.op == 'MatMul': - node.device = '/device:CPU:0' - - # rerun grappler to fuse conv2d/matmul - config.graph_options.rewrite_options.optimizers[:] = [ - 'remap', - 'constfold', 'arithmetic', 'dependency' - ] - - optimized_graph = _run_grappler(config, optimized_graph, graph, signature_def) - - optimized_graph = _remove_unused_control_flow_inputs(optimized_graph) - - # Because TF break the Prelu op into 6 ops, for performance we are - # fusing those ops into a single prelu - optimized_graph = fuse_prelu.fuse_ops_for_prelu(optimized_graph) - - # Because grappler does not support DepthwiseConv2d fusing, we have - # implemented it here. - optimized_graph = fuse_depthwise_conv2d.fuse_depthwise_conv2d(optimized_graph) - - # Since the grappler remap optimizer doe snot support prelu as the activation - # function for _FusedConv2D op, we are doing it manually here. - optimized_graph = fuse_prelu.fuse_prelu_with_fused_conv2d_or_matmul( - optimized_graph) - - unsupported = validate(optimized_graph, skip_op_check, - strip_debug_ops) - if unsupported: - raise ValueError('Unsupported Ops in the model after optimization\n' + - ', '.join(unsupported)) - - return optimized_graph - -def extract_const_nodes(nodes): - """Takes a list of nodes and extract the weights. Return weight manifest - object. - - Args: - nodes: list of tf.NodeDef TensorFlow NodeDef proto object. - """ - constants = [node for node in nodes if node.op == 'Const'] - const_inputs = {} - # removed the conditional inputs for constants - for const in constants: - const_inputs[const.name] = const.input[:] - del const.input[:] - - const_manifest = [] - - for const in constants: - const_manifest.append({ - 'name': const.name, - 'data': graph_rewrite_util.values_from_const(const) - }) - # Restore the conditional inputs - const.input[:] = const_inputs[const.name] - - # Remove the binary array from tensor and save it to the external file. - for field_name in CLEARED_TENSOR_FIELDS: - const.attr["value"].tensor.ClearField(field_name) - - return const_manifest - -def extract_weights(graph_def, initializer_graph_def=None): - """Takes a Python GraphDef object and extract the weights. - - Args: - graph_def: tf.GraphDef TensorFlow GraphDef proto object, which represents - the model topology. - initializer_graph_def: tf.GraphDef proto object for initializer graph. - """ - global_manifest = extract_const_nodes(graph_def.node) - - function_manifests = [] - for func in graph_def.library.function: - nodes = graph_rewrite_util.rename_constants( - func.node_def, func.signature.name) - del func.node_def[:] - func.node_def.extend(nodes) - function_manifests += extract_const_nodes(func.node_def) - - initializer_manifests = [] - if initializer_graph_def: - initializer_manifests = extract_const_nodes(initializer_graph_def.node) - - return [global_manifest + function_manifests + initializer_manifests] - -def write_artifacts(topology, - weights, - output_graph, - tf_version, - signature_def, - quantization_dtype_map=None, - weight_shard_size_bytes=1024 * 1024 * 4, - initializer_graph_def=None, - initializer_signature_def=None, - resource_ids_maps=None, - metadata=None): - """Writes weights and topology to the output_dir. - - If `topology` is Falsy (e.g., `None`), only emit weights to output_dir. - - Args: - topology: tf.GraphDef TensorFlow GraphDef proto object, which represents - the model topology. - weights: an array of weight groups (as defined in tfjs write_weights). - output_graph: the output file name to hold all the contents. - tf_version: Tensorflow version of the input graph. - signature_def: the SignatureDef of the inference graph. - quantization_dtype_map: A mapping from dtype - (`uint8`, `uint16`, `float16`) to weights names. The weight mapping - supports wildcard substitution. - weight_shard_size_bytes: Shard size (in bytes) of the weight files. - The size of each weight file will be <= this value. - initializer_graph_def: tf.GraphDef proto object for initializer graph. - initializer_signature_def: the SignatureDef of the initializer graph. - resource_ids_maps: Tuple of two dictionaries, one - mapping inference input names to resource id, and the other - mapping initializer output names to resource id. - metadata: User defined metadata map. - """ - model_json = { - common.FORMAT_KEY: common.TFJS_GRAPH_MODEL_FORMAT, - # TODO(piyu): Add tensorflow version below by using `meta_info_def`. - common.GENERATED_BY_KEY: tf_version, - common.CONVERTED_BY_KEY: common.get_converted_by(), - common.SIGNATURE_KEY: MessageToDict(signature_def), - } - model_json[common.ARTIFACT_MODEL_TOPOLOGY_KEY] = topology or None - - if metadata: - model_json[common.USER_DEFINED_METADATA_KEY] = metadata - - if initializer_graph_def and initializer_graph_def.node: - model_json[common.ARTIFACT_MODEL_INITIALIZER] = MessageToDict( - initializer_graph_def) - if initializer_signature_def: - model_json[common.INITIALIZER_SIGNATURE_KEY] = MessageToDict( - initializer_signature_def) - - # Assign resource ids to inference inputs and initializer outputs. In - # TensorFlow, both inference and initializer graphs have a reference - # to the common resource (so initializer runs on reference, and then inference - # graph uses it). We are doing something similar but instead of assigning - # a reference to the resource in the serialized graph, we assign the id - # of the resource, and then we can recreate the common reference in javascript - # by matching resource ids. - if resource_ids_maps is not None: - model_input_to_resource_id, init_output_to_resource_id = resource_ids_maps - signature_inputs = model_json[common.SIGNATURE_KEY]['inputs'] - initializer_signature_outputs = model_json[common.INITIALIZER_SIGNATURE_KEY]['outputs'] - - for (input, resource_id) in model_input_to_resource_id.items(): - if input in signature_inputs: - signature_inputs[input][common.RESOURCE_ID_KEY] = resource_id - - for (output, resource_id) in init_output_to_resource_id.items(): - if output in initializer_signature_outputs: - initializer_signature_outputs[output][common.RESOURCE_ID_KEY] = resource_id - - - weights_manifest = write_weights.write_weights( - weights, os.path.dirname(output_graph), write_manifest=False, - quantization_dtype_map=quantization_dtype_map, - shard_size_bytes=weight_shard_size_bytes) - assert isinstance(weights_manifest, list) - model_json[common.ARTIFACT_WEIGHTS_MANIFEST_KEY] = weights_manifest - - with gfile.GFile(output_graph, 'w') as f: - json.dump(model_json, f) - -def _remove_unused_control_flow_inputs(input_graph_def): - result_graph_def = graph_pb2.GraphDef() - for node in input_graph_def.node: - if (node.op == 'Placeholder' and - node.name.startswith('unused_control_flow_input')): - continue - new_node = node_def_pb2.NodeDef() - new_node.CopyFrom(node) - result_graph_def.node.extend([new_node]) - result_graph_def.library.CopyFrom(input_graph_def.library) - result_graph_def.versions.CopyFrom(input_graph_def.versions) - return result_graph_def - -def _check_signature_in_model(saved_model, signature_name): - if signature_name not in saved_model.signatures: - raise ValueError("Signature '%s' does not exist. The following signatures " - "are available: %s" % (signature_name, - saved_model.signatures.keys())) - -def _copy_assets(saved_model_dir, output_dir): - input_assets_path = os.path.join(saved_model_dir, common.ASSETS_DIRECTORY_NAME) - - if gfile.exists(input_assets_path) and gfile.isdir(input_assets_path): - - tmp_dir = tempfile.mkdtemp() - zip_path = gfile.join(tmp_dir, common.ASSETS_DIRECTORY_NAME + '.zip') - - with ZipFile(zip_path, 'w') as archive: - for (input_dir_path, _, file_names) in gfile.walk(input_assets_path): - - relative_dir_path = os.path.relpath(input_dir_path, input_assets_path) - - for file_name in file_names: - - input_file_path = gfile.join(input_dir_path, file_name) - relative_file_path = gfile.join(relative_dir_path, file_name) - - with gfile.GFile(input_file_path, 'rb') as input_file: - with archive.open(relative_file_path, 'w') as relative_file: - shutil.copyfileobj(input_file, relative_file) - - output_assets_path = gfile.join(output_dir, common.ASSETS_DIRECTORY_NAME + '.zip') - gfile.copy(zip_path, output_assets_path, overwrite=True) - - if gfile.isdir(tmp_dir): - gfile.rmtree(tmp_dir) - -def _is_assets_required(model_ops): - # TFDF stores the necessary files for its binary in the assets folder. - # Check if any TFDF ops are used in the model. - with resource_loader.open_file('op_list/tfdf.json') as tfdf_json: - ops = json.load(tfdf_json) - opNames = frozenset([x['tfOpName'] for x in ops]) - return not opNames.isdisjoint(model_ops) - -def _get_frozen_graph_ops(frozen_graph): - if frozen_graph is None: - return [] - return [node.op for node in frozen_graph.as_graph_def().node] - - -def _freeze_saved_model_v1(saved_model_dir, saved_model_tags, - output_node_names): - """Freeze the graph by converting variables to constants for 1.x saved model. - - Args: - saved_model_dir: dir where saved model files are stored. - saved_model_tags: inference graph tag. - output_node_names: List of name strings for the result nodes of the graph. - - Returns: - A freezed and optimized graph. - Nullable. A freezed and optimized initializer graph. - Nullable. A list of output node names of initializer. - """ - # v1 loader need empty list if there are no saved_model tags. - if not saved_model_tags: - saved_model_tags = [] - - g = tf.Graph() - with g.as_default(): - with tf.compat.v1.Session() as sess: - meta_graph = loader.load(sess, saved_model_tags, saved_model_dir) - - meta_graph_def = g.as_graph_def() - if not meta_graph_def.HasField('library'): - meta_graph_def.library.CopyFrom(function_pb2.FunctionDefLibrary()) - - frozen_graph_def = tf.compat.v1.graph_util.convert_variables_to_constants( - sess, meta_graph_def, output_node_names) - - frozen_graph = tf.Graph() - with frozen_graph.as_default(): - tf.import_graph_def(frozen_graph_def, name='') - - frozen_initializer_graph = None - initializer_output_names = None - # Only support table initializers for now. - if meta_graph.collection_def and meta_graph.collection_def[ - 'table_initializer']: - initializer_output_names = meta_graph.collection_def[ - 'table_initializer'].node_list.value - # This will use grappler to extract a subgraph with the - # table initializer ops as the outputs. - frozen_initializer_graph_def = (tf.compat.v1.graph_util - .convert_variables_to_constants( - sess, meta_graph_def, - initializer_output_names)) - frozen_initializer_graph = tf.Graph() - with frozen_initializer_graph.as_default(): - tf.import_graph_def(frozen_initializer_graph_def, name='') - - return frozen_graph, frozen_initializer_graph - -def _freeze_saved_model_v2(concrete_func, control_flow_v2=False): - if version.parse(tf.__version__) < version.parse('2.2.0'): - return convert_to_constants.convert_variables_to_constants_v2( - concrete_func, lower_control_flow=not control_flow_v2).graph - - return convert_to_constants.convert_variables_to_constants_v2( - concrete_func, lower_control_flow=not control_flow_v2, - aggressive_inlining=True).graph - -def _find_signature_def_name(tensor, signature_map): - if not signature_map: - return tensor.name - - tensor_shape_str = tensor.shape.as_proto().SerializeToString() - names = [] - for key in signature_map: - tensor_info = signature_map[key] - signature_shape_str = tensor_info.tensor_shape.SerializeToString() - if (tensor_info.dtype == tensor.dtype and - tensor_shape_str == signature_shape_str): - names.append(key) - - if not names or len(names) > 1: - return tensor.name - else: - return names[0] - -def _build_signature_def(frozen_graph, input_nodes, output_nodes, - signature_def=None): - signature = meta_graph_pb2.SignatureDef() - for input_tensor in input_nodes: - op_name = input_tensor.name.split(':')[0] - # The graph freezing may turn the original inputs into constants, or remove - # them from the graph, so we need to ignore those. - try: - op = frozen_graph.get_operation_by_name(op_name) - if op.type != 'Const': - name = input_tensor.name - if hasattr(signature_def, 'inputs'): - name = _find_signature_def_name(input_tensor, signature_def.inputs) - signature.inputs[name].name = input_tensor.name - signature.inputs[name].dtype = input_tensor.dtype.as_datatype_enum - signature.inputs[name].tensor_shape.CopyFrom( - input_tensor.shape.as_proto()) - except KeyError: - # The original input was removed when the graph was frozen. - continue - for output_tensor in output_nodes: - if hasattr(output_tensor, 'name'): - name = output_tensor.name - if hasattr(signature_def, 'inputs'): - name = _find_signature_def_name(output_tensor, signature_def.outputs) - signature.outputs[name].name = output_tensor.name - signature.outputs[name].dtype = output_tensor.dtype.as_datatype_enum - signature.outputs[name].tensor_shape.CopyFrom( - output_tensor.shape.as_proto()) - else: #just the tensor name string array - signature.outputs[output_tensor].name = output_tensor - return signature - -def convert_tf_frozen_model(frozen_model_path, - output_node_names, - output_dir, - quantization_dtype_map=None, - skip_op_check=False, - strip_debug_ops=False, - weight_shard_size_bytes=1024 * 1024 * 4, - experiments=False, - metadata=None): - """Convert frozen model and check the model compatibility with Tensorflow.js. - Optimize and convert the model to Tensorflow.js format, when the model passes - the compatiblity check. - Args: - frozen_model_path: string The path to frozen model. - output_node_names: string The names of the output nodes, comma separated. - output_dir: string The name of the output directory. The directory - will consist of - - a file named 'model.json' - - possibly sharded binary weight files. - quantization_dtype_map: A mapping from dtype - (`uint8`, `uint16`, `float16`) to weights names. The weight mapping - supports wildcard substitution. - skip_op_check: Bool whether to skip the op check. - strip_debug_ops: Bool whether to strip debug ops. - weight_shard_size_bytes: Shard size (in bytes) of the weight files. - The size of each weight file will be <= this value. - experiments: Bool enable experimental features. - metadata: User defined metadata map. - """ - - if not os.path.exists(output_dir): - os.makedirs(output_dir) - output_graph = os.path.join(output_dir, common.ARTIFACT_MODEL_JSON_FILE_NAME) - - graph = load_graph(frozen_model_path) - signature = _build_signature_def( - graph, [], output_node_names.split(',')) - - optimized_graph = optimize_graph(graph, signature, - skip_op_check=skip_op_check, - strip_debug_ops=strip_debug_ops, - experiments=experiments) - - weights = extract_weights(optimized_graph) - - write_artifacts(MessageToDict(optimized_graph), - weights, - output_graph, tf.__version__, - signature, - quantization_dtype_map=quantization_dtype_map, - weight_shard_size_bytes=weight_shard_size_bytes, - metadata=metadata) - -def _load_model(saved_model_dir, saved_model_tags): - model = None - # Ensure any graphs created in eager mode are able to run. - with context.eager_mode(): - if saved_model_tags: - model = load(saved_model_dir, saved_model_tags) - else: - model = load(saved_model_dir) - return model - -def _find_signature(saved_model_dir, saved_model_tags, signature_def): - meta_graph = get_meta_graph_def(saved_model_dir, saved_model_tags) - signature_def_map = meta_graph.signature_def - if signature_def not in signature_def_map.keys(): - raise ValueError('Signature "%s" does not exist in the saved model' - % (signature_def)) - - return signature_def_map[signature_def] - -def _get_resource_initializer_concrete_function(model): - """Create a tf.function that creates and initializes all the resources used by the model. - For more information on resources, please see the TensorFlow code: - https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/trackable/resource.py#L232 - Args: - model: Loaded saved model. - - Returns: - Nullable. A concrete function. - """ - trackable_view = TrackableView(model) - model_resources = [obj for obj in trackable_view.descendants() if isinstance(obj, TrackableResource)] - - if not model_resources: - return None - - # A list holding tuples of (TrackableResource, captured_input_index) where - # TrackableResource represents one resource in the model - # (a hash table for example), and captured_input_index is the resource - # initialization function's captured input index corresponding - # to the TrackableResource. Captured inputs are simply inputs not provided - # directly be user, but by the model. - model_resources_with_captured_input_index = [] - for model_resource in model_resources: - # A runtime id that is unique across different resources, and constant - # across graphs. - resource_handle_id = model_resource.resource_handle._id - # the _initialize function initializes the resource, so one of its captured - # inputs must be the resource, so search for that input. - captured_inputs = model_resource._initialize.get_concrete_function()._captured_inputs - for captured_input_index in range(len(captured_inputs)): - if captured_inputs[captured_input_index]._id == resource_handle_id: - model_resources_with_captured_input_index.append((model_resource, captured_input_index)) - - @tf.function() - def resource_initializer(): - # Recreate resources to capture them in this tf.function. - new_resources = [] - for (model_resource, captured_input_index) in model_resources_with_captured_input_index: - # Make a new resource (that is identical to the old, but captured in - # this functon only). - new_resource = model_resource._create_resource() - new_resources.append(new_resource) - - # Since we precomputed the captured input corresponding to this resource, - # we can directly replace it with the copy new_resource. If we don't do - # this, then _initialize will not get capture in this graph since the - # old resource was already initialized in TF model load. - model_resource._initialize.get_concrete_function()._captured_inputs[captured_input_index] = new_resource - model_resource._initialize() - - return new_resources - - # Add resource_initializer to the output graph. - return resource_initializer.get_concrete_function() - -def _get_resource_ids_maps(model, concrete_func, resource_init_concrete_func): - """Generates dictionaries that map tensor names to the loaded saved model resource id, - allowing for matching of initializer outputs to inference inputs. - - Args: - model: Loaded saved model. - concrete_func: Concrete function of the inference graph. - resource_init_concrete_func: Concrete function of the initializer graph. - - Returns: - A dictionary mapping inference input names to resource id. - A dictionary mapping initializer output names to resource id. - """ - trackable_view = TrackableView(model) - model_resources = [obj for obj in trackable_view.descendants() if isinstance(obj, TrackableResource)] - - - # Each resource has a unique runtime resource id associated with it which - # can be used across graphs, so we extract it here from inference - # graph for use later. - resource_id_to_captured_input_index = { - captured_input._id : captured_input_index for \ - captured_input_index, captured_input in \ - enumerate(concrete_func._captured_inputs) - } - # Captured inputs always come after user provided inputs. - captured_input_index_offset = len(concrete_func.inputs) - len(concrete_func._captured_inputs) - - model_input_to_resource_id = {} - init_output_to_resource_id = {} - for i, resource in enumerate(model_resources): - _id = resource.resource_handle._id - # Get input from inference graph corresponding to this resource. - captured_input_index = resource_id_to_captured_input_index[_id] - model_input = concrete_func.inputs[captured_input_index + captured_input_index_offset] - - # Get output from initializer graph corresponding to this resource. - init_output = resource_init_concrete_func.outputs[i] - - # Match both with the same id (initializer output will be passed in to - # corresponding input in inference input). - model_input_to_resource_id[model_input.name] = _id - init_output_to_resource_id[init_output.name] = _id - - return (model_input_to_resource_id, init_output_to_resource_id) - -def _convert_tf_saved_model(output_dir, - saved_model_dir=None, - keras_model=None, - signature_def='serving_default', - saved_model_tags='serve', - quantization_dtype_map=None, - skip_op_check=False, - strip_debug_ops=False, - use_structured_outputs_names=False, - weight_shard_size_bytes=1024 * 1024 * 4, - control_flow_v2=False, - experiments=False, - metadata=None, - frozen_graph_dir=None): - """Take a SavedModel or KerasModel and convert to Tensorflow.js graph model. - - Args: - output_dir: string The name of the output directory. The directory - will consist of - - a file named 'model.json' - - possibly sharded binary weight files. - saved_model_dir: string The saved model directory. - : string The names of the output nodes, comma separated. - keras_model: An in-memory Keras model object. - signature_def: string Tagset of the SignatureDef to load. Defaults to - 'serving_default'. - saved_model_tags: tags of the GraphDef to load. Defaults to 'serve'. - quantization_dtype_map: A mapping from dtype - (`uint8`, `uint16`, `float16`) to weights names. The weight mapping - supports wildcard substitution. - skip_op_check: Bool whether to skip the op check. - strip_debug_ops: Bool whether to strip debug ops. - use_structured_outputs_names: Bool whether output of graph model will follow - the structured_outputs format. - weight_shard_size_bytes: Shard size (in bytes) of the weight files. - The size of each weight file will be <= this value. - control_flow_v2: Bool whether to enable control flow v2 ops. - experiments: Bool enable experimental features. - metadata: User defined metadata map. - frozen_graph_dir: The directory to keep the intermediate frozen graph of - model. - """ - if signature_def is None: - signature_def = 'serving_default' - - if not gfile.exists(output_dir): - gfile.makedirs(output_dir) - output_graph = os.path.join( - output_dir, common.ARTIFACT_MODEL_JSON_FILE_NAME) - - saved_model_tags_list = None - if saved_model_tags: - saved_model_tags_list = saved_model_tags.split(',') - - model = None - concrete_func = None - saved_model_sigature = None - if saved_model_dir: - saved_model_sigature = _find_signature(saved_model_dir, saved_model_tags, - signature_def) - model = _load_model(saved_model_dir, saved_model_tags_list) - _check_signature_in_model(model, signature_def) - concrete_func = model.signatures[signature_def] - elif keras_model: - model = keras_model - input_signature = None - # If the model's call is not a `tf.function`, then we need to first get its - # input signature from `model_input_signature` method. We can't directly - # call `trace_model_call` because otherwise the batch dimension is set - # to None. - if not isinstance(model.call, def_function.Function): - # Pass `keep_original_batch_size=True` will ensure that we get an input - # signature including the batch dimension specified by the user. - input_signature = model_input_signature( - model, keep_original_batch_size=True) - func = trace_model_call(model, input_signature) - concrete_func = func.get_concrete_function() - else: - raise Exception('Provide either a saved model or keras model to convert.') - - output_node_names = [] - for output_tensor in concrete_func.outputs: - output_node_names.append(output_tensor.name.split(':')[0]) - - num_outputs = len(output_node_names) - structured_outputs = concrete_func.structured_outputs - if use_structured_outputs_names and structured_outputs is not None: - if not isinstance(structured_outputs, dict): - raise Exception('Converter only supports dict structured_outputs.') - - # As per tensorflow/python/util/nest.py: "If `structure` is or contains a - # dict instance, the keys will be sorted to pack the flat sequence - # in deterministic order." - sorted_keys = sorted(structured_outputs.keys()) - - # Check if structure is a simple dictionary. - # We don't support anything more complex due to the GraphModel.predict - # function return type in typescript. - test_sequence = list(range(num_outputs)) - actual_structure = tf.nest.pack_sequence_as( - structured_outputs, test_sequence, True) - expected_structure = dict(zip(sorted_keys, test_sequence)) - if actual_structure != expected_structure: - raise Exception('Converter only supports structured_outputs of form ' - '{"key1": value1, "key2":value2 ... })') - - metadata = metadata or {} - metadata[common.STRUCTURED_OUTPUTS_KEYS_KEY] = sorted_keys - - # TensorFlow doesn't encode the saved model version in the graph in a - # reliable way. Try to freeze the graph using V2 utils. If that fails, freeze - # the graph using V1 utils. - frozen_initializer_graph = None - resource_ids_maps = None - try: - frozen_graph = _freeze_saved_model_v2(concrete_func, control_flow_v2) - resource_initializer_concrete_func = _get_resource_initializer_concrete_function(model) - - if resource_initializer_concrete_func: - frozen_initializer_graph = _freeze_saved_model_v2(resource_initializer_concrete_func, control_flow_v2) - resource_ids_maps = _get_resource_ids_maps(model, concrete_func, resource_initializer_concrete_func) - - except BaseException: - if saved_model_dir: - (frozen_graph, - frozen_initializer_graph) = _freeze_saved_model_v1(saved_model_dir, - saved_model_tags_list, - output_node_names) - else: - print('Can not freeze saved model v1.') - return - - if frozen_graph_dir: - output_graph = os.path.join(frozen_graph_dir, - common.ARTIFACT_MODEL_JSON_FILE_NAME) - frozen_file = output_graph + '.frozen' - with tf.compat.v1.gfile.GFile(frozen_file, 'wb') as f: - f.write(frozen_graph.as_graph_def().SerializeToString()) - - signature = _build_signature_def( - frozen_graph, concrete_func.inputs, concrete_func.outputs, saved_model_sigature) - - define_transform_graph_func() - - tf_version = None - try: - tf_version = model.tensorflow_version - except: # pylint: disable=W0702 - # keras model does not have tensorflow_version, hard code to the latest - # tensorflow version. - tf_version = tf.__version__ - - if saved_model_dir: - model_ops = set(_get_frozen_graph_ops(frozen_graph)) |\ - set(_get_frozen_graph_ops(frozen_initializer_graph)) - if _is_assets_required(model_ops): - _copy_assets(saved_model_dir, output_dir) - - optimized_graph = optimize_graph(frozen_graph, signature, - skip_op_check=skip_op_check, - strip_debug_ops=strip_debug_ops, - experiments=experiments) - - initializer_graph_def = None - initializer_signature_def = None - if frozen_initializer_graph: - initializer_graph_def = frozen_initializer_graph.as_graph_def() - if hasattr(frozen_initializer_graph, 'outputs'): - initializer_signature_def = _build_signature_def(frozen_initializer_graph, [], frozen_initializer_graph.outputs) - - weights = extract_weights(optimized_graph, initializer_graph_def) - - write_artifacts(MessageToDict(optimized_graph), - weights, - output_graph, - tf_version, signature, - quantization_dtype_map=quantization_dtype_map, - weight_shard_size_bytes=weight_shard_size_bytes, - initializer_graph_def=initializer_graph_def, - initializer_signature_def=initializer_signature_def, - resource_ids_maps=resource_ids_maps, - metadata=metadata) - -def define_transform_graph_func(): - """Check if the TransformGraph is available to be imported, this package is - available in g3 but not in oss version of TensorFlow. - """ - - transform_graph_available = True - try: - from tensorflow.tools.graph_transforms import TransformGraph # pylint: disable=C0415 - except: # pylint: disable=W0702 - transform_graph_available = False - - # Define the strip graph functions when TransformGraph is available, this will - # strip the unused nodes from the graph. - if transform_graph_available: - def _strip_unused_nodes(frozen_graph, concrete_func, output_node_names): - # Find the names of the input nodes needed to extract the minimal - # inference graph. This is particularly useful for cases when the concrete - # function contains nodes that do not contribute the inference computation - # defined by the input/output pair. This would also eliminate op - # unsupported error caused by nodes outside of the minial infrerence - # graph. - input_node_names = [] - input_tensors = {} - for input_tensor in concrete_func.inputs: - if input_tensor.dtype != 'resource': - op_name = input_tensor.name.split(':')[0] - # The graph freezing may turn the original inputs into constants, or - # remove them from the graph, so we need to ignore those. - try: - op = frozen_graph.get_operation_by_name(op_name) - if op.type != 'Const': - input_node_names.append(op_name) - input_tensors[op_name] = input_tensor - except KeyError: - # The original input was removed when the graph was frozen. - continue - - graph_transformations = ['strip_unused_nodes'] - stripped_graph_def = TransformGraph( - frozen_graph.as_graph_def(), input_node_names, output_node_names, - graph_transformations) - - # The transform graph library cannot support input nodes that has dynamic - # shape, this code will update the dtype and shape based on the - # input tensor manually. - for node in stripped_graph_def.node: - if node.name in input_tensors: - if node.attr['shape'] and node.attr['shape'].shape: - node.attr['shape'].shape.CopyFrom( - input_tensors[node.name].shape.as_proto()) - if node.attr['dtype'] and node.attr['dtype'].type: - node.attr['dtype'].type = input_tensors[ - node.name].dtype.as_datatype_enum - - with tf.Graph().as_default() as stripped_graph: - tf.import_graph_def(stripped_graph_def, name='') - return stripped_graph - -def convert_tf_saved_model(saved_model_dir, - output_dir, signature_def='serving_default', - saved_model_tags='serve', - quantization_dtype_map=None, - skip_op_check=False, - strip_debug_ops=False, - use_structured_outputs_names=False, - weight_shard_size_bytes=1024 * 1024 * 4, - control_flow_v2=False, - experiments=False, - metadata=None, - frozen_graph_dir=None): - """Freeze the SavedModel and check the model compatibility with Tensorflow.js. - - Optimize and convert the model to Tensorflow.js format, when the model passes - the compatiblity check. - - Args: - saved_model_dir: string The saved model directory. - : string The names of the output nodes, comma separated. - output_dir: string The name of the output directory. The directory - will consist of - - a file named 'model.json' - - possibly sharded binary weight files. - signature_def: string Tagset of the SignatureDef to load. Defaults to - 'serving_default'. - saved_model_tags: tags of the GraphDef to load. Defaults to 'serve'. - quantization_dtype_map: A mapping from dtype - (`uint8`, `uint16`, `float16`) to weights names. The weight mapping - supports wildcard substitution. - skip_op_check: Bool whether to skip the op check. - strip_debug_ops: Bool whether to strip debug ops. - use_structured_outputs_names: Bool whether output of graph model will follow - the structured_outputs format. - weight_shard_size_bytes: Shard size (in bytes) of the weight files. - The size of each weight file will be <= this value. - control_flow_v2: Bool whether to enable control flow v2 ops. - experiments: Bool enable experimental features. - metadata: User defined metadata map. - frozen_graph_dir: The directory to keep the intermediate frozen graph of - model. - """ - _convert_tf_saved_model(output_dir, saved_model_dir=saved_model_dir, - signature_def=signature_def, - saved_model_tags=saved_model_tags, - quantization_dtype_map=quantization_dtype_map, - skip_op_check=skip_op_check, - strip_debug_ops=strip_debug_ops, - use_structured_outputs_names= - use_structured_outputs_names, - weight_shard_size_bytes=weight_shard_size_bytes, - control_flow_v2=control_flow_v2, - experiments=experiments, - metadata=metadata, - frozen_graph_dir=frozen_graph_dir) - -def load_and_initialize_hub_module(module_path, signature='default'): - """Loads graph of a TF-Hub module and initializes it into a session. - - Args: - module_path: string Path to TF-Hub module. - signature: string Signature to use when creating the apply graph. - - Return: - graph: tf.Graph Graph of the module. - session: tf.Session Session with initialized variables and tables. - inputs: dict Dictionary of input tensors. - outputs: dict Dictionary of output tensors. - - Raises: - ValueError: If signature contains a SparseTensor on input or output. - """ - graph = tf.Graph() - with graph.as_default(): - tf.compat.v1.logging.info('Importing %s', module_path) - module = hub.Module(module_path) - - signature_inputs = module.get_input_info_dict(signature) - signature_outputs = module.get_output_info_dict(signature) - # First check there are no SparseTensors in input or output. - for key, info in list(signature_inputs.items()) + list( - signature_outputs.items()): - if info.is_sparse: - raise ValueError( - 'Signature "%s" has a SparseTensor on input/output "%s".' - ' SparseTensors are not supported.' % (signature, key)) - - # Create placeholders to represent the input of the provided signature. - inputs = {} - for input_key, input_info in signature_inputs.items(): - inputs[input_key] = tf.compat.v1.placeholder( - shape=input_info.get_shape(), dtype=input_info.dtype, name=input_key) - - outputs = module(inputs=inputs, signature=signature, as_dict=True) - - session = tf.compat.v1.Session(graph=graph) - session.run(tf.compat.v1.global_variables_initializer()) - session.run(tf.compat.v1.tables_initializer()) - - return graph, session, inputs, outputs - - -def convert_tf_hub_module_v1(module_path, output_dir, - signature='default', quantization_dtype_map=None, - skip_op_check=False, strip_debug_ops=False, - weight_shard_size_bytes=1024 * 1024 * 4, - experiments=False, - metadata=None): - """Freeze the TF-Hub module and check compatibility with Tensorflow.js. - - Optimize and convert the TF-Hub module to Tensorflow.js format, if it passes - the compatiblity check. - - Args: - module_path: string Path to the module. - output_dir: string The name of the output directory. The directory - will consist of - - a file named 'model.json' - - possibly sharded binary weight files. - signature: string Signature to load. - quantization_dtype_map: A mapping from dtype - (`uint8`, `uint16`, `float16`) to weights names. The weight mapping - supports wildcard substitution. - skip_op_check: Bool whether to skip the op check. - strip_debug_ops: Bool whether to strip debug ops. - weight_shard_size_bytes: Shard size (in bytes) of the weight files. - The size of each weight file will be <= this value. - experiments: Bool enable experimental features. - metadata: User defined metadata map. - """ - - if signature is None: - signature = 'default' - - if not os.path.exists(output_dir): - os.makedirs(output_dir) - - graph, sess, inputs, outputs = load_and_initialize_hub_module( - module_path, signature) - - input_node_names = [] - output_node_names = [] - - for input_tensor in inputs.values(): - input_node_names.append(input_tensor.name.split(':')[0]) - for output_tensor in outputs.values(): - output_node_names.append(output_tensor.name.split(':')[0]) - - print('Creating a model with inputs %s and outputs %s.' % (input_node_names, - output_node_names)) - - frozen_graph_def = tf.compat.v1.graph_util.convert_variables_to_constants( - sess, graph.as_graph_def(), output_node_names) - - output_graph = os.path.join(output_dir, common.ARTIFACT_MODEL_JSON_FILE_NAME) - frozen_file = output_graph + '.frozen' - try: - with tf.compat.v1.gfile.GFile(frozen_file, 'wb') as f: - f.write(frozen_graph_def.SerializeToString()) - - frozen_graph = load_graph(frozen_file) - signature = _build_signature_def(frozen_graph, - inputs.values(), outputs.values()) - - optimized_graph = optimize_graph(frozen_graph, signature, - skip_op_check=skip_op_check, - strip_debug_ops=strip_debug_ops, - experiments=experiments) - - weights = extract_weights(optimized_graph) - - write_artifacts(MessageToDict(optimized_graph), weights, - output_graph, tf.__version__, signature, - quantization_dtype_map=quantization_dtype_map, - weight_shard_size_bytes=weight_shard_size_bytes, - metadata=metadata) - finally: - # Clean up the temp files. - if os.path.exists(frozen_file): - os.remove(frozen_file) - - -def convert_tf_hub_module(module_handle, output_dir, - signature='default', saved_model_tags='serve', - quantization_dtype_map=None, - skip_op_check=False, strip_debug_ops=False, - use_structured_outputs_names=False, - weight_shard_size_bytes=1024 * 1024 * 4, - control_flow_v2=False, - experiments=False, - metadata=None): - """Conversion for TF Hub modules V1 and V2. - - See convert_tf_hub_module and convert_tf_saved_model. - - Args: - module_path: string Path to the module. - output_dir: string The name of the output directory. The directory - will consist of - - a file named 'model.json' - - possibly sharded binary weight files. - signature: string Signature to load. - saved_model_tags: tags of the GraphDef to load. Defaults to ''. - quantization_dtype_map: A mapping from dtype - (`uint8`, `uint16`, `float16`) to weights names. The weight mapping - supports wildcard substitution. - skip_op_check: Bool whether to skip the op check. - strip_debug_ops: Bool whether to strip debug ops. - use_structured_outputs_names: Bool whether output of graph model will follow - the structured_outputs format. - weight_shard_size_bytes: Shard size (in bytes) of the weight files. - The size of each weight file will be <= this value. - control_flow_v2: Bool whether to enable control flow v2 ops. - experiments: Bool enable experimental features. - metadata: User defined metadata map. - """ - module_path = hub.resolve(module_handle) - # TODO(vbardiovskyg): We can remove this v1 code path once loading of all v1 - # modules is fixed on the TF side, or once the modules we cannot load become - # replaced with newer versions. - if gfile.exists(os.path.join(module_path, _HUB_V1_MODULE_PB)): - print("Loading the module using TF 1.X interface from %s." % module_path) - convert_tf_hub_module_v1(module_path, output_dir, signature, - quantization_dtype_map, - skip_op_check, strip_debug_ops, - weight_shard_size_bytes, - experiments=experiments, - metadata=metadata) - else: - print("Loading the module using TF 2.X interface from %s." % module_path) - if signature is None: - signature = 'default' - convert_tf_saved_model(saved_model_dir=module_path, - output_dir=output_dir, - signature_def=signature, - saved_model_tags=saved_model_tags, - quantization_dtype_map=quantization_dtype_map, - skip_op_check=skip_op_check, - strip_debug_ops=strip_debug_ops, - use_structured_outputs_names= - use_structured_outputs_names, - weight_shard_size_bytes=weight_shard_size_bytes, - control_flow_v2=control_flow_v2, - experiments=experiments, - metadata=metadata) - -def convert_keras_model_to_graph_model(keras_model, - output_dir, - saved_model_tags='serve', - quantization_dtype_map=None, - skip_op_check=False, - strip_debug_ops=False, - use_structured_outputs_names=False, - weight_shard_size_bytes=1024 * 1024 * 4, - control_flow_v2=False, - experiments=False, - metadata=None): - """Convert an in-memory keras model to Tensorflow.js graph model format. - - Args: - keras_model: Keras Model object. - output_dir: string The name of the output directory. The directory - will consist of - - a file named 'model.json' - - possibly sharded binary weight files. - saved_model_tags: tags of the GraphDef to load. Defaults to 'serve'. - quantization_dtype_map: A mapping from dtype - (`uint8`, `uint16`, `float16`) to weights names. The weight mapping - supports wildcard substitution. - skip_op_check: Bool whether to skip the op check. - strip_debug_ops: Bool whether to strip debug ops. - use_structured_outputs_names: Bool whether output of graph model will follow - the structured_outputs format. - weight_shard_size_bytes: Shard size (in bytes) of the weight files. - The size of each weight file will be <= this value. - control_flow_v2: Bool whether to enable control flow v2 ops. - experiments: Bool enable experimental features. - metadata: User defined metadata map. - """ - _convert_tf_saved_model(output_dir, keras_model=keras_model, - saved_model_tags=saved_model_tags, - quantization_dtype_map=quantization_dtype_map, - skip_op_check=skip_op_check, - strip_debug_ops=strip_debug_ops, - use_structured_outputs_names= - use_structured_outputs_names, - weight_shard_size_bytes=weight_shard_size_bytes, - control_flow_v2=control_flow_v2, - experiments=experiments, - metadata=metadata) diff --git a/tfjs-master/tfjs-converter/python/tensorflowjs/converters/tf_saved_model_conversion_v2_test.py b/tfjs-master/tfjs-converter/python/tensorflowjs/converters/tf_saved_model_conversion_v2_test.py deleted file mode 100644 index 8eb000d3d..000000000 --- a/tfjs-master/tfjs-converter/python/tensorflowjs/converters/tf_saved_model_conversion_v2_test.py +++ /dev/null @@ -1,1428 +0,0 @@ -# Copyright 2018 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================== -"""Unit tests for artifact conversion to and from Tensorflow SavedModel v2.""" - -import base64 -import glob -import json -import os -import shutil -import tempfile -import unittest -import numpy as np - -import tensorflow.compat.v2 as tf -from tensorflow_decision_forests.keras import GradientBoostedTreesModel -from tensorflow.python.eager import def_function -from tensorflow.python.framework import constant_op -from tensorflow.python.framework import dtypes -from tensorflow.python.framework import tensor_spec -from tensorflow.python.ops import variables -from tensorflow.python.trackable import autotrackable -from tensorflow.python.tools import freeze_graph -from tensorflow.python.saved_model.save import save -import tensorflow_hub as hub -from tensorflowjs import version -from tensorflowjs.converters import graph_rewrite_util -from tensorflowjs.converters import tf_saved_model_conversion_v2 -from tensorflowjs.converters.common import ASSETS_DIRECTORY_NAME - -SAVED_MODEL_DIR = 'saved_model' -HUB_MODULE_DIR = 'hub_module' -FROZEN_MODEL_DIR = 'frozen_model' - -class ConvertTest(tf.test.TestCase): - def setUp(self): - super(ConvertTest, self).setUp() - self._tmp_dir = tempfile.mkdtemp() - - def tearDown(self): - if os.path.isdir(self._tmp_dir): - shutil.rmtree(self._tmp_dir) - super(ConvertTest, self).tearDown() - - def _create_saved_model_v1(self): - """Create a TensorFlow SavedModel for testing.""" - - graph = tf.Graph() - with graph.as_default(): - x = tf.compat.v1.constant([[37.0, -23.0], [1.0, 4.0]]) - w = tf.compat.v1.get_variable('w', shape=[2, 2]) - y = tf.compat.v1.matmul(x, w) - output = tf.compat.v1.nn.softmax(y) - init_op = w.initializer - - # Create a builder. - save_dir = os.path.join(self._tmp_dir, SAVED_MODEL_DIR) - builder = tf.compat.v1.saved_model.builder.SavedModelBuilder(save_dir) - - with tf.compat.v1.Session() as sess: - # Run the initializer on `w`. - sess.run(init_op) - - builder.add_meta_graph_and_variables( - sess, [tf.compat.v1.saved_model.tag_constants.SERVING], - signature_def_map={ - 'serving_default': - tf.compat.v1.saved_model \ - .signature_def_utils.predict_signature_def( - inputs={'x': x}, - outputs={'output': output}) - }, - assets_collection=None) - - builder.save() - - def _create_saved_model_v1_with_hashtable(self): - """Create a TensorFlow SavedModel V1 with unused hash table for testing.""" - - graph = tf.Graph() - with graph.as_default(): - x = tf.compat.v1.placeholder('int32', [None, 2, 2]) - t = tf.compat.v1.to_float(x) - w = tf.compat.v1.get_variable('w', shape=[2, 2]) - output = tf.compat.v1.matmul(t, w) - init_op = w.initializer - - # Add a hash table that is not used by the output. - keys = tf.constant(['key']) - values = tf.constant([1]) - initializer = tf.lookup.KeyValueTensorInitializer(keys, values) - table = tf.lookup.StaticHashTable(initializer, -1) - - # Create a builder. - save_dir = os.path.join(self._tmp_dir, SAVED_MODEL_DIR) - builder = tf.compat.v1.saved_model.builder.SavedModelBuilder( - save_dir) - - with tf.compat.v1.Session() as sess: - # Run the initializer on `w`. - sess.run(init_op) - table.lookup(keys) - builder.add_meta_graph_and_variables( - sess, [tf.compat.v1.saved_model.tag_constants.SERVING], - signature_def_map={ - 'serving_default': - tf.compat.v1.saved_model \ - .signature_def_utils.predict_signature_def( - inputs={'t': t}, - outputs={'output': output}) - }, - assets_collection=None) - - builder.save() - - def _create_saved_model_v2_with_hashtable(self): - """Create a TensorFlow SavedModel V2 with hash table for testing.""" - - class Table(tf.Module): - def __init__(self): - super(Table, self).__init__() - keys = tf.constant(['a', 'b']) - vals= tf.constant([0, 1]) - init = tf.lookup.KeyValueTensorInitializer(keys, vals) - self.table = tf.lookup.StaticHashTable(init, -1) - - def initializeTable(self): - @tf.function - def lookup(input): - return self.table.lookup(input) - - return lookup - - model = Table() - concrete_fn = model.initializeTable().get_concrete_function( - input=tf.TensorSpec([None], tf.string)) - - save_dir = os.path.join(self._tmp_dir, SAVED_MODEL_DIR) - tf.saved_model.save(model, save_dir, signatures={"serving_default": concrete_fn}) - - def _create_saved_model_with_fusable_conv2d(self, use_bias): - """Test a basic model with fusable conv2d.""" - layers = [ - tf.keras.layers.Conv2D( - 16, [3, 3], padding='same', use_bias=use_bias), - tf.keras.layers.BatchNormalization(), - tf.keras.layers.ReLU() - ] - model = tf.keras.Sequential(layers) - model.predict(tf.ones((1, 224, 224, 3))) - tf.keras.backend.set_learning_phase(0) - save_dir = os.path.join(self._tmp_dir, SAVED_MODEL_DIR) - tf.saved_model.save(model, save_dir) - - def _create_saved_model_with_fusable_depthwise_conv2d(self): - """Test a basic model with fusable depthwise conv2d.""" - layers = [ - tf.keras.layers.DepthwiseConv2D( - 1, use_bias=True, - bias_initializer=tf.initializers.constant(0.25)), - tf.keras.layers.ReLU() - ] - model = tf.keras.Sequential(layers) - model.predict(tf.ones((1, 2, 2, 3))) - tf.keras.backend.set_learning_phase(0) - save_dir = os.path.join(self._tmp_dir, SAVED_MODEL_DIR) - tf.saved_model.save(model, save_dir) - - def _create_saved_model_with_fusable_addV2(self): - """Test a basic model with fusable addV2.""" - @tf.function - def conv2d_addV2_depthwise_addV2(x): - filter = tf.ones([1, 1, 1, 1]) - bias = tf.constant([100], dtype=dtypes.float32) - res = tf.raw_ops.Conv2D( - input=x, filter=filter, strides=[1, 1, 1, 1], padding="VALID") - res = tf.raw_ops.AddV2(x=res, y=bias) - res = tf.raw_ops.DepthwiseConv2dNative( - input=res, filter=filter, strides=[1, 1, 1, 1], padding="VALID") - res = tf.raw_ops.AddV2(x=res, y=bias) - return res - root = autotrackable.AutoTrackable() - root.f = conv2d_addV2_depthwise_addV2 - to_save = root.f.get_concrete_function( - tensor_spec.TensorSpec([1, 1, 1, 1], dtypes.float32)) - save_dir = os.path.join(self._tmp_dir, SAVED_MODEL_DIR) - save(root, save_dir, to_save) - - def _create_saved_model_with_unfusable_addV2(self): - """Test a basic model with fusable addV2.""" - @tf.function - def addV2_conv2d(x): - bias = tf.constant([100], dtype=dtypes.float32) - filter = tf.ones([1, 1, 1, 1]) - res = tf.raw_ops.AddV2(x=x, y=bias) - res = tf.raw_ops.Conv2D( - input=res, filter=filter, strides=[1, 1, 1, 1], padding="VALID") - return res - root = autotrackable.AutoTrackable() - root.f = addV2_conv2d - to_save = root.f.get_concrete_function( - tensor_spec.TensorSpec([1, 1, 1, 1], dtypes.float32)) - save_dir = os.path.join(self._tmp_dir, SAVED_MODEL_DIR) - save(root, save_dir, to_save) - - def _create_saved_model_with_prelu(self): - """Test a basic model with fusable conv2d.""" - layers = [ - tf.keras.layers.Conv2D( - 16, [3, 3], padding='same', use_bias=True, - bias_initializer=tf.initializers.constant(0.25)), - tf.keras.layers.PReLU(alpha_initializer=tf.initializers.constant(0.25)), - tf.keras.layers.DepthwiseConv2D( - 1, use_bias=True, - bias_initializer=tf.initializers.constant(0.25)), - tf.keras.layers.PReLU(alpha_initializer=tf.initializers.constant(0.25)) - ] - model = tf.keras.Sequential(layers) - model.predict(tf.ones((1, 224, 224, 3))) - tf.keras.backend.set_learning_phase(0) - save_dir = os.path.join(self._tmp_dir, SAVED_MODEL_DIR) - tf.saved_model.save(model, save_dir) - - def _create_saved_model_with_unfusable_prelu(self): - """Test a basic model with unfusable prelu.""" - layers = [ - tf.keras.layers.ReLU(), - tf.keras.layers.PReLU(alpha_initializer=tf.initializers.constant(0.25)) - ] - model = tf.keras.Sequential(layers) - model.predict(tf.ones((1, 224, 3))) - tf.keras.backend.set_learning_phase(0) - save_dir = os.path.join(self._tmp_dir, SAVED_MODEL_DIR) - tf.saved_model.save(model, save_dir) - - def _create_saved_model(self): - """Test a basic model with functions to make sure functions are inlined.""" - input_data = constant_op.constant(1., shape=[1]) - root = autotrackable.AutoTrackable() - root.v1 = variables.Variable(3.) - root.v2 = variables.Variable(2.) - root.f = def_function.function(lambda x: root.v1 * root.v2 * x) - to_save = root.f.get_concrete_function(input_data) - - save_dir = os.path.join(self._tmp_dir, SAVED_MODEL_DIR) - save(root, save_dir, to_save) - - def _create_saved_model_with_fusable_matmul(self): - """Test a fusable matmul model.""" - input_data = constant_op.constant(1., shape=[1, 1]) - bias_data = constant_op.constant(1., shape=[1]) - root = autotrackable.AutoTrackable() - root.v2 = variables.Variable([[2.]]) - root.f = def_function.function( - lambda x: tf.nn.relu(tf.nn.bias_add(tf.matmul(x, root.v2), - bias_data))) - to_save = root.f.get_concrete_function(input_data) - - save_dir = os.path.join(self._tmp_dir, SAVED_MODEL_DIR) - save(root, save_dir, to_save) - - def _create_saved_model_with_control_flow(self): - """Test a basic model with control flow to inlined.""" - @tf.function - def find_next_odd(v): - v1 = v + 1 - while tf.equal(v1 % 2, 0): - v1 = v1 + 1 - return v1 - root = autotrackable.AutoTrackable() - root.f = find_next_odd - to_save = root.f.get_concrete_function( - tensor_spec.TensorSpec([], dtypes.int32)) - - save_dir = os.path.join(self._tmp_dir, SAVED_MODEL_DIR) - save(root, save_dir, to_save) - - def _create_saved_model_with_tfdf(self): - """Test a basic TFDF model.""" - P = 5 - NUM_EXAMPLES = 10 - NUM_FEATURES = 4 - - x_train = np.random.uniform(size=(NUM_EXAMPLES, NUM_FEATURES)) - y_train = np.random.uniform(size=NUM_EXAMPLES) > 0.5 - w_train = y_train * (P - 1) + 1 # 1 or p depending on the class. - - model = GradientBoostedTreesModel() - model.fit(x=x_train, y=y_train, sample_weight=w_train) - - save_dir = os.path.join(self._tmp_dir, SAVED_MODEL_DIR) - model.save(save_dir) - - def _create_unsupported_saved_model(self): - root = autotrackable.AutoTrackable() - root.w = variables.Variable(tf.random.uniform([2, 2])) - - @def_function.function - def exported_function(x): - root.x = constant_op.constant([[37.0, -23.0], [1.0, 4.0]]) - root.y = tf.matmul(root.x, root.w) - # unsupported op: linalg.diag - root.z = tf.linalg.diag(root.y) - return root.z * x - - root.f = exported_function - to_save = root.f.get_concrete_function( - tensor_spec.TensorSpec([], dtypes.float32)) - - save_dir = os.path.join(self._tmp_dir, SAVED_MODEL_DIR) - save(root, save_dir, to_save) - - def _create_saved_model_with_debug_ops(self): - root = autotrackable.AutoTrackable() - root.w = variables.Variable(tf.random.uniform([2, 2])) - - @def_function.function - def exported_function(x): - root.x = constant_op.constant([[37.0, -23.0], [1.0, 4.0]]) - root.y = tf.matmul(root.x, root.w) - tf.compat.v1.Print(root.x, [root.x]) - tf.compat.v1.Assert(tf.greater(tf.reduce_max(root.x), 0), [root.x]) - tf.compat.v1.check_numerics(root.x, 'NaN found') - return root.y * x - - root.f = exported_function - to_save = root.f.get_concrete_function( - tensor_spec.TensorSpec([], dtypes.float32)) - - save_dir = os.path.join(self._tmp_dir, SAVED_MODEL_DIR) - save(root, save_dir, to_save) - - def _create_saved_model_with_structured_outputs(self): - def create_input(name): - return tf.keras.layers.Input(name=name, shape=(1,), dtype=tf.float32) - - input1 = create_input("input1") - input3 = create_input("input3") - input2 = create_input("input2") - - output1 = tf.keras.layers.Dense(1, name='a') - output1 = output1(tf.keras.layers.concatenate([input1, input3], axis=1)) - output2 = tf.keras.layers.Dense(1, name='b')(input2) - output3 = tf.keras.layers.Multiply(name='c')([output1, output2]) - - inputs = { - "input1": input1, - "input3": input3, - "input2": input2 - } - - outputs = { - "a": output1, - "c": output3, - "b": output2 - } - - model = tf.keras.Model(inputs=inputs, outputs=outputs) - save_dir = os.path.join(self._tmp_dir, SAVED_MODEL_DIR) - tf.saved_model.save(model, save_dir) - - def _create_hub_module(self): - # Module function that doubles its input. - def double_module_fn(): - w = tf.Variable([2.0, 4.0]) - x = tf.compat.v1.placeholder(dtype=tf.float32) - hub.add_signature(inputs=x, outputs=x*w) - graph = tf.Graph() - with graph.as_default(): - spec = hub.create_module_spec(double_module_fn) - m = hub.Module(spec) - # Export the module. - with tf.compat.v1.Session(graph=graph) as sess: - sess.run(tf.compat.v1.global_variables_initializer()) - m.export(os.path.join(self._tmp_dir, HUB_MODULE_DIR), sess) - - def create_frozen_model(self): - graph = tf.Graph() - saved_model_dir = os.path.join(self._tmp_dir, FROZEN_MODEL_DIR) - with graph.as_default(): - x = tf.constant([[37.0, -23.0], [1.0, 4.0]]) - w = tf.Variable(tf.random.uniform([2, 2])) - y = tf.matmul(x, w) - tf.nn.softmax(y) - init_op = w.initializer - - # Create a builder - builder = tf.compat.v1.saved_model.builder.SavedModelBuilder( - saved_model_dir) - - with tf.compat.v1.Session() as sess: - # Run the initializer on `w`. - sess.run(init_op) - - builder.add_meta_graph_and_variables( - sess, [tf.compat.v1.saved_model.tag_constants.SERVING], - signature_def_map=None, - assets_collection=None) - - builder.save() - - frozen_file = os.path.join(self._tmp_dir, FROZEN_MODEL_DIR, 'model.frozen') - freeze_graph.freeze_graph( - '', - '', - True, - '', - "Softmax", - '', - '', - frozen_file, - True, - '', - saved_model_tags=tf.compat.v1.saved_model.tag_constants.SERVING, - input_saved_model_dir=saved_model_dir) - - def test_convert_saved_model_v1(self): - self._create_saved_model_v1() - - input_dir = os.path.join(self._tmp_dir, SAVED_MODEL_DIR) - output_dir = os.path.join(input_dir, 'js') - tf_saved_model_conversion_v2.convert_tf_saved_model( - input_dir, - output_dir - ) - - tfjs_path = os.path.join(self._tmp_dir, SAVED_MODEL_DIR, 'js') - # Check model.json and weights manifest. - with open(os.path.join(tfjs_path, 'model.json'), 'rt') as f: - model_json = json.load(f) - self.assertTrue(model_json['modelTopology']) - self.assertIsNot(model_json['modelTopology']['versions'], None) - signature = model_json['signature'] - self.assertIsNot(signature, None) - self.assertIsNot(signature['inputs'], None) - self.assertIsNot(signature['outputs'], None) - weights_manifest = model_json['weightsManifest'] - self.assertCountEqual(weights_manifest[0]['paths'], - ['group1-shard1of1.bin']) - self.assertIn('weights', weights_manifest[0]) - - # Check meta-data in the artifact JSON. - self.assertEqual(model_json['format'], 'graph-model') - self.assertEqual( - model_json['convertedBy'], - 'TensorFlow.js Converter v%s' % version.version) - self.assertEqual(model_json['generatedBy'], - tf.__version__) - self.assertTrue(glob.glob(os.path.join(output_dir, 'group*-*'))) - - def test_convert_saved_model_v1_with_hashtable(self): - self._create_saved_model_v1_with_hashtable() - - input_dir = os.path.join(self._tmp_dir, SAVED_MODEL_DIR) - output_dir = os.path.join(input_dir, 'js') - tf_saved_model_conversion_v2.convert_tf_saved_model( - input_dir, - output_dir - ) - - expected_weights_manifest = [{ - 'paths': ['group1-shard1of1.bin'], - 'weights': [ - {'dtype': 'float32', 'name': 'w', 'shape': [2, 2]}, - {'dtype': 'string', 'name': 'Const', 'shape': [1]}, - {'dtype': 'int32', 'name': 'Const_1', 'shape': [1]} - ]}] - - tfjs_path = os.path.join(self._tmp_dir, SAVED_MODEL_DIR, 'js') - # Check model.json and weights manifest. - with open(os.path.join(tfjs_path, 'model.json'), 'rt') as f: - model_json = json.load(f) - self.assertTrue(model_json['modelTopology']) - self.assertIsNot(model_json['modelTopology']['versions'], None) - signature = model_json['signature'] - self.assertIsNot(signature, None) - self.assertIsNot(signature['inputs'], None) - self.assertIsNot(signature['outputs'], None) - self.assertTrue(model_json['modelInitializer']) - - for node in model_json['modelTopology']['node']: - if node['name'] == 'ToFloat' and node['op'] == 'Placeholder': - self.assertEqual(node['attr']['shape'], - {'shape': {'dim': [ - {'size': '-1'}, {'size': '2'}, {'size': '2'}]}}) - - weights_manifest = model_json['weightsManifest'] - self.assertEqual(weights_manifest, expected_weights_manifest) - # Check meta-data in the artifact JSON. - self.assertEqual(model_json['format'], 'graph-model') - self.assertEqual( - model_json['convertedBy'], - 'TensorFlow.js Converter v%s' % version.version) - self.assertEqual(model_json['generatedBy'], - tf.__version__) - self.assertTrue(glob.glob(os.path.join(output_dir, 'group*-*'))) - - def test_convert_saved_model_v2_with_hashtable(self): - self._create_saved_model_v2_with_hashtable() - - input_dir = os.path.join(self._tmp_dir, SAVED_MODEL_DIR) - output_dir = os.path.join(input_dir, 'js') - tf_saved_model_conversion_v2.convert_tf_saved_model( - input_dir, - output_dir - ) - - expected_signature = { - 'inputs': { - 'input': { - 'name': 'input:0', - 'dtype': 'DT_STRING', - 'tensorShape': {'dim': [{'size': '-1'}]} - }, - 'unknown:0': { - 'name': 'unknown:0', - 'dtype': 'DT_RESOURCE', - 'tensorShape': {}, - 'resourceId': None - } - }, - 'outputs': { - 'output_0': { - 'name': 'Identity:0', - 'dtype': 'DT_INT32', - 'tensorShape': {'dim': [{'size': '-1'}]} - } - } - } - - expected_initializer_signature = { - 'outputs': { - 'Identity:0': { - 'name': 'Identity:0', - 'dtype': 'DT_RESOURCE', - 'tensorShape': {}, - 'resourceId': None - } - } - } - - tfjs_path = os.path.join(self._tmp_dir, SAVED_MODEL_DIR, 'js') - # Check model.json and weights manifest. - with open(os.path.join(tfjs_path, 'model.json'), 'rt') as f: - model_json = json.load(f) - - # Check resource ids match which indicates the initializer output is mapped - # to the inference input. - signature_resource_id = model_json['signature']['inputs']['unknown:0']['resourceId'] - initializer_resource_id = model_json['initializerSignature']['outputs']['Identity:0']['resourceId'] - self.assertTrue(signature_resource_id) - self.assertEqual(signature_resource_id, initializer_resource_id) - - # Update expected signatures with resourceId since it is a runtime value. - expected_signature['inputs']['unknown:0']['resourceId'] = signature_resource_id - expected_initializer_signature['outputs']['Identity:0']['resourceId'] = signature_resource_id - self.assertEqual(model_json['signature'], expected_signature) - self.assertEqual(model_json['initializerSignature'], expected_initializer_signature) - - self.assertTrue(model_json['modelTopology']) - self.assertIsNot(model_json['modelTopology']['versions'], None) - model_ops = [node['op'] for node in model_json['modelTopology']['node']] - self.assertIn('LookupTableFindV2', model_ops) - - self.assertTrue(model_json['modelInitializer']) - initializer_ops = [node['op'] for node in model_json['modelInitializer']['node']] - self.assertIn('HashTableV2', initializer_ops) - self.assertIn('LookupTableImportV2', initializer_ops) - - weights_manifest = model_json['weightsManifest'][0] - self.assertEqual(weights_manifest['paths'], ['group1-shard1of1.bin']) - self.assertEqual(weights_manifest['weights'][0], - {'name': 'unknown_0', 'shape': [], 'dtype': 'int32'}) - # Only check weights and dtype since name may vary between TF versions. - self.assertEqual(weights_manifest['weights'][1]['shape'], [2]) - self.assertEqual(weights_manifest['weights'][1]['dtype'], 'string') - self.assertEqual(weights_manifest['weights'][2]['shape'], [2]) - self.assertEqual(weights_manifest['weights'][2]['dtype'], 'int32') - - # Check meta-data in the artifact JSON. - self.assertEqual(model_json['format'], 'graph-model') - self.assertEqual( - model_json['convertedBy'], - 'TensorFlow.js Converter v%s' % version.version) - self.assertEqual(model_json['generatedBy'], - tf.__version__) - self.assertTrue(glob.glob(os.path.join(output_dir, 'group*-*'))) - - def test_convert_saved_model_v1_with_metadata(self): - self._create_saved_model_v1() - - input_dir = os.path.join(self._tmp_dir, SAVED_MODEL_DIR) - output_dir = os.path.join(input_dir, 'js') - - metadata_json = {'a': 1} - tf_saved_model_conversion_v2.convert_tf_saved_model( - input_dir, - output_dir, - metadata={'key': metadata_json} - ) - - tfjs_path = os.path.join(self._tmp_dir, SAVED_MODEL_DIR, 'js') - # Check model.json and weights manifest. - with open(os.path.join(tfjs_path, 'model.json'), 'rt') as f: - model_json = json.load(f) - self.assertEqual(metadata_json, model_json['userDefinedMetadata']['key']) - - def test_convert_saved_model(self): - self._create_saved_model() - - tf_saved_model_conversion_v2.convert_tf_saved_model( - os.path.join(self._tmp_dir, SAVED_MODEL_DIR), - os.path.join(self._tmp_dir, SAVED_MODEL_DIR) - ) - - tfjs_path = os.path.join(self._tmp_dir, SAVED_MODEL_DIR) - # Check model.json and weights manifest. - with open(os.path.join(tfjs_path, 'model.json'), 'rt') as f: - model_json = json.load(f) - self.assertTrue(model_json['modelTopology']) - self.assertIsNot(model_json['modelTopology']['versions'], None) - signature = model_json['signature'] - self.assertIsNot(signature, None) - self.assertIsNot(signature['inputs'], None) - self.assertIsNot(signature['outputs'], None) - weights_manifest = model_json['weightsManifest'] - self.assertCountEqual(weights_manifest[0]['paths'], - ['group1-shard1of1.bin']) - self.assertIn('weights', weights_manifest[0]) - - def test_convert_saved_model_with_frozen_file(self): - self._create_saved_model() - - tf_saved_model_conversion_v2.convert_tf_saved_model( - os.path.join(self._tmp_dir, SAVED_MODEL_DIR), - os.path.join(self._tmp_dir, SAVED_MODEL_DIR), - frozen_graph_dir=os.path.join(self._tmp_dir, SAVED_MODEL_DIR) - ) - - frozen_file_path = os.path.join(self._tmp_dir, SAVED_MODEL_DIR, - 'model.json.frozen') - # Check model.json.frozen exist. - self.assertTrue( - glob.glob(frozen_file_path)) - - def test_convert_saved_model_with_metadata(self): - self._create_saved_model() - - metadata_json = {'a': 1} - - tf_saved_model_conversion_v2.convert_tf_saved_model( - os.path.join(self._tmp_dir, SAVED_MODEL_DIR), - os.path.join(self._tmp_dir, SAVED_MODEL_DIR), - metadata={'key': metadata_json} - ) - - tfjs_path = os.path.join(self._tmp_dir, SAVED_MODEL_DIR) - # Check model.json and weights manifest. - with open(os.path.join(tfjs_path, 'model.json'), 'rt') as f: - model_json = json.load(f) - self.assertEqual(metadata_json, model_json['userDefinedMetadata']['key']) - - def test_convert_saved_model_with_fused_conv2d(self): - for use_bias in [True, False]: - self._create_saved_model_with_fusable_conv2d(use_bias) - tf_saved_model_conversion_v2.convert_tf_saved_model( - os.path.join(self._tmp_dir, SAVED_MODEL_DIR), - os.path.join(self._tmp_dir, SAVED_MODEL_DIR) - ) - - tfjs_path = os.path.join(self._tmp_dir, SAVED_MODEL_DIR) - # Check model.json and weights manifest. - with open(os.path.join(tfjs_path, 'model.json'), 'rt') as f: - model_json = json.load(f) - self.assertTrue(model_json['modelTopology']) - self.assertIsNot(model_json['modelTopology']['versions'], None) - signature = model_json['signature'] - self.assertIsNot(signature, None) - self.assertIsNot(signature['inputs'], None) - self.assertIsNot(signature['outputs'], None) - - nodes = model_json['modelTopology']['node'] - - fused_op = None - for node in nodes: - self.assertNotIn('BatchNorm', node['op']) - self.assertNotIn('Relu', node['op']) - self.assertNotIn('BiasAdd', node['op']) - if node['op'] == '_FusedConv2D': - fused_op = node - self.assertIsNot(fused_op, None) - self.assertEqual( - base64.b64decode(fused_op['attr']['fused_ops']['list']['s'][0]), - b'BiasAdd') - self.assertEqual( - base64.b64decode(fused_op['attr']['fused_ops']['list']['s'][1]), - b'Relu') - - # Check meta-data in the artifact JSON. - self.assertEqual(model_json['format'], 'graph-model') - self.assertEqual( - model_json['convertedBy'], - 'TensorFlow.js Converter v%s' % version.version) - self.assertEqual(model_json['generatedBy'], - tf.__version__) - self.assertTrue( - glob.glob( - os.path.join(self._tmp_dir, SAVED_MODEL_DIR, 'group*-*'))) - - def test_convert_saved_model_with_fused_matmul(self): - self._create_saved_model_with_fusable_matmul() - tf_saved_model_conversion_v2.convert_tf_saved_model( - os.path.join(self._tmp_dir, SAVED_MODEL_DIR), - os.path.join(self._tmp_dir, SAVED_MODEL_DIR) - ) - - tfjs_path = os.path.join(self._tmp_dir, SAVED_MODEL_DIR) - # Check model.json and weights manifest. - with open(os.path.join(tfjs_path, 'model.json'), 'rt') as f: - model_json = json.load(f) - self.assertTrue(model_json['modelTopology']) - self.assertIsNot(model_json['modelTopology']['versions'], None) - signature = model_json['signature'] - self.assertIsNot(signature, None) - self.assertIsNot(signature['inputs'], None) - self.assertIsNot(signature['outputs'], None) - - nodes = model_json['modelTopology']['node'] - fused_op = None - for node in nodes: - self.assertNotEqual(node['op'], 'MatMul') - self.assertNotIn('Relu', node['op']) - self.assertNotIn('BiasAdd', node['op']) - if node['op'] == graph_rewrite_util.FUSED_MATMUL: - fused_op = node - self.assertIsNot(fused_op, None) - self.assertIsNot(fused_op['attr']['transpose_a'], None) - self.assertIsNot(fused_op['attr']['transpose_b'], None) - self.assertEqual( - base64.b64decode(fused_op['attr']['fused_ops']['list']['s'][0]), - b'BiasAdd') - self.assertEqual( - base64.b64decode(fused_op['attr']['fused_ops']['list']['s'][1]), - b'Relu') - - # Check meta-data in the artifact JSON. - self.assertEqual(model_json['format'], 'graph-model') - self.assertEqual( - model_json['convertedBy'], - 'TensorFlow.js Converter v%s' % version.version) - self.assertEqual(model_json['generatedBy'], - tf.__version__) - self.assertTrue( - glob.glob( - os.path.join(self._tmp_dir, SAVED_MODEL_DIR, 'group*-*'))) - - def test_convert_saved_model_with_fused_depthwise_conv2d(self): - self._create_saved_model_with_fusable_depthwise_conv2d() - tf_saved_model_conversion_v2.convert_tf_saved_model( - os.path.join(self._tmp_dir, SAVED_MODEL_DIR), - os.path.join(self._tmp_dir, SAVED_MODEL_DIR) - ) - - tfjs_path = os.path.join(self._tmp_dir, SAVED_MODEL_DIR) - # Check model.json and weights manifest. - with open(os.path.join(tfjs_path, 'model.json'), 'rt') as f: - model_json = json.load(f) - self.assertTrue(model_json['modelTopology']) - self.assertIsNot(model_json['modelTopology']['versions'], None) - signature = model_json['signature'] - self.assertIsNot(signature, None) - self.assertIsNot(signature['inputs'], None) - self.assertIsNot(signature['outputs'], None) - - nodes = model_json['modelTopology']['node'] - - fused_op = None - for node in nodes: - self.assertNotIn('BatchNorm', node['op']) - self.assertNotIn('Relu', node['op']) - self.assertNotIn('BiasAdd', node['op']) - if node['op'] == graph_rewrite_util.FUSED_DEPTHWISE_CONV2D: - fused_op = node - self.assertIsNot(fused_op, None) - self.assertIsNot(fused_op['attr']['dilations'], None) - self.assertIsNot(fused_op['attr']['strides'], None) - self.assertEqual( - base64.b64decode(fused_op['attr']['fused_ops']['list']['s'][0]), - b'BiasAdd') - self.assertEqual( - base64.b64decode(fused_op['attr']['fused_ops']['list']['s'][1]), - b'Relu') - - # Check meta-data in the artifact JSON. - self.assertEqual(model_json['format'], 'graph-model') - self.assertEqual( - model_json['convertedBy'], - 'TensorFlow.js Converter v%s' % version.version) - self.assertEqual(model_json['generatedBy'], - tf.__version__) - self.assertTrue( - glob.glob( - os.path.join(self._tmp_dir, SAVED_MODEL_DIR, 'group*-*'))) - - def test_convert_saved_model_with_unfusable_addV2(self): - self._create_saved_model_with_unfusable_addV2() - tf_saved_model_conversion_v2.convert_tf_saved_model( - os.path.join(self._tmp_dir, SAVED_MODEL_DIR), - os.path.join(self._tmp_dir, SAVED_MODEL_DIR) - ) - - tfjs_path = os.path.join(self._tmp_dir, SAVED_MODEL_DIR) - # Check model.json and weights manifest. - with open(os.path.join(tfjs_path, 'model.json'), 'rt') as f: - model_json = json.load(f) - self.assertTrue(model_json['modelTopology']) - self.assertIsNot(model_json['modelTopology']['versions'], None) - signature = model_json['signature'] - self.assertIsNot(signature, None) - self.assertIsNot(signature['inputs'], None) - self.assertIsNot(signature['outputs'], None) - - nodes = model_json['modelTopology']['node'] - - # check if AddV2 op exists - addV2_op = None - for node in nodes: - if node['op'] == 'AddV2': - addV2_op = node - break - self.assertTrue(addV2_op) - - # Check meta-data in the artifact JSON. - self.assertEqual(model_json['format'], 'graph-model') - self.assertEqual( - model_json['convertedBy'], - 'TensorFlow.js Converter v%s' % version.version) - self.assertEqual(model_json['generatedBy'], - tf.__version__) - self.assertTrue( - glob.glob( - os.path.join(self._tmp_dir, SAVED_MODEL_DIR, 'group*-*'))) - - def test_convert_saved_model_with_fusable_addV2(self): - self._create_saved_model_with_fusable_addV2() - tf_saved_model_conversion_v2.convert_tf_saved_model( - os.path.join(self._tmp_dir, SAVED_MODEL_DIR), - os.path.join(self._tmp_dir, SAVED_MODEL_DIR) - ) - - tfjs_path = os.path.join(self._tmp_dir, SAVED_MODEL_DIR) - # Check model.json and weights manifest. - with open(os.path.join(tfjs_path, 'model.json'), 'rt') as f: - model_json = json.load(f) - self.assertTrue(model_json['modelTopology']) - self.assertIsNot(model_json['modelTopology']['versions'], None) - signature = model_json['signature'] - self.assertIsNot(signature, None) - self.assertIsNot(signature['inputs'], None) - self.assertIsNot(signature['outputs'], None) - - nodes = model_json['modelTopology']['node'] - - # Check if AddV2 is fused to Conv2D and Depthwise ops. - fused_conv2d_op = None - fused_depthwise_op = None - for node in nodes: - self.assertNotEqual('Conv2D', node['op']) - self.assertNotEqual('DepthwiseConv2dNative', node['op']) - self.assertNotEqual('AddV2', node['op']) - self.assertNotEqual('BiasAdd', node['op']) - if node['op'] == graph_rewrite_util.FUSED_CONV2D: - fused_conv2d_op = node - elif node['op'] == graph_rewrite_util.FUSED_DEPTHWISE_CONV2D: - fused_depthwise_op = node - self.assertIsNot(fused_conv2d_op, None) - self.assertIsNot(fused_depthwise_op, None) - fused_conv2d_ops = list(map(base64.b64decode, - fused_conv2d_op['attr']['fused_ops']['list']['s'])) - self.assertEqual(fused_conv2d_ops, [b'BiasAdd']) - self.assertEqual(fused_conv2d_op['attr']['num_args']['i'], '1') - fused_depthwise_ops = list( - map(base64.b64decode, - fused_depthwise_op['attr']['fused_ops']['list']['s'])) - self.assertEqual(fused_depthwise_ops, [b'BiasAdd']) - self.assertEqual(fused_depthwise_op['attr']['num_args']['i'], '1') - - # Check meta-data in the artifact JSON. - self.assertEqual(model_json['format'], 'graph-model') - self.assertEqual( - model_json['convertedBy'], - 'TensorFlow.js Converter v%s' % version.version) - self.assertEqual(model_json['generatedBy'], - tf.__version__) - self.assertTrue( - glob.glob( - os.path.join(self._tmp_dir, SAVED_MODEL_DIR, 'group*-*'))) - - def test_convert_saved_model_with_prelu(self): - self._create_saved_model_with_prelu() - tf_saved_model_conversion_v2.convert_tf_saved_model( - os.path.join(self._tmp_dir, SAVED_MODEL_DIR), - os.path.join(self._tmp_dir, SAVED_MODEL_DIR) - ) - - tfjs_path = os.path.join(self._tmp_dir, SAVED_MODEL_DIR) - # Check model.json and weights manifest. - with open(os.path.join(tfjs_path, 'model.json'), 'rt') as f: - model_json = json.load(f) - self.assertTrue(model_json['modelTopology']) - self.assertIsNot(model_json['modelTopology']['versions'], None) - signature = model_json['signature'] - self.assertIsNot(signature, None) - self.assertIsNot(signature['inputs'], None) - self.assertIsNot(signature['outputs'], None) - - nodes = model_json['modelTopology']['node'] - - prelu_op = None - fused_op = None - depthwise_fused_op = None - for node in nodes: - if node['op'] == 'Prelu': - prelu_op = node - if node['op'] == graph_rewrite_util.FUSED_CONV2D: - fused_op = node - if node['op'] == graph_rewrite_util.FUSED_DEPTHWISE_CONV2D: - depthwise_fused_op = node - self.assertTrue(prelu_op is None) - self.assertIsNot(fused_op, None) - self.assertIsNot(depthwise_fused_op, None) - - fused_ops = list(map(base64.b64decode, - fused_op['attr']['fused_ops']['list']['s'])) - self.assertEqual(fused_ops, [b'BiasAdd', b'Prelu']) - self.assertEqual(fused_op['attr']['num_args']['i'], '2') - depthwise_fused_ops = list( - map(base64.b64decode, - depthwise_fused_op['attr']['fused_ops']['list']['s'])) - self.assertEqual(depthwise_fused_ops, [b'BiasAdd', b'Prelu']) - self.assertEqual(depthwise_fused_op['attr']['num_args']['i'], '2') - # Check meta-data in the artifact JSON. - self.assertEqual(model_json['format'], 'graph-model') - self.assertEqual( - model_json['convertedBy'], - 'TensorFlow.js Converter v%s' % version.version) - self.assertEqual(model_json['generatedBy'], - tf.__version__) - self.assertTrue( - glob.glob( - os.path.join(self._tmp_dir, SAVED_MODEL_DIR, 'group*-*'))) - - def test_convert_saved_model_with_unfusable_prelu(self): - self._create_saved_model_with_unfusable_prelu() - tf_saved_model_conversion_v2.convert_tf_saved_model( - os.path.join(self._tmp_dir, SAVED_MODEL_DIR), - os.path.join(self._tmp_dir, SAVED_MODEL_DIR) - ) - - tfjs_path = os.path.join(self._tmp_dir, SAVED_MODEL_DIR) - # Check model.json and weights manifest. - with open(os.path.join(tfjs_path, 'model.json'), 'rt') as f: - model_json = json.load(f) - self.assertTrue(model_json['modelTopology']) - self.assertIsNot(model_json['modelTopology']['versions'], None) - signature = model_json['signature'] - self.assertIsNot(signature, None) - self.assertIsNot(signature['inputs'], None) - self.assertIsNot(signature['outputs'], None) - - nodes = model_json['modelTopology']['node'] - - prelu_op = None - for node in nodes: - if node['op'] == 'Prelu': - prelu_op = node - break - - self.assertTrue(prelu_op) - - # Check meta-data in the artifact JSON. - self.assertEqual(model_json['format'], 'graph-model') - self.assertEqual( - model_json['convertedBy'], - 'TensorFlow.js Converter v%s' % version.version) - self.assertEqual(model_json['generatedBy'], - tf.__version__) - self.assertTrue( - glob.glob( - os.path.join(self._tmp_dir, SAVED_MODEL_DIR, 'group*-*'))) - - def test_convert_saved_model_with_control_flow(self): - self._create_saved_model_with_control_flow() - - tf_saved_model_conversion_v2.convert_tf_saved_model( - os.path.join(self._tmp_dir, SAVED_MODEL_DIR), - os.path.join(self._tmp_dir, SAVED_MODEL_DIR) - ) - - tfjs_path = os.path.join(self._tmp_dir, SAVED_MODEL_DIR) - # Check model.json and weights manifest. - with open(os.path.join(tfjs_path, 'model.json'), 'rt') as f: - model_json = json.load(f) - self.assertTrue(model_json['modelTopology']) - self.assertIsNot(model_json['modelTopology']['versions'], None) - signature = model_json['signature'] - self.assertIsNot(signature, None) - self.assertIsNot(signature['inputs'], None) - self.assertIsNot(signature['outputs'], None) - - weights_manifest = model_json['weightsManifest'] - self.assertCountEqual(weights_manifest[0]['paths'], - ['group1-shard1of1.bin']) - self.assertIn('weights', weights_manifest[0]) - - # Check meta-data in the artifact JSON. - self.assertEqual(model_json['format'], 'graph-model') - self.assertEqual( - model_json['convertedBy'], - 'TensorFlow.js Converter v%s' % version.version) - self.assertEqual(model_json['generatedBy'], - tf.__version__) - self.assertTrue( - glob.glob( - os.path.join(self._tmp_dir, SAVED_MODEL_DIR, 'group*-*'))) - - def test_convert_saved_model_with_control_flow_v2(self): - self._create_saved_model_with_control_flow() - - tfjs_path = os.path.join(self._tmp_dir, SAVED_MODEL_DIR) - tf_saved_model_conversion_v2.convert_tf_saved_model( - tfjs_path, tfjs_path, control_flow_v2=True - ) - - # Check model.json and weights manifest. - with open(os.path.join(tfjs_path, 'model.json'), 'rt') as f: - model_json = json.load(f) - self.assertTrue(model_json['modelTopology']) - self.assertIsNot(model_json['modelTopology']['versions'], None) - signature = model_json['signature'] - self.assertIsNot(signature, None) - self.assertIsNot(signature['inputs'], None) - self.assertIsNot(signature['outputs'], None) - - weights_manifest = model_json['weightsManifest'] - self.assertCountEqual(weights_manifest[0]['paths'], - ['group1-shard1of1.bin']) - self.assertIn('weights', weights_manifest[0]) - - add_y_weight = None - for weight in weights_manifest[0]['weights']: - if 'add/y' in weight['name']: - add_y_weight = weight - - self.assertIsNot(add_y_weight, None) - self.assertFalse(add_y_weight['name'].startswith('add/y')) - - nodes = model_json['modelTopology']['node'] - - while_op = None - for node in nodes: - self.assertNotIn('Merge', node['op']) - self.assertNotIn('Switch', node['op']) - if node['op'] == 'StatelessWhile': - while_op = node - self.assertIsNot(while_op, None) - # Check meta-data in the artifact JSON. - self.assertEqual(model_json['format'], 'graph-model') - self.assertEqual( - model_json['convertedBy'], - 'TensorFlow.js Converter v%s' % version.version) - self.assertEqual(model_json['generatedBy'], - tf.__version__) - self.assertTrue( - glob.glob( - os.path.join(self._tmp_dir, SAVED_MODEL_DIR, 'group*-*'))) - - def test_convert_saved_model_with_tfdf(self): - self._create_saved_model_with_tfdf() - - tfjs_path = os.path.join(self._tmp_dir, SAVED_MODEL_DIR) - tf_saved_model_conversion_v2.convert_tf_saved_model( - tfjs_path, tfjs_path, skip_op_check=True - ) - - # Check model.json and weights manifest. - with open(os.path.join(tfjs_path, 'model.json'), 'rt') as f: - model_json = json.load(f) - - # Check TFDF ops are present. - model_ops = [node['op'] for node in model_json['modelTopology']['node']] - self.assertIn('SimpleMLInferenceOpWithHandle', model_ops) - - initializer_ops = [node['op'] for node in model_json['modelInitializer']['node']] - self.assertIn('SimpleMLCreateModelResource', initializer_ops) - self.assertIn('SimpleMLLoadModelFromPathWithHandle', initializer_ops) - - # Check assets containing TFDF files were copied over. - self.assertTrue( - os.path.exists( - os.path.join(tfjs_path, ASSETS_DIRECTORY_NAME + '.zip'))) - - def test_convert_saved_model_sharded(self): - self._create_saved_model() - model_path = os.path.join(self._tmp_dir, SAVED_MODEL_DIR) - tfjs_path = os.path.join(self._tmp_dir, SAVED_MODEL_DIR) - - # Do initial conversion without sharding. - tf_saved_model_conversion_v2.convert_tf_saved_model(model_path, tfjs_path) - weight_files = glob.glob(os.path.join(tfjs_path, 'group*.bin')) - - # Get size of weights in bytes after graph optimizations. - optimized_total_weight = sum([os.path.getsize(f) for f in weight_files]) - - # Due to the shard size, there ought to be 2 shards after conversion. - weight_shard_size_bytes = int(optimized_total_weight * 0.8) - - tfjs_path = os.path.join(self._tmp_dir, 'sharded_model') - # Convert Saved Model again with shard argument set. - tf_saved_model_conversion_v2.convert_tf_saved_model( - model_path, tfjs_path, - weight_shard_size_bytes=weight_shard_size_bytes) - - weight_files = sorted(glob.glob(os.path.join(tfjs_path, 'group*.bin'))) - self.assertEqual(len(weight_files), 2) - weight_file_sizes = [os.path.getsize(f) for f in weight_files] - - self.assertEqual(sum(weight_file_sizes), optimized_total_weight) - self.assertLess(weight_file_sizes[1], weight_file_sizes[0]) - - def test_optimizer_add_unsupported_op(self): - self._create_unsupported_saved_model() - with self.assertRaisesRegexp( # pylint: disable=deprecated-method - ValueError, r'^Unsupported Ops'): - tf_saved_model_conversion_v2.convert_tf_saved_model( - os.path.join(self._tmp_dir, SAVED_MODEL_DIR), - os.path.join(self._tmp_dir, SAVED_MODEL_DIR) - ) - - def test_convert_saved_model_skip_op_check(self): - self._create_unsupported_saved_model() - - tf_saved_model_conversion_v2.convert_tf_saved_model( - os.path.join(self._tmp_dir, SAVED_MODEL_DIR), - os.path.join(self._tmp_dir, SAVED_MODEL_DIR), skip_op_check=True - ) - - tfjs_path = os.path.join(self._tmp_dir, SAVED_MODEL_DIR) - # Check model.json and weights manifest. - with open(os.path.join(tfjs_path, 'model.json'), 'rt') as f: - model_json = json.load(f) - self.assertTrue(model_json['modelTopology']) - self.assertIsNot(model_json['modelTopology']['versions'], None) - signature = model_json['signature'] - self.assertIsNot(signature, None) - self.assertIsNot(signature['inputs'], None) - self.assertIsNot(signature['outputs'], None) - - weights_manifest = model_json['weightsManifest'] - self.assertCountEqual(weights_manifest[0]['paths'], - ['group1-shard1of1.bin']) - self.assertIn('weights', weights_manifest[0]) - self.assertTrue( - glob.glob( - os.path.join(self._tmp_dir, SAVED_MODEL_DIR, 'group*-*'))) - - # (TODO: piyu) disable this test, need to change - # convert_variables_to_constants_v2 to set function_optimization=aggressive. - @unittest.skip('not supported') - def test_convert_saved_model_strip_debug_ops(self): - self._create_saved_model_with_debug_ops() - - tf_saved_model_conversion_v2.convert_tf_saved_model( - os.path.join(self._tmp_dir, SAVED_MODEL_DIR), - os.path.join(self._tmp_dir, SAVED_MODEL_DIR), - strip_debug_ops=True) - - tfjs_path = os.path.join(self._tmp_dir, SAVED_MODEL_DIR) - # Check model.json and weights manifest. - with open(os.path.join(tfjs_path, 'model.json'), 'rt') as f: - model_json = json.load(f) - self.assertTrue(model_json['modelTopology']) - self.assertIsNot(model_json['modelTopology']['versions'], None) - signature = model_json['signature'] - self.assertIsNot(signature, None) - self.assertIsNot(signature['inputs'], None) - self.assertIsNot(signature['outputs'], None) - - weights_manifest = model_json['weightsManifest'] - self.assertCountEqual(weights_manifest[0]['paths'], - ['group1-shard1of1.bin']) - self.assertIn('weights', weights_manifest[0]) - self.assertTrue( - glob.glob( - os.path.join(self._tmp_dir, SAVED_MODEL_DIR, 'group*-*'))) - - def test_convert_saved_model_structured_outputs_true(self): - self._create_saved_model_with_structured_outputs() - - tf_saved_model_conversion_v2.convert_tf_saved_model( - os.path.join(self._tmp_dir, SAVED_MODEL_DIR), - os.path.join(self._tmp_dir, SAVED_MODEL_DIR), - use_structured_outputs_names=True) - - tfjs_path = os.path.join(self._tmp_dir, SAVED_MODEL_DIR) - # Check model.json and weights manifest. - with open(os.path.join(tfjs_path, 'model.json'), 'rt') as f: - model_json = json.load(f) - self.assertTrue(model_json['modelTopology']) - self.assertIsNot(model_json['modelTopology']['versions'], None) - signature = model_json['signature'] - self.assertIsNot(signature, None) - self.assertIsNot(signature['inputs'], None) - self.assertIsNot(signature['outputs'], None) - - self.assertEqual(["a", "b", "c"], - model_json['userDefinedMetadata']['structuredOutputKeys']) - - def test_convert_saved_model_structured_outputs_false(self): - self._create_saved_model_with_structured_outputs() - - tf_saved_model_conversion_v2.convert_tf_saved_model( - os.path.join(self._tmp_dir, SAVED_MODEL_DIR), - os.path.join(self._tmp_dir, SAVED_MODEL_DIR)) - - tfjs_path = os.path.join(self._tmp_dir, SAVED_MODEL_DIR) - # Check model.json and weights manifest. - with open(os.path.join(tfjs_path, 'model.json'), 'rt') as f: - model_json = json.load(f) - self.assertIs(model_json.get('userDefinedMetadata'), None) - - def test_convert_hub_module_v1(self): - self._create_hub_module() - module_path = os.path.join(self._tmp_dir, HUB_MODULE_DIR) - tfjs_path = os.path.join(self._tmp_dir, SAVED_MODEL_DIR) - - tf_saved_model_conversion_v2.convert_tf_hub_module(module_path, tfjs_path) - - # Check model.json and weights manifest. - with open(os.path.join(tfjs_path, 'model.json'), 'rt') as f: - model_json = json.load(f) - self.assertTrue(model_json['modelTopology']) - self.assertIsNot(model_json['modelTopology']['versions'], None) - signature = model_json['signature'] - self.assertIsNot(signature, None) - self.assertIsNot(signature['inputs'], None) - self.assertIsNot(signature['outputs'], None) - - weights_manifest = model_json['weightsManifest'] - self.assertCountEqual(weights_manifest[0]['paths'], - ['group1-shard1of1.bin']) - self.assertIn('weights', weights_manifest[0]) - - self.assertTrue( - glob.glob( - os.path.join(self._tmp_dir, SAVED_MODEL_DIR, 'group*-*'))) - - def test_convert_hub_module_v1_sharded(self): - self._create_hub_module() - module_path = os.path.join(self._tmp_dir, HUB_MODULE_DIR) - tfjs_path = os.path.join(self._tmp_dir, SAVED_MODEL_DIR) - - # Do initial conversion without sharding. - tf_saved_model_conversion_v2.convert_tf_hub_module(module_path, tfjs_path) - weight_files = glob.glob(os.path.join(tfjs_path, 'group*.bin')) - - # Get size of weights in bytes after graph optimizations. - optimized_total_weight = sum([os.path.getsize(f) for f in weight_files]) - - # Due to the shard size, there ought to be 3 shards after conversion. - weight_shard_size_bytes = int(optimized_total_weight * 0.4) - - tfjs_path = os.path.join(self._tmp_dir, 'sharded_model') - # Convert Hub model again with shard argument set. - tf_saved_model_conversion_v2.convert_tf_hub_module( - module_path, tfjs_path, - weight_shard_size_bytes=weight_shard_size_bytes) - - weight_files = sorted(glob.glob(os.path.join(tfjs_path, 'group*.bin'))) - self.assertEqual(len(weight_files), 3) - weight_file_sizes = [os.path.getsize(f) for f in weight_files] - - self.assertEqual(sum(weight_file_sizes), optimized_total_weight) - self.assertEqual(weight_file_sizes[0], weight_file_sizes[1]) - self.assertLess(weight_file_sizes[2], weight_file_sizes[0]) - - def test_convert_hub_module_v1_with_metadata(self): - self._create_hub_module() - module_path = os.path.join(self._tmp_dir, HUB_MODULE_DIR) - tfjs_path = os.path.join(self._tmp_dir, SAVED_MODEL_DIR) - - metadata_json = {'a': 1} - tf_saved_model_conversion_v2.convert_tf_hub_module( - module_path, tfjs_path, metadata={'key': metadata_json}) - - # Check model.json and weights manifest. - with open(os.path.join(tfjs_path, 'model.json'), 'rt') as f: - model_json = json.load(f) - self.assertEqual(metadata_json, model_json['userDefinedMetadata']['key']) - - def test_convert_hub_module_v2(self): - self._create_saved_model() - module_path = os.path.join(self._tmp_dir, SAVED_MODEL_DIR) - tfjs_path = os.path.join(self._tmp_dir, SAVED_MODEL_DIR) - - tf_saved_model_conversion_v2.convert_tf_hub_module( - module_path, tfjs_path, "serving_default", "serve") - - # Check model.json and weights manifest. - with open(os.path.join(tfjs_path, 'model.json'), 'rt') as f: - model_json = json.load(f) - self.assertTrue(model_json['modelTopology']) - self.assertIsNot(model_json['modelTopology']['versions'], None) - signature = model_json['signature'] - self.assertIsNot(signature, None) - self.assertIsNot(signature['inputs'], None) - self.assertIsNot(signature['outputs'], None) - - weights_manifest = model_json['weightsManifest'] - self.assertCountEqual(weights_manifest[0]['paths'], - ['group1-shard1of1.bin']) - self.assertIn('weights', weights_manifest[0]) - - self.assertTrue( - glob.glob( - os.path.join(self._tmp_dir, SAVED_MODEL_DIR, 'group*-*'))) - - def test_convert_hub_module_v2_with_metadata(self): - self._create_saved_model() - module_path = os.path.join(self._tmp_dir, SAVED_MODEL_DIR) - tfjs_path = os.path.join(self._tmp_dir, SAVED_MODEL_DIR) - - metadata_json = {'a': 1} - tf_saved_model_conversion_v2.convert_tf_hub_module( - module_path, tfjs_path, "serving_default", "serve", - metadata={'key': metadata_json}) - - # Check model.json and weights manifest. - with open(os.path.join(tfjs_path, 'model.json'), 'rt') as f: - model_json = json.load(f) - self.assertEqual(metadata_json, model_json['userDefinedMetadata']['key']) - - def test_convert_frozen_model(self): - self.create_frozen_model() - print(glob.glob( - os.path.join(self._tmp_dir, FROZEN_MODEL_DIR, '*'))) - - tf_saved_model_conversion_v2.convert_tf_frozen_model( - os.path.join(self._tmp_dir, FROZEN_MODEL_DIR, 'model.frozen'), - 'Softmax', - os.path.join(self._tmp_dir, FROZEN_MODEL_DIR)) - - tfjs_path = os.path.join(self._tmp_dir, FROZEN_MODEL_DIR) - # Check model.json and weights manifest. - with open(os.path.join(tfjs_path, 'model.json'), 'rt') as f: - model_json = json.load(f) - self.assertTrue(model_json['modelTopology']) - self.assertIsNot(model_json['modelTopology']['versions'], None) - signature = model_json['signature'] - self.assertIsNot(signature, None) - # frozen model signature has no input nodes. - self.assertIsNot(signature['outputs'], None) - - weights_manifest = model_json['weightsManifest'] - self.assertCountEqual(weights_manifest[0]['paths'], - ['group1-shard1of1.bin']) - self.assertIn('weights', weights_manifest[0]) - self.assertTrue( - glob.glob( - os.path.join(self._tmp_dir, FROZEN_MODEL_DIR, 'group*-*'))) - - def test_convert_frozen_model_with_metadata(self): - self.create_frozen_model() - print(glob.glob( - os.path.join(self._tmp_dir, FROZEN_MODEL_DIR, '*'))) - - metadata_json = {'a': 1} - tf_saved_model_conversion_v2.convert_tf_frozen_model( - os.path.join(self._tmp_dir, FROZEN_MODEL_DIR, 'model.frozen'), - 'Softmax', - os.path.join(self._tmp_dir, FROZEN_MODEL_DIR), - metadata={'key': metadata_json}) - - tfjs_path = os.path.join(self._tmp_dir, FROZEN_MODEL_DIR) - # Check model.json and weights manifest. - with open(os.path.join(tfjs_path, 'model.json'), 'rt') as f: - model_json = json.load(f) - self.assertEqual(metadata_json, model_json['userDefinedMetadata']['key']) - - def test_convert_keras_model_to_saved_model(self): - keras_model = tf.keras.Sequential( - [tf.keras.layers.Dense(1, input_shape=[2])]) - - tfjs_path = os.path.join(self._tmp_dir, SAVED_MODEL_DIR) - tf_saved_model_conversion_v2.convert_keras_model_to_graph_model( - keras_model, tfjs_path) - - # Check model.json and weights manifest. - with open(os.path.join(tfjs_path, 'model.json'), 'rt') as f: - model_json = json.load(f) - self.assertTrue(model_json['modelTopology']) - self.assertIsNot(model_json['modelTopology']['versions'], None) - signature = model_json['signature'] - self.assertIsNot(signature, None) - self.assertIsNot(signature['inputs'], None) - self.assertIsNot(signature['outputs'], None) - - weights_manifest = model_json['weightsManifest'] - self.assertCountEqual(weights_manifest[0]['paths'], - ['group1-shard1of1.bin']) - self.assertIn('weights', weights_manifest[0]) - self.assertTrue( - glob.glob( - os.path.join(self._tmp_dir, SAVED_MODEL_DIR, 'group*-*'))) - -if __name__ == '__main__': - tf.test.main() diff --git a/tfjs-master/tfjs-converter/python/tensorflowjs/converters/wizard.py b/tfjs-master/tfjs-converter/python/tensorflowjs/converters/wizard.py deleted file mode 100644 index 4a3767068..000000000 --- a/tfjs-master/tfjs-converter/python/tensorflowjs/converters/wizard.py +++ /dev/null @@ -1,658 +0,0 @@ -# Copyright 2019 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================== -"""Interactive command line tool for tensorflow.js model conversion.""" - -from __future__ import print_function, unicode_literals - -import json -import os -import re -import sys -import tempfile -import traceback - -try: - import PyInquirer -except ImportError: - sys.exit("""Please install PyInquirer using following command: - pip install PyInquirer==1.0.3""") - -import h5py -import tensorflow.compat.v2 as tf -from tensorflow.core.framework import types_pb2 -from tensorflow.python.saved_model import loader_impl -from tensorflowjs.converters import converter -from tensorflowjs.converters import common - -# regex for recognizing valid url for TFHub module. -TFHUB_VALID_URL_REGEX = re.compile( - # http:// or https:// - r'^(http)s?://', re.IGNORECASE) - -# prompt style -prompt_style = PyInquirer.style_from_dict({ - PyInquirer.Token.Separator: '#6C6C6C', - PyInquirer.Token.QuestionMark: '#FF9D00 bold', - PyInquirer.Token.Selected: '#5F819D', - PyInquirer.Token.Pointer: '#FF9D00 bold', - PyInquirer.Token.Instruction: '', # default - PyInquirer.Token.Answer: '#5F819D bold', - PyInquirer.Token.Question: '', -}) - - -def value_in_list(answers, key, values): - """Determine user's answer for the key is in the value list. - Args: - answer: Dict of user's answers to the questions. - key: question key. - values: List of values to check from. - """ - try: - value = answers[key] - return value in values - except KeyError: - return False - - -def get_tfjs_model_type(model_file): - with open(model_file) as f: - data = json.load(f) - print("====", data) - if 'format' in data: - return data['format'] - else: # Default to layers model - return common.TFJS_LAYERS_MODEL_FORMAT - - -def detect_saved_model(input_path): - if os.path.exists(os.path.join(input_path, 'assets', 'saved_model.json')): - return common.KERAS_SAVED_MODEL - saved_model = loader_impl.parse_saved_model(input_path) - graph_def = saved_model.meta_graphs[0].object_graph_def - if graph_def.nodes: - if 'tf_keras' in graph_def.nodes[0].user_object.identifier: - return common.KERAS_SAVED_MODEL - return common.TF_SAVED_MODEL - - -def detect_input_format(input_path): - """Determine the input format from model's input path or file. - Args: - input_path: string of the input model path - returns: - string: detected input format - string: normalized input path - """ - input_path = input_path.strip() - detected_input_format = None - if re.match(TFHUB_VALID_URL_REGEX, input_path): - detected_input_format = common.TF_HUB_MODEL - elif os.path.isdir(input_path): - if (any(fname.lower().endswith('saved_model.pb') - for fname in os.listdir(input_path))): - detected_input_format = detect_saved_model(input_path) - else: - for fname in os.listdir(input_path): - fname = fname.lower() - if fname.endswith('model.json'): - filename = os.path.join(input_path, fname) - if get_tfjs_model_type(filename) == common.TFJS_LAYERS_MODEL_FORMAT: - input_path = os.path.join(input_path, fname) - detected_input_format = common.TFJS_LAYERS_MODEL - break - elif os.path.isfile(input_path): - if h5py.is_hdf5(input_path): - detected_input_format = common.KERAS_MODEL - elif input_path.endswith('saved_model.pb'): - input_path = os.path.dirname(input_path) - detected_input_format = detect_saved_model(input_path) - elif (input_path.endswith('model.json') and - get_tfjs_model_type(input_path) == common.TFJS_LAYERS_MODEL_FORMAT): - detected_input_format = common.TFJS_LAYERS_MODEL - - return detected_input_format, input_path - - -def input_path_message(answers): - """Determine question for model's input path. - Args: - answer: Dict of user's answers to the questions - """ - answer = answers[common.INPUT_FORMAT] - message = 'The original path seems to be wrong, ' - if answer == common.KERAS_MODEL: - return message + 'what is the path of input HDF5 file?' - elif answer == common.TF_HUB_MODEL: - return message + ("what is the TFHub module URL? \n" - "(i.e. https://tfhub.dev/google/imagenet/" - "mobilenet_v1_100_224/classification/1)") - else: - return message + 'what is the directory that contains the model?' - - -def validate_input_path(input_path, input_format): - """Validate the input path for given input format. - Args: - input_path: input path of the model. - input_format: model format string. - """ - path = os.path.expanduser(input_path.strip()) - if not path: - return 'Please enter a valid path' - if input_format == common.TF_HUB_MODEL: - if not re.match(TFHUB_VALID_URL_REGEX, path): - return """This is not an valid URL for TFHub module: %s, - We expect a URL that starts with http(s)://""" % path - elif not os.path.exists(path): - return 'Nonexistent path for the model: %s' % path - if input_format in (common.KERAS_SAVED_MODEL, common.TF_SAVED_MODEL): - is_dir = os.path.isdir(path) - if not is_dir and not path.endswith('saved_model.pb'): - return 'The path provided is not a directory or pb file: %s' % path - if (is_dir and - not any(f.endswith('saved_model.pb') for f in os.listdir(path))): - return 'Did not find a .pb file inside the directory: %s' % path - if input_format == common.KERAS_SAVED_MODEL: - if detect_saved_model(input_path) != common.KERAS_SAVED_MODEL: - return 'This is a saved model but not a keras saved model: %s' % path - - if input_format == common.TFJS_LAYERS_MODEL: - is_dir = os.path.isdir(path) - if not is_dir and not path.endswith('model.json'): - return 'The path provided is not a directory or json file: %s' % path - if is_dir and not any(f.endswith('model.json') for f in os.listdir(path)): - return 'Did not find the model.json file inside the directory: %s' % path - if input_format == common.KERAS_MODEL: - if not h5py.is_hdf5(path): - return 'The path provided is not a keras model file: %s' % path - return True - - -def expand_input_path(input_path): - """Expand the relative input path to absolute path, and add layers model file - name to the end if input format is `tfjs_layers_model`. - Args: - input_path: input path of the model. - Returns: - string: return expanded input path. - """ - input_path = os.path.expanduser(input_path.strip()) - is_dir = os.path.isdir(input_path) - if is_dir: - for fname in os.listdir(input_path): - if fname.endswith('.json'): - filename = os.path.join(input_path, fname) - return filename - return input_path - - -def output_path_exists(output_path): - """Check the existence of the output path. - Args: - output_path: input path of the model. - Returns: - bool: return true when the output directory exists. - """ - if os.path.exists(output_path): - return True - return False - - -def generate_arguments(params): - """Generate the tensorflowjs command string for the selected params. - Args: - params: user selected parameters for the conversion. - Returns: - list: the argument list for converter. - """ - args = [] - not_param_list = [common.INPUT_PATH, common.OUTPUT_PATH, - 'overwrite_output_path', 'quantize'] - no_false_param = [common.SPLIT_WEIGHTS_BY_LAYER, common.SKIP_OP_CHECK] - for key, value in sorted(params.items()): - if key not in not_param_list and value is not None: - if key in no_false_param: - if value is True: - args.append('--%s' % (key)) - else: - args.append('--%s=%s' % (key, value)) - - args.append(params[common.INPUT_PATH]) - args.append(params[common.OUTPUT_PATH]) - return args - - -def is_saved_model(input_format): - """Check if the input path contains saved model. - Args: - input_format: input model format. - Returns: - bool: whether this is for a saved model conversion. - """ - return input_format == common.TF_SAVED_MODEL - -def available_output_formats(answers): - """Generate the output formats for given input format. - Args: - ansowers: user selected parameter dict. - """ - input_format = answers[common.INPUT_FORMAT] - if input_format == common.KERAS_MODEL: - return [{ - 'key': 'g', # shortcut key for the option - 'name': 'Tensorflow.js Graph Model', - 'value': common.TFJS_GRAPH_MODEL, - }, { - 'key': 'l', - 'name': 'TensoFlow.js Layers Model', - 'value': common.TFJS_LAYERS_MODEL, - }] - if input_format == common.TFJS_LAYERS_MODEL: - return [{ - 'key': 'k', # shortcut key for the option - 'name': 'Keras Model', - 'value': common.KERAS_MODEL, - }, { - 'key': 's', - 'name': 'Keras Saved Model', - 'value': common.KERAS_SAVED_MODEL, - }, { - 'key': 'l', - 'name': 'TensoFlow.js Layers Model', - 'value': common.TFJS_LAYERS_MODEL, - }] - return [] - - -def available_tags(answers): - """Generate the available saved model tags from the proto file. - Args: - ansowers: user selected parameter dict. - """ - if is_saved_model(answers[common.INPUT_FORMAT]): - saved_model = loader_impl.parse_saved_model(answers[common.INPUT_PATH]) - tags = [] - for meta_graph in saved_model.meta_graphs: - tags.append(",".join(meta_graph.meta_info_def.tags)) - return tags - return [] - - -def available_signature_names(answers): - """Generate the available saved model signatures from the proto file - and selected tags. - Args: - ansowers: user selected parameter dict. - """ - if (is_saved_model(answers[common.INPUT_FORMAT]) and - common.SAVED_MODEL_TAGS in answers): - path = answers[common.INPUT_PATH] - tags = answers[common.SAVED_MODEL_TAGS] - saved_model = loader_impl.parse_saved_model(path) - for meta_graph in saved_model.meta_graphs: - if tags == ",".join(meta_graph.meta_info_def.tags): - signatures = [] - for key in meta_graph.signature_def: - input_nodes = meta_graph.signature_def[key].inputs - output_nodes = meta_graph.signature_def[key].outputs - signatures.append( - {'value': key, - 'name': format_signature(key, input_nodes, output_nodes)}) - return signatures - return [] - - -def format_signature(name, input_nodes, output_nodes): - string = "signature name: %s\n" % name - string += " inputs: %s" % format_nodes(input_nodes) - string += " outputs: %s" % format_nodes(output_nodes) - return string - - -def format_nodes(nodes): - string = "%s of %s\n" % (3 if len(nodes) > 3 else len(nodes), len(nodes)) - count = 0 - for key in nodes: - value = nodes[key] - string += " name: %s, " % value.name - string += "dtype: %s, " % types_pb2.DataType.Name(value.dtype) - if value.tensor_shape.unknown_rank: - string += "shape: Unknown\n" - else: - string += "shape: %s\n" % [x.size for x in value.tensor_shape.dim] - count += 1 - if count >= 3: - break - return string - - -def input_format_string(base, target_format, detected_format): - if target_format == detected_format: - return base + ' *' - else: - return base - - -def input_format_message(detected_input_format): - message = 'What is your input model format? ' - if detected_input_format: - message += '(auto-detected format is marked with *)' - else: - message += '(model format cannot be detected.) ' - return message - -def update_output_path(output_path, params): - output_path = os.path.expanduser(output_path.strip()) - if (common.OUTPUT_FORMAT in params and - params[common.OUTPUT_FORMAT] == common.KERAS_MODEL): - if os.path.isdir(output_path): - output_path = os.path.join(output_path, 'model.H5') - return output_path - -def input_formats(detected_format): - formats = [{ - 'key': 'k', - 'name': input_format_string('Keras (HDF5)', common.KERAS_MODEL, - detected_format), - 'value': common.KERAS_MODEL - }, { - 'key': 'e', - 'name': input_format_string('Tensorflow Keras Saved Model', - common.KERAS_SAVED_MODEL, - detected_format), - 'value': common.KERAS_SAVED_MODEL, - }, { - 'key': 's', - 'name': input_format_string('Tensorflow Saved Model', - common.TF_SAVED_MODEL, - detected_format), - 'value': common.TF_SAVED_MODEL, - }, { - 'key': 'h', - 'name': input_format_string('TFHub Module', - common.TF_HUB_MODEL, - detected_format), - 'value': common.TF_HUB_MODEL, - }, { - 'key': 'l', - 'name': input_format_string('TensoFlow.js Layers Model', - common.TFJS_LAYERS_MODEL, - detected_format), - 'value': common.TFJS_LAYERS_MODEL, - }] - formats.sort(key=lambda x: x['value'] != detected_format) - return formats - - -def run(dryrun): - print('Welcome to TensorFlow.js Converter.') - input_path = [{ - 'type': 'input', - 'name': common.INPUT_PATH, - 'message': 'Please provide the path of model file or ' - 'the directory that contains model files. \n' - 'If you are converting TFHub module please provide the URL.', - 'filter': os.path.expanduser, - 'validate': - lambda path: 'Please enter a valid path' if not path else True - }] - - input_params = PyInquirer.prompt(input_path, style=prompt_style) - detected_input_format, normalized_path = detect_input_format( - input_params[common.INPUT_PATH]) - input_params[common.INPUT_PATH] = normalized_path - - formats = [ - { - 'type': 'list', - 'name': common.INPUT_FORMAT, - 'message': input_format_message(detected_input_format), - 'choices': input_formats(detected_input_format) - }, { - 'type': 'list', - 'name': common.OUTPUT_FORMAT, - 'message': 'What is your output format?', - 'choices': available_output_formats, - 'when': lambda answers: value_in_list(answers, common.INPUT_FORMAT, - (common.KERAS_MODEL, - common.TFJS_LAYERS_MODEL)) - } - ] - format_params = PyInquirer.prompt(formats, input_params, style=prompt_style) - message = input_path_message(format_params) - - questions = [ - { - 'type': 'input', - 'name': common.INPUT_PATH, - 'message': message, - 'filter': expand_input_path, - 'validate': lambda value: validate_input_path( - value, format_params[common.INPUT_FORMAT]), - 'when': lambda answers: (not detected_input_format) - }, - { - 'type': 'list', - 'name': common.SAVED_MODEL_TAGS, - 'choices': available_tags, - 'message': 'What is tags for the saved model?', - 'when': lambda answers: (is_saved_model(answers[common.INPUT_FORMAT]) - and - (common.OUTPUT_FORMAT not in format_params - or format_params[common.OUTPUT_FORMAT] == - common.TFJS_GRAPH_MODEL)) - }, - { - 'type': 'list', - 'name': common.SIGNATURE_NAME, - 'message': 'What is signature name of the model?', - 'choices': available_signature_names, - 'when': lambda answers: (is_saved_model(answers[common.INPUT_FORMAT]) - and - (common.OUTPUT_FORMAT not in format_params - or format_params[common.OUTPUT_FORMAT] == - common.TFJS_GRAPH_MODEL)) - }, - { - 'type': 'list', - 'name': 'quantize', - 'message': 'Do you want to compress the model? ' - '(this will decrease the model precision.)', - 'choices': [{ - 'name': 'No compression (Higher accuracy)', - 'value': None - }, { - 'name': 'float16 quantization ' - '(2x smaller, Minimal accuracy loss)', - 'value': 'float16' - }, { - 'name': 'uint16 affine quantization (2x smaller, Accuracy loss)', - 'value': 'uint16' - }, { - 'name': 'uint8 affine quantization (4x smaller, Accuracy loss)', - 'value': 'uint8' - }] - }, - { - 'type': 'input', - 'name': common.QUANTIZATION_TYPE_FLOAT16, - 'message': 'Please enter the layers to apply float16 quantization ' - '(2x smaller, minimal accuracy tradeoff).\n' - 'Supports wildcard expansion with *, e.g., conv/*/weights', - 'default': '*', - 'when': lambda answers: - value_in_list(answers, 'quantize', ('float16')) - }, - { - 'type': 'input', - 'name': common.QUANTIZATION_TYPE_UINT8, - 'message': 'Please enter the layers to apply affine 1-byte integer ' - 'quantization (4x smaller, accuracy tradeoff).\n' - 'Supports wildcard expansion with *, e.g., conv/*/weights', - 'default': '*', - 'when': lambda answers: - value_in_list(answers, 'quantize', ('uint8')) - }, - { - 'type': 'input', - 'name': common.QUANTIZATION_TYPE_UINT16, - 'message': 'Please enter the layers to apply affine 2-byte integer ' - 'quantization (2x smaller, accuracy tradeoff).\n' - 'Supports wildcard expansion with *, e.g., conv/*/weights', - 'default': '*', - 'when': lambda answers: - value_in_list(answers, 'quantize', ('uint16')) - }, - { - 'type': 'input', - 'name': common.WEIGHT_SHARD_SIZE_BYTES, - 'message': 'Please enter shard size (in bytes) of the weight files?', - 'default': str(4 * 1024 * 1024), - 'validate': - lambda size: ('Please enter a positive integer' if not - (size.isdigit() and int(size) > 0) else True), - 'when': lambda answers: (value_in_list(answers, common.OUTPUT_FORMAT, - (common.TFJS_LAYERS_MODEL, - common.TFJS_GRAPH_MODEL)) or - value_in_list(answers, common.INPUT_FORMAT, - (common.TF_SAVED_MODEL, - common.TF_HUB_MODEL))) - }, - { - 'type': 'confirm', - 'name': common.SPLIT_WEIGHTS_BY_LAYER, - 'message': 'Do you want to split weights by layers?', - 'default': False, - 'when': lambda answers: (value_in_list(answers, common.OUTPUT_FORMAT, - (common.TFJS_LAYERS_MODEL)) and - value_in_list(answers, common.INPUT_FORMAT, - (common.KERAS_MODEL, - common.KERAS_SAVED_MODEL))) - }, - { - 'type': 'confirm', - 'name': common.SKIP_OP_CHECK, - 'message': 'Do you want to skip op validation? \n' - 'This will allow conversion of unsupported ops, \n' - 'you can implement them as custom ops in tfjs-converter.', - 'default': False, - 'when': lambda answers: value_in_list(answers, common.INPUT_FORMAT, - (common.TF_SAVED_MODEL, - common.TF_HUB_MODEL)) - }, - { - 'type': 'confirm', - 'name': common.STRIP_DEBUG_OPS, - 'message': 'Do you want to strip debug ops? \n' - 'This will improve model execution performance.', - 'default': True, - 'when': lambda answers: value_in_list(answers, common.INPUT_FORMAT, - (common.TF_SAVED_MODEL, - common.TF_HUB_MODEL)) - }, - { - 'type': 'confirm', - 'name': common.CONTROL_FLOW_V2, - 'message': 'Do you want to enable Control Flow V2 ops? \n' - 'This will improve branch and loop execution performance.', - 'default': True, - 'when': lambda answers: value_in_list(answers, common.INPUT_FORMAT, - (common.TF_SAVED_MODEL, - common.TF_HUB_MODEL)) - }, - { - 'type': 'input', - 'name': common.METADATA, - 'message': 'Do you want to provide metadata? \n' - 'Provide your own metadata in the form: \n' - 'metadata_key:path/metadata.json \n' - 'Separate multiple metadata by comma.' - } - ] - params = PyInquirer.prompt(questions, format_params, style=prompt_style) - - output_options = [ - { - 'type': 'input', - 'name': common.OUTPUT_PATH, - 'message': 'Which directory do you want to save ' - 'the converted model in?', - 'filter': lambda path: update_output_path(path, params), - 'validate': lambda path: len(path) > 0 - }, - { - 'type': 'confirm', - 'message': 'The output already directory exists, ' - 'do you want to overwrite it?', - 'name': 'overwrite_output_path', - 'default': False, - 'when': lambda ans: output_path_exists(ans[common.OUTPUT_PATH]) - } - ] - - while (common.OUTPUT_PATH not in params or - output_path_exists(params[common.OUTPUT_PATH]) and - not params['overwrite_output_path']): - params = PyInquirer.prompt(output_options, params, style=prompt_style) - - arguments = generate_arguments(params) - print('converter command generated:') - print('tensorflowjs_converter %s' % ' '.join(arguments)) - print('\n\n') - - log_file = os.path.join(tempfile.gettempdir(), 'converter_error.log') - if not dryrun: - try: - converter.convert(arguments) - print('\n\nFile(s) generated by conversion:') - - print("Filename {0:25} Size(bytes)".format('')) - total_size = 0 - output_path = params[common.OUTPUT_PATH] - if os.path.isfile(output_path): - output_path = os.path.dirname(output_path) - for basename in sorted(os.listdir(output_path)): - filename = os.path.join(output_path, basename) - size = os.path.getsize(filename) - print("{0:35} {1}".format(basename, size)) - total_size += size - print("Total size:{0:24} {1}".format('', total_size)) - except BaseException: - exc_type, exc_value, exc_traceback = sys.exc_info() - lines = traceback.format_exception(exc_type, exc_value, exc_traceback) - with open(log_file, 'a') as writer: - writer.write(''.join(line for line in lines)) - print('Conversion failed, please check error log file %s.' % log_file) - -def pip_main(): - """Entry point for pip-packaged binary. - - Note that pip-packaged binary calls the entry method without - any arguments, which is why this method is needed in addition to the - `main` method below. - """ - main([' '.join(sys.argv[1:])]) - - -def main(argv): - if argv[0] and not argv[0] == '--dryrun': - print("Usage: tensorflowjs_wizard [--dryrun]") - sys.exit(1) - dry_run = argv[0] == '--dryrun' - run(dry_run) - -if __name__ == '__main__': - tf.app.run(main=main, argv=[' '.join(sys.argv[1:])]) diff --git a/tfjs-master/tfjs-converter/python/tensorflowjs/converters/wizard_test.py b/tfjs-master/tfjs-converter/python/tensorflowjs/converters/wizard_test.py deleted file mode 100644 index dce959230..000000000 --- a/tfjs-master/tfjs-converter/python/tensorflowjs/converters/wizard_test.py +++ /dev/null @@ -1,260 +0,0 @@ -# Copyright 2019 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================== -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -import unittest -import tempfile -import json -import os -import shutil -import tensorflow.compat.v2 as tf -from tensorflow.python.eager import def_function -from tensorflow.python.ops import variables -from tensorflow.python.trackable import autotrackable -from tensorflow.python.saved_model import save - -from tensorflowjs.converters import wizard - -SAVED_MODEL_DIR = 'saved_model' -SAVED_MODEL_NAME = 'saved_model.pb' -HD5_FILE_NAME = 'test.h5' -LAYERS_MODEL_NAME = 'model.json' - - -class CliTest(unittest.TestCase): - def setUp(self): - self._tmp_dir = tempfile.mkdtemp() - super(CliTest, self).setUp() - - def tearDown(self): - if os.path.isdir(self._tmp_dir): - shutil.rmtree(self._tmp_dir) - super(CliTest, self).tearDown() - - def _create_layers_model(self): - data = {'format': 'layers-model'} - filename = os.path.join(self._tmp_dir, 'model.json') - with open(filename, 'a') as model_file: - json.dump(data, model_file) - - def _create_hd5_file(self): - input_tensor = tf.keras.layers.Input((3,)) - dense1 = tf.keras.layers.Dense( - 4, use_bias=True, kernel_initializer='ones', bias_initializer='zeros', - name='MyDense10')(input_tensor) - output = tf.keras.layers.Dense( - 2, use_bias=False, kernel_initializer='ones', name='MyDense20')(dense1) - model = tf.keras.models.Model(inputs=[input_tensor], outputs=[output]) - h5_path = os.path.join(self._tmp_dir, HD5_FILE_NAME) - print(h5_path) - model.save_weights(h5_path) - - def _create_keras_saved_model(self): - model = tf.keras.Sequential() - model.add(tf.keras.layers.Reshape([2, 3], input_shape=[6])) - model.add(tf.keras.layers.LSTM(10)) - model.add(tf.keras.layers.Dense(1, activation='sigmoid')) - save_dir = os.path.join(self._tmp_dir, SAVED_MODEL_DIR) - tf.keras.models.save_model(model, save_dir) - - def _create_saved_model(self): - """Test a basic model with functions to make sure functions are inlined.""" - input_data = tf.constant(1., shape=[1]) - root = autotrackable.AutoTrackable() - root.v1 = variables.Variable(3.) - root.v2 = variables.Variable(2.) - root.f = def_function.function(lambda x: root.v1 * root.v2 * x) - to_save = root.f.get_concrete_function(input_data) - - save_dir = os.path.join(self._tmp_dir, SAVED_MODEL_DIR) - save.save(root, save_dir, to_save) - - def testOfValues(self): - answers = {'input_path': 'abc', 'input_format': '123'} - self.assertEqual(True, wizard.value_in_list(answers, 'input_path', ['abc'])) - self.assertEqual(False, wizard.value_in_list(answers, - 'input_path', ['abd'])) - self.assertEqual(False, wizard.value_in_list(answers, - 'input_format2', ['abc'])) - - def testInputPathMessage(self): - answers = {'input_format': 'keras'} - self.assertEqual("The original path seems to be wrong, " - "what is the path of input HDF5 file?", - wizard.input_path_message(answers)) - - answers = {'input_format': 'tf_hub'} - self.assertEqual("The original path seems to be wrong, " - "what is the TFHub module URL? \n" - "(i.e. https://tfhub.dev/google/imagenet/" - "mobilenet_v1_100_224/classification/1)", - wizard.input_path_message(answers)) - - answers = {'input_format': 'tf_saved_model'} - self.assertEqual("The original path seems to be wrong, " - "what is the directory that contains the model?", - wizard.input_path_message(answers)) - - def testValidateInputPathForTFHub(self): - self.assertNotEqual(True, - wizard.validate_input_path(self._tmp_dir, 'tf_hub')) - self.assertEqual(True, - wizard.validate_input_path("https://tfhub.dev/mobilenet", - 'tf_hub')) - - def testValidateInputPathForSavedModel(self): - self.assertNotEqual(True, wizard.validate_input_path( - self._tmp_dir, 'tf_saved_model')) - self._create_saved_model() - save_dir = os.path.join(self._tmp_dir, SAVED_MODEL_DIR) - self.assertEqual(True, wizard.validate_input_path( - save_dir, 'tf_saved_model')) - - save_dir = os.path.join(self._tmp_dir, SAVED_MODEL_DIR, SAVED_MODEL_NAME) - self.assertEqual(True, wizard.validate_input_path( - save_dir, 'tf_saved_model')) - - def testValidateInputPathForKerasSavedModel(self): - self.assertNotEqual(True, wizard.validate_input_path( - self._tmp_dir, 'keras_saved_model')) - self._create_keras_saved_model() - save_dir = os.path.join(self._tmp_dir, SAVED_MODEL_DIR) - self.assertEqual(True, wizard.validate_input_path( - save_dir, 'keras_saved_model')) - - def testValidateInputPathForKerasModel(self): - self.assertNotEqual(True, - wizard.validate_input_path(self._tmp_dir, 'keras')) - self._create_hd5_file() - save_dir = os.path.join(self._tmp_dir, HD5_FILE_NAME) - self.assertEqual(True, wizard.validate_input_path( - save_dir, 'keras')) - - def testValidateInputPathForLayersModel(self): - self.assertNotEqual(True, - wizard.validate_input_path(self._tmp_dir, 'keras')) - self._create_layers_model() - save_dir = os.path.join(self._tmp_dir) - self.assertEqual(True, wizard.validate_input_path( - save_dir, 'tfjs_layers_model')) - - save_dir = os.path.join(self._tmp_dir, 'model.json') - self.assertEqual(True, wizard.validate_input_path( - save_dir, 'tfjs_layers_model')) - - def testOutputPathExist(self): - self.assertEqual(True, wizard.output_path_exists(self._tmp_dir)) - output_dir = os.path.join(self._tmp_dir, 'test') - self.assertNotEqual(True, wizard.output_path_exists(output_dir)) - - def testAvailableTags(self): - self._create_saved_model() - save_dir = os.path.join(self._tmp_dir, SAVED_MODEL_DIR) - self.assertEqual(['serve'], wizard.available_tags( - {'input_path': save_dir, - 'input_format': 'tf_saved_model'})) - - def testAvailableSignatureNames(self): - self._create_saved_model() - save_dir = os.path.join(self._tmp_dir, SAVED_MODEL_DIR) - self.assertEqual(sorted(['__saved_model_init_op', 'serving_default']), - sorted( - [x['value'] for x in wizard.available_signature_names( - {'input_path': save_dir, - 'input_format': 'tf_saved_model', - 'saved_model_tags': 'serve'})])) - - def testGenerateCommandForSavedModel(self): - options = {'input_format': 'tf_saved_model', - 'input_path': 'tmp/saved_model', - 'saved_model_tags': 'test', - 'signature_name': 'test_default', - 'quantize_float16': 'conv/*/weights', - 'weight_shard_size_bytes': '4194304', - 'skip_op_check': False, - 'strip_debug_ops': True, - 'control_flow_v2': True, - 'metadata': 'metadata_key:metadata.json', - 'output_path': 'tmp/web_model'} - - self.assertEqual(['--control_flow_v2=True', - '--input_format=tf_saved_model', - '--metadata=metadata_key:metadata.json', - '--quantize_float16=conv/*/weights', - '--saved_model_tags=test', - '--signature_name=test_default', - '--strip_debug_ops=True', - '--weight_shard_size_bytes=4194304', - 'tmp/saved_model', 'tmp/web_model'], - wizard.generate_arguments(options)) - - def testGenerateCommandForKerasSavedModel(self): - options = {'input_format': 'tf_keras_saved_model', - 'output_format': 'tfjs_layers_model', - 'input_path': 'tmp/saved_model', - 'saved_model_tags': 'test', - 'signature_name': 'test_default', - 'weight_shard_size_bytes': '100', - 'quantize_float16': 'conv/*/weights', - 'skip_op_check': True, - 'strip_debug_ops': False, - 'control_flow_v2': False, - 'output_path': 'tmp/web_model'} - - self.assertEqual(['--control_flow_v2=False', - '--input_format=tf_keras_saved_model', - '--output_format=tfjs_layers_model', - '--quantize_float16=conv/*/weights', - '--saved_model_tags=test', - '--signature_name=test_default', '--skip_op_check', - '--strip_debug_ops=False', - '--weight_shard_size_bytes=100', - 'tmp/saved_model', 'tmp/web_model'], - wizard.generate_arguments(options)) - - def testGenerateCommandForKerasModel(self): - options = {'input_format': 'keras', - 'input_path': 'tmp/model.HD5', - 'weight_shard_size_bytes': '100', - 'quantize_uint16': 'conv/*/weights', - 'output_path': 'tmp/web_model'} - - self.assertEqual(['--input_format=keras', - '--quantize_uint16=conv/*/weights', - '--weight_shard_size_bytes=100', - 'tmp/model.HD5', 'tmp/web_model'], - wizard.generate_arguments(options)) - - def testGenerateCommandForLayerModel(self): - options = {'input_format': 'tfjs_layers_model', - 'output_format': 'keras', - 'input_path': 'tmp/model.json', - 'quantize_uint8': 'conv/*/weights', - 'weight_shard_size_bytes': '100', - 'output_path': 'tmp/web_model'} - - self.assertEqual(['--input_format=tfjs_layers_model', - '--output_format=keras', - '--quantize_uint8=conv/*/weights', - '--weight_shard_size_bytes=100', - 'tmp/model.json', - 'tmp/web_model'], - wizard.generate_arguments(options)) - - -if __name__ == '__main__': - unittest.main() diff --git a/tfjs-master/tfjs-converter/python/tensorflowjs/op_list/BUILD.bazel b/tfjs-master/tfjs-converter/python/tensorflowjs/op_list/BUILD.bazel deleted file mode 100644 index 41805d22a..000000000 --- a/tfjs-master/tfjs-converter/python/tensorflowjs/op_list/BUILD.bazel +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright 2021 Google LLC. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================= - -package( - licenses = ["notice"], # Apache 2.0 -) - -filegroup( - name = "ops", - srcs = glob(["*.json"]), - visibility = ["//visibility:public"], -) diff --git a/tfjs-master/tfjs-converter/python/tensorflowjs/op_list/arithmetic.json b/tfjs-master/tfjs-converter/python/tensorflowjs/op_list/arithmetic.json deleted file mode 100644 index a87d8425f..000000000 --- a/tfjs-master/tfjs-converter/python/tensorflowjs/op_list/arithmetic.json +++ /dev/null @@ -1,380 +0,0 @@ -[ - { - "tfOpName": "Add", - "category": "arithmetic", - "inputs": [ - { - "start": 0, - "name": "a", - "type": "tensor" - }, - { - "start": 1, - "name": "b", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "AddV2", - "category": "arithmetic", - "inputs": [ - { - "start": 0, - "name": "a", - "type": "tensor" - }, - { - "start": 1, - "name": "b", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "AddN", - "category": "arithmetic", - "inputs": [ - { - "start": 0, - "end": 0, - "name": "tensors", - "type": "tensors" - } - ] - }, - { - "tfOpName": "BiasAdd", - "category": "arithmetic", - "inputs": [ - { - "start": 0, - "name": "a", - "type": "tensor" - }, - { - "start": 1, - "name": "b", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - }, - { - "tfName": "data_format", - "name": "dataFormat", - "type": "string", - "notSupported": true - } - ] - }, - { - "tfOpName": "Sub", - "category": "arithmetic", - "inputs": [ - { - "start": 0, - "name": "a", - "type": "tensor" - }, - { - "start": 1, - "name": "b", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "RealDiv", - "category": "arithmetic", - "inputs": [ - { - "start": 0, - "name": "a", - "type": "tensor" - }, - { - "start": 1, - "name": "b", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "Div", - "category": "arithmetic", - "inputs": [ - { - "start": 0, - "name": "a", - "type": "tensor" - }, - { - "start": 1, - "name": "b", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "DivNoNan", - "category": "arithmetic", - "inputs": [ - { - "start": 0, - "name": "a", - "type": "tensor" - }, - { - "start": 1, - "name": "b", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "FloorDiv", - "category": "arithmetic", - "inputs": [ - { - "start": 0, - "name": "a", - "type": "tensor" - }, - { - "start": 1, - "name": "b", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "Mul", - "category": "arithmetic", - "inputs": [ - { - "start": 0, - "name": "a", - "type": "tensor" - }, - { - "start": 1, - "name": "b", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "Maximum", - "category": "arithmetic", - "inputs": [ - { - "start": 0, - "name": "a", - "type": "tensor" - }, - { - "start": 1, - "name": "b", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "Minimum", - "category": "arithmetic", - "inputs": [ - { - "start": 0, - "name": "a", - "type": "tensor" - }, - { - "start": 1, - "name": "b", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "Pow", - "category": "arithmetic", - "inputs": [ - { - "start": 0, - "name": "a", - "type": "tensor" - }, - { - "start": 1, - "name": "b", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "SquaredDifference", - "category": "arithmetic", - "inputs": [ - { - "start": 0, - "name": "a", - "type": "tensor" - }, - { - "start": 1, - "name": "b", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "Mod", - "category": "arithmetic", - "inputs": [ - { - "start": 0, - "name": "a", - "type": "tensor" - }, - { - "start": 1, - "name": "b", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "FloorMod", - "category": "arithmetic", - "inputs": [ - { - "start": 0, - "name": "a", - "type": "tensor" - }, - { - "start": 1, - "name": "b", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - } -] \ No newline at end of file diff --git a/tfjs-master/tfjs-converter/python/tensorflowjs/op_list/basic_math.json b/tfjs-master/tfjs-converter/python/tensorflowjs/op_list/basic_math.json deleted file mode 100644 index d63b255c6..000000000 --- a/tfjs-master/tfjs-converter/python/tensorflowjs/op_list/basic_math.json +++ /dev/null @@ -1,881 +0,0 @@ -[ - { - "tfOpName": "Abs", - "category": "basic_math", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "Acos", - "category": "basic_math", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "Asin", - "category": "basic_math", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "Atan", - "category": "basic_math", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "Atan2", - "category": "basic_math", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - }, - { - "start": 1, - "name": "y", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "Ceil", - "category": "basic_math", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "ClipByValue", - "category": "basic_math", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - }, - { - "start": 1, - "name": "clipValueMin", - "type": "number" - }, - { - "start": 2, - "name": "clipValueMax", - "type": "number" - } - ], - "attrs": [ - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "Complex", - "category": "basic_math", - "inputs": [ - { - "start": 0, - "name": "real", - "type": "tensor" - }, - { - "start": 1, - "name": "imag", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "ComplexAbs", - "category": "basic_math", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "Cos", - "category": "basic_math", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "Cosh", - "category": "basic_math", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "Elu", - "category": "basic_math", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "Exp", - "category": "basic_math", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "Floor", - "category": "basic_math", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "Log", - "category": "basic_math", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "Imag", - "category": "basic_math", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - }, - { - "tfName": "Tout", - "name": "outputType", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "Neg", - "category": "basic_math", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "Real", - "category": "basic_math", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - }, - { - "tfName": "Tout", - "name": "outputType", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "Prelu", - "category": "basic_math", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - }, - { - "start": 1, - "name": "alpha", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "Relu", - "category": "basic_math", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "Relu6", - "category": "basic_math", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "Selu", - "category": "basic_math", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "Sigmoid", - "category": "basic_math", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "Sin", - "category": "basic_math", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "Sinh", - "category": "basic_math", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "Sqrt", - "category": "basic_math", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "Rsqrt", - "category": "basic_math", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "Square", - "category": "basic_math", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "Tan", - "category": "basic_math", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "Tanh", - "category": "basic_math", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "Sign", - "category": "basic_math", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "Round", - "category": "basic_math", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "Expm1", - "category": "basic_math", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "Log1p", - "category": "basic_math", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "Reciprocal", - "category": "basic_math", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "Softplus", - "category": "basic_math", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "Asinh", - "category": "basic_math", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "Acosh", - "category": "basic_math", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "Atanh", - "category": "basic_math", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "Erf", - "category": "basic_math", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "LeakyRelu", - "category": "basic_math", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "alpha", - "name": "alpha", - "type": "number", - "defaultValue": 0.2 - }, - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "IsNan", - "category": "basic_math", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "IsFinite", - "category": "basic_math", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "IsInf", - "category": "basic_math", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - } -] diff --git a/tfjs-master/tfjs-converter/python/tensorflowjs/op_list/control.json b/tfjs-master/tfjs-converter/python/tensorflowjs/op_list/control.json deleted file mode 100644 index ef5f531af..000000000 --- a/tfjs-master/tfjs-converter/python/tensorflowjs/op_list/control.json +++ /dev/null @@ -1,864 +0,0 @@ -[ - { - "tfOpName": "EmptyTensorList", - "category": "control", - "inputs": [ - { - "start": 0, - "name": "elementShape", - "type": "shape" - }, - { - "start": 1, - "name": "maxNumElements", - "type": "number" - } - ], - "attrs": [ - { - "tfName": "element_dtype", - "name": "elementDType", - "type": "dtype" - } - ] - }, - { - "tfOpName": "LoopCond", - "category": "control", - "inputs": [ - { - "start": 0, - "name": "pred", - "type": "tensor" - } - ] - }, - { - "tfOpName": "Switch", - "category": "control", - "inputs": [ - { - "start": 0, - "name": "data", - "type": "tensor" - }, - { - "start": 1, - "name": "pred", - "type": "tensor" - } - ] - }, - { - "tfOpName": "Merge", - "category": "control", - "inputs": [ - { - "start": 0, - "end": 0, - "name": "tensors", - "type": "tensors" - } - ] - }, - { - "tfOpName": "Enter", - "category": "control", - "inputs": [ - { - "start": 0, - "name": "tensor", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - }, - { - "tfName": "frame_name", - "name": "frameName", - "type": "string" - }, - { - "tfName": "is_constant", - "name": "isConstant", - "type": "bool" - } - ] - }, - { - "tfOpName": "Exit", - "category": "control", - "inputs": [ - { - "start": 0, - "name": "tensor", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "NextIteration", - "category": "control", - "inputs": [ - { - "start": 0, - "name": "tensor", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "TensorArrayV3", - "category": "control", - "inputs": [ - { - "start": 0, - "name": "size", - "type": "number" - } - ], - "attrs": [ - { - "tfName": "dtype", - "name": "dtype", - "type": "dtype" - }, - { - "tfName": "element_shape", - "name": "elementShape", - "type": "shape" - }, - { - "tfName": "dynamic_size", - "name": "dynamicSize", - "type": "bool" - }, - { - "tfName": "clear_after_read", - "name": "clearAfterRead", - "type": "bool" - }, - { - "tfName": "identical_element_shapes", - "name": "identicalElementShapes", - "type": "bool" - }, - { - "tfName": "tensor_array_name", - "name": "name", - "type": "string" - } - ] - }, - { - "tfOpName": "TensorArrayWriteV3", - "category": "control", - "inputs": [ - { - "start": 0, - "name": "tensorArrayId", - "type": "tensor" - }, - { - "start": 1, - "name": "index", - "type": "number" - }, - { - "start": 2, - "name": "tensor", - "type": "tensor" - }, - { - "start": 3, - "name": "flowIn", - "type": "number" - } - ], - "attrs": [ - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "TensorArrayReadV3", - "category": "control", - "inputs": [ - { - "start": 0, - "name": "tensorArrayId", - "type": "tensor" - }, - { - "start": 1, - "name": "index", - "type": "number" - }, - { - "start": 2, - "name": "flowIn", - "type": "number" - } - ], - "attrs": [ - { - "tfName": "dtype", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "TensorArrayGatherV3", - "category": "control", - "inputs": [ - { - "start": 0, - "name": "tensorArrayId", - "type": "tensor" - }, - { - "start": 1, - "name": "indices", - "type": "number[]" - }, - { - "start": 2, - "name": "flowIn", - "type": "number" - } - ], - "attrs": [ - { - "tfName": "dtype", - "name": "dtype", - "type": "dtype" - }, - { - "tfName": "element_shape", - "name": "elementShape", - "type": "shape" - } - ] - }, - { - "tfOpName": "TensorArrayScatterV3", - "category": "control", - "inputs": [ - { - "start": 0, - "name": "tensorArrayId", - "type": "tensor" - }, - { - "start": 1, - "name": "indices", - "type": "number[]" - }, - { - "start": 2, - "name": "tensor", - "type": "tensor" - }, - { - "start": 3, - "name": "flowIn", - "type": "number" - } - ], - "attrs": [ - { - "tfName": "T", - "name": "dtype", - "type": "dtype" - } - ] - }, - { - "tfOpName": "TensorArrayConcatV3", - "category": "control", - "inputs": [ - { - "start": 0, - "name": "tensorArrayId", - "type": "tensor" - }, - { - "start": 1, - "name": "flowIn", - "type": "number" - } - ], - "attrs": [ - { - "tfName": "dtype", - "name": "dtype", - "type": "dtype" - }, - { - "tfName": "element_shape_except0", - "name": "elementShapeExcept0", - "type": "shape", - "notSupported": true - } - ] - }, - { - "tfOpName": "TensorArraySplitV3", - "category": "control", - "inputs": [ - { - "start": 0, - "name": "tensorArrayId", - "type": "tensor" - }, - { - "start": 1, - "name": "tensor", - "type": "tensor" - }, - { - "start": 2, - "name": "lengths", - "type": "number[]" - }, - { - "start": 3, - "name": "flowIn", - "type": "number" - } - ], - "attrs": [ - { - "tfName": "T", - "name": "dtype", - "type": "dtype" - } - ] - }, - { - "tfOpName": "TensorArraySizeV3", - "category": "control", - "inputs": [ - { - "start": 0, - "name": "tensorArrayId", - "type": "tensor" - }, - { - "start": 1, - "name": "flowIn", - "type": "number" - } - ] - }, - { - "tfOpName": "TensorArrayCloseV3", - "category": "control", - "inputs": [ - { - "start": 0, - "name": "tensorArrayId", - "type": "tensor" - } - ] - }, - { - "tfOpName": "StatelessIf", - "category": "control", - "inputs": [ - { - "start": 0, - "name": "cond", - "type": "tensor" - }, - { - "start": 1, - "end": 0, - "name": "args", - "type": "tensors" - } - ], - "attrs": [ - { - "tfName": "then_branch", - "name": "thenBranch", - "type": "func" - }, - { - "tfName": "else_branch", - "name": "elseBranch", - "type": "func" - } - ] - }, - { - "tfOpName": "If", - "category": "control", - "inputs": [ - { - "start": 0, - "name": "cond", - "type": "tensor" - }, - { - "start": 1, - "end": 0, - "name": "args", - "type": "tensors" - } - ], - "attrs": [ - { - "tfName": "then_branch", - "name": "thenBranch", - "type": "func" - }, - { - "tfName": "else_branch", - "name": "elseBranch", - "type": "func" - } - ] - }, - { - "tfOpName": "StatelessWhile", - "category": "control", - "inputs": [ - { - "start": 0, - "end": 0, - "name": "args", - "type": "tensors" - } - ], - "attrs": [ - { - "tfName": "cond", - "name": "cond", - "type": "func" - }, - { - "tfName": "body", - "name": "body", - "type": "func" - } - ] - }, - { - "tfOpName": "While", - "category": "control", - "inputs": [ - { - "start": 0, - "end": 0, - "name": "args", - "type": "tensors" - } - ], - "attrs": [ - { - "tfName": "cond", - "name": "cond", - "type": "func" - }, - { - "tfName": "body", - "name": "body", - "type": "func" - } - ] - }, - { - "tfOpName": "TensorListScatter", - "category": "control", - "inputs": [ - { - "start": 0, - "name": "tensor", - "type": "tensor" - }, - { - "start": 1, - "name": "indices", - "type": "number[]" - }, - { - "start": 2, - "name": "elementShape", - "type": "shape" - } - ], - "attrs": [ - { - "tfName": "element_dtype", - "name": "elementDType", - "type": "dtype" - } - ] - }, - { - "tfOpName": "TensorListScatterV2", - "category": "control", - "inputs": [ - { - "start": 0, - "name": "tensor", - "type": "tensor" - }, - { - "start": 1, - "name": "indices", - "type": "number[]" - }, - { - "start": 2, - "name": "elementShape", - "type": "shape" - }, - { - "start": 3, - "name": "numElements", - "type": "number" - } - ], - "attrs": [ - { - "tfName": "element_dtype", - "name": "elementDType", - "type": "dtype" - } - ] - }, - { - "tfOpName": "TensorListGather", - "category": "control", - "inputs": [ - { - "start": 0, - "name": "tensorListId", - "type": "tensor" - }, - { - "start": 1, - "name": "indices", - "type": "number[]" - }, - { - "start": 2, - "name": "elementShape", - "type": "shape" - } - ], - "attrs": [ - { - "tfName": "element_dtype", - "name": "elementDType", - "type": "dtype" - } - ] - }, - { - "tfOpName": "TensorListGetItem", - "category": "control", - "inputs": [ - { - "start": 0, - "name": "tensorListId", - "type": "tensor" - }, - { - "start": 1, - "name": "index", - "type": "number" - }, - { - "start": 2, - "name": "elementShape", - "type": "shape" - } - ], - "attrs": [ - { - "tfName": "element_dtype", - "name": "elementDType", - "type": "dtype" - } - ] - }, - { - "tfOpName": "TensorListSetItem", - "category": "control", - "inputs": [ - { - "start": 0, - "name": "tensorListId", - "type": "tensor" - }, - { - "start": 1, - "name": "index", - "type": "number" - }, - { - "start": 2, - "name": "tensor", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "element_dtype", - "name": "elementDType", - "type": "dtype" - } - ] - }, - { - "tfOpName": "TensorListReserve", - "category": "control", - "inputs": [ - { - "start": 0, - "name": "elementShape", - "type": "shape" - }, - { - "start": 1, - "name": "numElements", - "type": "number" - } - ], - "attrs": [ - { - "tfName": "element_dtype", - "name": "elementDType", - "type": "dtype" - } - ] - }, - { - "tfOpName": "TensorListFromTensor", - "category": "control", - "inputs": [ - { - "start": 0, - "name": "tensor", - "type": "tensor" - }, - { - "start": 1, - "name": "elementShape", - "type": "shape" - } - ], - "attrs": [ - { - "tfName": "element_dtype", - "name": "elementDType", - "type": "dtype" - } - ] - }, - { - "tfOpName": "TensorListStack", - "category": "control", - "inputs": [ - { - "start": 0, - "name": "tensorListId", - "type": "tensor" - }, - { - "start": 1, - "name": "elementShape", - "type": "shape" - } - ], - "attrs": [ - { - "tfName": "element_dtype", - "name": "elementDType", - "type": "dtype" - }, - { - "tfName": "num_elements", - "name": "numElements", - "type": "dtype" - } - ] - }, - { - "tfOpName": "TensorListSplit", - "category": "control", - "inputs": [ - { - "start": 0, - "name": "tensor", - "type": "tensor" - }, - { - "start": 1, - "name": "elementShape", - "type": "shape" - }, - { - "start": 2, - "name": "lengths", - "type": "number[]" - } - ], - "attrs": [ - { - "tfName": "element_dtype", - "name": "elementDType", - "type": "dtype" - } - ] - }, - { - "tfOpName": "TensorListConcat", - "category": "control", - "inputs": [ - { - "start": 0, - "name": "tensorListId", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "element_shape", - "name": "elementShape", - "type": "shape" - }, - { - "tfName": "element_dtype", - "name": "elementDType", - "type": "dtype" - } - ] - }, - { - "tfOpName": "TensorListConcatV2", - "category": "control", - "inputs": [ - { - "start": 0, - "name": "tensorListId", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "element_shape", - "name": "elementShape", - "type": "shape" - }, - { - "tfName": "element_dtype", - "name": "elementDType", - "type": "dtype" - } - ] - }, - { - "tfOpName": "TensorListPopBack", - "category": "control", - "inputs": [ - { - "start": 0, - "name": "tensorListId", - "type": "tensor" - }, - { - "start": 1, - "name": "elementShape", - "type": "shape" - } - ], - "attrs": [ - { - "tfName": "element_dtype", - "name": "elementDType", - "type": "dtype" - } - ] - }, - { - "tfOpName": "TensorListPushBack", - "category": "control", - "inputs": [ - { - "start": 0, - "name": "tensorListId", - "type": "tensor" - }, - { - "start": 1, - "name": "tensor", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "element_dtype", - "name": "elementDType", - "type": "dtype" - } - ] - }, - { - "tfOpName": "TensorListLength", - "category": "control", - "inputs": [ - { - "start": 0, - "name": "tensorListId", - "type": "tensor" - } - ] - }, - { - "tfOpName": "TensorListResize", - "category": "control", - "inputs": [ - { - "start": 0, - "name": "tensorListId", - "type": "tensor" - }, - { - "start": 1, - "name": "size", - "type": "number" - } - ] - } -] diff --git a/tfjs-master/tfjs-converter/python/tensorflowjs/op_list/convolution.json b/tfjs-master/tfjs-converter/python/tensorflowjs/op_list/convolution.json deleted file mode 100644 index e64f53b4e..000000000 --- a/tfjs-master/tfjs-converter/python/tensorflowjs/op_list/convolution.json +++ /dev/null @@ -1,689 +0,0 @@ -[ - { - "tfOpName": "AvgPool", - "category": "convolution", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "strides", - "name": "strides", - "type": "number[]" - }, - { - "tfName": "padding", - "name": "pad", - "type": "string" - }, - { - "tfName": "data_format", - "name": "dataFormat", - "type": "string", - "notSupported": true - }, - { - "tfName": "ksize", - "name": "kernelSize", - "type": "number[]" - }, - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "MaxPool", - "category": "convolution", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "strides", - "name": "strides", - "type": "number[]" - }, - { - "tfName": "padding", - "name": "pad", - "type": "string" - }, - { - "tfName": "data_format", - "name": "dataFormat", - "type": "string", - "notSupported": true - }, - { - "tfName": "ksize", - "name": "kernelSize", - "type": "number[]" - }, - { - "tfName": "explicit_paddings", - "name": "explicitPaddings", - "type": "number[]", - "defaultValue": [], - "notSupported": true - }, - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "MaxPoolWithArgmax", - "category": "convolution", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "strides", - "name": "strides", - "type": "number[]" - }, - { - "tfName": "padding", - "name": "pad", - "type": "string" - }, - { - "tfName": "ksize", - "name": "kernelSize", - "type": "number[]" - }, - { - "tfName": "include_batch_in_index", - "name": "includeBatchInIndex", - "type": "bool" - }, - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "AvgPool3D", - "category": "convolution", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "strides", - "name": "strides", - "type": "number[]" - }, - { - "tfName": "padding", - "name": "pad", - "type": "string" - }, - { - "tfName": "data_format", - "name": "dataFormat", - "type": "string", - "notSupported": true - }, - { - "tfName": "ksize", - "name": "kernelSize", - "type": "number[]" - }, - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "MaxPool3D", - "category": "convolution", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "strides", - "name": "strides", - "type": "number[]" - }, - { - "tfName": "padding", - "name": "pad", - "type": "string" - }, - { - "tfName": "data_format", - "name": "dataFormat", - "type": "string", - "notSupported": true - }, - { - "tfName": "ksize", - "name": "kernelSize", - "type": "number[]" - }, - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "Conv1D", - "category": "convolution", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - }, - { - "start": 1, - "name": "filter", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "stride", - "name": "stride", - "type": "number" - }, - { - "tfName": "padding", - "name": "pad", - "type": "string" - }, - { - "tfName": "data_format", - "name": "dataFormat", - "type": "string", - "defaultValue": "NWC" - }, - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - }, - { - "tfName": "dilation", - "name": "dilation", - "type": "number", - "defaultValue": 1 - } - ] - }, - { - "tfOpName": "Conv2D", - "category": "convolution", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - }, - { - "start": 1, - "name": "filter", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - }, - { - "tfName": "strides", - "name": "strides", - "type": "number[]" - }, - { - "tfName": "padding", - "name": "pad", - "type": "string" - }, - { - "tfName": "useCudnnOnGpu", - "name": "useCudnnOnGpu", - "type": "bool" - }, - { - "tfName": "data_format", - "name": "dataFormat", - "type": "string", - "defaultValue": "NHWC" - }, - { - "tfName": "explicit_paddings", - "name": "explicitPaddings", - "type": "number[]", - "defaultValue": [] - }, - { - "tfName": "dilations", - "name": "dilations", - "type": "number[]" - } - ] - }, - { - "tfOpName": "_FusedConv2D", - "category": "convolution", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - }, - { - "start": 1, - "name": "filter", - "type": "tensor" - }, - { - "start": 2, - "end": 0, - "name": "args", - "type": "tensors" - } - ], - "attrs": [ - { - "tfName": "num_args", - "name": "numArgs", - "type": "number" - }, - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - }, - { - "tfName": "strides", - "name": "strides", - "type": "number[]" - }, - { - "tfName": "padding", - "name": "pad", - "type": "string" - }, - { - "tfName": "explicit_paddings", - "name": "explicitPaddings", - "type": "number[]", - "defaultValue": [] - }, - { - "tfName": "use_cudnn_on_gpu", - "name": "useCudnnOnGpu", - "type": "bool", - "defaultValue": true - }, - { - "tfName": "data_format", - "name": "dataFormat", - "type": "string", - "defaultValue": "NHWC" - }, - { - "tfName": "dilations", - "name": "dilations", - "type": "number[]", - "defaultValue": [ - 1, - 1, - 1, - 1 - ] - }, - { - "tfName": "fused_ops", - "name": "fusedOps", - "type": "string[]", - "defaultValue": [] - }, - { - "tfName": "epsilon", - "name": "epsilon", - "type": "number", - "defaultValue": 0.0001 - }, - { - "tfName": "leakyrelu_alpha", - "name": "leakyreluAlpha", - "type": "number", - "defaultValue": 0.2 - } - ] - }, - { - "tfOpName": "Conv2DBackpropInput", - "category": "convolution", - "inputs": [ - { - "start": 2, - "name": "x", - "type": "tensor" - }, - { - "start": 1, - "name": "filter", - "type": "tensor" - }, - { - "start": 0, - "name": "outputShape", - "type": "number[]" - } - ], - "attrs": [ - { - "tfName": "strides", - "name": "strides", - "type": "number[]" - }, - { - "tfName": "padding", - "name": "pad", - "type": "string" - }, - { - "tfName": "data_format", - "name": "dataFormat", - "type": "string", - "notSupported": true - }, - { - "tfName": "explicit_paddings", - "name": "explicitPaddings", - "type": "number[]", - "defaultValue": [] - }, - { - "tfName": "dilations", - "name": "dilations", - "type": "number[]", - "notSupported": true - } - ] - }, - { - "tfOpName": "DepthwiseConv2d", - "category": "convolution", - "inputs": [ - { - "start": 0, - "name": "input", - "type": "tensor" - }, - { - "start": 1, - "name": "filter", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "strides", - "name": "strides", - "type": "number[]" - }, - { - "tfName": "padding", - "name": "pad", - "type": "string" - }, - { - "tfName": "data_format", - "name": "dataFormat", - "type": "string", - "defaultValue": "NHWC" - }, - { - "tfName": "explicit_paddings", - "name": "explicitPaddings", - "type": "number[]", - "defaultValue": [] - }, - { - "tfName": "dilations", - "name": "dilations", - "type": "number[]" - } - ] - }, - { - "tfOpName": "DepthwiseConv2dNative", - "category": "convolution", - "inputs": [ - { - "start": 0, - "name": "input", - "type": "tensor" - }, - { - "start": 1, - "name": "filter", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "strides", - "name": "strides", - "type": "number[]" - }, - { - "tfName": "padding", - "name": "pad", - "type": "string" - }, - { - "tfName": "data_format", - "name": "dataFormat", - "type": "string", - "defaultValue": "NHWC" - }, - { - "tfName": "explicit_paddings", - "name": "explicitPaddings", - "type": "number[]", - "defaultValue": [] - }, - { - "tfName": "dilations", - "name": "dilations", - "type": "number[]" - } - ] - }, - { - "tfOpName": "FusedDepthwiseConv2dNative", - "category": "convolution", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - }, - { - "start": 1, - "name": "filter", - "type": "tensor" - }, - { - "start": 2, - "end": 0, - "name": "args", - "type": "tensors" - } - ], - "attrs": [ - { - "tfName": "num_args", - "name": "numArgs", - "type": "number" - }, - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - }, - { - "tfName": "strides", - "name": "strides", - "type": "number[]" - }, - { - "tfName": "padding", - "name": "pad", - "type": "string" - }, - { - "tfName": "data_format", - "name": "dataFormat", - "type": "string", - "defaultValue": "NHWC" - }, - { - "tfName": "dilations", - "name": "dilations", - "type": "number[]", - "defaultValue": [ - 1, - 1, - 1, - 1 - ] - }, - { - "tfName": "fused_ops", - "name": "fusedOps", - "type": "string[]", - "defaultValue": [] - }, - { - "tfName": "explicit_paddings", - "name": "explicitPaddings", - "type": "number[]", - "defaultValue": [] - } - ] - }, - { - "tfOpName": "Conv3D", - "category": "convolution", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - }, - { - "start": 1, - "name": "filter", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "strides", - "name": "strides", - "type": "number[]" - }, - { - "tfName": "padding", - "name": "pad", - "type": "string" - }, - { - "tfName": "data_format", - "name": "dataFormat", - "type": "string", - "defaultValue": "NHWC" - }, - { - "tfName": "dilations", - "name": "dilations", - "type": "number[]" - } - ] - }, - { - "tfOpName": "Dilation2D", - "category": "convolution", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - }, - { - "start": 1, - "name": "filter", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "strides", - "name": "strides", - "type": "number[]" - }, - { - "tfName": "rates", - "name": "dilations", - "type": "number[]" - }, - { - "tfName": "padding", - "name": "pad", - "type": "string" - } - ] - } -] diff --git a/tfjs-master/tfjs-converter/python/tensorflowjs/op_list/creation.json b/tfjs-master/tfjs-converter/python/tensorflowjs/op_list/creation.json deleted file mode 100644 index 3b2476b97..000000000 --- a/tfjs-master/tfjs-converter/python/tensorflowjs/op_list/creation.json +++ /dev/null @@ -1,404 +0,0 @@ -[ - { - "tfOpName": "Fill", - "category": "creation", - "inputs": [ - { - "start": 0, - "name": "shape", - "type": "number[]" - }, - { - "start": 1, - "name": "value", - "type": "number" - } - ], - "attrs": [ - { - "tfName": "T", - "name": "dtype", - "type": "dtype" - } - ] - }, - { - "tfOpName": "LinSpace", - "category": "creation", - "inputs": [ - { - "start": 0, - "name": "start", - "type": "number" - }, - { - "start": 1, - "name": "stop", - "type": "number" - }, - { - "start": 2, - "name": "num", - "type": "number" - } - ], - "attrs": [ - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "OneHot", - "category": "creation", - "inputs": [ - { - "start": 0, - "name": "indices", - "type": "tensor" - }, - { - "start": 1, - "name": "depth", - "type": "number" - }, - { - "start": 2, - "name": "onValue", - "type": "number", - "defaultValue": 1 - }, - { - "start": 3, - "name": "offValue", - "type": "number", - "defaultValue": 0 - } - ], - "attrs": [ - { - "tfName": "axis", - "name": "axis", - "type": "number", - "notSupported": true - }, - { - "tfName": "T", - "name": "dtype", - "type": "dtype" - } - ] - }, - { - "tfOpName": "Ones", - "category": "creation", - "inputs": [ - { - "start": 0, - "name": "shape", - "type": "number[]" - } - ], - "attrs": [ - { - "tfName": "T", - "name": "dtype", - "type": "dtype" - } - ] - }, - { - "tfOpName": "OnesLike", - "category": "creation", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "dtype", - "name": "dtype", - "type": "dtype" - } - ] - }, - { - "tfOpName": "RandomStandardNormal", - "category": "creation", - "inputs": [ - { - "start": 0, - "name": "shape", - "type": "number[]" - } - ], - "attrs": [ - { - "tfName": "seed", - "name": "seed", - "type": "number", - "defaultValue": 0 - }, - { - "tfName": "seed2", - "name": "seed2", - "type": "number", - "defaultValue": 0, - "notSupported": true - }, - { - "tfName": "dtype", - "name": "dtype", - "type": "dtype" - }, - { - "tfName": "T", - "name": "T", - "type": "number", - "notSupported": true - } - ] - }, - { - "tfOpName": "RandomUniform", - "category": "creation", - "inputs": [ - { - "start": 0, - "name": "shape", - "type": "number[]" - } - ], - "attrs": [ - { - "tfName": "minval", - "name": "minval", - "type": "number", - "defaultValue": 0 - }, - { - "tfName": "maxval", - "name": "maxval", - "type": "number", - "defaultValue": 1 - }, - { - "tfName": "dtype", - "name": "dtype", - "type": "dtype" - }, - { - "tfName": "seed", - "name": "seed", - "type": "number", - "defaultValue": 0 - }, - { - "tfName": "seed2", - "name": "seed2", - "type": "number", - "defaultValue": 0, - "notSupported": true - }, - { - "tfName": "T", - "name": "T", - "type": "number", - "notSupported": true - } - ] - }, - { - "tfOpName": "RandomUniformInt", - "category": "creation", - "inputs": [ - { - "start": 0, - "name": "shape", - "type": "number[]" - } - ], - "attrs": [ - { - "tfName": "minval", - "name": "minval", - "type": "number" - }, - { - "tfName": "maxval", - "name": "maxval", - "type": "number" - }, - { - "tfName": "seed", - "name": "seed", - "type": "number", - "defaultValue": 0 - }, - { - "tfName": "seed2", - "name": "seed2", - "type": "number", - "defaultValue": 0, - "notSupported": true - } - ] - }, - { - "tfOpName": "Range", - "category": "creation", - "inputs": [ - { - "start": 0, - "name": "start", - "type": "number" - }, - { - "start": 1, - "name": "stop", - "type": "number" - }, - { - "start": 2, - "name": "step", - "type": "number", - "defaultValue": 0 - } - ], - "attrs": [ - { - "tfName": "Tidx", - "name": "dtype", - "type": "dtype" - } - ] - }, - { - "tfOpName": "TruncatedNormal", - "category": "creation", - "inputs": [ - { - "start": 0, - "name": "shape", - "type": "number[]" - } - ], - "attrs": [ - { - "tfName": "means", - "name": "mean", - "type": "number", - "defaultValue": 0 - }, - { - "tfName": "stddev", - "name": "stdDev", - "type": "number", - "defaultValue": 1 - }, - { - "tfName": "seed", - "name": "seed", - "type": "number" - }, - { - "tfName": "seed2", - "name": "seed2", - "type": "number", - "defaultValue": 0, - "notSupported": true - }, - { - "tfName": "dtype", - "name": "dtype", - "type": "dtype" - }, - { - "tfName": "T", - "name": "T", - "type": "number", - "notSupported": true - } - ] - }, - { - "tfOpName": "Zeros", - "category": "creation", - "inputs": [ - { - "start": 0, - "name": "shape", - "type": "number[]" - } - ], - "attrs": [ - { - "tfName": "T", - "name": "dtype", - "type": "dtype" - } - ] - }, - { - "tfOpName": "ZerosLike", - "category": "creation", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "T", - "name": "dtype", - "type": "dtype" - } - ] - }, - { - "tfOpName": "Multinomial", - "category": "creation", - "inputs": [ - { - "start": 0, - "name": "logits", - "type": "tensor" - }, - { - "start": 1, - "name": "numSamples", - "type": "number" - } - ], - "attrs": [ - { - "tfName": "seed", - "name": "seed", - "type": "number" - }, - { - "tfName": "seed2", - "name": "seed2", - "type": "number" - }, - { - "tfName": "T", - "name": "dtype", - "type": "dtype" - }, - { - "tfName": "output_dtype", - "name": "output_dtype", - "type": "dtype" - } - ] - } -] diff --git a/tfjs-master/tfjs-converter/python/tensorflowjs/op_list/dynamic.json b/tfjs-master/tfjs-converter/python/tensorflowjs/op_list/dynamic.json deleted file mode 100644 index 9a028b506..000000000 --- a/tfjs-master/tfjs-converter/python/tensorflowjs/op_list/dynamic.json +++ /dev/null @@ -1,188 +0,0 @@ -[ - { - "tfOpName": "NonMaxSuppressionV2", - "category": "dynamic", - "inputs": [ - { - "start": 0, - "name": "boxes", - "type": "tensor" - }, - { - "start": 1, - "name": "scores", - "type": "tensor" - }, - { - "start": 2, - "name": "maxOutputSize", - "type": "number" - }, - { - "start": 3, - "name": "iouThreshold", - "type": "number" - } - ] - }, - { - "tfOpName": "NonMaxSuppressionV3", - "category": "dynamic", - "inputs": [ - { - "start": 0, - "name": "boxes", - "type": "tensor" - }, - { - "start": 1, - "name": "scores", - "type": "tensor" - }, - { - "start": 2, - "name": "maxOutputSize", - "type": "number" - }, - { - "start": 3, - "name": "iouThreshold", - "type": "number" - }, - { - "start": 4, - "name": "scoreThreshold", - "type": "number" - } - ] - }, - { - "tfOpName": "NonMaxSuppressionV4", - "category": "dynamic", - "inputs": [ - { - "start": 0, - "name": "boxes", - "type": "tensor" - }, - { - "start": 1, - "name": "scores", - "type": "tensor" - }, - { - "start": 2, - "name": "maxOutputSize", - "type": "number" - }, - { - "start": 3, - "name": "iouThreshold", - "type": "number" - }, - { - "start": 4, - "name": "scoreThreshold", - "type": "number" - } - ], - "attrs": [ - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - }, - { - "tfName": "T_threshold", - "name": "threshold", - "type": "dtype", - "notSupported": true - }, - { - "tfName": "pad_to_max_output_size", - "name": "padToMaxOutputSize", - "type": "bool" - } - ] - }, - { - "tfOpName": "NonMaxSuppressionV5", - "category": "dynamic", - "inputs": [ - { - "start": 0, - "name": "boxes", - "type": "tensor" - }, - { - "start": 1, - "name": "scores", - "type": "tensor" - }, - { - "start": 2, - "name": "maxOutputSize", - "type": "number" - }, - { - "start": 3, - "name": "iouThreshold", - "type": "number" - }, - { - "start": 4, - "name": "scoreThreshold", - "type": "number" - }, - { - "start": 5, - "name": "softNmsSigma", - "type": "number" - } - ] - }, - { - "tfOpName": "Where", - "category": "dynamic", - "inputs": [ - { - "start": 0, - "name": "condition", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "ListDiff", - "category": "dynamic", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - }, - { - "start": 1, - "name": "y", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - } -] \ No newline at end of file diff --git a/tfjs-master/tfjs-converter/python/tensorflowjs/op_list/evaluation.json b/tfjs-master/tfjs-converter/python/tensorflowjs/op_list/evaluation.json deleted file mode 100644 index 3a66b1051..000000000 --- a/tfjs-master/tfjs-converter/python/tensorflowjs/op_list/evaluation.json +++ /dev/null @@ -1,84 +0,0 @@ -[ - { - "tfOpName": "LowerBound", - "category": "evaluation", - "inputs": [ - { - "start": 0, - "name": "sortedSequence", - "type": "tensor" - }, - { - "start": 1, - "name": "values", - "type": "tensor" - } - ] - }, - { - "tfOpName": "TopKV2", - "category": "evaluation", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - }, - { - "start": 1, - "name": "k", - "type": "number" - } - ], - "attrs": [ - { - "tfName": "sorted", - "name": "sorted", - "type": "bool" - } - ] - }, - { - "tfOpName": "UpperBound", - "category": "evaluation", - "inputs": [ - { - "start": 0, - "name": "sortedSequence", - "type": "tensor" - }, - { - "start": 1, - "name": "values", - "type": "tensor" - } - ] - }, - { - "tfOpName": "Unique", - "category": "evaluation", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - } - ] - }, - { - "tfOpName": "UniqueV2", - "category": "evaluation", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - }, - { - "start": 1, - "name": "axis", - "type": "number" - } - ] - } -] diff --git a/tfjs-master/tfjs-converter/python/tensorflowjs/op_list/graph.json b/tfjs-master/tfjs-converter/python/tensorflowjs/op_list/graph.json deleted file mode 100644 index bb32c430d..000000000 --- a/tfjs-master/tfjs-converter/python/tensorflowjs/op_list/graph.json +++ /dev/null @@ -1,198 +0,0 @@ -[ - { - "tfOpName": "PlaceholderWithDefault", - "category": "graph", - "inputs": [ - { - "start": 0, - "name": "default", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "shape", - "name": "shape", - "type": "shape" - }, - { - "tfName": "dtype", - "name": "dtype", - "type": "dtype" - } - ] - }, - { - "tfOpName": "Placeholder", - "category": "graph", - "attrs": [ - { - "tfName": "shape", - "name": "shape", - "type": "shape" - }, - { - "tfName": "dtype", - "name": "dtype", - "type": "dtype" - } - ] - }, - { - "tfOpName": "Const", - "category": "graph" - }, - { - "tfOpName": "Identity", - "category": "graph", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - } - ] - }, - { - "tfOpName": "IdentityN", - "category": "graph", - "inputs": [ - { - "start": 0, - "end": 0, - "name": "x", - "type": "tensors" - } - ] - }, - { - "tfOpName": "Snapshot", - "category": "graph", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - } - ] - }, - { - "tfOpName": "Rank", - "category": "graph", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - } - ] - }, - { - "tfOpName": "Size", - "category": "graph", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - } - ] - }, - { - "tfOpName": "Shape", - "category": "graph", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - } - ] - }, - { - "tfOpName": "ShapeN", - "category": "graph", - "inputs": [ - { - "start": 0, - "end": 0, - "name": "x", - "type": "tensors" - } - ] - }, - { - "tfOpName": "Print", - "category": "graph", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - }, - { - "start": 1, - "name": "data", - "type": "tensors" - } - ], - "attrs": [ - { - "tfName": "message", - "name": "message", - "type": "string" - }, - { - "tfName": "first_n", - "name": "firstN", - "type": "number", - "notSupported": true - }, - { - "tfName": "summarize", - "name": "summarize", - "type": "number", - "defaultValue": 3 - } - ] - }, - { - "tfOpName": "NoOp", - "category": "graph", - "inputs": [] - }, - { - "tfOpName": "StopGradient", - "category": "graph", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - } - ] - }, - { - "tfOpName": "FakeQuantWithMinMaxVars", - "category": "graph", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "min", - "name": "min", - "type": "number" - }, - { - "tfName": "max", - "name": "max", - "type": "number" - } - ] - } -] \ No newline at end of file diff --git a/tfjs-master/tfjs-converter/python/tensorflowjs/op_list/hash_table.json b/tfjs-master/tfjs-converter/python/tensorflowjs/op_list/hash_table.json deleted file mode 100644 index 7d07f2a40..000000000 --- a/tfjs-master/tfjs-converter/python/tensorflowjs/op_list/hash_table.json +++ /dev/null @@ -1,260 +0,0 @@ -[ - { - "tfOpName": "HashTable", - "category": "hash_table", - "inputs": [], - "attrs": [ - { - "tfName": "shared_name", - "name": "sharedName", - "type": "string" - }, - { - "tfName": "use_node_name_sharing", - "name": "useNodeNameSharing", - "type": "bool" - }, - { - "tfName": "key_dtype", - "name": "keyDType", - "type": "dtype" - }, - { - "tfName": "value_dtype", - "name": "valueDType", - "type": "dtype" - } - ] - }, - { - "tfOpName": "HashTableV2", - "category": "hash_table", - "inputs": [], - "attrs": [ - { - "tfName": "shared_name", - "name": "sharedName", - "type": "string" - }, - { - "tfName": "use_node_name_sharing", - "name": "useNodeNameSharing", - "type": "bool" - }, - { - "tfName": "key_dtype", - "name": "keyDType", - "type": "dtype" - }, - { - "tfName": "value_dtype", - "name": "valueDType", - "type": "dtype" - } - ] - }, - { - "tfOpName": "LookupTableImport", - "category": "hash_table", - "inputs": [ - { - "start": 0, - "name": "tableHandle", - "type": "tensor" - }, - { - "start": 1, - "name": "keys", - "type": "tensor" - }, - { - "start": 2, - "name": "values", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "Tin", - "name": "tIn", - "type": "dtype", - "notSupported": true - }, - { - "tfName": "Tout", - "name": "tOut", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "LookupTableImportV2", - "category": "hash_table", - "inputs": [ - { - "start": 0, - "name": "tableHandle", - "type": "tensor" - }, - { - "start": 1, - "name": "keys", - "type": "tensor" - }, - { - "start": 2, - "name": "values", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "Tin", - "name": "tIn", - "type": "dtype", - "notSupported": true - }, - { - "tfName": "Tout", - "name": "tOut", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "LookupTableFind", - "category": "hash_table", - "inputs": [ - { - "start": 0, - "name": "tableHandle", - "type": "tensor" - }, - { - "start": 1, - "name": "keys", - "type": "tensor" - }, - { - "start": 2, - "name": "defaultValue", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "Tin", - "name": "tIn", - "type": "dtype", - "notSupported": true - }, - { - "tfName": "Tout", - "name": "tOut", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "LookupTableFindV2", - "category": "hash_table", - "inputs": [ - { - "start": 0, - "name": "tableHandle", - "type": "tensor" - }, - { - "start": 1, - "name": "keys", - "type": "tensor" - }, - { - "start": 2, - "name": "defaultValue", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "Tin", - "name": "tIn", - "type": "dtype", - "notSupported": true - }, - { - "tfName": "Tout", - "name": "tOut", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "LookupTableSize", - "category": "hash_table", - "inputs": [ - { - "start": 0, - "name": "tableHandle", - "type": "tensor" - } - ] - }, - { - "tfOpName": "LookupTableSizeV2", - "category": "hash_table", - "inputs": [ - { - "start": 0, - "name": "tableHandle", - "type": "tensor" - } - ] - }, - { - "tfOpName": "InitializeTable", - "category": "hash_table", - "inputs": [ - { - "start": 0, - "name": "tableHandle", - "type": "tensor" - }, - { - "start": 1, - "name": "keys", - "type": "tensor" - }, - { - "start": 2, - "name": "values", - "type": "tensor" - } - ] - }, - { - "tfOpName": "InitializeTableV2", - "category": "hash_table", - "inputs": [ - { - "start": 0, - "name": "tableHandle", - "type": "tensor" - }, - { - "start": 1, - "name": "keys", - "type": "tensor" - }, - { - "start": 2, - "name": "values", - "type": "tensor" - } - ] - } -] diff --git a/tfjs-master/tfjs-converter/python/tensorflowjs/op_list/image.json b/tfjs-master/tfjs-converter/python/tensorflowjs/op_list/image.json deleted file mode 100644 index 6664ef6d6..000000000 --- a/tfjs-master/tfjs-converter/python/tensorflowjs/op_list/image.json +++ /dev/null @@ -1,146 +0,0 @@ -[ - { - "tfOpName": "ResizeBilinear", - "category": "image", - "inputs": [ - { - "start": 0, - "name": "images", - "type": "tensor" - }, - { - "start": 1, - "name": "size", - "type": "number[]" - } - ], - "attrs": [ - { - "tfName": "align_corners", - "name": "alignCorners", - "type": "bool" - }, - { - "tfName": "half_pixel_centers", - "name": "halfPixelCenters", - "type": "bool" - }, - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "ResizeNearestNeighbor", - "category": "image", - "inputs": [ - { - "start": 0, - "name": "images", - "type": "tensor" - }, - { - "start": 1, - "name": "size", - "type": "number[]" - } - ], - "attrs": [ - { - "tfName": "align_corners", - "name": "alignCorners", - "type": "bool" - }, - { - "tfName": "half_pixel_centers", - "name": "halfPixelCenters", - "type": "bool" - }, - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "CropAndResize", - "category": "image", - "inputs": [ - { - "start": 0, - "name": "image", - "type": "tensor" - }, - { - "start": 1, - "name": "boxes", - "type": "tensor" - }, - { - "start": 2, - "name": "boxInd", - "type": "tensor" - }, - { - "start": 3, - "name": "cropSize", - "type": "number[]" - } - ], - "attrs": [ - { - "tfName": "method", - "name": "method", - "type": "string" - }, - { - "tfName": "extrapolation_value", - "name": "extrapolationValue", - "type": "number" - } - ] - }, - { - "tfOpName": "ImageProjectiveTransformV3", - "category": "image", - "inputs": [ - { - "start": 0, - "name": "images", - "type": "tensor" - }, - { - "start": 1, - "name": "transforms", - "type": "tensor" - }, - { - "start": 2, - "name": "outputShape", - "type": "number[]" - }, - { - "start": 3, - "name": "fillValue", - "type": "number" - } - ], - "attrs": [ - { - "tfName": "interpolation", - "name": "interpolation", - "type": "string" - }, - { - "tfName": "fill_mode", - "name": "fillMode", - "type": "string" - } - ] - } -] \ No newline at end of file diff --git a/tfjs-master/tfjs-converter/python/tensorflowjs/op_list/logical.json b/tfjs-master/tfjs-converter/python/tensorflowjs/op_list/logical.json deleted file mode 100644 index fb9a4e297..000000000 --- a/tfjs-master/tfjs-converter/python/tensorflowjs/op_list/logical.json +++ /dev/null @@ -1,287 +0,0 @@ -[ - { - "tfOpName": "Equal", - "category": "logical", - "inputs": [ - { - "start": 0, - "name": "a", - "type": "tensor" - }, - { - "start": 1, - "name": "b", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "NotEqual", - "category": "logical", - "inputs": [ - { - "start": 0, - "name": "a", - "type": "tensor" - }, - { - "start": 1, - "name": "b", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "Greater", - "category": "logical", - "inputs": [ - { - "start": 0, - "name": "a", - "type": "tensor" - }, - { - "start": 1, - "name": "b", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "GreaterEqual", - "category": "logical", - "inputs": [ - { - "start": 0, - "name": "a", - "type": "tensor" - }, - { - "start": 1, - "name": "b", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "Less", - "category": "logical", - "inputs": [ - { - "start": 0, - "name": "a", - "type": "tensor" - }, - { - "start": 1, - "name": "b", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "LessEqual", - "category": "logical", - "inputs": [ - { - "start": 0, - "name": "a", - "type": "tensor" - }, - { - "start": 1, - "name": "b", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "LogicalAnd", - "category": "logical", - "inputs": [ - { - "start": 0, - "name": "a", - "type": "tensor" - }, - { - "start": 1, - "name": "b", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "LogicalNot", - "category": "logical", - "inputs": [ - { - "start": 0, - "name": "a", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "LogicalOr", - "category": "logical", - "inputs": [ - { - "start": 0, - "name": "a", - "type": "tensor" - }, - { - "start": 1, - "name": "b", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "Select", - "category": "logical", - "inputs": [ - { - "start": 0, - "name": "condition", - "type": "tensor" - }, - { - "start": 1, - "name": "a", - "type": "tensor" - }, - { - "start": 2, - "name": "b", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "SelectV2", - "category": "logical", - "inputs": [ - { - "start": 0, - "name": "condition", - "type": "tensor" - }, - { - "start": 1, - "name": "a", - "type": "tensor" - }, - { - "start": 2, - "name": "b", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "BitwiseAnd", - "category": "logical", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - }, - { - "start": 1, - "name": "y", - "type": "tensor" - } - ] - } -] diff --git a/tfjs-master/tfjs-converter/python/tensorflowjs/op_list/matrices.json b/tfjs-master/tfjs-converter/python/tensorflowjs/op_list/matrices.json deleted file mode 100644 index d8a9f246d..000000000 --- a/tfjs-master/tfjs-converter/python/tensorflowjs/op_list/matrices.json +++ /dev/null @@ -1,250 +0,0 @@ -[ - { - "tfOpName": "_FusedMatMul", - "category": "matrices", - "inputs": [ - { - "start": 0, - "name": "a", - "type": "tensor" - }, - { - "start": 1, - "name": "b", - "type": "tensor" - }, - { - "start": 2, - "end": 0, - "name": "args", - "type": "tensors" - } - ], - "attrs": [ - { - "tfName": "num_args", - "name": "numArgs", - "type": "number" - }, - { - "tfName": "fused_ops", - "name": "fusedOps", - "type": "string[]", - "defaultValue": [] - }, - { - "tfName": "epsilon", - "name": "epsilon", - "type": "number", - "defaultValue": 0.0001 - }, - { - "tfName": "transpose_a", - "name": "transposeA", - "type": "bool", - "defaultValue": false - }, - { - "tfName": "transpose_b", - "name": "transposeB", - "type": "bool", - "defaultValue": false - }, - { - "tfName": "leakyrelu_alpha", - "name": "leakyreluAlpha", - "type": "number", - "defaultValue": 0.2 - }, - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "MatMul", - "category": "matrices", - "inputs": [ - { - "start": 0, - "name": "a", - "type": "tensor" - }, - { - "start": 1, - "name": "b", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "transpose_a", - "name": "transposeA", - "type": "bool", - "defaultValue": false - }, - { - "tfName": "transpose_b", - "name": "transposeB", - "type": "bool", - "defaultValue": false - }, - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "BatchMatMul", - "category": "matrices", - "inputs": [ - { - "start": 0, - "name": "a", - "type": "tensor" - }, - { - "start": 1, - "name": "b", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "adj_x", - "name": "transposeA", - "type": "bool", - "defaultValue": false - }, - { - "tfName": "adj_y", - "name": "transposeB", - "type": "bool", - "defaultValue": false - }, - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "BatchMatMulV2", - "category": "matrices", - "inputs": [ - { - "start": 0, - "name": "a", - "type": "tensor" - }, - { - "start": 1, - "name": "b", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "adj_x", - "name": "transposeA", - "type": "bool", - "defaultValue": false - }, - { - "tfName": "adj_y", - "name": "transposeB", - "type": "bool", - "defaultValue": false - }, - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "Transpose", - "category": "matrices", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - }, - { - "start": 1, - "name": "perm", - "type": "number[]" - } - ], - "attrs": [ - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "Einsum", - "category": "matrices", - "inputs": [ - { - "start": 0, - "end": 0, - "name": "tensors", - "type": "tensors" - } - ], - "attrs": [ - { - "tfName": "equation", - "name": "equation", - "type": "string" - }, - { - "tfName": "N", - "name": "n", - "type": "number", - "defaultValue": 2 - }, - { - "tfName": "T", - "name": "dtype", - "type": "dtype" - } - ] - }, - { - "tfOpName": "MatrixBandPart", - "category": "matrices", - "inputs": [ - { - "start": 0, - "name": "a", - "type": "tensor" - }, - { - "start": 1, - "name": "numLower", - "type": "tensor" - }, - { - "start": 1, - "name": "numUpper", - "type": "tensor" - } - ] - } -] diff --git a/tfjs-master/tfjs-converter/python/tensorflowjs/op_list/normalization.json b/tfjs-master/tfjs-converter/python/tensorflowjs/op_list/normalization.json deleted file mode 100644 index fd460f0da..000000000 --- a/tfjs-master/tfjs-converter/python/tensorflowjs/op_list/normalization.json +++ /dev/null @@ -1,220 +0,0 @@ -[ - { - "tfOpName": "EuclideanNorm", - "category": "normalization", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - }, - { - "start": 1, - "name": "axis", - "type": "number[]" - } - ], - "attrs": [ - { - "tfName": "keep_dims", - "name": "keepDims", - "type": "bool", - "defaultValue": false - } - ] - }, - { - "tfOpName": "FusedBatchNorm", - "category": "normalization", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - }, - { - "start": 1, - "name": "scale", - "type": "tensor" - }, - { - "start": 2, - "name": "offset", - "type": "tensor" - }, - { - "start": 3, - "name": "mean", - "type": "tensor" - }, - { - "start": 4, - "name": "variance", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "epsilon", - "name": "epsilon", - "type": "number", - "defaultValue": 0.001 - }, - { - "tfName": "data_format", - "name": "dataFormat", - "type": "string", - "notSupported": true - } - ] - }, - { - "tfOpName": "FusedBatchNormV2", - "category": "normalization", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - }, - { - "start": 1, - "name": "scale", - "type": "tensor" - }, - { - "start": 2, - "name": "offset", - "type": "tensor" - }, - { - "start": 3, - "name": "mean", - "type": "tensor" - }, - { - "start": 4, - "name": "variance", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "epsilon", - "name": "epsilon", - "type": "number", - "defaultValue": 0.001 - }, - { - "tfName": "data_format", - "name": "dataFormat", - "type": "string", - "notSupported": true - } - ] - }, - { - "tfOpName": "FusedBatchNormV3", - "category": "normalization", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - }, - { - "start": 1, - "name": "scale", - "type": "tensor" - }, - { - "start": 2, - "name": "offset", - "type": "tensor" - }, - { - "start": 3, - "name": "mean", - "type": "tensor" - }, - { - "start": 4, - "name": "variance", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "epsilon", - "name": "epsilon", - "type": "number", - "defaultValue": 0.001 - }, - { - "tfName": "data_format", - "name": "dataFormat", - "type": "string", - "notSupported": true - } - ] - }, - { - "tfOpName": "LRN", - "category": "normalization", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "depth_radius", - "name": "radius", - "type": "number", - "defaultValue": 5 - }, - { - "tfName": "bias", - "name": "bias", - "type": "number", - "defaultValue": 1 - }, - { - "tfName": "alpha", - "name": "alpha", - "type": "number", - "defaultValue": 1 - }, - { - "tfName": "beta", - "name": "beta", - "type": "number", - "defaultValue": 0.5 - } - ] - }, - { - "tfOpName": "Softmax", - "category": "normalization", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - } - ] - }, - { - "tfOpName": "LogSoftmax", - "category": "normalization", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - } - ] - } -] diff --git a/tfjs-master/tfjs-converter/python/tensorflowjs/op_list/ragged.json b/tfjs-master/tfjs-converter/python/tensorflowjs/op_list/ragged.json deleted file mode 100644 index cf1f8c71f..000000000 --- a/tfjs-master/tfjs-converter/python/tensorflowjs/op_list/ragged.json +++ /dev/null @@ -1,86 +0,0 @@ -[ - { - "tfOpName": "RaggedGather", - "category": "ragged", - "inputs": [ - { - "start": 0, - "end": -3, - "name": "paramsNestedSplits", - "type": "tensors" - }, - { - "start": -2, - "name": "paramsDenseValues", - "type": "tensor" - }, - { - "start": -1, - "name": "indices", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "OUTPUT_RAGGED_RANK", - "name": "outputRaggedRank", - "type": "number" - } - ] - }, - { - "tfOpName": "RaggedRange", - "category": "ragged", - "inputs": [ - { - "start": 0, - "name": "starts", - "type": "tensor" - }, - { - "start": 1, - "name": "limits", - "type": "tensor" - }, - { - "start": 2, - "name": "splits", - "type": "tensor" - } - ] - }, - { - "tfOpName": "RaggedTensorToTensor", - "category": "ragged", - "inputs": [ - { - "start": 0, - "name": "shape", - "type": "tensor" - }, - { - "start": 1, - "name": "values", - "type": "tensor" - }, - { - "start": 2, - "name": "defaultValue", - "type": "tensor" - }, - { - "start": 3, - "end": 0, - "name": "rowPartitionTensors", - "type": "tensors" - } - ], - "attrs": [ - { - "tfName": "row_partition_types", - "name": "rowPartitionTypes", - "type": "string[]" - } - ] - } -] diff --git a/tfjs-master/tfjs-converter/python/tensorflowjs/op_list/reduction.json b/tfjs-master/tfjs-converter/python/tensorflowjs/op_list/reduction.json deleted file mode 100644 index 486a75461..000000000 --- a/tfjs-master/tfjs-converter/python/tensorflowjs/op_list/reduction.json +++ /dev/null @@ -1,306 +0,0 @@ -[ - { - "tfOpName": "Bincount", - "category": "reduction", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - }, - { - "start": 1, - "name": "size", - "type": "number" - }, - { - "start": 2, - "name": "weights", - "type": "tensor" - } - ] - }, - { - "tfOpName": "DenseBincount", - "category": "reduction", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - }, - { - "start": 1, - "name": "size", - "type": "number" - }, - { - "start": 2, - "name": "weights", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "binary_output", - "name": "binaryOutput", - "type": "bool" - } - ] - }, - { - "tfOpName": "Max", - "category": "reduction", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - }, - { - "start": 1, - "name": "axis", - "type": "number[]" - } - ], - "attrs": [ - { - "tfName": "keep_dims", - "name": "keepDims", - "type": "bool" - } - ] - }, - { - "tfOpName": "Mean", - "category": "reduction", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - }, - { - "start": 1, - "name": "axis", - "type": "number[]" - } - ], - "attrs": [ - { - "tfName": "keep_dims", - "name": "keepDims", - "type": "bool" - } - ] - }, - { - "tfOpName": "Min", - "category": "reduction", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - }, - { - "start": 1, - "name": "axis", - "type": "number[]" - } - ], - "attrs": [ - { - "tfName": "keep_dims", - "name": "keepDims", - "type": "bool" - } - ] - }, - { - "tfOpName": "Sum", - "category": "reduction", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - }, - { - "start": 1, - "name": "axis", - "type": "number[]" - } - ], - "attrs": [ - { - "tfName": "keep_dims", - "name": "keepDims", - "type": "bool" - } - ] - }, - { - "tfOpName": "All", - "category": "reduction", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - }, - { - "start": 1, - "name": "axis", - "type": "number[]" - } - ], - "attrs": [ - { - "tfName": "keep_dims", - "name": "keepDims", - "type": "bool" - } - ] - }, - { - "tfOpName": "Any", - "category": "reduction", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - }, - { - "start": 1, - "name": "axis", - "type": "number[]" - } - ], - "attrs": [ - { - "tfName": "keep_dims", - "name": "keepDims", - "type": "bool" - } - ] - }, - { - "tfOpName": "ArgMax", - "category": "reduction", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - }, - { - "start": 1, - "name": "axis", - "type": "number" - } - ] - }, - { - "tfOpName": "ArgMin", - "category": "reduction", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - }, - { - "start": 1, - "name": "axis", - "type": "number" - } - ] - }, - { - "tfOpName": "Prod", - "category": "reduction", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - }, - { - "start": 1, - "name": "axis", - "type": "number[]" - } - ], - "attrs": [ - { - "tfName": "keep_dims", - "name": "keepDims", - "type": "bool" - }, - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "Cumprod", - "category": "reduction", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - }, - { - "start": 1, - "name": "axis", - "type": "number" - } - ], - "attrs": [ - { - "tfName": "exclusive", - "name": "exclusive", - "type": "bool" - }, - { - "tfName": "reverse", - "name": "reverse", - "type": "bool" - } - ] - }, - { - "tfOpName": "Cumsum", - "category": "reduction", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - }, - { - "start": 1, - "name": "axis", - "type": "number" - } - ], - "attrs": [ - { - "tfName": "exclusive", - "name": "exclusive", - "type": "bool" - }, - { - "tfName": "reverse", - "name": "reverse", - "type": "bool" - } - ] - } -] diff --git a/tfjs-master/tfjs-converter/python/tensorflowjs/op_list/slice_join.json b/tfjs-master/tfjs-converter/python/tensorflowjs/op_list/slice_join.json deleted file mode 100644 index 724ae5a3d..000000000 --- a/tfjs-master/tfjs-converter/python/tensorflowjs/op_list/slice_join.json +++ /dev/null @@ -1,419 +0,0 @@ -[ - { - "tfOpName": "ConcatV2", - "category": "slice_join", - "inputs": [ - { - "start": 0, - "end": -1, - "name": "tensors", - "type": "tensors" - }, - { - "start": -1, - "name": "axis", - "type": "number" - } - ], - "attrs": [ - { - "tfName": "N", - "name": "n", - "type": "number", - "defaultValue": 2 - } - ] - }, - { - "tfOpName": "Concat", - "category": "slice_join", - "inputs": [ - { - "start": 1, - "end": 0, - "name": "tensors", - "type": "tensors" - }, - { - "start": 0, - "name": "axis", - "type": "number" - } - ], - "attrs": [ - { - "tfName": "N", - "name": "n", - "type": "number", - "defaultValue": 2 - } - ] - }, - { - "tfOpName": "GatherV2", - "category": "slice_join", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - }, - { - "start": 1, - "name": "indices", - "type": "tensor" - }, - { - "start": 2, - "name": "axis", - "type": "number", - "defaultValue": 0 - } - ], - "attrs": [ - { - "tfName": "batch_dims", - "name": "batchDims", - "type": "number", - "defaultValue": 0 - } - ] - }, - { - "tfOpName": "Gather", - "category": "slice_join", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - }, - { - "start": 1, - "name": "indices", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "validate_indices", - "name": "validateIndices", - "type": "bool", - "notSupported": true - } - ] - }, - { - "tfOpName": "Reverse", - "category": "slice_join", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - }, - { - "start": 1, - "name": "dims", - "type": "bool[]" - } - ] - }, - { - "tfOpName": "ReverseV2", - "category": "slice_join", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - }, - { - "start": 1, - "name": "axis", - "type": "number[]" - } - ] - }, - { - "tfOpName": "Slice", - "category": "slice_join", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - }, - { - "start": 1, - "name": "begin", - "type": "number[]" - }, - { - "start": 2, - "name": "size", - "type": "number[]" - } - ] - }, - { - "tfOpName": "StridedSlice", - "category": "slice_join", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - }, - { - "start": 1, - "name": "begin", - "type": "number[]" - }, - { - "start": 2, - "name": "end", - "type": "number[]" - }, - { - "start": 3, - "name": "strides", - "type": "number[]" - } - ], - "attrs": [ - { - "tfName": "begin_mask", - "name": "beginMask", - "type": "number", - "defaultValue": 0 - }, - { - "tfName": "end_mask", - "name": "endMask", - "type": "number", - "defaultValue": 0 - }, - { - "tfName": "new_axis_mask", - "name": "newAxisMask", - "type": "number", - "defaultValue": 0 - }, - { - "tfName": "ellipsis_mask", - "name": "ellipsisMask", - "type": "number", - "defaultValue": 0 - }, - { - "tfName": "shrink_axis_mask", - "name": "shrinkAxisMask", - "type": "number", - "defaultValue": 0 - } - ] - }, - { - "tfOpName": "Pack", - "category": "slice_join", - "inputs": [ - { - "start": 0, - "end": 0, - "name": "tensors", - "type": "tensors" - } - ], - "attrs": [ - { - "tfName": "axis", - "name": "axis", - "type": "number", - "defaultValue": 0 - } - ] - }, - { - "tfOpName": "Unpack", - "category": "slice_join", - "inputs": [ - { - "start": 0, - "name": "tensor", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "axis", - "name": "axis", - "type": "number", - "defaultValue": 0 - }, - { - "tfName": "num", - "name": "num", - "type": "number", - "defaultValue": 0, - "notSupported": true - } - ] - }, - { - "tfOpName": "Tile", - "category": "slice_join", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - }, - { - "start": 1, - "name": "reps", - "type": "number[]" - } - ] - }, - { - "tfOpName": "Split", - "category": "slice_join", - "inputs": [ - { - "start": 0, - "name": "axis", - "type": "number", - "defaultValue": 0 - }, - { - "start": 1, - "name": "x", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "num_split", - "name": "numOrSizeSplits", - "type": "number", - "defaultValue": 1 - } - ] - }, - { - "tfOpName": "SplitV", - "category": "slice_join", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - }, - { - "start": 1, - "name": "numOrSizeSplits", - "type": "number[]" - }, - { - "start": 2, - "name": "axis", - "type": "number", - "defaultValue": 0 - } - ] - }, - { - "tfOpName": "ScatterNd", - "category": "slice_join", - "inputs": [ - { - "start": 0, - "name": "indices", - "type": "tensor" - }, - { - "start": 1, - "name": "values", - "type": "tensor" - }, - { - "start": 2, - "name": "shape", - "type": "number[]" - } - ] - }, - { - "tfOpName": "GatherNd", - "category": "slice_join", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - }, - { - "start": 1, - "name": "indices", - "type": "tensor" - } - ] - }, - { - "tfOpName": "SparseToDense", - "category": "slice_join", - "inputs": [ - { - "start": 0, - "name": "sparseIndices", - "type": "tensor" - }, - { - "start": 1, - "name": "outputShape", - "type": "number[]" - }, - { - "start": 2, - "name": "sparseValues", - "type": "tensor" - }, - { - "start": 3, - "name": "defaultValue", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "validate_indices", - "name": "validateIndices", - "type": "bool", - "defaultValue": false, - "notSupported": true - } - ] - }, - { - "tfOpName": "TensorScatterUpdate", - "category": "slice_join", - "inputs": [ - { - "start": 0, - "name": "tensor", - "type": "tensor" - }, - { - "start": 1, - "name": "indices", - "type": "tensor" - }, - { - "start": 2, - "name": "values", - "type": "tensor" - } - ] - } -] diff --git a/tfjs-master/tfjs-converter/python/tensorflowjs/op_list/sparse.json b/tfjs-master/tfjs-converter/python/tensorflowjs/op_list/sparse.json deleted file mode 100644 index 51f98afed..000000000 --- a/tfjs-master/tfjs-converter/python/tensorflowjs/op_list/sparse.json +++ /dev/null @@ -1,99 +0,0 @@ -[ - { - "tfOpName": "SparseFillEmptyRows", - "category": "sparse", - "inputs": [ - { - "start": 0, - "name": "indices", - "type": "tensor" - }, - { - "start": 1, - "name": "values", - "type": "tensor" - }, - { - "start": 2, - "name": "denseShape", - "type": "tensor" - }, - { - "start": 3, - "name": "defaultValue", - "type": "tensor" - } - ] - }, - { - "tfOpName": "SparseReshape", - "category": "sparse", - "inputs": [ - { - "start": 0, - "name": "inputIndices", - "type": "tensor" - }, - { - "start": 1, - "name": "inputShape", - "type": "tensor" - }, - { - "start": 2, - "name": "newShape", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "T", - "name": "dtype", - "type": "dtype", - "notSupported": true - } - ] - }, - { - "tfOpName": "SparseSegmentMean", - "category": "sparse", - "inputs": [ - { - "start": 0, - "name": "data", - "type": "tensor" - }, - { - "start": 1, - "name": "indices", - "type": "tensor" - }, - { - "start": 2, - "name": "segmentIds", - "type": "tensor" - } - ] - }, - { - "tfOpName": "SparseSegmentSum", - "category": "sparse", - "inputs": [ - { - "start": 0, - "name": "data", - "type": "tensor" - }, - { - "start": 1, - "name": "indices", - "type": "tensor" - }, - { - "start": 2, - "name": "segmentIds", - "type": "tensor" - } - ] - } -] \ No newline at end of file diff --git a/tfjs-master/tfjs-converter/python/tensorflowjs/op_list/spectral.json b/tfjs-master/tfjs-converter/python/tensorflowjs/op_list/spectral.json deleted file mode 100644 index e852669f6..000000000 --- a/tfjs-master/tfjs-converter/python/tensorflowjs/op_list/spectral.json +++ /dev/null @@ -1,58 +0,0 @@ -[ - { - "tfOpName": "FFT", - "category": "spectral", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - } - ] - }, - { - "tfOpName": "IFFT", - "category": "spectral", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - } - ] - }, - { - "tfOpName": "RFFT", - "category": "spectral", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - }, - { - "start": 1, - "name": "fft_length", - "type": "number", - "notSupported": true - } - ] - }, - { - "tfOpName": "IRFFT", - "category": "spectral", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - }, - { - "start": 1, - "name": "fft_length", - "type": "number", - "notSupported": true - } - ] - } -] \ No newline at end of file diff --git a/tfjs-master/tfjs-converter/python/tensorflowjs/op_list/string.json b/tfjs-master/tfjs-converter/python/tensorflowjs/op_list/string.json deleted file mode 100644 index 1df8caba1..000000000 --- a/tfjs-master/tfjs-converter/python/tensorflowjs/op_list/string.json +++ /dev/null @@ -1,128 +0,0 @@ -[ - { - "tfOpName": "StaticRegexReplace", - "category": "string", - "inputs": [ - { - "start": 0, - "name": "input", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "pattern", - "name": "pattern", - "type": "string" - }, - { - "tfName": "rewrite", - "name": "rewrite", - "type": "string" - }, - { - "tfName": "replace_global", - "name": "replaceGlobal", - "type": "bool" - } - ] - }, - { - "tfOpName": "StringNGrams", - "category": "string", - "inputs": [ - { - "start": 0, - "name": "data", - "type": "tensor" - }, - { - "start": 1, - "name": "dataSplits", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "separator", - "name": "separator", - "type": "string" - }, - { - "tfName": "ngram_widths", - "name": "nGramWidths", - "type": "number[]" - }, - { - "tfName": "left_pad", - "name": "leftPad", - "type": "string" - }, - { - "tfName": "right_pad", - "name": "rightPad", - "type": "string" - }, - { - "tfName": "pad_width", - "name": "padWidth", - "type": "number" - }, - { - "tfName": "preserve_short_sequences", - "name": "preserveShortSequences", - "type": "bool" - } - ], - "outputs": [ - "ngrams", - "ngrams_splits" - ] - }, - { - "tfOpName": "StringSplit", - "category": "string", - "inputs": [ - { - "start": 0, - "name": "input", - "type": "tensor" - }, - { - "start": 1, - "name": "delimiter", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "skip_empty", - "name": "skipEmpty", - "type": "bool" - } - ], - "outputs": [ - "indices", - "values", - "shape" - ] - }, - { - "tfOpName": "StringToHashBucketFast", - "category": "string", - "inputs": [ - { - "start": 0, - "name": "input", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "num_buckets", - "name": "numBuckets", - "type": "number" - } - ] - } -] diff --git a/tfjs-master/tfjs-converter/python/tensorflowjs/op_list/tfdf.json b/tfjs-master/tfjs-converter/python/tensorflowjs/op_list/tfdf.json deleted file mode 100644 index 385438c00..000000000 --- a/tfjs-master/tfjs-converter/python/tensorflowjs/op_list/tfdf.json +++ /dev/null @@ -1,11 +0,0 @@ -[ - { - "tfOpName": "SimpleMLCreateModelResource" - }, - { - "tfOpName": "SimpleMLLoadModelFromPathWithHandle" - }, - { - "tfOpName": "SimpleMLInferenceOpWithHandle" - } -] diff --git a/tfjs-master/tfjs-converter/python/tensorflowjs/op_list/transformation.json b/tfjs-master/tfjs-converter/python/tensorflowjs/op_list/transformation.json deleted file mode 100644 index c3023e669..000000000 --- a/tfjs-master/tfjs-converter/python/tensorflowjs/op_list/transformation.json +++ /dev/null @@ -1,261 +0,0 @@ -[ - { - "tfOpName": "Cast", - "category": "transformation", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "SrcT", - "name": "sdtype", - "type": "dtype", - "notSupported": true - }, - { - "tfName": "DstT", - "name": "dtype", - "type": "dtype" - } - ] - }, - { - "tfOpName": "ExpandDims", - "category": "transformation", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - }, - { - "start": 1, - "name": "axis", - "type": "number" - } - ] - }, - { - "tfOpName": "MirrorPad", - "category": "transformation", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - }, - { - "start": 1, - "name": "padding", - "type": "number[]" - } - ], - "attrs": [ - { - "tfName": "mode", - "name": "mode", - "type": "string" - } - ] - }, - { - "tfOpName": "Pad", - "category": "transformation", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - }, - { - "start": 1, - "name": "padding", - "type": "number[]" - } - ], - "attrs": [ - { - "tfName": "constant_value", - "name": "constantValue", - "type": "number", - "defaultValue": 0 - } - ] - }, - { - "tfOpName": "PadV2", - "category": "transformation", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - }, - { - "start": 1, - "name": "padding", - "type": "number[]" - }, - { - "start": 2, - "name": "constantValue", - "type": "number", - "defaultValue": 0 - } - ] - }, - { - "tfOpName": "Reshape", - "category": "transformation", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - }, - { - "start": 1, - "name": "shape", - "type": "number[]" - } - ] - }, - { - "tfOpName": "EnsureShape", - "category": "transformation", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - }, - { - "start": 1, - "name": "shape", - "type": "number[]" - } - ] - }, - { - "tfOpName": "Squeeze", - "category": "transformation", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "axis", - "tfDeprecatedName": "squeeze_dims", - "name": "axis", - "type": "number[]" - } - ] - }, - { - "tfOpName": "SpaceToBatchND", - "category": "transformation", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - }, - { - "start": 1, - "name": "blockShape", - "type": "number[]" - }, - { - "start": 2, - "name": "paddings", - "type": "number[]" - } - ] - }, - { - "tfOpName": "BatchToSpaceND", - "category": "transformation", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - }, - { - "start": 1, - "name": "blockShape", - "type": "number[]" - }, - { - "start": 2, - "name": "crops", - "type": "number[]" - } - ] - }, - { - "tfOpName": "DepthToSpace", - "category": "transformation", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - } - ], - "attrs": [ - { - "tfName": "block_size", - "name": "blockSize", - "type": "number" - }, - { - "tfName": "data_format", - "name": "dataFormat", - "type": "string" - } - ] - }, - { - "tfOpName": "BroadcastTo", - "category": "transformation", - "inputs": [ - { - "start": 0, - "name": "x", - "type": "tensor" - }, - { - "start": 1, - "name": "shape", - "type": "number[]" - } - ], - "attrs": [] - }, - { - "tfOpName": "BroadcastArgs", - "category": "transformation", - "inputs": [ - { - "start": 0, - "name": "s0", - "type": "tensor" - }, - { - "start": 1, - "name": "s1", - "type": "tensor" - } - ], - "attrs": [] - } -] diff --git a/tfjs-master/tfjs-converter/python/tensorflowjs/quantization.py b/tfjs-master/tfjs-converter/python/tensorflowjs/quantization.py deleted file mode 100644 index 93fa83767..000000000 --- a/tfjs-master/tfjs-converter/python/tensorflowjs/quantization.py +++ /dev/null @@ -1,216 +0,0 @@ -# Copyright 2018 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================== -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -import fnmatch -import numpy as np - -QUANTIZATION_DTYPE_FLOAT16 = 'float16' -QUANTIZATION_DTYPE_UINT8 = 'uint8' -QUANTIZATION_DTYPE_UINT16 = 'uint16' - -QUANTIZATION_BYTES_TO_DTYPES = {1: QUANTIZATION_DTYPE_UINT8, - 2: QUANTIZATION_DTYPE_UINT16} -QUANTIZATION_OPTION_TO_DTYPES = {QUANTIZATION_DTYPE_UINT8: np.uint8, - QUANTIZATION_DTYPE_UINT16: np.uint16, - QUANTIZATION_DTYPE_FLOAT16: np.float16} - - -def map_layers_to_quantization_dtype(names, quantization_dtype_map): - """Maps node names to their quantization dtypes. - - Given a quantization_dtype_map which maps dtypes `uint8`, `uint16`, `float16` - to node patterns, e.g., conv/*/weights we construct a new mapping for each - individual node name to its dtype, e.g., conv/1/weight -> `uint8`. - A dtype in the map can also be a boolean, signaling a fallthrough dtype. - There can only be one fallthrough dtype in the map. A fallthrough dtype - will convert all weights that don't match any pattern to the provided dtype. - - Args: - names: Array of node names. - quantization_dtype_map: A mapping from dtype (`uint8`, `uint16`, `float16`) - to weights. The weight mapping supports wildcard substitution. - - Returns: - quantization_dtype: A mapping from each node name which matches - an entry in quantization_dtype_map to its corresponding dtype. - - Raises: - ValueError: - If multiple dtypes match the same node name - - If more than one fallthrough is provided - """ - if quantization_dtype_map is None: - return {} - - fallthrough = None - quantization_dtype = {} - for dtype_name, patterns in quantization_dtype_map.items(): - # Record fallthrough if there is one - if isinstance(patterns, bool) and patterns: - # Only one fallthrough is supported - if fallthrough is not None: - raise ValueError( - 'More than one quantization fallthrough provided, ' - 'exactly one is supported') - fallthrough = dtype_name - continue - if isinstance(patterns, str): - patterns = list([patterns]) - - # Record matched weights for dtype - for pattern in patterns: - for match in fnmatch.filter(names, pattern): - dtype = QUANTIZATION_OPTION_TO_DTYPES[dtype_name] - if match in quantization_dtype and quantization_dtype[match] != dtype: - raise ValueError( - 'Two quantization values %s, %s match the same node %s' % - (dtype, quantization_dtype[match], match)) - quantization_dtype[match] = dtype - - # Catch all remaining names with fallthrough - if fallthrough is not None: - nameset = set(names) - fallthrough_names = nameset - set(quantization_dtype.keys()) - for name in fallthrough_names: - quantization_dtype[name] = QUANTIZATION_OPTION_TO_DTYPES[fallthrough] - - return quantization_dtype - -def quantize_weights(data, quantization_dtype): - """Quantizes the weights by linearly re-scaling across available bits. - - The weights are quantized by linearly re-scaling the values between the - minimum and maximum value, and representing them with the number of bits - provided by the `quantization_dtype`. - - In order to guarantee that 0 is perfectly represented by one of the quantized - values, the range is "nudged" in the same manner as in TF-Lite. - - Weights can be de-quantized by multiplying by the returned `scale` and adding - `min`. - - Args: - data: A numpy array of dtype 'float32' or 'int32'. - quantization_dtype: A numpy dtype to quantize weights to. Only np.float16, - np.uint8, and np.uint16 are supported. - - Returns: - quantized_data: The quantized weights as a numpy array with dtype - `quantization_dtype`. - metadata: A dictionary with the corresponding metadata for the quantization - type. There is no metadata associated with float16. - For affine quantization there are two associated metadata values: - scale: The linearly scaling constant used for quantization. - min_val: The minimum value of the linear range. - Raises: - ValueError: if `quantization_dtype` is not a valid type. - """ - if quantization_dtype in [np.uint8, np.uint16]: - # Compute the min and max for the group. - min_val = data.min().astype(np.float64) - max_val = data.max().astype(np.float64) - if min_val == max_val: - # If there is only a single value, we can represent everything as zeros. - quantized_data = np.zeros_like(data, dtype=quantization_dtype) - scale = 1.0 - else: - # Quantize data. - scale, min_val, max_val = _get_affine_quantization_range( - min_val, max_val, quantization_dtype) - quantized_data = np.round( - (data.clip(min_val, max_val) - min_val) / scale).astype( - quantization_dtype) - - return quantized_data, {'min': min_val, 'scale': scale} - elif quantization_dtype == np.float16: - if data.dtype != np.float32: - raise ValueError( - 'Invalid data dtype %r\n' - 'float16 quantization only supports float32 dtype' % data.dtype) - quantized_data = data.astype(np.float16) - return quantized_data, {} - else: - raise ValueError('Invalid `quantization_dtype`: %r' % quantization_dtype) - - - -def dequantize_weights(data, metadata, original_dtype=np.float32): - dtype = data.dtype - - if dtype in [np.uint8, np.uint16]: - if not ('scale' in metadata and 'min' in metadata): - raise ValueError( - 'Missing metadata min or scale for dtype %s' % dtype.name) - scale = metadata['scale'] - min_val = metadata['min'] - if original_dtype == np.int32: - return np.round(data * scale + min_val).astype(original_dtype) - else: - return (data * scale + min_val).astype(original_dtype) - elif dtype == np.float16: - if original_dtype != np.float32: - raise ValueError( - 'Invalid data dtype %r\n' - 'float16 quantization only supports float32 dtype' % data.dtype) - return data.astype(original_dtype) - else: - raise ValueError( - 'Invalid dtype %s for dequantization\n' - 'Supported dtypes are uint8, uint16, float16' % dtype.name) - -def _get_affine_quantization_range(min_val, max_val, quantization_dtype): - """Computes quantization range to ensure that zero is represented if covered. - - Gymnastics with nudged zero point is to ensure that real zero maps to an - integer, which is required for e.g. zero-padding in convolutional layers. - - Based on `NudgeQuantizationRange` in - tensorflow/contrib/lite/kernels/internal/quantization_util.h, except we do not - nudge if 0 is not in the range. - - Args: - min_val: The actual minimum value of the data. - max_val: The actual maximum value of the data. - quantization_dtype: A numpy dtype to quantize weights to. Only np.uint8 and - np.uint16 are supported. - - Returns: - scale: The linear scaling constant used for quantization. - nudged_min: The adjusted minimum value to ensure zero is represented, if - covered. - nudged_max: The adjusted maximum value to ensure zero is represented, if - covered. - Raises: - ValueError: if `quantization_dtype` is not a valid type. - """ - if quantization_dtype not in [np.uint8, np.uint16]: - raise ValueError('Invalid `quantization_dtype`: %r' % quantization_dtype) - - quant_max = np.iinfo(quantization_dtype).max - scale = (max_val - min_val) / quant_max - - if min_val <= 0 <= max_val: - quantized_zero_point = (0 - min_val) / scale - nudged_zero_point = np.round(quantized_zero_point) - - # Solve `0 = nudged_zero_point * scale + nudged_min` for `nudged_min`. - nudged_min = -nudged_zero_point * scale - nudged_max = quant_max * scale + nudged_min - else: - nudged_min, nudged_max = min_val, max_val - - return scale, nudged_min, nudged_max diff --git a/tfjs-master/tfjs-converter/python/tensorflowjs/quantization_test.py b/tfjs-master/tfjs-converter/python/tensorflowjs/quantization_test.py deleted file mode 100644 index caab4415f..000000000 --- a/tfjs-master/tfjs-converter/python/tensorflowjs/quantization_test.py +++ /dev/null @@ -1,253 +0,0 @@ -# Copyright 2018 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================== -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -import unittest - -import numpy as np - -from tensorflowjs import quantization - -class TestQuantizationUtil(unittest.TestCase): - - def assertDictContainsSubsetAlmostEqual(self, d1, d2): - self.assertIsInstance(d1, dict) - self.assertIsInstance(d2, dict) - - d1_keys = set(d1.keys()) - d2_keys = set(d2.keys()) - - self.assertTrue(d2_keys.issubset(d1_keys)) - - for key in d2_keys: - self.assertAlmostEqual(d1[key], d2[key]) - - - def _runQuantizeTest( - self, range_min, range_max, data_dtype, quantization_dtype, - expected_metadata): - d = np.arange(range_min, range_max + 1, dtype=data_dtype) - q, metadata = quantization.quantize_weights(d, quantization_dtype) - - self.assertDictContainsSubsetAlmostEqual(metadata, expected_metadata) - self.assertEqual(q.dtype, quantization_dtype) - - de_q = quantization.dequantize_weights( - q, metadata, data_dtype) - if data_dtype != np.float32: - np.testing.assert_allclose(de_q, d) - else: - np.testing.assert_array_almost_equal(de_q, d, decimal=2) - - if quantization_dtype in [np.uint8, np.uint16]: - s = metadata['scale'] - m = metadata['min'] - if range_min <= 0 <= range_max: - d_0 = np.zeros(1, data_dtype) - q_0 = np.round((d_0 - m) / s).astype(quantization_dtype) - self.assertEqual( - quantization.dequantize_weights(q_0, metadata, data_dtype), d_0) - - def testAffineQuantizeAllEqual(self): - d = np.ones(5, dtype=np.float32) - q, metadata = quantization.quantize_weights(d, np.uint8) - assert 'scale' in metadata and 'min' in metadata - self.assertEqual(metadata['scale'], 1.0) - self.assertEqual(q.dtype, np.uint8) - - de_q = quantization.dequantize_weights(q, metadata, np.float32) - np.testing.assert_array_equal(de_q, d) - - def testFloatQuantizeAllEqual(self): - d = np.ones(5, dtype=np.float32) - q, metadata = quantization.quantize_weights(d, np.float16) - self.assertDictEqual(metadata, {}) - - self.assertEqual(q.dtype, np.float16) - de_q = quantization.dequantize_weights(q, metadata, np.float32) - np.testing.assert_array_equal(de_q, d) - - def testAffineQuantizeNegativeFloats(self): - self._runQuantizeTest( - -3, -1, np.float32, np.uint8, - expected_metadata={'scale': 2/255}) - self._runQuantizeTest( - -3, -1, np.float32, np.uint16, - expected_metadata={'scale': 2/65536}) - - def testAffineQuantizeNegativeAndZeroFloats(self): - self._runQuantizeTest( - -3, 0, np.float32, np.uint8, - expected_metadata={'scale': 3/255}) - self._runQuantizeTest( - -3, 0, np.float32, np.uint16, - expected_metadata={'scale': 3/65536}) - - def testAffineQuantizeNegativeAndPositiveFloats(self): - self._runQuantizeTest( - -3, 3, np.float32, np.uint8, - expected_metadata={'scale': 6/255}) - self._runQuantizeTest( - -3, 3, np.float32, np.uint16, - expected_metadata={'scale': 6/65536}) - - def testAffineQuantizeZeroAndPositiveFloats(self): - self._runQuantizeTest( - 0, 3, np.float32, np.uint8, - expected_metadata={'scale': 3/255}) - self._runQuantizeTest( - 0, 3, np.float32, np.uint16, - expected_metadata={'scale': 3/65536}) - - def testAffineQuantizePositiveFloats(self): - self._runQuantizeTest( - 1, 3, np.float32, np.uint8, - expected_metadata={'scale': 2/255}) - self._runQuantizeTest( - 1, 3, np.float32, np.uint16, - expected_metadata={'scale': 2/65536}) - - def testAffineQuantizeNormalizedFloats(self): - data = np.array( - [-0.29098126, -0.24776903, -0.27248842, 0.23848203], dtype=np.float32) - q, metadata = quantization.quantize_weights(data, np.uint16) - de_q = quantization.dequantize_weights(q, metadata, data.dtype) - np.testing.assert_array_almost_equal(de_q, data, decimal=5) - - def testAffineQuantizeNegativeInts(self): - self._runQuantizeTest( - -3, -1, np.int32, np.uint8, - expected_metadata={'scale': 2/255}) - self._runQuantizeTest( - -3, -1, np.int32, np.uint16, - expected_metadata={'scale': 2/65536}) - - def testAffineQuantizeNegativeAndZeroInts(self): - self._runQuantizeTest( - -3, 0, np.int32, np.uint8, - expected_metadata={'scale': 3/255}) - self._runQuantizeTest( - -3, 0, np.int32, np.uint16, - expected_metadata={'scale': 3/65536}) - - def testAffineQuantizeNegativeAndPositiveInts(self): - self._runQuantizeTest( - -3, 3, np.int32, np.uint8, - expected_metadata={'scale': 6/255}) - self._runQuantizeTest( - -3, 3, np.int32, np.uint16, - expected_metadata={'scale': 6/65536}) - - def testAffineQuantizeZeroAndPositiveInts(self): - self._runQuantizeTest( - 0, 3, np.int32, np.uint8, - expected_metadata={'scale': 3/255}) - self._runQuantizeTest( - 0, 3, np.int32, np.uint16, - expected_metadata={'scale': 3/65536}) - - def testAffineQuantizePositiveInts(self): - self._runQuantizeTest( - 1, 3, np.int32, np.uint8, - expected_metadata={'scale': 2/255}) - self._runQuantizeTest( - 1, 3, np.int32, np.uint16, - expected_metadata={'scale': 2/65536}) - - def testInvalidQuantizationTypes(self): - # Invalid quantization type - with self.assertRaises(ValueError): - quantization.quantize_weights(np.array([]), bool) - - # Invalid data dtype for float16 quantization - with self.assertRaises(ValueError): - d = np.ones(1, dtype=np.int32) - quantization.quantize_weights(d, np.float16) - - def testInvalidDequantizationTypes(self): - # Invalid metadata for affine quantization - with self.assertRaises(ValueError): - d = np.ones(1, dtype=np.uint8) - quantization.dequantize_weights(np.array([]), {}) - - # Invalid target dtype for float16 quantization - with self.assertRaises(ValueError): - d = np.ones(1, dtype=np.float16) - quantization.dequantize_weights(d, {}, np.int32) - - # Invalid dequantization type - with self.assertRaises(ValueError): - d = np.ones(1, dtype=bool) - quantization.dequantize_weights(d, {}) - - def testMapLayerFallthrough(self): - names = ['conv/0/weight', 'conv/0/bias', 'conv/1/weight', 'conv/1/bias'] - quantization_dtype_map = {'float16': ['conv/0/*'], 'uint8': True} - dtype_map = quantization.map_layers_to_quantization_dtype( - names, quantization_dtype_map) - - self.assertDictEqual(dtype_map, { - 'conv/0/weight': np.float16, - 'conv/0/bias': np.float16, - 'conv/1/weight': np.uint8, - 'conv/1/bias': np.uint8 - }) - - def testMapLayerConflictingMap(self): - names = ['conv/0/weight', 'conv/0/bias', 'conv/1/weight', 'conv/1/bias'] - quantization_dtype_map = {'float16': ['conv/0/*'], 'uint8': ['conv/0/bias']} - - with self.assertRaises(ValueError): - quantization.map_layers_to_quantization_dtype( - names, quantization_dtype_map) - - - def testMapLayerStringToList(self): - names = ['conv/0/weight', 'conv/0/bias', 'conv/1/weight', 'conv/1/bias'] - quantization_dtype_map = {'float16': '*'} - - - dtype_map = quantization.map_layers_to_quantization_dtype( - names, quantization_dtype_map) - - self.assertDictEqual(dtype_map, { - 'conv/0/weight': np.float16, - 'conv/0/bias': np.float16, - 'conv/1/weight': np.float16, - 'conv/1/bias': np.float16 - }) - - def testMapLayerNoDtypeMap(self): - names = ['conv/0/weight', 'conv/0/bias', 'conv/1/weight', 'conv/1/bias'] - quantization_dtype_map = {} - dtype_map = quantization.map_layers_to_quantization_dtype( - names, quantization_dtype_map) - - self.assertDictEqual(dtype_map, {}) - - def testMapLayerExactlyOneFallthrough(self): - names = ['conv/0/weight', 'conv/0/bias', 'conv/1/weight', 'conv/1/bias'] - quantization_dtype_map = {'float16': True, 'uint8': True} - - with self.assertRaises(ValueError): - quantization.map_layers_to_quantization_dtype( - names, quantization_dtype_map) - - - -if __name__ == '__main__': - unittest.main() diff --git a/tfjs-master/tfjs-converter/python/tensorflowjs/read_weights.py b/tfjs-master/tfjs-converter/python/tensorflowjs/read_weights.py deleted file mode 100644 index ee8d7b96d..000000000 --- a/tfjs-master/tfjs-converter/python/tensorflowjs/read_weights.py +++ /dev/null @@ -1,202 +0,0 @@ -# Copyright 2018 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================== -"""Read weights stored in TensorFlow.js-format binary files.""" - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -import io -import os - -import numpy as np -from tensorflowjs import quantization - -_INPUT_DTYPES = [np.float16, np.float32, np.int32, np.complex64, - np.uint8, np.uint16, object, bool] - -# Number of bytes used to encode the length of a string in a string tensor. -STRING_LENGTH_NUM_BYTES = 4 -# The data type used to encode the length of a string in a string tensor. -STRING_LENGTH_DTYPE = np.dtype('uint32').newbyteorder('<') - -def read_weights(weights_manifest, base_path, flatten=False): - """Load weight values according to a TensorFlow.js weights manifest. - - Args: - weights_manifest: A TensorFlow.js-format weights manifest (a JSON array). - base_path: Base path prefix for the weights files. - flatten: Whether all the weight groups in the return value are to be - flattened as a single weights group. Default: `False`. - - Returns: - If `flatten` is `False`, a `list` of weight groups. Each group is an array - of weight entries. Each entry is a dict that maps a unique name to a numpy - array, for example: - entry = { - 'name': 'weight1', - 'data': np.array([1, 2, 3], 'float32') - } - - Weights groups would then look like: - weight_groups = [ - [group_0_entry1, group_0_entry2], - [group_1_entry1, group_1_entry2], - ] - If `flatten` is `True`, returns a single weight group. - """ - if not isinstance(weights_manifest, list): - raise ValueError( - 'weights_manifest should be a `list`, but received %s' % - type(weights_manifest)) - - data_buffers = [] - for group in weights_manifest: - buff = io.BytesIO() - buff_writer = io.BufferedWriter(buff) - for path in group['paths']: - with open(os.path.join(base_path, path), 'rb') as f: - buff_writer.write(f.read()) - buff_writer.flush() - buff_writer.seek(0) - data_buffers.append(buff.read()) - return decode_weights(weights_manifest, data_buffers, flatten=flatten) - - -def _deserialize_string_array(data_buffer, offset, shape): - """Deserializes bytes into np.array of dtype `object` which holds strings. - - Each string value is preceded by 4 bytes which denote a 32-bit unsigned - integer in little endian that specifies the byte length of the following - string. This is followed by the actual string bytes. If the tensor has no - strings there will be no bytes reserved. Empty strings will still take 4 bytes - for the length. - - For example, a tensor that has 2 strings will be encoded as - [byte length of s1][bytes of s1...][byte length of s2][bytes of s2...] - - where byte length always takes 4 bytes. - - Args: - data_buffer: A buffer of bytes containing the serialized data. - offset: The byte offset in that buffer that denotes the start of the tensor. - shape: The logical shape of the tensor. - - Returns: - A tuple of (np.array, offset) where the np.array contains the encoded - strings, and the offset contains the new offset (the byte position in the - buffer at the end of the string data). - """ - size = int(np.prod(shape)) - if size == 0: - return (np.array([], 'object').reshape(shape), - offset + STRING_LENGTH_NUM_BYTES) - vals = [] - for _ in range(size): - byte_length = np.frombuffer( - data_buffer[offset:offset + STRING_LENGTH_NUM_BYTES], - STRING_LENGTH_DTYPE)[0] - offset += STRING_LENGTH_NUM_BYTES - string = data_buffer[offset:offset + byte_length] - vals.append(string) - offset += byte_length - return np.array(vals, 'object').reshape(shape), offset - - -def _deserialize_numeric_array(data_buffer, offset, dtype, shape): - weight_numel = 1 - for dim in shape: - weight_numel *= dim - return np.frombuffer( - data_buffer, dtype=dtype, count=weight_numel, - offset=offset).reshape(shape) - -def decode_weights(weights_manifest, data_buffers, flatten=False): - """Load weight values from buffer(s) according to a weights manifest. - - Args: - weights_manifest: A TensorFlow.js-format weights manifest (a JSON array). - data_buffers: A buffer or a `list` of buffers containing the weights values - in binary format, concatenated in the order specified in - `weights_manifest`. If a `list` of buffers, the length of the `list` - must match the length of `weights_manifest`. A single buffer is - interpreted as a `list` of one buffer and is valid only if the length of - `weights_manifest` is `1`. - flatten: Whether all the weight groups in the return value are to be - flattened as a single weight groups. Default: `False`. - - Returns: - If `flatten` is `False`, a `list` of weight groups. Each group is an array - of weight entries. Each entry is a dict that maps a unique name to a numpy - array, for example: - entry = { - 'name': 'weight1', - 'data': np.array([1, 2, 3], 'float32') - } - - Weights groups would then look like: - weight_groups = [ - [group_0_entry1, group_0_entry2], - [group_1_entry1, group_1_entry2], - ] - If `flatten` is `True`, returns a single weight group. - - Raises: - ValueError: if the lengths of `weights_manifest` and `data_buffers` do not - match. - """ - if not isinstance(data_buffers, list): - data_buffers = [data_buffers] - if len(weights_manifest) != len(data_buffers): - raise ValueError( - 'Mismatch in the length of weights_manifest (%d) and the length of ' - 'data buffers (%d)' % (len(weights_manifest), len(data_buffers))) - - out = [] - for group, data_buffer in zip(weights_manifest, data_buffers): - offset = 0 - out_group = [] - - for weight in group['weights']: - quant_info = weight.get('quantization', None) - name = weight['name'] - if weight['dtype'] == 'string': - # String array. - dtype = object - elif quant_info: - # Quantized array. - dtype = np.dtype(quant_info['dtype']) - else: - # Regular numeric array. - dtype = np.dtype(weight['dtype']) - shape = weight['shape'] - if dtype not in _INPUT_DTYPES: - raise NotImplementedError('Unsupported data type: %s' % dtype) - if weight['dtype'] == 'string': - value, offset = _deserialize_string_array(data_buffer, offset, shape) - else: - value = _deserialize_numeric_array(data_buffer, offset, dtype, shape) - offset += dtype.itemsize * value.size - if quant_info: - value = quantization.dequantize_weights( - value, quant_info, np.dtype(weight['dtype'])) - out_group.append({'name': name, 'data': value}) - - if flatten: - out += out_group - else: - out.append(out_group) - - return out diff --git a/tfjs-master/tfjs-converter/python/tensorflowjs/read_weights_test.py b/tfjs-master/tfjs-converter/python/tensorflowjs/read_weights_test.py deleted file mode 100644 index 9e9d46ec6..000000000 --- a/tfjs-master/tfjs-converter/python/tensorflowjs/read_weights_test.py +++ /dev/null @@ -1,406 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2018 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================== - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -import os -import shutil - -import tempfile - -import numpy as np -import tensorflow as tf - -from tensorflowjs import read_weights -from tensorflowjs import write_weights - - -class ReadWeightsTest(tf.test.TestCase): - def setUp(self): - self._tmp_dir = tempfile.mkdtemp() - super(ReadWeightsTest, self).setUp() - - def tearDown(self): - if os.path.isdir(self._tmp_dir): - shutil.rmtree(self._tmp_dir) - super(ReadWeightsTest, self).tearDown() - - def testReadOneGroup(self): - groups = [ - [{ - 'name': 'weight1', - 'data': np.array([1, 2, 3], 'float32') - }, { - 'name': 'weight2', - 'data': np.array([1 + 1j, 2 + 2j, 3 + 3j]) - }] - ] - - manifest = write_weights.write_weights(groups, self._tmp_dir) - - # Read the weights using `read_weights`. - read_output = read_weights.read_weights(manifest, self._tmp_dir) - self.assertEqual(1, len(read_output)) - self.assertEqual(2, len(read_output[0])) - self.assertEqual('weight1', read_output[0][0]['name']) - self.assertTrue( - np.allclose(groups[0][0]['data'], read_output[0][0]['data'])) - self.assertEqual('weight2', read_output[0][1]['name']) - self.assertTrue( - np.allclose(groups[0][1]['data'], read_output[0][1]['data'])) - def testReadOneGroupString(self): - groups = [ - [{ - 'name': 'weight1', - 'data': np.array([['test', 'a'], ['b', 'c']], 'object') - }] - ] - - manifest = write_weights.write_weights(groups, self._tmp_dir) - - # Read the weights using `read_weights`. - read_output = read_weights.read_weights(manifest, self._tmp_dir) - self.assertEqual(1, len(read_output)) - self.assertEqual(1, len(read_output[0])) - self.assertEqual('weight1', read_output[0][0]['name']) - np.testing.assert_array_equal( - read_output[0][0]['data'], - np.array([[u'test'.encode('utf-8'), u'a'.encode('utf-8')], - [u'b'.encode('utf-8'), u'c'.encode('utf-8')]], 'object')) - - - def testReadCyrillicStringUnicodeAndEncoded(self): - groups = [ - [{ - 'name': 'weight1', - # String is stored as unicode. - 'data': np.array([u'здраво'], 'object') - }, { - 'name': 'weight2', - # String is stored encoded. - 'data': np.array([u'поздрав'.encode('utf-8')], 'object') - }, { - 'name': 'weight3', - # Let np choose the dtype (string or bytes depending on py version). - 'data': np.array([u'здраво'.encode('utf-8')]) - }] - ] - - manifest = write_weights.write_weights(groups, self._tmp_dir) - - # Read the weights using `read_weights`. - read_output = read_weights.read_weights(manifest, self._tmp_dir) - self.assertEqual(1, len(read_output)) - group = read_output[0] - self.assertEqual(3, len(group)) - - weight1 = group[0] - self.assertEqual('weight1', weight1['name']) - np.testing.assert_array_equal( - weight1['data'], - np.array([u'здраво'.encode('utf-8')], 'object')) - - weight2 = group[1] - self.assertEqual('weight2', weight2['name']) - np.testing.assert_array_equal( - weight2['data'], - np.array([u'поздрав'.encode('utf-8')], 'object')) - - weight3 = group[2] - self.assertEqual('weight3', weight3['name']) - np.testing.assert_array_equal( - weight3['data'], - np.array([u'здраво'.encode('utf-8')])) - - def testReadEastAsianStringUnicodeAndEncoded(self): - # Each string tensor uses different encoding. - groups = [ - [{ - 'name': 'weight1', - # Decoded. - 'data': np.array([u'语言处ç†'], 'object') - }, { - 'name': 'weight2', - # Encoded as utf-16. - 'data': np.array([u'语言处ç†'.encode('utf-16')], 'object') - }, { - 'name': 'weight3', - # Encoded as utf-8. - 'data': np.array([u'语言处ç†'.encode('utf-8')], 'object') - }] - ] - - manifest = write_weights.write_weights(groups, self._tmp_dir) - - # Read the weights using `read_weights`. - read_output = read_weights.read_weights(manifest, self._tmp_dir) - self.assertEqual(1, len(read_output)) - group = read_output[0] - self.assertEqual(3, len(group)) - - weight1 = group[0] - self.assertEqual('weight1', weight1['name']) - np.testing.assert_array_equal( - weight1['data'], - np.array([u'语言处ç†'.encode('utf-8')], 'object')) - - weight2 = group[1] - self.assertEqual('weight2', weight2['name']) - np.testing.assert_array_equal( - weight2['data'], - np.array([u'语言处ç†'.encode('utf-16')], 'object')) - - weight3 = group[2] - self.assertEqual('weight3', weight3['name']) - np.testing.assert_array_equal( - weight3['data'], - np.array([u'语言处ç†'.encode('utf-8')], 'object')) - - def testReadOneGroupStringWithShards(self): - groups = [ - [{ - 'name': 'weight1', - 'data': np.array(['test', 'a', 'c'], 'object') - }] - ] - - manifest = write_weights.write_weights(groups, self._tmp_dir, - shard_size_bytes=4) - - # Read the weights using `read_weights`. - read_output = read_weights.read_weights(manifest, self._tmp_dir) - self.assertEqual(1, len(read_output)) - self.assertEqual(1, len(read_output[0])) - self.assertEqual('weight1', read_output[0][0]['name']) - np.testing.assert_array_equal(read_output[0][0]['data'], - np.array([u'test'.encode('utf-8'), - u'a'.encode('utf-8'), - u'c'.encode('utf-8')], 'object')) - - def testReadOneGroupEmptyStrings(self): - groups = [ - [{ - 'name': 'weight1', - 'data': np.array(['', ''], 'object') - }, { - 'name': 'weight2', - 'data': np.array([], 'object') - }, { - 'name': 'weight3', - 'data': np.array([[]], 'object') - }] - ] - - manifest = write_weights.write_weights(groups, self._tmp_dir) - - # Read the weights using `read_weights`. - read_output = read_weights.read_weights(manifest, self._tmp_dir) - self.assertEqual(1, len(read_output)) - group = read_output[0] - self.assertEqual(3, len(group)) - - weight1 = group[0] - self.assertEqual('weight1', weight1['name']) - np.testing.assert_array_equal( - weight1['data'], - np.array([u''.encode('utf-8'), u''.encode('utf-8')], 'object')) - - weight2 = group[1] - self.assertEqual('weight2', weight2['name']) - np.testing.assert_array_equal( - weight2['data'], - np.array([], 'object')) - - weight3 = group[2] - self.assertEqual('weight3', weight3['name']) - np.testing.assert_array_equal( - weight3['data'], - np.array([[]], 'object')) - - def testReadOneGroupFlattened(self): - groups = [ - [{ - 'name': 'weight1', - 'data': np.array([1, 2, 3], 'float32') - }] - ] - - manifest = write_weights.write_weights(groups, self._tmp_dir) - - # Read the weights using `read_weights`. - read_output = read_weights.read_weights( - manifest, self._tmp_dir, flatten=True) - self.assertEqual(1, len(read_output)) - self.assertEqual('weight1', read_output[0]['name']) - self.assertTrue(np.allclose(groups[0][0]['data'], read_output[0]['data'])) - - def testReadOneGroupWithInt32DataFlattened(self): - groups = [ - [{ - 'name': 'weight1', - 'data': np.array([1, 2, 3], 'float32') - }, { - 'name': 'weight2', - 'data': np.array([10, 20, 30], 'int32') - }] - ] - - manifest = write_weights.write_weights(groups, self._tmp_dir) - - # Read the weights using `read_weights`. - read_output = read_weights.read_weights( - manifest, self._tmp_dir, flatten=True) - self.assertEqual(2, len(read_output)) - self.assertEqual('weight1', read_output[0]['name']) - self.assertTrue(np.allclose(groups[0][0]['data'], read_output[0]['data'])) - self.assertEqual('weight2', read_output[1]['name']) - self.assertTrue(np.allclose(groups[0][1]['data'], read_output[1]['data'])) - - def testReadTwoGroupsFlattend(self): - groups = [ - [{ - 'name': 'weight1', - 'data': np.array([1, 2, 3], 'float32') - }], - [{ - 'name': 'weight2', - 'data': np.array([10, 20, 30], 'int32') - }] - ] - - manifest = write_weights.write_weights(groups, self._tmp_dir) - - # Read the weights using `read_weights`. - read_output = read_weights.read_weights( - manifest, self._tmp_dir, flatten=True) - self.assertEqual(2, len(read_output)) - self.assertEqual('weight1', read_output[0]['name']) - self.assertTrue(np.allclose(groups[0][0]['data'], read_output[0]['data'])) - self.assertEqual('weight2', read_output[1]['name']) - self.assertTrue(np.allclose(groups[1][0]['data'], read_output[1]['data'])) - - def testReadOneGroupWithShards(self): - groups = [ - [{ - 'name': 'weight1', - 'data': np.random.rand(1, 100).astype(np.float32) - }] - ] - - manifest = write_weights.write_weights(groups, self._tmp_dir) - - # Read the weights using `read_weights`. - read_output = read_weights.read_weights(manifest, self._tmp_dir) - self.assertEqual(1, len(read_output)) - self.assertEqual(1, len(read_output[0])) - self.assertEqual('weight1', read_output[0][0]['name']) - self.assertTrue( - np.allclose(groups[0][0]['data'], read_output[0][0]['data'])) - - def testReadWeightsWithIncorrectTypeInWeightsManifestRaisesError(self): - groups = [ - [{ - 'name': 'weight1', - 'data': np.random.rand(1, 100).astype(np.float32) - }] - ] - - write_weights.write_weights(groups, self._tmp_dir) - - with self.assertRaises(ValueError): - read_weights.read_weights(groups[0][0], self._tmp_dir) - - - def testReadAffineQuantizedWeights(self): - groups = [ - [{ - 'name': 'weight1', - 'data': np.array([0, 1, 2, 3], 'float32') - }] - ] - - manifest = write_weights.write_weights( - groups, self._tmp_dir, quantization_dtype_map={'uint8': '*'}) - - # Read the weights using `read_weights`. - read_output = read_weights.read_weights(manifest, self._tmp_dir) - self.assertEqual(1, len(read_output)) - self.assertEqual(1, len(read_output[0])) - self.assertEqual('weight1', read_output[0][0]['name']) - self.assertEqual(read_output[0][0]['data'].dtype, np.float32) - self.assertTrue( - np.allclose(groups[0][0]['data'], read_output[0][0]['data'])) - - def testReadFloat16QuantizedWeights(self): - groups = [ - [{ - 'name': 'weight1', - 'data': np.array([0, 1, 2, 3], 'float32') - }] - ] - - manifest = write_weights.write_weights( - groups, self._tmp_dir, quantization_dtype_map={'float16': '*'}) - - # Read the weights using `read_weights`. - read_output = read_weights.read_weights(manifest, self._tmp_dir) - self.assertEqual(1, len(read_output)) - self.assertEqual(1, len(read_output[0])) - self.assertEqual('weight1', read_output[0][0]['name']) - self.assertEqual(read_output[0][0]['data'].dtype, np.float32) - self.assertTrue( - np.allclose(groups[0][0]['data'], read_output[0][0]['data'])) - - def testReadBoolWeights(self): - groups = [ - [{ - 'name': 'weight1', - 'data': np.array([True, False, True], 'bool') - }] - ] - - manifest = write_weights.write_weights(groups, self._tmp_dir) - - # Read the weights using `read_weights`. - read_output = read_weights.read_weights(manifest, self._tmp_dir) - self.assertEqual(1, len(read_output)) - self.assertEqual(1, len(read_output[0])) - self.assertEqual('weight1', read_output[0][0]['name']) - np.testing.assert_array_equal(read_output[0][0]['data'], - np.array([True, False, True], 'bool')) - - def testReadStringScalar(self): - groups = [ - [{ - 'name': 'weight1', - 'data': np.array(u'abc'.encode('utf-8'), 'object') - }] - ] - - manifest = write_weights.write_weights(groups, self._tmp_dir) - - # Read the weights using `read_weights`. - read_output = read_weights.read_weights(manifest, self._tmp_dir) - self.assertEqual(1, len(read_output)) - self.assertEqual(1, len(read_output[0])) - self.assertEqual('weight1', read_output[0][0]['name']) - np.testing.assert_array_equal(read_output[0][0]['data'], - np.array(u'abc'.encode('utf-8'), 'object')) - -if __name__ == '__main__': - tf.test.main() diff --git a/tfjs-master/tfjs-converter/python/tensorflowjs/resource_loader.py b/tfjs-master/tfjs-converter/python/tensorflowjs/resource_loader.py deleted file mode 100644 index 645fac394..000000000 --- a/tfjs-master/tfjs-converter/python/tensorflowjs/resource_loader.py +++ /dev/null @@ -1,53 +0,0 @@ -# Copyright 2019 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================== -"""Resource management library.""" - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -import os - - -def open_file(path): - """Opens the file at given path, where path is relative to tensorflowjs/. - - Args: - path: a string resource path relative to tensorflowjs/. - - Returns: - An open file of that resource. - - Raises: - IOError: If the path is not found, or the resource can't be opened. - """ - path = os.path.join(os.path.dirname(os.path.abspath(__file__)), path) - return open(path) - - -def list_dir(path): - """List the files inside a dir where path is relative to tensorflowjs/. - - Args: - path: a string path to a resource directory relative to tensorflowjs/. - - Returns: - A list of files inside that directory. - - Raises: - IOError: If the path is not found, or the resource can't be read. - """ - path = os.path.join(os.path.dirname(os.path.abspath(__file__)), path) - return os.listdir(path) diff --git a/tfjs-master/tfjs-converter/python/tensorflowjs/resource_loader_test.py b/tfjs-master/tfjs-converter/python/tensorflowjs/resource_loader_test.py deleted file mode 100644 index 28761065b..000000000 --- a/tfjs-master/tfjs-converter/python/tensorflowjs/resource_loader_test.py +++ /dev/null @@ -1,47 +0,0 @@ -# Copyright 2019 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================== - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -import json -import unittest -from os import path - -from tensorflowjs import resource_loader - -class ResourceLoaderTest(unittest.TestCase): - - def testListingFilesInOpList(self): - files = resource_loader.list_dir('op_list') - self.assertGreater(len(files), 0) - for filename in files: - self.assertTrue(filename == 'BUILD' or filename.endswith('.json')) - - def testReadingFileInOpList(self): - file_path = path.join('op_list', 'arithmetic.json') - with resource_loader.open_file(file_path) as f: - data = json.load(f) - first_op = data[0] - self.assertIn('tfOpName', first_op) - self.assertIn('category', first_op) - - def testReadingNonExistentFileRaisesError(self): - with self.assertRaises(IOError): - resource_loader.open_file('___non_existent') - -if __name__ == '__main__': - unittest.main() diff --git a/tfjs-master/tfjs-converter/python/tensorflowjs/version.py b/tfjs-master/tfjs-converter/python/tensorflowjs/version.py deleted file mode 100644 index 545de7143..000000000 --- a/tfjs-master/tfjs-converter/python/tensorflowjs/version.py +++ /dev/null @@ -1,4 +0,0 @@ -# @license See the LICENSE file. - -# This code is auto-generated, do not modify this file! -version = '1.7.0' diff --git a/tfjs-master/tfjs-converter/python/tensorflowjs/write_weights.py b/tfjs-master/tfjs-converter/python/tensorflowjs/write_weights.py deleted file mode 100644 index 8dd616295..000000000 --- a/tfjs-master/tfjs-converter/python/tensorflowjs/write_weights.py +++ /dev/null @@ -1,416 +0,0 @@ -# Copyright 2018 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================== - -import io -import json -import math -import os - -import numpy as np -import tensorflow as tf - -from tensorflowjs import quantization -from tensorflowjs import read_weights - -_OUTPUT_DTYPES = [np.float16, np.float32, np.int32, np.complex64, - np.uint8, np.uint16, bool, object] -_AUTO_DTYPE_CONVERSION = { - np.dtype(np.float16): np.float32, - np.dtype(np.float64): np.float32, - np.dtype(np.int64): np.int32, - np.dtype(np.complex128): np.complex64} - -def write_weights( - weight_groups, write_dir, shard_size_bytes=1024 * 1024 * 4, - write_manifest=True, quantization_dtype_map=None): - """Writes weights to a binary format on disk for ingestion by JavaScript. - - Weights are organized into groups. When writing to disk, the bytes from all - weights in each group are concatenated together and then split into shards - (default is 4MB). This means that large weights (> shard_size) get sharded - and small weights (< shard_size) will be packed. If the bytes can't be split - evenly into shards, there will be a leftover shard that is smaller than the - shard size. - - Weights are optionally quantized to either 8 or 16 bits for compression, - which is enabled via the `quantization_dtype_map`. - - Args: - weight_groups: An list of groups. Each group is an array of weight - entries. Each entry is a dict that maps a unique name to a numpy array, - for example: - entry = { - 'name': 'weight1', - 'data': np.array([1, 2, 3], 'float32') - } - - Weights groups would then look like: - weight_groups = [ - [group_0_entry1, group_0_entry2], - [group_1_entry1, group_1_entry2], - ] - - The 'name' must be unique across all groups and all entries. The 'data' - field must be a numpy ndarray. - write_dir: A directory to write the files to. - shard_size_bytes: The size of shards in bytes. Defaults to 4MB, which is - the max file size for caching for all major browsers. - write_manifest: Whether to write the manifest JSON to disk. Defaults to - True. - quantization_dtype_map: (Optional) A mapping from dtype - (`uint8`, `uint16`, `float16`) to weights names. The weight mapping - supports wildcard substitution. - Returns: - The weights manifest JSON dict. - - An example manifest with 2 groups, 2 weights, and each weight sharded - into 2: - - The manifest JSON looks like the following: - [{ - 'paths': ['group1-shard1of2', 'group1-shard2of2'], - 'weights': [{ - 'name': 'weight1', - 'shape': [1000, 1000], - 'dtype': 'float32' - }] - }, { - 'paths': ['group2-shard1of2', 'group2-shard2of2'], - 'weights': [{ - 'name': 'weight2', - 'shape': [2000, 2000], - 'dtype': 'float32' - }] - }] - or, if quantization is used: - [{ - 'paths': ['group1-shard1of2', 'group1-shard2of2'], - 'weights': [{ - 'name': 'weight1', - 'shape': [1000, 1000], - 'dtype': 'float32' - 'quantization': {'min': -0.1, 'scale': 0.01, 'dtype': 'uint8'} - }] - }, { - 'paths': ['group2-shard1of2', 'group2-shard2of2'], - 'weights': [{ - 'name': 'weight2', - 'shape': [2000, 2000], - 'dtype': 'float32', - 'quantization': {'dtype': 'float16'} - }] - }] - """ - _assert_weight_groups_valid(weight_groups) - _assert_shard_size_bytes_valid(shard_size_bytes) - _assert_no_duplicate_weight_names(weight_groups) - - manifest = [] - - for group_index, group in enumerate(weight_groups): - for e in group: - _auto_convert_weight_entry(e) - names = [entry['name'] for entry in group] - quantization_dtype = quantization.map_layers_to_quantization_dtype( - names, quantization_dtype_map) - - group = [ - _quantize_entry(e, quantization_dtype[e['name']]) - if e['name'] in quantization_dtype else e for e in group - ] - group_bytes, total_bytes, _ = _stack_group_bytes(group) - - shard_filenames = _shard_group_bytes_to_disk( - write_dir, group_index, group_bytes, total_bytes, shard_size_bytes) - - weights_entries = _get_weights_manifest_for_group(group) - manifest_entry = { - 'paths': shard_filenames, - 'weights': weights_entries - } - manifest.append(manifest_entry) - - if write_manifest: - manifest_path = os.path.join(write_dir, 'weights_manifest.json') - with tf.io.gfile.GFile(manifest_path, 'wb') as f: - f.write(json.dumps(manifest).encode()) - - return manifest - - -def _quantize_entry(entry, quantization_dtype): - """Quantizes the weights in the entry, returning a new entry. - - The weights are quantized by linearly re-scaling the values between the - minimum and maximum value, and representing them with the number of bits - provided by the `quantization_dtype`. - - In order to guarantee that 0 is perfectly represented by one of the quanzitzed - values, the range is "nudged" in the same manner as in TF-Lite. - - Args: - entry: A weight entries to quantize. - quantization_dtype: An numpy dtype to quantize weights to. - Only np.uint8, np.uint16, and np.float16 are supported. - - Returns: - A new entry containing the quantized data and additional quantization info, - for example: - original_entry = { - 'name': 'weight1', - 'data': np.array([0, -0.1, 1.2], 'float32') - } - quantized_entry = { - 'name': 'weight1', - 'data': np.array([20, 0, 255], 'uint8') - 'quantization': {'min': -0.10196078817, 'scale': 0.00509803940852, - 'dtype': 'uint8', 'original_dtype': 'float32'} - } - """ - data = entry['data'] - # Only float32 tensors are quantized. - if data.dtype != 'float32': - return entry - quantized_data, metadata = quantization.quantize_weights( - data, quantization_dtype) - metadata.update({'original_dtype': data.dtype.name}) - quantized_entry = entry.copy() - quantized_entry['data'] = quantized_data - quantized_entry['quantization'] = metadata - return quantized_entry - - -def _serialize_string_array(data): - """Serializes a numpy array of dtype `string` into bytes. - - Each string value is preceded by 4 bytes which denote a 32-bit unsigned - integer in little endian that specifies the byte length of the following - string. This is followed by the actual string bytes. If the tensor has no - strings there will be no bytes reserved. Empty strings will still take 4 bytes - for the length. - - For example, a tensor that has 2 strings will be encoded as - [byte length of s1][bytes of s1...][byte length of s2][bytes of s2...] - - where byte length always takes 4 bytes. - - Args: - data: A numpy array of dtype `string`. - - Returns: - bytes of the entire string tensor to be serialized on disk. - """ - strings = data.flatten().tolist() - - string_bytes = io.BytesIO() - bytes_writer = io.BufferedWriter(string_bytes) - - for x in strings: - encoded = x if isinstance(x, bytes) else x.encode('utf-8') - length_as_bytes = np.array(len(encoded), - read_weights.STRING_LENGTH_DTYPE).tobytes() - bytes_writer.write(length_as_bytes) - bytes_writer.write(encoded) - bytes_writer.flush() - string_bytes.seek(0) - return string_bytes.read() - -def _serialize_numeric_array(data): - """Serializes a numeric numpy array into bytes. - - Args: - data: A numeric numpy array. - - Returns: - bytes of the array to be serialized on disk. - """ - return data.tobytes() - -def _stack_group_bytes(group): - """Stacks the bytes for a weight group into a flat byte array. - - Args: - group: A list of weight entries. - Returns: - A type: (group_bytes, total_bytes, weights_entries, group_bytes_writer) - group_bytes: The stacked bytes for the group, as a BytesIO() stream. - total_bytes: A number representing the total size of the byte buffer. - groups_bytes_writer: The io.BufferedWriter object. Returned so that - group_bytes does not get garbage collected and closed. - - """ - group_bytes = io.BytesIO() - group_bytes_writer = io.BufferedWriter(group_bytes) - total_bytes = 0 - - for entry in group: - _assert_valid_weight_entry(entry) - data = entry['data'] - - if data.dtype == object: - data_bytes = _serialize_string_array(data) - else: - data_bytes = _serialize_numeric_array(data) - group_bytes_writer.write(data_bytes) - total_bytes += len(data_bytes) - - group_bytes_writer.flush() - group_bytes.seek(0) - - # NOTE: We must return the bytes writer here, otherwise it goes out of scope - # and python closes the IO operation. - return (group_bytes, total_bytes, group_bytes_writer) - - -def _shard_group_bytes_to_disk( - write_dir, group_index, group_bytes, total_bytes, shard_size_bytes): - """Shards the concatenated bytes for a group to disk. - - Args: - write_dir: The directory to write the files to. - group_index: The index for the group. - group_bytes: An io.BytesIO() object representing the byte array. - total_bytes: The total number of bytes of the stream. - shard_size_bytes: The size of shards in bytes. If None, the whole byte - array will be written as one shard. - Returns: - A list of filenames that were written to disk. - """ - if shard_size_bytes is None: - shard_size_bytes = total_bytes - - num_shards = int(math.ceil(float(total_bytes) / shard_size_bytes)) - - filenames = [] - for i in range(num_shards): - shard = group_bytes.read(shard_size_bytes) - - filename = 'group%d-shard%dof%d.bin' % (group_index + 1, i + 1, num_shards) - filenames.append(filename) - filepath = os.path.join(write_dir, filename) - - # Write the shard to disk. - with tf.io.gfile.GFile(filepath, 'wb') as f: - f.write(shard) - - return filenames - - -def _get_weights_manifest_for_group(group): - """Gets the weights entries manifest JSON for a group. - - Args: - group: A list of weight entries. - Returns: - An list of manifest entries (dicts) to be written in the weights manifest. - """ - weights_entries = [] - for entry in group: - is_quantized = 'quantization' in entry - dtype = (entry['quantization']['original_dtype'] - if is_quantized else entry['data'].dtype.name) - var_manifest = { - 'name': entry['name'], - 'shape': list(entry['data'].shape), - 'dtype': dtype - } - # String arrays have dtype 'object' and need extra metadata to parse. - if dtype == 'object': - var_manifest['dtype'] = 'string' - if is_quantized: - manifest = {'dtype': entry['data'].dtype.name} - manifest.update(entry['quantization']) - var_manifest['quantization'] = manifest - weights_entries.append(var_manifest) - return weights_entries - - -def _assert_no_duplicate_weight_names(weight_groups): - weight_names = set() - for group in weight_groups: - for entry in group: - name = entry['name'] - if name in weight_names: - raise Exception( - 'Error dumping weights, duplicate weight name ' + name) - weight_names.add(name) - - -def _auto_convert_weight_entry(entry): - data = entry['data'] - if data.dtype in _AUTO_DTYPE_CONVERSION: - entry['data'] = data.astype(_AUTO_DTYPE_CONVERSION[data.dtype]) - print('weight ' + entry['name'] + ' with shape ' + str(data.shape) + - ' and dtype ' + data.dtype.name + ' was auto converted to the type ' + - np.dtype(_AUTO_DTYPE_CONVERSION[data.dtype]).name) - - -def _assert_valid_weight_entry(entry): - if 'name' not in entry: - raise ValueError('Error dumping weight, no name field found.') - if 'data' not in entry: - raise ValueError('Error dumping weight, no data field found.') - - name = entry['name'] - data = entry['data'] - - # String tensors can be backed by different numpy dtypes, thus we consolidate - # to a single 'object' dtype. - if data.dtype.name.startswith('str') or data.dtype.name.startswith('bytes'): - data = data.astype(object) - entry['data'] = data - - - if not (data.dtype in _OUTPUT_DTYPES or data.dtype in _AUTO_DTYPE_CONVERSION): - raise ValueError('Error dumping weight ' + name + ', dtype ' + - data.dtype.name + ' not supported.') - - if not isinstance(data, np.ndarray): - raise ValueError('Error dumping weight ' + name + ', data ' + - 'must be a numpy ndarray.') - - -def _assert_weight_groups_valid(weight_groups): - if not isinstance(weight_groups, list): - raise Exception('weight_groups must be a list of groups') - if not weight_groups: - raise ValueError('weight_groups must have more than one list element') - for i, weight_group in enumerate(weight_groups): - if not isinstance(weight_group, list): - raise ValueError( - 'weight_groups[' + i + '] must be a list of weight entries') - for j, weights in enumerate(weight_group): - if 'name' not in weights: - raise ValueError( - 'weight_groups[' + i + '][' + j + '] has no string field \'name\'') - if 'data' not in weights: - raise ValueError( - 'weight_groups[' + i + '][' + j + '] has no numpy ' + - 'array field \'data\'') - if not isinstance(weights['data'], np.ndarray): - raise ValueError( - 'weight_groups[' + i + '][' + j + '][\'data\'] is not a numpy ' + - 'array') - - -def _assert_shard_size_bytes_valid(shard_size_bytes): - if shard_size_bytes <= 0: - raise ValueError( - 'shard_size_bytes must be greater than 0, but got %s' % - shard_size_bytes) - if not isinstance(shard_size_bytes, int): - raise ValueError( - 'shard_size_bytes must be an integer, but got %s' % - shard_size_bytes) diff --git a/tfjs-master/tfjs-converter/python/tensorflowjs/write_weights_test.py b/tfjs-master/tfjs-converter/python/tensorflowjs/write_weights_test.py deleted file mode 100644 index 11e7d8154..000000000 --- a/tfjs-master/tfjs-converter/python/tensorflowjs/write_weights_test.py +++ /dev/null @@ -1,789 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2018 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================== - -import os -import shutil - -import numpy as np -import tensorflow as tf - -from tensorflowjs import write_weights - -TMP_DIR = '/tmp/write_weights_test/' - - -class TestWriteWeights(tf.test.TestCase): - def setUp(self): - if not os.path.isdir(TMP_DIR): - os.makedirs(TMP_DIR) - - def tearDown(self): - if os.path.isdir(TMP_DIR): - shutil.rmtree(TMP_DIR) - - def test_1_group_1_weight(self): - groups = [ - [{ - 'name': 'weight1', - 'data': np.array([1, 2, 3], 'float32') - }] - ] - - manifest = write_weights.write_weights( - groups, TMP_DIR, shard_size_bytes=4 * 4) - - self.assertTrue( - os.path.isfile(os.path.join(TMP_DIR, 'weights_manifest.json')), - 'weights_manifest.json does not exist') - - self.assertEqual( - manifest, - [{ - 'paths': ['group1-shard1of1.bin'], - 'weights': [{ - 'name': 'weight1', - 'shape': [3], - 'dtype': 'float32' - }] - }]) - - weights_path = os.path.join(TMP_DIR, 'group1-shard1of1.bin') - weight1 = np.fromfile(weights_path, 'float32') - np.testing.assert_array_equal(weight1, np.array([1, 2, 3], 'float32')) - - def test_1_group_1_weight_bool(self): - groups = [ - [{ - 'name': 'weight1', - 'data': np.array([True, False, True], 'bool') - }] - ] - - manifest = write_weights.write_weights( - groups, TMP_DIR, shard_size_bytes=4 * 4) - - self.assertTrue( - os.path.isfile(os.path.join(TMP_DIR, 'weights_manifest.json')), - 'weights_manifest.json does not exist') - - self.assertEqual( - manifest, - [{ - 'paths': ['group1-shard1of1.bin'], - 'weights': [{ - 'name': 'weight1', - 'shape': [3], - 'dtype': 'bool' - }] - }]) - - weights_path = os.path.join(TMP_DIR, 'group1-shard1of1.bin') - weight1 = np.fromfile(weights_path, 'bool') - np.testing.assert_array_equal( - weight1, np.array([True, False, True], 'bool')) - - def test_1_group_1_weight_string(self): - groups = [ - [{ - 'name': 'weight1', - 'data': np.array([['здраво', 'end'], ['test', 'a']], 'object') - }] - ] - - manifest = write_weights.write_weights( - groups, TMP_DIR, shard_size_bytes=4 * 1024 * 1024) - - self.assertTrue( - os.path.isfile(os.path.join(TMP_DIR, 'weights_manifest.json')), - 'weights_manifest.json does not exist') - - self.assertEqual( - manifest, - [{ - 'paths': ['group1-shard1of1.bin'], - 'weights': [{ - 'name': 'weight1', - 'shape': [2, 2], - 'dtype': 'string' - }] - }]) - - weights_path = os.path.join(TMP_DIR, 'group1-shard1of1.bin') - with open(weights_path, 'rb') as f: - weight_bytes = f.read() - - self.assertEqual(len(weight_bytes), 36) - # 'здраво' - size = np.frombuffer(weight_bytes[:4], 'uint32')[0] - self.assertEqual(size, 12) # 6 cyrillic chars (2 bytes each). - string = weight_bytes[4:16].decode('utf-8') - self.assertEqual(string, u'здраво') - # 'end' - size = np.frombuffer(weight_bytes[16:20], 'uint32')[0] - self.assertEqual(size, 3) # 3 ascii chars. - string = weight_bytes[20:23].decode('utf-8') - self.assertEqual(string, u'end') - # 'test' - size = np.frombuffer(weight_bytes[23:27], 'uint32')[0] - self.assertEqual(size, 4) # 4 ascii chars. - string = weight_bytes[27:31].decode('utf-8') - self.assertEqual(string, u'test') - # 'a' - size = np.frombuffer(weight_bytes[31:35], 'uint32')[0] - self.assertEqual(size, 1) # 4 ascii chars. - string = weight_bytes[35:36].decode('utf-8') - self.assertEqual(string, u'a') - - - def test_1_group_1_weight_string_empty(self): - groups = [ - [{ - 'name': 'weight1', - 'data': np.array([''], 'object') - }] - ] - - manifest = write_weights.write_weights( - groups, TMP_DIR, shard_size_bytes=4 * 1024 * 1024) - - self.assertTrue( - os.path.isfile(os.path.join(TMP_DIR, 'weights_manifest.json')), - 'weights_manifest.json does not exist') - - self.assertEqual( - manifest, - [{ - 'paths': ['group1-shard1of1.bin'], - 'weights': [{ - 'name': 'weight1', - 'shape': [1], - 'dtype': 'string' - }] - }]) - - weights_path = os.path.join(TMP_DIR, 'group1-shard1of1.bin') - with open(weights_path, 'rb') as f: - weight_bytes = f.read() - self.assertEqual(len(weight_bytes), 4) - size = np.frombuffer(weight_bytes[:4], 'uint32')[0] - self.assertEqual(size, 0) # Empty string. - - def test_1_group_1_weight_string_unicode(self): - groups = [ - [{ - 'name': 'weight1', - 'data': np.array([[u'здраво', u'end'], [u'test', u'a']], 'object') - }] - ] - - manifest = write_weights.write_weights( - groups, TMP_DIR, shard_size_bytes=4 * 1024 * 1024) - - self.assertTrue( - os.path.isfile(os.path.join(TMP_DIR, 'weights_manifest.json')), - 'weights_manifest.json does not exist') - - self.assertEqual( - manifest, - [{ - 'paths': ['group1-shard1of1.bin'], - 'weights': [{ - 'name': 'weight1', - 'shape': [2, 2], - 'dtype': 'string' - }] - }]) - - weights_path = os.path.join(TMP_DIR, 'group1-shard1of1.bin') - with open(weights_path, 'rb') as f: - weight_bytes = f.read() - - self.assertEqual(len(weight_bytes), 36) - # 'здраво' - size = np.frombuffer(weight_bytes[:4], 'uint32')[0] - self.assertEqual(size, 12) # 6 cyrillic chars (2 bytes each). - string = weight_bytes[4:16].decode('utf-8') - self.assertEqual(string, u'здраво') - # 'end' - size = np.frombuffer(weight_bytes[16:20], 'uint32')[0] - self.assertEqual(size, 3) # 3 ascii chars. - string = weight_bytes[20:23].decode('utf-8') - self.assertEqual(string, u'end') - # 'test' - size = np.frombuffer(weight_bytes[23:27], 'uint32')[0] - self.assertEqual(size, 4) # 4 ascii chars. - string = weight_bytes[27:31].decode('utf-8') - self.assertEqual(string, u'test') - # 'a' - size = np.frombuffer(weight_bytes[31:35], 'uint32')[0] - self.assertEqual(size, 1) # 4 ascii chars. - string = weight_bytes[35:36].decode('utf-8') - self.assertEqual(string, u'a') - - def test_1_group_1_weight_string_sharded(self): - groups = [ - [{ - 'name': 'weight1', - 'data': np.array(['helloworld'], 'object') - }] - ] - - # The array takes up 14 bytes across 3 shards when shard size is 5 bytes. - manifest = write_weights.write_weights( - groups, TMP_DIR, shard_size_bytes=5) - - self.assertTrue( - os.path.isfile(os.path.join(TMP_DIR, 'weights_manifest.json')), - 'weights_manifest.json does not exist') - - self.assertEqual( - manifest, - [{ - 'paths': [ - 'group1-shard1of3.bin', - 'group1-shard2of3.bin', - 'group1-shard3of3.bin' - ], - 'weights': [{ - 'name': 'weight1', - 'shape': [1], - 'dtype': 'string' - }] - }]) - - weight_bytes = bytes() - with open(os.path.join(TMP_DIR, 'group1-shard1of3.bin'), 'rb') as f: - weight_bytes += f.read() - with open(os.path.join(TMP_DIR, 'group1-shard2of3.bin'), 'rb') as f: - weight_bytes += f.read() - with open(os.path.join(TMP_DIR, 'group1-shard3of3.bin'), 'rb') as f: - weight_bytes += f.read() - - self.assertEqual(len(weight_bytes), 14) - size = np.frombuffer(weight_bytes[:4], 'uint32')[0] - self.assertEqual(size, 10) # 10 ascii chars. - string = weight_bytes[4:14].decode('utf-8') - self.assertEqual(string, u'helloworld') - - def test_1_group_1_weight_complex(self): - groups = [ - [{ - 'name': 'weight1', - 'data': np.array([1 + 1j, 2 + 2j, 3 + 3j], 'complex') - }] - ] - - manifest = write_weights.write_weights( - groups, TMP_DIR, shard_size_bytes=6 * 4) - - self.assertTrue( - os.path.isfile(os.path.join(TMP_DIR, 'weights_manifest.json')), - 'weights_manifest.json does not exist') - - self.assertEqual( - manifest, - [{ - 'paths': ['group1-shard1of1.bin'], - 'weights': [{ - 'name': 'weight1', - 'shape': [3], - 'dtype': 'complex64' - }] - }]) - - weights_path = os.path.join(TMP_DIR, 'group1-shard1of1.bin') - weight1 = np.fromfile(weights_path, 'complex64') - np.testing.assert_array_equal( - weight1, np.array([1 + 1j, 2 + 2j, 3 + 3j], 'complex64')) - - def test_1_group_3_weights_packed_multi_dtype(self): - # Each string tensor uses different encoding. - groups = [ - [{ - 'name': 'weight1', - 'data': np.array([1, 2, 3], 'float32') - }, { - 'name': 'weight2', - 'data': np.array([ - u'hello'.encode('utf-16'), u'end'.encode('utf-16')], 'object') - }, { - 'name': 'weight3', - 'data': np.array([u'здраво'.encode('windows-1251')], 'object') - }, { - 'name': 'weight4', - 'data': np.array([u'语言处ç†'.encode('utf-8')], 'object') - }, { - 'name': 'weight5', - 'data': np.array([4, 5, 6], 'float32') - }] - ] - - manifest = write_weights.write_weights( - groups, TMP_DIR, shard_size_bytes=4 * 1024 * 1024) - - self.assertTrue( - os.path.isfile(os.path.join(TMP_DIR, 'weights_manifest.json')), - 'weights_manifest.json does not exist') - - self.assertEqual( - manifest, - [{ - 'paths': ['group1-shard1of1.bin'], - 'weights': [{ - 'name': 'weight1', - 'shape': [3], - 'dtype': 'float32' - }, { - 'name': 'weight2', - 'shape': [2], - 'dtype': 'string' - }, { - 'name': 'weight3', - 'shape': [1], - 'dtype': 'string' - }, { - 'name': 'weight4', - 'shape': [1], - 'dtype': 'string' - }, { - 'name': 'weight5', - 'shape': [3], - 'dtype': 'float32' - }] - }]) - - weights_path = os.path.join(TMP_DIR, 'group1-shard1of1.bin') - with open(weights_path, 'rb') as f: - weight_bytes = f.read() - self.assertEqual(len(weight_bytes), 78) - - # [1, 2, 3] - weight1 = np.frombuffer(weight_bytes[:12], 'float32') - np.testing.assert_array_equal(weight1, np.array([1, 2, 3], 'float32')) - - # 'hello' - size = np.frombuffer(weight_bytes[12:16], 'uint32')[0] - self.assertEqual(size, 12) # 5 ascii chars in utf-16. - string = weight_bytes[16:28].decode('utf-16') - self.assertEqual(string, u'hello') - - # 'end' - size = np.frombuffer(weight_bytes[28:32], 'uint32')[0] - self.assertEqual(size, 8) # 3 ascii chars in utf-16. - string = weight_bytes[32:40].decode('utf-16') - self.assertEqual(string, u'end') - - # 'здраво' - size = np.frombuffer(weight_bytes[40:44], 'uint32')[0] - self.assertEqual(size, 6) # 6 cyrillic chars in windows-1251. - string = weight_bytes[44:50].decode('windows-1251') - self.assertEqual(string, u'здраво') - - # '语言处ç†' - size = np.frombuffer(weight_bytes[50:54], 'uint32')[0] - self.assertEqual(size, 12) # 4 east asian chars in utf-8. - string = weight_bytes[54:66].decode('utf-8') - self.assertEqual(string, u'语言处ç†') - - weight5 = np.frombuffer(weight_bytes[66:], 'float32') - np.testing.assert_array_equal(weight5, np.array([4, 5, 6], 'float32')) - - def test_1_group_1_weight_sharded(self): - groups = [ - [{ - 'name': 'weight1', - 'data': np.array([1, 2, 3], 'float32') - }] - ] - # Shard size is smaller than the size of the array so it gets split between - # multiple files. - manifest = write_weights.write_weights( - groups, TMP_DIR, shard_size_bytes=2 * 4) - - self.assertTrue( - os.path.isfile(os.path.join(TMP_DIR, 'weights_manifest.json')), - 'weights_manifest.json does not exist') - - self.assertEqual( - manifest, - [{ - 'paths': ['group1-shard1of2.bin', 'group1-shard2of2.bin'], - 'weights': [{ - 'name': 'weight1', - 'shape': [3], - 'dtype': 'float32' - }] - }]) - - shard_1_path = os.path.join(TMP_DIR, 'group1-shard1of2.bin') - shard_1 = np.fromfile(shard_1_path, 'float32') - np.testing.assert_array_equal(shard_1, np.array([1, 2], 'float32')) - - shard_2_path = os.path.join(TMP_DIR, 'group1-shard2of2.bin') - shard_2 = np.fromfile(shard_2_path, 'float32') - np.testing.assert_array_equal(shard_2, np.array([3], 'float32')) - - def test_1_group_2_weights_packed(self): - groups = [ - [{ - 'name': 'weight1', - 'data': np.array([1, 2, 3], 'float32') - }, { - 'name': 'weight2', - 'data': np.array([4, 5], 'float32') - }] - ] - - # Shard size is larger than the sum of the two weights so they get packed. - manifest = write_weights.write_weights( - groups, TMP_DIR, shard_size_bytes=8 * 4) - - self.assertTrue( - os.path.isfile(os.path.join(TMP_DIR, 'weights_manifest.json')), - 'weights_manifest.json does not exist') - self.assertEqual( - manifest, - [{ - 'paths': ['group1-shard1of1.bin'], - 'weights': [{ - 'name': 'weight1', - 'shape': [3], - 'dtype': 'float32' - }, { - 'name': 'weight2', - 'shape': [2], - 'dtype': 'float32' - }] - }]) - - weights_path = os.path.join(TMP_DIR, 'group1-shard1of1.bin') - weights = np.fromfile(weights_path, 'float32') - np.testing.assert_array_equal(weights, np.array([1, 2, 3, 4, 5], 'float32')) - - def test_1_group_2_packed_sharded_multi_dtype(self): - groups = [ - [{ - 'name': 'weight1', - 'data': np.array([1, 2, 3], 'int32') - }, { - 'name': 'weight2', - 'data': np.array([True, False, False, True], 'bool') - }, { - 'name': 'weight3', - 'data': np.array([4.1, 5.1], 'float32') - }] - ] - - # Shard size is smaller than the sum of the weights so they get packed and - # then sharded. The two buffers will get sharded into 3 files, with shapes - # [2], [2], and [1]. The second shard is a mixed dtype. - manifest = write_weights.write_weights( - groups, TMP_DIR, shard_size_bytes=2 * 4) - - self.assertTrue( - os.path.isfile(os.path.join(TMP_DIR, 'weights_manifest.json')), - 'weights_manifest.json does not exist') - self.assertEqual( - manifest, - [{ - 'paths': ['group1-shard1of3.bin', - 'group1-shard2of3.bin', - 'group1-shard3of3.bin'], - 'weights': [{ - 'name': 'weight1', - 'shape': [3], - 'dtype': 'int32' - }, { - 'name': 'weight2', - 'shape': [4], - 'dtype': 'bool' - }, { - 'name': 'weight3', - 'shape': [2], - 'dtype': 'float32' - }] - }]) - - shard_1_path = os.path.join(TMP_DIR, 'group1-shard1of3.bin') - shard_1 = np.fromfile(shard_1_path, 'int32') - np.testing.assert_array_equal(shard_1, np.array([1, 2], 'int32')) - - # Shard 2 has a mixed dtype so we parse the bytes directly. - shard_2_path = os.path.join(TMP_DIR, 'group1-shard2of3.bin') - with open(shard_2_path, 'rb') as f: - shard_2_bytes = f.read() - self.assertEqual(len(shard_2_bytes), 8) - shard_2_int = np.frombuffer(shard_2_bytes[:4], 'int32') - np.testing.assert_array_equal(shard_2_int, np.array([3], 'int32')) - shard_2_bool = np.frombuffer(shard_2_bytes[4:], 'bool') - np.testing.assert_array_equal( - shard_2_bool, np.array([True, False, False, True], 'bool')) - - shard_3_path = os.path.join(TMP_DIR, 'group1-shard3of3.bin') - shard_3 = np.fromfile(shard_3_path, 'float32') - np.testing.assert_array_equal(shard_3, np.array([4.1, 5.1], 'float32')) - - def test_2_groups_4_weights_sharded_packed(self): - groups = [ - # Group 1 - [{ - 'name': 'weight1', - 'data': np.array([1, 2, 3], 'float64') - }, { - 'name': 'weight2', - 'data': np.array([[4, 5], [6, 7]], 'float32') - }, { - 'name': 'weight5', - 'data': np.array([1], 'float16') - }], - # Group 2 - [{ - 'name': 'weight3', - 'data': np.array([1, 2, 3, 4], 'int64') - }, { - 'name': 'weight4', - 'data': np.array([[1.1, 1.2], [1.3, 1.4], [1.5, 1.6]], 'float32') - }] - ] - - manifest = write_weights.write_weights( - groups, TMP_DIR, shard_size_bytes=4 * 4) - - self.assertTrue( - os.path.isfile(os.path.join(TMP_DIR, 'weights_manifest.json')), - 'weights_manifest.json does not exist') - self.assertEqual( - manifest, - [{ - 'paths': ['group1-shard1of2.bin', 'group1-shard2of2.bin'], - 'weights': [{ - 'name': 'weight1', - 'shape': [3], - 'dtype': 'float32' - }, { - 'name': 'weight2', - 'shape': [2, 2], - 'dtype': 'float32' - }, { - 'name': 'weight5', - 'shape': [1], - 'dtype': 'float32' - }] - }, { - 'paths': ['group2-shard1of3.bin', - 'group2-shard2of3.bin', - 'group2-shard3of3.bin'], - 'weights': [{ - 'name': 'weight3', - 'shape': [4], - 'dtype': 'int32' - }, { - 'name': 'weight4', - 'shape': [3, 2], - 'dtype': 'float32' - }] - }]) - - group0_shard_1_path = os.path.join(TMP_DIR, 'group1-shard1of2.bin') - group0_shard_1 = np.fromfile(group0_shard_1_path, 'float32') - np.testing.assert_array_equal( - group0_shard_1, np.array([1, 2, 3, 4], 'float32')) - - group0_shard_2_path = os.path.join(TMP_DIR, 'group1-shard2of2.bin') - group0_shard_2 = np.fromfile(group0_shard_2_path, 'float32') - np.testing.assert_array_equal( - group0_shard_2, np.array([5, 6, 7, 1], 'float32')) - - group1_shard_1_path = os.path.join(TMP_DIR, 'group2-shard1of3.bin') - group1_shard_1 = np.fromfile(group1_shard_1_path, 'int32') - np.testing.assert_array_equal( - group1_shard_1, np.array([1, 2, 3, 4], 'int32')) - - group2_shard_2_path = os.path.join(TMP_DIR, 'group2-shard2of3.bin') - group2_shard_2 = np.fromfile(group2_shard_2_path, 'float32') - np.testing.assert_array_equal( - group2_shard_2, np.array([1.1, 1.2, 1.3, 1.4], 'float32')) - - group2_shard_3_path = os.path.join(TMP_DIR, 'group2-shard3of3.bin') - group2_shard_3 = np.fromfile(group2_shard_3_path, 'float32') - np.testing.assert_array_equal( - group2_shard_3, np.array([1.5, 1.6], 'float32')) - - def test_no_write_manfest(self): - groups = [ - [{ - 'name': 'weight1', - 'data': np.array([1, 2, 3], 'float32') - }] - ] - - manifest = write_weights.write_weights( - groups, TMP_DIR, write_manifest=False) - - self.assertFalse( - os.path.isfile(os.path.join(TMP_DIR, 'weights_manifest.json')), - 'weights_manifest.json exists, but expected not to exist') - self.assertEqual( - manifest, - [{ - 'paths': ['group1-shard1of1.bin'], - 'weights': [{ - 'name': 'weight1', - 'shape': [3], - 'dtype': 'float32' - }] - }]) - - weights_path = os.path.join(TMP_DIR, 'group1-shard1of1.bin') - weight1 = np.fromfile(weights_path, 'float32') - np.testing.assert_array_equal(weight1, np.array([1, 2, 3], 'float32')) - - def test_no_weights_groups_throws(self): - groups = None - with self.assertRaises(Exception): - write_weights.write_weights(groups, TMP_DIR) - - def test_empty_groups_throws(self): - groups = [] - with self.assertRaises(Exception): - write_weights.write_weights(groups, TMP_DIR) - - def test_non_grouped_weights_throws(self): - groups = [{ - 'name': 'weight1', - 'data': np.array([1, 2, 3], 'float32') - }] - - with self.assertRaises(Exception): - write_weights.write_weights(groups, TMP_DIR) - - def test_bad_weights_entry_throws_no_name(self): - groups = [ - [{ - 'noname': 'weight1', - 'data': np.array([1, 2, 3], 'float32') - }] - ] - - with self.assertRaises(Exception): - write_weights.write_weights(groups, TMP_DIR) - - def test_bad_weights_entry_throws_no_data(self): - groups = [ - [{ - 'name': 'weight1', - 'nodata': np.array([1, 2, 3], 'float32') - }] - ] - - with self.assertRaises(Exception): - write_weights.write_weights(groups, TMP_DIR) - - def test_duplicate_weight_name_throws(self): - groups = [ - [{ - 'name': 'duplicate', - 'data': np.array([1, 2, 3], 'float32') - }], [{ - 'name': 'duplicate', - 'data': np.array([4, 5, 6], 'float32') - }] - ] - - with self.assertRaises(Exception): - write_weights.write_weights(groups, TMP_DIR) - - def test_quantize_group(self): - groups = [ - [{ - 'name': 'weight1', - 'data': np.array([1, 2, 3], 'float32') - }, { - 'name': 'weight2', - 'data': np.array([4, 5], 'int32') - }, { - 'name': 'weight3', - 'data': np.array([6, 7], 'float64') - }, { - 'name': 'weight4', - 'data': np.array(['hello'], object) - }] - ] - - manifest = write_weights.write_weights( - groups, TMP_DIR, shard_size_bytes=1024, - quantization_dtype_map={ - 'float16': 'weight1', - 'uint8': 'weight3' - }) - - self.assertTrue( - os.path.isfile(os.path.join(TMP_DIR, 'weights_manifest.json')), - 'weights_manifest.json does not exist') - self.assertEqual( - manifest, - [{ - 'paths': ['group1-shard1of1.bin'], - 'weights': [{ - 'name': 'weight1', - 'shape': [3], - 'dtype': 'float32', - 'quantization': { - 'original_dtype': 'float32', - 'dtype': 'float16' - } - }, { - 'name': 'weight2', - 'shape': [2], - 'dtype': 'int32' - }, { - 'name': 'weight3', - 'shape': [2], - 'dtype': 'float32', - 'quantization': { - 'min': 6.0, - 'scale': 1/255.0, - 'original_dtype': 'float32', - 'dtype': 'uint8' - } - }, { - 'name': 'weight4', - 'shape': [1], - 'dtype': 'string' - }] - }]) - - weights_path = os.path.join(TMP_DIR, 'group1-shard1of1.bin') - with open(weights_path, 'rb') as f: - weight_bytes = f.read() - self.assertEqual(len(weight_bytes), 25) - w1 = np.frombuffer(weight_bytes[:6], 'float16') - np.testing.assert_array_equal(w1, np.array([1, 2, 3], 'float16')) - - w2 = np.frombuffer(weight_bytes[6:14], 'int32') - np.testing.assert_array_equal(w2, np.array([4, 5], 'int32')) - - w3 = np.frombuffer(weight_bytes[14:16], 'uint8') - np.testing.assert_array_equal(w3, np.array([0, 255], 'uint8')) - - size = np.frombuffer(weight_bytes[16:20], 'uint32')[0] - self.assertEqual(size, 5) # 5 ascii letters. - w4 = weight_bytes[20:].decode('utf-8') - self.assertEqual(w4, u'hello') - - -if __name__ == '__main__': - tf.test.main() diff --git a/tfjs-master/tfjs-converter/python/test_nightly_pip_package.py b/tfjs-master/tfjs-converter/python/test_nightly_pip_package.py deleted file mode 100644 index adb4ec9c5..000000000 --- a/tfjs-master/tfjs-converter/python/test_nightly_pip_package.py +++ /dev/null @@ -1,120 +0,0 @@ -# Copyright 2019 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================== -"""Test the Python API and shell binary of the tensorflowjs pip package.""" - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -import glob -import os -import shutil -import subprocess -import tempfile - -import tensorflow.compat.v2 as tf -from tensorflow.python.saved_model.save import save - -class APIAndShellTest(tf.test.TestCase): - """Nightly tests for the Python API of the pip package.""" - - def setUp(self): - # Make sure this file is not being run from the source directory, to - # avoid picking up source files. - if os.path.isdir( - os.path.join(os.path.dirname(__file__), 'tensorflowjs')): - self.fail('Do not run this test from the Python source directory. ' - 'This file is intended to be run on pip install.') - - self._tmp_dir = tempfile.mkdtemp() - super(APIAndShellTest, self).setUp() - - def tearDown(self): - if os.path.isdir(self._tmp_dir): - shutil.rmtree(self._tmp_dir) - super(APIAndShellTest, self).tearDown() - - def testConvertTfHubMobileNetV2ToTfjsGraphModel(self): - # 1. Convert tfhub mobilenet v2 module. - tfhub_url = ( - 'https://tfhub.dev/google/imagenet/mobilenet_v2_100_224' - '/classification/3' - ) - graph_model_output_dir = os.path.join(self._tmp_dir, 'tfjs_graph') - process = subprocess.Popen([ - 'tensorflowjs_converter', '--input_format', 'tf_hub', - tfhub_url, graph_model_output_dir - ]) - process.communicate() - self.assertEqual(0, process.returncode) - - # 2. Check the files that belong to the conversion result. - files = glob.glob(os.path.join(graph_model_output_dir, '*')) - self.assertIn(os.path.join(graph_model_output_dir, 'model.json'), files) - weight_files = glob.glob( - os.path.join(graph_model_output_dir, 'group*.bin')) - self.assertEqual(len(weight_files), 4) - - def testConvertMobileNetV2ModelToTfjsGraphModel(self): - """create the keras mobilenet v2 model.""" - # 1. Create a saved model from keras mobilenet v2. - model = tf.keras.applications.MobileNetV2() - - save_dir = os.path.join(self._tmp_dir, 'mobilenetv2') - save(model, save_dir) - - # 2. Convert to graph model. - graph_model_output_dir = os.path.join(self._tmp_dir, 'tfjs_graph') - process = subprocess.Popen([ - 'tensorflowjs_converter', '--input_format', 'tf_saved_model', - save_dir, graph_model_output_dir - ]) - process.communicate() - self.assertEqual(0, process.returncode) - - # 3. Check the files that belong to the conversion result. - files = glob.glob(os.path.join(graph_model_output_dir, '*')) - self.assertIn(os.path.join(graph_model_output_dir, 'model.json'), files) - weight_files = glob.glob( - os.path.join(graph_model_output_dir, 'group*.bin')) - self.assertEqual(len(weight_files), 4) - - def testConvertMobileNetV2Hdf5ToTfjsGraphModel(self): - # 1. Create a model for testing. - model = tf.keras.applications.MobileNetV2() - - h5_path = os.path.join(self._tmp_dir, 'model.h5') - model.save(h5_path) - - # 2. Convert the keras hdf5 model to tfjs_layers_model format. - graph_model_output_dir = os.path.join(self._tmp_dir, 'tfjs_graph') - # Implicit value of --output_format: tfjs_layers_model - process = subprocess.Popen([ - 'tensorflowjs_converter', '--input_format', 'keras', - '--output_format', 'tfjs_graph_model', - h5_path, graph_model_output_dir - ]) - process.communicate() - self.assertEqual(0, process.returncode) - - # 3. Check the files that belong to the conversion result. - files = glob.glob(os.path.join(graph_model_output_dir, '*')) - self.assertIn(os.path.join(graph_model_output_dir, 'model.json'), files) - weight_files = glob.glob( - os.path.join(graph_model_output_dir, 'group*.bin')) - self.assertEqual(len(weight_files), 4) - -if __name__ == '__main__': - tf.test.main() diff --git a/tfjs-master/tfjs-converter/python/test_pip_package.py b/tfjs-master/tfjs-converter/python/test_pip_package.py deleted file mode 100644 index 313323ab2..000000000 --- a/tfjs-master/tfjs-converter/python/test_pip_package.py +++ /dev/null @@ -1,1034 +0,0 @@ -# Copyright 2018 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================== -"""Test the Python API and shell binary of the tensorflowjs pip package.""" - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -import glob -import json -import os -import shutil -import subprocess -import sys -import tempfile - -import numpy as np -import tensorflow.compat.v2 as tf -from tensorflow.compat.v1 import saved_model -from tensorflow.python.eager import def_function -from tensorflow.python.framework import constant_op -from tensorflow.python.ops import variables -from tensorflow.python.tools import freeze_graph -from tensorflow.python.trackable import autotrackable -from tensorflow.python.saved_model.save import save -import tensorflow_hub as hub - -import tensorflowjs as tfjs - - -def _createKerasModel(layer_name_prefix, h5_path=None): - """Create a Keras model for testing. - - Args: - layer_name_prefix: A prefix string for layer names. This helps avoid - clashes in layer names between different test methods. - h5_path: Optional string path for a HDF5 (.h5) file to save the model - in. - - Returns: - An instance of tf.keras.Model. - """ - input_tensor = tf.keras.layers.Input((3, )) - dense1 = tf.keras.layers.Dense( - 4, - use_bias=True, - kernel_initializer='ones', - bias_initializer='zeros', - name=layer_name_prefix + '1')(input_tensor) - output = tf.keras.layers.Dense( - 2, - use_bias=False, - kernel_initializer='ones', - name=layer_name_prefix + '2')(dense1) - model = tf.keras.models.Model(inputs=[input_tensor], outputs=[output]) - model.compile(optimizer='adam', loss='binary_crossentropy') - model.predict(tf.ones((1, 3)), steps=1) - - if h5_path: - model.save(h5_path, save_format='h5') - return model - -def _createTensorFlowSavedModelV1(name_scope, save_path): - """Create a TensorFlow SavedModel for testing. - Args: - name_scope: Name scope to create the model under. This helps avoid - op and variable name clashes between different test methods. - save_path: The directory path in which to save the model. - """ - graph = tf.Graph() - with graph.as_default(): - with tf.compat.v1.name_scope(name_scope): - x = tf.compat.v1.constant([[37.0, -23.0], [1.0, 4.0]]) - w = tf.compat.v1.get_variable('w', shape=[2, 2]) - y = tf.compat.v1.matmul(x, w) - output = tf.compat.v1.nn.softmax(y) - init_op = w.initializer - - # Create a builder. - builder = saved_model.builder.SavedModelBuilder(save_path) - - with tf.compat.v1.Session() as sess: - # Run the initializer on `w`. - sess.run(init_op) - - builder.add_meta_graph_and_variables( - sess, [saved_model.tag_constants.SERVING], - signature_def_map={ - "serving_default": - saved_model.signature_def_utils.predict_signature_def( - inputs={"x": x}, - outputs={"output": output}) - }, - assets_collection=None) - - builder.save() - -def _createTensorFlowSavedModel(save_path): - """Create a TensorFlow SavedModel for testing. - - Args: - save_path: The directory path in which to save the model. - """ - - input_data = constant_op.constant(1., shape=[1]) - root = autotrackable.AutoTrackable() - root.v1 = variables.Variable(3.) - root.v2 = variables.Variable(2.) - root.f = def_function.function(lambda x: root.v1 * root.v2 * x) - to_save = root.f.get_concrete_function(input_data) - - save(root, save_path, to_save) - - -def _create_hub_module(save_path): - """Create a TensorFlow Hub module for testing. - - Args: - save_path: The directory path in which to save the model. - """ - # Module function that doubles its input. - def double_module_fn(): - w = tf.Variable([2.0, 4.0]) - x = tf.compat.v1.placeholder(dtype=tf.float32) - hub.add_signature(inputs=x, outputs=x*w) - graph = tf.Graph() - with graph.as_default(): - spec = hub.create_module_spec(double_module_fn) - m = hub.Module(spec) - # Export the module. - with tf.compat.v1.Session(graph=graph) as sess: - sess.run(tf.compat.v1.global_variables_initializer()) - m.export(save_path, sess) - -def _create_frozen_model(save_path): - graph = tf.Graph() - saved_model_dir = os.path.join(save_path) - with graph.as_default(): - x = tf.constant([[37.0, -23.0], [1.0, 4.0]]) - w = tf.Variable(tf.random.uniform([2, 2])) - y = tf.matmul(x, w) - tf.nn.softmax(y) - init_op = w.initializer - - # Create a builder - builder = saved_model.builder.SavedModelBuilder( - saved_model_dir) - - with tf.compat.v1.Session() as sess: - # Run the initializer on `w`. - sess.run(init_op) - - builder.add_meta_graph_and_variables( - sess, [saved_model.tag_constants.SERVING], - signature_def_map=None, - assets_collection=None) - - builder.save() - - frozen_file = os.path.join(save_path, 'frozen.pb') - freeze_graph.freeze_graph( - '', - '', - True, - '', - "Softmax", - '', - '', - frozen_file, - True, - '', - saved_model_tags=saved_model.tag_constants.SERVING, - input_saved_model_dir=saved_model_dir) -class APIAndShellTest(tf.test.TestCase): - """Tests for the Python API of the pip package.""" - - @classmethod - def setUpClass(cls): - cls.class_tmp_dir = tempfile.mkdtemp() - cls.tf_saved_model_dir = os.path.join(cls.class_tmp_dir, 'tf_saved_model') - cls.tf_saved_model_v1_dir = os.path.join( - cls.class_tmp_dir, 'tf_saved_model_v1') - cls.tf_frozen_model_dir = os.path.join(cls.class_tmp_dir, 'tf_frozen_model') - _createTensorFlowSavedModel(cls.tf_saved_model_dir) - _createTensorFlowSavedModelV1('b', cls.tf_saved_model_v1_dir) - _create_frozen_model(cls.tf_frozen_model_dir) - cls.tf_hub_module_dir = os.path.join(cls.class_tmp_dir, 'tf_hub_module') - _create_hub_module(cls.tf_hub_module_dir) - - @classmethod - def tearDownClass(cls): - shutil.rmtree(cls.class_tmp_dir) - - def setUp(self): - # Make sure this file is not being run from the source directory, to - # avoid picking up source files. - if os.path.isdir( - os.path.join(os.path.dirname(__file__), 'tensorflowjs')): - self.fail('Do not run this test from the Python source directory. ' - 'This file is intended to be run on pip install.') - - self._tmp_dir = tempfile.mkdtemp() - super(APIAndShellTest, self).setUp() - - def tearDown(self): - if os.path.isdir(self._tmp_dir): - shutil.rmtree(self._tmp_dir) - super(APIAndShellTest, self).tearDown() - - def testVersionString(self): - self.assertEqual(2, tfjs.__version__.count('.')) - - def testSaveKerasModel(self): - with self.test_session(): - # First create a toy keras model. - model = _createKerasModel('MergedDense') - - tfjs.converters.save_keras_model(model, self._tmp_dir) - - # Briefly check the model topology. - with open(os.path.join(self._tmp_dir, 'model.json')) as f: - json_content = json.load(f) - model_json = json_content['modelTopology'] - self.assertIsInstance(model_json['model_config'], dict) - self.assertIsInstance(model_json['model_config']['config'], dict) - self.assertIn('layers', model_json['model_config']['config']) - - weights_manifest = json_content['weightsManifest'] - self.assertIsInstance(weights_manifest, list) - - # Briefly check the weights manifest. - weight_shapes = dict() - weight_dtypes = dict() - for manifest_item in weights_manifest: - for weight in manifest_item['weights']: - weight_name = weight['name'] - weight_shapes[weight_name] = weight['shape'] - weight_dtypes[weight_name] = weight['dtype'] - - self.assertEqual( - sorted(list(weight_shapes.keys())), - sorted([ - 'MergedDense1/kernel', 'MergedDense1/bias', - 'MergedDense2/kernel' - ])) - self.assertEqual(weight_shapes['MergedDense1/kernel'], [3, 4]) - self.assertEqual(weight_shapes['MergedDense1/bias'], [4]) - self.assertEqual(weight_shapes['MergedDense2/kernel'], [4, 2]) - self.assertEqual(weight_dtypes['MergedDense1/kernel'], 'float32') - self.assertEqual(weight_dtypes['MergedDense1/bias'], 'float32') - self.assertEqual(weight_dtypes['MergedDense2/kernel'], 'float32') - - def testLoadKerasModel(self): - # Use separate tf.Graph and tf.compat.v1.Session contexts - # to prevent name collision. - with tf.Graph().as_default(), tf.compat.v1.Session(): - # First create a toy keras model. - model1 = _createKerasModel('MergedDense') - tfjs.converters.save_keras_model(model1, self._tmp_dir) - model1_weight_values = model1.get_weights() - - with tf.Graph().as_default(), tf.compat.v1.Session(): - # Load the model from saved artifacts. - model2 = tfjs.converters.load_keras_model( - os.path.join(self._tmp_dir, 'model.json')) - - # Compare the loaded model with the original one. - model2_weight_values = model2.get_weights() - self.assertEqual(len(model1_weight_values), len(model2_weight_values)) - for model1_weight_value, model2_weight_value in zip( - model1_weight_values, model2_weight_values): - self.assertAllClose(model1_weight_value, model2_weight_value) - - # Check the content of the output directory. - self.assertTrue(glob.glob(os.path.join(self._tmp_dir, 'group*-*'))) - - def testInvalidInputFormatRaisesError(self): - process = subprocess.Popen( - [ - 'tensorflowjs_converter', '--input_format', - 'nonsensical_format', self._tmp_dir, self._tmp_dir - ], - stdout=subprocess.PIPE, - stderr=subprocess.PIPE) - _, stderr = process.communicate() - self.assertGreater(process.returncode, 0) - self.assertIn(b'--input_format', tf.compat.as_bytes(stderr)) - - def testMissingInputPathRaisesError(self): - process = subprocess.Popen( - [ - 'tensorflowjs_converter' - ], - stdout=subprocess.PIPE, - stderr=subprocess.PIPE) - _, stderr = process.communicate() - self.assertGreater(process.returncode, 0) - self.assertIn(b'input_path', tf.compat.as_bytes(stderr)) - - def testKerasH5ConversionWorksFromCLI(self): - with tf.Graph().as_default(), tf.compat.v1.Session(): - # First create a toy keras model. - os.makedirs(os.path.join(self._tmp_dir, 'keras_h5')) - h5_path = os.path.join(self._tmp_dir, 'keras_h5', 'model.h5') - _createKerasModel('MergedDenseForCLI', h5_path) - - process = subprocess.Popen([ - 'tensorflowjs_converter', '--input_format', 'keras', h5_path, - self._tmp_dir - ]) - process.communicate() - self.assertEqual(0, process.returncode) - - # Briefly check the model topology. - with open(os.path.join(self._tmp_dir, 'model.json'), 'rt') as f: - json_content = json.load(f) - model_json = json_content['modelTopology'] - self.assertIsInstance(model_json['model_config'], dict) - self.assertIsInstance(model_json['model_config']['config'], dict) - self.assertIn('layers', model_json['model_config']['config']) - - weights_manifest = json_content['weightsManifest'] - self.assertIsInstance(weights_manifest, list) - - # Briefly check the weights manifest. - weight_shapes = dict() - weight_dtypes = dict() - for manifest_item in weights_manifest: - for weight in manifest_item['weights']: - weight_name = weight['name'] - weight_shapes[weight_name] = weight['shape'] - weight_dtypes[weight_name] = weight['dtype'] - - self.assertEqual( - sorted(list(weight_shapes.keys())), - sorted([ - 'MergedDenseForCLI1/kernel', 'MergedDenseForCLI1/bias', - 'MergedDenseForCLI2/kernel' - ])) - self.assertEqual(weight_shapes['MergedDenseForCLI1/kernel'], [3, 4]) - self.assertEqual(weight_shapes['MergedDenseForCLI1/bias'], [4]) - self.assertEqual(weight_shapes['MergedDenseForCLI2/kernel'], [4, 2]) - self.assertEqual(weight_dtypes['MergedDenseForCLI1/kernel'], 'float32') - self.assertEqual(weight_dtypes['MergedDenseForCLI1/bias'], 'float32') - self.assertEqual(weight_dtypes['MergedDenseForCLI2/kernel'], 'float32') - - # Verify that there is only one weight group due to the default - # non-split_weights_by_layer behavior. The model is a small one, which - # does not exceed the 4-MB shard size limit. Therefore, there should - # be only one weight file. - self.assertEqual( - 1, len(glob.glob(os.path.join(self._tmp_dir, 'group*')))) - - def testKerasH5ConversionSplitWeightsByLayerWorksFromCLI(self): - with tf.Graph().as_default(), tf.compat.v1.Session(): - # First create a toy keras model. - os.makedirs(os.path.join(self._tmp_dir, 'keras_h5')) - h5_path = os.path.join(self._tmp_dir, 'keras_h5', 'model.h5') - _createKerasModel('MergedDenseForCLI', h5_path) - - process = subprocess.Popen([ - 'tensorflowjs_converter', '--input_format', 'keras', - '--split_weights_by_layer', h5_path, self._tmp_dir - ]) - process.communicate() - self.assertEqual(0, process.returncode) - - # Briefly check the model topology. - with open(os.path.join(self._tmp_dir, 'model.json'), 'rt') as f: - json_content = json.load(f) - model_json = json_content['modelTopology'] - self.assertIsInstance(model_json['model_config'], dict) - self.assertIsInstance(model_json['model_config']['config'], dict) - self.assertIn('layers', model_json['model_config']['config']) - - weights_manifest = json_content['weightsManifest'] - self.assertIsInstance(weights_manifest, list) - - # Briefly check the weights manifest. - weight_shapes = dict() - weight_dtypes = dict() - for manifest_item in weights_manifest: - for weight in manifest_item['weights']: - weight_name = weight['name'] - weight_shapes[weight_name] = weight['shape'] - weight_dtypes[weight_name] = weight['dtype'] - - self.assertEqual( - sorted(list(weight_shapes.keys())), - sorted([ - 'MergedDenseForCLI1/kernel', 'MergedDenseForCLI1/bias', - 'MergedDenseForCLI2/kernel' - ])) - self.assertEqual(weight_shapes['MergedDenseForCLI1/kernel'], [3, 4]) - self.assertEqual(weight_shapes['MergedDenseForCLI1/bias'], [4]) - self.assertEqual(weight_shapes['MergedDenseForCLI2/kernel'], [4, 2]) - self.assertEqual(weight_dtypes['MergedDenseForCLI1/kernel'], 'float32') - self.assertEqual(weight_dtypes['MergedDenseForCLI1/bias'], 'float32') - self.assertEqual(weight_dtypes['MergedDenseForCLI2/kernel'], 'float32') - - # Verify that there are two weight groups due to the optional flag - # --split_weights_by_layer behavior. The model is a small one. None of - # the layers should have weight sizes exceeding the 4-MB shard size - # limit. - self.assertEqual( - 2, len(glob.glob(os.path.join(self._tmp_dir, 'group*')))) - - def testKerasH5ConversionWithSignatureNameErrors(self): - process = subprocess.Popen( - [ - 'tensorflowjs_converter', '--input_format', 'keras', - '--signature_name', 'bar', - os.path.join(self._tmp_dir, 'foo.h5'), - os.path.join(self._tmp_dir, 'output') - ], - stdout=subprocess.PIPE, - stderr=subprocess.PIPE) - _, stderr = process.communicate() - self.assertGreater(process.returncode, 0) - self.assertIn( - b'The --signature_name flag is applicable only to', - tf.compat.as_bytes(stderr)) - - def testConvertTFSavedModelV1WithCommandLineWorks(self): - output_dir = os.path.join(self._tmp_dir) - process = subprocess.Popen([ - 'tensorflowjs_converter', '--input_format', 'tf_saved_model', - '--output_format', 'tfjs_graph_model', - self.tf_saved_model_v1_dir, output_dir - ]) - process.communicate() - self.assertEqual(0, process.returncode) - - weights = [{ - 'paths': ['group1-shard1of1.bin'], - 'weights': [{'dtype': 'float32', 'name': 'w', 'shape': [2, 2]}]}] - - # Load the saved weights as a JSON string. - output_json = json.load( - open(os.path.join(output_dir, 'model.json'), 'rt')) - self.assertEqual(output_json['weightsManifest'], weights) - - # Check the content of the output directory. - self.assertTrue(glob.glob(os.path.join(output_dir, 'group*-*'))) - - - def testConvertTFHubModuleWithCommandLineWorks(self): - output_dir = os.path.join(self._tmp_dir) - process = subprocess.Popen([ - 'tensorflowjs_converter', '--input_format', 'tf_hub', - self.tf_hub_module_dir, output_dir - ]) - process.communicate() - self.assertEqual(0, process.returncode) - - weights = [{ - 'paths': ['group1-shard1of1.bin'], - 'weights': [{ - 'shape': [2], - 'name': 'module/Variable', - 'dtype': 'float32' - }] - }] - # Load the saved weights as a JSON string. - output_json = json.load( - open(os.path.join(output_dir, 'model.json'), 'rt')) - self.assertEqual(output_json['weightsManifest'], weights) - - # Check the content of the output directory. - self.assertTrue(glob.glob(os.path.join(output_dir, 'group*-*'))) - - def testConvertTFSavedModelWithCommandLineWorks(self): - output_dir = os.path.join(self._tmp_dir) - process = subprocess.Popen([ - 'tensorflowjs_converter', '--input_format', 'tf_saved_model', - '--output_format', 'tfjs_graph_model', - self.tf_saved_model_dir, output_dir - ]) - process.communicate() - self.assertEqual(0, process.returncode) - - weights = [{ - 'paths': ['group1-shard1of1.bin'], - 'weights': [{ - 'dtype': 'float32', - 'shape': [], - 'name': 'StatefulPartitionedCall/mul' - }] - }] - - # Load the saved weights as a JSON string. - output_json = json.load( - open(os.path.join(output_dir, 'model.json'), 'rt')) - weights_manifest = output_json['weightsManifest'] - self.assertEqual(len(weights_manifest), len(weights)) - if sys.version_info[0] < 3: - self.assertItemsEqual(weights_manifest[0]['paths'], - weights[0]['paths']) - self.assertItemsEqual(weights_manifest[0]['weights'], - weights[0]['weights']) - else: - self.assertCountEqual(weights_manifest[0]['paths'], - weights[0]['paths']) - self.assertCountEqual(weights_manifest[0]['weights'], - weights[0]['weights']) - - # Check the content of the output directory. - self.assertTrue(glob.glob(os.path.join(output_dir, 'group*-*'))) - - def testConvertTFSavedModelIntoShardedWeights(self): - output_dir = os.path.join(self._tmp_dir, 'tfjs_model') - # Do initial conversion without sharding. - process = subprocess.Popen([ - 'tensorflowjs_converter', '--input_format', 'tf_saved_model', - '--output_format', 'tfjs_graph_model', - self.tf_saved_model_dir, output_dir - ]) - process.communicate() - self.assertEqual(0, process.returncode) - - weight_files = glob.glob(os.path.join(output_dir, 'group*.bin')) - - # Get size of weights in bytes after graph optimizations. - optimized_total_weight = sum([os.path.getsize(f) for f in weight_files]) - # Due to the shard size, there ought to be 2 shards after conversion. - weight_shard_size_bytes = int(optimized_total_weight * 0.8) - - output_dir = os.path.join(self._tmp_dir, 'sharded_model') - # Convert Saved Model again with shard argument set. - process = subprocess.Popen([ - 'tensorflowjs_converter', '--input_format', 'tf_saved_model', - '--output_format', 'tfjs_graph_model', - '--weight_shard_size_bytes', str(weight_shard_size_bytes), - self.tf_saved_model_dir, output_dir - ]) - process.communicate() - self.assertEqual(0, process.returncode) - - weight_files = sorted(glob.glob(os.path.join(output_dir, 'group*.bin'))) - self.assertEqual(len(weight_files), 2) - weight_file_sizes = [os.path.getsize(f) for f in weight_files] - self.assertEqual(sum(weight_file_sizes), optimized_total_weight) - self.assertLess(weight_file_sizes[1], weight_file_sizes[0]) - - def testConvertTFFrozenModelWithCommandLineWorks(self): - output_dir = os.path.join(self._tmp_dir) - frozen_file = os.path.join(self.tf_frozen_model_dir, 'frozen.pb') - process = subprocess.Popen([ - 'tensorflowjs_converter', '--input_format', 'tf_frozen_model', - '--output_format', 'tfjs_graph_model', '--output_node_names', - 'Softmax', - frozen_file, output_dir - ]) - process.communicate() - self.assertEqual(0, process.returncode) - - # Check model.json and weights manifest. - with open(os.path.join(output_dir, 'model.json'), 'rt') as f: - model_json = json.load(f) - self.assertTrue(model_json['modelTopology']) - self.assertIsNot(model_json['modelTopology']['versions'], None) - signature = model_json['signature'] - self.assertIsNot(signature, None) - # frozen model signature has no inputs - self.assertIsNot(signature['outputs'], None) - - weights_manifest = model_json['weightsManifest'] - weights_manifest = model_json['weightsManifest'] - self.assertCountEqual(weights_manifest[0]['paths'], - ['group1-shard1of1.bin']) - self.assertIn('weights', weights_manifest[0]) - self.assertTrue( - glob.glob( - os.path.join(self._tmp_dir, 'group*-*'))) - - # Check the content of the output directory. - self.assertTrue(glob.glob(os.path.join(output_dir, 'group*-*'))) - - def testConvertTensorflowjsArtifactsToKerasH5(self): - # 1. Create a toy keras model and save it as an HDF5 file. - os.makedirs(os.path.join(self._tmp_dir, 'keras_h5')) - h5_path = os.path.join(self._tmp_dir, 'keras_h5', 'model.h5') - with tf.Graph().as_default(), tf.compat.v1.Session(): - model = _createKerasModel('MergedDenseForCLI', h5_path) - model_json = model.to_json() - - # 2. Convert the HDF5 file to tensorflowjs format. - process = subprocess.Popen([ - 'tensorflowjs_converter', '--input_format', 'keras', h5_path, - self._tmp_dir - ]) - process.communicate() - self.assertEqual(0, process.returncode) - - # 3. Convert the tensorflowjs artifacts back to HDF5. - new_h5_path = os.path.join(self._tmp_dir, 'model_2.h5') - process = subprocess.Popen([ - 'tensorflowjs_converter', '--input_format', 'tfjs_layers_model', - '--output_format', 'keras', - os.path.join(self._tmp_dir, 'model.json'), new_h5_path]) - process.communicate() - self.assertEqual(0, process.returncode) - - # 4. Load the model back from the new HDF5 file and compare with the - # original model. - with tf.Graph().as_default(), tf.compat.v1.Session(): - model_2 = tf.keras.models.load_model(new_h5_path) - model_2_json = model_2.to_json() - self.assertEqual(model_json, model_2_json) - - def testLoadTensorflowjsArtifactsAsKerasModel(self): - # 1. Create a toy keras model and save it as an HDF5 file. - os.makedirs(os.path.join(self._tmp_dir, 'keras_h5')) - h5_path = os.path.join(self._tmp_dir, 'keras_h5', 'model.h5') - with tf.Graph().as_default(), tf.compat.v1.Session(): - model = _createKerasModel('MergedDenseForCLI', h5_path) - model_json = model.to_json() - - # 2. Convert the HDF5 file to tensorflowjs format. - process = subprocess.Popen([ - 'tensorflowjs_converter', '--input_format', 'keras', h5_path, - self._tmp_dir - ]) - process.communicate() - self.assertEqual(0, process.returncode) - - # 3. Load the tensorflowjs artifacts as a tf.keras.Model instance. - with tf.Graph().as_default(), tf.compat.v1.Session(): - model_2 = tfjs.converters.load_keras_model( - os.path.join(self._tmp_dir, 'model.json')) - model_2_json = model_2.to_json() - self.assertEqual(model_json, model_2_json) - - def testVersion(self): - process = subprocess.Popen( - ['tensorflowjs_converter', '--version'], - stdout=subprocess.PIPE, - stderr=subprocess.PIPE) - stdout, _ = process.communicate() - self.assertEqual(0, process.returncode) - self.assertIn( - tf.compat.as_bytes('tensorflowjs %s' % tfjs.__version__), - tf.compat.as_bytes(stdout)) - - process = subprocess.Popen( - ['tensorflowjs_converter', '-v'], - stdout=subprocess.PIPE, - stderr=subprocess.PIPE) - stdout, _ = process.communicate() - self.assertEqual(0, process.returncode) - self.assertIn( - tf.compat.as_bytes('tensorflowjs %s' % tfjs.__version__), - tf.compat.as_bytes(stdout)) - - -class ConvertTfKerasSavedModelTest(tf.test.TestCase): - - def setUp(self): - super(ConvertTfKerasSavedModelTest, self).setUp() - self._tmp_dir = tempfile.mkdtemp() - - def tearDown(self): - if os.path.isdir(self._tmp_dir): - shutil.rmtree(self._tmp_dir) - super(ConvertTfKerasSavedModelTest, self).tearDown() - - def _createSimpleSequentialModel(self): - model = tf.keras.Sequential() - model.add(tf.keras.layers.Reshape([2, 3], input_shape=[6])) - model.add(tf.keras.layers.LSTM(10)) - model.add(tf.keras.layers.Dense(1, activation='sigmoid')) - model.compile(optimizer='adam', loss='binary_crossentropy') - model.predict(tf.ones((1, 6)), steps=1) - return model - - def _createNestedSequentialModel(self): - model = tf.keras.Sequential() - model.add(tf.keras.layers.Dense(6, input_shape=[10], activation='relu')) - model.add(self._createSimpleSequentialModel()) - model.compile(optimizer='adam', loss='binary_crossentropy') - model.predict(tf.ones((1, 10)), steps=1) - return model - - def _createFunctionalModelWithWeights(self): - input1 = tf.keras.Input(shape=[8]) - input2 = tf.keras.Input(shape=[10]) - y = tf.keras.layers.Concatenate()([input1, input2]) - y = tf.keras.layers.Dense(4, activation='softmax')(y) - model = tf.keras.Model([input1, input2], y) - model.compile(optimizer='adam', loss='binary_crossentropy') - model.predict([tf.ones((1, 8)), tf.ones((1, 10))], steps=1) - return model - - def testConvertTfKerasNestedSequentialSavedModelIntoTfjsFormat(self): - with tf.Graph().as_default(), tf.compat.v1.Session(): - x = np.random.randn(8, 10) - - # 1. Run the model.predict(), store the result. Then saved the model - # as a SavedModel. - model = self._createNestedSequentialModel() - y = model.predict(x) - - tf.keras.models.save_model(model, self._tmp_dir) - - # 2. Convert the keras saved model to tfjs format. - tfjs_output_dir = os.path.join(self._tmp_dir, 'tfjs') - # Implicit value of --output_format: tfjs_layers_model - process = subprocess.Popen([ - 'tensorflowjs_converter', '--input_format', 'keras_saved_model', - self._tmp_dir, tfjs_output_dir - ]) - process.communicate() - self.assertEqual(0, process.returncode) - - model_json_path = os.path.join(tfjs_output_dir, 'model.json') - self.assertTrue(os.path.isfile(model_json_path)) - - # 3. Convert the tfjs model to keras h5 format. - new_h5_path = os.path.join(self._tmp_dir, 'new_h5.h5') - process = subprocess.Popen([ - 'tensorflowjs_converter', '--input_format', 'tfjs_layers_model', - '--output_format', 'keras', model_json_path, new_h5_path]) - process.communicate() - self.assertEqual(0, process.returncode) - - self.assertTrue(os.path.isfile(new_h5_path)) - - # 4. Load the model back and assert on the equality of the predict - # results. - model_prime = tf.keras.models.load_model(new_h5_path) - new_y = model_prime.predict(x) - self.assertAllClose(y, new_y) - - def testConvertTfKerasFunctionalSavedModelIntoTfjsFormat(self): - with tf.Graph().as_default(), tf.compat.v1.Session(): - x1 = np.random.randn(4, 8) - x2 = np.random.randn(4, 10) - - # 1. Run the model.predict(), store the result. Then saved the model - # as a SavedModel. - model = self._createFunctionalModelWithWeights() - y = model.predict([x1, x2]) - - tf.keras.models.save_model(model, self._tmp_dir) - - # 2. Convert the keras saved model to tfjs format. - tfjs_output_dir = os.path.join(self._tmp_dir, 'tfjs') - # Use explicit --output_format value: tfjs_layers_model - process = subprocess.Popen([ - 'tensorflowjs_converter', '--input_format', 'keras_saved_model', - '--output_format', 'tfjs_layers_model', - self._tmp_dir, tfjs_output_dir - ]) - process.communicate() - self.assertEqual(0, process.returncode) - - model_json_path = os.path.join(tfjs_output_dir, 'model.json') - self.assertTrue(os.path.isfile(model_json_path)) - - # 3. Convert the tfjs model to keras h5 format. - new_h5_path = os.path.join(self._tmp_dir, 'new_h5.h5') - process = subprocess.Popen([ - 'tensorflowjs_converter', '--input_format', 'tfjs_layers_model', - '--output_format', 'keras', model_json_path, new_h5_path]) - process.communicate() - self.assertEqual(0, process.returncode) - - self.assertTrue(os.path.isfile(new_h5_path)) - - # 4. Load the model back and assert on the equality of the predict - # results. - model_prime = tf.keras.models.load_model(new_h5_path) - new_y = model_prime.predict([x1, x2]) - self.assertAllClose(y, new_y) - - def testUsingIncorrectKerasSavedModelRaisesError(self): - with tf.Graph().as_default(), tf.compat.v1.Session(): - # 1. Run the model.predict(), store the result. Then saved the model - # as a SavedModel. - model = self._createNestedSequentialModel() - tf.keras.models.save_model(model, self._tmp_dir) - - # 2. Convert the keras saved model to tfjs format. - tfjs_output_dir = os.path.join(self._tmp_dir, 'tfjs') - # Use incorrect --input_format value: keras - process = subprocess.Popen( - [ - 'tensorflowjs_converter', '--input_format', 'keras', - self._tmp_dir, tfjs_output_dir - ], - stdout=subprocess.PIPE, - stderr=subprocess.PIPE) - _, stderr = process.communicate() - self.assertIn( - b'Expected path to point to an HDF5 file, ' - b'but it points to a directory', tf.compat.as_bytes(stderr)) - - def testConvertTfjsLayersModelIntoShardedWeights(self): - with tf.Graph().as_default(), tf.compat.v1.Session(): - x = np.random.randn(8, 10) - - # 1. Run the model.predict(), store the result. Then saved the model - # as a SavedModel. - model = self._createNestedSequentialModel() - y = model.predict(x) - - weights = model.get_weights() - total_weight_bytes = sum(np.size(w) for w in weights) * 4 - - tf.keras.models.save_model(model, self._tmp_dir) - - # 2. Convert the keras saved model to tfjs_layers_model format. - tfjs_output_dir = os.path.join(self._tmp_dir, 'tfjs') - # Implicit value of --output_format: tfjs_layers_model - process = subprocess.Popen([ - 'tensorflowjs_converter', '--input_format', 'keras_saved_model', - self._tmp_dir, tfjs_output_dir - ]) - process.communicate() - self.assertEqual(0, process.returncode) - - # 3. Convert the tfjs_layers_model to another tfjs_layers_model, - # with sharded weights. - weight_shard_size_bytes = int(total_weight_bytes * 0.3) - # Due to the shard size, there ought to be 4 shards after conversion. - sharded_model_dir = os.path.join(self._tmp_dir, 'tfjs_sharded') - process = subprocess.Popen([ - 'tensorflowjs_converter', '--input_format', 'tfjs_layers_model', - '--output_format', 'tfjs_layers_model', - '--weight_shard_size_bytes', str(weight_shard_size_bytes), - os.path.join(tfjs_output_dir, 'model.json'), sharded_model_dir - ]) - process.communicate() - self.assertEqual(0, process.returncode) - - # 4. Check the sharded weight files and their sizes. - weight_files = sorted( - glob.glob(os.path.join(sharded_model_dir, 'group*.bin'))) - self.assertEqual(len(weight_files), 4) - weight_file_sizes = [os.path.getsize(f) for f in weight_files] - self.assertEqual(sum(weight_file_sizes), total_weight_bytes) - self.assertEqual(weight_file_sizes[0], weight_file_sizes[1]) - self.assertEqual(weight_file_sizes[0], weight_file_sizes[2]) - self.assertLess(weight_file_sizes[3], weight_file_sizes[0]) - - # 5. Convert the sharded tfjs_layers_model back into a keras h5 file. - new_h5_path = os.path.join(self._tmp_dir, 'new_h5.h5') - process = subprocess.Popen([ - 'tensorflowjs_converter', '--input_format', 'tfjs_layers_model', - os.path.join(sharded_model_dir, 'model.json'), new_h5_path - ]) - process.communicate() - self.assertEqual(0, process.returncode) - - with tf.Graph().as_default(), tf.compat.v1.Session(): - # 6. Load the keras model and check the predict() output is close to - # before. - new_model = tf.keras.models.load_model(new_h5_path) - new_y = new_model.predict(x) - self.assertAllClose(new_y, y) - - def testConvertTfjsLayersModelWithLegacyQuantization(self): - with tf.Graph().as_default(), tf.compat.v1.Session(): - # 1. Saved the model as a SavedModel. - model = self._createNestedSequentialModel() - - weights = model.get_weights() - total_weight_bytes = sum(np.size(w) for w in weights) * 4 - - tf.keras.models.save_model(model, self._tmp_dir) - - # 2. Convert the keras saved model to tfjs_layers_model format. - tfjs_output_dir = os.path.join(self._tmp_dir, 'tfjs') - # Implicit value of --output_format: tfjs_layers_model - process = subprocess.Popen([ - 'tensorflowjs_converter', '--input_format', 'keras_saved_model', - self._tmp_dir, tfjs_output_dir - ]) - process.communicate() - self.assertEqual(0, process.returncode) - - # 3. Convert the tfjs_layers_model to another tfjs_layers_model, - # with uint16 quantization. - sharded_model_dir = os.path.join(self._tmp_dir, 'tfjs_sharded') - process = subprocess.Popen([ - 'tensorflowjs_converter', '--input_format', 'tfjs_layers_model', - '--output_format', 'tfjs_layers_model', - '--quantization_bytes', '2', - os.path.join(tfjs_output_dir, 'model.json'), sharded_model_dir - ]) - process.communicate() - self.assertEqual(0, process.returncode) - - # 4. Check the quantized weight file and its size. - weight_files = sorted( - glob.glob(os.path.join(sharded_model_dir, 'group*.bin'))) - self.assertEqual(len(weight_files), 1) - weight_file_size = os.path.getsize(weight_files[0]) - # The size of the weight file should reflect the uint16 quantization. - self.assertEqual(weight_file_size, total_weight_bytes // 2) - - - def testConvertTfjsLayersModelWithQuantization(self): - with tf.Graph().as_default(), tf.compat.v1.Session(): - # 1. Saved the model as a SavedModel. - model = self._createNestedSequentialModel() - - weights = model.get_weights() - total_weight_bytes = sum(np.size(w) for w in weights) * 4 - - tf.keras.models.save_model(model, self._tmp_dir) - - # 2. Convert the keras saved model to tfjs_layers_model format. - tfjs_output_dir = os.path.join(self._tmp_dir, 'tfjs') - # Implicit value of --output_format: tfjs_layers_model - process = subprocess.Popen([ - 'tensorflowjs_converter', '--input_format', 'keras_saved_model', - self._tmp_dir, tfjs_output_dir - ]) - process.communicate() - self.assertEqual(0, process.returncode) - - # 3. Convert the tfjs_layers_model to another tfjs_layers_model, - # with uint16 quantization. - sharded_model_dir = os.path.join(self._tmp_dir, 'tfjs_sharded') - process = subprocess.Popen([ - 'tensorflowjs_converter', '--input_format', 'tfjs_layers_model', - '--output_format', 'tfjs_layers_model', - '--quantize_uint16', '*', - os.path.join(tfjs_output_dir, 'model.json'), sharded_model_dir - ]) - process.communicate() - self.assertEqual(0, process.returncode) - - # 4. Check the quantized weight file and its size. - weight_files = sorted( - glob.glob(os.path.join(sharded_model_dir, 'group*.bin'))) - self.assertEqual(len(weight_files), 1) - weight_file_size = os.path.getsize(weight_files[0]) - # The size of the weight file should reflect the uint16 quantization. - self.assertEqual(weight_file_size, total_weight_bytes // 2) - - def testConvertTfjsLayersModelToTfjsGraphModel(self): - with tf.Graph().as_default(), tf.compat.v1.Session(): - # 1. Create a model for testing. - model = tf.keras.Sequential() - model.add(tf.keras.layers.Dense(10, activation='relu', input_shape=[4])) - model.add(tf.keras.layers.Dense(1, activation='sigmoid')) - model.compile(optimizer='adam', loss='binary_crossentropy') - model.predict(tf.ones((1, 4)), steps=1) - - h5_path = os.path.join(self._tmp_dir, 'model.h5') - model.save(h5_path, save_format='h5') - - # 2. Convert the keras saved model to tfjs_layers_model format. - layers_model_output_dir = os.path.join(self._tmp_dir, 'tfjs_layers') - # Implicit value of --output_format: tfjs_layers_model - process = subprocess.Popen([ - 'tensorflowjs_converter', '--input_format', 'keras', - h5_path, layers_model_output_dir - ]) - process.communicate() - self.assertEqual(0, process.returncode) - - # 3. Convert the tfjs_layers_model to another tfjs_graph_model. - graph_model_dir = os.path.join(self._tmp_dir, 'tfjs_graph') - process = subprocess.Popen([ - 'tensorflowjs_converter', '--input_format', 'tfjs_layers_model', - '--output_format', 'tfjs_graph_model', - os.path.join(layers_model_output_dir, 'model.json'), graph_model_dir - ]) - process.communicate() - self.assertEqual(0, process.returncode) - - # 4. Check the model.json and weight file and its size. - self.assertTrue(os.path.isfile(os.path.join(graph_model_dir, 'model.json'))) - weight_files = sorted( - glob.glob(os.path.join(graph_model_dir, 'group*.bin'))) - self.assertEqual(len(weight_files), 1) - - def testConvertTfjsLayersModelToKerasSavedModel(self): - with tf.Graph().as_default(), tf.compat.v1.Session(): - # 1. Create a model for testing. - model = tf.keras.Sequential() - model.add(tf.keras.layers.Dense(10, activation='relu', input_shape=[4])) - model.add(tf.keras.layers.Dense(1, activation='sigmoid')) - model.compile(optimizer='adam', loss='binary_crossentropy') - model.predict(tf.ones((1, 4)), steps=1) - - h5_path = os.path.join(self._tmp_dir, 'model.h5') - model.save(h5_path, save_format='h5') - - # 2. Convert the keras saved model to tfjs_layers_model format. - layers_model_output_dir = os.path.join(self._tmp_dir, 'tfjs_layers') - # Implicit value of --output_format: tfjs_layers_model - process = subprocess.Popen([ - 'tensorflowjs_converter', '--input_format', 'keras', - h5_path, layers_model_output_dir - ]) - process.communicate() - self.assertEqual(0, process.returncode) - - # 3. Convert the tfjs_layers_model to another keras_saved_model. - keras_saved_model_dir = os.path.join(self._tmp_dir, 'keras_saved_model') - process = subprocess.Popen([ - 'tensorflowjs_converter', '--input_format', 'tfjs_layers_model', - '--output_format', 'keras_saved_model', - os.path.join(layers_model_output_dir, 'model.json'), - keras_saved_model_dir - ]) - process.communicate() - self.assertEqual(0, process.returncode) - - # 4. Check the files that belong to the conversion result. - files = glob.glob(os.path.join(keras_saved_model_dir, '*')) - self.assertIn(os.path.join(keras_saved_model_dir, 'saved_model.pb'), files) - self.assertIn(os.path.join(keras_saved_model_dir, 'variables'), files) - self.assertIn(os.path.join(keras_saved_model_dir, 'assets'), files) - - -if __name__ == '__main__': - tf.test.main() diff --git a/tfjs-master/tfjs-converter/python/update_locked_deps.sh b/tfjs-master/tfjs-converter/python/update_locked_deps.sh deleted file mode 100644 index cd7345e28..000000000 --- a/tfjs-master/tfjs-converter/python/update_locked_deps.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env bash -# Copyright 2022 Google LLC. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================= - - -# This script updates the pip requirements lock files that pin the installed -# versions of pypi packages. - -bazel run //tfjs-converter/python:tensorflowjs_deps_requirements.update -bazel run //tfjs-converter/python:tensorflowjs_dev_deps_requirements.update diff --git a/tfjs-master/tfjs-converter/scripts/BUILD.bazel b/tfjs-master/tfjs-converter/scripts/BUILD.bazel deleted file mode 100644 index 6834cf9c2..000000000 --- a/tfjs-master/tfjs-converter/scripts/BUILD.bazel +++ /dev/null @@ -1,65 +0,0 @@ -load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_binary") -load("//tools:defaults.bzl", "ts_library") - -package(default_visibility = ["//visibility:public"]) - -exports_files( - ["op.template.ts"], - visibility = ["//visibility:public"], -) - -ts_library( - name = "test_snippets_lib", - testonly = True, - srcs = [ - "test_snippets.ts", - ], - deps = [ - "//tfjs-backend-cpu/src:tfjs-backend-cpu_lib", - "//tfjs-converter/src:tfjs-converter_lib", - "//tfjs-core/scripts/test_snippets:test_snippets_util_lib", - "//tfjs-core/src:tfjs-core_lib", - "//tfjs-core/src:tfjs-core_src_lib", - ], -) - -ts_library( - name = "gen_op_lib", - srcs = [ - ":gen_op.ts", - ], - deps = [ - "@npm//@types/argparse", - "@npm//@types/node", - "@npm//argparse", - ], -) - -nodejs_binary( - name = "gen_op_bin", - data = [ - ":gen_op_lib", - ], - entry_point = "gen_op.ts", -) - -ts_library( - name = "kernels_to_ops_lib", - srcs = [ - ":kernels_to_ops.ts", - ], - deps = [ - "@npm//@types/argparse", - "@npm//@types/node", - "@npm//argparse", - "@npm//ts-morph", - ], -) - -nodejs_binary( - name = "kernels_to_ops_bin", - data = [ - ":kernels_to_ops_lib", - ], - entry_point = "kernels_to_ops.ts", -) diff --git a/tfjs-master/tfjs-converter/scripts/build-npm.sh b/tfjs-master/tfjs-converter/scripts/build-npm.sh deleted file mode 100644 index 2bc67b4a9..000000000 --- a/tfjs-master/tfjs-converter/scripts/build-npm.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env bash -# Copyright 2018 Google LLC. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================= - -# Exit immediately if a command exits with a non-zero status. -set -e - -yarn rimraf dist/ -yarn -yarn build-ci -yarn rollup -c --visualize --npm - -echo "Stored standalone library at dist/tf-converter(.min).js" -npm pack diff --git a/tfjs-master/tfjs-converter/scripts/cloud_funcs/README.md b/tfjs-master/tfjs-converter/scripts/cloud_funcs/README.md deleted file mode 100644 index d17ac4deb..000000000 --- a/tfjs-master/tfjs-converter/scripts/cloud_funcs/README.md +++ /dev/null @@ -1,21 +0,0 @@ -This directory contains the following Google Cloud Function. - -### `trigger_nightly` -Programatically triggers a Cloud Build on master. This function is called by the Cloud Scheduler at 3am EST every day (configurable via the Cloud Scheduler UI). -You can also trigger the function manually via the Cloud UI. - -Command to re-deploy: -```sh -gcloud functions deploy converter_python_nightly \ - --runtime nodejs8 \ - --trigger-topic converter_python_nightly -``` - -### The pipeline - -The pipeline looks like this: - -1) At 3am, Cloud Scheduler writes to `nightly` topic -2) That triggers the `nightly` function, which starts a build programatically -3) That build runs and writes its status to `cloud-builds` topic -4) That triggers the `send_email` function, which sends email and chat with the build status. diff --git a/tfjs-master/tfjs-converter/scripts/cloud_funcs/trigger_nightly/index.js b/tfjs-master/tfjs-converter/scripts/cloud_funcs/trigger_nightly/index.js deleted file mode 100644 index 65e64d6fd..000000000 --- a/tfjs-master/tfjs-converter/scripts/cloud_funcs/trigger_nightly/index.js +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2019 Google LLC. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= - -const {google} = require('googleapis'); - -module.exports.converter_python_nightly = async data => { - const cloudbuild = google.cloudbuild('v1'); - const auth = await google.auth.getClient( - {scopes: ['https://www.googleapis.com/auth/cloud-platform']}); - google.options({auth}); - const resp = await cloudbuild.projects.triggers.run({ - 'projectId': 'learnjs-174218', - 'triggerId': 'tfjs-converter-nightly-test', - 'resource': {'branchName': 'master'} - }); - console.log(resp); -}; diff --git a/tfjs-master/tfjs-converter/scripts/cloud_funcs/trigger_nightly/package.json b/tfjs-master/tfjs-converter/scripts/cloud_funcs/trigger_nightly/package.json deleted file mode 100644 index 38b313a61..000000000 --- a/tfjs-master/tfjs-converter/scripts/cloud_funcs/trigger_nightly/package.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "name": "cloudbuild", - "version": "1.0.0", - "description": "", - "main": "index.js", - "dependencies": { - "googleapis": "^39.2.0" - } -} diff --git a/tfjs-master/tfjs-converter/scripts/create_python_pips.sh b/tfjs-master/tfjs-converter/scripts/create_python_pips.sh deleted file mode 100644 index 19a46b106..000000000 --- a/tfjs-master/tfjs-converter/scripts/create_python_pips.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env bash -# Copyright 2021 Google LLC. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================= - -# Exit the script on any command with non 0 return code -set -e - -yarn bazel build tfjs-converter/python:python3_wheel diff --git a/tfjs-master/tfjs-converter/scripts/gen_doc.ts b/tfjs-master/tfjs-converter/scripts/gen_doc.ts deleted file mode 100644 index 02fdd499a..000000000 --- a/tfjs-master/tfjs-converter/scripts/gen_doc.ts +++ /dev/null @@ -1,177 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import * as fs from 'fs'; - -import * as arithmetic from '../src/operations/op_list/arithmetic'; -import * as basicMath from '../src/operations/op_list/basic_math'; -import * as control from '../src/operations/op_list/control'; -import * as convolution from '../src/operations/op_list/convolution'; -import * as creation from '../src/operations/op_list/creation'; -import * as dynamic from '../src/operations/op_list/dynamic'; -import * as evaluation from '../src/operations/op_list/evaluation'; -import * as graph from '../src/operations/op_list/graph'; -import * as hashtable from '../src/operations/op_list/hash_table'; -import * as image from '../src/operations/op_list/image'; -import * as logical from '../src/operations/op_list/logical'; -import * as matrices from '../src/operations/op_list/matrices'; -import * as normalization from '../src/operations/op_list/normalization'; -import * as reduction from '../src/operations/op_list/reduction'; -import * as sliceJoin from '../src/operations/op_list/slice_join'; -import * as sparse from '../src/operations/op_list/sparse'; -import * as spectral from '../src/operations/op_list/spectral'; -import * as string from '../src/operations/op_list/string'; -import * as transformation from '../src/operations/op_list/transformation'; -import {OpMapper} from '../src/operations/types'; - -// tfjs-core api file is generated by tfjs-website project and should be -// manually copied over before running this script. -const JSON_DIR = './tfjs-core.json'; -const DOC_DIR = './docs/'; -const ops = [ - arithmetic, basicMath, control, convolution, creation, dynamic, evaluation, - graph, hashtable, image, logical, matrices, normalization, reduction, - sliceJoin, sparse, spectral, string, transformation -]; - -async function genDoc() { - const json = JSON.parse(fs.readFileSync(JSON_DIR, 'utf8')); - // tslint:disable-next-line:no-any - const coreApis = json.docs.headings.reduce((list: Array<{}>, h: any) => { - return h.subheadings ? list.concat(h.subheadings.reduce( - // tslint:disable-next-line:no-any - (sublist: Array<{}>, sub: any) => { - return sublist.concat(sub.symbols); - }, - [])) : - list; - }, []); - const output: string[] = []; - - output.push('# Supported Tensorflow Ops\n\n'); - - generateTable( - 'Operations', 'Arithmetic', (arithmetic.json as {}) as OpMapper[], output, - coreApis); - generateTable( - 'Operations', 'Basic math', (basicMath.json as {}) as OpMapper[], output, - coreApis); - generateTable( - 'Operations', 'Control Flow', (control.json as {}) as OpMapper[], output, - coreApis); - generateTable( - 'Operations', 'Convolution', (convolution.json as {}) as OpMapper[], - output, coreApis); - generateTable( - 'Tensors', 'Creation', (creation.json as {}) as OpMapper[], output, - coreApis); - generateTable( - 'Operations', 'Dynamic', (dynamic.json as {}) as OpMapper[], output, - coreApis); - generateTable( - 'Operations', 'Evaluation', (evaluation.json as {}) as OpMapper[], output, - coreApis); - generateTable( - 'Tensorflow', 'Graph', (graph.json as {}) as OpMapper[], output, - coreApis); - generateTable( - 'Operations', 'Hashtable', (hashtable.json as {}) as OpMapper[], output, - coreApis); - generateTable( - 'Operations', 'Images', (image.json as {}) as OpMapper[], output, - coreApis); - generateTable( - 'Operations', 'Linear Algebra', [] as OpMapper[], output, coreApis); - generateTable( - 'Operations', 'Logical', (logical.json as {}) as OpMapper[], output, - coreApis); - generateTable( - 'Operations', 'Matrices', (matrices.json as {}) as OpMapper[], output, - coreApis); - generateTable( - 'Operations', 'Moving Average', [] as OpMapper[], output, coreApis); - generateTable( - 'Operations', 'Normalization', (normalization.json as {}) as OpMapper[], - output, coreApis); - generateTable( - 'Operations', 'Reduction', (reduction.json as {}) as OpMapper[], output, - coreApis); - generateTable('Tensors', 'RNN', [] as OpMapper[], output, coreApis); - generateTable('Operations', 'Scan', [] as OpMapper[], output, coreApis); - generateTable('Operations', 'Segment', [] as OpMapper[], output, coreApis); - generateTable('Operations', 'Signal', [] as OpMapper[], output, coreApis); - generateTable( - 'Tensors', 'Slicing and Joining', (sliceJoin.json as {}) as OpMapper[], - output, coreApis); - generateTable( - 'Operations', 'Sparse', (sparse.json as {}) as OpMapper[], output, - coreApis); - generateTable( - 'Operations', 'Spectral', (spectral.json as {}) as OpMapper[], output, - coreApis); - generateTable( - 'Operations', 'String', (string.json as {}) as OpMapper[], output, - coreApis); - generateTable( - 'Tensors', 'Transformations', (transformation.json as {}) as OpMapper[], - output, coreApis); - - console.log(process.cwd()); - fs.writeFileSync(DOC_DIR + 'supported_ops.md', output.join('')); - - console.log( - `Supported Ops written to ${DOC_DIR + 'supported_ops.md'}\n` + - `Found ${ops.reduce((sum, cat) => sum += cat.json.length, 0)} ops\n`); -} - -function findCoreOps(heading: string, subHeading: string, coreApis: Array<{}>) { - return coreApis.filter( - // tslint:disable-next-line:no-any - (op: any) => op.docInfo.heading === heading && - op.docInfo.subheading === subHeading); -} - -function generateTable( - heading: string, subHeading: string, ops: OpMapper[], output: string[], - coreApis: Array<{}>) { - const coreOps = findCoreOps(heading, subHeading, coreApis); - output.push(`## ${heading} - ${subHeading}\n\n`); - output.push('|Tensorflow Op Name|Tensorflow.js Op Name|\n'); - output.push('|---|---|\n'); - ops.sort((a, b) => a.tfOpName.localeCompare(b.tfOpName)).forEach(element => { - const coreOp = coreOps.find( - (op: any) => op.symbolName.toLocaleLowerCase() === - element.tfOpName.toLocaleLowerCase()); - - output.push(`|${element.tfOpName}|${ - coreOp ? (coreOp as any).symbolName : element.tfOpName}|\n`); - }); - - coreOps - // tslint:disable-next-line:no-any - .sort((a: any, b: any) => a.symbolName.localeCompare(b.symbolName)) - // tslint:disable-next-line:no-any - .forEach((element: any) => { - if (!ops.find( - op => op.tfOpName.toLocaleLowerCase() === - element.symbolName.toLocaleLowerCase())) { - output.push(`|Not mapped|${element.symbolName}|\n`); - } - }); - output.push('\n'); -} - -genDoc(); diff --git a/tfjs-master/tfjs-converter/scripts/gen_op.bzl b/tfjs-master/tfjs-converter/scripts/gen_op.bzl deleted file mode 100644 index 7e3370611..000000000 --- a/tfjs-master/tfjs-converter/scripts/gen_op.bzl +++ /dev/null @@ -1,59 +0,0 @@ -# Copyright 2021 Google LLC. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================= - -load("@bazel_skylib//lib:paths.bzl", "paths") -load("@build_bazel_rules_nodejs//:providers.bzl", "run_node") - -def _gen_op_impl(ctx): - files = [f for s in ctx.attr.srcs for f in s.files.to_list()] - outputs = [] - - for f in files: - ts_filename = f.basename[:-len(f.extension)] + "ts" - dest_path = paths.join(ctx.attr.dest_dir, ts_filename) - output_file = ctx.actions.declare_file(dest_path) - outputs.append(output_file) - run_node( - ctx, - executable = "gen_op_bin", - inputs = [f], - outputs = [output_file], - arguments = [ - f.path, - output_file.path, - ], - ) - - return [DefaultInfo(files = depset(outputs))] - -gen_op = rule( - implementation = _gen_op_impl, - attrs = { - "dest_dir": attr.string( - mandatory = True, - doc = "Output directory for the generated .ts files relative to the BUILD file", - ), - "gen_op_bin": attr.label( - executable = True, - cfg = "exec", - default = Label("@//tfjs-converter/scripts:gen_op_bin"), - doc = "The script that generates ts ops from json", - ), - "srcs": attr.label_list( - allow_files = [".json"], - doc = "The json files to generate the ops from", - ), - }, -) diff --git a/tfjs-master/tfjs-converter/scripts/gen_op.ts b/tfjs-master/tfjs-converter/scripts/gen_op.ts deleted file mode 100644 index 39d66d8ef..000000000 --- a/tfjs-master/tfjs-converter/scripts/gen_op.ts +++ /dev/null @@ -1,41 +0,0 @@ -import * as argparse from 'argparse'; -import * as fs from 'fs'; - -const parser = new argparse.ArgumentParser(); - -parser.addArgument( - 'json', {help: 'Path to json input file'}); - -parser.addArgument( - 'out', {help: 'Path to write output'}); - -const {json, out} = parser.parseArgs() as { - json: string, - out: string, -}; - -const jsonContents = fs.readFileSync(json, 'utf8').replace(/"/g, '\''); -const tsContents = ` -/** - * @license - * Copyright ${new Date().getFullYear()} Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {OpMapper} from '../types'; - -export const json: OpMapper[] = ${jsonContents}; -`; - -fs.writeFileSync(out, tsContents); diff --git a/tfjs-master/tfjs-converter/scripts/kernels_to_ops.bzl b/tfjs-master/tfjs-converter/scripts/kernels_to_ops.bzl deleted file mode 100644 index 6b119a2bd..000000000 --- a/tfjs-master/tfjs-converter/scripts/kernels_to_ops.bzl +++ /dev/null @@ -1,50 +0,0 @@ -# Copyright 2021 Google LLC. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================= - -load("@build_bazel_rules_nodejs//:providers.bzl", "run_node") - -def _kernels_to_ops_impl(ctx): - output_file = ctx.outputs.out - run_node( - ctx, - executable = "kernels_to_ops_bin", - inputs = ctx.files.srcs, - outputs = [output_file], - arguments = [ - "--out", - output_file.path, - ], - ) - - return [DefaultInfo(files = depset([output_file]))] - -kernels_to_ops = rule( - implementation = _kernels_to_ops_impl, - attrs = { - "kernels_to_ops_bin": attr.label( - executable = True, - cfg = "exec", - default = Label("@//tfjs-converter/scripts:kernels_to_ops_bin"), - doc = "The script that generates the kernel2op.json metadata file", - ), - "out": attr.output( - mandatory = True, - doc = "Output label for the generated .json file", - ), - "srcs": attr.label_list( - doc = "The files in the ts project", - ), - }, -) diff --git a/tfjs-master/tfjs-converter/scripts/kernels_to_ops.ts b/tfjs-master/tfjs-converter/scripts/kernels_to_ops.ts deleted file mode 100644 index 9ff1f6998..000000000 --- a/tfjs-master/tfjs-converter/scripts/kernels_to_ops.ts +++ /dev/null @@ -1,159 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -/** - * This script generates a mapping of Kernel Names to op names as defined by - * the converter source code. This allows a couple of things for modular builds - * 1. From a model.json file we can create imports for the ops the converter - * will call. - * 2. From those ops we could validate that the kernels we add to the modular - * build match the names of kernels in model.json (this is not necessary - * but is potentially useful for alignment). - * - * This can also be used to keep our supported ops list up to date. - * - * The approach used is to parse the source code of the converter executors - * (src/operations/executors) for the following kind pattern. - * case 'BiasAdd': - * case 'AddV2': - * case 'Add': { - * return [tfc.add( - * (getParamValue('a', node, tensorMap, context) as tfc.Tensor), - * getParamValue('b', node, tensorMap, context) as tfc.Tensor)]; - * } - * - * Case matchers represent kernel names and tfc.*(...) represent the tfjs op(s) - * that are called. This example shows that we need to support fallthrough case - * statements as well. - * - */ - -import * as argparse from 'argparse'; -import * as fs from 'fs'; -import {CaseClause, CaseOrDefaultClause, Project, SourceFile, SwitchStatement, SyntaxKind} from 'ts-morph'; - -const parser = new argparse.ArgumentParser(); - -parser.addArgument( - '--out', {help: 'Path to output JSON to create', required: true}); - -const project = new Project({}); - -function getSwitchStatement(source: SourceFile): SwitchStatement { - // Each executor only has one switch statment. - let switchStatement: SwitchStatement; - source.forEachDescendant((node) => { - if (node.getKindName() === 'SwitchStatement') { - switchStatement = node as SwitchStatement; - } - }); - return switchStatement; -} - -type KernelMapping = { - [key: string]: string[] -}; - -function getKernelMappingForFile(source: SourceFile) { - const switchStatement = getSwitchStatement(source); - if (switchStatement == null) { - throw new Error('No switch statment found in executor'); - } - const caseClauses = switchStatement.getClauses(); - - const kernelsToOp: KernelMapping = {}; - let currentClauseGroup: string[] = []; - - // Loop through clauses until you reach one that has a block or return. - // This allows us to coalesce fallthrough case blocks in a switch statement. - caseClauses.forEach((caseClause: CaseOrDefaultClause) => { - if (caseClause instanceof CaseClause) { - let kernelName; - caseClause.forEachChild(clausePart => { - const kind = clausePart.getKindName(); - if (kind === 'StringLiteral') { - kernelName = clausePart.getText().replace(/\'/g, ''); - currentClauseGroup.push(kernelName); - } - if (kind === 'Block' || kind === 'ReturnStatement') { - // We have reached a code block, all the previously captured - // kernels use this block as their execution path. - - // Parse the code block and determing all the tfc.*() function calls - // used. - const callExprs = - clausePart.getDescendantsOfKind(SyntaxKind.CallExpression); - const tfOpsCallExprs = - callExprs.filter(expr => expr.getText().match(/ops/)); - const tfSymbols: Set = new Set(); - for (const tfOpsCall of tfOpsCallExprs) { - const tfOpsCallStr = tfOpsCall.getText(); - const functionCallMatcher = /(ops\.([\w\.]*)\()/g; - const matches = tfOpsCallStr.match(functionCallMatcher); - if (matches != null && matches.length > 0) { - for (const match of matches) { - // extract the method name (and any namespaces used to call it) - const symbolMatcher = /(ops\.([\w\.]*)\()/; - const symbol = match.match(symbolMatcher)[2]; - tfSymbols.add(symbol); - } - } - } - for (const kern of currentClauseGroup) { - kernelsToOp[kern] = Array.from(tfSymbols); - } - // Reset the clause tracker as we are moving to a new set of kernels - currentClauseGroup = []; - } - }); - } - }); - - return kernelsToOp; -} - -function getKernelMapping() { - const sourceFiles = project.getSourceFiles(); - const kernelsToOp: KernelMapping = {}; - - for (const sourceFile of sourceFiles) { - const mapping = getKernelMappingForFile(sourceFile); - Object.assign(kernelsToOp, mapping); - } - return kernelsToOp; -} - -async function run(outputFilePath: string) { - const EXECUTORS_PATH = 'tfjs-converter/src/operations/executors/*_executor.ts'; - project.addSourceFilesAtPaths(EXECUTORS_PATH); - - const kernelMapping = getKernelMapping(); - - const pairs: Array<[string, string[]]> = Object.entries(kernelMapping).sort(); - const sortedKernelMapping: KernelMapping = {}; - pairs.forEach(([k, v]) => { - sortedKernelMapping[k] = v; - }); - const replacer: null = null; - const space = 2; - fs.writeFileSync( - outputFilePath, JSON.stringify(sortedKernelMapping, replacer, space), - {encoding: 'utf8'}); -} - -const args = parser.parseArgs(); -run(args.out); diff --git a/tfjs-master/tfjs-converter/scripts/tag-version b/tfjs-master/tfjs-converter/scripts/tag-version deleted file mode 100644 index 19f0194ff..000000000 --- a/tfjs-master/tfjs-converter/scripts/tag-version +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/env node -// Copyright 2018 Google LLC. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= - - -// Run this script from the base directory (not the script directory): -// ./scripts/tag-version - -var fs = require('fs'); -var exec = require('child_process').exec; - -var version = JSON.parse(fs.readFileSync('package.json', 'utf8')).version; -var tag = `v${version}`; - -exec(`git tag ${tag}`, err => { - if (err) { - throw new Error(`Could not git tag with ${tag}: ${err.message}.`); - } - console.log(`Successfully tagged with ${tag}.`); -}); - -exec(`git push --tags`, err => { - if (err) { - throw new Error(`Could not push git tags: ${err.message}.`); - } - console.log(`Successfully pushed tags.`); -}); diff --git a/tfjs-master/tfjs-converter/scripts/test_snippets.ts b/tfjs-master/tfjs-converter/scripts/test_snippets.ts deleted file mode 100644 index 839b1c7a1..000000000 --- a/tfjs-master/tfjs-converter/scripts/test_snippets.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import '@tensorflow/tfjs-backend-cpu'; -// tslint:disable-next-line: no-imports-from-dist -import '@tensorflow/tfjs-core/dist/public/chained_ops/register_all_chained_ops'; -// tslint:disable-next-line: no-imports-from-dist -import '@tensorflow/tfjs-core/dist/register_all_gradients'; - -import * as tfc from '@tensorflow/tfjs-core'; -// tslint:disable-next-line: no-imports-from-dist -import {parseAndEvaluateSnippets} from '@tensorflow/tfjs-core/dist/scripts/test_snippets/util'; - -import * as tfconv from '../src/index'; - -const tf = { - ...tfconv, - ...tfc -}; -parseAndEvaluateSnippets(tf); diff --git a/tfjs-master/tfjs-converter/scripts/tsconfig.json b/tfjs-master/tfjs-converter/scripts/tsconfig.json deleted file mode 100644 index c5e8c9340..000000000 --- a/tfjs-master/tfjs-converter/scripts/tsconfig.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "../tsconfig.test", - "compilerOptions": { - "module": "commonjs" - } -} diff --git a/tfjs-master/tfjs-converter/src/BUILD.bazel b/tfjs-master/tfjs-converter/src/BUILD.bazel deleted file mode 100644 index 941640fb7..000000000 --- a/tfjs-master/tfjs-converter/src/BUILD.bazel +++ /dev/null @@ -1,79 +0,0 @@ -# Copyright 2021 Google LLC. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================= - -load("//tfjs-converter/scripts:gen_op.bzl", "gen_op") -load("//tools:defaults.bzl", "ts_library") - -package(default_visibility = ["//visibility:public"]) - -TEST_SRCS = [ - "**/*_test.ts", - "run_tests.ts", - "operations/executors/spy_ops.ts", -] - -# Used for test-snippets -filegroup( - name = "all_srcs", - srcs = glob(["**/*.ts"]), -) - -gen_op( - name = "ops_ts_files", - srcs = [ - "//tfjs-converter/python/tensorflowjs/op_list:ops", - ], - dest_dir = "operations/op_list/", -) - -ts_library( - name = "tfjs-converter_src_lib", - srcs = glob( - ["**/*.ts"], - exclude = TEST_SRCS + ["index.ts"], - ) + [":ops_ts_files"], - module_name = "@tensorflow/tfjs-converter/dist", - deps = [ - "//tfjs-core/src:tfjs-core_lib", - "//tfjs-core/src:tfjs-core_src_lib", - "@npm//@types/seedrandom", - "@npm//seedrandom", - ], -) - -ts_library( - name = "tfjs-converter_lib", - srcs = ["index.ts"], - module_name = "@tensorflow/tfjs-converter", - deps = [ - ":tfjs-converter_src_lib", - ], -) - -ts_library( - name = "tfjs-converter_test_lib", - testonly = True, - srcs = glob(TEST_SRCS), - deps = [ - ":tfjs-converter_lib", - ":tfjs-converter_src_lib", - "//tfjs-backend-cpu/src:tfjs-backend-cpu_lib", - "//tfjs-core/src:tfjs-core_lib", - "//tfjs-core/src:tfjs-core_src_lib", - "@npm//@types/jasmine", - "@npm//ajv", - "@npm//jasmine", - ], -) diff --git a/tfjs-master/tfjs-converter/src/data/api.proto b/tfjs-master/tfjs-converter/src/data/api.proto deleted file mode 100644 index edf7f69fd..000000000 --- a/tfjs-master/tfjs-converter/src/data/api.proto +++ /dev/null @@ -1,347 +0,0 @@ -// api.proto -// Definition of various TensorFlow protobuf messages for use with the TensorFlow API. -// -// Assembled from these relevant proto sources: -// https://github.com/google/protobuf/blob/master/src/google/protobuf/any.proto -// https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/framework/types.proto -// https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/framework/tensor.proto -// https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/framework/tensor_shape.proto -// https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/framework/attr_value.proto -// https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/framework/versions.proto -// https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/framework/graph.proto -// https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/framework/node_def.proto -// https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/framework/op_def.proto -// https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/protobuf/saver.proto -// https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/protobuf/meta_graph.proto -// https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/protobuf/saved_model.proto -// https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/framework/function.proto - -syntax = "proto3"; -package tensorflow; - -message Any { - string type_url = 1; - bytes value = 2; -} - -enum DataType { - // Not a legal value for DataType. Used to indicate a DataType field - // has not been set. - DT_INVALID = 0; - - // Data types that all computation devices are expected to be - // capable to support. - DT_FLOAT = 1; - DT_DOUBLE = 2; - DT_INT32 = 3; - DT_UINT8 = 4; - DT_INT16 = 5; - DT_INT8 = 6; - DT_STRING = 7; - DT_COMPLEX64 = 8; // Single-precision complex - DT_INT64 = 9; - DT_BOOL = 10; - DT_QINT8 = 11; // Quantized int8 - DT_QUINT8 = 12; // Quantized uint8 - DT_QINT32 = 13; // Quantized int32 - DT_BFLOAT16 = 14; // Float32 truncated to 16 bits. Only for cast ops. - - // Do not use! These are only for parameters. Every enum above - // should have a corresponding value below (verified by types_test). - DT_FLOAT_REF = 101; - DT_DOUBLE_REF = 102; - DT_INT32_REF = 103; - DT_UINT8_REF = 104; - DT_INT16_REF = 105; - DT_INT8_REF = 106; - DT_STRING_REF = 107; - DT_COMPLEX64_REF = 108; - DT_INT64_REF = 109; - DT_BOOL_REF = 110; - DT_QINT8_REF = 111; - DT_QUINT8_REF = 112; - DT_QINT32_REF = 113; - DT_BFLOAT16_REF = 114; -} - -message TensorShape { - // One dimension of the tensor. - message Dim { - // Size of the tensor in that dimension. - int64 size = 1; - - // Optional name of the tensor dimension. - string name = 2; - } - - // Dimensions of the tensor, such as {"input", 30}, {"output", 40} for a 30 x - // 40 2D tensor. The names are optional. - // - // The order of entries in "dim" matters: It indicates the layout of the - // values in the tensor in-memory representation. - // - // The first entry in "dim" is the outermost dimension used to layout the - // values, the last entry is the innermost dimension. This matches the - // in-memory layout of RowMajor Eigen tensors. - repeated Dim dim = 2; - - bool unknown_rank = 3; -} - -message Tensor { - DataType dtype = 1; - - // Shape of the tensor. TODO(touts): sort out the 0-rank issues. - TensorShape tensor_shape = 2; - - // Only one of the representations below is set, one of "tensor_contents" and - // the "xxx_val" attributes. We are not using oneof because as oneofs cannot - // contain repeated fields it would require another extra set of messages. - - // Version number. - // - // In version 0, if the "repeated xxx" representations contain only one - // element, that element is repeated to fill the shape. This makes it easy - // to represent a constant Tensor with a single value. - int32 version_number = 3; - - // Serialized content from TensorBase::Serialize() This representation can be - // used for all tensor types. - bytes tensor_content = 4; - - // Type specific representations that make it easy to create tensor protos in - // all languages. Only the representation corresponding to "dtype" can - // be set. The values hold the flattened representation of the tensor in - // row major order. - - // DT_FLOAT. - repeated float float_val = 5 [packed = true]; - - // DT_DOUBLE. - repeated double double_val = 6 [packed = true]; - - // DT_INT32, DT_INT16, DT_INT8, DT_UINT8. - repeated int32 int_val = 7 [packed = true]; - - // DT_STRING - repeated bytes string_val = 8; - - // DT_COMPLEX64. scomplex_val(2*i) and scomplex_val(2*i+1) are real - // and imaginary parts of i-th single precision complex. - repeated float scomplex_val = 9 [packed = true]; - - // DT_INT64 - repeated int64 int64_val = 10 [packed = true]; - - // DT_BOOL - repeated bool bool_val = 11 [packed = true]; - - // DT_UINT32 - repeated uint32 uint32_val = 16 [packed = true]; - - // DT_UINT64 - repeated uint64 uint64_val = 17 [packed = true]; -} - -message AttrValue { - message ListValue { - repeated bytes s = 2; - repeated int64 i = 3 [packed = true]; - repeated float f = 4 [packed = true]; - repeated bool b = 5 [packed = true]; - repeated DataType type = 6 [packed = true]; - repeated TensorShape shape = 7; - repeated Tensor tensor = 8; - repeated NameAttrList func = 9; - } - - oneof value { - ListValue list = 1; - bytes s = 2; - int64 i = 3; - float f = 4; - bool b = 5; - DataType type = 6; - TensorShape shape = 7; - Tensor tensor = 8; - string placeholder = 9; - NameAttrList func = 10; - } -} - -message NameAttrList { - string name = 1; - map attr = 2; -} - -message NodeDef { - string name = 1; - string op = 2; - repeated string input = 3; - string device = 4; - map attr = 5; -} - -message VersionDef { - int32 producer = 1; - int32 min_consumer = 2; - repeated int32 bad_consumers = 3; -} - -message GraphDef { - repeated NodeDef node = 1; - VersionDef versions = 4; - FunctionDefLibrary library = 2; -} - -message CollectionDef { - message NodeList { - repeated string value = 1; - } - message BytesList { - repeated bytes value = 1; - } - message Int64List { - repeated int64 value = 1 [packed = true]; - } - message FloatList { - repeated float value = 1 [packed = true]; - } - message AnyList { - repeated Any value = 1; - } - - oneof kind { - NodeList node_list = 1; - BytesList bytes_list = 2; - Int64List int64_list = 3; - FloatList float_list = 4; - AnyList any_list = 5; - } -} - -message SaverDef { - string filename_tensor_name = 1; - string save_tensor_name = 2; - string restore_op_name = 3; - int32 max_to_keep = 4; - bool sharded = 5; - float keep_checkpoint_every_n_hours = 6; - - enum CheckpointFormatVersion { - LEGACY = 0; - V1 = 1; - V2 = 2; - } - CheckpointFormatVersion version = 7; -} - -message TensorInfo { - message CooSparse { - string values_tensor_name = 1; - string indices_tensor_name = 2; - string dense_shape_tensor_name = 3; - } - - oneof encoding { - string name = 1; - CooSparse coo_sparse = 4; - } - DataType dtype = 2; - TensorShape tensor_shape = 3; -} - -message SignatureDef { - map inputs = 1; - map outputs = 2; - string method_name = 3; -} - -message AssetFileDef { - TensorInfo tensor_info = 1; - string filename = 2; -} - -message OpDef { - string name = 1; - - message ArgDef { - string name = 1; - string description = 2; - DataType type = 3; - string type_attr = 4; // if specified, attr must have type "type" - string number_attr = 5; // if specified, attr must have type "int" - string type_list_attr = 6; - bool is_ref = 16; - } - repeated ArgDef input_arg = 2; - repeated ArgDef output_arg = 3; - - message AttrDef { - string name = 1; - string type = 2; - AttrValue default_value = 3; - string description = 4; - bool has_minimum = 5; - int64 minimum = 6; - AttrValue allowed_values = 7; - } - repeated AttrDef attr = 4; - - message OpDeprecation { - int32 version = 1; - string explanation = 2; - } - OpDeprecation deprecation = 8; - - string summary = 5; - string description = 6; - bool is_commutative = 18; - bool is_aggregate = 16; // for things like add - bool is_stateful = 17; // for things like variables, queue - bool allows_uninitialized_input = 19; // for Assign, etc. -} - -message OpList { - repeated OpDef op = 1; -} - -message MetaGraphDef { - message MetaInfoDef { - string meta_graph_version = 1; - OpList stripped_op_list = 2; - Any any_info = 3; - repeated string tags = 4; - string tensorflow_version = 5; - string tensorflow_git_version = 6; - } - MetaInfoDef meta_info_def = 1; - GraphDef graph_def = 2; - SaverDef saver_def = 3; - map collection_def = 4; - map signature_def = 5; - repeated AssetFileDef asset_file_def = 6; -} - -message SavedModel { - int64 saved_model_schema_version = 1; - repeated MetaGraphDef meta_graphs = 2; -} - -message FunctionDefLibrary { - repeated FunctionDef function = 1; - repeated GradientDef gradient = 2; -} - -message FunctionDef { - OpDef signature = 1; - map attr = 5; - reserved 2; - repeated NodeDef node_def = 3; - map ret = 4; -} - -message GradientDef { - string function_name = 1; // The function name. - string gradient_func = 2; // The gradient function's name. -} diff --git a/tfjs-master/tfjs-converter/src/data/compiled_api.ts b/tfjs-master/tfjs-converter/src/data/compiled_api.ts deleted file mode 100644 index d5d0b4f17..000000000 --- a/tfjs-master/tfjs-converter/src/data/compiled_api.ts +++ /dev/null @@ -1,581 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * ============================================================================= - */ - -/* tslint:disable */ - -/** Properties of an Any. */ -export declare interface IAny { - /** Any typeUrl */ - typeUrl?: (string|null); - - /** Any value */ - value?: (Uint8Array|null); -} - -/** DataType enum. */ -export enum DataType { - // Not a legal value for DataType. Used to indicate a DataType field - // has not been set. - DT_INVALID = 0, - - // Data types that all computation devices are expected to be - // capable to support. - DT_FLOAT = 1, - DT_DOUBLE = 2, - DT_INT32 = 3, - DT_UINT8 = 4, - DT_INT16 = 5, - DT_INT8 = 6, - DT_STRING = 7, - DT_COMPLEX64 = 8, // Single-precision complex - DT_INT64 = 9, - DT_BOOL = 10, - DT_QINT8 = 11, // Quantized int8 - DT_QUINT8 = 12, // Quantized uint8 - DT_QINT32 = 13, // Quantized int32 - DT_BFLOAT16 = 14, // Float32 truncated to 16 bits. Only for cast ops. - DT_QINT16 = 15, // Quantized int16 - DT_QUINT16 = 16, // Quantized uint16 - DT_UINT16 = 17, - DT_COMPLEX128 = 18, // Double-precision complex - DT_HALF = 19, - DT_RESOURCE = 20, - DT_VARIANT = 21, // Arbitrary C++ data types - DT_UINT32 = 22, - DT_UINT64 = 23, - - // Do not use! These are only for parameters. Every enum above - // should have a corresponding value below (verified by types_test). - DT_FLOAT_REF = 101, - DT_DOUBLE_REF = 102, - DT_INT32_REF = 103, - DT_UINT8_REF = 104, - DT_INT16_REF = 105, - DT_INT8_REF = 106, - DT_STRING_REF = 107, - DT_COMPLEX64_REF = 108, - DT_INT64_REF = 109, - DT_BOOL_REF = 110, - DT_QINT8_REF = 111, - DT_QUINT8_REF = 112, - DT_QINT32_REF = 113, - DT_BFLOAT16_REF = 114, - DT_QINT16_REF = 115, - DT_QUINT16_REF = 116, - DT_UINT16_REF = 117, - DT_COMPLEX128_REF = 118, - DT_HALF_REF = 119, - DT_RESOURCE_REF = 120, - DT_VARIANT_REF = 121, - DT_UINT32_REF = 122, - DT_UINT64_REF = 123, -} - -/** Properties of a TensorShape. */ -export declare interface ITensorShape { - /** TensorShape dim */ - dim?: (TensorShape.IDim[]|null); - - /** TensorShape unknownRank */ - unknownRank?: (boolean|null); -} - -export namespace TensorShape { - /** Properties of a Dim. */ - export declare interface IDim { - /** Dim size */ - size?: (number|string|null); - - /** Dim name */ - name?: (string|null); - } -} - -/** Properties of a Tensor. */ -export declare interface ITensor { - /** Tensor dtype */ - dtype?: (DataType|null); - - /** Tensor tensorShape */ - tensorShape?: (ITensorShape|null); - - /** Tensor versionNumber */ - versionNumber?: (number|null); - - /** Tensor tensorContent */ - tensorContent?: (Uint8Array|null); - - /** Tensor floatVal */ - floatVal?: (number[]|null); - - /** Tensor doubleVal */ - doubleVal?: (number[]|null); - - /** Tensor intVal */ - intVal?: (number[]|null); - - /** Tensor stringVal */ - stringVal?: (Uint8Array[]|null); - - /** Tensor scomplexVal */ - scomplexVal?: (number[]|null); - - /** Tensor int64Val */ - int64Val?: ((number | string)[]|null); - - /** Tensor boolVal */ - boolVal?: (boolean[]|null); - - /** Tensor uint32Val */ - uint32Val?: (number[]|null); - - /** Tensor uint64Val */ - uint64Val?: ((number | string)[]|null); -} - -/** Properties of an AttrValue. */ -export declare interface IAttrValue { - /** AttrValue list */ - list?: (AttrValue.IListValue|null); - - /** AttrValue s */ - s?: (string|null); - - /** AttrValue i */ - i?: (number|string|null); - - /** AttrValue f */ - f?: (number|null); - - /** AttrValue b */ - b?: (boolean|null); - - /** AttrValue type */ - type?: (DataType|null); - - /** AttrValue shape */ - shape?: (ITensorShape|null); - - /** AttrValue tensor */ - tensor?: (ITensor|null); - - /** AttrValue placeholder */ - placeholder?: (string|null); - - /** AttrValue func */ - func?: (INameAttrList|null); -} - -export namespace AttrValue { - /** Properties of a ListValue. */ - export declare interface IListValue { - /** ListValue s */ - s?: (string[]|null); - - /** ListValue i */ - i?: ((number | string)[]|null); - - /** ListValue f */ - f?: (number[]|null); - - /** ListValue b */ - b?: (boolean[]|null); - - /** ListValue type */ - type?: (DataType[]|null); - - /** ListValue shape */ - shape?: (ITensorShape[]|null); - - /** ListValue tensor */ - tensor?: (ITensor[]|null); - - /** ListValue func */ - func?: (INameAttrList[]|null); - } -} - -/** Properties of a NameAttrList. */ -export declare interface INameAttrList { - /** NameAttrList name */ - name?: (string|null); - - /** NameAttrList attr */ - attr?: ({[k: string]: IAttrValue}|null); -} - -/** Properties of a NodeDef. */ -export declare interface INodeDef { - /** NodeDef name */ - name?: (string|null); - - /** NodeDef op */ - op?: (string|null); - - /** NodeDef input */ - input?: (string[]|null); - - /** NodeDef device */ - device?: (string|null); - - /** NodeDef attr */ - attr?: ({[k: string]: IAttrValue}|null); -} - -/** Properties of a VersionDef. */ -export declare interface IVersionDef { - /** VersionDef producer */ - producer?: (number|null); - - /** VersionDef minConsumer */ - minConsumer?: (number|null); - - /** VersionDef badConsumers */ - badConsumers?: (number[]|null); -} - -/** Properties of a GraphDef. */ -export declare interface IGraphDef { - /** GraphDef node */ - node?: (INodeDef[]|null); - - /** GraphDef versions */ - versions?: (IVersionDef|null); - - /** GraphDef library */ - library?: (IFunctionDefLibrary|null); -} - -/** Properties of a CollectionDef. */ -export declare interface ICollectionDef { - /** CollectionDef nodeList */ - nodeList?: (CollectionDef.INodeList|null); - - /** CollectionDef bytesList */ - bytesList?: (CollectionDef.IBytesList|null); - - /** CollectionDef int64List */ - int64List?: (CollectionDef.IInt64List|null); - - /** CollectionDef floatList */ - floatList?: (CollectionDef.IFloatList|null); - - /** CollectionDef anyList */ - anyList?: (CollectionDef.IAnyList|null); -} - -export namespace CollectionDef { - /** Properties of a NodeList. */ - export declare interface INodeList { - /** NodeList value */ - value?: (string[]|null); - } - - /** Properties of a BytesList. */ - export declare interface IBytesList { - /** BytesList value */ - value?: (Uint8Array[]|null); - } - - /** Properties of an Int64List. */ - export declare interface IInt64List { - /** Int64List value */ - value?: ((number | string)[]|null); - } - - /** Properties of a FloatList. */ - export declare interface IFloatList { - /** FloatList value */ - value?: (number[]|null); - } - - /** Properties of an AnyList. */ - export declare interface IAnyList { - /** AnyList value */ - value?: (IAny[]|null); - } -} - -/** Properties of a SaverDef. */ -export declare interface ISaverDef { - /** SaverDef filenameTensorName */ - filenameTensorName?: (string|null); - - /** SaverDef saveTensorName */ - saveTensorName?: (string|null); - - /** SaverDef restoreOpName */ - restoreOpName?: (string|null); - - /** SaverDef maxToKeep */ - maxToKeep?: (number|null); - - /** SaverDef sharded */ - sharded?: (boolean|null); - - /** SaverDef keepCheckpointEveryNHours */ - keepCheckpointEveryNHours?: (number|null); - - /** SaverDef version */ - version?: (SaverDef.CheckpointFormatVersion|null); -} - -export namespace SaverDef { - /** CheckpointFormatVersion enum. */ - export enum CheckpointFormatVersion {'LEGACY' = 0, 'V1' = 1, 'V2' = 2} -} - -/** Properties of a TensorInfo. */ -export declare interface ITensorInfo { - /** TensorInfo name */ - name?: (string|null); - - /** TensorInfo cooSparse */ - cooSparse?: (TensorInfo.ICooSparse|null); - - /** TensorInfo dtype */ - dtype?: (DataType|string|null); - - /** TensorInfo tensorShape */ - tensorShape?: (ITensorShape|null); - - /** Resource id tensor was originally assigned to. */ - resourceId?: (number|null); -} - -export namespace TensorInfo { - /** Properties of a CooSparse. */ - export declare interface ICooSparse { - /** CooSparse valuesTensorName */ - valuesTensorName?: (string|null); - - /** CooSparse indicesTensorName */ - indicesTensorName?: (string|null); - - /** CooSparse denseShapeTensorName */ - denseShapeTensorName?: (string|null); - } -} - -/** Properties of a SignatureDef. */ -export declare interface ISignatureDef { - /** SignatureDef inputs */ - inputs?: ({[k: string]: ITensorInfo}|null); - - /** SignatureDef outputs */ - outputs?: ({[k: string]: ITensorInfo}|null); - - /** SignatureDef methodName */ - methodName?: (string|null); -} - -/** Properties of an AssetFileDef. */ -export declare interface IAssetFileDef { - /** AssetFileDef tensorInfo */ - tensorInfo?: (ITensorInfo|null); - - /** AssetFileDef filename */ - filename?: (string|null); -} - -/** Properties of an OpDef. */ -export declare interface IOpDef { - /** OpDef name */ - name?: (string|null); - - /** OpDef inputArg */ - inputArg?: (OpDef.IArgDef[]|null); - - /** OpDef outputArg */ - outputArg?: (OpDef.IArgDef[]|null); - - /** OpDef attr */ - attr?: (OpDef.IAttrDef[]|null); - - /** OpDef deprecation */ - deprecation?: (OpDef.IOpDeprecation|null); - - /** OpDef summary */ - summary?: (string|null); - - /** OpDef description */ - description?: (string|null); - - /** OpDef isCommutative */ - isCommutative?: (boolean|null); - - /** OpDef isAggregate */ - isAggregate?: (boolean|null); - - /** OpDef isStateful */ - isStateful?: (boolean|null); - - /** OpDef allowsUninitializedInput */ - allowsUninitializedInput?: (boolean|null); -} - -export namespace OpDef { - /** Properties of an ArgDef. */ - export declare interface IArgDef { - /** ArgDef name */ - name?: (string|null); - - /** ArgDef description */ - description?: (string|null); - - /** ArgDef type */ - type?: (DataType|null); - - /** ArgDef typeAttr */ - typeAttr?: (string|null); - - /** ArgDef numberAttr */ - numberAttr?: (string|null); - - /** ArgDef typeListAttr */ - typeListAttr?: (string|null); - - /** ArgDef isRef */ - isRef?: (boolean|null); - } - - /** Properties of an AttrDef. */ - export declare interface IAttrDef { - /** AttrDef name */ - name?: (string|null); - - /** AttrDef type */ - type?: (string|null); - - /** AttrDef defaultValue */ - defaultValue?: (IAttrValue|null); - - /** AttrDef description */ - description?: (string|null); - - /** AttrDef hasMinimum */ - hasMinimum?: (boolean|null); - - /** AttrDef minimum */ - minimum?: (number|string|null); - - /** AttrDef allowedValues */ - allowedValues?: (IAttrValue|null); - } - - /** Properties of an OpDeprecation. */ - export declare interface IOpDeprecation { - /** OpDeprecation version */ - version?: (number|null); - - /** OpDeprecation explanation */ - explanation?: (string|null); - } -} - -/** Properties of an OpList. */ -export declare interface IOpList { - /** OpList op */ - op?: (IOpDef[]|null); -} - -/** Properties of a MetaGraphDef. */ -export declare interface IMetaGraphDef { - /** MetaGraphDef metaInfoDef */ - metaInfoDef?: (MetaGraphDef.IMetaInfoDef|null); - - /** MetaGraphDef graphDef */ - graphDef?: (IGraphDef|null); - - /** MetaGraphDef saverDef */ - saverDef?: (ISaverDef|null); - - /** MetaGraphDef collectionDef */ - collectionDef?: ({[k: string]: ICollectionDef}|null); - - /** MetaGraphDef signatureDef */ - signatureDef?: ({[k: string]: ISignatureDef}|null); - - /** MetaGraphDef assetFileDef */ - assetFileDef?: (IAssetFileDef[]|null); -} - -export namespace MetaGraphDef { - /** Properties of a MetaInfoDef. */ - export declare interface IMetaInfoDef { - /** MetaInfoDef metaGraphVersion */ - metaGraphVersion?: (string|null); - - /** MetaInfoDef strippedOpList */ - strippedOpList?: (IOpList|null); - - /** MetaInfoDef anyInfo */ - anyInfo?: (IAny|null); - - /** MetaInfoDef tags */ - tags?: (string[]|null); - - /** MetaInfoDef tensorflowVersion */ - tensorflowVersion?: (string|null); - - /** MetaInfoDef tensorflowGitVersion */ - tensorflowGitVersion?: (string|null); - } -} - -/** Properties of a SavedModel. */ -export declare interface ISavedModel { - /** SavedModel savedModelSchemaVersion */ - savedModelSchemaVersion?: (number|string|null); - - /** SavedModel metaGraphs */ - metaGraphs?: (IMetaGraphDef[]|null); -} - -/** Properties of a FunctionDefLibrary. */ -export declare interface IFunctionDefLibrary { - /** FunctionDefLibrary function */ - 'function'?: (IFunctionDef[]|null); - - /** FunctionDefLibrary gradient */ - gradient?: (IGradientDef[]|null); -} - -/** Properties of a FunctionDef. */ -export declare interface IFunctionDef { - /** FunctionDef signature */ - signature?: (IOpDef|null); - - /** FunctionDef attr */ - attr?: ({[k: string]: IAttrValue}|null); - - /** FunctionDef nodeDef */ - nodeDef?: (INodeDef[]|null); - - /** FunctionDef ret */ - ret?: ({[k: string]: string}|null); -} - -/** Properties of a GradientDef. */ -export declare interface IGradientDef { - /** GradientDef functionName */ - functionName?: (string|null); - - /** GradientDef gradientFunc */ - gradientFunc?: (string|null); -} diff --git a/tfjs-master/tfjs-converter/src/data/types.ts b/tfjs-master/tfjs-converter/src/data/types.ts deleted file mode 100644 index 122cf16d4..000000000 --- a/tfjs-master/tfjs-converter/src/data/types.ts +++ /dev/null @@ -1,47 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {DataType, Tensor} from '@tensorflow/tfjs-core'; - -import {HashTable} from '../executor/hash_table'; -import {TensorArray} from '../executor/tensor_array'; -import {TensorList} from '../executor/tensor_list'; - -export type NamedTensorMap = { - [key: string]: Tensor -}; - -export type NamedTensorsMap = { - [key: string]: Tensor[] -}; - -export type TensorArrayMap = { - [key: number]: TensorArray -}; - -export type TensorListMap = { - [key: number]: TensorList -}; - -export type HashTableMap = { - [key: number]: HashTable -}; - -export interface TensorInfo { - name: string; - shape?: number[]; - dtype: DataType; -} diff --git a/tfjs-master/tfjs-converter/src/executor/execution_context.ts b/tfjs-master/tfjs-converter/src/executor/execution_context.ts deleted file mode 100644 index 5ba437ecc..000000000 --- a/tfjs-master/tfjs-converter/src/executor/execution_context.ts +++ /dev/null @@ -1,188 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {Tensor} from '@tensorflow/tfjs-core'; - -import {NamedTensorsMap, TensorArrayMap, TensorListMap} from '../data/types'; - -import {TensorArray} from './tensor_array'; -import {TensorList} from './tensor_list'; -import {FunctionExecutor} from './types'; - -export interface ExecutionContextInfo { - id: number; // the unique id of the context info - frameName: string; // The frame name of the loop, this comes from - // the TensorFlow NodeDef. - iterationId: number; // The iteration id of the loop -} - -/** - * ExecutionContext captures the runtime environment of the node. It keeps - * track of the current frame and iteration for the control flow ops. - * - * For example, typical Dynamic RNN model may contain loops, for which - * TensorFlow will generate graphs with Enter/Exit nodes to control the - * current execution frame, and NextIteration Nodes for iteration id increment. - * For model with branch logic, TensorFLow will generate Switch/Merge ops. - */ -export class ExecutionContext { - private rootContext = {id: 0, frameName: '', iterationId: 0}; - private contexts: ExecutionContextInfo[] = [this.rootContext]; - private lastId = 0; - private _currentContextIds: string[]; - - constructor( - readonly weightMap: NamedTensorsMap = {}, - readonly tensorArrayMap: TensorArrayMap = {}, - readonly tensorListMap: TensorListMap = {}, - readonly functionMap: {[key: string]: FunctionExecutor} = {}, - readonly parseNodeNameCache?: Map) { - this.generateCurrentContextIds(); - } - - private newFrame(id: number, frameName: string) { - return {id, frameName, iterationId: 0}; - } - - /** - * Set the current context - * @param contexts: ExecutionContextInfo[] the current path of execution - * frames - */ - set currentContext(contexts: ExecutionContextInfo[]) { - if (this.contexts !== contexts) { - this.contexts = contexts; - this.generateCurrentContextIds(); - } - } - - get currentContext(): ExecutionContextInfo[] { - return this.contexts; - } - - /** - * Returns the current context in string format. - */ - get currentContextId(): string { - return this._currentContextIds[0]; - } - - /** - * Returns the current context and all parent contexts in string format. - * This allow access to the nodes in the current and parent frames. - */ - get currentContextIds(): string[] { - return this._currentContextIds; - } - - private generateCurrentContextIds() { - const names = []; - for (let i = 0; i < this.contexts.length - 1; i++) { - const contexts = this.contexts.slice(0, this.contexts.length - i); - names.push(this.contextIdforContexts(contexts)); - } - names.push(''); - this._currentContextIds = names; - } - - private contextIdforContexts(contexts: ExecutionContextInfo[]) { - return contexts ? - contexts - .map( - context => (context.id === 0 && context.iterationId === 0) ? - '' : - `${context.frameName}-${context.iterationId}`) - .join('/') : - ''; - } - - /** - * Enter a new frame, a new context is pushed on the current context list. - * @param frameId new frame id - */ - enterFrame(frameId: string) { - if (this.contexts) { - this.lastId++; - this.contexts = this.contexts.slice(); - this.contexts.push(this.newFrame(this.lastId, frameId)); - this._currentContextIds.unshift(this.contextIdforContexts(this.contexts)); - } - } - - /** - * Exit the current frame, the last context is removed from the current - * context list. - */ - exitFrame() { - if (this.contexts && this.contexts.length > 1) { - this.contexts = this.contexts.slice(); - this.contexts.splice(-1); - this.currentContextIds.shift(); - } else { - throw new Error('Cannot exit frame, the context is empty'); - } - } - - /** - * Enter the next iteration of a loop, the iteration id of last context is - * increased. - */ - nextIteration() { - if (this.contexts && this.contexts.length > 0) { - this.contexts = this.contexts.slice(); - this.lastId++; - const context = - Object.assign({}, this.contexts[this.contexts.length - 1]); - context.iterationId += 1; - context.id = this.lastId; - this.contexts.splice(-1, 1, context); - this._currentContextIds.splice( - 0, 1, this.contextIdforContexts(this.contexts)); - } else { - throw new Error('Cannot increase frame iteration, the context is empty'); - } - } - - getWeight(name: string): Tensor[] { - return this.weightMap[name]; - } - - addTensorArray(tensorArray: TensorArray) { - this.tensorArrayMap[tensorArray.id] = tensorArray; - } - - getTensorArray(id: number): TensorArray { - return this.tensorArrayMap[id]; - } - - addTensorList(tensorList: TensorList) { - this.tensorListMap[tensorList.id] = tensorList; - } - - getTensorList(id: number): TensorList { - return this.tensorListMap[id]; - } - - dispose(keepIds: Set) { - for (const key in this.tensorArrayMap) { - this.tensorArrayMap[key].clearAndClose(keepIds); - } - - for (const key in this.tensorListMap) { - this.tensorListMap[key].clearAndClose(keepIds); - } - } -} diff --git a/tfjs-master/tfjs-converter/src/executor/execution_context_test.ts b/tfjs-master/tfjs-converter/src/executor/execution_context_test.ts deleted file mode 100644 index 40821fd09..000000000 --- a/tfjs-master/tfjs-converter/src/executor/execution_context_test.ts +++ /dev/null @@ -1,98 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ExecutionContext} from './execution_context'; -import {TensorArray} from './tensor_array'; - -let context: ExecutionContext; -let tensorArray: TensorArray; -describe('ExecutionContext', () => { - beforeEach(() => { - context = new ExecutionContext({}, {}, {}); - }); - - it('should initialize', () => { - expect(context.currentContext).toEqual([ - {id: 0, frameName: '', iterationId: 0} - ]); - expect(context.currentContextId).toEqual(''); - }); - - describe('tensor array', () => { - beforeEach(() => { - tensorArray = new TensorArray('', 'float32', 10, [1], true, true, true); - }); - - it('should be able to add tensor array', () => { - context.addTensorArray(tensorArray); - expect(context.getTensorArray(tensorArray.id)).toBe(tensorArray); - }); - - it('should be able to read tensor array', () => { - expect(context.getTensorArray(tensorArray.id)).toBeUndefined(); - }); - }); - - describe('enterFrame', () => { - it('should add new Frame', () => { - context.enterFrame('1'); - expect(context.currentContextId).toEqual('/1-0'); - expect(context.currentContext).toEqual([ - {id: 0, frameName: '', iterationId: 0}, - {id: 1, frameName: '1', iterationId: 0} - ]); - }); - }); - - describe('exitFrame', () => { - it('should remove Frame', () => { - context.enterFrame('1'); - context.exitFrame(); - - expect(context.currentContextId).toEqual(''); - expect(context.currentContext).toEqual([ - {id: 0, frameName: '', iterationId: 0} - ]); - }); - - it('should remember previous Frame', () => { - context.enterFrame('1'); - context.nextIteration(); - context.enterFrame('2'); - context.exitFrame(); - - expect(context.currentContextId).toEqual('/1-1'); - expect(context.currentContext).toEqual([ - {id: 0, frameName: '', iterationId: 0}, - {id: 2, frameName: '1', iterationId: 1} - ]); - }); - }); - - describe('nextIteration', () => { - it('should increate iteration', () => { - context.enterFrame('1'); - context.nextIteration(); - - expect(context.currentContextId).toEqual('/1-1'); - expect(context.currentContext).toEqual([ - {id: 0, frameName: '', iterationId: 0}, - {id: 2, frameName: '1', iterationId: 1} - ]); - }); - }); -}); diff --git a/tfjs-master/tfjs-converter/src/executor/graph_executor.ts b/tfjs-master/tfjs-converter/src/executor/graph_executor.ts deleted file mode 100644 index 52f7d481e..000000000 --- a/tfjs-master/tfjs-converter/src/executor/graph_executor.ts +++ /dev/null @@ -1,773 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {DataType, env, keep, NamedTensorMap, Tensor, tidy, util} from '@tensorflow/tfjs-core'; - -import {ISignatureDef} from '../data/compiled_api'; -import {NamedTensorsMap, TensorArrayMap, TensorInfo, TensorListMap} from '../data/types'; -import {getNodeNameAndIndex, getParamValue, getTensor, getTensorsForCurrentContext, parseNodeName} from '../operations/executors/utils'; -import {executeOp} from '../operations/operation_executor'; -import {Graph, Node} from '../operations/types'; - -import {ExecutionContext, ExecutionContextInfo} from './execution_context'; -import {getExecutionSubgraph, getNodeLiveUntilMap, getNodesInTopologicalOrder, isControlFlow} from './model_analysis'; -import {ResourceManager} from './resource_manager'; -import {FunctionExecutor} from './types'; - -interface NodeWithContexts { - contexts: ExecutionContextInfo[]; - node: Node; -} - -export class GraphExecutor implements FunctionExecutor { - private compiledMap = new Map>(); - private parseNodeNameCache = new Map(); - private _weightMap: NamedTensorsMap = {}; - private _weightIds: number[]; - private _signature: ISignatureDef; - private _inputs: Node[]; - private _outputs: Node[]; - private _initNodes: Node[]; // Internal init nodes to start initialization. - private SEPARATOR = ','; - private _functions: {[key: string]: Graph} = {}; - private _functionExecutorMap: {[key: string]: FunctionExecutor} = {}; - private _resourceManager: ResourceManager; - private clonedTensorsMap: NamedTensorsMap; - private keepIntermediateTensors = false; - - get weightIds(): number[] { - return this.parent ? this.parent.weightIds : this._weightIds; - } - - get functionExecutorMap(): {[key: string]: FunctionExecutor} { - return this.parent ? this.parent.functionExecutorMap : - this._functionExecutorMap; - } - - get weightMap(): NamedTensorsMap { - return this.parent ? this.parent.weightMap : this._weightMap; - } - - set weightMap(weightMap: NamedTensorsMap) { - const weightIds = Object.keys(weightMap).map( - key => weightMap[key].map(tensor => tensor.id)); - this._weightIds = [].concat(...weightIds); - this._weightMap = weightMap; - } - - /** - * Set `ResourceManager` shared by executors of a model. - * @param resourceManager: `ResourceManager` of the `GraphModel`. - */ - set resourceManager(resourceManager: ResourceManager) { - this._resourceManager = resourceManager; - } - - get inputs(): TensorInfo[] { - return this._inputs.map(node => { - return { - name: node.name, - shape: node.attrParams['shape'] ? - node.attrParams['shape'].value as number[] : - undefined, - dtype: node.attrParams['dtype'] ? - node.attrParams['dtype'].value as DataType : - undefined - }; - }); - } - - get outputs(): TensorInfo[] { - return this._outputs.map(node => { - return { - name: node.name, - shape: node.attrParams['shape'] ? - node.attrParams['shape'].value as number[] : - undefined, - dtype: node.attrParams['dtype'] ? - node.attrParams['dtype'].value as DataType : - undefined - }; - }); - } - - get inputNodes(): string[] { - return this._inputs.map(node => node.signatureKey || node.name); - } - - get outputNodes(): string[] { - return this._outputs.map((node) => { - const name = node.signatureKey || node.name; - return node.defaultOutput ? (`${name}:${node.defaultOutput}`) : name; - }); - } - - get functions(): {[key: string]: ISignatureDef} { - return Object.keys(this._functions).reduce((map, key) => { - map[key] = this._functions[key].signature; - return map; - }, {} as {[key: string]: ISignatureDef}); - } - - /** - * - * @param graph Graph the model or function graph to be executed. - * @param parent When building function exector you need to set the parent - * executor. Since the weights and function executor maps are set at parant - * level, that function executor can access the function maps and weight maps - * through the parent. - */ - constructor(private graph: Graph, private parent?: GraphExecutor) { - this._outputs = graph.outputs; - this._inputs = graph.inputs; - this._initNodes = graph.initNodes; - this._signature = graph.signature; - this._functions = graph.functions; - // create sub-graph executors - if (graph.functions != null) { - Object.keys(graph.functions).forEach(name => { - this._functionExecutorMap[name] = - new GraphExecutor(graph.functions[name], this); - }); - } - } - - private getCompilationKey(inputs: Node[], outputs: Node[]): string { - const sortedInputs = inputs.map(node => node.name).sort(); - const sortedOutputs = outputs.map(node => node.name).sort(); - return sortedInputs.join(this.SEPARATOR) + '--' + - sortedOutputs.join(this.SEPARATOR); - } - - /** - * Compiles the inference graph and returns the minimal set of nodes that are - * required for execution, in the correct execution order. - * @returns {Object} compilation The compile result. - * @returns {Node[]} compilation.orderedNodes Nodes in the correct execution - * order. - * @returns {Map} compilation.nodeLiveUntilMap A map from node - * to disposable nodes after its execution. That is, for a node `x`, - * `nodeLiveUntilMap[x]` indicates all nodes whose intermediate - * tensors should be disposed after `x` is executed. - */ - private compile(inputs: NamedTensorMap, outputs: Node[]): - {orderedNodes: Node[], nodeLiveUntilMap: Map} { - const executionInfo = - getExecutionSubgraph(inputs, outputs, this.weightMap, this._initNodes); - const {missingInputs, dynamicNode, syncInputs} = executionInfo; - if (dynamicNode != null) { - throw new Error( - `This execution contains the node '${dynamicNode.name}', which has ` + - `the dynamic op '${dynamicNode.op}'. Please use ` + - `model.executeAsync() instead. Alternatively, to avoid the ` + - `dynamic ops, specify the inputs [${syncInputs}]`); - } - - if (missingInputs.length > 0) { - const outNames = outputs.map(n => n.name); - const inNames = Object.keys(inputs); - throw new Error( - `Cannot compute the outputs [${outNames}] from the provided inputs ` + - `[${inNames}]. Missing the following inputs: [${missingInputs}]`); - } - - const orderedNodes = getNodesInTopologicalOrder(this.graph, executionInfo); - const nodeLiveUntilMap = getNodeLiveUntilMap(orderedNodes); - return {orderedNodes, nodeLiveUntilMap}; - } - - private cloneAndKeepTensor(tensor: Tensor) { - if (tensor == null) { - return null; - } - const clone = tensor.clone(); - // Keep the clone because`model.execute()` may be called within - // a `tidy()`, but the user may inspect these tensors after the - // tidy. - keep(clone); - return clone; - } - - private cloneTensorList(tensors: Tensor[]) { - if (!tensors) { - return null; - } - const clonedTensor = tensors.map(tensor => { - return this.cloneAndKeepTensor(tensor); - }); - return clonedTensor; - } - - private cloneTensorMap(tensorsMap: NamedTensorsMap): NamedTensorsMap { - return Object.fromEntries( - Object.entries(tensorsMap).map(([name, tensorsList]) => { - return [name, this.cloneTensorList(tensorsList)]; - })); - } - - /** - * Executes the inference for given input tensors. - * @param inputs Tensor map for the model inputs, keyed by the input node - * names. - * @param outputs Optional. output node name from the Tensorflow model, if - * no outputs are specified, the default outputs of the model would be used. - * You can inspect intermediate nodes of the model by adding them to the - * outputs array. - */ - execute(inputs: NamedTensorMap, outputs?: string[]): Tensor[] { - // Dispose any tensors from a prior run to avoid leaking them. - this.disposeIntermediateTensors(); - inputs = this.mapInputs(inputs); - const names = Object.keys(inputs).sort(); - this.checkInputs(inputs); - this.checkInputShapeAndType(inputs); - outputs = this.mapOutputs(outputs); - this.checkOutputs(outputs); - const inputNodes = - names.map(name => this.graph.nodes[parseNodeName(name)[0]]); - const outputNodeNames = outputs.map(name => parseNodeName(name)[0]); - const outputNodeNameSet = new Set(outputNodeNames); - let outputNodes = outputNodeNames.map(name => this.graph.nodes[name]); - // If no outputs are specified, then use the default outputs of the model. - if (outputNodes.length === 0) { - outputNodes = this._outputs; - } - - const compilationKey = this.getCompilationKey(inputNodes, outputNodes); - - // Do nothing if the compiled graph cache contains the input. - let compilation = this.compiledMap.get(compilationKey); - if (compilation == null) { - compilation = this.compile(inputs, outputNodes); - this.compiledMap.set(compilationKey, compilation); - } - - // Keep tensors if KEEP_INTERMEDIATE_TENSORS is on. - try { - this.keepIntermediateTensors = env().getBool('KEEP_INTERMEDIATE_TENSORS'); - } catch (e) { - this.keepIntermediateTensors = false; - console.warn(e.message); - } - const tensorArrayMap: TensorArrayMap = {}; - const tensorListMap: TensorListMap = {}; - - return tidy(() => { - const context = new ExecutionContext( - this.weightMap, tensorArrayMap, tensorListMap, - this.functionExecutorMap, this.parseNodeNameCache); - const tensorsMap: NamedTensorsMap = {...this.weightMap}; - if (this.keepIntermediateTensors) { - this.clonedTensorsMap = this.cloneTensorMap(this.weightMap); - } - - Object.keys(inputs).forEach(name => { - const [nodeName, index] = parseNodeName(name, context); - const tensors: Tensor[] = []; - tensors[index] = inputs[name]; - tensorsMap[nodeName] = tensors; - if (this.keepIntermediateTensors) { - this.clonedTensorsMap[nodeName] = this.cloneTensorList(tensors); - } - }); - - const tensorsToKeep = this.getFrozenTensorIds(tensorsMap); - const {orderedNodes, nodeLiveUntilMap} = compilation; - for (const node of orderedNodes) { - if (tensorsMap[node.name]) { - continue; - } - const tensors = - executeOp(node, tensorsMap, context, this._resourceManager) as - Tensor[]; - if (util.isPromise(tensors)) { - throw new Error( - `The execution of the op '${node.op}' returned a promise. ` + - `Please use model.executeAsync() instead.`); - } - tensorsMap[node.name] = tensors; - if (this.keepIntermediateTensors) { - this.clonedTensorsMap[node.name] = this.cloneTensorList(tensors); - } - this.checkTensorForDisposalWithNodeLiveUntilInfo( - node, tensorsMap, context, tensorsToKeep, outputNodeNameSet, - nodeLiveUntilMap.get(node.name)); - } - - // dispose the context for the root executor - if (this.parent == null) { - context.dispose(tensorsToKeep); - } - - return outputs.map(name => getTensor(name, tensorsMap, context)); - }); - } - - private getFrozenTensorIds(tensorMap: NamedTensorsMap): Set { - const ids = [].concat.apply( - [], - Object.keys(tensorMap) - .map(key => tensorMap[key]) - .map(tensors => tensors.map(tensor => tensor.id))); - return new Set(ids); - } - - private checkTensorForDisposal( - nodeName: string, node: Node, tensorMap: NamedTensorsMap, - context: ExecutionContext, tensorsToKeep: Set, - outputNodeNameSet: Set, - intermediateTensorConsumerCount: {[key: string]: number}) { - // Skip output nodes and any control flow nodes, since its dependency is - // tricky to track correctly. - if (isControlFlow(node) || outputNodeNameSet.has(nodeName)) { - return; - } - - for (const tensor of tensorMap[nodeName]) { - if (tensor == null) { - continue; - } - intermediateTensorConsumerCount[tensor.id] = - (intermediateTensorConsumerCount[tensor.id] || 0) + - node.children.length; - } - - for (const input of node.inputs) { - // Skip any control flow nodes, since its dependency is tricky to track - // correctly. - if (isControlFlow(input)) { - continue; - } - - const tensors = - getTensorsForCurrentContext(input.name, tensorMap, context); - if (tensors == null) { - continue; - } - - for (const tensor of tensors) { - if (!tensor || tensor.kept || tensorsToKeep.has(tensor.id)) { - continue; - } - - // Only intermediate nodes' tensors have counts set, not marked as - // kept, and not in `tensorsToKeep`. - // Input and weight nodes' tensors should exist in `tensorsToKeep`. - // Output and control flow nodes' tensors should never have count set. - const count = intermediateTensorConsumerCount[tensor.id]; - if (count === 1) { - tensor.dispose(); - delete intermediateTensorConsumerCount[tensor.id]; - } else if (count != null) { - intermediateTensorConsumerCount[tensor.id]--; - } - } - } - } - - private checkTensorForDisposalWithNodeLiveUntilInfo( - node: Node, tensorMap: NamedTensorsMap, context: ExecutionContext, - tensorsToKeep: Set, outputNodeNameSet: Set, - liveUntilNodes?: Node[]) { - function isNonDisposableNode(node: Node) { - // Skip output nodes and any control flow nodes, since its dependency is - // tricky to track correctly. - return isControlFlow(node) || outputNodeNameSet.has(node.name); - } - - if (isControlFlow(node) || liveUntilNodes == null) { - return; - } - - for (const nodeToDispose of liveUntilNodes) { - if (isNonDisposableNode(nodeToDispose)) { - continue; - } - const tensors = getTensorsForCurrentContext( - nodeToDispose.name, tensorMap, context); - for (const tensor of tensors) { - if (!tensor || tensor.kept || tensorsToKeep.has(tensor.id)) { - continue; - } - tensor.dispose(); - } - } - } - - /** - * Executes the inference for given input tensors in Async fashion. - * @param inputs Tensor map for the model inputs, keyed by the input node - * names. - * @param outputs output node name from the Tensorflow model, if no outputs - * are specified, the default outputs of the model would be used. You can - * inspect intermediate nodes of the model by adding them to the outputs - * array. - */ - async executeAsync(inputs: NamedTensorMap, outputs?: string[]): - Promise { - return this._executeAsync(inputs, outputs); - } - - disposeIntermediateTensors() { - if (!this.clonedTensorsMap) { - return; - } - Object.values(this.clonedTensorsMap).forEach(tensorsList => { - for (const tensor of tensorsList) { - if (tensor && !tensor.isDisposed) { - tensor.dispose(); - } - } - }); - - this.clonedTensorsMap = null; - } - - getIntermediateTensors(): NamedTensorsMap { - return this.clonedTensorsMap; - } - - /** - * Executes the inference for given input tensors in Async fashion. - * @param inputs Tensor map for the model inputs, keyed by the input node - * names. - * @param outputs Optional. output node name from the Tensorflow model, - * if no outputs are specified, the default outputs of the model would be - * used. You can inspect intermediate nodes of the model by adding them to - * the outputs array. - * @param isFunctionExecution Optional. Flag for executing a function. - * @param tensorArrayMap Optional, global TensorArray map by id. Used for - * function execution. - * @param tensorArrayMap Optinal global TensorList map by id. Used for - * function execution. - */ - private async _executeAsync( - inputs: NamedTensorMap, outputs?: string[], isFunctionExecution = false, - tensorArrayMap: TensorArrayMap = {}, - tensorListMap: TensorListMap = {}): Promise { - // Dispose any tensors from a prior run to avoid leaking them. - this.disposeIntermediateTensors(); - if (!isFunctionExecution) { - inputs = this.mapInputs(inputs); - this.checkInputs(inputs); - this.checkInputShapeAndType(inputs); - outputs = this.mapOutputs(outputs); - this.checkOutputs(outputs); - } - - // Keep tensors if KEEP_INTERMEDIATE_TENSORS is on. - try { - this.keepIntermediateTensors = env().getBool('KEEP_INTERMEDIATE_TENSORS'); - } catch (e) { - this.keepIntermediateTensors = false; - console.warn(e.message); - } - - const context = new ExecutionContext( - this.weightMap, tensorArrayMap, tensorListMap, this.functionExecutorMap, - this.parseNodeNameCache); - - if (this.keepIntermediateTensors) { - this.clonedTensorsMap = this.cloneTensorMap(this.weightMap); - } - - // Graph with control flow op requires runtime evaluation of the execution - // order, while without control flow the execution order is pre-determined - // in the compile method. - const tensorsMap = await this.executeWithControlFlow( - inputs, context, outputs, isFunctionExecution); - const results = outputs.map(name => getTensor(name, tensorsMap, context)); - - // dispose all the intermediate tensors - const outputIds = results.map(t => t.id); - const inputIds = Object.keys(inputs).map(name => inputs[name].id); - const keepIds = - new Set([...outputIds, ...inputIds, ...this.weightIds]); - - Object.values(tensorsMap).forEach(tensorsList => { - tensorsList.forEach(tensor => { - if (tensor && !tensor.isDisposed && !keepIds.has(tensor.id)) { - tensor.dispose(); - } - }); - }); - - // dispose the context for the root executor - if (this.parent == null) { - context.dispose(keepIds); - } - - return results; - } - - async executeFunctionAsync( - inputs: Tensor[], tensorArrayMap: TensorArrayMap, - tensorListMap: TensorListMap): Promise { - const mappedInputs = inputs.reduce((map, tensor, index) => { - map[this.inputs[index].name] = tensor; - return map; - }, {} as NamedTensorMap); - - return this._executeAsync( - mappedInputs, this.outputNodes, true, tensorArrayMap, tensorListMap); - } - - /** - * When there are control flow nodes in the graph, the graph execution use - * ExecutionContext to keep track of the frames and loop iterators. - * @param inputs placeholder tensors for the graph. - * @param context the execution context object for current execution. - * @param outputNames Optional. output node name from the Tensorflow model, - * if no outputs are specified, the default outputs of the model would be - * used. You can inspect intermediate nodes of the model by adding them to - * the outputs array. - * @param isFunctionExecution Flag for executing a function. - */ - private async executeWithControlFlow( - inputs: NamedTensorMap, context: ExecutionContext, outputNames?: string[], - isFunctionExecution?: boolean): Promise { - const names = Object.keys(inputs); - const inputNodes = - names.map(name => this.graph.nodes[parseNodeName(name)[0]]); - const outputNodeNames = outputNames.map(name => parseNodeName(name)[0]); - const outputNodeNameSet = new Set(outputNodeNames); - let outputNodes = outputNodeNames.map(name => this.graph.nodes[name]); - - // If no outputs are specified, then use the default outputs of the model. - if (outputNodes.length === 0) { - outputNodes = this._outputs; - } - - const {usedNodes, missingInputs, dynamicNode, syncInputs} = - getExecutionSubgraph( - inputs, outputNodes, this.weightMap, this._initNodes); - - // First nodes to execute include inputNodes, weights, and initNodes. - const stack: NodeWithContexts[] = [ - ...inputNodes, ...this.graph.weights, ...(this._initNodes || []) - ].map(node => { - return {node, contexts: context.currentContext}; - }); - const tensorsMap: NamedTensorsMap = {...this.weightMap}; - Object.keys(inputs).forEach(name => { - const [nodeName, index] = parseNodeName(name); - const tensors: Tensor[] = []; - tensors[index] = inputs[name]; - tensorsMap[nodeName] = tensors; - }); - const intermediateTensorConsumerCount: {[key: number]: number} = {}; - const tensorsToKeep = this.getFrozenTensorIds(tensorsMap); - const added: {[key: string]: boolean} = {}; - while (stack.length > 0) { - const promises = this.processStack( - inputNodes, stack, context, tensorsMap, added, tensorsToKeep, - outputNodeNameSet, intermediateTensorConsumerCount, usedNodes); - await Promise.all(promises); - } - if (dynamicNode == null && !isFunctionExecution) { - console.warn( - `This model execution did not contain any nodes with control flow ` + - `or dynamic output shapes. You can use model.execute() instead.`); - } - const missingOutputs = - outputNodes - .filter( - node => !isControlFlow(node) && - !getTensor(node.name, tensorsMap, context)) - .map(node => node.name); - if (missingOutputs.length > 0) { - let alternativeMsg = ''; - if (dynamicNode != null) { - alternativeMsg = - `Alternatively, to avoid the dynamic ops, use model.execute() ` + - `and specify the inputs [${syncInputs}]`; - } - throw new Error( - `Cannot compute the outputs [${missingOutputs}] from the provided ` + - `inputs [${names}]. Consider providing the following inputs: ` + - `[${missingInputs}]. ${alternativeMsg}`); - } - return tensorsMap; - } - - private processStack( - inputNodes: Node[], stack: NodeWithContexts[], context: ExecutionContext, - tensorMap: NamedTensorsMap, added: {[key: string]: boolean}, - tensorsToKeep: Set, outputNodeNameSet: Set, - intermediateTensorConsumerCount: {[key: number]: number}, - usedNodes: Set) { - const promises: Array> = []; - while (stack.length > 0) { - const item = stack.pop(); - context.currentContext = item.contexts; - let nodeName = ''; - // The tensor of the Enter op with isConstant set should be set - // in the parent scope, so it will be available as constant for the - // whole loop. - if (item.node.op === 'Enter' && - getParamValue('isConstant', item.node, tensorMap, context)) { - [nodeName] = getNodeNameAndIndex(item.node.name, context); - } - - // only process nodes that are not in the tensorMap yet, this include - // inputNodes and internal initNodes. - if (tensorMap[item.node.name] == null) { - const tensors = - executeOp(item.node, tensorMap, context, this._resourceManager); - if (!nodeName) { - [nodeName] = getNodeNameAndIndex(item.node.name, context); - } - const currentContext = context.currentContext; - if (util.isPromise(tensors)) { - promises.push(tensors.then(t => { - tensorMap[nodeName] = t; - if (this.keepIntermediateTensors) { - this.clonedTensorsMap[nodeName] = this.cloneTensorList(t); - } - context.currentContext = currentContext; - this.checkTensorForDisposal( - nodeName, item.node, tensorMap, context, tensorsToKeep, - outputNodeNameSet, intermediateTensorConsumerCount); - this.processChildNodes( - item.node, stack, context, tensorMap, added, usedNodes); - return t; - })); - } else { - tensorMap[nodeName] = tensors; - if (this.keepIntermediateTensors) { - this.clonedTensorsMap[nodeName] = this.cloneTensorList(tensors); - } - this.checkTensorForDisposal( - nodeName, item.node, tensorMap, context, tensorsToKeep, - outputNodeNameSet, intermediateTensorConsumerCount); - this.processChildNodes( - item.node, stack, context, tensorMap, added, usedNodes); - } - } else { - this.processChildNodes( - item.node, stack, context, tensorMap, added, usedNodes); - } - } - return promises; - } - - private processChildNodes( - node: Node, stack: NodeWithContexts[], context: ExecutionContext, - tensorMap: NamedTensorsMap, added: {[key: string]: boolean}, - usedNodes: Set) { - node.children.forEach((childNode) => { - const [nodeName, ] = getNodeNameAndIndex(childNode.name, context); - if (added[nodeName] || !usedNodes.has(childNode.name)) { - return; - } - // Merge op can be pushed if any of its inputs has value. - if (childNode.op === 'Merge') { - if (childNode.inputNames.some(name => { - return !!getTensor(name, tensorMap, context); - })) { - added[nodeName] = true; - stack.push({contexts: context.currentContext, node: childNode}); - } - } else // Otherwise all inputs must to have value. - if (childNode.inputNames.every(name => { - return !!getTensor(name, tensorMap, context); - })) { - added[nodeName] = true; - stack.push({contexts: context.currentContext, node: childNode}); - } - }); - } - - /** - * Releases the memory used by the weight tensors. - */ - dispose() { - Object.keys(this.weightMap) - .forEach( - key => this.weightMap[key].forEach(tensor => tensor.dispose())); - } - - private checkInputShapeAndType(inputs: NamedTensorMap) { - Object.keys(inputs).forEach(name => { - const input = inputs[name]; - const [nodeName, ] = parseNodeName(name); - const node = this.graph.nodes[nodeName]; - if (node.attrParams['shape'] && node.attrParams['shape'].value) { - const shape = node.attrParams['shape'].value as number[]; - const match = shape.length === input.shape.length && - input.shape.every( - (dim, index) => shape[index] === -1 || shape[index] === dim); - util.assert( - match, - () => `The shape of dict['${node.name}'] provided in ` + - `model.execute(dict) must be [${shape}], but was ` + - `[${input.shape}]`); - } - if (node.attrParams['dtype'] && node.attrParams['dtype'].value) { - util.assert( - input.dtype === node.attrParams['dtype'].value as string, - () => `The dtype of dict['${node.name}'] provided in ` + - `model.execute(dict) must be ` + - `${node.attrParams['dtype'].value}, but was ${input.dtype}`); - } - }); - } - - private mapInputs(inputs: NamedTensorMap) { - const result: NamedTensorMap = {}; - for (const inputName in inputs) { - const tensor = this._signature ?.inputs ?.[inputName]; - if (tensor != null) { - result[tensor.name] = inputs[inputName]; - } else { - result[inputName] = inputs[inputName]; - } - } - return result; - } - - private checkInputs(inputs: NamedTensorMap) { - const notInGraph = Object.keys(inputs).filter(name => { - const [nodeName] = parseNodeName(name); - return this.graph.nodes[nodeName] == null; - }); - if (notInGraph.length > 0) { - throw new Error( - `The dict provided in model.execute(dict) has ` + - `keys: [${notInGraph}] that are not part of graph`); - } - } - - private mapOutputs(outputs: string[]) { - return outputs.map(name => { - const tensor = this._signature ?.outputs ?.[name]; - if (tensor != null) { - return tensor.name; - } - return name; - }, {}); - } - - private checkOutputs(outputs: string[]): void { - outputs.forEach(name => { - const [normalizedName] = parseNodeName(name); - if (!this.graph.nodes[normalizedName]) { - throw new Error(`The output '${name}' is not found in the graph`); - } - }); - } -} diff --git a/tfjs-master/tfjs-converter/src/executor/graph_executor_test.ts b/tfjs-master/tfjs-converter/src/executor/graph_executor_test.ts deleted file mode 100644 index 2623a8a82..000000000 --- a/tfjs-master/tfjs-converter/src/executor/graph_executor_test.ts +++ /dev/null @@ -1,718 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import * as tfc from '@tensorflow/tfjs-core'; - -import * as tensorflow from '../data/compiled_api'; -import {createNumberAttr} from '../operations/executors/test_helper'; -import {createTensorAttr} from '../operations/executors/test_helper'; -import {Graph, Node} from '../operations/types'; - -import {GraphExecutor} from './graph_executor'; - -let executor: GraphExecutor; -let inputNode: Node; -let constNode: Node; -let intermediateNode: Node; -let intermediateNode2: Node; -let rsqrtNode: Node; -let outputNode: Node; -let graph: Graph; -let graphWithControlFlow: Graph; -let constTensor: tfc.Tensor; - -const SIGNATURE: tensorflow.ISignatureDef = { - inputs: { - x: {name: 'input', dtype: tensorflow.DataType.DT_INT32, tensorShape: {}} - }, - outputs: { - add: {name: 'output', dtype: tensorflow.DataType.DT_FLOAT, tensorShape: {}} - } -}; - -describe('GraphExecutor', () => { - beforeEach(() => { - inputNode = { - inputNames: [], - inputs: [], - children: [], - signatureKey: 'x', - name: 'input', - op: 'Placeholder', - category: 'graph', - attrParams: {}, - inputParams: {} - }; - constNode = { - inputNames: [], - inputs: [], - children: [], - name: 'const', - op: 'Const', - category: 'graph', - attrParams: {}, - inputParams: {} - - }; - intermediateNode = { - inputNames: ['input', 'const'], - inputs: [inputNode, constNode], - children: [], - name: 'intermediate', - op: 'Add', - category: 'arithmetic', - inputParams: {'a': createTensorAttr(0), 'b': createTensorAttr(1)}, - attrParams: {} - }; - intermediateNode2 = { - inputNames: ['intermediate', 'const'], - inputs: [intermediateNode, constNode], - children: [], - name: 'intermediate2', - op: 'Add', - category: 'arithmetic', - inputParams: {'a': createTensorAttr(0), 'b': createTensorAttr(1)}, - attrParams: {} - }; - outputNode = { - inputNames: ['intermediate2', 'const'], - inputs: [intermediateNode2, constNode], - children: [], - name: 'output', - signatureKey: 'add', - op: 'Add', - category: 'arithmetic', - inputParams: {'a': createTensorAttr(0), 'b': createTensorAttr(1)}, - attrParams: {} - }; - graph = { - inputs: [inputNode], - nodes: { - 'input': inputNode, - 'const': constNode, - 'intermediate': intermediateNode, - 'intermediate2': intermediateNode2, - 'output': outputNode - }, - outputs: [outputNode], - weights: [constNode], - placeholders: [inputNode], - functions: { - while_body: { - inputs: [inputNode], - nodes: { - 'input': inputNode, - 'const': constNode, - 'intermediate': intermediateNode, - 'intermediate2': intermediateNode2, - 'output': outputNode - }, - outputs: [outputNode], - weights: [constNode], - placeholders: [inputNode], - signature: SIGNATURE - } - }, - signature: SIGNATURE - }; - inputNode.children.push(intermediateNode); - constNode.children.push(intermediateNode, intermediateNode2, outputNode); - intermediateNode.children.push(intermediateNode2); - intermediateNode2.children.push(outputNode); - executor = new GraphExecutor(graph); - constTensor = tfc.scalar(2.0); - executor.weightMap = {'const': [constTensor]}; - }); - afterEach(() => {}); - - describe('execute graph', () => { - describe('initialization', () => { - it('should expose input names', () => { - expect(executor.inputNodes).toEqual(['x']); - }); - - it('should expose output names', () => { - expect(executor.outputNodes).toEqual(['add']); - }); - - it('should expose inputs', () => { - inputNode.attrParams['shape'] = {value: [1], type: 'shape'}; - inputNode.attrParams['dtype'] = {value: 'float32', type: 'dtype'}; - expect(executor.inputs).toEqual([ - {name: 'input', shape: [1], dtype: 'float32'} - ]); - }); - - it('should expose outputs', () => { - outputNode.attrParams['shape'] = {value: [1, 1], type: 'shape'}; - outputNode.attrParams['dtype'] = {value: 'int32', type: 'dtype'}; - expect(executor.outputs).toEqual([ - {name: 'output', shape: [1, 1], dtype: 'int32'} - ]); - }); - - it('should expose functions', () => { - expect(executor.functions).toEqual({while_body: SIGNATURE}); - }); - }); - - describe('graph level', () => { - describe('execute', () => { - it('should execute the op', async () => { - const inputTensor = tfc.scalar(1); - const result = executor.execute({input: inputTensor}, ['output']); - tfc.test_util.expectArraysClose(await result[0].data(), [7.0]); - }); - - it('should allow output intermediate nodes', async () => { - const inputTensor = tfc.scalar(1); - const result = executor.execute( - {input: inputTensor}, ['output', 'intermediate']); - tfc.test_util.expectArraysClose(await result[1].data(), [3.0]); - tfc.test_util.expectArraysClose(await result[0].data(), [7.0]); - }); - - it('should allow output multiple intermediate nodes', async () => { - const inputTensor = tfc.scalar(1); - const result = executor.execute( - {input: inputTensor}, - ['output', 'intermediate', 'intermediate2']); - tfc.test_util.expectArraysClose(await result[1].data(), [3.0]); - tfc.test_util.expectArraysClose(await result[2].data(), [5.0]); - tfc.test_util.expectArraysClose(await result[0].data(), [7.0]); - }); - - it('should allow feed intermediate nodes', async () => { - const intermediateTensor = tfc.scalar(1); - const result = - executor.execute({intermediate: intermediateTensor}, ['output']); - tfc.test_util.expectArraysClose(await result[0].data(), [5.0]); - }); - - it('should skip noop', async () => { - const inputNode: Node = { - inputNames: [], - inputs: [], - children: [], - name: 'input', - op: 'Placeholder', - category: 'graph', - attrParams: {}, - inputParams: {} - }; - - const noopNode: Node = { - inputNames: ['input'], - inputs: [inputNode], - children: [], - name: 'noop', - op: 'NoOp', - category: 'graph', - inputParams: {}, - attrParams: {} - }; - - const packNode: Node = { - // Even though `noop` is an input, it should be excluded during - // execution - inputNames: ['input', 'noop'], - inputs: [inputNode, noopNode], - children: [], - name: 'pack', - op: 'Pack', - category: 'slice_join', - inputParams: { - tensors: { - // this range matches all the tensors in the input - 'type': 'tensors', - 'inputIndexStart': 0, - 'inputIndexEnd': 0, - } - }, - attrParams: {axis: createNumberAttr(0)} - }; - inputNode.children.push(noopNode, packNode); - noopNode.children.push(packNode); - - const graph: Graph = { - inputs: [inputNode], - nodes: { - 'input': inputNode, - 'noop': noopNode, - 'pack': packNode, - }, - outputs: [packNode], - placeholders: [inputNode], - weights: [] - }; - - const executor = new GraphExecutor(graph); - const inputTensor = tfc.tensor1d([123, 456]); - const result = executor.execute({input: inputTensor}, ['pack']); - tfc.test_util.expectArraysClose(await result[0].data(), [123, 456]); - }); - - describe('strict input check', () => { - it('should throw exception if missing inputs', () => { - expect(() => executor.execute({}, ['output'])) - .toThrowError( - 'Cannot compute the outputs [output] from the provided ' + - 'inputs []. Missing the following inputs: [input]'); - }); - - it('should throw exception if contains extra inputs', () => { - const inputTensor = tfc.scalar(1); - expect( - () => executor.execute( - {test: inputTensor, input: inputTensor}, ['output'])) - .toThrowError( - 'The dict provided in model.execute(dict) has keys: ' + - '[test] that are not part of graph'); - }); - - it('should throw exception if inputs shapes mismatch', () => { - inputNode.attrParams['shape'] = {value: [1, 1], type: 'shape'}; - const inputTensor = tfc.tensor1d([1], 'float32'); - expect(() => executor.execute({input: inputTensor}, ['output'])) - .toThrow(new Error( - 'The shape of dict[\'input\'] provided' + - ' in model.execute(dict) must be [1,1], but was [1]')); - }); - - it('should throw exception for dtype mismatch', () => { - inputNode.attrParams['dtype'] = {value: 'int32', type: 'dtype'}; - const inputTensor = tfc.tensor1d([1], 'float32'); - expect(() => executor.execute({input: inputTensor}, ['output'])) - .toThrow(new Error( - 'The dtype of dict[\'input\'] provided' + - ' in model.execute(dict) must be int32, but was float32')); - }); - }); - - describe('outputs check', () => { - it('should reject missing outputs', () => { - const inputTensor = tfc.tensor1d([1], 'float32'); - expect(() => executor.execute({input: inputTensor}, ['missing'])) - .toThrowError(/The output 'missing' is not found in the graph/); - }); - - it('should reject missing outputs with child tensors', () => { - const inputTensor = tfc.tensor1d([1], 'float32'); - expect(() => executor.execute({input: inputTensor}, ['missing:0'])) - .toThrowError( - /The output 'missing:0' is not found in the graph/); - }); - - it('should accept existing outputs', () => { - const inputTensor = tfc.tensor1d([1], 'float32'); - const res = executor.execute({input: inputTensor}, ['output']); - expect(res).not.toBeNull(); - }); - - it('should accept existing outputs with child tensors', () => { - const inputTensor = tfc.tensor1d([1], 'float32'); - const res = executor.execute({input: inputTensor}, ['output:0']); - expect(res).not.toBeNull(); - }); - }); - - it('should not throw exception if inputs shapes is dynamic', () => { - inputNode.attrParams['shape'] = {value: [-1, 1, 1, 1], type: 'shape'}; - const inputTensor = tfc.tensor4d([1, 1], [2, 1, 1, 1], 'float32'); - const res = executor.execute({input: inputTensor}, ['output']); - expect(res).not.toBeNull(); - }); - - it('should not have mem leak when add index', async () => { - const inputTensor = tfc.tensor4d([1, 1], [2, 1, 1, 1], 'float32'); - const numTensors: number = tfc.memory().numTensors; - - const res = executor.execute({input: inputTensor}, ['output:0']); - expect(res).not.toBeNull(); - expect(tfc.memory().numTensors).toEqual(numTensors + 1); - }); - }); - - describe('executeAsync', () => { - beforeEach(() => { - inputNode = { - inputNames: [], - inputs: [], - children: [], - name: 'input', - op: 'Placeholder', - category: 'graph', - attrParams: {}, - inputParams: {} - }; - constNode = { - inputNames: [], - inputs: [], - children: [], - name: 'const', - op: 'Const', - category: 'graph', - attrParams: {}, - inputParams: {} - }; - intermediateNode = { - inputNames: ['input', 'const'], - inputs: [inputNode, constNode], - children: [], - name: 'intermediate', - op: 'Add', - category: 'arithmetic', - inputParams: {'a': createTensorAttr(0), 'b': createTensorAttr(1)}, - attrParams: {} - }; - rsqrtNode = { - inputNames: ['intermediate'], - inputs: [intermediateNode], - children: [], - name: 'rsqrt', - op: 'Rsqrt', - category: 'basic_math', - inputParams: {'x': createTensorAttr(0)}, - attrParams: {} - }; - outputNode = { - inputNames: ['const', 'rsqrt'], - inputs: [constNode, rsqrtNode], - children: [], - name: 'output', - op: 'Switch', - category: 'control', - inputParams: - {'pred': createTensorAttr(0), 'data': createTensorAttr(1)}, - attrParams: {} - }; - inputNode.children.push(intermediateNode); - constNode.children.push(intermediateNode, outputNode); - intermediateNode.children.push(rsqrtNode); - rsqrtNode.children.push(outputNode); - graphWithControlFlow = { - inputs: [constNode, inputNode], - nodes: { - 'input': inputNode, - 'const': constNode, - 'intermediate': intermediateNode, - 'rsqrt': rsqrtNode, - 'output': outputNode - }, - outputs: [outputNode], - weights: [constNode], - placeholders: [inputNode] - }; - - executor = new GraphExecutor(graphWithControlFlow); - executor.weightMap = {const : [constTensor]}; - }); - - it('should execute control flow graph', async () => { - const inputTensor = tfc.scalar(1); - - const result = - await executor.executeAsync({input: inputTensor}, ['output:1']); - tfc.test_util.expectArraysClose(await result[0].data(), [0.57735]); - }); - - it('should allow output intermediate nodes', async () => { - const inputTensor = tfc.scalar(1); - const result = await executor.executeAsync( - {input: inputTensor}, ['intermediate']); - tfc.test_util.expectArraysClose(await result[0].data(), [3.0]); - }); - - it('should be able to execute control flow graph ' + - 'with intermediate node more than once', - async () => { - const inputTensor = tfc.scalar(1); - - const result = await executor.executeAsync( - {intermediate: inputTensor}, ['output:1']); - tfc.test_util.expectArraysClose(await result[0].data(), [1]); - const result2 = await executor.executeAsync( - {intermediate: inputTensor}, ['output:1']); - tfc.test_util.expectArraysClose(await result2[0].data(), [1]); - }); - - it('should not have mem leak', async () => { - const inputTensor = tfc.scalar(1); - const numTensors: number = tfc.memory().numTensors; - - await executor.executeAsync({input: inputTensor}, ['output:1']); - expect(tfc.memory().numTensors).toEqual(numTensors + 1); - }); - }); - - describe('controlFlowV2_if', () => { - beforeEach(() => { - inputNode = { - inputNames: [], - inputs: [], - children: [], - name: 'input', - op: 'Placeholder', - category: 'graph', - attrParams: {}, - inputParams: {} - }; - const inputNode2: Node = { - inputNames: [], - inputs: [], - children: [], - name: 'x', - op: 'Placeholder', - category: 'graph', - attrParams: {}, - inputParams: {} - }; - const inputNode3: Node = { - inputNames: [], - inputs: [], - children: [], - name: 'y', - op: 'Placeholder', - category: 'graph', - attrParams: {}, - inputParams: {} - }; - outputNode = { - inputNames: ['input', 'x', 'y'], - inputs: [inputNode, inputNode2, inputNode3], - children: [], - name: 'output', - op: 'StatelessIf', - category: 'control', - attrParams: { - 'thenBranch': {'value': 'trueFunc', 'type': 'func'}, - 'elseBranch': {'value': 'falseFunc', 'type': 'func'} - }, - inputParams: { - 'cond': {'type': 'tensor', 'inputIndexStart': 0}, - 'args': - {'type': 'tensors', 'inputIndexStart': 1, 'inputIndexEnd': 0} - } - }; - inputNode.children.push(outputNode); - inputNode2.children.push(outputNode); - inputNode3.children.push(outputNode); - const xNode: Node = { - inputNames: [], - inputs: [], - children: [], - name: 'x', - op: 'Placeholder', - category: 'graph', - attrParams: {}, - inputParams: {} - }; - const yNode: Node = { - inputNames: [], - inputs: [], - children: [], - name: 'y', - op: 'Placeholder', - category: 'graph', - attrParams: {}, - inputParams: {} - }; - const trueFuncGraph: Graph = { - inputs: [xNode, yNode], - nodes: {'x': xNode, 'y': yNode}, - outputs: [xNode], - weights: [], - placeholders: [xNode, yNode], - }; - const falseFuncGraph: Graph = { - inputs: [xNode, yNode], - nodes: {'x': xNode, 'y': yNode}, - outputs: [yNode], - weights: [], - placeholders: [xNode, yNode], - }; - graphWithControlFlow = { - inputs: [inputNode, inputNode2, inputNode3], - nodes: { - 'input': inputNode, - 'x': inputNode2, - 'y': inputNode3, - 'output': outputNode - }, - outputs: [outputNode], - weights: [], - placeholders: [inputNode, inputNode2, inputNode3], - functions: {trueFunc: trueFuncGraph, falseFunc: falseFuncGraph} - }; - - executor = new GraphExecutor(graphWithControlFlow); - executor.weightMap = {}; - }); - - it('should execute control flow v2 graph', async () => { - const condTensor = tfc.scalar(true, 'bool'); - const condTensor2 = tfc.scalar(false, 'bool'); - const trueTensor = tfc.scalar(1, 'int32'); - const falseTensor = tfc.scalar(0, 'int32'); - - let result = await executor.executeAsync( - {input: condTensor, x: trueTensor, y: falseTensor}, ['output']); - tfc.test_util.expectArraysClose(await result[0].data(), 1); - result = await executor.executeAsync( - {input: condTensor2, x: trueTensor, y: falseTensor}, ['output']); - tfc.test_util.expectArraysClose(await result[0].data(), 0); - }); - it('should not have mem leak', async () => { - const condTensor = tfc.scalar(true, 'bool'); - const trueTensor = tfc.scalar(1, 'int32'); - const falseTensor = tfc.scalar(0, 'int32'); - const numTensors: number = tfc.memory().numTensors; - - await executor.executeAsync( - {input: condTensor, x: trueTensor, y: falseTensor}, ['output']); - expect(tfc.memory().numTensors).toEqual(numTensors); - }); - }); - - describe('controlFlowV2_while', () => { - beforeEach(() => { - const inputNode2: Node = { - inputNames: [], - inputs: [], - children: [], - name: 'x', - op: 'Placeholder', - category: 'graph', - attrParams: {}, - inputParams: {} - }; - const inputNode3: Node = { - inputNames: [], - inputs: [], - children: [], - name: 'y', - op: 'Placeholder', - category: 'graph', - attrParams: {}, - inputParams: {} - }; - outputNode = { - inputNames: ['x', 'y'], - inputs: [inputNode2, inputNode3], - children: [], - name: 'output', - op: 'StatelessWhile', - category: 'control', - attrParams: { - 'cond': {'value': 'condFunc', 'type': 'func'}, - 'body': {'value': 'bodyFunc', 'type': 'func'} - }, - inputParams: { - 'args': - {'type': 'tensors', 'inputIndexStart': 0, 'inputIndexEnd': 0} - } - }; - inputNode2.children.push(outputNode); - inputNode3.children.push(outputNode); - const xNode: Node = { - inputNames: [], - inputs: [], - children: [], - name: 'x', - op: 'Placeholder', - category: 'graph', - attrParams: {}, - inputParams: {} - }; - const yNode: Node = { - inputNames: [], - inputs: [], - children: [], - name: 'y', - op: 'Placeholder', - category: 'graph', - attrParams: {}, - inputParams: {} - }; - const addNode: Node = { - inputNames: ['x', 'y'], - inputs: [xNode, yNode], - children: [], - name: 'add', - op: 'Add', - category: 'arithmetic', - inputParams: {'a': createTensorAttr(0), 'b': createTensorAttr(1)}, - attrParams: {} - }; - xNode.children.push(addNode); - yNode.children.push(addNode); - const bodyFunc: Graph = { - inputs: [xNode, yNode], - nodes: {'x': xNode, 'y': yNode, add: addNode}, - outputs: [addNode, yNode], - weights: [], - placeholders: [xNode, yNode], - }; - const condFunc: Graph = { - inputs: [xNode, yNode], - nodes: {'x': xNode, 'y': yNode}, - outputs: [xNode], - weights: [], - placeholders: [xNode, yNode], - }; - graphWithControlFlow = { - inputs: [inputNode2, inputNode3], - nodes: {'x': inputNode2, 'y': inputNode3, 'output': outputNode}, - outputs: [outputNode], - weights: [], - placeholders: [inputNode2, inputNode3], - functions: {condFunc, bodyFunc} - }; - - executor = new GraphExecutor(graphWithControlFlow); - executor.weightMap = {}; - }); - - it('should execute control flow v2 graph', async () => { - const trueTensor = tfc.scalar(-1, 'int32'); - const falseTensor = tfc.scalar(1, 'int32'); - - const result = await executor.executeAsync( - {x: trueTensor, y: falseTensor}, ['output']); - tfc.test_util.expectArraysClose(await result[0].data(), 0); - }); - it('should not have mem leak', async () => { - const trueTensor = tfc.scalar(-1, 'int32'); - const falseTensor = tfc.scalar(1, 'int32'); - const numTensors: number = tfc.memory().numTensors; - - await executor.executeAsync( - {x: trueTensor, y: falseTensor}, ['output']); - expect(tfc.memory().numTensors).toEqual(numTensors + 1); - }); - it('should not have mem leak when add index', async () => { - const trueTensor = tfc.scalar(-1, 'int32'); - const falseTensor = tfc.scalar(1, 'int32'); - const numTensors: number = tfc.memory().numTensors; - - await executor.executeAsync( - {x: trueTensor, y: falseTensor}, ['output:0']); - expect(tfc.memory().numTensors).toEqual(numTensors + 1); - }); - }); - }); - }); -}); diff --git a/tfjs-master/tfjs-converter/src/executor/graph_model.ts b/tfjs-master/tfjs-converter/src/executor/graph_model.ts deleted file mode 100644 index ef9c8ad57..000000000 --- a/tfjs-master/tfjs-converter/src/executor/graph_model.ts +++ /dev/null @@ -1,684 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {dispose, InferenceModel, io, ModelPredictConfig, NamedTensorMap, Tensor, util} from '@tensorflow/tfjs-core'; - -import * as tensorflow from '../data/compiled_api'; -import {NamedTensorsMap, TensorInfo} from '../data/types'; -import {OperationMapper} from '../operations/operation_mapper'; - -import {GraphExecutor} from './graph_executor'; -import {ResourceManager} from './resource_manager'; - -export const TFHUB_SEARCH_PARAM = '?tfjs-format=file'; -export const DEFAULT_MODEL_NAME = 'model.json'; -type Url = string|io.IOHandler|io.IOHandlerSync; -type UrlIOHandler = T extends string ? io.IOHandler : T; - -/** - * A `tf.GraphModel` is a directed, acyclic graph built from a - * SavedModel GraphDef and allows inference execution. - * - * A `tf.GraphModel` can only be created by loading from a model converted from - * a [TensorFlow SavedModel](https://www.tensorflow.org/guide/saved_model) using - * the command line converter tool and loaded via `tf.loadGraphModel`. - * - * @doc {heading: 'Models', subheading: 'Classes'} - */ -export class GraphModel implements - InferenceModel { - private executor: GraphExecutor; - private version = 'n/a'; - private handler: UrlIOHandler; - private artifacts: io.ModelArtifacts; - private initializer: GraphExecutor; - private resourceIdToCapturedInput: {[key: number]: Tensor}; - private resourceManager: ResourceManager; - private signature: tensorflow.ISignatureDef; - private initializerSignature: tensorflow.ISignatureDef; - private structuredOutputKeys: string[]; - private readonly io: typeof io; - - // Returns the version information for the tensorflow model GraphDef. - get modelVersion(): string { - return this.version; - } - - get inputNodes(): string[] { - return this.executor.inputNodes; - } - - get outputNodes(): string[] { - return this.executor.outputNodes; - } - - get inputs(): TensorInfo[] { - return this.executor.inputs; - } - - get outputs(): TensorInfo[] { - return this.executor.outputs; - } - - get weights(): NamedTensorsMap { - return this.executor.weightMap; - } - - get metadata(): {} { - return this.artifacts.userDefinedMetadata; - } - - get modelSignature(): {} { - return this.signature; - } - - get modelStructuredOutputKeys(): {} { - return this.structuredOutputKeys; - } - - /** - * @param modelUrl url for the model, or an `io.IOHandler`. - * @param weightManifestUrl url for the weight file generated by - * scripts/convert.py script. - * @param requestOption options for Request, which allows to send credentials - * and custom headers. - * @param onProgress Optional, progress callback function, fired periodically - * before the load is completed. - */ - constructor( - private modelUrl: ModelURL, private loadOptions: io.LoadOptions = {}, - tfio = io) { - this.io = tfio; - if (loadOptions == null) { - this.loadOptions = {}; - } - this.resourceManager = new ResourceManager(); - } - - private findIOHandler() { - type IOHandler = UrlIOHandler; - const path = this.modelUrl; - if ((path as io.IOHandler).load != null) { - // Path is an IO Handler. - this.handler = path as IOHandler; - } else if (this.loadOptions.requestInit != null) { - this.handler = this.io.browserHTTPRequest( - path as string, this.loadOptions) as IOHandler; - } else { - const handlers = - this.io.getLoadHandlers(path as string, this.loadOptions); - if (handlers.length === 0) { - // For backward compatibility: if no load handler can be found, - // assume it is a relative http path. - handlers.push( - this.io.browserHTTPRequest(path as string, this.loadOptions)); - } else if (handlers.length > 1) { - throw new Error( - `Found more than one (${handlers.length}) load handlers for ` + - `URL '${[path]}'`); - } - this.handler = handlers[0] as IOHandler; - } - } - - /** - * Loads the model and weight files, construct the in memory weight map and - * compile the inference graph. - */ - load(): UrlIOHandler extends io.IOHandlerSync? boolean: - Promise { - type IOHandler = UrlIOHandler; - this.findIOHandler(); - if (this.handler.load == null) { - throw new Error( - 'Cannot proceed with model loading because the IOHandler provided ' + - 'does not have the `load` method implemented.'); - } - - type Result = - IOHandler extends io.IOHandlerSync ? boolean : Promise; - - const loadResult = this.handler.load() as ReturnType; - if (util.isPromise(loadResult)) { - return loadResult.then(artifacts => this.loadSync(artifacts)) as Result; - } - - return this.loadSync(loadResult) as Result; - } - - /** - * Synchronously construct the in memory weight map and - * compile the inference graph. - * - * @doc {heading: 'Models', subheading: 'Classes', ignoreCI: true} - */ - loadSync(artifacts: io.ModelArtifacts) { - this.artifacts = artifacts; - const graph = this.artifacts.modelTopology as tensorflow.IGraphDef; - - let signature = this.artifacts.signature; - if (this.artifacts.userDefinedMetadata != null) { - const metadata = this.artifacts.userDefinedMetadata; - if (metadata.signature != null) { - signature = metadata.signature; - } - - if (metadata.structuredOutputKeys != null) { - this.structuredOutputKeys = metadata.structuredOutputKeys as string[]; - } - } - this.signature = signature; - - this.version = `${graph.versions.producer}.${graph.versions.minConsumer}`; - const weightMap = this.io.decodeWeights( - this.artifacts.weightData, this.artifacts.weightSpecs); - this.executor = new GraphExecutor( - OperationMapper.Instance.transformGraph(graph, this.signature)); - this.executor.weightMap = this.convertTensorMapToTensorsMap(weightMap); - // Attach a model-level resourceManager to each executor to share resources, - // such as `HashTable`. - this.executor.resourceManager = this.resourceManager; - - if (artifacts.modelInitializer != null && - (artifacts.modelInitializer as tensorflow.IGraphDef).node != null) { - const initializer = - OperationMapper.Instance.transformGraph(artifacts.modelInitializer); - this.initializer = new GraphExecutor(initializer); - this.initializer.weightMap = this.executor.weightMap; - // Attach a model-level resourceManager to the initializer, the - // hashTables created from when executing the initializer will be stored - // in the resourceManager. - this.initializer.resourceManager = this.resourceManager; - this.initializerSignature = artifacts.initializerSignature; - } - - return true; - } - - /** - * Save the configuration and/or weights of the GraphModel. - * - * An `IOHandler` is an object that has a `save` method of the proper - * signature defined. The `save` method manages the storing or - * transmission of serialized data ("artifacts") that represent the - * model's topology and weights onto or via a specific medium, such as - * file downloads, local storage, IndexedDB in the web browser and HTTP - * requests to a server. TensorFlow.js provides `IOHandler` - * implementations for a number of frequently used saving mediums, such as - * `tf.io.browserDownloads` and `tf.io.browserLocalStorage`. See `tf.io` - * for more details. - * - * This method also allows you to refer to certain types of `IOHandler`s - * as URL-like string shortcuts, such as 'localstorage://' and - * 'indexeddb://'. - * - * Example 1: Save `model`'s topology and weights to browser [local - * storage](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage); - * then load it back. - * - * ```js - * const modelUrl = - * 'https://storage.googleapis.com/tfjs-models/savedmodel/mobilenet_v2_1.0_224/model.json'; - * const model = await tf.loadGraphModel(modelUrl); - * const zeros = tf.zeros([1, 224, 224, 3]); - * model.predict(zeros).print(); - * - * const saveResults = await model.save('localstorage://my-model-1'); - * - * const loadedModel = await tf.loadGraphModel('localstorage://my-model-1'); - * console.log('Prediction from loaded model:'); - * model.predict(zeros).print(); - * ``` - * - * @param handlerOrURL An instance of `IOHandler` or a URL-like, - * scheme-based string shortcut for `IOHandler`. - * @param config Options for saving the model. - * @returns A `Promise` of `SaveResult`, which summarizes the result of - * the saving, such as byte sizes of the saved artifacts for the model's - * topology and weight values. - * - * @doc {heading: 'Models', subheading: 'Classes', ignoreCI: true} - */ - async save(handlerOrURL: io.IOHandler|string, config?: io.SaveConfig): - Promise { - if (typeof handlerOrURL === 'string') { - const handlers = this.io.getSaveHandlers(handlerOrURL); - if (handlers.length === 0) { - throw new Error( - `Cannot find any save handlers for URL '${handlerOrURL}'`); - } else if (handlers.length > 1) { - throw new Error( - `Found more than one (${handlers.length}) save handlers for ` + - `URL '${handlerOrURL}'`); - } - handlerOrURL = handlers[0]; - } - if (handlerOrURL.save == null) { - throw new Error( - 'GraphModel.save() cannot proceed because the IOHandler ' + - 'provided does not have the `save` attribute defined.'); - } - - return handlerOrURL.save(this.artifacts); - } - - private addStructuredOutputNames(outputTensors: Tensor|Tensor[]) { - if (this.structuredOutputKeys) { - const outputTensorsArray = - outputTensors instanceof Tensor ? [outputTensors] : outputTensors; - const outputTensorMap: NamedTensorMap = {}; - - outputTensorsArray.forEach( - (outputTensor, i) => outputTensorMap[this.structuredOutputKeys[i]] = - outputTensor); - - return outputTensorMap; - } - return outputTensors; - } - - /** - * Execute the inference for the input tensors. - * - * @param input The input tensors, when there is single input for the model, - * inputs param should be a `tf.Tensor`. For models with mutliple inputs, - * inputs params should be in either `tf.Tensor`[] if the input order is - * fixed, or otherwise NamedTensorMap format. - * - * For model with multiple inputs, we recommend you use NamedTensorMap as the - * input type, if you use `tf.Tensor`[], the order of the array needs to - * follow the - * order of inputNodes array. @see {@link GraphModel.inputNodes} - * - * You can also feed any intermediate nodes using the NamedTensorMap as the - * input type. For example, given the graph - * InputNode => Intermediate => OutputNode, - * you can execute the subgraph Intermediate => OutputNode by calling - * model.execute('IntermediateNode' : tf.tensor(...)); - * - * This is useful for models that uses tf.dynamic_rnn, where the intermediate - * state needs to be fed manually. - * - * For batch inference execution, the tensors for each input need to be - * concatenated together. For example with mobilenet, the required input shape - * is [1, 244, 244, 3], which represents the [batch, height, width, channel]. - * If we are provide a batched data of 100 images, the input tensor should be - * in the shape of [100, 244, 244, 3]. - * - * @param config Prediction configuration for specifying the batch size. - * Currently the batch size option is ignored for graph model. - * - * @returns Inference result tensors. If the model is converted and it - * originally had structured_outputs in tensorflow, then a NamedTensorMap - * will be returned matching the structured_outputs. If no structured_outputs - * are present, the output will be single `tf.Tensor` if the model has single - * output node, otherwise Tensor[]. - * - * @doc {heading: 'Models', subheading: 'Classes'} - */ - predict(inputs: Tensor|Tensor[]|NamedTensorMap, config?: ModelPredictConfig): - Tensor|Tensor[]|NamedTensorMap { - const outputTensors = this.execute(inputs, this.outputNodes); - return this.addStructuredOutputNames(outputTensors); - } - - /** - * Execute the inference for the input tensors in async fashion, use this - * method when your model contains control flow ops. - * - * @param input The input tensors, when there is single input for the model, - * inputs param should be a `tf.Tensor`. For models with mutliple inputs, - * inputs params should be in either `tf.Tensor`[] if the input order is - * fixed, or otherwise NamedTensorMap format. - * - * For model with multiple inputs, we recommend you use NamedTensorMap as the - * input type, if you use `tf.Tensor`[], the order of the array needs to - * follow the - * order of inputNodes array. @see {@link GraphModel.inputNodes} - * - * You can also feed any intermediate nodes using the NamedTensorMap as the - * input type. For example, given the graph - * InputNode => Intermediate => OutputNode, - * you can execute the subgraph Intermediate => OutputNode by calling - * model.execute('IntermediateNode' : tf.tensor(...)); - * - * This is useful for models that uses tf.dynamic_rnn, where the intermediate - * state needs to be fed manually. - * - * For batch inference execution, the tensors for each input need to be - * concatenated together. For example with mobilenet, the required input shape - * is [1, 244, 244, 3], which represents the [batch, height, width, channel]. - * If we are provide a batched data of 100 images, the input tensor should be - * in the shape of [100, 244, 244, 3]. - * - * @param config Prediction configuration for specifying the batch size. - * Currently the batch size option is ignored for graph model. - * - * @returns A Promise of inference result tensors. If the model is converted - * and it originally had structured_outputs in tensorflow, then a - * NamedTensorMap will be returned matching the structured_outputs. If no - * structured_outputs are present, the output will be single `tf.Tensor` if - * the model has single output node, otherwise Tensor[]. - * - * @doc {heading: 'Models', subheading: 'Classes'} - */ - async predictAsync( - inputs: Tensor|Tensor[]|NamedTensorMap, - config?: ModelPredictConfig): Promise { - const outputTensors = await this.executeAsync(inputs, this.outputNodes); - return this.addStructuredOutputNames(outputTensors); - } - - private normalizeInputs(inputs: Tensor|Tensor[]| - NamedTensorMap): NamedTensorMap { - if (!(inputs instanceof Tensor) && !Array.isArray(inputs)) { - // The input is already a NamedTensorMap. - const signatureInputs = this.signature?.inputs; - if (signatureInputs != null) { - for (const input in signatureInputs) { - const tensor = signatureInputs[input]; - if (tensor.resourceId != null) { - inputs[input] = this.resourceIdToCapturedInput[tensor.resourceId]; - } - } - } - return inputs; - } - inputs = Array.isArray(inputs) ? inputs : [inputs]; - - const numCapturedInputs = - Object.keys(this.resourceIdToCapturedInput).length; - if (inputs.length + numCapturedInputs !== this.inputNodes.length) { - throw new Error(`Input tensor count mismatch, the graph model has ${ - this.inputNodes.length - - numCapturedInputs} non-resource placeholders, while there are ${ - inputs.length} input tensors provided.`); - } - - let inputIndex = 0; - return this.inputNodes.reduce((map, inputName) => { - const resourceId = this.signature?.inputs?.[inputName]?.resourceId; - if (resourceId != null) { - map[inputName] = this.resourceIdToCapturedInput[resourceId]; - } else { - map[inputName] = (inputs as Tensor[])[inputIndex++]; - } - return map; - }, {} as NamedTensorMap); - } - - private normalizeOutputs(outputs: string|string[]): string[] { - outputs = outputs || this.outputNodes; - return !Array.isArray(outputs) ? [outputs] : outputs; - } - - private executeInitializerGraph() { - if (this.initializer == null) { - return []; - } - if (this.initializerSignature == null) { - return this.initializer.execute({}, []); - } else { - return this.initializer.execute( - {}, Object.keys(this.initializerSignature.outputs)); - } - } - - private async executeInitializerGraphAsync() { - if (this.initializer == null) { - return []; - } - if (this.initializerSignature == null) { - return this.initializer.executeAsync({}, []); - } else { - return this.initializer.executeAsync( - {}, Object.keys(this.initializerSignature.outputs)); - } - } - - private setResourceIdToCapturedInput(outputs: Tensor[]) { - this.resourceIdToCapturedInput = {}; - - if (this.initializerSignature) { - const signatureOutputs = this.initializerSignature.outputs; - const outputNames = Object.keys(signatureOutputs); - for (let i = 0; i < outputNames.length; i++) { - const outputName = outputNames[i]; - const tensorInfo = signatureOutputs[outputName]; - this.resourceIdToCapturedInput[tensorInfo.resourceId] = outputs[i]; - } - } - } - - /** - * Executes inference for the model for given input tensors. - * @param inputs tensor, tensor array or tensor map of the inputs for the - * model, keyed by the input node names. - * @param outputs output node name from the TensorFlow model, if no - * outputs are specified, the default outputs of the model would be used. - * You can inspect intermediate nodes of the model by adding them to the - * outputs array. - * - * @returns A single tensor if provided with a single output or no outputs - * are provided and there is only one default output, otherwise return a - * tensor array. The order of the tensor array is the same as the outputs - * if provided, otherwise the order of outputNodes attribute of the model. - * - * @doc {heading: 'Models', subheading: 'Classes'} - */ - execute(inputs: Tensor|Tensor[]|NamedTensorMap, outputs?: string|string[]): - Tensor|Tensor[] { - if (this.resourceIdToCapturedInput == null) { - this.setResourceIdToCapturedInput(this.executeInitializerGraph()); - } - inputs = this.normalizeInputs(inputs); - outputs = this.normalizeOutputs(outputs); - const result = this.executor.execute(inputs, outputs); - return result.length > 1 ? result : result[0]; - } - - /** - * Executes inference for the model for given input tensors in async - * fashion, use this method when your model contains control flow ops. - * @param inputs tensor, tensor array or tensor map of the inputs for the - * model, keyed by the input node names. - * @param outputs output node name from the TensorFlow model, if no outputs - * are specified, the default outputs of the model would be used. You can - * inspect intermediate nodes of the model by adding them to the outputs - * array. - * - * @returns A Promise of single tensor if provided with a single output or - * no outputs are provided and there is only one default output, otherwise - * return a tensor map. - * - * @doc {heading: 'Models', subheading: 'Classes'} - */ - async executeAsync( - inputs: Tensor|Tensor[]|NamedTensorMap, - outputs?: string|string[]): Promise { - if (this.resourceIdToCapturedInput == null) { - this.setResourceIdToCapturedInput( - await this.executeInitializerGraphAsync()); - } - inputs = this.normalizeInputs(inputs); - outputs = this.normalizeOutputs(outputs); - const result = await this.executor.executeAsync(inputs, outputs); - return result.length > 1 ? result : result[0]; - } - - /** - * Get intermediate tensors for model debugging mode (flag - * KEEP_INTERMEDIATE_TENSORS is true). - * - * @doc {heading: 'Models', subheading: 'Classes'} - */ - getIntermediateTensors(): NamedTensorsMap { - return this.executor.getIntermediateTensors(); - } - - /** - * Dispose intermediate tensors for model debugging mode (flag - * KEEP_INTERMEDIATE_TENSORS is true). - * - * @doc {heading: 'Models', subheading: 'Classes'} - */ - disposeIntermediateTensors() { - this.executor.disposeIntermediateTensors(); - } - - private convertTensorMapToTensorsMap(map: NamedTensorMap): NamedTensorsMap { - return Object.keys(map).reduce((newMap: NamedTensorsMap, key) => { - newMap[key] = [map[key]]; - return newMap; - }, {}); - } - - /** - * Releases the memory used by the weight tensors and resourceManager. - * - * @doc {heading: 'Models', subheading: 'Classes'} - */ - dispose() { - this.executor.dispose(); - - if (this.initializer) { - this.initializer.dispose(); - if (this.resourceIdToCapturedInput) { - dispose(this.resourceIdToCapturedInput); - } - } - - this.resourceManager.dispose(); - } -} - -/** - * Load a graph model given a URL to the model definition. - * - * Example of loading MobileNetV2 from a URL and making a prediction with a - * zeros input: - * - * ```js - * const modelUrl = - * 'https://storage.googleapis.com/tfjs-models/savedmodel/mobilenet_v2_1.0_224/model.json'; - * const model = await tf.loadGraphModel(modelUrl); - * const zeros = tf.zeros([1, 224, 224, 3]); - * model.predict(zeros).print(); - * ``` - * - * Example of loading MobileNetV2 from a TF Hub URL and making a prediction - * with a zeros input: - * - * ```js - * const modelUrl = - * 'https://tfhub.dev/google/imagenet/mobilenet_v2_140_224/classification/2'; - * const model = await tf.loadGraphModel(modelUrl, {fromTFHub: true}); - * const zeros = tf.zeros([1, 224, 224, 3]); - * model.predict(zeros).print(); - * ``` - * @param modelUrl The url or an `io.IOHandler` that loads the model. - * @param options Options for the HTTP request, which allows to send - * credentials - * and custom headers. - * - * @doc {heading: 'Models', subheading: 'Loading'} - */ -export async function loadGraphModel( - modelUrl: string|io.IOHandler, options: io.LoadOptions = {}, - tfio = io): Promise { - if (modelUrl == null) { - throw new Error( - 'modelUrl in loadGraphModel() cannot be null. Please provide a url ' + - 'or an IOHandler that loads the model'); - } - if (options == null) { - options = {}; - } - - if (options.fromTFHub && typeof modelUrl === 'string') { - modelUrl = getTFHubUrl(modelUrl); - } - const model = new GraphModel(modelUrl, options, tfio); - await model.load(); - return model; -} - -/** - * Load a graph model given a synchronous IO handler with a 'load' method. - * - * @param modelSource The `io.IOHandlerSync` that loads the model, or the - * `io.ModelArtifacts` that encode the model, or a tuple of - * `[io.ModelJSON, ArrayBuffer]` of which the first element encodes the - * model and the second contains the weights. - * - * @doc {heading: 'Models', subheading: 'Loading'} - */ -export function loadGraphModelSync( - modelSource: io.IOHandlerSync| - io.ModelArtifacts|[io.ModelJSON, /* Weights */ ArrayBuffer]): - GraphModel { - if (modelSource == null) { - throw new Error( - 'modelUrl in loadGraphModelSync() cannot be null. Please provide ' + - 'model artifacts or an IOHandler that loads the model'); - } - - let ioHandler: io.IOHandlerSync; - if (modelSource instanceof Array) { - const [modelJSON, weights] = modelSource; - if (!modelJSON) { - throw new Error('modelJSON must be the first element of the array'); - } - if (!weights || !(weights instanceof ArrayBuffer)) { - throw new Error( - 'An ArrayBuffer of weights must be the second element of' + - ' the array'); - } - if (!('modelTopology' in modelJSON)) { - throw new Error('Model JSON is missing \'modelTopology\''); - } - if (!('weightsManifest' in modelJSON)) { - throw new Error('Model JSON is missing \'weightsManifest\''); - } - - const weightSpecs = io.getWeightSpecs(modelJSON.weightsManifest); - const modelArtifacts = - io.getModelArtifactsForJSONSync(modelJSON, weightSpecs, weights); - ioHandler = io.fromMemorySync(modelArtifacts); - } else if ('load' in modelSource) { - // Then modelSource is already an IOHandlerSync. - ioHandler = modelSource; - } else if ( - 'modelTopology' in modelSource && 'weightSpecs' in modelSource && - 'weightData' in modelSource) { - // modelSource is of type ModelArtifacts. - ioHandler = io.fromMemorySync(modelSource); - } else { - throw new Error('Unknown model format'); - } - - const model = new GraphModel(ioHandler); - model.load(); - return model; -} - -function getTFHubUrl(modelUrl: string): string { - if (!modelUrl.endsWith('/')) { - modelUrl = (modelUrl) + '/'; - } - return `${modelUrl}${DEFAULT_MODEL_NAME}${TFHUB_SEARCH_PARAM}`; -} diff --git a/tfjs-master/tfjs-converter/src/executor/graph_model_test.ts b/tfjs-master/tfjs-converter/src/executor/graph_model_test.ts deleted file mode 100644 index 2b6d4ca10..000000000 --- a/tfjs-master/tfjs-converter/src/executor/graph_model_test.ts +++ /dev/null @@ -1,1255 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import * as tfc from '@tensorflow/tfjs-core'; -import {io, scalar, Tensor} from '@tensorflow/tfjs-core'; - -import * as tensorflow from '../data/compiled_api'; -import {deregisterOp, registerOp} from '../operations/custom_op/register'; -import {RecursiveSpy, spyOnAllFunctions} from '../operations/executors/spy_ops'; -import {GraphNode} from '../operations/types'; - -import {GraphModel, loadGraphModel, loadGraphModelSync} from './graph_model'; -import {HASH_TABLE_MODEL_V2} from './test_data/hash_table_v2_model_loader'; -import {STRUCTURED_OUTPUTS_MODEL} from './test_data/structured_outputs_model_loader'; - -const HOST = 'http://example.org'; -const MODEL_URL = `${HOST}/model.json`; -const RELATIVE_MODEL_URL = '/path/model.pb'; -let model: GraphModel; -const bias = tfc.tensor1d([1], 'int32'); - -const weightsManifest: tfc.io.WeightsManifestEntry[] = - [{'name': 'Const', 'dtype': 'int32', 'shape': [1]}]; - -const weightsManifestWithInitializer: tfc.io.WeightsManifestEntry[] = [ - {'dtype': 'string', 'name': 'transform/keys', 'shape': [1]}, - {'dtype': 'float32', 'name': 'transform/values', 'shape': [1]} -]; - -const SIMPLE_MODEL: tensorflow.IGraphDef = { - node: [ - { - name: 'Input', - op: 'Placeholder', - attr: { - dtype: { - type: tensorflow.DataType.DT_INT32, - }, - shape: {shape: {dim: [{size: -1}, {size: 1}]}} - } - }, - { - name: 'Const', - op: 'Const', - attr: { - dtype: {type: tensorflow.DataType.DT_INT32}, - value: { - tensor: { - dtype: tensorflow.DataType.DT_INT32, - tensorShape: {dim: [{size: 1}]}, - } - }, - index: {i: 0}, - length: {i: 4} - } - }, - {name: 'Add1', op: 'Add', input: ['Input', 'Const'], attr: {}}, - {name: 'Add', op: 'Add', input: ['Add1', 'Const'], attr: {}} - ], - versions: {producer: 1.0, minConsumer: 3} -}; - -const CONTROL_FLOW_MODEL: tensorflow.IGraphDef = { - node: [ - { - name: 'Input', - op: 'Placeholder', - attr: { - dtype: { - type: tensorflow.DataType.DT_INT32, - }, - shape: {shape: {dim: [{size: -1}, {size: 1}]}} - } - }, - {name: 'Enter', op: 'Enter', attr: {}, input: ['Input']}, - ], - versions: {producer: 1.0, minConsumer: 3} -}; - -const DYNAMIC_SHAPE_MODEL: tensorflow.IGraphDef = { - node: [ - { - name: 'Input', - op: 'Placeholder', - attr: { - dtype: { - type: tensorflow.DataType.DT_BOOL, - }, - shape: {shape: {dim: [{size: -1}, {size: 1}]}} - } - }, - {name: 'Where', op: 'Where', attr: {}, input: ['Input']} - ], - versions: {producer: 1.0, minConsumer: 3} -}; - -const SIGNATURE: tensorflow.ISignatureDef = { - inputs: {x: {name: 'Input:0', dtype: tensorflow.DataType.DT_INT32}}, - outputs: {y: {name: 'Add:0', dtype: tensorflow.DataType.DT_INT32}} -}; -const SIMPLE_HTTP_MODEL_LOADER = { - load: async () => { - return { - modelTopology: SIMPLE_MODEL, - weightSpecs: weightsManifest, - weightData: bias.dataSync(), - format: 'tfjs-graph-model', - generatedBy: '1.15', - convertedBy: '1.3.1', - userDefinedMetadata: {signature: SIGNATURE} - }; - } -}; - -const NO_INPUT_SIGNATURE_MODEL_LOADER = { - load: async () => { - return { - modelTopology: SIMPLE_MODEL, - weightSpecs: weightsManifest, - weightData: bias.dataSync(), - format: 'tfjs-graph-model', - generatedBy: '1.15', - convertedBy: '1.3.1', - userDefinedMetadata: {signature: {outputs: SIGNATURE.outputs}} - }; - } -}; - -const CUSTOM_OP_MODEL: tensorflow.IGraphDef = { - node: [ - { - name: 'Input', - op: 'Placeholder', - attr: { - dtype: { - type: tensorflow.DataType.DT_INT32, - }, - shape: {shape: {dim: [{size: -1}, {size: 1}]}} - } - }, - { - name: 'Const', - op: 'Const', - attr: { - dtype: {type: tensorflow.DataType.DT_INT32}, - value: { - tensor: { - dtype: tensorflow.DataType.DT_INT32, - tensorShape: {dim: [{size: 1}]}, - } - }, - index: {i: 0}, - length: {i: 4} - } - }, - {name: 'Add1', op: 'Add', input: ['Input', 'Const'], attr: {}}, - {name: 'CustomOp', op: 'CustomOp', input: ['Add1'], attr: {}} - ], - versions: {producer: 1.0, minConsumer: 3} -}; - -const CUSTOM_HTTP_MODEL_LOADER = { - load: async () => { - return { - modelTopology: CUSTOM_OP_MODEL, - weightSpecs: weightsManifest, - weightData: bias.dataSync(), - format: 'tfjs-graph-model', - generatedBy: '1.15', - convertedBy: '1.3.1' - }; - } -}; - -const CONTROL_SIGNATURE: tensorflow.ISignatureDef = { - inputs: {x: {name: 'Input:0', dtype: tensorflow.DataType.DT_INT32}}, - outputs: {y: {name: 'Enter:0', dtype: tensorflow.DataType.DT_INT32}} -}; -const CONTROL_FLOW_HTTP_MODEL_LOADER = { - load: async () => { - return { - modelTopology: CONTROL_FLOW_MODEL, - weightSpecs: weightsManifest, - weightData: bias.dataSync(), - userDefinedMetadata: {signature: CONTROL_SIGNATURE}, - format: 'tfjs-graph-model', - generatedBy: '1.15', - convertedBy: '1.3.1' - }; - } -}; - -const STRUCTURED_OUTPUTS_MODEL_LOADER = { - load: async () => { - return STRUCTURED_OUTPUTS_MODEL; - } -}; - -const INITIALIZER_GRAPHDEF: tensorflow.IGraphDef = { - node: [ - { - name: 'transform/values', - op: 'Const', - attr: { - dtype: {type: tensorflow.DataType.DT_FLOAT}, - value: { - tensor: { - dtype: tensorflow.DataType.DT_FLOAT, - tensorShape: {dim: [{size: 1}]} - } - } - } - }, - { - name: 'transform/keys', - op: 'Const', - attr: { - dtype: {type: tensorflow.DataType.DT_STRING}, - value: { - tensor: { - dtype: tensorflow.DataType.DT_STRING, - tensorShape: {dim: [{size: 1}]} - } - } - } - }, - { - name: 'transform/hash_table', - op: 'HashTableV2', - attr: { - value_dtype: {type: tensorflow.DataType.DT_FLOAT}, - use_node_name_sharing: {b: false}, - key_dtype: {type: tensorflow.DataType.DT_STRING}, - container: {s: ''}, - shared_name: {s: 'dGFibGVuYW1l' /* base64 'tablename' */} - } - }, - { - name: 'transform/key_value_init/LookupTableImportV2', - op: 'LookupTableImportV2', - input: ['transform/hash_table', 'transform/keys', 'transform/values'], - attr: { - Tin: {type: tensorflow.DataType.DT_FLOAT}, - Tout: {type: tensorflow.DataType.DT_STRING} - } - } - ], - versions: {producer: 1.0, minConsumer: 3} -}; - -const HASH_TABLE_MODEL: tensorflow.IGraphDef = { - node: [ - { - name: 'Input', - op: 'Placeholder', - attr: { - dtype: { - type: tensorflow.DataType.DT_STRING, - }, - shape: {shape: {dim: [{size: 1}]}} - } - }, - { - name: 'Input_1', - op: 'Placeholder', - attr: { - dtype: { - type: tensorflow.DataType.DT_FLOAT, - }, - shape: {shape: {dim: [{size: 1}]}} - } - }, - { - name: 'transform/hash_table', - op: 'HashTableV2', - input: [], - attr: { - value_dtype: {type: tensorflow.DataType.DT_FLOAT}, - use_node_name_sharing: {b: false}, - key_dtype: {type: tensorflow.DataType.DT_STRING}, - container: {s: ''}, - shared_name: {s: 'dGFibGVuYW1l' /* base64 'tablename' */} - } - }, - { - name: 'LookupTableFindV2', - op: 'LookupTableFindV2', - input: ['transform/hash_table', 'Input', 'Input_1'], - attr: {} - } - ], - versions: {producer: 1.0, minConsumer: 3} -}; - -const HASH_TABLE_SIGNATURE: tensorflow.ISignatureDef = { - inputs: { - keys: {name: 'Input:0', dtype: tensorflow.DataType.DT_STRING}, - defaultValues: {name: 'Input_1:0', dtype: tensorflow.DataType.DT_FLOAT} - }, - outputs: { - values: {name: 'LookupTableFindV2:0', dtype: tensorflow.DataType.DT_FLOAT} - } -}; -const HASHTABLE_V1_HTTP_MODEL_LOADER = { - load: async () => { - return { - modelTopology: HASH_TABLE_MODEL, - weightSpecs: weightsManifestWithInitializer, - weightData: new ArrayBuffer(16), - format: 'tfjs-graph-model', - generatedBy: '1.15', - convertedBy: '2.4', - userDefinedMetadata: {signature: HASH_TABLE_SIGNATURE}, - modelInitializer: INITIALIZER_GRAPHDEF - }; - } -}; - -const HASHTABLE_V2_MODEL_LOADER = { - load: async () => { - return HASH_TABLE_MODEL_V2; - } -}; - -class IOHandlerForTest implements tfc.io.IOHandler { - savedArtifacts: tfc.io.ModelArtifacts; - - async save(modelArtifacts: tfc.io.ModelArtifacts): - Promise { - this.savedArtifacts = modelArtifacts; - return {modelArtifactsInfo: null}; - } -} - -describe('loadSync', () => { - let artifacts: io.ModelArtifacts; - - beforeEach(() => { - model = new GraphModel(MODEL_URL); - artifacts = { - format: 'graph-model', - generatedBy: '0.0.0', - modelTopology: SIMPLE_MODEL, - weightSpecs: weightsManifest, - weightData: new Int32Array([5]).buffer - }; - }); - - it('Can load old model.', () => { - artifacts.convertedBy = 'TensorFlow.js Converter v1.3.2'; - artifacts.userDefinedMetadata = {signature: SIGNATURE}; - const loaded = model.loadSync(artifacts); - - expect(loaded).toBe(true); - expect(model.modelSignature).toEqual(SIGNATURE); - }); - - it('Can load new model.', () => { - artifacts.convertedBy = 'TensorFlow.js Converter v2.8.0'; - artifacts.signature = SIGNATURE; - const loaded = model.loadSync(artifacts); - - expect(loaded).toBe(true); - expect(model.modelSignature).toEqual(SIGNATURE); - }); - - it('Can load model without signature.', () => { - const loaded = model.loadSync(artifacts); - - expect(loaded).toBe(true); - expect(model.modelSignature).toBeUndefined(); - }); - - it('Can load model with structured_outputs.', () => { - artifacts.convertedBy = 'TensorFlow.js Converter v3.19.0'; - artifacts.userDefinedMetadata = {structuredOutputKeys: ['a', 'b', 'c']}; - const loaded = model.loadSync(artifacts); - - expect(loaded).toBe(true); - expect(model.modelStructuredOutputKeys).toEqual(['a', 'b', 'c']); - }); - - it('Can load model with different convertedBy language.', () => { - artifacts.convertedBy = '1.3.2'; - artifacts.userDefinedMetadata = {signature: SIGNATURE}; - const loaded = model.loadSync(artifacts); - - expect(loaded).toBe(true); - expect(model.modelSignature).toEqual(SIGNATURE); - }); -}); - -describe('loadGraphModel', () => { - let spyIo: RecursiveSpy; - - beforeEach(() => { - spyIo = spyOnAllFunctions(io); - }); - - it('Pass a custom io handler', async () => { - const customLoader: tfc.io.IOHandler = { - load: async () => { - return { - modelTopology: SIMPLE_MODEL, - weightSpecs: weightsManifest, - weightData: new Int32Array([5]).buffer, - }; - } - }; - const model = await loadGraphModel(customLoader); - expect(model).toBeDefined(); - const bias = model.weights['Const'][0]; - expect(bias.dtype).toBe('int32'); - expect(bias.dataSync()).toEqual(new Int32Array([5])); - }); - - it('Expect an error when moderUrl is null', async () => { - let errorMsg = 'no error'; - try { - await loadGraphModel(null); - } catch (err) { - errorMsg = err.message; - } - expect(errorMsg).toMatch(/modelUrl in loadGraphModel\(\) cannot be null/); - }); - - it('Pass a fetchFunc', async () => { - const fetchFunc = () => {}; - spyIo.getLoadHandlers.and.returnValue([CUSTOM_HTTP_MODEL_LOADER]); - await loadGraphModel(MODEL_URL, {fetchFunc}, spyIo); - expect(spyIo.getLoadHandlers).toHaveBeenCalledWith(MODEL_URL, {fetchFunc}); - }); -}); - -describe('loadGraphModelSync', () => { - function checkModel(model: GraphModel) { - expect(model).toBeDefined(); - const bias = model.weights['Const'][0]; - expect(bias.dtype).toBe('int32'); - expect(bias.dataSync()).toEqual(new Int32Array([5])); - } - - it('Pass a custom io handler', () => { - const customLoader: tfc.io.IOHandlerSync = { - load: () => { - return { - modelTopology: SIMPLE_MODEL, - weightSpecs: weightsManifest, - weightData: new Int32Array([5]).buffer, - }; - } - }; - const model = loadGraphModelSync(customLoader); - checkModel(model); - }); - - it('Pass the model artifacts directly', () => { - const modelArtifacts: tfc.io.ModelArtifacts = { - modelTopology: SIMPLE_MODEL, - weightSpecs: weightsManifest, - weightData: new Int32Array([5]).buffer, - }; - const model = loadGraphModelSync(modelArtifacts); - checkModel(model); - }); - - it('Pass the model JSON and weights', () => { - const modelJson: tfc.io.ModelJSON = { - modelTopology: SIMPLE_MODEL, - weightsManifest: [{paths: [], weights: weightsManifest}], - }; - const weights = new Int32Array([5]).buffer; - const model = loadGraphModelSync([modelJson, weights]); - checkModel(model); - }); - - it('Throws an error if ModelJSON is passed without weights', () => { - const modelJson: tfc.io.ModelJSON = { - modelTopology: SIMPLE_MODEL, - weightsManifest: [{paths: [], weights: weightsManifest}], - }; - expect(() => { - return loadGraphModelSync( - [modelJson] as unknown as [io.ModelJSON, ArrayBuffer]); - }) - .toThrowMatching( - err => err.message.includes('weights must be the second element')); - }); - - it('Throws an error if modelJSON is missing \'modelTopology\'', () => { - const badInput = { - weightsManifest: [{paths: [] as string[], weights: weightsManifest}], - }; - const weights = new Int32Array([5]).buffer; - expect(() => { - return loadGraphModelSync([badInput as io.ModelJSON, weights]); - }) - .toThrowMatching( - err => err.message.includes('missing \'modelTopology\'')); - }); - - it('Throws an error if modelJSON is missing \'weightsManifest\'', () => { - const badInput = { - modelTopology: SIMPLE_MODEL, - }; - const weights = new Int32Array([5]).buffer; - expect(() => { - return loadGraphModelSync([badInput as io.ModelJSON, weights]); - }) - .toThrowMatching( - err => err.message.includes('missing \'weightsManifest\'')); - }); - - it('Throws an error if modelSource is an unknown format', () => { - const badInput = {foo: 'bar'}; - expect(() => { - return loadGraphModelSync(badInput as io.ModelArtifacts); - }).toThrowMatching(err => err.message.includes('Unknown model format')); - }); - - it('Expect an error when moderUrl is null', () => { - let errorMsg = 'no error'; - try { - loadGraphModelSync(null); - } catch (err) { - errorMsg = err.message; - } - expect(errorMsg).toMatch( - /modelUrl in loadGraphModelSync\(\) cannot be null/); - }); -}); - -describe('Model', () => { - let spyIo: RecursiveSpy; - - beforeEach(() => { - spyIo = spyOnAllFunctions(io); - model = new GraphModel(MODEL_URL, undefined, spyIo); - }); - - describe('custom model', () => { - beforeEach(() => { - spyIo.getLoadHandlers.and.returnValue([CUSTOM_HTTP_MODEL_LOADER]); - registerOp('CustomOp', (nodeValue: GraphNode) => { - const x = nodeValue.inputs[0]; - return [tfc.add(x, scalar(1, 'int32'))]; - }); - }); - afterEach(() => deregisterOp('CustomOp')); - it('load', async () => { - const loaded = await model.load(); - expect(loaded).toBe(true); - }); - - describe('predict', () => { - it('should generate the output for single tensor', async () => { - await model.load(); - const input = tfc.tensor2d([1, 1], [2, 1], 'int32'); - const output = model.predict(input); - expect((output as tfc.Tensor).dataSync()[0]).toEqual(3); - }); - }); - - describe('save', () => { - it('should call the save io handler', async () => { - await model.load(); - const handler = new IOHandlerForTest(); - - await model.save(handler); - expect(handler.savedArtifacts.format).toEqual('tfjs-graph-model'); - expect(handler.savedArtifacts.generatedBy).toEqual('1.15'); - expect(handler.savedArtifacts.convertedBy).toEqual('1.3.1'); - expect(handler.savedArtifacts.modelTopology).toEqual(CUSTOM_OP_MODEL); - expect(handler.savedArtifacts.weightSpecs).toEqual(weightsManifest); - tfc.test_util.expectArraysClose( - new Int32Array(io.CompositeArrayBuffer.join( - handler.savedArtifacts.weightData)), bias.dataSync()); - }); - }); - }); - - describe('simple model', () => { - beforeEach(() => { - spyIo.getLoadHandlers.and.returnValue([SIMPLE_HTTP_MODEL_LOADER]); - spyIo.browserHTTPRequest.and.returnValue(SIMPLE_HTTP_MODEL_LOADER); - }); - it('load', async () => { - const loaded = await model.load(); - expect(loaded).toBe(true); - }); - - describe('save', () => { - it('should call the save io handler', async () => { - await model.load(); - const handler = new IOHandlerForTest(); - - await model.save(handler); - expect(handler.savedArtifacts.format).toEqual('tfjs-graph-model'); - expect(handler.savedArtifacts.generatedBy).toEqual('1.15'); - expect(handler.savedArtifacts.convertedBy).toEqual('1.3.1'); - expect(handler.savedArtifacts.modelTopology).toEqual(SIMPLE_MODEL); - expect(handler.savedArtifacts.userDefinedMetadata).toEqual({ - signature: SIGNATURE - }); - expect(handler.savedArtifacts.weightSpecs).toEqual(weightsManifest); - tfc.test_util.expectArraysClose( - new Int32Array(io.CompositeArrayBuffer.join( - handler.savedArtifacts.weightData)), bias.dataSync()); - }); - }); - - describe('predict', () => { - it('should generate the output for single tensor', async () => { - await model.load(); - const input = tfc.tensor2d([1, 1], [2, 1], 'int32'); - const output = model.predict(input); - expect((output as tfc.Tensor).dataSync()[0]).toEqual(3); - }); - - it('should support signature keys', async () => { - await model.load(); - const input = tfc.tensor2d([1, 1], [2, 1], 'int32'); - const output = model.predict({x: input}); - expect((output as tfc.Tensor).dataSync()[0]).toEqual(3); - }); - - it('should generate the output for tensor array', async () => { - await model.load(); - const input = tfc.tensor2d([1, 1], [2, 1], 'int32'); - const output = model.predict([input]); - expect((output as tfc.Tensor).dataSync()[0]).toEqual(3); - }); - - it('should generate the output for tensor map', async () => { - await model.load(); - const input = tfc.tensor2d([1, 1], [2, 1], 'int32'); - const output = model.predict({'Input': input}); - expect((output as tfc.Tensor).dataSync()[0]).toEqual(3); - }); - - it('should throw error if wrong signature key is used', async () => { - await model.load(); - const input = tfc.tensor1d([1], 'int32'); - expect(() => model.predict({x1: input})).toThrow(); - }); - - it('should throw error if input size mismatch', async () => { - await model.load(); - const input = tfc.tensor1d([1], 'int32'); - expect(() => model.predict([input, input])).toThrow(); - }); - - it('should throw exception if inputs shapes do not match', () => { - const input = tfc.tensor2d([1, 1], [1, 2], 'int32'); - expect(() => model.predict([input])).toThrow(); - }); - - it('should throw exception if inputs dtype does not match graph', () => { - const input = tfc.tensor1d([1], 'float32'); - expect(() => model.predict([input])).toThrow(); - }); - }); - - describe('execute', () => { - it('should generate the default output', async () => { - await model.load(); - const input = tfc.tensor2d([1, 1], [2, 1], 'int32'); - const output = model.execute({'Input': input}); - expect((output as tfc.Tensor).dataSync()[0]).toEqual(3); - }); - it('should allow signature keys', async () => { - await model.load(); - const input = tfc.tensor2d([1, 1], [2, 1], 'int32'); - const output = model.execute({x: input}, ['y']); - expect((output as tfc.Tensor).dataSync()[0]).toEqual(3); - }); - it('should generate the output array', async () => { - await model.load(); - const input = tfc.tensor2d([1, 1], [2, 1], 'int32'); - const output = model.execute({'Input': input}, ['Add', 'Const']); - expect(Array.isArray(output)).toBeTruthy(); - expect((output as tfc.Tensor[])[0].dataSync()[0]).toEqual(3); - expect((output as tfc.Tensor[])[1].dataSync()[0]).toEqual(1); - }); - it('should throw exception if inputs shapes do not match', () => { - const input = tfc.tensor2d([1, 1], [1, 2], 'int32'); - expect(() => model.execute([input])).toThrow(); - }); - - it('should throw exception if inputs dtype does not match graph', () => { - const input = tfc.tensor2d([1, 1], [2, 1], 'float32'); - expect(() => model.predict([input])).toThrow(); - }); - - it('should throw error if input size mismatch', async () => { - await model.load(); - const input = tfc.tensor2d([1, 1], [2, 1], 'int32'); - - expect(() => model.execute([input, input])).toThrow(); - }); - - it('should allow feed intermediate node', async () => { - await model.load(); - const input = tfc.tensor2d([1, 1], [2, 1], 'int32'); - const output = model.execute({'Add1': input}) as tfc.Tensor; - tfc.test_util.expectArraysClose(await output.data(), [2, 2]); - }); - it('should allow feed intermediate node with index', async () => { - await model.load(); - const input = tfc.tensor2d([1, 1], [2, 1], 'int32'); - const output = model.execute({'Add1:0': input}) as tfc.Tensor; - tfc.test_util.expectArraysClose(await output.data(), [2, 2]); - }); - }); - - describe('dispose', () => { - it('should dispose the weights', async () => { - const numOfTensors = tfc.memory().numTensors; - model = new GraphModel(MODEL_URL, undefined, spyIo); - - await model.load(); - model.dispose(); - - expect(tfc.memory().numTensors).toEqual(numOfTensors); - }); - }); - - describe('getVersion', () => { - it('should return the version info from the tf model', async () => { - await model.load(); - expect(model.modelVersion).toEqual('1.3'); - }); - }); - - describe('relative path', () => { - beforeEach(() => { - model = new GraphModel(RELATIVE_MODEL_URL, undefined, spyIo); - }); - - it('load', async () => { - const loaded = await model.load(); - expect(loaded).toBe(true); - }); - }); - - it('should loadGraphModel', async () => { - const model = await loadGraphModel(MODEL_URL, undefined, spyIo); - expect(model).not.toBeUndefined(); - }); - - it('should loadGraphModel with request options', async () => { - const model = await loadGraphModel( - MODEL_URL, {requestInit: {credentials: 'include'}}, spyIo); - expect(spyIo.browserHTTPRequest).toHaveBeenCalledWith(MODEL_URL, { - requestInit: {credentials: 'include'} - }); - expect(model).not.toBeUndefined(); - }); - - it('should call loadGraphModel for TfHub Module', async () => { - const url = `${HOST}/model/1`; - const model = await loadGraphModel(url, {fromTFHub: true}, spyIo); - expect(model).toBeDefined(); - }); - - describe('InferenceModel interface', () => { - it('should expose inputs', async () => { - await model.load(); - expect(model.inputs).toEqual([ - {name: 'Input', shape: [-1, 1], dtype: 'int32'} - ]); - }); - it('should expose outputs', async () => { - await model.load(); - expect(model.outputs).toEqual([ - {name: 'Add', shape: undefined, dtype: undefined} - ]); - }); - }); - }); - - describe('no signature input model', () => { - beforeEach(() => { - spyIo.getLoadHandlers.and.returnValue([NO_INPUT_SIGNATURE_MODEL_LOADER]); - spyIo.browserHTTPRequest.and.returnValue(NO_INPUT_SIGNATURE_MODEL_LOADER); - }); - - it('load', async () => { - const loaded = await model.load(); - expect(loaded).toBe(true); - }); - - describe('predict', () => { - it('should generate default output', async () => { - await model.load(); - const input = tfc.tensor2d([1, 1], [2, 1], 'int32'); - const output = model.execute({'Input': input}); - expect((output as tfc.Tensor).dataSync()[0]).toEqual(3); - }); - }); - - describe('execute', () => { - it('should generate default output', async () => { - await model.load(); - const input = tfc.tensor2d([1, 1], [2, 1], 'int32'); - const output = model.execute(input); - expect((output as tfc.Tensor).dataSync()[0]).toEqual(3); - }); - }); - }); - - describe('structured outputs model', () => { - beforeEach(() => { - spyIo.getLoadHandlers.and.returnValue([STRUCTURED_OUTPUTS_MODEL_LOADER]); - spyIo.browserHTTPRequest.and.returnValue(STRUCTURED_OUTPUTS_MODEL_LOADER); - }); - it('load', async () => { - const loaded = await model.load(); - expect(loaded).toBe(true); - }); - - describe('save', () => { - it('should call the save io handler', async () => { - await model.load(); - const handler = new IOHandlerForTest(); - - await model.save(handler); - expect(handler.savedArtifacts.format) - .toEqual(STRUCTURED_OUTPUTS_MODEL.format); - expect(handler.savedArtifacts.generatedBy) - .toEqual(STRUCTURED_OUTPUTS_MODEL.generatedBy); - expect(handler.savedArtifacts.convertedBy) - .toEqual(STRUCTURED_OUTPUTS_MODEL.convertedBy); - expect(handler.savedArtifacts.modelTopology) - .toEqual(STRUCTURED_OUTPUTS_MODEL.modelTopology); - expect(handler.savedArtifacts.userDefinedMetadata) - .toEqual(STRUCTURED_OUTPUTS_MODEL.userDefinedMetadata); - }); - }); - - describe('predict', () => { - it('should support structured outputs', async () => { - await model.load(); - - const input = tfc.tensor2d([[1]]); - const output = - model.predict({input1: input, input2: input, input3: input}) as - tfc.NamedTensorMap; - expect(Object.keys(output)).toEqual(['a', 'b', 'c']); - }); - }); - - describe('execute', () => { - it('should generate the list output', async () => { - await model.load(); - const input = tfc.tensor2d([[1]]); - const output = - model.execute({input1: input, input2: input, input3: input}); - expect(Array.isArray(output)).toBeTruthy(); - }); - }); - - describe('dispose', () => { - it('should dispose the weights', async () => { - const numOfTensors = tfc.memory().numTensors; - await model.load(); - model.dispose(); - - expect(tfc.memory().numTensors).toEqual(numOfTensors); - }); - }); - }); - - describe('control flow model', () => { - beforeEach(() => { - spyIo.getLoadHandlers.and.returnValue([CONTROL_FLOW_HTTP_MODEL_LOADER]); - spyIo.browserHTTPRequest.and.returnValue(CONTROL_FLOW_HTTP_MODEL_LOADER); - }); - - describe('save', () => { - it('should call the save io handler', async () => { - await model.load(); - const handler = new IOHandlerForTest(); - - await model.save(handler); - expect(handler.savedArtifacts.format).toEqual('tfjs-graph-model'); - expect(handler.savedArtifacts.generatedBy).toEqual('1.15'); - expect(handler.savedArtifacts.convertedBy).toEqual('1.3.1'); - expect(handler.savedArtifacts.modelTopology) - .toEqual(CONTROL_FLOW_MODEL); - expect(handler.savedArtifacts.userDefinedMetadata).toEqual({ - signature: CONTROL_SIGNATURE - }); - expect(handler.savedArtifacts.weightSpecs).toEqual(weightsManifest); - tfc.test_util.expectArraysClose( - new Int32Array(io.CompositeArrayBuffer.join(handler.savedArtifacts - .weightData)), bias.dataSync()); - }); - }); - - it('should throw error if call predict directly', async () => { - await model.load(); - const input = tfc.tensor2d([1, 1], [2, 1], 'int32'); - - expect(() => model.predict([input])).toThrow(); - }); - - it('should throw error if call execute directly', async () => { - await model.load(); - const input = tfc.tensor2d([1, 1], [2, 1], 'int32'); - - expect(() => model.predict([input])).toThrow(); - }); - - it('should be success if call executeAsync', async () => { - await model.load(); - const input = tfc.tensor2d([1, 1], [2, 1], 'int32'); - const res = await model.executeAsync([input]); - expect(res).not.toBeNull(); - }); - - it('should be success if call executeAsync with signature keys', - async () => { - await model.load(); - const input = tfc.tensor2d([1, 1], [2, 1], 'int32'); - const res = await model.executeAsync({x: input}, ['y']); - expect(res).not.toBeNull(); - }); - - it('should allow feed intermediate node with executeAsync', async () => { - await model.load(); - const input = tfc.tensor2d([1, 1], [2, 1], 'int32'); - const res = await model.executeAsync({Enter: input}); - expect(res).not.toBeNull(); - }); - }); - const DYNAMIC_SIGNATURE: tensorflow.ISignatureDef = { - inputs: {x: {name: 'Input:0', dtype: tensorflow.DataType.DT_INT32}}, - outputs: {y: {name: 'Where:0', dtype: tensorflow.DataType.DT_INT32}} - }; - const DYNAMIC_HTTP_MODEL_LOADER = { - load: async () => { - return { - modelTopology: DYNAMIC_SHAPE_MODEL, - weightSpecs: weightsManifest, - weightData: bias.dataSync(), - userDefinedMetadata: {signature: DYNAMIC_SIGNATURE} - }; - } - }; - const DYNAMIC_HTTP_MODEL_NEW_LOADER = { - load: async () => { - return { - convertedBy: '2.8', - modelTopology: DYNAMIC_SHAPE_MODEL, - weightSpecs: weightsManifest, - weightData: bias.dataSync(), - signature: DYNAMIC_SIGNATURE, - userDefinedMetadata: {metadata1: {a: '1'}} - }; - } - }; - describe('dynamic shape model', () => { - beforeEach(() => { - spyIo.getLoadHandlers.and.returnValue([DYNAMIC_HTTP_MODEL_LOADER]); - spyIo.browserHTTPRequest.and.returnValue(DYNAMIC_HTTP_MODEL_LOADER); - }); - - it('should throw error if call predict directly', async () => { - await model.load(); - const input = tfc.tensor2d([1, 1], [2, 1], 'int32'); - - expect(() => model.predict([input])).toThrow(); - }); - - it('should throw error if call execute directly', async () => { - await model.load(); - const input = tfc.tensor2d([1, 1], [2, 1], 'int32'); - - expect(() => model.execute([input])).toThrow(); - }); - - it('should be success if call executeAsync', async () => { - await model.load(); - const input = tfc.tensor2d([1, 1], [2, 1], 'bool'); - const res = await model.executeAsync([input]); - expect(res).not.toBeNull(); - }); - - it('should be success if call executeAsync with signature key', - async () => { - await model.load(); - const input = tfc.tensor2d([1, 1], [2, 1], 'bool'); - const res = await model.executeAsync({x: input}, ['y']); - expect(res).not.toBeNull(); - }); - - it('should allow feed intermediate node with executeAsync', async () => { - await model.load(); - const input = tfc.tensor2d([1, 1], [2, 1], 'int32'); - const res = await model.executeAsync({Where: input}); - expect(res).not.toBeNull(); - }); - }); - describe('dynamic shape model with metadata', () => { - beforeEach(() => { - spyIo.getLoadHandlers.and.returnValue([DYNAMIC_HTTP_MODEL_NEW_LOADER]); - spyIo.browserHTTPRequest.and.returnValue(DYNAMIC_HTTP_MODEL_NEW_LOADER); - }); - - it('should be success if call executeAsync with signature key', - async () => { - await model.load(); - const input = tfc.tensor2d([1, 1], [2, 1], 'bool'); - const res = await model.executeAsync({x: input}, ['y']); - expect(res).not.toBeNull(); - expect(model.metadata).toEqual({metadata1: {a: '1'}}); - }); - - it('should allow feed intermediate node with executeAsync', async () => { - await model.load(); - const input = tfc.tensor2d([1, 1], [2, 1], 'int32'); - const res = await model.executeAsync({Where: input}); - expect(res).not.toBeNull(); - }); - }); - - describe('Hashtable V1 model', () => { - beforeEach(() => { - spyIo.getLoadHandlers.and.returnValue([HASHTABLE_V1_HTTP_MODEL_LOADER]); - spyIo.browserHTTPRequest.and.returnValue(HASHTABLE_V1_HTTP_MODEL_LOADER); - }); - it('should be successful if call executeAsync', async () => { - await model.load(); - const keys = tfc.tensor1d(['a'], 'string'); - const defaultValues = tfc.tensor1d([0]); - const res = await model.executeAsync({keys, defaultValues}); - expect(res).not.toBeNull(); - }); - }); - - describe('Hashtable V2 model', () => { - beforeEach(() => { - spyIo.getLoadHandlers.and.returnValue([HASHTABLE_V2_MODEL_LOADER]); - spyIo.browserHTTPRequest.and.returnValue(HASHTABLE_V2_MODEL_LOADER); - }); - it('load', async () => { - const loaded = await model.load(); - expect(loaded).toBe(true); - }); - - describe('execute', () => { - it('should be successful if call executeAsync', async () => { - await model.load(); - const res = await model.executeAsync( - {'input': tfc.tensor1d(['a', 'b', 'c'])}) as Tensor; - expect(Array.from(res.dataSync())).toEqual([0, 1, -1]); - }); - }); - - describe('dispose', () => { - it('should dispose the weights', async () => { - const startTensors = tfc.memory().numTensors; - - await model.load(); - - const input = tfc.tensor1d(['a', 'b', 'c']); - const output = await model.executeAsync({input}) as Tensor; - input.dispose(); - output.dispose(); - - model.dispose(); - - expect(tfc.memory().numTensors).toEqual(startTensors); - }); - }); - }); -}); - -describe('Graph execution gives actionable errors', () => { - it('executeAsync warns when there are no dynamic ops', async () => { - const customLoader: tfc.io.IOHandler = { - load: async () => ({ - modelTopology: SIMPLE_MODEL, - weightSpecs: weightsManifest, - weightData: new Int32Array([5]).buffer, - }) - }; - const model = await loadGraphModel(customLoader); - spyOn(console, 'warn'); - const input = tfc.tensor2d([1, 1], [2, 1], 'int32'); - await model.executeAsync(input); - expect(console.warn).toHaveBeenCalledTimes(1); - expect(console.warn) - .toHaveBeenCalledWith( - 'This model execution did not contain any nodes with control ' + - 'flow or dynamic output shapes. You can use model.execute() ' + - 'instead.'); - }); - - it('executeAsync does not warn when there are dynamic ops', async () => { - const customLoader: tfc.io.IOHandler = { - load: async () => ({ - modelTopology: CONTROL_FLOW_MODEL, - weightSpecs: weightsManifest, - weightData: new Int32Array([5]).buffer, - }) - }; - const model = await loadGraphModel(customLoader); - spyOn(console, 'warn'); - const input = tfc.tensor2d([1, 1], [2, 1], 'int32'); - await model.executeAsync(input); - expect(console.warn).toHaveBeenCalledTimes(0); - }); - - it('executeAsync warns when the subgraph has no dynamic ops', async () => { - const graphDef: tensorflow.IGraphDef = { - node: [ - {name: 'input', op: 'Placeholder'}, - {name: 'intermediate', op: 'Enter', input: ['input']}, - {name: 'intermediate2', op: 'Sqrt', input: ['intermediate']}, - {name: 'output', op: 'Square', input: ['intermediate2']}, - ], - versions: {producer: 1.0, minConsumer: 3} - }; - const customLoader: tfc.io.IOHandler = { - load: async () => ({ - modelTopology: graphDef, - weightSpecs: weightsManifest, - weightData: new Int32Array([5]).buffer, - }) - }; - const model = await loadGraphModel(customLoader); - spyOn(console, 'warn'); - const input = tfc.tensor2d([1, 1], [2, 1], 'int32'); - await model.executeAsync({'intermediate2': input}); - expect(console.warn).toHaveBeenCalledTimes(1); - expect(console.warn) - .toHaveBeenCalledWith( - 'This model execution did not contain any nodes with control ' + - 'flow or dynamic output shapes. You can use model.execute() ' + - 'instead.'); - }); - - it('executeAsync works when the subgraph has no unknown ops', async () => { - const graphDef: tensorflow.IGraphDef = { - node: [ - {name: 'input', op: 'Placeholder'}, - {name: 'intermediate', op: 'Unknown', input: ['input']}, - {name: 'intermediate2', op: 'Sqrt', input: ['intermediate']}, - {name: 'output', op: 'Square', input: ['intermediate2']}, - ], - versions: {producer: 1.0, minConsumer: 3} - }; - const customLoader: tfc.io.IOHandler = { - load: async () => ({ - modelTopology: graphDef, - weightSpecs: weightsManifest, - weightData: new Int32Array([5]).buffer, - }) - }; - const model = await loadGraphModel(customLoader); - spyOn(console, 'warn'); - const input = tfc.tensor2d([1, 1], [2, 1], 'int32'); - await model.executeAsync({'intermediate2': input}); - }); - - it('executeAsync throws when the subgraph has unknown ops', async () => { - const graphDef: tensorflow.IGraphDef = { - node: [ - {name: 'input', op: 'Placeholder'}, - {name: 'intermediate', op: 'Unknown', input: ['input']}, - {name: 'intermediate2', op: 'Sqrt', input: ['intermediate']}, - {name: 'output', op: 'Square', input: ['intermediate2']}, - ], - versions: {producer: 1.0, minConsumer: 3} - }; - const customLoader: tfc.io.IOHandler = { - load: async () => ({ - modelTopology: graphDef, - weightSpecs: weightsManifest, - weightData: new Int32Array([5]).buffer, - }) - }; - const model = await loadGraphModel(customLoader); - const input = tfc.tensor2d([1, 1], [2, 1], 'int32'); - try { - await model.executeAsync({'input': input}); - throw new Error('Previous line should throw'); - } catch (ex) { - expect((ex as Error).message) - .toBe( - 'Unknown op \'Unknown\'. File an issue at ' + - 'https://github.com/tensorflow/tfjs/issues so we can add it, ' + - 'or register a custom execution with tf.registerOp()'); - } - }); - - it('execute fails when there are dynamic ops', async () => { - const customLoader: tfc.io.IOHandler = { - load: async () => ({ - modelTopology: CONTROL_FLOW_MODEL, - weightSpecs: weightsManifest, - weightData: new Int32Array([5]).buffer, - }) - }; - const model = await loadGraphModel(customLoader); - const input = tfc.tensor2d([1, 1], [2, 1], 'int32'); - expect(() => model.execute(input)) - .toThrowError(/This execution contains the node 'Enter'/); - }); - - it('execute does not warn when there are no dynamic ops', async () => { - const customLoader: tfc.io.IOHandler = { - load: async () => ({ - modelTopology: SIMPLE_MODEL, - weightSpecs: weightsManifest, - weightData: new Int32Array([5]).buffer, - }) - }; - const model = await loadGraphModel(customLoader); - spyOn(console, 'warn'); - const input = tfc.tensor2d([1, 1], [2, 1], 'int32'); - model.execute(input); - expect(console.warn).toHaveBeenCalledTimes(0); - }); - - it('execute err when there are no dynamic ops', async () => { - const customLoader: tfc.io.IOHandler = { - load: async () => ({ - modelTopology: SIMPLE_MODEL, - weightSpecs: weightsManifest, - weightData: new Int32Array([5]).buffer, - }) - }; - const model = await loadGraphModel(customLoader); - spyOn(console, 'warn'); - const input = tfc.tensor2d([1, 1], [2, 1], 'int32'); - model.execute(input); - expect(console.warn).toHaveBeenCalledTimes(0); - }); -}); diff --git a/tfjs-master/tfjs-converter/src/executor/hash_table.ts b/tfjs-master/tfjs-converter/src/executor/hash_table.ts deleted file mode 100644 index 9552349fe..000000000 --- a/tfjs-master/tfjs-converter/src/executor/hash_table.ts +++ /dev/null @@ -1,165 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {DataType, keep, scalar, stack, Tensor, tidy, unstack, util} from '@tensorflow/tfjs-core'; -// tslint:disable-next-line: no-imports-from-dist -import * as tfOps from '@tensorflow/tfjs-core/dist/ops/ops_for_converter'; - -/** - * Hashtable contains a set of tensors, which can be accessed by key. - */ -export class HashTable { - readonly handle: Tensor; - - // tslint:disable-next-line: no-any - private tensorMap: Map; - - get id() { - return this.handle.id; - } - - /** - * Constructor of HashTable. Creates a hash table. - * - * @param keyDType `dtype` of the table keys. - * @param valueDType `dtype` of the table values. - */ - constructor(readonly keyDType: DataType, readonly valueDType: DataType) { - this.handle = scalar(0); - // tslint:disable-next-line: no-any - this.tensorMap = new Map(); - - keep(this.handle); - } - - /** - * Dispose the tensors and handle and clear the hashtable. - */ - clearAndClose() { - this.tensorMap.forEach(value => value.dispose()); - this.tensorMap.clear(); - this.handle.dispose(); - } - - /** - * The number of items in the hash table. - */ - size(): number { - return this.tensorMap.size; - } - - /** - * The number of items in the hash table as a rank-0 tensor. - */ - tensorSize(): Tensor { - return tfOps.scalar(this.size(), 'int32'); - } - - /** - * Replaces the contents of the table with the specified keys and values. - * @param keys Keys to store in the hashtable. - * @param values Values to store in the hashtable. - */ - async import(keys: Tensor, values: Tensor): Promise { - this.checkKeyAndValueTensor(keys, values); - - // We only store the primitive values of the keys, this allows lookup - // to be O(1). - const $keys = await keys.data(); - - // Clear the hashTable before inserting new values. - this.tensorMap.forEach(value => value.dispose()); - this.tensorMap.clear(); - - return tidy(() => { - const $values = unstack(values); - - const keysLength = $keys.length; - const valuesLength = $values.length; - - util.assert( - keysLength === valuesLength, - () => `The number of elements doesn't match, keys has ` + - `${keysLength} elements, the values has ${valuesLength} ` + - `elements.`); - - for (let i = 0; i < keysLength; i++) { - const key = $keys[i]; - const value = $values[i]; - - keep(value); - this.tensorMap.set(key, value); - } - - return this.handle; - }); - } - - /** - * Looks up keys in a hash table, outputs the corresponding values. - * - * Performs batch lookups, for every element in the key tensor, `find` - * stacks the corresponding value into the return tensor. - * - * If an element is not present in the table, the given `defaultValue` is - * used. - * - * @param keys Keys to look up. Must have the same type as the keys of the - * table. - * @param defaultValue The scalar `defaultValue` is the value output for keys - * not present in the table. It must also be of the same type as the - * table values. - */ - async find(keys: Tensor, defaultValue: Tensor): Promise { - this.checkKeyAndValueTensor(keys, defaultValue); - - const $keys = await keys.data(); - - return tidy(() => { - const result: Tensor[] = []; - - for (let i = 0; i < $keys.length; i++) { - const key = $keys[i]; - - const value = this.findWithDefault(key, defaultValue); - result.push(value); - } - - return stack(result); - }); - } - - // tslint:disable-next-line: no-any - private findWithDefault(key: any, defaultValue: Tensor): Tensor { - const result = this.tensorMap.get(key); - - return result != null ? result : defaultValue; - } - - private checkKeyAndValueTensor(key: Tensor, value: Tensor) { - if (key.dtype !== this.keyDType) { - throw new Error( - `Expect key dtype ${this.keyDType}, but got ` + - `${key.dtype}`); - } - - if (value.dtype !== this.valueDType) { - throw new Error( - `Expect value dtype ${this.valueDType}, but got ` + - `${value.dtype}`); - } - } -} diff --git a/tfjs-master/tfjs-converter/src/executor/model_analysis.ts b/tfjs-master/tfjs-converter/src/executor/model_analysis.ts deleted file mode 100644 index 450e73071..000000000 --- a/tfjs-master/tfjs-converter/src/executor/model_analysis.ts +++ /dev/null @@ -1,347 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {NamedTensorMap} from '@tensorflow/tfjs-core'; - -import {NamedTensorsMap} from '../data/types'; -import {parseNodeName} from '../operations/executors/utils'; -import {Graph, Node} from '../operations/types'; - -export interface ExecutionInfo { - inputs: NamedTensorMap; - outputs: Node[]; - usedNodes: Set; - missingInputs: string[]; - dynamicNode: Node; - syncInputs: string[]; -} - -/** - * Given graph inputs and desired outputs, find the minimal set of nodes - * to execute in order to compute the outputs. In addition return other useful - * info such: - * - Missing inputs needed to compute the output. - * - Whether the subgraph contains dynamic ops (control flow, dynamic shape). - * - Alternative inputs in order to avoid async (dynamic op) execution. - */ -export function getExecutionSubgraph( - inputs: NamedTensorMap, outputs: Node[], weightMap: NamedTensorsMap, - initNodes?: Node[]): ExecutionInfo { - const usedNodes = new Set(); - const missingInputs: string[] = []; - let dynamicNode: Node = null; - let syncInputs: string[] = null; - - // Start with the outputs, going backwards and find all the nodes that are - // needed to compute those outputs. - const seen = new Set(); - const inputNodeNames = - new Set(Object.keys(inputs).map((name) => parseNodeName(name)[0])); - - initNodes = initNodes || []; - const initNodeNames = - new Set(initNodes.map((node) => parseNodeName(node.name)[0])); - - const frontier = [...outputs]; - while (frontier.length > 0) { - const node = frontier.pop(); - if (isControlFlow(node) || isDynamicShape(node) || isHashTable(node)) { - if (dynamicNode == null) { - dynamicNode = node; - syncInputs = dynamicNode.children.map(child => child.name) - .filter(name => usedNodes.has(name)); - } - } - usedNodes.add(node.name); - - // Weights are dead end since we already have their values. - if (weightMap[node.name] != null) { - continue; - } - // This node is a dead end since it's one of the user-provided inputs. - if (inputNodeNames.has(node.name)) { - continue; - } - // This node is a dead end since it doesn't have any inputs. - if (initNodeNames.has(node.name)) { - continue; - } - if (node.inputs.length === 0) { - missingInputs.push(node.name); - continue; - } - node.inputs.forEach(input => { - // Don't add to the frontier if it is already there. - if (seen.has(input.name)) { - return; - } - seen.add(input.name); - frontier.push(input); - }); - } - return {inputs, outputs, usedNodes, missingInputs, dynamicNode, syncInputs}; -} - -/** - * Given the execution info, return a list of nodes in topological order that - * need to be executed to compute the output. - */ -export function getNodesInTopologicalOrder( - graph: Graph, executionInfo: ExecutionInfo): Node[] { - const {usedNodes, inputs} = executionInfo; - const inputNodes = Object.keys(inputs) - .map(name => parseNodeName(name)[0]) - .map(name => graph.nodes[name]); - const initNodes = graph.initNodes || []; - - const isUsed = (node: Node|string) => - usedNodes.has(typeof node === 'string' ? node : node.name); - - function unique(nodes: Node[]): Node[] { - return [...new Map(nodes.map((node) => [node.name, node])).values()]; - } - const predefinedNodes = unique([ - ...inputNodes, - ...graph.weights, - ...initNodes, - ]).filter(isUsed); - const allNodes = unique([ - ...predefinedNodes, - ...Object.values(graph.nodes), - ]).filter(isUsed); - const nameToNode = - new Map(allNodes.map((node) => [node.name, node])); - - const inCounts: Record = {}; - for (const node of allNodes) { - inCounts[node.name] = inCounts[node.name] || 0; - for (const child of node.children) { - // When the child is unused, set in counts to infinity so that it will - // never be decreased to 0 and added to the execution list. - if (!isUsed(child)) { - inCounts[child.name] = Number.POSITIVE_INFINITY; - } - inCounts[child.name] = (inCounts[child.name] || 0) + 1; - } - } - - // Build execution order for all used nodes regardless whether they are - // predefined or not. - const frontier = Object.entries(inCounts) - .filter(([, inCount]) => inCount === 0) - .map(([name]) => name); - const orderedNodeNames = [...frontier]; - while (frontier.length > 0) { - const nodeName = frontier.pop(); - const node = nameToNode.get(nodeName)!; - for (const child of node.children.filter(isUsed)) { - if (--inCounts[child.name] === 0) { - orderedNodeNames.push(child.name); - frontier.push(child.name); - } - } - } - - const orderedNodes = orderedNodeNames.map((name) => nameToNode.get(name)); - const filteredOrderedNodes = - filterPredefinedReachableNodes(orderedNodes, predefinedNodes); - - // TODO: Turn validation on/off with tf env flag. - validateNodesExecutionOrder(filteredOrderedNodes, predefinedNodes); - - return filteredOrderedNodes; -} - -/** - * This is a helper function of `getNodesInTopologicalOrder`. - * Returns ordered nodes reachable by at least one predefined node. - * This can help us filter out redundant nodes from the returned node list. - * For example: - * If we have four nodes with dependencies like this: - * a --> b --> c --> d - * when node `c` is predefined (e.g. given as an input tensor), we can - * skip node `a` and `b` since their outputs will never be used. - * - * @param orderedNodes Graph nodes in execution order. - * @param predefinedNodes Graph inputs, weights, and init nodes. Nodes in this - * list must have distinct names. - */ -function filterPredefinedReachableNodes( - orderedNodes: Node[], predefinedNodes: Node[]) { - const nameToNode = - new Map(orderedNodes.map((node) => [node.name, node])); - - // TODO: Filter out more nodes when >=2 nodes are predefined in a path. - const stack = predefinedNodes.map((node) => node.name); - const predefinedReachableNodeNames = new Set(stack); - // Perform a DFS starting from the set of all predefined nodes - // to find the set of all nodes reachable from the predefined nodes. - while (stack.length > 0) { - const nodeName = stack.pop(); - const node = nameToNode.get(nodeName)!; - for (const child of node.children) { - if (!nameToNode.has(child.name) || - predefinedReachableNodeNames.has(child.name)) { - continue; - } - predefinedReachableNodeNames.add(child.name); - stack.push(child.name); - } - } - - // Filter out unreachable nodes and build the ordered node list. - const filteredOrderedNodes = orderedNodes.filter( - (node) => predefinedReachableNodeNames.has(node.name)); - - return filteredOrderedNodes; -} - -class NodesExecutionOrderError extends Error { - constructor(message: string) { - super(`NodesExecutionOrderError: ${message}`); - } -} - -/** - * This is a helper function of `getNodesInTopologicalOrder`. - * Validates property: given nodes `a` and `b`, Order(a) > Order(b) if `a` - * is a child of `b`. This function throws an error if validation fails. - * - * @param orderedNodes Graph nodes in execution order. - * @param predefinedNodes Graph inputs, weights, and init nodes. Nodes in this - * list must have distinct names. - */ -function validateNodesExecutionOrder( - orderedNodes: Node[], predefinedNodes: Node[]) { - const nodeNameToOrder = new Map( - orderedNodes.map((node, order) => [node.name, order])); - const predefinedNodeNames = new Set(predefinedNodes.map((node) => node.name)); - const isPredefined = (node: Node|string) => - predefinedNodeNames.has(typeof node === 'string' ? node : node.name); - const willBeExecutedNodeNames = - new Set(orderedNodes.map((node) => node.name)); - const willBeExecuted = (node: Node|string) => - willBeExecutedNodeNames.has(typeof node === 'string' ? node : node.name); - - for (const node of orderedNodes) { - for (const child of node.children.filter(willBeExecuted)) { - if (!nodeNameToOrder.has(child.name)) { - throw new NodesExecutionOrderError( - `Child ${child.name} of node ${node.name} is unreachable.`); - } - if (nodeNameToOrder.get(node.name) > nodeNameToOrder.get(child.name)) { - throw new NodesExecutionOrderError(`Node ${ - node.name} is scheduled to run after its child ${child.name}.`); - } - } - if (!isPredefined(node)) { - for (const input of node.inputs) { - if (!nodeNameToOrder.has(input.name)) { - throw new NodesExecutionOrderError( - `Input ${input.name} of node ${node.name} is unreachable.`); - } - if (nodeNameToOrder.get(input.name) > nodeNameToOrder.get(node.name)) { - throw new NodesExecutionOrderError(`Node ${ - node.name} is scheduled to run before its input ${input.name}.`); - } - } - } - } -} - -/** - * Given the execution info, return a map from node name to the disposable - * node name list after its execution. - * - * @returns A map from node name to disposable nodes after its - * execution. That is, for a node `x`, `nodeLiveUntilMap[x]` indicates - * all nodes which their intermediate tensors should be disposed after `x` - * being executed. - */ -export function getNodeLiveUntilMap(orderedNodes: Node[]): Map { - const nodeNameToOrder = new Map( - orderedNodes.map((node, order) => [node.name, order])); - - const INF_LIFE = Number.MAX_SAFE_INTEGER; - // Make control flow nodes (and consequently their direct parents) - // live forever since they're tricky to track correctly. - const selfLifespans = orderedNodes.map( - (node, nodeOrder) => isControlFlow(node) ? INF_LIFE : nodeOrder); - const getSelfLifeSpan = (node: Node) => { - const selfLife = selfLifespans[nodeNameToOrder.get(node.name)!]; - if (selfLife == null) { - // If nodeToOrder does not contain the node, it is unused or - // unreachable in graph. - return -1; - } - return selfLife; - }; - - // `liveUntil[i]` points to the last node in the `orderedNodes` array that - // may depend on tensors from node `i`. It indicates that all the - // intermediate tensors from `orderedNodes[i]` should be disposed after - // `orderedNodes[liveUntil[i]]` is executed. - // A node lives long enough to pass on its tensors to its children. - // It lives until at least `max(node's position, children's positions)`. - const liveUntilOrders = orderedNodes.map((node, nodeOrder) => { - return node.children.map(getSelfLifeSpan) - .reduce((a, b) => Math.max(a, b), selfLifespans[nodeOrder]); - }); - - // liveUntilMap: - // - Key: Name of a node `x` - // - Values: All nodes whose intermediate tensors should be disposed - // after `x` is executed. - const liveUntilMap = new Map(); - for (let nodeOrder = 0; nodeOrder < orderedNodes.length; ++nodeOrder) { - const liveUntilOrder = liveUntilOrders[nodeOrder]; - if (liveUntilOrder === INF_LIFE) { - continue; - } - const node = orderedNodes[nodeOrder]; - const liveUntilNode = orderedNodes[liveUntilOrder]; - if (!liveUntilMap.has(liveUntilNode.name)) { - liveUntilMap.set(liveUntilNode.name, []); - } - liveUntilMap.get(liveUntilNode.name)!.push(node); - } - return liveUntilMap; -} - -const CONTROL_FLOW_OPS = new Set([ - 'Switch', 'Merge', 'Enter', 'Exit', 'NextIteration', 'StatelessIf', - 'StatelessWhile', 'if', 'While' -]); -const DYNAMIC_SHAPE_OPS = new Set([ - 'NonMaxSuppressionV2', 'NonMaxSuppressionV3', 'NonMaxSuppressionV5', 'Where' -]); -const HASH_TABLE_OPS = new Set([ - 'HashTable', 'HashTableV2', 'LookupTableImport', 'LookupTableImportV2', - 'LookupTableFind', 'LookupTableFindV2', 'LookupTableSize', 'LookupTableSizeV2' -]); - -export function isControlFlow(node: Node) { - return CONTROL_FLOW_OPS.has(node.op); -} - -export function isDynamicShape(node: Node) { - return DYNAMIC_SHAPE_OPS.has(node.op); -} - -export function isHashTable(node: Node) { - return HASH_TABLE_OPS.has(node.op); -} diff --git a/tfjs-master/tfjs-converter/src/executor/model_analysis_test.ts b/tfjs-master/tfjs-converter/src/executor/model_analysis_test.ts deleted file mode 100644 index 18c1da78f..000000000 --- a/tfjs-master/tfjs-converter/src/executor/model_analysis_test.ts +++ /dev/null @@ -1,136 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {NamedTensorMap, scalar} from '@tensorflow/tfjs-core'; - -import {IGraphDef} from '../data/compiled_api'; -import {OperationMapper} from '../operations/operation_mapper'; - -import {getExecutionSubgraph} from './model_analysis'; - -describe('getExecutionInfo', () => { - it('2 disconnected subgraphs, no dynamic ops', () => { - const weightMap = {}; - const graphDef: IGraphDef = { - node: [ - {name: 'input', op: 'Placeholder'}, - {name: 'intermediate', op: 'Add', input: ['input', 'input']}, - {name: 'output', op: 'Square', input: ['intermediate']}, - {name: 'input2', op: 'Const'}, // Unrelated to input. - {name: 'output2', op: 'Sqrt', input: ['input2']} // Related to input2. - ], - versions: {producer: 1.0, minConsumer: 3} - }; - const graph = OperationMapper.Instance.transformGraph(graphDef); - - // input --> output - let inputs: NamedTensorMap = {'input': scalar(0)}; - let outputs = [graph.nodes['output']]; - let executionInfo = getExecutionSubgraph(inputs, outputs, weightMap); - expect(executionInfo.inputs).toBe(inputs); - expect(executionInfo.outputs).toBe(outputs); - expect(executionInfo.dynamicNode).toBeFalsy(); - expect(executionInfo.missingInputs).toEqual([]); - expect(executionInfo.syncInputs).toBeFalsy(); - expect(executionInfo.usedNodes).toContain('input'); - expect(executionInfo.usedNodes).toContain('intermediate'); - expect(executionInfo.usedNodes).toContain('output'); - expect(executionInfo.usedNodes.size).toBe(3); - - // input --> intermediate - inputs = {'input': scalar(0)}; - outputs = [graph.nodes['intermediate']]; - executionInfo = getExecutionSubgraph(inputs, outputs, weightMap); - expect(executionInfo.inputs).toBe(inputs); - expect(executionInfo.outputs).toBe(outputs); - expect(executionInfo.dynamicNode).toBeFalsy(); - expect(executionInfo.missingInputs).toEqual([]); - expect(executionInfo.syncInputs).toBeFalsy(); - expect(executionInfo.usedNodes).toContain('input'); - expect(executionInfo.usedNodes).toContain('intermediate'); - expect(executionInfo.usedNodes.size).toBe(2); - - // input2 --> output2 - inputs = {'input2': scalar(0)}; - outputs = [graph.nodes['output2']]; - executionInfo = getExecutionSubgraph(inputs, outputs, weightMap); - expect(executionInfo.inputs).toBe(inputs); - expect(executionInfo.outputs).toBe(outputs); - expect(executionInfo.dynamicNode).toBeFalsy(); - expect(executionInfo.missingInputs).toEqual([]); - expect(executionInfo.syncInputs).toBeFalsy(); - expect(executionInfo.usedNodes).toContain('input2'); - expect(executionInfo.usedNodes).toContain('output2'); - expect(executionInfo.usedNodes.size).toBe(2); - - // input --> output2 is disconnected. - inputs = {'input': scalar(0)}; - outputs = [graph.nodes['output2']]; - executionInfo = getExecutionSubgraph(inputs, outputs, weightMap); - expect(executionInfo.inputs).toBe(inputs); - expect(executionInfo.outputs).toBe(outputs); - expect(executionInfo.dynamicNode).toBeFalsy(); - expect(executionInfo.missingInputs).toEqual(['input2']); - expect(executionInfo.syncInputs).toBeFalsy(); - expect(executionInfo.usedNodes).toContain('output2'); - expect(executionInfo.usedNodes).toContain('input2'); - expect(executionInfo.usedNodes.size).toBe(2); - - // input2 --> output is disconnected. - inputs = {'input2': scalar(0)}; - outputs = [graph.nodes['output']]; - executionInfo = getExecutionSubgraph(inputs, outputs, weightMap); - expect(executionInfo.inputs).toBe(inputs); - expect(executionInfo.outputs).toBe(outputs); - expect(executionInfo.dynamicNode).toBeFalsy(); - expect(executionInfo.missingInputs).toEqual(['input']); - expect(executionInfo.syncInputs).toBeFalsy(); - expect(executionInfo.usedNodes).toContain('input'); - expect(executionInfo.usedNodes).toContain('intermediate'); - expect(executionInfo.usedNodes).toContain('output'); - expect(executionInfo.usedNodes.size).toBe(3); - }); - - it('Async graph', () => { - const weightMap = {}; - const graphDef: IGraphDef = { - node: [ - {name: 'input', op: 'Placeholder'}, - {name: 'intermediate', op: 'Enter', input: ['input']}, - {name: 'intermediate2', op: 'Const', input: ['intermediate']}, - {name: 'output', op: 'Square', input: ['intermediate2']}, - ], - versions: {producer: 1.0, minConsumer: 3} - }; - const graph = OperationMapper.Instance.transformGraph(graphDef); - - // input --> output - const inputs: NamedTensorMap = {'input': scalar(0)}; - const outputs = [graph.nodes['output']]; - const executionInfo = getExecutionSubgraph(inputs, outputs, weightMap); - expect(executionInfo.inputs).toBe(inputs); - expect(executionInfo.outputs).toBe(outputs); - expect(executionInfo.dynamicNode).toBe(graph.nodes['intermediate']); - expect(executionInfo.missingInputs).toEqual([]); - expect(executionInfo.syncInputs).toEqual(['intermediate2']); - expect(executionInfo.usedNodes).toContain('input'); - expect(executionInfo.usedNodes).toContain('intermediate'); - expect(executionInfo.usedNodes).toContain('intermediate2'); - expect(executionInfo.usedNodes).toContain('output'); - expect(executionInfo.usedNodes.size).toBe(4); - }); -}); diff --git a/tfjs-master/tfjs-converter/src/executor/resource_manager.ts b/tfjs-master/tfjs-converter/src/executor/resource_manager.ts deleted file mode 100644 index add272007..000000000 --- a/tfjs-master/tfjs-converter/src/executor/resource_manager.ts +++ /dev/null @@ -1,73 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {HashTableMap, NamedTensorMap} from '../data/types'; -import {HashTable} from './hash_table'; - -/** - * Contains global resources of a model. - */ -export class ResourceManager { - constructor( - readonly hashTableNameToHandle: NamedTensorMap = {}, - readonly hashTableMap: HashTableMap = {}) {} - - /** - * Register a `HashTable` in the resource manager. - * - * The `HashTable` can be retrieved by `resourceManager.getHashTableById`, - * where id is the table handle tensor's id. - * - * @param name Op node name that creates the `HashTable`. - * @param hashTable The `HashTable` to be added to resource manager. - */ - addHashTable(name: string, hashTable: HashTable) { - this.hashTableNameToHandle[name] = hashTable.handle; - this.hashTableMap[hashTable.id] = hashTable; - } - - /** - * Get the table handle by node name. - * @param name Op node name that creates the `HashTable`. This name is also - * used in the inputs list of lookup and import `HashTable` ops. - */ - getHashTableHandleByName(name: string) { - return this.hashTableNameToHandle[name]; - } - - /** - * Get the actual `HashTable` by its handle tensor's id. - * @param id The id of the handle tensor. - */ - getHashTableById(id: number): HashTable { - return this.hashTableMap[id]; - } - - /** - * Dispose `ResourceManager`, including its hashTables and tensors in them. - */ - dispose() { - for (const key in this.hashTableMap) { - this.hashTableMap[key].clearAndClose(); - delete this.hashTableMap[key]; - } - - for (const name in this.hashTableNameToHandle) { - this.hashTableNameToHandle[name].dispose(); - delete this.hashTableNameToHandle[name]; - } - } -} diff --git a/tfjs-master/tfjs-converter/src/executor/tensor_array.ts b/tfjs-master/tfjs-converter/src/executor/tensor_array.ts deleted file mode 100644 index b69553ffb..000000000 --- a/tfjs-master/tfjs-converter/src/executor/tensor_array.ts +++ /dev/null @@ -1,316 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {concat, DataType, keep, reshape, scalar, slice, stack, Tensor, tensor, tidy, unstack} from '@tensorflow/tfjs-core'; - -import {assertShapesMatchAllowUndefinedSize} from './tensor_utils'; - -export interface TensorWithState { - tensor?: Tensor; - written?: boolean; - read?: boolean; - cleared?: boolean; -} -/** - * The TensorArray object keeps an array of Tensors. It - * allows reading from the array and writing to the array. - */ -export class TensorArray { - private tensors: TensorWithState[] = []; - private closed_ = false; - readonly idTensor: Tensor; - constructor( - readonly name: string, readonly dtype: DataType, private maxSize: number, - private elementShape: number[], readonly identicalElementShapes: boolean, - readonly dynamicSize: boolean, readonly clearAfterRead: boolean) { - this.idTensor = scalar(0); - keep(this.idTensor); - } - - get id() { - return this.idTensor.id; - } - - get closed() { - return this.closed_; - } - - /** - * Dispose the tensors and idTensor and mark the TensoryArray as closed. - */ - clearAndClose(keepIds?: Set) { - this.tensors.forEach(tensor => { - if (keepIds == null || !keepIds.has(tensor.tensor.id)) { - tensor.tensor.dispose(); - } - }); - this.tensors = []; - this.closed_ = true; - this.idTensor.dispose(); - } - - size(): number { - return this.tensors.length; - } - - /** - * Read the value at location index in the TensorArray. - * @param index Number the index to read from. - */ - read(index: number): Tensor { - if (this.closed_) { - throw new Error(`TensorArray ${this.name} has already been closed.`); - } - - if (index < 0 || index >= this.size()) { - throw new Error(`Tried to read from index ${index}, but array size is: ${ - this.size()}`); - } - - const tensorWithState = this.tensors[index]; - if (tensorWithState.cleared) { - throw new Error( - `TensorArray ${this.name}: Could not read index ${ - index} twice because it was cleared after a previous read ` + - `(perhaps try setting clear_after_read = false?).`); - } - - if (this.clearAfterRead) { - tensorWithState.cleared = true; - } - - tensorWithState.read = true; - return tensorWithState.tensor; - } - - /** - * Helper method to read multiple tensors from the specified indices. - */ - readMany(indices: number[]): Tensor[] { - return indices.map(index => this.read(index)); - } - - /** - * Write value into the index of the TensorArray. - * @param index number the index to write to. - * @param tensor - */ - write(index: number, tensor: Tensor) { - if (this.closed_) { - throw new Error(`TensorArray ${this.name} has already been closed.`); - } - - if (index < 0 || !this.dynamicSize && index >= this.maxSize) { - throw new Error(`Tried to write to index ${ - index}, but array is not resizeable and size is: ${this.maxSize}`); - } - - const t = this.tensors[index] || {}; - - if (tensor.dtype !== this.dtype) { - throw new Error(`TensorArray ${ - this.name}: Could not write to TensorArray index ${index}, - because the value dtype is ${ - tensor.dtype}, but TensorArray dtype is ${this.dtype}.`); - } - - // Set the shape for the first time write to unknow shape tensor array - if (this.size() === 0 && - (this.elementShape == null || this.elementShape.length === 0)) { - this.elementShape = tensor.shape; - } - - assertShapesMatchAllowUndefinedSize( - this.elementShape, tensor.shape, - `TensorArray ${this.name}: Could not write to TensorArray index ${ - index}.`); - - if (t.read) { - throw new Error( - `TensorArray ${this.name}: Could not write to TensorArray index ${ - index}, because it has already been read.`); - } - - if (t.written) { - throw new Error( - `TensorArray ${this.name}: Could not write to TensorArray index ${ - index}, because it has already been written.`); - } - - t.tensor = tensor; - keep(tensor); - t.written = true; - - this.tensors[index] = t; - } - - /** - * Helper method to write multiple tensors to the specified indices. - */ - writeMany(indices: number[], tensors: Tensor[]) { - if (indices.length !== tensors.length) { - throw new Error( - `TensorArray ${this.name}: could not write multiple tensors,` + - `because the index size: ${ - indices.length} is not the same as tensors size: ${ - tensors.length}.`); - } - - indices.forEach((i, index) => this.write(i, tensors[index])); - } - - /** - * Return selected values in the TensorArray as a packed Tensor. All of - * selected values must have been written and their shapes must all match. - * @param [indices] number[] Optional. Taking values in [0, max_value). If the - * TensorArray is not dynamic, max_value=size(). If not specified returns - * all tensors in the original order. - * @param [dtype] - */ - gather(indices?: number[], dtype?: DataType): Tensor { - if (!!dtype && dtype !== this.dtype) { - throw new Error(`TensorArray dtype is ${ - this.dtype} but gather requested dtype ${dtype}`); - } - - if (!indices) { - indices = []; - for (let i = 0; i < this.size(); i++) { - indices.push(i); - } - } else { - indices = indices.slice(0, this.size()); - } - - if (indices.length === 0) { - return tensor([], [0].concat(this.elementShape)); - } - - // Read all the PersistentTensors into a vector to keep track of - // their memory. - const tensors = this.readMany(indices); - - assertShapesMatchAllowUndefinedSize( - this.elementShape, tensors[0].shape, 'TensorArray shape mismatch: '); - - return stack(tensors, 0); - } - - /** - * Return the values in the TensorArray as a concatenated Tensor. - */ - concat(dtype?: DataType): Tensor { - if (!!dtype && dtype !== this.dtype) { - throw new Error(`TensorArray dtype is ${ - this.dtype} but concat requested dtype ${dtype}`); - } - - if (this.size() === 0) { - return tensor([], [0].concat(this.elementShape)); - } - - const indices = []; - for (let i = 0; i < this.size(); i++) { - indices.push(i); - } - // Collect all the tensors from the tensors array. - const tensors = this.readMany(indices); - - assertShapesMatchAllowUndefinedSize( - this.elementShape, tensors[0].shape, - `TensorArray shape mismatch: tensor array shape (${ - this.elementShape}) vs first tensor shape (${tensors[0].shape})`); - - return concat(tensors, 0); - } - - /** - * Scatter the values of a Tensor in specific indices of a TensorArray. - * @param indices nummber[] values in [0, max_value). If the - * TensorArray is not dynamic, max_value=size(). - * @param tensor Tensor input tensor. - */ - scatter(indices: number[], tensor: Tensor) { - if (tensor.dtype !== this.dtype) { - throw new Error(`TensorArray dtype is ${ - this.dtype} but tensor has dtype ${tensor.dtype}`); - } - - if (indices.length !== tensor.shape[0]) { - throw new Error(`Expected len(indices) == tensor.shape[0], but saw: ${ - indices.length} vs. ${tensor.shape[0]}`); - } - - const maxIndex = Math.max(...indices); - - if (!this.dynamicSize && maxIndex >= this.maxSize) { - throw new Error( - `Max index must be < array size (${maxIndex} vs. ${this.maxSize})`); - } - - this.writeMany(indices, unstack(tensor, 0)); - } - - /** - * Split the values of a Tensor into the TensorArray. - * @param length number[] with the lengths to use when splitting value along - * its first dimension. - * @param tensor Tensor, the tensor to split. - */ - split(length: number[], tensor: Tensor) { - if (tensor.dtype !== this.dtype) { - throw new Error(`TensorArray dtype is ${ - this.dtype} but tensor has dtype ${tensor.dtype}`); - } - let totalLength = 0; - const cumulativeLengths = length.map(len => { - totalLength += len; - return totalLength; - }); - - if (totalLength !== tensor.shape[0]) { - throw new Error(`Expected sum of lengths to be equal to - tensor.shape[0], but sum of lengths is - ${totalLength}, and tensor's shape is: ${tensor.shape}`); - } - - if (!this.dynamicSize && length.length !== this.maxSize) { - throw new Error( - `TensorArray's size is not equal to the size of lengths (${ - this.maxSize} vs. ${length.length}), ` + - 'and the TensorArray is not marked as dynamically resizeable'); - } - - const elementPerRow = totalLength === 0 ? 0 : tensor.size / totalLength; - const tensors: Tensor[] = []; - tidy(() => { - tensor = reshape(tensor, [1, totalLength, elementPerRow]); - for (let i = 0; i < length.length; ++i) { - const previousLength = (i === 0) ? 0 : cumulativeLengths[i - 1]; - const indices = [0, previousLength, 0]; - const sizes = [1, length[i], elementPerRow]; - tensors[i] = reshape(slice(tensor, indices, sizes), this.elementShape); - } - return tensors; - }); - const indices = []; - for (let i = 0; i < length.length; i++) { - indices[i] = i; - } - this.writeMany(indices, tensors); - } -} diff --git a/tfjs-master/tfjs-converter/src/executor/tensor_array_test.ts b/tfjs-master/tfjs-converter/src/executor/tensor_array_test.ts deleted file mode 100644 index 0e3d77387..000000000 --- a/tfjs-master/tfjs-converter/src/executor/tensor_array_test.ts +++ /dev/null @@ -1,286 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {memory, Tensor, tensor2d, tensor3d} from '@tensorflow/tfjs-core'; -import {test_util} from '@tensorflow/tfjs-core'; - -import {TensorArray} from './tensor_array'; - -let tensorArray: TensorArray; -let tensor: Tensor; -let tensor2: Tensor; -const NAME = 'TA1'; -const DTYPE = 'int32'; -const SIZE = 10; -const SHAPE = [1, 1]; -const IDENTICAL_SHAPE = true; -const DYNAMIC_SIZE = false; -const CLEAR_AFTER_READ = false; - -describe('TensorArray', () => { - beforeEach(() => { - tensorArray = new TensorArray( - NAME, DTYPE, SIZE, SHAPE, IDENTICAL_SHAPE, DYNAMIC_SIZE, - CLEAR_AFTER_READ); - tensor = tensor2d([1], [1, 1], 'int32'); - tensor2 = tensor2d([2], [1, 1], 'int32'); - }); - afterEach(() => tensorArray.clearAndClose()); - - it('should initialize', () => { - expect(tensorArray.size()).toEqual(0); - expect(tensorArray.name).toEqual('TA1'); - expect(tensorArray.dynamicSize).toBeFalsy(); - expect(tensorArray.closed).toBeFalsy(); - }); - - it('should close', () => { - const numOfTensors = memory().numTensors; - const size = tensorArray.size(); - tensorArray.clearAndClose(); - expect(tensorArray.size()).toBe(0); - expect(tensorArray.closed).toBeTruthy(); - - // disposed the tensor in the array and idTensor of the array - expect(memory().numTensors).toEqual(numOfTensors - size - 1); - }); - - it('should not dispose keep tensors when close', () => { - const numOfTensors = memory().numTensors; - tensorArray.write(0, tensor); - tensorArray.write(1, tensor2); - const size = tensorArray.size(); - const keepIds = new Set([tensor.id]); - tensorArray.clearAndClose(keepIds); - expect(tensorArray.size()).toBe(0); - expect(tensorArray.closed).toBeTruthy(); - expect(tensor.isDisposed).toBeFalsy(); - expect(tensor2.isDisposed).toBeTruthy(); - // disposed the tensor in the array and idTensor of the array - expect(memory().numTensors).toEqual(numOfTensors - size); - }); - - describe('write', () => { - it('should add new tensor', () => { - tensorArray.write(0, tensor); - expect(tensorArray.size()).toBe(1); - }); - it('should add multiple tensors', () => { - tensorArray.writeMany([0, 1], [tensor, tensor2]); - expect(tensorArray.size()).toBe(2); - }); - it('should fail if dtype does not match', () => { - const tensor = tensor2d([1], [1, 1], 'float32'); - expect(() => tensorArray.write(0, tensor)).toThrow(); - }); - it('should fail if shape does not match', () => { - const tensor = tensor2d([1, 2], [2, 1], 'int32'); - expect(() => tensorArray.write(0, tensor)).toThrow(); - }); - it('should allow unknown shape', () => { - const unknownShape: number[] = undefined; - tensorArray = new TensorArray( - NAME, DTYPE, SIZE, unknownShape, IDENTICAL_SHAPE, DYNAMIC_SIZE, - CLEAR_AFTER_READ); - const tensor = tensor2d([1, 2], [2, 1], 'int32'); - tensorArray.write(0, tensor); - expect(tensorArray.read(0)).not.toBeNull(); - }); - it('should fail if the index has already been written', () => { - tensorArray.write(0, tensor); - expect(() => tensorArray.write(0, tensor)).toThrow(); - }); - it('should fail if the index greater than array size', () => { - expect(() => tensorArray.write(11, tensor)).toThrow(); - }); - it('should fail if the array is closed', () => { - tensorArray.clearAndClose(); - expect(() => tensorArray.write(0, tensor)).toThrow(); - }); - it('should create no new tensors', () => { - const numTensors = memory().numTensors; - tensorArray.write(0, tensor); - expect(memory().numTensors).toEqual(numTensors); - }); - }); - - describe('read', () => { - beforeEach(() => { - tensorArray.writeMany([0, 1], [tensor, tensor2]); - }); - - it('should read the correct index', () => { - expect(tensorArray.read(0)).toBe(tensor); - expect(tensorArray.read(1)).toBe(tensor2); - }); - it('should read the multiple indices', () => { - expect(tensorArray.readMany([0, 1])).toEqual([tensor, tensor2]); - }); - it('should failed if index is out of bound', () => { - expect(() => tensorArray.read(3)).toThrow(); - expect(() => tensorArray.read(-1)).toThrow(); - }); - it('should failed if array is closed', () => { - tensorArray.clearAndClose(); - expect(() => tensorArray.read(0)).toThrow(); - }); - it('should create no new tensors', () => { - const numTensors = memory().numTensors; - tensorArray.read(0); - tensorArray.read(1); - expect(memory().numTensors).toEqual(numTensors); - }); - }); - - describe('gather', () => { - beforeEach(() => { - tensorArray.writeMany([0, 1], [tensor, tensor2]); - }); - - it('should return default packed tensors', async () => { - const gathered = tensorArray.gather(); - expect(gathered.shape).toEqual([2, 1, 1]); - test_util.expectArraysClose(await gathered.data(), [1, 2]); - }); - - it('should return packed tensors when indices is specified', async () => { - const gathered = tensorArray.gather([1, 0]); - expect(gathered.shape).toEqual([2, 1, 1]); - test_util.expectArraysClose(await gathered.data(), [2, 1]); - }); - it('should return when indices longer than available tensors', async () => { - const gathered = tensorArray.gather([1, 0, 2, 3]); - expect(gathered.shape).toEqual([2, 1, 1]); - test_util.expectArraysClose(await gathered.data(), [2, 1]); - }); - it('should fail if dtype is not matched', () => { - expect(() => tensorArray.gather([0, 1], 'float32')).toThrow(); - }); - it('should create one new tensor', () => { - const numTensors: number = memory().numTensors; - tensorArray.gather(); - expect(memory().numTensors).toEqual(numTensors + 1); - }); - }); - - describe('concat', () => { - beforeEach(() => { - tensorArray.writeMany([0, 1], [tensor, tensor2]); - }); - - it('should return default concat tensors', async () => { - const concat = tensorArray.concat(); - expect(concat.shape).toEqual([2, 1]); - test_util.expectArraysClose(await concat.data(), [1, 2]); - }); - - it('should fail if dtype is not matched', () => { - expect(() => tensorArray.concat('float32')).toThrow(); - }); - - it('should create one new tensor', () => { - const numTensors: number = memory().numTensors; - tensorArray.concat(); - expect(memory().numTensors).toEqual(numTensors + 1); - }); - }); - - describe('scatter', () => { - it('should scatter the input tensor', () => { - const input = tensor3d([1, 2, 3], [3, 1, 1], 'int32'); - tensorArray.scatter([0, 1, 2], input); - expect(tensorArray.size()).toEqual(3); - }); - - it('should fail if indices and tensor shapes do not matched', () => { - const input = tensor3d([1, 2, 3], [3, 1, 1], 'int32'); - expect(() => tensorArray.scatter([1, 2], input)).toThrow(); - }); - - it('should not fail if tensor array shape is -1', () => { - tensorArray = new TensorArray( - NAME, DTYPE, SIZE, [-1, 1], IDENTICAL_SHAPE, DYNAMIC_SIZE, - CLEAR_AFTER_READ); - const input = tensor3d([1, 2, 3], [3, 1, 1], 'int32'); - tensorArray.scatter([1, 2, 3], input); - const res = tensorArray.gather([1]); - expect(res).not.toBeNull(); - }); - - it('should fail if max index > array max size', () => { - const input = tensor3d([1, 2, 3], [3, 1, 1], 'int32'); - expect(() => tensorArray.scatter([1, 2, 11], input)).toThrow(); - }); - - it('should fail if dtype is not matched', () => { - const input = tensor3d([1, 2, 3], [3, 1, 1], 'float32'); - expect(() => tensorArray.scatter([0, 1, 2], input)).toThrow(); - }); - it('should create three new tensors', () => { - const input = tensor3d([1, 2, 3], [3, 1, 1], 'int32'); - const numTensors: number = memory().numTensors; - tensorArray.scatter([0, 1, 2], input); - expect(memory().numTensors).toEqual(numTensors + 3); - }); - }); - - describe('split', () => { - beforeEach(() => { - tensorArray = new TensorArray( - NAME, DTYPE, 3, [2, 2], IDENTICAL_SHAPE, DYNAMIC_SIZE, - CLEAR_AFTER_READ); - }); - - it('should split the input tensor', () => { - const input = - tensor3d([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [3, 2, 2], 'int32'); - tensorArray.split([1, 1, 1], input); - expect(tensorArray.size()).toEqual(3); - }); - - it('should fail if indices and tensor shapes do not matched', () => { - const input = tensor3d([1, 2, 3], [3, 1, 1], 'int32'); - expect(() => tensorArray.split([1, 1], input)).toThrow(); - }); - - it('should not fail if indices and tensor shapes is -1', () => { - tensorArray = new TensorArray( - NAME, DTYPE, SIZE, [-1, 1], IDENTICAL_SHAPE, DYNAMIC_SIZE, - CLEAR_AFTER_READ); - const input = tensor3d([1, 2, 3], [3, 1, 1], 'int32'); - expect(() => tensorArray.split([1, 1], input)).toThrow(); - }); - - it('should fail if length > array max size', () => { - const input = tensor3d([1, 2, 3], [3, 1, 1], 'int32'); - expect(() => tensorArray.split([1, 1, 1, 1], input)).toThrow(); - }); - - it('should fail if dtype is not matched', () => { - const input = tensor3d([1, 2, 3], [3, 1, 1], 'float32'); - expect(() => tensorArray.split([1, 1, 1], input)).toThrow(); - }); - - it('should create three new tensors', () => { - const input = - tensor3d([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [3, 2, 2], 'int32'); - const numTensors: number = memory().numTensors; - tensorArray.split([1, 1, 1], input); - expect(memory().numTensors).toEqual(numTensors + 3); - }); - }); -}); diff --git a/tfjs-master/tfjs-converter/src/executor/tensor_list.ts b/tfjs-master/tfjs-converter/src/executor/tensor_list.ts deleted file mode 100644 index 577ada6d1..000000000 --- a/tfjs-master/tfjs-converter/src/executor/tensor_list.ts +++ /dev/null @@ -1,426 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {concat, DataType, keep, reshape, scalar, slice, stack, Tensor, tensor, tidy, unstack} from '@tensorflow/tfjs-core'; - -import {assertShapesMatchAllowUndefinedSize, inferElementShape, mergeElementShape} from './tensor_utils'; - -/** - * TensorList stores a container of `tf.Tensor` objects, which are accessible - * via tensors field. - * - * In order to get a copy of the underlying list, use the copy method: - * ``` - * TensorList b = a.copy(); - * b.tensors().pushBack(t); // This does not modify a.tensors(). - * ``` - * - * Note that this is not a deep copy: the memory locations of the underlying - * tensors will still point to the same locations of the corresponding tensors - * in the original. - */ - -export class TensorList { - readonly idTensor: Tensor; - maxNumElements: number; - - get id() { - return this.idTensor.id; - } - /** - * - * @param tensors list of tensors - * @param elementShape shape of each tensor, this can be a single number (any - * shape is allowed) or partial shape (dim = -1). - * @param elementDtype data type of each tensor - * @param maxNumElements The maximum allowed size of `tensors`. Defaults to -1 - * meaning that the size of `tensors` is unbounded. - */ - constructor( - readonly tensors: Tensor[], readonly elementShape: number|number[], - readonly elementDtype: DataType, maxNumElements = -1) { - if (tensors != null) { - tensors.forEach(tensor => { - if (elementDtype !== tensor.dtype) { - throw new Error(`Invalid data types; op elements ${ - elementDtype}, but list elements ${tensor.dtype}`); - } - assertShapesMatchAllowUndefinedSize( - elementShape, tensor.shape, 'TensorList shape mismatch: '); - - keep(tensor); - }); - } - this.idTensor = scalar(0); - this.maxNumElements = maxNumElements; - keep(this.idTensor); - } - - /** - * Get a new TensorList containing a copy of the underlying tensor container. - */ - copy(): TensorList { - return new TensorList( - [...this.tensors], this.elementShape, this.elementDtype); - } - - /** - * Dispose the tensors and idTensor and clear the tensor list. - */ - clearAndClose(keepIds?: Set) { - this.tensors.forEach(tensor => { - if (keepIds == null || !keepIds.has(tensor.id)) { - tensor.dispose(); - } - }); - this.tensors.length = 0; - this.idTensor.dispose(); - } - /** - * The size of the tensors in the tensor list. - */ - size() { - return this.tensors.length; - } - - /** - * Return a tensor that stacks a list of rank-R tf.Tensors into one rank-(R+1) - * tf.Tensor. - * @param elementShape shape of each tensor - * @param elementDtype data type of each tensor - * @param numElements the number of elements to stack - */ - stack(elementShape: number[], elementDtype: DataType, numElements = -1): - Tensor { - if (elementDtype !== this.elementDtype) { - throw new Error(`Invalid data types; op elements ${ - elementDtype}, but list elements ${this.elementDtype}`); - } - if (numElements !== -1 && this.tensors.length !== numElements) { - throw new Error(`Operation expected a list with ${ - numElements} elements but got a list with ${ - this.tensors.length} elements.`); - } - assertShapesMatchAllowUndefinedSize( - elementShape, this.elementShape, 'TensorList shape mismatch: '); - const outputElementShape = - inferElementShape(this.elementShape, this.tensors, elementShape); - return tidy(() => { - const reshapedTensors = - this.tensors.map(tensor => reshape(tensor, outputElementShape)); - return stack(reshapedTensors, 0); - }); - } - - /** - * Pop a tensor from the end of the list. - * @param elementShape shape of the tensor - * @param elementDtype data type of the tensor - */ - popBack(elementShape: number[], elementDtype: DataType): Tensor { - if (elementDtype !== this.elementDtype) { - throw new Error(`Invalid data types; op elements ${ - elementDtype}, but list elements ${this.elementDtype}`); - } - - if (this.size() === 0) { - throw new Error('Trying to pop from an empty list.'); - } - const outputElementShape = - inferElementShape(this.elementShape, this.tensors, elementShape); - const tensor = this.tensors.pop(); - tensor.kept = false; - - assertShapesMatchAllowUndefinedSize( - tensor.shape, elementShape, 'TensorList shape mismatch: '); - - return reshape(tensor, outputElementShape); - } - - /** - * Push a tensor to the end of the list. - * @param tensor Tensor to be pushed. - */ - pushBack(tensor: Tensor) { - if (tensor.dtype !== this.elementDtype) { - throw new Error(`Invalid data types; op elements ${ - tensor.dtype}, but list elements ${this.elementDtype}`); - } - - assertShapesMatchAllowUndefinedSize( - tensor.shape, this.elementShape, 'TensorList shape mismatch: '); - - if (this.maxNumElements === this.size()) { - throw new Error(`Trying to push element into a full list.`); - } - keep(tensor); - this.tensors.push(tensor); - } - - /** - * Update the size of the list. - * @param size the new size of the list. - */ - resize(size: number) { - if (size < 0) { - throw new Error( - `TensorListResize expects size to be non-negative. Got: ${size}`); - } - - if (this.maxNumElements !== -1 && size > this.maxNumElements) { - throw new Error(`TensorListResize input size ${ - size} is greater maxNumElement ${this.maxNumElements}.`); - } - - const destTensorList: TensorList = new TensorList( - [], this.elementShape, this.elementDtype, this.maxNumElements); - destTensorList.tensors.length = size; - for (let i = 0; i < Math.min(this.tensors.length, size); ++i) { - destTensorList.tensors[i] = this.tensors[i]; - } - return destTensorList; - } - - /** - * Retrieve the element at the provided index - * @param elementShape shape of the tensor - * @param elementDtype dtype of the tensor - * @param elementIndex index of the tensor - */ - getItem(elementIndex: number, elementShape: number[], elementDtype: DataType): - Tensor { - if (elementDtype !== this.elementDtype) { - throw new Error(`Invalid data types; op elements ${ - elementDtype}, but list elements ${this.elementDtype}`); - } - if (elementIndex < 0 || elementIndex > this.tensors.length) { - throw new Error(`Trying to access element ${ - elementIndex} in a list with ${this.tensors.length} elements.`); - } - - if (this.tensors[elementIndex] == null) { - throw new Error(`element at index ${elementIndex} is null.`); - } - - assertShapesMatchAllowUndefinedSize( - this.tensors[elementIndex].shape, elementShape, - 'TensorList shape mismatch: '); - const outputElementShape = - inferElementShape(this.elementShape, this.tensors, elementShape); - return reshape(this.tensors[elementIndex], outputElementShape); - } - - /** - * Set the tensor at the index - * @param elementIndex index of the tensor - * @param tensor the tensor to be inserted into the list - */ - setItem(elementIndex: number, tensor: Tensor) { - if (tensor.dtype !== this.elementDtype) { - throw new Error(`Invalid data types; op elements ${ - tensor.dtype}, but list elements ${this.elementDtype}`); - } - - if (elementIndex < 0 || - this.maxNumElements !== -1 && elementIndex >= this.maxNumElements) { - throw new Error(`Trying to set element ${ - elementIndex} in a list with max ${this.maxNumElements} elements.`); - } - - assertShapesMatchAllowUndefinedSize( - this.elementShape, tensor.shape, 'TensorList shape mismatch: '); - keep(tensor); - - // dispose the previous value if it is replacing. - if (this.tensors[elementIndex] != null) { - this.tensors[elementIndex].kept = false; - } - - this.tensors[elementIndex] = tensor; - } - - /** - * Return selected values in the TensorList as a stacked Tensor. All of - * selected values must have been written and their shapes must all match. - * @param indices indices of tensors to gather - * @param elementDtype output tensor dtype - * @param elementShape output tensor element shape - */ - gather(indices: number[], elementDtype: DataType, elementShape: number[]): - Tensor { - if (elementDtype !== this.elementDtype) { - throw new Error(`Invalid data types; op elements ${ - elementDtype}, but list elements ${this.elementDtype}`); - } - - assertShapesMatchAllowUndefinedSize( - this.elementShape, elementShape, 'TensorList shape mismatch: '); - - // When indices is greater than the size of the list, indices beyond the - // size of the list are ignored. - indices = indices.slice(0, this.size()); - const outputElementShape = - inferElementShape(this.elementShape, this.tensors, elementShape); - if (indices.length === 0) { - return tensor([], [0].concat(outputElementShape)); - } - - return tidy(() => { - const tensors = - indices.map(i => reshape(this.tensors[i], outputElementShape)); - return stack(tensors, 0); - }); - } - - /** - * Return the values in the TensorList as a concatenated Tensor. - * @param elementDtype output tensor dtype - * @param elementShape output tensor element shape - */ - concat(elementDtype: DataType, elementShape: number[]): Tensor { - if (!!elementDtype && elementDtype !== this.elementDtype) { - throw new Error(`TensorList dtype is ${ - this.elementDtype} but concat requested dtype ${elementDtype}`); - } - - assertShapesMatchAllowUndefinedSize( - this.elementShape, elementShape, 'TensorList shape mismatch: '); - const outputElementShape = - inferElementShape(this.elementShape, this.tensors, elementShape); - - if (this.size() === 0) { - return tensor([], [0].concat(outputElementShape)); - } - return tidy(() => { - const tensors = this.tensors.map(t => reshape(t, outputElementShape)); - return concat(tensors, 0); - }); - } -} - -/** - * Creates a TensorList which, when stacked, has the value of tensor. - * @param tensor from tensor - * @param elementShape output tensor element shape - */ -export function fromTensor( - tensor: Tensor, elementShape: number[], elementDtype: DataType) { - const dtype = tensor.dtype; - if (tensor.shape.length < 1) { - throw new Error( - `Tensor must be at least a vector, but saw shape: ${tensor.shape}`); - } - if (tensor.dtype !== elementDtype) { - throw new Error(`Invalid data types; op elements ${ - tensor.dtype}, but list elements ${elementDtype}`); - } - const tensorElementShape = tensor.shape.slice(1); - assertShapesMatchAllowUndefinedSize( - tensorElementShape, elementShape, 'TensorList shape mismatch: '); - const tensorList: Tensor[] = unstack(tensor); - return new TensorList(tensorList, elementShape, dtype); -} - -/** - * Return a TensorList of the given size with empty elements. - * @param elementShape the shape of the future elements of the list - * @param elementDtype the desired type of elements in the list - * @param numElements the number of elements to reserve - * @param maxNumElements the maximum number of elements in th list - */ -export function reserve( - elementShape: number[], elementDtype: DataType, numElements: number, - maxNumElements: number) { - return new TensorList([], elementShape, elementDtype, maxNumElements); -} - -/** - * Put tensors at specific indices of a stacked tensor into a TensorList. - * @param indices list of indices on how to scatter the tensor. - * @param tensor input tensor. - * @param elementShape the shape of the future elements of the list - * @param numElements the number of elements to scatter - */ -export function scatter( - tensor: Tensor, indices: number[], elementShape: number[], - numElements?: number): TensorList { - if (indices.length !== tensor.shape[0]) { - throw new Error(`Expected len(indices) == tensor.shape[0], but saw: ${ - indices.length} vs. ${tensor.shape[0]}`); - } - - const maxIndex = Math.max(...indices); - - if (numElements != null && numElements !== -1 && maxIndex >= numElements) { - throw new Error( - `Max index must be < array size (${maxIndex} vs. ${numElements})`); - } - - const list = new TensorList([], elementShape, tensor.dtype, numElements); - const tensors = unstack(tensor, 0); - indices.forEach((value, index) => { - list.setItem(value, tensors[index]); - }); - return list; -} - -/** - * Split the values of a Tensor into a TensorList. - * @param length the lengths to use when splitting value along - * its first dimension. - * @param tensor the tensor to split. - * @param elementShape the shape of the future elements of the list - */ -export function split( - tensor: Tensor, length: number[], elementShape: number[]) { - let totalLength = 0; - const cumulativeLengths = length.map(len => { - totalLength += len; - return totalLength; - }); - - if (totalLength !== tensor.shape[0]) { - throw new Error(`Expected sum of lengths to be equal to - tensor.shape[0], but sum of lengths is - ${totalLength}, and tensor's shape is: ${tensor.shape}`); - } - - const shapeWithoutFirstDim = tensor.shape.slice(1); - const outputElementShape = - mergeElementShape(shapeWithoutFirstDim, elementShape); - const elementPerRow = totalLength === 0 ? 0 : tensor.size / totalLength; - const tensors: Tensor[] = tidy(() => { - const tensors = []; - tensor = reshape(tensor, [1, totalLength, elementPerRow]); - for (let i = 0; i < length.length; ++i) { - const previousLength = (i === 0) ? 0 : cumulativeLengths[i - 1]; - const indices = [0, previousLength, 0]; - const sizes = [1, length[i], elementPerRow]; - tensors[i] = reshape( - slice(tensor, indices, sizes), outputElementShape as number[]); - } - tensor.dispose(); - return tensors; - }); - - const list = new TensorList([], elementShape, tensor.dtype, length.length); - - for (let i = 0; i < tensors.length; i++) { - list.setItem(i, tensors[i]); - } - return list; -} diff --git a/tfjs-master/tfjs-converter/src/executor/tensor_list_test.ts b/tfjs-master/tfjs-converter/src/executor/tensor_list_test.ts deleted file mode 100644 index 8cf5bc6cd..000000000 --- a/tfjs-master/tfjs-converter/src/executor/tensor_list_test.ts +++ /dev/null @@ -1,345 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {memory, Tensor, tensor2d, tensor3d, test_util} from '@tensorflow/tfjs-core'; - -import {reserve, scatter, split, TensorList} from './tensor_list'; - -let tensorList: TensorList; -let tensor: Tensor; -let tensor2: Tensor; -const DTYPE = 'int32'; -const SIZE = 10; -const SHAPE = [1, 1]; - -describe('TensorList', () => { - beforeEach(() => { - tensorList = new TensorList([], SHAPE, DTYPE, SIZE); - tensor = tensor2d([1], [1, 1], 'int32'); - tensor2 = tensor2d([2], [1, 1], 'int32'); - }); - - it('should initialize', () => { - expect(tensorList.size()).toEqual(0); - expect(tensorList.elementDtype).toEqual(DTYPE); - expect(tensorList.maxNumElements).toEqual(SIZE); - expect(tensorList.elementShape).toEqual(SHAPE); - }); - - it('should allow scalar shape', () => { - tensorList = new TensorList([], -1, DTYPE, SIZE); - expect(tensorList.size()).toEqual(0); - expect(tensorList.elementDtype).toEqual(DTYPE); - expect(tensorList.maxNumElements).toEqual(SIZE); - expect(tensorList.elementShape).toEqual(-1); - }); - - it('should not dispose keep tensors when close', () => { - const numOfTensors = memory().numTensors; - tensorList.pushBack(tensor); - tensorList.pushBack(tensor2); - const size = tensorList.size(); - const keepIds = new Set([tensor.id]); - tensorList.clearAndClose(keepIds); - expect(tensorList.size()).toBe(0); - expect(tensor.isDisposed).toBeFalsy(); - expect(tensor2.isDisposed).toBeTruthy(); - // disposed the tensor in the array and idTensor of the array - expect(memory().numTensors).toEqual(numOfTensors - size); - }); - - describe('pushBack', () => { - it('should add new tensor', () => { - tensorList.pushBack(tensor); - expect(tensorList.size()).toBe(1); - }); - it('should fail if dtype does not match', () => { - const tensor = tensor2d([1], [1, 1], 'float32'); - expect(() => tensorList.pushBack(tensor)).toThrow(); - }); - it('should fail if shape does not match', () => { - const tensor = tensor2d([1, 2], [2, 1], 'int32'); - expect(() => tensorList.pushBack(tensor)).toThrow(); - }); - it('should not fail for multiple push', () => { - tensorList.pushBack(tensor); - expect(() => tensorList.pushBack(tensor)).not.toThrow(); - }); - it('should fail if greater than array size', () => { - tensorList.maxNumElements = 1; - tensorList.pushBack(tensor); - expect(() => tensorList.pushBack(tensor)).toThrow(); - }); - it('should not fail for wildcard shape', () => { - tensorList = new TensorList([], [-1, 1], DTYPE, SIZE); - const tensor = tensor2d([1], [1, 1], 'int32'); - tensorList.pushBack(tensor); - expect(tensorList.size()).toBe(1); - }); - it('should create no new tensors', () => { - const numTensors = memory().numTensors; - tensorList.pushBack(tensor); - expect(memory().numTensors).toEqual(numTensors); - }); - }); - - describe('popBack', () => { - it('should add new tensor', () => { - tensorList.pushBack(tensor); - tensorList.popBack(SHAPE, DTYPE); - expect(tensorList.size()).toBe(0); - }); - it('should fail if dtype does not match', () => { - tensorList.pushBack(tensor); - expect(() => tensorList.popBack(SHAPE, 'float32')).toThrow(); - }); - it('should fail if shape does not match', () => { - expect(() => tensorList.popBack([2, 1], DTYPE)).toThrow(); - }); - it('should not fail for multiple push', () => { - tensorList.pushBack(tensor); - tensorList.pushBack(tensor2); - tensorList.popBack(SHAPE, DTYPE); - expect(() => tensorList.popBack(SHAPE, DTYPE)).not.toThrow(); - }); - it('should fail if greater than array size', () => { - expect(() => tensorList.popBack(SHAPE, DTYPE)).toThrow(); - }); - it('should create no new tensors', () => { - tensorList.pushBack(tensor); - const numTensors = memory().numTensors; - const tensorPoped = tensorList.popBack(SHAPE, DTYPE); - expect(tensorPoped.kept).toBeFalsy(); - // a new reshaped tensor - expect(memory().numTensors).toEqual(numTensors + 1); - }); - it('should not fail for wildcard shape', () => { - tensorList = new TensorList([], [-1, 1], DTYPE, SIZE); - const tensor = tensor2d([1], [1, 1], DTYPE); - tensorList.pushBack(tensor); - tensorList.popBack([-1, 1], DTYPE); - expect(tensorList.size()).toBe(0); - }); - }); - describe('setItem', () => { - it('should add new tensor', () => { - tensorList.setItem(0, tensor); - expect(tensorList.size()).toBe(1); - }); - it('should fail if dtype does not match', () => { - const tensor = tensor2d([1], [1, 1], 'float32'); - expect(() => tensorList.setItem(0, tensor)).toThrow(); - }); - it('should fail if shape does not match', () => { - const tensor = tensor2d([1, 2], [2, 1], 'int32'); - expect(() => tensorList.setItem(0, tensor)).toThrow(); - }); - it('should not fail if the index has already been written', () => { - tensorList.setItem(0, tensor); - expect(() => tensorList.setItem(0, tensor)).not.toThrow(); - }); - it('should fail if the index greater than array size', () => { - expect(() => tensorList.setItem(11, tensor)).toThrow(); - }); - it('should not fail for wildcard shape', () => { - tensorList = new TensorList([], [-1, 1], DTYPE, SIZE); - tensorList.setItem(0, tensor); - expect(tensorList.size()).toBe(1); - }); - it('should create no new tensors', () => { - const numTensors = memory().numTensors; - tensorList.setItem(0, tensor); - expect(memory().numTensors).toEqual(numTensors); - }); - it('should remove kept flag for replaced tensor', () => { - tensorList = new TensorList([], [-1, 1], DTYPE, SIZE); - tensorList.setItem(0, tensor); - expect(tensor.kept).toBeTruthy(); - tensorList.setItem(0, tensor2); - expect(tensor.kept).toBeFalsy(); - expect(tensor2.kept).toBeTruthy(); - }); - }); - - describe('getItem', () => { - beforeEach(() => { - tensorList.setItem(0, tensor); - tensorList.setItem(1, tensor2); - }); - - it('should read the correct index', async () => { - test_util.expectArraysEqual( - await tensorList.getItem(0, SHAPE, DTYPE).data(), - await tensor.data()); - test_util.expectArraysEqual( - await tensorList.getItem(1, SHAPE, DTYPE).data(), - await tensor2.data()); - }); - - it('should failed if index is out of bound', () => { - expect(() => tensorList.getItem(3, SHAPE, DTYPE)).toThrow(); - expect(() => tensorList.getItem(-1, SHAPE, DTYPE)).toThrow(); - }); - it('should create no new tensors', () => { - const numTensors = memory().numTensors; - const tensor1 = tensorList.getItem(0, SHAPE, DTYPE); - const tensor2 = tensorList.getItem(1, SHAPE, DTYPE); - - tensor1.dispose(); - tensor2.dispose(); - // 2 reshape tensors - expect(memory().numTensors).toEqual(numTensors); - }); - it('should not fail for wildcard shape', async () => { - const tensor3 = tensorList.getItem(0, [-1, 1], DTYPE); - test_util.expectArraysEqual(await tensor3.data(), await tensor.data()); - }); - }); - - describe('reserve', () => { - it('should create a tensor list', async () => { - const tensorList = reserve([1, 1], 'float32', 10, 10); - expect(tensorList.maxNumElements).toEqual(10); - expect(tensorList.elementDtype).toEqual('float32'); - expect(tensorList.elementShape).toEqual([1, 1]); - }); - it('should not fail for wildcard shape', async () => { - const tensorList = reserve([-1, 1], 'float32', 10, 10); - expect(tensorList.maxNumElements).toEqual(10); - expect(tensorList.elementDtype).toEqual('float32'); - expect(tensorList.elementShape).toEqual([-1, 1]); - }); - }); - - describe('concat', () => { - beforeEach(() => { - tensorList.setItem(0, tensor); - tensorList.setItem(1, tensor2); - }); - - it('should return default concat tensors', async () => { - const concat = tensorList.concat(DTYPE, SHAPE); - expect(concat.shape).toEqual([2, 1]); - test_util.expectArraysClose(await concat.data(), [1, 2]); - }); - it('should not fail for wildcard shape', async () => { - const concat = tensorList.concat(DTYPE, [-1, 1]); - expect(concat.shape).toEqual([2, 1]); - test_util.expectArraysClose(await concat.data(), [1, 2]); - }); - it('should fail if dtype is not matched', () => { - expect(() => tensorList.concat('float32', SHAPE)).toThrow(); - }); - - it('should create one new tensor', () => { - const numTensors: number = memory().numTensors; - tensorList.concat(DTYPE, SHAPE); - expect(memory().numTensors).toEqual(numTensors + 1); - }); - }); - - describe('gather', () => { - beforeEach(() => { - tensorList.setItem(0, tensor); - tensorList.setItem(1, tensor2); - }); - - it('should return packed tensors when indices is specified', async () => { - const gathered = tensorList.gather([1, 0], DTYPE, SHAPE); - expect(gathered.shape).toEqual([2, 1, 1]); - test_util.expectArraysClose(await gathered.data(), [2, 1]); - }); - it('should return when indices longer than available tensors', async () => { - const gathered = tensorList.gather([1, 0, 2, 3], DTYPE, SHAPE); - expect(gathered.shape).toEqual([2, 1, 1]); - test_util.expectArraysClose(await gathered.data(), [2, 1]); - }); - it('should fail if dtype is not matched', () => { - expect(() => tensorList.gather([0, 1], 'float32', SHAPE)).toThrow(); - }); - it('should create one new tensor', () => { - const numTensors: number = memory().numTensors; - tensorList.gather([0, 1], DTYPE, SHAPE); - expect(memory().numTensors).toEqual(numTensors + 1); - }); - it('should not fail for wildcard shape', async () => { - const numTensors: number = memory().numTensors; - tensorList.gather([0, 1], DTYPE, [-1, 1]); - expect(memory().numTensors).toEqual(numTensors + 1); - }); - }); - - describe('scatter', () => { - it('should scatter the input tensor', () => { - const input = tensor3d([1, 2, 3], [3, 1, 1], 'int32'); - const list = scatter(input, [0, 1, 2], [1, 1], 3); - expect(list.size()).toEqual(3); - }); - - it('should fail if indices and tensor shapes do not matched', () => { - const input = tensor3d([1, 2, 3], [3, 1, 1], 'int32'); - expect(() => scatter(input, [1, 2], [1, 1], 2)).toThrow(); - }); - - it('should fail if max index > array max size', () => { - const input = tensor3d([1, 2, 3], [3, 1, 1], 'int32'); - expect(() => scatter(input, [0, 1, 11], [1, 1], 3)).toThrow(); - }); - - it('should create three new tensors', () => { - const input = tensor3d([1, 2, 3], [3, 1, 1], 'int32'); - const numTensors: number = memory().numTensors; - scatter(input, [0, 1, 2], [1, 1], 3); - // Three tensors in the list and the idTensor - expect(memory().numTensors).toEqual(numTensors + 3 + 1); - }); - it('should not fail for wildcard shape', async () => { - const input = tensor3d([1, 2, 3], [3, 1, 1], 'int32'); - const list = scatter(input, [0, 1, 2], [-1, 1], 3); - expect(list.size()).toEqual(3); - }); - }); - - describe('split', () => { - it('should split the input tensor', () => { - const input = - tensor3d([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [3, 2, 2], 'int32'); - const list = split(input, [1, 1, 1], [2, 2]); - expect(list.size()).toEqual(3); - }); - - it('should fail if indices and tensor shapes do not matched', () => { - const input = tensor3d([1, 2, 3], [3, 1, 1], 'int32'); - expect(() => split(input, [1, 1], [1, 1])).toThrow(); - }); - - it('should create three new tensors', () => { - const input = - tensor3d([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [3, 2, 2], 'int32'); - const numTensors: number = memory().numTensors; - split(input, [1, 1, 1], [2, 2]); - // Three tensors in the list and the idTensor - expect(memory().numTensors).toEqual(numTensors + 3 + 1); - }); - it('should not fail for wildcard shape', async () => { - const input = - tensor3d([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [3, 2, 2], 'int32'); - const list = split(input, [1, 1, 1], [-1, 2]); - expect(list.size()).toEqual(3); - }); - }); -}); diff --git a/tfjs-master/tfjs-converter/src/executor/tensor_utils.ts b/tfjs-master/tfjs-converter/src/executor/tensor_utils.ts deleted file mode 100644 index 14ef48d4f..000000000 --- a/tfjs-master/tfjs-converter/src/executor/tensor_utils.ts +++ /dev/null @@ -1,113 +0,0 @@ - -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -/** - * This differs from util.assertShapesMatch in that it allows values of - * negative one, an undefined size of a dimensinon, in a shape to match - * anything. - */ - -import {Tensor, util} from '@tensorflow/tfjs-core'; - -/** - * Used by TensorList and TensorArray to verify if elementShape matches, support - * negative value as the dim shape. - * @param shapeA - * @param shapeB - * @param errorMessagePrefix - */ -export function assertShapesMatchAllowUndefinedSize( - shapeA: number|number[], shapeB: number|number[], - errorMessagePrefix = ''): void { - // constant shape means unknown rank - if (typeof shapeA === 'number' || typeof shapeB === 'number') { - return; - } - util.assert( - shapeA.length === shapeB.length, - () => errorMessagePrefix + ` Shapes ${shapeA} and ${shapeB} must match`); - for (let i = 0; i < shapeA.length; i++) { - const dim0 = shapeA[i]; - const dim1 = shapeB[i]; - util.assert( - dim0 < 0 || dim1 < 0 || dim0 === dim1, - () => - errorMessagePrefix + ` Shapes ${shapeA} and ${shapeB} must match`); - } -} - -export function fullDefinedShape(elementShape: number|number[]): boolean { - if (typeof elementShape === 'number' || elementShape.some(dim => dim < 0)) { - return false; - } - return true; -} -/** - * Generate the output element shape from the list elementShape, list tensors - * and input param. - * @param listElementShape - * @param tensors - * @param elementShape - */ -export function inferElementShape( - listElementShape: number|number[], tensors: Tensor[], - elementShape: number|number[]): number[] { - let partialShape = mergeElementShape(listElementShape, elementShape); - const notfullDefinedShape = !fullDefinedShape(partialShape); - if (notfullDefinedShape && tensors.length === 0) { - throw new Error( - `Tried to calculate elements of an empty list` + - ` with non-fully-defined elementShape: ${partialShape}`); - } - if (notfullDefinedShape) { - tensors.forEach(tensor => { - partialShape = mergeElementShape(tensor.shape, partialShape); - }); - } - if (!fullDefinedShape(partialShape)) { - throw new Error(`Non-fully-defined elementShape: ${partialShape}`); - } - return partialShape as number[]; -} - -export function mergeElementShape( - elementShapeA: number|number[], elementShapeB: number|number[]): number| - number[] { - if (typeof elementShapeA === 'number') { - return elementShapeB; - } - if (typeof elementShapeB === 'number') { - return elementShapeA; - } - - if (elementShapeA.length !== elementShapeB.length) { - throw new Error(`Incompatible ranks during merge: ${elementShapeA} vs. ${ - elementShapeB}`); - } - - const result: number[] = []; - for (let i = 0; i < elementShapeA.length; ++i) { - const dim0 = elementShapeA[i]; - const dim1 = elementShapeB[i]; - if (dim0 >= 0 && dim1 >= 0 && dim0 !== dim1) { - throw new Error(`Incompatible shape during merge: ${elementShapeA} vs. ${ - elementShapeB}`); - } - result[i] = dim0 >= 0 ? dim0 : dim1; - } - return result; -} diff --git a/tfjs-master/tfjs-converter/src/executor/test_data/hash_table_v2_model_loader.ts b/tfjs-master/tfjs-converter/src/executor/test_data/hash_table_v2_model_loader.ts deleted file mode 100644 index 622bda4e6..000000000 --- a/tfjs-master/tfjs-converter/src/executor/test_data/hash_table_v2_model_loader.ts +++ /dev/null @@ -1,342 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -export const HASH_TABLE_MODEL_V2 = { - modelTopology: { - node: [ - { - name: 'unknown_0', - op: 'Const', - attr: { - value: {tensor: {dtype: 'DT_INT32', tensorShape: {}}}, - dtype: {type: 'DT_INT32'} - } - }, - { - name: 'input', - op: 'Placeholder', - attr: - {shape: {shape: {dim: [{size: '-1'}]}}, dtype: {type: 'DT_STRING'}} - }, - { - name: 'unknown', - op: 'Placeholder', - attr: {shape: {shape: {}}, dtype: {type: 'DT_RESOURCE'}} - }, - { - name: 'StatefulPartitionedCall/None_Lookup/LookupTableFindV2', - op: 'LookupTableFindV2', - input: ['unknown', 'input', 'unknown_0'], - attr: { - Tout: {type: 'DT_INT32'}, - Tin: {type: 'DT_STRING'}, - _has_manual_control_dependencies: {b: true} - } - }, - { - name: 'Identity', - op: 'Identity', - input: ['StatefulPartitionedCall/None_Lookup/LookupTableFindV2'], - attr: {T: {type: 'DT_INT32'}} - } - ], - library: {}, - versions: {producer: 1240} - }, - format: 'graph-model', - generatedBy: '2.11.0-dev20220822', - convertedBy: 'TensorFlow.js Converter v1.7.0', - weightSpecs: [ - {name: 'unknown_0', shape: [], dtype: 'int32'}, - {name: '114', shape: [2], dtype: 'string'}, - {name: '116', shape: [2], dtype: 'int32'} - ], - 'weightData': - new Uint8Array([ - 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x61, 0x01, 0x00, - 0x00, 0x00, 0x62, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00 - ]).buffer, - - signature: { - inputs: { - input: { - name: 'input:0', - dtype: 'DT_STRING', - tensorShape: {dim: [{size: '-1'}]} - }, - 'unknown:0': { - name: 'unknown:0', - dtype: 'DT_RESOURCE', - tensorShape: {}, - resourceId: 66 - } - }, - outputs: { - output_0: { - name: 'Identity:0', - dtype: 'DT_INT32', - tensorShape: {dim: [{size: '-1'}]} - } - } - }, - modelInitializer: { - node: [ - { - name: 'Func/StatefulPartitionedCall/input_control_node/_0', - op: 'NoOp', - attr: {_has_manual_control_dependencies: {b: true}} - }, - { - name: '114', - op: 'Const', - attr: { - value: - {tensor: {dtype: 'DT_STRING', tensorShape: {dim: [{size: '2'}]}}}, - _has_manual_control_dependencies: {b: true}, - dtype: {type: 'DT_STRING'} - } - }, - { - name: '116', - op: 'Const', - attr: { - _has_manual_control_dependencies: {b: true}, - dtype: {type: 'DT_INT32'}, - value: - {tensor: {dtype: 'DT_INT32', tensorShape: {dim: [{size: '2'}]}}} - } - }, - { - name: - 'Func/StatefulPartitionedCall/StatefulPartitionedCall/input_control_node/_9', - op: 'NoOp', - input: ['^Func/StatefulPartitionedCall/input_control_node/_0'], - attr: {_has_manual_control_dependencies: {b: true}} - }, - { - name: 'StatefulPartitionedCall/StatefulPartitionedCall/hash_table', - op: 'HashTableV2', - input: [ - '^Func/StatefulPartitionedCall/StatefulPartitionedCall/input_control_node/_9' - ], - attr: { - container: {s: ''}, - use_node_name_sharing: {b: true}, - _has_manual_control_dependencies: {b: true}, - shared_name: {s: 'OTVfbG9hZF8xXzUy'}, - value_dtype: {type: 'DT_INT32'}, - key_dtype: {type: 'DT_STRING'} - } - }, - { - name: - 'Func/StatefulPartitionedCall/StatefulPartitionedCall/output_control_node/_11', - op: 'NoOp', - input: ['^StatefulPartitionedCall/StatefulPartitionedCall/hash_table'], - attr: {_has_manual_control_dependencies: {b: true}} - }, - { - name: 'Func/StatefulPartitionedCall/output_control_node/_2', - op: 'NoOp', - input: [ - '^Func/StatefulPartitionedCall/StatefulPartitionedCall/output_control_node/_11' - ], - attr: {_has_manual_control_dependencies: {b: true}} - }, - { - name: 'StatefulPartitionedCall/StatefulPartitionedCall/NoOp', - op: 'NoOp', - input: ['^StatefulPartitionedCall/StatefulPartitionedCall/hash_table'], - attr: { - _acd_function_control_output: {b: true}, - _has_manual_control_dependencies: {b: true} - } - }, - { - name: 'StatefulPartitionedCall/StatefulPartitionedCall/Identity', - op: 'Identity', - input: [ - 'StatefulPartitionedCall/StatefulPartitionedCall/hash_table', - '^StatefulPartitionedCall/StatefulPartitionedCall/NoOp' - ], - attr: {T: {type: 'DT_RESOURCE'}} - }, - { - name: 'Func/StatefulPartitionedCall/StatefulPartitionedCall/output/_10', - op: 'Identity', - input: ['StatefulPartitionedCall/StatefulPartitionedCall/Identity'], - attr: {T: {type: 'DT_RESOURCE'}} - }, - { - name: 'StatefulPartitionedCall/NoOp', - op: 'NoOp', - input: [ - '^Func/StatefulPartitionedCall/StatefulPartitionedCall/output_control_node/_11' - ], - attr: { - _has_manual_control_dependencies: {b: true}, - _acd_function_control_output: {b: true} - } - }, - { - name: 'StatefulPartitionedCall/Identity', - op: 'Identity', - input: [ - 'Func/StatefulPartitionedCall/StatefulPartitionedCall/output/_10', - '^StatefulPartitionedCall/NoOp' - ], - attr: {T: {type: 'DT_RESOURCE'}} - }, - { - name: 'Func/StatefulPartitionedCall/output/_1', - op: 'Identity', - input: ['StatefulPartitionedCall/Identity'], - attr: { - T: {type: 'DT_RESOURCE'}, - _has_manual_control_dependencies: {b: true} - } - }, - { - name: 'Func/StatefulPartitionedCall_1/input_control_node/_3', - op: 'NoOp', - input: ['^114', '^116', '^Func/StatefulPartitionedCall/output/_1'], - attr: {_has_manual_control_dependencies: {b: true}} - }, - { - name: 'Func/StatefulPartitionedCall_1/input/_4', - op: 'Identity', - input: [ - 'Func/StatefulPartitionedCall/output/_1', - '^Func/StatefulPartitionedCall_1/input_control_node/_3' - ], - attr: {T: {type: 'DT_RESOURCE'}} - }, - { - name: - 'Func/StatefulPartitionedCall_1/StatefulPartitionedCall/input_control_node/_12', - op: 'NoOp', - input: ['^Func/StatefulPartitionedCall_1/input_control_node/_3'], - attr: {_has_manual_control_dependencies: {b: true}} - }, - { - name: - 'Func/StatefulPartitionedCall_1/StatefulPartitionedCall/input/_13', - op: 'Identity', - input: [ - 'Func/StatefulPartitionedCall_1/input/_4', - '^Func/StatefulPartitionedCall_1/StatefulPartitionedCall/input_control_node/_12' - ], - attr: {T: {type: 'DT_RESOURCE'}} - }, - { - name: 'Func/StatefulPartitionedCall_1/input/_5', - op: 'Identity', - input: ['114', '^Func/StatefulPartitionedCall_1/input_control_node/_3'], - attr: {T: {type: 'DT_STRING'}} - }, - { - name: - 'Func/StatefulPartitionedCall_1/StatefulPartitionedCall/input/_14', - op: 'Identity', - input: [ - 'Func/StatefulPartitionedCall_1/input/_5', - '^Func/StatefulPartitionedCall_1/StatefulPartitionedCall/input_control_node/_12' - ], - attr: {T: {type: 'DT_STRING'}} - }, - { - name: 'Func/StatefulPartitionedCall_1/input/_6', - op: 'Identity', - input: ['116', '^Func/StatefulPartitionedCall_1/input_control_node/_3'], - attr: {T: {type: 'DT_INT32'}} - }, - { - name: - 'Func/StatefulPartitionedCall_1/StatefulPartitionedCall/input/_15', - op: 'Identity', - input: [ - 'Func/StatefulPartitionedCall_1/input/_6', - '^Func/StatefulPartitionedCall_1/StatefulPartitionedCall/input_control_node/_12' - ], - attr: {T: {type: 'DT_INT32'}} - }, - { - name: - 'StatefulPartitionedCall_1/StatefulPartitionedCall/key_value_init94/LookupTableImportV2', - op: 'LookupTableImportV2', - input: [ - 'Func/StatefulPartitionedCall_1/StatefulPartitionedCall/input/_13', - 'Func/StatefulPartitionedCall_1/StatefulPartitionedCall/input/_14', - 'Func/StatefulPartitionedCall_1/StatefulPartitionedCall/input/_15' - ], - attr: { - Tout: {type: 'DT_INT32'}, - Tin: {type: 'DT_STRING'}, - _has_manual_control_dependencies: {b: true} - } - }, - { - name: - 'Func/StatefulPartitionedCall_1/StatefulPartitionedCall/output_control_node/_17', - op: 'NoOp', - input: [ - '^StatefulPartitionedCall_1/StatefulPartitionedCall/key_value_init94/LookupTableImportV2' - ], - attr: {_has_manual_control_dependencies: {b: true}} - }, - { - name: 'Func/StatefulPartitionedCall_1/output_control_node/_8', - op: 'NoOp', - input: [ - '^Func/StatefulPartitionedCall_1/StatefulPartitionedCall/output_control_node/_17' - ], - attr: {_has_manual_control_dependencies: {b: true}} - }, - { - name: 'NoOp', - op: 'NoOp', - input: [ - '^Func/StatefulPartitionedCall/output_control_node/_2', - '^Func/StatefulPartitionedCall_1/output_control_node/_8' - ], - attr: { - _has_manual_control_dependencies: {b: true}, - _acd_function_control_output: {b: true} - } - }, - { - name: 'Identity', - op: 'Identity', - input: [ - 'Func/StatefulPartitionedCall/output/_1', - '^Func/StatefulPartitionedCall_1/output_control_node/_8', '^NoOp' - ], - attr: {T: {type: 'DT_RESOURCE'}} - } - ], - versions: {producer: 1240} - }, - initializerSignature: { - outputs: { - 'Identity:0': { - name: 'Identity:0', - dtype: 'DT_RESOURCE', - tensorShape: {}, - resourceId: 66 - } - } - } -}; diff --git a/tfjs-master/tfjs-converter/src/executor/test_data/structured_outputs_model_loader.ts b/tfjs-master/tfjs-converter/src/executor/test_data/structured_outputs_model_loader.ts deleted file mode 100644 index 2eb3ded12..000000000 --- a/tfjs-master/tfjs-converter/src/executor/test_data/structured_outputs_model_loader.ts +++ /dev/null @@ -1,210 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -export const STRUCTURED_OUTPUTS_MODEL = { - 'modelTopology': { - 'node': [ - { - 'name': 'StatefulPartitionedCall/model/concatenate/concat/axis', - 'op': 'Const', - 'attr': { - 'value': {'tensor': {'dtype': 'DT_INT32', 'tensorShape': {}}}, - 'dtype': {'type': 'DT_INT32'} - } - }, - { - 'name': 'StatefulPartitionedCall/model/a/MatMul/ReadVariableOp', - 'op': 'Const', - 'attr': { - 'dtype': {'type': 'DT_FLOAT'}, - 'value': { - 'tensor': { - 'dtype': 'DT_FLOAT', - 'tensorShape': {'dim': [{'size': '2'}, {'size': '1'}]} - } - } - } - }, - { - 'name': 'StatefulPartitionedCall/model/b/MatMul/ReadVariableOp', - 'op': 'Const', - 'attr': { - 'value': { - 'tensor': { - 'dtype': 'DT_FLOAT', - 'tensorShape': {'dim': [{'size': '1'}, {'size': '1'}]} - } - }, - 'dtype': {'type': 'DT_FLOAT'} - } - }, - { - 'name': 'input1', - 'op': 'Placeholder', - 'attr': { - 'dtype': {'type': 'DT_FLOAT'}, - 'shape': {'shape': {'dim': [{'size': '-1'}, {'size': '1'}]}} - } - }, - { - 'name': 'input2', - 'op': 'Placeholder', - 'attr': { - 'dtype': {'type': 'DT_FLOAT'}, - 'shape': {'shape': {'dim': [{'size': '-1'}, {'size': '1'}]}} - } - }, - { - 'name': 'input3', - 'op': 'Placeholder', - 'attr': { - 'shape': {'shape': {'dim': [{'size': '-1'}, {'size': '1'}]}}, - 'dtype': {'type': 'DT_FLOAT'} - } - }, - { - 'name': 'StatefulPartitionedCall/model/b/MatMul', - 'op': 'MatMul', - 'input': - ['input2', 'StatefulPartitionedCall/model/b/MatMul/ReadVariableOp'], - 'device': '/device:CPU:0', - 'attr': { - 'transpose_b': {'b': false}, - 'transpose_a': {'b': false}, - 'T': {'type': 'DT_FLOAT'} - } - }, - { - 'name': 'StatefulPartitionedCall/model/concatenate/concat', - 'op': 'ConcatV2', - 'input': [ - 'input1', 'input3', - 'StatefulPartitionedCall/model/concatenate/concat/axis' - ], - 'attr': { - 'Tidx': {'type': 'DT_INT32'}, - 'T': {'type': 'DT_FLOAT'}, - 'N': {'i': '2'} - } - }, - { - 'name': 'Identity_1', - 'op': 'Identity', - 'input': ['StatefulPartitionedCall/model/b/MatMul'], - 'attr': {'T': {'type': 'DT_FLOAT'}} - }, - { - 'name': 'StatefulPartitionedCall/model/a/MatMul', - 'op': 'MatMul', - 'input': [ - 'StatefulPartitionedCall/model/concatenate/concat', - 'StatefulPartitionedCall/model/a/MatMul/ReadVariableOp' - ], - 'device': '/device:CPU:0', - 'attr': { - 'T': {'type': 'DT_FLOAT'}, - 'transpose_b': {'b': false}, - 'transpose_a': {'b': false} - } - }, - { - 'name': 'Identity', - 'op': 'Identity', - 'input': ['StatefulPartitionedCall/model/a/MatMul'], - 'attr': {'T': {'type': 'DT_FLOAT'}} - }, - { - 'name': 'StatefulPartitionedCall/model/c/mul', - 'op': 'Mul', - 'input': [ - 'StatefulPartitionedCall/model/a/MatMul', - 'StatefulPartitionedCall/model/b/MatMul' - ], - 'attr': {'T': {'type': 'DT_FLOAT'}} - }, - { - 'name': 'Identity_2', - 'op': 'Identity', - 'input': ['StatefulPartitionedCall/model/c/mul'], - 'attr': {'T': {'type': 'DT_FLOAT'}} - } - ], - 'library': {}, - 'versions': {'producer': 898} - }, - 'format': 'graph-model', - 'generatedBy': '2.7.3', - 'convertedBy': 'TensorFlow.js Converter v1.7.0', - 'weightSpecs': [ - { - 'name': 'StatefulPartitionedCall/model/concatenate/concat/axis', - 'shape': [], - 'dtype': 'int32' - }, - { - 'name': 'StatefulPartitionedCall/model/a/MatMul/ReadVariableOp', - 'shape': [2, 1], - 'dtype': 'float32' - }, - { - 'name': 'StatefulPartitionedCall/model/b/MatMul/ReadVariableOp', - 'shape': [1, 1], - 'dtype': 'float32' - } - ], - 'weightData': new Uint8Array([ - 0x01, 0x00, 0x00, 0x00, 0x70, 0x3d, 0x72, 0x3e, 0x3d, 0xd2, - 0x12, 0xbf, 0x0c, 0xfb, 0x94, 0x3e - ]).buffer, - 'signature': { - 'inputs': { - 'input1:0': { - 'name': 'input1:0', - 'dtype': 'DT_FLOAT', - 'tensorShape': {'dim': [{'size': '-1'}, {'size': '1'}]} - }, - 'input3:0': { - 'name': 'input3:0', - 'dtype': 'DT_FLOAT', - 'tensorShape': {'dim': [{'size': '-1'}, {'size': '1'}]} - }, - 'input2:0': { - 'name': 'input2:0', - 'dtype': 'DT_FLOAT', - 'tensorShape': {'dim': [{'size': '-1'}, {'size': '1'}]} - } - }, - 'outputs': { - 'Identity_1:0': { - 'name': 'Identity_1:0', - 'dtype': 'DT_FLOAT', - 'tensorShape': {'dim': [{'size': '-1'}, {'size': '1'}]} - }, - 'Identity:0': { - 'name': 'Identity:0', - 'dtype': 'DT_FLOAT', - 'tensorShape': {'dim': [{'size': '-1'}, {'size': '1'}]} - }, - 'Identity_2:0': { - 'name': 'Identity_2:0', - 'dtype': 'DT_FLOAT', - 'tensorShape': {'dim': [{'size': '-1'}, {'size': '1'}]} - } - } - }, - 'userDefinedMetadata': {'structuredOutputKeys': ['a', 'b', 'c']} -}; diff --git a/tfjs-master/tfjs-converter/src/executor/types.ts b/tfjs-master/tfjs-converter/src/executor/types.ts deleted file mode 100644 index d225f4ac8..000000000 --- a/tfjs-master/tfjs-converter/src/executor/types.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Tensor} from '@tensorflow/tfjs-core'; - -import {NamedTensorsMap, TensorArrayMap, TensorListMap} from '../data/types'; - -/** - * - */ -export interface FunctionExecutor { - executeFunctionAsync( - inputs: Tensor[], tensorArrayMap: TensorArrayMap, - tensorListMap: TensorListMap): Promise; - weightMap: NamedTensorsMap; -} diff --git a/tfjs-master/tfjs-converter/src/flags.ts b/tfjs-master/tfjs-converter/src/flags.ts deleted file mode 100644 index 56f868259..000000000 --- a/tfjs-master/tfjs-converter/src/flags.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {env} from '@tensorflow/tfjs-core'; - -const ENV = env(); - -/** Whether to keep intermediate tensors. */ -ENV.registerFlag('KEEP_INTERMEDIATE_TENSORS', () => false, debugValue => { - if (debugValue) { - console.warn( - 'Keep intermediate tensors is ON. This will print the values of all ' + - 'intermediate tensors during model inference. Not all models ' + - 'support this mode. For details, check e2e/benchmarks/ ' + - 'model_config.js. This significantly impacts performance.'); - } -}); diff --git a/tfjs-master/tfjs-converter/src/index.ts b/tfjs-master/tfjs-converter/src/index.ts deleted file mode 100644 index e6abafdd3..000000000 --- a/tfjs-master/tfjs-converter/src/index.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import './flags'; - -export {IAttrValue, INameAttrList, INodeDef, ITensor, ITensorShape} from './data/compiled_api'; -export {GraphModel, loadGraphModel, loadGraphModelSync} from './executor/graph_model'; -export {deregisterOp, registerOp} from './operations/custom_op/register'; -export {GraphNode, OpExecutor} from './operations/types'; -export {version as version_converter} from './version'; diff --git a/tfjs-master/tfjs-converter/src/metadata_test.ts b/tfjs-master/tfjs-converter/src/metadata_test.ts deleted file mode 100644 index 16cb03219..000000000 --- a/tfjs-master/tfjs-converter/src/metadata_test.ts +++ /dev/null @@ -1,104 +0,0 @@ -/** - * @license - * Copyright 2020 Google Inc. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// This test checks the metadata.json to make sure that only the kernels that -// we know we don't map to tfjs ops have empty entries in metadata -// kernel2op.json -describe('kernel2op metadata file', () => { - it('has kernel2op.json', () => { - expect(() => { - // tslint:disable-next-line:no-require-imports - require('tfjs-converter/metadata/kernel2op.json'); - }).not.toThrow(); - }); - - it('only known unmapped kernel are unmmapped', () => { - const knownUnmappedKernels = [ - 'Const', - 'EmptyTensorList', - 'Enter', - 'Exit', - 'FakeQuantWithMinMaxVars', - 'Identity', - 'IdentityN', - 'If', - 'LoopCond', - 'Merge', - 'NextIteration', - 'Placeholder', - 'PlaceholderWithDefault', - 'Print', - 'Snapshot', - 'StatelessIf', - 'StatelessWhile', - 'StopGradient', - 'Switch', - 'TensorArrayCloseV3', - 'TensorArrayConcatV3', - 'TensorArrayGatherV3', - 'TensorArrayReadV3', - 'TensorArrayScatterV3', - 'TensorArraySizeV3', - 'TensorArraySplitV3', - 'TensorArrayV3', - 'TensorArrayWriteV3', - 'TensorListConcat', - 'TensorListConcatV2', - 'TensorListFromTensor', - 'TensorListGather', - 'TensorListGetItem', - 'TensorListLength', - 'TensorListPopBack', - 'TensorListPushBack', - 'TensorListReserve', - 'TensorListResize', - 'TensorListScatter', - 'TensorListScatterV2', - 'TensorListSetItem', - 'TensorListSplit', - 'TensorListStack', - 'While', - 'HashTable', - 'HashTableV2', - 'LookupTableImport', - 'LookupTableImportV2', - 'LookupTableFind', - 'LookupTableFindV2', - 'LookupTableSize', - 'LookupTableSizeV2', - 'InitializeTable', - 'InitializeTableV2', - ]; - // tslint:disable-next-line:no-require-imports - const kernel2op = require('tfjs-converter/metadata/kernel2op.json'); - const kernels: string[] = Object.keys(kernel2op); - - for (const kernelName of kernels) { - const tfOps = kernel2op[kernelName]; - if (knownUnmappedKernels.includes(kernelName)) { - expect(tfOps.length) - .toEqual(0, `Kernel "${kernelName}" is expected to be unmapped but - instead maps to ${tfOps}`); - } else { - expect(tfOps.length) - .toBeGreaterThan( - 0, `Kernel ${kernelName} is expected to be mapped to a list - of tf ops`); - } - } - }); -}); diff --git a/tfjs-master/tfjs-converter/src/operations/custom_op/node_value_impl.ts b/tfjs-master/tfjs-converter/src/operations/custom_op/node_value_impl.ts deleted file mode 100644 index 349811c14..000000000 --- a/tfjs-master/tfjs-converter/src/operations/custom_op/node_value_impl.ts +++ /dev/null @@ -1,103 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {DataType, Tensor} from '@tensorflow/tfjs-core'; - -import {NamedTensorsMap} from '../../data/types'; -import {ExecutionContext} from '../../executor/execution_context'; -import {getTensor} from '../executors/utils'; -import {getBoolArrayParam, getBoolParam, getDtypeArrayParam, getDtypeParam, getNumberParam, getNumericArrayParam, getStringArrayParam, getStringParam, getTensorShapeArrayParam, getTensorShapeParam} from '../operation_mapper'; -import {GraphNode, Node, ValueType} from '../types'; - -/** - * Helper class for lookup inputs and params for nodes in the model graph. - */ -export class NodeValueImpl implements GraphNode { - public readonly inputs: Tensor[] = []; - public readonly attrs: {[key: string]: ValueType} = {}; - constructor( - private node: Node, private tensorMap: NamedTensorsMap, - private context: ExecutionContext) { - this.inputs = node.inputNames.map(name => this.getInput(name)); - if (node.rawAttrs != null) { - this.attrs = Object.keys(node.rawAttrs) - .reduce((attrs: {[key: string]: ValueType}, key) => { - attrs[key] = this.getAttr(key); - return attrs; - }, {}); - } - } - - /** - * Return the value of the attribute or input param. - * @param name String: name of attribute or input param. - */ - private getInput(name: string): Tensor { - return getTensor(name, this.tensorMap, this.context); - } - - /** - * Return the value of the attribute or input param. - * @param name String: name of attribute or input param. - */ - private getAttr(name: string, defaultValue?: ValueType): ValueType { - const value = this.node.rawAttrs[name]; - if (value.tensor != null) { - return getTensor(name, this.tensorMap, this.context); - } - if (value.i != null || value.f != null) { - return getNumberParam(this.node.rawAttrs, name, defaultValue as number); - } - if (value.s != null) { - return getStringParam(this.node.rawAttrs, name, defaultValue as string); - } - if (value.b != null) { - return getBoolParam(this.node.rawAttrs, name, defaultValue as boolean); - } - if (value.shape != null) { - return getTensorShapeParam( - this.node.rawAttrs, name, defaultValue as number[]); - } - if (value.type != null) { - return getDtypeParam(this.node.rawAttrs, name, defaultValue as DataType); - } - if (value.list != null) { - if (value.list.i != null || value.list.f != null) { - return getNumericArrayParam( - this.node.rawAttrs, name, defaultValue as number[]); - } - if (value.list.s != null) { - return getStringArrayParam( - this.node.rawAttrs, name, defaultValue as string[]); - } - if (value.list.shape != null) { - return getTensorShapeArrayParam( - this.node.rawAttrs, name, defaultValue as number[][]); - } - if (value.list.b != null) { - return getBoolArrayParam( - this.node.rawAttrs, name, defaultValue as boolean[]); - } - if (value.list.type != null) { - return getDtypeArrayParam( - this.node.rawAttrs, name, defaultValue as DataType[]); - } - } - - return defaultValue; - } -} diff --git a/tfjs-master/tfjs-converter/src/operations/custom_op/node_value_impl_test.ts b/tfjs-master/tfjs-converter/src/operations/custom_op/node_value_impl_test.ts deleted file mode 100644 index ab304eee0..000000000 --- a/tfjs-master/tfjs-converter/src/operations/custom_op/node_value_impl_test.ts +++ /dev/null @@ -1,115 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {scalar, test_util} from '@tensorflow/tfjs-core'; - -import * as tensorflow from '../../data/compiled_api'; -import {ExecutionContext} from '../../executor/execution_context'; -import {Node} from '../types'; - -import {NodeValueImpl} from './node_value_impl'; - -const NODE: Node = { - name: 'test', - op: 'const', - category: 'custom', - inputNames: ['a', 'b'], - inputs: [], - inputParams: {}, - attrParams: {}, - children: [], - rawAttrs: { - c: {tensor: {}}, - d: {i: 3}, - e: {s: 'TkhXQw=='}, - f: {type: tensorflow.DataType.DT_FLOAT}, - g: {b: true}, - h: {f: 4.5}, - i: {list: {i: [3, 6, 0]}}, - j: {list: {f: [4.5, 5.5, 0.0]}}, - k: {list: {s: ['TkhXQw==', 'TkhXQw==', '']}}, - l: { - list: - {type: [tensorflow.DataType.DT_FLOAT, tensorflow.DataType.DT_INT32]} - }, - m: {shape: {dim: [{name: 'a', size: 1}, {name: 'b', size: 2}]}}, - n: { - list: { - shape: [ - {dim: [{name: 'a', size: 1}, {name: 'b', size: 2}]}, - {dim: [{name: 'c', size: 2}, {name: 'd', size: 3}]} - ] - } - }, - o: {list: {b: [true, false]}} - } -}; -const TENSOR_MAP = { - 'a': [scalar(1)], - 'b': [scalar(2)], - 'test': [scalar(3)] -}; - -let nodeValue: NodeValueImpl; -describe('NodeValueImpl', () => { - beforeEach(() => { - nodeValue = - new NodeValueImpl(NODE, TENSOR_MAP, new ExecutionContext({}, {}, {})); - }); - describe('getInput', () => { - it('should find tensor from tensormap', async () => { - const result = nodeValue.inputs[0]; - test_util.expectArraysClose(await result.data(), [1]); - - const result2 = nodeValue.inputs[1]; - test_util.expectArraysClose(await result2.data(), [2]); - }); - }); - describe('getAttr', () => { - it('should parse number', () => { - expect(nodeValue.attrs['d']).toEqual(3); - expect(nodeValue.attrs['h']).toEqual(4.5); - }); - it('should parse number[]', () => { - expect(nodeValue.attrs['i']).toEqual([3, 6, 0]); - expect(nodeValue.attrs['j']).toEqual([4.5, 5.5, 0.0]); - }); - it('should parse string', () => { - expect(nodeValue.attrs['e']).toEqual('nhwc'); - }); - it('should parse string[]', () => { - expect(nodeValue.attrs['k']).toEqual(['nhwc', 'nhwc', '']); - }); - it('should parse boolean', () => { - expect(nodeValue.attrs['g']).toEqual(true); - }); - it('should parse boolean[]', () => { - expect(nodeValue.attrs['o']).toEqual([true, false]); - }); - it('should parse dtype', () => { - expect(nodeValue.attrs['f']).toEqual('float32'); - }); - it('should parse dtype[]', () => { - expect(nodeValue.attrs['l']).toEqual(['float32', 'int32']); - }); - it('should parse tensor shape', () => { - expect(nodeValue.attrs['m']).toEqual([1, 2]); - }); - it('should parse tensor shape[]', () => { - expect(nodeValue.attrs['n']).toEqual([[1, 2], [2, 3]]); - }); - }); -}); diff --git a/tfjs-master/tfjs-converter/src/operations/custom_op/register.ts b/tfjs-master/tfjs-converter/src/operations/custom_op/register.ts deleted file mode 100644 index a913636d7..000000000 --- a/tfjs-master/tfjs-converter/src/operations/custom_op/register.ts +++ /dev/null @@ -1,80 +0,0 @@ - -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {OpExecutor, OpMapper} from '../types'; - -const CUSTOM_OPS: {[key: string]: OpMapper} = {}; - -/** - * Register an Op for graph model executor. This allows you to register - * TensorFlow custom op or override existing op. - * - * Here is an example of registering a new MatMul Op. - * ```js - * const customMatmul = (node) => - * tf.matMul( - * node.inputs[0], node.inputs[1], - * node.attrs['transpose_a'], node.attrs['transpose_b']); - * - * tf.registerOp('MatMul', customMatmul); - * ``` - * The inputs and attrs of the node object are based on the TensorFlow op - * registry. - * - * @param name The Tensorflow Op name. - * @param opFunc An op function which is called with the current graph node - * during execution and needs to return a tensor or a list of tensors. The node - * has the following attributes: - * - attr: A map from attribute name to its value - * - inputs: A list of input tensors - * - * @doc {heading: 'Models', subheading: 'Op Registry'} - */ -export function registerOp(name: string, opFunc: OpExecutor) { - const opMapper: OpMapper = { - tfOpName: name, - category: 'custom', - inputs: [], - attrs: [], - customExecutor: opFunc - }; - - CUSTOM_OPS[name] = opMapper; -} - -/** - * Retrieve the OpMapper object for the registered op. - * - * @param name The Tensorflow Op name. - * - * @doc {heading: 'Models', subheading: 'Op Registry'} - */ -export function getRegisteredOp(name: string): OpMapper { - return CUSTOM_OPS[name]; -} - -/** - * Deregister the Op for graph model executor. - * - * @param name The Tensorflow Op name. - * - * @doc {heading: 'Models', subheading: 'Op Registry'} - */ -export function deregisterOp(name: string) { - delete CUSTOM_OPS[name]; -} diff --git a/tfjs-master/tfjs-converter/src/operations/custom_op/register_test.ts b/tfjs-master/tfjs-converter/src/operations/custom_op/register_test.ts deleted file mode 100644 index 65998ad70..000000000 --- a/tfjs-master/tfjs-converter/src/operations/custom_op/register_test.ts +++ /dev/null @@ -1,44 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {scalar} from '@tensorflow/tfjs-core'; - -import {deregisterOp, getRegisteredOp, registerOp} from './register'; - -describe('register custom op', () => { - describe('registerCustomOp', () => { - it('should auto fill missing fields', () => { - const executor = () => scalar(1); - registerOp('newOp', executor); - const opMapper = getRegisteredOp('newOp'); - expect(opMapper.tfOpName).toEqual('newOp'); - expect(opMapper.category).toEqual('custom'); - expect(opMapper.inputs).toEqual([]); - expect(opMapper.attrs).toEqual([]); - expect(opMapper.customExecutor).toEqual(executor); - deregisterOp('newOp'); - }); - }); - describe('deregisterOp', () => { - it('should remove the custom op', () => { - registerOp('newOp', () => scalar(1)); - expect(getRegisteredOp('newOp')).toBeDefined(); - deregisterOp('newOp'); - expect(getRegisteredOp('newOp')).not.toBeDefined(); - }); - }); -}); diff --git a/tfjs-master/tfjs-converter/src/operations/executors/arithmetic_executor.ts b/tfjs-master/tfjs-converter/src/operations/executors/arithmetic_executor.ts deleted file mode 100644 index 35e8f590b..000000000 --- a/tfjs-master/tfjs-converter/src/operations/executors/arithmetic_executor.ts +++ /dev/null @@ -1,98 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Tensor} from '@tensorflow/tfjs-core'; -// tslint:disable-next-line: no-imports-from-dist -import * as tfOps from '@tensorflow/tfjs-core/dist/ops/ops_for_converter'; - -import {NamedTensorsMap} from '../../data/types'; -import {ExecutionContext} from '../../executor/execution_context'; -import {InternalOpExecutor, Node} from '../types'; - -import {getParamValue} from './utils'; - -export const executeOp: InternalOpExecutor = - (node: Node, tensorMap: NamedTensorsMap, - context: ExecutionContext, ops = tfOps): Tensor[] => { - switch (node.op) { - case 'BiasAdd': - case 'AddV2': - case 'Add': { - return [ops.add( - (getParamValue('a', node, tensorMap, context) as Tensor), - getParamValue('b', node, tensorMap, context) as Tensor)]; - } - case 'AddN': { - return [ops.addN(( - getParamValue('tensors', node, tensorMap, context) as Tensor[]))]; - } - case 'FloorMod': - case 'Mod': - return [ops.mod( - getParamValue('a', node, tensorMap, context) as Tensor, - getParamValue('b', node, tensorMap, context) as Tensor)]; - case 'Mul': - return [ops.mul( - getParamValue('a', node, tensorMap, context) as Tensor, - getParamValue('b', node, tensorMap, context) as Tensor)]; - case 'RealDiv': - case 'Div': { - return [ops.div( - getParamValue('a', node, tensorMap, context) as Tensor, - getParamValue('b', node, tensorMap, context) as Tensor)]; - } - case 'DivNoNan': { - return [ops.divNoNan( - getParamValue('a', node, tensorMap, context) as Tensor, - getParamValue('b', node, tensorMap, context) as Tensor)]; - } - case 'FloorDiv': { - return [ops.floorDiv( - getParamValue('a', node, tensorMap, context) as Tensor, - getParamValue('b', node, tensorMap, context) as Tensor)]; - } - case 'Sub': { - return [ops.sub( - getParamValue('a', node, tensorMap, context) as Tensor, - getParamValue('b', node, tensorMap, context) as Tensor)]; - } - case 'Minimum': { - return [ops.minimum( - getParamValue('a', node, tensorMap, context) as Tensor, - getParamValue('b', node, tensorMap, context) as Tensor)]; - } - case 'Maximum': { - return [ops.maximum( - getParamValue('a', node, tensorMap, context) as Tensor, - getParamValue('b', node, tensorMap, context) as Tensor)]; - } - case 'Pow': { - return [ops.pow( - getParamValue('a', node, tensorMap, context) as Tensor, - getParamValue('b', node, tensorMap, context) as Tensor)]; - } - case 'SquaredDifference': { - return [ops.squaredDifference( - getParamValue('a', node, tensorMap, context) as Tensor, - getParamValue('b', node, tensorMap, context) as Tensor)]; - } - default: - throw TypeError(`Node type ${node.op} is not implemented`); - } - }; - -export const CATEGORY = 'arithmetic'; diff --git a/tfjs-master/tfjs-converter/src/operations/executors/arithmetic_executor_test.ts b/tfjs-master/tfjs-converter/src/operations/executors/arithmetic_executor_test.ts deleted file mode 100644 index 6b07ec604..000000000 --- a/tfjs-master/tfjs-converter/src/operations/executors/arithmetic_executor_test.ts +++ /dev/null @@ -1,95 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Tensor, test_util} from '@tensorflow/tfjs-core'; -// tslint:disable-next-line: no-imports-from-dist -import * as tfOps from '@tensorflow/tfjs-core/dist/ops/ops_for_converter'; - -import {ExecutionContext} from '../../executor/execution_context'; -import {Node} from '../types'; - -import {executeOp} from './arithmetic_executor'; -import {createTensorAttr, createTensorsAttr, uncapitalize} from './test_helper'; -import {RecursiveSpy, spyOnAllFunctions} from './spy_ops'; - -describe('arithmetic', () => { - let node: Node; - const input1 = [tfOps.scalar(1)]; - const input2 = [tfOps.scalar(1)]; - const input3 = [tfOps.scalar(4)]; - const context = new ExecutionContext({}, {}, {}); - - beforeEach(() => { - node = { - name: 'test', - op: '', - category: 'arithmetic', - inputNames: ['input1', 'input2'], - inputs: [], - inputParams: {a: createTensorAttr(0), b: createTensorAttr(1)}, - attrParams: {}, - children: [] - }; - }); - - describe('executeOp', () => { - let spyOps: RecursiveSpy; - let spyOpsAsTfOps: typeof tfOps; - - beforeEach(() => { - spyOps = spyOnAllFunctions(tfOps); - spyOpsAsTfOps = spyOps as unknown as typeof tfOps; - }); - - (['Add', 'Mul', 'Div', 'Sub', 'Maximum', 'Minimum', 'Pow', - 'SquaredDifference', 'Mod', 'FloorDiv', 'DivNoNan'] as const) - .forEach((op => { - it('should call tfOps.' + op, () => { - node.op = op; - executeOp(node, {input1, input2}, context, spyOpsAsTfOps); - - expect(spyOps[uncapitalize(op)]) - .toHaveBeenCalledWith(input1[0], input2[0]); - }); - })); - - it('AddV2', async () => { - - node.op = 'AddV2'; - const res = executeOp(node, {input1, input2}, context, - spyOpsAsTfOps) as Tensor[]; - expect(spyOps.add).toHaveBeenCalledWith(input1[0], input2[0]); - expect(res[0].dtype).toBe('float32'); - expect(res[0].shape).toEqual([]); - test_util.expectArraysClose(await res[0].data(), 2); - }); - - it('AddN', async () => { - node.op = 'AddN'; - node.inputParams = {tensors: createTensorsAttr(0, 0)}; - node.inputNames = ['input1', 'input2', 'input3']; - const res = - executeOp(node, {input1, input2, input3}, context, - spyOpsAsTfOps) as Tensor[]; - expect(spyOps.addN) - .toHaveBeenCalledWith([input1[0], input2[0], input3[0]]); - expect(res[0].dtype).toBe('float32'); - expect(res[0].shape).toEqual([]); - test_util.expectArraysClose(await res[0].data(), [6]); - }); - }); -}); diff --git a/tfjs-master/tfjs-converter/src/operations/executors/basic_math_executor.ts b/tfjs-master/tfjs-converter/src/operations/executors/basic_math_executor.ts deleted file mode 100644 index 530cd7757..000000000 --- a/tfjs-master/tfjs-converter/src/operations/executors/basic_math_executor.ts +++ /dev/null @@ -1,182 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Tensor} from '@tensorflow/tfjs-core'; -// tslint:disable-next-line: no-imports-from-dist -import * as tfOps from '@tensorflow/tfjs-core/dist/ops/ops_for_converter'; - -import {NamedTensorsMap} from '../../data/types'; -import {ExecutionContext} from '../../executor/execution_context'; -import {InternalOpExecutor, Node} from '../types'; - -import {getParamValue, getTensor} from './utils'; - -export const executeOp: InternalOpExecutor = - (node: Node, tensorMap: NamedTensorsMap, context: ExecutionContext, - ops = tfOps): Tensor[] => { - switch (node.op) { - case 'Abs': - case 'ComplexAbs': - return [ops.abs( - getParamValue('x', node, tensorMap, context) as Tensor)]; - case 'Acos': - return [ops.acos( - getParamValue('x', node, tensorMap, context) as Tensor)]; - case 'Acosh': - return [ops.acosh( - getParamValue('x', node, tensorMap, context) as Tensor)]; - case 'Asin': - return [ops.asin( - getParamValue('x', node, tensorMap, context) as Tensor)]; - case 'Asinh': - return [ops.asinh( - getParamValue('x', node, tensorMap, context) as Tensor)]; - case 'Atan': - return [ops.atan( - getParamValue('x', node, tensorMap, context) as Tensor)]; - case 'Atan2': - return [ops.atan2( - getParamValue('x', node, tensorMap, context) as Tensor, - getParamValue('y', node, tensorMap, context) as Tensor)]; - case 'Atanh': - return [ops.atanh( - getParamValue('x', node, tensorMap, context) as Tensor)]; - case 'Ceil': - return [ops.ceil( - getParamValue('x', node, tensorMap, context) as Tensor)]; - case 'Complex': - return [ops.complex( - getParamValue('real', node, tensorMap, context) as Tensor, - getParamValue('imag', node, tensorMap, context) as Tensor)]; - case 'Cos': - return [ops.cos( - getParamValue('x', node, tensorMap, context) as Tensor)]; - case 'Cosh': - return [ops.cosh( - getParamValue('x', node, tensorMap, context) as Tensor)]; - case 'Elu': - return [ops.elu( - getParamValue('x', node, tensorMap, context) as Tensor)]; - case 'Erf': - return [ops.erf( - getParamValue('x', node, tensorMap, context) as Tensor)]; - case 'Exp': - return [ops.exp( - getParamValue('x', node, tensorMap, context) as Tensor)]; - case 'Expm1': { - return [ops.expm1( - getParamValue('x', node, tensorMap, context) as Tensor)]; - } - case 'Floor': - return [ops.floor( - getParamValue('x', node, tensorMap, context) as Tensor)]; - case 'Log': - return [ops.log( - getParamValue('x', node, tensorMap, context) as Tensor)]; - case 'Log1p': { - return [ops.log1p( - getParamValue('x', node, tensorMap, context) as Tensor)]; - } - case 'Imag': - return [ops.imag( - getParamValue('x', node, tensorMap, context) as Tensor)]; - - case 'Neg': - return [ops.neg( - getParamValue('x', node, tensorMap, context) as Tensor)]; - case 'Reciprocal': { - return [ops.reciprocal( - getParamValue('x', node, tensorMap, context) as Tensor)]; - } - case 'Real': - return [ops.real( - getParamValue('x', node, tensorMap, context) as Tensor)]; - case 'Relu': - return [ops.relu( - getParamValue('x', node, tensorMap, context) as Tensor)]; - case 'Round': { - return [ops.round( - getParamValue('x', node, tensorMap, context) as Tensor)]; - } - case 'Selu': - return [ops.selu( - getParamValue('x', node, tensorMap, context) as Tensor)]; - case 'Sigmoid': - return [ops.sigmoid( - getParamValue('x', node, tensorMap, context) as Tensor)]; - case 'Sin': - return [ops.sin( - getParamValue('x', node, tensorMap, context) as Tensor)]; - case 'Sign': { - return [ops.sign( - getParamValue('x', node, tensorMap, context) as Tensor)]; - } - case 'Sinh': { - return [ops.sinh( - getParamValue('x', node, tensorMap, context) as Tensor)]; - } - case 'Softplus': { - return [ops.softplus( - getParamValue('x', node, tensorMap, context) as Tensor)]; - } - case 'Sqrt': { - return [ops.sqrt( - getParamValue('x', node, tensorMap, context) as Tensor)]; - } - case 'Square': { - return [ops.square( - getParamValue('x', node, tensorMap, context) as Tensor)]; - } - case 'Tanh': { - return [ops.tanh( - getParamValue('x', node, tensorMap, context) as Tensor)]; - } - case 'Tan': - return [ops.tan( - getParamValue('x', node, tensorMap, context) as Tensor)]; - case 'ClipByValue': - return [ops.clipByValue( - getParamValue('x', node, tensorMap, context) as Tensor, - getParamValue('clipValueMin', node, tensorMap, context) as number, - getParamValue('clipValueMax', node, tensorMap, context) as - number)]; - case 'Relu6': - return [ops.relu6( - getParamValue('x', node, tensorMap, context) as Tensor)]; - case 'Rsqrt': - return [ops.rsqrt(getTensor(node.inputNames[0], tensorMap, context))]; - case 'LeakyRelu': - return [ops.leakyRelu( - getParamValue('x', node, tensorMap, context) as Tensor, - getParamValue('alpha', node, tensorMap, context) as number)]; - case 'Prelu': - return [ops.prelu( - getParamValue('x', node, tensorMap, context) as Tensor, - getParamValue('alpha', node, tensorMap, context) as Tensor)]; - case 'IsNan': - return [ops.isNaN(getTensor(node.inputNames[0], tensorMap, context))]; - case 'IsInf': - return [ops.isInf(getTensor(node.inputNames[0], tensorMap, context))]; - case 'IsFinite': - return [ops.isFinite( - getTensor(node.inputNames[0], tensorMap, context))]; - default: - throw TypeError(`Node type ${node.op} is not implemented`); - } - }; - -export const CATEGORY = 'basic_math'; diff --git a/tfjs-master/tfjs-converter/src/operations/executors/basic_math_executor_test.ts b/tfjs-master/tfjs-converter/src/operations/executors/basic_math_executor_test.ts deleted file mode 100644 index 5d545d4a2..000000000 --- a/tfjs-master/tfjs-converter/src/operations/executors/basic_math_executor_test.ts +++ /dev/null @@ -1,255 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {scalar} from '@tensorflow/tfjs-core'; -// tslint:disable-next-line: no-imports-from-dist -import * as tfOps from '@tensorflow/tfjs-core/dist/ops/ops_for_converter'; - -import {ExecutionContext} from '../../executor/execution_context'; -import * as basic_math from '../op_list/basic_math'; -import {Node} from '../types'; - -import {executeOp} from './basic_math_executor'; -import {RecursiveSpy, spyOnAllFunctions} from './spy_ops'; -import {createNumberAttr, createNumberAttrFromIndex, createTensorAttr, uncapitalize, validateParam} from './test_helper'; - -describe('basic math', () => { - let node: Node; - const input1 = [scalar(1)]; - const context = new ExecutionContext({}, {}, {}); - - beforeEach(() => { - node = { - name: 'test', - op: '', - category: 'basic_math', - inputNames: ['input1'], - inputs: [], - inputParams: {x: createTensorAttr(0)}, - attrParams: {}, - children: [] - }; - }); - - describe('executeOp', () => { - let spyOps: RecursiveSpy; - let spyOpsAsTfOps: typeof tfOps; - - beforeEach(() => { - spyOps = spyOnAllFunctions(tfOps); - spyOpsAsTfOps = spyOps as unknown as typeof tfOps; - }); - - ([ - 'Abs', 'Acos', 'Asin', 'Atan', 'Ceil', 'Cos', 'Cosh', - 'Elu', 'Exp', 'Floor', 'Log', 'Imag', 'Neg', 'Real', - 'Relu', 'Selu', 'Sigmoid', 'Sin', 'Sinh', 'Sqrt', 'Square', - 'Tanh', 'Tan', 'Sign', 'Round', 'Expm1', 'Log1p', 'Reciprocal', - 'Softplus', 'Asinh', 'Acosh', 'Atanh', 'Erf' - ] as const ) - .forEach(op => { - it('should call tfOps.' + op, () => { - node.op = op; - spyOps[uncapitalize(op)].and.returnValue({}); - executeOp(node, {input1}, context, spyOpsAsTfOps); - - expect(spyOps[uncapitalize(op)]).toHaveBeenCalledWith(input1[0]); - }); - it('should match op def', () => { - node.op = op; - - expect(validateParam(node, basic_math.json)).toBeTruthy(); - }); - }); - describe('Relu6', () => { - it('should call tfOps.relu6', () => { - node.op = 'Relu6'; - - executeOp(node, {input1}, context, spyOpsAsTfOps); - - expect(spyOps.relu6).toHaveBeenCalledWith(input1[0]); - }); - it('should match op def', () => { - node.op = 'Relu6'; - - expect(validateParam(node, basic_math.json)).toBeTruthy(); - }); - }); - describe('ClipByValue', () => { - it('should call tfOps.clipByValue', () => { - node.op = 'ClipByValue'; - node.inputNames = ['input1', 'input2', 'input3']; - node.inputParams['clipValueMin'] = createNumberAttrFromIndex(1); - node.inputParams['clipValueMax'] = createNumberAttrFromIndex(2); - const input2 = [tfOps.scalar(2)]; - const input3 = [tfOps.scalar(3)]; - executeOp(node, {input1, input2, input3}, context, spyOpsAsTfOps); - - expect(spyOps.clipByValue).toHaveBeenCalledWith(input1[0], 2, 3); - }); - it('should match op def', () => { - node.op = 'ClipByValue'; - node.inputParams['clipValueMin'] = createNumberAttrFromIndex(1); - node.inputParams['clipValueMax'] = createNumberAttrFromIndex(2); - - expect(validateParam(node, basic_math.json)).toBeTruthy(); - }); - }); - describe('Rsqrt', () => { - it('should call tfOps.rsqrt', () => { - const input1 = [tfOps.scalar(1)]; - node.op = 'Rsqrt'; - executeOp(node, {input1}, context, spyOpsAsTfOps); - - expect(spyOps.rsqrt).toHaveBeenCalledWith(input1[0]); - }); - it('should match op def', () => { - node.op = 'Rsqrt'; - - expect(validateParam(node, basic_math.json)).toBeTruthy(); - }); - }); - describe('LeakyRelu', () => { - it('should call tfOps.leakyRelu', () => { - node.op = 'LeakyRelu'; - node.attrParams['alpha'] = createNumberAttr(1); - node.inputNames = ['input1']; - executeOp(node, {input1}, context, spyOpsAsTfOps); - - expect(spyOps.leakyRelu).toHaveBeenCalledWith(input1[0], 1); - }); - it('should match op def', () => { - node.op = 'LeakyRelu'; - node.attrParams['alpha'] = createNumberAttr(1); - expect(validateParam(node, basic_math.json)).toBeTruthy(); - }); - }); - describe('Prelu', () => { - it('should call tfOps.Prelu', () => { - node.op = 'Prelu'; - node.inputParams['x'] = createTensorAttr(0); - node.inputParams['alpha'] = createTensorAttr(1); - node.inputNames = ['input1', 'input2']; - const input2 = [tfOps.scalar(1)]; - executeOp(node, {input1, input2}, context, spyOpsAsTfOps); - - expect(spyOps.prelu).toHaveBeenCalledWith(input1[0], input2[0]); - }); - it('should match op def', () => { - node.op = 'Prelu'; - node.inputParams['x'] = createTensorAttr(0); - node.inputParams['alpha'] = createTensorAttr(1); - expect(validateParam(node, basic_math.json)).toBeTruthy(); - }); - }); - describe('Atan2', () => { - it('should call tfOps.atan2', () => { - node.op = 'Atan2'; - node.inputParams['y'] = createTensorAttr(1); - node.inputNames = ['input1', 'input2']; - const input2 = [tfOps.scalar(2)]; - executeOp(node, {input1, input2}, context, spyOpsAsTfOps); - - expect(spyOps.atan2).toHaveBeenCalledWith(input1[0], input2[0]); - }); - it('should match op def', () => { - node.op = 'Atan2'; - node.inputParams['y'] = createTensorAttr(1); - - expect(validateParam(node, basic_math.json)).toBeTruthy(); - }); - }); - describe('ComplexAbs', () => { - it('should call tfOps.abs', () => { - node.op = 'ComplexAbs'; - node.inputNames = ['input1']; - executeOp(node, {input1}, context, spyOpsAsTfOps); - - expect(spyOps.abs).toHaveBeenCalledWith(input1[0]); - }); - it('should match op def', () => { - node.op = 'ComplexAbs'; - - expect(validateParam(node, basic_math.json)).toBeTruthy(); - }); - }); - describe('Complex', () => { - it('should call tfOps.complex', () => { - node.op = 'Complex'; - node.inputParams = { - real: createTensorAttr(0), - imag: createTensorAttr(1) - }; - const input2 = [tfOps.scalar(2)]; - node.inputNames = ['input1', 'input2']; - executeOp(node, {input1, input2}, context, spyOpsAsTfOps); - - expect(spyOps.complex).toHaveBeenCalledWith(input1[0], input2[0]); - }); - it('should match op def', () => { - node.op = 'Complex'; - node.inputParams = { - real: createTensorAttr(0), - imag: createTensorAttr(1) - }; - - expect(validateParam(node, basic_math.json)).toBeTruthy(); - }); - }); - describe('IsNan', () => { - it('should call tfOps.isNaN', () => { - node.op = 'IsNan'; - - executeOp(node, {input1}, context, spyOpsAsTfOps); - - expect(spyOps.isNaN).toHaveBeenCalledWith(input1[0]); - }); - it('should match op def', () => { - node.op = 'IsNan'; - - expect(validateParam(node, basic_math.json)).toBeTruthy(); - }); - }); - describe('IsInf', () => { - it('should call tfOps.isInf', () => { - node.op = 'IsInf'; - - executeOp(node, {input1}, context, spyOpsAsTfOps); - - expect(spyOps.isInf).toHaveBeenCalledWith(input1[0]); - }); - it('should match op def', () => { - node.op = 'IsInf'; - - expect(validateParam(node, basic_math.json)).toBeTruthy(); - }); - }); - describe('IsFinite', () => { - it('should call tfOps.isFinite', () => { - node.op = 'IsFinite'; - - executeOp(node, {input1}, context, spyOpsAsTfOps); - - expect(spyOps.isFinite).toHaveBeenCalledWith(input1[0]); - }); - it('should match op def', () => { - node.op = 'IsFinite'; - - expect(validateParam(node, basic_math.json)).toBeTruthy(); - }); - }); - }); -}); diff --git a/tfjs-master/tfjs-converter/src/operations/executors/control_executor.ts b/tfjs-master/tfjs-converter/src/operations/executors/control_executor.ts deleted file mode 100644 index 0fa6bed98..000000000 --- a/tfjs-master/tfjs-converter/src/operations/executors/control_executor.ts +++ /dev/null @@ -1,392 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {DataType, scalar, Tensor} from '@tensorflow/tfjs-core'; - -import {NamedTensorsMap} from '../../data/types'; -import {ExecutionContext} from '../../executor/execution_context'; -import {TensorArray} from '../../executor/tensor_array'; -import {fromTensor, reserve, scatter, split} from '../../executor/tensor_list'; -import {InternalOpAsyncExecutor, Node} from '../types'; - -import {cloneTensor, getParamValue, getTensor} from './utils'; - -export const executeOp: InternalOpAsyncExecutor = async( - node: Node, tensorMap: NamedTensorsMap, - context: ExecutionContext): Promise => { - switch (node.op) { - case 'If': - case 'StatelessIf': { - const thenFunc = - getParamValue('thenBranch', node, tensorMap, context) as string; - const elseFunc = - getParamValue('elseBranch', node, tensorMap, context) as string; - const cond = getParamValue('cond', node, tensorMap, context) as Tensor; - const args = getParamValue('args', node, tensorMap, context) as Tensor[]; - const condValue = await cond.data(); - if (condValue[0]) { - return context.functionMap[thenFunc].executeFunctionAsync( - args, context.tensorArrayMap, context.tensorListMap); - } else { - return context.functionMap[elseFunc].executeFunctionAsync( - args, context.tensorArrayMap, context.tensorListMap); - } - } - case 'While': - case 'StatelessWhile': { - const bodyFunc = - getParamValue('body', node, tensorMap, context) as string; - const condFunc = - getParamValue('cond', node, tensorMap, context) as string; - const args = getParamValue('args', node, tensorMap, context) as Tensor[]; - - // Calculate the condition of the loop - const condResult = - (await context.functionMap[condFunc].executeFunctionAsync( - args, context.tensorArrayMap, context.tensorListMap)); - const argIds = args.map(tensor => tensor.id); - let condValue = await condResult[0].data(); - // Dispose the intermediate tensors for condition function - condResult.forEach(tensor => { - if (!tensor.kept && argIds.indexOf(tensor.id) === -1) { - tensor.dispose(); - } - }); - - let result: Tensor[] = args; - - while (condValue[0]) { - // Record the previous result for intermediate tensor tracking - const origResult = result; - // Execution the body of the loop - result = await context.functionMap[bodyFunc].executeFunctionAsync( - result, context.tensorArrayMap, context.tensorListMap); - const resultIds = result.map(tensor => tensor.id); - - // Dispose the intermediate tensor for body function that is not global - // kept, not input/output of the body function - origResult.forEach(tensor => { - if (!tensor.kept && argIds.indexOf(tensor.id) === -1 && - resultIds.indexOf(tensor.id) === -1) { - tensor.dispose(); - } - }); - - // Recalcuate the condition of the loop using the latest results. - const condResult = - (await context.functionMap[condFunc].executeFunctionAsync( - result, context.tensorArrayMap, context.tensorListMap)); - condValue = await condResult[0].data(); - // Dispose the intermediate tensors for condition function - condResult.forEach(tensor => { - if (!tensor.kept && argIds.indexOf(tensor.id) === -1 && - resultIds.indexOf(tensor.id) === -1) { - tensor.dispose(); - } - }); - } - return result; - } - case 'LoopCond': { - const pred = getParamValue('pred', node, tensorMap, context) as Tensor; - return [cloneTensor(pred)]; - } - case 'Switch': { - const pred = getParamValue('pred', node, tensorMap, context) as Tensor; - let data = getParamValue('data', node, tensorMap, context) as Tensor; - if (!data.kept) { - data = cloneTensor(data); - } - // Outputs nodes :0 => false, :1 => true - return (await pred.data())[0] ? [undefined, data] : [data, undefined]; - } - case 'Merge': { - const inputName = node.inputNames.find( - name => getTensor(name, tensorMap, context) !== undefined); - if (inputName) { - const data = getTensor(inputName, tensorMap, context); - return [cloneTensor(data)]; - } - return undefined; - } - case 'Enter': { - const frameId = - getParamValue('frameName', node, tensorMap, context) as string; - const data = getParamValue('tensor', node, tensorMap, context) as Tensor; - context.enterFrame(frameId); - return [cloneTensor(data)]; - } - case 'Exit': { - const data = getParamValue('tensor', node, tensorMap, context) as Tensor; - context.exitFrame(); - return [cloneTensor(data)]; - } - case 'NextIteration': { - const data = getParamValue('tensor', node, tensorMap, context) as Tensor; - context.nextIteration(); - return [cloneTensor(data)]; - } - case 'TensorArrayV3': { - const size = getParamValue('size', node, tensorMap, context) as number; - const dtype = - getParamValue('dtype', node, tensorMap, context) as DataType; - const elementShape = - getParamValue('elementShape', node, tensorMap, context) as number[]; - const dynamicSize = - getParamValue('dynamicSize', node, tensorMap, context) as boolean; - const clearAfterRead = - getParamValue('clearAfterRead', node, tensorMap, context) as boolean; - const identicalElementShapes = - getParamValue('identicalElementShapes', node, tensorMap, context) as - boolean; - const name = getParamValue('name', node, tensorMap, context) as string; - const tensorArray = new TensorArray( - name, dtype, size, elementShape, identicalElementShapes, dynamicSize, - clearAfterRead); - context.addTensorArray(tensorArray); - return [tensorArray.idTensor, scalar(1.0)]; - } - case 'TensorArrayWriteV3': { - const id = - getParamValue('tensorArrayId', node, tensorMap, context) as Tensor; - const index = getParamValue('index', node, tensorMap, context) as number; - const writeTensor = - getParamValue('tensor', node, tensorMap, context) as Tensor; - const writeTensorArray = context.getTensorArray(id.id); - writeTensorArray.write(index, writeTensor); - return [writeTensorArray.idTensor]; - } - case 'TensorArrayReadV3': { - const readId = - getParamValue('tensorArrayId', node, tensorMap, context) as Tensor; - const readIndex = - getParamValue('index', node, tensorMap, context) as number; - const readTensorArray = context.getTensorArray(readId.id); - return [readTensorArray.read(readIndex)]; - } - case 'TensorArrayGatherV3': { - const gatherId = - getParamValue('tensorArrayId', node, tensorMap, context) as Tensor; - const gatherIndices = - getParamValue('indices', node, tensorMap, context) as number[]; - const gatherDtype = - getParamValue('dtype', node, tensorMap, context) as DataType; - const gatherTensorArray = context.getTensorArray(gatherId.id); - return [gatherTensorArray.gather(gatherIndices, gatherDtype)]; - } - case 'TensorArrayScatterV3': { - const scatterId = - getParamValue('tensorArrayId', node, tensorMap, context) as Tensor; - const scatterIndices = - getParamValue('indices', node, tensorMap, context) as number[]; - const scatterTensor = - getParamValue('tensor', node, tensorMap, context) as Tensor; - const scatterTensorArray = context.getTensorArray(scatterId.id); - scatterTensorArray.scatter(scatterIndices, scatterTensor); - return [scatterTensorArray.idTensor]; - } - case 'TensorArrayConcatV3': { - const concatId = - getParamValue('tensorArrayId', node, tensorMap, context) as Tensor; - const concatTensorArray = context.getTensorArray(concatId.id); - const concatDtype = - getParamValue('dtype', node, tensorMap, context) as DataType; - return [concatTensorArray.concat(concatDtype)]; - } - case 'TensorArraySplitV3': { - const splitId = - getParamValue('tensorArrayId', node, tensorMap, context) as Tensor; - const splitTensor = - getParamValue('tensor', node, tensorMap, context) as Tensor; - const lengths = - getParamValue('lengths', node, tensorMap, context) as number[]; - const splitTensorArray = context.getTensorArray(splitId.id); - splitTensorArray.split(lengths, splitTensor); - return [splitTensorArray.idTensor]; - } - case 'TensorArraySizeV3': { - const sizeId = - getParamValue('tensorArrayId', node, tensorMap, context) as Tensor; - const sizeTensorArray = context.getTensorArray(sizeId.id); - return [scalar(sizeTensorArray.size(), 'int32')]; - } - case 'TensorArrayCloseV3': { - const closeId = - getParamValue('tensorArrayId', node, tensorMap, context) as Tensor; - const closeTensorArray = context.getTensorArray(closeId.id); - closeTensorArray.clearAndClose(); - return [closeTensorArray.idTensor]; - } - case 'TensorListSetItem': { - const idTensor = - getParamValue('tensorListId', node, tensorMap, context) as Tensor; - const index = getParamValue('index', node, tensorMap, context) as number; - const writeTensor = - getParamValue('tensor', node, tensorMap, context) as Tensor; - const tensorList = context.getTensorList(idTensor.id); - tensorList.setItem(index, writeTensor); - return [tensorList.idTensor]; - } - case 'TensorListGetItem': { - const idTensor = - getParamValue('tensorListId', node, tensorMap, context) as Tensor; - const readIndex = - getParamValue('index', node, tensorMap, context) as number; - const elementShape = - getParamValue('elementShape', node, tensorMap, context) as number[]; - - const elementDType = - getParamValue('elementDType', node, tensorMap, context) as DataType; - const tensorList = context.getTensorList(idTensor.id); - return [tensorList.getItem(readIndex, elementShape, elementDType)]; - } - case 'TensorListScatterV2': - case 'TensorListScatter': { - const scatterIndices = - getParamValue('indices', node, tensorMap, context) as number[]; - const scatterTensor = - getParamValue('tensor', node, tensorMap, context) as Tensor; - const elementShape = - getParamValue('elementShape', node, tensorMap, context) as number[]; - const numElements = - getParamValue('numElements', node, tensorMap, context) as number; - const tensorList = - scatter(scatterTensor, scatterIndices, elementShape, numElements); - context.addTensorList(tensorList); - return [tensorList.idTensor]; - } - case 'TensorListReserve': - case 'EmptyTensorList': { - const elementShape = - getParamValue('elementShape', node, tensorMap, context) as number[]; - const elementDtype = - getParamValue('elementDType', node, tensorMap, context) as DataType; - let numElementsParam; - - if (node.op === 'TensorListReserve') { - numElementsParam = 'numElements'; - } else { - numElementsParam = 'maxNumElements'; - } - - const numElements = - getParamValue(numElementsParam, node, tensorMap, context) as number; - const maxNumElements = node.op === 'TensorListReserve' ? -1 : numElements; - const tensorList = - reserve(elementShape, elementDtype, numElements, maxNumElements); - context.addTensorList(tensorList); - return [tensorList.idTensor]; - } - case 'TensorListGather': { - const gatherId = - getParamValue('tensorListId', node, tensorMap, context) as Tensor; - const gatherIndices = - getParamValue('indices', node, tensorMap, context) as number[]; - const elementShape = - getParamValue('elementShape', node, tensorMap, context) as number[]; - const elementDtype = - getParamValue('elementDType', node, tensorMap, context) as DataType; - const tensorList = context.getTensorList(gatherId.id); - return [tensorList.gather(gatherIndices, elementDtype, elementShape)]; - } - case 'TensorListStack': { - const idTensor = - getParamValue('tensorListId', node, tensorMap, context) as Tensor; - const elementShape = - getParamValue('elementShape', node, tensorMap, context) as number[]; - const elementDtype = - getParamValue('elementDType', node, tensorMap, context) as DataType; - const numElements = - getParamValue('numElements', node, tensorMap, context) as number; - const tensorList = context.getTensorList(idTensor.id); - return [tensorList.stack(elementShape, elementDtype, numElements)]; - } - case 'TensorListFromTensor': { - const tensor = - getParamValue('tensor', node, tensorMap, context) as Tensor; - const elementShape = - getParamValue('elementShape', node, tensorMap, context) as number[]; - const elementDtype = - getParamValue('elementDType', node, tensorMap, context) as DataType; - const tensorList = fromTensor(tensor, elementShape, elementDtype); - context.addTensorList(tensorList); - return [tensorList.idTensor]; - } - case 'TensorListConcat': - case 'TensorListConcatV2': { - const concatId = - getParamValue('tensorListId', node, tensorMap, context) as Tensor; - const tensorList = context.getTensorList(concatId.id); - const concatDtype = - getParamValue('dtype', node, tensorMap, context) as DataType; - const elementShape = - getParamValue('elementShape', node, tensorMap, context) as number[]; - return [tensorList.concat(concatDtype, elementShape)]; - } - case 'TensorListPushBack': { - const idTensor = - getParamValue('tensorListId', node, tensorMap, context) as Tensor; - const writeTensor = - getParamValue('tensor', node, tensorMap, context) as Tensor; - const tensorList = context.getTensorList(idTensor.id); - tensorList.pushBack(writeTensor); - return [tensorList.idTensor]; - } - case 'TensorListPopBack': { - const idTensor = - getParamValue('tensorListId', node, tensorMap, context) as Tensor; - const elementShape = - getParamValue('elementShape', node, tensorMap, context) as number[]; - const elementDType = - getParamValue('elementDType', node, tensorMap, context) as DataType; - const tensorList = context.getTensorList(idTensor.id); - return [tensorList.popBack(elementShape, elementDType)]; - } - case 'TensorListSplit': { - const splitTensor = - getParamValue('tensor', node, tensorMap, context) as Tensor; - const elementShape = - getParamValue('elementShape', node, tensorMap, context) as number[]; - const lengths = - getParamValue('lengths', node, tensorMap, context) as number[]; - - const tensorList = split(splitTensor, lengths, elementShape); - context.addTensorList(tensorList); - return [tensorList.idTensor]; - } - case 'TensorListLength': { - const idTensor = - getParamValue('tensorListId', node, tensorMap, context) as Tensor; - const tensorList = context.getTensorList(idTensor.id); - return [scalar(tensorList.size(), 'int32')]; - } - case 'TensorListResize': { - const idTensor = - getParamValue('tensorListId', node, tensorMap, context) as Tensor; - const size = getParamValue('size', node, tensorMap, context) as number; - - const srcTensorList = context.getTensorList(idTensor.id); - const destTensorList = srcTensorList.resize(size); - context.addTensorList(destTensorList); - return [destTensorList.idTensor]; - } - default: - throw TypeError(`Node type ${node.op} is not implemented`); - } -}; - -export const CATEGORY = 'control'; diff --git a/tfjs-master/tfjs-converter/src/operations/executors/control_executor_test.ts b/tfjs-master/tfjs-converter/src/operations/executors/control_executor_test.ts deleted file mode 100644 index 79c9c8d18..000000000 --- a/tfjs-master/tfjs-converter/src/operations/executors/control_executor_test.ts +++ /dev/null @@ -1,1105 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {scalar, Tensor, tensor1d, tensor2d, test_util} from '@tensorflow/tfjs-core'; -// tslint:disable-next-line: no-imports-from-dist -import * as tfOps from '@tensorflow/tfjs-core/dist/ops/ops_for_converter'; - -import {ExecutionContext} from '../../executor/execution_context'; -import {GraphExecutor} from '../../executor/graph_executor'; -import {TensorArray} from '../../executor/tensor_array'; -import {TensorList} from '../../executor/tensor_list'; -import * as control from '../op_list/control'; -import {Graph, Node} from '../types'; - -import {executeOp} from './control_executor'; -import {createBoolAttr, createDtypeAttr, createNumberAttrFromIndex, createNumericArrayAttrFromIndex, createShapeAttrFromIndex, createStrAttr, createTensorAttr, createTensorsAttr, createTensorShapeAttr, validateParam} from './test_helper'; - -describe('control', () => { - let node: Node; - let input1: Tensor[]; - let input2: Tensor[]; - const context = new ExecutionContext({}, {}, {}); - - beforeEach(() => { - node = { - name: 'test', - op: '', - category: 'control', - inputNames: ['input1', 'pred'], - inputs: [], - inputParams: {}, - attrParams: {}, - children: [] - }; - input1 = [tfOps.scalar(1, 'int32')]; - input2 = [tfOps.scalar(0, 'bool')]; - }); - - afterEach(() => { - input1[0].dispose(); - input2[0].dispose(); - }); - - describe('executeOp', () => { - describe('Switch', () => { - it('should set the output condition is true', async () => { - node.op = 'Switch'; - node.inputParams['pred'] = createTensorAttr(1); - node.inputParams['data'] = createTensorAttr(0); - - const pred = [tfOps.scalar(true)]; - const result = await executeOp(node, {pred, input1}, context); - expect(result[0]).toBeUndefined(); - test_util.expectArraysEqual( - await result[1].array(), await input1[0].array()); - }); - it('should set the output condition is false', async () => { - node.op = 'Switch'; - node.inputParams['pred'] = createTensorAttr(1); - node.inputParams['data'] = createTensorAttr(0); - - const pred = [tfOps.scalar(false)]; - const result = await executeOp(node, {pred, input1}, context); - test_util.expectArraysEqual( - await result[0].array(), await input1[0].array()); - expect(result[1]).toBeUndefined(); - }); - it('should match json def', () => { - node.op = 'Switch'; - node.inputParams['pred'] = createTensorAttr(1); - node.inputParams['data'] = createTensorAttr(0); - - expect(validateParam(node, control.json)).toBeTruthy(); - }); - }); - describe('Merge', () => { - it('should return the first available input', async () => { - node.op = 'Merge'; - - const pred = [tfOps.scalar(true)]; - test_util.expectArraysEqual( - await (await executeOp(node, {pred: undefined, input1}, context))[0] - .array(), - await input1[0].array()); - test_util.expectArraysEqual( - await (await executeOp(node, {pred, input1: undefined}, context))[0] - .array(), - await pred[0].array()); - }); - it('should return undefined if no inputs are available', async () => { - node.op = 'Merge'; - expect(await executeOp( - node, {pred: undefined, input1: undefined}, context)) - .toEqual(undefined); - }); - it('should match json def', () => { - node.op = 'Merge'; - - expect(validateParam(node, control.json)).toBeTruthy(); - }); - }); - - describe('Enter', () => { - it('should call enterFrame on context', async () => { - spyOn(context, 'enterFrame'); - node.op = 'Enter'; - node.inputParams['tensor'] = createTensorAttr(0); - node.attrParams['frameName'] = createStrAttr('test'); - node.inputNames = ['input1']; - - test_util.expectArraysEqual( - await (await executeOp(node, {input1}, context))[0].array(), - await input1[0].array()); - expect(context.enterFrame).toHaveBeenCalled(); - }); - it('should match json def', () => { - node.op = 'Enter'; - node.inputParams['tensor'] = createTensorAttr(0); - - expect(validateParam(node, control.json)).toBeTruthy(); - }); - }); - describe('Exit', () => { - it('should call existFrame on context', async () => { - spyOn(context, 'exitFrame'); - node.op = 'Exit'; - node.inputParams['tensor'] = createTensorAttr(0); - node.inputNames = ['input1']; - - test_util.expectArraysEqual( - await (await executeOp(node, {input1}, context))[0].array(), - await input1[0].array()); - expect(context.exitFrame).toHaveBeenCalled(); - }); - it('should match json def', () => { - node.op = 'Exit'; - node.inputParams['tensor'] = createTensorAttr(0); - - expect(validateParam(node, control.json)).toBeTruthy(); - }); - }); - describe('NextIteration', () => { - it('should call nextIteration on context', async () => { - spyOn(context, 'nextIteration'); - node.op = 'NextIteration'; - node.inputParams['tensor'] = createTensorAttr(0); - node.inputNames = ['input1']; - - test_util.expectArraysEqual( - await (await executeOp(node, {input1}, context))[0].array(), - await input1[0].array()); - expect(context.nextIteration).toHaveBeenCalled(); - }); - it('should match json def', () => { - node.op = 'NextIteration'; - node.inputParams['tensor'] = createTensorAttr(0); - - expect(validateParam(node, control.json)).toBeTruthy(); - }); - }); - - describe('TensorArrayV3', () => { - it('should create new tensor on the context', async () => { - node.op = 'TensorArrayV3'; - node.inputParams['size'] = createNumberAttrFromIndex(0); - node.attrParams['name'] = createStrAttr(''); - node.attrParams['dtype'] = createDtypeAttr('int32'); - node.attrParams['elementShape'] = createTensorShapeAttr([10, 10]); - node.attrParams['dynamicSize'] = createBoolAttr(false); - node.attrParams['clearAfterRead'] = createBoolAttr(true); - node.attrParams['identicalElementShapes'] = createBoolAttr(true); - node.inputNames = ['input1']; - - const tensorId = (await executeOp(node, {input1}, context))[0]; - expect(context.getTensorArray(tensorId.id)).toBeDefined(); - }); - it('should match json def', () => { - node.op = 'TensorArrayV3'; - node.inputParams['size'] = createNumberAttrFromIndex(0); - node.attrParams['name'] = createStrAttr(''); - node.attrParams['dtype'] = createDtypeAttr('int32'); - node.attrParams['elementShape'] = createTensorShapeAttr([10, 10]); - node.attrParams['dynamicSize'] = createBoolAttr(false); - node.attrParams['clearAfterRead'] = createBoolAttr(true); - node.attrParams['identicalElementShapes'] = createBoolAttr(true); - - expect(validateParam(node, control.json)).toBeTruthy(); - }); - }); - - describe('TensorArrayWriteV3', () => { - it('should write the tensor to tensorArray', async () => { - const tensorArray = - new TensorArray('', 'int32', 5, [], true, false, true); - context.addTensorArray(tensorArray); - node.op = 'TensorArrayWriteV3'; - node.inputParams['tensorArrayId'] = createTensorAttr(0); - node.inputParams['index'] = createNumberAttrFromIndex(1); - node.inputParams['tensor'] = createTensorAttr(2); - node.inputNames = ['input2', 'input3', 'input1']; - const input2 = [tensorArray.idTensor]; - const input3 = [scalar(0)]; - await executeOp(node, {input1, input2, input3}, context); - - expect(tensorArray.size()).toEqual(1); - }); - it('should match json def', () => { - node.op = 'TensorArrayWriteV3'; - node.inputParams['tensorArrayId'] = createTensorAttr(0); - node.inputParams['index'] = createNumberAttrFromIndex(1); - node.inputParams['tensor'] = createTensorAttr(2); - - expect(validateParam(node, control.json)).toBeTruthy(); - }); - }); - - describe('TensorArrayReadV3', () => { - it('should read the tensor from tensorArray', async () => { - const tensorArray = - new TensorArray('', 'int32', 5, [3], true, false, true); - const input4 = tensor1d([0, 0, 0], 'int32'); - tensorArray.write(0, input4); - context.addTensorArray(tensorArray); - node.op = 'TensorArrayReadV3'; - node.inputParams['tensorArrayId'] = createTensorAttr(0); - node.inputParams['index'] = createNumberAttrFromIndex(1); - node.inputNames = ['input2', 'input3']; - const input2 = [tensorArray.idTensor]; - const input3 = [scalar(0)]; - const read = await executeOp(node, {input1, input2, input3}, context); - - test_util.expectArraysClose( - await read[0].array(), await input4.array()); - }); - it('should match json def', () => { - node.op = 'TensorArrayReadV3'; - node.inputParams['tensorArrayId'] = createTensorAttr(0); - node.inputParams['index'] = createNumberAttrFromIndex(1); - - expect(validateParam(node, control.json)).toBeTruthy(); - }); - }); - - describe('TensorArrayGatherV3', () => { - it('should gather the tensors from tensorArray', async () => { - const tensorArray = - new TensorArray('', 'int32', 5, [3], true, false, true); - const input4 = tensor1d([0, 0, 0], 'int32'); - const input5 = tensor1d([1, 1, 1], 'int32'); - tensorArray.writeMany([0, 1], [input4, input5]); - context.addTensorArray(tensorArray); - node.op = 'TensorArrayGatherV3'; - node.inputParams['tensorArrayId'] = createTensorAttr(0); - node.inputParams['indices'] = createNumericArrayAttrFromIndex(1); - node.attrParams['dtype'] = createDtypeAttr('int32'); - node.inputNames = ['input2', 'input3']; - const input2 = [tensorArray.idTensor]; - const input3 = [tensor1d([0, 1])]; - const gather = await executeOp(node, {input2, input3}, context); - expect(gather.length).toEqual(1); - expect(gather[0].shape).toEqual([2, 3]); - test_util.expectArraysClose( - gather[0].dataSync(), new Int32Array([0, 0, 0, 1, 1, 1])); - }); - it('should match json def', () => { - node.op = 'TensorArrayGatherV3'; - node.inputParams['tensorArrayId'] = createTensorAttr(0); - node.inputParams['indices'] = createNumericArrayAttrFromIndex(1); - node.attrParams['dtype'] = createDtypeAttr('int32'); - - expect(validateParam(node, control.json)).toBeTruthy(); - }); - }); - - describe('TensorArrayScatterV3', () => { - it('should scatter the tensor to tensorArray', async () => { - const tensorArray = - new TensorArray('', 'int32', 5, [3], true, false, true); - const input4 = [tensor2d([0, 0, 0, 1, 1, 1], [2, 3], 'int32')]; - context.addTensorArray(tensorArray); - node.op = 'TensorArrayScatterV3'; - node.inputParams['tensorArrayId'] = createTensorAttr(0); - node.inputParams['indices'] = createNumericArrayAttrFromIndex(1); - node.inputParams['tensor'] = createTensorAttr(2); - node.inputNames = ['input2', 'input3', 'input4']; - const input2 = [tensorArray.idTensor]; - const input3 = [tensor1d([0, 1], 'int32')]; - await executeOp(node, {input2, input3, input4}, context); - - expect(tensorArray.size()).toEqual(2); - }); - - it('should match json def', () => { - node.op = 'TensorArrayScatterV3'; - node.inputParams['tensorArrayId'] = createTensorAttr(0); - node.inputParams['indices'] = createNumericArrayAttrFromIndex(1); - node.inputParams['tensor'] = createTensorAttr(2); - - expect(validateParam(node, control.json)).toBeTruthy(); - }); - }); - - describe('TensorArraySplitV3', () => { - it('should split the tensor to tensorArray', async () => { - const tensorArray = - new TensorArray('', 'int32', 2, [3], true, false, true); - const input4 = [tensor2d([0, 0, 0, 1, 1, 1], [2, 3], 'int32')]; - context.addTensorArray(tensorArray); - node.op = 'TensorArraySplitV3'; - node.inputParams['tensorArrayId'] = createTensorAttr(0); - node.inputParams['tensor'] = createTensorAttr(1); - node.inputParams['lengths'] = createNumericArrayAttrFromIndex(2); - node.inputNames = ['input2', 'input4', 'input3']; - const input2 = [tensorArray.idTensor]; - const input3 = [tensor1d([1, 1], 'int32')]; - await executeOp(node, {input2, input3, input4}, context); - - expect(tensorArray.size()).toEqual(2); - }); - it('should match json def', () => { - node.op = 'TensorArraySplitV3'; - node.inputParams['tensorArrayId'] = createTensorAttr(0); - node.inputParams['tensor'] = createTensorAttr(1); - node.inputParams['lengths'] = createNumericArrayAttrFromIndex(2); - - expect(validateParam(node, control.json)).toBeTruthy(); - }); - }); - - describe('TensorArrayConcatV3', () => { - it('should concat the tensors from tensorArray', async () => { - const tensorArray = - new TensorArray('', 'int32', 5, [3], true, false, true); - const input4 = tensor1d([0, 0, 0], 'int32'); - const input5 = tensor1d([1, 1, 1], 'int32'); - tensorArray.writeMany([0, 1], [input4, input5]); - context.addTensorArray(tensorArray); - node.op = 'TensorArrayConcatV3'; - node.inputParams['tensorArrayId'] = createTensorAttr(0); - node.attrParams['dtype'] = createDtypeAttr('int32'); - node.inputNames = ['input2']; - const input2 = [tensorArray.idTensor]; - const concat = await executeOp(node, {input2}, context); - expect(concat.length).toEqual(1); - expect(concat[0].shape).toEqual([6]); - test_util.expectArraysClose( - concat[0].dataSync(), new Int32Array([0, 0, 0, 1, 1, 1])); - }); - it('should match json def', () => { - node.op = 'TensorArrayConcatV3'; - node.inputParams['tensorArrayId'] = createTensorAttr(0); - node.attrParams['dtype'] = createDtypeAttr('int32'); - - expect(validateParam(node, control.json)).toBeTruthy(); - }); - }); - - describe('TensorArraySizeV3', () => { - it('should get the size of tensorArray', async () => { - const tensorArray = - new TensorArray('', 'int32', 5, [3], true, false, true); - const input4 = tensor1d([0, 0, 0], 'int32'); - const input5 = tensor1d([1, 1, 1], 'int32'); - tensorArray.writeMany([0, 1], [input4, input5]); - context.addTensorArray(tensorArray); - node.op = 'TensorArraySizeV3'; - node.inputParams['tensorArrayId'] = createTensorAttr(0); - node.inputNames = ['input2']; - const input2 = [tensorArray.idTensor]; - const size = await executeOp(node, {input2}, context); - expect(size.length).toEqual(1); - expect(size[0].shape).toEqual([]); - test_util.expectArraysClose(size[0].dataSync(), new Int32Array([2])); - }); - it('should match json def', () => { - node.op = 'TensorArraySizeV3'; - node.inputParams['tensorArrayId'] = createTensorAttr(0); - - expect(validateParam(node, control.json)).toBeTruthy(); - }); - }); - - describe('TensorArrayCloseV3', () => { - it('should close the tensorArray', async () => { - const tensorArray = - new TensorArray('', 'int32', 5, [3], true, false, true); - const input4 = tensor1d([0, 0, 0], 'int32'); - const input5 = tensor1d([1, 1, 1], 'int32'); - tensorArray.writeMany([0, 1], [input4, input5]); - context.addTensorArray(tensorArray); - node.op = 'TensorArrayCloseV3'; - node.inputParams['tensorArrayId'] = createTensorAttr(0); - node.inputNames = ['input2']; - const input2 = [tensorArray.idTensor]; - await executeOp(node, {input2}, context); - expect(tensorArray.closed).toBeTruthy(); - }); - it('should match json def', () => { - node.op = 'TensorArrayCloseV3'; - node.inputParams['tensorArrayId'] = createTensorAttr(0); - - expect(validateParam(node, control.json)).toBeTruthy(); - }); - }); - }); - describe('StatelessWhile', () => { - it('should set the output', async () => { - node.op = 'StatelessWhile'; - node.inputNames = ['input1', 'input2']; - node.inputParams['args'] = createTensorsAttr(0, 0); - node.attrParams['cond'] = {'value': 'condFunc', 'type': 'func'}; - node.attrParams['body'] = {'value': 'bodyFunc', 'type': 'func'}; - - const cond = [tfOps.scalar(false)]; - const graph: Graph = { - inputs: [], - nodes: { - - }, - outputs: [], - weights: [], - placeholders: [], - functions: {}, - signature: {} - }; - const condExecutor = new GraphExecutor(graph); - let firstTime = true; - spyOn(condExecutor, 'executeFunctionAsync').and.callFake(async () => { - if (firstTime) { - firstTime = false; - return input1; - } - return input2; - }); - const bodyExecutor = new GraphExecutor(graph); - const input3 = [tfOps.scalar(3, 'int32')]; - spyOn(bodyExecutor, 'executeFunctionAsync').and - .returnValue(Promise.resolve(input3)); - context.functionMap['bodyFunc'] = bodyExecutor; - context.functionMap['condFunc'] = condExecutor; - const result = await executeOp(node, {cond, input1, input2}, context); - - test_util.expectArraysEqual( - await result[0].array(), await input3[0].array()); - }); - - it('should match json def', () => { - node.op = 'StatelessWhile'; - node.inputNames = ['input1', 'input2']; - node.inputParams['args'] = createTensorsAttr(0, 0); - node.attrParams['cond'] = {'value': 'condFunc', 'type': 'func'}; - node.attrParams['body'] = {'value': 'bodyFunc', 'type': 'func'}; - - expect(validateParam(node, control.json)).toBeTruthy(); - }); - }); - describe('While', () => { - it('should set the output', async () => { - node.op = 'While'; - node.inputNames = ['input1', 'input2']; - node.inputParams['args'] = createTensorsAttr(0, 0); - node.attrParams['cond'] = {'value': 'condFunc', 'type': 'func'}; - node.attrParams['body'] = {'value': 'bodyFunc', 'type': 'func'}; - - const cond = [tfOps.scalar(false)]; - const graph: Graph = { - inputs: [], - nodes: { - - }, - outputs: [], - weights: [], - placeholders: [], - functions: {}, - signature: {} - }; - const condExecutor = new GraphExecutor(graph); - let firstTime = true; - spyOn(condExecutor, 'executeFunctionAsync').and.callFake(async () => { - if (firstTime) { - firstTime = false; - return input1; - } - return input2; - }); - const bodyExecutor = new GraphExecutor(graph); - const input3 = [tfOps.scalar(3, 'int32')]; - spyOn(bodyExecutor, 'executeFunctionAsync').and - .returnValue(Promise.resolve(input3)); - context.functionMap['bodyFunc'] = bodyExecutor; - context.functionMap['condFunc'] = condExecutor; - const result = await executeOp(node, {cond, input1, input2}, context); - - test_util.expectArraysEqual( - await result[0].array(), await input3[0].array()); - }); - - it('should match json def', () => { - node.op = 'While'; - node.inputNames = ['input1', 'input2']; - node.inputParams['args'] = createTensorsAttr(0, 0); - node.attrParams['cond'] = {'value': 'condFunc', 'type': 'func'}; - node.attrParams['body'] = {'value': 'bodyFunc', 'type': 'func'}; - - expect(validateParam(node, control.json)).toBeTruthy(); - }); - }); - describe('StatelessIf', () => { - it('should set the output condition is true', async () => { - node.op = 'StatelessIf'; - node.inputNames = ['cond', 'input1', 'input2']; - node.inputParams['args'] = createTensorsAttr(1, 0); - node.inputParams['cond'] = createTensorAttr(0); - node.attrParams['thenBranch'] = {'value': 'thenFunc', 'type': 'func'}; - node.attrParams['elseBranch'] = {'value': 'elseFunc', 'type': 'func'}; - - const cond = [tfOps.scalar(true)]; - const graph: Graph = { - inputs: [], - nodes: { - - }, - outputs: [], - weights: [], - placeholders: [], - functions: {}, - signature: {} - }; - const thenExecutor = new GraphExecutor(graph); - spyOn(thenExecutor, 'executeFunctionAsync').and - .returnValue(Promise.resolve(input1)); - const elseExecutor = new GraphExecutor(graph); - spyOn(elseExecutor, 'executeFunctionAsync').and - .returnValue(Promise.resolve(input2)); - context.functionMap['thenFunc'] = thenExecutor; - context.functionMap['elseFunc'] = elseExecutor; - const result = await executeOp(node, {cond, input1, input2}, context); - - test_util.expectArraysEqual( - await result[0].array(), await input1[0].array()); - }); - it('should set the output condition is false', async () => { - node.op = 'StatelessIf'; - node.inputNames = ['cond', 'input1']; - node.inputParams['args'] = createTensorsAttr(1, 0); - node.inputParams['cond'] = createTensorAttr(0); - node.attrParams['thenBranch'] = {'value': 'thenFunc', 'type': 'func'}; - node.attrParams['elseBranch'] = {'value': 'elseFunc', 'type': 'func'}; - - const cond = [tfOps.scalar(false)]; - const graph: Graph = { - inputs: [], - nodes: { - - }, - outputs: [], - weights: [], - placeholders: [], - functions: {}, - signature: {} - }; - const thenExecutor = new GraphExecutor(graph); - spyOn(thenExecutor, 'executeFunctionAsync').and - .returnValue(Promise.resolve(input1)); - const elseExecutor = new GraphExecutor(graph); - spyOn(elseExecutor, 'executeFunctionAsync').and - .returnValue(Promise.resolve(input2)); - context.functionMap['thenFunc'] = thenExecutor; - context.functionMap['elseFunc'] = elseExecutor; - const result = await executeOp(node, {cond, input1, input2}, context); - - test_util.expectArraysEqual( - await result[0].array(), await input2[0].array()); - }); - it('should match json def', () => { - node.op = 'StatelessIf'; - node.inputNames = ['cond', 'input1']; - node.inputParams['args'] = createTensorsAttr(1, 0); - node.inputParams['cond'] = createTensorAttr(0); - node.attrParams['thenBranch'] = {'value': 'thenFunc', 'type': 'func'}; - node.attrParams['elseBranch'] = {'value': 'elseFunc', 'type': 'func'}; - - expect(validateParam(node, control.json)).toBeTruthy(); - }); - }); - describe('If', () => { - it('should set the output condition is true', async () => { - node.op = 'If'; - node.inputNames = ['cond', 'input1', 'input2']; - node.inputParams['args'] = createTensorsAttr(1, 0); - node.inputParams['cond'] = createTensorAttr(0); - node.attrParams['thenBranch'] = {'value': 'thenFunc', 'type': 'func'}; - node.attrParams['elseBranch'] = {'value': 'elseFunc', 'type': 'func'}; - - const cond = [tfOps.scalar(true)]; - const graph: Graph = { - inputs: [], - nodes: { - - }, - outputs: [], - weights: [], - placeholders: [], - functions: {}, - signature: {} - }; - const thenExecutor = new GraphExecutor(graph); - spyOn(thenExecutor, 'executeFunctionAsync').and - .returnValue(Promise.resolve(input1)); - const elseExecutor = new GraphExecutor(graph); - spyOn(elseExecutor, 'executeFunctionAsync').and - .returnValue(Promise.resolve(input2)); - context.functionMap['thenFunc'] = thenExecutor; - context.functionMap['elseFunc'] = elseExecutor; - const result = await executeOp(node, {cond, input1, input2}, context); - - test_util.expectArraysEqual( - await result[0].array(), await input1[0].array()); - }); - it('should set the output condition is false', async () => { - node.op = 'If'; - node.inputNames = ['cond', 'input1']; - node.inputParams['args'] = createTensorsAttr(1, 0); - node.inputParams['cond'] = createTensorAttr(0); - node.attrParams['thenBranch'] = {'value': 'thenFunc', 'type': 'func'}; - node.attrParams['elseBranch'] = {'value': 'elseFunc', 'type': 'func'}; - - const cond = [tfOps.scalar(false)]; - const graph: Graph = { - inputs: [], - nodes: { - - }, - outputs: [], - weights: [], - placeholders: [], - functions: {}, - signature: {} - }; - const thenExecutor = new GraphExecutor(graph); - spyOn(thenExecutor, 'executeFunctionAsync').and - .returnValue(Promise.resolve(input1)); - const elseExecutor = new GraphExecutor(graph); - spyOn(elseExecutor, 'executeFunctionAsync').and - .returnValue(Promise.resolve(input2)); - context.functionMap['thenFunc'] = thenExecutor; - context.functionMap['elseFunc'] = elseExecutor; - const result = await executeOp(node, {cond, input1, input2}, context); - - test_util.expectArraysEqual( - await result[0].array(), await input2[0].array()); - }); - it('should match json def', () => { - node.op = 'If'; - node.inputNames = ['cond', 'input1']; - node.inputParams['args'] = createTensorsAttr(1, 0); - node.inputParams['cond'] = createTensorAttr(0); - node.attrParams['thenBranch'] = {'value': 'thenFunc', 'type': 'func'}; - node.attrParams['elseBranch'] = {'value': 'elseFunc', 'type': 'func'}; - - expect(validateParam(node, control.json)).toBeTruthy(); - }); - }); - describe('TensorListReserve', () => { - it('should create new tensor on the context', async () => { - node.op = 'TensorListReserve'; - node.inputParams['elementShape'] = createNumericArrayAttrFromIndex(0); - node.inputParams['numElements'] = createNumberAttrFromIndex(1); - node.attrParams['elementDType'] = createDtypeAttr('int32'); - node.inputNames = ['input4', 'input1']; - const input4 = [tensor1d([10, 10], 'int32')]; - const tensorListId = - (await executeOp(node, {input1, input4}, context))[0]; - const tensorList = context.getTensorList(tensorListId.id); - expect(tensorList.elementDtype).toEqual('int32'); - expect(tensorList.elementShape).toEqual([10, 10]); - expect(tensorList.maxNumElements).toEqual(-1); - }); - it('should match json def', () => { - node.op = 'TensorListReserve'; - node.inputParams['elementShape'] = createShapeAttrFromIndex(0); - node.inputParams['numElements'] = createNumberAttrFromIndex(1); - node.attrParams['elementDType'] = createDtypeAttr('int32'); - - expect(validateParam(node, control.json)).toBeTruthy(); - }); - }); - - describe('EmptyTensorList', () => { - it('should create new tensor on the context', async () => { - node.op = 'EmptyTensorList'; - node.inputParams['elementShape'] = createNumericArrayAttrFromIndex(0); - node.inputParams['maxNumElements'] = createNumberAttrFromIndex(1); - node.attrParams['elementDType'] = createDtypeAttr('int32'); - node.inputNames = ['input4', 'input1']; - const input4 = [tensor1d([10, 10], 'int32')]; - const tensorListId = - (await executeOp(node, {input1, input4}, context))[0]; - const tensorList = context.getTensorList(tensorListId.id); - expect(tensorList.elementDtype).toEqual('int32'); - expect(tensorList.elementShape).toEqual([10, 10]); - expect(tensorList.maxNumElements).toEqual(1); - }); - it('should match json def', () => { - node.op = 'EmptyTensorList'; - node.inputParams['elementShape'] = createShapeAttrFromIndex(0); - node.inputParams['maxNumElements'] = createNumberAttrFromIndex(1); - node.attrParams['elementDType'] = createDtypeAttr('int32'); - - expect(validateParam(node, control.json)).toBeTruthy(); - }); - }); - - describe('TensorListConcat', () => { - it('should concat the tensors from tensorList', async () => { - const input4 = tensor1d([0, 0, 0], 'int32'); - const input5 = tensor1d([1, 1, 1], 'int32'); - const tensorList = new TensorList([input4, input5], [3], 'int32', 5); - context.addTensorList(tensorList); - node.op = 'TensorListConcat'; - node.inputParams['tensorListId'] = createTensorAttr(0); - node.attrParams['elementDType'] = createDtypeAttr('int32'); - node.attrParams['elementShape'] = createTensorShapeAttr([3]); - node.inputNames = ['input2']; - const input2 = [tensorList.idTensor]; - const concat = await executeOp(node, {input2}, context); - expect(concat.length).toEqual(1); - expect(concat[0].shape).toEqual([6]); - test_util.expectArraysClose( - concat[0].dataSync(), new Int32Array([0, 0, 0, 1, 1, 1])); - }); - it('should match json def', () => { - node.op = 'TensorListConcat'; - node.inputParams['tensorListId'] = createTensorAttr(0); - node.attrParams['elementDType'] = createDtypeAttr('int32'); - node.attrParams['elementShape'] = createTensorShapeAttr([3]); - - expect(validateParam(node, control.json)).toBeTruthy(); - }); - }); - - describe('TensorListConcatV2', () => { - it('should concat the tensors from tensorList', async () => { - const input4 = tensor1d([0, 0, 0], 'int32'); - const input5 = tensor1d([1, 1, 1], 'int32'); - const tensorList = new TensorList([input4, input5], [3], 'int32', 5); - context.addTensorList(tensorList); - node.op = 'TensorListConcatV2'; - node.inputParams['tensorListId'] = createTensorAttr(0); - node.attrParams['elementDType'] = createDtypeAttr('int32'); - node.attrParams['elementShape'] = createTensorShapeAttr([3]); - node.inputNames = ['input2']; - const input2 = [tensorList.idTensor]; - const concat = await executeOp(node, {input2}, context); - expect(concat.length).toEqual(1); - expect(concat[0].shape).toEqual([6]); - test_util.expectArraysClose( - concat[0].dataSync(), new Int32Array([0, 0, 0, 1, 1, 1])); - }); - it('should match json def', () => { - node.op = 'TensorListConcatV2'; - node.inputParams['tensorListId'] = createTensorAttr(0); - node.attrParams['elementDType'] = createDtypeAttr('int32'); - node.attrParams['elementShape'] = createTensorShapeAttr([3]); - - expect(validateParam(node, control.json)).toBeTruthy(); - }); - }); - - describe('TensorListScatter', () => { - it('should scatter the tensor to tensorList', async () => { - const input4 = [tensor2d([0, 0, 0, 1, 1, 1], [2, 3], 'int32')]; - node.op = 'TensorListScatter'; - node.inputParams['tensor'] = createTensorAttr(0); - node.inputParams['indices'] = createNumericArrayAttrFromIndex(1); - node.inputParams['elementShape'] = createShapeAttrFromIndex(2); - node.inputNames = ['input4', 'input2', 'input3']; - const input2 = [tensor1d([0, 1], 'int32')]; - const input3 = [tensor1d([3], 'int32')]; - const tensorListId = - (await executeOp(node, {input2, input3, input4}, context))[0]; - const tensorList = context.getTensorList(tensorListId.id); - expect(tensorList.size()).toEqual(2); - }); - - it('should match json def', () => { - node.op = 'TensorListScatter'; - node.inputParams['tensor'] = createTensorAttr(0); - node.inputParams['indices'] = createNumericArrayAttrFromIndex(1); - node.inputParams['elementShape'] = createShapeAttrFromIndex(2); - - expect(validateParam(node, control.json)).toBeTruthy(); - }); - }); - - describe('TensorListScatterV2', () => { - it('should scatter the tensor to tensorList', async () => { - const input4 = [tensor2d([0, 0, 0, 1, 1, 1], [2, 3], 'int32')]; - node.op = 'TensorListScatterV2'; - node.inputParams['tensor'] = createTensorAttr(0); - node.inputParams['indices'] = createNumericArrayAttrFromIndex(1); - node.inputParams['elementShape'] = createShapeAttrFromIndex(2); - node.inputParams['numElements'] = createNumberAttrFromIndex(3); - node.inputNames = ['input4', 'input2', 'input3', 'input5']; - const input2 = [tensor1d([0, 1], 'int32')]; - const input3 = [tensor1d([3], 'int32')]; - const input5 = [tensor1d([2], 'int32')]; - const tensorListId = - (await executeOp(node, {input2, input3, input4, input5}, context))[0]; - const tensorList = context.getTensorList(tensorListId.id); - expect(tensorList.size()).toEqual(2); - }); - - it('should match json def', () => { - node.op = 'TensorListScatterV2'; - node.inputParams['tensor'] = createTensorAttr(0); - node.inputParams['indices'] = createNumericArrayAttrFromIndex(1); - node.inputParams['elementShape'] = createShapeAttrFromIndex(2); - node.inputParams['numElements'] = createNumberAttrFromIndex(3); - - expect(validateParam(node, control.json)).toBeTruthy(); - }); - }); - - describe('TensorListSetItem', () => { - it('should write the tensor to tensorArray', async () => { - const tensorList = new TensorList([], [], 'int32', 5); - context.addTensorList(tensorList); - node.op = 'TensorListSetItem'; - node.inputParams['tensorListId'] = createTensorAttr(0); - node.inputParams['index'] = createNumberAttrFromIndex(1); - node.inputParams['tensor'] = createTensorAttr(2); - node.attrParams['elementDType'] = createDtypeAttr('int32'); - node.inputNames = ['input2', 'input3', 'input1']; - const input2 = [tensorList.idTensor]; - const input3 = [scalar(0)]; - await executeOp(node, {input1, input2, input3}, context); - - expect(tensorList.size()).toEqual(1); - }); - it('should match json def', () => { - node.op = 'TensorListSetItem'; - node.inputParams['tensorListId'] = createTensorAttr(0); - node.inputParams['index'] = createNumberAttrFromIndex(1); - node.inputParams['tensor'] = createTensorAttr(2); - node.attrParams['elementDType'] = createDtypeAttr('int32'); - - expect(validateParam(node, control.json)).toBeTruthy(); - }); - }); - - describe('TensorListGetItem', () => { - it('should read the tensor from tensorList', async () => { - const tensorList = new TensorList([], [3], 'int32', 5); - const input4 = tensor1d([0, 0, 0], 'int32'); - tensorList.setItem(0, input4); - context.addTensorList(tensorList); - node.op = 'TensorListGetItem'; - node.inputParams['tensorListId'] = createTensorAttr(0); - node.inputParams['index'] = createNumberAttrFromIndex(1); - node.inputParams['elementShape'] = createShapeAttrFromIndex(2); - node.inputNames = ['input2', 'input3', 'input5']; - node.attrParams['elementDType'] = createDtypeAttr('int32'); - const input2 = [tensorList.idTensor]; - const input3 = [scalar(0)]; - const input5 = [tensor1d([3], 'int32')]; - const read = await executeOp(node, {input5, input2, input3}, context); - - test_util.expectArraysClose(await read[0].array(), await input4.array()); - }); - it('should match json def', () => { - node.op = 'TensorListGetItem'; - node.inputParams['tensorListId'] = createTensorAttr(0); - node.inputParams['index'] = createNumberAttrFromIndex(1); - node.inputParams['elementShape'] = createShapeAttrFromIndex(2); - node.attrParams['elementDType'] = createDtypeAttr('int32'); - - expect(validateParam(node, control.json)).toBeTruthy(); - }); - }); - - describe('TensorListPushBack', () => { - it('should write the tensor to tensorArray', async () => { - const tensorList = new TensorList([], [], 'int32', 5); - context.addTensorList(tensorList); - node.op = 'TensorListPushBack'; - node.inputParams['tensorListId'] = createTensorAttr(0); - node.inputParams['tensor'] = createTensorAttr(1); - node.attrParams['elementDType'] = createDtypeAttr('int32'); - node.inputNames = ['input2', 'input1']; - const input2 = [tensorList.idTensor]; - await executeOp(node, {input1, input2}, context); - - expect(tensorList.size()).toEqual(1); - }); - it('should match json def', () => { - node.op = 'TensorListPushBack'; - node.inputParams['tensorListId'] = createTensorAttr(0); - node.inputParams['tensor'] = createTensorAttr(1); - node.attrParams['elementDType'] = createDtypeAttr('int32'); - - expect(validateParam(node, control.json)).toBeTruthy(); - }); - }); - - describe('TensorListPopBack', () => { - it('should read the tensor from tensorList', async () => { - const tensorList = new TensorList([], [3], 'int32', 5); - const input4 = tensor1d([0, 0, 0], 'int32'); - tensorList.setItem(0, input4); - context.addTensorList(tensorList); - node.op = 'TensorListPopBack'; - node.inputParams['tensorListId'] = createTensorAttr(0); - node.inputParams['elementShape'] = createShapeAttrFromIndex(1); - node.inputNames = ['input2', 'input5']; - node.attrParams['elementDType'] = createDtypeAttr('int32'); - const input2 = [tensorList.idTensor]; - const input5 = [tensor1d([3], 'int32')]; - const read = await executeOp(node, {input5, input2}, context); - - test_util.expectArraysClose(await read[0].array(), await input4.array()); - }); - it('should match json def', () => { - node.op = 'TensorListPopBack'; - node.inputParams['tensorListId'] = createTensorAttr(0); - node.inputParams['elementShape'] = createShapeAttrFromIndex(1); - node.attrParams['elementDType'] = createDtypeAttr('int32'); - - expect(validateParam(node, control.json)).toBeTruthy(); - }); - }); - - describe('TensorListStack', () => { - it('should read the tensor from tensorList', async () => { - const tensorList = new TensorList([], [3], 'int32', 5); - const input4 = tensor1d([0, 0, 0], 'int32'); - tensorList.setItem(0, input4); - context.addTensorList(tensorList); - node.op = 'TensorListStack'; - node.inputParams['tensorListId'] = createTensorAttr(0); - node.inputParams['elementShape'] = createShapeAttrFromIndex(1); - node.inputNames = ['input2', 'input5']; - node.attrParams['elementDType'] = createDtypeAttr('int32'); - const input2 = [tensorList.idTensor]; - const input5 = [tensor1d([3], 'int32')]; - const read = await executeOp(node, {input5, input2}, context); - - test_util.expectArraysClose( - await read[0].array(), [await input4.array()]); - }); - it('should match json def', () => { - node.op = 'TensorListStack'; - node.inputParams['tensorListId'] = createTensorAttr(0); - node.inputParams['elementShape'] = createShapeAttrFromIndex(1); - node.attrParams['elementDType'] = createDtypeAttr('int32'); - - expect(validateParam(node, control.json)).toBeTruthy(); - }); - - describe('TensorListGather', () => { - it('should read the tensor from tensorList', async () => { - const tensorList = new TensorList([], [3], 'int32', 5); - const input4 = tensor1d([0, 0, 0], 'int32'); - tensorList.setItem(0, input4); - const input6 = tensor1d([1, 1, 1], 'int32'); - tensorList.setItem(1, input6); - context.addTensorList(tensorList); - node.op = 'TensorListGather'; - node.inputParams['tensorListId'] = createTensorAttr(0); - node.inputParams['indices'] = createNumericArrayAttrFromIndex(1); - node.inputParams['elementShape'] = createShapeAttrFromIndex(2); - node.inputNames = ['input2', 'input3', 'input5']; - node.attrParams['elementDType'] = createDtypeAttr('int32'); - const input2 = [tensorList.idTensor]; - const input3 = [tensor1d([0, 1], 'int32')]; - - const input5 = [tensor1d([3], 'int32')]; - const read = await executeOp(node, {input5, input2, input3}, context); - - test_util.expectArraysClose( - await read[0].array(), - [await input4.array(), await input6.array()]); - }); - it('should match json def', () => { - node.op = 'TensorListGather'; - node.inputParams['tensorListId'] = createTensorAttr(0); - node.inputParams['indices'] = createNumericArrayAttrFromIndex(1); - node.inputParams['elementShape'] = createShapeAttrFromIndex(2); - node.attrParams['elementDType'] = createDtypeAttr('int32'); - - expect(validateParam(node, control.json)).toBeTruthy(); - }); - }); - }); - - describe('TensorListSplit', () => { - it('should scatter the tensor to tensorList', async () => { - const input4 = [tensor2d([0, 0, 0, 1, 1, 1], [2, 3], 'int32')]; - node.op = 'TensorListSplit'; - node.inputParams['tensor'] = createTensorAttr(0); - node.inputParams['elementShape'] = createShapeAttrFromIndex(1); - node.inputParams['lengths'] = createNumericArrayAttrFromIndex(2); - node.attrParams['elementDType'] = createDtypeAttr('int32'); - - node.inputNames = ['input4', 'input2', 'input3']; - const input2 = [tensor1d([3], 'int32')]; - const input3 = [tensor1d([1, 1], 'int32')]; - const idTensor = - (await executeOp(node, {input2, input3, input4}, context))[0]; - const tensorList = context.getTensorList(idTensor.id); - expect(tensorList.size()).toEqual(2); - }); - - it('should match json def', () => { - node.op = 'TensorListSplit'; - node.inputParams['tensor'] = createTensorAttr(0); - node.inputParams['elementShape'] = createShapeAttrFromIndex(1); - node.inputParams['lengths'] = createNumericArrayAttrFromIndex(2); - node.attrParams['elementDType'] = createDtypeAttr('int32'); - - expect(validateParam(node, control.json)).toBeTruthy(); - }); - }); - - describe('TensorListLength', () => { - it('should get the size of tensorList', async () => { - const input4 = tensor1d([0, 0, 0], 'int32'); - const input5 = tensor1d([1, 1, 1], 'int32'); - const tensorList = new TensorList([input4, input5], [3], 'int32', 5); - context.addTensorList(tensorList); - node.op = 'TensorListLength'; - node.inputParams['tensorListId'] = createTensorAttr(0); - node.inputNames = ['input2']; - const input2 = [tensorList.idTensor]; - const size = await executeOp(node, {input2}, context); - expect(size.length).toEqual(1); - expect(size[0].shape).toEqual([]); - test_util.expectArraysClose(size[0].dataSync(), [2]); - }); - - it('should match json def', () => { - node.op = 'TensorListLength'; - node.inputParams['tensorListId'] = createTensorAttr(0); - - expect(validateParam(node, control.json)).toBeTruthy(); - }); - }); - - describe('TensorListResize', () => { - it('should match the size when reducing the size', async () => { - const input4 = tensor1d([0, 0, 0], 'int32'); - const input5 = tensor1d([1, 1, 1], 'int32'); - const tensorList = new TensorList([input4, input5], [3], 'int32', 5); - context.addTensorList(tensorList); - node.op = 'TensorListResize'; - node.inputParams['tensorListId'] = createTensorAttr(0); - node.inputParams['size'] = createNumberAttrFromIndex(1); - node.inputNames = ['input2', 'input3']; - const input2 = [tensorList.idTensor]; - const input3 = [scalar(1)]; - const tensorListId = - (await executeOp(node, {input2, input3}, context))[0]; - const destTensorList = context.getTensorList(tensorListId.id); - expect(destTensorList.size()).toEqual(1); - }); - - it('should match the size when increasing the size', async () => { - const input4 = tensor1d([0, 0, 0], 'int32'); - const input5 = tensor1d([1, 1, 1], 'int32'); - const srcTensorList = new TensorList([input4, input5], [3], 'int32', 5); - context.addTensorList(srcTensorList); - node.op = 'TensorListResize'; - node.inputParams['tensorListId'] = createTensorAttr(0); - node.inputParams['size'] = createNumberAttrFromIndex(1); - node.inputNames = ['input2', 'input3']; - const input2 = [srcTensorList.idTensor]; - const input3 = [scalar(3)]; - const destTensorListId = - (await executeOp(node, {input2, input3}, context))[0]; - const destTensorList = context.getTensorList(destTensorListId.id); - expect(destTensorList.size()).toEqual(3); - }); - - it('should match json def', () => { - node.op = 'TensorListResize'; - node.inputParams['tensorListId'] = createTensorAttr(0); - node.inputParams['size'] = createNumberAttrFromIndex(1); - - expect(validateParam(node, control.json)).toBeTruthy(); - }); - }); -}); diff --git a/tfjs-master/tfjs-converter/src/operations/executors/convolution_executor.ts b/tfjs-master/tfjs-converter/src/operations/executors/convolution_executor.ts deleted file mode 100644 index 18658dc06..000000000 --- a/tfjs-master/tfjs-converter/src/operations/executors/convolution_executor.ts +++ /dev/null @@ -1,320 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Rank, Tensor, Tensor3D, Tensor4D, Tensor5D} from '@tensorflow/tfjs-core'; -// tslint:disable-next-line: no-imports-from-dist -import * as tfOps from '@tensorflow/tfjs-core/dist/ops/ops_for_converter'; - -import {NamedTensorsMap} from '../../data/types'; -import {ExecutionContext} from '../../executor/execution_context'; -import {InternalOpExecutor, Node} from '../types'; - -import {getPadding, getParamValue} from './utils'; - -function fusedConvAndDepthWiseParams( - node: Node, tensorMap: NamedTensorsMap, context: ExecutionContext) { - const [extraOp, activationFunc] = - (getParamValue('fusedOps', node, tensorMap, context) as string[]); - - const isBiasAdd = extraOp === 'biasadd'; - const noBiasAdd = !isBiasAdd; - const isPrelu = activationFunc === 'prelu'; - const isBatchNorm = extraOp === 'fusedbatchnorm'; - - const numArgs = - (getParamValue('numArgs', node, tensorMap, context) as number); - if (isBiasAdd) { - if (isPrelu && numArgs !== 2) { - throw new Error( - 'FusedConv2d and DepthwiseConv2d with BiasAdd and Prelu ' + - 'must have two extra arguments: bias and alpha.'); - } - if (!isPrelu && isBiasAdd && numArgs !== 1) { - throw new Error( - 'FusedConv2d and DepthwiseConv2d with BiasAdd must have ' + - 'one extra argument: bias.'); - } - } - if (isBatchNorm) { - throw new Error( - 'FusedConv2d and DepthwiseConv2d with FusedBatchNorm is not supported'); - } - const stride = getParamValue('strides', node, tensorMap, context) as number[]; - const pad = getPadding(node, tensorMap, context); - const dataFormat = - (getParamValue('dataFormat', node, tensorMap, context) as string) - .toUpperCase(); - const dilations = - getParamValue('dilations', node, tensorMap, context) as number[]; - let [biasArg, preluArg] = - getParamValue('args', node, tensorMap, context) as Tensor[]; - if (noBiasAdd) { - preluArg = biasArg; - biasArg = undefined; - } - const leakyreluAlpha = - getParamValue('leakyreluAlpha', node, tensorMap, context) as number; - - return { - stride, - pad, - dataFormat, - dilations, - biasArg, - preluArg, - activationFunc, - leakyreluAlpha - }; -} - -export const executeOp: InternalOpExecutor = - (node: Node, tensorMap: NamedTensorsMap, - context: ExecutionContext, ops = tfOps): Tensor[] => { - switch (node.op) { - case 'Conv1D': { - const stride = - getParamValue('stride', node, tensorMap, context) as number; - const pad = getParamValue('pad', node, tensorMap, context); - const dataFormat = - (getParamValue('dataFormat', node, tensorMap, context) as string) - .toUpperCase(); - const dilation = - getParamValue('dilation', node, tensorMap, context) as number; - return [ops.conv1d( - getParamValue('x', node, tensorMap, context) as Tensor3D, - getParamValue('filter', node, tensorMap, context) as Tensor3D, - stride, pad as 'valid' | 'same', dataFormat as 'NWC' | 'NCW', - dilation)]; - } - case 'Conv2D': { - const stride = - getParamValue('strides', node, tensorMap, context) as number[]; - const pad = getPadding(node, tensorMap, context); - const dataFormat = - (getParamValue('dataFormat', node, tensorMap, context) as string) - .toUpperCase(); - const dilations = - getParamValue('dilations', node, tensorMap, context) as number[]; - return [ops.conv2d( - getParamValue('x', node, tensorMap, context) as Tensor3D | - Tensor4D, - getParamValue('filter', node, tensorMap, context) as Tensor4D, - [stride[1], stride[2]], pad as 'valid' | 'same', - dataFormat as 'NHWC' | 'NCHW', [dilations[1], dilations[2]])]; - } - case '_FusedConv2D': { - const { - stride, - pad, - dataFormat, - dilations, - biasArg, - preluArg, - activationFunc, - leakyreluAlpha - } = fusedConvAndDepthWiseParams(node, tensorMap, context); - - return [ops.fused.conv2d({ - x: getParamValue('x', node, tensorMap, context) as Tensor3D | - Tensor4D, - filter: getParamValue('filter', node, tensorMap, context) as - Tensor4D, - strides: [stride[1], stride[2]], - pad: pad as 'valid' | 'same', - dataFormat: dataFormat as 'NHWC' | 'NCHW', - dilations: [dilations[1], dilations[2]], - bias: biasArg, - activation: activationFunc as tfOps.fused.Activation, - preluActivationWeights: preluArg, - leakyreluAlpha - })]; - } - - case 'FusedDepthwiseConv2dNative': { - const { - stride, - pad, - dataFormat, - dilations, - biasArg, - preluArg, - activationFunc, - leakyreluAlpha, - } = fusedConvAndDepthWiseParams(node, tensorMap, context); - - return [ops.fused.depthwiseConv2d({ - x: getParamValue('x', node, tensorMap, context) as Tensor3D | - Tensor4D, - filter: getParamValue('filter', node, tensorMap, context) as - Tensor4D, - strides: [stride[1], stride[2]], - pad: pad as 'valid' | 'same', - dataFormat: dataFormat as 'NHWC' | 'NCHW', - dilations: [dilations[1], dilations[2]], - bias: biasArg, - activation: activationFunc as tfOps.fused.Activation, - preluActivationWeights: preluArg, - leakyreluAlpha - })]; - } - case 'Conv2DBackpropInput': - case 'Conv2dTranspose': { - const shape = getParamValue( - 'outputShape', node, tensorMap, - context) as [number, number, number] | - [number, number, number, number]; - const stride = - getParamValue('strides', node, tensorMap, context) as number[]; - const pad = getPadding(node, tensorMap, context); - return [ops.conv2dTranspose( - getParamValue('x', node, tensorMap, context) as Tensor3D | - Tensor4D, - getParamValue('filter', node, tensorMap, context) as Tensor4D, - shape, [stride[1], stride[2]], pad as 'valid' | 'same')]; - } - case 'DepthwiseConv2dNative': - case 'DepthwiseConv2d': { - const stride = - getParamValue('strides', node, tensorMap, context) as number[]; - const pad = getPadding(node, tensorMap, context); - const dilations = - getParamValue('dilations', node, tensorMap, context) as number[]; - const dataFormat = - (getParamValue('dataFormat', node, tensorMap, context) as string) - .toUpperCase(); - - return [ops.depthwiseConv2d( - getParamValue('input', node, tensorMap, context) as Tensor3D | - Tensor4D, - getParamValue('filter', node, tensorMap, context) as Tensor4D, - [stride[1], stride[2]], pad as 'valid' | 'same', - dataFormat as 'NHWC' | 'NCHW', [dilations[1], dilations[2]])]; - } - case 'Conv3D': { - const stride = - getParamValue('strides', node, tensorMap, context) as number[]; - const pad = getParamValue('pad', node, tensorMap, context); - const dataFormat = - (getParamValue('dataFormat', node, tensorMap, context) as string) - .toUpperCase(); - const dilations = - getParamValue('dilations', node, tensorMap, context) as number[]; - return [ops.conv3d( - getParamValue('x', node, tensorMap, context) as Tensor4D | - Tensor, - getParamValue('filter', node, tensorMap, context) as - Tensor, - [stride[1], stride[2], stride[3]], pad as 'valid' | 'same', - dataFormat as 'NDHWC' | 'NCDHW', - [dilations[1], dilations[2], dilations[3]])]; - } - case 'AvgPool': { - const stride = - getParamValue('strides', node, tensorMap, context) as number[]; - const pad = getParamValue('pad', node, tensorMap, context); - const kernelSize = - getParamValue('kernelSize', node, tensorMap, context) as number[]; - - return [ops.avgPool( - getParamValue('x', node, tensorMap, context) as Tensor3D | - Tensor4D, - [kernelSize[1], kernelSize[2]], [stride[1], stride[2]], - pad as 'valid' | 'same')]; - } - case 'MaxPool': { - const stride = - getParamValue('strides', node, tensorMap, context) as number[]; - const pad = getParamValue('pad', node, tensorMap, context); - const kernelSize = - getParamValue('kernelSize', node, tensorMap, context) as number[]; - - return [ops.maxPool( - getParamValue('x', node, tensorMap, context) as Tensor3D | - Tensor4D, - [kernelSize[1], kernelSize[2]], [stride[1], stride[2]], - pad as 'valid' | 'same')]; - } - case 'MaxPoolWithArgmax': { - const stride = - getParamValue('strides', node, tensorMap, context) as number[]; - const pad = getParamValue('pad', node, tensorMap, context); - const kernelSize = - getParamValue('kernelSize', node, tensorMap, context) as number[]; - const includeBatchInIndex = - getParamValue('includeBatchInIndex', node, tensorMap, context) as - boolean; - const {result, indexes} = ops.maxPoolWithArgmax( - getParamValue('x', node, tensorMap, context) as Tensor4D, - [kernelSize[1], kernelSize[2]], [stride[1], stride[2]], - pad as 'valid' | 'same', includeBatchInIndex); - return [result, indexes]; - } - case 'AvgPool3D': { - const stride = - getParamValue('strides', node, tensorMap, context) as number[]; - const pad = getParamValue('pad', node, tensorMap, context); - const kernelSize = - getParamValue('kernelSize', node, tensorMap, context) as number[]; - - return [ops.avgPool3d( - getParamValue('x', node, tensorMap, context) as Tensor5D, - [kernelSize[1], kernelSize[2], kernelSize[3]], - [stride[1], stride[2], stride[3]], pad as 'valid' | 'same')]; - } - - case 'MaxPool3D': { - const stride = - getParamValue('strides', node, tensorMap, context) as number[]; - const pad = getParamValue('pad', node, tensorMap, context); - const kernelSize = - getParamValue('kernelSize', node, tensorMap, context) as number[]; - - return [ops.maxPool3d( - getParamValue('x', node, tensorMap, context) as Tensor5D, - [kernelSize[1], kernelSize[2], kernelSize[3]], - [stride[1], stride[2], stride[3]], pad as 'valid' | 'same')]; - } - - case 'Dilation2D': { - const strides = - getParamValue('strides', node, tensorMap, context) as number[]; - const pad = getParamValue('pad', node, tensorMap, context); - const dilations = - getParamValue('dilations', node, tensorMap, context) as number[]; - - // strides: [1, stride_height, stride_width, 1]. - const strideHeight = strides[1]; - const strideWidth = strides[2]; - - // dilations: [1, dilation_height, dilation_width, 1]. - const dilationHeight = dilations[1]; - const dilationWidth = dilations[2]; - - return [ops.dilation2d( - getParamValue('x', node, tensorMap, context) as Tensor3D | - Tensor4D, - getParamValue('filter', node, tensorMap, context) as Tensor3D, - [strideHeight, strideWidth], pad as 'valid' | 'same', - [dilationHeight, dilationWidth], 'NHWC' /* dataFormat */)]; - } - - default: - throw TypeError(`Node type ${node.op} is not implemented`); - } - }; - -export const CATEGORY = 'convolution'; diff --git a/tfjs-master/tfjs-converter/src/operations/executors/convolution_executor_test.ts b/tfjs-master/tfjs-converter/src/operations/executors/convolution_executor_test.ts deleted file mode 100644 index ef3c3c8e3..000000000 --- a/tfjs-master/tfjs-converter/src/operations/executors/convolution_executor_test.ts +++ /dev/null @@ -1,692 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -// tslint:disable-next-line: no-imports-from-dist -import * as tfOps from '@tensorflow/tfjs-core/dist/ops/ops_for_converter'; - -import {ExecutionContext} from '../../executor/execution_context'; -import {Node} from '../types'; - -import {executeOp} from './convolution_executor'; -import {RecursiveSpy} from './spy_ops'; -import {createNumberAttr, createNumericArrayAttr, createStrArrayAttr, createStrAttr, createTensorAttr, createTensorsAttr} from './test_helper'; -import {createBoolAttr} from './test_helper'; - -describe('convolution', () => { - let node: Node; - const input = [tfOps.scalar(1)]; - const context = new ExecutionContext({}, {}, {}); - - let spyOps: RecursiveSpy; - let spyOpsAsTfOps: typeof tfOps; - - beforeEach(() => { - node = { - name: 'test', - op: '', - category: 'convolution', - inputNames: ['input'], - inputs: [], - inputParams: {x: createTensorAttr(0)}, - attrParams: {}, - children: [] - }; - spyOps = - Object.fromEntries(Object.keys(tfOps).map((op: keyof typeof tfOps) => { - if (op === 'fused') { - return [ - op, { - conv2d: jasmine.createSpy(op), - depthwiseConv2d: jasmine.createSpy(op), - matMul: jasmine.createSpy(op), - } - ]; - } - const spy = jasmine.createSpy(op); - return [op, spy] as const ; - })) as unknown as typeof spyOps; - spyOpsAsTfOps = spyOps as unknown as typeof tfOps; - }); - - describe('executeOp', () => { - describe('AvgPool', () => { - it('should call tfOps.avgPool', () => { - node.op = 'AvgPool'; - node.attrParams['strides'] = createNumericArrayAttr([1, 2, 2, 1]); - node.attrParams['pad'] = createStrAttr('same'); - node.attrParams['kernelSize'] = createNumericArrayAttr([1, 2, 2, 1]); - - executeOp(node, {input}, context, spyOpsAsTfOps); - - expect(spyOps.avgPool) - .toHaveBeenCalledWith(input[0], [2, 2], [2, 2], 'same'); - }); - }); - - describe('maxPool', () => { - it('should call tfOps.maxPool', () => { - node.op = 'MaxPool'; - node.attrParams['strides'] = createNumericArrayAttr([1, 2, 2, 1]); - node.attrParams['pad'] = createStrAttr('same'); - node.attrParams['kernelSize'] = createNumericArrayAttr([1, 2, 2, 1]); - - executeOp(node, {input}, context, spyOpsAsTfOps); - - expect(spyOps.maxPool) - .toHaveBeenCalledWith(input[0], [2, 2], [2, 2], 'same'); - }); - }); - describe('Conv2d', () => { - it('should call tfOps.conv2d', () => { - node.op = 'Conv2D'; - node.inputParams['filter'] = createTensorAttr(1); - node.attrParams['strides'] = createNumericArrayAttr([1, 2, 2, 1]); - node.attrParams['pad'] = createStrAttr('same'); - node.attrParams['dataFormat'] = createStrAttr('NHWC'); - node.attrParams['dilations'] = createNumericArrayAttr([1, 2, 2, 1]); - - const input1 = [tfOps.scalar(1.0)]; - const input2 = [tfOps.scalar(1.0)]; - node.inputNames = ['input1', 'input2']; - - executeOp(node, {input1, input2}, context, spyOpsAsTfOps); - - expect(spyOps.conv2d) - .toHaveBeenCalledWith( - input1[0], input2[0], [2, 2], 'same', 'NHWC', [2, 2]); - }); - it('should support explicit padding', () => { - node.op = 'Conv2D'; - node.inputParams['filter'] = createTensorAttr(1); - node.attrParams['strides'] = createNumericArrayAttr([1, 2, 2, 1]); - node.attrParams['pad'] = createStrAttr('explicit'); - node.attrParams['explicitPaddings'] = - createNumericArrayAttr([0, 0, 1, 1, 2, 2, 0, 0]); - node.attrParams['dataFormat'] = createStrAttr('NHWC'); - node.attrParams['dilations'] = createNumericArrayAttr([1, 2, 2, 1]); - - const input1 = [tfOps.scalar(1.0)]; - const input2 = [tfOps.scalar(1.0)]; - node.inputNames = ['input1', 'input2']; - - executeOp(node, {input1, input2}, context, spyOpsAsTfOps); - - expect(spyOps.conv2d) - .toHaveBeenCalledWith( - input1[0], input2[0], [2, 2], [[0, 0], [1, 1], [2, 2], [0, 0]], - 'NHWC', [2, 2]); - }); - }); - describe('Conv2DBackpropInput', () => { - it('should call tfOps.conv2dTranspose', () => { - node.op = 'Conv2DBackpropInput'; - node.attrParams['outputShape'] = createNumericArrayAttr([1, 2, 2, 2]); - node.inputParams['filter'] = createTensorAttr(1); - node.attrParams['strides'] = createNumericArrayAttr([1, 2, 2, 1]); - node.attrParams['pad'] = createStrAttr('same'); - - const input1 = [tfOps.scalar(1.0)]; - const input2 = [tfOps.scalar(1.0)]; - node.inputNames = ['input1', 'input2']; - - executeOp(node, {input1, input2}, context, spyOpsAsTfOps); - - expect(spyOps.conv2dTranspose) - .toHaveBeenCalledWith( - input1[0], input2[0], [1, 2, 2, 2], [2, 2], 'same'); - }); - it('should support explicit padding', () => { - node.op = 'Conv2DBackpropInput'; - node.attrParams['outputShape'] = createNumericArrayAttr([1, 2, 2, 2]); - node.inputParams['filter'] = createTensorAttr(1); - node.attrParams['strides'] = createNumericArrayAttr([1, 2, 2, 1]); - node.attrParams['pad'] = createStrAttr('explicit'); - node.attrParams['explicitPaddings'] = - createNumericArrayAttr([0, 0, 1, 1, 2, 2, 0, 0]); - - const input1 = [tfOps.scalar(1.0)]; - const input2 = [tfOps.scalar(1.0)]; - node.inputNames = ['input1', 'input2']; - - executeOp(node, {input1, input2}, context, spyOpsAsTfOps); - - expect(spyOps.conv2dTranspose) - .toHaveBeenCalledWith( - input1[0], - input2[0], - [1, 2, 2, 2], - [2, 2], - [[0, 0], [1, 1], [2, 2], [0, 0]], - ); - }); - }); - describe('Conv1D', () => { - it('should call tfOps.conv1d', () => { - node.op = 'Conv1D'; - node.category = 'convolution'; - node.inputParams['filter'] = createTensorAttr(1); - node.attrParams['stride'] = createNumberAttr(1); - node.attrParams['pad'] = createStrAttr('same'); - node.attrParams['dataFormat'] = createStrAttr('NWC'); - node.attrParams['dilation'] = createNumberAttr(1); - - const input1 = [tfOps.scalar(1.0)]; - const input2 = [tfOps.scalar(1.0)]; - node.inputNames = ['input1', 'input2']; - - executeOp(node, {input1, input2}, context, spyOpsAsTfOps); - - expect(spyOps.conv1d) - .toHaveBeenCalledWith(input1[0], input2[0], 1, 'same', 'NWC', 1); - }); - }); - - describe('DepthwiseConv2d', () => { - it('should call tfOps.depthwiseConv2d', () => { - node.op = 'DepthwiseConv2d'; - node.category = 'convolution'; - node.inputParams['input'] = createTensorAttr(0); - node.inputParams['filter'] = createTensorAttr(1); - node.attrParams['strides'] = createNumericArrayAttr([1, 2, 2, 1]); - node.attrParams['pad'] = createStrAttr('same'); - node.attrParams['dataFormat'] = createStrAttr('NHWC'); - node.attrParams['dilations'] = createNumericArrayAttr([1, 2, 2, 1]); - const input1 = [tfOps.scalar(1.0)]; - const input2 = [tfOps.scalar(1.0)]; - node.inputNames = ['input1', 'input2']; - - executeOp(node, {input1, input2}, context, spyOpsAsTfOps); - - expect(spyOps.depthwiseConv2d) - .toHaveBeenCalledWith( - input1[0], input2[0], [2, 2], 'same', 'NHWC', [2, 2]); - }); - it('support explicit padding', () => { - node.op = 'DepthwiseConv2d'; - node.category = 'convolution'; - node.inputParams['input'] = createTensorAttr(0); - node.inputParams['filter'] = createTensorAttr(1); - node.attrParams['strides'] = createNumericArrayAttr([1, 2, 2, 1]); - node.attrParams['pad'] = createStrAttr('explicit'); - node.attrParams['explicitPaddings'] = - createNumericArrayAttr([0, 0, 1, 1, 2, 2, 0, 0]); - node.attrParams['dataFormat'] = createStrAttr('NHWC'); - node.attrParams['dilations'] = createNumericArrayAttr([1, 2, 2, 1]); - const input1 = [tfOps.scalar(1.0)]; - const input2 = [tfOps.scalar(1.0)]; - node.inputNames = ['input1', 'input2']; - - executeOp(node, {input1, input2}, context, spyOpsAsTfOps); - - expect(spyOps.depthwiseConv2d) - .toHaveBeenCalledWith( - input1[0], input2[0], [2, 2], [[0, 0], [1, 1], [2, 2], [0, 0]], - 'NHWC', [2, 2]); - }); - }); - - describe('Conv3d', () => { - it('should call tfOps.conv3d', () => { - node.op = 'Conv3D'; - node.category = 'convolution'; - node.inputParams['filter'] = createTensorAttr(1); - node.attrParams['strides'] = createNumericArrayAttr([1, 2, 2, 2, 1]); - node.attrParams['pad'] = createStrAttr('same'); - node.attrParams['dataFormat'] = createStrAttr('NHWC'); - node.attrParams['dilations'] = createNumericArrayAttr([1, 2, 2, 2, 1]); - - const input1 = [tfOps.scalar(1.0)]; - const input2 = [tfOps.scalar(1.0)]; - node.inputNames = ['input1', 'input2']; - - executeOp(node, {input1, input2}, context, spyOpsAsTfOps); - - expect(spyOps.conv3d) - .toHaveBeenCalledWith( - input1[0], input2[0], [2, 2, 2], 'same', 'NHWC', [2, 2, 2]); - }); - }); - - describe('AvgPool3D', () => { - it('should call tfOps.avgPool3d', () => { - node.op = 'AvgPool3D'; - node.attrParams['strides'] = createNumericArrayAttr([1, 2, 2, 2, 1]); - node.attrParams['pad'] = createStrAttr('same'); - node.attrParams['kernelSize'] = createNumericArrayAttr([1, 2, 2, 2, 1]); - - executeOp(node, {input}, context, spyOpsAsTfOps); - - expect(spyOps.avgPool3d) - .toHaveBeenCalledWith(input[0], [2, 2, 2], [2, 2, 2], 'same'); - }); - }); - - describe('MaxPool3D', () => { - it('should call tfOps.maxPool3d', () => { - node.op = 'MaxPool3D'; - node.attrParams['strides'] = createNumericArrayAttr([1, 2, 2, 2, 1]); - node.attrParams['pad'] = createStrAttr('same'); - node.attrParams['kernelSize'] = createNumericArrayAttr([1, 2, 2, 2, 1]); - - executeOp(node, {input}, context, spyOpsAsTfOps); - - expect(spyOps.maxPool3d) - .toHaveBeenCalledWith(input[0], [2, 2, 2], [2, 2, 2], 'same'); - }); - }); - - describe('MaxPoolWithArgmax', () => { - it('should call tfOps.maxPoolWithArgmax', () => { - node.op = 'MaxPoolWithArgmax'; - node.attrParams['strides'] = createNumericArrayAttr([1, 2, 2, 1]); - node.attrParams['pad'] = createStrAttr('same'); - node.attrParams['kernelSize'] = createNumericArrayAttr([1, 2, 2, 1]); - node.attrParams['dataFormat'] = createStrAttr('NDHWC'); - node.attrParams['includeBatchInIndex'] = createBoolAttr(true); - spyOps.maxPoolWithArgmax.and.returnValue( - {result: 'fake', indexes: 'fake'}); - - executeOp(node, {input}, context, spyOpsAsTfOps); - - expect(spyOps.maxPoolWithArgmax) - .toHaveBeenCalledWith(input[0], [2, 2], [2, 2], 'same', true); - }); - }); - - describe('_FusedConv2d', () => { - it('with bias and activation func', () => { - node.op = '_FusedConv2D'; - node.inputParams['filter'] = createTensorAttr(1); - node.inputParams['args'] = createTensorsAttr(2, 0); - node.attrParams['fusedOps'] = createStrArrayAttr(['biasadd', 'relu']); - node.attrParams['strides'] = createNumericArrayAttr([1, 2, 2, 1]); - node.attrParams['pad'] = createStrAttr('same'); - node.attrParams['dataFormat'] = createStrAttr('NHWC'); - node.attrParams['dilations'] = createNumericArrayAttr([1, 2, 2, 1]); - node.attrParams['numArgs'] = createNumberAttr(1); - const input1 = [tfOps.scalar(1.0)]; - const input2 = [tfOps.scalar(2.0)]; - const input3 = [tfOps.scalar(3.0)]; - - node.inputNames = ['input1', 'input2', 'input3']; - executeOp(node, {input1, input2, input3}, context, spyOpsAsTfOps); - - expect(spyOps.fused.conv2d).toHaveBeenCalledWith({ - x: input1[0], - filter: input2[0], - strides: [2, 2], - pad: 'same', - dataFormat: 'NHWC', - dilations: [2, 2], - bias: input3[0], - activation: 'relu', - preluActivationWeights: undefined, - leakyreluAlpha: undefined - }); - }); - it('should support explicit padding', () => { - node.op = '_FusedConv2D'; - node.inputParams['filter'] = createTensorAttr(1); - node.inputParams['args'] = createTensorsAttr(2, 0); - node.attrParams['fusedOps'] = createStrArrayAttr(['biasadd', 'relu']); - node.attrParams['strides'] = createNumericArrayAttr([1, 2, 2, 1]); - node.attrParams['pad'] = createStrAttr('explicit'); - node.attrParams['explicitPaddings'] = - createNumericArrayAttr([0, 0, 1, 1, 2, 2, 0, 0]); - node.attrParams['dataFormat'] = createStrAttr('NHWC'); - node.attrParams['dilations'] = createNumericArrayAttr([1, 2, 2, 1]); - node.attrParams['numArgs'] = createNumberAttr(1); - const input1 = [tfOps.scalar(1.0)]; - const input2 = [tfOps.scalar(2.0)]; - const input3 = [tfOps.scalar(3.0)]; - - node.inputNames = ['input1', 'input2', 'input3']; - executeOp(node, {input1, input2, input3}, context, spyOpsAsTfOps); - - expect(spyOps.fused.conv2d).toHaveBeenCalledWith({ - x: input1[0], - filter: input2[0], - strides: [2, 2], - pad: [[0, 0], [1, 1], [2, 2], [0, 0]], - dataFormat: 'NHWC', - dilations: [2, 2], - bias: input3[0], - activation: 'relu', - preluActivationWeights: undefined, - leakyreluAlpha: undefined - }); - }); - it('with bias and prelu activation func', () => { - node.op = '_FusedConv2D'; - node.inputParams['filter'] = createTensorAttr(1); - node.inputParams['args'] = createTensorsAttr(2, 0); - node.attrParams['fusedOps'] = createStrArrayAttr(['biasadd', 'prelu']); - node.attrParams['strides'] = createNumericArrayAttr([1, 2, 2, 1]); - node.attrParams['pad'] = createStrAttr('same'); - node.attrParams['dataFormat'] = createStrAttr('NHWC'); - node.attrParams['dilations'] = createNumericArrayAttr([1, 2, 2, 1]); - node.attrParams['numArgs'] = createNumberAttr(2); - const input1 = [tfOps.scalar(1.0)]; - const input2 = [tfOps.scalar(2.0)]; - const input3 = [tfOps.scalar(3.0)]; - const input4 = [tfOps.scalar(4.0)]; - node.inputNames = ['input1', 'input2', 'input3', 'input4']; - executeOp( - node, {input1, input2, input3, input4}, context, spyOpsAsTfOps); - - expect(spyOps.fused.conv2d).toHaveBeenCalledWith({ - x: input1[0], - filter: input2[0], - strides: [2, 2], - pad: 'same', - dataFormat: 'NHWC', - dilations: [2, 2], - bias: input3[0], - activation: 'prelu', - preluActivationWeights: input4[0], - leakyreluAlpha: undefined - }); - }); - it('with bias and leakyrelu activation func', () => { - node.op = '_FusedConv2D'; - node.inputParams['filter'] = createTensorAttr(1); - node.inputParams['args'] = createTensorsAttr(2, 0); - node.attrParams['fusedOps'] = - createStrArrayAttr(['biasadd', 'leakyrelu']); - node.attrParams['strides'] = createNumericArrayAttr([1, 2, 2, 1]); - node.attrParams['pad'] = createStrAttr('same'); - node.attrParams['dataFormat'] = createStrAttr('NHWC'); - node.attrParams['dilations'] = createNumericArrayAttr([1, 2, 2, 1]); - node.attrParams['numArgs'] = createNumberAttr(1); - node.attrParams['leakyreluAlpha'] = createNumberAttr(0.3); - const input1 = [tfOps.scalar(1.0)]; - const input2 = [tfOps.scalar(2.0)]; - const input3 = [tfOps.scalar(3.0)]; - node.inputNames = ['input1', 'input2', 'input3']; - executeOp(node, {input1, input2, input3}, context, spyOpsAsTfOps); - - expect(spyOps.fused.conv2d).toHaveBeenCalledWith({ - x: input1[0], - filter: input2[0], - strides: [2, 2], - pad: 'same', - dataFormat: 'NHWC', - dilations: [2, 2], - bias: input3[0], - activation: 'leakyrelu', - preluActivationWeights: undefined, - leakyreluAlpha: 0.3 - }); - }); - - it('bias add', () => { - node.op = '_FusedConv2D'; - node.inputParams['filter'] = createTensorAttr(1); - node.inputParams['args'] = createTensorsAttr(2, 0); - node.attrParams['fusedOps'] = createStrArrayAttr(['biasadd']); - node.attrParams['strides'] = createNumericArrayAttr([1, 2, 2, 1]); - node.attrParams['pad'] = createStrAttr('same'); - node.attrParams['dataFormat'] = createStrAttr('NHWC'); - node.attrParams['dilations'] = createNumericArrayAttr([1, 2, 2, 1]); - node.attrParams['numArgs'] = createNumberAttr(1); - const input1 = [tfOps.scalar(1.0)]; - const input2 = [tfOps.scalar(2.0)]; - const input3 = [tfOps.scalar(3.0)]; - - node.inputNames = ['input1', 'input2', 'input3']; - executeOp(node, {input1, input2, input3}, context, spyOpsAsTfOps); - - expect(spyOps.fused.conv2d).toHaveBeenCalledWith({ - x: input1[0], - filter: input2[0], - strides: [2, 2], - pad: 'same', - dataFormat: 'NHWC', - dilations: [2, 2], - bias: input3[0], - activation: undefined, - preluActivationWeights: undefined, - leakyreluAlpha: undefined - }); - }); - it('fail with batchnorm', () => { - node.op = '_FusedConv2D'; - node.inputParams['filter'] = createTensorAttr(1); - node.inputParams['args'] = createTensorsAttr(2, 0); - node.attrParams['fusedOps'] = createStrArrayAttr(['fusedbatchnorm']); - node.attrParams['strides'] = createNumericArrayAttr([1, 2, 2, 1]); - node.attrParams['pad'] = createStrAttr('same'); - node.attrParams['dataFormat'] = createStrAttr('NHWC'); - node.attrParams['dilations'] = createNumericArrayAttr([1, 2, 2, 1]); - node.attrParams['numArgs'] = createNumberAttr(1); - const input1 = [tfOps.scalar(1.0)]; - const input2 = [tfOps.scalar(2.0)]; - const input3 = [tfOps.scalar(3.0)]; - - node.inputNames = ['input1', 'input2', 'input3']; - expect( - () => executeOp( - node, {input1, input2, input3}, context, spyOpsAsTfOps)) - .toThrow(); - }); - }); - }); - describe('FusedDepthwiseConv2d', () => { - it('support explicit padding', () => { - node.op = 'FusedDepthwiseConv2dNative'; - node.inputParams['filter'] = createTensorAttr(1); - node.inputParams['args'] = createTensorsAttr(2, 0); - node.attrParams['fusedOps'] = createStrArrayAttr(['biasadd', 'relu']); - node.attrParams['strides'] = createNumericArrayAttr([1, 2, 2, 1]); - node.attrParams['pad'] = createStrAttr('explicit'); - node.attrParams['explicitPaddings'] = - createNumericArrayAttr([0, 0, 1, 1, 2, 2, 0, 0]); - node.attrParams['dataFormat'] = createStrAttr('NHWC'); - node.attrParams['dilations'] = createNumericArrayAttr([1, 2, 2, 1]); - node.attrParams['numArgs'] = createNumberAttr(1); - const input1 = [tfOps.scalar(1.0)]; - const input2 = [tfOps.scalar(2.0)]; - const input3 = [tfOps.scalar(3.0)]; - - node.inputNames = ['input1', 'input2', 'input3']; - executeOp(node, {input1, input2, input3}, context, spyOpsAsTfOps); - - expect(spyOps.fused.depthwiseConv2d).toHaveBeenCalledWith({ - x: input1[0], - filter: input2[0], - strides: [2, 2], - pad: [[0, 0], [1, 1], [2, 2], [0, 0]], - dataFormat: 'NHWC', - dilations: [2, 2], - bias: input3[0], - activation: 'relu', - preluActivationWeights: undefined, - leakyreluAlpha: undefined - }); - }); - it('with only activation func', () => { - node.op = 'FusedDepthwiseConv2dNative'; - node.inputParams['filter'] = createTensorAttr(1); - node.inputParams['args'] = createTensorsAttr(2, 0); - node.attrParams['fusedOps'] = createStrArrayAttr(['noop', 'prelu']); - node.attrParams['strides'] = createNumericArrayAttr([1, 2, 2, 1]); - node.attrParams['pad'] = createStrAttr('same'); - node.attrParams['dataFormat'] = createStrAttr('NHWC'); - node.attrParams['dilations'] = createNumericArrayAttr([1, 2, 2, 1]); - node.attrParams['numArgs'] = createNumberAttr(1); - const input1 = [tfOps.scalar(1.0)]; - const input2 = [tfOps.scalar(2.0)]; - const input3 = [tfOps.scalar(3.0)]; - node.inputNames = ['input1', 'input2', 'input3']; - executeOp(node, {input1, input2, input3}, context, spyOpsAsTfOps); - - expect(spyOps.fused.depthwiseConv2d).toHaveBeenCalledWith({ - x: input1[0], - filter: input2[0], - strides: [2, 2], - pad: 'same', - dataFormat: 'NHWC', - dilations: [2, 2], - bias: undefined, - activation: 'prelu', - preluActivationWeights: input3[0], - leakyreluAlpha: undefined - }); - }); - it('with bias and activation func', () => { - node.op = 'FusedDepthwiseConv2dNative'; - node.inputParams['filter'] = createTensorAttr(1); - node.inputParams['args'] = createTensorsAttr(2, 0); - node.attrParams['fusedOps'] = createStrArrayAttr(['biasadd', 'relu']); - node.attrParams['strides'] = createNumericArrayAttr([1, 2, 2, 1]); - node.attrParams['pad'] = createStrAttr('same'); - node.attrParams['dataFormat'] = createStrAttr('NHWC'); - node.attrParams['dilations'] = createNumericArrayAttr([1, 2, 2, 1]); - node.attrParams['numArgs'] = createNumberAttr(1); - const input1 = [tfOps.scalar(1.0)]; - const input2 = [tfOps.scalar(2.0)]; - const input3 = [tfOps.scalar(3.0)]; - - node.inputNames = ['input1', 'input2', 'input3']; - executeOp(node, {input1, input2, input3}, context, spyOpsAsTfOps); - - expect(spyOps.fused.depthwiseConv2d).toHaveBeenCalledWith({ - x: input1[0], - filter: input2[0], - strides: [2, 2], - pad: 'same', - dataFormat: 'NHWC', - dilations: [2, 2], - bias: input3[0], - activation: 'relu', - preluActivationWeights: undefined, - leakyreluAlpha: undefined - }); - }); - it('with bias and prelu activation func', () => { - node.op = 'FusedDepthwiseConv2dNative'; - node.inputParams['filter'] = createTensorAttr(1); - node.inputParams['args'] = createTensorsAttr(2, 0); - node.attrParams['fusedOps'] = createStrArrayAttr(['biasadd', 'prelu']); - node.attrParams['strides'] = createNumericArrayAttr([1, 2, 2, 1]); - node.attrParams['pad'] = createStrAttr('same'); - node.attrParams['dataFormat'] = createStrAttr('NHWC'); - node.attrParams['dilations'] = createNumericArrayAttr([1, 2, 2, 1]); - node.attrParams['numArgs'] = createNumberAttr(2); - const input1 = [tfOps.scalar(1.0)]; - const input2 = [tfOps.scalar(2.0)]; - const input3 = [tfOps.scalar(3.0)]; - const input4 = [tfOps.scalar(4.0)]; - node.inputNames = ['input1', 'input2', 'input3', 'input4']; - executeOp(node, {input1, input2, input3, input4}, context, spyOpsAsTfOps); - - expect(spyOps.fused.depthwiseConv2d).toHaveBeenCalledWith({ - x: input1[0], - filter: input2[0], - strides: [2, 2], - pad: 'same', - dataFormat: 'NHWC', - dilations: [2, 2], - bias: input3[0], - activation: 'prelu', - preluActivationWeights: input4[0], - leakyreluAlpha: undefined - }); - }); - it('with bias and leakyrelu activation func', () => { - node.op = 'FusedDepthwiseConv2dNative'; - node.inputParams['filter'] = createTensorAttr(1); - node.inputParams['args'] = createTensorsAttr(2, 0); - node.attrParams['fusedOps'] = - createStrArrayAttr(['biasadd', 'leakyrelu']); - node.attrParams['strides'] = createNumericArrayAttr([1, 2, 2, 1]); - node.attrParams['pad'] = createStrAttr('same'); - node.attrParams['dataFormat'] = createStrAttr('NHWC'); - node.attrParams['dilations'] = createNumericArrayAttr([1, 2, 2, 1]); - node.attrParams['numArgs'] = createNumberAttr(1); - node.attrParams['leakyreluAlpha'] = createNumberAttr(0.3); - const input1 = [tfOps.scalar(1.0)]; - const input2 = [tfOps.scalar(2.0)]; - const input3 = [tfOps.scalar(3.0)]; - node.inputNames = ['input1', 'input2', 'input3']; - executeOp(node, {input1, input2, input3}, context, spyOpsAsTfOps); - - expect(spyOps.fused.depthwiseConv2d).toHaveBeenCalledWith({ - x: input1[0], - filter: input2[0], - strides: [2, 2], - pad: 'same', - dataFormat: 'NHWC', - dilations: [2, 2], - bias: input3[0], - activation: 'leakyrelu', - preluActivationWeights: undefined, - leakyreluAlpha: 0.3 - }); - }); - - it('bias add', () => { - node.op = 'FusedDepthwiseConv2dNative'; - node.inputParams['filter'] = createTensorAttr(1); - node.inputParams['args'] = createTensorsAttr(2, 0); - node.attrParams['fusedOps'] = createStrArrayAttr(['biasadd']); - node.attrParams['strides'] = createNumericArrayAttr([1, 2, 2, 1]); - node.attrParams['pad'] = createStrAttr('same'); - node.attrParams['dataFormat'] = createStrAttr('NHWC'); - node.attrParams['dilations'] = createNumericArrayAttr([1, 2, 2, 1]); - node.attrParams['numArgs'] = createNumberAttr(1); - const input1 = [tfOps.scalar(1.0)]; - const input2 = [tfOps.scalar(2.0)]; - const input3 = [tfOps.scalar(3.0)]; - - node.inputNames = ['input1', 'input2', 'input3']; - executeOp(node, {input1, input2, input3}, context, spyOpsAsTfOps); - - expect(spyOps.fused.depthwiseConv2d).toHaveBeenCalledWith({ - x: input1[0], - filter: input2[0], - strides: [2, 2], - pad: 'same', - dataFormat: 'NHWC', - dilations: [2, 2], - bias: input3[0], - activation: undefined, - preluActivationWeights: undefined, - leakyreluAlpha: undefined - }); - }); - }); - - describe('dilation2d', () => { - it('should call tfOps.dilation2d', () => { - node.op = 'Dilation2D'; - node.inputParams['filter'] = createTensorAttr(1); - node.attrParams['strides'] = createNumericArrayAttr([1, 1, 1, 1]); - node.attrParams['pad'] = createStrAttr('same'); - node.attrParams['dilations'] = createNumericArrayAttr([1, 2, 2, 1]); - - const input1 = [tfOps.scalar(1.0)]; - const input2 = [tfOps.scalar(1.0)]; - node.inputNames = ['input1', 'input2']; - - executeOp(node, {input1, input2}, context, spyOpsAsTfOps); - - expect(spyOps.dilation2d) - .toHaveBeenCalledWith( - input1[0], input2[0], [1, 1], 'same', [2, 2], 'NHWC'); - }); - }); -}); diff --git a/tfjs-master/tfjs-converter/src/operations/executors/creation_executor.ts b/tfjs-master/tfjs-converter/src/operations/executors/creation_executor.ts deleted file mode 100644 index a13d37a7b..000000000 --- a/tfjs-master/tfjs-converter/src/operations/executors/creation_executor.ts +++ /dev/null @@ -1,143 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {DataType, Tensor, Tensor1D} from '@tensorflow/tfjs-core'; -// tslint:disable-next-line: no-imports-from-dist -import * as tfOps from '@tensorflow/tfjs-core/dist/ops/ops_for_converter'; - -import {NamedTensorsMap} from '../../data/types'; -import {ExecutionContext} from '../../executor/execution_context'; -import {InternalOpExecutor, Node} from '../types'; - -import {getParamValue} from './utils'; - -export const executeOp: InternalOpExecutor = - (node: Node, tensorMap: NamedTensorsMap, context: ExecutionContext, - ops = tfOps): Tensor[] => { - switch (node.op) { - case 'Fill': { - const shape = - getParamValue('shape', node, tensorMap, context) as number[]; - const dtype = - getParamValue('dtype', node, tensorMap, context) as DataType; - const value = - getParamValue('value', node, tensorMap, context) as number; - return [ops.fill(shape, value, dtype)]; - } - case 'LinSpace': { - const start = - getParamValue('start', node, tensorMap, context) as number; - const stop = - getParamValue('stop', node, tensorMap, context) as number; - const num = getParamValue('num', node, tensorMap, context) as number; - return [ops.linspace(start, stop, num)]; - } - case 'Multinomial': { - const logits = - getParamValue('logits', node, tensorMap, context) as Tensor1D; - const numSamples = - getParamValue('numSamples', node, tensorMap, context) as number; - const seed = - getParamValue('seed', node, tensorMap, context) as number; - return [ops.multinomial(logits, numSamples, seed)]; - } - case 'OneHot': { - const indices = - getParamValue('indices', node, tensorMap, context) as Tensor1D; - const depth = - getParamValue('depth', node, tensorMap, context) as number; - const onValue = - getParamValue('onValue', node, tensorMap, context) as number; - const offValue = - getParamValue('offValue', node, tensorMap, context) as number; - const dtype = - getParamValue('dtype', node, tensorMap, context) as DataType; - return [ops.oneHot(indices, depth, onValue, offValue, dtype)]; - } - case 'Ones': { - return [ops.ones( - getParamValue('shape', node, tensorMap, context) as number[], - getParamValue('dtype', node, tensorMap, context) as DataType)]; - } - case 'OnesLike': { - return [ops.onesLike( - getParamValue('x', node, tensorMap, context) as Tensor)]; - } - case 'RandomStandardNormal': { - return [ops.randomStandardNormal( - getParamValue('shape', node, tensorMap, context) as number[], - getParamValue('dtype', node, tensorMap, context) as 'float32' | - 'int32', - getParamValue('seed', node, tensorMap, context) as number)]; - } - case 'RandomUniform': { - return [ops.randomUniform( - // tslint:disable-next-line:no-any - getParamValue('shape', node, tensorMap, context) as any, - getParamValue('minval', node, tensorMap, context) as number, - getParamValue('maxval', node, tensorMap, context) as number, - getParamValue('dtype', node, tensorMap, context) as DataType)]; - } - case 'RandomUniformInt': { - return [ops.randomUniformInt( - getParamValue('shape', node, tensorMap, context) as number[], - getParamValue('minval', node, tensorMap, context) as number, - getParamValue('maxval', node, tensorMap, context) as number, - getParamValue('seed', node, tensorMap, context) as number)]; - } - case 'Range': { - const start = - getParamValue('start', node, tensorMap, context) as number; - const stop = - getParamValue('stop', node, tensorMap, context) as number; - const step = - getParamValue('step', node, tensorMap, context) as number; - return [ops.range( - start, stop, step, - getParamValue('dtype', node, tensorMap, context) as 'float32' | - 'int32')]; - } - case 'TruncatedNormal': { - const shape = - getParamValue('shape', node, tensorMap, context) as number[]; - const mean = - getParamValue('mean', node, tensorMap, context) as number; - const stdDev = - getParamValue('stdDev', node, tensorMap, context) as number; - const seed = - getParamValue('seed', node, tensorMap, context) as number; - return [ops.truncatedNormal( - shape, mean, stdDev, - getParamValue('dtype', node, tensorMap, context) as 'float32' | - 'int32', - seed)]; - } - case 'Zeros': { - return [ops.zeros( - getParamValue('shape', node, tensorMap, context) as number[], - getParamValue('dtype', node, tensorMap, context) as DataType)]; - } - case 'ZerosLike': { - return [ops.zerosLike( - getParamValue('x', node, tensorMap, context) as Tensor)]; - } - default: - throw TypeError(`Node type ${node.op} is not implemented`); - } - }; - -export const CATEGORY = 'creation'; diff --git a/tfjs-master/tfjs-converter/src/operations/executors/creation_executor_test.ts b/tfjs-master/tfjs-converter/src/operations/executors/creation_executor_test.ts deleted file mode 100644 index 10733f8d5..000000000 --- a/tfjs-master/tfjs-converter/src/operations/executors/creation_executor_test.ts +++ /dev/null @@ -1,332 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -// tslint:disable-next-line: no-imports-from-dist -import * as tfOps from '@tensorflow/tfjs-core/dist/ops/ops_for_converter'; - -import {ExecutionContext} from '../../executor/execution_context'; -import * as creation from '../op_list/creation'; -import {Node} from '../types'; - -import {executeOp} from './creation_executor'; -import {RecursiveSpy, spyOnAllFunctions} from './spy_ops'; -import {createDtypeAttr, createNumberAttr, createNumberAttrFromIndex, createNumericArrayAttrFromIndex, createTensorAttr, validateParam} from './test_helper'; - -describe('creation', () => { - let node: Node; - const input1 = [tfOps.tensor1d([1, 2, 3])]; - const input2 = [tfOps.scalar(1)]; - const context = new ExecutionContext({}, {}, {}); - let spyOps: RecursiveSpy; - let spyOpsAsTfOps: typeof tfOps; - - beforeEach(() => { - spyOps = spyOnAllFunctions(tfOps); - spyOpsAsTfOps = spyOps as unknown as typeof tfOps; - - node = { - name: 'test', - op: '', - category: 'creation', - inputNames: ['input1', 'input2'], - inputs: [], - inputParams: {}, - attrParams: {}, - children: [] - }; - }); - - describe('executeOp', () => { - describe('Fill', () => { - it('should call tfOps.fill', () => { - node.op = 'Fill'; - node.inputParams['shape'] = createNumericArrayAttrFromIndex(0); - node.inputParams['value'] = createNumberAttrFromIndex(1); - node.attrParams['dtype'] = createDtypeAttr('int32'); - - executeOp(node, {input1, input2}, context, spyOpsAsTfOps); - - expect(spyOps.fill).toHaveBeenCalledWith([1, 2, 3], 1, 'int32'); - }); - it('should match json def', () => { - node.op = 'Fill'; - node.inputParams['shape'] = createNumericArrayAttrFromIndex(0); - node.inputParams['value'] = createNumberAttrFromIndex(1); - node.attrParams['dtype'] = createDtypeAttr('int32'); - - expect(validateParam(node, creation.json)).toBeTruthy(); - }); - }); - describe('LinSpace', () => { - it('should call tfOps.linspace', () => { - node.op = 'LinSpace'; - node.inputParams['start'] = createNumberAttrFromIndex(0); - node.inputParams['stop'] = createNumberAttrFromIndex(1); - node.inputParams['num'] = createNumberAttrFromIndex(2); - node.inputNames = ['input', 'input2', 'input3']; - const input = [tfOps.scalar(0)]; - const input3 = [tfOps.scalar(2)]; - executeOp(node, {input, input2, input3}, context, spyOpsAsTfOps); - - expect(spyOps.linspace).toHaveBeenCalledWith(0, 1, 2); - }); - it('should match json def', () => { - node.op = 'LinSpace'; - node.inputParams['start'] = createNumberAttrFromIndex(0); - node.inputParams['stop'] = createNumberAttrFromIndex(1); - node.inputParams['num'] = createNumberAttrFromIndex(2); - - expect(validateParam(node, creation.json)).toBeTruthy(); - }); - }); - describe('OneHot', () => { - it('should call tfOps.oneHot', () => { - node.op = 'OneHot'; - node.inputParams['indices'] = createTensorAttr(0); - node.inputParams['depth'] = createNumberAttrFromIndex(1); - node.inputParams['onValue'] = createNumberAttrFromIndex(2); - node.inputParams['offValue'] = createNumberAttrFromIndex(3); - node.attrParams['dtype'] = createDtypeAttr('float32'); - node.inputNames = ['input', 'input2', 'input3', 'input4']; - const input = [tfOps.tensor1d([0])]; - const input3 = [tfOps.scalar(2)]; - const input4 = [tfOps.scalar(3)]; - spyOps.oneHot.and.returnValue({}); - executeOp( - node, {input, input2, input3, input4}, context, spyOpsAsTfOps); - - expect(spyOps.oneHot) - .toHaveBeenCalledWith(input[0], 1, 2, 3, 'float32'); - }); - it('should match json def', () => { - node.op = 'OneHot'; - node.inputParams['indices'] = createTensorAttr(0); - node.inputParams['depth'] = createNumberAttrFromIndex(1); - node.inputParams['onValue'] = createNumberAttrFromIndex(2); - node.inputParams['offValue'] = createNumberAttrFromIndex(3); - node.attrParams['dtype'] = createDtypeAttr('float32'); - - expect(validateParam(node, creation.json)).toBeTruthy(); - }); - }); - describe('Ones', () => { - it('should call tfOps.ones', () => { - node.op = 'Ones'; - node.inputParams['shape'] = createNumericArrayAttrFromIndex(0); - node.attrParams['dtype'] = createDtypeAttr('float32'); - executeOp(node, {input1}, context, spyOpsAsTfOps); - - expect(spyOps.ones).toHaveBeenCalledWith([1, 2, 3], 'float32'); - }); - it('should match json def', () => { - node.op = 'Ones'; - node.inputParams['shape'] = createNumericArrayAttrFromIndex(0); - node.attrParams['dtype'] = createDtypeAttr('float32'); - - expect(validateParam(node, creation.json)).toBeTruthy(); - }); - }); - describe('OnesLike', () => { - it('should call tfOps.onesLike', () => { - node.op = 'OnesLike'; - node.inputParams['x'] = createTensorAttr(0); - executeOp(node, {input1}, context, spyOpsAsTfOps); - - expect(spyOps.onesLike).toHaveBeenCalledWith(input1[0]); - }); - it('should match json def', () => { - node.op = 'OnesLike'; - node.inputParams['x'] = createTensorAttr(0); - - expect(validateParam(node, creation.json)).toBeTruthy(); - }); - }); - describe('Range', () => { - it('should call tfOps.range', () => { - node.op = 'Range'; - node.inputParams['start'] = createNumberAttrFromIndex(0); - node.inputParams['stop'] = createNumberAttrFromIndex(1); - node.inputParams['step'] = createNumberAttrFromIndex(2); - node.attrParams['dtype'] = createDtypeAttr('float32'); - node.inputNames = ['input', 'input2', 'input3']; - const input = [tfOps.scalar(0)]; - const input3 = [tfOps.scalar(2)]; - executeOp(node, {input, input2, input3}, context, spyOpsAsTfOps); - - expect(spyOps.range).toHaveBeenCalledWith(0, 1, 2, 'float32'); - }); - it('should match json def', () => { - node.op = 'Range'; - node.inputParams['start'] = createNumberAttrFromIndex(0); - node.inputParams['stop'] = createNumberAttrFromIndex(1); - node.inputParams['step'] = createNumberAttrFromIndex(2); - node.attrParams['dtype'] = createDtypeAttr('float32'); - - expect(validateParam(node, creation.json)).toBeTruthy(); - }); - }); - describe('RandomStandardNormal', () => { - it('should call tfOps.randomStandardNormal', () => { - node.op = 'RandomStandardNormal'; - node.inputParams['shape'] = createNumericArrayAttrFromIndex(0); - node.inputNames = ['input1']; - node.attrParams['dtype'] = createDtypeAttr('float32'); - node.attrParams['seed'] = createNumberAttr(0); - - executeOp(node, {input1}, context, spyOpsAsTfOps); - - expect(spyOps.randomStandardNormal) - .toHaveBeenCalledWith([1, 2, 3], 'float32', 0); - }); - it('should match json def', () => { - node.op = 'RandomStandardNormal'; - node.inputParams['shape'] = createNumericArrayAttrFromIndex(0); - node.inputNames = ['input1']; - node.attrParams['dtype'] = createDtypeAttr('float32'); - node.attrParams['seed'] = createNumberAttr(0); - - expect(validateParam(node, creation.json)).toBeTruthy(); - }); - }); - describe('RandomUniform', () => { - it('should call tfOps.randomUniform', () => { - node.op = 'RandomUniform'; - node.inputParams['shape'] = createNumericArrayAttrFromIndex(0); - node.inputNames = ['input1']; - node.attrParams['maxval'] = createNumberAttr(1); - node.attrParams['minval'] = createNumberAttr(0); - node.attrParams['dtype'] = createDtypeAttr('float32'); - node.attrParams['seed'] = createNumberAttr(0); - - executeOp(node, {input1}, context, spyOpsAsTfOps); - - expect(spyOps.randomUniform) - .toHaveBeenCalledWith([1, 2, 3], 0, 1, 'float32'); - }); - it('should match json def', () => { - node.op = 'RandomUniform'; - node.inputParams['shape'] = createNumericArrayAttrFromIndex(0); - node.inputNames = ['input1']; - node.attrParams['maxval'] = createNumberAttr(1); - node.attrParams['minval'] = createNumberAttr(0); - node.attrParams['dtype'] = createDtypeAttr('float32'); - node.attrParams['seed'] = createNumberAttr(0); - - expect(validateParam(node, creation.json)).toBeTruthy(); - }); - }); - describe('RandomUniformInt', () => { - it('should call tfOps.randomUniformInt', () => { - node.op = 'RandomUniformInt'; - node.inputParams['shape'] = createNumericArrayAttrFromIndex(0); - node.inputNames = ['input1']; - node.attrParams['maxval'] = createNumberAttr(1); - node.attrParams['minval'] = createNumberAttr(0); - node.attrParams['seed'] = createNumberAttr(456); - - executeOp(node, {input1}, context, spyOpsAsTfOps); - - expect(spyOps.randomUniformInt) - .toHaveBeenCalledWith([1, 2, 3], 0, 1, 456); - }); - it('should match json def', () => { - node.op = 'RandomUniformInt'; - node.inputParams['shape'] = createNumericArrayAttrFromIndex(0); - node.inputNames = ['input1']; - node.attrParams['maxval'] = createNumberAttr(1); - node.attrParams['minval'] = createNumberAttr(0); - node.attrParams['seed'] = createNumberAttr(456); - - expect(validateParam(node, creation.json)).toBeTruthy(); - }); - }); - describe('TruncatedNormal', () => { - it('should call tfOps.truncatedNormal', () => { - node.op = 'TruncatedNormal'; - node.inputParams['shape'] = createNumericArrayAttrFromIndex(0); - node.inputNames = ['input1']; - node.attrParams['stdDev'] = createNumberAttr(1); - node.attrParams['mean'] = createNumberAttr(0); - node.attrParams['dtype'] = createDtypeAttr('float32'); - node.attrParams['seed'] = createNumberAttr(0); - - executeOp(node, {input1}, context, spyOpsAsTfOps); - - expect(spyOps.truncatedNormal) - .toHaveBeenCalledWith([1, 2, 3], 0, 1, 'float32', 0); - }); - it('should match json def', () => { - node.op = 'TruncatedNormal'; - node.inputParams['shape'] = createNumericArrayAttrFromIndex(0); - node.inputNames = ['input1']; - node.attrParams['stdDev'] = createNumberAttr(1); - node.attrParams['mean'] = createNumberAttr(0); - node.attrParams['dtype'] = createDtypeAttr('float32'); - node.attrParams['seed'] = createNumberAttr(0); - - expect(validateParam(node, creation.json)).toBeTruthy(); - }); - }); - describe('Zeros', () => { - it('should call tfOps.zeros', () => { - node.op = 'Zeros'; - node.inputParams['shape'] = createNumericArrayAttrFromIndex(0); - node.attrParams['dtype'] = createDtypeAttr('float32'); - executeOp(node, {input1}, context, spyOpsAsTfOps); - - expect(spyOps.zeros).toHaveBeenCalledWith([1, 2, 3], 'float32'); - }); - it('should match json def', () => { - node.op = 'Zeros'; - node.inputParams['shape'] = createNumericArrayAttrFromIndex(0); - node.attrParams['dtype'] = createDtypeAttr('float32'); - expect(validateParam(node, creation.json)).toBeTruthy(); - }); - }); - describe('ZerosLike', () => { - it('should call tfOps.zerosLike', () => { - node.op = 'ZerosLike'; - node.inputParams['x'] = createTensorAttr(0); - executeOp(node, {input1}, context, spyOpsAsTfOps); - - expect(spyOps.zerosLike).toHaveBeenCalledWith(input1[0]); - }); - it('should match json def', () => { - node.op = 'ZerosLike'; - node.inputParams['x'] = createTensorAttr(0); - expect(validateParam(node, creation.json)).toBeTruthy(); - }); - }); - describe('Multinomial', () => { - it('should call tfOps.multinomial', () => { - node.op = 'Multinomial'; - node.inputParams['logits'] = createTensorAttr(0); - node.inputParams['numSamples'] = createNumberAttrFromIndex(1); - node.attrParams['seed'] = createNumberAttr(2); - executeOp(node, {input1, input2}, context, spyOpsAsTfOps); - - expect(spyOps.multinomial).toHaveBeenCalledWith(input1[0], 1, 2); - }); - it('should match json def', () => { - node.op = 'Multinomial'; - node.inputParams['logits'] = createTensorAttr(0); - node.inputParams['numSamples'] = createNumberAttrFromIndex(1); - node.attrParams['seed'] = createNumberAttr(2); - expect(validateParam(node, creation.json)).toBeTruthy(); - }); - }); - }); -}); diff --git a/tfjs-master/tfjs-converter/src/operations/executors/dynamic_executor.ts b/tfjs-master/tfjs-converter/src/operations/executors/dynamic_executor.ts deleted file mode 100644 index 801ec2ebf..000000000 --- a/tfjs-master/tfjs-converter/src/operations/executors/dynamic_executor.ts +++ /dev/null @@ -1,114 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Tensor, Tensor1D, Tensor2D} from '@tensorflow/tfjs-core'; -// tslint:disable-next-line: no-imports-from-dist -import * as tfOps from '@tensorflow/tfjs-core/dist/ops/ops_for_converter'; - -import {NamedTensorsMap} from '../../data/types'; -import {ExecutionContext} from '../../executor/execution_context'; -import { ResourceManager } from '../../executor/resource_manager'; -import {InternalOpAsyncExecutor, Node} from '../types'; - -import {getParamValue} from './utils'; - -function nmsParams( - node: Node, tensorMap: NamedTensorsMap, context: ExecutionContext) { - const boxes = getParamValue('boxes', node, tensorMap, context) as Tensor; - const scores = getParamValue('scores', node, tensorMap, context) as Tensor; - const maxOutputSize = - getParamValue('maxOutputSize', node, tensorMap, context) as number; - const iouThreshold = - getParamValue('iouThreshold', node, tensorMap, context) as number; - const scoreThreshold = - getParamValue('scoreThreshold', node, tensorMap, context) as number; - const softNmsSigma = - getParamValue('softNmsSigma', node, tensorMap, context) as number; - - return { - boxes, - scores, - maxOutputSize, - iouThreshold, - scoreThreshold, - softNmsSigma - }; -} - -export const executeOp: InternalOpAsyncExecutor = async( - node: Node, tensorMap: NamedTensorsMap, - context: ExecutionContext, resourceManager: ResourceManager, - ops = tfOps): Promise => { - switch (node.op) { - case 'NonMaxSuppressionV5': { - const { - boxes, - scores, - maxOutputSize, - iouThreshold, - scoreThreshold, - softNmsSigma - } = nmsParams(node, tensorMap, context); - - const result = await ops.image.nonMaxSuppressionWithScoreAsync( - boxes as Tensor2D, scores as Tensor1D, maxOutputSize, iouThreshold, - scoreThreshold, softNmsSigma); - - return [result.selectedIndices, result.selectedScores]; - } - case 'NonMaxSuppressionV4': { - const {boxes, scores, maxOutputSize, iouThreshold, scoreThreshold} = - nmsParams(node, tensorMap, context); - - const padToMaxOutputSize = - getParamValue('padToMaxOutputSize', node, tensorMap, context) as - boolean; - - const result = await ops.image.nonMaxSuppressionPaddedAsync( - boxes as Tensor2D, scores as Tensor1D, maxOutputSize, iouThreshold, - scoreThreshold, padToMaxOutputSize); - - return [result.selectedIndices, result.validOutputs]; - } - case 'NonMaxSuppressionV3': - case 'NonMaxSuppressionV2': { - const {boxes, scores, maxOutputSize, iouThreshold, scoreThreshold} = - nmsParams(node, tensorMap, context); - - return [await ops.image.nonMaxSuppressionAsync( - boxes as Tensor2D, scores as Tensor1D, maxOutputSize, iouThreshold, - scoreThreshold)]; - } - case 'Where': { - const condition = ops.cast( - (getParamValue('condition', node, tensorMap, context) as Tensor), - 'bool'); - const result = [await ops.whereAsync(condition)]; - condition.dispose(); - return result; - } - case 'ListDiff': { - return ops.setdiff1dAsync( - getParamValue('x', node, tensorMap, context) as Tensor, - getParamValue('y', node, tensorMap, context) as Tensor); - } - default: - throw TypeError(`Node type ${node.op} is not implemented`); - } -}; - -export const CATEGORY = 'dynamic'; diff --git a/tfjs-master/tfjs-converter/src/operations/executors/dynamic_executor_test.ts b/tfjs-master/tfjs-converter/src/operations/executors/dynamic_executor_test.ts deleted file mode 100644 index 5e052d629..000000000 --- a/tfjs-master/tfjs-converter/src/operations/executors/dynamic_executor_test.ts +++ /dev/null @@ -1,259 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {memory} from '@tensorflow/tfjs-core'; -// tslint:disable-next-line: no-imports-from-dist -import * as tfOps from '@tensorflow/tfjs-core/dist/ops/ops_for_converter'; - -import {ExecutionContext} from '../../executor/execution_context'; -import * as dynamic from '../op_list/dynamic'; -import {Node} from '../types'; - -import {executeOp} from './dynamic_executor'; -import {RecursiveSpy, spyOnAllFunctions} from './spy_ops'; -import {createBoolAttr, createNumberAttrFromIndex, createTensorAttr, validateParam} from './test_helper'; - -describe('dynamic', () => { - let node: Node; - const input1 = [tfOps.tensor1d([1])]; - const context = new ExecutionContext({}, {}, {}); - let spyOps: RecursiveSpy; - let spyOpsAsTfOps: typeof tfOps; - - beforeEach(() => { - spyOps = spyOnAllFunctions(tfOps); - spyOpsAsTfOps = spyOps as unknown as typeof tfOps; - node = { - name: 'input1', - op: '', - category: 'dynamic', - inputNames: ['input1'], - inputs: [], - inputParams: {}, - attrParams: {}, - children: [] - }; - }); - - describe('executeOp', () => { - describe('NonMaxSuppressionV2', () => { - it('should return input', () => { - node.op = 'NonMaxSuppressionV2'; - node.inputParams['boxes'] = createTensorAttr(0); - node.inputParams['scores'] = createTensorAttr(1); - node.inputParams['maxOutputSize'] = createNumberAttrFromIndex(2); - node.inputParams['iouThreshold'] = createNumberAttrFromIndex(3); - node.inputParams['scoreThreshold'] = createNumberAttrFromIndex(4); - node.inputNames = ['input1', 'input2', 'input3', 'input4', 'input5']; - const input2 = [tfOps.tensor1d([1])]; - const input3 = [tfOps.tensor1d([1])]; - const input4 = [tfOps.tensor1d([1])]; - const input5 = [tfOps.tensor1d([1])]; - spyOps.image.nonMaxSuppressionAsync.and.returnValue({}); - - const result = executeOp( - node, {input1, input2, input3, input4, input5}, context, undefined, - spyOpsAsTfOps); - expect(spyOps.image.nonMaxSuppressionAsync) - .toHaveBeenCalledWith(input1[0], input2[0], 1, 1, 1); - expect(result instanceof Promise).toBeTruthy(); - }); - it('should match json def', () => { - node.op = 'NonMaxSuppressionV2'; - node.inputParams['boxes'] = createTensorAttr(0); - node.inputParams['scores'] = createTensorAttr(1); - node.inputParams['maxOutputSize'] = createNumberAttrFromIndex(2); - node.inputParams['iouThreshold'] = createNumberAttrFromIndex(3); - node.inputParams['scoreThreshold'] = createNumberAttrFromIndex(4); - node.inputNames = ['input1', 'input2', 'input3', 'input4', 'input5']; - - expect(validateParam(node, dynamic.json, 'NonMaxSuppressionV3')) - .toBeTruthy(); - }); - }); - describe('NonMaxSuppressionV3', () => { - it('should return input', () => { - node.op = 'NonMaxSuppressionV3'; - node.inputParams['boxes'] = createTensorAttr(0); - node.inputParams['scores'] = createTensorAttr(1); - node.inputParams['maxOutputSize'] = createNumberAttrFromIndex(2); - node.inputParams['iouThreshold'] = createNumberAttrFromIndex(3); - node.inputParams['scoreThreshold'] = createNumberAttrFromIndex(4); - node.inputNames = ['input1', 'input2', 'input3', 'input4', 'input5']; - const input2 = [tfOps.tensor1d([1])]; - const input3 = [tfOps.tensor1d([1])]; - const input4 = [tfOps.tensor1d([1])]; - const input5 = [tfOps.tensor1d([1])]; - spyOps.image.nonMaxSuppressionAsync.and.returnValue({}); - - const result = executeOp( - node, {input1, input2, input3, input4, input5}, context, undefined, - spyOpsAsTfOps); - expect(spyOps.image.nonMaxSuppressionAsync) - .toHaveBeenCalledWith(input1[0], input2[0], 1, 1, 1); - expect(result instanceof Promise).toBeTruthy(); - }); - it('should match json def', () => { - node.op = 'NonMaxSuppressionV3'; - node.inputParams['boxes'] = createTensorAttr(0); - node.inputParams['scores'] = createTensorAttr(1); - node.inputParams['maxOutputSize'] = createNumberAttrFromIndex(2); - node.inputParams['iouThreshold'] = createNumberAttrFromIndex(3); - node.inputParams['scoreThreshold'] = createNumberAttrFromIndex(4); - node.inputNames = ['input1', 'input2', 'input3', 'input4', 'input5']; - - expect(validateParam(node, dynamic.json, 'NonMaxSuppressionV3')) - .toBeTruthy(); - }); - }); - - describe('NonMaxSuppressionV4', () => { - it('should return input', () => { - node.op = 'NonMaxSuppressionV4'; - node.inputParams['boxes'] = createTensorAttr(0); - node.inputParams['scores'] = createTensorAttr(1); - node.inputParams['maxOutputSize'] = createNumberAttrFromIndex(2); - node.inputParams['iouThreshold'] = createNumberAttrFromIndex(3); - node.inputParams['scoreThreshold'] = createNumberAttrFromIndex(4); - node.attrParams['padToMaxOutputSize'] = createBoolAttr(true); - node.inputNames = ['input1', 'input2', 'input3', 'input4', 'input5']; - const input2 = [tfOps.tensor1d([1])]; - const input3 = [tfOps.tensor1d([1])]; - const input4 = [tfOps.tensor1d([1])]; - const input5 = [tfOps.tensor1d([1])]; - - spyOps.image.nonMaxSuppressionPaddedAsync.and.returnValue({}); - - const result = executeOp( - node, {input1, input2, input3, input4, input5}, context, undefined, - spyOpsAsTfOps); - expect(spyOps.image.nonMaxSuppressionPaddedAsync) - .toHaveBeenCalledWith(input1[0], input2[0], 1, 1, 1, true); - expect(result instanceof Promise).toBeTruthy(); - }); - it('should match json def', () => { - node.op = 'NonMaxSuppressionV4'; - node.inputParams['boxes'] = createTensorAttr(0); - node.inputParams['scores'] = createTensorAttr(1); - node.inputParams['maxOutputSize'] = createNumberAttrFromIndex(2); - node.inputParams['iouThreshold'] = createNumberAttrFromIndex(3); - node.inputParams['scoreThreshold'] = createNumberAttrFromIndex(4); - node.attrParams['padToMaxOutputSize'] = createBoolAttr(true); - node.inputNames = ['input1', 'input2', 'input3', 'input4', 'input5']; - - expect(validateParam(node, dynamic.json, 'NonMaxSuppressionV4')) - .toBeTruthy(); - }); - }); - - describe('NonMaxSuppressionV5', () => { - it('should return input', () => { - node.op = 'NonMaxSuppressionV5'; - node.inputParams['boxes'] = createTensorAttr(0); - node.inputParams['scores'] = createTensorAttr(1); - node.inputParams['maxOutputSize'] = createNumberAttrFromIndex(2); - node.inputParams['iouThreshold'] = createNumberAttrFromIndex(3); - node.inputParams['scoreThreshold'] = createNumberAttrFromIndex(4); - node.inputParams['softNmsSigma'] = createNumberAttrFromIndex(5); - node.inputNames = - ['input1', 'input2', 'input3', 'input4', 'input5', 'input6']; - const input2 = [tfOps.tensor1d([1])]; - const input3 = [tfOps.tensor1d([1])]; - const input4 = [tfOps.tensor1d([1])]; - const input5 = [tfOps.tensor1d([1])]; - const input6 = [tfOps.tensor1d([1])]; - spyOps.image.nonMaxSuppressionWithScoreAsync.and.returnValue({}); - const result = executeOp( - node, {input1, input2, input3, input4, input5, input6}, context, - undefined, spyOpsAsTfOps); - expect(spyOps.image.nonMaxSuppressionWithScoreAsync) - .toHaveBeenCalledWith(input1[0], input2[0], 1, 1, 1, 1); - expect(result instanceof Promise).toBeTruthy(); - }); - it('should match json def', () => { - node.op = 'NonMaxSuppressionV5'; - node.inputParams['boxes'] = createTensorAttr(0); - node.inputParams['scores'] = createTensorAttr(1); - node.inputParams['maxOutputSize'] = createNumberAttrFromIndex(2); - node.inputParams['iouThreshold'] = createNumberAttrFromIndex(3); - node.inputParams['scoreThreshold'] = createNumberAttrFromIndex(4); - node.inputParams['softNmsSigma'] = createNumberAttrFromIndex(5); - node.inputNames = - ['input1', 'input2', 'input3', 'input4', 'input5', 'input6']; - - expect(validateParam(node, dynamic.json, 'NonMaxSuppressionV5')) - .toBeTruthy(); - }); - }); - - describe('Where', () => { - it('should call tfOps.whereAsync', async () => { - node.op = 'Where'; - node.inputParams = {'condition': createTensorAttr(0)}; - const input1 = [tfOps.scalar(1)]; - // spyOn(tfOps, 'whereAsync'); - - const result = - executeOp(node, {input1}, context, undefined, spyOpsAsTfOps); - expect(spyOps.whereAsync.calls.mostRecent().args[0].dtype) - .toEqual('bool'); - expect(spyOps.whereAsync.calls.mostRecent().args[0].arraySync()) - .toEqual(1); - expect(result instanceof Promise).toBeTruthy(); - }); - it('should match json def', () => { - node.op = 'Where'; - node.inputParams = {'condition': createTensorAttr(0)}; - - expect(validateParam(node, dynamic.json)).toBeTruthy(); - }); - it('should not have memory leak', async () => { - node.op = 'Where'; - node.inputParams = {'condition': createTensorAttr(0)}; - const input1 = [tfOps.scalar(1)]; - - const prevCount = memory().numTensors; - await executeOp(node, {input1}, context); - const afterCount = memory().numTensors; - expect(afterCount).toEqual(prevCount + 1); - }); - }); - - describe('ListDiff', () => { - it('should call tfOps.setdiff1dAsync', async () => { - node.op = 'ListDiff'; - node.inputNames = ['input1', 'input2']; - node.inputParams = {'x': createTensorAttr(0), 'y': createTensorAttr(1)}; - const input1 = [tfOps.scalar(1)]; - const input2 = [tfOps.scalar(1)]; - spyOps.setdiff1dAsync.and.returnValue({}); - - const result = executeOp( - node, {input1, input2}, context, undefined, spyOpsAsTfOps); - expect(spyOps.setdiff1dAsync) - .toHaveBeenCalledWith(input1[0], input2[0]); - expect(result instanceof Promise).toBeTruthy(); - }); - it('should match json def', () => { - node.op = 'ListDiff'; - node.inputNames = ['input1', 'input2']; - node.inputParams = {'x': createTensorAttr(0), 'y': createTensorAttr(1)}; - - expect(validateParam(node, dynamic.json)).toBeTruthy(); - }); - }); - }); -}); diff --git a/tfjs-master/tfjs-converter/src/operations/executors/evaluation_executor.ts b/tfjs-master/tfjs-converter/src/operations/executors/evaluation_executor.ts deleted file mode 100644 index 6020624ac..000000000 --- a/tfjs-master/tfjs-converter/src/operations/executors/evaluation_executor.ts +++ /dev/null @@ -1,74 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Tensor} from '@tensorflow/tfjs-core'; -// tslint:disable-next-line: no-imports-from-dist -import * as tfOps from '@tensorflow/tfjs-core/dist/ops/ops_for_converter'; - -import {NamedTensorsMap} from '../../data/types'; -import {ExecutionContext} from '../../executor/execution_context'; -import {InternalOpExecutor, Node} from '../types'; - -import {getParamValue} from './utils'; - -export const executeOp: InternalOpExecutor = - (node: Node, tensorMap: NamedTensorsMap, context: ExecutionContext, - ops = tfOps): - Tensor[] => { - switch (node.op) { - case 'LowerBound': { - const sortedSequence = - getParamValue('sortedSequence', node, tensorMap, context) as - Tensor; - const values = - getParamValue('values', node, tensorMap, context) as Tensor; - return [ops.lowerBound(sortedSequence, values)]; - } - case 'TopKV2': { - const x = getParamValue('x', node, tensorMap, context) as Tensor; - const k = getParamValue('k', node, tensorMap, context) as number; - const sorted = - getParamValue('sorted', node, tensorMap, context) as boolean; - const result = ops.topk(x, k, sorted); - return [result.values, result.indices]; - } - case 'UpperBound': { - const sortedSequence = - getParamValue('sortedSequence', node, tensorMap, context) as - Tensor; - const values = - getParamValue('values', node, tensorMap, context) as Tensor; - return [ops.upperBound(sortedSequence, values)]; - } - case 'Unique': { - const x = getParamValue('x', node, tensorMap, context) as Tensor; - const result = ops.unique(x); - return [result.values, result.indices]; - } - case 'UniqueV2': { - const x = getParamValue('x', node, tensorMap, context) as Tensor; - const axis = - getParamValue('axis', node, tensorMap, context) as number; - const result = ops.unique(x, axis); - return [result.values, result.indices]; - } - default: - throw TypeError(`Node type ${node.op} is not implemented`); - } - }; - -export const CATEGORY = 'evaluation'; diff --git a/tfjs-master/tfjs-converter/src/operations/executors/evaluation_executor_test.ts b/tfjs-master/tfjs-converter/src/operations/executors/evaluation_executor_test.ts deleted file mode 100644 index 919fdf0a0..000000000 --- a/tfjs-master/tfjs-converter/src/operations/executors/evaluation_executor_test.ts +++ /dev/null @@ -1,139 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -// tslint:disable-next-line: no-imports-from-dist -import * as tfOps from '@tensorflow/tfjs-core/dist/ops/ops_for_converter'; - -import {ExecutionContext} from '../../executor/execution_context'; -import {Node} from '../types'; - -import {executeOp} from './evaluation_executor'; -import {RecursiveSpy, spyOnAllFunctions} from './spy_ops'; -import {createBoolAttr, createNumberAttrFromIndex, createTensorAttr} from './test_helper'; - -describe('evaluation', () => { - let node: Node; - const input1 = [tfOps.tensor1d([1])]; - const input2 = [tfOps.scalar(1)]; - const context = new ExecutionContext({}, {}, {}); - - beforeEach(() => { - node = { - name: 'input1', - op: '', - category: 'evaluation', - inputNames: ['input1', 'input2'], - inputs: [], - inputParams: {}, - attrParams: {}, - children: [] - }; - }); - - describe('executeOp', () => { - let spyOps: RecursiveSpy; - let spyOpsAsTfOps: typeof tfOps; - - beforeEach(() => { - spyOps = spyOnAllFunctions(tfOps); - spyOpsAsTfOps = spyOps as unknown as typeof tfOps; - }); - - describe('LowerBound', () => { - it('should return input', () => { - node.op = 'LowerBound'; - node.inputParams['sortedSequence'] = createTensorAttr(0); - node.inputParams['values'] = createTensorAttr(1); - node.inputNames = ['sortedSequence', 'values']; - - const sortedSequence = [tfOps.tensor2d( - [0., 3., 8., 9., 10., 1., 2., 3., 4., 5.], [2, 5], 'int32')]; - const values = [tfOps.tensor2d( - [ - 9.8, - 2.1, - 4.3, - 0.1, - 6.6, - 4.5, - ], - [2, 3], 'float32')]; - executeOp(node, {sortedSequence, values}, context, spyOpsAsTfOps); - expect(spyOps.lowerBound) - .toHaveBeenCalledWith(sortedSequence[0], values[0]); - }); - }); - - describe('TopKV2', () => { - it('should return input', () => { - node.op = 'TopKV2'; - node.inputParams['x'] = createTensorAttr(0); - node.inputParams['k'] = createNumberAttrFromIndex(1); - node.attrParams['sorted'] = createBoolAttr(true); - executeOp(node, {input1, input2}, context, spyOpsAsTfOps); - expect(spyOps.topk).toHaveBeenCalledWith(input1[0], 1, true); - }); - }); - - describe('UpperBound', () => { - it('should return input', () => { - node.op = 'UpperBound'; - node.inputParams['sortedSequence'] = createTensorAttr(0); - node.inputParams['values'] = createTensorAttr(1); - node.inputNames = ['sortedSequence', 'values']; - - const sortedSequence = [tfOps.tensor2d( - [0., 3., 8., 9., 10., 1., 2., 3., 4., 5.], [2, 5], 'int32')]; - const values = [tfOps.tensor2d( - [ - 9.8, - 2.1, - 4.3, - 0.1, - 6.6, - 4.5, - ], - [2, 3], 'float32')]; - executeOp(node, {sortedSequence, values}, context, spyOpsAsTfOps); - expect(spyOps.upperBound) - .toHaveBeenCalledWith(sortedSequence[0], values[0]); - }); - }); - - describe('Unique', () => { - it('should get called correctly', () => { - node.op = 'Unique'; - node.inputParams['x'] = createTensorAttr(0); - executeOp(node, {input1}, context, spyOpsAsTfOps); - expect(spyOps.unique).toHaveBeenCalledWith(input1[0]); - }); - }); - - describe('UniqueV2', () => { - it('should get called correctly', () => { - node.op = 'UniqueV2'; - node.inputParams['x'] = createTensorAttr(0); - node.inputParams['axis'] = createNumberAttrFromIndex(1); - const xInput = [tfOps.tensor2d([[1], [2]])]; - const axisInput = [tfOps.scalar(1)]; - executeOp( - node, {'input1': xInput, 'input2': axisInput}, context, - spyOpsAsTfOps); - expect(spyOps.unique).toHaveBeenCalledWith(xInput[0], 1); - }); - }); - }); -}); diff --git a/tfjs-master/tfjs-converter/src/operations/executors/graph_executor.ts b/tfjs-master/tfjs-converter/src/operations/executors/graph_executor.ts deleted file mode 100644 index f6ba57e76..000000000 --- a/tfjs-master/tfjs-converter/src/operations/executors/graph_executor.ts +++ /dev/null @@ -1,94 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Tensor} from '@tensorflow/tfjs-core'; -// tslint:disable-next-line: no-imports-from-dist -import * as tfOps from '@tensorflow/tfjs-core/dist/ops/ops_for_converter'; - -import {NamedTensorsMap} from '../../data/types'; -import {ExecutionContext} from '../../executor/execution_context'; -import {InternalOpExecutor, Node} from '../types'; - -import {cloneTensor, getParamValue, getTensor} from './utils'; - -export const executeOp: InternalOpExecutor = - (node: Node, tensorMap: NamedTensorsMap, - context: ExecutionContext, ops = tfOps): Tensor[] => { - switch (node.op) { - case 'Const': { - return tensorMap[node.name]; - } - case 'PlaceholderWithDefault': - const def = - getParamValue('default', node, tensorMap, context) as Tensor; - return [getTensor(node.name, tensorMap, context) || def]; - case 'Placeholder': - return [getTensor(node.name, tensorMap, context)]; - case 'Identity': - case 'StopGradient': - case 'FakeQuantWithMinMaxVars': { // This op is currently ignored. - const data = getParamValue('x', node, tensorMap, context) as Tensor; - return [cloneTensor(data)]; - } - case 'IdentityN': - return (getParamValue('x', node, tensorMap, context) as Tensor[]) - .map((t: Tensor) => cloneTensor(t)); - case 'Snapshot': - const snapshot = - (getParamValue('x', node, tensorMap, context) as Tensor); - return [cloneTensor(snapshot)]; - case 'Shape': - return [ops.tensor1d( - (getParamValue('x', node, tensorMap, context) as Tensor).shape, - 'int32')]; - case 'ShapeN': - return (getParamValue('x', node, tensorMap, context) as Tensor[]) - .map((t: Tensor) => ops.tensor1d(t.shape)); - case 'Size': - return [ops.scalar( - (getParamValue('x', node, tensorMap, context) as Tensor).size, - 'int32')]; - case 'Rank': - return [ops.scalar( - (getParamValue('x', node, tensorMap, context) as Tensor).rank, - 'int32')]; - case 'NoOp': - return [ops.scalar(1)]; - case 'Print': - const input = getParamValue('x', node, tensorMap, context) as Tensor; - const data = - getParamValue('data', node, tensorMap, context) as Tensor[]; - const message = - getParamValue('message', node, tensorMap, context) as string; - const summarize = - getParamValue('summarize', node, tensorMap, context) as number; - console.warn( - 'The graph has a tf.print() operation,' + - 'usually used for debugging, which slows down performance.'); - console.log(message); - for (let i = 0; i < data.length; i++) { - console.log(Array.prototype.slice.call(data[i].dataSync()) - .slice(0, summarize)); - } - return [input]; - - default: - throw TypeError(`Node type ${node.op} is not implemented`); - } - }; - -export const CATEGORY = 'graph'; diff --git a/tfjs-master/tfjs-converter/src/operations/executors/graph_executor_test.ts b/tfjs-master/tfjs-converter/src/operations/executors/graph_executor_test.ts deleted file mode 100644 index 1e32e4bee..000000000 --- a/tfjs-master/tfjs-converter/src/operations/executors/graph_executor_test.ts +++ /dev/null @@ -1,193 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {Tensor} from '@tensorflow/tfjs-core'; -import {test_util} from '@tensorflow/tfjs-core'; -// tslint:disable-next-line: no-imports-from-dist -import * as tfOps from '@tensorflow/tfjs-core/dist/ops/ops_for_converter'; - -import {ExecutionContext} from '../../executor/execution_context'; -import {Node} from '../types'; - -import {executeOp} from './graph_executor'; -import {createNumberAttr, createStrAttr, createTensorAttr, createTensorsAttr} from './test_helper'; - -describe('graph', () => { - let node: Node; - const input1 = [tfOps.tensor1d([1])]; - const input2 = [tfOps.tensor1d([1])]; - const input3 = [tfOps.tensor3d([1, 1, 1, 2, 2, 2], [1, 2, 3])]; - const context = new ExecutionContext({}, {}, {}); - - beforeEach(() => { - node = { - name: 'input1', - op: '', - category: 'graph', - inputNames: [], - inputs: [], - inputParams: {}, - attrParams: {}, - children: [] - }; - }); - - describe('executeOp', () => { - describe('Const', () => { - it('should return input', () => { - node.op = 'Const'; - expect(executeOp(node, {input1}, context)).toEqual(input1); - }); - }); - describe('placeholder', () => { - it('should return input', () => { - node.op = 'Placeholder'; - expect(executeOp(node, {input1}, context)).toEqual(input1); - }); - it('should return default if input not set', () => { - node.inputNames = ['input2']; - node.op = 'PlaceholderWithDefault'; - node.inputParams.default = createTensorAttr(0); - expect(executeOp(node, {input2}, context)).toEqual(input2); - }); - }); - describe('Identity', () => { - it('should return input', async () => { - node.inputNames = ['input']; - node.inputParams.x = createTensorAttr(0); - node.op = 'Identity'; - test_util.expectArraysEqual( - await (executeOp(node, {input: input1}, context) as Tensor[])[0] - .array(), - await input1[0].array()); - }); - }); - describe('IdentityN', () => { - it('should return inputs', () => { - node.inputNames = ['input1', 'input3']; - node.inputParams.x = createTensorsAttr(0, 0); - node.op = 'IdentityN'; - expect( - (executeOp(node, {input1, input3}, context) as Tensor[]).map(t => { - return Array.prototype.slice.call(t.dataSync()); - })) - .toEqual([[1], [1, 1, 1, 2, 2, 2]]); - }); - }); - describe('Snapshot', () => { - it('should return input', async () => { - node.inputNames = ['input']; - node.inputParams.x = createTensorAttr(0); - node.op = 'Snapshot'; - const result = - (executeOp(node, {input: input1}, context) as Tensor[])[0]; - expect(result.rank).toEqual(input1[0].rank); - test_util.expectArraysClose(await result.data(), [1]); - }); - }); - describe('Shape', () => { - it('should return shape', () => { - node.inputNames = ['input']; - node.inputParams.x = createTensorAttr(0); - node.op = 'Shape'; - expect(Array.prototype.slice.call( - (executeOp(node, {input: input3}, context) as Tensor[])[0] - .dataSync())) - .toEqual([1, 2, 3]); - }); - }); - describe('ShapeN', () => { - it('should return shapeN', () => { - node.inputNames = ['input1', 'input3']; - node.inputParams.x = createTensorsAttr(0, 0); - node.op = 'ShapeN'; - expect( - (executeOp(node, {input1, input3}, context) as Tensor[]).map(t => { - return Array.prototype.slice.call(t.dataSync()); - })) - .toEqual([[1], [1, 2, 3]]); - }); - }); - describe('Size', () => { - it('should return size', () => { - node.inputNames = ['input']; - node.inputParams.x = createTensorAttr(0); - node.op = 'Size'; - expect(Array.prototype.slice.call( - (executeOp(node, {input: input3}, context) as Tensor[])[0] - .dataSync())) - .toEqual([6]); - }); - }); - describe('Rank', () => { - it('should return rank', () => { - node.inputNames = ['input']; - node.inputParams.x = createTensorAttr(0); - node.op = 'Rank'; - expect(Array.prototype.slice.call( - (executeOp(node, {input: input3}, context) as Tensor[])[0] - .dataSync())) - .toEqual([3]); - }); - }); - describe('NoOp', () => { - it('should return empty', async () => { - node.op = 'NoOp'; - test_util.expectArraysClose( - await (executeOp(node, {}, context) as Tensor[])[0].data(), [1]); - }); - }); - }); - describe('Print', () => { - it('should return empty', () => { - node.op = 'Print'; - node.inputNames = ['input1', 'input2']; - node.inputParams.x = createTensorAttr(0); - node.inputParams.data = createTensorsAttr(1, 2); - node.attrParams.message = createStrAttr('message'); - node.attrParams.summarize = createNumberAttr(1); - spyOn(console, 'log').and.callThrough(); - spyOn(console, 'warn').and.callThrough(); - - expect(executeOp(node, {input1, input2}, context)).toEqual(input1); - expect(console.warn).toHaveBeenCalled(); - expect(console.log).toHaveBeenCalledWith('message'); - expect(console.log).toHaveBeenCalledWith([1]); - }); - }); - describe('StopGradient', () => { - it('should return input', async () => { - node.inputNames = ['input']; - node.inputParams.x = createTensorAttr(0); - node.op = 'StopGradient'; - test_util.expectArraysClose( - await (executeOp(node, {input: input1}, context) as Tensor[])[0] - .array(), - await input1[0].array()); - }); - }); - describe('FakeQuantWithMinMaxVars', () => { - it('should return input', async () => { - node.inputNames = ['input']; - node.inputParams.x = createTensorAttr(0); - node.op = 'FakeQuantWithMinMaxVars'; - test_util.expectArraysClose( - await (executeOp(node, {input: input1}, context) as Tensor[])[0] - .array(), - await input1[0].array()); - }); - }); -}); diff --git a/tfjs-master/tfjs-converter/src/operations/executors/hash_table_executor.ts b/tfjs-master/tfjs-converter/src/operations/executors/hash_table_executor.ts deleted file mode 100644 index 6a040abc5..000000000 --- a/tfjs-master/tfjs-converter/src/operations/executors/hash_table_executor.ts +++ /dev/null @@ -1,91 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {DataType, Tensor} from '@tensorflow/tfjs-core'; - -import {NamedTensorsMap} from '../../data/types'; -import {ExecutionContext} from '../../executor/execution_context'; -import {HashTable} from '../../executor/hash_table'; -import {ResourceManager} from '../../executor/resource_manager'; -import {InternalOpAsyncExecutor, Node} from '../types'; - -import {getParamValue} from './utils'; - -export const executeOp: InternalOpAsyncExecutor = async( - node: Node, tensorMap: NamedTensorsMap, context: ExecutionContext, - resourceManager: ResourceManager): Promise => { - switch (node.op) { - case 'HashTable': - case 'HashTableV2': { - const existingTableHandle = - resourceManager.getHashTableHandleByName(node.name); - // Table is shared with initializer. - if (existingTableHandle != null) { - return [existingTableHandle]; - } else { - const keyDType = - getParamValue('keyDType', node, tensorMap, context) as DataType; - const valueDType = - getParamValue('valueDType', node, tensorMap, context) as DataType; - - const hashTable = new HashTable(keyDType, valueDType); - resourceManager.addHashTable(node.name, hashTable); - return [hashTable.handle]; - } - } - case 'InitializeTable': - case 'InitializeTableV2': - case 'LookupTableImport': - case 'LookupTableImportV2': { - const handle = getParamValue( - 'tableHandle', node, tensorMap, context, - resourceManager) as Tensor; - const keys = getParamValue('keys', node, tensorMap, context) as Tensor; - const values = - getParamValue('values', node, tensorMap, context) as Tensor; - - const hashTable = resourceManager.getHashTableById(handle.id); - - return [await hashTable.import(keys, values)]; - } - case 'LookupTableFind': - case 'LookupTableFindV2': { - const handle = getParamValue( - 'tableHandle', node, tensorMap, context, - resourceManager) as Tensor; - const keys = getParamValue('keys', node, tensorMap, context) as Tensor; - const defaultValue = - getParamValue('defaultValue', node, tensorMap, context) as Tensor; - - const hashTable = resourceManager.getHashTableById(handle.id); - return [await hashTable.find(keys, defaultValue)]; - } - case 'LookupTableSize': - case 'LookupTableSizeV2': { - const handle = getParamValue( - 'tableHandle', node, tensorMap, context, - resourceManager) as Tensor; - - const hashTable = resourceManager.getHashTableById(handle.id); - return [hashTable.tensorSize()]; - } - default: - throw TypeError(`Node type ${node.op} is not implemented`); - } -}; - -export const CATEGORY = 'hash_table'; diff --git a/tfjs-master/tfjs-converter/src/operations/executors/hash_table_executor_test.ts b/tfjs-master/tfjs-converter/src/operations/executors/hash_table_executor_test.ts deleted file mode 100644 index 64cc3d12e..000000000 --- a/tfjs-master/tfjs-converter/src/operations/executors/hash_table_executor_test.ts +++ /dev/null @@ -1,515 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * ============================================================================= - */ -import {memory, test_util} from '@tensorflow/tfjs-core'; - -// tslint:disable-next-line: no-imports-from-dist -import * as tfOps from '@tensorflow/tfjs-core/dist/ops/ops_for_converter'; - -import {ExecutionContext} from '../../executor/execution_context'; -import {HashTable} from '../../executor/hash_table'; -import {ResourceManager} from '../../executor/resource_manager'; -import * as hashTable from '../op_list/hash_table'; -import {Node} from '../types'; - -import {executeOp} from './hash_table_executor'; -import {createDtypeAttr, createTensorAttr, validateParam} from './test_helper'; - -describe('hash_table', () => { - let node: Node; - const context = new ExecutionContext({}, {}, {}); - let resourceManager: ResourceManager; - - beforeEach(() => { - node = { - name: 'test', - op: '', - category: 'hash_table', - inputNames: [], - inputs: [], - inputParams: {}, - attrParams: {}, - children: [] - }; - resourceManager = new ResourceManager(); - }); - - afterEach(() => { - resourceManager.dispose(); - }); - - describe('executeOp', () => { - describe('HashTable', () => { - it('should create new tensor on the resourceManager.', async () => { - node.op = 'HashTable'; - node.attrParams['keyDType'] = createDtypeAttr('string'); - node.attrParams['valueDType'] = createDtypeAttr('float32'); - - const before = memory().numTensors; - const handle = (await executeOp(node, {}, context, resourceManager))[0]; - const after = memory().numTensors; - // 1 handle is created. - expect(after).toBe(before + 1); - expect(resourceManager.getHashTableById(handle.id)).toBeDefined(); - expect(Object.keys(resourceManager.hashTableMap).length).toBe(1); - }); - it('should match json def.', () => { - node.op = 'HashTable'; - node.attrParams['keyDType'] = createDtypeAttr('string'); - node.attrParams['valueDType'] = createDtypeAttr('float32'); - - expect(validateParam(node, hashTable.json)).toBeTruthy(); - }); - }); - - describe('HashTableV2', () => { - it('should create new tensor on the resourceManager.', async () => { - node.op = 'HashTableV2'; - node.attrParams['keyDType'] = createDtypeAttr('string'); - node.attrParams['valueDType'] = createDtypeAttr('float32'); - - const before = memory().numTensors; - const handle = (await executeOp(node, {}, context, resourceManager))[0]; - const after = memory().numTensors; - // 1 handle is created. - expect(after).toBe(before + 1); - expect(resourceManager.getHashTableById(handle.id)).toBeDefined(); - expect(Object.keys(resourceManager.hashTableMap).length).toBe(1); - }); - it('should match json def.', () => { - node.op = 'HashTableV2'; - node.attrParams['keyDType'] = createDtypeAttr('string'); - node.attrParams['valueDType'] = createDtypeAttr('float32'); - - expect(validateParam(node, hashTable.json)).toBeTruthy(); - }); - }); - - for (const opName of ['LookupTableImport', 'LookupTableImportV2', - 'InitializeTable', 'InitializeTableV2']) { - describe(opName, () => { - it('should return hashTable handle.', async () => { - const hashTable = new HashTable('string', 'float32'); - - resourceManager.addHashTable('hashtable', hashTable); - - node.op = opName; - node.inputParams['tableHandle'] = createTensorAttr(0); - node.inputParams['keys'] = createTensorAttr(1); - node.inputParams['values'] = createTensorAttr(2); - node.inputNames = ['hashtable', 'input3', 'input5']; - const input3 = [tfOps.tensor1d(['a'], 'string')]; - const input5 = [tfOps.tensor1d([5.5])]; - - const before = memory().numTensors; - (await executeOp(node, {input3, input5}, context, resourceManager)); - const after = memory().numTensors; - expect(after).toBe(before + 1); - }); - - it('should throw if dtype doesnot match.', async () => { - const hashTable = new HashTable('string', 'float32'); - - resourceManager.addHashTable('hashtable', hashTable); - - node.op = opName; - node.inputParams['tableHandle'] = createTensorAttr(0); - node.inputParams['keys'] = createTensorAttr(1); - node.inputParams['values'] = createTensorAttr(2); - node.inputNames = ['hashtable', 'input3', 'input5']; - const input3 = [tfOps.tensor1d([1])]; - const input5 = [tfOps.tensor1d([5.5])]; - - const before = memory().numTensors; - try { - await executeOp(node, {input3, input5}, context, resourceManager); - fail('Should fail, succeed unexpectedly.'); - } catch (err) { - expect(err).toMatch(/Expect key dtype/); - } - const after = memory().numTensors; - expect(after).toBe(before); - }); - - it('should throw if length of keys and values doesnot match.', - async () => { - const hashTable = new HashTable('string', 'float32'); - - resourceManager.addHashTable('hashtable', hashTable); - - node.op = opName; - node.inputParams['tableHandle'] = createTensorAttr(0); - node.inputParams['keys'] = createTensorAttr(1); - node.inputParams['values'] = createTensorAttr(2); - node.inputNames = ['hashtable', 'input3', 'input5']; - const input3 = [tfOps.tensor1d(['a', 'b'])]; - const input5 = [tfOps.tensor1d([5.5])]; - - const before = memory().numTensors; - try { - await executeOp(node, {input3, input5}, context, - resourceManager); - fail('Should fail, succeed unexpectedly.'); - } catch (err) { - expect(err).toMatch(/The number of elements doesn't match/); - } - const after = memory().numTensors; - expect(after).toBe(before); - }); - - it('should match json def.', () => { - node.op = opName; - node.inputParams['tableHandle'] = createTensorAttr(0); - node.inputParams['keys'] = createTensorAttr(1); - node.inputParams['values'] = createTensorAttr(2); - - expect(validateParam(node, hashTable.json)).toBeTruthy(); - }); - }); - } - - describe('LookupTableFind', () => { - it('should find the value from hashtable.', async () => { - const hashTable = new HashTable('string', 'float32'); - - resourceManager.addHashTable('hashtable', hashTable); - - const importNode: Node = { - name: 'importv2', - op: 'LookupTableImportV2', - category: 'hash_table', - inputNames: ['hashtable', 'keys', 'values'], - inputs: [], - inputParams: { - tableHandle: createTensorAttr(0), - keys: createTensorAttr(1), - values: createTensorAttr(2) - }, - attrParams: {}, - children: [] - }; - - const keys = [tfOps.tensor1d(['a'], 'string')]; - const values = [tfOps.tensor1d([5.5])]; - - (await executeOp(importNode, {keys, values}, context, resourceManager)); - - node.op = 'LookupTableFind'; - node.inputParams['tableHandle'] = createTensorAttr(0); - node.inputParams['keys'] = createTensorAttr(1); - node.inputParams['defaultValue'] = createTensorAttr(2); - node.inputNames = ['hashtable', 'input3', 'input5']; - const input3 = [tfOps.tensor1d(['a', 'b'], 'string')]; - const input5 = [tfOps.scalar(0)]; - - const before = memory().numTensors; - - const result = - (await executeOp(node, {input3, input5}, context, resourceManager)); - const after = memory().numTensors; - test_util.expectArraysClose(await result[0].data(), [5.5, 0]); - - // Create a result tensor. - expect(after).toBe(before + 1); - }); - it('should throw if dtype doesnot match.', async () => { - const hashTable = new HashTable('string', 'float32'); - - resourceManager.addHashTable('hashtable', hashTable); - - const importNode: Node = { - name: 'importv2', - op: 'LookupTableImportV2', - category: 'hash_table', - inputNames: ['hashtable', 'keys', 'values'], - inputs: [], - inputParams: { - tableHandle: createTensorAttr(0), - keys: createTensorAttr(1), - values: createTensorAttr(2) - }, - attrParams: {}, - children: [] - }; - - const keys = [tfOps.tensor1d(['a'], 'string')]; - const values = [tfOps.tensor1d([5.5])]; - - (await executeOp(importNode, {keys, values}, context, resourceManager)); - - node.op = 'LookupTableFind'; - node.inputParams['tableHandle'] = createTensorAttr(0); - node.inputParams['keys'] = createTensorAttr(1); - node.inputParams['defaultValue'] = createTensorAttr(2); - node.inputNames = ['hashtable', 'input3', 'input5']; - const input3 = [tfOps.tensor1d([1, 2], 'float32')]; - const input5 = [tfOps.scalar(0)]; - - const before = memory().numTensors; - try { - await executeOp(node, {input3, input5}, context, resourceManager); - fail('Shoudl fail, succeed unexpectedly.'); - } catch (err) { - expect(err).toMatch(/Expect key dtype/); - } - const after = memory().numTensors; - expect(after).toBe(before); - }); - it('should match json def.', () => { - node.op = 'LookupTableFind'; - node.inputParams['tableHandle'] = createTensorAttr(0); - node.inputParams['keys'] = createTensorAttr(1); - node.inputParams['defaultValue'] = createTensorAttr(2); - - expect(validateParam(node, hashTable.json)).toBeTruthy(); - }); - }); - - describe('LookupTableFindV2', () => { - it('should find the value from hashtable.', async () => { - const hashTable = new HashTable('string', 'float32'); - - resourceManager.addHashTable('hashtable', hashTable); - - const importNode: Node = { - name: 'importv2', - op: 'LookupTableImportV2', - category: 'hash_table', - inputNames: ['hashtable', 'keys', 'values'], - inputs: [], - inputParams: { - tableHandle: createTensorAttr(0), - keys: createTensorAttr(1), - values: createTensorAttr(2) - }, - attrParams: {}, - children: [] - }; - - const keys = [tfOps.tensor1d(['a'], 'string')]; - const values = [tfOps.tensor1d([5.5])]; - - (await executeOp(importNode, {keys, values}, context, resourceManager)); - - node.op = 'LookupTableFindV2'; - node.inputParams['tableHandle'] = createTensorAttr(0); - node.inputParams['keys'] = createTensorAttr(1); - node.inputParams['defaultValue'] = createTensorAttr(2); - node.inputNames = ['hashtable', 'input3', 'input5']; - const input3 = [tfOps.tensor1d(['a', 'b'], 'string')]; - const input5 = [tfOps.scalar(0)]; - - const before = memory().numTensors; - - const result = - (await executeOp(node, {input3, input5}, context, resourceManager)); - const after = memory().numTensors; - test_util.expectArraysClose(await result[0].data(), [5.5, 0]); - - // Create a result tensor. - expect(after).toBe(before + 1); - }); - it('should throw if dtype doesnot match.', async () => { - const hashTable = new HashTable('string', 'float32'); - - resourceManager.addHashTable('hashtable', hashTable); - - const importNode: Node = { - name: 'importv2', - op: 'LookupTableImportV2', - category: 'hash_table', - inputNames: ['hashtable', 'keys', 'values'], - inputs: [], - inputParams: { - tableHandle: createTensorAttr(0), - keys: createTensorAttr(1), - values: createTensorAttr(2) - }, - attrParams: {}, - children: [] - }; - - const keys = [tfOps.tensor1d(['a'], 'string')]; - const values = [tfOps.tensor1d([5.5])]; - - (await executeOp(importNode, {keys, values}, context, resourceManager)); - - node.op = 'LookupTableFindV2'; - node.inputParams['tableHandle'] = createTensorAttr(0); - node.inputParams['keys'] = createTensorAttr(1); - node.inputParams['defaultValue'] = createTensorAttr(2); - node.inputNames = ['hashtable', 'input3', 'input5']; - const input3 = [tfOps.tensor1d([1, 2], 'float32')]; - const input5 = [tfOps.scalar(0)]; - - const before = memory().numTensors; - try { - await executeOp(node, {input3, input5}, context, resourceManager); - fail('Shoudl fail, succeed unexpectedly.'); - } catch (err) { - expect(err).toMatch(/Expect key dtype/); - } - const after = memory().numTensors; - expect(after).toBe(before); - }); - it('should match json def.', () => { - node.op = 'LookupTableFindV2'; - node.inputParams['tableHandle'] = createTensorAttr(0); - node.inputParams['keys'] = createTensorAttr(1); - node.inputParams['defaultValue'] = createTensorAttr(2); - - expect(validateParam(node, hashTable.json)).toBeTruthy(); - }); - }); - describe('LookupTableSize', () => { - it('should return 0 if the hashtable is empty.', async () => { - const hashTable = new HashTable('string', 'float32'); - resourceManager.addHashTable('hashtablesize', hashTable); - const importNode: Node = { - name: 'importv2', - op: 'LookupTableImportV2', - category: 'hash_table', - inputNames: ['hashtablesize', 'keys', 'values'], - inputs: [], - inputParams: { - tableHandle: createTensorAttr(0), - keys: createTensorAttr(1), - values: createTensorAttr(2) - }, - attrParams: {}, - children: [] - }; - // Import empty tensors - const keys = [tfOps.tensor1d([], 'string')]; - const values = [tfOps.tensor1d([])]; - (await executeOp(importNode, {keys, values}, context, resourceManager)); - - node.op = 'LookupTableSize'; - node.inputParams['tableHandle'] = createTensorAttr(0); - node.inputNames = ['hashtablesize']; - const before = memory().numTensors; - const result = await executeOp(node, {}, context, resourceManager); - const after = memory().numTensors; - const size = await result[0].data(); - - test_util.expectArraysClose(size, [0]); - expect(after).toBe(before + 1); - }); - it('should return the number of elements in the hashtable.', async () => { - const hashTable = new HashTable('string', 'float32'); - resourceManager.addHashTable('hashtablesize', hashTable); - const importNode: Node = { - name: 'importv2', - op: 'LookupTableImportV2', - category: 'hash_table', - inputNames: ['hashtablesize', 'keys', 'values'], - inputs: [], - inputParams: { - tableHandle: createTensorAttr(0), - keys: createTensorAttr(1), - values: createTensorAttr(2) - }, - attrParams: {}, - children: [] - }; - // Import tensors with 2 elements - const keys = [tfOps.tensor1d(['a', 'b'], 'string')]; - const values = [tfOps.tensor1d([5.5, 10])]; - (await executeOp(importNode, {keys, values}, context, resourceManager)); - - node.op = 'LookupTableSize'; - node.inputParams['tableHandle'] = createTensorAttr(0); - node.inputNames = ['hashtablesize']; - const before = memory().numTensors; - const result = await executeOp(node, {}, context, resourceManager); - const after = memory().numTensors; - const size = await result[0].data(); - - test_util.expectArraysClose(size, [2]); - expect(after).toBe(before + 1); - }); - }); - describe('LookupTableSizeV2', () => { - it('should return 0 if the hashtable is empty.', async () => { - const hashTable = new HashTable('string', 'float32'); - resourceManager.addHashTable('hashtablesize', hashTable); - const importNode: Node = { - name: 'importv2', - op: 'LookupTableImportV2', - category: 'hash_table', - inputNames: ['hashtablesize', 'keys', 'values'], - inputs: [], - inputParams: { - tableHandle: createTensorAttr(0), - keys: createTensorAttr(1), - values: createTensorAttr(2) - }, - attrParams: {}, - children: [] - }; - // Import empty tensors - const keys = [tfOps.tensor1d([], 'string')]; - const values = [tfOps.tensor1d([])]; - (await executeOp(importNode, {keys, values}, context, resourceManager)); - - node.op = 'LookupTableSizeV2'; - node.inputParams['tableHandle'] = createTensorAttr(0); - node.inputNames = ['hashtablesize']; - const before = memory().numTensors; - const result = await executeOp(node, {}, context, resourceManager); - const after = memory().numTensors; - const size = await result[0].data(); - - test_util.expectArraysClose(size, [0]); - expect(after).toBe(before + 1); - }); - it('should return the number of elements in the hashtable.', async () => { - const hashTable = new HashTable('string', 'float32'); - resourceManager.addHashTable('hashtablesize', hashTable); - const importNode: Node = { - name: 'importv2', - op: 'LookupTableImportV2', - category: 'hash_table', - inputNames: ['hashtablesize', 'keys', 'values'], - inputs: [], - inputParams: { - tableHandle: createTensorAttr(0), - keys: createTensorAttr(1), - values: createTensorAttr(2) - }, - attrParams: {}, - children: [] - }; - // Import tensors with 2 elements - const keys = [tfOps.tensor1d(['a', 'b'], 'string')]; - const values = [tfOps.tensor1d([5.5, 10])]; - (await executeOp(importNode, {keys, values}, context, resourceManager)); - - node.op = 'LookupTableSizeV2'; - node.inputParams['tableHandle'] = createTensorAttr(0); - node.inputNames = ['hashtablesize']; - const before = memory().numTensors; - const result = await executeOp(node, {}, context, resourceManager); - const after = memory().numTensors; - const size = await result[0].data(); - - test_util.expectArraysClose(size, [2]); - expect(after).toBe(before + 1); - }); - }); - }); -}); diff --git a/tfjs-master/tfjs-converter/src/operations/executors/image_executor.ts b/tfjs-master/tfjs-converter/src/operations/executors/image_executor.ts deleted file mode 100644 index 87e29d40d..000000000 --- a/tfjs-master/tfjs-converter/src/operations/executors/image_executor.ts +++ /dev/null @@ -1,109 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Tensor, Tensor1D, Tensor2D, Tensor3D, Tensor4D} from '@tensorflow/tfjs-core'; -// tslint:disable-next-line: no-imports-from-dist -import * as tfOps from '@tensorflow/tfjs-core/dist/ops/ops_for_converter'; - -import {NamedTensorsMap} from '../../data/types'; -import {ExecutionContext} from '../../executor/execution_context'; -import {InternalOpExecutor, Node} from '../types'; - -import {getParamValue} from './utils'; - -export const executeOp: InternalOpExecutor = - (node: Node, tensorMap: NamedTensorsMap, - context: ExecutionContext, ops = tfOps): Tensor[] => { - switch (node.op) { - case 'ResizeBilinear': { - const images = - getParamValue('images', node, tensorMap, context) as Tensor; - const size = - getParamValue('size', node, tensorMap, context) as number[]; - const alignCorners = - getParamValue('alignCorners', node, tensorMap, context) as - boolean; - const halfPixelCenters = - getParamValue('halfPixelCenters', node, tensorMap, context) as - boolean; - return [ops.image.resizeBilinear( - images as Tensor3D | Tensor4D, [size[0], size[1]], alignCorners, - halfPixelCenters)]; - } - case 'ResizeNearestNeighbor': { - const images = - getParamValue('images', node, tensorMap, context) as Tensor; - const size = - getParamValue('size', node, tensorMap, context) as number[]; - const alignCorners = - getParamValue('alignCorners', node, tensorMap, context) as - boolean; - const halfPixelCenters = - getParamValue('halfPixelCenters', node, tensorMap, context) as - boolean; - return [ops.image.resizeNearestNeighbor( - images as Tensor3D | Tensor4D, [size[0], size[1]], alignCorners, - halfPixelCenters)]; - } - case 'CropAndResize': { - const image = - getParamValue('image', node, tensorMap, context) as Tensor; - const boxes = - getParamValue('boxes', node, tensorMap, context) as Tensor; - const boxInd = - getParamValue('boxInd', node, tensorMap, context) as Tensor; - const cropSize = - getParamValue('cropSize', node, tensorMap, context) as number[]; - const method = - getParamValue('method', node, tensorMap, context) as string; - const extrapolationValue = - getParamValue('extrapolationValue', node, tensorMap, context) as - number; - return [ops.image.cropAndResize( - image as Tensor4D, boxes as Tensor2D, boxInd as Tensor1D, - cropSize as [number, number], method as 'bilinear' | 'nearest', - extrapolationValue)]; - } - case 'ImageProjectiveTransformV3': { - const images = - getParamValue('images', node, tensorMap, context) as Tensor; - const transforms = - getParamValue('transforms', node, tensorMap, context) as Tensor; - const outputShape = - getParamValue('outputShape', node, tensorMap, context) as - number[]; - const fillValue = - getParamValue('fillValue', node, tensorMap, context) as number; - const interpolation = - getParamValue('interpolation', node, tensorMap, context) as - string; - const fillMode = - getParamValue('fillMode', node, tensorMap, context) as string; - return [ops.image.transform( - images as Tensor4D, - transforms as Tensor2D, - interpolation.toLowerCase() as 'bilinear' | 'nearest', - fillMode.toLowerCase() as 'constant' | 'reflect' | 'wrap' | 'nearest', - fillValue, - outputShape as [number, number])]; - } - default: - throw TypeError(`Node type ${node.op} is not implemented`); - } - }; - -export const CATEGORY = 'image'; diff --git a/tfjs-master/tfjs-converter/src/operations/executors/image_executor_test.ts b/tfjs-master/tfjs-converter/src/operations/executors/image_executor_test.ts deleted file mode 100644 index ef73eb979..000000000 --- a/tfjs-master/tfjs-converter/src/operations/executors/image_executor_test.ts +++ /dev/null @@ -1,174 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -// tslint:disable-next-line: no-imports-from-dist -import * as tfOps from '@tensorflow/tfjs-core/dist/ops/ops_for_converter'; - -import {ExecutionContext} from '../../executor/execution_context'; -import * as image from '../op_list/image'; -import {Node} from '../types'; - -import {executeOp} from './image_executor'; -import {createBoolAttr, createNumberAttr, createNumberAttrFromIndex, createNumericArrayAttrFromIndex, createStrAttr, createTensorAttr, validateParam} from './test_helper'; -import {spyOnAllFunctions, RecursiveSpy} from './spy_ops'; - -describe('image', () => { - let node: Node; - const input1 = [tfOps.tensor1d([1])]; - const context = new ExecutionContext({}, {}, {}); - let spyOps: RecursiveSpy; - let spyOpsAsTfOps: typeof tfOps; - - beforeEach(() => { - spyOps = spyOnAllFunctions(tfOps); - spyOpsAsTfOps = spyOps as unknown as typeof tfOps; - node = { - name: 'input1', - op: '', - category: 'image', - inputNames: ['input1'], - inputs: [], - inputParams: {}, - attrParams: {}, - children: [] - }; - }); - - describe('executeOp', () => { - describe('ResizeBilinear', () => { - it('should return input', () => { - node.op = 'ResizeBilinear'; - node.inputParams['images'] = createTensorAttr(0); - node.inputParams['size'] = createNumericArrayAttrFromIndex(1); - node.attrParams['alignCorners'] = createBoolAttr(true); - node.attrParams['halfPixelCenters'] = createBoolAttr(true); - node.inputNames = ['input1', 'input2']; - const input2 = [tfOps.tensor1d([1, 2])]; - spyOps.image.resizeBilinear.and.returnValue({}); - - executeOp(node, {input1, input2}, context, spyOpsAsTfOps); - expect(spyOps.image.resizeBilinear) - .toHaveBeenCalledWith(input1[0], [1, 2], true, true); - }); - it('should match json def', () => { - node.op = 'ResizeBilinear'; - node.inputParams['images'] = createTensorAttr(0); - node.inputParams['size'] = createNumericArrayAttrFromIndex(1); - node.attrParams['alignCorners'] = createBoolAttr(true); - node.attrParams['halfPixelCenters'] = createBoolAttr(true); - - expect(validateParam(node, image.json)).toBeTruthy(); - }); - }); - describe('ResizeNearestNeighbor', () => { - it('should return input', () => { - node.op = 'ResizeNearestNeighbor'; - node.inputParams['images'] = createTensorAttr(0); - node.inputParams['size'] = createNumericArrayAttrFromIndex(1); - node.attrParams['alignCorners'] = createBoolAttr(true); - node.attrParams['halfPixelCenters'] = createBoolAttr(true); - node.inputNames = ['input1', 'input2']; - const input2 = [tfOps.tensor1d([1, 2])]; - spyOps.image.resizeNearestNeighbor.and.returnValue({}); - - executeOp(node, {input1, input2}, context, spyOpsAsTfOps); - expect(spyOps.image.resizeNearestNeighbor) - .toHaveBeenCalledWith(input1[0], [1, 2], true, true); - }); - it('should match json def', () => { - node.op = 'ResizeNearestNeighbor'; - node.inputParams['images'] = createTensorAttr(0); - node.inputParams['size'] = createNumericArrayAttrFromIndex(1); - node.attrParams['alignCorners'] = createBoolAttr(true); - node.attrParams['halfPixelCenters'] = createBoolAttr(true); - - expect(validateParam(node, image.json)).toBeTruthy(); - }); - }); - describe('CropAndResize', () => { - it('should return input', () => { - node.op = 'CropAndResize'; - node.inputParams['image'] = createTensorAttr(0); - node.inputParams['boxes'] = createTensorAttr(1); - node.inputParams['boxInd'] = createTensorAttr(2); - node.inputParams['cropSize'] = createNumericArrayAttrFromIndex(3); - node.attrParams['method'] = createStrAttr('bilinear'); - node.attrParams['extrapolationValue'] = createNumberAttr(0.5); - node.inputNames = ['input1', 'input2', 'input3', 'input4']; - - spyOps.image.cropAndResize.and.returnValue({}); - const input2 = [tfOps.tensor1d([2])]; - const input3 = [tfOps.tensor1d([3])]; - const input4 = [tfOps.tensor1d([4, 5])]; - - executeOp(node, {input1, input2, input3, input4}, context, - spyOpsAsTfOps); - expect(spyOps.image.cropAndResize) - .toHaveBeenCalledWith( - input1[0], input2[0], input3[0], [4, 5], 'bilinear', 0.5); - }); - - it('should match json def', () => { - node.op = 'CropAndResize'; - node.inputParams['image'] = createTensorAttr(0); - node.inputParams['boxes'] = createTensorAttr(1); - node.inputParams['boxInd'] = createTensorAttr(2); - node.inputParams['cropSize'] = createNumericArrayAttrFromIndex(3); - node.attrParams['method'] = createStrAttr('bilinear'); - node.attrParams['extrapolationValue'] = createNumberAttr(0.5); - node.inputNames = ['input1', 'input2', 'input3', 'input4']; - - expect(validateParam(node, image.json)).toBeTruthy(); - }); - }); - describe('ImageProjectiveTransformV3', () => { - it('should return input', () => { - node.op = 'ImageProjectiveTransformV3'; - node.inputParams['images'] = createTensorAttr(0); - node.inputParams['transforms'] = createTensorAttr(1); - node.inputParams['outputShape'] = createNumericArrayAttrFromIndex(2); - node.inputParams['fillValue'] = createNumberAttrFromIndex(3); - node.attrParams['interpolation'] = createStrAttr('bilinear'); - node.attrParams['fillMode'] = createStrAttr('constant'); - node.inputNames = ['input1', 'input2', 'input3', 'input4']; - - const input1 = [tfOps.tensor4d([1], [1, 1, 1, 1])]; - const input2 = [tfOps.tensor2d([1, 2, 3, 4, 5, 6, 7, 8], [1, 8])]; - const input3 = [tfOps.tensor1d([4, 5])]; - const input4 = [tfOps.scalar(3)]; - - executeOp(node, {input1, input2, input3, input4}, context, - spyOpsAsTfOps); - expect(spyOps.image.transform) - .toHaveBeenCalledWith( - input1[0], input2[0], 'bilinear', 'constant', 3, [4, 5]); - }); - - it('should match json def', () => { - node.op = 'ImageProjectiveTransformV3'; - node.inputParams['images'] = createTensorAttr(0); - node.inputParams['transforms'] = createTensorAttr(1); - node.inputParams['outputShape'] = createNumericArrayAttrFromIndex(2); - node.inputParams['fillValue'] = createNumberAttrFromIndex(3); - node.attrParams['interpolation'] = createStrAttr('bilinear'); - node.attrParams['fillMode'] = createStrAttr('constant'); - node.inputNames = ['input1', 'input2', 'input3', 'input4']; - - expect(validateParam(node, image.json)).toBeTruthy(); - }); - }); - }); -}); diff --git a/tfjs-master/tfjs-converter/src/operations/executors/logical_executor.ts b/tfjs-master/tfjs-converter/src/operations/executors/logical_executor.ts deleted file mode 100644 index 108e0a678..000000000 --- a/tfjs-master/tfjs-converter/src/operations/executors/logical_executor.ts +++ /dev/null @@ -1,93 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Tensor} from '@tensorflow/tfjs-core'; -// tslint:disable-next-line: no-imports-from-dist -import * as tfOps from '@tensorflow/tfjs-core/dist/ops/ops_for_converter'; - -import {NamedTensorsMap} from '../../data/types'; -import {ExecutionContext} from '../../executor/execution_context'; -import {InternalOpExecutor, Node} from '../types'; - -import {getParamValue} from './utils'; - -export const executeOp: InternalOpExecutor = - (node: Node, tensorMap: NamedTensorsMap, context: ExecutionContext, - ops = tfOps): Tensor[] => { - switch (node.op) { - case 'Equal': { - return [ops.equal( - getParamValue('a', node, tensorMap, context) as Tensor, - getParamValue('b', node, tensorMap, context) as Tensor)]; - } - case 'NotEqual': { - return [ops.notEqual( - getParamValue('a', node, tensorMap, context) as Tensor, - getParamValue('b', node, tensorMap, context) as Tensor)]; - } - case 'Greater': { - return [ops.greater( - getParamValue('a', node, tensorMap, context) as Tensor, - getParamValue('b', node, tensorMap, context) as Tensor)]; - } - case 'GreaterEqual': { - return [ops.greaterEqual( - getParamValue('a', node, tensorMap, context) as Tensor, - getParamValue('b', node, tensorMap, context) as Tensor)]; - } - case 'Less': { - return [ops.less( - getParamValue('a', node, tensorMap, context) as Tensor, - getParamValue('b', node, tensorMap, context) as Tensor)]; - } - case 'LessEqual': { - return [ops.lessEqual( - getParamValue('a', node, tensorMap, context) as Tensor, - getParamValue('b', node, tensorMap, context) as Tensor)]; - } - case 'LogicalAnd': { - return [ops.logicalAnd( - getParamValue('a', node, tensorMap, context) as Tensor, - getParamValue('b', node, tensorMap, context) as Tensor)]; - } - case 'LogicalNot': { - return [ops.logicalNot( - getParamValue('a', node, tensorMap, context) as Tensor)]; - } - case 'LogicalOr': { - return [ops.logicalOr( - getParamValue('a', node, tensorMap, context) as Tensor, - getParamValue('b', node, tensorMap, context) as Tensor)]; - } - case 'Select': - case 'SelectV2': { - return [ops.where( - getParamValue('condition', node, tensorMap, context) as Tensor, - getParamValue('a', node, tensorMap, context) as Tensor, - getParamValue('b', node, tensorMap, context) as Tensor)]; - } - case 'BitwiseAnd': { - return [ops.bitwiseAnd( - getParamValue('a', node, tensorMap, context) as Tensor, - getParamValue('b', node, tensorMap, context) as Tensor)]; - } - default: - throw TypeError(`Node type ${node.op} is not implemented`); - } - }; - -export const CATEGORY = 'logical'; diff --git a/tfjs-master/tfjs-converter/src/operations/executors/logical_executor_test.ts b/tfjs-master/tfjs-converter/src/operations/executors/logical_executor_test.ts deleted file mode 100644 index f8c3c6cc1..000000000 --- a/tfjs-master/tfjs-converter/src/operations/executors/logical_executor_test.ts +++ /dev/null @@ -1,108 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -// tslint:disable-next-line: no-imports-from-dist -import * as tfOps from '@tensorflow/tfjs-core/dist/ops/ops_for_converter'; - -import {ExecutionContext} from '../../executor/execution_context'; -import {Node} from '../types'; - -import {executeOp} from './logical_executor'; -import {RecursiveSpy, spyOnAllFunctions} from './spy_ops'; -import {createTensorAttr, uncapitalize} from './test_helper'; - -describe('logical', () => { - let node: Node; - const input1 = [tfOps.scalar(1)]; - const input2 = [tfOps.scalar(2)]; - const context = new ExecutionContext({}, {}, {}); - - beforeEach(() => { - node = { - name: 'test', - op: '', - category: 'logical', - inputNames: ['input1', 'input2'], - inputs: [], - inputParams: {a: createTensorAttr(0), b: createTensorAttr(1)}, - attrParams: {}, - children: [] - }; - }); - - describe('executeOp', () => { - let spyOps: RecursiveSpy; - let spyOpsAsTfOps: typeof tfOps; - - beforeEach(() => { - spyOps = spyOnAllFunctions(tfOps); - spyOpsAsTfOps = spyOps as unknown as typeof tfOps; - }); - - ([ - 'Equal', 'NotEqual', 'Greater', 'GreaterEqual', 'Less', 'LessEqual', - 'LogicalAnd', 'LogicalOr', 'BitwiseAnd' - ] as const ) - .forEach(op => { - it('should call tfOps.' + op, () => { - node.op = op; - spyOps[uncapitalize(op)].and.returnValue({}); - executeOp(node, {input1, input2}, context, spyOpsAsTfOps); - - expect(spyOps[uncapitalize(op)]) - .toHaveBeenCalledWith(input1[0], input2[0]); - }); - }); - describe('LogicalNot', () => { - it('should call tfOps.logicalNot', () => { - node.op = 'LogicalNot'; - spyOps.logicalNot.and.returnValue({}); - - executeOp(node, {input1}, context, spyOpsAsTfOps); - - expect(spyOps.logicalNot).toHaveBeenCalledWith(input1[0]); - }); - }); - - describe('Select', () => { - it('should call tfOps.where', () => { - node.op = 'Select'; - node.inputNames = ['input1', 'input2', 'input3']; - node.inputParams.condition = createTensorAttr(2); - const input3 = [tfOps.scalar(1)]; - spyOps.where.and.returnValue({}); - executeOp(node, {input1, input2, input3}, context, spyOpsAsTfOps); - - expect(spyOps.where) - .toHaveBeenCalledWith(input3[0], input1[0], input2[0]); - }); - }); - - describe('SelectV2', () => { - it('should call tfOps.where', () => { - node.op = 'SelectV2'; - node.inputNames = ['input1', 'input2', 'input3']; - node.inputParams.condition = createTensorAttr(2); - const input3 = [tfOps.scalar(1)]; - spyOps.where.and.returnValue({}); - executeOp(node, {input1, input2, input3}, context, spyOpsAsTfOps); - - expect(spyOps.where) - .toHaveBeenCalledWith(input3[0], input1[0], input2[0]); - }); - }); - }); -}); diff --git a/tfjs-master/tfjs-converter/src/operations/executors/matrices_executor.ts b/tfjs-master/tfjs-converter/src/operations/executors/matrices_executor.ts deleted file mode 100644 index df03a7ebb..000000000 --- a/tfjs-master/tfjs-converter/src/operations/executors/matrices_executor.ts +++ /dev/null @@ -1,103 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Scalar, Tensor, Tensor2D} from '@tensorflow/tfjs-core'; -// tslint:disable-next-line: no-imports-from-dist -import * as tfOps from '@tensorflow/tfjs-core/dist/ops/ops_for_converter'; - -import {NamedTensorsMap} from '../../data/types'; -import {ExecutionContext} from '../../executor/execution_context'; -import {InternalOpExecutor, Node} from '../types'; - -import {getParamValue} from './utils'; - -export const executeOp: InternalOpExecutor = - (node: Node, tensorMap: NamedTensorsMap, context: ExecutionContext, - ops = tfOps): Tensor[] => { - switch (node.op) { - case 'BatchMatMul': - case 'BatchMatMulV2': - case 'MatMul': - return [ops.matMul( - getParamValue('a', node, tensorMap, context) as Tensor2D, - getParamValue('b', node, tensorMap, context) as Tensor2D, - getParamValue('transposeA', node, tensorMap, context) as boolean, - getParamValue('transposeB', node, tensorMap, context) as - boolean)]; - - case 'Einsum': - return [ops.einsum( - getParamValue('equation', node, tensorMap, context) as string, - ...getParamValue('tensors', node, tensorMap, context) as - Tensor[])]; - - case 'Transpose': - return [ops.transpose( - getParamValue('x', node, tensorMap, context) as Tensor, - getParamValue('perm', node, tensorMap, context) as number[])]; - - case '_FusedMatMul': - const [extraOp, activationFunc] = - (getParamValue('fusedOps', node, tensorMap, context) as string[]); - - const isBiasAdd = extraOp === 'biasadd'; - const isPrelu = activationFunc === 'prelu'; - - const numArgs = - (getParamValue('numArgs', node, tensorMap, context) as number); - const leakyreluAlpha = - getParamValue('leakyreluAlpha', node, tensorMap, context) as - number; - - if (isBiasAdd) { - if (isPrelu && numArgs !== 2) { - throw new Error( - 'Fused MatMul with BiasAdd and Prelu must have two ' + - 'extra arguments: bias and alpha.'); - } - if (!isPrelu && numArgs !== 1) { - throw new Error( - 'Fused MatMul with BiasAdd must have one extra argument: bias.'); - } - } - const [biasArg, preluArg] = - getParamValue('args', node, tensorMap, context) as Tensor[]; - return [ops.fused.matMul({ - a: getParamValue('a', node, tensorMap, context) as Tensor2D, - b: getParamValue('b', node, tensorMap, context) as Tensor2D, - transposeA: getParamValue('transposeA', node, tensorMap, context) as - boolean, - transposeB: getParamValue('transposeB', node, tensorMap, context) as - boolean, - bias: biasArg, - activation: activationFunc as tfOps.fused.Activation, - preluActivationWeights: preluArg, - leakyreluAlpha - })]; - - case 'MatrixBandPart': - return [ops.linalg.bandPart( - getParamValue('a', node, tensorMap, context) as Tensor2D, - getParamValue('numLower', node, tensorMap, context) as Scalar, - getParamValue('numUpper', node, tensorMap, context) as Scalar)]; - - default: - throw TypeError(`Node type ${node.op} is not implemented`); - } - }; - -export const CATEGORY = 'matrices'; diff --git a/tfjs-master/tfjs-converter/src/operations/executors/matrices_executor_test.ts b/tfjs-master/tfjs-converter/src/operations/executors/matrices_executor_test.ts deleted file mode 100644 index 19d06eae7..000000000 --- a/tfjs-master/tfjs-converter/src/operations/executors/matrices_executor_test.ts +++ /dev/null @@ -1,218 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Tensor} from '@tensorflow/tfjs-core'; -// tslint:disable-next-line: no-imports-from-dist -import * as tfOps from '@tensorflow/tfjs-core/dist/ops/ops_for_converter'; - -import {ExecutionContext} from '../../executor/execution_context'; -import * as matrices from '../op_list/matrices'; -import {Node} from '../types'; - -import {executeOp} from './matrices_executor'; -import {RecursiveSpy, spyOnAllFunctions} from './spy_ops'; -import {createBoolAttr, createNumberAttr, createNumericArrayAttr, createStrArrayAttr, createStrAttr, createTensorAttr, createTensorsAttr, validateParam} from './test_helper'; - -describe('matrices', () => { - let node: Node; - const input1 = [tfOps.scalar(1)]; - const input2 = [tfOps.scalar(2)]; - const context = new ExecutionContext({}, {}, {}); - let spyOps: RecursiveSpy; - let spyOpsAsTfOps: typeof tfOps; - - beforeEach(() => { - spyOps = spyOnAllFunctions(tfOps); - spyOpsAsTfOps = spyOps as unknown as typeof tfOps; - node = { - name: 'test', - op: '', - category: 'matrices', - inputNames: ['input1', 'input2'], - inputs: [], - inputParams: {a: createTensorAttr(0), b: createTensorAttr(1)}, - attrParams: {}, - children: [] - }; - }); - - describe('executeOp', () => { - describe('MatMul', () => { - it('should call tfOps.matMul', () => { - node.op = 'MatMul'; - node.attrParams.transposeA = createBoolAttr(true); - node.attrParams.transposeB = createBoolAttr(false); - spyOps.matMul.and.returnValue({}); - executeOp(node, {input1, input2}, context, spyOpsAsTfOps); - - expect(spyOps.matMul) - .toHaveBeenCalledWith(input1[0], input2[0], true, false); - }); - }); - describe('_FusedMatMul', () => { - it('should call tfOps.fused.matMul', () => { - node.op = '_FusedMatMul'; - node.inputParams['args'] = createTensorsAttr(2, 0); - node.attrParams['fusedOps'] = createStrArrayAttr(['biasadd', 'relu']); - node.attrParams['numArgs'] = createNumberAttr(1); - node.attrParams.transposeA = createBoolAttr(true); - node.attrParams.transposeB = createBoolAttr(false); - const input3 = [tfOps.scalar(3.0)]; - node.inputNames = ['input1', 'input2', 'input3']; - spyOps.fused.matMul.and.returnValue({}); - executeOp(node, {input1, input2, input3}, context, spyOpsAsTfOps); - - expect(spyOps.fused.matMul).toHaveBeenCalledWith({ - a: input1[0], - b: input2[0], - transposeA: true, - transposeB: false, - bias: input3[0], - activation: 'relu', - preluActivationWeights: undefined, - leakyreluAlpha: undefined - }); - }); - it('should call tfOps.fused.matMul - prelu activation', () => { - node.op = '_FusedMatMul'; - node.inputParams['args'] = createTensorsAttr(2, 0); - node.attrParams['fusedOps'] = createStrArrayAttr(['biasadd', 'prelu']); - node.attrParams['numArgs'] = createNumberAttr(2); - node.attrParams.transposeA = createBoolAttr(true); - node.attrParams.transposeB = createBoolAttr(false); - const input3 = [tfOps.scalar(3.0)]; - const input4 = [tfOps.scalar(4.0)]; - node.inputNames = ['input1', 'input2', 'input3', 'input4']; - spyOps.fused.matMul.and.returnValue({}); - executeOp( - node, {input1, input2, input3, input4}, context, spyOpsAsTfOps); - - expect(spyOps.fused.matMul).toHaveBeenCalledWith({ - a: input1[0], - b: input2[0], - transposeA: true, - transposeB: false, - bias: input3[0], - activation: 'prelu', - preluActivationWeights: input4[0], - leakyreluAlpha: undefined - }); - }); - it('should call tfOps.fused.matMul - leakyrelu activation', () => { - node.op = '_FusedMatMul'; - node.inputParams['args'] = createTensorsAttr(2, 0); - node.attrParams['fusedOps'] = - createStrArrayAttr(['biasadd', 'leakyrelu']); - node.attrParams['numArgs'] = createNumberAttr(1); - node.attrParams.transposeA = createBoolAttr(true); - node.attrParams.transposeB = createBoolAttr(false); - node.attrParams.leakyreluAlpha = createNumberAttr(0.3); - const input3 = [tfOps.scalar(3.0)]; - node.inputNames = ['input1', 'input2', 'input3']; - spyOps.fused.matMul.and.returnValue({}); - executeOp(node, {input1, input2, input3}, context, spyOpsAsTfOps); - - expect(spyOps.fused.matMul).toHaveBeenCalledWith({ - a: input1[0], - b: input2[0], - transposeA: true, - transposeB: false, - bias: input3[0], - activation: 'leakyrelu', - preluActivationWeights: undefined, - leakyreluAlpha: 0.3 - }); - }); - it('should match json def.', () => { - node.op = '_FusedMatMul'; - - node.attrParams['fusedOps'] = - createStrArrayAttr(['biasadd', 'leakyrelu']); - node.attrParams['numArgs'] = createNumberAttr(1); - node.attrParams.transposeA = createBoolAttr(true); - node.attrParams.transposeB = createBoolAttr(false); - node.attrParams.leakyreluAlpha = createNumberAttr(0.3); - - expect(validateParam(node, matrices.json)).toBeTruthy(); - }); - }); - describe('BatchMatMul', () => { - it('should call tfOps.matMul', () => { - node.op = 'BatchMatMul'; - node.attrParams.transposeA = createBoolAttr(true); - node.attrParams.transposeB = createBoolAttr(false); - spyOps.matMul.and.returnValue({}); - executeOp(node, {input1, input2}, context, spyOpsAsTfOps); - - expect(spyOps.matMul) - .toHaveBeenCalledWith(input1[0], input2[0], true, false); - }); - }); - describe('BatchMatMulV2', () => { - it('should call tfOps.matMul', () => { - node.op = 'BatchMatMulV2'; - node.attrParams.transposeA = createBoolAttr(true); - node.attrParams.transposeB = createBoolAttr(false); - spyOps.matMul.and.returnValue({}); - executeOp(node, {input1, input2}, context, spyOpsAsTfOps); - - expect(spyOps.matMul) - .toHaveBeenCalledWith(input1[0], input2[0], true, false); - }); - }); - describe('Einsum', () => { - it('should call tfOps.einsum', () => { - node.op = 'Einsum'; - node.inputParams = {tensors: createTensorsAttr(0, 0)}; - node.inputNames = ['input1', 'input2']; - node.attrParams.equation = createStrAttr(',->'); - executeOp(node, {input1, input2}, context, spyOpsAsTfOps); - const res = executeOp(node, {input1, input2}, context) as Tensor[]; - expect(spyOps.einsum).toHaveBeenCalledWith(',->', input1[0], input2[0]); - expect(res[0].dtype).toBe('float32'); - expect(res[0].shape).toEqual([]); - }); - }); - describe('Transpose', () => { - it('should call tfOps.transpose', () => { - node.op = 'Transpose'; - node.inputNames = ['input1', 'input2', 'input3']; - node.inputParams.x = createTensorAttr(0); - node.attrParams.perm = createNumericArrayAttr([1, 2]); - spyOps.transpose.and.returnValue({}); - executeOp(node, {input1}, context, spyOpsAsTfOps); - - expect(spyOps.transpose).toHaveBeenCalledWith(input1[0], [1, 2]); - }); - }); - describe('MatrixBandPart', () => { - it('should call tfOps.linalg.bandPart', () => { - node.op = 'MatrixBandPart'; - node.inputNames = ['input1', 'input2', 'input3']; - node.inputParams.a = createTensorAttr(0); - node.inputParams.numLower = createTensorAttr(1); - node.inputParams.numUpper = createTensorAttr(2); - const input3 = [tfOps.scalar(3.0)]; - spyOps.linalg.bandPart.and.returnValue({}); - executeOp(node, {input1, input2, input3}, context, spyOpsAsTfOps); - - expect(spyOps.linalg.bandPart) - .toHaveBeenCalledWith(input1[0], input2[0], input3[0]); - }); - }); - }); -}); diff --git a/tfjs-master/tfjs-converter/src/operations/executors/normalization_executor.ts b/tfjs-master/tfjs-converter/src/operations/executors/normalization_executor.ts deleted file mode 100644 index 56abb03ee..000000000 --- a/tfjs-master/tfjs-converter/src/operations/executors/normalization_executor.ts +++ /dev/null @@ -1,78 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Tensor, Tensor3D, Tensor4D} from '@tensorflow/tfjs-core'; -// tslint:disable-next-line: no-imports-from-dist -import * as tfOps from '@tensorflow/tfjs-core/dist/ops/ops_for_converter'; - -import {NamedTensorsMap} from '../../data/types'; -import {ExecutionContext} from '../../executor/execution_context'; -import {InternalOpExecutor, Node} from '../types'; - -import {getParamValue} from './utils'; - -export const executeOp: InternalOpExecutor = - (node: Node, tensorMap: NamedTensorsMap, - context: ExecutionContext, ops = tfOps): Tensor[] => { - switch (node.op) { - case 'EuclideanNorm': - return [ops.euclideanNorm( - getParamValue('x', node, tensorMap, context) as Tensor, - getParamValue('axis', node, tensorMap, context) as number[], - getParamValue('keepDims', node, tensorMap, context) as boolean)]; - case 'FusedBatchNorm': - case 'FusedBatchNormV2': { - return [ops.batchNorm( - getParamValue('x', node, tensorMap, context) as Tensor, - getParamValue('mean', node, tensorMap, context) as Tensor, - getParamValue('variance', node, tensorMap, context) as Tensor, - getParamValue('offset', node, tensorMap, context) as Tensor, - getParamValue('scale', node, tensorMap, context) as Tensor, - getParamValue('epsilon', node, tensorMap, context) as number)]; - } - case 'FusedBatchNormV3': { - return [ops.batchNorm( - getParamValue('x', node, tensorMap, context) as Tensor, - getParamValue('mean', node, tensorMap, context) as Tensor, - getParamValue('variance', node, tensorMap, context) as Tensor, - getParamValue('offset', node, tensorMap, context) as Tensor, - getParamValue('scale', node, tensorMap, context) as Tensor, - getParamValue('epsilon', node, tensorMap, context) as number)]; - } - case 'LRN': { - return [ops.localResponseNormalization( - getParamValue('x', node, tensorMap, context) as Tensor3D | - Tensor4D, - getParamValue('radius', node, tensorMap, context) as number, - getParamValue('bias', node, tensorMap, context) as number, - getParamValue('alpha', node, tensorMap, context) as number, - getParamValue('beta', node, tensorMap, context) as number)]; - } - case 'Softmax': { - return [ops.softmax( - getParamValue('x', node, tensorMap, context) as Tensor)]; - } - case 'LogSoftmax': { - return [ops.logSoftmax( - getParamValue('x', node, tensorMap, context) as Tensor)]; - } - default: - throw TypeError(`Node type ${node.op} is not implemented`); - } - }; - -export const CATEGORY = 'normalization'; diff --git a/tfjs-master/tfjs-converter/src/operations/executors/normalization_executor_test.ts b/tfjs-master/tfjs-converter/src/operations/executors/normalization_executor_test.ts deleted file mode 100644 index 1e53b9346..000000000 --- a/tfjs-master/tfjs-converter/src/operations/executors/normalization_executor_test.ts +++ /dev/null @@ -1,192 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -// tslint:disable-next-line: no-imports-from-dist -import * as tfOps from '@tensorflow/tfjs-core/dist/ops/ops_for_converter'; - -import {ExecutionContext} from '../../executor/execution_context'; -import * as normalization from '../op_list/normalization'; -import {Node} from '../types'; - -import {executeOp} from './normalization_executor'; -import {createBoolAttr, createNumberAttr, createNumericArrayAttrFromIndex, createTensorAttr, validateParam} from './test_helper'; -import {spyOnAllFunctions, RecursiveSpy} from './spy_ops'; - -describe('normalization', () => { - let node: Node; - const input1 = [tfOps.scalar(1)]; - const context = new ExecutionContext({}, {}, {}); - let spyOps: RecursiveSpy; - let spyOpsAsTfOps: typeof tfOps; - - beforeEach(() => { - spyOps = spyOnAllFunctions(tfOps); - spyOpsAsTfOps = spyOps as unknown as typeof tfOps; - node = { - name: 'test', - op: '', - category: 'normalization', - inputNames: ['input1'], - inputs: [], - inputParams: {x: createTensorAttr(0)}, - attrParams: {}, - children: [] - }; - }); - - describe('executeOp', () => { - describe('EuclideanNorm', () => { - it('should call tfOps.euclideanNorm', () => { - node.op = 'EuclideanNorm'; - node.inputParams['axis'] = createNumericArrayAttrFromIndex(1); - node.attrParams.keepDims = createBoolAttr(false); - node.inputNames = ['input1', 'input2']; - const input2 = [tfOps.tensor1d([2])]; - executeOp(node, {input1, input2}, context, spyOpsAsTfOps); - - expect(spyOps.euclideanNorm).toHaveBeenCalledWith(input1[0], [2], - false); - }); - it('should match json def', () => { - node.op = 'EuclideanNorm'; - delete node.inputParams.x; - node.inputParams.axis = createNumericArrayAttrFromIndex(1); - node.attrParams.keepDims = createBoolAttr(false); - - expect(validateParam(node, normalization.json)).toBeTruthy(); - }); - }); - describe('FusedBatchNorm', () => { - it('should call tfOps.batchNorm', () => { - node.op = 'FusedBatchNorm'; - node.inputParams.scale = createTensorAttr(1); - node.inputParams.offset = createTensorAttr(2); - node.inputParams.mean = createTensorAttr(3); - node.inputParams.variance = createTensorAttr(4); - node.attrParams.epsilon = createNumberAttr(5); - node.inputNames = ['input1', 'input2', 'input3', 'input4', 'input5']; - const input2 = [tfOps.scalar(1)]; - const input3 = [tfOps.scalar(2)]; - const input4 = [tfOps.scalar(3)]; - const input5 = [tfOps.scalar(4)]; - executeOp(node, {input1, input2, input3, input4, input5}, context, - spyOpsAsTfOps); - - expect(spyOps.batchNorm) - .toHaveBeenCalledWith( - input1[0], input4[0], input5[0], input3[0], input2[0], 5); - }); - }); - describe('FusedBatchNormV2', () => { - it('should call tfOps.batchNorm', () => { - node.op = 'FusedBatchNormV2'; - node.inputParams.scale = createTensorAttr(1); - node.inputParams.offset = createTensorAttr(2); - node.inputParams.mean = createTensorAttr(3); - node.inputParams.variance = createTensorAttr(4); - node.attrParams.epsilon = createNumberAttr(5); - node.inputNames = ['input1', 'input2', 'input3', 'input4', 'input5']; - const input2 = [tfOps.scalar(1)]; - const input3 = [tfOps.scalar(2)]; - const input4 = [tfOps.scalar(3)]; - const input5 = [tfOps.scalar(4)]; - executeOp(node, {input1, input2, input3, input4, input5}, context, - spyOpsAsTfOps); - - expect(spyOps.batchNorm) - .toHaveBeenCalledWith( - input1[0], input4[0], input5[0], input3[0], input2[0], 5); - }); - }); - describe('FusedBatchNormV3', () => { - it('should call tfOps.batchNorm', () => { - node.op = 'FusedBatchNormV3'; - node.inputParams.scale = createTensorAttr(1); - node.inputParams.offset = createTensorAttr(2); - node.inputParams.mean = createTensorAttr(3); - node.inputParams.variance = createTensorAttr(4); - node.attrParams.epsilon = createNumberAttr(5); - node.inputNames = ['input1', 'input2', 'input3', 'input4', 'input5']; - const input2 = [tfOps.scalar(1)]; - const input3 = [tfOps.scalar(2)]; - const input4 = [tfOps.scalar(3)]; - const input5 = [tfOps.scalar(4)]; - executeOp(node, {input1, input2, input3, input4, input5}, context, - spyOpsAsTfOps); - - expect(spyOps.batchNorm) - .toHaveBeenCalledWith( - input1[0], input4[0], input5[0], input3[0], input2[0], 5); - }); - }); - describe('LRN', () => { - it('should call tfOps.localResponseNormalization', () => { - node.op = 'LRN'; - node.attrParams.radius = createNumberAttr(1); - node.attrParams.bias = createNumberAttr(2); - node.attrParams.alpha = createNumberAttr(3); - node.attrParams.beta = createNumberAttr(4); - spyOps.localResponseNormalization.and.returnValue({}); - - executeOp(node, {input1}, context, spyOpsAsTfOps); - - expect(spyOps.localResponseNormalization) - .toHaveBeenCalledWith(input1[0], 1, 2, 3, 4); - }); - it('should match json def', () => { - node.op = 'LRN'; - node.attrParams.radius = createNumberAttr(1); - node.attrParams.bias = createNumberAttr(2); - node.attrParams.alpha = createNumberAttr(3); - node.attrParams.beta = createNumberAttr(4); - - expect(validateParam(node, normalization.json)).toBeTruthy(); - }); - }); - - describe('Softmax', () => { - it('should call tfOps.softmax', () => { - node.op = 'Softmax'; - spyOps.softmax.and.returnValue({}); - - executeOp(node, {input1}, context, spyOpsAsTfOps); - - expect(spyOps.softmax).toHaveBeenCalledWith(input1[0]); - }); - it('should match json def', () => { - node.op = 'Softmax'; - - expect(validateParam(node, normalization.json)).toBeTruthy(); - }); - }); - - describe('LogSoftmax', () => { - it('should call tfOps.logSoftmax', () => { - node.op = 'LogSoftmax'; - spyOps.logSoftmax.and.returnValue({}); - - executeOp(node, {input1}, context, spyOpsAsTfOps); - - expect(spyOps.logSoftmax).toHaveBeenCalledWith(input1[0]); - }); - it('should match json def', () => { - node.op = 'LogSoftmax'; - - expect(validateParam(node, normalization.json)).toBeTruthy(); - }); - }); - }); -}); diff --git a/tfjs-master/tfjs-converter/src/operations/executors/ragged_executor.ts b/tfjs-master/tfjs-converter/src/operations/executors/ragged_executor.ts deleted file mode 100644 index a9c773894..000000000 --- a/tfjs-master/tfjs-converter/src/operations/executors/ragged_executor.ts +++ /dev/null @@ -1,70 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Tensor, Tensor1D} from '@tensorflow/tfjs-core'; -// tslint:disable-next-line: no-imports-from-dist -import * as tfOps from '@tensorflow/tfjs-core/dist/ops/ops_for_converter'; - -import {NamedTensorsMap} from '../../data/types'; -import {ExecutionContext} from '../../executor/execution_context'; -import {InternalOpExecutor, Node} from '../types'; - -import {getParamValue} from './utils'; - -export const executeOp: InternalOpExecutor = - (node: Node, tensorMap: NamedTensorsMap, context: ExecutionContext, - ops = tfOps): Tensor[] => { - switch (node.op) { - case 'RaggedGather': { - const { - outputNestedSplits, - outputDenseValues, - } = - ops.raggedGather( - getParamValue( - 'paramsNestedSplits', node, tensorMap, context) as - Tensor[], - getParamValue( - 'paramsDenseValues', node, tensorMap, context) as Tensor, - getParamValue('indices', node, tensorMap, context) as Tensor, - getParamValue('outputRaggedRank', node, tensorMap, context) as - number); - return outputNestedSplits.concat(outputDenseValues); - } - case 'RaggedRange': { - const {rtNestedSplits, rtDenseValues} = ops.raggedRange( - getParamValue('starts', node, tensorMap, context) as Tensor, - getParamValue('limits', node, tensorMap, context) as Tensor, - getParamValue('splits', node, tensorMap, context) as Tensor); - return [rtNestedSplits, rtDenseValues]; - } - case 'RaggedTensorToTensor': { - return [ops.raggedTensorToTensor( - getParamValue('shape', node, tensorMap, context) as Tensor, - getParamValue('values', node, tensorMap, context) as Tensor1D, - getParamValue('defaultValue', node, tensorMap, context) as Tensor, - getParamValue('rowPartitionTensors', node, tensorMap, context) as - Tensor[], - getParamValue('rowPartitionTypes', node, tensorMap, context) as - string[])]; - } - default: - throw TypeError(`Node type ${node.op} is not implemented`); - } - }; - -export const CATEGORY = 'ragged'; diff --git a/tfjs-master/tfjs-converter/src/operations/executors/ragged_executor_test.ts b/tfjs-master/tfjs-converter/src/operations/executors/ragged_executor_test.ts deleted file mode 100644 index 3ec537c60..000000000 --- a/tfjs-master/tfjs-converter/src/operations/executors/ragged_executor_test.ts +++ /dev/null @@ -1,182 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {Tensor, test_util} from '@tensorflow/tfjs-core'; -// tslint:disable-next-line: no-imports-from-dist -import * as tfOps from '@tensorflow/tfjs-core/dist/ops/ops_for_converter'; - -import {ExecutionContext} from '../../executor/execution_context'; -import * as ragged from '../op_list/ragged'; -import {Node} from '../types'; - -import {executeOp} from './ragged_executor'; -import {RecursiveSpy, spyOnAllFunctions} from './spy_ops'; -import {createNumberAttr, createStrArrayAttr, createTensorAttr, createTensorsAttr, validateParam} from './test_helper'; - -describe('ragged', () => { - let node: Node; - const context = new ExecutionContext({}, {}, {}); - let spyOps: RecursiveSpy; - let spyOpsAsTfOps: typeof tfOps; - - beforeEach(() => { - spyOps = spyOnAllFunctions(tfOps); - spyOpsAsTfOps = spyOps as unknown as typeof tfOps; - node = { - name: 'test', - op: '', - category: 'ragged', - inputNames: [], - inputs: [], - inputParams: {}, - attrParams: {}, - children: [] - }; - }); - - describe('executeOp', () => { - describe('RaggedGather', () => { - const OUTPUT_RAGGED_RANK = 2; - beforeEach(() => { - node.op = 'RaggedGather'; - node.inputParams = { - paramsNestedSplits: createTensorsAttr(0, 2), - paramsDenseValues: createTensorAttr(2), - indices: createTensorAttr(3), - }; - node.attrParams = { - outputRaggedRank: createNumberAttr(OUTPUT_RAGGED_RANK) - }; - }); - - it('should call tfOps.ragged.raggedGather', async () => { - node.inputNames = [ - 'paramsNestedSplits1', 'paramsNestedSplits2', 'paramsDenseValues', - 'indices' - ]; - - const paramsNestedSplits1 = - [tfOps.tensor1d([0, 1, 3, 3, 5, 6], 'int32')]; - const paramsNestedSplits2 = - [tfOps.tensor1d([0, 0, 2, 3, 5, 8, 9], 'int32')]; - const paramsDenseValues = - [tfOps.tensor1d([.1, .2, .3, .4, .5, .6, .7, .8, .9])]; - const indices = [tfOps.tensor1d([2, 1, 0, 2, 3], 'int32')]; - - const result = executeOp( - node, { - paramsNestedSplits1, - paramsNestedSplits2, - paramsDenseValues, - indices - }, - context, spyOpsAsTfOps) as Tensor[]; - - expect(spyOps.raggedGather) - .toHaveBeenCalledWith( - [paramsNestedSplits1[0], paramsNestedSplits2[0]], - paramsDenseValues[0], indices[0], OUTPUT_RAGGED_RANK); - - test_util.expectArraysClose(await result[0].data(), [0, 0, 2, 3, 3, 5]); - test_util.expectArraysClose(await result[1].data(), [0, 2, 3, 3, 5, 8]); - - test_util.expectArraysClose( - await result[2].data(), [.1, .2, .3, .4, .5, .6, .7, .8]); - }); - }); - - it('should match json def', () => { - expect(validateParam(node, ragged.json)).toBeTruthy(); - }); - - describe('RaggedRange', () => { - beforeEach(() => { - node.op = 'RaggedRange'; - node.inputParams = { - starts: createTensorAttr(0), - limits: createTensorAttr(1), - splits: createTensorAttr(2), - }; - }); - - it('should call tfOps.ragged.raggedRange', async () => { - node.inputNames = ['starts', 'limits', 'splits']; - - const starts = [tfOps.tensor1d([0, 5, 8, 5], 'int32')]; - const limits = [tfOps.tensor1d([8, 7, 8, 1], 'int32')]; - const splits = [tfOps.tensor1d([2, 1, 1, -1], 'int32')]; - const result = - executeOp(node, {starts, limits, splits}, context, spyOpsAsTfOps) as - Tensor[]; - - expect(spyOps.raggedRange) - .toHaveBeenCalledWith(starts[0], limits[0], splits[0]); - test_util.expectArraysClose(await result[0].data(), [0, 4, 6, 6, 10]); - test_util.expectArraysClose( - await result[1].data(), [0, 2, 4, 6, 5, 6, 5, 4, 3, 2]); - }); - - it('should match json def', () => { - expect(validateParam(node, ragged.json)).toBeTruthy(); - }); - }); - - describe('RaggedTensorToTensor', () => { - const types = ['FIRST_DIM_SIZE', 'VALUE_ROWIDS']; - beforeEach(() => { - node.op = 'RaggedTensorToTensor'; - node.inputParams = { - shape: createTensorAttr(0), - values: createTensorAttr(1), - defaultValue: createTensorAttr(2), - rowPartitionTensors: createTensorsAttr(3, 0) - }; - node.attrParams = {rowPartitionTypes: createStrArrayAttr(types)}; - }); - - it('should call tfOps.ragged.raggedTensorToTensor', async () => { - node.inputNames = [ - 'shape', 'values', 'defaultValue', 'rowPartition1', 'rowPartition2' - ]; - - const shape = [tfOps.tensor1d([4, 4], 'int32')]; - const values = [tfOps.tensor1d([.1, .2, .3, .4, .5, .6, .7, .8, .9])]; - const defaultValue = [tfOps.scalar(1.5)]; - const rowPartition1 = [tfOps.scalar(4, 'int32')]; - const rowPartition2 = - [tfOps.tensor1d([0, 0, 0, 2, 2, 2, 2, 3, 3], 'int32')]; - - const result = - executeOp( - node, - {shape, values, defaultValue, rowPartition1, rowPartition2}, - context, spyOpsAsTfOps) as Tensor[]; - - expect(spyOps.raggedTensorToTensor) - .toHaveBeenCalledWith( - shape[0], values[0], defaultValue[0], - [rowPartition1[0], rowPartition2[0]], types); - test_util.expectArraysClose(await result[0].data(), [ - .1, .2, .3, 1.5, 1.5, 1.5, 1.5, 1.5, .4, .5, .6, .7, .8, .9, 1.5, 1.5 - ]); - }); - - it('should match json def', () => { - expect(validateParam(node, ragged.json)).toBeTruthy(); - }); - }); - }); -}); diff --git a/tfjs-master/tfjs-converter/src/operations/executors/reduction_executor.ts b/tfjs-master/tfjs-converter/src/operations/executors/reduction_executor.ts deleted file mode 100644 index f2d9e2c5c..000000000 --- a/tfjs-master/tfjs-converter/src/operations/executors/reduction_executor.ts +++ /dev/null @@ -1,157 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Tensor, Tensor1D, Tensor2D} from '@tensorflow/tfjs-core'; -// tslint:disable-next-line: no-imports-from-dist -import * as tfOps from '@tensorflow/tfjs-core/dist/ops/ops_for_converter'; - -import {NamedTensorsMap} from '../../data/types'; -import {ExecutionContext} from '../../executor/execution_context'; -import {InternalOpExecutor, Node} from '../types'; - -import {getParamValue} from './utils'; - -export const executeOp: InternalOpExecutor = - (node: Node, tensorMap: NamedTensorsMap, - context: ExecutionContext, ops = tfOps): Tensor[] => { - switch (node.op) { - case 'Max': { - const axis = - getParamValue('axis', node, tensorMap, context) as number[]; - const keepDims = - getParamValue('keepDims', node, tensorMap, context) as boolean; - return [ops.max( - getParamValue('x', node, tensorMap, context) as Tensor, axis, - keepDims)]; - } - case 'Mean': { - const axis = - getParamValue('axis', node, tensorMap, context) as number[]; - const keepDims = - getParamValue('keepDims', node, tensorMap, context) as boolean; - return [ops.mean( - getParamValue('x', node, tensorMap, context) as Tensor, axis, - keepDims)]; - } - case 'Min': { - const axis = - getParamValue('axis', node, tensorMap, context) as number[]; - const keepDims = - getParamValue('keepDims', node, tensorMap, context) as boolean; - return [ops.min( - getParamValue('x', node, tensorMap, context) as Tensor, axis, - keepDims)]; - } - case 'Sum': { - const axis = - getParamValue('axis', node, tensorMap, context) as number[]; - const keepDims = - getParamValue('keepDims', node, tensorMap, context) as boolean; - return [ops.sum( - getParamValue('x', node, tensorMap, context) as Tensor, axis, - keepDims)]; - } - case 'All': { - const axis = - getParamValue('axis', node, tensorMap, context) as number[]; - const keepDims = - getParamValue('keepDims', node, tensorMap, context) as boolean; - return [ops.all( - getParamValue('x', node, tensorMap, context) as Tensor, axis, - keepDims)]; - } - case 'Any': { - const axis = - getParamValue('axis', node, tensorMap, context) as number[]; - const keepDims = - getParamValue('keepDims', node, tensorMap, context) as boolean; - return [ops.any( - getParamValue('x', node, tensorMap, context) as Tensor, axis, - keepDims)]; - } - case 'ArgMax': { - const axis = - getParamValue('axis', node, tensorMap, context) as number; - return [ops.argMax( - getParamValue('x', node, tensorMap, context) as Tensor, axis)]; - } - case 'ArgMin': { - const axis = - getParamValue('axis', node, tensorMap, context) as number; - return [ops.argMin( - getParamValue('x', node, tensorMap, context) as Tensor, axis)]; - } - case 'Prod': { - const axis = - getParamValue('axis', node, tensorMap, context) as number[]; - const keepDims = - getParamValue('keepDims', node, tensorMap, context) as boolean; - return [ops.prod( - getParamValue('x', node, tensorMap, context) as Tensor, axis, - keepDims)]; - } - case 'Cumprod': { - const axis = - getParamValue('axis', node, tensorMap, context) as number; - const exclusive = - getParamValue('exclusive', node, tensorMap, context) as boolean; - const reverse = - getParamValue('reverse', node, tensorMap, context) as boolean; - return [ops.cumprod( - getParamValue('x', node, tensorMap, context) as Tensor, axis, - exclusive, reverse)]; - } - case 'Cumsum': { - const axis = - getParamValue('axis', node, tensorMap, context) as number; - const exclusive = - getParamValue('exclusive', node, tensorMap, context) as boolean; - const reverse = - getParamValue('reverse', node, tensorMap, context) as boolean; - return [ops.cumsum( - getParamValue('x', node, tensorMap, context) as Tensor, axis, - exclusive, reverse)]; - } - case 'Bincount': - const x = getParamValue('x', node, tensorMap, context) as Tensor1D; - const weights = - getParamValue('weights', node, tensorMap, context) as Tensor1D; - const size = - getParamValue('size', node, tensorMap, context) as number; - - return [ops.bincount(x, weights, size)]; - case 'DenseBincount': { - const x = getParamValue('x', node, tensorMap, context) as Tensor1D | - Tensor2D; - const weights = - getParamValue('weights', node, tensorMap, context) as Tensor1D | - Tensor2D; - const size = - getParamValue('size', node, tensorMap, context) as number; - - const binaryOutput = - getParamValue('binaryOutput', node, tensorMap, context) as - boolean; - - return [ops.denseBincount(x, weights, size, binaryOutput)]; - } - default: - throw TypeError(`Node type ${node.op} is not implemented`); - } - }; - -export const CATEGORY = 'reduction'; diff --git a/tfjs-master/tfjs-converter/src/operations/executors/reduction_executor_test.ts b/tfjs-master/tfjs-converter/src/operations/executors/reduction_executor_test.ts deleted file mode 100644 index 06d0c1491..000000000 --- a/tfjs-master/tfjs-converter/src/operations/executors/reduction_executor_test.ts +++ /dev/null @@ -1,169 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -// tslint:disable-next-line: no-imports-from-dist -import * as tfOps from '@tensorflow/tfjs-core/dist/ops/ops_for_converter'; - -import {ExecutionContext} from '../../executor/execution_context'; -import * as reduction from '../op_list/reduction'; -import {Node} from '../types'; - -import {executeOp} from './reduction_executor'; -import {RecursiveSpy, spyOnAllFunctions} from './spy_ops'; -import {createBoolAttr, createNumberAttr, createNumberAttrFromIndex, createNumericArrayAttrFromIndex, createTensorAttr, uncapitalize, validateParam} from './test_helper'; - -describe('reduction', () => { - let node: Node; - const input1 = [tfOps.scalar(1)]; - const context = new ExecutionContext({}, {}, {}); - let spyOps: RecursiveSpy; - let spyOpsAsTfOps: typeof tfOps; - - beforeEach(() => { - spyOps = spyOnAllFunctions(tfOps); - spyOpsAsTfOps = spyOps as unknown as typeof tfOps; - node = { - name: 'test', - op: '', - category: 'reduction', - inputNames: ['input1'], - inputs: [], - inputParams: {x: createTensorAttr(0)}, - attrParams: {}, - children: [] - }; - }); - - describe('executeOp', () => { - (['Max', 'Mean', 'Min', 'Sum', 'All', 'Any', 'Prod'] as const ) - .forEach(op => { - it('should call tfOps.' + op, () => { - node.op = op; - node.attrParams.keepDims = createBoolAttr(true); - node.attrParams.axis = createNumberAttr(1); - spyOps[uncapitalize(op)].and.returnValue({}); - executeOp(node, {input1}, context, spyOpsAsTfOps); - - expect(spyOps[uncapitalize(op)]) - .toHaveBeenCalledWith(input1[0], 1, true); - }); - }); - describe('ArgMax', () => { - it('should call tfOps.argMax', () => { - node.op = 'ArgMax'; - node.attrParams.keepDims = createBoolAttr(true); - node.attrParams.axis = createNumberAttr(1); - spyOps.argMax.and.returnValue({}); - executeOp(node, {input1}, context, spyOpsAsTfOps); - - expect(spyOps.argMax).toHaveBeenCalledWith(input1[0], 1); - }); - }); - describe('ArgMin', () => { - it('should call tfOps.argMin', () => { - node.op = 'ArgMin'; - node.attrParams.keepDims = createBoolAttr(true); - node.attrParams.axis = createNumberAttr(1); - spyOps.argMin.and.returnValue({}); - executeOp(node, {input1}, context, spyOpsAsTfOps); - - expect(spyOps.argMin).toHaveBeenCalledWith(input1[0], 1); - }); - }); - describe('Cumprod', () => { - it('should call tfOps.cumprod', () => { - node.op = 'Cumprod'; - node.attrParams.exclusive = createBoolAttr(true); - node.attrParams.reverse = createBoolAttr(false); - node.inputNames = ['input1', 'input2']; - node.inputParams.axis = createNumberAttrFromIndex(1); - const input2 = [tfOps.scalar(2)]; - executeOp(node, {input1, input2}, context, spyOpsAsTfOps); - - expect(spyOps.cumprod).toHaveBeenCalledWith(input1[0], 2, true, false); - }); - }); - describe('Cumsum', () => { - it('should call tfOps.cumsum', () => { - node.op = 'Cumsum'; - node.attrParams.exclusive = createBoolAttr(true); - node.attrParams.reverse = createBoolAttr(false); - node.inputNames = ['input1', 'input2']; - node.inputParams.axis = createNumberAttrFromIndex(1); - const input2 = [tfOps.scalar(2)]; - executeOp(node, {input1, input2}, context, spyOpsAsTfOps); - - expect(spyOps.cumsum).toHaveBeenCalledWith(input1[0], 2, true, false); - }); - }); - describe('Bincount', () => { - it('should call tfOps.bincount', () => { - node.op = 'Bincount'; - node.inputNames = ['input4', 'input3', 'input2']; - node.inputParams.size = createNumberAttrFromIndex(1); - node.inputParams.weights = createTensorAttr(2); - const input4 = [tfOps.tensor1d([1, 1], 'int32')]; - const input3 = [tfOps.scalar(2)]; - const input2 = [tfOps.tensor1d([])]; - executeOp(node, {input4, input3, input2}, context, spyOpsAsTfOps); - - expect(spyOps.bincount).toHaveBeenCalledWith(input4[0], input2[0], 2); - }); - it('should match json def for bincount.', () => { - node.op = 'Bincount'; - node.inputParams.size = createNumberAttrFromIndex(1); - node.inputParams.weights = createTensorAttr(2); - - expect(validateParam(node, reduction.json, 'Bincount')).toBeTruthy(); - }); - }); - describe('DenseBincount', () => { - it('should call tfOps.denseBincount', () => { - node.op = 'DenseBincount'; - node.inputNames = ['input4', 'input3', 'input2']; - node.inputParams.x = createTensorAttr(0); - node.inputParams.size = createNumberAttrFromIndex(1); - node.inputParams.weights = createTensorAttr(2); - node.attrParams.binaryOutput = createBoolAttr(true); - const input4 = [tfOps.tensor1d([1, 1], 'int32')]; - const input3 = [tfOps.scalar(2)]; - const input2 = [tfOps.tensor1d([])]; - executeOp(node, {input4, input3, input2}, context, spyOpsAsTfOps); - - expect(spyOps.denseBincount) - .toHaveBeenCalledWith(input4[0], input2[0], 2, true); - }); - it('should match json def for denseBincount.', () => { - node.op = 'DenseBincount'; - node.inputParams.size = createNumberAttrFromIndex(1); - node.inputParams.weights = createTensorAttr(2); - node.attrParams.binaryOutput = createBoolAttr(true); - - expect(validateParam(node, reduction.json, 'DenseBincount')) - .toBeTruthy(); - }); - }); - describe('Prod', () => { - it('should match op def', () => { - node.op = 'Prod'; - node.inputParams['axis'] = createNumericArrayAttrFromIndex(1); - node.attrParams['keepDims'] = createBoolAttr(true); - - expect(validateParam(node, reduction.json)).toBeTruthy(); - }); - }); - }); -}); diff --git a/tfjs-master/tfjs-converter/src/operations/executors/slice_join_executor.ts b/tfjs-master/tfjs-converter/src/operations/executors/slice_join_executor.ts deleted file mode 100644 index 524a5bce9..000000000 --- a/tfjs-master/tfjs-converter/src/operations/executors/slice_join_executor.ts +++ /dev/null @@ -1,202 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Scalar, Tensor, Tensor1D, tidy, util} from '@tensorflow/tfjs-core'; -// tslint:disable-next-line: no-imports-from-dist -import * as tfOps from '@tensorflow/tfjs-core/dist/ops/ops_for_converter'; - -import {NamedTensorsMap} from '../../data/types'; -import {ExecutionContext} from '../../executor/execution_context'; -import {InternalOpExecutor, Node} from '../types'; - -import {getParamValue} from './utils'; - -export const executeOp: InternalOpExecutor = - (node: Node, tensorMap: NamedTensorsMap, context: ExecutionContext, - ops = tfOps): Tensor[] => { - switch (node.op) { - case 'ConcatV2': - case 'Concat': { - const n = getParamValue('n', node, tensorMap, context) as number; - const axis = - getParamValue('axis', node, tensorMap, context) as number; - let inputs = - getParamValue('tensors', node, tensorMap, context) as Tensor[]; - inputs = inputs.slice(0, n); - return [ops.concat(inputs, axis)]; - } - case 'Gather': { - const input = getParamValue('x', node, tensorMap, context) as Tensor; - const indices = - getParamValue('indices', node, tensorMap, context) as Tensor1D; - return [ops.gather(input, ops.cast(indices, 'int32'), 0)]; - } - case 'GatherV2': { - const axis = - getParamValue('axis', node, tensorMap, context) as number; - const batchDims = - getParamValue('batchDims', node, tensorMap, context) as number; - const input = getParamValue('x', node, tensorMap, context) as Tensor; - const indices = - getParamValue('indices', node, tensorMap, context) as Tensor1D; - return [ops.gather( - input, ops.cast(indices, 'int32'), axis, batchDims)]; - } - case 'Reverse': { - const dims = - getParamValue('dims', node, tensorMap, context) as boolean[]; - const axis = []; - for (let i = 0; i < dims.length; i++) { - if (dims[i]) { - axis.push(i); - } - } - const input = getParamValue('x', node, tensorMap, context) as Tensor; - return [ops.reverse(input, axis)]; - } - case 'ReverseV2': { - const axis = - getParamValue('axis', node, tensorMap, context) as number[]; - const input = getParamValue('x', node, tensorMap, context) as Tensor; - return [ops.reverse(input, axis)]; - } - case 'Slice': { - // tslint:disable-next-line:no-any - const begin = getParamValue('begin', node, tensorMap, context) as any; - // tslint:disable-next-line:no-any - const size = getParamValue('size', node, tensorMap, context) as any; - return [ops.slice( - getParamValue('x', node, tensorMap, context) as Tensor, begin, - size)]; - } - case 'StridedSlice': { - const begin = - getParamValue('begin', node, tensorMap, context) as number[]; - const end = - getParamValue('end', node, tensorMap, context) as number[]; - const strides = - getParamValue('strides', node, tensorMap, context) as number[]; - const beginMask = - getParamValue('beginMask', node, tensorMap, context) as number; - const endMask = - getParamValue('endMask', node, tensorMap, context) as number; - const ellipsisMask = - getParamValue('ellipsisMask', node, tensorMap, context) as number; - const newAxisMask = - getParamValue('newAxisMask', node, tensorMap, context) as number; - const shrinkAxisMask = - getParamValue('shrinkAxisMask', node, tensorMap, context) as - number; - const tensor = getParamValue('x', node, tensorMap, context) as Tensor; - - return [ops.stridedSlice( - tensor, begin, end, strides, beginMask, endMask, ellipsisMask, - newAxisMask, shrinkAxisMask)]; - } - case 'Pack': { - return tidy(() => { - const axis = - getParamValue('axis', node, tensorMap, context) as number; - const tensors = - getParamValue('tensors', node, tensorMap, context) as Tensor[]; - // Reshape the tensors to the first tensor's shape if they don't - // match. - const shape = tensors[0].shape; - const squeezedShape = ops.squeeze(tensors[0]).shape; - const mapped = tensors.map(tensor => { - const sameShape = util.arraysEqual(tensor.shape, shape); - if (!sameShape && - !util.arraysEqual(ops.squeeze(tensor).shape, squeezedShape)) { - throw new Error('the input tensors shape does not match'); - } - return sameShape ? tensor : ops.reshape(tensor, shape); - }); - return [ops.stack(mapped, axis)]; - }); - } - case 'Unpack': { - const axis = - getParamValue('axis', node, tensorMap, context) as number; - const tensor = - getParamValue('tensor', node, tensorMap, context) as Tensor; - return ops.unstack(tensor, axis); - } - case 'Tile': { - const reps = - getParamValue('reps', node, tensorMap, context) as number[]; - return [ops.tile( - getParamValue('x', node, tensorMap, context) as Tensor, reps)]; - } - case 'Split': - case 'SplitV': { - const axis = - getParamValue('axis', node, tensorMap, context) as number; - const numOrSizeSplits = - getParamValue('numOrSizeSplits', node, tensorMap, context) as - number | - number[]; - const tensor = getParamValue('x', node, tensorMap, context) as Tensor; - - return ops.split(tensor, numOrSizeSplits, axis); - } - case 'ScatterNd': { - const indices = - getParamValue('indices', node, tensorMap, context) as Tensor; - const values = - getParamValue('values', node, tensorMap, context) as Tensor; - const shape = - getParamValue('shape', node, tensorMap, context) as number[]; - return [ops.scatterND(indices, values, shape)]; - } - case 'GatherNd': { - const x = getParamValue('x', node, tensorMap, context) as Tensor; - const indices = - getParamValue('indices', node, tensorMap, context) as Tensor; - return [ops.gatherND(x, indices)]; - } - case 'SparseToDense': { - const indices = - getParamValue('sparseIndices', node, tensorMap, context) as - Tensor; - const shape = - getParamValue('outputShape', node, tensorMap, context) as - number[]; - const sparseValues = - getParamValue('sparseValues', node, tensorMap, context) as Tensor; - const defaultValue = - getParamValue('defaultValue', node, tensorMap, context) as Scalar; - return [ops.sparseToDense( - indices, sparseValues, shape, - sparseValues.dtype === defaultValue.dtype ? - defaultValue : - ops.cast(defaultValue, sparseValues.dtype))]; - } - case 'TensorScatterUpdate': { - const indices = - getParamValue('indices', node, tensorMap, context) as Tensor; - const values = - getParamValue('values', node, tensorMap, context) as Tensor; - const tensor = - getParamValue('tensor', node, tensorMap, context) as Tensor; - return [ops.tensorScatterUpdate(tensor, indices, values)]; - } - default: - throw TypeError(`Node type ${node.op} is not implemented`); - } - }; - -export const CATEGORY = 'slice_join'; diff --git a/tfjs-master/tfjs-converter/src/operations/executors/slice_join_executor_test.ts b/tfjs-master/tfjs-converter/src/operations/executors/slice_join_executor_test.ts deleted file mode 100644 index 04132f2cc..000000000 --- a/tfjs-master/tfjs-converter/src/operations/executors/slice_join_executor_test.ts +++ /dev/null @@ -1,486 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -// tslint:disable-next-line: no-imports-from-dist -import * as tfOps from '@tensorflow/tfjs-core/dist/ops/ops_for_converter'; - -import {ExecutionContext} from '../../executor/execution_context'; -import * as slice_join from '../op_list/slice_join'; -import {Node} from '../types'; - -import {executeOp} from './slice_join_executor'; -import {RecursiveSpy, spyOnAllFunctions} from './spy_ops'; -import {createBooleanArrayAttrFromIndex, createNumberAttr, createNumberAttrFromIndex, createNumericArrayAttrFromIndex, createTensorAttr, createTensorsAttr, validateParam} from './test_helper'; - -describe('slice join', () => { - let node: Node; - const input1 = [tfOps.scalar(1)]; - const input2 = [tfOps.scalar(2)]; - const input3 = [tfOps.scalar(3)]; - const input4 = [tfOps.tensor1d([3])]; - const input5 = [tfOps.tensor1d([3, 4])]; - const context = new ExecutionContext({}, {}, {}); - let spyOps: RecursiveSpy; - let spyOpsAsTfOps: typeof tfOps; - - beforeEach(() => { - spyOps = spyOnAllFunctions(tfOps); - spyOpsAsTfOps = spyOps as unknown as typeof tfOps; - }); - - describe('multi-tensor ops', () => { - beforeEach(() => { - node = { - name: 'test', - op: '', - category: 'slice_join', - inputNames: ['input1', 'input2', 'input3'], - inputs: [], - inputParams: {}, - attrParams: {}, - children: [] - }; - }); - describe('executeOp', () => { - it('Concat', () => { - node.op = 'Concat'; - node.inputParams.tensors = createTensorsAttr(1, 0); - node.inputParams.axis = createNumberAttrFromIndex(0); - node.attrParams.n = createNumberAttr(2); - spyOps.concat.and.returnValue({}); - executeOp(node, {input1, input2, input3}, context, spyOpsAsTfOps); - - expect(spyOps.concat).toHaveBeenCalledWith([input2[0], input3[0]], 1); - }); - it('Concat when input length and n mismatch', () => { - node.op = 'Concat'; - node.inputParams.tensors = createTensorsAttr(0, -1); - node.inputParams.axis = createNumberAttrFromIndex(-1); - node.attrParams.n = createNumberAttr(1); - spyOps.concat.and.returnValue({}); - executeOp(node, {input1, input2, input3}, context, spyOpsAsTfOps); - - expect(spyOps.concat).toHaveBeenCalledWith([input1[0]], 3); - }); - it('should match json def for Concat', () => { - node.op = 'Concat'; - node.inputParams.tensors = createTensorsAttr(1, 0); - node.inputParams.axis = createNumberAttrFromIndex(0); - node.attrParams.n = createNumberAttr(2); - - expect(validateParam(node, slice_join.json, 'Concat')).toBeTruthy(); - }); - it('ConcatV2', () => { - node.op = 'ConcatV2'; - node.inputParams.tensors = createTensorsAttr(0, -1); - node.inputParams.axis = createNumberAttrFromIndex(-1); - node.attrParams.n = createNumberAttr(2); - spyOps.concat.and.returnValue({}); - executeOp(node, {input1, input2, input3}, context, spyOpsAsTfOps); - - expect(spyOps.concat).toHaveBeenCalledWith([input1[0], input2[0]], 3); - }); - it('ConcatV2 when input length and n mismatch', () => { - node.op = 'ConcatV2'; - node.inputParams.tensors = createTensorsAttr(0, -1); - node.inputParams.axis = createNumberAttrFromIndex(-1); - node.attrParams.n = createNumberAttr(1); - spyOps.concat.and.returnValue({}); - executeOp(node, {input1, input2, input3}, context, spyOpsAsTfOps); - - expect(spyOps.concat).toHaveBeenCalledWith([input1[0]], 3); - }); - it('should match json def for ConcatV2', () => { - node.op = 'ConcatV2'; - node.inputParams.tensors = createTensorsAttr(0, -1); - node.inputParams.axis = createNumberAttrFromIndex(-1); - node.attrParams.n = createNumberAttr(3); - - expect(validateParam(node, slice_join.json, 'ConcatV2')).toBeTruthy(); - }); - it('should call tfOps.unstack', () => { - node.op = 'Unpack'; - node.inputParams.tensor = createTensorAttr(0); - node.attrParams.axis = createNumberAttr(4); - spyOps.unstack.and.returnValue({}); - - executeOp(node, {input1}, context, spyOpsAsTfOps); - - expect(spyOps.unstack).toHaveBeenCalledWith(input1[0], 4); - }); - it('should match json def for unstack', () => { - node.op = 'Unpack'; - node.inputParams.tensor = createTensorAttr(0); - node.attrParams.axis = createNumberAttr(4); - - expect(validateParam(node, slice_join.json)).toBeTruthy(); - }); - it('should call tfOps.stack', () => { - node.op = 'Pack'; - node.inputParams.tensors = createTensorsAttr(0, 0); - node.attrParams.axis = createNumberAttr(4); - spyOps.stack.and.returnValue({}); - executeOp(node, {input1, input2, input3}, context, spyOpsAsTfOps); - - expect(spyOps.stack.calls.mostRecent().args[0][0]).toEqual(input1[0]); - expect(spyOps.stack.calls.mostRecent().args[0][1]).toEqual(input2[0]); - expect(spyOps.stack.calls.mostRecent().args[0][2]).toEqual(input3[0]); - expect(spyOps.stack.calls.mostRecent().args[1]).toEqual(4); - }); - it('should match json def for unstack', () => { - node.op = 'Pack'; - node.inputParams.tensors = createTensorsAttr(0, 0); - node.attrParams.axis = createNumberAttr(4); - - expect(validateParam(node, slice_join.json)).toBeTruthy(); - }); - it('should reshape tensors for tfOps.stack', () => { - node.op = 'Pack'; - node.inputNames = ['input1', 'input2', 'input3', 'input4']; - node.inputParams.tensors = createTensorsAttr(0, 0); - node.attrParams.axis = createNumberAttr(4); - spyOps.stack.and.returnValue({}); - executeOp( - node, {input1, input2, input3, input4}, context, spyOpsAsTfOps); - - expect(spyOps.stack.calls.mostRecent().args[0][0]).toEqual(input1[0]); - expect(spyOps.stack.calls.mostRecent().args[0][1]).toEqual(input2[0]); - expect(spyOps.stack.calls.mostRecent().args[0][2]).toEqual(input3[0]); - expect(spyOps.stack.calls.mostRecent().args[0][3].shape).toEqual([]); - expect(spyOps.stack.calls.mostRecent().args[1]).toEqual(4); - }); - it('should raise error if tensors shape does not match for tfOps.stack', - () => { - node.op = 'Pack'; - node.inputNames = ['input1', 'input2', 'input3', 'input5']; - node.inputParams.tensors = createTensorsAttr(0, 0); - node.attrParams.axis = createNumberAttr(4); - expect( - () => executeOp(node, {input1, input2, input3, input5}, context)) - .toThrow(new Error('the input tensors shape does not match')); - }); - }); - }); - describe('single-tensor ops', () => { - beforeEach(() => { - node = { - name: 'test', - op: '', - category: 'slice_join', - inputNames: ['input1'], - inputs: [], - inputParams: {x: createTensorAttr(0)}, - attrParams: {}, - children: [] - }; - }); - describe('executeOp', () => { - it('should call tfOps.reverse', () => { - node.op = 'Reverse'; - node.inputParams.dims = createBooleanArrayAttrFromIndex(1); - node.inputNames = ['input1', 'input6']; - const input6 = [tfOps.tensor1d([false, true], 'bool')]; - spyOps.reverse.and.returnValue({}); - executeOp(node, {input1, input6}, context, spyOpsAsTfOps); - - expect(spyOps.reverse).toHaveBeenCalledWith(input1[0], [1]); - }); - it('should match json def for reverse', () => { - node.op = 'Reverse'; - node.inputParams.dims = createBooleanArrayAttrFromIndex(1); - - expect(validateParam(node, slice_join.json, 'Reverse')).toBeTruthy(); - }); - it('should call tfOps.reverse', () => { - node.op = 'ReverseV2'; - node.inputParams.axis = createNumericArrayAttrFromIndex(1); - node.inputNames = ['input1', 'input4']; - spyOps.reverse.and.returnValue({}); - executeOp(node, {input1, input4}, context, spyOpsAsTfOps); - - expect(spyOps.reverse).toHaveBeenCalledWith(input1[0], [3]); - }); - it('should match json def for reverse', () => { - node.op = 'ReverseV2'; - node.inputParams.axis = createNumericArrayAttrFromIndex(1); - - expect(validateParam(node, slice_join.json, 'ReverseV2')).toBeTruthy(); - }); - it('should call tfOps.tile', () => { - node.op = 'Tile'; - node.inputParams.reps = createNumericArrayAttrFromIndex(1); - node.inputNames = ['input1', 'input4']; - spyOps.tile.and.returnValue({}); - executeOp(node, {input1, input4}, context, spyOpsAsTfOps); - - expect(spyOps.tile).toHaveBeenCalledWith(input1[0], [3]); - }); - it('should match json def for tile', () => { - node.op = 'Tile'; - node.inputParams.reps = createNumericArrayAttrFromIndex(1); - - expect(validateParam(node, slice_join.json)).toBeTruthy(); - }); - it('should call tfOps.slice', () => { - node.op = 'Slice'; - node.inputParams.begin = createNumericArrayAttrFromIndex(1); - node.inputParams.size = createNumericArrayAttrFromIndex(2); - const input6 = [tfOps.tensor1d([2], 'int32')]; - node.inputNames = ['input1', 'input6', 'input4']; - spyOps.slice.and.returnValue({}); - - executeOp(node, {input1, input6, input4}, context, spyOpsAsTfOps); - - expect(spyOps.slice).toHaveBeenCalledWith(input1[0], [2], [3]); - }); - it('should match json def for slice', () => { - node.op = 'Slice'; - node.inputParams.begin = createNumericArrayAttrFromIndex(1); - node.inputParams.size = createNumericArrayAttrFromIndex(2); - - expect(validateParam(node, slice_join.json)).toBeTruthy(); - }); - it('should call tfOps.stridedSlice', () => { - node.op = 'StridedSlice'; - node.inputParams.begin = createNumericArrayAttrFromIndex(1); - node.inputParams.end = createNumericArrayAttrFromIndex(2); - node.inputParams.strides = createNumericArrayAttrFromIndex(3); - node.attrParams.beginMask = createNumberAttr(4); - node.attrParams.endMask = createNumberAttr(5); - node.attrParams.ellipsisMask = createNumberAttr(1); - node.attrParams.newAxisMask = createNumberAttr(2); - node.attrParams.shrinkAxisMask = createNumberAttr(3); - node.inputNames = ['input1', 'input6', 'input7', 'input4']; - const input6 = [tfOps.tensor1d([2], 'int32')]; - const input7 = [tfOps.tensor1d([3], 'int32')]; - executeOp( - node, {input1, input6, input7, input4}, context, spyOpsAsTfOps); - - expect(spyOps.stridedSlice) - .toHaveBeenCalledWith(input1[0], [2], [3], [3], 4, 5, 1, 2, 3); - }); - it('should match json def for stridedSlice', () => { - node.op = 'StridedSlice'; - node.inputParams.begin = createNumericArrayAttrFromIndex(1); - node.inputParams.end = createNumericArrayAttrFromIndex(2); - node.inputParams.strides = createNumericArrayAttrFromIndex(3); - node.attrParams.beginMask = createNumberAttr(4); - node.attrParams.endMask = createNumberAttr(5); - node.attrParams.ellipsisMask = createNumberAttr(1); - node.attrParams.newAxisMask = createNumberAttr(2); - node.attrParams.shrinkAxisMask = createNumberAttr(3); - - expect(validateParam(node, slice_join.json)).toBeTruthy(); - }); - it('should call tfOps.gather', () => { - node.op = 'Gather'; - node.inputParams.indices = createTensorAttr(1); - const input5 = [tfOps.scalar(2, 'int32')]; - node.inputNames = ['input1', 'input5']; - spyOps.gather.and.returnValue({}); - executeOp(node, {input1, input5, input3}, context, spyOpsAsTfOps); - - expect(spyOps.gather) - .toHaveBeenCalledWith( - input1[0], jasmine.objectContaining({dataId: input5[0].dataId}), - 0); - }); - it('should match json def for gather', () => { - node.op = 'Gather'; - node.inputParams.indices = createTensorAttr(1); - - expect(validateParam(node, slice_join.json, 'Gather')).toBeTruthy(); - }); - it('should call tfOps.gather', () => { - node.op = 'GatherV2'; - node.inputParams.indices = createTensorAttr(1); - node.inputParams.axis = createNumberAttrFromIndex(2); - node.attrParams.batchDims = createNumberAttr(1); - const input5 = [tfOps.scalar(2, 'int32')]; - node.inputNames = ['input1', 'input5', 'input3']; - spyOps.gather.and.returnValue({}); - executeOp(node, {input1, input5, input3}, context, spyOpsAsTfOps); - - expect(spyOps.gather) - .toHaveBeenCalledWith( - input1[0], jasmine.objectContaining({dataId: input5[0].dataId}), - 3, 1); - }); - - it('should make indices param of int32 dtype', () => { - node.op = 'Gather'; - node.inputParams.indices = createTensorAttr(1); - node.inputNames = ['input1', 'input5']; - const input5 = [tfOps.scalar(2, 'float32')]; - spyOps.gather.and.returnValue({}); - executeOp(node, {input1, input5}, context, spyOpsAsTfOps); - - expect(spyOps.gather) - .toHaveBeenCalledWith( - input1[0], jasmine.objectContaining({dtype: 'int32'}), 0); - }); - it('should match json def for gather', () => { - node.op = 'GatherV2'; - node.inputParams.indices = createTensorAttr(1); - node.inputParams.axis = createNumberAttrFromIndex(2); - node.attrParams.batchDims = createNumberAttr(1); - - expect(validateParam(node, slice_join.json, 'GatherV2')).toBeTruthy(); - }); - it('should call tfOps.split', () => { - node.op = 'Split'; - node.inputParams.axis = createNumberAttrFromIndex(0); - node.inputParams.x = createTensorAttr(1); - node.attrParams.numOrSizeSplits = createNumberAttr(2); - node.inputNames = ['input1', 'input2']; - spyOps.split.and.returnValue({}); - executeOp(node, {input1, input2}, context, spyOpsAsTfOps); - - expect(spyOps.split).toHaveBeenCalledWith(input2[0], 2, 1); - }); - it('should match json def for split', () => { - node.op = 'Split'; - node.inputParams.axis = createNumberAttrFromIndex(0); - node.inputParams.x = createTensorAttr(1); - node.attrParams.numOrSizeSplits = createNumberAttr(2); - - expect(validateParam(node, slice_join.json, 'Split')).toBeTruthy(); - }); - it('should call tfOps.split', () => { - node.op = 'SplitV'; - node.inputParams.x = createTensorAttr(0); - node.inputParams.numOrSizeSplits = createNumericArrayAttrFromIndex(1); - node.inputParams.axis = createNumberAttrFromIndex(2); - node.inputNames = ['input1', 'input2', 'input3']; - spyOps.split.and.returnValue({}); - executeOp(node, {input1, input2, input3}, context, spyOpsAsTfOps); - - expect(spyOps.split).toHaveBeenCalledWith(input1[0], 2, 3); - }); - it('should match json def for split', () => { - node.op = 'SplitV'; - node.inputParams.x = createTensorAttr(0); - node.inputParams.numOrSizeSplits = createNumericArrayAttrFromIndex(1); - node.inputParams.axis = createNumberAttrFromIndex(2); - - expect(validateParam(node, slice_join.json, 'SplitV')).toBeTruthy(); - }); - it('should call tfOps.scatterND', () => { - node.op = 'ScatterNd'; - node.inputParams.indices = createTensorAttr(0); - node.inputParams.values = createTensorAttr(1); - node.inputParams.shape = createNumericArrayAttrFromIndex(2); - node.inputNames = ['input1', 'input2', 'input4']; - spyOps.scatterND.and.returnValue({}); - executeOp(node, {input1, input2, input4}, context, spyOpsAsTfOps); - - expect(spyOps.scatterND).toHaveBeenCalledWith(input1[0], input2[0], [ - 3 - ]); - }); - it('should match json def for scatterND', () => { - node.op = 'ScatterNd'; - delete node.inputParams.x; - node.inputParams.indices = createTensorAttr(0); - node.inputParams.values = createTensorAttr(1); - node.inputParams.shape = createNumericArrayAttrFromIndex(2); - - expect(validateParam(node, slice_join.json)).toBeTruthy(); - }); - it('should call tfOps.gatherND', () => { - node.op = 'GatherNd'; - node.inputParams.x = createTensorAttr(0); - node.inputParams.indices = createTensorAttr(1); - node.inputNames = ['input1', 'input2']; - spyOps.gatherND.and.returnValue({}); - executeOp(node, {input1, input2}, context, spyOpsAsTfOps); - - expect(spyOps.gatherND).toHaveBeenCalledWith(input1[0], input2[0]); - }); - it('should match json def for gatherND', () => { - node.op = 'GatherNd'; - node.inputParams.x = createTensorAttr(0); - node.inputParams.indices = createTensorAttr(1); - - expect(validateParam(node, slice_join.json)).toBeTruthy(); - }); - it('should call tfOps.sparseToDense', () => { - node.op = 'SparseToDense'; - node.inputParams.sparseIndices = createTensorAttr(0); - node.inputParams.outputShape = createNumericArrayAttrFromIndex(1); - node.inputParams.sparseValues = createTensorAttr(2); - node.inputParams.defaultValue = createTensorAttr(3); - node.inputParams.indices = createTensorAttr(1); - node.inputNames = ['input1', 'input4', 'input3', 'input2']; - spyOps.sparseToDense.and.returnValue({}); - executeOp( - node, {input1, input2, input3, input4}, context, spyOpsAsTfOps); - - expect(spyOps.sparseToDense) - .toHaveBeenCalledWith(input1[0], input3[0], [3], input2[0]); - }); - it('should make defaultValue of same dtype as sparseValues', () => { - node.op = 'SparseToDense'; - node.inputParams.sparseIndices = createTensorAttr(0); - node.inputParams.outputShape = createNumericArrayAttrFromIndex(1); - node.inputParams.sparseValues = createTensorAttr(2); - node.inputParams.defaultValue = createTensorAttr(3); - node.inputParams.indices = createTensorAttr(1); - const input5 = [tfOps.scalar(5, 'int32')]; - node.inputNames = ['input1', 'input4', 'input3', 'input5']; - spyOps.sparseToDense.and.returnValue({}); - executeOp( - node, {input1, input5, input3, input4}, context, spyOpsAsTfOps); - - expect(spyOps.sparseToDense) - .toHaveBeenCalledWith( - input1[0], input3[0], [3], - jasmine.objectContaining({dtype: 'float32'})); - }); - it('should match json def for sparseToDense', () => { - node.op = 'SparseToDense'; - node.inputParams = {}; - node.inputParams.sparseIndices = createTensorAttr(0); - node.inputParams.outputShape = createNumericArrayAttrFromIndex(1); - node.inputParams.sparseValues = createTensorAttr(2); - node.inputParams.defaultValue = createTensorAttr(3); - - expect(validateParam(node, slice_join.json)).toBeTruthy(); - }); - it('should call tfOps.tensorScatterUpdate', () => { - node.op = 'TensorScatterUpdate'; - node.inputParams.tensor = createTensorAttr(0); - node.inputParams.indices = createTensorAttr(1); - node.inputParams.values = createTensorAttr(2); - node.inputNames = ['input3', 'input1', 'input2']; - spyOps.tensorScatterUpdate.and.returnValue({}); - executeOp(node, {input3, input1, input2}, context, spyOpsAsTfOps); - - expect(spyOps.tensorScatterUpdate) - .toHaveBeenCalledWith(input3[0], input1[0], input2[0]); - }); - it('should match json def for tensorScatterUpdate', () => { - node.op = 'TensorScatterUpdate'; - delete node.inputParams.x; - node.inputParams.tensor = createTensorAttr(0); - node.inputParams.indices = createTensorAttr(1); - node.inputParams.values = createTensorAttr(2); - - expect(validateParam(node, slice_join.json)).toBeTruthy(); - }); - }); - }); -}); diff --git a/tfjs-master/tfjs-converter/src/operations/executors/sparse_executor.ts b/tfjs-master/tfjs-converter/src/operations/executors/sparse_executor.ts deleted file mode 100644 index 3cab1601d..000000000 --- a/tfjs-master/tfjs-converter/src/operations/executors/sparse_executor.ts +++ /dev/null @@ -1,80 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Scalar, Tensor, Tensor1D, Tensor2D} from '@tensorflow/tfjs-core'; -// tslint:disable-next-line: no-imports-from-dist -import * as tfOps from '@tensorflow/tfjs-core/dist/ops/ops_for_converter'; - -import {NamedTensorsMap} from '../../data/types'; -import {ExecutionContext} from '../../executor/execution_context'; -import {InternalOpExecutor, Node} from '../types'; - -import {getParamValue} from './utils'; - -export const executeOp: InternalOpExecutor = - (node: Node, tensorMap: NamedTensorsMap, - context: ExecutionContext, ops = tfOps): Tensor[] => { - switch (node.op) { - case 'SparseFillEmptyRows': { - const { - outputIndices, - outputValues, - emptyRowIndicator, - reverseIndexMap - } = - ops.sparse.sparseFillEmptyRows( - getParamValue('indices', node, tensorMap, context) as - Tensor2D, - getParamValue('values', node, tensorMap, context) as Tensor1D, - getParamValue('denseShape', node, tensorMap, context) as - Tensor1D, - getParamValue('defaultValue', node, tensorMap, context) as - Scalar); - return [ - outputIndices, outputValues, emptyRowIndicator, reverseIndexMap - ]; - } - case 'SparseReshape': { - const {outputIndices, outputShape} = ops.sparse.sparseReshape( - getParamValue('inputIndices', node, tensorMap, context) as - Tensor2D, - getParamValue('inputShape', node, tensorMap, context) as Tensor1D, - getParamValue('newShape', node, tensorMap, context) as Tensor1D); - return [outputIndices, outputShape]; - } - case 'SparseSegmentMean': { - const outputData = ops.sparse.sparseSegmentMean( - getParamValue('data', node, tensorMap, context) as Tensor, - getParamValue('indices', node, tensorMap, context) as Tensor1D, - getParamValue('segmentIds', node, tensorMap, context) as - Tensor1D); - return [outputData]; - } - case 'SparseSegmentSum': { - const outputData = ops.sparse.sparseSegmentSum( - getParamValue('data', node, tensorMap, context) as Tensor, - getParamValue('indices', node, tensorMap, context) as Tensor1D, - getParamValue('segmentIds', node, tensorMap, context) as - Tensor1D); - return [outputData]; - } - default: - throw TypeError(`Node type ${node.op} is not implemented`); - } - }; - -export const CATEGORY = 'sparse'; diff --git a/tfjs-master/tfjs-converter/src/operations/executors/sparse_executor_test.ts b/tfjs-master/tfjs-converter/src/operations/executors/sparse_executor_test.ts deleted file mode 100644 index f42a3fc07..000000000 --- a/tfjs-master/tfjs-converter/src/operations/executors/sparse_executor_test.ts +++ /dev/null @@ -1,198 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {Tensor, test_util} from '@tensorflow/tfjs-core'; -// tslint:disable-next-line: no-imports-from-dist -import * as tfOps from '@tensorflow/tfjs-core/dist/ops/ops_for_converter'; - -import {ExecutionContext} from '../../executor/execution_context'; -import * as sparse from '../op_list/sparse'; -import {Node} from '../types'; - -import {executeOp} from './sparse_executor'; -import {createTensorAttr, validateParam} from './test_helper'; -import {RecursiveSpy, spyOnAllFunctions} from './spy_ops'; - -describe('sparse', () => { - let node: Node; - const context = new ExecutionContext({}, {}, {}); - let spyOps: RecursiveSpy; - let spyOpsAsTfOps: typeof tfOps; - - beforeEach(() => { - spyOps = spyOnAllFunctions(tfOps); - spyOpsAsTfOps = spyOps as unknown as typeof tfOps; - node = { - name: 'test', - op: '', - category: 'sparse', - inputNames: [], - inputs: [], - inputParams: {}, - attrParams: {}, - children: [] - }; - }); - - describe('executeOp', () => { - describe('SparseFillEmptyRows', () => { - it('should call tfOps.sparse.sparseFillEmptyRows', async () => { - node.op = 'SparseFillEmptyRows'; - node.inputParams = { - indices: createTensorAttr(0), - values: createTensorAttr(1), - denseShape: createTensorAttr(2), - defaultValue: createTensorAttr(3) - }; - node.inputNames = ['indices', 'values', 'denseShape', 'defaultValue']; - - const indices = [tfOps.tensor2d( - [0, 0, 1, 0, 1, 3, 1, 4, 3, 2, 3, 3], [6, 2], 'int32')]; - const values = [tfOps.tensor1d([0, 10, 13, 14, 32, 33], 'int32')]; - const denseShape = [tfOps.tensor1d([5, 6], 'int32')]; - const defaultValue = [tfOps.scalar(-1, 'int32')]; - const result = executeOp( - node, {indices, values, denseShape, defaultValue}, - context, spyOpsAsTfOps) as Tensor[]; - - expect(spyOps.sparse.sparseFillEmptyRows) - .toHaveBeenCalledWith( - indices[0], values[0], denseShape[0], defaultValue[0]); - test_util.expectArraysClose( - await result[0].data(), - [0, 0, 1, 0, 1, 3, 1, 4, 2, 0, 3, 2, 3, 3, 4, 0]); - test_util.expectArraysClose( - await result[1].data(), [0, 10, 13, 14, -1, 32, 33, -1]); - test_util.expectArraysClose(await result[2].data(), [0, 0, 1, 0, 1]); - test_util.expectArraysClose(await result[3].data(), [0, 1, 2, 3, 5, 6]); - }); - it('should match json def', () => { - node.op = 'SparseFillEmptyRows'; - node.inputParams = { - indices: createTensorAttr(0), - values: createTensorAttr(1), - denseShape: createTensorAttr(2), - defaultValue: createTensorAttr(3) - }; - - expect(validateParam(node, sparse.json)).toBeTruthy(); - }); - }); - describe('SparseReshape', () => { - it('should call tfOps.sparse.sparseReshape', async () => { - node.op = 'SparseReshape'; - node.inputParams = { - inputIndices: createTensorAttr(0), - inputShape: createTensorAttr(1), - newShape: createTensorAttr(2) - }; - node.inputNames = ['inputIndices', 'inputShape', 'newShape']; - - const inputIndices = [tfOps.tensor2d( - [0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 2, 3], [5, 3], 'int32')]; - const inputShape = [tfOps.tensor1d([2, 3, 6], 'int32')]; - const newShape = [tfOps.tensor1d([9, -1], 'int32')]; - const result = - executeOp(node, {inputIndices, inputShape, newShape}, context, - spyOpsAsTfOps) as Tensor[]; - - expect(spyOps.sparse.sparseReshape) - .toHaveBeenCalledWith(inputIndices[0], inputShape[0], newShape[0]); - test_util.expectArraysClose( - await result[0].data(), [0, 0, 0, 1, 1, 2, 4, 2, 8, 1]); - test_util.expectArraysClose(await result[1].data(), [9, 4]); - }); - - it('should match json def', () => { - node.op = 'SparseReshape'; - node.inputParams = { - inputIndices: createTensorAttr(0), - inputShape: createTensorAttr(1), - newShape: createTensorAttr(2) - }; - - expect(validateParam(node, sparse.json)).toBeTruthy(); - }); - }); - describe('SparseSegmentMean', () => { - it('should call tfOps.sparse.sparseSegmentMean', async () => { - node.op = 'SparseSegmentMean'; - node.inputParams = { - data: createTensorAttr(0), - indices: createTensorAttr(1), - segmentIds: createTensorAttr(2) - }; - node.inputNames = ['data', 'indices', 'segmentIds']; - - const data = [tfOps.tensor2d( - [1, 2, 3, 4, -1, -2, -3, -4, 6, 7, 8, 9], [3, 4], 'float32')]; - const indices = [tfOps.tensor1d([0, 1, 2], 'int32')]; - const segmentIds = [tfOps.tensor1d([0, 1, 1], 'int32')]; - const result = - executeOp(node, {data, indices, segmentIds}, context, - spyOpsAsTfOps) as Tensor[]; - - expect(spyOps.sparse.sparseSegmentMean) - .toHaveBeenCalledWith(data[0], indices[0], segmentIds[0]); - test_util.expectArraysClose( - await result[0].data(), [1.0, 2.0, 3.0, 4.0, 2.5, 2.5, 2.5, 2.5]); - }); - it('should match json def', () => { - node.op = 'SparseSegmentMean'; - node.inputParams = { - data: createTensorAttr(0), - indices: createTensorAttr(1), - segmentIds: createTensorAttr(2) - }; - - expect(validateParam(node, sparse.json)).toBeTruthy(); - }); - }); - describe('SparseSegmentSum', () => { - it('should call tfOps.sparse.sparseSegmentSum', async () => { - node.op = 'SparseSegmentSum'; - node.inputParams = { - data: createTensorAttr(0), - indices: createTensorAttr(1), - segmentIds: createTensorAttr(2) - }; - node.inputNames = ['data', 'indices', 'segmentIds']; - - const data = [tfOps.tensor2d( - [1, 2, 3, 4, -1, -2, -3, -4, 5, 6, 7, 8], [3, 4], 'int32')]; - const indices = [tfOps.tensor1d([0, 1], 'int32')]; - const segmentIds = [tfOps.tensor1d([0, 0], 'int32')]; - const result = - executeOp(node, {data, indices, segmentIds}, context, - spyOpsAsTfOps) as Tensor[]; - - expect(spyOps.sparse.sparseSegmentSum) - .toHaveBeenCalledWith(data[0], indices[0], segmentIds[0]); - test_util.expectArraysClose(await result[0].data(), [0, 0, 0, 0]); - }); - it('should match json def', () => { - node.op = 'SparseSegmentSum'; - node.inputParams = { - data: createTensorAttr(0), - indices: createTensorAttr(1), - segmentIds: createTensorAttr(2) - }; - - expect(validateParam(node, sparse.json)).toBeTruthy(); - }); - }); - }); -}); diff --git a/tfjs-master/tfjs-converter/src/operations/executors/spectral_executor.ts b/tfjs-master/tfjs-converter/src/operations/executors/spectral_executor.ts deleted file mode 100644 index 9a1f49b93..000000000 --- a/tfjs-master/tfjs-converter/src/operations/executors/spectral_executor.ts +++ /dev/null @@ -1,53 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Tensor} from '@tensorflow/tfjs-core'; -// tslint:disable-next-line: no-imports-from-dist -import * as tfOps from '@tensorflow/tfjs-core/dist/ops/ops_for_converter'; - -import {NamedTensorsMap} from '../../data/types'; -import {ExecutionContext} from '../../executor/execution_context'; -import {InternalOpExecutor, Node} from '../types'; - -import {getParamValue} from './utils'; - -export const executeOp: InternalOpExecutor = - (node: Node, tensorMap: NamedTensorsMap, context: ExecutionContext, - ops = tfOps): Tensor[] => { - switch (node.op) { - case 'FFT': { - return [ops.fft( - getParamValue('x', node, tensorMap, context) as Tensor)]; - } - case 'IFFT': { - return [ops.ifft( - getParamValue('x', node, tensorMap, context) as Tensor)]; - } - case 'RFFT': { - return [ops.rfft( - getParamValue('x', node, tensorMap, context) as Tensor)]; - } - case 'IRFFT': { - return [ops.irfft( - getParamValue('x', node, tensorMap, context) as Tensor)]; - } - default: - throw TypeError(`Node type ${node.op} is not implemented`); - } - }; - -export const CATEGORY = 'spectral'; diff --git a/tfjs-master/tfjs-converter/src/operations/executors/spectral_executor_test.ts b/tfjs-master/tfjs-converter/src/operations/executors/spectral_executor_test.ts deleted file mode 100644 index 5e4d0a794..000000000 --- a/tfjs-master/tfjs-converter/src/operations/executors/spectral_executor_test.ts +++ /dev/null @@ -1,108 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -// tslint:disable-next-line: no-imports-from-dist -import * as tfOps from '@tensorflow/tfjs-core/dist/ops/ops_for_converter'; - -import {ExecutionContext} from '../../executor/execution_context'; -import * as spectral from '../op_list/spectral'; -import {Node} from '../types'; - -import {executeOp} from './spectral_executor'; -import {createTensorAttr, validateParam} from './test_helper'; -import {RecursiveSpy, spyOnAllFunctions} from './spy_ops'; - -describe('spectral', () => { - let node: Node; - const input1 = [tfOps.scalar(1)]; - const context = new ExecutionContext({}, {}, {}); - let spyOps: RecursiveSpy; - let spyOpsAsTfOps: typeof tfOps; - - beforeEach(() => { - spyOps = spyOnAllFunctions(tfOps); - spyOpsAsTfOps = spyOps as unknown as typeof tfOps; - node = { - name: 'test', - op: '', - category: 'spectral', - inputNames: ['input1'], - inputs: [], - inputParams: {x: createTensorAttr(0)}, - attrParams: {}, - children: [] - }; - }); - - describe('executeOp', () => { - describe('FFT', () => { - it('should call tfOps.fft', () => { - node.op = 'FFT'; - spyOps.fft.and.returnValue({}); - executeOp(node, {input1}, context, spyOpsAsTfOps); - - expect(spyOps.fft).toHaveBeenCalledWith(input1[0]); - }); - it('should match json def', () => { - node.op = 'FFT'; - - expect(validateParam(node, spectral.json)).toBeTruthy(); - }); - }); - describe('IFFT', () => { - it('should call tfOps.ifft', () => { - node.op = 'IFFT'; - spyOps.ifft.and.returnValue({}); - executeOp(node, {input1}, context, spyOpsAsTfOps); - - expect(spyOps.ifft).toHaveBeenCalledWith(input1[0]); - }); - it('should match json def', () => { - node.op = 'IFFT'; - - expect(validateParam(node, spectral.json)).toBeTruthy(); - }); - }); - describe('RFFT', () => { - it('should call tfOps.rfft', () => { - node.op = 'RFFT'; - spyOps.rfft.and.returnValue({}); - executeOp(node, {input1}, context, spyOpsAsTfOps); - - expect(spyOps.rfft).toHaveBeenCalledWith(input1[0]); - }); - it('should match json def', () => { - node.op = 'RFFT'; - - expect(validateParam(node, spectral.json)).toBeTruthy(); - }); - }); - describe('IRFFT', () => { - it('should call tfOps.irfft', () => { - node.op = 'IRFFT'; - spyOps.irfft.and.returnValue({}); - executeOp(node, {input1}, context, spyOpsAsTfOps); - - expect(spyOps.irfft).toHaveBeenCalledWith(input1[0]); - }); - it('should match json def', () => { - node.op = 'IRFFT'; - - expect(validateParam(node, spectral.json)).toBeTruthy(); - }); - }); - }); -}); diff --git a/tfjs-master/tfjs-converter/src/operations/executors/spy_ops.ts b/tfjs-master/tfjs-converter/src/operations/executors/spy_ops.ts deleted file mode 100644 index ae1ef9936..000000000 --- a/tfjs-master/tfjs-converter/src/operations/executors/spy_ops.ts +++ /dev/null @@ -1,44 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// The opposite of Extract -type Without = T extends U ? never : T; - -// Do not spy on CompositeArrayBuffer because it is a class constructor. -type NotSpiedOn = 'CompositeArrayBuffer'; - -export type RecursiveSpy = - T extends Function ? jasmine.Spy : - {[K in Without]: RecursiveSpy} & - {[K in Extract]: T[K]}; - -export function spyOnAllFunctions(obj: T): RecursiveSpy { - return Object.fromEntries(Object.entries(obj).map(([key, val]) => { - // TODO(mattSoulanille): Do not hard code this - if (key === 'CompositeArrayBuffer') { - return val; - } - if (val instanceof Function) { - return [key, jasmine.createSpy(`${key} spy`, val).and.callThrough()]; - } else if (val instanceof Array) { - return [key, val]; - } else if (val instanceof Object) { - return [key, spyOnAllFunctions(val)]; - } - return [key, val]; - })) as RecursiveSpy; -} diff --git a/tfjs-master/tfjs-converter/src/operations/executors/string_executor.ts b/tfjs-master/tfjs-converter/src/operations/executors/string_executor.ts deleted file mode 100644 index 85b5a4942..000000000 --- a/tfjs-master/tfjs-converter/src/operations/executors/string_executor.ts +++ /dev/null @@ -1,73 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Scalar, Tensor, Tensor1D} from '@tensorflow/tfjs-core'; -// tslint:disable-next-line: no-imports-from-dist -import * as tfOps from '@tensorflow/tfjs-core/dist/ops/ops_for_converter'; - -import {NamedTensorsMap} from '../../data/types'; -import {ExecutionContext} from '../../executor/execution_context'; -import {InternalOpExecutor, Node} from '../types'; - -import {getParamValue} from './utils'; - -export const executeOp: InternalOpExecutor = - (node: Node, tensorMap: NamedTensorsMap, - context: ExecutionContext, ops = tfOps): Tensor[] => { - switch (node.op) { - case 'StaticRegexReplace': { - return [ops.string.staticRegexReplace( - getParamValue('input', node, tensorMap, context) as Tensor, - getParamValue('pattern', node, tensorMap, context) as string, - getParamValue('rewrite', node, tensorMap, context) as string, - getParamValue('replaceGlobal', node, tensorMap, context) as boolean, - )]; - } - case 'StringNGrams': { - const {nGrams, nGramsSplits} = ops.string.stringNGrams( - getParamValue('data', node, tensorMap, context) as Tensor1D, - getParamValue('dataSplits', node, tensorMap, context) as Tensor, - getParamValue('separator', node, tensorMap, context) as string, - getParamValue('nGramWidths', node, tensorMap, context) as - number[], - getParamValue('leftPad', node, tensorMap, context) as string, - getParamValue('rightPad', node, tensorMap, context) as string, - getParamValue('padWidth', node, tensorMap, context) as number, - getParamValue( - 'preserveShortSequences', node, tensorMap, context) as - boolean); - return [nGrams, nGramsSplits]; - } - case 'StringSplit': { - const {indices, values, shape} = ops.string.stringSplit( - getParamValue('input', node, tensorMap, context) as Tensor1D, - getParamValue('delimiter', node, tensorMap, context) as Scalar, - getParamValue('skipEmpty', node, tensorMap, context) as boolean); - return [indices, values, shape]; - } - case 'StringToHashBucketFast': { - const output = ops.string.stringToHashBucketFast( - getParamValue('input', node, tensorMap, context) as Tensor, - getParamValue('numBuckets', node, tensorMap, context) as number); - return [output]; - } - default: - throw TypeError(`Node type ${node.op} is not implemented`); - } - }; - -export const CATEGORY = 'string'; diff --git a/tfjs-master/tfjs-converter/src/operations/executors/string_executor_test.ts b/tfjs-master/tfjs-converter/src/operations/executors/string_executor_test.ts deleted file mode 100644 index 55792db2a..000000000 --- a/tfjs-master/tfjs-converter/src/operations/executors/string_executor_test.ts +++ /dev/null @@ -1,176 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {Tensor, test_util} from '@tensorflow/tfjs-core'; -// tslint:disable-next-line: no-imports-from-dist -import * as tfOps from '@tensorflow/tfjs-core/dist/ops/ops_for_converter'; - -import {ExecutionContext} from '../../executor/execution_context'; -import * as string from '../op_list/string'; -import {Node} from '../types'; - -import {executeOp} from './string_executor'; -import {createBoolAttr, createNumberAttr, createNumericArrayAttr, createStrAttr, createTensorAttr, validateParam} from './test_helper'; -import {RecursiveSpy, spyOnAllFunctions} from './spy_ops'; - -describe('string', () => { - let node: Node; - const context = new ExecutionContext({}, {}, {}); - let spyOps: RecursiveSpy; - let spyOpsAsTfOps: typeof tfOps; - - beforeEach(() => { - spyOps = spyOnAllFunctions(tfOps); - spyOpsAsTfOps = spyOps as unknown as typeof tfOps; - node = { - name: 'test', - op: '', - category: 'string', - inputNames: [], - inputs: [], - inputParams: {}, - attrParams: {}, - children: [], - outputs: [] - }; - }); - - describe('executeOp', () => { - describe('StaticRegexReplace', () => { - it('should call tfOps.string.staticRegexReplace', async () => { - node.op = 'StaticRegexReplace'; - node.inputParams = { - input: createTensorAttr(0), - }; - node.attrParams = { - pattern: createStrAttr('foo'), - rewrite: createStrAttr('bar'), - replaceGlobal: createBoolAttr(true), - }; - node.inputNames = ['input']; - - const input = [tfOps.tensor1d(['a', 'b', 'foo', 'd'])]; - const result = executeOp(node, {input}, context, - spyOpsAsTfOps) as Tensor[]; - - expect(spyOps.string.staticRegexReplace) - .toHaveBeenCalledWith(input[0], 'foo', 'bar', true); - - test_util.expectArraysEqual( - await result[0].data(), ['a', 'b', 'bar', 'd']); - }); - }); - describe('StringNGrams', () => { - it('should call tfOps.string.stringNGrams', async () => { - node.op = 'StringNGrams'; - node.inputParams = { - data: createTensorAttr(0), - dataSplits: createTensorAttr(1) - }; - node.attrParams = { - separator: createStrAttr('|'), - nGramWidths: createNumericArrayAttr([3]), - leftPad: createStrAttr('LP'), - rightPad: createStrAttr('RP'), - padWidth: createNumberAttr(-1), - preserveShortSequences: createBoolAttr(false) - }; - node.inputNames = ['data', 'dataSplits']; - node.outputs = ['ngrams', 'ngrams_splits']; - - const data = [tfOps.tensor1d(['a', 'b', 'c', 'd', 'e', 'f'], 'string')]; - const dataSplits = [tfOps.tensor1d([0, 4, 6], 'int32')]; - const result = executeOp(node, {data, dataSplits}, context, - spyOpsAsTfOps) as Tensor[]; - - expect(spyOps.string.stringNGrams) - .toHaveBeenCalledWith( - data[0], dataSplits[0], '|', [3], 'LP', 'RP', -1, false); - test_util.expectArraysEqual(await result[0].data(), [ - 'LP|LP|a', 'LP|a|b', 'a|b|c', 'b|c|d', 'c|d|RP', 'd|RP|RP', // 0 - 'LP|LP|e', 'LP|e|f', 'e|f|RP', 'f|RP|RP' // 1 - ]); - test_util.expectArraysEqual(await result[1].data(), [0, 6, 10]); - }); - it('should match json def', () => { - node.op = 'StringNGrams'; - node.inputParams = { - data: createTensorAttr(0), - dataSplits: createTensorAttr(1) - }; - node.outputs = ['ngrams', 'ngrams_splits']; - expect(validateParam(node, string.json)).toBeTruthy(); - }); - }); - describe('StringSplit', () => { - it('should call tfOps.string.stringSplit', async () => { - node.op = 'StringSplit'; - node.inputParams = { - input: createTensorAttr(0), - delimiter: createTensorAttr(1) - }; - node.attrParams = {skipEmpty: createBoolAttr(false)}; - node.inputNames = ['input', 'delimiter']; - node.outputs = ['indices', 'values', 'shape']; - - const input = [tfOps.tensor1d(['#a', 'b#', '#c#'], 'string')]; - const delimiter = [tfOps.scalar('#', 'string')]; - const result = executeOp(node, {input, delimiter}, context, - spyOpsAsTfOps) as Tensor[]; - - expect(spyOps.string.stringSplit) - .toHaveBeenCalledWith(input[0], delimiter[0], false); - test_util.expectArraysEqual( - await result[0].data(), [0, 0, 0, 1, 1, 0, 1, 1, 2, 0, 2, 1, 2, 2]); - test_util.expectArraysEqual( - await result[1].data(), ['', 'a', 'b', '', '', 'c', '']); - test_util.expectArraysEqual(await result[2].data(), [3, 3]); - }); - it('should match json def', () => { - node.op = 'StringSplit'; - node.inputParams = { - input: createTensorAttr(0), - delimiter: createTensorAttr(1) - }; - node.outputs = ['indices', 'values', 'shape']; - - expect(validateParam(node, string.json)).toBeTruthy(); - }); - }); - describe('StringToHashBucketFast', () => { - it('should call tfOps.string.stringToHashBucketFast', async () => { - node.op = 'StringToHashBucketFast'; - node.inputParams = {input: createTensorAttr(0)}; - node.attrParams = {numBuckets: createNumberAttr(10)}; - node.inputNames = ['input']; - - const input = [tfOps.tensor1d(['a', 'b', 'c', 'd'], 'string')]; - const result = executeOp(node, {input}, context, - spyOpsAsTfOps) as Tensor[]; - - expect(spyOps.string.stringToHashBucketFast) - .toHaveBeenCalledWith(input[0], 10); - test_util.expectArraysClose(await result[0].data(), [9, 2, 2, 5]); - }); - it('should match json def', () => { - node.op = 'StringToHashBucketFast'; - node.inputParams = {input: createTensorAttr(0)}; - - expect(validateParam(node, string.json)).toBeTruthy(); - }); - }); - }); -}); diff --git a/tfjs-master/tfjs-converter/src/operations/executors/test_helper.ts b/tfjs-master/tfjs-converter/src/operations/executors/test_helper.ts deleted file mode 100644 index 25a004fcc..000000000 --- a/tfjs-master/tfjs-converter/src/operations/executors/test_helper.ts +++ /dev/null @@ -1,101 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {InputParamValue, OpMapper, ParamValue} from '../types'; -import {Node} from '../types'; - -export function createNumberAttr(value: number): ParamValue { - return {value, type: 'number'}; -} - -export function createNumberAttrFromIndex(inputIndex: number): InputParamValue { - return {inputIndexStart: inputIndex, type: 'number'}; -} - -export function createStrAttr(str: string): ParamValue { - return {value: str, type: 'string'}; -} - -export function createStrArrayAttr(strs: string[]): ParamValue { - return {value: strs, type: 'string[]'}; -} - -export function createBoolAttr(value: boolean): ParamValue { - return {value, type: 'bool'}; -} - -export function createTensorShapeAttr(value: number[]): ParamValue { - return {value, type: 'shape'}; -} - -export function createShapeAttrFromIndex(inputIndex: number): InputParamValue { - return {inputIndexStart: inputIndex, type: 'shape'}; -} - -export function createNumericArrayAttr(value: number[]): ParamValue { - return {value, type: 'number[]'}; -} - -export function createNumericArrayAttrFromIndex(inputIndex: number): - InputParamValue { - return {inputIndexStart: inputIndex, type: 'number[]'}; -} - -export function createBooleanArrayAttrFromIndex(inputIndex: number): - InputParamValue { - return {inputIndexStart: inputIndex, type: 'bool[]'}; -} - -export function createTensorAttr(index: number): InputParamValue { - return {inputIndexStart: index, type: 'tensor'}; -} - -export function createTensorsAttr( - index: number, paramLength: number): InputParamValue { - return {inputIndexStart: index, inputIndexEnd: paramLength, type: 'tensors'}; -} - -export function createDtypeAttr(dtype: string): ParamValue { - return {value: dtype, type: 'dtype'}; -} - -export function validateParam( - node: Node, opMappers: OpMapper[], tfOpName?: string) { - const opMapper = tfOpName != null ? - opMappers.find(mapper => mapper.tfOpName === tfOpName) : - opMappers.find(mapper => mapper.tfOpName === node.op); - const matched = Object.keys(node.inputParams).every(key => { - const value = node.inputParams[key]; - const def = opMapper.inputs.find(param => param.name === key); - return def && def.type === value.type && - def.start === value.inputIndexStart && def.end === value.inputIndexEnd; - }) && - Object.keys(node.attrParams).every(key => { - const value = node.attrParams[key]; - const def = opMapper.attrs.find(param => param.name === key); - return def && def.type === value.type; - }); - if (!matched) { - console.log('node = ', node); - console.log('opMapper = ', opMapper); - } - return matched; -} - -export function uncapitalize(name: Name): Uncapitalize { - return name.charAt(0).toLowerCase() + name.slice(1) as Uncapitalize; -} diff --git a/tfjs-master/tfjs-converter/src/operations/executors/transformation_executor.ts b/tfjs-master/tfjs-converter/src/operations/executors/transformation_executor.ts deleted file mode 100644 index 0244f8cb6..000000000 --- a/tfjs-master/tfjs-converter/src/operations/executors/transformation_executor.ts +++ /dev/null @@ -1,122 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Tensor, Tensor4D} from '@tensorflow/tfjs-core'; -// tslint:disable-next-line: no-imports-from-dist -import * as tfOps from '@tensorflow/tfjs-core/dist/ops/ops_for_converter'; - -import {NamedTensorsMap} from '../../data/types'; -import {ExecutionContext} from '../../executor/execution_context'; -import {InternalOpExecutor, Node} from '../types'; - -import {getParamValue} from './utils'; - -export const executeOp: InternalOpExecutor = - (node: Node, tensorMap: NamedTensorsMap, context: ExecutionContext, - ops = tfOps): Tensor[] => { - switch (node.op) { - case 'Cast': { - return [ops.cast( - getParamValue('x', node, tensorMap, context) as Tensor, - getParamValue('dtype', node, tensorMap, context) as 'int32' | - 'float32' | 'bool')]; - } - case 'ExpandDims': { - const axis = - getParamValue('axis', node, tensorMap, context) as number; - return [ops.expandDims( - getParamValue('x', node, tensorMap, context) as Tensor, axis)]; - } - case 'Squeeze': { - const axis = - getParamValue('axis', node, tensorMap, context) as number[]; - return [ops.squeeze( - getParamValue('x', node, tensorMap, context) as Tensor, axis)]; - } - - case 'Reshape': { - return [ops.reshape( - getParamValue('x', node, tensorMap, context) as Tensor, - getParamValue('shape', node, tensorMap, context) as number[])]; - } - case 'EnsureShape': { - return [ops.ensureShape( - getParamValue('x', node, tensorMap, context) as Tensor, - getParamValue('shape', node, tensorMap, context) as number[])]; - } - case 'MirrorPad': { - return [ops.mirrorPad( - getParamValue('x', node, tensorMap, context) as Tensor, - getParamValue('padding', node, tensorMap, context) as - Array<[number, number]>, - getParamValue('mode', node, tensorMap, context) as 'reflect' | - 'symmetric')]; - } - case 'PadV2': - case 'Pad': { - return [ops.pad( - getParamValue('x', node, tensorMap, context) as Tensor, - getParamValue('padding', node, tensorMap, context) as - Array<[number, number]>, - getParamValue('constantValue', node, tensorMap, context) as - number)]; - } - case 'SpaceToBatchND': { - const blockShape = - getParamValue('blockShape', node, tensorMap, context) as number[]; - const paddings = - getParamValue('paddings', node, tensorMap, context) as number[][]; - return [ops.spaceToBatchND( - getParamValue('x', node, tensorMap, context) as Tensor, - blockShape, paddings)]; - } - case 'BatchToSpaceND': { - const blockShape = - getParamValue('blockShape', node, tensorMap, context) as number[]; - const crops = - getParamValue('crops', node, tensorMap, context) as number[][]; - return [ops.batchToSpaceND( - getParamValue('x', node, tensorMap, context) as Tensor, - blockShape, crops)]; - } - case 'DepthToSpace': { - const blockSize = - getParamValue('blockSize', node, tensorMap, context) as number; - const dataFormat = - (getParamValue('dataFormat', node, tensorMap, context) as - string).toUpperCase() as 'NHWC' | - 'NCHW'; - return [ops.depthToSpace( - getParamValue('x', node, tensorMap, context) as Tensor4D, - blockSize, dataFormat)]; - } - case 'BroadcastTo': { - return [ops.broadcastTo( - getParamValue('x', node, tensorMap, context) as Tensor, - getParamValue('shape', node, tensorMap, context) as number[])]; - } - case 'BroadcastArgs': { - return [ops.broadcastArgs( - getParamValue('s0', node, tensorMap, context) as Tensor, - getParamValue('s1', node, tensorMap, context) as Tensor)]; - } - default: - throw TypeError(`Node type ${node.op} is not implemented`); - } - }; - -export const CATEGORY = 'transformation'; diff --git a/tfjs-master/tfjs-converter/src/operations/executors/transformation_executor_test.ts b/tfjs-master/tfjs-converter/src/operations/executors/transformation_executor_test.ts deleted file mode 100644 index dec5c09f1..000000000 --- a/tfjs-master/tfjs-converter/src/operations/executors/transformation_executor_test.ts +++ /dev/null @@ -1,217 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -// tslint:disable-next-line: no-imports-from-dist -import * as tfOps from '@tensorflow/tfjs-core/dist/ops/ops_for_converter'; - -import {ExecutionContext} from '../../executor/execution_context'; -import {Node} from '../types'; - -import {RecursiveSpy, spyOnAllFunctions} from './spy_ops'; -import {createDtypeAttr, createNumberAttr, createNumericArrayAttrFromIndex, createStrAttr, createTensorAttr} from './test_helper'; -import {executeOp} from './transformation_executor'; - -describe('transformation', () => { - let node: Node; - const input1 = [tfOps.scalar(1)]; - const input2 = [tfOps.tensor1d([1, 1])]; - const context = new ExecutionContext({}, {}, {}); - - beforeEach(() => { - node = { - name: 'test', - op: '', - category: 'transformation', - inputNames: ['input1'], - inputs: [], - inputParams: {x: createTensorAttr(0)}, - attrParams: {}, - children: [] - }; - }); - - describe('executeOp', () => { - let spyOps: RecursiveSpy; - let spyOpsAsTfOps: typeof tfOps; - - beforeEach(() => { - spyOps = spyOnAllFunctions(tfOps); - spyOpsAsTfOps = spyOps as unknown as typeof tfOps; - }); - - describe('Cast', () => { - it('should call tfOps.cast', () => { - node.op = 'Cast'; - node.attrParams.dtype = createDtypeAttr('float32'); - executeOp(node, {input1}, context, spyOpsAsTfOps); - - expect(spyOps.cast).toHaveBeenCalledWith(input1[0], 'float32'); - }); - }); - describe('ExpandDims', () => { - it('should call tfOps.expandDims', () => { - node.op = 'ExpandDims'; - node.attrParams.axis = createNumberAttr(1); - spyOps.expandDims.and.returnValue({}); - executeOp(node, {input1}, context, spyOpsAsTfOps); - - expect(spyOps.expandDims).toHaveBeenCalledWith(input1[0], 1); - }); - }); - describe('MirrorPad', () => { - it('should call tfc.mirrorPad', () => { - node.op = 'MirrorPad'; - node.inputParams.padding = createNumericArrayAttrFromIndex(1); - node.attrParams.mode = createStrAttr('reflect'); - node.inputNames = ['input1', 'input3']; - const input3 = [tfOps.tensor2d([1, 1, 2, 2], [2, 2])]; - spyOps.mirrorPad.and.returnValue({}); - executeOp(node, {input1, input3}, context, spyOpsAsTfOps); - - expect(spyOps.mirrorPad) - .toHaveBeenCalledWith(input1[0], [[1, 1], [2, 2]], 'reflect'); - }); - }); - describe('Pad', () => { - it('should call tfOps.pad', () => { - node.op = 'Pad'; - node.inputParams.padding = createNumericArrayAttrFromIndex(1); - node.attrParams.constantValue = createNumberAttr(1); - node.inputNames = ['input1', 'input3']; - const input3 = [tfOps.tensor2d([1, 1, 2, 2], [2, 2])]; - spyOps.pad.and.returnValue({}); - executeOp(node, {input1, input3}, context, spyOpsAsTfOps); - - expect(spyOps.pad).toHaveBeenCalledWith(input1[0], [[1, 1], [2, 2]], 1); - }); - }); - describe('PadV2', () => { - it('should call tfOps.pad', () => { - node.op = 'PadV2'; - node.inputParams.padding = createNumericArrayAttrFromIndex(1); - node.attrParams.constantValue = createNumberAttr(1); - node.inputNames = ['input1', 'input3']; - const input3 = [tfOps.tensor2d([1, 1, 2, 2], [2, 2])]; - spyOps.pad.and.returnValue({}); - executeOp(node, {input1, input3}, context, spyOpsAsTfOps); - - expect(spyOps.pad).toHaveBeenCalledWith(input1[0], [[1, 1], [2, 2]], 1); - }); - }); - describe('Reshape', () => { - it('should call tfOps.reshape', () => { - node.op = 'Reshape'; - node.inputParams.shape = createNumericArrayAttrFromIndex(1); - node.inputNames = ['input1', 'input2']; - - executeOp(node, {input1, input2}, context, spyOpsAsTfOps); - - expect(spyOps.reshape).toHaveBeenCalledWith(input1[0], [1, 1]); - }); - }); - describe('EnsureShape', () => { - it('should call tfOps.ensureShape', () => { - node.op = 'EnsureShape'; - node.inputParams.shape = createNumericArrayAttrFromIndex(1); - node.inputNames = ['input2', 'input3']; - const input3 = [tfOps.tensor1d([2])]; - - executeOp(node, {input2, input3}, context, spyOpsAsTfOps); - - expect(spyOps.ensureShape).toHaveBeenCalledWith(input2[0], [2]); - }); - }); - describe('Squeeze', () => { - it('should call tfOps.squeeze', () => { - node.op = 'Squeeze'; - node.attrParams.axis = createNumberAttr(1); - spyOps.squeeze.and.returnValue({}); - executeOp(node, {input1}, context, spyOpsAsTfOps); - - expect(spyOps.squeeze).toHaveBeenCalledWith(input1[0], 1); - }); - }); - describe('SpaceToBatchND', () => { - it('should call tfOps.spaceToBatchND', () => { - node.op = 'SpaceToBatchND'; - node.inputParams.blockShape = createNumericArrayAttrFromIndex(1); - node.inputParams.paddings = createNumericArrayAttrFromIndex(2); - node.inputNames = ['input1', 'input2', 'input3']; - const input2 = [tfOps.tensor1d([1, 1, 2, 2])]; - const input3 = [tfOps.tensor2d([1, 2, 2, 3, 2, 3, 3, 4], [4, 2])]; - spyOps.spaceToBatchND.and.returnValue({}); - executeOp(node, {input1, input2, input3}, context, spyOpsAsTfOps); - - expect(spyOps.spaceToBatchND) - .toHaveBeenCalledWith( - input1[0], [1, 1, 2, 2], [[1, 2], [2, 3], [2, 3], [3, 4]]); - }); - }); - describe('BatchToSpaceND', () => { - it('should call tfOps.batchToSpaceND', () => { - node.op = 'BatchToSpaceND'; - node.inputParams.blockShape = createNumericArrayAttrFromIndex(1); - node.inputParams.crops = createNumericArrayAttrFromIndex(2); - node.inputNames = ['input1', 'input2', 'input3']; - const input2 = [tfOps.tensor1d([1, 1, 2, 2])]; - const input3 = [tfOps.tensor2d([1, 2, 2, 3, 2, 3, 3, 4], [4, 2])]; - spyOps.batchToSpaceND.and.returnValue({}); - executeOp(node, {input1, input2, input3}, context, spyOpsAsTfOps); - - expect(spyOps.batchToSpaceND) - .toHaveBeenCalledWith( - input1[0], [1, 1, 2, 2], [[1, 2], [2, 3], [2, 3], [3, 4]]); - }); - }); - describe('DepthToSpace', () => { - it('should call tfOps.depthToSpace', () => { - node.op = 'DepthToSpace'; - node.attrParams.blockSize = createNumberAttr(1); - node.attrParams.dataFormat = createStrAttr('nhwc'); - node.inputNames = ['input1']; - spyOps.depthToSpace.and.returnValue({}); - executeOp(node, {input1}, context, spyOpsAsTfOps); - - expect(spyOps.depthToSpace).toHaveBeenCalledWith(input1[0], 1, 'NHWC'); - }); - }); - describe('BroadcastTo', () => { - it('should call tfOps.broadcastTo', () => { - node.op = 'BroadcastTo'; - node.inputParams.shape = createNumericArrayAttrFromIndex(1); - node.inputNames = ['input1', 'input2']; - - executeOp(node, {input1, input2}, context, spyOpsAsTfOps); - - expect(spyOps.broadcastTo).toHaveBeenCalledWith(input1[0], [1, 1]); - }); - }); - describe('BroadcastArgs', () => { - it('should call tfOps.broadcastArgs', () => { - node.op = 'BroadcastArgs'; - node.inputParams.s0 = createTensorAttr(0); - node.inputParams.s1 = createTensorAttr(1); - node.inputNames = ['input1', 'input2']; - const input1 = [tfOps.tensor1d([1, 1])]; - const input2 = [tfOps.tensor1d([1, 1])]; - spyOps.broadcastArgs.and.returnValue({}); - executeOp(node, {input1, input2}, context, spyOpsAsTfOps); - - expect(spyOps.broadcastArgs).toHaveBeenCalledWith(input1[0], input2[0]); - }); - }); - }); -}); diff --git a/tfjs-master/tfjs-converter/src/operations/executors/utils.ts b/tfjs-master/tfjs-converter/src/operations/executors/utils.ts deleted file mode 100644 index e206893be..000000000 --- a/tfjs-master/tfjs-converter/src/operations/executors/utils.ts +++ /dev/null @@ -1,191 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {clone, Tensor, util} from '@tensorflow/tfjs-core'; - -import {NamedTensorsMap} from '../../data/types'; -import {ExecutionContext} from '../../executor/execution_context'; -import {ResourceManager} from '../../executor/resource_manager'; -import {Node, ValueType} from '../types'; - -export function getParamValue( - paramName: string, node: Node, tensorMap: NamedTensorsMap, - context: ExecutionContext, resourceManager?: ResourceManager): ValueType { - const inputParam = node.inputParams[paramName]; - if (inputParam && inputParam.inputIndexStart !== undefined) { - const start = inputParam.inputIndexStart; - const end = inputParam.inputIndexEnd === 0 ? - undefined : - (inputParam.inputIndexEnd === undefined ? start + 1 : - inputParam.inputIndexEnd); - const shiftedStart = start < 0 ? node.inputNames.length + start : start; - if (inputParam.type === 'tensor') { - return getTensor( - node.inputNames[shiftedStart], tensorMap, context, resourceManager); - } - if (inputParam.type === 'tensors') { - // TODO(mattSoulanille): This filters out NoOp nodes during execution, but - // these should really never be in the execution graph in the first place. - // They're necessary for ordering the graph, but should not be visible - // during execution. Perhaps have different sets of children, one for - // control dependencies and another for real dependencies. - const inputs = node.inputs.slice(start, end); - const inputNames = node.inputNames.slice(start, end) - .filter((_name, index) => inputs[index]?.op !== 'NoOp'); - - return inputNames.map( - name => getTensor(name, tensorMap, context, resourceManager)); - } - const tensor = getTensor( - node.inputNames[shiftedStart], tensorMap, context, resourceManager); - const data = tensor.dataSync(); - return inputParam.type === 'number' ? - data[0] : - util.toNestedArray(tensor.shape, data); - } - const attrParam = node.attrParams[paramName]; - return attrParam && attrParam.value; -} - -/** - * Retrieve the tensor from tensorsMap based on input name. - * @param name Node input name - * @param tensorsMap Tensors map keyed by the node - * @param context contains tensors and information for running the current node. - * @param resourceManager Optional. Contains global resources of the model. - */ -export function getTensor( - name: string, tensorsMap: NamedTensorsMap, context: ExecutionContext, - resourceManager?: ResourceManager): Tensor { - const [nodeName, index] = parseNodeName(name, context); - - if (resourceManager != null) { - const tensor = resourceManager.getHashTableHandleByName(nodeName); - if (tensor != null) { - return tensor; - } - } - - const contextId = context.currentContextIds.find(contextId => { - return !!tensorsMap[getNodeNameWithContextId(nodeName, contextId)]; - }); - - return contextId !== undefined ? - tensorsMap[getNodeNameWithContextId(nodeName, contextId)][index] : - undefined; -} - -/** - * Retrieve the tensors based on input name for current context. - * @param name Node input name - * @param tensorsMap Tensors map keyed by the node - */ -export function getTensorsForCurrentContext( - name: string, tensorsMap: NamedTensorsMap, - context: ExecutionContext): Tensor[] { - return tensorsMap[getNodeNameWithContextId(name, context.currentContextId)]; -} - -/** - * Returns the node name, outputName and index from the Node input name. - * @param inputName The input name of the node, in format of - * node_name:output_index, i.e. MatMul:0, if the output_index is not set, it is - * default to 0. - * If the input name contains output name i.e. StringSplit:indices:0, it will - * return ['StringSplit', 0, 'indices']. - */ -export function getNodeNameAndIndex( - inputName: string, context?: ExecutionContext): [string, number, string] { - const [nodeName, index, outputName] = parseNodeName(inputName, context); - - return [ - getNodeNameWithContextId(nodeName, context && context.currentContextId), - index, outputName - ]; -} - -function getNodeNameWithContextId(name: string, contextId?: string): string { - return !!contextId ? `${name}-${contextId}` : name; -} - -export function parseNodeName( - name: string, context?: ExecutionContext): [string, number, string?] { - if (name === '') { - return ['', 0, undefined]; - } - - const isCacheEnabled = context != null && context.parseNodeNameCache != null; - if (isCacheEnabled) { - const cachedResult = context.parseNodeNameCache.get(name); - if (cachedResult != null) { - return cachedResult; - } - } - const parts = name.split(':'); - let result: [string, number, string?]; - if (parts.length === 1) { - result = [name, 0, undefined]; - } else { - const nodeName = parts[0]; - const outputName = parts.length === 3 ? parts[1] : undefined; - const index = Number(parts[parts.length - 1]); - result = [nodeName, index, outputName]; - } - if (isCacheEnabled) { - context.parseNodeNameCache.set(name, result); - } - return result; -} - -export function split(arr: number[], size: number) { - const res = []; - for (let i = 0; i < arr.length; i += size) { - res.push(arr.slice(i, i + size)); - } - return res; -} -export function getPadding( - node: Node, tensorMap: NamedTensorsMap, - context: ExecutionContext): ValueType { - let pad = getParamValue('pad', node, tensorMap, context); - if (pad === 'explicit') { - // This is 1d array, we need to convert it to 2d array - pad = getParamValue('explicitPaddings', node, tensorMap, context); - const explicitPadding: [ - [number, number], [number, number], [number, number], [number, number] - ] = [[0, 0], [0, 0], [0, 0], [0, 0]]; - for (let i = 0; i < 4; i++) { - explicitPadding[i][0] = (pad as number[])[i * 2]; - explicitPadding[i][1] = (pad as number[])[i * 2 + 1]; - } - return explicitPadding; - } - return pad; -} - -/** - * Reuse the tensor if it is marked as keep, otherwise clone the tensor to - * avoid disposal. This is important for TensorArray and TensorList ops, since - * internally they use a tensor as the id for TensorArray and TensorList, and - * to simplify lookup, they also use Tensor.id as the key to the internal map. - * These id tensors have been marked as kept in the backend, we need avoid clone - * them in order to create new Tensor.id. - * @param tensor - */ -export function cloneTensor(tensor: Tensor): Tensor { - return tensor.kept ? tensor : clone(tensor); -} diff --git a/tfjs-master/tfjs-converter/src/operations/op_mapper_schema.ts b/tfjs-master/tfjs-converter/src/operations/op_mapper_schema.ts deleted file mode 100644 index 1ec2ddd57..000000000 --- a/tfjs-master/tfjs-converter/src/operations/op_mapper_schema.ts +++ /dev/null @@ -1,99 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -export const json = { - '$schema': 'http://json-schema.org/draft-07/schema#', - 'definitions': { - 'OpMapper': { - 'type': 'object', - 'properties': { - 'tfOpName': {'type': 'string'}, - 'category': {'$ref': '#/definitions/Category'}, - 'inputs': { - 'type': 'array', - 'items': {'$ref': '#/definitions/InputParamMapper'} - }, - 'attrs': { - 'type': 'array', - 'items': {'$ref': '#/definitions/AttrParamMapper'} - }, - 'customExecutor': {'$ref': '#/definitions/OpExecutor'}, - 'outputs': {'type': 'array'} - }, - 'required': ['tfOpName'], - 'additionalProperties': false - }, - 'Category': { - 'type': 'string', - 'enum': [ - 'arithmetic', 'basic_math', 'control', 'convolution', - 'custom', 'dynamic', 'evaluation', 'image', - 'creation', 'graph', 'logical', 'matrices', - 'normalization', 'ragged', 'reduction', 'slice_join', - 'spectral', 'transformation', 'sparse', 'string' - ] - }, - 'InputParamMapper': { - 'type': 'object', - 'properties': { - 'name': {'type': 'string'}, - 'type': {'$ref': '#/definitions/ParamTypes'}, - 'defaultValue': { - 'anyOf': [ - {'type': 'string'}, {'type': 'array', 'items': {'type': 'string'}}, - {'type': 'number'}, {'type': 'array', 'items': {'type': 'number'}}, - {'type': 'boolean'}, {'type': 'array', 'items': {'type': 'boolean'}} - ] - }, - 'notSupported': {'type': 'boolean'}, - 'start': {'type': 'number'}, - 'end': {'type': 'number'} - }, - 'required': ['name', 'start', 'type'], - 'additionalProperties': false - }, - 'ParamTypes': { - 'type': 'string', - 'enum': [ - 'number', 'string', 'number[]', 'bool', 'shape', 'tensor', 'tensors', - 'dtype', 'string[]', 'func', 'dtype[]', 'bool[]' - ] - }, - 'AttrParamMapper': { - 'type': 'object', - 'properties': { - 'name': {'type': 'string'}, - 'type': {'$ref': '#/definitions/ParamTypes'}, - 'defaultValue': { - 'anyOf': [ - {'type': 'string'}, {'type': 'array', 'items': {'type': 'string'}}, - {'type': 'number'}, {'type': 'array', 'items': {'type': 'number'}}, - {'type': 'boolean'}, {'type': 'array', 'items': {'type': 'boolean'}} - ] - }, - 'notSupported': {'type': 'boolean'}, - 'tfName': {'type': 'string'}, - 'tfDeprecatedName': {'type': 'string'} - }, - 'required': ['name', 'tfName', 'type'], - 'additionalProperties': false - }, - 'OpExecutor': {'type': 'object', 'additionalProperties': false} - }, - 'items': {'$ref': '#/definitions/OpMapper'}, - 'type': 'array' -}; diff --git a/tfjs-master/tfjs-converter/src/operations/operation_executor.ts b/tfjs-master/tfjs-converter/src/operations/operation_executor.ts deleted file mode 100644 index 3a75d0343..000000000 --- a/tfjs-master/tfjs-converter/src/operations/operation_executor.ts +++ /dev/null @@ -1,124 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tfc from '@tensorflow/tfjs-core'; - -import {NamedTensorsMap} from '../data/types'; -import {ExecutionContext} from '../executor/execution_context'; -import {ResourceManager} from '../executor/resource_manager'; - -import {NodeValueImpl} from './custom_op/node_value_impl'; -import {getRegisteredOp} from './custom_op/register'; -import * as arithmetic from './executors/arithmetic_executor'; -import * as basicMath from './executors/basic_math_executor'; -import * as control from './executors/control_executor'; -import * as convolution from './executors/convolution_executor'; -import * as creation from './executors/creation_executor'; -import * as dynamic from './executors/dynamic_executor'; -import * as evaluation from './executors/evaluation_executor'; -import * as graph from './executors/graph_executor'; -import * as hashTable from './executors/hash_table_executor'; -import * as image from './executors/image_executor'; -import * as logical from './executors/logical_executor'; -import * as matrices from './executors/matrices_executor'; -import * as normalization from './executors/normalization_executor'; -import * as ragged from './executors/ragged_executor'; -import * as reduction from './executors/reduction_executor'; -import * as sliceJoin from './executors/slice_join_executor'; -import * as sparse from './executors/sparse_executor'; -import * as spectral from './executors/spectral_executor'; -import * as string from './executors/string_executor'; -import * as transformation from './executors/transformation_executor'; -import {Node} from './types'; - -/** - * Executes the op defined by the node object. - * @param node - * @param tensorMap contains tensors for executed nodes and weights - * @param context contains tensors and information for running the current node. - * @param resourceManager Optional. Contains global resources of the model. - */ -export function executeOp( - node: Node, tensorMap: NamedTensorsMap, context: ExecutionContext, - resourceManager?: ResourceManager, tidy = tfc.tidy): tfc.Tensor[]| - Promise { - const value = - ((node: Node, tensorMap: NamedTensorsMap, context: ExecutionContext) => { - switch (node.category) { - case 'arithmetic': - return tidy(() => arithmetic.executeOp(node, tensorMap, context)); - case 'basic_math': - return tidy(() => basicMath.executeOp(node, tensorMap, context)); - case 'control': - return control.executeOp(node, tensorMap, context); - case 'convolution': - return tidy(() => convolution.executeOp(node, tensorMap, context)); - case 'creation': - return tidy(() => creation.executeOp(node, tensorMap, context)); - case 'dynamic': - return dynamic.executeOp(node, tensorMap, context); - case 'evaluation': - return tidy(() => evaluation.executeOp(node, tensorMap, context)); - case 'image': - return tidy(() => image.executeOp(node, tensorMap, context)); - case 'graph': - return tidy(() => graph.executeOp(node, tensorMap, context)); - case 'logical': - return tidy(() => logical.executeOp(node, tensorMap, context)); - case 'matrices': - return tidy(() => matrices.executeOp(node, tensorMap, context)); - case 'normalization': - return tidy( - () => normalization.executeOp(node, tensorMap, context)); - case 'ragged': - return tidy(() => ragged.executeOp(node, tensorMap, context)); - case 'reduction': - return tidy(() => reduction.executeOp(node, tensorMap, context)); - case 'slice_join': - return tidy(() => sliceJoin.executeOp(node, tensorMap, context)); - case 'sparse': - return tidy(() => sparse.executeOp(node, tensorMap, context)); - case 'spectral': - return tidy(() => spectral.executeOp(node, tensorMap, context)); - case 'string': - return tidy(() => string.executeOp(node, tensorMap, context)); - case 'transformation': - return tidy( - () => transformation.executeOp(node, tensorMap, context)); - case 'hash_table': - return hashTable.executeOp( - node, tensorMap, context, resourceManager); - case 'custom': - const opMapper = getRegisteredOp(node.op); - if (opMapper && opMapper.customExecutor) { - return opMapper.customExecutor( - new NodeValueImpl(node, tensorMap, context)); - } else { - throw TypeError(`Custom op ${node.op} is not registered.`); - } - default: - throw TypeError( - `Unknown op '${node.op}'. File an issue at ` + - `https://github.com/tensorflow/tfjs/issues so we can add it` + - `, or register a custom execution with tf.registerOp()`); - } - })(node, tensorMap, context); - if (tfc.util.isPromise(value)) { - return value.then((data) => [].concat(data)); - } - return [].concat(value); -} diff --git a/tfjs-master/tfjs-converter/src/operations/operation_executor_test.ts b/tfjs-master/tfjs-converter/src/operations/operation_executor_test.ts deleted file mode 100644 index e9979bea1..000000000 --- a/tfjs-master/tfjs-converter/src/operations/operation_executor_test.ts +++ /dev/null @@ -1,138 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tfc from '@tensorflow/tfjs-core'; -import {add, mul, scalar, Tensor, test_util} from '@tensorflow/tfjs-core'; - -import {ExecutionContext} from '../executor/execution_context'; -import {ResourceManager} from '../executor/resource_manager'; - -import {deregisterOp, registerOp} from './custom_op/register'; -import * as arithmetic from './executors/arithmetic_executor'; -import * as basic_math from './executors/basic_math_executor'; -import * as control from './executors/control_executor'; -import * as convolution from './executors/convolution_executor'; -import * as creation from './executors/creation_executor'; -import * as dynamic from './executors/dynamic_executor'; -import * as evaluation from './executors/evaluation_executor'; -import * as graph from './executors/graph_executor'; -import * as hash_table from './executors/hash_table_executor'; -import * as image from './executors/image_executor'; -import * as logical from './executors/logical_executor'; -import * as matrices from './executors/matrices_executor'; -import * as normalization from './executors/normalization_executor'; -import * as reduction from './executors/reduction_executor'; -import * as slice_join from './executors/slice_join_executor'; -import * as sparse from './executors/sparse_executor'; -import * as spectral from './executors/spectral_executor'; -import * as string from './executors/string_executor'; -import * as transformation from './executors/transformation_executor'; -import {executeOp} from './operation_executor'; -import {Node} from './types'; - -describe('OperationExecutor', () => { - let node: Node; - const context = new ExecutionContext({}, {}, {}); - - beforeEach(() => { - node = { - name: 'test', - op: 'const', - category: 'graph', - inputNames: [], - inputs: [], - inputParams: {}, - attrParams: {}, - children: [] - }; - }); - - describe('executeOp', () => { - [arithmetic, basic_math, control, convolution, creation, dynamic, - evaluation, graph, image, logical, matrices, normalization, reduction, - slice_join, sparse, spectral, string, transformation] - .forEach(category => { - it('should call ' + category.CATEGORY + ' executor', () => { - spyOn(category, 'executeOp'); - node.category = category.CATEGORY; - executeOp(node, {}, context); - expect(category.executeOp).toHaveBeenCalledWith(node, {}, context); - }); - }); - [arithmetic, basic_math, convolution, creation, evaluation, graph, image, - logical, matrices, normalization, reduction, slice_join, sparse, spectral, - string, transformation] - .forEach(category => { - it('should call tidy around executor', () => { - const tidySpy = jasmine.createSpy('tidy spy', tfc.tidy); - - node.category = category.CATEGORY; - executeOp(node, {}, context, undefined, tidySpy as typeof tfc.tidy); - expect(tidySpy).toHaveBeenCalled(); - }); - }); - - it('hash_table executor should have been called.', () => { - const resourceManager = new ResourceManager(); - spyOn(hash_table, 'executeOp'); - node.category = hash_table.CATEGORY; - executeOp(node, {}, context, resourceManager); - expect(hash_table.executeOp) - .toHaveBeenCalledWith(node, {}, context, resourceManager); - }); - }); - - describe('custom op executeOp', () => { - it('should throw exception if custom op is not registered', () => { - node.category = 'custom'; - expect(() => executeOp(node, {}, context)) - .toThrowError('Custom op const is not registered.'); - }); - }); - - describe('custom op executeOp', () => { - it('should call the registered custom op', async () => { - registerOp('const', () => [scalar(1)]); - registerOp('const2', () => [scalar(2)]); - node.category = 'custom'; - const result = executeOp(node, {}, context) as Tensor[]; - test_util.expectArraysClose(await result[0].data(), [1]); - deregisterOp('const'); - deregisterOp('const2'); - }); - - it('should handle custom op with inputs and attrs', async () => { - registerOp('const', (node) => { - const a = node.inputs[0]; - const b = node.inputs[1]; - const attrC = node.attrs['c'] as Tensor; - const attrD = node.attrs['d'] as number; - return [add(mul(attrC.dataSync()[0], a), mul(attrD, b))]; - }); - - node.category = 'custom'; - node.inputNames = ['a', 'b']; - node.rawAttrs = {c: {tensor: {}}, d: {i: 3}}; - const result = executeOp( - node, {a: [scalar(1)], b: [scalar(2)], c: [scalar(2)]}, - context) as Tensor[]; - // result = 2 * 1 + 3 * 2 - test_util.expectArraysClose(await result[0].data(), [8]); - deregisterOp('const'); - }); - }); -}); diff --git a/tfjs-master/tfjs-converter/src/operations/operation_mapper.ts b/tfjs-master/tfjs-converter/src/operations/operation_mapper.ts deleted file mode 100644 index a0e2e0787..000000000 --- a/tfjs-master/tfjs-converter/src/operations/operation_mapper.ts +++ /dev/null @@ -1,607 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {DataType, env} from '@tensorflow/tfjs-core'; - -import * as tensorflow from '../data/compiled_api'; - -import {getRegisteredOp} from './custom_op/register'; -import {getNodeNameAndIndex} from './executors/utils'; -import * as arithmetic from './op_list/arithmetic'; -import * as basicMath from './op_list/basic_math'; -import * as control from './op_list/control'; -import * as convolution from './op_list/convolution'; -import * as creation from './op_list/creation'; -import * as dynamic from './op_list/dynamic'; -import * as evaluation from './op_list/evaluation'; -import * as graph from './op_list/graph'; -import * as hashTable from './op_list/hash_table'; -import * as image from './op_list/image'; -import * as logical from './op_list/logical'; -import * as matrices from './op_list/matrices'; -import * as normalization from './op_list/normalization'; -import * as reduction from './op_list/reduction'; -import * as sliceJoin from './op_list/slice_join'; -import * as sparse from './op_list/sparse'; -import * as spectral from './op_list/spectral'; -import * as string from './op_list/string'; -import * as transformation from './op_list/transformation'; -import {Graph, InputParamValue, Node, OpMapper, ParamValue} from './types'; - -export class OperationMapper { - private static _instance: OperationMapper; - - private opMappers: {[key: string]: OpMapper}; - - // Singleton instance for the mapper - public static get Instance() { - return this._instance || (this._instance = new this()); - } - - // Loads the op mapping from the JSON file. - private constructor() { - const ops = [ - arithmetic, basicMath, control, convolution, creation, dynamic, - evaluation, graph, hashTable, image, logical, matrices, normalization, - reduction, sliceJoin, sparse, spectral, string, transformation - ]; - const mappersJson: OpMapper[] = [].concat(...ops.map(op => op.json)); - - this.opMappers = mappersJson.reduce<{[key: string]: OpMapper}>( - (map, mapper: OpMapper) => { - map[mapper.tfOpName] = mapper; - return map; - }, - {}); - } - - // Converts the model inference graph from Tensorflow GraphDef to local - // representation for TensorFlow.js API - transformGraph( - graph: tensorflow.IGraphDef, - signature: tensorflow.ISignatureDef = {}): Graph { - const tfNodes = graph.node; - const placeholders: Node[] = []; - const weights: Node[] = []; - const initNodes: Node[] = []; - const nodes = tfNodes.reduce<{[key: string]: Node}>((map, node) => { - map[node.name] = this.mapNode(node); - if (node.op.startsWith('Placeholder')) { - placeholders.push(map[node.name]); - } else if (node.op === 'Const') { - weights.push(map[node.name]); - } else if (node.input == null || node.input.length === 0) { - initNodes.push(map[node.name]); - } - return map; - }, {}); - - let inputs: Node[] = []; - const outputs: Node[] = []; - let inputNodeNameToKey: {[key: string]: string} = {}; - let outputNodeNameToKey: {[key: string]: string} = {}; - if (signature != null) { - inputNodeNameToKey = this.mapSignatureEntries(signature.inputs); - outputNodeNameToKey = this.mapSignatureEntries(signature.outputs); - } - const allNodes = Object.keys(nodes); - allNodes.forEach(key => { - const node = nodes[key]; - node.inputNames.forEach((name, index) => { - const [nodeName, , outputName] = getNodeNameAndIndex(name); - const inputNode = nodes[nodeName]; - if (inputNode.outputs != null) { - const outputIndex = inputNode.outputs.indexOf(outputName); - if (outputIndex !== -1) { - const inputName = `${nodeName}:${outputIndex}`; - // update the input name to use the mapped output index directly. - node.inputNames[index] = inputName; - } - } - node.inputs.push(inputNode); - inputNode.children.push(node); - }); - }); - - // if signature has not outputs set, add any node that does not have - // outputs. - if (Object.keys(outputNodeNameToKey).length === 0) { - allNodes.forEach(key => { - const node = nodes[key]; - if (node.children.length === 0) { - outputs.push(node); - } - }); - } else { - Object.keys(outputNodeNameToKey).forEach(name => { - const [nodeName, ] = getNodeNameAndIndex(name); - const node = nodes[nodeName]; - if (node != null) { - node.signatureKey = outputNodeNameToKey[name]; - outputs.push(node); - } - }); - } - - if (Object.keys(inputNodeNameToKey).length > 0) { - Object.keys(inputNodeNameToKey).forEach(name => { - const [nodeName, ] = getNodeNameAndIndex(name); - const node = nodes[nodeName]; - if (node) { - node.signatureKey = inputNodeNameToKey[name]; - inputs.push(node); - } - }); - } else { - inputs = placeholders; - } - - let functions = {}; - if (graph.library != null && graph.library.function != null) { - functions = graph.library.function.reduce((functions, func) => { - functions[func.signature.name] = this.mapFunction(func); - return functions; - }, {} as {[key: string]: Graph}); - } - - const result: Graph = - {nodes, inputs, outputs, weights, placeholders, signature, functions}; - - if (initNodes.length > 0) { - result.initNodes = initNodes; - } - - return result; - } - - private mapSignatureEntries(entries: {[k: string]: tensorflow.ITensorInfo}) { - return Object.keys(entries || {}) - .reduce<{[key: string]: string}>((prev, curr) => { - prev[entries[curr].name] = curr; - return prev; - }, {}); - } - - private mapNode(node: tensorflow.INodeDef): Node { - // Unsupported ops will cause an error at run-time (not parse time), since - // they may not be used by the actual execution subgraph. - const mapper = - getRegisteredOp(node.op) || this.opMappers[node.op] || {} as OpMapper; - if (node.attr == null) { - node.attr = {}; - } - - const newNode: Node = { - name: node.name, - op: node.op, - category: mapper.category, - inputNames: - (node.input || - []).map(input => input.startsWith('^') ? input.slice(1) : input), - inputs: [], - children: [], - inputParams: {}, - attrParams: {}, - rawAttrs: node.attr, - outputs: mapper.outputs - }; - - if (mapper.inputs != null) { - newNode.inputParams = - mapper.inputs.reduce<{[key: string]: InputParamValue}>( - (map, param) => { - map[param.name] = { - type: param.type, - inputIndexStart: param.start, - inputIndexEnd: param.end - }; - return map; - }, - {}); - } - if (mapper.attrs != null) { - newNode.attrParams = - mapper.attrs.reduce<{[key: string]: ParamValue}>((map, param) => { - const type = param.type; - let value = undefined; - switch (param.type) { - case 'string': - value = getStringParam( - node.attr, param.tfName, param.defaultValue as string); - - if (value === undefined && !!param.tfDeprecatedName) { - value = getStringParam( - node.attr, param.tfDeprecatedName, - param.defaultValue as string); - } - break; - case 'string[]': - value = getStringArrayParam( - node.attr, param.tfName, param.defaultValue as string[]); - - if (value === undefined && !!param.tfDeprecatedName) { - value = getStringArrayParam( - node.attr, param.tfDeprecatedName, - param.defaultValue as string[]); - } - break; - case 'number': - value = getNumberParam( - node.attr, param.tfName, - (param.defaultValue || 0) as number); - if (value === undefined && !!param.tfDeprecatedName) { - value = getNumberParam( - node.attr, param.tfDeprecatedName, - param.defaultValue as number); - } - break; - case 'number[]': - value = getNumericArrayParam( - node.attr, param.tfName, param.defaultValue as number[]); - if (value === undefined && !!param.tfDeprecatedName) { - value = getNumericArrayParam( - node.attr, param.tfDeprecatedName, - param.defaultValue as number[]); - } - break; - case 'bool': - value = getBoolParam( - node.attr, param.tfName, param.defaultValue as boolean); - if (value === undefined && !!param.tfDeprecatedName) { - value = getBoolParam( - node.attr, param.tfDeprecatedName, - param.defaultValue as boolean); - } - break; - case 'bool[]': - value = getBoolArrayParam( - node.attr, param.tfName, param.defaultValue as boolean[]); - if (value === undefined && !!param.tfDeprecatedName) { - value = getBoolArrayParam( - node.attr, param.tfDeprecatedName, - param.defaultValue as boolean[]); - } - break; - case 'shape': - value = getTensorShapeParam( - node.attr, param.tfName, param.defaultValue as number[]); - if (value === undefined && !!param.tfDeprecatedName) { - value = getTensorShapeParam( - node.attr, param.tfDeprecatedName, - param.defaultValue as number[]); - } - break; - case 'shape[]': - value = getTensorShapeArrayParam( - node.attr, param.tfName, param.defaultValue as number[][]); - if (value === undefined && !!param.tfDeprecatedName) { - value = getTensorShapeArrayParam( - node.attr, param.tfDeprecatedName, - param.defaultValue as number[][]); - } - break; - case 'dtype': - value = getDtypeParam( - node.attr, param.tfName, param.defaultValue as DataType); - if (value === undefined && !!param.tfDeprecatedName) { - value = getDtypeParam( - node.attr, param.tfDeprecatedName, - param.defaultValue as DataType); - } - break; - case 'dtype[]': - value = getDtypeArrayParam( - node.attr, param.tfName, param.defaultValue as DataType[]); - if (value === undefined && !!param.tfDeprecatedName) { - value = getDtypeArrayParam( - node.attr, param.tfDeprecatedName, - param.defaultValue as DataType[]); - } - break; - case 'func': - value = getFuncParam( - node.attr, param.tfName, param.defaultValue as string); - if (value === undefined && !!param.tfDeprecatedName) { - value = getFuncParam( - node.attr, param.tfDeprecatedName, - param.defaultValue as string); - } - break; - case 'tensor': - case 'tensors': - break; - default: - throw new Error( - `Unsupported param type: ${param.type} for op: ${node.op}`); - } - map[param.name] = {value, type}; - return map; - }, {}); - } - return newNode; - } - - // map the TFunctionDef to TFJS graph object - private mapFunction(functionDef: tensorflow.IFunctionDef): Graph { - const tfNodes = functionDef.nodeDef; - const placeholders: Node[] = []; - const weights: Node[] = []; - let nodes: {[key: string]: Node} = {}; - if (tfNodes != null) { - nodes = tfNodes.reduce<{[key: string]: Node}>((map, node) => { - map[node.name] = this.mapNode(node); - if (node.op === 'Const') { - weights.push(map[node.name]); - } - return map; - }, {}); - } - const inputs: Node[] = []; - const outputs: Node[] = []; - - functionDef.signature.inputArg.forEach(arg => { - const [nodeName, ] = getNodeNameAndIndex(arg.name); - const node: Node = { - name: nodeName, - op: 'Placeholder', - inputs: [], - inputNames: [], - category: 'graph', - inputParams: {}, - attrParams: {dtype: {value: parseDtypeParam(arg.type), type: 'dtype'}}, - children: [] - }; - node.signatureKey = arg.name; - inputs.push(node); - nodes[nodeName] = node; - }); - - const allNodes = Object.keys(nodes); - allNodes.forEach(key => { - const node = nodes[key]; - node.inputNames.forEach((name, index) => { - const [nodeName, , outputName] = getNodeNameAndIndex(name); - const inputNode = nodes[nodeName]; - if (inputNode.outputs != null) { - const outputIndex = inputNode.outputs.indexOf(outputName); - if (outputIndex !== -1) { - const inputName = `${nodeName}:${outputIndex}`; - // update the input name to use the mapped output index directly. - node.inputNames[index] = inputName; - } - } - node.inputs.push(inputNode); - inputNode.children.push(node); - }); - }); - - const returnNodeMap = functionDef.ret; - - functionDef.signature.outputArg.forEach(output => { - const [nodeName, index] = getNodeNameAndIndex(returnNodeMap[output.name]); - const node = nodes[nodeName]; - if (node != null) { - node.defaultOutput = index; - outputs.push(node); - } - }); - - const signature = this.mapArgsToSignature(functionDef); - return {nodes, inputs, outputs, weights, placeholders, signature}; - } - - private mapArgsToSignature(functionDef: tensorflow.IFunctionDef): - tensorflow.ISignatureDef { - return { - methodName: functionDef.signature.name, - inputs: functionDef.signature.inputArg.reduce( - (map, arg) => { - map[arg.name] = this.mapArgToTensorInfo(arg); - return map; - }, - {} as {[key: string]: tensorflow.ITensorInfo}), - outputs: functionDef.signature.outputArg.reduce( - (map, arg) => { - map[arg.name] = this.mapArgToTensorInfo(arg, functionDef.ret); - return map; - }, - {} as {[key: string]: tensorflow.ITensorInfo}), - }; - } - - private mapArgToTensorInfo( - arg: tensorflow.OpDef.IArgDef, - nameMap?: {[key: string]: string}): tensorflow.ITensorInfo { - let name = arg.name; - if (nameMap != null) { - name = nameMap[name]; - } - return {name, dtype: arg.type}; - } -} - -export function decodeBase64(text: string): string { - const global = env().global; - if (typeof global.atob !== 'undefined') { - return global.atob(text); - } else if (typeof Buffer !== 'undefined') { - return new Buffer(text, 'base64').toString(); - } else { - throw new Error( - 'Unable to decode base64 in this environment. ' + - 'Missing built-in atob() or Buffer()'); - } -} - -export function parseStringParam(s: []|string, keepCase: boolean): string { - const value = - Array.isArray(s) ? String.fromCharCode.apply(null, s) : decodeBase64(s); - return keepCase ? value : value.toLowerCase(); -} - -export function getStringParam( - attrs: {[key: string]: tensorflow.IAttrValue}, name: string, def: string, - keepCase = false): string { - const param = attrs[name]; - if (param != null) { - return parseStringParam(param.s, keepCase); - } - return def; -} - -export function getBoolParam( - attrs: {[key: string]: tensorflow.IAttrValue}, name: string, - def: boolean): boolean { - const param = attrs[name]; - return param ? param.b : def; -} - -export function getNumberParam( - attrs: {[key: string]: tensorflow.IAttrValue}, name: string, - def: number): number { - const param = attrs[name] || {}; - const value = - param['i'] != null ? param['i'] : (param['f'] != null ? param['f'] : def); - return (typeof value === 'number') ? value : parseInt(value, 10); -} - -export function parseDtypeParam(value: string|tensorflow.DataType): DataType { - if (typeof (value) === 'string') { - // tslint:disable-next-line:no-any - value = tensorflow.DataType[value as any]; - } - switch (value) { - case tensorflow.DataType.DT_FLOAT: - case tensorflow.DataType.DT_HALF: - return 'float32'; - case tensorflow.DataType.DT_INT32: - case tensorflow.DataType.DT_INT64: - case tensorflow.DataType.DT_INT8: - case tensorflow.DataType.DT_UINT8: - return 'int32'; - case tensorflow.DataType.DT_BOOL: - return 'bool'; - case tensorflow.DataType.DT_DOUBLE: - return 'float32'; - case tensorflow.DataType.DT_STRING: - return 'string'; - default: - // Unknown dtype error will happen at runtime (instead of parse time), - // since these nodes might not be used by the actual subgraph execution. - return null; - } -} - -export function getFuncParam( - attrs: {[key: string]: tensorflow.IAttrValue}, name: string, - def: string): string { - const param = attrs[name]; - if (param && param.func) { - return param.func.name; - } - return def; -} - -export function getDtypeParam( - attrs: {[key: string]: tensorflow.IAttrValue}, name: string, - def: DataType): DataType { - const param = attrs[name]; - if (param && param.type) { - return parseDtypeParam(param.type); - } - return def; -} - -export function getDtypeArrayParam( - attrs: {[key: string]: tensorflow.IAttrValue}, name: string, - def: DataType[]): DataType[] { - const param = attrs[name]; - if (param && param.list && param.list.type) { - return param.list.type.map(v => parseDtypeParam(v)); - } - return def; -} - -export function parseTensorShapeParam(shape: tensorflow.ITensorShape): number[]| - undefined { - if (shape.unknownRank) { - return undefined; - } - if (shape.dim != null) { - return shape.dim.map( - dim => - (typeof dim.size === 'number') ? dim.size : parseInt(dim.size, 10)); - } - return []; -} - -export function getTensorShapeParam( - attrs: {[key: string]: tensorflow.IAttrValue}, name: string, - def?: number[]): number[]|undefined { - const param = attrs[name]; - if (param && param.shape) { - return parseTensorShapeParam(param.shape); - } - return def; -} - -export function getNumericArrayParam( - attrs: {[key: string]: tensorflow.IAttrValue}, name: string, - def: number[]): number[] { - const param = attrs[name]; - if (param) { - return ((param.list.f && param.list.f.length ? param.list.f : - param.list.i) || - []) - .map(v => (typeof v === 'number') ? v : parseInt(v, 10)); - } - return def; -} - -export function getStringArrayParam( - attrs: {[key: string]: tensorflow.IAttrValue}, name: string, def: string[], - keepCase = false): string[] { - const param = attrs[name]; - if (param && param.list && param.list.s) { - return param.list.s.map((v) => { - return parseStringParam(v, keepCase); - }); - } - return def; -} - -export function getTensorShapeArrayParam( - attrs: {[key: string]: tensorflow.IAttrValue}, name: string, - def: number[][]): number[][] { - const param = attrs[name]; - if (param && param.list && param.list.shape) { - return param.list.shape.map((v) => { - return parseTensorShapeParam(v); - }); - } - return def; -} - -export function getBoolArrayParam( - attrs: {[key: string]: tensorflow.IAttrValue}, name: string, - def: boolean[]): boolean[] { - const param = attrs[name]; - if (param && param.list && param.list.b) { - return param.list.b; - } - return def; -} diff --git a/tfjs-master/tfjs-converter/src/operations/operation_mapper_test.ts b/tfjs-master/tfjs-converter/src/operations/operation_mapper_test.ts deleted file mode 100644 index 522d95382..000000000 --- a/tfjs-master/tfjs-converter/src/operations/operation_mapper_test.ts +++ /dev/null @@ -1,557 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tensorflow from '../data/compiled_api'; - -import * as arithmetic from './op_list/arithmetic'; -import * as basicMath from './op_list/basic_math'; -import * as control from './op_list/control'; -import * as convolution from './op_list/convolution'; -import * as creation from './op_list/creation'; -import * as dynamic from './op_list/dynamic'; -import * as evaluation from './op_list/evaluation'; -import * as graph from './op_list/graph'; -import * as hashTable from './op_list/hash_table'; -import * as image from './op_list/image'; -import * as logical from './op_list/logical'; -import * as matrices from './op_list/matrices'; -import * as normalization from './op_list/normalization'; -import * as reduction from './op_list/reduction'; -import * as sliceJoin from './op_list/slice_join'; -import * as sparse from './op_list/sparse'; -import * as spectral from './op_list/spectral'; -import * as string from './op_list/string'; -import * as transformation from './op_list/transformation'; -import {OperationMapper} from './operation_mapper'; -import {Graph} from './types'; - -const ops = [ - arithmetic, basicMath, control, convolution, creation, dynamic, evaluation, - graph, hashTable, image, logical, matrices, normalization, reduction, - sliceJoin, sparse, spectral, string, transformation -]; -const mapper: OperationMapper = OperationMapper.Instance; -let convertedGraph: Graph; - -const SIMPLE_MODEL: tensorflow.IGraphDef = { - node: [ - { - name: 'image_placeholder', - op: 'Placeholder', - attr: { - dtype: { - type: tensorflow.DataType.DT_FLOAT, - }, - shape: {shape: {dim: [{size: '3'}, {size: 3}, {size: '3'}, {size: 1}]}} - } - }, - { - name: 'Const', - op: 'Const', - attr: { - dtype: {type: tensorflow.DataType.DT_INT32}, - value: { - tensor: { - dtype: tensorflow.DataType.DT_INT32, - tensorShape: {dim: [{size: 3}, {size: 3}, {size: 1}, {size: 1}]}, - intVal: [0, 0, 0, 0, 1, 0, 0, 0, 0] - } - } - } - }, - { - name: 'Shape', - op: 'Const', - attr: { - dtype: {type: tensorflow.DataType.DT_INT32}, - value: { - tensor: { - dtype: tensorflow.DataType.DT_INT32, - tensorShape: {dim: [{size: 3}, {size: 1}, {size: 1}, {size: 1}]}, - intVal: [1, 1, 1] - } - } - } - }, - { - name: 'Value', - op: 'Const', - attr: {dtype: {type: tensorflow.DataType.DT_INT32}, value: {i: 1}} - }, - {name: 'Fill', op: 'Fill', input: ['Shape', 'Value'], attr: {}}, - { - name: 'Conv2D', - op: 'Conv2D', - input: ['image_placeholder', 'Const'], - attr: { - T: {type: tensorflow.DataType.DT_FLOAT}, - dataFormat: {s: 'TkhXQw=='}, - padding: {s: 'U0FNRQ=='}, - strides: {list: {f: [], i: [1, 2, 2, 1]}}, - useCudnnOnGpu: {b: true} - } - }, - { - name: 'BiasAdd', - op: 'BiasAdd', - input: ['Conv2D', 'Shape'], - attr: - {T: {type: tensorflow.DataType.DT_FLOAT}, dataFormat: {s: 'TkhXQw=='}} - }, - { - name: 'Cast', - op: 'Cast', - input: ['BiasAdd'], - attr: {DstT: {type: tensorflow.DataType.DT_INT64}} - }, - { - name: 'Squeeze', - op: 'Squeeze', - input: ['Cast'], - attr: {squeeze_dims: {list: {i: ['1', '2']}}} - }, - { - name: 'Squeeze2', - op: 'Squeeze', - input: ['BiasAdd'], - attr: {squeeze_dims: {list: {}}} - }, - { - name: 'Split', - op: 'Split', - input: ['image_placeholder'], - attr: {num_split: {i: 3} as tensorflow.IAttrValue} - }, - {name: 'LogicalNot', op: 'LogicalNot', input: ['image_placeholder']}, - { - name: 'FusedBatchNorm', - op: 'FusedBatchNorm', - input: ['image_placeholder'], - attr: {epsilon: {f: 0.0001} as tensorflow.IAttrValue} - }, - { - name: 'Cast2', - op: 'Cast', - input: ['BiasAdd'], - attr: {DstT: {type: tensorflow.DataType.DT_UINT8}} - }, - { - name: 'Cast3', - op: 'Cast', - input: ['BiasAdd'], - attr: {DstT: {type: tensorflow.DataType.DT_HALF}} - }, - ], - library: { - function: [ - { - signature: { - name: '__inference_while_cond_10_49_frozen', - inputArg: [ - {name: 'while_loop_counter', type: tensorflow.DataType.DT_INT32}, { - name: 'while_maximum_iterations', - type: tensorflow.DataType.DT_INT32 - }, - {name: 'placeholder', type: tensorflow.DataType.DT_INT32}, - {name: 'less_y', type: tensorflow.DataType.DT_INT32}, { - name: 'while_cond_10___redundant_placeholder0', - type: tensorflow.DataType.DT_INT32 - } - ], - outputArg: [{name: 'identity', type: tensorflow.DataType.DT_BOOL}] - }, - nodeDef: [{ - name: 'Less', - op: 'Less', - input: ['placeholder', 'less_y'], - attr: {T: {type: tensorflow.DataType.DT_INT32}} - }], - ret: {identity: 'Less:z:0'} - }, - { - signature: { - name: '__inference_while_body_11_40_frozen', - inputArg: [ - {name: 'while_loop_counter', type: tensorflow.DataType.DT_INT32}, { - name: 'while_maximum_iterations', - type: tensorflow.DataType.DT_INT32 - }, - {name: 'placeholder', type: tensorflow.DataType.DT_INT32}, - {name: 'y_0', type: tensorflow.DataType.DT_INT32}, - {name: 'add_1_z_0', type: tensorflow.DataType.DT_INT32} - ], - outputArg: [ - {name: 'identity', type: tensorflow.DataType.DT_INT32}, - {name: 'identity_1', type: tensorflow.DataType.DT_INT32}, - {name: 'identity_2', type: tensorflow.DataType.DT_INT32}, - {name: 'y', type: tensorflow.DataType.DT_INT32}, - {name: 'add_1_z', type: tensorflow.DataType.DT_INT32} - ] - }, - nodeDef: [ - { - name: 'add_2/y', - op: 'Const', - attr: { - dtype: {type: tensorflow.DataType.DT_INT32}, - value: { - tensor: { - dtype: tensorflow.DataType.DT_INT32, - tensorShape: {}, - intVal: [1] - } - } - } - }, - { - name: 'add', - op: 'AddV2', - input: ['placeholder', 'y_0'], - attr: {T: {type: tensorflow.DataType.DT_INT32}} - }, - { - name: 'add_2', - op: 'AddV2', - input: ['add_2/y:output:0', 'while_loop_counter'], - attr: {T: {type: tensorflow.DataType.DT_INT32}} - }, - { - name: 'add_1', - op: 'AddV2', - input: ['add:z:0', 'add_1_z_0'], - attr: {T: {type: tensorflow.DataType.DT_INT32}} - } - ], - ret: { - identity_1: 'while_maximum_iterations', - identity_2: 'add_1:z:0', - y: 'y_0', - identity: 'add_2:z:0', - add_1_z: 'add_1_z_0' - } - } - ] - }, - versions: {producer: 1.0} -}; - -const SIGNATURE: tensorflow.ISignatureDef = { - inputs: { - image: { - name: 'image_placeholder', - dtype: tensorflow.DataType.DT_INT32, - tensorShape: { - - } - } - }, - outputs: { - squeeze: - {name: 'Squeeze', dtype: tensorflow.DataType.DT_FLOAT, tensorShape: {}} - } -}; - -describe('completeness check', () => { - it('should convert all op categories', () => { - ops.forEach(op => { - op.json.forEach(tfOp => { - const graph = { - node: [{name: tfOp.tfOpName, op: tfOp.tfOpName, attr: {}}] - }; - convertedGraph = mapper.transformGraph(graph); - expect(Object.keys(convertedGraph.nodes)).toEqual([tfOp.tfOpName]); - const node = convertedGraph.nodes[tfOp.tfOpName]; - expect(node.op).toEqual(tfOp.tfOpName); - expect(node.category).withContext(`Op: ${node.op}, category`) - .toEqual(tfOp.category); - }); - }); - }); - it('should convert op with outputs field', () => { - const name = 'string split'; - const op = 'StringSplit'; - const graph = {node: [{name, op: 'StringSplit', attr: {}}]}; - convertedGraph = mapper.transformGraph(graph); - expect(Object.keys(convertedGraph.nodes)).toEqual([name]); - expect(convertedGraph.nodes[name].op).toEqual(op); - expect(convertedGraph.nodes[name].outputs).toEqual([ - 'indices', 'values', 'shape' - ]); - }); -}); -describe('operationMapper without signature', () => { - beforeEach(() => { - convertedGraph = mapper.transformGraph(SIMPLE_MODEL); - }); - afterEach(() => {}); - - describe('transform graph', () => { - describe('graph level', () => { - it('should find the graph input nodes', () => { - expect(convertedGraph.inputs.map(node => node.name)).toEqual([ - 'image_placeholder' - ]); - }); - - it('should find the graph output nodes', () => { - expect(convertedGraph.outputs.map(node => node.name)).toEqual([ - 'Fill', 'Squeeze', 'Squeeze2', 'Split', 'LogicalNot', - 'FusedBatchNorm', 'Cast2', 'Cast3' - ]); - }); - - it('should find the graph weight nodes', () => { - expect(convertedGraph.weights.map(node => node.name)).toEqual([ - 'Const', 'Shape', 'Value' - ]); - }); - - it('should convert nodes', () => { - expect(Object.keys(convertedGraph.nodes)).toEqual([ - 'image_placeholder', 'Const', 'Shape', 'Value', 'Fill', 'Conv2D', - 'BiasAdd', 'Cast', 'Squeeze', 'Squeeze2', 'Split', 'LogicalNot', - 'FusedBatchNorm', 'Cast2', 'Cast3' - ]); - }); - }); - - describe('function level', () => { - it('should convert the functions', () => { - expect(Object.keys(convertedGraph.functions)).toEqual([ - '__inference_while_cond_10_49_frozen', - '__inference_while_body_11_40_frozen' - ]); - }); - it('should find the graph input nodes', () => { - expect(convertedGraph.functions['__inference_while_cond_10_49_frozen'] - .inputs.map(node => node.name)) - .toEqual([ - 'while_loop_counter', 'while_maximum_iterations', 'placeholder', - 'less_y', 'while_cond_10___redundant_placeholder0' - ]); - }); - - it('should find the graph output nodes', () => { - expect(convertedGraph.functions['__inference_while_cond_10_49_frozen'] - .outputs.map(node => node.name)) - .toEqual(['Less']); - }); - - it('should find the graph weight nodes', () => { - expect(convertedGraph.functions['__inference_while_cond_10_49_frozen'] - .weights.map(node => node.name)) - .toEqual([]); - }); - - it('should convert nodes', () => { - expect(Object.keys(convertedGraph - .functions['__inference_while_cond_10_49_frozen'] - .nodes)) - .toEqual([ - 'Less', 'while_loop_counter', 'while_maximum_iterations', - 'placeholder', 'less_y', 'while_cond_10___redundant_placeholder0' - ]); - }); - it('should convert signature', () => { - expect(convertedGraph.functions['__inference_while_cond_10_49_frozen'] - .signature) - .toEqual({ - methodName: '__inference_while_cond_10_49_frozen', - inputs: { - while_loop_counter: { - name: 'while_loop_counter', - dtype: tensorflow.DataType.DT_INT32 - }, - while_maximum_iterations: { - name: 'while_maximum_iterations', - dtype: tensorflow.DataType.DT_INT32 - }, - placeholder: - {name: 'placeholder', dtype: tensorflow.DataType.DT_INT32}, - less_y: {name: 'less_y', dtype: tensorflow.DataType.DT_INT32}, - while_cond_10___redundant_placeholder0: { - name: 'while_cond_10___redundant_placeholder0', - dtype: tensorflow.DataType.DT_INT32 - } - }, - outputs: { - identity: {name: 'Less:z:0', dtype: tensorflow.DataType.DT_BOOL} - } - }); - }); - }); - describe('node level', () => { - it('should find the input nodes', () => { - expect(convertedGraph.nodes['Fill'].inputs.map(node => node.name)) - .toEqual(['Shape', 'Value']); - }); - it('should find the children nodes', () => { - expect(convertedGraph.nodes['image_placeholder'].children.map( - node => node.name)) - .toEqual(['Conv2D', 'Split', 'LogicalNot', 'FusedBatchNorm']); - }); - - it('should map the input params', () => { - expect( - convertedGraph.nodes['Fill'].inputParams['shape'].inputIndexStart) - .toEqual(0); - expect( - convertedGraph.nodes['Fill'].inputParams['value'].inputIndexStart) - .toEqual(1); - }); - - it('should map the attribute params', () => { - expect(convertedGraph.nodes['Conv2D'].attrParams['strides'].value) - .toEqual([1, 2, 2, 1]); - expect(convertedGraph.nodes['Conv2D'].attrParams['pad'].value) - .toEqual('same'); - expect(convertedGraph.nodes['Conv2D'].attrParams['useCudnnOnGpu'].value) - .toEqual(true); - expect( - convertedGraph.nodes['Split'].attrParams['numOrSizeSplits'].value) - .toEqual(3); - expect( - convertedGraph.nodes['FusedBatchNorm'].attrParams['epsilon'].value) - .toEqual(0.0001); - expect(convertedGraph.nodes['Squeeze2'].attrParams['axis'].value) - .toEqual([]); - }); - - it('should map the placeholder attribute params', () => { - expect( - convertedGraph.nodes['image_placeholder'].attrParams['shape'].value) - .toEqual([3, 3, 3, 1]); - expect( - convertedGraph.nodes['image_placeholder'].attrParams['dtype'].value) - .toEqual('float32'); - }); - it('should map params with deprecated name', () => { - expect(convertedGraph.nodes['Squeeze'].attrParams['axis'].value) - .toEqual([1, 2]); - }); - it('should map params with int64 dtype', () => { - expect(convertedGraph.nodes['Cast'].attrParams['dtype'].value) - .toEqual('int32'); - }); - }); - }); -}); -describe('operationMapper with signature', () => { - beforeEach(() => { - convertedGraph = mapper.transformGraph(SIMPLE_MODEL, SIGNATURE); - }); - afterEach(() => {}); - - describe('transform graph', () => { - describe('graph level', () => { - it('should find the graph input nodes', () => { - expect(convertedGraph.inputs.map(node => node.name)).toEqual([ - 'image_placeholder' - ]); - expect(convertedGraph.inputs.map(node => node.signatureKey)).toEqual([ - 'image' - ]); - }); - - it('should find the graph output nodes', () => { - expect(convertedGraph.outputs.map(node => node.name)).toEqual([ - 'Squeeze' - ]); - expect(convertedGraph.outputs.map(node => node.signatureKey)).toEqual([ - 'squeeze' - ]); - }); - - it('should find the graph weight nodes', () => { - expect(convertedGraph.weights.map(node => node.name)).toEqual([ - 'Const', 'Shape', 'Value' - ]); - }); - - it('should convert nodes', () => { - expect(Object.keys(convertedGraph.nodes)).toEqual([ - 'image_placeholder', 'Const', 'Shape', 'Value', 'Fill', 'Conv2D', - 'BiasAdd', 'Cast', 'Squeeze', 'Squeeze2', 'Split', 'LogicalNot', - 'FusedBatchNorm', 'Cast2', 'Cast3' - ]); - }); - }); - - describe('node level', () => { - it('should find the input nodes', () => { - expect(convertedGraph.nodes['Fill'].inputs.map(node => node.name)) - .toEqual(['Shape', 'Value']); - }); - it('should find the children nodes', () => { - expect(convertedGraph.nodes['image_placeholder'].children.map( - node => node.name)) - .toEqual(['Conv2D', 'Split', 'LogicalNot', 'FusedBatchNorm']); - }); - - it('should map the input params', () => { - expect( - convertedGraph.nodes['Fill'].inputParams['shape'].inputIndexStart) - .toEqual(0); - expect( - convertedGraph.nodes['Fill'].inputParams['value'].inputIndexStart) - .toEqual(1); - }); - - it('should map the attribute params', () => { - expect(convertedGraph.nodes['Conv2D'].attrParams['strides'].value) - .toEqual([1, 2, 2, 1]); - expect(convertedGraph.nodes['Conv2D'].attrParams['pad'].value) - .toEqual('same'); - expect(convertedGraph.nodes['Conv2D'].attrParams['useCudnnOnGpu'].value) - .toEqual(true); - expect( - convertedGraph.nodes['Split'].attrParams['numOrSizeSplits'].value) - .toEqual(3); - expect( - convertedGraph.nodes['FusedBatchNorm'].attrParams['epsilon'].value) - .toEqual(0.0001); - expect(convertedGraph.nodes['Squeeze2'].attrParams['axis'].value) - .toEqual([]); - }); - - it('should map the placeholder attribute params', () => { - expect( - convertedGraph.nodes['image_placeholder'].attrParams['shape'].value) - .toEqual([3, 3, 3, 1]); - expect( - convertedGraph.nodes['image_placeholder'].attrParams['dtype'].value) - .toEqual('float32'); - }); - it('should map params with deprecated name', () => { - expect(convertedGraph.nodes['Squeeze'].attrParams['axis'].value) - .toEqual([1, 2]); - }); - it('should map params with int64 dtype', () => { - expect(convertedGraph.nodes['Cast'].attrParams['dtype'].value) - .toEqual('int32'); - }); - it('should map params with uint8 dtype', () => { - expect(convertedGraph.nodes['Cast2'].attrParams['dtype'].value) - .toEqual('int32'); - }); - it('should map params with half dtype', () => { - expect(convertedGraph.nodes['Cast3'].attrParams['dtype'].value) - .toEqual('float32'); - }); - }); - }); -}); diff --git a/tfjs-master/tfjs-converter/src/operations/types.ts b/tfjs-master/tfjs-converter/src/operations/types.ts deleted file mode 100644 index 4510edccc..000000000 --- a/tfjs-master/tfjs-converter/src/operations/types.ts +++ /dev/null @@ -1,143 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {Tensor} from '@tensorflow/tfjs-core'; -// tslint:disable-next-line:no-imports-from-dist -import * as tfOps from '@tensorflow/tfjs-core/dist/ops/ops_for_converter'; - -import * as tensorflow from '../data/compiled_api'; -import {NamedTensorsMap} from '../data/types'; -import {ExecutionContext} from '../executor/execution_context'; -import {ResourceManager} from '../executor/resource_manager'; - -export type ParamType = 'number'|'string'|'string[]'|'number[]'|'bool'|'bool[]'| - 'shape'|'shape[]'|'tensor'|'tensors'|'dtype'|'dtype[]'|'func'; -export type Category = 'arithmetic'|'basic_math'|'control'|'convolution'| - 'creation'|'custom'|'dynamic'|'evaluation'|'graph'|'hash_table'|'image'| - 'logical'|'matrices'|'normalization'|'ragged'|'reduction'|'slice_join'| - 'sparse'|'spectral'|'string'|'transformation'; - -// For mapping input or attributes of NodeDef into TensorFlow.js op param. -export declare interface ParamMapper { - // tensorflow.js name for the field, it should be in camelcase format. - name: string; - type: ParamType; - defaultValue?: ValueType; - notSupported?: boolean; -} - -// For mapping the input of TensorFlow NodeDef into TensorFlow.js Op param. -export declare interface InputParamMapper extends ParamMapper { - // The first number is the starting index of the param, the second number is - // the length of the param. If the length value is positive number, it - // represents the true length of the param. Otherwise, it represents a - // variable length, the value is the index go backward from the end of the - // array. - // For example `[0, 5]`: this param is the array of input tensors starting at - // index 0 and with the length of 5. - // For example `[1, -1]`: this param is the array of input tensors starting at - // index 1 and with the `inputs.length - 1`. - // Zero-based index at where in the input array this param starts. - // A negative index can be used, indicating an offset from the end of the - // sequence. slice(-2) extracts the last two elements in the sequence. - start: number; - // Zero-based index before where in the input array the param ends. The - // mapping is up to but not including end. For example, start = 1, end = 4 - // includes the second element through the fourth element (elements indexed 1, - // 2, and 3). A negative index can be used, indicating an offset from the end - // of the sequence. start = 2, end = -1 includes the third element through the - // second-to-last element in the sequence. If end is omitted, end is set to - // start + 1, the mapping only include the single element at start index. If - // end is set to 0, the mapping is through the end of the input array - // (arr.length). If end is greater than the length of the inputs, mapping - // inncludes through to the end of the sequence (arr.length). - end?: number; -} - -// For mapping the attributes of TensorFlow NodeDef into TensorFlow.js op param. -export declare interface AttrParamMapper extends ParamMapper { - // TensorFlow attribute name, this should be set if the tensorflow attribute - // name is different form the tensorflow.js name. - tfName?: string; - // TensorFlow deprecated attribute name, this is used to support old models. - tfDeprecatedName?: string; -} - -export interface InternalOpExecutor { - (node: Node, tensorMap: NamedTensorsMap, context: ExecutionContext, - ops?: typeof tfOps): Tensor|Tensor[]; -} - -export interface InternalOpAsyncExecutor { - (node: Node, tensorMap: NamedTensorsMap, context: ExecutionContext, - resourceManager?: ResourceManager, ops?: typeof tfOps): Promise; -} - -export declare interface OpMapper { - tfOpName: string; - category?: Category; - inputs?: InputParamMapper[]; - attrs?: AttrParamMapper[]; - outputs?: string[]; - customExecutor?: OpExecutor; -} - -export declare interface Node { - signatureKey?: string; - name: string; - op: string; - category: Category; - inputNames: string[]; - inputs: Node[]; - inputParams: {[key: string]: InputParamValue}; - attrParams: {[key: string]: ParamValue}; - children: Node[]; - rawAttrs?: {[k: string]: tensorflow.IAttrValue}; - defaultOutput?: number; - outputs?: string[]; -} - -export declare interface Graph { - nodes: {[key: string]: Node}; - placeholders: Node[]; - inputs: Node[]; - outputs: Node[]; - weights: Node[]; - signature?: tensorflow.ISignatureDef; - functions?: {[key: string]: Graph}; - initNodes?: Node[]; -} - -export type ValueType = string|string[]|number|number[]|number[][]|boolean| - boolean[]|Tensor|Tensor[]; -export declare interface ParamValue { - value?: ValueType; - type: ParamType; -} - -export declare interface InputParamValue extends ParamValue { - inputIndexStart?: number; - inputIndexEnd?: number; -} - -export interface OpExecutor { - (node: GraphNode): Tensor|Tensor[]|Promise; -} - -export interface GraphNode { - inputs: Tensor[]; - attrs: {[key: string]: ValueType}; -} diff --git a/tfjs-master/tfjs-converter/src/run_tests.ts b/tfjs-master/tfjs-converter/src/run_tests.ts deleted file mode 100644 index f362f5511..000000000 --- a/tfjs-master/tfjs-converter/src/run_tests.ts +++ /dev/null @@ -1,41 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// Use the CPU backend for running tests. -import '@tensorflow/tfjs-backend-cpu'; -// tslint:disable-next-line: no-imports-from-dist -import '@tensorflow/tfjs-core/dist/public/chained_ops/register_all_chained_ops'; -// tslint:disable-next-line:no-imports-from-dist -import {setTestEnvs} from '@tensorflow/tfjs-core/dist/jasmine_util'; - -// tslint:disable-next-line:no-require-imports -const jasmineCtor = require('jasmine'); -// tslint:disable-next-line:no-require-imports - -Error.stackTraceLimit = Infinity; - -process.on('unhandledRejection', e => { - throw e; -}); - -setTestEnvs([{name: 'test-converter', backendName: 'cpu', flags: {}}]); - -const unitTests = 'tfjs-converter/src/**/*_test.js'; - -const runner = new jasmineCtor(); -runner.loadConfig({spec_files: [unitTests], random: false}); -runner.execute(); diff --git a/tfjs-master/tfjs-converter/src/version.ts b/tfjs-master/tfjs-converter/src/version.ts deleted file mode 100644 index 5fa574e7d..000000000 --- a/tfjs-master/tfjs-converter/src/version.ts +++ /dev/null @@ -1,5 +0,0 @@ -/** @license See the LICENSE file. */ - -// This code is auto-generated, do not modify this file! -const version = '0.0.0'; -export {version}; diff --git a/tfjs-master/tfjs-converter/src/version_test.ts b/tfjs-master/tfjs-converter/src/version_test.ts deleted file mode 100644 index 1a989f182..000000000 --- a/tfjs-master/tfjs-converter/src/version_test.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. - * - * Use of this source code is governed by an MIT-style - * license that can be found in the LICENSE file or at - * https://opensource.org/licenses/MIT. - * ============================================================================= - */ - -import {version_converter} from './index'; - -describe('tfjs-core version consistency', () => { - it('dev-peer match', () => { - const tfjsCoreDevDepVersion = - // tslint:disable-next-line:no-require-imports - require('tfjs-converter/package.json').devDependencies['@tensorflow/tfjs-core']; - - const tfjsCorePeerDepVersion = - // tslint:disable-next-line:no-require-imports - require('tfjs-converter/package.json').peerDependencies['@tensorflow/tfjs-core']; - expect(tfjsCoreDevDepVersion).toEqual(tfjsCorePeerDepVersion); - }); - - it('version.ts matches package version', () => { - // tslint:disable-next-line:no-require-imports - const expected = require('tfjs-converter/package.json').version; - expect(version_converter).toBe(expected); - }); -}); diff --git a/tfjs-master/tfjs-converter/tensorflowjs_wizard.gif b/tfjs-master/tfjs-converter/tensorflowjs_wizard.gif deleted file mode 100644 index 4c88e4deb..000000000 Binary files a/tfjs-master/tfjs-converter/tensorflowjs_wizard.gif and /dev/null differ diff --git a/tfjs-master/tfjs-converter/tools/compiled_api.d.ts b/tfjs-master/tfjs-converter/tools/compiled_api.d.ts deleted file mode 100644 index e2c9c649f..000000000 --- a/tfjs-master/tfjs-converter/tools/compiled_api.d.ts +++ /dev/null @@ -1,1607 +0,0 @@ -import * as $protobuf from 'protobufjs'; - -/** Namespace tensorflow. */ -export namespace tensorflow { - /** Properties of an Any. */ - interface IAny { - /** Any typeUrl */ - typeUrl?: (string|null); - - /** Any value */ - value?: (Uint8Array|null); - } - - /** Represents an Any. */ - class Any implements IAny { - /** - * Constructs a new Any. - * @param [p] Properties to set - */ - constructor(p?: tensorflow.IAny); - - /** Any typeUrl. */ - public typeUrl: string; - - /** Any value. */ - public value: Uint8Array; - - /** - * Decodes an Any message from the specified reader or buffer. - * @param r Reader or buffer to decode from - * @param [l] Message length if known beforehand - * @returns Any - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - public static decode(r: ($protobuf.Reader|Uint8Array), l?: number): - tensorflow.Any; - } - - /** DataType enum. */ - enum DataType { - // Not a legal value for DataType. Used to indicate a DataType field - // has not been set. - DT_INVALID = 0, - - // Data types that all computation devices are expected to be - // capable to support. - DT_FLOAT = 1, - DT_DOUBLE = 2, - DT_INT32 = 3, - DT_UINT8 = 4, - DT_INT16 = 5, - DT_INT8 = 6, - DT_STRING = 7, - DT_COMPLEX64 = 8, // Single-precision complex - DT_INT64 = 9, - DT_BOOL = 10, - DT_QINT8 = 11, // Quantized int8 - DT_QUINT8 = 12, // Quantized uint8 - DT_QINT32 = 13, // Quantized int32 - DT_BFLOAT16 = 14, // Float32 truncated to 16 bits. Only for cast ops. - DT_QINT16 = 15, // Quantized int16 - DT_QUINT16 = 16, // Quantized uint16 - DT_UINT16 = 17, - DT_COMPLEX128 = 18, // Double-precision complex - DT_HALF = 19, - DT_RESOURCE = 20, - DT_VARIANT = 21, // Arbitrary C++ data types - DT_UINT32 = 22, - DT_UINT64 = 23, - - // Do not use! These are only for parameters. Every enum above - // should have a corresponding value below (verified by types_test). - DT_FLOAT_REF = 101, - DT_DOUBLE_REF = 102, - DT_INT32_REF = 103, - DT_UINT8_REF = 104, - DT_INT16_REF = 105, - DT_INT8_REF = 106, - DT_STRING_REF = 107, - DT_COMPLEX64_REF = 108, - DT_INT64_REF = 109, - DT_BOOL_REF = 110, - DT_QINT8_REF = 111, - DT_QUINT8_REF = 112, - DT_QINT32_REF = 113, - DT_BFLOAT16_REF = 114, - DT_QINT16_REF = 115, - DT_QUINT16_REF = 116, - DT_UINT16_REF = 117, - DT_COMPLEX128_REF = 118, - DT_HALF_REF = 119, - DT_RESOURCE_REF = 120, - DT_VARIANT_REF = 121, - DT_UINT32_REF = 122, - DT_UINT64_REF = 123, - } - - /** Properties of a TensorShape. */ - interface ITensorShape { - /** TensorShape dim */ - dim?: (tensorflow.TensorShape.IDim[]|null); - - /** TensorShape unknownRank */ - unknownRank?: (boolean|null); - } - - /** Represents a TensorShape. */ - class TensorShape implements ITensorShape { - /** - * Constructs a new TensorShape. - * @param [p] Properties to set - */ - constructor(p?: tensorflow.ITensorShape); - - /** TensorShape dim. */ - public dim: tensorflow.TensorShape.IDim[]; - - /** TensorShape unknownRank. */ - public unknownRank: boolean; - - /** - * Decodes a TensorShape message from the specified reader or buffer. - * @param r Reader or buffer to decode from - * @param [l] Message length if known beforehand - * @returns TensorShape - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - public static decode(r: ($protobuf.Reader|Uint8Array), l?: number): - tensorflow.TensorShape; - } - - namespace TensorShape { - - /** Properties of a Dim. */ - interface IDim { - /** Dim size */ - size?: (number|Long|null); - - /** Dim name */ - name?: (string|null); - } - - /** Represents a Dim. */ - class Dim implements IDim { - /** - * Constructs a new Dim. - * @param [p] Properties to set - */ - constructor(p?: tensorflow.TensorShape.IDim); - - /** Dim size. */ - public size: (number|Long); - - /** Dim name. */ - public name: string; - - /** - * Decodes a Dim message from the specified reader or buffer. - * @param r Reader or buffer to decode from - * @param [l] Message length if known beforehand - * @returns Dim - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - public static decode(r: ($protobuf.Reader|Uint8Array), l?: number): - tensorflow.TensorShape.Dim; - } - } - - /** Properties of a Tensor. */ - interface ITensor { - /** Tensor dtype */ - dtype?: (tensorflow.DataType|null); - - /** Tensor tensorShape */ - tensorShape?: (tensorflow.ITensorShape|null); - - /** Tensor versionNumber */ - versionNumber?: (number|null); - - /** Tensor tensorContent */ - tensorContent?: (Uint8Array|null); - - /** Tensor floatVal */ - floatVal?: (number[]|null); - - /** Tensor doubleVal */ - doubleVal?: (number[]|null); - - /** Tensor intVal */ - intVal?: (number[]|null); - - /** Tensor stringVal */ - stringVal?: (Uint8Array[]|null); - - /** Tensor scomplexVal */ - scomplexVal?: (number[]|null); - - /** Tensor int64Val */ - int64Val?: ((number | Long)[]|null); - - /** Tensor boolVal */ - boolVal?: (boolean[]|null); - - /** Tensor uint32Val */ - uint32Val?: (number[]|null); - - /** Tensor uint64Val */ - uint64Val?: ((number | Long)[]|null); - } - - /** Represents a Tensor. */ - class Tensor implements ITensor { - /** - * Constructs a new Tensor. - * @param [p] Properties to set - */ - constructor(p?: tensorflow.ITensor); - - /** Tensor dtype. */ - public dtype: tensorflow.DataType; - - /** Tensor tensorShape. */ - public tensorShape?: (tensorflow.ITensorShape|null); - - /** Tensor versionNumber. */ - public versionNumber: number; - - /** Tensor tensorContent. */ - public tensorContent: Uint8Array; - - /** Tensor floatVal. */ - public floatVal: number[]; - - /** Tensor doubleVal. */ - public doubleVal: number[]; - - /** Tensor intVal. */ - public intVal: number[]; - - /** Tensor stringVal. */ - public stringVal: Uint8Array[]; - - /** Tensor scomplexVal. */ - public scomplexVal: number[]; - - /** Tensor int64Val. */ - public int64Val: (number|Long)[]; - - /** Tensor boolVal. */ - public boolVal: boolean[]; - - /** Tensor uint32Val. */ - public uint32Val: number[]; - - /** Tensor uint64Val. */ - public uint64Val: (number|Long)[]; - - /** - * Decodes a Tensor message from the specified reader or buffer. - * @param r Reader or buffer to decode from - * @param [l] Message length if known beforehand - * @returns Tensor - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - public static decode(r: ($protobuf.Reader|Uint8Array), l?: number): - tensorflow.Tensor; - } - - /** Properties of an AttrValue. */ - interface IAttrValue { - /** AttrValue list */ - list?: (tensorflow.AttrValue.IListValue|null); - - /** AttrValue s */ - s?: (Uint8Array|null); - - /** AttrValue i */ - i?: (number|Long|null); - - /** AttrValue f */ - f?: (number|null); - - /** AttrValue b */ - b?: (boolean|null); - - /** AttrValue type */ - type?: (tensorflow.DataType|null); - - /** AttrValue shape */ - shape?: (tensorflow.ITensorShape|null); - - /** AttrValue tensor */ - tensor?: (tensorflow.ITensor|null); - - /** AttrValue placeholder */ - placeholder?: (string|null); - - /** AttrValue func */ - func?: (tensorflow.INameAttrList|null); - } - - /** Represents an AttrValue. */ - class AttrValue implements IAttrValue { - /** - * Constructs a new AttrValue. - * @param [p] Properties to set - */ - constructor(p?: tensorflow.IAttrValue); - - /** AttrValue list. */ - public list?: (tensorflow.AttrValue.IListValue|null); - - /** AttrValue s. */ - public s: Uint8Array; - - /** AttrValue i. */ - public i: (number|Long); - - /** AttrValue f. */ - public f: number; - - /** AttrValue b. */ - public b: boolean; - - /** AttrValue type. */ - public type: tensorflow.DataType; - - /** AttrValue shape. */ - public shape?: (tensorflow.ITensorShape|null); - - /** AttrValue tensor. */ - public tensor?: (tensorflow.ITensor|null); - - /** AttrValue placeholder. */ - public placeholder: string; - - /** AttrValue func. */ - public func?: (tensorflow.INameAttrList|null); - - /** AttrValue value. */ - public value?: ('list'|'s'|'i'|'f'|'b'|'type'|'shape'|'tensor'| - 'placeholder'|'func'); - - /** - * Decodes an AttrValue message from the specified reader or buffer. - * @param r Reader or buffer to decode from - * @param [l] Message length if known beforehand - * @returns AttrValue - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - public static decode(r: ($protobuf.Reader|Uint8Array), l?: number): - tensorflow.AttrValue; - } - - namespace AttrValue { - - /** Properties of a ListValue. */ - interface IListValue { - /** ListValue s */ - s?: (Uint8Array[]|null); - - /** ListValue i */ - i?: ((number | Long)[]|null); - - /** ListValue f */ - f?: (number[]|null); - - /** ListValue b */ - b?: (boolean[]|null); - - /** ListValue type */ - type?: (tensorflow.DataType[]|null); - - /** ListValue shape */ - shape?: (tensorflow.ITensorShape[]|null); - - /** ListValue tensor */ - tensor?: (tensorflow.ITensor[]|null); - - /** ListValue func */ - func?: (tensorflow.INameAttrList[]|null); - } - - /** Represents a ListValue. */ - class ListValue implements IListValue { - /** - * Constructs a new ListValue. - * @param [p] Properties to set - */ - constructor(p?: tensorflow.AttrValue.IListValue); - - /** ListValue s. */ - public s: Uint8Array[]; - - /** ListValue i. */ - public i: (number|Long)[]; - - /** ListValue f. */ - public f: number[]; - - /** ListValue b. */ - public b: boolean[]; - - /** ListValue type. */ - public type: tensorflow.DataType[]; - - /** ListValue shape. */ - public shape: tensorflow.ITensorShape[]; - - /** ListValue tensor. */ - public tensor: tensorflow.ITensor[]; - - /** ListValue func. */ - public func: tensorflow.INameAttrList[]; - - /** - * Decodes a ListValue message from the specified reader or buffer. - * @param r Reader or buffer to decode from - * @param [l] Message length if known beforehand - * @returns ListValue - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - public static decode(r: ($protobuf.Reader|Uint8Array), l?: number): - tensorflow.AttrValue.ListValue; - } - } - - /** Properties of a NameAttrList. */ - interface INameAttrList { - /** NameAttrList name */ - name?: (string|null); - - /** NameAttrList attr */ - attr?: ({[k: string]: tensorflow.IAttrValue}|null); - } - - /** Represents a NameAttrList. */ - class NameAttrList implements INameAttrList { - /** - * Constructs a new NameAttrList. - * @param [p] Properties to set - */ - constructor(p?: tensorflow.INameAttrList); - - /** NameAttrList name. */ - public name: string; - - /** NameAttrList attr. */ - public attr: {[k: string]: tensorflow.IAttrValue}; - - /** - * Decodes a NameAttrList message from the specified reader or buffer. - * @param r Reader or buffer to decode from - * @param [l] Message length if known beforehand - * @returns NameAttrList - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - public static decode(r: ($protobuf.Reader|Uint8Array), l?: number): - tensorflow.NameAttrList; - } - - /** Properties of a NodeDef. */ - interface INodeDef { - /** NodeDef name */ - name?: (string|null); - - /** NodeDef op */ - op?: (string|null); - - /** NodeDef input */ - input?: (string[]|null); - - /** NodeDef device */ - device?: (string|null); - - /** NodeDef attr */ - attr?: ({[k: string]: tensorflow.IAttrValue}|null); - } - - /** Represents a NodeDef. */ - class NodeDef implements INodeDef { - /** - * Constructs a new NodeDef. - * @param [p] Properties to set - */ - constructor(p?: tensorflow.INodeDef); - - /** NodeDef name. */ - public name: string; - - /** NodeDef op. */ - public op: string; - - /** NodeDef input. */ - public input: string[]; - - /** NodeDef device. */ - public device: string; - - /** NodeDef attr. */ - public attr: {[k: string]: tensorflow.IAttrValue}; - - /** - * Decodes a NodeDef message from the specified reader or buffer. - * @param r Reader or buffer to decode from - * @param [l] Message length if known beforehand - * @returns NodeDef - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - public static decode(r: ($protobuf.Reader|Uint8Array), l?: number): - tensorflow.NodeDef; - } - - /** Properties of a VersionDef. */ - interface IVersionDef { - /** VersionDef producer */ - producer?: (number|null); - - /** VersionDef minConsumer */ - minConsumer?: (number|null); - - /** VersionDef badConsumers */ - badConsumers?: (number[]|null); - } - - /** Represents a VersionDef. */ - class VersionDef implements IVersionDef { - /** - * Constructs a new VersionDef. - * @param [p] Properties to set - */ - constructor(p?: tensorflow.IVersionDef); - - /** VersionDef producer. */ - public producer: number; - - /** VersionDef minConsumer. */ - public minConsumer: number; - - /** VersionDef badConsumers. */ - public badConsumers: number[]; - - /** - * Decodes a VersionDef message from the specified reader or buffer. - * @param r Reader or buffer to decode from - * @param [l] Message length if known beforehand - * @returns VersionDef - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - public static decode(r: ($protobuf.Reader|Uint8Array), l?: number): - tensorflow.VersionDef; - } - - /** Properties of a GraphDef. */ - interface IGraphDef { - /** GraphDef node */ - node?: (tensorflow.INodeDef[]|null); - - /** GraphDef versions */ - versions?: (tensorflow.IVersionDef|null); - - /** GraphDef library */ - library?: (tensorflow.IFunctionDefLibrary|null); - } - - /** Represents a GraphDef. */ - class GraphDef implements IGraphDef { - /** - * Constructs a new GraphDef. - * @param [p] Properties to set - */ - constructor(p?: tensorflow.IGraphDef); - - /** GraphDef node. */ - public node: tensorflow.INodeDef[]; - - /** GraphDef versions. */ - public versions?: (tensorflow.IVersionDef|null); - - /** GraphDef library. */ - public library?: (tensorflow.IFunctionDefLibrary|null); - - /** - * Decodes a GraphDef message from the specified reader or buffer. - * @param r Reader or buffer to decode from - * @param [l] Message length if known beforehand - * @returns GraphDef - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - public static decode(r: ($protobuf.Reader|Uint8Array), l?: number): - tensorflow.GraphDef; - } - - /** Properties of a CollectionDef. */ - interface ICollectionDef { - /** CollectionDef nodeList */ - nodeList?: (tensorflow.CollectionDef.INodeList|null); - - /** CollectionDef bytesList */ - bytesList?: (tensorflow.CollectionDef.IBytesList|null); - - /** CollectionDef int64List */ - int64List?: (tensorflow.CollectionDef.IInt64List|null); - - /** CollectionDef floatList */ - floatList?: (tensorflow.CollectionDef.IFloatList|null); - - /** CollectionDef anyList */ - anyList?: (tensorflow.CollectionDef.IAnyList|null); - } - - /** Represents a CollectionDef. */ - class CollectionDef implements ICollectionDef { - /** - * Constructs a new CollectionDef. - * @param [p] Properties to set - */ - constructor(p?: tensorflow.ICollectionDef); - - /** CollectionDef nodeList. */ - public nodeList?: (tensorflow.CollectionDef.INodeList|null); - - /** CollectionDef bytesList. */ - public bytesList?: (tensorflow.CollectionDef.IBytesList|null); - - /** CollectionDef int64List. */ - public int64List?: (tensorflow.CollectionDef.IInt64List|null); - - /** CollectionDef floatList. */ - public floatList?: (tensorflow.CollectionDef.IFloatList|null); - - /** CollectionDef anyList. */ - public anyList?: (tensorflow.CollectionDef.IAnyList|null); - - /** CollectionDef kind. */ - public kind?: ('nodeList'|'bytesList'|'int64List'|'floatList'|'anyList'); - - /** - * Decodes a CollectionDef message from the specified reader or buffer. - * @param r Reader or buffer to decode from - * @param [l] Message length if known beforehand - * @returns CollectionDef - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - public static decode(r: ($protobuf.Reader|Uint8Array), l?: number): - tensorflow.CollectionDef; - } - - namespace CollectionDef { - - /** Properties of a NodeList. */ - interface INodeList { - /** NodeList value */ - value?: (string[]|null); - } - - /** Represents a NodeList. */ - class NodeList implements INodeList { - /** - * Constructs a new NodeList. - * @param [p] Properties to set - */ - constructor(p?: tensorflow.CollectionDef.INodeList); - - /** NodeList value. */ - public value: string[]; - - /** - * Decodes a NodeList message from the specified reader or buffer. - * @param r Reader or buffer to decode from - * @param [l] Message length if known beforehand - * @returns NodeList - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - public static decode(r: ($protobuf.Reader|Uint8Array), l?: number): - tensorflow.CollectionDef.NodeList; - } - - /** Properties of a BytesList. */ - interface IBytesList { - /** BytesList value */ - value?: (Uint8Array[]|null); - } - - /** Represents a BytesList. */ - class BytesList implements IBytesList { - /** - * Constructs a new BytesList. - * @param [p] Properties to set - */ - constructor(p?: tensorflow.CollectionDef.IBytesList); - - /** BytesList value. */ - public value: Uint8Array[]; - - /** - * Decodes a BytesList message from the specified reader or buffer. - * @param r Reader or buffer to decode from - * @param [l] Message length if known beforehand - * @returns BytesList - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - public static decode(r: ($protobuf.Reader|Uint8Array), l?: number): - tensorflow.CollectionDef.BytesList; - } - - /** Properties of an Int64List. */ - interface IInt64List { - /** Int64List value */ - value?: ((number | Long)[]|null); - } - - /** Represents an Int64List. */ - class Int64List implements IInt64List { - /** - * Constructs a new Int64List. - * @param [p] Properties to set - */ - constructor(p?: tensorflow.CollectionDef.IInt64List); - - /** Int64List value. */ - public value: (number|Long)[]; - - /** - * Decodes an Int64List message from the specified reader or buffer. - * @param r Reader or buffer to decode from - * @param [l] Message length if known beforehand - * @returns Int64List - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - public static decode(r: ($protobuf.Reader|Uint8Array), l?: number): - tensorflow.CollectionDef.Int64List; - } - - /** Properties of a FloatList. */ - interface IFloatList { - /** FloatList value */ - value?: (number[]|null); - } - - /** Represents a FloatList. */ - class FloatList implements IFloatList { - /** - * Constructs a new FloatList. - * @param [p] Properties to set - */ - constructor(p?: tensorflow.CollectionDef.IFloatList); - - /** FloatList value. */ - public value: number[]; - - /** - * Decodes a FloatList message from the specified reader or buffer. - * @param r Reader or buffer to decode from - * @param [l] Message length if known beforehand - * @returns FloatList - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - public static decode(r: ($protobuf.Reader|Uint8Array), l?: number): - tensorflow.CollectionDef.FloatList; - } - - /** Properties of an AnyList. */ - interface IAnyList { - /** AnyList value */ - value?: (tensorflow.IAny[]|null); - } - - /** Represents an AnyList. */ - class AnyList implements IAnyList { - /** - * Constructs a new AnyList. - * @param [p] Properties to set - */ - constructor(p?: tensorflow.CollectionDef.IAnyList); - - /** AnyList value. */ - public value: tensorflow.IAny[]; - - /** - * Decodes an AnyList message from the specified reader or buffer. - * @param r Reader or buffer to decode from - * @param [l] Message length if known beforehand - * @returns AnyList - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - public static decode(r: ($protobuf.Reader|Uint8Array), l?: number): - tensorflow.CollectionDef.AnyList; - } - } - - /** Properties of a SaverDef. */ - interface ISaverDef { - /** SaverDef filenameTensorName */ - filenameTensorName?: (string|null); - - /** SaverDef saveTensorName */ - saveTensorName?: (string|null); - - /** SaverDef restoreOpName */ - restoreOpName?: (string|null); - - /** SaverDef maxToKeep */ - maxToKeep?: (number|null); - - /** SaverDef sharded */ - sharded?: (boolean|null); - - /** SaverDef keepCheckpointEveryNHours */ - keepCheckpointEveryNHours?: (number|null); - - /** SaverDef version */ - version?: (tensorflow.SaverDef.CheckpointFormatVersion|null); - } - - /** Represents a SaverDef. */ - class SaverDef implements ISaverDef { - /** - * Constructs a new SaverDef. - * @param [p] Properties to set - */ - constructor(p?: tensorflow.ISaverDef); - - /** SaverDef filenameTensorName. */ - public filenameTensorName: string; - - /** SaverDef saveTensorName. */ - public saveTensorName: string; - - /** SaverDef restoreOpName. */ - public restoreOpName: string; - - /** SaverDef maxToKeep. */ - public maxToKeep: number; - - /** SaverDef sharded. */ - public sharded: boolean; - - /** SaverDef keepCheckpointEveryNHours. */ - public keepCheckpointEveryNHours: number; - - /** SaverDef version. */ - public version: tensorflow.SaverDef.CheckpointFormatVersion; - - /** - * Decodes a SaverDef message from the specified reader or buffer. - * @param r Reader or buffer to decode from - * @param [l] Message length if known beforehand - * @returns SaverDef - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - public static decode(r: ($protobuf.Reader|Uint8Array), l?: number): - tensorflow.SaverDef; - } - - namespace SaverDef { - - /** CheckpointFormatVersion enum. */ - enum CheckpointFormatVersion { LEGACY = 0, V1 = 1, V2 = 2 } - } - - /** Properties of a TensorInfo. */ - interface ITensorInfo { - /** TensorInfo name */ - name?: (string|null); - - /** TensorInfo cooSparse */ - cooSparse?: (tensorflow.TensorInfo.ICooSparse|null); - - /** TensorInfo dtype */ - dtype?: (tensorflow.DataType|null); - - /** TensorInfo tensorShape */ - tensorShape?: (tensorflow.ITensorShape|null); - } - - /** Represents a TensorInfo. */ - class TensorInfo implements ITensorInfo { - /** - * Constructs a new TensorInfo. - * @param [p] Properties to set - */ - constructor(p?: tensorflow.ITensorInfo); - - /** TensorInfo name. */ - public name: string; - - /** TensorInfo cooSparse. */ - public cooSparse?: (tensorflow.TensorInfo.ICooSparse|null); - - /** TensorInfo dtype. */ - public dtype: tensorflow.DataType; - - /** TensorInfo tensorShape. */ - public tensorShape?: (tensorflow.ITensorShape|null); - - /** TensorInfo encoding. */ - public encoding?: ('name'|'cooSparse'); - - /** - * Decodes a TensorInfo message from the specified reader or buffer. - * @param r Reader or buffer to decode from - * @param [l] Message length if known beforehand - * @returns TensorInfo - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - public static decode(r: ($protobuf.Reader|Uint8Array), l?: number): - tensorflow.TensorInfo; - } - - namespace TensorInfo { - - /** Properties of a CooSparse. */ - interface ICooSparse { - /** CooSparse valuesTensorName */ - valuesTensorName?: (string|null); - - /** CooSparse indicesTensorName */ - indicesTensorName?: (string|null); - - /** CooSparse denseShapeTensorName */ - denseShapeTensorName?: (string|null); - } - - /** Represents a CooSparse. */ - class CooSparse implements ICooSparse { - /** - * Constructs a new CooSparse. - * @param [p] Properties to set - */ - constructor(p?: tensorflow.TensorInfo.ICooSparse); - - /** CooSparse valuesTensorName. */ - public valuesTensorName: string; - - /** CooSparse indicesTensorName. */ - public indicesTensorName: string; - - /** CooSparse denseShapeTensorName. */ - public denseShapeTensorName: string; - - /** - * Decodes a CooSparse message from the specified reader or buffer. - * @param r Reader or buffer to decode from - * @param [l] Message length if known beforehand - * @returns CooSparse - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - public static decode(r: ($protobuf.Reader|Uint8Array), l?: number): - tensorflow.TensorInfo.CooSparse; - } - } - - /** Properties of a SignatureDef. */ - interface ISignatureDef { - /** SignatureDef inputs */ - inputs?: ({[k: string]: tensorflow.ITensorInfo}|null); - - /** SignatureDef outputs */ - outputs?: ({[k: string]: tensorflow.ITensorInfo}|null); - - /** SignatureDef methodName */ - methodName?: (string|null); - } - - /** Represents a SignatureDef. */ - class SignatureDef implements ISignatureDef { - /** - * Constructs a new SignatureDef. - * @param [p] Properties to set - */ - constructor(p?: tensorflow.ISignatureDef); - - /** SignatureDef inputs. */ - public inputs: {[k: string]: tensorflow.ITensorInfo}; - - /** SignatureDef outputs. */ - public outputs: {[k: string]: tensorflow.ITensorInfo}; - - /** SignatureDef methodName. */ - public methodName: string; - - /** - * Decodes a SignatureDef message from the specified reader or buffer. - * @param r Reader or buffer to decode from - * @param [l] Message length if known beforehand - * @returns SignatureDef - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - public static decode(r: ($protobuf.Reader|Uint8Array), l?: number): - tensorflow.SignatureDef; - } - - /** Properties of an AssetFileDef. */ - interface IAssetFileDef { - /** AssetFileDef tensorInfo */ - tensorInfo?: (tensorflow.ITensorInfo|null); - - /** AssetFileDef filename */ - filename?: (string|null); - } - - /** Represents an AssetFileDef. */ - class AssetFileDef implements IAssetFileDef { - /** - * Constructs a new AssetFileDef. - * @param [p] Properties to set - */ - constructor(p?: tensorflow.IAssetFileDef); - - /** AssetFileDef tensorInfo. */ - public tensorInfo?: (tensorflow.ITensorInfo|null); - - /** AssetFileDef filename. */ - public filename: string; - - /** - * Decodes an AssetFileDef message from the specified reader or buffer. - * @param r Reader or buffer to decode from - * @param [l] Message length if known beforehand - * @returns AssetFileDef - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - public static decode(r: ($protobuf.Reader|Uint8Array), l?: number): - tensorflow.AssetFileDef; - } - - /** Properties of an OpDef. */ - interface IOpDef { - /** OpDef name */ - name?: (string|null); - - /** OpDef inputArg */ - inputArg?: (tensorflow.OpDef.IArgDef[]|null); - - /** OpDef outputArg */ - outputArg?: (tensorflow.OpDef.IArgDef[]|null); - - /** OpDef attr */ - attr?: (tensorflow.OpDef.IAttrDef[]|null); - - /** OpDef deprecation */ - deprecation?: (tensorflow.OpDef.IOpDeprecation|null); - - /** OpDef summary */ - summary?: (string|null); - - /** OpDef description */ - description?: (string|null); - - /** OpDef isCommutative */ - isCommutative?: (boolean|null); - - /** OpDef isAggregate */ - isAggregate?: (boolean|null); - - /** OpDef isStateful */ - isStateful?: (boolean|null); - - /** OpDef allowsUninitializedInput */ - allowsUninitializedInput?: (boolean|null); - } - - /** Represents an OpDef. */ - class OpDef implements IOpDef { - /** - * Constructs a new OpDef. - * @param [p] Properties to set - */ - constructor(p?: tensorflow.IOpDef); - - /** OpDef name. */ - public name: string; - - /** OpDef inputArg. */ - public inputArg: tensorflow.OpDef.IArgDef[]; - - /** OpDef outputArg. */ - public outputArg: tensorflow.OpDef.IArgDef[]; - - /** OpDef attr. */ - public attr: tensorflow.OpDef.IAttrDef[]; - - /** OpDef deprecation. */ - public deprecation?: (tensorflow.OpDef.IOpDeprecation|null); - - /** OpDef summary. */ - public summary: string; - - /** OpDef description. */ - public description: string; - - /** OpDef isCommutative. */ - public isCommutative: boolean; - - /** OpDef isAggregate. */ - public isAggregate: boolean; - - /** OpDef isStateful. */ - public isStateful: boolean; - - /** OpDef allowsUninitializedInput. */ - public allowsUninitializedInput: boolean; - - /** - * Decodes an OpDef message from the specified reader or buffer. - * @param r Reader or buffer to decode from - * @param [l] Message length if known beforehand - * @returns OpDef - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - public static decode(r: ($protobuf.Reader|Uint8Array), l?: number): - tensorflow.OpDef; - } - - namespace OpDef { - - /** Properties of an ArgDef. */ - interface IArgDef { - /** ArgDef name */ - name?: (string|null); - - /** ArgDef description */ - description?: (string|null); - - /** ArgDef type */ - type?: (tensorflow.DataType|null); - - /** ArgDef typeAttr */ - typeAttr?: (string|null); - - /** ArgDef numberAttr */ - numberAttr?: (string|null); - - /** ArgDef typeListAttr */ - typeListAttr?: (string|null); - - /** ArgDef isRef */ - isRef?: (boolean|null); - } - - /** Represents an ArgDef. */ - class ArgDef implements IArgDef { - /** - * Constructs a new ArgDef. - * @param [p] Properties to set - */ - constructor(p?: tensorflow.OpDef.IArgDef); - - /** ArgDef name. */ - public name: string; - - /** ArgDef description. */ - public description: string; - - /** ArgDef type. */ - public type: tensorflow.DataType; - - /** ArgDef typeAttr. */ - public typeAttr: string; - - /** ArgDef numberAttr. */ - public numberAttr: string; - - /** ArgDef typeListAttr. */ - public typeListAttr: string; - - /** ArgDef isRef. */ - public isRef: boolean; - - /** - * Decodes an ArgDef message from the specified reader or buffer. - * @param r Reader or buffer to decode from - * @param [l] Message length if known beforehand - * @returns ArgDef - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - public static decode(r: ($protobuf.Reader|Uint8Array), l?: number): - tensorflow.OpDef.ArgDef; - } - - /** Properties of an AttrDef. */ - interface IAttrDef { - /** AttrDef name */ - name?: (string|null); - - /** AttrDef type */ - type?: (string|null); - - /** AttrDef defaultValue */ - defaultValue?: (tensorflow.IAttrValue|null); - - /** AttrDef description */ - description?: (string|null); - - /** AttrDef hasMinimum */ - hasMinimum?: (boolean|null); - - /** AttrDef minimum */ - minimum?: (number|Long|null); - - /** AttrDef allowedValues */ - allowedValues?: (tensorflow.IAttrValue|null); - } - - /** Represents an AttrDef. */ - class AttrDef implements IAttrDef { - /** - * Constructs a new AttrDef. - * @param [p] Properties to set - */ - constructor(p?: tensorflow.OpDef.IAttrDef); - - /** AttrDef name. */ - public name: string; - - /** AttrDef type. */ - public type: string; - - /** AttrDef defaultValue. */ - public defaultValue?: (tensorflow.IAttrValue|null); - - /** AttrDef description. */ - public description: string; - - /** AttrDef hasMinimum. */ - public hasMinimum: boolean; - - /** AttrDef minimum. */ - public minimum: (number|Long); - - /** AttrDef allowedValues. */ - public allowedValues?: (tensorflow.IAttrValue|null); - - /** - * Decodes an AttrDef message from the specified reader or buffer. - * @param r Reader or buffer to decode from - * @param [l] Message length if known beforehand - * @returns AttrDef - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - public static decode(r: ($protobuf.Reader|Uint8Array), l?: number): - tensorflow.OpDef.AttrDef; - } - - /** Properties of an OpDeprecation. */ - interface IOpDeprecation { - /** OpDeprecation version */ - version?: (number|null); - - /** OpDeprecation explanation */ - explanation?: (string|null); - } - - /** Represents an OpDeprecation. */ - class OpDeprecation implements IOpDeprecation { - /** - * Constructs a new OpDeprecation. - * @param [p] Properties to set - */ - constructor(p?: tensorflow.OpDef.IOpDeprecation); - - /** OpDeprecation version. */ - public version: number; - - /** OpDeprecation explanation. */ - public explanation: string; - - /** - * Decodes an OpDeprecation message from the specified reader or buffer. - * @param r Reader or buffer to decode from - * @param [l] Message length if known beforehand - * @returns OpDeprecation - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - public static decode(r: ($protobuf.Reader|Uint8Array), l?: number): - tensorflow.OpDef.OpDeprecation; - } - } - - /** Properties of an OpList. */ - interface IOpList { - /** OpList op */ - op?: (tensorflow.IOpDef[]|null); - } - - /** Represents an OpList. */ - class OpList implements IOpList { - /** - * Constructs a new OpList. - * @param [p] Properties to set - */ - constructor(p?: tensorflow.IOpList); - - /** OpList op. */ - public op: tensorflow.IOpDef[]; - - /** - * Decodes an OpList message from the specified reader or buffer. - * @param r Reader or buffer to decode from - * @param [l] Message length if known beforehand - * @returns OpList - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - public static decode(r: ($protobuf.Reader|Uint8Array), l?: number): - tensorflow.OpList; - } - - /** Properties of a MetaGraphDef. */ - interface IMetaGraphDef { - /** MetaGraphDef metaInfoDef */ - metaInfoDef?: (tensorflow.MetaGraphDef.IMetaInfoDef|null); - - /** MetaGraphDef graphDef */ - graphDef?: (tensorflow.IGraphDef|null); - - /** MetaGraphDef saverDef */ - saverDef?: (tensorflow.ISaverDef|null); - - /** MetaGraphDef collectionDef */ - collectionDef?: ({[k: string]: tensorflow.ICollectionDef}|null); - - /** MetaGraphDef signatureDef */ - signatureDef?: ({[k: string]: tensorflow.ISignatureDef}|null); - - /** MetaGraphDef assetFileDef */ - assetFileDef?: (tensorflow.IAssetFileDef[]|null); - } - - /** Represents a MetaGraphDef. */ - class MetaGraphDef implements IMetaGraphDef { - /** - * Constructs a new MetaGraphDef. - * @param [p] Properties to set - */ - constructor(p?: tensorflow.IMetaGraphDef); - - /** MetaGraphDef metaInfoDef. */ - public metaInfoDef?: (tensorflow.MetaGraphDef.IMetaInfoDef|null); - - /** MetaGraphDef graphDef. */ - public graphDef?: (tensorflow.IGraphDef|null); - - /** MetaGraphDef saverDef. */ - public saverDef?: (tensorflow.ISaverDef|null); - - /** MetaGraphDef collectionDef. */ - public collectionDef: {[k: string]: tensorflow.ICollectionDef}; - - /** MetaGraphDef signatureDef. */ - public signatureDef: {[k: string]: tensorflow.ISignatureDef}; - - /** MetaGraphDef assetFileDef. */ - public assetFileDef: tensorflow.IAssetFileDef[]; - - /** - * Decodes a MetaGraphDef message from the specified reader or buffer. - * @param r Reader or buffer to decode from - * @param [l] Message length if known beforehand - * @returns MetaGraphDef - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - public static decode(r: ($protobuf.Reader|Uint8Array), l?: number): - tensorflow.MetaGraphDef; - } - - namespace MetaGraphDef { - - /** Properties of a MetaInfoDef. */ - interface IMetaInfoDef { - /** MetaInfoDef metaGraphVersion */ - metaGraphVersion?: (string|null); - - /** MetaInfoDef strippedOpList */ - strippedOpList?: (tensorflow.IOpList|null); - - /** MetaInfoDef anyInfo */ - anyInfo?: (tensorflow.IAny|null); - - /** MetaInfoDef tags */ - tags?: (string[]|null); - - /** MetaInfoDef tensorflowVersion */ - tensorflowVersion?: (string|null); - - /** MetaInfoDef tensorflowGitVersion */ - tensorflowGitVersion?: (string|null); - } - - /** Represents a MetaInfoDef. */ - class MetaInfoDef implements IMetaInfoDef { - /** - * Constructs a new MetaInfoDef. - * @param [p] Properties to set - */ - constructor(p?: tensorflow.MetaGraphDef.IMetaInfoDef); - - /** MetaInfoDef metaGraphVersion. */ - public metaGraphVersion: string; - - /** MetaInfoDef strippedOpList. */ - public strippedOpList?: (tensorflow.IOpList|null); - - /** MetaInfoDef anyInfo. */ - public anyInfo?: (tensorflow.IAny|null); - - /** MetaInfoDef tags. */ - public tags: string[]; - - /** MetaInfoDef tensorflowVersion. */ - public tensorflowVersion: string; - - /** MetaInfoDef tensorflowGitVersion. */ - public tensorflowGitVersion: string; - - /** - * Decodes a MetaInfoDef message from the specified reader or buffer. - * @param r Reader or buffer to decode from - * @param [l] Message length if known beforehand - * @returns MetaInfoDef - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - public static decode(r: ($protobuf.Reader|Uint8Array), l?: number): - tensorflow.MetaGraphDef.MetaInfoDef; - } - } - - /** Properties of a SavedModel. */ - interface ISavedModel { - /** SavedModel savedModelSchemaVersion */ - savedModelSchemaVersion?: (number|Long|null); - - /** SavedModel metaGraphs */ - metaGraphs?: (tensorflow.IMetaGraphDef[]|null); - } - - /** Represents a SavedModel. */ - class SavedModel implements ISavedModel { - /** - * Constructs a new SavedModel. - * @param [p] Properties to set - */ - constructor(p?: tensorflow.ISavedModel); - - /** SavedModel savedModelSchemaVersion. */ - public savedModelSchemaVersion: (number|Long); - - /** SavedModel metaGraphs. */ - public metaGraphs: tensorflow.IMetaGraphDef[]; - - /** - * Decodes a SavedModel message from the specified reader or buffer. - * @param r Reader or buffer to decode from - * @param [l] Message length if known beforehand - * @returns SavedModel - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - public static decode(r: ($protobuf.Reader|Uint8Array), l?: number): - tensorflow.SavedModel; - } - - /** Properties of a FunctionDefLibrary. */ - interface IFunctionDefLibrary { - /** FunctionDefLibrary function */ - 'function'?: (tensorflow.IFunctionDef[]|null); - - /** FunctionDefLibrary gradient */ - gradient?: (tensorflow.IGradientDef[]|null); - } - - /** Represents a FunctionDefLibrary. */ - class FunctionDefLibrary implements IFunctionDefLibrary { - /** - * Constructs a new FunctionDefLibrary. - * @param [p] Properties to set - */ - constructor(p?: tensorflow.IFunctionDefLibrary); - - /** FunctionDefLibrary function. */ - public function: tensorflow.IFunctionDef[]; - - /** FunctionDefLibrary gradient. */ - public gradient: tensorflow.IGradientDef[]; - - /** - * Decodes a FunctionDefLibrary message from the specified reader or buffer. - * @param r Reader or buffer to decode from - * @param [l] Message length if known beforehand - * @returns FunctionDefLibrary - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - public static decode(r: ($protobuf.Reader|Uint8Array), l?: number): - tensorflow.FunctionDefLibrary; - } - - /** Properties of a FunctionDef. */ - interface IFunctionDef { - /** FunctionDef signature */ - signature?: (tensorflow.IOpDef|null); - - /** FunctionDef attr */ - attr?: ({[k: string]: tensorflow.IAttrValue}|null); - - /** FunctionDef nodeDef */ - nodeDef?: (tensorflow.INodeDef[]|null); - - /** FunctionDef ret */ - ret?: ({[k: string]: string}|null); - } - - /** Represents a FunctionDef. */ - class FunctionDef implements IFunctionDef { - /** - * Constructs a new FunctionDef. - * @param [p] Properties to set - */ - constructor(p?: tensorflow.IFunctionDef); - - /** FunctionDef signature. */ - public signature?: (tensorflow.IOpDef|null); - - /** FunctionDef attr. */ - public attr: {[k: string]: tensorflow.IAttrValue}; - - /** FunctionDef nodeDef. */ - public nodeDef: tensorflow.INodeDef[]; - - /** FunctionDef ret. */ - public ret: {[k: string]: string}; - - /** - * Decodes a FunctionDef message from the specified reader or buffer. - * @param r Reader or buffer to decode from - * @param [l] Message length if known beforehand - * @returns FunctionDef - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - public static decode(r: ($protobuf.Reader|Uint8Array), l?: number): - tensorflow.FunctionDef; - } - - /** Properties of a GradientDef. */ - interface IGradientDef { - /** GradientDef functionName */ - functionName?: (string|null); - - /** GradientDef gradientFunc */ - gradientFunc?: (string|null); - } - - /** Represents a GradientDef. */ - class GradientDef implements IGradientDef { - /** - * Constructs a new GradientDef. - * @param [p] Properties to set - */ - constructor(p?: tensorflow.IGradientDef); - - /** GradientDef functionName. */ - public functionName: string; - - /** GradientDef gradientFunc. */ - public gradientFunc: string; - - /** - * Decodes a GradientDef message from the specified reader or buffer. - * @param r Reader or buffer to decode from - * @param [l] Message length if known beforehand - * @returns GradientDef - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - public static decode(r: ($protobuf.Reader|Uint8Array), l?: number): - tensorflow.GradientDef; - } -} diff --git a/tfjs-master/tfjs-converter/tools/compiled_api.js b/tfjs-master/tfjs-converter/tools/compiled_api.js deleted file mode 100644 index 89e3c9b5e..000000000 --- a/tfjs-master/tfjs-converter/tools/compiled_api.js +++ /dev/null @@ -1,1723 +0,0 @@ -/*eslint-disable block-scoped-var, no-redeclare, no-control-regex, no-prototype-builtins*/ -"use strict"; - -var $protobuf = require("protobufjs/minimal"); - -var $Reader = $protobuf.Reader, $util = $protobuf.util; - -var $root = $protobuf.roots["default"] || ($protobuf.roots["default"] = {}); - -$root.tensorflow = (function() { - - var tensorflow = {}; - - tensorflow.Any = (function() { - - function Any(p) { - if (p) - for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) - if (p[ks[i]] != null) - this[ks[i]] = p[ks[i]]; - } - - Any.prototype.typeUrl = ""; - Any.prototype.value = $util.newBuffer([]); - - Any.decode = function decode(r, l) { - if (!(r instanceof $Reader)) - r = $Reader.create(r); - var c = l === undefined ? r.len : r.pos + l, m = new $root.tensorflow.Any(); - while (r.pos < c) { - var t = r.uint32(); - switch (t >>> 3) { - case 1: - m.typeUrl = r.string(); - break; - case 2: - m.value = r.bytes(); - break; - default: - r.skipType(t & 7); - break; - } - } - return m; - }; - - return Any; - })(); - - tensorflow.DataType = (function() { - var valuesById = {}, values = Object.create(valuesById); - values[valuesById[0] = "DT_INVALID"] = 0; - values[valuesById[1] = "DT_FLOAT"] = 1; - values[valuesById[2] = "DT_DOUBLE"] = 2; - values[valuesById[3] = "DT_INT32"] = 3; - values[valuesById[4] = "DT_UINT8"] = 4; - values[valuesById[5] = "DT_INT16"] = 5; - values[valuesById[6] = "DT_INT8"] = 6; - values[valuesById[7] = "DT_STRING"] = 7; - values[valuesById[8] = "DT_COMPLEX64"] = 8; - values[valuesById[9] = "DT_INT64"] = 9; - values[valuesById[10] = "DT_BOOL"] = 10; - values[valuesById[11] = "DT_QINT8"] = 11; - values[valuesById[12] = "DT_QUINT8"] = 12; - values[valuesById[13] = "DT_QINT32"] = 13; - values[valuesById[14] = "DT_BFLOAT16"] = 14; - values[valuesById[101] = "DT_FLOAT_REF"] = 101; - values[valuesById[102] = "DT_DOUBLE_REF"] = 102; - values[valuesById[103] = "DT_INT32_REF"] = 103; - values[valuesById[104] = "DT_UINT8_REF"] = 104; - values[valuesById[105] = "DT_INT16_REF"] = 105; - values[valuesById[106] = "DT_INT8_REF"] = 106; - values[valuesById[107] = "DT_STRING_REF"] = 107; - values[valuesById[108] = "DT_COMPLEX64_REF"] = 108; - values[valuesById[109] = "DT_INT64_REF"] = 109; - values[valuesById[110] = "DT_BOOL_REF"] = 110; - values[valuesById[111] = "DT_QINT8_REF"] = 111; - values[valuesById[112] = "DT_QUINT8_REF"] = 112; - values[valuesById[113] = "DT_QINT32_REF"] = 113; - values[valuesById[114] = "DT_BFLOAT16_REF"] = 114; - return values; - })(); - - tensorflow.TensorShape = (function() { - - function TensorShape(p) { - this.dim = []; - if (p) - for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) - if (p[ks[i]] != null) - this[ks[i]] = p[ks[i]]; - } - - TensorShape.prototype.dim = $util.emptyArray; - TensorShape.prototype.unknownRank = false; - - TensorShape.decode = function decode(r, l) { - if (!(r instanceof $Reader)) - r = $Reader.create(r); - var c = l === undefined ? r.len : r.pos + l, m = new $root.tensorflow.TensorShape(); - while (r.pos < c) { - var t = r.uint32(); - switch (t >>> 3) { - case 2: - if (!(m.dim && m.dim.length)) - m.dim = []; - m.dim.push($root.tensorflow.TensorShape.Dim.decode(r, r.uint32())); - break; - case 3: - m.unknownRank = r.bool(); - break; - default: - r.skipType(t & 7); - break; - } - } - return m; - }; - - TensorShape.Dim = (function() { - - function Dim(p) { - if (p) - for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) - if (p[ks[i]] != null) - this[ks[i]] = p[ks[i]]; - } - - Dim.prototype.size = $util.Long ? $util.Long.fromBits(0,0,false) : 0; - Dim.prototype.name = ""; - - Dim.decode = function decode(r, l) { - if (!(r instanceof $Reader)) - r = $Reader.create(r); - var c = l === undefined ? r.len : r.pos + l, m = new $root.tensorflow.TensorShape.Dim(); - while (r.pos < c) { - var t = r.uint32(); - switch (t >>> 3) { - case 1: - m.size = r.int64(); - break; - case 2: - m.name = r.string(); - break; - default: - r.skipType(t & 7); - break; - } - } - return m; - }; - - return Dim; - })(); - - return TensorShape; - })(); - - tensorflow.Tensor = (function() { - - function Tensor(p) { - this.floatVal = []; - this.doubleVal = []; - this.intVal = []; - this.stringVal = []; - this.scomplexVal = []; - this.int64Val = []; - this.boolVal = []; - this.uint32Val = []; - this.uint64Val = []; - if (p) - for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) - if (p[ks[i]] != null) - this[ks[i]] = p[ks[i]]; - } - - Tensor.prototype.dtype = 0; - Tensor.prototype.tensorShape = null; - Tensor.prototype.versionNumber = 0; - Tensor.prototype.tensorContent = $util.newBuffer([]); - Tensor.prototype.floatVal = $util.emptyArray; - Tensor.prototype.doubleVal = $util.emptyArray; - Tensor.prototype.intVal = $util.emptyArray; - Tensor.prototype.stringVal = $util.emptyArray; - Tensor.prototype.scomplexVal = $util.emptyArray; - Tensor.prototype.int64Val = $util.emptyArray; - Tensor.prototype.boolVal = $util.emptyArray; - Tensor.prototype.uint32Val = $util.emptyArray; - Tensor.prototype.uint64Val = $util.emptyArray; - - Tensor.decode = function decode(r, l) { - if (!(r instanceof $Reader)) - r = $Reader.create(r); - var c = l === undefined ? r.len : r.pos + l, m = new $root.tensorflow.Tensor(); - while (r.pos < c) { - var t = r.uint32(); - switch (t >>> 3) { - case 1: - m.dtype = r.int32(); - break; - case 2: - m.tensorShape = $root.tensorflow.TensorShape.decode(r, r.uint32()); - break; - case 3: - m.versionNumber = r.int32(); - break; - case 4: - m.tensorContent = r.bytes(); - break; - case 5: - if (!(m.floatVal && m.floatVal.length)) - m.floatVal = []; - if ((t & 7) === 2) { - var c2 = r.uint32() + r.pos; - while (r.pos < c2) - m.floatVal.push(r.float()); - } else - m.floatVal.push(r.float()); - break; - case 6: - if (!(m.doubleVal && m.doubleVal.length)) - m.doubleVal = []; - if ((t & 7) === 2) { - var c2 = r.uint32() + r.pos; - while (r.pos < c2) - m.doubleVal.push(r.double()); - } else - m.doubleVal.push(r.double()); - break; - case 7: - if (!(m.intVal && m.intVal.length)) - m.intVal = []; - if ((t & 7) === 2) { - var c2 = r.uint32() + r.pos; - while (r.pos < c2) - m.intVal.push(r.int32()); - } else - m.intVal.push(r.int32()); - break; - case 8: - if (!(m.stringVal && m.stringVal.length)) - m.stringVal = []; - m.stringVal.push(r.bytes()); - break; - case 9: - if (!(m.scomplexVal && m.scomplexVal.length)) - m.scomplexVal = []; - if ((t & 7) === 2) { - var c2 = r.uint32() + r.pos; - while (r.pos < c2) - m.scomplexVal.push(r.float()); - } else - m.scomplexVal.push(r.float()); - break; - case 10: - if (!(m.int64Val && m.int64Val.length)) - m.int64Val = []; - if ((t & 7) === 2) { - var c2 = r.uint32() + r.pos; - while (r.pos < c2) - m.int64Val.push(r.int64()); - } else - m.int64Val.push(r.int64()); - break; - case 11: - if (!(m.boolVal && m.boolVal.length)) - m.boolVal = []; - if ((t & 7) === 2) { - var c2 = r.uint32() + r.pos; - while (r.pos < c2) - m.boolVal.push(r.bool()); - } else - m.boolVal.push(r.bool()); - break; - case 16: - if (!(m.uint32Val && m.uint32Val.length)) - m.uint32Val = []; - if ((t & 7) === 2) { - var c2 = r.uint32() + r.pos; - while (r.pos < c2) - m.uint32Val.push(r.uint32()); - } else - m.uint32Val.push(r.uint32()); - break; - case 17: - if (!(m.uint64Val && m.uint64Val.length)) - m.uint64Val = []; - if ((t & 7) === 2) { - var c2 = r.uint32() + r.pos; - while (r.pos < c2) - m.uint64Val.push(r.uint64()); - } else - m.uint64Val.push(r.uint64()); - break; - default: - r.skipType(t & 7); - break; - } - } - return m; - }; - - return Tensor; - })(); - - tensorflow.AttrValue = (function() { - - function AttrValue(p) { - if (p) - for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) - if (p[ks[i]] != null) - this[ks[i]] = p[ks[i]]; - } - - AttrValue.prototype.list = null; - AttrValue.prototype.s = $util.newBuffer([]); - AttrValue.prototype.i = $util.Long ? $util.Long.fromBits(0,0,false) : 0; - AttrValue.prototype.f = 0; - AttrValue.prototype.b = false; - AttrValue.prototype.type = 0; - AttrValue.prototype.shape = null; - AttrValue.prototype.tensor = null; - AttrValue.prototype.placeholder = ""; - AttrValue.prototype.func = null; - - var $oneOfFields; - - Object.defineProperty(AttrValue.prototype, "value", { - get: $util.oneOfGetter($oneOfFields = ["list", "s", "i", "f", "b", "type", "shape", "tensor", "placeholder", "func"]), - set: $util.oneOfSetter($oneOfFields) - }); - - AttrValue.decode = function decode(r, l) { - if (!(r instanceof $Reader)) - r = $Reader.create(r); - var c = l === undefined ? r.len : r.pos + l, m = new $root.tensorflow.AttrValue(); - while (r.pos < c) { - var t = r.uint32(); - switch (t >>> 3) { - case 1: - m.list = $root.tensorflow.AttrValue.ListValue.decode(r, r.uint32()); - break; - case 2: - m.s = r.bytes(); - break; - case 3: - m.i = r.int64(); - break; - case 4: - m.f = r.float(); - break; - case 5: - m.b = r.bool(); - break; - case 6: - m.type = r.int32(); - break; - case 7: - m.shape = $root.tensorflow.TensorShape.decode(r, r.uint32()); - break; - case 8: - m.tensor = $root.tensorflow.Tensor.decode(r, r.uint32()); - break; - case 9: - m.placeholder = r.string(); - break; - case 10: - m.func = $root.tensorflow.NameAttrList.decode(r, r.uint32()); - break; - default: - r.skipType(t & 7); - break; - } - } - return m; - }; - - AttrValue.ListValue = (function() { - - function ListValue(p) { - this.s = []; - this.i = []; - this.f = []; - this.b = []; - this.type = []; - this.shape = []; - this.tensor = []; - this.func = []; - if (p) - for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) - if (p[ks[i]] != null) - this[ks[i]] = p[ks[i]]; - } - - ListValue.prototype.s = $util.emptyArray; - ListValue.prototype.i = $util.emptyArray; - ListValue.prototype.f = $util.emptyArray; - ListValue.prototype.b = $util.emptyArray; - ListValue.prototype.type = $util.emptyArray; - ListValue.prototype.shape = $util.emptyArray; - ListValue.prototype.tensor = $util.emptyArray; - ListValue.prototype.func = $util.emptyArray; - - ListValue.decode = function decode(r, l) { - if (!(r instanceof $Reader)) - r = $Reader.create(r); - var c = l === undefined ? r.len : r.pos + l, m = new $root.tensorflow.AttrValue.ListValue(); - while (r.pos < c) { - var t = r.uint32(); - switch (t >>> 3) { - case 2: - if (!(m.s && m.s.length)) - m.s = []; - m.s.push(r.bytes()); - break; - case 3: - if (!(m.i && m.i.length)) - m.i = []; - if ((t & 7) === 2) { - var c2 = r.uint32() + r.pos; - while (r.pos < c2) - m.i.push(r.int64()); - } else - m.i.push(r.int64()); - break; - case 4: - if (!(m.f && m.f.length)) - m.f = []; - if ((t & 7) === 2) { - var c2 = r.uint32() + r.pos; - while (r.pos < c2) - m.f.push(r.float()); - } else - m.f.push(r.float()); - break; - case 5: - if (!(m.b && m.b.length)) - m.b = []; - if ((t & 7) === 2) { - var c2 = r.uint32() + r.pos; - while (r.pos < c2) - m.b.push(r.bool()); - } else - m.b.push(r.bool()); - break; - case 6: - if (!(m.type && m.type.length)) - m.type = []; - if ((t & 7) === 2) { - var c2 = r.uint32() + r.pos; - while (r.pos < c2) - m.type.push(r.int32()); - } else - m.type.push(r.int32()); - break; - case 7: - if (!(m.shape && m.shape.length)) - m.shape = []; - m.shape.push($root.tensorflow.TensorShape.decode(r, r.uint32())); - break; - case 8: - if (!(m.tensor && m.tensor.length)) - m.tensor = []; - m.tensor.push($root.tensorflow.Tensor.decode(r, r.uint32())); - break; - case 9: - if (!(m.func && m.func.length)) - m.func = []; - m.func.push($root.tensorflow.NameAttrList.decode(r, r.uint32())); - break; - default: - r.skipType(t & 7); - break; - } - } - return m; - }; - - return ListValue; - })(); - - return AttrValue; - })(); - - tensorflow.NameAttrList = (function() { - - function NameAttrList(p) { - this.attr = {}; - if (p) - for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) - if (p[ks[i]] != null) - this[ks[i]] = p[ks[i]]; - } - - NameAttrList.prototype.name = ""; - NameAttrList.prototype.attr = $util.emptyObject; - - NameAttrList.decode = function decode(r, l) { - if (!(r instanceof $Reader)) - r = $Reader.create(r); - var c = l === undefined ? r.len : r.pos + l, m = new $root.tensorflow.NameAttrList(), k; - while (r.pos < c) { - var t = r.uint32(); - switch (t >>> 3) { - case 1: - m.name = r.string(); - break; - case 2: - r.skip().pos++; - if (m.attr === $util.emptyObject) - m.attr = {}; - k = r.string(); - r.pos++; - m.attr[k] = $root.tensorflow.AttrValue.decode(r, r.uint32()); - break; - default: - r.skipType(t & 7); - break; - } - } - return m; - }; - - return NameAttrList; - })(); - - tensorflow.NodeDef = (function() { - - function NodeDef(p) { - this.input = []; - this.attr = {}; - if (p) - for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) - if (p[ks[i]] != null) - this[ks[i]] = p[ks[i]]; - } - - NodeDef.prototype.name = ""; - NodeDef.prototype.op = ""; - NodeDef.prototype.input = $util.emptyArray; - NodeDef.prototype.device = ""; - NodeDef.prototype.attr = $util.emptyObject; - - NodeDef.decode = function decode(r, l) { - if (!(r instanceof $Reader)) - r = $Reader.create(r); - var c = l === undefined ? r.len : r.pos + l, m = new $root.tensorflow.NodeDef(), k; - while (r.pos < c) { - var t = r.uint32(); - switch (t >>> 3) { - case 1: - m.name = r.string(); - break; - case 2: - m.op = r.string(); - break; - case 3: - if (!(m.input && m.input.length)) - m.input = []; - m.input.push(r.string()); - break; - case 4: - m.device = r.string(); - break; - case 5: - r.skip().pos++; - if (m.attr === $util.emptyObject) - m.attr = {}; - k = r.string(); - r.pos++; - m.attr[k] = $root.tensorflow.AttrValue.decode(r, r.uint32()); - break; - default: - r.skipType(t & 7); - break; - } - } - return m; - }; - - return NodeDef; - })(); - - tensorflow.VersionDef = (function() { - - function VersionDef(p) { - this.badConsumers = []; - if (p) - for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) - if (p[ks[i]] != null) - this[ks[i]] = p[ks[i]]; - } - - VersionDef.prototype.producer = 0; - VersionDef.prototype.minConsumer = 0; - VersionDef.prototype.badConsumers = $util.emptyArray; - - VersionDef.decode = function decode(r, l) { - if (!(r instanceof $Reader)) - r = $Reader.create(r); - var c = l === undefined ? r.len : r.pos + l, m = new $root.tensorflow.VersionDef(); - while (r.pos < c) { - var t = r.uint32(); - switch (t >>> 3) { - case 1: - m.producer = r.int32(); - break; - case 2: - m.minConsumer = r.int32(); - break; - case 3: - if (!(m.badConsumers && m.badConsumers.length)) - m.badConsumers = []; - if ((t & 7) === 2) { - var c2 = r.uint32() + r.pos; - while (r.pos < c2) - m.badConsumers.push(r.int32()); - } else - m.badConsumers.push(r.int32()); - break; - default: - r.skipType(t & 7); - break; - } - } - return m; - }; - - return VersionDef; - })(); - - tensorflow.GraphDef = (function() { - - function GraphDef(p) { - this.node = []; - if (p) - for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) - if (p[ks[i]] != null) - this[ks[i]] = p[ks[i]]; - } - - GraphDef.prototype.node = $util.emptyArray; - GraphDef.prototype.versions = null; - GraphDef.prototype.library = null; - - GraphDef.decode = function decode(r, l) { - if (!(r instanceof $Reader)) - r = $Reader.create(r); - var c = l === undefined ? r.len : r.pos + l, m = new $root.tensorflow.GraphDef(); - while (r.pos < c) { - var t = r.uint32(); - switch (t >>> 3) { - case 1: - if (!(m.node && m.node.length)) - m.node = []; - m.node.push($root.tensorflow.NodeDef.decode(r, r.uint32())); - break; - case 4: - m.versions = $root.tensorflow.VersionDef.decode(r, r.uint32()); - break; - case 2: - m.library = $root.tensorflow.FunctionDefLibrary.decode(r, r.uint32()); - break; - default: - r.skipType(t & 7); - break; - } - } - return m; - }; - - return GraphDef; - })(); - - tensorflow.CollectionDef = (function() { - - function CollectionDef(p) { - if (p) - for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) - if (p[ks[i]] != null) - this[ks[i]] = p[ks[i]]; - } - - CollectionDef.prototype.nodeList = null; - CollectionDef.prototype.bytesList = null; - CollectionDef.prototype.int64List = null; - CollectionDef.prototype.floatList = null; - CollectionDef.prototype.anyList = null; - - var $oneOfFields; - - Object.defineProperty(CollectionDef.prototype, "kind", { - get: $util.oneOfGetter($oneOfFields = ["nodeList", "bytesList", "int64List", "floatList", "anyList"]), - set: $util.oneOfSetter($oneOfFields) - }); - - CollectionDef.decode = function decode(r, l) { - if (!(r instanceof $Reader)) - r = $Reader.create(r); - var c = l === undefined ? r.len : r.pos + l, m = new $root.tensorflow.CollectionDef(); - while (r.pos < c) { - var t = r.uint32(); - switch (t >>> 3) { - case 1: - m.nodeList = $root.tensorflow.CollectionDef.NodeList.decode(r, r.uint32()); - break; - case 2: - m.bytesList = $root.tensorflow.CollectionDef.BytesList.decode(r, r.uint32()); - break; - case 3: - m.int64List = $root.tensorflow.CollectionDef.Int64List.decode(r, r.uint32()); - break; - case 4: - m.floatList = $root.tensorflow.CollectionDef.FloatList.decode(r, r.uint32()); - break; - case 5: - m.anyList = $root.tensorflow.CollectionDef.AnyList.decode(r, r.uint32()); - break; - default: - r.skipType(t & 7); - break; - } - } - return m; - }; - - CollectionDef.NodeList = (function() { - - function NodeList(p) { - this.value = []; - if (p) - for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) - if (p[ks[i]] != null) - this[ks[i]] = p[ks[i]]; - } - - NodeList.prototype.value = $util.emptyArray; - - NodeList.decode = function decode(r, l) { - if (!(r instanceof $Reader)) - r = $Reader.create(r); - var c = l === undefined ? r.len : r.pos + l, m = new $root.tensorflow.CollectionDef.NodeList(); - while (r.pos < c) { - var t = r.uint32(); - switch (t >>> 3) { - case 1: - if (!(m.value && m.value.length)) - m.value = []; - m.value.push(r.string()); - break; - default: - r.skipType(t & 7); - break; - } - } - return m; - }; - - return NodeList; - })(); - - CollectionDef.BytesList = (function() { - - function BytesList(p) { - this.value = []; - if (p) - for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) - if (p[ks[i]] != null) - this[ks[i]] = p[ks[i]]; - } - - BytesList.prototype.value = $util.emptyArray; - - BytesList.decode = function decode(r, l) { - if (!(r instanceof $Reader)) - r = $Reader.create(r); - var c = l === undefined ? r.len : r.pos + l, m = new $root.tensorflow.CollectionDef.BytesList(); - while (r.pos < c) { - var t = r.uint32(); - switch (t >>> 3) { - case 1: - if (!(m.value && m.value.length)) - m.value = []; - m.value.push(r.bytes()); - break; - default: - r.skipType(t & 7); - break; - } - } - return m; - }; - - return BytesList; - })(); - - CollectionDef.Int64List = (function() { - - function Int64List(p) { - this.value = []; - if (p) - for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) - if (p[ks[i]] != null) - this[ks[i]] = p[ks[i]]; - } - - Int64List.prototype.value = $util.emptyArray; - - Int64List.decode = function decode(r, l) { - if (!(r instanceof $Reader)) - r = $Reader.create(r); - var c = l === undefined ? r.len : r.pos + l, m = new $root.tensorflow.CollectionDef.Int64List(); - while (r.pos < c) { - var t = r.uint32(); - switch (t >>> 3) { - case 1: - if (!(m.value && m.value.length)) - m.value = []; - if ((t & 7) === 2) { - var c2 = r.uint32() + r.pos; - while (r.pos < c2) - m.value.push(r.int64()); - } else - m.value.push(r.int64()); - break; - default: - r.skipType(t & 7); - break; - } - } - return m; - }; - - return Int64List; - })(); - - CollectionDef.FloatList = (function() { - - function FloatList(p) { - this.value = []; - if (p) - for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) - if (p[ks[i]] != null) - this[ks[i]] = p[ks[i]]; - } - - FloatList.prototype.value = $util.emptyArray; - - FloatList.decode = function decode(r, l) { - if (!(r instanceof $Reader)) - r = $Reader.create(r); - var c = l === undefined ? r.len : r.pos + l, m = new $root.tensorflow.CollectionDef.FloatList(); - while (r.pos < c) { - var t = r.uint32(); - switch (t >>> 3) { - case 1: - if (!(m.value && m.value.length)) - m.value = []; - if ((t & 7) === 2) { - var c2 = r.uint32() + r.pos; - while (r.pos < c2) - m.value.push(r.float()); - } else - m.value.push(r.float()); - break; - default: - r.skipType(t & 7); - break; - } - } - return m; - }; - - return FloatList; - })(); - - CollectionDef.AnyList = (function() { - - function AnyList(p) { - this.value = []; - if (p) - for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) - if (p[ks[i]] != null) - this[ks[i]] = p[ks[i]]; - } - - AnyList.prototype.value = $util.emptyArray; - - AnyList.decode = function decode(r, l) { - if (!(r instanceof $Reader)) - r = $Reader.create(r); - var c = l === undefined ? r.len : r.pos + l, m = new $root.tensorflow.CollectionDef.AnyList(); - while (r.pos < c) { - var t = r.uint32(); - switch (t >>> 3) { - case 1: - if (!(m.value && m.value.length)) - m.value = []; - m.value.push($root.tensorflow.Any.decode(r, r.uint32())); - break; - default: - r.skipType(t & 7); - break; - } - } - return m; - }; - - return AnyList; - })(); - - return CollectionDef; - })(); - - tensorflow.SaverDef = (function() { - - function SaverDef(p) { - if (p) - for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) - if (p[ks[i]] != null) - this[ks[i]] = p[ks[i]]; - } - - SaverDef.prototype.filenameTensorName = ""; - SaverDef.prototype.saveTensorName = ""; - SaverDef.prototype.restoreOpName = ""; - SaverDef.prototype.maxToKeep = 0; - SaverDef.prototype.sharded = false; - SaverDef.prototype.keepCheckpointEveryNHours = 0; - SaverDef.prototype.version = 0; - - SaverDef.decode = function decode(r, l) { - if (!(r instanceof $Reader)) - r = $Reader.create(r); - var c = l === undefined ? r.len : r.pos + l, m = new $root.tensorflow.SaverDef(); - while (r.pos < c) { - var t = r.uint32(); - switch (t >>> 3) { - case 1: - m.filenameTensorName = r.string(); - break; - case 2: - m.saveTensorName = r.string(); - break; - case 3: - m.restoreOpName = r.string(); - break; - case 4: - m.maxToKeep = r.int32(); - break; - case 5: - m.sharded = r.bool(); - break; - case 6: - m.keepCheckpointEveryNHours = r.float(); - break; - case 7: - m.version = r.int32(); - break; - default: - r.skipType(t & 7); - break; - } - } - return m; - }; - - SaverDef.CheckpointFormatVersion = (function() { - var valuesById = {}, values = Object.create(valuesById); - values[valuesById[0] = "LEGACY"] = 0; - values[valuesById[1] = "V1"] = 1; - values[valuesById[2] = "V2"] = 2; - return values; - })(); - - return SaverDef; - })(); - - tensorflow.TensorInfo = (function() { - - function TensorInfo(p) { - if (p) - for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) - if (p[ks[i]] != null) - this[ks[i]] = p[ks[i]]; - } - - TensorInfo.prototype.name = ""; - TensorInfo.prototype.cooSparse = null; - TensorInfo.prototype.dtype = 0; - TensorInfo.prototype.tensorShape = null; - - var $oneOfFields; - - Object.defineProperty(TensorInfo.prototype, "encoding", { - get: $util.oneOfGetter($oneOfFields = ["name", "cooSparse"]), - set: $util.oneOfSetter($oneOfFields) - }); - - TensorInfo.decode = function decode(r, l) { - if (!(r instanceof $Reader)) - r = $Reader.create(r); - var c = l === undefined ? r.len : r.pos + l, m = new $root.tensorflow.TensorInfo(); - while (r.pos < c) { - var t = r.uint32(); - switch (t >>> 3) { - case 1: - m.name = r.string(); - break; - case 4: - m.cooSparse = $root.tensorflow.TensorInfo.CooSparse.decode(r, r.uint32()); - break; - case 2: - m.dtype = r.int32(); - break; - case 3: - m.tensorShape = $root.tensorflow.TensorShape.decode(r, r.uint32()); - break; - default: - r.skipType(t & 7); - break; - } - } - return m; - }; - - TensorInfo.CooSparse = (function() { - - function CooSparse(p) { - if (p) - for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) - if (p[ks[i]] != null) - this[ks[i]] = p[ks[i]]; - } - - CooSparse.prototype.valuesTensorName = ""; - CooSparse.prototype.indicesTensorName = ""; - CooSparse.prototype.denseShapeTensorName = ""; - - CooSparse.decode = function decode(r, l) { - if (!(r instanceof $Reader)) - r = $Reader.create(r); - var c = l === undefined ? r.len : r.pos + l, m = new $root.tensorflow.TensorInfo.CooSparse(); - while (r.pos < c) { - var t = r.uint32(); - switch (t >>> 3) { - case 1: - m.valuesTensorName = r.string(); - break; - case 2: - m.indicesTensorName = r.string(); - break; - case 3: - m.denseShapeTensorName = r.string(); - break; - default: - r.skipType(t & 7); - break; - } - } - return m; - }; - - return CooSparse; - })(); - - return TensorInfo; - })(); - - tensorflow.SignatureDef = (function() { - - function SignatureDef(p) { - this.inputs = {}; - this.outputs = {}; - if (p) - for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) - if (p[ks[i]] != null) - this[ks[i]] = p[ks[i]]; - } - - SignatureDef.prototype.inputs = $util.emptyObject; - SignatureDef.prototype.outputs = $util.emptyObject; - SignatureDef.prototype.methodName = ""; - - SignatureDef.decode = function decode(r, l) { - if (!(r instanceof $Reader)) - r = $Reader.create(r); - var c = l === undefined ? r.len : r.pos + l, m = new $root.tensorflow.SignatureDef(), k; - while (r.pos < c) { - var t = r.uint32(); - switch (t >>> 3) { - case 1: - r.skip().pos++; - if (m.inputs === $util.emptyObject) - m.inputs = {}; - k = r.string(); - r.pos++; - m.inputs[k] = $root.tensorflow.TensorInfo.decode(r, r.uint32()); - break; - case 2: - r.skip().pos++; - if (m.outputs === $util.emptyObject) - m.outputs = {}; - k = r.string(); - r.pos++; - m.outputs[k] = $root.tensorflow.TensorInfo.decode(r, r.uint32()); - break; - case 3: - m.methodName = r.string(); - break; - default: - r.skipType(t & 7); - break; - } - } - return m; - }; - - return SignatureDef; - })(); - - tensorflow.AssetFileDef = (function() { - - function AssetFileDef(p) { - if (p) - for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) - if (p[ks[i]] != null) - this[ks[i]] = p[ks[i]]; - } - - AssetFileDef.prototype.tensorInfo = null; - AssetFileDef.prototype.filename = ""; - - AssetFileDef.decode = function decode(r, l) { - if (!(r instanceof $Reader)) - r = $Reader.create(r); - var c = l === undefined ? r.len : r.pos + l, m = new $root.tensorflow.AssetFileDef(); - while (r.pos < c) { - var t = r.uint32(); - switch (t >>> 3) { - case 1: - m.tensorInfo = $root.tensorflow.TensorInfo.decode(r, r.uint32()); - break; - case 2: - m.filename = r.string(); - break; - default: - r.skipType(t & 7); - break; - } - } - return m; - }; - - return AssetFileDef; - })(); - - tensorflow.OpDef = (function() { - - function OpDef(p) { - this.inputArg = []; - this.outputArg = []; - this.attr = []; - if (p) - for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) - if (p[ks[i]] != null) - this[ks[i]] = p[ks[i]]; - } - - OpDef.prototype.name = ""; - OpDef.prototype.inputArg = $util.emptyArray; - OpDef.prototype.outputArg = $util.emptyArray; - OpDef.prototype.attr = $util.emptyArray; - OpDef.prototype.deprecation = null; - OpDef.prototype.summary = ""; - OpDef.prototype.description = ""; - OpDef.prototype.isCommutative = false; - OpDef.prototype.isAggregate = false; - OpDef.prototype.isStateful = false; - OpDef.prototype.allowsUninitializedInput = false; - - OpDef.decode = function decode(r, l) { - if (!(r instanceof $Reader)) - r = $Reader.create(r); - var c = l === undefined ? r.len : r.pos + l, m = new $root.tensorflow.OpDef(); - while (r.pos < c) { - var t = r.uint32(); - switch (t >>> 3) { - case 1: - m.name = r.string(); - break; - case 2: - if (!(m.inputArg && m.inputArg.length)) - m.inputArg = []; - m.inputArg.push($root.tensorflow.OpDef.ArgDef.decode(r, r.uint32())); - break; - case 3: - if (!(m.outputArg && m.outputArg.length)) - m.outputArg = []; - m.outputArg.push($root.tensorflow.OpDef.ArgDef.decode(r, r.uint32())); - break; - case 4: - if (!(m.attr && m.attr.length)) - m.attr = []; - m.attr.push($root.tensorflow.OpDef.AttrDef.decode(r, r.uint32())); - break; - case 8: - m.deprecation = $root.tensorflow.OpDef.OpDeprecation.decode(r, r.uint32()); - break; - case 5: - m.summary = r.string(); - break; - case 6: - m.description = r.string(); - break; - case 18: - m.isCommutative = r.bool(); - break; - case 16: - m.isAggregate = r.bool(); - break; - case 17: - m.isStateful = r.bool(); - break; - case 19: - m.allowsUninitializedInput = r.bool(); - break; - default: - r.skipType(t & 7); - break; - } - } - return m; - }; - - OpDef.ArgDef = (function() { - - function ArgDef(p) { - if (p) - for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) - if (p[ks[i]] != null) - this[ks[i]] = p[ks[i]]; - } - - ArgDef.prototype.name = ""; - ArgDef.prototype.description = ""; - ArgDef.prototype.type = 0; - ArgDef.prototype.typeAttr = ""; - ArgDef.prototype.numberAttr = ""; - ArgDef.prototype.typeListAttr = ""; - ArgDef.prototype.isRef = false; - - ArgDef.decode = function decode(r, l) { - if (!(r instanceof $Reader)) - r = $Reader.create(r); - var c = l === undefined ? r.len : r.pos + l, m = new $root.tensorflow.OpDef.ArgDef(); - while (r.pos < c) { - var t = r.uint32(); - switch (t >>> 3) { - case 1: - m.name = r.string(); - break; - case 2: - m.description = r.string(); - break; - case 3: - m.type = r.int32(); - break; - case 4: - m.typeAttr = r.string(); - break; - case 5: - m.numberAttr = r.string(); - break; - case 6: - m.typeListAttr = r.string(); - break; - case 16: - m.isRef = r.bool(); - break; - default: - r.skipType(t & 7); - break; - } - } - return m; - }; - - return ArgDef; - })(); - - OpDef.AttrDef = (function() { - - function AttrDef(p) { - if (p) - for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) - if (p[ks[i]] != null) - this[ks[i]] = p[ks[i]]; - } - - AttrDef.prototype.name = ""; - AttrDef.prototype.type = ""; - AttrDef.prototype.defaultValue = null; - AttrDef.prototype.description = ""; - AttrDef.prototype.hasMinimum = false; - AttrDef.prototype.minimum = $util.Long ? $util.Long.fromBits(0,0,false) : 0; - AttrDef.prototype.allowedValues = null; - - AttrDef.decode = function decode(r, l) { - if (!(r instanceof $Reader)) - r = $Reader.create(r); - var c = l === undefined ? r.len : r.pos + l, m = new $root.tensorflow.OpDef.AttrDef(); - while (r.pos < c) { - var t = r.uint32(); - switch (t >>> 3) { - case 1: - m.name = r.string(); - break; - case 2: - m.type = r.string(); - break; - case 3: - m.defaultValue = $root.tensorflow.AttrValue.decode(r, r.uint32()); - break; - case 4: - m.description = r.string(); - break; - case 5: - m.hasMinimum = r.bool(); - break; - case 6: - m.minimum = r.int64(); - break; - case 7: - m.allowedValues = $root.tensorflow.AttrValue.decode(r, r.uint32()); - break; - default: - r.skipType(t & 7); - break; - } - } - return m; - }; - - return AttrDef; - })(); - - OpDef.OpDeprecation = (function() { - - function OpDeprecation(p) { - if (p) - for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) - if (p[ks[i]] != null) - this[ks[i]] = p[ks[i]]; - } - - OpDeprecation.prototype.version = 0; - OpDeprecation.prototype.explanation = ""; - - OpDeprecation.decode = function decode(r, l) { - if (!(r instanceof $Reader)) - r = $Reader.create(r); - var c = l === undefined ? r.len : r.pos + l, m = new $root.tensorflow.OpDef.OpDeprecation(); - while (r.pos < c) { - var t = r.uint32(); - switch (t >>> 3) { - case 1: - m.version = r.int32(); - break; - case 2: - m.explanation = r.string(); - break; - default: - r.skipType(t & 7); - break; - } - } - return m; - }; - - return OpDeprecation; - })(); - - return OpDef; - })(); - - tensorflow.OpList = (function() { - - function OpList(p) { - this.op = []; - if (p) - for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) - if (p[ks[i]] != null) - this[ks[i]] = p[ks[i]]; - } - - OpList.prototype.op = $util.emptyArray; - - OpList.decode = function decode(r, l) { - if (!(r instanceof $Reader)) - r = $Reader.create(r); - var c = l === undefined ? r.len : r.pos + l, m = new $root.tensorflow.OpList(); - while (r.pos < c) { - var t = r.uint32(); - switch (t >>> 3) { - case 1: - if (!(m.op && m.op.length)) - m.op = []; - m.op.push($root.tensorflow.OpDef.decode(r, r.uint32())); - break; - default: - r.skipType(t & 7); - break; - } - } - return m; - }; - - return OpList; - })(); - - tensorflow.MetaGraphDef = (function() { - - function MetaGraphDef(p) { - this.collectionDef = {}; - this.signatureDef = {}; - this.assetFileDef = []; - if (p) - for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) - if (p[ks[i]] != null) - this[ks[i]] = p[ks[i]]; - } - - MetaGraphDef.prototype.metaInfoDef = null; - MetaGraphDef.prototype.graphDef = null; - MetaGraphDef.prototype.saverDef = null; - MetaGraphDef.prototype.collectionDef = $util.emptyObject; - MetaGraphDef.prototype.signatureDef = $util.emptyObject; - MetaGraphDef.prototype.assetFileDef = $util.emptyArray; - - MetaGraphDef.decode = function decode(r, l) { - if (!(r instanceof $Reader)) - r = $Reader.create(r); - var c = l === undefined ? r.len : r.pos + l, m = new $root.tensorflow.MetaGraphDef(), k; - while (r.pos < c) { - var t = r.uint32(); - switch (t >>> 3) { - case 1: - m.metaInfoDef = $root.tensorflow.MetaGraphDef.MetaInfoDef.decode(r, r.uint32()); - break; - case 2: - m.graphDef = $root.tensorflow.GraphDef.decode(r, r.uint32()); - break; - case 3: - m.saverDef = $root.tensorflow.SaverDef.decode(r, r.uint32()); - break; - case 4: - r.skip().pos++; - if (m.collectionDef === $util.emptyObject) - m.collectionDef = {}; - k = r.string(); - r.pos++; - m.collectionDef[k] = $root.tensorflow.CollectionDef.decode(r, r.uint32()); - break; - case 5: - r.skip().pos++; - if (m.signatureDef === $util.emptyObject) - m.signatureDef = {}; - k = r.string(); - r.pos++; - m.signatureDef[k] = $root.tensorflow.SignatureDef.decode(r, r.uint32()); - break; - case 6: - if (!(m.assetFileDef && m.assetFileDef.length)) - m.assetFileDef = []; - m.assetFileDef.push($root.tensorflow.AssetFileDef.decode(r, r.uint32())); - break; - default: - r.skipType(t & 7); - break; - } - } - return m; - }; - - MetaGraphDef.MetaInfoDef = (function() { - - function MetaInfoDef(p) { - this.tags = []; - if (p) - for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) - if (p[ks[i]] != null) - this[ks[i]] = p[ks[i]]; - } - - MetaInfoDef.prototype.metaGraphVersion = ""; - MetaInfoDef.prototype.strippedOpList = null; - MetaInfoDef.prototype.anyInfo = null; - MetaInfoDef.prototype.tags = $util.emptyArray; - MetaInfoDef.prototype.tensorflowVersion = ""; - MetaInfoDef.prototype.tensorflowGitVersion = ""; - - MetaInfoDef.decode = function decode(r, l) { - if (!(r instanceof $Reader)) - r = $Reader.create(r); - var c = l === undefined ? r.len : r.pos + l, m = new $root.tensorflow.MetaGraphDef.MetaInfoDef(); - while (r.pos < c) { - var t = r.uint32(); - switch (t >>> 3) { - case 1: - m.metaGraphVersion = r.string(); - break; - case 2: - m.strippedOpList = $root.tensorflow.OpList.decode(r, r.uint32()); - break; - case 3: - m.anyInfo = $root.tensorflow.Any.decode(r, r.uint32()); - break; - case 4: - if (!(m.tags && m.tags.length)) - m.tags = []; - m.tags.push(r.string()); - break; - case 5: - m.tensorflowVersion = r.string(); - break; - case 6: - m.tensorflowGitVersion = r.string(); - break; - default: - r.skipType(t & 7); - break; - } - } - return m; - }; - - return MetaInfoDef; - })(); - - return MetaGraphDef; - })(); - - tensorflow.SavedModel = (function() { - - function SavedModel(p) { - this.metaGraphs = []; - if (p) - for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) - if (p[ks[i]] != null) - this[ks[i]] = p[ks[i]]; - } - - SavedModel.prototype.savedModelSchemaVersion = $util.Long ? $util.Long.fromBits(0,0,false) : 0; - SavedModel.prototype.metaGraphs = $util.emptyArray; - - SavedModel.decode = function decode(r, l) { - if (!(r instanceof $Reader)) - r = $Reader.create(r); - var c = l === undefined ? r.len : r.pos + l, m = new $root.tensorflow.SavedModel(); - while (r.pos < c) { - var t = r.uint32(); - switch (t >>> 3) { - case 1: - m.savedModelSchemaVersion = r.int64(); - break; - case 2: - if (!(m.metaGraphs && m.metaGraphs.length)) - m.metaGraphs = []; - m.metaGraphs.push($root.tensorflow.MetaGraphDef.decode(r, r.uint32())); - break; - default: - r.skipType(t & 7); - break; - } - } - return m; - }; - - return SavedModel; - })(); - - tensorflow.FunctionDefLibrary = (function() { - - function FunctionDefLibrary(p) { - this["function"] = []; - this.gradient = []; - if (p) - for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) - if (p[ks[i]] != null) - this[ks[i]] = p[ks[i]]; - } - - FunctionDefLibrary.prototype["function"] = $util.emptyArray; - FunctionDefLibrary.prototype.gradient = $util.emptyArray; - - FunctionDefLibrary.decode = function decode(r, l) { - if (!(r instanceof $Reader)) - r = $Reader.create(r); - var c = l === undefined ? r.len : r.pos + l, m = new $root.tensorflow.FunctionDefLibrary(); - while (r.pos < c) { - var t = r.uint32(); - switch (t >>> 3) { - case 1: - if (!(m["function"] && m["function"].length)) - m["function"] = []; - m["function"].push($root.tensorflow.FunctionDef.decode(r, r.uint32())); - break; - case 2: - if (!(m.gradient && m.gradient.length)) - m.gradient = []; - m.gradient.push($root.tensorflow.GradientDef.decode(r, r.uint32())); - break; - default: - r.skipType(t & 7); - break; - } - } - return m; - }; - - return FunctionDefLibrary; - })(); - - tensorflow.FunctionDef = (function() { - - function FunctionDef(p) { - this.attr = {}; - this.nodeDef = []; - this.ret = {}; - if (p) - for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) - if (p[ks[i]] != null) - this[ks[i]] = p[ks[i]]; - } - - FunctionDef.prototype.signature = null; - FunctionDef.prototype.attr = $util.emptyObject; - FunctionDef.prototype.nodeDef = $util.emptyArray; - FunctionDef.prototype.ret = $util.emptyObject; - - FunctionDef.decode = function decode(r, l) { - if (!(r instanceof $Reader)) - r = $Reader.create(r); - var c = l === undefined ? r.len : r.pos + l, m = new $root.tensorflow.FunctionDef(), k; - while (r.pos < c) { - var t = r.uint32(); - switch (t >>> 3) { - case 1: - m.signature = $root.tensorflow.OpDef.decode(r, r.uint32()); - break; - case 5: - r.skip().pos++; - if (m.attr === $util.emptyObject) - m.attr = {}; - k = r.string(); - r.pos++; - m.attr[k] = $root.tensorflow.AttrValue.decode(r, r.uint32()); - break; - case 3: - if (!(m.nodeDef && m.nodeDef.length)) - m.nodeDef = []; - m.nodeDef.push($root.tensorflow.NodeDef.decode(r, r.uint32())); - break; - case 4: - r.skip().pos++; - if (m.ret === $util.emptyObject) - m.ret = {}; - k = r.string(); - r.pos++; - m.ret[k] = r.string(); - break; - default: - r.skipType(t & 7); - break; - } - } - return m; - }; - - return FunctionDef; - })(); - - tensorflow.GradientDef = (function() { - - function GradientDef(p) { - if (p) - for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) - if (p[ks[i]] != null) - this[ks[i]] = p[ks[i]]; - } - - GradientDef.prototype.functionName = ""; - GradientDef.prototype.gradientFunc = ""; - - GradientDef.decode = function decode(r, l) { - if (!(r instanceof $Reader)) - r = $Reader.create(r); - var c = l === undefined ? r.len : r.pos + l, m = new $root.tensorflow.GradientDef(); - while (r.pos < c) { - var t = r.uint32(); - switch (t >>> 3) { - case 1: - m.functionName = r.string(); - break; - case 2: - m.gradientFunc = r.string(); - break; - default: - r.skipType(t & 7); - break; - } - } - return m; - }; - - return GradientDef; - })(); - - return tensorflow; -})(); - -module.exports = $root; diff --git a/tfjs-master/tfjs-converter/tools/model_summary.ts b/tfjs-master/tfjs-converter/tools/model_summary.ts deleted file mode 100644 index c6fddf384..000000000 --- a/tfjs-master/tfjs-converter/tools/model_summary.ts +++ /dev/null @@ -1,60 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import * as fs from 'fs'; - -function summarize(argv: string[]) { - if (argv.length < 3) { - console.log('Usage: yarn model-summary model_file'); - return; - } - - const sourcePath = process.argv[2]; - console.log('reading pb model file: ' + sourcePath); - const rawdata = fs.readFileSync(sourcePath); - const model = JSON.parse(rawdata.toString()); - if (model.format !== 'graph-model') { - console.log('This tool only supports TFJS Graph models.'); - return; - } - // tslint:disable-next-line: no-any - let nodes: any[] = model['modelTopology']['node']; - const library = model['modelTopology']['library']; - if (library != null) { - const functions = library['function']; - - // tslint:disable-next-line: no-any - if (functions != null) { - functions.forEach((func: any) => nodes = nodes.concat(func['nodeDef'])); - } - } - - const opCount: {[key: string]: number} = {}; - nodes.forEach(opNode => { - let count = 0; - const op = opNode['op']; - if (opCount[op]) { - count = opCount[op]; - } - opCount[op] = count + 1; - }); - - const keys = Object.keys(opCount).sort(); - keys.forEach(key => console.log(`${key}: ${opCount[key]}`)); - console.log(`Total ops = ${nodes.length}`); -} - -summarize(process.argv); diff --git a/tfjs-master/tfjs-converter/tools/pb2json_converter.ts b/tfjs-master/tfjs-converter/tools/pb2json_converter.ts deleted file mode 100644 index 61db9f153..000000000 --- a/tfjs-master/tfjs-converter/tools/pb2json_converter.ts +++ /dev/null @@ -1,86 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import * as fs from 'fs'; -import * as Long from 'long'; -import * as path from 'path'; - -import {tensorflow} from './compiled_api'; - -function replacer(key: string, value: any) { - if (value instanceof Long) { - return (value as Long).toString(); - } - if (value instanceof Uint8Array) { - return Array.from(value); - } - return value; -} -const PB_MODEL_FILENAME = 'tensorflowjs_model.pb'; -const WEIGHT_FILENAME = 'weights_manifest.json'; -const JSON_MODEL_FILENAME = 'model.json'; -function convert(argv: string[]) { - if (argv.length < 4) { - console.log( - 'Usage: ts-node pb2json.ts pb_model_directory json_model_directory'); - return; - } - - const sourcePath = process.argv[2]; - console.log('reading pb model directory: ' + sourcePath); - fs.readdir(sourcePath, (err, files) => { - if (![PB_MODEL_FILENAME, WEIGHT_FILENAME].every( - file => files.indexOf(file) !== -1)) { - console.log( - 'Please make sure the pb model directory contains ' + - 'tensorflowjs_model.pb and weights_manifest.json files.'); - return; - } - - const modelFile = path.join(sourcePath, PB_MODEL_FILENAME); - console.log('reading pb file: ' + modelFile); - const buffer = fs.readFileSync(modelFile); - - const modelTopology = tensorflow.GraphDef.decode(new Uint8Array(buffer)); - - const manifestFile = path.join(sourcePath, WEIGHT_FILENAME); - console.log('reading manifest file: ' + manifestFile); - const weightsManifest = JSON.parse(fs.readFileSync(manifestFile, 'utf8')); - - const destPath = process.argv[3]; - - if (!fs.existsSync(destPath)) { - fs.mkdirSync(destPath); - } - const destModelFile = path.join(destPath, JSON_MODEL_FILENAME); - console.log('writing json file: ' + destModelFile); - fs.writeFileSync( - destModelFile, - JSON.stringify({modelTopology, weightsManifest}, replacer)); - - files.forEach(file => { - if (file !== PB_MODEL_FILENAME && file !== WEIGHT_FILENAME) { - fs.copyFile( - path.join(sourcePath, file), path.join(destPath, file), (err) => { - if (err) throw err; - console.log(`Weight file: ${file} copied.`); - }); - } - }); - }); -} - -convert(process.argv); diff --git a/tfjs-master/tfjs-converter/tools/tsconfig.json b/tfjs-master/tfjs-converter/tools/tsconfig.json deleted file mode 100644 index dcad96028..000000000 --- a/tfjs-master/tfjs-converter/tools/tsconfig.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "extends": "../tsconfig", - "compilerOptions": { - "module": "commonjs", - "target": "es5" - } -} diff --git a/tfjs-master/tfjs-converter/tsconfig.json b/tfjs-master/tfjs-converter/tsconfig.json deleted file mode 100644 index 5ea8addec..000000000 --- a/tfjs-master/tfjs-converter/tsconfig.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "extends": "../tsconfig", - "include": [ - "src/" - ], - "exclude": [ - "node_modules/" - ], - "compilerOptions": { - "outDir": "./dist", - "downlevelIteration": true - } -} diff --git a/tfjs-master/tfjs-converter/yarn.lock b/tfjs-master/tfjs-converter/yarn.lock deleted file mode 100644 index a0535ff08..000000000 --- a/tfjs-master/tfjs-converter/yarn.lock +++ /dev/null @@ -1,507 +0,0 @@ -# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. -# yarn lockfile v1 - - -"@bazel/bazelisk@^1.12.0": - version "1.12.0" - resolved "https://registry.yarnpkg.com/@bazel/bazelisk/-/bazelisk-1.12.0.tgz#f08aebbf4afcb12684422450b0845dd6ef5cfe50" - integrity sha512-7oQusq1e4AIyFgotxVV7Pc40Et0QyvoVjujL+7/qV5Vrbfh0Nj3CfqSgl63weEyI4r0+K6RlGVsjfRuBi05p5w== - -"@bazel/ibazel@^0.16.2": - version "0.16.2" - resolved "https://registry.yarnpkg.com/@bazel/ibazel/-/ibazel-0.16.2.tgz#05dd7f06659759fda30f87b15534f1e42f1201bb" - integrity sha512-KgqAWMH0emL6f3xH6nqyTryoBMqlJ627LBIe9PT1PRRQPz2FtHib3FIHJPukp1slzF3hJYZvdiVwgPnHbaSOOA== - -"@protobufjs/aspromise@^1.1.1", "@protobufjs/aspromise@^1.1.2": - version "1.1.2" - resolved "https://registry.yarnpkg.com/@protobufjs/aspromise/-/aspromise-1.1.2.tgz#9b8b0cc663d669a7d8f6f5d0893a14d348f30fbf" - integrity sha1-m4sMxmPWaafY9vXQiToU00jzD78= - -"@protobufjs/base64@^1.1.2": - version "1.1.2" - resolved "https://registry.yarnpkg.com/@protobufjs/base64/-/base64-1.1.2.tgz#4c85730e59b9a1f1f349047dbf24296034bb2735" - integrity sha512-AZkcAA5vnN/v4PDqKyMR5lx7hZttPDgClv83E//FMNhR2TMcLUhfRUBHCmSl0oi9zMgDDqRUJkSxO3wm85+XLg== - -"@protobufjs/codegen@^2.0.4": - version "2.0.4" - resolved "https://registry.yarnpkg.com/@protobufjs/codegen/-/codegen-2.0.4.tgz#7ef37f0d010fb028ad1ad59722e506d9262815cb" - integrity sha512-YyFaikqM5sH0ziFZCN3xDC7zeGaB/d0IUb9CATugHWbd1FRFwWwt4ld4OYMPWu5a3Xe01mGAULCdqhMlPl29Jg== - -"@protobufjs/eventemitter@^1.1.0": - version "1.1.0" - resolved "https://registry.yarnpkg.com/@protobufjs/eventemitter/-/eventemitter-1.1.0.tgz#355cbc98bafad5978f9ed095f397621f1d066b70" - integrity sha1-NVy8mLr61ZePntCV85diHx0Ga3A= - -"@protobufjs/fetch@^1.1.0": - version "1.1.0" - resolved "https://registry.yarnpkg.com/@protobufjs/fetch/-/fetch-1.1.0.tgz#ba99fb598614af65700c1619ff06d454b0d84c45" - integrity sha1-upn7WYYUr2VwDBYZ/wbUVLDYTEU= - dependencies: - "@protobufjs/aspromise" "^1.1.1" - "@protobufjs/inquire" "^1.1.0" - -"@protobufjs/float@^1.0.2": - version "1.0.2" - resolved "https://registry.yarnpkg.com/@protobufjs/float/-/float-1.0.2.tgz#5e9e1abdcb73fc0a7cb8b291df78c8cbd97b87d1" - integrity sha1-Xp4avctz/Ap8uLKR33jIy9l7h9E= - -"@protobufjs/inquire@^1.1.0": - version "1.1.0" - resolved "https://registry.yarnpkg.com/@protobufjs/inquire/-/inquire-1.1.0.tgz#ff200e3e7cf2429e2dcafc1140828e8cc638f089" - integrity sha1-/yAOPnzyQp4tyvwRQIKOjMY48Ik= - -"@protobufjs/path@^1.1.2": - version "1.1.2" - resolved "https://registry.yarnpkg.com/@protobufjs/path/-/path-1.1.2.tgz#6cc2b20c5c9ad6ad0dccfd21ca7673d8d7fbf68d" - integrity sha1-bMKyDFya1q0NzP0hynZz2Nf79o0= - -"@protobufjs/pool@^1.1.0": - version "1.1.0" - resolved "https://registry.yarnpkg.com/@protobufjs/pool/-/pool-1.1.0.tgz#09fd15f2d6d3abfa9b65bc366506d6ad7846ff54" - integrity sha1-Cf0V8tbTq/qbZbw2ZQbWrXhG/1Q= - -"@protobufjs/utf8@^1.1.0": - version "1.1.0" - resolved "https://registry.yarnpkg.com/@protobufjs/utf8/-/utf8-1.1.0.tgz#a777360b5b39a1a2e5106f8e858f2fd2d060c570" - integrity sha1-p3c2C1s5oaLlEG+OhY8v0tBgxXA= - -"@tensorflow/tfjs-backend-cpu@link:../link-package/node_modules/@tensorflow/tfjs-backend-cpu": - version "0.0.0" - -"@tensorflow/tfjs-core@link:../link-package/node_modules/@tensorflow/tfjs-core": - version "0.0.0" - -"@types/argparse@^1.0.38": - version "1.0.38" - resolved "https://registry.yarnpkg.com/@types/argparse/-/argparse-1.0.38.tgz#a81fd8606d481f873a3800c6ebae4f1d768a56a9" - integrity sha512-ebDJ9b0e702Yr7pWgB0jzm+CX4Srzz8RcXtLJDJB+BSccqMa36uyH/zUsSYao5+BD1ytv3k3rPYCq4mAE1hsXA== - -"@types/long@~3.0.32": - version "3.0.32" - resolved "https://registry.yarnpkg.com/@types/long/-/long-3.0.32.tgz#f4e5af31e9e9b196d8e5fca8a5e2e20aa3d60b69" - integrity sha512-ZXyOOm83p7X8p3s0IYM3VeueNmHpkk/yMlP8CLeOnEcu6hIwPH7YjZBvhQkR0ZFS2DqZAxKtJ/M5fcuv3OU5BA== - -"@types/node-fetch@1.6.9": - version "1.6.9" - resolved "https://registry.yarnpkg.com/@types/node-fetch/-/node-fetch-1.6.9.tgz#a750fb0f4cf2960bf72b462e4c86908022dd69c5" - integrity sha512-n2r6WLoY7+uuPT7pnEtKJCmPUGyJ+cbyBR8Avnu4+m1nzz7DwBVuyIvvlBzCZ/nrpC7rIgb3D6pNavL7rFEa9g== - dependencies: - "@types/node" "*" - -"@types/node@*", "@types/node@>=13.7.0": - version "17.0.38" - resolved "https://registry.yarnpkg.com/@types/node/-/node-17.0.38.tgz#f8bb07c371ccb1903f3752872c89f44006132947" - integrity sha512-5jY9RhV7c0Z4Jy09G+NIDTsCZ5G0L5n+Z+p+Y7t5VJHM30bgwzSjVtlcBxqAj+6L/swIlvtOSzr8rBk/aNyV2g== - -ansi-regex@^5.0.1: - version "5.0.1" - resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.1.tgz#082cb2c89c9fe8659a311a53bd6a4dc5301db304" - integrity sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ== - -ansi-styles@^4.0.0, ansi-styles@^4.1.0: - version "4.3.0" - resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-4.3.0.tgz#edd803628ae71c04c85ae7a0906edad34b648937" - integrity sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg== - dependencies: - color-convert "^2.0.1" - -arg@^4.1.0: - version "4.1.3" - resolved "https://registry.yarnpkg.com/arg/-/arg-4.1.3.tgz#269fc7ad5b8e42cb63c896d5666017261c144089" - integrity sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA== - -argparse@^1.0.10: - version "1.0.10" - resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911" - integrity sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg== - dependencies: - sprintf-js "~1.0.2" - -balanced-match@^1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee" - integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw== - -brace-expansion@^1.1.7: - version "1.1.11" - resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" - integrity sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA== - dependencies: - balanced-match "^1.0.0" - concat-map "0.0.1" - -buffer-from@^1.0.0: - version "1.1.1" - resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef" - integrity sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A== - -chalk@^4.1.0: - version "4.1.2" - resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01" - integrity sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA== - dependencies: - ansi-styles "^4.1.0" - supports-color "^7.1.0" - -cliui@^7.0.2: - version "7.0.4" - resolved "https://registry.yarnpkg.com/cliui/-/cliui-7.0.4.tgz#a0265ee655476fc807aea9df3df8df7783808b4f" - integrity sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ== - dependencies: - string-width "^4.2.0" - strip-ansi "^6.0.0" - wrap-ansi "^7.0.0" - -color-convert@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-2.0.1.tgz#72d3a68d598c9bdb3af2ad1e84f21d896abd4de3" - integrity sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ== - dependencies: - color-name "~1.1.4" - -color-name@~1.1.4: - version "1.1.4" - resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2" - integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA== - -concat-map@0.0.1: - version "0.0.1" - resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" - integrity sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg== - -detect-indent@^6.0.0: - version "6.1.0" - resolved "https://registry.yarnpkg.com/detect-indent/-/detect-indent-6.1.0.tgz#592485ebbbf6b3b1ab2be175c8393d04ca0d57e6" - integrity sha512-reYkTUJAZb9gUuZ2RvVCNhVHdg62RHnJ7WJl8ftMi4diZ6NWlciOzQN88pUhSELEwflJht4oQDv0F0BMlwaYtA== - -diff@^4.0.1: - version "4.0.2" - resolved "https://registry.yarnpkg.com/diff/-/diff-4.0.2.tgz#60f3aecb89d5fae520c11aa19efc2bb982aade7d" - integrity sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A== - -emoji-regex@^8.0.0: - version "8.0.0" - resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37" - integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A== - -escalade@^3.1.1: - version "3.1.1" - resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.1.1.tgz#d8cfdc7000965c5a0174b4a82eaa5c0552742e40" - integrity sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw== - -fs-extra@^8.0.1: - version "8.1.0" - resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-8.1.0.tgz#49d43c45a88cd9677668cb7be1b46efdb8d2e1c0" - integrity sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g== - dependencies: - graceful-fs "^4.2.0" - jsonfile "^4.0.0" - universalify "^0.1.0" - -fs.realpath@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" - integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw== - -get-caller-file@^2.0.5: - version "2.0.5" - resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e" - integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg== - -glob@^7.1.4, glob@^7.1.6: - version "7.2.3" - resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.3.tgz#b8df0fb802bbfa8e89bd1d938b4e16578ed44f2b" - integrity sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q== - dependencies: - fs.realpath "^1.0.0" - inflight "^1.0.4" - inherits "2" - minimatch "^3.1.1" - once "^1.3.0" - path-is-absolute "^1.0.0" - -graceful-fs@^4.1.6, graceful-fs@^4.2.0: - version "4.2.10" - resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.10.tgz#147d3a006da4ca3ce14728c7aefc287c367d7a6c" - integrity sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA== - -has-flag@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b" - integrity sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ== - -ignore-walk@^3.0.3: - version "3.0.4" - resolved "https://registry.yarnpkg.com/ignore-walk/-/ignore-walk-3.0.4.tgz#c9a09f69b7c7b479a5d74ac1a3c0d4236d2a6335" - integrity sha512-PY6Ii8o1jMRA1z4F2hRkH/xN59ox43DavKvD3oDpfurRlOJyAHpifIwpbdv1n4jt4ov0jSpw3kQ4GhJnpBL6WQ== - dependencies: - minimatch "^3.0.4" - -ignore@^5.0.4: - version "5.2.0" - resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.2.0.tgz#6d3bac8fa7fe0d45d9f9be7bac2fc279577e345a" - integrity sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ== - -inflight@^1.0.4: - version "1.0.6" - resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" - integrity sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA== - dependencies: - once "^1.3.0" - wrappy "1" - -inherits@2: - version "2.0.4" - resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" - integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== - -ini@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/ini/-/ini-2.0.0.tgz#e5fd556ecdd5726be978fa1001862eacb0a94bc5" - integrity sha512-7PnF4oN3CvZF23ADhA5wRaYEQpJ8qygSkbtTXWBeXWXmEVRXK+1ITciHWwHhsjv1TmW0MgacIv6hEi5pX5NQdA== - -is-fullwidth-code-point@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz#f116f8064fe90b3f7844a38997c0b75051269f1d" - integrity sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg== - -is-wsl@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/is-wsl/-/is-wsl-1.1.0.tgz#1f16e4aa22b04d1336b66188a66af3c600c3a66d" - integrity sha1-HxbkqiKwTRM2tmGIpmrzxgDDpm0= - -jsonfile@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-4.0.0.tgz#8771aae0799b64076b76640fca058f9c10e33ecb" - integrity sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg== - optionalDependencies: - graceful-fs "^4.1.6" - -long@^5.0.0: - version "5.2.3" - resolved "https://registry.yarnpkg.com/long/-/long-5.2.3.tgz#a3ba97f3877cf1d778eccbcb048525ebb77499e1" - integrity sha512-lcHwpNoggQTObv5apGNCTdJrO69eHOZMi4BNC+rTLER8iHAqGrUVeLh/irVIM7zTw2bOXA8T6uNPeujwOLg/2Q== - -make-error@^1.1.1: - version "1.3.6" - resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.6.tgz#2eb2e37ea9b67c4891f684a1394799af484cf7a2" - integrity sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw== - -minimatch@^3.0.4, minimatch@^3.1.1: - version "3.1.2" - resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b" - integrity sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw== - dependencies: - brace-expansion "^1.1.7" - -minimist@1.2.6: - version "1.2.6" - resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.6.tgz#8637a5b759ea0d6e98702cfb3a9283323c93af44" - integrity sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q== - -node-fetch@~2.6.1: - version "2.6.7" - resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.7.tgz#24de9fba827e3b4ae44dc8b20256a379160052ad" - integrity sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ== - dependencies: - whatwg-url "^5.0.0" - -npm-bundled@^1.1.1: - version "1.1.2" - resolved "https://registry.yarnpkg.com/npm-bundled/-/npm-bundled-1.1.2.tgz#944c78789bd739035b70baa2ca5cc32b8d860bc1" - integrity sha512-x5DHup0SuyQcmL3s7Rx/YQ8sbw/Hzg0rj48eN0dV7hf5cmQq5PXIeioroH3raV1QC1yh3uTYuMThvEQF3iKgGQ== - dependencies: - npm-normalize-package-bin "^1.0.1" - -npm-normalize-package-bin@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/npm-normalize-package-bin/-/npm-normalize-package-bin-1.0.1.tgz#6e79a41f23fd235c0623218228da7d9c23b8f6e2" - integrity sha512-EPfafl6JL5/rU+ot6P3gRSCpPDW5VmIzX959Ob1+ySFUuuYHWHekXpwdUZcKP5C+DS4GEtdJluwBjnsNDl+fSA== - -npm-packlist@^2.1.5: - version "2.2.2" - resolved "https://registry.yarnpkg.com/npm-packlist/-/npm-packlist-2.2.2.tgz#076b97293fa620f632833186a7a8f65aaa6148c8" - integrity sha512-Jt01acDvJRhJGthnUJVF/w6gumWOZxO7IkpY/lsX9//zqQgnF7OJaxgQXcerd4uQOLu7W5bkb4mChL9mdfm+Zg== - dependencies: - glob "^7.1.6" - ignore-walk "^3.0.3" - npm-bundled "^1.1.1" - npm-normalize-package-bin "^1.0.1" - -once@^1.3.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" - integrity sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w== - dependencies: - wrappy "1" - -opn@~5.1.0: - version "5.1.0" - resolved "https://registry.yarnpkg.com/opn/-/opn-5.1.0.tgz#72ce2306a17dbea58ff1041853352b4a8fc77519" - integrity sha512-iPNl7SyM8L30Rm1sjGdLLheyHVw5YXVfi3SKWJzBI7efxRwHojfRFjwE/OLM6qp9xJYMgab8WicTU1cPoY+Hpg== - dependencies: - is-wsl "^1.1.0" - -path-is-absolute@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" - integrity sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg== - -protobufjs@~7.2.4: - version "7.2.4" - resolved "https://registry.yarnpkg.com/protobufjs/-/protobufjs-7.2.4.tgz#3fc1ec0cdc89dd91aef9ba6037ba07408485c3ae" - integrity sha512-AT+RJgD2sH8phPmCf7OUZR8xGdcJRga4+1cOaXJ64hvcSkVhNcRHOwIxUatPH15+nj59WAGTDv3LSGZPEQbJaQ== - dependencies: - "@protobufjs/aspromise" "^1.1.2" - "@protobufjs/base64" "^1.1.2" - "@protobufjs/codegen" "^2.0.4" - "@protobufjs/eventemitter" "^1.1.0" - "@protobufjs/fetch" "^1.1.0" - "@protobufjs/float" "^1.0.2" - "@protobufjs/inquire" "^1.1.0" - "@protobufjs/path" "^1.1.2" - "@protobufjs/pool" "^1.1.0" - "@protobufjs/utf8" "^1.1.0" - "@types/node" ">=13.7.0" - long "^5.0.0" - -require-directory@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42" - integrity sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q== - -source-map-support@^0.5.6: - version "0.5.19" - resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.19.tgz#a98b62f86dcaf4f67399648c085291ab9e8fed61" - integrity sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw== - dependencies: - buffer-from "^1.0.0" - source-map "^0.6.0" - -source-map@^0.6.0: - version "0.6.1" - resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" - integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== - -sprintf-js@~1.0.2: - version "1.0.3" - resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" - integrity sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw= - -string-width@^4.1.0, string-width@^4.2.0: - version "4.2.3" - resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" - integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== - dependencies: - emoji-regex "^8.0.0" - is-fullwidth-code-point "^3.0.0" - strip-ansi "^6.0.1" - -strip-ansi@^6.0.0, strip-ansi@^6.0.1: - version "6.0.1" - resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" - integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== - dependencies: - ansi-regex "^5.0.1" - -supports-color@^7.1.0: - version "7.2.0" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-7.2.0.tgz#1b7dcdcb32b8138801b3e478ba6a51caa89648da" - integrity sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw== - dependencies: - has-flag "^4.0.0" - -tr46@~0.0.3: - version "0.0.3" - resolved "https://registry.yarnpkg.com/tr46/-/tr46-0.0.3.tgz#8184fd347dac9cdc185992f3a6622e14b9d9ab6a" - integrity sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o= - -ts-node@~8.8.2: - version "8.8.2" - resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-8.8.2.tgz#0b39e690bee39ea5111513a9d2bcdc0bc121755f" - integrity sha512-duVj6BpSpUpD/oM4MfhO98ozgkp3Gt9qIp3jGxwU2DFvl/3IRaEAvbLa8G60uS7C77457e/m5TMowjedeRxI1Q== - dependencies: - arg "^4.1.0" - diff "^4.0.1" - make-error "^1.1.1" - source-map-support "^0.5.6" - yn "3.1.1" - -typescript@4.9.4: - version "4.9.4" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.9.4.tgz#a2a3d2756c079abda241d75f149df9d561091e78" - integrity sha512-Uz+dTXYzxXXbsFpM86Wh3dKCxrQqUcVMxwU54orwlJjOpO3ao8L7j5lH+dWfTwgCwIuM9GQ2kvVotzYJMXTBZg== - -universalify@^0.1.0: - version "0.1.2" - resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.2.tgz#b646f69be3942dabcecc9d6639c80dc105efaa66" - integrity sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg== - -webidl-conversions@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871" - integrity sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE= - -whatwg-url@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-5.0.0.tgz#966454e8765462e37644d3626f6742ce8b70965d" - integrity sha1-lmRU6HZUYuN2RNNib2dCzotwll0= - dependencies: - tr46 "~0.0.3" - webidl-conversions "^3.0.0" - -wrap-ansi@^7.0.0: - version "7.0.0" - resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" - integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== - dependencies: - ansi-styles "^4.0.0" - string-width "^4.1.0" - strip-ansi "^6.0.0" - -wrappy@1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" - integrity sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ== - -y18n@^5.0.5: - version "5.0.8" - resolved "https://registry.yarnpkg.com/y18n/-/y18n-5.0.8.tgz#7f4934d0f7ca8c56f95314939ddcd2dd91ce1d55" - integrity sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA== - -yalc@~1.0.0-pre.50: - version "1.0.0-pre.53" - resolved "https://registry.yarnpkg.com/yalc/-/yalc-1.0.0-pre.53.tgz#c51db2bb924a6908f4cb7e82af78f7e5606810bc" - integrity sha512-tpNqBCpTXplnduzw5XC+FF8zNJ9L/UXmvQyyQj7NKrDNavbJtHvzmZplL5ES/RCnjX7JR7W9wz5GVDXVP3dHUQ== - dependencies: - chalk "^4.1.0" - detect-indent "^6.0.0" - fs-extra "^8.0.1" - glob "^7.1.4" - ignore "^5.0.4" - ini "^2.0.0" - npm-packlist "^2.1.5" - yargs "^16.1.1" - -yargs-parser@^20.2.2: - version "20.2.9" - resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.9.tgz#2eb7dc3b0289718fc295f362753845c41a0c94ee" - integrity sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w== - -yargs@^16.1.1: - version "16.2.0" - resolved "https://registry.yarnpkg.com/yargs/-/yargs-16.2.0.tgz#1c82bf0f6b6a66eafce7ef30e376f49a12477f66" - integrity sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw== - dependencies: - cliui "^7.0.2" - escalade "^3.1.1" - get-caller-file "^2.0.5" - require-directory "^2.1.1" - string-width "^4.2.0" - y18n "^5.0.5" - yargs-parser "^20.2.2" - -yn@3.1.1: - version "3.1.1" - resolved "https://registry.yarnpkg.com/yn/-/yn-3.1.1.tgz#1e87401a09d767c1d5eab26a6e4c185182d2eb50" - integrity sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q== diff --git a/tfjs-master/tfjs-core/.bazelrc b/tfjs-master/tfjs-core/.bazelrc deleted file mode 100644 index a69cab90b..000000000 --- a/tfjs-master/tfjs-core/.bazelrc +++ /dev/null @@ -1 +0,0 @@ -build --symlink_prefix=dist/ diff --git a/tfjs-master/tfjs-core/.npmignore b/tfjs-master/tfjs-core/.npmignore deleted file mode 100644 index 664d161d9..000000000 --- a/tfjs-master/tfjs-core/.npmignore +++ /dev/null @@ -1,31 +0,0 @@ -# Ignore other packages in the mono-repo. -tfjs-backend-webgpu/ -tfjs-backend-nodegl/ -tfjs-react-native/ - -.vscode/ -.rpt2_cache/ -src/**/*_test.ts -integration_tests/ - -dist/backends/**/*_test.js -models/ -coverage/ -package/ -**/node_modules/ -karma.conf.js -*.tgz -*.log -.travis.yml -CONTRIBUTING.md -tslint.json -yarn.lock -DEVELOPMENT.md -ISSUE_TEMPLATE.md -PULL_REQUEST_TEMPLATE.md -rollup.config.js -tsconfig.json -.yalc/ -yalc.lock -tfjs-react-native/ -tfjs-backend-nodegl/ diff --git a/tfjs-master/tfjs-core/.npmrc b/tfjs-master/tfjs-core/.npmrc deleted file mode 100644 index 43c97e719..000000000 --- a/tfjs-master/tfjs-core/.npmrc +++ /dev/null @@ -1 +0,0 @@ -package-lock=false diff --git a/tfjs-master/tfjs-core/.vscode/launch.json b/tfjs-master/tfjs-core/.vscode/launch.json deleted file mode 100644 index 9281ba120..000000000 --- a/tfjs-master/tfjs-core/.vscode/launch.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "type": "chrome", - "request": "attach", - "name": "Attach Karma Chrome", - "address": "localhost", - "port": 9333, - "pathMapping": { - "/": "${workspaceRoot}", - "/base/": "${workspaceRoot}/" - } - } - ] -} diff --git a/tfjs-master/tfjs-core/.vscode/settings.json b/tfjs-master/tfjs-core/.vscode/settings.json deleted file mode 100644 index 5f30a3cfd..000000000 --- a/tfjs-master/tfjs-core/.vscode/settings.json +++ /dev/null @@ -1 +0,0 @@ -../../.vscode/settings.json \ No newline at end of file diff --git a/tfjs-master/tfjs-core/.vscode/tasks.json b/tfjs-master/tfjs-core/.vscode/tasks.json deleted file mode 100644 index 594b0eea8..000000000 --- a/tfjs-master/tfjs-core/.vscode/tasks.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "version": "2.0.0", - "tasks": [ - { - "command": "yarn", - "label": "lint", - "type": "shell", - "args": [ - "lint" - ], - "problemMatcher": { - "base": "$tslint5", - "owner": "tslint-type-checked", - "fileLocation": "absolute" - } - }, - { - "command": "yarn", - "label": "build", - "type": "shell", - "args": ["build", "--pretty", "false", "--noEmit"], - "problemMatcher": [ - "$tsc" - ] - } - ] - } diff --git a/tfjs-master/tfjs-core/BUILD.bazel b/tfjs-master/tfjs-core/BUILD.bazel deleted file mode 100644 index ea1b141a9..000000000 --- a/tfjs-master/tfjs-core/BUILD.bazel +++ /dev/null @@ -1,184 +0,0 @@ -# Copyright 2021 Google LLC. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================= - -load("@bazel_skylib//rules:copy_file.bzl", "copy_file") -load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_test", "pkg_npm") -load("//tools:copy_to_dist.bzl", "copy_to_dist", "copy_ts_library_to_dist") -load("//tools:tfjs_bundle.bzl", "tfjs_bundle") -load("//tools:tfjs_web_test.bzl", "tfjs_web_test") - -package(default_visibility = ["//visibility:public"]) - -# Allow typescript rules in any package to reference this file -exports_files([ - "tsconfig.json", - "package.json", -]) - -tfjs_bundle( - name = "tf-core", - entry_point = "//tfjs-core/src:index.ts", - external = [ - "crypto", - ], - leave_as_require = [ - "crypto", - "node-fetch", - "util", - ], - umd_name = "tf", - deps = [ - "//tfjs-core/src:tfjs-core_lib", - ], -) - -copy_ts_library_to_dist( - name = "copy_src_to_dist", - srcs = [ - "//tfjs-core/src:tfjs-core_lib", - "//tfjs-core/src:tfjs-core_src_lib", - "//tfjs-core/src:tfjs-core_test_lib", - ], - root = "src", -) - -copy_to_dist( - name = "copy_bundles", - srcs = [ - ":tf-core", - ":tf-core.es2017", - ":tf-core.es2017.min", - ":tf-core.fesm", - ":tf-core.fesm.min", - ":tf-core.min", - ":tf-core.node", - ], -) - -copy_ts_library_to_dist( - name = "copy_test_snippets", - srcs = [ - "//tfjs-core/scripts/test_snippets:test_snippets_util_lib", - ], - root = ".", -) - -copy_file( - name = "copy_miniprogram", - src = ":tf-core.min.js", - out = "dist/miniprogram/index.js", -) - -copy_file( - name = "copy_miniprogram_map", - src = ":tf-core.min.js.map", - out = "dist/miniprogram/index.js.map", -) - -pkg_npm( - name = "tfjs-core_pkg", - package_name = "@tensorflow/tfjs-core", - srcs = [ - "README.md", - "package.json", - ], - tags = ["ci"], - deps = [ - ":copy_bundles", - ":copy_miniprogram", - ":copy_miniprogram_map", - ":copy_src_to_dist", - ":copy_test_snippets", - ], -) - -tfjs_web_test( - name = "tfjs-core_test", - srcs = [ - "//tfjs-core/src:tfjs-core_test_bundle", - ], - browsers = [ - "bs_android_10", - "bs_chrome_mac", - "bs_firefox_mac", - "bs_ios_12", - "bs_safari_mac", - "win_10_chrome", - ], - static_files = [ - # Listed here so sourcemaps are served - "//tfjs-core/src:tfjs-core_test_bundle", - ], -) - -# Defined here because chdir must be a subdirectory of the directory the rule is -# defined in. -nodejs_test( - name = "test_snippets_test", - chdir = "tfjs-core", - data = [ - ":tsconfig.json", - "//:tsconfig.json", - "//tfjs-backend-cpu/src:tfjs-backend-cpu_lib", - "//tfjs-core/scripts/test_snippets:test_snippets_lib", - "//tfjs-core/src:all_srcs", - ], - entry_point = "//tfjs-core/scripts/test_snippets:test_snippets.ts", - link_workspace_root = True, - tags = [ - "ci", - # Run the test locally since it makes http requests. - "no-remote-exec", - "requires-network", - ], -) - -nodejs_test( - name = "tfjs-core_node_test", - data = [ - "//tfjs-backend-cpu/src:tfjs-backend-cpu_lib", - "//tfjs-core/src:setup_test_lib", - "//tfjs-core/src:test_node_lib", - "//tfjs-core/src:tfjs-core_lib", - "//tfjs-core/src:tfjs-core_src_lib", - "//tfjs-core/src:tfjs-core_test_lib", - ], - entry_point = "//tfjs-core/src:test_node.ts", - link_workspace_root = True, - tags = ["ci"], -) - -nodejs_test( - name = "tfjs-core_async_backends_test", - data = [ - "//tfjs-backend-cpu/src:tfjs-backend-cpu_lib", - "//tfjs-core/src:tfjs-core_test_lib", - ], - entry_point = "//tfjs-core/src:test_async_backends.ts", - link_workspace_root = True, - tags = ["ci"], -) - -test_suite( - name = "tests", - tests = [ - ":test_snippets_test", - ":tfjs-core_async_backends_test", - ":tfjs-core_node_test", - ":tfjs-core_test", - "//tfjs-core/src:worker_node_test", - "//tfjs-core/src:worker_test", - ], -) diff --git a/tfjs-master/tfjs-core/README.md b/tfjs-master/tfjs-core/README.md deleted file mode 100644 index 0de6436b3..000000000 --- a/tfjs-master/tfjs-core/README.md +++ /dev/null @@ -1,45 +0,0 @@ -# TensorFlow.js Core API - -A part of the TensorFlow.js ecosystem, this repo hosts `@tensorflow/tfjs-core`, -the TensorFlow.js Core API, which provides low-level, hardware-accelerated -linear algebra operations and an eager API for automatic differentiation. - -Check out [js.tensorflow.org](https://js.tensorflow.org) for more -information about the library, tutorials and API docs. - -To keep track of issues we use the [tensorflow/tfjs](https://github.com/tensorflow/tfjs) Github repo. - -## Importing - -You can install TensorFlow.js via yarn or npm. We recommend using the -[@tensorflow/tfjs](https://www.npmjs.com/package/@tensorflow/tfjs) npm package, -which gives you both this Core API and the higher-level -[Layers API](/tfjs-layers): - -```js -import * as tf from '@tensorflow/tfjs'; -// You have the Core API: tf.matMul(), tf.softmax(), ... -// You also have Layers API: tf.model(), tf.layers.dense(), ... -``` - -On the other hand, if you care about the bundle size and you do not use the -Layers API, you can import only the Core API: - -```js -import * as tfc from '@tensorflow/tfjs-core'; -// You have the Core API: tfc.matMul(), tfc.softmax(), ... -// No Layers API. -``` - -**Note**: If you are only importing the Core API, you also need to import a -backend (e.g., [tfjs-backend-cpu](/tfjs-backend-cpu), -[tfjs-backend-webgl](/tfjs-backend-webgl), [tfjs-backend-wasm](/tfjs-backend-wasm)). - -For info about development, check out [DEVELOPMENT.md](/DEVELOPMENT.md). - -## For more information - -- [TensorFlow.js API documentation](https://js.tensorflow.org/api/latest/) -- [TensorFlow.js Tutorials](https://js.tensorflow.org/tutorials/) - -Thanks BrowserStack for providing testing support. diff --git a/tfjs-master/tfjs-core/development/op_modularization.md b/tfjs-master/tfjs-core/development/op_modularization.md deleted file mode 100644 index e2916561e..000000000 --- a/tfjs-master/tfjs-core/development/op_modularization.md +++ /dev/null @@ -1,168 +0,0 @@ - # How to modularize an op - -_This document generally describes the world that we are moving towards as we modularise tfjs. Some of its descriptions hold for the current state of the world._ It's primarily a pragmatic workflow guide, you don't have to follow the steps in this exact order, but it can be a helpful starting place/checklist. - -Glossary - -**Op**: In TensorFlow.js an op is a backend agnostic function that is generally exposed as public API to end users. These are implemented in `tfjs-core` - -**Kernel**: In TensorFlow.js a kernel is a backend specific low level implementation of functionality that is used by one or more ops. The kernels and their interfaces that are available in tfjs are defined in `tfjs-core/src/kernel_names.ts`. Kernels should not call other kernels nor call back into the public API of tfjs. Kernels may share code as regular function imports. - -**Gradient**: The definition of backward mode operation for a given **Kernel**. These are implemented in tfjs-core and are also backend agnostic (i.e. they call other ops or kernels). - -**runKernelFunc**: A function in tfjs-core's engine that executes functions. It can handle both modular and non-modular kernels (non-modular kernels are kernels called through the backend object rather than the kernel registry). Will be replaced with **runKernel** once all kernels are modular across all backends. - -## Steps in tfjs-core - -Note: We will be modularising **all the ops** before modularizing **any of** the kernels in the various backends. - -**Before you start:** Go to [this issue](https://github.com/tensorflow/tfjs/issues/2822) and tell us which op you want to work on by leaving a comment. - -- Add necessary kernel names and interfaces to **tfjs-core/src/kernel_names.ts** - - This **must** include an identifier for the kernel and optionally types for the `Inputs` and `Attrs`. Use these identifiers in Op and Kernel definitions. As closely as possible we want to match the interface defined by the [C++ API](https://www.tensorflow.org/api_docs/cc). We cannot always match exactly, so reach out for guidance if you are unsure. - - ```ts - export const SquaredDifference = 'SquaredDifference'; - export type SquaredDifferenceInputs = Pick; - ``` - -- Create `src/ops/op_name.ts` - - Move op definition into this file. e.g. `tfjs-core/src/ops/squared_difference.ts` - - Note that we still use runKernelFunc to support backends that haven't yet modularized their kernels. This the forward and backward function will be defined here as well as in the modular kernel(s)/gradient(s). - - Generally ops should only do input validation and data transformations to make the parameters **match the kernel interface.** Any other data transformation should be done by kernels. The guiding principle here is that the work of the kernel (as defined by its interface) should not be split between an op and a kernel definition. Note: in some cases when you move responsibility for data manipulation from ops to kernels, _older_ modualized kernels will break (i.e. fail their tests, e.g. kernels in the wasm backend). In these cases you also need to go in and adjust those kernels to match the new input. - - ```ts - import {ENGINE, ForwardFunc} from '../engine'; - import {SquaredDifference, SquaredDifferenceInputs} from '../kernel_names'; - import {Tensor} from '../tensor'; - import {NamedTensorMap} from '../tensor_types'; - import {makeTypesMatch} from '../tensor_util'; - import {convertToTensor} from '../tensor_util_env'; - import {TensorLike} from '../types'; - - import {assertAndGetBroadcastShape} from './broadcast_util'; - import {op} from './operation'; - import {scalar} from './tensor_ops'; - - - function squaredDifference_( - a: Tensor|TensorLike, b: Tensor|TensorLike): T { - let $a = convertToTensor(a, 'a', 'squaredDifference'); - let $b = convertToTensor(b, 'b', 'squaredDifference'); - [$a, $b] = makeTypesMatch($a, $b); - - assertAndGetBroadcastShape($a.shape, $b.shape); - // **************** - // Modularization note: this gradient definition should be removed from - // here once the modular gradient is implemented in the steps below. - //***************** - const der = (dy: Tensor, saved: Tensor[]) => { - const [$a, $b] = saved; - const two = scalar(2); - const derA = () => dy.mul($a.sub($b).mul(two)); - const derB = () => dy.mul($b.sub($a).mul(two)); - return {a: derA, b: derB}; - }; - // **************** - // END Modularization note - //***************** - - - const forward: ForwardFunc = (backend, save) => { - const res = backend.squaredDifference($a, $b); - save([$a, $b]); - return res; - }; - - const inputs: SquaredDifferenceInputs = {a: $a, b: $b}; - const attrs = {}; - - const inputsToSave = [$a, $b]; - const outputToSave: boolean[] = []; - return ENGINE.runKernelFunc( - forward, inputs as unknown as NamedTensorMap, der, - SquaredDifference, attrs, inputsToSave, outputToSave) as T; - } - - export const squaredDifference = op({squaredDifference_}); - ``` - - - -- Export modularized op from `src/ops/ops.ts` - - ```ts - export {squaredDifference} from './squared_difference'; - ``` - -- Make chained op augmentor in `src/public/chained_ops/op_name.ts` - - `src/public/chained_ops/squared_difference.ts` - - ```ts - - import {squaredDifference} from '../../ops/squared_difference'; - import {Tensor} from '../../tensor'; - import {Rank, TensorLike} from '../../types'; - - declare module '../../tensor' { - interface Tensor { - squaredDifference(b: Tensor|TensorLike): T; - } - } - - Tensor.prototype.squaredDifference = function(b: Tensor| - TensorLike): T { - this.throwIfDisposed(); - return squaredDifference(this, b); - }; - ``` - -- Add augmentor to `src/public/chained_ops/register_all_chained_ops.ts` -- Add chained op test to `src/public/chained_ops/register_all_chained_ops_test.ts` -- Remove op from `src/tensor.ts` - - Remove it from the `Tensor` class and from the `OpHandler` interface - -- Create `src/gradients/kernel_name` for any kernels used that do not already have a modular gradient - - e.g. `src/gradients/SquaredDifference_grad.ts` - - Note that we use **directly imported ops**. Avoid using the chained API - - ```ts - import {SquaredDifference} from '../kernel_names'; - import {GradConfig} from '../kernel_registry'; - import {mul, sub} from '../ops/binary_ops'; - import {scalar} from '../ops/tensor_ops'; - import {Tensor} from '../tensor'; - - export const squaredDifferenceGradConfig: GradConfig = { - kernelName: SquaredDifference, - gradFunc: (dy: Tensor, saved: Tensor[]) => { - const [a, b] = saved; - const two = scalar(2); - const derA = () => mul(dy, mul(two, sub(a, b))); - const derB = () => mul(dy, mul(two, sub(b, a))); - return {a: derA, b: derB}; - } - }; - ``` - -- Add gradient config to `src/register_all_gradients.ts` - - ```ts - import {squaredDifferenceGradConfig} from './gradients/SquaredDifference_grad'; - - const gradConfigs: GradConfig[] = [ - // add the gradient config to this list. - squaredDifferenceGradConfig, - ]; - ``` - -## Submit a PR - -At this stage you should be able to submit a PR for review. Don't forget to run `yarn test` locally within `tfjs-core` before you do! diff --git a/tfjs-master/tfjs-core/package.json b/tfjs-master/tfjs-core/package.json deleted file mode 100644 index 8021b6fda..000000000 --- a/tfjs-master/tfjs-core/package.json +++ /dev/null @@ -1,77 +0,0 @@ -{ - "name": "@tensorflow/tfjs-core", - "version": "0.0.0", - "description": "Hardware-accelerated JavaScript library for machine intelligence", - "private": false, - "main": "dist/tf-core.node.js", - "jsdelivr": "dist/tf-core.min.js", - "unpkg": "dist/tf-core.min.js", - "types": "dist/index.d.ts", - "jsnext:main": "dist/index.js", - "module": "dist/index.js", - "miniprogram": "dist/miniprogram", - "engines": { - "yarn": ">= 1.3.2" - }, - "repository": { - "type": "git", - "url": "https://github.com/tensorflow/tfjs.git", - "directory": "tfjs-core" - }, - "license": "Apache-2.0", - "devDependencies": { - "@bazel/bazelisk": "^1.12.0", - "@bazel/ibazel": "^0.16.2" - }, - "scripts": { - "build": "bazel build :tfjs-core_pkg", - "publish-npm": "bazel run :tfjs-core_pkg.publish", - "coverage": "bazel coverage :tfjs-core_node_test", - "test": "bazel test :tests --test_output=all", - "test-dev": "ibazel test :tests --test_output=all", - "test-browser": "bazel test :tfjs-core_test --test_output=streamed", - "test-browser-debug": "bazel run :tfjs-core_test --test_output=streamed", - "test-node": "bazel test :tfjs-core_node_test --test_output=streamed", - "test-node-debug": "bazel run :tfjs-core_node_test --config=debug --test_output=streamed", - "test-async-backends": "bazel test :tfjs-core_async_backends_test --test_output=streamed", - "test-snippets": "bazel test :test_snippets_test --test_output=streamed" - }, - "dependencies": { - "@types/long": "^4.0.1", - "@types/offscreencanvas": "~2019.7.0", - "@types/seedrandom": "^2.4.28", - "@webgpu/types": "0.1.38", - "long": "4.0.0", - "node-fetch": "~2.6.1", - "seedrandom": "^3.0.5" - }, - "browser": { - "node-fetch": false, - "util": false, - "crypto": false, - "worker_threads": false - }, - "sideEffects": [ - "./dist/index.js", - "./dist/engine.js", - "./dist/tensor.js", - "./dist/base_side_effects.js", - "./dist/flags.js", - "./dist/platforms/*.js", - "./dist/register_all_gradients.js", - "./dist/public/chained_ops/*.js", - "./dist/io/*.js", - "./src/index.mjs", - "./src/engine.mjs", - "./src/tensor.mjs", - "./src/base_side_effects.mjs", - "./src/flags.mjs", - "./src/platforms/*.mjs", - "./src/register_all_gradients.mjs", - "./src/public/chained_ops/*.mjs", - "./src/io/*.mjs" - ], - "resolutions": { - "minimist": "1.2.6" - } -} diff --git a/tfjs-master/tfjs-core/scripts/build-npm.sh b/tfjs-master/tfjs-core/scripts/build-npm.sh deleted file mode 100644 index 55dd985ad..000000000 --- a/tfjs-master/tfjs-core/scripts/build-npm.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/env bash -# Copyright 2017 Google LLC. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================= - -set -e - -yarn rimraf dist/ -yarn - -yarn build -yarn build-test-snippets -yarn rollup -c --visualize --npm - -# Use minified files for miniprogram -mkdir dist/miniprogram -cp dist/tf-core.min.js dist/miniprogram/index.js -cp dist/tf-core.min.js.map dist/miniprogram/index.js.map - -echo "Stored standalone library at dist/tf-core(.min).js" diff --git a/tfjs-master/tfjs-core/scripts/cloud_funcs/README.md b/tfjs-master/tfjs-core/scripts/cloud_funcs/README.md deleted file mode 100644 index 2d56e9e01..000000000 --- a/tfjs-master/tfjs-core/scripts/cloud_funcs/README.md +++ /dev/null @@ -1,50 +0,0 @@ -This directory contains the following Google Cloud Functions. - -### `trigger_nightly` -Programatically triggers a Cloud Build on master. This function is called by the Cloud Scheduler at 3am EST every day (configurable via the Cloud Scheduler UI). -You can also trigger the function manually via the Cloud UI. - -Command to re-deploy: -```sh -gcloud functions deploy nightly \ - --runtime nodejs8 \ - --trigger-topic nightly -``` - -If a build was triggered by nightly, there is a substitution variable `_NIGHTLY=true`. -You can forward the substitution as the `NIGHTLY` environment variable so the scripts can use it, by specifying `env: ['NIGHTLY=$_NIGHTLY']` in `cloudbuild.yml`. - -### `send_email` -Sends an email and a chat message with the nightly build status. Every build sends a message to the `cloud-builds` topic with its build information. The `send_email` function is subscribed to that topic and ignores all builds (e.g. builds triggered by pull requests) **except** for the nightly build and sends an email to an internal mailing list with its build status around 3:10am. - -Command to re-deploy: - -```sh -gcloud functions deploy send_email \ - --runtime nodejs8 \ - --stage-bucket learnjs-174218_cloudbuild \ - --trigger-topic cloud-builds \ - --set-env-vars MAILGUN_API_KEY="[API_KEY_HERE]",HANGOUTS_URL="[URL_HERE]" -``` - -### `sync_reactnative` -Makes a request to browserStack to sync the current build of the tfjs-react-native integration app to browserstack. The app itself is stored in a GCP bucket. This needs to be done at least once every 30 days and is triggered via cloud scheduler via the `sync_reactnative` topic. -Currently set to run weekly on Thursdays at 3AM. - -Command to re-deploy: - -```sh -gcloud functions deploy sync_reactnative \ - --runtime nodejs8 \ - --trigger-topic sync_reactnative \ - --set-env-vars HANGOUTS_URL="[URL_HERE]",BOTS_HANGOUTS_URL="[URL_HERE]" -``` - -### The pipeline - -The pipeline looks like this: - -1) At 3am, Cloud Scheduler writes to `nightly` topic -2) That triggers the `nightly` function, which starts a build programatically -3) That build runs and writes its status to `cloud-builds` topic -4) That triggers the `send_email` function, which sends email and chat with the build status. diff --git a/tfjs-master/tfjs-core/scripts/test-bundle-size.js b/tfjs-master/tfjs-core/scripts/test-bundle-size.js deleted file mode 100644 index 6c936d863..000000000 --- a/tfjs-master/tfjs-core/scripts/test-bundle-size.js +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/env node -// Copyright 2019 Google LLC. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= - -const shell = require('shelljs'); -const {exec} = require('../../scripts/test-util'); -const {showDiff, getFileSizeBytes} = require('../../scripts/bundle-size-util'); - -// Get the bundle sizes from this change. -exec(`yarn rollup -c --ci`, {silent: true}); -const minSize = getFileSizeBytes('dist/tf-core.min.js'); - -// Clone master and get the bundle size from master. -const dirName = '/tmp/tfjs-core-bundle'; -const coreDirName = 'tfjs-core'; -exec( - `git clone --depth=1 --single-branch ` + - `https://github.com/tensorflow/tfjs ${dirName}`, - {silent: true}); - -shell.cd(dirName); -shell.cd(coreDirName); -exec(`yarn && yarn rollup -c --ci`, {silent: true}); - -const masterMinSize = getFileSizeBytes('dist/tf-core.min.js'); - -console.log(`~~~~ minified bundle ~~~~`); -console.log(`==> post-gzip`) -showDiff(minSize.gzipFileSizeBytes, masterMinSize.gzipFileSizeBytes); -console.log(); -console.log(`==> pre-gzip`) -showDiff(minSize.fileSizeBytes, masterMinSize.fileSizeBytes); -console.log(); -console.log(); - -exec(`rm -r ${dirName}`); diff --git a/tfjs-master/tfjs-core/scripts/test_snippets/BUILD.bazel b/tfjs-master/tfjs-core/scripts/test_snippets/BUILD.bazel deleted file mode 100644 index 27a10ea3a..000000000 --- a/tfjs-master/tfjs-core/scripts/test_snippets/BUILD.bazel +++ /dev/null @@ -1,31 +0,0 @@ -load("//tools:defaults.bzl", "ts_library") - -package(default_visibility = ["//visibility:public"]) - -ts_library( - name = "test_snippets_util_lib", - srcs = [ - "util.ts", - ], - module_name = "@tensorflow/tfjs-core/dist/scripts/test_snippets", - deps = [ - "@npm//@types/node", - "@npm//typescript", - ], -) - -ts_library( - name = "test_snippets_lib", - testonly = True, - srcs = [ - "test_snippets.ts", - ], - module_name = "@tensorflow/tfjs-core/dist/scripts/test_snippets", - deps = [ - ":test_snippets_util_lib", - "//tfjs-backend-cpu/src:tfjs-backend-cpu_lib", - "//tfjs-core/src:tfjs-core_lib", - "//tfjs-core/src:tfjs-core_src_lib", - "//tfjs-core/src:tfjs-core_test_lib", - ], -) diff --git a/tfjs-master/tfjs-core/scripts/test_snippets/test_snippets.ts b/tfjs-master/tfjs-core/scripts/test_snippets/test_snippets.ts deleted file mode 100644 index a410d85d3..000000000 --- a/tfjs-master/tfjs-core/scripts/test_snippets/test_snippets.ts +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env node -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import * as tf from '../../src/index'; -import '../../src/public/chained_ops/register_all_chained_ops'; -import '../../src/register_all_gradients'; -import '@tensorflow/tfjs-backend-cpu'; -import {parseAndEvaluateSnippets} from './util'; - -parseAndEvaluateSnippets(tf); diff --git a/tfjs-master/tfjs-core/scripts/test_snippets/util.ts b/tfjs-master/tfjs-core/scripts/test_snippets/util.ts deleted file mode 100644 index 20e5e6bd9..000000000 --- a/tfjs-master/tfjs-core/scripts/test_snippets/util.ts +++ /dev/null @@ -1,183 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as fs from 'fs'; -import * as path from 'path'; -import * as ts from 'typescript'; - -process.on('unhandledRejection', ex => { - throw ex; -}); - -// Used for logging the number of snippets that have been found. -let snippetCount = 0; -// Used for counting the number of errors that have been found. -let errorCount = 0; - -/** - * Parse and evaluate snippets for the src/index.ts from where this script is - * run. - * @param tf The TensorFlow.js module to use when evaluating snippets. If used - * outside core, this should be a union of core and the separate package. - * This is unused here but is used in eval() of the snippets. - */ -// tslint:disable-next-line:no-any -export async function parseAndEvaluateSnippets(tf: any) { - const index = path.join(process.cwd(), 'src/index.ts'); - const tsconfigPath = path.join(process.cwd(), 'tsconfig.json'); - - // Use the same compiler options that we use to compile the library - // here. - const tsconfig = JSON.parse(fs.readFileSync(tsconfigPath, 'utf8')); - - delete tsconfig.compilerOptions.moduleResolution; - const program = ts.createProgram([index], tsconfig.compilerOptions); - - const checker = program.getTypeChecker(); - - for (const sourceFile of program.getSourceFiles()) { - if (!sourceFile.isDeclarationFile) { - const children = sourceFile.getChildren(); - for (let i = 0; i < children.length; i++) { - await visit(tf, checker, children[i], sourceFile); - } - } - } - - if (errorCount === 0) { - console.log(`Parsed and evaluated ${snippetCount} snippets successfully.`); - } else { - console.log( - `Evaluated ${snippetCount} snippets with ${errorCount} errors.`); - process.exit(1); - } -} - -async function visit( - // tslint:disable-next-line:no-any - tf: any, checker: ts.TypeChecker, node: ts.Node, - sourceFile: ts.SourceFile) { - const children = node.getChildren(); - for (let i = 0; i < children.length; i++) { - await visit(tf, checker, children[i], sourceFile); - } - - if (ts.isClassDeclaration(node) || ts.isFunctionDeclaration(node) || - ts.isMethodDeclaration(node) || ts.isInterfaceDeclaration(node)) { - const symbol = checker.getSymbolAtLocation(node.name); - const jsdoc = getJSDocTag(symbol); - if (jsdoc == null) { - return; - } - // Ignore snippets of methods that have been marked with ignoreCI. - if (jsdoc['ignoreCI']) { - return; - } - - const documentation = symbol.getDocumentationComment(checker); - if (documentation == null) { - return; - } - for (let i = 0; i < documentation.length; i++) { - const doc = documentation[i]; - const re = /```js.*?```/gs; - const matches = re.exec(doc.text); - if (matches == null) { - return; - } - - for (let k = 0; k < matches.length; k++) { - snippetCount++; - - const match = matches[k]; - const lines = match.split('\n'); - const evalLines: string[] = []; - for (let j = 0; j < lines.length; j++) { - let line = lines[j]; - if (line.startsWith('```js')) { - line = line.substring('```js'.length); - } - if (line.endsWith('```')) { - line = line.substring(0, line.length - '```'.length); - } - line = line.trim(); - if (line.startsWith('*')) { - line = line.substring(1).trim(); - } - evalLines.push(line); - } - - const srcCode = evalLines.join('\n'); - const evalString = `(async () => {${srcCode}})()`; - - const oldLog = console.log; - const oldWarn = console.warn; - - const reportError = (e: string|Error) => { - oldLog(); - oldLog(`Error executing snippet for ${symbol.name} at ${ - sourceFile.fileName}`); - oldLog(); - oldLog(`\`\`\`js${srcCode}\`\`\``); - oldLog(); - - console.error(e); - errorCount++; - }; - - // Overrwrite console.log so we don't spam the console. - console.log = (msg: string) => {}; - console.warn = (msg: string) => {}; - try { - await eval(evalString); - } catch (e) { - reportError(e); - } - console.log = oldLog; - console.warn = oldWarn; - } - } - } -} - -interface JSDoc { - namespace?: string; - ignoreCI?: boolean; -} - -function getJSDocTag(symbol: ts.Symbol): JSDoc { - const tags = symbol.getJsDocTags(); - for (let i = 0; i < tags.length; i++) { - const jsdocTag = tags[i]; - if (jsdocTag.name === 'doc' && jsdocTag.text != null) { - if (jsdocTag.text.length !== 1) { - throw new Error('Expected exactly one jsdoc SymbolDisplayPart but got' - + ` ${jsdocTag.text.length} instead: ${jsdocTag.text}`); - } - const text = jsdocTag.text[0].text.trim(); - const json = convertDocStringToDocInfoObject(text); - return json; - } - } - return null; -} - -function convertDocStringToDocInfoObject(docString: string): JSDoc { - const jsonString = - docString.replace(/([a-zA-Z0-9]+):/g, '"$1":').replace(/\'/g, '"'); - return JSON.parse(jsonString); -} diff --git a/tfjs-master/tfjs-core/scripts/touch_modular_op_files.ts b/tfjs-master/tfjs-core/scripts/touch_modular_op_files.ts deleted file mode 100644 index e64c3b330..000000000 --- a/tfjs-master/tfjs-core/scripts/touch_modular_op_files.ts +++ /dev/null @@ -1,130 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -/** - * A helper script to generate empty files typically used in modularizing an op. - * params: - * --op the name of the op - * --chained is this op part of the chained api (optional) - * --grad the name of the kernel(s) to create gradient files for - * - * It assumes you run it from tfjs_core. - * - * Example - * npx ts-node -s scripts/touch_modular_op_files.ts --op op_name --grad \ - * KernelName --chained - * - * Generates the following files (they will be empty) - * tfjs_core/src/ops/op_name.ts - * - * if --chained is present - * tfjs_core/src/public/chained_ops/op_name.ts - * - * if --kernel is present - * tfjs_core/src/gradients/KernelName_grad.ts - * - * Example 2 (multiple kernels) - * npx ts-node -s scripts/touch_modular_op_files.ts --grad Kernel1,Kernel2 - */ - -import * as argparse from 'argparse'; -import {execSync} from 'child_process'; -import * as fs from 'fs'; - -const parser = new argparse.ArgumentParser(); - -parser.addArgument('--op', {help: 'the name of the op'}); -parser.addArgument('--grad', {help: 'the name of the grad.'}); -parser.addArgument('--chained', { - action: 'storeTrue', - defaultValue: false, - help: 'is this op part of the chained api.' -}); - -async function main() { - const args = parser.parseArgs(); - console.log('Called touch_modular_op_files with args:', args); - - if (args.op != null) { - const ops: string[] = args.op.split(',').filter((o: string) => o != null); - ops.forEach(op => { - let filePath = `./src/ops/${op}.ts`; - let command = `touch ${filePath}`; - execSync(command); - - // create a test file - filePath = `./src/ops/${op}_test.ts`; - command = `touch ${filePath}`; - execSync(command); - - if (args.chained) { - filePath = `./src/public/chained_ops/${op}.ts`; - command = `touch ${filePath}`; - execSync(command); - } - }); - } - - if (args.grad) { - const downcaseFirstChar = (str: string) => { - return str.charAt(0).toLowerCase() + str.slice(1); - }; - - const kernels: string[] = - args.grad.split(',').filter((k: string) => k != null); - - kernels.forEach(kernelName => { - const gradientFileTemplate = `/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {${kernelName}, ${kernelName}Attrs} from '../kernel_names'; -import {GradConfig, NamedAttrMap} from '../kernel_registry'; -import {Tensor} from '../tensor'; - -export const ${downcaseFirstChar(kernelName)}GradConfig: GradConfig = { - kernelName: ${kernelName}, - inputsToSave: [], // UPDATE ME - outputsToSave: [], // UPDATE ME - gradFunc: (dy: Tensor, saved: Tensor[], attrs: NamedAttrMap) => { - const [] = saved; - const {} = attrs as unknown as ${kernelName}Attrs; - return { - }; - } -}; -`; - const filePath = `./src/gradients/${kernelName}_grad.ts`; - fs.writeFileSync(filePath, gradientFileTemplate, {flag: 'a'}); - }); - } -} - -main(); diff --git a/tfjs-master/tfjs-core/scripts/tsconfig.json b/tfjs-master/tfjs-core/scripts/tsconfig.json deleted file mode 100644 index c5e8c9340..000000000 --- a/tfjs-master/tfjs-core/scripts/tsconfig.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "../tsconfig.test", - "compilerOptions": { - "module": "commonjs" - } -} diff --git a/tfjs-master/tfjs-core/src/BUILD.bazel b/tfjs-master/tfjs-core/src/BUILD.bazel deleted file mode 100644 index e10b62016..000000000 --- a/tfjs-master/tfjs-core/src/BUILD.bazel +++ /dev/null @@ -1,286 +0,0 @@ -# Copyright 2021 Google LLC. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================= - -load("@npm//@bazel/jasmine:index.bzl", "jasmine_node_test") -load("//tools:defaults.bzl", "esbuild", "ts_library") -load("//tools:enumerate_tests.bzl", "enumerate_tests") -load("//tools:make_version_test_file.bzl", "make_version_test_file") -load("//tools:tfjs_web_test.bzl", "tfjs_web_test") - -package(default_visibility = ["//visibility:public"]) - -TEST_SRCS = [ - "**/*_test.ts", - "image_test_util.ts", -] - -TEST_ENTRYPOINTS = [ - "test_node.ts", - "setup_test.ts", - "worker_test.ts", - "worker_node_test.ts", - "platforms/platform_node_test.ts", - "ops/from_pixels_worker_test.ts", -] - -# Used for test-snippets -filegroup( - name = "all_srcs", - srcs = glob(["**/*.ts"]), -) - -make_version_test_file( - name = "version_test", - package_json = "//tfjs-core:package.json", - version_name = "version_core", -) - -filegroup( - name = "shared_test_srcs", - srcs = glob( - ["**/*_test.ts"], - exclude = TEST_ENTRYPOINTS, - ) + [ - ":version_test", - ], -) - -# Generates the 'tests.ts' file that imports all test entrypoints. -enumerate_tests( - name = "tests", - srcs = [":shared_test_srcs"], - root_path = "tfjs-core/src", -) - -# Compiles the majority of tfjs-core using the `@tensorflow/tfjs-core/dist` -# module name. -ts_library( - name = "tfjs-core_src_lib", - srcs = glob( - ["**/*.ts"], - exclude = TEST_SRCS + TEST_ENTRYPOINTS + ["index.ts"], - ), - module_name = "@tensorflow/tfjs-core/dist", - deps = [ - "@npm//@types/jasmine", - "@npm//@types/long", - "@npm//@types/node", - "@npm//@types/offscreencanvas", - "@npm//@types/seedrandom", - "@npm//@webgpu/types", - "@npm//jasmine", - "@npm//long", - "@npm//node-fetch", - "@npm//seedrandom", - ], -) - -# Compiles the `index.ts` entrypoint of tfjs-core separately from the rest of -# the sources in order to use the `@tensorflow/tfjs-core` module name instead -# of `@tensorflow/tfjs-core/dist`, -ts_library( - name = "tfjs-core_lib", - srcs = ["index.ts"], - module_name = "@tensorflow/tfjs-core", - deps = [ - ":tfjs-core_src_lib", - ], -) - -ts_library( - name = "tfjs-core_test_lib", - srcs = glob( - TEST_SRCS, - exclude = TEST_ENTRYPOINTS, - ) + [ - ":tests", - ":version_test", - ], - # TODO(msoulanille): Mark this as testonly once it's no longer needed in the - # npm package (for other downstream packages' tests). - module_name = "@tensorflow/tfjs-core/dist", - deps = [ - ":tfjs-core_lib", - ":tfjs-core_src_lib", - ], -) - -ts_library( - name = "setup_test_lib", - srcs = [ - "setup_test.ts", - ], - deps = [ - ":tfjs-core_src_lib", - ":tfjs-core_test_lib", - "//tfjs-backend-cpu/src:tfjs-backend-cpu_lib", - ], -) - -ts_library( - name = "test_node_lib", - srcs = [ - "test_node.ts", - ], - deps = [ - # test_node.ts depends on setup_test.js as a runtime dependency, - # so it is not listed here (it is listed in the nodejs_test, instead). - ":tfjs-core_src_lib", - ":tfjs-core_test_lib", - "//tfjs-backend-cpu/src:tfjs-backend-cpu_lib", - ], -) - -esbuild( - name = "tfjs-core_test_bundle", - testonly = True, - entry_point = "setup_test.ts", - external = [ - # webworker tests call 'require('@tensorflow/tfjs')', which - # is external to the test bundle. - # Note: This is not a bazel target. It's just a string. - "@tensorflow/tfjs", - "worker_threads", - "util", - ], - sources_content = True, - deps = [ - ":setup_test_lib", - ":tfjs-core_lib", - ":tfjs-core_test_lib", - "//tfjs-backend-cpu/src:tfjs-backend-cpu_lib", - ], -) - -ts_library( - name = "worker_node_test_lib", - srcs = [ - "worker_node_test.ts", - ], - deps = [ - ":tfjs-core_src_lib", - "//tfjs-backend-cpu/src:tfjs-backend-cpu_lib", - ], -) - -jasmine_node_test( - name = "worker_node_test", - deps = [ - ":worker_node_test_lib", - "//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", - ], -) - -ts_library( - name = "platform_node_test_lib", - srcs = [ - "platforms/platform_node_test.ts", - ], - deps = [ - ":tfjs-core_lib", - ":tfjs-core_src_lib", - "//tfjs-backend-cpu/src:tfjs-backend-cpu_lib", - "@npm//@types/node", - ], -) - -jasmine_node_test( - name = "platform_node_test", - deps = [ - ":platform_node_test_lib", - ], -) - -ts_library( - name = "worker_test_lib", - srcs = [ - "worker_test.ts", - ], - deps = [ - ":tfjs-core_lib", - ":tfjs-core_src_lib", - "//tfjs-backend-cpu/src:tfjs-backend-cpu_lib", - ], -) - -tfjs_web_test( - name = "worker_test", - browsers = [ - "bs_chrome_mac", - "bs_firefox_mac", - "bs_safari_mac", - # Temporarily disabled because BrowserStack does not support loading - # absolute paths in iOS, which is required for loading the worker. - # https://www.browserstack.com/question/39573 - # "bs_ios_12", - "bs_android_10", - "win_10_chrome", - ], - static_files = [ - # For the webworker - "//tfjs-core:tf-core.min.js", - "//tfjs-core:tf-core.min.js.map", - "//tfjs-backend-cpu:tf-backend-cpu.min.js", - "//tfjs-backend-cpu:tf-backend-cpu.min.js.map", - ], - deps = [ - ":worker_test_lib", - "@npm//long:long__umd", - "@npm//seedrandom:seedrandom__umd", - ], -) - -ts_library( - name = "from_pixels_worker_test_lib", - srcs = [ - "ops/from_pixels_worker_test.ts", - ], - deps = [ - ":tfjs-core_lib", - ":tfjs-core_src_lib", - "//tfjs-backend-cpu/src:tfjs-backend-cpu_lib", - "@npm//@types/offscreencanvas", - ], -) - -tfjs_web_test( - name = "from_pixels_worker_test", - browsers = [ - "bs_chrome_mac", - # Omit Firefox since it does not support offscreen canvas. - "bs_safari_mac", - # Temporarily disabled because BrowserStack does not support loading - # absolute paths in iOS, which is required for loading the worker. - # https://www.browserstack.com/question/39573 - # "bs_ios_12", - "bs_android_10", - "win_10_chrome", - ], - static_files = [ - # For the webworker - "//tfjs-core:tf-core.min.js", - "//tfjs-core:tf-core.min.js.map", - "//tfjs-backend-cpu:tf-backend-cpu.min.js", - "//tfjs-backend-cpu:tf-backend-cpu.min.js.map", - ], - deps = [ - ":from_pixels_worker_test_lib", - "@npm//long:long__umd", - "@npm//seedrandom:seedrandom__umd", - ], -) diff --git a/tfjs-master/tfjs-core/src/backends/backend.ts b/tfjs-master/tfjs-core/src/backends/backend.ts deleted file mode 100644 index 6f23ec0a3..000000000 --- a/tfjs-master/tfjs-core/src/backends/backend.ts +++ /dev/null @@ -1,162 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Backend, DataToGPUOptions, GPUData, Tensor} from '../tensor'; -import {DataId} from '../tensor_info'; -import {BackendValues, DataType, WebGLData, WebGPUData} from '../types'; - -export const EPSILON_FLOAT32 = 1e-7; -export const EPSILON_FLOAT16 = 1e-4; - -// Required information for all backends. -export interface BackendTimingInfo { - kernelMs: number|{error: string}; - getExtraProfileInfo?(): string; // a field for additional timing information - // e.g. packing / unpacking for WebGL backend -} - -export interface TensorStorage { - read(dataId: DataId): Promise; - readSync(dataId: DataId): BackendValues; - disposeData(dataId: DataId, force?: boolean): boolean; - write(values: BackendValues, shape: number[], dtype: DataType): DataId; - move( - dataId: DataId, values: BackendValues, shape: number[], dtype: DataType, - refCount: number): void; - memory(): {unreliable: boolean;}; // Backend-specific information. - /** Returns number of data ids currently in the storage. */ - numDataIds(): number; - refCount(dataId: DataId): number; -} - -/** Convenient class for storing tensor-related data. */ -export class DataStorage { - private data = new WeakMap(); - private dataIdsCount = 0; - - constructor(private backend: KernelBackend, private dataMover: DataMover) {} - - get(dataId: DataId) { - if (!this.data.has(dataId)) { - this.dataMover.moveData(this.backend, dataId); - } - return this.data.get(dataId); - } - - set(dataId: DataId, value: T): void { - this.dataIdsCount++; - this.data.set(dataId, value); - } - - has(dataId: DataId): boolean { - return this.data.has(dataId); - } - - delete(dataId: DataId): boolean { - this.dataIdsCount--; - return this.data.delete(dataId); - } - - numDataIds(): number { - return this.dataIdsCount; - } -} - -export interface DataMover { - /** - * To be called by backends whenever they see a dataId that they don't own. - * Upon calling this method, the mover will fetch the tensor from another - * backend and register it with the current active backend. - */ - moveData(backend: KernelBackend, dataId: DataId): void; -} - -export interface BackendTimer { - // check if backend timer is available - timerAvailable(): boolean; - time(f: () => void): Promise; -} - -/** - * The interface that defines the kernels that should be implemented when - * adding a new backend. New backends don't need to implement every one of the - * methods, this can be done gradually (throw an error for unimplemented - * methods). - */ -export class KernelBackend implements TensorStorage, Backend, BackendTimer { - refCount(dataId: DataId): number { - return notYetImplemented('refCount'); - } - incRef(dataId: DataId): void { - return notYetImplemented('incRef'); - } - timerAvailable(): boolean { - return true; - } - time(f: () => void): Promise { - return notYetImplemented('time'); - } - read(dataId: object): Promise { - return notYetImplemented('read'); - } - readSync(dataId: object): BackendValues { - return notYetImplemented('readSync'); - } - readToGPU(dataId: object, options?: DataToGPUOptions): GPUData { - return notYetImplemented('readToGPU'); - } - numDataIds(): number { - return notYetImplemented('numDataIds'); - } - disposeData(dataId: object, force?: boolean): boolean { - return notYetImplemented('disposeData'); - } - write(values: BackendValues, shape: number[], dtype: DataType): DataId { - return notYetImplemented('write'); - } - move( - dataId: DataId, values: BackendValues, shape: number[], dtype: DataType, - refCount: number): void { - return notYetImplemented('move'); - } - - createTensorFromGPUData( - values: WebGLData|WebGPUData, shape: number[], dtype: DataType): Tensor { - return notYetImplemented('createTensorFromGPUData'); - } - - memory(): {unreliable: boolean; reasons?: string[]} { - return notYetImplemented('memory'); - } - /** Returns the highest precision for floats in bits (e.g. 16 or 32) */ - floatPrecision(): 16|32 { - return notYetImplemented('floatPrecision'); - } - /** Returns the smallest representable number. */ - epsilon(): number { - return this.floatPrecision() === 32 ? EPSILON_FLOAT32 : EPSILON_FLOAT16; - } - dispose(): void { - return notYetImplemented('dispose'); - } -} - -function notYetImplemented(kernelName: string): never { - throw new Error( - `'${kernelName}' not yet implemented or not found in the registry. ` + - `This kernel may not be supported by the tfjs backend you have chosen`); -} diff --git a/tfjs-master/tfjs-core/src/backends/backend_test.ts b/tfjs-master/tfjs-core/src/backends/backend_test.ts deleted file mode 100644 index 550f90fd3..000000000 --- a/tfjs-master/tfjs-core/src/backends/backend_test.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {EPSILON_FLOAT16, EPSILON_FLOAT32} from './backend'; - -describeWithFlags('epsilon', ALL_ENVS, () => { - it('Epsilon is a function of float precision', () => { - const epsilonValue = tf.backend().floatPrecision() === 32 ? - EPSILON_FLOAT32 : - EPSILON_FLOAT16; - expect(tf.backend().epsilon()).toBe(epsilonValue); - }); - - it('abs(epsilon) > 0', async () => { - expect(await tf.abs(tf.backend().epsilon()).array()).toBeGreaterThan(0); - }); -}); diff --git a/tfjs-master/tfjs-core/src/backends/backend_util.ts b/tfjs-master/tfjs-core/src/backends/backend_util.ts deleted file mode 100644 index 4175b9cc3..000000000 --- a/tfjs-master/tfjs-core/src/backends/backend_util.ts +++ /dev/null @@ -1,65 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {decodeString, encodeString} from '../util'; - -// Utilities needed by backend consumers of tf-core. -export * from '../ops/axis_util'; -export * from '../ops/broadcast_util'; -export * from '../ops/concat_util'; -export * from '../ops/conv_util'; -export * from '../ops/fused_util'; -export * from '../ops/fused_types'; -export * from '../ops/ragged_to_dense_util'; -export * from '../ops/reduce_util'; - -import * as slice_util from '../ops/slice_util'; -export {slice_util}; - -export {BackendValues, TypedArray, upcastType, PixelData} from '../types'; -export {MemoryInfo, TimingInfo} from '../engine'; -export * from '../ops/rotate_util'; -export * from '../ops/array_ops_util'; -export * from '../ops/gather_nd_util'; -export * from '../ops/scatter_nd_util'; -export * from '../ops/selu_util'; -export * from '../ops/fused_util'; -export * from '../ops/erf_util'; -export * from '../log'; -export * from '../backends/complex_util'; -export * from '../backends/einsum_util'; -export * from '../ops/split_util'; -export * from '../ops/sparse/sparse_fill_empty_rows_util'; -export * from '../ops/sparse/sparse_reshape_util'; -export * from '../ops/sparse/sparse_segment_reduction_util'; - -import * as segment_util from '../ops/segment_util'; -export {segment_util}; - -export function fromUint8ToStringArray(vals: Uint8Array[]) { - try { - // Decode the bytes into string. - return vals.map(val => decodeString(val)); - } catch (err) { - throw new Error( - `Failed to decode encoded string bytes into utf-8, error: ${err}`); - } -} - -export function fromStringArrayToUint8(strings: string[]) { - return strings.map(s => encodeString(s)); -} diff --git a/tfjs-master/tfjs-core/src/backends/complex_util.ts b/tfjs-master/tfjs-core/src/backends/complex_util.ts deleted file mode 100644 index 28bfdd052..000000000 --- a/tfjs-master/tfjs-core/src/backends/complex_util.ts +++ /dev/null @@ -1,153 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {TypedArray} from '../types'; -/** - * Merges real and imaginary Float32Arrays into a single complex Float32Array. - * - * The memory layout is interleaved as follows: - * real: [r0, r1, r2] - * imag: [i0, i1, i2] - * complex: [r0, i0, r1, i1, r2, i2] - * - * This is the inverse of splitRealAndImagArrays. - * - * @param real The real values of the complex tensor values. - * @param imag The imag values of the complex tensor values. - * @returns A complex tensor as a Float32Array with merged values. - */ -export function mergeRealAndImagArrays( - real: Float32Array, imag: Float32Array): Float32Array { - if (real.length !== imag.length) { - throw new Error( - `Cannot merge real and imag arrays of different lengths. real:` + - `${real.length}, imag: ${imag.length}.`); - } - const result = new Float32Array(real.length * 2); - for (let i = 0; i < result.length; i += 2) { - result[i] = real[i / 2]; - result[i + 1] = imag[i / 2]; - } - return result; -} - -/** - * Splits a complex Float32Array into real and imag parts. - * - * The memory layout is interleaved as follows: - * complex: [r0, i0, r1, i1, r2, i2] - * real: [r0, r1, r2] - * imag: [i0, i1, i2] - * - * This is the inverse of mergeRealAndImagArrays. - * - * @param complex The complex tensor values. - * @returns An object with real and imag Float32Array components of the complex - * tensor. - */ -export function splitRealAndImagArrays(complex: Float32Array): - {real: Float32Array, imag: Float32Array} { - const real = new Float32Array(complex.length / 2); - const imag = new Float32Array(complex.length / 2); - for (let i = 0; i < complex.length; i += 2) { - real[i / 2] = complex[i]; - imag[i / 2] = complex[i + 1]; - } - return {real, imag}; -} - -/** - * Extracts even indexed complex values in the given array. - * @param complex The complex tensor values - */ -export function complexWithEvenIndex(complex: Float32Array): - {real: Float32Array, imag: Float32Array} { - const len = Math.ceil(complex.length / 4); - const real = new Float32Array(len); - const imag = new Float32Array(len); - for (let i = 0; i < complex.length; i += 4) { - real[Math.floor(i / 4)] = complex[i]; - imag[Math.floor(i / 4)] = complex[i + 1]; - } - return {real, imag}; -} - -/** - * Extracts odd indexed comple values in the given array. - * @param complex The complex tensor values - */ -export function complexWithOddIndex(complex: Float32Array): - {real: Float32Array, imag: Float32Array} { - const len = Math.floor(complex.length / 4); - const real = new Float32Array(len); - const imag = new Float32Array(len); - for (let i = 2; i < complex.length; i += 4) { - real[Math.floor(i / 4)] = complex[i]; - imag[Math.floor(i / 4)] = complex[i + 1]; - } - return {real, imag}; -} - -/** - * Get the map representing a complex value in the given array. - * @param complex The complex tensor values. - * @param index An index of the target complex value. - */ -export function getComplexWithIndex( - complex: Float32Array, index: number): {real: number, imag: number} { - const real = complex[index * 2]; - const imag = complex[index * 2 + 1]; - return {real, imag}; -} - -/** - * Insert a given complex value into the TypedArray. - * @param data The array in which the complex value is inserted. - * @param c The complex value to be inserted. - * @param index An index of the target complex value. - */ -export function assignToTypedArray( - data: TypedArray, real: number, imag: number, index: number) { - data[index * 2] = real; - data[index * 2 + 1] = imag; -} - -/** - * Make the list of exponent terms used by FFT. - */ -export function exponents( - n: number, inverse: boolean): {real: Float32Array, imag: Float32Array} { - const real = new Float32Array(n / 2); - const imag = new Float32Array(n / 2); - for (let i = 0; i < Math.ceil(n / 2); i++) { - const x = (inverse ? 2 : -2) * Math.PI * (i / n); - real[i] = Math.cos(x); - imag[i] = Math.sin(x); - } - return {real, imag}; -} - -/** - * Make the exponent term used by FFT. - */ -export function exponent( - k: number, n: number, inverse: boolean): {real: number, imag: number} { - const x = (inverse ? 2 : -2) * Math.PI * (k / n); - const real = Math.cos(x); - const imag = Math.sin(x); - return {real, imag}; -} diff --git a/tfjs-master/tfjs-core/src/backends/complex_util_test.ts b/tfjs-master/tfjs-core/src/backends/complex_util_test.ts deleted file mode 100644 index 721bd729a..000000000 --- a/tfjs-master/tfjs-core/src/backends/complex_util_test.ts +++ /dev/null @@ -1,76 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -import * as complex_util from './complex_util'; - -describe('complex_util', () => { - it('mergeRealAndImagArrays', () => { - const real = new Float32Array([1, 2, 3]); - const imag = new Float32Array([4, 5, 6]); - const complex = complex_util.mergeRealAndImagArrays(real, imag); - expect(complex).toEqual(new Float32Array([1, 4, 2, 5, 3, 6])); - }); - - it('splitRealAndImagArrays', () => { - const complex = new Float32Array([1, 4, 2, 5, 3, 6]); - const result = complex_util.splitRealAndImagArrays(complex); - expect(result.real).toEqual(new Float32Array([1, 2, 3])); - expect(result.imag).toEqual(new Float32Array([4, 5, 6])); - }); - - it('complexWithEvenIndex', () => { - const complex = new Float32Array([1, 2, 3, 4, 5, 6]); - const result = complex_util.complexWithEvenIndex(complex); - expect(result.real).toEqual(new Float32Array([1, 5])); - expect(result.imag).toEqual(new Float32Array([2, 6])); - }); - - it('complexWithOddIndex', () => { - const complex = new Float32Array([1, 2, 3, 4, 5, 6]); - const result = complex_util.complexWithOddIndex(complex); - expect(result.real).toEqual(new Float32Array([3])); - expect(result.imag).toEqual(new Float32Array([4])); - }); -}); - -describeWithFlags('complex_util exponents', ALL_ENVS, () => { - it('exponents inverse=false', () => { - const inverse = false; - const result = complex_util.exponents(5, inverse); - expectArraysClose(result.real, new Float32Array([1, 0.30901700258255005])); - expectArraysClose(result.imag, new Float32Array([0, -0.9510565400123596])); - }); - it('exponents inverse=true', () => { - const inverse = true; - const result = complex_util.exponents(5, inverse); - expectArraysClose(result.real, new Float32Array([1, 0.30901700258255005])); - expectArraysClose(result.imag, new Float32Array([0, 0.9510565400123596])); - }); -}); - -describeWithFlags('complex_util assignment', ALL_ENVS, () => { - it('assign complex value in TypedArray', () => { - const t = new Float32Array(4); - - complex_util.assignToTypedArray(t, 1, 2, 0); - complex_util.assignToTypedArray(t, 3, 4, 1); - - expectArraysClose(t, new Float32Array([1, 2, 3, 4])); - }); -}); diff --git a/tfjs-master/tfjs-core/src/backends/einsum_util.ts b/tfjs-master/tfjs-core/src/backends/einsum_util.ts deleted file mode 100644 index aef34779f..000000000 --- a/tfjs-master/tfjs-core/src/backends/einsum_util.ts +++ /dev/null @@ -1,220 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -/** - * Utility functions for computing einsum (tensor contraction and summation - * based on Einstein summation.) - */ - -import {Tensor} from '../tensor'; -import {assert} from '../util_base'; - -const ARROW = '->'; -const ARROW_REGEX = /->/g; -const COMMA = ','; -const ELLIPSIS = '...'; - -/** - * Parse an equation for einsum. - * - * @param equation The einsum equation (e.g., "ij,jk->ik"). - * @param numTensors Number of tensors provided along with `equation`. Used to - * check matching number of input tensors. - * @returns An object consisting of the following fields: - * - allDims: all dimension names as strings. - * - summedDims: a list of all dimensions being summed over, as indices to - * the elements of `allDims`. - * - idDims: indices of the dimensions in each input tensor, as indices to - * the elements of `allDims. - */ -export function decodeEinsumEquation(equation: string, numTensors: number): { - allDims: string[], - summedDims: number[], - idDims: number[][], -} { - equation = equation.replace(/\s/g, ''); // Remove witespace in equation. - const numArrows = - (equation.length - equation.replace(ARROW_REGEX, '').length) / - ARROW.length; - if (numArrows < 1) { - throw new Error('Equations without an arrow are not supported.'); - } else if (numArrows > 1) { - throw new Error(`Equation must contain exactly one arrow ("${ARROW}").`); - } - const [inputString, outputString] = equation.split(ARROW); - assert( - inputString.indexOf(ELLIPSIS) === -1, - () => `The ellipsis notation ("${ELLIPSIS}") is not supported yet.`); - const inputTerms = inputString.split(COMMA); - const numInputs = inputTerms.length; - if (numTensors !== numInputs) { - throw new Error( - `Expected ${numInputs} input tensors, received ${numTensors}`); - } - if (numInputs > 2) { - throw new Error( - 'Support for more than 2 input tensors is not implemented yet.'); - } - - const allDims: string[] = []; - for (let i = 0; i < outputString.length; ++i) { - const dimName = outputString[i]; - if (!inputTerms.some(inputTerm => inputTerm.indexOf(dimName) !== -1)) { - throw new Error( - `Output subscripts contain the label ${dimName} ` + - `not present in the input subscripts.`); - } - if (allDims.indexOf(dimName) === -1) { - allDims.push(dimName); - } - } - for (let i = 0; i < inputString.length; ++i) { - const dimName = inputString[i]; - if (allDims.indexOf(dimName) === -1 && dimName !== COMMA) { - allDims.push(dimName); - } - } - - const idDims: number[][] = new Array(inputTerms.length); - for (let i = 0; i < numInputs; ++i) { - if (new Set(inputTerms[i].split('')).size !== inputTerms[i].length) { - throw new Error( - `Found duplicate axes in input component ${inputTerms[i]}. ` + - `Support for duplicate axes in input is not implemented yet.`); - } - idDims[i] = []; - for (let j = 0; j < inputTerms[i].length; ++j) { - idDims[i].push(allDims.indexOf(inputTerms[i][j])); - } - } - - const numDims = allDims.length; // Number of unique dimensions. - const numOutDims = outputString.length; // Number of output dimensions. - const summedDims: number[] = []; // Dimensions being summed over. - for (let i = numOutDims; i < numDims; ++i) { - summedDims.push(i); - } - return {allDims, summedDims, idDims}; -} - -/** - * Get the permutation for a given input tensor. - * - * @param nDims Total number of dimension of all tensors involved in the einsum - * operation. - * @param idDims Dimension indices involve in the tensor in question. - * @returns An object consisting of the following fields: - * - permutationIndices: Indices to permute the axes of the tensor with. - * - expandDims: Indices to the dimension that need to be expanded from the - * tensor after permutation. - */ -export function getEinsumPermutation(nDims: number, idDims: number[]): - {permutationIndices: number[], expandDims: number[]} { - let permutationIndices: number[] = new Array(nDims); - permutationIndices.fill(-1); - for (let i = 0; i < idDims.length; ++i) { - permutationIndices[idDims[i]] = i; - } - const expandDims: number[] = []; - for (let i = 0; i < nDims; ++i) { - if (permutationIndices[i] === -1) { - expandDims.push(i); - } - } - permutationIndices = permutationIndices.filter(d => d !== -1); - return {permutationIndices, expandDims}; -} - -/** - * Checks that the dimension sizes from different input tensors match the - * equation. - */ -export function checkEinsumDimSizes( - nDims: number, idDims: number[][], tensors: Tensor[]) { - const dimSizes: number[] = new Array(nDims); - for (let i = 0; i < tensors.length; ++i) { - const shape: number[] = tensors[i].shape; - for (let j = 0; j < idDims[i].length; ++j) { - if (dimSizes[idDims[i][j]] === undefined) { - dimSizes[idDims[i][j]] = shape[j]; - } else { - assert( - dimSizes[idDims[i][j]] === shape[j], - () => `Expected dimension ${dimSizes[idDims[i][j]]} at axis ${j} ` + - `of input shaped ${JSON.stringify(shape)}, ` + - `but got dimension ${shape[j]}`); - } - } - } -} - -/** - * Gets path of computation for einsum. - * - * @param summedDims indices to the dimensions being summed over. - * @param idDims A look up table for the dimensions present in each input - * tensor. Each consituent array contains indices for the dimensions in the - * corresponding input tensor. - * - * @return A map with two fields: - * - path: The path of computation, with each element indicating the dimension - * being summed over after the element-wise multiplication in that step. - * - steps: With the same length as `path`. Each element contains the indices - * to the input tensors being used for element-wise multiplication in the - * corresponding step. - */ -export function getEinsumComputePath(summedDims: number[], idDims: number[][]): - {path: number[], steps: number[][]} { - const path: number[] = summedDims; - const steps: number[][] = []; - let nSteps = 0; - if (summedDims.length === 0) { - // Einsum that involes no summing: e.g., transpose and outer product. - path.push(-1); - } - nSteps = summedDims.length + 1; - for (let i = 0; i < nSteps; ++i) { - steps.push([]); - } - const computedTermIndices: number[] = []; - for (let i = 0; i < path.length; ++i) { - const summedDim = path[i]; - const termIndices = findTermsWithDim(idDims, summedDim); - for (const termIndex of termIndices) { - if (computedTermIndices.indexOf(termIndex) === -1) { - steps[i].push(termIndex); - computedTermIndices.push(termIndex); - } - } - } - return {path, steps}; -} - -/** Determines if an axes permutation is the identity permutation. */ -export function isIdentityPermutation(perm: number[]): boolean { - return perm.every((dim: number, index: number) => dim === index); -} - -function findTermsWithDim(idDims: number[][], dim: number): number[] { - const termIndices: number[] = []; - for (let i = 0; i < idDims.length; ++i) { - if (idDims[i].length === 0 || idDims[i].indexOf(dim) !== -1 || dim === -1) { - termIndices.push(i); - } - } - return termIndices; -} diff --git a/tfjs-master/tfjs-core/src/backends/kernel_impls.ts b/tfjs-master/tfjs-core/src/backends/kernel_impls.ts deleted file mode 100644 index 867abfcef..000000000 --- a/tfjs-master/tfjs-core/src/backends/kernel_impls.ts +++ /dev/null @@ -1,19 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -export {nonMaxSuppressionV3Impl, nonMaxSuppressionV4Impl, nonMaxSuppressionV5Impl} from './non_max_suppression_impl'; -export {whereImpl} from './where_impl'; diff --git a/tfjs-master/tfjs-core/src/backends/non_max_suppression_impl.ts b/tfjs-master/tfjs-core/src/backends/non_max_suppression_impl.ts deleted file mode 100644 index 51b45a577..000000000 --- a/tfjs-master/tfjs-core/src/backends/non_max_suppression_impl.ts +++ /dev/null @@ -1,205 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {TypedArray} from '../types'; -import {binaryInsert} from './non_max_suppression_util'; - -/** - * Implementation of the NonMaxSuppression kernel shared between webgl and cpu. - */ -interface Candidate { - score: number; - boxIndex: number; - suppressBeginIndex: number; -} - -interface NonMaxSuppressionResult { - selectedIndices: number[]; - selectedScores?: number[]; - validOutputs?: number; -} - -export function nonMaxSuppressionV3Impl( - boxes: TypedArray, scores: TypedArray, maxOutputSize: number, - iouThreshold: number, scoreThreshold: number): NonMaxSuppressionResult { - return nonMaxSuppressionImpl_( - boxes, scores, maxOutputSize, iouThreshold, scoreThreshold, - 0 /* softNmsSigma */); -} - -export function nonMaxSuppressionV4Impl( - boxes: TypedArray, scores: TypedArray, maxOutputSize: number, - iouThreshold: number, scoreThreshold: number, - padToMaxOutputSize: boolean): NonMaxSuppressionResult { - return nonMaxSuppressionImpl_( - boxes, scores, maxOutputSize, iouThreshold, scoreThreshold, - 0 /* softNmsSigma */, false /* returnScoresTensor */, - padToMaxOutputSize /* padToMaxOutputSize */, true - /* returnValidOutputs */); -} - -export function nonMaxSuppressionV5Impl( - boxes: TypedArray, scores: TypedArray, maxOutputSize: number, - iouThreshold: number, scoreThreshold: number, - softNmsSigma: number): NonMaxSuppressionResult { - return nonMaxSuppressionImpl_( - boxes, scores, maxOutputSize, iouThreshold, scoreThreshold, softNmsSigma, - true /* returnScoresTensor */); -} - -function nonMaxSuppressionImpl_( - boxes: TypedArray, scores: TypedArray, maxOutputSize: number, - iouThreshold: number, scoreThreshold: number, softNmsSigma: number, - returnScoresTensor = false, padToMaxOutputSize = false, - returnValidOutputs = false): NonMaxSuppressionResult { - // The list is sorted in ascending order, so that we can always pop the - // candidate with the largest score in O(1) time. - const candidates = []; - - for (let i = 0; i < scores.length; i++) { - if (scores[i] > scoreThreshold) { - candidates.push({score: scores[i], boxIndex: i, suppressBeginIndex: 0}); - } - } - - candidates.sort(ascendingComparator); - - // If softNmsSigma is 0, the outcome of this algorithm is exactly same as - // before. - const scale = softNmsSigma > 0 ? (-0.5 / softNmsSigma) : 0.0; - - const selectedIndices: number[] = []; - const selectedScores: number[] = []; - - while (selectedIndices.length < maxOutputSize && candidates.length > 0) { - const candidate = candidates.pop(); - const {score: originalScore, boxIndex, suppressBeginIndex} = candidate; - - if (originalScore < scoreThreshold) { - break; - } - - // Overlapping boxes are likely to have similar scores, therefore we - // iterate through the previously selected boxes backwards in order to - // see if candidate's score should be suppressed. We use - // suppressBeginIndex to track and ensure a candidate can be suppressed - // by a selected box no more than once. Also, if the overlap exceeds - // iouThreshold, we simply ignore the candidate. - let ignoreCandidate = false; - for (let j = selectedIndices.length - 1; j >= suppressBeginIndex; --j) { - const iou = intersectionOverUnion(boxes, boxIndex, selectedIndices[j]); - - if (iou >= iouThreshold) { - ignoreCandidate = true; - break; - } - - candidate.score = - candidate.score * suppressWeight(iouThreshold, scale, iou); - - if (candidate.score <= scoreThreshold) { - break; - } - } - - // At this point, if `candidate.score` has not dropped below - // `scoreThreshold`, then we know that we went through all of the - // previous selections and can safely update `suppressBeginIndex` to the - // end of the selected array. Then we can re-insert the candidate with - // the updated score and suppressBeginIndex back in the candidate list. - // If on the other hand, `candidate.score` has dropped below the score - // threshold, we will not add it back to the candidates list. - candidate.suppressBeginIndex = selectedIndices.length; - - if (!ignoreCandidate) { - // Candidate has passed all the tests, and is not suppressed, so - // select the candidate. - if (candidate.score === originalScore) { - selectedIndices.push(boxIndex); - selectedScores.push(candidate.score); - } else if (candidate.score > scoreThreshold) { - // Candidate's score is suppressed but is still high enough to be - // considered, so add back to the candidates list. - binaryInsert(candidates, candidate, ascendingComparator); - } - } - } - - // NonMaxSuppressionV4 feature: padding output to maxOutputSize. - const validOutputs = selectedIndices.length; - const elemsToPad = maxOutputSize - validOutputs; - - if (padToMaxOutputSize && elemsToPad > 0) { - selectedIndices.push(...new Array(elemsToPad).fill(0)); - selectedScores.push(...new Array(elemsToPad).fill(0.0)); - } - - const result: NonMaxSuppressionResult = {selectedIndices}; - - if (returnScoresTensor) { - result['selectedScores'] = selectedScores; - } - - if (returnValidOutputs) { - result['validOutputs'] = validOutputs; - } - - return result; -} - -function intersectionOverUnion(boxes: TypedArray, i: number, j: number) { - const iCoord = boxes.subarray(i * 4, i * 4 + 4); - const jCoord = boxes.subarray(j * 4, j * 4 + 4); - const yminI = Math.min(iCoord[0], iCoord[2]); - const xminI = Math.min(iCoord[1], iCoord[3]); - const ymaxI = Math.max(iCoord[0], iCoord[2]); - const xmaxI = Math.max(iCoord[1], iCoord[3]); - const yminJ = Math.min(jCoord[0], jCoord[2]); - const xminJ = Math.min(jCoord[1], jCoord[3]); - const ymaxJ = Math.max(jCoord[0], jCoord[2]); - const xmaxJ = Math.max(jCoord[1], jCoord[3]); - const areaI = (ymaxI - yminI) * (xmaxI - xminI); - const areaJ = (ymaxJ - yminJ) * (xmaxJ - xminJ); - if (areaI <= 0 || areaJ <= 0) { - return 0.0; - } - const intersectionYmin = Math.max(yminI, yminJ); - const intersectionXmin = Math.max(xminI, xminJ); - const intersectionYmax = Math.min(ymaxI, ymaxJ); - const intersectionXmax = Math.min(xmaxI, xmaxJ); - const intersectionArea = Math.max(intersectionYmax - intersectionYmin, 0.0) * - Math.max(intersectionXmax - intersectionXmin, 0.0); - return intersectionArea / (areaI + areaJ - intersectionArea); -} - -// A Gaussian penalty function, this method always returns values in [0, 1]. -// The weight is a function of similarity, the more overlap two boxes are, the -// smaller the weight is, meaning highly overlapping boxe will be significantly -// penalized. On the other hand, a non-overlapping box will not be penalized. -function suppressWeight(iouThreshold: number, scale: number, iou: number) { - const weight = Math.exp(scale * iou * iou); - return iou <= iouThreshold ? weight : 0.0; -} - -function ascendingComparator(c1: Candidate, c2: Candidate) { - // For objects with same scores, we make the object with the larger index go - // first. In an array that pops from the end, this means that the object with - // the smaller index will be popped first. This ensures the same output as - // the TensorFlow python version. - return (c1.score - c2.score) || - ((c1.score === c2.score) && (c2.boxIndex - c1.boxIndex)); -} diff --git a/tfjs-master/tfjs-core/src/backends/non_max_suppression_util.ts b/tfjs-master/tfjs-core/src/backends/non_max_suppression_util.ts deleted file mode 100644 index 0a93f4355..000000000 --- a/tfjs-master/tfjs-core/src/backends/non_max_suppression_util.ts +++ /dev/null @@ -1,89 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -/** - * Inserts a value into a sorted array. This method allows duplicate, meaning it - * allows inserting duplicate value, in which case, the element will be inserted - * at the lowest index of the value. - * @param arr The array to modify. - * @param element The element to insert. - * @param comparator Optional. If no comparator is specified, elements are - * compared using array_util.defaultComparator, which is suitable for Strings - * and Numbers in ascending arrays. If the array contains multiple instances of - * the target value, the left-most instance will be returned. To provide a - * comparator, it should take 2 arguments to compare and return a negative, - * zero, or a positive number. - */ -export function binaryInsert( - arr: T[], element: T, comparator?: (a: T, b: T) => number) { - const index = binarySearch(arr, element, comparator); - const insertionPoint = index < 0 ? -(index + 1) : index; - arr.splice(insertionPoint, 0, element); -} - -/** - * Searches the array for the target using binary search, returns the index - * of the found element, or position to insert if element not found. If no - * comparator is specified, elements are compared using array_ - * util.defaultComparator, which is suitable for Strings and Numbers in - * ascending arrays. If the array contains multiple instances of the target - * value, the left-most instance will be returned. - * @param arr The array to be searched in. - * @param target The target to be searched for. - * @param comparator Should take 2 arguments to compare and return a negative, - * zero, or a positive number. - * @return Lowest index of the target value if found, otherwise the insertion - * point where the target should be inserted, in the form of - * (-insertionPoint - 1). - */ -export function binarySearch( - arr: T[], target: T, comparator?: (a: T, b: T) => number) { - return binarySearch_(arr, target, comparator || defaultComparator); -} - -/** - * Compares its two arguments for order. - * @param a The first element to be compared. - * @param b The second element to be compared. - * @return A negative number, zero, or a positive number as the first - * argument is less than, equal to, or greater than the second. - */ -function defaultComparator(a: T, b: T): number { - return a > b ? 1 : a < b ? -1 : 0; -} - -function binarySearch_( - arr: T[], target: T, comparator: (a: T, b: T) => number) { - let left = 0; - let right = arr.length; - let middle = 0; - let found = false; - while (left < right) { - middle = left + ((right - left) >>> 1); - const compareResult = comparator(target, arr[middle]); - if (compareResult > 0) { - left = middle + 1; - } else { - right = middle; - // If compareResult is 0, the value is found. We record it is found, - // and then keep looking because there may be duplicate. - found = !compareResult; - } - } - - return found ? left : -left - 1; -} diff --git a/tfjs-master/tfjs-core/src/backends/non_max_suppression_util_test.ts b/tfjs-master/tfjs-core/src/backends/non_max_suppression_util_test.ts deleted file mode 100644 index cec9bb3c5..000000000 --- a/tfjs-master/tfjs-core/src/backends/non_max_suppression_util_test.ts +++ /dev/null @@ -1,184 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as non_max_suppression_util from './non_max_suppression_util'; - -describe('non_max_suppression_util', () => { - const insertionPoint = (i: number) => -(i + 1); - - describe('binarySearch', () => { - const d = [ - -897123.9, -321434.58758, -1321.3124, -324, -9, -3, 0, 0, 0, 0.31255, 5, - 142.88888708, 334, 342, 453, 54254 - ]; - - it('-897123.9 should be found at index 0', () => { - const result = non_max_suppression_util.binarySearch(d, -897123.9); - expect(result).toBe(0); - }); - - it(`54254 should be found at index ${d.length - 1}`, () => { - const result = non_max_suppression_util.binarySearch(d, 54254); - expect(result).toBe(d.length - 1); - }); - - it('-3 should be found at index 5', () => { - const result = non_max_suppression_util.binarySearch(d, -3); - expect(result).toBe(5); - }); - - it('0 should be found at index 6', () => { - const result = non_max_suppression_util.binarySearch(d, 0); - expect(result).toBe(6); - }); - - it('-900000 should have an insertion point of 0', () => { - const result = non_max_suppression_util.binarySearch(d, -900000); - expect(result).toBeLessThan(0); - expect(insertionPoint(result)).toBe(0); - }); - - it(`54255 should have an insertion point of ${d.length}`, () => { - const result = non_max_suppression_util.binarySearch(d, 54255); - expect(result).toBeLessThan(0); - expect(insertionPoint(result)).toEqual(d.length); - }); - - it('1.1 should have an insertion point of 10', () => { - const result = non_max_suppression_util.binarySearch(d, 1.1); - expect(result).toBeLessThan(0); - expect(insertionPoint(result)).toEqual(10); - }); - }); - - describe('binarySearch with custom comparator', () => { - const e = [ - 54254, - 453, - 342, - 334, - 142.88888708, - 5, - 0.31255, - 0, - 0, - 0, - -3, - -9, - -324, - -1321.3124, - -321434.58758, - -897123.9, - ]; - - const revComparator = (a: number, b: number) => (b - a); - - it('54254 should be found at index 0', () => { - const result = - non_max_suppression_util.binarySearch(e, 54254, revComparator); - expect(result).toBe(0); - }); - - it(`-897123.9 should be found at index ${e.length - 1}`, () => { - const result = - non_max_suppression_util.binarySearch(e, -897123.9, revComparator); - expect(result).toBe(e.length - 1); - }); - - it('-3 should be found at index 10', () => { - const result = - non_max_suppression_util.binarySearch(e, -3, revComparator); - expect(result).toBe(10); - }); - - it('0 should be found at index 7', () => { - const result = non_max_suppression_util.binarySearch(e, 0, revComparator); - expect(result).toBe(7); - }); - - it('54254.1 should have an insertion point of 0', () => { - const result = - non_max_suppression_util.binarySearch(e, 54254.1, revComparator); - expect(result).toBeLessThan(0); - expect(insertionPoint(result)).toBe(0); - }); - - it(`-897124 should have an insertion point of ${e.length}`, () => { - const result = - non_max_suppression_util.binarySearch(e, -897124, revComparator); - expect(result).toBeLessThan(0); - expect(insertionPoint(result)).toBe(e.length); - }); - }); - - describe( - 'binarySearch with custom comparator with single element array', () => { - const g = [1]; - - const revComparator = (a: number, b: number) => (b - a); - - it('1 should be found at index 0', () => { - const result = - non_max_suppression_util.binarySearch(g, 1, revComparator); - expect(result).toBe(0); - }); - - it('2 should have an insertion point of 0', () => { - const result = - non_max_suppression_util.binarySearch(g, 2, revComparator); - expect(result).toBeLessThan(0); - expect(insertionPoint(result)).toBe(0); - }); - - it('0 should have an insertion point of 1', () => { - const result = - non_max_suppression_util.binarySearch(g, 0, revComparator); - expect(result).toBeLessThan(0); - expect(insertionPoint(result)).toBe(1); - }); - }); - - describe('binarySearch test left-most duplicated element', () => { - it('should find the index of the first 0', () => { - const result = non_max_suppression_util.binarySearch([0, 0, 1], 0); - expect(result).toBe(0); - }); - - it('should find the index of the first 1', () => { - const result = non_max_suppression_util.binarySearch([0, 1, 1], 1); - expect(result).toBe(1); - }); - }); - - describe('binaryInsert', () => { - it('inserts correctly', () => { - const a: number[] = []; - - non_max_suppression_util.binaryInsert(a, 3); - expect(a).toEqual([3]); - - non_max_suppression_util.binaryInsert(a, 3); - expect(a).toEqual([3, 3]); - - non_max_suppression_util.binaryInsert(a, 1); - expect(a).toEqual([1, 3, 3]); - - non_max_suppression_util.binaryInsert(a, 5); - expect(a).toEqual([1, 3, 3, 5]); - }); - }); -}); diff --git a/tfjs-master/tfjs-core/src/backends/where_impl.ts b/tfjs-master/tfjs-core/src/backends/where_impl.ts deleted file mode 100644 index bbfdebae3..000000000 --- a/tfjs-master/tfjs-core/src/backends/where_impl.ts +++ /dev/null @@ -1,41 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -/** An implementation of the Where kernel shared between cpu and webgl */ - -import {buffer} from '../ops/buffer'; -import {Tensor2D} from '../tensor'; -import {TypedArray} from '../types'; - -export function whereImpl(condShape: number[], condVals: TypedArray): Tensor2D { - const indices = []; - for (let i = 0; i < condVals.length; i++) { - if (condVals[i]) { - indices.push(i); - } - } - - const inBuffer = buffer(condShape, 'int32'); - - const out = buffer([indices.length, condShape.length], 'int32'); - for (let i = 0; i < indices.length; i++) { - const loc = inBuffer.indexToLoc(indices[i]); - const offset = i * condShape.length; - out.values.set(loc, offset); - } - return out.toTensor() as Tensor2D; -} diff --git a/tfjs-master/tfjs-core/src/base.ts b/tfjs-master/tfjs-core/src/base.ts deleted file mode 100644 index bda9e5657..000000000 --- a/tfjs-master/tfjs-core/src/base.ts +++ /dev/null @@ -1,103 +0,0 @@ -/** - * @license - * Copyright 2020 Google Inc. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// base.ts is tfjs-core without auto registration of things like flags, -// gradients, chained ops or the opHandler. See base_side_effects.ts for parts -// tfjs core that are required side effects. - -/** - * @fileoverview - * @suppress {partialAlias} Optimization disabled due to passing the module - * object into a function below: - * - * import * as ops from './ops/ops'; - * setOpHandler(ops); - */ - -// Serialization. -import * as io from './io/io'; -import * as math from './math'; -import * as broadcast_util from './ops/broadcast_util'; -import * as browser from './ops/browser'; -import * as gather_util from './ops/gather_nd_util'; -import * as scatter_util from './ops/scatter_nd_util'; -import * as slice_util from './ops/slice_util'; -import * as serialization from './serialization'; -import * as tensor_util from './tensor_util'; -import * as test_util from './test_util'; -import * as util from './util'; -import {version} from './version'; - -export {InferenceModel, MetaGraph, MetaGraphInfo, ModelPredictConfig, ModelTensorInfo, SavedModelTensorInfo, SignatureDef, SignatureDefEntry, SignatureDefInfo} from './model_types'; -export {AdadeltaOptimizer} from './optimizers/adadelta_optimizer'; -export {AdagradOptimizer} from './optimizers/adagrad_optimizer'; -export {AdamOptimizer} from './optimizers/adam_optimizer'; -export {AdamaxOptimizer} from './optimizers/adamax_optimizer'; -export {MomentumOptimizer} from './optimizers/momentum_optimizer'; -export {Optimizer} from './optimizers/optimizer'; -// Optimizers. -export {OptimizerConstructors} from './optimizers/optimizer_constructors'; -export {RMSPropOptimizer} from './optimizers/rmsprop_optimizer'; -export {SGDOptimizer} from './optimizers/sgd_optimizer'; -export {DataToGPUOptions, DataToGPUWebGLOption, GPUData, Scalar, Tensor, Tensor1D, Tensor2D, Tensor3D, Tensor4D, Tensor5D, TensorBuffer, Variable} from './tensor'; -export {GradSaveFunc, NamedTensorMap, TensorContainer, TensorContainerArray, TensorContainerObject} from './tensor_types'; -export {BackendValues, DataType, DataTypeMap, DataTypeFor, DataValues, NumericDataType, PixelData, Rank, RecursiveArray, ScalarLike, ShapeMap, sumOutType, TensorLike, TypedArray, upcastType, WebGLData, WebGPUData} from './types'; - -export * from './ops/ops'; -export {Reduction} from './ops/loss_ops_utils'; - -export * from './train'; -export * from './globals'; -export * from './kernel_registry'; -export {TensorInfo, DataId} from './tensor_info'; -export {customGrad, grad, grads, valueAndGrad, valueAndGrads, variableGrads} from './gradients'; - -export {TimingInfo, MemoryInfo, ForwardFunc} from './engine'; -export {Environment, env, ENV} from './environment'; -export {Platform} from './platforms/platform'; - -export {version as version_core}; - -// Top-level method exports. -export {nextFrame} from './browser_util'; - -// Second level exports. -import * as backend_util from './backends/backend_util'; -import * as device_util from './device_util'; -export { - browser, - io, - math, - serialization, - test_util, - util, - backend_util, - broadcast_util, - tensor_util, - slice_util, - gather_util, - scatter_util, - device_util -}; - -import * as kernel_impls from './backends/kernel_impls'; -export {kernel_impls}; -// Backend specific. -export {KernelBackend, BackendTimingInfo, DataMover, DataStorage} from './backends/backend'; - -// Export all kernel names / info. -export * from './kernel_names'; diff --git a/tfjs-master/tfjs-core/src/base_side_effects.ts b/tfjs-master/tfjs-core/src/base_side_effects.ts deleted file mode 100644 index 6c198966d..000000000 --- a/tfjs-master/tfjs-core/src/base_side_effects.ts +++ /dev/null @@ -1,42 +0,0 @@ -/** - * @license - * Copyright 2020 Google Inc. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// Required side effectful code for tfjs-core - -// Set up Engine and ENV -import {getOrMakeEngine} from './engine'; -getOrMakeEngine(); - -// Register backend-agnostic flags. -import './flags'; -// Register platforms -import './platforms/platform_browser'; -import './platforms/platform_node'; - -// Set up OpHandler -import {buffer} from './ops/buffer'; -import {cast} from './ops/cast'; -import {clone} from './ops/clone'; -import {print} from './ops/print'; -import {OpHandler, setOpHandler} from './tensor'; -const opHandler: OpHandler = { - buffer, - cast, - clone, - print -}; -setOpHandler(opHandler); diff --git a/tfjs-master/tfjs-core/src/browser_util.ts b/tfjs-master/tfjs-core/src/browser_util.ts deleted file mode 100644 index e853225a6..000000000 --- a/tfjs-master/tfjs-core/src/browser_util.ts +++ /dev/null @@ -1,41 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -const delayCallback: Function = (() => { - if (typeof requestAnimationFrame !== 'undefined') { - return requestAnimationFrame; - } else if (typeof setImmediate !== 'undefined') { - return setImmediate; - } - return (f: Function) => f(); // no delays -})(); - -/** - * Returns a promise that resolves when a requestAnimationFrame has completed. - * - * On Node.js this uses setImmediate instead of requestAnimationFrame. - * - * This is simply a sugar method so that users can do the following: - * `await tf.nextFrame();` - * - * @doc {heading: 'Performance', subheading: 'Timing'} - */ -function nextFrame(): Promise { - return new Promise(resolve => delayCallback(() => resolve())); -} - -export {nextFrame}; diff --git a/tfjs-master/tfjs-core/src/browser_util_test.ts b/tfjs-master/tfjs-core/src/browser_util_test.ts deleted file mode 100644 index c49b8ebd1..000000000 --- a/tfjs-master/tfjs-core/src/browser_util_test.ts +++ /dev/null @@ -1,57 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from './index'; -import {ALL_ENVS, describeWithFlags} from './jasmine_util'; - -function isFloat(num: number) { - return num % 1 !== 0; -} - -describeWithFlags('nextFrame', ALL_ENVS, () => { - it('basic usage', async () => { - const t0 = tf.util.now(); - await tf.nextFrame(); - const t1 = tf.util.now(); - - // tf.nextFrame may take no more than 1ms to complete, so this test is - // meaningful only if the precision of tf.util.now is better than 1ms. - // After version 59, the precision of Firefox's tf.util.now becomes 2ms by - // default for security issues, https://caniuse.com/?search=performance.now. - // Then, this test is dropped for Firefox, even though it could be - // set to better precision through browser setting, - // https://github.com/lumen/threading-benchmarks/issues/7. - if (isFloat(t0) || isFloat(t1)) { - // If t0 or t1 have decimal point, it means the precision is better than - // 1ms. - expect(t1).toBeGreaterThan(t0); - } - }); - - it('does not block timers', async () => { - let flag = false; - setTimeout(() => { - flag = true; - }, 50); - const t0 = tf.util.now(); - expect(flag).toBe(false); - while (tf.util.now() - t0 < 1000 && !flag) { - await tf.nextFrame(); - } - expect(flag).toBe(true); - }); -}); diff --git a/tfjs-master/tfjs-core/src/buffer_test.ts b/tfjs-master/tfjs-core/src/buffer_test.ts deleted file mode 100644 index 41c8effde..000000000 --- a/tfjs-master/tfjs-core/src/buffer_test.ts +++ /dev/null @@ -1,96 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from './index'; -import {ALL_ENVS, describeWithFlags} from './jasmine_util'; -import {expectArraysClose, expectArraysEqual} from './test_util'; - -describeWithFlags('tf.buffer', ALL_ENVS, () => { - it('float32', async () => { - const buff = tf.buffer([1, 2, 3], 'float32'); - buff.set(1.3, 0, 0, 0); - buff.set(2.9, 0, 1, 0); - expect(buff.get(0, 0, 0)).toBeCloseTo(1.3); - expect(buff.get(0, 0, 1)).toBeCloseTo(0); - expect(buff.get(0, 0, 2)).toBeCloseTo(0); - expect(buff.get(0, 1, 0)).toBeCloseTo(2.9); - expect(buff.get(0, 1, 1)).toBeCloseTo(0); - expect(buff.get(0, 1, 2)).toBeCloseTo(0); - expectArraysClose(await buff.toTensor().data(), [1.3, 0, 0, 2.9, 0, 0]); - expectArraysClose(buff.values, new Float32Array([1.3, 0, 0, 2.9, 0, 0])); - }); - - it('get() out of range throws', async () => { - const t = tf.tensor([1, 2, 3, 4, 5, 6, 7, 8], [2, 2, 2]); - - const buff = await t.buffer(); - expect(buff.get(0, 0, 0)).toBeCloseTo(1); - expect(buff.get(0, 0, 1)).toBeCloseTo(2); - expect(() => buff.get(0, 0, 2)) - .toThrowError(/Requested out of range element/); - }); - - it('int32', async () => { - const buff = tf.buffer([2, 3], 'int32'); - buff.set(1.3, 0, 0); - buff.set(2.1, 1, 1); - expect(buff.get(0, 0)).toEqual(1); - expect(buff.get(0, 1)).toEqual(0); - expect(buff.get(0, 2)).toEqual(0); - expect(buff.get(1, 0)).toEqual(0); - expect(buff.get(1, 1)).toEqual(2); - expect(buff.get(1, 2)).toEqual(0); - expectArraysClose(await buff.toTensor().data(), [1, 0, 0, 0, 2, 0]); - expectArraysClose(buff.values, new Int32Array([1, 0, 0, 0, 2, 0])); - }); - - it('bool', async () => { - const buff = tf.buffer([4], 'bool'); - buff.set(true, 1); - buff.set(true, 2); - expect(buff.get(0)).toBeFalsy(); - expect(buff.get(1)).toBeTruthy(); - expect(buff.get(2)).toBeTruthy(); - expect(buff.get(3)).toBeFalsy(); - expectArraysClose(await buff.toTensor().data(), [0, 1, 1, 0]); - expectArraysClose(buff.values, new Uint8Array([0, 1, 1, 0])); - }); - - it('string', async () => { - const buff = tf.buffer([2, 2], 'string'); - buff.set('first', 0, 0); - buff.set('third', 1, 0); - expect(buff.get(0, 0)).toEqual('first'); - expect(buff.get(0, 1)).toBeFalsy(); - expect(buff.get(1, 0)).toEqual('third'); - expect(buff.get(1, 1)).toBeFalsy(); - expectArraysEqual( - await buff.toTensor().data(), ['first', null, 'third', null]); - }); - - it('throws when passed non-integer shape', () => { - const msg = 'Tensor must have a shape comprised of positive ' + - 'integers but got shape [2,2.2].'; - expect(() => tf.buffer([2, 2.2])).toThrowError(msg); - }); - - it('throws when passed negative shape', () => { - const msg = 'Tensor must have a shape comprised of positive ' + - 'integers but got shape [2,-2].'; - expect(() => tf.buffer([2, -2])).toThrowError(msg); - }); -}); diff --git a/tfjs-master/tfjs-core/src/debug_mode_test.ts b/tfjs-master/tfjs-core/src/debug_mode_test.ts deleted file mode 100644 index d32caad0f..000000000 --- a/tfjs-master/tfjs-core/src/debug_mode_test.ts +++ /dev/null @@ -1,123 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from './index'; -import {ALL_ENVS, describeWithFlags, SYNC_BACKEND_ENVS} from './jasmine_util'; -import {convertToTensor} from './tensor_util_env'; -import {expectArraysClose} from './test_util'; - -describeWithFlags('debug on', SYNC_BACKEND_ENVS, () => { - beforeAll(() => { - // Silence debug warnings. - spyOn(console, 'warn'); - tf.enableDebugMode(); - }); - - it('debug mode does not error when no nans', async () => { - const a = tf.tensor1d([2, -1, 0, 3]); - const res = tf.relu(a); - expectArraysClose(await res.data(), [2, 0, 0, 3]); - }); - - it('debug mode errors when nans in tensor construction, float32', () => { - const a = () => tf.tensor1d([2, NaN], 'float32'); - expect(a).toThrowError(); - }); - - it('debug mode errors when nans in tensor construction, int32', () => { - const a = () => tf.tensor1d([2, NaN], 'int32'); - expect(a).toThrowError(); - }); - - it('debug mode errors when Infinity in tensor construction', () => { - const a = () => tf.tensor1d([2, Infinity], 'float32'); - expect(a).toThrowError(); - }); - - it('debug mode errors when nans in tensor created from TypedArray', () => { - const a = () => tf.tensor1d(new Float32Array([1, 2, NaN]), 'float32'); - expect(a).toThrowError(); - }); - - it('debug mode errors when infinities in op output', async () => { - const a = tf.tensor1d([1, 2, 3, 4]); - const b = tf.tensor1d([2, -1, 0, 3]); - - const c = async () => { - const result = a.div(b); - // Must await result so we know exception would have happened by the - // time we call `expect`. - await result.data(); - }; - - await c(); - - expect(console.warn).toHaveBeenCalled(); - }); - - it('debug mode errors when nans in op output', async () => { - const a = tf.tensor1d([-1, 2]); - const b = tf.tensor1d([0.5, 1]); - - const c = async () => { - const result = a.pow(b); - await result.data(); - }; - - await c(); - - expect(console.warn).toHaveBeenCalled(); - }); - - it('debug mode errors when nans in oneHot op (tensorlike), int32', () => { - const f = () => tf.oneHot([2, NaN], 3); - expect(f).toThrowError(); - }); - - it('debug mode errors when nan in convertToTensor, int32', () => { - const a = () => convertToTensor(NaN, 'a', 'test', 'int32'); - expect(a).toThrowError(); - }); - - it('debug mode errors when nan in convertToTensor array input, int32', () => { - const a = () => convertToTensor([NaN], 'a', 'test', 'int32'); - expect(a).toThrowError(); - }); - - // tslint:disable-next-line: ban - xit('A x B', async () => { - const a = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - const b = tf.tensor2d([0, 1, -3, 2, 2, 1], [3, 2]); - - const c = tf.matMul(a, b); - - expect(c.shape).toEqual([2, 2]); - expectArraysClose(await c.data(), [0, 8, -3, 20]); - }); -}); - -describeWithFlags('debug off', ALL_ENVS, () => { - beforeAll(() => { - tf.env().set('DEBUG', false); - }); - - it('no errors where there are nans, and debug mode is disabled', async () => { - const a = tf.tensor1d([2, NaN]); - const res = tf.relu(a); - expectArraysClose(await res.data(), [2, NaN]); - }); -}); diff --git a/tfjs-master/tfjs-core/src/device_util.ts b/tfjs-master/tfjs-core/src/device_util.ts deleted file mode 100644 index 1ae970298..000000000 --- a/tfjs-master/tfjs-core/src/device_util.ts +++ /dev/null @@ -1,64 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// tslint:disable-next-line:no-any -function _isNavigatorDefined(): boolean { - return typeof navigator !== 'undefined' && navigator != null; -} - -let isMobileMockValue: boolean|undefined; - -export function mockIsMobile(value: boolean|undefined) { - isMobileMockValue = value; -} - -export function isMobile(nav?: Navigator): boolean { - if (isMobileMockValue !== undefined) { - return isMobileMockValue; - } - if (nav || _isNavigatorDefined()) { - if (!nav) { - nav = navigator; - } - if (nav.product === 'ReactNative') { - return true; - } - - const a = nav.userAgent || nav.vendor || - // tslint:disable-next-line:no-any - (typeof window !== 'undefined' ? (window as any).opera : ''); - // Use `navigator.userAgentData.mobile` as fallback. - if (!a) { - // tslint:disable-next-line:no-any - const navAny = nav as any; - return navAny.userAgentData && navAny.userAgentData.mobile; - } - // tslint:disable-next-line:max-line-length - return /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i - .test(a) || - // tslint:disable-next-line:max-line-length - /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i - .test(a.substr(0, 4)); - } - return false; -} - -export function isBrowser(): boolean { - return (typeof window !== 'undefined' && window.document != null) || - //@ts-ignore - (typeof WorkerGlobalScope !== 'undefined'); -} diff --git a/tfjs-master/tfjs-core/src/device_util_test.ts b/tfjs-master/tfjs-core/src/device_util_test.ts deleted file mode 100644 index 15a4812a7..000000000 --- a/tfjs-master/tfjs-core/src/device_util_test.ts +++ /dev/null @@ -1,29 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as device_util from './device_util'; -import {ALL_ENVS, describeWithFlags} from './jasmine_util'; - -describeWithFlags('isMobile', ALL_ENVS, () => { - it('should not fail when navigator is set', () => { - expect(() => device_util.isMobile()).not.toThrow(); - }); - it('identifies react native as a mobile device', () => { - expect(device_util.isMobile( - {product: 'ReactNative'} as Navigator)).toEqual(true); - }); -}); diff --git a/tfjs-master/tfjs-core/src/engine.ts b/tfjs-master/tfjs-core/src/engine.ts deleted file mode 100644 index a29b04c24..000000000 --- a/tfjs-master/tfjs-core/src/engine.ts +++ /dev/null @@ -1,1315 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {BackendTimingInfo, DataMover, KernelBackend} from './backends/backend'; -import {Environment, setEnvironmentGlobal} from './environment'; -import {getGlobalNamespace} from './global_util'; -import {Add, Cast, Identity} from './kernel_names'; -import { getGradient, getKernel, getKernelsForBackend, GradFunc, NamedAttrMap } from './kernel_registry'; -import { TensorInfo } from './tensor_info'; -import * as log from './log'; -import {KernelProfile, Profiler} from './profiler'; -import {backpropagateGradients, getFilteredNodesXToY, TapeNode} from './tape'; -import {DataToGPUOptions, GPUData, setTensorTracker, Tensor, TensorTracker, Variable} from './tensor'; -import {DataId} from './tensor_info'; -import {GradSaveFunc, NamedTensorMap, NamedVariableMap, TensorContainer} from './tensor_types'; -import {getTensorsInContainer} from './tensor_util'; -import {BackendValues, DataType, DataValues} from './types'; -import * as util from './util'; -import {bytesFromStringArray, makeOnesTypedArray, now, sizeFromShape} from './util'; - -/** - * A function that computes an output. The save function is for saving tensors - * computed in the forward pass, that we need in the backward pass. - */ -export type ForwardFunc = (backend: KernelBackend, save?: GradSaveFunc) => T; - -/** - * @docalias (a: Tensor, b: Tensor,..., save?: Function) => { - * value: Tensor, - * gradFunc: (dy: Tensor, saved?: NamedTensorMap) => Tensor | Tensor[] - * } - */ -export type CustomGradientFunc = - (...inputs: Array) => { - value: T; - gradFunc: (dy: T, saved: Tensor[]) => Tensor | Tensor[]; - }; - -export type MemoryInfo = { - numTensors: number; numDataBuffers: number; numBytes: number; - unreliable?: boolean; reasons: string[]; -}; - -type KernelInfo = { - name: string; bytesAdded: number; totalBytesSnapshot: number; - tensorsAdded: number; - totalTensorsSnapshot: number; - inputShapes: number[][]; - outputShapes: number[][]; - kernelTimeMs: number | {error: string} | Promise; - extraInfo: string | Promise; -}; - -export type ProfileInfo = { - newBytes: number; newTensors: number; peakBytes: number; - kernels: KernelInfo[]; - result: TensorContainer; - kernelNames: string[]; -}; - -export interface TimingInfo extends BackendTimingInfo { - wallMs: number; -} - -/** @docalias Function */ -export type ScopeFn = () => T; - -interface ScopeState { - track: Tensor[]; - name: string; - id: number; -} - -interface RegisteredKernelInvocation { - kernelName: string; - inputs: I; - attrs?: NamedAttrMap; -} - -interface CustomGradKernelInvocation { - forwardFunc: ForwardFunc; - backwardsFunc: (dy: T, saved: Tensor[]) => { - [P in keyof I]: () => I[P] - }; - inputs: I; - attrs?: NamedAttrMap; -} - -function isRegisteredKernelInvocation( - kernelInvocation: RegisteredKernelInvocation| - CustomGradKernelInvocation): - kernelInvocation is RegisteredKernelInvocation { - return (kernelInvocation as RegisteredKernelInvocation).kernelName != null; -} - -class EngineState { - // Public since optimizers will use it. - registeredVariables: NamedVariableMap = {}; - - nextTapeNodeId = 0; - numBytes = 0; - numTensors = 0; - numStringTensors = 0; - numDataBuffers = 0; - - activeTape: TapeNode[]; - // Number of nested tf.grad() statements when computing higher-order - // gradients. E.g. `1` for first-order gradients and `2` for second-order - // gradients. Used to track if the tape should be removed after a backprop. - gradientDepth = 0; - // Number of nested kernel calls. When kernel depth is greater than 1, we turn - // off the tape. - kernelDepth = 0; - - // Keep Tensors that parallel the tapes. - activeScope: ScopeState; - scopeStack: ScopeState[] = []; - /** - * Keeps track of the number of data moves during a kernel execution. We - * maintain a stack since kernels can call other kernels, recursively. - */ - numDataMovesStack: number[] = []; - nextScopeId = 0; - - tensorInfo = new WeakMap(); - - profiling = false; - activeProfile: ProfileInfo = { - newBytes: 0, - newTensors: 0, - peakBytes: 0, - kernels: [], - result: null, - get kernelNames(): - string[] { - return Array.from(new Set(this.kernels.map(k => k.name))); - } - }; - - dispose() { - for (const variableName in this.registeredVariables) { - this.registeredVariables[variableName].dispose(); - } - } -} - -export class Engine implements TensorTracker, DataMover { - state: EngineState; - backendName: string; - registry: {[id: string]: KernelBackend} = {}; - registryFactory: { - [id: string]: { - factory: () => KernelBackend | Promise, - priority: number - } - } = {}; - - private profiler: Profiler; - private backendInstance: KernelBackend; - private pendingBackendInit: Promise; - private pendingBackendInitId = 0; - - constructor(public ENV: Environment) { - this.state = new EngineState(); - } - - async ready(): Promise { - if (this.pendingBackendInit != null) { - return this.pendingBackendInit.then(() => {}); - } - if (this.backendInstance != null) { - return; - } - const sortedBackends = this.getSortedBackends(); - - for (let i = 0; i < sortedBackends.length; i++) { - const backendName = sortedBackends[i]; - const success = await this.initializeBackend(backendName).success; - if (success) { - await this.setBackend(backendName); - return; - } - } - - throw new Error( - `Could not initialize any backends, all backend initializations ` + - `failed.`); - } - - get backend(): KernelBackend { - if (this.pendingBackendInit != null) { - throw new Error( - `Backend '${this.backendName}' has not yet been initialized. Make ` + - `sure to await tf.ready() or await tf.setBackend() before calling ` + - `other methods`); - } - if (this.backendInstance == null) { - const {name, asyncInit} = this.initializeBackendsAndReturnBest(); - if (asyncInit) { - throw new Error( - `The highest priority backend '${name}' has not yet been ` + - `initialized. Make sure to await tf.ready() or ` + - `await tf.setBackend() before calling other methods`); - } - this.setBackend(name); - } - return this.backendInstance; - } - - backendNames(): string[] { - return Object.keys(this.registryFactory); - } - - findBackend(backendName: string): KernelBackend { - if (!(backendName in this.registry)) { - // If the backend hasn't been initialized but we have a registry entry for - // it, initialize it and return it. - if (backendName in this.registryFactory) { - const {asyncInit} = this.initializeBackend(backendName); - if (asyncInit) { - // Backend is not ready yet. - return null; - } - } else { - return null; - } - } - return this.registry[backendName]; - } - - findBackendFactory(backendName: string): - () => KernelBackend | Promise { - if (!(backendName in this.registryFactory)) { - return null; - } - return this.registryFactory[backendName].factory; - } - - registerBackend( - backendName: string, - factory: () => KernelBackend | Promise, - priority = 1): boolean { - if (backendName in this.registryFactory) { - log.warn( - `${backendName} backend was already registered. ` + - `Reusing existing backend factory.`); - return false; - } - this.registryFactory[backendName] = {factory, priority}; - return true; - } - - async setBackend(backendName: string): Promise { - if (this.registryFactory[backendName] == null) { - throw new Error(`Backend name '${backendName}' not found in registry`); - } - this.backendName = backendName; - if (this.registry[backendName] == null) { - this.backendInstance = null; - const {success, asyncInit} = this.initializeBackend(backendName); - const result = asyncInit ? await success : success; - if (!result) { - return false; - } - } - this.backendInstance = this.registry[backendName]; - this.setupRegisteredKernels(); - // Reset the profiler. - this.profiler = new Profiler(this.backendInstance); - - return true; - } - - private setupRegisteredKernels(): void { - const kernels = getKernelsForBackend(this.backendName); - kernels.forEach(kernel => { - if (kernel.setupFunc != null) { - kernel.setupFunc(this.backendInstance); - } - }); - } - - private disposeRegisteredKernels(backendName: string): void { - const kernels = getKernelsForBackend(backendName); - kernels.forEach(kernel => { - if (kernel.disposeFunc != null) { - kernel.disposeFunc(this.registry[backendName]); - } - }); - } - - /** - * Initializes a backend by looking up the backend name in the factory - * registry and calling the factory method. Returns a boolean representing - * whether the initialization of the backend suceeded. Throws an error if - * there is no backend in the factory registry. - */ - private initializeBackend(backendName: string): - {success: boolean|Promise, asyncInit: boolean} { - const registryFactoryEntry = this.registryFactory[backendName]; - if (registryFactoryEntry == null) { - throw new Error( - `Cannot initialize backend ${backendName}, no registration found.`); - } - - try { - const backend = registryFactoryEntry.factory(); - /* Test if the factory returns a promise. - Done in a more liberal way than - previous 'Promise.resolve(backend)===backend' - as we needed to account for custom Promise - implementations (e.g. Angular) */ - if (backend && !(backend instanceof KernelBackend) && - typeof backend.then === 'function') { - const promiseId = ++this.pendingBackendInitId; - const success = - backend - .then(backendInstance => { - // Outdated promise. Another backend was set in the meantime. - if (promiseId < this.pendingBackendInitId) { - return false; - } - this.registry[backendName] = backendInstance; - this.pendingBackendInit = null; - return true; - }) - .catch(err => { - // Outdated promise. Another backend was set in the meantime. - if (promiseId < this.pendingBackendInitId) { - return false; - } - this.pendingBackendInit = null; - log.warn(`Initialization of backend ${backendName} failed`); - log.warn(err.stack || err.message); - return false; - }); - this.pendingBackendInit = success; - return {success, asyncInit: true}; - } else { - this.registry[backendName] = backend as KernelBackend; - return {success: true, asyncInit: false}; - } - } catch (err) { - log.warn(`Initialization of backend ${backendName} failed`); - log.warn(err.stack || err.message); - return {success: false, asyncInit: false}; - } - } - - removeBackend(backendName: string): void { - if (!(backendName in this.registryFactory)) { - throw new Error(`${backendName} backend not found in registry`); - } - if (this.backendName === backendName && this.pendingBackendInit != null) { - // There is a pending promise of the backend we want to remove. Make it - // obsolete. - this.pendingBackendInitId++; - } - - if (backendName in this.registry) { - this.disposeRegisteredKernels(backendName); - this.registry[backendName].dispose(); - delete this.registry[backendName]; - } - - delete this.registryFactory[backendName]; - - // Unset the backend if it is active. - if (this.backendName === backendName) { - this.pendingBackendInit = null; - this.backendName = null; - this.backendInstance = null; - } - } - - private getSortedBackends(): string[] { - if (Object.keys(this.registryFactory).length === 0) { - throw new Error('No backend found in registry.'); - } - return Object.keys(this.registryFactory).sort((a: string, b: string) => { - // Highest priority comes first. - return this.registryFactory[b].priority - - this.registryFactory[a].priority; - }); - } - - private initializeBackendsAndReturnBest(): - {name: string, asyncInit: boolean} { - const sortedBackends = this.getSortedBackends(); - - for (let i = 0; i < sortedBackends.length; i++) { - const backendName = sortedBackends[i]; - const {success, asyncInit} = this.initializeBackend(backendName); - if (asyncInit || success) { - return {name: backendName, asyncInit}; - } - } - throw new Error( - `Could not initialize any backends, all backend initializations ` + - `failed.`); - } - - moveData(backend: KernelBackend, dataId: DataId) { - const info = this.state.tensorInfo.get(dataId); - const srcBackend = info.backend; - const values = this.readSync(dataId); - const refCount = srcBackend.refCount(dataId); - // Delete the tensor from the old backend and move it to the new - // backend. - srcBackend.disposeData(dataId, true); - info.backend = backend; - backend.move(dataId, values, info.shape, info.dtype, refCount); - if (this.shouldCheckForMemLeaks()) { - // Track the number of moves during a kernel execution to correctly - // detect memory leaks. - this.state.numDataMovesStack[this.state.numDataMovesStack.length - 1]++; - } - } - - tidy(nameOrFn: string|ScopeFn, fn?: ScopeFn): - T { - let name: string = null; - if (fn == null) { - // Called with only 1 argument. - if (typeof nameOrFn !== 'function') { - throw new Error('Please provide a function to tidy()'); - } - fn = nameOrFn; - } else { - // Called with 2 arguments. - if (typeof nameOrFn !== 'string' && !(nameOrFn instanceof String)) { - throw new Error( - 'When calling with two arguments, the first argument ' + - 'to tidy() must be a string'); - } - if (typeof fn !== 'function') { - throw new Error( - 'When calling with two arguments, the 2nd argument ' + - 'to tidy() must be a function'); - } - name = nameOrFn as string; - // TODO(nsthorat,smilkov): Do operation logging and performance - // profiling. - } - let result: T; - return this.scopedRun( - () => this.startScope(name), () => this.endScope(result), () => { - result = fn(); - if (result instanceof Promise) { - console.error('Cannot return a Promise inside of tidy.'); - } - return result; - }); - } - - private scopedRun(start: () => void, end: () => void, f: () => T): T { - start(); - try { - const res = f(); - end(); - return res; - } catch (ex) { - end(); - throw ex; - } - } - - private static nextTensorId = 0; - private nextTensorId(): number { - return Engine.nextTensorId++; - } - - private static nextVariableId = 0; - private nextVariableId(): number { - return Engine.nextVariableId++; - } - - /** - * This method is called instead of the public-facing tensor.clone() when - * saving a tensor for backwards pass. It makes sure to add the clone - * operation to the tape regardless of being called inside a kernel - * execution. - */ - private clone(x: Tensor): Tensor { - const y: Tensor = ENGINE.runKernel(Identity, - {x} as unknown as NamedTensorMap); - const inputs = {x}; - const grad = (dy: Tensor) => ({ - x: () => { - const dtype = 'float32'; - const gradInputs = {x: dy}; - const attrs = {dtype}; - - return ENGINE.runKernel( - Cast, gradInputs as unknown as NamedTensorMap, - // tslint:disable-next-line: no-unnecessary-type-assertion - attrs as unknown as NamedAttrMap) as Tensor; - } - }); - const saved: Tensor[] = []; - this.addTapeNode(this.state.activeScope.name, inputs, [y], grad, saved, {}); - return y; - } - - /** - * Execute a kernel with the given name and return the output tensor. - * - * @param kernelName The name of the kernel to execute. - * @param inputs A map of input names to tensors. - * @param attrs A map of attribute names to their values. An attribute is a - * primitive (non-tensor) input to the kernel. - * @param inputsToSave A list of tensors, inputs to save for the backprop - * computation. - * @param outputsToSave A list of booleans, specifying which output to save - * for the backprop computation. These are booleans since the output - * tensors are not visible to the user. - */ - runKernel( - kernelName: string, inputs: NamedTensorMap, attrs?: NamedAttrMap): T { - if (this.backendName == null) { - // backend has not been initialized yet (backend initialization is lazy - // can be deferred until an op/ kernel is run). - // The below getter has side effects that will try to initialize the - // backend and set properties like this.backendName - // tslint:disable-next-line: no-unused-expression - this.backend; - } - const hasKernel = getKernel(kernelName, this.backendName) != null; - if (!hasKernel) { - throw new Error(`Kernel '${kernelName}' not registered for backend '${ - this.backendName}'`); - } - return this.runKernelFunc({kernelName, inputs, attrs}); - } - - private shouldCheckForMemLeaks(): boolean { - return this.ENV.getBool('IS_TEST'); - } - - private checkKernelForMemLeak( - kernelName: string, numDataIdsBefore: number, - outInfos: TensorInfo[]): void { - const numDataIdsAfter = this.backend.numDataIds(); - - // Count the number of data ids associated with the result of the kernel. - let numOutputDataIds = 0; - outInfos.forEach(info => { - // Complex numbers allocate 3 data ids, one for 'real', one for - // 'imaginary', and one for the container that holds the former two. - numOutputDataIds += (info.dtype === 'complex64' ? 3 : 1); - }); - - // Account for the number of moves during kernel execution. A "data move" - // can happen in the middle of a kernel execution, placing a new (key,value) - // pair in the data storage. Since data moves have net zero effect (we - // always remove the data from the old backend), we have to cancel them out - // when detecting memory leaks. - const numMoves = - this.state.numDataMovesStack[this.state.numDataMovesStack.length - 1]; - const dataIdsLeaked = - numDataIdsAfter - numDataIdsBefore - numOutputDataIds - numMoves; - if (dataIdsLeaked > 0) { - throw new Error( - `Backend '${this.backendName}' has an internal memory leak ` + - `(${dataIdsLeaked} data ids) after running '${kernelName}'`); - } - } - - /** - * Internal helper method to execute a kernel Func - * - * Use `runKernel` to execute kernels from outside of engine. - */ - private runKernelFunc( - kernelParams: RegisteredKernelInvocation| - CustomGradKernelInvocation): T { - let outputs: Tensor[]; - let saved: Tensor[] = []; - const isTapeOn = this.isTapeOn(); - - const startingBytecount = this.state.numBytes; - const startingNumTensors = this.state.numTensors; - - if (this.shouldCheckForMemLeaks()) { - this.state.numDataMovesStack.push(0); - } - - let kernelFunc: () => Tensor[]; - if (this.backendName == null) { - // backend has not been initialized yet (backend initialization is lazy - // can be deferred until an op/ kernel is run). - // The below getter has side effects that will try to initialize the - // backend and set properties like this.backendName - // tslint:disable-next-line: no-unused-expression - this.backend; - } - - let out: TensorInfo|TensorInfo[]; - - const kernelOrScopeName = isRegisteredKernelInvocation(kernelParams) ? - kernelParams.kernelName : - this.state.activeScope != null ? this.state.activeScope.name : ''; - - // Create the kernelFunc from either a registered kernel OR passed in - // forward/backward functions (used by custom grad). In this context a - // kernelFunc wraps a kernel implementation with some bookkeeping. - - if (isRegisteredKernelInvocation(kernelParams)) { - const {kernelName, inputs, attrs} = kernelParams; - if (this.backendName == null) { - // backend has not been initialized yet (backend initialization is lazy - // can be deferred until an op/ kernel is run). - // The below getter has side effects that will try to initialize the - // backend and set properties like this.backendName - // tslint:disable-next-line: no-unused-expression - this.backend; - } - const kernel = getKernel(kernelName, this.backendName); - util.assert( - kernel != null, - () => `Cannot find registered kernel '${kernelName}' for backend '${ - this.backendName}'`); - - kernelFunc = () => { - const numDataIdsBefore = this.backend.numDataIds(); - out = kernel.kernelFunc({inputs, attrs, backend: this.backend}); - const outInfos = Array.isArray(out) ? out : [out]; - if (this.shouldCheckForMemLeaks()) { - this.checkKernelForMemLeak(kernelName, numDataIdsBefore, outInfos); - } - - const outTensors = outInfos.map((outInfo: TensorInfo|Tensor) => { - // todo (yassogba) remove this option (Tensor) when node backend - // methods have been modularized and they all return tensorInfo. - // TensorInfos do not have a rank attribute. - if ((outInfo as Tensor).rank != null) { - return outInfo as Tensor; - } - return this.makeTensorFromTensorInfo(outInfo); - }); - - // Save any required inputs and outputs. - - // Do not save unless we are recording to the tape. Otherwise it would - // cause a mem leak since there would be no backprop for these tensors - // (which would otherwise dispose them). - if (isTapeOn) { - const tensorsToSave = - this.getTensorsForGradient(kernelName, inputs, outTensors); - saved = this.saveTensorsForBackwardMode(tensorsToSave); - } - return outTensors; - }; - } else { - const {forwardFunc} = kernelParams; - // Running a customGrad op. - const saveFunc: GradSaveFunc = (tensors) => { - // Do not save unless we are recording to the tape. Otherwise it would - // cause a mem leak since we would never run backprop, which disposes - // the kept tensors. - if (!isTapeOn) { - return; - } - saved = tensors.map(tensor => this.keep(this.clone(tensor))); - }; - - kernelFunc = () => { - const numDataIdsBefore = this.backend.numDataIds(); - out = this.tidy(() => forwardFunc(this.backend, saveFunc)); - const outs = (Array.isArray(out) ? out : [out]) as Tensor[]; - if (this.shouldCheckForMemLeaks()) { - // Scope name is used to print a more helpful error message if needed. - this.checkKernelForMemLeak(kernelOrScopeName, numDataIdsBefore, outs); - } - return outs; - }; - } - - // - // Run the kernelFunc. Optionally profiling it. - // - const {inputs, attrs} = kernelParams; - const backwardsFunc = isRegisteredKernelInvocation(kernelParams) ? - null : - kernelParams.backwardsFunc; - - let kernelProfile: KernelProfile; - this.scopedRun( - // Stop recording to a tape when running a kernel. - () => this.state.kernelDepth++, () => this.state.kernelDepth--, () => { - if (!this.ENV.getBool('DEBUG') && !this.state.profiling) { - outputs = kernelFunc(); - } else { - kernelProfile = this.profiler.profileKernel( - kernelOrScopeName, inputs, () => kernelFunc()); - if (this.ENV.getBool('DEBUG')) { - this.profiler.logKernelProfile(kernelProfile); - } - outputs = kernelProfile.outputs; - } - }); - - if (isTapeOn) { - this.addTapeNode( - kernelOrScopeName, inputs, outputs, backwardsFunc, saved, attrs); - } - - if (this.state.profiling) { - this.state.activeProfile.kernels.push({ - name: kernelOrScopeName, - bytesAdded: this.state.numBytes - startingBytecount, - totalBytesSnapshot: this.state.numBytes, - tensorsAdded: this.state.numTensors - startingNumTensors, - totalTensorsSnapshot: this.state.numTensors, - inputShapes: Object.keys(inputs).map( - key => inputs[key] != null ? inputs[key].shape : null), - outputShapes: outputs.map(item => item.shape), - kernelTimeMs: kernelProfile.timeMs, - extraInfo: kernelProfile.extraInfo - }); - } - return (Array.isArray(out) ? outputs : outputs[0]) as T; - } - - /** - * Saves tensors used in forward mode for use in backward mode. - * - * @param tensors the list of tensors to save. - */ - private saveTensorsForBackwardMode(tensors: Tensor[]): Tensor[] { - const saved = tensors.map(tensor => this.keep(this.clone(tensor))); - return saved; - } - - /** - * Returns a list of tensors to save for a given gradient calculation. - * - * @param kernelName name of kernel to look up gradient for. - * @param inputs a map of input tensors. - * @param outputs an array of output tensors from forward mode of kernel. - */ - private getTensorsForGradient( - kernelName: string, inputs: NamedTensorMap, - outputs: Tensor[]): Tensor[]|null { - const gradConfig = getGradient(kernelName); - if (gradConfig != null) { - const inputsToSave: string[] = gradConfig.inputsToSave || []; - const outputsToSave: boolean[] = gradConfig.outputsToSave || []; - - // If saveAllInputs is true, all inputs will be saved. Otherwise, inputs - // specified in inputsToSave will be saved. - let inputTensorsToSave: Tensor[]; - if (gradConfig.saveAllInputs) { - util.assert( - Array.isArray(inputs), - () => 'saveAllInputs is true, expected inputs to be an array.'); - - inputTensorsToSave = Object.keys(inputs).map((key) => inputs[key]); - } else { - inputTensorsToSave = inputsToSave.map((inputName) => inputs[inputName]); - } - - const outputTensorsToSave: Tensor[] = - outputs.filter((_, i) => outputsToSave[i]); - - return inputTensorsToSave.concat(outputTensorsToSave); - } - // We return an empty list rather than throw an error because the kernel we - // are looking up may not actually be relevant to backproping through the - // overall function - // - // See 'does not error if irrelevant (pruned) ops are missing grads' test - // in gradients_test.ts for an example. - return []; - } - - /** - * Internal method used by public APIs for tensor creation. Makes a new - * tensor with the provided shape, dtype and values. It always - * creates a new data id and writes the values to the underlying backend. - */ - makeTensor( - values: DataValues, shape: number[], dtype: DataType, - backend?: KernelBackend): Tensor { - if (values == null) { - throw new Error('Values passed to engine.makeTensor() are null'); - } - dtype = dtype || 'float32'; - backend = backend || this.backend; - let backendVals = values as BackendValues; - if (dtype === 'string' && util.isString(values[0])) { - backendVals = (values as string[]).map(d => util.encodeString(d)); - } - const dataId = backend.write(backendVals, shape, dtype); - const t = new Tensor(shape, dtype, dataId, this.nextTensorId()); - this.trackTensor(t, backend); - - // Count bytes for string tensors. - if (dtype === 'string') { - const info = this.state.tensorInfo.get(dataId); - const newBytes = bytesFromStringArray(backendVals as Uint8Array[]); - this.state.numBytes += newBytes - info.bytes; - info.bytes = newBytes; - } - return t; - } - - /** - * Internal method used by backends. Makes a new tensor - * that is a wrapper around an existing data id. It doesn't create - * a new data id, only increments the ref count used in memory tracking. - * @deprecated - */ - makeTensorFromDataId( - dataId: DataId, shape: number[], dtype: DataType, - backend?: KernelBackend): Tensor { - dtype = dtype || 'float32'; - const tensorInfo: TensorInfo = {dataId, shape, dtype}; - return this.makeTensorFromTensorInfo(tensorInfo, backend); - } - - /** - * Internal method used by backends. Makes a new tensor that is a wrapper - * around an existing data id in TensorInfo. It doesn't create a new data id, - * only increments the ref count used in memory tracking. - */ - makeTensorFromTensorInfo(tensorInfo: TensorInfo, backend?: KernelBackend): - Tensor { - const {dataId, shape, dtype} = tensorInfo; - const t = new Tensor(shape, dtype, dataId, this.nextTensorId()); - this.trackTensor(t, backend); - return t; - } - - makeVariable( - initialValue: Tensor, trainable = true, name?: string, - dtype?: DataType): Variable { - name = name || this.nextVariableId().toString(); - if (dtype != null && dtype !== initialValue.dtype) { - initialValue = initialValue.cast(dtype); - } - const v = new Variable(initialValue, trainable, name, this.nextTensorId()); - if (this.state.registeredVariables[v.name] != null) { - throw new Error(`Variable with name ${v.name} was already registered`); - } - this.state.registeredVariables[v.name] = v; - this.incRef(v, this.backend); - return v; - } - - trackTensor(a: Tensor, backend: KernelBackend): void { - this.state.numTensors++; - if (a.dtype === 'string') { - this.state.numStringTensors++; - } - // Bytes for complex numbers are counted by their components. Bytes for - // string tensors are counted when writing values. - let bytes = 0; - if (a.dtype !== 'complex64' && a.dtype !== 'string') { - bytes = a.size * util.bytesPerElement(a.dtype); - } - this.state.numBytes += bytes; - - if (!this.state.tensorInfo.has(a.dataId)) { - this.state.numDataBuffers++; - this.state.tensorInfo.set(a.dataId, { - backend: backend || this.backend, - dtype: a.dtype, - shape: a.shape, - bytes - }); - } - - if (!(a instanceof Variable)) { - this.track(a); - } - } - - // Track the tensor by dataId and increase the refCount for the dataId in the - // backend. - // TODO(pyu10055): This is currently used by makeVariable method, to increase - // refCount on the backend for the dataId. It can potentially be replaced with - // Identity op indead of calling backend directly. - incRef(a: Tensor, backend: KernelBackend): void { - this.trackTensor(a, backend); - this.backend.incRef(a.dataId); - } - - removeDataId(dataId: DataId, backend: KernelBackend) { - if (this.state.tensorInfo.has(dataId) && - this.state.tensorInfo.get(dataId).backend === backend) { - this.state.tensorInfo.delete(dataId); - this.state.numDataBuffers--; - } - } - disposeTensor(a: Tensor): void { - if (!this.state.tensorInfo.has(a.dataId)) { - return; - } - const info = this.state.tensorInfo.get(a.dataId); - - this.state.numTensors--; - if (a.dtype === 'string') { - this.state.numStringTensors--; - this.state.numBytes -= info.bytes; - } - // Don't count bytes for complex numbers as they are counted by their - // components. - if (a.dtype !== 'complex64' && a.dtype !== 'string') { - const bytes = a.size * util.bytesPerElement(a.dtype); - this.state.numBytes -= bytes; - } - - // Remove the reference to dataId if backend dispose the data successfully - if (info.backend.disposeData(a.dataId)) { - this.removeDataId(a.dataId, info.backend); - } - - // TODO(nsthorat): Construct an error and save the stack trace for - // debugging when in debug mode. Creating a stack trace is too expensive - // to do unconditionally. - } - - disposeVariables(): void { - for (const varName in this.state.registeredVariables) { - const v = this.state.registeredVariables[varName]; - this.disposeVariable(v); - } - } - - disposeVariable(v: Variable): void { - this.disposeTensor(v); - if (this.state.registeredVariables[v.name] != null) { - delete this.state.registeredVariables[v.name]; - } - } - - memory(): MemoryInfo { - const info = this.backend.memory() as MemoryInfo; - info.numTensors = this.state.numTensors; - info.numDataBuffers = this.state.numDataBuffers; - info.numBytes = this.state.numBytes; - if (this.state.numStringTensors > 0) { - info.unreliable = true; - if (info.reasons == null) { - info.reasons = []; - } - info.reasons.push( - 'Memory usage by string tensors is approximate ' + - '(2 bytes per character)'); - } - return info; - } - - async profile(query: () => (TensorContainer | Promise)): - Promise { - this.state.profiling = true; - - const startBytes = this.state.numBytes; - const startNumTensors = this.state.numTensors; - - this.state.activeProfile.kernels = []; - this.state.activeProfile.result = await query(); - - this.state.profiling = false; - - this.state.activeProfile.peakBytes = Math.max( - ...this.state.activeProfile.kernels.map(d => d.totalBytesSnapshot)); - this.state.activeProfile.newBytes = this.state.numBytes - startBytes; - this.state.activeProfile.newTensors = - this.state.numTensors - startNumTensors; - for (const kernel of this.state.activeProfile.kernels) { - kernel.kernelTimeMs = await kernel.kernelTimeMs; - kernel.extraInfo = await kernel.extraInfo; - } - return this.state.activeProfile; - } - - isTapeOn(): boolean { - return this.state.gradientDepth > 0 && this.state.kernelDepth === 0; - } - - private addTapeNode( - kernelName: string, inputs: NamedTensorMap, outputs: Tensor[], - gradientsFunc: GradFunc, saved: Tensor[], attrs: NamedAttrMap): void { - const tapeNode: TapeNode = - {id: this.state.nextTapeNodeId++, kernelName, inputs, outputs, saved}; - - const gradConfig = getGradient(kernelName); - if (gradConfig != null) { - gradientsFunc = gradConfig.gradFunc; - } - if (gradientsFunc != null) { - tapeNode.gradient = (dys: Tensor[]) => { - // TODO(smilkov): To optimize back-prop, pass dys that are not used in - // the backprop graph to the user as null instead of zeros - dys = dys.map((dy, i) => { - if (dy == null) { - const output = outputs[i]; - const vals = util.makeZerosTypedArray(output.size, output.dtype); - return this.makeTensor(vals, output.shape, output.dtype); - } - return dy; - }); - // Grad functions of ops with single outputs expect a dy, while ops - // with multiple outputs expect dys (array of dy). - return gradientsFunc(dys.length > 1 ? dys : dys[0], saved, attrs); - }; - } - this.state.activeTape.push(tapeNode); - } - - keep(result: T): T { - result.kept = true; - return result; - } - - private startTape() { - if (this.state.gradientDepth === 0) { - this.state.activeTape = []; - } - this.state.gradientDepth++; - } - - private endTape() { - this.state.gradientDepth--; - } - - /** - * Start a scope. Use this with endScope() to achieve the same functionality - * as scope() without the need for a function closure. - */ - startScope(name?: string) { - const scopeInfo: ScopeState = { - track: [], - name: 'unnamed scope', - id: this.state.nextScopeId++ - }; - if (name) { - scopeInfo.name = name; - } - this.state.scopeStack.push(scopeInfo); - this.state.activeScope = scopeInfo; - } - - /** - * End a scope. Use this with startScope() to achieve the same functionality - * as scope() without the need for a function closure. - */ - endScope(result?: TensorContainer) { - const tensorsToTrackInParent = getTensorsInContainer(result); - const tensorsToTrackInParentSet = - new Set(tensorsToTrackInParent.map(t => t.id)); - - // Dispose the arrays tracked in this scope. - for (let i = 0; i < this.state.activeScope.track.length; i++) { - const tensor = this.state.activeScope.track[i]; - if (!tensor.kept && !tensorsToTrackInParentSet.has(tensor.id)) { - tensor.dispose(); - } - } - - const oldScope = this.state.scopeStack.pop(); - this.state.activeScope = this.state.scopeStack.length === 0 ? - null : - this.state.scopeStack[this.state.scopeStack.length - 1]; - - // Track the current result in the parent scope. - tensorsToTrackInParent.forEach(tensor => { - // Only track the tensor if was allocated in the inner scope and is not - // globally kept. - if (!tensor.kept && tensor.scopeId === oldScope.id) { - this.track(tensor); - } - }); - } - - /** - * Returns gradients of `f` with respect to each of the `xs`. The gradients - * returned are of the same length as `xs`, but some might be null if `f` - * was not a function of that `x`. It also takes optional dy to multiply the - * gradient, which defaults to `1`. - */ - gradients( - f: () => T, xs: Tensor[], dy?: T, - allowNoGradients = false): {value: T, grads: Tensor[]} { - util.assert( - xs.length > 0, () => 'gradients() received an empty list of xs.'); - if (dy != null && dy.dtype !== 'float32') { - throw new Error(`dy must have 'float32' dtype, but has '${dy.dtype}'`); - } - - const y = this.scopedRun( - () => this.startTape(), () => this.endTape(), - () => this.tidy('forward', f)); - - util.assert( - y instanceof Tensor, - () => 'The result y returned by f() must be a tensor.'); - // Filter out the nodes that don't connect x => y. - const filteredTape = getFilteredNodesXToY(this.state.activeTape, xs, y); - if (!allowNoGradients && filteredTape.length === 0 && xs.length > 0) { - throw new Error( - 'Cannot compute gradient of y=f(x) with respect to x. Make sure ' + - 'that the f you passed encloses all operations that lead from x ' + - 'to y.'); - } - - return this.tidy('backward', () => { - const accumulatedGradientMap: {[tensorId: number]: Tensor} = {}; - accumulatedGradientMap[y.id] = (dy == null) ? ones(y.shape) : dy; - - // Backprop gradients through the filtered nodes. - backpropagateGradients( - accumulatedGradientMap, filteredTape, - // Pass the tidy function to avoid circular dep with `tape.ts`. - f => this.tidy(f as ScopeFn), - // Pass an add function to avoide a circular dep with `tape.ts`. - add); - const grads = xs.map(x => accumulatedGradientMap[x.id]); - - if (this.state.gradientDepth === 0) { - // This means that we are not computing higher-order gradients - // and can clean up the tape. - this.state.activeTape.forEach(node => { - for (const tensor of node.saved) { - tensor.dispose(); - } - }); - this.state.activeTape = null; - } - return {value: y, grads}; - }); - } - - customGrad(f: CustomGradientFunc): - (...args: Array) => T { - util.assert( - util.isFunction(f), - () => 'The f passed in customGrad(f) must be a function.'); - return (...inputs: Tensor[]): T => { - util.assert( - inputs.every(t => t instanceof Tensor), - () => 'The args passed in customGrad(f)(x1, x2,...) must all be ' + - 'tensors'); - - let res: { - value: T, - gradFunc: (dy: T, saved: Tensor[]) => Tensor | Tensor[], - }; - const inputMap: NamedTensorMap = {}; - inputs.forEach((input, i) => { - inputMap[i] = input; - }); - - const forwardFunc: ForwardFunc = (_, save) => { - res = f(...[...inputs, save]); - util.assert( - res.value instanceof Tensor, - () => 'The function f passed in customGrad(f) must return an ' + - 'object where `obj.value` is a tensor'); - util.assert( - util.isFunction(res.gradFunc), - () => 'The function f passed in customGrad(f) must return an ' + - 'object where `obj.gradFunc` is a function.'); - return res.value; - }; - - const backwardsFunc = (dy: T, saved: Tensor[]) => { - const gradRes = res.gradFunc(dy, saved); - const grads: Tensor[] = Array.isArray(gradRes) ? gradRes : [gradRes]; - util.assert( - grads.length === inputs.length, - () => 'The function f passed in customGrad(f) must return an ' + - 'object where `obj.gradFunc` is a function that returns ' + - 'the same number of tensors as inputs passed to f(...).'); - util.assert( - grads.every(t => t instanceof Tensor), - () => 'The function f passed in customGrad(f) must return an ' + - 'object where `obj.gradFunc` is a function that returns ' + - 'a list of only tensors.'); - const gradMap: {[key: string]: () => Tensor} = {}; - grads.forEach((grad, i) => { - gradMap[i] = () => grad; - }); - return gradMap; - }; - - return this.runKernelFunc({ - forwardFunc, - backwardsFunc, - inputs: inputMap, - }); - }; - } - - readSync(dataId: DataId): BackendValues { - // Route the read to the correct backend. - const info = this.state.tensorInfo.get(dataId); - return info.backend.readSync(dataId); - } - read(dataId: DataId): Promise { - // Route the read to the correct backend. - const info = this.state.tensorInfo.get(dataId); - return info.backend.read(dataId); - } - - readToGPU(dataId: DataId, options?: DataToGPUOptions): GPUData { - // Route the read to the correct backend. - const info = this.state.tensorInfo.get(dataId); - return info.backend.readToGPU(dataId, options); - } - - async time(query: () => void): Promise { - const start = now(); - const timingInfo = await this.backend.time(query) as TimingInfo; - timingInfo.wallMs = now() - start; - return timingInfo; - } - - /** - * Tracks a Tensor in the current scope to be automatically cleaned up - * when the current scope ends, and returns the value. - * - * @param result The Tensor to track in the current scope. - */ - private track(result: T): T { - if (this.state.activeScope != null) { - result.scopeId = this.state.activeScope.id; - this.state.activeScope.track.push(result); - } - - return result; - } - - get registeredVariables(): NamedVariableMap { - return this.state.registeredVariables; - } - - /** - * Resets the engine state. Removes all backends but does not remove - * registered backend factories. - */ - reset(): void { - // Make any pending promise obsolete. - this.pendingBackendInitId++; - - this.state.dispose(); - this.ENV.reset(); - this.state = new EngineState(); - - for (const backendName in this.registry) { - this.disposeRegisteredKernels(backendName); - this.registry[backendName].dispose(); - delete this.registry[backendName]; - } - this.backendName = null; - this.backendInstance = null; - this.pendingBackendInit = null; - } -} - -function ones(shape: number[]): Tensor { - const values = makeOnesTypedArray(sizeFromShape(shape), 'float32'); - return ENGINE.makeTensor(values, shape, 'float32'); -} - -export function getOrMakeEngine(): Engine { - const ns = getGlobalNamespace() as unknown as {_tfengine: Engine}; - if (ns._tfengine == null) { - const environment = new Environment(ns); - ns._tfengine = new Engine(environment); - } - setEnvironmentGlobal(ns._tfengine.ENV); - - // Tell the current tensor interface that the global engine is responsible - // for tracking. - setTensorTracker(() => ns._tfengine); - return ns._tfengine; -} - -export const ENGINE = getOrMakeEngine(); - -/** - * A implementation of the add op for use within engine and tape. - * - * This allows us to avoid a circular dependency between add.ts and engine. - * It is exported to be available in tape tests. - */ -export function add(a: Tensor, b: Tensor): Tensor { - // We duplicate Add here to avoid a circular dependency with add.ts. - const inputs = {a, b}; - return ENGINE.runKernel(Add, inputs as unknown as NamedTensorMap); -} diff --git a/tfjs-master/tfjs-core/src/engine_test.ts b/tfjs-master/tfjs-core/src/engine_test.ts deleted file mode 100644 index 97b7e7871..000000000 --- a/tfjs-master/tfjs-core/src/engine_test.ts +++ /dev/null @@ -1,800 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelBackend} from './backends/backend'; -import {ENGINE} from './engine'; -import * as tf from './index'; -import {KernelFunc} from './index'; -import {ALL_ENVS, describeWithFlags, TestKernelBackend} from './jasmine_util'; -import { TensorInfo } from './tensor_info'; -import {Tensor} from './tensor'; -import {expectArraysClose} from './test_util'; -import {BackendValues, DataType} from './types'; - -describe('Backend registration', () => { - beforeAll(() => { - // Silences backend registration warnings. - spyOn(console, 'warn'); - }); - - let registeredBackends: string[] = []; - let registerBackend: typeof tf.registerBackend; - - beforeEach(() => { - // Registering a backend changes global state (engine), so we wrap - // registration to automatically remove registered backend at the end - // of each test. - registerBackend = (name, factory, priority) => { - registeredBackends.push(name); - return tf.registerBackend(name, factory, priority); - }; - - ENGINE.reset(); - }); - - afterEach(() => { - // Remove all registered backends at the end of each test. - registeredBackends.forEach(name => { - if (tf.findBackendFactory(name) != null) { - tf.removeBackend(name); - } - }); - registeredBackends = []; - }); - - it('removeBackend disposes the backend and removes the factory', () => { - let backend: KernelBackend; - const factory = () => { - const newBackend = new TestKernelBackend(); - if (backend == null) { - backend = newBackend; - spyOn(backend, 'dispose').and.callThrough(); - } - return newBackend; - }; - - registerBackend('test-backend', factory); - - expect(tf.findBackend('test-backend') != null).toBe(true); - expect(tf.findBackend('test-backend')).toBe(backend); - expect(tf.findBackendFactory('test-backend')).toBe(factory); - - tf.removeBackend('test-backend'); - - expect(tf.findBackend('test-backend') == null).toBe(true); - expect(tf.findBackend('test-backend')).toBe(null); - expect((backend.dispose as jasmine.Spy).calls.count()).toBe(1); - expect(tf.findBackendFactory('test-backend')).toBe(null); - }); - - it('findBackend initializes the backend', () => { - let backend: KernelBackend; - const factory = () => { - const newBackend = new TestKernelBackend(); - if (backend == null) { - backend = newBackend; - } - return newBackend; - }; - registerBackend('custom-cpu', factory); - - expect(tf.findBackend('custom-cpu') != null).toBe(true); - expect(tf.findBackend('custom-cpu')).toBe(backend); - expect(tf.findBackendFactory('custom-cpu')).toBe(factory); - }); - - it('custom backend registration', () => { - let backend: KernelBackend; - const priority = 103; - registerBackend('custom-cpu', () => { - const newBackend = new TestKernelBackend(); - if (backend == null) { - backend = newBackend; - } - return newBackend; - }, priority); - - expect(tf.backend() != null).toBe(true); - expect(tf.backend()).toBe(backend); - }); - - it('high priority backend registration fails, falls back', () => { - let lowPriorityBackend: KernelBackend; - const lowPriority = 103; - const highPriority = 104; - registerBackend('custom-low-priority', () => { - lowPriorityBackend = new TestKernelBackend(); - return lowPriorityBackend; - }, lowPriority); - registerBackend('custom-high-priority', () => { - throw new Error(`High priority backend fails`); - }, highPriority); - - expect(tf.backend() != null).toBe(true); - expect(tf.backend()).toBe(lowPriorityBackend); - expect(tf.getBackend()).toBe('custom-low-priority'); - }); - - it('low priority and high priority backends, setBackend low priority', () => { - let lowPriorityBackend: KernelBackend; - let highPriorityBackend: KernelBackend; - const lowPriority = 103; - const highPriority = 104; - registerBackend('custom-low-priority', () => { - lowPriorityBackend = new TestKernelBackend(); - return lowPriorityBackend; - }, lowPriority); - registerBackend('custom-high-priority', () => { - highPriorityBackend = new TestKernelBackend(); - return highPriorityBackend; - }, highPriority); - - expect(tf.backend() != null).toBe(true); - expect(tf.backend()).toBe(highPriorityBackend); - expect(tf.getBackend()).toBe('custom-high-priority'); - - tf.setBackend('custom-low-priority'); - - expect(tf.backend() != null).toBe(true); - expect(tf.backend()).toBe(lowPriorityBackend); - expect(tf.getBackend()).toBe('custom-low-priority'); - }); - - it('default custom background null', () => { - expect(tf.findBackend('custom')).toBeNull(); - }); - - it('allow custom backend', () => { - const backend = new TestKernelBackend(); - const success = registerBackend('custom', () => backend); - expect(success).toBeTruthy(); - expect(tf.findBackend('custom')).toEqual(backend); - }); - - it('sync backend with await ready works', async () => { - const testBackend = new TestKernelBackend(); - registerBackend('sync', () => testBackend); - tf.setBackend('sync'); - - expect(tf.getBackend()).toEqual('sync'); - await tf.ready(); - expect(tf.backend()).toEqual(testBackend); - }); - - it('sync backend without await ready works', async () => { - const testBackend = new TestKernelBackend(); - registerBackend('sync', () => testBackend); - tf.setBackend('sync'); - - expect(tf.getBackend()).toEqual('sync'); - expect(tf.backend()).toEqual(testBackend); - }); - - it('async backend with await ready works', async () => { - const testBackend = new TestKernelBackend(); - registerBackend('async', async () => { - await tf.nextFrame(); - return testBackend; - }); - tf.setBackend('async'); - - expect(tf.getBackend()).toEqual('async'); - await tf.ready(); - expect(tf.backend()).toEqual(testBackend); - }); - - it('async backend without await ready does not work', async () => { - const testBackend = new TestKernelBackend(); - registerBackend('async', async () => { - await tf.nextFrame(); - return testBackend; - }); - tf.setBackend('async'); - - expect(tf.getBackend()).toEqual('async'); - expect(() => tf.backend()) - .toThrowError(/Backend 'async' has not yet been initialized./); - }); - - it('tf.square() fails if user does not await ready on async backend', - async () => { - registerBackend('async', async () => { - await tf.nextFrame(); - return new TestKernelBackend(); - }); - tf.setBackend('async'); - expect(() => tf.square(2)) - .toThrowError(/Backend 'async' has not yet been initialized/); - }); - - it('tf.square() works when user awaits ready on async backend', async () => { - registerBackend('async', async () => { - await tf.nextFrame(); - return new TestKernelBackend(); - }); - tf.setBackend('async'); - await tf.ready(); - expect(() => tf.square(2)).toThrowError(/'write' not yet implemented/); - }); - - it('Registering async2 (higher priority) fails, async1 becomes active', - async () => { - const testBackend = new TestKernelBackend(); - registerBackend('async1', async () => { - await tf.nextFrame(); - return testBackend; - }, 100 /* priority */); - registerBackend('async2', async () => { - await tf.nextFrame(); - throw new Error('failed to create async2'); - }, 101 /* priority */); - - // Await for the library to find the best backend that succesfully - // initializes. - await tf.ready(); - expect(tf.backend()).toEqual(testBackend); - expect(tf.getBackend()).toBe('async1'); - }); - - it('Registering sync as higher priority and async as lower priority', - async () => { - const testBackend = new TestKernelBackend(); - registerBackend('sync', () => testBackend, 101 /* priority */); - registerBackend('async', async () => { - await tf.nextFrame(); - return new TestKernelBackend(); - }, 100 /* priority */); - - // No need to await for ready() since the highest priority one is sync. - expect(tf.backend()).toEqual(testBackend); - expect(tf.getBackend()).toBe('sync'); - }); - - it('async as higher priority and sync as lower priority with await ready', - async () => { - const testBackend = new TestKernelBackend(); - registerBackend('async', async () => { - await tf.nextFrame(); - return testBackend; - }, 101 /* priority */); - registerBackend( - 'sync', () => new TestKernelBackend(), 100 /* priority */); - - await tf.ready(); - expect(tf.backend()).toEqual(testBackend); - expect(tf.getBackend()).toBe('async'); - }); - - it('async as higher priority and sync as lower priority w/o await ready', - async () => { - const testBackend = new TestKernelBackend(); - registerBackend('async', async () => { - await tf.nextFrame(); - return testBackend; - }, 101 /* priority */); - registerBackend( - 'sync', () => new TestKernelBackend(), 100 /* priority */); - - expect(() => tf.backend()) - .toThrowError( - /The highest priority backend 'async' has not yet been/); - }); - - it('Registering and setting a backend that fails to register', async () => { - registerBackend('async', async () => { - await tf.nextFrame(); - throw new Error('failed to create async'); - }); - const success = tf.setBackend('async'); - expect(tf.getBackend()).toBe('async'); - expect(() => tf.backend()) - .toThrowError(/Backend 'async' has not yet been initialized/); - expect(await success).toBe(false); - }); -}); - -describeWithFlags('memory', ALL_ENVS, () => { - it('Sum(float)', async () => { - expect(tf.memory().numTensors).toBe(0); - expect(tf.memory().numBytes).toBe(0); - const sum = tf.tidy(() => { - const a = tf.tensor1d([1, 2, 3, 4]); - expect(tf.memory().numTensors).toBe(1); - expect(tf.memory().numBytes).toBe(4 * 4); - return a.sum(); - }); - expect(tf.memory().numTensors).toBe(1); - expect(tf.memory().numBytes).toBe(4); - expectArraysClose(await sum.data(), [1 + 2 + 3 + 4]); - }); - - it('Sum(bool)', async () => { - const sum = tf.tidy(() => { - const a = tf.tensor1d([true, true, false, true], 'bool'); - expect(tf.memory().numTensors).toBe(1); - expect(tf.memory().numBytes).toBe(4); - return a.sum(); - }); - expect(tf.memory().numTensors).toBe(1); - expect(tf.memory().numBytes).toBe(4); - expect(sum.dtype).toBe('int32'); - expectArraysClose(await sum.data(), [1 + 1 + 0 + 1]); - }); - - it('Sum(int32)', async () => { - const sum = tf.tidy(() => { - const a = tf.tensor1d([1, 1, 0, 1], 'int32'); - expect(tf.memory().numTensors).toBe(1); - expect(tf.memory().numBytes).toBe(4 * 4); - return a.sum(); - }); - expect(tf.memory().numTensors).toBe(1); - expect(tf.memory().numBytes).toBe(4); - expect(sum.dtype).toBe('int32'); - expectArraysClose(await sum.data(), [1 + 1 + 0 + 1]); - }); - - it('string tensor', () => { - const a = tf.tensor([['a', 'bb'], ['c', 'd']]); - - expect(tf.memory().numTensors).toBe(1); - expect(tf.memory().numBytes).toBe(5); // 5 letters, each 1 byte in utf8. - - a.dispose(); - - expect(tf.memory().numTensors).toBe(0); - expect(tf.memory().numBytes).toBe(0); - }); - - it('unreliable is true for string tensors', () => { - tf.tensor('a'); - const mem = tf.memory(); - expect(mem.unreliable).toBe(true); - const expectedReason = 'Memory usage by string tensors is approximate ' + - '(2 bytes per character)'; - expect(mem.reasons.indexOf(expectedReason) >= 0).toBe(true); - }); - - it('makeTensorFromDataId creates a tensor', () => { - const tensor = ENGINE.makeTensorFromDataId({}, [3], 'float32'); - expect(tensor).toBeDefined(); - expect(tensor.shape).toEqual([3]); - }); -}); - -describeWithFlags('profile', ALL_ENVS, () => { - it('squaring', async () => { - const profile = await tf.profile(() => { - const x = tf.tensor1d([1, 2, 3]); - let x2 = x.square(); - x2.dispose(); - x2 = x.square(); - x2.dispose(); - return x; - }); - - const result = profile.result as Tensor; - - expect(profile.newBytes).toBe(12); - expect(profile.peakBytes).toBe(24); - expect(profile.newTensors).toBe(1); - expectArraysClose(await result.data(), [1, 2, 3]); - expect(profile.kernels.length).toBe(2); - - // Test the types for `kernelTimeMs` and `extraInfo` to confirm the promises - // are resolved. - expect(profile.kernels[0].kernelTimeMs instanceof Promise).toBe(false); - expect(profile.kernels[0].extraInfo instanceof Promise).toBe(false); - expect(profile.kernels[1].kernelTimeMs instanceof Promise).toBe(false); - expect(profile.kernels[1].extraInfo instanceof Promise).toBe(false); - - // The specific values of `kernelTimeMs` and `extraInfo` are tested in the - // tests of Profiler.profileKernel, so their values are not tested here. - expect(profile.kernels[0]).toEqual({ - 'name': 'Square', - 'bytesAdded': 12, - 'totalBytesSnapshot': 24, - 'tensorsAdded': 1, - 'totalTensorsSnapshot': 2, - 'inputShapes': [[3]], - 'outputShapes': [[3]], - 'kernelTimeMs': profile.kernels[0].kernelTimeMs, - 'extraInfo': profile.kernels[0].extraInfo - }); - - expect(profile.kernels[1]).toEqual({ - 'name': 'Square', - 'bytesAdded': 12, - 'totalBytesSnapshot': 24, - 'tensorsAdded': 1, - 'totalTensorsSnapshot': 2, - 'inputShapes': [[3]], - 'outputShapes': [[3]], - 'kernelTimeMs': profile.kernels[1].kernelTimeMs, - 'extraInfo': profile.kernels[1].extraInfo - }); - }); - - it('squaring without disposing', async () => { - const profile = await tf.profile(() => { - const x = tf.tensor1d([1, 2, 3]); - const x2 = x.square(); - return x2; - }); - - const result = profile.result as Tensor; - - expect(profile.newBytes).toBe(24); - expect(profile.peakBytes).toBe(24); - expect(profile.newTensors).toBe(2); - expectArraysClose(await result.data(), [1, 4, 9]); - expect(profile.kernels.length).toBe(1); - expect(profile.kernels[0].kernelTimeMs instanceof Promise).toBe(false); - expect(profile.kernels[0].extraInfo instanceof Promise).toBe(false); - expect(profile.kernels[0]).toEqual({ - 'name': 'Square', - 'bytesAdded': 12, - 'totalBytesSnapshot': 24, - 'tensorsAdded': 1, - 'totalTensorsSnapshot': 2, - 'inputShapes': [[3]], - 'outputShapes': [[3]], - 'kernelTimeMs': profile.kernels[0].kernelTimeMs, - 'extraInfo': profile.kernels[0].extraInfo - }); - }); - - it('squaring in async query', async () => { - const profile = await tf.profile(async () => { - await new Promise(resolve => setTimeout(resolve, 1)); - const x = tf.tensor1d([1, 2, 3]); - const x2 = x.square(); - x2.dispose(); - return x; - }); - - const result = profile.result as Tensor; - - expect(profile.newBytes).toBe(12); - expect(profile.peakBytes).toBe(24); - expect(profile.newTensors).toBe(1); - expectArraysClose(await result.data(), [1, 2, 3]); - expect(profile.kernels.length).toBe(1); - expect(profile.kernels[0].kernelTimeMs instanceof Promise).toBe(false); - expect(profile.kernels[0].extraInfo instanceof Promise).toBe(false); - expect(profile.kernels[0]).toEqual({ - 'name': 'Square', - 'bytesAdded': 12, - 'totalBytesSnapshot': 24, - 'tensorsAdded': 1, - 'totalTensorsSnapshot': 2, - 'inputShapes': [[3]], - 'outputShapes': [[3]], - 'kernelTimeMs': profile.kernels[0].kernelTimeMs, - 'extraInfo': profile.kernels[0].extraInfo - }); - }); - - it('reports correct kernelNames', async () => { - const profile = await tf.profile(() => { - const x = tf.tensor1d([1, 2, 3]); - const x2 = x.square(); - const x3 = x2.abs(); - return x3; - }); - - expect(profile.kernelNames).toEqual(jasmine.arrayWithExactContents([ - 'Square', 'Abs' - ])); - }); -}); - -describeWithFlags('disposeVariables', ALL_ENVS, () => { - it('reuse same name variable', () => { - tf.tensor1d([1, 2, 3]).variable(true, 'v1'); - tf.tensor1d([1, 2, 3]).variable(true, 'v2'); - expect(() => { - tf.tensor1d([1, 2, 3]).variable(true, 'v1'); - }).toThrowError(); - tf.disposeVariables(); - tf.tensor1d([1, 2, 3]).variable(true, 'v1'); - tf.tensor1d([1, 2, 3]).variable(true, 'v2'); - }); -}); - -/** - * The following test constraints to the CPU environment because it needs a - * concrete backend to exist. This test will work for any backend, but currently - * this is the simplest backend to test against. - */ -describeWithFlags( - 'Switching cpu backends', - {predicate: testEnv => testEnv.backendName === 'cpu'}, () => { - beforeEach(() => { - tf.registerBackend('cpu1', tf.findBackendFactory('cpu')); - tf.registerBackend('cpu2', tf.findBackendFactory('cpu')); - }); - - afterEach(() => { - tf.removeBackend('cpu1'); - tf.removeBackend('cpu2'); - }); - - it('Move data from cpu1 to cpu2 backend', async () => { - tf.setBackend('cpu1'); - // This scalar lives in cpu1. - const a = tf.scalar(5); - - tf.setBackend('cpu2'); - // This scalar lives in cpu2. - const b = tf.scalar(3); - - expect(tf.memory().numDataBuffers).toBe(2); - expect(tf.memory().numTensors).toBe(2); - expect(tf.memory().numBytes).toBe(8); - - // Make sure you can read both tensors. - expectArraysClose(await a.data(), [5]); - expectArraysClose(await b.data(), [3]); - - // Switch back to cpu1. - tf.setBackend('cpu1'); - // Again make sure you can read both tensors. - expectArraysClose(await a.data(), [5]); - expectArraysClose(await b.data(), [3]); - - tf.dispose([a, b]); - - expect(tf.memory().numDataBuffers).toBe(0); - expect(tf.memory().numTensors).toBe(0); - expect(tf.memory().numBytes).toBe(0); - }); - - it('can execute op with data from mixed backends', async () => { - const kernelFunc = tf.getKernel('Add', 'cpu').kernelFunc; - tf.registerKernel({kernelName: 'Add', backendName: 'cpu1', kernelFunc}); - tf.registerKernel({kernelName: 'Add', backendName: 'cpu2', kernelFunc}); - - tf.setBackend('cpu1'); - // This scalar lives in cpu1. - const a = tf.scalar(5); - - tf.setBackend('cpu2'); - // This scalar lives in cpu2. - const b = tf.scalar(3); - - // Verify that ops can execute with mixed backend data. - ENGINE.startScope(); - tf.setBackend('cpu1'); - expectArraysClose(await tf.add(a, b).data(), [8]); - - tf.setBackend('cpu2'); - expectArraysClose(await tf.add(a, b).data(), [8]); - ENGINE.endScope(); - - tf.dispose([a, b]); - }); - }); - -/** - * The following unit test is a special integration-style test that assumes - * things about CPU & WebGL backends being registered. This tests doesn't live - * in the backend directory because it is testing engine rather than - * backend-specific details but needs a real backend to exist. This test will - * fail if the CPU backends is not registered. This is intentional, we should - * have coverage for when these backends are enabled and ensure they work with - * the engine. - */ -// TODO(#5632): Re-enable these tests -/* -describeWithFlags( - 'Switching WebGL + CPU backends', { - predicate: testEnv => testEnv.backendName === 'webgl' && - ENGINE.backendNames().indexOf('webgl') !== -1 && - ENGINE.backendNames().indexOf('cpu') !== -1 - }, - () => { - beforeEach(() => { - tf.registerBackend('webgl1', tf.findBackendFactory('webgl')); - tf.registerBackend('webgl2', tf.findBackendFactory('webgl')); - tf.registerBackend('cpu1', tf.findBackendFactory('cpu')); - }); - - afterEach(() => { - tf.removeBackend('webgl1'); - tf.removeBackend('webgl2'); - tf.removeBackend('cpu1'); - }); - - it('can execute op with data from mixed backends', async () => { - tf.setBackend('webgl1'); - const a = tf.scalar(5); - - tf.setBackend('webgl2'); - const b = tf.scalar(3); - - tf.setBackend('cpu1'); - const c = tf.scalar(2); - - // Verify that ops can execute with mixed backend data. - ENGINE.startScope(); - tf.setBackend('webgl1'); - expectArraysClose(await tf.addN([a, b, c]).data(), [10]); - - tf.setBackend('webgl2'); - expectArraysClose(await tf.addN([a, b, c]).data(), [10]); - - tf.setBackend('cpu1'); - expectArraysClose(await tf.addN([a, b, c]).data(), [10]); - ENGINE.endScope(); - - expect(tf.memory().numTensors).toBe(3); - expect(tf.memory().numDataBuffers).toBe(3); - - tf.dispose([a, b, c]); - - expect(tf.memory().numTensors).toBe(0); - expect(tf.memory().numDataBuffers).toBe(0); - }); - - it('fromPixels with mixed backends works', async () => { - tf.setBackend('webgl1'); - const a = tf.browser.fromPixels( - new ImageData(new Uint8ClampedArray([1, 2, 3, 4]), 1, 1)); - - tf.setBackend('webgl2'); - const b = tf.browser.fromPixels( - new ImageData(new Uint8ClampedArray([5, 6, 7, 8]), 1, 1)); - - expectArraysClose(await tf.add(a, b).data(), [6, 8, 10]); - }); - - it('single tidy multiple backends', () => { - const kernelFunc = tf.getKernel('Square', 'webgl').kernelFunc; - tf.registerKernel( - {kernelName: 'Square', backendName: 'webgl1', kernelFunc}); - tf.registerKernel( - {kernelName: 'Square', backendName: 'webgl2', kernelFunc}); - - expect(tf.memory().numTensors).toBe(0); - - tf.tidy(() => { - tf.setBackend('webgl1'); - const a = tf.scalar(1); - a.square(); // Uploads to GPU. - - tf.setBackend('webgl2'); - const b = tf.scalar(1); - b.square(); // Uploads to GPU. - - expect(tf.memory().numTensors).toBe(4); - }); - expect(tf.memory().numTensors).toBe(0); - - tf.unregisterKernel('Square', 'webgl1'); - tf.unregisterKernel('Square', 'webgl2'); - }); - }); -*/ -interface TestStorage extends KernelBackend { - id: number; -} - -describeWithFlags('Detects memory leaks in kernels', ALL_ENVS, () => { - const backendName = 'test-mem'; - const kernelName = 'MyKernel'; - const kernelNameComplex = 'Kernel-complex'; - - it('Detects memory leak in a kernel', () => { - let dataIdsCount = 0; - tf.registerBackend(backendName, () => { - return { - id: 1, - dispose: () => null, - disposeData: (dataId: {}) => null, - numDataIds: () => dataIdsCount - } as TestStorage; - }); - - const kernelWithMemLeak: KernelFunc = () => { - dataIdsCount += 2; - return {dataId: {}, shape: [], dtype: 'float32'}; - }; - tf.registerKernel({kernelName, backendName, kernelFunc: kernelWithMemLeak}); - - tf.setBackend(backendName); - expect(() => tf.engine().runKernel(kernelName, {}, {})) - .toThrowError( - /Backend 'test-mem' has an internal memory leak \(1 data ids\)/); - - tf.removeBackend(backendName); - tf.unregisterKernel(kernelName, backendName); - }); - - it('No mem leak in a kernel with multiple outputs', () => { - let dataIdsCount = 0; - tf.registerBackend(backendName, () => { - return { - id: 1, - dispose: () => null, - disposeData: (dataId: {}) => null, - numDataIds: () => dataIdsCount - } as TestStorage; - }); - tf.setBackend(backendName); - - const kernelWith3Outputs: KernelFunc = () => { - dataIdsCount += 3; - const t: TensorInfo = {dataId: {}, shape: [], dtype: 'float32'}; - return [t, t, t]; - }; - tf.registerKernel( - {kernelName, backendName, kernelFunc: kernelWith3Outputs}); - - const res = tf.engine().runKernel(kernelName, {}, {}); - expect(Array.isArray(res)).toBe(true); - expect((res as Array<{}>).length).toBe(3); - - const kernelWithComplexOutputs: KernelFunc = () => { - dataIdsCount += 3; - return {dataId: {}, shape: [], dtype: 'complex64'}; - }; - tf.registerKernel({ - kernelName: kernelNameComplex, - backendName, - kernelFunc: kernelWithComplexOutputs - }); - - const res2 = tf.engine().runKernel(kernelNameComplex, {}, {}) as TensorInfo; - expect(res2.shape).toEqual([]); - expect(res2.dtype).toEqual('complex64'); - - tf.removeBackend(backendName); - tf.unregisterKernel(kernelName, backendName); - tf.unregisterKernel(kernelNameComplex, backendName); - }); -}); - -// NOTE: This describe is purposefully not a describeWithFlags so that we -// test tensor allocation where no scopes have been created. -describe('Memory allocation outside a test scope', () => { - it('constructing a tensor works', async () => { - const backendName = 'test-backend'; - tf.registerBackend(backendName, () => { - let storedValues: BackendValues = null; - return { - id: 1, - floatPrecision: () => 32, - write: (values: BackendValues, shape: number[], dtype: DataType) => { - const dataId = {}; - storedValues = values; - return dataId; - }, - read: async (dataId: object) => storedValues, - dispose: () => null, - disposeData: (dataId: {}) => null - } as TestStorage; - }); - tf.setBackend(backendName); - - const a = tf.tensor1d([1, 2, 3]); - expectArraysClose(await a.data(), [1, 2, 3]); - a.dispose(); - - tf.removeBackend(backendName); - }); -}); diff --git a/tfjs-master/tfjs-core/src/environment.ts b/tfjs-master/tfjs-core/src/environment.ts deleted file mode 100644 index a3026ee33..000000000 --- a/tfjs-master/tfjs-core/src/environment.ts +++ /dev/null @@ -1,219 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Platform} from './platforms/platform'; -import {isPromise} from './util_base'; - -// Expects flags from URL in the format ?tfjsflags=FLAG1:1,FLAG2:true. -const TENSORFLOWJS_FLAGS_PREFIX = 'tfjsflags'; - -type FlagValue = number|boolean|string; -type FlagEvaluationFn = (() => FlagValue)|(() => Promise); -export type Flags = { - [featureName: string]: FlagValue -}; -export type FlagRegistryEntry = { - evaluationFn: FlagEvaluationFn; - setHook?: (value: FlagValue) => void; -}; - -/** - * The environment contains evaluated flags as well as the registered platform. - * This is always used as a global singleton and can be retrieved with - * `tf.env()`. - * - * @doc {heading: 'Environment'} - */ -export class Environment { - private flags: Flags = {}; - private flagRegistry: {[flagName: string]: FlagRegistryEntry} = {}; - - private urlFlags: Flags = {}; - - platformName: string; - platform: Platform; - - // Jasmine spies on this in 'environment_test.ts' - getQueryParams = getQueryParams; - - // tslint:disable-next-line: no-any - constructor(public global: any) { - this.populateURLFlags(); - } - - setPlatform(platformName: string, platform: Platform) { - if (this.platform != null) { - if (!(env().getBool('IS_TEST') || env().getBool('PROD'))) { - console.warn( - `Platform ${this.platformName} has already been set. ` + - `Overwriting the platform with ${platformName}.`); - } - } - this.platformName = platformName; - this.platform = platform; - } - - registerFlag( - flagName: string, evaluationFn: FlagEvaluationFn, - setHook?: (value: FlagValue) => void) { - this.flagRegistry[flagName] = {evaluationFn, setHook}; - - // Override the flag value from the URL. This has to happen here because - // the environment is initialized before flags get registered. - if (this.urlFlags[flagName] != null) { - const flagValue = this.urlFlags[flagName]; - if (!(env().getBool('IS_TEST') || env().getBool('PROD'))) { - console.warn( - `Setting feature override from URL ${flagName}: ${flagValue}.`); - } - this.set(flagName, flagValue); - } - } - - async getAsync(flagName: string): Promise { - if (flagName in this.flags) { - return this.flags[flagName]; - } - - this.flags[flagName] = await this.evaluateFlag(flagName); - return this.flags[flagName]; - } - - get(flagName: string): FlagValue { - if (flagName in this.flags) { - return this.flags[flagName]; - } - - const flagValue = this.evaluateFlag(flagName); - if (isPromise(flagValue)) { - throw new Error( - `Flag ${flagName} cannot be synchronously evaluated. ` + - `Please use getAsync() instead.`); - } - - this.flags[flagName] = flagValue; - return this.flags[flagName]; - } - - getNumber(flagName: string): number { - return this.get(flagName) as number; - } - - getBool(flagName: string): boolean { - return this.get(flagName) as boolean; - } - - getString(flagName: string): string { - return this.get(flagName) as string; - } - - getFlags(): Flags { - return this.flags; - } - // For backwards compatibility. - get features(): Flags { - return this.flags; - } - - set(flagName: string, value: FlagValue): void { - if (this.flagRegistry[flagName] == null) { - throw new Error( - `Cannot set flag ${flagName} as it has not been registered.`); - } - this.flags[flagName] = value; - if (this.flagRegistry[flagName].setHook != null) { - this.flagRegistry[flagName].setHook(value); - } - } - - private evaluateFlag(flagName: string): FlagValue|Promise { - if (this.flagRegistry[flagName] == null) { - throw new Error( - `Cannot evaluate flag '${flagName}': no evaluation function found.`); - } - return this.flagRegistry[flagName].evaluationFn(); - } - - setFlags(flags: Flags) { - this.flags = Object.assign({}, flags); - } - - reset() { - this.flags = {}; - this.urlFlags = {}; - this.populateURLFlags(); - } - - private populateURLFlags(): void { - if (typeof this.global === 'undefined' || - typeof this.global.location === 'undefined' || - typeof this.global.location.search === 'undefined') { - return; - } - - const urlParams = this.getQueryParams(this.global.location.search); - if (TENSORFLOWJS_FLAGS_PREFIX in urlParams) { - const keyValues = urlParams[TENSORFLOWJS_FLAGS_PREFIX].split(','); - keyValues.forEach(keyValue => { - const [key, value] = keyValue.split(':') as [string, string]; - this.urlFlags[key] = parseValue(key, value); - }); - } - } -} - -export function getQueryParams(queryString: string): {[key: string]: string} { - const params = {}; - queryString.replace(/[?&]([^=?&]+)(?:=([^&]*))?/g, (s, ...t) => { - decodeParam(params, t[0], t[1]); - return t.join('='); - }); - return params; -} - -function decodeParam( - params: {[key: string]: string}, name: string, value?: string) { - params[decodeURIComponent(name)] = decodeURIComponent(value || ''); -} - -function parseValue(flagName: string, value: string): FlagValue { - const lowerCaseValue = value.toLowerCase(); - if (lowerCaseValue === 'true' || lowerCaseValue === 'false') { - return lowerCaseValue === 'true'; - } else if (`${+ lowerCaseValue}` === lowerCaseValue) { - return +lowerCaseValue; - } else { - return value; - } -} - -/** - * Returns the current environment (a global singleton). - * - * The environment object contains the evaluated feature values as well as the - * active platform. - * - * @doc {heading: 'Environment'} - */ -export function env() { - return ENV; -} - -export let ENV: Environment = null; -export function setEnvironmentGlobal(environment: Environment) { - ENV = environment; -} diff --git a/tfjs-master/tfjs-core/src/environment_test.ts b/tfjs-master/tfjs-core/src/environment_test.ts deleted file mode 100644 index 433e2043a..000000000 --- a/tfjs-master/tfjs-core/src/environment_test.ts +++ /dev/null @@ -1,181 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as environment from './environment'; -import {Environment} from './environment'; - -describe('initializes flags from the url', () => { - // Silence console.warns for these tests. - beforeAll(() => spyOn(console, 'warn').and.returnValue(null)); - - it('no overrides one registered flag', () => { - const global = {location: {search: ''}}; - const env = new Environment(global); - spyOn(env, 'getQueryParams').and.returnValue({}); - - env.registerFlag('FLAG1', () => false); - expect(env.get('FLAG1')).toBe(false); - }); - - it('one unregistered flag', () => { - const global = {location: {search: ''}}; - const env = new Environment(global); - spyOn(env, 'getQueryParams').and.returnValue({'tfjsflags': 'FLAG1:true'}); - expect(env.features).toEqual({}); - }); - - it('one registered flag true', () => { - const global = {location: {search: '?tfjsflags=FLAG1:true'}}; - const env = new Environment(global); - env.registerFlag('FLAG1', () => false); - - expect(env.get('FLAG1')).toBe(true); - }); - - it('one registered flag false', () => { - const global = {location: {search: '?tfjsflags=FLAG1:false'}}; - const env = new Environment(global); - env.registerFlag('FLAG1', () => true); - - expect(env.get('FLAG1')).toBe(false); - }); - - it('two registered flags', () => { - const global = {location: {search: '?tfjsflags=FLAG1:true,FLAG2:200'}}; - const env = new Environment(global); - env.registerFlag('FLAG1', () => false); - env.registerFlag('FLAG2', () => 100); - - expect(env.get('FLAG1')).toBe(true); - expect(env.get('FLAG2')).toBe(200); - }); - - it('one registered flag string', () => { - const global = {location: {search: '?tfjsflags=FLAG1:FlagString'}}; - const env = new Environment(global); - env.registerFlag('FLAG1', () => 'FlagString'); - - expect(env.get('FLAG1')).toBe('FlagString'); - expect(env.get('FLAG1')).not.toBe('flagstring'); - }); - - it('one registered flag empty string', () => { - const global = {location: {search: '?tfjsflags=FLAG1:'}}; - const env = new Environment(global); - env.registerFlag('FLAG1', () => 'FlagString'); - - expect(env.get('FLAG1')).toBe(''); - }); -}); - -describe('flag registration and evaluation', () => { - it('one flag registered', () => { - const env = new Environment({}); - - const evalObject = {eval: () => true}; - const spy = spyOn(evalObject, 'eval').and.callThrough(); - - env.registerFlag('FLAG1', () => evalObject.eval()); - - expect(env.get('FLAG1')).toBe(true); - expect(spy.calls.count()).toBe(1); - - // Multiple calls to get do not call the evaluation function again. - expect(env.get('FLAG1')).toBe(true); - expect(spy.calls.count()).toBe(1); - }); - - it('one string flag registered', () => { - const env = new Environment({}); - - env.registerFlag('FLAG1', () => ''); - - // Set to a non empty string, this is case sensitive. - env.set('FLAG1', 'FlagString'); - expect(env.get('FLAG1')).toBe('FlagString'); - expect(env.get('FLAG1')).not.toBe('flagString'); - }); - - it('multiple flags registered', () => { - const env = new Environment({}); - - const evalObject = {eval1: () => true, eval2: () => 100}; - const spy1 = spyOn(evalObject, 'eval1').and.callThrough(); - const spy2 = spyOn(evalObject, 'eval2').and.callThrough(); - - env.registerFlag('FLAG1', () => evalObject.eval1()); - env.registerFlag('FLAG2', () => evalObject.eval2()); - - expect(env.get('FLAG1')).toBe(true); - expect(spy1.calls.count()).toBe(1); - expect(spy2.calls.count()).toBe(0); - expect(env.get('FLAG2')).toBe(100); - expect(spy1.calls.count()).toBe(1); - expect(spy2.calls.count()).toBe(1); - - // Multiple calls to get do not call the evaluation function again. - expect(env.get('FLAG1')).toBe(true); - expect(env.get('FLAG2')).toBe(100); - expect(spy1.calls.count()).toBe(1); - expect(spy2.calls.count()).toBe(1); - }); - - it('setting overrides value', () => { - const env = new Environment({}); - - const evalObject = {eval: () => true}; - const spy = spyOn(evalObject, 'eval').and.callThrough(); - - env.registerFlag('FLAG1', () => evalObject.eval()); - - expect(env.get('FLAG1')).toBe(true); - expect(spy.calls.count()).toBe(1); - - env.set('FLAG1', false); - - expect(env.get('FLAG1')).toBe(false); - expect(spy.calls.count()).toBe(1); - }); - - it('set hook is called', () => { - const env = new Environment({}); - - const evalObject = {eval: () => true, setHook: () => true}; - const evalSpy = spyOn(evalObject, 'eval').and.callThrough(); - const setHookSpy = spyOn(evalObject, 'setHook').and.callThrough(); - - env.registerFlag( - 'FLAG1', () => evalObject.eval(), () => evalObject.setHook()); - - expect(env.get('FLAG1')).toBe(true); - expect(evalSpy.calls.count()).toBe(1); - expect(setHookSpy.calls.count()).toBe(0); - - env.set('FLAG1', false); - - expect(env.get('FLAG1')).toBe(false); - expect(evalSpy.calls.count()).toBe(1); - expect(setHookSpy.calls.count()).toBe(1); - }); -}); - -describe('environment.getQueryParams', () => { - it('basic', () => { - expect(environment.getQueryParams('?a=1&b=hi&f=animal')) - .toEqual({'a': '1', 'b': 'hi', 'f': 'animal'}); - }); -}); diff --git a/tfjs-master/tfjs-core/src/flags.ts b/tfjs-master/tfjs-core/src/flags.ts deleted file mode 100644 index e6086f6ab..000000000 --- a/tfjs-master/tfjs-core/src/flags.ts +++ /dev/null @@ -1,90 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import './engine'; - -import * as device_util from './device_util'; -import {env} from './environment'; - -const ENV = env(); - -/** - * This file contains environment-related flag registrations. - */ - -/** Whether to enable debug mode. */ -ENV.registerFlag('DEBUG', () => false, debugValue => { - if (debugValue) { - console.warn( - 'Debugging mode is ON. The output of every math call will ' + - 'be downloaded to CPU and checked for NaNs. ' + - 'This significantly impacts performance.'); - } -}); - -/** Whether we are in a browser (as versus, say, node.js) environment. */ -ENV.registerFlag('IS_BROWSER', () => device_util.isBrowser()); - -/** Whether we are in a browser (as versus, say, node.js) environment. */ -ENV.registerFlag( - 'IS_NODE', - () => (typeof process !== 'undefined') && - (typeof process.versions !== 'undefined') && - (typeof process.versions.node !== 'undefined')); - -/** Whether this browser is Chrome. */ -ENV.registerFlag( - 'IS_CHROME', - () => typeof navigator !== 'undefined' && navigator != null && - navigator.userAgent != null && /Chrome/.test(navigator.userAgent) && - /Google Inc/.test(navigator.vendor)); - -/** Whether this browser is Safari. */ -ENV.registerFlag( - 'IS_SAFARI', - () => typeof navigator !== 'undefined' && navigator != null && - navigator.userAgent != null && /Safari/.test(navigator.userAgent) && - /Apple/.test(navigator.vendor)); -/** - * True when the environment is "production" where we disable safety checks - * to gain performance. - */ -ENV.registerFlag('PROD', () => false); - -/** - * Whether to do sanity checks when inferring a shape from user-provided - * values, used when creating a new tensor. - */ -ENV.registerFlag( - 'TENSORLIKE_CHECK_SHAPE_CONSISTENCY', () => ENV.getBool('DEBUG')); - -/** Whether deprecation warnings are enabled. */ -ENV.registerFlag('DEPRECATION_WARNINGS_ENABLED', () => true); - -/** True if running unit tests. */ -ENV.registerFlag('IS_TEST', () => false); - -/** Whether to check computation result for errors. */ -ENV.registerFlag('CHECK_COMPUTATION_FOR_ERRORS', () => ENV.getBool('DEBUG')); - -/** Whether the backend needs to wrap input to imageBitmap. */ -ENV.registerFlag('WRAP_TO_IMAGEBITMAP', () => false); - -/** Whether to enable canvas2d willReadFrequently for GPU backends */ -ENV.registerFlag('CANVAS2D_WILL_READ_FREQUENTLY_FOR_GPU', () => false); - -/** Whether to use setTimeoutCustom */ -ENV.registerFlag('USE_SETTIMEOUTCUSTOM', () => false); diff --git a/tfjs-master/tfjs-core/src/flags_test.ts b/tfjs-master/tfjs-core/src/flags_test.ts deleted file mode 100644 index 4677804f6..000000000 --- a/tfjs-master/tfjs-core/src/flags_test.ts +++ /dev/null @@ -1,125 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as device_util from './device_util'; -import * as tf from './index'; - -describe('DEBUG', () => { - beforeEach(() => { - tf.env().reset(); - spyOn(console, 'warn').and.callFake((msg: string) => {}); - }); - afterAll(() => tf.env().reset()); - - it('disabled by default', () => { - expect(tf.env().getBool('DEBUG')).toBe(false); - }); - - it('warns when enabled', () => { - const consoleWarnSpy = console.warn as jasmine.Spy; - tf.env().set('DEBUG', true); - expect(consoleWarnSpy.calls.count()).toBe(1); - expect((consoleWarnSpy.calls.first().args[0] as string) - .startsWith('Debugging mode is ON. ')) - .toBe(true); - - expect(tf.env().getBool('DEBUG')).toBe(true); - expect(consoleWarnSpy.calls.count()).toBe(1); - }); -}); - -// TODO (yassogba) figure out why this spy is not working / fix this test. -describe('IS_BROWSER', () => { - let isBrowser: boolean; - beforeEach(() => { - tf.env().reset(); - spyOn(device_util, 'isBrowser').and.callFake(() => isBrowser); - }); - afterAll(() => tf.env().reset()); - - // tslint:disable-next-line: ban - xit('isBrowser: true', () => { - isBrowser = true; - expect(tf.env().getBool('IS_BROWSER')).toBe(true); - }); - - // tslint:disable-next-line: ban - xit('isBrowser: false', () => { - isBrowser = false; - expect(tf.env().getBool('IS_BROWSER')).toBe(false); - }); -}); - -describe('PROD', () => { - beforeEach(() => tf.env().reset()); - afterAll(() => tf.env().reset()); - - it('disabled by default', () => { - expect(tf.env().getBool('PROD')).toBe(false); - }); -}); - -describe('TENSORLIKE_CHECK_SHAPE_CONSISTENCY', () => { - beforeEach(() => tf.env().reset()); - afterAll(() => tf.env().reset()); - - it('disabled when debug is disabled', () => { - tf.env().set('DEBUG', false); - expect(tf.env().getBool('TENSORLIKE_CHECK_SHAPE_CONSISTENCY')).toBe(false); - }); - - it('enabled when debug is enabled', () => { - // Silence debug warnings. - spyOn(console, 'warn'); - tf.enableDebugMode(); - expect(tf.env().getBool('TENSORLIKE_CHECK_SHAPE_CONSISTENCY')).toBe(true); - }); -}); - -describe('DEPRECATION_WARNINGS_ENABLED', () => { - beforeEach(() => tf.env().reset()); - afterAll(() => tf.env().reset()); - - it('enabled by default', () => { - expect(tf.env().getBool('DEPRECATION_WARNINGS_ENABLED')).toBe(true); - }); -}); - -describe('IS_TEST', () => { - beforeEach(() => tf.env().reset()); - afterAll(() => tf.env().reset()); - - it('disabled by default', () => { - expect(tf.env().getBool('IS_TEST')).toBe(false); - }); -}); - -describe('async flags test', () => { - const asyncFlagName = 'ASYNC_FLAG'; - beforeEach(() => tf.env().registerFlag(asyncFlagName, async () => true)); - - afterEach(() => tf.env().reset()); - - it('evaluating async flag works', async () => { - const flagVal = await tf.env().getAsync(asyncFlagName); - expect(flagVal).toBe(true); - }); - - it('evaluating async flag synchronously fails', async () => { - expect(() => tf.env().get(asyncFlagName)).toThrow(); - }); -}); diff --git a/tfjs-master/tfjs-core/src/global_util.ts b/tfjs-master/tfjs-core/src/global_util.ts deleted file mode 100644 index dc869bd8f..000000000 --- a/tfjs-master/tfjs-core/src/global_util.ts +++ /dev/null @@ -1,69 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// Note that the identifier globalNameSpace is scoped to this module, but will -// always resolve to the same global object regardless of how the module is -// resolved. -// tslint:disable-next-line:no-any -let globalNameSpace: {_tfGlobals: Map}; -// tslint:disable-next-line:no-any -export function getGlobalNamespace(): {_tfGlobals: Map} { - if (globalNameSpace == null) { - // tslint:disable-next-line:no-any - let ns: any; - if (typeof (window) !== 'undefined') { - ns = window; - } else if (typeof (global) !== 'undefined') { - ns = global; - } else if (typeof (process) !== 'undefined') { - ns = process; - } else if (typeof (self) !== 'undefined') { - ns = self; - } else { - throw new Error('Could not find a global object'); - } - globalNameSpace = ns; - } - return globalNameSpace; -} - -// tslint:disable-next-line:no-any -function getGlobalMap(): Map { - const ns = getGlobalNamespace(); - if (ns._tfGlobals == null) { - ns._tfGlobals = new Map(); - } - return ns._tfGlobals; -} - -/** - * Returns a globally accessible 'singleton' object. - * - * @param key the name of the object - * @param init a function to initialize to initialize this object - * the first time it is fetched. - */ -export function getGlobal(key: string, init: () => T): T { - const globalMap = getGlobalMap(); - if (globalMap.has(key)) { - return globalMap.get(key); - } else { - const singleton = init(); - globalMap.set(key, singleton); - return globalMap.get(key); - } -} diff --git a/tfjs-master/tfjs-core/src/globals.ts b/tfjs-master/tfjs-core/src/globals.ts deleted file mode 100644 index 9bc658f5f..000000000 --- a/tfjs-master/tfjs-core/src/globals.ts +++ /dev/null @@ -1,384 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {KernelBackend} from './backends/backend'; -import {ENGINE, Engine, MemoryInfo, ProfileInfo, ScopeFn, TimingInfo} from './engine'; -import {env} from './environment'; - -import {Platform} from './platforms/platform'; -import {setDeprecationWarningFn, Tensor} from './tensor'; -import {TensorContainer} from './tensor_types'; -import {getTensorsInContainer} from './tensor_util'; - -/** - * Enables production mode which disables correctness checks in favor of - * performance. - * - * @doc {heading: 'Environment'} - */ -export function enableProdMode(): void { - env().set('PROD', true); -} - -/** - * Enables debug mode which will log information about all executed kernels: - * the elapsed time of the kernel execution, as well as the rank, shape, and - * size of the output tensor. - * - * Debug mode will significantly slow down your application as it will - * download the result of every operation to the CPU. This should not be used in - * production. Debug mode does not affect the timing information of the kernel - * execution as we do not measure download time in the kernel execution time. - * - * See also: `tf.profile`, `tf.memory`. - * - * @doc {heading: 'Environment'} - */ -export function enableDebugMode(): void { - env().set('DEBUG', true); -} - -/** Globally disables deprecation warnings */ -export function disableDeprecationWarnings(): void { - env().set('DEPRECATION_WARNINGS_ENABLED', false); - console.warn(`TensorFlow.js deprecation warnings have been disabled.`); -} - -/** Warn users about deprecated functionality. */ -export function deprecationWarn(msg: string) { - if (env().getBool('DEPRECATION_WARNINGS_ENABLED')) { - console.warn( - msg + ' You can disable deprecation warnings with ' + - 'tf.disableDeprecationWarnings().'); - } -} -setDeprecationWarningFn(deprecationWarn); - -/** - * Dispose all variables kept in backend engine. - * - * @doc {heading: 'Environment'} - */ -export function disposeVariables(): void { - ENGINE.disposeVariables(); -} - -/** - * It returns the global engine that keeps track of all tensors and backends. - * - * @doc {heading: 'Environment'} - */ -export function engine(): Engine { - return ENGINE; -} - -/** - * Returns memory info at the current time in the program. The result is an - * object with the following properties: - * - * - `numBytes`: Number of bytes allocated (undisposed) at this time. - * - `numTensors`: Number of unique tensors allocated. - * - `numDataBuffers`: Number of unique data buffers allocated - * (undisposed) at this time, which is ≤ the number of tensors - * (e.g. `a.reshape(newShape)` makes a new Tensor that shares the same - * data buffer with `a`). - * - `unreliable`: True if the memory usage is unreliable. See `reasons` when - * `unreliable` is true. - * - `reasons`: `string[]`, reasons why the memory is unreliable, present if - * `unreliable` is true. - * - * WebGL Properties: - * - `numBytesInGPU`: Number of bytes allocated (undisposed) in the GPU only at - * this time. - * - * @doc {heading: 'Performance', subheading: 'Memory'} - */ -export function memory(): MemoryInfo { - return ENGINE.memory(); -} - -/** - * Executes the provided function `f()` and returns a promise that resolves - * with information about the function's memory use: - * - `newBytes`: the number of new bytes allocated - * - `newTensors`: the number of new tensors created - * - `peakBytes`: the peak number of bytes allocated - * - `kernels`: an array of objects for each kernel involved that reports - * their input and output shapes, number of bytes used, and number of new - * tensors created. - * - `kernelNames`: an array of unique strings with just the names of the - * kernels in the `kernels` array. - * - * ```js - * const profile = await tf.profile(() => { - * const x = tf.tensor1d([1, 2, 3]); - * let x2 = x.square(); - * x2.dispose(); - * x2 = x.square(); - * x2.dispose(); - * return x; - * }); - * - * console.log(`newBytes: ${profile.newBytes}`); - * console.log(`newTensors: ${profile.newTensors}`); - * console.log(`byte usage over all kernels: ${profile.kernels.map(k => - * k.totalBytesSnapshot)}`); - * ``` - * - * - * @doc {heading: 'Performance', subheading: 'Profile'} - */ -export function profile(f: () => (TensorContainer | Promise)): - Promise { - return ENGINE.profile(f); -} - -/** - * Executes the provided function `fn` and after it is executed, cleans up all - * intermediate tensors allocated by `fn` except those returned by `fn`. - * `fn` must not return a Promise (async functions not allowed). The returned - * result can be a complex object. - * - * Using this method helps avoid memory leaks. In general, wrap calls to - * operations in `tf.tidy` for automatic memory cleanup. - * - * NOTE: Variables do *not* get cleaned up when inside a tidy(). If you want to - * dispose variables, please use `tf.disposeVariables` or call dispose() - * directly on variables. - * - * ```js - * // y = 2 ^ 2 + 1 - * const y = tf.tidy(() => { - * // a, b, and one will be cleaned up when the tidy ends. - * const one = tf.scalar(1); - * const a = tf.scalar(2); - * const b = a.square(); - * - * console.log('numTensors (in tidy): ' + tf.memory().numTensors); - * - * // The value returned inside the tidy function will return - * // through the tidy, in this case to the variable y. - * return b.add(one); - * }); - * - * console.log('numTensors (outside tidy): ' + tf.memory().numTensors); - * y.print(); - * ``` - * - * @param nameOrFn The name of the closure, or the function to execute. - * If a name is provided, the 2nd argument should be the function. - * If debug mode is on, the timing and the memory usage of the function - * will be tracked and displayed on the console using the provided name. - * @param fn The function to execute. - * - * @doc {heading: 'Performance', subheading: 'Memory'} - */ -export function tidy( - nameOrFn: string|ScopeFn, fn?: ScopeFn): T { - return ENGINE.tidy(nameOrFn, fn); -} - -/** - * Disposes any `tf.Tensor`s found within the provided object. - * - * @param container an object that may be a `tf.Tensor` or may directly - * contain `tf.Tensor`s, such as a `Tensor[]` or `{key: Tensor, ...}`. If - * the object is not a `tf.Tensor` or does not contain `Tensors`, nothing - * happens. In general it is safe to pass any object here, except that - * `Promise`s are not supported. - * - * @doc {heading: 'Performance', subheading: 'Memory'} - */ -export function dispose(container: TensorContainer) { - const tensors = getTensorsInContainer(container); - tensors.forEach(tensor => tensor.dispose()); -} - -/** - * Keeps a `tf.Tensor` generated inside a `tf.tidy` from being disposed - * automatically. - * - * ```js - * let b; - * const y = tf.tidy(() => { - * const one = tf.scalar(1); - * const a = tf.scalar(2); - * - * // b will not be cleaned up by the tidy. a and one will be cleaned up - * // when the tidy ends. - * b = tf.keep(a.square()); - * - * console.log('numTensors (in tidy): ' + tf.memory().numTensors); - * - * // The value returned inside the tidy function will return - * // through the tidy, in this case to the variable y. - * return b.add(one); - * }); - * - * console.log('numTensors (outside tidy): ' + tf.memory().numTensors); - * console.log('y:'); - * y.print(); - * console.log('b:'); - * b.print(); - * ``` - * - * @param result The tensor to keep from being disposed. - * - * @doc {heading: 'Performance', subheading: 'Memory'} - */ -export function keep(result: T): T { - return ENGINE.keep(result); -} - -/** - * Executes `f()` and returns a promise that resolves with timing - * information. - * - * The result is an object with the following properties: - * - * - `wallMs`: Wall execution time. - * - `kernelMs`: Kernel execution time, ignoring data transfer. If using the - * WebGL backend and the query timer extension is not available, this will - * return an error object. - * - On `WebGL` The following additional properties exist: - * - `uploadWaitMs`: CPU blocking time on texture uploads. - * - `downloadWaitMs`: CPU blocking time on texture downloads (readPixels). - * - * ```js - * const x = tf.randomNormal([20, 20]); - * const time = await tf.time(() => x.matMul(x)); - * - * console.log(`kernelMs: ${time.kernelMs}, wallTimeMs: ${time.wallMs}`); - * ``` - * - * @param f The function to execute and time. - * - * @doc {heading: 'Performance', subheading: 'Timing'} - */ -export function time(f: () => void): Promise { - return ENGINE.time(f); -} - -/** - * Sets the backend (cpu, webgl, wasm, etc) responsible for creating tensors and - * executing operations on those tensors. Returns a promise that resolves - * to a boolean if the backend initialization was successful. - * - * Note this disposes the current backend, if any, as well as any tensors - * associated with it. A new backend is initialized, even if it is of the - * same type as the previous one. - * - * @param backendName The name of the backend. Currently supports - * `'webgl'|'cpu'` in the browser, `'tensorflow'` under node.js - * (requires tfjs-node), and `'wasm'` (requires tfjs-backend-wasm). - * - * @doc {heading: 'Backends'} - */ -export function setBackend(backendName: string): Promise { - return ENGINE.setBackend(backendName); -} - -/** - * Returns a promise that resolves when the currently selected backend (or the - * highest priority one) has initialized. Await this promise when you are using - * a backend that has async initialization. - * - * @doc {heading: 'Backends'} - */ -export function ready(): Promise { - return ENGINE.ready(); -} - -/** - * Returns the current backend name (cpu, webgl, etc). The backend is - * responsible for creating tensors and executing operations on those tensors. - * - * @doc {heading: 'Backends'} - */ -export function getBackend(): string { - return ENGINE.backendName; -} - -/** - * Removes a backend and the registered factory. - * - * @doc {heading: 'Backends'} - */ -export function removeBackend(name: string): void { - ENGINE.removeBackend(name); -} - -/** - * Finds the backend registered under the provided name. Returns null if the - * name is not in the registry, or the registration hasn't finished yet. - */ -export function findBackend(name: string): KernelBackend { - return ENGINE.findBackend(name); -} - -/** - * Finds the backend factory registered under the provided name. Returns a - * function that produces a new backend when called. Returns null if the name - * is not in the registry. - */ -export function findBackendFactory(name: string): () => - KernelBackend | Promise { - return ENGINE.findBackendFactory(name); -} - -/** - * Registers a global backend. The registration should happen when importing - * a module file (e.g. when importing `backend_webgl.ts`), and is used for - * modular builds (e.g. custom tfjs bundle with only webgl support). - * - * @param factory The backend factory function. When called, it should - * return a backend instance, or a promise of an instance. - * @param priority The priority of the backend (higher = more important). - * In case multiple backends are registered, the priority is used to find - * the best backend. Defaults to 1. - * @return False if there is already a registered backend under this name, true - * if not. - * - * @doc {heading: 'Backends'} - */ -export function registerBackend( - name: string, factory: () => KernelBackend | Promise, - priority = 1): boolean { - return ENGINE.registerBackend(name, factory, priority); -} - -/** - * Gets the current backend. If no backends have been initialized, this will - * attempt to initialize the best backend. Will throw an error if the highest - * priority backend has async initialization, in which case you should call - * 'await tf.ready()' before running other code. - * - * @doc {heading: 'Backends'} - */ -export function backend(): KernelBackend { - return ENGINE.backend; -} - -/** - * Sets the global platform. - * - * @param platformName The name of this platform. - * @param platform A platform implementation. - */ -export function setPlatform(platformName: string, platform: Platform) { - env().setPlatform(platformName, platform); -} diff --git a/tfjs-master/tfjs-core/src/globals_test.ts b/tfjs-master/tfjs-core/src/globals_test.ts deleted file mode 100644 index 88a2ab40d..000000000 --- a/tfjs-master/tfjs-core/src/globals_test.ts +++ /dev/null @@ -1,297 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from './index'; -import {ALL_ENVS, describeWithFlags, NODE_ENVS} from './jasmine_util'; -import {expectArraysClose} from './test_util'; - -describe('deprecation warnings', () => { - beforeEach(() => { - spyOn(console, 'warn').and.callFake((msg: string): void => null); - }); - - it('deprecationWarn warns', () => { - // flags_test.ts verifies deprecation warnings are on by default. - const deprecationVal = tf.env().get('DEPRECATION_WARNINGS_ENABLED'); - tf.env().set('DEPRECATION_WARNINGS_ENABLED', true); - tf.deprecationWarn('xyz is deprecated.'); - tf.env().set('DEPRECATION_WARNINGS_ENABLED', deprecationVal); - expect(console.warn).toHaveBeenCalledTimes(1); - expect(console.warn) - .toHaveBeenCalledWith( - 'xyz is deprecated. You can disable deprecation warnings with ' + - 'tf.disableDeprecationWarnings().'); - }); - - it('disableDeprecationWarnings called, deprecationWarn doesnt warn', () => { - tf.disableDeprecationWarnings(); - expect(console.warn).toHaveBeenCalledTimes(1); - expect(console.warn) - .toHaveBeenCalledWith( - 'TensorFlow.js deprecation warnings have been disabled.'); - - // deprecationWarn no longer warns. - tf.deprecationWarn('xyz is deprecated.'); - expect(console.warn).toHaveBeenCalledTimes(1); - }); -}); - -describe('Flag flipping methods', () => { - beforeEach(() => { - tf.env().reset(); - }); - - afterEach(() => { - tf.env().reset(); - }); - - it('tf.enableProdMode', () => { - tf.enableProdMode(); - expect(tf.env().getBool('PROD')).toBe(true); - }); - - it('tf.enableDebugMode', () => { - // Silence debug warnings. - spyOn(console, 'warn'); - tf.enableDebugMode(); - expect(tf.env().getBool('DEBUG')).toBe(true); - }); -}); - -describeWithFlags('time cpu', NODE_ENVS, () => { - it('simple upload', async () => { - const a = tf.zeros([10, 10]); - const time = await tf.time(() => a.square()); - expect(time.kernelMs).toBeGreaterThan(0); - expect(time.kernelMs).toBeLessThanOrEqual(time.wallMs); - }); -}); - -describeWithFlags('tidy', ALL_ENVS, () => { - it('returns Tensor', async () => { - tf.tidy(() => { - const a = tf.tensor1d([1, 2, 3]); - let b = tf.tensor1d([0, 0, 0]); - - expect(tf.memory().numTensors).toBe(2); - tf.tidy(() => { - const result = tf.tidy(() => { - b = tf.add(a, b); - b = tf.add(a, b); - b = tf.add(a, b); - return tf.add(a, b); - }); - - // result is new. All intermediates should be disposed. - expect(tf.memory().numTensors).toBe(2 + 1); - expect(result.shape).toEqual([3]); - expect(result.isDisposed).toBe(false); - }); - - // a, b are still here, result should be disposed. - expect(tf.memory().numTensors).toBe(2); - }); - - expect(tf.memory().numTensors).toBe(0); - }); - - it('multiple disposes does not affect num arrays', () => { - expect(tf.memory().numTensors).toBe(0); - const a = tf.tensor1d([1, 2, 3]); - const b = tf.tensor1d([1, 2, 3]); - expect(tf.memory().numTensors).toBe(2); - a.dispose(); - a.dispose(); - expect(tf.memory().numTensors).toBe(1); - b.dispose(); - expect(tf.memory().numTensors).toBe(0); - }); - - it('allows primitive types', () => { - const a = tf.tidy(() => 5); - expect(a).toBe(5); - - const b = tf.tidy(() => 'hello'); - expect(b).toBe('hello'); - }); - - it('allows complex types', async () => { - const res = tf.tidy(() => { - return {a: tf.scalar(1), b: 'hello', c: [tf.scalar(2), 'world']}; - }); - expectArraysClose(await res.a.data(), [1]); - expectArraysClose(await (res.c[0] as tf.Tensor).data(), [2]); - }); - - it('returns Tensor[]', async () => { - const a = tf.tensor1d([1, 2, 3]); - const b = tf.tensor1d([0, -1, 1]); - expect(tf.memory().numTensors).toBe(2); - - tf.tidy(() => { - const result = tf.tidy(() => { - tf.add(a, b); - return [tf.add(a, b), tf.sub(a, b)]; - }); - - // the 2 results are new. All intermediates should be disposed. - expect(tf.memory().numTensors).toBe(4); - expect(result[0].isDisposed).toBe(false); - expect(result[0].shape).toEqual([3]); - expect(result[1].isDisposed).toBe(false); - expect(result[1].shape).toEqual([3]); - expect(tf.memory().numTensors).toBe(4); - }); - - // the 2 results should be disposed. - expect(tf.memory().numTensors).toBe(2); - a.dispose(); - b.dispose(); - expect(tf.memory().numTensors).toBe(0); - }); - - it('basic usage without return', () => { - const a = tf.tensor1d([1, 2, 3]); - let b = tf.tensor1d([0, 0, 0]); - - expect(tf.memory().numTensors).toBe(2); - - tf.tidy(() => { - b = tf.add(a, b); - b = tf.add(a, b); - b = tf.add(a, b); - tf.add(a, b); - }); - - // all intermediates should be disposed. - expect(tf.memory().numTensors).toBe(2); - }); - - it('nested usage', async () => { - const a = tf.tensor1d([1, 2, 3]); - let b = tf.tensor1d([0, 0, 0]); - - expect(tf.memory().numTensors).toBe(2); - - tf.tidy(() => { - const result = tf.tidy(() => { - b = tf.add(a, b); - b = tf.tidy(() => { - b = tf.tidy(() => { - return tf.add(a, b); - }); - // original a, b, and two intermediates. - expect(tf.memory().numTensors).toBe(4); - - tf.tidy(() => { - tf.add(a, b); - }); - // All the intermediates should be cleaned up. - expect(tf.memory().numTensors).toBe(4); - - return tf.add(a, b); - }); - expect(tf.memory().numTensors).toBe(4); - - return tf.add(a, b); - }); - - expect(tf.memory().numTensors).toBe(3); - expect(result.isDisposed).toBe(false); - expect(result.shape).toEqual([3]); - }); - expect(tf.memory().numTensors).toBe(2); - }); - - it('nested usage returns tensor created from outside scope', () => { - const x = tf.scalar(1); - - tf.tidy(() => { - tf.tidy(() => { - return x; - }); - }); - - expect(x.isDisposed).toBe(false); - }); - - it('nested usage with keep works', () => { - let b: tf.Tensor; - tf.tidy(() => { - const a = tf.scalar(1); - tf.tidy(() => { - b = tf.keep(a); - }); - }); - - expect(b.isDisposed).toBe(false); - b.dispose(); - }); - - it('single argument', () => { - let hasRan = false; - tf.tidy(() => { - hasRan = true; - }); - expect(hasRan).toBe(true); - }); - - it('single argument, but not a function throws error', () => { - expect(() => { - tf.tidy('asdf'); - }).toThrowError(); - }); - - it('2 arguments, first is string', () => { - let hasRan = false; - tf.tidy('name', () => { - hasRan = true; - }); - expect(hasRan).toBe(true); - }); - - it('2 arguments, but first is not string throws error', () => { - expect(() => { - // tslint:disable-next-line:no-any - tf.tidy(4 as any, () => {}); - }).toThrowError(); - }); - - it('2 arguments, but second is not a function throws error', () => { - expect(() => { - // tslint:disable-next-line:no-any - tf.tidy('name', 'another name' as any); - }).toThrowError(); - }); - - it('works with arbitrary depth of result', async () => { - tf.tidy(() => { - const res = tf.tidy(() => { - return [tf.scalar(1), [[tf.scalar(2)]], {list: [tf.scalar(3)]}]; - }); - expect((res[0] as tf.Tensor).isDisposed).toBe(false); - // tslint:disable-next-line:no-any - expect((res[1] as any)[0][0].isDisposed).toBe(false); - // tslint:disable-next-line:no-any - expect((res[2] as any).list[0].isDisposed).toBe(false); - expect(tf.memory().numTensors).toBe(3); - return res[0]; - }); - // Everything but scalar(1) got disposed. - expect(tf.memory().numTensors).toBe(1); - }); -}); diff --git a/tfjs-master/tfjs-core/src/gradients.ts b/tfjs-master/tfjs-core/src/gradients.ts deleted file mode 100644 index 9ea6c6022..000000000 --- a/tfjs-master/tfjs-core/src/gradients.ts +++ /dev/null @@ -1,395 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {CustomGradientFunc, ENGINE} from './engine'; -import {Scalar, Tensor, Variable} from './tensor'; -import {NamedTensorMap} from './tensor_types'; -import {convertToTensor, convertToTensorArray} from './tensor_util_env'; -import {TensorLike} from './types'; -import * as util from './util'; - -/** - * Provided `f(x)`, returns another function `g(x, dy?)`, which gives the - * gradient of `f(x)` with respect to `x`. - * - * If `dy` is provided, the gradient of `f(x).mul(dy).sum()` with respect to - * `x` is computed instead. `f(x)` must take a single tensor `x` and return a - * single tensor `y`. If `f()` takes multiple inputs, use `tf.grads` instead. - * - * ```js - * // f(x) = x ^ 2 - * const f = x => x.square(); - * // f'(x) = 2x - * const g = tf.grad(f); - * - * const x = tf.tensor1d([2, 3]); - * g(x).print(); - * ``` - * - * ```js - * // f(x) = x ^ 3 - * const f = x => x.pow(tf.scalar(3, 'int32')); - * // f'(x) = 3x ^ 2 - * const g = tf.grad(f); - * // f''(x) = 6x - * const gg = tf.grad(g); - * - * const x = tf.tensor1d([2, 3]); - * gg(x).print(); - * ``` - * - * @param f The function f(x), to compute gradient for. - * - * @doc {heading: 'Training', subheading: 'Gradients'} - */ -function grad(f: (x: Tensor) => Tensor): ( - x: TensorLike|Tensor, dy?: TensorLike|Tensor) => Tensor { - util.assert( - util.isFunction(f), () => 'The f passed in grad(f) must be a function'); - return (x: TensorLike|Tensor, dy?: TensorLike|Tensor): Tensor => { - // x can be of any dtype, thus null as the last argument. - const $x = convertToTensor(x, 'x', 'tf.grad', 'string_or_numeric'); - const $dy: Tensor = - (dy != null) ? convertToTensor(dy, 'dy', 'tf.grad') : null; - return ENGINE.tidy(() => { - const {value, grads} = ENGINE.gradients(() => f($x), [$x], $dy); - if ($dy != null) { - util.assertShapesMatch( - value.shape, $dy.shape, - 'The shape of dy passed in grad(f)(x, dy) must match the shape ' + - 'returned by f(x)'); - } - checkGrads(grads); - return grads[0]; - }); - }; -} - -/** - * Provided `f(x1, x2,...)`, returns another function `g([x1, x2,...], dy?)`, - * which gives an array of gradients of `f()` with respect to each input - * [`x1`,`x2`,...]. - * - * If `dy` is passed when calling `g()`, the gradient of - * `f(x1,...).mul(dy).sum()` with respect to each input is computed instead. - * The provided `f` must take one or more tensors and return a single tensor - * `y`. If `f()` takes a single input, we recommend using `tf.grad` instead. - * - * ```js - * // f(a, b) = a * b - * const f = (a, b) => a.mul(b); - * // df / da = b, df / db = a - * const g = tf.grads(f); - * - * const a = tf.tensor1d([2, 3]); - * const b = tf.tensor1d([-2, -3]); - * const [da, db] = g([a, b]); - * console.log('da'); - * da.print(); - * console.log('db'); - * db.print(); - * ``` - * - * @param f The function `f(x1, x2,...)` to compute gradients for. - * - * @doc {heading: 'Training', subheading: 'Gradients'} - */ -function grads(f: (...args: Tensor[]) => Tensor): ( - args: Array, dy?: Tensor|TensorLike) => Tensor[] { - util.assert( - util.isFunction(f), () => 'The f passed in grads(f) must be a function'); - return (args: Array, dy?: Tensor|TensorLike): Tensor[] => { - util.assert( - Array.isArray(args), - () => 'The args passed in grads(f)(args) must be an array ' + - 'of `Tensor`s or `TensorLike`s'); - // args can be of any dtype, thus null as the last argument. - const $args = - convertToTensorArray(args, 'args', 'tf.grads', 'string_or_numeric'); - const $dy: Tensor = - (dy != null) ? convertToTensor(dy, 'dy', 'tf.grads') : null; - return ENGINE.tidy(() => { - const {value, grads} = ENGINE.gradients(() => f(...$args), $args, $dy); - if ($dy != null) { - util.assertShapesMatch( - value.shape, $dy.shape, - 'The shape of dy passed in grads(f)([x1,...], dy) must ' + - 'match the shape returned by f([x1,...])'); - } - checkGrads(grads); - return grads; - }); - }; -} - -/** - * Like `tf.grad`, but also returns the value of `f()`. Useful when `f()` - * returns a metric you want to show. - * - * The result is a rich object with the following properties: - * - grad: The gradient of `f(x)` w.r.t. `x` (result of `tf.grad`). - * - value: The value returned by `f(x)`. - * - * ```js - * // f(x) = x ^ 2 - * const f = x => x.square(); - * // f'(x) = 2x - * const g = tf.valueAndGrad(f); - * - * const x = tf.tensor1d([2, 3]); - * const {value, grad} = g(x); - * - * console.log('value'); - * value.print(); - * console.log('grad'); - * grad.print(); - * ``` - * - * @doc {heading: 'Training', subheading: 'Gradients'} - */ -function valueAndGrad(f: (x: I) => O): ( - x: I, dy?: O) => { - value: O; - grad: I; -} { - util.assert( - util.isFunction(f), - () => 'The f passed in valueAndGrad(f) must be a function'); - return (x: I, dy?: O) => { - util.assert( - x instanceof Tensor, - () => 'The x passed in valueAndGrad(f)(x) must be a tensor'); - util.assert( - dy == null || dy instanceof Tensor, - () => 'The dy passed in valueAndGrad(f)(x, dy) must be a tensor'); - const {grads, value} = ENGINE.gradients(() => f(x), [x], dy); - checkGrads(grads); - return {grad: grads[0] as I, value}; - }; -} - -/** - * Like `tf.grads`, but returns also the value of `f()`. Useful when `f()` - * returns a metric you want to show. - * - * The result is a rich object with the following properties: - * - grads: The gradients of `f()` w.r.t. each input (result of `tf.grads`). - * - value: The value returned by `f(x)`. - * - * ```js - * // f(a, b) = a * b - * const f = (a, b) => a.mul(b); - * // df/da = b, df/db = a - * const g = tf.valueAndGrads(f); - * - * const a = tf.tensor1d([2, 3]); - * const b = tf.tensor1d([-2, -3]); - * const {value, grads} = g([a, b]); - * - * const [da, db] = grads; - * - * console.log('value'); - * value.print(); - * - * console.log('da'); - * da.print(); - * console.log('db'); - * db.print(); - * ``` - * - * @doc {heading: 'Training', subheading: 'Gradients'} - */ -function valueAndGrads(f: (...args: Tensor[]) => O): ( - args: Tensor[], dy?: O) => { - grads: Tensor[]; - value: O; -} { - util.assert( - util.isFunction(f), - () => 'The f passed in valueAndGrads(f) must be a function'); - return (args: Tensor[], dy?: O) => { - util.assert( - Array.isArray(args) && args.every(arg => arg instanceof Tensor), - () => 'The args passed in valueAndGrads(f)(args) must be array of ' + - 'tensors'); - util.assert( - dy == null || dy instanceof Tensor, - () => 'The dy passed in valueAndGrads(f)(args, dy) must be a tensor'); - const res = ENGINE.gradients(() => f(...args), args, dy); - if (dy != null) { - util.assertShapesMatch( - res.value.shape, dy.shape, - 'The shape of dy passed in valueAndGrads(f)([x1,...], dy) must ' + - 'match the shape returned by f([x1,...])'); - } - checkGrads(res.grads); - return res; - }; -} - -/** - * Computes and returns the gradient of f(x) with respect to the list of - * trainable variables provided by `varList`. If no list is provided, it - * defaults to all trainable variables. - * - * ```js - * const a = tf.variable(tf.tensor1d([3, 4])); - * const b = tf.variable(tf.tensor1d([5, 6])); - * const x = tf.tensor1d([1, 2]); - * - * // f(a, b) = a * x ^ 2 + b * x - * const f = () => a.mul(x.square()).add(b.mul(x)).sum(); - * // df/da = x ^ 2, df/db = x - * const {value, grads} = tf.variableGrads(f); - * - * Object.keys(grads).forEach(varName => grads[varName].print()); - * ``` - * - * @param f The function to execute. f() should return a scalar. - * @param varList The list of variables to compute the gradients with respect - * to. Defaults to all trainable variables. - * @returns An object with the following keys and values: - * - `value`: The value of the function `f`. - * - `grads`: A map from the names of the variables to the gradients. - * If the `varList` argument is provided explicitly and contains a subset of - * non-trainable variables, this map in the return value will contain keys - * that map the names of the non-trainable variables to `null`. - * - * @doc {heading: 'Training', subheading: 'Gradients'} - */ -function variableGrads(f: () => Scalar, varList?: Variable[]): - {value: Scalar, grads: NamedTensorMap} { - util.assert( - util.isFunction(f), - () => 'The f passed in variableGrads(f) must be a function'); - util.assert( - varList == null || - Array.isArray(varList) && varList.every(v => v instanceof Variable), - () => - 'The varList passed in variableGrads(f, varList) must be an array ' + - 'of variables'); - - const specifiedVarList = varList != null; - if (!specifiedVarList) { - // Get all of the trainable variables. - varList = []; - for (const varName in ENGINE.registeredVariables) { - varList.push(ENGINE.registeredVariables[varName]); - } - } - - const specifiedNonTrainable: Variable[] = - specifiedVarList ? varList.filter(variable => !variable.trainable) : null; - - // Prune non-trainable variables. - const originalVarCount = varList.length; - varList = varList.filter(variable => variable.trainable); - util.assert( - varList.length > 0, - () => `variableGrads() expects at least one of the input variables to ` + - `be trainable, but none of the ${originalVarCount} variables is ` + - `trainable.`); - - const allowNoGradients = true; - const {value, grads} = ENGINE.gradients(f, varList, null, allowNoGradients); - - util.assert( - grads.some(g => g != null), - () => 'Cannot find a connection between any variable and the result of ' + - 'the loss function y=f(x). Please make sure the operations that ' + - 'use variables are inside the function f passed to minimize().'); - util.assert( - value.rank === 0, - () => `The f passed in variableGrads(f) must return a scalar, but it ` + - `returned a rank-${value.rank} tensor`); - - const namedGrads: NamedTensorMap = {}; - varList.forEach((v, i) => { - if (grads[i] != null) { - namedGrads[v.name] = grads[i]; - } - }); - if (specifiedNonTrainable != null) { - // If varList is explicitly provided and contains non-trainable values, - // add them to the returned gradients with `null` values. - specifiedNonTrainable.forEach(v => namedGrads[v.name] = null); - } - return {value, grads: namedGrads}; -} - -/** - * Overrides the gradient computation of a function `f`. - * - * Takes a function - * `f(...inputs, save) => {value: Tensor, gradFunc: (dy, saved) => Tensor[]}` - * and returns another function `g(...inputs)` which takes the same inputs as - * `f`. When called, `g` returns `f().value`. In backward mode, custom gradients - * with respect to each input of `f` are computed using `f().gradFunc`. - * - * The `save` function passed to `f` should be used for saving tensors needed - * in the gradient. And the `saved` passed to the `gradFunc` is a - * `NamedTensorMap`, which contains those saved tensors. - * - * ```js - * const customOp = tf.customGrad((x, save) => { - * // Save x to make sure it's available later for the gradient. - * save([x]); - * // Override gradient of our custom x ^ 2 op to be dy * abs(x); - * return { - * value: x.square(), - * // Note `saved.x` which points to the `x` we saved earlier. - * gradFunc: (dy, saved) => [dy.mul(saved[0].abs())] - * }; - * }); - * - * const x = tf.tensor1d([-1, -2, 3]); - * const dx = tf.grad(x => customOp(x)); - * - * console.log(`f(x):`); - * customOp(x).print(); - * console.log(`f'(x):`); - * dx(x).print(); - * ``` - * - * @param f The function to evaluate in forward mode, which should return - * `{value: Tensor, gradFunc: (dy, saved) => Tensor[]}`, where `gradFunc` - * returns the custom gradients of `f` with respect to its inputs. - * - * @doc {heading: 'Training', subheading: 'Gradients'} - */ -function customGrad(f: CustomGradientFunc): - (...args: Tensor[]) => T { - return ENGINE.customGrad(f); -} - -function checkGrads(grads: Tensor[]) { - const numNullGradients = grads.filter(g => g == null).length; - if (numNullGradients > 0) { - throw new Error( - `Cannot compute gradient of y=f(x) with respect to x. Make sure that - the f you passed encloses all operations that lead from x to y.`); - } -} - -export { - customGrad, - variableGrads, - valueAndGrad, - valueAndGrads, - grad, - grads, -}; diff --git a/tfjs-master/tfjs-core/src/gradients/Abs_grad.ts b/tfjs-master/tfjs-core/src/gradients/Abs_grad.ts deleted file mode 100644 index a0709ce6d..000000000 --- a/tfjs-master/tfjs-core/src/gradients/Abs_grad.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Abs} from '../kernel_names'; -import {GradConfig} from '../kernel_registry'; -import {cast} from '../ops/cast'; -import {mul} from '../ops/mul'; -import {step} from '../ops/step'; -import {Tensor} from '../tensor'; - -export const absGradConfig: GradConfig = { - kernelName: Abs, - inputsToSave: ['x'], - gradFunc: (dy: Tensor, saved: Tensor[]) => { - const [x] = saved; - return {x: () => mul(dy, step(cast(x, 'float32'), -1))}; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/Acos_grad.ts b/tfjs-master/tfjs-core/src/gradients/Acos_grad.ts deleted file mode 100644 index 718865319..000000000 --- a/tfjs-master/tfjs-core/src/gradients/Acos_grad.ts +++ /dev/null @@ -1,44 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Acos} from '../kernel_names'; -import {GradConfig} from '../kernel_registry'; -import {cast} from '../ops/cast'; -import {div} from '../ops/div'; -import {neg} from '../ops/neg'; -import {scalar} from '../ops/scalar'; -import {sqrt} from '../ops/sqrt'; -import {square} from '../ops/square'; -import {sub} from '../ops/sub'; -import {Tensor} from '../tensor'; - -export const acosGradConfig: GradConfig = { - kernelName: Acos, - inputsToSave: ['x'], - gradFunc: (dy: Tensor, saved: Tensor[]) => { - const [x] = saved; - - return { - x: () => { - const a = square(cast(x, 'float32')); - const b = sqrt(sub(scalar(1), a)); - return neg(div(dy, b)); - } - - }; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/Acosh_grad.ts b/tfjs-master/tfjs-core/src/gradients/Acosh_grad.ts deleted file mode 100644 index 5fd891611..000000000 --- a/tfjs-master/tfjs-core/src/gradients/Acosh_grad.ts +++ /dev/null @@ -1,40 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Acosh} from '../kernel_names'; -import {GradConfig} from '../kernel_registry'; -import {cast} from '../ops/cast'; -import {div} from '../ops/div'; -import {sqrt} from '../ops/sqrt'; -import {square} from '../ops/square'; -import {sub} from '../ops/sub'; -import {Tensor} from '../tensor'; - -export const acoshGradConfig: GradConfig = { - kernelName: Acosh, - inputsToSave: ['x'], - gradFunc: (dy: Tensor, saved: Tensor[]) => { - const [x] = saved; - - return { - x: () => { - const a = sqrt(sub(square(cast(x, 'float32')), 1)); - return div(dy, a); - } - }; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/AddN_grad.ts b/tfjs-master/tfjs-core/src/gradients/AddN_grad.ts deleted file mode 100644 index 2969e14c3..000000000 --- a/tfjs-master/tfjs-core/src/gradients/AddN_grad.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {AddN} from '../kernel_names'; -import {GradConfig} from '../kernel_registry'; -import {Tensor} from '../tensor'; - -export const addNGradConfig: GradConfig = { - kernelName: AddN, - saveAllInputs: true, - gradFunc: (dy: Tensor, saved: Tensor[]) => { - const ders: {[key: string]: () => Tensor} = {}; - saved.forEach((_, i) => { - ders[i] = () => dy.clone(); - }); - return ders; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/Add_grad.ts b/tfjs-master/tfjs-core/src/gradients/Add_grad.ts deleted file mode 100644 index 2618ac6d1..000000000 --- a/tfjs-master/tfjs-core/src/gradients/Add_grad.ts +++ /dev/null @@ -1,51 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {Add} from '../kernel_names'; -import {GradConfig} from '../kernel_registry'; -import * as broadcast_util from '../ops/broadcast_util'; -import {reshape} from '../ops/reshape'; -import {sum} from '../ops/sum'; -import {Tensor} from '../tensor'; - -export const addGradConfig: GradConfig = { - kernelName: Add, - inputsToSave: ['a', 'b'], - gradFunc: (dy: Tensor, saved: Tensor[]) => { - const [a, b] = saved; - const outShape = - broadcast_util.assertAndGetBroadcastShape(a.shape, b.shape); - - const derA = () => { - let res = dy; - const reduceAxes = broadcast_util.getReductionAxes(a.shape, outShape); - if (reduceAxes.length > 0) { - res = sum(res, reduceAxes); - } - return reshape(res, a.shape); - }; - const derB = () => { - let res = dy; - const reduceAxes = broadcast_util.getReductionAxes(b.shape, outShape); - if (reduceAxes.length > 0) { - res = sum(res, reduceAxes); - } - return reshape(res, b.shape); - }; - - return {a: derA, b: derB}; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/ArgMax_grad.ts b/tfjs-master/tfjs-core/src/gradients/ArgMax_grad.ts deleted file mode 100644 index 109523c41..000000000 --- a/tfjs-master/tfjs-core/src/gradients/ArgMax_grad.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** - * @license - * Copyright 2020 Google Inc. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ArgMax} from '../kernel_names'; -import {GradConfig} from '../kernel_registry'; -import {zerosLike} from '../ops/zeros_like'; -import {Tensor} from '../tensor'; - -export const argMaxGradConfig: GradConfig = { - kernelName: ArgMax, - inputsToSave: ['x'], - gradFunc: (dy: Tensor, saved: Tensor[]) => { - const [x] = saved; - return {x: () => zerosLike(x)}; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/ArgMin_grad.ts b/tfjs-master/tfjs-core/src/gradients/ArgMin_grad.ts deleted file mode 100644 index 063b6e631..000000000 --- a/tfjs-master/tfjs-core/src/gradients/ArgMin_grad.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** - * @license - * Copyright 2020 Google Inc. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ArgMin} from '../kernel_names'; -import {GradConfig} from '../kernel_registry'; -import {zerosLike} from '../ops/zeros_like'; -import {Tensor} from '../tensor'; - -export const argMinGradConfig: GradConfig = { - kernelName: ArgMin, - inputsToSave: ['x'], - gradFunc: (dy: Tensor, saved: Tensor[]) => { - const [x] = saved; - return {x: () => zerosLike(x)}; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/Asin_grad.ts b/tfjs-master/tfjs-core/src/gradients/Asin_grad.ts deleted file mode 100644 index 09851e347..000000000 --- a/tfjs-master/tfjs-core/src/gradients/Asin_grad.ts +++ /dev/null @@ -1,35 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Asin} from '../kernel_names'; -import {GradConfig} from '../kernel_registry'; -import {cast} from '../ops/cast'; -import {div} from '../ops/div'; -import {scalar} from '../ops/scalar'; -import {sqrt} from '../ops/sqrt'; -import {square} from '../ops/square'; -import {sub} from '../ops/sub'; -import {Tensor} from '../tensor'; - -export const asinGradConfig: GradConfig = { - kernelName: Asin, - inputsToSave: ['x'], - gradFunc: (dy: Tensor, saved: Tensor[]) => { - const [x] = saved; - return {x: () => div(dy, sqrt(sub(scalar(1), square(cast(x, 'float32')))))}; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/Asinh_grad.ts b/tfjs-master/tfjs-core/src/gradients/Asinh_grad.ts deleted file mode 100644 index 4ee93ba40..000000000 --- a/tfjs-master/tfjs-core/src/gradients/Asinh_grad.ts +++ /dev/null @@ -1,41 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Asinh} from '../kernel_names'; -import {GradConfig} from '../kernel_registry'; -import {add} from '../ops/add'; -import {cast} from '../ops/cast'; -import {div} from '../ops/div'; -import {scalar} from '../ops/scalar'; -import {sqrt} from '../ops/sqrt'; -import {square} from '../ops/square'; -import {Tensor} from '../tensor'; - -export const asinhGradConfig: GradConfig = { - kernelName: Asinh, - inputsToSave: ['x'], - gradFunc: (dy: Tensor, saved: Tensor[]) => { - const [x] = saved; - - return { - x: () => { - const a = sqrt(add(scalar(1), square(cast(x, 'float32')))); - return div(dy, a); - } - }; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/Atan2_grad.ts b/tfjs-master/tfjs-core/src/gradients/Atan2_grad.ts deleted file mode 100644 index b94a282be..000000000 --- a/tfjs-master/tfjs-core/src/gradients/Atan2_grad.ts +++ /dev/null @@ -1,57 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Atan2} from '../kernel_names'; -import {GradConfig} from '../kernel_registry'; -import {add} from '../ops/add'; -import {assertAndGetBroadcastShape, getReductionAxes} from '../ops/broadcast_util'; -import {div} from '../ops/div'; -import {mul} from '../ops/mul'; -import {neg} from '../ops/neg'; -import {reshape} from '../ops/reshape'; -import {square} from '../ops/square'; -import {sum} from '../ops/sum'; -import {Tensor} from '../tensor'; - -export const atan2GradConfig: GradConfig = { - kernelName: Atan2, - inputsToSave: ['a', 'b'], - gradFunc: (dy: Tensor, saved: Tensor[]) => { - const [a, b] = saved; - const outShape = assertAndGetBroadcastShape(a.shape, b.shape); - - const derA = () => { - const d = add(square(a), square(b)); - let res = mul(dy, div(b, d)); - const reduceAxes = getReductionAxes(a.shape, outShape); - if (reduceAxes.length > 0) { - res = sum(res, reduceAxes); - } - return reshape(res, a.shape); - }; - const derB = () => { - const d = add(square(a), square(b)); - let res = neg(mul(dy, div(a, d))); - const reduceAxes = getReductionAxes(b.shape, outShape); - if (reduceAxes.length > 0) { - res = sum(res, reduceAxes); - } - return reshape(res, b.shape); - }; - return {a: derA, b: derB}; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/Atan_grad.ts b/tfjs-master/tfjs-core/src/gradients/Atan_grad.ts deleted file mode 100644 index cb1b2bf68..000000000 --- a/tfjs-master/tfjs-core/src/gradients/Atan_grad.ts +++ /dev/null @@ -1,34 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Atan} from '../kernel_names'; -import {GradConfig} from '../kernel_registry'; -import {add} from '../ops/add'; -import {cast} from '../ops/cast'; -import {div} from '../ops/div'; -import {square} from '../ops/square'; -import {Tensor} from '../tensor'; - -export const atanGradConfig: GradConfig = { - kernelName: Atan, - inputsToSave: ['x'], - gradFunc: (dy: Tensor, saved: Tensor[]) => { - const [x] = saved; - - return {x: () => div(dy, add(square(cast(x, 'float32')), 1))}; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/Atanh_grad.ts b/tfjs-master/tfjs-core/src/gradients/Atanh_grad.ts deleted file mode 100644 index c1dcd5865..000000000 --- a/tfjs-master/tfjs-core/src/gradients/Atanh_grad.ts +++ /dev/null @@ -1,35 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Atanh} from '../kernel_names'; -import {GradConfig} from '../kernel_registry'; -import {cast} from '../ops/cast'; -import {div} from '../ops/div'; -import {square} from '../ops/square'; -import {sub} from '../ops/sub'; -import {scalar} from '../ops/scalar'; -import {Tensor} from '../tensor'; - -export const atanhGradConfig: GradConfig = { - kernelName: Atanh, - inputsToSave: ['x'], - gradFunc: (dy: Tensor, saved: Tensor[]) => { - const [x] = saved; - - return {x: () => div(dy, sub(scalar(1), square(cast(x, 'float32'))))}; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/AvgPool3D_grad.ts b/tfjs-master/tfjs-core/src/gradients/AvgPool3D_grad.ts deleted file mode 100644 index e66a6c2fb..000000000 --- a/tfjs-master/tfjs-core/src/gradients/AvgPool3D_grad.ts +++ /dev/null @@ -1,36 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {AvgPool3D, AvgPool3DAttrs} from '../kernel_names'; -import {GradConfig, NamedAttrMap} from '../kernel_registry'; -import {avgPool3dGrad} from '../ops/avg_pool_3d_grad'; -import {Tensor, Tensor5D} from '../tensor'; - -export const avgPool3DGradConfig: GradConfig = { - kernelName: AvgPool3D, - inputsToSave: ['x'], - gradFunc: (dy: Tensor, saved: Tensor[], attrs: NamedAttrMap) => { - const [x] = saved as [Tensor5D]; - const {filterSize, strides, pad, dimRoundingMode} = - attrs as unknown as AvgPool3DAttrs; - - return { - x: () => avgPool3dGrad( - dy as Tensor5D, x, filterSize, strides, pad, dimRoundingMode) - }; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/AvgPool_grad.ts b/tfjs-master/tfjs-core/src/gradients/AvgPool_grad.ts deleted file mode 100644 index c46065802..000000000 --- a/tfjs-master/tfjs-core/src/gradients/AvgPool_grad.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {AvgPool, AvgPoolAttrs} from '../kernel_names'; -import {GradConfig, NamedAttrMap} from '../kernel_registry'; -import {avgPoolGrad} from '../ops/avg_pool_grad'; -import {Tensor, Tensor4D} from '../tensor'; - -export const avgPoolGradConfig: GradConfig = { - kernelName: AvgPool, - inputsToSave: ['x'], - gradFunc: (dy: Tensor, saved: Tensor[], attrs: NamedAttrMap) => { - const [x] = saved as [Tensor4D]; - const {filterSize, strides, pad} = attrs as unknown as AvgPoolAttrs; - return {x: () => avgPoolGrad(dy as Tensor4D, x, filterSize, strides, pad)}; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/BatchMatMul_grad.ts b/tfjs-master/tfjs-core/src/gradients/BatchMatMul_grad.ts deleted file mode 100644 index 71d109dde..000000000 --- a/tfjs-master/tfjs-core/src/gradients/BatchMatMul_grad.ts +++ /dev/null @@ -1,53 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {BatchMatMul, BatchMatMulAttrs} from '../kernel_names'; -import {GradConfig, NamedAttrMap} from '../kernel_registry'; -import {matMul} from '../ops/mat_mul'; -import {Tensor} from '../tensor'; - -export const batchMatMulGradConfig: GradConfig = { - kernelName: BatchMatMul, - inputsToSave: ['a', 'b'], - gradFunc: (dy: Tensor, saved: Tensor[], attrs: NamedAttrMap) => { - const [a, b] = saved; - - const {transposeA, transposeB} = attrs as unknown as BatchMatMulAttrs; - - if (!transposeA && !transposeB) { - return { - a: () => matMul(dy, b, false, true), - b: () => matMul(a, dy, true, false) - }; - } else if (!transposeA && transposeB) { - return { - a: () => matMul(dy, b, false, false), - b: () => matMul(dy, a, true, false) - }; - } else if (transposeA && !transposeB) { - return { - a: () => matMul(b, dy, false, true), - b: () => matMul(a, dy, false, false) - }; - } else { - return { - a: () => matMul(b, dy, true, true), - b: () => matMul(dy, a, true, true) - }; - } - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/BatchToSpaceND_grad.ts b/tfjs-master/tfjs-core/src/gradients/BatchToSpaceND_grad.ts deleted file mode 100644 index 5f8fce512..000000000 --- a/tfjs-master/tfjs-core/src/gradients/BatchToSpaceND_grad.ts +++ /dev/null @@ -1,29 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {BatchToSpaceND, BatchToSpaceNDAttrs} from '../kernel_names'; -import {GradConfig, NamedAttrMap} from '../kernel_registry'; -import {spaceToBatchND} from '../ops/space_to_batch_nd'; -import {Tensor} from '../tensor'; - -export const batchToSpaceNDGradConfig: GradConfig = { - kernelName: BatchToSpaceND, - gradFunc: (dy: Tensor, saved: Tensor[], attrs: NamedAttrMap) => { - const {blockShape, crops} = attrs as unknown as BatchToSpaceNDAttrs; - return {x: () => spaceToBatchND(dy, blockShape, crops)}; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/BroadcastTo_grad.ts b/tfjs-master/tfjs-core/src/gradients/BroadcastTo_grad.ts deleted file mode 100644 index 91bdf63d7..000000000 --- a/tfjs-master/tfjs-core/src/gradients/BroadcastTo_grad.ts +++ /dev/null @@ -1,50 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {BroadcastTo, BroadCastToAttrs} from '../kernel_names'; -import {GradConfig, NamedAttrMap} from '../kernel_registry'; -import {sum} from '../ops/sum'; -import {Tensor} from '../tensor'; - -export const broadcastToGradConfig: GradConfig = { - kernelName: BroadcastTo, - gradFunc: (dy: Tensor, saved: Tensor[], attrs: NamedAttrMap) => { - const broadCastToAttrs: BroadCastToAttrs = - attrs as unknown as BroadCastToAttrs; - - const inputShape = broadCastToAttrs.inputShape; - const outputShape = broadCastToAttrs.shape; - - const reps: number[] = Array.from(outputShape); - for (let i = inputShape.length - 1; i >= 0; i--) { - if (inputShape[i] === outputShape[i]) { - reps[i] = 1; - } else if (inputShape[i] !== 1) { - throw new Error(`broadcastTo(): [${ - inputShape}] cannot be broadcast to [${outputShape}].`); - } - } - const axes: number[] = []; - for (let i = 0; i < reps.length; i++) { - if (reps[i] > 1) { - axes.push(i); - } - } - - return {x: () => sum(dy, axes, true /* keepDims */)}; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/Cast_grad.ts b/tfjs-master/tfjs-core/src/gradients/Cast_grad.ts deleted file mode 100644 index 1efb1ff26..000000000 --- a/tfjs-master/tfjs-core/src/gradients/Cast_grad.ts +++ /dev/null @@ -1,27 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Cast} from '../kernel_names'; -import {GradConfig} from '../kernel_registry'; -import {Tensor} from '../tensor'; - -export const castGradConfig: GradConfig = { - kernelName: Cast, - gradFunc: (dy: Tensor) => { - return {x: () => dy.clone()}; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/Ceil_grad.ts b/tfjs-master/tfjs-core/src/gradients/Ceil_grad.ts deleted file mode 100644 index 3b3ebabbc..000000000 --- a/tfjs-master/tfjs-core/src/gradients/Ceil_grad.ts +++ /dev/null @@ -1,29 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Ceil} from '../kernel_names'; -import {GradConfig} from '../kernel_registry'; -import {zerosLike} from '../ops/zeros_like'; -import {Tensor} from '../tensor'; - -export const ceilGradConfig: GradConfig = { - kernelName: Ceil, - gradFunc: (dy: Tensor) => { - // TODO(manrajgrover): Return null for gradients when backprop supports it. - return {x: () => zerosLike(dy)}; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/ClipByValue_grad.ts b/tfjs-master/tfjs-core/src/gradients/ClipByValue_grad.ts deleted file mode 100644 index d054f2be7..000000000 --- a/tfjs-master/tfjs-core/src/gradients/ClipByValue_grad.ts +++ /dev/null @@ -1,39 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ClipByValue, ClipByValueAttrs} from '../kernel_names'; -import {GradConfig, NamedAttrMap} from '../kernel_registry'; -import {greaterEqual} from '../ops/greater_equal'; -import {lessEqual} from '../ops/less_equal'; -import {logicalAnd} from '../ops/logical_and'; -import {where} from '../ops/where'; -import {zerosLike} from '../ops/zeros_like'; -import {Tensor} from '../tensor'; - -export const clipByValueGradConfig: GradConfig = { - kernelName: ClipByValue, - inputsToSave: ['x'], - gradFunc: (dy: Tensor, saved: Tensor[], attrs: NamedAttrMap) => { - const [x] = saved; - const {clipValueMin, clipValueMax} = attrs as unknown as ClipByValueAttrs; - return { - x: () => where( - logicalAnd(greaterEqual(x, clipValueMin), lessEqual(x, clipValueMax)), - dy, zerosLike(dy)), - }; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/ComplexAbs_grad.ts b/tfjs-master/tfjs-core/src/gradients/ComplexAbs_grad.ts deleted file mode 100644 index 6e39616f6..000000000 --- a/tfjs-master/tfjs-core/src/gradients/ComplexAbs_grad.ts +++ /dev/null @@ -1,26 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ComplexAbs} from '../kernel_names'; -import {GradConfig} from '../kernel_registry'; -import {absGradConfig} from './Abs_grad'; - -export const complexAbsGradConfig: GradConfig = { - kernelName: ComplexAbs, - inputsToSave: ['x'], - gradFunc: absGradConfig.gradFunc, -}; diff --git a/tfjs-master/tfjs-core/src/gradients/Concat_grad.ts b/tfjs-master/tfjs-core/src/gradients/Concat_grad.ts deleted file mode 100644 index cfe617246..000000000 --- a/tfjs-master/tfjs-core/src/gradients/Concat_grad.ts +++ /dev/null @@ -1,34 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {Concat, ConcatAttrs} from '../kernel_names'; -import {GradConfig, NamedAttrMap} from '../kernel_registry'; -import {split} from '../ops/split'; -import {Tensor} from '../tensor'; -import {parseAxisParam} from '../util'; - -export const concatGradConfig: GradConfig = { - kernelName: Concat, - saveAllInputs: true, - gradFunc: (dy: Tensor, saved: Tensor[], attrs: NamedAttrMap) => { - const shapes = saved.map(t => t.shape); - const {axis} = attrs as unknown as ConcatAttrs; - const $axis = parseAxisParam(axis, saved[0].shape)[0]; - const sizeSplits = shapes.map(s => s[$axis]); - const derTensors = split(dy, sizeSplits, $axis); - return derTensors.map(t => () => t) as {}; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/Conv2DBackpropInput_grad.ts b/tfjs-master/tfjs-core/src/gradients/Conv2DBackpropInput_grad.ts deleted file mode 100644 index fdd911a32..000000000 --- a/tfjs-master/tfjs-core/src/gradients/Conv2DBackpropInput_grad.ts +++ /dev/null @@ -1,40 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {Conv2DBackpropInput, Conv2DBackpropInputAttrs} from '../kernel_names'; -import {GradConfig, NamedAttrMap} from '../kernel_registry'; -import {conv2d} from '../ops/conv2d'; -import {conv2DBackpropFilter} from '../ops/conv2d_backprop_filter'; -import {Tensor, Tensor4D} from '../tensor'; - -export const conv2DBackpropInputGradConfig: GradConfig = { - kernelName: Conv2DBackpropInput, - inputsToSave: ['dy', 'filter'], - gradFunc: (ddx: Tensor4D, saved: Tensor[], attrs: NamedAttrMap) => { - const [dy, filter] = saved as [Tensor4D, Tensor4D]; - - const {strides, pad, dataFormat, dimRoundingMode} = - attrs as unknown as Conv2DBackpropInputAttrs; - - return { - dy: () => conv2d( - ddx, filter, strides, pad, dataFormat, 1 /* dilations */, - dimRoundingMode), - filter: () => conv2DBackpropFilter( - ddx, dy, filter.shape, strides, pad, dataFormat, dimRoundingMode) - }; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/Conv2D_grad.ts b/tfjs-master/tfjs-core/src/gradients/Conv2D_grad.ts deleted file mode 100644 index 1c4231c0a..000000000 --- a/tfjs-master/tfjs-core/src/gradients/Conv2D_grad.ts +++ /dev/null @@ -1,45 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {Conv2D, Conv2DAttrs} from '../kernel_names'; -import {GradConfig, NamedAttrMap} from '../kernel_registry'; -import {conv2DBackpropFilter} from '../ops/conv2d_backprop_filter'; -import {conv2DBackpropInput} from '../ops/conv2d_backprop_input'; -import * as conv_util from '../ops/conv_util'; -import {Tensor, Tensor4D} from '../tensor'; -import * as util from '../util'; - -export const conv2DGradConfig: GradConfig = { - kernelName: Conv2D, - inputsToSave: ['x', 'filter'], - gradFunc: (dy: Tensor4D, saved: Tensor[], attrs: NamedAttrMap) => { - const [x4D, $filter] = saved as [Tensor4D, Tensor4D]; - const {dilations, strides, pad, dataFormat} = - attrs as unknown as Conv2DAttrs; - - util.assert( - conv_util.tupleValuesAreOne(dilations), - () => 'Error in gradient of conv2D: dilation rates greater than 1 ' + - `are not yet supported in gradients. Got dilations '${dilations}'`); - - return { - x: () => - conv2DBackpropInput(x4D.shape, dy, $filter, strides, pad, dataFormat), - filter: () => - conv2DBackpropFilter(x4D, dy, $filter.shape, strides, pad, dataFormat) - }; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/Conv3D_grad.ts b/tfjs-master/tfjs-core/src/gradients/Conv3D_grad.ts deleted file mode 100644 index 9fa5fe97d..000000000 --- a/tfjs-master/tfjs-core/src/gradients/Conv3D_grad.ts +++ /dev/null @@ -1,45 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {Conv3D, Conv3DAttrs} from '../kernel_names'; -import {GradConfig, NamedAttrMap} from '../kernel_registry'; -import {conv3DBackpropFilter} from '../ops/conv3d_backprop_filter'; -import {conv3DBackpropInput} from '../ops/conv3d_backprop_input'; -import {tupleValuesAreOne} from '../ops/conv_util'; -import {Tensor, Tensor5D} from '../tensor'; -import * as util from '../util'; - -export const conv3DGradConfig: GradConfig = { - kernelName: Conv3D, - inputsToSave: ['x', 'filter'], - gradFunc: (dy: Tensor5D, saved: Tensor[], attrs: NamedAttrMap) => { - const {dilations, strides, pad} = attrs as unknown as Conv3DAttrs; - util.assert( - tupleValuesAreOne(dilations), - () => - 'Error in gradient of conv3D: dilation rates greater than 1 are ' + - `not yet supported in gradients. Got dilations '${dilations}'`); - - const [x5D, $filter] = saved; - - return { - x: () => conv3DBackpropInput( - (x5D as Tensor5D).shape, dy, $filter as Tensor5D, strides, pad), - filter: () => conv3DBackpropFilter( - x5D as Tensor5D, dy, ($filter as Tensor5D).shape, strides, pad) - }; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/Cos_grad.ts b/tfjs-master/tfjs-core/src/gradients/Cos_grad.ts deleted file mode 100644 index bde878ce4..000000000 --- a/tfjs-master/tfjs-core/src/gradients/Cos_grad.ts +++ /dev/null @@ -1,34 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Cos} from '../kernel_names'; -import {GradConfig} from '../kernel_registry'; -import {cast} from '../ops/cast'; -import {mul} from '../ops/mul'; -import {neg} from '../ops/neg'; -import {sin} from '../ops/sin'; -import {Tensor} from '../tensor'; - -export const cosGradConfig: GradConfig = { - kernelName: Cos, - inputsToSave: ['x'], - gradFunc: (dy: Tensor, saved: Tensor[]) => { - const [x] = saved; - - return {x: () => mul(neg(sin(cast(x, 'float32'))), dy)}; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/Cosh_grad.ts b/tfjs-master/tfjs-core/src/gradients/Cosh_grad.ts deleted file mode 100644 index ea6f9ec66..000000000 --- a/tfjs-master/tfjs-core/src/gradients/Cosh_grad.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Cosh} from '../kernel_names'; -import {GradConfig} from '../kernel_registry'; -import {cast} from '../ops/cast'; -import {mul} from '../ops/mul'; -import {sinh} from '../ops/sinh'; -import {Tensor} from '../tensor'; - -export const coshGradConfig: GradConfig = { - kernelName: Cosh, - inputsToSave: ['x'], - gradFunc: (dy: Tensor, saved: Tensor[]) => { - const [x] = saved; - - return {x: () => mul(sinh(cast(x, 'float32')), dy)}; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/Cumsum_grad.ts b/tfjs-master/tfjs-core/src/gradients/Cumsum_grad.ts deleted file mode 100644 index bcb386e03..000000000 --- a/tfjs-master/tfjs-core/src/gradients/Cumsum_grad.ts +++ /dev/null @@ -1,47 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Cumsum, CumsumAttrs} from '../kernel_names'; -import {GradConfig, NamedAttrMap} from '../kernel_registry'; -import {getAxesPermutation} from '../ops/axis_util'; -import {cumsum} from '../ops/cumsum'; -import {transpose} from '../ops/transpose'; -import {Tensor} from '../tensor'; - -export const cumsumGradConfig: GradConfig = { - kernelName: Cumsum, - inputsToSave: ['x'], - gradFunc: (dy: Tensor, saved: Tensor[], attrs: NamedAttrMap) => { - const [x] = saved; - const {axis, exclusive, reverse}: CumsumAttrs = - attrs as unknown as CumsumAttrs; - - return { - x: () => { - const permutation = getAxesPermutation([axis], x.rank); - - let out = cumsum(dy, axis, exclusive, !reverse); - - if (permutation != null) { - out = transpose(out, permutation); - } - - return out; - } - }; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/DepthwiseConv2dNative_grad.ts b/tfjs-master/tfjs-core/src/gradients/DepthwiseConv2dNative_grad.ts deleted file mode 100644 index 957690663..000000000 --- a/tfjs-master/tfjs-core/src/gradients/DepthwiseConv2dNative_grad.ts +++ /dev/null @@ -1,71 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {DepthwiseConv2dNative, DepthwiseConv2dNativeAttrs} from '../kernel_names'; -import {GradConfig, NamedAttrMap} from '../kernel_registry'; -import * as conv_util from '../ops/conv_util'; -import {depthwiseConv2dNativeBackpropFilter} from '../ops/depthwise_conv2d_native_backprop_filter'; -import {depthwiseConv2dNativeBackpropInput} from '../ops/depthwise_conv2d_native_backprop_input'; -import {Tensor, Tensor4D} from '../tensor'; -import * as util from '../util'; - -export const depthwiseConv2dNativeGradConfig: GradConfig = { - kernelName: DepthwiseConv2dNative, - inputsToSave: ['x', 'filter'], - gradFunc: (dy: Tensor4D, saved: Tensor[], attrs: NamedAttrMap) => { - const {dilations, strides, pad, dimRoundingMode} = - attrs as unknown as DepthwiseConv2dNativeAttrs; - const $dilations = dilations == null ? [1, 1] as[number,number] : dilations; - - util.assert( - conv_util.tupleValuesAreOne($dilations), - () => 'Error in gradient of depthwiseConv2dNative: dilation rates ' + - `greater than 1 are not yet supported. Got dilations ` + - `'${$dilations}'`); - - const [x, filter] = saved as [Tensor4D, Tensor4D]; - - util.assert( - x.rank === 4, - () => `Error in gradient of depthwiseConv2dNative: input must be ` + - `rank 4, but got rank ${x.rank}.`); - util.assert( - filter.rank === 4, - () => `Error in gradient of depthwiseConv2dNative: filter must be ` + - `rank 4, but got rank ${filter.rank}.`); - util.assert( - x.shape[3] === filter.shape[2], - () => `Error in gradient of depthwiseConv2d: number of input ` + - `channels (${x.shape[3]}) must match the inChannels dimension ` + - `in filter ${filter.shape[2]}.`); - - util.assert( - conv_util.eitherStridesOrDilationsAreOne(strides, $dilations), - () => 'Error in gradient of depthwiseConv2d: Either strides or ' + - `dilations must be 1. Got strides ${strides} and dilations ` + - `'${$dilations}'.`); - - conv_util.checkPadOnDimRoundingMode( - 'depthwiseConv2d', pad, dimRoundingMode); - - return { - x: () => depthwiseConv2dNativeBackpropInput( - x.shape, dy, filter, strides, pad, $dilations, dimRoundingMode), - filter: () => depthwiseConv2dNativeBackpropFilter( - x, dy, filter.shape, strides, pad, $dilations, dimRoundingMode), - }; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/Dilation2D_grad.ts b/tfjs-master/tfjs-core/src/gradients/Dilation2D_grad.ts deleted file mode 100644 index 9352a8577..000000000 --- a/tfjs-master/tfjs-core/src/gradients/Dilation2D_grad.ts +++ /dev/null @@ -1,42 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {ENGINE} from '../engine'; -import {Dilation2D, Dilation2DBackpropFilter, Dilation2DBackpropFilterInputs, Dilation2DBackpropInput, Dilation2DBackpropInputInputs} from '../kernel_names'; -import {GradConfig} from '../kernel_registry'; -import {NamedAttrMap} from '../kernel_registry'; -import {Tensor, Tensor3D, Tensor4D} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; - -export const dilation2dGradConfig: GradConfig = { - kernelName: Dilation2D, - inputsToSave: ['x', 'filter'], - gradFunc: (dy: Tensor4D, saved: Tensor[], attrs: NamedAttrMap) => { - const [x, filter] = saved as [Tensor4D, Tensor3D]; - - const inputInputs: Dilation2DBackpropInputInputs = {x, filter, dy}; - const filterInputs: Dilation2DBackpropFilterInputs = {x, filter, dy}; - - return { - x: () => ENGINE.runKernel( - Dilation2DBackpropInput, - inputInputs as unknown as NamedTensorMap, attrs), - filter: () => ENGINE.runKernel( - Dilation2DBackpropFilter, - filterInputs as unknown as NamedTensorMap, attrs) - }; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/Elu_grad.ts b/tfjs-master/tfjs-core/src/gradients/Elu_grad.ts deleted file mode 100644 index 159684a36..000000000 --- a/tfjs-master/tfjs-core/src/gradients/Elu_grad.ts +++ /dev/null @@ -1,34 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {ENGINE} from '../engine'; -import {Elu, EluGrad, EluGradInputs} from '../kernel_names'; -import {GradConfig} from '../kernel_registry'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; - -export const eluGradConfig: GradConfig = { - kernelName: Elu, - outputsToSave: [true], - gradFunc: (dy: Tensor, saved: Tensor[]) => { - const [y] = saved; - - const inputs: EluGradInputs = {dy, y}; - - return {x: () => ENGINE.runKernel(EluGrad, - inputs as unknown as NamedTensorMap)}; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/Erf_grad.ts b/tfjs-master/tfjs-core/src/gradients/Erf_grad.ts deleted file mode 100644 index dcb11ecf5..000000000 --- a/tfjs-master/tfjs-core/src/gradients/Erf_grad.ts +++ /dev/null @@ -1,34 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Erf} from '../kernel_names'; -import {GradConfig} from '../kernel_registry'; -import {exp} from '../ops/exp'; -import {mul} from '../ops/mul'; -import {neg} from '../ops/neg'; -import {square} from '../ops/square'; -import {Tensor} from '../tensor'; - -export const erfGradConfig: GradConfig = { - kernelName: Erf, - inputsToSave: ['x'], - gradFunc: (dy: Tensor, saved: Tensor[]) => { - const [x] = saved; - const a = mul(exp(neg(square(x))), 2 / Math.sqrt(Math.PI)); - return {x: () => mul(dy, a)}; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/Exp_grad.ts b/tfjs-master/tfjs-core/src/gradients/Exp_grad.ts deleted file mode 100644 index 44c1acf66..000000000 --- a/tfjs-master/tfjs-core/src/gradients/Exp_grad.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Exp} from '../kernel_names'; -import {GradConfig} from '../kernel_registry'; -import {mul} from '../ops/mul'; -import {Tensor} from '../tensor'; - -export const expGradConfig: GradConfig = { - kernelName: Exp, - outputsToSave: [true], - gradFunc: (dy: Tensor, saved: Tensor[]) => { - const [y] = saved; - return {x: () => mul(dy, y)}; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/ExpandDims_grad.ts b/tfjs-master/tfjs-core/src/gradients/ExpandDims_grad.ts deleted file mode 100644 index 5dd7ca9e3..000000000 --- a/tfjs-master/tfjs-core/src/gradients/ExpandDims_grad.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ExpandDims} from '../kernel_names'; -import {GradConfig} from '../kernel_registry'; -import {reshape} from '../ops/reshape'; -import {Tensor} from '../tensor'; - -export const expandDimsGradConfig: GradConfig = { - kernelName: ExpandDims, - inputsToSave: ['input'], - gradFunc: (dy: Tensor, saved: Tensor[]) => { - const [input] = saved; - return {input: () => reshape(dy, input.shape)}; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/Expm1_grad.ts b/tfjs-master/tfjs-core/src/gradients/Expm1_grad.ts deleted file mode 100644 index 3bf6e91f6..000000000 --- a/tfjs-master/tfjs-core/src/gradients/Expm1_grad.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Expm1} from '../kernel_names'; -import {GradConfig} from '../kernel_registry'; -import {exp} from '../ops/exp'; -import {mul} from '../ops/mul'; -import {Tensor} from '../tensor'; - -export const expm1GradConfig: GradConfig = { - kernelName: Expm1, - inputsToSave: ['x'], - gradFunc: (dy: Tensor, saved: Tensor[]) => { - const [x] = saved; - return {x: () => mul(dy, exp(x))}; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/FloorDiv_grad.ts b/tfjs-master/tfjs-core/src/gradients/FloorDiv_grad.ts deleted file mode 100644 index 0b4670882..000000000 --- a/tfjs-master/tfjs-core/src/gradients/FloorDiv_grad.ts +++ /dev/null @@ -1,56 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {FloorDiv} from '../kernel_names'; -import {GradConfig} from '../kernel_registry'; -import {assertAndGetBroadcastShape, getReductionAxes} from '../ops/broadcast_util'; -import {cast} from '../ops/cast'; -import {div} from '../ops/div'; -import {mul} from '../ops/mul'; -import {neg} from '../ops/neg'; -import {reshape} from '../ops/reshape'; -import {square} from '../ops/square'; -import {sum} from '../ops/sum'; -import {Tensor} from '../tensor'; - -export const floorDivGradConfig: GradConfig = { - kernelName: FloorDiv, - inputsToSave: ['a', 'b'], - gradFunc: (dy: Tensor, saved: Tensor[]) => { - const [a, b] = saved; - const outShape = assertAndGetBroadcastShape(a.shape, b.shape); - - const derA = () => { - const res = div(dy, cast(b, 'float32')); - const reduceAxes = getReductionAxes(a.shape, outShape); - if (reduceAxes.length > 0) { - return reshape(sum(res, reduceAxes), a.shape); - } - return res; - }; - const derB = () => { - let res = mul(dy, cast(a, 'float32')); - const reduceAxes = getReductionAxes(b.shape, outShape); - if (reduceAxes.length > 0) { - res = reshape(sum(res, reduceAxes), b.shape); - } - const tmp = square(b); - return neg(div(res, cast(tmp, 'float32'))); - }; - return {a: derA, b: derB}; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/Floor_grad.ts b/tfjs-master/tfjs-core/src/gradients/Floor_grad.ts deleted file mode 100644 index 454a8967c..000000000 --- a/tfjs-master/tfjs-core/src/gradients/Floor_grad.ts +++ /dev/null @@ -1,28 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Floor} from '../kernel_names'; -import {GradConfig} from '../kernel_registry'; -import {zerosLike} from '../ops/zeros_like'; -import {Tensor} from '../tensor'; - -export const floorGradConfig: GradConfig = { - kernelName: Floor, - gradFunc: (dy: Tensor) => { - return {x: () => zerosLike(dy)}; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/FusedBatchNorm_grad.ts b/tfjs-master/tfjs-core/src/gradients/FusedBatchNorm_grad.ts deleted file mode 100644 index a58f535a4..000000000 --- a/tfjs-master/tfjs-core/src/gradients/FusedBatchNorm_grad.ts +++ /dev/null @@ -1,110 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {FusedBatchNorm, FusedBatchNormAttrs} from '../kernel_names'; -import {GradConfig, NamedAttrMap} from '../kernel_registry'; -import {add} from '../ops/add'; -import {getReductionAxes} from '../ops/broadcast_util'; -import {mul} from '../ops/mul'; -import {reshape} from '../ops/reshape'; -import {rsqrt} from '../ops/rsqrt'; -import {scalar} from '../ops/scalar'; -import {sub} from '../ops/sub'; -import {sum} from '../ops/sum'; -import {tile} from '../ops/tile'; -import {Tensor} from '../tensor'; -import {Rank, ShapeMap} from '../types'; - -export const fusedBatchNormGradConfig: GradConfig = { - kernelName: FusedBatchNorm, - inputsToSave: ['x', 'mean', 'variance', 'scale'], - gradFunc: ( - dy: Tensor, saved: Tensor[], attrs: NamedAttrMap) => { - const {varianceEpsilon} = attrs as unknown as FusedBatchNormAttrs; - const [x, mean, variance, scale] = saved; - - const scaleValue = scale == null ? scalar(1) : scale; - const reductionAxes = getReductionAxes(mean.shape, x.shape); - const tileShape: number[] = []; - if (mean.rank === 1) { - for (let i = 0; i < x.shape.length - 1; ++i) { - tileShape.push(x.shape[i]); - } - tileShape.push(1); - } - - const xMinusMean = sub(x, mean); - const dyTimesScaleValue = mul(dy, scaleValue); - const oneOverSqrtVariance = rsqrt(add(variance, scalar(varianceEpsilon))); - const minusHalfRCube = mul( - mul(mul(oneOverSqrtVariance, oneOverSqrtVariance), oneOverSqrtVariance), - scalar(-0.5)); - - const derX = () => { - if (mean.rank === 1) { - return reshape( - mul(mul(dy, - tile( - reshape(oneOverSqrtVariance, [1, 1, 1, mean.shape[0]]), - tileShape)), - scaleValue), - x.shape); - } else { - return reshape(mul(mul(dy, oneOverSqrtVariance), scaleValue), x.shape); - } - }; - const derMean = () => { - let meanDer = - mul(mul(oneOverSqrtVariance, scalar(-1)), dyTimesScaleValue); - if (mean.rank === 1) { - meanDer = sum(meanDer, reductionAxes); - } - return reshape(meanDer, mean.shape as ShapeMap[R]); - }; - const derVariance = () => { - let varianceDer = mul(mul(minusHalfRCube, xMinusMean), dyTimesScaleValue); - - if (mean.rank === 1) { - varianceDer = sum(varianceDer, reductionAxes); - } - return reshape(varianceDer, mean.shape as ShapeMap[R]); - }; - const derScale = () => { - const xMinusMean2TimesRsqrt = mul(xMinusMean, oneOverSqrtVariance); - - let scaleDer = mul(dy, xMinusMean2TimesRsqrt); - if (mean.rank === 1) { - scaleDer = sum(scaleDer, reductionAxes); - } - return reshape(scaleDer, mean.shape as ShapeMap[R]); - }; - const derOffset = () => { - let offsetDer = dy; - if (mean.rank === 1) { - offsetDer = sum(offsetDer, reductionAxes); - } - return reshape(offsetDer, mean.shape as ShapeMap[R]); - }; - - return { - x: derX, - mean: derMean, - variance: derVariance, - scale: derScale, - offset: derOffset - }; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/GatherV2_grad.ts b/tfjs-master/tfjs-core/src/gradients/GatherV2_grad.ts deleted file mode 100644 index 35d7e19f8..000000000 --- a/tfjs-master/tfjs-core/src/gradients/GatherV2_grad.ts +++ /dev/null @@ -1,101 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {GatherV2, GatherV2Attrs} from '../kernel_names'; -import {GradConfig, NamedAttrMap} from '../kernel_registry'; -import {getUndoAxesPermutation} from '../ops/axis_util'; -import {reshape} from '../ops/reshape'; -import {stack} from '../ops/stack'; -import {transpose} from '../ops/transpose'; -import {unsortedSegmentSum} from '../ops/unsorted_segment_sum'; -import {Tensor, Tensor1D} from '../tensor'; -import {parseAxisParam} from '../util'; - -export const gatherGradConfig: GradConfig = { - kernelName: GatherV2, - inputsToSave: ['x', 'indices'], - gradFunc: (dy: Tensor, saved: Tensor[], attrs: NamedAttrMap) => { - const [x, indices] = saved; - const {axis, batchDims} = attrs as unknown as GatherV2Attrs; - - const parsedAxis = parseAxisParam(axis, x.shape)[0]; - - const derXBatch = (x: Tensor, indices: Tensor, dy: Tensor) => { - return (): Tensor => { - const paramsShape = x.shape; - const indicesSize = indices.size; - - const outerShape = paramsShape.slice(0, parsedAxis); - const outerDims = outerShape.length; - const innerShape = paramsShape.slice(axis, paramsShape.length).slice(1); - const innerDims = innerShape.length; - - const outerAxesIndices = arrayRange(0, outerDims); - const innerAxesIndices = - arrayRange(outerDims + 1, outerDims + 1 + innerDims); - - const valuesShape = arrayConcat([outerShape, [indicesSize], - innerShape]); - - const values = reshape(dy, valuesShape); - const reshapedIndices = reshape(indices, [indicesSize]); - - const transposeDims = - arrayConcat([[outerDims], outerAxesIndices, innerAxesIndices]); - const valuesTranspose = transpose(values, transposeDims); - let paramsGrad = unsortedSegmentSum( - valuesTranspose, reshapedIndices as Tensor1D, x.shape[parsedAxis]); - const invertTransposeDims = getUndoAxesPermutation(transposeDims); - paramsGrad = transpose(paramsGrad, invertTransposeDims); - return paramsGrad; - }; - }; - - if (batchDims === 1) { - const batchSize = x.shape[0]; - const xBatch = x.split(batchSize, 0); - const derXBatched = () => { - const stacked = stack( - xBatch.map((x, i) => { - return derXBatch(x, indices.slice(i,1), dy.slice(i,1))(); - })); - return stacked.reshape(x.shape); - }; - return {x: derXBatched, indices: () => indices}; - } else { - return {x: derXBatch(x, indices, dy), indices: () => indices}; - } - } -}; - -function arrayRange(start: number, stop: number): number[] { - const result = []; - for (let i = start; i < stop; ++i) { - result.push(i); - } - return result; -} - -function arrayConcat(arrays: number[][]): number[] { - const result = []; - for (let i = 0; i < arrays.length; ++i) { - for (let j = 0; j < arrays[i].length; ++j) { - result.push(arrays[i][j]); - } - } - return result; -} diff --git a/tfjs-master/tfjs-core/src/gradients/GreaterEqual_grad.ts b/tfjs-master/tfjs-core/src/gradients/GreaterEqual_grad.ts deleted file mode 100644 index abb512efd..000000000 --- a/tfjs-master/tfjs-core/src/gradients/GreaterEqual_grad.ts +++ /dev/null @@ -1,29 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {GreaterEqual} from '../kernel_names'; -import {GradConfig} from '../kernel_registry'; -import {zerosLike} from '../ops/zeros_like'; -import {Tensor} from '../tensor'; - -export const greaterEqualGradConfig: GradConfig = { - kernelName: GreaterEqual, - inputsToSave: ['a', 'b'], - gradFunc: (dy: Tensor, saved: Tensor[]) => { - const [a, b] = saved; - return {a: () => zerosLike(a), b: () => zerosLike(b)}; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/Identity_grad.ts b/tfjs-master/tfjs-core/src/gradients/Identity_grad.ts deleted file mode 100644 index dc2518921..000000000 --- a/tfjs-master/tfjs-core/src/gradients/Identity_grad.ts +++ /dev/null @@ -1,28 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Identity} from '../kernel_names'; -import {GradConfig} from '../kernel_registry'; -import {cast} from '../ops/cast'; -import {Tensor} from '../tensor'; - -export const identityGradConfig: GradConfig = { - kernelName: Identity, - gradFunc: (dy: Tensor) => { - return {x: () => cast(dy, 'float32')}; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/IsFinite_grad.ts b/tfjs-master/tfjs-core/src/gradients/IsFinite_grad.ts deleted file mode 100644 index fa7a40416..000000000 --- a/tfjs-master/tfjs-core/src/gradients/IsFinite_grad.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {IsFinite} from '../kernel_names'; -import {GradConfig} from '../kernel_registry'; -import {zerosLike} from '../ops/zeros_like'; -import {Tensor} from '../tensor'; - -export const isFiniteGradConfig: GradConfig = { - kernelName: IsFinite, - gradFunc: (dy: Tensor) => { - // TODO(nsthorat): Let gradients be null for cases where we want to stop - // backpropgation. - return {x: () => zerosLike(dy)}; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/IsInf_grad.ts b/tfjs-master/tfjs-core/src/gradients/IsInf_grad.ts deleted file mode 100644 index e56b750ef..000000000 --- a/tfjs-master/tfjs-core/src/gradients/IsInf_grad.ts +++ /dev/null @@ -1,31 +0,0 @@ - -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {IsInf} from '../kernel_names'; -import {GradConfig} from '../kernel_registry'; -import {zerosLike} from '../ops/zeros_like'; -import {Tensor} from '../tensor'; - -export const isInfGradConfig: GradConfig = { - kernelName: IsInf, - gradFunc: (dy: Tensor) => { - // TODO(nsthorat): Let gradients be null for cases where we want to stop - // backpropgation. - return {x: () => zerosLike(dy)}; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/IsNan_grad.ts b/tfjs-master/tfjs-core/src/gradients/IsNan_grad.ts deleted file mode 100644 index c5c5bb9e1..000000000 --- a/tfjs-master/tfjs-core/src/gradients/IsNan_grad.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {IsNan} from '../kernel_names'; -import {GradConfig} from '../kernel_registry'; -import {zerosLike} from '../ops/zeros_like'; -import {Tensor} from '../tensor'; - -export const isNanGradConfig: GradConfig = { - kernelName: IsNan, - gradFunc: (dy: Tensor) => { - // TODO(nsthorat): Let gradients be null for cases where we want to stop - // backpropgation. - return {x: () => zerosLike(dy)}; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/LRN_grad.ts b/tfjs-master/tfjs-core/src/gradients/LRN_grad.ts deleted file mode 100644 index bbb106cf8..000000000 --- a/tfjs-master/tfjs-core/src/gradients/LRN_grad.ts +++ /dev/null @@ -1,35 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {LRN, LRNAttrs} from '../kernel_names'; -import {GradConfig, NamedAttrMap} from '../kernel_registry'; -import {localResponseNormalizationBackprop} from '../ops/local_response_normalization_backprop'; -import {Tensor, Tensor4D} from '../tensor'; - -export const lrnGradConfig: GradConfig = { - kernelName: LRN, - inputsToSave: ['x'], - outputsToSave: [true], - gradFunc: (dy: Tensor4D, saved: Tensor[], attrs: NamedAttrMap) => { - const [x, y] = saved as [Tensor4D, Tensor4D]; - const {depthRadius, bias, alpha, beta} = attrs as unknown as LRNAttrs; - - return { - x: () => localResponseNormalizationBackprop( - x, y, dy, depthRadius, bias, alpha, beta) - }; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/LeakyRelu_grad.ts b/tfjs-master/tfjs-core/src/gradients/LeakyRelu_grad.ts deleted file mode 100644 index 99e6170e6..000000000 --- a/tfjs-master/tfjs-core/src/gradients/LeakyRelu_grad.ts +++ /dev/null @@ -1,36 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {LeakyRelu, LeakyReluAttrs} from '../kernel_names'; -import {GradConfig, NamedAttrMap} from '../kernel_registry'; -import {greater} from '../ops/greater'; -import {mul} from '../ops/mul'; -import {where} from '../ops/where'; -import {Tensor} from '../tensor'; - -export const leakyReluGradConfig: GradConfig = { - kernelName: LeakyRelu, - inputsToSave: ['x'], - gradFunc: (dy: Tensor, saved: Tensor[], attrs: NamedAttrMap) => { - const [x] = saved; - const {alpha} = attrs as unknown as LeakyReluAttrs; - const mask = greater(x, 0); - - // Returns `gradients * (features > 0) + alpha * gradients * (features <= - // 0)`. - return {x: () => where(mask, dy, mul(dy, alpha))}; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/Log1p_grad.ts b/tfjs-master/tfjs-core/src/gradients/Log1p_grad.ts deleted file mode 100644 index 323b6a04a..000000000 --- a/tfjs-master/tfjs-core/src/gradients/Log1p_grad.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Log1p} from '../kernel_names'; -import {GradConfig} from '../kernel_registry'; -import {add} from '../ops/add'; -import {div} from '../ops/div'; -import {Tensor} from '../tensor'; - -export const log1pGradConfig: GradConfig = { - kernelName: Log1p, - inputsToSave: ['x'], - gradFunc: (dy: Tensor, saved: Tensor[]) => { - const [x] = saved; - return {x: () => div(dy, add(x, 1))}; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/LogSoftmax_grad.ts b/tfjs-master/tfjs-core/src/gradients/LogSoftmax_grad.ts deleted file mode 100644 index 070f1af3b..000000000 --- a/tfjs-master/tfjs-core/src/gradients/LogSoftmax_grad.ts +++ /dev/null @@ -1,41 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {LogSoftmax, LogSoftmaxAttrs} from '../kernel_names'; -import {GradConfig, NamedAttrMap} from '../kernel_registry'; -import {exp} from '../ops/exp'; -import {mul} from '../ops/mul'; -import {sub} from '../ops/sub'; -import {sum} from '../ops/sum'; -import {Tensor} from '../tensor'; - -export const logSoftmaxGradConfig: GradConfig = { - kernelName: LogSoftmax, - inputsToSave: [], - outputsToSave: [true], - gradFunc: (dy: Tensor, saved: Tensor[], attrs: NamedAttrMap) => { - const [value] = saved; - const {axis} = attrs as unknown as LogSoftmaxAttrs; - return { - logits: () => { - const keepDims = true; - const softmax = exp(value); - return sub(dy, mul(sum(dy, axis, keepDims), softmax)); - } - }; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/Log_grad.ts b/tfjs-master/tfjs-core/src/gradients/Log_grad.ts deleted file mode 100644 index 090acb3ee..000000000 --- a/tfjs-master/tfjs-core/src/gradients/Log_grad.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Log} from '../kernel_names'; -import {GradConfig} from '../kernel_registry'; -import {cast} from '../ops/cast'; -import {div} from '../ops/div'; -import {Tensor} from '../tensor'; - -export const logGradConfig: GradConfig = { - kernelName: Log, - inputsToSave: ['x'], - gradFunc: (dy: Tensor, saved: Tensor[]) => { - const [x] = saved; - return {x: () => div(dy, cast(x, 'float32'))}; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/MaxPool3D_grad.ts b/tfjs-master/tfjs-core/src/gradients/MaxPool3D_grad.ts deleted file mode 100644 index 8cd9b49e3..000000000 --- a/tfjs-master/tfjs-core/src/gradients/MaxPool3D_grad.ts +++ /dev/null @@ -1,37 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {MaxPool3D, MaxPool3DAttrs} from '../kernel_names'; -import {GradConfig, NamedAttrMap} from '../kernel_registry'; -import {maxPool3dGrad} from '../ops/max_pool_3d_grad'; -import {Tensor, Tensor5D} from '../tensor'; - -export const maxPool3DGradConfig: GradConfig = { - kernelName: MaxPool3D, - inputsToSave: ['x'], - outputsToSave: [true], - gradFunc: (dy: Tensor, saved: Tensor[], attrs: NamedAttrMap) => { - const [x, y] = saved as [Tensor5D, Tensor5D]; - const {filterSize, strides, pad, dimRoundingMode} = - attrs as unknown as MaxPool3DAttrs; - - return { - x: () => maxPool3dGrad( - dy as Tensor5D, x, y, filterSize, strides, pad, dimRoundingMode) - }; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/MaxPool_grad.ts b/tfjs-master/tfjs-core/src/gradients/MaxPool_grad.ts deleted file mode 100644 index b391055fc..000000000 --- a/tfjs-master/tfjs-core/src/gradients/MaxPool_grad.ts +++ /dev/null @@ -1,35 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {MaxPool, MaxPoolAttrs} from '../kernel_names'; -import {GradConfig, NamedAttrMap} from '../kernel_registry'; -import {maxPoolGrad} from '../ops/max_pool_grad'; -import {Tensor, Tensor4D} from '../tensor'; - -export const maxPoolGradConfig: GradConfig = { - kernelName: MaxPool, - inputsToSave: ['x'], - outputsToSave: [true], - gradFunc: (dy: Tensor, saved: Tensor[], attrs: NamedAttrMap) => { - const [x, y] = saved as [Tensor4D, Tensor4D]; - const {filterSize, strides, pad} = attrs as unknown as MaxPoolAttrs; - - return { - x: () => maxPoolGrad(dy as Tensor4D, x, y, filterSize, strides, pad) - }; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/Max_grad.ts b/tfjs-master/tfjs-core/src/gradients/Max_grad.ts deleted file mode 100644 index 78db7f94b..000000000 --- a/tfjs-master/tfjs-core/src/gradients/Max_grad.ts +++ /dev/null @@ -1,42 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Max, MaxAttrs} from '../kernel_names'; -import {GradConfig, NamedAttrMap} from '../kernel_registry'; -import {Tensor} from '../tensor'; -import * as util from '../util'; - -import {gradForMinAndMax} from './min_max_grad_util'; - -export const maxGradConfig: GradConfig = { - kernelName: Max, - inputsToSave: ['x'], - outputsToSave: [true], - gradFunc: (dy: Tensor, saved: Tensor[], attrs: NamedAttrMap) => { - const maxAttrs: MaxAttrs = attrs as unknown as MaxAttrs; - const {reductionIndices} = maxAttrs; - const x = saved[0]; - const y = saved[1]; - const origAxes = util.parseAxisParam(reductionIndices, x.shape); - const maxGrad = gradForMinAndMax(dy, y, x, origAxes); - return { - x: () => { - return maxGrad['x'](); - } - }; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/Maximum_grad.ts b/tfjs-master/tfjs-core/src/gradients/Maximum_grad.ts deleted file mode 100644 index bac9c34ae..000000000 --- a/tfjs-master/tfjs-core/src/gradients/Maximum_grad.ts +++ /dev/null @@ -1,35 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Maximum} from '../kernel_names'; -import {GradConfig} from '../kernel_registry'; -import {cast} from '../ops/cast'; -import {greaterEqual} from '../ops/greater_equal'; -import {less} from '../ops/less'; -import {mul} from '../ops/mul'; -import {Tensor} from '../tensor'; - -export const maximumGradConfig: GradConfig = { - kernelName: Maximum, - inputsToSave: ['a', 'b'], - gradFunc: (dy: Tensor, saved: Tensor[]) => { - const [a, b] = saved; - const derA = () => mul(dy, cast(greaterEqual(a, b), 'float32')); - const derB = () => mul(dy, cast(less(a, b), 'float32')); - return {a: derA, b: derB}; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/Mean_grad.ts b/tfjs-master/tfjs-core/src/gradients/Mean_grad.ts deleted file mode 100644 index 108afa6af..000000000 --- a/tfjs-master/tfjs-core/src/gradients/Mean_grad.ts +++ /dev/null @@ -1,51 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Mean, MeanAttrs} from '../kernel_names'; -import {GradConfig, NamedAttrMap} from '../kernel_registry'; -import {computeOutAndReduceShapes} from '../ops/axis_util'; -import {div} from '../ops/div'; -import {mul} from '../ops/mul'; -import {ones} from '../ops/ones'; -import {reshape} from '../ops/reshape'; -import {Tensor} from '../tensor'; -import * as util from '../util'; - -export const meanGradConfig: GradConfig = { - kernelName: Mean, - inputsToSave: ['x'], - gradFunc: (dy: Tensor, saved: Tensor[], attrs: NamedAttrMap) => { - const [x] = saved; - const {axis} = attrs as unknown as MeanAttrs; - const axes = util.parseAxisParam(axis, x.shape); - const shapes = computeOutAndReduceShapes(x.shape, axes); - const reduceShape = shapes[1]; - const reduceSize = util.sizeFromShape(reduceShape); - - const derX = () => { - const expandedDyShape = x.shape.slice(); - axes.forEach(axis => { - expandedDyShape[axis] = 1; - }); - const expandedDy = reshape(dy, expandedDyShape); - const res = div(mul(expandedDy, ones(x.shape, 'float32')), reduceSize); - return res; - }; - - return {x: derX}; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/Min_grad.ts b/tfjs-master/tfjs-core/src/gradients/Min_grad.ts deleted file mode 100644 index 200268ab2..000000000 --- a/tfjs-master/tfjs-core/src/gradients/Min_grad.ts +++ /dev/null @@ -1,41 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Min, MinAttrs} from '../kernel_names'; -import {GradConfig, NamedAttrMap} from '../kernel_registry'; -import {Tensor} from '../tensor'; -import * as util from '../util'; - -import {gradForMinAndMax} from './min_max_grad_util'; - -export const minGradConfig: GradConfig = { - kernelName: Min, - inputsToSave: ['x'], - outputsToSave: [true], - gradFunc: (dy: Tensor, saved: Tensor[], attrs: NamedAttrMap) => { - const minAttrs: MinAttrs = attrs as unknown as MinAttrs; - const {axis} = minAttrs; - const [x, y] = saved; - const origAxes = util.parseAxisParam(axis, x.shape); - const minGrad = gradForMinAndMax(dy, y, x, origAxes); - return { - x: () => { - return minGrad['x'](); - } - }; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/Minimum_grad.ts b/tfjs-master/tfjs-core/src/gradients/Minimum_grad.ts deleted file mode 100644 index 3449a1a7e..000000000 --- a/tfjs-master/tfjs-core/src/gradients/Minimum_grad.ts +++ /dev/null @@ -1,35 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Minimum} from '../kernel_names'; -import {GradConfig} from '../kernel_registry'; -import {cast} from '../ops/cast'; -import {greater} from '../ops/greater'; -import {lessEqual} from '../ops/less_equal'; -import {mul} from '../ops/mul'; -import {Tensor} from '../tensor'; - -export const minimumGradConfig: GradConfig = { - kernelName: Minimum, - inputsToSave: ['a', 'b'], - gradFunc: (dy: Tensor, saved: Tensor[]) => { - const [a, b] = saved; - const derA = () => mul(dy, cast(lessEqual(a, b), 'float32')); - const derB = () => mul(dy, cast(greater(a, b), 'float32')); - return {a: derA, b: derB}; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/MirrorPad_grad.ts b/tfjs-master/tfjs-core/src/gradients/MirrorPad_grad.ts deleted file mode 100644 index 305bf33ed..000000000 --- a/tfjs-master/tfjs-core/src/gradients/MirrorPad_grad.ts +++ /dev/null @@ -1,34 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {MirrorPad, MirrorPadAttrs} from '../kernel_names'; -import {GradConfig, NamedAttrMap} from '../kernel_registry'; -import {slice} from '../ops/slice'; -import {Tensor} from '../tensor'; - -export const mirrorPadGradConfig: GradConfig = { - kernelName: MirrorPad, - inputsToSave: ['x'], - gradFunc: (dy: Tensor, saved: Tensor[], attrs: NamedAttrMap) => { - // Pad introduces values around the original tensor, so the gradient - // slices the original shape out of the gradient. - const x = saved[0]; - const {paddings} = attrs as unknown as MirrorPadAttrs; - const begin = paddings.map(p => p[0]); - return {x: () => slice(dy, begin, x.shape)}; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/Mod_grad.ts b/tfjs-master/tfjs-core/src/gradients/Mod_grad.ts deleted file mode 100644 index 7b50e7752..000000000 --- a/tfjs-master/tfjs-core/src/gradients/Mod_grad.ts +++ /dev/null @@ -1,53 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Mod} from '../kernel_names'; -import {GradConfig} from '../kernel_registry'; -import {assertAndGetBroadcastShape, getReductionAxes} from '../ops/broadcast_util'; -import {div} from '../ops/div'; -import {floor} from '../ops/floor'; -import {mul} from '../ops/mul'; -import {neg} from '../ops/neg'; -import {reshape} from '../ops/reshape'; -import {sum} from '../ops/sum'; -import {Tensor} from '../tensor'; - -export const modGradConfig: GradConfig = { - kernelName: Mod, - inputsToSave: ['a', 'b'], - gradFunc: (dy: Tensor, saved: Tensor[]) => { - const [a, b] = saved; - const outShape = assertAndGetBroadcastShape(a.shape, b.shape); - - const derA = () => { - const reduceAxes = getReductionAxes(a.shape, outShape); - if (reduceAxes.length > 0) { - return reshape(sum(dy, reduceAxes), a.shape); - } - return dy; - }; - const derB = () => { - const res = mul(dy, neg(floor(div(a, b)))); - const reduceAxes = getReductionAxes(b.shape, outShape); - if (reduceAxes.length > 0) { - return reshape(sum(res, reduceAxes), b.shape); - } - return res; - }; - return {a: derA, b: derB}; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/Multiply_grad.ts b/tfjs-master/tfjs-core/src/gradients/Multiply_grad.ts deleted file mode 100644 index 1fcc662b2..000000000 --- a/tfjs-master/tfjs-core/src/gradients/Multiply_grad.ts +++ /dev/null @@ -1,52 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Multiply} from '../kernel_names'; -import {GradConfig} from '../kernel_registry'; -import {assertAndGetBroadcastShape, getReductionAxes} from '../ops/broadcast_util'; -import {cast} from '../ops/cast'; -import {mul} from '../ops/mul'; -import {reshape} from '../ops/reshape'; -import {sum} from '../ops/sum'; -import {Tensor} from '../tensor'; - -export const multiplyGradConfig: GradConfig = { - kernelName: Multiply, - inputsToSave: ['a', 'b'], - gradFunc: (dy: Tensor, saved: Tensor[]) => { - const [a, b] = saved; - const outShape = assertAndGetBroadcastShape(a.shape, b.shape); - - const derA = () => { - const res = mul(dy, cast(b, 'float32')); - const reduceAxes = getReductionAxes(a.shape, outShape); - if (reduceAxes.length > 0) { - return reshape(sum(res, reduceAxes), a.shape); - } - return res; - }; - const derB = () => { - const res = mul(dy, cast(a, 'float32')); - const reduceAxes = getReductionAxes(b.shape, outShape); - if (reduceAxes.length > 0) { - return reshape(sum(res, reduceAxes), b.shape); - } - return res; - }; - return {a: derA, b: derB}; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/Neg_grad.ts b/tfjs-master/tfjs-core/src/gradients/Neg_grad.ts deleted file mode 100644 index 7ae3a9b39..000000000 --- a/tfjs-master/tfjs-core/src/gradients/Neg_grad.ts +++ /dev/null @@ -1,28 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Neg} from '../kernel_names'; -import {GradConfig} from '../kernel_registry'; -import {neg} from '../ops/neg'; -import {Tensor} from '../tensor'; - -export const negGradConfig: GradConfig = { - kernelName: Neg, - gradFunc: (dy: Tensor) => { - return {x: () => neg(dy)}; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/OneHot_grad.ts b/tfjs-master/tfjs-core/src/gradients/OneHot_grad.ts deleted file mode 100644 index 4db5271e8..000000000 --- a/tfjs-master/tfjs-core/src/gradients/OneHot_grad.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {OneHot} from '../kernel_names'; -import {GradConfig} from '../kernel_registry'; -import {zeros} from '../ops/zeros'; -import {Tensor} from '../tensor'; - -export const oneHotGradConfig: GradConfig = { - kernelName: OneHot, - inputsToSave: ['indices'], - gradFunc: (dy: Tensor, saved: Tensor[]) => { - const indices = saved[0]; - return {indices: () => zeros(indices.shape, 'float32')}; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/OnesLike_grad.ts b/tfjs-master/tfjs-core/src/gradients/OnesLike_grad.ts deleted file mode 100644 index 96bfcfceb..000000000 --- a/tfjs-master/tfjs-core/src/gradients/OnesLike_grad.ts +++ /dev/null @@ -1,28 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {OnesLike} from '../kernel_names'; -import {GradConfig} from '../kernel_registry'; -import {zerosLike} from '../ops/zeros_like'; -import {Tensor} from '../tensor'; - -export const onesLikeGradConfig: GradConfig = { - kernelName: OnesLike, - gradFunc: (dy: Tensor) => { - return {x: () => zerosLike(dy)}; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/Pack_grad.ts b/tfjs-master/tfjs-core/src/gradients/Pack_grad.ts deleted file mode 100644 index a5e225c76..000000000 --- a/tfjs-master/tfjs-core/src/gradients/Pack_grad.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Pack, PackAttrs} from '../kernel_names'; -import {GradConfig, NamedAttrMap} from '../kernel_registry'; -import {unstack} from '../ops/unstack'; -import {Tensor} from '../tensor'; - -export const packGradConfig: GradConfig = { - kernelName: Pack, - saveAllInputs: true, - gradFunc: (dy: Tensor, saved: Tensor[], attrs: NamedAttrMap) => { - const {axis} = attrs as unknown as PackAttrs; - const derTensors = unstack(dy, axis); - return derTensors.map(t => () => t) as {}; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/PadV2_grad.ts b/tfjs-master/tfjs-core/src/gradients/PadV2_grad.ts deleted file mode 100644 index 0547c72a0..000000000 --- a/tfjs-master/tfjs-core/src/gradients/PadV2_grad.ts +++ /dev/null @@ -1,34 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {PadV2, PadV2Attrs} from '../kernel_names'; -import {GradConfig, NamedAttrMap} from '../kernel_registry'; -import {slice} from '../ops/slice'; -import {Tensor} from '../tensor'; - -export const padV2GradConfig: GradConfig = { - kernelName: PadV2, - inputsToSave: ['x'], - gradFunc: (dy: Tensor, saved: Tensor[], attrs: NamedAttrMap) => { - // Pad introduces values around the original tensor, so the gradient - // slices the original shape out of the gradient. - const x = saved[0]; - const {paddings} = attrs as unknown as PadV2Attrs; - const begin = paddings.map(p => p[0]); - return {x: () => slice(dy, begin, x.shape)}; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/Pow_grad.ts b/tfjs-master/tfjs-core/src/gradients/Pow_grad.ts deleted file mode 100644 index 90fddcd5c..000000000 --- a/tfjs-master/tfjs-core/src/gradients/Pow_grad.ts +++ /dev/null @@ -1,65 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {Pow} from '../kernel_names'; -import {GradConfig} from '../kernel_registry'; -import * as broadcast_util from '../ops/broadcast_util'; -import {cast} from '../ops/cast'; -import {greater} from '../ops/greater'; -import {log} from '../ops/log'; -import {mul} from '../ops/mul'; -import {pow} from '../ops/pow'; -import {reshape} from '../ops/reshape'; -import {scalar} from '../ops/scalar'; -import {sub} from '../ops/sub'; -import {sum} from '../ops/sum'; -import {where} from '../ops/where'; -import {zerosLike} from '../ops/zeros_like'; -import {Tensor} from '../tensor'; - -export const powGradConfig: GradConfig = { - kernelName: Pow, - inputsToSave: ['a', 'b'], - outputsToSave: [true], - gradFunc: (dy: Tensor, saved: Tensor[]) => { - const [a, b, y] = saved; - const base = a; - const exp = b; - const outShape = - broadcast_util.assertAndGetBroadcastShape(base.shape, exp.shape); - - const derBase = () => { - const expFloat = cast(exp, 'float32'); - let res = mul(dy, mul(expFloat, pow(base, sub(expFloat, scalar(1))))); - const reduceAxes = broadcast_util.getReductionAxes(base.shape, outShape); - if (reduceAxes.length > 0) { - res = sum(res, reduceAxes); - } - return reshape(res, base.shape); - }; - const derExp = () => { - const condition = greater(base, 0); - const logBase = where(condition, log(base), zerosLike(base)); - let res = mul(dy, mul(y, logBase)); - const reduceAxes = broadcast_util.getReductionAxes(exp.shape, outShape); - if (reduceAxes.length > 0) { - res = sum(res, reduceAxes); - } - return reshape(res, exp.shape); - }; - return {a: derBase, b: derExp}; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/Prelu_grad.ts b/tfjs-master/tfjs-core/src/gradients/Prelu_grad.ts deleted file mode 100644 index 2eb18ce53..000000000 --- a/tfjs-master/tfjs-core/src/gradients/Prelu_grad.ts +++ /dev/null @@ -1,47 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {Prelu} from '../kernel_names'; -import {GradConfig} from '../kernel_registry'; -import {getReductionAxes} from '../ops/broadcast_util'; -import {greater} from '../ops/greater'; -import {mul} from '../ops/mul'; -import {reshape} from '../ops/reshape'; -import {sum} from '../ops/sum'; -import {where} from '../ops/where'; -import {zerosLike} from '../ops/zeros_like'; -import {Tensor} from '../tensor'; - -export const preluGradConfig: GradConfig = { - kernelName: Prelu, - inputsToSave: ['x', 'alpha'], - gradFunc: (dy: Tensor, saved: Tensor[]) => { - const [x, alpha] = saved; - const mask = greater(x, 0); - - return { - x: () => where(mask, dy, mul(dy, alpha)), - alpha: () => { - let res = where(mask, zerosLike(dy), mul(dy, x)); - const reduceAxes = getReductionAxes(alpha.shape, dy.shape); - if (reduceAxes.length > 0) { - res = sum(res, reduceAxes); - } - return reshape(res, alpha.shape); - } - }; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/Prod_grad.ts b/tfjs-master/tfjs-core/src/gradients/Prod_grad.ts deleted file mode 100644 index a3fc4a3eb..000000000 --- a/tfjs-master/tfjs-core/src/gradients/Prod_grad.ts +++ /dev/null @@ -1,105 +0,0 @@ -/** - * @license - * Copyright 2022 Google Inc. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {backend_util} from '../base'; -import {Prod, ProdAttrs} from '../kernel_names'; -import {GradConfig, NamedAttrMap} from '../kernel_registry'; -import {cumprod} from '../ops/cumprod'; -import {mul} from '../ops/mul'; -import {reshape} from '../ops/reshape'; -import {transpose} from '../ops/transpose'; -import {Tensor} from '../tensor'; - -// Gradient for product operation on a single axis. -function prodGradFn_(x: Tensor, dy: Tensor, axis: number): Tensor { - // The gradient tensor (dy) has a set of axes removed, so we create re-shaped - // versions (of size 1) for the removed axis; this supports broadcasting over - // those dimensions. - const expandedYShape = x.shape.slice(); - expandedYShape[axis] = 1; - - // The actual gradient computation. - const expandedDy = reshape(dy, expandedYShape); - const xCumProd = cumprod(x, axis, true, false); - const xCumRevProd = cumprod(x, axis, true, true); - const dx = mul(xCumProd, xCumRevProd); - return mul(expandedDy, dx); -} - -// Support gradients when the product is done on many axes at once. -// This done py pushing all the axes on which the product is applied into a -// single axis. -function prodsGradFn_(x: Tensor, dy: Tensor, axis: number[]): Tensor { - // Move all axes for doing prod over to the end of the tensor. - const xRank = x.shape.length; - const finalProdAxis = xRank - axis.length; - const xPermutation = backend_util.getAxesPermutation(axis, xRank); - let permutedX = x; - if (xPermutation != null) { - permutedX = transpose(x, xPermutation); - } - - // Reshape all the prod dimensions into a single one, and do compute prod - // gradients on that. - const newShape = permutedX.shape.slice(); - const removedShape = newShape.splice(xRank - axis.length, axis.length); - const endPartShape = removedShape.reduce((p, c) => p * c, 1); - newShape.push(endPartShape); - const reshapedPermutedX = permutedX.reshape(newShape); - let prodGrad = prodGradFn_(reshapedPermutedX, dy, finalProdAxis); - - // Undo the re-shaping now we have the dx vector, and permute back to - // original axes order. - prodGrad = prodGrad.reshape(permutedX.shape); - if (xPermutation != null) { - const undoPermutation = backend_util.getUndoAxesPermutation(xPermutation); - prodGrad = transpose(prodGrad, undoPermutation); - } - return prodGrad; -} - -// Running example: -// [ -// [ -// [3.0, 4.0], -// [5.0, 6.0], -// [7.0, 8.0] -// ], -// [ -// [3.0, 5.0], -// [0.0, 6.0], -// [5.0, 6.0] -// ] -// ] -// -export const prodGradConfig: GradConfig = { - kernelName: Prod, - inputsToSave: ['x'], - gradFunc: (dy: Tensor|Tensor[], saved: Tensor[], attrs: NamedAttrMap) => { - const [x] = saved; - const {axis} = (attrs as {}) as ProdAttrs; - let axisArr = [] as number[]; - if (axis === undefined || axis === null) { - axisArr = x.shape.map((_, i) => i); - } else if (typeof axis === 'number') { - axisArr = [axis]; - } else { - axisArr = axis; - } - return {x: () => prodsGradFn_(x, dy as Tensor, axisArr)}; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/RealDiv_grad.ts b/tfjs-master/tfjs-core/src/gradients/RealDiv_grad.ts deleted file mode 100644 index 56e517115..000000000 --- a/tfjs-master/tfjs-core/src/gradients/RealDiv_grad.ts +++ /dev/null @@ -1,56 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {RealDiv} from '../kernel_names'; -import {GradConfig} from '../kernel_registry'; -import * as broadcast_util from '../ops/broadcast_util'; -import {cast} from '../ops/cast'; -import {div} from '../ops/div'; -import {mul} from '../ops/mul'; -import {neg} from '../ops/neg'; -import {reshape} from '../ops/reshape'; -import {square} from '../ops/square'; -import {sum} from '../ops/sum'; -import {Tensor} from '../tensor'; - -export const divGradConfig: GradConfig = { - kernelName: RealDiv, - inputsToSave: ['a', 'b'], - gradFunc: (dy: Tensor, saved: Tensor[]) => { - const [a, b] = saved; - const outShape = - broadcast_util.assertAndGetBroadcastShape(a.shape, b.shape); - const derA = () => { - const res = div(dy, cast(b, 'float32')); - const reduceAxes = broadcast_util.getReductionAxes(a.shape, outShape); - if (reduceAxes.length > 0) { - return reshape(sum(res, reduceAxes), a.shape); - } - return res; - }; - const derB = () => { - let res = mul(dy, cast(a, 'float32')); - const reduceAxes = broadcast_util.getReductionAxes(b.shape, outShape); - if (reduceAxes.length > 0) { - res = reshape(sum(res, reduceAxes), b.shape); - } - const tmp = square(b); - return neg(div(res, cast(tmp, 'float32'))); - }; - return {a: derA, b: derB}; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/Reciprocal_grad.ts b/tfjs-master/tfjs-core/src/gradients/Reciprocal_grad.ts deleted file mode 100644 index c4bfa6c3d..000000000 --- a/tfjs-master/tfjs-core/src/gradients/Reciprocal_grad.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Reciprocal} from '../kernel_names'; -import {GradConfig} from '../kernel_registry'; -import {div} from '../ops/div'; -import {neg} from '../ops/neg'; -import {square} from '../ops/square'; -import {Tensor} from '../tensor'; - -export const reciprocalGradConfig: GradConfig = { - kernelName: Reciprocal, - inputsToSave: ['x'], - gradFunc: (dy: Tensor, saved: Tensor[]) => { - const [x] = saved; - return {x: () => div(dy, neg(square(x)))}; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/Relu6_grad.ts b/tfjs-master/tfjs-core/src/gradients/Relu6_grad.ts deleted file mode 100644 index ebf2ca7a4..000000000 --- a/tfjs-master/tfjs-core/src/gradients/Relu6_grad.ts +++ /dev/null @@ -1,34 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {Relu6} from '../kernel_names'; -import {GradConfig} from '../kernel_registry'; -import {cast} from '../ops/cast'; -import {lessEqual} from '../ops/less_equal'; -import {mul} from '../ops/mul'; -import {step} from '../ops/step'; -import {Tensor} from '../tensor'; - -export const relu6GradConfig: GradConfig = { - kernelName: Relu6, - inputsToSave: ['x'], - gradFunc: (dy: Tensor, saved: Tensor[]) => { - const [x] = saved; - const mask = mul(lessEqual(x, 6), step(x)); - - return {x: () => mul(dy, cast(mask, 'float32'))}; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/Relu_grad.ts b/tfjs-master/tfjs-core/src/gradients/Relu_grad.ts deleted file mode 100644 index c96bdcc30..000000000 --- a/tfjs-master/tfjs-core/src/gradients/Relu_grad.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {Relu} from '../kernel_names'; -import {GradConfig} from '../kernel_registry'; -import {cast} from '../ops/cast'; -import {mul} from '../ops/mul'; -import {step} from '../ops/step'; -import {Tensor} from '../tensor'; - -export const reluGradConfig: GradConfig = { - kernelName: Relu, - inputsToSave: ['x'], - gradFunc: (dy: Tensor, saved: Tensor[]) => { - const [x] = saved; - return {x: () => mul(dy, cast(step(x), 'float32'))}; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/Reshape_grad.ts b/tfjs-master/tfjs-core/src/gradients/Reshape_grad.ts deleted file mode 100644 index e6ddb4551..000000000 --- a/tfjs-master/tfjs-core/src/gradients/Reshape_grad.ts +++ /dev/null @@ -1,29 +0,0 @@ -/** - * @license - * Copyright 2020 Google Inc. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {Reshape} from '../kernel_names'; -import {GradConfig} from '../kernel_registry'; -import {reshape} from '../ops/reshape'; -import {Tensor} from '../tensor'; - -export const reshapeGradConfig: GradConfig = { - kernelName: Reshape, - inputsToSave: ['x'], - gradFunc: (dy: Tensor, saved: Tensor[]) => { - const [x] = saved; - return {x: () => reshape(dy, x.shape)}; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/ResizeBilinear_grad.ts b/tfjs-master/tfjs-core/src/gradients/ResizeBilinear_grad.ts deleted file mode 100644 index 8b10ebc19..000000000 --- a/tfjs-master/tfjs-core/src/gradients/ResizeBilinear_grad.ts +++ /dev/null @@ -1,39 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {ENGINE} from '../engine'; -import {ResizeBilinear, ResizeBilinearGrad, ResizeBilinearGradInputs} from '../kernel_names'; -import {GradConfig} from '../kernel_registry'; -import {NamedAttrMap} from '../kernel_registry'; -import {Tensor, Tensor4D} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; - -export const resizeBilinearGradConfig: GradConfig = { - kernelName: ResizeBilinear, - inputsToSave: ['images'], - gradFunc: (dy: Tensor4D, saved: Tensor[], attrs: NamedAttrMap) => { - const [images] = saved; - - const inputs: ResizeBilinearGradInputs = {dy, images}; - const imagesDer = () => - // tslint:disable-next-line: no-unnecessary-type-assertion - ENGINE.runKernel( - ResizeBilinearGrad, inputs as unknown as NamedTensorMap, attrs) as - Tensor4D; - - return {images: imagesDer}; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/ResizeNearestNeighbor_grad.ts b/tfjs-master/tfjs-core/src/gradients/ResizeNearestNeighbor_grad.ts deleted file mode 100644 index 41733273c..000000000 --- a/tfjs-master/tfjs-core/src/gradients/ResizeNearestNeighbor_grad.ts +++ /dev/null @@ -1,39 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {ENGINE} from '../engine'; -import {ResizeNearestNeighbor, ResizeNearestNeighborGrad, ResizeNearestNeighborGradInputs} from '../kernel_names'; -import {GradConfig} from '../kernel_registry'; -import {NamedAttrMap} from '../kernel_registry'; -import {Tensor, Tensor4D} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; - -export const resizeNearestNeighborGradConfig: GradConfig = { - kernelName: ResizeNearestNeighbor, - inputsToSave: ['images'], - gradFunc: (dy: Tensor4D, saved: Tensor[], attrs: NamedAttrMap) => { - const [images] = saved; - - const inputs: ResizeNearestNeighborGradInputs = {dy, images}; - const imagesDer = () => - // tslint:disable-next-line: no-unnecessary-type-assertion - ENGINE.runKernel( - ResizeNearestNeighborGrad, inputs as unknown as NamedTensorMap, - attrs) as Tensor4D; - - return {images: imagesDer}; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/Reverse_grad.ts b/tfjs-master/tfjs-core/src/gradients/Reverse_grad.ts deleted file mode 100644 index 6e7b8a159..000000000 --- a/tfjs-master/tfjs-core/src/gradients/Reverse_grad.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {Reverse, ReverseAttrs} from '../kernel_names'; -import {GradConfig, NamedAttrMap} from '../kernel_registry'; -import {reverse} from '../ops/reverse'; -import {Tensor} from '../tensor'; -import {parseAxisParam} from '../util'; - -export const reverseGradConfig: GradConfig = { - kernelName: Reverse, - gradFunc: (dy: Tensor, saved: Tensor[], attrs: NamedAttrMap) => { - const {dims} = attrs as unknown as ReverseAttrs; - const axes = parseAxisParam(dims, dy.shape); - return {x: () => reverse(dy, axes)}; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/Round_grad.ts b/tfjs-master/tfjs-core/src/gradients/Round_grad.ts deleted file mode 100644 index 8ddcb155c..000000000 --- a/tfjs-master/tfjs-core/src/gradients/Round_grad.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Round} from '../kernel_names'; -import {GradConfig} from '../kernel_registry'; -import {zerosLike} from '../ops/zeros_like'; -import {Tensor} from '../tensor'; - -export const roundGradConfig: GradConfig = { - kernelName: Round, - gradFunc: (dy: Tensor) => { - // TODO(nsthorat): Let gradients be null for cases where we want to stop - // backpropgation. - return {x: () => zerosLike(dy)}; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/Rsqrt_grad.ts b/tfjs-master/tfjs-core/src/gradients/Rsqrt_grad.ts deleted file mode 100644 index fa77d7792..000000000 --- a/tfjs-master/tfjs-core/src/gradients/Rsqrt_grad.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Rsqrt} from '../kernel_names'; -import {GradConfig} from '../kernel_registry'; -import {div} from '../ops/div'; -import {mul} from '../ops/mul'; -import {neg} from '../ops/neg'; -import {pow} from '../ops/pow'; -import {Tensor} from '../tensor'; - -export const rsqrtGradConfig: GradConfig = { - kernelName: Rsqrt, - inputsToSave: ['x'], - gradFunc: (dy: Tensor, saved: Tensor[]) => { - const [x] = saved; - return {x: () => neg(div(dy, mul(pow(x, 1.5), 2)))}; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/Select_grad.ts b/tfjs-master/tfjs-core/src/gradients/Select_grad.ts deleted file mode 100644 index b23ed03e1..000000000 --- a/tfjs-master/tfjs-core/src/gradients/Select_grad.ts +++ /dev/null @@ -1,39 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Select} from '../kernel_names'; -import {GradConfig} from '../kernel_registry'; -import {cast} from '../ops/cast'; -import {logicalNot} from '../ops/logical_not'; -import {mul} from '../ops/mul'; -import {zerosLike} from '../ops/zeros_like'; -import {Tensor} from '../tensor'; - -export const selectGradConfig: GradConfig = { - kernelName: Select, - inputsToSave: ['condition'], - gradFunc: (dy: Tensor, saved: Tensor[]) => { - const [condition] = saved; - return { - // TODO(julianoks): Return null for condition gradient - // when backprop supports it. - condition: () => cast(zerosLike(condition), 'float32'), - t: () => mul(dy, cast(condition, dy.dtype)), - e: () => mul(dy, cast(logicalNot(condition), dy.dtype)) - }; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/Selu_grad.ts b/tfjs-master/tfjs-core/src/gradients/Selu_grad.ts deleted file mode 100644 index 38f6ea5fa..000000000 --- a/tfjs-master/tfjs-core/src/gradients/Selu_grad.ts +++ /dev/null @@ -1,48 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {Selu} from '../kernel_names'; -import {GradConfig} from '../kernel_registry'; -import {cast} from '../ops/cast'; -import {exp} from '../ops/exp'; -import {greater} from '../ops/greater'; -import {mul} from '../ops/mul'; -import {scalar} from '../ops/scalar'; -import {SELU_SCALE, SELU_SCALEALPHA} from '../ops/selu_util'; -import {where} from '../ops/where'; -import {Tensor} from '../tensor'; - -export const seluGradConfig: GradConfig = { - kernelName: Selu, - inputsToSave: ['x'], - gradFunc: (dy: Tensor, saved: Tensor[]) => { - const [x] = saved; - return { - x: () => { - const mask = greater(x, scalar(0)); - - const scaleAlpha = scalar(SELU_SCALEALPHA); - const scale = scalar(SELU_SCALE); - - const greaterThanZeroDer = mul(dy, scale); - const lessEqualZeroDer = - mul(mul(dy, scaleAlpha), exp(cast(x, 'float32'))); - - return where(mask, greaterThanZeroDer, lessEqualZeroDer); - } - }; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/Sigmoid_grad.ts b/tfjs-master/tfjs-core/src/gradients/Sigmoid_grad.ts deleted file mode 100644 index 5a595406e..000000000 --- a/tfjs-master/tfjs-core/src/gradients/Sigmoid_grad.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Sigmoid} from '../kernel_names'; -import {GradConfig} from '../kernel_registry'; -import {mul} from '../ops/mul'; -import {scalar} from '../ops/scalar'; -import {sub} from '../ops/sub'; -import {Tensor} from '../tensor'; - -export const sigmoidGradConfig: GradConfig = { - kernelName: Sigmoid, - outputsToSave: [true], - gradFunc: (dy: Tensor, saved: Tensor[]) => { - const [y] = saved; - - return {x: () => mul(dy, mul(y, sub(scalar(1), y)))}; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/Sign_grad.ts b/tfjs-master/tfjs-core/src/gradients/Sign_grad.ts deleted file mode 100644 index 794007624..000000000 --- a/tfjs-master/tfjs-core/src/gradients/Sign_grad.ts +++ /dev/null @@ -1,28 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Sign} from '../kernel_names'; -import {GradConfig} from '../kernel_registry'; -import {zerosLike} from '../ops/zeros_like'; -import {Tensor} from '../tensor'; - -export const signGradConfig: GradConfig = { - kernelName: Sign, - gradFunc: (dy: Tensor) => { - return {x: () => zerosLike(dy)}; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/Sin_grad.ts b/tfjs-master/tfjs-core/src/gradients/Sin_grad.ts deleted file mode 100644 index 2a23be35e..000000000 --- a/tfjs-master/tfjs-core/src/gradients/Sin_grad.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Sin} from '../kernel_names'; -import {GradConfig} from '../kernel_registry'; -import {cast} from '../ops/cast'; -import {cos} from '../ops/cos'; -import {mul} from '../ops/mul'; -import {Tensor} from '../tensor'; - -export const sinGradConfig: GradConfig = { - kernelName: Sin, - inputsToSave: ['x'], - gradFunc: (dy: Tensor, saved: Tensor[]) => { - const [x] = saved; - return {x: () => mul(cos(cast(x, 'float32')), dy)}; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/Sinh_grad.ts b/tfjs-master/tfjs-core/src/gradients/Sinh_grad.ts deleted file mode 100644 index 916bfee09..000000000 --- a/tfjs-master/tfjs-core/src/gradients/Sinh_grad.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Sinh} from '../kernel_names'; -import {GradConfig} from '../kernel_registry'; -import {cast} from '../ops/cast'; -import {cosh} from '../ops/cosh'; -import {mul} from '../ops/mul'; -import {Tensor} from '../tensor'; - -export const sinhGradConfig: GradConfig = { - kernelName: Sinh, - inputsToSave: ['x'], - gradFunc: (dy: Tensor, saved: Tensor[]) => { - const [x] = saved; - - return {x: () => mul(cosh(cast(x, 'float32')), dy)}; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/Slice_grad.ts b/tfjs-master/tfjs-core/src/gradients/Slice_grad.ts deleted file mode 100644 index 5018f529f..000000000 --- a/tfjs-master/tfjs-core/src/gradients/Slice_grad.ts +++ /dev/null @@ -1,46 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Slice, SliceAttrs} from '../kernel_names'; -import {GradConfig, NamedAttrMap} from '../kernel_registry'; -import {pad} from '../ops/pad'; -import {parseSliceParams} from '../ops/slice_util'; -import {Tensor} from '../tensor'; - -export const sliceGradConfig: GradConfig = { - kernelName: Slice, - inputsToSave: ['x'], - gradFunc: (dy: Tensor, saved: Tensor[], attrs: NamedAttrMap) => { - const [x] = saved; - const {begin, size} = attrs as unknown as SliceAttrs; - - const inputShape = x.shape; - const [begin_, size_] = parseSliceParams(x, begin, size); - - // Create an Nx2 padding where the first column represents how many - // zeros are prepended (at start) for each dimension, and the second - // column indicates how many zeros are appended (at end). - - // The number of zeros to append is the shape of the input - // elementwise-subtracted by both the begin vector and sizes vector. - const paddings: Array<[number, number]> = []; - for (let i = 0; i < dy.rank; i++) { - paddings.push([begin_[i], inputShape[i] - begin_[i] - size_[i]]); - } - return {x: () => pad(dy, paddings)}; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/Softmax_grad.ts b/tfjs-master/tfjs-core/src/gradients/Softmax_grad.ts deleted file mode 100644 index e414644d8..000000000 --- a/tfjs-master/tfjs-core/src/gradients/Softmax_grad.ts +++ /dev/null @@ -1,38 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Softmax, SoftmaxAttrs} from '../kernel_names'; -import {GradConfig, NamedAttrMap} from '../kernel_registry'; -import {mul} from '../ops/mul'; -import {sub} from '../ops/sub'; -import {sum} from '../ops/sum'; -import {Tensor} from '../tensor'; - -export const softmaxGradConfig: GradConfig = { - kernelName: Softmax, - outputsToSave: [true], - gradFunc: (dy: Tensor, saved: Tensor[], attrs: NamedAttrMap) => { - const [y] = saved; - const {dim} = attrs as unknown as SoftmaxAttrs; - const keepDims = true; - - const dyTimesY = mul(dy, y); - return { - logits: () => sub(dyTimesY, mul(sum(dyTimesY, [dim], keepDims), y)) - }; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/Softplus_grad.ts b/tfjs-master/tfjs-core/src/gradients/Softplus_grad.ts deleted file mode 100644 index 257ff601c..000000000 --- a/tfjs-master/tfjs-core/src/gradients/Softplus_grad.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Softplus} from '../kernel_names'; -import {GradConfig} from '../kernel_registry'; -import {mul} from '../ops/mul'; -import {sigmoid} from '../ops/sigmoid'; -import {Tensor} from '../tensor'; - -export const softplusGradConfig: GradConfig = { - kernelName: Softplus, - inputsToSave: ['x'], - gradFunc: (dy: Tensor, saved: Tensor[]) => { - const [x] = saved; - - return {x: () => mul(dy, sigmoid(x))}; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/SpaceToBatchND_grad.ts b/tfjs-master/tfjs-core/src/gradients/SpaceToBatchND_grad.ts deleted file mode 100644 index 4fddd55b2..000000000 --- a/tfjs-master/tfjs-core/src/gradients/SpaceToBatchND_grad.ts +++ /dev/null @@ -1,29 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {SpaceToBatchND, SpaceToBatchNDAttrs} from '../kernel_names'; -import {GradConfig, NamedAttrMap} from '../kernel_registry'; -import {batchToSpaceND} from '../ops/batch_to_space_nd'; -import {Tensor} from '../tensor'; - -export const spaceToBatchNDGradConfig: GradConfig = { - kernelName: SpaceToBatchND, - gradFunc: (dy: Tensor, saved: Tensor[], attrs: NamedAttrMap) => { - const {blockShape, paddings} = attrs as unknown as SpaceToBatchNDAttrs; - return {x: () => batchToSpaceND(dy, blockShape, paddings)}; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/SplitV_grad.ts b/tfjs-master/tfjs-core/src/gradients/SplitV_grad.ts deleted file mode 100644 index 01109f4f3..000000000 --- a/tfjs-master/tfjs-core/src/gradients/SplitV_grad.ts +++ /dev/null @@ -1,29 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {SplitV, SplitVAttrs} from '../kernel_names'; -import {GradConfig, NamedAttrMap} from '../kernel_registry'; -import {concat} from '../ops/concat'; -import {Tensor} from '../tensor'; - -export const splitVGradConfig: GradConfig = { - kernelName: SplitV, - gradFunc: (dy: Tensor[], saved: Tensor[], attrs: NamedAttrMap) => { - const {axis} = attrs as unknown as SplitVAttrs; - - return {x: () => concat(dy, axis)}; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/Sqrt_grad.ts b/tfjs-master/tfjs-core/src/gradients/Sqrt_grad.ts deleted file mode 100644 index 71012f49b..000000000 --- a/tfjs-master/tfjs-core/src/gradients/Sqrt_grad.ts +++ /dev/null @@ -1,34 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Sqrt} from '../kernel_names'; -import {GradConfig} from '../kernel_registry'; -import {cast} from '../ops/cast'; -import {div} from '../ops/div'; -import {mul} from '../ops/mul'; -import {sqrt} from '../ops/sqrt'; -import {Tensor} from '../tensor'; - -export const sqrtGradConfig: GradConfig = { - kernelName: Sqrt, - inputsToSave: ['x'], - gradFunc: (dy: Tensor, saved: Tensor[]) => { - const [x] = saved; - - return {x: () => div(dy, mul(sqrt(cast(x, 'float32')), 2))}; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/Square_grad.ts b/tfjs-master/tfjs-core/src/gradients/Square_grad.ts deleted file mode 100644 index dabc8705a..000000000 --- a/tfjs-master/tfjs-core/src/gradients/Square_grad.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Square} from '../kernel_names'; -import {GradConfig} from '../kernel_registry'; -import {cast} from '../ops/cast'; -import {mul} from '../ops/mul'; -import {Tensor} from '../tensor'; - -export const squareGradConfig: GradConfig = { - kernelName: Square, - inputsToSave: ['x'], - gradFunc: (dy: Tensor, saved: Tensor[]) => { - const [x] = saved; - return {x: () => mul(dy, mul(cast(x, 'float32'), 2))}; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/SquaredDifference_grad.ts b/tfjs-master/tfjs-core/src/gradients/SquaredDifference_grad.ts deleted file mode 100644 index 8e0cccd60..000000000 --- a/tfjs-master/tfjs-core/src/gradients/SquaredDifference_grad.ts +++ /dev/null @@ -1,35 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {SquaredDifference} from '../kernel_names'; -import {GradConfig} from '../kernel_registry'; -import {mul} from '../ops/mul'; -import {scalar} from '../ops/scalar'; -import {sub} from '../ops/sub'; -import {Tensor} from '../tensor'; - -export const squaredDifferenceGradConfig: GradConfig = { - kernelName: SquaredDifference, - inputsToSave: ['a', 'b'], - gradFunc: (dy: Tensor, saved: Tensor[]) => { - const [a, b] = saved; - const two = scalar(2); - const derA = () => mul(dy, mul(two, sub(a, b))); - const derB = () => mul(dy, mul(two, sub(b, a))); - return {a: derA, b: derB}; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/Step_grad.ts b/tfjs-master/tfjs-core/src/gradients/Step_grad.ts deleted file mode 100644 index a24535136..000000000 --- a/tfjs-master/tfjs-core/src/gradients/Step_grad.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Step} from '../kernel_names'; -import {GradConfig} from '../kernel_registry'; -import {zerosLike} from '../ops/zeros_like'; -import {Tensor} from '../tensor'; - -export const stepGradConfig: GradConfig = { - kernelName: Step, - gradFunc: (dy: Tensor) => { - // TODO(manrajgrover): Return null for gradients when backprop supports - // it. - return {x: () => zerosLike(dy)}; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/Sub_grad.ts b/tfjs-master/tfjs-core/src/gradients/Sub_grad.ts deleted file mode 100644 index c0ea0258e..000000000 --- a/tfjs-master/tfjs-core/src/gradients/Sub_grad.ts +++ /dev/null @@ -1,52 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {Sub} from '../kernel_names'; -import {GradConfig} from '../kernel_registry'; -import * as broadcast_util from '../ops/broadcast_util'; -import {neg} from '../ops/neg'; -import {reshape} from '../ops/reshape'; -import {sum} from '../ops/sum'; -import {Tensor} from '../tensor'; - -export const subGradConfig: GradConfig = { - kernelName: Sub, - inputsToSave: ['a', 'b'], - gradFunc: (dy: Tensor, saved: Tensor[]) => { - const [a, b] = saved; - const outShape = - broadcast_util.assertAndGetBroadcastShape(a.shape, b.shape); - - const derA = () => { - let res = dy; - const reduceAxes = broadcast_util.getReductionAxes(a.shape, outShape); - if (reduceAxes.length > 0) { - res = sum(res, reduceAxes); - } - return reshape(res, a.shape); - }; - const derB = () => { - let res = dy; - const reduceAxes = broadcast_util.getReductionAxes(b.shape, outShape); - if (reduceAxes.length > 0) { - res = sum(res, reduceAxes); - } - return reshape(neg(res), b.shape); - }; - - return {a: derA, b: derB}; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/Sum_grad.ts b/tfjs-master/tfjs-core/src/gradients/Sum_grad.ts deleted file mode 100644 index 7cc942b1d..000000000 --- a/tfjs-master/tfjs-core/src/gradients/Sum_grad.ts +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @license - * Copyright 2020 Google Inc. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Sum, SumAttrs} from '../kernel_names'; -import {GradConfig, NamedAttrMap} from '../kernel_registry'; -import {mul} from '../ops/mul'; -import {ones} from '../ops/ones'; -import {reshape} from '../ops/reshape'; -import {Tensor} from '../tensor'; -import {parseAxisParam} from '../util'; - -export const sumGradConfig: GradConfig = { - kernelName: Sum, - inputsToSave: ['x'], - gradFunc: (dy: Tensor, saved: Tensor[], attrs: NamedAttrMap) => { - const [x] = saved; - const expandedDyShape = x.shape.slice(); - const {axis} = attrs as unknown as SumAttrs; - - const axes = parseAxisParam(axis, x.shape); - axes.forEach(axis => { - expandedDyShape[axis] = 1; - }); - const expandedDy = reshape(dy, expandedDyShape); - const derX = mul(expandedDy, ones(x.shape, 'float32')); - - return {x: () => derX}; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/Tan_grad.ts b/tfjs-master/tfjs-core/src/gradients/Tan_grad.ts deleted file mode 100644 index 858285b1e..000000000 --- a/tfjs-master/tfjs-core/src/gradients/Tan_grad.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Tan} from '../kernel_names'; -import {GradConfig} from '../kernel_registry'; -import {cos} from '../ops/cos'; -import {div} from '../ops/div'; -import {square} from '../ops/square'; -import {Tensor} from '../tensor'; - -export const tanGradConfig: GradConfig = { - kernelName: Tan, - inputsToSave: ['x'], - gradFunc: (dy: Tensor, saved: Tensor[]) => { - const [x] = saved; - - return {x: () => div(dy, square(cos(x)))}; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/Tanh_grad.ts b/tfjs-master/tfjs-core/src/gradients/Tanh_grad.ts deleted file mode 100644 index ccae78f2f..000000000 --- a/tfjs-master/tfjs-core/src/gradients/Tanh_grad.ts +++ /dev/null @@ -1,34 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Tanh} from '../kernel_names'; -import {GradConfig} from '../kernel_registry'; -import {mul} from '../ops/mul'; -import {scalar} from '../ops/scalar'; -import {square} from '../ops/square'; -import {sub} from '../ops/sub'; -import {Tensor} from '../tensor'; - -export const tanhGradConfig: GradConfig = { - kernelName: Tanh, - outputsToSave: [true], - gradFunc: (dy: Tensor, saved: Tensor[]) => { - const [y] = saved; - - return {x: () => mul(sub(scalar(1), square(y)), dy)}; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/Tile_grad.ts b/tfjs-master/tfjs-core/src/gradients/Tile_grad.ts deleted file mode 100644 index 4f090be21..000000000 --- a/tfjs-master/tfjs-core/src/gradients/Tile_grad.ts +++ /dev/null @@ -1,87 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Tile, TileAttrs} from '../kernel_names'; -import {GradConfig, NamedAttrMap} from '../kernel_registry'; -import {add} from '../ops/add'; -import {slice} from '../ops/slice'; -import {zerosLike} from '../ops/zeros_like'; -import {Tensor} from '../tensor'; - -export const tileGradConfig: GradConfig = { - kernelName: Tile, - inputsToSave: ['x'], - gradFunc: (dy: Tensor, saved: Tensor[], attrs: NamedAttrMap) => { - const [x] = saved; - const {reps} = attrs as unknown as TileAttrs; - - const derX = () => { - let xGrad = zerosLike(x); - // TODO(cais): Maybe reduce memory footprint by avoiding repeated - // slicing. - if (x.rank === 1) { - for (let i = 0; i < reps[0]; ++i) { - xGrad = add(xGrad, slice(dy, [i * x.shape[0]], [x.shape[0]])); - } - } else if (x.rank === 2) { - for (let i = 0; i < reps[0]; ++i) { - for (let j = 0; j < reps[1]; ++j) { - xGrad = add(xGrad, slice(dy, [i * x.shape[0], j * x.shape[1]], [ - x.shape[0], x.shape[1] - ])); - } - } - } else if (x.rank === 3) { - for (let i = 0; i < reps[0]; ++i) { - for (let j = 0; j < reps[1]; ++j) { - for (let k = 0; k < reps[2]; ++k) { - xGrad = - add(xGrad, - slice( - dy, [i * x.shape[0], j * x.shape[1], k * x.shape[2]], - [x.shape[0], x.shape[1], x.shape[2]])); - } - } - } - } else if (x.rank === 4) { - for (let i = 0; i < reps[0]; ++i) { - for (let j = 0; j < reps[1]; ++j) { - for (let k = 0; k < reps[2]; ++k) { - for (let l = 0; l < reps[3]; ++l) { - xGrad = - add(xGrad, - slice( - dy, - [ - i * x.shape[0], j * x.shape[1], k * x.shape[2], - l * x.shape[3] - ], - [x.shape[0], x.shape[1], x.shape[2], x.shape[3]])); - } - } - } - } - } else { - throw new Error( - `Gradient for tile operation is not implemented for rank-` + - `${x.rank} tensors yet.`); - } - return xGrad; - }; - return {x: derX}; - }, -}; diff --git a/tfjs-master/tfjs-core/src/gradients/Transpose_grad.ts b/tfjs-master/tfjs-core/src/gradients/Transpose_grad.ts deleted file mode 100644 index b7375c1e6..000000000 --- a/tfjs-master/tfjs-core/src/gradients/Transpose_grad.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Transpose, TransposeAttrs} from '../kernel_names'; -import {GradConfig, NamedAttrMap} from '../kernel_registry'; -import * as axis_util from '../ops/axis_util'; -import {transpose} from '../ops/transpose'; -import {Tensor} from '../tensor'; - -export const transposeGradConfig: GradConfig = { - kernelName: Transpose, - gradFunc: (dy: Tensor, saved: Tensor[], attrs: NamedAttrMap) => { - const transposeAttrs: TransposeAttrs = attrs as unknown as TransposeAttrs; - const {perm} = transposeAttrs; - const undoPerm = axis_util.getUndoAxesPermutation(perm); - return {x: () => transpose(dy, undoPerm)}; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/Unpack_grad.ts b/tfjs-master/tfjs-core/src/gradients/Unpack_grad.ts deleted file mode 100644 index 1244a55e5..000000000 --- a/tfjs-master/tfjs-core/src/gradients/Unpack_grad.ts +++ /dev/null @@ -1,29 +0,0 @@ -/** - * @license - * Copyright 2020 Google Inc. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {Unpack, UnpackAttrs} from '../kernel_names'; -import {GradConfig, NamedAttrMap} from '../kernel_registry'; -import {stack} from '../ops/stack'; -import {Tensor} from '../tensor'; - -export const unpackGradConfig: GradConfig = { - kernelName: Unpack, - gradFunc: (dy: Tensor[], saved: Tensor[], attrs: NamedAttrMap) => { - const unpackAttrs: UnpackAttrs = attrs as unknown as UnpackAttrs; - const {axis} = unpackAttrs; - return {value: () => stack(dy, axis)}; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/UnsortedSegmentSum_grad.ts b/tfjs-master/tfjs-core/src/gradients/UnsortedSegmentSum_grad.ts deleted file mode 100644 index a6bff2ed2..000000000 --- a/tfjs-master/tfjs-core/src/gradients/UnsortedSegmentSum_grad.ts +++ /dev/null @@ -1,58 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {UnsortedSegmentSum} from '../kernel_names'; -import {GradConfig} from '../kernel_registry'; -import {expandDims} from '../ops/expand_dims'; -import {gather} from '../ops/gather'; -import {greaterEqual} from '../ops/greater_equal'; -import {logicalAnd} from '../ops/logical_and'; -import {maximum} from '../ops/maximum'; -import {ones} from '../ops/ones'; -import {scalar} from '../ops/scalar'; -import {where} from '../ops/where'; -import {zerosLike} from '../ops/zeros_like'; -import {Tensor, Tensor1D} from '../tensor'; - -export const unsortedSegmentSumGradConfig: GradConfig = { - kernelName: UnsortedSegmentSum, - inputsToSave: ['segmentIds'], - gradFunc: (dy: Tensor, saved: Tensor[]) => { - const [segmentIds] = saved; - - const derX = () => { - return gatherDropNegatives(dy, segmentIds as Tensor1D); - }; - return {x: derX}; - } -}; - -function gatherDropNegatives(x: T, indices: Tensor1D) { - // Helper function for unsorted segment ops. Gathers params for - // positive segment ids and gathers 0 for inputs with negative segment id. - // Mirrors _GatherDropNegatives from tensorflow/python/ops/math_grad.py - const zeroClippedIndices = maximum(indices, zerosLike(indices)); - const gathered = gather(x, zeroClippedIndices as Tensor1D); - let isPositive = greaterEqual(indices, scalar(0, 'int32')); - const numIters = gathered.rank - isPositive.rank; - for (let i = 0; i < numIters; ++i) { - isPositive = expandDims(isPositive, i + 1); - } - isPositive = logicalAnd(isPositive, ones(gathered.shape, 'bool')); - const zeroSlice = zerosLike(gathered); - return where(isPositive, gathered, zeroSlice); -} diff --git a/tfjs-master/tfjs-core/src/gradients/ZerosLike_grad.ts b/tfjs-master/tfjs-core/src/gradients/ZerosLike_grad.ts deleted file mode 100644 index 688ad14bc..000000000 --- a/tfjs-master/tfjs-core/src/gradients/ZerosLike_grad.ts +++ /dev/null @@ -1,28 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ZerosLike} from '../kernel_names'; -import {GradConfig} from '../kernel_registry'; -import {zerosLike} from '../ops/zeros_like'; -import {Tensor} from '../tensor'; - -export const zerosLikeGradConfig: GradConfig = { - kernelName: ZerosLike, - gradFunc: (dy: Tensor) => { - return {x: () => zerosLike(dy)}; - } -}; diff --git a/tfjs-master/tfjs-core/src/gradients/min_max_grad_util.ts b/tfjs-master/tfjs-core/src/gradients/min_max_grad_util.ts deleted file mode 100644 index cc58a49fe..000000000 --- a/tfjs-master/tfjs-core/src/gradients/min_max_grad_util.ts +++ /dev/null @@ -1,42 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as axis_util from '../ops/axis_util'; -import {cast} from '../ops/cast'; -import {equal} from '../ops/equal'; -import {mul} from '../ops/mul'; -import {reshape} from '../ops/reshape'; -import {Tensor} from '../tensor'; - -/** - * Gradient helper function for the min and max operations. - */ -export function gradForMinAndMax( - dy: T, y: T, xOrig: Tensor, origAxes: number[]) { - if (y.rank < xOrig.rank) { - y = reshape(y, axis_util.expandShapeToKeepDim(y.shape, origAxes)) as T; - } - if (dy.rank < xOrig.rank) { - dy = reshape(dy, axis_util.expandShapeToKeepDim(dy.shape, origAxes)) as T; - } - return { - x: () => { - const dx = mul(dy, cast(equal(xOrig, y), dy.dtype)); - return dx; - } - }; -} diff --git a/tfjs-master/tfjs-core/src/gradients_test.ts b/tfjs-master/tfjs-core/src/gradients_test.ts deleted file mode 100644 index c3c355646..000000000 --- a/tfjs-master/tfjs-core/src/gradients_test.ts +++ /dev/null @@ -1,376 +0,0 @@ - -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from './engine'; -import * as tf from './index'; -import {ALL_ENVS, describeWithFlags} from './jasmine_util'; -import {Tensor} from './tensor'; -import {expectArraysClose} from './test_util'; - -describeWithFlags('gradients', ALL_ENVS, () => { - it('matmul + relu', async () => { - const a = tf.tensor2d([-1, 2, -3, 10, -20, 30], [2, 3]); - const b = tf.tensor2d([2, -3, 4, -1, 2, -3], [3, 2]); - - const [da, db] = tf.grads((a: tf.Tensor2D, b: tf.Tensor2D) => { - // m = dot(a, b) - // y = relu(m) - // e = sum(y) - const m = tf.matMul(a, b); - const y = tf.relu(m); - return tf.sum(y); - })([a, b]); - - // de/dy = 1 - // dy/dm = step(m) - // de/dm = de/dy * dy/dm = step(m) - const dedm = tf.step(tf.matMul(a, b)); - - // de/da = dot(de/dy, bT) - expect(da.shape).toEqual(a.shape); - let transposeA = false; - let transposeB = true; - expectArraysClose( - await da.data(), - await tf.matMul(dedm, b, transposeA, transposeB).data()); - - // de/db = dot(aT, de/dy) - expect(db.shape).toEqual(b.shape); - transposeA = true; - transposeB = false; - expectArraysClose( - await db.data(), - await tf.matMul(a, dedm, transposeA, transposeB).data()); - }); - - it('grad(f)', async () => { - const grad = tf.grad(x => x.square()); - const result = grad(tf.tensor1d([.1, .2])); - expectArraysClose(await result.data(), [.2, .4]); - }); - - it('calling grad(f) twice works', async () => { - const grad = tf.grad(x => x.square()); - - const result = grad(tf.tensor1d([.1, .2])); - const result2 = grad(tf.tensor1d([.1, .4])); - expectArraysClose(await result.data(), [.2, .4]); - expectArraysClose(await result2.data(), [.2, .8]); - }); - - it('grad(f): throwing an error during forward pass', () => { - const grad = tf.grad(x => { - throw new Error('failed forward pass'); - }); - expect(() => grad(tf.zeros([]))).toThrowError(); - expect(ENGINE.isTapeOn()).toBe(false); - }); - - it('grad(f): throwing an error during backwards pass', () => { - const customOp = tf.customGrad((x: tf.Tensor) => { - return { - value: x, - gradFunc: () => { - throw new Error('failed backward pass'); - } - }; - }); - const grad = tf.grad(x => customOp(x)); - expect(() => grad(tf.zeros([]))).toThrowError(); - expect(ENGINE.isTapeOn()).toBe(false); - }); - - it('grads(f)', async () => { - const grads = tf.grads(x => x.square()); - const result = grads([tf.tensor1d([.1, .2])]); - expectArraysClose(await result[0].data(), [.2, .4]); - }); - - it('calling grads(f) twice works', async () => { - const grads = tf.grads(x => x.square()); - - const result = grads([tf.tensor1d([.1, .2])]); - const result2 = grads([tf.tensor1d([.1, .4])]); - expectArraysClose(await result[0].data(), [.2, .4]); - expectArraysClose(await result2[0].data(), [.2, .8]); - }); - - it('works with reshape', async () => { - const a = tf.tensor2d([1, 2, 3, 4], [2, 2]); - const exponent = tf.tensor1d([2, 2, 2, 2], 'int32'); - - const da = tf.grad(a => { - const b = a.flatten(); - const m = tf.pow(b, exponent); - return tf.sum(m); - })(a); - - expect(da.shape).toEqual([2, 2]); - expectArraysClose(await da.data(), [2, 4, 6, 8]); - }); - - it('reshape outside tf.grads() throws error', () => { - const a = tf.tensor2d([1, 2, 3, 4], [2, 2]); - const b = a.flatten(); - const exponent = tf.tensor1d([2, 2, 2, 2], 'int32'); - - const f = () => { - tf.grads((a, b) => { - const m = tf.pow(b, exponent); - return tf.sum(m); - })([a, b]); - }; - expect(f).toThrowError(); - }); - - it('does not error if irrelevant (pruned) ops are missing grads', - async () => { - const a = tf.tensor1d([true, true], 'bool'); - const b = tf.tensor1d([false, true], 'bool'); - const da = tf.grad(a => { - // Logical has no gradients, but it is irrelevant. - a.logicalAnd(b); - return a.sum(); - })(a); - expectArraysClose(await da.data(), [1, 1]); - }); - - it('errors if relevant ops are missing grads', () => { - const a = tf.tensor1d([true, true], 'bool'); - const b = tf.tensor1d([false, true], 'bool'); - const dfda = tf.grad(a => { - // Logical has no gradients, but it's relevant to the output. - return a.logicalAnd(b); - }); - expect(() => dfda(a)).toThrowError(); - }); - - it('works with asType', async () => { - const a = tf.tensor2d([1, 2, 3, 4], [2, 2], 'int32'); - const exponent = tf.tensor2d([2, 2, 2, 2], [2, 2], 'int32'); - - const da = tf.grad(a => { - const b = a.toFloat(); - const m = tf.pow(b, exponent); - return tf.sum(m); - })(a); - - expect(da.shape).toEqual([2, 2]); - expect(da.dtype).toEqual('float32'); - expectArraysClose(await da.data(), [2, 4, 6, 8]); - }); - - it('asType outside of tf.grads() throws error', () => { - const a = tf.tensor2d([1, 2, 3, 4], [2, 2], 'int32'); - const b = a.toFloat(); - const exponent = tf.tensor2d([2, 2, 2, 2], [2, 2], 'int32'); - - const f = () => { - tf.grad(a => { - const m = tf.pow(b, exponent); - return tf.sum(m); - })(a); - }; - expect(f).toThrowError(); - }); - - it('saves tensors from the forward pass as expected', () => { - const x = tf.scalar(1).variable(); - const optimizer = tf.train.sgd(0.1); - optimizer.minimize(() => { - const y = x.square(); - const z = y.square(); - y.dispose(); - return z; - }); - }); - - it('custom ops do not leak', () => { - const before = tf.memory().numTensors; - const x = tf.softmax([1, 2, 3, 4]); - x.dispose(); - const now = tf.memory().numTensors; - expect(now).toBe(before); - }); -}); - -describeWithFlags('valueAndGradients', ALL_ENVS, () => { - it('matmul + relu', async () => { - const a = tf.tensor2d([-1, 2, -3, 10, -20, 30], [2, 3]); - const b = tf.tensor2d([2, -3, 4, -1, 2, -3], [3, 2]); - - const {value, grads} = - tf.valueAndGrads((a: tf.Tensor2D, b: tf.Tensor2D) => { - // m = dot(a, b) - // y = relu(m) - // e = sum(y) - const m = tf.matMul(a, b); - const y = tf.relu(m); - return tf.sum(y); - })([a, b]); - - expectArraysClose(await value.data(), 10); - - // de/dy = 1 - // dy/dm = step(m) - // de/dm = de/dy * dy/dm = step(m) - const dedm = tf.step(tf.matMul(a, b)); - - const [da, db] = grads; - // de/da = dot(de/dy, bT) - let transposeA = false; - let transposeB = true; - expectArraysClose( - await da.data(), - await tf.matMul(dedm, b, transposeA, transposeB).data()); - - // de/db = dot(aT, de/dy) - transposeA = true; - transposeB = false; - expectArraysClose( - await db.data(), - await tf.matMul(a, dedm, transposeA, transposeB).data()); - }); - - it('matmul + relu + inner tidy', async () => { - const a = tf.tensor2d([-1, 2, -3, 10, -20, 30], [2, 3]); - const b = tf.tensor2d([2, -3, 4, -1, 2, -3], [3, 2]); - - const {value, grads} = - tf.valueAndGrads((a: tf.Tensor2D, b: tf.Tensor2D) => { - // m = dot(a, b) - // y = relu(m) - // e = sum(y) - const m = tf.matMul(a, b); - return tf.tidy(() => { - const y = tf.relu(m); - return tf.sum(y); - }); - })([a, b]); - - expectArraysClose(await value.data(), 10); - - // de/dy = 1 - // dy/dm = step(m) - // de/dm = de/dy * dy/dm = step(m) - const dedm = tf.step(tf.matMul(a, b)); - - const [da, db] = grads; - // de/da = dot(de/dy, bT) - let transposeA = false; - let transposeB = true; - expectArraysClose( - await da.data(), - await tf.matMul(dedm, b, transposeA, transposeB).data()); - - // de/db = dot(aT, de/dy) - transposeA = true; - transposeB = false; - expectArraysClose( - await db.data(), - await tf.matMul(a, dedm, transposeA, transposeB).data()); - }); -}); - -describeWithFlags('higher-order gradients', ALL_ENVS, () => { - it('grad(grad(f))', async () => { - const x = tf.tensor1d([.1, .2]); - const before = tf.memory().numTensors; - const gradgrad = tf.grad(tf.grad(x => x.mul(x).mul(x))); - const result = gradgrad(x); - expect(tf.memory().numTensors).toBe(before + 1); - expectArraysClose(await result.data(), [.6, 1.2]); - }); - - it('grad(grad(x^2))', async () => { - const x = tf.scalar(3); - const gradgrad = tf.grad(tf.grad(x => x.square())); - const result = gradgrad(x); - // grad(grad(x^2)) = grad(2x) = 2 - expectArraysClose(await result.data(), [2]); - }); - - it('grads(grads(f))', async () => { - const grads = tf.grads(x => x.mul(x).mul(x)); - const gradsgrads = tf.grads(x => grads([x])[0]); - const result = gradsgrads([tf.tensor1d([.1, .2])]); - expectArraysClose(await result[0].data(), [.6, 1.2]); - }); -}); - -describeWithFlags('customGradient', ALL_ENVS, () => { - it('basic', async () => { - const a = tf.scalar(3); - const b = tf.scalar(2, 'int32'); - const dy = tf.scalar(4); - - const customPow = tf.customGrad((a: tf.Tensor) => { - const value = tf.pow(a, b); - const gradFunc = (dy: tf.Tensor) => dy.mul(tf.scalar(0.1)); - return {value, gradFunc}; - }); - - const {value, grad} = tf.valueAndGrad(a => customPow(a))(a, dy); - expect(value.shape).toEqual(a.shape); - expectArraysClose(await value.data(), [9]); - expect(grad.shape).toEqual(a.shape); - expectArraysClose(await grad.data(), [.4]); - }); - - it('second order derivative through customGradient', async () => { - const a = tf.scalar(3); - const b = tf.scalar(2, 'int32'); - - const dy = tf.scalar(5); - - const customPow = tf.customGrad((a: tf.Tensor, save: tf.GradSaveFunc) => { - const value = tf.pow(a, b); - save([a]); - const gradFunc = (dy: tf.Tensor, saved: Tensor[]) => { - const [a] = saved; - return dy.mul(a); - }; - return {value, gradFunc}; - }); - - const dda = tf.grad(tf.grad(a => customPow(a)))(a, dy); - expect(dda.shape).toEqual(a.shape); - - // First order: dy * a. Second order: dy. - expectArraysClose(await dda.data(), await dy.data()); - }); - - it('calling gradient of custom op twice works', async () => { - const customOp = tf.customGrad((x: tf.Tensor, save: tf.GradSaveFunc) => { - // Override gradient of our custom x ^ 2 op to be dy * abs(x); - save([x]); - return { - value: x.square(), - gradFunc: (dy, saved: Tensor[]) => { - const [x] = saved; - return dy.mul(x.abs()); - } - }; - }); - const x = tf.tensor1d([-1, -2, 3]); - const grad = tf.grad(x => customOp(x)); - - expectArraysClose(await grad(x).data(), [1, 2, 3]); - expectArraysClose(await grad(x).data(), [1, 2, 3]); - }); -}); diff --git a/tfjs-master/tfjs-core/src/hash_util.ts b/tfjs-master/tfjs-core/src/hash_util.ts deleted file mode 100644 index adc7c878a..000000000 --- a/tfjs-master/tfjs-core/src/hash_util.ts +++ /dev/null @@ -1,204 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -// Workaround for allowing cjs module to be included in bundle created by -// rollup. -import * as LongExports from 'long'; -// tslint:disable-next-line -const Long: LongExports.LongConstructor = - // tslint:disable-next-line - (LongExports as any).default || LongExports; - -export function hexToLong(hex: string): Long { - return Long.fromString(hex, true, 16); -} - -// Some primes between 2^63 and 2^64 for various uses. -// Hex 0xc3a5c85c97cb3127 -const k0: Long = hexToLong('c3a5c85c97cb3127'); -// Hex 0xb492b66fbe98f273 -const k1: Long = hexToLong('b492b66fbe98f273'); -// Hex 0x9ae16a3b2f90404f -const k2: Long = hexToLong('9ae16a3b2f90404f'); - -function shiftMix(val: Long): Long { - return val.xor(val.shru(47)); -} - -function fetch(s: Uint8Array, offset: number, numBytes: number): Long { - const bytes = s.slice(offset, offset + numBytes); - return Long.fromBytes(Array.from(bytes), true, true); -} - -function fetch64(s: Uint8Array, offset: number): Long { - return fetch(s, offset, 8); -} - -function fetch32(s: Uint8Array, offset: number): Long { - return fetch(s, offset, 4); -} - -function rotate64(val: Long, shift: number): Long { - // Avoid shifting by 64: doing so yields an undefined result. - return shift === 0 ? val : val.shru(shift).or(val.shl(64 - shift)); -} - -function hashLen16(u: Long, v: Long, mul = hexToLong('9ddfea08eb382d69')) { - // Murmur-inspired hashing. - let a = u.xor(v).mul(mul); - a = a.xor(a.shru(47)); - let b = v.xor(a).mul(mul); - b = b.xor(b.shru(47)); - b = b.mul(mul); - return b; -} - -// Return a 16-byte hash for 48 bytes. Quick and dirty. -// Callers do best to use "random-looking" values for a and b. -function weakHashLen32WithSeeds( - w: Long, x: Long, y: Long, z: Long, a: Long, b: Long) { - a = a.add(w); - b = rotate64(b.add(a).add(z), 21); - const c = a; - a = a.add(x); - a = a.add(y); - b = b.add(rotate64(a, 44)); - return [a.add(z), b.add(c)]; -} - -function weakHashLen32WithSeedsStr( - s: Uint8Array, offset: number, a: Long, b: Long) { - return weakHashLen32WithSeeds( - fetch64(s, offset), fetch64(s, offset + 8), fetch64(s, offset + 16), - fetch64(s, offset + 24), a, b); -} - -function hashLen0to16(s: Uint8Array, len = s.length): Long { - if (len >= 8) { - const mul = k2.add(len * 2); - const a = fetch64(s, 0).add(k2); - const b = fetch64(s, len - 8); - const c = rotate64(b, 37).mul(mul).add(a); - const d = rotate64(a, 25).add(b).mul(mul); - return hashLen16(c, d, mul); - } - if (len >= 4) { - const mul = k2.add(len * 2); - const a = fetch32(s, 0); - return hashLen16(a.shl(3).add(len), fetch32(s, len - 4), mul); - } - if (len > 0) { - const a = s[0]; - const b = s[len >> 1]; - const c = s[len - 1]; - const y = a + (b << 8); - const z = len + (c << 2); - return shiftMix(k2.mul(y).xor(k0.mul(z))).mul(k2); - } - return k2; -} - -function hashLen17to32(s: Uint8Array, len = s.length): Long { - const mul = k2.add(len * 2); - const a = fetch64(s, 0).mul(k1); - const b = fetch64(s, 8); - const c = fetch64(s, len - 8).mul(mul); - const d = fetch64(s, len - 16).mul(k2); - return hashLen16( - rotate64(a.add(b), 43).add(rotate64(c, 30)).add(d), - a.add(rotate64(b.add(k2), 18)).add(c), mul); -} - -function hashLen33to64(s: Uint8Array, len = s.length): Long { - const mul = k2.add(len * 2); - const a = fetch64(s, 0).mul(k2); - const b = fetch64(s, 8); - const c = fetch64(s, len - 8).mul(mul); - const d = fetch64(s, len - 16).mul(k2); - const y = rotate64(a.add(b), 43).add(rotate64(c, 30)).add(d); - const z = hashLen16(y, a.add(rotate64(b.add(k2), 18)).add(c), mul); - const e = fetch64(s, 16).mul(mul); - const f = fetch64(s, 24); - const g = y.add(fetch64(s, len - 32)).mul(mul); - const h = z.add(fetch64(s, len - 24)).mul(mul); - return hashLen16( - rotate64(e.add(f), 43).add(rotate64(g, 30)).add(h), - e.add(rotate64(f.add(a), 18)).add(g), mul); -} - -export function fingerPrint64(s: Uint8Array, len = s.length): Long { - const seed: Long = Long.fromNumber(81, true); - if (len <= 32) { - if (len <= 16) { - return hashLen0to16(s, len); - } else { - return hashLen17to32(s, len); - } - } else if (len <= 64) { - return hashLen33to64(s, len); - } - - // For strings over 64 bytes we loop. Internal state consists of - // 56 bytes: v, w, x, y, and z. - let x = seed; - let y = seed.mul(k1).add(113); - - let z = shiftMix(y.mul(k2).add(113)).mul(k2); - let v = [Long.UZERO, Long.UZERO]; - let w = [Long.UZERO, Long.UZERO]; - x = x.mul(k2).add(fetch64(s, 0)); - - let offset = 0; - // Set end so that after the loop we have 1 to 64 bytes left to process. - const end = ((len - 1) >> 6) * 64; - const last64 = end + ((len - 1) & 63) - 63; - - do { - x = rotate64(x.add(y).add(v[0]).add(fetch64(s, offset + 8)), 37).mul(k1); - y = rotate64(y.add(v[1]).add(fetch64(s, offset + 48)), 42).mul(k1); - x = x.xor(w[1]); - y = y.add(v[0]).add(fetch64(s, offset + 40)); - z = rotate64(z.add(w[0]), 33).mul(k1); - v = weakHashLen32WithSeedsStr(s, offset, v[1].mul(k1), x.add(w[0])); - w = weakHashLen32WithSeedsStr( - s, offset + 32, z.add(w[1]), y.add(fetch64(s, offset + 16))); - - [z, x] = [x, z]; - offset += 64; - } while (offset !== end); - const mul = k1.add(z.and(0xff).shl(1)); - // Point to the last 64 bytes of input. - offset = last64; - - w[0] = w[0].add((len - 1) & 63); - v[0] = v[0].add(w[0]); - w[0] = w[0].add(v[0]); - - x = rotate64(x.add(y).add(v[0]).add(fetch64(s, offset + 8)), 37).mul(mul); - y = rotate64(y.add(v[1]).add(fetch64(s, offset + 48)), 42).mul(mul); - x = x.xor(w[1].mul(9)); - y = y.add(v[0].mul(9).add(fetch64(s, offset + 40))); - z = rotate64(z.add(w[0]), 33).mul(mul); - v = weakHashLen32WithSeedsStr(s, offset, v[1].mul(mul), x.add(w[0])); - w = weakHashLen32WithSeedsStr( - s, offset + 32, z.add(w[1]), y.add(fetch64(s, offset + 16))); - - [z, x] = [x, z]; - - return hashLen16( - hashLen16(v[0], w[0], mul).add(shiftMix(y).mul(k0)).add(z), - hashLen16(v[1], w[1], mul).add(x), mul); -} diff --git a/tfjs-master/tfjs-core/src/hash_util_test.ts b/tfjs-master/tfjs-core/src/hash_util_test.ts deleted file mode 100644 index 56e504bf0..000000000 --- a/tfjs-master/tfjs-core/src/hash_util_test.ts +++ /dev/null @@ -1,170 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {fingerPrint64, hexToLong} from './hash_util'; -import {ALL_ENVS, describeWithFlags} from './jasmine_util'; - -/** - * The ACMRandom generator is for situations where extreme statistical quality - * is not important. ACMRandom is useful for testing since it is seeded allowing - * for reproducible results as well as low overhead so using it will - * not affect test speed. - */ -class ACMRandom { - static readonly MAX_INT32 = 2147483647; - private seed: number; - - constructor(seed: number) { - seed = seed & 0x7fffffff; - if (seed === 0 || seed === ACMRandom.MAX_INT32) { - seed = 1; - } - this.seed = seed; - } - - private next() { - const A = hexToLong('41A7'); // bits 14, 8, 7, 5, 2, 1, 0 - const MAX_INT32 = ACMRandom.MAX_INT32; - // We are computing - // seed = (seed * A) % MAX_INT32, where MAX_INT32 = 2^31-1 - // - // seed must not be zero or MAX_INT32, or else all subsequent computed - // values will be zero or MAX_INT32 respectively. For all other values, - // seed will end up cycling through every number in [1,MAX_INT32-1] - const product = A.mul(this.seed); - - // Compute (product % MAX_INT32) using the fact that - // ((x << 31) % MAX_INT32) == x. - this.seed = product.shru(31).add(product.and(MAX_INT32)).getLowBits(); - // The first reduction may overflow by 1 bit, so we may need to repeat. - // mod == MAX_INT32 is not possible; using > allows for the faster - // sign-bit-based test. - if (this.seed > MAX_INT32) { - this.seed -= MAX_INT32; - } - return this.seed; - } - - public rand8() { - return (this.next() >> 1) & 0x000000ff; - } -} - -describeWithFlags('hash_util', ALL_ENVS, () => { - it('check incremental hashes', () => { - const buf = new Uint8Array(1000); - const r = new ACMRandom(10); - for (let i = 0; i < buf.length; ++i) { - buf[i] = r.rand8(); - } - - const expectIteration = (length: number, expectedHash: string) => - expect(fingerPrint64(buf, length)).toEqual(hexToLong(expectedHash)); - - expectIteration(0, '9ae16a3b2f90404f'); - expectIteration(1, '49d8a5e3fa93c327'); - expectIteration(2, 'fd259abb0ff2bf12'); - expectIteration(3, '781f1c6437096ac2'); - expectIteration(4, '0f1369d6c0b45716'); - expectIteration(5, '02d8cec6394de09a'); - expectIteration(7, '1faf6c6d43626c48'); - expectIteration(9, 'c93efd6dbe139be8'); - expectIteration(12, '65abbc967c87d515'); - expectIteration(16, '3f61450a03cff5af'); - expectIteration(20, '5d2fe297e45fed1a'); - expectIteration(26, 'eb665983aeb9ab94'); - expectIteration(33, '3a5f3890b124b4a3'); - expectIteration(42, 'f0c1cd66d7d9f246'); - expectIteration(53, 'cf7e3e4b1efeba6d'); - expectIteration(67, '0ced753b45740875'); - expectIteration(84, 'a585e0be01846ff4'); - expectIteration(105, 'fb6496deb356cdda'); - expectIteration(132, 'f2e4c5b6db6c154a'); - expectIteration(166, '4498451c3bca85a0'); - expectIteration(208, 'd604355fa4d0b14e'); - expectIteration(261, 'bb165e6b84ba9cdf'); - expectIteration(327, '9ebfab4519b1348c'); - expectIteration(409, '5921974ba2e9a5c2'); - expectIteration(512, 'a86a96e7a44282e3'); - expectIteration(640, 'dd731dfee500aa3c'); - expectIteration(800, 'a69f3400e6c98357'); - expectIteration(1000, '5c63b66443990bec'); - }); - - // This is more thorough, but if something is wrong the output will be even - // less illuminating, because it just checks one integer at the end. - it('check many different strings', () => { - const iters = 800; - const s = new Uint8Array(4 * iters); - let len = 0; - let h = hexToLong('0'); - - // Helper that replaces h with a hash of itself and return a - // char that is also a hash of h. Neither hash needs to be particularly - // good. - const remix = (): number => { - h = h.xor(h.shru(41)); - h = h.mul(949921979); - return 'a'.charCodeAt(0) + h.and(0xfffff).mod(26).getLowBits(); - }; - - for (let i = 0; i < iters; i++) { - h = h.xor(fingerPrint64(s, i)); - s[len++] = remix(); - h = h.xor(fingerPrint64(s, i * i % len)); - s[len++] = remix(); - h = h.xor(fingerPrint64(s, i * i * i % len)); - s[len++] = remix(); - h = h.xor(fingerPrint64(s, len)); - s[len++] = remix(); - const x0 = s[len - 1]; - const x1 = s[len - 2]; - const x2 = s[len - 3]; - const x3 = s[len >> 1]; - s[((x0 << 16) + (x1 << 8) + x2) % len] ^= x3; - s[((x1 << 16) + (x2 << 8) + x3) % len] ^= i % 256; - } - - expect(h).toEqual(hexToLong('7a1d67c50ec7e167')); - }); - - it('check string hash', () => { - const fingerPrintHash = (hash: Long) => { - const mul = hexToLong('9ddfea08eb382d69'); - let b = hash.mul(mul); - b = b.xor(b.shru(44)); - b = b.mul(mul); - b = b.xor(b.shru(41)); - b = b.mul(mul); - return b; - }; - - const getString = (length: number) => Uint8Array.from( - 'x'.repeat(length).split('').map(char => char.charCodeAt(0))); - - expect(fingerPrintHash(fingerPrint64(getString(40)))) - .toEqual(hexToLong('2117170c4aebaffe')); - expect(fingerPrintHash(fingerPrint64(getString(60)))) - .toEqual(hexToLong('e252963f3fd7a3af')); - expect(fingerPrintHash(fingerPrint64(getString(70)))) - .toEqual(hexToLong('b0a8cf4a56c570fa')); - expect(fingerPrintHash(fingerPrint64(getString(80)))) - .toEqual(hexToLong('d6ddaa49ddef5839')); - expect(fingerPrintHash(fingerPrint64(getString(90)))) - .toEqual(hexToLong('168f3a694b4dce29')); - }); -}); diff --git a/tfjs-master/tfjs-core/src/image_test_util.ts b/tfjs-master/tfjs-core/src/image_test_util.ts deleted file mode 100644 index 16f646cb0..000000000 --- a/tfjs-master/tfjs-core/src/image_test_util.ts +++ /dev/null @@ -1,51 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from './index'; - -/** - * Returns an image used in various image related tests as a 4d tensor. - * - * The image is 8x8 and looks like this: - * https://drive.google.com/file/d/1Y0AsFZ2w9HsWgJfm8f2uDOGY7A4IHjcK/view?usp=sharing - * - */ -export function getTestImageAsTensor4d() { - return tf.tensor4d( - [ - 156, 100, 111, 255, 171, 120, 117, 255, 183, 138, 109, 255, 200, 155, - 98, 255, 212, 157, 75, 255, 224, 156, 55, 255, 241, 153, 43, 255, - 230, 133, 18, 255, 168, 129, 130, 255, 186, 152, 140, 255, 202, 174, - 137, 255, 220, 190, 128, 255, 230, 193, 104, 255, 241, 188, 82, 255, - 250, 177, 64, 255, 233, 148, 31, 255, 179, 176, 159, 255, 199, 198, - 168, 255, 211, 216, 162, 255, 225, 228, 151, 255, 235, 227, 128, 255, - 243, 220, 106, 255, 247, 201, 81, 255, 222, 164, 41, 255, 163, 208, - 187, 255, 179, 226, 194, 255, 184, 234, 181, 255, 191, 239, 165, 255, - 201, 236, 142, 255, 213, 230, 126, 255, 218, 210, 103, 255, 191, 170, - 61, 255, 108, 214, 202, 255, 119, 226, 206, 255, 121, 231, 192, 255, - 130, 235, 179, 255, 141, 232, 162, 255, 155, 226, 146, 255, 162, 206, - 127, 255, 135, 166, 86, 255, 55, 207, 212, 255, 62, 217, 213, 255, - 64, 219, 201, 255, 76, 225, 193, 255, 87, 220, 175, 255, 94, 206, - 156, 255, 98, 181, 135, 255, 71, 143, 97, 255, 18, 200, 224, 255, - 19, 204, 222, 255, 19, 203, 211, 255, 30, 209, 205, 255, 35, 200, - 186, 255, 37, 177, 164, 255, 39, 150, 141, 255, 15, 115, 105, 255, - 0, 193, 228, 255, 0, 192, 221, 255, 0, 189, 209, 255, 0, 194, - 204, 255, 4, 182, 186, 255, 3, 158, 162, 255, 6, 133, 140, 255, - 0, 102, 113, 255 - ], - [1, 8, 8, 4]); -} diff --git a/tfjs-master/tfjs-core/src/index.ts b/tfjs-master/tfjs-core/src/index.ts deleted file mode 100644 index 6859860a4..000000000 --- a/tfjs-master/tfjs-core/src/index.ts +++ /dev/null @@ -1,28 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// Required side effectful code. -import './base_side_effects'; - -// TODO(mattSoulanille): Move this to base_side_effects.ts -// It is here for now because custom bundles need to avoid calling it, and they -// only replace the index.js file, not the base_side_effects file. -import {registerOptimizers} from './optimizers/register_optimizers'; -registerOptimizers(); - -// All exports from this package should be in base. -export * from './base'; diff --git a/tfjs-master/tfjs-core/src/io/browser_files.ts b/tfjs-master/tfjs-core/src/io/browser_files.ts deleted file mode 100644 index 816e00a08..000000000 --- a/tfjs-master/tfjs-core/src/io/browser_files.ts +++ /dev/null @@ -1,345 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -/** - * IOHandlers related to files, such as browser-triggered file downloads, - * user-selected files in browser. - */ - -import '../flags'; -import {env} from '../environment'; - -import {basename, getModelArtifactsForJSON, getModelArtifactsInfoForJSON, getModelJSONForModelArtifacts} from './io_utils'; -import {IORouter, IORouterRegistry} from './router_registry'; -import {IOHandler, ModelArtifacts, ModelJSON, SaveResult, WeightData, WeightsManifestConfig, WeightsManifestEntry} from './types'; -import {CompositeArrayBuffer} from './composite_array_buffer'; - -const DEFAULT_FILE_NAME_PREFIX = 'model'; -const DEFAULT_JSON_EXTENSION_NAME = '.json'; -const DEFAULT_WEIGHT_DATA_EXTENSION_NAME = '.weights.bin'; - -function defer(f: () => T): Promise { - return new Promise(resolve => setTimeout(resolve)).then(f); -} - -export class BrowserDownloads implements IOHandler { - private readonly modelJsonFileName: string; - private readonly weightDataFileName: string; - private readonly modelJsonAnchor: HTMLAnchorElement; - private readonly weightDataAnchor: HTMLAnchorElement; - - static readonly URL_SCHEME = 'downloads://'; - - constructor(fileNamePrefix?: string) { - if (!env().getBool('IS_BROWSER')) { - // TODO(cais): Provide info on what IOHandlers are available under the - // current environment. - throw new Error( - 'browserDownloads() cannot proceed because the current environment ' + - 'is not a browser.'); - } - - if (fileNamePrefix.startsWith(BrowserDownloads.URL_SCHEME)) { - fileNamePrefix = fileNamePrefix.slice(BrowserDownloads.URL_SCHEME.length); - } - if (fileNamePrefix == null || fileNamePrefix.length === 0) { - fileNamePrefix = DEFAULT_FILE_NAME_PREFIX; - } - - this.modelJsonFileName = fileNamePrefix + DEFAULT_JSON_EXTENSION_NAME; - this.weightDataFileName = - fileNamePrefix + DEFAULT_WEIGHT_DATA_EXTENSION_NAME; - } - - async save(modelArtifacts: ModelArtifacts): Promise { - if (typeof (document) === 'undefined') { - throw new Error( - 'Browser downloads are not supported in ' + - 'this environment since `document` is not present'); - } - - // TODO(mattsoulanille): Support saving models over 2GB that exceed - // Chrome's ArrayBuffer size limit. - const weightBuffer = CompositeArrayBuffer.join(modelArtifacts.weightData); - - const weightsURL = window.URL.createObjectURL(new Blob( - [weightBuffer], {type: 'application/octet-stream'})); - - if (modelArtifacts.modelTopology instanceof ArrayBuffer) { - throw new Error( - 'BrowserDownloads.save() does not support saving model topology ' + - 'in binary formats yet.'); - } else { - const weightsManifest: WeightsManifestConfig = [{ - paths: ['./' + this.weightDataFileName], - weights: modelArtifacts.weightSpecs - }]; - const modelJSON: ModelJSON = - getModelJSONForModelArtifacts(modelArtifacts, weightsManifest); - - const modelJsonURL = window.URL.createObjectURL( - new Blob([JSON.stringify(modelJSON)], {type: 'application/json'})); - - // If anchor elements are not provided, create them without attaching them - // to parents, so that the downloaded file names can be controlled. - const jsonAnchor = this.modelJsonAnchor == null ? - document.createElement('a') : - this.modelJsonAnchor; - jsonAnchor.download = this.modelJsonFileName; - jsonAnchor.href = modelJsonURL; - // Trigger downloads by evoking a click event on the download anchors. - // When multiple downloads are started synchronously, Firefox will only - // save the last one. - await defer(() => jsonAnchor.dispatchEvent(new MouseEvent('click'))); - - if (modelArtifacts.weightData != null) { - const weightDataAnchor = this.weightDataAnchor == null ? - document.createElement('a') : - this.weightDataAnchor; - weightDataAnchor.download = this.weightDataFileName; - weightDataAnchor.href = weightsURL; - await defer( - () => weightDataAnchor.dispatchEvent(new MouseEvent('click'))); - } - - return {modelArtifactsInfo: getModelArtifactsInfoForJSON(modelArtifacts)}; - } - } -} - -class BrowserFiles implements IOHandler { - private readonly jsonFile: File; - private readonly weightsFiles: File[]; - - constructor(files: File[]) { - if (files == null || files.length < 1) { - throw new Error( - `When calling browserFiles, at least 1 file is required, ` + - `but received ${files}`); - } - this.jsonFile = files[0]; - this.weightsFiles = files.slice(1); - } - - async load(): Promise { - return new Promise((resolve, reject) => { - const jsonReader = new FileReader(); - jsonReader.onload = (event: Event) => { - // tslint:disable-next-line:no-any - const modelJSON = JSON.parse((event.target as any).result) as ModelJSON; - - const modelTopology = modelJSON.modelTopology; - if (modelTopology == null) { - reject(new Error(`modelTopology field is missing from file ${ - this.jsonFile.name}`)); - return; - } - - const weightsManifest = modelJSON.weightsManifest; - if (weightsManifest == null) { - reject(new Error(`weightManifest field is missing from file ${ - this.jsonFile.name}`)); - return; - } - - if (this.weightsFiles.length === 0) { - resolve({modelTopology}); - return; - } - - const modelArtifactsPromise = getModelArtifactsForJSON( - modelJSON, (weightsManifest) => this.loadWeights(weightsManifest)); - resolve(modelArtifactsPromise); - }; - - jsonReader.onerror = error => reject( - `Failed to read model topology and weights manifest JSON ` + - `from file '${this.jsonFile.name}'. BrowserFiles supports loading ` + - `Keras-style tf.Model artifacts only.`); - jsonReader.readAsText(this.jsonFile); - }); - } - - private loadWeights(weightsManifest: WeightsManifestConfig): Promise<[ - /* weightSpecs */ WeightsManifestEntry[], WeightData, - ]> { - const weightSpecs: WeightsManifestEntry[] = []; - const paths: string[] = []; - for (const entry of weightsManifest) { - weightSpecs.push(...entry.weights); - paths.push(...entry.paths); - } - - const pathToFile: {[path: string]: File} = - this.checkManifestAndWeightFiles(weightsManifest); - - const promises: Array> = - paths.map(path => this.loadWeightsFile(path, pathToFile[path])); - - return Promise.all(promises).then( - buffers => [weightSpecs, buffers]); - } - - private loadWeightsFile(path: string, file: File): Promise { - return new Promise((resolve, reject) => { - const weightFileReader = new FileReader(); - weightFileReader.onload = (event: Event) => { - // tslint:disable-next-line:no-any - const weightData = (event.target as any).result as ArrayBuffer; - resolve(weightData); - }; - weightFileReader.onerror = error => - reject(`Failed to weights data from file of path '${path}'.`); - weightFileReader.readAsArrayBuffer(file); - }); - } - - /** - * Check the compatibility between weights manifest and weight files. - */ - private checkManifestAndWeightFiles(manifest: WeightsManifestConfig): - {[path: string]: File} { - const basenames: string[] = []; - const fileNames = this.weightsFiles.map(file => basename(file.name)); - const pathToFile: {[path: string]: File} = {}; - for (const group of manifest) { - group.paths.forEach(path => { - const pathBasename = basename(path); - if (basenames.indexOf(pathBasename) !== -1) { - throw new Error( - `Duplicate file basename found in weights manifest: ` + - `'${pathBasename}'`); - } - basenames.push(pathBasename); - if (fileNames.indexOf(pathBasename) === -1) { - throw new Error( - `Weight file with basename '${pathBasename}' is not provided.`); - } else { - pathToFile[path] = this.weightsFiles[fileNames.indexOf(pathBasename)]; - } - }); - } - - if (basenames.length !== this.weightsFiles.length) { - throw new Error( - `Mismatch in the number of files in weights manifest ` + - `(${basenames.length}) and the number of weight files provided ` + - `(${this.weightsFiles.length}).`); - } - return pathToFile; - } -} - -export const browserDownloadsRouter: IORouter = (url: string|string[]) => { - if (!env().getBool('IS_BROWSER')) { - return null; - } else { - if (!Array.isArray(url) && url.startsWith(BrowserDownloads.URL_SCHEME)) { - return browserDownloads(url.slice(BrowserDownloads.URL_SCHEME.length)); - } else { - return null; - } - } -}; -IORouterRegistry.registerSaveRouter(browserDownloadsRouter); - -/** - * Creates an IOHandler that triggers file downloads from the browser. - * - * The returned `IOHandler` instance can be used as model exporting methods such - * as `tf.Model.save` and supports only saving. - * - * ```js - * const model = tf.sequential(); - * model.add(tf.layers.dense( - * {units: 1, inputShape: [10], activation: 'sigmoid'})); - * const saveResult = await model.save('downloads://mymodel'); - * // This will trigger downloading of two files: - * // 'mymodel.json' and 'mymodel.weights.bin'. - * console.log(saveResult); - * ``` - * - * @param fileNamePrefix Prefix name of the files to be downloaded. For use with - * `tf.Model`, `fileNamePrefix` should follow either of the following two - * formats: - * 1. `null` or `undefined`, in which case the default file - * names will be used: - * - 'model.json' for the JSON file containing the model topology and - * weights manifest. - * - 'model.weights.bin' for the binary file containing the binary weight - * values. - * 2. A single string or an Array of a single string, as the file name prefix. - * For example, if `'foo'` is provided, the downloaded JSON - * file and binary weights file will be named 'foo.json' and - * 'foo.weights.bin', respectively. - * @param config Additional configuration for triggering downloads. - * @returns An instance of `BrowserDownloads` `IOHandler`. - * - * @doc { - * heading: 'Models', - * subheading: 'Loading', - * namespace: 'io', - * ignoreCI: true - * } - */ -export function browserDownloads(fileNamePrefix = 'model'): IOHandler { - return new BrowserDownloads(fileNamePrefix); -} - -/** - * Creates an IOHandler that loads model artifacts from user-selected files. - * - * This method can be used for loading from files such as user-selected files - * in the browser. - * When used in conjunction with `tf.loadLayersModel`, an instance of - * `tf.LayersModel` (Keras-style) can be constructed from the loaded artifacts. - * - * ```js - * // Note: This code snippet won't run properly without the actual file input - * // elements in the HTML DOM. - * - * // Suppose there are two HTML file input (``) - * // elements. - * const uploadJSONInput = document.getElementById('upload-json'); - * const uploadWeightsInput = document.getElementById('upload-weights'); - * const model = await tf.loadLayersModel(tf.io.browserFiles( - * [uploadJSONInput.files[0], uploadWeightsInput.files[0]])); - * ``` - * - * @param files `File`s to load from. Currently, this function supports only - * loading from files that contain Keras-style models (i.e., `tf.Model`s), for - * which an `Array` of `File`s is expected (in that order): - * - A JSON file containing the model topology and weight manifest. - * - Optionally, one or more binary files containing the binary weights. - * These files must have names that match the paths in the `weightsManifest` - * contained by the aforementioned JSON file, or errors will be thrown - * during loading. These weights files have the same format as the ones - * generated by `tensorflowjs_converter` that comes with the `tensorflowjs` - * Python PIP package. If no weights files are provided, only the model - * topology will be loaded from the JSON file above. - * @returns An instance of `Files` `IOHandler`. - * - * @doc { - * heading: 'Models', - * subheading: 'Loading', - * namespace: 'io', - * ignoreCI: true - * } - */ -export function browserFiles(files: File[]): IOHandler { - return new BrowserFiles(files); -} diff --git a/tfjs-master/tfjs-core/src/io/browser_files_test.ts b/tfjs-master/tfjs-core/src/io/browser_files_test.ts deleted file mode 100644 index 349cc1f17..000000000 --- a/tfjs-master/tfjs-core/src/io/browser_files_test.ts +++ /dev/null @@ -1,680 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -/** - * Unit tests for file-related IOHandlers. - */ - -import * as tf from '../index'; -import {BROWSER_ENVS, describeWithFlags} from '../jasmine_util'; -import {browserDownloads, BrowserDownloads, browserDownloadsRouter} from './browser_files'; -import {WeightsManifestConfig, WeightsManifestEntry} from './types'; -import {CompositeArrayBuffer} from './composite_array_buffer'; - -const modelTopology1: {} = { - 'class_name': 'Sequential', - 'keras_version': '2.1.4', - 'config': [{ - 'class_name': 'Dense', - 'config': { - 'kernel_initializer': { - 'class_name': 'VarianceScaling', - 'config': { - 'distribution': 'uniform', - 'scale': 1.0, - 'seed': null, - 'mode': 'fan_avg' - } - }, - 'name': 'dense', - 'kernel_constraint': null, - 'bias_regularizer': null, - 'bias_constraint': null, - 'dtype': 'float32', - 'activation': 'linear', - 'trainable': true, - 'kernel_regularizer': null, - 'bias_initializer': {'class_name': 'Zeros', 'config': {}}, - 'units': 1, - 'batch_input_shape': [null, 3], - 'use_bias': true, - 'activity_regularizer': null - } - }], - 'backend': 'tensorflow' -}; -const weightSpecs1: tf.io.WeightsManifestEntry[] = [ - { - name: 'dense/kernel', - shape: [3, 1], - dtype: 'float32', - }, - { - name: 'dense/bias', - shape: [1], - dtype: 'float32', - } -]; -const weightData1 = new ArrayBuffer(16); -const trainingConfig1: tf.io.TrainingConfig = { - loss: 'categorical_crossentropy', - metrics: ['accuracy'], - optimizer_config: {class_name: 'SGD', config: {learningRate: 0.1}} -}; - -const artifacts1: tf.io.ModelArtifacts = { - modelTopology: modelTopology1, - weightSpecs: weightSpecs1, - weightData: weightData1, - format: 'layers-model', - generatedBy: 'TensorFlow.js v0.0.0', - convertedBy: null, - modelInitializer: {}, - trainingConfig: trainingConfig1, -}; - -describeWithFlags('browserDownloads', BROWSER_ENVS, () => { - class FakeHTMLAnchorElement { - download: string; - href: string; - clicked: number; - - constructor() { - this.clicked = 0; - } - - dispatchEvent() { - this.clicked++; - } - } - - let fakeAnchors: FakeHTMLAnchorElement[] = []; - let fakeAnchorCount = 0; - - beforeEach(() => { - fakeAnchorCount = 0; - fakeAnchors = [new FakeHTMLAnchorElement(), new FakeHTMLAnchorElement()]; - spyOn(document, 'createElement').and.callFake((tag: string) => { - return fakeAnchors[fakeAnchorCount++] as unknown as HTMLElement; - }); - }); - - it('Explicit file name prefix, with existing anchors', async () => { - const testStartDate = new Date(); - const downloadTrigger = tf.io.getSaveHandlers('downloads://test-model')[0]; - const saveResult = await downloadTrigger.save(artifacts1); - expect(saveResult.errors).toEqual(undefined); - const artifactsInfo = saveResult.modelArtifactsInfo; - expect(artifactsInfo.dateSaved.getTime()) - .toBeGreaterThanOrEqual(testStartDate.getTime()); - expect(saveResult.modelArtifactsInfo.modelTopologyBytes) - .toEqual(JSON.stringify(modelTopology1).length); - expect(saveResult.modelArtifactsInfo.weightSpecsBytes) - .toEqual(JSON.stringify(weightSpecs1).length); - expect(saveResult.modelArtifactsInfo.weightDataBytes).toEqual(16); - - const jsonAnchor = fakeAnchors[0]; - const weightDataAnchor = fakeAnchors[1]; - expect(jsonAnchor.download).toEqual('test-model.json'); - expect(weightDataAnchor.download).toEqual('test-model.weights.bin'); - - // Verify the content of the JSON file. - const jsonContent = await fetch(jsonAnchor.href); - const modelJSON = JSON.parse(await jsonContent.text()) as tf.io.ModelJSON; - expect(modelJSON.modelTopology).toEqual(modelTopology1); - expect(modelJSON.format).toEqual('layers-model'); - expect(modelJSON.generatedBy).toEqual('TensorFlow.js v0.0.0'); - expect(modelJSON.convertedBy).toEqual(null); - expect(modelJSON.modelInitializer).toEqual({}); - expect(modelJSON.trainingConfig).toEqual(trainingConfig1); - - const weightsManifest = modelJSON.weightsManifest; - expect(weightsManifest.length).toEqual(1); - expect(weightsManifest[0].paths).toEqual(['./test-model.weights.bin']); - expect(weightsManifest[0].weights).toEqual(weightSpecs1); - - // Verify the content of the binary weights file. - const response = await fetch(weightDataAnchor.href); - const buffer = await response.arrayBuffer(); - expect(buffer).toEqual(weightData1); - - // Verify that the downloads are triggered through clicks. - expect(jsonAnchor.clicked).toEqual(1); - expect(weightDataAnchor.clicked).toEqual(1); - }); - - it('URL scheme in explicit name gets stripped', async () => { - const testStartDate = new Date(); - const downloadTrigger = browserDownloads('downloads://test-model'); - const saveResult = await downloadTrigger.save(artifacts1); - expect(saveResult.errors).toEqual(undefined); - const artifactsInfo = saveResult.modelArtifactsInfo; - expect(artifactsInfo.dateSaved.getTime()) - .toBeGreaterThanOrEqual(testStartDate.getTime()); - expect(saveResult.modelArtifactsInfo.modelTopologyBytes) - .toEqual(JSON.stringify(modelTopology1).length); - expect(saveResult.modelArtifactsInfo.weightSpecsBytes) - .toEqual(JSON.stringify(weightSpecs1).length); - expect(saveResult.modelArtifactsInfo.weightDataBytes).toEqual(16); - - const jsonAnchor = fakeAnchors[0]; - const weightDataAnchor = fakeAnchors[1]; - expect(jsonAnchor.download).toEqual('test-model.json'); - expect(weightDataAnchor.download).toEqual('test-model.weights.bin'); - - // Verify the content of the JSON file. - const jsonContent = await fetch(jsonAnchor.href); - const modelTopologyAndWeightsManifest = - JSON.parse(await jsonContent.text()); - expect(modelTopologyAndWeightsManifest.modelTopology) - .toEqual(modelTopology1); - const weightsManifest = modelTopologyAndWeightsManifest.weightsManifest as - WeightsManifestConfig; - expect(weightsManifest.length).toEqual(1); - expect(weightsManifest[0].paths).toEqual(['./test-model.weights.bin']); - expect(weightsManifest[0].weights).toEqual(weightSpecs1); - - // Verify the content of the binary weights file. - const response = await fetch(weightDataAnchor.href); - const buffer = await response.arrayBuffer(); - expect(buffer).toEqual(weightData1); - - // Verify that the downloads are triggered through clicks. - expect(jsonAnchor.clicked).toEqual(1); - expect(weightDataAnchor.clicked).toEqual(1); - }); - - it('No file name provided, with existing anchors', async () => { - const testStartDate = new Date(); - const downloadTrigger = browserDownloads(); - const saveResult = await downloadTrigger.save(artifacts1); - expect(saveResult.errors).toEqual(undefined); - const artifactsInfo = saveResult.modelArtifactsInfo; - expect(artifactsInfo.dateSaved.getTime()) - .toBeGreaterThanOrEqual(testStartDate.getTime()); - expect(saveResult.modelArtifactsInfo.modelTopologyBytes) - .toEqual(JSON.stringify(modelTopology1).length); - expect(saveResult.modelArtifactsInfo.weightSpecsBytes) - .toEqual(JSON.stringify(weightSpecs1).length); - expect(saveResult.modelArtifactsInfo.weightDataBytes).toEqual(16); - - const jsonAnchor = fakeAnchors[0]; - const weightDataAnchor = fakeAnchors[1]; - - // Verify that the default file names are used. - expect(jsonAnchor.download).toEqual('model.json'); - expect(weightDataAnchor.download).toEqual('model.weights.bin'); - - // Verify the content of the JSON file. - const jsonContent = await fetch(jsonAnchor.href); - const modelTopologyAndWeightsManifest = - JSON.parse(await jsonContent.text()); - expect(modelTopologyAndWeightsManifest.modelTopology) - .toEqual(modelTopology1); - const weightsManifest = modelTopologyAndWeightsManifest.weightsManifest as - WeightsManifestConfig; - expect(weightsManifest.length).toEqual(1); - expect(weightsManifest[0].paths).toEqual(['./model.weights.bin']); - expect(weightsManifest[0].weights).toEqual(weightSpecs1); - - // Verify the content of the binary weights file. - const response = await fetch(weightDataAnchor.href); - const buffer = await response.arrayBuffer(); - expect(buffer).toEqual(weightData1); - }); - - it('Download only model topology', async () => { - const testStartDate = new Date(); - const downloadTrigger = browserDownloads(); - const modelTopologyOnlyArtifacts: tf.io.ModelArtifacts = { - modelTopology: modelTopology1, - }; - const saveResult = await downloadTrigger.save(modelTopologyOnlyArtifacts); - expect(saveResult.errors).toEqual(undefined); - const artifactsInfo = saveResult.modelArtifactsInfo; - expect(artifactsInfo.dateSaved.getTime()) - .toBeGreaterThanOrEqual(testStartDate.getTime()); - expect(saveResult.modelArtifactsInfo.modelTopologyBytes) - .toEqual(JSON.stringify(modelTopology1).length); - expect(saveResult.modelArtifactsInfo.weightSpecsBytes).toEqual(0); - expect(saveResult.modelArtifactsInfo.weightDataBytes).toEqual(0); - - const jsonAnchor = fakeAnchors[0]; - const weightDataAnchor = fakeAnchors[1]; - - // Verify that the default file names are used. - expect(jsonAnchor.download).toEqual('model.json'); - expect(jsonAnchor.clicked).toEqual(1); - // The weight file should not have been downoaded. - expect(weightDataAnchor.download).toEqual(undefined); - expect(weightDataAnchor.clicked).toEqual(0); - - // Verify the content of the JSON file. - const jsonContent = await fetch(jsonAnchor.href); - const modelTopologyAndWeightsManifest = - JSON.parse(await jsonContent.text()); - expect(modelTopologyAndWeightsManifest.modelTopology) - .toEqual(modelTopology1); - }); - - it('browserDownloadsRouter', () => { - expect( - browserDownloadsRouter('downloads://foo') instanceof BrowserDownloads) - .toEqual(true); - expect(browserDownloadsRouter('invaliddownloads://foo')).toBeNull(); - expect(browserDownloadsRouter('foo')).toBeNull(); - }); -}); - -describeWithFlags('browserFiles', BROWSER_ENVS, () => { - const weightsFile = new File( - [weightData1], 'model.weights.bin', {type: 'application/octet-stream'}); - - it('One group, one path', async () => { - const weightsManifest: WeightsManifestConfig = [{ - paths: ['./model.weights.bin'], - weights: weightSpecs1, - }]; - const modelJSON: tf.io.ModelJSON = { - modelTopology: modelTopology1, - weightsManifest, - format: 'layers-model', - generatedBy: 'TensorFlow.js v0.0.0', - convertedBy: '1.13.1', - modelInitializer: {}, - trainingConfig: trainingConfig1, - }; - const jsonFile = new File( - [JSON.stringify(modelJSON)], 'model.json', {type: 'application/json'}); - - const filesHandler = tf.io.browserFiles([jsonFile, weightsFile]); - const modelArtifacts = await filesHandler.load(); - expect(modelArtifacts.modelTopology).toEqual(modelTopology1); - expect(modelArtifacts.weightSpecs).toEqual(weightSpecs1); - expect(modelArtifacts.format).toEqual('layers-model'); - expect(modelArtifacts.generatedBy).toEqual('TensorFlow.js v0.0.0'); - expect(modelArtifacts.convertedBy).toEqual('1.13.1'); - expect(modelArtifacts.modelInitializer).toEqual({}); - expect(modelArtifacts.trainingConfig).toEqual(trainingConfig1); - - expect(new Uint8Array(CompositeArrayBuffer.join(modelArtifacts.weightData))) - .toEqual(new Uint8Array(weightData1)); - }); - - it(`One group, two paths`, async () => { - const weightSpecs: WeightsManifestEntry[] = [ - { - name: 'foo', - shape: [1, 1], - dtype: 'float32', - }, - { - name: 'bar', - shape: [1, 1], - dtype: 'float32', - } - ]; - const weightsManifest: WeightsManifestConfig = [{ - paths: ['./dir1/model.weights.1.bin', './dir2/model.weights.2.bin'], - weights: weightSpecs, - }]; - const weightsTopologyAndManifest = { - modelTopology: modelTopology1, - weightsManifest, - }; - const weightsFile1 = new File( - [new Uint8Array([1, 2, 3, 4]).buffer], 'model.weights.1.bin', - {type: 'application/octet-stream'}); - const weightsFile2 = new File( - [new Uint8Array([10, 20, 30, 40]).buffer], 'model.weights.2.bin', - {type: 'application/octet-stream'}); - - const jsonFile = new File( - [JSON.stringify(weightsTopologyAndManifest)], 'model.json', - {type: 'application/json'}); - - const filesHandler = - tf.io.browserFiles([jsonFile, weightsFile1, weightsFile2]); - const modelArtifacts = await filesHandler.load(); - expect(modelArtifacts.modelTopology).toEqual(modelTopology1); - expect(modelArtifacts.weightSpecs).toEqual(weightSpecs); - expect(new Uint8Array(CompositeArrayBuffer.join(modelArtifacts.weightData))) - .toEqual(new Uint8Array([ - 1, 2, 3, 4, 10, 20, 30, 40 - ])); - }); - - it(`Two groups, four paths, reverseOrder=false`, async () => { - const weightSpecs1: WeightsManifestEntry[] = [ - { - name: 'foo', - shape: [1, 1], - dtype: 'float32', - }, - { - name: 'bar', - shape: [1, 1], - dtype: 'float32', - } - ]; - const weightSpecs2: WeightsManifestEntry[] = [ - { - name: 'baz', - shape: [1, 1], - dtype: 'float32', - }, - { - name: 'qux', - shape: [1, 1], - dtype: 'float32', - } - ]; - const weightsManifest: WeightsManifestConfig = [ - { - paths: ['./model.weights.1.bin', './model.weights.2.bin'], - weights: weightSpecs1, - }, - { - paths: ['./model.weights.3.bin', './model.weights.4.bin'], - weights: weightSpecs2, - } - ]; - const weightsTopologyAndManifest = { - modelTopology: modelTopology1, - weightsManifest, - }; - const weightsFile1 = new File( - [new Uint8Array([1, 3, 5, 7]).buffer], 'model.weights.1.bin', - {type: 'application/octet-stream'}); - const weightsFile2 = new File( - [new Uint8Array([10, 30, 50, 70]).buffer], 'model.weights.2.bin', - {type: 'application/octet-stream'}); - const weightsFile3 = new File( - [new Uint8Array([2, 4, 6, 8]).buffer], 'model.weights.3.bin', - {type: 'application/octet-stream'}); - const weightsFile4 = new File( - [new Uint8Array([20, 40, 60, 80]).buffer], 'model.weights.4.bin', - {type: 'application/octet-stream'}); - - const jsonFile = new File( - [JSON.stringify(weightsTopologyAndManifest)], 'model.json', - {type: 'application/json'}); - - const filesHandler = tf.io.browserFiles( - [jsonFile, weightsFile1, weightsFile2, weightsFile3, weightsFile4]); - const modelArtifacts = await filesHandler.load(); - expect(modelArtifacts.modelTopology).toEqual(modelTopology1); - expect(modelArtifacts.weightSpecs) - .toEqual(weightSpecs1.concat(weightSpecs2)); - expect(new Uint8Array(CompositeArrayBuffer.join(modelArtifacts.weightData))) - .toEqual(new Uint8Array([ - 1, 3, 5, 7, 10, 30, 50, 70, 2, 4, 6, 8, 20, 40, 60, 80 - ])); - }); - - it(`Two groups, four paths, reverseOrder=true`, async () => { - const weightSpecs1: WeightsManifestEntry[] = [ - { - name: 'foo', - shape: [1, 1], - dtype: 'float32', - }, - { - name: 'bar', - shape: [1, 1], - dtype: 'float32', - } - ]; - const weightSpecs2: WeightsManifestEntry[] = [ - { - name: 'baz', - shape: [1, 1], - dtype: 'float32', - }, - { - name: 'qux', - shape: [1, 1], - dtype: 'float32', - } - ]; - const weightsManifest: WeightsManifestConfig = [ - { - paths: ['./model.weights.1.bin', './model.weights.2.bin'], - weights: weightSpecs1, - }, - { - paths: ['./model.weights.3.bin', './model.weights.4.bin'], - weights: weightSpecs2, - } - ]; - const weightsTopologyAndManifest = { - modelTopology: modelTopology1, - weightsManifest, - }; - const weightsFile1 = new File( - [new Uint8Array([1, 3, 5, 7]).buffer], 'model.weights.1.bin', - {type: 'application/octet-stream'}); - const weightsFile2 = new File( - [new Uint8Array([10, 30, 50, 70]).buffer], 'model.weights.2.bin', - {type: 'application/octet-stream'}); - const weightsFile3 = new File( - [new Uint8Array([2, 4, 6, 8]).buffer], 'model.weights.3.bin', - {type: 'application/octet-stream'}); - const weightsFile4 = new File( - [new Uint8Array([20, 40, 60, 80]).buffer], 'model.weights.4.bin', - {type: 'application/octet-stream'}); - - const jsonFile = new File( - [JSON.stringify(weightsTopologyAndManifest)], 'model.json', - {type: 'application/json'}); - - const filesHandler = tf.io.browserFiles( - [jsonFile, weightsFile4, weightsFile3, weightsFile2, weightsFile1]); - const modelArtifacts = await filesHandler.load(); - expect(modelArtifacts.modelTopology).toEqual(modelTopology1); - expect(modelArtifacts.weightSpecs) - .toEqual(weightSpecs1.concat(weightSpecs2)); - expect(new Uint8Array(CompositeArrayBuffer.join(modelArtifacts.weightData))) - .toEqual(new Uint8Array([ - 1, 3, 5, 7, 10, 30, 50, 70, 2, 4, 6, 8, 20, 40, 60, 80 - ])); - }); - - it('Upload model topology only', async () => { - const weightsManifest: WeightsManifestConfig = [{ - paths: ['./model.weights.bin'], - weights: weightSpecs1, - }]; - const weightsTopologyAndManifest = { - modelTopology: modelTopology1, - weightsManifest, - }; - const jsonFile = new File( - [JSON.stringify(weightsTopologyAndManifest)], 'model.json', - {type: 'application/json'}); - - // Select only a JSON file. - const filesHandler = tf.io.browserFiles([jsonFile]); - const modelArtifacts = await filesHandler.load(); - expect(modelArtifacts.modelTopology).toEqual(modelTopology1); - expect(modelArtifacts.weightSpecs).toEqual(undefined); - }); - - it('Mismatch in number of paths and number of files', async () => { - const weightsManifest: WeightsManifestConfig = [{ - paths: ['./model.weights.1.bin'], - weights: weightSpecs1, - }]; - const weightsTopologyAndManifest = { - modelTopology: weightSpecs1, - weightsManifest, - }; - const weightsFile1 = new File( - [new Uint8Array([1, 2, 3, 4]).buffer], 'model.weights.1.bin', - {type: 'application/octet-stream'}); - const weightsFile2 = new File( - [new Uint8Array([10, 20, 30, 40]).buffer], 'model.weights.2.bin', - {type: 'application/octet-stream'}); - - const jsonFile = new File( - [JSON.stringify(weightsTopologyAndManifest)], 'model.json', - {type: 'application/json'}); - - // Supply two weights files while the manifest has only one path. This is - // expected to fail. - const filesHandler = - tf.io.browserFiles([jsonFile, weightsFile2, weightsFile1]); - try { - await filesHandler.load(); - fail( - 'Loading with mismatch in number of paths and number of files ' + - 'succeeded unexpectedly.'); - } catch (err) { - expect(err.message) - .toEqual( - 'Mismatch in the number of files in weights manifest (1) ' + - 'and the number of weight files provided (2).'); - } - }); - - it('Mismatch in manifest paths and file names', async () => { - const weightSpecs: WeightsManifestEntry[] = [ - { - name: 'foo', - shape: [1, 1], - dtype: 'float32', - }, - { - name: 'bar', - shape: [1, 1], - dtype: 'float32', - } - ]; - const weightsManifest: WeightsManifestConfig = [{ - paths: ['./model.weights.1.bin', './model.weights.2.bin'], - weights: weightSpecs, - }]; - const weightsTopologyAndManifest = { - modelTopology: modelTopology1, - weightsManifest, - }; - const weightsFile1 = new File( - [new Uint8Array([1, 2, 3, 4]).buffer], 'model.weights.1.bin', - {type: 'application/octet-stream'}); - const weightsFile2 = new File( - [new Uint8Array([10, 20, 30, 40]).buffer], 'model.weights.3.bin', - {type: 'application/octet-stream'}); - // Notice the wrong file name here. It is expected to cause load() to - // fail. - - const jsonFile = new File( - [JSON.stringify(weightsTopologyAndManifest)], 'model.json', - {type: 'application/json'}); - - const filesHandler = - tf.io.browserFiles([jsonFile, weightsFile1, weightsFile2]); - try { - await filesHandler.load(); - fail( - 'Loading with mismatching paths and file names ' + - 'succeeded unexpectedly.'); - } catch (err) { - expect(err.message) - .toEqual( - 'Weight file with basename \'model.weights.2.bin\' is not ' + - 'provided.'); - } - }); - - it('Duplicate basenames in paths fails', async () => { - const weightSpecs: WeightsManifestEntry[] = [ - { - name: 'foo', - shape: [1, 1], - dtype: 'float32', - }, - { - name: 'bar', - shape: [1, 1], - dtype: 'float32', - } - ]; - // Notice the duplicate basenames here (albeit distinct full paths). This - // is expected to cause load() to fail. - const weightsManifest: WeightsManifestConfig = [{ - paths: ['./dir1/model.weights.1.bin', './dir2/model.weights.1.bin'], - weights: weightSpecs, - }]; - const weightsTopologyAndManifest = { - modelTopology: modelTopology1, - weightsManifest, - }; - const weightsFile1 = new File( - [new Uint8Array([1, 2, 3, 4]).buffer], 'model.weights.1.bin', - {type: 'application/octet-stream'}); - const weightsFile2 = new File( - [new Uint8Array([10, 20, 30, 40]).buffer], 'model.weights.2.bin', - {type: 'application/octet-stream'}); - // Notice the wrong file name here. It is expected to cause load() to - // fail. - - const jsonFile = new File( - [JSON.stringify(weightsTopologyAndManifest)], 'model.json', - {type: 'application/json'}); - - const filesHandler = - tf.io.browserFiles([jsonFile, weightsFile1, weightsFile2]); - try { - await filesHandler.load(); - fail('Loading with duplicate basenames in paths succeeded unexpectedly.'); - } catch (err) { - expect(err.message) - .toEqual( - 'Duplicate file basename found in weights manifest: ' + - '\'model.weights.1.bin\''); - } - }); - - it('Missing modelTopology from JSON leads to Error', async () => { - const weightsManifest: WeightsManifestConfig = [{ - paths: ['./model.weights.bin'], - weights: weightSpecs1, - }]; - const weightsTopologyAndManifest = { - weightsManifest, - }; - const jsonFile = new File( - [JSON.stringify(weightsTopologyAndManifest)], 'model.json', - {type: 'application/json'}); - - const filesHandler = tf.io.browserFiles([jsonFile, weightsFile]); - try { - await filesHandler.load(); - fail( - 'Loading with Files IOHandler with missing modelTopology ' + - 'succeeded unexpectedly.'); - } catch (err) { - expect(err.message) - .toMatch(/modelTopology field is missing from file model\.json/); - } - }); - - it('Incorrect number of files leads to Error', () => { - expect(() => tf.io.browserFiles(null)).toThrowError(/at least 1 file/); - expect(() => tf.io.browserFiles([])).toThrowError(/at least 1 file/); - }); -}); diff --git a/tfjs-master/tfjs-core/src/io/composite_array_buffer.ts b/tfjs-master/tfjs-core/src/io/composite_array_buffer.ts deleted file mode 100644 index 411fb0740..000000000 --- a/tfjs-master/tfjs-core/src/io/composite_array_buffer.ts +++ /dev/null @@ -1,226 +0,0 @@ -/** - * @license - * Copyright 2023 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {TypedArray} from '../types'; -import * as util from '../util'; - -type BufferShard = { - start: number, - end: number, - buffer: ArrayBuffer, -}; - -/** - * Wraps a list of ArrayBuffers into a `slice()`-able object without allocating - * a large ArrayBuffer. - * - * Allocating large ArrayBuffers (~2GB) can be unstable on Chrome. TFJS loads - * its weights as a list of (usually) 4MB ArrayBuffers and then slices the - * weight tensors out of them. For small models, it's safe to concatenate all - * the weight buffers into a single ArrayBuffer and then slice the weight - * tensors out of it, but for large models, a different approach is needed. - */ - -export class CompositeArrayBuffer { - private shards: BufferShard[] = []; - private previousShardIndex = 0; - private bufferUniformSize?: number; - public readonly byteLength: number; - - /** - * Concatenate a number of ArrayBuffers into one. - * - * @param buffers An array of ArrayBuffers to concatenate, or a single - * ArrayBuffer. - * @returns Result of concatenating `buffers` in order. - */ - static join(buffers?: ArrayBuffer[] | ArrayBuffer) { - return new CompositeArrayBuffer(buffers).slice(); - } - - constructor(buffers?: ArrayBuffer | ArrayBuffer[] | TypedArray | - TypedArray[]) { - if (buffers == null) { - return; - } - // Normalize the `buffers` input to be `ArrayBuffer[]`. - if (!(buffers instanceof Array)) { - buffers = [buffers]; - } - buffers = buffers.map((bufferOrTypedArray) => { - if (util.isTypedArray(bufferOrTypedArray)) { - return bufferOrTypedArray.buffer; - } - return bufferOrTypedArray; - }); - - // Skip setting up shards if there are no buffers. - if (buffers.length === 0) { - return; - } - - this.bufferUniformSize = buffers[0].byteLength; - let start = 0; - - for (let i = 0; i < buffers.length; i++) { - const buffer = buffers[i]; - // Check that all buffers except the last one have the same length. - if (i !== buffers.length - 1 && - buffer.byteLength !== this.bufferUniformSize) { - // Unset the buffer uniform size, since the buffer sizes are not - // uniform. - this.bufferUniformSize = undefined; - } - - // Create the shards, including their start and end points. - const end = start + buffer.byteLength; - this.shards.push({ buffer, start, end }); - start = end; - } - - // Set the byteLenghth - if (this.shards.length === 0) { - this.byteLength = 0; - } - this.byteLength = this.shards[this.shards.length - 1].end; - } - - slice(start = 0, end = this.byteLength): ArrayBuffer { - // If there are no shards, then the CompositeArrayBuffer was initialized - // with no data. - if (this.shards.length === 0) { - return new ArrayBuffer(0); - } - - // NaN is treated as zero for slicing. This matches ArrayBuffer's behavior. - start = isNaN(Number(start)) ? 0 : start; - end = isNaN(Number(end)) ? 0 : end; - - // Fix the bounds to within the array. - start = Math.max(0, start); - end = Math.min(this.byteLength, end); - if (end <= start) { - return new ArrayBuffer(0); - } - - const startShardIndex = this.findShardForByte(start); - if (startShardIndex === -1) { - // This should not happen since the start and end indices are always - // within 0 and the composite array's length. - throw new Error(`Could not find start shard for byte ${start}`); - } - - const size = end - start; - const outputBuffer = new ArrayBuffer(size); - const outputArray = new Uint8Array(outputBuffer); - let sliced = 0; - for (let i = startShardIndex; i < this.shards.length; i++) { - const shard = this.shards[i]; - - const globalStart = start + sliced; - const localStart = globalStart - shard.start; - const outputStart = sliced; - - const globalEnd = Math.min(end, shard.end); - const localEnd = globalEnd - shard.start; - - const outputSlice = new Uint8Array(shard.buffer, localStart, - localEnd - localStart); - outputArray.set(outputSlice, outputStart); - sliced += outputSlice.length; - - if (end < shard.end) { - break; - } - } - return outputBuffer; - } - - /** - * Get the index of the shard that contains the byte at `byteIndex`. - */ - private findShardForByte(byteIndex: number): number { - if (this.shards.length === 0 || byteIndex < 0 || - byteIndex >= this.byteLength) { - return -1; - } - - // If the buffers have a uniform size, compute the shard directly. - if (this.bufferUniformSize != null) { - this.previousShardIndex = Math.floor(byteIndex / this.bufferUniformSize); - return this.previousShardIndex; - } - - // If the buffers don't have a uniform size, we need to search for the - // shard. That means we need a function to check where the byteIndex lies - // relative to a given shard. - function check(shard: BufferShard) { - if (byteIndex < shard.start) { - return -1; - } - if (byteIndex >= shard.end) { - return 1; - } - return 0; - } - - // For efficiency, try the previous shard first. - if (check(this.shards[this.previousShardIndex]) === 0) { - return this.previousShardIndex; - } - - // Otherwise, use a generic search function. - // This should almost never end up being used in practice since the weight - // entries should always be in order. - const index = search(this.shards, check); - if (index === -1) { - return -1; - } - - this.previousShardIndex = index; - return this.previousShardIndex; - } -} - -/** - * Search for an element of a sorted array. - * - * @param sortedArray The sorted array to search - * @param compare A function to compare the current value against the searched - * value. Return 0 on a match, negative if the searched value is less than - * the value passed to the function, and positive if the searched value is - * greater than the value passed to the function. - * @returns The index of the element, or -1 if it's not in the array. - */ -export function search(sortedArray: T[], compare: (t: T) => number): number { - // Binary search - let min = 0; - let max = sortedArray.length; - - while (min <= max) { - const middle = Math.floor((max - min) / 2) + min; - const side = compare(sortedArray[middle]); - - if (side === 0) { - return middle; - } else if (side < 0) { - max = middle; - } else { - min = middle + 1; - } - } - return -1; -} diff --git a/tfjs-master/tfjs-core/src/io/composite_array_buffer_test.ts b/tfjs-master/tfjs-core/src/io/composite_array_buffer_test.ts deleted file mode 100644 index 0c88bc4ad..000000000 --- a/tfjs-master/tfjs-core/src/io/composite_array_buffer_test.ts +++ /dev/null @@ -1,126 +0,0 @@ -/** - * @license - * Copyright 2023 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {expectArraysEqual} from '../test_util'; -import {CompositeArrayBuffer} from './composite_array_buffer'; - -describe('CompositeArrayBuffer', () => { - const uniformBuffers = [ - new Uint8Array([0, 1, 2, 3]).buffer, - new Uint8Array([4, 5, 6, 7]).buffer, - new Uint8Array([8, 9, 10, 11]).buffer, - new Uint8Array([12, 13, 14, 15]).buffer, - new Uint8Array([16]).buffer, - ]; - - const nonUniformBuffers = [ - new Uint8Array([0, 1, 2]).buffer, - new Uint8Array([3, 4, 5, 6, 7]).buffer, - new Uint8Array([8, 9, 10, 11]).buffer, - new Uint8Array([12, 13, 14, 15, 16]).buffer, - ]; - - const bufferTestCases = [ - ['uniform', uniformBuffers], - ['non-uniform', nonUniformBuffers] - ] as const; - - for (const [buffersType, buffers] of bufferTestCases) { - let composite: CompositeArrayBuffer; - beforeEach(() => { - composite = new CompositeArrayBuffer(buffers); - }); - - it(`${buffersType}: slices across multiple buffers`, () => { - expectArraysEqual(new Uint8Array(composite.slice(1, 13)), - [1,2,3,4,5,6,7,8,9,10,11,12]); - }); - - it(`${buffersType}: slices to the end of the array when \'end\' is not ` + - 'specified', () => { - expectArraysEqual(new Uint8Array(composite.slice(5)), - [5,6,7,8,9,10,11,12,13,14,15,16]); - }); - - it(`${buffersType}: makes a copy when slice() is called with no arguments`, - () => { - expectArraysEqual(new Uint8Array(composite.slice()), - [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]); - }); - - it(`${buffersType}: slices from zero when start is negative`, () => { - expectArraysEqual(new Uint8Array(composite.slice(-4, 5)), - [0,1,2,3,4]); - }); - - it(`${buffersType}: slices to the end when end is greater than length`, - () => { - expectArraysEqual(new Uint8Array(composite.slice(7, 1000)), - [7,8,9,10,11,12,13,14,15,16]); - }); - - it(`${buffersType}: slices multiple ranges out of order`, () => { - expectArraysEqual(new Uint8Array(composite.slice(13, 15)), [13, 14]); - expectArraysEqual(new Uint8Array(composite.slice(0, 2)), [0, 1]); - expectArraysEqual(new Uint8Array(composite.slice(9, 13)), - [9, 10, 11, 12]); - }); - } - - it('can be created from an empty arraybuffer', () => { - const array = new Uint8Array([]); - const singleComposite = new CompositeArrayBuffer(array.buffer); - expectArraysEqual(new Uint8Array(singleComposite.slice()), []); - }); - - it('can be created from a single array', () => { - const array = new Uint8Array([1,2,3]); - const singleComposite = new CompositeArrayBuffer(array.buffer); - expectArraysEqual(new Uint8Array(singleComposite.slice()), array); - }); - - it('can be created from zero arrays', () => { - const singleComposite = new CompositeArrayBuffer([]); - expectArraysEqual(new Uint8Array(singleComposite.slice()), - new Uint8Array()); - }); - - it('can be created from undefined input', () => { - const singleComposite = new CompositeArrayBuffer(); - expectArraysEqual(new Uint8Array(singleComposite.slice()), - new Uint8Array()); - }); - - it('treats NaN as zero when passed as the start of slice', () => { - const array = new Uint8Array([1,2,3]); - const composite = new CompositeArrayBuffer(array.buffer); - expectArraysEqual(new Uint8Array(composite.slice(NaN, 2)), [1,2]); - }); - - it('treats NaN as zero when passed as the end of slice', () => { - const array = new Uint8Array([1,2,3]); - const composite = new CompositeArrayBuffer(array.buffer); - expectArraysEqual(new Uint8Array(composite.slice(0, NaN)), []); - }); - - it('supports TypedArray input', () => { - // This support is necessary for some tests in tfjs-converter. Maybe those - // tests are misconfigured? - const array = new Uint8Array([1,2,3]); - const composite = new CompositeArrayBuffer(array); - expectArraysEqual(new Uint8Array(composite.slice(0, 2)), [1,2]); - }); -}); diff --git a/tfjs-master/tfjs-core/src/io/http.ts b/tfjs-master/tfjs-core/src/io/http.ts deleted file mode 100644 index c30ce501d..000000000 --- a/tfjs-master/tfjs-core/src/io/http.ts +++ /dev/null @@ -1,352 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -/** - * IOHandler implementations based on HTTP requests in the web browser. - * - * Uses [`fetch`](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API). - */ - -import {env} from '../environment'; - -import {assert} from '../util'; -import {getModelArtifactsForJSON, getModelArtifactsInfoForJSON, getModelJSONForModelArtifacts, getWeightSpecs} from './io_utils'; -import {CompositeArrayBuffer} from './composite_array_buffer'; -import {IORouter, IORouterRegistry} from './router_registry'; -import {IOHandler, LoadOptions, ModelArtifacts, ModelJSON, OnProgressCallback, SaveResult, WeightData, WeightsManifestConfig, WeightsManifestEntry} from './types'; -import {loadWeightsAsArrayBuffer} from './weights_loader'; - -const OCTET_STREAM_MIME_TYPE = 'application/octet-stream'; -const JSON_TYPE = 'application/json'; -export class HTTPRequest implements IOHandler { - protected readonly path: string; - protected readonly requestInit: RequestInit; - - private readonly fetch: Function; - private readonly weightUrlConverter: (weightName: string) => Promise; - - readonly DEFAULT_METHOD = 'POST'; - - static readonly URL_SCHEME_REGEX = /^https?:\/\//; - - private readonly weightPathPrefix: string; - private readonly onProgress: OnProgressCallback; - - constructor(path: string, loadOptions?: LoadOptions) { - if (loadOptions == null) { - loadOptions = {}; - } - this.weightPathPrefix = loadOptions.weightPathPrefix; - this.onProgress = loadOptions.onProgress; - this.weightUrlConverter = loadOptions.weightUrlConverter; - - if (loadOptions.fetchFunc != null) { - assert( - typeof loadOptions.fetchFunc === 'function', - () => 'Must pass a function that matches the signature of ' + - '`fetch` (see ' + - 'https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API)'); - this.fetch = loadOptions.fetchFunc; - } else { - this.fetch = env().platform.fetch; - } - - assert( - path != null && path.length > 0, - () => 'URL path for http must not be null, undefined or ' + - 'empty.'); - - if (Array.isArray(path)) { - assert( - path.length === 2, - () => 'URL paths for http must have a length of 2, ' + - `(actual length is ${path.length}).`); - } - this.path = path; - - if (loadOptions.requestInit != null && - loadOptions.requestInit.body != null) { - throw new Error( - 'requestInit is expected to have no pre-existing body, but has one.'); - } - this.requestInit = loadOptions.requestInit || {}; - } - - async save(modelArtifacts: ModelArtifacts): Promise { - if (modelArtifacts.modelTopology instanceof ArrayBuffer) { - throw new Error( - 'BrowserHTTPRequest.save() does not support saving model topology ' + - 'in binary formats yet.'); - } - - const init = Object.assign({method: this.DEFAULT_METHOD}, this.requestInit); - init.body = new FormData(); - - const weightsManifest: WeightsManifestConfig = [{ - paths: ['./model.weights.bin'], - weights: modelArtifacts.weightSpecs, - }]; - const modelTopologyAndWeightManifest: ModelJSON = - getModelJSONForModelArtifacts(modelArtifacts, weightsManifest); - - init.body.append( - 'model.json', - new Blob( - [JSON.stringify(modelTopologyAndWeightManifest)], - {type: JSON_TYPE}), - 'model.json'); - - if (modelArtifacts.weightData != null) { - // TODO(mattsoulanille): Support saving models over 2GB that exceed - // Chrome's ArrayBuffer size limit. - const weightBuffer = CompositeArrayBuffer.join(modelArtifacts.weightData); - - init.body.append( - 'model.weights.bin', - new Blob([weightBuffer], {type: OCTET_STREAM_MIME_TYPE}), - 'model.weights.bin'); - } - - const response = await this.fetch(this.path, init); - - if (response.ok) { - return { - modelArtifactsInfo: getModelArtifactsInfoForJSON(modelArtifacts), - responses: [response], - }; - } else { - throw new Error( - `BrowserHTTPRequest.save() failed due to HTTP response status ` + - `${response.status}.`); - } - } - - /** - * Load model artifacts via HTTP request(s). - * - * See the documentation to `tf.io.http` for details on the saved - * artifacts. - * - * @returns The loaded model artifacts (if loading succeeds). - */ - async load(): Promise { - const modelConfigRequest = await this.fetch(this.path, this.requestInit); - - if (!modelConfigRequest.ok) { - throw new Error( - `Request to ${this.path} failed with status code ` + - `${modelConfigRequest.status}. Please verify this URL points to ` + - `the model JSON of the model to load.`); - } - let modelJSON: ModelJSON; - try { - modelJSON = await modelConfigRequest.json(); - } catch (e) { - let message = `Failed to parse model JSON of response from ${this.path}.`; - // TODO(nsthorat): Remove this after some time when we're comfortable that - // .pb files are mostly gone. - if (this.path.endsWith('.pb')) { - message += ' Your path contains a .pb file extension. ' + - 'Support for .pb models have been removed in TensorFlow.js 1.0 ' + - 'in favor of .json models. You can re-convert your Python ' + - 'TensorFlow model using the TensorFlow.js 1.0 conversion scripts ' + - 'or you can convert your.pb models with the \'pb2json\'' + - 'NPM script in the tensorflow/tfjs-converter repository.'; - } else { - message += ' Please make sure the server is serving valid ' + - 'JSON for this request.'; - } - throw new Error(message); - } - - // We do not allow both modelTopology and weightsManifest to be missing. - const modelTopology = modelJSON.modelTopology; - const weightsManifest = modelJSON.weightsManifest; - if (modelTopology == null && weightsManifest == null) { - throw new Error( - `The JSON from HTTP path ${this.path} contains neither model ` + - `topology or manifest for weights.`); - } - - return getModelArtifactsForJSON( - modelJSON, (weightsManifest) => this.loadWeights(weightsManifest)); - } - - private async loadWeights(weightsManifest: WeightsManifestConfig): - Promise<[WeightsManifestEntry[], WeightData]> { - const weightPath = Array.isArray(this.path) ? this.path[1] : this.path; - const [prefix, suffix] = parseUrl(weightPath); - const pathPrefix = this.weightPathPrefix || prefix; - - const weightSpecs = getWeightSpecs(weightsManifest); - - const fetchURLs: string[] = []; - const urlPromises: Array> = []; - for (const weightsGroup of weightsManifest) { - for (const path of weightsGroup.paths) { - if (this.weightUrlConverter != null) { - urlPromises.push(this.weightUrlConverter(path)); - } else { - fetchURLs.push(pathPrefix + path + suffix); - } - } - } - - if (this.weightUrlConverter) { - fetchURLs.push(...await Promise.all(urlPromises)); - } - - const buffers = await loadWeightsAsArrayBuffer(fetchURLs, { - requestInit: this.requestInit, - fetchFunc: this.fetch, - onProgress: this.onProgress - }); - return [weightSpecs, buffers]; - } -} - -/** - * Extract the prefix and suffix of the url, where the prefix is the path before - * the last file, and suffix is the search params after the last file. - * ``` - * const url = 'http://tfhub.dev/model/1/tensorflowjs_model.pb?tfjs-format=file' - * [prefix, suffix] = parseUrl(url) - * // prefix = 'http://tfhub.dev/model/1/' - * // suffix = '?tfjs-format=file' - * ``` - * @param url the model url to be parsed. - */ -export function parseUrl(url: string): [string, string] { - const lastSlash = url.lastIndexOf('/'); - const lastSearchParam = url.lastIndexOf('?'); - const prefix = url.substring(0, lastSlash); - const suffix = - lastSearchParam > lastSlash ? url.substring(lastSearchParam) : ''; - return [prefix + '/', suffix]; -} - -export function isHTTPScheme(url: string): boolean { - return url.match(HTTPRequest.URL_SCHEME_REGEX) != null; -} - -export const httpRouter: IORouter = - (url: string, loadOptions?: LoadOptions) => { - if (typeof fetch === 'undefined' && - (loadOptions == null || loadOptions.fetchFunc == null)) { - // `http` uses `fetch` or `node-fetch`, if one wants to use it in - // an environment that is not the browser or node they have to setup a - // global fetch polyfill. - return null; - } else { - let isHTTP = true; - if (Array.isArray(url)) { - isHTTP = url.every(urlItem => isHTTPScheme(urlItem)); - } else { - isHTTP = isHTTPScheme(url); - } - if (isHTTP) { - return http(url, loadOptions); - } - } - return null; - }; -IORouterRegistry.registerSaveRouter(httpRouter); -IORouterRegistry.registerLoadRouter(httpRouter); - -/** - * Creates an IOHandler subtype that sends model artifacts to HTTP server. - * - * An HTTP request of the `multipart/form-data` mime type will be sent to the - * `path` URL. The form data includes artifacts that represent the topology - * and/or weights of the model. In the case of Keras-style `tf.Model`, two - * blobs (files) exist in form-data: - * - A JSON file consisting of `modelTopology` and `weightsManifest`. - * - A binary weights file consisting of the concatenated weight values. - * These files are in the same format as the one generated by - * [tfjs_converter](https://js.tensorflow.org/tutorials/import-keras.html). - * - * The following code snippet exemplifies the client-side code that uses this - * function: - * - * ```js - * const model = tf.sequential(); - * model.add( - * tf.layers.dense({units: 1, inputShape: [100], activation: 'sigmoid'})); - * - * const saveResult = await model.save(tf.io.http( - * 'http://model-server:5000/upload', {requestInit: {method: 'PUT'}})); - * console.log(saveResult); - * ``` - * - * If the default `POST` method is to be used, without any custom parameters - * such as headers, you can simply pass an HTTP or HTTPS URL to `model.save`: - * - * ```js - * const saveResult = await model.save('http://model-server:5000/upload'); - * ``` - * - * The following GitHub Gist - * https://gist.github.com/dsmilkov/1b6046fd6132d7408d5257b0976f7864 - * implements a server based on [flask](https://github.com/pallets/flask) that - * can receive the request. Upon receiving the model artifacts via the requst, - * this particular server reconstitutes instances of [Keras - * Models](https://keras.io/models/model/) in memory. - * - * - * @param path A URL path to the model. - * Can be an absolute HTTP path (e.g., - * 'http://localhost:8000/model-upload)') or a relative path (e.g., - * './model-upload'). - * @param requestInit Request configurations to be used when sending - * HTTP request to server using `fetch`. It can contain fields such as - * `method`, `credentials`, `headers`, `mode`, etc. See - * https://developer.mozilla.org/en-US/docs/Web/API/Request/Request - * for more information. `requestInit` must not have a body, because the - * body will be set by TensorFlow.js. File blobs representing the model - * topology (filename: 'model.json') and the weights of the model (filename: - * 'model.weights.bin') will be appended to the body. If `requestInit` has a - * `body`, an Error will be thrown. - * @param loadOptions Optional configuration for the loading. It includes the - * following fields: - * - weightPathPrefix Optional, this specifies the path prefix for weight - * files, by default this is calculated from the path param. - * - fetchFunc Optional, custom `fetch` function. E.g., in Node.js, - * the `fetch` from node-fetch can be used here. - * - onProgress Optional, progress callback function, fired periodically - * before the load is completed. - * @returns An instance of `IOHandler`. - * - * @doc { - * heading: 'Models', - * subheading: 'Loading', - * namespace: 'io', - * ignoreCI: true - * } - */ -export function http(path: string, loadOptions?: LoadOptions): IOHandler { - return new HTTPRequest(path, loadOptions); -} - -/** - * Deprecated. Use `tf.io.http`. - * @param path - * @param loadOptions - */ -export function browserHTTPRequest( - path: string, loadOptions?: LoadOptions): IOHandler { - return http(path, loadOptions); -} diff --git a/tfjs-master/tfjs-core/src/io/http_test.ts b/tfjs-master/tfjs-core/src/io/http_test.ts deleted file mode 100644 index 18b868940..000000000 --- a/tfjs-master/tfjs-core/src/io/http_test.ts +++ /dev/null @@ -1,920 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {BROWSER_ENVS, CHROME_ENVS, describeWithFlags, NODE_ENVS} from '../jasmine_util'; -import {HTTPRequest, httpRouter, parseUrl} from './http'; -import {CompositeArrayBuffer} from './composite_array_buffer'; - -// Test data. -const modelTopology1: {} = { - 'class_name': 'Sequential', - 'keras_version': '2.1.4', - 'config': [{ - 'class_name': 'Dense', - 'config': { - 'kernel_initializer': { - 'class_name': 'VarianceScaling', - 'config': { - 'distribution': 'uniform', - 'scale': 1.0, - 'seed': null, - 'mode': 'fan_avg' - } - }, - 'name': 'dense', - 'kernel_constraint': null, - 'bias_regularizer': null, - 'bias_constraint': null, - 'dtype': 'float32', - 'activation': 'linear', - 'trainable': true, - 'kernel_regularizer': null, - 'bias_initializer': {'class_name': 'Zeros', 'config': {}}, - 'units': 1, - 'batch_input_shape': [null, 3], - 'use_bias': true, - 'activity_regularizer': null - } - }], - 'backend': 'tensorflow' -}; -const trainingConfig1: tf.io.TrainingConfig = { - loss: 'categorical_crossentropy', - metrics: ['accuracy'], - optimizer_config: {class_name: 'SGD', config: {learningRate: 0.1}} -}; - -let fetchSpy: jasmine.Spy; - -type TypedArrays = Float32Array|Int32Array|Uint8Array|Uint16Array; -const fakeResponse = - (body: string|TypedArrays|ArrayBuffer, contentType: string, path: string) => - ({ - ok: true, - json() { - return Promise.resolve(JSON.parse(body as string)); - }, - arrayBuffer() { - const buf: ArrayBuffer = (body as TypedArrays).buffer ? - (body as TypedArrays).buffer : - body as ArrayBuffer; - return Promise.resolve(buf); - }, - headers: {get: (key: string) => contentType}, - url: path - }) as unknown as Response; - -const setupFakeWeightFiles = - (fileBufferMap: { - [filename: string]: { - data: string|Float32Array|Int32Array|ArrayBuffer|Uint8Array|Uint16Array, - contentType: string - } - }, - requestInits: {[key: string]: RequestInit}) => { - fetchSpy = spyOn(tf.env().platform, 'fetch') - .and.callFake((path: string, init: RequestInit) => { - if (fileBufferMap[path]) { - requestInits[path] = init; - return Promise.resolve(fakeResponse( - fileBufferMap[path].data, - fileBufferMap[path].contentType, path)); - } else { - return Promise.reject('path not found'); - } - }); - }; - -describeWithFlags('http-load fetch', NODE_ENVS, () => { - let requestInits: {[key: string]: {headers: {[key: string]: string}}}; - // tslint:disable-next-line:no-any - let originalFetch: any; - // simulate a fetch polyfill, this needs to be non-null for spyOn to work - beforeEach(() => { - // tslint:disable-next-line:no-any - originalFetch = (global as any).fetch; - // tslint:disable-next-line:no-any - (global as any).fetch = () => {}; - requestInits = {}; - }); - - afterAll(() => { - // tslint:disable-next-line:no-any - (global as any).fetch = originalFetch; - }); - - it('1 group, 2 weights, 1 path', async () => { - const weightManifest1: tf.io.WeightsManifestConfig = [{ - paths: ['weightfile0'], - weights: [ - { - name: 'dense/kernel', - shape: [3, 1], - dtype: 'float32', - }, - { - name: 'dense/bias', - shape: [2], - dtype: 'float32', - } - ] - }]; - const floatData = new Float32Array([1, 3, 3, 7, 4]); - setupFakeWeightFiles( - { - './model.json': { - data: JSON.stringify({ - modelTopology: modelTopology1, - weightsManifest: weightManifest1, - format: 'tfjs-layers', - generatedBy: '1.15', - convertedBy: '1.3.1', - signature: null, - userDefinedMetadata: {} - }), - contentType: 'application/json' - }, - './weightfile0': - {data: floatData, contentType: 'application/octet-stream'}, - }, - requestInits); - - const handler = tf.io.http('./model.json'); - const modelArtifacts = await handler.load(); - expect(modelArtifacts.modelTopology).toEqual(modelTopology1); - expect(modelArtifacts.weightSpecs).toEqual(weightManifest1[0].weights); - expect(modelArtifacts.format).toEqual('tfjs-layers'); - expect(modelArtifacts.generatedBy).toEqual('1.15'); - expect(modelArtifacts.convertedBy).toEqual('1.3.1'); - expect(modelArtifacts.userDefinedMetadata).toEqual({}); - expect(new Float32Array(CompositeArrayBuffer.join( - modelArtifacts.weightData))).toEqual(floatData); - }); - - it('throw exception if no fetch polyfill', () => { - // tslint:disable-next-line:no-any - delete (global as any).fetch; - try { - tf.io.http('./model.json'); - } catch (err) { - expect(err.message).toMatch(/Unable to find fetch polyfill./); - } - }); -}); - -// Turned off for other browsers due to: -// https://github.com/tensorflow/tfjs/issues/426 -describeWithFlags('http-save', CHROME_ENVS, () => { - // Test data. - const weightSpecs1: tf.io.WeightsManifestEntry[] = [ - { - name: 'dense/kernel', - shape: [3, 1], - dtype: 'float32', - }, - { - name: 'dense/bias', - shape: [1], - dtype: 'float32', - } - ]; - const weightData1 = new ArrayBuffer(16); - const artifacts1: tf.io.ModelArtifacts = { - modelTopology: modelTopology1, - weightSpecs: weightSpecs1, - weightData: weightData1, - format: 'layers-model', - generatedBy: 'TensorFlow.js v0.0.0', - convertedBy: null, - signature: null, - userDefinedMetadata: {}, - modelInitializer: {}, - trainingConfig: trainingConfig1 - }; - - let requestInits: RequestInit[] = []; - - beforeEach(() => { - requestInits = []; - spyOn(tf.env().platform, 'fetch') - .and.callFake((path: string, init: RequestInit) => { - if (path === 'model-upload-test' || - path === 'http://model-upload-test') { - requestInits.push(init); - return Promise.resolve(new Response(null, {status: 200})); - } else { - return Promise.reject(new Response(null, {status: 404})); - } - }); - }); - - it('Save topology and weights, default POST method', (done) => { - const testStartDate = new Date(); - const handler = tf.io.getSaveHandlers('http://model-upload-test')[0]; - handler.save(artifacts1) - .then(saveResult => { - expect(saveResult.modelArtifactsInfo.dateSaved.getTime()) - .toBeGreaterThanOrEqual(testStartDate.getTime()); - // Note: The following two assertions work only because there is no - // non-ASCII characters in `modelTopology1` and `weightSpecs1`. - expect(saveResult.modelArtifactsInfo.modelTopologyBytes) - .toEqual(JSON.stringify(modelTopology1).length); - expect(saveResult.modelArtifactsInfo.weightSpecsBytes) - .toEqual(JSON.stringify(weightSpecs1).length); - expect(saveResult.modelArtifactsInfo.weightDataBytes) - .toEqual(weightData1.byteLength); - - expect(requestInits.length).toEqual(1); - const init = requestInits[0]; - expect(init.method).toEqual('POST'); - const body = init.body as FormData; - const jsonFile = body.get('model.json') as File; - const jsonFileReader = new FileReader(); - jsonFileReader.onload = (event: Event) => { - const modelJSON = - // tslint:disable-next-line:no-any - JSON.parse((event.target as any).result) as tf.io.ModelJSON; - expect(modelJSON.modelTopology).toEqual(modelTopology1); - expect(modelJSON.weightsManifest.length).toEqual(1); - expect(modelJSON.weightsManifest[0].weights).toEqual(weightSpecs1); - expect(modelJSON.trainingConfig).toEqual(trainingConfig1); - - const weightsFile = body.get('model.weights.bin') as File; - const weightsFileReader = new FileReader(); - weightsFileReader.onload = (event: Event) => { - // tslint:disable-next-line:no-any - const weightData = (event.target as any).result as ArrayBuffer; - expect(new Uint8Array(weightData)) - .toEqual(new Uint8Array(weightData1)); - done(); - }; - weightsFileReader.onerror = ev => { - done.fail(weightsFileReader.error.message); - }; - weightsFileReader.readAsArrayBuffer(weightsFile); - }; - jsonFileReader.onerror = ev => { - done.fail(jsonFileReader.error.message); - }; - jsonFileReader.readAsText(jsonFile); - }) - .catch(err => { - done.fail(err.stack); - }); - }); - - it('Save topology only, default POST method', (done) => { - const testStartDate = new Date(); - const handler = tf.io.getSaveHandlers('http://model-upload-test')[0]; - const topologyOnlyArtifacts = {modelTopology: modelTopology1}; - handler.save(topologyOnlyArtifacts) - .then(saveResult => { - expect(saveResult.modelArtifactsInfo.dateSaved.getTime()) - .toBeGreaterThanOrEqual(testStartDate.getTime()); - // Note: The following two assertions work only because there is no - // non-ASCII characters in `modelTopology1` and `weightSpecs1`. - expect(saveResult.modelArtifactsInfo.modelTopologyBytes) - .toEqual(JSON.stringify(modelTopology1).length); - expect(saveResult.modelArtifactsInfo.weightSpecsBytes).toEqual(0); - expect(saveResult.modelArtifactsInfo.weightDataBytes).toEqual(0); - - expect(requestInits.length).toEqual(1); - const init = requestInits[0]; - expect(init.method).toEqual('POST'); - const body = init.body as FormData; - const jsonFile = body.get('model.json') as File; - const jsonFileReader = new FileReader(); - jsonFileReader.onload = (event: Event) => { - // tslint:disable-next-line:no-any - const modelJSON = JSON.parse((event.target as any).result); - expect(modelJSON.modelTopology).toEqual(modelTopology1); - // No weights should have been sent to the server. - expect(body.get('model.weights.bin')).toEqual(null); - done(); - }; - jsonFileReader.onerror = event => { - done.fail(jsonFileReader.error.message); - }; - jsonFileReader.readAsText(jsonFile); - }) - .catch(err => { - done.fail(err.stack); - }); - }); - - it('Save topology and weights, PUT method, extra headers', (done) => { - const testStartDate = new Date(); - const handler = tf.io.http('model-upload-test', { - requestInit: { - method: 'PUT', - headers: - {'header_key_1': 'header_value_1', 'header_key_2': 'header_value_2'} - } - }); - handler.save(artifacts1) - .then(saveResult => { - expect(saveResult.modelArtifactsInfo.dateSaved.getTime()) - .toBeGreaterThanOrEqual(testStartDate.getTime()); - // Note: The following two assertions work only because there is no - // non-ASCII characters in `modelTopology1` and `weightSpecs1`. - expect(saveResult.modelArtifactsInfo.modelTopologyBytes) - .toEqual(JSON.stringify(modelTopology1).length); - expect(saveResult.modelArtifactsInfo.weightSpecsBytes) - .toEqual(JSON.stringify(weightSpecs1).length); - expect(saveResult.modelArtifactsInfo.weightDataBytes) - .toEqual(weightData1.byteLength); - - expect(requestInits.length).toEqual(1); - const init = requestInits[0]; - expect(init.method).toEqual('PUT'); - - // Check headers. - expect(init.headers).toEqual({ - 'header_key_1': 'header_value_1', - 'header_key_2': 'header_value_2' - }); - - const body = init.body as FormData; - const jsonFile = body.get('model.json') as File; - const jsonFileReader = new FileReader(); - jsonFileReader.onload = (event: Event) => { - const modelJSON = - // tslint:disable-next-line:no-any - JSON.parse((event.target as any).result) as tf.io.ModelJSON; - expect(modelJSON.format).toEqual('layers-model'); - expect(modelJSON.generatedBy).toEqual('TensorFlow.js v0.0.0'); - expect(modelJSON.convertedBy).toEqual(null); - expect(modelJSON.modelTopology).toEqual(modelTopology1); - expect(modelJSON.modelInitializer).toEqual({}); - expect(modelJSON.weightsManifest.length).toEqual(1); - expect(modelJSON.weightsManifest[0].weights).toEqual(weightSpecs1); - expect(modelJSON.trainingConfig).toEqual(trainingConfig1); - - const weightsFile = body.get('model.weights.bin') as File; - const weightsFileReader = new FileReader(); - weightsFileReader.onload = (event: Event) => { - // tslint:disable-next-line:no-any - const weightData = (event.target as any).result as ArrayBuffer; - expect(new Uint8Array(weightData)) - .toEqual(new Uint8Array(weightData1)); - done(); - }; - weightsFileReader.onerror = event => { - done.fail(weightsFileReader.error.message); - }; - weightsFileReader.readAsArrayBuffer(weightsFile); - }; - jsonFileReader.onerror = event => { - done.fail(jsonFileReader.error.message); - }; - jsonFileReader.readAsText(jsonFile); - }) - .catch(err => { - done.fail(err.stack); - }); - }); - - it('404 response causes Error', (done) => { - const handler = tf.io.getSaveHandlers('http://invalid/path')[0]; - handler.save(artifacts1) - .then(saveResult => { - done.fail( - 'Calling http at invalid URL succeeded ' + - 'unexpectedly'); - }) - .catch(err => { - expect().nothing(); - done(); - }); - }); - - it('getLoadHandlers with one URL string', () => { - const handlers = tf.io.getLoadHandlers('http://foo/model.json'); - expect(handlers.length).toEqual(1); - expect(handlers[0] instanceof HTTPRequest).toEqual(true); - }); - - it('Existing body leads to Error', () => { - expect(() => tf.io.http('model-upload-test', { - requestInit: {body: 'existing body'} - })).toThrowError(/requestInit is expected to have no pre-existing body/); - }); - - it('Empty, null or undefined URL paths lead to Error', () => { - expect(() => tf.io.http(null)) - .toThrowError(/must not be null, undefined or empty/); - expect(() => tf.io.http(undefined)) - .toThrowError(/must not be null, undefined or empty/); - expect(() => tf.io.http('')) - .toThrowError(/must not be null, undefined or empty/); - }); - - it('router', () => { - expect(httpRouter('http://bar/foo') instanceof HTTPRequest).toEqual(true); - expect(httpRouter('https://localhost:5000/upload') instanceof HTTPRequest) - .toEqual(true); - expect(httpRouter('localhost://foo')).toBeNull(); - expect(httpRouter('foo:5000/bar')).toBeNull(); - }); -}); - -describeWithFlags('parseUrl', BROWSER_ENVS, () => { - it('should parse url with no suffix', () => { - const url = 'http://google.com/file'; - const [prefix, suffix] = parseUrl(url); - expect(prefix).toEqual('http://google.com/'); - expect(suffix).toEqual(''); - }); - it('should parse url with suffix', () => { - const url = 'http://google.com/file?param=1'; - const [prefix, suffix] = parseUrl(url); - expect(prefix).toEqual('http://google.com/'); - expect(suffix).toEqual('?param=1'); - }); - it('should parse url with multiple serach params', () => { - const url = 'http://google.com/a?x=1/file?param=1'; - const [prefix, suffix] = parseUrl(url); - expect(prefix).toEqual('http://google.com/a?x=1/'); - expect(suffix).toEqual('?param=1'); - }); -}); - -describeWithFlags('http-load', BROWSER_ENVS, () => { - describe('JSON model', () => { - let requestInits: {[key: string]: {headers: {[key: string]: string}}}; - - beforeEach(() => { - requestInits = {}; - }); - - it('1 group, 2 weights, 1 path', async () => { - const weightManifest1: tf.io.WeightsManifestConfig = [{ - paths: ['weightfile0'], - weights: [ - { - name: 'dense/kernel', - shape: [3, 1], - dtype: 'float32', - }, - { - name: 'dense/bias', - shape: [2], - dtype: 'float32', - } - ] - }]; - const floatData = new Float32Array([1, 3, 3, 7, 4]); - setupFakeWeightFiles( - { - './model.json': { - data: JSON.stringify({ - modelTopology: modelTopology1, - weightsManifest: weightManifest1, - format: 'tfjs-graph-model', - generatedBy: '1.15', - convertedBy: '1.3.1', - signature: null, - userDefinedMetadata: {}, - modelInitializer: {} - }), - contentType: 'application/json' - }, - './weightfile0': - {data: floatData, contentType: 'application/octet-stream'}, - }, - requestInits); - - const handler = tf.io.http('./model.json'); - const modelArtifacts = await handler.load(); - expect(modelArtifacts.modelTopology).toEqual(modelTopology1); - expect(modelArtifacts.weightSpecs).toEqual(weightManifest1[0].weights); - expect(modelArtifacts.format).toEqual('tfjs-graph-model'); - expect(modelArtifacts.generatedBy).toEqual('1.15'); - expect(modelArtifacts.convertedBy).toEqual('1.3.1'); - expect(modelArtifacts.userDefinedMetadata).toEqual({}); - expect(modelArtifacts.modelInitializer).toEqual({}); - - expect(new Float32Array(CompositeArrayBuffer.join(modelArtifacts - .weightData))).toEqual(floatData); - expect(Object.keys(requestInits).length).toEqual(2); - // Assert that fetch is invoked with `window` as the context. - expect(fetchSpy.calls.mostRecent().object).toEqual(window); - }); - - it('1 group, 2 weights, 1 path, with requestInit', async () => { - const weightManifest1: tf.io.WeightsManifestConfig = [{ - paths: ['weightfile0'], - weights: [ - { - name: 'dense/kernel', - shape: [3, 1], - dtype: 'float32', - }, - { - name: 'dense/bias', - shape: [2], - dtype: 'float32', - } - ] - }]; - const floatData = new Float32Array([1, 3, 3, 7, 4]); - setupFakeWeightFiles( - { - './model.json': { - data: JSON.stringify({ - modelTopology: modelTopology1, - weightsManifest: weightManifest1 - }), - contentType: 'application/json' - }, - './weightfile0': - {data: floatData, contentType: 'application/octet-stream'}, - }, - requestInits); - - const handler = tf.io.http( - './model.json', - {requestInit: {headers: {'header_key_1': 'header_value_1'}}}); - const modelArtifacts = await handler.load(); - expect(modelArtifacts.modelTopology).toEqual(modelTopology1); - expect(modelArtifacts.weightSpecs).toEqual(weightManifest1[0].weights); - expect(new Float32Array(CompositeArrayBuffer.join(modelArtifacts - .weightData))).toEqual(floatData); - expect(Object.keys(requestInits).length).toEqual(2); - expect(Object.keys(requestInits).length).toEqual(2); - expect(requestInits['./model.json'].headers['header_key_1']) - .toEqual('header_value_1'); - expect(requestInits['./weightfile0'].headers['header_key_1']) - .toEqual('header_value_1'); - - expect(fetchSpy.calls.mostRecent().object).toEqual(window); - }); - - it('1 group, 2 weight, 2 paths', async () => { - const weightManifest1: tf.io.WeightsManifestConfig = [{ - paths: ['weightfile0', 'weightfile1'], - weights: [ - { - name: 'dense/kernel', - shape: [3, 1], - dtype: 'float32', - }, - { - name: 'dense/bias', - shape: [2], - dtype: 'float32', - } - ] - }]; - const floatData1 = new Float32Array([1, 3, 3]); - const floatData2 = new Float32Array([7, 4]); - setupFakeWeightFiles( - { - './model.json': { - data: JSON.stringify({ - modelTopology: modelTopology1, - weightsManifest: weightManifest1 - }), - contentType: 'application/json' - }, - './weightfile0': - {data: floatData1, contentType: 'application/octet-stream'}, - './weightfile1': - {data: floatData2, contentType: 'application/octet-stream'} - }, - requestInits); - - const handler = tf.io.http('./model.json'); - const modelArtifacts = await handler.load(); - expect(modelArtifacts.modelTopology).toEqual(modelTopology1); - expect(modelArtifacts.weightSpecs).toEqual(weightManifest1[0].weights); - expect(new Float32Array(CompositeArrayBuffer.join(modelArtifacts - .weightData))).toEqual(new Float32Array([1, 3, 3, 7, 4])); - }); - - it('2 groups, 2 weight, 2 paths', async () => { - const weightsManifest: tf.io.WeightsManifestConfig = [ - { - paths: ['weightfile0'], - weights: [{ - name: 'dense/kernel', - shape: [3, 1], - dtype: 'float32', - }] - }, - { - paths: ['weightfile1'], - weights: [{ - name: 'dense/bias', - shape: [2], - dtype: 'float32', - }], - } - ]; - const floatData1 = new Float32Array([1, 3, 3]); - const floatData2 = new Float32Array([7, 4]); - setupFakeWeightFiles( - { - './model.json': { - data: JSON.stringify( - {modelTopology: modelTopology1, weightsManifest}), - contentType: 'application/json' - }, - './weightfile0': - {data: floatData1, contentType: 'application/octet-stream'}, - './weightfile1': - {data: floatData2, contentType: 'application/octet-stream'} - }, - requestInits); - - const handler = tf.io.http('./model.json'); - const modelArtifacts = await handler.load(); - expect(modelArtifacts.modelTopology).toEqual(modelTopology1); - expect(modelArtifacts.weightSpecs) - .toEqual( - weightsManifest[0].weights.concat(weightsManifest[1].weights)); - expect(new Float32Array(CompositeArrayBuffer.join( - modelArtifacts.weightData))) - .toEqual(new Float32Array([1, 3, 3, 7, 4])); - }); - - it('2 groups, 2 weight, 2 paths, Int32 and Uint8 Data', async () => { - const weightsManifest: tf.io.WeightsManifestConfig = [ - { - paths: ['weightfile0'], - weights: [{ - name: 'fooWeight', - shape: [3, 1], - dtype: 'int32', - }] - }, - { - paths: ['weightfile1'], - weights: [{ - name: 'barWeight', - shape: [2], - dtype: 'bool', - }], - } - ]; - const floatData1 = new Int32Array([1, 3, 3]); - const floatData2 = new Uint8Array([7, 4]); - setupFakeWeightFiles( - { - 'path1/model.json': { - data: JSON.stringify( - {modelTopology: modelTopology1, weightsManifest}), - contentType: 'application/json' - }, - 'path1/weightfile0': - {data: floatData1, contentType: 'application/octet-stream'}, - 'path1/weightfile1': - {data: floatData2, contentType: 'application/octet-stream'} - }, - requestInits); - - const handler = tf.io.http('path1/model.json'); - const modelArtifacts = await handler.load(); - expect(modelArtifacts.modelTopology).toEqual(modelTopology1); - expect(modelArtifacts.weightSpecs) - .toEqual( - weightsManifest[0].weights.concat(weightsManifest[1].weights)); - expect(new Int32Array(CompositeArrayBuffer.join(modelArtifacts.weightData) - .slice(0, 12))).toEqual(new Int32Array([1, 3, 3])); - expect(new Uint8Array(CompositeArrayBuffer.join(modelArtifacts.weightData) - .slice(12, 14))).toEqual(new Uint8Array([7, 4])); - }); - - it('topology only', async () => { - setupFakeWeightFiles( - { - './model.json': { - data: JSON.stringify({modelTopology: modelTopology1}), - contentType: 'application/json' - }, - }, - requestInits); - - const handler = tf.io.http('./model.json'); - const modelArtifacts = await handler.load(); - expect(modelArtifacts.modelTopology).toEqual(modelTopology1); - expect(modelArtifacts.weightSpecs).toBeUndefined(); - expect(modelArtifacts.weightData).toBeUndefined(); - }); - - it('weights only', async () => { - const weightsManifest: tf.io.WeightsManifestConfig = [ - { - paths: ['weightfile0'], - weights: [{ - name: 'fooWeight', - shape: [3, 1], - dtype: 'int32', - }] - }, - { - paths: ['weightfile1'], - weights: [{ - name: 'barWeight', - shape: [2], - dtype: 'float32', - }], - } - ]; - const floatData1 = new Int32Array([1, 3, 3]); - const floatData2 = new Float32Array([-7, -4]); - setupFakeWeightFiles( - { - 'path1/model.json': { - data: JSON.stringify({weightsManifest}), - contentType: 'application/json' - }, - 'path1/weightfile0': - {data: floatData1, contentType: 'application/octet-stream'}, - 'path1/weightfile1': - {data: floatData2, contentType: 'application/octet-stream'} - }, - requestInits); - - const handler = tf.io.http('path1/model.json'); - const modelArtifacts = await handler.load(); - expect(modelArtifacts.modelTopology).toBeUndefined(); - expect(modelArtifacts.weightSpecs) - .toEqual( - weightsManifest[0].weights.concat(weightsManifest[1].weights)); - expect(new Int32Array(CompositeArrayBuffer.join(modelArtifacts.weightData) - .slice(0, 12))).toEqual(new Int32Array([1, 3, 3])); - expect(new Float32Array(CompositeArrayBuffer - .join(modelArtifacts.weightData) - .slice(12, 20))).toEqual(new Float32Array([-7, -4])); - }); - - it('Missing modelTopology and weightsManifest leads to error', async () => { - setupFakeWeightFiles( - { - 'path1/model.json': - {data: JSON.stringify({}), contentType: 'application/json'} - }, - requestInits); - const handler = tf.io.http('path1/model.json'); - handler.load() - .then(modelTopology1 => { - fail( - 'Loading from missing modelTopology and weightsManifest ' + - 'succeeded unexpectedly.'); - }) - .catch(err => { - expect(err.message) - .toMatch(/contains neither model topology or manifest/); - }); - expect().nothing(); - }); - - it('with fetch rejection leads to error', async () => { - setupFakeWeightFiles( - { - 'path1/model.json': - {data: JSON.stringify({}), contentType: 'text/html'} - }, - requestInits); - const handler = tf.io.http('path2/model.json'); - try { - const data = await handler.load(); - expect(data).toBeDefined(); - fail('Loading with fetch rejection succeeded unexpectedly.'); - } catch (err) { - // This error is mocked in beforeEach - expect(err).toEqual('path not found'); - } - }); - it('Provide WeightFileTranslateFunc', async () => { - const weightManifest1: tf.io.WeightsManifestConfig = [{ - paths: ['weightfile0'], - weights: [ - { - name: 'dense/kernel', - shape: [3, 1], - dtype: 'float32', - }, - { - name: 'dense/bias', - shape: [2], - dtype: 'float32', - } - ] - }]; - const floatData = new Float32Array([1, 3, 3, 7, 4]); - setupFakeWeightFiles( - { - './model.json': { - data: JSON.stringify({ - modelTopology: modelTopology1, - weightsManifest: weightManifest1 - }), - contentType: 'application/json' - }, - 'auth_weightfile0': - {data: floatData, contentType: 'application/octet-stream'}, - }, - requestInits); - async function prefixWeightUrlConverter(weightFile: string): - Promise { - // Add 'auth_' prefix to the weight file url. - return new Promise( - resolve => setTimeout(resolve, 1, 'auth_' + weightFile)); - } - - const handler = tf.io.http('./model.json', { - requestInit: {headers: {'header_key_1': 'header_value_1'}}, - weightUrlConverter: prefixWeightUrlConverter - }); - const modelArtifacts = await handler.load(); - expect(modelArtifacts.modelTopology).toEqual(modelTopology1); - expect(modelArtifacts.weightSpecs).toEqual(weightManifest1[0].weights); - expect(new Float32Array(CompositeArrayBuffer.join( - modelArtifacts.weightData))).toEqual(floatData); - expect(Object.keys(requestInits).length).toEqual(2); - expect(Object.keys(requestInits).length).toEqual(2); - expect(requestInits['./model.json'].headers['header_key_1']) - .toEqual('header_value_1'); - expect(requestInits['auth_weightfile0'].headers['header_key_1']) - .toEqual('header_value_1'); - - expect(fetchSpy.calls.mostRecent().object).toEqual(window); - }); - }); - - it('Overriding BrowserHTTPRequest fetchFunc', async () => { - const weightManifest1: tf.io.WeightsManifestConfig = [{ - paths: ['weightfile0'], - weights: [ - { - name: 'dense/kernel', - shape: [3, 1], - dtype: 'float32', - }, - { - name: 'dense/bias', - shape: [2], - dtype: 'float32', - } - ] - }]; - const floatData = new Float32Array([1, 3, 3, 7, 4]); - - const fetchInputs: RequestInfo[] = []; - const fetchInits: RequestInit[] = []; - async function customFetch( - input: RequestInfo, init?: RequestInit): Promise { - fetchInputs.push(input); - fetchInits.push(init); - - if (input === './model.json') { - return new Response( - JSON.stringify({ - modelTopology: modelTopology1, - weightsManifest: weightManifest1, - trainingConfig: trainingConfig1 - }), - {status: 200, headers: {'content-type': 'application/json'}}); - } else if (input === './weightfile0') { - return new Response(floatData, { - status: 200, - headers: {'content-type': 'application/octet-stream'} - }); - } else { - return new Response(null, {status: 404}); - } - } - - const handler = tf.io.http( - './model.json', - {requestInit: {credentials: 'include'}, fetchFunc: customFetch}); - const modelArtifacts = await handler.load(); - expect(modelArtifacts.modelTopology).toEqual(modelTopology1); - expect(modelArtifacts.trainingConfig).toEqual(trainingConfig1); - expect(modelArtifacts.weightSpecs).toEqual(weightManifest1[0].weights); - expect(new Float32Array(CompositeArrayBuffer - .join(modelArtifacts.weightData))).toEqual(floatData); - - expect(fetchInputs).toEqual(['./model.json', './weightfile0']); - expect(fetchInits.length).toEqual(2); - expect(fetchInits[0].credentials).toEqual('include'); - expect(fetchInits[1].credentials).toEqual('include'); - }); -}); diff --git a/tfjs-master/tfjs-core/src/io/indexed_db.ts b/tfjs-master/tfjs-core/src/io/indexed_db.ts deleted file mode 100644 index 42de50941..000000000 --- a/tfjs-master/tfjs-core/src/io/indexed_db.ts +++ /dev/null @@ -1,373 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import '../flags'; - -import {env} from '../environment'; - -import {getModelArtifactsInfoForJSON} from './io_utils'; -import {IORouter, IORouterRegistry} from './router_registry'; -import {IOHandler, ModelArtifacts, ModelArtifactsInfo, ModelStoreManager, SaveResult} from './types'; -import {CompositeArrayBuffer} from './composite_array_buffer'; - -const DATABASE_NAME = 'tensorflowjs'; -const DATABASE_VERSION = 1; - -// Model data and ModelArtifactsInfo (metadata) are stored in two separate -// stores for efficient access of the list of stored models and their metadata. -// 1. The object store for model data: topology, weights and weight manifests. -const MODEL_STORE_NAME = 'models_store'; -// 2. The object store for ModelArtifactsInfo, including meta-information such -// as the type of topology (JSON vs binary), byte size of the topology, byte -// size of the weights, etc. -const INFO_STORE_NAME = 'model_info_store'; - -/** - * Delete the entire database for tensorflow.js, including the models store. - */ -export async function deleteDatabase(): Promise { - const idbFactory = getIndexedDBFactory(); - - return new Promise((resolve, reject) => { - const deleteRequest = idbFactory.deleteDatabase(DATABASE_NAME); - deleteRequest.onsuccess = () => resolve(); - deleteRequest.onerror = error => reject(error); - }); -} - -function getIndexedDBFactory(): IDBFactory { - if (!env().getBool('IS_BROWSER')) { - // TODO(cais): Add more info about what IOHandler subtypes are available. - // Maybe point to a doc page on the web and/or automatically determine - // the available IOHandlers and print them in the error message. - throw new Error( - 'Failed to obtain IndexedDB factory because the current environment' + - 'is not a web browser.'); - } - // tslint:disable-next-line:no-any - const theWindow: any = typeof window === 'undefined' ? self : window; - const factory = theWindow.indexedDB || theWindow.mozIndexedDB || - theWindow.webkitIndexedDB || theWindow.msIndexedDB || - theWindow.shimIndexedDB; - if (factory == null) { - throw new Error( - 'The current browser does not appear to support IndexedDB.'); - } - return factory; -} - -function setUpDatabase(openRequest: IDBRequest) { - const db = openRequest.result as IDBDatabase; - db.createObjectStore(MODEL_STORE_NAME, {keyPath: 'modelPath'}); - db.createObjectStore(INFO_STORE_NAME, {keyPath: 'modelPath'}); -} - -/** - * IOHandler subclass: Browser IndexedDB. - * - * See the doc string of `browserIndexedDB` for more details. - */ -export class BrowserIndexedDB implements IOHandler { - protected readonly indexedDB: IDBFactory; - protected readonly modelPath: string; - - static readonly URL_SCHEME = 'indexeddb://'; - - constructor(modelPath: string) { - this.indexedDB = getIndexedDBFactory(); - - if (modelPath == null || !modelPath) { - throw new Error( - 'For IndexedDB, modelPath must not be null, undefined or empty.'); - } - this.modelPath = modelPath; - } - - async save(modelArtifacts: ModelArtifacts): Promise { - // TODO(cais): Support saving GraphDef models. - if (modelArtifacts.modelTopology instanceof ArrayBuffer) { - throw new Error( - 'BrowserLocalStorage.save() does not support saving model topology ' + - 'in binary formats yet.'); - } - - return this.databaseAction(this.modelPath, modelArtifacts) as - Promise; - } - - async load(): Promise { - return this.databaseAction(this.modelPath) as Promise; - } - - /** - * Perform database action to put model artifacts into or read model artifacts - * from IndexedDB object store. - * - * Whether the action is put or get depends on whether `modelArtifacts` is - * specified. If it is specified, the action will be put; otherwise the action - * will be get. - * - * @param modelPath A unique string path for the model. - * @param modelArtifacts If specified, it will be the model artifacts to be - * stored in IndexedDB. - * @returns A `Promise` of `SaveResult`, if the action is put, or a `Promise` - * of `ModelArtifacts`, if the action is get. - */ - private databaseAction(modelPath: string, modelArtifacts?: ModelArtifacts): - Promise { - return new Promise((resolve, reject) => { - const openRequest = this.indexedDB.open(DATABASE_NAME, DATABASE_VERSION); - openRequest.onupgradeneeded = () => setUpDatabase(openRequest); - - openRequest.onsuccess = () => { - const db = openRequest.result; - - if (modelArtifacts == null) { - // Read model out from object store. - const modelTx = db.transaction(MODEL_STORE_NAME, 'readonly'); - const modelStore = modelTx.objectStore(MODEL_STORE_NAME); - const getRequest = modelStore.get(this.modelPath); - getRequest.onsuccess = () => { - if (getRequest.result == null) { - db.close(); - return reject(new Error( - `Cannot find model with path '${this.modelPath}' ` + - `in IndexedDB.`)); - } else { - resolve(getRequest.result.modelArtifacts); - } - }; - getRequest.onerror = error => { - db.close(); - return reject(getRequest.error); - }; - modelTx.oncomplete = () => db.close(); - } else { - // Put model into object store. - - // Concatenate all the model weights into a single ArrayBuffer. Large - // models (~1GB) have problems saving if they are not concatenated. - // TODO(mattSoulanille): Save large models to multiple indexeddb - // records. - modelArtifacts.weightData = CompositeArrayBuffer.join( - modelArtifacts.weightData); - const modelArtifactsInfo: ModelArtifactsInfo = - getModelArtifactsInfoForJSON(modelArtifacts); - // First, put ModelArtifactsInfo into info store. - const infoTx = db.transaction(INFO_STORE_NAME, 'readwrite'); - let infoStore = infoTx.objectStore(INFO_STORE_NAME); - let putInfoRequest: IDBRequest; - try { - putInfoRequest = - infoStore.put({modelPath: this.modelPath, modelArtifactsInfo}); - } catch (error) { - return reject(error); - } - let modelTx: IDBTransaction; - putInfoRequest.onsuccess = () => { - // Second, put model data into model store. - modelTx = db.transaction(MODEL_STORE_NAME, 'readwrite'); - const modelStore = modelTx.objectStore(MODEL_STORE_NAME); - let putModelRequest: IDBRequest; - try { - putModelRequest = modelStore.put({ - modelPath: this.modelPath, - modelArtifacts, - modelArtifactsInfo - }); - } catch (error) { - // Sometimes, the serialized value is too large to store. - return reject(error); - } - putModelRequest.onsuccess = () => resolve({modelArtifactsInfo}); - putModelRequest.onerror = error => { - // If the put-model request fails, roll back the info entry as - // well. - infoStore = infoTx.objectStore(INFO_STORE_NAME); - const deleteInfoRequest = infoStore.delete(this.modelPath); - deleteInfoRequest.onsuccess = () => { - db.close(); - return reject(putModelRequest.error); - }; - deleteInfoRequest.onerror = error => { - db.close(); - return reject(putModelRequest.error); - }; - }; - }; - putInfoRequest.onerror = error => { - db.close(); - return reject(putInfoRequest.error); - }; - infoTx.oncomplete = () => { - if (modelTx == null) { - db.close(); - } else { - modelTx.oncomplete = () => db.close(); - } - }; - } - }; - openRequest.onerror = error => reject(openRequest.error); - }); - } -} - -export const indexedDBRouter: IORouter = (url: string|string[]) => { - if (!env().getBool('IS_BROWSER')) { - return null; - } else { - if (!Array.isArray(url) && url.startsWith(BrowserIndexedDB.URL_SCHEME)) { - return browserIndexedDB(url.slice(BrowserIndexedDB.URL_SCHEME.length)); - } else { - return null; - } - } -}; -IORouterRegistry.registerSaveRouter(indexedDBRouter); -IORouterRegistry.registerLoadRouter(indexedDBRouter); - -/** - * Creates a browser IndexedDB IOHandler for saving and loading models. - * - * ```js - * const model = tf.sequential(); - * model.add( - * tf.layers.dense({units: 1, inputShape: [100], activation: 'sigmoid'})); - * - * const saveResult = await model.save('indexeddb://MyModel')); - * console.log(saveResult); - * ``` - * - * @param modelPath A unique identifier for the model to be saved. Must be a - * non-empty string. - * @returns An instance of `BrowserIndexedDB` (sublcass of `IOHandler`), - * which can be used with, e.g., `tf.Model.save`. - */ -export function browserIndexedDB(modelPath: string): IOHandler { - return new BrowserIndexedDB(modelPath); -} - -function maybeStripScheme(key: string) { - return key.startsWith(BrowserIndexedDB.URL_SCHEME) ? - key.slice(BrowserIndexedDB.URL_SCHEME.length) : - key; -} - -export class BrowserIndexedDBManager implements ModelStoreManager { - private indexedDB: IDBFactory; - - constructor() { - this.indexedDB = getIndexedDBFactory(); - } - - async listModels(): Promise<{[path: string]: ModelArtifactsInfo}> { - return new Promise<{[path: string]: ModelArtifactsInfo}>( - (resolve, reject) => { - const openRequest = - this.indexedDB.open(DATABASE_NAME, DATABASE_VERSION); - openRequest.onupgradeneeded = () => setUpDatabase(openRequest); - - openRequest.onsuccess = () => { - const db = openRequest.result; - const tx = db.transaction(INFO_STORE_NAME, 'readonly'); - const store = tx.objectStore(INFO_STORE_NAME); - // tslint:disable:max-line-length - // Need to cast `store` as `any` here because TypeScript's DOM - // library does not have the `getAll()` method even though the - // method is supported in the latest version of most mainstream - // browsers: - // https://developer.mozilla.org/en-US/docs/Web/API/IDBObjectStore/getAll - // tslint:enable:max-line-length - // tslint:disable-next-line:no-any - const getAllInfoRequest = (store as any).getAll() as IDBRequest; - getAllInfoRequest.onsuccess = () => { - const out: {[path: string]: ModelArtifactsInfo} = {}; - for (const item of getAllInfoRequest.result) { - out[item.modelPath] = item.modelArtifactsInfo; - } - resolve(out); - }; - getAllInfoRequest.onerror = error => { - db.close(); - return reject(getAllInfoRequest.error); - }; - tx.oncomplete = () => db.close(); - }; - openRequest.onerror = error => reject(openRequest.error); - }); - } - - async removeModel(path: string): Promise { - path = maybeStripScheme(path); - return new Promise((resolve, reject) => { - const openRequest = this.indexedDB.open(DATABASE_NAME, DATABASE_VERSION); - openRequest.onupgradeneeded = () => setUpDatabase(openRequest); - - openRequest.onsuccess = () => { - const db = openRequest.result; - const infoTx = db.transaction(INFO_STORE_NAME, 'readwrite'); - const infoStore = infoTx.objectStore(INFO_STORE_NAME); - - const getInfoRequest = infoStore.get(path); - let modelTx: IDBTransaction; - getInfoRequest.onsuccess = () => { - if (getInfoRequest.result == null) { - db.close(); - return reject(new Error( - `Cannot find model with path '${path}' ` + - `in IndexedDB.`)); - } else { - // First, delete the entry in the info store. - const deleteInfoRequest = infoStore.delete(path); - const deleteModelData = () => { - // Second, delete the entry in the model store. - modelTx = db.transaction(MODEL_STORE_NAME, 'readwrite'); - const modelStore = modelTx.objectStore(MODEL_STORE_NAME); - const deleteModelRequest = modelStore.delete(path); - deleteModelRequest.onsuccess = () => - resolve(getInfoRequest.result.modelArtifactsInfo); - deleteModelRequest.onerror = error => - reject(getInfoRequest.error); - }; - // Proceed with deleting model data regardless of whether deletion - // of info data succeeds or not. - deleteInfoRequest.onsuccess = deleteModelData; - deleteInfoRequest.onerror = error => { - deleteModelData(); - db.close(); - return reject(getInfoRequest.error); - }; - } - }; - getInfoRequest.onerror = error => { - db.close(); - return reject(getInfoRequest.error); - }; - - infoTx.oncomplete = () => { - if (modelTx == null) { - db.close(); - } else { - modelTx.oncomplete = () => db.close(); - } - }; - }; - openRequest.onerror = error => reject(openRequest.error); - }); - } -} diff --git a/tfjs-master/tfjs-core/src/io/indexed_db_test.ts b/tfjs-master/tfjs-core/src/io/indexed_db_test.ts deleted file mode 100644 index 2aaff05e2..000000000 --- a/tfjs-master/tfjs-core/src/io/indexed_db_test.ts +++ /dev/null @@ -1,307 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -/** - * Unit tests for indexed_db.ts. - */ - -import * as tf from '../index'; -import {BROWSER_ENVS, describeWithFlags, runWithLock} from '../jasmine_util'; -import {expectArrayBuffersEqual} from '../test_util'; -import {browserIndexedDB, BrowserIndexedDB, BrowserIndexedDBManager, deleteDatabase, indexedDBRouter} from './indexed_db'; -import {CompositeArrayBuffer} from './composite_array_buffer'; - -describeWithFlags('IndexedDB', BROWSER_ENVS, () => { - // Test data. - const modelTopology1: {} = { - 'class_name': 'Sequential', - 'keras_version': '2.1.4', - 'config': [{ - 'class_name': 'Dense', - 'config': { - 'kernel_initializer': { - 'class_name': 'VarianceScaling', - 'config': { - 'distribution': 'uniform', - 'scale': 1.0, - 'seed': null, - 'mode': 'fan_avg' - } - }, - 'name': 'dense', - 'kernel_constraint': null, - 'bias_regularizer': null, - 'bias_constraint': null, - 'dtype': 'float32', - 'activation': 'linear', - 'trainable': true, - 'kernel_regularizer': null, - 'bias_initializer': {'class_name': 'Zeros', 'config': {}}, - 'units': 1, - 'batch_input_shape': [null, 3], - 'use_bias': true, - 'activity_regularizer': null - } - }], - 'backend': 'tensorflow' - }; - const weightSpecs1: tf.io.WeightsManifestEntry[] = [ - { - name: 'dense/kernel', - shape: [3, 1], - dtype: 'float32', - }, - { - name: 'dense/bias', - shape: [1], - dtype: 'float32', - } - ]; - const weightData1 = new ArrayBuffer(16); - const artifacts1: tf.io.ModelArtifacts = { - modelTopology: modelTopology1, - weightSpecs: weightSpecs1, - weightData: weightData1, - format: 'layers-model', - generatedBy: 'TensorFlow.js v0.0.0', - convertedBy: null, - modelInitializer: {} - }; - - const weightSpecs2: tf.io.WeightsManifestEntry[] = [ - { - name: 'dense/new_kernel', - shape: [5, 1], - dtype: 'float32', - }, - { - name: 'dense/new_bias', - shape: [1], - dtype: 'float32', - } - ]; - - beforeEach(deleteDatabase); - - afterEach(deleteDatabase); - - it('Save-load round trip', runWithLock(async () => { - const testStartDate = new Date(); - const handler = tf.io.getSaveHandlers('indexeddb://FooModel')[0]; - - const saveResult = await handler.save(artifacts1); - expect(saveResult.modelArtifactsInfo.dateSaved.getTime()) - .toBeGreaterThanOrEqual(testStartDate.getTime()); - // Note: The following two assertions work only because there is no - // non-ASCII characters in `modelTopology1` and `weightSpecs1`. - expect(saveResult.modelArtifactsInfo.modelTopologyBytes) - .toEqual(JSON.stringify(modelTopology1).length); - expect(saveResult.modelArtifactsInfo.weightSpecsBytes) - .toEqual(JSON.stringify(weightSpecs1).length); - expect(saveResult.modelArtifactsInfo.weightDataBytes) - .toEqual(weightData1.byteLength); - - const loadedArtifacts = await handler.load(); - expect(loadedArtifacts.modelTopology).toEqual(modelTopology1); - expect(loadedArtifacts.weightSpecs).toEqual(weightSpecs1); - expect(loadedArtifacts.format).toEqual('layers-model'); - expect(loadedArtifacts.generatedBy).toEqual('TensorFlow.js v0.0.0'); - expect(loadedArtifacts.convertedBy).toEqual(null); - expect(loadedArtifacts.modelInitializer).toEqual({}); - expectArrayBuffersEqual(CompositeArrayBuffer.join( - loadedArtifacts.weightData), weightData1); - })); - - it('Save two models and load one', runWithLock(async () => { - const weightData2 = new ArrayBuffer(24); - const artifacts2: tf.io.ModelArtifacts = { - modelTopology: modelTopology1, - weightSpecs: weightSpecs2, - weightData: weightData2, - }; - const handler1 = tf.io.getSaveHandlers('indexeddb://Model/1')[0]; - const saveResult1 = await handler1.save(artifacts1); - // Note: The following two assertions work only because there is no - // non-ASCII characters in `modelTopology1` and `weightSpecs1`. - expect(saveResult1.modelArtifactsInfo.modelTopologyBytes) - .toEqual(JSON.stringify(modelTopology1).length); - expect(saveResult1.modelArtifactsInfo.weightSpecsBytes) - .toEqual(JSON.stringify(weightSpecs1).length); - expect(saveResult1.modelArtifactsInfo.weightDataBytes) - .toEqual(weightData1.byteLength); - - const handler2 = tf.io.getSaveHandlers('indexeddb://Model/2')[0]; - const saveResult2 = await handler2.save(artifacts2); - expect(saveResult2.modelArtifactsInfo.dateSaved.getTime()) - .toBeGreaterThanOrEqual( - saveResult1.modelArtifactsInfo.dateSaved.getTime()); - // Note: The following two assertions work only because there is - // no non-ASCII characters in `modelTopology1` and - // `weightSpecs1`. - expect(saveResult2.modelArtifactsInfo.modelTopologyBytes) - .toEqual(JSON.stringify(modelTopology1).length); - expect(saveResult2.modelArtifactsInfo.weightSpecsBytes) - .toEqual(JSON.stringify(weightSpecs2).length); - expect(saveResult2.modelArtifactsInfo.weightDataBytes) - .toEqual(weightData2.byteLength); - - const loadedArtifacts = await handler1.load(); - expect(loadedArtifacts.modelTopology).toEqual(modelTopology1); - expect(loadedArtifacts.weightSpecs).toEqual(weightSpecs1); - expect(loadedArtifacts.weightData).toBeDefined(); - expectArrayBuffersEqual(CompositeArrayBuffer.join( - loadedArtifacts.weightData), weightData1); - })); - - it('Loading nonexistent model fails', runWithLock(async () => { - const handler = tf.io.getSaveHandlers('indexeddb://NonexistentModel')[0]; - - try { - await handler.load(); - fail('Loading nonexistent model from IndexedDB succeeded unexpectly'); - } catch (err) { - expect(err.message) - .toEqual( - 'Cannot find model ' + - 'with path \'NonexistentModel\' in IndexedDB.'); - } - })); - - it('Null, undefined or empty modelPath throws Error', () => { - expect(() => browserIndexedDB(null)) - .toThrowError( - /IndexedDB, modelPath must not be null, undefined or empty/); - expect(() => browserIndexedDB(undefined)) - .toThrowError( - /IndexedDB, modelPath must not be null, undefined or empty/); - expect(() => browserIndexedDB('')) - .toThrowError( - /IndexedDB, modelPath must not be null, undefined or empty./); - }); - - it('router', () => { - expect(indexedDBRouter('indexeddb://bar') instanceof BrowserIndexedDB) - .toEqual(true); - expect(indexedDBRouter('localstorage://bar')).toBeNull(); - expect(indexedDBRouter('qux')).toBeNull(); - }); - - it('Manager: List models: 0 result', runWithLock(async () => { - // Before any model is saved, listModels should return empty result. - const models = await new BrowserIndexedDBManager().listModels(); - expect(models).toEqual({}); - })); - - it('Manager: List models: 1 result', runWithLock(async () => { - const handler = tf.io.getSaveHandlers('indexeddb://baz/QuxModel')[0]; - const saveResult = await handler.save(artifacts1); - - // After successful saving, there should be one model. - const models = await new BrowserIndexedDBManager().listModels(); - expect(Object.keys(models).length).toEqual(1); - expect(models['baz/QuxModel'].modelTopologyType) - .toEqual(saveResult.modelArtifactsInfo.modelTopologyType); - expect(models['baz/QuxModel'].modelTopologyBytes) - .toEqual(saveResult.modelArtifactsInfo.modelTopologyBytes); - expect(models['baz/QuxModel'].weightSpecsBytes) - .toEqual(saveResult.modelArtifactsInfo.weightSpecsBytes); - expect(models['baz/QuxModel'].weightDataBytes) - .toEqual(saveResult.modelArtifactsInfo.weightDataBytes); - })); - - it('Manager: List models: 2 results', runWithLock(async () => { - // First, save a model. - const handler1 = tf.io.getSaveHandlers('indexeddb://QuxModel')[0]; - const saveResult1 = await handler1.save(artifacts1); - - // Then, save the model under another path. - const handler2 = tf.io.getSaveHandlers('indexeddb://repeat/QuxModel')[0]; - const saveResult2 = await handler2.save(artifacts1); - - // After successful saving, there should be two models. - const models = await new BrowserIndexedDBManager().listModels(); - expect(Object.keys(models).length).toEqual(2); - expect(models['QuxModel'].modelTopologyType) - .toEqual(saveResult1.modelArtifactsInfo.modelTopologyType); - expect(models['QuxModel'].modelTopologyBytes) - .toEqual(saveResult1.modelArtifactsInfo.modelTopologyBytes); - expect(models['QuxModel'].weightSpecsBytes) - .toEqual(saveResult1.modelArtifactsInfo.weightSpecsBytes); - expect(models['QuxModel'].weightDataBytes) - .toEqual(saveResult1.modelArtifactsInfo.weightDataBytes); - expect(models['repeat/QuxModel'].modelTopologyType) - .toEqual(saveResult2.modelArtifactsInfo.modelTopologyType); - expect(models['repeat/QuxModel'].modelTopologyBytes) - .toEqual(saveResult2.modelArtifactsInfo.modelTopologyBytes); - expect(models['repeat/QuxModel'].weightSpecsBytes) - .toEqual(saveResult2.modelArtifactsInfo.weightSpecsBytes); - expect(models['repeat/QuxModel'].weightDataBytes) - .toEqual(saveResult2.modelArtifactsInfo.weightDataBytes); - })); - - it('Manager: Successful removeModel', runWithLock(async () => { - // First, save a model. - const handler1 = tf.io.getSaveHandlers('indexeddb://QuxModel')[0]; - await handler1.save(artifacts1); - - // Then, save the model under another path. - const handler2 = tf.io.getSaveHandlers('indexeddb://repeat/QuxModel')[0]; - await handler2.save(artifacts1); - - // After successful saving, delete the first save, and then - // `listModel` should give only one result. - const manager = new BrowserIndexedDBManager(); - await manager.removeModel('QuxModel'); - - const models = await manager.listModels(); - expect(Object.keys(models)).toEqual(['repeat/QuxModel']); - })); - - it('Manager: Successful removeModel with URL scheme', - runWithLock(async () => { - // First, save a model. - const handler1 = tf.io.getSaveHandlers('indexeddb://QuxModel')[0]; - await handler1.save(artifacts1); - - // Then, save the model under another path. - const handler2 = tf.io.getSaveHandlers('indexeddb://repeat/QuxModel')[0]; - await handler2.save(artifacts1); - - // After successful saving, delete the first save, and then - // `listModel` should give only one result. - const manager = new BrowserIndexedDBManager(); - - // Delete a model specified with a path that includes the - // indexeddb:// scheme prefix should work. - manager.removeModel('indexeddb://QuxModel'); - - const models = await manager.listModels(); - expect(Object.keys(models)).toEqual(['repeat/QuxModel']); - })); - - it('Manager: Failed removeModel', runWithLock(async () => { - try { - // Attempt to delete a nonexistent model is expected to fail. - await new BrowserIndexedDBManager().removeModel('nonexistent'); - fail('Deleting nonexistent model succeeded unexpectedly.'); - } catch (err) { - expect(err.message) - .toEqual( - 'Cannot find model with path \'nonexistent\' in IndexedDB.'); - } - })); -}); diff --git a/tfjs-master/tfjs-core/src/io/io.ts b/tfjs-master/tfjs-core/src/io/io.ts deleted file mode 100644 index 49e9a1e2e..000000000 --- a/tfjs-master/tfjs-core/src/io/io.ts +++ /dev/null @@ -1,74 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// Importing local_storage and indexed_db is necessary for the routers to be -// registered. -import './indexed_db'; -import './local_storage'; - -import {browserFiles} from './browser_files'; -import {browserHTTPRequest, http, isHTTPScheme} from './http'; -import {concatenateArrayBuffers, decodeWeights, encodeWeights, getModelArtifactsForJSON, getModelArtifactsForJSONSync, getModelArtifactsInfoForJSON, getWeightSpecs} from './io_utils'; -import {fromMemory, fromMemorySync, withSaveHandler, withSaveHandlerSync} from './passthrough'; -import {getLoadHandlers, getSaveHandlers, registerLoadRouter, registerSaveRouter} from './router_registry'; -import {IOHandler, IOHandlerSync, LoadHandler, LoadOptions, ModelArtifacts, ModelArtifactsInfo, ModelJSON, ModelStoreManager, OnProgressCallback, RequestDetails, SaveConfig, SaveHandler, SaveResult, TrainingConfig, WeightGroup, WeightsManifestConfig, WeightsManifestEntry, WeightData} from './types'; -import {loadWeights, weightsLoaderFactory} from './weights_loader'; -import {CompositeArrayBuffer} from './composite_array_buffer'; - -export {copyModel, listModels, moveModel, removeModel} from './model_management'; -export { - browserFiles, - browserHTTPRequest, - CompositeArrayBuffer, - concatenateArrayBuffers, - decodeWeights, - encodeWeights, - fromMemory, - fromMemorySync, - getLoadHandlers, - getModelArtifactsForJSON, - getModelArtifactsForJSONSync, - getModelArtifactsInfoForJSON, - getSaveHandlers, - getWeightSpecs, - http, - IOHandler, - IOHandlerSync, - isHTTPScheme, - LoadHandler, - LoadOptions, - loadWeights, - ModelArtifacts, - ModelArtifactsInfo, - ModelJSON, - ModelStoreManager, - OnProgressCallback, - registerLoadRouter, - registerSaveRouter, - RequestDetails, - SaveConfig, - SaveHandler, - SaveResult, - TrainingConfig, - WeightData, - WeightGroup, - weightsLoaderFactory, - WeightsManifestConfig, - WeightsManifestEntry, - withSaveHandler, - withSaveHandlerSync, -}; diff --git a/tfjs-master/tfjs-core/src/io/io_utils.ts b/tfjs-master/tfjs-core/src/io/io_utils.ts deleted file mode 100644 index fa9005a9b..000000000 --- a/tfjs-master/tfjs-core/src/io/io_utils.ts +++ /dev/null @@ -1,622 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {complex} from '../ops/complex'; -import {tensor} from '../ops/tensor'; -import {NamedTensor, NamedTensorMap} from '../tensor_types'; -import {TypedArray} from '../types'; -import {sizeFromShape} from '../util'; - -import {DTYPE_VALUE_SIZE_MAP, ModelArtifacts, ModelArtifactsInfo, ModelJSON, WeightData, WeightGroup, WeightsManifestConfig, WeightsManifestEntry} from './types'; -import {CompositeArrayBuffer} from './composite_array_buffer'; - -/** Number of bytes reserved for the length of the string. (32bit integer). */ -const NUM_BYTES_STRING_LENGTH = 4; - -/** - * Encode a map from names to weight values as an ArrayBuffer, along with an - * `Array` of `WeightsManifestEntry` as specification of the encoded weights. - * - * This function does not perform sharding. - * - * This function is the reverse of `decodeWeights`. - * - * @param tensors A map ("dict") from names to tensors. - * @param group Group to which the weights belong (optional). - * @returns A `Promise` of - * - A flat `ArrayBuffer` with all the binary values of the `Tensor`s - * concatenated. - * - An `Array` of `WeightManifestEntry`s, carrying information including - * tensor names, `dtype`s and shapes. - * @throws Error: on unsupported tensor `dtype`. - */ -export async function encodeWeights( - tensors: NamedTensorMap|NamedTensor[], group?: WeightGroup): - Promise<{data: ArrayBuffer, specs: WeightsManifestEntry[]}> { - // TODO(adarob, cais): Support quantization. - const specs: WeightsManifestEntry[] = []; - const dataPromises: Array> = []; - - const names: string[] = Array.isArray(tensors) ? - tensors.map(tensor => tensor.name) : - Object.keys(tensors); - - for (let i = 0; i < names.length; ++i) { - const name = names[i]; - const t = Array.isArray(tensors) ? tensors[i].tensor : tensors[name]; - if (t.dtype !== 'float32' && t.dtype !== 'int32' && t.dtype !== 'bool' && - t.dtype !== 'string' && t.dtype !== 'complex64') { - throw new Error(`Unsupported dtype in weight '${name}': ${t.dtype}`); - } - const spec: WeightsManifestEntry = {name, shape: t.shape, dtype: t.dtype}; - if (t.dtype === 'string') { - const utf8bytes = new Promise(async resolve => { - const vals = await t.bytes() as Uint8Array[]; - const totalNumBytes = vals.reduce((p, c) => p + c.length, 0) + - NUM_BYTES_STRING_LENGTH * vals.length; - const bytes = new Uint8Array(totalNumBytes); - let offset = 0; - for (let i = 0; i < vals.length; i++) { - const val = vals[i]; - const bytesOfLength = - new Uint8Array(new Uint32Array([val.length]).buffer); - bytes.set(bytesOfLength, offset); - offset += NUM_BYTES_STRING_LENGTH; - bytes.set(val, offset); - offset += val.length; - } - resolve(bytes); - }); - dataPromises.push(utf8bytes); - } else { - dataPromises.push(t.data()); - } - if (group != null) { - spec.group = group; - } - specs.push(spec); - } - - const tensorValues = await Promise.all(dataPromises); - return {data: concatenateTypedArrays(tensorValues), specs}; -} - -/** - * Decode flat ArrayBuffer as weights. - * - * This function does not handle sharding. - * - * This function is the reverse of `encodeWeights`. - * - * @param weightData A flat ArrayBuffer or an array of ArrayBuffers carrying the - * binary values of the tensors concatenated in the order specified in - * `specs`. - * @param specs Specifications of the names, dtypes and shapes of the tensors - * whose value are encoded by `buffer`. - * @return A map from tensor name to tensor value, with the names corresponding - * to names in `specs`. - * @throws Error, if any of the tensors has unsupported dtype. - */ -export function decodeWeights( - weightData: WeightData, - specs: WeightsManifestEntry[]): NamedTensorMap { - // TODO(adarob, cais): Support quantization. - const compositeBuffer = new CompositeArrayBuffer(weightData); - const out: NamedTensorMap = {}; - let float16Decode: (buffer: Uint16Array) => Float32Array | undefined; - let offset = 0; - for (const spec of specs) { - const name = spec.name; - const dtype = spec.dtype; - const shape = spec.shape; - const size = sizeFromShape(shape); - let values: TypedArray|string[]|Uint8Array[]; - - if ('quantization' in spec) { - const quantization = spec.quantization; - if (quantization.dtype === 'uint8' || quantization.dtype === 'uint16') { - if (!('min' in quantization && 'scale' in quantization)) { - throw new Error( - `Weight ${spec.name} with quantization ${quantization.dtype} ` + - `doesn't have corresponding metadata min and scale.`); - } - } else if (quantization.dtype === 'float16') { - if (dtype !== 'float32') { - throw new Error( - `Weight ${spec.name} is quantized with ${quantization.dtype} ` + - `which only supports weights of type float32 not ${dtype}.`); - } - } else { - throw new Error( - `Weight ${spec.name} has unknown ` + - `quantization dtype ${quantization.dtype}. ` + - `Supported quantization dtypes are: ` + - `'uint8', 'uint16', and 'float16'.`); - } - const quantizationSizeFactor = DTYPE_VALUE_SIZE_MAP[quantization.dtype]; - const byteBuffer = - compositeBuffer.slice(offset, offset + size * quantizationSizeFactor); - const quantizedArray = (quantization.dtype === 'uint8') ? - new Uint8Array(byteBuffer) : - new Uint16Array(byteBuffer); - if (dtype === 'float32') { - if (quantization.dtype === 'uint8' || quantization.dtype === 'uint16') { - values = new Float32Array(quantizedArray.length); - for (let i = 0; i < quantizedArray.length; i++) { - const v = quantizedArray[i]; - values[i] = v * quantization.scale + quantization.min; - } - } else if (quantization.dtype === 'float16') { - if (float16Decode === undefined) { - float16Decode = getFloat16Decoder(); - } - values = float16Decode(quantizedArray as Uint16Array); - } else { - throw new Error( - `Unsupported quantization type ${quantization.dtype} ` + - `for weight type float32.`); - } - } else if (dtype === 'int32') { - if (quantization.dtype !== 'uint8' && quantization.dtype !== 'uint16') { - throw new Error( - `Unsupported quantization type ${quantization.dtype} ` + - `for weight type int32.`); - } - values = new Int32Array(quantizedArray.length); - for (let i = 0; i < quantizedArray.length; i++) { - const v = quantizedArray[i]; - values[i] = Math.round(v * quantization.scale + quantization.min); - } - } else { - throw new Error(`Unsupported dtype in weight '${name}': ${dtype}`); - } - offset += size * quantizationSizeFactor; - } else if (dtype === 'string') { - const size = sizeFromShape(spec.shape); - values = []; - for (let i = 0; i < size; i++) { - const byteLength = new Uint32Array( - compositeBuffer.slice(offset, offset + NUM_BYTES_STRING_LENGTH))[0]; - offset += NUM_BYTES_STRING_LENGTH; - const bytes = new Uint8Array( - compositeBuffer.slice(offset, offset + byteLength)); - (values as Uint8Array[]).push(bytes); - offset += byteLength; - } - } else { - const dtypeFactor = DTYPE_VALUE_SIZE_MAP[dtype]; - const byteBuffer = compositeBuffer.slice(offset, - offset + size * dtypeFactor); - - if (dtype === 'float32') { - values = new Float32Array(byteBuffer); - } else if (dtype === 'int32') { - values = new Int32Array(byteBuffer); - } else if (dtype === 'bool') { - values = new Uint8Array(byteBuffer); - } else if (dtype === 'complex64') { - values = new Float32Array(byteBuffer); - const real = new Float32Array(values.length / 2); - const image = new Float32Array(values.length / 2); - for (let i = 0; i < real.length; i++) { - real[i] = values[i * 2]; - image[i] = values[i * 2 + 1]; - } - const realTensor = tensor(real, shape, 'float32'); - const imageTensor = tensor(image, shape, 'float32'); - out[name] = complex(realTensor, imageTensor); - realTensor.dispose(); - imageTensor.dispose(); - } else { - throw new Error(`Unsupported dtype in weight '${name}': ${dtype}`); - } - offset += size * dtypeFactor; - } - if (dtype !== 'complex64') { - out[name] = tensor(values, shape, dtype); - } - } - return out; -} - -/** - * Concatenate TypedArrays into an ArrayBuffer. - */ -export function concatenateTypedArrays(xs: TypedArray[]): ArrayBuffer { - // TODO(adarob, cais): Support quantization. - if (xs === null) { - throw new Error(`Invalid input value: ${JSON.stringify(xs)}`); - } - - let totalByteLength = 0; - - // `normalizedXs` is here for this reason: a `TypedArray`'s `buffer' - // can have a different byte length from that of the `TypedArray` itself, - // for example, when the `TypedArray` is created from an offset in an - // `ArrayBuffer`. `normliazedXs` holds `TypedArray`s whose `buffer`s match - // the `TypedArray` in byte length. If an element of `xs` does not show - // this property, a new `TypedArray` that satisfy this property will be - // constructed and pushed into `normalizedXs`. - const normalizedXs: TypedArray[] = []; - xs.forEach((x: TypedArray) => { - totalByteLength += x.byteLength; - // tslint:disable:no-any - normalizedXs.push( - x.byteLength === x.buffer.byteLength ? x : - new (x.constructor as any)(x)); - if (!(x as any instanceof Float32Array || x as any instanceof Int32Array || - x as any instanceof Uint8Array)) { - throw new Error(`Unsupported TypedArray subtype: ${x.constructor.name}`); - } - // tslint:enable:no-any - }); - - const y = new Uint8Array(totalByteLength); - let offset = 0; - normalizedXs.forEach((x: TypedArray) => { - y.set(new Uint8Array(x.buffer), offset); - offset += x.byteLength; - }); - - return y.buffer; -} - -// Use Buffer on Node.js instead of Blob/atob/btoa -const useNodeBuffer = typeof Buffer !== 'undefined' && - (typeof Blob === 'undefined' || typeof atob === 'undefined' || - typeof btoa === 'undefined'); - -/** - * Calculate the byte length of a JavaScript string. - * - * Note that a JavaScript string can contain wide characters, therefore the - * length of the string is not necessarily equal to the byte length. - * - * @param str Input string. - * @returns Byte length. - */ -export function stringByteLength(str: string): number { - if (useNodeBuffer) { - return Buffer.byteLength(str, 'utf8'); - } - return new Blob([str]).size; -} - -/** - * Encode an ArrayBuffer as a base64 encoded string. - * - * @param buffer `ArrayBuffer` to be converted. - * @returns A string that base64-encodes `buffer`. - */ -export function arrayBufferToBase64String(buffer: ArrayBuffer): string { - if (useNodeBuffer) { - return Buffer.from(buffer).toString('base64'); - } - const buf = new Uint8Array(buffer); - let s = ''; - for (let i = 0, l = buf.length; i < l; i++) { - s += String.fromCharCode(buf[i]); - } - return btoa(s); -} - -/** - * Decode a base64 string as an ArrayBuffer. - * - * @param str Base64 string. - * @returns Decoded `ArrayBuffer`. - */ -export function base64StringToArrayBuffer(str: string): ArrayBuffer { - if (useNodeBuffer) { - const buf = Buffer.from(str, 'base64'); - return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength); - } - const s = atob(str); - const buffer = new Uint8Array(s.length); - for (let i = 0; i < s.length; ++i) { - buffer.set([s.charCodeAt(i)], i); - } - return buffer.buffer; -} - -/** - * Concatenate a number of ArrayBuffers into one. - * - * @param buffers An array of ArrayBuffers to concatenate, or a single - * ArrayBuffer. - * @returns Result of concatenating `buffers` in order. - * - * @deprecated Use tf.io.CompositeArrayBuffer.join() instead. - */ -export function concatenateArrayBuffers(buffers: ArrayBuffer[] - | ArrayBuffer): ArrayBuffer { - return CompositeArrayBuffer.join(buffers); -} - -/** - * Get the basename of a path. - * - * Behaves in a way analogous to Linux's basename command. - * - * @param path - */ -export function basename(path: string): string { - const SEPARATOR = '/'; - path = path.trim(); - while (path.endsWith(SEPARATOR)) { - path = path.slice(0, path.length - 1); - } - const items = path.split(SEPARATOR); - return items[items.length - 1]; -} - -/** - * Create `ModelJSON` from `ModelArtifacts`. - * - * @param artifacts Model artifacts, describing the model and its weights. - * @param manifest Weight manifest, describing where the weights of the - * `ModelArtifacts` are stored, and some metadata about them. - * @returns Object representing the `model.json` file describing the model - * artifacts and weights - */ -export function getModelJSONForModelArtifacts( - artifacts: ModelArtifacts, manifest: WeightsManifestConfig): ModelJSON { - const result: ModelJSON = { - modelTopology: artifacts.modelTopology, - format: artifacts.format, - generatedBy: artifacts.generatedBy, - convertedBy: artifacts.convertedBy, - weightsManifest: manifest - }; - if (artifacts.signature != null) { - result.signature = artifacts.signature; - } - if (artifacts.userDefinedMetadata != null) { - result.userDefinedMetadata = artifacts.userDefinedMetadata; - } - if (artifacts.modelInitializer != null) { - result.modelInitializer = artifacts.modelInitializer; - } - if (artifacts.initializerSignature != null) { - result.initializerSignature = artifacts.initializerSignature; - } - if (artifacts.trainingConfig != null) { - result.trainingConfig = artifacts.trainingConfig; - } - return result; -} - -/** - * Create `ModelArtifacts` from a JSON file and weights. - * - * @param modelJSON Object containing the parsed JSON of `model.json` - * @param weightSpecs The list of WeightsManifestEntry for the model. Must be - * passed if the modelJSON has a weightsManifest. - * @param weightData An ArrayBuffer or array of ArrayBuffers of weight data for - * the model corresponding to the weights in weightSpecs. Must be passed if - * the modelJSON has a weightsManifest. - * @returns A Promise of the `ModelArtifacts`, as described by the JSON file. - */ -export function getModelArtifactsForJSONSync( - modelJSON: ModelJSON, weightSpecs?: WeightsManifestEntry[], - weightData?: WeightData): ModelArtifacts { - - const modelArtifacts: ModelArtifacts = { - modelTopology: modelJSON.modelTopology, - format: modelJSON.format, - generatedBy: modelJSON.generatedBy, - convertedBy: modelJSON.convertedBy - }; - - if (modelJSON.trainingConfig != null) { - modelArtifacts.trainingConfig = modelJSON.trainingConfig; - } - if (modelJSON.weightsManifest != null) { - if (!weightSpecs) { - throw new Error('modelJSON has weightsManifest but weightSpecs is null'); - } - if (!weightData) { - throw new Error('modelJSON has weightsManifest but weightData is null'); - } - modelArtifacts.weightSpecs = weightSpecs; - modelArtifacts.weightData = weightData; - } - if (modelJSON.signature != null) { - modelArtifacts.signature = modelJSON.signature; - } - if (modelJSON.userDefinedMetadata != null) { - modelArtifacts.userDefinedMetadata = modelJSON.userDefinedMetadata; - } - if (modelJSON.modelInitializer != null) { - modelArtifacts.modelInitializer = modelJSON.modelInitializer; - } - if (modelJSON.initializerSignature != null) { - modelArtifacts.initializerSignature = modelJSON.initializerSignature; - } - - return modelArtifacts; -} - -/** - * Create `ModelArtifacts` from a JSON file. - * - * @param modelJSON Object containing the parsed JSON of `model.json` - * @param loadWeights Function that takes the JSON file's weights manifest, - * reads weights from the listed path(s), and returns a Promise of the - * weight manifest entries along with the weights data. - * @returns A Promise of the `ModelArtifacts`, as described by the JSON file. - */ -export async function getModelArtifactsForJSON( - modelJSON: ModelJSON, - loadWeights: (weightsManifest: WeightsManifestConfig) => Promise<[ - /* weightSpecs */ WeightsManifestEntry[], WeightData, - ]>): Promise { - let weightSpecs: WeightsManifestEntry[] | undefined; - let weightData: WeightData | undefined; - - if (modelJSON.weightsManifest != null) { - [weightSpecs, weightData] = await loadWeights(modelJSON.weightsManifest); - } - - return getModelArtifactsForJSONSync(modelJSON, weightSpecs, weightData); -} - -/** - * Populate ModelArtifactsInfo fields for a model with JSON topology. - * @param modelArtifacts - * @returns A ModelArtifactsInfo object. - */ -export function getModelArtifactsInfoForJSON(modelArtifacts: ModelArtifacts): - ModelArtifactsInfo { - if (modelArtifacts.modelTopology instanceof ArrayBuffer) { - throw new Error('Expected JSON model topology, received ArrayBuffer.'); - } - - return { - dateSaved: new Date(), - modelTopologyType: 'JSON', - modelTopologyBytes: modelArtifacts.modelTopology == null ? - 0 : - stringByteLength(JSON.stringify(modelArtifacts.modelTopology)), - weightSpecsBytes: modelArtifacts.weightSpecs == null ? - 0 : - stringByteLength(JSON.stringify(modelArtifacts.weightSpecs)), - weightDataBytes: modelArtifacts.weightData == null ? - 0 : - new CompositeArrayBuffer(modelArtifacts.weightData).byteLength, - }; -} - -/** - * Concatenate the weights stored in a WeightsManifestConfig into a list of - * WeightsManifestEntry - * - * @param weightsManifest The WeightsManifestConfig to extract weights from. - * @returns A list of WeightsManifestEntry of the weights in the weightsManifest - */ -export function getWeightSpecs(weightsManifest: WeightsManifestConfig): - WeightsManifestEntry[] { - const weightSpecs: WeightsManifestEntry[] = []; - for (const entry of weightsManifest) { - weightSpecs.push(...entry.weights); - } - return weightSpecs; -} - -/** - * Computes mantisa table for casting Float16 to Float32 - * See http://www.fox-toolkit.org/ftp/fasthalffloatconversion.pdf - * - * @returns Uint32Array, 2048 mantissa lookup values. - */ -function computeFloat16MantisaTable(): Uint32Array { - const convertMantissa = (i: number): number => { - let m = i << 13; - let e = 0; - - while ((m & 0x00800000) === 0) { - e -= 0x00800000; - m <<= 1; - } - m &= ~0x00800000; - e += 0x38800000; - - return m | e; - }; - - const mantisaTable = new Uint32Array(2048); - - mantisaTable[0] = 0; - for (let i = 1; i < 1024; i++) { - mantisaTable[i] = convertMantissa(i); - } - for (let i = 1024; i < 2048; i++) { - mantisaTable[i] = 0x38000000 + ((i - 1024) << 13); - } - - return mantisaTable; -} - -/** - * Computes exponent table for casting Float16 to Float32 - * See http://www.fox-toolkit.org/ftp/fasthalffloatconversion.pdf - * - * @returns Uint32Array, 64 exponent lookup values. - */ -function computeFloat16ExponentTable(): Uint32Array { - const exponentTable = new Uint32Array(64); - - exponentTable[0] = 0; - exponentTable[31] = 0x47800000; - exponentTable[32] = 0x80000000; - exponentTable[63] = 0xc7800000; - for (let i = 1; i < 31; i++) { - exponentTable[i] = i << 23; - } - for (let i = 33; i < 63; i++) { - exponentTable[i] = 0x80000000 + ((i - 32) << 23); - } - - return exponentTable; -} - -/** - * Computes offset table for casting Float16 to Float32 - * See http://www.fox-toolkit.org/ftp/fasthalffloatconversion.pdf - * - * @returns Uint32Array, 6d offset values. - */ -function computeFloat16OffsetTable(): Uint32Array { - const offsetTable = new Uint32Array(64); - - for (let i = 0; i < 64; i++) { - offsetTable[i] = 1024; - } - offsetTable[0] = offsetTable[32] = 0; - - return offsetTable; -} - -/** - * Retrieve a Float16 decoder which will decode a ByteArray of Float16 values - * to a Float32Array. - * - * @returns Function (buffer: Uint16Array) => Float32Array which decodes - * the Uint16Array of Float16 bytes to a Float32Array. - */ -export function getFloat16Decoder(): (buffer: Uint16Array) => Float32Array { - // Algorithm is based off of - // http://www.fox-toolkit.org/ftp/fasthalffloatconversion.pdf - - // Cache lookup tables - const mantisaTable = computeFloat16MantisaTable(); - const exponentTable = computeFloat16ExponentTable(); - const offsetTable = computeFloat16OffsetTable(); - - return (quantizedArray: Uint16Array) => { - const buffer = new ArrayBuffer(4 * quantizedArray.length); - const bufferUint32View = new Uint32Array(buffer); - for (let index = 0; index < quantizedArray.length; index++) { - const float16Bits = quantizedArray[index]; - const float32Bits = - mantisaTable[offsetTable[float16Bits >> 10] + (float16Bits & 0x3ff)] + - exponentTable[float16Bits >> 10]; - bufferUint32View[index] = float32Bits; - } - return new Float32Array(buffer); - }; -} diff --git a/tfjs-master/tfjs-core/src/io/io_utils_test.ts b/tfjs-master/tfjs-core/src/io/io_utils_test.ts deleted file mode 100644 index 01e497c07..000000000 --- a/tfjs-master/tfjs-core/src/io/io_utils_test.ts +++ /dev/null @@ -1,733 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, BROWSER_ENVS, describeWithFlags} from '../jasmine_util'; -import {scalar, tensor1d, tensor2d} from '../ops/ops'; -import {NamedTensor, NamedTensorMap} from '../tensor_types'; -import {expectArraysEqual} from '../test_util'; -import {expectArraysClose} from '../test_util'; -import {encodeString} from '../util'; - -import {arrayBufferToBase64String, base64StringToArrayBuffer, basename, concatenateArrayBuffers, concatenateTypedArrays, stringByteLength, getFloat16Decoder} from './io_utils'; -import {WeightsManifestEntry} from './types'; - -describe('concatenateTypedArrays', () => { - it('Single float arrays', () => { - const x = new Float32Array([1.1, 2.2, 3.3]); - const buffer = concatenateTypedArrays([x]); - expect(buffer.byteLength).toEqual(12); - expect(new Float32Array(buffer, 0, 3)).toEqual(x); - }); - - it('Float arrays', () => { - const x = new Float32Array([1.1, 2.2, 3.3]); - const y = new Float32Array([-1.1, -2.2, -3.3]); - const buffer = concatenateTypedArrays([x, y]); - expect(buffer.byteLength).toEqual(24); - expect(new Float32Array(buffer, 0, 3)).toEqual(x); - expect(new Float32Array(buffer, 12, 3)).toEqual(y); - }); - it('Single int32 arrays', () => { - const x = new Int32Array([11, 22, 33]); - const buffer = concatenateTypedArrays([x]); - expect(buffer.byteLength).toEqual(12); - expect(new Int32Array(buffer, 0, 3)).toEqual(x); - }); - - it('Int32 arrays', () => { - const x = new Int32Array([11, 22, 33]); - const y = new Int32Array([-11, -22, -33]); - const buffer = concatenateTypedArrays([x, y]); - expect(buffer.byteLength).toEqual(24); - expect(new Int32Array(buffer, 0, 3)).toEqual(x); - expect(new Int32Array(buffer, 12, 3)).toEqual(y); - }); - - it('Single uint8 arrays', () => { - const x = new Uint8Array([11, 22, 33]); - const buffer = concatenateTypedArrays([x]); - expect(buffer.byteLength).toEqual(3); - expect(new Uint8Array(buffer, 0, 3)).toEqual(x); - }); - - it('Uint8 arrays', () => { - const x = new Uint8Array([11, 22, 33]); - const y = new Uint8Array([111, 122, 133]); - const buffer = concatenateTypedArrays([x, y]); - expect(buffer.byteLength).toEqual(6); - expect(new Uint8Array(buffer, 0, 3)).toEqual(x); - expect(new Uint8Array(buffer, 3, 3)).toEqual(y); - }); - - it('Mixed Uint8, Int32 and Float32 arrays', () => { - const x = new Uint8Array([0, 1, 1, 0]); - const y = new Int32Array([10, 20, 30, 40]); - const z = new Float32Array([-1.1, -2.2, -3.3, -4.4]); - const buffer = concatenateTypedArrays([x, y, z]); - expect(buffer.byteLength).toEqual(1 * 4 + 4 * 4 + 4 * 4); - expect(new Uint8Array(buffer, 0, 4)).toEqual(x); - expect(new Int32Array(buffer, 4, 4)).toEqual(y); - expect(new Float32Array(buffer, 20, 4)).toEqual(z); - }); - - it('Concatenate Float32Arrays from SubArrays', () => { - const x1 = new Float32Array([1.1, 2.2, 3.3]); - const x2 = new Float32Array([-1.1, -2.2, -3.3]); - const xConcatenated = concatenateTypedArrays([x1, x2]); - const y1 = new Float32Array(xConcatenated, 0, 3); - const y2 = new Float32Array(xConcatenated, 3 * 4, 3); - // At this point, the buffer of y1 is longer than than the actual byte - // length of y1, because of the way y1 is constructed. The same is true for - // y2. - expect(y1.buffer.byteLength).toEqual(6 * 4); - expect(y2.buffer.byteLength).toEqual(6 * 4); - - const yConcatenated = concatenateTypedArrays([y1, y2]); - expect(yConcatenated.byteLength).toEqual(6 * 4); - expect(new Float32Array(yConcatenated, 0, 3)).toEqual(x1); - expect(new Float32Array(yConcatenated, 3 * 4, 3)).toEqual(x2); - }); - - it('Concatenate Int32Array from SubArrays', () => { - const x1 = new Int32Array([11, 22, 33]); - const x2 = new Int32Array([-11, -22, -33]); - const xConcatenated = concatenateTypedArrays([x1, x2]); - const y1 = new Int32Array(xConcatenated, 0, 3); - const y2 = new Int32Array(xConcatenated, 3 * 4, 3); - // At this point, the buffer of y1 is longer than than the actual byte - // length of y1, because of the way y1 is constructed. The same is true for - // y2. - expect(y1.buffer.byteLength).toEqual(6 * 4); - expect(y2.buffer.byteLength).toEqual(6 * 4); - - const yConcatenated = concatenateTypedArrays([y1, y2]); - expect(yConcatenated.byteLength).toEqual(6 * 4); - expect(new Int32Array(yConcatenated, 0, 3)).toEqual(x1); - expect(new Int32Array(yConcatenated, 3 * 4, 3)).toEqual(x2); - }); - - it('Concatenate Uint8Array from SubArrays', () => { - const x1 = new Uint8Array([11, 22, 33]); - const x2 = new Uint8Array([44, 55, 66]); - const xConcatenated = concatenateTypedArrays([x1, x2]); - const y1 = new Uint8Array(xConcatenated, 0, 3); - const y2 = new Uint8Array(xConcatenated, 3, 3); - // At this point, the buffer of y1 is longer than than the actual byte - // length of y1, because of the way y1 is constructed. The same is true for - // y2. - expect(y1.buffer.byteLength).toEqual(6); - expect(y2.buffer.byteLength).toEqual(6); - - const yConcatenated = concatenateTypedArrays([y1, y2]); - expect(yConcatenated.byteLength).toEqual(6); - expect(new Uint8Array(yConcatenated, 0, 3)).toEqual(x1); - expect(new Uint8Array(yConcatenated, 3, 3)).toEqual(x2); - }); - - it('Concatenate mixed TypedArrays from SubArrays', () => { - const x1 = new Uint8Array([11, 22, 33, 44]); - const x2 = new Int32Array([-44, -55, -66]); - const x3 = new Float32Array([1.1, 2.2, 3.3]); - const xConcatenated = concatenateTypedArrays([x1, x2, x3]); - const y1 = new Uint8Array(xConcatenated, 0, 4); - const y2 = new Int32Array(xConcatenated, 4, 3); - const y3 = new Float32Array(xConcatenated, 4 + 3 * 4, 3); - // At this point, the buffer of y1 is longer than than the actual byte - // length of y1, because of the way y1 is constructed. The same is true for - // y2 and y3. - expect(y1.buffer.byteLength).toEqual(4 + 3 * 4 + 3 * 4); - expect(y2.buffer.byteLength).toEqual(4 + 3 * 4 + 3 * 4); - expect(y3.buffer.byteLength).toEqual(4 + 3 * 4 + 3 * 4); - - const yConcatenated = concatenateTypedArrays([y1, y2, y3]); - expect(yConcatenated.byteLength).toEqual(4 + 3 * 4 + 3 * 4); - expect(new Uint8Array(yConcatenated, 0, 4)).toEqual(x1); - expect(new Int32Array(yConcatenated, 4, 3)).toEqual(x2); - expect(new Float32Array(yConcatenated, 4 + 3 * 4, 3)).toEqual(x3); - }); - - it('null and undefined inputs', () => { - expect(() => concatenateTypedArrays(null)).toThrow(); - expect(() => concatenateTypedArrays(undefined)).toThrow(); - }); - - it('empty input array', () => { - expect(concatenateTypedArrays([]).byteLength).toEqual(0); - }); - - it('Unsupported dtype', () => { - const x = new Int16Array([0, 1, 1, 0]); - // tslint:disable-next-line:no-any - expect(() => concatenateTypedArrays([x as any])) - .toThrowError(/Unsupported TypedArray subtype: Int16Array/); - }); -}); - -describeWithFlags('encodeWeights', ALL_ENVS, () => { - it('Float32 tensors as NamedTensorMap', async () => { - const tensors: NamedTensorMap = { - x1: tensor2d([[10, 20], [30, 40]]), - x2: scalar(42), - x3: tensor1d([-1.3, -3.7, 1.3, 3.7]), - }; - const dataAndSpecs = await tf.io.encodeWeights(tensors); - const data = dataAndSpecs.data; - const specs = dataAndSpecs.specs; - expect(data.byteLength).toEqual(4 * (4 + 1 + 4)); - expect(new Float32Array(data, 0, 4)).toEqual(new Float32Array([ - 10, 20, 30, 40 - ])); - expect(new Float32Array(data, 16, 1)).toEqual(new Float32Array([42])); - expect(new Float32Array(data, 20, 4)).toEqual(new Float32Array([ - -1.3, -3.7, 1.3, 3.7 - ])); - expect(specs).toEqual([ - { - name: 'x1', - dtype: 'float32', - shape: [2, 2], - }, - { - name: 'x2', - dtype: 'float32', - shape: [], - }, - { - name: 'x3', - dtype: 'float32', - shape: [4], - } - ]); - }); - - it('Float32 tensors as NamedTensor array', async () => { - const tensors: NamedTensor[] = [ - {name: 'x1234', tensor: tensor2d([[10, 20], [30, 40]])}, { - name: 'a42', - tensor: scalar(42), - }, - {name: 'b41', tensor: tensor1d([-1.3, -3.7, 1.3, 3.7])} - ]; - const dataAndSpecs = await tf.io.encodeWeights(tensors); - const data = dataAndSpecs.data; - const specs = dataAndSpecs.specs; - expect(data.byteLength).toEqual(4 * (4 + 1 + 4)); - expect(new Float32Array(data, 0, 4)).toEqual(new Float32Array([ - 10, 20, 30, 40 - ])); - expect(new Float32Array(data, 16, 1)).toEqual(new Float32Array([42])); - expect(new Float32Array(data, 20, 4)).toEqual(new Float32Array([ - -1.3, -3.7, 1.3, 3.7 - ])); - expect(specs).toEqual([ - { - name: 'x1234', - dtype: 'float32', - shape: [2, 2], - }, - { - name: 'a42', - dtype: 'float32', - shape: [], - }, - { - name: 'b41', - dtype: 'float32', - shape: [4], - } - ]); - }); - - it('Empty NamedTensor array', async () => { - const tensors: NamedTensor[] = []; - const dataAndSpecs = await tf.io.encodeWeights(tensors); - const data = dataAndSpecs.data; - const specs = dataAndSpecs.specs; - expect(data.byteLength).toEqual(0); - expect(specs).toEqual([]); - }); - - it('Int32 tensors', async () => { - const tensors: NamedTensorMap = { - x1: tensor2d([[10, 20], [30, 40]], [2, 2], 'int32'), - x2: scalar(42, 'int32'), - x3: tensor1d([-1, -3, -3, -7], 'int32'), - }; - const dataAndSpecs = await tf.io.encodeWeights(tensors); - const data = dataAndSpecs.data; - const specs = dataAndSpecs.specs; - expect(data.byteLength).toEqual(4 * (4 + 1 + 4)); - expect(new Int32Array(data, 0, 4)).toEqual(new Int32Array([ - 10, 20, 30, 40 - ])); - expect(new Int32Array(data, 16, 1)).toEqual(new Int32Array([42])); - expect(new Int32Array(data, 20, 4)).toEqual(new Int32Array([ - -1, -3, -3, -7 - ])); - expect(specs).toEqual([ - { - name: 'x1', - dtype: 'int32', - shape: [2, 2], - }, - { - name: 'x2', - dtype: 'int32', - shape: [], - }, - { - name: 'x3', - dtype: 'int32', - shape: [4], - } - ]); - }); - - it('Bool tensors', async () => { - const tensors: NamedTensorMap = { - x1: tensor2d([[true, false], [false, true]], [2, 2], 'bool'), - x2: scalar(false, 'bool'), - x3: tensor1d([false, true, true, false], 'bool'), - }; - const dataAndSpecs = await tf.io.encodeWeights(tensors); - const data = dataAndSpecs.data; - const specs = dataAndSpecs.specs; - expect(data.byteLength).toEqual(4 + 1 + 4); - expect(new Uint8Array(data, 0, 4)).toEqual(new Uint8Array([1, 0, 0, 1])); - expect(new Uint8Array(data, 4, 1)).toEqual(new Uint8Array([0])); - expect(new Uint8Array(data, 5, 4)).toEqual(new Uint8Array([0, 1, 1, 0])); - expect(specs).toEqual([ - { - name: 'x1', - dtype: 'bool', - shape: [2, 2], - }, - { - name: 'x2', - dtype: 'bool', - shape: [], - }, - { - name: 'x3', - dtype: 'bool', - shape: [4], - } - ]); - }); - - it('Complex64 tensors', async () => { - const tensors: NamedTensorMap = { - x1: tf.complex([1, 2], [1, 2]), - x2: tf.complex(1, 2), - x3: tf.complex([[1]], [[2]]), - }; - const dataAndSpecs = await tf.io.encodeWeights(tensors); - const data = dataAndSpecs.data; - const specs = dataAndSpecs.specs; - expect(data.byteLength).toEqual(8 * 4); - expect(new Float32Array(data, 0, 4)).toEqual(new Float32Array([ - 1, 1, 2, 2 - ])); - expect(new Float32Array(data, 16, 2)).toEqual(new Float32Array([1, 2])); - expect(new Float32Array(data, 24, 2)).toEqual(new Float32Array([1, 2])); - expect(specs).toEqual([ - { - name: 'x1', - dtype: 'complex64', - shape: [2], - }, - { - name: 'x2', - dtype: 'complex64', - shape: [], - }, - { - name: 'x3', - dtype: 'complex64', - shape: [1, 1], - } - ]); - }); - it('String tensors', async () => { - const tensors: NamedTensorMap = { - x1: tensor2d([['a', 'bc'], ['def', 'g']], [2, 2]), - x2: scalar(''), // Empty string. - x3: tensor1d(['здраво', 'поздрав']), // Cyrillic. - x4: scalar('正常'), // East Asian. - x5: scalar('hello') // Single string. - }; - const dataAndSpecs = await tf.io.encodeWeights(tensors); - const data = dataAndSpecs.data; - const specs = dataAndSpecs.specs; - const x1ByteLength = 7 + 4 * 4; // 7 ascii chars + 4 ints. - const x2ByteLength = 4; // No chars + 1 int. - const x3ByteLength = 13 * 2 + 2 * 4; // 13 cyrillic letters + 2 ints. - const x4ByteLength = 6 + 1 * 4; // 2 east asian letters + 1 int. - const x5ByteLength = 5 + 1 * 4; // 5 ascii chars + 1 int. - expect(data.byteLength) - .toEqual( - x1ByteLength + x2ByteLength + x3ByteLength + x4ByteLength + - x5ByteLength); - // x1 'a'. - expect(new Uint32Array(data, 0, 1)[0]).toBe(1); - expect(new Uint8Array(data, 4, 1)).toEqual(encodeString('a')); - // x1 'bc'. - expect(new Uint32Array(data.slice(5, 9))[0]).toBe(2); - expect(new Uint8Array(data, 9, 2)).toEqual(encodeString('bc')); - // x1 'def'. - expect(new Uint32Array(data.slice(11, 15))[0]).toBe(3); - expect(new Uint8Array(data, 15, 3)).toEqual(encodeString('def')); - // x1 'g'. - expect(new Uint32Array(data.slice(18, 22))[0]).toBe(1); - expect(new Uint8Array(data, 22, 1)).toEqual(encodeString('g')); - - // x2 is empty string. - expect(new Uint32Array(data.slice(23, 27))[0]).toBe(0); - - // x3 'здраво'. - expect(new Uint32Array(data.slice(27, 31))[0]).toBe(12); - expect(new Uint8Array(data, 31, 12)).toEqual(encodeString('здраво')); - - // x3 'поздрав'. - expect(new Uint32Array(data.slice(43, 47))[0]).toBe(14); - expect(new Uint8Array(data, 47, 14)).toEqual(encodeString('поздрав')); - - // x4 '正常'. - expect(new Uint32Array(data.slice(61, 65))[0]).toBe(6); - expect(new Uint8Array(data, 65, 6)).toEqual(encodeString('正常')); - - // x5 'hello'. - expect(new Uint32Array(data.slice(71, 75))[0]).toBe(5); - expect(new Uint8Array(data, 75, 5)).toEqual(encodeString('hello')); - - expect(specs).toEqual([ - {name: 'x1', dtype: 'string', shape: [2, 2]}, - {name: 'x2', dtype: 'string', shape: []}, - {name: 'x3', dtype: 'string', shape: [2]}, - {name: 'x4', dtype: 'string', shape: []}, - {name: 'x5', dtype: 'string', shape: []} - ]); - }); - - it('Mixed dtype tensors', async () => { - const tensors: NamedTensorMap = { - x1: tensor2d([[10, 20], [30, 40]], [2, 2], 'int32'), - x2: scalar(13.37, 'float32'), - x3: tensor1d([true, false, false, true], 'bool'), - x4: tf.complex([1, 1], [2, 2]) - }; - const dataAndSpecs = await tf.io.encodeWeights(tensors); - const data = dataAndSpecs.data; - const specs = dataAndSpecs.specs; - expect(data.byteLength).toEqual(4 * 4 + 4 * 1 + 1 * 4 + 4 * 4); - expect(new Int32Array(data, 0, 4)).toEqual(new Int32Array([ - 10, 20, 30, 40 - ])); - expect(new Float32Array(data, 16, 1)).toEqual(new Float32Array([13.37])); - expect(new Uint8Array(data, 20, 4)).toEqual(new Uint8Array([1, 0, 0, 1])); - expect(new Float32Array(data, 24, 4)).toEqual(new Float32Array([ - 1, 2, 1, 2 - ])); - expect(specs).toEqual([ - { - name: 'x1', - dtype: 'int32', - shape: [2, 2], - }, - { - name: 'x2', - dtype: 'float32', - shape: [], - }, - { - name: 'x3', - dtype: 'bool', - shape: [4], - }, - { - name: 'x4', - dtype: 'complex64', - shape: [2], - } - ]); - }); -}); - -describeWithFlags('decodeWeights', {}, () => { - it('Mixed dtype tensors', async () => { - const tensors: NamedTensorMap = { - x1: tensor2d([[10, 20], [30, 40]], [2, 2], 'int32'), - x2: scalar(13.37, 'float32'), - x3: tensor1d([true, false, false], 'bool'), - x4: tensor2d([['здраво', 'a'], ['b', 'c']], [2, 2], 'string'), - x5: tensor1d([''], 'string'), // Empty string. - x6: scalar('hello'), // Single string. - y1: tensor2d([-10, -20, -30], [3, 1], 'float32'), - y2: tf.complex([1, 1], [2, 2]) - }; - const dataAndSpecs = await tf.io.encodeWeights(tensors); - const data = dataAndSpecs.data; - const specs = dataAndSpecs.specs; - const decoded = tf.io.decodeWeights(data, specs); - expect(Object.keys(decoded).length).toEqual(8); - expectArraysEqual(await decoded['x1'].data(), await tensors['x1'].data()); - expectArraysEqual(await decoded['x2'].data(), await tensors['x2'].data()); - expectArraysEqual(await decoded['x3'].data(), await tensors['x3'].data()); - expectArraysEqual(await decoded['x4'].data(), await tensors['x4'].data()); - expectArraysEqual(await decoded['x5'].data(), await tensors['x5'].data()); - expectArraysEqual(await decoded['x6'].data(), await tensors['x6'].data()); - expectArraysEqual(await decoded['y1'].data(), await tensors['y1'].data()); - expectArraysEqual(await decoded['y2'].data(), await tensors['y2'].data()); - }); - - it('Unsupported dtype raises Error', () => { - const buffer = new ArrayBuffer(4); - // tslint:disable-next-line:no-any - const specs: any = [ - { - name: 'x', - dtype: 'int16', - shape: [], - }, - {name: 'y', dtype: 'int16', shape: []} - ]; - expect(() => tf.io.decodeWeights(buffer, specs)) - .toThrowError(/Unsupported dtype in weight \'x\': int16/); - }); - - it('support quantization uint8 weights', async () => { - const manifestSpecs: WeightsManifestEntry[] = [ - { - 'name': 'weight0', - 'dtype': 'float32', - 'shape': [3], - 'quantization': {'min': -1, 'scale': 0.1, 'dtype': 'uint8'} - }, - { - 'name': 'weight1', - 'dtype': 'int32', - 'shape': [3], - 'quantization': {'min': -1, 'scale': 0.1, 'dtype': 'uint8'} - } - ]; - const data = new Uint8Array([0, 48, 255, 0, 48, 255]); - const decoded = tf.io.decodeWeights(data.buffer, manifestSpecs); - const weight0 = decoded['weight0']; - expectArraysClose(await weight0.data(), [-1, 3.8, 24.5]); - expect(weight0.shape).toEqual([3]); - expect(weight0.dtype).toEqual('float32'); - - const weight1 = decoded['weight1']; - expectArraysEqual(await weight1.data(), [-1, 4, 25]); - expect(weight1.shape).toEqual([3]); - expect(weight1.dtype).toEqual('int32'); - }); - - it('support quantization uint16 weights', async () => { - const manifestSpecs: WeightsManifestEntry[] = [ - { - 'name': 'weight0', - 'dtype': 'float32', - 'shape': [3], - 'quantization': {'min': -1, 'scale': 0.1, 'dtype': 'uint16'} - }, - { - 'name': 'weight1', - 'dtype': 'int32', - 'shape': [3], - 'quantization': {'min': -1, 'scale': 0.1, 'dtype': 'uint16'} - } - ]; - const data = new Uint16Array([0, 48, 255, 0, 48, 255]); - const decoded = tf.io.decodeWeights(data.buffer, manifestSpecs); - const weight0 = decoded['weight0']; - expectArraysClose(await weight0.data(), [-1, 3.8, 24.5]); - expect(weight0.shape).toEqual([3]); - expect(weight0.dtype).toEqual('float32'); - - const weight1 = decoded['weight1']; - expectArraysEqual(await weight1.data(), [-1, 4, 25]); - expect(weight1.shape).toEqual([3]); - expect(weight1.dtype).toEqual('int32'); - }); - it('support quantization float16 weights', async () => { - const manifestSpecs: WeightsManifestEntry[] = [ - { - name: 'weight0', - dtype: 'float32', - shape: [3], - quantization: { dtype: 'float16' }, - }, - ]; - const data = new Uint16Array([13312, 14336, 14848]); - const decoded = tf.io.decodeWeights(data.buffer, manifestSpecs); - const weight0 = decoded['weight0']; - expectArraysClose(await weight0.data(), [0.25, 0.5, 0.75]); - expect(weight0.shape).toEqual([3]); - expect(weight0.dtype).toEqual('float32'); - }); -}); - -describe('stringByteLength', () => { - it('ASCII only', () => { - const str = '_Lorem ipsum 1337!'; - expect(stringByteLength(str)).toEqual(str.length); - }); - - it('Mixed narrow and wide chars', () => { - const str = 'aЖ文1'; - expect(stringByteLength(str.slice(0, 1))).toEqual(1); - expect(stringByteLength(str.slice(0, 2))).toEqual(3); - expect(stringByteLength(str.slice(0, 3))).toEqual(6); - expect(stringByteLength(str.slice(0, 4))).toEqual(7); - }); -}); - -describeWithFlags( - 'arrayBufferToBase64String-base64StringToArrayBuffer', BROWSER_ENVS, () => { - it('Round trip', () => { - // Generate some semi-random binary data. - const x = []; - for (let k = 0; k < 2; ++k) { - for (let i = 0; i < 254; ++i) { - x.push(i + k); - } - for (let i = 254; i >= 0; --i) { - x.push(i + k); - } - } - const buffer = Uint8Array.from(x).buffer; - const base64Str = arrayBufferToBase64String(buffer); - const decoded = - Array.from(new Uint8Array(base64StringToArrayBuffer(base64Str))); - expect(decoded).toEqual(x); - }); - }); - -describe('concatenateArrayBuffers', () => { - // TODO(mattSoulanille): Move these tests to CompositeArrayBuffer.join when - // concatenateArrayBuffers is removed. - it('Concatenate 3 non-empty ArrayBuffers', () => { - const buffer1 = new Uint8Array([1, 2, 3]); - const buffer2 = new Uint8Array([11, 22, 33, 44]); - const buffer3 = new Uint8Array([111, 222, 100]); - const out = concatenateArrayBuffers( - [buffer1.buffer, buffer2.buffer, buffer3.buffer]); - expect(new Uint8Array(out)).toEqual(new Uint8Array([ - 1, 2, 3, 11, 22, 33, 44, 111, 222, 100 - ])); - }); - - it('Concatenate non-empty and empty ArrayBuffers', () => { - const buffer1 = new Uint8Array([1, 2, 3]); - const buffer2 = new Uint8Array([11, 22, 33, 44]); - const buffer3 = new Uint8Array([]); - const buffer4 = new Uint8Array([150, 100, 50]); - const out = concatenateArrayBuffers( - [buffer1.buffer, buffer2.buffer, buffer3.buffer, buffer4.buffer]); - expect(new Uint8Array(out)).toEqual(new Uint8Array([ - 1, 2, 3, 11, 22, 33, 44, 150, 100, 50 - ])); - }); - - it('A single ArrayBuffer', () => { - const buffer1 = new Uint8Array([1, 3, 3, 7]); - const out = concatenateArrayBuffers([buffer1.buffer]); - expect(new Uint8Array(out)).toEqual(buffer1); - }); - - it('Zero ArrayBuffers', () => { - expect(new Uint8Array(concatenateArrayBuffers([]))) - .toEqual(new Uint8Array([])); - }); -}); - -describe('basename', () => { - it('Paths without slashes', () => { - expect(basename('foo.txt')).toEqual('foo.txt'); - expect(basename('bar')).toEqual('bar'); - }); - - it('Paths with slashes', () => { - expect(basename('qux/foo.txt')).toEqual('foo.txt'); - expect(basename('qux/My Model.json')).toEqual('My Model.json'); - expect(basename('foo/bar/baz')).toEqual('baz'); - expect(basename('/foo/bar/baz')).toEqual('baz'); - expect(basename('foo/bar/baz/')).toEqual('baz'); - expect(basename('foo/bar/baz//')).toEqual('baz'); - }); -}); - -describe('float16', () => { - it('decodes NaN to float32 NaN', () => { - const decoder = getFloat16Decoder(); - const float16NaN = 0x00007e00; - const buffer = new Uint16Array([float16NaN]); - const f32 = decoder(buffer); - expect(f32).toEqual(new Float32Array([NaN])); - }); - - it('decodes ±Infinity to float32 ±Infinity', () => { - const decoder = getFloat16Decoder(); - const positiveInfinity = 0x00007c00; - const negativeInfinity = 0xfffffc00; - const buffer = new Uint16Array([positiveInfinity, negativeInfinity]); - const f32 = decoder(buffer); - expect(f32).toEqual(new Float32Array([Infinity, -Infinity])); - }); - - it('decodes ±0 to float32 ±0', () => { - const decoder = getFloat16Decoder(); - const positiveZero = 0x00000000; - const negativeZero = 0xffff8000; - const buffer = new Uint16Array([positiveZero, negativeZero]); - const f32 = decoder(buffer); - expect(f32).toEqual(new Float32Array([0.0, -0.0])); - }); - - it('decodes -Infinity on underflow', () => { - const decoder = getFloat16Decoder(); - const minVal = 0xfffffbff; - const buffer = new Uint16Array([minVal + 1]); - const f32 = decoder(buffer); - expect(f32).toEqual(new Float32Array([-Infinity])); - }); - - it('decodes +Infinity on overflow', () => { - const decoder = getFloat16Decoder(); - const maxVal = 0x00007bff; - const buffer = new Uint16Array([maxVal + 1]); - const f32 = decoder(buffer); - expect(f32).toEqual(new Float32Array([Infinity])); - }); - - it('decodes interpretable float16 to float32', () => { - const decoder = getFloat16Decoder(); - const buffer = new Uint16Array([ - 0x00003400, - 0x00003800, - 0x00003A00, - 0x00003555 - ]); - const f32 = decoder(buffer); - expect(f32[0]).toBeCloseTo(0.25); - expect(f32[1]).toBeCloseTo(0.5); - expect(f32[2]).toBeCloseTo(0.75); - expect(f32[3]).toBeCloseTo(0.333); - }); -}); diff --git a/tfjs-master/tfjs-core/src/io/local_storage.ts b/tfjs-master/tfjs-core/src/io/local_storage.ts deleted file mode 100644 index f20206a92..000000000 --- a/tfjs-master/tfjs-core/src/io/local_storage.ts +++ /dev/null @@ -1,390 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import '../flags'; -import {env} from '../environment'; - -import {assert} from '../util'; -import {arrayBufferToBase64String, base64StringToArrayBuffer, getModelArtifactsInfoForJSON} from './io_utils'; -import {CompositeArrayBuffer} from './composite_array_buffer'; -import {IORouter, IORouterRegistry} from './router_registry'; -import {IOHandler, ModelArtifacts, ModelArtifactsInfo, ModelJSON, ModelStoreManager, SaveResult} from './types'; - -const PATH_SEPARATOR = '/'; -const PATH_PREFIX = 'tensorflowjs_models'; -const INFO_SUFFIX = 'info'; -const MODEL_TOPOLOGY_SUFFIX = 'model_topology'; -const WEIGHT_SPECS_SUFFIX = 'weight_specs'; -const WEIGHT_DATA_SUFFIX = 'weight_data'; -const MODEL_METADATA_SUFFIX = 'model_metadata'; - -/** - * Purge all tensorflow.js-saved model artifacts from local storage. - * - * @returns Paths of the models purged. - */ -export function purgeLocalStorageArtifacts(): string[] { - if (!env().getBool('IS_BROWSER') || typeof window === 'undefined' || - typeof window.localStorage === 'undefined') { - throw new Error( - 'purgeLocalStorageModels() cannot proceed because local storage is ' + - 'unavailable in the current environment.'); - } - const LS = window.localStorage; - const purgedModelPaths: string[] = []; - for (let i = 0; i < LS.length; ++i) { - const key = LS.key(i); - const prefix = PATH_PREFIX + PATH_SEPARATOR; - if (key.startsWith(prefix) && key.length > prefix.length) { - LS.removeItem(key); - const modelName = getModelPathFromKey(key); - if (purgedModelPaths.indexOf(modelName) === -1) { - purgedModelPaths.push(modelName); - } - } - } - return purgedModelPaths; -} - -type LocalStorageKeys = { - /** Key of the localStorage entry storing `ModelArtifactsInfo`. */ - info: string, - /** - * Key of the localStorage entry storing the 'modelTopology' key of - * `model.json` - */ - topology: string, - /** - * Key of the localStorage entry storing the `weightsManifest.weights` entries - * of `model.json` - */ - weightSpecs: string, - /** Key of the localStorage entry storing the weight data in Base64 */ - weightData: string, - /** - * Key of the localStorage entry storing the remaining fields of `model.json` - * @see {@link ModelMetadata} - */ - modelMetadata: string, -}; - -type ModelMetadata = Omit; - -function getModelKeys(path: string): LocalStorageKeys { - return { - info: [PATH_PREFIX, path, INFO_SUFFIX].join(PATH_SEPARATOR), - topology: [PATH_PREFIX, path, MODEL_TOPOLOGY_SUFFIX].join(PATH_SEPARATOR), - weightSpecs: [PATH_PREFIX, path, WEIGHT_SPECS_SUFFIX].join(PATH_SEPARATOR), - weightData: [PATH_PREFIX, path, WEIGHT_DATA_SUFFIX].join(PATH_SEPARATOR), - modelMetadata: - [PATH_PREFIX, path, MODEL_METADATA_SUFFIX].join(PATH_SEPARATOR) - }; -} - -function removeItems(keys: LocalStorageKeys): void { - for (const key of Object.values(keys)) { - window.localStorage.removeItem(key); - } -} - -/** - * Get model path from a local-storage key. - * - * E.g., 'tensorflowjs_models/my/model/1/info' --> 'my/model/1' - * - * @param key - */ -function getModelPathFromKey(key: string) { - const items = key.split(PATH_SEPARATOR); - if (items.length < 3) { - throw new Error(`Invalid key format: ${key}`); - } - return items.slice(1, items.length - 1).join(PATH_SEPARATOR); -} - -function maybeStripScheme(key: string) { - return key.startsWith(BrowserLocalStorage.URL_SCHEME) ? - key.slice(BrowserLocalStorage.URL_SCHEME.length) : - key; -} - -/** - * IOHandler subclass: Browser Local Storage. - * - * See the doc string to `browserLocalStorage` for more details. - */ -export class BrowserLocalStorage implements IOHandler { - protected readonly LS: Storage; - protected readonly modelPath: string; - protected readonly keys: LocalStorageKeys; - - static readonly URL_SCHEME = 'localstorage://'; - - constructor(modelPath: string) { - if (!env().getBool('IS_BROWSER') || typeof window === 'undefined' || - typeof window.localStorage === 'undefined') { - // TODO(cais): Add more info about what IOHandler subtypes are - // available. - // Maybe point to a doc page on the web and/or automatically determine - // the available IOHandlers and print them in the error message. - throw new Error( - 'The current environment does not support local storage.'); - } - this.LS = window.localStorage; - - if (modelPath == null || !modelPath) { - throw new Error( - 'For local storage, modelPath must not be null, undefined or empty.'); - } - this.modelPath = modelPath; - this.keys = getModelKeys(this.modelPath); - } - - /** - * Save model artifacts to browser local storage. - * - * See the documentation to `browserLocalStorage` for details on the saved - * artifacts. - * - * @param modelArtifacts The model artifacts to be stored. - * @returns An instance of SaveResult. - */ - async save(modelArtifacts: ModelArtifacts): Promise { - if (modelArtifacts.modelTopology instanceof ArrayBuffer) { - throw new Error( - 'BrowserLocalStorage.save() does not support saving model topology ' + - 'in binary formats yet.'); - } else { - const topology = JSON.stringify(modelArtifacts.modelTopology); - const weightSpecs = JSON.stringify(modelArtifacts.weightSpecs); - - const modelArtifactsInfo: ModelArtifactsInfo = - getModelArtifactsInfoForJSON(modelArtifacts); - - // TODO(mattsoulanille): Support saving models over 2GB that exceed - // Chrome's ArrayBuffer size limit. - const weightBuffer = CompositeArrayBuffer.join(modelArtifacts.weightData); - - try { - this.LS.setItem(this.keys.info, JSON.stringify(modelArtifactsInfo)); - this.LS.setItem(this.keys.topology, topology); - this.LS.setItem(this.keys.weightSpecs, weightSpecs); - this.LS.setItem( - this.keys.weightData, - arrayBufferToBase64String(weightBuffer)); - - // Note that JSON.stringify doesn't write out keys that have undefined - // values, so for some keys, we set undefined instead of a null-ish - // value. - const metadata: Required = { - format: modelArtifacts.format, - generatedBy: modelArtifacts.generatedBy, - convertedBy: modelArtifacts.convertedBy, - signature: modelArtifacts.signature != null ? - modelArtifacts.signature : - undefined, - userDefinedMetadata: modelArtifacts.userDefinedMetadata != null ? - modelArtifacts.userDefinedMetadata : - undefined, - modelInitializer: modelArtifacts.modelInitializer != null ? - modelArtifacts.modelInitializer : - undefined, - initializerSignature: modelArtifacts.initializerSignature != null ? - modelArtifacts.initializerSignature : - undefined, - trainingConfig: modelArtifacts.trainingConfig != null ? - modelArtifacts.trainingConfig : - undefined - }; - this.LS.setItem(this.keys.modelMetadata, JSON.stringify(metadata)); - - return {modelArtifactsInfo}; - } catch (err) { - // If saving failed, clean up all items saved so far. - removeItems(this.keys); - - throw new Error( - `Failed to save model '${this.modelPath}' to local storage: ` + - `size quota being exceeded is a possible cause of this failure: ` + - `modelTopologyBytes=${modelArtifactsInfo.modelTopologyBytes}, ` + - `weightSpecsBytes=${modelArtifactsInfo.weightSpecsBytes}, ` + - `weightDataBytes=${modelArtifactsInfo.weightDataBytes}.`); - } - } - } - - /** - * Load a model from local storage. - * - * See the documentation to `browserLocalStorage` for details on the saved - * artifacts. - * - * @returns The loaded model (if loading succeeds). - */ - async load(): Promise { - const info = - JSON.parse(this.LS.getItem(this.keys.info)) as ModelArtifactsInfo; - if (info == null) { - throw new Error( - `In local storage, there is no model with name '${this.modelPath}'`); - } - - if (info.modelTopologyType !== 'JSON') { - throw new Error( - 'BrowserLocalStorage does not support loading non-JSON model ' + - 'topology yet.'); - } - - const out: ModelArtifacts = {}; - - // Load topology. - const topology = JSON.parse(this.LS.getItem(this.keys.topology)); - if (topology == null) { - throw new Error( - `In local storage, the topology of model '${this.modelPath}' ` + - `is missing.`); - } - out.modelTopology = topology; - - // Load weight specs. - const weightSpecs = JSON.parse(this.LS.getItem(this.keys.weightSpecs)); - if (weightSpecs == null) { - throw new Error( - `In local storage, the weight specs of model '${this.modelPath}' ` + - `are missing.`); - } - out.weightSpecs = weightSpecs; - - // Load meta-data fields. - const metadataString = this.LS.getItem(this.keys.modelMetadata); - if (metadataString != null) { - const metadata = JSON.parse(metadataString) as ModelMetadata; - out.format = metadata.format; - out.generatedBy = metadata.generatedBy; - out.convertedBy = metadata.convertedBy; - if (metadata.signature != null) { - out.signature = metadata.signature; - } - if (metadata.userDefinedMetadata != null) { - out.userDefinedMetadata = metadata.userDefinedMetadata; - } - if (metadata.modelInitializer != null) { - out.modelInitializer = metadata.modelInitializer; - } - if (metadata.initializerSignature != null) { - out.initializerSignature = metadata.initializerSignature; - } - if (metadata.trainingConfig != null) { - out.trainingConfig = metadata.trainingConfig; - } - } - - // Load weight data. - const weightDataBase64 = this.LS.getItem(this.keys.weightData); - if (weightDataBase64 == null) { - throw new Error( - `In local storage, the binary weight values of model ` + - `'${this.modelPath}' are missing.`); - } - out.weightData = base64StringToArrayBuffer(weightDataBase64); - - return out; - } -} - -export const localStorageRouter: IORouter = (url: string|string[]) => { - if (!env().getBool('IS_BROWSER')) { - return null; - } else { - if (!Array.isArray(url) && url.startsWith(BrowserLocalStorage.URL_SCHEME)) { - return browserLocalStorage( - url.slice(BrowserLocalStorage.URL_SCHEME.length)); - } else { - return null; - } - } -}; -IORouterRegistry.registerSaveRouter(localStorageRouter); -IORouterRegistry.registerLoadRouter(localStorageRouter); - -/** - * Factory function for local storage IOHandler. - * - * This `IOHandler` supports both `save` and `load`. - * - * For each model's saved artifacts, four items are saved to local storage. - * - `${PATH_SEPARATOR}/${modelPath}/info`: Contains meta-info about the - * model, such as date saved, type of the topology, size in bytes, etc. - * - `${PATH_SEPARATOR}/${modelPath}/topology`: Model topology. For Keras- - * style models, this is a stringized JSON. - * - `${PATH_SEPARATOR}/${modelPath}/weight_specs`: Weight specs of the - * model, can be used to decode the saved binary weight values (see - * item below). - * - `${PATH_SEPARATOR}/${modelPath}/weight_data`: Concatenated binary - * weight values, stored as a base64-encoded string. - * - * Saving may throw an `Error` if the total size of the artifacts exceed the - * browser-specific quota. - * - * @param modelPath A unique identifier for the model to be saved. Must be a - * non-empty string. - * @returns An instance of `IOHandler`, which can be used with, e.g., - * `tf.Model.save`. - */ -export function browserLocalStorage(modelPath: string): IOHandler { - return new BrowserLocalStorage(modelPath); -} - -export class BrowserLocalStorageManager implements ModelStoreManager { - private readonly LS: Storage; - - constructor() { - assert( - env().getBool('IS_BROWSER'), - () => 'Current environment is not a web browser'); - assert( - typeof window === 'undefined' || - typeof window.localStorage !== 'undefined', - () => 'Current browser does not appear to support localStorage'); - this.LS = window.localStorage; - } - - async listModels(): Promise<{[path: string]: ModelArtifactsInfo}> { - const out: {[path: string]: ModelArtifactsInfo} = {}; - const prefix = PATH_PREFIX + PATH_SEPARATOR; - const suffix = PATH_SEPARATOR + INFO_SUFFIX; - for (let i = 0; i < this.LS.length; ++i) { - const key = this.LS.key(i); - if (key.startsWith(prefix) && key.endsWith(suffix)) { - const modelPath = getModelPathFromKey(key); - out[modelPath] = JSON.parse(this.LS.getItem(key)) as ModelArtifactsInfo; - } - } - return out; - } - - async removeModel(path: string): Promise { - path = maybeStripScheme(path); - const keys = getModelKeys(path); - if (this.LS.getItem(keys.info) == null) { - throw new Error(`Cannot find model at path '${path}'`); - } - const info = JSON.parse(this.LS.getItem(keys.info)) as ModelArtifactsInfo; - removeItems(keys); - return info; - } -} diff --git a/tfjs-master/tfjs-core/src/io/local_storage_test.ts b/tfjs-master/tfjs-core/src/io/local_storage_test.ts deleted file mode 100644 index 7d2a351d9..000000000 --- a/tfjs-master/tfjs-core/src/io/local_storage_test.ts +++ /dev/null @@ -1,404 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the 'License'); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {BROWSER_ENVS, describeWithFlags, runWithLock} from '../jasmine_util'; -import {arrayBufferToBase64String, base64StringToArrayBuffer} from './io_utils'; -import {browserLocalStorage, BrowserLocalStorage, BrowserLocalStorageManager, localStorageRouter, purgeLocalStorageArtifacts} from './local_storage'; - -describeWithFlags('LocalStorage', BROWSER_ENVS, () => { - // Test data. - const modelTopology1: {} = { - 'class_name': 'Sequential', - 'keras_version': '2.1.4', - 'config': [{ - 'class_name': 'Dense', - 'config': { - 'kernel_initializer': { - 'class_name': 'VarianceScaling', - 'config': { - 'distribution': 'uniform', - 'scale': 1.0, - 'seed': null, - 'mode': 'fan_avg' - } - }, - 'name': 'dense', - 'kernel_constraint': null, - 'bias_regularizer': null, - 'bias_constraint': null, - 'dtype': 'float32', - 'activation': 'linear', - 'trainable': true, - 'kernel_regularizer': null, - 'bias_initializer': {'class_name': 'Zeros', 'config': {}}, - 'units': 1, - 'batch_input_shape': [null, 3], - 'use_bias': true, - 'activity_regularizer': null - } - }], - 'backend': 'tensorflow' - }; - const weightSpecs1: tf.io.WeightsManifestEntry[] = [ - { - name: 'dense/kernel', - shape: [3, 1], - dtype: 'float32', - }, - { - name: 'dense/bias', - shape: [1], - dtype: 'float32', - } - ]; - const weightData1 = new ArrayBuffer(16); - const trainingConfig1: tf.io.TrainingConfig = { - loss: 'categorical_crossentropy', - metrics: ['accuracy'], - optimizer_config: {class_name: 'SGD', config: {learningRate: 0.1}} - }; - - const artifacts1: tf.io.ModelArtifacts = { - modelTopology: modelTopology1, - weightSpecs: weightSpecs1, - weightData: weightData1, - format: 'layers-model', - generatedBy: 'TensorFlow.js v0.0.0', - convertedBy: '1.13.1', - signature: null, - userDefinedMetadata: {}, - modelInitializer: {}, - initializerSignature: null, - trainingConfig: trainingConfig1, - }; - - const artifactsV0: tf.io.ModelArtifacts = { - modelTopology: modelTopology1, - weightSpecs: weightSpecs1, - weightData: weightData1 - }; - - function findOverflowingByteSize(): number { - const LS = window.localStorage; - const probeKey = - `tfjs_test_probe_values_${new Date().getTime()}_${Math.random()}`; - const minKilobytes = 200; - const stepKilobytes = 200; - const maxKilobytes = 40000; - for (let kilobytes = minKilobytes; kilobytes < maxKilobytes; - kilobytes += stepKilobytes) { - const bytes = kilobytes * 1024; - const data = new ArrayBuffer(bytes); - try { - const encoded = arrayBufferToBase64String(data); - LS.setItem(probeKey, encoded); - } catch (err) { - return bytes; - } - LS.removeItem(probeKey); - } - throw new Error( - `Unable to determined overflowing byte size up to ${maxKilobytes} kB.`); - } - - beforeEach(() => { - purgeLocalStorageArtifacts(); - }); - - afterEach(() => { - purgeLocalStorageArtifacts(); - }); - - it('Save artifacts succeeds', runWithLock(async () => { - const testStartDate = new Date(); - const handler = tf.io.getSaveHandlers('localstorage://foo/FooModel')[0]; - const saveResult = await handler.save(artifacts1); - - expect(saveResult.modelArtifactsInfo.dateSaved.getTime()) - .toBeGreaterThanOrEqual(testStartDate.getTime()); - // Note: The following two assertions work only because there is no - // non-ASCII characters in `modelTopology1` and `weightSpecs1`. - expect(saveResult.modelArtifactsInfo.modelTopologyBytes) - .toEqual(JSON.stringify(modelTopology1).length); - expect(saveResult.modelArtifactsInfo.weightSpecsBytes) - .toEqual(JSON.stringify(weightSpecs1).length); - expect(saveResult.modelArtifactsInfo.weightDataBytes).toEqual(16); - - // Check the content of the saved items in local storage. - const LS = window.localStorage; - const info = - JSON.parse(LS.getItem('tensorflowjs_models/foo/FooModel/info')); - expect(Date.parse(info.dateSaved)) - .toEqual(saveResult.modelArtifactsInfo.dateSaved.getTime()); - expect(info.modelTopologyBytes) - .toEqual(saveResult.modelArtifactsInfo.modelTopologyBytes); - expect(info.weightSpecsBytes) - .toEqual(saveResult.modelArtifactsInfo.weightSpecsBytes); - expect(info.weightDataBytes) - .toEqual(saveResult.modelArtifactsInfo.weightDataBytes); - - const topologyString = - LS.getItem('tensorflowjs_models/foo/FooModel/model_topology'); - expect(JSON.stringify(modelTopology1)).toEqual(topologyString); - - const weightSpecsString = - LS.getItem('tensorflowjs_models/foo/FooModel/weight_specs'); - expect(JSON.stringify(weightSpecs1)).toEqual(weightSpecsString); - - const weightDataBase64String = - LS.getItem('tensorflowjs_models/foo/FooModel/weight_data'); - expect(base64StringToArrayBuffer(weightDataBase64String)) - .toEqual(weightData1); - })); - - it('Save-load round trip succeeds', runWithLock(async () => { - const handler1 = tf.io.getSaveHandlers('localstorage://FooModel')[0]; - - await handler1.save(artifacts1); - const handler2 = tf.io.getLoadHandlers('localstorage://FooModel')[0]; - const loaded = await handler2.load(); - expect(loaded.modelTopology).toEqual(modelTopology1); - expect(loaded.weightSpecs).toEqual(weightSpecs1); - expect(loaded.weightData).toEqual(weightData1); - expect(loaded.format).toEqual('layers-model'); - expect(loaded.generatedBy).toEqual('TensorFlow.js v0.0.0'); - expect(loaded.convertedBy).toEqual('1.13.1'); - expect(loaded.userDefinedMetadata).toEqual({}); - expect(loaded.modelInitializer).toEqual({}); - expect(loaded.initializerSignature).toBeUndefined(); - expect(loaded.trainingConfig).toEqual(trainingConfig1); - })); - - it('Save-load round trip succeeds: v0 format', runWithLock(async () => { - const handler1 = tf.io.getSaveHandlers('localstorage://FooModel')[0]; - - await handler1.save(artifactsV0); - const handler2 = tf.io.getLoadHandlers('localstorage://FooModel')[0]; - const loaded = await handler2.load(); - expect(loaded.modelTopology).toEqual(modelTopology1); - expect(loaded.weightSpecs).toEqual(weightSpecs1); - expect(loaded.weightData).toEqual(weightData1); - expect(loaded.format).toBeUndefined(); - expect(loaded.generatedBy).toBeUndefined(); - expect(loaded.convertedBy).toBeUndefined(); - expect(loaded.userDefinedMetadata).toBeUndefined(); - expect(loaded.trainingConfig).toBeUndefined(); - expect(loaded.modelInitializer).toBeUndefined(); - expect(loaded.initializerSignature).toBeUndefined(); - expect(loaded.trainingConfig).toBeUndefined(); - })); - - it('Loading nonexistent model fails.', runWithLock(async () => { - const handler = - tf.io.getSaveHandlers('localstorage://NonexistentModel')[0]; - try { - await handler.load(); - } catch (err) { - expect(err.message) - .toEqual( - 'In local storage, there is no model with name ' + - '\'NonexistentModel\''); - return; // Success - } - fail('Loading nonexistent model succeeded unexpectedly.'); - })); - - it('Loading model with missing topology fails.', runWithLock(async () => { - const handler1 = tf.io.getSaveHandlers('localstorage://FooModel')[0]; - await handler1.save(artifacts1); - // Manually remove the topology item from local storage. - window.localStorage.removeItem( - 'tensorflowjs_models/FooModel/model_topology'); - - const handler2 = tf.io.getLoadHandlers('localstorage://FooModel')[0]; - try { - await handler2.load(); - } catch (err) { - expect(err.message) - .toEqual( - 'In local storage, the topology of model ' + - '\'FooModel\' is missing.'); - return; // Success - } - fail('Loading of model with missing topology succeeded unexpectedly.'); - })); - - it('Loading model with missing weight specs fails.', runWithLock(async () => { - const handler1 = tf.io.getSaveHandlers('localstorage://FooModel')[0]; - await handler1.save(artifacts1); - // Manually remove the weight specs item from local storage. - window.localStorage.removeItem( - 'tensorflowjs_models/FooModel/weight_specs'); - - const handler2 = tf.io.getLoadHandlers('localstorage://FooModel')[0]; - try { - await handler2.load(); - } catch (err) { - expect(err.message) - .toEqual( - 'In local storage, the weight specs of model ' + - '\'FooModel\' are missing.'); - return; // Success - } - fail( - 'Loading of model with missing weight specs ' + - 'succeeded unexpectedly.'); - })); - - it('Loading model with missing weight data fails.', runWithLock(async () => { - const handler1 = tf.io.getSaveHandlers('localstorage://FooModel')[0]; - await handler1.save(artifacts1); - - // Manually remove the weight data item from local storage. - window.localStorage.removeItem( - 'tensorflowjs_models/FooModel/weight_data'); - - const handler2 = tf.io.getLoadHandlers('localstorage://FooModel')[0]; - try { - await handler2.load(); - fail( - 'Loading of model with missing weight data ' + - 'succeeded unexpectedly.'); - } catch (err) { - expect(err.message) - .toEqual( - 'In local storage, the binary weight values of model ' + - '\'FooModel\' are missing.'); - } - })); - - it('Data size too large leads to error thrown', runWithLock(async () => { - const overflowByteSize = findOverflowingByteSize(); - const overflowArtifacts: tf.io.ModelArtifacts = { - modelTopology: modelTopology1, - weightSpecs: weightSpecs1, - weightData: new ArrayBuffer(overflowByteSize), - }; - const handler1 = tf.io.getSaveHandlers('localstorage://FooModel')[0]; - try { - await handler1.save(overflowArtifacts); - fail( - 'Saving of model of overflowing-size weight data succeeded ' + - 'unexpectedly.'); - } catch (err) { - expect( - (err.message as string) - .indexOf('Failed to save model \'FooModel\' to local storage')) - .toEqual(0); - } - })); - - it('Null, undefined or empty modelPath throws Error', () => { - expect(() => browserLocalStorage(null)) - .toThrowError( - /local storage, modelPath must not be null, undefined or empty/); - expect(() => browserLocalStorage(undefined)) - .toThrowError( - /local storage, modelPath must not be null, undefined or empty/); - expect(() => browserLocalStorage('')) - .toThrowError( - /local storage, modelPath must not be null, undefined or empty./); - }); - - it('router', () => { - expect( - localStorageRouter('localstorage://bar') instanceof BrowserLocalStorage) - .toEqual(true); - expect(localStorageRouter('indexeddb://bar')).toBeNull(); - expect(localStorageRouter('qux')).toBeNull(); - }); - - it('Manager: List models: 0 result', runWithLock(async () => { - // Before any model is saved, listModels should return empty result. - const out = await new BrowserLocalStorageManager().listModels(); - expect(out).toEqual({}); - })); - - it('Manager: List models: 1 result', runWithLock(async () => { - const handler = tf.io.getSaveHandlers('localstorage://baz/QuxModel')[0]; - const saveResult = await handler.save(artifacts1); - - // After successful saving, there should be one model. - const out = await new BrowserLocalStorageManager().listModels(); - if (Object.keys(out).length !== 1) { - console.log(JSON.stringify(out, null, 2)); - } - - expect(Object.keys(out).length).toEqual(1); - expect(out['baz/QuxModel'].modelTopologyType) - .toEqual(saveResult.modelArtifactsInfo.modelTopologyType); - expect(out['baz/QuxModel'].modelTopologyBytes) - .toEqual(saveResult.modelArtifactsInfo.modelTopologyBytes); - expect(out['baz/QuxModel'].weightSpecsBytes) - .toEqual(saveResult.modelArtifactsInfo.weightSpecsBytes); - expect(out['baz/QuxModel'].weightDataBytes) - .toEqual(saveResult.modelArtifactsInfo.weightDataBytes); - })); - - it('Manager: List models: 2 results', runWithLock(async () => { - // First, save a model. - const handler1 = tf.io.getSaveHandlers('localstorage://QuxModel')[0]; - const saveResult1 = await handler1.save(artifacts1); - - // Then, save the model under another path. - const handler2 = - tf.io.getSaveHandlers('localstorage://repeat/QuxModel')[0]; - const saveResult2 = await handler2.save(artifacts1); - - // After successful saving, there should be two models. - const out = await new BrowserLocalStorageManager().listModels(); - if (Object.keys(out).length !== 2) { - console.log(JSON.stringify(out, null, 2)); - } - expect(Object.keys(out).length).toEqual(2); - expect(out['QuxModel'].modelTopologyType) - .toEqual(saveResult1.modelArtifactsInfo.modelTopologyType); - expect(out['QuxModel'].modelTopologyBytes) - .toEqual(saveResult1.modelArtifactsInfo.modelTopologyBytes); - expect(out['QuxModel'].weightSpecsBytes) - .toEqual(saveResult1.modelArtifactsInfo.weightSpecsBytes); - expect(out['QuxModel'].weightDataBytes) - .toEqual(saveResult1.modelArtifactsInfo.weightDataBytes); - expect(out['repeat/QuxModel'].modelTopologyType) - .toEqual(saveResult2.modelArtifactsInfo.modelTopologyType); - expect(out['repeat/QuxModel'].modelTopologyBytes) - .toEqual(saveResult2.modelArtifactsInfo.modelTopologyBytes); - expect(out['repeat/QuxModel'].weightSpecsBytes) - .toEqual(saveResult2.modelArtifactsInfo.weightSpecsBytes); - expect(out['repeat/QuxModel'].weightDataBytes) - .toEqual(saveResult2.modelArtifactsInfo.weightDataBytes); - })); - - it('Manager: Successful deleteModel', runWithLock(async () => { - // First, save a model. - const handler1 = tf.io.getSaveHandlers('localstorage://QuxModel')[0]; - await handler1.save(artifacts1); - - // Then, save the model under another path. - const handler2 = - tf.io.getSaveHandlers('localstorage://repeat/QuxModel')[0]; - await handler2.save(artifacts1); - - // After successful saving, delete the first save, and then - // `listModel` should give only one result. - const manager = new BrowserLocalStorageManager(); - await manager.removeModel('QuxModel'); - const out = await manager.listModels(); - expect(Object.keys(out)).toEqual(['repeat/QuxModel']); - })); -}); diff --git a/tfjs-master/tfjs-core/src/io/model_management.ts b/tfjs-master/tfjs-core/src/io/model_management.ts deleted file mode 100644 index 38aaae0ed..000000000 --- a/tfjs-master/tfjs-core/src/io/model_management.ts +++ /dev/null @@ -1,356 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -/** - * Classes and functions for model management across multiple storage mediums. - * - * Supported client actions: - * - Listing models on all registered storage mediums. - * - Remove model by URL from any registered storage mediums, by using URL - * string. - * - Moving or copying model from one path to another in the same medium or from - * one medium to another, by using URL strings. - */ - -import {assert} from '../util'; - -import {IORouterRegistry} from './router_registry'; -import {ModelArtifactsInfo, ModelStoreManager} from './types'; - -const URL_SCHEME_SUFFIX = '://'; - -export class ModelStoreManagerRegistry { - // Singleton instance. - private static instance: ModelStoreManagerRegistry; - - private managers: {[scheme: string]: ModelStoreManager}; - - private constructor() { - this.managers = {}; - } - - private static getInstance(): ModelStoreManagerRegistry { - if (ModelStoreManagerRegistry.instance == null) { - ModelStoreManagerRegistry.instance = new ModelStoreManagerRegistry(); - } - return ModelStoreManagerRegistry.instance; - } - - /** - * Register a save-handler router. - * - * @param saveRouter A function that maps a URL-like string onto an instance - * of `IOHandler` with the `save` method defined or `null`. - */ - static registerManager(scheme: string, manager: ModelStoreManager) { - assert(scheme != null, () => 'scheme must not be undefined or null.'); - if (scheme.endsWith(URL_SCHEME_SUFFIX)) { - scheme = scheme.slice(0, scheme.indexOf(URL_SCHEME_SUFFIX)); - } - assert(scheme.length > 0, () => 'scheme must not be an empty string.'); - const registry = ModelStoreManagerRegistry.getInstance(); - assert( - registry.managers[scheme] == null, - () => `A model store manager is already registered for scheme '${ - scheme}'.`); - registry.managers[scheme] = manager; - } - - static getManager(scheme: string): ModelStoreManager { - const manager = ModelStoreManagerRegistry.getInstance().managers[scheme]; - if (manager == null) { - throw new Error(`Cannot find model manager for scheme '${scheme}'`); - } - return manager; - } - - static getSchemes(): string[] { - return Object.keys(ModelStoreManagerRegistry.getInstance().managers); - } -} - -/** - * Helper method for parsing a URL string into a scheme and a path. - * - * @param url E.g., 'localstorage://my-model' - * @returns A dictionary with two fields: scheme and path. - * Scheme: e.g., 'localstorage' in the example above. - * Path: e.g., 'my-model' in the example above. - */ -function parseURL(url: string): {scheme: string, path: string} { - if (url.indexOf(URL_SCHEME_SUFFIX) === -1) { - throw new Error( - `The url string provided does not contain a scheme. ` + - `Supported schemes are: ` + - `${ModelStoreManagerRegistry.getSchemes().join(',')}`); - } - return { - scheme: url.split(URL_SCHEME_SUFFIX)[0], - path: url.split(URL_SCHEME_SUFFIX)[1], - }; -} - -async function cloneModelInternal( - sourceURL: string, destURL: string, - deleteSource = false): Promise { - assert( - sourceURL !== destURL, - () => `Old path and new path are the same: '${sourceURL}'`); - - const loadHandlers = IORouterRegistry.getLoadHandlers(sourceURL); - assert( - loadHandlers.length > 0, - () => `Copying failed because no load handler is found for source URL ${ - sourceURL}.`); - assert( - loadHandlers.length < 2, - () => `Copying failed because more than one (${loadHandlers.length}) ` + - `load handlers for source URL ${sourceURL}.`); - const loadHandler = loadHandlers[0]; - - const saveHandlers = IORouterRegistry.getSaveHandlers(destURL); - assert( - saveHandlers.length > 0, - () => `Copying failed because no save handler is found for destination ` + - `URL ${destURL}.`); - assert( - saveHandlers.length < 2, - () => `Copying failed because more than one (${loadHandlers.length}) ` + - `save handlers for destination URL ${destURL}.`); - const saveHandler = saveHandlers[0]; - - const sourceScheme = parseURL(sourceURL).scheme; - const sourcePath = parseURL(sourceURL).path; - const sameMedium = sourceScheme === parseURL(sourceURL).scheme; - - const modelArtifacts = await loadHandler.load(); - - // If moving within the same storage medium, remove the old model as soon as - // the loading is done. Without doing this, it is possible that the combined - // size of the two models will cause the cloning to fail. - if (deleteSource && sameMedium) { - await ModelStoreManagerRegistry.getManager(sourceScheme) - .removeModel(sourcePath); - } - - const saveResult = await saveHandler.save(modelArtifacts); - - // If moving between mediums, the deletion is done after the save succeeds. - // This guards against the case in which saving to the destination medium - // fails. - if (deleteSource && !sameMedium) { - await ModelStoreManagerRegistry.getManager(sourceScheme) - .removeModel(sourcePath); - } - - return saveResult.modelArtifactsInfo; -} - -/** - * List all models stored in registered storage mediums. - * - * For a web browser environment, the registered mediums are Local Storage and - * IndexedDB. - * - * ```js - * // First create and save a model. - * const model = tf.sequential(); - * model.add(tf.layers.dense( - * {units: 1, inputShape: [10], activation: 'sigmoid'})); - * await model.save('localstorage://demo/management/model1'); - * - * // Then list existing models. - * console.log(JSON.stringify(await tf.io.listModels())); - * - * // Delete the model. - * await tf.io.removeModel('localstorage://demo/management/model1'); - * - * // List models again. - * console.log(JSON.stringify(await tf.io.listModels())); - * ``` - * - * @returns A `Promise` of a dictionary mapping URLs of existing models to - * their model artifacts info. URLs include medium-specific schemes, e.g., - * 'indexeddb://my/model/1'. Model artifacts info include type of the - * model's topology, byte sizes of the topology, weights, etc. - * - * @doc { - * heading: 'Models', - * subheading: 'Management', - * namespace: 'io', - * ignoreCI: true - * } - */ -async function listModels(): Promise<{[url: string]: ModelArtifactsInfo}> { - const schemes = ModelStoreManagerRegistry.getSchemes(); - const out: {[url: string]: ModelArtifactsInfo} = {}; - for (const scheme of schemes) { - const schemeOut = - await ModelStoreManagerRegistry.getManager(scheme).listModels(); - for (const path in schemeOut) { - const url = scheme + URL_SCHEME_SUFFIX + path; - out[url] = schemeOut[path]; - } - } - return out; -} - -/** - * Remove a model specified by URL from a registered storage medium. - * - * ```js - * // First create and save a model. - * const model = tf.sequential(); - * model.add(tf.layers.dense( - * {units: 1, inputShape: [10], activation: 'sigmoid'})); - * await model.save('localstorage://demo/management/model1'); - * - * // Then list existing models. - * console.log(JSON.stringify(await tf.io.listModels())); - * - * // Delete the model. - * await tf.io.removeModel('localstorage://demo/management/model1'); - * - * // List models again. - * console.log(JSON.stringify(await tf.io.listModels())); - * ``` - * - * @param url A URL to a stored model, with a scheme prefix, e.g., - * 'localstorage://my-model-1', 'indexeddb://my/model/2'. - * @returns ModelArtifactsInfo of the deleted model (if and only if deletion - * is successful). - * @throws Error if deletion fails, e.g., if no model exists at `path`. - * - * @doc { - * heading: 'Models', - * subheading: 'Management', - * namespace: 'io', - * ignoreCI: true - * } - */ -async function removeModel(url: string): Promise { - const schemeAndPath = parseURL(url); - const manager = ModelStoreManagerRegistry.getManager(schemeAndPath.scheme); - return manager.removeModel(schemeAndPath.path); -} - -/** - * Copy a model from one URL to another. - * - * This function supports: - * - * 1. Copying within a storage medium, e.g., - * `tf.io.copyModel('localstorage://model-1', 'localstorage://model-2')` - * 2. Copying between two storage mediums, e.g., - * `tf.io.copyModel('localstorage://model-1', 'indexeddb://model-1')` - * - * ```js - * // First create and save a model. - * const model = tf.sequential(); - * model.add(tf.layers.dense( - * {units: 1, inputShape: [10], activation: 'sigmoid'})); - * await model.save('localstorage://demo/management/model1'); - * - * // Then list existing models. - * console.log(JSON.stringify(await tf.io.listModels())); - * - * // Copy the model, from Local Storage to IndexedDB. - * await tf.io.copyModel( - * 'localstorage://demo/management/model1', - * 'indexeddb://demo/management/model1'); - * - * // List models again. - * console.log(JSON.stringify(await tf.io.listModels())); - * - * // Remove both models. - * await tf.io.removeModel('localstorage://demo/management/model1'); - * await tf.io.removeModel('indexeddb://demo/management/model1'); - * ``` - * - * @param sourceURL Source URL of copying. - * @param destURL Destination URL of copying. - * @returns ModelArtifactsInfo of the copied model (if and only if copying - * is successful). - * @throws Error if copying fails, e.g., if no model exists at `sourceURL`, or - * if `oldPath` and `newPath` are identical. - * - * @doc { - * heading: 'Models', - * subheading: 'Management', - * namespace: 'io', - * ignoreCI: true - * } - */ -async function copyModel( - sourceURL: string, destURL: string): Promise { - const deleteSource = false; - return cloneModelInternal(sourceURL, destURL, deleteSource); -} - -/** - * Move a model from one URL to another. - * - * This function supports: - * - * 1. Moving within a storage medium, e.g., - * `tf.io.moveModel('localstorage://model-1', 'localstorage://model-2')` - * 2. Moving between two storage mediums, e.g., - * `tf.io.moveModel('localstorage://model-1', 'indexeddb://model-1')` - * - * ```js - * // First create and save a model. - * const model = tf.sequential(); - * model.add(tf.layers.dense( - * {units: 1, inputShape: [10], activation: 'sigmoid'})); - * await model.save('localstorage://demo/management/model1'); - * - * // Then list existing models. - * console.log(JSON.stringify(await tf.io.listModels())); - * - * // Move the model, from Local Storage to IndexedDB. - * await tf.io.moveModel( - * 'localstorage://demo/management/model1', - * 'indexeddb://demo/management/model1'); - * - * // List models again. - * console.log(JSON.stringify(await tf.io.listModels())); - * - * // Remove the moved model. - * await tf.io.removeModel('indexeddb://demo/management/model1'); - * ``` - * - * @param sourceURL Source URL of moving. - * @param destURL Destination URL of moving. - * @returns ModelArtifactsInfo of the copied model (if and only if copying - * is successful). - * @throws Error if moving fails, e.g., if no model exists at `sourceURL`, or - * if `oldPath` and `newPath` are identical. - * - * @doc { - * heading: 'Models', - * subheading: 'Management', - * namespace: 'io', - * ignoreCI: true - * } - */ -async function moveModel( - sourceURL: string, destURL: string): Promise { - const deleteSource = true; - return cloneModelInternal(sourceURL, destURL, deleteSource); -} - -export {moveModel, copyModel, removeModel, listModels}; diff --git a/tfjs-master/tfjs-core/src/io/model_management_test.ts b/tfjs-master/tfjs-core/src/io/model_management_test.ts deleted file mode 100644 index 0f8a958ec..000000000 --- a/tfjs-master/tfjs-core/src/io/model_management_test.ts +++ /dev/null @@ -1,491 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {CHROME_ENVS, describeWithFlags, runWithLock} from '../jasmine_util'; -import {deleteDatabase} from './indexed_db'; -import {CompositeArrayBuffer} from './composite_array_buffer'; -import {purgeLocalStorageArtifacts} from './local_storage'; - -// Disabled for non-Chrome browsers due to: -// https://github.com/tensorflow/tfjs/issues/427 -describeWithFlags('ModelManagement', CHROME_ENVS, () => { - // Test data. - const modelTopology1: {} = { - 'class_name': 'Sequential', - 'keras_version': '2.1.4', - 'config': [{ - 'class_name': 'Dense', - 'config': { - 'kernel_initializer': { - 'class_name': 'VarianceScaling', - 'config': { - 'distribution': 'uniform', - 'scale': 1.0, - 'seed': null, - 'mode': 'fan_avg' - } - }, - 'name': 'dense', - 'kernel_constraint': null, - 'bias_regularizer': null, - 'bias_constraint': null, - 'dtype': 'float32', - 'activation': 'linear', - 'trainable': true, - 'kernel_regularizer': null, - 'bias_initializer': {'class_name': 'Zeros', 'config': {}}, - 'units': 1, - 'batch_input_shape': [null, 3], - 'use_bias': true, - 'activity_regularizer': null - } - }], - 'backend': 'tensorflow' - }; - const weightSpecs1: tf.io.WeightsManifestEntry[] = [ - { - name: 'dense/kernel', - shape: [3, 1], - dtype: 'float32', - }, - { - name: 'dense/bias', - shape: [1], - dtype: 'float32', - } - ]; - const weightData1 = new ArrayBuffer(16); - const artifacts1: tf.io.ModelArtifacts = { - modelTopology: modelTopology1, - weightSpecs: weightSpecs1, - weightData: weightData1, - }; - - beforeEach(done => { - purgeLocalStorageArtifacts(); - deleteDatabase().then(() => { - done(); - }); - }); - - afterEach(done => { - purgeLocalStorageArtifacts(); - deleteDatabase().then(() => { - done(); - }); - }); - - // TODO(cais): Reenable this test once we fix - // https://github.com/tensorflow/tfjs/issues/1198 - // tslint:disable-next-line:ban - xit('List models: 0 result', done => { - // Before any model is saved, listModels should return empty result. - tf.io.listModels() - .then(out => { - expect(out).toEqual({}); - done(); - }) - .catch(err => done.fail(err.stack)); - }); - - // TODO(cais): Reenable this test once we fix - // https://github.com/tensorflow/tfjs/issues/1198 - // tslint:disable-next-line:ban - xit('List models: 1 result', done => { - const url = 'localstorage://baz/QuxModel'; - const handler = tf.io.getSaveHandlers(url)[0]; - handler.save(artifacts1) - .then(saveResult => { - // After successful saving, there should be one model. - tf.io.listModels() - .then(out => { - expect(Object.keys(out).length).toEqual(1); - expect(out[url].modelTopologyType) - .toEqual(saveResult.modelArtifactsInfo.modelTopologyType); - expect(out[url].modelTopologyBytes) - .toEqual(saveResult.modelArtifactsInfo.modelTopologyBytes); - expect(out[url].weightSpecsBytes) - .toEqual(saveResult.modelArtifactsInfo.weightSpecsBytes); - expect(out[url].weightDataBytes) - .toEqual(saveResult.modelArtifactsInfo.weightDataBytes); - done(); - }) - .catch(err => done.fail(err.stack)); - }) - .catch(err => done.fail(err.stack)); - }); - - // TODO(cais): Reenable this test once we fix - // https://github.com/tensorflow/tfjs/issues/1198 - // tslint:disable-next-line:ban - xit('Manager: List models: 2 results in 2 mediums', done => { - const url1 = 'localstorage://QuxModel'; - const url2 = 'indexeddb://QuxModel'; - - // First, save a model in Local Storage. - const handler1 = tf.io.getSaveHandlers(url1)[0]; - handler1.save(artifacts1) - .then(saveResult1 => { - // Then, save the model in IndexedDB. - const handler2 = tf.io.getSaveHandlers(url2)[0]; - handler2.save(artifacts1) - .then(saveResult2 => { - // After successful saving, there should be two models. - tf.io.listModels() - .then(out => { - expect(Object.keys(out).length).toEqual(2); - expect(out[url1].modelTopologyType) - .toEqual( - saveResult1.modelArtifactsInfo.modelTopologyType); - expect(out[url1].modelTopologyBytes) - .toEqual(saveResult1.modelArtifactsInfo - .modelTopologyBytes); - expect(out[url1].weightSpecsBytes) - .toEqual( - saveResult1.modelArtifactsInfo.weightSpecsBytes); - expect(out[url1].weightDataBytes) - .toEqual( - saveResult1.modelArtifactsInfo.weightDataBytes); - expect(out[url2].modelTopologyType) - .toEqual( - saveResult2.modelArtifactsInfo.modelTopologyType); - expect(out[url2].modelTopologyBytes) - .toEqual(saveResult2.modelArtifactsInfo - .modelTopologyBytes); - expect(out[url2].weightSpecsBytes) - .toEqual( - saveResult2.modelArtifactsInfo.weightSpecsBytes); - expect(out[url2].weightDataBytes) - .toEqual( - saveResult2.modelArtifactsInfo.weightDataBytes); - done(); - }) - .catch(err => done.fail(err.stack)); - }) - .catch(err => done.fail(err.stack)); - }) - .catch(err => done.fail(err.stack)); - }); - - // TODO(cais): Reenable this test once we fix - // https://github.com/tensorflow/tfjs/issues/1198 - // tslint:disable-next-line:ban - xit('Successful removeModel', done => { - // First, save a model. - const handler1 = tf.io.getSaveHandlers('localstorage://QuxModel')[0]; - handler1.save(artifacts1) - .then(saveResult1 => { - // Then, save the model under another path. - const handler2 = - tf.io.getSaveHandlers('indexeddb://repeat/QuxModel')[0]; - handler2.save(artifacts1) - .then(saveResult2 => { - // After successful saving, delete the first save, and then - // `listModel` should give only one result. - - // Delete a model specified with a path that includes the - // indexeddb:// scheme prefix should work. - tf.io.removeModel('indexeddb://repeat/QuxModel') - .then(deletedInfo => { - tf.io.listModels() - .then(out => { - expect(Object.keys(out)).toEqual([ - 'localstorage://QuxModel' - ]); - - tf.io.removeModel('localstorage://QuxModel') - .then(out => { - // The delete the remaining model. - tf.io.listModels() - .then(out => { - expect(Object.keys(out)).toEqual([]); - done(); - }) - .catch(err => done.fail(err)); - }) - .catch(err => done.fail(err)); - }) - .catch(err => done.fail(err)); - }) - .catch(err => done.fail(err.stack)); - }) - .catch(err => done.fail(err.stack)); - }) - .catch(err => done.fail(err.stack)); - }); - - // TODO(cais): Reenable this test once we fix - // https://github.com/tensorflow/tfjs/issues/1198 - // tslint:disable-next-line:ban - xit('Successful copyModel between mediums', done => { - const url1 = 'localstorage://a1/FooModel'; - const url2 = 'indexeddb://a1/FooModel'; - // First, save a model. - const handler1 = tf.io.getSaveHandlers(url1)[0]; - handler1.save(artifacts1) - .then(saveResult => { - // Once model is saved, copy the model to another path. - tf.io.copyModel(url1, url2) - .then(modelInfo => { - tf.io.listModels().then(out => { - expect(Object.keys(out).length).toEqual(2); - expect(out[url1].modelTopologyType) - .toEqual(saveResult.modelArtifactsInfo.modelTopologyType); - expect(out[url1].modelTopologyBytes) - .toEqual( - saveResult.modelArtifactsInfo.modelTopologyBytes); - expect(out[url1].weightSpecsBytes) - .toEqual(saveResult.modelArtifactsInfo.weightSpecsBytes); - expect(out[url1].weightDataBytes) - .toEqual(saveResult.modelArtifactsInfo.weightDataBytes); - expect(out[url2].modelTopologyType) - .toEqual(saveResult.modelArtifactsInfo.modelTopologyType); - expect(out[url2].modelTopologyBytes) - .toEqual( - saveResult.modelArtifactsInfo.modelTopologyBytes); - expect(out[url2].weightSpecsBytes) - .toEqual(saveResult.modelArtifactsInfo.weightSpecsBytes); - expect(out[url2].weightDataBytes) - .toEqual(saveResult.modelArtifactsInfo.weightDataBytes); - - // Load the copy and verify the content. - const handler2 = tf.io.getLoadHandlers(url2)[0]; - handler2.load() - .then(loaded => { - expect(loaded.modelTopology).toEqual(modelTopology1); - expect(loaded.weightSpecs).toEqual(weightSpecs1); - expect(loaded.weightData).toBeDefined(); - expect(new Uint8Array( - CompositeArrayBuffer.join(loaded.weightData))) - .toEqual(new Uint8Array(weightData1)); - done(); - }) - .catch(err => done.fail(err.stack)); - }); - }) - .catch(err => done.fail(err.stack)); - }) - .catch(err => done.fail(err.stack)); - }); - - // TODO(cais): Reenable this test once we fix - // https://github.com/tensorflow/tfjs/issues/1198 - // tslint:disable-next-line:ban - xit('Successful moveModel between mediums', done => { - const url1 = 'localstorage://a1/FooModel'; - const url2 = 'indexeddb://a1/FooModel'; - // First, save a model. - const handler1 = tf.io.getSaveHandlers(url1)[0]; - handler1.save(artifacts1) - .then(saveResult => { - // Once model is saved, move the model to another path. - tf.io.moveModel(url1, url2) - .then(modelInfo => { - tf.io.listModels().then(out => { - expect(Object.keys(out)).toEqual([url2]); - expect(out[url2].modelTopologyType) - .toEqual(saveResult.modelArtifactsInfo.modelTopologyType); - expect(out[url2].modelTopologyBytes) - .toEqual( - saveResult.modelArtifactsInfo.modelTopologyBytes); - expect(out[url2].weightSpecsBytes) - .toEqual(saveResult.modelArtifactsInfo.weightSpecsBytes); - expect(out[url2].weightDataBytes) - .toEqual(saveResult.modelArtifactsInfo.weightDataBytes); - - // Load the copy and verify the content. - const handler2 = tf.io.getLoadHandlers(url2)[0]; - handler2.load() - .then(loaded => { - expect(loaded.modelTopology).toEqual(modelTopology1); - expect(loaded.weightSpecs).toEqual(weightSpecs1); - expect(new Uint8Array( - CompositeArrayBuffer.join(loaded.weightData))) - .toEqual(new Uint8Array(weightData1)); - done(); - }) - .catch(err => { - done.fail(err.stack); - }); - }); - }) - .catch(err => done.fail(err.stack)); - }) - .catch(err => done.fail(err.stack)); - }); - - it('Failed copyModel to invalid source URL', runWithLock(done => { - const url1 = 'invalidurl'; - const url2 = 'localstorage://a1/FooModel'; - tf.io.copyModel(url1, url2) - .then(out => { - done.fail('Copying from invalid URL succeeded unexpectedly.'); - }) - .catch(err => { - expect(err.message) - .toEqual( - 'Copying failed because no load handler is found for ' + - 'source URL invalidurl.'); - done(); - }); - })); - - it('Failed copyModel to invalid destination URL', runWithLock(done => { - const url1 = 'localstorage://a1/FooModel'; - const url2 = 'invalidurl'; - // First, save a model. - const handler1 = tf.io.getSaveHandlers(url1)[0]; - handler1.save(artifacts1) - .then(saveResult => { - // Once model is saved, copy the model to another path. - tf.io.copyModel(url1, url2) - .then(out => { - done.fail('Copying to invalid URL succeeded unexpectedly.'); - }) - .catch(err => { - expect(err.message) - .toEqual( - 'Copying failed because no save handler is found ' + - 'for destination URL invalidurl.'); - done(); - }); - }) - .catch(err => done.fail(err.stack)); - })); - - it('Failed moveModel to invalid destination URL', runWithLock(done => { - const url1 = 'localstorage://a1/FooModel'; - const url2 = 'invalidurl'; - // First, save a model. - const handler1 = tf.io.getSaveHandlers(url1)[0]; - handler1.save(artifacts1) - .then(saveResult => { - // Once model is saved, copy the model to an invalid path, which - // should fail. - tf.io.moveModel(url1, url2) - .then(out => { - done.fail('Copying to invalid URL succeeded unexpectedly.'); - }) - .catch(err => { - expect(err.message) - .toEqual( - 'Copying failed because no save handler is found ' + - 'for destination URL invalidurl.'); - - // Verify that the source has not been removed. - tf.io.listModels() - .then(out => { - expect(Object.keys(out)).toEqual([url1]); - done(); - }) - .catch(err => done.fail(err.stack)); - }); - }) - .catch(err => done.fail(err.stack)); - })); - - it('Failed deletedModel: Absent scheme', runWithLock(done => { - // Attempt to delete a nonexistent model is expected to fail. - tf.io.removeModel('foo') - .then(out => { - done.fail( - 'Removing model with missing scheme succeeded unexpectedly.'); - }) - .catch(err => { - expect(err.message) - .toMatch(/The url string provided does not contain a scheme/); - expect(err.message.indexOf('localstorage')).toBeGreaterThan(0); - expect(err.message.indexOf('indexeddb')).toBeGreaterThan(0); - done(); - }); - })); - - it('Failed deletedModel: Invalid scheme', runWithLock(done => { - // Attempt to delete a nonexistent model is expected to fail. - tf.io.removeModel('invalidscheme://foo') - .then(out => { - done.fail('Removing nonexistent model succeeded unexpectedly.'); - }) - .catch(err => { - expect(err.message) - .toEqual( - 'Cannot find model manager for scheme \'invalidscheme\''); - done(); - }); - })); - - it('Failed deletedModel: Nonexistent model', runWithLock(done => { - // Attempt to delete a nonexistent model is expected to fail. - tf.io.removeModel('indexeddb://nonexistent') - .then(out => { - done.fail('Removing nonexistent model succeeded unexpectedly.'); - }) - .catch(err => { - expect(err.message) - .toEqual( - 'Cannot find model ' + - 'with path \'nonexistent\' in IndexedDB.'); - done(); - }); - })); - - it('Failed copyModel', runWithLock(done => { - // Attempt to copy a nonexistent model should fail. - tf.io.copyModel('indexeddb://nonexistent', 'indexeddb://destination') - .then(out => { - done.fail('Copying nonexistent model succeeded unexpectedly.'); - }) - .catch(err => { - expect(err.message) - .toEqual( - 'Cannot find model ' + - 'with path \'nonexistent\' in IndexedDB.'); - done(); - }); - })); - - it('copyModel: Identical oldPath and newPath leads to Error', - runWithLock(done => { - tf.io.copyModel('a/1', 'a/1') - .then(out => { - done.fail( - 'Copying with identical ' + - 'old & new paths succeeded unexpectedly.'); - }) - .catch(err => { - expect(err.message) - .toEqual('Old path and new path are the same: \'a/1\''); - done(); - }); - })); - - it('moveModel: Identical oldPath and newPath leads to Error', - runWithLock(done => { - tf.io.moveModel('a/1', 'a/1') - .then(out => { - done.fail( - 'Copying with identical ' + - 'old & new paths succeeded unexpectedly.'); - }) - .catch(err => { - expect(err.message) - .toEqual('Old path and new path are the same: \'a/1\''); - done(); - }); - })); -}); diff --git a/tfjs-master/tfjs-core/src/io/passthrough.ts b/tfjs-master/tfjs-core/src/io/passthrough.ts deleted file mode 100644 index e5416002d..000000000 --- a/tfjs-master/tfjs-core/src/io/passthrough.ts +++ /dev/null @@ -1,181 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -/** - * IOHandlers that pass through the in-memory ModelArtifacts format. - */ - -import {IOHandler, IOHandlerSync, LoadHandler, ModelArtifacts, SaveHandler, SaveResult, TrainingConfig, WeightData, WeightsManifestEntry} from './types'; - -class PassthroughLoader implements IOHandlerSync { - constructor(private readonly modelArtifacts?: ModelArtifacts) {} - - load(): ModelArtifacts { - return this.modelArtifacts; - } -} - -class PassthroughSaver> { - constructor( - private readonly saveHandler: (artifacts: ModelArtifacts) => R) {} - - save(modelArtifacts: ModelArtifacts): R { - return this.saveHandler(modelArtifacts); - } -} - -class PassthroughAsync implements IOHandler { - load?: LoadHandler; - save?: SaveHandler; - - constructor(handler: IOHandlerSync) { - if (handler.load) { - this.load = () => Promise.resolve(handler.load()); - } - if (handler.save) { - this.save = (modelArtifacts: ModelArtifacts) => - Promise.resolve(handler.save(modelArtifacts)); - } - } -} - -/** - * Creates an IOHandler that loads model artifacts from memory. - * - * When used in conjunction with `tf.loadLayersModel`, an instance of - * `tf.LayersModel` (Keras-style) can be constructed from the loaded artifacts. - * - * ```js - * const model = await tf.loadLayersModel(tf.io.fromMemory( - * modelTopology, weightSpecs, weightData)); - * ``` - * - * @param modelArtifacts a object containing model topology (i.e., parsed from - * the JSON format). - * @param weightSpecs An array of `WeightsManifestEntry` objects describing the - * names, shapes, types, and quantization of the weight data. Optional. - * @param weightData A single `ArrayBuffer` containing the weight data, - * concatenated in the order described by the weightSpecs. Optional. - * @param trainingConfig Model training configuration. Optional. - * - * @returns A passthrough `IOHandler` that simply loads the provided data. - */ -export function fromMemory( - modelArtifacts: {}|ModelArtifacts, weightSpecs?: WeightsManifestEntry[], - weightData?: WeightData, trainingConfig?: TrainingConfig): IOHandler { - - const args = arguments as unknown as Parameters; - return new PassthroughAsync(fromMemorySync(...args)); -} - -/** - * Creates an IOHandler that loads model artifacts from memory. - * - * When used in conjunction with `tf.loadLayersModel`, an instance of - * `tf.LayersModel` (Keras-style) can be constructed from the loaded artifacts. - * - * ```js - * const model = await tf.loadLayersModel(tf.io.fromMemory( - * modelTopology, weightSpecs, weightData)); - * ``` - * - * @param modelArtifacts a object containing model topology (i.e., parsed from - * the JSON format). - * @param weightSpecs An array of `WeightsManifestEntry` objects describing the - * names, shapes, types, and quantization of the weight data. Optional. - * @param weightData A single `ArrayBuffer` containing the weight data, - * concatenated in the order described by the weightSpecs. Optional. - * @param trainingConfig Model training configuration. Optional. - * - * @returns A passthrough `IOHandlerSync` that simply loads the provided data. - */ -export function fromMemorySync( - modelArtifacts: {}|ModelArtifacts, weightSpecs?: WeightsManifestEntry[], - weightData?: WeightData, trainingConfig?: TrainingConfig): IOHandlerSync { - if (arguments.length === 1) { - const isModelArtifacts = - (modelArtifacts as ModelArtifacts).modelTopology != null || - (modelArtifacts as ModelArtifacts).weightSpecs != null; - if (isModelArtifacts) { - return new PassthroughLoader(modelArtifacts as ModelArtifacts); - } else { - // Legacy support: with only modelTopology. - // TODO(cais): Remove this deprecated API. - console.warn( - 'Please call tf.io.fromMemory() with only one argument. ' + - 'The argument should be of type ModelArtifacts. ' + - 'The multi-argument signature of tf.io.fromMemory() has been ' + - 'deprecated and will be removed in a future release.'); - return new PassthroughLoader({modelTopology: modelArtifacts as {}}); - } - } else { - // Legacy support. - // TODO(cais): Remove this deprecated API. - console.warn( - 'Please call tf.io.fromMemory() with only one argument. ' + - 'The argument should be of type ModelArtifacts. ' + - 'The multi-argument signature of tf.io.fromMemory() has been ' + - 'deprecated and will be removed in a future release.'); - return new PassthroughLoader({ - modelTopology: modelArtifacts as {}, - weightSpecs, - weightData, - trainingConfig - }); - } -} - -/** - * Creates an IOHandler that passes saved model artifacts to a callback. - * - * ```js - * function handleSave(artifacts) { - * // ... do something with the artifacts ... - * return {modelArtifactsInfo: {...}, ...}; - * } - * - * const saveResult = model.save(tf.io.withSaveHandler(handleSave)); - * ``` - * - * @param saveHandler A function that accepts a `ModelArtifacts` and returns a - * promise that resolves to a `SaveResult`. - */ -export function withSaveHandler( - saveHandler: (artifacts: ModelArtifacts) => - Promise): IOHandler { - return new PassthroughSaver(saveHandler); -} - -/** - * Creates an IOHandlerSync that passes saved model artifacts to a callback. - * - * ```js - * function handleSave(artifacts) { - * // ... do something with the artifacts ... - * return {modelArtifactsInfo: {...}, ...}; - * } - * - * const saveResult = model.save(tf.io.withSaveHandler(handleSave)); - * ``` - * - * @param saveHandler A function that accepts a `ModelArtifacts` and returns a - * `SaveResult`. - */ -export function withSaveHandlerSync( - saveHandler: (artifacts: ModelArtifacts) => SaveResult): IOHandlerSync { - return new PassthroughSaver(saveHandler); -} diff --git a/tfjs-master/tfjs-core/src/io/passthrough_test.ts b/tfjs-master/tfjs-core/src/io/passthrough_test.ts deleted file mode 100644 index 08bbec4ac..000000000 --- a/tfjs-master/tfjs-core/src/io/passthrough_test.ts +++ /dev/null @@ -1,270 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -/** - * Unit tests for passthrough IOHandlers. - */ - -import * as tf from '../index'; -import {BROWSER_ENVS, describeWithFlags} from '../jasmine_util'; - -const modelTopology1: {} = { - 'class_name': 'Sequential', - 'keras_version': '2.1.4', - 'config': [{ - 'class_name': 'Dense', - 'config': { - 'kernel_initializer': { - 'class_name': 'VarianceScaling', - 'config': { - 'distribution': 'uniform', - 'scale': 1.0, - 'seed': null, - 'mode': 'fan_avg' - } - }, - 'name': 'dense', - 'kernel_constraint': null, - 'bias_regularizer': null, - 'bias_constraint': null, - 'dtype': 'float32', - 'activation': 'linear', - 'trainable': true, - 'kernel_regularizer': null, - 'bias_initializer': {'class_name': 'Zeros', 'config': {}}, - 'units': 1, - 'batch_input_shape': [null, 3], - 'use_bias': true, - 'activity_regularizer': null - } - }], - 'backend': 'tensorflow' -}; - -const weightSpecs1: tf.io.WeightsManifestEntry[] = [ - { - name: 'dense/kernel', - shape: [3, 1], - dtype: 'float32', - }, - { - name: 'dense/bias', - shape: [1], - dtype: 'float32', - } -]; - -const weightData1 = new ArrayBuffer(16); -const artifacts1: tf.io.ModelArtifacts = { - modelTopology: modelTopology1, - weightSpecs: weightSpecs1, - weightData: weightData1, -}; - -describeWithFlags('Passthrough Saver', BROWSER_ENVS, () => { - it('passes provided arguments through on save', async () => { - const testStartDate = new Date(); - let savedArtifacts: tf.io.ModelArtifacts = null; - - async function saveHandler(artifacts: tf.io.ModelArtifacts): - Promise { - savedArtifacts = artifacts; - return { - modelArtifactsInfo: { - dateSaved: testStartDate, - modelTopologyType: 'JSON', - modelTopologyBytes: JSON.stringify(modelTopology1).length, - weightSpecsBytes: JSON.stringify(weightSpecs1).length, - weightDataBytes: weightData1.byteLength, - } - }; - } - - const saveTrigger = tf.io.withSaveHandler(saveHandler); - const saveResult = await saveTrigger.save(artifacts1); - - expect(saveResult.errors).toEqual(undefined); - const artifactsInfo = saveResult.modelArtifactsInfo; - expect(artifactsInfo.dateSaved.getTime()) - .toBeGreaterThanOrEqual(testStartDate.getTime()); - expect(saveResult.modelArtifactsInfo.modelTopologyBytes) - .toEqual(JSON.stringify(modelTopology1).length); - expect(saveResult.modelArtifactsInfo.weightSpecsBytes) - .toEqual(JSON.stringify(weightSpecs1).length); - expect(saveResult.modelArtifactsInfo.weightDataBytes).toEqual(16); - - expect(savedArtifacts.modelTopology).toEqual(modelTopology1); - expect(savedArtifacts.weightSpecs).toEqual(weightSpecs1); - expect(savedArtifacts.weightData).toEqual(weightData1); - }); -}); - -describeWithFlags('Passthrough Saver Sync', BROWSER_ENVS, () => { - it('passes provided arguments through on save', () => { - const testStartDate = new Date(); - let savedArtifacts: tf.io.ModelArtifacts = null; - - function saveHandler(artifacts: tf.io.ModelArtifacts): - tf.io.SaveResult { - savedArtifacts = artifacts; - return { - modelArtifactsInfo: { - dateSaved: testStartDate, - modelTopologyType: 'JSON', - modelTopologyBytes: JSON.stringify(modelTopology1).length, - weightSpecsBytes: JSON.stringify(weightSpecs1).length, - weightDataBytes: weightData1.byteLength, - } - }; - } - - const saveTrigger = tf.io.withSaveHandlerSync(saveHandler); - const saveResult = saveTrigger.save(artifacts1); - - expect(saveResult.errors).toEqual(undefined); - const artifactsInfo = saveResult.modelArtifactsInfo; - expect(artifactsInfo.dateSaved.getTime()) - .toBeGreaterThanOrEqual(testStartDate.getTime()); - expect(saveResult.modelArtifactsInfo.modelTopologyBytes) - .toEqual(JSON.stringify(modelTopology1).length); - expect(saveResult.modelArtifactsInfo.weightSpecsBytes) - .toEqual(JSON.stringify(weightSpecs1).length); - expect(saveResult.modelArtifactsInfo.weightDataBytes).toEqual(16); - - expect(savedArtifacts.modelTopology).toEqual(modelTopology1); - expect(savedArtifacts.weightSpecs).toEqual(weightSpecs1); - expect(savedArtifacts.weightData).toEqual(weightData1); - }); -}); - -describeWithFlags('Passthrough Loader', BROWSER_ENVS, () => { - it('load topology and weights: legacy signature', async () => { - const passthroughHandler = - tf.io.fromMemory(modelTopology1, weightSpecs1, weightData1); - const modelArtifacts = await passthroughHandler.load(); - expect(modelArtifacts.modelTopology).toEqual(modelTopology1); - expect(modelArtifacts.weightSpecs).toEqual(weightSpecs1); - expect(modelArtifacts.weightData).toEqual(weightData1); - expect(modelArtifacts.userDefinedMetadata).toEqual(undefined); - }); - - it('load topology and weights', async () => { - const passthroughHandler = tf.io.fromMemory({ - modelTopology: modelTopology1, - weightSpecs: weightSpecs1, - weightData: weightData1 - }); - const modelArtifacts = await passthroughHandler.load(); - expect(modelArtifacts.modelTopology).toEqual(modelTopology1); - expect(modelArtifacts.weightSpecs).toEqual(weightSpecs1); - expect(modelArtifacts.weightData).toEqual(weightData1); - expect(modelArtifacts.userDefinedMetadata).toEqual(undefined); - }); - - it('load model topology only: legacy signature', async () => { - const passthroughHandler = tf.io.fromMemory(modelTopology1); - const modelArtifacts = await passthroughHandler.load(); - expect(modelArtifacts.modelTopology).toEqual(modelTopology1); - expect(modelArtifacts.weightSpecs).toEqual(undefined); - expect(modelArtifacts.weightData).toEqual(undefined); - expect(modelArtifacts.userDefinedMetadata).toEqual(undefined); - }); - - it('load model topology only', async () => { - const passthroughHandler = - tf.io.fromMemory({modelTopology: modelTopology1}); - const modelArtifacts = await passthroughHandler.load(); - expect(modelArtifacts.modelTopology).toEqual(modelTopology1); - expect(modelArtifacts.weightSpecs).toEqual(undefined); - expect(modelArtifacts.weightData).toEqual(undefined); - expect(modelArtifacts.userDefinedMetadata).toEqual(undefined); - }); - - it('load topology, weights, and user-defined metadata', async () => { - const userDefinedMetadata: {} = {'fooField': 'fooValue'}; - const passthroughHandler = tf.io.fromMemory({ - modelTopology: modelTopology1, - weightSpecs: weightSpecs1, - weightData: weightData1, - userDefinedMetadata - }); - const modelArtifacts = await passthroughHandler.load(); - expect(modelArtifacts.modelTopology).toEqual(modelTopology1); - expect(modelArtifacts.weightSpecs).toEqual(weightSpecs1); - expect(modelArtifacts.weightData).toEqual(weightData1); - expect(modelArtifacts.userDefinedMetadata).toEqual(userDefinedMetadata); - }); -}); - -describeWithFlags('Passthrough Loader Sync', BROWSER_ENVS, () => { - it('load topology and weights: legacy signature', () => { - const passthroughHandler = - tf.io.fromMemorySync(modelTopology1, weightSpecs1, weightData1); - const modelArtifacts = passthroughHandler.load(); - expect(modelArtifacts.modelTopology).toEqual(modelTopology1); - expect(modelArtifacts.weightSpecs).toEqual(weightSpecs1); - expect(modelArtifacts.weightData).toEqual(weightData1); - expect(modelArtifacts.userDefinedMetadata).toEqual(undefined); - }); - - it('load topology and weights', () => { - const passthroughHandler = tf.io.fromMemorySync({ - modelTopology: modelTopology1, - weightSpecs: weightSpecs1, - weightData: weightData1 - }); - const modelArtifacts = passthroughHandler.load(); - expect(modelArtifacts.modelTopology).toEqual(modelTopology1); - expect(modelArtifacts.weightSpecs).toEqual(weightSpecs1); - expect(modelArtifacts.weightData).toEqual(weightData1); - expect(modelArtifacts.userDefinedMetadata).toEqual(undefined); - }); - - it('load model topology only: legacy signature', () => { - const passthroughHandler = tf.io.fromMemorySync(modelTopology1); - const modelArtifacts = passthroughHandler.load(); - expect(modelArtifacts.modelTopology).toEqual(modelTopology1); - expect(modelArtifacts.weightSpecs).toEqual(undefined); - expect(modelArtifacts.weightData).toEqual(undefined); - expect(modelArtifacts.userDefinedMetadata).toEqual(undefined); - }); - - it('load model topology only', () => { - const passthroughHandler = - tf.io.fromMemorySync({modelTopology: modelTopology1}); - const modelArtifacts = passthroughHandler.load(); - expect(modelArtifacts.modelTopology).toEqual(modelTopology1); - expect(modelArtifacts.weightSpecs).toEqual(undefined); - expect(modelArtifacts.weightData).toEqual(undefined); - expect(modelArtifacts.userDefinedMetadata).toEqual(undefined); - }); - - it('load topology, weights, and user-defined metadata', () => { - const userDefinedMetadata: {} = {'fooField': 'fooValue'}; - const passthroughHandler = tf.io.fromMemorySync({ - modelTopology: modelTopology1, - weightSpecs: weightSpecs1, - weightData: weightData1, - userDefinedMetadata - }); - const modelArtifacts = passthroughHandler.load(); - expect(modelArtifacts.modelTopology).toEqual(modelTopology1); - expect(modelArtifacts.weightSpecs).toEqual(weightSpecs1); - expect(modelArtifacts.weightData).toEqual(weightData1); - expect(modelArtifacts.userDefinedMetadata).toEqual(userDefinedMetadata); - }); -}); diff --git a/tfjs-master/tfjs-core/src/io/progress.ts b/tfjs-master/tfjs-core/src/io/progress.ts deleted file mode 100644 index 8d6b3d7fa..000000000 --- a/tfjs-master/tfjs-core/src/io/progress.ts +++ /dev/null @@ -1,73 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {assert} from '../util'; - -import {OnProgressCallback} from './types'; - -/** - * Monitor Promise.all progress, fire onProgress callback function. - * - * @param promises Promise list going to be monitored - * @param onProgress Callback function. Fired when a promise resolved. - * @param startFraction Optional fraction start. Default to 0. - * @param endFraction Optional fraction end. Default to 1. - */ -export function monitorPromisesProgress( - promises: Array>, onProgress: OnProgressCallback, - startFraction?: number, endFraction?: number) { - checkPromises(promises); - startFraction = startFraction == null ? 0 : startFraction; - endFraction = endFraction == null ? 1 : endFraction; - checkFraction(startFraction, endFraction); - let resolvedPromise = 0; - - const registerMonitor = (promise: Promise<{}>) => { - promise.then(value => { - const fraction = startFraction + - ++resolvedPromise / promises.length * (endFraction - startFraction); - // pass fraction as parameter to callback function. - onProgress(fraction); - return value; - }); - return promise; - }; - - function checkPromises(promises: Array>): void { - assert( - promises != null && Array.isArray(promises) && promises.length > 0, - () => 'promises must be a none empty array'); - } - - function checkFraction(startFraction: number, endFraction: number): void { - assert( - startFraction >= 0 && startFraction <= 1, - () => `Progress fraction must be in range [0, 1], but ` + - `got startFraction ${startFraction}`); - assert( - endFraction >= 0 && endFraction <= 1, - () => `Progress fraction must be in range [0, 1], but ` + - `got endFraction ${endFraction}`); - assert( - endFraction >= startFraction, - () => `startFraction must be no more than endFraction, but ` + - `got startFraction ${startFraction} and endFraction ` + - `${endFraction}`); - } - - return Promise.all(promises.map(registerMonitor)); -} diff --git a/tfjs-master/tfjs-core/src/io/progress_test.ts b/tfjs-master/tfjs-core/src/io/progress_test.ts deleted file mode 100644 index 7f0692ed9..000000000 --- a/tfjs-master/tfjs-core/src/io/progress_test.ts +++ /dev/null @@ -1,86 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {monitorPromisesProgress} from './progress'; - -describe('util.monitorPromisesProgress', () => { - it('Default progress from 0 to 1', (done) => { - const expectFractions: number[] = [0.25, 0.50, 0.75, 1.00]; - const fractionList: number[] = []; - const tasks = Array(4).fill(0).map(() => { - return Promise.resolve(); - }); - monitorPromisesProgress(tasks, (progress: number) => { - fractionList.push(parseFloat(progress.toFixed(2))); - }).then(() => { - expect(fractionList).toEqual(expectFractions); - done(); - }); - }); - - it('Progress with pre-defined range', (done) => { - const startFraction = 0.2; - const endFraction = 0.8; - const expectFractions: number[] = [0.35, 0.50, 0.65, 0.80]; - const fractionList: number[] = []; - const tasks = Array(4).fill(0).map(() => { - return Promise.resolve(); - }); - monitorPromisesProgress(tasks, (progress: number) => { - fractionList.push(parseFloat(progress.toFixed(2))); - }, startFraction, endFraction).then(() => { - expect(fractionList).toEqual(expectFractions); - done(); - }); - }); - - it('throws error when progress fraction is out of range', () => { - expect(() => { - const startFraction = -1; - const endFraction = 1; - const tasks = Array(4).fill(0).map(() => { - return Promise.resolve(); - }); - monitorPromisesProgress( - tasks, (progress: number) => {}, startFraction, endFraction); - }).toThrowError(); - }); - - it('throws error when startFraction more than endFraction', () => { - expect(() => { - const startFraction = 0.8; - const endFraction = 0.2; - const tasks = Array(4).fill(0).map(() => { - return Promise.resolve(); - }); - monitorPromisesProgress( - tasks, (progress: number) => {}, startFraction, endFraction); - }).toThrowError(); - }); - - it('throws error when promises is null', () => { - expect(() => { - monitorPromisesProgress(null, (progress: number) => {}); - }).toThrowError(); - }); - - it('throws error when promises is empty array', () => { - expect(() => { - monitorPromisesProgress([], (progress: number) => {}); - }).toThrowError(); - }); -}); diff --git a/tfjs-master/tfjs-core/src/io/router_registry.ts b/tfjs-master/tfjs-core/src/io/router_registry.ts deleted file mode 100644 index 7094f9243..000000000 --- a/tfjs-master/tfjs-core/src/io/router_registry.ts +++ /dev/null @@ -1,112 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {IOHandler, LoadOptions} from './types'; - -export type IORouter = (url: string|string[], loadOptions?: LoadOptions) => - IOHandler; - -export class IORouterRegistry { - // Singleton instance. - private static instance: IORouterRegistry; - - private saveRouters: IORouter[]; - private loadRouters: IORouter[]; - - private constructor() { - this.saveRouters = []; - this.loadRouters = []; - } - - private static getInstance(): IORouterRegistry { - if (IORouterRegistry.instance == null) { - IORouterRegistry.instance = new IORouterRegistry(); - } - return IORouterRegistry.instance; - } - - /** - * Register a save-handler router. - * - * @param saveRouter A function that maps a URL-like string onto an instance - * of `IOHandler` with the `save` method defined or `null`. - */ - static registerSaveRouter(saveRouter: IORouter) { - IORouterRegistry.getInstance().saveRouters.push(saveRouter); - } - - /** - * Register a load-handler router. - * - * @param loadRouter A function that maps a URL-like string onto an instance - * of `IOHandler` with the `load` method defined or `null`. - */ - static registerLoadRouter(loadRouter: IORouter) { - IORouterRegistry.getInstance().loadRouters.push(loadRouter); - } - - /** - * Look up IOHandler for saving, given a URL-like string. - * - * @param url - * @returns If only one match is found, an instance of IOHandler with the - * `save` method defined. If no match is found, `null`. - * @throws Error, if more than one match is found. - */ - static getSaveHandlers(url: string|string[]): IOHandler[] { - return IORouterRegistry.getHandlers(url, 'save'); - } - - /** - * Look up IOHandler for loading, given a URL-like string. - * - * @param url - * @param loadOptions Optional, custom load options. - * @returns All valid handlers for `url`, given the currently registered - * handler routers. - */ - static getLoadHandlers(url: string|string[], loadOptions?: LoadOptions): - IOHandler[] { - return IORouterRegistry.getHandlers(url, 'load', loadOptions); - } - - private static getHandlers( - url: string|string[], handlerType: 'save'|'load', - loadOptions?: LoadOptions): IOHandler[] { - const validHandlers: IOHandler[] = []; - const routers = handlerType === 'load' ? - IORouterRegistry.getInstance().loadRouters : - IORouterRegistry.getInstance().saveRouters; - routers.forEach(router => { - const handler = router(url, loadOptions); - if (handler !== null) { - validHandlers.push(handler); - } - }); - return validHandlers; - } -} - -export const registerSaveRouter = (loudRouter: IORouter) => - IORouterRegistry.registerSaveRouter(loudRouter); -export const registerLoadRouter = (loudRouter: IORouter) => - IORouterRegistry.registerLoadRouter(loudRouter); -export const getSaveHandlers = (url: string|string[]) => - IORouterRegistry.getSaveHandlers(url); -export const getLoadHandlers = - (url: string|string[], loadOptions?: LoadOptions) => - IORouterRegistry.getLoadHandlers(url, loadOptions); diff --git a/tfjs-master/tfjs-core/src/io/router_registry_test.ts b/tfjs-master/tfjs-core/src/io/router_registry_test.ts deleted file mode 100644 index 834e8e3d1..000000000 --- a/tfjs-master/tfjs-core/src/io/router_registry_test.ts +++ /dev/null @@ -1,148 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {BROWSER_ENVS, describeWithFlags} from '../jasmine_util'; - -import {BrowserIndexedDB, browserIndexedDB} from './indexed_db'; -import {BrowserLocalStorage, browserLocalStorage} from './local_storage'; -import {IORouterRegistry} from './router_registry'; -import {IOHandler, LoadHandler, LoadOptions, SaveHandler} from './types'; - -describeWithFlags('IORouterRegistry', BROWSER_ENVS, () => { - const localStorageRouter = (url: string) => { - const scheme = 'localstorage://'; - if (url.startsWith(scheme)) { - return browserLocalStorage(url.slice(scheme.length)); - } else { - return null; - } - }; - - const indexedDBRouter = (url: string) => { - const scheme = 'indexeddb://'; - if (url.startsWith(scheme)) { - return browserIndexedDB(url.slice(scheme.length)); - } else { - return null; - } - }; - - class FakeIOHandler implements IOHandler { - constructor(url1: string, url2: string) {} - } - - const fakeMultiStringRouter = (url: string|string[]) => { - const scheme = 'foo://'; - if (Array.isArray(url) && url.length === 2) { - if (url[0].startsWith(scheme) && url[1].startsWith(scheme)) { - return new FakeIOHandler(url[0], url[1]); - } else { - return null; - } - } else { - return null; - } - }; - - let tempRegistryInstance: IORouterRegistry = null; - beforeEach(() => { - // Force reset registry for testing. - // tslint:disable:no-any - tempRegistryInstance = (IORouterRegistry as any).instance; - (IORouterRegistry as any).instance = null; - // tslint:enable:no-any - }); - - afterEach(() => { - // tslint:disable-next-line:no-any - (IORouterRegistry as any).instance = tempRegistryInstance; - }); - - it('getSaveHandler succeeds', () => { - IORouterRegistry.registerSaveRouter(localStorageRouter); - IORouterRegistry.registerSaveRouter(indexedDBRouter); - - const out1 = tf.io.getSaveHandlers('localstorage://foo-model'); - expect(out1.length).toEqual(1); - expect(out1[0] instanceof BrowserLocalStorage).toEqual(true); - const out2 = tf.io.getSaveHandlers('indexeddb://foo-model'); - expect(out2.length).toEqual(1); - expect(out2[0] instanceof BrowserIndexedDB).toEqual(true); - }); - - it('getLoadHandler succeeds', () => { - IORouterRegistry.registerLoadRouter(localStorageRouter); - IORouterRegistry.registerLoadRouter(indexedDBRouter); - - const out1 = tf.io.getLoadHandlers('localstorage://foo-model'); - expect(out1.length).toEqual(1); - expect(out1[0] instanceof BrowserLocalStorage).toEqual(true); - const out2 = tf.io.getLoadHandlers('indexeddb://foo-model'); - expect(out2.length).toEqual(1); - expect(out2[0] instanceof BrowserIndexedDB).toEqual(true); - }); - - it('getLoadHandler with string array argument succeeds', () => { - IORouterRegistry.registerLoadRouter(fakeMultiStringRouter); - const loadHandler = - IORouterRegistry.getLoadHandlers(['foo:///123', 'foo:///456']); - expect(loadHandler[0] instanceof FakeIOHandler).toEqual(true); - - expect(IORouterRegistry.getLoadHandlers([ - 'foo:///123', 'bar:///456' - ])).toEqual([]); - expect(IORouterRegistry.getLoadHandlers(['foo:///123'])).toEqual([]); - expect(IORouterRegistry.getLoadHandlers('foo:///123')).toEqual([]); - }); - - it('getSaveHandler fails', () => { - IORouterRegistry.registerSaveRouter(localStorageRouter); - - expect(tf.io.getSaveHandlers('invalidscheme://foo-model')).toEqual([]); - // Check there is no crosstalk between save and load handlers. - expect(tf.io.getLoadHandlers('localstorage://foo-model')).toEqual([]); - }); - - const fakeLoadOptionsRouter = (url: string, loadOptions?: LoadOptions) => { - return new FakeLoadOptionsHandler(url, loadOptions); - }; - - class FakeLoadOptionsHandler implements IOHandler { - save?: SaveHandler; - load?: LoadHandler; - constructor(url: string, private readonly loadOptions?: LoadOptions) {} - get loadOptionsData() { - return this.loadOptions; - } - } - - it('getLoadHandler loadOptions', () => { - IORouterRegistry.registerLoadRouter(fakeLoadOptionsRouter); - - const loadOptions: LoadOptions = { - onProgress: (fraction: number) => {}, - fetchFunc: () => {} - }; - const loadHandler = tf.io.getLoadHandlers('foo:///123', loadOptions); - expect(loadHandler.length).toEqual(1); - expect(loadHandler[0] instanceof FakeLoadOptionsHandler).toEqual(true); - // Check callback function passed to IOHandler - expect((loadHandler[0] as FakeLoadOptionsHandler).loadOptionsData) - .toBe(loadOptions); - }); -}); diff --git a/tfjs-master/tfjs-core/src/io/types.ts b/tfjs-master/tfjs-core/src/io/types.ts deleted file mode 100644 index 2dc0893a8..000000000 --- a/tfjs-master/tfjs-core/src/io/types.ts +++ /dev/null @@ -1,545 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -/* Type definitions for exporting and importing of models. */ - -/** - * A map from Tensor dtype to number of bytes per element of the Tensor. - */ -export const DTYPE_VALUE_SIZE_MAP: {[dtype: string]: number} = { - 'float32': 4, - 'float16': 2, - 'int32': 4, - 'uint16': 2, - 'uint8': 1, - 'bool': 1, - 'complex64': 8 -}; - -/** - * A weight manifest. - * - * The weight manifest consists of an ordered list of weight-manifest groups. - * Each weight-manifest group ("group" for short hereafter) consists of a - * number of weight values stored in a number of paths. - * See the documentation of `WeightManifestGroupConfig` below for more details. - */ -export declare type WeightsManifestConfig = WeightsManifestGroupConfig[]; - -/** - * A weight-manifest group. - * - * Consists of an ordered list of weight values encoded in binary format, - * stored in an ordered list of paths. - */ -export declare interface WeightsManifestGroupConfig { - /** - * An ordered list of paths. - * - * Paths are intentionally abstract in order to be general. For example, they - * can be relative URL paths or relative paths on the file system. - */ - paths: string[]; - - /** - * Specifications of the weights stored in the paths. - */ - weights: WeightsManifestEntry[]; -} - -/** - * Group to which the weight belongs. - * - * - 'optimizer': Weight from a stateful optimizer. - */ -export type WeightGroup = 'model'|'optimizer'; - -/** - * An entry in the weight manifest. - * - * The entry contains specification of a weight. - */ -export declare interface WeightsManifestEntry { - /** - * Name of the weight, e.g., 'Dense_1/bias' - */ - name: string; - - /** - * Shape of the weight. - */ - shape: number[]; - - /** - * Data type of the weight. - */ - dtype: 'float32'|'int32'|'bool'|'string'|'complex64'; - - /** - * Type of the weight. - * - * Optional. - * - * The value 'optimizer' indicates the weight belongs to an optimizer - * (i.e., used only during model training and not during inference). - */ - group?: WeightGroup; - - /** - * Information for dequantization of the weight. - */ - quantization?: { - scale?: number, // The scaling constant to multiply by. - min?: number, // The (possibly nudged) minimum weight to add. - dtype: 'uint16'|'uint8'|'float16' // The dtype of the quantized weights. - }; -} - -/** - * Options for saving a model. - * @innamespace io - */ -export interface SaveConfig { - /** - * Whether to save only the trainable weights of the model, ignoring the - * non-trainable ones. - */ - trainableOnly?: boolean; - - /** - * Whether the optimizer will be saved (if exists). - * - * Default: `false`. - */ - includeOptimizer?: boolean; -} - -/** - * Result of a saving operation. - */ -export interface SaveResult { - /** - * Information about the model artifacts saved. - */ - modelArtifactsInfo: ModelArtifactsInfo; - - /** - * HTTP responses from the server that handled the model-saving request (if - * any). This is applicable only to server-based saving routes. - */ - responses?: Response[]; - - /** - * Error messages and related data (if any). - */ - errors?: Array<{}|string>; -} - -export declare interface ModelArtifactsInfo { - /** - * Timestamp for when the model is saved. - */ - dateSaved: Date; - - /** - * TODO (cais,yassogba) consider removing GraphDef as GraphDefs now - * come in a JSON format and none of our IOHandlers support a non json - * format. We could conder replacing this with 'Binary' if we want to - * allow future handlers to save to non json formats (though they will - * probably want more information than 'Binary'). - * Type of the model topology - * - * Type of the model topology - * - * Possible values: - * - JSON: JSON config (human-readable, e.g., Keras JSON). - * - GraphDef: TensorFlow - * [GraphDef](https://www.tensorflow.org/extend/tool_developers/#graphdef) - * protocol buffer (binary). - */ - modelTopologyType: 'JSON'|'GraphDef'; - - /** - * Size of model topology (Keras JSON or GraphDef), in bytes. - */ - modelTopologyBytes?: number; - - /** - * Size of weight specification or manifest, in bytes. - */ - weightSpecsBytes?: number; - - /** - * Size of weight value data, in bytes. - */ - weightDataBytes?: number; -} - -/** Model training configuration. */ -export declare interface TrainingConfig { - // TODO(cais): Tighten the typing once keras spec is available to tfjs-core. - // See - // tslint:disable-next-line:max-line-length - // https://github.com/tensorflow/tfjs-layers/blob/master/src/keras_format/training_config.ts - /** Optimizer used for the model training. */ - optimizer_config: {}; - - // TODO(cais): Tighten the typing once keras spec is available to tfjs-core. - /** Loss function(s) for the model's output(s). */ - loss: string|string[]|{[key: string]: string}; - - // TODO(cais): Tighten the typing once keras spec is available to tfjs-core. - /** Metric function(s) for the model's output(s). */ - metrics?: string[]|{[key: string]: string}; - - // TODO(cais): Tighten the typing once keras spec is available to tfjs-core. - weighted_metrics?: string[]; - - // TODO(cais): Tighten the typing once keras spec is available to tfjs-core. - sample_weight_mode?: string; - - loss_weights?: number[]|{[key: string]: number}; -} - -export type WeightData = ArrayBuffer | ArrayBuffer[]; - -/** - * The serialized artifacts of a model, including topology and weights. - * - * The `modelTopology`, `trainingConfig`, `weightSpecs` and `weightData` fields - * of this interface are optional, in order to support topology- or weights-only - * saving and loading. - * - * Note this interface is used internally in IOHandlers. For the file format - * written to disk as `model.json`, see `ModelJSON`. - */ -export declare interface ModelArtifacts { - /** - * Model topology. - * - * For Keras-style `tf.Model`s, this is a JSON object. - * For TensorFlow-style models (e.g., `SavedModel`), this is the JSON - * encoding of the `GraphDef` protocol buffer. - */ - modelTopology?: {}|ArrayBuffer; - - /** - * Serialized configuration for the model's training. - */ - trainingConfig?: TrainingConfig; - - /** - * Weight specifications. - * - * This corresponds to the weightsData below. - */ - weightSpecs?: WeightsManifestEntry[]; - - /** - * Binary buffer(s) for all weight values in the order specified by - * `weightSpecs`. This may be a single ArrayBuffer of all the weights - * concatenated together or an Array of ArrayBuffers containing the weights - * (weights may be sharded across multiple ArrayBuffers). - */ - weightData?: WeightData; - - /** - * Hard-coded format name for models saved from TensorFlow.js or converted - * by TensorFlow.js Converter. - */ - format?: string; - - /** - * What library is responsible for originally generating this artifact. - * - * Used for debugging purposes. E.g., 'TensorFlow.js v1.0.0'. - */ - generatedBy?: string; - - /** - * What library or tool is responsible for converting the original model - * to this format, applicable only if the model is output by a converter. - * - * Used for debugging purposes. E.g., 'TensorFlow.js Converter v1.0.0'. - * - * A value of `null` means the model artifacts are generated without any - * conversion process (e.g., saved directly from a TensorFlow.js - * `tf.LayersModel` instance.) - */ - convertedBy?: string|null; - - /** - * Inputs and outputs signature for saved model. - */ - signature?: {}; - - /** - * User-defined metadata about the model. - */ - userDefinedMetadata?: {[key: string]: {}}; - - /** - * Initializer for the model. - */ - modelInitializer?: {}; - - /** - * Inputs and outputs signature for model initializer. - */ - initializerSignature?: {}; -} - -/** - * The on-disk format of the `model.json` file. - * - * TF.js 1.0 always populates the optional fields when writing model.json. - * Prior versions did not provide those fields. - */ -export declare interface ModelJSON { - /** - * Model topology. - * - * For Keras-style `tf.Model`s, this is a JSON object. - * For TensorFlow-style models (e.g., `SavedModel`), this is the JSON - * encoding of the `GraphDef` protocol buffer. - */ - modelTopology: {}; - - /** Model training configuration. */ - trainingConfig?: TrainingConfig; - - /** - * Weights manifest. - * - * The weights manifest consists of an ordered list of weight-manifest - * groups. Each weight-manifest group consists of a number of weight values - * stored in a number of paths. See the documentation of - * `WeightsManifestConfig` for more details. - */ - weightsManifest: WeightsManifestConfig; - - /** - * Hard-coded format name for models saved from TensorFlow.js or converted - * by TensorFlow.js Converter. - */ - format?: string; - - /** - * What library is responsible for originally generating this artifact. - * - * Used for debugging purposes. E.g., 'TensorFlow.js v1.0.0'. - */ - generatedBy?: string; - - /** - * What library or tool is responsible for converting the original model - * to this format, applicable only if the model is output by a converter. - * - * Used for debugging purposes. E.g., 'TensorFlow.js Converter v1.0.0'. - * - * A value of `null` means the model artifacts are generated without any - * conversion process (e.g., saved directly from a TensorFlow.js - * `tf.LayersModel` instance.) - */ - convertedBy?: string|null; - - /** - * Inputs and outputs signature for saved model. - */ - signature?: {}; - - /** - * User-defined metadata about the model. - */ - userDefinedMetadata?: {[key: string]: {}}; - - /** - * Initializer for the model. - */ - modelInitializer?: {}; - - /** - * Inputs and outputs signature for model initializer. - */ - initializerSignature?: {}; -} - -/** - * Type definition for handlers of loading operations. - */ -export type LoadHandler = () => Promise; - -/** - * Type definition for handlers of saving operations. - */ -export type SaveHandler = (modelArtifact: ModelArtifacts) => - Promise; - -/** - * Interface for a model import/export handler. - * - * The `save` and `load` handlers are both optional, in order to allow handlers - * that support only saving or loading. - */ -// tslint:disable-next-line:interface-name -export interface IOHandler { - save?: SaveHandler; - load?: LoadHandler; -} - -/** - * Type definition for handlers of synchronous loading operations. - */ -export type LoadHandlerSync = () => ModelArtifacts; - -/** - * Type definition for handlers of synchronous saving operations. - */ -export type SaveHandlerSync = (modelArtifact: ModelArtifacts) => SaveResult; - -/** - * Interface for a synchronous model import/export handler. - * - * The `save` and `load` handlers are both optional, in order to allow handlers - * that support only saving or loading. - */ -// tslint:disable-next-line:interface-name -export type IOHandlerSync = { - save?: SaveHandlerSync; - load?: LoadHandlerSync; -}; - -/** - * An interface for the manager of a model store. - * - * A model store is defined as a storage medium on which multiple models can - * be stored. Each stored model has a unique `path` as its identifier. - * A `ModelStoreManager` for the store allows actions including - * - * - Listing the models stored in the store. - * - Deleting a model from the store. - */ -export interface ModelStoreManager { - /** - * List all models in the model store. - * - * @returns A dictionary mapping paths of existing models to their - * model artifacts info. Model artifacts info include type of the model's - * topology, byte sizes of the topology, weights, etc. - */ - listModels(): Promise<{[path: string]: ModelArtifactsInfo}>; - - /** - * Remove a model specified by `path`. - * - * @param path - * @returns ModelArtifactsInfo of the deleted model (if and only if deletion - * is successful). - * @throws Error if deletion fails, e.g., if no model exists at `path`. - */ - removeModel(path: string): Promise; -} - -/** - * Callback for the progress of a long-running action such as an HTTP - * request for a large binary object. - * - * `fraction` should be a number in the [0, 1] interval, indicating how - * much of the action has completed. - */ -export type OnProgressCallback = (fraction: number) => void; - -/** @innamespace io */ -export interface LoadOptions { - /** - * RequestInit (options) for HTTP requests. - * - * For detailed information on the supported fields, see - * [https://developer.mozilla.org/en-US/docs/Web/API/Request/Request]( - * https://developer.mozilla.org/en-US/docs/Web/API/Request/Request) - */ - requestInit?: RequestInit; - - /** - * Progress callback. - */ - onProgress?: OnProgressCallback; - - /** - * A function used to override the `window.fetch` function. - */ - fetchFunc?: Function; - - /** - * Strict loading model: whether extraneous weights or missing - * weights should trigger an `Error`. - * - * If `true`, require that the provided weights exactly match those - * required by the layers. `false` means that both extra weights - * and missing weights will be silently ignored. - * - * Default: `true`. - */ - strict?: boolean; - - /** - * Path prefix for weight files, by default this is calculated from the - * path of the model JSON file. - * - * For instance, if the path to the model JSON file is - * `http://localhost/foo/model.json`, then the default path prefix will be - * `http://localhost/foo/`. If a weight file has the path value - * `group1-shard1of2` in the weight manifest, then the weight file will be - * loaded from `http://localhost/foo/group1-shard1of2` by default. However, - * if you provide a `weightPathPrefix` value of - * `http://localhost/foo/alt-weights`, then the weight file will be loaded - * from the path `http://localhost/foo/alt-weights/group1-shard1of2` instead. - */ - weightPathPrefix?: string; - - /** - * Whether the module or model is to be loaded from TF Hub. - * - * Setting this to `true` allows passing a TF-Hub module URL, omitting the - * standard model file name and the query parameters. - * - * Default: `false`. - */ - fromTFHub?: boolean; - - /** - * An async function to convert weight file name to URL. The weight file - * names are stored in model.json's weightsManifest.paths field. By default we - * consider weight files are colocated with the model.json file. For example: - * model.json URL: https://www.google.com/models/1/model.json - * group1-shard1of1.bin url: - * https://www.google.com/models/1/group1-shard1of1.bin - * - * With this func you can convert the weight file name to any URL. - */ - weightUrlConverter?: (weightFileName: string) => Promise; -} - -/** - * Additional options for Platform.fetch - */ -export interface RequestDetails { - /** - * Is this request for a binary file (as opposed to a json file) - */ - isBinary?: boolean; -} diff --git a/tfjs-master/tfjs-core/src/io/weights_loader.ts b/tfjs-master/tfjs-core/src/io/weights_loader.ts deleted file mode 100644 index 8ad0ef2f8..000000000 --- a/tfjs-master/tfjs-core/src/io/weights_loader.ts +++ /dev/null @@ -1,237 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {env} from '../environment'; - -import {NamedTensorMap} from '../tensor_types'; -import * as util from '../util'; -import {CompositeArrayBuffer} from './composite_array_buffer'; -import {decodeWeights} from './io_utils'; -import {monitorPromisesProgress} from './progress'; -import {DTYPE_VALUE_SIZE_MAP, LoadOptions, WeightsManifestConfig, WeightsManifestEntry} from './types'; - -/** - * Reads binary weights data from a number of URLs. - * - * @param fetchURLs URLs to send the HTTP requests at, using `fetch` calls. - * @param requestOptions RequestInit (options) for the HTTP requests. - * @param fetchFunc Optional overriding value for the `window.fetch` function. - * @param onProgress Optional, progress callback function, fired periodically - * before the load is completed. - * @returns A `Promise` of an Array of `ArrayBuffer`. The Array has the same - * length as `fetchURLs`. - */ -export async function loadWeightsAsArrayBuffer( - fetchURLs: string[], loadOptions?: LoadOptions): Promise { - if (loadOptions == null) { - loadOptions = {}; - } - - const fetchFunc = loadOptions.fetchFunc == null ? env().platform.fetch : - loadOptions.fetchFunc; - - // Create the requests for all of the weights in parallel. - const requests = fetchURLs.map( - fetchURL => - fetchFunc(fetchURL, loadOptions.requestInit, { isBinary: true })); - - const fetchStartFraction = 0; - const fetchEndFraction = 0.5; - - const responses = loadOptions.onProgress == null ? - await Promise.all(requests) : - await monitorPromisesProgress( - requests, loadOptions.onProgress, fetchStartFraction, - fetchEndFraction); - - const bufferPromises = responses.map(response => response.arrayBuffer()); - - const bufferStartFraction = 0.5; - const bufferEndFraction = 1; - - const buffers = loadOptions.onProgress == null ? - await Promise.all(bufferPromises) : - await monitorPromisesProgress( - bufferPromises, loadOptions.onProgress, bufferStartFraction, - bufferEndFraction); - return buffers; -} - -/** - * Reads a weights manifest JSON configuration, fetches the weights and - * returns them as `Tensor`s. - * - * @param manifest The weights manifest JSON. - * @param filePathPrefix The path prefix for filenames given in the manifest. - * Defaults to the empty string. - * @param weightNames The names of the weights to be fetched. - */ -export async function loadWeights( - manifest: WeightsManifestConfig, filePathPrefix = '', - weightNames?: string[], - requestInit?: RequestInit): Promise { - // TODO(nsthorat): Groups are currently fetched atomically. If you need a - // single weight from a group, the whole group will be fetched. At a future - // date, we should support fetching only the individual shards within a - // group that are needed to reconstruct the requested weight. - // TODO(cais): Use `decodeWeights` for implementation. - - const fetchWeights = (fetchUrls: string[]) => - loadWeightsAsArrayBuffer(fetchUrls, { requestInit }); - const loadWeights = weightsLoaderFactory(fetchWeights); - - return loadWeights(manifest, filePathPrefix, weightNames); -} - -/** - * Creates a function, which reads a weights manifest JSON configuration, - * fetches the weight files using the specified function and returns them as - * `Tensor`s. - * - * ```js - * // example for creating a nodejs weight loader, which reads the weight files - * // from disk using fs.readFileSync - * - * import * as fs from 'fs' - * - * const fetchWeightsFromDisk = (filePaths: string[]) => - * filePaths.map(filePath => fs.readFileSync(filePath).buffer) - * - * const loadWeights = tf.io.weightsLoaderFactory(fetchWeightsFromDisk) - * - * const manifest = JSON.parse( - * fs.readFileSync('./my_model-weights_manifest').toString() - * ) - * const weightMap = await loadWeights(manifest, './') - * ``` - * @param fetchWeightsFunction The function used for fetching the weight files. - * @returns Weight loading function. - */ -export function weightsLoaderFactory( - fetchWeightsFunction: (fetchUrls: string[]) => Promise): - (manifest: WeightsManifestConfig, filePathPrefix?: string, - weightNames?: string[]) => Promise { - return async ( - manifest: WeightsManifestConfig, filePathPrefix = '', - weightNames?: string[]): Promise => { - // Collect all the groups, weights, and their relative offsets to be - // fetched. - const groupIndicesToFetchMap = manifest.map(() => false); - const groupWeightsToFetch: { - [group: number]: Array<{ - manifestEntry: WeightsManifestEntry; groupOffset: number; - sizeBytes: number; - }> - } = {}; - const weightsFound = - weightNames != null ? weightNames.map(() => false) : []; - const allManifestWeightNames: string[] = []; - manifest.forEach((manifestGroupConfig, groupIndex) => { - let groupOffset = 0; - manifestGroupConfig.weights.forEach(weightsEntry => { - const rawDtype = ('quantization' in weightsEntry) ? - weightsEntry.quantization.dtype : - weightsEntry.dtype; - - const weightsBytes = DTYPE_VALUE_SIZE_MAP[rawDtype] * - util.sizeFromShape(weightsEntry.shape); - - const enqueueWeightsForFetchingFn = () => { - groupIndicesToFetchMap[groupIndex] = true; - if (groupWeightsToFetch[groupIndex] == null) { - groupWeightsToFetch[groupIndex] = []; - } - - groupWeightsToFetch[groupIndex].push({ - manifestEntry: weightsEntry, - groupOffset, - sizeBytes: weightsBytes - }); - }; - - if (weightNames != null) { - weightNames.forEach((weightName, weightIndex) => { - if (weightName === weightsEntry.name) { - enqueueWeightsForFetchingFn(); - weightsFound[weightIndex] = true; - } - }); - } else { - enqueueWeightsForFetchingFn(); - } - - allManifestWeightNames.push(weightsEntry.name); - groupOffset += weightsBytes; - }); - }); - - if (!weightsFound.every(found => found)) { - const weightsNotFound = weightNames.filter((_, i) => !weightsFound[i]); - throw new Error( - `Could not find weights in manifest with names: ` + - `${weightsNotFound.join(', ')}. \n` + - `Manifest JSON has weights with names: ` + - `${allManifestWeightNames.join(', ')}.`); - } - - // Convert the one-hot boolean groupId => shouldFetch map to a list of group - // IDs. - const groupIndicesToFetch = - groupIndicesToFetchMap.reduce((accumulator, shouldFetch, i) => { - if (shouldFetch) { - accumulator.push(i); - } - return accumulator; - }, []); - - const fetchUrls: string[] = []; - groupIndicesToFetch.forEach(i => { - manifest[i].paths.forEach(filepath => { - const fetchUrl = filePathPrefix + - (!filePathPrefix.endsWith('/') ? '/' : '') + filepath; - fetchUrls.push(fetchUrl); - }); - }); - const buffers = await fetchWeightsFunction(fetchUrls); - - const weightsTensorMap: NamedTensorMap = {}; - let bufferIndexOffset = 0; - groupIndicesToFetch.forEach(i => { - const numBuffers = manifest[i].paths.length; - - const weightsBuffer = new CompositeArrayBuffer( - buffers.slice(bufferIndexOffset, bufferIndexOffset + numBuffers)); - - const weightsEntries = groupWeightsToFetch[i]; - - weightsEntries.forEach(weightsEntry => { - const byteBuffer = weightsBuffer.slice( - weightsEntry.groupOffset, - weightsEntry.groupOffset + weightsEntry.sizeBytes); - const nameToTensorMap = - decodeWeights(byteBuffer, [weightsEntry.manifestEntry]); - for (const name in nameToTensorMap) { - weightsTensorMap[name] = nameToTensorMap[name]; - } - }); - - bufferIndexOffset += numBuffers; - }); - - return weightsTensorMap; - }; -} diff --git a/tfjs-master/tfjs-core/src/io/weights_loader_test.ts b/tfjs-master/tfjs-core/src/io/weights_loader_test.ts deleted file mode 100644 index 69a00607d..000000000 --- a/tfjs-master/tfjs-core/src/io/weights_loader_test.ts +++ /dev/null @@ -1,543 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import * as tf from '../index'; -import {BROWSER_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose, expectArraysEqual} from '../test_util'; -import {WeightsManifestConfig} from './types'; - -describeWithFlags('loadWeights', BROWSER_ENVS, () => { - const setupFakeWeightFiles = (fileBufferMap: { - [filename: string]: Float32Array|Int32Array|ArrayBuffer|Uint8Array| - Uint16Array - }) => { - spyOn(tf.env().platform, 'fetch').and.callFake(async (path: string) => { - return new Response( - fileBufferMap[path], - {headers: {'Content-type': 'application/octet-stream'}}); - }); - }; - - it('1 group, 1 weight, 1 requested weight', async () => { - setupFakeWeightFiles({'./weightfile0': new Float32Array([1, 2, 3])}); - - const manifest: WeightsManifestConfig = [{ - 'paths': ['weightfile0'], - 'weights': [{'name': 'weight0', 'dtype': 'float32', 'shape': [3]}] - }]; - - const weightsNamesToFetch = ['weight0']; - const weights = - await tf.io.loadWeights(manifest, './', weightsNamesToFetch); - expect((tf.env().platform.fetch as jasmine.Spy).calls.count()).toBe(1); - - const weightNames = Object.keys(weights); - expect(weightNames.length).toEqual(weightsNamesToFetch.length); - - const weight0 = weights['weight0']; - expectArraysClose(await weight0.data(), [1, 2, 3]); - expect(weight0.shape).toEqual([3]); - expect(weight0.dtype).toEqual('float32'); - }); - - it('1 group, 2 weights, fetch 1st weight', async () => { - setupFakeWeightFiles({'./weightfile0': new Float32Array([1, 2, 3, 4, 5])}); - - const manifest: WeightsManifestConfig = [{ - 'paths': ['weightfile0'], - 'weights': [ - {'name': 'weight0', 'dtype': 'float32', 'shape': [2]}, - {'name': 'weight1', 'dtype': 'float32', 'shape': [3]} - ] - }]; - - // Load the first weight. - const weights = await tf.io.loadWeights(manifest, './', ['weight0']); - expect((tf.env().platform.fetch as jasmine.Spy).calls.count()).toBe(1); - - const weightNames = Object.keys(weights); - expect(weightNames.length).toEqual(1); - - const weight0 = weights['weight0']; - expectArraysClose(await weight0.data(), [1, 2]); - expect(weight0.shape).toEqual([2]); - expect(weight0.dtype).toEqual('float32'); - }); - - it('1 group, 2 weights, fetch 2nd weight', async () => { - setupFakeWeightFiles({'./weightfile0': new Float32Array([1, 2, 3, 4, 5])}); - - const manifest: WeightsManifestConfig = [{ - 'paths': ['weightfile0'], - 'weights': [ - {'name': 'weight0', 'dtype': 'float32', 'shape': [2]}, - {'name': 'weight1', 'dtype': 'float32', 'shape': [3]} - ] - }]; - - // Load the second weight. - const weights = await tf.io.loadWeights(manifest, './', ['weight1']); - expect((tf.env().platform.fetch as jasmine.Spy).calls.count()).toBe(1); - - const weightNames = Object.keys(weights); - expect(weightNames.length).toEqual(1); - - const weight1 = weights['weight1']; - expectArraysClose(await weight1.data(), [3, 4, 5]); - expect(weight1.shape).toEqual([3]); - expect(weight1.dtype).toEqual('float32'); - }); - - it('1 group, 2 weights, fetch all weights', async () => { - setupFakeWeightFiles({'./weightfile0': new Float32Array([1, 2, 3, 4, 5])}); - - const manifest: WeightsManifestConfig = [{ - 'paths': ['weightfile0'], - 'weights': [ - {'name': 'weight0', 'dtype': 'float32', 'shape': [2]}, - {'name': 'weight1', 'dtype': 'float32', 'shape': [3]} - ] - }]; - - // Load all weights. - const weights = - await tf.io.loadWeights(manifest, './', ['weight0', 'weight1']); - expect((tf.env().platform.fetch as jasmine.Spy).calls.count()).toBe(1); - - const weightNames = Object.keys(weights); - expect(weightNames.length).toEqual(2); - - const weight0 = weights['weight0']; - expectArraysClose(await weight0.data(), [1, 2]); - expect(weight0.shape).toEqual([2]); - expect(weight0.dtype).toEqual('float32'); - - const weight1 = weights['weight1']; - expectArraysClose(await weight1.data(), [3, 4, 5]); - expect(weight1.shape).toEqual([3]); - expect(weight1.dtype).toEqual('float32'); - }); - - it('1 group, multiple weights, different dtypes', async () => { - const buffer = new ArrayBuffer(5 * 4 + 1); - const view = new DataView(buffer); - view.setInt32(0, 1, true); - view.setInt32(4, 2, true); - view.setUint8(8, 1); - view.setFloat32(9, 3., true); - view.setFloat32(13, 4., true); - view.setFloat32(17, 5., true); - setupFakeWeightFiles({'./weightfile0': buffer}); - - const manifest: WeightsManifestConfig = [{ - 'paths': ['weightfile0'], - 'weights': [ - {'name': 'weight0', 'dtype': 'int32', 'shape': [2]}, - {'name': 'weight1', 'dtype': 'bool', 'shape': []}, - {'name': 'weight2', 'dtype': 'float32', 'shape': [3]}, - ] - }]; - - // Load all weights. - const weights = await tf.io.loadWeights( - manifest, './', ['weight0', 'weight1', 'weight2']); - expect((tf.env().platform.fetch as jasmine.Spy).calls.count()).toBe(1); - - const weightNames = Object.keys(weights); - expect(weightNames.length).toEqual(3); - - const weight0 = weights['weight0']; - expectArraysClose(await weight0.data(), [1, 2]); - expect(weight0.shape).toEqual([2]); - expect(weight0.dtype).toEqual('int32'); - - const weight1 = weights['weight1']; - expectArraysClose(await weight1.data(), [1]); - expect(weight1.shape).toEqual([]); - expect(weight1.dtype).toEqual('bool'); - - const weight2 = weights['weight2']; - expectArraysClose(await weight2.data(), [3, 4, 5]); - expect(weight2.shape).toEqual([3]); - expect(weight2.dtype).toEqual('float32'); - }); - - it('1 group, sharded 1 weight across multiple files', async () => { - const shard0 = new Float32Array([1, 2, 3, 4, 5]); - const shard1 = new Float32Array([1.1, 2.2]); - const shard2 = new Float32Array([10, 20, 30]); - - setupFakeWeightFiles({ - './weightfile0': shard0, - './weightsfile1': shard1, - './weightsfile2': shard2 - }); - - const manifest: WeightsManifestConfig = [{ - 'paths': ['weightfile0', 'weightsfile1', 'weightsfile2'], - 'weights': [{'name': 'weight0', 'dtype': 'float32', 'shape': [5, 2]}] - }]; - - const weights = await tf.io.loadWeights(manifest, './', ['weight0']); - expect((tf.env().platform.fetch as jasmine.Spy).calls.count()).toBe(3); - - const weightNames = Object.keys(weights); - expect(weightNames.length).toEqual(1); - - const weight0 = weights['weight0']; - expectArraysClose( - await weight0.data(), [1, 2, 3, 4, 5, 1.1, 2.2, 10, 20, 30]); - expect(weight0.shape).toEqual([5, 2]); - expect(weight0.dtype).toEqual('float32'); - }); - - it('1 group, sharded 2 weights across multiple files', async () => { - const shard0 = new Int32Array([1, 2, 3, 4, 5]); - - // shard1 contains part of the first weight and part of the second. - const shard1 = new ArrayBuffer(5 * 4); - const intBuffer = new Int32Array(shard1, 0, 2); - intBuffer.set([10, 20]); - const floatBuffer = new Float32Array(shard1, intBuffer.byteLength, 3); - floatBuffer.set([3.0, 4.0, 5.0]); - - const shard2 = new Float32Array([10, 20, 30]); - - setupFakeWeightFiles({ - './weightfile0': shard0, - './weightsfile1': shard1, - './weightsfile2': shard2 - }); - - const manifest: WeightsManifestConfig = [{ - 'paths': ['weightfile0', 'weightsfile1', 'weightsfile2'], - 'weights': [ - {'name': 'weight0', 'dtype': 'int32', 'shape': [7, 1]}, - {'name': 'weight1', 'dtype': 'float32', 'shape': [3, 2]} - ] - }]; - - const weights = - await tf.io.loadWeights(manifest, './', ['weight0', 'weight1']); - expect((tf.env().platform.fetch as jasmine.Spy).calls.count()).toBe(3); - - const weightNames = Object.keys(weights); - expect(weightNames.length).toEqual(2); - - const weight0 = weights['weight0']; - expectArraysClose(await weight0.data(), [1, 2, 3, 4, 5, 10, 20]); - expect(weight0.shape).toEqual([7, 1]); - expect(weight0.dtype).toEqual('int32'); - - const weight1 = weights['weight1']; - expectArraysClose(await weight1.data(), [3.0, 4.0, 5.0, 10, 20, 30]); - expect(weight1.shape).toEqual([3, 2]); - expect(weight1.dtype).toEqual('float32'); - }); - - it('2 group, 4 weights, fetches one group', async () => { - setupFakeWeightFiles({ - './weightfile0': new Float32Array([1, 2, 3, 4, 5]), - './weightfile1': new Float32Array([6, 7, 8, 9]) - }); - - const manifest: WeightsManifestConfig = [ - { - 'paths': ['weightfile0'], - 'weights': [ - {'name': 'weight0', 'dtype': 'float32', 'shape': [2]}, - {'name': 'weight1', 'dtype': 'float32', 'shape': [3]} - ] - }, - { - 'paths': ['weightfile1'], - 'weights': [ - {'name': 'weight2', 'dtype': 'float32', 'shape': [3, 1]}, - {'name': 'weight3', 'dtype': 'float32', 'shape': []} - ] - } - ]; - - const weights = - await tf.io.loadWeights(manifest, './', ['weight0', 'weight1']); - // Only the first group should be fetched. - expect((tf.env().platform.fetch as jasmine.Spy).calls.count()).toBe(1); - - const weightNames = Object.keys(weights); - expect(weightNames.length).toEqual(2); - - const weight0 = weights['weight0']; - expectArraysClose(await weight0.data(), [1, 2]); - expect(weight0.shape).toEqual([2]); - expect(weight0.dtype).toEqual('float32'); - - const weight1 = weights['weight1']; - expectArraysClose(await weight1.data(), [3, 4, 5]); - expect(weight1.shape).toEqual([3]); - expect(weight1.dtype).toEqual('float32'); - }); - - it('2 group, 4 weights, one weight from each group', async () => { - setupFakeWeightFiles({ - './weightfile0': new Float32Array([1, 2, 3, 4, 5]), - './weightfile1': new Float32Array([6, 7, 8, 9]) - }); - - const manifest: WeightsManifestConfig = [ - { - 'paths': ['weightfile0'], - 'weights': [ - {'name': 'weight0', 'dtype': 'float32', 'shape': [2]}, - {'name': 'weight1', 'dtype': 'float32', 'shape': [3]} - ] - }, - { - 'paths': ['weightfile1'], - 'weights': [ - {'name': 'weight2', 'dtype': 'float32', 'shape': [3, 1]}, - {'name': 'weight3', 'dtype': 'float32', 'shape': []} - ] - } - ]; - - const weights = - await tf.io.loadWeights(manifest, './', ['weight0', 'weight2']); - // Both groups need to be fetched. - expect((tf.env().platform.fetch as jasmine.Spy).calls.count()).toBe(2); - - const weightNames = Object.keys(weights); - expect(weightNames.length).toEqual(2); - - const weight0 = weights['weight0']; - expectArraysClose(await weight0.data(), [1, 2]); - expect(weight0.shape).toEqual([2]); - expect(weight0.dtype).toEqual('float32'); - - const weight2 = weights['weight2']; - expectArraysClose(await weight2.data(), [6, 7, 8]); - expect(weight2.shape).toEqual([3, 1]); - expect(weight2.dtype).toEqual('float32'); - }); - - it('2 group, 4 weights, dont specify weights fetchs all', async () => { - setupFakeWeightFiles({ - './weightfile0': new Float32Array([1, 2, 3, 4, 5]), - './weightfile1': new Float32Array([6, 7, 8, 9]) - }); - - const manifest: WeightsManifestConfig = [ - { - 'paths': ['weightfile0'], - 'weights': [ - {'name': 'weight0', 'dtype': 'float32', 'shape': [2]}, - {'name': 'weight1', 'dtype': 'float32', 'shape': [3]} - ] - }, - { - 'paths': ['weightfile1'], - 'weights': [ - {'name': 'weight2', 'dtype': 'float32', 'shape': [3, 1]}, - {'name': 'weight3', 'dtype': 'float32', 'shape': []} - ] - } - ]; - - // Don't pass a third argument to loadWeights to load all weights. - const weights = await tf.io.loadWeights(manifest, './'); - // Both groups need to be fetched. - expect((tf.env().platform.fetch as jasmine.Spy).calls.count()).toBe(2); - - const weightNames = Object.keys(weights); - expect(weightNames.length).toEqual(4); - - const weight0 = weights['weight0']; - expectArraysClose(await weight0.data(), [1, 2]); - expect(weight0.shape).toEqual([2]); - expect(weight0.dtype).toEqual('float32'); - - const weight1 = weights['weight1']; - expectArraysClose(await weight1.data(), [3, 4, 5]); - expect(weight1.shape).toEqual([3]); - expect(weight1.dtype).toEqual('float32'); - - const weight2 = weights['weight2']; - expectArraysClose(await weight2.data(), [6, 7, 8]); - expect(weight2.shape).toEqual([3, 1]); - expect(weight2.dtype).toEqual('float32'); - - const weight3 = weights['weight3']; - expectArraysClose(await weight3.data(), [9]); - expect(weight3.shape).toEqual([]); - expect(weight3.dtype).toEqual('float32'); - }); - - it('throws if requested weight not found', async () => { - setupFakeWeightFiles({'./weightfile0': new Float32Array([1, 2, 3])}); - - const manifest: WeightsManifestConfig = [{ - 'paths': ['weightfile0'], - 'weights': [{'name': 'weight0', 'dtype': 'float32', 'shape': [3]}] - }]; - - const weightsNamesToFetch = ['doesntexist']; - try { - await tf.io.loadWeights(manifest, './', weightsNamesToFetch); - fail(); - } catch (e) { - expect(e.message).toContain('Could not find weights'); - } - }); - - it('throws if requested weight has unknown dtype', async () => { - setupFakeWeightFiles({'./weightfile0': new Float32Array([1, 2, 3])}); - const manifest: WeightsManifestConfig = [{ - 'paths': ['weightfile0'], - 'weights': [{ - 'name': 'weight0', - // tslint:disable-next-line:no-any - 'dtype': 'null' as any, - 'shape': [3] - }] - }]; - - const weightsNamesToFetch = ['weight0']; - try { - await tf.io.loadWeights(manifest, './', weightsNamesToFetch); - fail(); - } catch (e) { - expect(e.message).toContain('Unsupported dtype'); - } - }); - - it('should use request option', async () => { - setupFakeWeightFiles({'./weightfile0': new Float32Array([1, 2, 3])}); - - const manifest: WeightsManifestConfig = [{ - 'paths': ['weightfile0'], - 'weights': [{'name': 'weight0', 'dtype': 'float32', 'shape': [3]}] - }]; - - const weightsNamesToFetch = ['weight0']; - await tf.io.loadWeights( - manifest, './', weightsNamesToFetch, {credentials: 'include'}); - expect((tf.env().platform.fetch as jasmine.Spy).calls.count()).toBe(1); - expect(tf.env().platform.fetch) - .toHaveBeenCalledWith( - './weightfile0', {credentials: 'include'}, {isBinary: true}); - }); - - const quantizationTest = async (quantizationDtype: 'uint8'|'uint16') => { - const arrayType = quantizationDtype === 'uint8' ? Uint8Array : Uint16Array; - setupFakeWeightFiles( - {'./weightfile0': new arrayType([0, 48, 255, 0, 48, 255])}); - - const manifest: WeightsManifestConfig = [{ - 'paths': ['weightfile0'], - 'weights': [ - { - 'name': 'weight0', - 'dtype': 'float32', - 'shape': [3], - 'quantization': {'min': -1, 'scale': 0.1, 'dtype': quantizationDtype} - }, - { - 'name': 'weight1', - 'dtype': 'int32', - 'shape': [3], - 'quantization': {'min': -1, 'scale': 0.1, 'dtype': quantizationDtype} - } - ] - }]; - - const weightsNamesToFetch = ['weight0', 'weight1']; - const weights = - await tf.io.loadWeights(manifest, './', weightsNamesToFetch); - expect((tf.env().platform.fetch as jasmine.Spy).calls.count()).toBe(1); - - const weightNames = Object.keys(weights); - expect(weightNames.length).toEqual(weightsNamesToFetch.length); - - const weight0 = weights['weight0']; - expectArraysClose(await weight0.data(), [-1, 3.8, 24.5]); - expect(weight0.shape).toEqual([3]); - expect(weight0.dtype).toEqual('float32'); - - const weight1 = weights['weight1']; - expectArraysEqual(await weight1.data(), [-1, 4, 25]); - expect(weight1.shape).toEqual([3]); - expect(weight1.dtype).toEqual('int32'); - }; - - it('quantized weights (uint8)', async () => { - await quantizationTest('uint8'); - }); - - it('quantized weights (uint16)', async () => { - await quantizationTest('uint16'); - }); - - it('2 groups, 1 quantized, 1 unquantized', async () => { - setupFakeWeightFiles({ - './weightfile0': new Uint8Array([0, 48, 255, 0, 48, 255]), - './weightfile1': new Float32Array([6, 7, 8, 9]) - }); - - const manifest: WeightsManifestConfig = [ - { - 'paths': ['weightfile0'], - 'weights': [ - { - 'name': 'weight0', - 'dtype': 'float32', - 'shape': [3], - 'quantization': {'min': -1, 'scale': 0.1, 'dtype': 'uint8'} - }, - { - 'name': 'weight1', - 'dtype': 'int32', - 'shape': [3], - 'quantization': {'min': -1, 'scale': 0.1, 'dtype': 'uint8'} - } - ] - }, - { - 'paths': ['weightfile1'], - 'weights': [ - {'name': 'weight2', 'dtype': 'float32', 'shape': [3, 1]}, - {'name': 'weight3', 'dtype': 'float32', 'shape': []} - ] - } - ]; - - const weights = - await tf.io.loadWeights(manifest, './', ['weight0', 'weight2']); - // Both groups need to be fetched. - expect((tf.env().platform.fetch as jasmine.Spy).calls.count()).toBe(2); - - const weightNames = Object.keys(weights); - expect(weightNames.length).toEqual(2); - - const weight0 = weights['weight0']; - expectArraysClose(await weight0.data(), [-1, 3.8, 24.5]); - expect(weight0.shape).toEqual([3]); - expect(weight0.dtype).toEqual('float32'); - - const weight2 = weights['weight2']; - expectArraysClose(await weight2.data(), [6, 7, 8]); - expect(weight2.shape).toEqual([3, 1]); - expect(weight2.dtype).toEqual('float32'); - }); -}); diff --git a/tfjs-master/tfjs-core/src/jasmine_util.ts b/tfjs-master/tfjs-core/src/jasmine_util.ts deleted file mode 100644 index 19f554d18..000000000 --- a/tfjs-master/tfjs-core/src/jasmine_util.ts +++ /dev/null @@ -1,326 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// We use the pattern below (as opposed to require('jasmine') to create the -// jasmine module in order to avoid loading node specific modules which may -// be ignored in browser environments but cannot be ignored in react-native -// due to the pre-bundling of dependencies that it must do. -// tslint:disable-next-line:no-require-imports -const jasmineRequire = require('jasmine-core/lib/jasmine-core/jasmine.js'); -const jasmineCore = jasmineRequire.core(jasmineRequire); -import {KernelBackend} from './backends/backend'; -import {ENGINE} from './engine'; -import {env, Environment, Flags} from './environment'; -import {purgeLocalStorageArtifacts} from './io/local_storage'; -import {isPromise} from './util_base'; - -Error.stackTraceLimit = Infinity; -jasmineCore.DEFAULT_TIMEOUT_INTERVAL = 20000; - -export type Constraints = { - flags?: Flags, - predicate?: (testEnv: TestEnv) => boolean, -}; - -export const NODE_ENVS: Constraints = { - predicate: () => env().platformName === 'node' -}; -export const CHROME_ENVS: Constraints = { - flags: {'IS_CHROME': true} -}; -export const BROWSER_ENVS: Constraints = { - predicate: () => env().platformName === 'browser' -}; - -export const SYNC_BACKEND_ENVS: Constraints = { - predicate: (testEnv: TestEnv) => testEnv.isDataSync === true -}; - -export const HAS_WORKER = { - predicate: () => typeof (Worker) !== 'undefined' && - typeof (Blob) !== 'undefined' && typeof (URL) !== 'undefined' -}; - -export const HAS_NODE_WORKER = { - predicate: () => { - let hasWorker = true; - try { - require.resolve('worker_threads'); - } catch { - hasWorker = false; - } - return typeof (process) !== 'undefined' && hasWorker; - } -}; - -export const ALL_ENVS: Constraints = {}; - -// Tests whether the current environment satisfies the set of constraints. -export function envSatisfiesConstraints( - env: Environment, testEnv: TestEnv, constraints: Constraints): boolean { - if (constraints == null) { - return true; - } - - if (constraints.flags != null) { - for (const flagName in constraints.flags) { - const flagValue = constraints.flags[flagName]; - if (env.get(flagName) !== flagValue) { - return false; - } - } - } - if (constraints.predicate != null && !constraints.predicate(testEnv)) { - return false; - } - return true; -} - -export interface TestFilter { - include?: string; - startsWith?: string; - excludes?: string[]; -} - -/** - * Add test filtering logic to Jasmine's specFilter hook. - * - * @param testFilters Used for include a test suite, with the ability - * to selectively exclude some of the tests. - * Either `include` or `startsWith` must exist for a `TestFilter`. - * Tests that have the substrings specified by the include or startsWith - * will be included in the test run, unless one of the substrings specified - * by `excludes` appears in the name. - * @param customInclude Function to programatically include a test. - * If this function returns true, a test will immediately run. Otherwise, - * `testFilters` is used for fine-grained filtering. - * - * If a test is not handled by `testFilters` or `customInclude`, the test will - * be excluded in the test run. - */ -export function setupTestFilters( - testFilters: TestFilter[], customInclude: (name: string) => boolean) { - const env = jasmine.getEnv(); - - // Account for --grep flag passed to karma by saving the existing specFilter. - const config = env.configuration(); - const grepFilter = config.specFilter; - - /** - * Filter method that returns boolean, if a given test should run or be - * ignored based on its name. The exclude list has priority over the - * include list. Thus, if a test matches both the exclude and the include - * list, it will be exluded. - */ - // tslint:disable-next-line: no-any - const specFilter = (spec: any) => { - // Filter out tests if the --grep flag is passed. - if (!grepFilter(spec)) { - return false; - } - - const name = spec.getFullName(); - - if (customInclude(name)) { - return true; - } - - // Include tests of a test suite unless tests are in excludes list. - for (let i = 0; i < testFilters.length; ++i) { - const testFilter = testFilters[i]; - if ((testFilter.include != null && - name.indexOf(testFilter.include) > -1) || - (testFilter.startsWith != null && - name.startsWith(testFilter.startsWith))) { - if (testFilter.excludes != null) { - for (let j = 0; j < testFilter.excludes.length; j++) { - if (name.indexOf(testFilter.excludes[j]) > -1) { - return false; - } - } - } - return true; - } - } - - // Otherwise ignore the test. - return false; - }; - - env.configure({...config, specFilter}); -} - -export function parseTestEnvFromKarmaFlags( - args: string[], registeredTestEnvs: TestEnv[]): TestEnv { - let flags: Flags; - let testEnvName: string; - - args.forEach((arg, i) => { - if (arg === '--flags') { - flags = JSON.parse(args[i + 1]); - } else if (arg === '--testEnv') { - testEnvName = args[i + 1]; - } - }); - - const testEnvNames = registeredTestEnvs.map(env => env.name).join(', '); - if (flags != null && testEnvName == null) { - throw new Error( - '--testEnv flag is required when --flags is present. ' + - `Available values are [${testEnvNames}].`); - } - if (testEnvName == null) { - return null; - } - - let testEnv: TestEnv; - registeredTestEnvs.forEach(env => { - if (env.name === testEnvName) { - testEnv = env; - } - }); - if (testEnv == null) { - throw new Error( - `Test environment with name ${testEnvName} not ` + - `found. Available test environment names are ` + - `${testEnvNames}`); - } - if (flags != null) { - testEnv.flags = flags; - } - - return testEnv; -} - -export function describeWithFlags( - name: string, constraints: Constraints, tests: (env: TestEnv) => void) { - if (TEST_ENVS.length === 0) { - throw new Error( - `Found no test environments. This is likely due to test environment ` + - `registries never being imported or test environment registries ` + - `being registered too late.`); - } - - TEST_ENVS.forEach(testEnv => { - env().setFlags(testEnv.flags); - env().set('IS_TEST', true); - if (envSatisfiesConstraints(env(), testEnv, constraints)) { - const testName = - name + ' ' + testEnv.name + ' ' + JSON.stringify(testEnv.flags || {}); - executeTests(testName, tests, testEnv); - } - }); -} - -export interface TestEnv { - name: string; - backendName: string; - flags?: Flags; - isDataSync?: boolean; -} - -export const TEST_ENVS: TestEnv[] = []; - -// Whether a call to setTestEnvs has been called so we turn off -// registration. This allows command line overriding or programmatic -// overriding of the default registrations. -let testEnvSet = false; -export function setTestEnvs(testEnvs: TestEnv[]) { - testEnvSet = true; - TEST_ENVS.length = 0; - TEST_ENVS.push(...testEnvs); -} - -export function registerTestEnv(testEnv: TestEnv) { - // When using an explicit call to setTestEnvs, turn off registration of - // test environments because the explicit call will set the test - // environments. - if (testEnvSet) { - return; - } - TEST_ENVS.push(testEnv); -} - -function executeTests( - testName: string, tests: (env: TestEnv) => void, testEnv: TestEnv) { - describe(testName, () => { - beforeAll(async () => { - ENGINE.reset(); - if (testEnv.flags != null) { - env().setFlags(testEnv.flags); - } - env().set('IS_TEST', true); - // Await setting the new backend since it can have async init. - await ENGINE.setBackend(testEnv.backendName); - }); - - beforeEach(() => { - ENGINE.startScope(); - }); - - afterEach(() => { - ENGINE.endScope(); - ENGINE.disposeVariables(); - }); - - afterAll(() => { - ENGINE.reset(); - }); - - tests(testEnv); - }); -} - -export class TestKernelBackend extends KernelBackend { - override dispose(): void {} -} - -let lock = Promise.resolve(); - -/** - * Wraps a Jasmine spec's test function so it is run exclusively to others that - * use runWithLock. - * - * @param spec The function that runs the spec. Must return a promise or call - * `done()`. - * - */ -export function runWithLock(spec: (done?: DoneFn) => Promise| void) { - return () => { - lock = lock.then(async () => { - let done: DoneFn; - const donePromise = new Promise((resolve, reject) => { - done = (() => { - resolve(); - }) as DoneFn; - done.fail = (message?) => { - reject(message); - }; - }); - - purgeLocalStorageArtifacts(); - const result = spec(done); - - if (isPromise(result)) { - await result; - } else { - await donePromise; - } - }); - return lock; - }; -} diff --git a/tfjs-master/tfjs-core/src/jasmine_util_test.ts b/tfjs-master/tfjs-core/src/jasmine_util_test.ts deleted file mode 100644 index fe051fc41..000000000 --- a/tfjs-master/tfjs-core/src/jasmine_util_test.ts +++ /dev/null @@ -1,148 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Environment} from './environment'; -import {envSatisfiesConstraints, parseTestEnvFromKarmaFlags, TestEnv} from './jasmine_util'; - -describe('jasmine_util.envSatisfiesConstraints', () => { - it('ENV satisfies empty constraints', () => { - const env = new Environment({}); - env.setFlags({}); - - const constraints = {}; - - const backendName = 'test-backend'; - - expect( - envSatisfiesConstraints(env, {name: 'test', backendName}, constraints)) - .toBe(true); - }); - - it('ENV satisfies matching flag constraints no predicate', () => { - const env = new Environment({}); - env.setFlags({'TEST-FLAG': true}); - - const constraints = {flags: {'TEST-FLAG': true}}; - - const backendName = 'test-backend'; - - expect( - envSatisfiesConstraints(env, {name: 'test', backendName}, constraints)) - .toBe(true); - }); - - it('ENV satisfies matching flag and predicate is true', () => { - const env = new Environment({}); - env.setFlags({'TEST-FLAG': true}); - - const constraints = {flags: {'TEST-FLAG': true}, predicate: () => true}; - - const backendName = 'test-backend'; - - expect( - envSatisfiesConstraints(env, {name: 'test', backendName}, constraints)) - .toBe(true); - }); - - it('ENV doesnt satisfy flags and predicate is true', () => { - const env = new Environment({}); - env.setFlags({'TEST-FLAG': true}); - - const constraints = {flags: {'TEST-FLAG': false}, predicate: () => true}; - - const backendName = 'test-backend'; - - expect( - envSatisfiesConstraints(env, {name: 'test', backendName}, constraints)) - .toBe(false); - }); - - it('ENV satisfies flags and predicate is false', () => { - const env = new Environment({}); - env.setFlags({'TEST-FLAG': true}); - - const constraints = {flags: {'TEST-FLAG': true}, predicate: () => false}; - - const backendName = 'test-backend'; - - expect( - envSatisfiesConstraints(env, {name: 'test', backendName}, constraints)) - .toBe(false); - }); - - it('ENV doesnt satiisfy flags and predicate is false', () => { - const env = new Environment({}); - env.setFlags({'TEST-FLAG': true}); - - const constraints = {flags: {'TEST-FLAG': false}, predicate: () => false}; - - const backendName = 'test-backend'; - - expect( - envSatisfiesConstraints(env, {name: 'test', backendName}, constraints)) - .toBe(false); - }); -}); - -describe('jasmine_util.parseKarmaFlags', () => { - const registeredTestEnvs: TestEnv[] = [ - {name: 'test-env', backendName: 'test-backend', isDataSync: true, flags: {}} - ]; - - it('parse empty args', () => { - const res = parseTestEnvFromKarmaFlags([], registeredTestEnvs); - expect(res).toBeNull(); - }); - - it('--testEnv test-env --flags {"IS_NODE": true}', () => { - const res = parseTestEnvFromKarmaFlags( - ['--testEnv', 'test-env', '--flags', '{"IS_NODE": true}'], - registeredTestEnvs); - expect(res.name).toBe('test-env'); - expect(res.backendName).toBe('test-backend'); - expect(res.flags).toEqual({IS_NODE: true}); - }); - - it('"--testEnv unknown" throws error', () => { - expect( - () => parseTestEnvFromKarmaFlags( - ['--testEnv', 'unknown'], registeredTestEnvs)) - .toThrowError(); - }); - - it('"--flags {}" throws error since --testEnv is missing', () => { - expect( - () => parseTestEnvFromKarmaFlags(['--flags', '{}'], registeredTestEnvs)) - .toThrowError(); - }); - - it('"--testEnv cpu --flags" throws error since features value is missing', - () => { - expect( - () => parseTestEnvFromKarmaFlags( - ['--testEnv', 'test-env', '--flags'], registeredTestEnvs)) - .toThrowError(); - }); - - it('"--backend cpu --flags notJson" throws error', () => { - expect( - () => parseTestEnvFromKarmaFlags( - ['--testEnv', 'test-env', '--flags', 'notJson'], - registeredTestEnvs)) - .toThrowError(); - }); -}); diff --git a/tfjs-master/tfjs-core/src/kernel_names.ts b/tfjs-master/tfjs-core/src/kernel_names.ts deleted file mode 100644 index 10e7d7d1a..000000000 --- a/tfjs-master/tfjs-core/src/kernel_names.ts +++ /dev/null @@ -1,1048 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -// Allow UpperCamelCase variable names -// tslint:disable: variable-name -// Unfortunately just enabling PascalCase per file (tslint:enable: -// allow-pascal-case) doesn't work. -import {NamedTensorInfoMap} from './kernel_registry'; -import {ExplicitPadding} from './ops/conv_util'; -import {Activation} from './ops/fused_types'; -import {TensorInfo} from './tensor_info'; -import {DataType, DrawOptions, PixelData} from './types'; - -export const Abs = 'Abs'; -export type AbsInputs = UnaryInputs; - -export const Acos = 'Acos'; -export type AcosInputs = UnaryInputs; - -export const Acosh = 'Acosh'; -export type AcoshInputs = UnaryInputs; - -export const Add = 'Add'; -export type AddInputs = BinaryInputs; - -export const AddN = 'AddN'; -export type AddNInputs = TensorInfo[]; - -export const All = 'All'; -export type AllInputs = Pick; -export interface AllAttrs { - axis: number|number[]; - keepDims: boolean; -} - -export const Any = 'Any'; -export type AnyInputs = Pick; -export interface AnyAttrs { - axis: number|number[]; - keepDims: boolean; -} - -export const ArgMax = 'ArgMax'; -export type ArgMaxInputs = Pick; -export interface ArgMaxAttrs { - axis: number; -} - -export const ArgMin = 'ArgMin'; -export type ArgMinInputs = Pick; -export interface ArgMinAttrs { - axis: number; -} - -export const Asin = 'Asin'; -export type AsinInputs = UnaryInputs; - -export const Asinh = 'Asinh'; -export type AsinhInputs = UnaryInputs; - -export const Atan = 'Atan'; -export type AtanInputs = UnaryInputs; - -export const Atanh = 'Atanh'; -export type AtanhInputs = UnaryInputs; - -export const Atan2 = 'Atan2'; -export type Atan2Inputs = BinaryInputs; - -export const AvgPool = 'AvgPool'; -export type AvgPoolInputs = Pick; -export interface AvgPoolAttrs { - filterSize: [number, number]|number; - strides: [number, number]|number; - pad: 'valid'|'same'|number|ExplicitPadding; - dimRoundingMode?: 'floor'|'round'|'ceil'; -} - -export const AvgPoolGrad = 'AvgPoolGrad'; -export type AvgPoolGradInputs = Pick; -export interface AvgPoolGradAttrs { - filterSize: [number, number]|number; - strides: [number, number]|number; - pad: 'valid'|'same'|number|ExplicitPadding; -} - -export const AvgPool3D = 'AvgPool3D'; -export type AvgPool3DInputs = Pick; -export interface AvgPool3DAttrs { - filterSize: [number, number, number]|number; - strides: [number, number, number]|number; - pad: 'valid'|'same'|number; - dimRoundingMode?: 'floor'|'round'|'ceil'; - dataFormat: 'NDHWC'|'NCDHW'; -} - -export const AvgPool3DGrad = 'AvgPool3DGrad'; -export type AvgPool3DGradInputs = Pick; -export interface AvgPool3DGradAttrs { - filterSize: [number, number, number]|number; - strides: [number, number, number]|number; - pad: 'valid'|'same'|number; - dimRoundingMode?: 'floor'|'round'|'ceil'; -} - -export const BatchMatMul = 'BatchMatMul'; -export type BatchMatMulInputs = Pick; -export interface BatchMatMulAttrs { - transposeA: boolean; - transposeB: boolean; -} - -export const BatchToSpaceND = 'BatchToSpaceND'; -export type BatchToSpaceNDInputs = Pick; -export interface BatchToSpaceNDAttrs { - blockShape: number[]; - crops: number[][]; -} - -export type BinaryInputs = Pick; - -export const Bincount = 'Bincount'; -export type BincountInputs = Pick; -export interface BincountAttrs { - size: number; -} - -export const BitwiseAnd = 'BitwiseAnd'; -export type BitwiseAndInputs = BinaryInputs; - -export const BroadcastTo = 'BroadcastTo'; -export type BroadcastToInputs = Pick; -export interface BroadCastToAttrs { - shape: number[]; - inputShape: number[]; // for gradient -} - -export const BroadcastArgs = 'BroadcastArgs'; -export type BroadcastArgsInputs = Pick; - -export const Cast = 'Cast'; -export type CastInputs = UnaryInputs; -export interface CastAttrs { - dtype: DataType; -} - -export const Ceil = 'Ceil'; -export type CeilInputs = UnaryInputs; - -export const ClipByValue = 'ClipByValue'; -export type ClipByValueInputs = UnaryInputs; -export interface ClipByValueAttrs { - clipValueMin: number; - clipValueMax: number; -} - -export const Complex = 'Complex'; -export type ComplexInputs = Pick; - -export const ComplexAbs = 'ComplexAbs'; -export type ComplexAbsInputs = UnaryInputs; - -export const Concat = 'Concat'; -export type ConcatInputs = TensorInfo[]; -export interface ConcatAttrs { - axis: number; -} - -export const Conv2D = 'Conv2D'; -export type Conv2DInputs = Pick; -export interface Conv2DAttrs { - strides: [number, number]|number; - pad: 'valid'|'same'|number|ExplicitPadding; - dataFormat: 'NHWC'|'NCHW'; - dilations: [number, number]|number; - dimRoundingMode?: 'floor'|'round'|'ceil'; -} - -export const Conv2DBackpropFilter = 'Conv2DBackpropFilter'; -export type Conv2DBackpropFilterInputs = Pick; -export interface Conv2DBackpropFilterAttrs { - strides: [number, number]|number; - pad: 'valid'|'same'|number|ExplicitPadding; - dataFormat: 'NHWC'|'NCHW'; - dimRoundingMode?: 'floor'|'round'|'ceil'; - filterShape: [number, number, number, number]; -} - -export const Conv2DBackpropInput = 'Conv2DBackpropInput'; -export type Conv2DBackpropInputInputs = Pick; -export interface Conv2DBackpropInputAttrs { - strides: [number, number]|number; - pad: 'valid'|'same'|number|ExplicitPadding; - dataFormat: 'NHWC'|'NCHW'; - dimRoundingMode?: 'floor'|'round'|'ceil'; - inputShape: [number, number, number, number]; -} - -export const Conv3D = 'Conv3D'; -export type Conv3DInputs = Pick; -export interface Conv3DAttrs { - strides: [number, number, number]|number; - pad: 'valid'|'same'; - dataFormat: 'NDHWC'|'NCDHW'; - dilations: [number, number, number]|number; -} - -export const Conv3DBackpropFilterV2 = 'Conv3DBackpropFilterV2'; -export type Conv3DBackpropFilterV2Inputs = Pick; - -export interface Conv3DBackpropFilterV2Attrs { - strides: [number, number, number]|number; - pad: 'valid'|'same'; - filterShape: [number, number, number, number, number]; -} - -export const Conv3DBackpropInputV2 = 'Conv3DBackpropInputV2'; -export type Conv3DBackpropInputV2Inputs = - Pick; -export interface Conv3DBackpropInputV2Attrs { - strides: [number, number, number]|number; - pad: 'valid'|'same'; - inputShape: [number, number, number, number, number]; -} - -export const Cos = 'Cos'; -export type CosInputs = UnaryInputs; - -export const Cosh = 'Cosh'; -export type CoshInputs = UnaryInputs; - -export const Cumprod = 'Cumprod'; -export type CumprodInputs = Pick; -export interface CumprodAttrs { - axis: number; - exclusive: boolean; - reverse: boolean; -} - -export const Cumsum = 'Cumsum'; -export type CumsumInputs = Pick; -export interface CumsumAttrs { - axis: number; - exclusive: boolean; - reverse: boolean; -} - -export const CropAndResize = 'CropAndResize'; -export type CropAndResizeInputs = - Pick; -export interface CropAndResizeAttrs { - cropSize: [number, number]; - method: 'bilinear'|'nearest'; - extrapolationValue: number; -} - -export const DenseBincount = 'DenseBincount'; -export type DenseBincountInputs = Pick; -export interface DenseBincountAttrs { - size: number; - binaryOutput?: boolean; -} - -export const DepthToSpace = 'DepthToSpace'; -export type DepthToSpaceInputs = Pick; -export interface DepthToSpaceAttrs { - blockSize: number; - dataFormat: 'NHWC'|'NCHW'; -} - -export const DepthwiseConv2dNative = 'DepthwiseConv2dNative'; -export type DepthwiseConv2dNativeInputs = - Pick; -export interface DepthwiseConv2dNativeAttrs { - strides: [number, number]|number; - pad: 'valid'|'same'|number|ExplicitPadding; - dataFormat: 'NHWC'|'NCHW'; - dilations: [number, number]|number; - dimRoundingMode?: 'floor'|'round'|'ceil'; -} - -export const DepthwiseConv2dNativeBackpropFilter = - 'DepthwiseConv2dNativeBackpropFilter'; -export type DepthwiseConv2dNativeBackpropFilterInputs = - Pick; -export interface DepthwiseConv2dNativeBackpropFilterAttrs { - strides: [number, number]|number; - dilations: [number, number]|number; - pad: 'valid'|'same'|number|ExplicitPadding; - dimRoundingMode?: 'floor'|'round'|'ceil'; - filterShape: [number, number, number, number]; -} - -export const DepthwiseConv2dNativeBackpropInput = - 'DepthwiseConv2dNativeBackpropInput'; -export type DepthwiseConv2dNativeBackpropInputInputs = - Pick; -export interface DepthwiseConv2dNativeBackpropInputAttrs { - strides: [number, number]|number; - dilations: [number, number]|number; - pad: 'valid'|'same'|number|ExplicitPadding; - dimRoundingMode?: 'floor'|'round'|'ceil'; - inputShape: [number, number, number, number]; -} - -export const Diag = 'Diag'; -export type DiagInputs = Pick; - -export const Dilation2D = 'Dilation2D'; -export type Dilation2DInputs = Pick; -export interface Dilation2DAttrs { - strides: [number, number]|number; - pad: 'valid'|'same'|number; - dilations: [number, number]|number; -} - -export const Dilation2DBackpropInput = 'Dilation2DBackpropInput'; -export type Dilation2DBackpropInputInputs = - Pick; - -export const Dilation2DBackpropFilter = 'Dilation2DBackpropFilter'; -export type Dilation2DBackpropFilterInputs = - Pick; - -export const Draw = 'Draw'; -export type DrawInputs = Pick; -export interface DrawAttrs { - canvas: HTMLCanvasElement; - options?: DrawOptions; -} - -export const RealDiv = 'RealDiv'; -export type RealDivInputs = BinaryInputs; - -export const Einsum = 'Einsum'; -export type EinsumInputs = TensorInfo[]; -export interface EinsumAttrs { - equation: string; -} - -export const Elu = 'Elu'; -export type EluInputs = Pick; - -export const EluGrad = 'EluGrad'; -export type EluGradInputs = Pick; - -export const Erf = 'Erf'; -export type ErfInputs = UnaryInputs; - -export const Equal = 'Equal'; -export type EqualInputs = BinaryInputs; - -export const Exp = 'Exp'; -export type ExpInputs = UnaryInputs; - -export const ExpandDims = 'ExpandDims'; -export type ExpandDimsInputs = Pick; -export interface ExpandDimsAttrs { - dim: number; -} - -export const Expm1 = 'Expm1'; -export type Expm1Inputs = UnaryInputs; - -export const FFT = 'FFT'; -export type FFTInputs = Pick; - -export const Fill = 'Fill'; -export interface FillAttrs { - shape: number[]; - value: number|string; - dtype: DataType; -} - -export const FlipLeftRight = 'FlipLeftRight'; -export type FlipLeftRightInputs = Pick; - -export const Floor = 'Floor'; -export type FloorInputs = UnaryInputs; - -export const FloorDiv = 'FloorDiv'; -export type FloorDivInputs = BinaryInputs; - -export const FusedBatchNorm = 'FusedBatchNorm'; -export type FusedBatchNormInputs = - Pick; -export interface FusedBatchNormAttrs { - varianceEpsilon: number; -} - -export const GatherV2 = 'GatherV2'; -export type GatherV2Inputs = Pick; -export interface GatherV2Attrs { - axis: number; - batchDims: number; -} - -export const GatherNd = 'GatherNd'; -export type GatherNdInputs = Pick; - -export const Greater = 'Greater'; -export type GreaterInputs = BinaryInputs; - -export const GreaterEqual = 'GreaterEqual'; -export type GreaterEqualInputs = BinaryInputs; - -export const Identity = 'Identity'; -export type IdentityInputs = Pick; - -export const IFFT = 'IFFT'; -export type IFFTInputs = Pick; - -export const Imag = 'Imag'; -export type ImagInputs = Pick; - -export const IsFinite = 'IsFinite'; -export type IsFiniteInputs = UnaryInputs; - -export const IsInf = 'IsInf'; -export type IsInfInputs = UnaryInputs; - -export const IsNan = 'IsNan'; -export type IsNanInputs = UnaryInputs; - -export const LeakyRelu = 'LeakyRelu'; -export type LeakyReluInputs = Pick; -export interface LeakyReluAttrs { - alpha: number; -} - -export const Less = 'Less'; -export type LessInputs = BinaryInputs; - -export const LessEqual = 'LessEqual'; -export type LessEqualInputs = BinaryInputs; - -export const LinSpace = 'LinSpace'; -export interface LinSpaceAttrs { - start: number; - stop: number; - num: number; -} -export const Log = 'Log'; -export type LogInputs = UnaryInputs; - -export const Log1p = 'Log1p'; -export type Log1pInputs = UnaryInputs; - -export const LogicalAnd = 'LogicalAnd'; -export type LogicalAndInputs = BinaryInputs; - -export const LogicalNot = 'LogicalNot'; -export type LogicalNotInputs = Pick; - -export const LogicalOr = 'LogicalOr'; -export type LogicalOrInputs = BinaryInputs; - -export const LogicalXor = 'LogicalXor'; -export type LogicalXorInputs = BinaryInputs; - -export const LogSoftmax = 'LogSoftmax'; -export type LogSoftmaxInputs = Pick; -export interface LogSoftmaxAttrs { - axis: number; -} - -export const LowerBound = 'LowerBound'; -export type LowerBoundInputs = - Pick; - -export const LRN = 'LRN'; -export type LRNInputs = Pick; -export interface LRNAttrs { - depthRadius: number; - bias: number; - alpha: number; - beta: number; -} - -export const LRNGrad = 'LRNGrad'; -export type LRNGradInputs = Pick; -export interface LRNGradAttrs { - depthRadius: number; - bias: number; - alpha: number; - beta: number; -} - -export const MatrixBandPart = 'MatrixBandPart'; -export type MatrixBandPartInputs = - Pick; -export interface MatrixBandPartAttrs {} - -export const Max = 'Max'; -export type MaxInputs = Pick; -export interface MaxAttrs { - reductionIndices: number|number[]; - keepDims: boolean; -} - -export const Maximum = 'Maximum'; -export type MaximumInputs = BinaryInputs; - -export const MaxPool = 'MaxPool'; -export type MaxPoolInputs = Pick; -export interface MaxPoolAttrs { - filterSize: [number, number]|number; - strides: [number, number]|number; - pad: 'valid'|'same'|number|ExplicitPadding; - dimRoundingMode?: 'floor'|'round'|'ceil'; -} - -export const MaxPoolGrad = 'MaxPoolGrad'; -export type MaxPoolGradInputs = Pick; -export interface MaxPoolGradAttrs { - filterSize: [number, number]|number; - strides: [number, number]|number; - pad: 'valid'|'same'|number|ExplicitPadding; - dimRoundingMode?: 'floor'|'round'|'ceil'; -} - -export const MaxPool3D = 'MaxPool3D'; -export type MaxPool3DInputs = Pick; -export interface MaxPool3DAttrs { - filterSize: [number, number, number]|number; - strides: [number, number, number]|number; - pad: 'valid'|'same'|number; - dataFormat: 'NDHWC'|'NCDHW'; - dimRoundingMode?: 'floor'|'round'|'ceil'; -} - -export const MaxPool3DGrad = 'MaxPool3DGrad'; -export type MaxPool3DGradInputs = - Pick; -export interface MaxPool3DGradAttrs { - filterSize: [number, number, number]|number; - strides: [number, number, number]|number; - pad: 'valid'|'same'|number; - dimRoundingMode?: 'floor'|'round'|'ceil'; -} - -export const MaxPoolWithArgmax = 'MaxPoolWithArgmax'; -export type MaxPoolWithArgmaxInputs = Pick; -export interface MaxPoolWithArgmaxAttrs { - filterSize: [number, number]|number; - strides: [number, number]|number; - pad: 'valid'|'same'|number; - includeBatchInIndex: boolean; -} - -export const Mean = 'Mean'; -export type MeanInputs = Pick; -export interface MeanAttrs { - axis: number|number[]; - keepDims: boolean; -} - -export const Min = 'Min'; -export type MinInputs = Pick; -export interface MinAttrs { - axis: number|number[]; - keepDims: boolean; -} - -export const Minimum = 'Minimum'; -export type MinimumInputs = BinaryInputs; - -export const MirrorPad = 'MirrorPad'; -export type MirrorPadInputs = Pick; -export interface MirrorPadAttrs { - paddings: Array<[number, number]>; - mode: 'reflect'|'symmetric'; -} - -export const Mod = 'Mod'; -export type ModInputs = BinaryInputs; - -export const Multinomial = 'Multinomial'; -export type MultinomialInputs = Pick; -export interface MultinomialAttrs { - numSamples: number; - seed: number; - normalized: boolean; -} - -export const Multiply = 'Multiply'; -export type MultiplyInputs = BinaryInputs; - -export const Neg = 'Neg'; -export type NegInputs = UnaryInputs; - -export const NotEqual = 'NotEqual'; -export type NotEqualInputs = BinaryInputs; - -export const NonMaxSuppressionV3 = 'NonMaxSuppressionV3'; -export type NonMaxSuppressionV3Inputs = - Pick; -export interface NonMaxSuppressionV3Attrs { - maxOutputSize: number; - iouThreshold: number; - scoreThreshold: number; -} - -export const NonMaxSuppressionV4 = 'NonMaxSuppressionV4'; -export type NonMaxSuppressionV4Inputs = - Pick; -export interface NonMaxSuppressionV4Attrs { - maxOutputSize: number; - iouThreshold: number; - scoreThreshold: number; - padToMaxOutputSize: boolean; -} - -export const NonMaxSuppressionV5 = 'NonMaxSuppressionV5'; -export type NonMaxSuppressionV5Inputs = - Pick; -export interface NonMaxSuppressionV5Attrs { - maxOutputSize: number; - iouThreshold: number; - scoreThreshold: number; - softNmsSigma: number; -} - -export const OnesLike = 'OnesLike'; -export type OnesLikeInputs = UnaryInputs; - -export const OneHot = 'OneHot'; -export type OneHotInputs = Pick; -export interface OneHotAttrs { - depth: number; - onValue: number; - offValue: number; - dtype: DataType; -} - -export const Pack = 'Pack'; -export type PackInputs = TensorInfo[]; -export interface PackAttrs { - axis: number; -} - -export const PadV2 = 'PadV2'; -export type PadV2Inputs = Pick; -export interface PadV2Attrs { - paddings: Array<[number, number]>; - constantValue: number; -} - -export const Pool = 'Pool'; -export type PoolInputs = Pick; - -export const Pow = 'Pow'; -export type PowInputs = BinaryInputs; - -export const Prelu = 'Prelu'; -export type PreluInputs = Pick; - -export const Prod = 'Prod'; -export type ProdInputs = Pick; -export interface ProdAttrs { - axis: number|number[]; - keepDims: boolean; -} - -export const RaggedGather = 'RaggedGather'; -export type RaggedGatherInputs = { - paramsNestedSplits: TensorInfo[] -}&Pick; -export interface RaggedGatherAttrs { - outputRaggedRank: number; -} - -export const RaggedRange = 'RaggedRange'; -export type RaggedRangeInputs = - Pick; - -export const RaggedTensorToTensor = 'RaggedTensorToTensor'; -export type RaggedTensorToTensorInputs = - Pick& - {rowPartitionTensors: TensorInfo[]}; -export interface RaggedTensorToTensorAttrs { - rowPartitionTypes: string[]; -} - -export const Range = 'Range'; -export interface RangeAttrs { - start: number; - stop: number; - step: number; - dtype: 'float32'|'int32'; -} - -export const Real = 'Real'; -export type RealInputs = Pick; - -export const Reciprocal = 'Reciprocal'; -export type ReciprocalInputs = UnaryInputs; - -export const Relu = 'Relu'; -export type ReluInputs = Pick; - -export const Reshape = 'Reshape'; -export type ReshapeInputs = Pick; -export interface ReshapeAttrs { - shape: number[]; -} - -export const ResizeNearestNeighbor = 'ResizeNearestNeighbor'; -export type ResizeNearestNeighborInputs = Pick; -export interface ResizeNearestNeighborAttrs { - alignCorners: boolean; - halfPixelCenters: boolean; - size: [number, number]; -} - -export const ResizeNearestNeighborGrad = 'ResizeNearestNeighborGrad'; -export type ResizeNearestNeighborGradInputs = - Pick; -export type ResizeNearestNeighborGradAttrs = ResizeNearestNeighborAttrs; - -export const ResizeBilinear = 'ResizeBilinear'; -export type ResizeBilinearInputs = Pick; -export interface ResizeBilinearAttrs { - alignCorners: boolean; - halfPixelCenters: boolean; - size: [number, number]; -} - -export const ResizeBilinearGrad = 'ResizeBilinearGrad'; -export type ResizeBilinearGradInputs = Pick; -export type ResizeBilinearGradAttrs = ResizeBilinearAttrs; - -export const Relu6 = 'Relu6'; -export type Relu6Inputs = Pick; - -export const Reverse = 'Reverse'; -export type ReverseInputs = Pick; -export interface ReverseAttrs { - dims: number|number[]; -} - -export const Round = 'Round'; -export type RoundInputs = UnaryInputs; - -export const Rsqrt = 'Rsqrt'; -export type RsqrtInputs = UnaryInputs; - -export const ScatterNd = 'ScatterNd'; -export type ScatterNdInputs = Pick; -export interface ScatterNdAttrs { - shape: number[]; -} - -export const TensorScatterUpdate = 'TensorScatterUpdate'; -export type TensorScatterUpdateInputs = - Pick; -export interface TensorScatterUpdateAttrs {} - -export const SearchSorted = 'SearchSorted'; -export type SearchSortedInputs = - Pick; -export interface SearchSortedAttrs { - side: 'left'|'right'; -} - -export const Select = 'Select'; -export type SelectInputs = Pick; - -export const Selu = 'Selu'; -export type SeluInputs = Pick; - -export const Slice = 'Slice'; -export type SliceInputs = Pick; -export interface SliceAttrs { - begin: number|number[]; - size: number|number[]; -} -export const Sin = 'Sin'; -export type SinInputs = UnaryInputs; - -export const Sinh = 'Sinh'; -export type SinhInputs = UnaryInputs; - -export const Sign = 'Sign'; -export type SignInputs = UnaryInputs; - -export const Sigmoid = 'Sigmoid'; -export type SigmoidInputs = UnaryInputs; - -export const Softplus = 'Softplus'; -export type SoftplusInputs = UnaryInputs; - -export const Sqrt = 'Sqrt'; -export type SqrtInputs = UnaryInputs; - -export const Sum = 'Sum'; -export type SumInputs = Pick; -export interface SumAttrs { - axis: number|number[]; - keepDims: boolean; -} - -export const SpaceToBatchND = 'SpaceToBatchND'; -export type SpaceToBatchNDInputs = Pick; -export interface SpaceToBatchNDAttrs { - blockShape: number[]; - paddings: number[][]; -} - -export const SplitV = 'SplitV'; -export type SplitVInputs = Pick; -export interface SplitVAttrs { - numOrSizeSplits: number[]|number; - axis: number; -} - -export const Softmax = 'Softmax'; -export type SoftmaxInputs = Pick; -export interface SoftmaxAttrs { - dim: number; -} - -export const SparseFillEmptyRows = 'SparseFillEmptyRows'; -export type SparseFillEmptyRowsInputs = - Pick; - -export const SparseReshape = 'SparseReshape'; -export type SparseReshapeInputs = - Pick; - -export const SparseSegmentMean = 'SparseSegmentMean'; -export type SparseSegmentMeanInputs = - Pick; - -export const SparseSegmentSum = 'SparseSegmentSum'; -export type SparseSegmentSumInputs = - Pick; - -export const SparseToDense = 'SparseToDense'; -export type SparseToDenseInputs = - Pick; -export interface SparseToDenseAttrs { - outputShape: number[]; -} - -export const SquaredDifference = 'SquaredDifference'; -export type SquaredDifferenceInputs = BinaryInputs; - -export const Square = 'Square'; -export type SquareInputs = Pick; - -export const StaticRegexReplace = 'StaticRegexReplace'; -export type StaticRegexReplaceInputs = UnaryInputs; -export interface StaticRegexReplaceAttrs { - pattern: string; - rewrite: string; - replaceGlobal: boolean; -} - -export const StridedSlice = 'StridedSlice'; -export type StridedSliceInputs = Pick; -export interface StridedSliceAttrs { - begin: number[]; - end: number[]; - strides: number[]; - beginMask: number; - endMask: number; - ellipsisMask: number; - newAxisMask: number; - shrinkAxisMask: number; -} - -export const StringNGrams = 'StringNGrams'; -export type StringNGramsInputs = Pick; -export interface StringNGramsAttrs { - separator: string; - nGramWidths: number[]; - leftPad: string; - rightPad: string; - padWidth: number; - preserveShortSequences: boolean; -} - -export const StringSplit = 'StringSplit'; -export type StringSplitInputs = Pick; -export interface StringSplitAttrs { - skipEmpty: boolean; -} - -export const StringToHashBucketFast = 'StringToHashBucketFast'; -export type StringToHashBucketFastInputs = Pick; -export interface StringToHashBucketFastAttrs { - numBuckets: number; -} - -export const Sub = 'Sub'; -export type SubInputs = BinaryInputs; - -export const Tan = 'Tan'; -export type TanInputs = UnaryInputs; - -export const Tanh = 'Tanh'; -export type TanhInputs = UnaryInputs; - -export const Tile = 'Tile'; -export type TileInputs = Pick; -export interface TileAttrs { - reps: number[]; -} - -export const TopK = 'TopK'; -export type TopKInputs = Pick; -export interface TopKAttrs { - k: number; - sorted: boolean; -} - -export const Transform = 'Transform'; -export type TransformInputs = Pick; -export interface TransformAttrs { - interpolation: 'nearest'|'bilinear'; - fillMode: 'constant'|'reflect'|'wrap'|'nearest'; - fillValue: number; - outputShape?: [number, number]; -} - -export const Transpose = 'Transpose'; -export type TransposeInputs = Pick; -export interface TransposeAttrs { - perm: number[]; -} - -export const Unique = 'Unique'; -export type UniqueInputs = Pick; -export interface UniqueAttrs { - axis: number; -} - -export type UnaryInputs = Pick; - -export const Unpack = 'Unpack'; -export type UnpackInputs = Pick; -export interface UnpackAttrs { - axis: number; -} - -export const UnsortedSegmentSum = 'UnsortedSegmentSum'; -export type UnsortedSegmentSumInputs = - Pick; -export interface UnsortedSegmentSumAttrs { - numSegments: number; -} - -export const UpperBound = 'UpperBound'; -export type UpperBoundInputs = - Pick; - -export const ZerosLike = 'ZerosLike'; -export type ZerosLikeInputs = UnaryInputs; - -/** - * TensorFlow.js-only kernels - */ -export const Step = 'Step'; -export type StepInputs = UnaryInputs; -export interface StepAttrs { - alpha: number; -} - -export const FromPixels = 'FromPixels'; -export interface FromPixelsInputs { - pixels: PixelData|ImageData|HTMLImageElement|HTMLCanvasElement| - HTMLVideoElement|ImageBitmap; -} -export interface FromPixelsAttrs { - numChannels: number; -} - -export const RotateWithOffset = 'RotateWithOffset'; -export type RotateWithOffsetInputs = Pick; -export interface RotateWithOffsetAttrs { - radians: number; - fillValue: number|[number, number, number]; - center: number|[number, number]; -} - -export const _FusedMatMul = '_FusedMatMul'; -// tslint:disable-next-line: class-name -export interface _FusedMatMulInputs extends NamedTensorInfoMap { - a: TensorInfo; - b: TensorInfo; - bias?: TensorInfo; - preluActivationWeights?: TensorInfo; -} -// tslint:disable-next-line: class-name -export interface _FusedMatMulAttrs { - transposeA: boolean; - transposeB: boolean; - activation: Activation; - leakyreluAlpha?: number; -} - -export const FusedConv2D = 'FusedConv2D'; -export interface FusedConv2DInputs extends NamedTensorInfoMap { - x: TensorInfo; - filter: TensorInfo; - bias?: TensorInfo; - preluActivationWeights?: TensorInfo; -} -export interface FusedConv2DAttrs { - strides: [number, number]|number; - pad: 'valid'|'same'|number|ExplicitPadding; - dataFormat: 'NHWC'|'NCHW'; - dilations: [number, number]|number; - dimRoundingMode: 'floor'|'round'|'ceil'; - activation: Activation; - leakyreluAlpha?: number; -} - -export const FusedDepthwiseConv2D = 'FusedDepthwiseConv2D'; -export interface FusedDepthwiseConv2DInputs extends NamedTensorInfoMap { - x: TensorInfo; - filter: TensorInfo; - bias?: TensorInfo; - preluActivationWeights?: TensorInfo; -} -export interface FusedDepthwiseConv2DAttrs { - strides: [number, number]|number; - pad: 'valid'|'same'|number|ExplicitPadding; - dataFormat: 'NHWC'|'NCHW'; - dilations: [number, number]|number; - dimRoundingMode: 'floor'|'round'|'ceil'; - activation: Activation; - leakyreluAlpha?: number; -} diff --git a/tfjs-master/tfjs-core/src/kernel_registry.ts b/tfjs-master/tfjs-core/src/kernel_registry.ts deleted file mode 100644 index c7284a1ce..000000000 --- a/tfjs-master/tfjs-core/src/kernel_registry.ts +++ /dev/null @@ -1,209 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {env} from './environment'; -import {getGlobal} from './global_util'; -import * as log from './log'; -import {NamedGradientMap} from './tape'; -import {Tensor} from './tensor'; -import {TensorInfo} from './tensor_info'; -import {RecursiveArray} from './types'; - -const kernelRegistry = - getGlobal('kernelRegistry', () => new Map<`${string}_${string}`, - KernelConfig>()); -const gradRegistry = - getGlobal('gradRegistry', () => new Map()); - -type AttributeValue = - number | number[] | boolean | boolean[] | string | string[] | NamedAttrMap; - -/** These are extra non-tensor/primitive params passed to kernel functions. */ -export type Attribute = AttributeValue | RecursiveArray; - -/** Specifies the code to run when executing a kernel. */ -export type KernelFunc = (params: { - inputs: NamedTensorInfoMap, - backend: {}, - attrs?: NamedAttrMap, -}) => TensorInfo | TensorInfo[]; - -/** The function to run when computing a gradient during backprop. */ -export type GradFunc = - (dy: Tensor | Tensor[], saved: Tensor[], attrs: NamedAttrMap) => - NamedGradientMap; - -/** Function that gets called after the backend initializes. */ -export type KernelSetupFunc = (backend: {}) => void; -/** Function that gets called right before the backend is disposed. */ -export type KernelDisposeFunc = KernelSetupFunc; - -/** Config object for registering a kernel in the global registry. */ -export interface KernelConfig { - kernelName: string; - backendName: string; - kernelFunc: KernelFunc; - setupFunc?: KernelSetupFunc; - disposeFunc?: KernelDisposeFunc; -} - -/** Config object for registering a gradient in the global registry. */ -export interface GradConfig { - kernelName: string; - inputsToSave?: string[]; - // When saveAllInputs is true, all inputs will be saved. Only use this flag - // if inputs is an array of Tensors. - saveAllInputs?: boolean; - outputsToSave?: boolean[]; - gradFunc: GradFunc; -} - -export interface NamedTensorInfoMap { - [name: string]: TensorInfo|undefined; -} - -export interface NamedAttrMap { - [name: string]: Attribute; -} - -/** - * Returns the kernel function (code) associated with the provided names. - * - * @param kernelName The official name of the kernel. - * @param backendName The official name of the backend. - */ -export function getKernel( - kernelName: string, backendName: string): KernelConfig { - const key = makeKey(kernelName, backendName); - return kernelRegistry.get(key); -} - -/** - * Returns the registered gradient info associated with the provided kernel. - * @param kernelName The official TF kernel name. - */ -export function getGradient(kernelName: string): GradConfig { - return gradRegistry.get(kernelName); -} - -export function getKernelsForBackend(backendName: string): KernelConfig[] { - const it = kernelRegistry.entries(); - const result: KernelConfig[] = []; - - while (true) { - const {done, value} = it.next(); - if (done) { - break; - } - const [key, config] = value; - const [backend, ] = key.split('_'); - if (backend === backendName) { - result.push(config); - } - } - return result; -} - -/** - * Registers the function (forward pass) for the kernel in a global registry. - * - * @param config A config object with the following properties: - * - `kernelName` The official name of the kernel. - * - `backendName` The official name of the backend. - * - `kernelFunc` The function to run during the forward pass of the kernel. - * - `setupFunc` Optional. Gets called once, after the backend initializes. - * - `disposeFunc` Optional. Gets called once, right before the backend is - * disposed. - */ -export function registerKernel(config: KernelConfig) { - const {kernelName, backendName} = config; - const key = makeKey(kernelName, backendName); - if (kernelRegistry.has(key)) { - log.warn( - `The kernel '${kernelName}' for backend ` + - `'${backendName}' is already registered`); - } - kernelRegistry.set(key, config); -} - -/** - * Registers a gradient function for a given kernel in the global registry, - * to be used during the back-propagation of that kernel. - * - * @param config An object with the following properties: - * - `kernelName` The name of the kernel that the gradient function is for. - * - `gradFunc` The function to run during back-propagation. - */ -export function registerGradient(config: GradConfig) { - const {kernelName} = config; - - if (gradRegistry.has(kernelName)) { - // TODO (yassogba) after 3.0 assess whether we need to keep this gated - // to debug mode. - if (env().getBool('DEBUG')) { - log.warn(`Overriding the gradient for '${kernelName}'`); - } - } - gradRegistry.set(kernelName, config); -} - -/** - * Removes the kernel function from the registry. - * - * @param kernelName The official name of the kernel. - * @param backendName The official name of the backend. - * - */ -export function unregisterKernel( - kernelName: string, backendName: string): void { - const key = makeKey(kernelName, backendName); - if (!kernelRegistry.has(key)) { - throw new Error( - `The kernel '${kernelName}' for backend ` + - `'${backendName}' is not registered`); - } - kernelRegistry.delete(key); -} - -/** Removes the registered gradient from the global registry. */ -export function unregisterGradient(kernelName: string): void { - if (!gradRegistry.has(kernelName)) { - throw new Error( - `The gradient '${kernelName}' for backend is not registered`); - } - gradRegistry.delete(kernelName); -} - -/** - * Finds kernels that have already been registered to a backend and re-registers - * them for a new backend. Useful for registering custom backends. - * @param registeredBackendName Already registered backend. - * @param newBackendName New backend. - */ -export function copyRegisteredKernels( - registeredBackendName: string, newBackendName: string): void { - const kernels = getKernelsForBackend(registeredBackendName); - kernels.forEach(kernelConfig => { - const newKernelConfig = - Object.assign({}, kernelConfig, {backendName: newBackendName}); - registerKernel(newKernelConfig); - }); -} - -function makeKey(kernelName: string, - backendName: string): `${string}_${string}` { - return `${backendName}_${kernelName}`; -} diff --git a/tfjs-master/tfjs-core/src/kernel_registry_test.ts b/tfjs-master/tfjs-core/src/kernel_registry_test.ts deleted file mode 100644 index 1f7194ae1..000000000 --- a/tfjs-master/tfjs-core/src/kernel_registry_test.ts +++ /dev/null @@ -1,411 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from './index'; -import {KernelBackend} from './index'; -import {ALL_ENVS, describeWithFlags, TestEnv} from './jasmine_util'; -import { KernelFunc } from './kernel_registry'; -import { TensorInfo } from './tensor_info'; -import {expectArraysClose} from './test_util'; - -describeWithFlags('kernel_registry', ALL_ENVS, (testEnv: TestEnv) => { - afterEach(async () => { - // Revert backend mutation. - await tf.setBackend(testEnv.backendName); - }); - - it('register a kernel and call it', () => { - // Make sure the backend is loaded. Perhaps tf.getBackend - // should call tf.backend to make sure the backend is loaded? - expect(tf.backend()).toBeDefined(); - let called = false; - tf.registerKernel({ - kernelName: 'MyKernel', - backendName: tf.getBackend(), - kernelFunc: ({inputs, attrs}) => { - expect(attrs.a).toBe(5); - expect(inputs.x.shape).toEqual([2, 2]); - expect(inputs.x.dtype).toBe('float32'); - called = true; - return {dtype: 'float32', shape: [3, 3], dataId: {}}; - } - }); - - const inputs = {x: tf.zeros([2, 2])}; - const attrs = {a: 5}; - const res = tf.engine().runKernel('MyKernel', inputs, attrs) as TensorInfo; - - expect(called).toBe(true); - expect(res.dtype).toBe('float32'); - expect(res.shape).toEqual([3, 3]); - - tf.unregisterKernel('MyKernel', tf.getBackend()); - }); - - it('errors when running non-existent kernel', () => { - const inputs = {}; - const attrs = {}; - expect(() => tf.engine().runKernel('DoesNotExist', inputs, attrs)) - .toThrowError(); - }); - - // TODO (yassogba) double registration happens now because a backend might be - // imported more than once (e.g. by a top level package and a dependent - // package). We may want to remove this test long-term but skip it for - // now. - // tslint:disable-next-line: ban - xit('errors when registering the same kernel twice', () => { - interface TestBackend extends KernelBackend { - id: number; - } - tf.registerBackend('backend1', () => { - return { - id: 1, - dispose: () => null, - disposeData: (dataId: {}) => null, - numDataIds: () => 0 - } as TestBackend; - }); - - tf.registerKernel({ - kernelName: 'MyKernel', - backendName: 'backend1', - kernelFunc: () => { - return null; - } - }); - expect(() => tf.registerKernel({ - kernelName: 'MyKernel', - backendName: 'backend1', - kernelFunc: () => { - return null; - } - })).toThrowError(); - - tf.unregisterKernel('MyKernel', 'backend1'); - tf.removeBackend('backend1'); - }); - - it('register same kernel on two different backends', async () => { - interface TestBackend extends KernelBackend { - id: number; - } - tf.registerBackend('backend1', () => { - return { - id: 1, - dispose: () => null, - disposeData: (dataId: {}) => true, - numDataIds: () => 0 - } as TestBackend; - }); - tf.registerBackend('backend2', () => { - return { - id: 2, - dispose: () => null, - disposeData: (dataId: {}) => null, - numDataIds: () => 0 - } as TestBackend; - }); - - let lastStorageId = -1; - const kernelFunc: KernelFunc = ({backend}) => { - lastStorageId = (backend as TestBackend).id; - return {dataId: {}, shape: [], dtype: 'float32'}; - }; - tf.registerKernel( - {kernelName: 'MyKernel', backendName: 'backend1', kernelFunc}); - tf.registerKernel( - {kernelName: 'MyKernel', backendName: 'backend2', kernelFunc}); - - // No kernel has been executed yet. - expect(lastStorageId).toBe(-1); - - // Kernel was executed on the first backend. - await tf.setBackend('backend1'); - tf.engine().runKernel('MyKernel', {}, {}); - expect(lastStorageId).toBe(1); - - // Kernel was executed on the second backend. - await tf.setBackend('backend2'); - tf.engine().runKernel('MyKernel', {}, {}); - expect(lastStorageId).toBe(2); - - tf.removeBackend('backend1'); - tf.removeBackend('backend2'); - tf.unregisterKernel('MyKernel', 'backend1'); - tf.unregisterKernel('MyKernel', 'backend2'); - }); - - it('register kernel with setup and dispose functions', async () => { - const backendName = 'custom-backend'; - const kernelName = 'MyKernel'; - interface TestBackend extends KernelBackend {} - const customBackend = { - dispose: () => null, - disposeData: (dataId: {}) => true, - numDataIds: () => 0 - } as TestBackend; - tf.registerBackend(backendName, () => customBackend); - - const kernelFunc: KernelFunc = () => { - return {dataId: {}, shape: [], dtype: 'float32'}; - }; - let setupCalled = false; - const setupFunc = (backend: KernelBackend) => { - expect(backend).toBe(customBackend); - setupCalled = true; - }; - let disposeCalled = false; - const disposeFunc = (backend: KernelBackend) => { - expect(backend).toBe(customBackend); - disposeCalled = true; - }; - tf.registerKernel( - {kernelName, backendName, kernelFunc, setupFunc, disposeFunc}); - - expect(setupCalled).toBe(false); - expect(disposeCalled).toBe(false); - - await tf.setBackend(backendName); - expect(setupCalled).toBe(true); - expect(disposeCalled).toBe(false); - - // Kernel was executed on the first backend. - tf.engine().runKernel(kernelName, {}, {}); - - tf.removeBackend(backendName); - expect(setupCalled).toBe(true); - expect(disposeCalled).toBe(true); - - tf.unregisterKernel(kernelName, backendName); - }); -}); - -describeWithFlags('gradient registry', ALL_ENVS, () => { - it('register a kernel with gradient and call it', async () => { - let kernelWasCalled = false; - let gradientWasCalled = false; - const kernelName = 'MyKernel'; - const x = tf.zeros([2, 2]); - - tf.registerKernel({ - kernelName, - backendName: tf.getBackend(), - kernelFunc: () => { - kernelWasCalled = true; - return {dtype: 'float32', shape: [3, 3], dataId: {}}; - } - }); - - tf.registerGradient({ - kernelName, - inputsToSave: ['x'], - gradFunc: (dy: tf.Tensor, saved) => { - // Make sure saved input (x) was passed to the gradient function. - expect(saved[0].dataId).toEqual(x.dataId); - // Make sure dy matches the shape of the output. - expect(dy.shape).toEqual([3, 3]); - gradientWasCalled = true; - return {x: () => tf.fill([2, 2], 3)}; - }, - }); - - const gradFunc = - tf.grad(x => tf.engine().runKernel(kernelName, {x}, {} /* attrs */)); - const dx = gradFunc(x); - expect(kernelWasCalled).toBe(true); - expect(gradientWasCalled).toBe(true); - expect(dx.dtype).toBe('float32'); - expect(dx.shape).toEqual([2, 2]); - expectArraysClose(await dx.data(), [3, 3, 3, 3]); - tf.unregisterKernel(kernelName, tf.getBackend()); - tf.unregisterGradient(kernelName); - }); - - it('register a kernel with gradient that specifies outputsToSave and call it', - async () => { - let kernelWasCalled = false; - let gradientWasCalled = false; - const kernelName = 'MyKernel'; - - const tensor = tf.zeros([3, 3], 'float32'); - const forwardReturnDataId = tensor.dataId; - tf.registerKernel({ - kernelName, - backendName: tf.getBackend(), - kernelFunc: () => { - kernelWasCalled = true; - return { - dtype: tensor.dtype, - shape: tensor.shape, - dataId: forwardReturnDataId - }; - } - }); - - tf.registerGradient({ - kernelName, - outputsToSave: [true], - gradFunc: (dy: tf.Tensor, saved) => { - // Make sure saved output was passed to the gradient function. - expect(saved[0].dataId).toEqual(forwardReturnDataId); - // Make sure dy matches the shape of the output. - expect(dy.shape).toEqual([3, 3]); - gradientWasCalled = true; - return {x: () => tf.fill([2, 2], 3)}; - }, - }); - - const gradFunc = tf.grad( - x => tf.engine().runKernel( - kernelName, {x}, {} /* attrs */ - )); - const x = tf.zeros([2, 2]); - const dx = gradFunc(x); - expect(kernelWasCalled).toBe(true); - expect(gradientWasCalled).toBe(true); - expect(dx.dtype).toBe('float32'); - expect(dx.shape).toEqual([2, 2]); - tf.unregisterKernel(kernelName, tf.getBackend()); - tf.unregisterGradient(kernelName); - }); - - it('register a kernel with array inputs and saveAllInputs true', async () => { - let kernelWasCalled = false; - let gradientWasCalled = false; - const kernelName = 'MyKernel'; - const x = [tf.zeros([2, 2]), tf.zeros([2, 2])]; - - const forwardReturnDataId = {}; - tf.registerKernel({ - kernelName, - backendName: tf.getBackend(), - kernelFunc: () => { - kernelWasCalled = true; - return {dtype: 'float32', shape: [3, 3], dataId: forwardReturnDataId}; - } - }); - - tf.registerGradient({ - kernelName, - saveAllInputs: true, - gradFunc: (dy: tf.Tensor, saved) => { - // Make sure saved input (x) was passed to the gradient function. - const [$x0, $x1] = x; - expect(saved.length).toEqual(x.length); - expect($x0.dataId).toEqual(x[0].dataId); - expect($x1.dataId).toEqual(x[1].dataId); - gradientWasCalled = true; - return {0: () => tf.fill([2, 2], 3), 1: () => tf.fill([2, 2], 3)}; - } - }); - - // Inputs as array. - const z = (...x: tf.Tensor[]) => - // tslint:disable-next-line: no-unnecessary-type-assertion - tf.engine().runKernel( - kernelName, x as unknown as tf.NamedTensorMap, {} /* attrs */) as - tf.Tensor; - const gradFunc = tf.grads(z); - const dx = gradFunc(x); - expect(kernelWasCalled).toBe(true); - expect(gradientWasCalled).toBe(true); - expect(dx.length).toEqual(2); - expect(dx[0].dtype).toBe('float32'); - expect(dx[0].shape).toEqual([2, 2]); - expect(dx[1].dtype).toBe('float32'); - expect(dx[1].shape).toEqual([2, 2]); - expectArraysClose(await dx[0].data(), [3, 3, 3, 3]); - expectArraysClose(await dx[1].data(), [3, 3, 3, 3]); - tf.unregisterKernel(kernelName, tf.getBackend()); - tf.unregisterGradient(kernelName); - }); - - it('register a kernel with map inputs and saveAllInputs true should throw ' + - 'error', - async () => { - const kernelName = 'MyKernel'; - const x0 = tf.zeros([2, 2]); - const x1 = tf.zeros([2, 2]); - - const forwardReturnDataId = {}; - tf.registerKernel({ - kernelName, - backendName: tf.getBackend(), - kernelFunc: () => { - return { - dtype: 'float32', - shape: [3, 3], - dataId: forwardReturnDataId - }; - } - }); - - tf.registerGradient({ - kernelName, - saveAllInputs: true, - gradFunc: (dy: tf.Tensor, saved) => { - // Make sure saved input (x) was passed to the gradient function. - const [$x0, $x1] = saved; - expect($x0.dataId).toEqual(x0.dataId); - expect($x1.dataId).toEqual(x1.dataId); - return {x0: () => tf.fill([2, 2], 3), x1: () => tf.fill([2, 2], 3)}; - } - }); - - // Inputs as map. - const z = (x0: tf.Tensor, x1: tf.Tensor) => - // tslint:disable-next-line: no-unnecessary-type-assertion - tf.engine().runKernel(kernelName, {x0, x1}, {} /* attrs */) as - tf.Tensor; - const gradFunc = tf.grads(z); - expect(() => gradFunc([x0, x1])) - .toThrowError( - /saveAllInputs is true, expected inputs to be an array/); - tf.unregisterKernel(kernelName, tf.getBackend()); - tf.unregisterGradient(kernelName); - }); - - it('errors when running non-existent gradient', () => { - const kernelName = 'MyKernel'; - const x = tf.zeros([2, 2]); - - tf.registerKernel({ - kernelName, - backendName: tf.getBackend(), - kernelFunc: () => ({dtype: 'float32', shape: [3, 3], dataId: {}}) - }); - - const gradFunc = - tf.grad(x => tf.engine().runKernel(kernelName, {x}, {} /* attrs */)); - expect(() => gradFunc(x)) - .toThrowError(/gradient function not found for MyKernel/); - - tf.unregisterKernel(kernelName, tf.getBackend()); - }); - - // tslint:disable-next-line: ban - xit('warning when registering the same gradient twice', () => { - const kernelName = 'MyKernel'; - tf.registerGradient({kernelName, gradFunc: () => null}); - spyOn(console, 'warn').and.callFake((msg: string) => { - expect(msg).toBe('Overriding the gradient for \'MyKernel\''); - }); - tf.registerGradient({kernelName, gradFunc: () => null}); - tf.unregisterGradient(kernelName); - }); -}); diff --git a/tfjs-master/tfjs-core/src/log.ts b/tfjs-master/tfjs-core/src/log.ts deleted file mode 100644 index 5a03b379c..000000000 --- a/tfjs-master/tfjs-core/src/log.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {env} from './environment'; - -export function warn(...msg: Array<{}>): void { - if (!(env().getBool('IS_TEST') || env().getBool('PROD'))) { - console.warn(...msg); - } -} - -export function log(...msg: Array<{}>): void { - if (!(env().getBool('IS_TEST') || env().getBool('PROD'))) { - console.log(...msg); - } -} diff --git a/tfjs-master/tfjs-core/src/math.ts b/tfjs-master/tfjs-core/src/math.ts deleted file mode 100644 index b3f44d537..000000000 --- a/tfjs-master/tfjs-core/src/math.ts +++ /dev/null @@ -1,24 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -/** - * Exports under the tf.math.* namespace. - */ - -import {confusionMatrix} from './ops/confusion_matrix'; - -export {confusionMatrix}; diff --git a/tfjs-master/tfjs-core/src/model_types.ts b/tfjs-master/tfjs-core/src/model_types.ts deleted file mode 100644 index 9484e978a..000000000 --- a/tfjs-master/tfjs-core/src/model_types.ts +++ /dev/null @@ -1,156 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Tensor} from './tensor'; -import {NamedTensorMap} from './tensor_types'; -import {DataType} from './types'; - -export interface ModelPredictConfig { - /** - * Optional. Batch size (Integer). If unspecified, it will default to 32. - */ - batchSize?: number; - - /** - * Optional. Verbosity mode. Defaults to false. - */ - verbose?: boolean; -} - -/** - * Interface for model input/output tensor info. - */ -export interface ModelTensorInfo { - // Name of the tensor. - name: string; - // Tensor shape information, Optional. - shape?: number[]; - // Data type of the tensor. - dtype: DataType; - // TensorFlow native Data type of the tensor. - tfDtype?: string; -} - -/** - * Common interface for a machine learning model that can do inference. - */ -export interface InferenceModel { - /** - * Return the array of input tensor info. - */ - readonly inputs: ModelTensorInfo[]; - - /** - * Return the array of output tensor info. - */ - readonly outputs: ModelTensorInfo[]; - - /** - * Execute the inference for the input tensors. - * - * @param input The input tensors, when there is single input for the model, - * inputs param should be a Tensor. For models with multiple inputs, inputs - * params should be in either Tensor[] if the input order is fixed, or - * otherwise NamedTensorMap format. - * For batch inference execution, the tensors for each input need to be - * concatenated together. For example with mobilenet, the required input shape - * is [1, 244, 244, 3], which represents the [batch, height, width, channel]. - * If we are provide a batched data of 100 images, the input tensor should be - * in the shape of [100, 244, 244, 3]. - * - * @param config Prediction configuration for specifying the batch size. - * - * @returns Inference result tensors. The output would be single Tensor if - * model has single output node, otherwise Tensor[] or NamedTensorMap[] will - * be returned for model with multiple outputs. - */ - predict(inputs: Tensor|Tensor[]|NamedTensorMap, config: ModelPredictConfig): - Tensor|Tensor[]|NamedTensorMap; - - /** - * Single Execute the inference for the input tensors and return activation - * values for specified output node names without batching. - * - * @param input The input tensors, when there is single input for the model, - * inputs param should be a Tensor. For models with multiple inputs, inputs - * params should be in either Tensor[] if the input order is fixed, or - * otherwise NamedTensorMap format. - * - * @param outputs string|string[]. List of output node names to retrieve - * activation from. - * - * @returns Activation values for the output nodes result tensors. The return - * type matches specified parameter outputs type. The output would be single - * Tensor if single output is specified, otherwise Tensor[] for multiple - * outputs. - */ - execute(inputs: Tensor|Tensor[]|NamedTensorMap, outputs: string|string[]): - Tensor|Tensor[]; -} - -/** - * @deprecated Deprecated interface for SavedModel/GraphModel MetaGraph info. - * User MetaGraph instead. - */ -export interface MetaGraphInfo { - tags: string[]; - signatureDefs: SignatureDefInfo; -} - -/** - * @deprecated Deprecated interface for SavedModel/GraphModel SignatureDef info. - * User SignatureDef instead. - */ -export interface SignatureDefInfo { - [key: string]: { - inputs: {[key: string]: SavedModelTensorInfo}; - outputs: {[key: string]: SavedModelTensorInfo}; - }; -} - -/** - * @deprecated Deprecated interface for SavedModel/GraphModel signature - * input/output Tensor info. User ModelTensorInfo instead. - */ -export interface SavedModelTensorInfo { - dtype: string; - shape: number[]; - name: string; -} - -/** - * Interface for SavedModel/GraphModel MetaGraph info. - */ -export interface MetaGraph { - tags: string[]; - signatureDefs: SignatureDef; -} - -/** - * Interface for SavedModel/GraphModel SignatureDef entry. - */ -export interface SignatureDefEntry { - inputs: {[key: string]: ModelTensorInfo}; - outputs: {[key: string]: ModelTensorInfo}; -} - -/** - * Interface for SavedModel/GraphModel SignatureDef info. - */ -export interface SignatureDef { - [key: string]: SignatureDefEntry; -} diff --git a/tfjs-master/tfjs-core/src/ops/abs.ts b/tfjs-master/tfjs-core/src/ops/abs.ts deleted file mode 100644 index 969b0c805..000000000 --- a/tfjs-master/tfjs-core/src/ops/abs.ts +++ /dev/null @@ -1,51 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {Abs, AbsInputs, ComplexAbs, ComplexAbsInputs} from '../kernel_names'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -import {op} from './operation'; - -/** - * Computes absolute value element-wise: `abs(x)` - * - * ```js - * const x = tf.tensor1d([-1, 2, -3, 4]); - * - * x.abs().print(); // or tf.abs(x) - * ``` - * @param x The input `tf.Tensor`. - * - * @doc {heading: 'Operations', subheading: 'Basic math'} - */ -function abs_(x: T|TensorLike): T { - const $x = convertToTensor(x, 'x', 'abs'); - - if ($x.dtype === 'complex64') { - const inputs: ComplexAbsInputs = {x: $x}; - return ENGINE.runKernel(ComplexAbs, inputs as unknown as NamedTensorMap); - } else { - const inputs: AbsInputs = {x: $x}; - return ENGINE.runKernel(Abs, inputs as unknown as NamedTensorMap); - } -} - -export const abs = /* @__PURE__ */ op({abs_}); diff --git a/tfjs-master/tfjs-core/src/ops/abs_test.ts b/tfjs-master/tfjs-core/src/ops/abs_test.ts deleted file mode 100644 index 81ae7219b..000000000 --- a/tfjs-master/tfjs-core/src/ops/abs_test.ts +++ /dev/null @@ -1,178 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; -import {backend} from '../index'; - -describeWithFlags('abs', ALL_ENVS, () => { - it('basic', async () => { - const a = tf.tensor1d([1, -2, 0, 3, -0.1]); - const result = tf.abs(a); - expectArraysClose(await result.data(), [1, 2, 0, 3, 0.1]); - }); - - it('5D', async () => { - const a = tf.tensor5d([1, -2, 0, -3], [1, 2, 2, 1, 1]); - const result = tf.abs(a); - expectArraysClose(await result.data(), [1, 2, 0, 3]); - }); - - it('6D', async () => { - const a = tf.tensor6d([1, -2, 5, -3, -1, 4, 7, 8], [1, 2, 2, 2, 1, 1]); - const result = tf.abs(a); - expectArraysClose(await result.data(), [1, 2, 5, 3, 1, 4, 7, 8]); - }); - - it('int32', async () => { - if (backend() && backend().floatPrecision() === 32) { - // TODO: Use skip() instead when it is implemented - const a = tf.tensor1d([10, 12345678, -12345678], 'int32'); - const result = tf.abs(a); - expect(result.dtype).toEqual('int32'); - expectArraysClose(await result.data(), [10, 12345678, 12345678]); - } - }); - - it('complex64 rank-1', async () => { - const a = tf.complex([-2, -1, 0, 1, 2], [1, 2, 3, 0, -1]); - const result = tf.abs(a); - expectArraysClose(await result.data(), [ - Math.sqrt(-2 * -2 + 1 * 1), Math.sqrt(-1 * -1 + 2 * 2), - Math.sqrt(0 * 0 + 3 * 3), Math.sqrt(1 * 1 + 0 * 0), - Math.sqrt(2 * 2 + -1 * -1) - ]); - expect(result.shape).toEqual([5]); - }); - - it('complex64 rank-2', async () => { - const a = tf.complex([[-3, -2, -1], [0, 1, 2]], [[4, 1, 2], [3, 0, -1]]); - const result = tf.abs(a); - expectArraysClose(await result.data(), [ - Math.sqrt(-3 * -3 + 4 * 4), Math.sqrt(-2 * -2 + 1 * 1), - Math.sqrt(-1 * -1 + 2 * 2), Math.sqrt(0 * 0 + 3 * 3), - Math.sqrt(1 * 1 + 0 * 0), Math.sqrt(2 * 2 + -1 * -1) - ]); - expect(result.shape).toEqual([2, 3]); - }); - - it('complex64 rank-3', async () => { - const a = tf.complex( - [[[-3, -2], [-1, 0]], [[1, 2], [3, 4]]], - [[[4, 1], [2, 3]], [[0, -1], [-3, -4]]]); - const result = tf.abs(a); - expectArraysClose(await result.data(), [ - Math.sqrt(-3 * -3 + 4 * 4), Math.sqrt(-2 * -2 + 1 * 1), - Math.sqrt(-1 * -1 + 2 * 2), Math.sqrt(0 * 0 + 3 * 3), - Math.sqrt(1 * 1 + 0 * 0), Math.sqrt(2 * 2 + -1 * -1), - Math.sqrt(3 * 3 + -3 * -3), Math.sqrt(4 * 4 + -4 * -4) - ]); - expect(result.shape).toEqual([2, 2, 2]); - }); - - it('is underflow-safe for complex64', async () => { - const floatBits = tf.backend().floatPrecision(); - let small; - switch (floatBits) { - case 32: - small = 1e-30; - break; - case 16: - small = 1e-4; - break; - default: - throw new Error(`Test not implemented for ENV.engine.floatPrecision()=${ - floatBits}.`); - } - - const a = tf.complex([small, 0, small, 0], [small, small, 0, 0]); - const result = tf.abs(a); - expectArraysClose( - await result.data(), - [ - Math.hypot(small, small), Math.hypot(0, small), Math.hypot(small, 0), - Math.hypot(0, 0) - ], - /*tolerance=*/ small / 100); - expect(result.shape).toEqual([4]); - }); - - it('propagates NaNs', async () => { - const a = tf.tensor1d([1, -2, 0, 3, -0.1, NaN]); - const result = tf.abs(a); - expectArraysClose(await result.data(), [1, 2, 0, 3, 0.1, NaN]); - }); - - it('gradients: Scalar', async () => { - const a = tf.scalar(4); - const dy = tf.scalar(8); - - const da = tf.grad(a => tf.abs(a))(a, dy); - - expect(da.shape).toEqual(a.shape); - expect(da.dtype).toEqual('float32'); - expectArraysClose(await da.data(), [8 * 1]); - }); - - it('gradient with clones', () => { - const a = tf.scalar(4); - const dy = tf.scalar(8); - - const da = tf.grad(a => a.clone().abs().clone())(a, dy); - - expect(da.shape).toEqual(a.shape); - expect(da.dtype).toEqual('float32'); - }); - - it('gradients: Tensor1D', async () => { - const a = tf.tensor1d([1, 2, -3, 5]); - const dy = tf.tensor1d([1, 2, 3, 4]); - - const da = tf.grad(a => tf.abs(a))(a, dy); - - expect(da.shape).toEqual(a.shape); - expect(da.dtype).toEqual('float32'); - expectArraysClose(await da.data(), [1 * 1, 2 * 1, 3 * -1, 4 * 1]); - }); - - it('gradients: Tensor2D', async () => { - const a = tf.tensor2d([3, -1, -2, 3], [2, 2]); - const dy = tf.tensor2d([1, 2, 3, 4], [2, 2]); - - const da = tf.grad(a => tf.abs(a))(a, dy); - - expect(da.shape).toEqual(a.shape); - expect(da.dtype).toEqual('float32'); - expectArraysClose(await da.data(), [1 * 1, 2 * -1, 3 * -1, 4 * 1]); - }); - - it('throws when passed a non-tensor', () => { - expect(() => tf.abs({} as tf.Tensor)) - .toThrowError(/Argument 'x' passed to 'abs' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const result = tf.abs([1, -2, 0, 3, -0.1]); - expectArraysClose(await result.data(), [1, 2, 0, 3, 0.1]); - }); - - it('throws for string tensor', () => { - expect(() => tf.abs('q')) - .toThrowError(/Argument 'x' passed to 'abs' must be numeric/); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/acos.ts b/tfjs-master/tfjs-core/src/ops/acos.ts deleted file mode 100644 index e54d3abe4..000000000 --- a/tfjs-master/tfjs-core/src/ops/acos.ts +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {ENGINE} from '../engine'; -import {Acos, AcosInputs} from '../kernel_names'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -import {op} from './operation'; - -/** - * Computes acos of the input `tf.Tensor` element-wise: `acos(x)` - * - * ```js - * const x = tf.tensor1d([0, 1, -1, .7]); - * - * x.acos().print(); // or tf.acos(x) - * ``` - * @param x The input tensor. - * @doc {heading: 'Operations', subheading: 'Basic math'} - */ -function acos_(x: T|TensorLike): T { - const $x = convertToTensor(x, 'x', 'acos'); - const inputs: AcosInputs = {x: $x}; - - return ENGINE.runKernel(Acos, inputs as unknown as NamedTensorMap); -} -export const acos = /* @__PURE__ */ op({acos_}); diff --git a/tfjs-master/tfjs-core/src/ops/acos_test.ts b/tfjs-master/tfjs-core/src/ops/acos_test.ts deleted file mode 100644 index a78e6bf07..000000000 --- a/tfjs-master/tfjs-core/src/ops/acos_test.ts +++ /dev/null @@ -1,123 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('acos', ALL_ENVS, () => { - it('basic', async () => { - const values = [.1, -3, 2, 7, -4]; - const a = tf.tensor1d(values); - const result = tf.acos(a); - - const expected = []; - for (let i = 0; i < a.size; i++) { - expected[i] = Math.acos(values[i]); - } - expectArraysClose(await result.data(), expected); - }); - - it('propagates NaNs', async () => { - const a = tf.tensor1d([4, NaN, 0]); - const res = tf.acos(a); - expectArraysClose(await res.data(), [Math.acos(4), NaN, Math.acos(0)]); - }); - - it('gradients: Scalar', async () => { - const a = tf.scalar(0.5); - const dy = tf.scalar(8); - - const gradients = tf.grad(a => tf.acos(a))(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose( - await gradients.data(), [(-1 * 8) / Math.sqrt(1 - (0.5 * 0.5))]); - }); - - it('gradient with clones', async () => { - const a = tf.scalar(0.5); - const dy = tf.scalar(8); - - const gradients = tf.grad(a => tf.acos(a.clone()).clone())(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose( - await gradients.data(), [(-1 * 8) / Math.sqrt(1 - (0.5 * 0.5))]); - }); - - it('gradients: Tensor1D', async () => { - const aValues = [-0.1, 0.2, 0.3, -0.5]; - const dyValues = [1, 2, 3, 4]; - const a = tf.tensor1d(aValues); - const dy = tf.tensor1d(dyValues); - - const gradients = tf.grad(a => tf.acos(a))(a, dy); - - const expected = []; - for (let i = 0; i < a.size; i++) { - expected[i] = - (-1 * dyValues[i]) / Math.sqrt(1 - (aValues[i] * aValues[i])); - } - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), expected); - }); - - it('gradients: Tensor2D', async () => { - const aValues = [-0.3, 0.1, 0.2, 0.3]; - const dyValues = [1, 2, 3, 4]; - const a = tf.tensor2d(aValues, [2, 2]); - const dy = tf.tensor2d(dyValues, [2, 2]); - - const gradients = tf.grad(a => tf.acos(a))(a, dy); - - const expected = []; - for (let i = 0; i < a.size; i++) { - expected[i] = - (-1 * dyValues[i]) / Math.sqrt(1 - (aValues[i] * aValues[i])); - } - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), expected); - }); - - it('throws when passed a non-tensor', () => { - expect(() => tf.acos({} as tf.Tensor)) - .toThrowError(/Argument 'x' passed to 'acos' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const values = [.1, -3, 2, 7, -4]; - const result = tf.acos(values); - - const expected = []; - for (let i = 0; i < values.length; i++) { - expected[i] = Math.acos(values[i]); - } - expectArraysClose(await result.data(), expected); - }); - - it('throws for string tensor', () => { - expect(() => tf.acos('q')) - .toThrowError(/Argument 'x' passed to 'acos' must be numeric/); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/acosh.ts b/tfjs-master/tfjs-core/src/ops/acosh.ts deleted file mode 100644 index f9c5e583c..000000000 --- a/tfjs-master/tfjs-core/src/ops/acosh.ts +++ /dev/null @@ -1,46 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {Acosh, AcoshInputs} from '../kernel_names'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -import {op} from './operation'; - -/** - * Computes the inverse hyperbolic cos of the input `tf.Tensor` element-wise: - * `acosh(x)` - * - * ```js - * const x = tf.tensor1d([10, 1, 3, 5.7]); - * - * x.acosh().print(); // or tf.acosh(x) - * ``` - * @param x The input tensor. - * - * @doc {heading: 'Operations', subheading: 'Basic math'} - */ -function acosh_(x: T|TensorLike): T { - const $x = convertToTensor(x, 'x', 'acosh'); - const inputs: AcoshInputs = {x: $x}; - - return ENGINE.runKernel(Acosh, inputs as unknown as NamedTensorMap); -} -export const acosh = /* @__PURE__ */ op({acosh_}); diff --git a/tfjs-master/tfjs-core/src/ops/acosh_test.ts b/tfjs-master/tfjs-core/src/ops/acosh_test.ts deleted file mode 100644 index 400eb39f2..000000000 --- a/tfjs-master/tfjs-core/src/ops/acosh_test.ts +++ /dev/null @@ -1,148 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('acosh', ALL_ENVS, () => { - it('basic', async () => { - const values = [2, 3, 4, 5, 6]; - const a = tf.tensor1d(values); - const result = tf.acosh(a); - - const expected = []; - for (let i = 0; i < a.size; i++) { - expected[i] = Math.acosh(values[i]); - } - expectArraysClose(await result.data(), expected); - }); - - it('scalar', async () => { - const value = 2; - const a = tf.scalar(value); - const result = tf.acosh(a); - - const expected = [Math.acosh(value)]; - expectArraysClose(await result.data(), expected); - }); - - it('tensor2d', async () => { - const values = [2, 3, 4, 5]; - const a = tf.tensor2d(values, [2, 2]); - const result = tf.acosh(a); - - const expected = []; - for (let i = 0; i < a.size; i++) { - expected[i] = Math.acosh(values[i]); - } - expectArraysClose(await result.data(), expected); - }); - - it('propagates NaNs', async () => { - const a = tf.tensor1d([4, NaN, 2]); - const res = tf.acosh(a); - expectArraysClose(await res.data(), [Math.acosh(4), NaN, Math.acosh(2)]); - }); - - it('NaN outside function domain', async () => { - const a = tf.tensor1d([4, -1, 2]); - const res = tf.acosh(a); - expectArraysClose(await res.data(), [Math.acosh(4), NaN, Math.acosh(2)]); - }); - - it('gradients: Scalar', async () => { - const a = tf.scalar(1.5); - const dy = tf.scalar(8); - - const gradients = tf.grad(a => tf.acosh(a))(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose( - await gradients.data(), [8.0 / Math.sqrt(1.5 * 1.5 - 1.0)]); - }); - - it('gradient with clones', async () => { - const a = tf.scalar(1.5); - const dy = tf.scalar(8); - - const gradients = tf.grad(a => tf.acosh(a.clone()).clone())(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose( - await gradients.data(), [8.0 / Math.sqrt(1.5 * 1.5 - 1.0)]); - }); - - it('gradients: Tensor1D', async () => { - const aValues = [2, 3, 5, 10]; - const dyValues = [1, 2, 3, 4]; - const a = tf.tensor1d(aValues); - const dy = tf.tensor1d(dyValues); - - const gradients = tf.grad(a => tf.acosh(a))(a, dy); - - const expected = []; - for (let i = 0; i < a.size; i++) { - expected[i] = dyValues[i] / Math.sqrt(Math.pow(aValues[i], 2) - 1.0); - } - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), expected); - }); - - it('gradients: Tensor2D', async () => { - const aValues = [2, 3, 5, 7]; - const dyValues = [1, 2, 3, 4]; - const a = tf.tensor2d(aValues, [2, 2]); - const dy = tf.tensor2d(dyValues, [2, 2]); - - const gradients = tf.grad(a => tf.acosh(a))(a, dy); - - const expected = []; - for (let i = 0; i < a.size; i++) { - expected[i] = dyValues[i] / Math.sqrt(Math.pow(aValues[i], 2) - 1.0); - } - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), expected); - }); - - it('throws when passed a non-tensor', () => { - expect(() => tf.acosh({} as tf.Tensor)) - .toThrowError(/Argument 'x' passed to 'acosh' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const values = [2, 3, 4, 5, 6]; - const result = tf.acosh(values); - - const expected = []; - for (let i = 0; i < values.length; i++) { - expected[i] = Math.acosh(values[i]); - } - expectArraysClose(await result.data(), expected); - }); - - it('throws for string tensor', () => { - expect(() => tf.acosh('q')) - .toThrowError(/Argument 'x' passed to 'acosh' must be numeric/); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/add.ts b/tfjs-master/tfjs-core/src/ops/add.ts deleted file mode 100644 index a89132eae..000000000 --- a/tfjs-master/tfjs-core/src/ops/add.ts +++ /dev/null @@ -1,60 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {ENGINE} from '../engine'; -import {Add, AddInputs} from '../kernel_names'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {makeTypesMatch} from '../tensor_util'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -import {op} from './operation'; - -/** - * Adds two `tf.Tensor`s element-wise, A + B. Supports broadcasting. - * - * - * ```js - * const a = tf.tensor1d([1, 2, 3, 4]); - * const b = tf.tensor1d([10, 20, 30, 40]); - * - * a.add(b).print(); // or tf.add(a, b) - * ``` - * - * ```js - * // Broadcast add a with b. - * const a = tf.scalar(5); - * const b = tf.tensor1d([10, 20, 30, 40]); - * - * a.add(b).print(); // or tf.add(a, b) - * ``` - * @param a The first `tf.Tensor` to add. - * @param b The second `tf.Tensor` to add. Must have the same type as `a`. - * - * @doc {heading: 'Operations', subheading: 'Arithmetic'} - */ -function add_(a: Tensor|TensorLike, b: Tensor|TensorLike): T { - let $a = convertToTensor(a, 'a', 'add'); - let $b = convertToTensor(b, 'b', 'add'); - [$a, $b] = makeTypesMatch($a, $b); - - const inputs: AddInputs = {a: $a, b: $b}; - - return ENGINE.runKernel(Add, inputs as unknown as NamedTensorMap); -} - -export const add = /* @__PURE__ */ op({add_}); diff --git a/tfjs-master/tfjs-core/src/ops/add_n.ts b/tfjs-master/tfjs-core/src/ops/add_n.ts deleted file mode 100644 index b4116e677..000000000 --- a/tfjs-master/tfjs-core/src/ops/add_n.ts +++ /dev/null @@ -1,72 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {ENGINE} from '../engine'; -import {AddN, AddNInputs} from '../kernel_names'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; -import * as util from '../util'; - -import {op} from './operation'; - -/** - * Adds a list of `tf.Tensor`s element-wise, each with the same shape and dtype. - * - * ```js - * const a = tf.tensor1d([1, 2]); - * const b = tf.tensor1d([3, 4]); - * const c = tf.tensor1d([5, 6]); - * - * tf.addN([a, b, c]).print(); - * ``` - * @param tensors A list of tensors with the same shape and dtype. - * @doc {heading: 'Operations', subheading: 'Arithmetic'} - */ -function addN_(tensors: Array): T { - util.assert( - Array.isArray(tensors), - () => 'The argument passed to tf.addN() must be a list of tensors'); - util.assert( - tensors.length >= 1, - () => `Must pass at least one tensor to tf.addN(), but got ` + - `${tensors.length}`); - - const $tensors = - tensors.map((t, i) => convertToTensor(t, `tensors${i}`, 'addN')); - - const firstTensor = $tensors[0]; - $tensors.forEach(t => { - if (t.dtype !== firstTensor.dtype) { - throw new Error( - 'All tensors passed to tf.addN() must have the same dtype'); - } - }); - - $tensors.forEach(t => { - if (!util.arraysEqual(t.shape, firstTensor.shape)) { - throw new Error( - 'All tensors passed to tf.addN() must have the same shape'); - } - }); - - const inputs: AddNInputs = $tensors; - - return ENGINE.runKernel(AddN, inputs as unknown as NamedTensorMap); -} - -export const addN = /* @__PURE__ */ op({addN_}); diff --git a/tfjs-master/tfjs-core/src/ops/add_n_test.ts b/tfjs-master/tfjs-core/src/ops/add_n_test.ts deleted file mode 100644 index 68cb7bbcc..000000000 --- a/tfjs-master/tfjs-core/src/ops/add_n_test.ts +++ /dev/null @@ -1,87 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('addN', ALL_ENVS, () => { - it('a single tensor', async () => { - const res = tf.addN([tf.tensor1d([1, 2, 3])]); - expectArraysClose(await res.data(), [1, 2, 3]); - }); - - it('two tensors, int32', async () => { - const res = tf.addN([ - tf.tensor1d([1, 2, -1], 'int32'), - tf.tensor1d([5, 3, 2], 'int32'), - ]); - expectArraysClose(await res.data(), [6, 5, 1]); - expect(res.dtype).toBe('int32'); - expect(res.shape).toEqual([3]); - }); - - it('three tensors', async () => { - const res = tf.addN([ - tf.tensor1d([1, 2]), - tf.tensor1d([5, 3]), - tf.tensor1d([-5, -2]), - ]); - expectArraysClose(await res.data(), [1, 3]); - expect(res.dtype).toBe('float32'); - expect(res.shape).toEqual([2]); - }); - - it('accepts a tensor-like object', async () => { - const res = tf.addN([[1, 2], [3, 4]]); - expectArraysClose(await res.data(), [4, 6]); - expect(res.dtype).toBe('float32'); - expect(res.shape).toEqual([2]); - }); - - it('list of numbers gets treated as a list of scalars', async () => { - const res = tf.addN([1, 2, 3, 4]); - expectArraysClose(await res.data(), [10]); - expect(res.dtype).toBe('float32'); - expect(res.shape).toEqual([]); - }); - - it('errors if list is empty', () => { - expect(() => tf.addN([])) - .toThrowError( - /Must pass at least one tensor to tf.addN\(\), but got 0/); - }); - - it('errors if argument is not an array', () => { - // tslint:disable-next-line:no-any - expect(() => tf.addN(tf.scalar(3) as any)) - .toThrowError( - /The argument passed to tf.addN\(\) must be a list of tensors/); - }); - - it('errors if arguments not of same dtype', () => { - expect(() => tf.addN([tf.scalar(1, 'int32'), tf.scalar(2, 'float32')])) - .toThrowError( - /All tensors passed to tf.addN\(\) must have the same dtype/); - }); - - it('errors if arguments not of same shape', () => { - expect(() => tf.addN([tf.scalar(1), tf.tensor1d([2])])) - .toThrowError( - /All tensors passed to tf.addN\(\) must have the same shape/); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/add_test.ts b/tfjs-master/tfjs-core/src/ops/add_test.ts deleted file mode 100644 index c0145aaa2..000000000 --- a/tfjs-master/tfjs-core/src/ops/add_test.ts +++ /dev/null @@ -1,325 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose, expectArraysEqual} from '../test_util'; - -describeWithFlags('add', ALL_ENVS, () => { - it('c + A', async () => { - const c = tf.scalar(5); - const a = tf.tensor1d([1, 2, 3]); - - const result = tf.add(c, a); - - expectArraysClose(await result.data(), [6, 7, 8]); - }); - - it('c + A propagates NaNs', async () => { - const c = tf.scalar(NaN); - const a = tf.tensor1d([1, 2, 3]); - - const res = tf.add(c, a); - - expectArraysEqual(await res.data(), [NaN, NaN, NaN]); - }); - - it('A + B broadcasting same rank Tensors different shape', async () => { - const a = tf.tensor2d([1, 2, -3, -4], [2, 2]); - const b = tf.tensor2d([2, 3], [2, 1]); - - const result = tf.add(a, b); - - expect(result.shape).toEqual([2, 2]); - const expected = [3, 4, 0, -1]; - - expectArraysClose(await result.data(), expected); - }); - - it('A + B broadcast 2D + 1D', async () => { - const a = tf.tensor2d([1, 2, -3, -4], [2, 2]); - const b = tf.tensor1d([1, 2]); - - const result = tf.add(a, b); - - expect(result.shape).toEqual([2, 2]); - const expected = [2, 4, -2, -2]; - - expectArraysClose(await result.data(), expected); - }); - - it('A + B', async () => { - const a = tf.tensor1d([2, 5, 1]); - const b = tf.tensor1d([4, 2, -1]); - - const result = tf.add(a, b); - - const expected = [6, 7, 0]; - expectArraysClose(await result.data(), expected); - }); - - it('TensorLike', async () => { - const a = [2, 5, 1]; - const b = [4, 2, -1]; - - const result = tf.add(a, b); - - const expected = [6, 7, 0]; - expectArraysClose(await result.data(), expected); - }); - - it('TensorLike chained', async () => { - const a = tf.tensor1d([2, 5, 1]); - const b = [4, 2, -1]; - - const result = a.add(b); - - const expected = [6, 7, 0]; - expectArraysClose(await result.data(), expected); - }); - - it('A + B propagates NaNs', async () => { - const a = tf.tensor1d([2, 5, NaN]); - const b = tf.tensor1d([4, 2, -1]); - - const res = tf.add(a, b); - expectArraysClose(await res.data(), [6, 7, NaN]); - }); - - it('A + B throws when passed tensors with different shape', () => { - const a = tf.tensor1d([2, 5, 1, 5]); - const b = tf.tensor1d([4, 2, -1]); - - expect(() => tf.add(a, b)).toThrowError(); - expect(() => tf.add(b, a)).toThrowError(); - }); - - it('2D+scalar broadcast', async () => { - const a = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - const b = tf.scalar(2); - const res = tf.add(a, b); - expect(res.shape).toEqual([2, 3]); - expectArraysClose(await res.data(), [3, 4, 5, 6, 7, 8]); - }); - - it('scalar+1D broadcast', async () => { - const a = tf.scalar(2); - const b = tf.tensor1d([1, 2, 3, 4, 5, 6]); - const res = tf.add(a, b); - expect(res.shape).toEqual([6]); - expectArraysClose(await res.data(), [3, 4, 5, 6, 7, 8]); - }); - - it('2D+2D broadcast each with 1 dim', async () => { - const a = tf.tensor2d([1, 2, 5], [1, 3]); - const b = tf.tensor2d([7, 3], [2, 1]); - const res = tf.add(a, b); - expect(res.shape).toEqual([2, 3]); - expectArraysClose(await res.data(), [8, 9, 12, 4, 5, 8]); - }); - - it('2D+2D broadcast inner dim of b', async () => { - const a = tf.tensor2d([1, 2, 5, 4, 5, 6], [2, 3]); - const b = tf.tensor2d([7, 3], [2, 1]); - const res = tf.add(a, b); - expect(res.shape).toEqual([2, 3]); - expectArraysClose(await res.data(), [8, 9, 12, 7, 8, 9]); - }); - - it('3D+scalar', async () => { - const a = tf.tensor3d([1, 2, 3, 4, 5, 6], [2, 3, 1]); - const b = tf.scalar(-1); - const res = tf.add(a, b); - expect(res.shape).toEqual([2, 3, 1]); - expectArraysClose(await res.data(), [0, 1, 2, 3, 4, 5]); - }); - - it('6D+scalar', async () => { - const a = tf.range(0, 64).reshape([2, 2, 2, 2, 2, 2]); - const b = tf.scalar(-1); - const res = tf.add(a, b); - expect(res.shape).toEqual([2, 2, 2, 2, 2, 2]); - const expectedResult = [ - -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, - 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, - 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62 - ]; - expectArraysClose(await res.data(), expectedResult); - }); - - it('6D+2D', async () => { - const a = tf.range(0, 64).reshape([2, 2, 2, 2, 2, 2]); - const b = tf.tensor2d([11, 13, 17, 19], [2, 2]); - const res = tf.add(a, b); - expect(res.shape).toEqual([2, 2, 2, 2, 2, 2]); - const expectedResult = [ - 11, 14, 19, 22, 15, 18, 23, 26, 19, 22, 27, 30, 23, 26, 31, 34, - 27, 30, 35, 38, 31, 34, 39, 42, 35, 38, 43, 46, 39, 42, 47, 50, - 43, 46, 51, 54, 47, 50, 55, 58, 51, 54, 59, 62, 55, 58, 63, 66, - 59, 62, 67, 70, 63, 66, 71, 74, 67, 70, 75, 78, 71, 74, 79, 82 - ]; - expectArraysClose(await res.data(), expectedResult); - }); - - it('add tensors with 0 in shape', async () => { - const a = tf.tensor1d([1]); - const b = tf.tensor3d([], [0, 0, 5]); - const res = tf.add(a, b); - expect(res.shape).toEqual([0, 0, 5]); - expectArraysEqual(await res.data(), []); - }); - - it('gradient: scalar + 1D broadcast', async () => { - const a = tf.scalar(2); - const b = tf.tensor1d([3, 4, 5]); - const dy = tf.tensor1d([7, 8, 9]); - - const grads = tf.grads((a, b) => tf.add(a, b)); - const [da, db] = grads([a, b], dy); - - expect(da.shape).toEqual(a.shape); - expect(da.dtype).toEqual('float32'); - expectArraysClose(await da.data(), [7 + 8 + 9]); - - expect(db.shape).toEqual(b.shape); - expect(db.dtype).toEqual('float32'); - expectArraysClose(await db.data(), [7, 8, 9]); - }); - - it('gradient with clones', async () => { - const a = tf.scalar(2); - const b = tf.tensor1d([3, 4, 5]); - const dy = tf.tensor1d([7, 8, 9]); - - const grads = tf.grads((a, b) => tf.add(a.clone(), b.clone()).clone()); - const [da, db] = grads([a, b], dy); - - expect(da.shape).toEqual(a.shape); - expect(da.dtype).toEqual('float32'); - expectArraysClose(await da.data(), [7 + 8 + 9]); - - expect(db.shape).toEqual(b.shape); - expect(db.dtype).toEqual('float32'); - expectArraysClose(await db.data(), [7, 8, 9]); - }); - - it('gradient: 2D + 2D broadcast', async () => { - const a = tf.tensor2d([2, 3], [2, 1]); - const b = tf.tensor2d([4, 5, 6, 7], [2, 2]); - const dy = tf.tensor2d([5, 4, 3, 2], [2, 2]); - - const grads = tf.grads((a, b) => tf.add(a, b)); - const [da, db] = grads([a, b], dy); - - expect(da.shape).toEqual(a.shape); - expect(da.dtype).toEqual('float32'); - expectArraysClose(await da.data(), [5 + 4, 3 + 2]); - - expect(db.shape).toEqual(b.shape); - expect(db.dtype).toEqual('float32'); - expectArraysClose(await db.data(), [5, 4, 3, 2]); - }); - - it('complex number addition', async () => { - const real1 = tf.tensor1d([1]); - const imag1 = tf.tensor1d([2]); - const complex1 = tf.complex(real1, imag1); - - const real2 = tf.tensor1d([3]); - const imag2 = tf.tensor1d([4]); - const complex2 = tf.complex(real2, imag2); - - const result = complex1.add(complex2); - - expect(result.dtype).toBe('complex64'); - expect(result.shape).toEqual([1]); - expectArraysClose(await result.data(), [4, 6]); - }); - - it('complex number reshape and then addition', async () => { - const real1 = tf.tensor1d([1]); - const imag1 = tf.tensor1d([2]); - const complex1 = tf.complex(real1, imag1); - - const real2 = tf.tensor1d([3]); - const imag2 = tf.tensor1d([4]); - const complex2 = tf.complex(real2, imag2); - - const complex1Reshaped = complex1.reshape([1, 1, 1]); - const complex2Reshaped = complex2.reshape([1, 1, 1]); - - const result = complex1Reshaped.add(complex2Reshaped); - - expect(result.dtype).toBe('complex64'); - expect(result.shape).toEqual([1, 1, 1]); - expectArraysClose(await result.data(), [4, 6]); - }); - - it('complex number broadcasting addition', async () => { - const real1 = tf.tensor2d([1, 2, -3, -4], [2, 2]); - const imag1 = tf.tensor2d([10, 20, -30, -40], [2, 2]); - const complex1 = tf.complex(real1, imag1); - - const real2 = tf.tensor1d([4]); - const imag2 = tf.tensor1d([5]); - const complex2 = tf.complex(real2, imag2); - - const result = tf.add(complex1, complex2); - - expect(result.dtype).toEqual('complex64'); - expect(result.shape).toEqual([2, 2]); - expectArraysClose( - await result.data(), - [1 + 4, 10 + 5, 2 + 4, 20 + 5, -3 + 4, -30 + 5, -4 + 4, -40 + 5]); - }); - - it('throws when passed a as a non-tensor', () => { - expect(() => tf.add({} as tf.Tensor, tf.scalar(1))) - .toThrowError(/Argument 'a' passed to 'add' must be a Tensor/); - }); - it('throws when passed b as a non-tensor', () => { - expect(() => tf.add(tf.scalar(1), {} as tf.Tensor)) - .toThrowError(/Argument 'b' passed to 'add' must be a Tensor/); - }); - - it('upcasts when dtypes dont match', async () => { - let res = tf.add(tf.scalar(1, 'int32'), tf.scalar(1, 'float32')); - expect(res.dtype).toBe('float32'); - expectArraysClose(await res.data(), [2]); - - res = tf.add(tf.scalar(1, 'int32'), tf.scalar(true, 'bool')); - expect(res.dtype).toBe('int32'); - expectArraysClose(await res.data(), [2]); - - res = tf.add(tf.scalar(1, 'int32'), tf.scalar(false, 'bool')); - expect(res.dtype).toBe('int32'); - expectArraysClose(await res.data(), [1]); - - res = tf.add(tf.complex(4, 7), tf.scalar(1, 'float32')); - expect(res.dtype).toBe('complex64'); - expectArraysClose(await res.data(), [5, 7]); - - res = tf.add(tf.complex(4, 7), tf.scalar(1, 'int32')); - expect(res.dtype).toBe('complex64'); - expectArraysClose(await res.data(), [5, 7]); - }); - - it('accepts a tensor-like object', async () => { - const result = tf.add(5, [1, 2, 3]); - expectArraysClose(await result.data(), [6, 7, 8]); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/all.ts b/tfjs-master/tfjs-core/src/ops/all.ts deleted file mode 100644 index 2d8bd4886..000000000 --- a/tfjs-master/tfjs-core/src/ops/all.ts +++ /dev/null @@ -1,69 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {All, AllAttrs, AllInputs} from '../kernel_names'; -import {NamedAttrMap} from '../kernel_registry'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -import {op} from './operation'; - -/** - * Computes the logical and of elements across dimensions of a `tf.Tensor`. - * - * Reduces the input along the dimensions given in `axes`. Unless `keepDims` - * is true, the rank of the `tf.Tensor` is reduced by 1 for each entry in - * `axes`. If `keepDims` is true, the reduced dimensions are retained with - * length 1. If `axes` has no entries, all dimensions are reduced, and a - * `tf.Tensor` with a single element is returned. - * - * ```js - * const x = tf.tensor1d([1, 1, 1], 'bool'); - * - * x.all().print(); // or tf.all(x) - * ``` - * - * ```js - * const x = tf.tensor2d([1, 1, 0, 0], [2, 2], 'bool'); - * - * const axis = 1; - * x.all(axis).print(); // or tf.all(x, axis) - * ``` - * - * @param x The input tensor. Must be of dtype bool. - * @param axis The dimension(s) to reduce. By default it reduces - * all dimensions. - * @param keepDims If true, retains reduced dimensions with size 1. - * - * @doc {heading: 'Operations', subheading: 'Reduction'} - */ -function all_( - x: Tensor|TensorLike, axis: number|number[] = null, keepDims = false): T { - const $x = convertToTensor(x, 'x', 'all', 'bool'); - - const inputs: AllInputs = {x: $x}; - const attrs: AllAttrs = {axis, keepDims}; - - return ENGINE.runKernel( - All, inputs as unknown as NamedTensorMap, - attrs as unknown as NamedAttrMap); -} - -export const all = /* @__PURE__ */ op({all_}); diff --git a/tfjs-master/tfjs-core/src/ops/all_test.ts b/tfjs-master/tfjs-core/src/ops/all_test.ts deleted file mode 100644 index 87945a59b..000000000 --- a/tfjs-master/tfjs-core/src/ops/all_test.ts +++ /dev/null @@ -1,116 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose, expectArraysEqual} from '../test_util'; - -describeWithFlags('all', ALL_ENVS, () => { - it('Tensor1D', async () => { - let a = tf.tensor1d([0, 0, 0], 'bool'); - expectArraysClose(await tf.all(a).data(), 0); - - a = tf.tensor1d([1, 0, 1], 'bool'); - expectArraysClose(await tf.all(a).data(), 0); - - a = tf.tensor1d([1, 1, 1], 'bool'); - expectArraysClose(await tf.all(a).data(), 1); - }); - - it('ignores NaNs', async () => { - const a = tf.tensor1d([1, NaN, 1], 'bool'); - expectArraysEqual(await tf.all(a).data(), 1); - }); - - it('2D', async () => { - const a = tf.tensor2d([1, 1, 0, 0], [2, 2], 'bool'); - expectArraysClose(await tf.all(a).data(), 0); - }); - - it('2D axis=[0,1]', async () => { - const a = tf.tensor2d([1, 1, 0, 0, 1, 0], [2, 3], 'bool'); - expectArraysClose(await tf.all(a, [0, 1]).data(), 0); - }); - - it('2D, axis=0', async () => { - const a = tf.tensor2d([1, 1, 0, 0], [2, 2], 'bool'); - let r = tf.all(a, 0); - - expect(r.shape).toEqual([2]); - expectArraysClose(await r.data(), [0, 0]); - - r = tf.all(a, 1); - - expect(r.shape).toEqual([2]); - expectArraysClose(await r.data(), [1, 0]); - }); - - it('2D, axis=0, keepDims', async () => { - const a = tf.tensor2d([1, 1, 0, 0, 1, 0], [2, 3], 'bool'); - const r = a.all(0, true /* keepDims */); - - expect(r.shape).toEqual([1, 3]); - expectArraysClose(await r.data(), [0, 1, 0]); - }); - - it('2D, axis=1 provided as a number', async () => { - const a = tf.tensor2d([1, 1, 0, 0, 1, 0], [2, 3], 'bool'); - const r = tf.all(a, 1); - expectArraysClose(await r.data(), [0, 0]); - }); - - it('2D, axis = -1 provided as a number', async () => { - const a = tf.tensor2d([1, 1, 0, 0, 1, 0], [2, 3], 'bool'); - const r = tf.all(a, -1); - expectArraysClose(await r.data(), [0, 0]); - }); - - it('2D, axis=[1]', async () => { - const a = tf.tensor2d([1, 1, 0, 0, 1, 0], [2, 3], 'bool'); - const r = tf.all(a, [1]); - expectArraysClose(await r.data(), [0, 0]); - }); - - it('throws when dtype is not boolean', () => { - const a = tf.tensor2d([1, 1, 0, 0], [2, 2]); - expect(() => tf.all(a)) - .toThrowError( - /Argument 'x' passed to 'all' must be bool tensor, but got float/); - }); - - it('throws when passed a non-tensor', () => { - expect(() => tf.all({} as tf.Tensor)) - .toThrowError(/Argument 'x' passed to 'all' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const a = [0, 0, 0]; - expectArraysClose(await tf.all(a).data(), 0); - }); - - it('throws error for string tensor', () => { - expect(() => tf.all(['a'])) - .toThrowError( - /Argument 'x' passed to 'all' must be bool tensor, but got string/); - }); - - it('returns a boolean tensor', () => { - const a = tf.tensor1d([1, 0], 'bool'); - const r = tf.all(a); - expect(r.dtype).toEqual('bool'); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/any.ts b/tfjs-master/tfjs-core/src/ops/any.ts deleted file mode 100644 index c1a6e9723..000000000 --- a/tfjs-master/tfjs-core/src/ops/any.ts +++ /dev/null @@ -1,70 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {Any, AnyAttrs, AnyInputs} from '../kernel_names'; -import {NamedAttrMap} from '../kernel_registry'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -import {op} from './operation'; - -/** - * Computes the logical or of elements across dimensions of a `tf.Tensor`. - * - * Reduces the input along the dimensions given in `axes`. Unless `keepDims` - * is true, the rank of the `tf.Tensor` is reduced by 1 for each entry in - * `axes`. If `keepDims` is true, the reduced dimensions are retained with - * length 1. If `axes` has no entries, all dimensions are reduced, and a - * `tf.Tensor` with a single element is returned. - * - * ```js - * const x = tf.tensor1d([1, 1, 1], 'bool'); - * - * x.any().print(); // or tf.any(x) - * ``` - * - * ```js - * const x = tf.tensor2d([1, 1, 0, 0], [2, 2], 'bool'); - * - * const axis = 1; - * x.any(axis).print(); // or tf.any(x, axis) - * ``` - * - * @param x The input tensor. Must be of dtype bool. - * @param axis The dimension(s) to reduce. By default it reduces - * all dimensions. - * @param keepDims If true, retains reduced dimensions with size 1. - * - * @doc {heading: 'Operations', subheading: 'Reduction'} - */ -function any_( - x: Tensor|TensorLike, axis: number|number[] = null, keepDims = false): T { - const $x = convertToTensor(x, 'x', 'any', 'bool'); - - const inputs: AnyInputs = {x: $x}; - const attrs: AnyAttrs = {axis, keepDims}; - - return ENGINE.runKernel( - Any, inputs as unknown as NamedTensorMap, - attrs as unknown as NamedAttrMap); -} - -// tslint:disable-next-line:variable-name -export const any = /* @__PURE__ */ op({any_}); diff --git a/tfjs-master/tfjs-core/src/ops/any_test.ts b/tfjs-master/tfjs-core/src/ops/any_test.ts deleted file mode 100644 index 0353cca98..000000000 --- a/tfjs-master/tfjs-core/src/ops/any_test.ts +++ /dev/null @@ -1,115 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose, expectArraysEqual} from '../test_util'; - -describeWithFlags('any', ALL_ENVS, () => { - it('Tensor1D', async () => { - let a = tf.tensor1d([0, 0, 0], 'bool'); - expectArraysClose(await tf.any(a).data(), 0); - - a = tf.tensor1d([1, 0, 1], 'bool'); - expectArraysClose(await tf.any(a).data(), 1); - - a = tf.tensor1d([1, 1, 1], 'bool'); - expectArraysClose(await tf.any(a).data(), 1); - }); - - it('ignores NaNs', async () => { - const a = tf.tensor1d([1, NaN, 0], 'bool'); - expectArraysEqual(await tf.any(a).data(), 1); - }); - - it('2D', async () => { - const a = tf.tensor2d([1, 1, 0, 0], [2, 2], 'bool'); - expectArraysClose(await tf.any(a).data(), 1); - }); - - it('2D axis=[0,1]', async () => { - const a = tf.tensor2d([1, 1, 0, 0, 1, 0], [2, 3], 'bool'); - expectArraysClose(await tf.any(a, [0, 1]).data(), 1); - }); - - it('2D, axis=0', async () => { - const a = tf.tensor2d([1, 1, 0, 0], [2, 2], 'bool'); - let r = tf.any(a, 0); - - expect(r.shape).toEqual([2]); - expectArraysClose(await r.data(), [1, 1]); - - r = tf.any(a, 1); - - expect(r.shape).toEqual([2]); - expectArraysClose(await r.data(), [1, 0]); - }); - - it('2D, axis=0, keepDims', async () => { - const a = tf.tensor2d([1, 1, 0, 0, 1, 0], [2, 3], 'bool'); - const r = a.any(0, true /* keepDims */); - - expect(r.shape).toEqual([1, 3]); - expectArraysClose(await r.data(), [1, 1, 0]); - }); - - it('2D, axis=1 provided as a number', async () => { - const a = tf.tensor2d([1, 1, 0, 0, 1, 0], [2, 3], 'bool'); - const r = tf.any(a, 1); - expectArraysClose(await r.data(), [1, 1]); - }); - - it('2D, axis = -1 provided as a number', async () => { - const a = tf.tensor2d([1, 1, 0, 0, 1, 0], [2, 3], 'bool'); - const r = tf.any(a, -1); - expectArraysClose(await r.data(), [1, 1]); - }); - - it('2D, axis=[1]', async () => { - const a = tf.tensor2d([1, 1, 0, 0, 1, 0], [2, 3], 'bool'); - const r = tf.any(a, [1]); - expectArraysClose(await r.data(), [1, 1]); - }); - - it('throws when dtype is not boolean', () => { - const a = tf.tensor2d([1, 1, 0, 0], [2, 2]); - expect(() => tf.any(a)) - .toThrowError( - /Argument 'x' passed to 'any' must be bool tensor, but got float/); - }); - - it('throws when passed a non-tensor', () => { - expect(() => tf.any({} as tf.Tensor)) - .toThrowError(/Argument 'x' passed to 'any' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const a = [0, 0, 0]; - expectArraysClose(await tf.any(a).data(), 0); - }); - - it('throws error for string tensor', () => { - expect(() => tf.any(['a'])) - .toThrowError(/Argument 'x' passed to 'any' must be bool tensor/); - }); - - it('returns a boolean tensor', () => { - const a = tf.tensor1d([1, 0], 'bool'); - const r = tf.any(a); - expect(r.dtype).toEqual('bool'); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/arg_max.ts b/tfjs-master/tfjs-core/src/ops/arg_max.ts deleted file mode 100644 index d1c5deb8f..000000000 --- a/tfjs-master/tfjs-core/src/ops/arg_max.ts +++ /dev/null @@ -1,63 +0,0 @@ -/** - * @license - * Copyright 2020 Google Inc. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {ArgMax, ArgMaxAttrs, ArgMaxInputs} from '../kernel_names'; -import {NamedAttrMap} from '../kernel_registry'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -import {op} from './operation'; - -/** - * Returns the indices of the maximum values along an `axis`. - * - * The result has the same shape as `input` with the dimension along `axis` - * removed. - * - * ```js - * const x = tf.tensor1d([1, 2, 3]); - * - * x.argMax().print(); // or tf.argMax(x) - * ``` - * - * ```js - * const x = tf.tensor2d([1, 2, 4, 3], [2, 2]); - * - * const axis = 1; - * x.argMax(axis).print(); // or tf.argMax(x, axis) - * ``` - * - * @param x The input tensor. - * @param axis The dimension to reduce. Defaults to 0 (outer-most dimension). - * - * @doc {heading: 'Operations', subheading: 'Reduction'} - */ -function argMax_(x: Tensor|TensorLike, axis = 0): T { - const $x = convertToTensor(x, 'x', 'argMax'); - - const inputs: ArgMaxInputs = {x: $x}; - const attrs: ArgMaxAttrs = {axis}; - - return ENGINE.runKernel( - ArgMax, inputs as unknown as NamedTensorMap, - attrs as unknown as NamedAttrMap); -} - -export const argMax = /* @__PURE__ */ op({argMax_}); diff --git a/tfjs-master/tfjs-core/src/ops/arg_max_test.ts b/tfjs-master/tfjs-core/src/ops/arg_max_test.ts deleted file mode 100644 index d7c4cd9ec..000000000 --- a/tfjs-master/tfjs-core/src/ops/arg_max_test.ts +++ /dev/null @@ -1,178 +0,0 @@ -/** - * @license - * Copyright 2020 Google Inc. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose, expectArraysEqual} from '../test_util'; - -import * as reduce_util from './reduce_util'; - -describeWithFlags('argmax', ALL_ENVS, () => { - it('Tensor1D', async () => { - const a = tf.tensor1d([1, 0, 3, 2]); - const result = tf.argMax(a); - expect(result.dtype).toBe('int32'); - expectArraysEqual(await result.data(), 2); - }); - - it('one value', async () => { - const a = tf.tensor1d([10]); - const result = tf.argMax(a); - expect(result.dtype).toBe('int32'); - expectArraysEqual(await result.data(), 0); - }); - - it('N > than parallelization threshold', async () => { - const n = reduce_util.PARALLELIZE_THRESHOLD * 2; - const values = new Float32Array(n); - for (let i = 0; i < n; i++) { - values[i] = i; - } - const a = tf.tensor1d(values); - const result = tf.argMax(a); - expect(result.dtype).toBe('int32'); - expectArraysEqual(await result.data(), n - 1); - }); - - it('3D, N > than parallelization threshold', async () => { - const n = reduce_util.PARALLELIZE_THRESHOLD * 2; - const values = new Float32Array(n); - for (let i = 0; i < n; i++) { - values[i] = i; - } - const a = tf.tensor3d(values, [1, 1, n]); - const result = tf.argMax(a, -1); - expect(result.dtype).toBe('int32'); - expectArraysEqual(await result.data(), n - 1); - }); - - it('max index corresponds to start of a non-initial window', async () => { - const n = reduce_util.PARALLELIZE_THRESHOLD * 2; - const windowSize = reduce_util.computeOptimalWindowSize(n); - const values = new Float32Array(n); - const index = windowSize * 2; - values[index] = 1; - const a = tf.tensor1d(values); - const result = tf.argMax(a); - expect(result.dtype).toBe('int32'); - expectArraysEqual(await result.data(), index); - }); - - it('5D, max index corresponds to start of a non-initial window', async () => { - const n = reduce_util.PARALLELIZE_THRESHOLD * 2; - const windowSize = reduce_util.computeOptimalWindowSize(n); - const values = new Float32Array(n); - const index = windowSize * 2; - values[index] = 1; - const a = tf.tensor5d(values, [1, 1, 1, 1, n]); - const result = tf.argMax(a, -1); - expect(result.dtype).toBe('int32'); - expectArraysEqual(await result.data(), index); - }); - - it('ignores NaNs', async () => { - const a = tf.tensor1d([0, 3, 5, NaN, 3]); - const res = tf.argMax(a); - expect(res.dtype).toBe('int32'); - expectArraysEqual(await res.data(), 2); - }); - - it('2D, no axis specified', async () => { - const a = tf.tensor2d([3, -1, 0, 100, -7, 2], [2, 3]); - expectArraysEqual(await tf.argMax(a).data(), [1, 0, 1]); - }); - - it('4D, no axis specified', async () => { - const a = tf.tensor4d([3, -1, 0, 100, -7, 2], [2, 1, 1, 3]); - expectArraysEqual(await tf.argMax(a).data(), [1, 0, 1]); - }); - - it('2D, axis=0', async () => { - const a = tf.tensor2d([3, -1, 0, 100, -7, 2], [2, 3]); - const r = tf.argMax(a, 0); - - expect(r.shape).toEqual([3]); - expect(r.dtype).toBe('int32'); - expectArraysEqual(await r.data(), [1, 0, 1]); - }); - - it('6D, axis=0', async () => { - const a = tf.tensor6d([3, -1, 0, 100, -7, 2], [2, 1, 1, 1, 1, 3]); - const r = tf.argMax(a, 0); - - expect(r.shape).toEqual([1, 1, 1, 1, 3]); - expect(r.dtype).toBe('int32'); - expectArraysEqual(await r.data(), [1, 0, 1]); - }); - - it('2D, axis=1', async () => { - const a = tf.tensor2d([3, 2, 5, 100, -7, 2], [2, 3]); - const r = tf.argMax(a, 1); - expect(r.dtype).toBe('int32'); - expectArraysEqual(await r.data(), [2, 0]); - }); - - it('2D, axis = -1', async () => { - const a = tf.tensor2d([3, 2, 5, 100, -7, 2], [2, 3]); - const r = tf.argMax(a, -1); - expect(r.dtype).toBe('int32'); - expectArraysEqual(await r.data(), [2, 0]); - }); - - it('throws when passed a non-tensor', () => { - expect(() => tf.argMax({} as tf.Tensor)) - .toThrowError(/Argument 'x' passed to 'argMax' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const result = tf.argMax([1, 0, 3, 2]); - expect(result.dtype).toBe('int32'); - expectArraysEqual(await result.data(), 2); - }); - - it('accepts tensor with bool values', async () => { - const t = tf.tensor1d([0, 1], 'bool'); - const result = tf.argMax(t); - expect(result.dtype).toBe('int32'); - expectArraysEqual(await result.data(), 1); - }); - - it('has gradient', async () => { - const a = tf.tensor2d([3, 2, 5, 100, -7, 2], [2, 3]); - const dy = tf.ones([3], 'float32'); - const da = tf.grad((x: tf.Tensor2D) => tf.argMax(x))(a, dy); - - expect(da.dtype).toBe('float32'); - expect(da.shape).toEqual([2, 3]); - expectArraysClose(await da.data(), [0, 0, 0, 0, 0, 0]); - }); - - it('gradient with clones', async () => { - const a = tf.tensor2d([3, 2, 5, 100, -7, 2], [2, 3]); - const dy = tf.ones([3], 'float32'); - const da = tf.grad((x: tf.Tensor2D) => tf.argMax(x.clone()).clone())(a, dy); - - expect(da.dtype).toBe('float32'); - expect(da.shape).toEqual([2, 3]); - expectArraysClose(await da.data(), [0, 0, 0, 0, 0, 0]); - }); - - it('throws error for string tensor', () => { - expect(() => tf.argMax(['a'])) - .toThrowError(/Argument 'x' passed to 'argMax' must be numeric tensor/); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/arg_min.ts b/tfjs-master/tfjs-core/src/ops/arg_min.ts deleted file mode 100644 index b55e81185..000000000 --- a/tfjs-master/tfjs-core/src/ops/arg_min.ts +++ /dev/null @@ -1,63 +0,0 @@ -/** - * @license - * Copyright 2020 Google Inc. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {ArgMin, ArgMinAttrs, ArgMinInputs} from '../kernel_names'; -import {NamedAttrMap} from '../kernel_registry'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -import {op} from './operation'; - -/** - * Returns the indices of the minimum values along an `axis`. - * - * The result has the same shape as `input` with the dimension along `axis` - * removed. - * - * ```js - * const x = tf.tensor1d([1, 2, 3]); - * - * x.argMin().print(); // or tf.argMin(x) - * ``` - * - * ```js - * const x = tf.tensor2d([1, 2, 4, 3], [2, 2]); - * - * const axis = 1; - * x.argMin(axis).print(); // or tf.argMin(x, axis) - * ``` - * - * @param x The input tensor. - * @param axis The dimension to reduce. Defaults to 0 (outer-most dimension). - * - * @doc {heading: 'Operations', subheading: 'Reduction'} - */ -function argMin_(x: Tensor|TensorLike, axis = 0): T { - const $x = convertToTensor(x, 'x', 'argMin'); - - const inputs: ArgMinInputs = {x: $x}; - const attrs: ArgMinAttrs = {axis}; - - return ENGINE.runKernel( - ArgMin, inputs as unknown as NamedTensorMap, - attrs as unknown as NamedAttrMap); -} - -export const argMin = /* @__PURE__ */ op({argMin_}); diff --git a/tfjs-master/tfjs-core/src/ops/arg_min_test.ts b/tfjs-master/tfjs-core/src/ops/arg_min_test.ts deleted file mode 100644 index 21c1b5c3f..000000000 --- a/tfjs-master/tfjs-core/src/ops/arg_min_test.ts +++ /dev/null @@ -1,152 +0,0 @@ -/** - * @license - * Copyright 2020 Google Inc. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose, expectArraysEqual} from '../test_util'; - -import * as reduce_util from './reduce_util'; - -describeWithFlags('argmin', ALL_ENVS, () => { - it('Tensor1D', async () => { - const a = tf.tensor1d([1, 0, 3, 2]); - const result = tf.argMin(a); - expectArraysEqual(await result.data(), 1); - }); - - it('one value', async () => { - const a = tf.tensor1d([10]); - const result = tf.argMin(a); - expectArraysEqual(await result.data(), 0); - }); - - it('N > than parallelization threshold', async () => { - const n = reduce_util.PARALLELIZE_THRESHOLD * 2; - const values = new Float32Array(n); - for (let i = 0; i < n; i++) { - values[i] = n - i; - } - const a = tf.tensor1d(values); - const result = tf.argMin(a); - expect(result.dtype).toBe('int32'); - expectArraysEqual(await result.data(), n - 1); - }); - - it('4D, N > than parallelization threshold', async () => { - const n = reduce_util.PARALLELIZE_THRESHOLD * 2; - const values = new Float32Array(n); - for (let i = 0; i < n; i++) { - values[i] = n - i; - } - const a = tf.tensor4d(values, [1, 1, 1, n]); - const result = tf.argMin(a, -1); - expect(result.dtype).toBe('int32'); - expectArraysEqual(await result.data(), n - 1); - }); - - it('min index corresponds to start of a non-initial window', async () => { - const n = reduce_util.PARALLELIZE_THRESHOLD * 2; - const windowSize = reduce_util.computeOptimalWindowSize(n); - const values = new Float32Array(n); - const index = windowSize * 2; - values[index] = -1; - const a = tf.tensor1d(values); - const result = tf.argMin(a); - expect(result.dtype).toBe('int32'); - expectArraysEqual(await result.data(), index); - }); - - it('ignores NaNs', async () => { - const a = tf.tensor1d([5, 0, NaN, -1, 3]); - const res = tf.argMin(a); - expectArraysEqual(await res.data(), 3); - }); - - it('3D, ignores NaNs', async () => { - const a = tf.tensor3d([5, 0, NaN, -1, 3], [1, 1, 5]); - const res = tf.argMin(a, -1); - expectArraysEqual(await res.data(), 3); - }); - - it('2D, no axis specified', async () => { - const a = tf.tensor2d([3, -1, 0, 100, -7, 2], [2, 3]); - expectArraysEqual(await tf.argMin(a).data(), [0, 1, 0]); - }); - - it('2D, axis=0', async () => { - const a = tf.tensor2d([3, -1, 0, 100, -7, 2], [2, 3]); - const r = tf.argMin(a, 0); - - expect(r.shape).toEqual([3]); - expect(r.dtype).toBe('int32'); - expectArraysEqual(await r.data(), [0, 1, 0]); - }); - - it('2D, axis=1', async () => { - const a = tf.tensor2d([3, 2, 5, 100, -7, -8], [2, 3]); - const r = tf.argMin(a, 1); - expectArraysEqual(await r.data(), [1, 2]); - }); - - it('2D, axis = -1', async () => { - const a = tf.tensor2d([3, 2, 5, 100, -7, -8], [2, 3]); - const r = tf.argMin(a, -1); - expectArraysEqual(await r.data(), [1, 2]); - }); - - it('throws when passed a non-tensor', () => { - expect(() => tf.argMin({} as tf.Tensor)) - .toThrowError(/Argument 'x' passed to 'argMin' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const result = tf.argMin([1, 0, 3, 2]); - expectArraysEqual(await result.data(), 1); - }); - - it('accepts tensor with bool values', async () => { - const t = tf.tensor1d([0, 1], 'bool'); - const result = tf.argMin(t); - expect(result.dtype).toBe('int32'); - expectArraysEqual(await result.data(), 0); - }); - - it('has gradient', async () => { - const a = tf.tensor2d([3, 2, 5, 100, -7, 2], [2, 3]); - const dy = tf.ones([3], 'float32'); - const da = tf.grad((x: tf.Tensor2D) => tf.argMin(x))(a, dy); - - expect(da.dtype).toBe('float32'); - expect(da.shape).toEqual([2, 3]); - expectArraysClose(await da.data(), [0, 0, 0, 0, 0, 0]); - }); - - it('gradient with clones', async () => { - const a = tf.tensor2d([3, 2, 5, 100, -7, 2], [2, 3]); - const dy = tf.ones([3], 'float32'); - const da = tf.grad((x: tf.Tensor2D) => tf.argMin(x.clone()).clone())(a, dy); - - expect(da.dtype).toBe('float32'); - expect(da.shape).toEqual([2, 3]); - expectArraysClose(await da.data(), [0, 0, 0, 0, 0, 0]); - }); - - it('throws error for string tensor', () => { - expect(() => tf.argMin(['a'])) - .toThrowError(/Argument 'x' passed to 'argMin' must be numeric tensor/); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/arithmetic_test.ts b/tfjs-master/tfjs-core/src/ops/arithmetic_test.ts deleted file mode 100644 index e681c0270..000000000 --- a/tfjs-master/tfjs-core/src/ops/arithmetic_test.ts +++ /dev/null @@ -1,964 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose, expectArraysEqual} from '../test_util'; - -describeWithFlags('div', ALL_ENVS, () => { - it('same shape', async () => { - const a = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - const c = tf.tensor2d([1, 2, 3, 4, 2, 5], [2, 3]); - - const r = tf.div(a, c); - - expectArraysClose(await r.data(), [1, 1, 1, 1, 2.5, 6 / 5]); - }); - - it('vec4 same shape', async () => { - const a = tf.tensor2d([1, 2, -3, -4], [2, 2]); - const b = tf.tensor2d([5, 3, 4, -7], [2, 2]); - const expected = [0.2, 0.666, -0.75, 0.571]; - const result = tf.div(a, b); - - expect(result.shape).toEqual([2, 2]); - expectArraysClose(await result.data(), expected); - }); - - it('TensorLike', async () => { - const a = [0, 1, -2, -4, 4, -4]; - const b = [0.15, 0.2, 0.25, 0.5, 0.7, 1.2]; - const result = tf.div(a, b); - - expect(result.shape).toEqual([6]); - expectArraysClose( - await result.data(), - [0, 5.0, -8.0, -8.0, 5.714285850524902, -3.3333332538604736]); - }); - - it('TensorLike chained', async () => { - const a = tf.tensor1d([0, 1, -2, -4, 4, -4]); - const b = [0.15, 0.2, 0.25, 0.5, 0.7, 1.2]; - const result = a.div(b); - - expect(result.shape).toEqual(a.shape); - expectArraysClose( - await result.data(), - [0, 5.0, -8.0, -8.0, 5.714285850524902, -3.3333332538604736]); - }); - - it('division by zero results in infinity', async () => { - const r = tf.div(1, 0); - const rData = await r.data(); - - expect(Array.from(rData)).toEqual([Infinity]); - }); - - it('integer division implements floor divide', async () => { - const a = tf.tensor1d([-6, -6, -5, -4, -3, -3, 3, 3, 2], 'int32'); - const c = tf.tensor1d([-2, 2, 3, 2, -3, 3, 2, 3, 2], 'int32'); - - const r = tf.div(a, c); - - expect(r.dtype).toEqual('int32'); - expectArraysClose(await r.data(), [3, -3, -2, -2, 1, -1, 1, 1, 1]); - }); - - it('integer division broadcasts', async () => { - const a = tf.tensor1d([-5, -4, 3, 2], 'int32'); - const c = tf.scalar(2, 'int32'); - - const r = tf.div(a, c); - - expect(r.dtype).toEqual('int32'); - expectArraysClose(await r.data(), [-3, -2, 1, 1]); - }); - - it('propagates NaNs', async () => { - const a = tf.tensor2d([1, 2], [2, 1]); - const c = tf.tensor2d([3, NaN], [2, 1]); - - const r = tf.div(a, c); - - expectArraysClose(await r.data(), [1 / 3, NaN]); - }); - - it('broadcasting same rank Tensors different shape', async () => { - const a = tf.tensor2d([1, 2, -3, -4], [2, 2]); - const b = tf.tensor2d([2, 3], [2, 1]); - - const result = tf.div(a, b); - - expect(result.shape).toEqual([2, 2]); - const expected = [1 / 2, 1, -1, -4 / 3]; - - expectArraysClose(await result.data(), expected); - }); - - it('broadcast scalar', async () => { - const a = tf.tensor2d([1, 2, 3, 4], [2, 2]); - const b = [2]; - - const result = tf.div(a, b); - - expect(result.shape).toEqual([2, 2]); - const expected = [0.5, 1, 1.5, 2]; - - expectArraysClose(await result.data(), expected); - }); - - it('broadcast 2D + 1D', async () => { - const a = tf.tensor2d([1, 2, -3, -4], [2, 2]); - const b = tf.tensor1d([1, 2]); - - const result = tf.div(a, b); - - expect(result.shape).toEqual([2, 2]); - const expected = [1, 1, -3, -2]; - - expectArraysClose(await result.data(), expected); - }); - - it('upcasts when dtypes dont match', async () => { - let res = tf.div(tf.scalar(6, 'int32'), tf.scalar(3, 'float32')); - expect(res.dtype).toBe('float32'); - expectArraysClose(await res.data(), [2]); - - res = tf.div(tf.scalar(6, 'int32'), tf.scalar(true, 'bool')); - expect(res.dtype).toBe('int32'); - expectArraysClose(await res.data(), [6]); - }); - - it('throws when passed tensors of different shapes', () => { - const a = tf.tensor2d([1, 2, -3, -4, 5, 6], [2, 3]); - const b = tf.tensor2d([5, 3, 4, -7], [2, 2]); - - expect(() => tf.div(a, b)).toThrowError(); - expect(() => tf.div(b, a)).toThrowError(); - }); - - it('scalar divided by array', async () => { - const c = tf.scalar(2); - const a = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - - const r = tf.div(c, a); - - expectArraysClose( - await r.data(), [2 / 1, 2 / 2, 2 / 3, 2 / 4, 2 / 5, 2 / 6]); - }); - - it('scalar divided by array propagates NaNs', async () => { - const c = tf.scalar(NaN); - const a = tf.tensor2d([1, 2, 3], [1, 3]); - - const r = tf.div(c, a); - - expectArraysEqual(await r.data(), [NaN, NaN, NaN]); - }); - - it('array divided by scalar', async () => { - const a = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - const c = tf.scalar(2); - - const r = tf.div(a, c); - - expectArraysClose( - await r.data(), [1 / 2, 2 / 2, 3 / 2, 4 / 2, 5 / 2, 6 / 2]); - }); - - it('array divided by scalar propagates NaNs', async () => { - const a = tf.tensor2d([1, 2, NaN], [1, 3]); - const c = tf.scalar(2); - - const r = tf.div(a, c); - expectArraysClose(await r.data(), [1 / 2, 2 / 2, NaN]); - }); - - it('gradient: Scalar', async () => { - const a = tf.scalar(5); - const b = tf.scalar(2); - const dy = tf.scalar(4); - - const before = tf.memory().numTensors; - const grads = tf.grads((a, b) => tf.div(a, b)); - const [da, db] = grads([a, b], dy); - const now = tf.memory().numTensors; - expect(now).toBe(before + 2); - - expect(da.shape).toEqual(a.shape); - expect(da.dtype).toEqual('float32'); - expectArraysClose(await da.data(), [4 / 2]); - - expect(db.shape).toEqual(b.shape); - expect(db.dtype).toEqual('float32'); - expectArraysClose(await db.data(), [-4 * 5 / (2 * 2)]); - }); - - it('gradient with clones', async () => { - const grads = tf.grads((a, b) => tf.div(a.clone(), b.clone()).clone()); - const [da, db] = grads([5, 2]); - expect(da.shape).toEqual([]); - expect(db.shape).toEqual([]); - expectArraysClose(await da.data(), [1 / 2]); - expectArraysClose(await db.data(), [-5 / 4]); - }); - - it('gradient: Tensor1D', async () => { - const a = tf.tensor1d([1, 2, 3]); - const b = tf.tensor1d([3, 4, 5]); - const dy = tf.tensor1d([1, 10, 20]); - - const grads = tf.grads((a, b) => tf.div(a, b)); - const [da, db] = grads([a, b], dy); - - expect(da.shape).toEqual(a.shape); - expect(db.dtype).toEqual('float32'); - expectArraysClose(await da.data(), [1 / 3, 10 / 4, 20 / 5]); - - expect(db.shape).toEqual(b.shape); - expect(db.dtype).toEqual('float32'); - expectArraysClose( - await db.data(), [-1 * 1 / 9, -10 * 2 / 16, -20 * 3 / 25]); - }); - - it('gradient: Tensor1D with int32', async () => { - const a = tf.tensor1d([1, 2, 3], 'int32'); - const b = tf.tensor1d([3, 4, 5], 'int32'); - const dy = tf.tensor1d([1, 10, 20]); - - const grads = tf.grads((a, b) => tf.div(a, b)); - const [da, db] = grads([a, b], dy); - - expect(da.shape).toEqual(a.shape); - expect(db.dtype).toEqual('float32'); - expectArraysClose(await da.data(), [1 / 3, 10 / 4, 20 / 5]); - - expect(db.shape).toEqual(b.shape); - expect(db.dtype).toEqual('float32'); - expectArraysClose( - await db.data(), [-1 * 1 / 9, -10 * 2 / 16, -20 * 3 / 25]); - }); - - it('gradient: 1d with 1d ', async () => { - const a = tf.tensor1d([true, false, true], 'bool'); - const b = tf.tensor1d([1, 2, 3], 'int32'); - const dy = tf.tensor1d([1, 19, 20]); - - const grads = tf.grads((a, b) => tf.div(a.toInt(), b)); - const [da, db] = grads([a, b], dy); - - expect(da.shape).toEqual(a.shape); - expect(db.dtype).toEqual('float32'); - expectArraysClose(await da.data(), [1, 19 / 2, 20 / 3]); - - expect(db.shape).toEqual(b.shape); - expect(db.dtype).toEqual('float32'); - expectArraysClose(await db.data(), [-1 / 1, 0, -20 / 9]); - }); - - it('gradient: Tensor2D', async () => { - const a = tf.tensor2d([3, 1, 2, 3], [2, 2]); - const b = tf.tensor2d([1, 3, 4, 5], [2, 2]); - const dy = tf.tensor2d([1, 10, 15, 20], [2, 2]); - - const grads = tf.grads((a, b) => tf.div(a, b)); - const [da, db] = grads([a, b], dy); - - expect(da.shape).toEqual(a.shape); - expect(da.dtype).toEqual('float32'); - expectArraysClose(await da.data(), [1 / 1, 10 / 3, 15 / 4, 20 / 5]); - - expect(db.shape).toEqual(b.shape); - expect(db.dtype).toEqual('float32'); - expectArraysClose( - await db.data(), [-1 * 3 / 1, -10 * 1 / 9, -15 * 2 / 16, -20 * 3 / 25]); - }); - - it('gradient: scalar / Tensor1D', async () => { - const a = tf.scalar(2); - const b = tf.tensor1d([3, 4, 5]); - const dy = tf.tensor1d([6, 7, 8]); - - const grads = tf.grads((a, b) => tf.div(a, b)); - const [da, db] = grads([a, b], dy); - - expect(da.shape).toEqual(a.shape); - expect(da.dtype).toEqual('float32'); - expectArraysClose(await da.data(), [6 / 3 + 7 / 4 + 8 / 5]); - - expect(db.shape).toEqual(b.shape); - expect(db.dtype).toEqual('float32'); - expectArraysClose(await db.data(), [-6 * 2 / 9, -7 * 2 / 16, -8 * 2 / 25]); - }); - - it('gradient: Tensor2D / scalar', async () => { - const a = tf.tensor2d([[2, 3], [4, 5]], [2, 2]); - const b = tf.scalar(2); - const dy = tf.tensor2d([[6, 7], [8, 9]], [2, 2]); - - const grads = tf.grads((a, b) => tf.div(a, b)); - const [da, db] = grads([a, b], dy); - - expect(da.shape).toEqual(a.shape); - expect(da.dtype).toEqual('float32'); - expectArraysClose(await da.data(), [6 / 2, 7 / 2, 8 / 2, 9 / 2]); - - expect(db.shape).toEqual(b.shape); - expect(db.dtype).toEqual('float32'); - expectArraysClose( - await db.data(), [-6 * 2 / 4 + -7 * 3 / 4 + -8 * 4 / 4 + -9 * 5 / 4]); - }); - - it('gradient: Tensor2D / Tensor2D w/ broadcast', async () => { - const a = tf.tensor2d([3, 4], [2, 1]); - const b = tf.tensor2d([[2, 3], [4, 5]], [2, 2]); - const dy = tf.tensor2d([[6, 7], [8, 9]], [2, 2]); - - const grads = tf.grads((a, b) => tf.div(a, b)); - const [da, db] = grads([a, b], dy); - - expect(da.shape).toEqual(a.shape); - expect(da.dtype).toEqual('float32'); - expectArraysClose(await da.data(), [6 / 2 + 7 / 3, 8 / 4 + 9 / 5]); - - expect(db.shape).toEqual(b.shape); - expect(db.dtype).toEqual('float32'); - expectArraysClose( - await db.data(), [-6 * 3 / 4, -7 * 3 / 9, -8 * 4 / 16, -9 * 4 / 25]); - }); - - it('throws when passed a as a non-tensor', () => { - expect(() => tf.div({} as tf.Tensor, tf.scalar(1))) - .toThrowError(/Argument 'a' passed to 'div' must be a Tensor/); - }); - - it('throws when passed b as a non-tensor', () => { - expect(() => tf.div(tf.scalar(1), {} as tf.Tensor)) - .toThrowError(/Argument 'b' passed to 'div' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const r = tf.div([[1, 2, 3], [4, 5, 6]], 2); - expect(r.shape).toEqual([2, 3]); - expectArraysClose( - await r.data(), [1 / 2, 2 / 2, 3 / 2, 4 / 2, 5 / 2, 6 / 2]); - }); -}); - -describeWithFlags('mul', ALL_ENVS, () => { - it('same-shaped tensors', async () => { - const a = tf.tensor2d([1, 2, -3, -4], [2, 2]); - const b = tf.tensor2d([5, 3, 4, -7], [2, 2]); - const expected = [5, 6, -12, 28]; - const result = tf.mul(a, b); - - expect(result.shape).toEqual([2, 2]); - expectArraysClose(await result.data(), expected); - }); - - it('TensorLike', async () => { - const a = [[1, 2], [-3, -4]]; - const b = [[5, 3], [4, -7]]; - const expected = [5, 6, -12, 28]; - const result = tf.mul(a, b); - - expect(result.shape).toEqual([2, 2]); - expectArraysClose(await result.data(), expected); - }); - - it('TensorLike chained', async () => { - const a = tf.tensor2d([1, 2, -3, -4], [2, 2]); - const b = [[5, 3], [4, -7]]; - const expected = [5, 6, -12, 28]; - const result = a.mul(b); - - expect(result.shape).toEqual([2, 2]); - expectArraysClose(await result.data(), expected); - }); - - it('broadcasting tensors', async () => { - const a = tf.tensor2d([1, 2, -3, -4], [2, 2]); - const b = tf.scalar(2); - const expected = [2, 4, -6, -8]; - const result = tf.mul(a, b); - - expect(result.shape).toEqual([2, 2]); - expectArraysClose(await result.data(), expected); - }); - - it('broadcasting same rank Tensors different shape', async () => { - const a = tf.tensor2d([1, 2, -3, -4], [2, 2]); - const b = tf.tensor2d([2, 3], [2, 1]); - - const result = tf.mul(a, b); - - expect(result.shape).toEqual([2, 2]); - const expected = [2, 4, -9, -12]; - - expectArraysClose(await result.data(), expected); - }); - - it('broadcast 2D + 1D', async () => { - const a = tf.tensor2d([1, 2, -3, -4], [2, 2]); - const b = tf.tensor1d([1, 2]); - - const result = tf.mul(a, b); - - expect(result.shape).toEqual([2, 2]); - const expected = [1, 4, -3, -8]; - - expectArraysClose(await result.data(), expected); - }); - - it('broadcast 5D + 2D', async () => { - const a = tf.range(1, 33).reshape([2, 2, 2, 2, 2]); - const b = tf.tensor([2, 3], [2, 1]); - const result = tf.mul(a, b); - expect(result.shape).toEqual([2, 2, 2, 2, 2]); - const expected = [ - 2, 4, 9, 12, 10, 12, 21, 24, 18, 20, 33, 36, 26, 28, 45, 48, - 34, 36, 57, 60, 42, 44, 69, 72, 50, 52, 81, 84, 58, 60, 93, 96 - ]; - expectArraysClose(await result.data(), expected); - }); - - it('broadcast 6D + 2D', async () => { - const a = tf.range(1, 65).reshape([2, 2, 2, 2, 2, 2]); - const b = tf.tensor([2, 3], [2, 1]); - const result = tf.mul(a, b); - expect(result.shape).toEqual([2, 2, 2, 2, 2, 2]); - const expected = [ - 2, 4, 9, 12, 10, 12, 21, 24, 18, 20, 33, 36, 26, - 28, 45, 48, 34, 36, 57, 60, 42, 44, 69, 72, 50, 52, - 81, 84, 58, 60, 93, 96, 66, 68, 105, 108, 74, 76, 117, - 120, 82, 84, 129, 132, 90, 92, 141, 144, 98, 100, 153, 156, - 106, 108, 165, 168, 114, 116, 177, 180, 122, 124, 189, 192 - ]; - expectArraysClose(await result.data(), expected); - }); - - it('gradient: Scalar', async () => { - const a = tf.scalar(5); - const b = tf.scalar(2); - const dy = tf.scalar(4); - - const grads = tf.grads((a, b) => tf.mul(a, b)); - const [da, db] = grads([a, b], dy); - - expect(da.shape).toEqual(a.shape); - expect(da.dtype).toEqual('float32'); - expectArraysClose(await da.data(), await b.mul(dy).data()); - - expect(db.shape).toEqual(b.shape); - expect(db.dtype).toEqual('float32'); - expectArraysClose(await db.data(), await a.mul(dy).data()); - }); - - it('gradient with clones', async () => { - const grads = tf.grads((a, b) => tf.mul(a.clone(), b.clone()).clone()); - const [da, db] = grads([4, 2]); - - expect(da.shape).toEqual([]); - expect(da.dtype).toEqual('float32'); - expectArraysClose(await da.data(), 2); - - expect(db.shape).toEqual([]); - expect(db.dtype).toEqual('float32'); - expectArraysClose(await db.data(), 4); - }); - - it('gradient: Tensor1D', async () => { - const a = tf.tensor1d([1, 2, 3]); - const b = tf.tensor1d([3, 4, 5]); - const dy = tf.tensor1d([1, 10, 20]); - - const grads = tf.grads((a, b) => tf.mul(a, b)); - const [da, db] = grads([a, b], dy); - - expect(da.shape).toEqual(a.shape); - expect(da.dtype).toEqual('float32'); - expectArraysClose(await da.data(), [3 * 1, 4 * 10, 5 * 20]); - - expect(db.shape).toEqual(b.shape); - expect(db.dtype).toEqual('float32'); - expectArraysClose(await db.data(), [1 * 1, 2 * 10, 3 * 20]); - }); - - it('gradient: Tensor1D with dtype int32', async () => { - const a = tf.tensor1d([1, 2, 3], 'int32'); - const b = tf.tensor1d([3, 4, 5], 'int32'); - const dy = tf.tensor1d([1, 10, 20]); - - const grads = tf.grads((a, b) => tf.mul(a, b)); - const [da, db] = grads([a, b], dy); - - expect(da.shape).toEqual(a.shape); - expect(db.dtype).toEqual('float32'); - expectArraysClose(await da.data(), [3 * 1, 4 * 10, 5 * 20]); - - expect(db.shape).toEqual(b.shape); - expect(db.dtype).toEqual('float32'); - expectArraysClose(await db.data(), [1 * 1, 2 * 10, 3 * 20]); - }); - - it('gradient: Tensor2D', async () => { - const a = tf.tensor2d([3, 1, 2, 3], [2, 2]); - const b = tf.tensor2d([1, 3, 4, 5], [2, 2]); - const dy = tf.tensor2d([1, 10, 15, 20], [2, 2]); - - const grads = tf.grads((a, b) => tf.mul(a, b)); - const [da, db] = grads([a, b], dy); - - expect(da.shape).toEqual(a.shape); - expect(da.dtype).toEqual('float32'); - expectArraysClose(await da.data(), [1 * 1, 3 * 10, 4 * 15, 5 * 20]); - - expect(db.shape).toEqual(b.shape); - expect(db.dtype).toEqual('float32'); - expectArraysClose(await db.data(), [3 * 1, 1 * 10, 2 * 15, 3 * 20]); - }); - - it('gradient: scalar * Tensor1D', async () => { - const a = tf.scalar(2); - const b = tf.tensor1d([3, 4, 5]); - const dy = tf.tensor1d([6, 7, 8]); - - const grads = tf.grads((a, b) => tf.mul(a, b)); - const [da, db] = grads([a, b], dy); - - expect(da.shape).toEqual(a.shape); - expect(da.dtype).toEqual('float32'); - expectArraysClose(await da.data(), [3 * 6 + 4 * 7 + 5 * 8]); - - expect(db.shape).toEqual(b.shape); - expect(db.dtype).toEqual('float32'); - expectArraysClose(await db.data(), [2 * 6, 2 * 7, 2 * 8]); - }); - - it('gradient: Tensor2D * scalar', async () => { - const a = tf.tensor2d([[2, 3], [4, 5]], [2, 2]); - const b = tf.scalar(2); - const dy = tf.tensor2d([[6, 7], [8, 9]], [2, 2]); - - const grads = tf.grads((a, b) => tf.mul(a, b)); - const [da, db] = grads([a, b], dy); - - expect(da.shape).toEqual(a.shape); - expect(da.dtype).toEqual('float32'); - expectArraysClose(await da.data(), [2 * 6, 2 * 7, 2 * 8, 2 * 9]); - - expect(db.shape).toEqual(b.shape); - expect(db.dtype).toEqual('float32'); - expectArraysClose(await db.data(), [2 * 6 + 3 * 7 + 4 * 8 + 5 * 9]); - }); - - it('gradient: Tensor2D * Tensor2D w/ broadcast', async () => { - const a = tf.tensor2d([3, 4], [2, 1]); - const b = tf.tensor2d([[2, 3], [4, 5]], [2, 2]); - const dy = tf.tensor2d([[6, 7], [8, 9]], [2, 2]); - - const grads = tf.grads((a, b) => tf.mul(a, b)); - const [da, db] = grads([a, b], dy); - - expect(da.shape).toEqual(a.shape); - expect(da.dtype).toEqual('float32'); - expectArraysClose(await da.data(), [2 * 6 + 3 * 7, 4 * 8 + 5 * 9]); - - expect(db.shape).toEqual(b.shape); - expect(db.dtype).toEqual('float32'); - expectArraysClose(await db.data(), [6 * 3, 7 * 3, 8 * 4, 9 * 4]); - }); - - it('complex number multiplication', async () => { - const real1 = tf.tensor1d([2]); - const imag1 = tf.tensor1d([3]); - const complex1 = tf.complex(real1, imag1); - - const real2 = tf.tensor1d([4]); - const imag2 = tf.tensor1d([5]); - const complex2 = tf.complex(real2, imag2); - - const result = complex1.mul(complex2); - - expect(result.dtype).toBe('complex64'); - expect(result.shape).toEqual([1]); - expectArraysClose(await result.data(), [2 * 4 - 3 * 5, 2 * 5 + 3 * 4]); - }); - - it('complex number broadcasting multiplication', async () => { - const real1 = tf.tensor2d([1, 2, -3, -4], [2, 2]); - const imag1 = tf.tensor2d([10, 20, -30, -40], [2, 2]); - const complex1 = tf.complex(real1, imag1); - - const real2 = tf.tensor1d([4]); - const imag2 = tf.tensor1d([5]); - const complex2 = tf.complex(real2, imag2); - - const result = tf.mul(complex1, complex2); - - expect(result.dtype).toEqual('complex64'); - expect(result.shape).toEqual([2, 2]); - expectArraysClose(await result.data(), [ - 1 * 4 - 10 * 5, 1 * 5 + 10 * 4, 2 * 4 - 20 * 5, 2 * 5 + 20 * 4, - -3 * 4 + 30 * 5, -3 * 5 + -30 * 4, -4 * 4 + 40 * 5, -4 * 5 + -40 * 4 - ]); - }); - - it('throws when passed a as a non-tensor', () => { - expect(() => tf.mul({} as tf.Tensor, tf.scalar(1))) - .toThrowError(/Argument 'a' passed to 'mul' must be a Tensor/); - }); - it('throws when passed b as a non-tensor', () => { - expect(() => tf.mul(tf.scalar(1), {} as tf.Tensor)) - .toThrowError(/Argument 'b' passed to 'mul' must be a Tensor/); - }); - it('upcasts when dtypes dont match', async () => { - let res = tf.mul(tf.scalar(2, 'int32'), tf.scalar(3, 'float32')); - expect(res.dtype).toBe('float32'); - expectArraysClose(await res.data(), [6]); - - res = tf.mul(tf.scalar(2, 'int32'), tf.scalar(true, 'bool')); - expect(res.dtype).toBe('int32'); - expectArraysClose(await res.data(), [2]); - - res = tf.mul(tf.scalar(2, 'int32'), tf.scalar(false, 'bool')); - expect(res.dtype).toBe('int32'); - expectArraysClose(await res.data(), [0]); - }); - - it('accepts a tensor-like object', async () => { - const result = tf.mul([[1, 2], [-3, -4]], 2); - expect(result.shape).toEqual([2, 2]); - expectArraysClose(await result.data(), [2, 4, -6, -8]); - }); -}); - -describeWithFlags('pow', ALL_ENVS, () => { - it('same-shaped tensors', async () => { - const a = tf.tensor2d([1, -2, -3, 0, 7, 1], [2, 3]); - const b = tf.tensor2d([5, 3, 4, 5, 2, -3], [2, 3], 'int32'); - const expected = [1, -8, 81, 0, 49, 1]; - const result = tf.pow(a, b); - - expect(result.shape).toEqual([2, 3]); - expectArraysClose(await result.data(), expected, 0.01); - }); - - it('TensorLike', async () => { - const a = [1, 2, 3]; - const exp = 2; - - const result = tf.pow(a, exp); - - expect(result.shape).toEqual([3]); - expect(result.dtype).toBe('float32'); - expectArraysClose(await result.data(), [1, 4, 9]); - }); - - it('TensorLike chained', async () => { - const a = tf.tensor1d([1, 2, 3]); - const exp = 2; - - const result = a.pow(exp); - - expect(result.shape).toEqual([3]); - expect(result.dtype).toBe('float32'); - expectArraysClose(await result.data(), [1, 4, 9]); - }); - - it('int32^int32 returns int32', async () => { - const a = tf.tensor1d([1, 2, 3], 'int32'); - const exp = tf.scalar(2, 'int32'); - - const result = tf.pow(a, exp); - - expect(result.shape).toEqual([3]); - expect(result.dtype).toBe('int32'); - expectArraysEqual(await result.data(), [1, 4, 9]); - }); - - it('different-shaped tensors', async () => { - const a = tf.tensor2d([1, -2, -3, 0, 7, 1], [2, 3]); - const b = tf.scalar(2, 'int32'); - const expected = [1, 4, 9, 0, 49, 1]; - const result = tf.pow(a, b); - - expect(result.shape).toEqual([2, 3]); - expectArraysClose(await result.data(), expected, 0.05); - }); - - it('propagates NaNs', async () => { - const a = tf.tensor2d([NaN, 3, NaN, 0], [2, 2]); - const b = tf.tensor2d([1, 3, 2, 3], [2, 2], 'int32'); - - const result = tf.pow(a, b); - expectArraysClose(await result.data(), [NaN, 27, NaN, 0], 0.05); - }); - - it('exponent of 0 returns 1', async () => { - const a = tf.tensor1d([-2, -1, 0, 1, 2]); - const b = tf.scalar(0); - - const result = tf.pow(a, b); - expectArraysClose(await result.data(), [1, 1, 1, 1, 1]); - }); - - it('handles non int32 exponent param', async () => { - const a = tf.tensor1d([2, 4]); - const b = tf.tensor1d([.5, 1.2]); - - const result = tf.pow(a, b); - const expected = [Math.pow(2, 0.5), Math.pow(4, 1.2)]; - expectArraysClose(await result.data(), expected); - }); - - it('broadcasting same rank Tensors different shape', async () => { - const a = tf.tensor2d([1, 2, -3, -4], [2, 2]); - const b = tf.tensor2d([2, 1], [2, 1], 'int32'); - - const result = tf.pow(a, b); - - expect(result.shape).toEqual([2, 2]); - const expected = [1, 4, -3, -4]; - - expectArraysClose(await result.data(), expected); - }); - - it('broadcast 2D + 1D', async () => { - const a = tf.tensor2d([1, 2, -3, -4], [2, 2]); - const b = tf.tensor1d([1, 2], 'int32'); - - const result = tf.pow(a, b); - - expect(result.shape).toEqual([2, 2]); - const expected = [1, 4, -3, 16]; - - expectArraysClose(await result.data(), expected); - }); - - it('gradients: Scalar ^ Scalar', async () => { - const a = tf.scalar(5); - const b = tf.scalar(2, 'int32'); - const dy = tf.scalar(3); - - const grads = tf.grads((a, b) => tf.pow(a, b)); - const [da, db] = grads([a, b], dy); - - expect(da.shape).toEqual(a.shape); - expect(da.dtype).toEqual('float32'); - expectArraysClose(await da.data(), [2 * 5 * 3]); - - expect(db.shape).toEqual(b.shape); - expect(db.dtype).toEqual('float32'); - expectArraysClose(await db.data(), [3 * Math.pow(5, 2) * Math.log(5)]); - }); - - it('gradient with clones', async () => { - const a = tf.scalar(5); - const b = tf.scalar(2, 'int32'); - - const grads = tf.grads((a, b) => tf.pow(a.clone(), b.clone()).clone()); - const [da, db] = grads([a, b]); - - expect(da.shape).toEqual(a.shape); - expect(da.dtype).toEqual('float32'); - expectArraysClose(await da.data(), [2 * 5]); - - expect(db.shape).toEqual(b.shape); - expect(db.dtype).toEqual('float32'); - expectArraysClose(await db.data(), [Math.pow(5, 2) * Math.log(5)]); - }); - - it('gradients: x ^ 2 where x = 0', async () => { - const f = (x: tf.Scalar) => x.pow(tf.scalar(2)).asScalar(); - const g = tf.grad(f)(tf.scalar(0)); - - expectArraysClose(await g.data(), [0]); - }); - - it('gradients: Scalar ^ Scalar fractional exponent', async () => { - const a = tf.scalar(4.0); - const b = tf.scalar(1.5); - const dy = tf.scalar(3.0); - - const grads = tf.grads((a, b) => tf.pow(a, b)); - const [da, db] = grads([a, b], dy); - - expect(da.shape).toEqual(a.shape); - expect(da.dtype).toEqual('float32'); - expectArraysClose(await da.data(), [1.5 * Math.pow(4, 0.5) * 3]); - - expect(db.shape).toEqual(b.shape); - expect(db.dtype).toEqual('float32'); - expectArraysClose( - await db.data(), [3.0 * Math.pow(4, 1.5) * Math.log(4.0)]); - }); - - it('gradients: Tensor ^ Tensor', async () => { - const a = tf.tensor1d([-1, .5, 2]); - const b = tf.tensor1d([3, 2, -1], 'int32'); - const dy = tf.tensor1d([1, 5, 10]); - - const grads = tf.grads((a, b) => tf.pow(a, b)); - const [da, db] = grads([a, b], dy); - - expect(da.shape).toEqual(a.shape); - expect(da.dtype).toEqual('float32'); - expectArraysClose( - await da.data(), - [ - 3 * Math.pow(-1, 2) * 1, 2 * Math.pow(.5, 1) * 5, - -1 * Math.pow(2, -2) * 10 - ], - 1e-1); - - expect(db.shape).toEqual(b.shape); - expect(db.dtype).toEqual('float32'); - expectArraysClose(await db.data(), [ - 0, 5 * Math.pow(.5, 2) * Math.log(.5), 10 * Math.pow(2, -1) * Math.log(2) - ]); - }); - - it('gradient wrt exponent with negative base', async () => { - const a = tf.tensor1d([-1, -.5, -2.7]); - const b = tf.tensor1d([3, 2, -1], 'int32'); - const dy = tf.tensor1d([1, 1, 1]); - - const grads = tf.grads((a, b) => tf.pow(a, b)); - const [, db] = grads([a, b], dy); - - expect(db.shape).toEqual(b.shape); - expect(db.dtype).toEqual('float32'); - expectArraysClose(await db.data(), [0, 0, 0]); - }); - - it('gradient: scalar / Tensor1D', async () => { - const a = tf.scalar(2); - const b = tf.tensor1d([3, 4, 5]); - const dy = tf.tensor1d([6, 7, 8]); - - const grads = tf.grads((a, b) => tf.pow(a, b)); - const [da, db] = grads([a, b], dy); - - expect(da.shape).toEqual(a.shape); - expect(da.dtype).toEqual('float32'); - expectArraysClose(await da.data(), [ - 6 * 3 * Math.pow(2, 2) + 7 * 4 * Math.pow(2, 3) + 8 * 5 * Math.pow(2, 4) - ]); - - expect(db.shape).toEqual(b.shape); - expect(db.dtype).toEqual('float32'); - expectArraysClose(await db.data(), [ - 6 * Math.pow(2, 3) * Math.log(2), 7 * Math.pow(2, 4) * Math.log(2), - 8 * Math.pow(2, 5) * Math.log(2) - ]); - }); - - it('gradient: Tensor2D / scalar', async () => { - const a = tf.tensor2d([[2, 3], [4, 5]], [2, 2]); - const b = tf.scalar(2); - const dy = tf.tensor2d([[6, 7], [8, 9]], [2, 2]); - - const grads = tf.grads((a, b) => tf.pow(a, b)); - const [da, db] = grads([a, b], dy); - - expect(da.shape).toEqual(a.shape); - expect(da.dtype).toEqual('float32'); - expectArraysClose(await da.data(), [ - 6 * 2 * Math.pow(2, 1), 7 * 2 * Math.pow(3, 1), 8 * 2 * Math.pow(4, 1), - 9 * 2 * Math.pow(5, 1) - ]); - - expect(db.shape).toEqual(b.shape); - expect(db.dtype).toEqual('float32'); - expectArraysClose( - await db.data(), - [6 * Math.pow(2, 2) * Math.log(2) + 7 * Math.pow(3, 2) * Math.log(3) + - 8 * Math.pow(4, 2) * Math.log(4) + 9 * Math.pow(5, 2) * Math.log(5)]); - }); - - it('gradient: Tensor2D / Tensor2D w/ broadcast', async () => { - const a = tf.tensor2d([3, 4], [2, 1]); - const b = tf.tensor2d([[2, 3], [.4, .5]], [2, 2]); - const dy = tf.tensor2d([[6, 7], [8, 9]], [2, 2]); - - const grads = tf.grads((a, b) => tf.pow(a, b)); - const [da, db] = grads([a, b], dy); - - expect(da.shape).toEqual(a.shape); - expect(da.dtype).toEqual('float32'); - expectArraysClose(await da.data(), [ - 6 * 2 * Math.pow(3, 1) + 7 * 3 * Math.pow(3, 2), - 8 * .4 * Math.pow(4, .4 - 1) + 9 * .5 * Math.pow(4, .5 - 1) - ]); - - expect(db.shape).toEqual(b.shape); - expect(db.dtype).toEqual('float32'); - expectArraysClose(await db.data(), [ - 6 * Math.pow(3, 2) * Math.log(3), 7 * Math.pow(3, 3) * Math.log(3), - 8 * Math.pow(4, .4) * Math.log(4), 9 * Math.pow(4, .5) * Math.log(4) - ]); - }); - - it('throws when passed base as a non-tensor', () => { - expect(() => tf.pow({} as tf.Tensor, tf.scalar(1))) - .toThrowError(/Argument 'base' passed to 'pow' must be a Tensor/); - }); - it('throws when passed exp as a non-tensor', () => { - expect(() => tf.pow(tf.scalar(1), {} as tf.Tensor)) - .toThrowError(/Argument 'exp' passed to 'pow' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const result = tf.pow([1, 2, 3], 2); - - expect(result.shape).toEqual([3]); - expect(result.dtype).toBe('float32'); - expectArraysClose(await result.data(), [1, 4, 9]); - }); - - it('negative base and whole exponent not NaN', async () => { - const a = tf.tensor1d([-2, -3, -4], 'float32'); - const b = tf.tensor1d([2, -3, 4], 'float32'); - - const expected = [Math.pow(-2, 2), Math.pow(-3, -3), Math.pow(-4, 4)]; - const result = tf.pow(a, b); - - expectArraysClose(await result.data(), expected); - }); - - it('negative base and whole exponent not NaN - vec4', async () => { - const a = tf.tensor1d([-2, -3, -4, -5], 'float32'); - const b = tf.tensor1d([2, -3, 4, -5], 'float32'); - - const expected = - [Math.pow(-2, 2), Math.pow(-3, -3), Math.pow(-4, 4), Math.pow(-5, -5)]; - const result = tf.pow(a, b); - - expectArraysClose(await result.data(), expected); - }); - - it('negative base and fract exponent NaN', async () => { - const a = tf.tensor1d([-2, -3, -4], 'float32'); - const b = tf.tensor1d([2.1, -3.01, 4.1], 'float32'); - - const expected = [NaN, NaN, NaN]; - const result = tf.pow(a, b); - - expectArraysClose(await result.data(), expected); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/array_ops_util.ts b/tfjs-master/tfjs-core/src/ops/array_ops_util.ts deleted file mode 100644 index e567388a3..000000000 --- a/tfjs-master/tfjs-core/src/ops/array_ops_util.ts +++ /dev/null @@ -1,153 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -/** - * Gets the new shape of the input Tensor after it's been reshaped - * to: - * [blockShape[0], ..., blockShape[M-1], batch / prod(blockShape), - * inputShape[1], ..., inputShape[N-1]] - * - * See step 1: https://www.tensorflow.org/api_docs/python/tf/batch_to_space_nd - */ -export function getReshaped( - inputShape: number[], blockShape: number[], prod: number, - batchToSpace = true): number[] { - let reshaped: number[] = []; - if (batchToSpace) { - reshaped = reshaped.concat(blockShape.slice(0)); - reshaped.push(inputShape[0] / prod); - reshaped = reshaped.concat(inputShape.slice(1)); - } else { - reshaped = reshaped.concat(inputShape[0]); - const spatialLength = blockShape.length; - for (let i = 0; i < spatialLength; ++i) { - reshaped = - reshaped.concat([inputShape[i + 1] / blockShape[i], blockShape[i]]); - } - reshaped = reshaped.concat(inputShape.slice(spatialLength + 1)); - } - return reshaped; -} - -/** - * Gets the permutation that will transpose the dimensions of the - * reshaped tensor to shape: - * - * [batch / prod(block_shape),inputShape[1], blockShape[0], ..., - * inputShape[M], blockShape[M-1],inputShape[M+1], ..., inputShape[N-1]] - * - * see step 2: https://www.tensorflow.org/api_docs/python/tf/batch_to_space_nd - */ -export function getPermuted( - reshapedRank: number, blockShapeRank: number, - batchToSpace = true): number[] { - const permuted = []; - if (batchToSpace) { - permuted.push(blockShapeRank); - for (let i = blockShapeRank + 1; i < reshapedRank; ++i) { - if (i <= 2 * blockShapeRank) { - permuted.push(i); - permuted.push(i - (blockShapeRank + 1)); - } else { - permuted.push(i); - } - } - } else { - const permutedBeforeBatch = []; - const permutedAfterBatch = []; - for (let i = 1; i < reshapedRank; ++i) { - if (i >= blockShapeRank * 2 + 1 || i % 2 === 1) { - permutedAfterBatch.push(i); - } else { - permutedBeforeBatch.push(i); - } - } - permuted.push(...permutedBeforeBatch); - permuted.push(0); - permuted.push(...permutedAfterBatch); - } - return permuted; -} - -/** - * Gets the shape of the reshaped and permuted input Tensor before any cropping - * is applied. The new shape will be: - * - * [batch / prod(blockShape),inputShape[1] * blockShape[0], ..., - * inputShape[M] * blockShape[M-1],inputShape[M+1], ..., inputShape[N-1]] - * - * See step 3: https://www.tensorflow.org/api_docs/python/tf/batch_to_space_nd - */ -export function getReshapedPermuted( - inputShape: number[], blockShape: number[], prod: number, - batchToSpace = true): number[] { - const reshapedPermuted = []; - - if (batchToSpace) { - reshapedPermuted.push(inputShape[0] / prod); - } else { - reshapedPermuted.push(inputShape[0] * prod); - } - - for (let i = 1; i < inputShape.length; ++i) { - if (i <= blockShape.length) { - if (batchToSpace) { - reshapedPermuted.push(blockShape[i - 1] * inputShape[i]); - } else { - reshapedPermuted.push(inputShape[i] / blockShape[i - 1]); - } - } else { - reshapedPermuted.push(inputShape[i]); - } - } - - return reshapedPermuted; -} - -/** - * Converts the crops argument into the beginning coordinates of a slice - * operation. - */ -export function getSliceBeginCoords( - crops: number[][], blockShape: number): number[] { - const sliceBeginCoords = [0]; - for (let i = 0; i < blockShape; ++i) { - sliceBeginCoords.push(crops[i][0]); - } - return sliceBeginCoords; -} - -/** - * Converts the crops argument into the size of a slice operation. When - * combined with getSliceBeginCoords this function allows the reshaped and - * permuted Tensor to be cropped to its final output shape of: - * - * inputShape[1] * blockShape[0] - crops[0,0] - crops[0,1], ..., - * inputShape[M] * blockShape[M-1] -crops[M-1,0] - - * crops[M-1,1],inputShape[M+1], ..., inputShape[N-1]] - * - * See step 4: https://www.tensorflow.org/api_docs/python/tf/batch_to_space_nd - */ -export function getSliceSize( - uncroppedShape: number[], crops: number[][], blockShape: number): number[] { - const sliceSize = uncroppedShape.slice(0, 1); - for (let i = 0; i < blockShape; ++i) { - sliceSize.push(uncroppedShape[i + 1] - crops[i][0] - crops[i][1]); - } - - return sliceSize; -} diff --git a/tfjs-master/tfjs-core/src/ops/asin.ts b/tfjs-master/tfjs-core/src/ops/asin.ts deleted file mode 100644 index 64d8459cf..000000000 --- a/tfjs-master/tfjs-core/src/ops/asin.ts +++ /dev/null @@ -1,44 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {Asin, AsinInputs} from '../kernel_names'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -import {op} from './operation'; - -/** - * Computes asin of the input `tf.Tensor` element-wise: `asin(x)` - * - * ```js - * const x = tf.tensor1d([0, 1, -1, .7]); - * - * x.asin().print(); // or tf.asin(x) - * ``` - * @param x The input tensor. - * @doc {heading: 'Operations', subheading: 'Basic math'} - */ -function asin_(x: T|TensorLike): T { - const $x = convertToTensor(x, 'x', 'asin'); - const inputs: AsinInputs = {x: $x}; - - return ENGINE.runKernel(Asin, inputs as unknown as NamedTensorMap); -} -export const asin = /* @__PURE__ */ op({asin_}); diff --git a/tfjs-master/tfjs-core/src/ops/asin_test.ts b/tfjs-master/tfjs-core/src/ops/asin_test.ts deleted file mode 100644 index ff75ed18f..000000000 --- a/tfjs-master/tfjs-core/src/ops/asin_test.ts +++ /dev/null @@ -1,119 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('asin', ALL_ENVS, () => { - it('basic', async () => { - const values = [.1, -3, 2, 7, -4]; - const a = tf.tensor1d(values); - const result = tf.asin(a); - - const expected = []; - for (let i = 0; i < a.size; i++) { - expected[i] = Math.asin(values[i]); - } - expectArraysClose(await result.data(), expected); - }); - - it('propagates NaNs', async () => { - const a = tf.tensor1d([4, NaN, 0]); - const res = tf.asin(a); - expectArraysClose(await res.data(), [Math.asin(4), NaN, Math.asin(0)]); - }); - - it('gradients: Scalar', async () => { - const a = tf.scalar(0.5); - const dy = tf.scalar(8); - - const gradients = tf.grad(a => tf.asin(a))(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), [8 / Math.sqrt(1 - (0.5 * 0.5))]); - }); - - it('gradient with clones', async () => { - const a = tf.scalar(0.5); - const dy = tf.scalar(8); - - const gradients = tf.grad(a => tf.asin(a.clone()).clone())(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), [8 / Math.sqrt(1 - (0.5 * 0.5))]); - }); - - it('gradients: Tensor1D', async () => { - const aValues = [-0.1, 0.2, 0.3, -0.5]; - const dyValues = [1, 2, 3, 4]; - const a = tf.tensor1d(aValues); - const dy = tf.tensor1d(dyValues); - - const gradients = tf.grad(a => tf.asin(a))(a, dy); - - const expected = []; - for (let i = 0; i < a.size; i++) { - expected[i] = dyValues[i] / Math.sqrt(1 - (aValues[i] * aValues[i])); - } - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), expected); - }); - - it('gradients: Tensor2D', async () => { - const aValues = [-0.3, 0.1, 0.2, 0.3]; - const dyValues = [1, 2, 3, 4]; - const a = tf.tensor2d(aValues, [2, 2]); - const dy = tf.tensor2d(dyValues, [2, 2]); - - const gradients = tf.grad(a => tf.asin(a))(a, dy); - - const expected = []; - for (let i = 0; i < a.size; i++) { - expected[i] = dyValues[i] / Math.sqrt(1 - (aValues[i] * aValues[i])); - } - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), expected); - }); - - it('throws when passed a non-tensor', () => { - expect(() => tf.asin({} as tf.Tensor)) - .toThrowError(/Argument 'x' passed to 'asin' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const values = [.1, -3, 2, 7, -4]; - const result = tf.asin(values); - - const expected = []; - for (let i = 0; i < values.length; i++) { - expected[i] = Math.asin(values[i]); - } - expectArraysClose(await result.data(), expected); - }); - - it('throws for string tensor', () => { - expect(() => tf.asin('q')) - .toThrowError(/Argument 'x' passed to 'asin' must be numeric/); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/asinh.ts b/tfjs-master/tfjs-core/src/ops/asinh.ts deleted file mode 100644 index 3b7314c94..000000000 --- a/tfjs-master/tfjs-core/src/ops/asinh.ts +++ /dev/null @@ -1,47 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {Asinh, AsinhInputs} from '../kernel_names'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -import {op} from './operation'; - -/** - * Computes inverse hyperbolic sin of the input `tf.Tensor` element-wise: - * `asinh(x)` - * - * ```js - * const x = tf.tensor1d([0, 1, -1, .7]); - * - * x.asinh().print(); // or tf.asinh(x) - * ``` - * @param x The input tensor. - * - * @doc {heading: 'Operations', subheading: 'Basic math'} - */ -function asinh_(x: T|TensorLike): T { - const $x = convertToTensor(x, 'x', 'asinh'); - - const inputs: AsinhInputs = {x: $x}; - - return ENGINE.runKernel(Asinh, inputs as unknown as NamedTensorMap); -} -export const asinh = /* @__PURE__ */ op({asinh_}); diff --git a/tfjs-master/tfjs-core/src/ops/asinh_test.ts b/tfjs-master/tfjs-core/src/ops/asinh_test.ts deleted file mode 100644 index 83251b180..000000000 --- a/tfjs-master/tfjs-core/src/ops/asinh_test.ts +++ /dev/null @@ -1,139 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('asinh', ALL_ENVS, () => { - it('basic', async () => { - const values = [1, -3, 2, 7, -4]; - const a = tf.tensor1d(values); - const result = tf.asinh(a); - - const expected = []; - for (let i = 0; i < a.size; i++) { - expected[i] = Math.asinh(values[i]); - } - expectArraysClose(await result.data(), expected); - }); - - it('scalar', async () => { - const a = tf.scalar(1); - const result = tf.asinh(a); - - const expected = [Math.asinh(1)]; - expectArraysClose(await result.data(), expected); - }); - - it('tensor2D', async () => { - const values = [1, -3, 2, 7]; - const a = tf.tensor2d(values, [2, 2]); - const result = tf.asinh(a); - - const expected = []; - for (let i = 0; i < a.size; i++) { - expected[i] = Math.asinh(values[i]); - } - expectArraysClose(await result.data(), expected); - }); - - it('propagates NaNs', async () => { - const a = tf.tensor1d([4, NaN, 0]); - const res = tf.asinh(a); - expectArraysClose(await res.data(), [Math.asinh(4), NaN, Math.asinh(0)]); - }); - - it('gradients: Scalar', async () => { - const a = tf.scalar(0.5); - const dy = tf.scalar(8); - - const gradients = tf.grad(a => tf.asinh(a))(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), [8 / Math.sqrt(1.0 + 0.5 * 0.5)]); - }); - - it('gradient with clones', async () => { - const a = tf.scalar(0.5); - const dy = tf.scalar(8); - - const gradients = tf.grad(a => tf.asinh(a.clone()).clone())(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), [8 / Math.sqrt(1.0 + 0.5 * 0.5)]); - }); - - it('gradients: Tensor1D', async () => { - const aValues = [-1, 2, 3, -5]; - const dyValues = [1, 2, 3, 4]; - const a = tf.tensor1d(aValues); - const dy = tf.tensor1d(dyValues); - - const gradients = tf.grad(a => tf.asinh(a))(a, dy); - - const expected = []; - for (let i = 0; i < a.size; i++) { - expected[i] = dyValues[i] / Math.sqrt(1 + aValues[i] * aValues[i]); - } - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), expected); - }); - - it('gradients: Tensor2D', async () => { - const aValues = [-3, 1, 2, 3]; - const dyValues = [1, 2, 3, 4]; - const a = tf.tensor2d(aValues, [2, 2]); - const dy = tf.tensor2d(dyValues, [2, 2]); - - const gradients = tf.grad(a => tf.asinh(a))(a, dy); - - const expected = []; - for (let i = 0; i < a.size; i++) { - expected[i] = dyValues[i] / Math.sqrt(1 + aValues[i] * aValues[i]); - } - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), expected); - }); - - it('throws when passed a non-tensor', () => { - expect(() => tf.asinh({} as tf.Tensor)) - .toThrowError(/Argument 'x' passed to 'asinh' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const values = [1, -3, 2, 7, -4]; - const result = tf.asinh(values); - - const expected = []; - for (let i = 0; i < values.length; i++) { - expected[i] = Math.asinh(values[i]); - } - expectArraysClose(await result.data(), expected); - }); - - it('throws for string tensor', () => { - expect(() => tf.asinh('q')) - .toThrowError(/Argument 'x' passed to 'asinh' must be numeric/); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/atan.ts b/tfjs-master/tfjs-core/src/ops/atan.ts deleted file mode 100644 index b56e20283..000000000 --- a/tfjs-master/tfjs-core/src/ops/atan.ts +++ /dev/null @@ -1,46 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {Atan, AtanInputs} from '../kernel_names'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -import {op} from './operation'; - -/** - * Computes atan of the input `tf.Tensor` element-wise: `atan(x)` - * - * ```js - * const x = tf.tensor1d([0, 1, -1, .7]); - * - * x.atan().print(); // or tf.atan(x) - * ``` - * @param x The input tensor. - * - * @doc {heading: 'Operations', subheading: 'Basic math'} - */ -function atan_(x: T|TensorLike): T { - const $x = convertToTensor(x, 'x', 'atan'); - - const inputs: AtanInputs = {x: $x}; - - return ENGINE.runKernel(Atan, inputs as unknown as NamedTensorMap); -} -export const atan = /* @__PURE__ */ op({atan_}); diff --git a/tfjs-master/tfjs-core/src/ops/atan2.ts b/tfjs-master/tfjs-core/src/ops/atan2.ts deleted file mode 100644 index 1150a88f7..000000000 --- a/tfjs-master/tfjs-core/src/ops/atan2.ts +++ /dev/null @@ -1,55 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {Atan2, Atan2Inputs} from '../kernel_names'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {makeTypesMatch} from '../tensor_util'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -import {op} from './operation'; - -/** - * Computes arctangent of `tf.Tensor`s a / b element-wise: `atan2(a, b)`. - * Supports broadcasting. - * - * ```js - * const a = tf.tensor1d([1.0, 1.0, -1.0, .7]); - * const b = tf.tensor1d([2.0, 13.0, 3.5, .21]); - * - * tf.atan2(a, b).print() - * ``` - * - * @param a The first tensor. - * @param b The second tensor. Must have the same dtype as `a`. - * - * @doc {heading: 'Operations', subheading: 'Basic math'} - */ -function atan2_( - a: Tensor|TensorLike, b: Tensor|TensorLike): T { - let $a = convertToTensor(a, 'a', 'atan2'); - let $b = convertToTensor(b, 'b', 'atan2'); - [$a, $b] = makeTypesMatch($a, $b); - - const inputs: Atan2Inputs = {a: $a, b: $b}; - - return ENGINE.runKernel(Atan2, inputs as unknown as NamedTensorMap); -} - -export const atan2 = /* @__PURE__ */ op({atan2_}); diff --git a/tfjs-master/tfjs-core/src/ops/atan_test.ts b/tfjs-master/tfjs-core/src/ops/atan_test.ts deleted file mode 100644 index 79b7b8579..000000000 --- a/tfjs-master/tfjs-core/src/ops/atan_test.ts +++ /dev/null @@ -1,130 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('atan', ALL_ENVS, () => { - it('basic', async () => { - const values = [1, -3, 2, 7, -4]; - const a = tf.tensor1d(values); - const result = tf.atan(a); - - const expected = []; - for (let i = 0; i < a.size; i++) { - expected[i] = Math.atan(values[i]); - } - expectArraysClose(await result.data(), expected); - }); - - it('6D atan', async () => { - const a = tf.range(1, 65).reshape([2, 2, 2, 2, 2, 2]); - const result = tf.atan(a); - - const expected = []; - for (let i = 1; i < 65; ++i) { - expected[i - 1] = Math.atan(i); - } - expectArraysClose(await result.data(), expected); - }); - - it('propagates NaNs', async () => { - const a = tf.tensor1d([4, NaN, 0]); - const res = tf.atan(a); - expectArraysClose(await res.data(), [Math.atan(4), NaN, Math.atan(0)]); - }); - - it('gradients: Scalar', async () => { - const a = tf.scalar(0.5); - const dy = tf.scalar(8); - - const gradients = tf.grad(a => tf.atan(a))(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), [8 / (1 + (0.5 * 0.5))]); - }); - - it('gradient with clones', async () => { - const a = tf.scalar(0.5); - const dy = tf.scalar(8); - - const gradients = tf.grad(a => tf.atan(a.clone()).clone())(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), [8 / (1 + (0.5 * 0.5))]); - }); - - it('gradients: Tensor1D', async () => { - const aValues = [-0.1, 0.2, 0.3, -0.5]; - const dyValues = [1, 2, 3, 4]; - const a = tf.tensor1d(aValues); - const dy = tf.tensor1d(dyValues); - - const gradients = tf.grad(a => tf.atan(a))(a, dy); - - const expected = []; - for (let i = 0; i < a.size; i++) { - expected[i] = dyValues[i] / (1 + (aValues[i] * aValues[i])); - } - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), expected); - }); - - it('gradients: Tensor2D', async () => { - const aValues = [-0.3, 0.1, 0.2, 0.3]; - const dyValues = [1, 2, 3, 4]; - const a = tf.tensor2d(aValues, [2, 2]); - const dy = tf.tensor2d(dyValues, [2, 2]); - - const gradients = tf.grad(a => tf.atan(a))(a, dy); - - const expected = []; - for (let i = 0; i < a.size; i++) { - expected[i] = dyValues[i] / (1 + (aValues[i] * aValues[i])); - } - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), expected); - }); - - it('throws when passed a non-tensor', () => { - expect(() => tf.atan({} as tf.Tensor)) - .toThrowError(/Argument 'x' passed to 'atan' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const values = [1, -3, 2, 7, -4]; - const result = tf.atan(values); - - const expected = []; - for (let i = 0; i < values.length; i++) { - expected[i] = Math.atan(values[i]); - } - expectArraysClose(await result.data(), expected); - }); - - it('throws for string tensor', () => { - expect(() => tf.atan('q')) - .toThrowError(/Argument 'x' passed to 'atan' must be numeric/); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/atanh.ts b/tfjs-master/tfjs-core/src/ops/atanh.ts deleted file mode 100644 index 417cc5282..000000000 --- a/tfjs-master/tfjs-core/src/ops/atanh.ts +++ /dev/null @@ -1,47 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {Atanh, AtanhInputs} from '../kernel_names'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -import {op} from './operation'; - -/** - * Computes inverse hyperbolic tan of the input `tf.Tensor` element-wise: - * `atanh(x)` - * - * ```js - * const x = tf.tensor1d([0, .1, -.1, .7]); - * - * x.atanh().print(); // or tf.atanh(x) - * ``` - * @param x The input tensor. - * - * @doc {heading: 'Operations', subheading: 'Basic math'} - */ -function atanh_(x: T|TensorLike): T { - const $x = convertToTensor(x, 'x', 'atanh'); - - const inputs: AtanhInputs = {x: $x}; - - return ENGINE.runKernel(Atanh, inputs as unknown as NamedTensorMap); -} -export const atanh = /* @__PURE__ */ op({atanh_}); diff --git a/tfjs-master/tfjs-core/src/ops/atanh_test.ts b/tfjs-master/tfjs-core/src/ops/atanh_test.ts deleted file mode 100644 index 26e3b4e89..000000000 --- a/tfjs-master/tfjs-core/src/ops/atanh_test.ts +++ /dev/null @@ -1,140 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('atanh', ALL_ENVS, () => { - it('basic', async () => { - const values = [-0.25, 0.25, 0.5, .75, -0.4]; - const a = tf.tensor1d(values); - const result = tf.atanh(a); - - const expected = []; - for (let i = 0; i < a.size; i++) { - expected[i] = Math.atanh(values[i]); - } - expectArraysClose(await result.data(), expected); - }); - - it('scalar', async () => { - const value = 0.2; - const a = tf.scalar(value); - const result = tf.atanh(a); - - const expected = [Math.atanh(value)]; - expectArraysClose(await result.data(), expected); - }); - - it('tensor2d', async () => { - const values = [0.2, 0.3, 0.4, 0.5]; - const a = tf.tensor2d(values, [2, 2]); - const result = tf.atanh(a); - - const expected = []; - for (let i = 0; i < a.size; i++) { - expected[i] = Math.atanh(values[i]); - } - expectArraysClose(await result.data(), expected); - }); - - it('propagates NaNs', async () => { - const a = tf.tensor1d([0.5, NaN, 0]); - const res = tf.atanh(a); - expectArraysClose(await res.data(), [Math.atanh(0.5), NaN, Math.atanh(0)]); - }); - - it('NaN outside function domain', async () => { - const a = tf.tensor1d([-2, 0, 2]); - const res = tf.atanh(a); - expectArraysClose(await res.data(), [NaN, Math.atanh(0), NaN]); - }); - - it('gradients: Scalar', async () => { - const a = tf.scalar(0.5); - const dy = tf.scalar(8); - - const gradients = tf.grad(a => tf.atanh(a))(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), [8 / (1 - 0.5 * 0.5)]); - }); - - it('gradient with clones', async () => { - const a = tf.scalar(0.5); - const dy = tf.scalar(8); - - const gradients = tf.grad(a => tf.atanh(a.clone()).clone())(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), [8 / (1 - 0.5 * 0.5)]); - }); - - it('gradients: Tensor1D', async () => { - const aValues = [-0.1, 0.2, 0.3, -0.5]; - const dyValues = [1, 2, 3, 4]; - const a = tf.tensor1d(aValues); - const dy = tf.tensor1d(dyValues); - - const gradients = tf.grad(a => tf.atanh(a))(a, dy); - - const expected = []; - for (let i = 0; i < a.size; i++) { - expected[i] = dyValues[i] / (1 - Math.pow(aValues[i], 2)); - } - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), expected); - }); - - it('gradients: Tensor2D', async () => { - const aValues = [-0.3, 0.1, 0.2, 0.3]; - const dyValues = [1, 2, 3, 4]; - const a = tf.tensor2d(aValues, [2, 2]); - const dy = tf.tensor2d(dyValues, [2, 2]); - - const gradients = tf.grad(a => tf.atanh(a))(a, dy); - - const expected = []; - for (let i = 0; i < a.size; i++) { - expected[i] = dyValues[i] / (1 - Math.pow(aValues[i], 2)); - } - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), expected); - }); - - it('throws when passed a non-tensor', () => { - expect(() => tf.atanh({} as tf.Tensor)) - .toThrowError(/Argument 'x' passed to 'atanh' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const result = tf.atanh(0.2); - expectArraysClose(await result.data(), [Math.atanh(0.2)]); - }); - - it('throws for string tensor', () => { - expect(() => tf.atanh('q')) - .toThrowError(/Argument 'x' passed to 'atanh' must be numeric/); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/avg_pool.ts b/tfjs-master/tfjs-core/src/ops/avg_pool.ts deleted file mode 100644 index 8e2ce5288..000000000 --- a/tfjs-master/tfjs-core/src/ops/avg_pool.ts +++ /dev/null @@ -1,95 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {AvgPool, AvgPoolAttrs, AvgPoolInputs} from '../kernel_names'; -import {NamedAttrMap} from '../kernel_registry'; -import {Tensor3D, Tensor4D} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; -import * as util from '../util'; - -import {cast} from './cast'; -import * as conv_util from './conv_util'; -import {op} from './operation'; -import {reshape} from './reshape'; - -/** - * Computes the 2D average pooling of an image. - * - * @param x The input tensor, of rank 4 or rank 3 of shape - * `[batch, height, width, inChannels]`. If rank 3, batch of 1 is assumed. - * @param filterSize The filter size: `[filterHeight, filterWidth]`. If - * `filterSize` is a single number, then `filterHeight == filterWidth`. - * @param strides The strides of the pooling: `[strideHeight, strideWidth]`. If - * `strides` is a single number, then `strideHeight == strideWidth`. - * @param pad The type of padding algorithm: - * - `same` and stride 1: output will be of same size as input, - * regardless of filter size. - * - `valid`: output will be smaller than input if filter is larger - * than 1x1. - * - For more info, see this guide: - * [https://www.tensorflow.org/api_docs/python/tf/nn/convolution]( - * https://www.tensorflow.org/api_docs/python/tf/nn/convolution) - * @param dimRoundingMode A string from: 'ceil', 'round', 'floor'. If none is - * provided, it will default to truncate. - * - * @doc {heading: 'Operations', subheading: 'Convolution'} - */ -function avgPool_( - x: T|TensorLike, filterSize: [number, number]|number, - strides: [number, number]|number, - pad: 'valid'|'same'|number|conv_util.ExplicitPadding, - dimRoundingMode?: 'floor'|'round'|'ceil'): T { - const $x = convertToTensor(x, 'x', 'avgPool', 'float32'); - const dilations = 1; - - util.assert( - conv_util.eitherStridesOrDilationsAreOne(strides, dilations), - () => 'Error in avgPool: Either strides or dilations must be 1. ' + - `Got strides ${strides} and dilations '${dilations}'`); - - let x4D = $x as Tensor4D; - let reshapedTo4D = false; - if ($x.rank === 3) { - reshapedTo4D = true; - x4D = reshape($x, [1, $x.shape[0], $x.shape[1], $x.shape[2]]); - } - - util.assert( - x4D.rank === 4, - () => `Error in avgPool: x must be rank 4 but got rank ${x4D.rank}.`); - conv_util.checkPadOnDimRoundingMode('avgPool', pad, dimRoundingMode); - const inputs: AvgPoolInputs = {x: x4D}; - const attrs: AvgPoolAttrs = {filterSize, strides, pad, dimRoundingMode}; - - // tslint:disable-next-line: no-unnecessary-type-assertion - let res = ENGINE.runKernel( - AvgPool, inputs as unknown as NamedTensorMap, - attrs as unknown as NamedAttrMap) as T; - - res = cast(res, $x.dtype); - - if (reshapedTo4D) { - return reshape(res, [res.shape[1], res.shape[2], res.shape[3]]) as T; - } - - return res; -} - -export const avgPool = /* @__PURE__ */ op({avgPool_}); diff --git a/tfjs-master/tfjs-core/src/ops/avg_pool_3d.ts b/tfjs-master/tfjs-core/src/ops/avg_pool_3d.ts deleted file mode 100644 index 334d5afbc..000000000 --- a/tfjs-master/tfjs-core/src/ops/avg_pool_3d.ts +++ /dev/null @@ -1,115 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {AvgPool3D, AvgPool3DAttrs, AvgPool3DInputs} from '../kernel_names'; -import {NamedAttrMap} from '../kernel_registry'; -import {Tensor4D, Tensor5D} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; -import * as util from '../util'; - -import {cast} from './cast'; -import {checkPadOnDimRoundingMode} from './conv_util'; -import {op} from './operation'; -import {reshape} from './reshape'; - -/** - * Computes the 3D average pooling. - * - * ```js - * const x = tf.tensor5d([1, 2, 3, 4, 5, 6, 7, 8], [1, 2, 2, 2, 1]); - * const result = tf.avgPool3d(x, 2, 1, 'valid'); - * result.print(); - * ``` - * - * @param x The input tensor, of rank 5 or rank 4 of shape - * `[batch, depth, height, width, inChannels]`. - * @param filterSize The filter size: - * `[filterDepth, filterHeight, filterWidth]`. - * If `filterSize` is a single number, - * then `filterDepth == filterHeight == filterWidth`. - * @param strides The strides of the pooling: - * `[strideDepth, strideHeight, strideWidth]`. - * If `strides` is a single number, - * then `strideDepth == strideHeight == strideWidth`. - * @param pad The type of padding algorithm. - * - `same` and stride 1: output will be of same size as input, - * regardless of filter size. - * - `valid`: output will be smaller than input if filter is larger - * than 1*1x1. - * - For more info, see this guide: - * [https://www.tensorflow.org/api_docs/python/tf/nn/convolution]( - * https://www.tensorflow.org/api_docs/python/tf/nn/convolution) - * @param dimRoundingMode A string from: 'ceil', 'round', 'floor'. If none is - * provided, it will default to truncate. - * @param dataFormat An optional string from: "NDHWC", "NCDHW". Defaults to - * "NDHWC". Specify the data format of the input and output data. With the - * default format "NDHWC", the data is stored in the order of: [batch, - * depth, height, width, channels]. Only "NDHWC" is currently supported. - * - * @doc {heading: 'Operations', subheading: 'Convolution'} - */ -function avgPool3d_( - x: T|TensorLike, filterSize: [number, number, number]|number, - strides: [number, number, number]|number, pad: 'valid'|'same'|number, - dimRoundingMode?: 'floor'|'round'|'ceil', - dataFormat: 'NDHWC'|'NCDHW' = 'NDHWC'): T { - const $x = convertToTensor(x, 'x', 'avgPool3d', 'float32'); - - let x5D = $x as Tensor5D; - let reshapedTo5D = false; - if ($x.rank === 4) { - reshapedTo5D = true; - x5D = reshape($x, [1, $x.shape[0], $x.shape[1], $x.shape[2], $x.shape[3]]); - } - - util.assert( - x5D.rank === 5, - () => `Error in avgPool3d: x must be rank 5 but got rank ${x5D.rank}.`); - util.assert( - dataFormat === 'NDHWC', - () => `Error in avgPool3d: Only NDHWC is currently supported, ` + - `but got dataFormat of ${dataFormat}`); - util.assert( - (typeof strides === 'number' && strides > 0) || - (Array.isArray(strides) && strides[0] > 0 && strides[1] > 0 && - strides[2] > 0), - () => `Error in avgPool3d: Stride must be > 0, but got '${strides}'`); - checkPadOnDimRoundingMode('avgPool3d', pad, dimRoundingMode); - const inputs: AvgPool3DInputs = {x: x5D}; - const attrs: - AvgPool3DAttrs = {filterSize, strides, pad, dimRoundingMode, dataFormat}; - - // tslint:disable-next-line: no-unnecessary-type-assertion - let res = ENGINE.runKernel( - AvgPool3D, inputs as unknown as NamedTensorMap, - attrs as unknown as NamedAttrMap) as T; - - res = cast(res, x5D.dtype); - - if (reshapedTo5D) { - return reshape( - res, [res.shape[1], res.shape[2], res.shape[3], res.shape[4]]) as - T; - } - - return res; -} - -export const avgPool3d = /* @__PURE__ */ op({avgPool3d_}); diff --git a/tfjs-master/tfjs-core/src/ops/avg_pool_3d_grad.ts b/tfjs-master/tfjs-core/src/ops/avg_pool_3d_grad.ts deleted file mode 100644 index 73729d23c..000000000 --- a/tfjs-master/tfjs-core/src/ops/avg_pool_3d_grad.ts +++ /dev/null @@ -1,99 +0,0 @@ - -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {AvgPool3DGrad, AvgPool3DGradAttrs, AvgPool3DGradInputs} from '../kernel_names'; -import {NamedAttrMap} from '../kernel_registry'; -import {Tensor4D, Tensor5D} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; -import * as util from '../util'; - -import {checkPadOnDimRoundingMode} from './conv_util'; -import {op} from './operation'; -import {reshape} from './reshape'; - -/** - * Computes the backprop of a 3d avg pool. - * - * @param dy The dy error, of rank 5 of shape - * [batchSize, depth, height, width, channels]. - * assumed. - * @param input The original input image, of rank 5 or rank4 of shape - * [batchSize, depth, height, width, channels]. - * @param filterSize The filter size: - * `[filterDepth, filterHeight, filterWidth]`. - * `filterSize` is a single number, - * then `filterDepth == filterHeight == filterWidth`. - * @param strides The strides of the pooling: - * `[strideDepth, strideHeight, strideWidth]`. If - * `strides` is a single number, then `strideHeight == strideWidth`. - * @param pad A string from: 'same', 'valid'. The type of padding algorithm - * used in the forward prop of the op. - * @param dimRoundingMode A string from: 'ceil', 'round', 'floor'. If none is - * provided, it will default to truncate. - */ -function avgPool3dGrad_( - dy: T|TensorLike, input: T|TensorLike, - filterSize: [number, number, number]|number, - strides: [number, number, number]|number, pad: 'valid'|'same'|number, - dimRoundingMode?: 'floor'|'round'|'ceil'): T { - const $dy = convertToTensor(dy, 'dy', 'avgPool3dGrad'); - const $input = convertToTensor(input, 'input', 'avgPool3dGrad'); - - let dy5D = $dy as Tensor5D; - let input5D = $input as Tensor5D; - let reshapedTo5D = false; - - if ($input.rank === 4) { - reshapedTo5D = true; - dy5D = reshape( - $dy, [1, $dy.shape[0], $dy.shape[1], $dy.shape[2], $dy.shape[3]]); - input5D = reshape($input, [ - 1, $input.shape[0], $input.shape[1], $input.shape[2], $input.shape[3] - ]); - } - - util.assert( - dy5D.rank === 5, - () => `Error in avgPool3dGrad: dy must be rank 5 but got rank ` + - `${dy5D.rank}.`); - util.assert( - input5D.rank === 5, - () => `Error in avgPool3dGrad: input must be rank 5 but got rank ` + - `${input5D.rank}.`); - checkPadOnDimRoundingMode('avgPool3dGrad', pad, dimRoundingMode); - const inputs: AvgPool3DGradInputs = {dy: dy5D, input: input5D}; - const attrs: AvgPool3DGradAttrs = {filterSize, strides, pad, dimRoundingMode}; - - // tslint:disable-next-line: no-unnecessary-type-assertion - const res = ENGINE.runKernel( - AvgPool3DGrad, inputs as unknown as NamedTensorMap, - attrs as unknown as NamedAttrMap) as T; - - if (reshapedTo5D) { - return reshape( - res, [res.shape[1], res.shape[2], res.shape[3], res.shape[4]]) as - T; - } - - return res; -} - -export const avgPool3dGrad = /* @__PURE__ */ op({avgPool3dGrad_}); diff --git a/tfjs-master/tfjs-core/src/ops/avg_pool_3d_test.ts b/tfjs-master/tfjs-core/src/ops/avg_pool_3d_test.ts deleted file mode 100644 index 7c2c12cbe..000000000 --- a/tfjs-master/tfjs-core/src/ops/avg_pool_3d_test.ts +++ /dev/null @@ -1,363 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('avgPool3d', ALL_ENVS, () => { - it('x=[2,2,2,1] f=[2,2,2] s=1 p=valid', async () => { - const x = tf.tensor4d([1, 2, 3, 4, 5, 6, 7, 8], [2, 2, 2, 1]); - - const result = tf.avgPool3d(x, 2, 1, 'valid'); - - expect(result.shape).toEqual([1, 1, 1, 1]); - expectArraysClose(await result.data(), [4.5]); - }); - - it('x=[2,2,2,1] f=[1,2,2] s=1 p=valid', async () => { - const x = tf.tensor4d([1, 2, 3, 4, 5, 6, 7, 8], [2, 2, 2, 1]); - - const result = tf.avgPool3d(x, [1, 2, 2], 1, 'valid'); - - expect(result.shape).toEqual([2, 1, 1, 1]); - expectArraysClose(await result.data(), [2.5, 6.5]); - }); - - it('x=[1,1,1,1,1] f=[1,1,1] s=1 [0] => [0]', async () => { - const x = tf.tensor5d([0], [1, 1, 1, 1, 1]); - - const result = tf.avgPool3d(x, 1, 1, 0); - - expect(result.shape).toEqual([1, 1, 1, 1, 1]); - expectArraysClose(await result.data(), [0]); - }); - - it('x=[1,2,2,2,1] f=[2,2,2] s=1 p=valid', async () => { - const x = tf.tensor5d([1, 2, 3, 4, 5, 6, 7, 8], [1, 2, 2, 2, 1]); - - const result = tf.avgPool3d(x, 2, 1, 'valid'); - - expect(result.shape).toEqual([1, 1, 1, 1, 1]); - expectArraysClose(await result.data(), [4.5]); - }); - - it('x=[1,2,2,2,1] f=[2,2,2] s=1 p=same', async () => { - const x = tf.tensor5d([1, 2, 3, 4, 5, 6, 7, 8], [1, 2, 2, 2, 1]); - const expected = [4.5, 5, 5.5, 6, 6.5, 7, 7.5, 8]; - const result = tf.avgPool3d(x, 2, 1, 'same'); - - expect(result.shape).toEqual([1, 2, 2, 2, 1]); - expectArraysClose(await result.data(), expected); - }); - - it('x=[1,3,3,3,1] f=[2,2,2] s=1 p=valid', async () => { - const x = tf.tensor5d( - [ - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27 - ], - [1, 3, 3, 3, 1]); - const expected = [7.5, 8.5, 10.5, 11.5, 16.5, 17.5, 19.5, 20.5]; - const result = tf.avgPool3d(x, 2, 1, 'valid'); - - expect(result.shape).toEqual([1, 2, 2, 2, 1]); - expectArraysClose(await result.data(), expected); - }); - - it('x=[1,3,3,3,1] f=[2,2,2] s=1 p=same', async () => { - const x = tf.tensor5d( - [ - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27 - ], - [1, 3, 3, 3, 1]); - const expected = [ - 7.5, 8.5, 9, 10.5, 11.5, 12, 12, 13, 13.5, - 16.5, 17.5, 18, 19.5, 20.5, 21, 21, 22, 22.5, - 21, 22, 22.5, 24, 25, 25.5, 25.5, 26.5, 27 - ]; - const result = tf.avgPool3d(x, 2, 1, 'same'); - - expect(result.shape).toEqual([1, 3, 3, 3, 1]); - expectArraysClose(await result.data(), expected); - }); - - it('x=[1,3,3,3,1] f=[2,2,2] s=1 p=valid, propagates NaNs', async () => { - const x = tf.tensor5d( - [ - 1, 2, 3, 4, 5, 6, 7, 8, NaN, 10, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, NaN, 23, 24, 25, 26, 27 - ], - [1, 3, 3, 3, 1]); - const expected = [7.5, 8.5, 10.5, NaN, NaN, 17.5, NaN, 20.5]; - const result = tf.avgPool3d(x, 2, 1, 'valid'); - - expect(result.shape).toEqual([1, 2, 2, 2, 1]); - expectArraysClose(await result.data(), expected); - }); - - it('x=[2,3,3,3,1] f=[2,2,2] s=1 p=valid', async () => { - const x = tf.tensor5d( - [ - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, - 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, - 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54 - ], - [2, 3, 3, 3, 1]); - const expected = [ - 7.5, 8.5, 10.5, 11.5, 16.5, 17.5, 19.5, 20.5, 34.5, 35.5, 37.5, 38.5, - 43.5, 44.5, 46.5, 47.5 - ]; - const result = tf.avgPool3d(x, 2, 1, 'valid'); - - expect(result.shape).toEqual([2, 2, 2, 2, 1]); - expectArraysClose(await result.data(), expected); - }); - - it('x=[1,3,3,3,2] f=[2,2,2] s=1 p=valid', async () => { - const x = tf.tensor5d( - [ - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, - 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, - 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54 - ], - [1, 3, 3, 3, 2]); - const expected = - [14, 15, 16, 17, 20, 21, 22, 23, 32, 33, 34, 35, 38, 39, 40, 41]; - const result = tf.avgPool3d(x, 2, 1, 'valid'); - - expect(result.shape).toEqual([1, 2, 2, 2, 2]); - expectArraysClose(await result.data(), expected); - }); - - it('x=[1,2,2,2,1] f=[2,2,2] s=1 p=1 roundingMode=floor', async () => { - const x = tf.tensor5d([1, 2, 3, 4, 5, 6, 7, 8], [1, 2, 2, 2, 1]); - const expected = [ - 1, 1.5, 2, 2, 2.5, 3, 3, 3.5, 4, 3, 3.5, 4, 4, 4.5, - 5, 5, 5.5, 6, 5, 5.5, 6, 6, 6.5, 7, 7, 7.5, 8 - ]; - const result = tf.avgPool3d(x, 2, 1, 1, 'floor'); - - expect(result.shape).toEqual([1, 3, 3, 3, 1]); - expectArraysClose(await result.data(), expected); - }); - - it('x=[1,1,1,1,1] f=[1,1,3] s=1 p=valid', async () => { - // Output tensor would have a dimension of zero, if a certain filter's - // dimension is larger than the input's. - const x = tf.tensor5d([1], [1, 1, 1, 1, 1]); - const expected: number[] = []; - const result = tf.avgPool3d(x, [1, 1, 3], 1, 'valid'); - - expect(result.shape).toEqual([1, 1, 1, 0, 1]); - expectArraysClose(await result.data(), expected); - }); - - it('x=[1,1,1,4,1] f=[1,1,1] s=[1,1,2] p=0', async () => { - // Works if the padding is a number. - const x = tf.ones([1, 1, 1, 4, 1]) as tf.Tensor5D; - const expected = [1, 1]; - const result = tf.avgPool3d(x, [1, 1, 1], [1, 1, 2], 0); - - expect(result.shape).toEqual([1, 1, 1, 2, 1]); - expectArraysClose(await result.data(), expected); - }); - - it('x=[1,1,1,1,1] f=[2,2,2] s=1 p=2', async () => { - // Works if the padding is larger than filter size. - const x = tf.ones([1, 1, 1, 1, 1]) as tf.Tensor5D; - const expected = [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, - 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ]; - const result = tf.avgPool3d(x, [2, 2, 2], 1, 2); - - expect(result.shape).toEqual([1, 4, 4, 4, 1]); - expectArraysClose(await result.data(), expected); - }); - - it('throws when x is not rank 5', async () => { - // tslint:disable-next-line:no-any - const x: any = tf.tensor1d([1]); - - expect(() => tf.avgPool3d(x as tf.Tensor5D, 2, 1, 'valid')).toThrowError(); - }); - - it('throws when dimRoundingMode is set and pad is same', async () => { - const x = tf.tensor5d([1], [1, 1, 1, 1, 1]); - const pad = 'same'; - const dimRoundingMode = 'round'; - - expect(() => tf.avgPool3d(x, 2, 1, pad, dimRoundingMode)).toThrowError(); - }); - - it('throws when dimRoundingMode is set and pad is valid', async () => { - const x = tf.tensor5d([1], [1, 1, 1, 1, 1]); - const pad = 'valid'; - const dimRoundingMode = 'round'; - - expect(() => tf.avgPool3d(x, 2, 1, pad, dimRoundingMode)).toThrowError(); - }); - - it('throws when dimRoundingMode is set and pad is a non-integer number', - async () => { - const x = tf.tensor5d([1], [1, 1, 1, 1, 1]); - const pad = 1.2; - const dimRoundingMode = 'round'; - - expect(() => tf.avgPool3d(x, 2, 1, pad, dimRoundingMode)).toThrowError(); - }); - - it('throws when passed a non-tensor', () => { - expect(() => tf.avgPool3d({} as tf.Tensor5D, 2, 1, 'valid')).toThrowError(); - }); - - it('throws when input dtype is not float32', () => { - const a = tf.tensor5d([1], [1, 1, 1, 1, 1], 'int32'); - expect(() => tf.avgPool3d(a, 2, 1, 0)).toThrowError(); - }); - - it('accepts a tensor-like object', async () => { - const x = [[[[[0]]]]]; // 1x1x1x1x1 - const result = tf.avgPool3d(x, 1, 1, 0); - expect(result.shape).toEqual([1, 1, 1, 1, 1]); - expectArraysClose(await result.data(), [0]); - }); -}); - -describeWithFlags('avgPool3dBackprop', ALL_ENVS, () => { - it('gradient x=[2,2,2,1] f=[1,1,1] s=1', async () => { - const dy = tf.tensor4d([1, 2, 3, 4, 5, 6, 7, 8], [2, 2, 2, 1]); - const x: tf.Tensor4D = tf.ones([2, 2, 2, 1]); - const expected = [1, 2, 3, 4, 5, 6, 7, 8]; - - const dx = tf.grad((x: tf.Tensor4D) => tf.avgPool3d(x, 1, 1, 0))(x, dy); - - expect(dx.shape).toEqual(x.shape); - expectArraysClose(await dx.data(), expected); - }); - - it('gradient x=[1,2,2,2,1] f=[1,1,1] s=1', async () => { - const dy = tf.tensor5d([1, 2, 3, 4, 5, 6, 7, 8], [1, 2, 2, 2, 1]); - const x: tf.Tensor5D = tf.ones([1, 2, 2, 2, 1]); - const expected = [1, 2, 3, 4, 5, 6, 7, 8]; - - const dx = tf.grad((x: tf.Tensor5D) => tf.avgPool3d(x, 1, 1, 0))(x, dy); - - expect(dx.shape).toEqual(x.shape); - expectArraysClose(await dx.data(), expected); - }); - - it('gradient x=[1,2,2,2,1] f=[2,2,2] s=2', async () => { - const dy = tf.tensor5d([8], [1, 1, 1, 1, 1]); - const x: tf.Tensor5D = tf.ones([1, 2, 2, 2, 1]); - const expected = [1, 1, 1, 1, 1, 1, 1, 1]; - - const dx = tf.grad((x: tf.Tensor5D) => tf.avgPool3d(x, 2, 1, 0))(x, dy); - - expect(dx.shape).toEqual(x.shape); - expectArraysClose(await dx.data(), expected); - }); - - it('gradient with clone x=[1,2,2,2,1] f=[2,2,2] s=1', async () => { - const dy = tf.tensor5d([8], [1, 1, 1, 1, 1]); - const x: tf.Tensor5D = tf.ones([1, 2, 2, 2, 1]); - const expected = [1, 1, 1, 1, 1, 1, 1, 1]; - - const dx = tf.grad( - (x: tf.Tensor5D) => tf.avgPool3d(x.clone(), 2, 1, 0).clone())(x, dy); - - expect(dx.shape).toEqual(x.shape); - expectArraysClose(await dx.data(), expected); - }); - - it('gradient x=[1,3,3,3,1] f=[2,2,2] s=1', async () => { - const dy = tf.tensor5d([1, 2, 3, 4, 5, 6, 7, 8], [1, 2, 2, 2, 1]); - const x: tf.Tensor5D = tf.ones([1, 3, 3, 3, 1]); - const expected = [ - 0.125, 0.375, 0.25, 0.5, 1.25, 0.75, 0.375, 0.875, 0.5, - 0.75, 1.75, 1, 2, 4.5, 2.5, 1.25, 2.75, 1.5, - 0.625, 1.375, 0.75, 1.5, 3.25, 1.75, 0.875, 1.875, 1 - ]; - - const dx = tf.grad((x: tf.Tensor5D) => tf.avgPool3d(x, 2, 1, 0))(x, dy); - - expect(dx.shape).toEqual(x.shape); - expectArraysClose(await dx.data(), expected); - }); - - it('gradient x=[1,4,4,4,1] f=[2,2,2] s=2', async () => { - const dy = tf.tensor5d([1, 2, 3, 4, 5, 6, 7, 8], [1, 2, 2, 2, 1]); - const x: tf.Tensor5D = tf.ones([1, 4, 4, 4, 1]); - const expected = [ - 0.125, 0.125, 0.25, 0.25, 0.125, 0.125, 0.25, 0.25, 0.375, 0.375, - 0.5, 0.5, 0.375, 0.375, 0.5, 0.5, 0.125, 0.125, 0.25, 0.25, - 0.125, 0.125, 0.25, 0.25, 0.375, 0.375, 0.5, 0.5, 0.375, 0.375, - 0.5, 0.5, 0.625, 0.625, 0.75, 0.75, 0.625, 0.625, 0.75, 0.75, - 0.875, 0.875, 1, 1, 0.875, 0.875, 1, 1, 0.625, 0.625, - 0.75, 0.75, 0.625, 0.625, 0.75, 0.75, 0.875, 0.875, 1, 1, - 0.875, 0.875, 1, 1 - ]; - - const dx = tf.grad((x: tf.Tensor5D) => tf.avgPool3d(x, 2, 2, 0))(x, dy); - - expect(dx.shape).toEqual(x.shape); - expectArraysClose(await dx.data(), expected); - }); - - it('gradient x=[1,3,3,3,2] f=[2,2,2] s=1', async () => { - const dy = tf.tensor5d( - [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], - [1, 2, 2, 2, 2]); - const x: tf.Tensor5D = tf.ones([1, 3, 3, 3, 2]); - const expected = [ - 0.125, 0.25, 0.5, 0.75, 0.375, 0.5, 0.75, 1, 2, 2.5, 1.25, - 1.5, 0.625, 0.75, 1.5, 1.75, 0.875, 1, 1.25, 1.5, 3, 3.5, - 1.75, 2, 3.5, 4, 8, 9, 4.5, 5, 2.25, 2.5, 5, - 5.5, 2.75, 3, 1.125, 1.25, 2.5, 2.75, 1.375, 1.5, 2.75, 3, - 6, 6.5, 3.25, 3.5, 1.625, 1.75, 3.5, 3.75, 1.875, 2 - ]; - - const dx = tf.grad((x: tf.Tensor5D) => tf.avgPool3d(x, 2, 1, 0))(x, dy); - - expect(dx.shape).toEqual(x.shape); - expectArraysClose(await dx.data(), expected); - }); - - it('gradient x=[2,3,3,3,1] f=[2,2,2] s=1', async () => { - const dy = tf.tensor5d( - [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], - [2, 2, 2, 2, 1]); - const x: tf.Tensor5D = tf.ones([2, 3, 3, 3, 1]); - const expected = [ - 0.125, 0.375, 0.25, 0.5, 1.25, 0.75, 0.375, 0.875, 0.5, 0.75, 1.75, - 1, 2, 4.5, 2.5, 1.25, 2.75, 1.5, 0.625, 1.375, 0.75, 1.5, - 3.25, 1.75, 0.875, 1.875, 1, 1.125, 2.375, 1.25, 2.5, 5.25, 2.75, - 1.375, 2.875, 1.5, 2.75, 5.75, 3, 6, 12.5, 6.5, 3.25, 6.75, - 3.5, 1.625, 3.375, 1.75, 3.5, 7.25, 3.75, 1.875, 3.875, 2 - ]; - - const dx = tf.grad((x: tf.Tensor5D) => tf.avgPool3d(x, 2, 1, 0))(x, dy); - - expect(dx.shape).toEqual(x.shape); - expectArraysClose(await dx.data(), expected); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/avg_pool_grad.ts b/tfjs-master/tfjs-core/src/ops/avg_pool_grad.ts deleted file mode 100644 index 8f87f1a13..000000000 --- a/tfjs-master/tfjs-core/src/ops/avg_pool_grad.ts +++ /dev/null @@ -1,96 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {AvgPoolGrad, AvgPoolGradAttrs, AvgPoolGradInputs} from '../kernel_names'; -import {NamedAttrMap} from '../kernel_registry'; -import {Tensor3D, Tensor4D} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; -import * as util from '../util'; - -import {ExplicitPadding} from './conv_util'; -import {op} from './operation'; -import {reshape} from './reshape'; - -/** - * Computes the backprop of an 2D avg pool. - * - * @param dy The dy error, of rank 4 or rank 3 of shape - * [batchSize, height, width, channels]. If rank 3, batch of 1 is - * assumed. - * @param input The input image, of rank 4 or rank 3 of shape - * [batchSize, height, width, channels]. If rank 3, batch of 1 is - * assumed. - * @param filterSize The filter size: `[filterHeight, filterWidth]`. If - * `filterSize` is a single number, then `filterHeight == filterWidth`. - * @param strides The strides of the pooling: `[strideHeight, strideWidth]`. If - * `strides` is a single number, then `strideHeight == strideWidth`. - * @param pad The type of padding algorithm used in the forward prop of the op. - * 'same', 'valid', for more info, see this guide: - * [https://www.tensorflow.org/api_docs/python/tf/nn/convolution]( - * https://www.tensorflow.org/api_docs/python/tf/nn/convolution) - */ -function avgPoolGrad_( - dy: T|TensorLike, input: T|TensorLike, filterSize: [number, number]|number, - strides: [number, number]|number, - pad: 'valid'|'same'|number|ExplicitPadding): T { - const $dy = convertToTensor(dy, 'dy', 'avgPoolGrad'); - const $input = convertToTensor(input, 'input', 'avgPoolGrad'); - - util.assert( - $input.rank === $dy.rank, - () => `Rank of input (${$input.rank}) does not match rank of dy (${ - $dy.rank})`); - - let input4D = $input as Tensor4D; - let dy4D = $dy as Tensor4D; - let reshapedTo4D = false; - - if ($input.rank === 3) { - reshapedTo4D = true; - input4D = - reshape($input, [1, $input.shape[0], $input.shape[1], $input.shape[2]]); - dy4D = reshape($dy, [1, $dy.shape[0], $dy.shape[1], $dy.shape[2]]); - } - - util.assert( - dy4D.rank === 4, - () => `Error in avgPoolGrad: dy must be rank 4 but got rank ` + - `${dy4D.rank}.`); - util.assert( - input4D.rank === 4, - () => `Error in avgPoolGrad: input must be rank 4 but got rank ` + - `${input4D.rank}.`); - - const inputs: AvgPoolGradInputs = {dy: dy4D, input: input4D}; - - const attrs: AvgPoolGradAttrs = {filterSize, strides, pad}; - - // tslint:disable-next-line: no-unnecessary-type-assertion - const res = ENGINE.runKernel( - AvgPoolGrad, inputs as unknown as NamedTensorMap, - attrs as unknown as NamedAttrMap) as T; - - if (reshapedTo4D) { - return reshape(res, [res.shape[1], res.shape[2], res.shape[3]]) as T; - } - return res; -} - -export const avgPoolGrad = /* @__PURE__ */ op({avgPoolGrad_}); diff --git a/tfjs-master/tfjs-core/src/ops/avg_pool_test.ts b/tfjs-master/tfjs-core/src/ops/avg_pool_test.ts deleted file mode 100644 index 2f9a19181..000000000 --- a/tfjs-master/tfjs-core/src/ops/avg_pool_test.ts +++ /dev/null @@ -1,277 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; -import {identityPoolTest} from './identity_pool_test'; - -describeWithFlags('avgPool', ALL_ENVS, () => { - it('x=[1,1,1] f=[1,1] s=1 [0] => [0]', async () => { - const a = tf.tensor3d([0], [1, 1, 1]); - const result = tf.avgPool(a, 1, 1, 0); - expectArraysClose(await result.data(), [0]); - }); - - it('x=[3,3,1] f=[2,2] s=1', async () => { - // Feed forward. - const a = tf.tensor3d([1, 2, 3, 4, 5, 6, 7, 9, 8], [3, 3, 1]); - const result = tf.avgPool(a, 2, 1, 0); - - expect(result.shape).toEqual([2, 2, 1]); - expect(result.dtype).toBe('float32'); - expectArraysClose(await result.data(), [3, 4, 6.25, 7]); - }); - - it('input int32 throws error', () => { - // Feed forward. - const a = tf.tensor3d([1, 2, 3, 4, 5, 6, 7, 9, 8], [3, 3, 1], 'int32'); - expect(() => tf.avgPool(a, 2, 1, 0)).toThrowError(); - }); - - it('x=[2,3,3,1] f=[2,2], s=1', async () => { - // Feed forward. - const a = tf.tensor4d( - [1, 2, 3, 4, 5, 6, 7, 9, 8, 1, 2, 3, 4, 5, 6, 7, 8, 9], [2, 3, 3, 1]); - const result = tf.avgPool(a, 2, 1, 0); - - expect(result.shape).toEqual([2, 2, 2, 1]); - expectArraysClose(await result.data(), [3, 4, 6.25, 7, 3, 4, 6, 7]); - }); - - it('x=[3,3,1] f=[2,2] s=1 propagates NaNs', async () => { - // Feed forward. - const a = tf.tensor3d([1, 2, 3, 4, 5, 6, 7, NaN, 8], [3, 3, 1]); - const result = tf.avgPool(a, 2, 1, 0); - - expect(result.shape).toEqual([2, 2, 1]); - expectArraysClose(await result.data(), [3, 4, NaN, NaN]); - }); - - it('x=[3,3,2] f=[2,2] s=1', async () => { - // Feed forward. - const a = tf.tensor3d( - [1, 99, 2, 88, 3, 77, 4, 66, 5, 55, 6, 44, 7, 33, 9, 22, 8, 11], - [3, 3, 2]); - const result = tf.avgPool(a, 2, 1, 0); - - expect(result.shape).toEqual([2, 2, 2]); - expectArraysClose(await result.data(), [3, 77, 4, 66, 6.25, 44, 7, 33]); - }); - - it('x=[4,4,1] f=[2,2] s=2', async () => { - // Feed forward. - const a = tf.tensor3d( - [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], [4, 4, 1]); - const result = tf.avgPool(a, 2, 2, 0); - - expect(result.shape).toEqual([2, 2, 1]); - expectArraysClose(await result.data(), [2.5, 4.5, 10.5, 12.5]); - }); - - it('x=[2,2,1] f=[2,2] s=1 p=same', async () => { - // Feed forward. - const a = tf.tensor3d([1, 2, 3, 4], [2, 2, 1]); - const fSize = 2; - const strides = 1; - const result = tf.avgPool(a, fSize, strides, 'same'); - - expect(result.shape).toEqual([2, 2, 1]); - expectArraysClose(await result.data(), [2.5, 3, 3.5, 4]); - }); - - it('x=[2,2,3] f=[2,2] s=1 p=valid', async () => { - // Feed forward. - const a = tf.tensor3d([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [2, 2, 3]); - const fSize = 2; - const strides = 1; - const result = tf.avgPool(a, fSize, strides, 'valid'); - - expect(result.shape).toEqual([1, 1, 3]); - expectArraysClose(await result.data(), [5.5, 6.5, 7.5]); - }); - - it('x=[3,3,1] f=[3,3] s=1 p=explicit', async () => { - // Feed forward. - const x = tf.tensor3d([0, 1, 2, 3, 4, 5, 6, 7, 8], [3, 3, 1]); - const padding = - [[0, 0], [1, 2], [0, 1], [0, 0]] as tf.backend_util.ExplicitPadding; - const result = tf.avgPool(x, 3, 1, padding); - - expect(result.shape).toEqual([4, 2, 1]); - expectArraysClose(await result.data(), [2.5, 3, 4, 4.5, 5.5, 6, 7, 7.5]); - }); - - it('x=[2,2,3] f=[2,2] s=3 p=1 default dimRoundingMode', () => { - // Feed forward. - const x = tf.tensor3d([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [2, 2, 3]); - const result = tf.avgPool(x, 2, 3, 1); - - expect(result.shape).toEqual([1, 1, 3]); - }); - - it('x=[2,2,3] f=[1,1] s=2 p=1 dimRoundingMode=floor', () => { - // Feed forward. - const x = tf.tensor3d([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [2, 2, 3]); - const result = tf.avgPool(x, 1, 2, 1, 'floor'); - - expect(result.shape).toEqual([2, 2, 3]); - }); - - it('x=[2,2,3] f=[2,2] s=3 p=1 dimRoundingMode=floor', () => { - // Feed forward. - const x = tf.tensor3d([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [2, 2, 3]); - const result = tf.avgPool(x, 2, 3, 1, 'floor'); - - expect(result.shape).toEqual([1, 1, 3]); - }); - - it('x=[2,2,3] f=[2,2] s=3 p=1 dimRoundingMode=round', () => { - // Feed forward. - const x = tf.tensor3d([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [2, 2, 3]); - const result = tf.avgPool(x, 2, 3, 1, 'round'); - - expect(result.shape).toEqual([2, 2, 3]); - }); - - it('x=[2,2,3] f=[2,2] s=3 p=1 dimRoundingMode=ceil', () => { - // Feed forward. - const x = tf.tensor3d([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [2, 2, 3]); - const result = tf.avgPool(x, 2, 3, 1, 'ceil'); - - expect(result.shape).toEqual([2, 2, 3]); - }); - - it('gradient x=[1,1,1] f=[1,1] s=1 [0] => [0]', async () => { - const x = tf.tensor3d([0], [1, 1, 1]); - const dy = tf.tensor3d([0], [1, 1, 1]); - const dx = tf.grad((x: tf.Tensor3D) => x.avgPool(1, 1, 0))(x, dy); - - expect(dx.shape).toEqual(x.shape); - expectArraysClose(await dx.data(), [0]); - }); - - it('gradient with clones', async () => { - const x = tf.tensor3d([0], [1, 1, 1]); - const dy = tf.tensor3d([0], [1, 1, 1]); - const dx = tf.grad( - (x: tf.Tensor3D) => tf.avgPool(x.clone(), 1, 1, 0).clone())(x, dy); - - expect(dx.shape).toEqual(x.shape); - expectArraysClose(await dx.data(), [0]); - }); - - it('gradient x=[3,3,1] f=[2,2] s=1', async () => { - // Feed forward. - const x = tf.tensor3d([1, 2, 3, 4, 5, 6, 7, 9, 8], [3, 3, 1]); - const dy = tf.tensor3d([1, 2, 3, 4], [2, 2, 1]); - const avgMultiplier = 1 / (2 * 2); - - const dx = tf.grad((x: tf.Tensor3D) => x.avgPool(2, 1, 0))(x, dy); - - expect(dx.shape).toEqual(x.shape); - expectArraysClose(await dx.data(), [ - 1 * avgMultiplier, 3 * avgMultiplier, 2 * avgMultiplier, - 4 * avgMultiplier, 10 * avgMultiplier, 6 * avgMultiplier, - 3 * avgMultiplier, 7 * avgMultiplier, 4 * avgMultiplier - ]); - }); - - it('gradient x=[3,3,1] f=[3,3] s=1 p=explicit', async () => { - // Feed forward. - const x = tf.tensor3d([0, 1, 2, 3, 4, 5, 6, 7, 8], [3, 3, 1]); - const padding = - [[0, 0], [1, 2], [0, 1], [0, 0]] as tf.backend_util.ExplicitPadding; - const dy = tf.tensor3d([0, 3, 0, 6, 0, 9, 0, 12], [4, 2, 1]); - const dx = tf.grad((x: tf.Tensor3D) => x.avgPool(3, 1, padding))(x, dy); - expect(dx.shape).toEqual(x.shape); - expectArraysClose(await dx.data(), [0, 1, 1, 0, 2, 2, 0, 3, 3]); - }); - - it('gradient x=[2,3,3,1] f=[2,2], s=1', async () => { - // Feed forward. - const x = tf.tensor4d( - [1, 2, 3, 4, 5, 6, 7, 9, 8, 1, 2, 3, 4, 5, 6, 7, 8, 9], [2, 3, 3, 1]); - const dy = tf.tensor4d([1, 2, 3, 4, 1, 2, 3, 4], [2, 2, 2, 1]); - const avgMultiplier = 1 / (2 * 2); - - const dx = tf.grad((x: tf.Tensor4D) => x.avgPool(2, 1, 0))(x, dy); - - expect(dx.shape).toEqual(x.shape); - expectArraysClose(await dx.data(), [ - 1 * avgMultiplier, 3 * avgMultiplier, 2 * avgMultiplier, - 4 * avgMultiplier, 10 * avgMultiplier, 6 * avgMultiplier, - 3 * avgMultiplier, 7 * avgMultiplier, 4 * avgMultiplier, - 1 * avgMultiplier, 3 * avgMultiplier, 2 * avgMultiplier, - 4 * avgMultiplier, 10 * avgMultiplier, 6 * avgMultiplier, - 3 * avgMultiplier, 7 * avgMultiplier, 4 * avgMultiplier - ]); - }); - - it('throws when dimRoundingMode is set and pad is same', () => { - const x = tf.tensor3d([1, 2, 3, 4], [2, 2, 1]); - - const pad = 'same'; - const dimRoundingMode = 'round'; - - expect(() => tf.avgPool(x, 2, 1, pad, dimRoundingMode)).toThrowError(); - }); - - it('throws when dimRoundingMode is set and pad is valid', () => { - const x = tf.tensor3d([1, 2, 3, 4], [2, 2, 1]); - - const pad = 'valid'; - const dimRoundingMode = 'round'; - - expect(() => tf.avgPool(x, 2, 1, pad, dimRoundingMode)).toThrowError(); - }); - - it('throws when dimRoundingMode is set and pad is a non-integer number', - () => { - const x = tf.tensor3d([1, 2, 3, 4], [2, 2, 1]); - - const pad = 1.2; - const dimRoundingMode = 'round'; - - expect(() => tf.avgPool(x, 2, 1, pad, dimRoundingMode)).toThrowError(); - }); - - it('throws when dimRoundingMode is set and pad is explicit by non-integer ' + - 'number', - () => { - const x = tf.tensor3d([1, 2, 3, 4], [2, 2, 1]); - - const pad = [[0, 0], [0, 2.1], [1, 1], [0, 0]] as - tf.backend_util.ExplicitPadding; - const dimRoundingMode = 'round'; - - expect(() => tf.avgPool(x, 2, 1, pad, dimRoundingMode)).toThrowError(); - }); - - it('throws when passed a non-tensor', () => { - expect(() => tf.avgPool({} as tf.Tensor3D, 2, 1, 'valid')) - .toThrowError(/Argument 'x' passed to 'avgPool' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const a = [[[0]]]; // 1x1x1 - const result = tf.avgPool(a, 1, 1, 0); - expectArraysClose(await result.data(), [0]); - }); - - identityPoolTest(tf.avgPool); -}); diff --git a/tfjs-master/tfjs-core/src/ops/axis_util.ts b/tfjs-master/tfjs-core/src/ops/axis_util.ts deleted file mode 100644 index d63c783fc..000000000 --- a/tfjs-master/tfjs-core/src/ops/axis_util.ts +++ /dev/null @@ -1,109 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as util from '../util'; - -/** - * Returns true if the axis specifies the inner most dimensions of the - * array. - */ -export function axesAreInnerMostDims(axes: number[], rank: number): boolean { - for (let i = 0; i < axes.length; ++i) { - if (axes[axes.length - i - 1] !== rank - 1 - i) { - return false; - } - } - return true; -} - -export function combineLocations( - outputLoc: number[], reduceLoc: number[], axes: number[]): number[] { - const rank = outputLoc.length + reduceLoc.length; - const loc = []; - let outIdx = 0; - let reduceIdx = 0; -   for (let dim = 0; dim < rank; dim++) { - if (axes.indexOf(dim) === -1) { - loc.push(outputLoc[outIdx++]); - } else { - loc.push(reduceLoc[reduceIdx++]); - } - } - return loc; -} - -export function computeOutAndReduceShapes( - aShape: number[], axes: number[]): [number[], number[]] { - const outShape = []; - const rank = aShape.length; - for (let dim = 0; dim < rank; dim++) { - if (axes.indexOf(dim) === -1) { - outShape.push(aShape[dim]); - } - } - const reduceShape = axes.map(dim => aShape[dim]); - return [outShape, reduceShape]; -} - -export function expandShapeToKeepDim( - shape: number[], axes: number[]): number[] { - const reduceSubShape = axes.map(x => 1); - return combineLocations(shape, reduceSubShape, axes); -} - -export function assertAxesAreInnerMostDims( - msg: string, axes: number[], rank: number): void { - util.assert( - axesAreInnerMostDims(axes, rank), - () => `${msg} supports only inner-most axes for now. ` + - `Got axes ${axes} and rank-${rank} input.`); -} - -/** - * Returns the axes permutation to be used with `tf.transpose`, if such - * permutation is necessary. Otherwise it returns null. This method is used by - * operations that operate only on inner-most axes. - */ -export function getAxesPermutation(axes: number[], rank: number): number[]| - null { - if (axesAreInnerMostDims(axes, rank)) { - return null; - } - const result: number[] = []; - for (let i = 0; i < rank; ++i) { - if (axes.indexOf(i) === -1) { - result.push(i); - } - } - axes.forEach(axis => result.push(axis)); - return result; -} - -/** Returns the axes permutation that undoes the original permutation. */ -export function getUndoAxesPermutation(axes: number[]): number[] { - return axes.map((axis, i) => [i, axis]) - .sort((a, b) => a[1] - b[1]) - .map(x => x[0]); -} - -export function getInnerMostAxes(numAxes: number, rank: number): number[] { - const res: number[] = []; - for (let i = rank - numAxes; i < rank; ++i) { - res.push(i); - } - return res; -} diff --git a/tfjs-master/tfjs-core/src/ops/axis_util_test.ts b/tfjs-master/tfjs-core/src/ops/axis_util_test.ts deleted file mode 100644 index 60ed27447..000000000 --- a/tfjs-master/tfjs-core/src/ops/axis_util_test.ts +++ /dev/null @@ -1,216 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -import * as axis_util from './axis_util'; - -describe('axis_util combineLocations', () => { - it('rank 4, reduce last 2 dims', () => { - const loc = axis_util.combineLocations([4, 1], [3, 7], [2, 3]); - expect(loc).toEqual([4, 1, 3, 7]); - }); - - it('rank 4, reduce first two dims', () => { - const loc = axis_util.combineLocations([4, 1], [3, 7], [0, 1]); - expect(loc).toEqual([3, 7, 4, 1]); - }); - - it('rank 4, reduce 1st and 3rd dims', () => { - const loc = axis_util.combineLocations([4, 1], [3, 7], [0, 2]); - expect(loc).toEqual([3, 4, 7, 1]); - }); - - it('rank 4, reduce 1st and 4th dims', () => { - const loc = axis_util.combineLocations([4, 1], [3, 7], [0, 3]); - expect(loc).toEqual([3, 4, 1, 7]); - }); - - it('rank 3, reduce all dims', () => { - const loc = axis_util.combineLocations([], [3, 7, 1], [0, 1, 2]); - expect(loc).toEqual([3, 7, 1]); - }); - - it('rank 2, reduce last dim', () => { - const loc = axis_util.combineLocations([3], [5], [1]); - expect(loc).toEqual([3, 5]); - }); - - it('rank 2, reduce first dim', () => { - const loc = axis_util.combineLocations([3], [5], [0]); - expect(loc).toEqual([5, 3]); - }); -}); - -describe('axis_util computeOutAndReduceShapes', () => { - it('rank 4, reduce all dims', () => { - const [out, red] = - axis_util.computeOutAndReduceShapes([3, 7, 2, 4], [0, 1, 2, 3]); - expect(out).toEqual([]); - expect(red).toEqual([3, 7, 2, 4]); - }); - - it('rank 4, reduce last 2 dims', () => { - const [out, red] = - axis_util.computeOutAndReduceShapes([3, 7, 2, 4], [2, 3]); - expect(out).toEqual([3, 7]); - expect(red).toEqual([2, 4]); - }); - - it('rank 4, reduce first 2 dims', () => { - const [out, red] = - axis_util.computeOutAndReduceShapes([3, 7, 2, 4], [0, 1]); - expect(out).toEqual([2, 4]); - expect(red).toEqual([3, 7]); - }); - - it('rank 4, reduce last 3 dims', () => { - const [out, red] = - axis_util.computeOutAndReduceShapes([3, 7, 2, 4], [1, 2, 3]); - expect(out).toEqual([3]); - expect(red).toEqual([7, 2, 4]); - }); - - it('rank 4, reduce 1st and 3rd dims', () => { - const [out, red] = - axis_util.computeOutAndReduceShapes([3, 7, 2, 4], [0, 2]); - expect(out).toEqual([7, 4]); - expect(red).toEqual([3, 2]); - }); - - it('rank 3, reduce all dims', () => { - const [out, red] = - axis_util.computeOutAndReduceShapes([3, 7, 2], [0, 1, 2]); - expect(out).toEqual([]); - expect(red).toEqual([3, 7, 2]); - }); -}); - -describe('axis_util axesAreInnerMostDims', () => { - it('rank 4, reduce last dim', () => { - const res = axis_util.axesAreInnerMostDims([3], 4); - expect(res).toBe(true); - }); - - it('rank 4, reduce last 2 dims', () => { - const res = axis_util.axesAreInnerMostDims([2, 3], 4); - expect(res).toBe(true); - }); - - it('rank 4, reduce last 3 dims', () => { - const res = axis_util.axesAreInnerMostDims([1, 2, 3], 4); - expect(res).toBe(true); - }); - - it('rank 4, reduce all dims', () => { - const res = axis_util.axesAreInnerMostDims([0, 1, 2, 3], 4); - expect(res).toBe(true); - }); - - it('rank 4, reduce all but 2nd', () => { - const res = axis_util.axesAreInnerMostDims([0, 2, 3], 4); - expect(res).toBe(false); - }); - - it('rank 4, reduce all but 3rd', () => { - const res = axis_util.axesAreInnerMostDims([0, 1, 3], 4); - expect(res).toBe(false); - }); - - it('rank 4, reduce all but last', () => { - const res = axis_util.axesAreInnerMostDims([0, 1, 2], 4); - expect(res).toBe(false); - }); -}); - -describe('axis_util expandShapeToKeepDim', () => { - it('2d -> 1d axis=0', () => { - const shape = axis_util.expandShapeToKeepDim([2], [0]); - expect(shape).toEqual([1, 2]); - }); - - it('2d -> 1d axis=1', () => { - const shape = axis_util.expandShapeToKeepDim([4], [1]); - expect(shape).toEqual([4, 1]); - }); - - it('3d -> 1d axis=1,2', () => { - const shape = axis_util.expandShapeToKeepDim([7], [1, 2]); - expect(shape).toEqual([7, 1, 1]); - }); - - it('3d -> 2d axis=1', () => { - const shape = axis_util.expandShapeToKeepDim([7, 3], [1]); - expect(shape).toEqual([7, 1, 3]); - }); -}); - -describe('axis_util getPermAxes', () => { - it('all axes, no perm is needed', () => { - const perm = axis_util.getAxesPermutation([0, 1, 2], 3); - expect(perm).toBeNull(); - }); - - it('no axes, no perm is needed', () => { - const perm = axis_util.getAxesPermutation([], 3); - expect(perm).toBeNull(); - }); - - it('inner most 2 axes, no perm is needed', () => { - const perm = axis_util.getAxesPermutation([2, 3], 4); - expect(perm).toBeNull(); - }); - - it('outer most axis, perm is needed', () => { - const perm = axis_util.getAxesPermutation([0], 4); - expect(perm).toEqual([1, 2, 3, 0]); - }); - - it('2 outer most axes, perm is needed', () => { - const perm = axis_util.getAxesPermutation([0, 1], 4); - expect(perm).toEqual([2, 3, 0, 1]); - }); -}); - -describeWithFlags('axis_util getUndoAxesPermutation', ALL_ENVS, () => { - it('4d axes', () => { - const axes = [2, 0, 1, 3]; - expect(axis_util.getUndoAxesPermutation(axes)).toEqual([1, 2, 0, 3]); - }); - - it('3d axes, no perm', () => { - const axes = [0, 1, 2]; - expect(axis_util.getUndoAxesPermutation(axes)).toEqual([0, 1, 2]); - }); - - it('3d axes, complete flip', () => { - const axes = [2, 1, 0]; - expect(axis_util.getUndoAxesPermutation(axes)).toEqual([2, 1, 0]); - }); - - it('4d array with values', async () => { - const axes = [2, 0, 1, 3]; - const undoPermutation = axis_util.getUndoAxesPermutation(axes); - - const a = tf.randomNormal([2, 3, 4, 5]); - const aT = tf.transpose(a, axes); - const aTT = tf.transpose(aT, undoPermutation); - expectArraysClose(await a.data(), await aTT.data()); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/basic_lstm_cell.ts b/tfjs-master/tfjs-core/src/ops/basic_lstm_cell.ts deleted file mode 100644 index d9f1e252f..000000000 --- a/tfjs-master/tfjs-core/src/ops/basic_lstm_cell.ts +++ /dev/null @@ -1,80 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Scalar, Tensor1D, Tensor2D} from '../tensor'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -import {add} from './add'; -import {concat} from './concat'; -import {matMul} from './mat_mul'; -import {mul} from './mul'; -import {op} from './operation'; -import {sigmoid} from './sigmoid'; -import {slice} from './slice'; -import {tanh} from './tanh'; - -/** - * Computes the next state and output of a BasicLSTMCell. - * - * Returns `[newC, newH]`. - * - * Derived from tf.contrib.rnn.BasicLSTMCell. - * - * @param forgetBias Forget bias for the cell. - * @param lstmKernel The weights for the cell. - * @param lstmBias The bias for the cell. - * @param data The input to the cell. - * @param c Previous cell state. - * @param h Previous cell output. - * - * @doc {heading: 'Operations', subheading: 'RNN'} - */ -function basicLSTMCell_( - forgetBias: Scalar|TensorLike, lstmKernel: Tensor2D|TensorLike, - lstmBias: Tensor1D|TensorLike, data: Tensor2D|TensorLike, - c: Tensor2D|TensorLike, h: Tensor2D|TensorLike): [Tensor2D, Tensor2D] { - const $forgetBias = - convertToTensor(forgetBias, 'forgetBias', 'basicLSTMCell'); - const $lstmKernel = - convertToTensor(lstmKernel, 'lstmKernel', 'basicLSTMCell'); - const $lstmBias = convertToTensor(lstmBias, 'lstmBias', 'basicLSTMCell'); - const $data = convertToTensor(data, 'data', 'basicLSTMCell'); - const $c = convertToTensor(c, 'c', 'basicLSTMCell'); - const $h = convertToTensor(h, 'h', 'basicLSTMCell'); - - const combined = concat([$data, $h], 1); - const weighted = matMul(combined, $lstmKernel); - const res: Tensor2D = add(weighted, $lstmBias); - - // i = input_gate, j = new_input, f = forget_gate, o = output_gate - const batchSize = res.shape[0]; - const sliceCols = res.shape[1] / 4; - const sliceSize: [number, number] = [batchSize, sliceCols]; - const i = slice(res, [0, 0], sliceSize); - const j = slice(res, [0, sliceCols], sliceSize); - const f = slice(res, [0, sliceCols * 2], sliceSize); - const o = slice(res, [0, sliceCols * 3], sliceSize); - - const newC: Tensor2D = - add(mul(sigmoid(i), tanh(j)), - mul($c, sigmoid(add($forgetBias, f)) as Tensor2D)); - const newH: Tensor2D = mul(tanh(newC), sigmoid(o)); - return [newC, newH]; -} - -export const basicLSTMCell = /* @__PURE__ */ op({basicLSTMCell_}); diff --git a/tfjs-master/tfjs-core/src/ops/basic_lstm_cell_test.ts b/tfjs-master/tfjs-core/src/ops/basic_lstm_cell_test.ts deleted file mode 100644 index 663b68a4c..000000000 --- a/tfjs-master/tfjs-core/src/ops/basic_lstm_cell_test.ts +++ /dev/null @@ -1,161 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {Rank} from '../types'; - -describeWithFlags('basicLSTMCell', ALL_ENVS, () => { - it('basicLSTMCell with batch=2', async () => { - const lstmKernel = tf.randomNormal([3, 4]); - const lstmBias = tf.randomNormal([4]); - const forgetBias = tf.scalar(1.0); - - const data = tf.randomNormal([1, 2]); - const batchedData = tf.concat2d([data, data], 0); // 2x2 - const c = tf.randomNormal([1, 1]); - const batchedC = tf.concat2d([c, c], 0); // 2x1 - const h = tf.randomNormal([1, 1]); - const batchedH = tf.concat2d([h, h], 0); // 2x1 - const [newC, newH] = tf.basicLSTMCell( - forgetBias, lstmKernel, lstmBias, batchedData, batchedC, batchedH); - const newCVals = await newC.array(); - const newHVals = await newH.array(); - expect(newCVals[0][0]).toEqual(newCVals[1][0]); - expect(newHVals[0][0]).toEqual(newHVals[1][0]); - }); - - it('basicLSTMCell accepts a tensor-like object', async () => { - const lstmKernel = tf.randomNormal([3, 4]); - const lstmBias = [0, 0, 0, 0]; - const forgetBias = 1; - - const data = [[0, 0]]; // 1x2 - const batchedData = tf.concat2d([data, data], 0); // 2x2 - const c = [[0]]; // 1x1 - const batchedC = tf.concat2d([c, c], 0); // 2x1 - const h = [[0]]; // 1x1 - const batchedH = tf.concat2d([h, h], 0); // 2x1 - const [newC, newH] = tf.basicLSTMCell( - forgetBias, lstmKernel, lstmBias, batchedData, batchedC, batchedH); - const newCVals = await newC.array(); - const newHVals = await newH.array(); - expect(newCVals[0][0]).toEqual(newCVals[1][0]); - expect(newHVals[0][0]).toEqual(newHVals[1][0]); - }); -}); -describeWithFlags('basicLSTMCell throws with non-tensor', ALL_ENVS, () => { - it('input: forgetBias', () => { - const lstmKernel = tf.randomNormal([3, 4]); - const lstmBias = tf.randomNormal([4]); - - const data = tf.randomNormal([1, 2]); - const batchedData = tf.concat2d([data, data], 0); // 2x2 - const c = tf.randomNormal([1, 1]); - const batchedC = tf.concat2d([c, c], 0); // 2x1 - const h = tf.randomNormal([1, 1]); - const batchedH = tf.concat2d([h, h], 0); // 2x1 - expect( - () => tf.basicLSTMCell( - {} as tf.Scalar, lstmKernel, lstmBias, batchedData, batchedC, - batchedH)) - .toThrowError( - /Argument 'forgetBias' passed to 'basicLSTMCell' must be a Tensor/); - }); - it('input: lstmKernel', () => { - const lstmBias = tf.randomNormal([4]); - const forgetBias = tf.scalar(1.0); - - const data = tf.randomNormal([1, 2]); - const batchedData = tf.concat2d([data, data], 0); // 2x2 - const c = tf.randomNormal([1, 1]); - const batchedC = tf.concat2d([c, c], 0); // 2x1 - const h = tf.randomNormal([1, 1]); - const batchedH = tf.concat2d([h, h], 0); // 2x1 - expect( - () => tf.basicLSTMCell( - forgetBias, {} as tf.Tensor2D, lstmBias, batchedData, batchedC, - batchedH)) - .toThrowError( - /Argument 'lstmKernel' passed to 'basicLSTMCell' must be a Tensor/); - }); - it('input: lstmBias', () => { - const lstmKernel = tf.randomNormal([3, 4]); - const forgetBias = tf.scalar(1.0); - - const data = tf.randomNormal([1, 2]); - const batchedData = tf.concat2d([data, data], 0); // 2x2 - const c = tf.randomNormal([1, 1]); - const batchedC = tf.concat2d([c, c], 0); // 2x1 - const h = tf.randomNormal([1, 1]); - const batchedH = tf.concat2d([h, h], 0); // 2x1 - expect( - () => tf.basicLSTMCell( - forgetBias, lstmKernel, {} as tf.Tensor1D, batchedData, batchedC, - batchedH)) - .toThrowError( - /Argument 'lstmBias' passed to 'basicLSTMCell' must be a Tensor/); - }); - it('input: data', () => { - const lstmKernel = tf.randomNormal([3, 4]); - const lstmBias = tf.randomNormal([4]); - const forgetBias = tf.scalar(1.0); - - const c = tf.randomNormal([1, 1]); - const batchedC = tf.concat2d([c, c], 0); // 2x1 - const h = tf.randomNormal([1, 1]); - const batchedH = tf.concat2d([h, h], 0); // 2x1 - expect( - () => tf.basicLSTMCell( - forgetBias, lstmKernel, lstmBias, {} as tf.Tensor2D, batchedC, - batchedH)) - .toThrowError( - /Argument 'data' passed to 'basicLSTMCell' must be a Tensor/); - }); - it('input: c', () => { - const lstmKernel = tf.randomNormal([3, 4]); - const lstmBias = tf.randomNormal([4]); - const forgetBias = tf.scalar(1.0); - - const data = tf.randomNormal([1, 2]); - const batchedData = tf.concat2d([data, data], 0); // 2x2 - const h = tf.randomNormal([1, 1]); - const batchedH = tf.concat2d([h, h], 0); // 2x1 - expect( - () => tf.basicLSTMCell( - forgetBias, lstmKernel, lstmBias, batchedData, {} as tf.Tensor2D, - batchedH)) - .toThrowError( - /Argument 'c' passed to 'basicLSTMCell' must be a Tensor/); - }); - it('input: h', () => { - const lstmKernel = tf.randomNormal([3, 4]); - const lstmBias = tf.randomNormal([4]); - const forgetBias = tf.scalar(1.0); - - const data = tf.randomNormal([1, 2]); - const batchedData = tf.concat2d([data, data], 0); // 2x2 - const c = tf.randomNormal([1, 1]); - const batchedC = tf.concat2d([c, c], 0); // 2x1 - expect( - () => tf.basicLSTMCell( - forgetBias, lstmKernel, lstmBias, batchedData, batchedC, - {} as tf.Tensor2D)) - .toThrowError( - /Argument 'h' passed to 'basicLSTMCell' must be a Tensor/); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/batch_to_space_nd.ts b/tfjs-master/tfjs-core/src/ops/batch_to_space_nd.ts deleted file mode 100644 index 7deeea9d8..000000000 --- a/tfjs-master/tfjs-core/src/ops/batch_to_space_nd.ts +++ /dev/null @@ -1,107 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {BatchToSpaceND, BatchToSpaceNDAttrs, BatchToSpaceNDInputs} from '../kernel_names'; -import {NamedAttrMap} from '../kernel_registry'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; -import * as util from '../util'; - -import {op} from './operation'; - -/** - * This operation reshapes the "batch" dimension 0 into `M + 1` dimensions of - * shape `blockShape + [batch]`, interleaves these blocks back into the grid - * defined by the spatial dimensions `[1, ..., M]`, to obtain a result with - * the same rank as the input. The spatial dimensions of this intermediate - * result are then optionally cropped according to `crops` to produce the - * output. This is the reverse of `tf.spaceToBatchND`. See below for a precise - * description. - * - * ```js - * const x = tf.tensor4d([1, 2, 3, 4], [4, 1, 1, 1]); - * const blockShape = [2, 2]; - * const crops = [[0, 0], [0, 0]]; - * - * x.batchToSpaceND(blockShape, crops).print(); - * ``` - * - * @param x A `tf.Tensor`. N-D with `x.shape` = `[batch] + spatialShape + - * remainingShape`, where spatialShape has `M` dimensions. - * @param blockShape A 1-D array. Must have shape `[M]`, all values must - * be >= 1. - * @param crops A 2-D array. Must have shape `[M, 2]`, all values must be >= 0. - * `crops[i] = [cropStart, cropEnd]` specifies the amount to crop from input - * dimension `i + 1`, which corresponds to spatial dimension `i`. It is required - * that `cropStart[i] + cropEnd[i] <= blockShape[i] * inputShape[i + 1]` - * - * This operation is equivalent to the following steps: - * - * 1. Reshape `x` to `reshaped` of shape: `[blockShape[0], ..., - * blockShape[M-1], batch / prod(blockShape), x.shape[1], ..., - * x.shape[N-1]]` - * - * 2. Permute dimensions of `reshaped` to produce `permuted` of shape `[batch / - * prod(blockShape),x.shape[1], blockShape[0], ..., x.shape[M], - * blockShape[M-1],x.shape[M+1], ..., x.shape[N-1]]` - * - * 3. Reshape `permuted` to produce `reshapedPermuted` of shape `[batch / - * prod(blockShape),x.shape[1] * blockShape[0], ..., x.shape[M] * - * blockShape[M-1],x.shape[M+1], ..., x.shape[N-1]]` - * - * 4. Crop the start and end of dimensions `[1, ..., M]` of `reshapedPermuted` - * according to `crops` to produce the output of shape: `[batch / - * prod(blockShape),x.shape[1] * blockShape[0] - crops[0,0] - crops[0,1], - * ..., x.shape[M] * blockShape[M-1] - crops[M-1,0] - - * crops[M-1,1],x.shape[M+1], ..., x.shape[N-1]]` - * - * @doc {heading: 'Tensors', subheading: 'Transformations'} - */ -function batchToSpaceND_( - x: T|TensorLike, blockShape: number[], crops: number[][]): T { - const $x = convertToTensor(x, 'x', 'batchToSpaceND'); - const prod = blockShape.reduce((a, b) => a * b); - - util.assert( - $x.rank >= 1 + blockShape.length, - () => `input rank is ${$x.rank} but should be > than blockShape.length ${ - blockShape.length}`); - - util.assert( - crops.length === blockShape.length, - () => `crops.length is ${ - crops.length} but should be equal to blockShape.length ${ - blockShape.length}`); - - util.assert( - $x.shape[0] % prod === 0, - () => `input tensor batch is ${ - $x.shape[0]} but is not divisible by the product of ` + - `the elements of blockShape ${blockShape.join(' * ')} === ${prod}`); - - const inputs: BatchToSpaceNDInputs = {x: $x}; - const attrs: BatchToSpaceNDAttrs = {blockShape, crops}; - - return ENGINE.runKernel( - BatchToSpaceND, inputs as unknown as NamedTensorMap, - attrs as unknown as NamedAttrMap); -} - -export const batchToSpaceND = /* @__PURE__ */ op({batchToSpaceND_}); diff --git a/tfjs-master/tfjs-core/src/ops/batch_to_space_nd_test.ts b/tfjs-master/tfjs-core/src/ops/batch_to_space_nd_test.ts deleted file mode 100644 index d08e537fc..000000000 --- a/tfjs-master/tfjs-core/src/ops/batch_to_space_nd_test.ts +++ /dev/null @@ -1,214 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('batchToSpaceND', ALL_ENVS, () => { - it('tensor4d, input shape=[4, 1, 1, 1], blockShape=[2, 2]', async () => { - const t = tf.tensor4d([1, 2, 3, 4], [4, 1, 1, 1]); - const blockShape = [2, 2]; - const crops = [[0, 0], [0, 0]]; - - const res = tf.batchToSpaceND(t, blockShape, crops); - expect(res.shape).toEqual([1, 2, 2, 1]); - expectArraysClose(await res.data(), [1, 2, 3, 4]); - }); - - it('tensor4d, input shape=[4, 1, 1, 3], blockShape=[2, 2]', async () => { - const t = - tf.tensor4d([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [4, 1, 1, 3]); - const blockShape = [2, 2]; - const crops = [[0, 0], [0, 0]]; - - const res = tf.batchToSpaceND(t, blockShape, crops); - expect(res.shape).toEqual([1, 2, 2, 3]); - expectArraysClose( - await res.data(), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]); - }); - - it('tensor4d, input shape=[4, 2, 2, 1], blockShape=[2, 2]', async () => { - const t = tf.tensor4d( - [1, 3, 9, 11, 2, 4, 10, 12, 5, 7, 13, 15, 6, 8, 14, 16], [4, 2, 2, 1]); - const blockShape = [2, 2]; - const crops = [[0, 0], [0, 0]]; - - const res = tf.batchToSpaceND(t, blockShape, crops); - expect(res.shape).toEqual([1, 4, 4, 1]); - expectArraysClose( - await res.data(), - [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]); - }); - - it('tensor4d, input shape=[8, 1, 3, 1], blockShape=[2, 2]', async () => { - const t = tf.tensor4d( - [ - 0, 1, 3, 0, 9, 11, 0, 2, 4, 0, 10, 12, - 0, 5, 7, 0, 13, 15, 0, 6, 8, 0, 14, 16 - ], - [8, 1, 3, 1]); - const blockShape = [2, 2]; - const crops = [[0, 0], [2, 0]]; - - const res = tf.batchToSpaceND(t, blockShape, crops); - expect(res.shape).toEqual([2, 2, 4, 1]); - expectArraysClose( - await res.data(), - [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]); - }); - - it('tensor2d, blockShape [1]', async () => { - const t = tf.tensor2d([1, 2, 3, 4], [2, 2]); - const blockShape = [2]; - const crops = [[0, 0]]; - - const res = tf.batchToSpaceND(t, blockShape, crops); - expect(res.shape).toEqual([1, 4]); - expectArraysClose(await res.data(), [1, 3, 2, 4]); - }); - - it('tensor3d, blockSHape [1]', async () => { - const t = tf.tensor( - [ - -61, 37, -68, 72, 31, 62, 0, -13, 28, 54, 96, - 44, -55, -64, -88, -94, 65, -32, -96, -73, -2, -77, - -14, 47, 33, 15, 70, 20, 75, 28, 84, -13 - ], - [8, 2, 2]); - const blockShape = [2]; - const crops = [[0, 2]]; - - const res = tf.batchToSpaceND(t, blockShape, crops); - expect(res.shape).toEqual([4, 2, 2]); - expectArraysClose( - await res.data(), - [-61, 37, 65, -32, 31, 62, -2, -77, 28, 54, 33, 15, -55, -64, 75, 28]); - }); - - it('tensor3d, blockShape [2]', async () => { - const t = tf.tensor( - [ - -61, 37, -68, 72, 31, 62, 0, -13, 28, 54, 96, - 44, -55, -64, -88, -94, 65, -32, -96, -73, -2, -77, - -14, 47, 33, 15, 70, 20, 75, 28, 84, -13 - ], - [8, 2, 2]); - const blockShape = [2, 2]; - const crops = [[2, 0], [2, 0]]; - - const res = tf.batchToSpaceND(t, blockShape, crops); - expect(res.shape).toEqual([2, 2, 2]); - expectArraysClose(await res.data(), [72, 44, -73, 20, -13, -94, 47, -13]); - }); - - it('throws when blockShape equal to input rank', () => { - const t = tf.tensor4d([1, 2, 3, 4], [4, 1, 1, 1]); - const blockShape = [2, 2, 2, 2]; - const crops = [[0, 0], [0, 0], [0, 0], [0, 0]]; - - expect(() => tf.batchToSpaceND(t, blockShape, crops)) - .toThrowError( - `input rank is ${t.rank} but should be > than blockShape.length ${ - blockShape.length}`); - }); - - it('throws when crops row dimension not equal to blockshape', () => { - const t = tf.tensor4d([1, 2, 3, 4], [4, 1, 1, 1]); - const blockShape = [2, 2]; - const crops = [[0, 0]]; - - expect(() => tf.batchToSpaceND(t, blockShape, crops)) - .toThrowError(`crops.length is ${ - crops.length} but should be equal to blockShape.length ${ - blockShape.length}`); - }); - - it('throws when input tensor batch not divisible by prod(blockShape)', () => { - const t = tf.tensor4d([1, 2, 3, 4, 5], [5, 1, 1, 1]); - const blockShape = [2, 2]; - const crops = [[0, 0], [0, 0]]; - const prod = blockShape.reduce((a, b) => a * b); - - expect(() => tf.batchToSpaceND(t, blockShape, crops)) - .toThrowError( - `input tensor batch is ${t.shape[0]} but is not divisible by the ` + - `product of the elements of blockShape ${ - blockShape.join(' * ')} === ${prod}`); - }); - - it('accepts a tensor-like object', async () => { - const t = [[[[1]]], [[[2]]], [[[3]]], [[[4]]]]; - const blockShape = [2, 2]; - const crops = [[0, 0], [0, 0]]; - - const res = tf.batchToSpaceND(t, blockShape, crops); - expect(res.shape).toEqual([1, 2, 2, 1]); - expectArraysClose(await res.data(), [1, 2, 3, 4]); - }); - - it('gradients, input shape=[4, 2, 2], block shape=[2]', async () => { - const t = tf.tensor( - [-61, 37, -68, 72, 31, 62, 0, -13, 28, 54, 96, 44, -55, -64, -88, -94], - [4, 2, 2]); - const blockShape = [2]; - const crops = [[0, 2]]; - const dy = tf.tensor([.01, .02, .03, .04, .05, .06, .07, .08], [2, 2, 2]); - - const gradient = - tf.grad(t => tf.batchToSpaceND(t, blockShape, crops))(t, dy); - expect(gradient.shape).toEqual([4, 2, 2]); - expectArraysClose(await gradient.data(), [ - 0.01, 0.02, 0, 0, 0.05, 0.06, 0, 0, 0.03, 0.04, 0, 0, 0.07, 0.08, 0, 0 - ]); - }); - - it('gradients, input shape=[4, 2, 2, 1], block shape=[2, 2]', async () => { - const t = tf.tensor4d( - [1, 3, 9, 11, 2, 4, 10, 12, 5, 7, 13, 15, 6, 8, 14, 16], [4, 2, 2, 1]); - const blockShape = [2, 2]; - const crops = [[0, 0], [0, 0]]; - const dy = tf.tensor( - [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], [1, 4, 4, 1]); - - const gradient = - tf.grad(t => tf.batchToSpaceND(t, blockShape, crops))(t, dy); - expect(gradient.shape).toEqual([4, 2, 2, 1]); - expectArraysClose( - await gradient.data(), - [1, 3, 9, 11, 2, 4, 10, 12, 5, 7, 13, 15, 6, 8, 14, 16]); - }); - - it('gradient with clones, input=[4, 2, 2, 1], block shape=[2, 2]', - async () => { - const t = tf.tensor4d( - [1, 3, 9, 11, 2, 4, 10, 12, 5, 7, 13, 15, 6, 8, 14, 16], - [4, 2, 2, 1]); - const blockShape = [2, 2]; - const crops = [[0, 0], [0, 0]]; - const dy = tf.tensor( - [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], - [1, 4, 4, 1]); - - const gradient = tf.grad( - t => tf.batchToSpaceND(t.clone(), blockShape, crops).clone())(t, dy); - expect(gradient.shape).toEqual([4, 2, 2, 1]); - expectArraysClose( - await gradient.data(), - [1, 3, 9, 11, 2, 4, 10, 12, 5, 7, 13, 15, 6, 8, 14, 16]); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/batchnorm.ts b/tfjs-master/tfjs-core/src/ops/batchnorm.ts deleted file mode 100644 index 5b3f1db27..000000000 --- a/tfjs-master/tfjs-core/src/ops/batchnorm.ts +++ /dev/null @@ -1,111 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {FusedBatchNorm, FusedBatchNormAttrs, FusedBatchNormInputs} from '../kernel_names'; -import {NamedAttrMap} from '../kernel_registry'; -import {Tensor, Tensor1D, Tensor4D} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {Rank, TensorLike} from '../types'; -import * as util from '../util'; - -import {xAs4D} from './batchnorm_util'; -import {op} from './operation'; -import {reshape} from './reshape'; - -/** - * Batch normalization. - * - * As described in - * [http://arxiv.org/abs/1502.03167](http://arxiv.org/abs/1502.03167). - * - * Mean, variance, scale, and offset can be of two shapes: - * - The same shape as the input. - * - In the common case, the depth dimension is the last dimension of x, so - * the values would be a `tf.Tensor1D` of shape [depth]. - * - * Also available are stricter rank-specific methods with the same signature - * as this method that assert that parameters passed are of given rank - * - `tf.batchNorm2d` - * - `tf.batchNorm3d` - * - `tf.batchNorm4d` - * - * @param x The input Tensor. - * @param mean A mean Tensor. - * @param variance A variance Tensor. - * @param offset An offset Tensor. - * @param scale A scale Tensor. - * @param varianceEpsilon A small float number to avoid dividing by 0. - * - * @doc {heading: 'Operations', subheading: 'Normalization'} - */ -function batchNorm_( - x: Tensor|TensorLike, mean: Tensor|Tensor1D|TensorLike, - variance: Tensor|Tensor1D|TensorLike, - offset?: Tensor|Tensor1D|TensorLike, - scale?: Tensor|Tensor1D|TensorLike, - varianceEpsilon?: number): Tensor { - if (varianceEpsilon == null) { - varianceEpsilon = 0.001; - } - const $x = convertToTensor(x, 'x', 'batchNorm'); - const $mean = convertToTensor(mean, 'mean', 'batchNorm'); - const $variance = convertToTensor(variance, 'variance', 'batchNorm'); - let $scale: Tensor|Tensor1D; - if (scale != null) { - $scale = convertToTensor(scale, 'scale', 'batchNorm'); - } - let $offset: Tensor|Tensor1D; - if (offset != null) { - $offset = convertToTensor(offset, 'offset', 'batchNorm'); - } - - util.assert( - $mean.rank === $variance.rank, - () => 'Batch normalization gradient requires mean and variance to have ' + - 'equal ranks.'); - util.assert( - $offset == null || $mean.rank === $offset.rank, - () => 'Batch normalization gradient requires mean and offset to have ' + - 'equal ranks.'); - util.assert( - $scale == null || $mean.rank === $scale.rank, - () => 'Batch normalization gradient requires mean and scale to have ' + - 'equal ranks.'); - - const x4D: Tensor4D = xAs4D($x); - - const inputs: FusedBatchNormInputs = { - x: x4D, - scale: $scale, - offset: $offset, - mean: $mean, - variance: $variance - }; - - const attrs: FusedBatchNormAttrs = {varianceEpsilon}; - - // tslint:disable-next-line: no-unnecessary-type-assertion - const res = ENGINE.runKernel( - FusedBatchNorm, inputs as unknown as NamedTensorMap, - attrs as unknown as NamedAttrMap) as Tensor; - - return reshape(res, $x.shape); -} - -export const batchNorm = /* @__PURE__ */ op({batchNorm_}); diff --git a/tfjs-master/tfjs-core/src/ops/batchnorm2d.ts b/tfjs-master/tfjs-core/src/ops/batchnorm2d.ts deleted file mode 100644 index 0e1bca920..000000000 --- a/tfjs-master/tfjs-core/src/ops/batchnorm2d.ts +++ /dev/null @@ -1,80 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {Tensor1D, Tensor2D} from '../tensor'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; -import * as util from '../util'; - -import {batchNorm} from './batchnorm'; -import {op} from './operation'; - -/** - * Batch normalization, strictly for 2D. For the more relaxed version, see - * `tf.batchNorm`. - * - * @param x The input Tensor. - * @param mean A mean Tensor. - * @param variance A variance Tensor. - * @param offset An offset Tensor. - * @param scale A scale Tensor. - * @param varianceEpsilon A small float number to avoid dividing by 0. - */ -function batchNorm2d_( - x: Tensor2D|TensorLike, mean: Tensor2D|Tensor1D|TensorLike, - variance: Tensor2D|Tensor1D|TensorLike, - offset?: Tensor2D|Tensor1D|TensorLike, scale?: Tensor2D|Tensor1D|TensorLike, - varianceEpsilon?: number): Tensor2D { - const $x = convertToTensor(x, 'x', 'batchNorm'); - const $mean = convertToTensor(mean, 'mean', 'batchNorm'); - const $variance = convertToTensor(variance, 'variance', 'batchNorm'); - let $scale: Tensor2D|Tensor1D; - if (scale != null) { - $scale = convertToTensor(scale, 'scale', 'batchNorm'); - } - let $offset: Tensor2D|Tensor1D; - if (offset != null) { - $offset = convertToTensor(offset, 'offset', 'batchNorm'); - } - util.assert( - $x.rank === 2, - () => `Error in batchNorm2D: x must be rank 2 but got rank ` + - `${$x.rank}.`); - util.assert( - $mean.rank === 2 || $mean.rank === 1, - () => `Error in batchNorm2D: mean must be rank 2 or rank 1 but ` + - `got rank ${$mean.rank}.`); - util.assert( - $variance.rank === 2 || $variance.rank === 1, - () => `Error in batchNorm2D: variance must be rank 2 or rank 1 ` + - `but got rank ${$variance.rank}.`); - if ($scale != null) { - util.assert( - $scale.rank === 2 || $scale.rank === 1, - () => `Error in batchNorm2D: scale must be rank 2 or rank 1 ` + - `but got rank ${$scale.rank}.`); - } - if ($offset != null) { - util.assert( - $offset.rank === 2 || $offset.rank === 1, - () => `Error in batchNorm2D: offset must be rank 2 or rank 1 ` + - `but got rank ${$offset.rank}.`); - } - - return batchNorm($x, $mean, $variance, $offset, $scale, varianceEpsilon); -} - -export const batchNorm2d = /* @__PURE__ */ op({batchNorm2d_}); diff --git a/tfjs-master/tfjs-core/src/ops/batchnorm3d.ts b/tfjs-master/tfjs-core/src/ops/batchnorm3d.ts deleted file mode 100644 index 69c493b26..000000000 --- a/tfjs-master/tfjs-core/src/ops/batchnorm3d.ts +++ /dev/null @@ -1,80 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {Tensor1D, Tensor3D} from '../tensor'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; -import * as util from '../util'; - -import {batchNorm} from './batchnorm'; -import {op} from './operation'; - -/** - * Batch normalization, strictly for 3D. For the more relaxed version, see - * `tf.batchNorm`. - * - * @param x The input Tensor. - * @param mean A mean Tensor. - * @param variance A variance Tensor. - * @param offset An offset Tensor. - * @param scale A scale Tensor. - * @param varianceEpsilon A small float number to avoid dividing by 0. - */ -function batchNorm3d_( - x: Tensor3D|TensorLike, mean: Tensor3D|Tensor1D|TensorLike, - variance: Tensor3D|Tensor1D|TensorLike, - offset?: Tensor3D|Tensor1D|TensorLike, scale?: Tensor3D|Tensor1D|TensorLike, - varianceEpsilon?: number): Tensor3D { - const $x = convertToTensor(x, 'x', 'batchNorm'); - const $mean = convertToTensor(mean, 'mean', 'batchNorm'); - const $variance = convertToTensor(variance, 'variance', 'batchNorm'); - let $scale: Tensor3D|Tensor1D; - if (scale != null) { - $scale = convertToTensor(scale, 'scale', 'batchNorm'); - } - let $offset: Tensor3D|Tensor1D; - if (offset != null) { - $offset = convertToTensor(offset, 'offset', 'batchNorm'); - } - util.assert( - $x.rank === 3, - () => `Error in batchNorm3D: x must be rank 3 but got rank ` + - `${$x.rank}.`); - util.assert( - $mean.rank === 3 || $mean.rank === 1, - () => `Error in batchNorm3D: mean must be rank 3 or rank 1 but ` + - `got rank ${$mean.rank}.`); - util.assert( - $variance.rank === 3 || $variance.rank === 1, - () => `Error in batchNorm3D: variance must be rank 3 or rank 1 ` + - `but got rank ${$variance.rank}.`); - if ($scale != null) { - util.assert( - $scale.rank === 3 || $scale.rank === 1, - () => `Error in batchNorm3D: scale must be rank 3 or rank 1 ` + - `but got rank ${$scale.rank}.`); - } - if ($offset != null) { - util.assert( - $offset.rank === 3 || $offset.rank === 1, - () => `Error in batchNorm3D: offset must be rank 3 or rank 1 ` + - `but got rank ${$offset.rank}.`); - } - - return batchNorm($x, $mean, $variance, $offset, $scale, varianceEpsilon); -} - -export const batchNorm3d = /* @__PURE__ */ op({batchNorm3d_}); diff --git a/tfjs-master/tfjs-core/src/ops/batchnorm4d.ts b/tfjs-master/tfjs-core/src/ops/batchnorm4d.ts deleted file mode 100644 index 4dc6aa6d8..000000000 --- a/tfjs-master/tfjs-core/src/ops/batchnorm4d.ts +++ /dev/null @@ -1,79 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {Tensor1D, Tensor4D} from '../tensor'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; -import * as util from '../util'; - -import {batchNorm} from './batchnorm'; -import {op} from './operation'; - -/** - * Batch normalization, strictly for 4D. For the more relaxed version, see - * `tf.batchNorm`. - * - * @param x The input Tensor. - * @param mean A mean Tensor. - * @param variance A variance Tensor. - * @param offset An offset Tensor. - * @param scale A scale Tensor. - * @param varianceEpsilon A small float number to avoid dividing by 0. - */ -function batchNorm4d_( - x: Tensor4D|TensorLike, mean: Tensor4D|Tensor1D|TensorLike, - variance: Tensor4D|Tensor1D|TensorLike, - offset?: Tensor4D|Tensor1D|TensorLike, scale?: Tensor4D|Tensor1D|TensorLike, - varianceEpsilon?: number): Tensor4D { - const $x = convertToTensor(x, 'x', 'batchNorm'); - const $mean = convertToTensor(mean, 'mean', 'batchNorm'); - const $variance = convertToTensor(variance, 'variance', 'batchNorm'); - let $scale: Tensor4D|Tensor1D; - if (scale != null) { - $scale = convertToTensor(scale, 'scale', 'batchNorm'); - } - let $offset: Tensor4D|Tensor1D; - if (offset != null) { - $offset = convertToTensor(offset, 'offset', 'batchNorm'); - } - util.assert( - $x.rank === 4, - () => `Error in batchNorm4D: x must be rank 4 but got rank ` + - `${$x.rank}.`); - util.assert( - $mean.rank === 4 || $mean.rank === 1, - () => `Error in batchNorm4D: mean must be rank 4 or rank 1 but ` + - `got rank ${$mean.rank}.`); - util.assert( - $variance.rank === 4 || $variance.rank === 1, - () => `Error in batchNorm4D: variance must be rank 4 or rank 1 ` + - `but got rank ${$variance.rank}.`); - if ($scale != null) { - util.assert( - $scale.rank === 4 || $scale.rank === 1, - () => `Error in batchNorm4D: scale must be rank 4 or rank 1 ` + - `but got rank ${$scale.rank}.`); - } - if ($offset != null) { - util.assert( - $offset.rank === 4 || $offset.rank === 1, - () => `Error in batchNorm4D: offset must be rank 4 or rank 1 ` + - `but got rank ${$offset.rank}.`); - } - return batchNorm($x, $mean, $variance, $offset, $scale, varianceEpsilon); -} - -export const batchNorm4d = /* @__PURE__ */ op({batchNorm4d_}); diff --git a/tfjs-master/tfjs-core/src/ops/batchnorm_test.ts b/tfjs-master/tfjs-core/src/ops/batchnorm_test.ts deleted file mode 100644 index 97da7f4d5..000000000 --- a/tfjs-master/tfjs-core/src/ops/batchnorm_test.ts +++ /dev/null @@ -1,905 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('batchNorm4D', ALL_ENVS, () => { - it('simple batchnorm4D, no offset or scale, 2x1x1x2', async () => { - const xT = tf.tensor4d([2, 4, 9, 23], [2, 1, 1, 2]); - const meanT = tf.tensor1d([1, 2]); - const varianceT = tf.tensor1d([2, 3]); - const varianceEpsilon = .001; - - const result = tf.batchNorm4d( - xT, meanT, varianceT, undefined, undefined, varianceEpsilon); - - const x = await xT.array(); - const mean = await meanT.array(); - const variance = await varianceT.array(); - expectArraysClose(await result.data(), [ - (x[0][0][0][0] - mean[0]) * 1 / Math.sqrt(variance[0] + varianceEpsilon), - (x[0][0][0][1] - mean[1]) * 1 / Math.sqrt(variance[1] + varianceEpsilon), - (x[1][0][0][0] - mean[0]) * 1 / Math.sqrt(variance[0] + varianceEpsilon), - (x[1][0][0][1] - mean[1]) * 1 / Math.sqrt(variance[1] + varianceEpsilon) - ]); - }); - - it('simple batchnorm4D, no offset, 2x1x1x2', async () => { - const xT = tf.tensor4d([2, 4, 9, 23], [2, 1, 1, 2]); - const meanT = tf.tensor1d([1, 2]); - const varianceT = tf.tensor1d([2, 3]); - const scaleT = tf.tensor1d([4, 5]); - const varianceEpsilon = .001; - - const result = tf.batchNorm4d( - xT, meanT, varianceT, undefined, scaleT, varianceEpsilon); - const x = await xT.buffer(); - const mean = await meanT.buffer(); - const variance = await varianceT.buffer(); - const scale = await scaleT.buffer(); - - expectArraysClose(await result.data(), [ - (x.get(0, 0, 0, 0) - mean.get(0)) * scale.get(0) / - Math.sqrt(variance.get(0) + varianceEpsilon), - (x.get(0, 0, 0, 1) - mean.get(1)) * scale.get(1) / - Math.sqrt(variance.get(1) + varianceEpsilon), - (x.get(1, 0, 0, 0) - mean.get(0)) * scale.get(0) / - Math.sqrt(variance.get(0) + varianceEpsilon), - (x.get(1, 0, 0, 1) - mean.get(1)) * scale.get(1) / - Math.sqrt(variance.get(1) + varianceEpsilon) - ]); - }); - - it('simple batchnorm4D, no scale, 2x1x1x2', async () => { - const xT = tf.tensor4d([2, 4, 9, 23], [2, 1, 1, 2]); - const meanT = tf.tensor1d([1, 2]); - const varianceT = tf.tensor1d([2, 3]); - const offsetT = tf.tensor1d([4, 5]); - - const varianceEpsilon = .001; - - const result = tf.batchNorm4d( - xT, meanT, varianceT, offsetT, undefined, varianceEpsilon); - const x = await xT.buffer(); - const mean = await meanT.buffer(); - const variance = await varianceT.buffer(); - const offset = await offsetT.buffer(); - - expectArraysClose(await result.data(), [ - offset.get(0) + - (x.get(0, 0, 0, 0) - mean.get(0)) * 1 / - Math.sqrt(variance.get(0) + varianceEpsilon), - offset.get(1) + - (x.get(0, 0, 0, 1) - mean.get(1)) * 1 / - Math.sqrt(variance.get(1) + varianceEpsilon), - offset.get(0) + - (x.get(1, 0, 0, 0) - mean.get(0)) * 1 / - Math.sqrt(variance.get(0) + varianceEpsilon), - offset.get(1) + - (x.get(1, 0, 0, 1) - mean.get(1)) * 1 / - Math.sqrt(variance.get(1) + varianceEpsilon) - ]); - }); - - it('simple batchnorm4D, 2x1x1x2', async () => { - const xT = tf.tensor4d([2, 4, 9, 23], [2, 1, 1, 2]); - const meanT = tf.tensor1d([1, 2]); - const varianceT = tf.tensor1d([2, 3]); - const offsetT = tf.tensor1d([3, 4]); - const scaleT = tf.tensor1d([4, 5]); - - const varianceEpsilon = .001; - - const result = - tf.batchNorm4d(xT, meanT, varianceT, offsetT, scaleT, varianceEpsilon); - const x = await xT.buffer(); - const mean = await meanT.buffer(); - const variance = await varianceT.buffer(); - const scale = await scaleT.buffer(); - const offset = await offsetT.buffer(); - - expectArraysClose(await result.data(), [ - offset.get(0) + - (x.get(0, 0, 0, 0) - mean.get(0)) * scale.get(0) / - Math.sqrt(variance.get(0) + varianceEpsilon), - offset.get(1) + - (x.get(0, 0, 0, 1) - mean.get(1)) * scale.get(1) / - Math.sqrt(variance.get(1) + varianceEpsilon), - offset.get(0) + - (x.get(1, 0, 0, 0) - mean.get(0)) * scale.get(0) / - Math.sqrt(variance.get(0) + varianceEpsilon), - offset.get(1) + - (x.get(1, 0, 0, 1) - mean.get(1)) * scale.get(1) / - Math.sqrt(variance.get(1) + varianceEpsilon) - ]); - }); - - it('accepts a tensor-like object', async () => { - const x = [[[[2, 4]]], [[[9, 23]]]]; // 2x1x1x2 - const mean = [1, 2]; - const variance = [2, 3]; - const offset = [3, 4]; - const scale = [4, 5]; - - const varianceEpsilon = .001; - - const result = - tf.batchNorm4d(x, mean, variance, offset, scale, varianceEpsilon); - - expectArraysClose(await result.data(), [ - offset[0] + - (x[0][0][0][0] - mean[0]) * scale[0] / - Math.sqrt(variance[0] + varianceEpsilon), - offset[1] + - (x[0][0][0][1] - mean[1]) * scale[1] / - Math.sqrt(variance[1] + varianceEpsilon), - offset[0] + - (x[1][0][0][0] - mean[0]) * scale[0] / - Math.sqrt(variance[0] + varianceEpsilon), - offset[1] + - (x[1][0][0][1] - mean[1]) * scale[1] / - Math.sqrt(variance[1] + varianceEpsilon) - ]); - }); - - it('simple batchnorm4D gradients, 2x1x1x2', async () => { - const x = tf.tensor4d([2, 4, 9, 23], [2, 1, 1, 2]); - const mean = tf.tensor1d([1, 2]); - const variance = tf.tensor1d([2, 3]); - const offset = tf.tensor1d([3, 4]); - const scale = tf.tensor1d([2, 5]); - - const varianceEpsilon = .001; - - const dy = tf.tensor4d([-1, -1, -1, -1], [2, 1, 1, 2]); - const gradX = tf.grad( - (x: tf.Tensor4D) => tf.batchNorm4d( - x, mean, variance, offset, scale, varianceEpsilon))(x, dy); - expectArraysClose(await gradX.data(), [-1.414, -2.887, -1.414, -2.887]); - expect(gradX.shape).toEqual([2, 1, 1, 2]); - const gradMean = tf.grad( - (mean: tf.Tensor1D) => tf.batchNorm4d( - x, mean, variance, offset, scale, varianceEpsilon))(mean, dy); - expectArraysClose(await gradMean.data(), [2.828, 5.773]); - expect(gradMean.shape).toEqual([2]); - const gradVariance = tf.grad( - (variance: tf.Tensor1D) => tf.batchNorm4d( - x, mean, variance, offset, scale, varianceEpsilon))(variance, dy); - expectArraysClose(await gradVariance.data(), [3.180, 11.060]); - expect(gradVariance.shape).toEqual([2]); - const gradOffset = tf.grad( - (offset: tf.Tensor1D) => tf.batchNorm4d( - x, mean, variance, offset, scale, varianceEpsilon))(offset, dy); - expectArraysClose(await gradOffset.data(), await dy.sum([0, 1, 2]).data()); - expect(gradOffset.shape).toEqual([2]); - const gradScale = tf.grad( - (scale: tf.Tensor1D) => tf.batchNorm4d( - x, mean, variance, offset, scale, varianceEpsilon))(scale, dy); - expectArraysClose(await gradScale.data(), [-6.362, -13.277]); - expect(gradScale.shape).toEqual([2]); - }); - - it('batchnorm4D gradients, same shapes in x, mean and variance', async () => { - const x = tf.tensor4d([10, 20, 30, 40], [2, 1, 1, 2]); - const mean = tf.tensor4d([0, 5, 10, 15], [2, 1, 1, 2]); - const variance = tf.tensor4d([2, 4, 6, 8], [2, 1, 1, 2]); - const scale = tf.tensor4d([2, 5, 2, 5], [2, 1, 1, 2]); - const offset = tf.tensor4d([0, 0, 0, 0], [2, 1, 1, 2]); - - const varianceEpsilon = .001; - - const dy = tf.tensor4d([-1, -1, -1, -1], [2, 1, 1, 2]); - const gradX = tf.grad( - (x: tf.Tensor4D) => tf.batchNorm4d( - x, mean, variance, offset, scale, varianceEpsilon))(x, dy); - expectArraysClose(await gradX.data(), [-1.414, -2.500, -0.816, -1.768]); - expect(gradX.shape).toEqual([2, 1, 1, 2]); - const gradMean = tf.grad( - (mean: tf.Tensor4D) => tf.batchNorm4d( - x, mean, variance, offset, scale, varianceEpsilon))(mean, dy); - expectArraysClose(await gradMean.data(), [1.414, 2.500, 0.816, 1.768]); - expect(gradMean.shape).toEqual([2, 1, 1, 2]); - const gradVariance = tf.grad( - (variance: tf.Tensor4D) => tf.batchNorm4d( - x, mean, variance, offset, scale, varianceEpsilon))(variance, dy); - expectArraysClose(await gradVariance.data(), [3.533, 4.686, 1.360, 2.762]); - expect(gradVariance.shape).toEqual([2, 1, 1, 2]); - const gradOffset = tf.grad( - (offset: tf.Tensor4D) => tf.batchNorm4d( - x, mean, variance, offset, scale, varianceEpsilon))(offset, dy); - expectArraysClose(await gradOffset.data(), await dy.data()); - expect(gradOffset.shape).toEqual([2, 1, 1, 2]); - const gradScale = tf.grad( - (scale: tf.Tensor4D) => tf.batchNorm4d( - x, mean, variance, offset, scale, varianceEpsilon))(scale, dy); - expectArraysClose(await gradScale.data(), [-7.069, -7.499, -8.164, -8.838]); - expect(gradScale.shape).toEqual([2, 1, 1, 2]); - }); -}); - -describeWithFlags('batchNorm3D', ALL_ENVS, () => { - it('simple batchnorm3D, no offset or scale, 2x1x2', async () => { - const xT = tf.tensor3d([2, 4, 9, 23], [2, 1, 2]); - const meanT = tf.tensor1d([1, 2]); - const varianceT = tf.tensor1d([2, 3]); - const varianceEpsilon = .001; - - const result = tf.batchNorm3d( - xT, meanT, varianceT, undefined, undefined, varianceEpsilon); - const x = await xT.buffer(); - const mean = await meanT.buffer(); - const variance = await varianceT.buffer(); - expectArraysClose(await result.data(), [ - (x.get(0, 0, 0) - mean.get(0)) * 1 / - Math.sqrt(variance.get(0) + varianceEpsilon), - (x.get(0, 0, 1) - mean.get(1)) * 1 / - Math.sqrt(variance.get(1) + varianceEpsilon), - (x.get(1, 0, 0) - mean.get(0)) * 1 / - Math.sqrt(variance.get(0) + varianceEpsilon), - (x.get(1, 0, 1) - mean.get(1)) * 1 / - Math.sqrt(variance.get(1) + varianceEpsilon) - ]); - }); - - it('simple batchnorm3D, no offset, 2x1x2', async () => { - const xT = tf.tensor3d([2, 4, 9, 23], [2, 1, 2]); - const meanT = tf.tensor1d([1, 2]); - const varianceT = tf.tensor1d([2, 3]); - const scaleT = tf.tensor1d([4, 5]); - const varianceEpsilon = .001; - - const result = tf.batchNorm3d( - xT, meanT, varianceT, undefined, scaleT, varianceEpsilon); - - const x = await xT.buffer(); - const mean = await meanT.buffer(); - const variance = await varianceT.buffer(); - const scale = await scaleT.buffer(); - expectArraysClose(await result.data(), [ - (x.get(0, 0, 0) - mean.get(0)) * scale.get(0) / - Math.sqrt(variance.get(0) + varianceEpsilon), - (x.get(0, 0, 1) - mean.get(1)) * scale.get(1) / - Math.sqrt(variance.get(1) + varianceEpsilon), - (x.get(1, 0, 0) - mean.get(0)) * scale.get(0) / - Math.sqrt(variance.get(0) + varianceEpsilon), - (x.get(1, 0, 1) - mean.get(1)) * scale.get(1) / - Math.sqrt(variance.get(1) + varianceEpsilon) - ]); - }); - - it('simple batchnorm3D, no scale, 2x1x2', async () => { - const xT = tf.tensor3d([2, 4, 9, 23], [2, 1, 2]); - const meanT = tf.tensor1d([1, 2]); - const varianceT = tf.tensor1d([2, 3]); - const offsetT = tf.tensor1d([4, 5]); - - const varianceEpsilon = .001; - - const result = tf.batchNorm3d( - xT, meanT, varianceT, offsetT, undefined, varianceEpsilon); - - const x = await xT.buffer(); - const mean = await meanT.buffer(); - const variance = await varianceT.buffer(); - const offset = await offsetT.buffer(); - expectArraysClose(await result.data(), [ - offset.get(0) + - (x.get(0, 0, 0) - mean.get(0)) * 1 / - Math.sqrt(variance.get(0) + varianceEpsilon), - offset.get(1) + - (x.get(0, 0, 1) - mean.get(1)) * 1 / - Math.sqrt(variance.get(1) + varianceEpsilon), - offset.get(0) + - (x.get(1, 0, 0) - mean.get(0)) * 1 / - Math.sqrt(variance.get(0) + varianceEpsilon), - offset.get(1) + - (x.get(1, 0, 1) - mean.get(1)) * 1 / - Math.sqrt(variance.get(1) + varianceEpsilon) - ]); - }); - - it('simple batchnorm3D, 2x1x2', async () => { - const xT = tf.tensor3d([2, 4, 9, 23], [2, 1, 2]); - const meanT = tf.tensor1d([1, 2]); - const varianceT = tf.tensor1d([2, 3]); - const offsetT = tf.tensor1d([3, 4]); - const scaleT = tf.tensor1d([4, 5]); - - const varianceEpsilon = .001; - - const result = - tf.batchNorm3d(xT, meanT, varianceT, offsetT, scaleT, varianceEpsilon); - const x = await xT.buffer(); - const mean = await meanT.buffer(); - const variance = await varianceT.buffer(); - const offset = await offsetT.buffer(); - const scale = await scaleT.buffer(); - - expectArraysClose(await result.data(), [ - offset.get(0) + - (x.get(0, 0, 0) - mean.get(0)) * scale.get(0) / - Math.sqrt(variance.get(0) + varianceEpsilon), - offset.get(1) + - (x.get(0, 0, 1) - mean.get(1)) * scale.get(1) / - Math.sqrt(variance.get(1) + varianceEpsilon), - offset.get(0) + - (x.get(1, 0, 0) - mean.get(0)) * scale.get(0) / - Math.sqrt(variance.get(0) + varianceEpsilon), - offset.get(1) + - (x.get(1, 0, 1) - mean.get(1)) * scale.get(1) / - Math.sqrt(variance.get(1) + varianceEpsilon) - ]); - }); - - it('accepts a tensor-like object', async () => { - const x = [[[2, 4]], [[9, 23]]]; // 2x1x2 - const mean = [1, 2]; - const variance = [2, 3]; - const offset = [3, 4]; - const scale = [4, 5]; - - const varianceEpsilon = .001; - - const result = - tf.batchNorm3d(x, mean, variance, offset, scale, varianceEpsilon); - - expectArraysClose(await result.data(), [ - offset[0] + - (x[0][0][0] - mean[0]) * scale[0] / - Math.sqrt(variance[0] + varianceEpsilon), - offset[1] + - (x[0][0][1] - mean[1]) * scale[1] / - Math.sqrt(variance[1] + varianceEpsilon), - offset[0] + - (x[1][0][0] - mean[0]) * scale[0] / - Math.sqrt(variance[0] + varianceEpsilon), - offset[1] + - (x[1][0][1] - mean[1]) * scale[1] / - Math.sqrt(variance[1] + varianceEpsilon) - ]); - }); - - it('batchnorm3D, x,mean,var,offset,scale are all 3D', async () => { - const shape: [number, number, number] = [2, 1, 2]; - const xT = tf.tensor3d([2, 4, 9, 23], shape); - const meanT = tf.tensor3d([1, 2, 3, 4], shape); - const varianceT = tf.tensor3d([2, 3, 4, 5], shape); - const offsetT = tf.tensor3d([3, 4, 5, 6], shape); - const scaleT = tf.tensor3d([4, 5, 6, 7], shape); - - const varianceEpsilon = .001; - - const result = - tf.batchNorm3d(xT, meanT, varianceT, offsetT, scaleT, varianceEpsilon); - - const x = await xT.buffer(); - const mean = await meanT.buffer(); - const variance = await varianceT.buffer(); - const offset = await offsetT.buffer(); - const scale = await scaleT.buffer(); - expectArraysClose(await result.data(), [ - offset.get(0, 0, 0) + - (x.get(0, 0, 0) - mean.get(0, 0, 0)) * scale.get(0, 0, 0) / - Math.sqrt(variance.get(0, 0, 0) + varianceEpsilon), - offset.get(0, 0, 1) + - (x.get(0, 0, 1) - mean.get(0, 0, 1)) * scale.get(0, 0, 1) / - Math.sqrt(variance.get(0, 0, 1) + varianceEpsilon), - offset.get(1, 0, 0) + - (x.get(1, 0, 0) - mean.get(1, 0, 0)) * scale.get(1, 0, 0) / - Math.sqrt(variance.get(1, 0, 0) + varianceEpsilon), - offset.get(1, 0, 1) + - (x.get(1, 0, 1) - mean.get(1, 0, 1)) * scale.get(1, 0, 1) / - Math.sqrt(variance.get(1, 0, 1) + varianceEpsilon) - ]); - }); - - it('simple batchnorm3D gradients, 2x1x2', async () => { - const x = tf.tensor3d([2, 4, 9, 23], [2, 1, 2]); - const mean = tf.tensor1d([1, 2]); - const variance = tf.tensor1d([2, 3]); - const offset = tf.tensor1d([3, 4]); - const scale = tf.tensor1d([2, 5]); - - const varianceEpsilon = .001; - - const dy = tf.tensor3d([1, 1, 1, 1], [2, 1, 2]); - const gradX = tf.grad( - (x: tf.Tensor3D) => tf.batchNorm3d( - x, mean, variance, offset, scale, varianceEpsilon))(x, dy); - expectArraysClose(await gradX.data(), [1.414, 2.887, 1.414, 2.887]); - expect(gradX.shape).toEqual([2, 1, 2]); - const gradMean = tf.grad( - (mean: tf.Tensor1D) => tf.batchNorm3d( - x, mean, variance, offset, scale, varianceEpsilon))(mean, dy); - expectArraysClose(await gradMean.data(), [-2.828, -5.773]); - expect(gradMean.shape).toEqual([2]); - const gradVariance = tf.grad( - (variance: tf.Tensor1D) => tf.batchNorm3d( - x, mean, variance, offset, scale, varianceEpsilon))(variance, dy); - expectArraysClose(await gradVariance.data(), [-3.180, -11.060]); - expect(gradVariance.shape).toEqual([2]); - const gradOffset = tf.grad( - (offset: tf.Tensor1D) => tf.batchNorm3d( - x, mean, variance, offset, scale, varianceEpsilon))(offset, dy); - expectArraysClose(await gradOffset.data(), [2, 2]); - expect(gradOffset.shape).toEqual([2]); - const gradScale = tf.grad( - (scale: tf.Tensor1D) => tf.batchNorm3d( - x, mean, variance, offset, scale, varianceEpsilon))(scale, dy); - expectArraysClose(await gradScale.data(), [6.362, 13.277]); - expect(gradScale.shape).toEqual([2]); - }); - - it('batchnorm3D gradients, same shapes in x, mean and variance', async () => { - const x = tf.tensor3d([10, 20, 30, 40], [2, 1, 2]); - const mean = tf.tensor3d([0, 5, 10, 15], [2, 1, 2]); - const variance = tf.tensor3d([2, 4, 6, 8], [2, 1, 2]); - const scale = tf.tensor3d([2, 5, 2, 5], [2, 1, 2]); - const offset = tf.tensor3d([0, 0, 0, 0], [2, 1, 2]); - - const varianceEpsilon = .001; - - const dy = tf.tensor3d([1, 1, 1, 1], [2, 1, 2]); - const gradX = tf.grad( - (x: tf.Tensor3D) => tf.batchNorm3d( - x, mean, variance, offset, scale, varianceEpsilon))(x, dy); - expectArraysClose(await gradX.data(), [1.414, 2.500, 0.816, 1.768]); - expect(gradX.shape).toEqual([2, 1, 2]); - const gradMean = tf.grad( - (mean: tf.Tensor3D) => tf.batchNorm3d( - x, mean, variance, offset, scale, varianceEpsilon))(mean, dy); - expectArraysClose(await gradMean.data(), [-1.414, -2.500, -0.816, -1.768]); - expect(gradMean.shape).toEqual([2, 1, 2]); - const gradVariance = tf.grad( - (variance: tf.Tensor3D) => tf.batchNorm3d( - x, mean, variance, offset, scale, varianceEpsilon))(variance, dy); - expectArraysClose( - await gradVariance.data(), [-3.533, -4.686, -1.360, -2.762]); - expect(gradVariance.shape).toEqual([2, 1, 2]); - const gradOffset = tf.grad( - (offset: tf.Tensor3D) => tf.batchNorm3d( - x, mean, variance, offset, scale, varianceEpsilon))(offset, dy); - expectArraysClose(await gradOffset.data(), [1, 1, 1, 1]); - expect(gradOffset.shape).toEqual([2, 1, 2]); - const gradScale = tf.grad( - (scale: tf.Tensor3D) => tf.batchNorm3d( - x, mean, variance, offset, scale, varianceEpsilon))(scale, dy); - expectArraysClose(await gradScale.data(), [7.069, 7.499, 8.164, 8.838]); - expect(gradScale.shape).toEqual([2, 1, 2]); - }); - - it('batchnorm matches tensorflow, 2x3x3', async () => { - const x = tf.tensor3d( - [ - 0.49955603, 0.04158615, -1.09440524, 2.03854165, -0.61578344, - 2.87533573, 1.18105987, 0.807462, 1.87888837, 2.26563962, -0.37040935, - 1.35848753, -0.75347094, 0.15683117, 0.91925946, 0.34121279, - 0.92717143, 1.89683965 - ], - [2, 3, 3]); - const mean = tf.tensor1d([0.39745062, -0.48062894, 0.4847822]); - const variance = tf.tensor1d([0.32375343, 0.67117643, 1.08334653]); - const offset = tf.tensor1d([0.69398749, -1.29056387, 0.9429723]); - const scale = tf.tensor1d([-0.5607271, 0.9878457, 0.25181573]); - const varianceEpsilon = .001; - - const result = - tf.batchNorm3d(x, mean, variance, offset, scale, varianceEpsilon); - - expectArraysClose(await result.data(), [ - 0.59352049, -0.66135202, 0.5610874, -0.92077015, -1.45341019, 1.52106473, - -0.07704776, 0.26144429, 1.28010017, -1.14422404, -1.15776136, 1.15425493, - 1.82644104, -0.52249442, 1.04803919, 0.74932291, 0.40568101, 1.2844412 - ]); - }); -}); - -describeWithFlags('batchNorm2D', ALL_ENVS, () => { - it('simple batchnorm2D, no offset or scale, 2x2', async () => { - const xT = tf.tensor2d([2, 4, 9, 23], [2, 2]); - const meanT = tf.tensor1d([1, 2]); - const varianceT = tf.tensor1d([2, 3]); - const varianceEpsilon = .001; - - const result = tf.batchNorm2d( - xT, meanT, varianceT, undefined, undefined, varianceEpsilon); - - const x = await xT.buffer(); - const mean = await meanT.buffer(); - const variance = await varianceT.buffer(); - expectArraysClose(await result.data(), [ - (x.get(0, 0) - mean.get(0)) * 1 / - Math.sqrt(variance.get(0) + varianceEpsilon), - (x.get(0, 1) - mean.get(1)) * 1 / - Math.sqrt(variance.get(1) + varianceEpsilon), - (x.get(1, 0) - mean.get(0)) * 1 / - Math.sqrt(variance.get(0) + varianceEpsilon), - (x.get(1, 1) - mean.get(1)) * 1 / - Math.sqrt(variance.get(1) + varianceEpsilon) - ]); - }); - it('simple batchnorm2D, no offset, 2x2', async () => { - const xT = tf.tensor2d([2, 4, 9, 23], [2, 2]); - const meanT = tf.tensor1d([1, 2]); - const varianceT = tf.tensor1d([2, 3]); - const scaleT = tf.tensor1d([4, 5]); - const varianceEpsilon = .001; - - const result = tf.batchNorm2d( - xT, meanT, varianceT, undefined, scaleT, varianceEpsilon); - - const x = await xT.buffer(); - const mean = await meanT.buffer(); - const variance = await varianceT.buffer(); - const scale = await scaleT.buffer(); - expectArraysClose(await result.data(), [ - (x.get(0, 0) - mean.get(0)) * scale.get(0) / - Math.sqrt(variance.get(0) + varianceEpsilon), - (x.get(0, 1) - mean.get(1)) * scale.get(1) / - Math.sqrt(variance.get(1) + varianceEpsilon), - (x.get(1, 0) - mean.get(0)) * scale.get(0) / - Math.sqrt(variance.get(0) + varianceEpsilon), - (x.get(1, 1) - mean.get(1)) * scale.get(1) / - Math.sqrt(variance.get(1) + varianceEpsilon) - ]); - }); - - it('simple batchnorm2D, no scale, 2x2', async () => { - const xT = tf.tensor2d([2, 4, 9, 23], [2, 2]); - const meanT = tf.tensor1d([1, 2]); - const varianceT = tf.tensor1d([2, 3]); - const offsetT = tf.tensor1d([4, 5]); - - const varianceEpsilon = .001; - - const result = tf.batchNorm2d( - xT, meanT, varianceT, offsetT, undefined, varianceEpsilon); - - const offset = await offsetT.array(); - const mean = await meanT.array(); - const variance = await varianceT.array(); - const x = await xT.array(); - - expectArraysClose(await result.data(), [ - offset[0] + - (x[0][0] - mean[0]) * 1 / Math.sqrt(variance[0] + varianceEpsilon), - offset[1] + - (x[0][1] - mean[1]) * 1 / Math.sqrt(variance[1] + varianceEpsilon), - offset[0] + - (x[1][0] - mean[0]) * 1 / Math.sqrt(variance[0] + varianceEpsilon), - offset[1] + - (x[1][1] - mean[1]) * 1 / Math.sqrt(variance[1] + varianceEpsilon) - ]); - }); - - it('simple batchnorm2D, 2x2', async () => { - const xT = tf.tensor2d([2, 4, 9, 23], [2, 2]); - const meanT = tf.tensor1d([1, 2]); - const varianceT = tf.tensor1d([2, 3]); - const offsetT = tf.tensor1d([3, 4]); - const scaleT = tf.tensor1d([4, 5]); - - const varianceEpsilon = .001; - - const result = - tf.batchNorm2d(xT, meanT, varianceT, offsetT, scaleT, varianceEpsilon); - - const offset = await offsetT.array(); - const mean = await meanT.array(); - const variance = await varianceT.array(); - const scale = await scaleT.array(); - const x = await xT.array(); - - expectArraysClose(await result.data(), [ - offset[0] + - (x[0][0] - mean[0]) * scale[0] / - Math.sqrt(variance[0] + varianceEpsilon), - offset[1] + - (x[0][1] - mean[1]) * scale[1] / - Math.sqrt(variance[1] + varianceEpsilon), - offset[0] + - (x[1][0] - mean[0]) * scale[0] / - Math.sqrt(variance[0] + varianceEpsilon), - offset[1] + - (x[1][1] - mean[1]) * scale[1] / - Math.sqrt(variance[1] + varianceEpsilon) - ]); - }); - - it('simple batchnorm2D gradients, 2x2', async () => { - const x = tf.tensor2d([2, 4, 9, 23], [2, 2]); - const mean = tf.tensor1d([1, 2]); - const variance = tf.tensor1d([2, 3]); - const offset = tf.tensor1d([3, 4]); - const scale = tf.tensor1d([2, 5]); - - const varianceEpsilon = .001; - - const dy = tf.tensor2d([1, 1, 1, 1], [2, 2]); - const [gradX, gradMean, gradVariance, gradOffset, gradScale] = tf.grads( - (x: tf.Tensor2D, mean: tf.Tensor1D, variance: tf.Tensor1D, - offset: tf.Tensor1D, scale: tf.Tensor1D) => - tf.batchNorm2d(x, mean, variance, offset, scale, varianceEpsilon))( - [x, mean, variance, offset, scale], dy); - expectArraysClose(await gradX.data(), [1.414, 2.887, 1.414, 2.887]); - expect(gradX.shape).toEqual([2, 2]); - expectArraysClose(await gradMean.data(), [-2.828, -5.773]); - expect(gradMean.shape).toEqual([2]); - expectArraysClose(await gradVariance.data(), [-3.180, -11.060]); - expect(gradVariance.shape).toEqual([2]); - expectArraysClose(await gradOffset.data(), [2, 2]); - expect(gradOffset.shape).toEqual([2]); - expectArraysClose(await gradScale.data(), [6.362, 13.277]); - expect(gradScale.shape).toEqual([2]); - }); - - it('gradient with clones batchnorm2D', async () => { - const x = tf.tensor2d([2, 4, 9, 23], [2, 2]); - const mean = tf.tensor1d([1, 2]); - const variance = tf.tensor1d([2, 3]); - const offset = tf.tensor1d([3, 4]); - const scale = tf.tensor1d([2, 5]); - - const varianceEpsilon = .001; - - const dy = tf.tensor2d([1, 1, 1, 1], [2, 2]); - const [gradX, gradMean, gradVariance, gradOffset, gradScale] = tf.grads( - (x: tf.Tensor2D, mean: tf.Tensor1D, variance: tf.Tensor1D, - offset: tf.Tensor1D, scale: tf.Tensor1D) => - tf.batchNorm2d( - x.clone(), mean.clone(), variance.clone(), offset.clone(), - scale.clone(), varianceEpsilon) - .clone())([x, mean, variance, offset, scale], dy); - expectArraysClose(await gradX.data(), [1.414, 2.887, 1.414, 2.887]); - expect(gradX.shape).toEqual([2, 2]); - expectArraysClose(await gradMean.data(), [-2.828, -5.773]); - expect(gradMean.shape).toEqual([2]); - expectArraysClose(await gradVariance.data(), [-3.180, -11.060]); - expect(gradVariance.shape).toEqual([2]); - expectArraysClose(await gradOffset.data(), [2, 2]); - expect(gradOffset.shape).toEqual([2]); - expectArraysClose(await gradScale.data(), [6.362, 13.277]); - expect(gradScale.shape).toEqual([2]); - }); - - it('batchnorm2D gradients, same shapes in x, mean and variance', async () => { - const x = tf.tensor2d([10, 20, 30, 40], [2, 2]); - const mean = tf.tensor2d([0, 5, 10, 15], [2, 2]); - const variance = tf.tensor2d([2, 4, 6, 8], [2, 2]); - const scale = tf.tensor2d([2, 5, 2, 5], [2, 2]); - const offset = tf.tensor2d([0, 0, 0, 0], [2, 2]); - - const varianceEpsilon = .001; - - const dy = tf.tensor2d([1, 1, 1, 1], [2, 2]); - const gradX = tf.grad( - (x: tf.Tensor2D) => tf.batchNorm2d( - x, mean, variance, offset, scale, varianceEpsilon))(x, dy); - expectArraysClose(await gradX.data(), [1.414, 2.500, 0.816, 1.768]); - expect(gradX.shape).toEqual([2, 2]); - const gradMean = tf.grad( - (mean: tf.Tensor2D) => tf.batchNorm2d( - x, mean, variance, offset, scale, varianceEpsilon))(mean, dy); - expectArraysClose(await gradMean.data(), [-1.414, -2.500, -0.816, -1.768]); - expect(gradMean.shape).toEqual([2, 2]); - const gradVariance = tf.grad( - (variance: tf.Tensor2D) => tf.batchNorm2d( - x, mean, variance, offset, scale, varianceEpsilon))(variance, dy); - expectArraysClose( - await gradVariance.data(), [-3.533, -4.686, -1.360, -2.762]); - expect(gradVariance.shape).toEqual([2, 2]); - const gradOffset = tf.grad( - (offset: tf.Tensor2D) => tf.batchNorm2d( - x, mean, variance, offset, scale, varianceEpsilon))(offset, dy); - expectArraysClose(await gradOffset.data(), [1, 1, 1, 1]); - expect(gradOffset.shape).toEqual([2, 2]); - const gradScale = tf.grad( - (scale: tf.Tensor2D) => tf.batchNorm2d( - x, mean, variance, offset, scale, varianceEpsilon))(scale, dy); - expectArraysClose(await gradScale.data(), [7.069, 7.499, 8.164, 8.838]); - expect(gradScale.shape).toEqual([2, 2]); - }); - - it('gradient with clones', () => { - const x = tf.zeros([2, 2]); - const mean = tf.zeros([2, 2]); - const variance = tf.zeros([2, 2]); - const scale = tf.zeros([2, 2]); - const offset = tf.zeros([2, 2]); - - const varianceEpsilon = .001; - - const gradF = tf.grads( - (x: tf.Tensor2D, mean: tf.Tensor2D, variance: tf.Tensor2D, - offset: tf.Tensor2D, scale: tf.Tensor2D) => - tf.batchNorm2d( - x.clone(), mean.clone(), variance.clone(), offset.clone(), - scale.clone(), varianceEpsilon) - .clone()); - const [gradX, gradMean, gradVariance, gradOffset, gradScale] = - gradF([x, mean, variance, offset, scale]); - expect(gradX.shape).toEqual(x.shape); - expect(gradMean.shape).toEqual(mean.shape); - expect(gradVariance.shape).toEqual(variance.shape); - expect(gradOffset.shape).toEqual(offset.shape); - expect(gradScale.shape).toEqual(scale.shape); - }); - - it('batchnorm2D matches tensorflow, 3x3', async () => { - const x = tf.tensor2d( - [ - 0.3136892, 0.92389025, 0.594782, 0.05021042, 0.67545404, 0.93910035, - 0.13277993, 0.96474269, 0.88608916 - ], - [3, 3]); - const mean = tf.tensor1d([0.19526312, 0.74857256, 0.45166398]); - const variance = tf.tensor1d([0.22963001, 0.61521992, 0.46623685]); - const offset = tf.tensor1d([0.43098484, 0.77712237, 0.47916298]); - const scale = tf.tensor1d([0.62186907, 0.85673736, 0.19201061]); - const varianceEpsilon = .001; - - const result = - tf.batchNorm2d(x, mean, variance, offset, scale, varianceEpsilon); - - expectArraysClose(await result.data(), [ - 0.58433646, 0.96846228, 0.51936529, 0.24315402, 0.69732157, 0.61608542, - 0.35007446, 1.01304821, 0.60119441 - ]); - }); - - it('throws when passed x as a non-tensor', () => { - const mean = tf.tensor1d([1, 2]); - const variance = tf.tensor1d([2, 3]); - - expect(() => tf.batchNorm({} as tf.Tensor, mean, variance)) - .toThrowError(/Argument 'x' passed to 'batchNorm' must be a Tensor/); - }); - it('throws when passed mean as a non-tensor', () => { - const x = tf.tensor4d([2, 4, 9, 23], [2, 1, 1, 2]); - const variance = tf.tensor1d([2, 3]); - - expect(() => tf.batchNorm(x, {} as tf.Tensor, variance)) - .toThrowError(/Argument 'mean' passed to 'batchNorm' must be a Tensor/); - }); - it('throws when passed variance as a non-tensor', () => { - const x = tf.tensor4d([2, 4, 9, 23], [2, 1, 1, 2]); - const mean = tf.tensor1d([1, 2]); - - const e = /Argument 'variance' passed to 'batchNorm' must be a Tensor/; - expect(() => tf.batchNorm(x, mean, {} as tf.Tensor)).toThrowError(e); - }); - it('throws when passed scale as a non-tensor', () => { - const x = tf.tensor4d([2, 4, 9, 23], [2, 1, 1, 2]); - const mean = tf.tensor1d([1, 2]); - const variance = tf.tensor1d([2, 3]); - const epsilon = .001; - - expect(() => tf.batchNorm(x, mean, variance, epsilon, {} as tf.Tensor)) - .toThrowError( - /Argument 'scale' passed to 'batchNorm' must be a Tensor/); - }); - it('throws when passed offset as a non-tensor', () => { - const x = tf.tensor4d([2, 4, 9, 23], [2, 1, 1, 2]); - const mean = tf.tensor1d([1, 2]); - const variance = tf.tensor1d([2, 3]); - const epsilon = .001; - const scale = tf.tensor1d([0.62186907, 0.85673736, 0.19201061]); - - const e = /Argument 'offset' passed to 'batchNorm' must be a Tensor/; - expect( - () => tf.batchNorm(x, mean, variance, {} as tf.Tensor, scale, epsilon)) - .toThrowError(e); - }); - - it('accepts a tensor-like object', async () => { - const x = [[2, 4], [9, 23]]; - const mean = [1, 2]; - const variance = [2, 3]; - const offset = [3, 4]; - const scale = [4, 5]; - - const varianceEpsilon = .001; - - const result = - tf.batchNorm2d(x, mean, variance, offset, scale, varianceEpsilon); - - expectArraysClose(await result.data(), [ - offset[0] + - (x[0][0] - mean[0]) * scale[0] / - Math.sqrt(variance[0] + varianceEpsilon), - offset[1] + - (x[0][1] - mean[1]) * scale[1] / - Math.sqrt(variance[1] + varianceEpsilon), - offset[0] + - (x[1][0] - mean[0]) * scale[0] / - Math.sqrt(variance[0] + varianceEpsilon), - offset[1] + - (x[1][1] - mean[1]) * scale[1] / - Math.sqrt(variance[1] + varianceEpsilon) - ]); - }); - - it('throws error when x is a string tensor', () => { - const mean = [1, 2]; - const variance = [2, 3]; - const offset = [3, 4]; - const scale = [4, 5]; - - const varianceEpsilon = .001; - - const f = () => tf.batchNorm2d( - [['a', 'b'], ['c', 'd']], mean, variance, offset, scale, - varianceEpsilon); - expect(f).toThrowError( - /Argument 'x' passed to 'batchNorm' must be numeric/); - }); - - it('throws error when mean is a string tensor', () => { - const x = [[2, 4], [9, 23]]; - const variance = [2, 3]; - const offset = [3, 4]; - const scale = [4, 5]; - - const varianceEpsilon = .001; - - const f = () => - tf.batchNorm2d(x, ['a', 'b'], variance, offset, scale, varianceEpsilon); - expect(f).toThrowError( - /Argument 'mean' passed to 'batchNorm' must be numeric/); - }); - - it('throws error when variance is a string tensor', () => { - const x = [[2, 4], [9, 23]]; - const mean = [1, 2]; - const offset = [3, 4]; - const scale = [4, 5]; - - const varianceEpsilon = .001; - - const f = () => - tf.batchNorm2d(x, mean, ['a', 'b'], offset, scale, varianceEpsilon); - expect(f).toThrowError(/'variance' passed to 'batchNorm' must be numeric/); - }); - - it('throws error when scale is a string tensor', () => { - const x = [[2, 4], [9, 23]]; - const mean = [1, 2]; - const variance = [2, 3]; - const offset = [3, 4]; - - const varianceEpsilon = .001; - - const f = () => - tf.batchNorm2d(x, mean, variance, offset, ['a', 'b'], varianceEpsilon); - expect(f).toThrowError(/'scale' passed to 'batchNorm' must be numeric/); - }); - - it('throws error when offset is a string tensor', () => { - const x = [[2, 4], [9, 23]]; - const mean = [1, 2]; - const variance = [2, 3]; - const scale = [4, 5]; - - const varianceEpsilon = .001; - - const f = () => - tf.batchNorm2d(x, mean, variance, ['a', 'b'], scale, varianceEpsilon); - expect(f).toThrowError(/'offset' passed to 'batchNorm' must be numeric/); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/batchnorm_util.ts b/tfjs-master/tfjs-core/src/ops/batchnorm_util.ts deleted file mode 100644 index f85b4c097..000000000 --- a/tfjs-master/tfjs-core/src/ops/batchnorm_util.ts +++ /dev/null @@ -1,34 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {Tensor, Tensor4D} from '../tensor'; -import {Rank} from '../types'; -import {reshape} from './reshape'; - -export function xAs4D(x: Tensor) { - let x4D: Tensor4D; - if (x.rank === 0 || x.rank === 1) { - x4D = reshape(x, [1, 1, 1, x.size]); - } else if (x.rank === 2) { - x4D = reshape(x, [1, 1, x.shape[0], x.shape[1]]); - } else if (x.rank === 3) { - x4D = reshape(x, [1, x.shape[0], x.shape[1], x.shape[2]]); - } else { - x4D = x as Tensor4D; - } - - return x4D; -} diff --git a/tfjs-master/tfjs-core/src/ops/binary_ops_test.ts b/tfjs-master/tfjs-core/src/ops/binary_ops_test.ts deleted file mode 100644 index 56f1de170..000000000 --- a/tfjs-master/tfjs-core/src/ops/binary_ops_test.ts +++ /dev/null @@ -1,1305 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose, expectArraysEqual} from '../test_util'; - -describeWithFlags('prelu', ALL_ENVS, () => { - it('basic', async () => { - const x = tf.tensor1d([0, 1, -2, -4]); - const a = tf.tensor1d([0.15, 0.2, 0.25, 0.15]); - const result = tf.prelu(x, a); - - expect(result.shape).toEqual(x.shape); - expectArraysClose(await result.data(), [0, 1, -0.5, -0.6]); - }); - - it('basic TensorLike', async () => { - const x = [0, 1, -2, -4]; - const a = [0.15, 0.2, 0.25, 0.15]; - const result = tf.prelu(x, a); - - expect(result.shape).toEqual([4]); - expectArraysClose(await result.data(), [0, 1, -0.5, -0.6]); - }); - - it('basic TensorLike chained', async () => { - const x = tf.tensor1d([0, 1, -2, -4]); - const a = [0.15, 0.2, 0.25, 0.15]; - const result = x.prelu(a); - - expect(result.shape).toEqual(x.shape); - expectArraysClose(await result.data(), [0, 1, -0.5, -0.6]); - }); - - it('basic int32', async () => { - const x = tf.tensor1d([0, 1, -2, -4], 'int32'); - const a = [0.15, 0.2, 0.25, 0.15]; - const result = tf.prelu(x, a); - - expect(result.shape).toEqual([4]); - expect(result.dtype).toEqual('float32'); - expectArraysClose(await result.data(), [0, 1, -0.5, -0.6]); - }); - - it('derivative', async () => { - const x = tf.tensor1d([0.5, 3, -0.1, -4]); - const a = tf.tensor1d([0.2, 0.4, 0.25, 0.15]); - const dy = tf.tensor1d([1, 1, 1, 1]); - - const dx = tf.grad(x => tf.prelu(x, a))(x, dy); - - expect(dx.shape).toEqual(x.shape); - expect(dx.dtype).toEqual('float32'); - expectArraysClose(await dx.data(), [1, 1, 0.25, 0.15]); - }); - - it('gradient with clones', async () => { - const x = tf.tensor1d([0.5, 3, -0.1, -4]); - const a = tf.tensor1d([0.2, 0.4, 0.25, 0.15]); - const dx = tf.grad(x => tf.prelu(x.clone(), a).clone())(x); - - expect(dx.shape).toEqual(x.shape); - expect(dx.dtype).toEqual('float32'); - expectArraysClose(await dx.data(), [1, 1, 0.25, 0.15]); - }); - - it('derivative where alpha got broadcasted', async () => { - const x = tf.tensor2d([[0.5, 3, -0.1, -4]]); - const a = tf.tensor2d([[0.2]]); - const dy = tf.tensor2d([[1, 1, 1, 1]]); - - const da = tf.grad(a => tf.prelu(x, a))(a, dy); - expect(da.shape).toEqual(a.shape); - expectArraysClose(await da.data(), [-4.1]); - }); - - it('throws when passed x as a non-tensor', () => { - expect(() => tf.prelu({} as tf.Tensor, tf.scalar(1))) - .toThrowError(/Argument 'x' passed to 'prelu' must be a Tensor/); - }); - it('throws when passed alpha as a non-tensor', () => { - expect(() => tf.prelu(tf.scalar(1), {} as tf.Tensor)) - .toThrowError(/Argument 'alpha' passed to 'prelu' must be a Tensor/); - }); - - it('throws for string tensor', () => { - expect(() => tf.prelu(['a'], 0.1)) - .toThrowError(/Argument 'x' passed to 'prelu' must be numeric tensor/); - }); -}); - -describeWithFlags('maximum', ALL_ENVS, () => { - it('float32 and float32', async () => { - const a = tf.tensor1d([0.5, 3, -0.1, -4]); - const b = tf.tensor1d([0.2, 0.4, 0.25, 0.15]); - const result = tf.maximum(a, b); - - expect(result.shape).toEqual(a.shape); - expectArraysClose(await result.data(), [0.5, 3, 0.25, 0.15]); - }); - - it('TensorLike', async () => { - const a = [0.5, 3, -0.1, -4]; - const b = [0.2, 0.4, 0.25, 0.15]; - const result = tf.maximum(a, b); - - expect(result.shape).toEqual([4]); - expectArraysClose(await result.data(), [0.5, 3, 0.25, 0.15]); - }); - - it('TensorLike chained', async () => { - const a = tf.tensor1d([0.5, 3, -0.1, -4]); - const b = [0.2, 0.4, 0.25, 0.15]; - const result = a.maximum(b); - - expect(result.shape).toEqual([4]); - expectArraysClose(await result.data(), [0.5, 3, 0.25, 0.15]); - }); - - it('int32 and int32', async () => { - const a = tf.tensor1d([1, 5, 2, 3], 'int32'); - const b = tf.tensor1d([2, 3, 1, 4], 'int32'); - const result = tf.maximum(a, b); - - expect(result.shape).toEqual(a.shape); - expect(result.dtype).toBe('int32'); - expectArraysEqual(await result.data(), [2, 5, 2, 4]); - }); - - it('bool and bool', async () => { - const a = tf.tensor1d([true, false, false, true], 'bool'); - const b = tf.tensor1d([false, false, true, true], 'bool'); - const result = tf.maximum(a, b); - - expect(result.shape).toEqual(a.shape); - expect(result.dtype).toBe('int32'); - expectArraysEqual(await result.data(), [1, 0, 1, 1]); - }); - - it('upcasts when dtypes dont match', async () => { - const a = tf.tensor1d([1, 0, 0, 1], 'float32'); - const b = tf.tensor1d([0, 0, 1, 1], 'int32'); - const res = tf.maximum(a, b); - expect(res.shape).toEqual(a.shape); - expect(res.dtype).toBe('float32'); - expectArraysEqual(await res.data(), [1, 0, 1, 1]); - }); - - it('propagates NaN', async () => { - const a = tf.tensor1d([0.5, -0.1, NaN]); - const b = tf.tensor1d([0.2, 0.3, 0.25]); - const result = tf.maximum(a, b); - - expect(result.shape).toEqual(a.shape); - expectArraysClose(await result.data(), [0.5, 0.3, NaN]); - }); - - it('broadcasts Tensor1D and scalar', async () => { - const a = tf.tensor1d([0.5, 3, -0.1, -4]); - const b = tf.scalar(0.6); - const result = tf.maximum(a, b); - - expect(result.shape).toEqual(a.shape); - expectArraysClose(await result.data(), [0.6, 3, 0.6, 0.6]); - }); - - it('broadcasts scalar and Tensor1D', async () => { - const a = tf.scalar(0.6); - const b = tf.tensor1d([0.5, 3, -0.1, -4]); - const result = tf.maximum(a, b); - - expect(result.shape).toEqual(b.shape); - expectArraysClose(await result.data(), [0.6, 3, 0.6, 0.6]); - }); - - it('broadcasts Tensor1D and Tensor2D', async () => { - const a = tf.tensor1d([0.5, 0.3]); - const b = tf.tensor2d([0.2, 0.4, 0.6, 0.15], [2, 2]); - const result = tf.maximum(a, b); - - expect(result.shape).toEqual(b.shape); - expectArraysClose(await result.data(), [0.5, 0.4, 0.6, 0.3]); - }); - - it('broadcasts 2x1 Tensor2D and 2x2 Tensor2D', async () => { - const a = tf.tensor2d([0.5, 0.3], [2, 1]); - const b = tf.tensor2d([0.2, 0.4, 0.6, 0.15], [2, 2]); - const result = tf.maximum(a, b); - - expect(result.shape).toEqual(b.shape); - expectArraysClose(await result.data(), [0.5, 0.5, 0.6, 0.3]); - }); - - it('gradients: Scalar', async () => { - const a = tf.scalar(5.2); - const b = tf.scalar(0.6); - const dy = tf.scalar(3); - - const grads = tf.grads((a, b) => tf.maximum(a, b)); - const [da, db] = grads([a, b], dy); - - expect(da.shape).toEqual(a.shape); - expect(db.shape).toEqual(b.shape); - expect(da.dtype).toEqual('float32'); - expect(db.dtype).toEqual('float32'); - - expectArraysClose(await da.data(), [3 * 1]); - expectArraysClose(await db.data(), [3 * 0]); - }); - - it('gradient with clones', async () => { - const a = tf.scalar(5.2); - const b = tf.scalar(0.6); - const dy = tf.scalar(3); - - const grads = tf.grads((a, b) => tf.maximum(a.clone(), b.clone()).clone()); - const [da, db] = grads([a, b], dy); - - expect(da.shape).toEqual(a.shape); - expect(db.shape).toEqual(b.shape); - expect(da.dtype).toEqual('float32'); - expect(db.dtype).toEqual('float32'); - - expectArraysClose(await da.data(), [3 * 1]); - expectArraysClose(await db.data(), [3 * 0]); - }); - - it('gradients: Tensor1D', async () => { - const a = tf.tensor1d([1.1, 2.6, 3, 5.9]); - const b = tf.tensor1d([1.0, 2.7, 3, 5.8]); - const dy = tf.tensor1d([1, 2, 3, 4]); - - const grads = tf.grads((a, b) => tf.maximum(a, b)); - const [da, db] = grads([a, b], dy); - - expect(da.shape).toEqual(a.shape); - expect(db.shape).toEqual(b.shape); - expect(da.dtype).toEqual('float32'); - expect(db.dtype).toEqual('float32'); - - expectArraysClose(await da.data(), [1 * 1, 2 * 0, 3 * 1, 4 * 1]); - expectArraysClose(await db.data(), [1 * 0, 2 * 1, 3 * 0, 4 * 0]); - }); - - it('gradients: Tensor2D', async () => { - const a = tf.tensor2d([0.5, 0.3, 0.7, 0.9], [2, 2]); - const b = tf.tensor2d([0.2, 0.4, 0.7, 0.15], [2, 2]); - const dy = tf.tensor2d([1, 2, 3, 4], [2, 2]); - - const grads = tf.grads((a, b) => tf.maximum(a, b)); - const [da, db] = grads([a, b], dy); - - expect(da.shape).toEqual(a.shape); - expect(db.shape).toEqual(b.shape); - expect(da.dtype).toEqual('float32'); - expect(db.dtype).toEqual('float32'); - - expectArraysClose(await da.data(), [1 * 1, 2 * 0, 3 * 1, 4 * 1]); - expectArraysClose(await db.data(), [1 * 0, 2 * 1, 3 * 0, 4 * 0]); - }); - - it('throws when passed a as a non-tensor', () => { - expect(() => tf.maximum({} as tf.Tensor, tf.scalar(1))) - .toThrowError(/Argument 'a' passed to 'maximum' must be a Tensor/); - }); - it('throws when passed b as a non-tensor', () => { - expect(() => tf.maximum(tf.scalar(1), {} as tf.Tensor)) - .toThrowError(/Argument 'b' passed to 'maximum' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const a = [[0.5, 3], [-0.1, -4]]; - const b = [[0.2, 0.4], [0.25, 0.15]]; - const result = tf.maximum(a, b); - - expect(result.shape).toEqual([2, 2]); - expectArraysClose(await result.data(), [0.5, 3, 0.25, 0.15]); - }); - - it('throws for string tensor', () => { - expect(() => tf.maximum('q', 3)) - .toThrowError( - /Argument 'a' passed to 'maximum' must be numeric tensor/); - - expect(() => tf.maximum(3, 'q')) - .toThrowError( - /Argument 'b' passed to 'maximum' must be numeric tensor/); - }); -}); - -describeWithFlags('squaredDifference', ALL_ENVS, () => { - it('float32 and float32', async () => { - const a = tf.tensor1d([0.5, 3, -0.1, -4]); - const b = tf.tensor1d([0.2, 0.4, 0.25, 0.15]); - const result = tf.squaredDifference(a, b); - - expect(result.shape).toEqual(a.shape); - expectArraysClose(await result.data(), [ - Math.pow(0.5 - 0.2, 2), Math.pow(3 - 0.4, 2), Math.pow(-0.1 - 0.25, 2), - Math.pow(-4 - 0.15, 2) - ]); - }); - - it('TensorLike', async () => { - const a = [0.5, 3, -0.1, -4]; - const b = [0.2, 0.4, 0.25, 0.15]; - const result = tf.squaredDifference(a, b); - - expect(result.shape).toEqual([4]); - expectArraysClose(await result.data(), [ - Math.pow(0.5 - 0.2, 2), Math.pow(3 - 0.4, 2), Math.pow(-0.1 - 0.25, 2), - Math.pow(-4 - 0.15, 2) - ]); - }); - - it('TensorLike chained', async () => { - const a = tf.tensor1d([0.5, 3, -0.1, -4]); - const b = [0.2, 0.4, 0.25, 0.15]; - const result = a.squaredDifference(b); - - expect(result.shape).toEqual(a.shape); - expectArraysClose(await result.data(), [ - Math.pow(0.5 - 0.2, 2), Math.pow(3 - 0.4, 2), Math.pow(-0.1 - 0.25, 2), - Math.pow(-4 - 0.15, 2) - ]); - }); - - it('int32 and int32', async () => { - const a = tf.tensor1d([1, 5, 2, 3], 'int32'); - const b = tf.tensor1d([2, 3, 1, 4], 'int32'); - const result = tf.squaredDifference(a, b); - - expect(result.shape).toEqual(a.shape); - expect(result.dtype).toBe('int32'); - expectArraysEqual(await result.data(), [ - Math.pow(1 - 2, 2), Math.pow(5 - 3, 2), Math.pow(2 - 1, 2), - Math.pow(3 - 4, 2) - ]); - }); - - it('upcasts when dtypes dont match', async () => { - let res = - tf.squaredDifference(tf.scalar(5, 'int32'), tf.scalar(2, 'float32')); - expect(res.dtype).toBe('float32'); - expectArraysClose(await res.data(), [9]); - - res = tf.squaredDifference(tf.scalar(5, 'int32'), tf.scalar(true, 'bool')); - expect(res.dtype).toBe('int32'); - expectArraysClose(await res.data(), [16]); - - res = tf.squaredDifference(tf.scalar(5, 'int32'), tf.scalar(false, 'bool')); - expect(res.dtype).toBe('int32'); - expectArraysClose(await res.data(), [25]); - }); - - it('propagates NaN', async () => { - const a = tf.tensor1d([0.5, -0.1, NaN]); - const b = tf.tensor1d([0.2, 0.3, 0.25]); - const result = tf.squaredDifference(a, b); - - expect(result.shape).toEqual(a.shape); - expectArraysClose( - await result.data(), - [Math.pow(0.5 - 0.2, 2), Math.pow(-0.1 - 0.3, 2), NaN]); - }); - - it('broadcasts Tensor1D and scalar', async () => { - const a = tf.tensor1d([0.5, 3, -0.1, -4]); - const b = tf.scalar(0.6); - const result = tf.squaredDifference(a, b); - - expect(result.shape).toEqual(a.shape); - expectArraysClose(await result.data(), [ - Math.pow(0.5 - 0.6, 2), Math.pow(3 - 0.6, 2), Math.pow(-0.1 - 0.6, 2), - Math.pow(-4 - 0.6, 2) - ]); - }); - - it('broadcasts scalar and Tensor1D', async () => { - const a = tf.scalar(0.6); - const b = tf.tensor1d([0.5, 3, -0.1, -4]); - const result = tf.squaredDifference(a, b); - - expect(result.shape).toEqual(b.shape); - expectArraysClose(await result.data(), [ - Math.pow(0.6 - 0.5, 2), Math.pow(0.6 - 3, 2), Math.pow(0.6 - (-0.1), 2), - Math.pow(0.6 - (-4), 2) - ]); - }); - - it('broadcasts Tensor1D and Tensor2D', async () => { - const a = tf.tensor1d([0.5, 0.3]); - const b = tf.tensor2d([0.2, 0.4, 0.6, 0.15], [2, 2]); - const result = tf.squaredDifference(a, b); - - expect(result.shape).toEqual(b.shape); - expectArraysClose(await result.data(), [ - Math.pow(0.5 - 0.2, 2), Math.pow(0.3 - 0.4, 2), Math.pow(0.5 - 0.6, 2), - Math.pow(0.3 - 0.15, 2) - ]); - }); - - it('broadcasts 2x1 Tensor2D and 2x2 Tensor2D', async () => { - const a = tf.tensor2d([0.5, 0.3], [2, 1]); - const b = tf.tensor2d([0.2, 0.4, 0.6, 0.15], [2, 2]); - const result = tf.squaredDifference(a, b); - - expect(result.shape).toEqual(b.shape); - expectArraysClose(await result.data(), [ - Math.pow(0.5 - 0.2, 2), Math.pow(0.5 - 0.4, 2), Math.pow(0.3 - 0.6, 2), - Math.pow(0.3 - 0.15, 2) - ]); - }); - - it('gradients: Scalar', async () => { - const a = tf.scalar(5.2); - const b = tf.scalar(0.6); - const dy = tf.scalar(3); - - const grads = tf.grads((a, b) => tf.squaredDifference(a, b)); - const [da, db] = grads([a, b], dy); - - expect(da.shape).toEqual(a.shape); - expect(db.shape).toEqual(b.shape); - expect(da.dtype).toEqual('float32'); - expect(db.dtype).toEqual('float32'); - - expectArraysClose(await da.data(), [3 * 2 * (5.2 - 0.6)]); - expectArraysClose(await db.data(), [3 * 2 * (0.6 - 5.2)]); - }); - - it('gradient with clones', async () => { - const a = tf.scalar(5.2); - const b = tf.scalar(0.6); - const dy = tf.scalar(3); - - const grads = - tf.grads((a, b) => tf.squaredDifference(a.clone(), b.clone()).clone()); - const [da, db] = grads([a, b], dy); - - expect(da.shape).toEqual(a.shape); - expect(db.shape).toEqual(b.shape); - expect(da.dtype).toEqual('float32'); - expect(db.dtype).toEqual('float32'); - - expectArraysClose(await da.data(), [3 * 2 * (5.2 - 0.6)]); - expectArraysClose(await db.data(), [3 * 2 * (0.6 - 5.2)]); - }); - - it('gradients: Tensor1D', async () => { - const a = tf.tensor1d([1.1, 2.6, 3, 5.9]); - const b = tf.tensor1d([1.0, 2.7, 3, 5.8]); - const dy = tf.tensor1d([1, 2, 3, 1]); - - const grads = tf.grads((a, b) => tf.squaredDifference(a, b)); - const [da, db] = grads([a, b], dy); - - expect(da.shape).toEqual(a.shape); - expect(db.shape).toEqual(b.shape); - expect(da.dtype).toEqual('float32'); - expect(db.dtype).toEqual('float32'); - - expectArraysClose(await da.data(), [ - 1 * 2 * (1.1 - 1.0), 2 * 2 * (2.6 - 2.7), 3 * 2 * (3 - 3), - 1 * 2 * (5.9 - 5.8) - ]); - expectArraysClose(await db.data(), [ - 1 * 2 * (1.0 - 1.1), 2 * 2 * (2.7 - 2.6), 3 * 2 * (3 - 3), - 1 * 2 * (5.8 - 5.9) - ]); - }); - - it('gradients: Tensor2D', async () => { - const a = tf.tensor2d([0.5, 0.3, 0.7, 0.9], [2, 2]); - const b = tf.tensor2d([0.2, 0.4, 0.7, 0.15], [2, 2]); - const dy = tf.tensor2d([1, 2, 3, 4], [2, 2]); - - const grads = tf.grads((a, b) => tf.squaredDifference(a, b)); - const [da, db] = grads([a, b], dy); - - expect(da.shape).toEqual(a.shape); - expect(db.shape).toEqual(b.shape); - expect(da.dtype).toEqual('float32'); - expect(db.dtype).toEqual('float32'); - - expectArraysClose(await da.data(), [ - 1 * 2 * (0.5 - 0.2), 2 * 2 * (0.3 - 0.4), 3 * 2 * (0.7 - 0.7), - 4 * 2 * (0.9 - 0.15) - ]); - expectArraysClose(await db.data(), [ - 1 * 2 * (0.2 - 0.5), 2 * 2 * (0.4 - 0.3), 3 * 2 * (0.7 - 0.7), - 4 * 2 * (0.15 - 0.9) - ]); - }); - - it('throws when passed a as a non-tensor', () => { - expect(() => tf.squaredDifference({} as tf.Tensor, tf.scalar(1))) - .toThrowError( - /Argument 'a' passed to 'squaredDifference' must be a Tensor/); - }); - it('throws when passed b as a non-tensor', () => { - expect(() => tf.squaredDifference(tf.scalar(1), {} as tf.Tensor)) - .toThrowError( - /Argument 'b' passed to 'squaredDifference' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const a = [[0.5, 3], [-0.1, -4]]; - const b = 0.6; - const result = tf.squaredDifference(a, b); - - expect(result.shape).toEqual([2, 2]); - expectArraysClose(await result.data(), [ - Math.pow(0.5 - 0.6, 2), Math.pow(3 - 0.6, 2), Math.pow(-0.1 - 0.6, 2), - Math.pow(-4 - 0.6, 2) - ]); - }); - - it('throws for string tensor', () => { - expect(() => tf.squaredDifference('q', 3)) - .toThrowError( - /Argument 'a' passed to 'squaredDifference' must be numeric/); - - expect(() => tf.squaredDifference(3, 'q')) - .toThrowError( - /Argument 'b' passed to 'squaredDifference' must be numeric/); - }); -}); - -describeWithFlags('minimum', ALL_ENVS, () => { - it('float32 and float32', async () => { - const a = tf.tensor1d([0.5, 3, -0.1, -4]); - const b = tf.tensor1d([0.2, 0.4, 0.25, 0.15]); - const result = tf.minimum(a, b); - - expect(result.shape).toEqual(a.shape); - expectArraysClose(await result.data(), [0.2, 0.4, -0.1, -4]); - }); - - it('TensorLike', async () => { - const a = [0.5, 3, -0.1, -4]; - const b = [0.2, 0.4, 0.25, 0.15]; - const result = tf.minimum(a, b); - - expect(result.shape).toEqual([4]); - expectArraysClose(await result.data(), [0.2, 0.4, -0.1, -4]); - }); - - it('TensorLike chained', async () => { - const a = tf.tensor1d([0.5, 3, -0.1, -4]); - const b = [0.2, 0.4, 0.25, 0.15]; - const result = a.minimum(b); - - expect(result.shape).toEqual(a.shape); - expectArraysClose(await result.data(), [0.2, 0.4, -0.1, -4]); - }); - - it('int32 and int32', async () => { - const a = tf.tensor1d([1, 5, 2, 3], 'int32'); - const b = tf.tensor1d([2, 3, 1, 4], 'int32'); - const result = tf.minimum(a, b); - - expect(result.shape).toEqual(a.shape); - expect(result.dtype).toBe('int32'); - expectArraysEqual(await result.data(), [1, 3, 1, 3]); - }); - - it('bool and bool', async () => { - const a = tf.tensor1d([true, false, false, true], 'bool'); - const b = tf.tensor1d([false, false, true, true], 'bool'); - const result = tf.minimum(a, b); - - expect(result.shape).toEqual(a.shape); - expect(result.dtype).toBe('int32'); - expectArraysEqual(await result.data(), [0, 0, 0, 1]); - }); - - it('upcasts when dtypes dont match', async () => { - const a = tf.tensor1d([1, 0, 0, 1], 'float32'); - const b = tf.tensor1d([0, 0, 1, 1], 'int32'); - const res = tf.minimum(a, b); - expect(res.shape).toEqual(a.shape); - expect(res.dtype).toBe('float32'); - expectArraysEqual(await res.data(), [0, 0, 0, 1]); - }); - - it('propagates NaN', async () => { - const a = tf.tensor1d([0.5, -0.1, NaN]); - const b = tf.tensor1d([0.2, 0.3, 0.25]); - const result = tf.minimum(a, b); - - expect(result.shape).toEqual(a.shape); - expectArraysClose(await result.data(), [0.2, -0.1, NaN]); - }); - - it('broadcasts Tensor1D and scalar', async () => { - const a = tf.tensor1d([0.5, 3, -0.1, -4]); - const b = tf.scalar(0.6); - const result = tf.minimum(a, b); - - expect(result.shape).toEqual(a.shape); - expectArraysClose(await result.data(), [0.5, 0.6, -0.1, -4]); - }); - - it('broadcasts scalar and Tensor1D', async () => { - const a = tf.scalar(0.6); - const b = tf.tensor1d([0.5, 3, -0.1, -4]); - const result = tf.minimum(a, b); - - expect(result.shape).toEqual(b.shape); - expectArraysClose(await result.data(), [0.5, 0.6, -0.1, -4]); - }); - - it('broadcasts Tensor1D and Tensor2D', async () => { - const a = tf.tensor1d([0.5, 0.3]); - const b = tf.tensor2d([0.2, 0.4, 0.6, 0.15], [2, 2]); - const result = tf.minimum(a, b); - - expect(result.shape).toEqual(b.shape); - expectArraysClose(await result.data(), [0.2, 0.3, 0.5, 0.15]); - }); - - it('broadcasts 2x1 Tensor2D and 2x2 Tensor2D', async () => { - const a = tf.tensor2d([0.5, 0.3], [2, 1]); - const b = tf.tensor2d([0.2, 0.4, 0.6, 0.15], [2, 2]); - const result = tf.minimum(a, b); - - expect(result.shape).toEqual(b.shape); - expectArraysClose(await result.data(), [0.2, 0.4, 0.3, 0.15]); - }); - - it('gradients: Scalar', async () => { - const a = tf.scalar(5.2); - const b = tf.scalar(0.6); - const dy = tf.scalar(3); - - const grads = tf.grads((a, b) => tf.minimum(a, b)); - const [da, db] = grads([a, b], dy); - - expect(da.shape).toEqual(a.shape); - expect(db.shape).toEqual(b.shape); - expect(da.dtype).toEqual('float32'); - expect(db.dtype).toEqual('float32'); - - expectArraysClose(await da.data(), [3 * 0]); - expectArraysClose(await db.data(), [3 * 1]); - }); - - it('gradient with clones', async () => { - const a = tf.scalar(5.2); - const b = tf.scalar(0.6); - const dy = tf.scalar(3); - - const grads = tf.grads((a, b) => tf.minimum(a.clone(), b.clone()).clone()); - const [da, db] = grads([a, b], dy); - - expect(da.shape).toEqual(a.shape); - expect(db.shape).toEqual(b.shape); - expect(da.dtype).toEqual('float32'); - expect(db.dtype).toEqual('float32'); - - expectArraysClose(await da.data(), [3 * 0]); - expectArraysClose(await db.data(), [3 * 1]); - }); - - it('gradients: Tensor1D', async () => { - const a = tf.tensor1d([1.1, 2.6, 3, 5.9]); - const b = tf.tensor1d([1.0, 2.7, 3, 5.8]); - const dy = tf.tensor1d([1, 2, 3, 4]); - - const grads = tf.grads((a, b) => tf.minimum(a, b)); - const [da, db] = grads([a, b], dy); - - expect(da.shape).toEqual(a.shape); - expect(db.shape).toEqual(b.shape); - expect(da.dtype).toEqual('float32'); - expect(db.dtype).toEqual('float32'); - - expectArraysClose(await da.data(), [1 * 0, 2 * 1, 3 * 1, 4 * 0]); - expectArraysClose(await db.data(), [1 * 1, 2 * 0, 3 * 0, 4 * 1]); - }); - - it('gradients: Tensor2D', async () => { - const a = tf.tensor2d([0.5, 0.3, 0.7, 0.9], [2, 2]); - const b = tf.tensor2d([0.2, 0.4, 0.7, 0.15], [2, 2]); - const dy = tf.tensor2d([1, 2, 3, 4], [2, 2]); - - const grads = tf.grads((a, b) => tf.minimum(a, b)); - const [da, db] = grads([a, b], dy); - - expect(da.shape).toEqual(a.shape); - expect(db.shape).toEqual(b.shape); - expect(da.dtype).toEqual('float32'); - expect(db.dtype).toEqual('float32'); - - expectArraysClose(await da.data(), [1 * 0, 2 * 1, 3 * 1, 4 * 0]); - expectArraysClose(await db.data(), [1 * 1, 2 * 0, 3 * 0, 4 * 1]); - }); - - it('throws when passed a as a non-tensor', () => { - expect(() => tf.minimum({} as tf.Tensor, tf.scalar(1))) - .toThrowError(/Argument 'a' passed to 'minimum' must be a Tensor/); - }); - it('throws when passed b as a non-tensor', () => { - expect(() => tf.minimum(tf.scalar(1), {} as tf.Tensor)) - .toThrowError(/Argument 'b' passed to 'minimum' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const a = [[0.5, 3], [-0.1, -4]]; - const b = [[0.2, 0.4], [0.25, 0.15]]; - const result = tf.minimum(a, b); - - expect(result.shape).toEqual([2, 2]); - expectArraysClose(await result.data(), [0.2, 0.4, -0.1, -4]); - }); - - it('throws for string tensor', () => { - expect(() => tf.minimum('q', 3)) - .toThrowError(/Argument 'a' passed to 'minimum' must be numeric/); - - expect(() => tf.minimum(3, 'q')) - .toThrowError(/Argument 'b' passed to 'minimum' must be numeric/); - }); -}); - -describeWithFlags('mod', ALL_ENVS, () => { - it('float32 and float32', async () => { - const a = tf.tensor1d([0.5, 3, -0.1, -4]); - const b = tf.tensor1d([0.2, 0.4, 0.25, 0.15]); - const result = tf.mod(a, b); - - expect(result.shape).toEqual(a.shape); - expectArraysClose(await result.data(), [0.1, 0.2, 0.15, 0.05]); - }); - - it('TensorLike', async () => { - const a = [0.5, 3, -0.1, -4]; - const b = [0.2, 0.4, 0.25, 0.15]; - const result = tf.mod(a, b); - - expect(result.shape).toEqual([4]); - expectArraysClose(await result.data(), [0.1, 0.2, 0.15, 0.05]); - }); - - it('TensorLike chained', async () => { - const a = tf.tensor1d([0.5, 3, -0.1, -4]); - const b = [0.2, 0.4, 0.25, 0.15]; - const result = a.mod(b); - - expect(result.shape).toEqual(a.shape); - expectArraysClose(await result.data(), [0.1, 0.2, 0.15, 0.05]); - }); - - it('int32 and int32', async () => { - const a = tf.tensor1d([1, 5, 2, 3], 'int32'); - const b = tf.tensor1d([2, 3, 1, 4], 'int32'); - const result = tf.mod(a, b); - - expect(result.shape).toEqual(a.shape); - expect(result.dtype).toBe('int32'); - expectArraysEqual(await result.data(), [1, 2, 0, 3]); - }); - - it('upcasts when dtypes dont match', async () => { - let res = tf.mod(tf.scalar(5, 'int32'), tf.scalar(2, 'float32')); - expect(res.dtype).toBe('float32'); - expectArraysClose(await res.data(), [1]); - - res = tf.mod(tf.scalar(5, 'int32'), tf.scalar(true, 'bool')); - expect(res.dtype).toBe('int32'); - expectArraysClose(await res.data(), [0]); - }); - - it('propagates NaN', async () => { - const a = tf.tensor1d([5, -1, NaN]); - const b = tf.tensor1d([2, 3, 0.25]); - const result = tf.mod(a, b); - - expect(result.shape).toEqual(a.shape); - expectArraysClose(await result.data(), [1, 2, NaN]); - }); - - it('broadcasts Tensor1D and scalar', async () => { - const a = tf.tensor1d([0.5, 2.5, -0.1, -4], 'float32'); - const b = tf.scalar(0.6); - const result = tf.mod(a, b); - - expect(result.shape).toEqual(a.shape); - expectArraysClose(await result.data(), [0.5, 0.1, 0.5, 0.2]); - }); - - it('broadcasts scalar and Tensor1D', async () => { - // TODO(manraj): Fix for case fmod(0.6, -0.1) - const a = tf.scalar(2); - const b = tf.tensor1d([3, 3, -1, -4]); - const result = tf.mod(a, b); - - expect(result.shape).toEqual(b.shape); - expectArraysClose(await result.data(), [2, 2, 0, -2]); - }); - - it('broadcasts Tensor1D and Tensor2D', async () => { - const a = tf.tensor1d([0.5, 0.3]); - const b = tf.tensor2d([0.2, 0.4, 0.6, 0.15], [2, 2]); - const result = tf.mod(a, b); - - expect(result.shape).toEqual(b.shape); - expectArraysClose(await result.data(), [0.1, 0.3, 0.5, 0.0]); - }); - - it('broadcasts 2x1 Tensor2D and 2x2 Tensor2D', async () => { - const a = tf.tensor2d([0.5, 0.3], [2, 1]); - const b = tf.tensor2d([0.2, 0.4, 0.6, 0.15], [2, 2]); - const result = tf.mod(a, b); - - expect(result.shape).toEqual(b.shape); - expectArraysClose(await result.data(), [0.1, 0.1, 0.3, 0.0]); - }); - - it('gradients: Scalar', async () => { - const a = tf.scalar(5.2); - const b = tf.scalar(0.6); - const dy = tf.scalar(3); - - const grads = tf.grads((a, b) => tf.mod(a, b)); - const [da, db] = grads([a, b], dy); - - expect(da.shape).toEqual(a.shape); - expect(db.shape).toEqual(b.shape); - expect(da.dtype).toEqual('float32'); - expect(db.dtype).toEqual('float32'); - - expectArraysClose(await da.data(), [3]); - expectArraysClose(await db.data(), [3 * -1 * Math.floor(5.2 / 0.6)]); - }); - - it('gradient with clones', async () => { - const a = tf.scalar(5.2); - const b = tf.scalar(0.6); - const dy = tf.scalar(3); - - const grads = tf.grads((a, b) => tf.mod(a.clone(), b.clone()).clone()); - const [da, db] = grads([a, b], dy); - - expect(da.shape).toEqual(a.shape); - expect(db.shape).toEqual(b.shape); - expect(da.dtype).toEqual('float32'); - expect(db.dtype).toEqual('float32'); - - expectArraysClose(await da.data(), [3]); - expectArraysClose(await db.data(), [3 * -1 * Math.floor(5.2 / 0.6)]); - }); - - it('gradients: Tensor1D', async () => { - const a = tf.tensor1d([1.1, 2.6, 3, 5.9]); - const b = tf.tensor1d([1.0, 2.7, 3, 5.8]); - const dy = tf.tensor1d([1, 2, 3, 4]); - - const grads = tf.grads((a, b) => tf.mod(a, b)); - const [da, db] = grads([a, b], dy); - - expect(da.shape).toEqual(a.shape); - expect(db.shape).toEqual(b.shape); - expect(da.dtype).toEqual('float32'); - expect(db.dtype).toEqual('float32'); - - expectArraysClose(await da.data(), [1 * 1, 2 * 1, 3 * 1, 4 * 1]); - expectArraysClose(await db.data(), [ - 1 * -1 * Math.floor(1.1 / 1.0), 2 * -1 * Math.floor(2.6 / 2.7), - 3 * -1 * Math.floor(3 / 3), 4 * -1 * Math.floor(5.9 / 5.8) - ]); - }); - - it('gradients: Tensor2D', async () => { - const a = tf.tensor2d([0.5, 0.3, 0.7, 0.91], [2, 2]); - const b = tf.tensor2d([0.2, 0.4, 0.7, 0.15], [2, 2]); - const dy = tf.tensor2d([1, 2, 3, 4], [2, 2]); - - const grads = tf.grads((a, b) => tf.mod(a, b)); - const [da, db] = grads([a, b], dy); - - expect(da.shape).toEqual(a.shape); - expect(db.shape).toEqual(b.shape); - expect(da.dtype).toEqual('float32'); - expect(db.dtype).toEqual('float32'); - - expectArraysClose(await da.data(), [1 * 1, 2 * 1, 3 * 1, 4 * 1]); - expectArraysClose(await db.data(), [ - 1 * -1 * Math.floor(0.5 / 0.2), 2 * -1 * Math.floor(0.3 / 0.4), - 3 * -1 * Math.floor(0.7 / 0.7), 4 * -1 * Math.floor(0.91 / 0.15) - ]); - }); - - it('gradients: broadcasts scalar and Tensor1D', async () => { - const a = tf.scalar(0.7); - const b = tf.tensor1d([0.2, 0.3, 0.4, 0.5]); - const dy = tf.tensor1d([1, 2, 3, 4]); - - const grads = tf.grads((a, b) => tf.mod(a, b)); - const [da, db] = grads([a, b], dy); - - expect(da.shape).toEqual(a.shape); - expect(db.shape).toEqual(b.shape); - expect(da.dtype).toEqual('float32'); - expect(db.dtype).toEqual('float32'); - - expectArraysClose(await da.data(), [1 + 2 + 3 + 4]); - expectArraysClose(await db.data(), [ - 1 * -1 * Math.floor(0.7 / 0.2), 2 * -1 * Math.floor(0.7 / 0.3), - 3 * -1 * Math.floor(0.7 / 0.4), 4 * -1 * Math.floor(0.7 / 0.5) - ]); - }); - - it('broadcasts Tensor1D and Tensor2D', async () => { - const a = tf.tensor1d([0.5, 0.3]); - const b = tf.tensor2d([0.2, 0.4, 0.7, 0.15], [2, 2]); - const dy = tf.tensor2d([1, 2, 3, 4], [2, 2]); - - const grads = tf.grads((a, b) => tf.mod(a, b)); - const [da, db] = grads([a, b], dy); - - expect(da.shape).toEqual(a.shape); - expect(db.shape).toEqual(b.shape); - expect(da.dtype).toEqual('float32'); - expect(db.dtype).toEqual('float32'); - - expectArraysClose(await da.data(), [1 * 1 + 3 * 1, 2 * 1 + 4 * 1]); - expectArraysClose(await db.data(), [ - 1 * -1 * Math.floor(0.5 / 0.2), 2 * -1 * Math.floor(0.3 / 0.4), - 3 * -1 * Math.floor(0.5 / 0.7), 4 * -1 * Math.floor(0.3 / 0.15) - ]); - }); - - it('throws when passed a as a non-tensor', () => { - expect(() => tf.mod({} as tf.Tensor, tf.scalar(1))) - .toThrowError(/Argument 'a' passed to 'mod' must be a Tensor/); - }); - it('throws when passed b as a non-tensor', () => { - expect(() => tf.mod(tf.scalar(1), {} as tf.Tensor)) - .toThrowError(/Argument 'b' passed to 'mod' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const a = [[0.5, 3], [-0.1, -4]]; - const b = [[0.2, 0.4], [0.25, 0.15]]; - const result = tf.mod(a, b); - - expect(result.shape).toEqual([2, 2]); - expectArraysClose(await result.data(), [0.1, 0.2, 0.15, 0.05]); - }); - - it('throws for string tensor', () => { - expect(() => tf.mod('q', 3)) - .toThrowError(/Argument 'a' passed to 'mod' must be numeric/); - - expect(() => tf.mod(3, 'q')) - .toThrowError(/Argument 'b' passed to 'mod' must be numeric/); - }); -}); - -describeWithFlags('atan2', ALL_ENVS, () => { - it('same shape', async () => { - const aValues = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]; - const bValues = [1.0, 2.5, 3.5, 4.5, 2.0, 5.0]; - - const a = tf.tensor2d(aValues, [2, 3]); - const c = tf.tensor2d(bValues, [2, 3]); - - const r = tf.atan2(a, c); - const expected = []; - - for (let i = 0; i < a.size; i++) { - expected[i] = Math.atan2(aValues[i], bValues[i]); - } - expectArraysClose(await r.data(), expected); - }); - - it('uses chaining', async () => { - const aValues = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]; - const bValues = [1.0, 2.5, 3.5, 4.5, 2.0, 5.0]; - - const a = tf.tensor2d(aValues, [2, 3]); - const b = tf.tensor2d(bValues, [2, 3]); - - const r = a.atan2(b); - const expected = []; - - for (let i = 0; i < a.size; i++) { - expected[i] = Math.atan2(aValues[i], bValues[i]); - } - expectArraysClose(await r.data(), expected); - }); - - it('propagates NaNs', async () => { - const a = tf.tensor2d([1.0, 2.0], [2, 1]); - const c = tf.tensor2d([3.0, NaN], [2, 1]); - - const r = tf.atan2(a, c); - - expectArraysClose(await r.data(), [Math.atan2(1.0, 3.0), NaN]); - }); - - it('broadcasting same rank Tensors different shape', async () => { - const aValues = [1.0, 2.0, -3.0, -4.0]; - const bValues = [2.0, 3.0]; - - const a = tf.tensor2d(aValues, [2, 2]); - const b = tf.tensor2d(bValues, [2, 1]); - - const result = tf.atan2(a, b); - - expect(result.shape).toEqual([2, 2]); - const expected = [ - Math.atan2(1.0, 2.0), Math.atan2(2.0, 2.0), Math.atan2(-3.0, 3.0), - Math.atan2(-4.0, 3.0) - ]; - expectArraysClose(await result.data(), expected); - }); - - it('throws when passed tensors of different shapes', () => { - const a = tf.tensor2d([1, 2, -3, -4, 5, 6], [2, 3]); - const b = tf.tensor2d([5, 3, 4, -7], [2, 2]); - - expect(() => tf.atan2(a, b)).toThrowError(); - expect(() => tf.atan2(b, a)).toThrowError(); - }); - - it('upcasts when dtypes dont match', async () => { - const aValues = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]; - const bValues = [1, 2, 3, 4, 2, 5]; - - const a = tf.tensor2d(aValues, [2, 3], 'float32'); - const c = tf.tensor2d(bValues, [2, 3], 'int32'); - - const r = tf.atan2(a, c); - const expected = []; - - for (let i = 0; i < a.size; i++) { - expected[i] = Math.atan2(aValues[i], bValues[i]); - } - expect(r.shape).toEqual([2, 3]); - expect(r.dtype).toBe('float32'); - expectArraysClose(await r.data(), expected); - }); - - it('atan2 of scalar and array propagates NaNs', async () => { - const c = tf.scalar(NaN); - const a = tf.tensor2d([1, 2, 3], [1, 3]); - - const r = tf.atan2(c, a); - - expectArraysEqual(await r.data(), [NaN, NaN, NaN]); - }); - - it('atan2 of scalar and array', async () => { - const aValues = [1, 2, 3, 4, 5, 6]; - - const a = tf.tensor2d(aValues, [2, 3]); - const c = tf.scalar(2); - - const r = tf.atan2(a, c); - const expected = []; - - for (let i = 0; i < a.size; i++) { - expected[i] = Math.atan2(aValues[i], 2); - } - expectArraysClose(await r.data(), expected); - }); - - it('atan2 vec4 NaNs', async () => { - const aValues = [1.0, 2.0, 3.0, 4.0]; - const cValues = [3.0, NaN, 3.0, 4.0]; - const a = tf.tensor2d(aValues, [4, 1]); - const c = tf.tensor2d(cValues, [4, 1]); - - const r = tf.atan2(a, c); - const expected = []; - - for (let i = 0; i < a.size; i++) { - expected[i] = Math.atan2(aValues[i], cValues[i]); - } - expectArraysClose(await r.data(), expected); - }); - - it('atan2 vec4 all NaNs', async () => { - const aValues = [NaN, 2.0, NaN, NaN]; - const cValues = [3.0, NaN, 3.0, 4.0]; - const a = tf.tensor2d(aValues, [4, 1]); - const c = tf.tensor2d(cValues, [4, 1]); - - const r = tf.atan2(a, c); - const expected = []; - - for (let i = 0; i < a.size; i++) { - expected[i] = Math.atan2(aValues[i], cValues[i]); - } - expectArraysClose(await r.data(), expected); - }); - - it('gradient: Scalar', async () => { - const a = tf.scalar(5); - const b = tf.scalar(2); - const dy = tf.scalar(4); - - const grads = tf.grads((a, b) => tf.atan2(a, b)); - const [da, db] = grads([a, b], dy); - - expect(da.shape).toEqual(a.shape); - expect(da.dtype).toEqual('float32'); - expectArraysClose(await da.data(), [4 * 2 / 29]); - - expect(db.shape).toEqual(b.shape); - expect(db.dtype).toEqual('float32'); - expectArraysClose(await db.data(), [4 * -5 / 29]); - }); - - it('gradient with clones', async () => { - const a = tf.scalar(5); - const b = tf.scalar(2); - const dy = tf.scalar(4); - - const grads = tf.grads((a, b) => tf.atan2(a.clone(), b.clone()).clone()); - const [da, db] = grads([a, b], dy); - - expect(da.shape).toEqual(a.shape); - expect(da.dtype).toEqual('float32'); - expectArraysClose(await da.data(), [4 * 2 / 29]); - - expect(db.shape).toEqual(b.shape); - expect(db.dtype).toEqual('float32'); - expectArraysClose(await db.data(), [4 * -5 / 29]); - }); - - it('gradient: Tensor1D', async () => { - const a = tf.tensor1d([1, 2, 3]); - const b = tf.tensor1d([3, 4, 5]); - const dy = tf.tensor1d([1, 10, 20]); - - const grads = tf.grads((a, b) => tf.atan2(a, b)); - const [da, db] = grads([a, b], dy); - - expect(da.shape).toEqual(a.shape); - expect(db.dtype).toEqual('float32'); - expectArraysClose(await da.data(), [1 * 3 / 10, 10 * 4 / 20, 20 * 5 / 34]); - - expect(db.shape).toEqual(b.shape); - expect(db.dtype).toEqual('float32'); - expectArraysClose( - await db.data(), [-1 * 1 / 10, -10 * 2 / 20, -20 * 3 / 34]); - }); - - it('gradient: Tensor2D', async () => { - const a = tf.tensor2d([3, 1, 2, 3], [2, 2]); - const b = tf.tensor2d([1, 3, 4, 5], [2, 2]); - const dy = tf.tensor2d([1, 10, 15, 20], [2, 2]); - - const grads = tf.grads((a, b) => tf.atan2(a, b)); - const [da, db] = grads([a, b], dy); - - expect(da.shape).toEqual(a.shape); - expect(da.dtype).toEqual('float32'); - expectArraysClose( - await da.data(), [1 * 1 / 10, 10 * 3 / 10, 15 * 4 / 20, 20 * 5 / 34]); - - expect(db.shape).toEqual(b.shape); - expect(db.dtype).toEqual('float32'); - expectArraysClose( - await db.data(), - [-1 * 3 / 10, -10 * 1 / 10, -15 * 2 / 20, -20 * 3 / 34]); - }); - - it('gradient: scalar / Tensor1D', async () => { - const a = tf.scalar(2); - const b = tf.tensor1d([3, 4, 5]); - const dy = tf.tensor1d([6, 7, 8]); - - const grads = tf.grads((a, b) => tf.atan2(a, b)); - const [da, db] = grads([a, b], dy); - - expect(da.shape).toEqual(a.shape); - expect(da.dtype).toEqual('float32'); - expectArraysClose(await da.data(), [6 * 3 / 13 + 7 * 4 / 20 + 8 * 5 / 29]); - - expect(db.shape).toEqual(b.shape); - expect(db.dtype).toEqual('float32'); - expectArraysClose(await db.data(), [-6 * 2 / 13, -7 * 2 / 20, -8 * 2 / 29]); - }); - - it('gradient: Tensor2D / scalar', async () => { - const a = tf.tensor2d([[2, 3], [4, 5]], [2, 2]); - const b = tf.scalar(2); - const dy = tf.tensor2d([[6, 7], [8, 9]], [2, 2]); - - const grads = tf.grads((a, b) => tf.atan2(a, b)); - const [da, db] = grads([a, b], dy); - - expect(da.shape).toEqual(a.shape); - expect(da.dtype).toEqual('float32'); - expectArraysClose( - await da.data(), [6 * 2 / 8, 7 * 2 / 13, 8 * 2 / 20, 9 * 2 / 29]); - - expect(db.shape).toEqual(b.shape); - expect(db.dtype).toEqual('float32'); - expectArraysClose( - await db.data(), - [-6 * 2 / 8 + -7 * 3 / 13 + -8 * 4 / 20 + -9 * 5 / 29]); - }); - - it('gradient: Tensor2D / Tensor2D w/ broadcast', async () => { - const a = tf.tensor2d([3, 4], [2, 1]); - const b = tf.tensor2d([[2, 3], [4, 5]], [2, 2]); - const dy = tf.tensor2d([[6, 7], [8, 9]], [2, 2]); - - const grads = tf.grads((a, b) => tf.atan2(a, b)); - const [da, db] = grads([a, b], dy); - - expect(da.shape).toEqual(a.shape); - expect(da.dtype).toEqual('float32'); - expectArraysClose( - await da.data(), [6 * 2 / 13 + 7 * 3 / 18, 8 * 4 / 32 + 9 * 5 / 41]); - - expect(db.shape).toEqual(b.shape); - expect(db.dtype).toEqual('float32'); - expectArraysClose( - await db.data(), [-6 * 3 / 13, -7 * 3 / 18, -8 * 4 / 32, -9 * 4 / 41]); - }); - - it('throws when passed a as a non-tensor', () => { - expect(() => tf.atan2({} as tf.Tensor, tf.scalar(1))) - .toThrowError(/Argument 'a' passed to 'atan2' must be a Tensor/); - }); - it('throws when passed b as a non-tensor', () => { - expect(() => tf.atan2(tf.scalar(1), {} as tf.Tensor)) - .toThrowError(/Argument 'b' passed to 'atan2' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const a = [[1, 2, 3], [4, 5, 6]]; - const c = 2; - - const r = tf.atan2(a, c); - const expected = []; - - for (let i = 0; i < 6; i++) { - expected[i] = Math.atan2(i + 1, 2); - } - expectArraysClose(await r.data(), expected); - }); - - it('throws for string tensor', () => { - expect(() => tf.atan2('q', 3)) - .toThrowError(/Argument 'a' passed to 'atan2' must be numeric/); - - expect(() => tf.atan2(3, 'q')) - .toThrowError(/Argument 'b' passed to 'atan2' must be numeric/); - }); -}); - -describeWithFlags('div', ALL_ENVS, () => { - it('divNoNan divide 0', async () => { - // Broadcast div a with b. - const a = tf.tensor1d([2, 4, 6, 8]); - const b = tf.tensor1d([0, 0, 0, 0]); - - const c = a.divNoNan(b); - expect(c.shape).toEqual(a.shape); - expectArraysClose(await c.data(), [0, 0, 0, 0]); - }); - - it('divNoNan divide 0 and non-0', async () => { - // Broadcast div a with b. - const a = tf.tensor1d([2, 4, 6, 8]); - const b = tf.tensor1d([2, 2, 0, 4]); - - const c = a.divNoNan(b); - expect(c.shape).toEqual(a.shape); - expectArraysClose(await c.data(), [1, 2, 0, 2]); - }); - - it('divNoNan divide 0 broadcast', async () => { - // Broadcast div a with b. - const a = tf.tensor1d([2, 4, 6, 8]); - const b = tf.scalar(0); - - const c = a.divNoNan(b); - expect(c.shape).toEqual(a.shape); - expectArraysClose(await c.data(), [0, 0, 0, 0]); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/bincount.ts b/tfjs-master/tfjs-core/src/ops/bincount.ts deleted file mode 100644 index 0c7d952c4..000000000 --- a/tfjs-master/tfjs-core/src/ops/bincount.ts +++ /dev/null @@ -1,70 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {Bincount, BincountAttrs, BincountInputs} from '../kernel_names'; -import {NamedAttrMap} from '../kernel_registry'; -import {Tensor1D} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; -import * as util from '../util'; - -import {op} from './operation'; - -/** - * Outputs a vector with length `size` and the same dtype as `weights`. - * - * If `weights` are empty, then index `i` stores the number of times the value - * `i` is counted in `x`. If `weights` are non-empty, then index `i` stores the - * sum of the value in `weights` at each index where the corresponding value in - * `x` is `i`. - * - * Values in `x` outside of the range [0, size) are ignored. - * - * @param x The input int tensor, rank 1. - * @param weights The weights tensor, must have the same shape as x, or a - * length-0 Tensor, in which case it acts as all weights equal to 1. - * @param size Non-negative integer. - * - * @doc {heading: 'Operations', subheading: 'Reduction'} - */ -function bincount_( - x: T|TensorLike, weights: T|TensorLike, size: number): T { - const $x = convertToTensor(x, 'x', 'bincount'); - const $weights = convertToTensor(weights, 'weights', 'bincount'); - - util.assert( - $x.dtype === 'int32', - () => `Error in bincount: input ` + - `dtype must be int32, but got ${$x.dtype}`); - util.assert(size >= 0, () => `size must be non-negative, but got ${size}.`); - util.assert( - $weights.size === $x.size || $weights.size === 0, - () => `Error in bincount: weights must have the same size as input or` + - `0-length, but got input shape: ${$x.shape}, weights shape: ` + - `${$weights.shape}.`); - - const inputs: BincountInputs = {x: $x, weights: $weights}; - const attrs: BincountAttrs = {size}; - - return ENGINE.runKernel( - Bincount, inputs as unknown as NamedTensorMap, - attrs as unknown as NamedAttrMap); -} - -export const bincount = /* @__PURE__ */ op({bincount_}); diff --git a/tfjs-master/tfjs-core/src/ops/bincount_test.ts b/tfjs-master/tfjs-core/src/ops/bincount_test.ts deleted file mode 100644 index 46b091f44..000000000 --- a/tfjs-master/tfjs-core/src/ops/bincount_test.ts +++ /dev/null @@ -1,101 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('bincount', ALL_ENVS, () => { - it('with 0-length weights.', async () => { - const x = tf.tensor1d([1, 1, 1, 2], 'int32'); - const weights = tf.tensor1d([]); - const size = 3; - - const result = tf.bincount(x, weights, size); - - expect(result.shape).toEqual([3]); - expectArraysClose(await result.data(), [0, 3, 1]); - }); - - it('with number out of range.', async () => { - const x = tf.tensor1d([1, 1, 1, 2], 'int32'); - const weights = tf.tensor1d([]); - const size = 2; - - const result = tf.bincount(x, weights, size); - - expect(result.shape).toEqual([2]); - expectArraysClose(await result.data(), [0, 3]); - }); - - it('with 1d float weights.', async () => { - const x = tf.tensor1d([1, 1, 1, 2], 'int32'); - const weights = tf.tensor1d([0.5, 0.3, 0.3, 0.1]); - const size = 3; - - const result = tf.bincount(x, weights, size); - - expect(result.shape).toEqual([3]); - expectArraysClose(await result.data(), [0, 1.1, 0.1]); - }); - - it('with 1d float weights and number out of range.', async () => { - const x = tf.tensor1d([1, 1, 1, 2], 'int32'); - const weights = tf.tensor1d([0.5, 0.3, 0.3, 0.1]); - const size = 2; - - const result = tf.bincount(x, weights, size); - - expect(result.shape).toEqual([2]); - expectArraysClose(await result.data(), [0, 1.1]); - }); - - it('throws error for non int x tensor.', async () => { - const x = tf.tensor1d([1, 1, 1, 2], 'float32'); - const weights = tf.tensor1d([]); - const size = 3; - - expect(() => tf.bincount(x, weights, size)).toThrowError(); - }); - - it('throws error if size is negative.', async () => { - const x = tf.tensor1d([1, 1, 1, 2], 'int32'); - const weights = tf.tensor1d([]); - const size = -1; - - expect(() => tf.bincount(x, weights, size)).toThrowError(); - }); - - it('throws error when shape is different.', async () => { - const x = tf.tensor1d([1, 1, 1, 2], 'int32'); - const weights = tf.tensor1d([0.5, 0.3]); - const size = 2; - - expect(() => tf.bincount(x, weights, size)).toThrowError(); - }); - - it('hands output from other ops.', async () => { - const x = tf.tensor1d([1, 1, 1, 2], 'int32'); - const weights = tf.tensor1d([]); - const size = 4; - const added = tf.add(x, tf.tensor1d([1], 'int32')); - const result = tf.bincount(added, weights, size); - - expect(result.shape).toEqual([4]); - expectArraysClose(await result.data(), [0, 0, 3, 1]); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/bitwise_and.ts b/tfjs-master/tfjs-core/src/ops/bitwise_and.ts deleted file mode 100644 index a8c1e7da1..000000000 --- a/tfjs-master/tfjs-core/src/ops/bitwise_and.ts +++ /dev/null @@ -1,65 +0,0 @@ -/** - * @license - * Copyright 2023 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {BitwiseAnd, BitwiseAndInputs} from '../kernel_names'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {Rank} from '../types'; -import {arraysEqual} from '../util_base'; - -import {op} from './operation'; - -/** - * Bitwise `AND` operation for input tensors. - * - * Given two input tensors, returns a new tensor - * with the `AND` calculated values. - * - * The method supports int32 values - * - * - * ```js - * const x = tf.tensor1d([0, 5, 3, 14], 'int32'); - * const y = tf.tensor1d([5, 0, 7, 11], 'int32'); - * tf.bitwiseAnd(x, y).print(); - * ``` - * - * @param x The input tensor to be calculated. - * @param y The input tensor to be calculated. - * - * @doc {heading: 'Operations', subheading: 'Logical'} - */ -function bitwiseAnd_(x: Tensor, y: Tensor): Tensor { - const $x = convertToTensor(x, 'x', 'bitwiseAnd'); - const $y = convertToTensor(y, 'y', 'bitwiseAnd'); - - if (!arraysEqual($x.shape, $y.shape)) { - throw new Error(`BitwiseAnd: Tensors must have the same shape. x: ${ - $x.shape}, y: ${$y.shape}`); - } - if ($x.dtype !== 'int32' || $y.dtype !== 'int32') { - throw new Error( - `BitwiseAnd: Only supports 'int32' values in tensor, found type of x: ${ - $x.dtype} and type of y: ${$y.dtype}`); - } - - const inputs: BitwiseAndInputs = {a: $x, b: $y}; - return ENGINE.runKernel(BitwiseAnd, inputs as unknown as NamedTensorMap); -} -export const bitwiseAnd = /* @__PURE__ */ op({bitwiseAnd_}); diff --git a/tfjs-master/tfjs-core/src/ops/bitwise_and_test.ts b/tfjs-master/tfjs-core/src/ops/bitwise_and_test.ts deleted file mode 100644 index 0a1a21873..000000000 --- a/tfjs-master/tfjs-core/src/ops/bitwise_and_test.ts +++ /dev/null @@ -1,46 +0,0 @@ -/** - * @license - * Copyright 2023 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; -import {bitwiseAnd} from './bitwise_and'; - -describeWithFlags('bitwiseAnd', ALL_ENVS, () => { - it('a bitwiseAnd b', async () => { - const a = tf.tensor1d([0, 5, 3, 14], 'int32'); - const b = tf.tensor1d([5, 0, 7, 11], 'int32'); - - const res = bitwiseAnd(a, b); - expectArraysClose(await res.data(), [0, 0, 3, 10]); - }); - - it('different shape', () => { - const a = tf.tensor1d([0, 5, 3, 14]); - const b = tf.tensor1d([5, 0, 7]); - - expect(() => bitwiseAnd(a, b)) - .toThrowError(/BitwiseAnd: Tensors must have the same shape/); - }); - - it('wrong type', () => { - const a = tf.tensor1d([0, 1, 3, 14], 'float32'); - const b = tf.tensor1d([5, 0, 7, 12], 'float32'); - - expect(() => bitwiseAnd(a, b)) - .toThrowError(/BitwiseAnd: Only supports 'int32' values in tensor/); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/boolean_mask.ts b/tfjs-master/tfjs-core/src/ops/boolean_mask.ts deleted file mode 100644 index 7c70f788f..000000000 --- a/tfjs-master/tfjs-core/src/ops/boolean_mask.ts +++ /dev/null @@ -1,90 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Tensor} from '../tensor'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; -import * as util from '../util'; - -import {gather} from './gather'; -import {reshape} from './reshape'; -import {squeeze} from './squeeze'; -import {whereAsync} from './where_async'; - -/** - * Apply boolean mask to tensor. - * - * ```js - * const tensor = tf.tensor2d([1, 2, 3, 4, 5, 6], [3, 2]); - * const mask = tf.tensor1d([1, 0, 1], 'bool'); - * const result = await tf.booleanMaskAsync(tensor, mask); - * result.print(); - * ``` - * - * @param tensor N-D tensor. - * @param mask K-D boolean tensor, K <= N and K must be known statically. - * @param axis A 0-D int Tensor representing the axis in tensor to mask from. - * By default, axis is 0 which will mask from the first dimension. - * Otherwise K + axis <= N. - * - * @doc {heading: 'Tensors', subheading: 'Slicing and Joining'} - */ -async function booleanMaskAsync_( - tensor: Tensor|TensorLike, mask: Tensor|TensorLike, - axis?: number): Promise { - const $tensor = convertToTensor(tensor, 'tensor', 'boolMask'); - const $mask = convertToTensor(mask, 'mask', 'boolMask', 'bool'); - - const axisFrom = axis == null ? 0 : axis; - const maskDim = $mask.rank; - const tensorShape = $tensor.shape; - - util.assert(maskDim > 0, () => 'mask cannot be scalar'); - util.assertShapesMatch( - tensorShape.slice(axisFrom, axisFrom + maskDim), $mask.shape, - `mask's shape must match the first K dimensions of tensor's shape,`); - - let leadingSize = 1; - for (let i = axisFrom; i < axisFrom + maskDim; i++) { - leadingSize *= tensorShape[i]; - } - const targetTensorShape = - tensorShape.slice(0, axisFrom) - .concat([leadingSize], tensorShape.slice(axisFrom + maskDim)); - const reshapedTensor = reshape($tensor, targetTensorShape); - const reshapedMask = reshape($mask, [-1]); - const positivePositions = await whereAsync(reshapedMask); - const indices = squeeze(positivePositions, [1]); - - const res = gather(reshapedTensor, indices, axisFrom); - - // Ensure no memory leak. - if (tensor !== $tensor) { - $tensor.dispose(); - } - if (mask !== $mask) { - $mask.dispose(); - } - indices.dispose(); - reshapedTensor.dispose(); - reshapedMask.dispose(); - positivePositions.dispose(); - - return res; -} - -export const booleanMaskAsync = booleanMaskAsync_; diff --git a/tfjs-master/tfjs-core/src/ops/boolean_mask_test.ts b/tfjs-master/tfjs-core/src/ops/boolean_mask_test.ts deleted file mode 100644 index a21c05768..000000000 --- a/tfjs-master/tfjs-core/src/ops/boolean_mask_test.ts +++ /dev/null @@ -1,113 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('booleanMaskAsync', ALL_ENVS, () => { - it('1d array, 1d mask, default axis', async () => { - const array = tf.tensor1d([1, 2, 3]); - const mask = tf.tensor1d([1, 0, 1], 'bool'); - const result = await tf.booleanMaskAsync(array, mask); - expect(result.shape).toEqual([2]); - expect(result.dtype).toBe('float32'); - expectArraysClose(await result.data(), [1, 3]); - }); - - it('2d array, 1d mask, default axis', async () => { - const array = tf.tensor2d([1, 2, 3, 4, 5, 6], [3, 2]); - const mask = tf.tensor1d([1, 0, 1], 'bool'); - const result = await tf.booleanMaskAsync(array, mask); - expect(result.shape).toEqual([2, 2]); - expect(result.dtype).toBe('float32'); - expectArraysClose(await result.data(), [1, 2, 5, 6]); - }); - - it('2d array, 2d mask, default axis', async () => { - const array = tf.tensor2d([1, 2, 3, 4, 5, 6], [3, 2]); - const mask = tf.tensor2d([1, 0, 1, 0, 1, 0], [3, 2], 'bool'); - const result = await tf.booleanMaskAsync(array, mask); - expect(result.shape).toEqual([3]); - expect(result.dtype).toBe('float32'); - expectArraysClose(await result.data(), [1, 3, 5]); - }); - - it('2d array, 1d mask, axis=1', async () => { - const array = tf.tensor2d([1, 2, 3, 4, 5, 6], [3, 2]); - const mask = tf.tensor1d([0, 1], 'bool'); - const axis = 1; - const result = await tf.booleanMaskAsync(array, mask, axis); - expect(result.shape).toEqual([3, 1]); - expect(result.dtype).toBe('float32'); - expectArraysClose(await result.data(), [2, 4, 6]); - }); - - it('accepts tensor-like object as array or mask', async () => { - const array = [[1, 2], [3, 4], [5, 6]]; - const mask = [1, 0, 1]; - const result = await tf.booleanMaskAsync(array, mask); - expect(result.shape).toEqual([2, 2]); - expect(result.dtype).toBe('float32'); - expectArraysClose(await result.data(), [1, 2, 5, 6]); - }); - - it('ensure no memory leak', async () => { - const numTensorsBefore = tf.memory().numTensors; - - const array = tf.tensor1d([1, 2, 3]); - const mask = tf.tensor1d([1, 0, 1], 'bool'); - - const result = await tf.booleanMaskAsync(array, mask); - expect(result.shape).toEqual([2]); - expect(result.dtype).toBe('float32'); - expectArraysClose(await result.data(), [1, 3]); - array.dispose(); - mask.dispose(); - result.dispose(); - - const numTensorsAfter = tf.memory().numTensors; - expect(numTensorsAfter).toBe(numTensorsBefore); - }); - - it('should throw if mask is scalar', async () => { - const array = tf.tensor2d([1, 2, 3, 4, 5, 6], [3, 2]); - const mask = tf.scalar(1, 'bool'); - let errorMessage = 'No error thrown.'; - try { - await tf.booleanMaskAsync(array, mask); - } catch (error) { - errorMessage = error.message; - } - expect(errorMessage).toBe('mask cannot be scalar'); - }); - - it('should throw if array and mask shape miss match', async () => { - const array = tf.tensor2d([1, 2, 3, 4, 5, 6], [3, 2]); - const mask = tf.tensor2d([1, 0], [1, 2], 'bool'); - let errorMessage = 'No error thrown.'; - try { - await tf.booleanMaskAsync(array, mask); - } catch (error) { - errorMessage = error.message; - } - expect(errorMessage) - .toBe( - `mask's shape must match the first K ` + - `dimensions of tensor's shape, Shapes 3,2 and 1,2 must match`); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/broadcast_args.ts b/tfjs-master/tfjs-core/src/ops/broadcast_args.ts deleted file mode 100644 index dbe5cf174..000000000 --- a/tfjs-master/tfjs-core/src/ops/broadcast_args.ts +++ /dev/null @@ -1,62 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import { NamedTensorMap } from '../tensor_types'; -import { ENGINE } from '../engine'; -import { BroadcastArgs, BroadcastArgsInputs } from '../kernel_names'; -import { Tensor } from '../tensor'; -import { convertToTensor } from '../tensor_util_env'; -import { Rank, TensorLike } from '../types'; - -import { op } from './operation'; - -/** - * Return the shape of s0 op s1 with broadcast. - * - * compute r0, the broadcasted shape as a tensor. - * s0, s1 and r0 are all integer vectors. - * - * This function returns the shape of the result of an operation between - * two tensors of size s0 and s1 performed with broadcast. - * - * @param s0 A tensor representing a shape - * @param s1 A tensor representing a shape - * - * @doc {heading: 'Tensors', subheading: 'Transformations'} - */ -function broadcastArgs_( - s0: Tensor | TensorLike, s1: Tensor | TensorLike): Tensor { - const shape1Input = convertToTensor(s0, 's0', 'broadcastArgs', 'int32'); - const shape2Input = convertToTensor(s1, 's1', 'broadcastArgs', 'int32'); - - if (shape1Input.rank !== 1) { - throw new Error( - 'broadcastArgs(): first input must be a vector (rank=1). ' + - `Has rank ${shape1Input.rank}`); - } - - if (shape2Input.rank !== 1) { - throw new Error( - 'broadcastArgs(): second input must be a vector (rank=1). ' + - `Has rank ${shape2Input.rank}`); - } - - const inputs: BroadcastArgsInputs = { s0: shape1Input, s1: shape2Input }; - return ENGINE.runKernel(BroadcastArgs, inputs as unknown as NamedTensorMap); -} - -export const broadcastArgs = /* @__PURE__ */ op({ broadcastArgs_ }); diff --git a/tfjs-master/tfjs-core/src/ops/broadcast_args_test.ts b/tfjs-master/tfjs-core/src/ops/broadcast_args_test.ts deleted file mode 100644 index 11793a831..000000000 --- a/tfjs-master/tfjs-core/src/ops/broadcast_args_test.ts +++ /dev/null @@ -1,76 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysEqual} from '../test_util'; - -describeWithFlags('broadcastArgs', ALL_ENVS, () => { - it('([1,1], [1,1]) -> [1,1]', async () => { - const s1 = tf.tensor1d([1, 1], 'int32'); - const s2 = tf.tensor1d([1, 1], 'int32'); - const expected = [1, 1]; - - expectArraysEqual(expected, await tf.broadcastArgs(s1, s2).array()); - }); - - it('([1,1], [4,2]) -> [4,2]', async () => { - const s1 = tf.tensor1d([1, 1], 'int32'); - const s2 = tf.tensor1d([4, 2], 'int32'); - const expected = [4, 2]; - - expectArraysEqual(expected, await tf.broadcastArgs(s1, s2).array()); - }); - - it('([1,6], [3,1]) -> [3,6]', async () => { - const s1 = tf.tensor1d([1, 6], 'int32'); - const s2 = tf.tensor1d([3, 1], 'int32'); - const expected = [3, 6]; - - expectArraysEqual(expected, await tf.broadcastArgs(s1, s2).array()); - }); - - it('([1,6], [3,1,1,1]) -> [3,1,1,6]', async () => { - const s1 = tf.tensor1d([1, 6], 'int32'); - const s2 = tf.tensor1d([3, 1, 1, 1], 'int32'); - const expected = [3, 1, 1, 6]; - - expectArraysEqual(expected, await tf.broadcastArgs(s1, s2).array()); - }); - - it('([1,6,-1], [3,1,1,1]) -> [3,1,6,-1]', async () => { - const s1 = tf.tensor1d([1, 6, -1], 'int32'); - const s2 = tf.tensor1d([3, 1, 1, 1], 'int32'); - const expected = [3, 1, 6, -1]; - - expectArraysEqual(expected, await tf.broadcastArgs(s1, s2).array()); - }); - - it('([1,2], [1,3]) -> error', async () => { - const s1 = tf.tensor1d([1, 2], 'int32'); - const s2 = tf.tensor1d([1, 3], 'int32'); - - expect(() => tf.broadcastArgs(s1, s2).arraySync()).toThrowError(); - }); - - it('([[1,1],[1,1]], [[1,1],[1,1]]) -> error', async () => { - const s1 = tf.tensor2d([[1, 1], [1, 1]], [2, 2], 'int32'); - const s2 = tf.tensor2d([[1, 1], [1, 1]], [2, 2], 'int32'); - - expect(() => tf.broadcastArgs(s1, s2).arraySync()).toThrowError(); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/broadcast_to.ts b/tfjs-master/tfjs-core/src/ops/broadcast_to.ts deleted file mode 100644 index 9e5782b5d..000000000 --- a/tfjs-master/tfjs-core/src/ops/broadcast_to.ts +++ /dev/null @@ -1,89 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {Tile, TileAttrs, TileInputs} from '../kernel_names'; -import {NamedAttrMap} from '../kernel_registry'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {Rank, ShapeMap, TensorLike} from '../types'; -import {assertNonNegativeIntegerDimensions} from '../util_base'; - -import {clone} from './clone'; -import {op} from './operation'; -import {reshape} from './reshape'; - -/** - * Broadcast an array to a compatible shape NumPy-style. - * - * The tensor's shape is compared to the broadcast shape from end to beginning. - * Ones are prepended to the tensor's shape until it has the same length as - * the broadcast shape. If input.shape[i]==shape[i], the (i+1)-th axis is - * already broadcast-compatible. If input.shape[i]==1 and shape[i]==N, then - * the input tensor is tiled N times along that axis (using tf.tile). - * - * @param input The tensor that is to be broadcasted. - * @param shape The input is to be broadcast to this shape. - * - * @doc {heading: 'Tensors', subheading: 'Transformations'} - */ -function broadcastTo_( - x: Tensor|TensorLike, shape: ShapeMap[R]): Tensor { - let input = convertToTensor(x, 'broadcastTo', 'x'); - const xShape = input.shape; - - assertNonNegativeIntegerDimensions(shape); - - if (shape.length < input.rank) { - throw new Error(`broadcastTo(): shape.length=${shape.length} < input.rank=${ - input.rank}.`); - } - - if (shape.length > input.rank) { - const newShape = input.shape.slice(); - while (newShape.length < shape.length) { - newShape.unshift(1); - } - input = reshape(input, newShape); - } - - const inputShape = input.shape; - const reps: number[] = Array.from(shape); - for (let i = shape.length - 1; i >= 0; i--) { - if (inputShape[i] === shape[i]) { - reps[i] = 1; - } else if (input.shape[i] !== 1) { - throw new Error( - `broadcastTo(): [${xShape}] cannot be broadcast to [${shape}].`); - } - } - const axes = reps.map((n, i) => n > 1 ? i : -1).filter(i => i >= 0); - - if (axes.length === 0) { - return clone(input) as Tensor; - } - - // TODO call broadcastTo kernel directly once backends implement broadcstTo - const inputs: TileInputs = {x: input}; - const attrs: TileAttrs = {reps}; - return ENGINE.runKernel( - Tile, inputs as unknown as NamedTensorMap, - attrs as unknown as NamedAttrMap); -} - -export const broadcastTo = /* @__PURE__ */ op({broadcastTo_}); diff --git a/tfjs-master/tfjs-core/src/ops/broadcast_to_test.ts b/tfjs-master/tfjs-core/src/ops/broadcast_to_test.ts deleted file mode 100644 index 26c54c04d..000000000 --- a/tfjs-master/tfjs-core/src/ops/broadcast_to_test.ts +++ /dev/null @@ -1,81 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {Tensor} from '../tensor'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('broadcastTo', ALL_ENVS, () => { - it('[] -> [3,2]', async () => { - const a = tf.scalar(4.2); - const A = tf.tensor2d([[4.2, 4.2], [4.2, 4.2], [4.2, 4.2]]); - - expectArraysClose( - await A.array(), await tf.broadcastTo(a, A.shape).array()); - - // test gradients - const w = tf.tensor2d([[4.7, 4.5], [-6.1, -6.6], [-8.1, -3.4]]), - f = (a: Tensor) => - tf.broadcastTo(a, A.shape).mul(w).mean().asScalar(), - h = (a: Tensor) => a.mul(w).mean().asScalar(); - - const df = tf.grad(f), dh = tf.grad(h); - - expectArraysClose(await df(a).array(), await dh(a).array()); - }); - - it('[2] -> [3,2]', async () => { - const a = tf.tensor1d([1, 2]); - const A = tf.tensor2d([[1, 2], [1, 2], [1, 2]]); - expectArraysClose( - await A.array(), await tf.broadcastTo(a, A.shape).array()); - - // test gradients - const w = tf.tensor2d([[4.7, 4.5], [-6.1, -6.6], [-8.1, -3.4]]), - f = (a: Tensor) => - tf.broadcastTo(a, A.shape).mul(w).mean().asScalar(), - h = (a: Tensor) => a.mul(w).mean().asScalar(); - - const df = tf.grad(f), dh = tf.grad(h); - - expectArraysClose(await df(a).array(), await dh(a).array()); - }); - - it('[3,1] -> [3,2]', async () => { - const a = tf.tensor2d([[1], [2], [3]]); - const A = tf.tensor2d([[1, 1], [2, 2], [3, 3]]); - - expectArraysClose( - await A.array(), await tf.broadcastTo(a, A.shape).array()); - - // test gradients - const w = tf.tensor2d([[4.7, 4.5], [-6.1, -6.6], [-8.1, -3.4]]), - f = (a: Tensor) => - tf.broadcastTo(a, A.shape).mul(w).mean().asScalar(), - h = (a: Tensor) => a.mul(w).mean().asScalar(); - - const df = tf.grad(f), dh = tf.grad(h); - - expectArraysClose(await df(a).array(), await dh(a).array()); - }); - - it('should throw error when shape is not integer', () => { - const a = tf.scalar(4.2); - expect(() => tf.broadcastTo(a, [2, 2.22, 3.33])).toThrow(); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/broadcast_util.ts b/tfjs-master/tfjs-core/src/ops/broadcast_util.ts deleted file mode 100644 index 43efde440..000000000 --- a/tfjs-master/tfjs-core/src/ops/broadcast_util.ts +++ /dev/null @@ -1,87 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -/** - * Returns the dimensions in the input shape that are broadcasted to - * produce the provided output shape. - * - * The returned dimensions are 0-indexed and sorted. An example: - * inShape = [4, 1, 3] - * outShape = [5, 4, 3, 3] - * result = [1]. Dimension 1 (2nd dimension of input) gets broadcasted 1 => 3. - */ -export function getBroadcastDims( - inShape: number[], outShape: number[]): number[] { - const inRank = inShape.length; - const dims: number[] = []; - for (let i = 0; i < inRank; i++) { - const dim = inRank - 1 - i; - const a = inShape[dim] || 1; - const b = outShape[outShape.length - 1 - i] || 1; - if (b > 1 && a === 1) { - dims.unshift(dim); - } - } - return dims; -} - -/** - * Returns the axes in the output space that should be reduced to produce - * the input space. - */ -export function getReductionAxes( - inShape: number[], outShape: number[]): number[] { - const result: number[] = []; - for (let i = 0; i < outShape.length; i++) { - const inDim = inShape[inShape.length - i - 1]; - const outAxis = outShape.length - i - 1; - const outDim = outShape[outAxis]; - if (inDim == null || (inDim === 1 && outDim > 1)) { - result.unshift(outAxis); - } - } - return result; -} - -export function assertAndGetBroadcastShape( - shapeA: number[], shapeB: number[]): number[] { - const l = Math.max(shapeA.length, shapeB.length); - const result = new Array(l); - - for (let i = 0; i < l; i++) { - let a = shapeA[shapeA.length - i - 1]; - if (a == null) { - a = 1; - } - let b = shapeB[shapeB.length - i - 1]; - if (b == null) { - b = 1; - } - if (a === 1) { - result[l - i - 1] = b; - } else if (b === 1) { - result[l - i - 1] = a; - } else if (a !== b) { - const errMsg = `Operands could not be broadcast together with shapes ` + - `${shapeA} and ${shapeB}.`; - throw Error(errMsg); - } else { - result[l - i - 1] = a; - } - } - return result; -} diff --git a/tfjs-master/tfjs-core/src/ops/broadcast_util_test.ts b/tfjs-master/tfjs-core/src/ops/broadcast_util_test.ts deleted file mode 100644 index 8a4230590..000000000 --- a/tfjs-master/tfjs-core/src/ops/broadcast_util_test.ts +++ /dev/null @@ -1,174 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as broadcast_util from './broadcast_util'; - -describe('broadcast_util.getBroadcastShape', () => { - it('two scalars', () => { - const res = broadcast_util.assertAndGetBroadcastShape([], []); - expect(res).toEqual([]); - }); - - it('scalar and 1d', () => { - const res = broadcast_util.assertAndGetBroadcastShape([6], []); - expect(res).toEqual([6]); - }); - - it('scalar and 2d', () => { - const res = broadcast_util.assertAndGetBroadcastShape([2, 6], []); - expect(res).toEqual([2, 6]); - }); - - it('1d and 2d', () => { - const res = broadcast_util.assertAndGetBroadcastShape([6], [2, 6]); - expect(res).toEqual([2, 6]); - }); - - it('2d and 3d', () => { - const res = broadcast_util.assertAndGetBroadcastShape([2, 6], [7, 2, 6]); - expect(res).toEqual([7, 2, 6]); - }); - - it('3d and 3d', () => { - const res = broadcast_util.assertAndGetBroadcastShape([1, 1, 6], [7, 2, 6]); - expect(res).toEqual([7, 2, 6]); - }); - - it('incompatible inner shape', () => { - const f = () => - broadcast_util.assertAndGetBroadcastShape([7, 2, 5], [7, 2, 6]); - expect(f).toThrowError(); - }); - - it('incompatible middle shape', () => { - const f = () => - broadcast_util.assertAndGetBroadcastShape([7, 3, 6], [7, 2, 6]); - expect(f).toThrowError(); - }); - - it('compatible with broadcasting support', () => { - const res = broadcast_util.assertAndGetBroadcastShape([7, 1, 1], [7, 1, 1]); - expect(res).toEqual([7, 1, 1]); - }); - - it('3d and 3d, each gets broadcasted', () => { - const res = broadcast_util.assertAndGetBroadcastShape([4, 1, 7], [1, 3, 1]); - expect(res).toEqual([4, 3, 7]); - }); - - it('[0] and [1] = [0]', () => { - const res = broadcast_util.assertAndGetBroadcastShape([0], [1]); - expect(res).toEqual([0]); - - const res2 = broadcast_util.assertAndGetBroadcastShape([1], [0]); - expect(res2).toEqual([0]); - }); - - it('[0] and [0] = [0]', () => { - const res = broadcast_util.assertAndGetBroadcastShape([0], [0]); - expect(res).toEqual([0]); - }); - - it('[0, 1] and [1, 3] = [0, 3]', () => { - const res = broadcast_util.assertAndGetBroadcastShape([0, 1], [1, 3]); - expect(res).toEqual([0, 3]); - }); - - it('[5, 0, 3] and [5, 1, 1] = [5, 0, 3]', () => { - const res = broadcast_util.assertAndGetBroadcastShape([5, 0, 3], [5, 1, 1]); - expect(res).toEqual([5, 0, 3]); - }); - - it('[1] and [0, 0, 4] = [0, 0, 4]', () => { - const res = broadcast_util.assertAndGetBroadcastShape([1], [0, 0, 4]); - expect(res).toEqual([0, 0, 4]); - }); -}); - -describe('broadcast_util.getBroadcastDims', () => { - it('[] => []', () => { - const dims = broadcast_util.getBroadcastDims([], []); - expect(dims.length).toBe(0); - }); - - it('[] => [5, 4]', () => { - const dims = broadcast_util.getBroadcastDims([], [5, 4]); - expect(dims.length).toBe(0); - }); - - it('[1] => [5]', () => { - const dims = broadcast_util.getBroadcastDims([1], [5]); - expect(dims).toEqual([0]); - }); - - it('[5, 1] => [5, 3]', () => { - const dims = broadcast_util.getBroadcastDims([5, 1], [5, 3]); - expect(dims).toEqual([1]); - }); - - it('[1, 3] => [5, 3]', () => { - const dims = broadcast_util.getBroadcastDims([1, 3], [5, 3]); - expect(dims).toEqual([0]); - }); - - it('[1, 1] => [5, 3]', () => { - const dims = broadcast_util.getBroadcastDims([1, 1], [5, 3]); - expect(dims).toEqual([0, 1]); - }); - - it('[4, 1, 3] => [4, 5, 3]', () => { - const dims = broadcast_util.getBroadcastDims([4, 1, 3], [4, 5, 3]); - expect(dims).toEqual([1]); - }); -}); - -describe('broadcast_util.getReductionAxes', () => { - it('[] => []', () => { - const axes = broadcast_util.getReductionAxes([], []); - expect(axes).toEqual([]); - }); - - it('[] => [5, 4]', () => { - const axes = broadcast_util.getReductionAxes([], [5, 4]); - expect(axes).toEqual([0, 1]); - }); - - it('[1] => [5]', () => { - const axes = broadcast_util.getReductionAxes([1], [5]); - expect(axes).toEqual([0]); - }); - - it('[5, 1] => [5, 3]', () => { - const axes = broadcast_util.getReductionAxes([5, 1], [5, 3]); - expect(axes).toEqual([1]); - }); - - it('[1, 3] => [5, 3]', () => { - const axes = broadcast_util.getReductionAxes([1, 3], [5, 3]); - expect(axes).toEqual([0]); - }); - - it('[1, 1] => [5, 3]', () => { - const axes = broadcast_util.getReductionAxes([1, 1], [5, 3]); - expect(axes).toEqual([0, 1]); - }); - - it('[4, 1, 3] => [4, 5, 3]', () => { - const axes = broadcast_util.getReductionAxes([4, 1, 3], [4, 5, 3]); - expect(axes).toEqual([1]); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/browser.ts b/tfjs-master/tfjs-core/src/ops/browser.ts deleted file mode 100644 index 91b4b0491..000000000 --- a/tfjs-master/tfjs-core/src/ops/browser.ts +++ /dev/null @@ -1,436 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {env} from '../environment'; -import {Draw, DrawAttrs, DrawInputs, FromPixels, FromPixelsAttrs, FromPixelsInputs} from '../kernel_names'; -import {getKernel, NamedAttrMap} from '../kernel_registry'; -import {Tensor, Tensor2D, Tensor3D} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {DrawOptions, ImageOptions, PixelData, TensorLike} from '../types'; - -import {cast} from './cast'; -import {op} from './operation'; -import {tensor3d} from './tensor3d'; - -let fromPixels2DContext: CanvasRenderingContext2D; -let hasToPixelsWarned = false; - -/** - * Creates a `tf.Tensor` from an image. - * - * ```js - * const image = new ImageData(1, 1); - * image.data[0] = 100; - * image.data[1] = 150; - * image.data[2] = 200; - * image.data[3] = 255; - * - * tf.browser.fromPixels(image).print(); - * ``` - * - * @param pixels The input image to construct the tensor from. The - * supported image types are all 4-channel. You can also pass in an image - * object with following attributes: - * `{data: Uint8Array; width: number; height: number}` - * @param numChannels The number of channels of the output tensor. A - * numChannels value less than 4 allows you to ignore channels. Defaults to - * 3 (ignores alpha channel of input image). - * - * @returns A Tensor3D with the shape `[height, width, numChannels]`. - * - * Note: fromPixels can be lossy in some cases, same image may result in - * slightly different tensor values, if rendered by different rendering - * engines. This means that results from different browsers, or even same - * browser with CPU and GPU rendering engines can be different. See discussion - * in details: - * https://github.com/tensorflow/tfjs/issues/5482 - * - * @doc {heading: 'Browser', namespace: 'browser', ignoreCI: true} - */ -function fromPixels_( - pixels: PixelData|ImageData|HTMLImageElement|HTMLCanvasElement| - HTMLVideoElement|ImageBitmap, - numChannels = 3): Tensor3D { - // Sanity checks. - if (numChannels > 4) { - throw new Error( - 'Cannot construct Tensor with more than 4 channels from pixels.'); - } - if (pixels == null) { - throw new Error('pixels passed to tf.browser.fromPixels() can not be null'); - } - let isPixelData = false; - let isImageData = false; - let isVideo = false; - let isImage = false; - let isCanvasLike = false; - let isImageBitmap = false; - if ((pixels as PixelData).data instanceof Uint8Array) { - isPixelData = true; - } else if ( - typeof (ImageData) !== 'undefined' && pixels instanceof ImageData) { - isImageData = true; - } else if ( - typeof (HTMLVideoElement) !== 'undefined' && - pixels instanceof HTMLVideoElement) { - isVideo = true; - } else if ( - typeof (HTMLImageElement) !== 'undefined' && - pixels instanceof HTMLImageElement) { - isImage = true; - // tslint:disable-next-line: no-any - } else if ((pixels as any).getContext != null) { - isCanvasLike = true; - } else if ( - typeof (ImageBitmap) !== 'undefined' && pixels instanceof ImageBitmap) { - isImageBitmap = true; - } else { - throw new Error( - 'pixels passed to tf.browser.fromPixels() must be either an ' + - `HTMLVideoElement, HTMLImageElement, HTMLCanvasElement, ImageData ` + - `in browser, or OffscreenCanvas, ImageData in webworker` + - ` or {data: Uint32Array, width: number, height: number}, ` + - `but was ${(pixels as {}).constructor.name}`); - } - // If the current backend has 'FromPixels' registered, it has a more - // efficient way of handling pixel uploads, so we call that. - const kernel = getKernel(FromPixels, ENGINE.backendName); - if (kernel != null) { - const inputs: FromPixelsInputs = {pixels}; - const attrs: FromPixelsAttrs = {numChannels}; - return ENGINE.runKernel( - FromPixels, inputs as unknown as NamedTensorMap, - attrs as unknown as NamedAttrMap); - } - - const [width, height] = isVideo ? - [ - (pixels as HTMLVideoElement).videoWidth, - (pixels as HTMLVideoElement).videoHeight - ] : - [pixels.width, pixels.height]; - let vals: Uint8ClampedArray|Uint8Array; - - if (isCanvasLike) { - vals = - // tslint:disable-next-line:no-any - (pixels as any).getContext('2d').getImageData(0, 0, width, height).data; - } else if (isImageData || isPixelData) { - vals = (pixels as PixelData | ImageData).data; - } else if (isImage || isVideo || isImageBitmap) { - if (fromPixels2DContext == null) { - if (typeof document === 'undefined') { - if (typeof OffscreenCanvas !== 'undefined' && - typeof OffscreenCanvasRenderingContext2D !== 'undefined') { - // @ts-ignore - fromPixels2DContext = new OffscreenCanvas(1, 1).getContext('2d'); - } else { - throw new Error( - 'Cannot parse input in current context. ' + - 'Reason: OffscreenCanvas Context2D rendering is not supported.'); - } - } else { - fromPixels2DContext = document.createElement('canvas').getContext( - '2d', {willReadFrequently: true}); - } - } - fromPixels2DContext.canvas.width = width; - fromPixels2DContext.canvas.height = height; - fromPixels2DContext.drawImage( - pixels as HTMLVideoElement, 0, 0, width, height); - vals = fromPixels2DContext.getImageData(0, 0, width, height).data; - } - let values: Int32Array; - if (numChannels === 4) { - values = new Int32Array(vals); - } else { - const numPixels = width * height; - values = new Int32Array(numPixels * numChannels); - for (let i = 0; i < numPixels; i++) { - for (let channel = 0; channel < numChannels; ++channel) { - values[i * numChannels + channel] = vals[i * 4 + channel]; - } - } - } - const outShape: [number, number, number] = [height, width, numChannels]; - return tensor3d(values, outShape, 'int32'); -} - -// Helper functions for |fromPixelsAsync| to check whether the input can -// be wrapped into imageBitmap. -function isPixelData(pixels: PixelData|ImageData|HTMLImageElement| - HTMLCanvasElement|HTMLVideoElement| - ImageBitmap): pixels is PixelData { - return (pixels != null) && ((pixels as PixelData).data instanceof Uint8Array); -} - -function isImageBitmapFullySupported() { - return typeof window !== 'undefined' && - typeof (ImageBitmap) !== 'undefined' && - window.hasOwnProperty('createImageBitmap'); -} - -function isNonEmptyPixels(pixels: PixelData|ImageData|HTMLImageElement| - HTMLCanvasElement|HTMLVideoElement|ImageBitmap) { - return pixels != null && pixels.width !== 0 && pixels.height !== 0; -} - -function canWrapPixelsToImageBitmap(pixels: PixelData|ImageData| - HTMLImageElement|HTMLCanvasElement| - HTMLVideoElement|ImageBitmap) { - return isImageBitmapFullySupported() && !(pixels instanceof ImageBitmap) && - isNonEmptyPixels(pixels) && !isPixelData(pixels); -} - -/** - * Creates a `tf.Tensor` from an image in async way. - * - * ```js - * const image = new ImageData(1, 1); - * image.data[0] = 100; - * image.data[1] = 150; - * image.data[2] = 200; - * image.data[3] = 255; - * - * (await tf.browser.fromPixelsAsync(image)).print(); - * ``` - * This API is the async version of fromPixels. The API will first - * check |WRAP_TO_IMAGEBITMAP| flag, and try to wrap the input to - * imageBitmap if the flag is set to true. - * - * @param pixels The input image to construct the tensor from. The - * supported image types are all 4-channel. You can also pass in an image - * object with following attributes: - * `{data: Uint8Array; width: number; height: number}` - * @param numChannels The number of channels of the output tensor. A - * numChannels value less than 4 allows you to ignore channels. Defaults to - * 3 (ignores alpha channel of input image). - * - * @doc {heading: 'Browser', namespace: 'browser', ignoreCI: true} - */ -export async function fromPixelsAsync( - pixels: PixelData|ImageData|HTMLImageElement|HTMLCanvasElement| - HTMLVideoElement|ImageBitmap, - numChannels = 3) { - let inputs: PixelData|ImageData|HTMLImageElement|HTMLCanvasElement| - HTMLVideoElement|ImageBitmap = null; - - // Check whether the backend needs to wrap |pixels| to imageBitmap and - // whether |pixels| can be wrapped to imageBitmap. - if (env().getBool('WRAP_TO_IMAGEBITMAP') && - canWrapPixelsToImageBitmap(pixels)) { - // Force the imageBitmap creation to not do any premultiply alpha - // ops. - let imageBitmap; - - try { - // wrap in try-catch block, because createImageBitmap may not work - // properly in some browsers, e.g. - // https://bugzilla.mozilla.org/show_bug.cgi?id=1335594 - // tslint:disable-next-line: no-any - imageBitmap = await (createImageBitmap as any)( - pixels as ImageBitmapSource, {premultiplyAlpha: 'none'}); - } catch (e) { - imageBitmap = null; - } - - // createImageBitmap will clip the source size. - // In some cases, the input will have larger size than its content. - // E.g. new Image(10, 10) but with 1 x 1 content. Using - // createImageBitmap will clip the size from 10 x 10 to 1 x 1, which - // is not correct. We should avoid wrapping such resouce to - // imageBitmap. - if (imageBitmap != null && imageBitmap.width === pixels.width && - imageBitmap.height === pixels.height) { - inputs = imageBitmap; - } else { - inputs = pixels; - } - } else { - inputs = pixels; - } - - return fromPixels_(inputs, numChannels); -} - -function validateImgTensor(img: Tensor2D|Tensor3D) { - if (img.rank !== 2 && img.rank !== 3) { - throw new Error( - `toPixels only supports rank 2 or 3 tensors, got rank ${img.rank}.`); - } - const depth = img.rank === 2 ? 1 : img.shape[2]; - - if (depth > 4 || depth === 2) { - throw new Error( - `toPixels only supports depth of size ` + - `1, 3 or 4 but got ${depth}`); - } - - if (img.dtype !== 'float32' && img.dtype !== 'int32') { - throw new Error( - `Unsupported type for toPixels: ${img.dtype}.` + - ` Please use float32 or int32 tensors.`); - } -} - -function validateImageOptions(imageOptions: ImageOptions) { - const alpha = imageOptions ?.alpha || 1; - if (alpha > 1 || alpha < 0) { - throw new Error(`Alpha value ${alpha} is suppoed to be in range [0 - 1].`); - } -} - -/** - * Draws a `tf.Tensor` of pixel values to a byte array or optionally a - * canvas. - * - * When the dtype of the input is 'float32', we assume values in the range - * [0-1]. Otherwise, when input is 'int32', we assume values in the range - * [0-255]. - * - * Returns a promise that resolves when the canvas has been drawn to. - * - * @param img A rank-2 tensor with shape `[height, width]`, or a rank-3 tensor - * of shape `[height, width, numChannels]`. If rank-2, draws grayscale. If - * rank-3, must have depth of 1, 3 or 4. When depth of 1, draws - * grayscale. When depth of 3, we draw with the first three components of - * the depth dimension corresponding to r, g, b and alpha = 1. When depth of - * 4, all four components of the depth dimension correspond to r, g, b, a. - * @param canvas The canvas to draw to. - * - * @doc {heading: 'Browser', namespace: 'browser'} - */ -export async function toPixels( - img: Tensor2D|Tensor3D|TensorLike, - canvas?: HTMLCanvasElement): Promise { - let $img = convertToTensor(img, 'img', 'toPixels'); - if (!(img instanceof Tensor)) { - // Assume int32 if user passed a native array. - const originalImgTensor = $img; - $img = cast(originalImgTensor, 'int32'); - originalImgTensor.dispose(); - } - validateImgTensor($img); - - const [height, width] = $img.shape.slice(0, 2); - const depth = $img.rank === 2 ? 1 : $img.shape[2]; - const data = await $img.data(); - const multiplier = $img.dtype === 'float32' ? 255 : 1; - const bytes = new Uint8ClampedArray(width * height * 4); - - for (let i = 0; i < height * width; ++i) { - const rgba = [0, 0, 0, 255]; - - for (let d = 0; d < depth; d++) { - const value = data[i * depth + d]; - - if ($img.dtype === 'float32') { - if (value < 0 || value > 1) { - throw new Error( - `Tensor values for a float32 Tensor must be in the ` + - `range [0 - 1] but encountered ${value}.`); - } - } else if ($img.dtype === 'int32') { - if (value < 0 || value > 255) { - throw new Error( - `Tensor values for a int32 Tensor must be in the ` + - `range [0 - 255] but encountered ${value}.`); - } - } - - if (depth === 1) { - rgba[0] = value * multiplier; - rgba[1] = value * multiplier; - rgba[2] = value * multiplier; - } else { - rgba[d] = value * multiplier; - } - } - - const j = i * 4; - bytes[j + 0] = Math.round(rgba[0]); - bytes[j + 1] = Math.round(rgba[1]); - bytes[j + 2] = Math.round(rgba[2]); - bytes[j + 3] = Math.round(rgba[3]); - } - - if (canvas != null) { - if (!hasToPixelsWarned) { - const kernel = getKernel(Draw, ENGINE.backendName); - if (kernel != null) { - console.warn( - 'tf.browser.toPixels is not efficient to draw tensor on canvas. ' + - 'Please try tf.browser.draw instead.'); - hasToPixelsWarned = true; - } - } - - canvas.width = width; - canvas.height = height; - const ctx = canvas.getContext('2d'); - const imageData = new ImageData(bytes, width, height); - ctx.putImageData(imageData, 0, 0); - } - if ($img !== img) { - $img.dispose(); - } - return bytes; -} - -/** - * Draws a `tf.Tensor` to a canvas. - * - * When the dtype of the input is 'float32', we assume values in the range - * [0-1]. Otherwise, when input is 'int32', we assume values in the range - * [0-255]. - * - * @param image The tensor to draw on the canvas. Must match one of - * these shapes: - * - Rank-2 with shape `[height, width`]: Drawn as grayscale. - * - Rank-3 with shape `[height, width, 1]`: Drawn as grayscale. - * - Rank-3 with shape `[height, width, 3]`: Drawn as RGB with alpha set in - * `imageOptions` (defaults to 1, which is opaque). - * - Rank-3 with shape `[height, width, 4]`: Drawn as RGBA. - * @param canvas The canvas to draw to. - * @param options The configuration arguments for image to be drawn and the - * canvas to draw to. - * - * @doc {heading: 'Browser', namespace: 'browser'} - */ -export function draw( - image: Tensor2D|Tensor3D|TensorLike, canvas: HTMLCanvasElement, - options?: DrawOptions): void { - let $img = convertToTensor(image, 'img', 'draw'); - if (!(image instanceof Tensor)) { - // Assume int32 if user passed a native array. - const originalImgTensor = $img; - $img = cast(originalImgTensor, 'int32'); - originalImgTensor.dispose(); - } - validateImgTensor($img); - validateImageOptions(options?.imageOptions); - - const inputs: DrawInputs = {image: $img}; - const attrs: DrawAttrs = {canvas, options}; - ENGINE.runKernel( - Draw, inputs as unknown as NamedTensorMap, - attrs as unknown as NamedAttrMap); -} - -export const fromPixels = /* @__PURE__ */ op({fromPixels_}); diff --git a/tfjs-master/tfjs-core/src/ops/buffer.ts b/tfjs-master/tfjs-core/src/ops/buffer.ts deleted file mode 100644 index 7d8951e6e..000000000 --- a/tfjs-master/tfjs-core/src/ops/buffer.ts +++ /dev/null @@ -1,54 +0,0 @@ -/** - * @license - * Copyright 2020 Google Inc. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {TensorBuffer} from '../tensor'; -import {DataType, DataTypeMap, Rank, ShapeMap} from '../types'; -import * as util from '../util'; - -/** - * Creates an empty `tf.TensorBuffer` with the specified `shape` and `dtype`. - * - * The values are stored in CPU as `TypedArray`. Fill the buffer using - * `buffer.set()`, or by modifying directly `buffer.values`. - * - * When done, call `buffer.toTensor()` to get an immutable `tf.Tensor` with - * those values. - * - * ```js - * // Create a buffer and set values at particular indices. - * const buffer = tf.buffer([2, 2]); - * buffer.set(3, 0, 0); - * buffer.set(5, 1, 0); - * - * // Convert the buffer back to a tensor. - * buffer.toTensor().print(); - * ``` - * - * @param shape An array of integers defining the output tensor shape. - * @param dtype The dtype of the buffer. Defaults to 'float32'. - * @param values The values of the buffer as `TypedArray`. Defaults to - * zeros. - * - * @doc {heading: 'Tensors', subheading: 'Creation'} - */ -export function buffer( - shape: ShapeMap[R], dtype: D = 'float32' as D, - values?: DataTypeMap[D]): TensorBuffer { - dtype = dtype || 'float32' as D; - util.assertNonNegativeIntegerDimensions(shape); - return new TensorBuffer(shape, dtype, values); -} diff --git a/tfjs-master/tfjs-core/src/ops/cast.ts b/tfjs-master/tfjs-core/src/ops/cast.ts deleted file mode 100644 index bee8b2f48..000000000 --- a/tfjs-master/tfjs-core/src/ops/cast.ts +++ /dev/null @@ -1,60 +0,0 @@ -/** - * @license - * Copyright 2020 Google Inc. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {ENGINE} from '../engine'; -import {Cast, CastAttrs, CastInputs} from '../kernel_names'; -import {NamedAttrMap} from '../kernel_registry'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {DataType, TensorLike} from '../types'; -import * as util from '../util'; - -import {op} from './operation'; - -/** - * Casts a `tf.Tensor` to a new dtype. - * - * ```js - * const x = tf.tensor1d([1.5, 2.5, 3]); - * tf.cast(x, 'int32').print(); - * ``` - * @param x The input tensor to be casted. - * @param dtype The dtype to cast the input tensor to. - * - * @doc {heading: 'Tensors', subheading: 'Transformations'} - */ -function cast_(x: T|TensorLike, dtype: DataType): T { - const $x = convertToTensor(x, 'x', 'cast'); - - // Sanity checks. - if (!util.isValidDtype(dtype)) { - throw new Error(`Failed to cast to unknown dtype ${dtype}`); - } - if (dtype === 'string' && $x.dtype !== 'string' || - dtype !== 'string' && $x.dtype === 'string') { - throw new Error('Only strings can be casted to strings'); - } - - const inputs: CastInputs = {x: $x}; - const attrs: CastAttrs = {dtype}; - - return ENGINE.runKernel( - Cast, inputs as unknown as NamedTensorMap, - attrs as unknown as NamedAttrMap); -} - -export const cast = /* @__PURE__ */ op({cast_}); diff --git a/tfjs-master/tfjs-core/src/ops/ceil.ts b/tfjs-master/tfjs-core/src/ops/ceil.ts deleted file mode 100644 index 1c113343c..000000000 --- a/tfjs-master/tfjs-core/src/ops/ceil.ts +++ /dev/null @@ -1,45 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {Ceil, CeilInputs} from '../kernel_names'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -import {op} from './operation'; - -/** - * Computes ceiling of input `tf.Tensor` element-wise: `ceil(x)` - * - * ```js - * const x = tf.tensor1d([.6, 1.1, -3.3]); - * - * x.ceil().print(); // or tf.ceil(x) - * ``` - * @param x The input Tensor. - * - * @doc {heading: 'Operations', subheading: 'Basic math'} - */ -function ceil_(x: T|TensorLike): T { - const $x = convertToTensor(x, 'x', 'ceil', 'float32'); - - const inputs: CeilInputs = {x: $x}; - return ENGINE.runKernel(Ceil, inputs as unknown as NamedTensorMap); -} -export const ceil = /* @__PURE__ */ op({ceil_}); diff --git a/tfjs-master/tfjs-core/src/ops/ceil_test.ts b/tfjs-master/tfjs-core/src/ops/ceil_test.ts deleted file mode 100644 index daa266011..000000000 --- a/tfjs-master/tfjs-core/src/ops/ceil_test.ts +++ /dev/null @@ -1,98 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('ceil', ALL_ENVS, () => { - it('basic', async () => { - const a = tf.tensor1d([1.5, 2.1, -1.4]); - const r = tf.ceil(a); - expectArraysClose(await r.data(), [2, 3, -1]); - }); - - it('propagates NaNs', async () => { - const a = tf.tensor1d([1.5, NaN, -1.4]); - const r = tf.ceil(a); - expectArraysClose(await r.data(), [2, NaN, -1]); - }); - - it('gradients: Scalar', async () => { - const a = tf.scalar(5.2); - const dy = tf.scalar(3); - - const gradients = tf.grad(a => tf.ceil(a))(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), [0]); - }); - - it('gradient with clones', async () => { - const a = tf.scalar(5.2); - const dy = tf.scalar(3); - - const gradients = tf.grad(a => tf.ceil(a.clone()).clone())(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), [0]); - }); - - it('gradients: Tensor1D', async () => { - const a = tf.tensor1d([-1.1, 2.6, 3, -5.9]); - const dy = tf.tensor1d([1, 2, 3, 4]); - - const gradients = tf.grad(a => tf.ceil(a))(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), [0, 0, 0, 0]); - }); - - it('gradients: Tensor2D', async () => { - const a = tf.tensor2d([-3, 1, 2.2, 3], [2, 2]); - const dy = tf.tensor2d([1, 2, 3, 4], [2, 2]); - - const gradients = tf.grad(a => tf.ceil(a))(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), [0, 0, 0, 0]); - }); - - it('throws when passed a non-tensor', () => { - expect(() => tf.ceil({} as tf.Tensor)) - .toThrowError(/Argument 'x' passed to 'ceil' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const r = tf.ceil([1.5, 2.1, -1.4]); - expectArraysClose(await r.data(), [2, 3, -1]); - }); - - it('throws for string tensor', () => { - expect(() => tf.ceil('q')) - .toThrowError(/Argument 'x' passed to 'ceil' must be float32/); - }); - - it('throws for int32 tensor', () => { - expect(() => tf.ceil(tf.tensor1d([1], 'int32'))) - .toThrowError(/Argument 'x' passed to 'ceil' must be float32/); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/clip_by_value.ts b/tfjs-master/tfjs-core/src/ops/clip_by_value.ts deleted file mode 100644 index 642b9d0da..000000000 --- a/tfjs-master/tfjs-core/src/ops/clip_by_value.ts +++ /dev/null @@ -1,63 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {ENGINE} from '../engine'; -import {ClipByValue, ClipByValueAttrs, ClipByValueInputs} from '../kernel_names'; -import {NamedAttrMap} from '../kernel_registry'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; -import * as util from '../util'; -import {fill} from './fill'; - -import {op} from './operation'; - -/** - * Clips values element-wise. `max(min(x, clipValueMax), clipValueMin)` - * - * ```js - * const x = tf.tensor1d([-1, 2, -3, 4]); - * - * x.clipByValue(-2, 3).print(); // or tf.clipByValue(x, -2, 3) - * ``` - * @param x The input tensor. - * @param clipValueMin Lower bound of range to be clipped to. - * @param clipValueMax Upper bound of range to be clipped to. - * - * @doc {heading: 'Operations', subheading: 'Basic math'} - */ -function clipByValue_( - x: T|TensorLike, clipValueMin: number, clipValueMax: number): T { - const $x = convertToTensor(x, 'x', 'clipByValue'); - util.assert( - (clipValueMin <= clipValueMax), - () => `Error in clip: min (${clipValueMin}) must be ` + - `less than or equal to max (${clipValueMax}).`); - - if (clipValueMin === clipValueMax) { - return fill($x.shape, clipValueMin, $x.dtype) as T; - } - - const inputs: ClipByValueInputs = {x: $x}; - const attrs: ClipByValueAttrs = {clipValueMin, clipValueMax}; - - return ENGINE.runKernel( - ClipByValue, inputs as unknown as NamedTensorMap, - attrs as unknown as NamedAttrMap); -} - -export const clipByValue = /* @__PURE__ */ op({clipByValue_}); diff --git a/tfjs-master/tfjs-core/src/ops/clip_by_value_test.ts b/tfjs-master/tfjs-core/src/ops/clip_by_value_test.ts deleted file mode 100644 index 359672f6a..000000000 --- a/tfjs-master/tfjs-core/src/ops/clip_by_value_test.ts +++ /dev/null @@ -1,165 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('clipByValue', ALL_ENVS, () => { - it('basic', async () => { - const a = tf.tensor1d([3, -1, 0, 100, -7, 2]); - const min = -1; - const max = 50; - - const result = tf.clipByValue(a, min, max); - - expectArraysClose(await result.data(), [3, -1, 0, 50, -1, 2]); - }); - - it('basic vec4', async () => { - const a = tf.tensor1d([3, -1, 0, 100, -7, 2, 5, NaN]); - const min = -1; - const max = 50; - - const result = tf.clipByValue(a, min, max); - - expectArraysClose(await result.data(), [3, -1, 0, 50, -1, 2, 5, NaN]); - }); - - it('propagates NaNs', async () => { - const a = tf.tensor1d([3, -1, 0, 100, -7, 2, NaN]); - const min = -1; - const max = 50; - - const result = tf.clipByValue(a, min, max); - - expectArraysClose(await result.data(), [3, -1, 0, 50, -1, 2, NaN]); - }); - - it('min greater than max', () => { - const a = tf.tensor1d([3, -1, 0, 100, -7, 2]); - const min = 1; - const max = -1; - - const f = () => { - tf.clipByValue(a, min, max); - }; - expect(f).toThrowError(); - }); - - it('gradient: 1D tensor', async () => { - const min = -1; - const max = 2; - const x = tf.tensor1d([3, -2, 1]); // Only 1 is not clipped. - const dy = tf.tensor1d([5, 50, 500]); - const gradients = tf.grad(x => x.clipByValue(min, max))(x, dy); - - expect(gradients.shape).toEqual(x.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), [0, 0, 500]); - }); - - it('gradient: 1D tensor with max or min value', async () => { - const min = -1; - const max = 2; - const x = tf.tensor1d([-1, 1, 2, 3]); - const dy = tf.tensor1d([1, 10, 100, 1000]); - const gradients = tf.grad(x => x.clipByValue(min, max))(x, dy); - - expect(gradients.shape).toEqual(x.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), [1, 10, 100, 0]); - }); - - it('gradient: scalar', async () => { - const min = -1; - const max = 2; - const x = tf.scalar(-10); // Clipped. - const dy = tf.scalar(5); - const gradients = tf.grad(x => x.clipByValue(min, max))(x, dy); - - expect(gradients.shape).toEqual(x.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), [0]); - }); - - it('gradient with clones', async () => { - const min = -1; - const max = 2; - const x = tf.scalar(-10); // Clipped. - const dy = tf.scalar(5); - const gradients = - tf.grad(x => x.clone().clipByValue(min, max).clone())(x, dy); - - expect(gradients.shape).toEqual(x.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), [0]); - }); - - it('gradient with primitive as input', async () => { - const min = -1; - const max = 2; - const x = -10; - const dy = tf.scalar(5); - const gradients = tf.grad(x => x.clipByValue(min, max))(x, dy); - expect(gradients.shape).toEqual([]); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), [0]); - }); - - it('throws when passed a non-tensor', () => { - expect(() => tf.clipByValue({} as tf.Tensor, 0, 1)) - .toThrowError(/Argument 'x' passed to 'clipByValue' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const min = -1; - const max = 50; - const result = tf.clipByValue([3, -1, 0, 100, -7, 2], min, max); - expectArraysClose(await result.data(), [3, -1, 0, 50, -1, 2]); - }); - - it('clip(x, eps, 1-eps) never returns 0 or 1', async () => { - const min = tf.backend().epsilon(); - const max = 0.5; - const res = await tf.clipByValue([0, 1], min, max).data(); - expect(res[0]).toBeGreaterThan(0); - expect(res[1]).toBeCloseTo(max); - }); - - it('clip min = max', async () => { - const min = 2; - const max = 2; - const tensor = tf.tensor([1, 2, 3, 4, 5], [5], 'float32'); - const result = tf.clipByValue(tensor, min, max); - expectArraysClose(await result.data(), [2, 2, 2, 2, 2]); - }); - - it('throws for string tensor', () => { - expect(() => tf.clipByValue('q', 0, 1)) - .toThrowError(/Argument 'x' passed to 'clipByValue' must be numeric/); - }); - - it('clip int32 tensor', async () => { - const min = -1; - const max = 50; - const tensor = tf.tensor([2, 3, 4], [3], 'int32'); - const result = tf.clipByValue(tensor, min, max); - expectArraysClose(await result.data(), [2, 3, 4]); - expect(result.dtype).toEqual('int32'); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/clone.ts b/tfjs-master/tfjs-core/src/ops/clone.ts deleted file mode 100644 index 5906b9e76..000000000 --- a/tfjs-master/tfjs-core/src/ops/clone.ts +++ /dev/null @@ -1,50 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {Identity, IdentityInputs} from '../kernel_names'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -import {op} from './operation'; - -/** - * Creates a new tensor with the same values and shape as the specified - * tensor. - * - * ```js - * const x = tf.tensor([1, 2]); - * - * x.clone().print(); - * ``` - * - * @param x The tensor to clone. - * - * @doc {heading: 'Tensors', subheading: 'Creation'} - */ -function clone_(x: T|TensorLike): T { - const $x = convertToTensor(x, 'x', 'clone', 'string_or_numeric'); - const inputs: IdentityInputs = {x: $x}; - - // Note this op is called tf.identity in python. Hence the kernel name used - // here. - return ENGINE.runKernel(Identity, inputs as unknown as NamedTensorMap); -} - -export const clone = /* @__PURE__ */ op({clone_}); diff --git a/tfjs-master/tfjs-core/src/ops/clone_test.ts b/tfjs-master/tfjs-core/src/ops/clone_test.ts deleted file mode 100644 index 85c7bc0e5..000000000 --- a/tfjs-master/tfjs-core/src/ops/clone_test.ts +++ /dev/null @@ -1,305 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose, expectArraysEqual} from '../test_util'; - -describeWithFlags('clone', ALL_ENVS, () => { - it('returns a tensor with the same shape and value', async () => { - const a = tf.tensor2d([1, 2, 3, 4, 5, 6, 7, 8, 9], [3, 3]); - const aPrime = tf.clone(a); - expect(aPrime.shape).toEqual(a.shape); - expectArraysClose(await aPrime.data(), await a.data()); - expect(aPrime.shape).toEqual(a.shape); - }); - - it('accepts a tensor-like object', async () => { - const res = tf.clone([[1, 2, 3], [4, 5, 6]]); - expect(res.dtype).toBe('float32'); - expect(res.shape).toEqual([2, 3]); - expectArraysClose(await res.data(), [1, 2, 3, 4, 5, 6]); - }); -}); - -describeWithFlags('clone', ALL_ENVS, () => { - it('1D default dtype', async () => { - const a = tf.tensor1d([1, 2, 3]); - const b = tf.clone(a); - expect(b.dtype).toBe('float32'); - expect(b.shape).toEqual([3]); - expectArraysClose(await b.data(), [1, 2, 3]); - }); - - it('1D float32 dtype', async () => { - const a = tf.tensor1d([1, 2, 3], 'float32'); - const b = tf.clone(a); - expect(b.dtype).toBe('float32'); - expect(b.shape).toEqual([3]); - expectArraysClose(await b.data(), [1, 2, 3]); - }); - - it('1D int32 dtype', async () => { - const a = tf.tensor1d([1, 2, 3], 'int32'); - const b = tf.clone(a); - expect(b.dtype).toBe('int32'); - expect(b.shape).toEqual([3]); - expectArraysEqual(await b.data(), [1, 2, 3]); - }); - - it('1D bool dtype', async () => { - const a = tf.tensor1d([1, 1, 0], 'bool'); - const b = tf.clone(a); - expect(b.dtype).toBe('bool'); - expect(b.shape).toEqual([3]); - expectArraysEqual(await b.data(), [1, 1, 0]); - }); - - it('1D complex64 dtype', async () => { - const a = tf.complex([1], [1]); - const b = tf.clone(a); - expect(b.dtype).toBe('complex64'); - expect(b.shape).toEqual([1]); - expectArraysEqual(await b.data(), [1, 1]); - }); - - it('1D string dtype', async () => { - const a = tf.tensor1d(['a', 'b', 'c'], 'string'); - const b = tf.clone(a); - expect(b.dtype).toBe('string'); - expect(b.shape).toEqual([3]); - expectArraysEqual(await b.data(), ['a', 'b', 'c']); - }); - - it('2D default dtype', async () => { - const a = tf.tensor2d([1, 2, 3, 4], [2, 2]); - const b = tf.clone(a); - expect(b.dtype).toBe('float32'); - expect(b.shape).toEqual([2, 2]); - expectArraysClose(await b.data(), [1, 2, 3, 4]); - }); - - it('2D float32 dtype', async () => { - const a = tf.tensor2d([1, 2, 3, 4], [2, 2], 'float32'); - const b = tf.clone(a); - expect(b.dtype).toBe('float32'); - expect(b.shape).toEqual([2, 2]); - expectArraysClose(await b.data(), [1, 2, 3, 4]); - }); - - it('2D int32 dtype', async () => { - const a = tf.tensor2d([1, 2, 3, 4], [2, 2], 'int32'); - const b = tf.clone(a); - expect(b.dtype).toBe('int32'); - expect(b.shape).toEqual([2, 2]); - expectArraysEqual(await b.data(), [1, 2, 3, 4]); - }); - - it('2D bool dtype', async () => { - const a = tf.tensor2d([1, 1, 1, 0], [2, 2], 'bool'); - const b = tf.clone(a); - expect(b.dtype).toBe('bool'); - expect(b.shape).toEqual([2, 2]); - expectArraysEqual(await b.data(), [1, 1, 1, 0]); - }); - - it('2D complex64 dtype', async () => { - const a = tf.complex([[1, 3], [5, 7]], [[2, 4], [6, 8]]); - const b = tf.clone(a); - expect(b.dtype).toBe('complex64'); - expect(b.shape).toEqual([2, 2]); - expectArraysEqual(await b.data(), [1, 2, 3, 4, 5, 6, 7, 8]); - }); - - it('2D string dtype', async () => { - const a = tf.tensor2d(['a', 'b', 'c', 'd'], [2, 2], 'string'); - const b = tf.clone(a); - expect(b.dtype).toBe('string'); - expect(b.shape).toEqual([2, 2]); - expectArraysEqual(await b.data(), ['a', 'b', 'c', 'd']); - }); - - it('3D default dtype', async () => { - const a = tf.tensor3d([1, 2, 3, 4], [2, 2, 1]); - const b = tf.clone(a); - expect(b.dtype).toBe('float32'); - expect(b.shape).toEqual([2, 2, 1]); - expectArraysClose(await b.data(), [1, 2, 3, 4]); - }); - - it('3D float32 dtype', async () => { - const a = tf.tensor3d([1, 2, 3, 4], [2, 2, 1], 'float32'); - const b = tf.clone(a); - expect(b.dtype).toBe('float32'); - expect(b.shape).toEqual([2, 2, 1]); - expectArraysClose(await b.data(), [1, 2, 3, 4]); - }); - - it('3D int32 dtype', async () => { - const a = tf.tensor3d([1, 2, 3, 4], [2, 2, 1], 'int32'); - const b = tf.clone(a); - expect(b.dtype).toBe('int32'); - expect(b.shape).toEqual([2, 2, 1]); - expectArraysEqual(await b.data(), [1, 2, 3, 4]); - }); - - it('3D bool dtype', async () => { - const a = tf.tensor3d([1, 1, 1, 0], [2, 2, 1], 'bool'); - const b = tf.clone(a); - expect(b.dtype).toBe('bool'); - expect(b.shape).toEqual([2, 2, 1]); - expectArraysEqual(await b.data(), [1, 1, 1, 0]); - }); - - it('3D complex64 dtype', async () => { - const a = tf.complex([[[1], [3]], [[5], [7]]], [[[2], [4]], [[6], [8]]]); - const b = tf.clone(a); - expect(b.dtype).toBe('complex64'); - expect(b.shape).toEqual([2, 2, 1]); - expectArraysEqual(await b.data(), [1, 2, 3, 4, 5, 6, 7, 8]); - }); - - it('3D string dtype', async () => { - const a = tf.tensor3d(['a', 'b', 'c', 'd'], [2, 2, 1], 'string'); - const b = tf.clone(a); - expect(b.dtype).toBe('string'); - expect(b.shape).toEqual([2, 2, 1]); - expectArraysEqual(await b.data(), ['a', 'b', 'c', 'd']); - }); - - it('4D default dtype', async () => { - const a = tf.tensor4d([1, 2, 3, 4], [2, 2, 1, 1]); - const b = tf.clone(a); - expect(b.dtype).toBe('float32'); - expect(b.shape).toEqual([2, 2, 1, 1]); - expectArraysClose(await b.data(), [1, 2, 3, 4]); - }); - - it('4D float32 dtype', async () => { - const a = tf.tensor4d([1, 2, 3, 4], [2, 2, 1, 1], 'float32'); - const b = tf.clone(a); - expect(b.dtype).toBe('float32'); - expect(b.shape).toEqual([2, 2, 1, 1]); - expectArraysClose(await b.data(), [1, 2, 3, 4]); - }); - - it('4D int32 dtype', async () => { - const a = tf.tensor4d([1, 2, 3, 4], [2, 2, 1, 1], 'int32'); - const b = tf.clone(a); - expect(b.dtype).toBe('int32'); - expect(b.shape).toEqual([2, 2, 1, 1]); - expectArraysEqual(await b.data(), [1, 2, 3, 4]); - }); - - it('4D bool dtype', async () => { - const a = tf.tensor4d([1, 1, 1, 0], [2, 2, 1, 1], 'bool'); - const b = tf.clone(a); - expect(b.dtype).toBe('bool'); - expect(b.shape).toEqual([2, 2, 1, 1]); - expectArraysEqual(await b.data(), [1, 1, 1, 0]); - }); - - it('4D complex64 dtype', async () => { - const a = tf.complex( - [[[[1]], [[3]]], [[[5]], [[7]]]], [[[[2]], [[4]]], [[[6]], [[8]]]]); - const b = tf.clone(a); - expect(b.dtype).toBe('complex64'); - expect(b.shape).toEqual([2, 2, 1, 1]); - expectArraysEqual(await b.data(), [1, 2, 3, 4, 5, 6, 7, 8]); - }); - - it('4D string dtype', async () => { - const a = tf.tensor4d(['a', 'b', 'c', 'd'], [2, 2, 1, 1], 'string'); - const b = tf.clone(a); - expect(b.dtype).toBe('string'); - expect(b.shape).toEqual([2, 2, 1, 1]); - expectArraysEqual(await b.data(), ['a', 'b', 'c', 'd']); - }); - - it('gradient: 1D', async () => { - const a = tf.tensor1d([1, 2, 3]); - const dy = tf.tensor1d([4, 5, 6]); - const da = tf.grad(x => tf.clone(x))(a, dy); - - expect(da.dtype).toBe('float32'); - expect(da.shape).toEqual([3]); - expectArraysClose(await da.data(), [4, 5, 6]); - }); - - it('gradient with clones', async () => { - const a = tf.tensor1d([1, 2, 3]); - const dy = tf.tensor1d([4, 5, 6]); - const da = tf.grad(x => tf.clone(x.clone()).clone())(a, dy); - - expect(da.dtype).toBe('float32'); - expect(da.shape).toEqual([3]); - expectArraysClose(await da.data(), [4, 5, 6]); - }); - - it('gradient: 1D string throws error with string dy', () => { - const a = tf.tensor1d(['a', 'b', 'c'], 'string'); - const dy = tf.tensor1d(['d', 'e', 'f']); - expect(() => tf.grad(x => tf.clone(x))(a, dy)).toThrowError(); - }); - - it('gradient: 1D string throws error with bool dy', () => { - const a = tf.tensor1d(['a', 'b', 'c'], 'string'); - const dy = tf.tensor1d([false, true, false], 'bool'); - expect(() => tf.grad(x => tf.clone(x))(a, dy)).toThrowError(); - }); - - it('gradient: 1D string throws error with int32 dy', () => { - const a = tf.tensor1d(['a', 'b', 'c'], 'string'); - const dy = tf.tensor1d([4, 5, 6], 'int32'); - expect(() => tf.grad(x => tf.clone(x))(a, dy)).toThrowError(); - }); - - it('gradient: 1D string works with float32 dy', async () => { - const a = tf.tensor1d(['a', 'b', 'c'], 'string'); - const dy = tf.tensor1d([4, 5, 6]); - const da = tf.grad(x => tf.clone(x))(a, dy); - - expect(da.dtype).toBe('float32'); - expect(da.shape).toEqual([3]); - expectArraysClose(await da.data(), [4, 5, 6]); - }); - - it('gradient: 2D int32', async () => { - const a = tf.tensor2d([1, 2, 3, 4], [2, 2], 'int32'); - const dy = tf.tensor2d([5, 6, 7, 8], [2, 2], 'float32'); - const da = tf.grad(x => tf.clone(x))(a, dy); - - expect(da.dtype).toBe('float32'); - expect(da.shape).toEqual([2, 2]); - expectArraysEqual(await da.data(), [5, 6, 7, 8]); - }); - - it('gradient: 4D bool', async () => { - const a = tf.tensor4d([1, 1, 1, 0], [2, 2, 1, 1], 'bool'); - const dy = tf.tensor4d([5, 6, 7, 8], [2, 2, 1, 1], 'float32'); - const da = tf.grad(x => tf.clone(x))(a, dy); - - expect(da.dtype).toBe('float32'); - expect(da.shape).toEqual([2, 2, 1, 1]); - expectArraysEqual(await da.data(), [5, 6, 7, 8]); - }); - - it('throws when passed a non-tensor', () => { - expect(() => tf.clone({} as tf.Tensor)) - .toThrowError(/Argument 'x' passed to 'clone' must be a Tensor/); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/complex.ts b/tfjs-master/tfjs-core/src/ops/complex.ts deleted file mode 100644 index c8105454c..000000000 --- a/tfjs-master/tfjs-core/src/ops/complex.ts +++ /dev/null @@ -1,59 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {ENGINE} from '../engine'; -import {Complex, ComplexInputs} from '../kernel_names'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; -import * as util from '../util'; - -import {op} from './operation'; - -/** - * Converts two real numbers to a complex number. - * - * Given a tensor `real` representing the real part of a complex number, and a - * tensor `imag` representing the imaginary part of a complex number, this - * operation returns complex numbers elementwise of the form [r0, i0, r1, i1], - * where r represents the real part and i represents the imag part. - * - * The input tensors real and imag must have the same shape. - * - * ```js - * const real = tf.tensor1d([2.25, 3.25]); - * const imag = tf.tensor1d([4.75, 5.75]); - * const complex = tf.complex(real, imag); - * - * complex.print(); - * ``` - * - * @doc {heading: 'Tensors', subheading: 'Creation'} - */ -function complex_(real: T|TensorLike, imag: T|TensorLike): T { - const $real = convertToTensor(real, 'real', 'complex'); - const $imag = convertToTensor(imag, 'imag', 'complex'); - util.assertShapesMatch( - $real.shape, $imag.shape, - `real and imag shapes, ${$real.shape} and ${$imag.shape}, ` + - `must match in call to tf.complex().`); - - const inputs: ComplexInputs = {real: $real, imag: $imag}; - return ENGINE.runKernel(Complex, inputs as unknown as NamedTensorMap); -} - -export const complex = /* @__PURE__ */ op({complex_}); diff --git a/tfjs-master/tfjs-core/src/ops/complex_ops_test.ts b/tfjs-master/tfjs-core/src/ops/complex_ops_test.ts deleted file mode 100644 index 2c7539ad3..000000000 --- a/tfjs-master/tfjs-core/src/ops/complex_ops_test.ts +++ /dev/null @@ -1,58 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('complex64', ALL_ENVS, () => { - it('tf.complex', async () => { - const real = tf.tensor1d([3, 30]); - const imag = tf.tensor1d([4, 40]); - const complex = tf.complex(real, imag); - - expect(complex.dtype).toBe('complex64'); - expect(complex.shape).toEqual(real.shape); - expectArraysClose(await complex.data(), [3, 4, 30, 40]); - }); - - it('tf.real', async () => { - const complex = tf.complex([3, 30], [4, 40]); - const real = tf.real(complex); - - expect(real.dtype).toBe('float32'); - expect(real.shape).toEqual([2]); - expectArraysClose(await real.data(), [3, 30]); - }); - - it('tf.imag', async () => { - const complex = tf.complex([3, 30], [4, 40]); - const imag = tf.imag(complex); - - expect(imag.dtype).toBe('float32'); - expect(imag.shape).toEqual([2]); - expectArraysClose(await imag.data(), [4, 40]); - }); - - it('throws when shapes dont match', () => { - const real = tf.tensor1d([3, 30]); - const imag = tf.tensor1d([4, 40, 50]); - - const re = - /real and imag shapes, 2 and 3, must match in call to tf.complex\(\)/; - expect(() => tf.complex(real, imag)).toThrowError(re); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/concat.ts b/tfjs-master/tfjs-core/src/ops/concat.ts deleted file mode 100644 index afd58226c..000000000 --- a/tfjs-master/tfjs-core/src/ops/concat.ts +++ /dev/null @@ -1,96 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {ENGINE} from '../engine'; -import {Concat, ConcatAttrs, ConcatInputs} from '../kernel_names'; -import {NamedAttrMap} from '../kernel_registry'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensorArray} from '../tensor_util_env'; -import {TensorLike} from '../types'; -import {assert} from '../util'; - -import {clone} from './clone'; -import {op} from './operation'; - -/** - * Concatenates a list of `tf.Tensor`s along a given axis. - * - * The tensors ranks and types must match, and their sizes must match in all - * dimensions except `axis`. - * - * Also available are stricter rank-specific methods that assert that - * `tensors` are of the given rank: - * - `tf.concat1d` - * - `tf.concat2d` - * - `tf.concat3d` - * - `tf.concat4d` - * - * Except `tf.concat1d` (which does not have axis param), all methods have - * same signature as this method. - * - * ```js - * const a = tf.tensor1d([1, 2]); - * const b = tf.tensor1d([3, 4]); - * a.concat(b).print(); // or a.concat(b) - * ``` - * - * ```js - * const a = tf.tensor1d([1, 2]); - * const b = tf.tensor1d([3, 4]); - * const c = tf.tensor1d([5, 6]); - * tf.concat([a, b, c]).print(); - * ``` - * - * ```js - * const a = tf.tensor2d([[1, 2], [10, 20]]); - * const b = tf.tensor2d([[3, 4], [30, 40]]); - * const axis = 1; - * tf.concat([a, b], axis).print(); - * ``` - * @param tensors A list of tensors to concatenate. - * @param axis The axis to concatenate along. Defaults to 0 (the first dim). - * - * @doc {heading: 'Tensors', subheading: 'Slicing and Joining'} - */ -function concat_(tensors: Array, axis = 0): T { - assert(tensors.length >= 1, () => 'Pass at least one tensor to concat'); - - const $tensors = - convertToTensorArray(tensors, 'tensors', 'concat', 'string_or_numeric'); - - if ($tensors[0].dtype === 'complex64') { - $tensors.forEach(tensor => { - if (tensor.dtype !== 'complex64') { - throw new Error(`Cannot concatenate complex64 tensors with a tensor - with dtype ${tensor.dtype}. `); - } - }); - } - - if ($tensors.length === 1) { - return clone($tensors[0]); - } - - const inputs: ConcatInputs = $tensors; - const attr: ConcatAttrs = {axis}; - - return ENGINE.runKernel( - Concat, inputs as unknown as NamedTensorMap, - attr as unknown as NamedAttrMap); -} - -export const concat = /* @__PURE__ */ op({concat_}); diff --git a/tfjs-master/tfjs-core/src/ops/concat_1d.ts b/tfjs-master/tfjs-core/src/ops/concat_1d.ts deleted file mode 100644 index 84bcc7fc9..000000000 --- a/tfjs-master/tfjs-core/src/ops/concat_1d.ts +++ /dev/null @@ -1,38 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {Tensor1D} from '../tensor'; -import {TensorLike} from '../types'; - -import {concat} from './concat'; -import {op} from './operation'; - -/** - * Concatenates a list of`tf.Tensor1D`s along an axis. See `concat` for details. - * - * For example, if: - * A: shape(3) = |r1, g1, b1| - * B: shape(2) = |r2, g2| - * C = tf.concat1d([A, B]) == |r1, g1, b1, r2, g2| - * - * @param tensors A list of`tf.Tensor`s to concatenate. - * @return The concatenated array. - */ -function concat1d_(tensors: Array): Tensor1D { - return concat(tensors, 0 /* axis */); -} - -export const concat1d = /* @__PURE__ */ op({concat1d_}); diff --git a/tfjs-master/tfjs-core/src/ops/concat_2d.ts b/tfjs-master/tfjs-core/src/ops/concat_2d.ts deleted file mode 100644 index 206fbefd9..000000000 --- a/tfjs-master/tfjs-core/src/ops/concat_2d.ts +++ /dev/null @@ -1,55 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {Tensor2D} from '../tensor'; -import {TensorLike} from '../types'; - -import {concat} from './concat'; -import {op} from './operation'; - -/** - * Concatenates a list of`tf.Tensor2D`s along an axis. See `concat` for details. - * - * For example, if: - * A: shape(2, 3) = | r1, g1, b1 | - * | r2, g2, b2 | - * - * B: shape(2, 3) = | r3, g3, b3 | - * | r4, g4, b4 | - * - * C = tf.concat2d([A, B], axis) - * - * if axis = 0: - * C: shape(4, 3) = | r1, g1, b1 | - * | r2, g2, b2 | - * | r3, g3, b3 | - * | r4, g4, b4 | - * - * if axis = 1: - * C = shape(2, 6) = | r1, g1, b1, r3, g3, b3 | - * | r2, g2, b2, r4, g4, b4 | - * - * - * @param tensors A list of `tf.Tensor`s to concatenate. - * @param axis The axis to concatenate along. - * @return The concatenated array. - */ -function concat2d_( - tensors: Array, axis: number): Tensor2D { - return concat(tensors, axis); -} - -export const concat2d = /* @__PURE__ */ op({concat2d_}); diff --git a/tfjs-master/tfjs-core/src/ops/concat_3d.ts b/tfjs-master/tfjs-core/src/ops/concat_3d.ts deleted file mode 100644 index c6534b28c..000000000 --- a/tfjs-master/tfjs-core/src/ops/concat_3d.ts +++ /dev/null @@ -1,59 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {Tensor3D} from '../tensor'; -import {TensorLike} from '../types'; - -import {concat} from './concat'; -import {op} from './operation'; - -/** - * Concatenates a list of `tf.Tensor3D`s along an axis. - * See `concat` for details. - * - * For example, if: - * A: shape(2, 1, 3) = | r1, g1, b1 | - * | r2, g2, b2 | - * - * B: shape(2, 1, 3) = | r3, g3, b3 | - * | r4, g4, b4 | - * - * C = tf.concat3d([A, B], axis) - * - * if axis = 0: - * C: shape(4, 1, 3) = | r1, g1, b1 | - * | r2, g2, b2 | - * | r3, g3, b3 | - * | r4, g4, b4 | - * - * if axis = 1: - * C: shape(2, 2, 3) = | r1, g1, b1, r3, g3, b3 | - * | r2, g2, b2, r4, g4, b4 | - * - * if axis = 2: - * C = shape(2, 1, 6) = | r1, g1, b1, r3, g3, b3 | - * | r2, g2, b2, r4, g4, b4 | - * - * @param tensors A list of`tf.Tensor`s to concatenate. - * @param axis The axis to concate along. - * @return The concatenated array. - */ -function concat3d_( - tensors: Array, axis: number): Tensor3D { - return concat(tensors, axis); -} - -export const concat3d = /* @__PURE__ */ op({concat3d_}); diff --git a/tfjs-master/tfjs-core/src/ops/concat_4d.ts b/tfjs-master/tfjs-core/src/ops/concat_4d.ts deleted file mode 100644 index 8c63779d3..000000000 --- a/tfjs-master/tfjs-core/src/ops/concat_4d.ts +++ /dev/null @@ -1,36 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {Tensor4D} from '../tensor'; -import {TensorLike} from '../types'; - -import {concat} from './concat'; -import {op} from './operation'; - -/** - * Concatenates a list of `tf.Tensor4D`s along an axis. - * See `concat` for details. - * - * @param tensors A list of `tf.Tensor`s to concatenate. - * @param axis The axis to concate along. - * @return The concatenated array. - */ -function concat4d_( - tensors: Array, axis: number): Tensor4D { - return concat(tensors, axis); -} - -export const concat4d = /* @__PURE__ */ op({concat4d_}); diff --git a/tfjs-master/tfjs-core/src/ops/concat_test.ts b/tfjs-master/tfjs-core/src/ops/concat_test.ts deleted file mode 100644 index c6ba752c6..000000000 --- a/tfjs-master/tfjs-core/src/ops/concat_test.ts +++ /dev/null @@ -1,634 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose, expectArraysEqual} from '../test_util'; - -describeWithFlags('concat1d', ALL_ENVS, () => { - it('3 + 5', async () => { - const a = tf.tensor1d([3]); - const b = tf.tensor1d([5]); - - const result = tf.concat1d([a, b]); - const expected = [3, 5]; - expectArraysClose(await result.data(), expected); - }); - it('TensorLike 3 + 5', async () => { - const a = [3]; - const b = [5]; - - const result = tf.concat1d([a, b]); - const expected = [3, 5]; - expectArraysClose(await result.data(), expected); - }); - it('TensorLike Chained 3 + 5', async () => { - const a = tf.tensor1d([3]); - const b = [5]; - - const result = a.concat([b]); - const expected = [3, 5]; - expectArraysClose(await result.data(), expected); - }); - it('3 + [5,7]', async () => { - const a = tf.tensor1d([3]); - const b = tf.tensor1d([5, 7]); - - const result = tf.concat1d([a, b]); - const expected = [3, 5, 7]; - expectArraysClose(await result.data(), expected); - }); - - it('[3,5] + 7', async () => { - const a = tf.tensor1d([3, 5]); - const b = tf.tensor1d([7]); - - const result = tf.concat1d([a, b]); - const expected = [3, 5, 7]; - expectArraysClose(await result.data(), expected); - }); - - it('3 + 5 + 7 + 9', async () => { - const a = tf.tensor1d([3]); - const b = tf.tensor1d([5]); - const c = tf.tensor1d([7]); - const d = tf.tensor1d([9]); - - const result = tf.concat1d([a, b, c, d]); - expectArraysClose(await result.data(), [3, 5, 7, 9]); - }); - - it('single tensor', async () => { - const a = tf.tensor1d([3]); - - const result = tf.concat1d([a]); - expectArraysClose(await result.data(), [3]); - }); - - it('accepts a tensor-like object', async () => { - const a = [3]; - const b = [5]; - - const result = tf.concat1d([a, b]); - const expected = [3, 5]; - expectArraysClose(await result.data(), expected); - }); - - it('concat complex input', async () => { - // [1+1j, 2+2j] - const c1 = tf.complex([1, 2], [1, 2]); - // [3+3j, 4+4j] - const c2 = tf.complex([3, 4], [3, 4]); - - const axis = 0; - const result = tf.concat([c1, c2], axis); - const expected = [1, 1, 2, 2, 3, 3, 4, 4]; - expect(result.dtype).toEqual('complex64'); - expectArraysClose(await result.data(), expected); - }); -}); - -describeWithFlags('concat2d', ALL_ENVS, () => { - it('[[3]] + [[5]], axis=0', async () => { - const axis = 0; - const a = tf.tensor2d([3], [1, 1]); - const b = tf.tensor2d([5], [1, 1]); - - const result = tf.concat2d([a, b], axis); - const expected = [3, 5]; - - expect(result.shape).toEqual([2, 1]); - expectArraysClose(await result.data(), expected); - }); - it('TensorLike [[3]] + [[5]], axis=0', async () => { - const axis = 0; - const a = [[3]]; - const b = [[5]]; - - const result = tf.concat2d([a, b], axis); - const expected = [3, 5]; - - expect(result.shape).toEqual([2, 1]); - expectArraysClose(await result.data(), expected); - }); - it('TensorLike Chained [[3]] + [[5]], axis=0', async () => { - const axis = 0; - const a = tf.tensor2d([3], [1, 1]); - const b = [[5]]; - - const result = a.concat([b], axis); - const expected = [3, 5]; - - expect(result.shape).toEqual([2, 1]); - expectArraysClose(await result.data(), expected); - }); - - it('[[3]] + [[5]], axis=1', async () => { - const axis = 1; - const a = tf.tensor2d([3], [1, 1]); - const b = tf.tensor2d([5], [1, 1]); - - const result = tf.concat2d([a, b], axis); - const expected = [3, 5]; - - expect(result.shape).toEqual([1, 2]); - expectArraysClose(await result.data(), expected); - }); - - it('[[1, 2], [3, 4]] + [[5, 6]], axis=0', async () => { - const axis = 0; - const a = tf.tensor2d([[1, 2], [3, 4]], [2, 2]); - const b = tf.tensor2d([[5, 6]], [1, 2]); - - const result = tf.concat2d([a, b], axis); - const expected = [1, 2, 3, 4, 5, 6]; - - expect(result.shape).toEqual([3, 2]); - expectArraysClose(await result.data(), expected); - }); - - it('[[1, 2],[3, 4]] + [[5, 6]] + [[7, 8]], axis=0', async () => { - const axis = 0; - const a = tf.tensor2d([[1, 2], [3, 4]]); - const b = tf.tensor2d([[5, 6]]); - const c = tf.tensor2d([[7, 8]]); - - const result = tf.concat2d([a, b, c], axis); - const expected = [1, 2, 3, 4, 5, 6, 7, 8]; - - expect(result.shape).toEqual([4, 2]); - expectArraysClose(await result.data(), expected); - }); - - it('[[1, 2], [3, 4]] + [[5, 6]], axis=1 throws error', () => { - const axis = 1; - const a = tf.tensor2d([[1, 2], [3, 4]], [2, 2]); - const b = tf.tensor2d([[5, 6]], [1, 2]); - - expect(() => tf.concat2d([a, b], axis)).toThrowError(); - }); - - it('[[1, 2], [3, 4]] + [[5, 6], [7, 8]], axis=1', async () => { - const axis = 1; - const a = tf.tensor2d([[1, 2], [3, 4]], [2, 2]); - const b = tf.tensor2d([[5, 6], [7, 8]], [2, 2]); - - const result = tf.concat2d([a, b], axis); - const expected = [1, 2, 5, 6, 3, 4, 7, 8]; - - expect(result.shape).toEqual([2, 4]); - expectArraysClose(await result.data(), expected); - }); - - it('[[1, 2],[3, 4]] + [[5, 6],[7, 8]] + [[9, 10],[11, 12]], axis=1', - async () => { - const axis = 1; - const a = tf.tensor2d([[1, 2], [3, 4]]); - const b = tf.tensor2d([[5, 6], [7, 8]]); - const c = tf.tensor2d([[9, 10], [11, 12]]); - - const result = tf.concat2d([a, b, c], axis); - const expected = [1, 2, 5, 6, 9, 10, 3, 4, 7, 8, 11, 12]; - - expect(result.shape).toEqual([2, 6]); - expectArraysClose(await result.data(), expected); - }); - - it('accepts a tensor-like object', async () => { - const axis = 0; - const a = [[3]]; - const b = [[5]]; - - const result = tf.concat2d([a, b], axis); - const expected = [3, 5]; - - expect(result.shape).toEqual([2, 1]); - expectArraysClose(await result.data(), expected); - }); - - it('concat zero-sized tensors', async () => { - const a = tf.tensor2d([], [0, 5]); - const b = tf.tensor2d([], [0, 5]); - const c = tf.tensor2d([], [0, 5]); - - const res = tf.concat([a, b, c], /* axis */ 0); - expect(res.shape).toEqual([0, 5]); - expectArraysEqual(await res.data(), []); - - const res2 = tf.concat([a, b, c], /* axis */ 1); - expect(res2.shape).toEqual([0, 15]); - expectArraysEqual(await res2.data(), []); - }); - - it('concat complex input axis=0', async () => { - // [[1+1j, 2+2j], [3+3j, 4+4j]] - const c1 = tf.complex([[1, 2], [3, 4]], [[1, 2], [3, 4]]); - // [[5+5j, 6+6j], [7+7j, 8+8j]] - const c2 = tf.complex([[5, 6], [7, 8]], [[5, 6], [7, 8]]); - - const axis = 0; - const result = tf.concat([c1, c2], axis); - const expected = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8]; - expect(result.dtype).toEqual('complex64'); - expectArraysClose(await result.data(), expected); - }); - - it('concat complex input axis=1', async () => { - // [[1+1j, 2+2j], [3+3j, 4+4j]] - const c1 = tf.complex([[1, 2], [3, 4]], [[1, 2], [3, 4]]); - // [[5+5j, 6+6j], [7+7j, 8+8j]] - const c2 = tf.complex([[5, 6], [7, 8]], [[5, 6], [7, 8]]); - - const axis = 1; - const result = tf.concat([c1, c2], axis); - const expected = [1, 1, 2, 2, 5, 5, 6, 6, 3, 3, 4, 4, 7, 7, 8, 8]; - expect(result.dtype).toEqual('complex64'); - expectArraysClose(await result.data(), expected); - }); -}); - -describeWithFlags('concat3d', ALL_ENVS, () => { - beforeAll(() => { - jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000000; - }); - - it('shapes correct concat axis=-1', async () => { - const tensor1 = tf.tensor3d([1, 2, 3], [1, 1, 3]); - const tensor2 = tf.tensor3d([4, 5, 6], [1, 1, 3]); - const values = tf.concat3d([tensor1, tensor2], -1); - expect(values.shape).toEqual([1, 1, 6]); - expectArraysClose(await values.data(), [1, 2, 3, 4, 5, 6]); - }); - - it('shapes correct concat axis=0', async () => { - const tensor1 = tf.tensor3d([1, 2, 3], [1, 1, 3]); - const tensor2 = tf.tensor3d([4, 5, 6], [1, 1, 3]); - const values = tf.concat3d([tensor1, tensor2], 0); - expect(values.shape).toEqual([2, 1, 3]); - expectArraysClose(await values.data(), [1, 2, 3, 4, 5, 6]); - }); - - it('concat axis=0', async () => { - const tensor1 = tf.tensor3d([1, 11, 111, 2, 22, 222], [1, 2, 3]); - const tensor2 = tf.tensor3d( - [5, 55, 555, 6, 66, 666, 7, 77, 777, 8, 88, 888], [2, 2, 3]); - const values = tf.concat3d([tensor1, tensor2], 0); - expect(values.shape).toEqual([3, 2, 3]); - expectArraysClose(await values.data(), [ - 1, 11, 111, 2, 22, 222, 5, 55, 555, 6, 66, 666, 7, 77, 777, 8, 88, 888 - ]); - }); - - it('TensorLike concat axis=0', async () => { - const tensor1 = [[[1, 11, 111], [2, 22, 222]]]; - const tensor2 = - [[[5, 55, 555], [6, 66, 666]], [[7, 77, 777], [8, 88, 888]]]; - const values = tf.concat3d([tensor1, tensor2], 0); - expect(values.shape).toEqual([3, 2, 3]); - expectArraysClose(await values.data(), [ - 1, 11, 111, 2, 22, 222, 5, 55, 555, 6, 66, 666, 7, 77, 777, 8, 88, 888 - ]); - }); - - it('Accepts string tensor.', async () => { - const tensor1 = tf.tensor3d(['one', 'two', 'three'], [1, 1, 3], 'string'); - const tensor2 = tf.tensor3d(['four', 'five', 'six'], [1, 1, 3], 'string'); - const values = tf.concat3d([tensor1, tensor2], 0); - expect(values.shape).toEqual([2, 1, 3]); - expectArraysClose( - await values.data(), ['one', 'two', 'three', 'four', 'five', 'six']); - }); - - it('TensorLike Chained concat axis=0', async () => { - const tensor1 = tf.tensor3d([1, 11, 111, 2, 22, 222], [1, 2, 3]); - const tensor2 = - [[[5, 55, 555], [6, 66, 666]], [[7, 77, 777], [8, 88, 888]]]; - const values = tensor1.concat([tensor2], 0); - expect(values.shape).toEqual([3, 2, 3]); - expectArraysClose(await values.data(), [ - 1, 11, 111, 2, 22, 222, 5, 55, 555, 6, 66, 666, 7, 77, 777, 8, 88, 888 - ]); - }); - - it('shapes correct concat axis=1', async () => { - const tensor1 = tf.tensor3d([1, 2, 3], [1, 1, 3]); - const tensor2 = tf.tensor3d([4, 5, 6], [1, 1, 3]); - const values = tf.concat3d([tensor1, tensor2], 1); - expect(values.shape).toEqual([1, 2, 3]); - expectArraysClose(await values.data(), [1, 2, 3, 4, 5, 6]); - }); - - it('concat axis=1', async () => { - const tensor1 = tf.tensor3d([1, 11, 111, 3, 33, 333], [2, 1, 3]); - const tensor2 = tf.tensor3d( - [5, 55, 555, 6, 66, 666, 7, 77, 777, 8, 88, 888], [2, 2, 3]); - const values = tf.concat3d([tensor1, tensor2], 1); - expect(values.shape).toEqual([2, 3, 3]); - expectArraysClose(await values.data(), [ - 1, 11, 111, 5, 55, 555, 6, 66, 666, 3, 33, 333, 7, 77, 777, 8, 88, 888 - ]); - }); - - it('shapes correct concat axis=2', async () => { - const tensor1 = tf.tensor3d([1, 2, 3], [1, 1, 3]); - const tensor2 = tf.tensor3d([4, 5, 6], [1, 1, 3]); - const values = tf.concat3d([tensor1, tensor2], 2); - expect(values.shape).toEqual([1, 1, 6]); - expectArraysClose(await values.data(), [1, 2, 3, 4, 5, 6]); - }); - - it('concat a large number of tensors, axis=0', async () => { - const tensors = []; - const expected = []; - for (let i = 0; i < 100; i++) { - tensors.push(tf.tensor([i], [1])); - expected.push(i); - } - const axis = 0; - const res = tf.concat(tensors, axis); - expect(res.shape).toEqual([100]); - expect(res.dtype).toBe('float32'); - expectArraysClose(await res.data(), expected); - }); - - it('concat a large number of tensors, axis=1', async () => { - const tensors = []; - const expected = []; - for (let i = 0; i < 100; i++) { - tensors.push(tf.tensor([i], [1, 1])); - expected.push(i); - } - const axis = 1; - const res = tf.concat(tensors, axis); - expect(res.shape).toEqual([1, 100]); - expect(res.dtype).toBe('float32'); - expectArraysClose(await res.data(), expected); - }); - - it('concat axis=2', async () => { - const tensor1 = tf.tensor3d([1, 11, 2, 22, 3, 33, 4, 44], [2, 2, 2]); - const tensor2 = tf.tensor3d( - [5, 55, 555, 6, 66, 666, 7, 77, 777, 8, 88, 888], [2, 2, 3]); - const values = tf.concat3d([tensor1, tensor2], 2); - expect(values.shape).toEqual([2, 2, 5]); - expectArraysClose(await values.data(), [ - 1, 11, 5, 55, 555, 2, 22, 6, 66, 666, - 3, 33, 7, 77, 777, 4, 44, 8, 88, 888 - ]); - }); - - it('concat throws when invalid non-axis shapes, axis=0', () => { - const axis = 0; - const x1 = tf.tensor3d([1, 11, 111], [1, 1, 3]); - const x2 = tf.tensor3d( - [5, 55, 555, 6, 66, 666, 7, 77, 777, 8, 88, 888], [2, 2, 3]); - expect(() => tf.concat3d([x1, x2], axis)).toThrowError(); - }); - - it('concat throws when invalid non-axis shapes, axis=1', () => { - const axis = 1; - const x1 = tf.tensor3d([1, 11, 111], [1, 1, 3]); - const x2 = tf.tensor3d( - [5, 55, 555, 6, 66, 666, 7, 77, 777, 8, 88, 888], [2, 2, 3]); - expect(() => tf.concat3d([x1, x2], axis)).toThrowError(); - }); - - it('concat throws when invalid non-axis shapes and zero size, axis=1', () => { - const axis = 1; - const x1 = tf.tensor3d([1, 11, 111], [1, 1, 3]); - const x2 = tf.tensor3d([], [1, 0, 4]); - expect(() => tf.concat3d([x1, x2], axis)).toThrowError(); - }); - - it('concat throws when invalid non-axis shapes, axis=2', () => { - const axis = 2; - const x1 = tf.tensor3d([1, 11, 2, 22], [1, 2, 2]); - const x2 = tf.tensor3d( - [5, 55, 555, 6, 66, 666, 7, 77, 777, 8, 88, 888], [2, 2, 3]); - expect(() => tf.concat3d([x1, x2], axis)).toThrowError(); - }); - - it('gradient concat axis=0', async () => { - const x1 = tf.tensor3d([1, 11, 2, 22], [1, 2, 2]); - const x2 = tf.tensor3d([5, 55, 6, 66, 7, 77, 8, 88], [2, 2, 2]); - const dy = - tf.tensor3d([66, 6, 55, 5, 44, 4, 33, 3, 22, 2, 11, 1], [3, 2, 2]); - const axis = 0; - - const grads = tf.grads( - (x1: tf.Tensor3D, x2: tf.Tensor3D) => tf.concat3d([x1, x2], axis)); - const [dx1, dx2] = grads([x1, x2], dy); - - expect(dx1.shape).toEqual(x1.shape); - expectArraysClose(await dx1.data(), [66, 6, 55, 5]); - - expect(dx2.shape).toEqual(x2.shape); - expectArraysClose(await dx2.data(), [44, 4, 33, 3, 22, 2, 11, 1]); - }); - - it('gradient with clones', async () => { - const x1 = tf.tensor3d([1, 11, 2, 22], [1, 2, 2]); - const x2 = tf.tensor3d([5, 55, 6, 66, 7, 77, 8, 88], [2, 2, 2]); - const dy = - tf.tensor3d([66, 6, 55, 5, 44, 4, 33, 3, 22, 2, 11, 1], [3, 2, 2]); - const axis = 0; - - const grads = tf.grads( - (x1: tf.Tensor3D, x2: tf.Tensor3D) => - tf.concat3d([x1.clone(), x2.clone()], axis).clone()); - const [dx1, dx2] = grads([x1, x2], dy); - - expect(dx1.shape).toEqual(x1.shape); - expectArraysClose(await dx1.data(), [66, 6, 55, 5]); - - expect(dx2.shape).toEqual(x2.shape); - expectArraysClose(await dx2.data(), [44, 4, 33, 3, 22, 2, 11, 1]); - }); - - it('gradient concat axis=1', async () => { - const x1 = tf.tensor3d([1, 11, 2, 22], [2, 1, 2]); - const x2 = tf.tensor3d([3, 33, 4, 44, 5, 55, 6, 66], [2, 2, 2]); - const dy = - tf.tensor3d([66, 6, 55, 5, 44, 4, 33, 3, 22, 2, 11, 1], [2, 3, 2]); - const axis = 1; - - const grads = tf.grads( - (x1: tf.Tensor3D, x2: tf.Tensor3D) => tf.concat3d([x1, x2], axis)); - const [dx1, dx2] = grads([x1, x2], dy); - - expect(dx1.shape).toEqual(x1.shape); - expectArraysClose(await dx1.data(), [66, 6, 33, 3]); - - expect(dx2.shape).toEqual(x2.shape); - expectArraysClose(await dx2.data(), [55, 5, 44, 4, 22, 2, 11, 1]); - }); - - it('gradient concat axis=2', async () => { - const x1 = tf.tensor3d([1, 2, 3, 4], [2, 2, 1]); - const x2 = tf.tensor3d([5, 55, 6, 66, 7, 77, 8, 88], [2, 2, 2]); - const dy = tf.tensor3d( - [4, 40, 400, 3, 30, 300, 2, 20, 200, 1, 10, 100], [2, 2, 3]); - const axis = 2; - - const grads = tf.grads( - (x1: tf.Tensor3D, x2: tf.Tensor3D) => tf.concat3d([x1, x2], axis)); - const [dx1, dx2] = grads([x1, x2], dy); - - expect(dx1.shape).toEqual(x1.shape); - expectArraysClose(await dx1.data(), [4, 3, 2, 1]); - - expect(dx2.shape).toEqual(x2.shape); - expectArraysClose(await dx2.data(), [40, 400, 30, 300, 20, 200, 10, 100]); - }); - - it('gradient concat axis=-1', async () => { - const x1 = tf.tensor3d([1, 2, 3, 4], [2, 2, 1]); - const x2 = tf.tensor3d([5, 55, 6, 66, 7, 77, 8, 88], [2, 2, 2]); - const dy = tf.tensor3d( - [4, 40, 400, 3, 30, 300, 2, 20, 200, 1, 10, 100], [2, 2, 3]); - const axis = -1; - - const grads = tf.grads( - (x1: tf.Tensor3D, x2: tf.Tensor3D) => tf.concat3d([x1, x2], axis)); - const [dx1, dx2] = grads([x1, x2], dy); - - expect(dx1.shape).toEqual(x1.shape); - expectArraysClose(await dx1.data(), [4, 3, 2, 1]); - - expect(dx2.shape).toEqual(x2.shape); - expectArraysClose(await dx2.data(), [40, 400, 30, 300, 20, 200, 10, 100]); - }); - - it('accepts a tensor-like object', async () => { - const tensor1 = [[[1, 2, 3]]]; // 1x1x3 - const tensor2 = [[[4, 5, 6]]]; // 1x1x3 - const values = tf.concat3d([tensor1, tensor2], 0); - expect(values.shape).toEqual([2, 1, 3]); - expectArraysClose(await values.data(), [1, 2, 3, 4, 5, 6]); - }); - - it('concat tensors with 0 in their shape', async () => { - const tensor1 = tf.tensor3d([1, 2, 3, 4, 5, 6], [2, 3, 1]); - const tensor2 = tf.tensor3d([], [0, 3, 1]); - const values = tf.concat3d([tensor1, tensor2], 0); - expect(values.shape).toEqual([2, 3, 1]); - expectArraysClose(await values.data(), [1, 2, 3, 4, 5, 6]); - }); - - it('concat complex input axis=0', async () => { - // [[[1+1j, 2+2j], [3+3j, 4+4j], [5+5j, 6+6j]]] - const c1 = - tf.complex([[[1, 2], [3, 4], [5, 6]]], [[[1, 2], [3, 4], [5, 6]]]); - // [[[7+7j, 8+8j], [9+9j, 10+10j], [11+11j, 12+12j]]] - const c2 = tf.complex( - [[[7, 8], [9, 10], [11, 12]]], [[[7, 8], [9, 10], [11, 12]]]); - - const axis = 0; - const result = tf.concat([c1, c2], axis); - const expected = [ - 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, - 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12 - ]; - expect(result.dtype).toEqual('complex64'); - expectArraysClose(await result.data(), expected); - }); - - it('concat complex input axis=1', async () => { - // [[[1+1j, 2+2j], [3+3j, 4+4j], [5+5j, 6+6j]]] - const c1 = - tf.complex([[[1, 2], [3, 4], [5, 6]]], [[[1, 2], [3, 4], [5, 6]]]); - // [[[7+7j, 8+8j], [9+9j, 10+10j], [11+11j, 12+12j]]] - const c2 = tf.complex( - [[[7, 8], [9, 10], [11, 12]]], [[[7, 8], [9, 10], [11, 12]]]); - - const axis = 1; - const result = tf.concat([c1, c2], axis); - const expected = [ - 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, - 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12 - ]; - expect(result.dtype).toEqual('complex64'); - expectArraysClose(await result.data(), expected); - }); - - it('concat complex input axis=1', async () => { - // [[[1+1j, 2+2j], [3+3j, 4+4j], [5+5j, 6+6j]]] - const c1 = - tf.complex([[[1, 2], [3, 4], [5, 6]]], [[[1, 2], [3, 4], [5, 6]]]); - // [[[7+7j, 8+8j], [9+9j, 10+10j], [11+11j, 12+12j]]] - const c2 = tf.complex( - [[[7, 8], [9, 10], [11, 12]]], [[[7, 8], [9, 10], [11, 12]]]); - - const axis = 2; - const result = tf.concat([c1, c2], axis); - const expected = [ - 1, 1, 2, 2, 7, 7, 8, 8, 3, 3, 4, 4, - 9, 9, 10, 10, 5, 5, 6, 6, 11, 11, 12, 12 - ]; - expect(result.dtype).toEqual('complex64'); - expectArraysClose(await result.data(), expected); - }); -}); - -describeWithFlags('concat throws for non-tensors', ALL_ENVS, () => { - it('throws when passed a non-tensor', () => { - expect(() => tf.concat([{} as tf.Tensor1D])) - .toThrowError( - /Argument 'tensors\[0\]' passed to 'concat' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const tensor1 = [[[1, 2, 3, 4]]]; // 1x1x4 - const tensor2 = [[[4, 5, 6, 7]]]; // 1x1x4 - const values = tf.concat([tensor1, tensor2], 0); - expect(values.shape).toEqual([2, 1, 4]); - expectArraysClose(await values.data(), [1, 2, 3, 4, 4, 5, 6, 7]); - }); -}); - -describeWithFlags('memory test', ALL_ENVS, () => { - it('returns a new tensor when op is effectively a no-op.', async () => { - const a = tf.tensor1d([]); - const b = tf.tensor1d([3]); - - const result = tf.concat([a, b]); - - a.dispose(); - b.dispose(); - - expectArraysClose(await result.data(), [3]); - }); - - it('ensure no memory leak', async () => { - const numTensorsBefore = tf.memory().numTensors; - const numDataIdBefore = tf.engine().backend.numDataIds(); - - const a = tf.tensor1d([]); - const b = tf.tensor1d([3]); - - const result = tf.concat([a, b]); - - a.dispose(); - b.dispose(); - result.dispose(); - - const numTensorsAfter = tf.memory().numTensors; - const numDataIdAfter = tf.engine().backend.numDataIds(); - expect(numTensorsAfter).toBe(numTensorsBefore); - expect(numDataIdAfter).toBe(numDataIdBefore); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/concat_util.ts b/tfjs-master/tfjs-core/src/ops/concat_util.ts deleted file mode 100644 index 608b585d2..000000000 --- a/tfjs-master/tfjs-core/src/ops/concat_util.ts +++ /dev/null @@ -1,52 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as util from '../util'; - -export function assertParamsConsistent(shapes: number[][], axis: number) { - const rank = shapes[0].length; - shapes.forEach((shape, i) => { - util.assert( - shape.length === rank, - () => - `Error in concat${rank}D: rank of tensors[${i}] must be the same ` + - `as the rank of the rest (${rank})`); - }); - - util.assert( - axis >= 0 && axis < rank, - () => `Error in concat${rank}D: axis must be between 0 and ${rank - 1}.`); - - const firstShape = shapes[0]; - shapes.forEach((shape, i) => { - for (let r = 0; r < rank; r++) { - util.assert( - (r === axis) || (shape[r] === firstShape[r]), - () => `Error in concat${rank}D: Shape of tensors[${i}] (${shape}) ` + - `does not match the shape of the rest (${firstShape}) ` + - `along the non-concatenated axis ${i}.`); - } - }); -} - -export function computeOutShape(shapes: number[][], axis: number): number[] { - const outputShape = shapes[0].slice(); - for (let i = 1; i < shapes.length; i++) { - outputShape[axis] += shapes[i][axis]; - } - return outputShape; -} diff --git a/tfjs-master/tfjs-core/src/ops/concat_util_test.ts b/tfjs-master/tfjs-core/src/ops/concat_util_test.ts deleted file mode 100644 index 2823c47fb..000000000 --- a/tfjs-master/tfjs-core/src/ops/concat_util_test.ts +++ /dev/null @@ -1,82 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as concat_util from './concat_util'; - -describe('concat_util.assertConcatShapesMatch rank=3D', () => { - it('Non-3D tensor x1', () => { - const assertFn = () => { - concat_util.assertParamsConsistent([[1], [1, 2, 3]], 1); - }; - - expect(assertFn).toThrow(); - }); - - it('Non-3D tensor x2', () => { - const assertFn = () => { - concat_util.assertParamsConsistent([[1, 2, 3], [2, 3]], 1); - }; - - expect(assertFn).toThrow(); - }); - - it('axis out of bound', () => { - const assertFn = () => { - concat_util.assertParamsConsistent([[1, 2, 3], [1, 2, 3]], 4); - }; - - expect(assertFn).toThrow(); - }); - - it('non-axis shape mismatch', () => { - const assertFn = () => { - concat_util.assertParamsConsistent([[2, 3, 3], [2, 2, 4]], 2); - }; - - expect(assertFn).toThrow(); - }); - - it('shapes line up', () => { - const assertFn = () => { - concat_util.assertParamsConsistent([[2, 3, 3], [2, 3, 4]], 2); - }; - - expect(assertFn).not.toThrow(); - }); - - it('3 shapes, all line up', () => { - const assertFn = () => { - concat_util.assertParamsConsistent([[2, 3, 3], [2, 3, 4], [2, 3, 8]], 2); - }; - expect(assertFn).not.toThrow(); - }); - - it('3 shapes, 3rd shape does not line up', () => { - const assertFn = () => { - concat_util.assertParamsConsistent([[2, 5, 3], [2, 1, 3], [2, 1, 5]], 1); - }; - expect(assertFn).toThrow(); - }); -}); - -describe('concat_util.computeConcatOutputShape', () => { - it('compute output shape, axis=0', () => { - expect(concat_util.computeOutShape([[2, 2, 3], [1, 2, 3]], 0)).toEqual([ - 3, 2, 3 - ]); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/confusion_matrix.ts b/tfjs-master/tfjs-core/src/ops/confusion_matrix.ts deleted file mode 100644 index b4625987d..000000000 --- a/tfjs-master/tfjs-core/src/ops/confusion_matrix.ts +++ /dev/null @@ -1,96 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Tensor1D, Tensor2D} from '../tensor'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; -import * as util from '../util'; - -import {cast} from './cast'; -import {matMul} from './mat_mul'; -import {oneHot} from './one_hot'; -import {op} from './operation'; -import {transpose} from './transpose'; - -/** - * Computes the confusion matrix from true labels and predicted labels. - * - * ```js - * const labels = tf.tensor1d([0, 1, 2, 1, 0], 'int32'); - * const predictions = tf.tensor1d([0, 2, 2, 1, 0], 'int32'); - * const numClasses = 3; - * const out = tf.math.confusionMatrix(labels, predictions, numClasses); - * out.print(); - * // Expected output matrix: - * // [[2, 0, 0], - * // [0, 1, 1], - * // [0, 0, 1]] - * ``` - * - * @param labels The target labels, assumed to be 0-based integers - * for the classes. The shape is `[numExamples]`, where - * `numExamples` is the number of examples included. - * @param predictions The predicted classes, assumed to be - * 0-based integers for the classes. Must have the same shape as `labels`. - * @param numClasses Number of all classes, as an integer. - * Its value must be larger than the largest element in `labels` and - * `predictions`. - * @returns The confusion matrix as a int32-type 2D tensor. The value at - * row `r` and column `c` is the number of times examples of actual class - * `r` were predicted as class `c`. - * - * @doc {heading: 'Operations', subheading: 'Evaluation'} - */ -export function confusionMatrix_( - labels: Tensor1D|TensorLike, predictions: Tensor1D|TensorLike, - numClasses: number): Tensor2D { - const $labels = convertToTensor(labels, 'labels', 'confusionMatrix'); - const $predictions = - convertToTensor(predictions, 'predictions', 'confusionMatrix'); - - util.assert( - numClasses == null || numClasses > 0 && Number.isInteger(numClasses), - () => `If provided, numClasses must be a positive integer, ` + - `but got ${numClasses}`); - util.assert( - $labels.rank === 1, - () => `Expected the rank of labels to be 1, but got ${$labels.rank}`); - util.assert( - $predictions.rank === 1, - () => `Expected the rank of predictions to be 1, ` + - `but got ${$predictions.rank}`); - util.assert( - $labels.shape[0] === $predictions.shape[0], - () => `Mismatch in the number of examples: ` + - `${$labels.shape[0]} vs. ${$predictions.shape[0]}. ` + - `Labels and predictions should have the same number of elements.`); - util.assert( - numClasses > 0 && Number.isInteger(numClasses), - () => `numClasses is required to be a positive integer, but got ` + - `${numClasses}`); - // TODO(cais): In the future, if oneHot supports tensors inputs for - // `numClasses`, `confusionMatrix` can make `numClasses` optional. - - const oneHotLabels = oneHot(cast($labels, 'int32'), numClasses) as Tensor2D; - const oneHotPredictions = - oneHot(cast($predictions, 'int32'), numClasses) as Tensor2D; - const oneHotLabelsT: Tensor2D = transpose(oneHotLabels); - const product: Tensor2D = matMul(oneHotLabelsT, oneHotPredictions); - return cast(product, 'int32'); -} - -export const confusionMatrix = /* @__PURE__ */ op({confusionMatrix_}); diff --git a/tfjs-master/tfjs-core/src/ops/confusion_matrix_test.ts b/tfjs-master/tfjs-core/src/ops/confusion_matrix_test.ts deleted file mode 100644 index fa0f24e34..000000000 --- a/tfjs-master/tfjs-core/src/ops/confusion_matrix_test.ts +++ /dev/null @@ -1,174 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysEqual} from '../test_util'; - -/** - * Unit tests for confusionMatrix(). - */ - -describeWithFlags('confusionMatrix', ALL_ENVS, () => { - // Reference (Python) TensorFlow code: - // - // ```py - // import tensorflow as tf - // - // tf.enable_eager_execution() - // - // labels = tf.constant([0, 1, 2, 1, 0]) - // predictions = tf.constant([0, 2, 2, 1, 0]) - // out = tf.confusion_matrix(labels, predictions, 3) - // - // print(out) - // ``` - it('3x3 all cases present in both labels and predictions', async () => { - const labels = tf.tensor1d([0, 1, 2, 1, 0], 'int32'); - const predictions = tf.tensor1d([0, 2, 2, 1, 0], 'int32'); - const numClasses = 3; - const out = tf.math.confusionMatrix(labels, predictions, numClasses); - expectArraysEqual(await out.data(), [2, 0, 0, 0, 1, 1, 0, 0, 1]); - expect(out.dtype).toBe('int32'); - expect(out.shape).toEqual([3, 3]); - }); - - it('float32 arguments are accepted', async () => { - const labels = tf.tensor1d([0, 1, 2, 1, 0], 'float32'); - const predictions = tf.tensor1d([0, 2, 2, 1, 0], 'float32'); - const numClasses = 3; - const out = tf.math.confusionMatrix(labels, predictions, numClasses); - expectArraysEqual(await out.data(), [2, 0, 0, 0, 1, 1, 0, 0, 1]); - expect(out.dtype).toBe('int32'); - expect(out.shape).toEqual([3, 3]); - }); - - // Reference (Python) TensorFlow code: - // - // ```py - // import tensorflow as tf - // - // tf.enable_eager_execution() - // - // labels = tf.constant([3, 3, 2, 2, 1, 1, 0, 0]) - // predictions = tf.constant([2, 2, 2, 2, 0, 0, 0, 0]) - // out = tf.confusion_matrix(labels, predictions, 4) - // - // print(out) - // ``` - it('4x4 all cases present in labels, but not predictions', async () => { - const labels = tf.tensor1d([3, 3, 2, 2, 1, 1, 0, 0], 'int32'); - const predictions = tf.tensor1d([2, 2, 2, 2, 0, 0, 0, 0], 'int32'); - const numClasses = 4; - const out = tf.math.confusionMatrix(labels, predictions, numClasses); - expectArraysEqual( - await out.data(), [2, 0, 0, 0, 2, 0, 0, 0, 0, 0, 2, 0, 0, 0, 2, 0]); - expect(out.dtype).toBe('int32'); - expect(out.shape).toEqual([4, 4]); - }); - - it('4x4 all cases present in predictions, but not labels', async () => { - const labels = tf.tensor1d([2, 2, 2, 2, 0, 0, 0, 0], 'int32'); - const predictions = tf.tensor1d([3, 3, 2, 2, 1, 1, 0, 0], 'int32'); - const numClasses = 4; - const out = tf.math.confusionMatrix(labels, predictions, numClasses); - expectArraysEqual( - await out.data(), [2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0]); - expect(out.dtype).toBe('int32'); - expect(out.shape).toEqual([4, 4]); - }); - - it('Plain arrays as inputs', async () => { - const labels: number[] = [3, 3, 2, 2, 1, 1, 0, 0]; - const predictions: number[] = [2, 2, 2, 2, 0, 0, 0, 0]; - const numClasses = 4; - const out = tf.math.confusionMatrix(labels, predictions, numClasses); - expectArraysEqual( - await out.data(), [2, 0, 0, 0, 2, 0, 0, 0, 0, 0, 2, 0, 0, 0, 2, 0]); - expect(out.dtype).toBe('int32'); - expect(out.shape).toEqual([4, 4]); - }); - - it('Int32Arrays as inputs', async () => { - const labels = new Int32Array([3, 3, 2, 2, 1, 1, 0, 0]); - const predictions = new Int32Array([2, 2, 2, 2, 0, 0, 0, 0]); - const numClasses = 4; - const out = tf.math.confusionMatrix(labels, predictions, numClasses); - expectArraysEqual( - await out.data(), [2, 0, 0, 0, 2, 0, 0, 0, 0, 0, 2, 0, 0, 0, 2, 0]); - expect(out.dtype).toBe('int32'); - expect(out.shape).toEqual([4, 4]); - }); - - // Reference (Python) TensorFlow code: - // - // ```py - // import tensorflow as tf - // - // tf.enable_eager_execution() - // - // labels = tf.constant([0, 4]) - // predictions = tf.constant([4, 0]) - // out = tf.confusion_matrix(labels, predictions, 5) - // - // print(out) - // ``` - it('5x5 predictions and labels both missing some cases', async () => { - const labels = tf.tensor1d([0, 4], 'int32'); - const predictions = tf.tensor1d([4, 0], 'int32'); - const numClasses = 5; - const out = tf.math.confusionMatrix(labels, predictions, numClasses); - expectArraysEqual(await out.data(), [ - 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 - ]); - expect(out.dtype).toBe('int32'); - expect(out.shape).toEqual([5, 5]); - }); - - it('Invalid numClasses leads to Error', () => { - expect( - () => tf.math.confusionMatrix( - tf.tensor1d([0, 1]), tf.tensor1d([1, 0]), 2.5)) - .toThrowError(/numClasses .* positive integer.* got 2\.5/); - }); - - it('Incorrect tensor rank leads to Error', () => { - expect( - () => tf.math.confusionMatrix( - // tslint:disable-next-line:no-any - tf.scalar(0) as any, tf.scalar(0) as any, 1)) - .toThrowError(/rank .* 1.*got 0/); - expect( - () => - // tslint:disable-next-line:no-any - tf.math.confusionMatrix(tf.zeros([3, 3]) as any, tf.zeros([9]), 2)) - .toThrowError(/rank .* 1.*got 2/); - expect( - () => - // tslint:disable-next-line:no-any - tf.math.confusionMatrix(tf.zeros([9]), tf.zeros([3, 3]) as any, 2)) - .toThrowError(/rank .* 1.*got 2/); - }); - - it('Mismatch in lengths leads to Error', () => { - expect( - // tslint:disable-next-line:no-any - () => tf.math.confusionMatrix(tf.zeros([3]) as any, tf.zeros([9]), 2)) - .toThrowError(/Mismatch .* 3 vs.* 9/); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/conv1d.ts b/tfjs-master/tfjs-core/src/ops/conv1d.ts deleted file mode 100644 index 90ca41ae1..000000000 --- a/tfjs-master/tfjs-core/src/ops/conv1d.ts +++ /dev/null @@ -1,116 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {Tensor2D, Tensor3D, Tensor4D} from '../tensor'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; -import * as util from '../util'; - -import {conv2d} from './conv2d'; -import * as conv_util from './conv_util'; -import {op} from './operation'; -import {reshape} from './reshape'; - -/** - * Computes a 1D convolution over the input x. - * - * @param x The input tensor, of rank 3 or rank 2, of shape - * `[batch, width, inChannels]`. If rank 2, batch of 1 is assumed. - * @param filter The filter, rank 3, of shape - * `[filterWidth, inDepth, outDepth]`. - * @param stride The number of entries by which the filter is moved right at - * each step. - * @param pad The type of padding algorithm. - * - `same` and stride 1: output will be of same size as input, - * regardless of filter size. - * - `valid`: output will be smaller than input if filter is larger - * than 1x1. - * - For more info, see this guide: - * [https://www.tensorflow.org/api_docs/python/tf/nn/convolution]( - * https://www.tensorflow.org/api_docs/python/tf/nn/convolution) - * @param dataFormat An optional string from "NWC", "NCW". Defaults to "NWC", - * the data is stored in the order of [batch, in_width, in_channels]. Only - * "NWC" is currently supported. - * @param dilation The dilation rate in which we sample input values in - * atrous convolution. Defaults to `1`. If it is greater than 1, then - * stride must be `1`. - * @param dimRoundingMode A string from: 'ceil', 'round', 'floor'. If none is - * provided, it will default to truncate. - * - * @doc {heading: 'Operations', subheading: 'Convolution'} - */ -function conv1d_( - x: T|TensorLike, filter: Tensor3D|TensorLike, stride: number, - pad: 'valid'|'same'|number|conv_util.ExplicitPadding, - dataFormat: 'NWC'|'NCW' = 'NWC', dilation = 1, - dimRoundingMode?: 'floor'|'round'|'ceil'): T { - const $x = convertToTensor(x, 'x', 'conv1d'); - const $filter = convertToTensor(filter, 'filter', 'conv1d'); - - let x3D = $x as Tensor3D; - let reshapedTo3D = false; - if ($x.rank === 2) { - reshapedTo3D = true; - x3D = reshape($x, [1, $x.shape[0], $x.shape[1]]); - } - - util.assert( - x3D.rank === 3, - () => `Error in conv1d: input must be rank 3, but got rank ${x3D.rank}.`); - util.assert( - $filter.rank === 3, - () => `Error in conv1d: filter must be rank 3, but got rank ` + - `${$filter.rank}.`); - conv_util.checkPadOnDimRoundingMode('conv1d', pad, dimRoundingMode); - util.assert( - x3D.shape[2] === $filter.shape[1], - () => `Error in conv1d: depth of input (${x3D.shape[2]}) must match ` + - `input depth for filter ${$filter.shape[1]}.`); - util.assert( - conv_util.eitherStridesOrDilationsAreOne(stride, dilation), - () => 'Error in conv1D: Either stride or dilation must be 1. ' + - `Got stride ${stride} and dilation '${dilation}'`); - util.assert( - conv_util.stridesOrDilationsArePositive(dilation), - () => 'Error in conv1D: Dilated rates should be larger than 0.'); - util.assert( - conv_util.stridesOrDilationsArePositive(stride), - () => 'Error in conv1D: Stride should be larger than 0.'); - util.assert( - dataFormat === 'NWC', - () => `Error in conv1d: got dataFormat of ${ - dataFormat} but only NWC is currently supported.`); - - const filter4D = reshape( - $filter, [1, $filter.shape[0], $filter.shape[1], $filter.shape[2]]); - const input4D = reshape(x3D, [x3D.shape[0], 1, x3D.shape[1], x3D.shape[2]]); - const strides: [number, number] = [1, stride]; - const dilations: [number, number] = [1, dilation]; - - const conv2dDataFormat = 'NHWC'; - - const res = conv2d( - (input4D as Tensor4D), (filter4D as Tensor4D), strides, pad, - conv2dDataFormat, dilations, dimRoundingMode); - - if (reshapedTo3D) { - return reshape(res, [res.shape[2], res.shape[3]]) as T; - } - - return reshape(res, [res.shape[0], res.shape[2], res.shape[3]]) as T; -} - -export const conv1d = /* @__PURE__ */ op({conv1d_}); diff --git a/tfjs-master/tfjs-core/src/ops/conv1d_test.ts b/tfjs-master/tfjs-core/src/ops/conv1d_test.ts deleted file mode 100644 index d0205d792..000000000 --- a/tfjs-master/tfjs-core/src/ops/conv1d_test.ts +++ /dev/null @@ -1,462 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; -import {Rank} from '../types'; - -describeWithFlags('conv1d', ALL_ENVS, () => { - it('conv1d input=2x2x1,d2=1,f=1,s=1,d=1,p=explicit', async () => { - const inputDepth = 1; - const inputShape: [number, number, number] = [2, 2, inputDepth]; - const outputDepth = 1; - const fSize = 1; - const pad = - [[0, 0], [0, 0], [0, 0], [0, 0]] as tf.backend_util.ExplicitPadding; - const stride = 1; - const dataFormat = 'NWC'; - const dilation = 1; - - const x = tf.tensor3d([1, 2, 3, 4], inputShape); - const w = tf.tensor3d([3], [fSize, inputDepth, outputDepth]); - - const result = tf.conv1d(x, w, stride, pad, dataFormat, dilation); - - expect(result.shape).toEqual([2, 2, 1]); - expectArraysClose(await result.data(), [3, 6, 9, 12]); - }); - - it('conv1d input=2x2x1,d2=1,f=1,s=1,d=1,p=same', async () => { - const inputDepth = 1; - const inputShape: [number, number, number] = [2, 2, inputDepth]; - const outputDepth = 1; - const fSize = 1; - const pad = 'same'; - const stride = 1; - const dataFormat = 'NWC'; - const dilation = 1; - - const x = tf.tensor3d([1, 2, 3, 4], inputShape); - const w = tf.tensor3d([3], [fSize, inputDepth, outputDepth]); - - const result = tf.conv1d(x, w, stride, pad, dataFormat, dilation); - - expect(result.shape).toEqual([2, 2, 1]); - expectArraysClose(await result.data(), [3, 6, 9, 12]); - }); - - it('conv1d input=4x1,d2=1,f=2x1x1,s=1,d=1,p=valid', async () => { - const inputDepth = 1; - const inputShape: [number, number] = [4, inputDepth]; - const outputDepth = 1; - const fSize = 2; - const pad = 'valid'; - const stride = 1; - const dataFormat = 'NWC'; - const dilation = 1; - - const x = tf.tensor2d([1, 2, 3, 4], inputShape); - const w = tf.tensor3d([2, 1], [fSize, inputDepth, outputDepth]); - - const result = tf.conv1d(x, w, stride, pad, dataFormat, dilation); - - expect(result.shape).toEqual([3, 1]); - expectArraysClose(await result.data(), [4, 7, 10]); - }); - - it('conv1d input=4x1,d2=1,f=2x1x1,s=1,d=2,p=valid', async () => { - const inputDepth = 1; - const inputShape: [number, number] = [4, inputDepth]; - const outputDepth = 1; - const fSize = 2; - const fSizeDilated = 3; - const pad = 'valid'; - const stride = 1; - const dataFormat = 'NWC'; - const dilation = 2; - const dilationWEffective = 1; - - const x = tf.tensor2d([1, 2, 3, 4], inputShape); - const w = tf.tensor3d([2, 1], [fSize, inputDepth, outputDepth]); - // adding a dilation rate is equivalent to using a filter - // with 0s for the dilation rate - const wDilated = - tf.tensor3d([2, 0, 1], [fSizeDilated, inputDepth, outputDepth]); - - const result = tf.conv1d(x, w, stride, pad, dataFormat, dilation); - const expectedResult = - tf.conv1d(x, wDilated, stride, pad, dataFormat, dilationWEffective); - - expect(result.shape).toEqual(expectedResult.shape); - expectArraysClose(await result.data(), await expectedResult.data()); - }); - - it('conv1d input=14x1,d2=1,f=3x1x1,s=1,d=3,p=valid', async () => { - const inputDepth = 1; - const inputShape: [number, number] = [14, inputDepth]; - const outputDepth = 1; - const fSize = 3; - const fSizeDilated = 7; - const pad = 'valid'; - const stride = 1; - const dataFormat = 'NWC'; - const dilation = 3; - const dilationWEffective = 1; - - const x = tf.tensor2d( - [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14], inputShape); - const w = tf.tensor3d([3, 2, 1], [fSize, inputDepth, outputDepth]); - // adding a dilation rate is equivalent to using a filter - // with 0s for the dilation rate - const wDilated = tf.tensor3d( - [3, 0, 0, 2, 0, 0, 1], [fSizeDilated, inputDepth, outputDepth]); - - const result = tf.conv1d(x, w, stride, pad, dataFormat, dilation); - const expectedResult = - tf.conv1d(x, wDilated, stride, pad, dataFormat, dilationWEffective); - - expect(result.shape).toEqual(expectedResult.shape); - expectArraysClose(await result.data(), await expectedResult.data()); - }); - - it('throws when dimRoundingMode is set and pad is same', () => { - const inputDepth = 1; - const inputShape: [number, number, number] = [2, 2, inputDepth]; - const outputDepth = 1; - const fSize = 1; - const pad = 'same'; - const stride = 1; - const dataFormat = 'NWC'; - const dilation = 1; - const dimRoundingMode = 'round'; - - const x = tf.tensor3d([1, 2, 3, 4], inputShape); - const w = tf.tensor3d([3], [fSize, inputDepth, outputDepth]); - - expect( - () => - tf.conv1d(x, w, stride, pad, dataFormat, dilation, dimRoundingMode)) - .toThrowError(); - }); - - it('throws when dimRoundingMode is set and pad is valid', () => { - const inputDepth = 1; - const inputShape: [number, number, number] = [2, 2, inputDepth]; - const outputDepth = 1; - const fSize = 1; - const pad = 'valid'; - const stride = 1; - const dataFormat = 'NWC'; - const dilation = 1; - const dimRoundingMode = 'round'; - - const x = tf.tensor3d([1, 2, 3, 4], inputShape); - const w = tf.tensor3d([3], [fSize, inputDepth, outputDepth]); - - expect( - () => - tf.conv1d(x, w, stride, pad, dataFormat, dilation, dimRoundingMode)) - .toThrowError(); - }); - - it('throws when dimRoundingMode is set and pad is a non-integer number', - () => { - const inputDepth = 1; - const inputShape: [number, number, number] = [2, 2, inputDepth]; - const outputDepth = 1; - const fSize = 1; - const pad = 1.2; - const stride = 1; - const dataFormat = 'NWC'; - const dilation = 1; - const dimRoundingMode = 'round'; - - const x = tf.tensor3d([1, 2, 3, 4], inputShape); - const w = tf.tensor3d([3], [fSize, inputDepth, outputDepth]); - - expect( - () => tf.conv1d( - x, w, stride, pad, dataFormat, dilation, dimRoundingMode)) - .toThrowError(); - }); - - it('throws when dimRoundingMode is set and pad is explicit by non-integer ' + - 'number', - () => { - const inputDepth = 1; - const inputShape: [number, number, number] = [2, 2, inputDepth]; - const outputDepth = 1; - const fSize = 1; - const pad = [[0, 0], [0, 2.1], [1, 1], [0, 0]] as - tf.backend_util.ExplicitPadding; - const stride = 1; - const dataFormat = 'NWC'; - const dilation = 1; - const dimRoundingMode = 'round'; - - const x = tf.tensor3d([1, 2, 3, 4], inputShape); - const w = tf.tensor3d([3], [fSize, inputDepth, outputDepth]); - - expect( - () => tf.conv1d( - x, w, stride, pad, dataFormat, dilation, dimRoundingMode)) - .toThrowError(); - }); - - it('TensorLike', async () => { - const pad = 'same'; - const stride = 1; - const dataFormat = 'NWC'; - const dilation = 1; - - const x = [[[1], [2]], [[3], [4]]]; - const w = [[[3]]]; - - const result = tf.conv1d(x, w, stride, pad, dataFormat, dilation); - - expect(result.shape).toEqual([2, 2, 1]); - expectArraysClose(await result.data(), [3, 6, 9, 12]); - }); - it('TensorLike Chained', async () => { - const inputDepth = 1; - const inputShape: [number, number, number] = [2, 2, inputDepth]; - const pad = 'same'; - const stride = 1; - const dataFormat = 'NWC'; - const dilation = 1; - - const x = tf.tensor3d([1, 2, 3, 4], inputShape); - const w = [[[3]]]; - - const result = x.conv1d(w, stride, pad, dataFormat, dilation); - - expect(result.shape).toEqual([2, 2, 1]); - expectArraysClose(await result.data(), [3, 6, 9, 12]); - }); - - it('throws when x is not rank 3', () => { - const inputDepth = 1; - const outputDepth = 1; - const fSize = 2; - const pad = 0; - const stride = 1; - const dataFormat = 'NWC'; - const dilation = 1; - - // tslint:disable-next-line:no-any - const x: any = tf.tensor2d([1, 2, 3, 4], [2, 2]); - const w = tf.tensor3d([3, 1], [fSize, inputDepth, outputDepth]); - - expect(() => tf.conv1d(x, w, stride, pad, dataFormat, dilation)) - .toThrowError(); - }); - - it('throws when weights is not rank 3', () => { - const inputDepth = 1; - const inputShape: [number, number, number] = [2, 2, inputDepth]; - const pad = 0; - const stride = 1; - const dataFormat = 'NWC'; - const dilation = 1; - - const x = tf.tensor3d([1, 2, 3, 4], inputShape); - // tslint:disable-next-line:no-any - const w: any = tf.tensor4d([3, 1, 5, 0], [2, 2, 1, 1]); - - expect(() => tf.conv1d(x, w, stride, pad, dataFormat, dilation)) - .toThrowError(); - }); - - it('throws when x depth does not match weight depth', () => { - const inputDepth = 1; - const wrongInputDepth = 5; - const inputShape: [number, number, number] = [2, 2, inputDepth]; - const outputDepth = 1; - const fSize = 2; - const pad = 0; - const stride = 1; - const dataFormat = 'NWC'; - const dilation = 1; - - const x = tf.tensor3d([1, 2, 3, 4], inputShape); - const w = tf.randomNormal([fSize, wrongInputDepth, outputDepth]); - - expect(() => tf.conv1d(x, w, stride, pad, dataFormat, dilation)) - .toThrowError(); - }); - - it('throws when stride is less than or equal to 0', () => { - const inputDepth = 1; - const inputShape: [number, number, number] = [2, 2, inputDepth]; - const outputDepth = 1; - const fSize = 1; - const pad = - [[0, 0], [0, 0], [0, 0], [0, 0]] as tf.backend_util.ExplicitPadding; - const stride = 0; - const dataFormat = 'NWC'; - const dilation = 1; - - const x = tf.tensor3d([1, 2, 3, 4], inputShape); - const w = tf.tensor3d([3], [fSize, inputDepth, outputDepth]); - - expect(() => tf.conv1d(x, w, stride, pad, dataFormat, dilation)) - .toThrowError(); - }); - - it('throws when dilation is less than or equal to 0', () => { - const inputDepth = 1; - const inputShape: [number, number, number] = [2, 2, inputDepth]; - const outputDepth = 1; - const fSize = 1; - const pad = - [[0, 0], [0, 0], [0, 0], [0, 0]] as tf.backend_util.ExplicitPadding; - const stride = 1; - const dataFormat = 'NWC'; - const dilation = 0; - - const x = tf.tensor3d([1, 2, 3, 4], inputShape); - const w = tf.tensor3d([3], [fSize, inputDepth, outputDepth]); - - expect(() => tf.conv1d(x, w, stride, pad, dataFormat, dilation)) - .toThrowError(); - }); - - it('throws when both stride and dilation are greater than 1', () => { - const inputDepth = 1; - const inputShape: [number, number, number] = [2, 2, inputDepth]; - const outputDepth = 1; - const fSize = 1; - const pad = 'same'; - const stride = 2; - const dataFormat = 'NWC'; - const dilation = 2; - - const x = tf.tensor3d([1, 2, 3, 4], inputShape); - const w = tf.tensor3d([3], [fSize, inputDepth, outputDepth]); - - expect(() => tf.conv1d(x, w, stride, pad, dataFormat, dilation)) - .toThrowError(); - }); - - it('throws when passed x as a non-tensor', () => { - const inputDepth = 1; - const outputDepth = 1; - const fSize = 1; - const pad = 'same'; - const stride = 2; - const dataFormat = 'NWC'; - const dilation = 2; - - const w = tf.tensor3d([3], [fSize, inputDepth, outputDepth]); - - expect( - () => - tf.conv1d({} as tf.Tensor3D, w, stride, pad, dataFormat, dilation)) - .toThrowError(/Argument 'x' passed to 'conv1d' must be a Tensor/); - }); - - it('throws when passed filter as a non-tensor', () => { - const inputDepth = 1; - const inputShape: [number, number, number] = [2, 2, inputDepth]; - const pad = 'same'; - const stride = 2; - const dataFormat = 'NWC'; - const dilation = 2; - - const x = tf.tensor3d([1, 2, 3, 4], inputShape); - - expect( - () => - tf.conv1d(x, {} as tf.Tensor3D, stride, pad, dataFormat, dilation)) - .toThrowError(/Argument 'filter' passed to 'conv1d' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const pad = 'same'; - const stride = 1; - const dataFormat = 'NWC'; - const dilation = 1; - const x = [[[1], [2]], [[3], [4]]]; // 2x2x1 - const w = [[[3]]]; // 1x1x1 - - const result = tf.conv1d(x, w, stride, pad, dataFormat, dilation); - - expect(result.shape).toEqual([2, 2, 1]); - expectArraysClose(await result.data(), [3, 6, 9, 12]); - }); - - it('gradient with clones, input=2x2x1,d2=1,f=1,s=1,d=1,p=same', async () => { - const inputDepth = 1; - const inputShape: [number, number, number] = [2, 2, inputDepth]; - const outputDepth = 1; - const fSize = 1; - const filterShape: [number, number, number] = - [fSize, inputDepth, outputDepth]; - const pad = 'same'; - const stride = 1; - const dataFormat = 'NWC'; - const dilation = 1; - - const x = tf.tensor3d([1, 2, 3, 4], inputShape); - const w = tf.tensor3d([3], filterShape); - - const dy = tf.tensor3d([3, 2, 1, 0], inputShape); - - const grads = tf.grads( - (x: tf.Tensor3D, w: tf.Tensor3D) => - tf.conv1d(x.clone(), w.clone(), stride, pad, dataFormat, dilation) - .clone()); - const [dx, dw] = grads([x, w], dy); - - expect(dx.shape).toEqual(x.shape); - expectArraysClose(await dx.data(), [9, 6, 3, 0]); - - expect(dw.shape).toEqual(w.shape); - expectArraysClose(await dw.data(), [10]); - }); - - it('conv1d gradients input=14x1,d2=1,f=3x1x1,s=1,p=valid', async () => { - const inputDepth = 1; - const inputShape: [number, number] = [14, inputDepth]; - - const outputDepth = 1; - const fSize = 3; - const pad = 'valid'; - const stride = 1; - const dataFormat = 'NWC'; - - const x = tf.tensor2d( - [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14], inputShape); - const w = tf.tensor3d([3, 2, 1], [fSize, inputDepth, outputDepth]); - - const dy = - tf.tensor2d([3, 2, 1, 0, 3, 2, 1, 0, 3, 2, 1, 0], [12, inputDepth]); - - const grads = tf.grads( - (x: tf.Tensor2D, w: tf.Tensor3D) => - tf.conv1d(x, w, stride, pad, dataFormat)); - const [dx, dw] = grads([x, w], dy); - - expect(dx.shape).toEqual(x.shape); - expectArraysClose( - await dx.data(), [9, 12, 10, 4, 10, 12, 10, 4, 10, 12, 10, 4, 1, 0]); - - expect(dw.shape).toEqual(w.shape); - expectArraysClose(await dw.data(), [102, 120, 138]); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/conv2d.ts b/tfjs-master/tfjs-core/src/ops/conv2d.ts deleted file mode 100644 index 033d92648..000000000 --- a/tfjs-master/tfjs-core/src/ops/conv2d.ts +++ /dev/null @@ -1,119 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {ENGINE} from '../engine'; -import {Conv2D, Conv2DAttrs, Conv2DInputs} from '../kernel_names'; -import {NamedAttrMap} from '../kernel_registry'; -import {Tensor3D, Tensor4D} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; -import * as util from '../util'; - -import * as conv_util from './conv_util'; -import {op} from './operation'; -import {reshape} from './reshape'; - -/** - * Computes a 2D convolution over the input x. - * - * @param x The input tensor, of rank 4 or rank 3, of shape - * `[batch, height, width, inChannels]`. If rank 3, batch of 1 is - * assumed. - * @param filter The filter, rank 4, of shape - * `[filterHeight, filterWidth, inDepth, outDepth]`. - * @param strides The strides of the convolution: `[strideHeight, - * strideWidth]`. - * @param pad The type of padding algorithm. - * - `same` and stride 1: output will be of same size as input, - * regardless of filter size. - * - `valid`: output will be smaller than input if filter is larger - * than 1x1. - * - For more info, see this guide: - * [https://www.tensorflow.org/api_docs/python/tf/nn/convolution]( - * https://www.tensorflow.org/api_docs/python/tf/nn/convolution) - * @param dataFormat: An optional string from: "NHWC", "NCHW". Defaults to - * "NHWC". Specify the data format of the input and output data. With the - * default format "NHWC", the data is stored in the order of: [batch, - * height, width, channels]. - * @param dilations The dilation rates: `[dilationHeight, dilationWidth]` - * in which we sample input values across the height and width dimensions - * in atrous convolution. Defaults to `[1, 1]`. If `dilations` is a single - * number, then `dilationHeight == dilationWidth`. If it is greater than - * 1, then all values of `strides` must be 1. - * @param dimRoundingMode A string from: 'ceil', 'round', 'floor'. If none is - * provided, it will default to truncate. - * - * @doc {heading: 'Operations', subheading: 'Convolution'} - */ -function conv2d_( - x: T|TensorLike, filter: Tensor4D|TensorLike, - strides: [number, number]|number, - pad: 'valid'|'same'|number|conv_util.ExplicitPadding, - dataFormat: 'NHWC'|'NCHW' = 'NHWC', - dilations: [number, number]|number = [1, 1], - dimRoundingMode?: 'floor'|'round'|'ceil'): T { - const $x = convertToTensor(x, 'x', 'conv2d', 'float32'); - const $filter = convertToTensor(filter, 'filter', 'conv2d', 'float32'); - - let x4D = $x as Tensor4D; - let reshapedTo4D = false; - - if ($x.rank === 3) { - reshapedTo4D = true; - x4D = reshape($x, [1, $x.shape[0], $x.shape[1], $x.shape[2]]); - } - - util.assert( - x4D.rank === 4, - () => `Error in conv2d: input must be rank 4, but got rank ${x4D.rank}.`); - util.assert( - $filter.rank === 4, - () => `Error in conv2d: filter must be rank 4, but got rank ` + - `${$filter.rank}.`); - conv_util.checkPadOnDimRoundingMode('conv2d', pad, dimRoundingMode); - const inDepth = dataFormat === 'NHWC' ? x4D.shape[3] : x4D.shape[1]; - util.assert( - inDepth === $filter.shape[2], - () => `Error in conv2d: depth of input (${inDepth}) must match ` + - `input depth for filter ${$filter.shape[2]}.`); - util.assert( - conv_util.eitherStridesOrDilationsAreOne(strides, dilations), - () => 'Error in conv2D: Either strides or dilations must be 1. ' + - `Got strides ${strides} and dilations '${dilations}'`); - util.assert( - conv_util.stridesOrDilationsArePositive(dilations), - () => 'Error in conv2D: Dilated rates should be larger than 0.'); - util.assert( - conv_util.stridesOrDilationsArePositive(strides), - () => 'Error in conv2D: Strides should be larger than 0.'); - - const inputs: Conv2DInputs = {x: x4D, filter: $filter}; - const attrs: - Conv2DAttrs = {strides, pad, dataFormat, dilations, dimRoundingMode}; - - // tslint:disable-next-line: no-unnecessary-type-assertion - const res = ENGINE.runKernel( - Conv2D, inputs as unknown as NamedTensorMap, - attrs as unknown as NamedAttrMap) as T; - - if (reshapedTo4D) { - return reshape(res, [res.shape[1], res.shape[2], res.shape[3]]) as T; - } - return res; -} - -export const conv2d = /* @__PURE__ */ op({conv2d_}); diff --git a/tfjs-master/tfjs-core/src/ops/conv2d_backprop_filter.ts b/tfjs-master/tfjs-core/src/ops/conv2d_backprop_filter.ts deleted file mode 100644 index 353e3fe3c..000000000 --- a/tfjs-master/tfjs-core/src/ops/conv2d_backprop_filter.ts +++ /dev/null @@ -1,95 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {ENGINE} from '../engine'; -import {Conv2DBackpropFilter, Conv2DBackpropFilterAttrs, Conv2DBackpropFilterInputs} from '../kernel_names'; -import {NamedAttrMap} from '../kernel_registry'; -import {Tensor3D, Tensor4D} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import * as util from '../util'; - -import * as conv_util from './conv_util'; -import {op} from './operation'; -import {reshape} from './reshape'; - -/** - * Computes the derivative of the filter of a 2D convolution. - * - * @param x The input tensor, of rank 4 or rank 3 of shape - * [batch, height, width, inChannels]. If rank 3, batch of 1 is assumed. - * @param dy The dy image, of rank 4 or rank 3, of shape - * [batch, height, width, outDepth]. If rank 3, batch of 1 is assumed. - * @param filterShape The shape of the filter, length 4, - * [filterHeight, filterWidth, inDepth, outDepth]. - * @param strides The strides of the convolution: [strideHeight, - * strideWidth]. - * @param pad A string from: 'same', 'valid'. The type of padding algorithm - * used in the forward prop of the op. - * @param dataFormat: An optional string from: "NHWC", "NCHW". Defaults to - * "NHWC". Specify the data format of the input and output data. With the - * default format "NHWC", the data is stored in the order of: [batch, - * height, width, channels]. - * @param dimRoundingMode A string from: 'ceil', 'round', 'floor'. If none is - * provided, it will default to truncate. - */ -function conv2DBackpropFilter_( - x: T, dy: T, filterShape: [number, number, number, number], - strides: [number, number]|number, - pad: 'valid'|'same'|number|conv_util.ExplicitPadding, - dataFormat: 'NHWC'|'NCHW' = 'NHWC', - dimRoundingMode?: 'floor'|'round'|'ceil'): Tensor4D { - let x4D = x as Tensor4D; - if (x.rank === 3) { - x4D = reshape(x, [1, x.shape[0], x.shape[1], x.shape[2]]); - } - let dy4D = dy as Tensor4D; - if (dy4D.rank === 3) { - dy4D = reshape(dy, [1, dy.shape[0], dy.shape[1], dy.shape[2]]); - } - util.assert( - x4D.rank === 4, - () => `Error in conv2dDerFilter: input must be rank 4, but got shape ` + - `${x4D.shape}.`); - util.assert( - dy4D.rank === 4, - () => `Error in conv2dDerFilter: dy must be rank 4, but got shape ` + - `${dy4D.shape}.`); - util.assert( - filterShape.length === 4, - () => `Error in conv2dDerFilter: filterShape must be length 4, but got ` + - `${filterShape}.`); - const inDepth = dataFormat === 'NHWC' ? x4D.shape[3] : x4D.shape[1]; - const outDepth = dataFormat === 'NHWC' ? dy4D.shape[3] : dy4D.shape[1]; - util.assert( - inDepth === filterShape[2], - () => `Error in conv2dDerFilter: depth of input ${inDepth}) must ` + - `match input depth in filter (${filterShape[2]}.`); - util.assert( - outDepth === filterShape[3], - () => `Error in conv2dDerFilter: depth of dy (${outDepth}) must ` + - `match output depth for filter (${filterShape[3]}).`); - conv_util.checkPadOnDimRoundingMode('conv2dDerFilter', pad, dimRoundingMode); - const inputs: Conv2DBackpropFilterInputs = {x: x4D, dy: dy4D}; - const attrs: Conv2DBackpropFilterAttrs = - {strides, pad, dataFormat, dimRoundingMode, filterShape}; - - // tslint:disable-next-line: no-unnecessary-type-assertion - return ENGINE.runKernel( - Conv2DBackpropFilter, inputs as unknown as NamedTensorMap, - attrs as unknown as NamedAttrMap) as Tensor4D; -} - -export const conv2DBackpropFilter = /* @__PURE__ */ op({conv2DBackpropFilter_}); diff --git a/tfjs-master/tfjs-core/src/ops/conv2d_backprop_input.ts b/tfjs-master/tfjs-core/src/ops/conv2d_backprop_input.ts deleted file mode 100644 index aa92b52cb..000000000 --- a/tfjs-master/tfjs-core/src/ops/conv2d_backprop_input.ts +++ /dev/null @@ -1,111 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {ENGINE} from '../engine'; -import {Conv2DBackpropInput, Conv2DBackpropInputAttrs, Conv2DBackpropInputInputs} from '../kernel_names'; -import {NamedAttrMap} from '../kernel_registry'; -import {Tensor3D, Tensor4D} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import * as util from '../util'; - -import * as conv_util from './conv_util'; -import {op} from './operation'; -import {reshape} from './reshape'; - -/** - * Computes the derivative of the input of a 2D convolution. - * - * @param xShape The shape of the input: [batch, height, width, inDepth]. - * If length of 3, batch of 1 is assumed. - * @param dy The derivative of the output, of rank 4 or rank 3 of shape - * `[batch, outHeight, outWidth, outDepth]`. If rank 3, batch of 1 is - * assumed. - * @param filter The filter, rank 4, of shape - * `[filterHeight, filterWidth, inDepth, outDepth]`. - * @param strides The strides of the convolution: `[strideHeight, - * strideWidth]`. - * @param pad The type of padding algorithm used: - * - `same` and stride 1: output will be of same size as input, - * regardless of filter size. - * - `valid`: output will be smaller than input if filter is larger - * than 1x1. - * @param dataFormat: An optional string from: "NHWC", "NCHW". Defaults to - * "NHWC". Specify the data format of the input and output data. With the - * default format "NHWC", the data is stored in the order of: [batch, - * height, width, channels]. - * @param dimRoundingMode A string from: 'ceil', 'round', 'floor'. If none is - * provided, it will default to truncate. - */ -function conv2DBackpropInput_( - xShape: [number, number, number, number]|[number, number, number], dy: T, - filter: Tensor4D, strides: [number, number]|number, - pad: 'valid'|'same'|number|conv_util.ExplicitPadding, - dataFormat: 'NHWC'|'NCHW' = 'NHWC', - dimRoundingMode?: 'floor'|'round'|'ceil'): T { - util.assert( - xShape.length === dy.rank, - () => `Length of inShape ` + - `(${xShape.length}) and rank of dy (${dy.rank}) must match`); - - let xShape4D = xShape as [number, number, number, number]; - let dy4D = dy as Tensor4D; - let reshapedTo4D = false; - if (dy.rank === 3) { - reshapedTo4D = true; - dy4D = reshape(dy, [1, dy.shape[0], dy.shape[1], dy.shape[2]]); - xShape4D = [1, xShape[0], xShape[1], xShape[2]]; - } - - util.assert( - xShape4D.length === 4, - () => - `Error in conv2dDerInput: inShape must be length 4, but got length ` + - `${xShape4D.length}.`); - util.assert( - dy4D.rank === 4, - () => `Error in conv2dDerInput: dy must be rank 4, but got ` + - `rank ${dy4D.rank}`); - util.assert( - filter.rank === 4, - () => `Error in conv2dDerInput: filter must be rank 4, but got ` + - `rank ${filter.rank}`); - const inDepth = dataFormat === 'NHWC' ? xShape4D[3] : xShape4D[1]; - const outDepth = dataFormat === 'NHWC' ? dy4D.shape[3] : dy4D.shape[1]; - util.assert( - inDepth === filter.shape[2], - () => `Error in conv2dDerInput: depth of input (${inDepth}) must ` + - `match input depth for filter ${filter.shape[2]}.`); - util.assert( - outDepth === filter.shape[3], - () => `Error in conv2dDerInput: depth of output (${outDepth}) must ` + - `match output depth for filter ${filter.shape[3]}.`); - conv_util.checkPadOnDimRoundingMode('conv2dDerInput', pad, dimRoundingMode); - const inputs: Conv2DBackpropInputInputs = {dy: dy4D, filter}; - const attrs: Conv2DBackpropInputAttrs = - {strides, pad, dataFormat, dimRoundingMode, inputShape: xShape4D}; - - // tslint:disable-next-line: no-unnecessary-type-assertion - const res = ENGINE.runKernel( - Conv2DBackpropInput, inputs as unknown as NamedTensorMap, - attrs as unknown as NamedAttrMap) as T; - - if (reshapedTo4D) { - return reshape(res, [res.shape[1], res.shape[2], res.shape[3]]) as T; - } - return res; -} - -export const conv2DBackpropInput = /* @__PURE__ */ op({conv2DBackpropInput_}); diff --git a/tfjs-master/tfjs-core/src/ops/conv2d_separable_test.ts b/tfjs-master/tfjs-core/src/ops/conv2d_separable_test.ts deleted file mode 100644 index b3db2a41d..000000000 --- a/tfjs-master/tfjs-core/src/ops/conv2d_separable_test.ts +++ /dev/null @@ -1,526 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('separableConv2d', ALL_ENVS, () => { - it('input=1x3x3x1,f=2,s=1,d=1,p=valid,chMul=1,outDepth=2', async () => { - const fSize = 2; - const pad = 'valid'; - const stride = 1; - const chMul = 1; - const inDepth = 1; - const outDepth = 2; - - const x = tf.tensor4d( - [ - 0.230664, 0.987388, 0.0685208, 0.419224, 0.887861, 0.731641, - 0.0741907, 0.409265, 0.351377 - ], - [1, 3, 3, inDepth]); - const depthwiseFilter = tf.tensor4d( - [0.303873, 0.229223, 0.144333, 0.803373], - [fSize, fSize, inDepth, chMul], - ); - const pointwiseFilter = - tf.tensor4d([0.1, -0.2], [1, 1, inDepth * chMul, outDepth]); - - const result = - tf.separableConv2d(x, depthwiseFilter, pointwiseFilter, stride, pad); - - expectArraysClose(await result.data(), [ - 0.10702161, -0.21404321, 0.10316753, -0.20633507, 0.06704096, -0.13408193, - 0.07788632, -0.15577264 - ]); - expect(result.shape).toEqual([1, 2, 2, outDepth]); - }); - - it('input=1x3x3x1,f=2,s=1,d=1,p=valid,chMul=1,outDepth=2 in tensor', - async () => { - const fSize = 2; - const pad = 'valid'; - const stride = 1; - const chMul = 1; - const inDepth = 1; - const outDepth = 2; - - const x = tf.tensor4d( - [ - 0.230664, 0.987388, 0.0685208, 0.419224, 0.887861, 0.731641, - 0.0741907, 0.409265, 0.351377 - ], - [1, 3, 3, inDepth]); - const depthwiseFilter = tf.tensor4d( - [0.303873, 0.229223, 0.144333, 0.803373], - [fSize, fSize, inDepth, chMul], - ); - const pointwiseFilter = - tf.tensor4d([0.1, -0.2], [1, 1, inDepth * chMul, outDepth]); - - const result = - x.separableConv2d(depthwiseFilter, pointwiseFilter, stride, pad); - - expectArraysClose(await result.data(), [ - 0.10702161, -0.21404321, 0.10316753, -0.20633507, 0.06704096, - -0.13408193, 0.07788632, -0.15577264 - ]); - expect(result.shape).toEqual([1, 2, 2, outDepth]); - }); - - it('input=1x3x3x1,f=2,s=1,d=1,p=valid,chMul=2,outDepth=2', async () => { - const fSize = 2; - const pad = 'valid'; - const stride = 1; - const chMul = 2; - const inDepth = 1; - const outDepth = 3; - - const x = tf.tensor4d( - [ - 0.230664, 0.987388, 0.0685208, 0.419224, 0.887861, 0.731641, - 0.0741907, 0.409265, 0.351377 - ], - [1, 3, 3, inDepth]); - const depthwiseFilter = tf.tensor4d( - [ - 0.303873, 0.229223, 0.144333, 0.803373, -0.303873, -0.229223, - -0.144333, -0.803373 - ], - [fSize, fSize, inDepth, chMul], - ); - const pointwiseFilter = tf.tensor4d( - [0.1, -0.2, -0.1, 0.2, 0.15, 0.15], [1, 1, inDepth * chMul, outDepth]); - - const result = - tf.separableConv2d(x, depthwiseFilter, pointwiseFilter, stride, pad); - - expectArraysClose(await result.data(), [ - 0.00305368, 0.0140969, 0.00980358, -0.10853045, -0.06339455, -0.0699412, - 0.11010849, 0.0347524, 0.05214475, 0.10307151, 0.02221644, 0.04224815 - ]); - expect(result.shape).toEqual([1, 2, 2, outDepth]); - }); - - it('input=1x3x3x1,f=2,s=1,d=1,p=valid,chMul=1,outDepth=2,3D input', - async () => { - const fSize = 2; - const pad = 'valid'; - const stride = 1; - const chMul = 1; - const inDepth = 1; - const outDepth = 2; - - const x = tf.tensor3d( - [ - 0.230664, 0.987388, 0.0685208, 0.419224, 0.887861, 0.731641, - 0.0741907, 0.409265, 0.351377 - ], - [3, 3, inDepth]); - const depthwiseFilter = tf.tensor4d( - [0.303873, 0.229223, 0.144333, 0.803373], - [fSize, fSize, inDepth, chMul], - ); - const pointwiseFilter = - tf.tensor4d([0.1, -0.2], [1, 1, inDepth * chMul, outDepth]); - - const result = - tf.separableConv2d(x, depthwiseFilter, pointwiseFilter, stride, pad); - - expectArraysClose(await result.data(), [ - 0.10702161, -0.21404321, 0.10316753, -0.20633507, 0.06704096, - -0.13408193, 0.07788632, -0.15577264 - ]); - expect(result.shape).toEqual([2, 2, outDepth]); - }); - - it('input=1x4x4x1,f=2,s=2,d=1,p=valid,chMul=1,outDepth=2', async () => { - const fSize = 2; - const pad = 'valid'; - const stride: [number, number] = [2, 2]; - const chMul = 1; - const inDepth = 1; - const outDepth = 2; - - const x = tf.tensor4d( - [ - 0.675707, 0.758567, 0.413529, 0.963967, 0.217291, 0.101335, 0.804231, - 0.329673, 0.924503, 0.728742, 0.180217, 0.210459, 0.133869, 0.650827, - 0.047613, 0.554795 - ], - [1, 4, 4, inDepth]); - const depthwiseFilter = tf.tensor4d( - [0.303873, 0.229223, 0.144333, 0.803373], - [fSize, fSize, inDepth, chMul], - ); - const pointwiseFilter = - tf.tensor4d([0.1, -0.2], [1, 1, inDepth * chMul, outDepth]); - - const result = - tf.separableConv2d(x, depthwiseFilter, pointwiseFilter, stride, pad); - - expectArraysClose(await result.data(), [ - 0.04919822, -0.09839644, 0.07275512, -0.14551024, 0.09901544, -0.19803089, - 0.05555845, -0.11111691 - ]); - expect(result.shape).toEqual([1, 2, 2, outDepth]); - }); - - it('input=2x4x4x1,f=2,s=2,d=1,p=valid,chMul=1,outDepth=2', async () => { - const fSize = 2; - const pad = 'valid'; - const stride: [number, number] = [2, 2]; - const chMul = 1; - const inDepth = 1; - const outDepth = 2; - - const x = tf.tensor4d( - [ - 0.675707, 0.758567, 0.413529, 0.963967, 0.217291, 0.101335, - 0.804231, 0.329673, 0.924503, 0.728742, 0.180217, 0.210459, - 0.133869, 0.650827, 0.047613, 0.554795, -0.675707, -0.758567, - -0.413529, -0.963967, -0.217291, -0.101335, -0.804231, -0.329673, - -0.924503, -0.728742, -0.180217, -0.210459, -0.133869, -0.650827, - -0.047613, -0.554795 - ], - [2, 4, 4, inDepth]); - const depthwiseFilter = tf.tensor4d( - [0.303873, 0.229223, 0.144333, 0.803373], - [fSize, fSize, inDepth, chMul], - ); - const pointwiseFilter = - tf.tensor4d([0.1, -0.2], [1, 1, inDepth * chMul, outDepth]); - - const result = - tf.separableConv2d(x, depthwiseFilter, pointwiseFilter, stride, pad); - - expectArraysClose(await result.data(), [ - 0.04919822, -0.09839644, 0.07275512, -0.14551024, 0.09901544, -0.19803089, - 0.05555845, -0.11111691, -0.04919822, 0.09839644, -0.07275512, 0.14551024, - -0.09901544, 0.19803089, -0.05555845, 0.11111691 - ]); - expect(result.shape).toEqual([2, 2, 2, outDepth]); - }); - - it('input=1x4x4x2,f=2,s=2,d=1,p=valid,chMul=1,outDepth=2', async () => { - const fSize = 2; - const pad = 'valid'; - const stride: [number, number] = [2, 2]; - const chMul = 1; - const inDepth = 2; - const outDepth = 2; - - const x = tf.tensor4d( - [ - 0.675707, 0.758567, 0.413529, 0.963967, 0.217291, 0.101335, - 0.804231, 0.329673, 0.924503, 0.728742, 0.180217, 0.210459, - 0.133869, 0.650827, 0.047613, 0.554795, -0.675707, -0.758567, - -0.413529, -0.963967, -0.217291, -0.101335, -0.804231, -0.329673, - -0.924503, -0.728742, -0.180217, -0.210459, -0.133869, -0.650827, - -0.047613, -0.554795 - ], - [1, 4, 4, inDepth]); - const depthwiseFilter = tf.tensor4d( - [ - 0.303873, 0.229223, 0.144333, 0.803373, 0.98976838, 0.56597068, - 0.42654137, 0.66445535 - ], - [fSize, fSize, inDepth, chMul], - ); - const pointwiseFilter = tf.tensor4d( - [0.1, -0.2, 0.05, -0.05], [1, 1, inDepth * chMul, outDepth]); - - const result = - tf.separableConv2d(x, depthwiseFilter, pointwiseFilter, stride, pad); - - expectArraysClose(await result.data(), [ - 0.20072255, -0.32641545, 0.08474462, -0.11823604, -0.20072255, 0.32641545, - -0.08474462, 0.11823604 - ]); - expect(result.shape).toEqual([1, 2, 2, outDepth]); - }); - - it('input=1x4x4x1,f=2,s=1,d=2,p=valid,chMul=1,outDepth=2', async () => { - const fSize = 2; - const pad = 'valid'; - const stride = 1; - const chMul = 1; - const inDepth = 1; - const outDepth = 2; - const dilationRate = 2; - - const x = tf.tensor4d( - [ - 0.675707, 0.758567, 0.413529, 0.963967, 0.217291, 0.101335, 0.804231, - 0.329673, 0.924503, 0.728742, 0.180217, 0.210459, 0.133869, 0.650827, - 0.047613, 0.554795 - ], - [1, 4, 4, inDepth]); - const depthwiseFilter = tf.tensor4d( - [0.303873, 0.229223, 0.144333, 0.803373], - [fSize, fSize, inDepth, chMul], - ); - const pointwiseFilter = - tf.tensor4d([0.1, -0.2], [1, 1, inDepth * chMul, outDepth]); - - const result = tf.separableConv2d( - x, depthwiseFilter, pointwiseFilter, stride, pad, dilationRate); - - expectArraysClose(await result.data(), [ - 0.05783373, -0.11566745, 0.07257301, -0.14514601, 0.03079498, -0.06158997, - 0.06460048, -0.12920095 - ]); - expect(result.shape).toEqual([1, 2, 2, outDepth]); - }); - - it('input=1x4x4x1,f=2,s=1,d=1,p=same,chMul=1,outDepth=2', async () => { - const fSize = 2; - const pad = 'same'; - const stride = 1; - const chMul = 1; - const inDepth = 1; - const outDepth = 2; - - const x = tf.tensor4d( - [ - 0.675707, 0.758567, 0.413529, 0.963967, 0.217291, 0.101335, 0.804231, - 0.329673, 0.924503, 0.728742, 0.180217, 0.210459, 0.133869, 0.650827, - 0.047613, 0.554795 - ], - [1, 4, 4, inDepth]); - const depthwiseFilter = tf.tensor4d( - [0.303873, 0.229223, 0.144333, 0.803373], - [fSize, fSize, inDepth, chMul], - ); - const pointwiseFilter = - tf.tensor4d([0.1, -0.2], [1, 1, inDepth * chMul, outDepth]); - - const result = - tf.separableConv2d(x, depthwiseFilter, pointwiseFilter, stride, pad); - - expectArraysClose(await result.data(), [ - 0.04919822, -0.09839644, 0.09860218, -0.19720435, 0.07275512, -0.14551024, - 0.03405062, -0.06810125, 0.08081452, -0.16162904, 0.04651042, -0.09302084, - 0.05150411, -0.10300821, 0.01305549, -0.02611098, 0.09901544, -0.19803089, - 0.03949417, -0.07898834, 0.05555845, -0.11111691, 0.0144028, -0.02880561, - 0.01898637, -0.03797274, 0.02086828, -0.04173655, 0.01416401, -0.02832802, - 0.01685872, -0.03371745 - ]); - expect(result.shape).toEqual([1, 4, 4, outDepth]); - }); - - it('TensorLike', async () => { - const pad = 'valid'; - const stride = 1; - const outDepth = 2; - - const x = [[ - [[0.230664], [0.987388], [0.0685208]], - [[0.419224], [0.887861], [0.731641]], - [[0.0741907], [0.409265], [0.351377]] - ]]; - const depthwiseFilter = - [[[[0.303873]], [[0.229223]]], [[[0.144333]], [[0.803373]]]]; - const pointwiseFilter = [[[[0.1, -0.2]]]]; - - const result = - tf.separableConv2d(x, depthwiseFilter, pointwiseFilter, stride, pad); - - expectArraysClose(await result.data(), [ - 0.10702161, -0.21404321, 0.10316753, -0.20633507, 0.06704096, -0.13408193, - 0.07788632, -0.15577264 - ]); - expect(result.shape).toEqual([1, 2, 2, outDepth]); - }); - - it('TensorLike Chained', async () => { - const pad = 'valid'; - const stride = 1; - const outDepth = 2; - const inDepth = 1; - - const x = tf.tensor4d( - [ - 0.230664, 0.987388, 0.0685208, 0.419224, 0.887861, 0.731641, - 0.0741907, 0.409265, 0.351377 - ], - [1, 3, 3, inDepth]); - const depthwiseFilter = - [[[[0.303873]], [[0.229223]]], [[[0.144333]], [[0.803373]]]]; - const pointwiseFilter = [[[[0.1, -0.2]]]]; - - const result = - x.separableConv2d(depthwiseFilter, pointwiseFilter, stride, pad); - - expectArraysClose(await result.data(), [ - 0.10702161, -0.21404321, 0.10316753, -0.20633507, 0.06704096, -0.13408193, - 0.07788632, -0.15577264 - ]); - expect(result.shape).toEqual([1, 2, 2, outDepth]); - }); - - it('Incorrect input rank raises error', () => { - // tslint:disable-next-line:no-any - const x = tf.zeros([4, 4]) as any; - const depthwiseFilter: tf.Tensor4D = tf.zeros([2, 2, 1, 3]); - const pointwiseFilter: tf.Tensor4D = tf.zeros([1, 1, 2, 4]); - expect( - () => - tf.separableConv2d(x, depthwiseFilter, pointwiseFilter, 1, 'valid')) - .toThrowError(/rank 4/); - }); - - it('Incorrect depthwise filter rank raises error', () => { - const x: tf.Tensor4D = tf.zeros([1, 4, 4, 1]); - // tslint:disable-next-line:no-any - const depthwiseFilter = tf.zeros([2, 2, 1]) as any; - const pointwiseFilter: tf.Tensor4D = tf.zeros([1, 1, 2, 4]); - expect( - () => - tf.separableConv2d(x, depthwiseFilter, pointwiseFilter, 1, 'valid')) - .toThrowError(/rank 4/); - }); - - it('Incorrect depthwise filter rank raises error', () => { - const x: tf.Tensor4D = tf.zeros([1, 4, 4, 1]); - const depthwiseFilter: tf.Tensor4D = tf.zeros([2, 2, 1, 3]); - // tslint:disable-next-line:no-any - const pointwiseFilter = tf.zeros([1, 1, 2]) as any; - expect( - () => - tf.separableConv2d(x, depthwiseFilter, pointwiseFilter, 1, 'valid')) - .toThrowError(/rank 4/); - }); - - it('Incorrect point filter 1st dimension raises error', () => { - const x: tf.Tensor4D = tf.zeros([1, 4, 4, 1]); - const depthwiseFilter: tf.Tensor4D = tf.zeros([2, 2, 1, 3]); - const pointwiseFilter: tf.Tensor4D = tf.zeros([2, 1, 3, 6]); - expect( - () => - tf.separableConv2d(x, depthwiseFilter, pointwiseFilter, 1, 'valid')) - .toThrowError(/must be 1, but got 2/); - }); - - it('Incorrect point filter 2nd dimension raises error', () => { - const x: tf.Tensor4D = tf.zeros([1, 4, 4, 1]); - const depthwiseFilter: tf.Tensor4D = tf.zeros([2, 2, 1, 3]); - const pointwiseFilter: tf.Tensor4D = tf.zeros([1, 5, 3, 6]); - expect( - () => - tf.separableConv2d(x, depthwiseFilter, pointwiseFilter, 1, 'valid')) - .toThrowError(/must be 1, but got 5/); - }); - - it('Incorrect pointwise filter 3rd dimension raises error', () => { - const x: tf.Tensor4D = tf.zeros([1, 4, 4, 1]); - const depthwiseFilter: tf.Tensor4D = tf.zeros([2, 2, 1, 3]); - const pointwiseFilter: tf.Tensor4D = tf.zeros([1, 1, 4, 6]); - expect( - () => - tf.separableConv2d(x, depthwiseFilter, pointwiseFilter, 1, 'valid')) - .toThrowError(/must be 3, but got 4/); - }); - - it('throws when passed x as a non-tensor', () => { - const fSize = 2; - const pad = 'valid'; - const stride = 1; - const chMul = 1; - const inDepth = 1; - const outDepth = 2; - - const depthwiseFilter: tf.Tensor4D = - tf.zeros([fSize, fSize, inDepth, chMul]); - const pointwiseFilter: tf.Tensor4D = - tf.zeros([1, 1, inDepth * chMul, outDepth]); - - const e = /Argument 'x' passed to 'separableConv2d' must be a Tensor/; - expect( - () => tf.separableConv2d( - {} as tf.Tensor3D, depthwiseFilter, pointwiseFilter, stride, pad)) - .toThrowError(e); - }); - - it('throws when passed depthwiseFilter as a non-tensor', () => { - const pad = 'valid'; - const stride = 1; - const chMul = 1; - const inDepth = 1; - const outDepth = 2; - - const x: tf.Tensor4D = tf.zeros([1, 3, 3, inDepth]); - const pointwiseFilter: tf.Tensor4D = - tf.zeros([1, 1, inDepth * chMul, outDepth]); - - const e = new RegExp( - 'Argument \'depthwiseFilter\' passed to \'separableConv2d\'' + - ' must be a Tensor'); - expect( - () => tf.separableConv2d( - x, {} as tf.Tensor4D, pointwiseFilter, stride, pad)) - .toThrowError(e); - }); - - it('throws when passed pointwiseFilter as a non-tensor', () => { - const fSize = 2; - const pad = 'valid'; - const stride = 1; - const chMul = 1; - const inDepth = 1; - - const x: tf.Tensor4D = tf.zeros([1, 3, 3, inDepth]); - const depthwiseFilter: tf.Tensor4D = - tf.zeros([fSize, fSize, inDepth, chMul]); - - const e = new RegExp( - 'Argument \'pointwiseFilter\' passed to \'separableConv2d\'' + - ' must be a Tensor'); - expect( - () => tf.separableConv2d( - x, depthwiseFilter, {} as tf.Tensor4D, stride, pad)) - .toThrowError(e); - }); - - it('accepts a tensor-like object', async () => { - const pad = 'valid'; - const stride = 1; - const outDepth = 2; - - // 3x3x1 - const x = [ - [[0.230664], [0.987388], [0.0685208]], - [[0.419224], [0.887861], [0.731641]], - [[0.0741907], [0.409265], [0.351377]] - ]; - // 2x2x1x1 - const depthwiseFilter = - [[[[0.303873]], [[0.229223]]], [[[0.144333]], [[0.803373]]]]; - // 1x1x1x2 - const pointwiseFilter = [[[[0.1, -0.2]]]]; - - const result = - tf.separableConv2d(x, depthwiseFilter, pointwiseFilter, stride, pad); - - expectArraysClose(await result.data(), [ - 0.10702161, -0.21404321, 0.10316753, -0.20633507, 0.06704096, -0.13408193, - 0.07788632, -0.15577264 - ]); - expect(result.shape).toEqual([2, 2, outDepth]); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/conv2d_test.ts b/tfjs-master/tfjs-core/src/ops/conv2d_test.ts deleted file mode 100644 index 86a18ae8e..000000000 --- a/tfjs-master/tfjs-core/src/ops/conv2d_test.ts +++ /dev/null @@ -1,983 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; -import {Rank} from '../types'; - -function generateCaseInputs(totalSizeTensor: number, totalSizeFilter: number) { - const inp = new Array(totalSizeTensor); - const filt = new Array(totalSizeFilter); - - for (let i = 0; i < totalSizeTensor; i++) { - inp[i] = i + 1; - } - for (let i = 0; i < totalSizeFilter; i++) { - filt[i] = i + 1; - } - - return {input: inp, filter: filt}; -} - -describeWithFlags('conv2d', ALL_ENVS, () => { - it('x=[1,4,4,1] f=[1,1,1,3] s=2 d=1 p=same', async () => { - const inputDepth = 1; - const inputShape: [number, number, number] = [4, 4, inputDepth]; - const outputDepth = 3; - const fSize = 1; - const pad = 'same'; - const stride: [number, number] = [2, 2]; - - const x = tf.tensor3d( - [ - 10, 30, 50, 70, 20, 40, 60, 80, -10, -30, -50, -70, -20, -40, -60, -80 - ], - inputShape); - const w = tf.tensor4d([1, 0.5, 1], [fSize, fSize, inputDepth, outputDepth]); - - const result = tf.conv2d(x, w, stride, pad); - - expectArraysClose( - await result.data(), - [10, 5, 10, 50, 25, 50, -10, -5, -10, -50, -25, -50]); - }); - - it('x=[2,2,2,2] f=[1,1,2,2] s=1 d=1 p=0', async () => { - const inputDepth = 2; - const inShape: [number, number, number, number] = [2, 2, 2, inputDepth]; - const outputDepth = 2; - const fSize = 1; - const pad = 0; - const stride = 1; - - const x = tf.tensor4d( - [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], inShape); - const w = - tf.tensor4d([-1, 1, -2, 0.5], [fSize, fSize, inputDepth, outputDepth]); - - const result = tf.conv2d(x, w, stride, pad); - expect(result.shape).toEqual([2, 2, 2, 2]); - const expected = - [-5, 2, -11, 5, -17, 8, -23, 11, -29, 14, -35, 17, -41, 20, -47, 23]; - - expectArraysClose(await result.data(), expected); - }); - - it('x=[2,2,1] f=[1,1,1,2] s=1 d=1 p=0', async () => { - const inputDepth = 1; - const inputShape: [number, number, number] = [2, 2, inputDepth]; - const outputDepth = 1; - const fSize = 1; - const pad = 0; - const stride = 1; - - const x = tf.tensor3d([1, 2, 3, 4], inputShape); - const w = tf.tensor4d([2], [fSize, fSize, inputDepth, outputDepth]); - - const result = tf.conv2d(x, w, stride, pad); - - expectArraysClose(await result.data(), [2, 4, 6, 8]); - }); - - it('x=[3,3,2] f=[2,2,2,1] s=1 d=1 p=valid', async () => { - const pad = 'valid'; - const stride = 1; - - const x = tf.tensor3d( - [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 60, 70, 80, 90], - [3, 3, 2]); - const w = tf.tensor4d([.1, .2, .3, .4, .5, .6, .7, .8], [2, 2, 2, 1]); - - const result = tf.conv2d(x, w, stride, pad); - - const resultData = await result.data(); - expect(result.shape).toEqual([2, 2, 1]); - expectArraysClose(resultData, new Float32Array([25.6, 53.5, 157.0, 220.9])); - }); - - it('x=[2,2,2,1] f=[1,1,1,1] s=1 d=1 p=0', async () => { - const inputDepth = 1; - const inShape: [number, number, number, number] = [2, 2, 2, inputDepth]; - const outputDepth = 1; - const fSize = 1; - const pad = 0; - const stride = 1; - - const x = tf.tensor4d([1, 2, 3, 4, 5, 6, 7, 8], inShape); - const w = tf.tensor4d([2], [fSize, fSize, inputDepth, outputDepth]); - - const result = tf.conv2d(x, w, stride, pad); - expect(result.shape).toEqual([2, 2, 2, 1]); - const expected = [2, 4, 6, 8, 10, 12, 14, 16]; - - expectArraysClose(await result.data(), expected); - }); - - it('x=[2,1,2,2] f=[1,1,1,1] s=1 d=1 p=0 NCHW', async () => { - const inputDepth = 1; - const inShape: [number, number, number, number] = [2, inputDepth, 2, 2]; - const outputDepth = 1; - const fSize = 1; - const pad = 0; - const stride = 1; - const dataFormat = 'NCHW'; - - const x = tf.tensor4d([1, 2, 3, 4, 5, 6, 7, 8], inShape); - const w = tf.tensor4d([2], [fSize, fSize, inputDepth, outputDepth]); - - const result = tf.conv2d(x, w, stride, pad, dataFormat); - expect(result.shape).toEqual([2, 1, 2, 2]); - const expected = [2, 4, 6, 8, 10, 12, 14, 16]; - - expectArraysClose(await result.data(), expected); - }); - - it('x=[4,2,1] f=[4,2,1,1] s=1 d=1 p=same', async () => { - const inputDepth = 1; - const outputDepth = 1; - const pad = 'same'; - const stride = 1; - const dataFormat = 'NHWC'; - const dilation = 1; - - const x = tf.tensor3d([1, 2, 3, 4, 5, 6, 7, 8], [4, 2, inputDepth]); - const w = - tf.tensor4d([3, 1, 5, 0, 2, 7, 8, 9], [4, 2, inputDepth, outputDepth]); - - const result = tf.conv2d(x, w, stride, pad, dataFormat, dilation); - - const resultData = await result.data(); - expect(result.shape).toEqual([4, 2, 1]); - expectArraysClose(resultData, [133, 66, 200, 102, 108, 58, 56, 58]); - }); - - it('x=[4,2,1] f=[4,2,1,1] s=1 d=1 p=explicit', async () => { - const inputDepth = 1; - const outputDepth = 1; - const pad = - [[0, 0], [1, 2], [0, 1], [0, 0]] as tf.backend_util.ExplicitPadding; - const stride = 1; - const dataFormat = 'NHWC'; - const dilation = 1; - - const x = tf.tensor3d([1, 2, 3, 4, 5, 6, 7, 8], [4, 2, inputDepth]); - const w = - tf.tensor4d([3, 1, 5, 0, 2, 7, 8, 9], [4, 2, inputDepth, outputDepth]); - - const result = tf.conv2d(x, w, stride, pad, dataFormat, dilation); - - const resultData = await result.data(); - expect(result.shape).toEqual([4, 2, 1]); - expectArraysClose(resultData, [133, 66, 200, 102, 108, 58, 56, 58]); - }); - - it('x=[2,2,1] f=[2,2,1,1] s=1 d=1 p=same', async () => { - const inputDepth = 1; - const inputShape: [number, number, number] = [2, 2, inputDepth]; - const outputDepth = 1; - const fSize = 2; - const pad = 'same'; - const stride = 1; - const dataFormat = 'NHWC'; - const dilation = 1; - - const x = tf.tensor3d([1, 2, 3, 4], inputShape); - const w = - tf.tensor4d([3, 1, 5, 0], [fSize, fSize, inputDepth, outputDepth]); - - const result = tf.conv2d(x, w, stride, pad, dataFormat, dilation); - - const resultData = await result.data(); - expect(result.shape).toEqual([2, 2, 1]); - expectArraysClose(resultData, new Float32Array([20, 26, 13, 12])); - }); - - it('x=[1,2,2] f=[2,2,1,1] s=1 d=1 p=same NCHW', async () => { - const inputDepth = 1; - const inputShape: [number, number, number] = [inputDepth, 2, 2]; - const outputDepth = 1; - const fSize = 2; - const pad = 'same'; - const stride = 1; - const dataFormat = 'NCHW'; - const dilation = 1; - - const x = tf.tensor3d([1, 2, 3, 4], inputShape); - const w = - tf.tensor4d([3, 1, 5, 0], [fSize, fSize, inputDepth, outputDepth]); - - const result = tf.conv2d(x, w, stride, pad, dataFormat, dilation); - - const resultData = await result.data(); - expect(result.shape).toEqual([1, 2, 2]); - expectArraysClose(resultData, [20, 26, 13, 12]); - }); - - it('x=[4,2,2] f=[1,1,4,4] s=1 d=1 p=same NCHW', async () => { - // Skip tensorflow backend due to NCHW not supported. - if (tf.getBackend() === 'tensorflow') { - return; - } - const inputDepth = 4; - const inputShape: [number, number, number] = [inputDepth, 2, 2]; - const outputDepth = 4; - const fSize = 1; - const pad = 'same'; - const stride = 1; - const dataFormat = 'NCHW'; - const dilation = 1; - - const x = tf.tensor3d( - [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4], inputShape); - const w = tf.tensor4d( - [3, 3, 3, 3, 1, 1, 1, 1, 5, 5, 5, 5, 0, 0, 0, 0], - [fSize, fSize, inputDepth, outputDepth]); - - const result = tf.conv2d(x, w, stride, pad, dataFormat, dilation); - - const resultData = await result.data(); - expect(result.shape).toEqual([4, 2, 2]); - expectArraysClose( - resultData, - [9, 18, 27, 36, 9, 18, 27, 36, 9, 18, 27, 36, 9, 18, 27, 36]); - }); - - it('x=[3,2,2] f=[1,1,3,4] s=1 d=1 p=same NCHW', async () => { - // Skip tensorflow backend due to NCHW not supported. - if (tf.getBackend() === 'tensorflow') { - return; - } - const inputDepth = 3; - const inputShape: [number, number, number] = [inputDepth, 2, 2]; - const outputDepth = 4; - const fSize = 1; - const pad = 'same'; - const stride = 1; - const dataFormat = 'NCHW'; - const dilation = 1; - - const x = tf.tensor3d([1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4], inputShape); - const w = tf.tensor4d( - [3, 3, 3, 3, 1, 1, 1, 1, 5, 5, 5, 5], - [fSize, fSize, inputDepth, outputDepth]); - - const result = tf.conv2d(x, w, stride, pad, dataFormat, dilation); - - const resultData = await result.data(); - expect(result.shape).toEqual([4, 2, 2]); - expectArraysClose( - resultData, - [9, 18, 27, 36, 9, 18, 27, 36, 9, 18, 27, 36, 9, 18, 27, 36]); - }); - - it('x=[2,2,2,2] f=[1,1,4,4] s=1 d=1 p=same NCHW', async () => { - // Skip tensorflow backend due to NCHW not supported. - if (tf.getBackend() === 'tensorflow') { - return; - } - const inputDepth = 2; - const inputShape: [number, number, number, number] = [2, inputDepth, 2, 2]; - const outputDepth = 2; - const fSize = 1; - const pad = 'same'; - const stride = 1; - const dataFormat = 'NCHW'; - const dilation = 1; - - const x = tf.tensor4d( - [1, 3, 5, 7, 2, 4, 6, 8, 9, 11, 13, 15, 10, 12, 14, 16], inputShape); - const w = - tf.tensor4d([-1, 1, -2, 0.5], [fSize, fSize, inputDepth, outputDepth]); - - const result = tf.conv2d(x, w, stride, pad, dataFormat, dilation); - - const resultData = await result.data(); - expect(result.shape).toEqual([2, 2, 2, 2]); - expectArraysClose( - resultData, - [-5, -11, -17, -23, 2, 5, 8, 11, -29, -35, -41, -47, 14, 17, 20, 23]); - }); - - it('x=[4,2,2] f=[2,2,4,4] s=1 d=1 p=same NCHW', async () => { - // Skip tensorflow backend due to NCHW not supported. - if (tf.getBackend() === 'tensorflow') { - return; - } - const inputDepth = 4; - const inputShape: [number, number, number] = [inputDepth, 2, 2]; - const outputDepth = 4; - const fSize = 2; - const pad = 'same'; - const stride = 1; - const dataFormat = 'NCHW'; - const dilation = 1; - - const x = tf.tensor3d( - [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4], inputShape); - const w = tf.tensor4d( - [ - 3, 3, 3, 3, 1, 1, 1, 1, 5, 5, 5, 5, 0, 0, 0, 0, 3, 3, 3, 3, 1, 1, - 1, 1, 5, 5, 5, 5, 0, 0, 0, 0, 3, 3, 3, 3, 1, 1, 1, 1, 5, 5, 5, 5, - 0, 0, 0, 0, 3, 3, 3, 3, 1, 1, 1, 1, 5, 5, 5, 5, 0, 0, 0, 0, - ], - [fSize, fSize, inputDepth, outputDepth]); - - const result = tf.conv2d(x, w, stride, pad, dataFormat, dilation); - - const resultData = await result.data(); - expect(result.shape).toEqual([4, 2, 2]); - expectArraysClose( - resultData, - [90, 54, 63, 36, 90, 54, 63, 36, 90, 54, 63, 36, 90, 54, 63, 36]); - }); - - it('x=[1,2,2] f=[2,2,1,1] s=1 d=1 p=explicit NCHW', async () => { - const inputDepth = 1; - const inputShape: [number, number, number] = [inputDepth, 2, 2]; - const outputDepth = 1; - const fSize = 2; - const pad = - [[0, 0], [0, 0], [0, 1], [0, 1]] as tf.backend_util.ExplicitPadding; - const stride = 1; - const dataFormat = 'NCHW'; - const dilation = 1; - - const x = tf.tensor3d([1, 2, 3, 4], inputShape); - const w = - tf.tensor4d([3, 1, 5, 0], [fSize, fSize, inputDepth, outputDepth]); - - const result = tf.conv2d(x, w, stride, pad, dataFormat, dilation); - - const resultData = await result.data(); - expect(result.shape).toEqual([1, 2, 2]); - expectArraysClose(resultData, [20, 26, 13, 12]); - }); - - it('x=[2,2,2] f=[2,2,2,1] s=1 d=1 p=same NCHW', async () => { - const inputDepth = 2; - const inputShape: [number, number, number] = [inputDepth, 2, 2]; - const outputDepth = 1; - const fSize = 2; - const pad = 'same'; - const stride = 1; - const dataFormat = 'NCHW'; - const dilation = 1; - - const x = tf.tensor3d([1, 2, 3, 4, 5, 6, 7, 8], inputShape); - const w = tf.tensor4d( - [3, 1, 5, 0, 0, 5, 1, 3], [fSize, fSize, inputDepth, outputDepth]); - - const result = tf.conv2d(x, w, stride, pad, dataFormat, dilation); - - const resultData = await result.data(); - expect(result.shape).toEqual([1, 2, 2]); - expectArraysClose(resultData, [81, 52, 36, 20]); - }); - - it('x=[2,1,2,2] f=[2,2,1,1] s=1 d=1 p=same NCHW', async () => { - const inputDepth = 1; - const inputShape: [number, number, number, number] = [2, inputDepth, 2, 2]; - const outputDepth = 1; - const fSize = 2; - const pad = 'same'; - const stride = 1; - const dataFormat = 'NCHW'; - const dilation = 1; - - const x = tf.tensor4d([1, 2, 3, 4, 5, 6, 7, 8], inputShape); - const w = - tf.tensor4d([3, 1, 5, 0], [fSize, fSize, inputDepth, outputDepth]); - - const result = tf.conv2d(x, w, stride, pad, dataFormat, dilation); - - const resultData = await result.data(); - expect(result.shape).toEqual([2, 1, 2, 2]); - expectArraysClose(resultData, [20, 26, 13, 12, 56, 58, 29, 24]); - }); - - it('x=[2,2,1] f=[2,2,1,1] s=1 d=1 p=0', async () => { - const inputDepth = 1; - const inputShape: [number, number, number] = [2, 2, inputDepth]; - const outputDepth = 1; - const fSize = 2; - const pad = 0; - const stride = 1; - const dataFormat = 'NHWC'; - const dilation = 1; - - const x = tf.tensor3d([1, 2, 3, 4], inputShape); - const w = - tf.tensor4d([3, 1, 5, 0], [fSize, fSize, inputDepth, outputDepth]); - - const result = tf.conv2d(x, w, stride, pad, dataFormat, dilation); - expectArraysClose(await result.data(), [20]); - }); - - it('x=[4,4,1] f=[2,2,1,1] s=1 d=2 p=0', async () => { - const inputDepth = 1; - const inputShape: [number, number, number] = [4, 4, inputDepth]; - const outputDepth = 1; - const fSize = 2; - const fSizeDilated = 3; - const pad = 0; - const stride = 1; - const dataFormat = 'NHWC'; - const dilation = 2; - const noDilation = 1; - - const x = tf.tensor3d( - [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], inputShape); - const w = - tf.tensor4d([3, 1, 5, 2], [fSize, fSize, inputDepth, outputDepth]); - // adding a dilation rate is equivalent to using a filter - // with 0s for the dilation rate - const wDilated = tf.tensor4d( - [3, 0, 1, 0, 0, 0, 5, 0, 2], - [fSizeDilated, fSizeDilated, inputDepth, outputDepth]); - - const result = tf.conv2d(x, w, stride, pad, dataFormat, dilation); - const expectedResult = - tf.conv2d(x, wDilated, stride, pad, dataFormat, noDilation); - - expect(result.shape).toEqual(expectedResult.shape); - expectArraysClose(await result.data(), await expectedResult.data()); - expect(result.shape).toEqual(expectedResult.shape); - expect(result.dtype).toBe(expectedResult.dtype); - }); - - it('x=[1,3,6,1] f=[2,2,1,1] s=[1,2] d=1 p=valid', async () => { - const inputDepth = 1; - const inputShape: [number, number, number, number] = [1, 3, 6, inputDepth]; - const outputDepth = 1; - const fSize = 2; - const pad = 'valid'; - const stride: [number, number] = [1, 2]; - - const inputs = generateCaseInputs(1 * 3 * 6 * inputDepth, fSize * fSize); - const x = tf.tensor4d(inputs.input, inputShape); - const w = - tf.tensor4d(inputs.filter, [fSize, fSize, inputDepth, outputDepth]); - - const result = tf.conv2d(x, w, stride, pad); - expectArraysClose( - await result.data(), [58.0, 78.0, 98.0, 118.0, 138.0, 158.0]); - }); - - it('x=[1,8,8,16] f=[3,3,16,1] s=[2,2] d=1 p=same', async () => { - const inputDepth = 16; - const xSize = 8; - const inputShape: [number, number, number, number] = - [1, xSize, xSize, inputDepth]; - const outputDepth = 1; - const fSize = 3; - const pad = 'same'; - const stride: [number, number] = [2, 2]; - - // TODO(annxingyuan): Make this test work with large inputs using - // generateCaseInputs https://github.com/tensorflow/tfjs/issues/3143 - const inputData = []; - for (let i = 0; i < xSize * xSize * inputDepth; i++) { - inputData.push(i % 5); - } - - const wData = []; - for (let i = 0; i < fSize * fSize * inputDepth * outputDepth; i++) { - wData.push(i % 5); - } - - const x = tf.tensor4d(inputData, inputShape); - const w = tf.tensor4d(wData, [fSize, fSize, inputDepth, outputDepth]); - const result = tf.conv2d(x, w, stride, pad); - expect(result.shape).toEqual([1, 4, 4, 1]); - expectArraysClose(await result.data(), new Float32Array([ - 854, 431, 568, 382, 580, 427, 854, 288, 431, 568, 580, - 289, 285, 570, 285, 258 - ])); - }); - - it('x=[1,8,8,3] f=[3,3,3,4] s=[2,2] d=1 p=same', async () => { - const inputDepth = 3; - const xSize = 8; - const inputShape: [number, number, number, number] = - [1, xSize, xSize, inputDepth]; - const outputDepth = 4; - const fSize = 3; - const pad = 'same'; - const stride: [number, number] = [2, 2]; - - // TODO(annxingyuan): Make this test work with large inputs using - // generateCaseInputs https://github.com/tensorflow/tfjs/issues/3143 - const inputData = []; - for (let i = 0; i < xSize * xSize * inputDepth; i++) { - inputData.push(i % 5); - } - - const wData = []; - for (let i = 0; i < fSize * fSize * inputDepth * outputDepth; i++) { - wData.push(i % 5); - } - - const x = tf.tensor4d(inputData, inputShape); - const w = tf.tensor4d(wData, [fSize, fSize, inputDepth, outputDepth]); - - const result = tf.conv2d(x, w, stride, pad); - expect(result.shape).toEqual([1, 4, 4, 4]); - expectArraysClose( - await result.data(), new Float32Array([ - 104, 125, 126, 102, 133, 126, 104, 57, 137, 102, 57, 112, 64, - 40, 76, 92, 116, 53, 110, 142, 50, 104, 133, 137, 104, 125, - 126, 102, 83, 88, 78, 33, 133, 126, 104, 57, 137, 102, 57, - 112, 116, 53, 110, 142, 37, 76, 100, 99, 33, 68, 83, 88, - 70, 83, 76, 64, 92, 88, 64, 40, 51, 44, 27, 50 - ])); - }); - - it('x=[1,8,8,3] f=[3,3,3,4] s=[2,2] d=1 p=valid', async () => { - const inputDepth = 3; - const xSize = 8; - const inputShape: [number, number, number, number] = - [1, xSize, xSize, inputDepth]; - const outputDepth = 4; - const fSize = 3; - const pad = 'valid'; - const stride: [number, number] = [2, 2]; - - const inputData = []; - for (let i = 0; i < xSize * xSize * inputDepth; i++) { - inputData.push(i % 5); - } - - const wData = []; - for (let i = 0; i < fSize * fSize * inputDepth * outputDepth; i++) { - wData.push(i % 5); - } - - const x = tf.tensor4d(inputData, inputShape); - const w = tf.tensor4d(wData, [fSize, fSize, inputDepth, outputDepth]); - - const result = tf.conv2d(x, w, stride, pad); - expect(result.shape).toEqual([1, 3, 3, 4]); - expectArraysClose( - await result.data(), new Float32Array([ - 104, 125, 126, 102, 133, 126, 104, 57, 137, 102, 57, 112, - 116, 53, 110, 142, 50, 104, 133, 137, 104, 125, 126, 102, - 133, 126, 104, 57, 137, 102, 57, 112, 116, 53, 110, 142 - ])); - }); - - it('x=[1,2,2,3] f=[1,1] s=2 p=1 fractional outputs default rounding', - async () => { - const inputDepth = 3; - const inShape: [number, number, number, number] = [1, 2, 2, inputDepth]; - const outputDepth = 1; - const fSize = 1; - - const x = tf.tensor4d([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], inShape); - const w = - tf.tensor4d([2, 2, 1], [fSize, fSize, inputDepth, outputDepth]); - const pad = - [[0, 0], [1, 1], [1, 1], [0, 0]] as tf.backend_util.ExplicitPadding; - const strides = 2; - - const result = tf.conv2d(x, w, strides, pad); - - expect(result.shape).toEqual([1, 2, 2, 1]); - expectArraysClose(await result.data(), [0, 0, 0, 54]); - }); - - it('throws when x is not rank 3', () => { - const inputDepth = 1; - const outputDepth = 1; - const fSize = 2; - const pad = 0; - const stride = 1; - - // tslint:disable-next-line:no-any - const x: any = tf.tensor2d([1, 2, 3, 4], [2, 2]); - const w = - tf.tensor4d([3, 1, 5, 0], [fSize, fSize, inputDepth, outputDepth]); - - expect(() => tf.conv2d(x, w, stride, pad)).toThrowError(); - }); - - it('throws when weights is not rank 4', () => { - const inputDepth = 1; - const inputShape: [number, number, number] = [2, 2, inputDepth]; - const pad = 0; - const stride = 1; - - const x = tf.tensor3d([1, 2, 3, 4], inputShape); - // tslint:disable-next-line:no-any - const w: any = tf.tensor3d([3, 1, 5, 0], [2, 2, 1]); - - expect(() => tf.conv2d(x, w, stride, pad)).toThrowError(); - }); - - it('throws when x depth does not match weight depth', () => { - const inputDepth = 1; - const wrongInputDepth = 5; - const inputShape: [number, number, number] = [2, 2, inputDepth]; - const outputDepth = 1; - const fSize = 2; - const pad = 0; - const stride = 1; - - const x = tf.tensor3d([1, 2, 3, 4], inputShape); - const w = - tf.randomNormal([fSize, fSize, wrongInputDepth, outputDepth]); - - expect(() => tf.conv2d(x, w, stride, pad)).toThrowError(); - }); - - it('throws when x depth does not match weight depth NCHW', () => { - const inputDepth = 1; - const wrongInputDepth = 5; - const inputShape: [number, number, number] = [inputDepth, 2, 2]; - const outputDepth = 1; - const fSize = 2; - const pad = 0; - const stride = 1; - const dataFormat = 'NCHW'; - - const x = tf.tensor3d([1, 2, 3, 4], inputShape); - const w = - tf.randomNormal([fSize, fSize, wrongInputDepth, outputDepth]); - - expect(() => tf.conv2d(x, w, stride, pad, dataFormat)).toThrowError(); - }); - - it('throws when dimRoundingMode is set and pad is same', () => { - const inputDepth = 1; - const inputShape: [number, number, number] = [2, 2, inputDepth]; - const outputDepth = 1; - const fSize = 2; - const pad = 'same'; - const stride = 1; - const dataFormat = 'NHWC'; - const dilation = 1; - const dimRoundingMode = 'round'; - - const x = tf.tensor3d([1, 2, 3, 4], inputShape); - const w = tf.randomNormal([fSize, fSize, inputDepth, outputDepth]); - - expect( - () => - tf.conv2d(x, w, stride, pad, dataFormat, dilation, dimRoundingMode)) - .toThrowError(); - }); - - it('throws when dimRoundingMode is set and pad is valid', () => { - const inputDepth = 1; - const inputShape: [number, number, number] = [2, 2, inputDepth]; - const outputDepth = 1; - const fSize = 2; - const pad = 'valid'; - const stride = 1; - const dataFormat = 'NHWC'; - const dilation = 1; - const dimRoundingMode = 'round'; - - const x = tf.tensor3d([1, 2, 3, 4], inputShape); - const w = tf.randomNormal([fSize, fSize, inputDepth, outputDepth]); - - expect( - () => - tf.conv2d(x, w, stride, pad, dataFormat, dilation, dimRoundingMode)) - .toThrowError(); - }); - - it('throws when dimRoundingMode is set and pad is a non-integer number', - () => { - const inputDepth = 1; - const inputShape: [number, number, number] = [2, 2, inputDepth]; - const outputDepth = 1; - const fSize = 2; - const pad = 1.2; - const stride = 1; - const dataFormat = 'NHWC'; - const dilation = 1; - const dimRoundingMode = 'round'; - - const x = tf.tensor3d([1, 2, 3, 4], inputShape); - const w = - tf.randomNormal([fSize, fSize, inputDepth, outputDepth]); - - expect( - () => tf.conv2d( - x, w, stride, pad, dataFormat, dilation, dimRoundingMode)) - .toThrowError(); - }); - - it('throws when dimRoundingMode is set and pad is explicit by non-integer ' + - 'number', - () => { - const inputDepth = 1; - const inputShape: [number, number, number] = [2, 2, inputDepth]; - const outputDepth = 1; - const fSize = 2; - const pad = [[0, 0], [0, 2.1], [1, 1], [0, 0]] as - tf.backend_util.ExplicitPadding; - const stride = 1; - const dataFormat = 'NHWC'; - const dilation = 1; - const dimRoundingMode = 'round'; - - const x = tf.tensor3d([1, 2, 3, 4], inputShape); - const w = - tf.randomNormal([fSize, fSize, inputDepth, outputDepth]); - - expect( - () => tf.conv2d( - x, w, stride, pad, dataFormat, dilation, dimRoundingMode)) - .toThrowError(); - }); - - it('throws when stride is less than or equal to 0', async () => { - const inputDepth = 1; - const inputShape: [number, number, number] = [2, 2, inputDepth]; - const outputDepth = 1; - const fSize = 1; - const pad = 0; - const stride: [number, number] = [1, 0]; - - const x = tf.tensor3d([1, 2, 3, 4], inputShape); - const w = tf.tensor4d([2], [fSize, fSize, inputDepth, outputDepth]); - - expect(() => tf.conv2d(x, w, stride, pad)).toThrowError(); - }); - - it('throws when dilation is less than or equal to 0', async () => { - const inputDepth = 1; - const inputShape: [number, number, number] = [2, 2, inputDepth]; - const outputDepth = 1; - const fSize = 1; - const pad = 0; - const stride = 1; - const dataFormat = 'NHWC'; - const dilation: [number, number] = [1, 0]; - - const x = tf.tensor3d([1, 2, 3, 4], inputShape); - const w = tf.tensor4d([2], [fSize, fSize, inputDepth, outputDepth]); - - expect(() => tf.conv2d(x, w, stride, pad, dataFormat, dilation)) - .toThrowError(); - }); - - it('throws when both stride and dilation are greater than 1', () => { - const inputDepth = 1; - const inputShape: [number, number, number] = [2, 2, inputDepth]; - const outputDepth = 1; - const fSize = 2; - const pad = 0; - const stride: [number, number] = [2, 1]; - const dataFormat = 'NHWC'; - const dilation: [number, number] = [1, 2]; - - const x = tf.tensor3d([1, 2, 3, 4], inputShape); - const w = - tf.tensor4d([3, 1, 5, 0], [fSize, fSize, inputDepth, outputDepth]); - - expect(() => tf.conv2d(x, w, stride, pad, dataFormat, dilation)) - .toThrowError(); - }); - - it('gradient with clones input=[3,3,1] f=[2,2,1,1] s=1 p=0', async () => { - const inputDepth = 1; - const outputDepth = 1; - const inputShape: [number, number, number] = [3, 3, inputDepth]; - const filterSize = 2; - const stride = 1; - const pad = 0; - - const filterShape: [number, number, number, number] = - [filterSize, filterSize, inputDepth, outputDepth]; - const filter = tf.ones(filterShape); - - const x = tf.tensor3d([1, 2, 3, 4, 5, 6, 7, 8, 9], inputShape); - const dy = tf.tensor3d([3, 1, 2, 0], [2, 2, 1]); - - const grads = tf.grads( - (x: tf.Tensor3D, filter: tf.Tensor4D) => - x.clone().conv2d(filter.clone(), stride, pad).clone()); - const [dx, dfilter] = grads([x, filter], dy); - - expect(dx.shape).toEqual(x.shape); - expectArraysClose(await dx.data(), [3, 4, 1, 5, 6, 1, 2, 2, 0]); - - expect(dfilter.shape).toEqual(filterShape); - expectArraysClose(await dfilter.data(), [13, 19, 31, 37]); - }); - - it('gradient x=[2,3,3,1] f=[2,2,1,1] s=1 p=0', async () => { - const inputDepth = 1; - const outputDepth = 1; - const inputShape: [number, number, number, number] = [2, 3, 3, inputDepth]; - const filterSize = 2; - const stride = 1; - const pad = 0; - - const filterShape: [number, number, number, number] = - [filterSize, filterSize, inputDepth, outputDepth]; - const filter = tf.ones(filterShape); - - const x = tf.tensor4d( - [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9], inputShape); - const dy = tf.tensor4d([3, 1, 2, 0, 3, 1, 2, 0], [2, 2, 2, 1]); - - const grads = tf.grads( - (x: tf.Tensor4D, filter: tf.Tensor4D) => x.conv2d(filter, stride, pad)); - const [dx, dfilter] = grads([x, filter], dy); - - expect(dx.shape).toEqual(x.shape); - expectArraysClose( - await dx.data(), - [3, 4, 1, 5, 6, 1, 2, 2, 0, 3, 4, 1, 5, 6, 1, 2, 2, 0]); - - expect(dfilter.shape).toEqual(filterShape); - expectArraysClose(await dfilter.data(), [13 * 2, 19 * 2, 31 * 2, 37 * 2]); - }); - - it('gradient x=[1,1,3,3] f=[2,2,1,1] s=1 p=0 NCHW', async () => { - const inputDepth = 1; - const outputDepth = 1; - const inputShape: [number, number, number, number] = [1, inputDepth, 3, 3]; - const filterSize = 2; - const stride = 1; - const pad = 0; - const dataFormat = 'NCHW'; - - const filterShape: [number, number, number, number] = - [filterSize, filterSize, inputDepth, outputDepth]; - const filter = tf.ones(filterShape); - - const x = tf.tensor4d([1, 2, 3, 4, 5, 6, 7, 8, 9], inputShape); - const dy = tf.tensor4d([3, 1, 2, 0], [1, 1, 2, 2]); - - const grads = tf.grads( - (x: tf.Tensor4D, filter: tf.Tensor4D) => - x.conv2d(filter, stride, pad, dataFormat)); - const [dx, dfilter] = grads([x, filter], dy); - - expect(dx.shape).toEqual(x.shape); - expectArraysClose(await dx.data(), [3, 4, 1, 5, 6, 1, 2, 2, 0]); - - expect(dfilter.shape).toEqual(filterShape); - expectArraysClose(await dfilter.data(), [13, 19, 31, 37]); - }); - - it('gradient x=[2,1,3,3] f=[2,2,1,1] s=1 p=0 NCHW', async () => { - const inputDepth = 1; - const outputDepth = 1; - const inputShape: [number, number, number, number] = [2, inputDepth, 3, 3]; - const filterSize = 2; - const stride = 1; - const pad = 0; - const dataFormat = 'NCHW'; - - const filterShape: [number, number, number, number] = - [filterSize, filterSize, inputDepth, outputDepth]; - const filter = tf.ones(filterShape); - - const x = tf.tensor4d( - [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9], inputShape); - const dy = tf.tensor4d([3, 1, 2, 0, 3, 1, 2, 0], [2, 1, 2, 2]); - - const grads = tf.grads( - (x: tf.Tensor4D, filter: tf.Tensor4D) => - x.conv2d(filter, stride, pad, dataFormat)); - const [dx, dfilter] = grads([x, filter], dy); - - expect(dx.shape).toEqual(x.shape); - expectArraysClose( - await dx.data(), - [3, 4, 1, 5, 6, 1, 2, 2, 0, 3, 4, 1, 5, 6, 1, 2, 2, 0]); - - expect(dfilter.shape).toEqual(filterShape); - expectArraysClose(await dfilter.data(), [26, 38, 62, 74]); - }); - - it('throws when passed x as a non-tensor', () => { - const inputDepth = 1; - const outputDepth = 1; - const fSize = 1; - const pad = 0; - const stride = 1; - - const w = tf.tensor4d([2], [fSize, fSize, inputDepth, outputDepth]); - - expect(() => tf.conv2d({} as tf.Tensor3D, w, stride, pad)) - .toThrowError(/Argument 'x' passed to 'conv2d' must be a Tensor/); - }); - - it('throws when passed filter as a non-tensor', () => { - const inputDepth = 1; - const inputShape: [number, number, number] = [2, 2, inputDepth]; - const pad = 0; - const stride = 1; - - const x = tf.tensor3d([1, 2, 3, 4], inputShape); - - expect(() => tf.conv2d(x, {} as tf.Tensor4D, stride, pad)) - .toThrowError(/Argument 'filter' passed to 'conv2d' must be a Tensor/); - }); - - it('throws when input is int32', async () => { - const inputDepth = 2; - const inShape: [number, number, number, number] = [2, 2, 2, inputDepth]; - const outputDepth = 2; - const fSize = 1; - const pad = 0; - const stride = 1; - - const x = tf.tensor4d( - [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], inShape, - 'int32'); - const w = - tf.tensor4d([-1, 1, -2, 0.5], [fSize, fSize, inputDepth, outputDepth]); - - expect(() => tf.conv2d(x, w, stride, pad)) - .toThrowError(/Argument 'x' passed to 'conv2d' must be float32/); - }); - - it('throws when filter is int32', async () => { - const inputDepth = 2; - const inShape: [number, number, number, number] = [2, 2, 2, inputDepth]; - const outputDepth = 2; - const fSize = 1; - const pad = 0; - const stride = 1; - - const x = tf.tensor4d( - [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], inShape); - const w = tf.tensor4d( - [-1, 1, -2, 0.5], [fSize, fSize, inputDepth, outputDepth], 'int32'); - - expect(() => tf.conv2d(x, w, stride, pad)) - .toThrowError(/Argument 'filter' passed to 'conv2d' must be float32/); - }); - - it('accepts a tensor-like object', async () => { - const pad = 0; - const stride = 1; - const x = [[[1], [2]], [[3], [4]]]; // 2x2x1 - const w = [[[[2]]]]; // 1x1x1x1 - - const result = tf.conv2d(x, w, stride, pad); - expectArraysClose(await result.data(), [2, 4, 6, 8]); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/conv2d_transpose.ts b/tfjs-master/tfjs-core/src/ops/conv2d_transpose.ts deleted file mode 100644 index 073425aae..000000000 --- a/tfjs-master/tfjs-core/src/ops/conv2d_transpose.ts +++ /dev/null @@ -1,58 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {Tensor3D, Tensor4D} from '../tensor'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -import {conv2DBackpropInput} from './conv2d_backprop_input'; -import {ExplicitPadding} from './conv_util'; -import {op} from './operation'; - -/** - * Computes the transposed 2D convolution of an image, also known as a - * deconvolution. - * - * @param x The input image, of rank 4 or rank 3, of shape - * `[batch, height, width, inDepth]`. If rank 3, batch of 1 is assumed. - * @param filter The filter, rank 4, of shape - * `[filterHeight, filterWidth, outDepth, inDepth]`. - * `inDepth` must match `inDepth` in `x`. - * @param outputShape Output shape, of rank 4 or rank 3: - * `[batch, height, width, outDepth]`. If rank 3, batch of 1 is assumed. - * @param strides The strides of the original convolution: - * `[strideHeight, strideWidth]`. - * @param pad The type of padding algorithm used in the non-transpose version - * of the op. - * @param dimRoundingMode A string from: 'ceil', 'round', 'floor'. If none is - * provided, it will default to truncate. - * - * @doc {heading: 'Operations', subheading: 'Convolution'} - */ -function conv2dTranspose_( - x: T|TensorLike, filter: Tensor4D|TensorLike, - outputShape: [number, number, number, number]|[number, number, number], - strides: [number, number]|number, - pad: 'valid'|'same'|number|ExplicitPadding, - dimRoundingMode?: 'floor'|'round'|'ceil'): T { - const $x = convertToTensor(x, 'x', 'conv2dTranspose'); - const $filter = convertToTensor(filter, 'filter', 'conv2dTranspose'); - - return conv2DBackpropInput( - outputShape, $x, $filter, strides, pad, 'NHWC', dimRoundingMode); -} - -export const conv2dTranspose = /* @__PURE__ */ op({conv2dTranspose_}); diff --git a/tfjs-master/tfjs-core/src/ops/conv2d_transpose_test.ts b/tfjs-master/tfjs-core/src/ops/conv2d_transpose_test.ts deleted file mode 100644 index 7ae3a94c0..000000000 --- a/tfjs-master/tfjs-core/src/ops/conv2d_transpose_test.ts +++ /dev/null @@ -1,709 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; -import {Rank} from '../types'; - -describeWithFlags('conv2dTranspose', ALL_ENVS, () => { - it('input=2x2x1,d2=1,f=2,s=1,p=0', async () => { - const origInputDepth = 1; - const origOutputDepth = 1; - const inputShape: [number, number, number] = [1, 1, origOutputDepth]; - const fSize = 2; - const origPad = 0; - const origStride = 1; - - const x = tf.tensor3d([2], inputShape); - const w = tf.tensor4d( - [3, 1, 5, 0], [fSize, fSize, origInputDepth, origOutputDepth]); - - const result = tf.conv2dTranspose(x, w, [2, 2, 1], origStride, origPad); - const expected = [6, 2, 10, 0]; - - expect(result.shape).toEqual([2, 2, 1]); - expectArraysClose(await result.data(), expected); - }); - - it('input=3x3x1,d2=1,f=2,s=2,p=same', async () => { - const origInputDepth = 1; - const origOutputDepth = 4; - const inputShape: [number, number, number, number] = - [1, 2, 2, origOutputDepth]; - const fSize = 2; - const origPad = 'same'; - const origStride = 2; - - const x = tf.tensor4d( - [ - 1.24, 1.66, 0.9, 1.39, 0.16, 0.27, 0.42, 0.61, 0.04, 0.17, 0.34, 0.28, - 0., 0.06, 0.14, 0.24 - ], - inputShape); - const w = tf.tensor4d( - [0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14., 15.], - [fSize, fSize, origInputDepth, origOutputDepth]); - - const result = tf.conv2dTranspose(x, w, [1, 3, 3, 1], origStride, origPad); - const expected = [7.63, 28.39, 2.94, 49.15, 69.91, 14.62, 1.69, 5.01, 1.06]; - - expect(result.shape).toEqual([1, 3, 3, 1]); - expectArraysClose(await result.data(), expected); - }); - - it('input=3x3x1,d2=1,f=2,s=2,p=explicit', async () => { - const origInputDepth = 1; - const origOutputDepth = 4; - const inputShape: [number, number, number, number] = - [1, 2, 2, origOutputDepth]; - const fSize = 2; - const origPad = - [[0, 0], [0, 1], [0, 1], [0, 0]] as tf.backend_util.ExplicitPadding; - const origStride = 2; - - const x = tf.tensor4d( - [ - 1.24, 1.66, 0.9, 1.39, 0.16, 0.27, 0.42, 0.61, 0.04, 0.17, 0.34, 0.28, - 0., 0.06, 0.14, 0.24 - ], - inputShape); - const w = tf.tensor4d( - [0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14., 15.], - [fSize, fSize, origInputDepth, origOutputDepth]); - - const result = tf.conv2dTranspose(x, w, [1, 3, 3, 1], origStride, origPad); - const expected = [7.63, 28.39, 2.94, 49.15, 69.91, 14.62, 1.69, 5.01, 1.06]; - - expect(result.shape).toEqual([1, 3, 3, 1]); - expectArraysClose(await result.data(), expected); - }); - - it('input=2x2x1,d2=1,f=2,s=1,p=0, batch=2', async () => { - const origInputDepth = 1; - const origOutputDepth = 1; - const inputShape: [number, number, number, number] = - [2, 1, 1, origOutputDepth]; - const fSize = 2; - const origPad = 0; - const origStride = 1; - - const x = tf.tensor4d([2, 3], inputShape); - const w = tf.tensor4d( - [3, 1, 5, 0], [fSize, fSize, origInputDepth, origOutputDepth]); - - const result = tf.conv2dTranspose(x, w, [2, 2, 2, 1], origStride, origPad); - const expected = [6, 2, 10, 0, 9, 3, 15, 0]; - - expect(result.shape).toEqual([2, 2, 2, 1]); - expectArraysClose(await result.data(), expected); - }); - - it('input=2x2x2,output=3x3x2,f=2,s=2,inDepth=2,p=same', async () => { - const origInputDepth = 2; - const origOutputDepth = 2; - const inputShape: [number, number, number, number] = - [1, 2, 2, origOutputDepth]; - const fSize = 2; - const origPad = 'same'; - const origStride = 2; - - const x = tf.tensor4d([0., 1., 2., 3., 4., 5., 6., 7.], inputShape); - const w = tf.tensor4d( - [0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14., 15.], - [fSize, fSize, origInputDepth, origOutputDepth]); - - const result = tf.conv2dTranspose( - x, w, [1, 3, 3, origInputDepth], origStride, origPad); - const expected = - [1, 3, 5, 7, 3, 13, 9, 11, 13, 15, 43, 53, 5, 23, 41, 59, 7, 33.]; - - expect(result.shape).toEqual([1, 3, 3, origInputDepth]); - expectArraysClose(await result.data(), expected); - }); - - it('throws when dimRoundingMode is set and pad is same', async () => { - const origInputDepth = 1; - const origOutputDepth = 4; - const inputShape: [number, number, number, number] = - [1, 2, 2, origOutputDepth]; - const fSize = 2; - const origPad = 'same'; - const origStride = 2; - const dimRoundingMode = 'round'; - - const x = tf.tensor4d( - [ - 1.24, 1.66, 0.9, 1.39, 0.16, 0.27, 0.42, 0.61, 0.04, 0.17, 0.34, 0.28, - 0., 0.06, 0.14, 0.24 - ], - inputShape); - const w = tf.tensor4d( - [0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14., 15.], - [fSize, fSize, origInputDepth, origOutputDepth]); - - expect( - () => tf.conv2dTranspose( - x, w, [1, 3, 3, 1], origStride, origPad, dimRoundingMode)) - .toThrowError(); - }); - - it('throws when dimRoundingMode is set and pad is valid', async () => { - const origInputDepth = 1; - const origOutputDepth = 4; - const inputShape: [number, number, number, number] = - [1, 2, 2, origOutputDepth]; - const fSize = 2; - const origPad = 'valid'; - const origStride = 2; - const dimRoundingMode = 'round'; - - const x = tf.tensor4d( - [ - 1.24, 1.66, 0.9, 1.39, 0.16, 0.27, 0.42, 0.61, 0.04, 0.17, 0.34, 0.28, - 0., 0.06, 0.14, 0.24 - ], - inputShape); - const w = tf.tensor4d( - [0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14., 15.], - [fSize, fSize, origInputDepth, origOutputDepth]); - - expect( - () => tf.conv2dTranspose( - x, w, [1, 3, 3, 1], origStride, origPad, dimRoundingMode)) - .toThrowError(); - }); - - it('throws when dimRoundingMode is set and pad is a non-integer number', - async () => { - const origInputDepth = 1; - const origOutputDepth = 4; - const inputShape: [number, number, number, number] = - [1, 2, 2, origOutputDepth]; - const fSize = 2; - const origPad = 1.2; - const origStride = 2; - const dimRoundingMode = 'round'; - - const x = tf.tensor4d( - [ - 1.24, 1.66, 0.9, 1.39, 0.16, 0.27, 0.42, 0.61, 0.04, 0.17, 0.34, - 0.28, 0., 0.06, 0.14, 0.24 - ], - inputShape); - const w = tf.tensor4d( - [ - 0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14., - 15. - ], - [fSize, fSize, origInputDepth, origOutputDepth]); - - expect( - () => tf.conv2dTranspose( - x, w, [1, 3, 3, 1], origStride, origPad, dimRoundingMode)) - .toThrowError(); - }); - - it('throws when dimRoundingMode is set and pad is explicit by non-integer ' + - 'number', - async () => { - const origInputDepth = 1; - const origOutputDepth = 4; - const inputShape: [number, number, number, number] = - [1, 2, 2, origOutputDepth]; - const fSize = 2; - const origPad = [[0, 0], [0, 1.1], [0, 1], [0, 0]] as - tf.backend_util.ExplicitPadding; - const origStride = 2; - const dimRoundingMode = 'round'; - - const x = tf.tensor4d( - [ - 1.24, 1.66, 0.9, 1.39, 0.16, 0.27, 0.42, 0.61, 0.04, 0.17, 0.34, - 0.28, 0., 0.06, 0.14, 0.24 - ], - inputShape); - const w = tf.tensor4d( - [ - 0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14., - 15. - ], - [fSize, fSize, origInputDepth, origOutputDepth]); - - expect( - () => tf.conv2dTranspose( - x, w, [1, 3, 3, 1], origStride, origPad, dimRoundingMode)) - .toThrowError(); - }); - - // Reference (Python) TensorFlow code: - // - // ```py - // import numpy as np - // import tensorflow as tf - // - // tf.enable_eager_execution() - // - // x = tf.constant(np.array([[ - // [[-0.14656299], [0.32942239], [-1.90302866]], - // [[-0.06487813], [-2.02637842], [-1.83669377]], - // [[0.82650784], [-0.89249092], [0.01207666]] - // ]]).astype(np.float32)) - // filt = tf.constant(np.array([ - // [[[-0.48280062], [1.26770487]], [[-0.83083738], [0.54341856]]], - // [[[-0.274904], [0.73111374]], [[2.01885189], [-2.68975237]]] - // ]).astype(np.float32)) - // - // with tf.GradientTape() as g: - // g.watch(x) - // g.watch(filt) - // y = tf.keras.backend.conv2d_transpose(x, filt, [1, 4, 4, 2]) - // print(y) - // (x_grad, filt_grad) = g.gradient(y, [x, filt]) - // - // print("x_grad = %s" % x_grad) - // print("filt_grad = %s" % filt_grad) - // ``` - it('gradient with clones input=[1,3,3,1] f=[2,2,2,1] s=1 padding=valid', - async () => { - const inputDepth = 1; - const outputDepth = 2; - const inputShape: [number, number, number, number] = - [1, 3, 3, inputDepth]; - const filterSize = 2; - const stride = 1; - const pad = 'valid'; - - const filterShape: [number, number, number, number] = - [filterSize, filterSize, outputDepth, inputDepth]; - - const x = tf.tensor4d( - [[ - [[-0.14656299], [0.32942239], [-1.90302866]], - [[-0.06487813], [-2.02637842], [-1.83669377]], - [[0.82650784], [-0.89249092], [0.01207666]] - ]], - inputShape); - const filt = tf.tensor4d( - [ - [[[-0.48280062], [1.26770487]], [[-0.83083738], [0.54341856]]], - [[[-0.274904], [0.73111374]], [[2.01885189], [-2.68975237]]] - ], - filterShape); - - const grads = tf.grads( - (x: tf.Tensor4D, filter: tf.Tensor4D) => - tf.conv2dTranspose( - x.clone(), filter.clone(), [1, 4, 4, outputDepth], stride, - pad) - .clone()); - const dy = tf.ones([1, 4, 4, outputDepth]); - const [xGrad, filtGrad] = grads([x, filt], dy); - - const expectedXGrad = tf.ones([1, 3, 3, 1]).mul(tf.scalar(0.2827947)); - expectArraysClose(await xGrad.data(), await expectedXGrad.data()); - const expectedFiltGrad = - tf.ones([2, 2, 2, 1]).mul(tf.scalar(-5.70202599)); - expectArraysClose(await filtGrad.data(), await expectedFiltGrad.data()); - }); - - // Reference (Python) TensorFlow code: - // - // ```py - // import numpy as np - // import tensorflow as tf - // - // tf.enable_eager_execution() - // - // x = tf.constant(np.array([ - // [[[-0.36541713], [-0.53973116]], [[0.01731674], [0.90227772]]] - // ]).astype(np.float32)) - // filt = tf.constant(np.array([ - // [[[-0.01423461], [-1.00267384]], [[1.61163029], [0.66302646]]], - // [[[-0.46900087], [-0.78649444]], [[0.87780536], [-0.84551637]]] - // ]).astype(np.float32)) - // - // with tf.GradientTape() as g: - // g.watch(x) - // g.watch(filt) - // y = tf.keras.backend.conv2d_transpose(x, filt, [1, 4, 4, 2], strides=(2, - // 2)) print(y) - // (x_grad, filt_grad) = g.gradient(y, [x, filt]) - // - // print("x_grad = %s" % -x_grad) - // print("filt_grad = %s" % -filt_grad) - // ``` - it('gradient input=[1,2,2,1] f=[2,2,2,1] s=[2,2] padding=valid', async () => { - const inputDepth = 1; - const outputDepth = 2; - const inputShape: [number, number, number, number] = [1, 2, 2, inputDepth]; - const filterSize = 2; - const stride: [number, number] = [2, 2]; - const pad = 'valid'; - - const filterShape: [number, number, number, number] = - [filterSize, filterSize, outputDepth, inputDepth]; - - const x = tf.tensor4d( - [[[[-0.36541713], [-0.53973116]], [[0.01731674], [0.90227772]]]], - inputShape); - const filt = tf.tensor4d( - [ - [[[-0.01423461], [-1.00267384]], [[1.61163029], [0.66302646]]], - [[[-0.46900087], [-0.78649444]], [[0.87780536], [-0.84551637]]] - ], - filterShape); - - const grads = tf.grads( - (x: tf.Tensor4D, filter: tf.Tensor4D) => - tf.conv2dTranspose(x, filter, [1, 4, 4, outputDepth], stride, pad)); - const dy = tf.ones([1, 4, 4, outputDepth]).mul(tf.scalar(-1)); - const [xGrad, filtGrad] = grads([x, filt], dy); - - const expectedXGrad = tf.ones([1, 2, 2, 1]).mul(tf.scalar(-0.03454196)); - expectArraysClose(await xGrad.data(), await expectedXGrad.data()); - expect(xGrad.shape).toEqual([1, 2, 2, 1]); - - const expectedFiltGrad = tf.ones([2, 2, 2, 1]).mul(tf.scalar(-0.01444618)); - expectArraysClose(await filtGrad.data(), await expectedFiltGrad.data()); - expect(filtGrad.shape).toEqual([2, 2, 2, 1]); - }); - - // Reference (Python) TensorFlow code: - // - // ```py - // import numpy as np - // import tensorflow as tf - // - // tf.enable_eager_execution() - // - // x = tf.constant(np.array([[ - // [[1.52433065], [-0.77053435], [-0.64562341]], - // [[0.77962889], [1.58413887], [-0.25581856]], - // [[-0.58966221], [0.05411662], [0.70749138]] - // ]]).astype(np.float32)) - // filt = tf.constant(np.array([ - // [[[0.11178388], [-0.96654977]], [[1.21021296], [0.84121729]]], - // [[[0.34968338], [-0.42306114]], [[1.27395733], [-1.09014535]]] - // ]).astype(np.float32)) - // - // with tf.GradientTape() as g: - // g.watch(x) - // g.watch(filt) - // y = tf.keras.backend.conv2d_transpose( - // x, filt, [1, 3, 3, 2], strides=(1, 1), padding='same') - // (x_grad, filt_grad) = g.gradient(y, [x, filt]) - // - // print("x_grad = %s" % x_grad) - // print("filt_grad = %s" % filt_grad) - // ``` - it('gradient input=[1,3,3,1] f=[2,2,2,1] s=[1,1] padding=same', async () => { - const inputDepth = 1; - const outputDepth = 2; - const inputShape: [number, number, number, number] = [1, 3, 3, inputDepth]; - const filterSize = 2; - const stride: [number, number] = [1, 1]; - const pad = 'same'; - - const filterShape: [number, number, number, number] = - [filterSize, filterSize, outputDepth, inputDepth]; - - const x = tf.tensor4d( - [[ - [[1.52433065], [-0.77053435], [-0.64562341]], - [[0.77962889], [1.58413887], [-0.25581856]], - [[-0.58966221], [0.05411662], [0.70749138]] - ]], - inputShape); - const filt = tf.tensor4d( - [ - [[[0.11178388], [-0.96654977]], [[1.21021296], [0.84121729]]], - [[[0.34968338], [-0.42306114]], [[1.27395733], [-1.09014535]]] - ], - filterShape); - - const grads = tf.grads( - (x: tf.Tensor4D, filter: tf.Tensor4D) => - tf.conv2dTranspose(x, filter, [1, 3, 3, outputDepth], stride, pad)); - const dy = tf.ones([1, 3, 3, outputDepth]); - const [xGrad, filtGrad] = grads([x, filt], dy); - - expectArraysClose(await xGrad.array(), [[ - [[1.30709858], [1.30709858], [-0.92814366]], - [[1.30709858], [1.30709858], [-0.92814366]], - [[1.19666437], [1.19666437], [-0.85476589]] - ]]); - expectArraysClose(await filtGrad.array(), [ - [[[2.38806788], [2.38806788]], [[2.58201847], [2.58201847]]], - [[[2.2161221], [2.2161221]], [[3.11756406], [3.11756406]]] - ]); - }); - - it('gradient input=[1,3,3,1] f=[2,2,2,1] s=[1,1] p=explicit', async () => { - const inputDepth = 1; - const outputDepth = 2; - const inputShape: [number, number, number, number] = [1, 3, 3, inputDepth]; - const filterSize = 2; - const stride: [number, number] = [1, 1]; - const pad = - [[0, 0], [0, 1], [0, 1], [0, 0]] as tf.backend_util.ExplicitPadding; - - const filterShape: [number, number, number, number] = - [filterSize, filterSize, outputDepth, inputDepth]; - - const x = tf.tensor4d( - [[ - [[1.52433065], [-0.77053435], [-0.64562341]], - [[0.77962889], [1.58413887], [-0.25581856]], - [[-0.58966221], [0.05411662], [0.70749138]] - ]], - inputShape); - const filt = tf.tensor4d( - [ - [[[0.11178388], [-0.96654977]], [[1.21021296], [0.84121729]]], - [[[0.34968338], [-0.42306114]], [[1.27395733], [-1.09014535]]] - ], - filterShape); - - const grads = tf.grads( - (x: tf.Tensor4D, filter: tf.Tensor4D) => - tf.conv2dTranspose(x, filter, [1, 3, 3, outputDepth], stride, pad)); - const dy = tf.ones([1, 3, 3, outputDepth]); - const [xGrad, filtGrad] = grads([x, filt], dy); - - expectArraysClose(await xGrad.array(), [[ - [[1.30709858], [1.30709858], [-0.92814366]], - [[1.30709858], [1.30709858], [-0.92814366]], - [[1.19666437], [1.19666437], [-0.85476589]] - ]]); - expectArraysClose(await filtGrad.array(), [ - [[[2.38806788], [2.38806788]], [[2.58201847], [2.58201847]]], - [[[2.2161221], [2.2161221]], [[3.11756406], [3.11756406]]] - ]); - }); - - // Reference (Python) TensorFlow code: - // - // ```py - // import numpy as np - // import tensorflow as tf - // - // tf.enable_eager_execution() - // - // x = tf.constant(np.array([[ - // [[1.52433065], [-0.77053435]], [[0.77962889], [1.58413887]], - // ]]).astype(np.float32)) - // filt = tf.constant(np.array([ - // [[[0.11178388], [-0.96654977]], [[1.21021296], [0.84121729]]], - // [[[0.34968338], [-0.42306114]], [[1.27395733], [-1.09014535]]] - // ]).astype(np.float32)) - // - // with tf.GradientTape() as g: - // g.watch(x) - // g.watch(filt) - // y = tf.keras.backend.conv2d_transpose( - // x, filt, [1, 3, 3, 2], strides=(2, 2), padding='same') - // print(y.shape) - // (x_grad, filt_grad) = g.gradient(y, [x, filt]) - // - // print("x_grad = %s" % x_grad) - // print("filt_grad = %s" % filt_grad) - // ``` - it('gradient input=[1,2,2,2] f=[2,2,2,1] s=[2,2] padding=same', async () => { - const inputDepth = 2; - const outputDepth = 2; - const inputShape: [number, number, number, number] = [1, 2, 2, inputDepth]; - const filterSize = 2; - const stride: [number, number] = [2, 2]; - const pad = 'same'; - - const filterShape: [number, number, number, number] = - [filterSize, filterSize, outputDepth, inputDepth]; - - const x = tf.tensor4d( - [[ - [[-1.81506593, 1.00900095], [-0.05199118, 0.26311377]], - [[-1.18469792, -0.34780521], [2.04971242, -0.65154692]] - ]], - inputShape); - const filt = tf.tensor4d( - [ - [ - [[0.19529686, -0.79594708], [0.70314057, -0.06081263]], - [[0.28724744, 0.88522715], [-0.51824096, -0.97120989]] - ], - [ - [[0.51872197, -1.17569193], [1.28316791, -0.81225092]], - [[-0.44221532, 0.70058174], [-0.4849217, 0.03806348]] - ] - ], - filterShape); - - const grads = tf.grads( - (x: tf.Tensor4D, filter: tf.Tensor4D) => - tf.conv2dTranspose(x, filter, [1, 3, 3, outputDepth], stride, pad)); - const dy = tf.ones([1, 3, 3, outputDepth]); - const [xGrad, filtGrad] = grads([x, filt], dy); - - expectArraysClose(await xGrad.data(), [ - 1.54219678, -2.19204008, 2.70032732, -2.84470257, 0.66744391, -0.94274245, - 0.89843743, -0.85675972 - ]); - expect(xGrad.shape).toEqual([1, 2, 2, 2]); - expectArraysClose(await filtGrad.data(), [ - -1.00204261, 0.27276259, -1.00204261, 0.27276259, -2.99976385, 0.66119574, - -2.99976385, 0.66119574, -1.86705711, 1.27211472, -1.86705711, 1.27211472, - -1.81506593, 1.00900095, -1.81506593, 1.00900095 - ]); - expect(filtGrad.shape).toEqual([2, 2, 2, 2]); - }); - - it('throws when x is not rank 3', () => { - const origInputDepth = 1; - const origOutputDepth = 1; - const fSize = 2; - const origPad = 0; - const origStride = 1; - - // tslint:disable-next-line:no-any - const x: any = tf.tensor2d([2, 2], [2, 1]); - const w = tf.tensor4d( - [3, 1, 5, 0], [fSize, fSize, origInputDepth, origOutputDepth]); - - expect(() => tf.conv2dTranspose(x, w, [2, 2, 1], origStride, origPad)) - .toThrowError(); - }); - - it('throws when weights is not rank 4', () => { - const origInputDepth = 1; - const origOutputDepth = 1; - const inputShape: [number, number, number] = [1, 1, origOutputDepth]; - const fSize = 2; - const origPad = 0; - const origStride = 1; - - const x = tf.tensor3d([2], inputShape); - // tslint:disable-next-line:no-any - const w: any = tf.tensor3d([3, 1, 5, 0], [fSize, fSize, origInputDepth]); - - expect(() => tf.conv2dTranspose(x, w, [2, 2, 1], origStride, origPad)) - .toThrowError(); - }); - - it('throws when x depth does not match weights original output depth', () => { - const origInputDepth = 1; - const origOutputDepth = 2; - const wrongOrigOutputDepth = 3; - const inputShape: [number, number, number] = [1, 1, origOutputDepth]; - const fSize = 2; - const origPad = 0; - const origStride = 1; - - const x = tf.tensor3d([2, 2], inputShape); - const w = tf.randomNormal( - [fSize, fSize, origInputDepth, wrongOrigOutputDepth]); - - expect(() => tf.conv2dTranspose(x, w, [2, 2, 2], origStride, origPad)) - .toThrowError(); - }); - - it('throws when passed x as a non-tensor', () => { - const origInputDepth = 1; - const origOutputDepth = 1; - const fSize = 2; - const origPad = 0; - const origStride = 1; - - const w = tf.tensor4d( - [3, 1, 5, 0], [fSize, fSize, origInputDepth, origOutputDepth]); - - expect( - () => tf.conv2dTranspose( - {} as tf.Tensor3D, w, [2, 2, 1], origStride, origPad)) - .toThrowError( - /Argument 'x' passed to 'conv2dTranspose' must be a Tensor/); - }); - - it('throws when passed filter as a non-tensor', () => { - const origOutputDepth = 1; - const inputShape: [number, number, number] = [1, 1, origOutputDepth]; - const origPad = 0; - const origStride = 1; - - const x = tf.tensor3d([2], inputShape); - - expect( - () => tf.conv2dTranspose( - x, {} as tf.Tensor4D, [2, 2, 1], origStride, origPad)) - .toThrowError( - /Argument 'filter' passed to 'conv2dTranspose' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const origPad = 0; - const origStride = 1; - - const x = [[[2]]]; // 1x1x1 - const w = [[[[3]], [[1]]], [[[5]], [[0]]]]; // 2x2x1x1 - - const result = tf.conv2dTranspose(x, w, [2, 2, 1], origStride, origPad); - const expected = [6, 2, 10, 0]; - - expect(result.shape).toEqual([2, 2, 1]); - expectArraysClose(await result.data(), expected); - }); - - it('input=8x8x8,output=4x4x8,f=8,s=1,inDepth=8,p=same vec4', async () => { - const origInputDepth = 8; - const origOutputDepth = 8; - const inputShape: [number, number, number, number] = - [1, 8, 8, origOutputDepth]; - const fSize = 8; - const origPad = 'same'; - const origStride: [number, number] = [1, 1]; - const wShape: [number, number, number, number] = - [fSize, fSize, origInputDepth, origOutputDepth]; - - const inputData = []; - for (let i = 0; i < fSize * fSize * origInputDepth; i++) { - inputData.push(i % 5); - } - const wData = []; - for (let i = 0; i < fSize * fSize * origInputDepth * origOutputDepth; i++) { - wData.push(i % 5); - } - - const x = tf.tensor4d(inputData, inputShape); - const w = tf.tensor4d(wData, wShape); - const result = tf.conv2dTranspose( - x, w, [1, 4, 4, origInputDepth], origStride, origPad); - expect(result.shape).toEqual([1, 4, 4, 8]); - - const expected = [ - 512, 533, 469, 550, 506, 512, 533, 469, 550, 506, 512, 533, 469, 550, 506, - 512, 533, 469, 550, 506, 512, 533, 469, 550, 506, 512, 533, 469, 550, 506, - 512, 533, 506, 512, 533, 469, 550, 506, 512, 533, 469, 550, 506, 512, 533, - 469, 550, 506, 512, 533, 469, 550, 506, 512, 533, 469, 550, 506, 512, 533, - 469, 550, 506, 512, 550, 506, 512, 533, 469, 550, 506, 512, 533, 469, 550, - 506, 512, 533, 469, 550, 506, 512, 533, 469, 550, 506, 512, 533, 469, 550, - 506, 512, 533, 469, 550, 506, 469, 550, 506, 512, 533, 469, 550, 506, 512, - 533, 469, 550, 506, 512, 533, 469, 550, 506, 512, 533, 469, 550, 506, 512, - 533, 469, 550, 506, 512, 533, 469, 550 - ]; - expectArraysClose(await result.data(), expected); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/conv3d.ts b/tfjs-master/tfjs-core/src/ops/conv3d.ts deleted file mode 100644 index 7947f42d3..000000000 --- a/tfjs-master/tfjs-core/src/ops/conv3d.ts +++ /dev/null @@ -1,120 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {ENGINE} from '../engine'; -import {Conv3D, Conv3DAttrs, Conv3DInputs} from '../kernel_names'; -import {NamedAttrMap} from '../kernel_registry'; -import {Tensor4D, Tensor5D} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; -import * as util from '../util'; - -import {eitherStridesOrDilationsAreOne, stridesOrDilationsArePositive} from './conv_util'; -import {op} from './operation'; -import {reshape} from './reshape'; - -/** - * Computes a 3D convolution over the input x. - * - * @param x The input tensor, of rank 5 or rank 4, of shape - * `[batch, depth, height, width, channels]`. If rank 4, - * batch of 1 is assumed. - * @param filter The filter, rank 5, of shape - * `[filterDepth, filterHeight, filterWidth, inChannels, outChannels]`. - * inChannels must match between input and filter. - * @param strides The strides of the convolution: `[strideDepth, strideHeight, - * strideWidth]`. - * @param pad The type of padding algorithm. - * - `same` and stride 1: output will be of same size as input, - * regardless of filter size. - * - `valid`: output will be smaller than input if filter is larger - * than 1x1. - * - For more info, see this guide: - * [https://www.tensorflow.org/api_docs/python/tf/nn/convolution]( - * https://www.tensorflow.org/api_docs/python/tf/nn/convolution) - * @param dataFormat: An optional string from: "NDHWC", "NCDHW". Defaults to - * "NDHWC". Specify the data format of the input and output data. With the - * default format "NDHWC", the data is stored in the order of: [batch, - * depth, height, width, channels]. Only "NDHWC" is currently supported. - * @param dilations The dilation rates: `[dilationDepth, dilationHeight, - * dilationWidth]` in which we sample input values across the height - * and width dimensions in atrous convolution. Defaults to `[1, 1, 1]`. - * If `dilations` is a single number, then - * `dilationDepth == dilationHeight == dilationWidth`. If it is greater - * than 1, then all values of `strides` must be 1. - * - * @doc {heading: 'Operations', subheading: 'Convolution'} - */ -function conv3d_( - x: T|TensorLike, filter: Tensor5D|TensorLike, - strides: [number, number, number]|number, pad: 'valid'|'same', - dataFormat: 'NDHWC'|'NCDHW' = 'NDHWC', - dilations: [number, number, number]|number = [1, 1, 1]): T { - const $x = convertToTensor(x, 'x', 'conv3d'); - const $filter = convertToTensor(filter, 'filter', 'conv3d'); - - let x5D = $x as Tensor5D; - let reshapedTo5D = false; - - if ($x.rank === 4) { - reshapedTo5D = true; - x5D = reshape($x, [1, $x.shape[0], $x.shape[1], $x.shape[2], $x.shape[3]]); - } - util.assert( - x5D.rank === 5, - () => `Error in conv3d: input must be rank 5, but got rank ${x5D.rank}.`); - util.assert( - $filter.rank === 5, - () => `Error in conv3d: filter must be rank 5, but got rank ` + - `${$filter.rank}.`); - util.assert( - x5D.shape[4] === $filter.shape[3], - () => `Error in conv3d: depth of input (${x5D.shape[4]}) must match ` + - `input depth for filter ${$filter.shape[3]}.`); - util.assert( - eitherStridesOrDilationsAreOne(strides, dilations), - () => 'Error in conv3D: Either strides or dilations must be 1. ' + - `Got strides ${strides} and dilations '${dilations}'`); - util.assert( - dataFormat === 'NDHWC', - () => `Error in conv3d: got dataFormat of ${ - dataFormat} but only NDHWC is currently supported.`); - util.assert( - stridesOrDilationsArePositive(dilations), - () => 'Error in conv3D: Dilated rates should be larger than 0.'); - util.assert( - stridesOrDilationsArePositive(strides), - () => 'Error in conv3D: Strides should be larger than 0.'); - - const inputs: Conv3DInputs = {x: x5D, filter: $filter}; - - const attrs: Conv3DAttrs = {strides, pad, dataFormat, dilations}; - - // tslint:disable-next-line: no-unnecessary-type-assertion - const res = ENGINE.runKernel( - Conv3D, inputs as unknown as NamedTensorMap, - attrs as unknown as NamedAttrMap) as T; - - if (reshapedTo5D) { - return reshape( - res, [res.shape[1], res.shape[2], res.shape[3], res.shape[4]]) as - T; - } - return res; -} - -export const conv3d = /* @__PURE__ */ op({conv3d_}); diff --git a/tfjs-master/tfjs-core/src/ops/conv3d_backprop_filter.ts b/tfjs-master/tfjs-core/src/ops/conv3d_backprop_filter.ts deleted file mode 100644 index 22b0eba3e..000000000 --- a/tfjs-master/tfjs-core/src/ops/conv3d_backprop_filter.ts +++ /dev/null @@ -1,85 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {ENGINE} from '../engine'; -import {Conv3DBackpropFilterV2, Conv3DBackpropFilterV2Attrs, Conv3DBackpropFilterV2Inputs} from '../kernel_names'; -import {NamedAttrMap} from '../kernel_registry'; -import {Tensor4D, Tensor5D} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import * as util from '../util'; - -import {op} from './operation'; -import {reshape} from './reshape'; - -/** - * Computes the derivative of the filter of a 3D convolution. - * - * @param x The input tensor, of rank 5 or rank 4 of shape - * [batch, depth, height, width, inChannels]. If rank 4, batch of 1 is - * assumed. - * @param dy The dy image, of rank 5 or rank 4, of shape - * [batch, depth, height, width, outDepth]. If rank 4, batch of 1 is - * assumed. - * @param filterShape The shape of the filter, length 5, - * [filterDepth, filterHeight, filterWidth, inDepth, outDepth]. - * @param strides The strides of the convolution: [strideDepth, strideHeight, - * strideWidth]. - * @param pad A string from: 'same', 'valid'. The type of padding algorithm - * used in the forward prop of the op. - */ -function conv3DBackpropFilter_( - x: T, dy: T, filterShape: [number, number, number, number, number], - strides: [number, number, number]|number, pad: 'valid'|'same'): Tensor5D { - let x5D = x as Tensor5D; - if (x.rank === 4) { - x5D = reshape(x, [1, x.shape[0], x.shape[1], x.shape[2], x.shape[3]]); - } - let dy5D = dy as Tensor5D; - if (dy5D.rank === 4) { - dy5D = reshape(dy, [1, dy.shape[0], dy.shape[1], dy.shape[2], dy.shape[3]]); - } - util.assert( - x5D.rank === 5, - () => `Error in conv3dDerFilter: input must be rank 5, but got shape ` + - `${x5D.shape}.`); - util.assert( - dy5D.rank === 5, - () => `Error in conv3dDerFilter: dy must be rank 5, but got shape ` + - `${dy5D.shape}.`); - util.assert( - filterShape.length === 5, - () => `Error in conv3dDerFilter: filterShape must be length 5, but got ` + - `${filterShape}.`); - util.assert( - x5D.shape[4] === filterShape[3], - () => `Error in conv3dDerFilter: depth of input ${x5D.shape[4]}) must ` + - `match input depth in filter (${filterShape[3]}.`); - util.assert( - dy5D.shape[4] === filterShape[4], - () => `Error in conv3dDerFilter: depth of dy (${dy5D.shape[4]}) must ` + - `match output depth for filter (${filterShape[4]}).`); - - const inputs: Conv3DBackpropFilterV2Inputs = {x: x5D, dy: dy5D}; - - const attrs: Conv3DBackpropFilterV2Attrs = {strides, pad, filterShape}; - - // tslint:disable-next-line: no-unnecessary-type-assertion - return ENGINE.runKernel( - Conv3DBackpropFilterV2, inputs as unknown as NamedTensorMap, - attrs as unknown as NamedAttrMap) as Tensor5D; -} - -export const conv3DBackpropFilter = /* @__PURE__ */ op({conv3DBackpropFilter_}); diff --git a/tfjs-master/tfjs-core/src/ops/conv3d_backprop_input.ts b/tfjs-master/tfjs-core/src/ops/conv3d_backprop_input.ts deleted file mode 100644 index 976c30ebb..000000000 --- a/tfjs-master/tfjs-core/src/ops/conv3d_backprop_input.ts +++ /dev/null @@ -1,107 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {ENGINE} from '../engine'; -import {Conv3DBackpropInputV2, Conv3DBackpropInputV2Attrs, Conv3DBackpropInputV2Inputs} from '../kernel_names'; -import {NamedAttrMap} from '../kernel_registry'; -import {Tensor4D, Tensor5D} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import * as util from '../util'; - -import {op} from './operation'; -import {reshape} from './reshape'; - -/** - * Computes the derivative of the input of a 3D convolution. - * - * @param xShape The shape of the input: [batch, depth, height, width, - * in_channels]. If length of 4, batch of 1 is assumed. - * @param dy The derivative of the output, of rank 5 or rank 4 of shape - * `[batch, outDepth, outHeight, outWidth, in_channels]`. - * If rank 4, batch of 1 is assumed. - * @param filter The filter, rank 5, of shape - * `[filterDepth, filterHeight, filterWidth, inDepth, outDepth]`. - * @param strides The strides of the convolution: `[strideDepth, strideHeight, - * strideWidth]`. - * @param pad The type of padding algorithm used: - * - `same` and stride 1: output will be of same size as input, - * regardless of filter size. - * - `valid`: output will be smaller than input if filter is larger - * than 1x1. - */ -function conv3DBackpropInput_( - xShape: - [number, number, number, number, - number]|[number, number, number, number], - dy: T, filter: Tensor5D, strides: [number, number, number]|number, - pad: 'valid'|'same'): T { - util.assert( - xShape.length === dy.rank, - () => `Length of inShape ` + - `(${xShape.length}) and rank of dy (${dy.rank}) must match`); - - let xShape5D = xShape as [number, number, number, number, number]; - let dy5D = dy as Tensor5D; - let reshapedTo5D = false; - if (dy.rank === 4) { - reshapedTo5D = true; - dy5D = reshape(dy, [1, dy.shape[0], dy.shape[1], dy.shape[2], dy.shape[3]]); - xShape5D = [1, xShape[0], xShape[1], xShape[2], xShape[3]]; - } - - const inDepth = xShape5D[4]; - const outDepth = dy5D.shape[4]; - util.assert( - xShape5D.length === 5, - () => - `Error in conv3dDerInput: inShape must be length 5, but got length ` + - `${xShape5D.length}.`); - util.assert( - dy5D.rank === 5, - () => `Error in conv3dDerInput: dy must be rank 5, but got ` + - `rank ${dy5D.rank}`); - util.assert( - filter.rank === 5, - () => `Error in conv3dDerInput: filter must be rank 5, but got ` + - `rank ${filter.rank}`); - util.assert( - inDepth === filter.shape[3], - () => `Error in conv3dDerInput: depth of input (${inDepth}) must ` + - `match input depth for filter ${filter.shape[3]}.`); - util.assert( - outDepth === filter.shape[4], - () => `Error in conv3dDerInput: depth of output (${outDepth}) must ` + - `match output depth for filter ${filter.shape[4]}.`); - - const inputs: Conv3DBackpropInputV2Inputs = {dy: dy5D, filter}; - - const attrs: - Conv3DBackpropInputV2Attrs = {pad, strides, inputShape: xShape5D}; - - // tslint:disable-next-line: no-unnecessary-type-assertion - const res = ENGINE.runKernel( - Conv3DBackpropInputV2, inputs as unknown as NamedTensorMap, - attrs as unknown as NamedAttrMap) as T; - - if (reshapedTo5D) { - return reshape( - res, [res.shape[1], res.shape[2], res.shape[3], res.shape[4]]) as - T; - } - return res; -} - -export const conv3DBackpropInput = /* @__PURE__ */ op({conv3DBackpropInput_}); diff --git a/tfjs-master/tfjs-core/src/ops/conv3d_test.ts b/tfjs-master/tfjs-core/src/ops/conv3d_test.ts deleted file mode 100644 index 2681796d1..000000000 --- a/tfjs-master/tfjs-core/src/ops/conv3d_test.ts +++ /dev/null @@ -1,518 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {Tensor5D} from '../tensor'; -import {expectArraysClose} from '../test_util'; -import {sizeFromShape} from '../util'; - -// Generates small floating point inputs to avoid overflows -function generateCaseInputs(totalSizeTensor: number, totalSizeFilter: number) { - const inp = new Array(totalSizeTensor); - const filt = new Array(totalSizeFilter); - - for (let i = 0; i < totalSizeTensor; i++) { - inp[i] = (i + 1) / totalSizeTensor; - } - for (let i = 0; i < totalSizeFilter; i++) { - filt[i] = (i + 1) / totalSizeFilter; - } - - return {input: inp, filter: filt}; -} - -function generateGradientCaseInputs( - totalSizeTensor: number, totalSizeFilter: number) { - const inp = new Array(totalSizeTensor); - const filt = new Array(totalSizeFilter); - - for (let i = 0; i < totalSizeTensor; i++) { - inp[i] = i + 1; - } - for (let i = 0; i < totalSizeFilter; i++) { - filt[i] = i + 1; - } - - return {input: inp, filter: filt}; -} - -function runConv3DTestCase( - batch: number, inDepth: number, inHeight: number, inWidth: number, - inChannels: number, outChannels: number, fDepth: number, fHeight: number, - fWidth: number, pad: 'valid'|'same', - stride: [number, number, number]|number) { - const inputShape: [number, number, number, number, number] = - [batch, inDepth, inHeight, inWidth, inChannels]; - const filterShape: [number, number, number, number, number] = - [fDepth, fHeight, fWidth, inChannels, outChannels]; - - const totalSizeTensor = sizeFromShape(inputShape); - const totalSizeFilter = sizeFromShape(filterShape); - const inputs = generateCaseInputs(totalSizeTensor, totalSizeFilter); - - const x = tf.tensor5d(inputs.input, inputShape); - const w = tf.tensor5d(inputs.filter, filterShape); - - const result = tf.conv3d(x, w, stride, pad); - return result; -} - -function runGradientConv3DTestCase( - batch: number, inDepth: number, inHeight: number, inWidth: number, - inChannels: number, outChannels: number, fDepth: number, fHeight: number, - fWidth: number, pad: 'valid'|'same', - stride: [number, number, number]|number) { - const inputShape: [number, number, number, number, number] = - [batch, inDepth, inHeight, inWidth, inChannels]; - const filterShape: [number, number, number, number, number] = - [fDepth, fHeight, fWidth, inChannels, outChannels]; - - const totalSizeTensor = sizeFromShape(inputShape); - const totalSizeFilter = sizeFromShape(filterShape); - const inputs = generateGradientCaseInputs(totalSizeTensor, totalSizeFilter); - - const x = tf.tensor5d(inputs.input, inputShape); - const w = tf.tensor5d(inputs.filter, filterShape); - - const grads = tf.grads( - (x: Tensor5D, filter: Tensor5D) => - tf.conv3d(x.clone(), filter.clone(), stride, pad).clone()); - const [dx, dfilter] = grads([x, w]); - - expect(dx.shape).toEqual(x.shape); - expect(dfilter.shape).toEqual(w.shape); - - return [dx, dfilter]; -} - -describeWithFlags('conv3d', ALL_ENVS, () => { - it('x=[1, 2, 3, 1, 3] f=[1, 1, 1, 3, 3] s=1 d=1 p=valid', async () => { - const batch = 1; - const inDepth = 2; - const inHeight = 3; - const inWidth = 1; - const inChannels = 3; - const outChannels = 3; - const fSize = 1; - const pad = 'valid'; - const stride = 1; - const result = runConv3DTestCase( - batch, inDepth, inHeight, inWidth, inChannels, outChannels, fSize, - fSize, fSize, pad, stride); - - const expectedOutput = [ - 0.18518519, 0.22222222, 0.25925926, 0.40740741, 0.5, 0.59259259, - 0.62962963, 0.77777778, 0.92592593, 0.85185185, 1.05555556, 1.25925926, - 1.07407407, 1.33333333, 1.59259259, 1.2962963, 1.61111111, 1.92592593 - ]; - - expectArraysClose(await result.data(), expectedOutput); - }); - it('x=[1, 2, 1, 3, 3] f=[1, 1, 1, 3, 3] s=1 d=1 p=valid', async () => { - const batch = 1; - const inDepth = 2; - const inHeight = 1; - const inWidth = 3; - const inChannels = 3; - const outChannels = 3; - const fSize = 1; - const pad = 'valid'; - const stride = 1; - const result = runConv3DTestCase( - batch, inDepth, inHeight, inWidth, inChannels, outChannels, fSize, - fSize, fSize, pad, stride); - - const expectedOutput = [ - 0.18518519, 0.22222222, 0.25925926, 0.40740741, 0.5, 0.59259259, - 0.62962963, 0.77777778, 0.92592593, 0.85185185, 1.05555556, 1.25925926, - 1.07407407, 1.33333333, 1.59259259, 1.2962963, 1.61111111, 1.92592593 - ]; - - expectArraysClose(await result.data(), expectedOutput); - }); - - it('x=[1, 1, 2, 3, 3] f=[1, 1, 1, 3, 3] s=1 d=1 p=valid', async () => { - const batch = 1; - const inDepth = 1; - const inHeight = 2; - const inWidth = 3; - const inChannels = 3; - const outChannels = 3; - const fSize = 1; - const pad = 'valid'; - const stride = 1; - const result = runConv3DTestCase( - batch, inDepth, inHeight, inWidth, inChannels, outChannels, fSize, - fSize, fSize, pad, stride); - - const expectedOutput = [ - 0.18518519, 0.22222222, 0.25925926, 0.40740741, 0.5, 0.59259259, - 0.62962963, 0.77777778, 0.92592593, 0.85185185, 1.05555556, 1.25925926, - 1.07407407, 1.33333333, 1.59259259, 1.2962963, 1.61111111, 1.92592593 - ]; - - expectArraysClose(await result.data(), expectedOutput); - }); - - it('x=[1, 4, 2, 3, 3] f=[2, 2, 2, 3, 3] s=1 d=1 p=valid', async () => { - const batch = 1; - const inDepth = 4; - const inHeight = 2; - const inWidth = 3; - const inChannels = 3; - const outChannels = 3; - const fSize = 2; - const pad = 'valid'; - const stride = 1; - const result = runConv3DTestCase( - batch, inDepth, inHeight, inWidth, inChannels, outChannels, fSize, - fSize, fSize, pad, stride); - - const expectedOutput = [ - 3.77199074, 3.85069444, 3.92939815, 4.2650463, 4.35763889, 4.45023148, - 6.73032407, 6.89236111, 7.05439815, 7.22337963, 7.39930556, 7.57523148, - 9.68865741, 9.93402778, 10.17939815, 10.18171296, 10.44097222, 10.70023148 - ]; - - expectArraysClose(await result.data(), expectedOutput); - }); - - it('x=[1, 5, 8, 7, 1] f=[1, 2, 3, 1, 1] s=[2, 3, 1] d=1 p=same', async () => { - const batch = 1; - const inDepth = 5; - const inHeight = 8; - const inWidth = 7; - const inChannels = 1; - const outChannels = 1; - const fDepth = 1; - const fHeight = 2; - const fWidth = 3; - const pad = 'same'; - const stride: [number, number, number] = [2, 3, 1]; - const result = runConv3DTestCase( - batch, inDepth, inHeight, inWidth, inChannels, outChannels, fDepth, - fHeight, fWidth, pad, stride); - - const expectedOutput = [ - 0.06071429, 0.08988095, 0.10238095, 0.11488095, 0.12738095, 0.13988095, - 0.08452381, 0.26071429, 0.35238095, 0.36488095, 0.37738095, 0.38988095, - 0.40238095, 0.23452381, 0.46071429, 0.61488095, 0.62738095, 0.63988095, - 0.65238095, 0.66488095, 0.38452381, 1.12738095, 1.48988095, 1.50238095, - 1.51488095, 1.52738095, 1.53988095, 0.88452381, 1.32738095, 1.75238095, - 1.76488095, 1.77738095, 1.78988095, 1.80238095, 1.03452381, 1.52738095, - 2.01488095, 2.02738095, 2.03988095, 2.05238095, 2.06488095, 1.18452381, - 2.19404762, 2.88988095, 2.90238095, 2.91488095, 2.92738095, 2.93988095, - 1.68452381, 2.39404762, 3.15238095, 3.16488095, 3.17738095, 3.18988095, - 3.20238095, 1.83452381, 2.59404762, 3.41488095, 3.42738095, 3.43988095, - 3.45238095, 3.46488095, 1.98452381 - ]; - - expectArraysClose(await result.data(), expectedOutput); - }); - - it('x=[1, 4, 2, 3, 3] f=[2, 2, 2, 3, 3] s=2 d=1 p=valid', async () => { - const batch = 1; - const inDepth = 4; - const inHeight = 2; - const inWidth = 3; - const inChannels = 3; - const outChannels = 3; - const fSize = 2; - const pad = 'valid'; - const stride = 2; - const result = runConv3DTestCase( - batch, inDepth, inHeight, inWidth, inChannels, outChannels, fSize, - fSize, fSize, pad, stride); - - const expectedOutput = [ - 3.77199074, 3.85069444, 3.92939815, 9.68865741, 9.93402778, 10.17939815 - ]; - - expectArraysClose(await result.data(), expectedOutput); - }); - - it('x=[1, 6, 7, 8, 2] f=[3, 2, 1, 2, 3] s=3 d=1 p=valid', async () => { - const batch = 1; - const inDepth = 6; - const inHeight = 7; - const inWidth = 8; - const inChannels = 2; - const outChannels = 3; - const fDepth = 3; - const fHeight = 2; - const fWidth = 1; - const pad = 'valid'; - const stride = 3; - const result = runConv3DTestCase( - batch, inDepth, inHeight, inWidth, inChannels, outChannels, fDepth, - fHeight, fWidth, pad, stride); - - const expectedOutput = [ - 1.51140873, 1.57167659, 1.63194444, 1.56349206, 1.62673611, 1.68998016, - 1.6155754, 1.68179563, 1.74801587, 1.9280754, 2.01215278, 2.09623016, - 1.98015873, 2.0672123, 2.15426587, 2.03224206, 2.12227183, 2.21230159, - 4.4280754, 4.65500992, 4.88194444, 4.48015873, 4.71006944, 4.93998016, - 4.53224206, 4.76512897, 4.99801587, 4.84474206, 5.09548611, 5.34623016, - 4.8968254, 5.15054563, 5.40426587, 4.94890873, 5.20560516, 5.46230159 - ]; - - expectArraysClose(await result.data(), expectedOutput); - }); - - it('x=[1, 4, 2, 3, 3] f=[2, 2, 2, 3, 3] s=2 d=1 p=same', async () => { - const batch = 1; - const inDepth = 4; - const inHeight = 2; - const inWidth = 3; - const inChannels = 3; - const outChannels = 3; - const fSize = 2; - const pad = 'same'; - const stride = 2; - const result = runConv3DTestCase( - batch, inDepth, inHeight, inWidth, inChannels, outChannels, fSize, - fSize, fSize, pad, stride); - - const expectedOutput = [ - 3.77199074, 3.85069444, 3.92939815, 2.0162037, 2.06597222, 2.11574074, - 9.68865741, 9.93402778, 10.17939815, 4.59953704, 4.73263889, 4.86574074 - ]; - - expectArraysClose(await result.data(), expectedOutput); - }); - - it('x=[1, 3, 3, 3, 1] f=[1, 1, 1, 1, 1] s=2 d=1 p=same', async () => { - const batch = 1; - const inDepth = 3; - const inHeight = 3; - const inWidth = 3; - const inChannels = 1; - const outChannels = 1; - const fSize = 1; - const pad = 'same'; - const stride = 2; - const result = runConv3DTestCase( - batch, inDepth, inHeight, inWidth, inChannels, outChannels, fSize, - fSize, fSize, pad, stride); - - const expectedOutput = [ - 0.03703704, 0.11111111, 0.25925926, 0.33333333, 0.7037037, 0.77777778, - 0.92592593, 1. - ]; - - expectArraysClose(await result.data(), expectedOutput); - }); - - it('x=[1, 3, 3, 3, 1] f=[1, 1, 1, 1, 1] s=2 d=1 p=valid', async () => { - const batch = 1; - const inDepth = 3; - const inHeight = 3; - const inWidth = 3; - const inChannels = 1; - const outChannels = 1; - const fSize = 1; - const pad = 'valid'; - const stride = 2; - const result = runConv3DTestCase( - batch, inDepth, inHeight, inWidth, inChannels, outChannels, fSize, - fSize, fSize, pad, stride); - - const expectedOutput = [ - 0.03703704, 0.11111111, 0.25925926, 0.33333333, 0.7037037, 0.77777778, - 0.92592593, 1. - ]; - - expectArraysClose(await result.data(), expectedOutput); - }); - - it('x=[1, 7, 7, 7, 1] f=[2, 2, 2, 1, 1] s=3 d=1 p=same', async () => { - const batch = 1; - const inDepth = 7; - const inHeight = 7; - const inWidth = 7; - const inChannels = 1; - const outChannels = 1; - const fSize = 2; - const pad = 'same'; - const stride = 3; - const result = runConv3DTestCase( - batch, inDepth, inHeight, inWidth, inChannels, outChannels, fSize, - fSize, fSize, pad, stride); - - const expectedOutput = [ - 0.54081633, 0.58017493, 0.28061224, 0.81632653, 0.85568513, 0.40306122, - 0.41873178, 0.4340379, 0.19642857, 2.46938776, 2.50874636, 1.1377551, - 2.74489796, 2.78425656, 1.26020408, 1.16873178, 1.1840379, 0.51785714, - 1.09511662, 1.10604956, 0.44642857, 1.17164723, 1.18258017, 0.47704082, - 0.3691691, 0.37244898, 0.125 - ]; - - expectArraysClose(await result.data(), expectedOutput); - }); - - it('x=[1, 7, 7, 7, 1] f=[2, 2, 2, 1, 1] s=3 d=1 p=valid', async () => { - const batch = 1; - const inDepth = 7; - const inHeight = 7; - const inWidth = 7; - const inChannels = 1; - const outChannels = 1; - const fSize = 2; - const pad = 'valid'; - const stride = 3; - const result = runConv3DTestCase( - batch, inDepth, inHeight, inWidth, inChannels, outChannels, fSize, - fSize, fSize, pad, stride); - - const expectedOutput = [ - 0.540816, 0.580175, 0.816327, 0.855685, 2.469388, 2.508746, 2.744898, - 2.784257 - ]; - - expectArraysClose(await result.data(), expectedOutput); - }); - - it('x=[1, 2, 1, 2, 1] f=[2, 1, 2, 1, 2] s=1 d=1 p=valid', async () => { - const batch = 1; - const inDepth = 2; - const inHeight = 1; - const inWidth = 2; - const inChannels = 1; - const outChannels = 2; - const fDepth = 2; - const fHeight = 1; - const fWidth = 2; - const pad = 'valid'; - const stride = 1; - const result = runConv3DTestCase( - batch, inDepth, inHeight, inWidth, inChannels, outChannels, fDepth, - fHeight, fWidth, pad, stride); - - const expectedOutput = [1.5625, 1.875]; - - expectArraysClose(await result.data(), expectedOutput); - }); - - it('gradient with clones, x=[1,3,6,1,1] filter=[2,2,1,1,1] s=1 d=1 p=valid', - async () => { - const batch = 1; - const inDepth = 3; - const inHeight = 6; - const inWidth = 1; - const inChannels = 1; - const outChannels = 1; - const fDepth = 2; - const fHeight = 2; - const fWidth = 1; - const pad = 'valid'; - const stride = 1; - const [dx, dfilter] = runGradientConv3DTestCase( - batch, inDepth, inHeight, inWidth, inChannels, outChannels, fDepth, - fHeight, fWidth, pad, stride); - - const expectedFilterOutput = [60.0, 70.0, 120.0, 130.0]; - const expectedOutput = [ - 1.0, 3.0, 3.0, 3.0, 3.0, 2.0, 4.0, 10.0, 10.0, 10.0, 10.0, 6.0, 3.0, - 7.0, 7.0, 7.0, 7.0, 4.0 - ]; - expectArraysClose(await dx.data(), expectedOutput); - expectArraysClose(await dfilter.data(), expectedFilterOutput); - }); - - it('throws when passed x as a non-tensor', () => { - const inputDepth = 1; - const outputDepth = 1; - const fSize = 1; - const pad = 'valid'; - const stride = 1; - - const w = tf.tensor5d([2], [fSize, fSize, fSize, inputDepth, outputDepth]); - - expect(() => tf.conv3d({} as tf.Tensor4D, w, stride, pad)) - .toThrowError(/Argument 'x' passed to 'conv3d' must be a Tensor/); - }); - - it('throws when passed filter as a non-tensor', () => { - const inputDepth = 1; - const inputShape: [number, number, number, number] = [2, 2, 1, inputDepth]; - const pad = 'valid'; - const stride = 1; - - const x = tf.tensor4d([1, 2, 3, 4], inputShape); - - expect(() => tf.conv3d(x, {} as Tensor5D, stride, pad)) - .toThrowError(/Argument 'filter' passed to 'conv3d' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const pad = 'valid'; - const stride = 1; - const x = [[[[1], [2]], [[3], [4]]]]; // 2x2x1x1 - const w = [[[[[2]]]]]; // 1x1x1x1x1 - - const result = tf.conv3d(x, w, stride, pad); - expectArraysClose(await result.data(), [2, 4, 6, 8]); - }); - - it('throws when data format not NDHWC', () => { - const inputDepth = 1; - const outputDepth = 1; - const inputShape: [number, number, number, number] = [2, 2, 1, inputDepth]; - const pad = 'valid'; - const fSize = 1; - const stride = 1; - const dataFormat = 'NCDHW'; - - const x = tf.tensor4d([1, 2, 3, 4], inputShape); - const w = tf.tensor5d([2], [fSize, fSize, fSize, inputDepth, outputDepth]); - - expect(() => tf.conv3d(x, w, stride, pad, dataFormat)).toThrowError(); - }); - - it('throws when stride is less than or equal to 0', async () => { - const inputDepth = 1; - const outputDepth = 1; - const inputShape: [number, number, number, number] = [2, 2, 1, inputDepth]; - const pad = 'valid'; - const fSize = 1; - const stride = 0; - const dataFormat = 'NDHWC'; - - const x = tf.tensor4d([1, 2, 3, 4], inputShape); - const w = tf.tensor5d([2], [fSize, fSize, fSize, inputDepth, outputDepth]); - - expect(() => tf.conv3d(x, w, stride, pad, dataFormat)).toThrowError(); - }); - - it('throws when dilation is less than or equal to 0', async () => { - const inputDepth = 1; - const outputDepth = 1; - const inputShape: [number, number, number, number] = [2, 2, 1, inputDepth]; - const pad = 'valid'; - const fSize = 1; - const stride = 0; - const dataFormat = 'NDHWC'; - const dilation: [number, number, number] = [1, 1, 0]; - - const x = tf.tensor4d([1, 2, 3, 4], inputShape); - const w = tf.tensor5d([2], [fSize, fSize, fSize, inputDepth, outputDepth]); - - expect(() => tf.conv3d(x, w, stride, pad, dataFormat, dilation)) - .toThrowError(); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/conv3d_transpose.ts b/tfjs-master/tfjs-core/src/ops/conv3d_transpose.ts deleted file mode 100644 index 09e474cde..000000000 --- a/tfjs-master/tfjs-core/src/ops/conv3d_transpose.ts +++ /dev/null @@ -1,55 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {Tensor4D, Tensor5D} from '../tensor'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -import {conv3DBackpropInput} from './conv3d_backprop_input'; -import {op} from './operation'; - -/** - * Computes the transposed 3D convolution of a volume, also known as a - * deconvolution. - * - * @param x The input image, of rank 5 or rank 4, of shape - * `[batch, depth, height, width, inDepth]`. If rank 4, batch of 1 is assumed. - * @param filter The filter, rank 4, of shape - * `[depth, filterHeight, filterWidth, outDepth, inDepth]`. - * `inDepth` must match `inDepth` in `x`. - * @param outputShape Output shape, of rank 5 or rank 4: - * `[batch, depth, height, width, outDepth]`. If rank 3, batch of 1 is - * assumed. - * @param strides The strides of the original convolution: - * `[strideDepth, strideHeight, strideWidth]`. - * @param pad The type of padding algorithm used in the non-transpose version - * of the op. - * - * @doc {heading: 'Operations', subheading: 'Convolution'} - */ -function conv3dTranspose_( - x: T|TensorLike, filter: Tensor5D|TensorLike, - outputShape: - [number, number, number, number, - number]|[number, number, number, number], - strides: [number, number, number]|number, pad: 'valid'|'same'): T { - const $x = convertToTensor(x, 'x', 'conv3dTranspose'); - const $filter = convertToTensor(filter, 'filter', 'conv3dTranspose'); - - return conv3DBackpropInput(outputShape, $x, $filter, strides, pad); -} - -export const conv3dTranspose = /* @__PURE__ */ op({conv3dTranspose_}); diff --git a/tfjs-master/tfjs-core/src/ops/conv3d_transpose_test.ts b/tfjs-master/tfjs-core/src/ops/conv3d_transpose_test.ts deleted file mode 100644 index c2064e713..000000000 --- a/tfjs-master/tfjs-core/src/ops/conv3d_transpose_test.ts +++ /dev/null @@ -1,85 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('conv3dTranspose', ALL_ENVS, () => { - // Reference Python TensorFlow code - // ```python - // import numpy as np - // import tensorflow as tf - // tf.enable_eager_execution() - // x = np.array([2], dtype = np.float32).reshape(1, 1, 1, 1, 1) - // w = np.array([5, 4, 8, 7, 1, 2, 6, 3], dtype = np.float32).reshape(2, 2, 2, - // 1, 1) - // tf.nn.conv3d_transpose(x, w, output_shape=[1, 2, 2, 2, 1], padding='VALID') - // ``` - it('input=2x2x2x1,d2=1,f=2,s=1,p=valid', async () => { - const origInputDepth = 1; - const origOutputDepth = 1; - const inputShape: [number, number, number, number] = - [1, 1, 1, origOutputDepth]; - const fSize = 2; - const origPad = 'valid'; - const origStride = 1; - - const x = tf.tensor4d([2], inputShape); - const w = tf.tensor5d( - [5, 4, 8, 7, 1, 2, 6, 3], - [fSize, fSize, fSize, origInputDepth, origOutputDepth]); - - const result = tf.conv3dTranspose(x, w, [2, 2, 2, 1], origStride, origPad); - const expected = [10, 8, 16, 14, 2, 4, 12, 6]; - - expect(result.shape).toEqual([2, 2, 2, 1]); - expectArraysClose(await result.data(), expected); - }); - - // Reference Python TensorFlow code - // ```python - // import numpy as np - // import tensorflow as tf - // tf.enable_eager_execution() - // x = np.array([2, 3], dtype = np.float32).reshape(2, 1, 1, 1, 1, 1) - // w = np.array([5, 4, 8, 7, 1, 2, 6, 3], dtype = np.float32).reshape(2, - // 2, 2, 1, 1) - // tf.nn.conv3d_transpose(x, w, output_shape=[2, 2, 2, 2, 1], padding='VALID') - // ``` - it('input=2x2x2x1,d2=1,f=2,s=1,p=valid, batch=2', async () => { - const origInputDepth = 1; - const origOutputDepth = 1; - const inputShape: [number, number, number, number, number] = - [2, 1, 1, 1, origOutputDepth]; - const fSize = 2; - const origPad = 'valid'; - const origStride = 1; - - const x = tf.tensor5d([2, 3], inputShape); - const w = tf.tensor5d( - [5, 4, 8, 7, 1, 2, 6, 3], - [fSize, fSize, fSize, origInputDepth, origOutputDepth]); - - const result = - tf.conv3dTranspose(x, w, [2, 2, 2, 2, 1], origStride, origPad); - const expected = [10, 8, 16, 14, 2, 4, 12, 6, 15, 12, 24, 21, 3, 6, 18, 9]; - - expect(result.shape).toEqual([2, 2, 2, 2, 1]); - expectArraysClose(await result.data(), expected); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/conv_util.ts b/tfjs-master/tfjs-core/src/ops/conv_util.ts deleted file mode 100644 index 93ef7efcc..000000000 --- a/tfjs-master/tfjs-core/src/ops/conv_util.ts +++ /dev/null @@ -1,640 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as util from '../util'; - -type PadType = 'SAME'|'VALID'|'NUMBER'|'EXPLICIT'; - -// For NHWC should be in the following form: -// [[0, 0], [pad_top,pad_bottom], [pad_left, pad_right], [0, 0]] -// For NCHW should be in the following form: -// [[0, 0], [0, 0], [pad_top,pad_bottom], [pad_left, pad_right]] -// Reference: https://www.tensorflow.org/api_docs/python/tf/nn/conv2d -export type ExplicitPadding = - [[number, number], [number, number], [number, number], [number, number]]; - -export type PadInfo = { - top: number, - left: number, - right: number, - bottom: number, - type: PadType -}; - -export type PadInfo3D = { - top: number, - left: number, - right: number, - bottom: number, - front: number, - back: number, - type: PadType -}; - -/** - * Information about the forward pass of a convolution/pooling operation. - * It includes input and output shape, strides, filter size and padding - * information. - */ -export type Conv2DInfo = { - batchSize: number, - inHeight: number, - inWidth: number, - inChannels: number, - outHeight: number, - outWidth: number, - outChannels: number, - dataFormat: 'channelsFirst'|'channelsLast', - strideHeight: number, - strideWidth: number, - dilationHeight: number, - dilationWidth: number, - filterHeight: number, - filterWidth: number, - effectiveFilterHeight: number, - effectiveFilterWidth: number, - padInfo: PadInfo, - inShape: [number, number, number, number], - outShape: [number, number, number, number], - filterShape: [number, number, number, number] -}; - -/** - * - * @param inputShape Input tensor shape is of the following dimensions: - * `[batch, height, width, inChannels]`. - * @param filterShape The filter shape is of the following dimensions: - * `[filterHeight, filterWidth, depth]`. - * @param strides The strides of the sliding window for each dimension of the - * input tensor: `[strideHeight, strideWidth]`. - * If `strides` is a single number, - * then `strideHeight == strideWidth`. - * @param pad The type of padding algorithm. - * - `same` and stride 1: output will be of same size as input, - * regardless of filter size. - * - `valid`: output will be smaller than input if filter is larger - * than 1*1x1. - * - For more info, see this guide: - * [https://www.tensorflow.org/api_docs/python/tf/nn/convolution]( - * https://www.tensorflow.org/api_docs/python/tf/nn/convolution) - * @param dataFormat The data format of the input and output data. - * Defaults to 'NHWC'. - * @param dilations The dilation rates: `[dilationHeight, dilationWidth]`. - * Defaults to `[1, 1]`. If `dilations` is a single number, then - * `dilationHeight == dilationWidth`. - */ -export function computeDilation2DInfo( - inputShape: [number, number, number, number], - filterShape: [number, number, number], strides: number|[number, number], - pad: 'same'|'valid'|number, dataFormat: 'NHWC' = 'NHWC', - dilations: number|[number, number]) { - // `computerConv2DInfo` require filterShape to be in the dimension of: - // `[filterHeight, filterWidth, depth, outDepth]`, dilation2d doesn't have - // outDepth, it should have the same depth as the input. - // Input shape: [batch, height, width, inChannels] - const inputChannels = inputShape[3]; - const $filterShape = - [...filterShape, inputChannels] as [number, number, number, number]; - const $dataFormat = convertConv2DDataFormat(dataFormat); - - return computeConv2DInfo( - inputShape, $filterShape, strides, dilations, pad, - null /* roundingMode */, null /* depthWise */, $dataFormat); -} - -export function computePool2DInfo( - inShape: [number, number, number, number], - filterSize: [number, number]|number, strides: number|[number, number], - dilations: number|[number, number], - pad: 'same'|'valid'|number|ExplicitPadding, - roundingMode?: 'floor'|'round'|'ceil', - dataFormat: 'channelsFirst'|'channelsLast' = 'channelsLast'): Conv2DInfo { - const [filterHeight, filterWidth] = parseTupleParam(filterSize); - - let filterShape: [number, number, number, number]; - if (dataFormat === 'channelsLast') { - filterShape = [filterHeight, filterWidth, inShape[3], inShape[3]]; - } else if (dataFormat === 'channelsFirst') { - filterShape = [filterHeight, filterWidth, inShape[1], inShape[1]]; - } else { - throw new Error(`Unknown dataFormat ${dataFormat}`); - } - - return computeConv2DInfo( - inShape, filterShape, strides, dilations, pad, roundingMode, false, - dataFormat); -} - -/** - * Computes the information for a forward pass of a pooling3D operation. - */ -export function computePool3DInfo( - inShape: [number, number, number, number, number], - filterSize: number|[number, number, number], - strides: number|[number, number, number], - dilations: number|[number, number, number], pad: 'same'|'valid'|number, - roundingMode?: 'floor'|'round'|'ceil', - dataFormat: 'NDHWC'|'NCDHW' = 'NDHWC'): Conv3DInfo { - const [filterDepth, filterHeight, filterWidth] = parse3TupleParam(filterSize); - - let filterShape: [number, number, number, number, number]; - let $dataFormat: 'channelsFirst'|'channelsLast'; - if (dataFormat === 'NDHWC') { - $dataFormat = 'channelsLast'; - filterShape = - [filterDepth, filterHeight, filterWidth, inShape[4], inShape[4]]; - } else if (dataFormat === 'NCDHW') { - $dataFormat = 'channelsFirst'; - filterShape = - [filterDepth, filterHeight, filterWidth, inShape[1], inShape[1]]; - } else { - throw new Error(`Unknown dataFormat ${dataFormat}`); - } - - return computeConv3DInfo( - inShape, filterShape, strides, dilations, pad, false, $dataFormat, - roundingMode); -} - -/** - * Computes the information for a forward pass of a convolution/pooling - * operation. - */ -export function computeConv2DInfo( - inShape: [number, number, number, number], - filterShape: [number, number, number, number], - strides: number|[number, number], dilations: number|[number, number], - pad: 'same'|'valid'|number|ExplicitPadding, - roundingMode?: 'floor'|'round'|'ceil', depthwise = false, - dataFormat: 'channelsFirst'|'channelsLast' = 'channelsLast'): Conv2DInfo { - let [batchSize, inHeight, inWidth, inChannels] = [-1, -1, -1, -1]; - if (dataFormat === 'channelsLast') { - [batchSize, inHeight, inWidth, inChannels] = inShape; - } else if (dataFormat === 'channelsFirst') { - [batchSize, inChannels, inHeight, inWidth] = inShape; - } else { - throw new Error(`Unknown dataFormat ${dataFormat}`); - } - - const [filterHeight, filterWidth, , filterChannels] = filterShape; - const [strideHeight, strideWidth] = parseTupleParam(strides); - const [dilationHeight, dilationWidth] = parseTupleParam(dilations); - - const effectiveFilterHeight = - getEffectiveFilterSize(filterHeight, dilationHeight); - const effectiveFilterWidth = - getEffectiveFilterSize(filterWidth, dilationWidth); - const {padInfo, outHeight, outWidth} = getPadAndOutInfo( - pad, inHeight, inWidth, strideHeight, strideWidth, effectiveFilterHeight, - effectiveFilterWidth, roundingMode, dataFormat); - - const outChannels = depthwise ? filterChannels * inChannels : filterChannels; - - let outShape: [number, number, number, number]; - if (dataFormat === 'channelsFirst') { - outShape = [batchSize, outChannels, outHeight, outWidth]; - } else if (dataFormat === 'channelsLast') { - outShape = [batchSize, outHeight, outWidth, outChannels]; - } - - return { - batchSize, - dataFormat, - inHeight, - inWidth, - inChannels, - outHeight, - outWidth, - outChannels, - padInfo, - strideHeight, - strideWidth, - filterHeight, - filterWidth, - effectiveFilterHeight, - effectiveFilterWidth, - dilationHeight, - dilationWidth, - inShape, - outShape, - filterShape - }; -} - -/** - * Information about the forward pass of a 3D convolution/pooling operation. - * It includes input and output shape, strides, filter size and padding - * information. - */ -export type Conv3DInfo = { - batchSize: number, - inDepth: number, - inHeight: number, - inWidth: number, - inChannels: number, - outDepth: number, - outHeight: number, - outWidth: number, - outChannels: number, - dataFormat: 'channelsFirst'|'channelsLast', - strideDepth: number, - strideHeight: number, - strideWidth: number, - dilationDepth: number, - dilationHeight: number, - dilationWidth: number, - filterDepth: number, - filterHeight: number, - filterWidth: number, - effectiveFilterDepth: number, - effectiveFilterHeight: number, - effectiveFilterWidth: number, - padInfo: PadInfo3D, - inShape: [number, number, number, number, number], - outShape: [number, number, number, number, number], - filterShape: [number, number, number, number, number] -}; - -/** - * Computes the information for a forward pass of a 3D convolution/pooling - * operation. - */ -export function computeConv3DInfo( - inShape: [number, number, number, number, number], - filterShape: [number, number, number, number, number], - strides: number|[number, number, number], - dilations: number|[number, number, number], pad: 'same'|'valid'|number, - depthwise = false, - dataFormat: 'channelsFirst'|'channelsLast' = 'channelsLast', - roundingMode?: 'floor'|'round'|'ceil'): Conv3DInfo { - let [batchSize, inDepth, inHeight, inWidth, inChannels] = - [-1, -1, -1, -1, -1]; - if (dataFormat === 'channelsLast') { - [batchSize, inDepth, inHeight, inWidth, inChannels] = inShape; - } else if (dataFormat === 'channelsFirst') { - [batchSize, inChannels, inDepth, inHeight, inWidth] = inShape; - } else { - throw new Error(`Unknown dataFormat ${dataFormat}`); - } - - const [filterDepth, filterHeight, filterWidth, , filterChannels] = - filterShape; - const [strideDepth, strideHeight, strideWidth] = parse3TupleParam(strides); - const [dilationDepth, dilationHeight, dilationWidth] = - parse3TupleParam(dilations); - - const effectiveFilterDepth = - getEffectiveFilterSize(filterDepth, dilationDepth); - const effectiveFilterHeight = - getEffectiveFilterSize(filterHeight, dilationHeight); - const effectiveFilterWidth = - getEffectiveFilterSize(filterWidth, dilationWidth); - const {padInfo, outDepth, outHeight, outWidth} = get3DPadAndOutInfo( - pad, inDepth, inHeight, inWidth, strideDepth, strideHeight, strideWidth, - effectiveFilterDepth, effectiveFilterHeight, effectiveFilterWidth, - roundingMode); - - const outChannels = depthwise ? filterChannels * inChannels : filterChannels; - - let outShape: [number, number, number, number, number]; - if (dataFormat === 'channelsFirst') { - outShape = [batchSize, outChannels, outDepth, outHeight, outWidth]; - } else if (dataFormat === 'channelsLast') { - outShape = [batchSize, outDepth, outHeight, outWidth, outChannels]; - } - - return { - batchSize, - dataFormat, - inDepth, - inHeight, - inWidth, - inChannels, - outDepth, - outHeight, - outWidth, - outChannels, - padInfo, - strideDepth, - strideHeight, - strideWidth, - filterDepth, - filterHeight, - filterWidth, - effectiveFilterDepth, - effectiveFilterHeight, - effectiveFilterWidth, - dilationDepth, - dilationHeight, - dilationWidth, - inShape, - outShape, - filterShape - }; -} - -function computeOutputShape2D( - inShape: [number, number], fieldSize: number, stride: number, - zeroPad?: number, roundingMode?: 'floor'|'round'|'ceil'): [number, number] { - if (zeroPad == null) { - zeroPad = computeDefaultPad(inShape, fieldSize, stride); - } - const inputRows = inShape[0]; - const inputCols = inShape[1]; - - const outputRows = - round((inputRows - fieldSize + 2 * zeroPad) / stride + 1, roundingMode); - const outputCols = - round((inputCols - fieldSize + 2 * zeroPad) / stride + 1, roundingMode); - - return [outputRows, outputCols]; -} - -function computeOutputShape4D( - inShape: [number, number, number, number], - filterShape: [number, number, number], outChannels: number, - strides: [number, number, number], zeroPad?: number, - roundingMode?: 'floor'|'round'|'ceil'): [number, number, number, number] { - if (zeroPad == null) { - zeroPad = computeDefaultPad(inShape, filterShape[0], strides[0]); - } - const outShape: [number, number, number, number] = [0, 0, 0, outChannels]; - for (let index = 0; index < 3; index++) { - if (inShape[index] + 2 * zeroPad >= filterShape[index]) { - outShape[index] = round( - (inShape[index] - filterShape[index] + 2 * zeroPad) / strides[index] + - 1, - roundingMode); - } - } - return outShape; -} - -export function computeDefaultPad( - inputShape: [number, number]|[number, number, number, number], - fieldSize: number, stride: number, dilation = 1): number { - const effectiveFieldSize = getEffectiveFilterSize(fieldSize, dilation); - return Math.floor( - (inputShape[0] * (stride - 1) - stride + effectiveFieldSize) / 2); -} - -function parseTupleParam(param: number|number[]): [number, number, number] { - if (typeof param === 'number') { - return [param, param, param]; - } - if (param.length === 2) { - return [param[0], param[1], 1]; - } - return param as [number, number, number]; -} - -function parse3TupleParam(param: number|[number, number, number]): - [number, number, number] { - return typeof param === 'number' ? [param, param, param] : param; -} - -/* See https://www.tensorflow.org/api_docs/python/tf/nn/atrous_conv2d - * Atrous convolution is equivalent to standard convolution with upsampled - * filters with effective_filter_height = - * filter_height + (filter_height - 1) * (dilation - 1) - * and effective_filter_width = - * filter_width + (filter_width - 1) * (dilation - 1), - * produced by inserting dilation - 1 zeros along consecutive elements across - * the filters' spatial dimensions. - * When there is a dilation, this converts a filter dimension to the - * effective filter dimension, so it can be used in a standard convolution. - */ -function getEffectiveFilterSize(filterSize: number, dilation: number) { - if (dilation <= 1) { - return filterSize; - } - - return filterSize + (filterSize - 1) * (dilation - 1); -} - -function getPadAndOutInfo( - pad: 'same'|'valid'|number|ExplicitPadding, inHeight: number, - inWidth: number, strideHeight: number, strideWidth: number, - filterHeight: number, filterWidth: number, - roundingMode: 'floor'|'round'|'ceil', - dataFormat: 'channelsFirst'| - 'channelsLast'): {padInfo: PadInfo, outHeight: number, outWidth: number} { - let padInfo: PadInfo; - let outHeight: number; - let outWidth: number; - - if (typeof pad === 'number') { - const padType = (pad === 0) ? 'VALID' : 'NUMBER'; - padInfo = {top: pad, bottom: pad, left: pad, right: pad, type: padType}; - const outShape = computeOutputShape2D( - [inHeight, inWidth], filterHeight, strideHeight, pad, roundingMode); - outHeight = outShape[0]; - outWidth = outShape[1]; - } else if (pad === 'same') { - outHeight = Math.ceil(inHeight / strideHeight); - outWidth = Math.ceil(inWidth / strideWidth); - const padAlongHeight = - Math.max(0, (outHeight - 1) * strideHeight + filterHeight - inHeight); - const padAlongWidth = - Math.max(0, (outWidth - 1) * strideWidth + filterWidth - inWidth); - const top = Math.floor(padAlongHeight / 2); - const bottom = padAlongHeight - top; - const left = Math.floor(padAlongWidth / 2); - const right = padAlongWidth - left; - padInfo = {top, bottom, left, right, type: 'SAME'}; - } else if (pad === 'valid') { - padInfo = {top: 0, bottom: 0, left: 0, right: 0, type: 'VALID'}; - outHeight = Math.ceil((inHeight - filterHeight + 1) / strideHeight); - outWidth = Math.ceil((inWidth - filterWidth + 1) / strideWidth); - } else if (typeof pad === 'object') { - const top = dataFormat === 'channelsLast' ? pad[1][0] : pad[2][0]; - const bottom = dataFormat === 'channelsLast' ? pad[1][1] : pad[2][1]; - const left = dataFormat === 'channelsLast' ? pad[2][0] : pad[3][0]; - const right = dataFormat === 'channelsLast' ? pad[2][1] : pad[3][1]; - const padType = (top === 0 && bottom === 0 && left === 0 && right === 0) ? - 'VALID' : - 'EXPLICIT'; - padInfo = {top, bottom, left, right, type: padType}; - outHeight = round( - (inHeight - filterHeight + top + bottom) / strideHeight + 1, - roundingMode); - outWidth = round( - (inWidth - filterWidth + left + right) / strideWidth + 1, roundingMode); - } else { - throw Error(`Unknown padding parameter: ${pad}`); - } - return {padInfo, outHeight, outWidth}; -} - -function get3DPadAndOutInfo( - pad: 'same'|'valid'|number, inDepth: number, inHeight: number, - inWidth: number, strideDepth: number, strideHeight: number, - strideWidth: number, filterDepth: number, filterHeight: number, - filterWidth: number, roundingMode?: 'floor'|'round'|'ceil'): { - padInfo: PadInfo3D, - outDepth: number, - outHeight: number, - outWidth: number -} { - let padInfo: PadInfo3D; - let outDepth: number; - let outHeight: number; - let outWidth: number; - - if (pad === 'valid') { - pad = 0; - } - - if (typeof pad === 'number') { - const padType = (pad === 0) ? 'VALID' : 'NUMBER'; - padInfo = { - top: pad, - bottom: pad, - left: pad, - right: pad, - front: pad, - back: pad, - type: padType - }; - const outShape = computeOutputShape4D( - [inDepth, inHeight, inWidth, 1], - [filterDepth, filterHeight, filterWidth], 1, - [strideDepth, strideHeight, strideWidth], pad, roundingMode); - outDepth = outShape[0]; - outHeight = outShape[1]; - outWidth = outShape[2]; - } else if (pad === 'same') { - outDepth = Math.ceil(inDepth / strideDepth); - outHeight = Math.ceil(inHeight / strideHeight); - outWidth = Math.ceil(inWidth / strideWidth); - const padAlongDepth = (outDepth - 1) * strideDepth + filterDepth - inDepth; - const padAlongHeight = - (outHeight - 1) * strideHeight + filterHeight - inHeight; - const padAlongWidth = (outWidth - 1) * strideWidth + filterWidth - inWidth; - const front = Math.floor(padAlongDepth / 2); - const back = padAlongDepth - front; - const top = Math.floor(padAlongHeight / 2); - const bottom = padAlongHeight - top; - const left = Math.floor(padAlongWidth / 2); - const right = padAlongWidth - left; - - padInfo = {top, bottom, left, right, front, back, type: 'SAME'}; - } else { - throw Error(`Unknown padding parameter: ${pad}`); - } - return {padInfo, outDepth, outHeight, outWidth}; -} - -/** - * Rounds a value depending on the rounding mode - * @param value - * @param roundingMode A string from: 'ceil', 'round', 'floor'. If none is - * provided, it will default to truncate. - */ -function round(value: number, roundingMode?: 'floor'|'round'|'ceil') { - if (!roundingMode) { - return Math.trunc(value); - } - switch (roundingMode) { - case 'round': - // used for Caffe Conv - return Math.round(value); - case 'ceil': - // used for Caffe Pool - return Math.ceil(value); - case 'floor': - return Math.floor(value); - default: - throw new Error(`Unknown roundingMode ${roundingMode}`); - } -} - -export function tupleValuesAreOne(param: number|number[]): boolean { - const [dimA, dimB, dimC] = parseTupleParam(param); - return dimA === 1 && dimB === 1 && dimC === 1; -} - -export function eitherStridesOrDilationsAreOne( - strides: number|number[], dilations: number|number[]): boolean { - return tupleValuesAreOne(strides) || tupleValuesAreOne(dilations); -} - -export function stridesOrDilationsArePositive(values: number| - number[]): boolean { - return parseTupleParam(values).every(value => value > 0); -} - -/** - * Convert Conv2D dataFormat from 'NHWC'|'NCHW' to - * 'channelsLast'|'channelsFirst' - * @param dataFormat in 'NHWC'|'NCHW' mode - * @return dataFormat in 'channelsLast'|'channelsFirst' mode - * @throws unknown dataFormat - */ -export function convertConv2DDataFormat(dataFormat: 'NHWC'|'NCHW'): - 'channelsLast'|'channelsFirst' { - if (dataFormat === 'NHWC') { - return 'channelsLast'; - } else if (dataFormat === 'NCHW') { - return 'channelsFirst'; - } else { - throw new Error(`Unknown dataFormat ${dataFormat}`); - } -} - -/** - * Check validity of pad when using dimRoundingMode. - * @param opDesc A string of op description - * @param pad The type of padding algorithm. - * - `same` and stride 1: output will be of same size as input, - * regardless of filter size. - * - `valid` output will be smaller than input if filter is larger - * than 1x1. - * - For more info, see this guide: - * [https://www.tensorflow.org/api_docs/python/tf/nn/convolution]( - * https://www.tensorflow.org/api_docs/python/tf/nn/convolution) - * @param dimRoundingMode A string from: 'ceil', 'round', 'floor'. If none is - * provided, it will default to truncate. - * @throws unknown padding parameter - */ -export function checkPadOnDimRoundingMode( - opDesc: string, pad: 'valid'|'same'|number|ExplicitPadding, - dimRoundingMode?: 'floor'|'round'|'ceil') { - if (dimRoundingMode != null) { - if (typeof pad === 'string') { - throw Error( - `Error in ${opDesc}: pad must be an integer when using ` + - `dimRoundingMode ${dimRoundingMode} but got pad ${pad}.`); - } else if (typeof pad === 'number') { - util.assert( - util.isInt(pad), - () => `Error in ${opDesc}: pad must be an integer when using ` + - `dimRoundingMode ${dimRoundingMode} but got pad ${pad}.`); - } else if (typeof pad === 'object') { - (pad as ExplicitPadding).forEach(p => { - p.forEach(v => { - util.assert( - util.isInt(v), - () => `Error in ${opDesc}: pad must be an integer when using ` + - `dimRoundingMode ${dimRoundingMode} but got pad ${v}.`); - }); - }); - } else { - throw Error(`Error in ${opDesc}: Unknown padding parameter: ${pad}`); - } - } -} diff --git a/tfjs-master/tfjs-core/src/ops/conv_util_test.ts b/tfjs-master/tfjs-core/src/ops/conv_util_test.ts deleted file mode 100644 index 99f6ba169..000000000 --- a/tfjs-master/tfjs-core/src/ops/conv_util_test.ts +++ /dev/null @@ -1,1000 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as conv_util from './conv_util'; - -describe('conv_util computeConv2DInfo', () => { - it('1x1 conv over 1x1 array with same pad', () => { - const inShape: [number, number, number, number] = [1, 1, 1, 1]; - const stride = 1; - const dilation = 1; - const convInfo = conv_util.computeConv2DInfo( - inShape, [1, 1, 1, 1], stride, dilation, 'same'); - expect(convInfo.batchSize).toEqual(1); - expect(convInfo.outHeight).toEqual(1); - expect(convInfo.outWidth).toEqual(1); - expect(convInfo.outChannels).toEqual(1); - expect(convInfo.effectiveFilterWidth).toEqual(1); - expect(convInfo.effectiveFilterHeight).toEqual(1); - }); - - it('2x2 conv over 3x3 array with same pad', () => { - const inShape: [number, number, number, number] = [1, 3, 3, 1]; - const stride = 1; - const dilation = 1; - const convInfo = conv_util.computeConv2DInfo( - inShape, [2, 2, 1, 1], stride, dilation, 'same'); - expect(convInfo.batchSize).toEqual(1); - expect(convInfo.outHeight).toEqual(3); - expect(convInfo.outWidth).toEqual(3); - expect(convInfo.outChannels).toEqual(1); - expect(convInfo.effectiveFilterWidth).toEqual(2); - expect(convInfo.effectiveFilterHeight).toEqual(2); - // Should produce non-even padding with extra pixel at the right/bottom. - expect(convInfo.padInfo.left).toBe(0); - expect(convInfo.padInfo.right).toBe(1); - expect(convInfo.padInfo.top).toBe(0); - expect(convInfo.padInfo.bottom).toBe(1); - }); - - it('2x2 conv over 3x3 array with same pad', () => { - const inShape: [number, number, number, number] = [1, 3, 3, 1]; - const stride = 1; - const dilation = 1; - const convInfo = conv_util.computeConv2DInfo( - inShape, [2, 2, 1, 1], stride, dilation, 'same'); - expect(convInfo.batchSize).toEqual(1); - expect(convInfo.outHeight).toEqual(3); - expect(convInfo.outWidth).toEqual(3); - expect(convInfo.outChannels).toEqual(1); - expect(convInfo.effectiveFilterWidth).toEqual(2); - expect(convInfo.effectiveFilterHeight).toEqual(2); - }); - - it('2x2 conv over 3x3 array with valid pad', () => { - const inShape: [number, number, number, number] = [1, 3, 3, 1]; - const stride = 1; - const dilation = 1; - const convInfo = conv_util.computeConv2DInfo( - inShape, [2, 2, 1, 1], stride, dilation, 'valid'); - expect(convInfo.batchSize).toEqual(1); - expect(convInfo.outHeight).toEqual(2); - expect(convInfo.outWidth).toEqual(2); - expect(convInfo.outChannels).toEqual(1); - expect(convInfo.effectiveFilterWidth).toEqual(2); - expect(convInfo.effectiveFilterHeight).toEqual(2); - }); - - it('3x3 conv over 5x5 array with same pad with stride 2', () => { - const inShape: [number, number, number, number] = [1, 5, 5, 1]; - const stride = 2; - const dilation = 1; - const convInfo = conv_util.computeConv2DInfo( - inShape, [3, 3, 1, 1], stride, dilation, 'same'); - expect(convInfo.batchSize).toEqual(1); - expect(convInfo.outHeight).toEqual(3); - expect(convInfo.outWidth).toEqual(3); - expect(convInfo.outChannels).toEqual(1); - expect(convInfo.effectiveFilterWidth).toEqual(3); - expect(convInfo.effectiveFilterHeight).toEqual(3); - - expect(convInfo.padInfo.left).toBe(1); - expect(convInfo.padInfo.right).toBe(1); - expect(convInfo.padInfo.top).toBe(1); - expect(convInfo.padInfo.bottom).toBe(1); - }); - - it('2x2 conv over 3x3 array with valid pad with stride 2', () => { - const inShape: [number, number, number, number] = [1, 3, 3, 1]; - const stride = 2; - const dilation = 1; - const convInfo = conv_util.computeConv2DInfo( - inShape, [2, 2, 1, 1], stride, dilation, 'valid'); - expect(convInfo.batchSize).toEqual(1); - expect(convInfo.outHeight).toEqual(1); - expect(convInfo.outWidth).toEqual(1); - expect(convInfo.outChannels).toEqual(1); - expect(convInfo.effectiveFilterWidth).toEqual(2); - expect(convInfo.effectiveFilterHeight).toEqual(2); - }); - - it('2x1 conv over 3x3 array with valid pad with stride 1', () => { - const inShape: [number, number, number, number] = [1, 3, 3, 1]; - const stride = 1; - const dilation = 1; - const convInfo = conv_util.computeConv2DInfo( - inShape, [2, 1, 1, 1], stride, dilation, 'valid'); - expect(convInfo.batchSize).toEqual(1); - expect(convInfo.outHeight).toEqual(2); - expect(convInfo.outWidth).toEqual(3); - expect(convInfo.outChannels).toEqual(1); - expect(convInfo.effectiveFilterWidth).toEqual(1); - expect(convInfo.effectiveFilterHeight).toEqual(2); - }); - - it('2x1 conv over 3x3 array with valid pad with strides h=2, w=1', () => { - const inShape: [number, number, number, number] = [1, 3, 3, 1]; - const strides: [number, number] = [2, 1]; - const dilation = 1; - const convInfo = conv_util.computeConv2DInfo( - inShape, [2, 1, 1, 1], strides, dilation, 'valid'); - expect(convInfo.batchSize).toEqual(1); - expect(convInfo.outHeight).toEqual(1); - expect(convInfo.outWidth).toEqual(3); - expect(convInfo.outChannels).toEqual(1); - expect(convInfo.effectiveFilterWidth).toEqual(1); - expect(convInfo.effectiveFilterHeight).toEqual(2); - }); - - it('1x2 conv over 3x3 array with valid pad with stride 1', () => { - const inShape: [number, number, number, number] = [1, 3, 3, 1]; - const stride = 1; - const dilation = 1; - const convInfo = conv_util.computeConv2DInfo( - inShape, [1, 2, 1, 1], stride, dilation, 'valid'); - expect(convInfo.batchSize).toEqual(1); - expect(convInfo.outHeight).toEqual(3); - expect(convInfo.outWidth).toEqual(2); - expect(convInfo.outChannels).toEqual(1); - expect(convInfo.effectiveFilterWidth).toEqual(2); - expect(convInfo.effectiveFilterHeight).toEqual(1); - }); - - it('1x2 conv over 3x3 array with valid pad with stride 1, batch=5', () => { - const inShape: [number, number, number, number] = [5, 3, 3, 1]; - const stride = 1; - const dilation = 1; - const convInfo = conv_util.computeConv2DInfo( - inShape, [1, 2, 1, 1], stride, dilation, 'valid'); - expect(convInfo.batchSize).toEqual(5); - expect(convInfo.outHeight).toEqual(3); - expect(convInfo.outWidth).toEqual(2); - expect(convInfo.outChannels).toEqual(1); - expect(convInfo.effectiveFilterWidth).toEqual(2); - expect(convInfo.effectiveFilterHeight).toEqual(1); - }); - - it('2x2 conv over 3x3 array with same pad with dilations 2', () => { - const inShape: [number, number, number, number] = [1, 3, 3, 1]; - const stride = 1; - const dilations = 2; - const convInfo = conv_util.computeConv2DInfo( - inShape, [2, 2, 1, 1], stride, dilations, 'same'); - expect(convInfo.batchSize).toEqual(1); - expect(convInfo.outHeight).toEqual(3); - expect(convInfo.outWidth).toEqual(3); - expect(convInfo.outChannels).toEqual(1); - // pad evenly on all sides - expect(convInfo.padInfo.left).toBe(1); - expect(convInfo.padInfo.right).toBe(1); - expect(convInfo.padInfo.top).toBe(1); - expect(convInfo.padInfo.bottom).toBe(1); - expect(convInfo.effectiveFilterWidth).toEqual(3); - expect(convInfo.effectiveFilterHeight).toEqual(3); - }); - - it('2x1 conv over 3x3 array with same pad with dilations 2', () => { - const inShape: [number, number, number, number] = [1, 3, 3, 1]; - const stride = 1; - const dilations = 2; - const convInfo = conv_util.computeConv2DInfo( - inShape, [2, 1, 1, 1], stride, dilations, 'same'); - expect(convInfo.batchSize).toEqual(1); - expect(convInfo.outHeight).toEqual(3); - expect(convInfo.outWidth).toEqual(3); - expect(convInfo.outChannels).toEqual(1); - // pad top and bottom - expect(convInfo.padInfo.left).toBe(0); - expect(convInfo.padInfo.right).toBe(0); - expect(convInfo.padInfo.top).toBe(1); - expect(convInfo.padInfo.bottom).toBe(1); - expect(convInfo.effectiveFilterWidth).toEqual(1); - expect(convInfo.effectiveFilterHeight).toEqual(3); - }); - - it('3x4 conv over 8x8 array with same pad with dilations h=4 w=3', () => { - const inShape: [number, number, number, number] = [1, 8, 8, 1]; - const stride = 1; - const dilations: [number, number] = [4, 3]; - const convInfo = conv_util.computeConv2DInfo( - inShape, [3, 4, 1, 1], stride, dilations, 'same'); - expect(convInfo.batchSize).toEqual(1); - expect(convInfo.outHeight).toEqual(8); - expect(convInfo.outWidth).toEqual(8); - expect(convInfo.outChannels).toEqual(1); - expect(convInfo.effectiveFilterWidth).toEqual(10); - expect(convInfo.effectiveFilterHeight).toEqual(9); - - expect(convInfo.padInfo.left).toBe(4); - expect(convInfo.padInfo.right).toBe(5); - expect(convInfo.padInfo.top).toBe(4); - expect(convInfo.padInfo.bottom).toBe(4); - }); - - it('2x1 conv over 3x3 array with valid pad with dilations 2', () => { - const inShape: [number, number, number, number] = [1, 3, 3, 1]; - const stride = 1; - const dilations = 2; - const convInfo = conv_util.computeConv2DInfo( - inShape, [2, 1, 1, 1], stride, dilations, 'valid'); - expect(convInfo.batchSize).toEqual(1); - expect(convInfo.outHeight).toEqual(1); - expect(convInfo.outWidth).toEqual(3); - expect(convInfo.outChannels).toEqual(1); - expect(convInfo.effectiveFilterWidth).toEqual(1); - expect(convInfo.effectiveFilterHeight).toEqual(3); - }); - - it('2x2 conv over 3x3 array with valid pad with dilations 2', () => { - const inShape: [number, number, number, number] = [1, 3, 3, 1]; - const stride = 1; - const dilations = 2; - const convInfo = conv_util.computeConv2DInfo( - inShape, [2, 2, 1, 1], stride, dilations, 'valid'); - expect(convInfo.batchSize).toEqual(1); - expect(convInfo.outHeight).toEqual(1); - expect(convInfo.outWidth).toEqual(1); - expect(convInfo.outChannels).toEqual(1); - expect(convInfo.effectiveFilterWidth).toEqual(3); - expect(convInfo.effectiveFilterHeight).toEqual(3); - }); - - it('2x2 conv over 4x4 array with valid pad with dilations 2', () => { - const inShape: [number, number, number, number] = [1, 4, 4, 1]; - const stride = 1; - const dilations = 2; - const convInfo = conv_util.computeConv2DInfo( - inShape, [2, 2, 1, 1], stride, dilations, 'valid'); - expect(convInfo.batchSize).toEqual(1); - expect(convInfo.outHeight).toEqual(2); - expect(convInfo.outWidth).toEqual(2); - expect(convInfo.outChannels).toEqual(1); - expect(convInfo.effectiveFilterWidth).toEqual(3); - expect(convInfo.effectiveFilterHeight).toEqual(3); - }); -}); - -describe('conv_util computeConv3DInfo', () => { - it('1x1x1 conv over 1x1x1 array with same pad', () => { - const inShape: [number, number, number, number, number] = [1, 1, 1, 1, 1]; - const stride = 1; - const dilation = 1; - const convInfo = conv_util.computeConv3DInfo( - inShape, [1, 1, 1, 1, 1], stride, dilation, 'same'); - expect(convInfo.batchSize).toEqual(1); - expect(convInfo.outDepth).toEqual(1); - expect(convInfo.outHeight).toEqual(1); - expect(convInfo.outWidth).toEqual(1); - expect(convInfo.outChannels).toEqual(1); - }); - - it('2x2x2 conv over 3x3x3 array with same pad', () => { - const inShape: [number, number, number, number, number] = [1, 3, 3, 3, 1]; - const stride = 1; - const dilation = 1; - const convInfo = conv_util.computeConv3DInfo( - inShape, [2, 2, 2, 1, 1], stride, dilation, 'same'); - expect(convInfo.batchSize).toEqual(1); - expect(convInfo.outDepth).toEqual(3); - expect(convInfo.outHeight).toEqual(3); - expect(convInfo.outWidth).toEqual(3); - expect(convInfo.outChannels).toEqual(1); - // Should produce non-even padding with extra pixel at the back/right/bottom - expect(convInfo.padInfo.front).toBe(0); - expect(convInfo.padInfo.back).toBe(1); - expect(convInfo.padInfo.left).toBe(0); - expect(convInfo.padInfo.right).toBe(1); - expect(convInfo.padInfo.top).toBe(0); - expect(convInfo.padInfo.bottom).toBe(1); - }); - - it('2x2x2 conv over 3x3x3 array with same pad', () => { - const inShape: [number, number, number, number, number] = [1, 3, 3, 3, 1]; - const stride = 1; - const dilation = 1; - const convInfo = conv_util.computeConv3DInfo( - inShape, [2, 2, 2, 1, 1], stride, dilation, 'same'); - expect(convInfo.batchSize).toEqual(1); - expect(convInfo.outDepth).toEqual(3); - expect(convInfo.outHeight).toEqual(3); - expect(convInfo.outWidth).toEqual(3); - expect(convInfo.outChannels).toEqual(1); - }); - - it('2x2x2 conv over 3x3x3 array with valid pad', () => { - const inShape: [number, number, number, number, number] = [1, 3, 3, 3, 1]; - const stride = 1; - const dilation = 1; - const convInfo = conv_util.computeConv3DInfo( - inShape, [2, 2, 2, 1, 1], stride, dilation, 'valid'); - expect(convInfo.batchSize).toEqual(1); - expect(convInfo.outDepth).toEqual(2); - expect(convInfo.outHeight).toEqual(2); - expect(convInfo.outWidth).toEqual(2); - expect(convInfo.outChannels).toEqual(1); - }); - - it('3x3x3 conv over 5x5x5 array with same pad with stride 2', () => { - const inShape: [number, number, number, number, number] = [1, 5, 5, 5, 1]; - const stride = 2; - const dilation = 1; - const convInfo = conv_util.computeConv3DInfo( - inShape, [3, 3, 3, 1, 1], stride, dilation, 'same'); - expect(convInfo.batchSize).toEqual(1); - expect(convInfo.outDepth).toEqual(3); - expect(convInfo.outHeight).toEqual(3); - expect(convInfo.outWidth).toEqual(3); - expect(convInfo.outChannels).toEqual(1); - - expect(convInfo.padInfo.front).toBe(1); - expect(convInfo.padInfo.back).toBe(1); - expect(convInfo.padInfo.left).toBe(1); - expect(convInfo.padInfo.right).toBe(1); - expect(convInfo.padInfo.top).toBe(1); - expect(convInfo.padInfo.bottom).toBe(1); - }); - - it('2x2x2 conv over 3x3x3 array with valid pad with stride 2', () => { - const inShape: [number, number, number, number, number] = [1, 3, 3, 3, 1]; - const stride = 2; - const dilation = 1; - const convInfo = conv_util.computeConv3DInfo( - inShape, [2, 2, 2, 1, 1], stride, dilation, 'valid'); - expect(convInfo.batchSize).toEqual(1); - expect(convInfo.outDepth).toEqual(1); - expect(convInfo.outHeight).toEqual(1); - expect(convInfo.outWidth).toEqual(1); - expect(convInfo.outChannels).toEqual(1); - }); - - it('2x1x1 conv over 3x3x3 array with valid pad with stride 1', () => { - const inShape: [number, number, number, number, number] = [1, 3, 3, 3, 1]; - const stride = 1; - const dilation = 1; - const convInfo = conv_util.computeConv3DInfo( - inShape, [2, 1, 1, 1, 1], stride, dilation, 'valid'); - expect(convInfo.batchSize).toEqual(1); - expect(convInfo.outDepth).toEqual(2); - expect(convInfo.outHeight).toEqual(3); - expect(convInfo.outWidth).toEqual(3); - expect(convInfo.outChannels).toEqual(1); - }); - - it('2x1x1 conv over 3x3x3 array with valid pad with strides d=2, h=1, w=1', - () => { - const inShape: [number, number, number, number, number] = - [1, 3, 3, 3, 1]; - const strides: [number, number, number] = [2, 1, 1]; - const dilation = 1; - const convInfo = conv_util.computeConv3DInfo( - inShape, [2, 1, 1, 1, 1], strides, dilation, 'valid'); - expect(convInfo.batchSize).toEqual(1); - expect(convInfo.outDepth).toEqual(1); - expect(convInfo.outHeight).toEqual(3); - expect(convInfo.outWidth).toEqual(3); - expect(convInfo.outChannels).toEqual(1); - }); - - it('1x2x2 conv over 3x3x3 array with valid pad with stride 1', () => { - const inShape: [number, number, number, number, number] = [1, 3, 3, 3, 1]; - const stride = 1; - const dilation = 1; - const convInfo = conv_util.computeConv3DInfo( - inShape, [1, 2, 2, 1, 1], stride, dilation, 'valid'); - expect(convInfo.batchSize).toEqual(1); - expect(convInfo.outDepth).toEqual(3); - expect(convInfo.outHeight).toEqual(2); - expect(convInfo.outWidth).toEqual(2); - expect(convInfo.outChannels).toEqual(1); - }); - - it('1x2x2 conv over 3x3x3 array with valid pad with stride 1, batch=5', - () => { - const inShape: [number, number, number, number, number] = - [5, 3, 3, 3, 1]; - const stride = 1; - const dilation = 1; - const convInfo = conv_util.computeConv3DInfo( - inShape, [1, 2, 2, 1, 1], stride, dilation, 'valid'); - expect(convInfo.batchSize).toEqual(5); - expect(convInfo.outDepth).toEqual(3); - expect(convInfo.outHeight).toEqual(2); - expect(convInfo.outWidth).toEqual(2); - expect(convInfo.outChannels).toEqual(1); - }); - - it('2x2x2 conv over 3x3x3 array with same pad with dilations 2', () => { - const inShape: [number, number, number, number, number] = [1, 3, 3, 3, 1]; - const stride = 1; - const dilations = 2; - const convInfo = conv_util.computeConv3DInfo( - inShape, [2, 2, 2, 1, 1], stride, dilations, 'same'); - expect(convInfo.batchSize).toEqual(1); - expect(convInfo.outDepth).toEqual(3); - expect(convInfo.outHeight).toEqual(3); - expect(convInfo.outWidth).toEqual(3); - expect(convInfo.outChannels).toEqual(1); - // pad evenly on all sides - expect(convInfo.padInfo.front).toBe(1); - expect(convInfo.padInfo.back).toBe(1); - expect(convInfo.padInfo.left).toBe(1); - expect(convInfo.padInfo.right).toBe(1); - expect(convInfo.padInfo.top).toBe(1); - expect(convInfo.padInfo.bottom).toBe(1); - }); - - it('2x1x1 conv over 3x3x3 array with same pad with dilations 2', () => { - const inShape: [number, number, number, number, number] = [1, 3, 3, 3, 1]; - const stride = 1; - const dilations = 2; - const convInfo = conv_util.computeConv3DInfo( - inShape, [2, 1, 1, 1, 1], stride, dilations, 'same'); - expect(convInfo.batchSize).toEqual(1); - expect(convInfo.outDepth).toEqual(3); - expect(convInfo.outHeight).toEqual(3); - expect(convInfo.outWidth).toEqual(3); - expect(convInfo.outChannels).toEqual(1); - // pad top and bottom - expect(convInfo.padInfo.front).toBe(1); - expect(convInfo.padInfo.back).toBe(1); - expect(convInfo.padInfo.left).toBe(0); - expect(convInfo.padInfo.right).toBe(0); - expect(convInfo.padInfo.top).toBe(0); - expect(convInfo.padInfo.bottom).toBe(0); - }); - - it('3x4x4 conv over 8x8 array with same pad with dilations d=4 h=3 w=3', - () => { - const inShape: [number, number, number, number, number] = - [1, 8, 8, 8, 1]; - const stride = 1; - const dilations: [number, number, number] = [4, 3, 3]; - const convInfo = conv_util.computeConv3DInfo( - inShape, [3, 4, 4, 1, 1], stride, dilations, 'same'); - expect(convInfo.batchSize).toEqual(1); - expect(convInfo.outDepth).toEqual(8); - expect(convInfo.outHeight).toEqual(8); - expect(convInfo.outWidth).toEqual(8); - expect(convInfo.outChannels).toEqual(1); - - expect(convInfo.padInfo.front).toBe(4); - expect(convInfo.padInfo.back).toBe(4); - expect(convInfo.padInfo.left).toBe(4); - expect(convInfo.padInfo.right).toBe(5); - expect(convInfo.padInfo.top).toBe(4); - expect(convInfo.padInfo.bottom).toBe(5); - }); - - it('2x1x1 conv over 3x3x3 array with valid pad with dilations 2', () => { - const inShape: [number, number, number, number, number] = [1, 3, 3, 3, 1]; - const stride = 1; - const dilations = 2; - const convInfo = conv_util.computeConv3DInfo( - inShape, [2, 1, 1, 1, 1], stride, dilations, 'valid'); - expect(convInfo.batchSize).toEqual(1); - expect(convInfo.outDepth).toEqual(1); - expect(convInfo.outHeight).toEqual(3); - expect(convInfo.outWidth).toEqual(3); - expect(convInfo.outChannels).toEqual(1); - }); - - it('2x2x2 conv over 3x3x3 array with valid pad with dilations 2', () => { - const inShape: [number, number, number, number, number] = [1, 3, 3, 3, 1]; - const stride = 1; - const dilations = 2; - const convInfo = conv_util.computeConv3DInfo( - inShape, [2, 2, 2, 1, 1], stride, dilations, 'valid'); - expect(convInfo.batchSize).toEqual(1); - expect(convInfo.outDepth).toEqual(1); - expect(convInfo.outHeight).toEqual(1); - expect(convInfo.outWidth).toEqual(1); - expect(convInfo.outChannels).toEqual(1); - }); - - it('2x2x2 conv over 4x4x4 array with valid pad with dilations 2', () => { - const inShape: [number, number, number, number, number] = [1, 4, 4, 4, 1]; - const stride = 1; - const dilations = 2; - const convInfo = conv_util.computeConv3DInfo( - inShape, [2, 2, 2, 1, 1], stride, dilations, 'valid'); - expect(convInfo.batchSize).toEqual(1); - expect(convInfo.outDepth).toEqual(2); - expect(convInfo.outHeight).toEqual(2); - expect(convInfo.outWidth).toEqual(2); - expect(convInfo.outChannels).toEqual(1); - }); -}); - -describe('conv_util computeConv2DInfo with depthwise=true', () => { - it('1x1 filter over 1x1 array with same pad', () => { - const inChannels = 1; - const inShape: [number, number, number, number] = [1, 1, 1, inChannels]; - const fSize = 1; - const chMul = 1; - const stride = 1; - const dilation = 1; - const pad = 'same'; - const convInfo = conv_util.computeConv2DInfo( - inShape, [fSize, fSize, inChannels, chMul], stride, dilation, pad, null, - true); - expect(convInfo.batchSize).toEqual(1); - expect(convInfo.outHeight).toEqual(1); - expect(convInfo.outWidth).toEqual(1); - expect(convInfo.outChannels).toEqual(1); - expect(convInfo.effectiveFilterWidth).toEqual(1); - expect(convInfo.effectiveFilterHeight).toEqual(1); - }); - - it('2x2 filter over 3x3 array with same pad, chMul=3, depth=2', () => { - const inChannels = 2; - const batchSize = 1; - const inSize = 3; - const inShape: [number, number, number, number] = - [batchSize, inSize, inSize, inChannels]; - const fSize = 2; - const chMul = 3; - const stride = 1; - const dilation = 1; - const pad = 'same'; - const convInfo = conv_util.computeConv2DInfo( - inShape, [fSize, fSize, inChannels, chMul], stride, dilation, pad, null, - true); - expect(convInfo.batchSize).toEqual(1); - expect(convInfo.outHeight).toEqual(3); - expect(convInfo.outWidth).toEqual(3); - expect(convInfo.outChannels).toEqual(6); - expect(convInfo.effectiveFilterWidth).toEqual(2); - expect(convInfo.effectiveFilterHeight).toEqual(2); - }); - - it('2x2 filter over 3x3 array with valid pad, chMul=3, depth=2', () => { - const inChannels = 2; - const batchSize = 1; - const inSize = 3; - const inShape: [number, number, number, number] = - [batchSize, inSize, inSize, inChannels]; - const fSize = 2; - const chMul = 3; - const stride = 1; - const dilation = 1; - const pad = 'valid'; - const convInfo = conv_util.computeConv2DInfo( - inShape, [fSize, fSize, inChannels, chMul], stride, dilation, pad, null, - true); - expect(convInfo.batchSize).toEqual(1); - expect(convInfo.outHeight).toEqual(2); - expect(convInfo.outWidth).toEqual(2); - expect(convInfo.outChannels).toEqual(6); - expect(convInfo.effectiveFilterWidth).toEqual(2); - expect(convInfo.effectiveFilterHeight).toEqual(2); - }); -}); - -describe('conv_util computeConv3DInfo with depthwise=true', () => { - it('1x1x1 filter over 1x1x1 array with same pad', () => { - const inChannels = 1; - const inShape: [number, number, number, number, number] = - [1, 1, 1, 1, inChannels]; - const fSize = 1; - const chMul = 1; - const stride = 1; - const dilation = 1; - const pad = 'same'; - const convInfo = conv_util.computeConv3DInfo( - inShape, [fSize, fSize, fSize, inChannels, chMul], stride, dilation, - pad, true); - expect(convInfo.batchSize).toEqual(1); - expect(convInfo.outDepth).toEqual(1); - expect(convInfo.outHeight).toEqual(1); - expect(convInfo.outWidth).toEqual(1); - expect(convInfo.outChannels).toEqual(1); - }); - - it('2x2x2 filter over 3x3x3 array with same pad, chMul=3, depth=2', () => { - const inChannels = 2; - const batchSize = 1; - const inSize = 3; - const inShape: [number, number, number, number, number] = - [batchSize, inSize, inSize, inSize, inChannels]; - const fSize = 2; - const chMul = 3; - const stride = 1; - const dilation = 1; - const pad = 'same'; - const convInfo = conv_util.computeConv3DInfo( - inShape, [fSize, fSize, fSize, inChannels, chMul], stride, dilation, - pad, true); - expect(convInfo.batchSize).toEqual(1); - expect(convInfo.outDepth).toEqual(3); - expect(convInfo.outHeight).toEqual(3); - expect(convInfo.outWidth).toEqual(3); - expect(convInfo.outChannels).toEqual(6); - }); - - it('2x2x2 filter over 3x3x3 array with valid pad, chMul=3, depth=2', () => { - const inChannels = 2; - const batchSize = 1; - const inSize = 3; - const inShape: [number, number, number, number, number] = - [batchSize, inSize, inSize, inSize, inChannels]; - const fSize = 2; - const chMul = 3; - const stride = 1; - const dilation = 1; - const pad = 'valid'; - const convInfo = conv_util.computeConv3DInfo( - inShape, [fSize, fSize, fSize, inChannels, chMul], stride, dilation, - pad, true); - expect(convInfo.batchSize).toEqual(1); - expect(convInfo.outDepth).toEqual(2); - expect(convInfo.outHeight).toEqual(2); - expect(convInfo.outWidth).toEqual(2); - expect(convInfo.outChannels).toEqual(6); - }); -}); - -describe('conv_util computeConv2DInfo channelsFirst', () => { - it('2x2 conv over 3x3 array with same pad', () => { - const inDepth = 2; - const outDepth = 4; - const inShape: [number, number, number, number] = [1, inDepth, 3, 3]; - const stride = 1; - const dilation = 1; - const convInfo = conv_util.computeConv2DInfo( - inShape, [2, 2, inDepth, outDepth], stride, dilation, 'same', null, - false, 'channelsFirst'); - expect(convInfo.batchSize).toEqual(1); - expect(convInfo.outHeight).toEqual(3); - expect(convInfo.outWidth).toEqual(3); - expect(convInfo.outChannels).toEqual(4); - expect(convInfo.outShape).toEqual([1, 4, 3, 3]); - expect(convInfo.effectiveFilterWidth).toEqual(2); - expect(convInfo.effectiveFilterHeight).toEqual(2); - // Should produce non-even padding with extra pixel at the right/bottom. - expect(convInfo.padInfo.left).toBe(0); - expect(convInfo.padInfo.right).toBe(1); - expect(convInfo.padInfo.top).toBe(0); - expect(convInfo.padInfo.bottom).toBe(1); - }); - - it('2x2 conv over 3x3 array with valid pad', () => { - const inDepth = 6; - const outDepth = 16; - const inShape: [number, number, number, number] = [1, inDepth, 3, 3]; - const stride = 1; - const dilation = 1; - const convInfo = conv_util.computeConv2DInfo( - inShape, [2, 2, inDepth, outDepth], stride, dilation, 'valid', null, - false, 'channelsFirst'); - expect(convInfo.batchSize).toEqual(1); - expect(convInfo.outHeight).toEqual(2); - expect(convInfo.outWidth).toEqual(2); - expect(convInfo.outChannels).toEqual(16); - expect(convInfo.outShape).toEqual([1, 16, 2, 2]); - expect(convInfo.effectiveFilterWidth).toEqual(2); - expect(convInfo.effectiveFilterHeight).toEqual(2); - // Should produce no padding. - expect(convInfo.padInfo.left).toBe(0); - expect(convInfo.padInfo.right).toBe(0); - expect(convInfo.padInfo.top).toBe(0); - expect(convInfo.padInfo.bottom).toBe(0); - }); -}); - -describe('conv_util computeConv3DInfo channelsFirst', () => { - it('2x2x2 conv over 3x3x3 array with same pad', () => { - const inDepth = 2; - const outDepth = 4; - const inShape: [number, number, number, number, number] = - [1, inDepth, 3, 3, 3]; - const stride = 1; - const dilation = 1; - const convInfo = conv_util.computeConv3DInfo( - inShape, [2, 2, 2, inDepth, outDepth], stride, dilation, 'same', false, - 'channelsFirst'); - expect(convInfo.batchSize).toEqual(1); - expect(convInfo.outDepth).toEqual(3); - expect(convInfo.outHeight).toEqual(3); - expect(convInfo.outWidth).toEqual(3); - expect(convInfo.outChannels).toEqual(4); - expect(convInfo.outShape).toEqual([1, 4, 3, 3, 3]); - // Should produce non-even padding with extra pixel at the back/right/bottom - expect(convInfo.padInfo.front).toBe(0); - expect(convInfo.padInfo.back).toBe(1); - expect(convInfo.padInfo.left).toBe(0); - expect(convInfo.padInfo.right).toBe(1); - expect(convInfo.padInfo.top).toBe(0); - expect(convInfo.padInfo.bottom).toBe(1); - }); - - it('2x2x2 conv over 3x3x3 array with valid pad', () => { - const inDepth = 6; - const outDepth = 16; - const inShape: [number, number, number, number, number] = - [1, inDepth, 3, 3, 3]; - const stride = 1; - const dilation = 1; - const convInfo = conv_util.computeConv3DInfo( - inShape, [2, 2, 2, inDepth, outDepth], stride, dilation, 'valid', false, - 'channelsFirst'); - expect(convInfo.batchSize).toEqual(1); - expect(convInfo.outDepth).toEqual(2); - expect(convInfo.outHeight).toEqual(2); - expect(convInfo.outWidth).toEqual(2); - expect(convInfo.outChannels).toEqual(16); - expect(convInfo.outShape).toEqual([1, 16, 2, 2, 2]); - // Should produce no padding. - expect(convInfo.padInfo.front).toBe(0); - expect(convInfo.padInfo.back).toBe(0); - expect(convInfo.padInfo.left).toBe(0); - expect(convInfo.padInfo.right).toBe(0); - expect(convInfo.padInfo.top).toBe(0); - expect(convInfo.padInfo.bottom).toBe(0); - }); -}); - -describe('conv_util computeConv2DInfo roundingMode', () => { - const inChannels = 6; - const batchSize = 1; - const inSize = 5; - const inShape: [number, number, number, number] = - [batchSize, inSize, inSize, inChannels]; - const fSize = 2; - const chMul = 12; - const stride = 2; - const dilation = 1; - const pad = 1; - - it('Default truncate the output dimension of Conv Layer', () => { - const convInfo = conv_util.computeConv2DInfo( - inShape, [fSize, fSize, inChannels, chMul], stride, dilation, pad); - - expect(convInfo.outShape).toEqual([batchSize, 3, 3, chMul]); - }); - - it('Floor the output dimension of Conv Layer', () => { - const convInfo = conv_util.computeConv2DInfo( - inShape, [fSize, fSize, inChannels, chMul], stride, dilation, pad, - 'floor'); - - expect(convInfo.outShape).toEqual([batchSize, 3, 3, chMul]); - }); - - it('Round the output dimension of Conv Layer', () => { - const convInfo = conv_util.computeConv2DInfo( - inShape, [fSize, fSize, inChannels, chMul], stride, dilation, pad, - 'round'); - - expect(convInfo.outShape).toEqual([batchSize, 4, 4, chMul]); - }); - - it('Ceil the output dimension of Conv Layer', () => { - const convInfo = conv_util.computeConv2DInfo( - inShape, [fSize, fSize, inChannels, chMul], stride, dilation, pad, - 'ceil'); - - expect(convInfo.outShape).toEqual([batchSize, 4, 4, chMul]); - }); -}); - -describe('conv_util computePoolInfo roundingMode', () => { - const inChannels = 6; - const batchSize = 1; - const inSize = 5; - const inShape: [number, number, number, number] = - [batchSize, inSize, inSize, inChannels]; - const fSize = 2; - const stride = 2; - const dilation = 1; - const pad = 1; - - it('Default truncate the output dimension of Pool Layer', () => { - const poolInfo = conv_util.computePool2DInfo( - inShape, [fSize, fSize], stride, pad, dilation, 'floor'); - - expect(poolInfo.outShape).toEqual([batchSize, 3, 3, inChannels]); - }); - - it('Floor the output dimension of Pool Layer', () => { - const poolInfo = conv_util.computePool2DInfo( - inShape, [fSize, fSize], stride, pad, dilation, 'floor'); - - expect(poolInfo.outShape).toEqual([batchSize, 3, 3, inChannels]); - }); - - it('Round the output dimension of Pool Layer', () => { - const poolInfo = conv_util.computePool2DInfo( - inShape, [fSize, fSize], stride, pad, dilation, 'round'); - - expect(poolInfo.outShape).toEqual([batchSize, 4, 4, inChannels]); - }); - - it('Ceil the output dimension of Pool Layer', () => { - const poolInfo = conv_util.computePool2DInfo( - inShape, [fSize, fSize], stride, pad, dilation, 'ceil'); - - expect(poolInfo.outShape).toEqual([batchSize, 4, 4, inChannels]); - }); -}); - -describe('conv_util computePool3dInfo', () => { - it('1x1x1 pool over 1x1x1 array with valid pad', () => { - const inShape: [number, number, number, number, number] = [1, 1, 1, 1, 1]; - const filterSize = 1; - const stride = 1; - const dilation = 1; - const convInfo = conv_util.computePool3DInfo( - inShape, filterSize, stride, dilation, 'valid'); - expect(convInfo.batchSize).toEqual(1); - expect(convInfo.outDepth).toEqual(1); - expect(convInfo.outHeight).toEqual(1); - expect(convInfo.outWidth).toEqual(1); - expect(convInfo.outChannels).toEqual(1); - expect(convInfo.effectiveFilterDepth).toEqual(1); - expect(convInfo.effectiveFilterWidth).toEqual(1); - expect(convInfo.effectiveFilterHeight).toEqual(1); - }); - - it('1x1x1 pool over 3x3x3 array with valid pad', () => { - const inShape: [number, number, number, number, number] = [1, 3, 3, 3, 1]; - const filterSize = 1; - const stride = 1; - const dilation = 1; - const convInfo = conv_util.computePool3DInfo( - inShape, filterSize, stride, dilation, 'valid'); - expect(convInfo.batchSize).toEqual(1); - expect(convInfo.outDepth).toEqual(3); - expect(convInfo.outHeight).toEqual(3); - expect(convInfo.outWidth).toEqual(3); - expect(convInfo.outChannels).toEqual(1); - expect(convInfo.effectiveFilterDepth).toEqual(1); - expect(convInfo.effectiveFilterWidth).toEqual(1); - expect(convInfo.effectiveFilterHeight).toEqual(1); - }); - - it('2x2x2 pool over 3x3x3 array with same pad', () => { - const inShape: [number, number, number, number, number] = [1, 3, 3, 3, 1]; - const filterSize = 2; - const stride = 1; - const dilation = 1; - const convInfo = conv_util.computePool3DInfo( - inShape, filterSize, stride, dilation, 'same'); - expect(convInfo.batchSize).toEqual(1); - expect(convInfo.outDepth).toEqual(3); - expect(convInfo.outHeight).toEqual(3); - expect(convInfo.outWidth).toEqual(3); - expect(convInfo.outChannels).toEqual(1); - expect(convInfo.effectiveFilterDepth).toEqual(2); - expect(convInfo.effectiveFilterWidth).toEqual(2); - expect(convInfo.effectiveFilterHeight).toEqual(2); - expect(convInfo.padInfo.top).toEqual(0); - expect(convInfo.padInfo.bottom).toEqual(1); - expect(convInfo.padInfo.left).toEqual(0); - expect(convInfo.padInfo.right).toEqual(1); - expect(convInfo.padInfo.front).toEqual(0); - expect(convInfo.padInfo.back).toEqual(1); - expect(convInfo.padInfo.type).toEqual('SAME'); - }); - - it('2x2x2 pool over 3x3x3 array with valid pad', () => { - const inShape: [number, number, number, number, number] = [1, 3, 3, 3, 1]; - const filterSize = 2; - const stride = 1; - const dilation = 1; - const convInfo = conv_util.computePool3DInfo( - inShape, filterSize, stride, dilation, 'valid'); - expect(convInfo.batchSize).toEqual(1); - expect(convInfo.outDepth).toEqual(2); - expect(convInfo.outHeight).toEqual(2); - expect(convInfo.outWidth).toEqual(2); - expect(convInfo.outChannels).toEqual(1); - expect(convInfo.effectiveFilterDepth).toEqual(2); - expect(convInfo.effectiveFilterWidth).toEqual(2); - expect(convInfo.effectiveFilterHeight).toEqual(2); - }); - - it('2x2x2 pool over 4x4x4 array with valid pad, stride 2', () => { - const inShape: [number, number, number, number, number] = [1, 4, 4, 4, 1]; - const filterSize = 2; - const stride = 2; - const dilation = 1; - const convInfo = conv_util.computePool3DInfo( - inShape, filterSize, stride, dilation, 'valid'); - expect(convInfo.batchSize).toEqual(1); - expect(convInfo.outDepth).toEqual(2); - expect(convInfo.outHeight).toEqual(2); - expect(convInfo.outWidth).toEqual(2); - expect(convInfo.outChannels).toEqual(1); - expect(convInfo.effectiveFilterDepth).toEqual(2); - expect(convInfo.effectiveFilterWidth).toEqual(2); - expect(convInfo.effectiveFilterHeight).toEqual(2); - }); - - it('2x2x2 pool over 3x3x3 array with valid pad, dilation 2', () => { - const inShape: [number, number, number, number, number] = [1, 3, 3, 3, 1]; - const filterSize = 2; - const stride = 1; - const dilation = 2; - const convInfo = conv_util.computePool3DInfo( - inShape, filterSize, stride, dilation, 'valid'); - expect(convInfo.batchSize).toEqual(1); - expect(convInfo.outDepth).toEqual(1); - expect(convInfo.outHeight).toEqual(1); - expect(convInfo.outWidth).toEqual(1); - expect(convInfo.outChannels).toEqual(1); - expect(convInfo.effectiveFilterDepth).toEqual(3); - expect(convInfo.effectiveFilterWidth).toEqual(3); - expect(convInfo.effectiveFilterHeight).toEqual(3); - }); - - it('2x2x2 pool over 3x3x3 array with pad 1, roundingMode floor', () => { - const inShape: [number, number, number, number, number] = [1, 3, 3, 3, 1]; - const filterSize = 2; - const stride = 1; - const dilation = 1; - const convInfo = conv_util.computePool3DInfo( - inShape, filterSize, stride, dilation, 1, 'floor'); - expect(convInfo.batchSize).toEqual(1); - expect(convInfo.outDepth).toEqual(4); - expect(convInfo.outHeight).toEqual(4); - expect(convInfo.outWidth).toEqual(4); - expect(convInfo.outChannels).toEqual(1); - expect(convInfo.effectiveFilterDepth).toEqual(2); - expect(convInfo.effectiveFilterWidth).toEqual(2); - expect(convInfo.effectiveFilterHeight).toEqual(2); - expect(convInfo.padInfo.top).toEqual(1); - expect(convInfo.padInfo.bottom).toEqual(1); - expect(convInfo.padInfo.left).toEqual(1); - expect(convInfo.padInfo.right).toEqual(1); - expect(convInfo.padInfo.front).toEqual(1); - expect(convInfo.padInfo.back).toEqual(1); - expect(convInfo.padInfo.type).toEqual('NUMBER'); - }); - - it('throws unknown dataFormat', () => { - const inShape: [number, number, number, number, number] = [1, 3, 3, 3, 1]; - const filterSize = 2; - const stride = 1; - const dilation = 1; - const fakeDataFormat = 'fakeFormat' as 'NDHWC' | 'NCDHW'; - expect( - () => conv_util.computePool3DInfo( - inShape, filterSize, stride, dilation, 1, 'floor', fakeDataFormat)) - .toThrowError(); - }); -}); - -describe('conv_util convertConv2DDataFormat', () => { - it('convert NHWC to channelsLast', () => { - const dataFormat: 'NHWC'|'NCHW' = 'NHWC'; - const $dataFormat = conv_util.convertConv2DDataFormat(dataFormat); - expect($dataFormat).toEqual('channelsLast'); - }); - - it('convert NCHW to channelsFirst', () => { - const dataFormat: 'NHWC'|'NCHW' = 'NCHW'; - const $dataFormat = conv_util.convertConv2DDataFormat(dataFormat); - expect($dataFormat).toEqual('channelsFirst'); - }); - - it('throws unknown dataFormat', () => { - const dataFormat = 'FakeFormat'; - expect( - () => conv_util.convertConv2DDataFormat(dataFormat as 'NHWC' | 'NCHW')) - .toThrowError(); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/cos.ts b/tfjs-master/tfjs-core/src/ops/cos.ts deleted file mode 100644 index 6f3b266d4..000000000 --- a/tfjs-master/tfjs-core/src/ops/cos.ts +++ /dev/null @@ -1,46 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {Cos, CosInputs} from '../kernel_names'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -import {op} from './operation'; - -/** - * Computes cos of the input `tf.Tensor` element-wise: `cos(x)` - * - * ```js - * const x = tf.tensor1d([0, Math.PI / 2, Math.PI * 3 / 4]); - * - * x.cos().print(); // or tf.cos(x) - * ``` - * @param x The input tensor. Must be float32 type. - * - * @doc {heading: 'Operations', subheading: 'Basic math'} - */ -function cos_(x: T|TensorLike): T { - const $x = convertToTensor(x, 'x', 'cos', 'float32'); - - const inputs: CosInputs = {x: $x}; - - return ENGINE.runKernel(Cos, inputs as unknown as NamedTensorMap); -} -export const cos = /* @__PURE__ */ op({cos_}); diff --git a/tfjs-master/tfjs-core/src/ops/cos_test.ts b/tfjs-master/tfjs-core/src/ops/cos_test.ts deleted file mode 100644 index 557aeb173..000000000 --- a/tfjs-master/tfjs-core/src/ops/cos_test.ts +++ /dev/null @@ -1,123 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('cos', ALL_ENVS, () => { - it('basic', async () => { - // Covers every 1/4pi range from -4pi to 4pi. - const values = [1, 3, 4, 6, 7, 9, 10, 12, -1, -3, -4, -6, -7, -9, -10, -12]; - const a = tf.tensor1d(values); - const result = tf.cos(a); - - const expected = []; - for (let i = 0; i < a.size; i++) { - expected[i] = Math.cos(values[i]); - } - expectArraysClose(await result.data(), expected); - }); - - it('propagates NaNs', async () => { - const a = tf.tensor1d([4, NaN, 0]); - const res = tf.cos(a); - expectArraysClose(await res.data(), [Math.cos(4), NaN, Math.cos(0)]); - }); - - it('gradients: Scalar', async () => { - const a = tf.scalar(5); - const dy = tf.scalar(8); - - const gradients = tf.grad(a => tf.cos(a))(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), [8 * Math.sin(5) * -1]); - }); - - it('gradient with clones', async () => { - const a = tf.scalar(5); - const dy = tf.scalar(8); - - const gradients = tf.grad(a => tf.cos(a.clone()).clone())(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), [8 * Math.sin(5) * -1]); - }); - - it('gradients: Tensor1D', async () => { - const a = tf.tensor1d([-1, 2, 3, -5]); - const dy = tf.tensor1d([1, 2, 3, 4]); - - const gradients = tf.grad(a => tf.cos(a))(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose( - await gradients.data(), - [ - 1 * Math.sin(-1) * -1, 2 * Math.sin(2) * -1, 3 * Math.sin(3) * -1, - 4 * Math.sin(-5) * -1 - ], - 1e-1); - }); - - it('gradients: Tensor2D', async () => { - const a = tf.tensor2d([-3, 1, 2, 3], [2, 2]); - const dy = tf.tensor2d([1, 2, 3, 4], [2, 2]); - - const gradients = tf.grad(a => tf.cos(a))(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose( - await gradients.data(), - [ - 1 * Math.sin(-3) * -1, 2 * Math.sin(1) * -1, 3 * Math.sin(2) * -1, - 4 * Math.sin(3) * -1 - ], - 1e-1); - }); - - it('throws when passed a non-tensor', () => { - expect(() => tf.cos({} as tf.Tensor)) - .toThrowError(/Argument 'x' passed to 'cos' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const values = [1, -3, 2, 7, -4]; - const result = tf.cos(values); - - const expected = []; - for (let i = 0; i < values.length; i++) { - expected[i] = Math.cos(values[i]); - } - expectArraysClose(await result.data(), expected); - }); - - it('throws for string tensor', () => { - expect(() => tf.cos('q')) - .toThrowError(/Argument 'x' passed to 'cos' must be float32/); - }); - - it('throws for int32 tensor', async () => { - expect(() => tf.cos(tf.tensor([10], [1], 'int32'))) - .toThrowError(/Argument 'x' passed to 'cos' must be float32/); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/cosh.ts b/tfjs-master/tfjs-core/src/ops/cosh.ts deleted file mode 100644 index 1bfb9f3e2..000000000 --- a/tfjs-master/tfjs-core/src/ops/cosh.ts +++ /dev/null @@ -1,45 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {Cosh, CoshInputs} from '../kernel_names'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -import {op} from './operation'; - -/** - * Computes hyperbolic cos of the input `tf.Tensor` element-wise: `cosh(x)` - * - * ```js - * const x = tf.tensor1d([0, 1, -1, .7]); - * - * x.cosh().print(); // or tf.cosh(x) - * ``` - * @param x The input tensor. Must be float32 type. - * - * @doc {heading: 'Operations', subheading: 'Basic math'} - */ -function cosh_(x: T|TensorLike): T { - const $x = convertToTensor(x, 'x', 'cosh', 'float32'); - const inputs: CoshInputs = {x: $x}; - - return ENGINE.runKernel(Cosh, inputs as unknown as NamedTensorMap); -} -export const cosh = /* @__PURE__ */ op({cosh_}); diff --git a/tfjs-master/tfjs-core/src/ops/cosh_test.ts b/tfjs-master/tfjs-core/src/ops/cosh_test.ts deleted file mode 100644 index ad1da9600..000000000 --- a/tfjs-master/tfjs-core/src/ops/cosh_test.ts +++ /dev/null @@ -1,126 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('cosh', ALL_ENVS, () => { - it('basic', async () => { - const values = [1, -3, 2, -1, -4]; - const a = tf.tensor1d(values); - const result = tf.cosh(a); - - const expected = []; - for (let i = 0; i < a.size; i++) { - expected[i] = Math.cosh(values[i]); - } - - expectArraysClose(await result.data(), expected); - }); - - it('propagates NaNs', async () => { - const a = tf.tensor1d([4, NaN, 0]); - const res = tf.cosh(a); - expectArraysClose(await res.data(), [Math.cosh(4), NaN, Math.cosh(0)]); - }); - - it('gradients: Scalar', async () => { - const a = tf.scalar(0.5); - const dy = tf.scalar(8); - - const gradients = tf.grad(a => tf.cosh(a))(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), [8 * Math.sinh(0.5)]); - }); - - it('gradient with clones', async () => { - const a = tf.scalar(0.5); - const dy = tf.scalar(8); - - const gradients = tf.grad(a => tf.cosh(a.clone()).clone())(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), [8 * Math.sinh(0.5)]); - }); - - it('gradients: Tensor1D', async () => { - const aValues = [-1, 2, 3, -5]; - const dyValues = [1, 2, 3, 4]; - const a = tf.tensor1d(aValues); - const dy = tf.tensor1d(dyValues); - - const gradients = tf.grad(a => tf.cosh(a))(a, dy); - - const expected = []; - for (let i = 0; i < a.size; i++) { - expected[i] = dyValues[i] * Math.sinh(aValues[i]); - } - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), expected); - }); - - it('gradients: Tensor2D', async () => { - const aValues = [-3, 1, 2, 3]; - const dyValues = [1, 2, 3, 4]; - const a = tf.tensor2d(aValues, [2, 2]); - const dy = tf.tensor2d(dyValues, [2, 2]); - - const gradients = tf.grad(a => tf.cosh(a))(a, dy); - - const expected = []; - for (let i = 0; i < a.size; i++) { - expected[i] = dyValues[i] * Math.sinh(aValues[i]); - } - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), expected); - }); - - it('throws when passed a non-tensor', () => { - expect(() => tf.cosh({} as tf.Tensor)) - .toThrowError(/Argument 'x' passed to 'cosh' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const values = [1, -3, 2, -1, -4]; - const result = tf.cosh(values); - - const expected = []; - for (let i = 0; i < values.length; i++) { - expected[i] = Math.cosh(values[i]); - } - - expectArraysClose(await result.data(), expected); - }); - - it('throws for string tensor', () => { - expect(() => tf.cosh('q')) - .toThrowError(/Argument 'x' passed to 'cosh' must be float32/); - }); - - it('throws for int32 tensor', () => { - expect(() => tf.cosh(tf.tensor([10], [1], 'int32'))) - .toThrowError(/Argument 'x' passed to 'cosh' must be float32/); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/cumprod.ts b/tfjs-master/tfjs-core/src/ops/cumprod.ts deleted file mode 100644 index e88cd9f5b..000000000 --- a/tfjs-master/tfjs-core/src/ops/cumprod.ts +++ /dev/null @@ -1,69 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the 'License'); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import { ENGINE } from '../engine'; -import { Cumprod, CumprodAttrs, CumprodInputs } from '../kernel_names'; -import { NamedAttrMap } from '../kernel_registry'; -import { Tensor } from '../tensor'; -import { NamedTensorMap } from '../tensor_types'; -import { convertToTensor } from '../tensor_util_env'; -import { TensorLike } from '../types'; - -import { op } from './operation'; - -/** - * Computes the cumulative product of a `tf.Tensor` along `axis`. - * - * ```js - * const x = tf.tensor([1, 2, 3, 4]); - * x.cumprod().print(); - * ``` - * ```js - * const x = tf.tensor([[1, 2], [3, 4]]); - * x.cumprod().print(); - * ``` - * - * @param x The input tensor to cumulatively multiply. - * @param axis The axis along which to multiply. Optional. Defaults to 0. - * @param exclusive Whether to perform exclusive cumulative product. Optional. - * Defaults to false. If set to true then the product of each tensor entry - * does not include its own value, but only the values previous to it - * along the specified axis. - * @param reverse Whether to multiply in the opposite direction. Optional. - * Defaults to false. - * - * @doc {heading: 'Operations', subheading: 'Scan'} - */ -function cumprod_( - x: Tensor | TensorLike, - axis = 0, - exclusive = false, - reverse = false -): T { - const $x = convertToTensor(x, 'x', 'cumprod'); - - const inputs: CumprodInputs = { x: $x }; - const attrs: CumprodAttrs = { axis, exclusive, reverse }; - - return ENGINE.runKernel( - Cumprod, - inputs as unknown as NamedTensorMap, - attrs as unknown as NamedAttrMap - ); -} - -export const cumprod = /* @__PURE__ */ op({ cumprod_ }); diff --git a/tfjs-master/tfjs-core/src/ops/cumprod_test.ts b/tfjs-master/tfjs-core/src/ops/cumprod_test.ts deleted file mode 100644 index 4e9d2a54a..000000000 --- a/tfjs-master/tfjs-core/src/ops/cumprod_test.ts +++ /dev/null @@ -1,167 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the 'License'); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import { ALL_ENVS, describeWithFlags } from '../jasmine_util'; -import { expectArraysClose } from '../test_util'; - -describeWithFlags('cumprod', ALL_ENVS, () => { - it('1D standard', async () => { - const res = tf.tensor1d([1, 2, 3, 4]).cumprod(); - expect(res.shape).toEqual([4]); - expectArraysClose(await res.data(), [1, 2, 6, 24]); - }); - - it('1D reverse', async () => { - const reverse = true; - const exclusive = false; - const res = tf.tensor1d([1, 2, 3, 4]).cumprod(0, exclusive, reverse); - expect(res.shape).toEqual([4]); - expectArraysClose(await res.data(), [24, 24, 12, 4]); - }); - - it('1D exclusive', async () => { - const exclusive = true; - const res = tf.tensor1d([1, 2, 3, 4]).cumprod(0, exclusive); - expect(res.shape).toEqual([4]); - expectArraysClose(await res.data(), [1, 1, 2, 6]); - }); - - it('1D exclusive reverse', async () => { - const reverse = true; - const exclusive = true; - const res = tf.tensor1d([1, 2, 3, 4]).cumprod(0, exclusive, reverse); - expect(res.shape).toEqual([4]); - expectArraysClose(await res.data(), [24, 12, 4, 1]); - }); - - // TODO: once gradients are implemented, create tests something like this. - // it('gradient: 1D', async () => { - // const a = tf.tensor1d([1, 2, 3]); - // const dy = tf.tensor1d([4, 5, 6]); - // const da = tf.grad((x) => tf.cumprod(x))(a, dy); - - // expect(da.shape).toEqual([3]); - // expectArraysClose(await da.data(), [15, 11, 6]); - // }); - - // it('gradient with clones', async () => { - // const a = tf.tensor1d([1, 2, 3]); - // const dy = tf.tensor1d([4, 5, 6]); - // const da = tf.grad((x) => tf.cumprod(x.clone()).clone())(a, dy); - - // expect(da.shape).toEqual([3]); - // expectArraysClose(await da.data(), [15, 11, 6]); - // }); - - it('2D standard', async () => { - const res = tf - .tensor2d([ - [1, 2], - [3, 4], - ]) - .cumprod(1); - expect(res.shape).toEqual([2, 2]); - expectArraysClose(await res.array(), [[1, 2], [3, 12]]); - }); - - it('2D reverse exclusive', async () => { - const reverse = true; - const exclusive = true; - const res = tf - .tensor2d([ - [1, 2], - [3, 4], - ]) - .cumprod(1, exclusive, reverse); - expect(res.shape).toEqual([2, 2]); - expectArraysClose(await res.array(), [[2, 1], [4, 1]]); - }); - - it('2D axis=0', async () => { - const res = tf - .tensor2d([ - [1, 2], - [3, 4], - ]) - .cumprod(); - expect(res.shape).toEqual([2, 2]); - expectArraysClose(await res.array(), [[1, 2], [3, 8]]); - }); - - it('3D standard', async () => { - const res = tf - .tensor3d([ - [ - [0, 1], - [2, 3], - ], - [ - [4, 5], - [6, 7], - ], - ]) - .cumprod(2); - expect(res.shape).toEqual([2, 2, 2]); - expectArraysClose(await res.array(), [ - [ - [0, 0 * 1], - [2, 2 * 3] - ], - [ - [4, 4 * 5], - [6, 6 * 7] - ] - ]); - }); - - it('4d axis=2', async () => { - const input = tf.add(tf.ones([1, 32, 8, 4]), tf.ones([1, 32, 8, 4])); - const res = tf.cumprod(input, 2, false, false); - - expect(res.shape).toEqual([1, 32, 8, 4]); - - const earlySlice = tf.slice(res, [0, 0, 0, 0], [1, 1, 8, 1]); - const lateSlice = tf.slice(res, [0, 31, 0, 0], [1, 1, 8, 1]); - const expectedDataInEachSlice = [2, 4, 8, 16, 32, 64, 128, 256]; - expectArraysClose(await earlySlice.data(), expectedDataInEachSlice); - expectArraysClose(await lateSlice.data(), expectedDataInEachSlice); - }); - - it('handle permutation properly', async () => { - const res = tf.ones([1, 240, 1, 10]).cumprod(1); - expect(res.shape).toEqual([1, 240, 1, 10]); - }); - - it('throws when passed a non-tensor', () => { - expect(() => tf.cumprod({} as tf.Tensor)).toThrowError( - /Argument 'x' passed to 'cumprod' must be a Tensor/ - ); - }); - - it('accepts a tensor-like object', async () => { - const res = tf.cumprod([1, 2, 3, 4]); - expect(res.shape).toEqual([4]); - expectArraysClose(await res.data(), [1, 2, 6, 24]); - }); - - it('throws error for string tensor', () => { - expect(() => tf.cumprod(['a', 'b', 'c'])).toThrowError( - /Argument 'x' passed to 'cumprod' must be numeric tensor/ - ); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/cumsum.ts b/tfjs-master/tfjs-core/src/ops/cumsum.ts deleted file mode 100644 index f6c781efa..000000000 --- a/tfjs-master/tfjs-core/src/ops/cumsum.ts +++ /dev/null @@ -1,63 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {Cumsum, CumsumAttrs, CumsumInputs} from '../kernel_names'; -import {NamedAttrMap} from '../kernel_registry'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -import {op} from './operation'; - -/** - * Computes the cumulative sum of a `tf.Tensor` along `axis`. - * - * ```js - * const x = tf.tensor([1, 2, 3, 4]); - * x.cumsum().print(); - * ``` - * ```js - * const x = tf.tensor([[1, 2], [3, 4]]); - * x.cumsum().print(); - * ``` - * - * @param x The input tensor to be summed. - * @param axis The axis along which to sum. Optional. Defaults to 0. - * @param exclusive Whether to perform exclusive cumulative sum. Optional. - * Defaults to false. If set to true then the sum of each tensor entry - * does not include its own value, but only the values previous to it - * along the specified axis. - * @param reverse Whether to sum in the opposite direction. Optional. - * Defaults to false. - * - * @doc {heading: 'Operations', subheading: 'Scan'} - */ -function cumsum_( - x: Tensor|TensorLike, axis = 0, exclusive = false, reverse = false): T { - const $x = convertToTensor(x, 'x', 'cumsum'); - - const inputs: CumsumInputs = {x: $x}; - const attrs: CumsumAttrs = {axis, exclusive, reverse}; - - return ENGINE.runKernel( - Cumsum, inputs as unknown as NamedTensorMap, - attrs as unknown as NamedAttrMap); -} - -export const cumsum = /* @__PURE__ */ op({cumsum_}); diff --git a/tfjs-master/tfjs-core/src/ops/cumsum_test.ts b/tfjs-master/tfjs-core/src/ops/cumsum_test.ts deleted file mode 100644 index e37361cf5..000000000 --- a/tfjs-master/tfjs-core/src/ops/cumsum_test.ts +++ /dev/null @@ -1,134 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('cumsum', ALL_ENVS, () => { - it('1D standard', async () => { - const res = tf.tensor1d([1, 2, 3, 4]).cumsum(); - expect(res.shape).toEqual([4]); - expectArraysClose(await res.data(), [1, 3, 6, 10]); - }); - - it('1D reverse', async () => { - const reverse = true; - const exclusive = false; - const res = tf.tensor1d([1, 2, 3, 4]).cumsum(0, exclusive, reverse); - expect(res.shape).toEqual([4]); - expectArraysClose(await res.data(), [10, 9, 7, 4]); - }); - - it('1D exclusive', async () => { - const exclusive = true; - const res = tf.tensor1d([1, 2, 3, 4]).cumsum(0, exclusive); - expect(res.shape).toEqual([4]); - expectArraysClose(await res.data(), [0, 1, 3, 6]); - }); - - it('1D exclusive reverse', async () => { - const reverse = true; - const exclusive = true; - const res = tf.tensor1d([1, 2, 3, 4]).cumsum(0, exclusive, reverse); - expect(res.shape).toEqual([4]); - expectArraysClose(await res.data(), [9, 7, 4, 0]); - }); - - it('gradient: 1D', async () => { - const a = tf.tensor1d([1, 2, 3]); - const dy = tf.tensor1d([4, 5, 6]); - const da = tf.grad(x => tf.cumsum(x))(a, dy); - - expect(da.shape).toEqual([3]); - expectArraysClose(await da.data(), [15, 11, 6]); - }); - - it('gradient with clones', async () => { - const a = tf.tensor1d([1, 2, 3]); - const dy = tf.tensor1d([4, 5, 6]); - const da = tf.grad(x => tf.cumsum(x.clone()).clone())(a, dy); - - expect(da.shape).toEqual([3]); - expectArraysClose(await da.data(), [15, 11, 6]); - }); - - it('2D standard', async () => { - const res = tf.tensor2d([[1, 2], [3, 4]]).cumsum(1); - expect(res.shape).toEqual([2, 2]); - expectArraysClose(await res.data(), [1, 3, 3, 7]); - }); - - it('2D reverse exclusive', async () => { - const reverse = true; - const exclusive = true; - const res = tf.tensor2d([[1, 2], [3, 4]]).cumsum(1, exclusive, reverse); - expect(res.shape).toEqual([2, 2]); - expectArraysClose(await res.data(), [2, 0, 4, 0]); - }); - - it('2D axis=0', async () => { - const res = tf.tensor2d([[1, 2], [3, 4]]).cumsum(); - expect(res.shape).toEqual([2, 2]); - expectArraysClose(await res.data(), [1, 2, 4, 6]); - }); - - it('3D standard', async () => { - const res = tf.tensor3d([[[0, 1], [2, 3]], [[4, 5], [6, 7]]]).cumsum(2); - expect(res.shape).toEqual([2, 2, 2]); - expectArraysClose(await res.data(), [0, 1, 2, 5, 4, 9, 6, 13]); - }); - - it('4d axis=2', async () => { - const input = tf.ones([1, 32, 46, 4]); - const res = tf.cumsum(input, 2, false, false); - - expect(res.shape).toEqual([1, 32, 46, 4]); - - const earlySlice = tf.slice(res, [0, 0, 0, 0], [1, 1, 46, 1]); - const lateSlice = tf.slice(res, [0, 31, 0, 0], [1, 1, 46, 1]); - const expectedDataInEachSlice = [ - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, - 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, - 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46 - ]; - expectArraysClose(await earlySlice.data(), expectedDataInEachSlice); - expectArraysClose(await lateSlice.data(), expectedDataInEachSlice); - }); - - it('handle permutation properly', async () => { - const res = tf.ones([1, 240, 1, 10]).cumsum(1); - expect(res.shape).toEqual([1, 240, 1, 10]); - }); - - it('throws when passed a non-tensor', () => { - expect(() => tf.cumsum({} as tf.Tensor)) - .toThrowError(/Argument 'x' passed to 'cumsum' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const res = tf.cumsum([1, 2, 3, 4]); - expect(res.shape).toEqual([4]); - expectArraysClose(await res.data(), [1, 3, 6, 10]); - }); - - it('throws error for string tensor', () => { - expect(() => tf.cumsum([ - 'a', 'b', 'c' - ])).toThrowError(/Argument 'x' passed to 'cumsum' must be numeric tensor/); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/dense_bincount.ts b/tfjs-master/tfjs-core/src/ops/dense_bincount.ts deleted file mode 100644 index cab19e466..000000000 --- a/tfjs-master/tfjs-core/src/ops/dense_bincount.ts +++ /dev/null @@ -1,78 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {DenseBincount, DenseBincountAttrs, DenseBincountInputs} from '../kernel_names'; -import {NamedAttrMap} from '../kernel_registry'; -import {Tensor1D, Tensor2D} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; -import * as util from '../util'; - -import {op} from './operation'; - -/** - * Outputs a vector with length `size` and the same dtype as `weights`. - * - * If `weights` are empty, then index `i` stores the number of times the value - * `i` is counted in `x`. If `weights` are non-empty, then index `i` stores the - * sum of the value in `weights` at each index where the corresponding value in - * `x` is `i`. - * - * Values in `x` outside of the range [0, size) are ignored. - * - * @param x The input int tensor, rank 1 or rank 2. - * @param weights The weights tensor, must have the same shape as x, or a - * length-0 Tensor, in which case it acts as all weights equal to 1. - * @param size Non-negative integer. - * @param binaryOutput Optional. Whether the kernel should count the appearance - * or number of occurrences. Defaults to False. - * - * @doc {heading: 'Operations', subheading: 'Reduction'} - */ -function denseBincount_( - x: T|TensorLike, weights: T|TensorLike, size: number, - binaryOutput = false): T { - const $x = convertToTensor(x, 'x', 'denseBincount'); - const $weights = convertToTensor(weights, 'weights', 'denseBincount'); - - util.assert( - $x.dtype === 'int32', - () => `Error in denseBincount: input ` + - `dtype must be int32, but got ${$x.dtype}`); - util.assert( - $x.rank <= 2, - () => `Error in denseBincount: input must be at most rank 2, but got ` + - `rank ${$x.rank}.`); - util.assert(size >= 0, () => `size must be non-negative, but got ${size}.`); - util.assert( - $weights.size === $x.size || $weights.size === 0, - () => - `Error in denseBincount: weights must have the same shape as x or ` + - `0-length, but got x shape: ${$x.shape}, weights shape: ` + - `${$weights.shape}.`); - - const inputs: DenseBincountInputs = {x: $x, weights: $weights}; - const attrs: DenseBincountAttrs = {size, binaryOutput}; - - return ENGINE.runKernel( - DenseBincount, inputs as unknown as NamedTensorMap, - attrs as unknown as NamedAttrMap); -} - -export const denseBincount = /* @__PURE__ */ op({denseBincount_}); diff --git a/tfjs-master/tfjs-core/src/ops/dense_bincount_test.ts b/tfjs-master/tfjs-core/src/ops/dense_bincount_test.ts deleted file mode 100644 index c7a623b04..000000000 --- a/tfjs-master/tfjs-core/src/ops/dense_bincount_test.ts +++ /dev/null @@ -1,144 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('denseBincount', ALL_ENVS, () => { - it('with 0-length weights.', async () => { - const x = tf.tensor1d([1, 1, 1, 2], 'int32'); - const weights = tf.tensor1d([]); - const size = 3; - - const result = tf.denseBincount(x, weights, size); - - expect(result.shape).toEqual([3]); - expectArraysClose(await result.data(), [0, 3, 1]); - }); - - it('with number out of range.', async () => { - const x = tf.tensor1d([1, 1, 1, 2], 'int32'); - const weights = tf.tensor1d([]); - const size = 2; - - const result = tf.denseBincount(x, weights, size); - - expect(result.shape).toEqual([2]); - expectArraysClose(await result.data(), [0, 3]); - }); - - it('with 1d float weights.', async () => { - const x = tf.tensor1d([1, 1, 1, 2], 'int32'); - const weights = tf.tensor1d([0.5, 0.3, 0.3, 0.1]); - const size = 3; - - const result = tf.denseBincount(x, weights, size); - - expect(result.shape).toEqual([3]); - expectArraysClose(await result.data(), [0, 1.1, 0.1]); - }); - - it('with 1d float weights and number out of range.', async () => { - const x = tf.tensor1d([1, 1, 1, 2], 'int32'); - const weights = tf.tensor1d([0.5, 0.3, 0.3, 0.1]); - const size = 2; - - const result = tf.denseBincount(x, weights, size); - - expect(result.shape).toEqual([2]); - expectArraysClose(await result.data(), [0, 1.1]); - }); - - it('with 2d inputs and 0-length weights.', async () => { - const x = tf.tensor2d([[1, 1], [1, 2]], [2, 2], 'int32'); - const weights = tf.tensor2d([], [0, 0]); - const size = 3; - - const result = tf.denseBincount(x, weights, size); - - expect(result.shape).toEqual([2, 3]); - expectArraysClose(await result.data(), [0, 2, 0, 0, 1, 1]); - }); - - it('with 2d inputs and 0-length weights and number out of range.', - async () => { - const x = tf.tensor2d([[1, 1], [1, 2]], [2, 2], 'int32'); - const weights = tf.tensor2d([], [0, 0]); - const size = 2; - - const result = tf.denseBincount(x, weights, size); - - expect(result.shape).toEqual([2, 2]); - expectArraysClose(await result.data(), [0, 2, 0, 1]); - }); - - it('with 2d inputs and 2d weights.', async () => { - const x = tf.tensor2d([[1, 1], [1, 2]], [2, 2], 'int32'); - const weights = tf.tensor2d([[0.5, 0.3], [0.3, 0.1]]); - const size = 3; - - const result = tf.denseBincount(x, weights, size); - - expect(result.shape).toEqual([2, 3]); - expectArraysClose(await result.data(), [0, 0.8, 0, 0, 0.3, 0.1]); - }); - - it('throws error for non int x tensor.', async () => { - const x = tf.tensor1d([1, 1, 1, 2], 'float32'); - const weights = tf.tensor1d([]); - const size = 3; - - expect(() => tf.denseBincount(x, weights, size)).toThrowError(); - }); - - it('throws error if size is negative.', async () => { - const x = tf.tensor1d([1, 1, 1, 2], 'int32'); - const weights = tf.tensor1d([]); - const size = -1; - - expect(() => tf.denseBincount(x, weights, size)).toThrowError(); - }); - - it('throws error when shape is different for 1d.', async () => { - const x = tf.tensor1d([1, 1, 1, 2], 'int32'); - const weights = tf.tensor1d([0.5, 0.3]); - const size = 2; - - expect(() => tf.denseBincount(x, weights, size)).toThrowError(); - }); - - it('throws error when shape is different for 2d.', async () => { - const x = tf.tensor2d([[1, 1], [1, 2]], [2, 2], 'int32'); - const weights = tf.tensor2d([[0.5], [0.3]]); - const size = 3; - - expect(() => tf.denseBincount(x, weights, size)).toThrowError(); - }); - - it('handle output from other ops.', async () => { - const x = tf.tensor1d([1, 1, 1, 2], 'int32'); - const weights = tf.tensor1d([]); - const size = 4; - - const result = tf.denseBincount( - tf.add(x, tf.scalar(1, 'int32')), weights, size); - - expect(result.shape).toEqual([4]); - expectArraysClose(await result.data(), [0, 0, 3, 1]); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/depth_to_space.ts b/tfjs-master/tfjs-core/src/ops/depth_to_space.ts deleted file mode 100644 index b48d5eb5a..000000000 --- a/tfjs-master/tfjs-core/src/ops/depth_to_space.ts +++ /dev/null @@ -1,105 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {DepthToSpace, DepthToSpaceAttrs, DepthToSpaceInputs} from '../kernel_names'; -import {NamedAttrMap} from '../kernel_registry'; -import {Tensor4D} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike4D} from '../types'; -import * as util from '../util'; - -import {op} from './operation'; - -/** - * Rearranges data from depth into blocks of spatial data. More specifically, - * this op outputs a copy of the input tensor where values from the `depth` - * dimension are moved in spatial blocks to the `height` and `width` dimensions. - * The attr `blockSize` indicates the input block size and how the data is - * moved. - * - * - Chunks of data of size `blockSize * blockSize` from depth are rearranged - * into non-overlapping blocks of size `blockSize x blockSize` - * - * - The width the output tensor is `inputWidth * blockSize`, whereas the - * height is `inputHeight * blockSize` - * - * - The Y, X coordinates within each block of the output image are determined - * by the high order component of the input channel index - * - * - The depth of the input tensor must be divisible by `blockSize * - * blockSize` - * - * The `dataFormat` attr specifies the layout of the input and output tensors - * with the following options: "NHWC": [ `batch, height, width, channels` ] - * "NCHW": [ `batch, channels, height, width` ] - * - * ```js - * const x = tf.tensor4d([1, 2, 3, 4], [1, 1, 1, 4]); - * const blockSize = 2; - * const dataFormat = "NHWC"; - * - * tf.depthToSpace(x, blockSize, dataFormat).print(); - * ``` - * - * @param x The input tensor of rank 4 - * @param blockSIze An `int` that is `>= 2`. The size of the spatial block - * @param dataFormat An optional string from: "NHWC", "NCHW". Defaults to "NHWC" - * - * @doc {heading: 'Tensors', subheading: 'Transformations'} - */ -function depthToSpace_( - x: Tensor4D|TensorLike4D, blockSize: number, - dataFormat: 'NHWC'|'NCHW' = 'NHWC'): Tensor4D { - const $x = convertToTensor(x, 'x', 'depthToSpace', 'float32') as Tensor4D; - - const inputHeight = (dataFormat === 'NHWC') ? $x.shape[1] : $x.shape[2]; - const inputWidth = (dataFormat === 'NHWC') ? $x.shape[2] : $x.shape[3]; - const inputDepth = (dataFormat === 'NHWC') ? $x.shape[3] : $x.shape[1]; - - util.assert( - blockSize > 1, - () => `blockSize should be > 1 for depthToSpace, but was: ${blockSize}`); - - util.assert( - inputHeight * blockSize >= 0, - () => `Negative dimension size caused by overflow when multiplying - ${inputHeight} and ${blockSize} for depthToSpace with input shape - ${$x.shape}`); - - util.assert( - inputWidth * blockSize >= 0, - () => `Negative dimension size caused by overflow when multiplying - ${inputWidth} and ${blockSize} for depthToSpace with input shape - ${$x.shape}`); - - util.assert( - (inputDepth % (blockSize * blockSize) === 0), - () => `Dimension size must be evenly divisible by ${ - blockSize * blockSize} but is ${ - inputDepth} for depthToSpace with input shape ${$x.shape}`); - - const inputs: DepthToSpaceInputs = {x: $x}; - const attrs: DepthToSpaceAttrs = {blockSize, dataFormat}; - - return ENGINE.runKernel( - DepthToSpace, inputs as unknown as NamedTensorMap, - attrs as unknown as NamedAttrMap); -} - -export const depthToSpace = /* @__PURE__ */ op({depthToSpace_}); diff --git a/tfjs-master/tfjs-core/src/ops/depth_to_space_test.ts b/tfjs-master/tfjs-core/src/ops/depth_to_space_test.ts deleted file mode 100644 index 7811387f2..000000000 --- a/tfjs-master/tfjs-core/src/ops/depth_to_space_test.ts +++ /dev/null @@ -1,90 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, BROWSER_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('depthToSpace', ALL_ENVS, () => { - it('tensor4d, input shape=[1, 1, 1, 4], blockSize=2, format=NHWC', - async () => { - const t = tf.tensor4d([[[[1, 2, 3, 4]]]]); - const blockSize = 2; - const dataFormat = 'NHWC'; - - const res = tf.depthToSpace(t, blockSize, dataFormat); - expect(res.shape).toEqual([1, 2, 2, 1]); - expectArraysClose(await res.data(), [1, 2, 3, 4]); - }); - - it('tensor4d, input shape=[1, 1, 1, 12], blockSize=2, format=NHWC', - async () => { - const t = tf.tensor4d([[[[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]]]]); - const blockSize = 2; - const dataFormat = 'NHWC'; - - const res = tf.depthToSpace(t, blockSize, dataFormat); - expect(res.shape).toEqual([1, 2, 2, 3]); - expectArraysClose( - await res.data(), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]); - }); - - it('tensor4d, input shape=[1, 2, 2, 4], blockSize=2, format=NHWC', - async () => { - const t = tf.tensor4d([ - [[[1, 2, 3, 4], [5, 6, 7, 8]], [[9, 10, 11, 12], [13, 14, 15, 16]]] - ]); - const blockSize = 2; - const dataFormat = 'NHWC'; - - const res = tf.depthToSpace(t, blockSize, dataFormat); - expect(res.shape).toEqual([1, 4, 4, 1]); - expectArraysClose( - await res.data(), - [1, 2, 5, 6, 3, 4, 7, 8, 9, 10, 13, 14, 11, 12, 15, 16]); - }); - - it('throws when depth not divisible by blockSize * blockSize', () => { - const t = tf.tensor4d([1, 2, 3, 4], [1, 1, 1, 4]); - const blockSize = 3; - - expect(() => tf.depthToSpace(t, blockSize)) - .toThrowError(`Dimension size must be evenly divisible by ${ - blockSize * blockSize} but is ${ - t.shape[3]} for depthToSpace with input shape ${t.shape}`); - }); - - it('throws for int32 input', async () => { - const t = tf.tensor4d([[[[1, 2, 3, 4]]]], [1, 1, 1, 4], 'int32'); - const blockSize = 2; - const dataFormat = 'NHWC'; - - expect(() => tf.depthToSpace(t, blockSize, dataFormat)) - .toThrowError(/Argument 'x' passed to 'depthToSpace' must be float32/); - }); -}); - -describeWithFlags('depthToSpace', BROWSER_ENVS, () => { - it('throws when blocksize < 2', () => { - const t = tf.tensor4d([1, 2, 3, 4], [1, 1, 1, 4]); - const blockSize = 1; - - expect(() => tf.depthToSpace(t, blockSize)) - .toThrowError( - `blockSize should be > 1 for depthToSpace, but was: ${blockSize}`); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/depthwise_conv2d.ts b/tfjs-master/tfjs-core/src/ops/depthwise_conv2d.ts deleted file mode 100644 index 67d8c0eee..000000000 --- a/tfjs-master/tfjs-core/src/ops/depthwise_conv2d.ts +++ /dev/null @@ -1,122 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {ENGINE} from '../engine'; -import {DepthwiseConv2dNative, DepthwiseConv2dNativeAttrs, DepthwiseConv2dNativeInputs} from '../kernel_names'; -import {NamedAttrMap} from '../kernel_registry'; -import {Tensor3D, Tensor4D} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; -import * as util from '../util'; - -import * as conv_util from './conv_util'; -import {op} from './operation'; -import {reshape} from './reshape'; - -/** - * Depthwise 2D convolution. - * - * Given a 4D `input` array and a `filter` array of shape - * `[filterHeight, filterWidth, inChannels, channelMultiplier]` containing - * `inChannels` convolutional filters of depth 1, this op applies a - * different filter to each input channel (expanding from 1 channel to - * `channelMultiplier` channels for each), then concatenates the results - * together. The output has `inChannels * channelMultiplier` channels. - * - * See - * [https://www.tensorflow.org/api_docs/python/tf/nn/depthwise_conv2d]( - * https://www.tensorflow.org/api_docs/python/tf/nn/depthwise_conv2d) - * for more details. - * - * @param x The input tensor, of rank 4 or rank 3, of shape - * `[batch, height, width, inChannels]`. If rank 3, batch of 1 is - * assumed. - * @param filter The filter tensor, rank 4, of shape - * `[filterHeight, filterWidth, inChannels, channelMultiplier]`. - * @param strides The strides of the convolution: `[strideHeight, - * strideWidth]`. If strides is a single number, then `strideHeight == - * strideWidth`. - * @param pad The type of padding algorithm. - * - `same` and stride 1: output will be of same size as input, - * regardless of filter size. - * - `valid`: output will be smaller than input if filter is larger - * than 1x1. - * - For more info, see this guide: - * [https://www.tensorflow.org/api_docs/python/tf/nn/convolution]( - * https://www.tensorflow.org/api_docs/python/tf/nn/convolution) - * @param dilations The dilation rates: `[dilationHeight, dilationWidth]` - * in which we sample input values across the height and width dimensions - * in atrous convolution. Defaults to `[1, 1]`. If `rate` is a single - * number, then `dilationHeight == dilationWidth`. If it is greater than - * 1, then all values of `strides` must be 1. - * @param dataFormat: An optional string from: "NHWC", "NCHW". Defaults to - * "NHWC". Specify the data format of the input and output data. With the - * default format "NHWC", the data is stored in the order of: [batch, - * height, width, channels]. Only "NHWC" is currently supported. - * @param dimRoundingMode A string from: 'ceil', 'round', 'floor'. If none is - * provided, it will default to truncate. - * - * @doc {heading: 'Operations', subheading: 'Convolution'} - */ -function depthwiseConv2d_( - x: T|TensorLike, filter: Tensor4D|TensorLike, - strides: [number, number]|number, - pad: 'valid'|'same'|number|conv_util.ExplicitPadding, - dataFormat: 'NHWC'|'NCHW' = 'NHWC', - dilations: [number, number]|number = [1, 1], - dimRoundingMode?: 'floor'|'round'|'ceil'): T { - const $x = convertToTensor(x, 'x', 'depthwiseConv2d', 'float32'); - const $filter = - convertToTensor(filter, 'filter', 'depthwiseConv2d', 'float32'); - - let x4D = $x as Tensor4D; - let reshapedTo4D = false; - if ($x.rank === 3) { - reshapedTo4D = true; - x4D = reshape($x, [1, $x.shape[0], $x.shape[1], $x.shape[2]]); - } - util.assert( - x4D.rank === 4, - () => `Error in depthwiseConv2d: input must be rank 4, but got ` + - `rank ${x4D.rank}.`); - util.assert( - $filter.rank === 4, - () => `Error in depthwiseConv2d: filter must be rank 4, but got rank ` + - `${$filter.rank}.`); - const inChannels = dataFormat === 'NHWC' ? x4D.shape[3] : x4D.shape[1]; - util.assert( - inChannels === $filter.shape[2], - () => `Error in depthwiseConv2d: number of input channels ` + - `(${inChannels}) must match the inChannels dimension in ` + - `filter ${$filter.shape[2]}.`); - conv_util.checkPadOnDimRoundingMode('depthwiseConv2d', pad, dimRoundingMode); - const inputs: DepthwiseConv2dNativeInputs = {x: x4D, filter: $filter}; - const attrs: DepthwiseConv2dNativeAttrs = - {strides, pad, dataFormat, dilations, dimRoundingMode}; - - // tslint:disable-next-line: no-unnecessary-type-assertion - const res = ENGINE.runKernel( - DepthwiseConv2dNative, inputs as unknown as NamedTensorMap, - attrs as unknown as NamedAttrMap) as T; - - if (reshapedTo4D) { - return reshape(res, [res.shape[1], res.shape[2], res.shape[3]]) as T; - } - return res; -} - -export const depthwiseConv2d = /* @__PURE__ */ op({depthwiseConv2d_}); diff --git a/tfjs-master/tfjs-core/src/ops/depthwise_conv2d_native_backprop_filter.ts b/tfjs-master/tfjs-core/src/ops/depthwise_conv2d_native_backprop_filter.ts deleted file mode 100644 index 235dfbbba..000000000 --- a/tfjs-master/tfjs-core/src/ops/depthwise_conv2d_native_backprop_filter.ts +++ /dev/null @@ -1,54 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {ENGINE} from '../engine'; -import {DepthwiseConv2dNativeBackpropFilter, DepthwiseConv2dNativeBackpropFilterAttrs, DepthwiseConv2dNativeBackpropFilterInputs} from '../kernel_names'; -import {NamedAttrMap} from '../kernel_registry'; -import {Tensor3D, Tensor4D} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; - -import {ExplicitPadding} from './conv_util'; -import {op} from './operation'; -import {reshape} from './reshape'; - -function depthwiseConv2dNativeBackpropFilter_( - x: T, dy: T, filterShape: [number, number, number, number], - strides: [number, number]|number, - pad: 'valid'|'same'|number|ExplicitPadding, - dilations: [number, number]|number = [1, 1], - dimRoundingMode?: 'floor'|'round'|'ceil'): Tensor4D { - let x4D = x as Tensor4D; - if (x.rank === 3) { - x4D = reshape(x, [1, x.shape[0], x.shape[1], x.shape[2]]); - } - let dy4D = dy as Tensor4D; - if (dy4D.rank === 3) { - dy4D = reshape(dy, [1, dy.shape[0], dy.shape[1], dy.shape[2]]); - } - - const inputs: DepthwiseConv2dNativeBackpropFilterInputs = {x: x4D, dy: dy4D}; - const attrs: DepthwiseConv2dNativeBackpropFilterAttrs = - {strides, pad, dimRoundingMode, dilations, filterShape}; - - // tslint:disable-next-line: no-unnecessary-type-assertion - return ENGINE.runKernel( - DepthwiseConv2dNativeBackpropFilter, - inputs as unknown as NamedTensorMap, - attrs as unknown as NamedAttrMap) as Tensor4D; -} - -export const depthwiseConv2dNativeBackpropFilter = - op({depthwiseConv2dNativeBackpropFilter_}); diff --git a/tfjs-master/tfjs-core/src/ops/depthwise_conv2d_native_backprop_input.ts b/tfjs-master/tfjs-core/src/ops/depthwise_conv2d_native_backprop_input.ts deleted file mode 100644 index f90037968..000000000 --- a/tfjs-master/tfjs-core/src/ops/depthwise_conv2d_native_backprop_input.ts +++ /dev/null @@ -1,58 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {ENGINE} from '../engine'; -import {DepthwiseConv2dNativeBackpropInput, DepthwiseConv2dNativeBackpropInputAttrs, DepthwiseConv2dNativeBackpropInputInputs} from '../kernel_names'; -import {NamedAttrMap} from '../kernel_registry'; -import {Tensor3D, Tensor4D} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; - -import {ExplicitPadding} from './conv_util'; -import {op} from './operation'; -import {reshape} from './reshape'; - -function depthwiseConv2dNativeBackpropInput_( - xShape: [number, number, number, number], dy: T, filter: Tensor4D, - strides: [number, number]|number, - pad: 'valid'|'same'|number|ExplicitPadding, - dilations: [number, number]|number = [1, 1], - dimRoundingMode?: 'floor'|'round'|'ceil'): T { - let dy4D = dy as Tensor4D; - let reshapedTo4D = false; - if (dy.rank === 3) { - reshapedTo4D = true; - dy4D = reshape(dy, [1, dy.shape[0], dy.shape[1], dy.shape[2]]); - } - - const inputs: DepthwiseConv2dNativeBackpropInputInputs = {dy: dy4D, filter}; - const attrs: DepthwiseConv2dNativeBackpropInputAttrs = - {strides, pad, dimRoundingMode, dilations, inputShape: xShape}; - - const res = - // tslint:disable-next-line: no-unnecessary-type-assertion - ENGINE.runKernel( - DepthwiseConv2dNativeBackpropInput, - inputs as unknown as NamedTensorMap, - attrs as unknown as NamedAttrMap) as T; - - if (reshapedTo4D) { - return reshape(res, [res.shape[1], res.shape[2], res.shape[3]]) as T; - } - return res; -} - -export const depthwiseConv2dNativeBackpropInput = - op({depthwiseConv2dNativeBackpropInput_}); diff --git a/tfjs-master/tfjs-core/src/ops/depthwise_conv2d_test.ts b/tfjs-master/tfjs-core/src/ops/depthwise_conv2d_test.ts deleted file mode 100644 index e6ccc7b0e..000000000 --- a/tfjs-master/tfjs-core/src/ops/depthwise_conv2d_test.ts +++ /dev/null @@ -1,1368 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; -import {Rank} from '../types'; - -describeWithFlags('depthwiseConv2D', ALL_ENVS, () => { - it('input=1x3x3x1,f=2,s=1,d=1,p=valid,chMul=1', async () => { - const fSize = 2; - const pad = 'valid'; - const stride = 1; - const chMul = 1; - const inDepth = 1; - - const x = tf.tensor4d( - [ - 0.230664, 0.987388, 0.0685208, 0.419224, 0.887861, 0.731641, - 0.0741907, 0.409265, 0.351377 - ], - [1, 3, 3, inDepth]); - const w = tf.tensor4d( - [0.303873, 0.229223, 0.144333, 0.803373], - [fSize, fSize, inDepth, chMul], - ); - - const result = tf.depthwiseConv2d(x, w, stride, pad); - expect(result.shape).toEqual([1, 2, 2, 1]); - const expected = [1.07022, 1.03167, 0.67041, 0.778863]; - expectArraysClose(await result.data(), expected); - }); - - it('input=1x3x3x1,f=2,s=1,d=1,p=explicit,chMul=1', async () => { - const fSize = 2; - const pad = - [[0, 0], [1, 2], [0, 1], [0, 0]] as tf.backend_util.ExplicitPadding; - const stride = 1; - const chMul = 1; - const inDepth = 1; - - const x = tf.tensor4d( - [ - 0.230664, 0.987388, 0.0685208, 0.419224, 0.887861, 0.731641, - 0.0741907, 0.409265, 0.351377 - ], - [1, 3, 3, inDepth]); - const w = tf.tensor4d( - [0.303873, 0.229223, 0.144333, 0.803373], - [fSize, fSize, inDepth, chMul], - ); - - const result = tf.depthwiseConv2d(x, w, stride, pad); - expect(result.shape).toEqual([1, 5, 3, 1]); - const expected = [ - 0.826533, 0.197560, 0.0098898, 1.070216, 1.031675, 0.126422, 0.6704096, - 0.778863, 0.273041, 0.116357, 0.204908, 0.106774, 0, 0, 0 - ]; - expectArraysClose(await result.data(), expected); - }); - - it('input=1x5x5x1,f=3,s=1,d=1,p=valid,chMul=1', async () => { - const fSize = 3; - const pad = 'valid'; - const stride = 1; - const chMul = 1; - const inDepth = 1; - - const x = tf.tensor4d( - [ - 0.149194, 0.089009, 0.654891, 0.083324, 0.537043, 0.644331, 0.563037, - 0.211859, 0.633501, 0.186427, 0.777034, 0.50001, 0.607341, 0.95303, - 0.696479, 0.050387, 0.62045, 0.728049, 0.028043, 0.437009, 0.712881, - 0.741935, 0.974474, 0.621102, 0.171411 - ], - [1, 5, 5, inDepth]); - const w = tf.tensor4d( - [ - 0.125386, 0.975199, 0.640437, 0.281895, 0.990968, 0.347208, 0.889702, - 0.180695, 0.691992 - ], - [fSize, fSize, inDepth, chMul], - ); - - const result = tf.depthwiseConv2d(x, w, stride, pad); - expect(result.shape).toEqual([1, 3, 3, 1]); - const expected = [ - 2.540022, 2.505885, 2.454062, 2.351701, 2.459601, 3.076421, 3.29848, - 3.437421, 2.93419 - ]; - expectArraysClose(await result.data(), expected); - }); - - it('input=1x3x3x1,f=2,s=1,d=2,p=valid,chMul=1', async () => { - const fSize = 2; - const pad = 'valid'; - const stride = 1; - const dilation = 2; - const chMul = 1; - const inDepth = 1; - - const x = tf.tensor4d( - [ - 0.230664, 0.987388, 0.0685208, 0.419224, 0.887861, 0.731641, - 0.0741907, 0.409265, 0.351377 - ], - [1, 3, 3, inDepth]); - const w = tf.tensor4d( - [0.303873, 0.229223, 0.144333, 0.803373], - [fSize, fSize, inDepth, chMul], - ); - // adding a dilation rate is equivalent to using a filter - // with 0s for the dilation rate - const fSizeDilated = fSize + (fSize - 1) * (dilation - 1); - const wDilated = tf.tensor4d( - [0.303873, 0, 0.229223, 0, 0, 0, 0.144333, 0, 0.803373], - [fSizeDilated, fSizeDilated, inDepth, chMul], - ); - - const result = tf.depthwiseConv2d(x, w, stride, pad, 'NHWC', dilation); - - const expectedResult = tf.depthwiseConv2d(x, wDilated, stride, pad); - - expect(result.shape).toEqual(expectedResult.shape); - expectArraysClose(await result.data(), await expectedResult.data()); - }); - - it('input=1x5x5x1,f=3,s=1,d=2,p=valid,chMul=1', async () => { - const fSize = 3; - const pad = 'valid'; - const stride = 1; - const dilation = 2; - const chMul = 1; - const inDepth = 1; - - const x = tf.tensor4d( - [ - 0.149194, 0.089009, 0.654891, 0.083324, 0.537043, 0.644331, 0.563037, - 0.211859, 0.633501, 0.186427, 0.777034, 0.50001, 0.607341, 0.95303, - 0.696479, 0.050387, 0.62045, 0.728049, 0.028043, 0.437009, 0.712881, - 0.741935, 0.974474, 0.621102, 0.171411 - ], - [1, 5, 5, inDepth]); - const w = tf.tensor4d( - [ - 0.125386, 0.975199, 0.640437, 0.281895, 0.990968, 0.347208, 0.889702, - 0.180695, 0.691992 - ], - [fSize, fSize, inDepth, chMul], - ); - // adding a dilation rate is equivalent to using a filter - // with 0s for the dilation rate - const fSizeDilated = fSize + (fSize - 1) * (dilation - 1); - const wDilated = tf.tensor4d( - [ - 0.125386, 0, 0.975199, 0, 0.640437, 0, 0, 0, 0, 0, - 0.281895, 0, 0.990968, 0, 0.347208, 0, 0, 0, 0, 0, - 0.889702, 0, 0.180695, 0, 0.691992 - ], - [fSizeDilated, fSizeDilated, inDepth, chMul], - ); - - const result = tf.depthwiseConv2d(x, w, stride, pad, 'NHWC', dilation); - - const expectedResult = tf.depthwiseConv2d(x, wDilated, stride, pad); - - expect(result.shape).toEqual(expectedResult.shape); - expectArraysClose(await result.data(), await expectedResult.data()); - }); - - it('input=1x5x5x1,f=2,s=1,d=4,p=valid,chMul=1', async () => { - const fSize = 2; - const pad = 'valid'; - const stride = 1; - const dilation = 4; - const chMul = 1; - const inDepth = 1; - - const x = tf.tensor4d( - [ - 0.149194, 0.089009, 0.654891, 0.083324, 0.537043, 0.644331, 0.563037, - 0.211859, 0.633501, 0.186427, 0.777034, 0.50001, 0.607341, 0.95303, - 0.696479, 0.050387, 0.62045, 0.728049, 0.028043, 0.437009, 0.712881, - 0.741935, 0.974474, 0.621102, 0.171411 - ], - [1, 5, 5, inDepth]); - const w = tf.tensor4d( - [0.125386, 0.975199, 0.640437, 0.281895], - [fSize, fSize, inDepth, chMul], - ); - // adding a dilation rate is equivalent to using a filter - // with 0s for the dilation rate - const fSizeDilated = fSize + (fSize - 1) * (dilation - 1); - const wDilated = tf.tensor4d( - [ - 0.125386, 0, 0, 0, 0.975199, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0.640437, 0, 0, 0, 0.281895 - ], - [fSizeDilated, fSizeDilated, inDepth, chMul], - ); - - const result = tf.depthwiseConv2d(x, w, stride, pad, 'NHWC', dilation); - - const expectedResult = tf.depthwiseConv2d(x, wDilated, stride, pad); - - expect(result.shape).toEqual(expectedResult.shape); - expectArraysClose(await result.data(), await expectedResult.data()); - }); - - it('input=1x3x3x2,f=2,s=1,d=1,p=same,chMul=1', async () => { - const fSize = 2; - const pad = 'same'; - const stride = 1; - const chMul = 1; - const inDepth = 2; - - const x = tf.tensor4d( - [ - 0.111057, 0.661818, 0.701979, 0.424362, 0.992854, 0.417599, 0.423036, - 0.500499, 0.368484, 0.714135, 0.456693, 0.531058, 0.636636, 0.345024, - 0.0506303, 0.789682, 0.177473, 0.793569 - ], - [1, 3, 3, inDepth]); - const w = tf.tensor4d( - [ - 0.614293, 0.0648011, 0.101113, 0.452887, 0.0582746, 0.426481, - 0.872743, 0.765767 - ], - [fSize, fSize, inDepth, chMul]); - const result = tf.depthwiseConv2d(x, w, stride, pad); - expect(result.shape).toEqual([1, 3, 3, 2]); - - const expected = [ - 0.485445, 0.995389, 0.95166, 0.927856, 0.636516, 0.253547, 0.378414, - 1.10771, 0.430373, 1.23126, 0.290885, 0.372855, 0.3962, 0.379995, - 0.0490466, 0.410569, 0.10902, 0.0514242 - ]; - expectArraysClose(await result.data(), expected); - }); - - it('input=1x5x5x1,f=3,s=1,d=1,p=same,chMul=1', async () => { - const fSize = 3; - const pad = 'same'; - const stride = 1; - const chMul = 1; - const inDepth = 1; - - const x = tf.tensor4d( - [ - 0.149194, 0.089009, 0.654891, 0.083324, 0.537043, 0.644331, 0.563037, - 0.211859, 0.633501, 0.186427, 0.777034, 0.50001, 0.607341, 0.95303, - 0.696479, 0.050387, 0.62045, 0.728049, 0.028043, 0.437009, 0.712881, - 0.741935, 0.974474, 0.621102, 0.171411 - ], - [1, 5, 5, inDepth]); - const w = tf.tensor4d( - [ - 0.125386, 0.975199, 0.640437, 0.281895, 0.990968, 0.347208, 0.889702, - 0.180695, 0.691992 - ], - [fSize, fSize, inDepth, chMul], - ); - - const result = tf.depthwiseConv2d(x, w, stride, pad); - expect(result.shape).toEqual([1, 5, 5, 1]); - const expected = [ - 0.684796, 1.179251, 1.680593, 0.885615, 1.152995, 1.52291, 2.540022, - 2.505885, 2.454062, 1.871258, 2.371015, 2.351701, 2.459601, 3.076421, - 1.323994, 1.985572, 3.29848, 3.437421, 2.93419, 1.823238, 1.410545, - 2.352186, 2.19622, 1.348218, 0.774635 - ]; - expectArraysClose(await result.data(), expected); - }); - - it('input=1x3x3x2,f=2,s=1,d=2,p=same,chMul=1', async () => { - const fSize = 2; - const pad = 'same'; - const stride = 1; - const dilation = 2; - const inDepth = 2; - - const x = tf.tensor4d( - [ - 0.111057, 0.661818, 0.701979, 0.424362, 0.992854, 0.417599, 0.423036, - 0.500499, 0.368484, 0.714135, 0.456693, 0.531058, 0.636636, 0.345024, - 0.0506303, 0.789682, 0.177473, 0.793569 - ], - [1, 3, 3, inDepth]); - - const w: tf.Tensor4D = - tf.stack( - [ - tf.tensor2d( - [0.614293, 0.0648011, 0.101113, 0.452887], [fSize, fSize]), - tf.tensor2d( - [0.0582746, 0.426481, 0.872743, 0.765767], [fSize, fSize]) - ], - 2) - .expandDims(3); - - // adding a dilation rate is equivalent to using a filter - // with 0s for the dilation rate - const fSizeDilated = fSize + (fSize - 1) * (dilation - 1); - const wDilated: tf.Tensor4D = - tf.stack( - [ - tf.tensor2d( - [0.614293, 0, 0.0648011, 0, 0, 0, 0.101113, 0, 0.452887], - [fSizeDilated, fSizeDilated]), - tf.tensor2d( - [0.0582746, 0, 0.426481, 0, 0, 0, 0.872743, 0, 0.765767], - [fSizeDilated, fSizeDilated]) - ], - 2) - .expandDims(3); - - expect(wDilated.shape).toEqual([fSizeDilated, fSizeDilated, inDepth, 1]); - - const result = tf.depthwiseConv2d(x, w, stride, pad, 'NHWC', dilation); - - const expectedResult = tf.depthwiseConv2d(x, wDilated, stride, pad); - - expect(result.shape).toEqual(expectedResult.shape); - expectArraysClose(await result.data(), await expectedResult.data()); - }); - - it('input=1x5x5x1,f=3,s=1,d=2,p=valid,chMul=1', async () => { - const fSize = 3; - const pad = 'valid'; - const stride = 1; - const chMul = 1; - const inDepth = 1; - - const x = tf.tensor4d( - [ - 0.149194, 0.089009, 0.654891, 0.083324, 0.537043, 0.644331, 0.563037, - 0.211859, 0.633501, 0.186427, 0.777034, 0.50001, 0.607341, 0.95303, - 0.696479, 0.050387, 0.62045, 0.728049, 0.028043, 0.437009, 0.712881, - 0.741935, 0.974474, 0.621102, 0.171411 - ], - [1, 5, 5, inDepth]); - const w = tf.tensor4d( - [ - 0.125386, 0.975199, 0.640437, 0.281895, 0.990968, 0.347208, 0.889702, - 0.180695, 0.691992 - ], - [fSize, fSize, inDepth, chMul], - ); - - const result = tf.depthwiseConv2d(x, w, stride, pad); - expect(result.shape).toEqual([1, 3, 3, 1]); - const expected = [ - 2.540022, 2.505885, 2.454062, 2.351701, 2.459601, 3.076421, 3.29848, - 3.437421, 2.93419 - ]; - expectArraysClose(await result.data(), expected); - }); - - it('input=1x5x5x4,f=3,s=1,d=1,p=same,chMul=1', async () => { - const fSize = 3; - const pad = 'same'; - const stride = 1; - const chMul = 1; - const inDepth = 4; - - const x = tf.tensor4d( - [ - 0.149194, 0.089009, 0.654891, 0.083324, 0.537043, 0.644331, - 0.563037, 0.211859, 0.633501, 0.186427, 0.777034, 0.50001, - 0.607341, 0.95303, 0.696479, 0.050387, 0.62045, 0.728049, - 0.028043, 0.437009, 0.712881, 0.741935, 0.974474, 0.621102, - 0.171411, 0.675707, 0.758567, 0.413529, 0.963967, 0.217291, - 0.101335, 0.804231, 0.329673, 0.924503, 0.728742, 0.180217, - 0.210459, 0.133869, 0.650827, 0.047613, 0.554795, 0.653365, - 0.442196, 0.261945, 0.0528113, 0.656698, 0.127345, 0.610039, - 0.169131, 0.458647, 0.0988288, 0.966109, 0.0421747, 0.82035, - 0.274711, 0.359377, 0.512113, 0.689682, 0.941571, 0.31961, - 0.743826, 0.858147, 0.984766, 0.926973, 0.579597, 0.444104, - 0.505969, 0.241437, 0.937999, 0.0957074, 0.773611, 0.46023, - 0.469379, 0.363789, 0.269745, 0.486136, 0.894215, 0.794299, - 0.724615, 0.261945, 0.0528113, 0.656698, 0.127345, 0.610039, - 0.169131, 0.458647, 0.0988288, 0.966109, 0.0421747, 0.82035, - 0.274711, 0.359377, 0.512113, 0.689682, 0.941571, 0.31961, - 0.743826, 0.858147, 0.984766, 0.926973 - ], - [1, 5, 5, inDepth]); - const w = tf.tensor4d( - [ - 0.6511372, 0.8699447, 0.6511372, 0.8699447, 0.267792, 0.9981787, - 0.267792, 0.9981787, 0.4913572, 0.3321196, 0.4913572, 0.3321196, - 0.5286497, 0.4241803, 0.5286497, 0.4241803, 0.0175446, 0.8365464, - 0.0175446, 0.8365464, 0.1768399, 0.2874831, 0.1768399, 0.2874831, - 0.0933998, 0.5764548, 0.0933998, 0.5764548, 0.0661623, 0.8850273, - 0.0661623, 0.8850273, 0.8700929, 0.205422, 0.8700929, 0.205422 - ], - [fSize, fSize, inDepth, chMul], - ); - - const result = tf.depthwiseConv2d(x, w, stride, pad); - expect(result.shape).toEqual([1, 5, 5, 4]); - const expected = [ - 0.29389750957489014, 1.055132269859314, 0.8355544209480286, - 0.7652503848075867, 1.116986632347107, 1.7007107734680176, - 0.7228718996047974, 1.2455471754074097, 0.7690584063529968, - 1.4749835729599, 1.1460752487182617, 1.5098011493682861, - 0.7502411007881165, 2.056602716445923, 1.0519171953201294, - 1.012758731842041, 0.37667199969291687, 1.6647151708602905, - 0.4798099994659424, 0.532977283000946, 0.4293096363544464, - 1.8309053182601929, 0.7433272004127502, 1.1491419076919556, - 1.3050479888916016, 2.7769954204559326, 1.6411027908325195, - 2.1799824237823486, 1.0364032983779907, 2.7503039836883545, - 1.7060394287109375, 2.880652904510498, 1.8967751264572144, - 3.3914175033569336, 1.734355092048645, 2.076633930206299, - 0.7774094939231873, 3.1432321071624756, 0.9456352591514587, - 1.0863502025604248, 0.8477171659469604, 2.5510711669921875, - 1.169355869293213, 2.0218098163604736, 2.23183274269104, - 3.257829189300537, 1.939490556716919, 2.96195650100708, - 1.0946838855743408, 2.4252827167510986, 1.329919695854187, - 3.0390005111694336, 1.8967963457107544, 2.775693416595459, - 1.5250799655914307, 2.4470155239105225, 0.40530526638031006, - 2.775503158569336, 0.8836789727210999, 1.1361782550811768, - 0.4407186806201935, 2.3912413120269775, 0.38215696811676025, - 2.047299861907959, 1.080580234527588, 3.09224534034729, - 1.2943278551101685, 3.1656715869903564, 0.9704407453536987, - 2.8066811561584473, 1.419780969619751, 3.1822099685668945, - 1.720312237739563, 3.279745578765869, 2.0871992111206055, - 2.6629819869995117, 0.5254714488983154, 3.3779194355010986, - 0.73943030834198, 2.0616414546966553, 0.5148154497146606, - 1.6852912902832031, 0.5320349931716919, 1.7935365438461304, - 1.1387810707092285, 2.119696617126465, 1.2744661569595337, - 2.3705403804779053, 1.0399315357208252, 1.6817822456359863, - 0.8927359580993652, 1.6332063674926758, 1.3386595249176025, - 1.8818190097808838, 1.267898440361023, 1.6589205265045166, - 0.8288722038269043, 2.119757890701294, 0.8847255706787109, - 1.5954076051712036 - ]; - expectArraysClose(await result.data(), expected); - }); - - it('input=1x5x5x4,f=5,s=2,d=1,p=same,chMul=1', async () => { - const fSize = 5; - const pad = 'same'; - const stride = 2; - const chMul = 1; - const inDepth = 4; - - const x = tf.tensor4d( - [ - 0.149194, 0.089009, 0.654891, 0.083324, 0.537043, 0.644331, - 0.563037, 0.211859, 0.633501, 0.186427, 0.777034, 0.50001, - 0.607341, 0.95303, 0.696479, 0.050387, 0.62045, 0.728049, - 0.028043, 0.437009, 0.712881, 0.741935, 0.974474, 0.621102, - 0.171411, 0.675707, 0.758567, 0.413529, 0.963967, 0.217291, - 0.101335, 0.804231, 0.329673, 0.924503, 0.728742, 0.180217, - 0.210459, 0.133869, 0.650827, 0.047613, 0.554795, 0.653365, - 0.442196, 0.261945, 0.0528113, 0.656698, 0.127345, 0.610039, - 0.169131, 0.458647, 0.0988288, 0.966109, 0.0421747, 0.82035, - 0.274711, 0.359377, 0.512113, 0.689682, 0.941571, 0.31961, - 0.743826, 0.858147, 0.984766, 0.926973, 0.579597, 0.444104, - 0.505969, 0.241437, 0.937999, 0.0957074, 0.773611, 0.46023, - 0.469379, 0.363789, 0.269745, 0.486136, 0.894215, 0.794299, - 0.724615, 0.261945, 0.0528113, 0.656698, 0.127345, 0.610039, - 0.169131, 0.458647, 0.0988288, 0.966109, 0.0421747, 0.82035, - 0.274711, 0.359377, 0.512113, 0.689682, 0.941571, 0.31961, - 0.743826, 0.858147, 0.984766, 0.926973 - ], - [1, 5, 5, inDepth]); - const w = tf.tensor4d( - [ - 0.6511372, 0.8699447, 0.6511372, 0.8699447, 0.267792, 0.9981787, - 0.267792, 0.9981787, 0.4913572, 0.3321196, 0.4913572, 0.3321196, - 0.5286497, 0.4241803, 0.5286497, 0.4241803, 0.0175446, 0.8365464, - 0.0175446, 0.8365464, 0.1768399, 0.2874831, 0.1768399, 0.2874831, - 0.0933998, 0.5764548, 0.0933998, 0.5764548, 0.0661623, 0.8850273, - 0.0661623, 0.8850273, 0.8700929, 0.205422, 0.8700929, 0.205422, - 0.149194, 0.089009, 0.654891, 0.083324, 0.537043, 0.644331, - 0.563037, 0.211859, 0.633501, 0.186427, 0.777034, 0.50001, - 0.607341, 0.95303, 0.696479, 0.050387, 0.62045, 0.728049, - 0.028043, 0.437009, 0.712881, 0.741935, 0.974474, 0.621102, - 0.171411, 0.125386, 0.975199, 0.640437, 0.281895, 0.990968, - 0.347208, 0.889702, 0.180695, 0.691992, 0.347154, 0.386692, - 0.327191, 0.483784, 0.591807, 0.24263, 0.95182, 0.174353, - 0.592136, 0.623469, 0.988244, 0.660731, 0.946534, 0.0801365, - 0.864889, 0.874602, 0.240347, 0.906352, 0.478657, 0.825918, - 0.380769, 0.184705, 0.238241, 0.201907, 0.294087, 0.181165, - 0.191303, 0.7225, 0.430064, 0.900622 - ], - [fSize, fSize, inDepth, chMul], - ); - - const result = tf.depthwiseConv2d(x, w, stride, pad); - expect(result.shape).toEqual([1, 3, 3, 4]); - const expected = [ - 2.2883458137512207, 2.5740344524383545, 2.3246560096740723, - 2.27826189994812, 3.0600292682647705, 5.021538734436035, - 4.432307720184326, 2.6976213455200195, 1.8467353582382202, - 3.617821216583252, 2.0940940380096436, 1.3091316223144531, - 2.4892354011535645, 4.767732620239258, 3.126866579055786, - 3.4326541423797607, 4.181705474853516, 8.082467079162598, - 6.922453880310059, 5.922790050506592, 2.819075345993042, - 5.9510369300842285, 3.7211103439331055, 2.7263708114624023, - 1.164026141166687, 3.3068809509277344, 1.6575196981430054, - 2.738445997238159, 2.288442850112915, 5.463253021240234, - 2.840029239654541, 3.8579823970794678, 1.440760612487793, - 3.862100839614868, 2.3826799392700195, 2.2323575019836426 - ]; - expectArraysClose(await result.data(), expected); - }); - - it('input=1x5x5x1,f=3,s=1,d=2,p=explicit,chMul=1', async () => { - const fSize = 3; - const pad = - [[0, 0], [0, 0], [0, 1], [0, 1]] as tf.backend_util.ExplicitPadding; - const stride = 1; - const chMul = 1; - const inDepth = 1; - - const x = tf.tensor4d( - [ - 0.149194, 0.089009, 0.654891, 0.083324, 0.537043, 0.644331, 0.563037, - 0.211859, 0.633501, 0.186427, 0.777034, 0.50001, 0.607341, 0.95303, - 0.696479, 0.050387, 0.62045, 0.728049, 0.028043, 0.437009, 0.712881, - 0.741935, 0.974474, 0.621102, 0.171411 - ], - [1, 5, 5, inDepth]); - const w = tf.tensor4d( - [ - 0.125386, 0.975199, 0.640437, 0.281895, 0.990968, 0.347208, 0.889702, - 0.180695, 0.691992 - ], - [fSize, fSize, inDepth, chMul], - ); - - const result = tf.depthwiseConv2d(x, w, stride, pad); - expect(result.shape).toEqual([1, 3, 4, 1]); - const expected = [ - 2.540022, 2.505885, 2.454062, 1.871258, 2.35170, 2.459601, 3.076421, - 1.32399, 3.298480, 3.437421, 2.93419, 1.823238 - ]; - expectArraysClose(await result.data(), expected); - }); - - it('input=1x3x3x4,f=3,s=1,d=2,p=same,chMul=1', async () => { - const fSize = 3; - const pad = 'same'; - const stride = 1; - const chMul = 1; - const inDepth = 4; - const dilation = 2; - - const x = tf.tensor4d( - [ - 0.5227615, 0.3477598, 0.5227615, 0.3477598, 0.4690094, 0.408161, - 0.4690094, 0.408161, 0.3239015, 0.2372907, 0.3239015, 0.2372907, - 0.6136674, 0.7918105, 0.6136674, 0.7918105, 0.9145211, 0.218611, - 0.9145211, 0.218611, 0.3778793, 0.2392365, 0.3778793, 0.2392365, - 0.2340134, 0.1251984, 0.2340134, 0.1251984, 0.6222534, 0.1327361, - 0.6222534, 0.1327361, 0.7697753, 0.1216059, 0.7697753, 0.1216059 - ], - [1, 3, 3, inDepth]); - const w = tf.tensor4d( - [ - 0.6511372, 0.8699447, 0.6511372, 0.8699447, 0.267792, 0.9981787, - 0.267792, 0.9981787, 0.4913572, 0.3321196, 0.4913572, 0.3321196, - 0.5286497, 0.4241803, 0.5286497, 0.4241803, 0.0175446, 0.8365464, - 0.0175446, 0.8365464, 0.1768399, 0.2874831, 0.1768399, 0.2874831, - 0.0933998, 0.5764548, 0.0933998, 0.5764548, 0.0661623, 0.8850273, - 0.0661623, 0.8850273, 0.8700929, 0.205422, 0.8700929, 0.205422 - ], - [fSize, fSize, inDepth, chMul], - ); - - const result = tf.depthwiseConv2d(x, w, stride, pad, 'NHWC', dilation); - expect(result.shape).toEqual([1, 3, 3, 4]); - const expected = [ - 0.7517092227935791, 0.4949187934398651, 0.7517092227935791, - 0.4949187934398651, 0.04939830303192139, 0.4589206874370575, - 0.04939830303192139, 0.4589206874370575, 0.3548273742198944, - 0.5258132815361023, 0.3548273742198944, 0.5258132815361023, - 0.0775906890630722, 0.7311626672744751, 0.0775906890630722, - 0.7311626672744751, 0.01604490540921688, 0.1828782558441162, - 0.01604490540921688, 0.1828782558441162, 0.3310448229312897, - 0.5360028743743896, 0.3310448229312897, 0.5360028743743896, - 0.4393753409385681, 0.565629243850708, 0.4393753409385681, - 0.565629243850708, 0.13651414215564728, 0.5184575319290161, - 0.13651414215564728, 0.5184575319290161, 0.5643441677093506, - 0.6942259669303894, 0.5643441677093506, 0.6942259669303894 - ]; - expectArraysClose(await result.data(), expected); - }); - - it('input=1x3x3x2,f=2,s=1,p=same,chMul=2', async () => { - const fSize = 2; - const pad = 'same'; - const stride = 1; - const chMul = 2; - const inDepth = 2; - - const x = tf.tensor4d( - [ - 0.675707, 0.758567, 0.413529, 0.963967, 0.217291, 0.101335, 0.804231, - 0.329673, 0.924503, 0.728742, 0.180217, 0.210459, 0.133869, 0.650827, - 0.047613, 0.554795, 0.653365, 0.442196 - ], - [1, 3, 3, inDepth]); - const w = tf.tensor4d( - [ - 0.347154, 0.386692, 0.327191, 0.483784, 0.591807, 0.24263, 0.95182, - 0.174353, 0.592136, 0.623469, 0.988244, 0.660731, 0.946534, 0.0801365, - 0.864889, 0.874602 - ], - [fSize, fSize, inDepth, chMul]); - const result = tf.depthwiseConv2d(x, w, stride, pad); - expect(result.shape).toEqual([1, 3, 3, 4]); - - const expected = [ - 1.83059, 0.937125, 2.1218, 1.39024, 0.990167, 0.803472, - 1.31405, 1.14959, 0.182147, 0.196385, 0.241141, 0.188081, - 0.950656, 0.622581, 1.92451, 1.20179, 1.07422, 0.483268, - 1.36948, 1.14256, 0.449444, 0.477042, 0.505857, 0.393989, - 0.0746509, 0.0633184, 0.74101, 0.41159, 0.403195, 0.176938, - 0.602415, 0.345499, 0.226819, 0.252651, 0.144682, 0.213927 - ]; - expectArraysClose(await result.data(), expected); - }); - - it('input=2x3x3x2,f=2,s=1,p=same,chMul=2', async () => { - const fSize = 2; - const pad = 'same'; - const stride = 1; - const chMul = 2; - const inDepth = 2; - - const x = tf.tensor4d( - [ - 0.261945, 0.0528113, 0.656698, 0.127345, 0.610039, 0.169131, - 0.458647, 0.0988288, 0.966109, 0.0421747, 0.82035, 0.274711, - 0.359377, 0.512113, 0.689682, 0.941571, 0.31961, 0.743826, - 0.858147, 0.984766, 0.926973, 0.579597, 0.444104, 0.505969, - 0.241437, 0.937999, 0.0957074, 0.773611, 0.46023, 0.469379, - 0.363789, 0.269745, 0.486136, 0.894215, 0.794299, 0.724615 - ], - [2, 3, 3, inDepth]); - const w = tf.tensor4d( - [ - 0.240347, 0.906352, 0.478657, 0.825918, 0.380769, 0.184705, 0.238241, - 0.201907, 0.294087, 0.181165, 0.191303, 0.7225, 0.430064, 0.900622, - 0.670338, 0.33478 - ], - [fSize, fSize, inDepth, chMul]); - const result = tf.depthwiseConv2d(x, w, stride, pad); - expect(result.shape).toEqual([2, 3, 3, 4]); - - const expected = [ - 0.863379, 1.3119, 0.102795, 0.154853, 1.02704, 1.62173, 0.293466, - 0.261764, 0.387876, 0.701529, 0.133508, 0.338167, 0.880395, 1.28039, - 0.786492, 0.775361, 0.884845, 1.43995, 0.764374, 1.0196, 0.291162, - 0.801428, 0.273788, 0.764303, 0.348985, 0.45311, 0.469447, 0.613073, - 0.287461, 0.684128, 0.627899, 0.927844, 0.0768174, 0.28968, 0.356037, - 0.614339, 0.67138, 1.07894, 1.30747, 1.86705, 0.617971, 1.35402, - 0.860607, 1.29693, 0.242087, 0.485892, 0.331979, 0.757015, 0.410527, - 0.740235, 1.28431, 1.42516, 0.68281, 0.975185, 1.13892, 1.62237, - 0.344208, 0.561029, 0.363292, 0.911203, 0.272541, 0.419513, 0.342154, - 0.403335, 0.419286, 0.587321, 0.600655, 0.884853, 0.190907, 0.719914, - 0.346842, 0.598472 - ]; - expectArraysClose(await result.data(), expected); - }); - - it('input=2x3x3x2,f=2,s=1,d=2,p=same,chMul=2', - async () => { - const fSize = 2; - const pad = 'same'; - const stride = 1; - const inDepth = 2; - const dilation = 2; - const noDilation = 1; - - const x = tf.tensor4d( - [ - 0.261945, 0.0528113, 0.656698, 0.127345, 0.610039, 0.169131, - 0.458647, 0.0988288, 0.966109, 0.0421747, 0.82035, 0.274711, - 0.359377, 0.512113, 0.689682, 0.941571, 0.31961, 0.743826, - 0.858147, 0.984766, 0.926973, 0.579597, 0.444104, 0.505969, - 0.241437, 0.937999, 0.0957074, 0.773611, 0.46023, 0.469379, - 0.363789, 0.269745, 0.486136, 0.894215, 0.794299, 0.724615 - ], - [2, 3, 3, inDepth]); - - const w = tf.stack( - [ - tf.stack( - [ - tf.tensor2d( - [0.240347, 0.906352, 0.478657, 0.825918], - [fSize, fSize]), - tf.tensor2d( - [0.380769, 0.184705, 0.238241, 0.201907], - [fSize, fSize]) - ], - 2), - tf.stack( - [ - tf.tensor2d( - [0.294087, 0.181165, 0.191303, 0.7225], - [fSize, fSize]), - tf.tensor2d( - [0.430064, 0.900622, 0.670338, 0.33478], - [fSize, fSize]) - ], - 2) - ], - 3) as tf.Tensor4D; - - const fSizeDilated = fSize + (fSize - 1) * (dilation - 1); - const wDilated = tf.stack([ - tf.stack( - [ - tf.tensor2d( - [0.240347, 0, 0.906352, 0, 0, 0, 0.478657, 0, 0.825918], - [fSizeDilated, fSizeDilated]), - tf.tensor2d( - [0.380769, 0, 0.184705, 0, 0, 0, 0.238241, 0, 0.201907], - [fSizeDilated, fSizeDilated]) - ], - 2), - tf.stack( - [ - tf.tensor2d([0.294087, 0, 0.181165, 0, 0, 0, 0.191303, 0, 0.7225], - [fSizeDilated, fSizeDilated]), - tf.tensor2d( - [0.430064, 0, 0.900622, 0, 0, 0, 0.670338, 0, 0.33478], - [fSizeDilated, fSizeDilated]) - ], - 2) - ], 3) as tf.Tensor4D; - - const result = tf.depthwiseConv2d(x, w, stride, pad, 'NHWC', dilation); - - const expectedResult = - tf.depthwiseConv2d(x, wDilated, stride, pad, 'NHWC', noDilation); - - expect(result.shape).toEqual(expectedResult.shape); - expectArraysClose(await result.data(), await expectedResult.data()); - }); - - it('input=2x3x3x2,f=3,s=1,d=2,p=same,chMul=2', async () => { - const fSize = 3; - const pad = 'same'; - const stride = 1; - const inDepth = 2; - const dilation = 2; - - const x = tf.tensor4d( - [[ - [ - [0.52276146, 0.34775984], [0.4690094, 0.40816104], - [0.32390153, 0.23729074], [0.61366737, 0.7918105], - [0.9145211, 0.218611], [0.37787926, 0.23923647], - [0.23401344, 0.12519836] - ], - - [ - [0.6222534, 0.13273609], [0.7697753, 0.12160587], - [0.0448128, 0.94806635], [0.4199953, 0.7140714], - [0.01420832, 0.47453713], [0.02061439, 0.37226152], - [0.62741446, 0.23167181] - ], - - [ - [0.7257557, 0.14352751], [0.3011638, 0.3869065], - [0.09286129, 0.25151742], [0.7566397, 0.13099921], - [0.65324724, 0.38959372], [0.65826, 0.7505318], - [0.35919082, 0.85470796] - ], - - [ - [0.24827361, 0.2826661], [0.24717247, 0.27446854], - [0.27112448, 0.68068564], [0.11082292, 0.7948675], - [0.41535318, 0.659986], [0.22165525, 0.18149579], - [0.42273378, 0.9558281] - ], - - [ - [0.943074, 0.6799041], [0.78851473, 0.07249606], - [0.771909, 0.7925967], [0.9551083, 0.03087568], - [0.82589805, 0.94797385], [0.5895462, 0.5045923], - [0.9667754, 0.24292922] - ], - - [ - [0.67123663, 0.109761], [0.04002762, 0.51942277], - [0.37868536, 0.8467603], [0.77171385, 0.51604605], - [0.8192849, 0.38843668], [0.19607484, 0.5591624], - [0.45990825, 0.35768318] - ], - - [ - [0.67443585, 0.6256168], [0.9373623, 0.6498393], - [0.7623085, 0.13218105], [0.9349631, 0.7660191], - [0.50054944, 0.7738123], [0.30201948, 0.525643], - [0.30896342, 0.21111596] - ] - ]], - [1, 7, 7, inDepth]); - - const w = tf.tensor4d( - [ - [ - [[0.65113723], [0.8699447]], - - [[0.267792], [0.9981787]], - - [[0.4913572], [0.33211958]] - ], - [ - [[0.5286497], [0.42418027]], - - [[0.01754463], [0.8365464]], - - [[0.17683995], [0.2874831]] - ], - [ - [[0.09339976], [0.57645476]], - - [[0.06616235], [0.8850273]], - - [[0.87009287], [0.20542204]] - ] - ], - [fSize, fSize, inDepth, 1], - ); - const result = tf.depthwiseConv2d(x, w, stride, pad, 'NHWC', dilation); - - expect(result.shape).toEqual([1, 7, 7, 2]); - expectArraysClose(await result.data(), [ - 0.19526604, 0.5378273, 0.795022, 0.9384107, 1.0860794, 0.7942326, - 0.9764694, 1.3974442, 0.5930813, 0.9848901, 0.44526684, 1.275759, - 0.572345, 1.1784878, 0.27117175, 0.773588, 0.20055711, 0.71320784, - 0.73477566, 1.8867722, 0.64123434, 1.6549369, 0.55551285, 2.0385633, - 0.24740812, 1.233143, 0.08528192, 1.6214795, 1.062326, 1.3828603, - 1.4494176, 1.1022222, 2.2350664, 2.283423, 1.5940895, 1.8871424, - 1.6627852, 2.4903212, 1.0405337, 2.0754304, 1.1508893, 1.9568737, - 0.6148571, 1.1505995, 1.1105528, 1.3823687, 1.4342139, 2.9909487, - 1.0210396, 2.6467443, 1.0563798, 3.3963797, 0.42652097, 2.274134, - 0.51121074, 2.264094, 1.1009313, 1.6042703, 1.510688, 1.2317145, - 2.025515, 2.3658662, 1.6722159, 2.0787857, 1.3785586, 2.895031, - 1.2915218, 2.2051222, 1.0423074, 2.4303207, 0.27844793, 0.84346974, - 0.25781655, 1.1208354, 0.9447272, 2.0111258, 0.3689065, 1.9052455, - 0.79137695, 2.355344, 0.5429248, 1.5593178, 0.8248403, 1.9922242, - 0.77847, 1.5032601, 0.8622418, 0.84645665, 1.6850245, 2.2958806, - 1.6242284, 1.329045, 1.6652328, 2.480535, 1.2793491, 1.2951884, - 1.0667037, 1.5720158 - ]); - }); - - it('input=1x8x8x2,f=3,s=1,d=3,p=valid,chMul=1', async () => { - const fSize = 3; - const pad = 'valid'; - const stride = 1; - const inDepth = 2; - const dilation = 3; - - const x = tf.tensor4d( - [ - 0.09941668063402176, 0.05248984694480896, 0.4567521810531616, - 0.8002573847770691, 0.810535192489624, 0.7010623216629028, - 0.5898630023002625, 0.05883334204554558, 0.2314797043800354, - 0.45427876710891724, 0.10960108041763306, 0.9710874557495117, - 0.18139968812465668, 0.8959258794784546, 0.35156702995300293, - 0.6495933532714844, 0.5185067653656006, 0.3260101079940796, - 0.7837356925010681, 0.9170011281967163, 0.465780109167099, - 0.0857422724366188, 0.38354963064193726, 0.8134718537330627, - 0.8768209218978882, 0.38151195645332336, 0.5045309066772461, - 0.8152258396148682, 0.2782581150531769, 0.545160174369812, - 0.1587309092283249, 0.5507456064224243, 0.2704062759876251, - 0.7736618518829346, 0.9871141314506531, 0.29300180077552795, - 0.3038032352924347, 0.36257433891296387, 0.967268168926239, - 0.7251133918762207, 0.6244085431098938, 0.8398842215538025, - 0.42696574330329895, 0.25569799542427063, 0.5784937143325806, - 0.22755105793476105, 0.8869972229003906, 0.05128923058509827, - 0.6748542785644531, 0.97468101978302, 0.5549167394638062, - 0.5639380812644958, 0.821204662322998, 0.5207878947257996, - 0.8831672668457031, 0.6721863746643066, 0.23375047743320465, - 0.040671784430742264, 0.24522553384304047, 0.6293181777000427, - 0.6886807680130005, 0.29527169466018677, 0.48199158906936646, - 0.5751473307609558, 0.817806601524353, 0.38846832513809204, - 0.5553714036941528, 0.1839468777179718, 0.5287416577339172, - 0.4813096523284912, 0.477756530046463, 0.641162633895874, - 0.03040425479412079, 0.20608118176460266, 0.7930338978767395, - 0.727353572845459, 0.42868077754974365, 0.6136374473571777, - 0.06312728673219681, 0.4346885681152344, 0.004786544945091009, - 0.4951920807361603, 0.588252604007721, 0.724294126033783, - 0.07830118387937546, 0.07353833317756653, 0.7818689346313477, - 0.8137099742889404, 0.6505773067474365, 0.5716961026191711, - 0.5416423678398132, 0.855529248714447, 0.8958709239959717, - 0.3598312437534332, 0.31329575181007385, 0.5971285104751587, - 0.034069616347551346, 0.6229354739189148, 0.24074052274227142, - 0.3356363773345947, 0.1049640029668808, 0.2543765604496002, - 0.1635538637638092, 0.8082090616226196, 0.9097364544868469, - 0.6435819268226624, 0.6100808382034302, 0.29750677943229675, - 0.0738643929362297, 0.8887753486633301, 0.7692861557006836, - 0.6412256360054016, 0.16205888986587524, 0.9414404034614563, - 0.5698712468147278, 0.6834514737129211, 0.41202589869499207, - 0.9096908569335938, 0.8094117045402527, 0.42103442549705505, - 0.8905773162841797, 0.069722980260849, 0.014392468146979809, - 0.22018849849700928, 0.30076053738594055, 0.8472294211387634, - 0.852762758731842, 0.5004454851150513 - ], - [1, 8, 8, inDepth]); - - const w = tf.tensor4d( - [ - 0.5785998106002808, 0.7439202666282654, 0.2178175300359726, - 0.8782838582992554, 0.6579487919807434, 0.6556791067123413, - 0.7341834306716919, 0.3332836329936981, 0.037182893604040146, - 0.7394348382949829, 0.04031887650489807, 0.19104436039924622, - 0.7014378309249878, 0.5309979319572449, 0.8485966920852661, - 0.6609954237937927, 0.021728534251451492, 0.9289031624794006 - ], - [fSize, fSize, inDepth, 1], - ); - const result = tf.depthwiseConv2d(x, w, stride, pad, 'NHWC', dilation); - - expect(result.shape).toEqual([1, 2, 2, 2]); - expectArraysClose(await result.data(), [ - 1.0257229804992676, 3.247040033340454, 1.9391249418258667, - 2.9474055767059326, 2.0091731548309326, 3.600433826446533, - 2.334312677383423, 2.548961877822876 - ]); - }); - - it('Tensor3D is allowed', async () => { - const fSize = 2; - const pad = 'same'; - const stride = 1; - const chMul = 3; - const inDepth = 2; - - const x = tf.zeros([3, 3, inDepth]); - const w = tf.zeros([fSize, fSize, inDepth, chMul]); - const result = tf.depthwiseConv2d(x, w, stride, pad); - expect(result.shape).toEqual([3, 3, inDepth * chMul]); - }); - - it('Pass null for dilations, which defaults to [1, 1]', () => { - const fSize = 2; - const pad = 'same'; - const stride = 1; - const chMul = 3; - const inDepth = 2; - const dilations: [number, number] = null; - - const x = tf.zeros([3, 3, inDepth]); - const w = tf.zeros([fSize, fSize, inDepth, chMul]); - const result = tf.depthwiseConv2d(x, w, stride, pad, 'NHWC', dilations); - expect(result.shape).toEqual([3, 3, inDepth * chMul]); - }); - - it('TensorLike', async () => { - const pad = 'valid'; - const stride = 1; - - const x = [[ - [[0.230664], [0.987388], [0.0685208]], - [[0.419224], [0.887861], [0.731641]], - [[0.0741907], [0.409265], [0.351377]] - ]]; - const w = [[[[0.303873]], [[0.229223]]], [[[0.144333]], [[0.803373]]]]; - - const result = tf.depthwiseConv2d(x, w, stride, pad); - - const expected = [1.07022, 1.03167, 0.67041, 0.778863]; - expectArraysClose(await result.data(), expected); - }); - it('TensorLike Chained', async () => { - const pad = 'valid'; - const stride = 1; - const inDepth = 1; - - const x = tf.tensor4d( - [ - 0.230664, 0.987388, 0.0685208, 0.419224, 0.887861, 0.731641, - 0.0741907, 0.409265, 0.351377 - ], - [1, 3, 3, inDepth]); - const w = [[[[0.303873]], [[0.229223]]], [[[0.144333]], [[0.803373]]]]; - - const result = x.depthwiseConv2d(w, stride, pad); - expect(result.shape).toEqual([1, 2, 2, 1]); - - const expected = [1.07022, 1.03167, 0.67041, 0.778863]; - expectArraysClose(await result.data(), expected); - }); - - it('throws when passed x as a non-tensor', () => { - const inputDepth = 1; - const outputDepth = 1; - const fSize = 1; - const pad = 'same'; - const stride = 2; - const dataFormat = 'NHWC'; - const dilation = 2; - - const w = tf.tensor4d([3], [fSize, fSize, inputDepth, outputDepth]); - - const e = /Argument 'x' passed to 'depthwiseConv2d' must be a Tensor/; - expect( - () => tf.depthwiseConv2d( - {} as tf.Tensor3D, w, stride, pad, dataFormat, dilation)) - .toThrowError(e); - }); - - it('throws when passed filter as a non-tensor', () => { - const inputDepth = 1; - const inputShape: [number, number, number] = [2, 2, inputDepth]; - const pad = 'same'; - const stride = 2; - const dataFormat = 'NHWC'; - const dilation = 2; - - const x = tf.tensor3d([1, 2, 3, 4], inputShape); - - const e = /Argument 'filter' passed to 'depthwiseConv2d' must be a Tensor/; - expect( - () => tf.depthwiseConv2d( - x, {} as tf.Tensor4D, stride, pad, dataFormat, dilation)) - .toThrowError(e); - }); - - it('throws when input is int32', async () => { - const fSize = 2; - const pad = 'valid'; - const stride = 1; - const chMul = 1; - const inDepth = 1; - - const x = - tf.tensor4d([1, 2, 3, 4, 5, 6, 7, 8, 9], [1, 3, 3, inDepth], 'int32'); - const w = tf.tensor4d( - [0.303873, 0.229223, 0.144333, 0.803373], - [fSize, fSize, inDepth, chMul], - ); - - const errRegex = /Argument 'x' passed to 'depthwiseConv2d' must be float32/; - expect(() => tf.depthwiseConv2d(x, w, stride, pad)).toThrowError(errRegex); - }); - - it('throws when filter is int32', async () => { - const fSize = 2; - const pad = 'valid'; - const stride = 1; - const chMul = 1; - const inDepth = 1; - - const x = tf.tensor4d([1, 2, 3, 4, 5, 6, 7, 8, 9], [1, 3, 3, inDepth]); - const w = tf.tensor4d( - [1, 2, 3, 4], - [fSize, fSize, inDepth, chMul], - 'int32', - ); - - const errRegex = - /Argument 'filter' passed to 'depthwiseConv2d' must be float32/; - expect(() => tf.depthwiseConv2d(x, w, stride, pad)).toThrowError(errRegex); - }); - - it('throws when dimRoundingMode is set and pad is same', () => { - const fSize = 2; - const pad = 'same'; - const stride = 1; - const chMul = 1; - const inDepth = 1; - const dimRoundingMode = 'round'; - - const x = tf.tensor4d( - [ - 0.230664, 0.987388, 0.0685208, 0.419224, 0.887861, 0.731641, - 0.0741907, 0.409265, 0.351377 - ], - [1, 3, 3, inDepth]); - const w = tf.tensor4d( - [0.303873, 0.229223, 0.144333, 0.803373], - [fSize, fSize, inDepth, chMul], - ); - expect( - () => tf.depthwiseConv2d(x, w, stride, pad, 'NHWC', 1, dimRoundingMode)) - .toThrowError(); - }); - - it('throws when dimRoundingMode is set and pad is valid', () => { - const fSize = 2; - const pad = 'valid'; - const stride = 1; - const chMul = 1; - const inDepth = 1; - const dimRoundingMode = 'round'; - - const x = tf.tensor4d( - [ - 0.230664, 0.987388, 0.0685208, 0.419224, 0.887861, 0.731641, - 0.0741907, 0.409265, 0.351377 - ], - [1, 3, 3, inDepth]); - const w = tf.tensor4d( - [0.303873, 0.229223, 0.144333, 0.803373], - [fSize, fSize, inDepth, chMul], - ); - expect( - () => tf.depthwiseConv2d(x, w, stride, pad, 'NHWC', 1, dimRoundingMode)) - .toThrowError(); - }); - - it('throws when dimRoundingMode is set and pad is a non-integer number', - () => { - const fSize = 2; - const pad = 1.2; - const stride = 1; - const chMul = 1; - const inDepth = 1; - const dimRoundingMode = 'round'; - - const x = tf.tensor4d( - [ - 0.230664, 0.987388, 0.0685208, 0.419224, 0.887861, 0.731641, - 0.0741907, 0.409265, 0.351377 - ], - [1, 3, 3, inDepth]); - const w = tf.tensor4d( - [0.303873, 0.229223, 0.144333, 0.803373], - [fSize, fSize, inDepth, chMul], - ); - expect( - () => tf.depthwiseConv2d( - x, w, stride, pad, 'NHWC', 1, dimRoundingMode)) - .toThrowError(); - }); - - it('throws when dimRoundingMode is set and pad is explicit by non-integer ' + - 'number', - () => { - const fSize = 2; - const pad = [[0, 0], [0, 2.1], [1, 1], [0, 0]] as - tf.backend_util.ExplicitPadding; - const stride = 1; - const chMul = 1; - const inDepth = 1; - const dimRoundingMode = 'round'; - - const x = tf.tensor4d( - [ - 0.230664, 0.987388, 0.0685208, 0.419224, 0.887861, 0.731641, - 0.0741907, 0.409265, 0.351377 - ], - [1, 3, 3, inDepth]); - const w = tf.tensor4d( - [0.303873, 0.229223, 0.144333, 0.803373], - [fSize, fSize, inDepth, chMul], - ); - expect( - () => tf.depthwiseConv2d( - x, w, stride, pad, 'NHWC', 1, dimRoundingMode)) - .toThrowError(); - }); - - it('accepts a tensor-like object', async () => { - const pad = 'valid'; - const stride = 1; - // 1x3x3x1 - const x = [[ - [[0.230664], [0.987388], [0.0685208]], - [[0.419224], [0.887861], [0.731641]], - [[0.0741907], [0.409265], [0.351377]] - ]]; - // 2x2x1x1 - const w = [[[[0.303873]], [[0.229223]]], [[[0.144333]], [[0.803373]]]]; - const result = tf.depthwiseConv2d(x, w, stride, pad); - expect(result.shape).toEqual([1, 2, 2, 1]); - - const expected = [1.07022, 1.03167, 0.67041, 0.778863]; - expectArraysClose(await result.data(), expected); - }); -}); - -describeWithFlags('depthwiseConv2d gradients', ALL_ENVS, () => { - let images: tf.Tensor4D; - let filter: tf.Tensor4D; - let result: tf.Tensor4D; - const stride = 1; - const pad = 'same'; - - beforeEach(() => { - // two 2x2 RGB images => 2x2x2x3 - images = tf.tensor4d([ - [[[2, 3, 1], [3, 0, 2]], [[0, 4, 1], [3, 1, 3]]], - [[[2, 1, 0], [0, 3, 3]], [[4, 0, 1], [1, 4, 1]]] - ]); - // 2x2 filters, chMul = 2 => 2x2x3x2 - filter = tf.tensor4d([ - [[[1, 1], [1, 1], [0, 0]], [[0, 1], [1, 1], [1, 1]]], - [[[1, 0], [1, 1], [0, 0]], [[0, 1], [1, 0], [0, 0]]] - ]); - // result of convolution operatoin - result = tf.tensor4d([ - [ - [[2, 8, 8, 7, 2, 2], [6, 3, 1, 1, 0, 0]], - [[0, 3, 5, 5, 3, 3], [3, 3, 1, 1, 0, 0]] - ], - [ - [[6, 3, 8, 4, 3, 3], [1, 0, 7, 7, 0, 0]], - [[4, 5, 4, 4, 1, 1], [1, 1, 4, 4, 0, 0]] - ] - ]); - }); - - it('wrt input', async () => { - const {value, grad} = tf.valueAndGrad( - (x: tf.Tensor4D) => tf.depthwiseConv2d(x, filter, stride, pad))(images); - - expectArraysClose(await value.data(), await result.data()); - - const expectedGrad = tf.tensor4d([ - [[[2., 2., 0.], [3., 4., 2.]], [[3., 4., 0.], [5., 7., 2.]]], - [[[2., 2., 0.], [3., 4., 2.]], [[3., 4., 0.], [5., 7., 2.]]] - ]); - - expectArraysClose(await grad.data(), await expectedGrad.data()); - }); - - // The gradients of normal and depthwise 2D convolutions are actually the same - // in the special case that dy = 1, so we also test the gradient of a function - // of the output to disambiguate the two methods. - it('wrt input, squared output', async () => { - const grad = tf.grad( - (x: tf.Tensor4D) => - tf.square(tf.depthwiseConv2d(x, filter, stride, pad)))(images); - - const expectedGrad = tf.tensor4d([ - [[[20., 30., 0.], [34., 34., 8.]], [[10., 50., 0.], [46., 44., 12.]]], - [[[18., 24., 0.], [8., 52., 12.]], [[30., 40., 0.], [22., 76., 4.]]] - ]); - - expectArraysClose(await grad.data(), await expectedGrad.data()); - }); - - it('wrt filter', async () => { - const {value, grad} = tf.valueAndGrad( - (f: tf.Tensor4D) => tf.depthwiseConv2d(images, f, stride, pad))(filter); - - expectArraysClose(await value.data(), await result.data()); - - const expectedGrad = tf.tensor4d([ - [[[15., 15.], [16., 16.], [12., 12.]], [[7., 7.], [8., 8.], [9., 9.]]], - [[[8., 8.], [9., 9.], [6., 6.]], [[4., 4.], [5., 5.], [4., 4.]]] - ]); - - expectArraysClose(await grad.data(), await expectedGrad.data()); - }); - - it('gradient with clones', async () => { - const [dx, dFilter] = tf.grads( - (x: tf.Tensor4D, filter: tf.Tensor4D) => - tf.depthwiseConv2d(x.clone(), filter.clone(), stride, pad).clone())( - [images, filter]); - expect(dx.shape).toEqual(images.shape); - expect(dFilter.shape).toEqual(filter.shape); - }); - - // Also disambiguate regular vs. depthwise filter gradients - it('wrt filter, squared output', async () => { - const grad = tf.grad( - (f: tf.Tensor4D) => - tf.square(tf.depthwiseConv2d(images, f, stride, pad)))(filter); - - const expectedGrad = tf.tensor4d([ - [ - [[120., 122.], [180., 166.], [12., 12.]], - [[20., 76.], [90., 66.], [46., 46.]] - ], - [ - [[86., 42.], [122., 114.], [10., 10.]], - [[24., 54.], [80., 46.], [18., 18.]] - ] - ]); - - expectArraysClose(await grad.data(), await expectedGrad.data()); - }); - - it('throws error on dilations > 1', () => { - const grad = tf.grad( - (x: tf.Tensor4D) => - tf.depthwiseConv2d(x, filter, stride, pad, 'NHWC', 2)); - - expect(() => grad(images)) - .toThrowError(/dilation rates greater than 1 are not yet supported/); - }); - - it('wrt input, stride=2, pad=valid', async () => { - const dx = tf.grad( - (x: tf.Tensor4D) => tf.depthwiseConv2d(x, filter, 2, 'valid'))(images); - - expectArraysClose(await dx.data(), [ - 2., 2., 0., 1., 2., 2., 1., 2., 0., 1., 1., 0., - 2., 2., 0., 1., 2., 2., 1., 2., 0., 1., 1., 0. - ]); - expect(dx.shape).toEqual([2, 2, 2, 3]); - }); - - it('wrt filter, stride=2, pad=valid', async () => { - const df = tf.grad( - (f: tf.Tensor4D) => tf.depthwiseConv2d(images, f, 2, 'valid'))(filter); - - expectArraysClose(await df.data(), [ - 4., 4., 4., 4., 1., 1., 3., 3., 3., 3., 5., 5., - 4., 4., 4., 4., 2., 2., 4., 4., 5., 5., 4., 4. - ]); - expect(df.shape).toEqual([2, 2, 3, 2]); - }); - - it('gradient with clones', async () => { - const fSize = 2; - const pad = 'valid'; - const stride = 1; - const chMul = 1; - const inDepth = 1; - - const x = tf.tensor4d( - [ - 0.230664, 0.987388, 0.0685208, 0.419224, 0.887861, 0.731641, - 0.0741907, 0.409265, 0.351377 - ], - [1, 3, 3, inDepth]); - - const f = tf.tensor4d( - [0.303873, 0.229223, 0.144333, 0.803373], - [fSize, fSize, inDepth, chMul], - ); - - const [dx, df] = tf.grads( - (x: tf.Tensor4D, f: tf.Tensor4D) => - tf.depthwiseConv2d(x.clone(), f.clone(), stride, pad).clone())( - [x, f]); - - expectArraysClose(await dx.data(), [ - 0.303873, 0.533096, 0.229223, 0.448206, 1.480802, 1.032596, 0.144333, - 0.947706, 0.803373 - ]); - expect(dx.shape).toEqual([1, 3, 3, 1]); - - expectArraysClose( - await df.data(), [2.525137, 2.6754108, 1.7905407, 2.380144]); - expect(df.shape).toEqual([2, 2, 1, 1]); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/diag.ts b/tfjs-master/tfjs-core/src/ops/diag.ts deleted file mode 100644 index 20216db0e..000000000 --- a/tfjs-master/tfjs-core/src/ops/diag.ts +++ /dev/null @@ -1,57 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {Diag, DiagInputs} from '../kernel_names'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; - -import {op} from './operation'; - -/** - * Returns a diagonal tensor with given diagonal values. - * - * Given a diagonal, this operation returns a tensor with the diagonal and - * everything else padded with zeros. - * - * Assume the input has dimensions `[D1,..., Dk]`, then the output is a tensor - * of rank 2k with dimensions `[D1,..., Dk, D1,..., Dk]` - * - * ```js - * const x = tf.tensor1d([1, 2, 3, 4]); - * - * tf.diag(x).print() - * ``` - * ```js - * const x = tf.tensor2d([1, 2, 3, 4, 5, 6, 7, 8], [4, 2]) - * - * tf.diag(x).print() - * ``` - * @param x The input tensor. - * - * @doc {heading: 'Tensors', subheading: 'Creation'} - */ -function diag_(x: Tensor): Tensor { - const $x = convertToTensor(x, 'x', 'diag'); - - const inputs: DiagInputs = {x: $x}; - - return ENGINE.runKernel(Diag, inputs as unknown as NamedTensorMap); -} - -export const diag = /* @__PURE__ */ op({diag_}); diff --git a/tfjs-master/tfjs-core/src/ops/diag_test.ts b/tfjs-master/tfjs-core/src/ops/diag_test.ts deleted file mode 100644 index 588c49104..000000000 --- a/tfjs-master/tfjs-core/src/ops/diag_test.ts +++ /dev/null @@ -1,104 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose, expectArraysEqual} from '../test_util'; - -describeWithFlags('diag', ALL_ENVS, () => { - it('1d', async () => { - const m = tf.tensor1d([5]); - const diag = tf.diag(m); - expect(diag.shape).toEqual([1, 1]); - expectArraysClose(await diag.data(), [5]); - }); - it('2d', async () => { - const m = tf.tensor2d([8, 2, 3, 4, 5, 1], [3, 2]); - const diag = tf.diag(m); - expect(diag.shape).toEqual([3, 2, 3, 2]); - expectArraysClose(await diag.data(), [ - 8, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, - 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 1 - ]); - }); - it('3d', async () => { - const m = tf.tensor3d([8, 5, 5, 7, 9, 10, 15, 1, 2, 14, 12, 3], [2, 2, 3]); - const diag = tf.diag(m); - expect(diag.shape).toEqual([2, 2, 3, 2, 2, 3]); - expectArraysClose(await diag.data(), [ - 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, - ]); - }); - it('4d', async () => { - const m = tf.tensor4d( - [ - 8, 5, 5, 7, 9, 10, 15, 1, 2, 14, 12, 3, - 9, 6, 6, 8, 10, 11, 16, 2, 3, 15, 13, 4 - ], - [2, 2, 3, 2]); - const diag = tf.diag(m); - expect(diag.shape).toEqual([2, 2, 3, 2, 2, 2, 3, 2]); - expectArraysClose(await diag.data(), [ - 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 4 - ]); - }); - it('int32', async () => { - const m = tf.tensor1d([5, 3], 'int32'); - const diag = tf.diag(m); - expect(diag.shape).toEqual([2, 2]); - expect(diag.dtype).toBe('int32'); - expectArraysEqual(await diag.data(), [5, 0, 0, 3]); - }); - it('bool', async () => { - const m = tf.tensor1d([5, 3], 'bool'); - const diag = tf.diag(m); - expect(diag.shape).toEqual([2, 2]); - expect(diag.dtype).toBe('bool'); - expectArraysEqual(await diag.data(), [1, 0, 0, 1]); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/dilation2d.ts b/tfjs-master/tfjs-core/src/ops/dilation2d.ts deleted file mode 100644 index 51c27da39..000000000 --- a/tfjs-master/tfjs-core/src/ops/dilation2d.ts +++ /dev/null @@ -1,110 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {Dilation2D, Dilation2DAttrs, Dilation2DInputs} from '../kernel_names'; -import {NamedAttrMap} from '../kernel_registry'; -import {Tensor3D, Tensor4D} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; -import * as util from '../util'; - -import {op} from './operation'; -import {reshape} from './reshape'; - -/** - * Computes the grayscale dilation over the input `x`. - * - * @param x The input tensor, rank 3 or rank 4 of shape - * `[batch, height, width, depth]`. If rank 3, batch of 1 is assumed. - * @param filter The filter tensor, rank 3, of shape - * `[filterHeight, filterWidth, depth]`. - * @param strides The strides of the sliding window for each dimension of the - * input tensor: `[strideHeight, strideWidth]`. - * If `strides` is a single number, - * then `strideHeight == strideWidth`. - * @param pad The type of padding algorithm. - * - `same` and stride 1: output will be of same size as input, - * regardless of filter size. - * - `valid`: output will be smaller than input if filter is larger - * than 1*1x1. - * - For more info, see this guide: - * [https://www.tensorflow.org/api_docs/python/tf/nn/convolution]( - * https://www.tensorflow.org/api_docs/python/tf/nn/convolution) - * @param dataFormat Specify the data format of the input and output data. - * Defaults to 'NHWC'. Only 'NHWC' is currently supported. With the - * default format "NHWC", the data is stored in the order of: [batch, - * height, width, channels]. - * @param dilations The dilation rates: `[dilationHeight, dilationWidth]` - * in which we sample input values across the height and width dimensions - * for atrous morphological dilation. Defaults to `[1, 1]`. If `dilations` - * is a single number, then `dilationHeight == dilationWidth`. If it is - * greater than 1, then all values of `strides` must be 1. - * - * @doc {heading: 'Operations', subheading: 'Convolution'} - */ -function dilation2d_( - x: T|TensorLike, filter: Tensor3D|TensorLike, - strides: [number, number]|number, pad: 'valid'|'same', - dilations: [number, number]|number = [1, 1], - dataFormat: 'NHWC' = 'NHWC'): T { - const $x = convertToTensor(x, 'x', 'dilation2d'); - const $filter = convertToTensor(filter, 'filter', 'dilation2d'); - - util.assert( - $x.rank === 3 || $x.rank === 4, - () => `Error in dilation2d: input must be rank 3 or 4, but got rank ` + - `${$x.rank}.`); - util.assert( - $filter.rank === 3, - () => `Error in dilation2d: filter must be rank 3, but got rank ` + - `${$filter.rank}.`); - util.assert( - dataFormat === 'NHWC', - () => `Error in dilation2d: Only NHWC is currently supported, ` + - `but got dataFormat of ${dataFormat}`); - - let x4D = $x as Tensor4D; - let reshapedTo4D = false; - - if ($x.rank === 3) { - x4D = reshape($x, [1, $x.shape[0], $x.shape[1], $x.shape[2]]); - reshapedTo4D = true; - } - - util.assert( - x4D.shape[3] === $filter.shape[2], - () => `Error in dilation2d: input and filter must have the same depth: ${ - x4D.shape[3]} vs ${$filter.shape[2]}`); - - const inputs: Dilation2DInputs = {x: x4D, filter: $filter}; - const attrs: Dilation2DAttrs = {strides, pad, dilations}; - - // tslint:disable-next-line: no-unnecessary-type-assertion - const res = ENGINE.runKernel( - Dilation2D, inputs as unknown as NamedTensorMap, - attrs as unknown as NamedAttrMap) as T; - - if (reshapedTo4D) { - return reshape(res, [res.shape[1], res.shape[2], res.shape[3]]) as T; - } - - return res; -} - -export const dilation2d = /* @__PURE__ */ op({dilation2d_}); diff --git a/tfjs-master/tfjs-core/src/ops/dilation2d_test.ts b/tfjs-master/tfjs-core/src/ops/dilation2d_test.ts deleted file mode 100644 index 05e0a8933..000000000 --- a/tfjs-master/tfjs-core/src/ops/dilation2d_test.ts +++ /dev/null @@ -1,280 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('dilation2d', ALL_ENVS, () => { - it('valid padding.', async () => { - const inputShape: [number, number, number, number] = [1, 2, 2, 1]; - const filterShape: [number, number, number] = [2, 2, 1]; - const x = tf.tensor4d([.1, .2, .3, .4], inputShape); - const filter = tf.tensor3d([.4, .3, .1, .0], filterShape); - - const result = tf.dilation2d(x, filter, 1 /* strides */, 'valid'); - - expect(result.shape).toEqual([1, 1, 1, 1]); - expectArraysClose(await result.data(), [.5]); - }); - - it('same padding.', async () => { - const inputShape: [number, number, number, number] = [1, 2, 2, 1]; - const filterShape: [number, number, number] = [2, 2, 1]; - const x = tf.tensor4d([.1, .2, .3, .4], inputShape); - const filter = tf.tensor3d([.4, .3, .1, .0], filterShape); - - const result = tf.dilation2d(x, filter, 1 /* strides */, 'same'); - - expect(result.shape).toEqual([1, 2, 2, 1]); - expectArraysClose(await result.data(), [.5, .6, .7, .8]); - }); - - it('same padding depth 3.', async () => { - const inputShape: [number, number, number, number] = [1, 2, 2, 3]; - const filterShape: [number, number, number] = [2, 2, 3]; - const x = tf.tensor4d( - [.1, .2, .0, .2, .3, .1, .3, .4, .2, .4, .5, .3], inputShape); - const filter = tf.tensor3d( - [.4, .5, .3, .3, .4, .2, .1, .2, .0, .0, .1, -.1], filterShape); - - const result = tf.dilation2d(x, filter, 1 /* strides */, 'same'); - - expect(result.shape).toEqual([1, 2, 2, 3]); - expectArraysClose( - await result.data(), [.5, .7, .3, .6, .8, .4, .7, .9, .5, .8, 1., .6]); - }); - - it('same padding batch 2.', async () => { - const inputShape: [number, number, number, number] = [2, 2, 2, 1]; - const filterShape: [number, number, number] = [2, 2, 1]; - const x = tf.tensor4d([.1, .2, .3, .4, .2, .3, .4, .5], inputShape); - const filter = tf.tensor3d([.4, .3, .1, .0], filterShape); - - const result = tf.dilation2d(x, filter, 1 /* strides */, 'same'); - - expect(result.shape).toEqual([2, 2, 2, 1]); - expectArraysClose(await result.data(), [.5, .6, .7, .8, .6, .7, .8, .9]); - }); - - it('same padding filter 2.', async () => { - const inputShape: [number, number, number, number] = [1, 3, 3, 1]; - const filterShape: [number, number, number] = [2, 2, 1]; - const x = tf.tensor4d([.1, .2, .3, .4, .5, .6, .7, .8, .9], inputShape); - const filter = tf.tensor3d([.4, .3, .1, .2], filterShape); - - const result = tf.dilation2d(x, filter, 1 /* strides */, 'same'); - - expect(result.shape).toEqual([1, 3, 3, 1]); - expectArraysClose( - await result.data(), [.7, .8, .7, 1, 1.1, 1, 1.1, 1.2, 1.3]); - }); - - it('valid padding non-square-window.', async () => { - const inputShape: [number, number, number, number] = [1, 2, 2, 1]; - const filterShape: [number, number, number] = [1, 2, 1]; - const x = tf.tensor4d([.1, .2, .3, .4], inputShape); - const filter = tf.tensor3d([.4, .3], filterShape); - - const result = tf.dilation2d(x, filter, 1 /* strides */, 'valid'); - - expect(result.shape).toEqual([1, 2, 1, 1]); - expectArraysClose(await result.data(), [.5, .7]); - }); - - it('same padding dilations 2.', async () => { - const inputShape: [number, number, number, number] = [1, 3, 3, 1]; - const filterShape: [number, number, number] = [2, 2, 1]; - const x = tf.tensor4d([.1, .2, .3, .4, .5, .6, .7, .8, .9], inputShape); - const filter = tf.tensor3d([.4, .3, .1, .2], filterShape); - - const result = tf.dilation2d(x, filter, 1 /* strides */, 'same', 2); - - // Because dilations = 2, the effective filter is [3, 3, 1]: - // filter_eff = [[[.4], [.0], [.3]], - // [[.0], [.0], [.0]], - // [[.1], [.0], [.2]]] - expect(result.shape).toEqual([1, 3, 3, 1]); - expectArraysClose( - await result.data(), [.7, .8, .6, 1., 1.1, .9, .8, .9, .9]); - }); - - it('valid padding uneven stride.', async () => { - const inputShape: [number, number, number, number] = [1, 3, 4, 1]; - const filterShape: [number, number, number] = [2, 2, 1]; - const x = tf.tensor4d( - [.1, .2, .3, .4, .5, .6, .7, .8, .9, 1., 1.1, 1.2], inputShape); - const filter = tf.tensor3d([.4, .3, .1, .2], filterShape); - - const result = tf.dilation2d(x, filter, [1, 2] /* strides */, 'valid'); - - expect(result.shape).toEqual([1, 2, 2, 1]); - expectArraysClose(await result.data(), [.8, 1., 1.2, 1.4]); - }); - - it('throws when input rank is not 3 or 4.', async () => { - const filterShape: [number, number, number] = [1, 1, 1]; - // tslint:disable-next-line:no-any - const x: any = tf.tensor1d([.5]); - const filter = tf.tensor3d([.4], filterShape); - - expect(() => tf.dilation2d(x, filter, 1, 'valid')).toThrowError(); - }); - - it('thorws when filter is not rank 3.', async () => { - const inputShape: [number, number, number, number] = [1, 2, 2, 1]; - const filterShape: [number, number] = [2, 2]; - const x = tf.tensor4d([.1, .2, .3, .4], inputShape); - // tslint:disable-next-line:no-any - const filter: any = tf.tensor2d([.4, .3, .1, .0], filterShape); - - expect(() => tf.dilation2d(x, filter, 1, 'valid')).toThrowError(); - }); - - it('throws when data format is not NHWC.', async () => { - const inputShape: [number, number, number, number] = [1, 2, 2, 1]; - const filterShape: [number, number, number] = [2, 2, 1]; - const x = tf.tensor4d([.1, .2, .3, .4], inputShape); - const filter = tf.tensor3d([.4, .3, .1, .0], filterShape); - // tslint:disable-next-line:no-any - const dataFormat: any = 'NCHW'; - - expect( - () => tf.dilation2d(x, filter, 1 /* strides */, 'valid', 1, dataFormat)) - .toThrowError(); - }); - - it('dilation gradient valid padding.', async () => { - const inputShape: [number, number, number, number] = [1, 3, 3, 1]; - const filterShape: [number, number, number] = [1, 1, 1]; - const x = tf.tensor4d([.1, .2, .3, .4, .5, .6, .7, .8, .9], inputShape); - const filter = tf.tensor3d([.5], filterShape); - const dy = tf.tensor4d([.2, .3, .4, .2, .1, 1., .2, .3, .4], inputShape); - - const grads = tf.grads( - (x: tf.Tensor4D, filter: tf.Tensor3D) => - x.dilation2d(filter, 1, 'valid')); - - const [dx, dfilter] = grads([x, filter], dy); - - expect(dx.shape).toEqual(x.shape); - expectArraysClose(await dx.data(), [.2, .3, .4, .2, .1, 1., .2, .3, .4]); - - expect(dfilter.shape).toEqual(filterShape); - expectArraysClose(await dfilter.data(), [3.1]); - }); - - it('dilation gradient same padding.', async () => { - const inputShape: [number, number, number, number] = [1, 3, 3, 1]; - const filterShape: [number, number, number] = [1, 1, 1]; - const x = tf.tensor4d([.1, .2, .3, .4, .5, .6, .7, .8, .9], inputShape); - const filter = tf.tensor3d([.5], filterShape); - const dy = tf.tensor4d([.2, .3, .4, .2, .1, 1., .2, .3, .4], inputShape); - - const grads = tf.grads( - (x: tf.Tensor4D, filter: tf.Tensor3D) => - x.dilation2d(filter, 1, 'same')); - - const [dx, dfilter] = grads([x, filter], dy); - - expect(dx.shape).toEqual(x.shape); - expectArraysClose(await dx.data(), [.2, .3, .4, .2, .1, 1., .2, .3, .4]); - - expect(dfilter.shape).toEqual(filterShape); - expectArraysClose(await dfilter.data(), [3.1]); - }); - - it('dilation gradient same padding depth 2.', async () => { - const inputShape: [number, number, number, number] = [1, 2, 2, 3]; - const filterShape: [number, number, number] = [1, 1, 3]; - const x = tf.tensor4d( - [.1, .2, .0, .2, .3, .1, .3, .4, .2, .4, .5, .3], inputShape); - const filter = tf.tensor3d([.4, .5, .6], filterShape); - const dy = tf.tensor4d( - [.2, .3, .4, .2, .1, 1., .2, .3, .4, .8, -.1, .1], inputShape); - - const grads = tf.grads( - (x: tf.Tensor4D, filter: tf.Tensor3D) => - x.dilation2d(filter, 1, 'same')); - - const [dx, dfilter] = grads([x, filter], dy); - - expect(dx.shape).toEqual(x.shape); - expectArraysClose( - await dx.data(), [.2, .3, .4, .2, .1, 1., .2, .3, .4, .8, -.1, .1]); - - expect(dfilter.shape).toEqual(filterShape); - expectArraysClose(await dfilter.data(), [1.4, .6, 1.9]); - }); - - it('dilation gradient valid padding filter 2.', async () => { - const inputShape: [number, number, number, number] = [1, 3, 3, 1]; - const filterShape: [number, number, number] = [2, 2, 1]; - const dyShape: [number, number, number, number] = [1, 2, 2, 1]; - const x = tf.tensor4d([.1, .2, .3, .4, .5, .6, .7, .8, .9], inputShape); - const filter = tf.tensor3d([.4, .3, .1, .2], filterShape); - const dy = tf.tensor4d([.2, .3, .4, .2], dyShape); - - const grads = tf.grads( - (x: tf.Tensor4D, filter: tf.Tensor3D) => - x.dilation2d(filter, 1, 'valid')); - - const [dx, dfilter] = grads([x, filter], dy); - - expect(dx.shape).toEqual(x.shape); - expectArraysClose(await dx.data(), [0, 0, 0, 0, .2, .3, 0, .4, .2]); - - expect(dfilter.shape).toEqual(filterShape); - expectArraysClose(await dfilter.data(), [0, 0, 0, 1.1]); - }); - - it('dilation gradient same padding filter 2 depth 3.', async () => { - const inputShape: [number, number, number, number] = [1, 3, 3, 3]; - const filterShape: [number, number, number] = [2, 2, 3]; - const x = tf.tensor4d( - [ - .1, .2, .3, .4, .5, .6, .7, .8, .9, .3, .2, .3, .4, .5, - .1, .9, .6, .3, .4, .5, .6, .2, .3, .5, .1, .2, .3 - ], - inputShape); - const filter = tf.tensor3d( - [.4, .3, .1, .2, .2, .1, .7, .3, .8, .4, .9, .1], filterShape); - const dy = tf.tensor4d( - [ - .2, .3, .4, .2, .1, .5, 0, .8, .7, .1, .2, .1, .2, .3, - .4, .5, .6, .6, .6, .7, .8, .3, .2, .1, .2, .4, .2 - ], - inputShape); - - const grads = tf.grads( - (x: tf.Tensor4D, filter: tf.Tensor3D) => - x.dilation2d(filter, 1, 'same')); - - const [dx, dfilter] = grads([x, filter], dy); - - expect(dx.shape).toEqual(x.shape); - expectArraysClose(await dx.data(), [ - 0, 0, 0, 0, 0, 0, 0, .8, .5, .2, 0, .4, 0, .3, - 0, .9, .7, .7, .7, .7, .9, .3, .4, .5, .2, .7, .8 - ]); - - expect(dfilter.shape).toEqual(filterShape); - expectArraysClose( - await dfilter.data(), - [1.6, 2.7, 1.1, .2, 0, .5, .3, 0, 2.2, .2, .9, 0]); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/div.ts b/tfjs-master/tfjs-core/src/ops/div.ts deleted file mode 100644 index 7448306c0..000000000 --- a/tfjs-master/tfjs-core/src/ops/div.ts +++ /dev/null @@ -1,70 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {RealDiv, RealDivInputs} from '../kernel_names'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {makeTypesMatch} from '../tensor_util'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -import {floorDiv} from './floorDiv'; -import {op} from './operation'; - -/** - * Divides two `tf.Tensor`s element-wise, A / B. Supports broadcasting. - * - * ```js - * const a = tf.tensor1d([1, 4, 9, 16]); - * const b = tf.tensor1d([1, 2, 3, 4]); - * - * a.div(b).print(); // or tf.div(a, b) - * ``` - * - * ```js - * // Broadcast div a with b. - * const a = tf.tensor1d([2, 4, 6, 8]); - * const b = tf.scalar(2); - * - * a.div(b).print(); // or tf.div(a, b) - * ``` - * - * @param a The first tensor as the numerator. - * @param b The second tensor as the denominator. Must have the same dtype as - * `a`. - * - * @doc {heading: 'Operations', subheading: 'Arithmetic'} - */ -function div_(a: Tensor|TensorLike, b: Tensor|TensorLike): T { - let $a = convertToTensor(a, 'a', 'div'); - let $b = convertToTensor(b, 'b', 'div'); - [$a, $b] = makeTypesMatch($a, $b); - - if ($a.dtype === 'int32' && $b.dtype === 'int32') { - return floorDiv($a, $b); - } - - const inputs: RealDivInputs = {a: $a, b: $b}; - const attrs = {}; - - // tslint:disable-next-line: no-unnecessary-type-assertion - return ENGINE.runKernel(RealDiv, - inputs as unknown as NamedTensorMap, attrs) as T; -} - -export const div = /* @__PURE__ */ op({div_}); diff --git a/tfjs-master/tfjs-core/src/ops/div_no_nan.ts b/tfjs-master/tfjs-core/src/ops/div_no_nan.ts deleted file mode 100644 index 65840ba35..000000000 --- a/tfjs-master/tfjs-core/src/ops/div_no_nan.ts +++ /dev/null @@ -1,72 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Tensor} from '../tensor'; -import {makeTypesMatch} from '../tensor_util'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -import {div} from './div'; -import {equal} from './equal'; -import {op} from './operation'; -import {where} from './where'; -import {zerosLike} from './zeros_like'; - -/** - * Divides two `tf.Tensor`s element-wise, A / B. Supports broadcasting. Return 0 - * if denominator is 0. - * - * - * ```js - * const a = tf.tensor1d([1, 4, 9, 16]); - * const b = tf.tensor1d([1, 2, 3, 4]); - * const c = tf.tensor1d([0, 0, 0, 0]); - * - * a.divNoNan(b).print(); // or tf.divNoNan(a, b) - * a.divNoNan(c).print(); // or tf.divNoNan(a, c) - * ``` - * - * ```js - * // Broadcast div a with b. - * const a = tf.tensor1d([2, 4, 6, 8]); - * const b = tf.scalar(2); - * const c = tf.scalar(0); - * - * a.divNoNan(b).print(); // or tf.divNoNan(a, b) - * a.divNoNan(c).print(); // or tf.divNoNan(a, c) - * ``` - * - * @param a The first tensor as the numerator. - * @param b The second tensor as the denominator. Must have the same dtype as - * `a`. - * - * @doc {heading: 'Operations', subheading: 'Arithmetic'} - */ -function divNoNan_( - a: Tensor|TensorLike, b: Tensor|TensorLike): T { - // TODO: Make this into its own kernel. - let $a = convertToTensor(a, 'a', 'div'); - let $b = convertToTensor(b, 'b', 'div'); - [$a, $b] = makeTypesMatch($a, $b); - - const divResult = div($a, $b); - const zeros = zerosLike(divResult); - const bEqualsZero = equal($b, zeros); - return where(bEqualsZero, zeros, divResult) as T; -} - -export const divNoNan = /* @__PURE__ */ op({divNoNan_}); diff --git a/tfjs-master/tfjs-core/src/ops/dot.ts b/tfjs-master/tfjs-core/src/ops/dot.ts deleted file mode 100644 index 48667d57b..000000000 --- a/tfjs-master/tfjs-core/src/ops/dot.ts +++ /dev/null @@ -1,82 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Tensor,} from '../tensor'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; -import * as util from '../util'; - -import {matMul} from './mat_mul'; -import {op} from './operation'; -import {reshape} from './reshape'; - -/** - * Computes the dot product of two matrices and/or vectors, `t1` and `t2`. - * - * ```js - * const a = tf.tensor1d([1, 2]); - * const b = tf.tensor2d([[1, 2], [3, 4]]); - * const c = tf.tensor2d([[1, 2, 3], [4, 5, 6]]); - * - * a.dot(b).print(); // or tf.dot(a, b) - * b.dot(a).print(); - * b.dot(c).print(); - * ``` - * @param t1 The first tensor in the dot operation. - * @param t2 The second tensor in the dot operation. - * - * @doc {heading: 'Operations', subheading: 'Matrices'} - */ -function dot_(t1: Tensor|TensorLike, t2: Tensor|TensorLike): Tensor { - const $t1 = convertToTensor(t1, 't1', 'dot'); - const $t2 = convertToTensor(t2, 't2', 'dot'); - - util.assert( - ($t1.rank === 1 || $t1.rank === 2) && ($t2.rank === 1 || $t2.rank === 2), - () => `Error in dot: inputs must all be rank 1 or 2, but got ranks ` + - `${$t1.rank} and ${$t2.rank}.`); - - const t1Inner = ($t1.rank === 1 ? $t1.size : $t1.shape[1]); - const t2Inner = ($t2.rank === 1 ? $t2.size : $t2.shape[0]); - - util.assert( - t1Inner === t2Inner, - () => `Error in dot: inner dimensions of inputs must match, but got ` + - `${t1Inner} and ${t2Inner}.`); - - if ($t1.rank === 1 && $t2.rank === 1) { - const t12D = reshape($t1, [1, -1]); - const t22D = reshape($t2, [-1, 1]); - const t1t2 = matMul(t12D, t22D); - return reshape(t1t2, []); - } else if ($t1.rank === 1 && $t2.rank === 2) { - const t12D = reshape($t1, [1, -1]); - const t22D = reshape($t2, [$t2.shape[0], $t2.shape[1]]); - const t1t2 = matMul(t12D, t22D); - return reshape(t1t2, [t1t2.size]); - } else if ($t1.rank === 2 && $t2.rank === 1) { - const t22D = reshape($t2, [-1, 1]); - const t1t2 = matMul($t1, t22D); - return reshape(t1t2, [t1t2.size]); - } else { - const t22D = reshape($t2, [$t2.shape[0], $t2.shape[1]]); - const t1t2 = matMul($t1, t22D); - return t1t2; - } -} - -export const dot = /* @__PURE__ */ op({dot_}); diff --git a/tfjs-master/tfjs-core/src/ops/draw_test.ts b/tfjs-master/tfjs-core/src/ops/draw_test.ts deleted file mode 100644 index e38427d9a..000000000 --- a/tfjs-master/tfjs-core/src/ops/draw_test.ts +++ /dev/null @@ -1,215 +0,0 @@ -/** - * @license - * Copyright 2023 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {BROWSER_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose, expectArraysEqual} from '../test_util'; - -function readPixelsFromCanvas( - canvas: HTMLCanvasElement, contextType: string, width: number, - height: number) { - let actualData; - if (contextType === '2d') { - const ctx = canvas.getContext(contextType); - actualData = ctx.getImageData(0, 0, width, height).data; - } else { - const tmpCanvas = document.createElement('canvas'); - tmpCanvas.width = width; - tmpCanvas.height = height; - const ctx = tmpCanvas.getContext('2d'); - - ctx.drawImage(canvas, 0, 0); - actualData = new Uint8ClampedArray( - ctx.getImageData(0, 0, ctx.canvas.width, ctx.canvas.height).data); - } - return actualData; -} - -function convertToRGBA( - data: number[], shape: number[], dtype: string, alpha = 1) { - const [height, width] = shape.slice(0, 2); - const depth = shape.length === 2 ? 1 : shape[2]; - const multiplier = dtype === 'float32' ? 255 : 1; - const bytes = new Uint8ClampedArray(width * height * 4); - - for (let i = 0; i < height * width; ++i) { - const rgba = [0, 0, 0, 255 * alpha]; - - for (let d = 0; d < depth; d++) { - const value = data[i * depth + d]; - - if (dtype === 'float32') { - if (value < 0 || value > 1) { - throw new Error( - `Tensor values for a float32 Tensor must be in the ` + - `range [0 - 1] but encountered ${value}.`); - } - } else if (dtype === 'int32') { - if (value < 0 || value > 255) { - throw new Error( - `Tensor values for a int32 Tensor must be in the ` + - `range [0 - 255] but encountered ${value}.`); - } - } - - if (depth === 1) { - rgba[0] = value * multiplier; - rgba[1] = value * multiplier; - rgba[2] = value * multiplier; - } else { - rgba[d] = value * multiplier; - } - } - - const j = i * 4; - bytes[j + 0] = Math.round(rgba[0]); - bytes[j + 1] = Math.round(rgba[1]); - bytes[j + 2] = Math.round(rgba[2]); - bytes[j + 3] = Math.round(rgba[3]); - } - return bytes; -} - -function drawAndReadback( - contextType: string, data: number[], shape: number[], dtype: string, - alpha = 1, canvasUsedAs2d = false) { - const [height, width] = shape.slice(0, 2); - let img; - if (shape.length === 3) { - img = tf.tensor3d( - data, shape as [number, number, number], dtype as keyof tf.DataTypeMap); - } else { - img = tf.tensor2d( - data, shape as [number, number], dtype as keyof tf.DataTypeMap); - } - const canvas = document.createElement('canvas'); - canvas.width = width; - canvas.height = height; - if (canvasUsedAs2d) { - canvas.getContext('2d'); - } - const drawOptions = {contextOptions: {contextType}, imageOptions: {alpha}}; - // tslint:disable-next-line:no-any - tf.browser.draw(img, canvas as any, drawOptions); - const actualData = readPixelsFromCanvas(canvas, contextType, width, height); - const expectedData = convertToRGBA(data, shape, dtype, alpha); - img.dispose(); - return [actualData, expectedData]; -} - -// CPU and GPU handle pixel value differently. The epsilon may possibly grow -// after each draw and read back. -const DRAW_EPSILON = 6.0; - -describeWithFlags('draw on canvas context', BROWSER_ENVS, (env) => { - let contextType: string; - beforeAll(async () => { - await tf.setBackend(env.name); - contextType = env.name === 'cpu' ? '2d' : env.name; - }); - - it('draw image with 4 channels and int values', async () => { - const data = - [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160]; - const shape = [2, 2, 4]; - const dtype = 'int32'; - const startNumTensors = tf.memory().numTensors; - const [actualData, expectedData] = - drawAndReadback(contextType, data, shape, dtype); - expect(tf.memory().numTensors).toEqual(startNumTensors); - expectArraysClose(actualData, expectedData, DRAW_EPSILON); - }); - - it('draw image with 4 channels and int values, alpha=0.5', async () => { - const data = - [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160]; - const shape = [2, 2, 4]; - const dtype = 'int32'; - const startNumTensors = tf.memory().numTensors; - const [actualData, expectedData] = - drawAndReadback(contextType, data, shape, dtype, 0.5); - expect(tf.memory().numTensors).toEqual(startNumTensors); - expectArraysClose(actualData, expectedData, DRAW_EPSILON); - }); - - it('draw image with 4 channels and float values', async () => { - const data = - [.1, .2, .3, .4, .5, .6, .7, .8, .09, .1, .11, .12, .13, .14, .15, .16]; - const shape = [2, 2, 4]; - const dtype = 'float32'; - const [actualData, expectedData] = - drawAndReadback(contextType, data, shape, dtype); - expectArraysClose(actualData, expectedData, DRAW_EPSILON); - }); - - it('draw image with 3 channels and int values', async () => { - const data = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]; - const shape = [2, 2, 3]; - const dtype = 'int32'; - const [actualData, expectedData] = - drawAndReadback(contextType, data, shape, dtype); - expectArraysEqual(actualData, expectedData); - }); - - it('draw image with 3 channels and int values, alpha=0.5', async () => { - const data = [101, 32, 113, 14, 35, 76, 17, 38, 59, 70, 81, 92]; - const shape = [2, 2, 3]; - const dtype = 'int32'; - const alpha = 0.5; - const [actualData, expectedData] = - drawAndReadback(contextType, data, shape, dtype, alpha); - expectArraysClose(actualData, expectedData, DRAW_EPSILON); - }); - - it('draw image with 3 channels and float values', async () => { - const data = [.1, .2, .3, .4, .5, .6, .7, .8, .9, .1, .11, .12]; - const shape = [2, 2, 3]; - const dtype = 'float32'; - const [actualData, expectedData] = - drawAndReadback(contextType, data, shape, dtype); - expectArraysClose(actualData, expectedData, DRAW_EPSILON); - }); - - it('draw 2D image in grayscale', async () => { - const data = [100, 12, 90, 64]; - const shape = [2, 2]; - const dtype = 'int32'; - const [actualData, expectedData] = - drawAndReadback(contextType, data, shape, dtype); - expectArraysEqual(actualData, expectedData); - }); - - it('draw image with alpha=0.5', async () => { - const data = [101, 212, 113, 14, 35, 76, 17, 38, 59, 70, 81, 92]; - const shape = [6, 2, 1]; - const dtype = 'int32'; - const alpha = 0.5; - const [actualData, expectedData] = - drawAndReadback(contextType, data, shape, dtype, alpha); - expectArraysClose(actualData, expectedData, DRAW_EPSILON); - }); - - it('draw image works when canvas has been used for 2d', async () => { - const data = [101, 212, 113, 14, 35, 76, 17, 38, 59, 70, 81, 92]; - const shape = [6, 2, 1]; - const dtype = 'int32'; - // Set canvasUsedAs2d to true so the canvas will be first used for 2d. - const [actualData, expectedData] = - drawAndReadback(contextType, data, shape, dtype, 1, true); - expectArraysClose(actualData, expectedData, DRAW_EPSILON); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/dropout.ts b/tfjs-master/tfjs-core/src/ops/dropout.ts deleted file mode 100644 index ee9fbdba2..000000000 --- a/tfjs-master/tfjs-core/src/ops/dropout.ts +++ /dev/null @@ -1,79 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Tensor} from '../tensor'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; -import * as util from '../util'; - -import {add} from './add'; -import {div} from './div'; -import {getNoiseShape} from './dropout_util'; -import {floor} from './floor'; -import {mul} from './mul'; -import {op} from './operation'; -import {randomUniform} from './random_uniform'; - -/** - * Computes dropout. - * - * ```js - * const x = tf.tensor1d([1, 2, 2, 1]); - * const rate = 0.75; - * const output = tf.dropout(x, rate); - * output.print(); - * ``` - * - * @param x A floating point Tensor or TensorLike. - * @param rate A float in the range [0, 1). The probability that each element - * of x is discarded. - * @param noiseShape An array of numbers of type int32, representing the - * shape for randomly generated keep/drop flags. If the noiseShape has null - * value, it will be automatically replaced with the x's relative dimension - * size. Optional. - * @param seed Used to create random seeds. Optional. - * @returns A Tensor of the same shape of x. - * - * @doc {heading: 'Operations', subheading: 'Dropout'} - */ -function dropout_( - x: Tensor|TensorLike, rate: number, noiseShape?: number[], - seed?: number|string): Tensor { - const $x = convertToTensor(x, 'x', 'dropout'); - - util.assert( - $x.dtype === 'float32', - () => `x has to be a floating point tensor since it's going to be ` + - `scaled, but got a ${$x.dtype} tensor instead.`); - util.assert( - rate >= 0 && rate < 1, - () => `rate must be a float in the range [0, 1), but got ${rate}.`); - - if (rate === 0) { - return x instanceof Tensor ? $x.clone() : $x; - } - - const $noiseShape = getNoiseShape($x, noiseShape); - const keepProb = 1 - rate; - const multiplier = div( - floor(add(randomUniform($noiseShape, 0, 1, 'float32', seed), keepProb)), - keepProb); - - return mul($x, multiplier); -} - -export const dropout = /* @__PURE__ */ op({dropout_}); diff --git a/tfjs-master/tfjs-core/src/ops/dropout_test.ts b/tfjs-master/tfjs-core/src/ops/dropout_test.ts deleted file mode 100644 index 75e8d4f36..000000000 --- a/tfjs-master/tfjs-core/src/ops/dropout_test.ts +++ /dev/null @@ -1,174 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -import {tensor1d, tensor2d} from './ops'; - -describeWithFlags('dropout', ALL_ENVS, () => { - it('x 1d array, rate 0', async () => { - const x = tensor1d([1, 2, 2, 1]); - const rate = 0; - const output = tf.dropout(x, rate); - expect(output.dtype).toEqual(x.dtype); - expect(output.shape).toEqual(x.shape); - expectArraysClose(await x.data(), await output.data()); - }); - - it('x 1d array, rate 0.75', async () => { - const x = tensor1d([1, 2, 2, 1]); - const rate = 0.75; - const output = tf.dropout(x, rate); - expect(output.dtype).toEqual(x.dtype); - expect(output.shape).toEqual(x.shape); - const xValues = await x.data(); - const outputValues = await output.data(); - for (let i = 0; i < xValues.length; i++) { - if (outputValues[i] !== 0) { - expect(outputValues[i]).toBeCloseTo(1 / (1 - rate) * xValues[i]); - } - } - }); - - it('x 2d array, rate 0', async () => { - const x = tensor2d([1, 5, 2, 4, 3, 6], [2, 3]); - const rate = 0; - const output = tf.dropout(x, rate); - expect(output.dtype).toEqual(x.dtype); - expect(output.shape).toEqual(x.shape); - expectArraysClose(await x.data(), await output.data()); - }); - - it('x 2d array, rate 0.75', async () => { - const x = tensor2d([1, 5, 2, 4, 3, 6], [2, 3]); - const rate = 0.75; - const output = tf.dropout(x, rate); - expect(output.dtype).toEqual(x.dtype); - expect(output.shape).toEqual(x.shape); - const xValues = await x.data(); - const outputValues = await output.data(); - for (let i = 0; i < xValues.length; i++) { - if (outputValues[i] !== 0) { - expect(outputValues[i]).toBeCloseTo(1 / (1 - rate) * xValues[i]); - } - } - }); - - it('x 1d array, rate 0.75, with noise shape length = 1', async () => { - const x = tensor1d([1, 2, 2, 1]); - const rate = 0.75; - const noiseShape = [1]; - const output = tf.dropout(x, rate, noiseShape); - expect(output.dtype).toEqual(x.dtype); - expect(output.shape).toEqual(x.shape); - const xValues = await x.data(); - const outputValues = await output.data(); - const maskedOutput = outputValues[0]; - for (let i = 0; i < xValues.length; i++) { - if (maskedOutput === 0) { - expect(outputValues[i]).toBe(maskedOutput); - } - if (outputValues[i] !== 0) { - expect(outputValues[i]).toBeCloseTo(1 / (1 - rate) * xValues[i]); - } - } - }); - - it('x 2d array, rate 0.75, with noise shape length = 2', async () => { - const x = tensor2d([1, 5, 2, 4, 3, 6], [2, 3]); - const rate = 0.75; - const noiseShape = [2, 1]; - const output = tf.dropout(x, rate, noiseShape); - expect(output.dtype).toEqual(x.dtype); - expect(output.shape).toEqual(x.shape); - const xValues = await x.data(); - const outputValues = await output.data(); - for (let i = 0; i < x.shape[0]; i++) { - const maskedOutput = outputValues[i * x.shape[1]]; - if (maskedOutput !== 0) { - expect(maskedOutput) - .toBeCloseTo(1 / (1 - rate) * xValues[i * x.shape[1]]); - } else { - for (let j = 0; j < x.shape[1]; j++) { - expect(outputValues[i * x.shape[1] + j]).toBe(maskedOutput); - } - } - } - }); - - it('broadcast noise shape', async () => { - const x = tensor2d([1, 5, 2, 4, 3, 6], [2, 3]); - const rate = 0.75; - // broadcast noise shape, same output as using noiseShape [2, 1] - const noiseShape = [1]; - const output = tf.dropout(x, rate, noiseShape); - expect(output.dtype).toEqual(x.dtype); - expect(output.shape).toEqual(x.shape); - const xValues = await x.data(); - const outputValues = await output.data(); - for (let i = 0; i < x.shape[0]; i++) { - const maskedOutput = outputValues[i * x.shape[1]]; - if (maskedOutput !== 0) { - expect(maskedOutput) - .toBeCloseTo(1 / (1 - rate) * xValues[i * x.shape[1]]); - } else { - for (let j = 0; j < x.shape[1]; j++) { - expect(outputValues[i * x.shape[1] + j]).toBe(maskedOutput); - } - } - } - }); - - it('x 1d array, rate 0.75, with seed', async () => { - const x = tensor1d([1, 2, 2, 1]); - const rate = 0.75; - const seed = 23; - const output = tf.dropout(x, rate, null, seed); - expect(output.dtype).toEqual(x.dtype); - expect(output.shape).toEqual(x.shape); - const xValues = await x.data(); - const outputValues = await output.data(); - for (let i = 0; i < xValues.length; i++) { - if (outputValues[i] !== 0) { - expect(outputValues[i]).toBeCloseTo(1 / (1 - rate) * xValues[i]); - } - } - }); - - it('x TensorLike object', async () => { - const x = [1.0, 2.0, 2.0, 1.0]; - const rate = 0; - const output = tf.dropout(x, rate); - expect(output.dtype).toEqual('float32'); - expect(output.shape).toEqual([4]); - expectArraysClose(await output.data(), x); - }); - - it('throws when x.dtype != float32', async () => { - const x = tensor1d([1, 2, 2, 1], 'int32'); - const rate = 0.75; - expect(() => tf.dropout(x, rate)).toThrowError(); - }); - - it('throws when rate is not in the range [0, 1)', async () => { - const x = tensor1d([1, 2, 2, 1]); - const rate = 1.5; - expect(() => tf.dropout(x, rate)).toThrowError(); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/dropout_util.ts b/tfjs-master/tfjs-core/src/ops/dropout_util.ts deleted file mode 100644 index 160585e18..000000000 --- a/tfjs-master/tfjs-core/src/ops/dropout_util.ts +++ /dev/null @@ -1,49 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Tensor} from '../tensor'; -import * as util from '../util'; - -/** - * Normalize noise shape based on provided tensor and noise shape. - * - * @param x Tensor. - * @param noiseShape The shape for the randomly generated keep/drop flags, as - * an array of numbers. Optional. - * @returns Normalized noise shape. - */ -export function getNoiseShape(x: Tensor, noiseShape?: number[]): number[] { - if (noiseShape == null) { - return x.shape.slice(); - } - if (util.arraysEqual(x.shape, noiseShape)) { - return noiseShape; - } - if (x.shape.length === noiseShape.length) { - const newDimension: number[] = []; - for (let i = 0; i < x.shape.length; i++) { - if (noiseShape[i] == null && x.shape[i] != null) { - newDimension.push(x.shape[i]); - } else { - newDimension.push(noiseShape[i]); - } - } - return newDimension; - } - - return noiseShape; -} diff --git a/tfjs-master/tfjs-core/src/ops/dropout_util_test.ts b/tfjs-master/tfjs-core/src/ops/dropout_util_test.ts deleted file mode 100644 index b5c388d72..000000000 --- a/tfjs-master/tfjs-core/src/ops/dropout_util_test.ts +++ /dev/null @@ -1,56 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {getNoiseShape} from './dropout_util'; - -describeWithFlags('getNoiseShape', ALL_ENVS, () => { - it('x.shape == noiseShape', async () => { - const x = tf.ones([2, 3]); - const noiseShape = [2, 3]; - const shape = getNoiseShape(x, noiseShape); - expect(shape).toEqual([2, 3]); - }); - - it('x.shape and noiseShape have same length, different value', async () => { - const x = tf.ones([2, 3]); - const noiseShape = [2, 1]; - const shape = getNoiseShape(x, noiseShape); - expect(shape).toEqual([2, 1]); - }); - - it('noiseShape has null value', async () => { - const x = tf.ones([2, 3]); - const noiseShape = [2, null]; - const shape = getNoiseShape(x, noiseShape); - expect(shape).toEqual([2, 3]); - }); - - it('x.shape and noiseShape has different length', async () => { - const x = tf.ones([2, 3, 4]); - const noiseShape = [2, 3]; - const shape = getNoiseShape(x, noiseShape); - expect(shape).toEqual([2, 3]); - }); - - it('noiseShape is null', async () => { - const x = tf.ones([2, 3]); - const shape = getNoiseShape(x, null); - expect(shape).toEqual([2, 3]); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/einsum.ts b/tfjs-master/tfjs-core/src/ops/einsum.ts deleted file mode 100644 index 1fde865fa..000000000 --- a/tfjs-master/tfjs-core/src/ops/einsum.ts +++ /dev/null @@ -1,112 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {Einsum, EinsumAttrs} from '../kernel_names'; -import {NamedAttrMap} from '../kernel_registry'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; - -import {op} from './operation'; - -/** - * Tensor contraction over specified indices and outer product. - * - * `einsum` allows defining Tensors by defining their element-wise computation. - * This computation is based on - * [Einstein summation](https://en.wikipedia.org/wiki/Einstein_notation). - * - * Some special cases include: - * - * Matrix multiplication: - * ```js - * const x = tf.tensor2d([[1, 2, 3], [4, 5, 6]]); - * const y = tf.tensor2d([[0, 1], [2, 3], [4, 5]]); - * x.print(); - * y.print(); - * tf.einsum('ij,jk->ik', x, y).print(); - * ``` - * - * Dot product: - * ```js - * const x = tf.tensor1d([1, 2, 3]); - * const y = tf.tensor1d([0, 1, 2]); - * x.print(); - * y.print(); - * tf.einsum('i,i->', x, y).print(); - * ``` - * - * Batch dot product: - * ```js - * const x = tf.tensor2d([[1, 2, 3], [4, 5, 6]]); - * const y = tf.tensor2d([[0, 1, 2], [3, 4, 5]]); - * x.print(); - * y.print(); - * tf.einsum('bi,bi->b', x, y).print(); - * ``` - * - * Outer prouduct: - * ```js - * const x = tf.tensor1d([1, 3, 5]); - * const y = tf.tensor1d([2, 4, 6]); - * x.print(); - * y.print(); - * tf.einsum('i,j->ij', x, y).print(); - * ``` - * - * Matrix transpose: - * ```js - * const x = tf.tensor2d([[1, 2], [3, 4]]); - * x.print(); - * tf.einsum('ij->ji', x).print(); - * ``` - * - * Batch matrix transpose: - * ```js - * const x = tf.tensor3d([[[1, 2], [3, 4]], [[-1, -2], [-3, -4]]]); - * x.print(); - * tf.einsum('bij->bji', x).print(); - * ``` - * - * Limitations: - * - * This implementation of einsum has the following limitations: - * - * - Does not support >2 input tensors. - * - Does not support duplicate axes for any given input tensor. E.g., equation - * 'ii->' is not supported. - * - The `...` notation is not supported. - * - * @param equation a string describing the contraction, in the same format as - * [numpy.einsum](https://numpy.org/doc/stable/reference/generated/numpy.einsum.html). - * @param tensors the input(s) to contract (each one a Tensor), whose shapes - * should be consistent with equation. - * @returns The output tensor. - * - * @doc {heading: 'Tensors', subheading: 'Matrices'} - */ -export function einsum_(equation: string, ...tensors: Tensor[]): Tensor { - const $tensors = - tensors.map((t, i) => convertToTensor(t, `tensors${i}`, 'einsum')); - const attrs: EinsumAttrs = {equation}; - return ENGINE.runKernel( - Einsum, $tensors as unknown as NamedTensorMap, - attrs as unknown as NamedAttrMap); -} - -export const einsum = /* @__PURE__ */ op({einsum_}); diff --git a/tfjs-master/tfjs-core/src/ops/einsum_test.ts b/tfjs-master/tfjs-core/src/ops/einsum_test.ts deleted file mode 100644 index 14a701203..000000000 --- a/tfjs-master/tfjs-core/src/ops/einsum_test.ts +++ /dev/null @@ -1,265 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -import {tensor1d, tensor2d, tensor3d} from './ops'; - -describeWithFlags('einsum', ALL_ENVS, () => { - it('two scalars', async () => { - const x = tf.scalar(2); - const y = tf.scalar(3); - const out = tf.einsum(',->', x, y); - expectArraysClose(await out.data(), 6); - }); - - it('1D tensor and scalars: reduce', async () => { - const x = tensor1d([2, 3]); - const y = tf.scalar(4); - const out = tf.einsum('i,->', x, y); - expectArraysClose(await out.data(), 20); - }); - - it('1D tensor and scalars: multiply', async () => { - const x = tensor1d([2, 3]); - const y = tf.scalar(4); - const out = tf.einsum('i,->i', x, y); - expectArraysClose(await out.data(), [8, 12]); - }); - - it('1d reduce sum', async () => { - const x = tensor1d([2, 4, 6]); - const out = tf.einsum('i->', x); - expectArraysClose(await out.data(), 12); - }); - - it('2d matrix reduce sum', async () => { - const x = tensor2d([[1, 2], [3, 4]]); - const out = tf.einsum('ij->', x); - expectArraysClose(await out.data(), 10); - }); - - it('2d matrices multiply and reduce summing', async () => { - const x = tensor2d([[1, 2], [3, 4]]); - const y = tensor2d([[4, 3], [2, 1]]); - const out = tf.einsum('ij,ji->', x, y); - expectArraysClose(await out.data(), 21); - }); - - it('2d matrix times scalar and reduce summing', async () => { - const x = tensor2d([[1, 2], [3, 4]]); - const y = tf.scalar(5); - const out = tf.einsum('ij,->', x, y); - expectArraysClose(await out.data(), 50); - }); - - it('two 1d tensors dot', async () => { - const x = tensor1d([1, 3, 5]); - const y = tensor1d([2, 4, 6]); - const out = tf.einsum('i,i->', x, y); - expectArraysClose(await out.data(), 44); - }); - - it('two 1d tensors outer', async () => { - const x = tensor1d([1, 3, 5]); - const y = tensor1d([2, 4, 6]); - const out = tf.einsum('i,j->ij', x, y); - expectArraysClose(await out.data(), [[2, 4, 6], [6, 12, 18], [10, 20, 30]]); - }); - - it('2d matrix calculate trace: duplicate axes not implemented yet', () => { - const x = tensor2d([[1, 2], [3, 4]]); - expect(() => tf.einsum('ii->', x)).toThrowError(/not implemented yet/); - }); - - it('2d and 1d matrix & vector multiply', async () => { - const x = tensor2d([[1, 2, 3], [4, 5, 6]]); - const y = tensor1d([2, 4, 6]); - const out = tf.einsum('ij,j->i', x, y); - expectArraysClose(await out.data(), [28, 64]); - }); - - it('2d matrix sum along columns', async () => { - const x = tensor2d([[1, 2, 3], [4, 5, 6]]); - const out = tf.einsum('ij->j', x); - expectArraysClose(await out.data(), [5, 7, 9]); - }); - - it('2d matrix sum along rows', async () => { - const x = tensor2d([[1, 2, 3], [4, 5, 6]]); - const out = tf.einsum('ij->i', x); - expectArraysClose(await out.data(), [6, 15]); - }); - - it('2d matrix transposing', async () => { - const x = tensor2d([[1, 2, 3], [4, 5, 6]]); - const out = tf.einsum('ij->ji', x); - expectArraysClose(await out.data(), [[1, 4], [2, 5], [3, 6]]); - }); - - it('2d matrix multiply', async () => { - const x = tensor2d([[1, 2, 3], [4, 5, 6]]); - const y = tensor2d([[0, 1], [2, 3], [4, 5]]); - const out = tf.einsum('ij,jk->ik', x, y); - expectArraysClose(await out.data(), [[16, 22], [34, 49]]); - }); - - it('2d matrix multiply and transposing', async () => { - const x = tensor2d([[1, 2, 3], [4, 5, 6]]); - const y = tensor2d([[0, 1], [2, 3], [4, 5]]); - const out = tf.einsum('ij,jk->ki', x, y); - expectArraysClose(await out.data(), [[16, 34], [22, 49]]); - }); - - it('two 2d matrices batch dot', async () => { - const x = tensor2d([[1, 2, 3], [4, 5, 6]]); - const y = tensor2d([[0, 1, 2], [3, 4, 5]]); - const out = tf.einsum('bi,bi->b', x, y); - expectArraysClose(await out.data(), [8, 62]); - }); - - it('two 2d matrices batch outer', async () => { - const x = tensor2d([[1, 2, 3], [4, 5, 6]]); - const y = tensor2d([[0, 1, 2], [3, 4, 5]]); - const out = tf.einsum('bi,bj->bij', x, y); - expectArraysClose(await out.data(), [ - [[0, 1, 2], [0, 2, 4], [0, 3, 6]], - [[12, 16, 20], [15, 20, 25], [18, 24, 30]] - ]); - }); - - it('two 3d tensors batch matmul', async () => { - const x = tf.reshape(tf.range(1, 13), [2, 2, 3]); - const y = tf.reshape(tf.range(1, 19), [2, 3, 3]); - const out = tf.einsum('bij,bjk->bik', x, y); - expectArraysClose( - await out.data(), - [[[30, 36, 42], [66, 81, 96]], [[318, 342, 366], [435, 468, 501]]]); - }); - - it('two 3d tensors A', async () => { - const x = tf.reshape(tf.range(1, 9), [2, 2, 2]); - const y = tf.reshape(tf.range(1, 13), [2, 3, 2]); - const out = tf.einsum('adc,abc->abd', x, y); - expectArraysClose( - await out.data(), - [[[5, 11], [11, 25], [17, 39]], [[83, 113], [105, 143], [127, 173]]]); - }); - - it('two 3d tensors B', async () => { - const x = tf.reshape(tf.range(1, 9), [2, 2, 2]); - const y = tf.reshape(tf.range(1, 13), [2, 3, 2]); - const out = tf.einsum('adc,abc->adb', x, y); - expectArraysClose( - await out.data(), - [[[5, 11, 17], [11, 25, 39]], [[83, 105, 127], [113, 143, 173]]]); - }); - - it('one 3d tensor: batch matrix transposing', async () => { - const x = tensor3d([[[1, 2], [3, 4]], [[-1, -2], [-3, -4]]]); - const out = tf.einsum('bij->bji', x); - expectArraysClose( - await out.data(), [[[1, 3], [2, 4]], [[-1, -3], [-2, -4]]]); - }); - - it('4d tensor and 3d tensor, contracting two dimensions', async () => { - const x = tf.reshape(tf.range(1, 33), [2, 4, 2, 2]); - const y = tf.reshape(tf.range(1, 9), [2, 2, 2]); - const out = tf.einsum('abcd,cde->abe', x, y); - expectArraysClose(await out.data(), [ - [[50, 60], [114, 140], [178, 220], [242, 300]], - [[306, 380], [370, 460], [434, 540], [498, 620]] - ]); - }); - - it('two 4d tensors, contracting one dimension', async () => { - const x = tf.reshape(tf.range(1, 33), [2, 4, 2, 2]); - const y = tf.reshape(tf.range(1, 25), [2, 3, 2, 2]); - const out = tf.einsum('aecd,abcd->acbe', x, y); - expectArraysClose(await out.data(), [ - [ - [[5, 17, 29, 41], [17, 61, 105, 149], [29, 105, 181, 257]], - [[25, 53, 81, 109], [53, 113, 173, 233], [81, 173, 265, 357]] - ], - [ - [[473, 581, 689, 797], [613, 753, 893, 1033], [753, 925, 1097, 1269]], - [[605, 729, 853, 977], [761, 917, 1073, 1229], [917, 1105, 1293, 1481]] - ] - ]); - }); - - it('two 4d tensors, contracting two dimensions', async () => { - const x = tf.reshape(tf.range(1, 33), [2, 4, 2, 2]); - const y = tf.reshape(tf.range(1, 25), [2, 3, 2, 2]); - const out = tf.einsum('aecd,abcd->abe', x, y); - expectArraysClose(await out.data(), [ - [[30, 70, 110, 150], [70, 174, 278, 382], [110, 278, 446, 614]], - [ - [1078, 1310, 1542, 1774], [1374, 1670, 1966, 2262], - [1670, 2030, 2390, 2750] - ] - ]); - }); - - it('mismatched dimensions throws error', () => { - const x = tensor2d([[1, 2, 3], [4, 5, 6]]); - const y = tensor2d([[0, 1], [2, 3]]); - expect(() => tf.einsum('ij,jk->ik', x, y)) - .toThrowError(/dimension 3 at axis 0 of (the )?input shaped \[2,2\]/); - }); - - it('incorrect equation throws error', () => { - const x = tensor2d([[1, 2], [3, 4]]); - const y = tensor2d([[0, 1], [2, 3]]); - expect(() => tf.einsum('', x, y)) - .toThrowError(/Equations without an arrow|Expecting exactly one/); - expect(() => tf.einsum('ij,jk>ik', x, y)) - .toThrowError(/Equations without an arrow|Expecting exactly one/); - }); - - it('incorrect number of tensors throws error', () => { - const x = tensor2d([[1, 2], [3, 4]]); - const y = tensor2d([[0, 1], [2, 3]]); - expect(() => tf.einsum('ij->ji', x, y)) - .toThrowError(/Expected 1 inputs? (tensors, received)?(but got:)? 2/); - }); - - it('more than two input tensors throws error', async () => { - const x = tensor2d([[1, 2], [3, 4]]); - const y = tensor2d([[0, 1], [2, 3]]); - const z = tensor2d([[-1, 0], [1, 2]]); - expect(() => tf.einsum('ij,jk,kl->il', x, y, z)) - .toThrowError(/(more than 2 input tensors)|(Expecting 1 or 2 input)/); - }); - - it('nonexistent dimension throws error', async () => { - const x = tensor2d([[1, 2, 3], [4, 5, 6]]); - const y = tensor2d([[0, 1], [2, 3], [4, 5]]); - expect(() => tf.einsum('ij,jk->in', x, y)) - .toThrowError( - 'Output subscripts contain the label n not present in ' + - 'the input subscripts.'); - }); - - it('two arrows in equation throws error', async () => { - const x = tensor2d([[1, 2, 3], [4, 5, 6]]); - const y = tensor2d([[0, 1], [2, 3], [4, 5]]); - expect(() => tf.einsum('ij,jk->ik->i', x, y)).toThrowError(/exactly one/); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/elu.ts b/tfjs-master/tfjs-core/src/ops/elu.ts deleted file mode 100644 index e1820d808..000000000 --- a/tfjs-master/tfjs-core/src/ops/elu.ts +++ /dev/null @@ -1,47 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {Elu, EluInputs} from '../kernel_names'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -import {op} from './operation'; - -/** - * Computes exponential linear element-wise: `x > 0 ? x : (e ^ x) - 1`. - * - * ```js - * const x = tf.tensor1d([-1, 1, -3, 2]); - * - * x.elu().print(); // or tf.elu(x) - * ``` - * @param x The input tensor. - * - * @doc {heading: 'Operations', subheading: 'Basic math'} - */ -function elu_(x: T|TensorLike): T { - const $x = convertToTensor(x, 'x', 'elu', 'float32'); - - const inputs: EluInputs = {x: $x}; - - return ENGINE.runKernel(Elu, inputs as unknown as NamedTensorMap); -} - -export const elu = /* @__PURE__ */ op({elu_}); diff --git a/tfjs-master/tfjs-core/src/ops/elu_test.ts b/tfjs-master/tfjs-core/src/ops/elu_test.ts deleted file mode 100644 index 35ec625bf..000000000 --- a/tfjs-master/tfjs-core/src/ops/elu_test.ts +++ /dev/null @@ -1,80 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('elu', ALL_ENVS, () => { - it('calculate elu', async () => { - const a = tf.tensor1d([1, -1, 0]); - const result = tf.elu(a); - - expect(result.shape).toEqual(a.shape); - expectArraysClose(await result.data(), [1, -0.6321, 0]); - }); - - it('elu propagates NaN', async () => { - const a = tf.tensor1d([1, NaN]); - const result = tf.elu(a); - expect(result.shape).toEqual(a.shape); - expectArraysClose(await result.data(), [1, NaN]); - }); - - it('derivative', async () => { - const x = tf.tensor1d([1, 3, -2, 0.4]); - const dy = tf.tensor1d([5, 50, 500, 5000]); - const gradients = tf.grad(a => tf.elu(a))(x, dy); - - expect(gradients.shape).toEqual(x.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose( - await gradients.data(), [5, 50, 500 * Math.exp(-2), 5000]); - }); - - it('gradient with clones', async () => { - const x = tf.tensor1d([1, 3, -2, 0.4]); - const dy = tf.tensor1d([5, 50, 500, 5000]); - const gradients = tf.grad(a => tf.elu(a.clone()).clone())(x, dy); - - expect(gradients.shape).toEqual(x.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose( - await gradients.data(), [5, 50, 500 * Math.exp(-2), 5000]); - }); - - it('throws when passed a non-tensor', () => { - expect(() => tf.elu({} as tf.Tensor)) - .toThrowError(/Argument 'x' passed to 'elu' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const result = tf.elu([1, -1, 0]); - expect(result.shape).toEqual(result.shape); - expectArraysClose(await result.data(), [1, -0.6321, 0]); - }); - - it('throws for string tensor', () => { - expect(() => tf.elu('q')) - .toThrowError(/Argument 'x' passed to 'elu' must be float32/); - }); - - it('throws for int32 tensor', () => { - expect(() => tf.elu(tf.tensor1d([1, 2, 3], 'int32'))) - .toThrowError(/Argument 'x' passed to 'elu' must be float32/); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/ensure_shape.ts b/tfjs-master/tfjs-core/src/ops/ensure_shape.ts deleted file mode 100644 index 0e3f3bd65..000000000 --- a/tfjs-master/tfjs-core/src/ops/ensure_shape.ts +++ /dev/null @@ -1,59 +0,0 @@ -/** - * @license - * Copyright 2023 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Tensor} from '../tensor'; -import {convertToTensor} from '../tensor_util_env'; -import {Rank, ShapeMap} from '../types'; -import {arraysEqualWithNull} from '../util_base'; - -import {op} from './operation'; - -/** - * Checks the input tensor mathes the given shape. - * - * Given an input tensor, returns a new tensor with the same values as the - * input tensor with shape `shape`. - * - * The method supports the null value in tensor. It will still check the shapes, - * and null is a placeholder. - * - * - * ```js - * const x = tf.tensor1d([1, 2, 3, 4]); - * const y = tf.tensor1d([1, null, 3, 4]); - * const z = tf.tensor2d([1, 2, 3, 4], [2,2]); - * tf.ensureShape(x, [4]).print(); - * tf.ensureShape(y, [4]).print(); - * tf.ensureShape(z, [null, 2]).print(); - * ``` - * - * @param x The input tensor to be ensured. - * @param shape A TensorShape representing the shape of this tensor, an array - * or null. - * - * @doc {heading: 'Tensors', subheading: 'Transformations'} - */ -function ensureShape_(x: Tensor, shape: ShapeMap[R]): Tensor { - const $x = convertToTensor(x, 'x', 'ensureShape', 'string_or_numeric'); - if (!arraysEqualWithNull($x.shape, shape)) { - throw new Error(`EnsureShape: Shape of tensor ${ - $x.shape} is not compatible with expected shape ${shape}`); - } - - return x; -} -export const ensureShape = /* @__PURE__ */ op({ensureShape_}); diff --git a/tfjs-master/tfjs-core/src/ops/ensure_shape_test.ts b/tfjs-master/tfjs-core/src/ops/ensure_shape_test.ts deleted file mode 100644 index 4a6146345..000000000 --- a/tfjs-master/tfjs-core/src/ops/ensure_shape_test.ts +++ /dev/null @@ -1,42 +0,0 @@ -/** - * @license - * Copyright 2023 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {ensureShape} from './ensure_shape'; - -describeWithFlags('ensureShape', ALL_ENVS, () => { - it('basic', () => { - const x = tf.ones([2, 3]); - expect(ensureShape(x, [2, 3])).toEqual(x); - }); - - it('different shape', () => { - const x = tf.ones([2, 3]); - expect(() => ensureShape(x, [5, 3])).toThrowError(/EnsureShape:/); - }); - - it('different length', () => { - const x = tf.tensor1d([1, 2, 3, 4]); - expect(() => ensureShape(x, [1, 3])).toThrowError(/EnsureShape:/); - }); - - it('null shape', () => { - const x = tf.tensor2d([1, null, 3, 4], [2, 2]); - expect(ensureShape(x, [2, 2])).toEqual(x); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/equal.ts b/tfjs-master/tfjs-core/src/ops/equal.ts deleted file mode 100644 index 210e4fc61..000000000 --- a/tfjs-master/tfjs-core/src/ops/equal.ts +++ /dev/null @@ -1,56 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {ENGINE} from '../engine'; -import {Equal, EqualInputs} from '../kernel_names'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {makeTypesMatch} from '../tensor_util'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -import {assertAndGetBroadcastShape} from './broadcast_util'; -import {op} from './operation'; - -/** - * Returns the truth value of (a == b) element-wise. Supports broadcasting. - * - * ```js - * const a = tf.tensor1d([1, 2, 3]); - * const b = tf.tensor1d([2, 2, 2]); - * - * a.equal(b).print(); - * ``` - * - * @param a The first input tensor. - * @param b The second input tensor. Must have the same dtype as `a`. - * - * @doc {heading: 'Operations', subheading: 'Logical'} - */ -function equal_( - a: Tensor|TensorLike, b: Tensor|TensorLike): T { - let $a = convertToTensor(a, 'a', 'equal', 'string_or_numeric'); - let $b = convertToTensor(b, 'b', 'equal', 'string_or_numeric'); - [$a, $b] = makeTypesMatch($a, $b); - - assertAndGetBroadcastShape($a.shape, $b.shape); - - const inputs: EqualInputs = {a: $a, b: $b}; - - return ENGINE.runKernel(Equal, inputs as unknown as NamedTensorMap); -} - -export const equal = /* @__PURE__ */ op({equal_}); diff --git a/tfjs-master/tfjs-core/src/ops/equal_test.ts b/tfjs-master/tfjs-core/src/ops/equal_test.ts deleted file mode 100644 index 35b18d982..000000000 --- a/tfjs-master/tfjs-core/src/ops/equal_test.ts +++ /dev/null @@ -1,294 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose, expectArraysEqual} from '../test_util'; - -describeWithFlags('equal', ALL_ENVS, () => { - it('Tensor1D - int32', async () => { - let a = tf.tensor1d([1, 4, 5], 'int32'); - let b = tf.tensor1d([2, 3, 5], 'int32'); - - expectArraysClose(await tf.equal(a, b).data(), [0, 0, 1]); - - a = tf.tensor1d([2, 2, 2], 'int32'); - b = tf.tensor1d([2, 2, 2], 'int32'); - expectArraysClose(await tf.equal(a, b).data(), [1, 1, 1]); - - a = tf.tensor1d([0, 0], 'int32'); - b = tf.tensor1d([3, 3], 'int32'); - expectArraysClose(await tf.equal(a, b).data(), [0, 0]); - }); - it('Tensor1D - float32', async () => { - let a = tf.tensor1d([1.1, 4.1, 5.1], 'float32'); - let b = tf.tensor1d([2.2, 3.2, 5.1], 'float32'); - - expectArraysClose(await tf.equal(a, b).data(), [0, 0, 1]); - - a = tf.tensor1d([2.31, 2.31, 2.31], 'float32'); - b = tf.tensor1d([2.31, 2.31, 2.31], 'float32'); - expectArraysClose(await tf.equal(a, b).data(), [1, 1, 1]); - - a = tf.tensor1d([0.45, 0.123], 'float32'); - b = tf.tensor1d([3.123, 3.321], 'float32'); - expectArraysClose(await tf.equal(a, b).data(), [0, 0]); - }); - - it('upcasts when dtypes dont match', async () => { - const a = [1.1, 4.1, 5]; - const b = [2.2, 3.2, 5]; - - let res = - tf.equal(tf.tensor(a, [3], 'float32'), tf.tensor(b, [3], 'int32')); - expect(res.dtype).toBe('bool'); - expect(res.shape).toEqual([3]); - expectArraysClose(await res.data(), [0, 0, 1]); - - res = tf.equal(tf.tensor(a, [3], 'int32'), tf.tensor(b, [3], 'bool')); - expect(res.dtype).toBe('bool'); - expect(res.shape).toEqual([3]); - expectArraysClose(await res.data(), [1, 0, 0]); - }); - - it('TensorLike', async () => { - const a = [1.1, 4.1, 5.1]; - const b = [2.2, 3.2, 5.1]; - - expectArraysClose(await tf.equal(a, b).data(), [0, 0, 1]); - }); - it('TensorLike chained', async () => { - const a = tf.tensor1d([1.1, 4.1, 5.1], 'float32'); - const b = [2.2, 3.2, 5.1]; - - expectArraysClose(await a.equal(b).data(), [0, 0, 1]); - }); - - it('mismatched Tensor1D shapes - int32', () => { - const a = tf.tensor1d([1, 2], 'int32'); - const b = tf.tensor1d([1, 2, 3], 'int32'); - const f = () => { - tf.equal(a, b); - }; - expect(f).toThrowError(); - }); - it('mismatched Tensor1D shapes - float32', () => { - const a = tf.tensor1d([1.1, 2.1], 'float32'); - const b = tf.tensor1d([1.1, 2.1, 3.1], 'float32'); - const f = () => { - tf.equal(a, b); - }; - expect(f).toThrowError(); - }); - it('NaNs in Tensor1D - float32', async () => { - const a = tf.tensor1d([1.1, NaN, 2.1], 'float32'); - const b = tf.tensor1d([2.1, 3.1, NaN], 'float32'); - expectArraysClose(await tf.equal(a, b).data(), [0, 0, 0]); - }); - it('scalar and 1D broadcast', async () => { - const a = tf.scalar(2); - const b = tf.tensor1d([1, 2, 3, 4, 5, 2]); - const res = tf.equal(a, b); - expect(res.dtype).toBe('bool'); - expect(res.shape).toEqual([6]); - expectArraysEqual(await res.data(), [0, 1, 0, 0, 0, 1]); - }); - - // Tensor2D: - it('Tensor2D - int32', async () => { - let a = tf.tensor2d([[1, 4, 5], [8, 9, 12]], [2, 3], 'int32'); - let b = tf.tensor2d([[2, 3, 6], [7, 10, 11]], [2, 3], 'int32'); - expectArraysClose(await tf.equal(a, b).data(), [0, 0, 0, 0, 0, 0]); - - a = tf.tensor2d([[0, 0], [1, 1]], [2, 2], 'int32'); - b = tf.tensor2d([[0, 0], [1, 1]], [2, 2], 'int32'); - expectArraysClose(await tf.equal(a, b).data(), [1, 1, 1, 1]); - }); - it('Tensor2D - float32', async () => { - let a = tf.tensor2d([[1.1, 4.1, 5.1], [8.1, 9.1, 12.1]], [2, 3], 'float32'); - let b = - tf.tensor2d([[2.1, 4.1, 5.1], [7.1, 10.1, 11.1]], [2, 3], 'float32'); - expectArraysClose(await tf.equal(a, b).data(), [0, 1, 1, 0, 0, 0]); - - a = tf.tensor2d([[0.2, 0.2], [1.2, 1.2]], [2, 2], 'float32'); - b = tf.tensor2d([[0.2, 0.2], [1.2, 1.2]], [2, 2], 'float32'); - expectArraysClose(await tf.equal(a, b).data(), [1, 1, 1, 1]); - }); - it('broadcasting Tensor2D shapes - int32', async () => { - const a = tf.tensor2d([[3], [7]], [2, 1], 'int32'); - const b = tf.tensor2d([[2, 3, 4], [7, 8, 9]], [2, 3], 'int32'); - expectArraysClose(await tf.equal(a, b).data(), [0, 1, 0, 1, 0, 0]); - }); - it('broadcasting Tensor2D shapes - float32', async () => { - const a = tf.tensor2d([[1.1], [7.1]], [2, 1], 'float32'); - const b = - tf.tensor2d([[0.1, 1.1, 2.1], [7.1, 8.1, 9.1]], [2, 3], 'float32'); - expectArraysClose(await tf.equal(a, b).data(), [0, 1, 0, 1, 0, 0]); - }); - it('NaNs in Tensor2D - float32', async () => { - const a = tf.tensor2d([[1.1, NaN], [1.1, NaN]], [2, 2], 'float32'); - const b = tf.tensor2d([[0.1, NaN], [1.1, NaN]], [2, 2], 'float32'); - expectArraysClose(await tf.equal(a, b).data(), [0, 0, 1, 0]); - }); - it('broadcasting Tensor2D shapes each with 1 dim', async () => { - const a = tf.tensor2d([1, 2, 5], [1, 3]); - const b = tf.tensor2d([5, 1], [2, 1]); - const res = tf.equal(a, b); - expect(res.dtype).toBe('bool'); - expect(res.shape).toEqual([2, 3]); - expectArraysEqual(await res.data(), [0, 0, 1, 1, 0, 0]); - }); - it('2D and scalar broadcast', async () => { - const a = tf.tensor2d([1, 2, 3, 2, 5, 6], [2, 3]); - const b = tf.scalar(2); - const res = tf.equal(a, b); - expect(res.dtype).toBe('bool'); - expect(res.shape).toEqual([2, 3]); - expectArraysEqual(await res.data(), [0, 1, 0, 1, 0, 0]); - }); - - // Tensor3D: - it('Tensor3D - int32', async () => { - let a = - tf.tensor3d([[[1], [4], [5]], [[8], [9], [12]]], [2, 3, 1], 'int32'); - let b = - tf.tensor3d([[[2], [3], [6]], [[7], [10], [12]]], [2, 3, 1], 'int32'); - expectArraysClose(await tf.equal(a, b).data(), [0, 0, 0, 0, 0, 1]); - - a = tf.tensor3d([[[0], [0], [0]], [[1], [1], [1]]], [2, 3, 1], 'int32'); - b = tf.tensor3d([[[0], [0], [0]], [[1], [1], [1]]], [2, 3, 1], 'int32'); - expectArraysClose(await tf.equal(a, b).data(), [1, 1, 1, 1, 1, 1]); - }); - it('Tensor3D - float32', async () => { - let a = tf.tensor3d( - [[[1.1], [4.1], [5.1]], [[8.1], [9.1], [12.1]]], [2, 3, 1], 'float32'); - let b = tf.tensor3d( - [[[2.1], [3.1], [6.1]], [[7.1], [10.1], [12.1]]], [2, 3, 1], 'float32'); - expectArraysClose(await tf.equal(a, b).data(), [0, 0, 0, 0, 0, 1]); - - a = tf.tensor3d( - [[[0.1], [0.1], [0.1]], [[1.1], [1.1], [1.1]]], [2, 3, 1], 'float32'); - b = tf.tensor3d( - [[[0.1], [0.1], [0.1]], [[1.1], [1.1], [1.1]]], [2, 3, 1], 'float32'); - expectArraysClose(await tf.equal(a, b).data(), [1, 1, 1, 1, 1, 1]); - }); - it('broadcasting Tensor3D shapes - int32', async () => { - const a = tf.tensor3d( - [[[1, 0], [2, 3], [4, 5]], [[6, 7], [9, 8], [10, 11]]], [2, 3, 2], - 'int32'); - const b = - tf.tensor3d([[[1], [2], [3]], [[7], [10], [9]]], [2, 3, 1], 'int32'); - expectArraysClose( - await tf.equal(a, b).data(), [1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0]); - }); - it('broadcasting Tensor3D shapes - float32', async () => { - const a = tf.tensor3d( - [ - [[1.1, 0.1], [2.1, 3.1], [4.1, 5.1]], - [[6.1, 7.1], [9.1, 8.1], [10.1, 11.1]] - ], - [2, 3, 2], 'float32'); - const b = tf.tensor3d( - [[[1.1], [2.1], [3.1]], [[7.1], [10.1], [9.1]]], [2, 3, 1], 'float32'); - expectArraysClose( - await tf.equal(a, b).data(), [1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0]); - }); - it('NaNs in Tensor3D - float32', async () => { - const a = tf.tensor3d( - [[[1.1], [NaN], [1.1]], [[0.1], [0.1], [0.1]]], [2, 3, 1], 'float32'); - const b = tf.tensor3d( - [[[0.1], [0.1], [1.1]], [[1.1], [0.1], [NaN]]], [2, 3, 1], 'float32'); - expectArraysClose(await tf.equal(a, b).data(), [0, 0, 1, 0, 1, 0]); - }); - it('3D and scalar', async () => { - const a = tf.tensor3d([1, 2, 3, 4, 5, -1], [2, 3, 1]); - const b = tf.scalar(-1); - const res = tf.equal(a, b); - expect(res.dtype).toBe('bool'); - expect(res.shape).toEqual([2, 3, 1]); - expectArraysEqual(await res.data(), [0, 0, 0, 0, 0, 1]); - }); - - // Tensor4D: - it('Tensor4D - int32', async () => { - let a = tf.tensor4d([1, 4, 5, 8], [2, 2, 1, 1], 'int32'); - let b = tf.tensor4d([2, 3, 6, 8], [2, 2, 1, 1], 'int32'); - expectArraysClose(await tf.equal(a, b).data(), [0, 0, 0, 1]); - - a = tf.tensor4d([0, 1, 2, 3], [2, 2, 1, 1], 'int32'); - b = tf.tensor4d([0, 1, 2, 3], [2, 2, 1, 1], 'int32'); - expectArraysClose(await tf.equal(a, b).data(), [1, 1, 1, 1]); - - a = tf.tensor4d([1, 1, 1, 1], [2, 2, 1, 1], 'int32'); - b = tf.tensor4d([2, 2, 2, 2], [2, 2, 1, 1], 'int32'); - expectArraysClose(await tf.equal(a, b).data(), [0, 0, 0, 0]); - }); - it('Tensor4D - float32', async () => { - let a = tf.tensor4d([1.1, 4.1, 5.1, 8.1], [2, 2, 1, 1], 'float32'); - let b = tf.tensor4d([2.1, 3.1, 6.1, 8.1], [2, 2, 1, 1], 'float32'); - expectArraysClose(await tf.equal(a, b).data(), [0, 0, 0, 1]); - - a = tf.tensor4d([0.1, 1.1, 2.2, 3.3], [2, 2, 1, 1], 'float32'); - b = tf.tensor4d([0.1, 1.1, 2.2, 3.3], [2, 2, 1, 1], 'float32'); - expectArraysClose(await tf.equal(a, b).data(), [1, 1, 1, 1]); - - a = tf.tensor4d([0.1, 0.1, 0.1, 0.1], [2, 2, 1, 1], 'float32'); - b = tf.tensor4d([1.1, 1.1, 1.1, 1.1], [2, 2, 1, 1], 'float32'); - expectArraysClose(await tf.equal(a, b).data(), [0, 0, 0, 0]); - }); - it('broadcasting Tensor4D shapes - int32', async () => { - const a = tf.tensor4d([1, 2, 5, 9], [2, 2, 1, 1], 'int32'); - const b = tf.tensor4d( - [[[[1, 2]], [[3, 4]]], [[[5, 6]], [[7, 8]]]], [2, 2, 1, 2], 'int32'); - expectArraysClose(await tf.equal(a, b).data(), [1, 0, 0, 0, 1, 0, 0, 0]); - }); - it('broadcasting Tensor4D shapes - float32', async () => { - const a = tf.tensor4d([1.1, 2.1, 5.1, 9.1], [2, 2, 1, 1], 'float32'); - const b = tf.tensor4d( - [[[[1.1, 2.1]], [[3.1, 4.1]]], [[[5.1, 6.1]], [[7.1, 8.1]]]], - [2, 2, 1, 2], 'float32'); - expectArraysClose(await tf.equal(a, b).data(), [1, 0, 0, 0, 1, 0, 0, 0]); - }); - it('NaNs in Tensor4D - float32', async () => { - const a = tf.tensor4d([1.1, NaN, 1.1, 0.1], [2, 2, 1, 1], 'float32'); - const b = tf.tensor4d([0.1, 1.1, 1.1, NaN], [2, 2, 1, 1], 'float32'); - expectArraysClose(await tf.equal(a, b).data(), [0, 0, 1, 0]); - }); - - it('throws when passed a as a non-tensor', () => { - expect(() => tf.equal({} as tf.Tensor, tf.scalar(1))) - .toThrowError(/Argument 'a' passed to 'equal' must be a Tensor/); - }); - it('throws when passed b as a non-tensor', () => { - expect(() => tf.equal(tf.scalar(1), {} as tf.Tensor)) - .toThrowError(/Argument 'b' passed to 'equal' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const a = [1, 4, 5]; - const b = [2, 3, 5]; - expectArraysClose(await tf.equal(a, b).data(), [0, 0, 1]); - }); - - it('should support string comparison', async () => { - const tensorA = tf.tensor('aa', [], 'string'); - const tensorB = tf.tensor(['aa', 'ab', 'aaa'], [3], 'string'); - const result = await tf.equal(tensorA, tensorB); - - expectArraysEqual(result.shape, [3]); - expectArraysEqual(await result.data(), [1, 0, 0]); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/erf.ts b/tfjs-master/tfjs-core/src/ops/erf.ts deleted file mode 100644 index 2e949bd7e..000000000 --- a/tfjs-master/tfjs-core/src/ops/erf.ts +++ /dev/null @@ -1,55 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {Erf, ErfInputs} from '../kernel_names'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; -import * as util from '../util'; - -import {cast} from './cast'; -import {op} from './operation'; - -/** - * Computes Gauss error function of the input `tf.Tensor` element-wise: - * `erf(x)` - * - * ```js - * const x = tf.tensor1d([0, .1, -.1, .7]); - * - * x.erf().print(); // or tf.erf(x); - * ``` - * @param x The input tensor. - * - * @doc {heading: 'Operations', subheading: 'Basic math'} - */ -function erf_(x: T|TensorLike): T { - let $x = convertToTensor(x, 'x', 'erf'); - util.assert( - $x.dtype === 'int32' || $x.dtype === 'float32', - () => 'Input dtype must be `int32` or `float32`.'); - - if ($x.dtype === 'int32') { - $x = cast($x, 'float32'); - } - - const inputs: ErfInputs = {x: $x}; - return ENGINE.runKernel(Erf, inputs as unknown as NamedTensorMap); -} -export const erf = /* @__PURE__ */ op({erf_}); diff --git a/tfjs-master/tfjs-core/src/ops/erf_test.ts b/tfjs-master/tfjs-core/src/ops/erf_test.ts deleted file mode 100644 index 0dd9b0374..000000000 --- a/tfjs-master/tfjs-core/src/ops/erf_test.ts +++ /dev/null @@ -1,135 +0,0 @@ -/** - * @license - * Copyright 2020 Google Inc. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('erf', ALL_ENVS, () => { - it('basic', async () => { - const values = [-0.25, 0.25, 0.5, .75, -0.4]; - const a = tf.tensor1d(values); - const result = tf.erf(a); - const expected = [-0.2763264, 0.2763264, 0.5204999, 0.7111556, -0.4283924]; - expectArraysClose(await result.data(), expected); - }); - - it('blowup', async () => { - const values = [-1.4, -2.5, -3.1, -4.4]; - const a = tf.tensor1d(values); - const result = tf.erf(a); - const expected = [-0.9522852, -0.999593, -0.9999883, -1]; - expectArraysClose(await result.data(), expected); - }); - - it('scalar', async () => { - const a = tf.scalar(1); - const result = tf.erf(a); - const expected = [0.8427008]; - expectArraysClose(await result.data(), expected); - }); - - it('scalar in int32', async () => { - const a = tf.scalar(1, 'int32'); - const result = tf.erf(a); - const expected = [0.8427008]; - expectArraysClose(await result.data(), expected); - }); - - it('tensor2d', async () => { - const values = [0.2, 0.3, 0.4, 0.5]; - const a = tf.tensor2d(values, [2, 2]); - const result = tf.erf(a); - const expected = [0.2227026, 0.32862678, 0.42839235, 0.5204999]; - expectArraysClose(await result.data(), expected); - }); - - it('propagates NaNs', async () => { - const a = tf.tensor1d([0.5, NaN, 0]); - const res = tf.erf(a); - expectArraysClose(await res.data(), [0.5204999, NaN, 0.0]); - }); - - it('gradients: Scalar', async () => { - const a = tf.scalar(0.5); - const dy = tf.scalar(8); - const gradients = tf.grad(a => tf.erf(a))(a, dy); - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose( - await gradients.data(), - [8 * 2 * Math.exp(-0.5 * 0.5) / Math.sqrt(Math.PI)]); - }); - - it('gradient with clones', async () => { - const a = tf.scalar(0.5); - const dy = tf.scalar(8); - const gradients = tf.grad(a => tf.erf(a.clone()).clone())(a, dy); - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose( - await gradients.data(), - [8 * 2 * Math.exp(-0.5 * 0.5) / Math.sqrt(Math.PI)]); - }); - - it('gradients: Tensor1D', async () => { - const aValues = [-0.1, 0.2, 0.3, -0.5]; - const dyValues = [1, 2, 3, 4]; - const a = tf.tensor1d(aValues); - const dy = tf.tensor1d(dyValues); - const gradients = tf.grad(a => tf.erf(a))(a, dy); - const expected = []; - for (let i = 0; i < a.size; i++) { - expected[i] = dyValues[i] * 2 * Math.exp(-aValues[i] * aValues[i]) / - Math.sqrt(Math.PI); - } - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), expected); - }); - - it('gradients: Tensor2D', async () => { - const aValues = [-0.3, 0.1, 0.2, 0.3]; - const dyValues = [1, 2, 3, 4]; - const a = tf.tensor2d(aValues, [2, 2]); - const dy = tf.tensor2d(dyValues, [2, 2]); - const gradients = tf.grad(a => tf.erf(a))(a, dy); - const expected = []; - for (let i = 0; i < a.size; i++) { - expected[i] = dyValues[i] * 2 * Math.exp(-aValues[i] * aValues[i]) / - Math.sqrt(Math.PI); - } - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), expected); - }); - - it('throws when passed a non-tensor', () => { - expect(() => tf.erf({} as tf.Tensor)) - .toThrowError(/Argument 'x' passed to 'erf' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const result = tf.erf(1); - expectArraysClose(await result.data(), [0.8427008]); - }); - - it('throws for string tensor', () => { - expect(() => tf.erf('q')) - .toThrowError(/Argument 'x' passed to 'erf' must be numeric/); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/erf_util.ts b/tfjs-master/tfjs-core/src/ops/erf_util.ts deleted file mode 100644 index a974c457f..000000000 --- a/tfjs-master/tfjs-core/src/ops/erf_util.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -export const ERF_P = 0.3275911; -export const ERF_A1 = 0.254829592; -export const ERF_A2 = -0.284496736; -export const ERF_A3 = 1.421413741; -export const ERF_A4 = -1.453152027; -export const ERF_A5 = 1.061405429; diff --git a/tfjs-master/tfjs-core/src/ops/euclidean_norm.ts b/tfjs-master/tfjs-core/src/ops/euclidean_norm.ts deleted file mode 100644 index cd8bbb473..000000000 --- a/tfjs-master/tfjs-core/src/ops/euclidean_norm.ts +++ /dev/null @@ -1,53 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Tensor} from '../tensor'; -import {TensorLike} from '../types'; - -import {norm} from './norm'; -import {op} from './operation'; - -/** - * Computes the Euclidean norm of scalar, vectors, and matrices. - * - * ```js - * const x = tf.tensor1d([1, 2, 3, 4]); - * - * x.euclideanNorm().print(); // or tf.euclideanNorm(x) - * ``` - * - * @param x The input array. - * @param axis Optional. If axis is null (the default), the input is - * considered a vector and a single vector norm is computed over the entire - * set of values in the Tensor, i.e. euclideanNorm(x) is equivalent - * to euclideanNorm(x.reshape([-1])). If axis is an integer, the input - * is considered a batch of vectors, and axis determines the axis in x - * over which to compute vector norms. If axis is a 2-tuple of integer it is - * considered a batch of matrices and axis determines the axes in NDArray - * over which to compute a matrix norm. - * @param keepDims Optional. If true, the norm has the same dimensionality - * as the input. - * - * @doc {heading: 'Operations', subheading: 'Matrices'} - */ -function euclideanNorm_( - x: Tensor|TensorLike, axis: number|number[] = null, - keepDims = false): Tensor { - return norm(x, 'euclidean', axis, keepDims); -} - -export const euclideanNorm = /* @__PURE__ */ op({euclideanNorm_}); diff --git a/tfjs-master/tfjs-core/src/ops/euclidean_norm_test.ts b/tfjs-master/tfjs-core/src/ops/euclidean_norm_test.ts deleted file mode 100644 index f8cf83f94..000000000 --- a/tfjs-master/tfjs-core/src/ops/euclidean_norm_test.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -// Because euclidean is the default norm option, the norm_test covers -// the tests for euclideanNorm. Here we basically just test the API -// can be called correctly. -describeWithFlags('euclideanNorm', ALL_ENVS, () => { - it('vector euclidean norm', async () => { - const a = tf.tensor1d([1, -2, 3, -4]); - const result = tf.euclideanNorm(a); - - expect(result.dtype).toBe('float32'); - expectArraysClose(await result.data(), 5.4772); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/exp.ts b/tfjs-master/tfjs-core/src/ops/exp.ts deleted file mode 100644 index fe06482d0..000000000 --- a/tfjs-master/tfjs-core/src/ops/exp.ts +++ /dev/null @@ -1,45 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {Exp, ExpInputs} from '../kernel_names'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -import {op} from './operation'; - -/** - * Computes exponential of the input `tf.Tensor` element-wise. `e ^ x` - * - * ```js - * const x = tf.tensor1d([1, 2, -3]); - * - * x.exp().print(); // or tf.exp(x) - * ``` - * @param x The input tensor. - * - * @doc {heading: 'Operations', subheading: 'Basic math'} - */ -function exp_(x: T|TensorLike): T { - const $x = convertToTensor(x, 'x', 'exp'); - - const inputs: ExpInputs = {x: $x}; - return ENGINE.runKernel(Exp, inputs as unknown as NamedTensorMap); -} -export const exp = /* @__PURE__ */ op({exp_}); diff --git a/tfjs-master/tfjs-core/src/ops/exp_test.ts b/tfjs-master/tfjs-core/src/ops/exp_test.ts deleted file mode 100644 index a29e0dea4..000000000 --- a/tfjs-master/tfjs-core/src/ops/exp_test.ts +++ /dev/null @@ -1,112 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; -import {backend} from '../index'; - -describeWithFlags('exp', ALL_ENVS, () => { - it('exp', async () => { - const a = tf.tensor1d([1, 2, 0]); - const r = tf.exp(a); - - expectArraysClose(await r.data(), [Math.exp(1), Math.exp(2), 1]); - }); - - it('int32', async () => { - if (backend() && backend().floatPrecision() === 32) { - // TODO: Use skip() instead when it is implemented - const a = tf.tensor1d([10], 'int32'); - const r = tf.exp(a); - - expect(r.dtype).toEqual('float32'); - expectArraysClose(await r.data(), [Math.exp(10)]); - } - }); - - it('exp propagates NaNs', async () => { - const a = tf.tensor1d([1, NaN, 0]); - const r = tf.exp(a); - expectArraysClose(await r.data(), [Math.exp(1), NaN, 1]); - }); - - it('gradients: Scalar', async () => { - const a = tf.scalar(0.5); - const dy = tf.scalar(3); - - const gradients = tf.grad(a => tf.exp(a))(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), [3 * Math.exp(0.5)]); - }); - - it('gradient with clones', async () => { - const a = tf.scalar(0.5); - const dy = tf.scalar(3); - - const gradients = tf.grad(a => tf.exp(a.clone()).clone())(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), [3 * Math.exp(0.5)]); - }); - - it('gradients: Tensor1D', async () => { - const a = tf.tensor1d([-1, 2, 3, -5]); - const dy = tf.tensor1d([1, 2, 3, 4]); - - const gradients = tf.grad(a => tf.exp(a))(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose( - await gradients.data(), - [1 * Math.exp(-1), 2 * Math.exp(2), 3 * Math.exp(3), 4 * Math.exp(-5)], - 1e-1); - }); - - it('gradients: Tensor2D', async () => { - const a = tf.tensor2d([-3, 1, 2, 3], [2, 2]); - const dy = tf.tensor2d([1, 2, 3, 4], [2, 2]); - - const gradients = tf.grad(a => tf.exp(a))(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose( - await gradients.data(), - [1 * Math.exp(-3), 2 * Math.exp(1), 3 * Math.exp(2), 4 * Math.exp(3)], - 1e-1); - }); - - it('throws when passed a non-tensor', () => { - expect(() => tf.exp({} as tf.Tensor)) - .toThrowError(/Argument 'x' passed to 'exp' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const r = tf.exp([1, 2, 0]); - expectArraysClose(await r.data(), [Math.exp(1), Math.exp(2), 1]); - }); - - it('throws for string tensor', () => { - expect(() => tf.exp('q')) - .toThrowError(/Argument 'x' passed to 'exp' must be numeric/); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/expand_dims.ts b/tfjs-master/tfjs-core/src/ops/expand_dims.ts deleted file mode 100644 index 583bde048..000000000 --- a/tfjs-master/tfjs-core/src/ops/expand_dims.ts +++ /dev/null @@ -1,58 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {ExpandDims, ExpandDimsAttrs, ExpandDimsInputs} from '../kernel_names'; -import {NamedAttrMap} from '../kernel_registry'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; -import * as util from '../util'; - -import {op} from './operation'; - -/** - * Returns a `tf.Tensor` that has expanded rank, by inserting a dimension - * into the tensor's shape. - * - * ```js - * const x = tf.tensor1d([1, 2, 3, 4]); - * const axis = 1; - * x.expandDims(axis).print(); - * ``` - * - * @param x The input tensor whose dimensions are to be expanded. - * @param axis The dimension index at which to insert shape of `1`. Defaults - * to 0 (the first dimension). - * - * @doc {heading: 'Tensors', subheading: 'Transformations'} - */ -function expandDims_(x: Tensor|TensorLike, axis = 0): T { - const $x = convertToTensor(x, 'x', 'expandDims', 'string_or_numeric'); - - util.assert(axis <= $x.rank, () => 'Axis must be <= rank of the tensor'); - - const inputs: ExpandDimsInputs = {input: $x}; - const attrs: ExpandDimsAttrs = {dim: axis}; - - return ENGINE.runKernel( - ExpandDims, inputs as unknown as NamedTensorMap, - attrs as unknown as NamedAttrMap); -} - -export const expandDims = /* @__PURE__ */ op({expandDims_}); diff --git a/tfjs-master/tfjs-core/src/ops/expand_dims_test.ts b/tfjs-master/tfjs-core/src/ops/expand_dims_test.ts deleted file mode 100644 index 387f083b2..000000000 --- a/tfjs-master/tfjs-core/src/ops/expand_dims_test.ts +++ /dev/null @@ -1,168 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('expandDims', ALL_ENVS, () => { - it('scalar, default axis is 0', async () => { - const res = tf.scalar(1).expandDims(); - expect(res.shape).toEqual([1]); - expectArraysClose(await res.data(), [1]); - }); - - it('scalar, axis is out of bounds throws error', () => { - const f = () => tf.scalar(1).expandDims(1); - expect(f).toThrowError(); - }); - - it('1d, axis=-3', () => { - expect(() => { - tf.tensor1d([1, 2, 3]).expandDims(-3); - }).toThrowError(); - }); - - it('1d, axis=-2', async () => { - const res = tf.tensor1d([1, 2, 3]).expandDims(-2 /* axis */); - expect(res.shape).toEqual([1, 3]); - expectArraysClose(await res.data(), [1, 2, 3]); - }); - - it('1d, axis=-1', async () => { - const res = tf.tensor1d([1, 2, 3]).expandDims(-1 /* axis */); - expect(res.shape).toEqual([3, 1]); - expectArraysClose(await res.data(), [1, 2, 3]); - }); - - it('1d, axis=0', async () => { - const res = tf.tensor1d([1, 2, 3]).expandDims(0 /* axis */); - expect(res.shape).toEqual([1, 3]); - expectArraysClose(await res.data(), [1, 2, 3]); - }); - - it('1d, axis=1', async () => { - const res = tf.tensor1d([1, 2, 3]).expandDims(1 /* axis */); - expect(res.shape).toEqual([3, 1]); - expectArraysClose(await res.data(), [1, 2, 3]); - }); - - it('2d, axis=-4', () => { - expect(() => { - tf.tensor2d([[1, 2], [3, 4], [5, 6]]).expandDims(-4 /* axis */); - }).toThrowError(); - }); - - it('2d, axis=-3', async () => { - const res = tf.tensor2d([[1, 2], [3, 4], [5, 6]]).expandDims(-3 /* axis */); - expect(res.shape).toEqual([1, 3, 2]); - expectArraysClose(await res.data(), [1, 2, 3, 4, 5, 6]); - }); - - it('2d, axis=-2', async () => { - const res = tf.tensor2d([[1, 2], [3, 4], [5, 6]]).expandDims(-2 /* axis */); - expect(res.shape).toEqual([3, 1, 2]); - expectArraysClose(await res.data(), [1, 2, 3, 4, 5, 6]); - }); - - it('2d, axis=-1', async () => { - const res = tf.tensor2d([[1, 2], [3, 4], [5, 6]]).expandDims(-1 /* axis */); - expect(res.shape).toEqual([3, 2, 1]); - expectArraysClose(await res.data(), [1, 2, 3, 4, 5, 6]); - }); - - it('2d, axis=0', async () => { - const res = tf.tensor2d([[1, 2], [3, 4], [5, 6]]).expandDims(0 /* axis */); - expect(res.shape).toEqual([1, 3, 2]); - expectArraysClose(await res.data(), [1, 2, 3, 4, 5, 6]); - }); - - it('2d, axis=1', async () => { - const res = tf.tensor2d([[1, 2], [3, 4], [5, 6]]).expandDims(1 /* axis */); - expect(res.shape).toEqual([3, 1, 2]); - expectArraysClose(await res.data(), [1, 2, 3, 4, 5, 6]); - }); - - it('2d, axis=2', async () => { - const res = tf.tensor2d([[1, 2], [3, 4], [5, 6]]).expandDims(2 /* axis */); - expect(res.shape).toEqual([3, 2, 1]); - expectArraysClose(await res.data(), [1, 2, 3, 4, 5, 6]); - }); - - it('4d, axis=0', async () => { - const res = tf.tensor4d([[[[4]]]]).expandDims(); - expect(res.shape).toEqual([1, 1, 1, 1, 1]); - expectArraysClose(await res.data(), [4]); - }); - - it('1d string tensor', async () => { - const t = tf.tensor(['hello', 'world']); - const res = t.expandDims(); - expect(res.shape).toEqual([1, 2]); - expectArraysClose(await res.data(), ['hello', 'world']); - }); - - it('2d string tensor, axis=1', async () => { - const t = tf.tensor([['a', 'b'], ['c', 'd']]); - const res = t.expandDims(1); - expect(res.shape).toEqual([2, 1, 2]); - expectArraysClose(await res.data(), ['a', 'b', 'c', 'd']); - }); - - it('throws when passed a non-tensor', () => { - expect(() => tf.expandDims({} as tf.Tensor)) - .toThrowError(/Argument 'x' passed to 'expandDims' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const res = tf.expandDims(7); - expect(res.shape).toEqual([1]); - expectArraysClose(await res.data(), [7]); - }); - - it('works with 0 in shape', async () => { - const a = tf.tensor2d([], [0, 3]); - const res = a.expandDims(); - expect(res.shape).toEqual([1, 0, 3]); - expectArraysClose(await res.data(), []); - - const res2 = a.expandDims(1); - expect(res2.shape).toEqual([0, 1, 3]); - expectArraysClose(await res2.data(), []); - - const res3 = a.expandDims(2); - expect(res3.shape).toEqual([0, 3, 1]); - expectArraysClose(await res3.data(), []); - }); - it('ensure no memory leak', async () => { - const numTensorsBefore = tf.memory().numTensors; - const numDataIdBefore = tf.engine().backend.numDataIds(); - - const t = tf.scalar(1); - const res = t.expandDims(); - expect(res.shape).toEqual([1]); - expectArraysClose(await res.data(), [1]); - - res.dispose(); - t.dispose(); - - const numTensorsAfter = tf.memory().numTensors; - const numDataIdAfter = tf.engine().backend.numDataIds(); - expect(numTensorsAfter).toBe(numTensorsBefore); - expect(numDataIdAfter).toBe(numDataIdBefore); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/expm1.ts b/tfjs-master/tfjs-core/src/ops/expm1.ts deleted file mode 100644 index 5fc08d438..000000000 --- a/tfjs-master/tfjs-core/src/ops/expm1.ts +++ /dev/null @@ -1,46 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {Expm1, Expm1Inputs} from '../kernel_names'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -import {op} from './operation'; - -/** - * Computes exponential of the input `tf.Tensor` minus one element-wise. - * `e ^ x - 1` - * - * ```js - * const x = tf.tensor1d([1, 2, -3]); - * - * x.expm1().print(); // or tf.expm1(x) - * ``` - * @param x The input tensor. - * - * @doc {heading: 'Operations', subheading: 'Basic math'} - */ -function expm1_(x: T|TensorLike): T { - const $x = convertToTensor(x, 'x', 'expm1'); - - const inputs: Expm1Inputs = {x: $x}; - return ENGINE.runKernel(Expm1, inputs as unknown as NamedTensorMap); -} -export const expm1 = /* @__PURE__ */ op({expm1_}); diff --git a/tfjs-master/tfjs-core/src/ops/expm1_test.ts b/tfjs-master/tfjs-core/src/ops/expm1_test.ts deleted file mode 100644 index 6b1908fec..000000000 --- a/tfjs-master/tfjs-core/src/ops/expm1_test.ts +++ /dev/null @@ -1,103 +0,0 @@ -/** - * @license - * Copyright 2020 Google Inc. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('expm1', ALL_ENVS, () => { - it('expm1', async () => { - const a = tf.tensor1d([1, 2, 0]); - const r = tf.expm1(a); - - expectArraysClose( - await r.data(), [Math.expm1(1), Math.expm1(2), Math.expm1(0)]); - }); - - it('expm1 propagates NaNs', async () => { - const a = tf.tensor1d([1, NaN, 0]); - const r = tf.expm1(a); - expectArraysClose(await r.data(), [Math.expm1(1), NaN, Math.expm1(0)]); - }); - - it('gradients: Scalar', async () => { - const a = tf.scalar(0.5); - const dy = tf.scalar(3); - - const gradients = tf.grad(a => tf.expm1(a))(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), [3 * Math.exp(0.5)]); - }); - - it('gradient with clones', async () => { - const a = tf.scalar(0.5); - const dy = tf.scalar(3); - - const gradients = tf.grad(a => tf.expm1(a.clone()).clone())(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), [3 * Math.exp(0.5)]); - }); - - it('gradients: Tensor1D', async () => { - const a = tf.tensor1d([-1, 2, 3, -5]); - const dy = tf.tensor1d([1, 2, 3, 4]); - - const gradients = tf.grad(a => tf.expm1(a))(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose( - await gradients.data(), - [1 * Math.exp(-1), 2 * Math.exp(2), 3 * Math.exp(3), 4 * Math.exp(-5)], - 1e-1); - }); - - it('gradients: Tensor2D', async () => { - const a = tf.tensor2d([-3, 1, 2, 3], [2, 2]); - const dy = tf.tensor2d([1, 2, 3, 4], [2, 2]); - - const gradients = tf.grad(a => tf.expm1(a))(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose( - await gradients.data(), - [1 * Math.exp(-3), 2 * Math.exp(1), 3 * Math.exp(2), 4 * Math.exp(3)], - 1e-1); - }); - - it('throws when passed a non-tensor', () => { - expect(() => tf.expm1({} as tf.Tensor)) - .toThrowError(/Argument 'x' passed to 'expm1' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const r = tf.expm1([1, 2, 0]); - - expectArraysClose( - await r.data(), [Math.expm1(1), Math.expm1(2), Math.expm1(0)]); - }); - - it('throws for string tensor', () => { - expect(() => tf.expm1('q')) - .toThrowError(/Argument 'x' passed to 'expm1' must be numeric/); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/eye.ts b/tfjs-master/tfjs-core/src/ops/eye.ts deleted file mode 100644 index 312848b81..000000000 --- a/tfjs-master/tfjs-core/src/ops/eye.ts +++ /dev/null @@ -1,82 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Tensor2D} from '../tensor'; -import {DataType} from '../types'; - -import {buffer} from './buffer'; -import {expandDims} from './expand_dims'; -import {op} from './operation'; -import {reshape} from './reshape'; -import {tile} from './tile'; - -/** - * Create an identity matrix. - * - * @param numRows Number of rows. - * @param numColumns Number of columns. Defaults to `numRows`. - * @param batchShape If provided, will add the batch shape to the beginning - * of the shape of the returned `tf.Tensor` by repeating the identity - * matrix. - * @param dtype Data type. - * @returns Identity matrix of the specified size and data type, possibly - * with batch repetition if `batchShape` is specified. - * - * @doc {heading: 'Tensors', subheading: 'Creation'} - */ -function eye_( - numRows: number, numColumns?: number, - batchShape?: - [ - number - ]|[number, - number]|[number, number, number]|[number, number, number, number], - dtype: DataType = 'float32'): Tensor2D { - if (numColumns == null) { - numColumns = numRows; - } - const buff = buffer([numRows, numColumns], dtype); - const n = numRows <= numColumns ? numRows : numColumns; - for (let i = 0; i < n; ++i) { - buff.set(1, i, i); - } - const out: Tensor2D = reshape(buff.toTensor(), [numRows, numColumns]); - if (batchShape == null) { - return out; - } else { - if (batchShape.length === 1) { - return tile(expandDims(out, 0), [batchShape[0], 1, 1]) as Tensor2D; - } else if (batchShape.length === 2) { - // tslint:disable-next-line:no-unnecessary-type-assertion - return tile( - expandDims(expandDims(out, 0), 0), - [batchShape[0], batchShape[1], 1, 1]) as Tensor2D; - } else if (batchShape.length === 3) { - // tslint:disable-next-line:no-unnecessary-type-assertion - return tile(expandDims(expandDims(expandDims(out, 0), 0), 0), [ - batchShape[0], batchShape[1], batchShape[2], 1, 1 - ]) as Tensor2D; - } else { - throw new Error( - `eye() currently supports only 1D and 2D ` + - // tslint:disable-next-line:no-any - `batchShapes, but received ${(batchShape as any).length}D.`); - } - } -} - -export const eye = /* @__PURE__ */ op({eye_}); diff --git a/tfjs-master/tfjs-core/src/ops/eye_test.ts b/tfjs-master/tfjs-core/src/ops/eye_test.ts deleted file mode 100644 index 4cdf67160..000000000 --- a/tfjs-master/tfjs-core/src/ops/eye_test.ts +++ /dev/null @@ -1,92 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('eye', ALL_ENVS, () => { - it('1x1', async () => { - const r = tf.eye(1); - expectArraysClose(await r.data(), [1]); - expect(r.shape).toEqual([1, 1]); - expect(r.dtype).toBe('float32'); - }); - - it('2x2', async () => { - const r = tf.eye(2); - expect(r.shape).toEqual([2, 2]); - expect(r.dtype).toBe('float32'); - expectArraysClose(await r.data(), [1, 0, 0, 1]); - }); - - it('3x3', async () => { - const r = tf.eye(3); - expect(r.shape).toEqual([3, 3]); - expect(r.dtype).toBe('float32'); - expectArraysClose(await r.data(), [1, 0, 0, 0, 1, 0, 0, 0, 1]); - }); - - it('3x4', async () => { - const r = tf.eye(3, 4); - expect(r.shape).toEqual([3, 4]); - expect(r.dtype).toBe('float32'); - expectArraysClose(await r.data(), [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0]); - }); - - it('4x3', async () => { - const r = tf.eye(4, 3); - expect(r.shape).toEqual([4, 3]); - expectArraysClose(await r.data(), [1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0]); - }); - - it('with 1D batchShape', async () => { - const r = tf.eye(2, 2, [3]); - expect(r.shape).toEqual([3, 2, 2]); - expectArraysClose(await r.data(), [1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1]); - }); - - it('with 2D batchShape', async () => { - const r = tf.eye(2, 2, [2, 3]); - expect(r.shape).toEqual([2, 3, 2, 2]); - expectArraysClose(await r.data(), [ - 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1 - ]); - }); - - it('with 3D batchShape', async () => { - const r = tf.eye(2, 2, [2, 2, 3]); - expect(r.shape).toEqual([2, 2, 3, 2, 2]); - expectArraysClose(await r.data(), [ - 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, - 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1 - ]); - }); - - it('3x3, int32', async () => { - const r = tf.eye(3, 3, null, 'int32'); - expect(r.dtype).toBe('int32'); - expect(r.shape).toEqual([3, 3]); - expectArraysClose(await r.data(), [1, 0, 0, 0, 1, 0, 0, 0, 1]); - }); - - it('3x3, bool', async () => { - const r = tf.eye(3, 3, null, 'bool'); - expect(r.dtype).toBe('bool'); - expect(r.shape).toEqual([3, 3]); - expectArraysClose(await r.data(), [1, 0, 0, 0, 1, 0, 0, 0, 1]); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/fill.ts b/tfjs-master/tfjs-core/src/ops/fill.ts deleted file mode 100644 index 70f2a18eb..000000000 --- a/tfjs-master/tfjs-core/src/ops/fill.ts +++ /dev/null @@ -1,50 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {Fill, FillAttrs} from '../kernel_names'; -import {NamedAttrMap} from '../kernel_registry'; -import {Tensor} from '../tensor'; -import {DataType, Rank, ShapeMap} from '../types'; -import {inferDtype} from '../util'; -import {assertNonNegativeIntegerDimensions} from '../util_base'; - -/** - * Creates a `tf.Tensor` filled with a scalar value. - * - * ```js - * tf.fill([2, 2], 4).print(); - * ``` - * - * @param shape An array of integers defining the output tensor shape. - * @param value The scalar value to fill the tensor with. - * @param dtype The type of an element in the resulting tensor. Defaults to - * 'float32' if the given param value is a number, otherwise 'string'. - * - * @doc {heading: 'Tensors', subheading: 'Creation'} - */ -function fill( - shape: ShapeMap[R], value: number|string, dtype?: DataType): Tensor { - assertNonNegativeIntegerDimensions(shape); - - dtype = dtype || inferDtype(value); - const attrs: FillAttrs = {shape, value, dtype}; - - return ENGINE.runKernel(Fill, {}, attrs as unknown as NamedAttrMap); -} - -export {fill}; diff --git a/tfjs-master/tfjs-core/src/ops/fill_test.ts b/tfjs-master/tfjs-core/src/ops/fill_test.ts deleted file mode 100644 index 2ba6d9221..000000000 --- a/tfjs-master/tfjs-core/src/ops/fill_test.ts +++ /dev/null @@ -1,85 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose, expectArraysEqual} from '../test_util'; - -describeWithFlags('fill', ALL_ENVS, () => { - it('1D fill', async () => { - const a = tf.fill([3], 2); - expect(a.dtype).toBe('float32'); - expect(a.shape).toEqual([3]); - expectArraysClose(await a.data(), [2, 2, 2]); - }); - - it('1D fill with inf', async () => { - const a = tf.fill([3], Number.POSITIVE_INFINITY); - expect(a.dtype).toBe('float32'); - expect(a.shape).toEqual([3]); - expectArraysClose(await a.data(), [ - Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY, - Number.POSITIVE_INFINITY - ]); - }); - - it('1D fill string', async () => { - const a = tf.fill([3], 'aa'); - expect(a.dtype).toBe('string'); - expect(a.shape).toEqual([3]); - expectArraysEqual(await a.data(), ['aa', 'aa', 'aa']); - }); - - it('2D fill', async () => { - const a = tf.fill([3, 2], 2); - expect(a.dtype).toBe('float32'); - expect(a.shape).toEqual([3, 2]); - expectArraysClose(await a.data(), [2, 2, 2, 2, 2, 2]); - }); - - it('2D fill string', async () => { - const a = tf.fill([3, 2], 'a'); - expect(a.dtype).toBe('string'); - expect(a.shape).toEqual([3, 2]); - expectArraysEqual(await a.data(), ['a', 'a', 'a', 'a', 'a', 'a']); - }); - - it('3D fill', async () => { - const a = tf.fill([3, 2, 1], 2); - expect(a.dtype).toBe('float32'); - expect(a.shape).toEqual([3, 2, 1]); - expectArraysClose(await a.data(), [2, 2, 2, 2, 2, 2]); - }); - - it('4D fill', async () => { - const a = tf.fill([3, 2, 1, 2], 2); - expect(a.dtype).toBe('float32'); - expect(a.shape).toEqual([3, 2, 1, 2]); - expectArraysClose(await a.data(), [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]); - }); - - it('5D fill', async () => { - const a = tf.fill([2, 1, 2, 1, 2], 2); - expect(a.dtype).toBe('float32'); - expect(a.shape).toEqual([2, 1, 2, 1, 2]); - expectArraysClose(await a.data(), [2, 2, 2, 2, 2, 2, 2, 2]); - }); - - it('should throw error when shape is not integer', () => { - expect(() => tf.fill([2, 2.22, 3.33], 1)).toThrow(); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/floor.ts b/tfjs-master/tfjs-core/src/ops/floor.ts deleted file mode 100644 index 8405647af..000000000 --- a/tfjs-master/tfjs-core/src/ops/floor.ts +++ /dev/null @@ -1,44 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {ENGINE} from '../engine'; -import {Floor, FloorInputs} from '../kernel_names'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -import {op} from './operation'; - -/** - * Computes floor of input `tf.Tensor` element-wise: `floor(x)`. - * - * ```js - * const x = tf.tensor1d([.6, 1.1, -3.3]); - * - * x.floor().print(); // or tf.floor(x) - * ``` - * @param x The input tensor. - * - * @doc {heading: 'Operations', subheading: 'Basic math'} - */ -function floor_(x: T|TensorLike): T { - const $x = convertToTensor(x, 'x', 'floor', 'float32'); - - const inputs: FloorInputs = {x: $x}; - return ENGINE.runKernel(Floor, inputs as unknown as NamedTensorMap); -} -export const floor = /* @__PURE__ */ op({floor_}); diff --git a/tfjs-master/tfjs-core/src/ops/floorDiv.ts b/tfjs-master/tfjs-core/src/ops/floorDiv.ts deleted file mode 100644 index 4d0a09400..000000000 --- a/tfjs-master/tfjs-core/src/ops/floorDiv.ts +++ /dev/null @@ -1,65 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {FloorDiv, FloorDivInputs} from '../kernel_names'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {makeTypesMatch} from '../tensor_util'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -import {op} from './operation'; - -/** - * Divides two `tf.Tensor`s element-wise, A / B. Supports broadcasting. - * The result is rounded with floor function. - * - * - * ```js - * const a = tf.tensor1d([1, 4, 9, 16]); - * const b = tf.tensor1d([1, 2, 3, 4]); - * - * a.floorDiv(b).print(); // or tf.div(a, b) - * ``` - * - * ```js - * // Broadcast div a with b. - * const a = tf.tensor1d([2, 4, 6, 8]); - * const b = tf.scalar(2); - * - * a.floorDiv(b).print(); // or tf.floorDiv(a, b) - * ``` - * - * @param a The first tensor as the numerator. - * @param b The second tensor as the denominator. Must have the same dtype as - * `a`. - * - * @doc {heading: 'Operations', subheading: 'Arithmetic'} - */ -function floorDiv_( - a: Tensor|TensorLike, b: Tensor|TensorLike): T { - let $a = convertToTensor(a, 'a', 'floorDiv'); - let $b = convertToTensor(b, 'b', 'floorDiv'); - [$a, $b] = makeTypesMatch($a, $b); - - const inputs: FloorDivInputs = {a: $a, b: $b}; - - return ENGINE.runKernel(FloorDiv, inputs as unknown as NamedTensorMap); -} - -export const floorDiv = /* @__PURE__ */ op({floorDiv_}); diff --git a/tfjs-master/tfjs-core/src/ops/floor_test.ts b/tfjs-master/tfjs-core/src/ops/floor_test.ts deleted file mode 100644 index d7d5c5614..000000000 --- a/tfjs-master/tfjs-core/src/ops/floor_test.ts +++ /dev/null @@ -1,99 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('floor', ALL_ENVS, () => { - it('basic', async () => { - const a = tf.tensor1d([1.5, 2.1, -1.4]); - const r = tf.floor(a); - - expectArraysClose(await r.data(), [1, 2, -2]); - }); - - it('propagates NaNs', async () => { - const a = tf.tensor1d([1.5, NaN, -1.4]); - const r = tf.floor(a); - expectArraysClose(await r.data(), [1, NaN, -2]); - }); - - it('gradients: Scalar', async () => { - const a = tf.scalar(5.2); - const dy = tf.scalar(3); - - const gradients = tf.grad(a => tf.floor(a))(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), [0]); - }); - - it('gradient with clones', async () => { - const a = tf.scalar(5.2); - const dy = tf.scalar(3); - - const gradients = tf.grad(a => tf.floor(a.clone()).clone())(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), [0]); - }); - - it('gradients: Tensor1D', async () => { - const a = tf.tensor1d([-1.1, 2.6, 3, -5.9]); - const dy = tf.tensor1d([1, 2, 3, 4]); - - const gradients = tf.grad(a => tf.floor(a))(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), [0, 0, 0, 0]); - }); - - it('gradients: Tensor2D', async () => { - const a = tf.tensor2d([-3, 1, 2.2, 3], [2, 2]); - const dy = tf.tensor2d([1, 2, 3, 4], [2, 2]); - - const gradients = tf.grad(a => tf.floor(a))(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), [0, 0, 0, 0]); - }); - - it('throws when passed a non-tensor', () => { - expect(() => tf.floor({} as tf.Tensor)) - .toThrowError(/Argument 'x' passed to 'floor' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const r = tf.floor([1.5, 2.1, -1.4]); - expectArraysClose(await r.data(), [1, 2, -2]); - }); - - it('throws for string tensor', () => { - expect(() => tf.floor('q')) - .toThrowError(/Argument 'x' passed to 'floor' must be float32/); - }); - - it('throws for int32 tensor', () => { - expect(() => tf.floor(tf.tensor1d([1], 'int32'))) - .toThrowError(/Argument 'x' passed to 'floor' must be float32/); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/floordiv_test.ts b/tfjs-master/tfjs-core/src/ops/floordiv_test.ts deleted file mode 100644 index 46fe81c8b..000000000 --- a/tfjs-master/tfjs-core/src/ops/floordiv_test.ts +++ /dev/null @@ -1,49 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('floorDiv', ALL_ENVS, () => { - it('floorDiv', async () => { - const a = tf.tensor1d([10, 20, -20, -40], 'int32'); - const b = tf.tensor1d([10, 12, 8, 5], 'int32'); - const result = tf.floorDiv(a, b); - - expect(result.shape).toEqual(a.shape); - expectArraysClose(await result.data(), [1, 1, -3, -8]); - }); - - it('floorDiv vec4', async () => { - const a = tf.tensor1d([10, 20, -20, -40], 'int32'); - const b = tf.tensor1d([10, 12, 8, 5], 'int32'); - const result = tf.floorDiv(a, b); - - expect(result.shape).toEqual(a.shape); - expectArraysClose(await result.data(), [1, 1, -3, -8]); - }); - - it('floorDiv float32', async () => { - const a = tf.tensor1d([0.0, -6.0, 5.9, -5.9], 'float32'); - const b = tf.tensor1d([3.0, 3.0, -3.1, -3.1], 'float32'); - const result = tf.floorDiv(a, b); - - expect(result.shape).toEqual(a.shape); - expectArraysClose(await result.data(), [0, -2, -2, 1]); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/from_pixels_test.ts b/tfjs-master/tfjs-core/src/ops/from_pixels_test.ts deleted file mode 100644 index 7cff8ed0a..000000000 --- a/tfjs-master/tfjs-core/src/ops/from_pixels_test.ts +++ /dev/null @@ -1,329 +0,0 @@ -/** - * @license - * Copyright 2020 Google Inc. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {BROWSER_ENVS, describeWithFlags, NODE_ENVS} from '../jasmine_util'; -import {createVideoElement, expectArraysClose, expectArraysEqual, play} from '../test_util'; - -class MockContext { - getImageData(x: number, y: number, width: number, height: number) { - const data = new Uint8ClampedArray(width * height * 4); - for (let i = 0; i < data.length; ++i) { - data[i] = i + 1; - } - return {data}; - } -} - -class MockCanvas { - constructor(public width: number, public height: number) {} - getContext(type: '2d'): MockContext { - return new MockContext(); - } -} - -describeWithFlags('fromPixels, mock canvas', NODE_ENVS, () => { - it('accepts a canvas-like element', async () => { - const c = new MockCanvas(2, 2); - // tslint:disable-next-line:no-any - const t = tf.browser.fromPixels(c as any); - expect(t.dtype).toBe('int32'); - expect(t.shape).toEqual([2, 2, 3]); - expectArraysEqual( - await t.data(), [1, 2, 3, 5, 6, 7, 9, 10, 11, 13, 14, 15]); - }); - - it('accepts a canvas-like element, numChannels=4', async () => { - const c = new MockCanvas(2, 2); - // tslint:disable-next-line:no-any - const t = tf.browser.fromPixels(c as any, 4); - expect(t.dtype).toBe('int32'); - expect(t.shape).toEqual([2, 2, 4]); - expectArraysEqual( - await t.data(), - [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]); - }); - - it('errors when passed a non-canvas object', () => { - // tslint:disable-next-line:no-any - expect(() => tf.browser.fromPixels(5 as any)).toThrowError(); - }); -}); - -describeWithFlags('fromPixels', BROWSER_ENVS, () => { - it('ImageData 1x1x3', async () => { - const pixels = new ImageData(1, 1); - pixels.data[0] = 0; - pixels.data[1] = 80; - pixels.data[2] = 160; - pixels.data[3] = 240; - - const array = tf.browser.fromPixels(pixels, 3); - - expectArraysEqual(await array.data(), [0, 80, 160]); - }); - - it('ImageData 1x1x4', async () => { - const pixels = new ImageData(1, 1); - pixels.data[0] = 0; - pixels.data[1] = 80; - pixels.data[2] = 160; - pixels.data[3] = 240; - - const array = tf.browser.fromPixels(pixels, 4); - - expectArraysEqual(await array.data(), [0, 80, 160, 240]); - }); - - it('ImageData 2x2x3', async () => { - const pixels = new ImageData(2, 2); - - for (let i = 0; i < 8; i++) { - pixels.data[i] = i * 2; - } - for (let i = 8; i < 16; i++) { - pixels.data[i] = i * 2; - } - - const array = tf.browser.fromPixels(pixels, 3); - - expectArraysEqual( - await array.data(), [0, 2, 4, 8, 10, 12, 16, 18, 20, 24, 26, 28]); - }); - - it('ImageData 2x2x4', async () => { - const pixels = new ImageData(2, 2); - for (let i = 0; i < 8; i++) { - pixels.data[i] = i * 2; - } - for (let i = 8; i < 16; i++) { - pixels.data[i] = i * 2; - } - - const array = tf.browser.fromPixels(pixels, 4); - - expectArraysClose( - await array.data(), - new Int32Array( - [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30])); - }); - - it('fromPixels, 3 channels', async () => { - const pixels = new ImageData(1, 2); - pixels.data[0] = 2; - pixels.data[1] = 3; - pixels.data[2] = 4; - pixels.data[3] = 255; // Not used. - pixels.data[4] = 5; - pixels.data[5] = 6; - pixels.data[6] = 7; - pixels.data[7] = 255; // Not used. - const res = tf.browser.fromPixels(pixels, 3); - expect(res.shape).toEqual([2, 1, 3]); - expect(res.dtype).toBe('int32'); - expectArraysClose(await res.data(), [2, 3, 4, 5, 6, 7]); - }); - - it('fromPixels, reshape, then do tf.add()', async () => { - const pixels = new ImageData(1, 1); - pixels.data[0] = 2; - pixels.data[1] = 3; - pixels.data[2] = 4; - pixels.data[3] = 255; // Not used. - const a = tf.browser.fromPixels(pixels, 3).reshape([1, 1, 1, 3]); - const res = a.add(tf.scalar(2, 'int32')); - expect(res.shape).toEqual([1, 1, 1, 3]); - expect(res.dtype).toBe('int32'); - expectArraysClose(await res.data(), [4, 5, 6]); - }); - - it('fromPixels + fromPixels', async () => { - const pixelsA = new ImageData(1, 1); - pixelsA.data[0] = 255; - pixelsA.data[1] = 3; - pixelsA.data[2] = 4; - pixelsA.data[3] = 255; // Not used. - const pixelsB = new ImageData(1, 1); - pixelsB.data[0] = 5; - pixelsB.data[1] = 6; - pixelsB.data[2] = 7; - pixelsB.data[3] = 255; // Not used. - const a = tf.browser.fromPixels(pixelsA, 3).toFloat(); - const b = tf.browser.fromPixels(pixelsB, 3).toFloat(); - const res = a.add(b); - expect(res.shape).toEqual([1, 1, 3]); - expect(res.dtype).toBe('float32'); - expectArraysClose(await res.data(), [260, 9, 11]); - }); - it('fromPixels for PixelData type', async () => { - const dataA = new Uint8Array([255, 3, 4, 255]); - const pixelsA = {width: 1, height: 1, data: dataA}; - - const dataB = new Uint8Array([5, 6, 7, 255]); - const pixelsB = {width: 1, height: 1, data: dataB}; - const a = tf.browser.fromPixels(pixelsA, 3).toFloat(); - const b = tf.browser.fromPixels(pixelsB, 3).toFloat(); - const res = a.add(b); - expect(res.shape).toEqual([1, 1, 3]); - expect(res.dtype).toBe('float32'); - expectArraysClose(await res.data(), [260, 9, 11]); - }); - - it('fromPixels for HTMLCanvasElement', async () => { - const canvas = document.createElement('canvas'); - canvas.width = 1; - canvas.height = 1; - const ctx = canvas.getContext('2d'); - const pixels = new ImageData(1, 1); - pixels.data[0] = 0; - pixels.data[1] = 80; - pixels.data[2] = 160; - pixels.data[3] = 240; - ctx.putImageData(pixels, 1, 1); - const res = tf.browser.fromPixels(canvas); - expect(res.shape).toEqual([1, 1, 3]); - const data = await res.data(); - expect(data.length).toEqual(1 * 1 * 3); - }); - it('fromPixels for HTMLImageElement', async () => { - const img = new Image(10, 10); - img.src = 'data:image/gif;base64' + - ',R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=='; - const res = tf.browser.fromPixels(img); - expect(res.shape).toEqual([10, 10, 3]); - const data = await res.data(); - expect(data.length).toEqual(10 * 10 * 3); - }); - it('fromPixels for HTMLVideoElement', async () => { - const source = document.createElement('source'); - source.src = - // tslint:disable-next-line:max-line-length - 'data:video/mp4;base64,AAAAIGZ0eXBpc29tAAACAGlzb21pc28yYXZjMW1wNDEAAAAIZnJlZQAAAu1tZGF0AAACrQYF//+p3EXpvebZSLeWLNgg2SPu73gyNjQgLSBjb3JlIDE1NSByMjkwMSA3ZDBmZjIyIC0gSC4yNjQvTVBFRy00IEFWQyBjb2RlYyAtIENvcHlsZWZ0IDIwMDMtMjAxOCAtIGh0dHA6Ly93d3cudmlkZW9sYW4ub3JnL3gyNjQuaHRtbCAtIG9wdGlvbnM6IGNhYmFjPTEgcmVmPTMgZGVibG9jaz0xOjA6MCBhbmFseXNlPTB4MzoweDExMyBtZT1oZXggc3VibWU9NyBwc3k9MSBwc3lfcmQ9MS4wMDowLjAwIG1peGVkX3JlZj0xIG1lX3JhbmdlPTE2IGNocm9tYV9tZT0xIHRyZWxsaXM9MSA4eDhkY3Q9MSBjcW09MCBkZWFkem9uZT0yMSwxMSBmYXN0X3Bza2lwPTEgY2hyb21hX3FwX29mZnNldD0tMiB0aHJlYWRzPTMgbG9va2FoZWFkX3RocmVhZHM9MSBzbGljZWRfdGhyZWFkcz0wIG5yPTAgZGVjaW1hdGU9MSBpbnRlcmxhY2VkPTAgYmx1cmF5X2NvbXBhdD0wIGNvbnN0cmFpbmVkX2ludHJhPTAgYmZyYW1lcz0zIGJfcHlyYW1pZD0yIGJfYWRhcHQ9MSBiX2JpYXM9MCBkaXJlY3Q9MSB3ZWlnaHRiPTEgb3Blbl9nb3A9MCB3ZWlnaHRwPTIga2V5aW50PTI1MCBrZXlpbnRfbWluPTEgc2NlbmVjdXQ9NDAgaW50cmFfcmVmcmVzaD0wIHJjX2xvb2thaGVhZD00MCByYz1jcmYgbWJ0cmVlPTEgY3JmPTI4LjAgcWNvbXA9MC42MCBxcG1pbj0wIHFwbWF4PTY5IHFwc3RlcD00IGlwX3JhdGlvPTEuNDAgYXE9MToxLjAwAIAAAAAwZYiEAD//8m+P5OXfBeLGOfKE3xkODvFZuBflHv/+VwJIta6cbpIo4ABLoKBaYTkTAAAC7m1vb3YAAABsbXZoZAAAAAAAAAAAAAAAAAAAA+gAAAPoAAEAAAEAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAIYdHJhawAAAFx0a2hkAAAAAwAAAAAAAAAAAAAAAQAAAAAAAAPoAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAQAAAAACgAAAAWgAAAAAAJGVkdHMAAAAcZWxzdAAAAAAAAAABAAAD6AAAAAAAAQAAAAABkG1kaWEAAAAgbWRoZAAAAAAAAAAAAAAAAAAAQAAAAEAAVcQAAAAAAC1oZGxyAAAAAAAAAAB2aWRlAAAAAAAAAAAAAAAAVmlkZW9IYW5kbGVyAAAAATttaW5mAAAAFHZtaGQAAAABAAAAAAAAAAAAAAAkZGluZgAAABxkcmVmAAAAAAAAAAEAAAAMdXJsIAAAAAEAAAD7c3RibAAAAJdzdHNkAAAAAAAAAAEAAACHYXZjMQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAACgAFoASAAAAEgAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABj//wAAADFhdmNDAWQACv/hABhnZAAKrNlCjfkhAAADAAEAAAMAAg8SJZYBAAZo6+JLIsAAAAAYc3R0cwAAAAAAAAABAAAAAQAAQAAAAAAcc3RzYwAAAAAAAAABAAAAAQAAAAEAAAABAAAAFHN0c3oAAAAAAAAC5QAAAAEAAAAUc3RjbwAAAAAAAAABAAAAMAAAAGJ1ZHRhAAAAWm1ldGEAAAAAAAAAIWhkbHIAAAAAAAAAAG1kaXJhcHBsAAAAAAAAAAAAAAAALWlsc3QAAAAlqXRvbwAAAB1kYXRhAAAAAQAAAABMYXZmNTguMTIuMTAw'; - source.type = 'video/mp4'; - - const video = await createVideoElement(source); - document.body.appendChild(video); - await play(video); - - const res = tf.browser.fromPixels(video); - expect(res.shape).toEqual([90, 160, 3]); - const data = await res.data(); - expect(data.length).toEqual(90 * 160 * 3); - document.body.removeChild(video); - }, 30_000 /* 30 seconds */); - - it('throws when passed a primitive number', () => { - const msg = /pixels passed to tf.browser.fromPixels\(\) must be either/; - // tslint:disable-next-line:no-any - expect(() => tf.browser.fromPixels(3 as any)).toThrowError(msg); - }); - - it('throws when passed a string', () => { - const msg = /pixels passed to tf.browser.fromPixels\(\) must be either/; - // tslint:disable-next-line:no-any - expect(() => tf.browser.fromPixels('test' as any)).toThrowError(msg); - }); - - it('canvas and image match', async () => { - const img = new Image(); - const size = 80; - img.src = - // tslint:disable-next-line:max-line-length - 'data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAASABIAAD/4QCMRXhpZgAATU0AKgAAAAgABQESAAMAAAABAAEAAAEaAAUAAAABAAAASgEbAAUAAAABAAAAUgEoAAMAAAABAAIAAIdpAAQAAAABAAAAWgAAAAAAAABIAAAAAQAAAEgAAAABAAOgAQADAAAAAQABAACgAgAEAAAAAQAAAFCgAwAEAAAAAQAAADwAAAAA/+0AOFBob3Rvc2hvcCAzLjAAOEJJTQQEAAAAAAAAOEJJTQQlAAAAAAAQ1B2M2Y8AsgTpgAmY7PhCfv/AABEIADwAUAMBIgACEQEDEQH/xAAfAAABBQEBAQEBAQAAAAAAAAAAAQIDBAUGBwgJCgv/xAC1EAACAQMDAgQDBQUEBAAAAX0BAgMABBEFEiExQQYTUWEHInEUMoGRoQgjQrHBFVLR8CQzYnKCCQoWFxgZGiUmJygpKjQ1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4eLj5OXm5+jp6vHy8/T19vf4+fr/xAAfAQADAQEBAQEBAQEBAAAAAAAAAQIDBAUGBwgJCgv/xAC1EQACAQIEBAMEBwUEBAABAncAAQIDEQQFITEGEkFRB2FxEyIygQgUQpGhscEJIzNS8BVictEKFiQ04SXxFxgZGiYnKCkqNTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqCg4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2dri4+Tl5ufo6ery8/T19vf4+fr/2wBDAAkGBxMSEhUSEhIVFRUXFxUWFRUVFRUVDxUVFhUWFxUVFRUYHSggGBolGxUVITEhJSkrLi4uFx8zODMtNygtLiv/2wBDAQoKCg4NDhsQEBotIB8fLS0tLS0tLS0tLSstLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLSstLS0tLS3/3QAEAAX/2gAMAwEAAhEDEQA/APP/AAlPI3nFOX2g5J9O5roPDuouWZJpEPdSCM1ydxbeXCWUtuzjKE42nrnFNtrlR5eACV5wRyOPWtYyWg1C7sehavfNEu8OFGO4zn6Vk6JczyOpWQu0p4P8KDvkdgACawdfcvGuX98A5rp/CMe22mQpt2x9f4mLhi2fToKKk+VN/cV7K0kt7nS6cXJXcjlWLASFlCnHQ4HI3dvwputWG7Dxu0bKRkg/Kc9AynsemeoNOOtrJE4gUyFBjA4BI4wD7GqxvG2q0qFGIKsD3Ddf1ANccK8m7s2qUEl7pUa8lZ9iuy9skAjI681vW68DPXFcxfXKxMkhJ5by/wDZzWsl43mBcjHpjnGOtd0Jc2pySVmbPlinooxVdZKej1oyD//Q8lstTkh3AdCCpBGR6VDHcYx6jv7V21zYxQwkjBcck9VOeoKmsSNY5QRsAUAkYGMYq3oPU2Bpm5IZThdwXI4HPUGtjUw8Fo5b77A4AHXsC3sM1zXhmBJnKzMxQLwuT1zXZarajyAuSQ2doPJCAd/bjH1NZ1pLk+42hzSkmyXQ9Y86FTCqoCqhiAvDfxbvQ5HoaNZL7Pnb7xwg5znHB55Jzz0rlvBUMgusxllTygXx93dwF9ieDWlfW8hulMkpf72zcMbSQRxjjvXDzJStf0OxXlG9hdQTzrafA5GHUf7SAMB/MfjWFB4pdYEDDMgyUkIHKZ4B/Sup05MCRO6OQR/skDH4EVkWVgjyfZTHlG3FW/uLnkZ+prtoVZJNI4akFc6LQ7rzVWVWDJjB9Q/cGrkuqRxsqM2Gbp/+usW60g2kJSNmaLfuYA8j8fSqEOsrzG4yB8xxgkDqOa6ee7sYch//0fMtOuDJIInYlMngntnpmtLxLAIpEQfLCyjheOh5GfyrNvLD7PdiJHDdCGIx1zwfyrS8SxGWSBQ64bCbifkVu+TWnLvcaegonjtfLaL5i567uQnAx+ddolpJekpG2yMffkI56YCqvtzjt39jxv8AYASdbeSXzM42tAAwG4ng5zt6dTXrGl24iiwP/r+nPvWGJ3S7G+Hd7lOLTUhUJENpAAB67iOhcd6rXEIlGdoWRTyOpVhzwe4PY1ZeYCQZPU4FVdfnMTxzJ3yjDs4ALAH8jz2zXPJRO2jGU3yLfp/kZ1zIuR1SQ8EjGTjsQeoqtYp5dxznJUkE8AqTzWvqCLPEJIjhgcg/xKw6hhWUsrltsmAwHy5IP3vQnnFXR9yVns+pzVqb16NdB+oXjMjgcjDcV5Q90d5ZcjPHXnHpXsslioh46kfqRXi9yhV2B6hmB+oJBrskrHHe5//S8la4Z5leYdSuR0yAea69NLQzKjRZgJ3oCc4IHII9DmsCOzWVyGzwuRg4rtbVf9WPRTz36CuujCLun0sQ20tDkTKbeVntVCkb0KkE7iTkAAfQY+tevwlhCm772xd31wM/rXiuoyst4wV2GJRjHYkqCf1Ne43R4rhxSVzswz3OWvyTcQrkj5iT7jGP61F4o1JHKRJyI8lj23Ebdo+gzn3xWP4vnYXcYBI+U9OD1HeqJriq6SPby+kv4j6Ghb6g8R3I2OxB5Vh6MO9PmvzNJGGUDa3AGe/qe49qyC1afh+MNcID2BP4ggf1NaUr3SNsWoNSm46pM3bm8wMd815RqaFppmUEgOxPtz/jXsuuWCIRtzyCfYfT2ryTxMNlxIq8BtpIHQk5r0JM+VtY/9k='; - - await new Promise(resolve => { - img.onload = () => resolve(img); - }); - - img.width = size; - img.height = size; - - const pixels = await tf.browser.fromPixels(img, 4); - - const canvas = document.createElement('canvas'); - canvas.width = size; - canvas.height = size; - const ctx = canvas.getContext('2d'); - ctx.drawImage(img, 0, 0, size, size); - const actual = ctx.getImageData(0, 0, size, size).data; - const actualInt32 = Int32Array.from(actual); - const pixelsData = await pixels.data(); - - expectArraysClose(pixelsData, actualInt32, 10); - }); - - if (tf.env().getBool('IS_CHROME')) { - it('fromPixels for ImageBitmap', async () => { - const imageDataWidth = 1; - const imageDataHeight = 2; - const numChannel = 3; - const pixels = new ImageData(imageDataWidth, imageDataHeight); - for (let i = 0; i < imageDataWidth * imageDataHeight * 4; ++i) { - if (i % 4 === 3) { - pixels.data[i] = 255; - } else { - pixels.data[i] = i; - } - } - - const imageBitmap = await createImageBitmap(pixels); - const res = tf.browser.fromPixels(imageBitmap, numChannel); - imageBitmap.close(); - expect(res.shape).toEqual([imageDataHeight, imageDataWidth, numChannel]); - const data = await res.data(); - expect(data.length) - .toEqual(imageDataHeight * imageDataWidth * numChannel); - expectArraysEqual(await res.data(), [0, 1, 2, 4, 5, 6]); - }); - - it('fromPixels for ImageBitmap outShape changes', async () => { - const imageDataWidth = 2; - const imageDataHeight = 2; - let numChannel = 3; - const pixels = new ImageData(imageDataWidth, imageDataHeight); - for (let i = 0; i < imageDataWidth * imageDataHeight * 4; ++i) { - if (i % 4 === 3) { - pixels.data[i] = 255; - } else { - pixels.data[i] = i; - } - } - - const imageBitmap = await createImageBitmap(pixels); - const res = tf.browser.fromPixels(imageBitmap, numChannel); - expect(res.shape).toEqual([imageDataHeight, imageDataWidth, numChannel]); - const data = await res.data(); - expect(data.length) - .toEqual(imageDataHeight * imageDataWidth * numChannel); - expectArraysEqual( - await res.data(), [0, 1, 2, 4, 5, 6, 8, 9, 10, 12, 13, 14]); - - // Change output shapes - numChannel = 4; - const resShapeChange = tf.browser.fromPixels(imageBitmap, numChannel); - expect(resShapeChange.shape).toEqual([ - imageDataHeight, imageDataWidth, numChannel - ]); - const data2 = await resShapeChange.data(); - expect(data2.length) - .toEqual(imageDataHeight * imageDataWidth * numChannel); - expectArraysEqual( - await resShapeChange.data(), - [0, 1, 2, 255, 4, 5, 6, 255, 8, 9, 10, 255, 12, 13, 14, 255]); - }); - } -}); diff --git a/tfjs-master/tfjs-core/src/ops/from_pixels_worker_test.ts b/tfjs-master/tfjs-core/src/ops/from_pixels_worker_test.ts deleted file mode 100644 index 5d6d0bf57..000000000 --- a/tfjs-master/tfjs-core/src/ops/from_pixels_worker_test.ts +++ /dev/null @@ -1,89 +0,0 @@ -/** - * @license - * Copyright 2021 Google Inc. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import '@tensorflow/tfjs-backend-cpu'; -import {expectArraysEqual} from '../test_util'; - -describe('fromPixels worker', () => { - it('fromPixels for ImageBitmap, worker', (done) => { - // Necessary preconditions - if (typeof (createImageBitmap) === 'undefined' || - typeof (Worker) === 'undefined') { - done(); - return; - } - - // Test-only preconditions - if (typeof (ImageData) === 'undefined' || typeof (Blob) === 'undefined' || - typeof (URL) === 'undefined') { - pending('Test-only js APIs are not supported in this context'); - done(); - return; - } - - const str2workerURL = (str: string): string => { - const blob = new Blob([str], {type: 'application/javascript'}); - return URL.createObjectURL(blob); - }; - - // The source code of a web worker. - const workerTest = ` - importScripts(location.origin + '/base/tfjs/tfjs-core/tf-core.min.js'); - importScripts(location.origin - + '/base/tfjs/tfjs-backend-cpu/tf-backend-cpu.min.js'); - - self.onmessage = (msg) => { - const bitmap = msg.data; - const tensor = tf.browser.fromPixels(bitmap, 4); - tensor.data().then((data) => { - const thinTensor = {shape: tensor.shape, dtype: tensor.dtype, data: data}; - self.postMessage(thinTensor); - }); - }; - `; - - const worker = new Worker(str2workerURL(workerTest)); - - worker.onmessage = (msg) => { - const thinTensor = msg.data; - expect(thinTensor.shape).toEqual([1, 1, 4]); - expect(thinTensor.dtype).toBe('int32'); - expectArraysEqual(thinTensor.data, [1, 2, 3, 255]); - done(); - worker.terminate(); - }; - - worker.onerror = (e) => { - if(typeof OffscreenCanvas === 'undefined' || - typeof OffscreenCanvasRenderingContext2D === 'undefined') { - expect(e.message).toEqual( - 'Cannot parse input in current context. ' + - 'Reason: OffscreenCanvas Context2D rendering is not supported.' - ); - } else { - throw e; - } - done(); - worker.terminate(); - }; - - const imData = new ImageData(new Uint8ClampedArray([1, 2, 3, 255]), 1, 1); - createImageBitmap(imData).then((bitmap) => { - worker.postMessage(bitmap, [bitmap]); - }); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/fused/conv2d.ts b/tfjs-master/tfjs-core/src/ops/fused/conv2d.ts deleted file mode 100644 index 1fc1dff74..000000000 --- a/tfjs-master/tfjs-core/src/ops/fused/conv2d.ts +++ /dev/null @@ -1,332 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../../engine'; -import {customGrad} from '../../gradients'; -import {FusedConv2D, FusedConv2DAttrs, FusedConv2DInputs} from '../../kernel_names'; -import {NamedAttrMap} from '../../kernel_registry'; -import {Tensor, Tensor3D, Tensor4D} from '../../tensor'; -import {GradSaveFunc, NamedTensorMap} from '../../tensor_types'; -import {makeTypesMatch} from '../../tensor_util'; -import {convertToTensor} from '../../tensor_util_env'; -import {TensorLike} from '../../types'; -import * as util from '../../util'; -import {add} from '../add'; -import * as broadcast_util from '../broadcast_util'; -import {conv2d as unfusedConv2d} from '../conv2d'; -import {conv2DBackpropFilter} from '../conv2d_backprop_filter'; -import {conv2DBackpropInput} from '../conv2d_backprop_input'; -import * as conv_util from '../conv_util'; -import {Activation} from '../fused_types'; -import {applyActivation, getFusedBiasGradient, getFusedDyActivation, shouldFuse} from '../fused_util'; -import {op} from '../operation'; -import {reshape} from '../reshape'; - -/** - * Computes a 2D convolution over the input x, optionally fused with adding a - * bias and applying an activation. - * - * ```js - * const inputDepth = 2; - * const inShape = [2, 2, 2, inputDepth]; - * const outputDepth = 2; - * const fSize = 1; - * const pad = 0; - * const strides = 1; - * - * const x = tf.tensor4d( [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - * 16], inShape); - * const w = tf.tensor4d([-1, 1, -2, 0.5], [fSize, fSize, inputDepth, - * outputDepth]); - * - * tf.fused.conv2d({ x, filter: w, strides, pad, dataFormat: 'NHWC', - * dilations: [1, 1], bias: tf.scalar(5), activation: 'relu' }).print(); - * ``` - * - * @param obj An object with the following properties: - * @param x The input tensor, of rank 4 or rank 3, of shape - * `[batch, height, width, inChannels]`. If rank 3, batch of 1 is - * assumed. - * @param filter The filter, rank 4, of shape - * `[filterHeight, filterWidth, inDepth, outDepth]`. - * @param strides The strides of the convolution: `[strideHeight, - * strideWidth]`. - * @param pad The type of padding algorithm. - * - `same` and stride 1: output will be of same size as input, - * regardless of filter size. - * - `valid` output will be smaller than input if filter is larger - * than 1x1. - * - For more info, see this guide: - * [https://www.tensorflow.org/api_docs/python/tf/nn/convolution]( - * https://www.tensorflow.org/api_docs/python/tf/nn/convolution) - * @param dataFormat An optional string from: "NHWC", "NCHW". Defaults to - * "NHWC". Specify the data format of the input and output data. With the - * default format "NHWC", the data is stored in the order of: [batch, - * height, width, channels]. Only "NHWC" is currently supported. - * @param dilations The dilation rates: `[dilationHeight, dilationWidth]` - * in which we sample input values across the height and width dimensions - * in atrous convolution. Defaults to `[1, 1]`. If `dilations` is a single - * number, then `dilationHeight == dilationWidth`. If it is greater than - * 1, then all values of `strides` must be 1. - * @param dimRoundingMode A string from: 'ceil', 'round', 'floor'. If none is - * provided, it will default to truncate. - * @param bias Tensor to be added to the result. - * @param activation Name of activation kernel (defaults to `linear`) to be - * applied - * after biasAdd. - * @param preluActivationWeights Tensor of prelu weights to be applied as part - * of a `prelu` activation, typically the same shape as `x`. - * @param leakyreluAlpha Optional. Alpha to be applied as part of a `leakyrelu` - * activation. - */ -function fusedConv2d_({ - x, - filter, - strides, - pad, - dataFormat = 'NHWC', - dilations = [1, 1], - dimRoundingMode, - bias, - activation = 'linear', - preluActivationWeights, - leakyreluAlpha -}: { - x: T|TensorLike, - filter: Tensor4D|TensorLike, - strides: [number, number]|number, - pad: 'valid'|'same'|number|conv_util.ExplicitPadding, - dataFormat?: 'NHWC'|'NCHW', - dilations?: [number, number]|number, - dimRoundingMode?: 'floor'|'round'|'ceil', - bias?: Tensor|TensorLike, - activation?: Activation, - preluActivationWeights?: Tensor, - leakyreluAlpha?: number -}): T { - activation = activation || 'linear'; - - if (shouldFuse(ENGINE.state.gradientDepth, activation) === false) { - // TODO: Transpose bias and preluActivationWeights properly for NCHW - // format before computation. - util.assert( - dataFormat === 'NHWC', - () => `Error in fused conv2d: got dataFormat of ${dataFormat} but ` + - `only NHWC is currently supported for the case of gradient depth ` + - `is 0 and the activation is not linear.`); - - let result = unfusedConv2d( - x, filter, strides, pad, dataFormat, dilations, dimRoundingMode); - if (bias != null) { - result = add(result, bias); - } - - return applyActivation( - result, activation, preluActivationWeights, leakyreluAlpha) as T; - } - - const $x = convertToTensor(x, 'x', 'conv2d', 'float32'); - const $filter = convertToTensor(filter, 'filter', 'conv2d', 'float32'); - - let x4D = $x as Tensor4D; - let reshapedTo4D = false; - - if ($x.rank === 3) { - reshapedTo4D = true; - x4D = reshape($x, [1, $x.shape[0], $x.shape[1], $x.shape[2]]); - } - util.assert( - x4D.rank === 4, - () => `Error in fused conv2d: input must be rank 4, but got rank ` + - `${x4D.rank}.`); - util.assert( - $filter.rank === 4, - () => `Error in fused conv2d: filter must be rank 4, but got rank ` + - `${$filter.rank}.`); - conv_util.checkPadOnDimRoundingMode('fused conv2d', pad, dimRoundingMode); - const inputChannels = dataFormat === 'NHWC' ? x4D.shape[3] : x4D.shape[1]; - util.assert( - $filter.shape[2] === inputChannels, - () => `Error in conv2d: depth of input (${inputChannels}) must match ` + - `input depth for filter ${$filter.shape[2]}.`); - util.assert( - conv_util.eitherStridesOrDilationsAreOne(strides, dilations), - () => 'Error in conv2D: Either strides or dilations must be 1. ' + - `Got strides ${strides} and dilations '${dilations}'`); - - const convInfo = conv_util.computeConv2DInfo( - x4D.shape, $filter.shape, strides, dilations, pad, dimRoundingMode); - - let $bias: Tensor; - if (bias != null) { - $bias = convertToTensor(bias, 'bias', 'fused conv2d'); - [$bias] = makeTypesMatch($bias, $x); - - // According to TensorFlow, the bias is supposed be a 1-D tensor or a - // scalar. - // - // 3-D or 4-D bias is not disabled for NHWC format, because they are - // currently being used in some cases. For examplem in our code base, - // https://github.com/tensorflow/tfjs/blob/b53bd47e880367ae57493f0ea628abaf08db2d5d/tfjs-core/src/ops/fused/fused_conv2d_test.ts#L1972. - if (dataFormat === 'NHWC') { - broadcast_util.assertAndGetBroadcastShape(convInfo.outShape, $bias.shape); - } else { - util.assert( - $bias.shape.length <= 1, - () => `Error in fused conv2d: only supports scalar or 1-D Tensor ` + - `bias for NCHW format but got the bias of ` + - `rank-${$bias.shape.length}.`); - - util.assert( - $bias.shape.length === 0 || $bias.shape[0] === convInfo.outChannels || - $bias.shape[0] === 1, - () => `Error in fused conv2d: bias shape (${$bias.shape}) is not ` + - `compatible with the number of output channels ` + - `(${convInfo.outChannels})`); - } - } - - let $preluActivationWeights: Tensor; - if (preluActivationWeights != null) { - // PReLU's activation weights could be a scalar, a 1-D tensor or a 3-D - // tensor. - const alphaShape = preluActivationWeights.shape; - util.assert( - alphaShape.length <= 1 || alphaShape.length === 3, - () => `Error in fused conv2d: only supports scalar, 1-D Tensor or ` + - `3-D Tensor PReLU activation weights but got a tensor of ` + - `rank-${alphaShape.length}.`); - - if (alphaShape.length === 1) { - // Whether the data format is NCHW or NHWC, the 1-D PReLU activation - // weights tensor should be aligned with the output channels of conv2d - // result. - util.assert( - alphaShape[0] === 1 || alphaShape[0] === convInfo.outChannels, - () => `Error in fused conv2d: PReLU activation weights ` + - `(${alphaShape}) is not compatible with the number of output ` + - `channels (${convInfo.outChannels}).`); - } else if (alphaShape.length === 3) { - // Whether the data format is NCHW or NHWC, the PReLU activation weights - // tensor should has the compatible shape with the result of conv2d. - try { - broadcast_util.assertAndGetBroadcastShape( - alphaShape, convInfo.outShape); - } catch (e) { - const errMsg = - `Error in fused conv2d: PReLU activation weights (${alphaShape}) ` + - `is not compatible with the output shape of the conv2d ` + - `(${convInfo.outShape}).`; - throw Error(errMsg); - } - } - - $preluActivationWeights = convertToTensor( - preluActivationWeights, 'prelu weights', 'fused conv2d'); - } - - const grad = (dy: Tensor4D, saved: Tensor[]) => { - util.assert( - dataFormat === 'NHWC', - () => `Error in gradient of fused conv2D: got dataFormat of ${ - dataFormat} but only NHWC is currently supported.`); - - const [$filter, x4D, y, $bias] = - saved as [Tensor4D, Tensor4D, Tensor4D, Tensor]; - - const dyActivation = getFusedDyActivation(dy, y, activation) as Tensor4D; - - util.assert( - conv_util.tupleValuesAreOne(dilations), - () => 'Error in gradient of fused conv2D: ' + - `dilation rates greater than 1 ` + - `are not yet supported in gradients. Got dilations '${dilations}'`); - - const xDer = - conv2DBackpropInput(x4D.shape, dyActivation, $filter, strides, pad); - const filterDer = - conv2DBackpropFilter(x4D, dyActivation, $filter.shape, strides, pad); - const der: Tensor[] = [xDer, filterDer]; - - if ($bias != null) { - const biasDer = getFusedBiasGradient($bias, dyActivation); - der.push(biasDer); - } - return der; - }; - - const inputs: FusedConv2DInputs = { - x: x4D, - filter: $filter, - bias: $bias, - preluActivationWeights: $preluActivationWeights - }; - - const attrs: FusedConv2DAttrs = { - strides, - pad, - dataFormat, - dilations, - dimRoundingMode, - activation, - leakyreluAlpha - }; - - // Depending on the the params passed in we will have different number of - // inputs and thus a a different number of elements in the gradient. - if (bias == null) { - const customOp = - customGrad((x4D: Tensor4D, filter: Tensor4D, save: GradSaveFunc) => { - let res: Tensor4D|Tensor3D = - // tslint:disable-next-line: no-unnecessary-type-assertion - ENGINE.runKernel( - FusedConv2D, inputs as unknown as NamedTensorMap, - attrs as unknown as NamedAttrMap); - - save([filter, x4D, res]); - - if (reshapedTo4D) { - // tslint:disable-next-line: no-unnecessary-type-assertion - res = reshape(res, [res.shape[1], res.shape[2], res.shape[3]]) as - Tensor3D; - } - - return {value: res, gradFunc: grad}; - }); - return customOp(x4D, $filter) as T; - } else { - const customOpWithBias = customGrad( - (x4D: Tensor4D, filter: Tensor4D, bias: Tensor, save: GradSaveFunc) => { - let res: Tensor4D|Tensor3D = ENGINE.runKernel( - FusedConv2D, inputs as unknown as NamedTensorMap, - attrs as unknown as NamedAttrMap); - - save([filter, x4D, res, bias]); - - if (reshapedTo4D) { - // tslint:disable-next-line: no-unnecessary-type-assertion - res = reshape(res, [res.shape[1], res.shape[2], res.shape[3]]) as - Tensor3D; - } - - return {value: res, gradFunc: grad}; - }); - - return customOpWithBias(x4D, $filter, $bias) as T; - } -} -export const conv2d = /* @__PURE__ */ op({fusedConv2d_}); diff --git a/tfjs-master/tfjs-core/src/ops/fused/depthwise_conv2d.ts b/tfjs-master/tfjs-core/src/ops/fused/depthwise_conv2d.ts deleted file mode 100644 index 8df3f7cab..000000000 --- a/tfjs-master/tfjs-core/src/ops/fused/depthwise_conv2d.ts +++ /dev/null @@ -1,260 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../../engine'; -import {customGrad} from '../../gradients'; -import {FusedDepthwiseConv2D, FusedDepthwiseConv2DAttrs, FusedDepthwiseConv2DInputs} from '../../kernel_names'; -import {NamedAttrMap} from '../../kernel_registry'; -import {Tensor, Tensor3D, Tensor4D} from '../../tensor'; -import {GradSaveFunc, NamedTensorMap} from '../../tensor_types'; -import {makeTypesMatch} from '../../tensor_util'; -import {convertToTensor} from '../../tensor_util_env'; -import {TensorLike} from '../../types'; -import * as util from '../../util'; -import {add} from '../add'; -import * as broadcast_util from '../broadcast_util'; -import * as conv_util from '../conv_util'; -import {depthwiseConv2d as unfusedDepthwiseConv2d} from '../depthwise_conv2d'; -import {depthwiseConv2dNativeBackpropFilter} from '../depthwise_conv2d_native_backprop_filter'; -import {depthwiseConv2dNativeBackpropInput} from '../depthwise_conv2d_native_backprop_input'; -import {Activation} from '../fused_types'; -import {applyActivation, getFusedBiasGradient, getFusedDyActivation, shouldFuse} from '../fused_util'; -import {op} from '../operation'; -import {reshape} from '../reshape'; - -/** - * Computes depthwise 2D convolution, optionally fused with adding a - * bias and applying an activation. - * - * Given a 4D `input` array and a `filter` array of shape - * `[filterHeight, filterWidth, inChannels, channelMultiplier]` containing - * `inChannels` convolutional filters of depth 1, this op applies a - * different filter to each input channel (expanding from 1 channel to - * `channelMultiplier` channels for each), then concatenates the results - * together. The output has `inChannels * channelMultiplier` channels. - * - * See - * [https://www.tensorflow.org/api_docs/python/tf/nn/depthwise_conv2d]( - * https://www.tensorflow.org/api_docs/python/tf/nn/depthwise_conv2d) - * for more details. - * - * @param obj An object with the following properties: - * @param x The input tensor, of rank 4 or rank 3, of shape - * `[batch, height, width, inChannels]`. If rank 3, batch of 1 is - * assumed. - * @param filter The filter tensor, rank 4, of shape - * `[filterHeight, filterWidth, inChannels, channelMultiplier]`. - * @param strides The strides of the convolution: `[strideHeight, - * strideWidth]`. If strides is a single number, then `strideHeight == - * strideWidth`. - * @param pad The type of padding algorithm. - * - `same` and stride 1: output will be of same size as input, - * regardless of filter size. - * - `valid`: output will be smaller than input if filter is larger - * than 1x1. - * - For more info, see this guide: - * [https://www.tensorflow.org/api_docs/python/tf/nn/convolution]( - * https://www.tensorflow.org/api_docs/python/tf/nn/convolution) - * @param dilations The dilation rates: `[dilationHeight, dilationWidth]` - * in which we sample input values across the height and width dimensions - * in atrous convolution. Defaults to `[1, 1]`. If `rate` is a single - * number, then `dilationHeight == dilationWidth`. If it is greater than - * 1, then all values of `strides` must be 1. - * @param dataFormat: An optional string from: "NHWC", "NCHW". Defaults to - * "NHWC". Specify the data format of the input and output data. With the - * default format "NHWC", the data is stored in the order of: [batch, - * height, width, channels]. Only "NHWC" is currently supported. - * @param dimRoundingMode A string from: 'ceil', 'round', 'floor'. If none is - * provided, it will default to truncate. - * @param bias Tensor to be added to the result. - * @param activation Name of activation kernel (defaults to `linear`). - * @param preluActivationWeights Tensor of prelu weights to be applied as part - * of a `prelu` activation, typically the same shape as `x`. - * @param leakyreluAlpha Optional. Alpha to be applied as part of a `leakyrelu` - * activation. - */ -function fusedDepthwiseConv2d_({ - x, - filter, - strides, - pad, - dataFormat = 'NHWC', - dilations = [1, 1], - dimRoundingMode, - bias, - activation = 'linear', - preluActivationWeights, - leakyreluAlpha -}: { - x: T|TensorLike, - filter: Tensor4D|TensorLike, - strides: [number, number]|number, - pad: 'valid'|'same'|number, - dataFormat?: 'NHWC'|'NCHW', - dilations?: [number, number]|number, - dimRoundingMode?: 'floor'|'round'|'ceil', - bias?: Tensor|TensorLike, - activation?: Activation, - preluActivationWeights?: Tensor, - leakyreluAlpha?: number -}): T { - if (shouldFuse(ENGINE.state.gradientDepth, activation) === false) { - let result = unfusedDepthwiseConv2d( - x, filter, strides, pad, dataFormat, dilations, dimRoundingMode); - if (bias != null) { - result = add(result, bias); - } - - return applyActivation( - result, activation, preluActivationWeights, leakyreluAlpha) as T; - } - - const $x = convertToTensor(x, 'x', 'depthwiseConv2d', 'float32'); - const $filter = - convertToTensor(filter, 'filter', 'depthwiseConv2d', 'float32'); - - let x4D = $x as Tensor4D; - let reshapedTo4D = false; - if ($x.rank === 3) { - reshapedTo4D = true; - x4D = reshape($x, [1, $x.shape[0], $x.shape[1], $x.shape[2]]); - } - util.assert( - x4D.rank === 4, - () => `Error in fused depthwiseConv2d: input must be rank 4, but got ` + - `rank ${x4D.rank}.`); - util.assert( - $filter.rank === 4, - () => `Error in fused depthwiseConv2d: filter must be rank 4, ` + - `but got rank ${$filter.rank}.`); - util.assert( - x4D.shape[3] === $filter.shape[2], - () => `Error in fused depthwiseConv2d: number of input channels ` + - `(${x4D.shape[3]}) must match the inChannels dimension in ` + - `filter ${$filter.shape[2]}.`); - if (dilations == null) { - dilations = [1, 1]; - } - util.assert( - conv_util.eitherStridesOrDilationsAreOne(strides, dilations), - () => - 'Error in fused depthwiseConv2d: Either strides or dilations must ' + - `be 1. Got strides ${strides} and dilations '${dilations}'`); - conv_util.checkPadOnDimRoundingMode( - 'fused depthwiseConv2d', pad, dimRoundingMode); - const convInfo = conv_util.computeConv2DInfo( - x4D.shape, $filter.shape, strides, dilations, pad, dimRoundingMode, - true /* depthwise */); - - let $bias: Tensor; - if (bias != null) { - $bias = convertToTensor(bias, 'bias', 'fused conv2d'); - [$bias] = makeTypesMatch($bias, $x); - - broadcast_util.assertAndGetBroadcastShape(convInfo.outShape, $bias.shape); - } - - let $preluActivationWeights: Tensor; - if (preluActivationWeights != null) { - $preluActivationWeights = convertToTensor( - preluActivationWeights, 'prelu weights', 'fused depthwiseConv2d'); - } - - const grad = (dy: Tensor4D, saved: Tensor[]) => { - util.assert( - conv_util.tupleValuesAreOne(dilations), - () => 'Error in gradient of fused depthwiseConv2d: dilation rates ' + - `greater than 1 are not yet supported. Got dilations ` + - `'${dilations}'`); - const [$filter, x4D, y, bias] = saved; - - const dyActivation = getFusedDyActivation(dy, y, activation) as Tensor4D; - - const xDer = depthwiseConv2dNativeBackpropInput( - (x4D as Tensor4D).shape, dyActivation, $filter as Tensor4D, strides, - pad, dilations, dimRoundingMode); - const filterDer = depthwiseConv2dNativeBackpropFilter( - x4D as Tensor4D, dyActivation, ($filter as Tensor4D).shape, strides, - pad, dilations, dimRoundingMode); - - if (bias != null) { - const biasDer = getFusedBiasGradient($bias, dyActivation); - return [xDer, filterDer, biasDer]; - } - return [xDer, filterDer]; - }; - - const inputs: FusedDepthwiseConv2DInputs = { - x: x4D, - filter: $filter, - bias: $bias, - preluActivationWeights: $preluActivationWeights - }; - const attrs: FusedDepthwiseConv2DAttrs = { - strides, - pad, - dataFormat, - dilations, - dimRoundingMode, - activation, - leakyreluAlpha - }; - - // Depending on the the params passed in we will have different number of - // inputs and thus a a different number of elements in the gradient. - if (bias == null) { - const customOp = - customGrad((x4D: Tensor4D, filter: Tensor4D, save: GradSaveFunc) => { - // tslint:disable-next-line: no-unnecessary-type-assertion - let res: Tensor4D|Tensor3D = ENGINE.runKernel( - FusedDepthwiseConv2D, inputs as unknown as NamedTensorMap, - attrs as unknown as NamedAttrMap); - - save([filter, x4D, res]); - - if (reshapedTo4D) { - // tslint:disable-next-line: no-unnecessary-type-assertion - res = reshape(res, [res.shape[1], res.shape[2], res.shape[3]]) as - Tensor3D; - } - - return {value: res, gradFunc: grad}; - }); - return customOp(x4D, $filter) as T; - } else { - const customOpWithBias = customGrad( - (x4D: Tensor4D, filter: Tensor4D, bias: Tensor, save: GradSaveFunc) => { - // tslint:disable-next-line: no-unnecessary-type-assertion - let res: Tensor4D|Tensor3D = ENGINE.runKernel( - FusedDepthwiseConv2D, inputs as unknown as NamedTensorMap, - attrs as unknown as NamedAttrMap); - - save([filter, x4D, res, bias]); - - if (reshapedTo4D) { - // tslint:disable-next-line: no-unnecessary-type-assertion - res = reshape(res, [res.shape[1], res.shape[2], res.shape[3]]) as - Tensor3D; - } - - return {value: res, gradFunc: grad}; - }); - - return customOpWithBias(x4D, $filter, $bias) as T; - } -} -export const depthwiseConv2d = /* @__PURE__ */ op({fusedDepthwiseConv2d_}); diff --git a/tfjs-master/tfjs-core/src/ops/fused/fused_conv2d_test.ts b/tfjs-master/tfjs-core/src/ops/fused/fused_conv2d_test.ts deleted file mode 100644 index e58714795..000000000 --- a/tfjs-master/tfjs-core/src/ops/fused/fused_conv2d_test.ts +++ /dev/null @@ -1,2125 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../../index'; -import {ALL_ENVS, describeWithFlags} from '../../jasmine_util'; -import {expectArraysClose} from '../../test_util'; - -function generateCaseInputs(totalSizeTensor: number, totalSizeFilter: number) { - const inp = new Array(totalSizeTensor); - const filt = new Array(totalSizeFilter); - - for (let i = 0; i < totalSizeTensor; i++) { - inp[i] = i * 0.001 - totalSizeTensor * 0.001 / 2; - } - for (let i = 0; i < totalSizeFilter; i++) { - const sign = i % 2 === 0 ? -1 : 1; - filt[i] = i * 0.001 * sign; - } - - return {input: inp, filter: filt}; -} - -describeWithFlags('fused conv2d', ALL_ENVS, () => { - it('basic', async () => { - const inputDepth = 2; - const inShape: [number, number, number, number] = [2, 2, 2, inputDepth]; - const outputDepth = 2; - const fSize = 1; - const pad = 0; - const stride = 1; - - const x = tf.tensor4d( - [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], inShape); - const w = - tf.tensor4d([-1, 1, -2, 0.5], [fSize, fSize, inputDepth, outputDepth]); - - const result = tf.fused.conv2d({x, filter: w, strides: stride, pad}); - expect(result.shape).toEqual([2, 2, 2, 2]); - const expected = - [-5, 2, -11, 5, -17, 8, -23, 11, -29, 14, -35, 17, -41, 20, -47, 23]; - - expectArraysClose(await result.data(), expected); - }); - - it('basic with relu', async () => { - const inputDepth = 2; - const inShape: [number, number, number, number] = [2, 2, 2, inputDepth]; - const outputDepth = 2; - const fSize = 1; - const pad = 0; - const stride = 1; - - const x = tf.tensor4d( - [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], inShape); - const w = - tf.tensor4d([-1, 1, -2, 0.5], [fSize, fSize, inputDepth, outputDepth]); - - const result = tf.fused.conv2d({ - x, - filter: w, - strides: stride, - pad, - dataFormat: 'NHWC', - dilations: [1, 1], - activation: 'relu' - }); - expect(result.shape).toEqual([2, 2, 2, 2]); - const expected = [0, 2, 0, 5, 0, 8, 0, 11, 0, 14, 0, 17, 0, 20, 0, 23]; - - expectArraysClose(await result.data(), expected); - }); - - it('relu with stride 2 x=[1,8,8,16] f=[3,3,16,1] s=[2,2] d=1 p=same', - async () => { - const inputDepth = 16; - const xSize = 8; - const inputShape: [number, number, number, number] = - [1, xSize, xSize, inputDepth]; - const outputDepth = 1; - const fSize = 3; - const pad = 'same'; - const stride: [number, number] = [2, 2]; - - // TODO(annxingyuan): Make this test work with large inputs - // https://github.com/tensorflow/tfjs/issues/3143 - const inputData = []; - for (let i = 0; i < xSize * xSize * inputDepth; i++) { - inputData.push(i % 5); - } - - const wData = []; - for (let i = 0; i < fSize * fSize * inputDepth * outputDepth; i++) { - wData.push(i % 5); - } - - const x = tf.tensor4d(inputData, inputShape); - const w = tf.tensor4d(wData, [fSize, fSize, inputDepth, outputDepth]); - - const result = tf.fused.conv2d({ - x, - filter: w, - strides: stride, - pad, - dataFormat: 'NHWC', - dilations: [1, 1], - activation: 'relu' - }); - expect(result.shape).toEqual([1, 4, 4, 1]); - expectArraysClose(await result.data(), new Float32Array([ - 854, 431, 568, 382, 580, 427, 854, 288, 431, 568, - 580, 289, 285, 570, 285, 258 - ])); - }); - - it('relu bias stride 2 x=[1,8,8,16] f=[3,3,16,1] s=[2,2] d=8 p=same', - async () => { - const inputDepth = 16; - const xSize = 8; - const inputShape: [number, number, number, number] = - [1, xSize, xSize, inputDepth]; - const outputDepth = 8; - const fSize = 3; - const pad = 'same'; - const stride: [number, number] = [2, 2]; - - const inputs = generateCaseInputs( - 1 * xSize * xSize * inputDepth, - fSize * fSize * inputDepth * outputDepth); - const x = tf.tensor4d(inputs.input, inputShape); - const w = - tf.tensor4d(inputs.filter, [fSize, fSize, inputDepth, outputDepth]); - const bias = tf.tensor1d([1, 4, 2, 3, 9, 6, 5, 8]); - const result = tf.fused.conv2d({ - x, - filter: w, - strides: stride, - pad, - dataFormat: 'NHWC', - dilations: [1, 1], - activation: 'relu', - bias - }); - expect(result.shape).toEqual([1, 4, 4, 8]); - expectArraysClose(await result.data(), new Float32Array([ - 25.75398063659668, - 0, - 26.857805252075195, - 0, - 33.961631774902344, - 0, - 30.065458297729492, - 0, - 23.118206024169922, - 0, - 24.212820053100586, - 0, - 31.307422637939453, - 0, - 27.402034759521484, - 0, - 20.482431411743164, - 0, - 21.567821502685547, - 0, - 28.653217315673828, - 0, - 24.73861312866211, - 0, - 11.078080177307129, - 0, - 12.130399703979492, - 0, - 19.182720184326172, - 0, - 15.235037803649902, - 0, - 4.6677775382995605, - 0.31717729568481445, - 5.697869777679443, - 0, - 12.727968215942383, - 2.2569849491119385, - 8.758066177368164, - 4.226885795593262, - 2.0319995880126953, - 2.9575586318969727, - 3.052880048751831, - 1.9366796016693115, - 10.073760032653809, - 4.915799617767334, - 6.094639778137207, - 6.89492130279541, - 0, - 5.5979437828063965, - 0.4078875780105591, - 4.586280822753906, - 7.419551849365234, - 7.5746169090271, - 3.43121600151062, - 9.562952041625977, - 0, - 6.404943943023682, - 0, - 5.401776313781738, - 6.5998077392578125, - 8.398608207702637, - 2.602976083755493, - 10.395440101623535, - 0, - 21.440250396728516, - 0, - 20.483882904052734, - 0, - 23.527509689331055, - 0, - 25.571144104003906, - 0, - 24.080629348754883, - 0, - 23.133480072021484, - 0, - 26.186328887939453, - 0, - 28.239177703857422, - 0, - 26.721012115478516, - 0, - 25.783079147338867, - 0, - 28.84514808654785, - 0, - 30.907209396362305, - 0, - 18.914127349853516, - 0, - 17.960111618041992, - 0, - 21.006093978881836, - 0, - 23.052082061767578, - 0, - 17.89089584350586, - 0, - 16.95684814453125, - 0, - 20.022798538208008, - 0, - 22.088754653930664, - 0, - 19.06132698059082, - 0, - 18.133424758911133, - 0, - 21.205520629882812, - 0, - 23.27761459350586, - 0, - 20.23175811767578, - 0, - 19.309999465942383, - 0, - 22.388240814208984, - 0, - 24.46647834777832, - 0, - 13.584352493286133, - 0, - 12.6395845413208, - 0, - 15.694815635681152, - 0, - 17.750045776367188 - ])); - }); - - it('prelu bias stride 2 x=[1,8,8,16] f=[3,3,16,1] s=[2,2] d=8 p=same', - async () => { - const inputDepth = 16; - const xSize = 8; - const inputShape: [number, number, number, number] = - [1, xSize, xSize, inputDepth]; - const outputDepth = 8; - const fSize = 3; - const pad = 'same'; - const stride: [number, number] = [2, 2]; - - const inputs = generateCaseInputs( - 1 * xSize * xSize * inputDepth, - fSize * fSize * inputDepth * outputDepth); - const x = tf.tensor4d(inputs.input, inputShape); - const w = - tf.tensor4d(inputs.filter, [fSize, fSize, inputDepth, outputDepth]); - const bias = tf.tensor1d([1, 4, 2, 3, 9, 6, 5, 8]); - const preluActivationWeights = tf.tensor1d([1, 2, 3, 4, 5, 6, 7, 8]); - - const result = tf.fused.conv2d({ - x, - filter: w, - strides: stride, - pad, - dataFormat: 'NHWC', - dilations: [1, 1], - activation: 'prelu', - preluActivationWeights, - bias - }); - expect(result.shape).toEqual([1, 4, 4, 8]); - expectArraysClose( - await result.data(), new Float32Array([ - 25.75398063659668, -41.61178970336914, 26.857805252075195, - -87.63885498046875, 33.961631774902344, -114.0812759399414, - 30.065458297729492, -136.93893432617188, 23.118206024169922, - -36.33102035522461, 24.212820053100586, -77.04048156738281, - 31.307422637939453, -98.12835693359375, 27.402034759521484, - -115.5947265625, 20.482431411743164, -31.050262451171875, - 21.567821502685547, -66.44209289550781, 28.653217315673828, - -82.17544555664062, 24.73861312866211, -94.25041198730469, - 11.078080177307129, -12.208478927612305, 12.130399703979492, - -28.626232147216797, 19.182720184326172, -25.253299713134766, - 15.235037803649902, -18.08960723876953, 4.6677775382995605, - 0.31717729568481445, 5.697869777679443, -2.8516759872436523, - 12.727968215942383, 2.2569849491119385, 8.758066177368164, - 4.226885795593262, 2.0319995880126953, 2.9575586318969727, - 3.052880048751831, 1.9366796016693115, 10.073760032653809, - 4.915799617767334, 6.094639778137207, 6.89492130279541, - -0.6037763357162476, 5.5979437828063965, 0.4078875780105591, - 4.586280822753906, 7.419551849365234, 7.5746169090271, - 3.43121600151062, 9.562952041625977, -1.4065279960632324, - 6.404943943023682, -1.2100803852081299, 5.401776313781738, - 6.5998077392578125, 8.398608207702637, 2.602976083755493, - 10.395440101623535, -16.418434143066406, 21.440250396728516, - -46.38618850708008, 20.483882904052734, -42.52848815917969, - 23.527509689331055, -87.84530639648438, 25.571144104003906, - -19.054208755493164, 24.080629348754883, -54.32115936279297, - 23.133480072021484, -55.79951477050781, 26.186328887939453, - -106.48924255371094, 28.239177703857422, -21.689987182617188, - 26.721012115478516, -62.25614929199219, 25.783079147338867, - -69.070556640625, 28.84514808654785, -125.13325500488281, - 30.907209396362305, -13.891133308410645, 18.914127349853516, - -38.81135940551758, 17.960111618041992, -29.915504455566406, - 21.006093978881836, -70.20361328125, 23.052082061767578, - -12.857919692993164, 17.89089584350586, -35.771610260009766, - 16.95684814453125, -24.949115753173828, 20.022798538208008, - -63.39042282104492, 22.088754653930664, -14.02528190612793, - 19.06132698059082, -39.2921257019043, 18.133424758911133, - -30.847349166870117, 21.205520629882812, -71.69097137451172, - 23.27761459350586, -15.192638397216797, 20.23175811767578, - -42.8126335144043, 19.309999465942383, -36.74560546875, - 22.388240814208984, -79.99152374267578, 24.46647834777832, - -8.556736946105957, 13.584352493286133, -22.835901260375977, - 12.6395845413208, -3.336000442504883, 15.694815635681152, - -33.0570182800293, 17.750045776367188 - ])); - }); - - it('relu6 bias stride 2 x=[1,8,8,16] f=[3,3,16,8] s=[2,2] d=8 p=same', - async () => { - const inputDepth = 16; - const xSize = 8; - const inputShape: [number, number, number, number] = - [1, xSize, xSize, inputDepth]; - const outputDepth = 8; - const fSize = 3; - const pad = 'same'; - const stride: [number, number] = [2, 2]; - - const inputs = generateCaseInputs( - 1 * xSize * xSize * inputDepth, - fSize * fSize * inputDepth * outputDepth); - const x = tf.tensor4d(inputs.input, inputShape); - const w = - tf.tensor4d(inputs.filter, [fSize, fSize, inputDepth, outputDepth]); - const bias = tf.tensor1d([1, 4, 2, 3, 9, 6, 5, 8]); - - const result = tf.fused.conv2d({ - x, - filter: w, - strides: stride, - pad, - dataFormat: 'NHWC', - dilations: [1, 1], - activation: 'relu6', - bias - }); - expect(result.shape).toEqual([1, 4, 4, 8]); - const resultData = await result.data(); - expectArraysClose(resultData, new Float32Array([ - 6, - 0, - 6, - 0, - 6, - 0, - 6, - 0, - 6, - 0, - 6, - 0, - 6, - 0, - 6, - 0, - 6, - 0, - 6, - 0, - 6, - 0, - 6, - 0, - 6, - 0, - 6, - 0, - 6, - 0, - 6, - 0, - 4.6677775382995605, - 0.31717729568481445, - 5.697869777679443, - 0, - 6, - 2.2569849491119385, - 6, - 4.226885795593262, - 2.0319995880126953, - 2.9575586318969727, - 3.052880048751831, - 1.9366796016693115, - 6, - 4.915799617767334, - 6, - 6, - 0, - 5.5979437828063965, - 0.4078875780105591, - 4.586280822753906, - 6, - 6, - 3.43121600151062, - 6, - 0, - 6, - 0, - 5.401776313781738, - 6, - 6, - 2.602976083755493, - 6, - 0, - 6, - 0, - 6, - 0, - 6, - 0, - 6, - 0, - 6, - 0, - 6, - 0, - 6, - 0, - 6, - 0, - 6, - 0, - 6, - 0, - 6, - 0, - 6, - 0, - 6, - 0, - 6, - 0, - 6, - 0, - 6, - 0, - 6, - 0, - 6, - 0, - 6, - 0, - 6, - 0, - 6, - 0, - 6, - 0, - 6, - 0, - 6, - 0, - 6, - 0, - 6, - 0, - 6, - 0, - 6, - 0, - 6, - 0, - 6, - 0, - 6, - 0, - 6 - ])); - }); - - it('leakyrelu bias stride 2 x=[1,8,8,16] f=[3,3,16,1] s=[2,2] d=8 p=same', - async () => { - const inputDepth = 16; - const xSize = 8; - const inputShape: [number, number, number, number] = - [1, xSize, xSize, inputDepth]; - const outputDepth = 8; - const fSize = 3; - const pad = 'same'; - const stride: [number, number] = [2, 2]; - - const inputs = generateCaseInputs( - 1 * xSize * xSize * inputDepth, - fSize * fSize * inputDepth * outputDepth); - const x = tf.tensor4d(inputs.input, inputShape); - const w = - tf.tensor4d(inputs.filter, [fSize, fSize, inputDepth, outputDepth]); - const bias = tf.tensor1d([1, 4, 2, 3, 9, 6, 5, 8]); - const leakyreluAlpha = 0.3; - - const result = tf.fused.conv2d({ - x, - filter: w, - strides: stride, - pad, - dataFormat: 'NHWC', - dilations: [1, 1], - activation: 'leakyrelu', - leakyreluAlpha, - bias - }); - expect(result.shape).toEqual([1, 4, 4, 8]); - expectArraysClose( - await result.data(), new Float32Array([ - 25.75398063659668, -6.241768836975098, 26.857805252075195, - -6.5729146003723145, 33.961631774902344, -5.704063892364502, - 30.065458297729492, -5.135210037231445, 23.118206024169922, - -5.449653148651123, 24.212820053100586, -5.778036117553711, - 31.307422637939453, -4.906418323516846, 27.402034759521484, - -4.334802627563477, 20.482431411743164, -4.657539367675781, - 21.567821502685547, -4.983157157897949, 28.653217315673828, - -4.108772277832031, 24.73861312866211, -3.534390687942505, - 11.078080177307129, -1.8312718868255615, 12.130399703979492, - -2.1469674110412598, 19.182720184326172, -1.262665033340454, - 15.235037803649902, -0.6783602833747864, 4.6677775382995605, - 0.31717729568481445, 5.697869777679443, -0.21387571096420288, - 12.727968215942383, 2.2569849491119385, 8.758066177368164, - 4.226885795593262, 2.0319995880126953, 2.9575586318969727, - 3.052880048751831, 1.9366796016693115, 10.073760032653809, - 4.915799617767334, 6.094639778137207, 6.89492130279541, - -0.18113291263580322, 5.5979437828063965, 0.4078875780105591, - 4.586280822753906, 7.419551849365234, 7.5746169090271, - 3.43121600151062, 9.562952041625977, -0.42195841670036316, - 6.404943943023682, -0.12100804597139359, 5.401776313781738, - 6.5998077392578125, 8.398608207702637, 2.602976083755493, - 10.395440101623535, -4.925530433654785, 21.440250396728516, - -4.6386189460754395, 20.483882904052734, -2.5517091751098633, - 23.527509689331055, -3.764799118041992, 25.571144104003906, - -5.7162628173828125, 24.080629348754883, -5.432116508483887, - 23.133480072021484, -3.347970962524414, 26.186328887939453, - -4.5638251304626465, 28.239177703857422, -6.5069966316223145, - 26.721012115478516, -6.225615501403809, 25.783079147338867, - -4.144233703613281, 28.84514808654785, -5.36285400390625, - 30.907209396362305, -4.167340278625488, 18.914127349853516, - -3.881135940551758, 17.960111618041992, -1.794930338859558, - 21.006093978881836, -3.0087265968322754, 23.052082061767578, - -3.8573760986328125, 17.89089584350586, -3.5771610736846924, - 16.95684814453125, -1.4969470500946045, 20.022798538208008, - -2.7167325019836426, 22.088754653930664, -4.207584857940674, - 19.06132698059082, -3.9292125701904297, 18.133424758911133, - -1.8508410453796387, 21.205520629882812, -3.0724704265594482, - 23.27761459350586, -4.557791709899902, 20.23175811767578, - -4.28126335144043, 19.309999465942383, -2.2047364711761475, - 22.388240814208984, -3.428208351135254, 24.46647834777832, - -2.567021131515503, 13.584352493286133, -2.283590316772461, - 12.6395845413208, -0.20016004145145416, 15.694815635681152, - -1.41672945022583, 17.750045776367188 - ])); - }); - - it('throws when dimRoundingMode is set and pad is same', () => { - const inputDepth = 16; - const xSize = 8; - const inputShape: [number, number, number, number] = - [1, xSize, xSize, inputDepth]; - const outputDepth = 8; - const fSize = 3; - const pad = 'same'; - const stride: [number, number] = [2, 2]; - - const inputs = generateCaseInputs( - 1 * xSize * xSize * inputDepth, - fSize * fSize * inputDepth * outputDepth); - const x = tf.tensor4d(inputs.input, inputShape); - const w = - tf.tensor4d(inputs.filter, [fSize, fSize, inputDepth, outputDepth]); - const bias = tf.tensor1d([1, 4, 2, 3, 9, 6, 5, 8]); - const leakyreluAlpha = 0.3; - - expect(() => tf.fused.conv2d({ - x, - filter: w, - strides: stride, - pad, - dataFormat: 'NHWC', - dilations: [1, 1], - activation: 'leakyrelu', - leakyreluAlpha, - bias, - dimRoundingMode: 'round' - })).toThrowError(); - }); - - it('throws when dimRoundingMode is set and pad is valid', () => { - const inputDepth = 16; - const xSize = 8; - const inputShape: [number, number, number, number] = - [1, xSize, xSize, inputDepth]; - const outputDepth = 8; - const fSize = 3; - const pad = 'valid'; - const stride: [number, number] = [2, 2]; - - const inputs = generateCaseInputs( - 1 * xSize * xSize * inputDepth, - fSize * fSize * inputDepth * outputDepth); - const x = tf.tensor4d(inputs.input, inputShape); - const w = - tf.tensor4d(inputs.filter, [fSize, fSize, inputDepth, outputDepth]); - const bias = tf.tensor1d([1, 4, 2, 3, 9, 6, 5, 8]); - const leakyreluAlpha = 0.3; - - expect(() => tf.fused.conv2d({ - x, - filter: w, - strides: stride, - pad, - dataFormat: 'NHWC', - dilations: [1, 1], - activation: 'leakyrelu', - leakyreluAlpha, - bias, - dimRoundingMode: 'round' - })).toThrowError(); - }); - - it('throws when dimRoundingMode is set and pad is a non-integer number', - () => { - const inputDepth = 16; - const xSize = 8; - const inputShape: [number, number, number, number] = - [1, xSize, xSize, inputDepth]; - const outputDepth = 8; - const fSize = 3; - const pad = 1.2; - const stride: [number, number] = [2, 2]; - - const inputs = generateCaseInputs( - 1 * xSize * xSize * inputDepth, - fSize * fSize * inputDepth * outputDepth); - const x = tf.tensor4d(inputs.input, inputShape); - const w = - tf.tensor4d(inputs.filter, [fSize, fSize, inputDepth, outputDepth]); - const bias = tf.tensor1d([1, 4, 2, 3, 9, 6, 5, 8]); - const leakyreluAlpha = 0.3; - - expect(() => tf.fused.conv2d({ - x, - filter: w, - strides: stride, - pad, - dataFormat: 'NHWC', - dilations: [1, 1], - activation: 'leakyrelu', - leakyreluAlpha, - bias, - dimRoundingMode: 'round' - })).toThrowError(); - }); - - it('throws when dimRoundingMode is set and pad is explicit by non-integer ' + - 'number', - () => { - const inputDepth = 16; - const xSize = 8; - const inputShape: [number, number, number, number] = - [1, xSize, xSize, inputDepth]; - const outputDepth = 8; - const fSize = 3; - const pad = [[0, 0], [0, 2.1], [1, 1], [0, 0]] as - tf.backend_util.ExplicitPadding; - const stride: [number, number] = [2, 2]; - - const inputs = generateCaseInputs( - 1 * xSize * xSize * inputDepth, - fSize * fSize * inputDepth * outputDepth); - const x = tf.tensor4d(inputs.input, inputShape); - const w = - tf.tensor4d(inputs.filter, [fSize, fSize, inputDepth, outputDepth]); - const bias = tf.tensor1d([1, 4, 2, 3, 9, 6, 5, 8]); - const leakyreluAlpha = 0.3; - - expect(() => tf.fused.conv2d({ - x, - filter: w, - strides: stride, - pad, - dataFormat: 'NHWC', - dilations: [1, 1], - activation: 'leakyrelu', - leakyreluAlpha, - bias, - dimRoundingMode: 'round' - })).toThrowError(); - }); - - it('basic with bias', async () => { - const inputDepth = 2; - const inShape: [number, number, number, number] = [2, 2, 2, inputDepth]; - const outputDepth = 2; - const fSize = 1; - const pad = 0; - const stride = 1; - - const x = tf.tensor4d( - [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], inShape); - const w = - tf.tensor4d([-1, 1, -2, 0.5], [fSize, fSize, inputDepth, outputDepth]); - - const result = tf.fused.conv2d({ - x, - filter: w, - strides: stride, - pad, - dataFormat: 'NHWC', - dilations: [1, 1], - bias: tf.tensor1d([5, 6]) - }); - expect(result.shape).toEqual([2, 2, 2, 2]); - const expected = - [0, 8, -6, 11, -12, 14, -18, 17, -24, 20, -30, 23, -36, 26, -42, 29]; - - expectArraysClose(await result.data(), expected); - }); - - it('basic with explicit padding', async () => { - const inputDepth = 1; - const outputDepth = 1; - const pad = - [[0, 0], [1, 2], [0, 1], [0, 0]] as tf.backend_util.ExplicitPadding; - const stride = 1; - const dataFormat = 'NHWC'; - const dilation = 1; - - const x = tf.tensor3d([1, 2, 3, 4, 5, 6, 7, 8], [4, 2, inputDepth]); - const w = - tf.tensor4d([3, 1, 5, 0, 2, 7, 8, 9], [4, 2, inputDepth, outputDepth]); - - const result = tf.fused.conv2d( - {x, filter: w, strides: stride, pad, dataFormat, dilations: dilation}); - - const resultData = await result.data(); - expect(result.shape).toEqual([4, 2, 1]); - expectArraysClose(resultData, [133, 66, 200, 102, 108, 58, 56, 58]); - }); - - it('basic with elu', async () => { - const inputDepth = 2; - const inShape: [number, number, number, number] = [2, 2, 2, inputDepth]; - const outputDepth = 2; - const fSize = 1; - const pad = 0; - const stride = 1; - - const x = tf.tensor4d( - [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], inShape); - const w = - tf.tensor4d([-1, 1, -2, 0.5], [fSize, fSize, inputDepth, outputDepth]); - - const result = tf.fused.conv2d({ - x, - filter: w, - strides: stride, - pad, - dataFormat: 'NHWC', - dilations: [1, 1], - activation: 'elu' - }); - expect(result.shape).toEqual([2, 2, 2, 2]); - const expected = - [-0.99326, 2, -1, 5, -1, 8, -1, 11, -1, 14, -1, 17, -1, 20, -1, 23]; - - expectArraysClose(await result.data(), expected); - }); - - it('basic with prelu', async () => { - const inputDepth = 2; - const inShape: [number, number, number, number] = [2, 2, 2, inputDepth]; - const outputDepth = 2; - const fSize = 1; - const pad = 0; - const stride = 1; - - const x = tf.tensor4d( - [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], inShape); - const alpha = tf.tensor3d([0.25, 0.75], [1, 1, 2]); - const w = - tf.tensor4d([-1, 1, -2, 0.5], [fSize, fSize, inputDepth, outputDepth]); - - const result = tf.fused.conv2d({ - x, - filter: w, - strides: stride, - pad, - dataFormat: 'NHWC', - dilations: [1, 1], - activation: 'prelu', - preluActivationWeights: alpha - }); - expect(result.shape).toEqual([2, 2, 2, 2]); - const expected = [ - -1.25, 2, -2.75, 5, -4.25, 8, -5.75, 11, -7.25, 14, -8.75, 17, -10.25, 20, - -11.75, 23 - ]; - - expectArraysClose(await result.data(), expected); - }); - - it('basic with leakyrelu', async () => { - const inputDepth = 2; - const inShape: [number, number, number, number] = [2, 2, 2, inputDepth]; - const outputDepth = 2; - const fSize = 1; - const pad = 0; - const stride = 1; - - const x = tf.tensor4d( - [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], inShape); - const alpha = 0.3; - const w = - tf.tensor4d([-1, 1, -2, 0.5], [fSize, fSize, inputDepth, outputDepth]); - - const result = tf.fused.conv2d({ - x, - filter: w, - strides: stride, - pad, - dataFormat: 'NHWC', - dilations: [1, 1], - activation: 'leakyrelu', - leakyreluAlpha: alpha - }); - expect(result.shape).toEqual([2, 2, 2, 2]); - const expected = [ - -1.5, 2, -3.3000001907348633, 5, -5.100000381469727, 8, - -6.900000095367432, 11, -8.700000762939453, 14, -10.5, 17, - -12.300000190734863, 20, -14.100000381469727, 23 - ]; - - expectArraysClose(await result.data(), expected); - }); - - it('basic with sigmoid', async () => { - const inputDepth = 2; - const inShape: [number, number, number, number] = [2, 2, 2, inputDepth]; - const outputDepth = 2; - const fSize = 1; - const pad = 0; - const stride = 1; - - const x = tf.tensor4d( - [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], inShape); - const alpha = 0.3; - const w = tf.tensor4d( - [-0.1, 0.1, -0.2, 0.05], [fSize, fSize, inputDepth, outputDepth]); - - const result = tf.fused.conv2d({ - x, - filter: w, - strides: stride, - pad, - dataFormat: 'NHWC', - dilations: [1, 1], - activation: 'sigmoid', - leakyreluAlpha: alpha - }); - expect(result.shape).toEqual([2, 2, 2, 2]); - const expected = [ - 0.3775407, 0.549834, 0.24973989, 0.6224593, 0.15446526, 0.6899744, - 0.09112296, 0.7502601, 0.0521535, 0.80218387, 0.02931219, 0.84553474, - 0.0163025, 0.8807971, 0.0090133, 0.908877 - ]; - - expectArraysClose(await result.data(), expected); - }); - - it('basic with broadcasted bias and relu', async () => { - const inputDepth = 2; - const inShape: [number, number, number, number] = [2, 2, 2, inputDepth]; - const outputDepth = 2; - const fSize = 1; - const pad = 0; - const stride = 1; - - const x = tf.tensor4d( - [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], inShape); - const w = - tf.tensor4d([-1, 1, -2, 0.5], [fSize, fSize, inputDepth, outputDepth]); - - const result = tf.fused.conv2d({ - x, - filter: w, - strides: stride, - pad, - dataFormat: 'NHWC', - dilations: [1, 1], - bias: tf.scalar(5), - activation: 'relu' - }); - expect(result.shape).toEqual([2, 2, 2, 2]); - const expected = [0, 7, 0, 10, 0, 13, 0, 16, 0, 19, 0, 22, 0, 25, 0, 28]; - - expectArraysClose(await result.data(), expected); - }); - - it('basic in NCHW', async () => { - const inputDepth = 2; - const inShape: [number, number, number, number] = [1, inputDepth, 2, 2]; - const outputDepth = 2; - const fSize = 1; - const pad = 0; - const stride = 1; - - const x = tf.tensor4d([1, 3, 5, 7, 2, 4, 6, 8], inShape); - const w = - tf.tensor4d([-1, 1, -2, 0.5], [fSize, fSize, inputDepth, outputDepth]); - - const result = tf.fused.conv2d( - {x, filter: w, strides: stride, pad, dataFormat: 'NCHW'}); - expect(result.shape).toEqual([1, 2, 2, 2]); - const expected = [-5, -11, -17, -23, 2, 5, 8, 11]; - expectArraysClose(await result.data(), expected); - }); - - it('basic in NCHW with scalar bias', async () => { - const inputDepth = 4; - const inputShape: [number, number, number, number] = [1, inputDepth, 2, 2]; - const outputDepth = 4; - const fSize = 1; - const pad = 'same'; - const stride = 1; - const dataFormat = 'NCHW'; - const dilation = 1; - - const x = tf.tensor4d( - [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4], inputShape); - const w = tf.tensor4d( - [3, 3, 3, 3, 1, 1, 1, 1, 5, 5, 5, 5, 0, 0, 0, 0], - [fSize, fSize, inputDepth, outputDepth]); - const bias = tf.scalar(1); - - const result = tf.fused.conv2d({ - x, - filter: w, - strides: stride, - pad, - dataFormat, - dilations: dilation, - bias - }); - - expect(result.shape).toEqual([1, 4, 2, 2]); - const expected = - [10, 19, 28, 37, 10, 19, 28, 37, 10, 19, 28, 37, 10, 19, 28, 37]; - expectArraysClose(await result.data(), expected); - }); - - it('basic in NCHW with 1-D bias', async () => { - const inputDepth = 4; - const inputShape: [number, number, number, number] = [1, inputDepth, 2, 2]; - const outputDepth = 4; - const fSize = 1; - const pad = 'same'; - const stride = 1; - const dataFormat = 'NCHW'; - const dilation = 1; - - const x = tf.tensor4d( - [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4], inputShape); - const w = tf.tensor4d( - [3, 3, 3, 3, 1, 1, 1, 1, 5, 5, 5, 5, 0, 0, 0, 0], - [fSize, fSize, inputDepth, outputDepth]); - const bias = tf.tensor1d([1, 2, 1, 2]); - - const result = tf.fused.conv2d({ - x, - filter: w, - strides: stride, - pad, - dataFormat, - dilations: dilation, - bias - }); - - expect(result.shape).toEqual([1, 4, 2, 2]); - const expected = - [10, 19, 28, 37, 11, 20, 29, 38, 10, 19, 28, 37, 11, 20, 29, 38]; - expectArraysClose(await result.data(), expected); - }); - - it('basic in NCHW with bias and multiple batches', async () => { - const inputDepth = 4; - const inputShape: [number, number, number, number] = [2, inputDepth, 2, 2]; - const outputDepth = 4; - const fSize = 1; - const pad = 'same'; - const stride = 1; - const dataFormat = 'NCHW'; - const dilation = 1; - - const x = tf.tensor4d( - [ - 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, - 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4 - ], - inputShape); - const w = tf.tensor4d( - [3, 3, 3, 3, 1, 1, 1, 1, 5, 5, 5, 5, 0, 0, 0, 0], - [fSize, fSize, inputDepth, outputDepth]); - const bias = tf.tensor1d([1, 2, 1, 2]); - - const result = tf.fused.conv2d({ - x, - filter: w, - strides: stride, - pad, - dataFormat, - dilations: dilation, - bias - }); - - expect(result.shape).toEqual([2, 4, 2, 2]); - const expected = [ - 10, 19, 28, 37, 11, 20, 29, 38, 10, 19, 28, 37, 11, 20, 29, 38, - 10, 19, 28, 37, 11, 20, 29, 38, 10, 19, 28, 37, 11, 20, 29, 38 - ]; - expectArraysClose(await result.data(), expected); - }); - - it('basic in NCHW with scalar PReLU actiavation', async () => { - const inputDepth = 2; - const inShape: [number, number, number, number] = [1, inputDepth, 2, 2]; - const outputDepth = 2; - const fSize = 1; - const dataFormat = 'NCHW'; - const dilation = 1; - const pad = 0; - const stride = 1; - - const x = tf.tensor4d([1, 2, 3, 4, 5, 6, 7, 8], inShape); - const w = - tf.tensor4d([-1, 1, -2, 0.5], [fSize, fSize, inputDepth, outputDepth]); - const alpha = tf.scalar(10); - - const result = tf.fused.conv2d({ - x, - filter: w, - strides: stride, - pad, - dataFormat, - dilations: dilation, - activation: 'prelu', - preluActivationWeights: alpha - }); - - expect(result.shape).toEqual([1, 2, 2, 2]); - const expected = [-110, -140, -170, -200, 3.5, 5, 6.5, 8]; - expectArraysClose(await result.data(), expected); - }); - - it('basic in NCHW with 1-D PReLU actiavation', async () => { - const inputDepth = 2; - const inShape: [number, number, number, number] = [1, inputDepth, 2, 2]; - const outputDepth = 2; - const fSize = 1; - const dataFormat = 'NCHW'; - const dilation = 1; - const pad = 0; - const stride = 1; - - const x = tf.tensor4d([1, 2, 3, 4, 5, 6, 7, 8], inShape); - const w = - tf.tensor4d([-1, 1, -2, 0.5], [fSize, fSize, inputDepth, outputDepth]); - const alpha = tf.tensor1d([10, 100]); - - const result = tf.fused.conv2d({ - x, - filter: w, - strides: stride, - pad, - dataFormat, - dilations: dilation, - activation: 'prelu', - preluActivationWeights: alpha - }); - - expect(result.shape).toEqual([1, 2, 2, 2]); - const expected = [-110, -140, -170, -200, 3.5, 5, 6.5, 8]; - expectArraysClose(await result.data(), expected); - }); - - it('basic in NCHW with 3-D PReLU actiavation', async () => { - const inputDepth = 2; - const inShape: [number, number, number, number] = [1, inputDepth, 2, 2]; - const outputDepth = 2; - const fSize = 1; - const dataFormat = 'NCHW'; - const dilation = 1; - const pad = 0; - const stride = 1; - - const x = tf.tensor4d([1, 2, 3, 4, 5, 6, 7, 8], inShape); - const w = - tf.tensor4d([-1, -1, -2, -2], [fSize, fSize, inputDepth, outputDepth]); - const alpha = tf.tensor3d([1, 10], [2, 1, 1]); - - const result = tf.fused.conv2d({ - x, - filter: w, - strides: stride, - pad, - dataFormat, - dilations: dilation, - activation: 'prelu', - preluActivationWeights: alpha - }); - - expect(result.shape).toEqual([1, 2, 2, 2]); - const expected = [-11, -14, -17, -20, -110, -140, -170, -200]; - expectArraysClose(await result.data(), expected); - }); - - it('basic in NCHW with full 3-D PReLU actiavation', async () => { - const inputDepth = 2; - const inShape: [number, number, number, number] = [1, inputDepth, 2, 2]; - const outputDepth = 2; - const fSize = 1; - const dataFormat = 'NCHW'; - const dilation = 1; - const pad = 0; - const stride = 1; - - const x = tf.tensor4d([1, 2, 3, 4, 5, 6, 7, 8], inShape); - const w = - tf.tensor4d([-1, -1, -2, -2], [fSize, fSize, inputDepth, outputDepth]); - const alpha = tf.tensor3d([1, 2, 3, 4, 5, 6, 7, 8], [2, 2, 2]); - - const result = tf.fused.conv2d({ - x, - filter: w, - strides: stride, - pad, - dataFormat, - dilations: dilation, - activation: 'prelu', - preluActivationWeights: alpha - }); - - expect(result.shape).toEqual([1, 2, 2, 2]); - const expected = [-11, -28, -51, -80, -55, -84, -119, -160]; - expectArraysClose(await result.data(), expected); - }); - - it('im2row', async () => { - const inputDepth = 1; - const inputShape: [number, number, number] = [4, 4, inputDepth]; - const outputDepth = 3; - const fSize = 1; - const pad = 'same'; - const strides: [number, number] = [2, 2]; - - const x = tf.tensor3d( - [ - 10, 30, 50, 70, 20, 40, 60, 80, -10, -30, -50, -70, -20, -40, -60, -80 - ], - inputShape); - const w = tf.tensor4d([1, 0.5, 1], [fSize, fSize, inputDepth, outputDepth]); - - const result = tf.fused.conv2d({x, filter: w, strides, pad}); - - expectArraysClose( - await result.data(), - [10, 5, 10, 50, 25, 50, -10, -5, -10, -50, -25, -50]); - }); - - it('im2row with relu', async () => { - const inputDepth = 1; - const inputShape: [number, number, number] = [4, 4, inputDepth]; - const outputDepth = 3; - const fSize = 1; - const pad = 'same'; - const strides: [number, number] = [2, 2]; - - const x = tf.tensor3d( - [ - 10, 30, 50, 70, 20, 40, 60, 80, -10, -30, -50, -70, -20, -40, -60, -80 - ], - inputShape); - const w = tf.tensor4d([1, 0.5, 1], [fSize, fSize, inputDepth, outputDepth]); - - const result = tf.fused.conv2d({ - x, - filter: w, - strides, - pad, - dataFormat: 'NHWC', - dilations: [1, 1], - activation: 'relu' - }); - - expectArraysClose( - await result.data(), [10, 5, 10, 50, 25, 50, 0, 0, 0, 0, 0, 0]); - }); - - it('im2row with prelu', async () => { - const inputDepth = 1; - const inputShape: [number, number, number] = [4, 4, inputDepth]; - const outputDepth = 3; - const fSize = 1; - const pad = 'same'; - const strides: [number, number] = [2, 2]; - - const x = tf.tensor3d( - [ - 10, 30, 50, 70, 20, 40, 60, 80, -10, -30, -50, -70, -20, -40, -60, -80 - ], - inputShape); - const w = tf.tensor4d([1, 0.5, 1], [fSize, fSize, inputDepth, outputDepth]); - const alpha = tf.tensor3d([0.5], [1, 1, inputDepth]); - - const result = tf.fused.conv2d({ - x, - filter: w, - strides, - pad, - dataFormat: 'NHWC', - dilations: [1, 1], - activation: 'prelu', - preluActivationWeights: alpha - }); - - expectArraysClose( - await result.data(), - [10, 5, 10, 50, 25, 50, -5, -2.5, -5, -25, -12.5, -25]); - }); - - it('im2row with leakyrelu', async () => { - const inputDepth = 1; - const inputShape: [number, number, number] = [4, 4, inputDepth]; - const outputDepth = 3; - const fSize = 1; - const pad = 'same'; - const strides: [number, number] = [2, 2]; - - const x = tf.tensor3d( - [ - 10, 30, 50, 70, 20, 40, 60, 80, -10, -30, -50, -70, -20, -40, -60, -80 - ], - inputShape); - const w = tf.tensor4d([1, 0.5, 1], [fSize, fSize, inputDepth, outputDepth]); - const alpha = 0.3; - - const result = tf.fused.conv2d({ - x, - filter: w, - strides, - pad, - dataFormat: 'NHWC', - dilations: [1, 1], - activation: 'leakyrelu', - leakyreluAlpha: alpha - }); - - expectArraysClose(await result.data(), [ - 10, 5, 10, 50, 25, 50, -3, -1.5, -3, -15.000000953674316, - -7.500000476837158, -15.000000953674316 - ]); - }); - - it('pointwise with prelu', async () => { - const inputDepth = 1; - const inputShape: [number, number, number] = [4, 4, inputDepth]; - const outputDepth = 3; - const fSize = 1; - const pad = 'same'; - const strides: [number, number] = [1, 1]; - - const x = tf.tensor3d( - [ - 10, 30, 50, 70, 20, 40, 60, 80, -10, -30, -50, -70, -20, -40, -60, -80 - ], - inputShape); - const w = tf.tensor4d([1, 0.5, 1], [fSize, fSize, inputDepth, outputDepth]); - const alpha = tf.tensor3d([0.5], [1, 1, inputDepth]); - - const result = tf.fused.conv2d({ - x, - filter: w, - strides, - pad, - dataFormat: 'NHWC', - dilations: [1, 1], - activation: 'prelu', - preluActivationWeights: alpha - }); - - expectArraysClose(await result.data(), [ - 10, 5, 10, 30, 15, 30, 50, 25, 50, 70, 35, 70, - 20, 10, 20, 40, 20, 40, 60, 30, 60, 80, 40, 80, - -5, -2.5, -5, -15, -7.5, -15, -25, -12.5, -25, -35, -17.5, -35, - -10, -5, -10, -20, -10, -20, -30, -15, -30, -40, -20, -40 - ]); - }); - - it('pointwise with leakyrelu', async () => { - const inputDepth = 1; - const inputShape: [number, number, number] = [4, 4, inputDepth]; - const outputDepth = 3; - const fSize = 1; - const pad = 'same'; - const strides: [number, number] = [1, 1]; - - const x = tf.tensor3d( - [ - 10, 30, 50, 70, 20, 40, 60, 80, -10, -30, -50, -70, -20, -40, -60, -80 - ], - inputShape); - const w = tf.tensor4d([1, 0.5, 1], [fSize, fSize, inputDepth, outputDepth]); - const alpha = 0.3; - - const result = tf.fused.conv2d({ - x, - filter: w, - strides, - pad, - dataFormat: 'NHWC', - dilations: [1, 1], - activation: 'leakyrelu', - leakyreluAlpha: alpha - }); - - expectArraysClose(await result.data(), [ - 10, - 5, - 10, - 30, - 15, - 30, - 50, - 25, - 50, - 70, - 35, - 70, - 20, - 10, - 20, - 40, - 20, - 40, - 60, - 30, - 60, - 80, - 40, - 80, - -3, - -1.5, - -3, - -9, - -4.5, - -9, - -15.000000953674316, - -7.500000476837158, - -15.000000953674316, - -21, - -10.5, - -21, - -6, - -3, - -6, - -12, - -6, - -12, - -18, - -9, - -18, - -24, - -12, - -24 - ]); - }); - - it('im2row with broadcasted bias and relu', async () => { - const inputDepth = 1; - const inputShape: [number, number, number] = [4, 4, inputDepth]; - const outputDepth = 3; - const fSize = 1; - const pad = 'same'; - const strides: [number, number] = [2, 2]; - - const x = tf.tensor3d( - [ - 10, 30, 50, 70, 20, 40, 60, 80, -10, -30, -50, -70, -20, -40, -60, -80 - ], - inputShape); - const w = tf.tensor4d([1, 0.5, 1], [fSize, fSize, inputDepth, outputDepth]); - - const result = tf.fused.conv2d({ - x, - filter: w, - strides, - pad, - dataFormat: 'NHWC', - dilations: [1, 1], - bias: tf.scalar(5), - activation: 'relu' - }); - - expectArraysClose( - await result.data(), [15, 10, 15, 55, 30, 55, 0, 0, 0, 0, 0, 0]); - }); - - it('im2row in NCHW', async () => { - const inputDepth = 2; - const inputShape: [number, number, number] = [inputDepth, 2, 2]; - const outputDepth = 2; - const fSize = 2; - const pad = 'same'; - const strides: [number, number] = [1, 1]; - - const x = tf.tensor3d([1, 2, 3, 4, 5, 6, 7, 8], inputShape); - const w = tf.tensor4d( - [1, 2, 3, 4, 5, 6, 7, 8, -1, -2, -3, -4, -5, -6, -7, -8], - [fSize, fSize, inputDepth, outputDepth]); - - const result = - tf.fused.conv2d({x, filter: w, strides, pad, dataFormat: 'NCHW'}); - - expectArraysClose( - await result.data(), [-32, -8, 100, 28, -40, -12, 122, 40]); - }); - - it('im2row in NCHW with scalar bias', async () => { - const inputDepth = 4; - const inputShape: [number, number, number, number] = [1, inputDepth, 2, 2]; - const outputDepth = 4; - const fSize = 2; - const pad = 'same'; - const stride = 1; - const dataFormat = 'NCHW'; - const dilation = 1; - - const x = tf.tensor4d( - [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4], inputShape); - const w = tf.tensor4d( - [ - 3, 3, 3, 3, 1, 1, 1, 1, 5, 5, 5, 5, 0, 0, 0, 0, 3, 3, 3, 3, 1, 1, - 1, 1, 5, 5, 5, 5, 0, 0, 0, 0, 3, 3, 3, 3, 1, 1, 1, 1, 5, 5, 5, 5, - 0, 0, 0, 0, 3, 3, 3, 3, 1, 1, 1, 1, 5, 5, 5, 5, 0, 0, 0, 0, - ], - [fSize, fSize, inputDepth, outputDepth]); - const bias = tf.scalar(1); - - const result = tf.fused.conv2d({ - x, - filter: w, - strides: stride, - pad, - dataFormat, - dilations: dilation, - bias - }); - - expect(result.shape).toEqual([1, 4, 2, 2]); - const expected = - [91, 55, 64, 37, 91, 55, 64, 37, 91, 55, 64, 37, 91, 55, 64, 37]; - expectArraysClose(await result.data(), expected); - }); - - it('im2row in NCHW with 1-D bias', async () => { - const inputDepth = 4; - const inputShape: [number, number, number, number] = [1, inputDepth, 2, 2]; - const outputDepth = 4; - const fSize = 2; - const pad = 'same'; - const stride = 1; - const dataFormat = 'NCHW'; - const dilation = 1; - - const x = tf.tensor4d( - [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4], inputShape); - const w = tf.tensor4d( - [ - 3, 3, 3, 3, 1, 1, 1, 1, 5, 5, 5, 5, 0, 0, 0, 0, 3, 3, 3, 3, 1, 1, - 1, 1, 5, 5, 5, 5, 0, 0, 0, 0, 3, 3, 3, 3, 1, 1, 1, 1, 5, 5, 5, 5, - 0, 0, 0, 0, 3, 3, 3, 3, 1, 1, 1, 1, 5, 5, 5, 5, 0, 0, 0, 0, - ], - [fSize, fSize, inputDepth, outputDepth]); - const bias = tf.tensor1d([1, 2, 1, 2]); - - const result = tf.fused.conv2d({ - x, - filter: w, - strides: stride, - pad, - dataFormat, - dilations: dilation, - bias - }); - - expect(result.shape).toEqual([1, 4, 2, 2]); - const expected = - [91, 55, 64, 37, 92, 56, 65, 38, 91, 55, 64, 37, 92, 56, 65, 38]; - expectArraysClose(await result.data(), expected); - }); - - it('im2row in NCHW with scalar PReLU actiavation weights', async () => { - const inputDepth = 2; - const inShape: [number, number, number, number] = [1, inputDepth, 2, 2]; - const outputDepth = 2; - const fSize = 2; - const dataFormat = 'NCHW'; - const dilation = 1; - const pad = 'same'; - const stride = 1; - - const x = tf.tensor4d([1, 2, 3, 4, 5, 6, 7, 8], inShape); - const w = tf.tensor4d( - [-1, -1, -1, -1, 1, 1, 1, 1, -2, -2, -2, -2, 0.5, 0.5, 0.5, 0.5], - [fSize, fSize, inputDepth, outputDepth]); - const alpha = tf.scalar(10); - - const result = tf.fused.conv2d({ - x, - filter: w, - strides: stride, - pad, - dataFormat, - dilations: dilation, - activation: 'prelu', - preluActivationWeights: alpha - }); - - expect(result.shape).toEqual([1, 2, 2, 2]); - const expected = [-120, -320, 2, -120, -120, -320, 2, -120]; - expectArraysClose(await result.data(), expected); - }); - - it('im2row in NCHW with 1-D PReLU actiavation weights', async () => { - const inputDepth = 2; - const inShape: [number, number, number, number] = [1, inputDepth, 2, 2]; - const outputDepth = 2; - const fSize = 2; - const dataFormat = 'NCHW'; - const dilation = 1; - const pad = 'same'; - const stride = 1; - - const x = tf.tensor4d([1, 2, 3, 4, 5, 6, 7, 8], inShape); - const w = tf.tensor4d( - [-1, -1, -1, -1, 1, 1, 1, 1, -2, -2, -2, -2, 0.5, 0.5, 0.5, 0.5], - [fSize, fSize, inputDepth, outputDepth]); - const alpha = tf.tensor1d([1, 10]); - - const result = tf.fused.conv2d({ - x, - filter: w, - strides: stride, - pad, - dataFormat, - dilations: dilation, - activation: 'prelu', - preluActivationWeights: alpha - }); - - expect(result.shape).toEqual([1, 2, 2, 2]); - const expected = [-12, -32, 2, -12, -120, -320, 2, -120]; - expectArraysClose(await result.data(), expected); - }); - - it('im2row in NCHW with 3-D PReLU actiavation weights', async () => { - const inputDepth = 2; - const inShape: [number, number, number, number] = [1, inputDepth, 2, 2]; - const outputDepth = 2; - const fSize = 2; - const dataFormat = 'NCHW'; - const dilation = 1; - const pad = 'same'; - const stride = 1; - - const x = tf.tensor4d([1, 2, 3, 4, 5, 6, 7, 8], inShape); - const w = tf.tensor4d( - [-1, -1, -1, -1, 1, 1, 1, 1, -2, -2, -2, -2, 0.5, 0.5, 0.5, 0.5], - [fSize, fSize, inputDepth, outputDepth]); - const alpha = tf.tensor3d([1, 10], [2, 1, 1]); - - const result = tf.fused.conv2d({ - x, - filter: w, - strides: stride, - pad, - dataFormat, - dilations: dilation, - activation: 'prelu', - preluActivationWeights: alpha - }); - - expect(result.shape).toEqual([1, 2, 2, 2]); - const expected = [-12, -32, 2, -12, -120, -320, 2, -120]; - expectArraysClose(await result.data(), expected); - }); - - it('im2row in NCHW with full 3-D PReLU actiavation weights', async () => { - const inputDepth = 2; - const inShape: [number, number, number, number] = [1, inputDepth, 2, 2]; - const outputDepth = 2; - const fSize = 2; - const dataFormat = 'NCHW'; - const dilation = 1; - const pad = 'same'; - const stride = 1; - - const x = tf.tensor4d([1, 2, 3, 4, 5, 6, 7, 8], inShape); - const w = tf.tensor4d( - [-1, -1, -1, -1, 1, 1, 1, 1, -2, -2, -2, -2, 0.5, 0.5, 0.5, 0.5], - [fSize, fSize, inputDepth, outputDepth]); - const alpha = tf.tensor3d([1, 2, 3, 4, 5, 6, 7, 8], [2, 2, 2]); - - const result = tf.fused.conv2d({ - x, - filter: w, - strides: stride, - pad, - dataFormat, - dilations: dilation, - activation: 'prelu', - preluActivationWeights: alpha - }); - - expect(result.shape).toEqual([1, 2, 2, 2]); - const expected = [-12, -64, 2, -48, -60, -192, 2, -96]; - expectArraysClose(await result.data(), expected); - }); - - it('batch in NCHW', async () => { - const inputDepth = 2; - const inputShape: [number, number, number, number] = [2, inputDepth, 2, 2]; - const outputDepth = 2; - const fSize = 2; - const pad = 'same'; - const strides: [number, number] = [1, 1]; - const dataFormat = 'NCHW'; - const dilation = 1; - - const x = tf.tensor4d( - [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], inputShape); - const w = tf.tensor4d( - [1, 2, 3, 4, 5, 6, 7, 8, -1, -2, -3, -4, -5, -6, -7, -8], - [fSize, fSize, inputDepth, outputDepth]); - - const result = tf.fused.conv2d( - {x, filter: w, strides, pad, dataFormat, dilations: dilation}); - - expect(result.shape).toEqual([2, 2, 2, 2]); - expectArraysClose(await result.data(), [ - -32, -8, 100, 28, -40, -12, 122, 40, -32, -8, 228, 60, -40, -12, 282, 88 - ]); - }); - - it('batch in NCHW with scalar bias', async () => { - const inputDepth = 2; - const inputShape: [number, number, number, number] = [2, inputDepth, 2, 2]; - const outputDepth = 2; - const fSize = 2; - const pad = 'same'; - const strides: [number, number] = [1, 1]; - const dataFormat = 'NCHW'; - const dilation = 1; - - const x = tf.tensor4d( - [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], inputShape); - const w = tf.tensor4d( - [1, 2, 3, 4, 5, 6, 7, 8, -1, -2, -3, -4, -5, -6, -7, -8], - [fSize, fSize, inputDepth, outputDepth]); - const bias = tf.scalar(1); - - const result = tf.fused.conv2d( - {x, filter: w, strides, pad, dataFormat, dilations: dilation, bias}); - - expect(result.shape).toEqual([2, 2, 2, 2]); - expectArraysClose(await result.data(), [ - -31, -7, 101, 29, -39, -11, 123, 41, -31, -7, 229, 61, -39, -11, 283, 89 - ]); - }); - - it('batch in NCHW with 1-D bias', async () => { - const inputDepth = 2; - const inputShape: [number, number, number, number] = [2, inputDepth, 2, 2]; - const outputDepth = 2; - const fSize = 2; - const pad = 'same'; - const strides: [number, number] = [1, 1]; - const dataFormat = 'NCHW'; - const dilation = 1; - - const x = tf.tensor4d( - [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], inputShape); - const w = tf.tensor4d( - [1, 2, 3, 4, 5, 6, 7, 8, -1, -2, -3, -4, -5, -6, -7, -8], - [fSize, fSize, inputDepth, outputDepth]); - const bias = tf.tensor1d([1, 2]); - - const result = tf.fused.conv2d( - {x, filter: w, strides, pad, dataFormat, dilations: dilation, bias}); - - expect(result.shape).toEqual([2, 2, 2, 2]); - expectArraysClose(await result.data(), [ - -31, -7, 101, 29, -38, -10, 124, 42, -31, -7, 229, 61, -38, -10, 284, 90 - ]); - }); - - it('batch in NCHW with scalar PReLU actiavation weights', async () => { - const inputDepth = 2; - const inputShape: [number, number, number, number] = [2, inputDepth, 2, 2]; - const outputDepth = 2; - const fSize = 2; - const pad = 'same'; - const strides: [number, number] = [1, 1]; - const dataFormat = 'NCHW'; - const dilation = 1; - - const x = tf.tensor4d( - [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], inputShape); - const w = tf.tensor4d( - [1, 2, 3, 4, 5, 6, 7, 8, -1, -2, -3, -4, -5, -6, -7, -8], - [fSize, fSize, inputDepth, outputDepth]); - const alpha = tf.scalar(10); - - const result = tf.fused.conv2d({ - x, - filter: w, - strides, - pad, - dataFormat, - dilations: dilation, - activation: 'prelu', - preluActivationWeights: alpha - }); - - expect(result.shape).toEqual([2, 2, 2, 2]); - expectArraysClose(await result.data(), [ - -320, -80, 100, 28, -400, -120, 122, 40, -320, -80, 228, 60, -400, -120, - 282, 88 - ]); - }); - - it('batch in NCHW with 1-D PReLU actiavation weights', async () => { - const inputDepth = 2; - const inputShape: [number, number, number, number] = [2, inputDepth, 2, 2]; - const outputDepth = 2; - const fSize = 2; - const pad = 'same'; - const strides: [number, number] = [1, 1]; - const dataFormat = 'NCHW'; - const dilation = 1; - - const x = tf.tensor4d( - [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], inputShape); - const w = tf.tensor4d( - [1, 2, 3, 4, 5, 6, 7, 8, -1, -2, -3, -4, -5, -6, -7, -8], - [fSize, fSize, inputDepth, outputDepth]); - const alpha = tf.tensor1d([1, 10]); - - const result = tf.fused.conv2d({ - x, - filter: w, - strides, - pad, - dataFormat, - dilations: dilation, - activation: 'prelu', - preluActivationWeights: alpha - }); - - expect(result.shape).toEqual([2, 2, 2, 2]); - expectArraysClose(await result.data(), [ - -32, -8, 100, 28, -400, -120, 122, 40, -32, -8, 228, 60, -400, -120, 282, - 88 - ]); - }); - - it('batch in NCHW with 3-D PReLU actiavation weights', async () => { - const inputDepth = 2; - const inputShape: [number, number, number, number] = [2, inputDepth, 2, 2]; - const outputDepth = 2; - const fSize = 2; - const pad = 'same'; - const strides: [number, number] = [1, 1]; - const dataFormat = 'NCHW'; - const dilation = 1; - - const x = tf.tensor4d( - [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], inputShape); - const w = tf.tensor4d( - [1, 2, 3, 4, 5, 6, 7, 8, -1, -2, -3, -4, -5, -6, -7, -8], - [fSize, fSize, inputDepth, outputDepth]); - const alpha = tf.tensor3d([1, 10], [2, 1, 1]); - - const result = tf.fused.conv2d({ - x, - filter: w, - strides, - pad, - dataFormat, - dilations: dilation, - activation: 'prelu', - preluActivationWeights: alpha - }); - - expect(result.shape).toEqual([2, 2, 2, 2]); - expectArraysClose(await result.data(), [ - -32, -8, 100, 28, -400, -120, 122, 40, -32, -8, 228, 60, -400, -120, 282, - 88 - ]); - }); - - it('batch in NCHW with full 3-D PReLU actiavation weights', async () => { - const inputDepth = 2; - const inputShape: [number, number, number, number] = [2, inputDepth, 2, 2]; - const outputDepth = 2; - const fSize = 2; - const pad = 'same'; - const strides: [number, number] = [1, 1]; - const dataFormat = 'NCHW'; - const dilation = 1; - - const x = tf.tensor4d( - [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], inputShape); - const w = tf.tensor4d( - [1, 2, 3, 4, 5, 6, 7, 8, -1, -2, -3, -4, -5, -6, -7, -8], - [fSize, fSize, inputDepth, outputDepth]); - const alpha = tf.tensor3d([1, 2, 3, 4, 5, 6, 7, 8], [2, 2, 2]); - - const result = tf.fused.conv2d({ - x, - filter: w, - strides, - pad, - dataFormat, - dilations: dilation, - activation: 'prelu', - preluActivationWeights: alpha - }); - - expect(result.shape).toEqual([2, 2, 2, 2]); - expectArraysClose(await result.data(), [ - -32, -16, 100, 28, -200, -72, 122, 40, -32, -16, 228, 60, -200, -72, 282, - 88 - ]); - }); - - it('backProp input x=[2,3,3,1] f=[2,2,1,1] s=1 p=0', async () => { - const inputDepth = 1; - const outputDepth = 1; - const inputShape: [number, number, number, number] = [2, 3, 3, inputDepth]; - const filterSize = 2; - const strides = 1; - const pad = 0; - - const filterShape: [number, number, number, number] = - [filterSize, filterSize, inputDepth, outputDepth]; - const filter = tf.tensor4d([-1, 1, -2, 0.5], filterShape); - - const x = tf.tensor4d( - [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9], inputShape); - const dy = tf.tensor4d([3, 1, 2, 0, 3, 1, 2, 0], [2, 2, 2, 1]); - - const grads = tf.grads( - (x: tf.Tensor4D) => tf.fused.conv2d({x, filter, strides, pad})); - const [dx] = grads([x], dy); - - expect(dx.shape).toEqual(x.shape); - expectArraysClose( - await dx.data(), - [-3, 2, 1, -8, 1.5, 0.5, -4, 1, 0, -3, 2, 1, -8, 1.5, 0.5, -4, 1, 0]); - }); - - it('gradient x=[2,3,3,1] f=[2,2,1,1] s=1 p=0', async () => { - const inputDepth = 1; - const outputDepth = 1; - const inputShape: [number, number, number, number] = [2, 3, 3, inputDepth]; - const filterSize = 2; - const strides = 1; - const pad = 0; - - const filterShape: [number, number, number, number] = - [filterSize, filterSize, inputDepth, outputDepth]; - const filter = tf.tensor4d([-1, 1, -2, 0.5], filterShape); - - const x = tf.tensor4d( - [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9], inputShape); - const dy = tf.tensor4d([3, 1, 2, 0, 3, 1, 2, 0], [2, 2, 2, 1]); - - const grads = tf.grads( - (x: tf.Tensor4D, filter: tf.Tensor4D) => - tf.fused.conv2d({x, filter, strides, pad})); - const [dx, dfilter] = grads([x, filter], dy); - - expect(dx.shape).toEqual(x.shape); - expectArraysClose( - await dx.data(), - [-3, 2, 1, -8, 1.5, 0.5, -4, 1, 0, -3, 2, 1, -8, 1.5, 0.5, -4, 1, 0]); - - expect(dfilter.shape).toEqual(filterShape); - expectArraysClose(await dfilter.data(), [26, 38, 62, 74]); - }); - - it('gradient x=[2,3,3,1] f=[2,2,1,1] s=1 p=0 with bias', async () => { - const inputDepth = 1; - const outputDepth = 1; - const inputShape: [number, number, number, number] = [2, 3, 3, inputDepth]; - const filterSize = 2; - const strides = 1; - const pad = 0; - - const filterShape: [number, number, number, number] = - [filterSize, filterSize, inputDepth, outputDepth]; - const filter = tf.tensor4d([-1, 1, -2, 0.5], filterShape); - const bias = tf.ones([2, 2, 2, 1]); - - const x = tf.tensor4d( - [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9], inputShape); - const dy = tf.tensor4d([3, 1, 2, 0, 3, 1, 2, 0], [2, 2, 2, 1]); - - const fusedGrads = - tf.grads((x: tf.Tensor4D, w: tf.Tensor4D, b) => tf.fused.conv2d({ - x, - filter: w, - strides, - pad, - dataFormat: 'NHWC', - dilations: [1, 1], - bias: b - })); - const [dxFused, dfilterFused, dbiasFused] = - fusedGrads([x, filter, bias], dy); - - const grads = tf.grads((x: tf.Tensor4D, filter: tf.Tensor4D, bias) => { - const conv = tf.conv2d(x, filter, strides, pad); - const sum = tf.add(conv, bias); - return sum; - }); - const [dx, dfilter, dbias] = grads([x, filter, bias], dy); - - expectArraysClose(await dxFused.array(), await dx.array()); - expectArraysClose(await dfilterFused.array(), await dfilter.array()); - expectArraysClose(await dbiasFused.array(), await dbias.array()); - }); - - it('gradient x=[2,3,3,1] f=[2,2,1,1] s=1 p=0 with bias and relu', - async () => { - const inputDepth = 1; - const outputDepth = 1; - const inputShape: [number, number, number, number] = - [2, 3, 3, inputDepth]; - const filterSize = 2; - const strides = 1; - const pad = 0; - - const filterShape: [number, number, number, number] = - [filterSize, filterSize, inputDepth, outputDepth]; - const filter = tf.tensor4d([-1, 1, -2, 0.5], filterShape); - const bias = tf.ones([2, 2, 2, 1]); - - const x = tf.tensor4d( - [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9], inputShape); - const dy = tf.tensor4d([3, 1, 2, 0, 3, 1, 2, 0], [2, 2, 2, 1]); - - const fusedGrads = - tf.grads((x: tf.Tensor4D, w: tf.Tensor4D, b) => tf.fused.conv2d({ - x, - filter: w, - strides, - pad, - dataFormat: 'NHWC', - dilations: [1, 1], - bias: b, - activation: 'relu' - })); - const [dxFused, dfilterFused, dbiasFused] = - fusedGrads([x, filter, bias], dy); - - const grads = tf.grads((x: tf.Tensor4D, filter: tf.Tensor4D, bias) => { - const conv = tf.conv2d(x, filter, strides, pad); - const sum = tf.add(conv, bias); - return tf.relu(sum); - }); - const [dx, dfilter, dbias] = grads([x, filter, bias], dy); - - expectArraysClose(await dxFused.array(), await dx.array()); - expectArraysClose(await dfilterFused.array(), await dfilter.array()); - expectArraysClose(await dbiasFused.array(), await dbias.array()); - }); - - it('gradient x=[2,3,3,1] f=[2,2,1,1] s=1 p=0 with bias and elu', async () => { - const inputDepth = 1; - const outputDepth = 1; - const inputShape: [number, number, number, number] = [2, 3, 3, inputDepth]; - const filterSize = 2; - const strides = 1; - const pad = 0; - - const filterShape: [number, number, number, number] = - [filterSize, filterSize, inputDepth, outputDepth]; - const filter = tf.tensor4d([-1, 1, -2, 0.5], filterShape); - const bias = tf.ones([2, 2, 2, 1]); - - const x = tf.tensor4d( - [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9], inputShape); - const dy = tf.tensor4d([3, 1, 2, 0, 3, 1, 2, 0], [2, 2, 2, 1]); - - const fusedGrads = - tf.grads((x: tf.Tensor4D, w: tf.Tensor4D, b) => tf.fused.conv2d({ - x, - filter: w, - strides, - pad, - dataFormat: 'NHWC', - dilations: [1, 1], - bias: b, - activation: 'elu' - })); - const [dxFused, dfilterFused, dbiasFused] = - fusedGrads([x, filter, bias], dy); - - const grads = tf.grads((x: tf.Tensor4D, filter: tf.Tensor4D, bias) => { - const conv = tf.conv2d(x, filter, strides, pad); - const sum = tf.add(conv, bias); - return tf.elu(sum); - }); - const [dx, dfilter, dbias] = grads([x, filter, bias], dy); - - expectArraysClose(await dxFused.array(), await dx.array()); - expectArraysClose(await dfilterFused.array(), await dfilter.array()); - expectArraysClose(await dbiasFused.array(), await dbias.array()); - }); - - it('throws when input is int32', async () => { - const inputDepth = 2; - const inShape: [number, number, number, number] = [2, 2, 2, inputDepth]; - const outputDepth = 2; - const fSize = 1; - const pad = 0; - const stride = 1; - - const x = tf.tensor4d( - [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], inShape, - 'int32'); - const w = - tf.tensor4d([-1, 1, -2, 0.5], [fSize, fSize, inputDepth, outputDepth]); - - expect(() => tf.fused.conv2d({x, filter: w, strides: stride, pad})) - .toThrowError(/Argument 'x' passed to 'conv2d' must be float32/); - }); - - it('throws when filter is int32', async () => { - const inputDepth = 2; - const inShape: [number, number, number, number] = [2, 2, 2, inputDepth]; - const outputDepth = 2; - const fSize = 1; - const pad = 0; - const stride = 1; - - const x = tf.tensor4d( - [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], inShape); - const w = tf.tensor4d( - [-1, 1, -2, 0.5], [fSize, fSize, inputDepth, outputDepth], 'int32'); - - expect(() => tf.fused.conv2d({x, filter: w, strides: stride, pad})) - .toThrowError(/Argument 'filter' passed to 'conv2d' must be float32/); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/fused/fused_depthwise_conv2d_test.ts b/tfjs-master/tfjs-core/src/ops/fused/fused_depthwise_conv2d_test.ts deleted file mode 100644 index 4ec897952..000000000 --- a/tfjs-master/tfjs-core/src/ops/fused/fused_depthwise_conv2d_test.ts +++ /dev/null @@ -1,442 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../../index'; -import {ALL_ENVS, describeWithFlags} from '../../jasmine_util'; -import {expectArraysClose} from '../../test_util'; - -describeWithFlags('fused depthwiseConv2D', ALL_ENVS, () => { - it('basic', async () => { - const fSize = 2; - const pad = 'valid'; - const strides = 1; - const chMul = 1; - const inDepth = 1; - - const x = tf.tensor4d( - [ - 0.230664, 0.987388, 0.0685208, 0.419224, 0.887861, 0.731641, - 0.0741907, 0.409265, 0.351377 - ], - [1, 3, 3, inDepth]); - const w = tf.tensor4d( - [-0.303873, -0.229223, 0.144333, 0.803373], - [fSize, fSize, inDepth, chMul], - ); - - const result = tf.fused.depthwiseConv2d({x, filter: w, strides, pad}); - expect(result.shape).toEqual([1, 2, 2, 1]); - const expected = [0.47737, 0.40018, 0.00859, -0.09615]; - expectArraysClose(await result.data(), expected); - }); - - it('basic with relu', async () => { - const fSize = 2; - const pad = 'valid'; - const strides = 1; - const chMul = 1; - const inDepth = 1; - - const x = tf.tensor4d( - [ - 0.230664, 0.987388, 0.0685208, 0.419224, 0.887861, 0.731641, - 0.0741907, 0.409265, 0.351377 - ], - [1, 3, 3, inDepth]); - const w = tf.tensor4d( - [-0.303873, -0.229223, 0.144333, 0.803373], - [fSize, fSize, inDepth, chMul], - ); - - const result = tf.fused.depthwiseConv2d( - {x, filter: w, strides, pad, activation: 'relu'}); - expect(result.shape).toEqual([1, 2, 2, 1]); - const expected = [0.47737, 0.40018, 0.00859, 0]; - expectArraysClose(await result.data(), expected); - }); - - it('basic with channel-wise broadcasted bias and relu', async () => { - const strides = 1; - const pad = 'same'; - const x = tf.tensor4d( - [ - 0, 1, 2, 3, 4, 5, 6, 7, 8, 0, 1, 2, 3, 4, 5, 6, 7, 8, - 0, 1, 2, 3, 4, 5, 6, 7, 8, 0, 1, 2, 3, 4, 5, 6, 7, 8 - ], - [1, 3, 3, 4]); - const w = tf.tensor4d( - [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], [2, 2, 4, 1]); - const bias = tf.tensor1d([0, 1, 2, 3]); - - const result = tf.fused.depthwiseConv2d({x, filter: w, strides, pad, bias}); - expect(result.shape).toEqual([1, 3, 3, 4]); - const expected = [ - 124, 167, 92, 142, 112, 117, 76, 124, 16, 28, 44, 64, - 88, 134, 134, 88, 76, 120, 154, 205, 40, 58, 80, 106, - 4, 18, 36, 31, 20, 33, 50, 71, 0, 7, 16, 27 - ]; - expectArraysClose(await result.data(), expected); - }); - - it('basic with broadcasted bias and relu', async () => { - const fSize = 2; - const pad = 'valid'; - const strides = 1; - const chMul = 1; - const inDepth = 1; - - const x = tf.tensor4d( - [ - 0.230664, 0.987388, 0.0685208, 0.419224, 0.887861, 0.731641, - 0.0741907, 0.409265, 0.351377 - ], - [1, 3, 3, inDepth]); - const w = tf.tensor4d( - [-0.303873, -0.229223, 0.144333, 0.803373], - [fSize, fSize, inDepth, chMul], - ); - - const result = tf.fused.depthwiseConv2d( - {x, filter: w, strides, pad, bias: tf.scalar(1), activation: 'relu'}); - expect(result.shape).toEqual([1, 2, 2, 1]); - const expected = [1.47737, 1.40018, 1.00859, 0.90385]; - expectArraysClose(await result.data(), expected); - }); - - // For WebGPU DepthwiseConv2D3x3Program. - it('basic with channel-wise broadcasted bias and relu filter 3x3', - async () => { - const fSize = 3; - const pad = 'same'; - const strides = 1; - const chMul = 1; - const inDepth = 4; - - const x = tf.tensor4d( - [ - 0.230664, 0.987388, 0.0685208, 0.419224, 0.887861, 0.731641, - 0.0741907, 0.409265, 0.351377, 0.230664, 0.987388, 0.0685208, - 0.419224, 0.887861, 0.731641, 0.0741907, 0.409265, 0.351377, - 0.230664, 0.987388, 0.0685208, 0.419224, 0.887861, 0.731641, - 0.0741907, 0.409265, 0.351377, 0.230664, 0.987388, 0.0685208, - 0.419224, 0.887861, 0.731641, 0.0741907, 0.409265, 0.351377 - ], - [1, 3, 3, inDepth]); - const w = tf.tensor4d( - [ - -0.303873, -0.229223, 0.144333, 0.803373, -0.303873, -0.229223, - 0.144333, 0.803373, -0.303873, -0.229223, 0.144333, 0.803373, - -0.303873, -0.229223, 0.144333, 0.803373, -0.303873, -0.229223, - 0.144333, 0.803373, -0.303873, -0.229223, 0.144333, 0.803373, - -0.303873, -0.229223, 0.144333, 0.803373, -0.303873, -0.229223, - 0.144333, 0.803373, -0.303873, -0.229223, 0.144333, 0.803373 - ], - [fSize, fSize, inDepth, chMul], - ); - const bias = tf.tensor1d([0, 1, 2, 3]); - const result = - tf.fused.depthwiseConv2d({x, filter: w, strides, pad, bias}); - expect(result.shape).toEqual([1, 3, 3, 4]); - const expected = [ - -0.5916450023651123, 0.32189714908599854, 2.1594903469085693, - 4.518429279327393, -0.7192406058311462, 0.1729278564453125, - 2.4301507472991943, 5.161257743835449, -0.521757185459137, - 0.6027780771255493, 2.3146610260009766, 4.764861583709717, - -0.9142301082611084, 0.212377667427063, 2.2707135677337646, - 5.417022228240967, -1.264151692390442, 0.046402156352996826, - 2.6004443168640137, 6.342137336730957, -1.044123649597168, - 0.5700653791427612, 2.434239149093628, 5.760432243347168, - -0.5743405818939209, 0.6064186692237854, 2.250115394592285, - 4.751436233520508, -0.8174881339073181, 0.4933167099952698, - 2.437333583831787, 5.621503829956055, -0.6675527095794678, - 0.7906477451324463, 2.2810182571411133, 5.376591682434082 - ]; - expectArraysClose(await result.data(), expected); - }); - - it('prelu', async () => { - const fSize = 3; - const pad = 'valid'; - const strides = 1; - const chMul = 1; - const inDepth = 1; - - const x = tf.tensor4d( - [ - 0.149194, 0.089009, 0.654891, 0.083324, 0.537043, 0.644331, 0.563037, - 0.211859, 0.633501, 0.186427, 0.777034, 0.50001, 0.607341, 0.95303, - 0.696479, 0.050387, 0.62045, 0.728049, 0.028043, 0.437009, 0.712881, - 0.741935, 0.974474, 0.621102, 0.171411 - ], - [1, 5, 5, inDepth]); - const alpha = tf.tensor4d( - [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9], [1, 3, 3, 1]); - const w = tf.tensor4d( - [ - -0.125386, -0.975199, -0.640437, -0.281895, -0.990968, -0.347208, - -0.889702, -0.180695, -0.691992 - ], - [fSize, fSize, inDepth, chMul], - ); - - const result = tf.fused.depthwiseConv2d({ - x, - filter: w, - strides, - pad, - activation: 'prelu', - preluActivationWeights: alpha - }); - expect(result.shape).toEqual([1, 3, 3, 1]); - const expected = [ - -0.25400, -0.50118, -0.73622, -0.94068, -1.2298, -1.84585, -2.3089, - -2.7499, -2.64077 - ]; - expectArraysClose(await result.data(), expected); - }); - - it('leakyrelu', async () => { - const fSize = 3; - const pad = 'valid'; - const strides = 1; - const chMul = 1; - const inDepth = 1; - - const x = tf.tensor4d( - [ - 0.149194, 0.089009, 0.654891, 0.083324, 0.537043, 0.644331, 0.563037, - 0.211859, 0.633501, 0.186427, 0.777034, 0.50001, 0.607341, 0.95303, - 0.696479, 0.050387, 0.62045, 0.728049, 0.028043, 0.437009, 0.712881, - 0.741935, 0.974474, 0.621102, 0.171411 - ], - [1, 5, 5, inDepth]); - const alpha = 0.3; - const w = tf.tensor4d( - [ - -0.125386, -0.975199, -0.640437, -0.281895, -0.990968, -0.347208, - -0.889702, -0.180695, -0.691992 - ], - [fSize, fSize, inDepth, chMul], - ); - - const result = tf.fused.depthwiseConv2d({ - x, - filter: w, - strides, - pad, - activation: 'leakyrelu', - leakyreluAlpha: alpha - }); - - expect(result.shape).toEqual([1, 3, 3, 1]); - const expected = [ - -0.7620067596435547, -0.7517655491828918, -0.7362186312675476, - -0.7055101990699768, -0.7378802299499512, -0.9229262471199036, - -0.9895440340042114, -1.031226396560669, -0.8802568912506104 - ]; - expectArraysClose(await result.data(), expected); - }); - - it('sigmoid', async () => { - const fSize = 3; - const pad = 'valid'; - const strides = 1; - const chMul = 1; - const inDepth = 1; - - const x = tf.tensor4d( - [ - 0.149194, 0.089009, 0.654891, 0.083324, 0.537043, 0.644331, 0.563037, - 0.211859, 0.633501, 0.186427, 0.777034, 0.50001, 0.607341, 0.95303, - 0.696479, 0.050387, 0.62045, 0.728049, 0.028043, 0.437009, 0.712881, - 0.741935, 0.974474, 0.621102, 0.171411 - ], - [1, 5, 5, inDepth]); - const w = tf.tensor4d( - [ - -0.125386, -0.975199, -0.640437, -0.281895, -0.990968, -0.347208, - -0.889702, -0.180695, -0.691992 - ], - [fSize, fSize, inDepth, chMul], - ); - - const result = tf.fused.depthwiseConv2d( - {x, filter: w, strides, pad, activation: 'sigmoid'}); - - expect(result.shape).toEqual([1, 3, 3, 1]); - const expected = [ - 0.07309964, 0.07544667, 0.07914197, 0.08693069, 0.07873929, 0.04409045, - 0.03562334, 0.0311462, 0.05048907 - ]; - expectArraysClose(await result.data(), expected); - }); - - it('gradient x=[2,3,3,1] f=[2,2,1,1] s=1 p=0', async () => { - const inputDepth = 1; - const outputDepth = 1; - const inputShape: [number, number, number, number] = [2, 3, 3, inputDepth]; - const filterSize = 2; - const strides = 1; - const pad = 0; - - const filterShape: [number, number, number, number] = - [filterSize, filterSize, inputDepth, outputDepth]; - const filter = tf.tensor4d([-1, 1, -2, 0.5], filterShape); - - const x = tf.tensor4d( - [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9], inputShape); - const dy = tf.tensor4d([3, 1, 2, 0, 3, 1, 2, 0], [2, 2, 2, 1]); - - const grads = tf.grads( - (x: tf.Tensor4D, filter: tf.Tensor4D) => - tf.fused.depthwiseConv2d({x, filter, strides, pad})); - const [dx, dfilter] = grads([x, filter], dy); - - expect(dx.shape).toEqual(x.shape); - expectArraysClose( - await dx.data(), - [-3, 2, 1, -8, 1.5, 0.5, -4, 1, 0, -3, 2, 1, -8, 1.5, 0.5, -4, 1, 0]); - - expect(dfilter.shape).toEqual(filterShape); - expectArraysClose(await dfilter.data(), [26, 38, 62, 74]); - }); - - it('gradient x=[2,3,3,1] f=[2,2,1,1] s=1 p=0 with bias', async () => { - const inputDepth = 1; - const outputDepth = 1; - const inputShape: [number, number, number, number] = [2, 3, 3, inputDepth]; - const filterSize = 2; - const strides = 1; - const pad = 0; - - const filterShape: [number, number, number, number] = - [filterSize, filterSize, inputDepth, outputDepth]; - const filter = tf.tensor4d([-1, 1, -2, 0.5], filterShape); - const bias = tf.ones([2, 2, 2, 1]); - - const x = tf.tensor4d( - [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9], inputShape); - const dy = tf.tensor4d([3, 1, 2, 0, 3, 1, 2, 0], [2, 2, 2, 1]); - - const fusedGrads = tf.grads( - (x: tf.Tensor4D, w: tf.Tensor4D, b) => tf.fused.depthwiseConv2d({ - x, - filter: w, - strides, - pad, - dataFormat: 'NHWC', - dilations: [1, 1], - bias: b - })); - const [dxFused, dfilterFused, dbiasFused] = - fusedGrads([x, filter, bias], dy); - - const grads = tf.grads((x: tf.Tensor4D, filter: tf.Tensor4D, bias) => { - const conv = tf.depthwiseConv2d(x, filter, strides, pad); - const sum = tf.add(conv, bias); - return sum; - }); - const [dx, dfilter, dbias] = grads([x, filter, bias], dy); - - expectArraysClose(await dxFused.array(), await dx.array()); - expectArraysClose(await dfilterFused.array(), await dfilter.array()); - expectArraysClose(await dbiasFused.array(), await dbias.array()); - }); - - it('gradient x=[2,3,3,1] f=[2,2,1,1] s=1 p=0 with bias and activation', - async () => { - const inputDepth = 1; - const outputDepth = 1; - const inputShape: [number, number, number, number] = - [2, 3, 3, inputDepth]; - const filterSize = 2; - const strides = 1; - const pad = 0; - - const filterShape: [number, number, number, number] = - [filterSize, filterSize, inputDepth, outputDepth]; - const filter = tf.tensor4d([-1, 1, -2, 0.5], filterShape); - const bias = tf.ones([2, 2, 2, 1]); - - const x = tf.tensor4d( - [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9], inputShape); - const dy = tf.tensor4d([3, 1, 2, 0, 3, 1, 2, 0], [2, 2, 2, 1]); - - const fusedGrads = tf.grads( - (x: tf.Tensor4D, w: tf.Tensor4D, b) => tf.fused.depthwiseConv2d({ - x, - filter: w, - strides, - pad, - dataFormat: 'NHWC', - dilations: [1, 1], - bias: b, - activation: 'relu' - })); - const [dxFused, dfilterFused, dbiasFused] = - fusedGrads([x, filter, bias], dy); - - const grads = tf.grads((x: tf.Tensor4D, filter: tf.Tensor4D, bias) => { - const conv = tf.depthwiseConv2d(x, filter, strides, pad); - const sum = tf.add(conv, bias); - return tf.relu(sum); - }); - const [dx, dfilter, dbias] = grads([x, filter, bias], dy); - - expectArraysClose(await dxFused.array(), await dx.array()); - expectArraysClose(await dfilterFused.array(), await dfilter.array()); - expectArraysClose(await dbiasFused.array(), await dbias.array()); - }); - - it('throws when input is int32', async () => { - const fSize = 2; - const pad = 'valid'; - const strides = 1; - const chMul = 1; - const inDepth = 1; - - const x = - tf.tensor4d([1, 2, 3, 4, 5, 6, 7, 8, 9], [1, 3, 3, inDepth], 'int32'); - const w = tf.tensor4d( - [-0.303873, -0.229223, 0.144333, 0.803373], - [fSize, fSize, inDepth, chMul], - ); - - expect(() => tf.fused.depthwiseConv2d({x, filter: w, strides, pad})) - .toThrowError( - /Argument 'x' passed to 'depthwiseConv2d' must be float32/); - }); - - it('throws when filter is int32', async () => { - const fSize = 2; - const pad = 'valid'; - const strides = 1; - const chMul = 1; - const inDepth = 1; - - const x = tf.tensor4d([1, 2, 3, 4, 5, 6, 7, 8, 9], [1, 3, 3, inDepth]); - const w = tf.tensor4d( - [1, 2, 3, 4], - [fSize, fSize, inDepth, chMul], - 'int32', - ); - - expect(() => tf.fused.depthwiseConv2d({x, filter: w, strides, pad})) - .toThrowError( - /Argument 'filter' passed to 'depthwiseConv2d' must be float32/); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/fused/fused_mat_mul_test.ts b/tfjs-master/tfjs-core/src/ops/fused/fused_mat_mul_test.ts deleted file mode 100644 index be8385c55..000000000 --- a/tfjs-master/tfjs-core/src/ops/fused/fused_mat_mul_test.ts +++ /dev/null @@ -1,402 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../../index'; -import {ALL_ENVS, describeWithFlags} from '../../jasmine_util'; -import {expectArraysClose} from '../../test_util'; - -describeWithFlags('fused matmul', ALL_ENVS, () => { - it('fused A x B', async () => { - const a = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - const b = tf.tensor2d([0, 1, -3, 2, 2, 1], [3, 2]); - - const c = tf.fused.matMul({a, b}); - - expect(c.shape).toEqual([2, 2]); - expectArraysClose(await c.data(), [0, 8, -3, 20]); - }); - - it('fused A x B with relu', async () => { - const a = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - const b = tf.tensor2d([0, 1, -3, 2, 2, 1], [3, 2]); - const transposeA = false; - const transposeB = false; - - const c = tf.fused.matMul( - {a, b, transposeA, transposeB, bias: null, activation: 'relu'}); - - expect(c.shape).toEqual([2, 2]); - expectArraysClose(await c.data(), [0, 8, 0, 20]); - }); - - it('fused A x B with elu', async () => { - const a = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - const b = tf.tensor2d([0, 1, -3, 2, 2, 1], [3, 2]); - const transposeA = false; - const transposeB = false; - - const c = tf.fused.matMul( - {a, b, transposeA, transposeB, bias: null, activation: 'elu'}); - - expect(c.shape).toEqual([2, 2]); - expectArraysClose(await c.data(), [0, 8, -0.9502, 20]); - }); - - it('fused A x B with relu6', async () => { - const a = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - const b = tf.tensor2d([0, 1, -3, 2, 2, 1], [3, 2]); - const transposeA = false; - const transposeB = false; - - const c = tf.fused.matMul( - {a, b, transposeA, transposeB, bias: null, activation: 'relu6'}); - - expect(c.shape).toEqual([2, 2]); - expectArraysClose(await c.data(), [0, 6, 0, 6]); - }); - - it('fused A x B with prelu', async () => { - const a = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - const b = tf.tensor2d([0, 1, -3, 2, 2, 1], [3, 2]); - const alpha = tf.tensor2d([0.5, 0.5], [1, 2]); - const transposeA = false; - const transposeB = false; - - const c = tf.fused.matMul({ - a, - b, - transposeA, - transposeB, - bias: null, - activation: 'prelu', - preluActivationWeights: alpha - }); - - expect(c.shape).toEqual([2, 2]); - expectArraysClose(await c.data(), [0, 8, -1.5, 20]); - }); - - it('fused A x B with leakyrelu', async () => { - const a = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - const b = tf.tensor2d([0, 1, -3, 2, 2, 1], [3, 2]); - const alpha = 0.3; - const transposeA = false; - const transposeB = false; - - const c = tf.fused.matMul({ - a, - b, - transposeA, - transposeB, - bias: null, - activation: 'leakyrelu', - leakyreluAlpha: alpha - }); - - expect(c.shape).toEqual([2, 2]); - expectArraysClose(await c.data(), [0, 8, -0.9000000357627869, 20]); - }); - - it('fused A x B with leakyrelu not provided.', async () => { - const a = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - const b = tf.tensor2d([0, 1, -3, 2, 2, 1], [3, 2]); - const transposeA = false; - const transposeB = false; - - const c = tf.fused.matMul({ - a, - b, - transposeA, - transposeB, - bias: null, - activation: 'leakyrelu' - }); - - expect(c.shape).toEqual([2, 2]); - // leakyRelu should use default alpha=0.2. - expectArraysClose(await c.data(), [0, 8, -0.6000000238418579, 20]); - }); - - it('fused A x B with sigmoid', async () => { - const a = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - const b = tf.tensor2d([0, 1, -3, 2, 2, 1], [3, 2]); - const transposeA = false; - const transposeB = false; - - const c = tf.fused.matMul( - {a, b, transposeA, transposeB, bias: null, activation: 'sigmoid'}); - - expect(c.shape).toEqual([2, 2]); - expectArraysClose(await c.data(), [0.5, 0.99966455, 0.04742587, 1]); - }); - - it('fused A x B with relu transpose', async () => { - const a = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - const b = tf.tensor2d([0, 1, -3, 2, 2, 1], [2, 3]); - const transposeA = false; - const transposeB = true; - - const c = tf.fused.matMul( - {a, b, transposeA, transposeB, bias: null, activation: 'relu'}); - - expect(c.shape).toEqual([2, 2]); - expectArraysClose(await c.data(), [0, 9, 0, 24]); - }); - - it('fused A x B with 2d bias and relu', async () => { - const a = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - const b = tf.tensor2d([0, 1, -3, 2, 2, 1], [3, 2]); - const c = tf.tensor2d([1, 1, 1, 1], [2, 2]); - const transposeA = false; - const transposeB = false; - - const d = tf.fused.matMul( - {a, b, transposeA, transposeB, bias: c, activation: 'relu'}); - - expect(d.shape).toEqual([2, 2]); - expectArraysClose(await d.data(), [1, 9, 0, 21]); - }); - - it('fused A x B with relu and broadcasted bias', async () => { - const a = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - const b = tf.tensor2d([0, 1, -3, 2, 2, 1], [3, 2]); - const c = tf.tensor1d([1, 1]); - const act: tf.fused.Activation = 'relu'; - const transposeA = false; - const transposeB = false; - - const d = tf.fused.matMul( - {a, b, transposeA, transposeB, bias: c, activation: act}); - - expect(d.shape).toEqual([2, 2]); - expectArraysClose(await d.data(), [1, 9, 0, 21]); - }); - - it('fused A x B with elu and broadcasted bias', async () => { - const a = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - const b = tf.tensor2d([0, 1, -3, 2, 2, 1], [3, 2]); - const c = tf.tensor1d([1, 1]); - const act: tf.fused.Activation = 'elu'; - const transposeA = false; - const transposeB = false; - - const d = tf.fused.matMul( - {a, b, transposeA, transposeB, bias: c, activation: act}); - - expect(d.shape).toEqual([2, 2]); - expectArraysClose(await d.data(), [1, 9, -0.8647, 21]); - }); - - it('fused A x B with elu and broadcasted shape', async () => { - const a = tf.tensor3d([1, 2, 3, 4, 5, 6], [1, 2, 3]); - const b = tf.tensor2d([0, 1, -3, 2, 2, 1], [3, 2]); - const c = tf.tensor1d([1, 1]); - const act: tf.fused.Activation = 'elu'; - const transposeA = false; - const transposeB = false; - - const d = tf.fused.matMul( - {a, b, transposeA, transposeB, bias: c, activation: act}); - - expect(d.shape).toEqual([1, 2, 2]); - expectArraysClose(await d.data(), [1, 9, -0.8647, 21]); - }); - - it('fused A x B with relu and broadcasted bias different rank', async () => { - const a = tf.tensor3d([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [2, 2, 3]); - const b = tf.tensor3d([0, 1, -3, 2, 2, 1, 0, 1, -3, 2, 2, 1], [2, 3, 2]); - const c = tf.tensor2d([1, 2], [1, 2]); - const act: tf.fused.Activation = 'relu'; - const transposeA = false; - const transposeB = false; - - const d = tf.fused.matMul( - {a, b, transposeA, transposeB, bias: c, activation: act}); - - expect(d.shape).toEqual([2, 2, 2]); - expectArraysClose(await d.data(), [2, 6, 0, 18, 0, 30, 0, 42]); - }); - - it('fused A x B with 2d bias only', async () => { - const a = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - const b = tf.tensor2d([0, 1, -3, 2, 2, 1], [3, 2]); - const c = tf.tensor2d([1, 1, 1, 1], [2, 2]); - const transposeA = false; - const transposeB = false; - - const d = tf.fused.matMul( - {a, b, transposeA, transposeB, bias: c, activation: 'linear'}); - - expect(d.shape).toEqual([2, 2]); - expectArraysClose(await d.data(), [1, 9, -2, 21]); - }); - - it('fused A x B with relu gradient', async () => { - const a = tf.tensor2d([1, 2, 3, 10, 20, -30], [2, 3]); - const b = tf.tensor2d([2, 3, 4, -1, 2, 3], [3, 2]); - const dy = tf.tensor2d([1, 10, 20, 30], [2, 2]); - const transposeA = false; - const transposeB = false; - - const grads = tf.grads((a, b) => { - const prod = tf.matMul(a, b, transposeA, transposeB); - return tf.relu(prod); - }); - - const fusedGrads = tf.grads((a, b) => { - return tf.fused.matMul( - {a, b, transposeA, transposeB, bias: null, activation: 'relu'}); - }); - - const [da, db] = grads([a, b], dy); - const [fusedDa, fusedDb] = fusedGrads([a, b], dy); - expectArraysClose(await da.array(), await fusedDa.array()); - expectArraysClose(await db.data(), await fusedDb.array()); - }); - - it('gradient with clones A x B with relu', () => { - const a = tf.tensor2d([1, 2, 3, 10, 20, -30], [2, 3]); - const b = tf.tensor2d([2, 3, 4, -1, 2, 3], [3, 2]); - const dy = tf.tensor2d([1, 10, 20, 30], [2, 2]); - const transposeA = false; - const transposeB = false; - - const fusedGrads = tf.grads((a, b) => { - return tf.fused - .matMul({ - a: a.clone(), - b: b.clone(), - transposeA, - transposeB, - bias: null, - activation: 'relu' - }) - .clone(); - }); - - const [fusedDa, fusedDb] = fusedGrads([a, b], dy); - expect(fusedDa.shape).toEqual(a.shape); - expect(fusedDb.shape).toEqual(b.shape); - }); - - it('fused A x B with relu bias gradient', async () => { - const a = tf.tensor2d([1, 2, 3, 10, 20, -30], [2, 3]); - const b = tf.tensor2d([2, 3, 4, -1, 2, 3], [3, 2]); - const c = tf.tensor2d([1, 1, 1, 1], [2, 2]); - const transposeA = false; - const transposeB = false; - - const dy = tf.tensor2d([1, 10, 20, 30], [2, 2]); - - const grads = tf.grads((a, b, c) => { - const prod = tf.matMul(a, b, transposeA, transposeB); - const sum = tf.add(prod, c); - return tf.relu(sum); - }); - - const fusedGrads = tf.grads((a, b, c) => { - return tf.fused.matMul( - {a, b, transposeA, transposeB, bias: c, activation: 'relu'}); - }); - - const [da, db, dc] = grads([a, b, c], dy); - const [fusedDa, fusedDb, fusedDc] = fusedGrads([a, b, c], dy); - - expectArraysClose(await da.array(), await fusedDa.array()); - expectArraysClose(await db.array(), await fusedDb.array()); - expectArraysClose(await dc.array(), await fusedDc.array()); - }); - - it('fused A x B with relu bias gradient transpose', async () => { - const a = tf.tensor2d([1, 2, 3, 10, 20, -30], [3, 2]); - const b = tf.tensor2d([2, 3, 4, -1, 2, 3], [3, 2]); - const c = tf.tensor2d([1, 1, 1, 1], [2, 2]); - const transposeA = true; - const transposeB = false; - - const dy = tf.tensor2d([1, 10, 20, 30], [2, 2]); - - const grads = tf.grads((a, b, c) => { - const prod = tf.matMul(a, b, transposeA, transposeB); - const sum = tf.add(prod, c); - return tf.relu(sum); - }); - - const fusedGrads = tf.grads((a, b, c) => { - return tf.fused.matMul( - {a, b, transposeA, transposeB, bias: c, activation: 'relu'}); - }); - - const [da, db, dc] = grads([a, b, c], dy); - const [fusedDa, fusedDb, fusedDc] = fusedGrads([a, b, c], dy); - - expectArraysClose(await da.array(), await fusedDa.array()); - expectArraysClose(await db.array(), await fusedDb.array()); - expectArraysClose(await dc.array(), await fusedDc.array()); - }); - - it('fused A x B with relu and broadcasted bias gradient', async () => { - const a = tf.tensor2d([1, 2, 3, 10, 20, -30], [2, 3]); - const b = tf.tensor2d([2, 3, 4, -1, 2, 3], [3, 2]); - const c = tf.tensor2d([[1]]); - const transposeA = false; - const transposeB = false; - - const dy = tf.tensor2d([1, 10, 20, 30], [2, 2]); - - const grads = tf.grads((a, b, c) => { - const prod = tf.matMul(a, b, transposeA, transposeB); - const sum = tf.add(prod, c); - return tf.relu(sum); - }); - - const fusedGrads = tf.grads((a, b, c) => { - return tf.fused.matMul( - {a, b, transposeA, transposeB, bias: c, activation: 'relu'}); - }); - - const [da, db, dc] = grads([a, b, c], dy); - const [fusedDa, fusedDb, fusedDc] = fusedGrads([a, b, c], dy); - - expectArraysClose(await da.array(), await fusedDa.array()); - expectArraysClose(await db.array(), await fusedDb.array()); - expectArraysClose(await dc.array(), await fusedDc.array()); - }); - - it('fused matmul with relu6 and gradients', async () => { - const a = tf.tensor2d([1, 2, 3, 10, 20, -30], [2, 3]); - const b = tf.tensor2d([2, 3, 4, -1, 2, 3], [3, 2]); - const dy = tf.tensor2d([1, 10, 20, 30], [2, 2]); - const transposeA = false; - const transposeB = false; - - const fusedGrads = tf.grads((a, b) => { - return tf.fused.matMul( - {a, b, transposeA, transposeB, bias: null, activation: 'relu6'}); - }); - const [fusedDa, fusedDb] = fusedGrads([a, b], dy); - - const grads = tf.grads((a, b) => { - const prod = tf.matMul(a, b, transposeA, transposeB); - return tf.relu6(prod); - }); - const [da, db] = grads([a, b], dy); - - expectArraysClose(await da.array(), await fusedDa.array()); - expectArraysClose(await db.data(), await fusedDb.array()); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/fused/mat_mul.ts b/tfjs-master/tfjs-core/src/ops/fused/mat_mul.ts deleted file mode 100644 index b1ba4fd19..000000000 --- a/tfjs-master/tfjs-core/src/ops/fused/mat_mul.ts +++ /dev/null @@ -1,213 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../../engine'; -import {customGrad} from '../../gradients'; -import {_FusedMatMul, _FusedMatMulAttrs, _FusedMatMulInputs} from '../../kernel_names'; -import {NamedAttrMap} from '../../kernel_registry'; -import {Tensor, Tensor3D} from '../../tensor'; -import {GradSaveFunc, NamedTensorMap} from '../../tensor_types'; -import {makeTypesMatch} from '../../tensor_util'; -import {convertToTensor} from '../../tensor_util_env'; -import {TensorLike} from '../../types'; -import * as util from '../../util'; - -import {add} from '../add'; -import * as broadcast_util from '../broadcast_util'; -import {Activation} from '../fused_types'; -import {applyActivation, getFusedBiasGradient, getFusedDyActivation, shouldFuse} from '../fused_util'; -import {matMul as unfusedMatMul} from '../mat_mul'; -import {op} from '../operation'; -import {reshape} from '../reshape'; - -/** - * Computes the dot product of two matrices with optional activation and bias. - * - * ```js - * const a = tf.tensor2d([-1, -2], [1, 2]); - * const b = tf.tensor2d([1, 2, 3, 4], [2, 2]); - * const bias = tf.tensor2d([1, 2], [1, 2]); - * - * tf.fused.matMul({a, b, bias, activation: 'relu'}).print(); - * ``` - * - * @param obj An object with the following properties: - * - `a` First matrix in dot product operation. - * - `b` Second matrix in dot product operation. - * - `transposeA` If true, `a` is transposed before multiplication. - * - `transposeB` If true, `b` is transposed before multiplication. - * - `bias` Matrix to be added to the result. - * - `activation` Name of activation kernel (defaults to `linear`). - * - `preluActivationWeights` Tensor of prelu weights. - * - `leakyreluAlpha` Alpha of leakyrelu. - */ -function fusedMatMul_({ - a, - b, - transposeA = false, - transposeB = false, - bias, - activation = 'linear', - preluActivationWeights, - leakyreluAlpha = 0.2, -}: { - a: Tensor|TensorLike, - b: Tensor|TensorLike, - transposeA?: boolean, - transposeB?: boolean, - bias?: Tensor|TensorLike, - activation?: Activation, - preluActivationWeights?: Tensor - leakyreluAlpha?: number -}): Tensor { - if (shouldFuse(ENGINE.state.gradientDepth, activation) === false) { - let result = unfusedMatMul(a, b, transposeA, transposeB); - if (bias != null) { - result = add(result, bias); - } - - return applyActivation( - result, activation, preluActivationWeights, leakyreluAlpha); - } - - let $a = convertToTensor(a, 'a', 'fused matMul'); - let $b = convertToTensor(b, 'b', 'fused matMul'); - [$a, $b] = makeTypesMatch($a, $b); - - const innerShapeA = - transposeA ? $a.shape[$a.rank - 2] : $a.shape[$a.rank - 1]; - const innerShapeB = - transposeB ? $b.shape[$b.rank - 1] : $b.shape[$b.rank - 2]; - - const outerShapeA = - transposeA ? $a.shape[$a.rank - 1] : $a.shape[$a.rank - 2]; - const outerShapeB = - transposeB ? $b.shape[$b.rank - 2] : $b.shape[$b.rank - 1]; - - const outerDimsA = $a.shape.slice(0, -2); - const outerDimsB = $b.shape.slice(0, -2); - const batchDimA = util.sizeFromShape(outerDimsA); - const batchDimB = util.sizeFromShape(outerDimsB); - - util.assert( - innerShapeA === innerShapeB, - () => `Error in fused matMul: inner shapes (${innerShapeA}) and (` + - `${innerShapeB}) of Tensors with shapes ${$a.shape} and ` + - `${$b.shape} and transposeA=${transposeA}` + - ` and transposeB=${transposeB} must match.`); - - const outShapeOuterDims = broadcast_util.assertAndGetBroadcastShape( - $a.shape.slice(0, -2), $b.shape.slice(0, -2)); - const outShape = outShapeOuterDims.concat([outerShapeA, outerShapeB]); - - const a3D: Tensor3D = transposeA ? - reshape($a, [batchDimA, innerShapeA, outerShapeA]) : - reshape($a, [batchDimA, outerShapeA, innerShapeA]); - const b3D: Tensor3D = transposeB ? - reshape($b, [batchDimB, outerShapeB, innerShapeB]) : - reshape($b, [batchDimB, innerShapeB, outerShapeB]); - - let $bias: Tensor; - if (bias != null) { - $bias = convertToTensor(bias, 'bias', 'fused matMul'); - [$bias] = makeTypesMatch($bias, $a); - - broadcast_util.assertAndGetBroadcastShape(outShape, $bias.shape); - } - - let $preluActivationWeights: Tensor; - if (preluActivationWeights != null) { - $preluActivationWeights = convertToTensor( - preluActivationWeights, 'prelu weights', 'fused matMul'); - } - - const grad = (dy: Tensor3D, saved: Tensor[]) => { - const [a3D, b3D, y, $bias] = saved; - // we reshape dy because the result of the forward is not - // necessarily going to be a 3d tensor due to a reshape done at the end of - // the customOp. - const dyActivation = - getFusedDyActivation(reshape(dy, y.shape), y, activation); - let aDer: Tensor; - let bDer: Tensor; - - if (!transposeA && !transposeB) { - aDer = unfusedMatMul(dyActivation, b3D, false, true); - bDer = unfusedMatMul(a3D, dyActivation, true, false); - } else if (!transposeA && transposeB) { - aDer = unfusedMatMul(dyActivation, b3D, false, false); - bDer = unfusedMatMul(dyActivation, a3D, true, false); - } else if (transposeA && !transposeB) { - aDer = unfusedMatMul(b3D, dyActivation, false, true); - bDer = unfusedMatMul(a3D, dyActivation, false, false); - } else { - aDer = unfusedMatMul(b3D, dyActivation, true, true); - bDer = unfusedMatMul(dyActivation, a3D, true, true); - } - - if (bias != null) { - const biasDer = getFusedBiasGradient($bias, dyActivation); - return [aDer, bDer, biasDer]; - } else { - return [aDer, bDer]; - } - }; - - const inputs: _FusedMatMulInputs = { - a: a3D, - b: b3D, - bias: $bias, - preluActivationWeights: $preluActivationWeights - }; - const attrs: _FusedMatMulAttrs = - {transposeA, transposeB, activation, leakyreluAlpha}; - - // Depending on the the params passed in we will have different number of - // inputs and thus a a different number of elements in the gradient. - if (bias == null) { - const customOp = - customGrad((a3D: Tensor3D, b3D: Tensor3D, save: GradSaveFunc) => { - const res = - // tslint:disable-next-line: no-unnecessary-type-assertion - ENGINE.runKernel( - _FusedMatMul, inputs as unknown as NamedTensorMap, - attrs as unknown as NamedAttrMap) as Tensor; - - save([a3D, b3D, res]); - - return {value: reshape(res, outShape), gradFunc: grad}; - }); - return customOp(a3D, b3D); - } else { - const customOpWithBias = customGrad( - (a3D: Tensor3D, b3D: Tensor3D, $bias: Tensor, save: GradSaveFunc) => { - const res = - // tslint:disable-next-line: no-unnecessary-type-assertion - ENGINE.runKernel( - _FusedMatMul, inputs as unknown as NamedTensorMap, - attrs as unknown as NamedAttrMap) as Tensor; - - save([a3D, b3D, res, $bias]); - - return {value: reshape(res, outShape), gradFunc: grad}; - }); - - return customOpWithBias(a3D, b3D, $bias); - } - } - - export const matMul = /* @__PURE__ */ op({fusedMatMul_}); diff --git a/tfjs-master/tfjs-core/src/ops/fused_ops.ts b/tfjs-master/tfjs-core/src/ops/fused_ops.ts deleted file mode 100644 index 13ebb8cbf..000000000 --- a/tfjs-master/tfjs-core/src/ops/fused_ops.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {conv2d} from './fused/conv2d'; -import {depthwiseConv2d} from './fused/depthwise_conv2d'; -import {matMul} from './fused/mat_mul'; -import {Activation} from './fused_types'; - -export {Activation, conv2d, depthwiseConv2d, matMul}; diff --git a/tfjs-master/tfjs-core/src/ops/fused_types.ts b/tfjs-master/tfjs-core/src/ops/fused_types.ts deleted file mode 100644 index 086e26d0c..000000000 --- a/tfjs-master/tfjs-core/src/ops/fused_types.ts +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @license - * Copyright 2020 Google Inc. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Tensor, Tensor3D, Tensor4D} from '../tensor'; -import {Conv2DInfo} from './conv_util'; - -export type FusedConv2DConfig = { - input: Tensor4D, - filter: Tensor4D, - convInfo: Conv2DInfo, - bias?: Tensor, - activation?: Activation, - preluActivationWeights?: Tensor, - leakyreluAlpha?: number -}; - -export type FusedBatchMatMulConfig = { - a: Tensor3D, - b: Tensor3D, - transposeA: boolean, - transposeB: boolean, - bias?: Tensor, - activation?: Activation, - preluActivationWeights?: Tensor, - leakyreluAlpha?: number -}; - -export type Activation = - 'linear'|'relu'|'prelu'|'elu'|'relu6'|'leakyrelu'|'sigmoid'; diff --git a/tfjs-master/tfjs-core/src/ops/fused_util.ts b/tfjs-master/tfjs-core/src/ops/fused_util.ts deleted file mode 100644 index 5afa311c5..000000000 --- a/tfjs-master/tfjs-core/src/ops/fused_util.ts +++ /dev/null @@ -1,83 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Tensor} from '../tensor'; - -import * as broadcast_util from './broadcast_util'; -import {elu} from './elu'; -import {Activation} from './fused_types'; -import {leakyRelu} from './leaky_relu'; -import {mul} from './mul'; -import {prelu} from './prelu'; -import {relu} from './relu'; -import {relu6} from './relu6'; -import {reshape} from './reshape'; -import {sigmoid} from './sigmoid'; -import {step} from './step'; -import {sum} from './sum'; - -// Returns gradient for fused activation. -export function getFusedDyActivation( - dy: Tensor, y: Tensor, activation: Activation): Tensor { - if (activation == null || activation === 'linear') { - return dy; - } - if (activation === 'relu') { - return mul(dy, step(y)); - } - throw new Error( - `Cannot compute gradient for fused activation ${activation}.`); -} - -// Returns gradient for fused bias. -export function getFusedBiasGradient( - bias: Tensor, dyActivation: Tensor): Tensor { - let res = dyActivation; - const reduceAxes = - broadcast_util.getReductionAxes(bias.shape, dyActivation.shape); - if (reduceAxes.length > 0) { - res = sum(res, reduceAxes); - } - return reshape(res, bias.shape); -} - -export function applyActivation( - x: Tensor, activation: Activation, preluActivationWeights?: Tensor, - leakyreluAlpha?: number): Tensor { - if (activation === 'linear') { - return x; - } else if (activation === 'relu') { - return relu(x); - } else if (activation === 'elu') { - return elu(x); - } else if (activation === 'relu6') { - return relu6(x); - } else if (activation === 'prelu') { - return prelu(x, preluActivationWeights); - } else if (activation === 'leakyrelu') { - return leakyRelu(x, leakyreluAlpha); - } else if (activation === 'sigmoid') { - return sigmoid(x); - } - throw new Error(`Unknown fused activation ${activation}.`); -} - -// Whether we should call fused ops. -export const shouldFuse = (gradientDepth: number, activation: Activation) => { - const gradientMode = gradientDepth > 0; - return !gradientMode || activation === 'linear'; -}; diff --git a/tfjs-master/tfjs-core/src/ops/gather.ts b/tfjs-master/tfjs-core/src/ops/gather.ts deleted file mode 100644 index 7ca40b3a4..000000000 --- a/tfjs-master/tfjs-core/src/ops/gather.ts +++ /dev/null @@ -1,67 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {GatherV2, GatherV2Attrs, GatherV2Inputs} from '../kernel_names'; -import {NamedAttrMap} from '../kernel_registry'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -import {op} from './operation'; - -/** - * Gather slices from tensor `x`'s axis `axis` according to `indices`. - * - * ```js - * const x = tf.tensor1d([1, 2, 3, 4]); - * const indices = tf.tensor1d([1, 3, 3], 'int32'); - * - * x.gather(indices).print(); - * ``` - * - * ```js - * const x = tf.tensor2d([1, 2, 3, 4], [2, 2]); - * const indices = tf.tensor1d([1, 1, 0], 'int32'); - * - * x.gather(indices).print(); - * ``` - * @param x The input tensor whose slices are to be gathered. - * @param indices The indices of the values to extract. - * @param axis The axis over which to select values. Defaults to 0. - * @param batchDims Optional. The number of batch dimensions. It must be less - * than or equal to rank(indices). Defaults to 0. - * The output tensor will have shape of - * `x.shape[:axis] + indices.shape[batchDims:] + x.shape[axis + 1:]` - * - * @doc {heading: 'Tensors', subheading: 'Slicing and Joining'} - */ -function gather_( - x: T|TensorLike, indices: Tensor|TensorLike, axis = 0, batchDims = 0): T { - const $x = convertToTensor(x, 'x', 'gather'); - const $indices = convertToTensor(indices, 'indices', 'gather', 'int32'); - - const inputs: GatherV2Inputs = {x: $x, indices: $indices}; - const attrs: GatherV2Attrs = {axis, batchDims}; - - return ENGINE.runKernel( - GatherV2, inputs as unknown as NamedTensorMap, - attrs as unknown as NamedAttrMap); -} - -export const gather = /* @__PURE__ */ op({gather_}); diff --git a/tfjs-master/tfjs-core/src/ops/gather_nd.ts b/tfjs-master/tfjs-core/src/ops/gather_nd.ts deleted file mode 100644 index 305c539fb..000000000 --- a/tfjs-master/tfjs-core/src/ops/gather_nd.ts +++ /dev/null @@ -1,72 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {ENGINE} from '../engine'; -import {GatherNd, GatherNdInputs} from '../kernel_names'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; -import {op} from './operation'; - -/** - * Gather slices from input tensor into a Tensor with shape specified by - * `indices`. - * - * `indices` is a K-dimensional integer tensor, best thought of as a - * (K-1)-dimensional tensor of indices into input, where each element defines a - * slice of input: - * output[\\(i_0, ..., i_{K-2}\\)] = input[indices[\\(i_0, ..., i_{K-2}\\)]] - * - * Whereas in `tf.gather`, `indices` defines slices into the first dimension of - * input, in `tf.gatherND`, `indices` defines slices into the first N dimensions - * of input, where N = indices.shape[-1]. - * - * The last dimension of indices can be at most the rank of input: - * indices.shape[-1] <= input.rank - * - * The last dimension of `indices` corresponds to elements - * (if indices.shape[-1] == input.rank) or slices - * (if indices.shape[-1] < input.rank) along dimension indices.shape[-1] of - * input. - * The output tensor has shape - * indices.shape[:-1] + input.shape[indices.shape[-1]:] - * - * Note that on CPU, if an out of bound index is found, an error is returned. On - * GPU, if an out of bound index is found, a 0 is stored in the corresponding - * output value. - * - * ```js - * const indices = tf.tensor2d([0, 1, 1, 0], [2,2], 'int32'); - * const input = tf.tensor2d([9, 10, 11, 12], [2, 2]); - * tf.gatherND(input, indices).print() // [10, 11] - * ``` - * - * @param x The tensor from which to gather values. - * @param indices Index tensor, must be of type int32. - * - * @doc {heading: 'Operations', subheading: 'Slicing and Joining'} - */ -function gatherND_(x: Tensor|TensorLike, indices: Tensor|TensorLike): Tensor { - const $indices = convertToTensor(indices, 'indices', 'gatherND', 'int32'); - const $x = convertToTensor(x, 'x', 'gatherND', 'string_or_numeric'); - - const inputs: GatherNdInputs = {params: $x, indices: $indices}; - - return ENGINE.runKernel(GatherNd, inputs as unknown as NamedTensorMap); -} - -export const gatherND = /* @__PURE__ */ op({gatherND_}); diff --git a/tfjs-master/tfjs-core/src/ops/gather_nd_test.ts b/tfjs-master/tfjs-core/src/ops/gather_nd_test.ts deleted file mode 100644 index 87b01dc01..000000000 --- a/tfjs-master/tfjs-core/src/ops/gather_nd_test.ts +++ /dev/null @@ -1,142 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -import {gatherND} from './gather_nd'; -import {scalar, tensor1d, tensor2d, tensor3d} from './ops'; - -describeWithFlags('gatherND', ALL_ENVS, () => { - it('should work for simple slice', async () => { - const indices = tensor2d([0, 4, 8], [3, 1], 'int32'); - const input = - tensor1d([100, 101, 102, 777, 778, 779, 1000, 1001, 1002], 'int32'); - const shape = [3]; - const result = gatherND(input, indices); - expect(result.shape).toEqual(shape); - expect(result.dtype).toEqual(input.dtype); - expectArraysClose(await result.data(), [100, 778, 1002]); - }); - - it('should work for indexing 2d', async () => { - const indices = tensor2d([0, 2], [2, 1], 'int32'); - const input = tensor2d( - [ - 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, - 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8 - ], - [8, 4], 'float32'); - const shape = [2, 4]; - const result = gatherND(input, indices); - expect(result.shape).toEqual(shape); - expect(result.dtype).toEqual(input.dtype); - expectArraysClose(await result.data(), [5, 5, 5, 5, 7, 7, 7, 7]); - }); - - it('should work for indexing 3d', async () => { - const indices = tensor2d([0, 2, 1, 1], [2, 2], 'int32'); - const input = tensor3d( - [ - 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, - 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8 - ], - [2, 4, 4], 'float32'); - const shape = [2, 4]; - const result = gatherND(input, indices); - expect(result.shape).toEqual(shape); - expect(result.dtype).toEqual(input.dtype); - expectArraysClose(await result.data(), [7, 7, 7, 7, 6, 6, 6, 6]); - }); - - it('should work for batch slice', async () => { - const indices = tensor3d([0, 4, 2], [3, 1, 1], 'int32'); - const input = - tensor1d([100, 101, 102, 777, 778, 779, 10000, 10001, 10002], 'int32'); - const shape = [3, 1]; - const result = gatherND(input, indices); - expect(result.shape).toEqual(shape); - expect(result.dtype).toEqual(input.dtype); - expectArraysClose(await result.data(), [100, 778, 102]); - }); - - it('should work for batch indexing 2d', async () => { - const indices = tensor3d([0, 2], [2, 1, 1], 'int32'); - const input = tensor2d( - [ - 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, - 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8 - ], - [8, 4], 'float32'); - const shape = [2, 1, 4]; - const result = gatherND(input, indices); - expect(result.shape).toEqual(shape); - expect(result.dtype).toEqual(input.dtype); - expectArraysClose(await result.data(), [5, 5, 5, 5, 7, 7, 7, 7]); - }); - - it('should work for batch indexing 3d', async () => { - const indices = tensor3d([0, 2, 1, 1], [2, 1, 2], 'int32'); - const input = tensor3d( - [ - 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, - 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8 - ], - [2, 4, 4], 'float32'); - const shape = [2, 1, 4]; - const result = gatherND(input, indices); - expect(result.shape).toEqual(shape); - expect(result.dtype).toEqual(input.dtype); - expectArraysClose(await result.data(), [7, 7, 7, 7, 6, 6, 6, 6]); - }); - - it('should work for TensorLike inputs', async () => { - const indices = [[0], [4], [8]]; - const input = [100, 101, 102, 777, 778, 779, 1000, 1001, 1002]; - const shape = [3]; - const result = gatherND(input, indices); - expect(result.shape).toEqual(shape); - expect(result.dtype).toEqual('float32'); - expectArraysClose(await result.data(), [100, 778, 1002]); - }); - - it('should throw error when indices are not int32', () => { - const indices = tensor1d([1], 'float32'); - const input = tensor2d( - [100, 101, 102, 103, 777, 778, 779, 780, 10000, 10001, 10002, 10004], - [3, 4], 'float32'); - expect(() => gatherND(input, indices)).toThrow(); - }); - it('should throw error when indices are scalar', () => { - const indices = scalar(1, 'int32'); - const input = tensor2d( - [100, 101, 102, 103, 777, 778, 779, 780, 10000, 10001, 10002, 10004], - [3, 4], 'float32'); - expect(() => gatherND(input, indices)).toThrow(); - }); - it('should throw error when x is scalar', () => { - const indices = tensor2d([0, 4, 2], [3, 1], 'int32'); - const input = scalar(1.0, 'float32'); - expect(() => gatherND(input, indices)).toThrow(); - }); - it('should throw error when indices inner dim > x shape length', () => { - const indices = tensor2d([0, 4, 2], [1, 3], 'int32'); - const input = - tensor2d([100, 101, 102, 10000, 10001, 10002], [3, 2], 'float32'); - expect(() => gatherND(input, indices)).toThrow(); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/gather_nd_util.ts b/tfjs-master/tfjs-core/src/ops/gather_nd_util.ts deleted file mode 100644 index 6e9887e24..000000000 --- a/tfjs-master/tfjs-core/src/ops/gather_nd_util.ts +++ /dev/null @@ -1,85 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import { TensorInfo } from '../tensor_info'; -import {computeStrides, sizeFromShape} from '../util'; - -/** - * Validate gather nd inputs. - * - * @param tensor The tensor contains the source values. - * @param indices The tensor contains the indices to slice the source. - * - * @returns [resultShape, numUpdates, sliceSize, strides] - */ -export function prepareAndValidate(tensor: TensorInfo, indices: TensorInfo): - [number[], number, number, number[]] { - const tensorRank = tensor.shape.length; - const indicesRank = indices.shape.length; - if (tensorRank < 1) { - throw new Error( - 'tf.gatherND() expects the input to be rank 1 or higher,' + - ` but the rank was ${tensorRank}.`); - } - if (indicesRank < 1) { - throw new Error( - 'tf.gatherND() expects the indices to be rank 1 or higher,' + - ` but the rank was ${indicesRank}.`); - } - if (indices.dtype !== 'int32') { - throw new Error( - 'tf.gatherND() expects the indices to be int32 type,' + - ` but the dtype was ${indices.dtype}.`); - } - if (indices.shape[indicesRank - 1] > tensorRank) { - throw new Error( - 'index innermost dimension length must be <= tensor rank; saw: ' + - `${indices.shape[indicesRank - 1]} vs. ${tensorRank}`); - } - - if (sizeFromShape(tensor.shape) === 0) { - throw new Error( - 'Requested more than 0 entries, but input is empty.' + - ` Input shape: ${tensor.shape}.`); - } - - const indicesShape = indices.shape; - const sliceRank = indicesShape[indicesShape.length - 1]; - - // The result shape is - // indices.shape[:-1] + params.shape[indices.shape[-1]:] - let nResult = 1; - for (let i = 0; i < indicesShape.length - 1; ++i) { - nResult *= indicesShape[i]; - } - - const inputShape = tensor.shape; - - const resultShape = indicesShape.slice(); - resultShape.pop(); - - let sliceSize = 1; - for (let i = sliceRank; i < tensorRank; ++i) { - sliceSize *= inputShape[i]; - resultShape.push(inputShape[i]); - } - - const strides = - [...computeStrides(tensor.shape).map(stride => stride / sliceSize), - 1].slice(0, sliceRank); - - return [resultShape, nResult, sliceSize, strides]; -} diff --git a/tfjs-master/tfjs-core/src/ops/gather_test.ts b/tfjs-master/tfjs-core/src/ops/gather_test.ts deleted file mode 100644 index 14bb00eac..000000000 --- a/tfjs-master/tfjs-core/src/ops/gather_test.ts +++ /dev/null @@ -1,613 +0,0 @@ -/** - * @license - * Copyright 2020 Google Inc. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('gather', ALL_ENVS, (env) => { - it('1D (gather), scalar indices', async () => { - const t = tf.tensor1d([1, 2, 3]); - - const t2 = tf.gather(t, tf.scalar(1, 'int32'), 0); - - expect(t2.shape).toEqual([]); - expectArraysClose(await t2.data(), [2]); - }); - - it('1D (gather), 1D indices', async () => { - const t = tf.tensor1d([1, 2, 3]); - - const t2 = tf.gather(t, tf.tensor1d([0, 2, 0, 1], 'int32'), 0); - - expect(t2.shape).toEqual([4]); - expectArraysClose(await t2.data(), [1, 3, 1, 2]); - }); - - it('1D (gather), 2D indices', async () => { - const t = tf.tensor1d([1, 2, 3]); - - const t2 = tf.gather(t, tf.tensor2d([0, 2, 0, 1], [1, 4], 'int32'), 0); - - expect(t2.shape).toEqual([1, 4]); - expectArraysClose(await t2.data(), [1, 3, 1, 2]); - }); - - it('2D (gather), scalar indices', async () => { - const t = tf.tensor2d([1, 11, 2, 22], [2, 2]); - let t2 = tf.gather(t, tf.scalar(1, 'int32'), 0); - expect(t2.shape).toEqual([2]); - expectArraysClose(await t2.data(), [2, 22]); - - t2 = tf.gather(t, tf.scalar(1, 'int32'), 1); - expect(t2.shape).toEqual([2]); - expectArraysClose(await t2.data(), [11, 22]); - }); - - it('2D (gather), 1D indices', async () => { - const t = tf.tensor2d([1, 11, 2, 22], [2, 2]); - let t2 = tf.gather(t, tf.tensor1d([1, 0, 0, 1], 'int32'), 0); - expect(t2.shape).toEqual([4, 2]); - expectArraysClose(await t2.data(), [2, 22, 1, 11, 1, 11, 2, 22]); - - t2 = tf.gather(t, tf.tensor1d([1, 0, 0, 1], 'int32'), 1); - expect(t2.shape).toEqual([2, 4]); - expectArraysClose(await t2.data(), [11, 1, 1, 11, 22, 2, 2, 22]); - }); - - it('2D (gather), 2D indices', async () => { - const t = tf.tensor2d([1, 11, 2, 22], [2, 2]); - let t2 = tf.gather(t, tf.tensor2d([1, 0, 0, 1], [2, 2], 'int32'), 0); - expect(t2.shape).toEqual([2, 2, 2]); - expectArraysClose(await t2.data(), [2, 22, 1, 11, 1, 11, 2, 22]); - - t2 = tf.gather(t, tf.tensor2d([1, 0, 0, 1], [2, 2], 'int32'), 1); - expect(t2.shape).toEqual([2, 2, 2]); - expectArraysClose(await t2.data(), [11, 1, 1, 11, 22, 2, 2, 22]); - }); - - it('2D (gather), 2D indices, non-zero batchDims', async () => { - const t = tf.tensor2d([1, 11, 2, 22], [2, 2]); - const t2 = tf.gather(t, tf.tensor2d([1, 0, 0, 1], [2, 2], 'int32'), 1, 1); - expect(t2.shape).toEqual([2, 2]); - expectArraysClose(await t2.data(), [11, 1, 2, 22]); - }); - - it('2D (gather), 2D indices, negative batchDims', async () => { - const t = tf.tensor2d([1, 11, 2, 22], [2, 2]); - const t2 = tf.gather(t, tf.tensor2d([1, 0, 0, 1], [2, 2], 'int32'), 1, -1); - expect(t2.shape).toEqual([2, 2]); - expectArraysClose(await t2.data(), [11, 1, 2, 22]); - }); - - it('3D (gather), 1D indices', async () => { - const t = tf.tensor3d([1, 2, 3, 4, 5, 6, 7, 8], [2, 2, 2]); - - const t2 = tf.gather(t, tf.tensor1d([1, 0, 0, 1], 'int32'), 2); - - expect(t2.shape).toEqual([2, 2, 4]); - expectArraysClose( - await t2.data(), [2, 1, 1, 2, 4, 3, 3, 4, 6, 5, 5, 6, 8, 7, 7, 8]); - }); - - it('3D (gather), 2D indices', async () => { - const t = tf.tensor3d([1, 2, 3, 4, 5, 6, 7, 8], [2, 2, 2]); - - const t2 = tf.gather(t, tf.tensor2d([1, 0, 0, 1], [2, 2], 'int32'), 2); - - expect(t2.shape).toEqual([2, 2, 2, 2]); - expectArraysClose( - await t2.data(), [2, 1, 1, 2, 4, 3, 3, 4, 6, 5, 5, 6, 8, 7, 7, 8]); - }); - - it('3D (gather), 2D indices, non-zero batchDims', async () => { - const t = tf.tensor3d([1, 2, 3, 4], [1, 2, 2]); - - const t2 = tf.gather(t, tf.tensor2d([1, 0, 1], [1, 3], 'int32'), 2, 1); - - expect(t2.shape).toEqual([1, 2, 3]); - expectArraysClose(await t2.data(), [2, 1, 2, 4, 3, 4]); - }); - - it('throws when batch dims greater than axis', () => { - const t = tf.tensor3d([1, 2, 3, 4, 5, 6, 7, 8], [2, 2, 2]); - - expect(() => tf.gather(t, tf.tensor3d([1, 0, 1], [1, 1, 3], 'int32'), 2, 3)) - .toThrowError(/must be less than or equal to axis/); - }); - - it('throws when batch dims greater than indices rank', () => { - const t = tf.tensor4d([1, 2, 3, 4, 5, 6, 7, 8], [1, 2, 2, 2]); - - expect(() => tf.gather(t, tf.tensor2d([1, 0, 1], [1, 3], 'int32'), 2, 3)) - .toThrowError(/Expect batchDims in the range of /); - }); - - it('throws when batch dims do not match', () => { - const t = tf.tensor3d([1, 2, 3, 4, 5, 6, 7, 8], [2, 2, 2]); - - expect(() => tf.gather(t, tf.tensor2d([1, 0, 1], [1, 3], 'int32'), 2, 1)) - .toThrowError(/should be equal to indices.shape/); - }); - - it('bool (gather), 1D indices', async () => { - const t = tf.tensor1d([true, false, true], 'bool'); - - const t2 = tf.gather(t, tf.tensor1d([0, 2, 0, 1], 'int32'), 0); - - expect(t2.shape).toEqual([4]); - expect(t2.dtype).toBe('bool'); - expect(await t2.data()).toEqual(new Uint8Array([1, 1, 1, 0])); - }); - - it('bool (gather), 2D indices', async () => { - const t = tf.tensor1d([true, false, true], 'bool'); - - const t2 = tf.gather(t, tf.tensor2d([0, 2, 0, 1], [2, 2], 'int32'), 0); - - expect(t2.shape).toEqual([2, 2]); - expect(t2.dtype).toBe('bool'); - expect(await t2.data()).toEqual(new Uint8Array([1, 1, 1, 0])); - }); - - it('int32 (gather), 1D indices', async () => { - const t = tf.tensor1d([1, 2, 5], 'int32'); - - const t2 = tf.gather(t, tf.tensor1d([0, 2, 0, 1], 'int32'), 0); - - expect(t2.shape).toEqual([4]); - expect(t2.dtype).toBe('int32'); - expect(await t2.data()).toEqual(new Int32Array([1, 5, 1, 2])); - }); - - it('int32 (gather), 2D indices', async () => { - const t = tf.tensor1d([1, 2, 5], 'int32'); - - const t2 = tf.gather(t, tf.tensor2d([0, 2, 0, 1], [2, 2], 'int32'), 0); - - expect(t2.shape).toEqual([2, 2]); - expect(t2.dtype).toBe('int32'); - expect(await t2.data()).toEqual(new Int32Array([1, 5, 1, 2])); - }); - - it('propagates NaNs', async () => { - const t = tf.tensor1d([1, 2, NaN]); - - const t2 = tf.gather(t, tf.tensor1d([0, 2, 0, 1], 'int32'), 0); - - expect(t2.shape).toEqual([4]); - expectArraysClose(await t2.data(), [1, NaN, 1, 2]); - }); - - it('chaining, axis=1', () => { - const x = tf.zeros([2, 4, 6]); - // [0, 2, 4] - const indices = tf.range(0, 6, 2, 'int32'); - const axis = 2; - expect(x.gather(indices, axis).shape).toEqual([2, 4, 3]); - }); - - it('indices not int32 throws error', () => { - const x = tf.zeros([2, 4, 6]); - // [0, 2, 4] - const indices = tf.range(0, 6, 2); - const axis = 2; - expect(() => x.gather(indices, axis)).toThrowError(); - }); - - it('throws when passed x as a non-tensor', () => { - expect(() => tf.gather({} as tf.Tensor, tf.tensor1d([1]))) - .toThrowError(/Argument 'x' passed to 'gather' must be a Tensor/); - }); - - it('throws when passed indices as a non-tensor', () => { - // tslint:disable-next-line:no-any - expect(() => tf.gather(tf.tensor1d([1]), {} as any)) - .toThrowError(/Argument 'indices' passed to 'gather' must be a Tensor/); - }); - - it('throws when index is out of bound', async () => { - const t = tf.tensor2d([1, 11, 2, 22], [2, 2]); - expect(() => tf.gather(t, tf.tensor1d([100], 'int32'))) - .toThrowError(/GatherV2: the index value 100 is not in \[0, 1\]/); - expect(() => tf.gather(t, tf.tensor1d([-1], 'int32'))) - .toThrowError(/GatherV2: the index value -1 is not in \[0, 1\]/); - }); - - it('accepts a tensor-like object', async () => { - const res = tf.gather([1, 2, 3], [0, 2, 0, 1], 0); - expect(res.shape).toEqual([4]); - expectArraysClose(await res.data(), [1, 3, 1, 2]); - }); - - it('gradient 1D (gather), 1D indices', async () => { - const t = tf.tensor1d([1, 2, 3]); - const indices = tf.tensor1d([0, 2, 0, 1], 'int32'); - const dy = tf.tensor([3, 4, 5, 6]); - - const gradients = tf.grad(t => tf.gather(t, indices))(t, dy); - - expect(gradients.shape).toEqual(t.shape); - expectArraysClose(await gradients.data(), [8, 6, 4]); - }); - - it('gradient with clones', () => { - const t = tf.tensor1d([1, 2, 3]); - const indices = tf.tensor1d([0, 2, 0, 1], 'int32'); - const gradF = tf.grad(t => tf.gather(t.clone(), indices.clone()).clone()); - const dt = gradF(t); - expect(dt.shape).toEqual(t.shape); - }); - - it('gradient 1D (gather), 2D indices', async () => { - const t = tf.tensor1d([1, 2, 3]); - const indices = tf.tensor2d([0, 2, 0, 1], [2, 2], 'int32'); - const dy = tf.tensor2d([3, 4, 5, 6], [2, 2]); - - const gradients = tf.grad(t => tf.gather(t, indices))(t, dy); - - expect(gradients.shape).toEqual(t.shape); - expectArraysClose(await gradients.data(), [8, 6, 4]); - }); - - it('gradient 2D (gather) axis=0 shape=[2, 2] 1D indices', async () => { - const t = tf.tensor2d([1, 11, 2, 22], [2, 2]); - const indices = tf.tensor1d([1, 0, 0, 1], 'int32'); - const dy = tf.tensor([3, 4, 5, 6, 7, 8, 9, 10], [4, 2]); - const axis = 0; - - const gradients = tf.grad(t => tf.gather(t, indices, axis))(t, dy); - - expect(gradients.shape).toEqual(t.shape); - expectArraysClose(await gradients.data(), [12, 14, 12, 14]); - }); - - it('gradient 2D (gather) axis=0 shape=[2, 2] 2D indices', async () => { - const t = tf.tensor2d([1, 11, 2, 22], [2, 2]); - const indices = tf.tensor2d([1, 0, 0, 1], [2, 2], 'int32'); - const dy = tf.tensor([3, 4, 5, 6, 7, 8, 9, 10], [2, 2, 2]); - const axis = 0; - - const gradients = tf.grad(t => tf.gather(t, indices, axis))(t, dy); - - expect(gradients.shape).toEqual(t.shape); - expectArraysClose(await gradients.data(), [12, 14, 12, 14]); - }); - - it('gradient 2D (gather) axis=0 shape=[4, 1] 1D indices', async () => { - const t = tf.tensor2d([1, 11, 2, 22], [4, 1]); - const indices = tf.tensor1d([1, 0, 0, 1], 'int32'); - const dy = tf.tensor([23, 7, 19, 13], [4, 1]); - const axis = 0; - - const gradients = tf.grad(t => tf.gather(t, indices, axis))(t, dy); - - expect(gradients.shape).toEqual(t.shape); - expectArraysClose(await gradients.data(), [26, 36, 0, 0]); - }); - - it('gradient 2D (gather) axis=0 shape=[4, 1] 2D indices', async () => { - const t = tf.tensor2d([1, 11, 2, 22], [4, 1]); - const indices = tf.tensor2d([1, 0, 0, 1], [2, 2], 'int32'); - const dy = tf.tensor([23, 7, 19, 13], [2, 2, 1]); - const axis = 0; - - const gradients = tf.grad(t => tf.gather(t, indices, axis))(t, dy); - - expect(gradients.shape).toEqual(t.shape); - expectArraysClose(await gradients.data(), [26, 36, 0, 0]); - }); - - it('gradient 2D (gather) axis=1 shape=[4, 2] 1D indices batchDims 1', - async () => { - const t = tf.variable(tf.tensor([[0, 1], - [1, 2], - [2, 3], - [3, 4]])); - const indices = tf.tensor([0, 1, 0, 1], [4, 1], 'int32'); - const dy = tf.tensor([1, 1, 1, 1], [4, 1]); - const axis = 1; - - const gradients = tf.grad(t => tf.gather(t, indices, axis, 1))(t, dy); - - expect(gradients.shape).toEqual(t.shape); - expectArraysClose(await gradients.data(), [1, 0, 0, 1, 1, 0, 0, 1]); - }); - - it('gradient 2D (gather) axis=1 shape=[2, 2] 1D indices', async () => { - const t = tf.tensor2d([1, 11, 2, 22], [2, 2]); - const indices = tf.tensor1d([1, 0, 0, 1], 'int32'); - const dy = tf.tensor([3, 4, 5, 6, 7, 8, 9, 10], [2, 4]); - const axis = 1; - - const gradients = tf.grad(t => tf.gather(t, indices, axis))(t, dy); - - expect(gradients.shape).toEqual(t.shape); - expectArraysClose(await gradients.data(), [9, 9, 17, 17]); - }); - - it('gradient 2D (gather) axis=1 shape=[2, 2] 2D indices', async () => { - const t = tf.tensor2d([1, 11, 2, 22], [2, 2]); - const indices = tf.tensor2d([1, 0, 0, 1], [2, 2], 'int32'); - const dy = tf.tensor([3, 4, 5, 6, 7, 8, 9, 10], [2, 2, 2]); - const axis = 1; - - const gradients = tf.grad(t => tf.gather(t, indices, axis))(t, dy); - - expect(gradients.shape).toEqual(t.shape); - expectArraysClose(await gradients.data(), [9, 9, 17, 17]); - }); - - it('gradient 2D (gather) axis=1 shape=[4, 1] 1D indices', async () => { - const t = tf.tensor2d([1, 11, 2, 22], [4, 1]); - const indices = tf.tensor1d([0, 0, 0, 0], 'int32'); - const dy = tf.tensor( - [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18], [4, 4]); - const axis = 1; - - const gradients = tf.grad(t => tf.gather(t, indices, axis))(t, dy); - - expect(gradients.shape).toEqual(t.shape); - expectArraysClose(await gradients.data(), [18, 34, 50, 66]); - }); - - it('gradient 2D (gather) axis=1 shape=[4, 1] 2D indices', async () => { - const t = tf.tensor2d([1, 11, 2, 22], [4, 1]); - const indices = tf.tensor2d([0, 0, 0, 0], [2, 2], 'int32'); - const dy = tf.tensor( - [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18], [4, 2, 2]); - const axis = 1; - - const gradients = tf.grad(t => tf.gather(t, indices, axis))(t, dy); - - expect(gradients.shape).toEqual(t.shape); - expectArraysClose(await gradients.data(), [18, 34, 50, 66]); - }); - - it('gradient 3D (gather) axis=0 shape=[2, 3, 2] 1D indices', async () => { - const t = tf.tensor3d([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [2, 3, 2]); - const indices = tf.tensor1d([1, 0, 0, 1], 'int32'); - const dy = tf.tensor( - [ - 2, -3, 4, 15, 6, 0.7, 1, 18, 0.01, 0, 12, 13, - 4, 15, 12, -7, 18, 19, 2, 21, 6, 23, 24, 25 - ], - [4, 3, 2]); - const axis = 0; - - const gradients = tf.grad(t => tf.gather(t, indices, axis))(t, dy); - - expect(gradients.shape).toEqual(t.shape); - expectArraysClose( - await gradients.data(), - [5, 33, 12.01, -7, 30, 32, 4, 18, 10, 38, 30, 25.7]); - }); - - it('gradient 3D (gather) axis=0 shape=[2, 3, 2] 2D indices', async () => { - const t = tf.tensor3d([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [2, 3, 2]); - const indices = tf.tensor2d([1, 0, 0, 1], [2, 2], 'int32'); - const dy = tf.tensor( - [ - 2, -3, 4, 15, 6, 0.7, 1, 18, 0.01, 0, 12, 13, - 4, 15, 12, -7, 18, 19, 2, 21, 6, 23, 24, 25 - ], - [2, 2, 3, 2]); - const axis = 0; - - const gradients = tf.grad(t => tf.gather(t, indices, axis))(t, dy); - - expect(gradients.shape).toEqual(t.shape); - expectArraysClose( - await gradients.data(), - [5, 33, 12.01, -7, 30, 32, 4, 18, 10, 38, 30, 25.7]); - }); - - it('gradient 3D (gather) axis=0 shape=[1, 4, 4]', async () => { - const t = tf.tensor3d( - [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], [1, 4, 4]); - const indices = tf.tensor1d([0, 0], 'int32'); - const dy = tf.tensor( - [ - 2, -3, 4, 15, 6, 0.7, 1, 18, 0.01, 0, 12, 13, 4, 15, 12, -7, - 18, 19, 2, 21, 6, 23, 24, 25, 101, 31, 34, 54, 1, 0, -3, -4 - ], - [2, 4, 4]); - const axis = 0; - - const gradients = tf.grad(t => tf.gather(t, indices, axis))(t, dy); - - expect(gradients.shape).toEqual(t.shape); - expectArraysClose( - await gradients.data(), - [20, 16, 6, 36, 12, 23.7, 25, 43, 101.01, 31, 46, 67, 5, 15, 9, -11]); - }); - - it('gradient 3D (gather) axis=0 shape=[1, 4, 4] 1D indices', async () => { - const t = tf.tensor3d( - [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], [1, 4, 4]); - const indices = tf.tensor1d([0, 0], 'int32'); - const dy = tf.tensor( - [ - 2, -3, 4, 15, 6, 0.7, 1, 18, 0.01, 0, 12, 13, 4, 15, 12, -7, - 18, 19, 2, 21, 6, 23, 24, 25, 101, 31, 34, 54, 1, 0, -3, -4 - ], - [2, 4, 4]); - const axis = 0; - - const gradients = tf.grad(t => tf.gather(t, indices, axis))(t, dy); - - expect(gradients.shape).toEqual(t.shape); - expectArraysClose( - await gradients.data(), - [20, 16, 6, 36, 12, 23.7, 25, 43, 101.01, 31, 46, 67, 5, 15, 9, -11]); - }); - - it('gradient 3D (gather) axis=1 shape=[2, 3, 2] 2D indices', async () => { - const t = tf.tensor3d([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [2, 3, 2]); - const indices = tf.tensor2d([1, 2, 2, 1], [2, 2], 'int32'); - const dy = tf.tensor( - [2, -3, 4, 15, 6, 0.7, 1, 18, 0.01, 0, 12, 13, 4, 15, 12, -7], - [2, 2, 2, 2]); - const axis = 1; - - const gradients = tf.grad(t => tf.gather(t, indices, axis))(t, dy); - - expect(gradients.shape).toEqual(t.shape); - expectArraysClose( - await gradients.data(), - [0, 0, 3, 15, 10, 15.7, 0, 0, 12.01, -7, 16, 28]); - }); - - it('gradient 3D (gather) axis=1 shape=[1, 4, 4] 1D indices', async () => { - const t = tf.tensor3d( - [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], [1, 4, 4]); - const indices = tf.tensor1d([1, 2, 2, 1], 'int32'); - const dy = tf.tensor( - [2, -3, 4, 15, 6, 0.7, 1, 18, 0.01, 0, 12, 13, 4, 15, 12, -7], - [1, 4, 4]); - const axis = 1; - - const gradients = tf.grad(t => tf.gather(t, indices, axis))(t, dy); - - expect(gradients.shape).toEqual(t.shape); - expectArraysClose( - await gradients.data(), - [0, 0, 0, 0, 6, 12, 16, 8, 6.01, .7, 13, 31, 0, 0, 0, 0]); - }); - - it('gradient 3D (gather) axis=1 shape=[1, 4, 4] 2D indices', async () => { - const t = tf.tensor3d( - [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], [1, 4, 4]); - const indices = tf.tensor2d([1, 2, 2, 1], [2, 2], 'int32'); - const dy = tf.tensor( - [2, -3, 4, 15, 6, 0.7, 1, 18, 0.01, 0, 12, 13, 4, 15, 12, -7], - [1, 2, 2, 4]); - const axis = 1; - - const gradients = tf.grad(t => tf.gather(t, indices, axis))(t, dy); - - expect(gradients.shape).toEqual(t.shape); - expectArraysClose( - await gradients.data(), - [0, 0, 0, 0, 6, 12, 16, 8, 6.01, .7, 13, 31, 0, 0, 0, 0]); - }); - - it('gradient 3D (gather) axis=2 shape=[2, 3, 2] 1D indices', async () => { - const t = tf.tensor3d([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [2, 3, 2]); - const indices = tf.tensor1d([1, 0, 1, 0], 'int32'); - const dy = tf.tensor( - [ - 2, -3, 4, 15, 6, 0.7, 1, 18, 0.01, 0, 12, 13, - 4, 15, 12, -7, 18, 19, 2, 21, 6, 23, 24, 25 - ], - [2, 3, 4]); - const axis = 2; - - const gradients = tf.grad(t => tf.gather(t, indices, axis))(t, dy); - - expect(gradients.shape).toEqual(t.shape); - expectArraysClose( - await gradients.data(), - [12, 6, 18.7, 7, 13, 12.01, 8, 16, 40, 20, 48, 30]); - }); - - it('gradient 3D (gather) axis=2 shape=[2, 3, 2] 2D indices', async () => { - const t = tf.tensor3d([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [2, 3, 2]); - const indices = tf.tensor2d([1, 0, 1, 0], [2, 2], 'int32'); - const dy = tf.tensor( - [ - 2, -3, 4, 15, 6, 0.7, 1, 18, 0.01, 0, 12, 13, - 4, 15, 12, -7, 18, 19, 2, 21, 6, 23, 24, 25 - ], - [2, 3, 2, 2]); - const axis = 2; - - const gradients = tf.grad(t => tf.gather(t, indices, axis))(t, dy); - - expect(gradients.shape).toEqual(t.shape); - expectArraysClose( - await gradients.data(), - [12, 6, 18.7, 7, 13, 12.01, 8, 16, 40, 20, 48, 30]); - }); - - it('gradient 3D (gather) axis=2 shape=[4, 1, 4] 1D indices', async () => { - const t = tf.tensor3d( - [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], [4, 1, 4]); - const indices = tf.tensor1d([1, 3, 1], 'int32'); - const dy = - tf.tensor([2, -3, 4, 15, 6, 0.7, 1, 18, 0.01, 0, 4, 15], [4, 1, 3]); - const axis = 2; - - const gradients = tf.grad(t => tf.gather(t, indices, axis))(t, dy); - - expect(gradients.shape).toEqual(t.shape); - expectArraysClose( - await gradients.data(), - [0, 6, 0, -3, 0, 15.7, 0, 6, 0, 1.01, 0, 18, 0, 15, 0, 4]); - }); - - it('gradient 3D (gather) axis=2 shape=[4, 1, 4] 2D indices', async () => { - const t = tf.tensor3d( - [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], [4, 1, 4]); - const indices = tf.tensor2d([1, 3, 1], [1, 3], 'int32'); - const dy = - tf.tensor([2, -3, 4, 15, 6, 0.7, 1, 18, 0.01, 0, 4, 15], [4, 1, 1, 3]); - const axis = 2; - - const gradients = tf.grad(t => tf.gather(t, indices, axis))(t, dy); - - expect(gradients.shape).toEqual(t.shape); - expectArraysClose( - await gradients.data(), - [0, 6, 0, -3, 0, 15.7, 0, 6, 0, 1.01, 0, 18, 0, 15, 0, 4]); - }); - - it('ensure no memory leak', async () => { - const numTensorsBefore = tf.memory().numTensors; - const numDataIdBefore = tf.engine().backend.numDataIds(); - const t = tf.tensor1d([1, 2, 3]); - const t1 = tf.scalar(1, 'int32'); - const t2 = tf.gather(t, t1, 0); - - expect(t2.shape).toEqual([]); - expectArraysClose(await t2.data(), [2]); - - t.dispose(); - t1.dispose(); - t2.dispose(); - - const numTensorsAfter = tf.memory().numTensors; - const numDataIdAfter = tf.engine().backend.numDataIds(); - expect(numTensorsAfter).toBe(numTensorsBefore); - expect(numDataIdAfter).toBe(numDataIdBefore); - }); - - it('fills with zero when index is out of bound', async () => { - if (env.backendName === 'webgl' || env.backendName === 'webgpu') { - const t = tf.tensor2d([1, 11, 2, 22], [2, 2]); - const tInt = tf.tensor2d([1, 11, 2, 22], [2, 2], 'int32'); - - const index = tf.tensor1d([0, 1, 100, -1, 2, -4], 'int32'); - const res = tf.gather(t, index); - const resInt = tf.gather(tInt, index); - - const expected = [1, 11, 2, 22, 0, 0, 0, 0, 0, 0, 0, 0]; - expectArraysClose(await res.data(), expected); - expectArraysClose(await resInt.data(), expected); - } - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/greater.ts b/tfjs-master/tfjs-core/src/ops/greater.ts deleted file mode 100644 index 570d31c53..000000000 --- a/tfjs-master/tfjs-core/src/ops/greater.ts +++ /dev/null @@ -1,56 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {ENGINE} from '../engine'; -import {Greater, GreaterInputs} from '../kernel_names'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {makeTypesMatch} from '../tensor_util'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -import {assertAndGetBroadcastShape} from './broadcast_util'; -import {op} from './operation'; - -/** - * Returns the truth value of (a > b) element-wise. Supports broadcasting. - * - * ```js - * const a = tf.tensor1d([1, 2, 3]); - * const b = tf.tensor1d([2, 2, 2]); - * - * a.greater(b).print(); - * ``` - * - * @param a The first input tensor. - * @param b The second input tensor. Must have the same dtype as `a`. - * - * @doc {heading: 'Operations', subheading: 'Logical'} - */ -function greater_( - a: Tensor|TensorLike, b: Tensor|TensorLike): T { - let $a = convertToTensor(a, 'a', 'greater', 'string_or_numeric'); - let $b = convertToTensor(b, 'b', 'greater', 'string_or_numeric'); - [$a, $b] = makeTypesMatch($a, $b); - - assertAndGetBroadcastShape($a.shape, $b.shape); - - const inputs: GreaterInputs = {a: $a, b: $b}; - - return ENGINE.runKernel(Greater, inputs as unknown as NamedTensorMap); -} - -export const greater = /* @__PURE__ */ op({greater_}); diff --git a/tfjs-master/tfjs-core/src/ops/greater_equal.ts b/tfjs-master/tfjs-core/src/ops/greater_equal.ts deleted file mode 100644 index 2a4a727af..000000000 --- a/tfjs-master/tfjs-core/src/ops/greater_equal.ts +++ /dev/null @@ -1,56 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {ENGINE} from '../engine'; -import {GreaterEqual, GreaterEqualInputs} from '../kernel_names'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {makeTypesMatch} from '../tensor_util'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -import {assertAndGetBroadcastShape} from './broadcast_util'; -import {op} from './operation'; - -/** - * Returns the truth value of (a >= b) element-wise. Supports broadcasting. - * - * ```js - * const a = tf.tensor1d([1, 2, 3]); - * const b = tf.tensor1d([2, 2, 2]); - * - * a.greaterEqual(b).print(); - * ``` - * - * @param a The first input tensor. - * @param b The second input tensor. Must have the same dtype as `a`. - * - * @doc {heading: 'Operations', subheading: 'Logical'} - */ -function greaterEqual_( - a: Tensor|TensorLike, b: Tensor|TensorLike): T { - let $a = convertToTensor(a, 'a', 'greaterEqual', 'string_or_numeric'); - let $b = convertToTensor(b, 'b', 'greaterEqual', 'string_or_numeric'); - [$a, $b] = makeTypesMatch($a, $b); - - assertAndGetBroadcastShape($a.shape, $b.shape); - - const inputs: GreaterEqualInputs = {a: $a, b: $b}; - - return ENGINE.runKernel(GreaterEqual, inputs as unknown as NamedTensorMap); -} - -export const greaterEqual = /* @__PURE__ */ op({greaterEqual_}); diff --git a/tfjs-master/tfjs-core/src/ops/greater_equal_test.ts b/tfjs-master/tfjs-core/src/ops/greater_equal_test.ts deleted file mode 100644 index 1b6642048..000000000 --- a/tfjs-master/tfjs-core/src/ops/greater_equal_test.ts +++ /dev/null @@ -1,365 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose, expectArraysEqual} from '../test_util'; - -describeWithFlags('greaterEqual', ALL_ENVS, () => { - // Tensor1D: - it('Tensor1D - int32', async () => { - let a = tf.tensor1d([1, 4, 5], 'int32'); - let b = tf.tensor1d([2, 3, 5], 'int32'); - let res = tf.greaterEqual(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [0, 1, 1]); - - a = tf.tensor1d([2, 2, 2], 'int32'); - b = tf.tensor1d([2, 2, 2], 'int32'); - res = tf.greaterEqual(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [1, 1, 1]); - - a = tf.tensor1d([0, 0], 'int32'); - b = tf.tensor1d([3, 3], 'int32'); - res = tf.greaterEqual(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [0, 0]); - }); - it('Tensor1D - float32', async () => { - let a = tf.tensor1d([1.1, 4.1, 5.1], 'float32'); - let b = tf.tensor1d([2.2, 3.2, 5.1], 'float32'); - let res = tf.greaterEqual(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [0, 1, 1]); - - a = tf.tensor1d([2.31, 2.31, 2.31], 'float32'); - b = tf.tensor1d([2.31, 2.31, 2.31], 'float32'); - res = tf.greaterEqual(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [1, 1, 1]); - - a = tf.tensor1d([0.45, 0.123], 'float32'); - b = tf.tensor1d([3.123, 3.321], 'float32'); - res = tf.greaterEqual(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [0, 0]); - }); - - it('upcasts when dtypes dont match', async () => { - const a = [1.1, 4.1, 5]; - const b = [2.2, 3.2, 5]; - - let res = tf.greaterEqual( - tf.tensor(a, [3], 'float32'), tf.tensor(b, [3], 'int32')); - expect(res.dtype).toBe('bool'); - expect(res.shape).toEqual([3]); - expectArraysClose(await res.data(), [0, 1, 1]); - - res = - tf.greaterEqual(tf.tensor(a, [3], 'int32'), tf.tensor(b, [3], 'bool')); - expect(res.dtype).toBe('bool'); - expect(res.shape).toEqual([3]); - expectArraysClose(await res.data(), [1, 1, 1]); - }); - - it('mismatched Tensor1D shapes - int32', () => { - const a = tf.tensor1d([1, 2], 'int32'); - const b = tf.tensor1d([1, 2, 3], 'int32'); - const f = () => { - tf.greaterEqual(a, b); - }; - expect(f).toThrowError(); - }); - it('mismatched Tensor1D shapes - float32', () => { - const a = tf.tensor1d([1.1, 2.1], 'float32'); - const b = tf.tensor1d([1.1, 2.1, 3.1], 'float32'); - const f = () => { - tf.greaterEqual(a, b); - }; - expect(f).toThrowError(); - }); - it('NaNs in Tensor1D - float32', async () => { - const a = tf.tensor1d([1.1, NaN, 2.1], 'float32'); - const b = tf.tensor1d([2.1, 3.1, NaN], 'float32'); - const res = tf.greaterEqual(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [0, 0, 0]); - }); - - // Tensor2D: - it('Tensor2D - int32', async () => { - let a = tf.tensor2d([[1, 4, 5], [8, 9, 12]], [2, 3], 'int32'); - let b = tf.tensor2d([[2, 3, 6], [7, 10, 11]], [2, 3], 'int32'); - let res = tf.greaterEqual(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [0, 1, 0, 1, 0, 1]); - - a = tf.tensor2d([[0, 0], [1, 1]], [2, 2], 'int32'); - b = tf.tensor2d([[0, 0], [1, 1]], [2, 2], 'int32'); - res = tf.greaterEqual(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [1, 1, 1, 1]); - }); - it('Tensor2D - float32', async () => { - let a = tf.tensor2d([[1.1, 4.1, 5.1], [8.1, 9.1, 12.1]], [2, 3], 'float32'); - let b = - tf.tensor2d([[2.1, 3.1, 6.1], [7.1, 10.1, 11.1]], [2, 3], 'float32'); - let res = tf.greaterEqual(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [0, 1, 0, 1, 0, 1]); - - a = tf.tensor2d([[0.2, 0.2], [1.2, 1.2]], [2, 2], 'float32'); - b = tf.tensor2d([[0.2, 0.2], [1.2, 1.2]], [2, 2], 'float32'); - res = tf.greaterEqual(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [1, 1, 1, 1]); - }); - it('broadcasting Tensor2D shapes - int32', async () => { - const a = tf.tensor2d([[3], [7]], [2, 1], 'int32'); - const b = tf.tensor2d([[2, 3, 4], [7, 8, 9]], [2, 3], 'int32'); - const res = tf.greaterEqual(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [1, 1, 0, 1, 0, 0]); - }); - it('broadcasting Tensor2D shapes - float32', async () => { - const a = tf.tensor2d([[1.1], [7.1]], [2, 1], 'float32'); - const b = - tf.tensor2d([[0.1, 1.1, 2.1], [7.1, 8.1, 9.1]], [2, 3], 'float32'); - const res = tf.greaterEqual(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [1, 1, 0, 1, 0, 0]); - }); - it('NaNs in Tensor2D - float32', async () => { - const a = tf.tensor2d([[1.1, NaN], [0.1, NaN]], [2, 2], 'float32'); - const b = tf.tensor2d([[0.1, NaN], [1.1, NaN]], [2, 2], 'float32'); - const res = tf.greaterEqual(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [1, 0, 0, 0]); - }); - - // Tensor3D: - it('Tensor3D - int32', async () => { - let a = - tf.tensor3d([[[1], [4], [5]], [[8], [9], [12]]], [2, 3, 1], 'int32'); - let b = - tf.tensor3d([[[2], [3], [6]], [[7], [10], [11]]], [2, 3, 1], 'int32'); - let res = tf.greaterEqual(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [0, 1, 0, 1, 0, 1]); - - a = tf.tensor3d([[[0], [0], [0]], [[1], [1], [1]]], [2, 3, 1], 'int32'); - b = tf.tensor3d([[[0], [0], [0]], [[1], [1], [1]]], [2, 3, 1], 'int32'); - res = tf.greaterEqual(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [1, 1, 1, 1, 1, 1]); - }); - it('Tensor3D - float32', async () => { - let a = tf.tensor3d( - [[[1.1], [4.1], [5.1]], [[8.1], [9.1], [12.1]]], [2, 3, 1], 'float32'); - let b = tf.tensor3d( - [[[2.1], [3.1], [6.1]], [[7.1], [10.1], [11.1]]], [2, 3, 1], 'float32'); - let res = tf.greaterEqual(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [0, 1, 0, 1, 0, 1]); - - a = tf.tensor3d( - [[[0.1], [0.1], [0.1]], [[1.1], [1.1], [1.2]]], [2, 3, 1], 'float32'); - b = tf.tensor3d( - [[[0.1], [0.1], [0.1]], [[1.1], [1.1], [1.1]]], [2, 3, 1], 'float32'); - res = tf.greaterEqual(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [1, 1, 1, 1, 1, 1]); - }); - it('broadcasting Tensor3D shapes - int32', async () => { - const a = tf.tensor3d( - [[[1, 0], [2, 3], [4, 5]], [[6, 7], [9, 8], [10, 11]]], [2, 3, 2], - 'int32'); - const b = - tf.tensor3d([[[1], [2], [3]], [[7], [10], [9]]], [2, 3, 1], 'int32'); - const res = tf.greaterEqual(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [1, 0, 1, 1, 1, 1, 0, 1, 0, 0, 1, 1]); - }); - it('broadcasting Tensor3D shapes - float32', async () => { - const a = tf.tensor3d( - [ - [[1.1, 0.1], [2.1, 3.1], [4.1, 5.1]], - [[6.1, 7.1], [9.1, 8.1], [10.1, 11.1]] - ], - [2, 3, 2], 'float32'); - const b = tf.tensor3d( - [[[1.1], [2.1], [3.1]], [[7.1], [10.1], [9.1]]], [2, 3, 1], 'float32'); - const res = tf.greaterEqual(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [1, 0, 1, 1, 1, 1, 0, 1, 0, 0, 1, 1]); - }); - it('NaNs in Tensor3D - float32', async () => { - const a = tf.tensor3d( - [[[1.1], [NaN], [1.1]], [[0.1], [0.1], [0.1]]], [2, 3, 1], 'float32'); - const b = tf.tensor3d( - [[[0.1], [0.1], [1.1]], [[1.1], [0.1], [NaN]]], [2, 3, 1], 'float32'); - const res = tf.greaterEqual(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [1, 0, 1, 0, 1, 0]); - }); - - // Tensor4D: - it('Tensor4D - int32', async () => { - let a = tf.tensor4d([1, 4, 5, 8], [2, 2, 1, 1], 'int32'); - let b = tf.tensor4d([2, 3, 6, 7], [2, 2, 1, 1], 'int32'); - let res = tf.greaterEqual(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [0, 1, 0, 1]); - - a = tf.tensor4d([0, 1, 2, 3], [2, 2, 1, 1], 'int32'); - b = tf.tensor4d([0, 1, 2, 3], [2, 2, 1, 1], 'int32'); - res = tf.greaterEqual(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [1, 1, 1, 1]); - - a = tf.tensor4d([1, 1, 1, 1], [2, 2, 1, 1], 'int32'); - b = tf.tensor4d([2, 2, 2, 2], [2, 2, 1, 1], 'int32'); - res = tf.greaterEqual(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [0, 0, 0, 0]); - }); - it('Tensor4D - float32', async () => { - let a = tf.tensor4d([1.1, 4.1, 5.1, 8.1], [2, 2, 1, 1], 'float32'); - let b = tf.tensor4d([2.1, 3.1, 6.1, 7.1], [2, 2, 1, 1], 'float32'); - let res = tf.greaterEqual(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [0, 1, 0, 1]); - - a = tf.tensor4d([0.1, 1.1, 2.2, 3.3], [2, 2, 1, 1], 'float32'); - b = tf.tensor4d([0.1, 1.1, 2.2, 3.3], [2, 2, 1, 1], 'float32'); - res = tf.greaterEqual(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [1, 1, 1, 1]); - - a = tf.tensor4d([0.1, 0.1, 0.1, 0.1], [2, 2, 1, 1], 'float32'); - b = tf.tensor4d([1.1, 1.1, 1.1, 1.1], [2, 2, 1, 1], 'float32'); - res = tf.greaterEqual(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [0, 0, 0, 0]); - }); - it('broadcasting Tensor4D shapes - int32', async () => { - const a = tf.tensor4d([1, 2, 5, 9], [2, 2, 1, 1], 'int32'); - const b = tf.tensor4d( - [[[[1, 2]], [[3, 4]]], [[[5, 6]], [[7, 8]]]], [2, 2, 1, 2], 'int32'); - const res = tf.greaterEqual(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [1, 0, 0, 0, 1, 0, 1, 1]); - }); - it('broadcasting Tensor4D shapes - float32', async () => { - const a = tf.tensor4d([1.1, 2.1, 5.1, 9.1], [2, 2, 1, 1], 'float32'); - const b = tf.tensor4d( - [[[[1.1, 2.1]], [[3.1, 4.1]]], [[[5.1, 6.1]], [[7.1, 8.1]]]], - [2, 2, 1, 2], 'float32'); - const res = tf.greaterEqual(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [1, 0, 0, 0, 1, 0, 1, 1]); - }); - it('NaNs in Tensor4D - float32', async () => { - const a = tf.tensor4d([1.1, NaN, 0.1, 0.1], [2, 2, 1, 1], 'float32'); - const b = tf.tensor4d([0.1, 1.1, 1.1, NaN], [2, 2, 1, 1], 'float32'); - const res = tf.greaterEqual(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [1, 0, 0, 0]); - }); - - it('throws when passed a as a non-tensor', () => { - expect(() => tf.greaterEqual({} as tf.Tensor, tf.scalar(1))) - .toThrowError(/Argument 'a' passed to 'greaterEqual' must be a Tensor/); - }); - it('throws when passed b as a non-tensor', () => { - expect(() => tf.greaterEqual(tf.scalar(1), {} as tf.Tensor)) - .toThrowError(/Argument 'b' passed to 'greaterEqual' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const a = [1, 4, 5]; - const b = [2, 3, 5]; - const res = tf.greaterEqual(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [0, 1, 1]); - }); - - it('has gradient', async () => { - const a = tf.tensor1d([3, 2, 5]); - const b = tf.tensor1d([4, 1, 5]); - const dy = tf.ones([3], 'float32'); - const da = tf.grad((a: tf.Tensor1D) => tf.greaterEqual(a, b))(a, dy); - - expect(da.dtype).toBe('float32'); - expect(da.shape).toEqual([3]); - expectArraysClose(await da.data(), [0, 0, 0]); - }); - - it('gradient with clones', async () => { - const a = tf.tensor1d([3, 2, 5]); - const b = tf.tensor1d([4, 1, 5]); - const dy = tf.ones([3], 'float32'); - const da = tf.grad( - (a: tf.Tensor1D) => tf.greaterEqual(a.clone(), b.clone()).clone())( - a, dy); - - expect(da.dtype).toBe('float32'); - expect(da.shape).toEqual([3]); - expectArraysClose(await da.data(), [0, 0, 0]); - }); - - it('should support string comparison', async () => { - const tensorA = tf.tensor('a', [], 'string'); - const tensorB = tf.tensor(['a', 'b', ''], [3], 'string'); - const result = await tf.greaterEqual(tensorA, tensorB); - - expectArraysEqual(result.shape, [3]); - expectArraysEqual(await result.data(), [1, 0, 1]); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/greater_test.ts b/tfjs-master/tfjs-core/src/ops/greater_test.ts deleted file mode 100644 index ff00acfa0..000000000 --- a/tfjs-master/tfjs-core/src/ops/greater_test.ts +++ /dev/null @@ -1,364 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose, expectArraysEqual} from '../test_util'; - -describeWithFlags('greater', ALL_ENVS, () => { - it('Tensor1D - int32', async () => { - let a = tf.tensor1d([1, 4, 5], 'int32'); - let b = tf.tensor1d([2, 3, 5], 'int32'); - let res = tf.greater(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [0, 1, 0]); - - a = tf.tensor1d([2, 2, 2], 'int32'); - b = tf.tensor1d([2, 2, 2], 'int32'); - res = tf.greater(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [0, 0, 0]); - - a = tf.tensor1d([3, 3], 'int32'); - b = tf.tensor1d([0, 0], 'int32'); - res = tf.greater(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [1, 1]); - }); - it('Tensor1D - float32', async () => { - let a = tf.tensor1d([1.1, 4.1, 5.1], 'float32'); - let b = tf.tensor1d([2.2, 3.2, 5.1], 'float32'); - let res = tf.greater(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [0, 1, 0]); - - a = tf.tensor1d([2.31, 2.31, 2.31], 'float32'); - b = tf.tensor1d([2.31, 2.31, 2.31], 'float32'); - res = tf.greater(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [0, 0, 0]); - - a = tf.tensor1d([3.123, 3.321], 'float32'); - b = tf.tensor1d([0.45, 0.123], 'float32'); - res = tf.greater(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [1, 1]); - }); - - it('upcasts when dtypes dont match', async () => { - const a = [1.1, 4.1, 5.2]; - const b = [2.2, 3.2, 5.1]; - - let res = - tf.greater(tf.tensor(a, [3], 'float32'), tf.tensor(b, [3], 'int32')); - expect(res.dtype).toBe('bool'); - expect(res.shape).toEqual([3]); - expectArraysClose(await res.data(), [0, 1, 1]); - - res = tf.greater(tf.tensor(a, [3], 'int32'), tf.tensor(b, [3], 'bool')); - expect(res.dtype).toBe('bool'); - expect(res.shape).toEqual([3]); - expectArraysClose(await res.data(), [0, 1, 1]); - }); - - it('TensorLike', async () => { - const a = [1.1, 4.1, 5.1]; - const b = [2.2, 3.2, 5.1]; - const res = tf.greater(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [0, 1, 0]); - }); - it('TensorLike Chained', async () => { - const a = tf.tensor1d([1.1, 4.1, 5.1], 'float32'); - const b = [2.2, 3.2, 5.1]; - const res = a.greater(b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [0, 1, 0]); - }); - it('mismatched Tensor1D shapes - int32', () => { - const a = tf.tensor1d([1, 2], 'int32'); - const b = tf.tensor1d([1, 2, 3], 'int32'); - const f = () => { - tf.greater(a, b); - }; - expect(f).toThrowError(); - }); - it('mismatched Tensor1D shapes - float32', () => { - const a = tf.tensor1d([1.1, 2.1], 'float32'); - const b = tf.tensor1d([1.1, 2.1, 3.1], 'float32'); - const f = () => { - tf.greater(a, b); - }; - expect(f).toThrowError(); - }); - it('NaNs in Tensor1D - float32', async () => { - const a = tf.tensor1d([1.1, NaN, 2.1], 'float32'); - const b = tf.tensor1d([2.1, 3.1, NaN], 'float32'); - const res = tf.greater(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [0, 0, 0]); - }); - - // Tensor2D: - it('Tensor2D - int32', async () => { - let a = tf.tensor2d([[1, 4, 5], [8, 9, 11]], [2, 3], 'int32'); - let b = tf.tensor2d([[2, 3, 6], [7, 10, 11]], [2, 3], 'int32'); - let res = tf.greater(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [0, 1, 0, 1, 0, 0]); - - a = tf.tensor2d([[0, 0], [1, 1]], [2, 2], 'int32'); - b = tf.tensor2d([[0, 0], [1, 1]], [2, 2], 'int32'); - res = tf.greater(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [0, 0, 0, 0]); - }); - it('Tensor2D - float32', async () => { - let a = tf.tensor2d([[1.1, 4.1, 5.1], [8.1, 9.1, 11.1]], [2, 3], 'float32'); - let b = - tf.tensor2d([[2.1, 3.1, 6.1], [7.1, 10.1, 11.1]], [2, 3], 'float32'); - let res = tf.greater(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [0, 1, 0, 1, 0, 0]); - - a = tf.tensor2d([[0.2, 0.2], [1.2, 1.2]], [2, 2], 'float32'); - b = tf.tensor2d([[0.2, 0.2], [1.2, 1.2]], [2, 2], 'float32'); - res = tf.greater(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [0, 0, 0, 0]); - }); - it('broadcasting Tensor2D shapes - int32', async () => { - const a = tf.tensor2d([[3], [7]], [2, 1], 'int32'); - const b = tf.tensor2d([[2, 3, 4], [7, 8, 9]], [2, 3], 'int32'); - const res = tf.greater(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [1, 0, 0, 0, 0, 0]); - }); - it('broadcasting Tensor2D shapes - float32', async () => { - const a = tf.tensor2d([[1.1], [7.1]], [2, 1], 'float32'); - const b = - tf.tensor2d([[0.1, 1.1, 2.1], [7.1, 8.1, 9.1]], [2, 3], 'float32'); - const res = tf.greater(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [1, 0, 0, 0, 0, 0]); - }); - it('NaNs in Tensor2D - float32', async () => { - const a = tf.tensor2d([[1.1, NaN], [0.1, NaN]], [2, 2], 'float32'); - const b = tf.tensor2d([[0.1, NaN], [1.1, NaN]], [2, 2], 'float32'); - const res = tf.greater(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [1, 0, 0, 0]); - }); - - // Tensor3D: - it('Tensor3D - int32', async () => { - let a = - tf.tensor3d([[[1], [4], [5]], [[8], [9], [11]]], [2, 3, 1], 'int32'); - let b = - tf.tensor3d([[[2], [3], [6]], [[7], [10], [11]]], [2, 3, 1], 'int32'); - let res = tf.greater(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [0, 1, 0, 1, 0, 0]); - - a = tf.tensor3d([[[0], [0], [0]], [[1], [1], [1]]], [2, 3, 1], 'int32'); - b = tf.tensor3d([[[0], [0], [0]], [[1], [1], [1]]], [2, 3, 1], 'int32'); - res = tf.greater(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [0, 0, 0, 0, 0, 0]); - }); - it('Tensor3D - float32', async () => { - let a = tf.tensor3d( - [[[1.1], [4.1], [5.1]], [[8.1], [9.1], [11.1]]], [2, 3, 1], 'float32'); - let b = tf.tensor3d( - [[[2.1], [3.1], [6.1]], [[7.1], [10.1], [11.1]]], [2, 3, 1], 'float32'); - let res = tf.greater(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [0, 1, 0, 1, 0, 0]); - - a = tf.tensor3d( - [[[0.1], [0.1], [0.1]], [[1.1], [1.1], [1.2]]], [2, 3, 1], 'float32'); - b = tf.tensor3d( - [[[0.1], [0.1], [0.1]], [[1.1], [1.1], [1.1]]], [2, 3, 1], 'float32'); - res = tf.greater(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [0, 0, 0, 0, 0, 1]); - }); - it('broadcasting Tensor3D shapes - int32', async () => { - const a = tf.tensor3d( - [[[1, 0], [2, 3], [4, 5]], [[6, 7], [9, 8], [10, 11]]], [2, 3, 2], - 'int32'); - const b = - tf.tensor3d([[[1], [2], [3]], [[7], [10], [9]]], [2, 3, 1], 'int32'); - const res = tf.greater(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1]); - }); - it('broadcasting Tensor3D shapes - float32', async () => { - const a = tf.tensor3d( - [ - [[1.1, 0.1], [2.1, 3.1], [4.1, 5.1]], - [[6.1, 7.1], [9.1, 8.1], [10.1, 11.1]] - ], - [2, 3, 2], 'float32'); - const b = tf.tensor3d( - [[[1.1], [2.1], [3.1]], [[7.1], [10.1], [9.1]]], [2, 3, 1], 'float32'); - const res = tf.greater(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1]); - }); - it('NaNs in Tensor3D - float32', async () => { - const a = tf.tensor3d( - [[[1.1], [NaN], [1.1]], [[0.1], [0.1], [0.1]]], [2, 3, 1], 'float32'); - const b = tf.tensor3d( - [[[0.1], [0.1], [1.1]], [[1.1], [0.1], [NaN]]], [2, 3, 1], 'float32'); - const res = tf.greater(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [1, 0, 0, 0, 0, 0]); - }); - - // Tensor4D: - it('Tensor4D - int32', async () => { - let a = tf.tensor4d([1, 4, 5, 8], [2, 2, 1, 1], 'int32'); - let b = tf.tensor4d([2, 3, 6, 8], [2, 2, 1, 1], 'int32'); - let res = tf.greater(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [0, 1, 0, 0]); - - a = tf.tensor4d([0, 1, 2, 3], [2, 2, 1, 1], 'int32'); - b = tf.tensor4d([0, 1, 2, 3], [2, 2, 1, 1], 'int32'); - res = tf.greater(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [0, 0, 0, 0]); - - a = tf.tensor4d([2, 2, 2, 2], [2, 2, 1, 1], 'int32'); - b = tf.tensor4d([1, 1, 1, 1], [2, 2, 1, 1], 'int32'); - res = tf.greater(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [1, 1, 1, 1]); - }); - it('Tensor4D - float32', async () => { - let a = tf.tensor4d([1.1, 4.1, 5.1, 8.1], [2, 2, 1, 1], 'float32'); - let b = tf.tensor4d([2.1, 3.1, 6.1, 8.1], [2, 2, 1, 1], 'float32'); - let res = tf.greater(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [0, 1, 0, 0]); - - a = tf.tensor4d([0.1, 1.1, 2.2, 3.3], [2, 2, 1, 1], 'float32'); - b = tf.tensor4d([0.1, 1.1, 2.2, 3.3], [2, 2, 1, 1], 'float32'); - res = tf.greater(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [0, 0, 0, 0]); - - a = tf.tensor4d([1.1, 1.1, 1.1, 1.1], [2, 2, 1, 1], 'float32'); - b = tf.tensor4d([0.1, 0.1, 0.1, 0.1], [2, 2, 1, 1], 'float32'); - res = tf.greater(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [1, 1, 1, 1]); - }); - it('broadcasting Tensor4D shapes - int32', async () => { - const a = tf.tensor4d([1, 2, 5, 9], [2, 2, 1, 1], 'int32'); - const b = tf.tensor4d( - [[[[1, 2]], [[3, 4]]], [[[5, 6]], [[7, 8]]]], [2, 2, 1, 2], 'int32'); - const res = tf.greater(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [0, 0, 0, 0, 0, 0, 1, 1]); - }); - it('broadcasting Tensor4D shapes - float32', async () => { - const a = tf.tensor4d([1.1, 2.1, 5.1, 9.1], [2, 2, 1, 1], 'float32'); - const b = tf.tensor4d( - [[[[1.1, 2.1]], [[3.1, 4.1]]], [[[5.1, 6.1]], [[7.1, 8.1]]]], - [2, 2, 1, 2], 'float32'); - const res = tf.greater(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [0, 0, 0, 0, 0, 0, 1, 1]); - }); - it('NaNs in Tensor4D - float32', async () => { - const a = tf.tensor4d([1.1, NaN, 0.1, 0.1], [2, 2, 1, 1], 'float32'); - const b = tf.tensor4d([0.1, 1.1, 1.1, NaN], [2, 2, 1, 1], 'float32'); - const res = tf.greater(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [1, 0, 0, 0]); - }); - - it('throws when passed a as a non-tensor', () => { - expect(() => tf.greater({} as tf.Tensor, tf.scalar(1))) - .toThrowError(/Argument 'a' passed to 'greater' must be a Tensor/); - }); - it('throws when passed b as a non-tensor', () => { - expect(() => tf.greater(tf.scalar(1), {} as tf.Tensor)) - .toThrowError(/Argument 'b' passed to 'greater' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const a = [1, 4, 5]; - const b = [2, 3, 5]; - - const res = tf.greater(a, b); - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [0, 1, 0]); - }); - - it('works with 0 sized tensors', async () => { - const a = tf.tensor2d([], [0, 5]); - const b = tf.tensor1d([1, 2, 3, 4, 5]); - const res = tf.greater(a, b); - expect(res.dtype).toBe('bool'); - expect(res.shape).toEqual([0, 5]); - expectArraysClose(await res.data(), []); - }); - - it('should support string comparison', async () => { - const tensorA = tf.tensor('a', [], 'string'); - const tensorB = tf.tensor(['a', 'b', ''], [3], 'string'); - const result = await tf.greater(tensorA, tensorB); - - expectArraysEqual(result.shape, [3]); - expectArraysEqual(await result.data(), [0, 0, 1]); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/identity_pool_test.ts b/tfjs-master/tfjs-core/src/ops/identity_pool_test.ts deleted file mode 100644 index 8611e8bc0..000000000 --- a/tfjs-master/tfjs-core/src/ops/identity_pool_test.ts +++ /dev/null @@ -1,91 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {expectArraysClose} from '../test_util'; - -/** - * Test utility for testing AvgPool, MaxPool, etc where kernel size is 1x1, - * effectively making them act as the identity function except where strides - * affect the output. - */ -export function identityPoolTest(pool: typeof tf.avgPool) { - it('1x1 pool size (identity)', async () => { - // tslint:disable-next-line: no-unnecessary-type-assertion - const a = tf.range(0, 10).reshape([1, 1, 1, 10]) as tf.Tensor4D; - const result = pool(a, [1, 1], [1, 1], 'valid'); - expectArraysClose(await result.data(), await a.data()); - }); - - it('1x1 pool size with strides', async () => { - // tslint:disable-next-line: no-unnecessary-type-assertion - const a = tf.range(0, 150).reshape([1, 10, 15, 1]) as tf.Tensor4D; - const result = pool(a, [1, 1], [3, 4], 'valid'); - expectArraysClose(await result.data(), [ - 0, 4, 8, 12, - 45, 49, 53, 57, - 90, 94, 98, 102, - 135, 139, 143, 147, - ]); - }); - - it('1x1 pool size batched', async () => { - // 7 batches of 3 x 4 - const shape = [7, 3, 4, 1]; - const size = shape.reduce((a, b) => a * b, 1); - // tslint:disable-next-line: no-unnecessary-type-assertion - const a = tf.range(0, size).reshape(shape) as tf.Tensor4D; - const result = pool(a, [1, 1], [1, 1], 'valid'); - expectArraysClose(await result.data(), await a.data()); - }); - - it('1x1 pool size batched with strides', async () => { - // tslint:disable-next-line: no-unnecessary-type-assertion - const a = tf.range(0, 300).reshape([2, 10, 15, 1]) as tf.Tensor4D; - const result = pool(a, [1, 1], [3, 4], 'valid'); - expectArraysClose(await result.data(), [ - // Batch 0 - 0, 4, 8, 12, - 45, 49, 53, 57, - 90, 94, 98, 102, - 135, 139, 143, 147, - // Batch 1 - 150, 154, 158, 162, - 195, 199, 203, 207, - 240, 244, 248, 252, - 285, 289, 293, 297, - ]); - }); - - it('1x1 pool size batched with strides and channels', async () => { - // tslint:disable-next-line: no-unnecessary-type-assertion - const a = tf.range(0, 900).reshape([2, 10, 15, 3]) as tf.Tensor4D; - const result = pool(a, [1, 1], [3, 4], 'valid'); - expectArraysClose(await result.data(), [ - // Batch 0 - 0, 1, 2, 12, 13, 14, 24, 25, 26, 36, 37, 38, - 135, 136, 137, 147, 148, 149, 159, 160, 161, 171, 172, 173, - 270, 271, 272, 282, 283, 284, 294, 295, 296, 306, 307, 308, - 405, 406, 407, 417, 418, 419, 429, 430, 431, 441, 442, 443, - // Batch 1 - 450, 451, 452, 462, 463, 464, 474, 475, 476, 486, 487, 488, - 585, 586, 587, 597, 598, 599, 609, 610, 611, 621, 622, 623, - 720, 721, 722, 732, 733, 734, 744, 745, 746, 756, 757, 758, - 855, 856, 857, 867, 868, 869, 879, 880, 881, 891, 892, 893, - ]); - }); -} diff --git a/tfjs-master/tfjs-core/src/ops/ifft_test.ts b/tfjs-master/tfjs-core/src/ops/ifft_test.ts deleted file mode 100644 index 1218d3c9d..000000000 --- a/tfjs-master/tfjs-core/src/ops/ifft_test.ts +++ /dev/null @@ -1,108 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('1D IFFT', ALL_ENVS, () => { - it('should return the same value with TensorFlow (2 elements)', async () => { - const t1Real = tf.tensor1d([1, 2]); - const t1Imag = tf.tensor1d([1, 1]); - const t1 = tf.complex(t1Real, t1Imag); - expectArraysClose(await tf.spectral.ifft(t1).data(), [1.5, 1, -0.5, 0]); - }); - - it('should calculate FFT from Tensor directly', async () => { - const t1Real = tf.tensor1d([1, 2]); - const t1Imag = tf.tensor1d([1, 1]); - const t1 = tf.complex(t1Real, t1Imag); - expectArraysClose(await t1.ifft().data(), [1.5, 1, -0.5, 0]); - }); - - it('should return the same value as TensorFlow (3 elements)', async () => { - const t1Real = tf.tensor1d([1, 2, 3]); - const t1Imag = tf.tensor1d([0, 0, 0]); - const t1 = tf.complex(t1Real, t1Imag); - expectArraysClose(await tf.spectral.ifft(t1).data(), [ - 2, -3.9736431e-08, -0.49999997, -.28867507, -0.49999994, 2.8867519e-01 - ]); - }); - - it('should return the same value as TensorFlow with imaginary (3 elements)', - async () => { - const t1Real = tf.tensor1d([1, 2, 3]); - const t1Imag = tf.tensor1d([1, 2, 3]); - const t1 = tf.complex(t1Real, t1Imag); - expectArraysClose( - await tf.spectral.ifft(t1).data(), - [2, 1.9999999, -0.21132492, -0.78867507, -0.7886752, -0.2113249]); - }); - - it('should return the same value as TensorFlow (negative 3 elements)', - async () => { - const t1Real = tf.tensor1d([-1, -2, -3]); - const t1Imag = tf.tensor1d([-1, -2, -3]); - const t1 = tf.complex(t1Real, t1Imag); - expectArraysClose( - await tf.spectral.ifft(t1).data(), - [-2, -1.9999999, 0.21132492, 0.78867507, 0.7886752, 0.2113249]); - }); - - it('should return the same value with TensorFlow (4 elements)', async () => { - const t1Real = tf.tensor1d([1, 2, 3, 4]); - const t1Imag = tf.tensor1d([0, 0, 0, 0]); - const t1 = tf.complex(t1Real, t1Imag); - expectArraysClose( - await tf.spectral.ifft(t1).data(), - [2.5, 0, -0.5, -0.5, -0.5, 0, -0.5, 0.5]); - }); - - it('should return the same value as TensorFlow with imaginary (4 elements)', - async () => { - const t1Real = tf.tensor1d([1, 2, 3, 4]); - const t1Imag = tf.tensor1d([1, 2, 3, 4]); - const t1 = tf.complex(t1Real, t1Imag); - expectArraysClose( - await tf.spectral.ifft(t1).data(), - [2.5, 2.5, 0, -1, -0.5, -0.5, -1, 0]); - }); -}); - -describeWithFlags('2D IFFT', ALL_ENVS, () => { - it('2D: should return the same value as TensorFlow', async () => { - const t1Real = tf.tensor2d([1, 2, 3, 4], [2, 2]); - const t1Imag = tf.tensor2d([5, 6, 7, 8], [2, 2]); - const t1 = tf.complex(t1Real, t1Imag); - const y = tf.spectral.ifft(t1); - expectArraysClose( - await y.data(), [1.5, 5.5, -0.5, -0.5, 3.5, 7.5, -0.5, -0.5]); - expect(y.shape).toEqual(t1Real.shape); - }); - - it('3D: should return the same value as TensorFlow', async () => { - const t1Real = tf.tensor3d([1, 2, 3, 4, -1, -2, -3, -4], [2, 2, 2]); - const t1Imag = tf.tensor3d([5, 6, 7, 8, -5, -6, -7, -8], [2, 2, 2]); - const t1 = tf.complex(t1Real, t1Imag); - const y = tf.spectral.ifft(t1); - expectArraysClose(await y.data(), [ - 1.5, 5.5, -0.5, -0.5, 3.5, 7.5, -0.5, -0.5, -1.5, -5.5, 0.5, 0.5, -3.5, - -7.5, 0.5, 0.5 - ]); - expect(y.shape).toEqual(t1Real.shape); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/imag.ts b/tfjs-master/tfjs-core/src/ops/imag.ts deleted file mode 100644 index 4c372ad24..000000000 --- a/tfjs-master/tfjs-core/src/ops/imag.ts +++ /dev/null @@ -1,46 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {Imag, ImagInputs} from '../kernel_names'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; -import {op} from './operation'; -/** - * Returns the imaginary part of a complex (or real) tensor. - * - * Given a tensor input, this operation returns a tensor of type float that is - * the imaginary part of each element in input considered as a complex number. - * If input is real, a tensor of all zeros is returned. - * - * ```js - * const x = tf.complex([-2.25, 3.25], [4.75, 5.75]); - * tf.imag(x).print(); - * ``` - * - * @doc {heading: 'Tensors', subheading: 'Creation'} - */ -function imag_(input: T|TensorLike): T { - const $input = convertToTensor(input, 'input', 'imag'); - - const inputs: ImagInputs = {input: $input}; - return ENGINE.runKernel(Imag, inputs as unknown as NamedTensorMap); -} - -export const imag = /* @__PURE__ */ op({imag_}); diff --git a/tfjs-master/tfjs-core/src/ops/image/crop_and_resize.ts b/tfjs-master/tfjs-core/src/ops/image/crop_and_resize.ts deleted file mode 100644 index b637cb8bb..000000000 --- a/tfjs-master/tfjs-core/src/ops/image/crop_and_resize.ts +++ /dev/null @@ -1,98 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../../engine'; -import {CropAndResize, CropAndResizeAttrs, CropAndResizeInputs} from '../../kernel_names'; -import {NamedAttrMap} from '../../kernel_registry'; -import {Tensor1D, Tensor2D, Tensor4D} from '../../tensor'; -import {NamedTensorMap} from '../../tensor_types'; -import {convertToTensor} from '../../tensor_util_env'; -import {TensorLike} from '../../types'; -import * as util from '../../util'; - -import {op} from '../operation'; - -/** - * Extracts crops from the input image tensor and resizes them using bilinear - * sampling or nearest neighbor sampling (possibly with aspect ratio change) - * to a common output size specified by cropSize. - * - * @param image 4d tensor of shape `[batch,imageHeight,imageWidth, depth]`, - * where imageHeight and imageWidth must be positive, specifying the - * batch of images from which to take crops - * @param boxes 2d float32 tensor of shape `[numBoxes, 4]`. Each entry is - * `[y1, x1, y2, x2]`, where `(y1, x1)` and `(y2, x2)` are the normalized - * coordinates of the box in the `boxInd[i]`th image in the batch - * @param boxInd 1d int32 tensor of shape `[numBoxes]` with values in range - * `[0, batch)` that specifies the image that the `i`-th box refers to. - * @param cropSize 1d int32 tensor of 2 elements `[cropHeigh, cropWidth]` - * specifying the size to which all crops are resized to. - * @param method Optional string from `'bilinear' | 'nearest'`, - * defaults to bilinear, which specifies the sampling method for resizing - * @param extrapolationValue A threshold for deciding when to remove boxes based - * on score. Defaults to 0. - * @return A 4D tensor of the shape `[numBoxes,cropHeight,cropWidth,depth]` - * - * @doc {heading: 'Operations', subheading: 'Images', namespace: 'image'} - */ -function cropAndResize_( - image: Tensor4D|TensorLike, - boxes: Tensor2D|TensorLike, - boxInd: Tensor1D|TensorLike, - cropSize: [number, number], - method: 'bilinear'|'nearest' = 'bilinear', - extrapolationValue = 0, - ): Tensor4D { - const $image = convertToTensor(image, 'image', 'cropAndResize'); - const $boxes = convertToTensor(boxes, 'boxes', 'cropAndResize', 'float32'); - const $boxInd = convertToTensor(boxInd, 'boxInd', 'cropAndResize', 'int32'); - - const numBoxes = $boxes.shape[0]; - - util.assert( - $image.rank === 4, - () => 'Error in cropAndResize: image must be rank 4,' + - `but got rank ${$image.rank}.`); - util.assert( - $boxes.rank === 2 && $boxes.shape[1] === 4, - () => `Error in cropAndResize: boxes must be have size [${numBoxes},4] ` + - `but had shape ${$boxes.shape}.`); - util.assert( - $boxInd.rank === 1 && $boxInd.shape[0] === numBoxes, - () => `Error in cropAndResize: boxInd must be have size [${numBoxes}] ` + - `but had shape ${$boxes.shape}.`); - util.assert( - cropSize.length === 2, - () => `Error in cropAndResize: cropSize must be of length 2, but got ` + - `length ${cropSize.length}.`); - util.assert( - cropSize[0] >= 1 && cropSize[1] >= 1, - () => `cropSize must be atleast [1,1], but was ${cropSize}`); - util.assert( - method === 'bilinear' || method === 'nearest', - () => `method must be bilinear or nearest, but was ${method}`); - - const inputs: - CropAndResizeInputs = {image: $image, boxes: $boxes, boxInd: $boxInd}; - const attrs: CropAndResizeAttrs = {method, extrapolationValue, cropSize}; - const res = ENGINE.runKernel( - CropAndResize, inputs as unknown as NamedTensorMap, - attrs as unknown as NamedAttrMap); - return res as Tensor4D; -} - -export const cropAndResize = /* @__PURE__ */ op({cropAndResize_}); diff --git a/tfjs-master/tfjs-core/src/ops/image/crop_and_resize_test.ts b/tfjs-master/tfjs-core/src/ops/image/crop_and_resize_test.ts deleted file mode 100644 index e785b48ea..000000000 --- a/tfjs-master/tfjs-core/src/ops/image/crop_and_resize_test.ts +++ /dev/null @@ -1,327 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import * as tf from '../../index'; -import {ALL_ENVS, describeWithFlags} from '../../jasmine_util'; -import {expectArraysClose} from '../../test_util'; - -describeWithFlags('cropAndResize', ALL_ENVS, () => { - it('1x1-bilinear', async () => { - const image: tf.Tensor4D = tf.tensor4d([1, 2, 3, 4], [1, 2, 2, 1]); - const boxes: tf.Tensor2D = tf.tensor2d([0, 0, 1, 1], [1, 4]); - const boxInd: tf.Tensor1D = tf.tensor1d([0], 'int32'); - - const output = - tf.image.cropAndResize(image, boxes, boxInd, [1, 1], 'bilinear', 0); - - expect(output.shape).toEqual([1, 1, 1, 1]); - expect(output.dtype).toBe('float32'); - expectArraysClose(await output.data(), [2.5]); - }); - - it('5x5-bilinear, no change in shape', async () => { - const image: tf.Tensor4D = tf.ones([1, 5, 5, 3]); - const boxes: tf.Tensor2D = tf.tensor2d([0, 0, 1, 1], [1, 4]); - const boxInd: tf.Tensor1D = tf.tensor1d([0], 'int32'); - - const output = - tf.image.cropAndResize(image, boxes, boxInd, [5, 5], 'bilinear', 0); - - expect(output.shape).toEqual([1, 5, 5, 3]); - expect(output.dtype).toBe('float32'); - expectArraysClose(await output.data(), await image.data()); - }); - - it('5x5-bilinear, no arguments passed in for method or extrapolation', - async () => { - const image: tf.Tensor4D = tf.ones([1, 5, 5, 3]); - const boxes: tf.Tensor2D = tf.tensor2d([0, 0, 1, 1], [1, 4]); - const boxInd: tf.Tensor1D = tf.tensor1d([0], 'int32'); - - const output = tf.image.cropAndResize(image, boxes, boxInd, [5, 5]); - - expect(output.shape).toEqual([1, 5, 5, 3]); - expect(output.dtype).toBe('float32'); - expectArraysClose(await output.data(), await image.data()); - }); - - it('5x5-bilinear, just a crop, no resize', async () => { - const image: tf.Tensor4D = tf.ones([1, 6, 6, 3]); - const boxes: tf.Tensor2D = tf.tensor2d([0.5, 0.5, 1, 1], [1, 4]); - const boxInd: tf.Tensor1D = tf.tensor1d([0], 'int32'); - - const output = - tf.image.cropAndResize(image, boxes, boxInd, [3, 3], 'bilinear', 0); - - expect(output.shape).toEqual([1, 3, 3, 3]); - expect(output.dtype).toBe('float32'); - expectArraysClose(await output.data(), await tf.ones([1, 3, 3, 3]).data()); - }); - - it('1x1-nearest', async () => { - const image: tf.Tensor4D = tf.tensor4d([1, 2, 3, 4], [1, 2, 2, 1]); - const boxes: tf.Tensor2D = tf.tensor2d([0, 0, 1, 1], [1, 4]); - const boxInd: tf.Tensor1D = tf.tensor1d([0], 'int32'); - - const output = - tf.image.cropAndResize(image, boxes, boxInd, [1, 1], 'nearest', 0); - - expect(output.shape).toEqual([1, 1, 1, 1]); - expect(output.dtype).toBe('float32'); - expectArraysClose(await output.data(), [4.0]); - }); - it('1x1Flipped-bilinear', async () => { - const image: tf.Tensor4D = tf.tensor4d([1, 2, 3, 4], [1, 2, 2, 1]); - const boxes: tf.Tensor2D = tf.tensor2d([1, 1, 0, 0], [1, 4]); - const boxInd: tf.Tensor1D = tf.tensor1d([0], 'int32'); - - const output = - tf.image.cropAndResize(image, boxes, boxInd, [1, 1], 'bilinear', 0); - - expect(output.shape).toEqual([1, 1, 1, 1]); - expect(output.dtype).toBe('float32'); - expectArraysClose(await output.data(), [2.5]); - }); - it('1x1Flipped-nearest', async () => { - const image: tf.Tensor4D = tf.tensor4d([1, 2, 3, 4], [1, 2, 2, 1]); - const boxes: tf.Tensor2D = tf.tensor2d([1, 1, 0, 0], [1, 4]); - const boxInd: tf.Tensor1D = tf.tensor1d([0], 'int32'); - - const output = - tf.image.cropAndResize(image, boxes, boxInd, [1, 1], 'nearest', 0); - - expect(output.shape).toEqual([1, 1, 1, 1]); - expect(output.dtype).toBe('float32'); - expectArraysClose(await output.data(), [4.0]); - }); - it('3x3-bilinear', async () => { - const image: tf.Tensor4D = tf.tensor4d([1, 2, 3, 4], [1, 2, 2, 1]); - const boxes: tf.Tensor2D = tf.tensor2d([0, 0, 1, 1], [1, 4]); - const boxInd: tf.Tensor1D = tf.tensor1d([0], 'int32'); - - const output = - tf.image.cropAndResize(image, boxes, boxInd, [3, 3], 'bilinear', 0); - - expect(output.shape).toEqual([1, 3, 3, 1]); - expect(output.dtype).toBe('float32'); - expectArraysClose(await output.data(), [1, 1.5, 2, 2, 2.5, 3, 3, 3.5, 4]); - }); - it('3x3-nearest', async () => { - const image: tf.Tensor4D = tf.tensor4d([1, 2, 3, 4], [1, 2, 2, 1]); - const boxes: tf.Tensor2D = tf.tensor2d([0, 0, 1, 1], [1, 4]); - const boxInd: tf.Tensor1D = tf.tensor1d([0], 'int32'); - - const output = - tf.image.cropAndResize(image, boxes, boxInd, [3, 3], 'nearest', 0); - - expect(output.shape).toEqual([1, 3, 3, 1]); - expect(output.dtype).toBe('float32'); - expectArraysClose(await output.data(), [1, 2, 2, 3, 4, 4, 3, 4, 4]); - }); - it('3x3Flipped-bilinear', async () => { - const image: tf.Tensor4D = tf.tensor4d([1, 2, 3, 4], [1, 2, 2, 1]); - const boxes: tf.Tensor2D = tf.tensor2d([1, 1, 0, 0], [1, 4]); - const boxInd: tf.Tensor1D = tf.tensor1d([0], 'int32'); - - const output = - tf.image.cropAndResize(image, boxes, boxInd, [3, 3], 'bilinear', 0); - - expect(output.shape).toEqual([1, 3, 3, 1]); - expect(output.dtype).toBe('float32'); - expectArraysClose(await output.data(), [4, 3.5, 3, 3, 2.5, 2, 2, 1.5, 1]); - }); - it('3x3Flipped-nearest', async () => { - const image: tf.Tensor4D = tf.tensor4d([1, 2, 3, 4], [1, 2, 2, 1]); - const boxes: tf.Tensor2D = tf.tensor2d([1, 1, 0, 0], [1, 4]); - const boxInd: tf.Tensor1D = tf.tensor1d([0], 'int32'); - - const output = - tf.image.cropAndResize(image, boxes, boxInd, [3, 3], 'nearest', 0); - - expect(output.shape).toEqual([1, 3, 3, 1]); - expect(output.dtype).toBe('float32'); - expectArraysClose(await output.data(), [4, 4, 3, 4, 4, 3, 2, 2, 1]); - }); - it('3x3to2x2-bilinear', async () => { - const image: tf.Tensor4D = - tf.tensor4d([1, 2, 3, 4, 5, 6, 7, 8, 9], [1, 3, 3, 1]); - const boxes: tf.Tensor2D = - tf.tensor2d([0, 0, 1, 1, 0, 0, 0.5, 0.5], [2, 4]); - const boxInd: tf.Tensor1D = tf.tensor1d([0, 0], 'int32'); - - const output = - tf.image.cropAndResize(image, boxes, boxInd, [2, 2], 'bilinear', 0); - - expect(output.shape).toEqual([2, 2, 2, 1]); - expect(output.dtype).toBe('float32'); - expectArraysClose(await output.data(), [1, 3, 7, 9, 1, 2, 4, 5]); - }); - it('3x3to2x2-nearest', async () => { - const image: tf.Tensor4D = - tf.tensor4d([1, 2, 3, 4, 5, 6, 7, 8, 9], [1, 3, 3, 1]); - const boxes: tf.Tensor2D = - tf.tensor2d([0, 0, 1, 1, 0, 0, 0.5, 0.5], [2, 4]); - const boxInd: tf.Tensor1D = tf.tensor1d([0, 0], 'int32'); - - const output = - tf.image.cropAndResize(image, boxes, boxInd, [2, 2], 'nearest', 0); - - expect(output.shape).toEqual([2, 2, 2, 1]); - expect(output.dtype).toBe('float32'); - expectArraysClose(await output.data(), [1, 3, 7, 9, 1, 2, 4, 5]); - }); - it('3x3to2x2Flipped-bilinear', async () => { - const image: tf.Tensor4D = - tf.tensor4d([1, 2, 3, 4, 5, 6, 7, 8, 9], [1, 3, 3, 1]); - const boxes: tf.Tensor2D = - tf.tensor2d([1, 1, 0, 0, 0.5, 0.5, 0, 0], [2, 4]); - const boxInd: tf.Tensor1D = tf.tensor1d([0, 0], 'int32'); - - const output = - tf.image.cropAndResize(image, boxes, boxInd, [2, 2], 'bilinear', 0); - - expect(output.shape).toEqual([2, 2, 2, 1]); - expect(output.dtype).toBe('float32'); - expectArraysClose(await output.data(), [9, 7, 3, 1, 5, 4, 2, 1]); - }); - it('3x3to2x2Flipped-nearest', async () => { - const image: tf.Tensor4D = - tf.tensor4d([1, 2, 3, 4, 5, 6, 7, 8, 9], [1, 3, 3, 1]); - const boxes: tf.Tensor2D = - tf.tensor2d([1, 1, 0, 0, 0.5, 0.5, 0, 0], [2, 4]); - const boxInd: tf.Tensor1D = tf.tensor1d([0, 0], 'int32'); - - const output = - tf.image.cropAndResize(image, boxes, boxInd, [2, 2], 'nearest', 0); - - expect(output.shape).toEqual([2, 2, 2, 1]); - expect(output.dtype).toBe('float32'); - expectArraysClose(await output.data(), [9, 7, 3, 1, 5, 4, 2, 1]); - }); - it('3x3-BoxisRectangular', async () => { - const image: tf.Tensor4D = tf.tensor4d([1, 2, 3, 4], [1, 2, 2, 1]); - const boxes: tf.Tensor2D = tf.tensor2d([0, 0, 1, 1.5], [1, 4]); - const boxInd: tf.Tensor1D = tf.tensor1d([0], 'int32'); - - const output = - tf.image.cropAndResize(image, boxes, boxInd, [3, 3], 'bilinear', 0); - - expect(output.shape).toEqual([1, 3, 3, 1]); - expect(output.dtype).toBe('float32'); - expectArraysClose( - await output.data(), [1, 1.75, 0, 2, 2.75, 0, 3, 3.75, 0]); - }); - it('3x3-BoxisRectangular-nearest', async () => { - const image: tf.Tensor4D = tf.tensor4d([1, 2, 3, 4], [1, 2, 2, 1]); - const boxes: tf.Tensor2D = tf.tensor2d([0, 0, 1, 1.5], [1, 4]); - const boxInd: tf.Tensor1D = tf.tensor1d([0], 'int32'); - - const output = - tf.image.cropAndResize(image, boxes, boxInd, [3, 3], 'nearest', 0); - - expect(output.shape).toEqual([1, 3, 3, 1]); - expect(output.dtype).toBe('float32'); - expectArraysClose(await output.data(), [1, 2, 0, 3, 4, 0, 3, 4, 0]); - }); - it('2x2to3x3-Extrapolated', async () => { - const val = -1; - const image: tf.Tensor4D = tf.tensor4d([1, 2, 3, 4], [1, 2, 2, 1]); - const boxes: tf.Tensor2D = tf.tensor2d([-1, -1, 1, 1], [1, 4]); - const boxInd: tf.Tensor1D = tf.tensor1d([0], 'int32'); - - const output = - tf.image.cropAndResize(image, boxes, boxInd, [3, 3], 'bilinear', val); - - expect(output.shape).toEqual([1, 3, 3, 1]); - expect(output.dtype).toBe('float32'); - expectArraysClose( - await output.data(), [val, val, val, val, 1, 2, val, 3, 4]); - }); - it('2x2to3x3-Extrapolated-Float', async () => { - const val = -1.5; - const image: tf.Tensor4D = tf.tensor4d([1, 2, 3, 4], [1, 2, 2, 1]); - const boxes: tf.Tensor2D = tf.tensor2d([-1, -1, 1, 1], [1, 4]); - const boxInd: tf.Tensor1D = tf.tensor1d([0], 'int32'); - - const output = - tf.image.cropAndResize(image, boxes, boxInd, [3, 3], 'bilinear', val); - - expect(output.shape).toEqual([1, 3, 3, 1]); - expect(output.dtype).toBe('float32'); - expectArraysClose( - await output.data(), [val, val, val, val, 1, 2, val, 3, 4]); - }); - it('2x2to3x3-NoCrop', async () => { - const val = -1.0; - const image: tf.Tensor4D = tf.tensor4d([1, 2, 3, 4], [1, 2, 2, 1]); - const boxes: tf.Tensor2D = tf.tensor2d([], [0, 4]); - const boxInd: tf.Tensor1D = tf.tensor1d([], 'int32'); - - const output = - tf.image.cropAndResize(image, boxes, boxInd, [3, 3], 'bilinear', val); - - expect(output.shape).toEqual([0, 3, 3, 1]); - expect(output.dtype).toBe('float32'); - expectArraysClose(await output.data(), []); - }); - it('MultipleBoxes-DifferentBoxes', async () => { - const image: tf.Tensor4D = - tf.tensor4d([1, 2, 3, 4, 5, 6, 7, 8], [2, 2, 2, 1]); - const boxes: tf.Tensor2D = - tf.tensor2d([0, 0, 1, 1.5, 0, 0, 1.5, 1], [2, 4]); - const boxInd: tf.Tensor1D = tf.tensor1d([0, 1], 'int32'); - - const output = - tf.image.cropAndResize(image, boxes, boxInd, [3, 3], 'bilinear', 0); - - expect(output.shape).toEqual([2, 3, 3, 1]); - expect(output.dtype).toBe('float32'); - expectArraysClose( - await output.data(), - [1, 1.75, 0, 2, 2.75, 0, 3, 3.75, 0, 5, 5.5, 6, 6.5, 7, 7.5, 0, 0, 0]); - }); - it('MultipleBoxes-DifferentBoxes-Nearest', async () => { - const image: tf.Tensor4D = - tf.tensor4d([1, 2, 3, 4, 5, 6, 7, 8], [2, 2, 2, 1]); - const boxes: tf.Tensor2D = tf.tensor2d([0, 0, 1, 1.5, 0, 0, 2, 1], [2, 4]); - const boxInd: tf.Tensor1D = tf.tensor1d([0, 1], 'int32'); - - const output = - tf.image.cropAndResize(image, boxes, boxInd, [3, 3], 'nearest', 0); - - expect(output.shape).toEqual([2, 3, 3, 1]); - expect(output.dtype).toBe('float32'); - expectArraysClose( - await output.data(), - [1, 2, 0, 3, 4, 0, 3, 4, 0, 5, 6, 6, 7, 8, 8, 0, 0, 0]); - }); - it('int32 image returns float output', async () => { - const image: tf.Tensor4D = - tf.tensor4d([1, 2, 3, 4, 5, 6, 7, 8], [2, 2, 2, 1], 'int32'); - const boxes: tf.Tensor2D = - tf.tensor2d([0, 0, 1, 1.5, 0, 0, 1.5, 1], [2, 4]); - const boxInd: tf.Tensor1D = tf.tensor1d([0, 1], 'int32'); - - const output = - tf.image.cropAndResize(image, boxes, boxInd, [3, 3], 'bilinear', 0); - - expect(output.shape).toEqual([2, 3, 3, 1]); - expect(output.dtype).toBe('float32'); - expectArraysClose( - await output.data(), - [1, 1.75, 0, 2, 2.75, 0, 3, 3.75, 0, 5, 5.5, 6, 6.5, 7, 7.5, 0, 0, 0]); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/image/flip_left_right.ts b/tfjs-master/tfjs-core/src/ops/image/flip_left_right.ts deleted file mode 100644 index ad3c83a9f..000000000 --- a/tfjs-master/tfjs-core/src/ops/image/flip_left_right.ts +++ /dev/null @@ -1,48 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../../engine'; -import {FlipLeftRight, FlipLeftRightInputs} from '../../kernel_names'; -import {Tensor4D} from '../../tensor'; -import {NamedTensorMap} from '../../tensor_types'; -import {convertToTensor} from '../../tensor_util_env'; -import {TensorLike} from '../../types'; -import * as util from '../../util'; -import {op} from '../operation'; - -/** - * Flips the image left to right. Currently available in the CPU, WebGL, and - * WASM backends. - * - * @param image 4d tensor of shape `[batch, imageHeight, imageWidth, depth]`. - */ -/** @doc {heading: 'Operations', subheading: 'Images', namespace: 'image'} */ -function flipLeftRight_(image: Tensor4D|TensorLike): Tensor4D { - const $image = convertToTensor(image, 'image', 'flipLeftRight', 'float32'); - - util.assert( - $image.rank === 4, - () => 'Error in flipLeftRight: image must be rank 4,' + - `but got rank ${$image.rank}.`); - - const inputs: FlipLeftRightInputs = {image: $image}; - const res = - ENGINE.runKernel(FlipLeftRight, inputs as unknown as NamedTensorMap, {}); - return res as Tensor4D; -} - -export const flipLeftRight = /* @__PURE__ */ op({flipLeftRight_}); diff --git a/tfjs-master/tfjs-core/src/ops/image/flip_left_right_test.ts b/tfjs-master/tfjs-core/src/ops/image/flip_left_right_test.ts deleted file mode 100644 index b53fe57ea..000000000 --- a/tfjs-master/tfjs-core/src/ops/image/flip_left_right_test.ts +++ /dev/null @@ -1,122 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {getTestImageAsTensor4d} from '../../image_test_util'; -import * as tf from '../../index'; -import {ALL_ENVS, describeWithFlags} from '../../jasmine_util'; -import {expectArraysClose} from '../../test_util'; - -describeWithFlags('flipLeftRight', ALL_ENVS, () => { - it('should flip (1x2x2x4)', async () => { - const image: tf.Tensor4D = tf.tensor([ - // batch 1 - [ - // row 1 - [ - [1, 2, 3, 255], - [4, 5, 6, 255], - ], - // row 2 - [ - [7, 8, 9, 255], - [10, 11, 12, 255], - ], - ], - ]); - const flipped = tf.image.flipLeftRight(image); - expectArraysClose( - [4, 5, 6, 255, 1, 2, 3, 255, 10, 11, 12, 255, 7, 8, 9, 255], - await flipped.data()); - }); - - it('should flip (2x2x2x4)', async () => { - const image: tf.Tensor4D = tf.tensor([ - // batch 1 - [ - // row 1 - [ - [1, 2, 3, 255], - [4, 5, 6, 255], - ], - // row 2 - [ - [7, 8, 9, 255], - [10, 11, 12, 255], - ], - ], - // batch 2 - [ - // row 1 - [ - [101, 102, 103, 255], - [104, 105, 106, 255], - ], - // row 2 - [ - [107, 108, 109, 255], - [110, 111, 112, 255], - ], - ], - ]); - const flipped = tf.image.flipLeftRight(image); - expectArraysClose( - [ - // batch 1 - ...[4, 5, 6, 255, 1, 2, 3, 255, 10, 11, 12, 255, 7, 8, 9, 255], - // batch 2 - ...[104, 105, 106, 255, 101, 102, 103, 255, 110, 111, 112, 255, 107, - 108, 109, 255], - ], - await flipped.data()); - }); - - it('should flip (from image)', async () => { - const flippedPixels = - tf.image.flipLeftRight(getTestImageAsTensor4d()).toInt(); - const flippedPixelsData = await flippedPixels.data(); - - const expected = [ - 230, 133, 18, 255, 241, 153, 43, 255, 224, 156, 55, 255, 212, 157, 75, - 255, 200, 155, 98, 255, 183, 138, 109, 255, 171, 120, 117, 255, 156, 100, - 111, 255, 233, 148, 31, 255, 250, 177, 64, 255, 241, 188, 82, 255, 230, - 193, 104, 255, 220, 190, 128, 255, 202, 174, 137, 255, 186, 152, 140, 255, - 168, 129, 130, 255, 222, 164, 41, 255, 247, 201, 81, 255, 243, 220, 106, - 255, 235, 227, 128, 255, 225, 228, 151, 255, 211, 216, 162, 255, 199, 198, - 168, 255, 179, 176, 159, 255, 191, 170, 61, 255, 218, 210, 103, 255, 213, - 230, 126, 255, 201, 236, 142, 255, 191, 239, 165, 255, 184, 234, 181, 255, - 179, 226, 194, 255, 163, 208, 187, 255, 135, 166, 86, 255, 162, 206, 127, - 255, 155, 226, 146, 255, 141, 232, 162, 255, 130, 235, 179, 255, 121, 231, - 192, 255, 119, 226, 206, 255, 108, 214, 202, 255, 71, 143, 97, 255, 98, - 181, 135, 255, 94, 206, 156, 255, 87, 220, 175, 255, 76, 225, 193, 255, - 64, 219, 201, 255, 62, 217, 213, 255, 55, 207, 212, 255, 15, 115, 105, - 255, 39, 150, 141, 255, 37, 177, 164, 255, 35, 200, 186, 255, 30, 209, - 205, 255, 19, 203, 211, 255, 19, 204, 222, 255, 18, 200, 224, 255, 0, - 102, 113, 255, 6, 133, 140, 255, 3, 158, 162, 255, 4, 182, 186, 255, - 0, 194, 204, 255, 0, 189, 209, 255, 0, 192, 221, 255, 0, 193, 228, - 255 - ]; - - expectArraysClose(expected, flippedPixelsData); - }); - - it('throws when input is int32', async () => { - const image: tf.Tensor4D = tf.tensor( - [[[[1, 2, 3, 255]], [[7, 8, 9, 255]]]], [1, 2, 1, 4], 'int32'); - expect(() => tf.image.flipLeftRight(image)) - .toThrowError( - /Argument 'image' passed to 'flipLeftRight' must be float32/); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/image/grayscale_to_rgb.ts b/tfjs-master/tfjs-core/src/ops/image/grayscale_to_rgb.ts deleted file mode 100644 index a50343e50..000000000 --- a/tfjs-master/tfjs-core/src/ops/image/grayscale_to_rgb.ts +++ /dev/null @@ -1,59 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Tensor2D, Tensor3D, Tensor4D, Tensor5D, Tensor6D} from '../../tensor'; -import {convertToTensor} from '../../tensor_util_env'; -import {TensorLike} from '../../types'; -import * as util from '../../util'; - -import {op} from '../operation'; -import {tile} from '../tile'; - -/** - * Converts images from grayscale to RGB format. - * - * @param image A grayscale tensor to convert. The `image`'s last dimension must - * be size 1 with at least a two-dimensional shape. - * - * @doc {heading: 'Operations', subheading: 'Images', namespace: 'image'} - */ -function grayscaleToRGB_(image: T|TensorLike): T { - const $image = convertToTensor(image, 'image', 'grayscaleToRGB'); - - const lastDimsIdx = $image.rank - 1; - const lastDims = $image.shape[lastDimsIdx]; - - util.assert( - $image.rank >= 2, - () => 'Error in grayscaleToRGB: images must be at least rank 2, ' + - `but got rank ${$image.rank}.`); - - util.assert( - lastDims === 1, - () => 'Error in grayscaleToRGB: last dimension of a grayscale image ' + - `should be size 1, but got size ${lastDims}.`); - - const reps = new Array($image.rank); - - reps.fill(1, 0, lastDimsIdx); - reps[lastDimsIdx] = 3; - - return tile($image, reps); -} - -export const grayscaleToRGB = /* @__PURE__ */ op({grayscaleToRGB_}); diff --git a/tfjs-master/tfjs-core/src/ops/image/grayscale_to_rgb_test.ts b/tfjs-master/tfjs-core/src/ops/image/grayscale_to_rgb_test.ts deleted file mode 100644 index c79457325..000000000 --- a/tfjs-master/tfjs-core/src/ops/image/grayscale_to_rgb_test.ts +++ /dev/null @@ -1,85 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../../index'; -import {ALL_ENVS, describeWithFlags} from '../../jasmine_util'; -import {Tensor2D} from '../../tensor'; -import {expectArraysClose} from '../../test_util'; - -describeWithFlags('grayscaleToRGB', ALL_ENVS, () => { - it('should convert (1,1,3,1) images into (1,1,3,3)', async () => { - const grayscale = tf.tensor4d([1.0, 2.0, 3.0], [1, 1, 3, 1]); - - const rgb = tf.image.grayscaleToRGB(grayscale); - const rgbData = await rgb.data(); - - const expected = [1.0, 1.0, 1.0, 2.0, 2.0, 2.0, 3.0, 3.0, 3.0]; - - expect(rgb.shape).toEqual([1, 1, 3, 3]); - expectArraysClose(rgbData, expected); - }); - - it('should convert (1,2,1) images into (1,2,3)', async () => { - const grayscale = tf.tensor3d([1.6, 2.4], [1, 2, 1]); - - const rgb = tf.image.grayscaleToRGB(grayscale); - const rgbData = await rgb.data(); - - const expected = [1.6, 1.6, 1.6, 2.4, 2.4, 2.4]; - - expect(rgb.shape).toEqual([1, 2, 3]); - expectArraysClose(rgbData, expected); - }); - - it('should convert (2,1) images into (2,3)', async () => { - const grayscale = tf.tensor2d([16, 24], [2, 1]); - - const rgb = tf.image.grayscaleToRGB(grayscale); - const rgbData = await rgb.data(); - - const expected = [16, 16, 16, 24, 24, 24]; - - expect(rgb.shape).toEqual([2, 3]); - expectArraysClose(rgbData, expected); - }); - - it('should convert [[[191], [3]]] array into (1,2,3) images', async () => { - const grayscale = [[[191], [3]]]; - - const rgb = tf.image.grayscaleToRGB(grayscale); - const rgbData = await rgb.data(); - - const expected = [191, 191, 191, 3, 3, 3]; - - expect(rgb.shape).toEqual([1, 2, 3]); - expectArraysClose(rgbData, expected); - }); - - it('should throw an error because of input last dim is not 1', () => { - const grayscale = tf.tensor4d([1.0, 1.0, 2.0, 2.0, 3.0, 3.0], [1, 1, 3, 2]); - - expect(() => tf.image.grayscaleToRGB(grayscale)) - .toThrowError(/last dimension of a grayscale image should be size 1/); - }); - - it('should throw an error because of image\'s rank is less than 2', () => { - const grayscale = tf.tensor1d([1, 2, 3]) as unknown as Tensor2D; - - expect(() => tf.image.grayscaleToRGB(grayscale)) - .toThrowError(/images must be at least rank 2/); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/image/non_max_suppression.ts b/tfjs-master/tfjs-core/src/ops/image/non_max_suppression.ts deleted file mode 100644 index 5aea5272c..000000000 --- a/tfjs-master/tfjs-core/src/ops/image/non_max_suppression.ts +++ /dev/null @@ -1,64 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../../engine'; -import {NonMaxSuppressionV3} from '../../kernel_names'; -import {Tensor1D, Tensor2D} from '../../tensor'; -import {convertToTensor} from '../../tensor_util_env'; -import {TensorLike} from '../../types'; -import {nonMaxSuppSanityCheck} from '../nonmax_util'; -import {op} from '../operation'; - -/** - * Performs non maximum suppression of bounding boxes based on - * iou (intersection over union). - * - * @param boxes a 2d tensor of shape `[numBoxes, 4]`. Each entry is - * `[y1, x1, y2, x2]`, where `(y1, x1)` and `(y2, x2)` are the corners of - * the bounding box. - * @param scores a 1d tensor providing the box scores of shape `[numBoxes]`. - * @param maxOutputSize The maximum number of boxes to be selected. - * @param iouThreshold A float representing the threshold for deciding whether - * boxes overlap too much with respect to IOU. Must be between [0, 1]. - * Defaults to 0.5 (50% box overlap). - * @param scoreThreshold A threshold for deciding when to remove boxes based - * on score. Defaults to -inf, which means any score is accepted. - * @return A 1D tensor with the selected box indices. - * - * @doc {heading: 'Operations', subheading: 'Images', namespace: 'image'} - */ -function nonMaxSuppression_( - boxes: Tensor2D|TensorLike, scores: Tensor1D|TensorLike, - maxOutputSize: number, iouThreshold = 0.5, - scoreThreshold = Number.NEGATIVE_INFINITY): Tensor1D { - const $boxes = - convertToTensor(boxes, 'boxes', 'nonMaxSuppression', 'float32'); - const $scores = - convertToTensor(scores, 'scores', 'nonMaxSuppression', 'float32'); - - const inputs = nonMaxSuppSanityCheck( - $boxes, $scores, maxOutputSize, iouThreshold, scoreThreshold); - maxOutputSize = inputs.maxOutputSize; - iouThreshold = inputs.iouThreshold; - scoreThreshold = inputs.scoreThreshold; - - const attrs = {maxOutputSize, iouThreshold, scoreThreshold}; - return ENGINE.runKernel( - NonMaxSuppressionV3, {boxes: $boxes, scores: $scores}, attrs); -} - -export const nonMaxSuppression = /* @__PURE__ */ op({nonMaxSuppression_}); diff --git a/tfjs-master/tfjs-core/src/ops/image/non_max_suppression_async.ts b/tfjs-master/tfjs-core/src/ops/image/non_max_suppression_async.ts deleted file mode 100644 index 44713f590..000000000 --- a/tfjs-master/tfjs-core/src/ops/image/non_max_suppression_async.ts +++ /dev/null @@ -1,77 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {nonMaxSuppressionV3Impl} from '../../backends/non_max_suppression_impl'; -import {Tensor1D, Tensor2D} from '../../tensor'; -import {convertToTensor} from '../../tensor_util_env'; -import {TensorLike} from '../../types'; -import {nonMaxSuppSanityCheck} from '../nonmax_util'; -import {tensor1d} from '../tensor1d'; - -/** - * Performs non maximum suppression of bounding boxes based on - * iou (intersection over union). - * - * This is the async version of `nonMaxSuppression` - * - * @param boxes a 2d tensor of shape `[numBoxes, 4]`. Each entry is - * `[y1, x1, y2, x2]`, where `(y1, x1)` and `(y2, x2)` are the corners of - * the bounding box. - * @param scores a 1d tensor providing the box scores of shape `[numBoxes]`. - * @param maxOutputSize The maximum number of boxes to be selected. - * @param iouThreshold A float representing the threshold for deciding whether - * boxes overlap too much with respect to IOU. Must be between [0, 1]. - * Defaults to 0.5 (50% box overlap). - * @param scoreThreshold A threshold for deciding when to remove boxes based - * on score. Defaults to -inf, which means any score is accepted. - * @return A 1D tensor with the selected box indices. - * - * @doc {heading: 'Operations', subheading: 'Images', namespace: 'image'} - */ -async function nonMaxSuppressionAsync_( - boxes: Tensor2D|TensorLike, scores: Tensor1D|TensorLike, - maxOutputSize: number, iouThreshold = 0.5, - scoreThreshold = Number.NEGATIVE_INFINITY): Promise { - const $boxes = convertToTensor(boxes, 'boxes', 'nonMaxSuppressionAsync'); - const $scores = convertToTensor(scores, 'scores', 'nonMaxSuppressionAsync'); - - const inputs = nonMaxSuppSanityCheck( - $boxes, $scores, maxOutputSize, iouThreshold, scoreThreshold); - maxOutputSize = inputs.maxOutputSize; - iouThreshold = inputs.iouThreshold; - scoreThreshold = inputs.scoreThreshold; - - const boxesAndScores = await Promise.all([$boxes.data(), $scores.data()]); - const boxesVals = boxesAndScores[0]; - const scoresVals = boxesAndScores[1]; - - // We call a cpu based impl directly with the typedarray data here rather - // than a kernel because all kernels are synchronous (and thus cannot await - // .data()). - const {selectedIndices} = nonMaxSuppressionV3Impl( - boxesVals, scoresVals, maxOutputSize, iouThreshold, scoreThreshold); - if ($boxes !== boxes) { - $boxes.dispose(); - } - if ($scores !== scores) { - $scores.dispose(); - } - - return tensor1d(selectedIndices, 'int32'); -} - -export const nonMaxSuppressionAsync = nonMaxSuppressionAsync_; diff --git a/tfjs-master/tfjs-core/src/ops/image/non_max_suppression_async_test.ts b/tfjs-master/tfjs-core/src/ops/image/non_max_suppression_async_test.ts deleted file mode 100644 index f1c2fff07..000000000 --- a/tfjs-master/tfjs-core/src/ops/image/non_max_suppression_async_test.ts +++ /dev/null @@ -1,114 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import * as tf from '../../index'; -import {ALL_ENVS, describeWithFlags} from '../../jasmine_util'; -import {expectArraysClose, expectArraysEqual} from '../../test_util'; - -describeWithFlags('nonMaxSuppressionAsync', ALL_ENVS, () => { - describe('NonMaxSuppressionAsync basic', () => { - it('select from three clusters', async () => { - const boxes = tf.tensor2d( - [ - 0, 0, 1, 1, 0, 0.1, 1, 1.1, 0, -0.1, 1, 0.9, - 0, 10, 1, 11, 0, 10.1, 1, 11.1, 0, 100, 1, 101 - ], - [6, 4]); - const scores = tf.tensor1d([0.9, 0.75, 0.6, 0.95, 0.5, 0.3]); - const maxOutputSize = 3; - const iouThreshold = 0.5; - const scoreThreshold = 0; - const indices = await tf.image.nonMaxSuppressionAsync( - boxes, scores, maxOutputSize, iouThreshold, scoreThreshold); - - expect(indices.shape).toEqual([3]); - expectArraysEqual(await indices.data(), [3, 0, 5]); - }); - - it('accepts a tensor-like object', async () => { - const boxes = [[0, 0, 1, 1], [0, 1, 1, 2]]; - const scores = [1, 2]; - const indices = await tf.image.nonMaxSuppressionAsync(boxes, scores, 10); - expect(indices.shape).toEqual([2]); - expect(indices.dtype).toEqual('int32'); - expectArraysEqual(await indices.data(), [1, 0]); - }); - }); - - describe('NonMaxSuppressionWithScoreAsync', () => { - it('select from three clusters with SoftNMS', async () => { - const boxes = tf.tensor2d( - [ - 0, 0, 1, 1, 0, 0.1, 1, 1.1, 0, -0.1, 1, 0.9, - 0, 10, 1, 11, 0, 10.1, 1, 11.1, 0, 100, 1, 101 - ], - [6, 4]); - const scores = tf.tensor1d([0.9, 0.75, 0.6, 0.95, 0.5, 0.3]); - const maxOutputSize = 6; - const iouThreshold = 1.0; - const scoreThreshold = 0; - const softNmsSigma = 0.5; - - const numTensorsBefore = tf.memory().numTensors; - - const {selectedIndices, selectedScores} = - await tf.image.nonMaxSuppressionWithScoreAsync( - boxes, scores, maxOutputSize, iouThreshold, scoreThreshold, - softNmsSigma); - - const numTensorsAfter = tf.memory().numTensors; - - expectArraysEqual(await selectedIndices.data(), [3, 0, 1, 5, 4, 2]); - - expectArraysClose( - await selectedScores.data(), [0.95, 0.9, 0.384, 0.3, 0.256, 0.197]); - - // The number of tensors should increase by the number of tensors - // returned (i.e. selectedIndices and selectedScores). - expect(numTensorsAfter).toEqual(numTensorsBefore + 2); - }); - }); - - describe('NonMaxSuppressionPaddedAsync', () => { - it('select from three clusters with pad five.', async () => { - const boxes = tf.tensor2d( - [ - 0, 0, 1, 1, 0, 0.1, 1, 1.1, 0, -0.1, 1, 0.9, - 0, 10, 1, 11, 0, 10.1, 1, 11.1, 0, 100, 1, 101 - ], - [6, 4]); - const scores = tf.tensor1d([0.9, 0.75, 0.6, 0.95, 0.5, 0.3]); - const maxOutputSize = 5; - const iouThreshold = 0.5; - const scoreThreshold = 0.0; - - const before = tf.memory().numTensors; - - const {selectedIndices, validOutputs} = - await tf.image.nonMaxSuppressionPaddedAsync( - boxes, scores, maxOutputSize, iouThreshold, scoreThreshold, true); - - const after = tf.memory().numTensors; - - expectArraysEqual(await selectedIndices.data(), [3, 0, 5, 0, 0]); - expectArraysEqual(await validOutputs.data(), 3); - - // The number of tensors should increase by the number of tensors - // returned (i.e. selectedIndices and selectedScores). - expect(after).toEqual(before + 2); - }); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/image/non_max_suppression_padded.ts b/tfjs-master/tfjs-core/src/ops/image/non_max_suppression_padded.ts deleted file mode 100644 index 58839e666..000000000 --- a/tfjs-master/tfjs-core/src/ops/image/non_max_suppression_padded.ts +++ /dev/null @@ -1,83 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../../engine'; -import {NonMaxSuppressionV4, NonMaxSuppressionV4Attrs, NonMaxSuppressionV4Inputs} from '../../kernel_names'; -import {NamedAttrMap} from '../../kernel_registry'; -import {Tensor, Tensor1D, Tensor2D} from '../../tensor'; -import {NamedTensorMap} from '../../tensor_types'; -import {convertToTensor} from '../../tensor_util_env'; -import {TensorLike} from '../../types'; - -import {nonMaxSuppSanityCheck} from '../nonmax_util'; -import {op} from '../operation'; - -/** - * Asynchronously performs non maximum suppression of bounding boxes based on - * iou (intersection over union), with an option to pad results. - * - * @param boxes a 2d tensor of shape `[numBoxes, 4]`. Each entry is - * `[y1, x1, y2, x2]`, where `(y1, x1)` and `(y2, x2)` are the corners of - * the bounding box. - * @param scores a 1d tensor providing the box scores of shape `[numBoxes]`. - * @param maxOutputSize The maximum number of boxes to be selected. - * @param iouThreshold A float representing the threshold for deciding whether - * boxes overlap too much with respect to IOU. Must be between [0, 1]. - * Defaults to 0.5 (50% box overlap). - * @param scoreThreshold A threshold for deciding when to remove boxes based - * on score. Defaults to -inf, which means any score is accepted. - * @param padToMaxOutputSize Defaults to false. If true, size of output - * `selectedIndices` is padded to maxOutputSize. - * @return A map with the following properties: - * - selectedIndices: A 1D tensor with the selected box indices. - * - validOutputs: A scalar denoting how many elements in `selectedIndices` - * are valid. Valid elements occur first, then padding. - * - * @doc {heading: 'Operations', subheading: 'Images', namespace: 'image'} - */ -function nonMaxSuppressionPadded_( - boxes: Tensor2D|TensorLike, scores: Tensor1D|TensorLike, - maxOutputSize: number, iouThreshold = 0.5, - scoreThreshold = Number.NEGATIVE_INFINITY, - padToMaxOutputSize = false): NamedTensorMap { - const $boxes = convertToTensor(boxes, 'boxes', 'nonMaxSuppression'); - const $scores = convertToTensor(scores, 'scores', 'nonMaxSuppression'); - - const params = nonMaxSuppSanityCheck( - $boxes, $scores, maxOutputSize, iouThreshold, scoreThreshold, - null /* softNmsSigma */); - const $maxOutputSize = params.maxOutputSize; - const $iouThreshold = params.iouThreshold; - const $scoreThreshold = params.scoreThreshold; - - const inputs: NonMaxSuppressionV4Inputs = {boxes: $boxes, scores: $scores}; - const attrs: NonMaxSuppressionV4Attrs = { - maxOutputSize: $maxOutputSize, - iouThreshold: $iouThreshold, - scoreThreshold: $scoreThreshold, - padToMaxOutputSize - }; - - // tslint:disable-next-line: no-unnecessary-type-assertion - const result = ENGINE.runKernel( - NonMaxSuppressionV4, inputs as unknown as NamedTensorMap, - attrs as unknown as NamedAttrMap) as Tensor[]; - - return {selectedIndices: result[0], validOutputs: result[1]}; -} - -export const nonMaxSuppressionPadded = /* @__PURE__ */ op({nonMaxSuppressionPadded_}); diff --git a/tfjs-master/tfjs-core/src/ops/image/non_max_suppression_padded_async.ts b/tfjs-master/tfjs-core/src/ops/image/non_max_suppression_padded_async.ts deleted file mode 100644 index 5222dbc0b..000000000 --- a/tfjs-master/tfjs-core/src/ops/image/non_max_suppression_padded_async.ts +++ /dev/null @@ -1,87 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {nonMaxSuppressionV4Impl} from '../../backends/non_max_suppression_impl'; -import {Tensor1D, Tensor2D} from '../../tensor'; -import {NamedTensorMap} from '../../tensor_types'; -import {convertToTensor} from '../../tensor_util_env'; -import {TensorLike} from '../../types'; -import {nonMaxSuppSanityCheck} from '../nonmax_util'; -import {scalar} from '../scalar'; -import {tensor1d} from '../tensor1d'; - -/** - * Asynchronously performs non maximum suppression of bounding boxes based on - * iou (intersection over union), with an option to pad results. - * - * @param boxes a 2d tensor of shape `[numBoxes, 4]`. Each entry is - * `[y1, x1, y2, x2]`, where `(y1, x1)` and `(y2, x2)` are the corners of - * the bounding box. - * @param scores a 1d tensor providing the box scores of shape `[numBoxes]`. - * @param maxOutputSize The maximum number of boxes to be selected. - * @param iouThreshold A float representing the threshold for deciding whether - * boxes overlap too much with respect to IOU. Must be between [0, 1]. - * Defaults to 0.5 (50% box overlap). - * @param scoreThreshold A threshold for deciding when to remove boxes based - * on score. Defaults to -inf, which means any score is accepted. - * @param padToMaxOutputSize Defaults to false. If true, size of output - * `selectedIndices` is padded to maxOutputSize. - * @return A map with the following properties: - * - selectedIndices: A 1D tensor with the selected box indices. - * - validOutputs: A scalar denoting how many elements in `selectedIndices` - * are valid. Valid elements occur first, then padding. - * - * @doc {heading: 'Operations', subheading: 'Images', namespace: 'image'} - */ -async function nonMaxSuppressionPaddedAsync_( - boxes: Tensor2D|TensorLike, scores: Tensor1D|TensorLike, - maxOutputSize: number, iouThreshold = 0.5, - scoreThreshold = Number.NEGATIVE_INFINITY, - padToMaxOutputSize = false): Promise { - const $boxes = convertToTensor(boxes, 'boxes', 'nonMaxSuppressionAsync'); - const $scores = convertToTensor(scores, 'scores', 'nonMaxSuppressionAsync'); - - const params = nonMaxSuppSanityCheck( - $boxes, $scores, maxOutputSize, iouThreshold, scoreThreshold, - null /* softNmsSigma */); - const $maxOutputSize = params.maxOutputSize; - const $iouThreshold = params.iouThreshold; - const $scoreThreshold = params.scoreThreshold; - - const [boxesVals, scoresVals] = - await Promise.all([$boxes.data(), $scores.data()]); - - // We call a cpu based impl directly with the typedarray data here rather - // than a kernel because all kernels are synchronous (and thus cannot await - // .data()). - const {selectedIndices, validOutputs} = nonMaxSuppressionV4Impl( - boxesVals, scoresVals, $maxOutputSize, $iouThreshold, $scoreThreshold, - padToMaxOutputSize); - - if ($boxes !== boxes) { - $boxes.dispose(); - } - if ($scores !== scores) { - $scores.dispose(); - } - - return { - selectedIndices: tensor1d(selectedIndices, 'int32'), - validOutputs: scalar(validOutputs, 'int32') - }; -} - -export const nonMaxSuppressionPaddedAsync = nonMaxSuppressionPaddedAsync_; diff --git a/tfjs-master/tfjs-core/src/ops/image/non_max_suppression_test.ts b/tfjs-master/tfjs-core/src/ops/image/non_max_suppression_test.ts deleted file mode 100644 index 247d74ab2..000000000 --- a/tfjs-master/tfjs-core/src/ops/image/non_max_suppression_test.ts +++ /dev/null @@ -1,316 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import * as tf from '../../index'; -import {ALL_ENVS, describeWithFlags} from '../../jasmine_util'; -import {expectArraysClose, expectArraysEqual} from '../../test_util'; - -describeWithFlags('nonMaxSuppression', ALL_ENVS, () => { - describe('NonMaxSuppression Basic', () => { - it('select from three clusters', async () => { - const boxes = tf.tensor2d( - [ - 0, 0, 1, 1, 0, 0.1, 1, 1.1, 0, -0.1, 1, 0.9, - 0, 10, 1, 11, 0, 10.1, 1, 11.1, 0, 100, 1, 101 - ], - [6, 4]); - const scores = tf.tensor1d([0.9, 0.75, 0.6, 0.95, 0.5, 0.3]); - const maxOutputSize = 3; - const iouThreshold = 0.5; - const scoreThreshold = 0; - const indices = tf.image.nonMaxSuppression( - boxes, scores, maxOutputSize, iouThreshold, scoreThreshold); - - expect(indices.shape).toEqual([3]); - expectArraysEqual(await indices.data(), [3, 0, 5]); - }); - - it('select from three clusters flipped coordinates', async () => { - const boxes = tf.tensor2d( - [ - 1, 1, 0, 0, 0, 0.1, 1, 1.1, 0, .9, 1, -0.1, - 0, 10, 1, 11, 1, 10.1, 0, 11.1, 1, 101, 0, 100 - ], - [6, 4]); - const scores = tf.tensor1d([0.9, 0.75, 0.6, 0.95, 0.5, 0.3]); - const maxOutputSize = 3; - const iouThreshold = 0.5; - const scoreThreshold = 0; - const indices = tf.image.nonMaxSuppression( - boxes, scores, maxOutputSize, iouThreshold, scoreThreshold); - - expect(indices.shape).toEqual([3]); - expectArraysEqual(await indices.data(), [3, 0, 5]); - }); - - it('select at most two boxes from three clusters', async () => { - const boxes = tf.tensor2d( - [ - 0, 0, 1, 1, 0, 0.1, 1, 1.1, 0, -0.1, 1, 0.9, - 0, 10, 1, 11, 0, 10.1, 1, 11.1, 0, 100, 1, 101 - ], - [6, 4]); - const scores = tf.tensor1d([0.9, 0.75, 0.6, 0.95, 0.5, 0.3]); - const maxOutputSize = 2; - const iouThreshold = 0.5; - const scoreThreshold = 0; - const indices = tf.image.nonMaxSuppression( - boxes, scores, maxOutputSize, iouThreshold, scoreThreshold); - - expect(indices.shape).toEqual([2]); - expectArraysEqual(await indices.data(), [3, 0]); - }); - - it('select at most thirty boxes from three clusters', async () => { - const boxes = tf.tensor2d( - [ - 0, 0, 1, 1, 0, 0.1, 1, 1.1, 0, -0.1, 1, 0.9, - 0, 10, 1, 11, 0, 10.1, 1, 11.1, 0, 100, 1, 101 - ], - [6, 4]); - const scores = tf.tensor1d([0.9, 0.75, 0.6, 0.95, 0.5, 0.3]); - const maxOutputSize = 30; - const iouThreshold = 0.5; - const scoreThreshold = 0; - const indices = tf.image.nonMaxSuppression( - boxes, scores, maxOutputSize, iouThreshold, scoreThreshold); - - expect(indices.shape).toEqual([3]); - expectArraysEqual(await indices.data(), [3, 0, 5]); - }); - - it('select single box', async () => { - const boxes = tf.tensor2d([0, 0, 1, 1], [1, 4]); - const scores = tf.tensor1d([0.9]); - const maxOutputSize = 3; - const iouThreshold = 0.5; - const scoreThreshold = 0; - const indices = tf.image.nonMaxSuppression( - boxes, scores, maxOutputSize, iouThreshold, scoreThreshold); - - expect(indices.shape).toEqual([1]); - expectArraysEqual(await indices.data(), [0]); - }); - - it('select from ten identical boxes', async () => { - const numBoxes = 10; - const corners = new Array(numBoxes) - .fill(0) - .map(_ => [0, 0, 1, 1]) - .reduce((arr, curr) => arr.concat(curr)); - const boxes = tf.tensor2d(corners, [numBoxes, 4]); - const scores = tf.tensor1d(Array(numBoxes).fill(0.9)); - const maxOutputSize = 3; - const iouThreshold = 0.5; - const scoreThreshold = 0; - const indices = tf.image.nonMaxSuppression( - boxes, scores, maxOutputSize, iouThreshold, scoreThreshold); - - expect(indices.shape).toEqual([1]); - expectArraysEqual(await indices.data(), [0]); - }); - - it('inconsistent box and score shapes', () => { - const boxes = tf.tensor2d( - [ - 0, 0, 1, 1, 0, 0.1, 1, 1.1, 0, -0.1, 1, 0.9, - 0, 10, 1, 11, 0, 10.1, 1, 11.1, 0, 100, 1, 101 - ], - [6, 4]); - const scores = tf.tensor1d([0.9, 0.75, 0.6, 0.95, 0.5]); - const maxOutputSize = 30; - const iouThreshold = 0.5; - const scoreThreshold = 0; - expect( - () => tf.image.nonMaxSuppression( - boxes, scores, maxOutputSize, iouThreshold, scoreThreshold)) - .toThrowError(/scores has incompatible shape with boxes/); - }); - - it('invalid iou threshold', () => { - const boxes = tf.tensor2d([0, 0, 1, 1], [1, 4]); - const scores = tf.tensor1d([0.9]); - const maxOutputSize = 3; - const iouThreshold = 1.2; - const scoreThreshold = 0; - expect( - () => tf.image.nonMaxSuppression( - boxes, scores, maxOutputSize, iouThreshold, scoreThreshold)) - .toThrowError(/iouThreshold must be in \[0, 1\]/); - }); - - it('empty input', async () => { - const boxes = tf.tensor2d([], [0, 4]); - const scores = tf.tensor1d([]); - const maxOutputSize = 3; - const iouThreshold = 0.5; - const scoreThreshold = 0; - const indices = tf.image.nonMaxSuppression( - boxes, scores, maxOutputSize, iouThreshold, scoreThreshold); - - expect(indices.shape).toEqual([0]); - expectArraysEqual(await indices.data(), []); - }); - - it('accepts a tensor-like object', async () => { - const boxes = [[0, 0, 1, 1], [0, 1, 1, 2]]; - const scores = [1, 2]; - const indices = tf.image.nonMaxSuppression(boxes, scores, 10); - expect(indices.shape).toEqual([2]); - expect(indices.dtype).toEqual('int32'); - expectArraysEqual(await indices.data(), [1, 0]); - }); - - it('throws when boxes is int32', async () => { - const boxes = tf.tensor2d([[0, 0, 1, 1], [0, 1, 1, 2]], [2, 4], 'int32'); - const scores = [1, 2]; - expect(() => tf.image.nonMaxSuppression(boxes, scores, 10)) - .toThrowError( - /Argument 'boxes' passed to 'nonMaxSuppression' must be float32/); - }); - - it('throws when scores is int32', async () => { - const boxes = [[0, 0, 1, 1], [0, 1, 1, 2]]; - const scores = tf.tensor1d([1, 2], 'int32'); - const errRegex = - /Argument 'scores' passed to 'nonMaxSuppression' must be float32/; - expect(() => tf.image.nonMaxSuppression(boxes, scores, 10)) - .toThrowError(errRegex); - }); - - it('works when inputs are not explicitly initialized on the CPU', - async () => { - // This test ensures that asynchronous backends work with NMS, which - // requires inputs to reside on the CPU. - const boxes = tf.tensor2d( - [ - 0, 0, 1, 1, 0, 0.1, 1, 1.1, 0, -0.1, 1, 0.9, - 0, 10, 1, 11, 0, 10.1, 1, 11.1, 0, 100, 1, 101 - ], - [6, 4]); - const a = tf.tensor1d([0, 1, -2, -4, 4, -4]); - const b = tf.tensor1d([0.15, 0.2, 0.25, 0.5, 0.7, 1.2]); - const scores = a.div(b); - const maxOutputSize = 2; - const iouThreshold = 0.5; - const scoreThreshold = 0; - await scores.data(); - const indices = tf.image.nonMaxSuppression( - boxes, scores as tf.Tensor1D, maxOutputSize, iouThreshold, - scoreThreshold); - - expect(indices.shape).toEqual([2]); - expectArraysEqual(await indices.data(), [4, 1]); - }); - }); - - describe('NonMaxSuppressionWithScore', () => { - it('select from three clusters with SoftNMS', async () => { - const boxes = tf.tensor2d( - [ - 0, 0, 1, 1, 0, 0.1, 1, 1.1, 0, -0.1, 1, 0.9, - 0, 10, 1, 11, 0, 10.1, 1, 11.1, 0, 100, 1, 101 - ], - [6, 4]); - const scores = tf.tensor1d([0.9, 0.75, 0.6, 0.95, 0.5, 0.3]); - const maxOutputSize = 6; - const iouThreshold = 1.0; - const scoreThreshold = 0; - const softNmsSigma = 0.5; - - const {selectedIndices, selectedScores} = - tf.image.nonMaxSuppressionWithScore( - boxes, scores, maxOutputSize, iouThreshold, scoreThreshold, - softNmsSigma); - - expectArraysEqual(await selectedIndices.data(), [3, 0, 1, 5, 4, 2]); - - expectArraysClose( - await selectedScores.data(), [0.95, 0.9, 0.384, 0.3, 0.256, 0.197]); - }); - }); - - describe('NonMaxSuppressionPadded', () => { - it('select from three clusters with pad five.', async () => { - const boxes = tf.tensor2d( - [ - 0, 0, 1, 1, 0, 0.1, 1, 1.1, 0, -0.1, 1, 0.9, - 0, 10, 1, 11, 0, 10.1, 1, 11.1, 0, 100, 1, 101 - ], - [6, 4]); - const scores = tf.tensor1d([0.9, 0.75, 0.6, 0.95, 0.5, 0.3]); - const maxOutputSize = 5; - const iouThreshold = 0.5; - const scoreThreshold = 0; - - const before = tf.memory().numTensors; - const {selectedIndices, validOutputs} = tf.image.nonMaxSuppressionPadded( - boxes, scores, maxOutputSize, iouThreshold, scoreThreshold, true); - const after = tf.memory().numTensors; - - expectArraysEqual(await selectedIndices.data(), [3, 0, 5, 0, 0]); - expectArraysEqual(await validOutputs.data(), 3); - expect(after).toEqual(before + 2); - }); - - it('select from three clusters with pad five and score threshold.', - async () => { - const boxes = tf.tensor2d( - [ - 0, 0, 1, 1, 0, 0.1, 1, 1.1, 0, -0.1, 1, 0.9, - 0, 10, 1, 11, 0, 10.1, 1, 11.1, 0, 100, 1, 101 - ], - [6, 4]); - const scores = tf.tensor1d([0.9, 0.75, 0.6, 0.95, 0.5, 0.3]); - const maxOutputSize = 6; - const iouThreshold = 0.5; - const scoreThreshold = 0.4; - - const before = tf.memory().numTensors; - const {selectedIndices, validOutputs} = - tf.image.nonMaxSuppressionPadded( - boxes, scores, maxOutputSize, iouThreshold, scoreThreshold, - true); - const after = tf.memory().numTensors; - - expectArraysEqual(await selectedIndices.data(), [3, 0, 0, 0, 0, 0]); - expectArraysEqual(await validOutputs.data(), 2); - expect(after).toEqual(before + 2); - }); - - it('select from three clusters with no padding when pad option is false.', - async () => { - const boxes = tf.tensor2d( - [ - 0, 0, 1, 1, 0, 0.1, 1, 1.1, 0, -0.1, 1, 0.9, - 0, 10, 1, 11, 0, 10.1, 1, 11.1, 0, 100, 1, 101 - ], - [6, 4]); - const scores = tf.tensor1d([0.9, 0.75, 0.6, 0.95, 0.5, 0.3]); - const maxOutputSize = 5; - const iouThreshold = 0.5; - const scoreThreshold = 0.0; - - const {selectedIndices, validOutputs} = - tf.image.nonMaxSuppressionPadded( - boxes, scores, maxOutputSize, iouThreshold, scoreThreshold, - false); - - expectArraysEqual(await selectedIndices.data(), [3, 0, 5]); - expectArraysEqual(await validOutputs.data(), 3); - }); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/image/non_max_suppression_with_score.ts b/tfjs-master/tfjs-core/src/ops/image/non_max_suppression_with_score.ts deleted file mode 100644 index 060c61356..000000000 --- a/tfjs-master/tfjs-core/src/ops/image/non_max_suppression_with_score.ts +++ /dev/null @@ -1,86 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../../engine'; -import {NonMaxSuppressionV5, NonMaxSuppressionV5Attrs, NonMaxSuppressionV5Inputs} from '../../kernel_names'; -import {NamedAttrMap} from '../../kernel_registry'; -import {Tensor, Tensor1D, Tensor2D} from '../../tensor'; -import {NamedTensorMap} from '../../tensor_types'; -import {convertToTensor} from '../../tensor_util_env'; -import {TensorLike} from '../../types'; - -import {nonMaxSuppSanityCheck} from '../nonmax_util'; -import {op} from '../operation'; - -/** - * Performs non maximum suppression of bounding boxes based on - * iou (intersection over union). - * - * This op also supports a Soft-NMS mode (cf. - * Bodla et al, https://arxiv.org/abs/1704.04503) where boxes reduce the score - * of other overlapping boxes, therefore favoring different regions of the image - * with high scores. To enable this Soft-NMS mode, set the `softNmsSigma` - * parameter to be larger than 0. - * - * @param boxes a 2d tensor of shape `[numBoxes, 4]`. Each entry is - * `[y1, x1, y2, x2]`, where `(y1, x1)` and `(y2, x2)` are the corners of - * the bounding box. - * @param scores a 1d tensor providing the box scores of shape `[numBoxes]`. - * @param maxOutputSize The maximum number of boxes to be selected. - * @param iouThreshold A float representing the threshold for deciding whether - * boxes overlap too much with respect to IOU. Must be between [0, 1]. - * Defaults to 0.5 (50% box overlap). - * @param scoreThreshold A threshold for deciding when to remove boxes based - * on score. Defaults to -inf, which means any score is accepted. - * @param softNmsSigma A float representing the sigma parameter for Soft NMS. - * When sigma is 0, it falls back to nonMaxSuppression. - * @return A map with the following properties: - * - selectedIndices: A 1D tensor with the selected box indices. - * - selectedScores: A 1D tensor with the corresponding scores for each - * selected box. - * - * @doc {heading: 'Operations', subheading: 'Images', namespace: 'image'} - */ -function nonMaxSuppressionWithScore_( - boxes: Tensor2D|TensorLike, scores: Tensor1D|TensorLike, - maxOutputSize: number, iouThreshold = 0.5, - scoreThreshold = Number.NEGATIVE_INFINITY, - softNmsSigma = 0.0): NamedTensorMap { - const $boxes = convertToTensor(boxes, 'boxes', 'nonMaxSuppression'); - const $scores = convertToTensor(scores, 'scores', 'nonMaxSuppression'); - - const params = nonMaxSuppSanityCheck( - $boxes, $scores, maxOutputSize, iouThreshold, scoreThreshold, - softNmsSigma); - maxOutputSize = params.maxOutputSize; - iouThreshold = params.iouThreshold; - scoreThreshold = params.scoreThreshold; - softNmsSigma = params.softNmsSigma; - - const inputs: NonMaxSuppressionV5Inputs = {boxes: $boxes, scores: $scores}; - const attrs: NonMaxSuppressionV5Attrs = - {maxOutputSize, iouThreshold, scoreThreshold, softNmsSigma}; - - // tslint:disable-next-line: no-unnecessary-type-assertion - const result = ENGINE.runKernel( - NonMaxSuppressionV5, inputs as unknown as NamedTensorMap, - attrs as unknown as NamedAttrMap) as Tensor[]; - - return {selectedIndices: result[0], selectedScores: result[1]}; -} - -export const nonMaxSuppressionWithScore = /* @__PURE__ */ op({nonMaxSuppressionWithScore_}); diff --git a/tfjs-master/tfjs-core/src/ops/image/non_max_suppression_with_score_async.ts b/tfjs-master/tfjs-core/src/ops/image/non_max_suppression_with_score_async.ts deleted file mode 100644 index 2f76f6df5..000000000 --- a/tfjs-master/tfjs-core/src/ops/image/non_max_suppression_with_score_async.ts +++ /dev/null @@ -1,94 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {nonMaxSuppressionV5Impl} from '../../backends/non_max_suppression_impl'; -import {Tensor1D, Tensor2D} from '../../tensor'; -import {NamedTensorMap} from '../../tensor_types'; -import {convertToTensor} from '../../tensor_util_env'; -import {TensorLike} from '../../types'; -import {nonMaxSuppSanityCheck} from '../nonmax_util'; -import {tensor1d} from '../tensor1d'; - -/** - * Asynchronously performs non maximum suppression of bounding boxes based on - * iou (intersection over union). - * - * This op also supports a Soft-NMS mode (cf. - * Bodla et al, https://arxiv.org/abs/1704.04503) where boxes reduce the score - * of other overlapping boxes, therefore favoring different regions of the image - * with high scores. To enable this Soft-NMS mode, set the `softNmsSigma` - * parameter to be larger than 0. - * - * @param boxes a 2d tensor of shape `[numBoxes, 4]`. Each entry is - * `[y1, x1, y2, x2]`, where `(y1, x1)` and `(y2, x2)` are the corners of - * the bounding box. - * @param scores a 1d tensor providing the box scores of shape `[numBoxes]`. - * @param maxOutputSize The maximum number of boxes to be selected. - * @param iouThreshold A float representing the threshold for deciding whether - * boxes overlap too much with respect to IOU. Must be between [0, 1]. - * Defaults to 0.5 (50% box overlap). - * @param scoreThreshold A threshold for deciding when to remove boxes based - * on score. Defaults to -inf, which means any score is accepted. - * @param softNmsSigma A float representing the sigma parameter for Soft NMS. - * When sigma is 0, it falls back to nonMaxSuppression. - * @return A map with the following properties: - * - selectedIndices: A 1D tensor with the selected box indices. - * - selectedScores: A 1D tensor with the corresponding scores for each - * selected box. - * - * @doc {heading: 'Operations', subheading: 'Images', namespace: 'image'} - */ -async function nonMaxSuppressionWithScoreAsync_( - boxes: Tensor2D|TensorLike, scores: Tensor1D|TensorLike, - maxOutputSize: number, iouThreshold = 0.5, - scoreThreshold = Number.NEGATIVE_INFINITY, - softNmsSigma = 0.0): Promise { - const $boxes = convertToTensor(boxes, 'boxes', 'nonMaxSuppressionAsync'); - const $scores = convertToTensor(scores, 'scores', 'nonMaxSuppressionAsync'); - - const params = nonMaxSuppSanityCheck( - $boxes, $scores, maxOutputSize, iouThreshold, scoreThreshold, - softNmsSigma); - maxOutputSize = params.maxOutputSize; - iouThreshold = params.iouThreshold; - scoreThreshold = params.scoreThreshold; - softNmsSigma = params.softNmsSigma; - - const boxesAndScores = await Promise.all([$boxes.data(), $scores.data()]); - const boxesVals = boxesAndScores[0]; - const scoresVals = boxesAndScores[1]; - - // We call a cpu based impl directly with the typedarray data here rather - // than a kernel because all kernels are synchronous (and thus cannot await - // .data()). - const {selectedIndices, selectedScores} = nonMaxSuppressionV5Impl( - boxesVals, scoresVals, maxOutputSize, iouThreshold, scoreThreshold, - softNmsSigma); - - if ($boxes !== boxes) { - $boxes.dispose(); - } - if ($scores !== scores) { - $scores.dispose(); - } - - return { - selectedIndices: tensor1d(selectedIndices, 'int32'), - selectedScores: tensor1d(selectedScores) - }; -} - -export const nonMaxSuppressionWithScoreAsync = nonMaxSuppressionWithScoreAsync_; diff --git a/tfjs-master/tfjs-core/src/ops/image/resize_bilinear.ts b/tfjs-master/tfjs-core/src/ops/image/resize_bilinear.ts deleted file mode 100644 index a43206043..000000000 --- a/tfjs-master/tfjs-core/src/ops/image/resize_bilinear.ts +++ /dev/null @@ -1,89 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../../engine'; -import {ResizeBilinear, ResizeBilinearAttrs, ResizeBilinearInputs} from '../../kernel_names'; -import {NamedAttrMap} from '../../kernel_registry'; -import {Tensor3D, Tensor4D} from '../../tensor'; -import {NamedTensorMap} from '../../tensor_types'; -import {convertToTensor} from '../../tensor_util_env'; -import {TensorLike} from '../../types'; -import * as util from '../../util'; - -import {op} from '../operation'; -import {reshape} from '../reshape'; - -/** - * Bilinear resize a single 3D image or a batch of 3D images to a new shape. - * - * @param images The images, of rank 4 or rank 3, of shape - * `[batch, height, width, inChannels]`. If rank 3, batch of 1 is assumed. - * @param size The new shape `[newHeight, newWidth]` to resize the - * images to. Each channel is resized individually. - * @param alignCorners Defaults to `false`. If true, rescale - * input by `(new_height - 1) / (height - 1)`, which exactly aligns the 4 - * corners of images and resized images. If false, rescale by - * `new_height / height`. Treat similarly the width dimension. - * @param halfPixelCenters Defaults to `false`. Whether to assume pixel centers - * are at 0.5, which would make the floating point coordinates of the top - * left pixel 0.5, 0.5. - * - * @doc {heading: 'Operations', subheading: 'Images', namespace: 'image'} - */ -function resizeBilinear_( - images: T|TensorLike, size: [number, number], alignCorners = false, - halfPixelCenters = false): T { - const $images = convertToTensor(images, 'images', 'resizeBilinear'); - - util.assert( - $images.rank === 3 || $images.rank === 4, - () => `Error in resizeBilinear: x must be rank 3 or 4, but got ` + - `rank ${$images.rank}.`); - util.assert( - size.length === 2, - () => `Error in resizeBilinear: new shape must 2D, but got shape ` + - `${size}.`); - util.assert( - halfPixelCenters === false || alignCorners === false, - () => `Error in resizeBilinear: If halfPixelCenters is true, ` + - `alignCorners must be false.`); - - let batchImages = $images as Tensor4D; - let reshapedTo4D = false; - if ($images.rank === 3) { - reshapedTo4D = true; - batchImages = reshape( - $images, [1, $images.shape[0], $images.shape[1], $images.shape[2]]); - } - - const [] = size; - - const inputs: ResizeBilinearInputs = {images: batchImages}; - const attrs: ResizeBilinearAttrs = {alignCorners, halfPixelCenters, size}; - - // tslint:disable-next-line: no-unnecessary-type-assertion - const res = ENGINE.runKernel( - ResizeBilinear, inputs as unknown as NamedTensorMap, - attrs as unknown as NamedAttrMap) as T; - - if (reshapedTo4D) { - return reshape(res, [res.shape[1], res.shape[2], res.shape[3]]) as T; - } - return res; -} - -export const resizeBilinear = /* @__PURE__ */ op({resizeBilinear_}); diff --git a/tfjs-master/tfjs-core/src/ops/image/resize_bilinear_test.ts b/tfjs-master/tfjs-core/src/ops/image/resize_bilinear_test.ts deleted file mode 100644 index 4c7ace516..000000000 --- a/tfjs-master/tfjs-core/src/ops/image/resize_bilinear_test.ts +++ /dev/null @@ -1,979 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../../index'; -import {ALL_ENVS, describeWithFlags} from '../../jasmine_util'; -import {expectArraysClose} from '../../test_util'; - -describeWithFlags('resizeBilinear', ALL_ENVS, () => { - it('simple alignCorners=false', async () => { - const input = tf.tensor3d([2, 2, 4, 4], [2, 2, 1]); - const output = input.resizeBilinear([3, 3], false); - - expectArraysClose( - await output.data(), [2, 2, 2, 10 / 3, 10 / 3, 10 / 3, 4, 4, 4]); - }); - - it('5x5-bilinear, no change in shape', async () => { - const image: tf.Tensor4D = tf.ones([1, 5, 5, 3]); - - const alignCorners = false; - const output = tf.image.resizeBilinear(image, [5, 5], alignCorners); - - expect(output.shape).toEqual([1, 5, 5, 3]); - expect(output.dtype).toBe('float32'); - expectArraysClose(await output.data(), await image.data()); - }); - - it('simple alignCorners=true', async () => { - const input = tf.tensor3d([2, 2, 4, 4], [2, 2, 1]); - const output = input.resizeBilinear([3, 3], true); - - expectArraysClose(await output.data(), [2, 2, 2, 3, 3, 3, 4, 4, 4]); - }); - - it('works when rows are copied', async () => { - const input = tf.tensor3d( - [ - 1.56324531, 2.13817752, 1.44398421, 1.07632684, 0.59306785, - -0.36970865, 1.62451879, 1.8367334, 1.13944798, 2.01993218, - 2.01919952, 2.67524054 - ], - [2, 3, 2]); - const output = input.resizeBilinear([4, 3], false); - - expectArraysClose(await output.data(), [ - 1.5632453, 2.13817763, 1.44398415, 1.07632685, 0.59306782, -0.36970866, - 1.59388208, 1.98745549, 1.2917161, 1.54812956, 1.30613375, 1.15276587, - 1.62451875, 1.83673334, 1.13944793, 2.01993227, 2.01919961, 2.67524052, - 1.62451875, 1.83673334, 1.13944793, 2.01993227, 2.01919961, 2.67524052 - ]); - }); - - it('works for ints', async () => { - const input = tf.tensor3d([1, 2, 3, 4, 5], [1, 5, 1], 'int32'); - const output = input.resizeBilinear([1, 10], false); - - expect(output.shape).toEqual([1, 10, 1]); - expect(output.dtype).toBe('float32'); - expectArraysClose( - await output.data(), [1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5]); - }); - - it('matches tensorflow w/ random numbers alignCorners=false, ' + - 'halfPixelCenters=true', - async () => { - const input = tf.tensor3d( - [ - 1.19074044, 0.91373104, 2.01611669, -0.52270832, 0.38725395, - 1.30809779, 0.61835143, 3.49600659, 2.09230986, 0.56473997, - 0.03823943, 1.19864896 - ], - [2, 3, 2]); - const output = input.resizeBilinear([4, 5], false, true); - - expectArraysClose(await output.data(), [ - 1.1907405, 0.913731, 1.520891, 0.3391553, 2.0161166, -0.5227083, - 1.0387988, 0.5757756, 0.3872539, 1.3080978, 1.0476432, 1.5592999, - 1.442652, 0.8352414, 2.0351648, -0.2508462, 0.9940659, 0.6681031, - 0.3000003, 1.2807356, 0.7614487, 2.8504376, 1.2861738, 1.8274136, - 2.0732617, 0.2928779, 0.9046002, 0.8527579, 0.125493, 1.2260112, - 0.6183515, 3.4960065, 1.2079349, 2.3234997, 2.09231, 0.5647399, - 0.8598673, 0.9450854, 0.0382394, 1.1986489 - ]); - }); - - it('batch of 2, simple, alignCorners=false, ' + - 'halfPixelCenters=true', - async () => { - const input = tf.tensor4d([2, 2, 4, 4, 3, 3, 5, 5], [2, 2, 2, 1]); - const output = - input.resizeBilinear([3, 3], false /* alignCorners */, true); - - expectArraysClose( - await output.data(), - [2, 2, 2, 3, 3, 3, 4, 4, 4, 3, 3, 3, 4, 4, 4, 5, 5, 5]); - }); - - it('target width = 1, alignCorners=false, ' + - 'halfPixelCenters=true', - async () => { - const input = tf.tensor3d([ - [ - [120.68856811523438, 134.51638793945312, 83.03671264648438], - [121.58008575439453, 113.28836059570312, 136.3172149658203], - [79.38370513916016, 101.87127685546875, 104.54979705810547], - [96.31678771972656, 111.77168273925781, 83.73509979248047] - ], - [ - [119.45088195800781, 88.98846435546875, 97.47553253173828], - [117.5562973022461, 108.26356506347656, 99.62212371826172], - [136.62701416015625, 94.10433197021484, 80.97366333007812], - [83.61205291748047, 90.60148620605469, 81.82512664794922] - ], - [ - [103.0362777709961, 123.1098403930664, 125.62944030761719], - [92.2915267944336, 103.15729522705078, 119.18060302734375], - [102.93293762207031, 117.821044921875, 99.40152740478516], - [96.32952117919922, 105.80963134765625, 104.8491439819336] - ], - [ - [104.87507629394531, 134.0189208984375, 111.02627563476562], - [85.4534683227539, 107.68426513671875, 103.03722381591797], - [89.70533752441406, 98.25298309326172, 78.42916870117188], - [113.6744613647461, 95.8189697265625, 122.75005340576172] - ] - ]); - - const output = input.resizeBilinear([3, 1], false, true); - - const expected = [ - 104.917, 106.514, 115.411, 112.352, 105.837, 99.7945, 89.2515, 104.222, - 93.8262 - ]; - expectArraysClose(await output.data(), expected); - expect(output.shape).toEqual([3, 1, 3]); - }); - - it('matches tensorflow w/ random numbers alignCorners=false', async () => { - const input = tf.tensor3d( - [ - 1.19074044, 0.91373104, 2.01611669, -0.52270832, 0.38725395, - 1.30809779, 0.61835143, 3.49600659, 2.09230986, 0.56473997, - 0.03823943, 1.19864896 - ], - [2, 3, 2]); - const output = input.resizeBilinear([4, 5], false); - - expectArraysClose(await output.data(), [ - 1.19074047, 0.91373104, 1.68596613, 0.05186744, 1.69034398, -0.15654698, - 0.7130264, 0.94193673, 0.38725394, 1.30809784, 0.9045459, 2.20486879, - 1.59434628, 0.89455694, 1.68591988, 0.26748738, 0.58103991, 1.00690198, - 0.21274668, 1.25337338, 0.6183514, 3.49600649, 1.50272655, 1.73724651, - 1.68149579, 0.69152176, 0.44905344, 1.07186723, 0.03823943, 1.19864893, - 0.6183514, 3.49600649, 1.50272655, 1.73724651, 1.68149579, 0.69152176, - 0.44905344, 1.07186723, 0.03823943, 1.19864893 - ]); - }); - - it('matches tensorflow w/ random numbers alignCorners=true', async () => { - const input = tf.tensor3d( - [ - 1.56324531, 2.13817752, 1.44398421, 1.07632684, 0.59306785, - -0.36970865, 1.62451879, 1.8367334, 1.13944798, 2.01993218, - 2.01919952, 2.67524054 - ], - [2, 3, 2]); - const output = input.resizeBilinear([4, 5], true); - - expectArraysClose(await output.data(), [ - 1.5632453, 2.13817763, 1.50361478, 1.60725224, 1.44398427, 1.07632685, - 1.01852608, 0.35330909, 0.59306782, -0.36970866, 1.58366978, 2.03769612, - 1.46307099, 1.71427906, 1.3424722, 1.39086199, 1.20545864, 1.01806819, - 1.06844509, 0.6452744, 1.60409427, 1.93721485, 1.42252707, 1.82130599, - 1.24096, 1.70539713, 1.3923912, 1.68282723, 1.54382229, 1.66025746, - 1.62451875, 1.83673346, 1.38198328, 1.92833281, 1.13944793, 2.01993227, - 1.57932377, 2.34758639, 2.01919961, 2.67524052 - ]); - }); - - it('batch of 2, simple, alignCorners=true', async () => { - const input = tf.tensor4d([2, 2, 4, 4, 3, 3, 5, 5], [2, 2, 2, 1]); - const output = input.resizeBilinear([3, 3], true /* alignCorners */); - - expectArraysClose( - await output.data(), - [2, 2, 2, 3, 3, 3, 4, 4, 4, 3, 3, 3, 4, 4, 4, 5, 5, 5]); - }); - - it('target width = 1, alignCorners=true', async () => { - const input = tf.tensor3d([ - [ - [120.68856811523438, 134.51638793945312, 83.03671264648438], - [121.58008575439453, 113.28836059570312, 136.3172149658203], - [79.38370513916016, 101.87127685546875, 104.54979705810547], - [96.31678771972656, 111.77168273925781, 83.73509979248047] - ], - [ - [119.45088195800781, 88.98846435546875, 97.47553253173828], - [117.5562973022461, 108.26356506347656, 99.62212371826172], - [136.62701416015625, 94.10433197021484, 80.97366333007812], - [83.61205291748047, 90.60148620605469, 81.82512664794922] - ], - [ - [103.0362777709961, 123.1098403930664, 125.62944030761719], - [92.2915267944336, 103.15729522705078, 119.18060302734375], - [102.93293762207031, 117.821044921875, 99.40152740478516], - [96.32952117919922, 105.80963134765625, 104.8491439819336] - ], - [ - [104.87507629394531, 134.0189208984375, 111.02627563476562], - [85.4534683227539, 107.68426513671875, 103.03722381591797], - [89.70533752441406, 98.25298309326172, 78.42916870117188], - [113.6744613647461, 95.8189697265625, 122.75005340576172] - ] - ]); - - const output = input.resizeBilinear([3, 1], true); - - const expected = [ - 120.68857, 134.51639, 83.03671, 111.243576, 106.04915, 111.55249, - 104.87508, 134.01892, 111.026276 - ]; - expectArraysClose(await output.data(), expected); - expect(output.shape).toEqual([3, 1, 3]); - }); - - it('target height = 1, alignCorners=true', async () => { - const input = tf.tensor3d([ - [ - [120.68856811523438, 134.51638793945312, 83.03671264648438], - [121.58008575439453, 113.28836059570312, 136.3172149658203], - [79.38370513916016, 101.87127685546875, 104.54979705810547], - [96.31678771972656, 111.77168273925781, 83.73509979248047] - ], - [ - [119.45088195800781, 88.98846435546875, 97.47553253173828], - [117.5562973022461, 108.26356506347656, 99.62212371826172], - [136.62701416015625, 94.10433197021484, 80.97366333007812], - [83.61205291748047, 90.60148620605469, 81.82512664794922] - ], - [ - [103.0362777709961, 123.1098403930664, 125.62944030761719], - [92.2915267944336, 103.15729522705078, 119.18060302734375], - [102.93293762207031, 117.821044921875, 99.40152740478516], - [96.32952117919922, 105.80963134765625, 104.8491439819336] - ], - [ - [104.87507629394531, 134.0189208984375, 111.02627563476562], - [85.4534683227539, 107.68426513671875, 103.03722381591797], - [89.70533752441406, 98.25298309326172, 78.42916870117188], - [113.6744613647461, 95.8189697265625, 122.75005340576172] - ] - ]); - - const output = input.resizeBilinear([1, 3], true); - - const expected = [ - 120.68857, 134.51639, 83.03671, 100.481895, 107.57982, 120.4335, 96.31679, - 111.77168, 83.7351 - ]; - expectArraysClose(await output.data(), expected); - expect(output.shape).toEqual([1, 3, 3]); - }); - - it('throws when passed a non-tensor', () => { - const e = /Argument 'images' passed to 'resizeBilinear' must be a Tensor/; - expect(() => tf.image.resizeBilinear({} as tf.Tensor3D, [ - 1, 1 - ])).toThrowError(e); - }); - - it('accepts a tensor-like object', async () => { - const input = [[[2], [2]], [[4], [4]]]; // 2x2x1 - const output = tf.image.resizeBilinear(input, [3, 3], false); - expectArraysClose( - await output.data(), [2, 2, 2, 10 / 3, 10 / 3, 10 / 3, 4, 4, 4]); - }); -}); - -describeWithFlags('resizeBilinear gradients', ALL_ENVS, () => { - it('greyscale: upscale, same aspect ratio', async () => { - const input = tf.tensor3d([[[100.0], [50.0]], [[60.0], [20.0]]]); - const dy = tf.tensor3d([ - [[1.0], [2.0], [3.0], [4.0]], [[5.0], [6.0], [7.0], [8.0]], - [[9.0], [10.0], [11.0], [12.0]], [[13.0], [14.0], [15.0], [16.0]] - ]); - - const size: [number, number] = [4, 4]; - const alignCorners = false; - const g = tf.grad( - (i: tf.Tensor3D) => tf.image.resizeBilinear(i, size, alignCorners)); - - const output = g(input, dy); - const expected = [6.0, 17.0, 38.0, 75.0]; - - expectArraysClose(await output.data(), expected); - }); - - it('with clones, greyscale: upscale, same aspect ratio', async () => { - const input = tf.tensor3d([[[100.0], [50.0]], [[60.0], [20.0]]]); - const dy = tf.tensor3d([ - [[1.0], [2.0], [3.0], [4.0]], [[5.0], [6.0], [7.0], [8.0]], - [[9.0], [10.0], [11.0], [12.0]], [[13.0], [14.0], [15.0], [16.0]] - ]); - - const size: [number, number] = [4, 4]; - const alignCorners = false; - const g = tf.grad( - (i: tf.Tensor3D) => - tf.image.resizeBilinear(i.clone(), size, alignCorners).clone()); - - const output = g(input, dy); - const expected = [6.0, 17.0, 38.0, 75.0]; - - expectArraysClose(await output.data(), expected); - }); - - it('greyscale: upscale, same aspect ratio, align corners', async () => { - const input = tf.tensor3d([[[100.0], [50.0]], [[60.0], [20.0]]]); - const dy = tf.tensor3d([ - [[1.0], [2.0], [3.0], [4.0]], [[5.0], [6.0], [7.0], [8.0]], - [[9.0], [10.0], [11.0], [12.0]], [[13.0], [14.0], [15.0], [16.0]] - ]); - - const size: [number, number] = [4, 4]; - const alignCorners = true; - const g = tf.grad( - (i: tf.Tensor3D) => tf.image.resizeBilinear(i, size, alignCorners)); - - const output = g(input, dy); - const expected = - [17.333330154418945, 23.999998092651367, 44.0, 50.66666793823242]; - - expectArraysClose(await output.data(), expected); - }); - - it('greyscale: upscale, taller than wider', async () => { - const input = tf.tensor3d([[[100.0], [50.0]], [[60.0], [20.0]]]); - const dy = tf.tensor3d([ - [[1.0], [2.0], [3.0], [4.0]], [[5.0], [6.0], [7.0], [8.0]], - [[9.0], [10.0], [11.0], [12.0]], [[13.0], [14.0], [15.0], [16.0]], - [[17.0], [18.0], [19.0], [20.0]], [[21.0], [22.0], [23.0], [24.0]], - [[25.0], [26.0], [27.0], [28.0]], [[29.0], [30.0], [31.0], [32.0]], - [[33.0], [34.0], [35.0], [36.0]] - ]); - - const size: [number, number] = [9, 4]; - const alignCorners = false; - const g = tf.grad( - (i: tf.Tensor3D) => tf.image.resizeBilinear(i, size, alignCorners)); - - const output = g(input, dy); - const expected = [ - 25.55555534362793, 55.5555534362793, 208.44444274902344, 376.4444274902344 - ]; - - expectArraysClose(await output.data(), expected); - }); - - it('greyscale: upscale, taller than wider, align corners', async () => { - const input = tf.tensor3d([[[100.0], [50.0]], [[60.0], [20.0]]]); - const dy = tf.tensor3d([ - [[1.0], [2.0], [3.0], [4.0]], [[5.0], [6.0], [7.0], [8.0]], - [[9.0], [10.0], [11.0], [12.0]], [[13.0], [14.0], [15.0], [16.0]], - [[17.0], [18.0], [19.0], [20.0]], [[21.0], [22.0], [23.0], [24.0]], - [[25.0], [26.0], [27.0], [28.0]], [[29.0], [30.0], [31.0], [32.0]], - [[33.0], [34.0], [35.0], [36.0]] - ]); - - const size: [number, number] = [9, 4]; - const alignCorners = true; - const g = tf.grad( - (i: tf.Tensor3D) => tf.image.resizeBilinear(i, size, alignCorners)); - - const output = g(input, dy); - const expected = [99.0, 114.0, 219.00001525878906, 233.99998474121094]; - - expectArraysClose(await output.data(), expected); - }); - - it('greyscale: upscale, wider than taller', async () => { - const input = tf.tensor3d([[[100.0], [50.0]], [[60.0], [20.0]]]); - const dy = tf.tensor3d([ - [[1.0], [2.0], [3.0], [4.0], [5.0], [6.0], [7.0]], - [[8.0], [9.0], [10.0], [11.0], [12.0], [13.0], [14.0]], - [[15.0], [16.0], [17.0], [18.0], [19.0], [20.0], [21.0]], - [[22.0], [23.0], [24.0], [25.0], [26.0], [27.0], [28.0]] - ]); - - const size: [number, number] = [4, 7]; - const alignCorners = false; - const g = tf.grad( - (i: tf.Tensor3D) => tf.image.resizeBilinear(i, size, alignCorners)); - - const output = g(input, dy); - const expected = [ - 14.428570747375488, 52.07142639160156, 98.71427917480469, - 240.78573608398438 - ]; - - expectArraysClose(await output.data(), expected); - }); - - it('greyscale: upscale, wider than taller, align corners', async () => { - const input = tf.tensor3d([[[100.0], [50.0]], [[60.0], [20.0]]]); - const dy = tf.tensor3d([ - [[1.0], [2.0], [3.0], [4.0], [5.0], [6.0], [7.0]], - [[8.0], [9.0], [10.0], [11.0], [12.0], [13.0], [14.0]], - [[15.0], [16.0], [17.0], [18.0], [19.0], [20.0], [21.0]], - [[22.0], [23.0], [24.0], [25.0], [26.0], [27.0], [28.0]] - ]); - - const size: [number, number] = [4, 7]; - const alignCorners = true; - const g = tf.grad( - (i: tf.Tensor3D) => tf.image.resizeBilinear(i, size, alignCorners)); - - const output = g(input, dy); - const expected = [51.33332824707031, 70.0, 133.0, 151.66668701171875]; - - expectArraysClose(await output.data(), expected); - }); - - // Downscale - - it('greyscale: downscale, same aspect ratio', async () => { - const input = tf.tensor3d([ - [[100.0], [50.0], [25.0], [10.0]], [[60.0], [20.0], [80.0], [20.0]], - [[40.0], [15.0], [200.0], [203.0]], [[40.0], [10.0], [230.0], [200.0]] - ]); - - const dy = tf.tensor3d([[[1.0], [2.0]], [[3.0], [4.0]]]); - - const size: [number, number] = [2, 2]; - const alignCorners = false; - const g = tf.grad( - (i: tf.Tensor3D) => tf.image.resizeBilinear(i, size, alignCorners)); - - const output = g(input, dy); - const expected = [ - 1.0, 0.0, 2.0, 0.0, 0.0, 0.0, 0.0, 0.0, 3.0, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, - 0.0 - ]; - - expectArraysClose(await output.data(), expected); - }); - - it('greyscale: downscale, same aspect ratio, align corners', async () => { - const input = tf.tensor3d([ - [[100.0], [50.0], [25.0], [10.0]], [[60.0], [20.0], [80.0], [20.0]], - [[40.0], [15.0], [200.0], [203.0]], [[40.0], [10.0], [230.0], [200.0]] - ]); - - const dy = tf.tensor3d([[[1.0], [2.0]], [[3.0], [4.0]]]); - - const size: [number, number] = [2, 2]; - const alignCorners = true; - const g = tf.grad( - (i: tf.Tensor3D) => tf.image.resizeBilinear(i, size, alignCorners)); - - const output = g(input, dy); - const expected = [ - 1.0, 0.0, 0.0, 2.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 3.0, 0.0, 0.0, - 4.0 - ]; - - expectArraysClose(await output.data(), expected); - }); - - it('greyscale: downscale, taller than wider', async () => { - const input = tf.tensor3d([ - [[100.0], [50.0], [25.0], [10.0]], [[60.0], [20.0], [80.0], [20.0]], - [[40.0], [15.0], [200.0], [203.0]], [[40.0], [10.0], [230.0], [200.0]] - ]); - - const dy = tf.tensor3d([[[1.0], [2.0]], [[3.0], [4.0]], [[5.0], [6.0]]]); - - const size: [number, number] = [3, 2]; - const alignCorners = false; - const g = tf.grad( - (i: tf.Tensor3D) => tf.image.resizeBilinear(i, size, alignCorners)); - - const output = g(input, dy); - const expected = [ - 1.0, 0.0, 2.0, 0.0, 1.9999998807907104, 0.0, 2.6666665077209473, 0.0, - 2.6666665077209473, 0.0, 3.3333330154418945, 0.0, 3.333333730697632, 0.0, - 4.000000476837158, 0.0 - ]; - - expectArraysClose(await output.data(), expected); - }); - - it('greyscale: downscale, taller than wider, align corners', async () => { - const input = tf.tensor3d([ - [[100.0], [50.0], [25.0], [10.0]], [[60.0], [20.0], [80.0], [20.0]], - [[40.0], [15.0], [200.0], [203.0]], [[40.0], [10.0], [230.0], [200.0]] - ]); - - const dy = tf.tensor3d([[[1.0], [2.0]], [[3.0], [4.0]], [[5.0], [6.0]]]); - - const size: [number, number] = [3, 2]; - const alignCorners = true; - const g = tf.grad( - (i: tf.Tensor3D) => tf.image.resizeBilinear(i, size, alignCorners)); - - const output = g(input, dy); - const expected = [ - 1.0, 0.0, 0.0, 2.0, 1.5, 0.0, 0.0, 2.0, 1.5, 0.0, 0.0, 2.0, 5.0, 0.0, 0.0, - 6.0 - ]; - - expectArraysClose(await output.data(), expected); - }); - - it('greyscale: downscale, wider than taller', async () => { - const input = tf.tensor3d([ - [[100.0], [50.0], [25.0], [10.0]], [[60.0], [20.0], [80.0], [20.0]], - [[40.0], [15.0], [200.0], [203.0]], [[40.0], [10.0], [230.0], [200.0]] - ]); - - const dy = tf.tensor3d([[[1.0], [2.0], [3.0]], [[4.0], [5.0], [6.0]]]); - - const size: [number, number] = [2, 3]; - const alignCorners = false; - const g = tf.grad( - (i: tf.Tensor3D) => tf.image.resizeBilinear(i, size, alignCorners)); - - const output = g(input, dy); - const expected = [ - 1.0, 1.3333332538604736, 1.6666665077209473, 2.000000238418579, 0.0, 0.0, - 0.0, 0.0, 4.0, 3.3333330154418945, 3.6666665077209473, 4.000000476837158, - 0.0, 0.0, 0.0, 0.0 - ]; - - expectArraysClose(await output.data(), expected); - }); - - it('greyscale: downscale, wider than taller, align corners', async () => { - const input = tf.tensor3d([ - [[100.0], [50.0], [25.0], [10.0]], [[60.0], [20.0], [80.0], [20.0]], - [[40.0], [15.0], [200.0], [203.0]], [[40.0], [10.0], [230.0], [200.0]] - ]); - - const dy = tf.tensor3d([[[1.0], [2.0], [3.0]], [[4.0], [5.0], [6.0]]]); - - const size: [number, number] = [2, 3]; - const alignCorners = true; - const g = tf.grad( - (i: tf.Tensor3D) => tf.image.resizeBilinear(i, size, alignCorners)); - - const output = g(input, dy); - const expected = [ - 1.0, 1.0, 1.0, 3.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 4.0, 2.5, 2.5, - 6.0 - ]; - - expectArraysClose(await output.data(), expected); - }); - - // No Op - - it('greyscale: same size', async () => { - const input = tf.tensor3d([[[100.0], [50.0]], [[60.0], [20.0]]]); - - const dy = tf.tensor3d([[[1.0], [2.0]], [[3.0], [4.0]]]); - - const size: [number, number] = [2, 2]; - const alignCorners = false; - const g = tf.grad( - (i: tf.Tensor3D) => tf.image.resizeBilinear(i, size, alignCorners)); - - const output = g(input, dy); - const expected = [1.0, 2.0, 3.0, 4.0]; - - expectArraysClose(await output.data(), expected); - }); - - it('greyscale: same size, align corners', async () => { - const input = tf.tensor3d([[[100.0], [50.0]], [[60.0], [20.0]]]); - - const dy = tf.tensor3d([[[1.0], [2.0]], [[3.0], [4.0]]]); - - const size: [number, number] = [2, 2]; - const alignCorners = true; - const g = tf.grad( - (i: tf.Tensor3D) => tf.image.resizeBilinear(i, size, alignCorners)); - - const output = g(input, dy); - const expected = [1.0, 2.0, 3.0, 4.0]; - - expectArraysClose(await output.data(), expected); - }); - - // 3 channel upscale - it('color: upscale, wider than taller', async () => { - const input = tf.tensor3d([ - [ - [115.11029815673828, 111.90936279296875, 66.87433624267578], - [72.03849029541016, 81.86637878417969, 119.53585815429688] - ], - [ - [68.555419921875, 97.49642181396484, 116.90741729736328], - [128.69467163085938, 86.78314208984375, 104.3116683959961] - ] - ]); - - const dy = tf.tensor3d([ - [ - [1.0, 2.0, 3.0], [4.0, 5.0, 6.0], [7.0, 8.0, 9.0], [10.0, 11.0, 12.0], - [13.0, 14.0, 15.0] - ], - [ - [16.0, 17.0, 18.0], [19.0, 20.0, 21.0], [22.0, 23.0, 24.0], - [25.0, 26.0, 27.0], [28.0, 29.0, 30.0] - ], - [ - [31.0, 32.0, 33.0], [34.0, 35.0, 36.0], [37.0, 38.0, 39.0], - [40.0, 41.0, 42.0], [43.0, 44.0, 45.0] - ] - ]); - - const size: [number, number] = [3, 5]; - const alignCorners = false; - const g = tf.grad( - (i: tf.Tensor3D) => tf.image.resizeBilinear(i, size, alignCorners)); - - const output = g(input, dy); - const expected = [ - 15.399999618530273, 17.799999237060547, 20.19999885559082, - 56.26666259765625, 60.533329010009766, 64.79999542236328, - 80.00000762939453, 83.0, 86.0, 178.33334350585938, 183.66668701171875, - 189.00001525878906 - ]; - - expectArraysClose(await output.data(), expected); - }); - - it('color: upscale, wider than taller, align corners', async () => { - const input = tf.tensor3d([ - [ - [115.11029815673828, 111.90936279296875, 66.87433624267578], - [72.03849029541016, 81.86637878417969, 119.53585815429688] - ], - [ - [68.555419921875, 97.49642181396484, 116.90741729736328], - [128.69467163085938, 86.78314208984375, 104.3116683959961] - ] - ]); - - const dy = tf.tensor3d([ - [ - [1.0, 2.0, 3.0], [4.0, 5.0, 6.0], [7.0, 8.0, 9.0], [10.0, 11.0, 12.0], - [13.0, 14.0, 15.0] - ], - [ - [16.0, 17.0, 18.0], [19.0, 20.0, 21.0], [22.0, 23.0, 24.0], - [25.0, 26.0, 27.0], [28.0, 29.0, 30.0] - ], - [ - [31.0, 32.0, 33.0], [34.0, 35.0, 36.0], [37.0, 38.0, 39.0], - [40.0, 41.0, 42.0], [43.0, 44.0, 45.0] - ] - ]); - - const size: [number, number] = [3, 5]; - const alignCorners = true; - const g = tf.grad( - (i: tf.Tensor3D) => tf.image.resizeBilinear(i, size, alignCorners)); - - const output = g(input, dy); - const expected = [ - 33.75, 37.5, 41.25, 56.25, 60.0, 63.75, 108.75, 112.5, 116.25, 131.25, - 135.0, 138.75 - ]; - - expectArraysClose(await output.data(), expected); - }); - - // 3 channel downscale - - it('color: downscale, taller than wider', async () => { - const input = tf.tensor3d([ - [ - [120.68856811523438, 134.51638793945312, 83.03671264648438], - [121.58008575439453, 113.28836059570312, 136.3172149658203], - [79.38370513916016, 101.87127685546875, 104.54979705810547], - [96.31678771972656, 111.77168273925781, 83.73509979248047] - ], - [ - [119.45088195800781, 88.98846435546875, 97.47553253173828], - [117.5562973022461, 108.26356506347656, 99.62212371826172], - [136.62701416015625, 94.10433197021484, 80.97366333007812], - [83.61205291748047, 90.60148620605469, 81.82512664794922] - ], - [ - [103.0362777709961, 123.1098403930664, 125.62944030761719], - [92.2915267944336, 103.15729522705078, 119.18060302734375], - [102.93293762207031, 117.821044921875, 99.40152740478516], - [96.32952117919922, 105.80963134765625, 104.8491439819336] - ], - [ - [104.87507629394531, 134.0189208984375, 111.02627563476562], - [85.4534683227539, 107.68426513671875, 103.03722381591797], - [89.70533752441406, 98.25298309326172, 78.42916870117188], - [113.6744613647461, 95.8189697265625, 122.75005340576172] - ] - ]); - - const dy = - tf.tensor3d([[[1.0, 2.0, 3.0]], [[4.0, 5.0, 6.0]], [[7.0, 8.0, 9.0]]]); - - const size: [number, number] = [3, 1]; - const alignCorners = false; - const g = tf.grad( - (i: tf.Tensor3D) => tf.image.resizeBilinear(i, size, alignCorners)); - - const output = g(input, dy); - const expected = [ - 1.0, - 2.0, - 3.0, - 0.0, - 0.0, - 0.0, - 0.0, - 0.0, - 0.0, - 0.0, - 0.0, - 0.0, - 2.6666665077209473, - 3.3333330154418945, - 3.999999761581421, - 0.0, - 0.0, - 0.0, - 0.0, - 0.0, - 0.0, - 0.0, - 0.0, - 0.0, - 3.666666269302368, - 4.3333330154418945, - 4.999999523162842, - 0.0, - 0.0, - 0.0, - 0.0, - 0.0, - 0.0, - 0.0, - 0.0, - 0.0, - 4.6666669845581055, - 5.333333969116211, - 6.000000953674316, - 0.0, - 0.0, - 0.0, - 0.0, - 0.0, - 0.0, - 0.0, - 0.0, - 0.0 - ]; - - expectArraysClose(await output.data(), expected); - }); - - it('color: downscale, width = 1, align corners', async () => { - const input = tf.tensor3d([ - [ - [120.68856811523438, 134.51638793945312, 83.03671264648438], - [121.58008575439453, 113.28836059570312, 136.3172149658203], - [79.38370513916016, 101.87127685546875, 104.54979705810547], - [96.31678771972656, 111.77168273925781, 83.73509979248047] - ], - [ - [119.45088195800781, 88.98846435546875, 97.47553253173828], - [117.5562973022461, 108.26356506347656, 99.62212371826172], - [136.62701416015625, 94.10433197021484, 80.97366333007812], - [83.61205291748047, 90.60148620605469, 81.82512664794922] - ], - [ - [103.0362777709961, 123.1098403930664, 125.62944030761719], - [92.2915267944336, 103.15729522705078, 119.18060302734375], - [102.93293762207031, 117.821044921875, 99.40152740478516], - [96.32952117919922, 105.80963134765625, 104.8491439819336] - ], - [ - [104.87507629394531, 134.0189208984375, 111.02627563476562], - [85.4534683227539, 107.68426513671875, 103.03722381591797], - [89.70533752441406, 98.25298309326172, 78.42916870117188], - [113.6744613647461, 95.8189697265625, 122.75005340576172] - ] - ]); - - const dy = - tf.tensor3d([[[1.0, 2.0, 3.0]], [[4.0, 5.0, 6.0]], [[7.0, 8.0, 9.0]]]); - - const size: [number, number] = [3, 1]; - const alignCorners = true; - const g = tf.grad( - (i: tf.Tensor3D) => tf.image.resizeBilinear(i, size, alignCorners)); - - const output = g(input, dy); - const expected = [ - 1.0, 2.0, 3.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 2.0, 2.5, 3.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 2.0, 2.5, 3.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 7.0, 8.0, 9.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 - ]; - expectArraysClose(await output.data(), expected); - }); - - it('color: downscale, height = 1, align corners', async () => { - const input = tf.tensor3d([ - [ - [120.68856811523438, 134.51638793945312, 83.03671264648438], - [121.58008575439453, 113.28836059570312, 136.3172149658203], - [79.38370513916016, 101.87127685546875, 104.54979705810547], - [96.31678771972656, 111.77168273925781, 83.73509979248047] - ], - [ - [119.45088195800781, 88.98846435546875, 97.47553253173828], - [117.5562973022461, 108.26356506347656, 99.62212371826172], - [136.62701416015625, 94.10433197021484, 80.97366333007812], - [83.61205291748047, 90.60148620605469, 81.82512664794922] - ], - [ - [103.0362777709961, 123.1098403930664, 125.62944030761719], - [92.2915267944336, 103.15729522705078, 119.18060302734375], - [102.93293762207031, 117.821044921875, 99.40152740478516], - [96.32952117919922, 105.80963134765625, 104.8491439819336] - ], - [ - [104.87507629394531, 134.0189208984375, 111.02627563476562], - [85.4534683227539, 107.68426513671875, 103.03722381591797], - [89.70533752441406, 98.25298309326172, 78.42916870117188], - [113.6744613647461, 95.8189697265625, 122.75005340576172] - ] - ]); - - const dy = tf.tensor3d([[[1., 2., 3.], [4., 5., 6.], [7., 8., 9.]]]); - - const size: [number, number] = [1, 3]; - const alignCorners = true; - const g = tf.grad( - (i: tf.Tensor3D) => tf.image.resizeBilinear(i, size, alignCorners)); - - const output = g(input, dy); - const expected = [ - 1., 2., 3., 2., 2.5, 3., 2., 2.5, 3., 7., 8., 9., 0., 0., 0., 0., - 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., - 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0. - ]; - expectArraysClose(await output.data(), expected); - }); - - it('color: downscale, taller than wider, align corners', async () => { - const input = tf.tensor3d([ - [ - [120.68856811523438, 134.51638793945312, 83.03671264648438], - [121.58008575439453, 113.28836059570312, 136.3172149658203], - [79.38370513916016, 101.87127685546875, 104.54979705810547], - [96.31678771972656, 111.77168273925781, 83.73509979248047] - ], - [ - [119.45088195800781, 88.98846435546875, 97.47553253173828], - [117.5562973022461, 108.26356506347656, 99.62212371826172], - [136.62701416015625, 94.10433197021484, 80.97366333007812], - [83.61205291748047, 90.60148620605469, 81.82512664794922] - ], - [ - [103.0362777709961, 123.1098403930664, 125.62944030761719], - [92.2915267944336, 103.15729522705078, 119.18060302734375], - [102.93293762207031, 117.821044921875, 99.40152740478516], - [96.32952117919922, 105.80963134765625, 104.8491439819336] - ], - [ - [104.87507629394531, 134.0189208984375, 111.02627563476562], - [85.4534683227539, 107.68426513671875, 103.03722381591797], - [89.70533752441406, 98.25298309326172, 78.42916870117188], - [113.6744613647461, 95.8189697265625, 122.75005340576172] - ] - ]); - - const dy = tf.tensor3d([ - [[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]], [[7.0, 8.0, 9.0], [10.0, 11.0, 12.0]], - [[13.0, 14.0, 15.0], [16.0, 17.0, 18.0]] - ]); - - const size: [number, number] = [3, 2]; - const alignCorners = true; - const g = tf.grad( - (i: tf.Tensor3D) => tf.image.resizeBilinear(i, size, alignCorners)); - - const output = g(input, dy); - const expected = [ - 1.0, 2.0, 3.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 4.0, 5.0, 6.0, - 3.5, 4.0, 4.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 5.0, 5.5, 6.0, - 3.5, 4.0, 4.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 5.0, 5.5, 6.0, - 13.0, 14.0, 15.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 16.0, 17.0, 18.0 - ]; - expectArraysClose(await output.data(), expected); - }); - - // 3 channel no-op - - it('color: same size', async () => { - const input = tf.tensor3d([ - [ - [115.11029815673828, 111.90936279296875, 66.87433624267578], - [72.03849029541016, 81.86637878417969, 119.53585815429688] - ], - [ - [68.555419921875, 97.49642181396484, 116.90741729736328], - [128.69467163085938, 86.78314208984375, 104.3116683959961] - ] - ]); - - const dy = tf.tensor3d([ - [[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]], [[7.0, 8.0, 9.0], [10.0, 11.0, 12.0]] - ]); - - const size: [number, number] = [2, 2]; - const alignCorners = false; - const g = tf.grad( - (i: tf.Tensor3D) => tf.image.resizeBilinear(i, size, alignCorners)); - - const output = g(input, dy); - const expected = - [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0]; - expectArraysClose(await output.data(), expected); - }); - - it('color: same size, align corners', async () => { - const input = tf.tensor3d([ - [ - [115.11029815673828, 111.90936279296875, 66.87433624267578], - [72.03849029541016, 81.86637878417969, 119.53585815429688] - ], - [ - [68.555419921875, 97.49642181396484, 116.90741729736328], - [128.69467163085938, 86.78314208984375, 104.3116683959961] - ] - ]); - - const dy = tf.tensor3d([ - [[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]], [[7.0, 8.0, 9.0], [10.0, 11.0, 12.0]] - ]); - - const size: [number, number] = [2, 2]; - const alignCorners = true; - const g = tf.grad( - (i: tf.Tensor3D) => tf.image.resizeBilinear(i, size, alignCorners)); - - const output = g(input, dy); - const expected = - [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0]; - expectArraysClose(await output.data(), expected); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/image/resize_nearest_neighbor.ts b/tfjs-master/tfjs-core/src/ops/image/resize_nearest_neighbor.ts deleted file mode 100644 index 730e49b3c..000000000 --- a/tfjs-master/tfjs-core/src/ops/image/resize_nearest_neighbor.ts +++ /dev/null @@ -1,93 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../../engine'; -import {ResizeNearestNeighbor, ResizeNearestNeighborAttrs, ResizeNearestNeighborInputs} from '../../kernel_names'; -import {NamedAttrMap} from '../../kernel_registry'; -import {Tensor3D, Tensor4D} from '../../tensor'; -import {NamedTensorMap} from '../../tensor_types'; -import {convertToTensor} from '../../tensor_util_env'; -import {TensorLike} from '../../types'; -import * as util from '../../util'; - -import {op} from '../operation'; -import {reshape} from '../reshape'; - -/** - * NearestNeighbor resize a batch of 3D images to a new shape. - * - * @param images The images, of rank 4 or rank 3, of shape - * `[batch, height, width, inChannels]`. If rank 3, batch of 1 is assumed. - * @param size The new shape `[newHeight, newWidth]` to resize the - * images to. Each channel is resized individually. - * @param alignCorners Defaults to False. If true, rescale - * input by `(new_height - 1) / (height - 1)`, which exactly aligns the 4 - * corners of images and resized images. If false, rescale by - * `new_height / height`. Treat similarly the width dimension. - * @param halfPixelCenters Defaults to `false`. Whether to assume pixels are of - * half the actual dimensions, and yield more accurate resizes. This flag - * would also make the floating point coordinates of the top left pixel - * 0.5, 0.5. - * - * @doc {heading: 'Operations', subheading: 'Images', namespace: 'image'} - */ -function resizeNearestNeighbor_( - images: T|TensorLike, size: [number, number], alignCorners = false, - halfPixelCenters = false): T { - const $images = convertToTensor(images, 'images', 'resizeNearestNeighbor'); - - util.assert( - $images.rank === 3 || $images.rank === 4, - () => `Error in resizeNearestNeighbor: x must be rank 3 or 4, but got ` + - `rank ${$images.rank}.`); - util.assert( - size.length === 2, - () => - `Error in resizeNearestNeighbor: new shape must 2D, but got shape ` + - `${size}.`); - util.assert( - $images.dtype === 'float32' || $images.dtype === 'int32', - () => '`images` must have `int32` or `float32` as dtype'); - util.assert( - halfPixelCenters === false || alignCorners === false, - () => `Error in resizeNearestNeighbor: If halfPixelCenters is true, ` + - `alignCorners must be false.`); - let batchImages = $images as Tensor4D; - let reshapedTo4D = false; - if ($images.rank === 3) { - reshapedTo4D = true; - batchImages = reshape( - $images, [1, $images.shape[0], $images.shape[1], $images.shape[2]]); - } - const [] = size; - - const inputs: ResizeNearestNeighborInputs = {images: batchImages}; - const attrs: - ResizeNearestNeighborAttrs = {alignCorners, halfPixelCenters, size}; - - // tslint:disable-next-line: no-unnecessary-type-assertion - const res = ENGINE.runKernel( - ResizeNearestNeighbor, inputs as unknown as NamedTensorMap, - attrs as unknown as NamedAttrMap) as T; - - if (reshapedTo4D) { - return reshape(res, [res.shape[1], res.shape[2], res.shape[3]]) as T; - } - return res; -} - -export const resizeNearestNeighbor = /* @__PURE__ */ op({resizeNearestNeighbor_}); diff --git a/tfjs-master/tfjs-core/src/ops/image/resize_nearest_neighbor_test.ts b/tfjs-master/tfjs-core/src/ops/image/resize_nearest_neighbor_test.ts deleted file mode 100644 index 8bbeb72cf..000000000 --- a/tfjs-master/tfjs-core/src/ops/image/resize_nearest_neighbor_test.ts +++ /dev/null @@ -1,734 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../../index'; -import {ALL_ENVS, describeWithFlags} from '../../jasmine_util'; -import {expectArraysClose} from '../../test_util'; - -describeWithFlags('resizeNearestNeighbor', ALL_ENVS, () => { - it('simple alignCorners=false', async () => { - const input = tf.tensor3d([2, 2, 4, 4], [2, 2, 1]); - const output = input.resizeNearestNeighbor([3, 3], false); - - expectArraysClose(await output.data(), [2, 2, 2, 2, 2, 2, 4, 4, 4]); - }); - - it('simple alignCorners=true', async () => { - const input = tf.tensor3d([2, 2, 4, 4], [2, 2, 1]); - const output = input.resizeNearestNeighbor([3, 3], true); - - expectArraysClose(await output.data(), [2, 2, 2, 4, 4, 4, 4, 4, 4]); - }); - - it('5x2To2x2 alignCorners=false halfPixelCenters=true', async () => { - const input = tf.tensor4d([1, 2, 3, 4, 5, 1, 2, 3, 4, 5], [1, 2, 5, 1]); - const output = input.resizeNearestNeighbor([2, 2], false, true); - - expectArraysClose(await output.data(), [2, 4, 2, 4]); - }); - - it('2x2To1x1 alignCorners=false halfPixelCenters=true', async () => { - const input = tf.tensor4d([1, 2, 3, 4], [1, 2, 2, 1]); - const output = input.resizeNearestNeighbor([1, 1], false, true); - - expectArraysClose(await output.data(), [4]); - }); - - it('2x2To3x3 alignCorners=false halfPixelCenters=true', async () => { - const input = tf.tensor4d([1, 2, 3, 4], [1, 2, 2, 1]); - const output = input.resizeNearestNeighbor([3, 3], false, true); - - expectArraysClose(await output.data(), [1, 2, 2, 3, 4, 4, 3, 4, 4]); - }); - - it('3x3To2x2 alignCorners=false halfPixelCenters=true', async () => { - const input = tf.tensor4d([1, 2, 3, 4, 5, 6, 7, 8, 9], [1, 3, 3, 1]); - const output = input.resizeNearestNeighbor([2, 2], false, true); - - expectArraysClose(await output.data(), [1, 3, 7, 9]); - }); - - it('2x2To2x5 alignCorners=false halfPixelCenters=true', async () => { - const input = tf.tensor4d([1, 2, 3, 4], [1, 2, 2, 1]); - const output = input.resizeNearestNeighbor([2, 5], false, true); - - expectArraysClose(await output.data(), [1, 1, 2, 2, 2, 3, 3, 4, 4, 4]); - }); - - it('4x4To3x3 alignCorners=false halfPixelCenters=true', async () => { - const input = tf.tensor4d( - [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], [1, 4, 4, 1]); - const output = input.resizeNearestNeighbor([3, 3], false, true); - - expectArraysClose(await output.data(), [1, 3, 4, 9, 11, 12, 13, 15, 16]); - }); - - it('2x2To5x2 alignCorners=false halfPixelCenters=true', async () => { - const input = tf.tensor4d([1, 2, 3, 4], [1, 2, 2, 1]); - const output = input.resizeNearestNeighbor([5, 2], false, true); - - expectArraysClose(await output.data(), [1, 2, 1, 2, 3, 4, 3, 4, 3, 4]); - }); - - it('2x2To4x4 alignCorners=false halfPixelCenters=true', async () => { - const input = tf.tensor4d([1, 2, 3, 4], [1, 2, 2, 1]); - const output = input.resizeNearestNeighbor([4, 4], false, true); - - expectArraysClose( - await output.data(), [1, 1, 2, 2, 1, 1, 2, 2, 3, 3, 4, 4, 3, 3, 4, 4]); - }); - - it('matches tensorflow w/ random numbers alignCorners=false', async () => { - const input = tf.tensor3d( - [ - 1.19074044, 0.91373104, 2.01611669, -0.52270832, 0.38725395, - 1.30809779, 0.61835143, 3.49600659, 2.09230986, 0.56473997, - 0.03823943, 1.19864896 - ], - [2, 3, 2]); - const output = input.resizeNearestNeighbor([4, 5], false); - - expectArraysClose(await output.data(), [ - 1.19074047, 0.913731039, 1.19074047, 0.913731039, 2.01611662, - -0.522708297, 2.01611662, -0.522708297, 0.38725394, 1.30809784, - 1.19074047, 0.913731039, 1.19074047, 0.913731039, 2.01611662, - -0.522708297, 2.01611662, -0.522708297, 0.38725394, 1.30809784, - 0.61835146, 3.49600649, 0.61835146, 3.49600649, 2.09230995, - 0.564739943, 2.09230995, 0.564739943, 0.0382394306, 1.19864893, - 0.61835146, 3.49600649, 0.61835146, 3.49600649, 2.09230995, - 0.564739943, 2.09230995, 0.564739943, 0.0382394306, 1.19864893 - ]); - }); - - it('matches tensorflow w/ random numbers alignCorners=true', async () => { - const input = tf.tensor3d( - [ - 1.19074044, 0.91373104, 2.01611669, -0.52270832, 0.38725395, - 1.30809779, 0.61835143, 3.49600659, 2.09230986, 0.56473997, - 0.03823943, 1.19864896 - ], - [2, 3, 2]); - const output = input.resizeNearestNeighbor([4, 5], true); - - expectArraysClose(await output.data(), [ - 1.19074044, 0.91373104, 2.01611669, -0.52270832, 2.01611669, -0.52270832, - 0.38725395, 1.30809779, 0.38725395, 1.30809779, 1.19074044, 0.91373104, - 2.01611669, -0.52270832, 2.01611669, -0.52270832, 0.38725395, 1.30809779, - 0.38725395, 1.30809779, 0.61835143, 3.49600659, 2.09230986, 0.56473997, - 2.09230986, 0.56473997, 0.03823943, 1.19864896, 0.03823943, 1.19864896, - 0.61835143, 3.49600659, 2.09230986, 0.56473997, 2.09230986, 0.56473997, - 0.03823943, 1.19864896, 0.03823943, 1.19864896 - ]); - }); - - it('batch of 2, simple, alignCorners=true', async () => { - const input = tf.tensor4d([2, 2, 4, 4, 3, 3, 5, 5], [2, 2, 2, 1]); - const output = input.resizeNearestNeighbor([3, 3], true /* alignCorners */); - - expectArraysClose( - await output.data(), - [2, 2, 2, 4, 4, 4, 4, 4, 4, 3, 3, 3, 5, 5, 5, 5, 5, 5]); - }); - - it('throws when passed a non-tensor', () => { - const e = - /Argument 'images' passed to 'resizeNearestNeighbor' must be a Tensor/; - expect(() => tf.image.resizeNearestNeighbor({} as tf.Tensor3D, [ - 1, 1 - ])).toThrowError(e); - }); - - it('accepts a tensor-like object', async () => { - const input = [[[2], [2]], [[4], [4]]]; // 2x2x1 - const output = tf.image.resizeNearestNeighbor(input, [3, 3], false); - - expectArraysClose(await output.data(), [2, 2, 2, 2, 2, 2, 4, 4, 4]); - }); - - it('does not throw when some output dim is 1 and alignCorners=true', () => { - const input = tf.tensor3d([2, 2, 4, 4], [2, 2, 1]); - expect(() => input.resizeNearestNeighbor([1, 3], true)).not.toThrow(); - }); -}); - -describeWithFlags('resizeNearestNeighbor gradients', ALL_ENVS, () => { - it('greyscale: upscale, same aspect ratio', async () => { - const input = tf.tensor3d([[[100.0], [50.0]], [[60.0], [20.0]]]); - const dy = tf.tensor3d([ - [[1.0], [2.0], [3.0], [4.0]], [[5.0], [6.0], [7.0], [8.0]], - [[9.0], [10.0], [11.0], [12.0]], [[13.0], [14.0], [15.0], [16.0]] - ]); - - const size: [number, number] = [4, 4]; - const alignCorners = false; - const g = tf.grad( - (i: tf.Tensor3D) => - tf.image.resizeNearestNeighbor(i, size, alignCorners)); - - const output = g(input, dy); - const expected = tf.tensor3d([[[14.0], [22.0]], [[46.0], [54.0]]]); - - expectArraysClose(await output.data(), await expected.data()); - expect(output.shape).toEqual(expected.shape); - expect(output.dtype).toBe(expected.dtype); - }); - - it('with clones, greyscale: upscale, same aspect ratio', async () => { - const input = tf.tensor3d([[[100.0], [50.0]], [[60.0], [20.0]]]); - const dy = tf.tensor3d([ - [[1.0], [2.0], [3.0], [4.0]], [[5.0], [6.0], [7.0], [8.0]], - [[9.0], [10.0], [11.0], [12.0]], [[13.0], [14.0], [15.0], [16.0]] - ]); - - const size: [number, number] = [4, 4]; - const alignCorners = false; - const g = tf.grad( - (i: tf.Tensor3D) => - tf.image.resizeNearestNeighbor(i.clone(), size, alignCorners) - .clone()); - - const output = g(input, dy); - const expected = tf.tensor3d([[[14.0], [22.0]], [[46.0], [54.0]]]); - - expectArraysClose(await output.data(), await expected.data()); - expect(output.shape).toEqual(expected.shape); - expect(output.dtype).toBe(expected.dtype); - }); - - it('greyscale: upscale, same aspect ratio, align corners', async () => { - const input = tf.tensor3d([[[100.0], [50.0]], [[60.0], [20.0]]]); - const dy = tf.tensor3d([ - [[1.0], [2.0], [3.0], [4.0]], [[5.0], [6.0], [7.0], [8.0]], - [[9.0], [10.0], [11.0], [12.0]], [[13.0], [14.0], [15.0], [16.0]] - ]); - - const size: [number, number] = [4, 4]; - const alignCorners = true; - const g = tf.grad( - (i: tf.Tensor3D) => - tf.image.resizeNearestNeighbor(i, size, alignCorners)); - - const output = g(input, dy); - const expected = tf.tensor3d([[[14.0], [22.0]], [[46.0], [54.0]]]); - - expectArraysClose(await output.data(), await expected.data()); - expect(output.shape).toEqual(expected.shape); - expect(output.dtype).toBe(expected.dtype); - }); - - it('greyscale: upscale, taller than wider', async () => { - const input = tf.tensor3d([[[100.0], [50.0]], [[60.0], [20.0]]]); - const dy = tf.tensor3d([ - [[1.0], [2.0], [3.0], [4.0]], [[5.0], [6.0], [7.0], [8.0]], - [[9.0], [10.0], [11.0], [12.0]], [[13.0], [14.0], [15.0], [16.0]], - [[17.0], [18.0], [19.0], [20.0]], [[21.0], [22.0], [23.0], [24.0]], - [[25.0], [26.0], [27.0], [28.0]], [[29.0], [30.0], [31.0], [32.0]], - [[33.0], [34.0], [35.0], [36.0]] - ]); - - const size: [number, number] = [9, 4]; - const alignCorners = false; - const g = tf.grad( - (i: tf.Tensor3D) => - tf.image.resizeNearestNeighbor(i, size, alignCorners)); - - const output = g(input, dy); - const expected = tf.tensor3d([[[95.0], [115.0]], [[220.0], [236.0]]]); - - expectArraysClose(await output.data(), await expected.data()); - expect(output.shape).toEqual(expected.shape); - expect(output.dtype).toBe(expected.dtype); - }); - - it('greyscale: upscale, taller than wider, align corners', async () => { - const input = tf.tensor3d([[[100.0], [50.0]], [[60.0], [20.0]]]); - const dy = tf.tensor3d([ - [[1.0], [2.0], [3.0], [4.0]], [[5.0], [6.0], [7.0], [8.0]], - [[9.0], [10.0], [11.0], [12.0]], [[13.0], [14.0], [15.0], [16.0]], - [[17.0], [18.0], [19.0], [20.0]], [[21.0], [22.0], [23.0], [24.0]], - [[25.0], [26.0], [27.0], [28.0]], [[29.0], [30.0], [31.0], [32.0]], - [[33.0], [34.0], [35.0], [36.0]] - ]); - - const size: [number, number] = [9, 4]; - const alignCorners = true; - const g = tf.grad( - (i: tf.Tensor3D) => - tf.image.resizeNearestNeighbor(i, size, alignCorners)); - - const output = g(input, dy); - const expected = tf.tensor3d([[[60.0], [76.0]], [[255.0], [275.0]]]); - - expectArraysClose(await output.data(), await expected.data()); - expect(output.shape).toEqual(expected.shape); - expect(output.dtype).toBe(expected.dtype); - }); - - it('greyscale: upscale, wider than taller', async () => { - const input = tf.tensor3d([[[100.0], [50.0]], [[60.0], [20.0]]]); - const dy = tf.tensor3d([ - [[1.0], [2.0], [3.0], [4.0], [5.0], [6.0], [7.0]], - [[8.0], [9.0], [10.0], [11.0], [12.0], [13.0], [14.0]], - [[15.0], [16.0], [17.0], [18.0], [19.0], [20.0], [21.0]], - [[22.0], [23.0], [24.0], [25.0], [26.0], [27.0], [28.0]] - ]); - - const size: [number, number] = [4, 7]; - const alignCorners = false; - const g = tf.grad( - (i: tf.Tensor3D) => - tf.image.resizeNearestNeighbor(i, size, alignCorners)); - - const output = g(input, dy); - const expected = tf.tensor3d([[[48.0], [57.0]], [[160.0], [141.0]]]); - - expectArraysClose(await output.data(), await expected.data()); - expect(output.shape).toEqual(expected.shape); - expect(output.dtype).toBe(expected.dtype); - }); - - it('greyscale: upscale, wider than taller, align corners', async () => { - const input = tf.tensor3d([[[100.0], [50.0]], [[60.0], [20.0]]]); - const dy = tf.tensor3d([ - [[1.0], [2.0], [3.0], [4.0], [5.0], [6.0], [7.0]], - [[8.0], [9.0], [10.0], [11.0], [12.0], [13.0], [14.0]], - [[15.0], [16.0], [17.0], [18.0], [19.0], [20.0], [21.0]], - [[22.0], [23.0], [24.0], [25.0], [26.0], [27.0], [28.0]] - ]); - - const size: [number, number] = [4, 7]; - const alignCorners = true; - const g = tf.grad( - (i: tf.Tensor3D) => - tf.image.resizeNearestNeighbor(i, size, alignCorners)); - - const output = g(input, dy); - const expected = tf.tensor3d([[[33.0], [72.0]], [[117.0], [184.0]]]); - - expectArraysClose(await output.data(), await expected.data()); - expect(output.shape).toEqual(expected.shape); - expect(output.dtype).toBe(expected.dtype); - }); - - // - // Downscaling - // - - it('greyscale: downscale, same aspect ratio', async () => { - const input = tf.tensor3d([ - [[100.0], [50.0], [25.0], [10.0]], [[60.0], [20.0], [80.0], [20.0]], - [[40.0], [15.0], [200.0], [203.0]], [[40.0], [10.0], [230.0], [200.0]] - ]); - const dy = tf.tensor3d([[[1.0], [2.0]], [[3.0], [4.0]]]); - - const size: [number, number] = [2, 2]; - const alignCorners = false; - const g = tf.grad( - (i: tf.Tensor3D) => - tf.image.resizeNearestNeighbor(i, size, alignCorners)); - - const output = g(input, dy); - const expected = tf.tensor3d([ - [[1.0], [0.0], [2.0], [0.0]], [[0.0], [0.0], [0.0], [0.0]], - [[3.0], [0.0], [4.0], [0.0]], [[0.0], [0.0], [0.0], [0.0]] - ]); - - expectArraysClose(await output.data(), await expected.data()); - expect(output.shape).toEqual(expected.shape); - expect(output.dtype).toBe(expected.dtype); - }); - - it('greyscale: downscale, same aspect ratio, align corners', async () => { - const input = tf.tensor3d([ - [[100.0], [50.0], [25.0], [10.0]], [[60.0], [20.0], [80.0], [20.0]], - [[40.0], [15.0], [200.0], [203.0]], [[40.0], [10.0], [230.0], [200.0]] - ]); - const dy = tf.tensor3d([[[1.0], [2.0]], [[3.0], [4.0]]]); - - const size: [number, number] = [2, 2]; - const alignCorners = true; - const g = tf.grad( - (i: tf.Tensor3D) => - tf.image.resizeNearestNeighbor(i, size, alignCorners)); - - const output = g(input, dy); - const expected = tf.tensor3d([ - [[1.0], [0.0], [0.0], [2.0]], [[0.0], [0.0], [0.0], [0.0]], - [[0.0], [0.0], [0.0], [0.0]], [[3.0], [0.0], [0.0], [4.0]] - ]); - - expectArraysClose(await output.data(), await expected.data()); - expect(output.shape).toEqual(expected.shape); - expect(output.dtype).toBe(expected.dtype); - }); - - it('greyscale: downscale, taller than wider', async () => { - const input = tf.tensor3d([ - [[100.0], [50.0], [25.0], [10.0]], [[60.0], [20.0], [80.0], [20.0]], - [[40.0], [15.0], [200.0], [203.0]], [[40.0], [10.0], [230.0], [200.0]] - ]); - const dy = tf.tensor3d([[[1.0], [2.0]], [[3.0], [4.0]], [[5.0], [6.0]]]); - - const size: [number, number] = [3, 2]; - const alignCorners = false; - const g = tf.grad( - (i: tf.Tensor3D) => - tf.image.resizeNearestNeighbor(i, size, alignCorners)); - - const output = g(input, dy); - const expected = tf.tensor3d([ - [[1.0], [0.0], [2.0], [0.0]], [[3.0], [0.0], [4.0], [0.0]], - [[5.0], [0.0], [6.0], [0.0]], [[0.0], [0.0], [0.0], [0.0]] - ]); - - expectArraysClose(await output.data(), await expected.data()); - expect(output.shape).toEqual(expected.shape); - expect(output.dtype).toBe(expected.dtype); - }); - - it('greyscale: downscale, taller than wider, align corners', async () => { - const input = tf.tensor3d([ - [[100.0], [50.0], [25.0], [10.0]], [[60.0], [20.0], [80.0], [20.0]], - [[40.0], [15.0], [200.0], [203.0]], [[40.0], [10.0], [230.0], [200.0]] - ]); - const dy = tf.tensor3d([[[1.0], [2.0]], [[3.0], [4.0]], [[5.0], [6.0]]]); - - const size: [number, number] = [3, 2]; - const alignCorners = true; - const g = tf.grad( - (i: tf.Tensor3D) => - tf.image.resizeNearestNeighbor(i, size, alignCorners)); - - const output = g(input, dy); - const expected = tf.tensor3d([ - [[1.0], [0.0], [0.0], [2.0]], [[0.0], [0.0], [0.0], [0.0]], - [[3.0], [0.0], [0.0], [4.0]], [[5.0], [0.0], [0.0], [6.0]] - ]); - - expectArraysClose(await output.data(), await expected.data()); - expect(output.shape).toEqual(expected.shape); - expect(output.dtype).toBe(expected.dtype); - }); - - it('greyscale: downscale, taller than wider', async () => { - const input = tf.tensor3d([ - [[100.0], [50.0], [25.0], [10.0]], [[60.0], [20.0], [80.0], [20.0]], - [[40.0], [15.0], [200.0], [203.0]], [[40.0], [10.0], [230.0], [200.0]] - ]); - const dy = tf.tensor3d([[[1.0], [2.0], [3.0]], [[4.0], [5.0], [6.0]]]); - - const size: [number, number] = [2, 3]; - const alignCorners = false; - const g = tf.grad( - (i: tf.Tensor3D) => - tf.image.resizeNearestNeighbor(i, size, alignCorners)); - - const output = g(input, dy); - const expected = tf.tensor3d([ - [[1.0], [2.0], [3.0], [0.0]], [[0.0], [0.0], [0.0], [0.0]], - [[4.0], [5.0], [6.0], [0.0]], [[0.0], [0.0], [0.0], [0.0]] - ]); - - expectArraysClose(await output.data(), await expected.data()); - expect(output.shape).toEqual(expected.shape); - expect(output.dtype).toBe(expected.dtype); - }); - - it('greyscale: downscale, taller than wider, align corners', async () => { - const input = tf.tensor3d([ - [[100.0], [50.0], [25.0], [10.0]], [[60.0], [20.0], [80.0], [20.0]], - [[40.0], [15.0], [200.0], [203.0]], [[40.0], [10.0], [230.0], [200.0]] - ]); - const dy = tf.tensor3d([[[1.0], [2.0], [3.0]], [[4.0], [5.0], [6.0]]]); - - const size: [number, number] = [2, 3]; - const alignCorners = true; - const g = tf.grad( - (i: tf.Tensor3D) => - tf.image.resizeNearestNeighbor(i, size, alignCorners)); - - const output = g(input, dy); - const expected = tf.tensor3d([ - [[1.0], [0.0], [2.0], [3.0]], [[0.0], [0.0], [0.0], [0.0]], - [[0.0], [0.0], [0.0], [0.0]], [[4.0], [0.0], [5.0], [6.0]] - ]); - - expectArraysClose(await output.data(), await expected.data()); - expect(output.shape).toEqual(expected.shape); - expect(output.dtype).toBe(expected.dtype); - }); - - it('greyscale: downscale, same size', async () => { - const input = tf.tensor3d([[[100.0], [50.0]], [[60.0], [20.0]]]); - const dy = tf.tensor3d([[[1.0], [2.0]], [[3.0], [4.0]]]); - - const size: [number, number] = [2, 2]; - const alignCorners = false; - const g = tf.grad( - (i: tf.Tensor3D) => - tf.image.resizeNearestNeighbor(i, size, alignCorners)); - - const output = g(input, dy); - const expected = tf.tensor3d([[[1.0], [2.0]], [[3.0], [4.0]]]); - - expectArraysClose(await output.data(), await expected.data()); - expect(output.shape).toEqual(expected.shape); - expect(output.dtype).toBe(expected.dtype); - }); - - it('greyscale: downscale, same size, align corners', async () => { - const input = tf.tensor3d([[[100.0], [50.0]], [[60.0], [20.0]]]); - const dy = tf.tensor3d([[[1.0], [2.0]], [[3.0], [4.0]]]); - - const size: [number, number] = [2, 2]; - const alignCorners = true; - const g = tf.grad( - (i: tf.Tensor3D) => - tf.image.resizeNearestNeighbor(i, size, alignCorners)); - - const output = g(input, dy); - const expected = tf.tensor3d([[[1.0], [2.0]], [[3.0], [4.0]]]); - - expectArraysClose(await output.data(), await expected.data()); - expect(output.shape).toEqual(expected.shape); - expect(output.dtype).toBe(expected.dtype); - }); - - // - // 3 channel images - // - - it('color: upscale, wider than taller', async () => { - const input = tf.tensor3d([ - [ - [100.26818084716797, 74.61857604980469, 81.62117767333984], - [127.86964416503906, 85.0583267211914, 102.95439147949219] - ], - [ - [104.3798828125, 96.70733642578125, 92.60601043701172], - [77.63021850585938, 68.55794525146484, 96.17212677001953] - ] - ]); - - const dy = tf.tensor3d([ - [ - [1.0, 2.0, 3.0], [4.0, 5.0, 6.0], [7.0, 8.0, 9.0], [10.0, 11.0, 12.0], - [13.0, 14.0, 15.0] - ], - [ - [16.0, 17.0, 18.0], [19.0, 20.0, 21.0], [22.0, 23.0, 24.0], - [25.0, 26.0, 27.0], [28.0, 29.0, 30.0] - ], - [ - [31.0, 32.0, 33.0], [34.0, 35.0, 36.0], [37.0, 38.0, 39.0], - [40.0, 41.0, 42.0], [43.0, 44.0, 45.0] - ] - ]); - - const size: [number, number] = [3, 5]; - const alignCorners = false; - const g = tf.grad( - (i: tf.Tensor3D) => - tf.image.resizeNearestNeighbor(i, size, alignCorners)); - - const output = g(input, dy); - const expected = tf.tensor3d([ - [[69.0, 75.0, 81.0], [76.0, 80.0, 84.0]], - [[102.0, 105.0, 108.0], [83.0, 85.0, 87.0]] - ]); - - expectArraysClose(await output.data(), await expected.data()); - expect(output.shape).toEqual(expected.shape); - expect(output.dtype).toBe(expected.dtype); - }); - - it('color: upscale, wider than taller, align corners', async () => { - const input = tf.tensor3d([ - [ - [100.26818084716797, 74.61857604980469, 81.62117767333984], - [127.86964416503906, 85.0583267211914, 102.95439147949219] - ], - [ - [104.3798828125, 96.70733642578125, 92.60601043701172], - [77.63021850585938, 68.55794525146484, 96.17212677001953] - ] - ]); - - const dy = tf.tensor3d([ - [ - [1.0, 2.0, 3.0], [4.0, 5.0, 6.0], [7.0, 8.0, 9.0], [10.0, 11.0, 12.0], - [13.0, 14.0, 15.0] - ], - [ - [16.0, 17.0, 18.0], [19.0, 20.0, 21.0], [22.0, 23.0, 24.0], - [25.0, 26.0, 27.0], [28.0, 29.0, 30.0] - ], - [ - [31.0, 32.0, 33.0], [34.0, 35.0, 36.0], [37.0, 38.0, 39.0], - [40.0, 41.0, 42.0], [43.0, 44.0, 45.0] - ] - ]); - - const size: [number, number] = [3, 5]; - const alignCorners = true; - const g = tf.grad( - (i: tf.Tensor3D) => - tf.image.resizeNearestNeighbor(i, size, alignCorners)); - - const output = g(input, dy); - const expected = tf.tensor3d([ - [[5.0, 7.0, 9.0], [30.0, 33.0, 36.0]], - [[100.0, 104.0, 108.0], [195.0, 201.0, 207.0]] - ]); - - expectArraysClose(await output.data(), await expected.data()); - expect(output.shape).toEqual(expected.shape); - expect(output.dtype).toBe(expected.dtype); - }); - - it('color: downscale, taller than wider', async () => { - const input = tf.tensor3d([ - [ - [97.98934936523438, 77.24969482421875, 113.70111846923828], - [111.34081268310547, 113.15758514404297, 157.90521240234375], - [105.77980041503906, 85.75989532470703, 69.62374114990234], - [125.94231414794922, 73.11385345458984, 87.03099822998047] - ], - [ - [62.25117111206055, 90.23927307128906, 119.1966552734375], - [93.55166625976562, 95.9106674194336, 115.56237030029297], - [102.98121643066406, 98.1983413696289, 97.55982971191406], - [86.47753143310547, 97.04051208496094, 121.50492095947266] - ], - [ - [92.4140853881836, 118.45619201660156, 108.0341796875], - [126.43061065673828, 123.28077697753906, 121.03379821777344], - [128.6694793701172, 98.47042846679688, 114.47464752197266], - [93.31566619873047, 95.2713623046875, 102.51188659667969] - ], - [ - [101.55884552001953, 83.31947326660156, 119.08016204833984], - [128.28546142578125, 92.56212615966797, 74.85054779052734], - [88.9786148071289, 119.43685913085938, 73.06110382080078], - [98.17908477783203, 105.54570007324219, 93.45832061767578] - ] - ]); - - const dy = - tf.tensor3d([[[1.0, 2.0, 3.0]], [[4.0, 5.0, 6.0]], [[7.0, 8.0, 9.0]]]); - - const size: [number, number] = [3, 1]; - const alignCorners = false; - const g = tf.grad( - (i: tf.Tensor3D) => - tf.image.resizeNearestNeighbor(i, size, alignCorners)); - - const output = g(input, dy); - const expected = tf.tensor3d([ - [[1.0, 2.0, 3.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0]], - [[4.0, 5.0, 6.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0]], - [[7.0, 8.0, 9.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0]], - [[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0]] - ]); - - expectArraysClose(await output.data(), await expected.data()); - expect(output.shape).toEqual(expected.shape); - expect(output.dtype).toBe(expected.dtype); - }); - - it('color: downscale, taller than wider, align corners', async () => { - const input = tf.tensor3d([ - [ - [97.98934936523438, 77.24969482421875, 113.70111846923828], - [111.34081268310547, 113.15758514404297, 157.90521240234375], - [105.77980041503906, 85.75989532470703, 69.62374114990234], - [125.94231414794922, 73.11385345458984, 87.03099822998047] - ], - [ - [62.25117111206055, 90.23927307128906, 119.1966552734375], - [93.55166625976562, 95.9106674194336, 115.56237030029297], - [102.98121643066406, 98.1983413696289, 97.55982971191406], - [86.47753143310547, 97.04051208496094, 121.50492095947266] - ], - [ - [92.4140853881836, 118.45619201660156, 108.0341796875], - [126.43061065673828, 123.28077697753906, 121.03379821777344], - [128.6694793701172, 98.47042846679688, 114.47464752197266], - [93.31566619873047, 95.2713623046875, 102.51188659667969] - ], - [ - [101.55884552001953, 83.31947326660156, 119.08016204833984], - [128.28546142578125, 92.56212615966797, 74.85054779052734], - [88.9786148071289, 119.43685913085938, 73.06110382080078], - [98.17908477783203, 105.54570007324219, 93.45832061767578] - ] - ]); - - const dy = - tf.tensor3d([[[1.0, 2.0, 3.0]], [[4.0, 5.0, 6.0]], [[7.0, 8.0, 9.0]]]); - - const size: [number, number] = [3, 1]; - const alignCorners = true; - const g = tf.grad( - (i: tf.Tensor3D) => - tf.image.resizeNearestNeighbor(i, size, alignCorners)); - - const output = g(input, dy); - const expected = tf.tensor3d([ - [[1.0, 2.0, 3.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0]], - [[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0]], - [[4.0, 5.0, 6.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0]], - [[7.0, 8.0, 9.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0]] - ]); - - expectArraysClose(await output.data(), await expected.data()); - expect(output.shape).toEqual(expected.shape); - expect(output.dtype).toBe(expected.dtype); - }); - - it('color: same size', async () => { - const input = tf.tensor3d([ - [ - [100.26818084716797, 74.61857604980469, 81.62117767333984], - [127.86964416503906, 85.0583267211914, 102.95439147949219] - ], - [ - [104.3798828125, 96.70733642578125, 92.60601043701172], - [77.63021850585938, 68.55794525146484, 96.17212677001953] - ] - ]); - - const dy = tf.tensor3d([ - [[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]], [[7.0, 8.0, 9.0], [10.0, 11.0, 12.0]] - ]); - - const size: [number, number] = [2, 2]; - const alignCorners = false; - const g = tf.grad( - (i: tf.Tensor3D) => - tf.image.resizeNearestNeighbor(i, size, alignCorners)); - - const output = g(input, dy); - const expected = tf.tensor3d([ - [[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]], [[7.0, 8.0, 9.0], [10.0, 11.0, 12.0]] - ]); - - expectArraysClose(await output.data(), await expected.data()); - expect(output.shape).toEqual(expected.shape); - expect(output.dtype).toBe(expected.dtype); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/image/rgb_to_grayscale.ts b/tfjs-master/tfjs-core/src/ops/image/rgb_to_grayscale.ts deleted file mode 100644 index 43a3cda96..000000000 --- a/tfjs-master/tfjs-core/src/ops/image/rgb_to_grayscale.ts +++ /dev/null @@ -1,84 +0,0 @@ -/** - * @license - * Copyright 2023 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Tensor2D, Tensor3D, Tensor4D, Tensor5D, Tensor6D} from '../../tensor'; -import {convertToTensor} from '../../tensor_util_env'; -import {TensorLike} from '../../types'; -import * as util from '../../util'; -import {cast} from '../cast'; -import {einsum} from '../einsum'; -import {expandDims} from '../expand_dims'; -import {op} from '../operation'; -import {tensor1d} from '../tensor1d'; - -/** - * Converts images from RGB format to grayscale. - * - * @param image A RGB tensor to convert. The `image`'s last dimension must - * be size 3 with at least a two-dimensional shape. - * - * @doc {heading: 'Operations', subheading: 'Images', namespace: 'image'} - */ -function rgbToGrayscale_(image: T|TensorLike): T { - const $image = convertToTensor(image, 'image', 'RGBToGrayscale'); - - const lastDimsIdx = $image.rank - 1; - const lastDims = $image.shape[lastDimsIdx]; - - util.assert( - $image.rank >= 2, - () => 'Error in RGBToGrayscale: images must be at least rank 2, ' + - `but got rank ${$image.rank}.`); - - util.assert( - lastDims === 3, - () => 'Error in RGBToGrayscale: last dimension of an RGB image ' + - `should be size 3, but got size ${lastDims}.`); - - // Remember original dtype so we can convert back if needed - const origDtype = $image.dtype; - const fltImage = cast($image, 'float32'); - - const rgbWeights = tensor1d([0.2989, 0.5870, 0.1140]); - - let grayFloat; - switch ($image.rank) { - case 2: - grayFloat = einsum('ij,j->i', fltImage, rgbWeights); - break; - case 3: - grayFloat = einsum('ijk,k->ij', fltImage, rgbWeights); - break; - case 4: - grayFloat = einsum('ijkl,l->ijk', fltImage, rgbWeights); - break; - case 5: - grayFloat = einsum('ijklm,m->ijkl', fltImage, rgbWeights); - break; - case 6: - grayFloat = einsum('ijklmn,n->ijklm', fltImage, rgbWeights); - break; - default: - throw new Error('Not a valid tensor rank.'); - } - grayFloat = expandDims(grayFloat, -1); - - return cast(grayFloat, origDtype) as T; -} - -export const rgbToGrayscale = /* @__PURE__ */ op({rgbToGrayscale_}); diff --git a/tfjs-master/tfjs-core/src/ops/image/rgb_to_grayscale_test.ts b/tfjs-master/tfjs-core/src/ops/image/rgb_to_grayscale_test.ts deleted file mode 100644 index bbeb37cbc..000000000 --- a/tfjs-master/tfjs-core/src/ops/image/rgb_to_grayscale_test.ts +++ /dev/null @@ -1,69 +0,0 @@ -/** - * @license - * Copyright 2023 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import * as tf from '../../index'; -import {ALL_ENVS, describeWithFlags} from '../../jasmine_util'; -import {expectArraysClose} from '../../test_util'; -import {Tensor2D} from '../../tensor'; - -describeWithFlags('RGBToGrayscale', ALL_ENVS, () => { - it('should return int32 dtype tensor for int32 dtype input', async () => { - const rgb = tf.tensor2d([16,24,56,1,2,9], [2,3], 'int32'); - const grayscale = tf.image.rgbToGrayscale(rgb); - - const expected = [[25],[2]]; - const grayscaleData = await grayscale.data(); - - expect(grayscale.shape).toEqual([2,1]); - expectArraysClose(grayscaleData, expected); - }); - - it('basic 3 rank array conversion', async () => { - const rgb = [[[1.0, 2.0, 3.0]]]; - const grayscale = tf.image.rgbToGrayscale(rgb); - - const expected = [[[1.8149]]]; - const grayscaleData = await grayscale.data(); - - expect(grayscale.shape).toEqual([1, 1, 1]); - expectArraysClose(grayscaleData, expected); - }); - - it('basic 4 rank array conversion', async () => { - const rgb = [[[[1.0, 2.0, 3.0], [2.0, 3.0, 4.0]]]]; - const grayscale = tf.image.rgbToGrayscale(rgb); - - const expected = [[[[1.8149],[2.8148]]]]; - const grayscaleData = await grayscale.data(); - - expect(grayscale.shape).toEqual([1, 1, 2, 1]); - expectArraysClose(grayscaleData, expected); - }); - - it('should throw an error because of input last dim is not 3', () => { - const grayscale = tf.tensor4d([1.0, 1.0, 2.0, 2.0, 3.0, 3.0], [1, 1, 3, 2]); - - expect(() => tf.image.rgbToGrayscale(grayscale)) - .toThrowError(/last dimension of an RGB image should be size 3/); - }); - - it('should throw an error because of image\'s rank is less than 2', () => { - const grayscale = tf.tensor1d([1, 2, 3]) as unknown as Tensor2D; - - expect(() => tf.image.rgbToGrayscale(grayscale)) - .toThrowError(/images must be at least rank 2/); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/image/rotate_with_offset.ts b/tfjs-master/tfjs-core/src/ops/image/rotate_with_offset.ts deleted file mode 100644 index 71a183a9a..000000000 --- a/tfjs-master/tfjs-core/src/ops/image/rotate_with_offset.ts +++ /dev/null @@ -1,64 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../../engine'; -import {RotateWithOffset, RotateWithOffsetAttrs, RotateWithOffsetInputs} from '../../kernel_names'; -import {NamedAttrMap} from '../../kernel_registry'; -import {Tensor4D} from '../../tensor'; -import {NamedTensorMap} from '../../tensor_types'; -import {convertToTensor} from '../../tensor_util_env'; -import {TensorLike} from '../../types'; -import * as util from '../../util'; - -import {op} from '../operation'; - -/** - * Rotates the input image tensor counter-clockwise with an optional offset - * center of rotation. Currently available in the CPU, WebGL, and WASM backends. - * - * @param image 4d tensor of shape `[batch, imageHeight, imageWidth, depth]`. - * @param radians The amount of rotation. - * @param fillValue The value to fill in the empty space leftover - * after rotation. Can be either a single grayscale value (0-255), or an - * array of three numbers `[red, green, blue]` specifying the red, green, - * and blue channels. Defaults to `0` (black). - * @param center The center of rotation. Can be either a single value (0-1), or - * an array of two numbers `[centerX, centerY]`. Defaults to `0.5` (rotates - * the image around its center). - * - * @doc {heading: 'Operations', subheading: 'Images', namespace: 'image'} - */ -function rotateWithOffset_( - image: Tensor4D|TensorLike, radians: number, - fillValue: number|[number, number, number] = 0, - center: number|[number, number] = 0.5): Tensor4D { - const $image = convertToTensor(image, 'image', 'rotateWithOffset', 'float32'); - - util.assert( - $image.rank === 4, - () => 'Error in rotateWithOffset: image must be rank 4,' + - `but got rank ${$image.rank}.`); - - const inputs: RotateWithOffsetInputs = {image: $image}; - const attrs: RotateWithOffsetAttrs = {radians, fillValue, center}; - const res = ENGINE.runKernel( - RotateWithOffset, inputs as unknown as NamedTensorMap, - attrs as unknown as NamedAttrMap); - return res as Tensor4D; -} - -export const rotateWithOffset = /* @__PURE__ */ op({rotateWithOffset_}); diff --git a/tfjs-master/tfjs-core/src/ops/image/rotate_with_offset_test.ts b/tfjs-master/tfjs-core/src/ops/image/rotate_with_offset_test.ts deleted file mode 100644 index 88242004a..000000000 --- a/tfjs-master/tfjs-core/src/ops/image/rotate_with_offset_test.ts +++ /dev/null @@ -1,155 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {getTestImageAsTensor4d} from '../../image_test_util'; -import * as tf from '../../index'; -import {BROWSER_ENVS, describeWithFlags} from '../../jasmine_util'; -import {expectArraysClose} from '../../test_util'; - -describeWithFlags('rotateWithOffset', BROWSER_ENVS, () => { - it('should rotate counterclockwise 90 degrees', async () => { - const rotatedPixels = - tf.image.rotateWithOffset(getTestImageAsTensor4d(), 90 * Math.PI / 180) - .toInt(); - const rotatedPixelsData = await rotatedPixels.data(); - - const expected = [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 230, 133, 18, 255, 233, 148, 31, 255, 222, 164, 41, 255, 191, - 170, 61, 255, 135, 166, 86, 255, 71, 143, 97, 255, 15, 115, 105, 255, - 0, 102, 113, 255, 241, 153, 43, 255, 250, 177, 64, 255, 247, 201, 81, - 255, 218, 210, 103, 255, 162, 206, 127, 255, 98, 181, 135, 255, 39, 150, - 141, 255, 6, 133, 140, 255, 224, 156, 55, 255, 241, 188, 82, 255, 243, - 220, 106, 255, 213, 230, 126, 255, 155, 226, 146, 255, 94, 206, 156, 255, - 37, 177, 164, 255, 3, 158, 162, 255, 212, 157, 75, 255, 230, 193, 104, - 255, 235, 227, 128, 255, 201, 236, 142, 255, 141, 232, 162, 255, 87, 220, - 175, 255, 35, 200, 186, 255, 4, 182, 186, 255, 200, 155, 98, 255, 220, - 190, 128, 255, 225, 228, 151, 255, 191, 239, 165, 255, 130, 235, 179, 255, - 76, 225, 193, 255, 30, 209, 205, 255, 0, 194, 204, 255, 183, 138, 109, - 255, 202, 174, 137, 255, 211, 216, 162, 255, 184, 234, 181, 255, 121, 231, - 192, 255, 64, 219, 201, 255, 19, 203, 211, 255, 0, 189, 209, 255, 171, - 120, 117, 255, 186, 152, 140, 255, 199, 198, 168, 255, 179, 226, 194, 255, - 119, 226, 206, 255, 62, 217, 213, 255, 19, 204, 222, 255, 0, 192, 221, - 255 - ]; - - expectArraysClose(expected, rotatedPixelsData); - }); - - it('should rotate clockwise 90 degrees', async () => { - const rotatedPixels = - tf.image.rotateWithOffset(getTestImageAsTensor4d(), -90 * Math.PI / 180) - .toInt(); - const rotatedPixelsData = await rotatedPixels.data(); - - const expected = [ - 0, 0, 0, 0, 0, 193, 228, 255, 18, 200, 224, 255, 55, 207, 212, - 255, 108, 214, 202, 255, 163, 208, 187, 255, 179, 176, 159, 255, 168, 129, - 130, 255, 0, 0, 0, 0, 0, 192, 221, 255, 19, 204, 222, 255, 62, - 217, 213, 255, 119, 226, 206, 255, 179, 226, 194, 255, 199, 198, 168, 255, - 186, 152, 140, 255, 0, 0, 0, 0, 0, 189, 209, 255, 19, 203, 211, - 255, 64, 219, 201, 255, 121, 231, 192, 255, 184, 234, 181, 255, 211, 216, - 162, 255, 202, 174, 137, 255, 0, 0, 0, 0, 0, 194, 204, 255, 30, - 209, 205, 255, 76, 225, 193, 255, 130, 235, 179, 255, 191, 239, 165, 255, - 225, 228, 151, 255, 220, 190, 128, 255, 0, 0, 0, 0, 4, 182, 186, - 255, 35, 200, 186, 255, 87, 220, 175, 255, 141, 232, 162, 255, 201, 236, - 142, 255, 235, 227, 128, 255, 230, 193, 104, 255, 0, 0, 0, 0, 3, - 158, 162, 255, 37, 177, 164, 255, 94, 206, 156, 255, 155, 226, 146, 255, - 213, 230, 126, 255, 243, 220, 106, 255, 241, 188, 82, 255, 0, 0, 0, - 0, 6, 133, 140, 255, 39, 150, 141, 255, 98, 181, 135, 255, 162, 206, - 127, 255, 218, 210, 103, 255, 247, 201, 81, 255, 250, 177, 64, 255, 0, - 0, 0, 0, 0, 102, 113, 255, 15, 115, 105, 255, 71, 143, 97, 255, - 135, 166, 86, 255, 191, 170, 61, 255, 222, 164, 41, 255, 233, 148, 31, - 255 - ]; - - expectArraysClose(expected, rotatedPixelsData); - }); - - it('offset center of rotation', async () => { - const rotatedPixels = - tf.image - .rotateWithOffset( - getTestImageAsTensor4d(), 45 * Math.PI / 180, 0, [0.25, 0.75]) - .toInt(); - const rotatedPixelsData = await rotatedPixels.data(); - - const expected = [ - 224, 156, 55, 255, 250, 177, 64, 255, 247, 201, 81, 255, 222, 164, 41, - 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 230, 193, 104, 255, 243, 220, 106, 255, 247, 201, 81, 255, 218, - 210, 103, 255, 135, 166, 86, 255, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 225, 228, 151, 255, 235, 227, 128, 255, 213, 230, 126, - 255, 162, 206, 127, 255, 98, 181, 135, 255, 71, 143, 97, 255, 0, 0, - 0, 0, 0, 0, 0, 0, 225, 228, 151, 255, 191, 239, 165, 255, 141, - 232, 162, 255, 94, 206, 156, 255, 98, 181, 135, 255, 39, 150, 141, 255, - 0, 102, 113, 255, 0, 0, 0, 0, 184, 234, 181, 255, 130, 235, 179, - 255, 76, 225, 193, 255, 87, 220, 175, 255, 37, 177, 164, 255, 6, 133, - 140, 255, 6, 133, 140, 255, 0, 0, 0, 0, 119, 226, 206, 255, 64, - 219, 201, 255, 76, 225, 193, 255, 30, 209, 205, 255, 4, 182, 186, 255, - 3, 158, 162, 255, 0, 0, 0, 0, 0, 0, 0, 0, 62, 217, 213, - 255, 62, 217, 213, 255, 19, 203, 211, 255, 0, 194, 204, 255, 0, 194, - 204, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, - 207, 212, 255, 19, 204, 222, 255, 0, 192, 221, 255, 0, 189, 209, 255, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0 - ]; - - expectArraysClose(expected, rotatedPixelsData); - }); - - it('offset center of rotation with white fill', async () => { - const rotatedPixels = - tf.image - .rotateWithOffset( - getTestImageAsTensor4d(), 45 * Math.PI / 180, 255, [0.25, 0.75]) - .toInt(); - const rotatedPixelsData = await rotatedPixels.data(); - - const expected = [ - 224, 156, 55, 255, 250, 177, 64, 255, 247, 201, 81, 255, 222, 164, 41, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 230, 193, 104, 255, 243, 220, 106, 255, 247, 201, 81, 255, 218, - 210, 103, 255, 135, 166, 86, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 225, 228, 151, 255, 235, 227, 128, 255, 213, 230, 126, - 255, 162, 206, 127, 255, 98, 181, 135, 255, 71, 143, 97, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 225, 228, 151, 255, 191, 239, 165, 255, 141, - 232, 162, 255, 94, 206, 156, 255, 98, 181, 135, 255, 39, 150, 141, 255, - 0, 102, 113, 255, 255, 255, 255, 255, 184, 234, 181, 255, 130, 235, 179, - 255, 76, 225, 193, 255, 87, 220, 175, 255, 37, 177, 164, 255, 6, 133, - 140, 255, 6, 133, 140, 255, 255, 255, 255, 255, 119, 226, 206, 255, 64, - 219, 201, 255, 76, 225, 193, 255, 30, 209, 205, 255, 4, 182, 186, 255, - 3, 158, 162, 255, 255, 255, 255, 255, 255, 255, 255, 255, 62, 217, 213, - 255, 62, 217, 213, 255, 19, 203, 211, 255, 0, 194, 204, 255, 0, 194, - 204, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 55, - 207, 212, 255, 19, 204, 222, 255, 0, 192, 221, 255, 0, 189, 209, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255 - ]; - - expectArraysClose(expected, rotatedPixelsData); - }); - - it('throws when input is int32', async () => { - expect( - () => tf.image.rotateWithOffset( - tf.tensor4d([1, 2, 3, 255], [1, 1, 1, 4], 'int32'), - 90 * Math.PI / 180)) - .toThrowError( - /Argument 'image' passed to 'rotateWithOffset' must be float32/); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/image/threshold.ts b/tfjs-master/tfjs-core/src/ops/image/threshold.ts deleted file mode 100644 index 6efa58004..000000000 --- a/tfjs-master/tfjs-core/src/ops/image/threshold.ts +++ /dev/null @@ -1,163 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import { Tensor1D, Tensor3D } from '../../tensor'; -import { tensor1d } from '../tensor1d'; -import { TensorLike } from '../../types'; -import { op } from '../operation'; -import { cast } from '../cast'; -import { split } from '../split'; -import { bincount } from '../bincount'; -import { lessEqual } from '../less_equal'; -import { greater } from '../greater'; -import { sum } from '../sum'; -import { add } from '../add'; -import { mul } from '../mul'; -import { div } from '../div'; -import { sub } from '../sub'; -import { round } from '../round'; -import { where } from '../where'; -import { fill } from '../fill'; -import {slice} from '../slice'; -import { range } from '../range'; -import { tensor } from '../tensor'; -import * as util from '../../util'; -import { convertToTensor } from '../../tensor_util_env'; - -/** - * Performs image binarization with corresponding threshold - * (depends on the method)value, which creates a binary image from a grayscale. - * @param image 3d tensor of shape [imageHeight,imageWidth, depth], - * where imageHeight and imageWidth must be positive.The image color - * range should be [0, 255]. - * @param method Optional string from `'binary' | 'otsu'` - * which specifies the method for thresholding. Defaults to 'binary'. - * @param inverted Optional boolean whichspecifies - * if colours should be inverted. Defaults to false. - * @param threshValue Optional number which defines threshold value from 0 to 1. - * Defaults to 0.5. - * @return A 3d tensor of shape [imageHeight,imageWidth, depth], which - * contains binarized image. - */ - -function threshold_( - image: Tensor3D | TensorLike, - method = 'binary', - inverted = false, - threshValue = 0.5 -): Tensor3D { - const $image = convertToTensor(image, 'image', 'threshold'); - - /* 0.2989, 0.5870, 0.1140 are represent luma coefficients in CCIR601. - Reference for converting between RGB and grayscale: https://en.wikipedia.org/wiki/Luma_%28video%29 */ - - const RED_INTENCITY_COEF = 0.2989; - const GREEN_INTENCITY_COEF = 0.5870; - const BLUE_INTENCITY_COEF = 0.1140; - const totalPixelsInImage = $image.shape[0] * $image.shape[1]; - - let $threshold = mul(tensor1d([threshValue]), 255); - let r, g, b, grayscale; - - util.assert( - $image.rank === 3, - () => 'Error in threshold: image must be rank 3,' + - `but got rank ${$image.rank}.`); - - util.assert( - $image.shape[2] === 3 || $image.shape[2]=== 1, - () => 'Error in threshold: ' + - 'image color channel must be equal to 3 or 1' + - `but got ${$image.shape[2]}.`); - - util.assert( - $image.dtype === 'int32' || $image.dtype === 'float32', - () => 'Error in dtype: image dtype must be int32 or float32,' + - `but got dtype ${$image.dtype}.`); - - util.assert( - method === 'otsu' || method === 'binary', - () => `Method must be binary or otsu, but was ${method}`); - - if ($image.shape[2] === 3) { - [r, g, b] = split($image, [1, 1, 1], -1); - const $r = mul(r,RED_INTENCITY_COEF); - const $g = mul(g,GREEN_INTENCITY_COEF); - const $b = mul(b,BLUE_INTENCITY_COEF); - grayscale = add(add($r, $g), $b); - } else { - grayscale = image; - } - - if (method === 'otsu') { - const $histogram = bincount(cast(round(grayscale), 'int32') as Tensor1D, - tensor([]), - 256); - $threshold = otsu($histogram, totalPixelsInImage); - } - - const invCondition = inverted ? - lessEqual(grayscale, $threshold) : greater(grayscale, $threshold); - - const result = cast(mul(invCondition,255), 'int32'); - - return result as Tensor3D; -} - -function otsu(histogram: Tensor1D, total: number):Tensor1D { - - let bestThresh = tensor1d([-1]); - let bestInBetVar = tensor1d([0]); - let cInBetVar = tensor1d([0]); - let classFirst, classSecond, meanFirst, - meanSec, weightForeground, weightBack; - - for (let index = 0; index < histogram.size-1; index++) { - - classFirst = slice(histogram, 0, index + 1); - - classSecond = slice(histogram,index + 1); - - weightForeground = div(sum(classFirst),total); - - weightBack = div(sum(classSecond),total); - - const meanFirstDivA = sum(mul(classFirst, range(0, classFirst.size))); - - meanFirst = div(meanFirstDivA, sum(classFirst) ); - - const meanSecFill = fill(classSecond.shape, classFirst.size); - const meanSecAdd = add(range(0,classSecond.size),meanSecFill); - const meanSecMul = mul(classSecond, (meanSecAdd)); - meanSec = div(sum(meanSecMul), sum(classSecond)); - - const cInBetVarSubA = sub(meanFirst, meanSec); - const cInBetVarSubB = sub(meanFirst, meanSec); - const cInBetVarMul = mul(weightForeground, weightBack); - cInBetVar = mul(mul(cInBetVarMul,cInBetVarSubA), cInBetVarSubB); - - const condition = greater(cInBetVar, bestInBetVar); - - bestInBetVar = where(condition, cInBetVar, bestInBetVar); - - bestThresh = where(condition, tensor1d([index]), bestThresh); - - } - return bestThresh; -} - -export const threshold = /* @__PURE__ */ op({ threshold_ }); diff --git a/tfjs-master/tfjs-core/src/ops/image/threshold_test.ts b/tfjs-master/tfjs-core/src/ops/image/threshold_test.ts deleted file mode 100644 index ba5c9dafb..000000000 --- a/tfjs-master/tfjs-core/src/ops/image/threshold_test.ts +++ /dev/null @@ -1,183 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import * as tf from '../../index'; -import {ALL_ENVS, describeWithFlags} from '../../jasmine_util'; -import {expectArraysEqual} from '../../test_util'; - -describeWithFlags('threshold', ALL_ENVS, () => { - let originalTimeout: number; - beforeEach(() => { - originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL; - jasmine.DEFAULT_TIMEOUT_INTERVAL = 80_000; - }); - afterAll(() => { - jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout; - }); - - it('default method binary, no arguments passed but input image', async () => { - const image: tf.Tensor3D = tf.tensor3d( - [144, 255, 51, 13, 32, 59, 222, 100, 51, 69, 71, 222], [2, 2, 3]); - - const thresholded = tf.image.threshold(image); - - expect(thresholded.shape).toEqual([2, 2, 1]); - expect(thresholded.dtype).toBe('int32'); - expectArraysEqual(await thresholded.data(), [255, 0, 255, 0]); - }); - - it('default method binary, inverted: false, threshValue = 0.7', async () => { - const image: tf.Tensor3D = tf.tensor3d( - [ - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 254, 253, 252, 235, - 195, 252, 234, 192, 255, 254, 253, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 253, 245, 237, 247, 198, 107, - 239, 156, 43, 236, 139, 68, 246, 201, 139, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 252, 239, 235, 241, - 171, 122, 233, 125, 44, 250, 221, 183, 252, 240, 229, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 251, 233, 227, 229, 105, 42, 249, 221, 190, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 254, 247, 245, 243, 184, 144, 255, 254, 254, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 253, 244, 241, 249, - 217, 206, 251, 231, 224, 251, 230, 223, 250, 225, 217, 250, 224, 215, - 250, 228, 220, 247, 235, 231, 235, 234, 234, 255, 255, 255, 255, 253, - 253, 252, 235, 230, 253, 243, 240, 251, 233, 226, 253, 242, 238, 254, - 247, 244, 252, 235, 230, 242, 232, 229, 240, 240, 240, 255, 255, 255 - ], - [7, 10, 3]); - - const method = 'binary'; - const inverted = false; - const threshValue = 0.7; - const output = tf.image.threshold(image, method, inverted, threshValue); - - expect(output.shape).toEqual([7, 10, 1]); - expect(output.dtype).toBe('int32'); - expectArraysEqual(await output.data(), [ - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 - ]); - }); - - it('default method binary, inverted: true, threshValue = 0.7', async () => { - const image: tf.Tensor3D = tf.tensor3d( - [ - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 254, 253, 252, 235, - 195, 252, 234, 192, 255, 254, 253, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 253, 245, 237, 247, 198, 107, - 239, 156, 43, 236, 139, 68, 246, 201, 139, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 252, 239, 235, 241, - 171, 122, 233, 125, 44, 250, 221, 183, 252, 240, 229, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 251, 233, 227, 229, 105, 42, 249, 221, 190, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 254, 247, 245, 243, 184, 144, 255, 254, 254, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 253, 244, 241, 249, - 217, 206, 251, 231, 224, 251, 230, 223, 250, 225, 217, 250, 224, 215, - 250, 228, 220, 247, 235, 231, 235, 234, 234, 255, 255, 255, 255, 253, - 253, 252, 235, 230, 253, 243, 240, 251, 233, 226, 253, 242, 238, 254, - 247, 244, 252, 235, 230, 242, 232, 229, 240, 240, 240, 255, 255, 255 - ], - [7, 10, 3]); - - const threshValue = 0.7; - const method = 'binary'; - const inverted = true; - const output = tf.image.threshold(image, method, inverted, threshValue); - - expect(output.shape).toEqual([7, 10, 1]); - expect(output.dtype).toBe('int32'); - expectArraysEqual(await output.data(), [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 0, 0, - 0, 0, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ]); - }); - - it('method otsu', async () => { - const image: tf.Tensor3D = tf.tensor3d( - [ - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 254, 253, 252, 235, - 195, 252, 234, 192, 255, 254, 253, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 253, 245, 237, 247, 198, 107, - 239, 156, 43, 236, 139, 68, 246, 201, 139, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 252, 239, 235, 241, - 171, 122, 233, 125, 44, 250, 221, 183, 252, 240, 229, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 251, 233, 227, 229, 105, 42, 249, 221, 190, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 254, 247, 245, 243, 184, 144, 255, 254, 254, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 253, 244, 241, 249, - 217, 206, 251, 231, 224, 251, 230, 223, 250, 225, 217, 250, 224, 215, - 250, 228, 220, 247, 235, 231, 235, 234, 234, 255, 255, 255, 255, 253, - 253, 252, 235, 230, 253, 243, 240, 251, 233, 226, 253, 242, 238, 254, - 247, 244, 252, 235, 230, 242, 232, 229, 240, 240, 240, 255, 255, 255 - ], - [7, 10, 3]); - - const method = 'otsu'; - const output = tf.image.threshold(image, method); - - expect(output.shape).toEqual([7, 10, 1]); - expect(output.dtype).toBe('int32'); - expectArraysEqual(await output.data(), [ - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, - 0, 0, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 - ]); - }); - - it('method otsu, inverted = true', async () => { - const image: tf.Tensor3D = tf.tensor3d( - [ - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 254, 253, 252, 235, - 195, 252, 234, 192, 255, 254, 253, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 253, 245, 237, 247, 198, 107, - 239, 156, 43, 236, 139, 68, 246, 201, 139, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 252, 239, 235, 241, - 171, 122, 233, 125, 44, 250, 221, 183, 252, 240, 229, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 251, 233, 227, 229, 105, 42, 249, 221, 190, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 254, 247, 245, 243, 184, 144, 255, 254, 254, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 253, 244, 241, 249, - 217, 206, 251, 231, 224, 251, 230, 223, 250, 225, 217, 250, 224, 215, - 250, 228, 220, 247, 235, 231, 235, 234, 234, 255, 255, 255, 255, 253, - 253, 252, 235, 230, 253, 243, 240, 251, 233, 226, 253, 242, 238, 254, - 247, 244, 252, 235, 230, 242, 232, 229, 240, 240, 240, 255, 255, 255 - ], - [7, 10, 3]); - const method = 'otsu'; - const inverted = true; - const output = tf.image.threshold(image, method, inverted); - - expect(output.shape).toEqual([7, 10, 1]); - expect(output.dtype).toBe('int32'); - expectArraysEqual(await output.data(), [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, - 0, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ]); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/image/transform.ts b/tfjs-master/tfjs-core/src/ops/image/transform.ts deleted file mode 100644 index f0d44a89b..000000000 --- a/tfjs-master/tfjs-core/src/ops/image/transform.ts +++ /dev/null @@ -1,94 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {ENGINE} from '../../engine'; -import {Transform, TransformAttrs, TransformInputs} from '../../kernel_names'; -import {NamedAttrMap} from '../../kernel_registry'; -import {Tensor2D, Tensor4D} from '../../tensor'; -import {NamedTensorMap} from '../../tensor_types'; -import {convertToTensor} from '../../tensor_util_env'; -import {TensorLike} from '../../types'; -import * as util from '../../util'; - -import {op} from '../operation'; - -/** - * Applies the given transform(s) to the image(s). - * - * @param image 4d tensor of shape `[batch, imageHeight, imageWidth, depth]`. - * @param transforms Projective transform matrix/matrices. A tensor1d of length - * 8 or tensor of size N x 8. If one row of transforms is [a0, a1, a2, b0, - * b1, b2, c0, c1], then it maps the output point (x, y) to a transformed - * input point (x', y') = ((a0 x + a1 y + a2) / k, (b0 x + b1 y + b2) / k), - * where k = c0 x + c1 y + 1. The transforms are inverted compared to the - * transform mapping input points to output points. - * @param interpolation Interpolation mode. - * Supported values: 'nearest', 'bilinear'. Default to 'nearest'. - * @param fillMode Points outside the boundaries of the input are filled - * according to the given mode, one of 'constant', 'reflect', 'wrap', - * 'nearest'. Default to 'constant'. - * 'reflect': (d c b a | a b c d | d c b a ) The input is extended by - * reflecting about the edge of the last pixel. - * 'constant': (k k k k | a b c d | k k k k) The input is extended by - * filling all values beyond the edge with the same constant value k. - * 'wrap': (a b c d | a b c d | a b c d) The input is extended by - * wrapping around to the opposite edge. - * 'nearest': (a a a a | a b c d | d d d d) The input is extended by - * the nearest pixel. - * @param fillValue A float represents the value to be filled outside the - * boundaries when fillMode is 'constant'. - * @param Output dimension after the transform, [height, width]. If undefined, - * output is the same size as input image. - * - * @doc {heading: 'Operations', subheading: 'Images', namespace: 'image'} - */ -function transform_( - image: Tensor4D|TensorLike, transforms: Tensor2D|TensorLike, - interpolation: 'nearest'|'bilinear' = 'nearest', - fillMode: 'constant'|'reflect'|'wrap'|'nearest' = 'constant', fillValue = 0, - outputShape?: [number, number]): Tensor4D { - const $image = convertToTensor(image, 'image', 'transform', 'float32'); - const $transforms = - convertToTensor(transforms, 'transforms', 'transform', 'float32'); - - util.assert( - $image.rank === 4, - () => 'Error in transform: image must be rank 4,' + - `but got rank ${$image.rank}.`); - - util.assert( - $transforms.rank === 2 && - ($transforms.shape[0] === $image.shape[0] || - $transforms.shape[0] === 1) && - $transforms.shape[1] === 8, - () => `Error in transform: Input transform should be batch x 8 or 1 x 8`); - - util.assert( - outputShape == null || outputShape.length === 2, - () => - 'Error in transform: outputShape must be [height, width] or null, ' + - `but got ${outputShape}.`); - - const inputs: TransformInputs = {image: $image, transforms: $transforms}; - const attrs: - TransformAttrs = {interpolation, fillMode, fillValue, outputShape}; - - return ENGINE.runKernel( - Transform, inputs as unknown as NamedTensorMap, - attrs as unknown as NamedAttrMap); -} - -export const transform = /* @__PURE__ */ op({transform_}); diff --git a/tfjs-master/tfjs-core/src/ops/image/transform_test.ts b/tfjs-master/tfjs-core/src/ops/image/transform_test.ts deleted file mode 100644 index 15a6524a3..000000000 --- a/tfjs-master/tfjs-core/src/ops/image/transform_test.ts +++ /dev/null @@ -1,128 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import * as tf from '../../index'; -import {ALL_ENVS, describeWithFlags} from '../../jasmine_util'; -import {expectArraysClose} from '../../test_util'; - -describeWithFlags('image.transform', ALL_ENVS, () => { - it('extreme projective transform.', async () => { - const images = tf.tensor4d( - [1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1], [1, 4, 4, 1]); - const transform = tf.tensor2d([1, 0, 0, 0, 1, 0, -1, 0], [1, 8]); - const transformedImages = - tf.image.transform(images, transform, 'nearest', 'constant', 0).toInt(); - const transformedImagesData = await transformedImages.data(); - - const expected = [1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0]; - - expectArraysClose(transformedImagesData, expected); - }); - - it('static output shape.', async () => { - const images = tf.tensor4d([1, 2, 3, 4], [1, 2, 2, 1]); - const transform = tf.randomUniform([1, 8], -1, 1); - const transformedImages = tf.image.transform( - images, transform as tf.Tensor2D, 'nearest', 'constant', 0, [3, 5]); - - expectArraysClose(transformedImages.shape, [1, 3, 5, 1]); - }); - - it('fill=constant, interpolation=nearest.', async () => { - const images = tf.tensor4d( - [1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0], [1, 4, 4, 1]); - const transform = tf.tensor2d([0, 0.5, 1, -1, 2, 3, 0, 0], [1, 8]); - const transformedImages = tf.image.transform(images, transform); - const transformedImagesData = await transformedImages.data(); - const expected = [1, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0]; - - expectArraysClose(transformedImagesData, expected); - }); - - it('fill=constant, interpolation=bilinear.', async () => { - const images = tf.tensor4d( - [1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0], [1, 4, 4, 1]); - const transform = tf.tensor2d([0, 0.5, 1, -1, 2, 3, 0, 0], [1, 8]); - const transformedImages = tf.image.transform(images, transform, 'bilinear'); - const transformedImagesData = await transformedImages.data(); - const expected = [1, 0, 1, 1, 0, 0, 0.5, 0.5, 0, 0, 0, 0, 0, 0, 0, 0]; - - expectArraysClose(transformedImagesData, expected); - }); - - it('fill=reflect, interpolation=bilinear.', async () => { - const images = tf.tensor4d( - [1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0], [1, 4, 4, 1]); - const transform = tf.tensor2d([0, 0.5, 1, -1, 2, 3, 0, 0], [1, 8]); - const transformedImages = - tf.image.transform(images, transform, 'bilinear', 'reflect'); - const transformedImagesData = await transformedImages.data(); - - const expected = - [1, 0, 1, 1, 0.5, 0.5, 0.5, 0.5, 1, 0, 1, 0, 0, 0.5, 0.5, 0]; - - expectArraysClose(transformedImagesData, expected); - }); - - it('fill=wrap, interpolation=bilinear.', async () => { - const images = tf.tensor4d( - [1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0], [1, 4, 4, 1]); - const transform = tf.tensor2d([0, 0.5, 1, -1, 2, 3, 0, 0], [1, 8]); - const transformedImages = - tf.image.transform(images, transform, 'bilinear', 'wrap'); - const transformedImagesData = await transformedImages.data(); - - const expected = - [1, 0, 1, 1, 0.5, 1, 0.5, 0.5, 1, 1, 0, 1, 0.5, 0.5, 0.5, 0.5]; - - expectArraysClose(transformedImagesData, expected); - }); - - it('fill=nearest, interpolation=bilinear.', async () => { - const images = tf.tensor4d( - [1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0], [1, 4, 4, 1]); - const transform = tf.tensor2d([0, 0.5, 1, -1, 2, 3, 0, 0], [1, 8]); - const transformedImages = - tf.image.transform(images, transform, 'bilinear', 'nearest'); - const transformedImagesData = await transformedImages.data(); - - const expected = [1, 0, 1, 1, 0.5, 0.5, 0.5, 0.5, 0, 0, 0, 0, 0, 0, 0, 0]; - - expectArraysClose(transformedImagesData, expected); - }); - - it('throws when input is int32.', async () => { - const images = tf.tensor4d( - [1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1], [1, 4, 4, 1], - 'int32'); - const transform = tf.tensor2d([1, 0, 0, 0, 1, 0, -1, 0], [1, 8]); - expect( - () => tf.image.transform(images, transform, 'nearest', 'constant', 0)) - .toThrowError(/Argument 'image' passed to 'transform' must be float32/); - }); - - it('throws when transforms is int32.', async () => { - const images = tf.tensor4d( - [1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1], - [1, 4, 4, 1], - ); - const transform = tf.tensor2d([1, 0, 0, 0, 1, 0, -1, 0], [1, 8], 'int32'); - expect( - () => tf.image.transform(images, transform, 'nearest', 'constant', 0)) - .toThrowError( - /Argument 'transforms' passed to 'transform' must be float32/); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/in_top_k.ts b/tfjs-master/tfjs-core/src/ops/in_top_k.ts deleted file mode 100644 index dfb9df57f..000000000 --- a/tfjs-master/tfjs-core/src/ops/in_top_k.ts +++ /dev/null @@ -1,103 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Tensor} from '../tensor'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; -import {assert, assertShapesMatch, getTypedArrayFromDType} from '../util'; -import {tensor} from './tensor'; - -/** - * Returns whether the targets are in the top K predictions. - * - * ```js - * const predictions = tf.tensor2d([[20, 10, 40, 30], [30, 50, -20, 10]]); - * const targets = tf.tensor1d([2, 0]); - * const precision = await tf.inTopKAsync(predictions, targets); - * precision.print(); - * ``` - * @param predictions 2-D or higher `tf.Tensor` with last dimension being - * at least `k`. - * @param targets 1-D or higher `tf.Tensor`. - * @param k Optional Number of top elements to look at for computing precision, - * default to 1. - * - * @doc {heading: 'Operations', subheading: 'Evaluation'} - */ -async function inTopKAsync_( - predictions: T|TensorLike, targets: U|TensorLike, k = 1): Promise { - const $predictions = convertToTensor(predictions, 'predictions', 'inTopK'); - const $targets = convertToTensor(targets, 'targets', 'inTopK'); - - assert( - $predictions.rank > 1, - () => 'inTopK() expects the predictions to be of rank 2 or higher, ' + - `but got ${$predictions.rank}`); - assert( - $predictions.rank - 1 === $targets.rank, - () => `predictions rank should be 1 larger than ` + - `targets rank, but got predictions rank ` + - `${$predictions.rank} and targets rank ${$targets.rank}`); - assertShapesMatch( - $predictions.shape.slice(0, $predictions.shape.length - 1), - $targets.shape, - `predictions's shape should be align with the targets' shape, ` + - 'except the last dimension.'); - const lastDim = $predictions.shape[$predictions.shape.length - 1]; - assert( - k > 0 && k <= lastDim, - () => `'k' passed to inTopK() must be > 0 && <= the predictions last ` + - `dimension (${lastDim}), but got ${k}`); - - const predictionsVals = await $predictions.data(); - const targetsVals = await $targets.data(); - - // Reshape predictionsVals into a 2d tensor [batch, lastDim] - // and look up topK along lastDim. - const [batch, size] = [predictionsVals.length / lastDim, lastDim]; - const precision = getTypedArrayFromDType('bool', batch); - - for (let b = 0; b < batch; b++) { - const offset = b * size; - const vals = predictionsVals.subarray(offset, offset + size); - const valAndInd: Array<{value: number, index: number}> = []; - for (let i = 0; i < vals.length; i++) { - valAndInd.push({value: vals[i], index: i}); - } - valAndInd.sort((a, b) => b.value - a.value); - - precision[b] = 0; - for (let i = 0; i < k; i++) { - if (valAndInd[i].index === targetsVals[b]) { - precision[b] = 1; - break; - } - } - } - - if (predictions !== $predictions) { - $predictions.dispose(); - } - if (targets !== $targets) { - $targets.dispose(); - } - - // Output precision has the same shape as targets. - return tensor(precision, $targets.shape, 'bool') as U; -} - -export const inTopKAsync = inTopKAsync_; diff --git a/tfjs-master/tfjs-core/src/ops/in_top_k_test.ts b/tfjs-master/tfjs-core/src/ops/in_top_k_test.ts deleted file mode 100644 index b23f338be..000000000 --- a/tfjs-master/tfjs-core/src/ops/in_top_k_test.ts +++ /dev/null @@ -1,152 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -import {tensor1d, tensor2d, tensor3d} from './ops'; - -describeWithFlags('inTopKAsync', ALL_ENVS, async () => { - it('predictions 2d array, targets 1d array, with default k', async () => { - const predictions = tensor2d([[20, 10, 40, 30], [30, 50, -20, 10]]); - const targets = tensor1d([2, 0]); - const precision = await tf.inTopKAsync(predictions, targets); - expect(precision.shape).toEqual([2]); - expect(precision.dtype).toBe('bool'); - expectArraysClose(await precision.data(), [1, 0]); - }); - - it('predictions 2d array, targets 1d array, with k=2', async () => { - const predictions = tensor2d([[20, 10, 40, 30], [30, 50, -20, 10]]); - const targets = tensor1d([2, 0]); - const k = 2; - const precision = await tf.inTopKAsync(predictions, targets, k); - expect(precision.shape).toEqual([2]); - expect(precision.dtype).toBe('bool'); - expectArraysClose(await precision.data(), [1, 1]); - }); - - it('predictions 3d array, targets 2d array, with default k', async () => { - const predictions = - tensor3d([[[1, 5, 2], [4, 3, 6]], [[3, 2, 1], [1, 2, 3]]]); - const targets = tensor2d([[1, 2], [0, 1]]); - const precision = await tf.inTopKAsync(predictions, targets); - expect(precision.shape).toEqual([2, 2]); - expect(precision.dtype).toBe('bool'); - expectArraysClose(await precision.data(), [1, 1, 1, 0]); - }); - - it('predictions 3d array, targets 2d array, with k=2', async () => { - const predictions = - tensor3d([[[1, 5, 2], [4, 3, 6]], [[3, 2, 1], [1, 2, 3]]]); - const targets = tensor2d([[1, 2], [0, 1]]); - const k = 2; - const precision = await tf.inTopKAsync(predictions, targets, k); - expect(precision.shape).toEqual([2, 2]); - expect(precision.dtype).toBe('bool'); - expectArraysClose(await precision.data(), [1, 1, 1, 1]); - }); - - it('lower-index element count first, with default k', async () => { - const predictions = tensor2d([[1, 2, 2, 1]]); - - const targets1 = tensor1d([1]); - const precision1 = await tf.inTopKAsync(predictions, targets1); - expect(precision1.shape).toEqual([1]); - expect(precision1.dtype).toBe('bool'); - expectArraysClose(await precision1.data(), [1]); - - const targets2 = tensor1d([2]); - const precision2 = await tf.inTopKAsync(predictions, targets2); - expect(precision2.shape).toEqual([1]); - expect(precision2.dtype).toBe('bool'); - expectArraysClose(await precision2.data(), [0]); - }); - - it('accept tensor-like object, with default k', async () => { - const predictions = [[20, 10, 40, 30], [30, 50, -20, 10]]; - const targets = [2, 0]; - const precision = await tf.inTopKAsync(predictions, targets); - expect(precision.shape).toEqual([2]); - expect(precision.dtype).toBe('bool'); - expectArraysClose(await precision.data(), [1, 0]); - }); - - it('doesnt leak tensors with tensor-like objects', async () => { - const numTensors = tf.memory().numTensors; - - const predictions = [[20, 10, 40, 30], [30, 50, -20, 10]]; - const targets = [2, 0]; - const precision = await tf.inTopKAsync(predictions, targets); - precision.dispose(); - - expect(tf.memory().numTensors).toBe(numTensors); - }); - - it('throws when predictions_rank <2', async () => { - const predictions = tensor1d([20, 10, 40, 30]); - const targets = [2]; - - // expect(...).toThrowError() does not support async functions. - // See https://github.com/jasmine/jasmine/issues/1410 - try { - await tf.inTopKAsync(predictions, targets); - throw new Error('The line above should have thrown an error'); - } catch (ex) { - expect(ex.message) - .toEqual( - 'inTopK() expects the predictions to ' + - 'be of rank 2 or higher, but got 1'); - } - }); - - it('throws when prediction.rank != targets.rank + 1', async () => { - const predictions = tensor2d([[20, 10, 40, 30], [30, 50, -20, 10]]); - const targets = tensor2d([[0], [0]]); - - // expect(...).toThrowError() does not support async functions. - // See https://github.com/jasmine/jasmine/issues/1410 - try { - await tf.inTopKAsync(predictions, targets); - throw new Error('The line above should have thrown an error'); - } catch (ex) { - expect(ex.message) - .toEqual( - 'predictions rank should be 1 larger than targets rank,' + - ' but got predictions rank 2 and targets rank 2'); - } - }); - - it('throws when k > size of last dimension of predictions', async () => { - const predictions = tensor2d([[20, 10, 40, 30], [30, 50, -20, 10]]); - const targets = tensor1d([2, 0]); - const k = 5; - - // expect(...).toThrowError() does not support async functions. - // See https://github.com/jasmine/jasmine/issues/1410 - try { - await tf.inTopKAsync(predictions, targets, k); - throw new Error('The line above should have thrown an error'); - } catch (ex) { - expect(ex.message) - .toEqual( - '\'k\' passed to inTopK() must be > 0 && <= the predictions ' + - 'last dimension (4), but got 5'); - } - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/is_finite.ts b/tfjs-master/tfjs-core/src/ops/is_finite.ts deleted file mode 100644 index 9cfd66561..000000000 --- a/tfjs-master/tfjs-core/src/ops/is_finite.ts +++ /dev/null @@ -1,46 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {IsFinite, IsFiniteInputs} from '../kernel_names'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -import {op} from './operation'; - -/** - * Returns which elements of x are finite. - * - * ```js - * const x = tf.tensor1d([NaN, Infinity, -Infinity, 0, 1]); - * - * x.isFinite().print(); // or tf.isNaN(x) - * ``` - * @param x The input Tensor. - * - * @doc {heading: 'Operations', subheading: 'Basic math'} - */ -function isFinite_(x: T|TensorLike): T { - const $x = convertToTensor(x, 'x', 'isFinite'); - - const inputs: IsFiniteInputs = {x: $x}; - - return ENGINE.runKernel(IsFinite, inputs as unknown as NamedTensorMap); -} -export const isFinite = /* @__PURE__ */ op({isFinite_}); diff --git a/tfjs-master/tfjs-core/src/ops/is_finite_test.ts b/tfjs-master/tfjs-core/src/ops/is_finite_test.ts deleted file mode 100644 index 8d09349ad..000000000 --- a/tfjs-master/tfjs-core/src/ops/is_finite_test.ts +++ /dev/null @@ -1,77 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('isFinite', ALL_ENVS, () => { - it('basic', async () => { - const a = tf.tensor1d([NaN, Infinity, -Infinity, 0, 1]); - const r = tf.isFinite(a); - expect(r.dtype).toEqual('bool'); - expectArraysClose(await r.data(), [0, 0, 0, 1, 1]); - }); - - it('gradients: Scalar', async () => { - const a = tf.scalar(NaN); - const dy = tf.scalar(3); - - const gradients = tf.grad(a => tf.isFinite(a))(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), [0]); - }); - - it('gradients: Tensor1D', async () => { - const a = tf.tensor1d([NaN, Infinity, -Infinity, 0, 1]); - const dy = tf.tensor1d([1, 1, 1, 1, 1]); - - const gradients = tf.grad(a => tf.isFinite(a))(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), [0, 0, 0, 0, 0]); - }); - - it('gradients: Tensor2D', async () => { - const a = tf.tensor2d([NaN, Infinity, -Infinity, 0], [2, 2]); - const dy = tf.tensor2d([1, 2, 3, 4], [2, 2]); - - const gradients = tf.grad(a => tf.isFinite(a))(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), [0, 0, 0, 0]); - }); - - it('throws when passed a non-tensor', () => { - expect(() => tf.isFinite({} as tf.Tensor)) - .toThrowError(/Argument 'x' passed to 'isFinite' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const r = tf.isFinite([NaN, Infinity, -Infinity, 0, 1]); - expectArraysClose(await r.data(), [0, 0, 0, 1, 1]); - }); - - it('throws for string tensor', () => { - expect(() => tf.isFinite('q')) - .toThrowError(/Argument 'x' passed to 'isFinite' must be numeric/); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/is_inf.ts b/tfjs-master/tfjs-core/src/ops/is_inf.ts deleted file mode 100644 index 21230c07a..000000000 --- a/tfjs-master/tfjs-core/src/ops/is_inf.ts +++ /dev/null @@ -1,46 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {IsInf, IsInfInputs} from '../kernel_names'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -import {op} from './operation'; - -/** - * Returns which elements of x are Infinity or -Infinity. - * - * ```js - * const x = tf.tensor1d([NaN, Infinity, -Infinity, 0, 1]); - * - * x.isInf().print(); // or tf.isNaN(x) - * ``` - * @param x The input Tensor. - * - * @doc {heading: 'Operations', subheading: 'Basic math'} - */ -function isInf_(x: T|TensorLike): T { - const $x = convertToTensor(x, 'x', 'isInf'); - - const inputs: IsInfInputs = {x: $x}; - - return ENGINE.runKernel(IsInf, inputs as unknown as NamedTensorMap); -} -export const isInf = /* @__PURE__ */ op({isInf_}); diff --git a/tfjs-master/tfjs-core/src/ops/is_inf_test.ts b/tfjs-master/tfjs-core/src/ops/is_inf_test.ts deleted file mode 100644 index 07e948ab7..000000000 --- a/tfjs-master/tfjs-core/src/ops/is_inf_test.ts +++ /dev/null @@ -1,77 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('isInf', ALL_ENVS, () => { - it('basic', async () => { - const a = tf.tensor1d([NaN, Infinity, -Infinity, 0, 1]); - const r = tf.isInf(a); - expect(r.dtype).toEqual('bool'); - expectArraysClose(await r.data(), [0, 1, 1, 0, 0]); - }); - - it('gradients: Scalar', async () => { - const a = tf.scalar(NaN); - const dy = tf.scalar(3); - - const gradients = tf.grad(a => tf.isInf(a))(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), [0]); - }); - - it('gradients: Tensor1D', async () => { - const a = tf.tensor1d([NaN, Infinity, -Infinity, 0, 1]); - const dy = tf.tensor1d([1, 1, 1, 1, 1]); - - const gradients = tf.grad(a => tf.isInf(a))(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), [0, 0, 0, 0, 0]); - }); - - it('gradients: Tensor2D', async () => { - const a = tf.tensor2d([NaN, Infinity, -Infinity, 0], [2, 2]); - const dy = tf.tensor2d([1, 2, 3, 4], [2, 2]); - - const gradients = tf.grad(a => tf.isInf(a))(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), [0, 0, 0, 0]); - }); - - it('throws when passed a non-tensor', () => { - expect(() => tf.isInf({} as tf.Tensor)) - .toThrowError(/Argument 'x' passed to 'isInf' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const r = tf.isInf([NaN, Infinity, -Infinity, 0, 1]); - expectArraysClose(await r.data(), [0, 1, 1, 0, 0]); - }); - - it('throws for string tensor', () => { - expect(() => tf.isInf('q')) - .toThrowError(/Argument 'x' passed to 'isInf' must be numeric/); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/is_nan.ts b/tfjs-master/tfjs-core/src/ops/is_nan.ts deleted file mode 100644 index 42f83db4b..000000000 --- a/tfjs-master/tfjs-core/src/ops/is_nan.ts +++ /dev/null @@ -1,45 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {IsNan, IsNanInputs} from '../kernel_names'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -import {op} from './operation'; - -/** - * Returns which elements of x are NaN. - * - * ```js - * const x = tf.tensor1d([NaN, Infinity, -Infinity, 0, 1]); - * - * x.isNaN().print(); // or tf.isNaN(x) - * ``` - * @param x The input Tensor. - * - * @doc {heading: 'Operations', subheading: 'Basic math'} - */ -function isNaN_(x: T|TensorLike): T { - const $x = convertToTensor(x, 'x', 'isNaN'); - const inputs: IsNanInputs = {x: $x}; - - return ENGINE.runKernel(IsNan, inputs as unknown as NamedTensorMap); -} -export const isNaN = /* @__PURE__ */ op({isNaN_}); diff --git a/tfjs-master/tfjs-core/src/ops/is_nan_test.ts b/tfjs-master/tfjs-core/src/ops/is_nan_test.ts deleted file mode 100644 index db6144ab0..000000000 --- a/tfjs-master/tfjs-core/src/ops/is_nan_test.ts +++ /dev/null @@ -1,77 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('isNaN', ALL_ENVS, () => { - it('basic', async () => { - const a = tf.tensor1d([NaN, Infinity, -Infinity, 0, 1]); - const r = tf.isNaN(a); - expect(r.dtype).toEqual('bool'); - expectArraysClose(await r.data(), [1, 0, 0, 0, 0]); - }); - - it('gradients: Scalar', async () => { - const a = tf.scalar(NaN); - const dy = tf.scalar(3); - - const gradients = tf.grad(a => tf.isNaN(a))(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), [0]); - }); - - it('gradients: Tensor1D', async () => { - const a = tf.tensor1d([NaN, Infinity, -Infinity, 0, 1]); - const dy = tf.tensor1d([1, 1, 1, 1, 1]); - - const gradients = tf.grad(a => tf.isNaN(a))(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), [0, 0, 0, 0, 0]); - }); - - it('gradients: Tensor2D', async () => { - const a = tf.tensor2d([NaN, Infinity, -Infinity, 0], [2, 2]); - const dy = tf.tensor2d([1, 2, 3, 4], [2, 2]); - - const gradients = tf.grad(a => tf.isNaN(a))(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), [0, 0, 0, 0]); - }); - - it('throws when passed a non-tensor', () => { - expect(() => tf.isNaN({} as tf.Tensor)) - .toThrowError(/Argument 'x' passed to 'isNaN' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const r = tf.isNaN([NaN, Infinity, -Infinity, 0, 1]); - expectArraysClose(await r.data(), [1, 0, 0, 0, 0]); - }); - - it('throws for string tensor', () => { - expect(() => tf.isNaN('q')) - .toThrowError(/Argument 'x' passed to 'isNaN' must be numeric/); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/leaky_relu.ts b/tfjs-master/tfjs-core/src/ops/leaky_relu.ts deleted file mode 100644 index ce0a13219..000000000 --- a/tfjs-master/tfjs-core/src/ops/leaky_relu.ts +++ /dev/null @@ -1,56 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {LeakyRelu, LeakyReluAttrs, LeakyReluInputs} from '../kernel_names'; -import {NamedAttrMap} from '../kernel_registry'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -import {op} from './operation'; - -/** - * Computes leaky rectified linear element-wise. - * - * See - * [http://web.stanford.edu/~awni/papers/relu_hybrid_icml2013_final.pdf]( - * http://web.stanford.edu/~awni/papers/relu_hybrid_icml2013_final.pdf) - * - * ```js - * const x = tf.tensor1d([-1, 2, -3, 4]); - * - * x.leakyRelu(0.1).print(); // or tf.leakyRelu(x, 0.1) - * ``` - * @param x The input tensor. - * @param alpha The scaling factor for negative values, defaults to 0.2. - * - * @doc {heading: 'Operations', subheading: 'Basic math'} - */ -function leakyRelu_(x: T|TensorLike, alpha = 0.2): T { - const $x = convertToTensor(x, 'x', 'leakyRelu'); - - const inputs: LeakyReluInputs = {x: $x}; - const attrs: LeakyReluAttrs = {alpha}; - - return ENGINE.runKernel( - LeakyRelu, inputs as unknown as NamedTensorMap, - attrs as unknown as NamedAttrMap); -} - -export const leakyRelu = /* @__PURE__ */ op({leakyRelu_}); diff --git a/tfjs-master/tfjs-core/src/ops/leaky_relu_test.ts b/tfjs-master/tfjs-core/src/ops/leaky_relu_test.ts deleted file mode 100644 index 36018b9b7..000000000 --- a/tfjs-master/tfjs-core/src/ops/leaky_relu_test.ts +++ /dev/null @@ -1,125 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; -import {backend} from '../index'; - -describeWithFlags('leakyrelu', ALL_ENVS, () => { - it('basic', async () => { - const a = tf.tensor1d([0, 1, -2]); - const result = tf.leakyRelu(a); - - expect(result.shape).toEqual(a.shape); - expectArraysClose(await result.data(), [0, 1, -0.4]); - }); - - it('int32', async () => { - if (backend() && backend().floatPrecision() === 32) { - // TODO: Use skip() instead when it is implemented - const a = tf.tensor1d([0, 1, -2], 'int32'); - const result = tf.leakyRelu(a); - - expect(result.shape).toEqual(a.shape); - expect(result.dtype).toEqual('float32'); - expectArraysClose(await result.data(), [0, 1, -0.4]); - } - }); - - it('propagates NaN', async () => { - const a = tf.tensor1d([0, 1, NaN]); - const result = tf.leakyRelu(a); - - expect(result.shape).toEqual(a.shape); - expectArraysClose(await result.data(), [0, 1, NaN]); - }); - - it('gradients: Scalar', async () => { - const a = tf.scalar(-4); - const dy = tf.scalar(8); - const alpha = 0.1; - - const gradients = tf.grad((a) => tf.leakyRelu(a, alpha))(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), [8 * alpha]); - }); - - it('gradient with clones', async () => { - const a = tf.scalar(-4); - const dy = tf.scalar(8); - const alpha = 0.1; - - const gradients = - tf.grad((a) => tf.leakyRelu(a.clone(), alpha).clone())(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), [8 * alpha]); - }); - - it('gradients: Tensor1D', async () => { - const aValues = [1, -1, 0.1]; - const dyValues = [1, 2, 3]; - const alpha = 0.1; - - const a = tf.tensor1d(aValues); - const dy = tf.tensor1d(dyValues); - - const gradients = tf.grad((a) => tf.leakyRelu(a, alpha))(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - - expectArraysClose(await gradients.data(), [1, 2 * alpha, 3]); - }); - - it('gradients: Tensor2D', async () => { - const aValues = [1, -1, 0.1, 0.5]; - const dyValues = [1, 2, 3, 4]; - const alpha = 0.1; - - const a = tf.tensor2d(aValues, [2, 2]); - const dy = tf.tensor2d(dyValues, [2, 2]); - - const gradients = tf.grad((a) => tf.leakyRelu(a, alpha))(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - - expectArraysClose(await gradients.data(), [1, 2 * alpha, 3, 4]); - }); - - it('throws when passed a non-tensor', () => { - expect(() => tf.leakyRelu({} as tf.Tensor)) - .toThrowError(/Argument 'x' passed to 'leakyRelu' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const result = tf.leakyRelu([0, 1, -2]); - - expect(result.shape).toEqual([3]); - expectArraysClose(await result.data(), [0, 1, -0.4]); - }); - - it('throws for string tensor', () => { - expect(() => tf.leakyRelu('q')) - .toThrowError(/Argument 'x' passed to 'leakyRelu' must be numeric/); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/less.ts b/tfjs-master/tfjs-core/src/ops/less.ts deleted file mode 100644 index 5910b69e9..000000000 --- a/tfjs-master/tfjs-core/src/ops/less.ts +++ /dev/null @@ -1,55 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {ENGINE} from '../engine'; -import {Less, LessInputs} from '../kernel_names'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {makeTypesMatch} from '../tensor_util'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -import {assertAndGetBroadcastShape} from './broadcast_util'; -import {op} from './operation'; - -/** - * Returns the truth value of (a < b) element-wise. Supports broadcasting. - * - * ```js - * const a = tf.tensor1d([1, 2, 3]); - * const b = tf.tensor1d([2, 2, 2]); - * - * a.less(b).print(); - * ``` - * @param a The first input tensor. - * @param b The second input tensor. Must have the same dtype as `a`. - * - * @doc {heading: 'Operations', subheading: 'Logical'} - */ -function less_( - a: Tensor|TensorLike, b: Tensor|TensorLike): T { - let $a = convertToTensor(a, 'a', 'less', 'string_or_numeric'); - let $b = convertToTensor(b, 'b', 'less', 'string_or_numeric'); - [$a, $b] = makeTypesMatch($a, $b); - - assertAndGetBroadcastShape($a.shape, $b.shape); - - const inputs: LessInputs = {a: $a, b: $b}; - - return ENGINE.runKernel(Less, inputs as unknown as NamedTensorMap); -} - -export const less = /* @__PURE__ */ op({less_}); diff --git a/tfjs-master/tfjs-core/src/ops/less_equal.ts b/tfjs-master/tfjs-core/src/ops/less_equal.ts deleted file mode 100644 index 423e3f9ab..000000000 --- a/tfjs-master/tfjs-core/src/ops/less_equal.ts +++ /dev/null @@ -1,56 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {ENGINE} from '../engine'; -import {LessEqual, LessEqualInputs} from '../kernel_names'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {makeTypesMatch} from '../tensor_util'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -import {assertAndGetBroadcastShape} from './broadcast_util'; -import {op} from './operation'; - -/** - * Returns the truth value of (a <= b) element-wise. Supports broadcasting. - * - * ```js - * const a = tf.tensor1d([1, 2, 3]); - * const b = tf.tensor1d([2, 2, 2]); - * - * a.lessEqual(b).print(); - * ``` - * - * @param a The first input tensor. - * @param b The second input tensor. Must have the same dtype as `a`. - * - * @doc {heading: 'Operations', subheading: 'Logical'} - */ -function lessEqual_( - a: Tensor|TensorLike, b: Tensor|TensorLike): T { - let $a = convertToTensor(a, 'a', 'lessEqual', 'string_or_numeric'); - let $b = convertToTensor(b, 'b', 'lessEqual', 'string_or_numeric'); - [$a, $b] = makeTypesMatch($a, $b); - - assertAndGetBroadcastShape($a.shape, $b.shape); - - const inputs: LessEqualInputs = {a: $a, b: $b}; - - return ENGINE.runKernel(LessEqual, inputs as unknown as NamedTensorMap); -} - -export const lessEqual = /* @__PURE__ */ op({lessEqual_}); diff --git a/tfjs-master/tfjs-core/src/ops/less_equal_test.ts b/tfjs-master/tfjs-core/src/ops/less_equal_test.ts deleted file mode 100644 index fba5e5038..000000000 --- a/tfjs-master/tfjs-core/src/ops/less_equal_test.ts +++ /dev/null @@ -1,354 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose, expectArraysEqual} from '../test_util'; - -describeWithFlags('lessEqual', ALL_ENVS, () => { - it('Tensor1D - int32', async () => { - let a = tf.tensor1d([1, 4, 5], 'int32'); - let b = tf.tensor1d([2, 3, 5], 'int32'); - let res = tf.lessEqual(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [1, 0, 1]); - - a = tf.tensor1d([2, 2, 2], 'int32'); - b = tf.tensor1d([2, 2, 2], 'int32'); - res = tf.lessEqual(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [1, 1, 1]); - - a = tf.tensor1d([0, 0], 'int32'); - b = tf.tensor1d([3, 3], 'int32'); - res = tf.lessEqual(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [1, 1]); - }); - it('Tensor1D - float32', async () => { - let a = tf.tensor1d([1.1, 4.1, 5.1], 'float32'); - let b = tf.tensor1d([2.2, 3.2, 5.1], 'float32'); - let res = tf.lessEqual(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [1, 0, 1]); - - a = tf.tensor1d([2.31, 2.31, 2.31], 'float32'); - b = tf.tensor1d([2.31, 2.31, 2.31], 'float32'); - res = tf.lessEqual(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [1, 1, 1]); - - a = tf.tensor1d([0.45, 0.123], 'float32'); - b = tf.tensor1d([3.123, 3.321], 'float32'); - res = tf.lessEqual(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [1, 1]); - }); - - it('upcasts when dtypes dont match', async () => { - const a = [1.1, 4.1, 5]; - const b = [2.2, 3.2, 5]; - - let res = - tf.lessEqual(tf.tensor(a, [3], 'float32'), tf.tensor(b, [3], 'int32')); - expect(res.dtype).toBe('bool'); - expect(res.shape).toEqual([3]); - expectArraysClose(await res.data(), [1, 0, 1]); - - res = tf.lessEqual(tf.tensor(a, [3], 'int32'), tf.tensor(b, [3], 'bool')); - expect(res.dtype).toBe('bool'); - expect(res.shape).toEqual([3]); - expectArraysClose(await res.data(), [1, 0, 0]); - }); - - it('TensorLike', async () => { - const a = [1.1, 4.1, 5.1]; - const b = [2.2, 3.2, 5.1]; - const res = tf.lessEqual(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [1, 0, 1]); - }); - it('TensorLike Chained', async () => { - const a = tf.tensor1d([1.1, 4.1, 5.1], 'float32'); - const b = [2.2, 3.2, 5.1]; - const res = a.lessEqual(b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [1, 0, 1]); - }); - it('mismatched Tensor1D shapes - int32', () => { - const a = tf.tensor1d([1, 2], 'int32'); - const b = tf.tensor1d([1, 2, 3], 'int32'); - const f = () => { - tf.lessEqual(a, b); - }; - expect(f).toThrowError(); - }); - it('mismatched Tensor1D shapes - float32', () => { - const a = tf.tensor1d([1.1, 2.1], 'float32'); - const b = tf.tensor1d([1.1, 2.1, 3.1], 'float32'); - const f = () => { - tf.lessEqual(a, b); - }; - expect(f).toThrowError(); - }); - it('NaNs in Tensor1D - float32', async () => { - const a = tf.tensor1d([1.1, NaN, 2.1], 'float32'); - const b = tf.tensor1d([2.1, 3.1, NaN], 'float32'); - const res = tf.lessEqual(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [1, 0, 0]); - }); - - // Tensor2D: - it('Tensor2D - int32', async () => { - let a = tf.tensor2d([[1, 4, 5], [8, 9, 12]], [2, 3], 'int32'); - let b = tf.tensor2d([[2, 3, 6], [7, 10, 11]], [2, 3], 'int32'); - let res = tf.lessEqual(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [1, 0, 1, 0, 1, 0]); - - a = tf.tensor2d([[0, 0], [1, 1]], [2, 2], 'int32'); - b = tf.tensor2d([[0, 0], [1, 1]], [2, 2], 'int32'); - res = tf.lessEqual(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [1, 1, 1, 1]); - }); - it('Tensor2D - float32', async () => { - let a = tf.tensor2d([[1.1, 4.1, 5.1], [8.1, 9.1, 12.1]], [2, 3], 'float32'); - let b = - tf.tensor2d([[2.1, 3.1, 6.1], [7.1, 10.1, 11.1]], [2, 3], 'float32'); - let res = tf.lessEqual(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [1, 0, 1, 0, 1, 0]); - - a = tf.tensor2d([[0.2, 0.2], [1.2, 1.2]], [2, 2], 'float32'); - b = tf.tensor2d([[0.2, 0.2], [1.2, 1.2]], [2, 2], 'float32'); - res = tf.lessEqual(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [1, 1, 1, 1]); - }); - it('broadcasting Tensor2D shapes - int32', async () => { - const a = tf.tensor2d([[3], [7]], [2, 1], 'int32'); - const b = tf.tensor2d([[2, 3, 4], [7, 8, 9]], [2, 3], 'int32'); - const res = tf.lessEqual(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [0, 1, 1, 1, 1, 1]); - }); - it('broadcasting Tensor2D shapes - float32', async () => { - const a = tf.tensor2d([[1.1], [7.1]], [2, 1], 'float32'); - const b = - tf.tensor2d([[0.1, 1.1, 2.1], [7.1, 8.1, 9.1]], [2, 3], 'float32'); - const res = tf.lessEqual(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [0, 1, 1, 1, 1, 1]); - }); - it('NaNs in Tensor2D - float32', async () => { - const a = tf.tensor2d([[1.1, NaN], [0.1, NaN]], [2, 2], 'float32'); - const b = tf.tensor2d([[0.1, NaN], [1.1, NaN]], [2, 2], 'float32'); - const res = tf.lessEqual(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [0, 0, 1, 0]); - }); - - // Tensor3D: - it('Tensor3D - int32', async () => { - let a = - tf.tensor3d([[[1], [4], [5]], [[8], [9], [12]]], [2, 3, 1], 'int32'); - let b = - tf.tensor3d([[[2], [3], [6]], [[7], [10], [11]]], [2, 3, 1], 'int32'); - let res = tf.lessEqual(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [1, 0, 1, 0, 1, 0]); - - a = tf.tensor3d([[[0], [0], [0]], [[1], [1], [1]]], [2, 3, 1], 'int32'); - b = tf.tensor3d([[[0], [0], [0]], [[1], [1], [1]]], [2, 3, 1], 'int32'); - res = tf.lessEqual(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [1, 1, 1, 1, 1, 1]); - }); - it('Tensor3D - float32', async () => { - let a = tf.tensor3d( - [[[1.1], [4.1], [5.1]], [[8.1], [9.1], [12.1]]], [2, 3, 1], 'float32'); - let b = tf.tensor3d( - [[[2.1], [3.1], [6.1]], [[7.1], [10.1], [11.1]]], [2, 3, 1], 'float32'); - let res = tf.lessEqual(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [1, 0, 1, 0, 1, 0]); - - a = tf.tensor3d( - [[[0.1], [0.1], [0.1]], [[1.1], [1.1], [1.2]]], [2, 3, 1], 'float32'); - b = tf.tensor3d( - [[[0.1], [0.1], [0.1]], [[1.1], [1.1], [1.1]]], [2, 3, 1], 'float32'); - res = tf.lessEqual(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [1, 1, 1, 1, 1, 0]); - }); - it('broadcasting Tensor3D shapes - int32', async () => { - const a = tf.tensor3d( - [[[1, 0], [2, 3], [4, 5]], [[6, 7], [9, 8], [10, 11]]], [2, 3, 2], - 'int32'); - const b = - tf.tensor3d([[[1], [2], [3]], [[7], [10], [9]]], [2, 3, 1], 'int32'); - const res = tf.lessEqual(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0]); - }); - it('broadcasting Tensor3D float32', async () => { - const a = tf.tensor3d( - [ - [[1.1, 0.1], [2.1, 3.1], [4.1, 5.1]], - [[6.1, 7.1], [9.1, 8.1], [10.1, 11.1]] - ], - [2, 3, 2], 'float32'); - const b = tf.tensor3d( - [[[1.1], [2.1], [3.1]], [[7.1], [10.1], [9.1]]], [2, 3, 1], 'float32'); - const res = tf.lessEqual(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0]); - }); - it('NaNs in Tensor3D - float32', async () => { - const a = tf.tensor3d( - [[[1.1], [NaN], [1.1]], [[0.1], [0.1], [0.1]]], [2, 3, 1], 'float32'); - const b = tf.tensor3d( - [[[0.1], [0.1], [1.1]], [[1.1], [0.1], [NaN]]], [2, 3, 1], 'float32'); - const res = tf.lessEqual(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [0, 0, 1, 1, 1, 0]); - }); - - // Tensor4D: - it('Tensor4D - int32', async () => { - let a = tf.tensor4d([1, 4, 5, 8], [2, 2, 1, 1], 'int32'); - let b = tf.tensor4d([2, 3, 6, 7], [2, 2, 1, 1], 'int32'); - let res = tf.lessEqual(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [1, 0, 1, 0]); - - a = tf.tensor4d([0, 1, 2, 3], [2, 2, 1, 1], 'int32'); - b = tf.tensor4d([0, 1, 2, 3], [2, 2, 1, 1], 'int32'); - res = tf.lessEqual(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [1, 1, 1, 1]); - - a = tf.tensor4d([1, 1, 1, 1], [2, 2, 1, 1], 'int32'); - b = tf.tensor4d([2, 2, 2, 2], [2, 2, 1, 1], 'int32'); - res = tf.lessEqual(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [1, 1, 1, 1]); - }); - it('Tensor4D - float32', async () => { - let a = tf.tensor4d([1.1, 4.1, 5.1, 8.1], [2, 2, 1, 1], 'float32'); - let b = tf.tensor4d([2.1, 3.1, 6.1, 7.1], [2, 2, 1, 1], 'float32'); - let res = tf.lessEqual(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [1, 0, 1, 0]); - - a = tf.tensor4d([0.1, 1.1, 2.2, 3.3], [2, 2, 1, 1], 'float32'); - b = tf.tensor4d([0.1, 1.1, 2.2, 3.3], [2, 2, 1, 1], 'float32'); - res = tf.lessEqual(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [1, 1, 1, 1]); - - a = tf.tensor4d([0.1, 0.1, 0.1, 0.1], [2, 2, 1, 1], 'float32'); - b = tf.tensor4d([1.1, 1.1, 1.1, 1.1], [2, 2, 1, 1], 'float32'); - res = tf.lessEqual(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [1, 1, 1, 1]); - }); - it('broadcasting Tensor4D shapes - int32', async () => { - const a = tf.tensor4d([1, 2, 5, 9], [2, 2, 1, 1], 'int32'); - const b = tf.tensor4d( - [[[[1, 2]], [[3, 4]]], [[[5, 6]], [[7, 8]]]], [2, 2, 1, 2], 'int32'); - const res = tf.lessEqual(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [1, 1, 1, 1, 1, 1, 0, 0]); - }); - it('broadcasting Tensor4D shapes - float32', async () => { - const a = tf.tensor4d([1.1, 2.1, 5.1, 9.1], [2, 2, 1, 1], 'float32'); - const b = tf.tensor4d( - [[[[1.1, 2.1]], [[3.1, 4.1]]], [[[5.1, 6.1]], [[7.1, 8.1]]]], - [2, 2, 1, 2], 'float32'); - const res = tf.lessEqual(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [1, 1, 1, 1, 1, 1, 0, 0]); - }); - it('NaNs in Tensor4D - float32', async () => { - const a = tf.tensor4d([1.1, NaN, 0.1, 0.1], [2, 2, 1, 1], 'float32'); - const b = tf.tensor4d([0.1, 1.1, 1.1, NaN], [2, 2, 1, 1], 'float32'); - const res = tf.lessEqual(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [0, 0, 1, 0]); - }); - - it('throws when passed a as a non-tensor', () => { - expect(() => tf.lessEqual({} as tf.Tensor, tf.scalar(1))) - .toThrowError(/Argument 'a' passed to 'lessEqual' must be a Tensor/); - }); - it('throws when passed b as a non-tensor', () => { - expect(() => tf.lessEqual(tf.scalar(1), {} as tf.Tensor)) - .toThrowError(/Argument 'b' passed to 'lessEqual' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const a = [1, 4, 5]; - const b = [2, 3, 5]; - const res = tf.lessEqual(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [1, 0, 1]); - }); - - it('should support string comparison', async () => { - const tensorA = tf.tensor('a', [], 'string'); - const tensorB = tf.tensor(['a', 'b', ''], [3], 'string'); - const result = await tf.lessEqual(tensorA, tensorB); - - expectArraysEqual(result.shape, [3]); - expectArraysEqual(await result.data(), [1, 1, 0]); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/less_test.ts b/tfjs-master/tfjs-core/src/ops/less_test.ts deleted file mode 100644 index a67f72e0a..000000000 --- a/tfjs-master/tfjs-core/src/ops/less_test.ts +++ /dev/null @@ -1,353 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose, expectArraysEqual} from '../test_util'; - -describeWithFlags('less', ALL_ENVS, () => { - it('Tensor1D - int32', async () => { - let a = tf.tensor1d([1, 4, 5], 'int32'); - let b = tf.tensor1d([2, 3, 5], 'int32'); - let res = tf.less(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [1, 0, 0]); - - a = tf.tensor1d([2, 2, 2], 'int32'); - b = tf.tensor1d([2, 2, 2], 'int32'); - res = tf.less(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [0, 0, 0]); - - a = tf.tensor1d([0, 0], 'int32'); - b = tf.tensor1d([3, 3], 'int32'); - res = tf.less(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [1, 1]); - }); - it('Tensor1D - float32', async () => { - let a = tf.tensor1d([1.1, 4.1, 5.1], 'float32'); - let b = tf.tensor1d([2.2, 3.2, 5.1], 'float32'); - let res = tf.less(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [1, 0, 0]); - - a = tf.tensor1d([2.31, 2.31, 2.31], 'float32'); - b = tf.tensor1d([2.31, 2.31, 2.31], 'float32'); - res = tf.less(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [0, 0, 0]); - - a = tf.tensor1d([0.45, 0.123], 'float32'); - b = tf.tensor1d([3.123, 3.321], 'float32'); - res = tf.less(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [1, 1]); - }); - it('TensorLike', async () => { - const a = [1.1, 4.1, 5.1]; - const b = [2.2, 3.2, 5.1]; - const res = tf.less(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [1, 0, 0]); - }); - it('TensorLike Chained', async () => { - const a = tf.tensor1d([1.1, 4.1, 5.1], 'float32'); - const b = [2.2, 3.2, 5.1]; - const res = a.less(b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [1, 0, 0]); - }); - - it('upcasts when dtypes dont match', async () => { - const a = [1.1, 4.1, 5.2]; - const b = [2.2, 3.2, 5.1]; - - let res = tf.less(tf.tensor(a, [3], 'float32'), tf.tensor(b, [3], 'int32')); - expect(res.dtype).toBe('bool'); - expect(res.shape).toEqual([3]); - expectArraysClose(await res.data(), [1, 0, 0]); - - res = tf.less(tf.tensor(a, [3], 'int32'), tf.tensor(b, [3], 'bool')); - expect(res.dtype).toBe('bool'); - expect(res.shape).toEqual([3]); - expectArraysClose(await res.data(), [0, 0, 0]); - }); - - it('mismatched Tensor1D shapes - int32', () => { - const a = tf.tensor1d([1, 2], 'int32'); - const b = tf.tensor1d([1, 2, 3], 'int32'); - const f = () => { - tf.less(a, b); - }; - expect(f).toThrowError(); - }); - it('mismatched Tensor1D shapes - float32', () => { - const a = tf.tensor1d([1.1, 2.1], 'float32'); - const b = tf.tensor1d([1.1, 2.1, 3.1], 'float32'); - const f = () => { - tf.less(a, b); - }; - expect(f).toThrowError(); - }); - it('NaNs in Tensor1D - float32', async () => { - const a = tf.tensor1d([1.1, NaN, 2.1], 'float32'); - const b = tf.tensor1d([2.1, 3.1, NaN], 'float32'); - const res = tf.less(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [1, 0, 0]); - }); - - // Tensor2D: - it('Tensor2D - int32', async () => { - let a = tf.tensor2d([[1, 4, 5], [8, 9, 12]], [2, 3], 'int32'); - let b = tf.tensor2d([[2, 3, 6], [7, 10, 11]], [2, 3], 'int32'); - let res = tf.less(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [1, 0, 1, 0, 1, 0]); - - a = tf.tensor2d([[0, 0], [1, 1]], [2, 2], 'int32'); - b = tf.tensor2d([[0, 0], [1, 1]], [2, 2], 'int32'); - res = tf.less(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [0, 0, 0, 0]); - }); - it('Tensor2D - float32', async () => { - let a = tf.tensor2d([[1.1, 4.1, 5.1], [8.1, 9.1, 12.1]], [2, 3], 'float32'); - let b = - tf.tensor2d([[2.1, 3.1, 6.1], [7.1, 10.1, 11.1]], [2, 3], 'float32'); - let res = tf.less(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [1, 0, 1, 0, 1, 0]); - - a = tf.tensor2d([[0.2, 0.2], [1.2, 1.2]], [2, 2], 'float32'); - b = tf.tensor2d([[0.2, 0.2], [1.2, 1.2]], [2, 2], 'float32'); - res = tf.less(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [0, 0, 0, 0]); - }); - it('broadcasting Tensor2D shapes - int32', async () => { - const a = tf.tensor2d([[3], [7]], [2, 1], 'int32'); - const b = tf.tensor2d([[2, 3, 4], [7, 8, 9]], [2, 3], 'int32'); - const res = tf.less(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [0, 0, 1, 0, 1, 1]); - }); - it('broadcasting Tensor2D shapes - float32', async () => { - const a = tf.tensor2d([[1.1], [7.1]], [2, 1], 'float32'); - const b = - tf.tensor2d([[0.1, 1.1, 2.1], [7.1, 8.1, 9.1]], [2, 3], 'float32'); - const res = tf.less(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [0, 0, 1, 0, 1, 1]); - }); - it('NaNs in Tensor2D - float32', async () => { - const a = tf.tensor2d([[1.1, NaN], [0.1, NaN]], [2, 2], 'float32'); - const b = tf.tensor2d([[0.1, NaN], [1.1, NaN]], [2, 2], 'float32'); - const res = tf.less(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [0, 0, 1, 0]); - }); - - // Tensor3D: - it('Tensor3D - int32', async () => { - let a = - tf.tensor3d([[[1], [4], [5]], [[8], [9], [12]]], [2, 3, 1], 'int32'); - let b = - tf.tensor3d([[[2], [3], [6]], [[7], [10], [11]]], [2, 3, 1], 'int32'); - let res = tf.less(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [1, 0, 1, 0, 1, 0]); - - a = tf.tensor3d([[[0], [0], [0]], [[1], [1], [1]]], [2, 3, 1], 'int32'); - b = tf.tensor3d([[[0], [0], [0]], [[1], [1], [1]]], [2, 3, 1], 'int32'); - res = tf.less(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [0, 0, 0, 0, 0, 0]); - }); - it('Tensor3D - float32', async () => { - let a = tf.tensor3d( - [[[1.1], [4.1], [5.1]], [[8.1], [9.1], [12.1]]], [2, 3, 1], 'float32'); - let b = tf.tensor3d( - [[[2.1], [3.1], [6.1]], [[7.1], [10.1], [11.1]]], [2, 3, 1], 'float32'); - let res = tf.less(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [1, 0, 1, 0, 1, 0]); - - a = tf.tensor3d( - [[[0.1], [0.1], [0.1]], [[1.1], [1.1], [1.0]]], [2, 3, 1], 'float32'); - b = tf.tensor3d( - [[[0.1], [0.1], [0.1]], [[1.1], [1.1], [1.1]]], [2, 3, 1], 'float32'); - res = tf.less(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [0, 0, 0, 0, 0, 1]); - }); - it('broadcasting Tensor3D shapes - int32', async () => { - const a = tf.tensor3d( - [[[1, 0], [2, 3], [4, 5]], [[6, 7], [9, 8], [10, 11]]], [2, 3, 2], - 'int32'); - const b = - tf.tensor3d([[[1], [2], [3]], [[7], [10], [9]]], [2, 3, 1], 'int32'); - const res = tf.less(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [0, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0]); - }); - it('broadcasting Tensor3D float32', async () => { - const a = tf.tensor3d( - [ - [[1.1, 0.1], [2.1, 3.1], [4.1, 5.1]], - [[6.1, 7.1], [9.1, 8.1], [10.1, 11.1]] - ], - [2, 3, 2], 'float32'); - const b = tf.tensor3d( - [[[1.1], [2.1], [3.1]], [[7.1], [10.1], [9.1]]], [2, 3, 1], 'float32'); - const res = tf.less(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [0, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0]); - }); - it('NaNs in Tensor3D - float32', async () => { - const a = tf.tensor3d( - [[[1.1], [NaN], [1.1]], [[0.1], [0.1], [0.1]]], [2, 3, 1], 'float32'); - const b = tf.tensor3d( - [[[0.1], [0.1], [1.1]], [[1.1], [0.1], [NaN]]], [2, 3, 1], 'float32'); - const res = tf.less(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [0, 0, 0, 1, 0, 0]); - }); - - // Tensor4D: - it('Tensor4D - int32', async () => { - let a = tf.tensor4d([1, 4, 5, 8], [2, 2, 1, 1], 'int32'); - let b = tf.tensor4d([2, 3, 6, 7], [2, 2, 1, 1], 'int32'); - let res = tf.less(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [1, 0, 1, 0]); - - a = tf.tensor4d([0, 1, 2, 3], [2, 2, 1, 1], 'int32'); - b = tf.tensor4d([0, 1, 2, 3], [2, 2, 1, 1], 'int32'); - res = tf.less(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [0, 0, 0, 0]); - - a = tf.tensor4d([1, 1, 1, 1], [2, 2, 1, 1], 'int32'); - b = tf.tensor4d([2, 2, 2, 2], [2, 2, 1, 1], 'int32'); - res = tf.less(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [1, 1, 1, 1]); - }); - it('Tensor4D - float32', async () => { - let a = tf.tensor4d([1.1, 4.1, 5.1, 8.1], [2, 2, 1, 1], 'float32'); - let b = tf.tensor4d([2.1, 3.1, 6.1, 7.1], [2, 2, 1, 1], 'float32'); - let res = tf.less(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [1, 0, 1, 0]); - - a = tf.tensor4d([0.1, 1.1, 2.2, 3.3], [2, 2, 1, 1], 'float32'); - b = tf.tensor4d([0.1, 1.1, 2.2, 3.3], [2, 2, 1, 1], 'float32'); - res = tf.less(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [0, 0, 0, 0]); - - a = tf.tensor4d([0.1, 0.1, 0.1, 0.1], [2, 2, 1, 1], 'float32'); - b = tf.tensor4d([1.1, 1.1, 1.1, 1.1], [2, 2, 1, 1], 'float32'); - res = tf.less(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [1, 1, 1, 1]); - }); - it('broadcasting Tensor4D shapes - int32', async () => { - const a = tf.tensor4d([1, 2, 5, 9], [2, 2, 1, 1], 'int32'); - const b = tf.tensor4d( - [[[[1, 2]], [[3, 4]]], [[[5, 6]], [[7, 8]]]], [2, 2, 1, 2], 'int32'); - const res = tf.less(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [0, 1, 1, 1, 0, 1, 0, 0]); - }); - it('broadcasting Tensor4D shapes - float32', async () => { - const a = tf.tensor4d([1.1, 2.1, 5.1, 9.1], [2, 2, 1, 1], 'float32'); - const b = tf.tensor4d( - [[[[1.1, 2.1]], [[3.1, 4.1]]], [[[5.1, 6.1]], [[7.1, 8.1]]]], - [2, 2, 1, 2], 'float32'); - const res = tf.less(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [0, 1, 1, 1, 0, 1, 0, 0]); - }); - it('NaNs in Tensor4D - float32', async () => { - const a = tf.tensor4d([1.1, NaN, 0.1, 0.1], [2, 2, 1, 1], 'float32'); - const b = tf.tensor4d([0.1, 1.1, 1.1, NaN], [2, 2, 1, 1], 'float32'); - const res = tf.less(a, b); - - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [0, 0, 1, 0]); - }); - - it('throws when passed a as a non-tensor', () => { - expect(() => tf.less({} as tf.Tensor, tf.scalar(1))) - .toThrowError(/Argument 'a' passed to 'less' must be a Tensor/); - }); - it('throws when passed b as a non-tensor', () => { - expect(() => tf.less(tf.scalar(1), {} as tf.Tensor)) - .toThrowError(/Argument 'b' passed to 'less' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const a = [1, 4, 5]; - const b = [2, 3, 5]; - - const res = tf.less(a, b); - expect(res.dtype).toBe('bool'); - expectArraysClose(await res.data(), [1, 0, 0]); - }); - - it('should support string comparison', async () => { - const tensorA = tf.tensor('a', [], 'string'); - const tensorB = tf.tensor(['a', 'b', ''], [3], 'string'); - const result = await tf.less(tensorA, tensorB); - - expectArraysEqual(result.shape, [3]); - expectArraysEqual(await result.data(), [0, 1, 0]); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/linalg/band_part.ts b/tfjs-master/tfjs-core/src/ops/linalg/band_part.ts deleted file mode 100644 index f58ea2b49..000000000 --- a/tfjs-master/tfjs-core/src/ops/linalg/band_part.ts +++ /dev/null @@ -1,141 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Scalar, Tensor} from '../../tensor'; -import {convertToTensor} from '../../tensor_util_env'; -import {TensorLike} from '../../types'; -import {assert} from '../../util'; - -import {greaterEqual} from '../greater_equal'; -import {less} from '../less'; -import {lessEqual} from '../less_equal'; -import {logicalAnd} from '../logical_and'; -import {minimum} from '../minimum'; -import {neg} from '../neg'; -import {op} from '../operation'; -import {range} from '../range'; -import {reshape} from '../reshape'; -import {stack} from '../stack'; -import {sub} from '../sub'; -import {unstack} from '../unstack'; -import {where} from '../where'; -import {zeros} from '../zeros'; - -/** - * Copy a tensor setting everything outside a central band in each innermost - * matrix to zero. - * - * The band part is computed as follows: Assume input has `k` dimensions - * `[I, J, K, ..., M, N]`, then the output is a tensor with the same shape where - * `band[i, j, k, ..., m, n] = in_band(m, n) * input[i, j, k, ..., m, n]`. - * The indicator function - * `in_band(m, n) = (num_lower < 0 || (m-n) <= num_lower)` - * `&& (num_upper < 0 || (n-m) <= num_upper)` - * - * ```js - * const x = tf.tensor2d([[ 0, 1, 2, 3], - * [-1, 0, 1, 2], - * [-2, -1, 0, 1], - * [-3, -2, -1, 0]]); - * let y = tf.linalg.bandPart(x, 1, -1); - * y.print(); // [[ 0, 1, 2, 3], - * // [-1, 0, 1, 2], - * // [ 0, -1, 0, 1], - * // [ 0, 0 , -1, 0]] - * let z = tf.linalg.bandPart(x, 2, 1); - * z.print(); // [[ 0, 1, 0, 0], - * // [-1, 0, 1, 0], - * // [-2, -1, 0, 1], - * // [ 0, -2, -1, 0]] - * ``` - * - * @param x Rank `k` tensor - * @param numLower Number of subdiagonals to keep. - * If negative, keep entire lower triangle. - * @param numUpper Number of subdiagonals to keep. - * If negative, keep entire upper triangle. - * @returns Rank `k` tensor of the same shape as input. - * The extracted banded tensor. - * - * @doc {heading:'Operations', subheading:'Linear Algebra', namespace:'linalg'} - */ -function bandPart_( - a: T|TensorLike, numLower: number|Scalar, numUpper: number|Scalar): T { - const $a = convertToTensor(a, 'a', 'bandPart'); - assert( - $a.rank >= 2, - () => `bandPart(): Rank must be at least 2, got ${$a.rank}.`); - - const shape = $a.shape; - const [M, N] = $a.shape.slice(-2); - - let $numLower: Scalar; - let $numUpper: Scalar; - if (typeof numLower === 'number') { - assert( - numLower % 1 === 0, - () => `bandPart(): numLower must be an integer, got ${numLower}.`); - assert( - numLower <= M, - () => `bandPart(): numLower (${numLower})` + - ` must not be greater than the number of rows (${M}).`); - $numLower = - convertToTensor(numLower < 0 ? M : numLower, 'numLower', 'bandPart') as - Scalar; - } else { - assert( - numLower.dtype === 'int32', - () => `bandPart(): numLower's dtype must be an int32.`); - // If numLower is a Scalar, checking `numLower <= M` could hurt performance, - // but minimum(numLower, M) could avoid unexpected results. - $numLower = where(less(numLower, 0), M, minimum(numLower, M)) as Scalar; - } - - if (typeof numUpper === 'number') { - assert( - numUpper % 1 === 0, - () => `bandPart(): numUpper must be an integer, got ${numUpper}.`); - assert( - numUpper <= N, - () => `bandPart(): numUpper (${numUpper})` + - ` must not be greater than the number of columns (${N}).`); - $numUpper = - convertToTensor(numUpper < 0 ? N : numUpper, 'numUpper', 'bandPart') as - Scalar; - } else { - assert( - numUpper.dtype === 'int32', - () => `bandPart(): numUpper's dtype must be an int32.`); - $numUpper = where(less(numUpper, 0), N, minimum(numUpper, N)) as Scalar; - } - - const i = reshape(range(0, M, 1, 'int32'), [-1, 1]); - const j = range(0, N, 1, 'int32'); - const ij = sub(i, j); - - const inBand = - logicalAnd(lessEqual(ij, $numLower), greaterEqual(ij, neg($numUpper))); - - const zero = zeros([M, N], $a.dtype); - - return reshape( - stack(unstack(reshape($a, [-1, M, N])) - .map(mat => where(inBand, mat, zero))), - shape) as T; -} - -export const bandPart = /* @__PURE__ */ op({bandPart_}); diff --git a/tfjs-master/tfjs-core/src/ops/linalg/band_part_test.ts b/tfjs-master/tfjs-core/src/ops/linalg/band_part_test.ts deleted file mode 100644 index fc0021453..000000000 --- a/tfjs-master/tfjs-core/src/ops/linalg/band_part_test.ts +++ /dev/null @@ -1,190 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../../index'; -import {ALL_ENVS, describeWithFlags} from '../../jasmine_util'; -import {Tensor2D, Tensor3D} from '../../tensor'; -import {expectArraysClose} from '../../test_util'; - -import {scalar, tensor1d, tensor2d, tensor3d} from '../ops'; - -describeWithFlags('bandPart', ALL_ENVS, () => { - it('keeps tensor unchanged', async () => { - const x: Tensor2D = tensor2d([1, 1, 1, 1, 1, 1, 1, 1, 1], [3, 3]); - expectArraysClose( - await tf.linalg.bandPart(x, -1, -1).array(), - [[1, 1, 1], [1, 1, 1], [1, 1, 1]]); - }); - - it('upper triangular matrix', async () => { - const x: Tensor2D = tensor2d([1, 1, 1, 1, 1, 1, 1, 1, 1], [3, 3]); - expectArraysClose( - await tf.linalg.bandPart(x, 0, -1).array(), - [[1, 1, 1], [0, 1, 1], [0, 0, 1]]); - }); - - it('lower triangular matrix', async () => { - const x: Tensor2D = tensor2d([1, 1, 1, 1, 1, 1, 1, 1, 1], [3, 3]); - expectArraysClose( - await tf.linalg.bandPart(x, -1, 0).array(), - [[1, 0, 0], [1, 1, 0], [1, 1, 1]]); - }); - - it('diagonal elements', async () => { - const x: Tensor2D = tensor2d([1, 1, 1, 1, 1, 1, 1, 1, 1], [3, 3]); - expectArraysClose( - await tf.linalg.bandPart(x, 0, 0).array(), - [[1, 0, 0], [0, 1, 0], [0, 0, 1]]); - }); - - it('lower triangular elements', async () => { - const x: Tensor2D = tensor2d([1, 1, 1, 1, 1, 1, 1, 1, 1], [3, 3]); - expectArraysClose( - await tf.linalg.bandPart(x, 1, 0).array(), - [[1, 0, 0], [1, 1, 0], [0, 1, 1]]); - }); - - it('upper triangular elements', async () => { - const x: Tensor2D = tensor2d([1, 1, 1, 1, 1, 1, 1, 1, 1], [3, 3]); - expectArraysClose( - await tf.linalg.bandPart(x, 0, 1).array(), - [[1, 1, 0], [0, 1, 1], [0, 0, 1]]); - }); - - it('4X4 matrix - tensorflow python examples', async () => { - const x: Tensor2D = tensor2d( - [[0, 1, 2, 3], [-1, 0, 1, 2], [-2, -1, 0, 1], [-3, -2, -1, 0]]); - expectArraysClose( - await tf.linalg.bandPart(x, 1, -1).array(), - [[0, 1, 2, 3], [-1, 0, 1, 2], [0, -1, 0, 1], [0, 0, -1, 0]]); - expectArraysClose( - await tf.linalg.bandPart(x, 2, 1).array(), - [[0, 1, 0, 0], [-1, 0, 1, 0], [-2, -1, 0, 1], [0, -2, -1, 0]]); - }); - - it('3 dimensional matrix', async () => { - const x: Tensor3D = tensor3d([[[1, 1], [1, 1]], [[1, 1], [1, 1]]]); - expectArraysClose( - await tf.linalg.bandPart(x, 0, 0).array(), - [[[1, 0], [0, 1]], [[1, 0], [0, 1]]]); - }); - - it('2X3X3 tensor', async () => { - const x: Tensor3D = tensor3d( - [[[1, 1, 1], [1, 1, 1], [1, 1, 1]], [[1, 1, 1], [1, 1, 1], [1, 1, 1]]]); - expectArraysClose( - await tf.linalg.bandPart(x, 1, 2).array(), - [[[1, 1, 1], [1, 1, 1], [0, 1, 1]], [[1, 1, 1], [1, 1, 1], [0, 1, 1]]]); - }); - - const la = tf.linalg; - - it('fails for scalar', async () => { - const x = scalar(1); - expect(() => la.bandPart(x, 1, 2)).toThrowError(/bandPart.*rank/i); - }); - - it('fails for 1D tensor', async () => { - const x = tensor1d([1, 2, 3, 4, 5]); - expect(() => la.bandPart(x, 1, 2)).toThrowError(/bandPart.*rank/i); - }); - - it('fails if numLower or numUpper too large', async () => { - const a = tf.tensor2d([[1, 2, 3], [4, 5, 6]]); - - for (const numLower of [3, 5, 8, 13]) { - for (const numUpper of [-1, 0, 1, 2]) { - expect(() => tf.linalg.bandPart(a, numLower, numUpper)) - .toThrowError(/bandPart.*numLower/i); - } - } - - for (const numLower of [-1, 0, 1]) { - for (const numUpper of [4, 5, 9]) { - expect(() => tf.linalg.bandPart(a, numLower, numUpper)) - .toThrowError(/bandPart.*numUpper/i); - } - } - - for (const numLower of [3, 5, 8, 13]) { - for (const numUpper of [4, 5, 9]) { - expect(() => tf.linalg.bandPart(a, numLower, numUpper)) - .toThrowError(/bandPart.*(numLower|numUpper)/i); - } - } - }); - - it('works for 3x4 example', async () => { - const a = tf.tensor2d([[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]]); - - expectArraysClose( - await la.bandPart(a, 0, 0).array(), - [[1, 0, 0, 0], [0, 6, 0, 0], [0, 0, 11, 0]]); - expectArraysClose( - await la.bandPart(a, 0, 1).array(), - [[1, 2, 0, 0], [0, 6, 7, 0], [0, 0, 11, 12]]); - expectArraysClose( - await la.bandPart(a, 0, 2).array(), - [[1, 2, 3, 0], [0, 6, 7, 8], [0, 0, 11, 12]]); - for (const numUpper of [3, 4, -1, -2]) { - expectArraysClose( - await la.bandPart(a, 0, numUpper).array(), - [[1, 2, 3, 4], [0, 6, 7, 8], [0, 0, 11, 12]]); - } - - expectArraysClose( - await la.bandPart(a, 1, 0).array(), - [[1, 0, 0, 0], [5, 6, 0, 0], [0, 10, 11, 0]]); - expectArraysClose( - await la.bandPart(a, 1, 1).array(), - [[1, 2, 0, 0], [5, 6, 7, 0], [0, 10, 11, 12]]); - expectArraysClose( - await la.bandPart(a, 1, 2).array(), - [[1, 2, 3, 0], [5, 6, 7, 8], [0, 10, 11, 12]]); - for (const numUpper of [3, 4, -1, -2]) { - expectArraysClose( - await la.bandPart(a, 1, numUpper).array(), - [[1, 2, 3, 4], [5, 6, 7, 8], [0, 10, 11, 12]]); - } - - for (const numLower of [2, 3, -1, -2]) { - expectArraysClose( - await la.bandPart(a, numLower, 0).array(), - [[1, 0, 0, 0], [5, 6, 0, 0], [9, 10, 11, 0]]); - expectArraysClose( - await la.bandPart(a, numLower, 1).array(), - [[1, 2, 0, 0], [5, 6, 7, 0], [9, 10, 11, 12]]); - expectArraysClose( - await la.bandPart(a, numLower, 2).array(), - [[1, 2, 3, 0], [5, 6, 7, 8], [9, 10, 11, 12]]); - for (const numUpper of [3, 4, -1, -2]) { - expectArraysClose( - await la.bandPart(a, numLower, numUpper).array(), - [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]]); - } - } - }); - - it('works for tensor numLower and tensor numUpper', async () => { - const x: Tensor2D = tensor2d([1, 1, 1, 1, 1, 1, 1, 1, 1], [3, 3]); - expectArraysClose( - await tf.linalg - .bandPart(x, tf.scalar(-1, 'int32'), tf.scalar(0, 'int32')) - .array(), - [[1, 0, 0], [1, 1, 0], [1, 1, 1]]); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/linalg/gram_schmidt.ts b/tfjs-master/tfjs-core/src/ops/linalg/gram_schmidt.ts deleted file mode 100644 index b2be6eae9..000000000 --- a/tfjs-master/tfjs-core/src/ops/linalg/gram_schmidt.ts +++ /dev/null @@ -1,109 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../../engine'; -import {Tensor1D, Tensor2D} from '../../tensor'; -import {assert} from '../../util'; - -import {div} from '../div'; -import {mul} from '../mul'; -import {norm} from '../norm'; -import {op} from '../operation'; -import {split} from '../split'; -import {squeeze} from '../squeeze'; -import {stack} from '../stack'; -import {sub} from '../sub'; -import {sum} from '../sum'; - -/** - * Gram-Schmidt orthogonalization. - * - * ```js - * const x = tf.tensor2d([[1, 2], [3, 4]]); - * let y = tf.linalg.gramSchmidt(x); - * y.print(); - * console.log('Orthogonalized:'); - * y.dot(y.transpose()).print(); // should be nearly the identity matrix. - * console.log('First row direction maintained:'); - * const data = await y.array(); - * console.log(data[0][1] / data[0][0]); // should be nearly 2. - * ``` - * - * @param xs The vectors to be orthogonalized, in one of the two following - * formats: - * - An Array of `tf.Tensor1D`. - * - A `tf.Tensor2D`, i.e., a matrix, in which case the vectors are the rows - * of `xs`. - * In each case, all the vectors must have the same length and the length - * must be greater than or equal to the number of vectors. - * @returns The orthogonalized and normalized vectors or matrix. - * Orthogonalization means that the vectors or the rows of the matrix - * are orthogonal (zero inner products). Normalization means that each - * vector or each row of the matrix has an L2 norm that equals `1`. - * - * @doc {heading:'Operations', subheading:'Linear Algebra', namespace:'linalg'} - */ -function gramSchmidt_(xs: Tensor1D[]|Tensor2D): Tensor1D[]|Tensor2D { - let inputIsTensor2D: boolean; - if (Array.isArray(xs)) { - inputIsTensor2D = false; - assert( - xs != null && xs.length > 0, - () => 'Gram-Schmidt process: input must not be null, undefined, or ' + - 'empty'); - const dim = xs[0].shape[0]; - for (let i = 1; i < xs.length; ++i) { - assert( - xs[i].shape[0] === dim, - () => - 'Gram-Schmidt: Non-unique lengths found in the input vectors: ' + - `(${(xs as Tensor1D[])[i].shape[0]} vs. ${dim})`); - } - } else { - inputIsTensor2D = true; - xs = split(xs, xs.shape[0], 0).map(x => squeeze(x, [0])); - } - - assert( - xs.length <= xs[0].shape[0], - () => `Gram-Schmidt: Number of vectors (${ - (xs as Tensor1D[]).length}) exceeds ` + - `number of dimensions (${(xs as Tensor1D[])[0].shape[0]}).`); - - const ys: Tensor1D[] = []; - const xs1d = xs; - for (let i = 0; i < xs.length; ++i) { - ys.push(ENGINE.tidy(() => { - let x = xs1d[i]; - if (i > 0) { - for (let j = 0; j < i; ++j) { - const proj = mul(sum(mul(ys[j], x)), ys[j]); - x = sub(x, proj); - } - } - return div(x, norm(x, 'euclidean')); - })); - } - - if (inputIsTensor2D) { - return stack(ys, 0) as Tensor2D; - } else { - return ys; - } -} - -export const gramSchmidt = /* @__PURE__ */ op({gramSchmidt_}); diff --git a/tfjs-master/tfjs-core/src/ops/linalg/gram_schmidt_test.ts b/tfjs-master/tfjs-core/src/ops/linalg/gram_schmidt_test.ts deleted file mode 100644 index 89b87c7b6..000000000 --- a/tfjs-master/tfjs-core/src/ops/linalg/gram_schmidt_test.ts +++ /dev/null @@ -1,87 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../../index'; -import {ALL_ENVS, describeWithFlags} from '../../jasmine_util'; -import {Tensor1D, Tensor2D} from '../../tensor'; -import {expectArraysClose} from '../../test_util'; - -describeWithFlags('gramSchmidt-tiny', ALL_ENVS, () => { - it('2x2, Array of Tensor1D', async () => { - const xs: Tensor1D[] = [ - tf.randomNormal([2], 0, 1, 'float32', 1), - tf.randomNormal([2], 0, 1, 'float32', 2) - ]; - const ys = tf.linalg.gramSchmidt(xs) as Tensor1D[]; - const y = tf.stack(ys) as Tensor2D; - // Test that the results are orthogonalized and normalized. - expectArraysClose( - await y.transpose().matMul(y).array(), await tf.eye(2).array()); - // Test angle between xs[0] and ys[0] is zero, i.e., the orientation of the - // first vector is kept. - expectArraysClose( - await tf.sum(xs[0].mul(ys[0])).array(), - await tf.norm(xs[0]).mul(tf.norm(ys[0])).array()); - }); - - it('3x3, Array of Tensor1D', async () => { - const xs: Tensor1D[] = [ - tf.randomNormal([3], 0, 1, 'float32', 1), - tf.randomNormal([3], 0, 1, 'float32', 2), - tf.randomNormal([3], 0, 1, 'float32', 3) - ]; - const ys = tf.linalg.gramSchmidt(xs) as Tensor1D[]; - const y = tf.stack(ys) as Tensor2D; - expectArraysClose( - await y.transpose().matMul(y).array(), await tf.eye(3).array()); - expectArraysClose( - await tf.sum(xs[0].mul(ys[0])).array(), - await tf.norm(xs[0]).mul(tf.norm(ys[0])).array()); - }); - - it('3x3, Matrix', async () => { - const xs: Tensor2D = tf.randomNormal([3, 3], 0, 1, 'float32', 1); - const y = tf.linalg.gramSchmidt(xs) as Tensor2D; - expectArraysClose( - await y.transpose().matMul(y).array(), await tf.eye(3).array()); - }); - - it('2x3, Matrix', async () => { - const xs: Tensor2D = tf.randomNormal([2, 3], 0, 1, 'float32', 1); - const y = tf.linalg.gramSchmidt(xs) as Tensor2D; - const yT: Tensor2D = y.transpose(); - expectArraysClose(await y.matMul(yT).array(), await tf.eye(2).array()); - }); - - it('3x2 Matrix throws Error', () => { - const xs = tf.tensor2d([[1, 2], [3, -1], [5, 1]]); - expect(() => tf.linalg.gramSchmidt(xs)) - .toThrowError( - /Number of vectors \(3\) exceeds number of dimensions \(2\)/); - }); - - it('Mismatching dimensions input throws Error', () => { - const xs: Tensor1D[] = - [tf.tensor1d([1, 2, 3]), tf.tensor1d([-1, 5, 1]), tf.tensor1d([0, 0])]; - - expect(() => tf.linalg.gramSchmidt(xs)).toThrowError(/Non-unique/); - }); - - it('Empty input throws Error', () => { - expect(() => tf.linalg.gramSchmidt([])).toThrowError(/empty/); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/linalg/qr.ts b/tfjs-master/tfjs-core/src/ops/linalg/qr.ts deleted file mode 100644 index b78e8c260..000000000 --- a/tfjs-master/tfjs-core/src/ops/linalg/qr.ts +++ /dev/null @@ -1,201 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {ENGINE} from '../../engine'; -import {dispose} from '../../globals'; -import {Tensor, Tensor2D} from '../../tensor'; -import {assert} from '../../util'; - -import {clone} from '../clone'; -import {concat} from '../concat'; -import {div} from '../div'; -import {eye} from '../eye'; -import {greater} from '../greater'; -import {matMul} from '../mat_mul'; -import {mul} from '../mul'; -import {neg} from '../neg'; -import {norm} from '../norm'; -import {op} from '../operation'; -import {reshape} from '../reshape'; -import {slice} from '../slice'; -import {stack} from '../stack'; -import {sub} from '../sub'; -import {tensor2d} from '../tensor2d'; -import {transpose} from '../transpose'; -import {unstack} from '../unstack'; -import {where} from '../where'; - -/** - * Compute QR decomposition of m-by-n matrix using Householder transformation. - * - * Implementation based on - * [http://www.cs.cornell.edu/~bindel/class/cs6210-f09/lec18.pdf] - * (http://www.cs.cornell.edu/~bindel/class/cs6210-f09/lec18.pdf) - * - * ```js - * const a = tf.tensor2d([[1, 2], [3, 4]]); - * let [q, r] = tf.linalg.qr(a); - * console.log('Q'); - * q.print(); - * console.log('R'); - * r.print(); - * console.log('Orthogonalized'); - * q.dot(q.transpose()).print() // should be nearly the identity matrix. - * console.log('Reconstructed'); - * q.dot(r).print(); // should be nearly [[1, 2], [3, 4]]; - * ``` - * - * @param x The `tf.Tensor` to be QR-decomposed. Must have rank >= 2. Suppose - * it has the shape `[..., M, N]`. - * @param fullMatrices An optional boolean parameter. Defaults to `false`. - * If `true`, compute full-sized `Q`. If `false` (the default), - * compute only the leading N columns of `Q` and `R`. - * @returns An `Array` of two `tf.Tensor`s: `[Q, R]`. `Q` is a unitary matrix, - * i.e., its columns all have unit norm and are mutually orthogonal. - * If `M >= N`, - * If `fullMatrices` is `false` (default), - * - `Q` has a shape of `[..., M, N]`, - * - `R` has a shape of `[..., N, N]`. - * If `fullMatrices` is `true` (default), - * - `Q` has a shape of `[..., M, M]`, - * - `R` has a shape of `[..., M, N]`. - * If `M < N`, - * - `Q` has a shape of `[..., M, M]`, - * - `R` has a shape of `[..., M, N]`. - * @throws If the rank of `x` is less than 2. - * - * @doc {heading:'Operations', - * subheading:'Linear Algebra', - * namespace:'linalg'} - */ -function qr_(x: Tensor, fullMatrices = false): [Tensor, Tensor] { - assert( - x.rank >= 2, - () => `qr() requires input tensor to have a rank >= 2, but got rank ${ - x.rank}`); - - if (x.rank === 2) { - return qr2d(x as Tensor2D, fullMatrices); - } else { - // Rank > 2. - // TODO(cais): Below we split the input into individual 2D tensors, - // perform QR decomposition on them and then stack the results back - // together. We should explore whether this can be parallelized. - const outerDimsProd = x.shape.slice(0, x.shape.length - 2) - .reduce((value, prev) => value * prev); - const x2ds = unstack( - reshape( - x, - [ - outerDimsProd, x.shape[x.shape.length - 2], - x.shape[x.shape.length - 1] - ]), - 0); - const q2ds: Tensor2D[] = []; - const r2ds: Tensor2D[] = []; - x2ds.forEach(x2d => { - const [q2d, r2d] = qr2d(x2d as Tensor2D, fullMatrices); - q2ds.push(q2d); - r2ds.push(r2d); - }); - const q = reshape(stack(q2ds, 0), x.shape); - const r = reshape(stack(r2ds, 0), x.shape); - return [q, r]; - } -} - -function qr2d(x: Tensor2D, fullMatrices = false): [Tensor2D, Tensor2D] { - return ENGINE.tidy(() => { - assert( - x.shape.length === 2, - () => `qr2d() requires a 2D Tensor, but got a ${ - x.shape.length}D Tensor.`); - - const m = x.shape[0]; - const n = x.shape[1]; - - let q = eye(m); // Orthogonal transform so far. - let r = clone(x); // Transformed matrix so far. - - const one2D = tensor2d([[1]], [1, 1]); - let w: Tensor2D = clone(one2D); - - const iters = m >= n ? n : m; - for (let j = 0; j < iters; ++j) { - // This tidy within the for-loop ensures we clean up temporary - // tensors as soon as they are no longer needed. - const rTemp = r; - const wTemp = w; - const qTemp = q; - [w, r, q] = ENGINE.tidy((): [Tensor2D, Tensor2D, Tensor2D] => { - // Find H = I - tau * w * w', to put zeros below R(j, j). - const rjEnd1 = slice(r, [j, j], [m - j, 1]); - const normX = norm(rjEnd1); - const rjj = slice(r, [j, j], [1, 1]); - - // The sign() function returns 0 on 0, which causes division by zero. - const s = where(greater(rjj, 0), tensor2d([[-1]]), tensor2d([[1]])); - - const u1 = sub(rjj, mul(s, normX)); - const wPre = div(rjEnd1, u1); - if (wPre.shape[0] === 1) { - w = clone(one2D); - } else { - w = concat( - [ - one2D, - slice(wPre, [1, 0], [wPre.shape[0] - 1, wPre.shape[1]]) as - Tensor2D - ], - 0); - } - const tau = neg(div(matMul(s, u1), normX)) as Tensor2D; - - // -- R := HR, Q := QH. - const rjEndAll = slice(r, [j, 0], [m - j, n]); - const tauTimesW: Tensor2D = mul(tau, w); - const wT: Tensor2D = transpose(w); - if (j === 0) { - r = sub(rjEndAll, matMul(tauTimesW, matMul(wT, rjEndAll))); - } else { - const rTimesTau: Tensor2D = - sub(rjEndAll, matMul(tauTimesW, matMul(wT, rjEndAll))); - r = concat([slice(r, [0, 0], [j, n]), rTimesTau], 0); - } - const tawTimesWT: Tensor2D = transpose(tauTimesW); - const qAllJEnd = slice(q, [0, j], [m, q.shape[1] - j]); - if (j === 0) { - q = sub(qAllJEnd, matMul(matMul(qAllJEnd, w), tawTimesWT)); - } else { - const qTimesTau: Tensor2D = - sub(qAllJEnd, matMul(matMul(qAllJEnd, w), tawTimesWT)); - q = concat([slice(q, [0, 0], [m, j]), qTimesTau], 1); - } - return [w, r, q]; - }); - dispose([rTemp, wTemp, qTemp]); - } - - if (!fullMatrices && m > n) { - q = slice(q, [0, 0], [m, n]); - r = slice(r, [0, 0], [n, n]); - } - - return [q, r]; - }) as [Tensor2D, Tensor2D]; -} - -export const qr = /* @__PURE__ */ op({qr_}); diff --git a/tfjs-master/tfjs-core/src/ops/linalg/qr_test.ts b/tfjs-master/tfjs-core/src/ops/linalg/qr_test.ts deleted file mode 100644 index 6361ff486..000000000 --- a/tfjs-master/tfjs-core/src/ops/linalg/qr_test.ts +++ /dev/null @@ -1,144 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../../index'; -import {ALL_ENVS, describeWithFlags} from '../../jasmine_util'; -import {expectArraysClose} from '../../test_util'; - -import {scalar, tensor1d, tensor2d, tensor3d, tensor4d} from '../ops'; - -describeWithFlags('qr', ALL_ENVS, () => { - it('1x1', async () => { - const x = tensor2d([[10]], [1, 1]); - const [q, r] = tf.linalg.qr(x); - expectArraysClose(await q.array(), [[-1]]); - expectArraysClose(await r.array(), [[-10]]); - }); - - it('2x2', async () => { - const x = tensor2d([[1, 3], [-2, -4]], [2, 2]); - const [q, r] = tf.linalg.qr(x); - expectArraysClose(await q.array(), [[-0.4472, -0.8944], [0.8944, -0.4472]]); - expectArraysClose(await r.array(), [[-2.2361, -4.9193], [0, -0.8944]]); - }); - - it('2x2x2', async () => { - const x = tensor3d([[[-1, -3], [2, 4]], [[1, 3], [-2, -4]]], [2, 2, 2]); - const [q, r] = tf.linalg.qr(x); - expectArraysClose(await q.array(), [ - [[-0.4472, -0.8944], [0.8944, -0.4472]], - [[-0.4472, -0.8944], [0.8944, -0.4472]] - ]); - expectArraysClose( - await r.array(), - [[[2.2361, 4.9193], [0, 0.8944]], [[-2.2361, -4.9193], [0, -0.8944]]]); - }); - - it('2x1x2x2', async () => { - const x = - tensor4d([[[[-1, -3], [2, 4]]], [[[1, 3], [-2, -4]]]], [2, 1, 2, 2]); - const [q, r] = tf.linalg.qr(x); - expectArraysClose(await q.array(), [ - [[[-0.4472, -0.8944], [0.8944, -0.4472]]], - [[[-0.4472, -0.8944], [0.8944, -0.4472]]], - ]); - expectArraysClose(await r.array(), [ - [[[2.2361, 4.9193], [0, 0.8944]]], [[[-2.2361, -4.9193], [0, -0.8944]]] - ]); - }); - - it('3x3', async () => { - const x = tensor2d([[1, 3, 2], [-2, 0, 7], [8, -9, 4]], [3, 3]); - const [q, r] = tf.linalg.qr(x); - expectArraysClose(await q.array(), [ - [-0.1204, 0.8729, 0.4729], [0.2408, -0.4364, 0.8669], - [-0.9631, -0.2182, 0.1576] - ]); - expectArraysClose( - await r.array(), - [[-8.3066, 8.3066, -2.4077], [0, 4.5826, -2.1822], [0, 0, 7.6447]]); - }); - - it('3x3, zero on diagonal', async () => { - const x = tensor2d([[0, 2, 2], [1, 1, 1], [0, 1, 2]], [3, 3]); - const [q, r] = tf.linalg.qr(x); - expectArraysClose(await q.data(), [ - [0., -0.89442719, 0.4472136], [1., 0., 0.], [0., -0.4472136, -0.89442719] - ]); - expectArraysClose( - await r.data(), - [[1., 1., 1.], [0., -2.23606798, -2.68328157], [0., 0., -0.89442719]]); - }); - - it('3x2, fullMatrices = default false', async () => { - const x = tensor2d([[1, 2], [3, -3], [-2, 1]], [3, 2]); - const [q, r] = tf.linalg.qr(x); - expectArraysClose( - await q.array(), - [[-0.2673, 0.9221], [-0.8018, -0.3738], [0.5345, -0.0997]]); - expectArraysClose(await r.array(), [[-3.7417, 2.4054], [0, 2.8661]]); - }); - - it('3x2, fullMatrices = true', async () => { - const x = tensor2d([[1, 2], [3, -3], [-2, 1]], [3, 2]); - const [q, r] = tf.linalg.qr(x, true); - expectArraysClose(await q.array(), [ - [-0.2673, 0.9221, 0.2798], [-0.8018, -0.3738, 0.4663], - [0.5345, -0.0997, 0.8393] - ]); - expectArraysClose( - await r.array(), [[-3.7417, 2.4054], [0, 2.8661], [0, 0]]); - }); - - it('2x3, fullMatrices = default false', async () => { - const x = tensor2d([[1, 2, 3], [-3, -2, 1]], [2, 3]); - const [q, r] = tf.linalg.qr(x); - expectArraysClose( - await q.array(), [[-0.3162278, -0.9486833], [0.9486833, -0.31622773]]); - expectArraysClose( - await r.array(), - [[-3.162, -2.5298, -2.3842e-07], [0, -1.2649, -3.162]]); - }); - - it('2x3, fullMatrices = true', async () => { - const x = tensor2d([[1, 2, 3], [-3, -2, 1]], [2, 3]); - const [q, r] = tf.linalg.qr(x, true); - expectArraysClose( - await q.array(), [[-0.3162278, -0.9486833], [0.9486833, -0.31622773]]); - expectArraysClose( - await r.array(), - [[-3.162, -2.5298, -2.3842e-07], [0, -1.2649, -3.162]]); - }); - - it('Does not leak memory', () => { - const x = tensor2d([[1, 3], [-2, -4]], [2, 2]); - // The first call to qr creates and keeps internal singleton tensors. - // Subsequent calls should always create exactly two tensors. - tf.linalg.qr(x); - // Count before real call. - const numTensors = tf.memory().numTensors; - tf.linalg.qr(x); - expect(tf.memory().numTensors).toEqual(numTensors + 2); - }); - - it('Insuffient input tensor rank leads to error', () => { - const x1 = scalar(12); - expect(() => tf.linalg.qr(x1)).toThrowError(/rank >= 2.*got rank 0/); - const x2 = tensor1d([12]); - expect(() => tf.linalg.qr(x2)).toThrowError(/rank >= 2.*got rank 1/); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/linspace.ts b/tfjs-master/tfjs-core/src/ops/linspace.ts deleted file mode 100644 index 3cc500eac..000000000 --- a/tfjs-master/tfjs-core/src/ops/linspace.ts +++ /dev/null @@ -1,42 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {LinSpace, LinSpaceAttrs} from '../kernel_names'; -import {NamedAttrMap} from '../kernel_registry'; -import {Tensor1D} from '../tensor'; - -/** - * Return an evenly spaced sequence of numbers over the given interval. - * - * ```js - * tf.linspace(0, 9, 10).print(); - * ``` - * @param start The start value of the sequence. - * @param stop The end value of the sequence. - * @param num The number of values to generate. - * - * @doc {heading: 'Tensors', subheading: 'Creation'} - */ -export function linspace(start: number, stop: number, num: number): Tensor1D { - if (num <= 0) { - throw new Error('The number of values should be positive.'); - } - - const attrs: LinSpaceAttrs = {start, stop, num}; - return ENGINE.runKernel(LinSpace, {}, attrs as unknown as NamedAttrMap); -} diff --git a/tfjs-master/tfjs-core/src/ops/linspace_test.ts b/tfjs-master/tfjs-core/src/ops/linspace_test.ts deleted file mode 100644 index af2502060..000000000 --- a/tfjs-master/tfjs-core/src/ops/linspace_test.ts +++ /dev/null @@ -1,66 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose, expectArraysEqual} from '../test_util'; - -describeWithFlags('linspace', ALL_ENVS, () => { - it('start stop', async () => { - const a = tf.linspace(1, 10, 10); - expectArraysEqual( - await a.data(), [1., 2., 3., 4., 5., 6., 7., 8., 9., 10.]); - expect(a.shape).toEqual([10]); - - const b = tf.linspace(12, 17, 8); - expectArraysClose(await b.data(), [ - 12., 12.71428571, 13.42857143, 14.14285714, 14.85714286, 15.57142857, - 16.28571429, 17. - ]); - expect(b.shape).toEqual([8]); - - const c = tf.linspace(9, 0, 6); - expectArraysClose(await c.data(), [9., 7.2, 5.4, 3.6, 1.8, 0.]); - expect(c.shape).toEqual([6]); - }); - - it('negative start stop', async () => { - const a = tf.linspace(-4, 5, 6); - expectArraysClose(await a.data(), [-4., -2.2, -0.4, 1.4, 3.2, 5.]); - expect(a.shape).toEqual([6]); - }); - - it('start negative stop', async () => { - const a = tf.linspace(4, -5, 6); - expectArraysClose(await a.data(), [4., 2.2, 0.4, -1.4, -3.2, -5.]); - expect(a.shape).toEqual([6]); - }); - - it('negative start negative stop', async () => { - const a = tf.linspace(-4, -5, 6); - expectArraysClose(await a.data(), [-4., -4.2, -4.4, -4.6, -4.8, -5.]); - expect(a.shape).toEqual([6]); - - const b = tf.linspace(-9, -4, 5); - expectArraysClose(await b.data(), [-9., -7.75, -6.5, -5.25, -4.]); - expect(b.shape).toEqual([5]); - }); - - it('should throw with no samples', () => { - expect(() => tf.linspace(2, 10, 0)).toThrow(); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/local_response_normalization.ts b/tfjs-master/tfjs-core/src/ops/local_response_normalization.ts deleted file mode 100644 index 5d08cbc1d..000000000 --- a/tfjs-master/tfjs-core/src/ops/local_response_normalization.ts +++ /dev/null @@ -1,80 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {LRN, LRNAttrs, LRNInputs} from '../kernel_names'; -import {NamedAttrMap} from '../kernel_registry'; -import {Tensor3D, Tensor4D} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; -import * as util from '../util'; - -import {op} from './operation'; -import {reshape} from './reshape'; - -/** - * Normalizes the activation of a local neighborhood across or within - * channels. - * - * @param x The input tensor. The 4-D input tensor is treated as a 3-D array - * of 1D vectors (along the last dimension), and each vector is - * normalized independently. - * @param depthRadius The number of adjacent channels in the 1D normalization - * window. - * @param bias A constant bias term for the basis. - * @param alpha A scale factor, usually positive. - * @param beta An exponent. - * - * @doc {heading: 'Operations', subheading: 'Normalization'} - */ -function localResponseNormalization_( - x: T|TensorLike, depthRadius = 5, bias = 1, alpha = 1, beta = 0.5): T { - const $x = convertToTensor(x, 'x', 'localResponseNormalization'); - util.assert( - $x.rank === 4 || $x.rank === 3, - () => `Error in localResponseNormalization: x must be rank 3 or 4 but got - rank ${$x.rank}.`); - util.assert( - util.isInt(depthRadius), - () => `Error in localResponseNormalization: depthRadius must be an ` + - `integer but got depthRadius ${depthRadius}.`); - - let x4D = $x as Tensor4D; - let reshapedTo4D = false; - if ($x.rank === 3) { - reshapedTo4D = true; - x4D = reshape($x, [1, $x.shape[0], $x.shape[1], $x.shape[2]]); - } - - const inputs: LRNInputs = {x: x4D}; - - const attrs: LRNAttrs = {depthRadius, bias, alpha, beta}; - - // tslint:disable-next-line: no-unnecessary-type-assertion - const res = ENGINE.runKernel( - LRN, inputs as unknown as NamedTensorMap, - attrs as unknown as NamedAttrMap) as T; - - if (reshapedTo4D) { - return reshape(res, [res.shape[1], res.shape[2], res.shape[3]]) as T; - } else { - return res; - } -} - -export const localResponseNormalization = /* @__PURE__ */ op({localResponseNormalization_}); diff --git a/tfjs-master/tfjs-core/src/ops/local_response_normalization_backprop.ts b/tfjs-master/tfjs-core/src/ops/local_response_normalization_backprop.ts deleted file mode 100644 index bd6d1a784..000000000 --- a/tfjs-master/tfjs-core/src/ops/local_response_normalization_backprop.ts +++ /dev/null @@ -1,38 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {LRNGrad, LRNGradAttrs, LRNGradInputs} from '../kernel_names'; -import {NamedAttrMap} from '../kernel_registry'; -import {Tensor4D} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; - -import {op} from './operation'; - -function localResponseNormalizationBackprop_( - x: T, y: T, dy: T, depthRadius = 5, bias = 1, alpha = 1, beta = 0.5): T { - const inputs: LRNGradInputs = {x, y, dy}; - - const attrs: LRNGradAttrs = {depthRadius, bias, alpha, beta}; - - return ENGINE.runKernel( - LRNGrad, inputs as unknown as NamedTensorMap, - attrs as unknown as NamedAttrMap); -} - -export const localResponseNormalizationBackprop = - op({localResponseNormalizationBackprop_}); diff --git a/tfjs-master/tfjs-core/src/ops/local_response_normalization_test.ts b/tfjs-master/tfjs-core/src/ops/local_response_normalization_test.ts deleted file mode 100644 index 0f8ce5bb7..000000000 --- a/tfjs-master/tfjs-core/src/ops/local_response_normalization_test.ts +++ /dev/null @@ -1,1069 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {Tensor4D} from '../tensor'; -import {expectArraysClose, expectArraysEqual} from '../test_util'; - -const sqArr = (arr: number[]) => arr.map(d => d * d); -const sumArr = (arr: number[]) => arr.reduce((prev, curr) => prev + curr, 0); - -// tslint:disable-next-line:no-any -const flatten = (arr: any): number[] => { - // tslint:disable-next-line:no-any - return arr.reduce((prev: any, curr: any) => { - return prev.concat(Array.isArray(curr) ? flatten(curr) : curr); - }, []); -}; - -describeWithFlags('localResponseNormalization with Tensor3D', ALL_ENVS, () => { - it('throws error with invalid input', () => { - // tslint:disable-next-line:no-any - const x: any = tf.tensor2d([1, 20, 300, 4], [1, 4]); - const radius = 3; - - expect(() => x.localResponseNormalization(radius)).toThrowError(); - }); - - it('throws error with invalid radius', () => { - const x = tf.tensor3d([1, 20, 300, 4], [1, 1, 4]); - const radius = 0.5; - - expect(() => x.localResponseNormalization(radius)).toThrowError(); - }); - - it('computes simple normalization across channels', async () => { - const xT = tf.tensor3d([1, 20, 300, 4], [1, 1, 4]); - const radius = 1; - const bias = 1; - const alpha = 1; - const beta = 0.5; - - const result = xT.localResponseNormalization(radius, bias, alpha, beta); - - const f = (...vals: number[]) => - Math.pow(bias + alpha * sumArr(sqArr(vals)), -beta); - - const x = await xT.array(); - expectArraysClose(await result.data(), [ - x[0][0][0] * f(x[0][0][0], x[0][0][1]), - x[0][0][1] * f(x[0][0][0], x[0][0][1], x[0][0][2]), - x[0][0][2] * f(x[0][0][1], x[0][0][2], x[0][0][3]), - x[0][0][3] * f(x[0][0][2], x[0][0][3]), - ]); - }); - - it('uses beta = 1.0 to test GPU optimization', async () => { - const xT = tf.tensor3d([1, 20, 300, 4], [1, 1, 4]); - const radius = 1; - const bias = 1; - const alpha = 1; - const beta = 1.0; - - const result = xT.localResponseNormalization(radius, bias, alpha, beta); - - const f = (...vals: number[]) => - Math.pow(bias + alpha * sumArr(sqArr(vals)), -beta); - - const x = await xT.array(); - expectArraysClose(await result.data(), [ - x[0][0][0] * f(x[0][0][0], x[0][0][1]), - x[0][0][1] * f(x[0][0][0], x[0][0][1], x[0][0][2]), - x[0][0][2] * f(x[0][0][1], x[0][0][2], x[0][0][3]), - x[0][0][3] * f(x[0][0][2], x[0][0][3]), - ]); - }); - - it('uses beta = 0.75 to test GPU optimization', async () => { - const xT = tf.tensor3d([1, 20, 300, 4], [1, 1, 4]); - const radius = 1; - const bias = 1; - const alpha = 1; - const beta = 0.75; - - const result = xT.localResponseNormalization(radius, bias, alpha, beta); - - const f = (...vals: number[]) => - Math.pow(bias + alpha * sumArr(sqArr(vals)), -beta); - - const x = await xT.array(); - expectArraysClose(await result.data(), [ - x[0][0][0] * f(x[0][0][0], x[0][0][1]), - x[0][0][1] * f(x[0][0][0], x[0][0][1], x[0][0][2]), - x[0][0][2] * f(x[0][0][1], x[0][0][2], x[0][0][3]), - x[0][0][3] * f(x[0][0][2], x[0][0][3]), - ]); - }); - - it('computes complex normalization across channels', async () => { - const xT = tf.tensor3d( - [1, 20, 300, 4, 5, 15, 24, 200, 1, 20, 300, 4, 5, 15, 24, 200], - [2, 2, 4]); - const radius = 1; - const bias = 1; - const alpha = 1; - const beta = 0.5; - const result = xT.localResponseNormalization(radius, bias, alpha, beta); - - const f = (...vals: number[]) => - Math.pow(bias + alpha * sumArr(sqArr(vals)), -beta); - - // 1 | 2 | 3 | 4 - // ------- | ------- | ------- | ------- - // o x . . | x o x . | . x o x | . . x o - - const x = await xT.array(); - expectArraysClose(await result.data(), [ - // 1 - 4 - x[0][0][0] * f(x[0][0][0], x[0][0][1]), - x[0][0][1] * f(x[0][0][0], x[0][0][1], x[0][0][2]), - x[0][0][2] * f(x[0][0][1], x[0][0][2], x[0][0][3]), - x[0][0][3] * f(x[0][0][2], x[0][0][3]), - - // 1 - 4 - x[0][1][0] * f(x[0][1][0], x[0][1][1]), - x[0][1][1] * f(x[0][1][0], x[0][1][1], x[0][1][2]), - x[0][1][2] * f(x[0][1][1], x[0][1][2], x[0][1][3]), - x[0][1][3] * f(x[0][1][2], x[0][1][3]), - - // 1 - 4 - x[1][0][0] * f(x[1][0][0], x[1][0][1]), - x[1][0][1] * f(x[1][0][0], x[1][0][1], x[1][0][2]), - x[1][0][2] * f(x[1][0][1], x[1][0][2], x[1][0][3]), - x[1][0][3] * f(x[1][0][2], x[1][0][3]), - - // 1 - 4 - x[1][1][0] * f(x[1][1][0], x[1][1][1]), - x[1][1][1] * f(x[1][1][0], x[1][1][1], x[1][1][2]), - x[1][1][2] * f(x[1][1][1], x[1][1][2], x[1][1][3]), - x[1][1][3] * f(x[1][1][2], x[1][1][3]), - ]); - }); - - it('yields same result as tensorflow', async () => { - // t = tf.random_uniform([1, 3, 3, 8]) - // l = tf.nn.lrn(t, depth_radius=2) - // print(tf.Session().run([t, l])) - - const input = [ - [ - [ - 0.95782757, 0.12892687, 0.63624668, 0.70160735, 0.77376258, - 0.54166114, 0.71172535, 0.65087497 - ], - [ - 0.91872108, 0.38846886, 0.37847793, 0.50477624, 0.42154622, - 0.43310916, 0.36253822, 0.07576156 - ], - [ - 0.48662257, 0.4154036, 0.81704032, 0.91660416, 0.87671542, 0.64215934, - 0.29933751, 0.90671134 - ] - ], - - [ - [ - 0.6208992, 0.60847163, 0.41475761, 0.2127713, 0.65306914, 0.13923979, - 0.32003641, 0.28183973 - ], - [ - 0.04751575, 0.26870155, 0.45150304, 0.58678186, 0.99118924, - 0.58878231, 0.30913198, 0.18836617 - ], - [ - 0.16166461, 0.56322742, 0.67908955, 0.2269547, 0.38491273, 0.97113752, - 0.51210916, 0.69430435 - ] - ], - - [ - [ - 0.06625497, 0.13011181, 0.59202921, 0.88871598, 0.6366322, 0.47911358, - 0.96530843, 0.74259472 - ], - [ - 0.62660718, 0.0445286, 0.18430257, 0.76863647, 0.87511849, 0.53588808, - 0.27980685, 0.30281997 - ], - [ - 0.73987067, 0.91034842, 0.26241004, 0.72832751, 0.78974342, - 0.50751543, 0.05434644, 0.8231523 - ] - ] - ]; - - const expected = [ - [ - [ - 0.62630326, 0.07662392, 0.34354961, 0.41885775, 0.42621866, - 0.29751951, 0.42365381, 0.4364861 - ], - [ - 0.62828875, 0.251122, 0.23605582, 0.36483878, 0.30624411, 0.32672295, - 0.29576892, 0.06582346 - ], - [ - 0.3376624, 0.24321821, 0.42558169, 0.46646208, 0.45103404, 0.32380751, - 0.17021206, 0.59476018 - ] - ], - - [ - [ - 0.44719055, 0.43318295, 0.26775005, 0.14921051, 0.49148726, - 0.10764983, 0.25084552, 0.25714993 - ], - [ - 0.04202608, 0.21094096, 0.27973703, 0.34166718, 0.57487047, - 0.35158369, 0.19708875, 0.15495601 - ], - [ - 0.12034657, 0.41341963, 0.47968671, 0.13278878, 0.22735766, - 0.57154536, 0.30411762, 0.42352781 - ] - ], - - [ - [ - 0.05656794, 0.08849642, 0.36951816, 0.53186077, 0.33065733, - 0.24236222, 0.54666328, 0.45085984 - ], - [ - 0.52425432, 0.03133496, 0.11043368, 0.46954039, 0.5271349, 0.31946796, - 0.1876673, 0.25085902 - ], - [ - 0.47316891, 0.5277527, 0.13831842, 0.40036613, 0.50113004, 0.28860986, - 0.03395459, 0.59127772 - ] - ] - ]; - - const x = tf.tensor3d(flatten(input), [3, 3, 8]); - const radius = 2; - const bias = 1; - const alpha = 1; - const beta = 0.5; - - const result = x.localResponseNormalization(radius, bias, alpha, beta); - - expectArraysClose(await result.data(), flatten(expected)); - }); - - it('accepts a tensor-like object', async () => { - const x = [[[1, 20, 300, 4]]]; // 1x1x4 - const radius = 1; - const bias = 1; - const alpha = 1; - const beta = 0.5; - - const result = tf.localResponseNormalization(x, radius, bias, alpha, beta); - - const f = (...vals: number[]) => - Math.pow(bias + alpha * sumArr(sqArr(vals)), -beta); - - expectArraysClose(await result.data(), [ - x[0][0][0] * f(x[0][0][0], x[0][0][1]), - x[0][0][1] * f(x[0][0][0], x[0][0][1], x[0][0][2]), - x[0][0][2] * f(x[0][0][1], x[0][0][2], x[0][0][3]), - x[0][0][3] * f(x[0][0][2], x[0][0][3]), - ]); - }); -}); - -describeWithFlags('localResponseNormalization with Tensor4D', ALL_ENVS, () => { - it('throws error with invalid input', () => { - // tslint:disable-next-line:no-any - const x: any = tf.tensor2d([1, 20, 300, 4], [1, 4]); - const radius = 3; - - expect(() => x.localResponseNormalization(radius)).toThrowError(); - }); - - it('throws error with invalid radius', () => { - const x = tf.tensor4d([1, 20, 300, 4], [1, 1, 1, 4]); - const radius = 0.5; - - expect(() => x.localResponseNormalization(radius)).toThrowError(); - }); - - it('computes simple normalization across channels', async () => { - const xT = tf.tensor4d([1, 20, 300, 4, 1, 20, 300, 4], [2, 1, 1, 4]); - const radius = 1; - const bias = 1; - const alpha = 1; - const beta = 0.5; - - const result = xT.localResponseNormalization(radius, bias, alpha, beta); - - const f = (...vals: number[]) => - Math.pow(bias + alpha * sumArr(sqArr(vals)), -beta); - - // Easier to read using these vars - const b0 = 0; - const b1 = 1; - const x = await xT.array(); - expectArraysClose(await result.data(), [ - x[b0][0][0][0] * f(x[b0][0][0][0], x[b0][0][0][1]), - x[b0][0][0][1] * f(x[b0][0][0][0], x[b0][0][0][1], x[b0][0][0][2]), - x[b0][0][0][2] * f(x[b0][0][0][1], x[b0][0][0][2], x[b0][0][0][3]), - x[b0][0][0][3] * f(x[b0][0][0][2], x[b0][0][0][3]), - - x[b1][0][0][0] * f(x[b1][0][0][0], x[b1][0][0][1]), - x[b1][0][0][1] * f(x[b1][0][0][0], x[b1][0][0][1], x[b1][0][0][2]), - x[b1][0][0][2] * f(x[b1][0][0][1], x[b1][0][0][2], x[b1][0][0][3]), - x[b1][0][0][3] * f(x[b1][0][0][2], x[b1][0][0][3]), - ]); - }); - - it('yields same result as tensorflow', async () => { - // t = tf.random_uniform([2, 3, 3, 8]) - // l = tf.nn.lrn(t, depth_radius=2) - // print(tf.Session().run([t, l])) - - const input = [ - [ - [ - [ - 0.5659827, 0.57000327, 0.75555623, 0.89843333, 0.55120194, - 0.53531718, 0.56402838, 0.95481384 - ], - [ - 0.57334661, 0.65172958, 0.75794137, 0.80764937, 0.376616, - 0.92726362, 0.36422753, 0.60535395 - ], - [ - 0.82404268, 0.01054764, 0.4649173, 0.91637003, 0.82287347, 0.043468, - 0.44953859, 0.92056584 - ] - ], - - [ - [ - 0.68583369, 0.52534163, 0.53325927, 0.39608097, 0.9337523, - 0.37397444, 0.81212556, 0.5697 - ], - [ - 0.34278774, 0.57656682, 0.2356832, 0.02636456, 0.49111438, - 0.17981696, 0.65398049, 0.70132935 - ], - [ - 0.14241767, 0.68376505, 0.65419888, 0.69369483, 0.21489143, - 0.46235347, 0.0559243, 0.60612857 - ] - ], - - [ - [ - 0.59678483, 0.09368539, 0.3017447, 0.36870825, 0.68145788, - 0.52048779, 0.46136606, 0.94114387 - ], - [ - 0.3156569, 0.75275254, 0.31970251, 0.3154043, 0.61088014, - 0.13359487, 0.99048364, 0.33625424 - ], - [ - 0.82103574, 0.52066624, 0.63629258, 0.42294252, 0.93214262, - 0.57041013, 0.66087878, 0.7019999 - ] - ] - ], - - [ - [ - [ - 0.21894431, 0.43085241, 0.79883206, 0.19462204, 0.68623316, - 0.08703053, 0.82380795, 0.85634673 - ], - [ - 0.45011401, 0.70312083, 0.86319792, 0.83205295, 0.67109787, - 0.82081223, 0.46556532, 0.46408331 - ], - [ - 0.07028461, 0.0038743, 0.44619524, 0.0611403, 0.96373355, - 0.80561554, 0.42428243, 0.46897113 - ] - ], - - [ - [ - 0.21006894, 0.48764861, 0.36842632, 0.23030031, 0.69685507, - 0.31707478, 0.68662715, 0.0639503 - ], - [ - 0.53940296, 0.50777435, 0.12625301, 0.12324154, 0.89205229, - 0.69380629, 0.33191144, 0.81000078 - ], - [ - 0.52650976, 0.71220326, 0.07246161, 0.08874547, 0.42528927, - 0.36320579, 0.54055619, 0.79342318 - ] - ], - - [ - [ - 0.75916636, 0.74499428, 0.76877356, 0.87210917, 0.93040991, - 0.49491942, 0.70801985, 0.14901721 - ], - [ - 0.27037835, 0.89302075, 0.69147241, 0.23044991, 0.98916364, - 0.60161841, 0.63691151, 0.56759977 - ], - [ - 0.56307781, 0.92782414, 0.25880754, 0.98518133, 0.04097319, - 0.24640906, 0.54566145, 0.99261606 - ] - ] - ] - ]; - - const expected = [ - [ - [ - [ - 0.38019636, 0.32782161, 0.414222, 0.49507114, 0.3040463, 0.28107059, - 0.33586296, 0.60191077 - ], - [ - 0.37577698, 0.37752095, 0.42895618, 0.4225589, 0.2054275, - 0.52219951, 0.23032214, 0.39414096 - ], - [ - 0.59856331, 0.00637784, 0.25168711, 0.5541048, 0.48015645, - 0.02301128, 0.27214608, 0.6427291 - ] - ], - - [ - [ - 0.48127589, 0.35518789, 0.30486941, 0.23976389, 0.52926594, - 0.21061926, 0.46920502, 0.39090639 - ], - [ - 0.27937523, 0.46979892, 0.17829391, 0.02044933, 0.37045884, - 0.12140442, 0.44160855, 0.50198948 - ], - [ - 0.10289387, 0.44164398, 0.41853485, 0.42720893, 0.14580171, - 0.31817055, 0.043797, 0.48155668 - ] - ], - - [ - [ - 0.49458414, 0.07425242, 0.21042404, 0.26262277, 0.46205613, - 0.30202535, 0.27406475, 0.61140078 - ], - [ - 0.23736385, 0.55076694, 0.2135559, 0.21463785, 0.38077739, - 0.08309806, 0.62830603, 0.23137885 - ], - [ - 0.5355776, 0.32740855, 0.3451882, 0.24221195, 0.51988536, - 0.31387195, 0.37391993, 0.46748781 - ] - ] - ], - - [ - [ - [ - 0.16003507, 0.31178808, 0.51775187, 0.12722474, 0.40769571, - 0.05085804, 0.48455271, 0.5505302 - ], - [ - 0.2880325, 0.39714804, 0.45591024, 0.4131493, 0.34525412, 0.4554069, - 0.29119283, 0.31980222 - ], - [ - 0.0640529, 0.00352532, 0.3052578, 0.03666528, 0.56009793, - 0.46656418, 0.24587312, 0.32762629 - ] - ], - - [ - [ - 0.17643087, 0.40210918, 0.2634095, 0.16233148, 0.4649446, - 0.21803913, 0.47819966, 0.05093931 - ], - [ - 0.43121469, 0.403974, 0.08191212, 0.07693455, 0.57362044, - 0.39671475, 0.19025819, 0.54028469 - ], - [ - 0.39356521, 0.53120333, 0.05151648, 0.06554616, 0.33433318, - 0.2425479, 0.36161765, 0.5536595 - ] - ], - - [ - [ - 0.46011236, 0.39919043, 0.36865807, 0.43511948, 0.46734285, - 0.26861796, 0.43624333, 0.11205748 - ], - [ - 0.17642327, 0.57622254, 0.37609601, 0.12030836, 0.54640025, - 0.34052721, 0.36361033, 0.3926385 - ], - [ - 0.37581176, 0.51741964, 0.14429154, 0.57254595, 0.02646073, - 0.13531584, 0.35629693, 0.64837402 - ] - ] - ] - ]; - - const x = tf.tensor4d(flatten(input), [2, 3, 3, 8]); - const radius = 2; - - const result = x.localResponseNormalization(radius); - - expectArraysClose(await result.data(), flatten(expected)); - }); - - it('yields same result as tensorflow with inner most dims of odd shape', - async () => { - // t = tf.random_uniform([1, 5, 5, 3]) - // l = tf.nn.lrn(t, depth_radius=2) - // print(tf.Session().run([t, l])) - - const input = [[ - [ - [0.08576167, 0.5713569, 0.10008252], - [0.9822943, 0.11068773, 0.5733849], - [0.52175903, 0.7347398, 0.760726], [0.7118578, 0.3927865, 0.7521831], - [0.849753, 0.43948555, 0.42316127] - ], - - [ - [0.5843748, 0.27483034, 0.45537806], - [0.91386235, 0.56130767, 0.2968701], - [0.37907827, 0.11928034, 0.32693362], - [0.8294349, 0.9177762, 0.01197743], - [0.44460166, 0.22238493, 0.93720853] - ], - - [ - [0.12325168, 0.62378526, 0.6220398], - [0.9955342, 0.8281578, 0.9977399], - [0.78915524, 0.48492992, 0.70430815], - [0.856709, 0.91682327, 0.53920233], - [0.9217057, 0.32411182, 0.16391528] - ], - - [ - [0.3235209, 0.43057775, 0.5644517], - [0.93911314, 0.09265935, 0.05458856], - [0.06284857, 0.6895604, 0.88354754], - [0.32220483, 0.72595966, 0.3620714], - [0.15844965, 0.931878, 0.8501971] - ], - - [ - [0.07301581, 0.7518866, 0.40925968], - [0.82419384, 0.40474093, 0.53465044], - [0.34532738, 0.21671772, 0.50855494], - [0.04778886, 0.7952956, 0.64908195], - [0.8807392, 0.09571135, 0.7910882] - ] - ]]; - - const expected = [[ - [ - [0.07398141, 0.4928751, 0.08633514], - [0.6468731, 0.07289152, 0.37759283], - [0.33744285, 0.4751862, 0.49199253], - [0.4770374, 0.2632181, 0.50406057], - [0.58718365, 0.30368677, 0.2924066] - ], - - [ - [0.45850667, 0.21563481, 0.35729447], - [0.6108259, 0.37517825, 0.19842808], - [0.3370665, 0.10606097, 0.29070085], - [0.52141804, 0.5769532, 0.00752952], - [0.30495936, 0.15253738, 0.6428463] - ], - - [ - [0.09209093, 0.46607855, 0.4647744], - [0.51949346, 0.43215245, 0.5206444], - [0.5143535, 0.31606635, 0.45905212], - [0.50611794, 0.54163164, 0.31854454], - [0.65478665, 0.23025146, 0.11644664] - ], - - [ - [0.25507566, 0.3394832, 0.4450343], - [0.68247277, 0.06733745, 0.03967063], - [0.04180532, 0.45867857, 0.587714], - [0.24273802, 0.546913, 0.27277213], [0.097959, 0.5761189, 0.525621] - ], - - [ - [0.05538246, 0.57030565, 0.31042328], - [0.56486595, 0.27739152, 0.36642575], - [0.2892991, 0.18155594, 0.42604348], - [0.03332775, 0.55463576, 0.452667], - [0.56725365, 0.06164437, 0.50951254] - ] - ]]; - - const x = tf.tensor4d(input, [1, 5, 5, 3]); - const radius = 2; - - const result = x.localResponseNormalization(radius); - - expectArraysClose(await result.data(), flatten(expected)); - }); - - it('throws when passed a non-tensor', () => { - const e = - /Argument 'x' passed to 'localResponseNormalization' must be a Tensor/; - expect(() => tf.localResponseNormalization({} as tf.Tensor3D)) - .toThrowError(e); - }); - - it('gradient with 3D input', async () => { - const input = [ - [ - [ - 0.95782757, 0.12892687, 0.63624668, 0.70160735, 0.77376258, - 0.54166114, 0.71172535, 0.65087497 - ], - [ - 0.91872108, 0.38846886, 0.37847793, 0.50477624, 0.42154622, - 0.43310916, 0.36253822, 0.07576156 - ], - [ - 0.48662257, 0.4154036, 0.81704032, 0.91660416, 0.87671542, 0.64215934, - 0.29933751, 0.90671134 - ] - ], - - [ - [ - 0.6208992, 0.60847163, 0.41475761, 0.2127713, 0.65306914, 0.13923979, - 0.32003641, 0.28183973 - ], - [ - 0.04751575, 0.26870155, 0.45150304, 0.58678186, 0.99118924, - 0.58878231, 0.30913198, 0.18836617 - ], - [ - 0.16166461, 0.56322742, 0.67908955, 0.2269547, 0.38491273, 0.97113752, - 0.51210916, 0.69430435 - ] - ], - - [ - [ - 0.06625497, 0.13011181, 0.59202921, 0.88871598, 0.6366322, 0.47911358, - 0.96530843, 0.74259472 - ], - [ - 0.62660718, 0.0445286, 0.18430257, 0.76863647, 0.87511849, 0.53588808, - 0.27980685, 0.30281997 - ], - [ - 0.73987067, 0.91034842, 0.26241004, 0.72832751, 0.78974342, - 0.50751543, 0.05434644, 0.8231523 - ] - ] - ]; - - const expected = [[ - [ - [ - 0.27552658, 0.52414668, 0.11137494, 0.24928074, 0.07215497, - 0.16210511, 0.19277242, 0.38672262 - ], - [ - 0.23314378, 0.38181645, 0.30470729, 0.35180706, 0.37793165, - 0.41450983, 0.60044503, 0.83605933 - ], - [ - 0.51801264, 0.38517883, 0.02934788, 0.03102355, 0.08222333, - 0.09746625, 0.4151727, 0.29936206 - ] - ], - - [ - [ - 0.37059873, 0.32463685, 0.26611608, 0.54228389, 0.30733055, - 0.66392428, 0.55629295, 0.79049641 - ], - [ - 0.87162501, 0.68129337, 0.35793597, 0.18797961, -0.03660985, - 0.23235559, 0.48184156, 0.76417446 - ], - [ - 0.65893668, 0.41059417, 0.26254228, 0.40696776, 0.3330358, 0.01789692, - 0.3162199, 0.28867012 - ] - ], - - [ - [ - 0.83880937, 0.62594998, 0.324698, 0.13046435, 0.09858654, 0.17851587, - 0.09067203, 0.30748016 - ], - [ - 0.57213897, 0.67710453, 0.45385274, 0.19951296, 0.07371041, - 0.20141563, 0.51362634, 0.7163325 - ], - [ - 0.33668244, 0.09696329, 0.33500126, 0.08948036, 0.26512182, - 0.19593786, 0.59144169, 0.379444 - ] - ] - ]]; - const radius = 2.0; - const bias = 1.0; - const alpha = 1.0; - const beta = 0.5; - - const t = tf.tensor3d(input); - const dy = tf.onesLike(t); - - const gradients = tf.grad( - (t: tf.Tensor3D) => - tf.localResponseNormalization(t, radius, bias, alpha, beta))(t, dy); - - expectArraysEqual(gradients.shape, t.shape); - expectArraysClose(await gradients.data(), flatten(expected)); - }); - - it('gradient with clones', () => { - const t = tf.zeros([3, 3, 8]); - const radius = 2.0; - const bias = 1.0; - const alpha = 1.0; - const beta = 0.5; - const dt = tf.grad( - (t: tf.Tensor3D) => - tf.localResponseNormalization(t.clone(), radius, bias, alpha, beta) - .clone())(t); - - expectArraysEqual(dt.shape, t.shape); - }); - - it('gradient with 4D input', async () => { - const input = [ - [ - [ - [ - 0.5659827, 0.57000327, 0.75555623, 0.89843333, 0.55120194, - 0.53531718, 0.56402838, 0.95481384 - ], - [ - 0.57334661, 0.65172958, 0.75794137, 0.80764937, 0.376616, - 0.92726362, 0.36422753, 0.60535395 - ], - [ - 0.82404268, 0.01054764, 0.4649173, 0.91637003, 0.82287347, 0.043468, - 0.44953859, 0.92056584 - ] - ], - - [ - [ - 0.68583369, 0.52534163, 0.53325927, 0.39608097, 0.9337523, - 0.37397444, 0.81212556, 0.5697 - ], - [ - 0.34278774, 0.57656682, 0.2356832, 0.02636456, 0.49111438, - 0.17981696, 0.65398049, 0.70132935 - ], - [ - 0.14241767, 0.68376505, 0.65419888, 0.69369483, 0.21489143, - 0.46235347, 0.0559243, 0.60612857 - ] - ], - - [ - [ - 0.59678483, 0.09368539, 0.3017447, 0.36870825, 0.68145788, - 0.52048779, 0.46136606, 0.94114387 - ], - [ - 0.3156569, 0.75275254, 0.31970251, 0.3154043, 0.61088014, - 0.13359487, 0.99048364, 0.33625424 - ], - [ - 0.82103574, 0.52066624, 0.63629258, 0.42294252, 0.93214262, - 0.57041013, 0.66087878, 0.7019999 - ] - ] - ], - - [ - [ - [ - 0.21894431, 0.43085241, 0.79883206, 0.19462204, 0.68623316, - 0.08703053, 0.82380795, 0.85634673 - ], - [ - 0.45011401, 0.70312083, 0.86319792, 0.83205295, 0.67109787, - 0.82081223, 0.46556532, 0.46408331 - ], - [ - 0.07028461, 0.0038743, 0.44619524, 0.0611403, 0.96373355, - 0.80561554, 0.42428243, 0.46897113 - ] - ], - - [ - [ - 0.21006894, 0.48764861, 0.36842632, 0.23030031, 0.69685507, - 0.31707478, 0.68662715, 0.0639503 - ], - [ - 0.53940296, 0.50777435, 0.12625301, 0.12324154, 0.89205229, - 0.69380629, 0.33191144, 0.81000078 - ], - [ - 0.52650976, 0.71220326, 0.07246161, 0.08874547, 0.42528927, - 0.36320579, 0.54055619, 0.79342318 - ] - ], - - [ - [ - 0.75916636, 0.74499428, 0.76877356, 0.87210917, 0.93040991, - 0.49491942, 0.70801985, 0.14901721 - ], - [ - 0.27037835, 0.89302075, 0.69147241, 0.23044991, 0.98916364, - 0.60161841, 0.63691151, 0.56759977 - ], - [ - 0.56307781, 0.92782414, 0.25880754, 0.98518133, 0.04097319, - 0.24640906, 0.54566145, 0.99261606 - ] - ] - ] - ]; - - const dyVals = [ - [ - [ - [ - 1.40394282, -1.68962789, -0.21134049, 1.15015793, 1.51244378, - 0.42844626, -2.70123291, 0.06449971 - ], - [ - -0.29038581, 0.67567694, 0.95617437, -1.07383668, 0.20920482, - 0.39050213, -0.81124371, 2.42158198 - ], - [ - -1.01235235, -0.63514435, -1.49017262, -0.01205151, 0.78492945, - -0.20330679, -2.31419802, -0.31220308 - ] - ], - - [ - [ - 0.07061944, -0.46716127, 0.91232526, -1.30444264, -0.07080109, - 0.13207501, 0.26701283, -0.48946589 - ], - [ - -0.74995744, -0.79466617, -1.03790498, -0.32234526, 1.33345711, - 0.11863081, 1.93010819, 0.47857195 - ], - [ - 0.37702683, -0.7804451, 0.45868117, 1.06967258, -0.65336537, - 0.3594887, 0.62512684, 0.77009726 - ] - ], - - [ - [ - 0.76865023, 1.00893021, -0.24408816, -0.3943336, 0.47094285, - -2.61926222, 1.52929449, 0.7862013 - ], - [ - -1.20878386, -0.26222935, -0.9076528, 0.03079577, -0.01467486, - -0.06949636, 0.05466342, 1.44880533 - ], - [ - 0.05611863, 0.15142779, 0.7802065, -1.2623471, 0.09119794, - -0.20110528, 0.17715968, -0.48476508 - ] - ] - ], - - [ - [ - [ - 0.1549256, 0.94472402, -0.70033115, -1.05752802, -0.63035947, - -1.35643113, -0.27211693, 2.33576941 - ], - [ - 0.81070906, -0.58353454, -0.3253817, 2.53953528, -1.40062141, - 1.7728076, -0.59849483, 1.49650824 - ], - [ - -0.00610052, -2.29434419, -1.77995121, -0.66354084, -0.70676774, - -0.81570011, -1.30821037, 0.40997007 - ] - ], - - [ - [ - -1.02013469, -0.74198806, -0.82677251, -0.00890179, -1.62196338, - -0.5095427, 1.26501179, 0.12931485 - ], - [ - -1.14763546, 0.11011696, -0.23312508, 0.29730096, -0.49138394, - -0.27012363, -0.15987533, -1.84277928 - ], - [ - -0.03816459, -0.73517877, -2.00476885, 0.47192496, -0.27395752, - 0.99806124, 1.54439747, -1.02016675 - ] - ], - - [ - [ - -1.27831209, -0.6961385, -0.73713994, -1.97954738, 0.39108652, - -0.46152538, 1.8255372, 2.18119025 - ], - [ - 0.56322283, -1.59858179, 1.54127491, -0.57665956, -1.0098567, - 0.93239671, 0.25231698, -0.7346009 - ], - [ - 0.41614994, -1.20103085, 0.4330301, -1.23348403, -0.46117213, - -0.3780126, 0.35449561, -0.60129249 - ] - ] - ] - ]; - - const depthRadius = 1; - const bias = 1; - const alpha = 1; - const beta = 0.75; - - const expected = [ - [ - [ - [ - 0.88732064, -0.98597342, -0.00569269, 0.09561057, 0.42255375, - 0.30286378, -1.17104781, 0.44769961 - ], - [ - -0.22329885, 0.19271846, 0.41454071, -0.50674957, 0.14660946, - 0.1591837, -0.83707076, 1.19177234 - ], - [ - -0.26728818, -0.3847312, -0.72818488, 0.09040837, 0.24023688, - -0.11545581, -1.09341288, 0.33930668 - ] - ], - - [ - [ - 0.10079086, -0.38184536, 0.60918945, -0.7267822, 0.13867335, - 0.03526202, 0.17270499, -0.2705338 - ], - [ - -0.38344458, -0.15589149, -0.68160093, -0.27644777, 0.79392856, - -0.14384332, 0.67121017, -0.23130262 - ], - [ - 0.31069142, -0.39895257, 0.11755499, 0.39481708, -0.5234766, - 0.2511853, 0.40955079, 0.3492966 - ] - ], - - [ - [ - 0.32660595, 0.7240563, -0.18117335, -0.2649861, 0.67781603, - -1.46250272, 0.8465963, -0.05466701 - ], - [ - -0.71582067, 0.20831716, -0.50778204, 0.07256755, -0.00893679, - -0.03798783, -0.18604305, 0.75747406 - ], - [ - -0.00540833, -0.07677216, 0.41930205, -0.69235319, 0.20631291, - -0.11946303, 0.19601521, -0.21237698 - ] - ] - ], - - [ - [ - [ - 0.0800111, 0.60922205, -0.31155977, -0.46448132, -0.15912701, - -0.72455585, -0.5727275, 0.71780092 - ], - [ - 0.50568235, -0.31544152, -0.40618286, 0.97909468, -1.15286613, - 0.8145386, -0.77758539, 0.93794745 - ], - [ - -0.00535599, -1.99269259, -1.15343952, -0.31053686, 0.01680636, - 0.10109296, -0.66026396, 0.35474917 - ] - ], - - [ - [ - -0.74113333, -0.20625943, -0.4339568, 0.21517368, -0.5734458, - -0.23481363, 0.53855389, 0.05860626 - ], - [ - -0.61435795, 0.29290834, -0.19639145, 0.20930134, -0.08880179, - 0.02209887, 0.21427482, -0.51696646 - ], - [ - 0.13036536, -0.19079237, -1.43941545, 0.42789665, -0.29732707, - 0.52354813, 0.78893, -0.59992862 - ] - ], - - [ - [ - -0.328383, 0.15830949, 0.13110149, -0.492423, 0.46827313, - -0.58950633, 0.56422544, 1.44929576 - ], - [ - 0.46141064, -0.80682266, 0.92562175, -0.28897452, -0.30567497, - 0.50646484, 0.16439518, -0.38878182 - ], - [ - 0.41004074, -0.38593128, 0.42881966, -0.22443436, -0.24573228, - -0.2941249, 0.31119603, -0.17903978 - ] - ] - ] - ]; - - const t = tf.tensor(input); - const dy = tf.tensor(dyVals); - - const gradients = tf.grad( - t => tf.localResponseNormalization( - t as Tensor4D, depthRadius, bias, alpha, beta))(t, dy as Tensor4D); - - expectArraysClose(await gradients.data(), flatten(expected)); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/log.ts b/tfjs-master/tfjs-core/src/ops/log.ts deleted file mode 100644 index de499454a..000000000 --- a/tfjs-master/tfjs-core/src/ops/log.ts +++ /dev/null @@ -1,45 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {Log, LogInputs} from '../kernel_names'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -import {op} from './operation'; - -/** - * Computes natural logarithm of the input `tf.Tensor` element-wise: `ln(x)` - * - * ```js - * const x = tf.tensor1d([1, 2, Math.E]); - * - * x.log().print(); // or tf.log(x) - * ``` - * @param x The input tensor. - * - * @doc {heading: 'Operations', subheading: 'Basic math'} - */ -function log_(x: T|TensorLike): T { - const $x = convertToTensor(x, 'x', 'log', 'float32'); - - const inputs: LogInputs = {x: $x}; - return ENGINE.runKernel(Log, inputs as unknown as NamedTensorMap); -} -export const log = /* @__PURE__ */ op({log_}); diff --git a/tfjs-master/tfjs-core/src/ops/log1p.ts b/tfjs-master/tfjs-core/src/ops/log1p.ts deleted file mode 100644 index 0b085f201..000000000 --- a/tfjs-master/tfjs-core/src/ops/log1p.ts +++ /dev/null @@ -1,46 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {Log1p, Log1pInputs} from '../kernel_names'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -import {op} from './operation'; - -/** - * Computes natural logarithm of the input `tf.Tensor` plus one - * element-wise: `ln(1 + x)` - * - * ```js - * const x = tf.tensor1d([1, 2, Math.E - 1]); - * - * x.log1p().print(); // or tf.log1p(x) - * ``` - * @param x The input tensor. - * - * @doc {heading: 'Operations', subheading: 'Basic math'} - */ -function log1p_(x: T|TensorLike): T { - const $x = convertToTensor(x, 'x', 'log1p'); - - const inputs: Log1pInputs = {x: $x}; - return ENGINE.runKernel(Log1p, inputs as unknown as NamedTensorMap); -} -export const log1p = /* @__PURE__ */ op({log1p_}); diff --git a/tfjs-master/tfjs-core/src/ops/log1p_test.ts b/tfjs-master/tfjs-core/src/ops/log1p_test.ts deleted file mode 100644 index 5befbfaff..000000000 --- a/tfjs-master/tfjs-core/src/ops/log1p_test.ts +++ /dev/null @@ -1,94 +0,0 @@ -/** - * @license - * Copyright 2020 Google Inc. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('log1p', ALL_ENVS, () => { - it('log1p', async () => { - const a = tf.tensor1d([1, 2]); - const r = tf.log1p(a); - expectArraysClose(await r.data(), [Math.log1p(1), Math.log1p(2)]); - }); - - it('log1p propagates NaNs', async () => { - const a = tf.tensor1d([1, NaN]); - const r = tf.log1p(a); - expectArraysClose(await r.data(), [Math.log1p(1), NaN]); - }); - - it('gradients: Scalar', async () => { - const a = tf.scalar(5); - const dy = tf.scalar(3); - - const gradients = tf.grad(a => tf.log1p(a))(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), [3 / (1 + 5)]); - }); - - it('gradient with clones', () => { - const a = tf.scalar(5); - const gradients = tf.grad(a => a.clone().log1p().clone())(a); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - }); - - it('gradients: Tensor1D', async () => { - const a = tf.tensor1d([-1, 2, 3, -5]); - const dy = tf.tensor1d([1, 2, 3, 4]); - - const gradients = tf.grad(a => tf.log1p(a))(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose( - await gradients.data(), - [Infinity, 2 / (1 + 2), 3 / (1 + 3), 4 / (1 + -5)]); - }); - - it('gradients: Tensor2D', async () => { - const a = tf.tensor2d([-3, 1, 2, 3], [2, 2]); - const dy = tf.tensor2d([1, 2, 3, 4], [2, 2]); - - const gradients = tf.grad(a => tf.log1p(a))(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose( - await gradients.data(), - [1 / (1 + -3), 2 / (1 + 1), 3 / (1 + 2), 4 / (1 + 3)]); - }); - - it('throws when passed a non-tensor', () => { - expect(() => tf.log1p({} as tf.Tensor)) - .toThrowError(/Argument 'x' passed to 'log1p' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const r = tf.log1p([1, 2]); - expectArraysClose(await r.data(), [Math.log1p(1), Math.log1p(2)]); - }); - - it('throws for string tensor', () => { - expect(() => tf.log1p('q')) - .toThrowError(/Argument 'x' passed to 'log1p' must be numeric/); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/log_sigmoid.ts b/tfjs-master/tfjs-core/src/ops/log_sigmoid.ts deleted file mode 100644 index 9a6574ad1..000000000 --- a/tfjs-master/tfjs-core/src/ops/log_sigmoid.ts +++ /dev/null @@ -1,63 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {customGrad} from '../gradients'; -import {Tensor} from '../tensor'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -import {mul} from './mul'; -import {neg} from './neg'; -import {op} from './operation'; -import {sigmoid} from './sigmoid'; -import {softplus} from './softplus'; - -/** - * Computes log sigmoid of the input `tf.Tensor` element-wise: - * `logSigmoid(x)`. For numerical stability, we use `-tf.softplus(-x)`. - * - * ```js - * const x = tf.tensor1d([0, 1, -1, .7]); - * - * x.logSigmoid().print(); // or tf.logSigmoid(x) - * ``` - * @param x The input tensor. - * - * @doc {heading: 'Operations', subheading: 'Basic math'} - */ -function logSigmoid_(x: T|TensorLike): T { - const $x = convertToTensor(x, 'x', 'logSigmoid'); - - // Use a custom gradient to maintain previous implementation. - // There is no LogSigmoid kernel in TF so we can't use engine.runKernel - // directly - const customOp = customGrad((x: Tensor) => { - // TODO(yassogba) we can remove the chained softplus call here only - // after backends have modualrized softplus at which point we can call - // engine runKernel(..., Sotfplus, ...) directly. - const value = neg(softplus(neg(x))); - - const gradFunc = (dy: T) => { - const derX = mul(dy, sigmoid(neg(x))); - return derX; - }; - return {value, gradFunc}; - }); - - return customOp($x) as T; -} -export const logSigmoid = /* @__PURE__ */ op({logSigmoid_}); diff --git a/tfjs-master/tfjs-core/src/ops/log_sigmoid_test.ts b/tfjs-master/tfjs-core/src/ops/log_sigmoid_test.ts deleted file mode 100644 index 8e7ee974d..000000000 --- a/tfjs-master/tfjs-core/src/ops/log_sigmoid_test.ts +++ /dev/null @@ -1,162 +0,0 @@ -/** - * @license - * Copyright 2020 Google Inc. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('logSigmoid', ALL_ENVS, () => { - it('basic', async () => { - const values = [1, -3, 2, 7, -4]; - const a = tf.tensor1d(values); - - const result = tf.logSigmoid(a); - - const expected = []; - for (let i = 0; i < a.size; i++) { - expected[i] = Math.log(1 / (1 + Math.exp(-values[i]))); - } - expectArraysClose(await result.data(), expected); - }); - - it('scalar', async () => { - const a = tf.scalar(-2); - - const result = tf.logSigmoid(a); - - const expected = [Math.log(1 / (1 + Math.exp(2)))]; - expectArraysClose(await result.data(), expected); - }); - - it('tensor2D', async () => { - const values = [1, 2, -3, 5]; - const a = tf.tensor2d(values, [2, 2]); - - const result = tf.logSigmoid(a); - - const expected = []; - for (let i = 0; i < a.size; i++) { - expected[i] = Math.log(1 / (1 + Math.exp(-values[i]))); - } - expectArraysClose(await result.data(), expected); - }); - - it('larger magnitude negative inputs', async () => { - const values = [-100, -200, -3000]; - const a = tf.tensor1d(values); - - const result = tf.logSigmoid(a); - - const expected = [-100, -200, -3000]; - - expectArraysClose(await result.data(), expected); - }); - - it('larger magnitude positive inputs', async () => { - const values = [100, 200, 3000, 50000]; - const a = tf.tensor1d(values); - - const result = tf.logSigmoid(a); - - const expected = [0, 0, 0, 0]; - - expectArraysClose(await result.data(), expected); - }); - - it('propagates NaNs', async () => { - const a = tf.tensor1d([3, NaN]); - const res = tf.logSigmoid(a); - expectArraysClose( - await res.data(), [Math.log(1 / (1 + Math.exp(-3))), NaN]); - }); - - it('gradients: Scalar', async () => { - const a = tf.scalar(3); - const dy = tf.scalar(4); - const dyVal = await dy.array(); - - const da = tf.grad(a => tf.logSigmoid(a))(a, dy); - const aVal = await a.array(); - const y = 1 / (1 + Math.exp(aVal)); - expectArraysClose(await da.data(), [dyVal * y]); - }); - - it('gradients: Tensor1D', async () => { - const a = tf.tensor1d([1, 2, -3, 5]); - const aVals = await a.array(); - const dy = tf.tensor1d([1, 2, 3, 4]); - const dyVals = await dy.array(); - const da = tf.grad(a => tf.logSigmoid(a))(a, dy); - - const expected = []; - for (let i = 0; i < a.size; i++) { - const y = 1 / (1 + Math.exp(aVals[i])); - expected[i] = dyVals[i] * y; - } - - expectArraysClose(await da.data(), expected); - }); - - it('gradient with clones', async () => { - const a = tf.tensor1d([1, 2, -3, 5]); - const aVals = await a.array(); - const dy = tf.tensor1d([1, 2, 3, 4]); - const dyVals = await dy.array(); - const da = tf.grad(a => tf.logSigmoid(a.clone()).clone())(a, dy); - - const expected = []; - for (let i = 0; i < a.size; i++) { - const y = 1 / (1 + Math.exp(aVals[i])); - expected[i] = dyVals[i] * y; - } - - expectArraysClose(await da.data(), expected); - }); - - it('gradients: Tensor2D', async () => { - const a = tf.tensor2d([1, 2, -3, 5], [2, 2]); - const dy = tf.tensor2d([1, 2, 3, 4], [2, 2]); - - const da = tf.grad(a => tf.logSigmoid(a))(a, dy); - - const expected = []; - const aVals = await a.data(); - const dyVals = await dy.data(); - for (let i = 0; i < a.size; i++) { - const y = 1 / (1 + Math.exp(aVals[i])); - expected[i] = dyVals[i] * y; - } - - expectArraysClose(await da.data(), expected); - }); - - it('throws when passed a non-tensor', () => { - expect(() => tf.logSigmoid({} as tf.Tensor)) - .toThrowError(/Argument 'x' passed to 'logSigmoid' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const result = tf.logSigmoid(-2); - const expected = [Math.log(1 / (1 + Math.exp(2)))]; - expectArraysClose(await result.data(), expected); - }); - - it('throws for string tensor', () => { - expect(() => tf.logSigmoid('q')) - .toThrowError(/Argument 'x' passed to 'logSigmoid' must be numeric/); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/log_softmax.ts b/tfjs-master/tfjs-core/src/ops/log_softmax.ts deleted file mode 100644 index e1f975e00..000000000 --- a/tfjs-master/tfjs-core/src/ops/log_softmax.ts +++ /dev/null @@ -1,106 +0,0 @@ -/** - * @license - * Copyright 2020 Google Inc. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {customGrad} from '../gradients'; - -import {Tensor} from '../tensor'; -import {GradSaveFunc} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -import {cast} from './cast'; -import {exp} from './exp'; -import {log} from './log'; -import {max} from './max'; -import {mul} from './mul'; -import {op} from './operation'; -import {sub} from './sub'; -import {sum} from './sum'; - -/** - * Computes the log softmax. - * - * ```js - * const a = tf.tensor1d([1, 2, 3]); - * - * a.logSoftmax().print(); // or tf.logSoftmax(a) - * ``` - * - * ```js - * const a = tf.tensor2d([2, 4, 6, 1, 2, 3], [2, 3]); - * - * a.logSoftmax().print(); // or tf.logSoftmax(a) - * ``` - * - * @param logits The logits array. - * @param axis The dimension softmax would be performed on. Defaults to `-1` - * which indicates the last dimension. - * - * @doc {heading: 'Operations', subheading: 'Normalization'} - */ -function logSoftmax_(logits: T|TensorLike, axis = -1): T { - const $logits = convertToTensor(logits, 'logits', 'logSoftmax'); - - if (axis === -1) { - axis = $logits.rank - 1; - } - if (axis !== $logits.rank - 1) { - throw Error( - 'Log Softmax along a non-last dimension is not yet supported. ' + - `Logits was rank ${$logits.rank} and axis was ${axis}`); - } - - // const forward: ForwardFunc = (backend, save) => { - // const keepDims = true; - // const xMax = max(logits, axis, true); - // const shifted = sub(logits, xMax); - // const value = - // sub(cast(shifted, 'float32'), log(sum(exp(shifted), axis, - // keepDims))); - // save([value]); - // return value; - // }; - - // Use a custom gradient for numerical stability. - const customOp = customGrad((logits: Tensor, save: GradSaveFunc) => { - const keepDims = true; - const xMax = max(logits, axis, true); - const shifted = sub(logits, xMax); - const value = - sub(cast(shifted, 'float32'), log(sum(exp(shifted), axis, keepDims))); - save([value]); - - const gradFunc = (dy: Tensor, saved: Tensor[]) => { - const [value] = saved; - const keepDims = true; - const softmax = exp(value); - return sub(dy, mul(sum(dy, axis, keepDims), softmax)); - }; - return {value, gradFunc}; - }); - - return customOp($logits) as T; - - // TODO Use Engine.runKernel when CPU/WebGL/WASM backends implement this. - // const inputs: LogSoftmaxInputs = {logits: $logits}; - // const attrs: LogSoftmaxAttrs = {axis}; - // return ENGINE.runKernel( - // LogSoftmax, inputs as unknown as NamedTensorMap, - // attrs as unknown as NamedAttrMap); -} - -export const logSoftmax = /* @__PURE__ */ op({logSoftmax_}); diff --git a/tfjs-master/tfjs-core/src/ops/log_softmax_test.ts b/tfjs-master/tfjs-core/src/ops/log_softmax_test.ts deleted file mode 100644 index 56c9b442e..000000000 --- a/tfjs-master/tfjs-core/src/ops/log_softmax_test.ts +++ /dev/null @@ -1,84 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('logSoftmax', ALL_ENVS, () => { - it('regular test', async () => { - const y = tf.logSoftmax(tf.tensor1d([2, 1, 3])); - - expectArraysClose(await y.data(), [-1.407606, -2.4076061, -0.407606]); - }); - - it('Huge difference', async () => { - const y = tf.logSoftmax(tf.tensor1d([-1000, +1000])); - - expectArraysClose(await y.data(), [-2000, 0]); - }); - - it('Propagates NaNs', async () => { - const a = tf.tensor1d([2, 1, NaN]); - const y = tf.logSoftmax(a); - expectArraysClose(await y.data(), [NaN, NaN, NaN]); - }); - - it('2D, axis=1', async () => { - const y = tf.logSoftmax(tf.tensor2d([[2, 1, 3], [1, 3, 2]], [2, 3]), 1); - const expected = - [-1.407606, -2.4076061, -0.407606, -2.4076061, -0.4076061, -1.4076061]; - expect(y.rank).toBe(2); - expectArraysClose(await y.data(), expected); - }); - - it('2D, implicit axis=1', async () => { - const y = tf.logSoftmax(tf.tensor2d([[2, 1, 3], [1, 3, 2]], [2, 3])); - const expected = - [-1.407606, -2.4076061, -0.407606, -2.4076061, -0.4076061, -1.4076061]; - expect(y.rank).toBe(2); - expectArraysClose(await y.data(), expected); - }); - - it('1D gradient', async () => { - const x = tf.tensor1d([1, 2, 10]); - const dy = tf.tensor1d([1, 2, 3]); - const dx = tf.grad((x) => x.logSoftmax())(x, dy); - - expect(dx.shape).toEqual(x.shape); - expectArraysClose(await dx.data(), [0.9992599, 1.9979881, -2.9972477]); - }); - - it('2D, axis=0 throws error', () => { - const f = () => { - tf.logSoftmax(tf.tensor2d([[2, 1, 3], [1, 3, 2]], [2, 3]), 0); - }; - expect(f).toThrowError(); - }); - - it('throws when passed a non-tensor', () => { - expect(() => tf.logSoftmax({} as tf.Tensor)) - .toThrowError( - /Argument 'logits' passed to 'logSoftmax' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const y = tf.logSoftmax([2, 1, 3]); - - expectArraysClose(await y.data(), [-1.407606, -2.4076061, -0.407606]); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/log_sum_exp.ts b/tfjs-master/tfjs-core/src/ops/log_sum_exp.ts deleted file mode 100644 index cb9662dae..000000000 --- a/tfjs-master/tfjs-core/src/ops/log_sum_exp.ts +++ /dev/null @@ -1,81 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Tensor} from '../tensor'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; -import {parseAxisParam} from '../util'; - -import {add} from './add'; -import {expandShapeToKeepDim} from './axis_util'; -import {exp} from './exp'; -import {log} from './log'; -import {max} from './max'; -import {op} from './operation'; -import {reshape} from './reshape'; -import {sub} from './sub'; -import {sum} from './sum'; - -/** - * Computes the log(sum(exp(elements across the reduction dimensions))). - * - * Reduces the input along the dimensions given in `axis`. Unless `keepDims` - * is true, the rank of the array is reduced by 1 for each entry in `axis`. - * If `keepDims` is true, the reduced dimensions are retained with length 1. - * If `axis` has no entries, all dimensions are reduced, and an array with a - * single element is returned. - * - * ```js - * const x = tf.tensor1d([1, 2, 3]); - * - * x.logSumExp().print(); // or tf.logSumExp(x) - * ``` - * - * ```js - * const x = tf.tensor2d([1, 2, 3, 4], [2, 2]); - * - * const axis = 1; - * x.logSumExp(axis).print(); // or tf.logSumExp(a, axis) - * ``` - * @param x The input tensor. - * @param axis The dimension(s) to reduce. If null (the default), - * reduces all dimensions. - * @param keepDims If true, retains reduced dimensions with length - * of 1. Defaults to false. - * - * @doc {heading: 'Operations', subheading: 'Reduction'} - */ -function logSumExp_( - x: Tensor|TensorLike, axis: number|number[] = null, keepDims = false): T { - const $x = convertToTensor(x, 'x', 'logSumExp'); - - const axes = parseAxisParam(axis, $x.shape); - const xMax = max($x, axes, true /* keepDims */); - const a = sub($x, xMax); - const b = exp(a); - const c = sum(b, axes); - const d = log(c); - const res = add(reshape(xMax, d.shape), d); - - if (keepDims) { - const newShape = expandShapeToKeepDim(res.shape, axes); - return reshape(res, newShape) as T; - } - return res as T; -} - -export const logSumExp = /* @__PURE__ */ op({logSumExp_}); diff --git a/tfjs-master/tfjs-core/src/ops/log_sum_exp_test.ts b/tfjs-master/tfjs-core/src/ops/log_sum_exp_test.ts deleted file mode 100644 index 0c64ff008..000000000 --- a/tfjs-master/tfjs-core/src/ops/log_sum_exp_test.ts +++ /dev/null @@ -1,134 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose, expectArraysEqual} from '../test_util'; - -describeWithFlags('logSumExp', ALL_ENVS, () => { - it('0', async () => { - const a = tf.scalar(0); - const result = tf.logSumExp(a); - expectArraysClose(await result.data(), 0); - }); - - it('basic', async () => { - const a = tf.tensor1d([1, 2, -3]); - const result = tf.logSumExp(a); - - expectArraysClose( - await result.data(), - Math.log(Math.exp(1) + Math.exp(2) + Math.exp(-3))); - }); - - it('propagates NaNs', async () => { - const a = tf.tensor1d([1, 2, NaN]); - const result = tf.logSumExp(a); - expectArraysEqual(await result.data(), NaN); - }); - - it('axes=0 in 2D array', async () => { - const a = tf.tensor2d([1, 2, 3, 0, 0, 1], [3, 2]); - const r = tf.logSumExp(a, [0]); - - expect(r.shape).toEqual([2]); - const expected = [ - Math.log(Math.exp(1) + Math.exp(3) + Math.exp(0)), - Math.log(Math.exp(2) + Math.exp(0) + Math.exp(1)) - ]; - expectArraysClose(await r.data(), expected); - }); - - it('axes=0 in 2D array, keepDims', async () => { - const a = tf.tensor2d([1, 2, 3, 0, 0, 1], [3, 2]); - const r = tf.logSumExp(a, [0], true /* keepDims */); - - expect(r.shape).toEqual([1, 2]); - const expected = [ - Math.log(Math.exp(1) + Math.exp(3) + Math.exp(0)), - Math.log(Math.exp(2) + Math.exp(0) + Math.exp(1)) - ]; - expectArraysClose(await r.data(), expected); - }); - - it('axes=1 in 2D array', async () => { - const a = tf.tensor2d([1, 2, 3, 0, 0, 1], [3, 2]); - const res = tf.logSumExp(a, [1]); - - expect(res.shape).toEqual([3]); - const expected = [ - Math.log(Math.exp(1) + Math.exp(2)), - Math.log(Math.exp(3) + Math.exp(0)), - Math.log(Math.exp(0) + Math.exp(1)), - ]; - expectArraysClose(await res.data(), expected); - }); - - it('axes = -1 in 2D array', async () => { - const a = tf.tensor2d([1, 2, 3, 0, 0, 1], [3, 2]); - const res = tf.logSumExp(a, -1); - - expect(res.shape).toEqual([3]); - const expected = [ - Math.log(Math.exp(1) + Math.exp(2)), - Math.log(Math.exp(3) + Math.exp(0)), - Math.log(Math.exp(0) + Math.exp(1)), - ]; - expectArraysClose(await res.data(), expected); - }); - - it('2D, axes=1 provided as a single digit', async () => { - const a = tf.tensor2d([1, 2, 3, 0, 0, 1], [2, 3]); - const res = tf.logSumExp(a, 1); - - expect(res.shape).toEqual([2]); - const expected = [ - Math.log(Math.exp(1) + Math.exp(2) + Math.exp(3)), - Math.log(Math.exp(0) + Math.exp(0) + Math.exp(1)) - ]; - expectArraysClose(await res.data(), expected); - }); - - it('axes=0,1 in 2D array', async () => { - const a = tf.tensor2d([1, 2, 3, 0, 0, 1], [3, 2]); - const res = tf.logSumExp(a, [0, 1]); - - expect(res.shape).toEqual([]); - const expected = [Math.log( - Math.exp(1) + Math.exp(2) + Math.exp(3) + Math.exp(0) + Math.exp(0) + - Math.exp(1))]; - expectArraysClose(await res.data(), expected); - }); - - it('throws when passed a non-tensor', () => { - expect(() => tf.logSumExp({} as tf.Tensor)) - .toThrowError(/Argument 'x' passed to 'logSumExp' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const result = tf.logSumExp([1, 2, -3]); - expectArraysClose( - await result.data(), - Math.log(Math.exp(1) + Math.exp(2) + Math.exp(-3))); - }); - - it('throws error for string tensor', () => { - expect(() => tf.logSumExp(['a'])) - .toThrowError( - /Argument 'x' passed to 'logSumExp' must be numeric tensor/); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/log_test.ts b/tfjs-master/tfjs-core/src/ops/log_test.ts deleted file mode 100644 index fa1b505ae..000000000 --- a/tfjs-master/tfjs-core/src/ops/log_test.ts +++ /dev/null @@ -1,116 +0,0 @@ -/** - * @license - * Copyright 2020 Google Inc. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('log', ALL_ENVS, () => { - it('log', async () => { - const a = tf.tensor1d([1, 2]); - const r = tf.log(a); - expectArraysClose(await r.data(), [Math.log(1), Math.log(2)]); - }); - - it('log 6D', async () => { - const a = tf.range(1, 65).reshape([2, 2, 2, 2, 2, 2]); - const r = tf.log(a); - - const expectedResult = []; - for (let i = 1; i < 65; i++) { - expectedResult[i - 1] = Math.log(i); - } - - expectArraysClose(await r.data(), expectedResult); - }); - - it('log propagates NaNs', async () => { - const a = tf.tensor1d([1, NaN]); - const r = tf.log(a); - expectArraysClose(await r.data(), [Math.log(1), NaN]); - }); - - it('negtive values', async () => { - const a = tf.tensor1d([1, -1]); - const r = tf.log(a); - expectArraysClose(await r.data(), [Math.log(1), NaN]); - }); - - it('gradients: Scalar', async () => { - const a = tf.scalar(5); - const dy = tf.scalar(3); - - const gradients = tf.grad(a => tf.log(a))(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), [3 / 5]); - }); - - it('gradient with clones', async () => { - const a = tf.scalar(5); - const dy = tf.scalar(3); - - const gradients = tf.grad(a => tf.log(a.clone()).clone())(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), [3 / 5]); - }); - - it('gradients: Tensor1D', async () => { - const a = tf.tensor1d([-1, 2, 3, -5]); - const dy = tf.tensor1d([1, 2, 3, 4]); - - const gradients = tf.grad(a => tf.log(a))(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), [1 / -1, 2 / 2, 3 / 3, 4 / -5]); - }); - - it('gradients: Tensor2D', async () => { - const a = tf.tensor2d([-3, 1, 2, 3], [2, 2]); - const dy = tf.tensor2d([1, 2, 3, 4], [2, 2]); - - const gradients = tf.grad(a => tf.log(a))(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), [1 / -3, 2 / 1, 3 / 2, 4 / 3]); - }); - - it('throws when passed a non-tensor', () => { - expect(() => tf.log({} as tf.Tensor)) - .toThrowError(/Argument 'x' passed to 'log' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const r = tf.log([1, 2]); - expectArraysClose(await r.data(), [Math.log(1), Math.log(2)]); - }); - - it('throws for string tensor', () => { - expect(() => tf.log('q')) - .toThrowError(/Argument 'x' passed to 'log' must be float32/); - }); - - it('throws for int32 tensor', () => { - expect(() => tf.log(tf.tensor1d([1], 'int32'))) - .toThrowError(/Argument 'x' passed to 'log' must be float32/); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/logical_and.ts b/tfjs-master/tfjs-core/src/ops/logical_and.ts deleted file mode 100644 index 07ba68643..000000000 --- a/tfjs-master/tfjs-core/src/ops/logical_and.ts +++ /dev/null @@ -1,53 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {ENGINE} from '../engine'; -import {LogicalAnd, LogicalAndInputs} from '../kernel_names'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -import {assertAndGetBroadcastShape} from './broadcast_util'; -import {op} from './operation'; - -/** - * Returns the truth value of `a AND b` element-wise. Supports broadcasting. - * - * ```js - * const a = tf.tensor1d([false, false, true, true], 'bool'); - * const b = tf.tensor1d([false, true, false, true], 'bool'); - * - * a.logicalAnd(b).print(); - * ``` - * - * @param a The first input tensor. Must be of dtype bool. - * @param b The second input tensor. Must be of dtype bool. - * - * @doc {heading: 'Operations', subheading: 'Logical'} - */ -function logicalAnd_( - a: Tensor|TensorLike, b: Tensor|TensorLike): T { - const $a = convertToTensor(a, 'a', 'logicalAnd', 'bool'); - const $b = convertToTensor(b, 'b', 'logicalAnd', 'bool'); - assertAndGetBroadcastShape($a.shape, $b.shape); - - const inputs: LogicalAndInputs = {a: $a, b: $b}; - - return ENGINE.runKernel(LogicalAnd, inputs as unknown as NamedTensorMap); -} - -export const logicalAnd = /* @__PURE__ */ op({logicalAnd_}); diff --git a/tfjs-master/tfjs-core/src/ops/logical_and_test.ts b/tfjs-master/tfjs-core/src/ops/logical_and_test.ts deleted file mode 100644 index bf44b4d44..000000000 --- a/tfjs-master/tfjs-core/src/ops/logical_and_test.ts +++ /dev/null @@ -1,126 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('logicalAnd', ALL_ENVS, () => { - it('Tensor1D.', async () => { - let a = tf.tensor1d([1, 0, 0], 'bool'); - let b = tf.tensor1d([0, 1, 0], 'bool'); - expectArraysClose(await tf.logicalAnd(a, b).data(), [0, 0, 0]); - - a = tf.tensor1d([0, 0, 0], 'bool'); - b = tf.tensor1d([0, 0, 0], 'bool'); - expectArraysClose(await tf.logicalAnd(a, b).data(), [0, 0, 0]); - - a = tf.tensor1d([1, 1], 'bool'); - b = tf.tensor1d([1, 1], 'bool'); - expectArraysClose(await tf.logicalAnd(a, b).data(), [1, 1]); - }); - it('mismatched Tensor1D shapes', () => { - const a = tf.tensor1d([1, 0], 'bool'); - const b = tf.tensor1d([0, 1, 0], 'bool'); - const f = () => { - tf.logicalAnd(a, b); - }; - expect(f).toThrowError(); - }); - - it('Tensor2D', async () => { - let a = tf.tensor2d([[1, 0, 1], [0, 0, 0]], [2, 3], 'bool'); - let b = tf.tensor2d([[0, 0, 0], [0, 1, 0]], [2, 3], 'bool'); - expectArraysClose(await tf.logicalAnd(a, b).data(), [0, 0, 0, 0, 0, 0]); - - a = tf.tensor2d([[0, 0, 0], [1, 1, 1]], [2, 3], 'bool'); - b = tf.tensor2d([[0, 0, 0], [1, 1, 1]], [2, 3], 'bool'); - expectArraysClose(await tf.logicalAnd(a, b).data(), [0, 0, 0, 1, 1, 1]); - }); - it('broadcasting Tensor2D shapes', async () => { - const a = tf.tensor2d([[1], [0]], [2, 1], 'bool'); - const b = tf.tensor2d([[0, 1, 0], [0, 1, 0]], [2, 3], 'bool'); - expectArraysClose(await tf.logicalAnd(a, b).data(), [0, 1, 0, 0, 0, 0]); - }); - - it('Tensor3D', async () => { - let a = tf.tensor3d([[[1], [0], [1]], [[0], [0], [1]]], [2, 3, 1], 'bool'); - let b = tf.tensor3d([[[0], [0], [1]], [[1], [0], [0]]], [2, 3, 1], 'bool'); - expectArraysClose(await tf.logicalAnd(a, b).data(), [0, 0, 1, 0, 0, 0]); - - a = tf.tensor3d([[[0], [0], [0]], [[1], [1], [1]]], [2, 3, 1], 'bool'); - b = tf.tensor3d([[[0], [0], [0]], [[1], [1], [1]]], [2, 3, 1], 'bool'); - expectArraysClose(await tf.logicalAnd(a, b).data(), [0, 0, 0, 1, 1, 1]); - }); - it('broadcasting Tensor3D shapes', async () => { - const a = tf.tensor3d( - [[[1, 0], [0, 0], [1, 1]], [[0, 0], [0, 1], [0, 0]]], [2, 3, 2], - 'bool'); - const b = - tf.tensor3d([[[0], [0], [1]], [[1], [0], [0]]], [2, 3, 1], 'bool'); - expectArraysClose( - await tf.logicalAnd(a, b).data(), [0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0]); - }); - - it('Tensor4D', async () => { - let a = tf.tensor4d([1, 0, 1, 0], [2, 2, 1, 1], 'bool'); - let b = tf.tensor4d([0, 1, 1, 0], [2, 2, 1, 1], 'bool'); - expectArraysClose(await tf.logicalAnd(a, b).data(), [0, 0, 1, 0]); - - a = tf.tensor4d([0, 0, 0, 0], [2, 2, 1, 1], 'bool'); - b = tf.tensor4d([0, 0, 0, 0], [2, 2, 1, 1], 'bool'); - expectArraysClose(await tf.logicalAnd(a, b).data(), [0, 0, 0, 0]); - - a = tf.tensor4d([1, 1, 1, 1], [2, 2, 1, 1], 'bool'); - b = tf.tensor4d([1, 1, 1, 1], [2, 2, 1, 1], 'bool'); - expectArraysClose(await tf.logicalAnd(a, b).data(), [1, 1, 1, 1]); - }); - it('broadcasting Tensor4D shapes', async () => { - const a = tf.tensor4d([1, 0, 1, 0], [2, 2, 1, 1], 'bool'); - const b = tf.tensor4d( - [[[[1, 0]], [[0, 0]]], [[[0, 0]], [[1, 1]]]], [2, 2, 1, 2], 'bool'); - expectArraysClose( - await tf.logicalAnd(a, b).data(), [1, 0, 0, 0, 0, 0, 0, 0]); - }); - - it('TensorLike', async () => { - const a = [true, false, false]; - const b = [false, true, false]; - expectArraysClose(await tf.logicalAnd(a, b).data(), [0, 0, 0]); - }); - - it('TensorLike Chained', async () => { - const a = tf.tensor1d([1, 0, 0], 'bool'); - const b = [false, true, false]; - expectArraysClose(await a.logicalAnd(b).data(), [0, 0, 0]); - }); - - it('throws when passed a as a non-tensor', () => { - expect(() => tf.logicalAnd({} as tf.Tensor, tf.scalar(1, 'bool'))) - .toThrowError(/Argument 'a' passed to 'logicalAnd' must be a Tensor/); - }); - it('throws when passed b as a non-tensor', () => { - expect(() => tf.logicalAnd(tf.scalar(1, 'bool'), {} as tf.Tensor)) - .toThrowError(/Argument 'b' passed to 'logicalAnd' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const a = [1, 0, 0, 1]; - const b = [0, 1, 0, 1]; - expectArraysClose(await tf.logicalAnd(a, b).data(), [0, 0, 0, 1]); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/logical_not.ts b/tfjs-master/tfjs-core/src/ops/logical_not.ts deleted file mode 100644 index 739097948..000000000 --- a/tfjs-master/tfjs-core/src/ops/logical_not.ts +++ /dev/null @@ -1,45 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {LogicalNot, LogicalNotInputs} from '../kernel_names'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; -import {op} from './operation'; - -/** - * Returns the truth value of `NOT x` element-wise. - * - * ```js - * const a = tf.tensor1d([false, true], 'bool'); - * - * a.logicalNot().print(); - * ``` - * - * @param x The input tensor. Must be of dtype 'bool'. - * - * @doc {heading: 'Operations', subheading: 'Logical'} - */ -function logicalNot_(x: T|TensorLike): T { - const $x = convertToTensor(x, 'x', 'logicalNot', 'bool'); - const inputs: LogicalNotInputs = {x: $x}; - return ENGINE.runKernel(LogicalNot, inputs as unknown as NamedTensorMap); -} - -export const logicalNot = /* @__PURE__ */ op({logicalNot_}); diff --git a/tfjs-master/tfjs-core/src/ops/logical_not_test.ts b/tfjs-master/tfjs-core/src/ops/logical_not_test.ts deleted file mode 100644 index 09ce959d1..000000000 --- a/tfjs-master/tfjs-core/src/ops/logical_not_test.ts +++ /dev/null @@ -1,94 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('logicalNot', ALL_ENVS, () => { - it('Tensor1D.', async () => { - let a = tf.tensor1d([1, 0, 0], 'bool'); - expectArraysClose(await tf.logicalNot(a).data(), [0, 1, 1]); - - a = tf.tensor1d([0, 0, 0], 'bool'); - expectArraysClose(await tf.logicalNot(a).data(), [1, 1, 1]); - - a = tf.tensor1d([1, 1], 'bool'); - expectArraysClose(await tf.logicalNot(a).data(), [0, 0]); - }); - it('Tests chaining in Tensor1D', async () => { - let a = tf.tensor1d([1, 0, 0], 'bool'); - expectArraysClose(await a.logicalNot().data(), [0, 1, 1]); - - a = tf.tensor1d([0, 0, 0], 'bool'); - expectArraysClose(await a.logicalNot().data(), [1, 1, 1]); - - a = tf.tensor1d([1, 1], 'bool'); - expectArraysClose(await a.logicalNot().data(), [0, 0]); - }); - - it('Tensor2D', async () => { - let a = tf.tensor2d([[1, 0, 1], [0, 0, 0]], [2, 3], 'bool'); - expectArraysClose(await tf.logicalNot(a).data(), [0, 1, 0, 1, 1, 1]); - - a = tf.tensor2d([[0, 0, 0], [1, 1, 1]], [2, 3], 'bool'); - expectArraysClose(await tf.logicalNot(a).data(), [1, 1, 1, 0, 0, 0]); - }); - - it('Tensor3D', async () => { - let a = tf.tensor3d([[[1], [0], [1]], [[0], [0], [0]]], [2, 3, 1], 'bool'); - expectArraysClose(await tf.logicalNot(a).data(), [0, 1, 0, 1, 1, 1]); - - a = tf.tensor3d([[[0], [0], [0]], [[1], [1], [1]]], [2, 3, 1], 'bool'); - expectArraysClose(await tf.logicalNot(a).data(), [1, 1, 1, 0, 0, 0]); - }); - - it('Tensor4D', async () => { - let a = tf.tensor4d([1, 0, 1, 0], [2, 2, 1, 1], 'bool'); - expectArraysClose(await tf.logicalNot(a).data(), [0, 1, 0, 1]); - - a = tf.tensor4d([0, 0, 0, 0], [2, 2, 1, 1], 'bool'); - expectArraysClose(await tf.logicalNot(a).data(), [1, 1, 1, 1]); - - a = tf.tensor4d([1, 1, 1, 1], [2, 2, 1, 1], 'bool'); - expectArraysClose(await tf.logicalNot(a).data(), [0, 0, 0, 0]); - }); - - it('Tensor6D', async () => { - let a = tf.tensor6d([1, 0, 1, 0], [2, 2, 1, 1, 1, 1], 'bool'); - expectArraysClose(await tf.logicalNot(a).data(), [0, 1, 0, 1]); - - a = tf.zeros([2, 2, 2, 2, 2, 2]).cast('bool'); - let expectedResult = new Uint8Array(64).fill(1); - expectedResult = expectedResult.fill(1); - expectArraysClose(await tf.logicalNot(a).data(), expectedResult); - - a = tf.ones([2, 2, 2, 2, 2, 2]).cast('bool'); - expectedResult = expectedResult.fill(0); - expectArraysClose(await tf.logicalNot(a).data(), expectedResult); - }); - - it('throws when passed a non-tensor', () => { - expect(() => tf.logicalNot({} as tf.Tensor)) - .toThrowError(/Argument 'x' passed to 'logicalNot' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const a = [1, 0, 0]; - expectArraysClose(await tf.logicalNot(a).data(), [0, 1, 1]); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/logical_or.ts b/tfjs-master/tfjs-core/src/ops/logical_or.ts deleted file mode 100644 index b339878df..000000000 --- a/tfjs-master/tfjs-core/src/ops/logical_or.ts +++ /dev/null @@ -1,50 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {LogicalOr, LogicalOrInputs} from '../kernel_names'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; -import {assertAndGetBroadcastShape} from './broadcast_util'; -import {op} from './operation'; - -/** - * Returns the truth value of `a OR b` element-wise. Supports broadcasting. - * - * ```js - * const a = tf.tensor1d([false, false, true, true], 'bool'); - * const b = tf.tensor1d([false, true, false, true], 'bool'); - * - * a.logicalOr(b).print(); - * ``` - * @param a The first input tensor. Must be of dtype bool. - * @param b The second input tensor. Must be of dtype bool. - * - * @doc {heading: 'Operations', subheading: 'Logical'} - */ -function logicalOr_( - a: Tensor|TensorLike, b: Tensor|TensorLike): T { - const $a = convertToTensor(a, 'a', 'logicalOr', 'bool'); - const $b = convertToTensor(b, 'b', 'logicalOr', 'bool'); - assertAndGetBroadcastShape($a.shape, $b.shape); - - const inputs: LogicalOrInputs = {a: $a, b: $b}; - return ENGINE.runKernel(LogicalOr, inputs as unknown as NamedTensorMap); -} -export const logicalOr = /* @__PURE__ */ op({logicalOr_}); diff --git a/tfjs-master/tfjs-core/src/ops/logical_or_test.ts b/tfjs-master/tfjs-core/src/ops/logical_or_test.ts deleted file mode 100644 index 56069dd55..000000000 --- a/tfjs-master/tfjs-core/src/ops/logical_or_test.ts +++ /dev/null @@ -1,109 +0,0 @@ -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('logicalOr', ALL_ENVS, () => { - it('Tensor1D.', async () => { - let a = tf.tensor1d([1, 0, 0], 'bool'); - let b = tf.tensor1d([0, 1, 0], 'bool'); - expectArraysClose(await tf.logicalOr(a, b).data(), [1, 1, 0]); - - a = tf.tensor1d([0, 0, 0], 'bool'); - b = tf.tensor1d([0, 0, 0], 'bool'); - expectArraysClose(await tf.logicalOr(a, b).data(), [0, 0, 0]); - - a = tf.tensor1d([1, 1], 'bool'); - b = tf.tensor1d([1, 1], 'bool'); - expectArraysClose(await tf.logicalOr(a, b).data(), [1, 1]); - }); - it('mismatched Tensor1D shapes', () => { - const a = tf.tensor1d([1, 0], 'bool'); - const b = tf.tensor1d([0, 1, 0], 'bool'); - const f = () => { - tf.logicalOr(a, b); - }; - expect(f).toThrowError(); - }); - - it('Tensor2D', async () => { - let a = tf.tensor2d([[1, 0, 1], [0, 0, 0]], [2, 3], 'bool'); - let b = tf.tensor2d([[0, 0, 0], [0, 1, 0]], [2, 3], 'bool'); - expectArraysClose(await tf.logicalOr(a, b).data(), [1, 0, 1, 0, 1, 0]); - - a = tf.tensor2d([[0, 0, 0], [1, 1, 1]], [2, 3], 'bool'); - b = tf.tensor2d([[0, 0, 0], [1, 1, 1]], [2, 3], 'bool'); - expectArraysClose(await tf.logicalOr(a, b).data(), [0, 0, 0, 1, 1, 1]); - }); - it('broadcasting Tensor2D shapes', async () => { - const a = tf.tensor2d([[1], [0]], [2, 1], 'bool'); - const b = tf.tensor2d([[0, 0, 0], [0, 1, 0]], [2, 3], 'bool'); - expectArraysClose(await tf.logicalOr(a, b).data(), [1, 1, 1, 0, 1, 0]); - }); - - it('Tensor3D', async () => { - let a = tf.tensor3d([[[1], [0], [1]], [[0], [0], [0]]], [2, 3, 1], 'bool'); - let b = tf.tensor3d([[[0], [0], [1]], [[1], [0], [0]]], [2, 3, 1], 'bool'); - expectArraysClose(await tf.logicalOr(a, b).data(), [1, 0, 1, 1, 0, 0]); - - a = tf.tensor3d([[[0], [0], [0]], [[1], [1], [1]]], [2, 3, 1], 'bool'); - b = tf.tensor3d([[[0], [0], [0]], [[1], [1], [1]]], [2, 3, 1], 'bool'); - expectArraysClose(await tf.logicalOr(a, b).data(), [0, 0, 0, 1, 1, 1]); - }); - it('broadcasting Tensor3D shapes', async () => { - const a = tf.tensor3d( - [[[1, 0], [0, 0], [1, 1]], [[0, 0], [0, 1], [0, 0]]], [2, 3, 2], - 'bool'); - const b = - tf.tensor3d([[[0], [0], [1]], [[1], [0], [0]]], [2, 3, 1], 'bool'); - expectArraysClose( - await tf.logicalOr(a, b).data(), [1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 0]); - }); - - it('Tensor4D', async () => { - let a = tf.tensor4d([1, 0, 1, 0], [2, 2, 1, 1], 'bool'); - let b = tf.tensor4d([0, 1, 0, 0], [2, 2, 1, 1], 'bool'); - expectArraysClose(await tf.logicalOr(a, b).data(), [1, 1, 1, 0]); - - a = tf.tensor4d([0, 0, 0, 0], [2, 2, 1, 1], 'bool'); - b = tf.tensor4d([0, 0, 0, 0], [2, 2, 1, 1], 'bool'); - expectArraysClose(await tf.logicalOr(a, b).data(), [0, 0, 0, 0]); - - a = tf.tensor4d([1, 1, 1, 1], [2, 2, 1, 1], 'bool'); - b = tf.tensor4d([1, 1, 1, 1], [2, 2, 1, 1], 'bool'); - expectArraysClose(await tf.logicalOr(a, b).data(), [1, 1, 1, 1]); - }); - it('broadcasting Tensor4D shapes', async () => { - const a = tf.tensor4d([1, 0, 1, 0], [2, 2, 1, 1], 'bool'); - const b = tf.tensor4d( - [[[[1, 0]], [[0, 0]]], [[[0, 0]], [[1, 1]]]], [2, 2, 1, 2], 'bool'); - expectArraysClose( - await tf.logicalOr(a, b).data(), [1, 1, 0, 0, 1, 1, 1, 1]); - }); - - it('TensorLike', async () => { - const a = [true, false, false]; - const b = [false, true, false]; - expectArraysClose(await tf.logicalOr(a, b).data(), [1, 1, 0]); - }); - - it('TensorLike Chained', async () => { - const a = tf.tensor1d([1, 0, 0], 'bool'); - const b = [false, true, false]; - expectArraysClose(await a.logicalOr(b).data(), [1, 1, 0]); - }); - - it('throws when passed a as a non-tensor', () => { - expect(() => tf.logicalOr({} as tf.Tensor, tf.scalar(1, 'bool'))) - .toThrowError(/Argument 'a' passed to 'logicalOr' must be a Tensor/); - }); - it('throws when passed b as a non-tensor', () => { - expect(() => tf.logicalOr(tf.scalar(1, 'bool'), {} as tf.Tensor)) - .toThrowError(/Argument 'b' passed to 'logicalOr' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const a = [1, 0, 0, 1]; - const b = [0, 1, 0, 1]; - expectArraysClose(await tf.logicalOr(a, b).data(), [1, 1, 0, 1]); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/logical_xor.ts b/tfjs-master/tfjs-core/src/ops/logical_xor.ts deleted file mode 100644 index 0820a58e7..000000000 --- a/tfjs-master/tfjs-core/src/ops/logical_xor.ts +++ /dev/null @@ -1,53 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Tensor} from '../tensor'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -import {assertAndGetBroadcastShape} from './broadcast_util'; -import {logicalAnd} from './logical_and'; -import {logicalNot} from './logical_not'; -import {logicalOr} from './logical_or'; -import {op} from './operation'; - -/** - * Returns the truth value of `a XOR b` element-wise. Supports broadcasting. - * - * ```js - * const a = tf.tensor1d([false, false, true, true], 'bool'); - * const b = tf.tensor1d([false, true, false, true], 'bool'); - * - * a.logicalXor(b).print(); - * ``` - * - * @param a The first input tensor. Must be of dtype bool. - * @param b The second input tensor. Must be of dtype bool. - * - * @doc {heading: 'Operations', subheading: 'Logical'} - */ -function logicalXor_( - a: Tensor|TensorLike, b: Tensor|TensorLike): T { - const $a = convertToTensor(a, 'a', 'logicalXor', 'bool'); - const $b = convertToTensor(b, 'b', 'logicalXor', 'bool'); - assertAndGetBroadcastShape($a.shape, $b.shape); - - // x ^ y = (x | y) & ~(x & y) - return logicalAnd(logicalOr(a, b), logicalNot(logicalAnd(a, b))); -} - -export const logicalXor = /* @__PURE__ */ op({logicalXor_}); diff --git a/tfjs-master/tfjs-core/src/ops/logical_xor_test.ts b/tfjs-master/tfjs-core/src/ops/logical_xor_test.ts deleted file mode 100644 index 07f1adc3c..000000000 --- a/tfjs-master/tfjs-core/src/ops/logical_xor_test.ts +++ /dev/null @@ -1,111 +0,0 @@ -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('logicalXor', ALL_ENVS, () => { - it('Tensor1D.', async () => { - let a = tf.tensor1d([1, 0, 0], 'bool'); - let b = tf.tensor1d([0, 1, 0], 'bool'); - expectArraysClose(await tf.logicalXor(a, b).data(), [1, 1, 0]); - - a = tf.tensor1d([0, 0, 0], 'bool'); - b = tf.tensor1d([0, 0, 0], 'bool'); - expectArraysClose(await tf.logicalXor(a, b).data(), [0, 0, 0]); - - a = tf.tensor1d([1, 1], 'bool'); - b = tf.tensor1d([1, 1], 'bool'); - expectArraysClose(await tf.logicalXor(a, b).data(), [0, 0]); - }); - it('mismatched Tensor1D shapes', () => { - const a = tf.tensor1d([1, 0], 'bool'); - const b = tf.tensor1d([0, 1, 0], 'bool'); - const f = () => { - tf.logicalXor(a, b); - }; - expect(f).toThrowError(); - }); - - // Tensor2D: - it('Tensor2D', async () => { - let a = tf.tensor2d([[1, 0, 1], [0, 0, 0]], [2, 3], 'bool'); - let b = tf.tensor2d([[0, 0, 0], [0, 1, 0]], [2, 3], 'bool'); - expectArraysClose(await tf.logicalXor(a, b).data(), [1, 0, 1, 0, 1, 0]); - - a = tf.tensor2d([[0, 0, 0], [1, 1, 1]], [2, 3], 'bool'); - b = tf.tensor2d([[0, 0, 0], [1, 1, 1]], [2, 3], 'bool'); - expectArraysClose(await tf.logicalXor(a, b).data(), [0, 0, 0, 0, 0, 0]); - }); - it('broadcasting Tensor2D shapes', async () => { - const a = tf.tensor2d([[1], [0]], [2, 1], 'bool'); - const b = tf.tensor2d([[0, 0, 0], [0, 1, 0]], [2, 3], 'bool'); - expectArraysClose(await tf.logicalXor(a, b).data(), [1, 1, 1, 0, 1, 0]); - }); - - // Tensor3D: - it('Tensor3D', async () => { - let a = tf.tensor3d([[[1], [0], [1]], [[0], [0], [0]]], [2, 3, 1], 'bool'); - let b = tf.tensor3d([[[0], [0], [1]], [[1], [0], [0]]], [2, 3, 1], 'bool'); - expectArraysClose(await tf.logicalXor(a, b).data(), [1, 0, 0, 1, 0, 0]); - - a = tf.tensor3d([[[0], [0], [0]], [[1], [1], [1]]], [2, 3, 1], 'bool'); - b = tf.tensor3d([[[0], [0], [0]], [[1], [1], [1]]], [2, 3, 1], 'bool'); - expectArraysClose(await tf.logicalXor(a, b).data(), [0, 0, 0, 0, 0, 0]); - }); - it('broadcasting Tensor3D shapes', async () => { - const a = tf.tensor3d( - [[[1, 0], [0, 0], [1, 1]], [[0, 0], [0, 1], [0, 0]]], [2, 3, 2], - 'bool'); - const b = - tf.tensor3d([[[0], [0], [1]], [[1], [0], [0]]], [2, 3, 1], 'bool'); - expectArraysClose( - await tf.logicalXor(a, b).data(), [1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0]); - }); - - // Tensor4D: - it('Tensor4D', async () => { - let a = tf.tensor4d([1, 0, 1, 0], [2, 2, 1, 1], 'bool'); - let b = tf.tensor4d([0, 1, 1, 0], [2, 2, 1, 1], 'bool'); - expectArraysClose(await tf.logicalXor(a, b).data(), [1, 1, 0, 0]); - - a = tf.tensor4d([0, 0, 0, 0], [2, 2, 1, 1], 'bool'); - b = tf.tensor4d([0, 0, 0, 0], [2, 2, 1, 1], 'bool'); - expectArraysClose(await tf.logicalXor(a, b).data(), [0, 0, 0, 0]); - - a = tf.tensor4d([1, 1, 1, 1], [2, 2, 1, 1], 'bool'); - b = tf.tensor4d([1, 1, 1, 1], [2, 2, 1, 1], 'bool'); - expectArraysClose(await tf.logicalXor(a, b).data(), [0, 0, 0, 0]); - }); - it('broadcasting Tensor4D shapes', async () => { - const a = tf.tensor4d([1, 0, 1, 0], [2, 2, 1, 1], 'bool'); - const b = tf.tensor4d( - [[[[1, 0]], [[0, 0]]], [[[0, 0]], [[1, 1]]]], [2, 2, 1, 2], 'bool'); - expectArraysClose( - await tf.logicalXor(a, b).data(), [0, 1, 0, 0, 1, 1, 1, 1]); - }); - - it('TensorLike', async () => { - const a = [true, false, false]; - const b = [false, true, false]; - expectArraysClose(await tf.logicalXor(a, b).data(), [1, 1, 0]); - }); - - it('TensorLike Chained', async () => { - const a = tf.tensor1d([1, 0, 0], 'bool'); - const b = [false, true, false]; - expectArraysClose(await a.logicalXor(b).data(), [1, 1, 0]); - }); - - it('throws when passed a as a non-tensor', () => { - expect(() => tf.logicalXor({} as tf.Tensor, tf.scalar(1, 'bool'))) - .toThrowError(/Argument 'a' passed to 'logicalXor' must be a Tensor/); - }); - it('throws when passed b as a non-tensor', () => { - expect(() => tf.logicalXor(tf.scalar(1, 'bool'), {} as tf.Tensor)) - .toThrowError(/Argument 'b' passed to 'logicalXor' must be a Tensor/); - }); - it('accepts a tensor-like object', async () => { - const a = [1, 0, 0, 1]; - const b = [0, 1, 0, 1]; - expectArraysClose(await tf.logicalXor(a, b).data(), [1, 1, 0, 0]); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/loss_ops_utils.ts b/tfjs-master/tfjs-core/src/ops/loss_ops_utils.ts deleted file mode 100644 index b8ee1fd49..000000000 --- a/tfjs-master/tfjs-core/src/ops/loss_ops_utils.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -export enum Reduction { - NONE, - MEAN, - SUM, - SUM_BY_NONZERO_WEIGHTS -} diff --git a/tfjs-master/tfjs-core/src/ops/losses/absolute_difference.ts b/tfjs-master/tfjs-core/src/ops/losses/absolute_difference.ts deleted file mode 100644 index fc4336498..000000000 --- a/tfjs-master/tfjs-core/src/ops/losses/absolute_difference.ts +++ /dev/null @@ -1,62 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Tensor} from '../../tensor'; -import {convertToTensor} from '../../tensor_util_env'; -import {TensorLike} from '../../types'; -import {assertShapesMatch} from '../../util'; -import {abs} from '../abs'; -import {Reduction} from '../loss_ops_utils'; -import {op} from '../operation'; -import {sub} from '../sub'; - -import {computeWeightedLoss} from './compute_weighted_loss'; - -/** - * Computes the absolute difference loss between two tensors. - * - * @param labels The ground truth output tensor, same dimensions as - * 'predictions'. - * @param predictions The predicted outputs. - * @param weights Tensor whose rank is either 0, or the same rank as - * `labels`, and must be broadcastable to `labels` (i.e., all dimensions - * must be either `1`, or the same as the corresponding `losses` - * dimension). - * @param reduction Type of reduction to apply to loss. Should be of type - * `Reduction` - * - * @doc {heading: 'Training', subheading: 'Losses', namespace: 'losses'} - */ -function absoluteDifference_( - labels: T|TensorLike, predictions: T|TensorLike, - weights?: Tensor|TensorLike, - reduction = Reduction.SUM_BY_NONZERO_WEIGHTS): O { - const $labels = convertToTensor(labels, 'labels', 'absoluteDifference'); - const $predictions = - convertToTensor(predictions, 'predictions', 'absoluteDifference'); - let $weights: Tensor = null; - if (weights != null) { - $weights = convertToTensor(weights, 'weights', 'absoluteDifference'); - } - assertShapesMatch( - $labels.shape, $predictions.shape, 'Error in absoluteDifference: '); - - const losses = abs(sub($labels, $predictions)); - return computeWeightedLoss(losses, $weights, reduction); -} - -export const absoluteDifference = /* @__PURE__ */ op({absoluteDifference_}); diff --git a/tfjs-master/tfjs-core/src/ops/losses/absolute_difference_test.ts b/tfjs-master/tfjs-core/src/ops/losses/absolute_difference_test.ts deleted file mode 100644 index 4ebac0b00..000000000 --- a/tfjs-master/tfjs-core/src/ops/losses/absolute_difference_test.ts +++ /dev/null @@ -1,222 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../../index'; -import {ALL_ENVS, describeWithFlags} from '../../jasmine_util'; -import {expectArraysClose} from '../../test_util'; - -describeWithFlags('absoluteDifference', ALL_ENVS, () => { - it('1D', async () => { - const predictions = tf.tensor1d([1, 2, 3]); - const label = tf.tensor1d([0.3, -0.6, -0.1]); - - const y = tf.losses.absoluteDifference(label, predictions); - - expect(y.shape).toEqual([]); - expectArraysClose( - await y.data(), - (Math.abs(1 - 0.3) + Math.abs(2 - (-0.6)) + Math.abs(3 - (-0.1))) / 3); - }); - - it('1D - weighted - Reduction.SUM_BY_NONZERO_WEIGHTS', async () => { - const predictions = tf.tensor1d([1, 2, 3]); - const label = tf.tensor1d([0.3, -0.6, -0.1]); - const weights = tf.tensor1d([0.1, 0.2, 0.3]); - - const y = tf.losses.absoluteDifference(label, predictions, weights); - - expect(y.shape).toEqual([]); - expectArraysClose( - await y.data(), - (Math.abs(1 - 0.3) * 0.1 + Math.abs(2 - (-0.6)) * 0.2 + - Math.abs(3 - (-0.1)) * 0.3) / - 3); - }); - - it('1D - weighted - Reduction.NONE', async () => { - const predictions = tf.tensor1d([1, 2, 3]); - const label = tf.tensor1d([0.3, -0.6, -0.1]); - const weights = tf.tensor1d([0.1, 0.2, 0.3]); - - const y = tf.losses.absoluteDifference( - label, predictions, weights, tf.Reduction.NONE); - - expect(y.shape).toEqual([3]); - expectArraysClose(await y.data(), [ - Math.abs(1 - 0.3) * 0.1, Math.abs(2 - (-0.6)) * 0.2, - Math.abs(3 - (-0.1)) * 0.3 - ]); - }); - - it('1D - Reduction.MEAN', async () => { - const predictions = tf.tensor1d([1, 2, 3]); - const label = tf.tensor1d([0.3, -0.6, -0.1]); - - const y = tf.losses.absoluteDifference( - label, predictions, undefined, tf.Reduction.MEAN); - - expect(y.shape).toEqual([]); - expectArraysClose( - await y.data(), - (Math.abs(1 - 0.3) + Math.abs(2 - (-0.6)) + Math.abs(3 - (-0.1))) / 3); - }); - - it('1D - weighted - Reduction.MEAN', async () => { - const predictions = tf.tensor1d([1, 2, 3]); - const label = tf.tensor1d([0.3, -0.6, -0.1]); - const weights = tf.tensor1d([0.1, 0.2, 0.3]); - - const y = tf.losses.absoluteDifference( - label, predictions, weights, tf.Reduction.MEAN); - - expect(y.shape).toEqual([]); - expectArraysClose( - await y.data(), - ((Math.abs(1 - 0.3) * 0.1) + (Math.abs(2 - (-0.6)) * 0.2) + - (Math.abs(3 - (-0.1)) * 0.3)) / - 0.6); - }); - - it('2D', async () => { - const predictions = tf.tensor2d([4, 8, 12, 8, 1, 3], [2, 3]); - const label = tf.tensor2d([1, 9, 2, -5, -2, 6], [2, 3]); - - const y = tf.losses.absoluteDifference(label, predictions); - - expect(y.shape).toEqual([]); - expectArraysClose( - await y.data(), - (Math.abs(4 - 1) + Math.abs(8 - 9) + Math.abs(12 - 2) + - Math.abs(8 - (-5)) + Math.abs(1 - (-2)) + Math.abs(3 - 6)) / - 6); - }); - - it('2D - weighted - Reduction.SUM_BY_NONZERO_WEIGHTS', async () => { - const predictions = tf.tensor2d([4, 8, 12, 8, 1, 3], [2, 3]); - const label = tf.tensor2d([1, 9, 2, -5, -2, 6], [2, 3]); - const weights = tf.tensor2d([3, 0, 5, 0, 4, 2], [2, 3]); - - const y = tf.losses.absoluteDifference(label, predictions, weights); - - expect(y.shape).toEqual([]); - expectArraysClose( - await y.data(), - (Math.abs(4 - 1) * 3 + Math.abs(8 - 9) * 0 + Math.abs(12 - 2) * 5 + - Math.abs(8 - (-5)) * 0 + Math.abs(1 - (-2)) * 4 + - Math.abs(3 - 6) * 2) / - 4); - }); - - it('2D - weighted - Reduction.NONE', async () => { - const predictions = tf.tensor2d([4, 8, 12, 8, 1, 3], [2, 3]); - const label = tf.tensor2d([1, 9, 2, -5, -2, 6], [2, 3]); - const weights = tf.tensor2d([3, 6, 5, 0, 4, 2], [2, 3]); - - const y = tf.losses.absoluteDifference( - label, predictions, weights, tf.Reduction.NONE); - - expect(y.shape).toEqual([2, 3]); - expectArraysClose(await y.data(), [ - Math.abs(4 - 1) * 3, Math.abs(8 - 9) * 6, Math.abs(12 - 2) * 5, - Math.abs(8 - (-5)) * 0, Math.abs(1 - (-2)) * 4, Math.abs(3 - 6) * 2 - ]); - }); - - it('2D - Reduction.MEAN', async () => { - const predictions = tf.tensor2d([4, 8, 12, 8, 1, 3], [2, 3]); - const label = tf.tensor2d([1, 9, 2, -5, -2, 6], [2, 3]); - - const y = tf.losses.absoluteDifference( - label, predictions, undefined, tf.Reduction.MEAN); - - expect(y.shape).toEqual([]); - expectArraysClose( - await y.data(), - (Math.abs(4 - 1) + Math.abs(8 - 9) + Math.abs(12 - 2) + - Math.abs(8 - (-5)) + Math.abs(1 - (-2)) + Math.abs(3 - 6)) / - 6); - }); - - it('2D - weighted - Reduction.MEAN', async () => { - const predictions = tf.tensor2d([4, 8, 12, 8, 1, 3], [2, 3]); - const label = tf.tensor2d([1, 9, 2, -5, -2, 6], [2, 3]); - const weights = tf.tensor2d([3, 6, 5, 0, 4, 2], [2, 3]); - - const y = tf.losses.absoluteDifference( - label, predictions, weights, tf.Reduction.MEAN); - - expect(y.shape).toEqual([]); - expectArraysClose( - await y.data(), - (Math.abs(4 - 1) * 3 + Math.abs(8 - 9) * 6 + Math.abs(12 - 2) * 5 + - Math.abs(8 - (-5)) * 0 + Math.abs(1 - (-2)) * 4 + - Math.abs(3 - 6) * 2) / - 20); - }); - - it('throws when passed label as a non-tensor', () => { - const predictions = tf.tensor2d([4, 8, 12, 8, 1, 3], [2, 3]); - const weights = tf.tensor2d([3, 6, 5, 0, 4, 2], [2, 3]); - - const e = - /Argument 'labels' passed to 'absoluteDifference' must be a Tensor/; - expect( - () => tf.losses.absoluteDifference( - {} as tf.Tensor, predictions, weights, tf.Reduction.MEAN)) - .toThrowError(e); - }); - - it('throws when passed label as a non-tensor', () => { - const label = tf.tensor2d([1, 9, 2, -5, -2, 6], [2, 3]); - const weights = tf.tensor2d([3, 6, 5, 0, 4, 2], [2, 3]); - - const e = new RegExp( - 'Argument \'predictions\' passed to \'absoluteDifference\' ' + - 'must be a Tensor'); - expect( - () => tf.losses.absoluteDifference( - label, {} as tf.Tensor, weights, tf.Reduction.MEAN)) - .toThrowError(e); - }); - - it('throws when passed weights as a non-tensor', () => { - const predictions = tf.tensor2d([4, 8, 12, 8, 1, 3], [2, 3]); - const label = tf.tensor2d([1, 9, 2, -5, -2, 6], [2, 3]); - - const e = - /Argument 'weights' passed to 'absoluteDifference' must be a Tensor/; - expect( - () => tf.losses.absoluteDifference( - label, predictions, {} as tf.Tensor, tf.Reduction.MEAN)) - .toThrowError(e); - }); - - it('accepts a tensor-like object', async () => { - const predictions = [1, 2, 3]; - const label = [0.3, -0.6, -0.1]; - const weights = [0.1, 0.2, 0.3]; - - const y = tf.losses.absoluteDifference( - label, predictions, weights, tf.Reduction.NONE); - - expect(y.shape).toEqual([3]); - expectArraysClose(await y.data(), [ - Math.abs(1 - 0.3) * 0.1, Math.abs(2 - (-0.6)) * 0.2, - Math.abs(3 - (-0.1)) * 0.3 - ]); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/losses/compute_weighted_loss.ts b/tfjs-master/tfjs-core/src/ops/losses/compute_weighted_loss.ts deleted file mode 100644 index ef079a3af..000000000 --- a/tfjs-master/tfjs-core/src/ops/losses/compute_weighted_loss.ts +++ /dev/null @@ -1,84 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {Tensor} from '../../tensor'; -import {convertToTensor} from '../../tensor_util_env'; -import {TensorLike} from '../../types'; - -import {cast} from '../cast'; -import {div} from '../div'; -import {Reduction} from '../loss_ops_utils'; -import {mean} from '../mean'; -import {mul} from '../mul'; -import {notEqual} from '../not_equal'; -import {ones} from '../ones'; -import {op} from '../operation'; -import {scalar} from '../scalar'; -import {sum} from '../sum'; - -/** - * Computes the weighted loss between two tensors. - * - * @param losses Tensor of shape `[batch_size, d1, ..., dN]`. - * @param weights Tensor whose rank is either 0, or the same rank as - * `losses`, and must be broadcastable to `losses` (i.e., all - * dimensions must be either `1`, or the same as the corresponding - * `losses` dimension). - * - * @doc {heading: 'Training', subheading: 'Losses', namespace: 'losses'} - */ -function computeWeightedLoss_( - losses: T|TensorLike, weights?: Tensor|TensorLike, - reduction = Reduction.SUM_BY_NONZERO_WEIGHTS): O { - const $losses = convertToTensor(losses, 'losses', 'computeWeightedLoss'); - let $weights: Tensor = null; - if (weights != null) { - $weights = convertToTensor(weights, 'weights', 'computeWeightedLoss'); - } - - const weightedLoss = ($weights == null) ? $losses : mul($losses, $weights); - - if (reduction === Reduction.NONE) { - return weightedLoss as O; - } - if (reduction === Reduction.SUM) { - return sum(weightedLoss); - } - if (reduction === Reduction.MEAN) { - if ($weights == null) { - return mean(weightedLoss); - } else { - const broadcastFactor = $losses.size / $weights.size; - const result = div(sum(weightedLoss), sum($weights)); - return broadcastFactor > 1 ? div(result, scalar(broadcastFactor)) : - result as O; - } - } - if (reduction === Reduction.SUM_BY_NONZERO_WEIGHTS) { - if ($weights == null) { - return div(sum(weightedLoss), scalar($losses.size)); - } else { - const broadcastedWeights = mul($weights, ones($losses.shape)); - - const numNonZeros = - cast(sum(notEqual(broadcastedWeights, scalar(0))), 'float32'); - return div(sum(weightedLoss), numNonZeros); - } - } - - throw Error(`Unknown reduction: ${reduction}`); -} -export const computeWeightedLoss = /* @__PURE__ */ op({computeWeightedLoss_}); diff --git a/tfjs-master/tfjs-core/src/ops/losses/compute_weighted_loss_test.ts b/tfjs-master/tfjs-core/src/ops/losses/compute_weighted_loss_test.ts deleted file mode 100644 index 29c282b67..000000000 --- a/tfjs-master/tfjs-core/src/ops/losses/compute_weighted_loss_test.ts +++ /dev/null @@ -1,237 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../../index'; -import {ALL_ENVS, describeWithFlags} from '../../jasmine_util'; -import {expectArraysClose} from '../../test_util'; - -describeWithFlags('computeWeightedLoss', ALL_ENVS, () => { - it('1D - no weights', async () => { - const losses = tf.tensor1d([1, 2, 3]); - - const y = tf.losses.computeWeightedLoss(losses); - - expect(y.shape).toEqual([]); - expectArraysClose(await y.data(), (1 + 2 + 3) / 3); - }); - - it('1D - no weights - Reduction.NONE', async () => { - const losses = tf.tensor1d([1, 2, 3]); - - const y = - tf.losses.computeWeightedLoss(losses, undefined, tf.Reduction.NONE); - - expect(y.shape).toEqual([3]); - expectArraysClose(await y.data(), [1, 2, 3]); - }); - - it('1D - no weights - Reduction.MEAN', async () => { - const losses = tf.tensor1d([1, 2, 3]); - - const y = - tf.losses.computeWeightedLoss(losses, undefined, tf.Reduction.MEAN); - - expect(y.shape).toEqual([]); - expectArraysClose(await y.data(), (1 + 2 + 3) / 3); - }); - - it('1D - no weights - Reduction.SUM', async () => { - const losses = tf.tensor1d([1, 2, 3]); - - const y = - tf.losses.computeWeightedLoss(losses, undefined, tf.Reduction.SUM); - - expect(y.shape).toEqual([]); - expectArraysClose(await y.data(), (1 + 2 + 3)); - }); - - it('1D - weights', async () => { - const losses = tf.tensor1d([1, 2, 3]); - const weights = tf.tensor1d([0.1, 0, 0.3]); - - const y = tf.losses.computeWeightedLoss(losses, weights); - - expect(y.shape).toEqual([]); - expectArraysClose(await y.data(), (1 * 0.1 + 2 * 0 + 3 * 0.3) / 2); - }); - - it('2D - weights - broadcast', async () => { - const losses = tf.tensor2d([[0, 0, 1], [1, 0, 0], [0, 1, 0]], [3, 3]); - const weights = tf.tensor2d([[0.1, 0.2, 0.3]]); - - const y = tf.losses.computeWeightedLoss(losses, weights); - - expect(y.shape).toEqual([]); - expectArraysClose(await y.data(), 0.06666667); - }); - - it('1D - weights - Reduction.NONE', async () => { - const losses = tf.tensor1d([1, 2, 3]); - const weights = tf.tensor1d([0.1, 0.2, 0.3]); - - const y = tf.losses.computeWeightedLoss(losses, weights, tf.Reduction.NONE); - - expect(y.shape).toEqual([3]); - expectArraysClose(await y.data(), [1 * 0.1, 2 * 0.2, 3 * 0.3]); - }); - - it('1D - weights - Reduction.MEAN', async () => { - const losses = tf.tensor1d([1, 2, 3]); - const weights = tf.tensor1d([0.1, 0.2, 0.3]); - - const y = tf.losses.computeWeightedLoss(losses, weights, tf.Reduction.MEAN); - - expect(y.shape).toEqual([]); - expectArraysClose(await y.data(), (1 * 0.1 + 2 * 0.2 + 3 * 0.3) / 0.6); - }); - - it('1D - weights - Reduction.SUM', async () => { - const losses = tf.tensor1d([1, 2, 3]); - const weights = tf.tensor1d([0.1, 0.2, 0.3]); - - const y = tf.losses.computeWeightedLoss(losses, weights, tf.Reduction.SUM); - - expect(y.shape).toEqual([]); - expectArraysClose(await y.data(), (1 * 0.1 + 2 * 0.2 + 3 * 0.3)); - }); - - it('2D - no weights', async () => { - const losses = tf.tensor2d([4, 8, 12, 8, 1, 3], [2, 3]); - - const y = tf.losses.computeWeightedLoss(losses); - - expect(y.shape).toEqual([]); - expectArraysClose(await y.data(), (4 + 8 + 12 + 8 + 1 + 3) / 6); - }); - - it('2D - weights', async () => { - const losses = tf.tensor2d([4, 8, 12, 8, 1, 3], [2, 3]); - const weights = tf.tensor2d([1, 0, 2, -5, 0, 6], [2, 3]); - - const y = tf.losses.computeWeightedLoss(losses, weights); - - expect(y.shape).toEqual([]); - expectArraysClose( - await y.data(), - (4 * 1 + 8 * 0 + 12 * 2 + (8 * -5) + 1 * 0 + 3 * 6) / 4); - }); - - it('2D - no weights - Reduction.MEAN', async () => { - const losses = tf.tensor2d([4, 8, 12, 8, 1, 3], [2, 3]); - - const y = - tf.losses.computeWeightedLoss(losses, undefined, tf.Reduction.MEAN); - - expect(y.shape).toEqual([]); - expectArraysClose(await y.data(), (4 + 8 + 12 + 8 + 1 + 3) / 6); - }); - - it('2D - weights - Reduction.MEAN', async () => { - const losses = tf.tensor2d([4, 8, 12, 8, 1, 3], [2, 3]); - const weights = tf.tensor2d([1, 0, 2, -5, 0, 6], [2, 3]); - - const y = tf.losses.computeWeightedLoss(losses, weights, tf.Reduction.MEAN); - - expect(y.shape).toEqual([]); - expectArraysClose( - await y.data(), - (4 * 1 + 8 * 0 + 12 * 2 + (8 * -5) + 1 * 0 + 3 * 6) / 4); - }); - - it('2D - weights - broadcast - MEAN', async () => { - const losses = tf.tensor2d([[0, 0, 1], [1, 0, 0], [0, 1, 0]], [3, 3]); - const weights = tf.tensor2d([[0.1, 0.2, 0.3]]); - - const y = tf.losses.computeWeightedLoss(losses, weights, tf.Reduction.MEAN); - - expect(y.shape).toEqual([]); - expectArraysClose(await y.data(), (0.3 + 0.1 + 0.2) / (3 * 0.6)); - }); - - it('2D - no weights - Reduction.SUM', async () => { - const losses = tf.tensor2d([4, 8, 12, 8, 1, 3], [2, 3]); - - const y = - tf.losses.computeWeightedLoss(losses, undefined, tf.Reduction.SUM); - - expect(y.shape).toEqual([]); - expectArraysClose(await y.data(), (4 + 8 + 12 + 8 + 1 + 3)); - }); - - it('2D - weights - Reduction.SUM', async () => { - const losses = tf.tensor2d([4, 8, 12, 8, 1, 3], [2, 3]); - const weights = tf.tensor2d([1, 0, 2, -5, 0, 6], [2, 3]); - - const y = tf.losses.computeWeightedLoss(losses, weights, tf.Reduction.SUM); - - expect(y.shape).toEqual([]); - expectArraysClose( - await y.data(), (4 * 1 + 8 * 0 + 12 * 2 + (8 * -5) + 1 * 0 + 3 * 6)); - }); - - it('2D - no weights - Reduction.NONE', async () => { - const losses = tf.tensor2d([4, 8, 12, 8, 1, 3], [2, 3]); - - const y = - tf.losses.computeWeightedLoss(losses, undefined, tf.Reduction.NONE); - - expect(y.shape).toEqual([2, 3]); - expectArraysClose(await y.data(), [4, 8, 12, 8, 1, 3]); - }); - - it('2D - weights - Reduction.NONE', async () => { - const losses = tf.tensor2d([4, 8, 12, 8, 1, 3], [2, 3]); - const weights = tf.tensor2d([1, 0, 2, -5, 0, 6], [2, 3]); - - const y = tf.losses.computeWeightedLoss(losses, weights, tf.Reduction.NONE); - - expect(y.shape).toEqual([2, 3]); - expectArraysClose( - await y.data(), [4 * 1, 8 * 0, 12 * 2, (8 * -5), 1 * 0, 3 * 6]); - }); - - it('throws when passed losses as a non-tensor', () => { - const weights = tf.tensor2d([1, 0, 2, -5, 0, 6], [2, 3]); - - const e = - /Argument 'losses' passed to 'computeWeightedLoss' must be a Tensor/; - expect( - () => tf.losses.computeWeightedLoss( - {} as tf.Tensor, weights, tf.Reduction.NONE)) - .toThrowError(e); - }); - - it('throws when passed weights as a non-tensor', () => { - const losses = tf.tensor2d([4, 8, 12, 8, 1, 3], [2, 3]); - - const e = - /Argument 'weights' passed to 'computeWeightedLoss' must be a Tensor/; - expect( - () => tf.losses.computeWeightedLoss( - losses, {} as tf.Tensor, tf.Reduction.NONE)) - .toThrowError(e); - }); - - it('accepts a tensor-like object', async () => { - const losses = [1, 2, 3]; - const weights = [0.1, 0, 0.3]; - const y = tf.losses.computeWeightedLoss(losses, weights); - - expect(y.shape).toEqual([]); - expectArraysClose(await y.data(), (1 * 0.1 + 2 * 0 + 3 * 0.3) / 2); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/losses/cosine_distance.ts b/tfjs-master/tfjs-core/src/ops/losses/cosine_distance.ts deleted file mode 100644 index 2a6983f21..000000000 --- a/tfjs-master/tfjs-core/src/ops/losses/cosine_distance.ts +++ /dev/null @@ -1,64 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {Tensor} from '../../tensor'; -import {convertToTensor} from '../../tensor_util_env'; -import {TensorLike} from '../../types'; -import {assertShapesMatch} from '../../util'; -import {Reduction} from '../loss_ops_utils'; -import {mul} from '../mul'; -import {op} from '../operation'; -import {scalar} from '../scalar'; -import {sub} from '../sub'; -import {sum} from '../sum'; - -import {computeWeightedLoss} from './compute_weighted_loss'; - -/** - * Computes the cosine distance loss between two tensors. - * - * @param labels The ground truth output tensor, same dimensions as - * 'predictions'. - * @param predictions The predicted outputs. - * @param axis The dimension along which the cosine distance is computed. - * @param weights Tensor whose rank is either 0, or the same rank as - * `labels`, and must be broadcastable to `labels` (i.e., all dimensions - * must be either `1`, or the same as the corresponding `losses` - * dimension). - * @param reduction Type of reduction to apply to loss. Should be of type - * `Reduction` - * - * @doc {heading: 'Training', subheading: 'Losses', namespace: 'losses'} - */ -function cosineDistance_( - labels: T|TensorLike, predictions: T|TensorLike, axis: number, - weights?: Tensor|TensorLike, - reduction = Reduction.SUM_BY_NONZERO_WEIGHTS): O { - const $labels = convertToTensor(labels, 'labels', 'cosineDistance'); - const $predictions = - convertToTensor(predictions, 'predictions', 'cosineDistance'); - let $weights: Tensor = null; - if (weights != null) { - $weights = convertToTensor(weights, 'weights', 'cosineDistance'); - } - assertShapesMatch( - $labels.shape, $predictions.shape, 'Error in cosineDistance: '); - - const one = scalar(1); - const losses = sub(one, sum(mul($labels, $predictions), axis, true)); - return computeWeightedLoss(losses, $weights, reduction); -} -export const cosineDistance = /* @__PURE__ */ op({cosineDistance_}); diff --git a/tfjs-master/tfjs-core/src/ops/losses/cosine_distance_test.ts b/tfjs-master/tfjs-core/src/ops/losses/cosine_distance_test.ts deleted file mode 100644 index 0b20b549d..000000000 --- a/tfjs-master/tfjs-core/src/ops/losses/cosine_distance_test.ts +++ /dev/null @@ -1,198 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import * as tf from '../../index'; -import {ALL_ENVS, describeWithFlags} from '../../jasmine_util'; -import {expectArraysClose} from '../../test_util'; - -describeWithFlags('cosineDistance', ALL_ENVS, () => { - it('1D', async () => { - const predictions = tf.tensor1d([1, 2, 3]); - const label = tf.tensor1d([0.3, -0.6, -0.1]); - - const y = tf.losses.cosineDistance(label, predictions, 0); - - expect(y.shape).toEqual([]); - expectArraysClose(await y.data(), 1 - (1 * 0.3 + 2 * -0.6 + 3 * -0.1)); - }); - - it('1D - weighted - Reduction.SUM_BY_NONZERO_WEIGHTS', async () => { - const predictions = tf.tensor1d([1, 2, 3]); - const label = tf.tensor1d([0.3, -0.6, -0.1]); - const weights = tf.scalar(0.1); - - const y = tf.losses.cosineDistance(label, predictions, 0, weights); - - expect(y.shape).toEqual([]); - expectArraysClose( - await y.data(), (1 - (1 * 0.3 + 2 * -0.6 + 3 * -0.1)) * 0.1); - }); - - it('1D - weighted - Reduction.NONE', async () => { - const predictions = tf.tensor1d([1, 2, 3]); - const label = tf.tensor1d([0.3, -0.6, -0.1]); - const weights = tf.scalar(0.1); - - const y = tf.losses.cosineDistance( - label, predictions, 0, weights, tf.Reduction.NONE); - - expect(y.shape).toEqual([1]); - expectArraysClose( - await y.data(), [(1 - (1 * 0.3 + 2 * -0.6 + 3 * -0.1)) * 0.1]); - }); - - it('1D - Reduction.MEAN', async () => { - const predictions = tf.tensor1d([1, 2, 3]); - const label = tf.tensor1d([0.3, -0.6, -0.1]); - - const y = tf.losses.cosineDistance( - label, predictions, 0, undefined, tf.Reduction.MEAN); - - expect(y.shape).toEqual([]); - expectArraysClose(await y.data(), (1 - (1 * 0.3 + 2 * -0.6 + 3 * -0.1))); - }); - - it('1D - weighted - Reduction.MEAN', async () => { - const predictions = tf.tensor1d([1, 2, 3]); - const label = tf.tensor1d([0.3, -0.6, -0.1]); - const weights = tf.scalar(0.1); - - const y = tf.losses.cosineDistance( - label, predictions, 0, weights, tf.Reduction.MEAN); - - expect(y.shape).toEqual([]); - expectArraysClose( - await y.data(), ((1 - (1 * 0.3 + 2 * -0.6 + 3 * -0.1)) * 0.1) / 0.1); - }); - - it('2D', async () => { - const predictions = tf.tensor2d([4, 8, 12, 8, 1, 3], [2, 3]); - const label = tf.tensor2d([1, 9, 2, -5, -2, 6], [2, 3]); - - const y = tf.losses.cosineDistance(label, predictions, 1); - - expect(y.shape).toEqual([]); - expectArraysClose( - await y.data(), - ((1 - (4 * 1 + 8 * 9 + 12 * 2)) + (1 - (8 * -5 + 1 * -2 + 3 * 6))) / 2); - }); - - it('2D - weighted - Reduction.SUM_BY_NONZERO_WEIGHTS', async () => { - const predictions = tf.tensor2d([4, 8, 12, 8, 1, 3], [2, 3]); - const label = tf.tensor2d([1, 9, 2, -5, -2, 6], [2, 3]); - const weights = tf.tensor2d([3, 0], [2, 1]); - - const y = tf.losses.cosineDistance(label, predictions, 1, weights); - - expect(y.shape).toEqual([]); - expectArraysClose( - await y.data(), - ((1 - (4 * 1 + 8 * 9 + 12 * 2)) * 3 + - (1 - (8 * -5 + 1 * -2 + 3 * 6)) * 0) / - 1); - }); - - it('2D - weighted - Reduction.NONE', async () => { - const predictions = tf.tensor2d([4, 8, 12, 8, 1, 3], [2, 3]); - const label = tf.tensor2d([1, 9, 2, -5, -2, 6], [2, 3]); - const weights = tf.tensor2d([3, 0], [2, 1]); - - const y = tf.losses.cosineDistance( - label, predictions, 1, weights, tf.Reduction.NONE); - - expect(y.shape).toEqual([2, 1]); - expectArraysClose(await y.data(), [ - (1 - (4 * 1 + 8 * 9 + 12 * 2)) * 3, (1 - (8 * -5 + 1 * -2 + 3 * 6)) * 0 - ]); - }); - - it('2D - Reduction.MEAN', async () => { - const predictions = tf.tensor2d([4, 8, 12, 8, 1, 3], [2, 3]); - const label = tf.tensor2d([1, 9, 2, -5, -2, 6], [2, 3]); - - const y = tf.losses.cosineDistance( - label, predictions, 1, undefined, tf.Reduction.MEAN); - - expect(y.shape).toEqual([]); - expectArraysClose( - await y.data(), - ((1 - (4 * 1 + 8 * 9 + 12 * 2)) + (1 - (8 * -5 + 1 * -2 + 3 * 6))) / 2); - }); - - it('2D - weighted - Reduction.MEAN', async () => { - const predictions = tf.tensor2d([4, 8, 12, 8, 1, 3], [2, 3]); - const label = tf.tensor2d([1, 9, 2, -5, -2, 6], [2, 3]); - const weights = tf.tensor2d([3, 0], [2, 1]); - - const y = tf.losses.cosineDistance( - label, predictions, 1, weights, tf.Reduction.MEAN); - - expect(y.shape).toEqual([]); - expectArraysClose( - await y.data(), - ((1 - (4 * 1 + 8 * 9 + 12 * 2)) * 3 + - (1 - (8 * -5 + 1 * -2 + 3 * 6)) * 0) / - 3); - }); - - it('throws when passed label as a non-tensor', () => { - const predictions = tf.tensor2d([4, 8, 12, 8, 1, 3], [2, 3]); - const weights = tf.tensor2d([3, 6, 5, 0, 4, 2], [2, 3]); - - const e = /Argument 'labels' passed to 'cosineDistance' must be a Tensor/; - expect( - () => tf.losses.cosineDistance( - {} as tf.Tensor, predictions, 0, weights, tf.Reduction.MEAN)) - .toThrowError(e); - }); - - it('throws when passed label as a non-tensor', () => { - const label = tf.tensor2d([1, 9, 2, -5, -2, 6], [2, 3]); - const weights = tf.tensor2d([3, 6, 5, 0, 4, 2], [2, 3]); - - const e = new RegExp( - 'Argument \'predictions\' passed to \'cosineDistance\' ' + - 'must be a Tensor'); - expect( - () => tf.losses.cosineDistance( - label, {} as tf.Tensor, 0, weights, tf.Reduction.MEAN)) - .toThrowError(e); - }); - - it('throws when passed weights as a non-tensor', () => { - const predictions = tf.tensor2d([4, 8, 12, 8, 1, 3], [2, 3]); - const label = tf.tensor2d([1, 9, 2, -5, -2, 6], [2, 3]); - - const e = /Argument 'weights' passed to 'cosineDistance' must be a Tensor/; - expect( - () => tf.losses.cosineDistance( - label, predictions, 0, {} as tf.Tensor, tf.Reduction.MEAN)) - .toThrowError(e); - }); - - it('accepts a tensor-like object', async () => { - const predictions = [1, 2, 3]; - const label = [0.3, -0.6, -0.1]; - const weights = 0.1; - - const y = tf.losses.cosineDistance( - label, predictions, 0, weights, tf.Reduction.NONE); - - expect(y.shape).toEqual([1]); - expectArraysClose( - await y.data(), [(1 - (1 * 0.3 + 2 * -0.6 + 3 * -0.1)) * 0.1]); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/losses/hinge_loss.ts b/tfjs-master/tfjs-core/src/ops/losses/hinge_loss.ts deleted file mode 100644 index 7bddda916..000000000 --- a/tfjs-master/tfjs-core/src/ops/losses/hinge_loss.ts +++ /dev/null @@ -1,63 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {Tensor} from '../../tensor'; -import {convertToTensor} from '../../tensor_util_env'; -import {TensorLike} from '../../types'; -import {assertShapesMatch} from '../../util'; -import {Reduction} from '../loss_ops_utils'; -import {mul} from '../mul'; -import {op} from '../operation'; -import {relu} from '../relu'; -import {scalar} from '../scalar'; -import {sub} from '../sub'; - -import {computeWeightedLoss} from './compute_weighted_loss'; - -/** - * Computes the Hinge loss between two tensors. - * - * @param labels The ground truth output tensor, same dimensions as - * 'predictions'. - * @param predictions The predicted outputs. - * @param weights Tensor whose rank is either 0, or the same rank as - * `labels`, and must be broadcastable to `labels` (i.e., all dimensions - * must be either `1`, or the same as the corresponding `losses` - * dimension). - * @param reduction Type of reduction to apply to loss. Should be of type - * `Reduction` - * - * @doc {heading: 'Training', subheading: 'Losses', namespace: 'losses'} - */ -function hingeLoss_( - labels: T|TensorLike, predictions: T|TensorLike, - weights?: Tensor|TensorLike, - reduction = Reduction.SUM_BY_NONZERO_WEIGHTS): O { - let $labels = convertToTensor(labels, 'labels', 'hingeLoss'); - const $predictions = convertToTensor(predictions, 'predictions', 'hingeLoss'); - let $weights: Tensor = null; - if (weights != null) { - $weights = convertToTensor(weights, 'weights', 'hingeLoss'); - } - assertShapesMatch($labels.shape, $predictions.shape, 'Error in hingeLoss: '); - - const one = scalar(1); - // Convert binary labels to (-1, 1) - $labels = sub(mul(scalar(2), $labels), one); - const losses = relu(sub(one, mul($labels, $predictions))); - return computeWeightedLoss(losses, $weights, reduction); -} -export const hingeLoss = /* @__PURE__ */ op({hingeLoss_}); diff --git a/tfjs-master/tfjs-core/src/ops/losses/hinge_loss_test.ts b/tfjs-master/tfjs-core/src/ops/losses/hinge_loss_test.ts deleted file mode 100644 index faaec6bc3..000000000 --- a/tfjs-master/tfjs-core/src/ops/losses/hinge_loss_test.ts +++ /dev/null @@ -1,181 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../../index'; -import {ALL_ENVS, describeWithFlags} from '../../jasmine_util'; -import {expectArraysClose} from '../../test_util'; - -describeWithFlags('hingeLoss', ALL_ENVS, () => { - it('1D', async () => { - const predictions = tf.tensor1d([0, 0, 1, 1]); - const label = tf.tensor1d([0, 1, 0, 1]); - - const y = tf.losses.hingeLoss(label, predictions); - - expect(y.shape).toEqual([]); - expectArraysClose(await y.data(), 1.0); - }); - - it('1D - weighted - Reduction.SUM_BY_NONZERO_WEIGHTS', async () => { - const predictions = tf.tensor1d([0, 0, 1, 1]); - const label = tf.tensor1d([0, 1, 0, 1]); - const weights = tf.tensor1d([0.1, 0.2, 0.3, 0.4]); - - const y = tf.losses.hingeLoss(label, predictions, weights); - - expect(y.shape).toEqual([]); - expectArraysClose(await y.data(), 0.225); - }); - - it('1D - weighted - Reduction.NONE', async () => { - const predictions = tf.tensor1d([0, 0, 1, 1]); - const label = tf.tensor1d([0, 1, 0, 1]); - const weights = tf.tensor1d([0.1, 0.2, 0.3, 0.4]); - - const y = - tf.losses.hingeLoss(label, predictions, weights, tf.Reduction.NONE); - - expect(y.shape).toEqual([4]); - expectArraysClose(await y.data(), [0.1, 0.2, 0.6, 0.0]); - }); - - it('1D - Reduction.MEAN', async () => { - const predictions = tf.tensor1d([0, 0, 1, 1]); - const label = tf.tensor1d([0, 1, 0, 1]); - - const y = - tf.losses.hingeLoss(label, predictions, undefined, tf.Reduction.MEAN); - - expect(y.shape).toEqual([]); - expectArraysClose(await y.data(), 1.0); - }); - - it('1D - weighted - Reduction.MEAN', async () => { - const predictions = tf.tensor1d([0, 0, 1, 1]); - const label = tf.tensor1d([0, 1, 0, 1]); - const weights = tf.tensor1d([0.1, 0.2, 0.3, 0.4]); - - const y = - tf.losses.hingeLoss(label, predictions, weights, tf.Reduction.MEAN); - - expect(y.shape).toEqual([]); - expectArraysClose(await y.data(), 0.9); - }); - - it('2D', async () => { - const predictions = tf.tensor2d([0, 0, 0, 1, 1, 1], [2, 3]); - const label = tf.tensor2d([0, 1, 0, 1, 0, 1], [2, 3]); - - const y = tf.losses.hingeLoss(label, predictions); - - expect(y.shape).toEqual([]); - expectArraysClose(await y.data(), 0.8333333); - }); - - it('2D - weighted - Reduction.SUM_BY_NONZERO_WEIGHTS', async () => { - const predictions = tf.tensor2d([0, 0, 0, 1, 1, 1], [2, 3]); - const label = tf.tensor2d([0, 1, 0, 1, 0, 1], [2, 3]); - const weights = tf.tensor2d([0.1, 0.2, 0.3, 0.4, 0.5, 0.6], [2, 3]); - - const y = tf.losses.hingeLoss(label, predictions, weights); - - expect(y.shape).toEqual([]); - expectArraysClose(await y.data(), 0.26666668); - }); - - it('2D - weighted - Reduction.NONE', async () => { - const predictions = tf.tensor2d([0, 0, 0, 1, 1, 1], [2, 3]); - const label = tf.tensor2d([0, 1, 0, 1, 0, 1], [2, 3]); - const weights = tf.tensor2d([0.1, 0.2, 0.3, 0.4, 0.5, 0.6], [2, 3]); - - const y = - tf.losses.hingeLoss(label, predictions, weights, tf.Reduction.NONE); - - expect(y.shape).toEqual([2, 3]); - expectArraysClose(await y.data(), [0.1, 0.2, 0.3, 0, 1, 0]); - }); - - it('2D - Reduction.MEAN', async () => { - const predictions = tf.tensor2d([0, 0, 0, 1, 1, 1], [2, 3]); - const label = tf.tensor2d([0, 1, 0, 1, 0, 1], [2, 3]); - - const y = - tf.losses.hingeLoss(label, predictions, undefined, tf.Reduction.MEAN); - - expect(y.shape).toEqual([]); - expectArraysClose(await y.data(), 0.8333333); - }); - - it('2D - weighted - Reduction.MEAN', async () => { - const predictions = tf.tensor2d([0, 0, 0, 1, 1, 1], [2, 3]); - const label = tf.tensor2d([0, 1, 0, 1, 0, 1], [2, 3]); - const weights = tf.tensor2d([0.1, 0.2, 0.3, 0.4, 0.5, 0.6], [2, 3]); - - const y = - tf.losses.hingeLoss(label, predictions, weights, tf.Reduction.MEAN); - - expect(y.shape).toEqual([]); - expectArraysClose(await y.data(), 0.76190484); - }); - - it('throws when passed label as a non-tensor', () => { - const predictions = tf.tensor2d([1, 0, 1, 0, 1, 0], [2, 3]); - const weights = tf.tensor2d([1, 0, 1, 0, 1, 0], [2, 3]); - - const e = /Argument 'labels' passed to 'hingeLoss' must be a Tensor/; - expect( - () => tf.losses.hingeLoss( - {} as tf.Tensor, predictions, weights, tf.Reduction.MEAN)) - .toThrowError(e); - }); - - it('throws when passed label as a non-tensor', () => { - const label = tf.tensor2d([1, 0, 1, 0, 1, 0], [2, 3]); - const weights = tf.tensor2d([1, 0, 1, 0, 1, 0], [2, 3]); - - const e = new RegExp( - 'Argument \'predictions\' passed to \'hingeLoss\' ' + - 'must be a Tensor'); - expect( - () => tf.losses.hingeLoss( - label, {} as tf.Tensor, weights, tf.Reduction.MEAN)) - .toThrowError(e); - }); - - it('throws when passed weights as a non-tensor', () => { - const predictions = tf.tensor2d([1, 0, 1, 0, 1, 0], [2, 3]); - const label = tf.tensor2d([1, 0, 1, 0, 1, 0], [2, 3]); - - const e = /Argument 'weights' passed to 'hingeLoss' must be a Tensor/; - expect( - () => tf.losses.hingeLoss( - label, predictions, {} as tf.Tensor, tf.Reduction.MEAN)) - .toThrowError(e); - }); - - it('accepts a tensor-like object', async () => { - const predictions = [0, 0, 1, 1]; - const label = [0, 1, 0, 1]; - const weights = [0.1, 0.2, 0.3, 0.4]; - - const y = - tf.losses.hingeLoss(label, predictions, weights, tf.Reduction.NONE); - - expect(y.shape).toEqual([4]); - expectArraysClose(await y.data(), [0.1, 0.2, 0.6, 0.0]); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/losses/huber_loss.ts b/tfjs-master/tfjs-core/src/ops/losses/huber_loss.ts deleted file mode 100644 index 6db6aac97..000000000 --- a/tfjs-master/tfjs-core/src/ops/losses/huber_loss.ts +++ /dev/null @@ -1,71 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Tensor} from '../../tensor'; -import {convertToTensor} from '../../tensor_util_env'; -import {TensorLike} from '../../types'; -import {assertShapesMatch} from '../../util'; -import {abs} from '../abs'; -import {add} from '../add'; -import {Reduction} from '../loss_ops_utils'; -import {minimum} from '../minimum'; -import {mul} from '../mul'; -import {op} from '../operation'; -import {scalar} from '../scalar'; -import {square} from '../square'; -import {sub} from '../sub'; - -import {computeWeightedLoss} from './compute_weighted_loss'; - -/** - * Computes the Huber loss between two tensors. - * - * @param labels The ground truth output tensor, same dimensions as - * 'predictions'. - * @param predictions The predicted outputs. - * @param weights Tensor whose rank is either 0, or the same rank as - * `labels`, and must be broadcastable to `labels` (i.e., all dimensions - * must be either `1`, or the same as the corresponding `losses` - * dimension). - * @param delta Point where Huber loss changes from quadratic to linear. - * @param reduction Type of reduction to apply to loss. Should be of type - * `Reduction`. - * - * @doc {heading: 'Training', subheading: 'Losses', namespace: 'losses'} - */ -function huberLoss_( - labels: T|TensorLike, predictions: T|TensorLike, - weights?: Tensor|TensorLike, delta = 1.0, - reduction = Reduction.SUM_BY_NONZERO_WEIGHTS): O { - const $labels = convertToTensor(labels, 'labels', 'huberLoss'); - const $predictions = convertToTensor(predictions, 'predictions', 'huberLoss'); - let $weights: Tensor = null; - if (weights != null) { - $weights = convertToTensor(weights, 'weights', 'huberLoss'); - } - assertShapesMatch($labels.shape, $predictions.shape, 'Error in huberLoss: '); - - const deltaScalar = scalar(delta); - const error = abs(sub($predictions, $labels)); - const quadratic = minimum(error, deltaScalar); - const linear = sub(error, quadratic); - - const losses = - add(mul(scalar(0.5), square(quadratic)), mul(deltaScalar, linear)); - return computeWeightedLoss(losses, $weights, reduction); -} -export const huberLoss = /* @__PURE__ */ op({huberLoss_}); diff --git a/tfjs-master/tfjs-core/src/ops/losses/huber_loss_test.ts b/tfjs-master/tfjs-core/src/ops/losses/huber_loss_test.ts deleted file mode 100644 index f1ef22079..000000000 --- a/tfjs-master/tfjs-core/src/ops/losses/huber_loss_test.ts +++ /dev/null @@ -1,191 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import * as tf from '../../index'; -import {ALL_ENVS, describeWithFlags} from '../../jasmine_util'; -import {expectArraysClose} from '../../test_util'; - -describeWithFlags('huberLoss', ALL_ENVS, () => { - it('1D', async () => { - const labels = tf.tensor1d([1, 2, 3]); - const predictions = tf.tensor1d([0.3, 0.6, 0.1]); - - const y = tf.losses.huberLoss(labels, predictions); - - expect(y.shape).toEqual([]); - expectArraysClose(await y.data(), 1.1816667); - }); - - it('1D - delta', async () => { - const labels = tf.tensor1d([1, 2, 3]); - const predictions = tf.tensor1d([0.3, 0.6, 0.1]); - const delta = 0.4; - - const y = tf.losses.huberLoss(labels, predictions, undefined, delta); - - expect(y.shape).toEqual([]); - expectArraysClose(await y.data(), 0.58666664); - }); - - it('1D - weighted - Reduction.SUM_BY_NONZERO_WEIGHTS', async () => { - const labels = tf.tensor1d([1, 2, 3]); - const predictions = tf.tensor1d([0.3, 0.6, 0.1]); - const weights = tf.tensor1d([0.1, 0.2, 0.3]); - - const y = tf.losses.huberLoss(labels, predictions, weights); - - expect(y.shape).toEqual([]); - expectArraysClose(await y.data(), 0.30816665); - }); - - it('1D - weighted - Reduction.NONE', async () => { - const labels = tf.tensor1d([1, 2, 3]); - const predictions = tf.tensor1d([0.3, 0.6, 0.1]); - const weights = tf.tensor1d([0.1, 0.2, 0.3]); - - const y = tf.losses.huberLoss( - labels, predictions, weights, undefined, tf.Reduction.NONE); - - expect(y.shape).toEqual([3]); - expectArraysClose(await y.data(), [0.0245, 0.17999999, 0.72]); - }); - - it('1D - Reduction.MEAN', async () => { - const labels = tf.tensor1d([1, 2, 3]); - const predictions = tf.tensor1d([0.3, 0.6, 0.1]); - - const y = tf.losses.huberLoss( - labels, predictions, undefined, undefined, tf.Reduction.MEAN); - - expect(y.shape).toEqual([]); - expectArraysClose(await y.data(), 1.1816667); - }); - - it('1D - weighted - Reduction.MEAN', async () => { - const labels = tf.tensor1d([1, 2, 3]); - const predictions = tf.tensor1d([0.3, 0.6, 0.1]); - const weights = tf.tensor1d([0.1, 0.2, 0.3]); - - const y = tf.losses.huberLoss( - labels, predictions, weights, undefined, tf.Reduction.MEAN); - - expect(y.shape).toEqual([]); - expectArraysClose(await y.data(), 1.5408332); - }); - - it('2D', async () => { - const labels = tf.tensor2d([0.4, 0.8, 0.12, 0.8, 0.1, 0.3], [2, 3]); - const predictions = tf.tensor2d([0.1, 0.7, 0.1, 0.5, 0.05, 0.15], [2, 3]); - - const y = tf.losses.huberLoss(labels, predictions); - - expect(y.shape).toEqual([]); - expectArraysClose(await y.data(), 0.01795); - }); - - it('2D - weighted - Reduction.SUM_BY_NONZERO_WEIGHTS', async () => { - const labels = tf.tensor2d([0.4, 0.8, 0.12, 0.8, 0.1, 0.3], [2, 3]); - const predictions = tf.tensor2d([0.1, 0.7, 0.1, 0.5, 0.05, 0.15], [2, 3]); - const weights = tf.tensor2d([3, 0, 5, 0, 4, 2], [2, 3]); - - const y = tf.losses.huberLoss(labels, predictions, weights); - - expect(y.shape).toEqual([]); - expectArraysClose(await y.data(), 0.040875003); - }); - - it('2D - weighted - Reduction.NONE', async () => { - const labels = tf.tensor2d([0.4, 0.8, 0.12, 0.8, 0.1, 0.3], [2, 3]); - const predictions = tf.tensor2d([0.1, 0.7, 0.1, 0.5, 0.05, 0.15], [2, 3]); - const weights = tf.tensor2d([3, 0, 5, 0, 4, 2], [2, 3]); - - const y = tf.losses.huberLoss( - labels, predictions, weights, undefined, tf.Reduction.NONE); - - expect(y.shape).toEqual([2, 3]); - expectArraysClose(await y.data(), [0.135, 0., 0.001, 0., 0.005, 0.0225]); - }); - - it('2D - Reduction.MEAN', async () => { - const labels = tf.tensor2d([0.4, 0.8, 0.12, 0.8, 0.1, 0.3], [2, 3]); - const predictions = tf.tensor2d([0.1, 0.7, 0.1, 0.5, 0.05, 0.15], [2, 3]); - - const y = tf.losses.huberLoss( - labels, predictions, undefined, undefined, tf.Reduction.MEAN); - - expect(y.shape).toEqual([]); - expectArraysClose(await y.data(), 0.01795); - }); - - it('2D - weighted - Reduction.MEAN', async () => { - const labels = tf.tensor2d([0.4, 0.8, 0.12, 0.8, 0.1, 0.3], [2, 3]); - const predictions = tf.tensor2d([0.1, 0.7, 0.1, 0.5, 0.05, 0.15], [2, 3]); - const weights = tf.tensor2d([3, 0, 5, 0, 4, 2], [2, 3]); - - const y = tf.losses.huberLoss( - labels, predictions, weights, undefined, tf.Reduction.MEAN); - - expect(y.shape).toEqual([]); - expectArraysClose(await y.data(), 0.011678572); - }); - - it('throws when passed label as a non-tensor', () => { - const predictions = tf.tensor2d([0.1, 0.7, 0.1, 0.5, 0.05, 0.15], [2, 3]); - const weights = tf.tensor2d([3, 6, 5, 0, 4, 2], [2, 3]); - - const e = /Argument 'labels' passed to 'huberLoss' must be a Tensor/; - expect( - () => tf.losses.huberLoss( - {} as tf.Tensor, predictions, weights, tf.Reduction.MEAN)) - .toThrowError(e); - }); - - it('throws when passed label as a non-tensor', () => { - const labels = tf.tensor2d([0.4, 0.8, 0.12, 0.8, 0.1, 0.3], [2, 3]); - const weights = tf.tensor2d([3, 6, 5, 0, 4, 2], [2, 3]); - - const e = new RegExp( - 'Argument \'predictions\' passed to \'huberLoss\' ' + - 'must be a Tensor'); - expect( - () => tf.losses.huberLoss( - labels, {} as tf.Tensor, weights, tf.Reduction.MEAN)) - .toThrowError(e); - }); - - it('throws when passed weights as a non-tensor', () => { - const labels = tf.tensor2d([0.4, 0.8, 0.12, 0.8, 0.1, 0.3], [2, 3]); - const predictions = tf.tensor2d([0.1, 0.7, 0.1, 0.5, 0.05, 0.15], [2, 3]); - - const e = /Argument 'weights' passed to 'huberLoss' must be a Tensor/; - expect( - () => tf.losses.huberLoss( - labels, predictions, {} as tf.Tensor, tf.Reduction.MEAN)) - .toThrowError(e); - }); - - it('accepts a tensor-like object', async () => { - const labels = [1, 2, 3]; - const predictions = [0.3, 0.6, 0.1]; - const weights = [0.1, 0.2, 0.3]; - - const y = tf.losses.huberLoss( - labels, predictions, weights, undefined, tf.Reduction.NONE); - - expect(y.shape).toEqual([3]); - expectArraysClose(await y.data(), [0.0245, 0.17999999, 0.72]); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/losses/log_loss.ts b/tfjs-master/tfjs-core/src/ops/losses/log_loss.ts deleted file mode 100644 index 0fae4f326..000000000 --- a/tfjs-master/tfjs-core/src/ops/losses/log_loss.ts +++ /dev/null @@ -1,70 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Tensor} from '../../tensor'; -import {convertToTensor} from '../../tensor_util_env'; -import {TensorLike} from '../../types'; -import {assertShapesMatch} from '../../util'; -import {add} from '../add'; -import {log} from '../log'; -import {Reduction} from '../loss_ops_utils'; -import {mul} from '../mul'; -import {neg} from '../neg'; -import {op} from '../operation'; -import {scalar} from '../scalar'; -import {sub} from '../sub'; - -import {computeWeightedLoss} from './compute_weighted_loss'; - -/** - * Computes the log loss between two tensors. - * - * @param labels The ground truth output tensor, same dimensions as - * 'predictions'. - * @param predictions The predicted outputs. - * @param weights Tensor whose rank is either 0, or the same rank as - * `labels`, and must be broadcastable to `labels` (i.e., all dimensions - * must be either `1`, or the same as the corresponding `losses` - * dimension). - * @param epsilon A small increment to avoid taking log of zero - * @param reduction Type of reduction to apply to loss. Should be of type - * `Reduction` - * - * @doc {heading: 'Training', subheading: 'Losses', namespace: 'losses'} - */ -function logLoss_( - labels: T|TensorLike, predictions: T|TensorLike, - weights?: Tensor|TensorLike, epsilon = 1e-7, - reduction = Reduction.SUM_BY_NONZERO_WEIGHTS): O { - const $labels = convertToTensor(labels, 'labels', 'logLoss'); - const $predictions = convertToTensor(predictions, 'predictions', 'logLoss'); - let $weights: Tensor = null; - if (weights != null) { - $weights = convertToTensor(weights, 'weights', 'logLoss'); - } - assertShapesMatch($labels.shape, $predictions.shape, 'Error in logLoss: '); - - const one = scalar(1); - const epsilonScalar = scalar(epsilon); - - const l1 = neg(mul($labels, log(add($predictions, epsilonScalar)))); - const l2 = - mul(sub(one, $labels), log(add(sub(one, $predictions), epsilonScalar))); - const losses = sub(l1, l2); - return computeWeightedLoss(losses, $weights, reduction); -} -export const logLoss = /* @__PURE__ */ op({logLoss_}); diff --git a/tfjs-master/tfjs-core/src/ops/losses/log_loss_test.ts b/tfjs-master/tfjs-core/src/ops/losses/log_loss_test.ts deleted file mode 100644 index 6a10d12db..000000000 --- a/tfjs-master/tfjs-core/src/ops/losses/log_loss_test.ts +++ /dev/null @@ -1,191 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import * as tf from '../../index'; -import {ALL_ENVS, describeWithFlags} from '../../jasmine_util'; -import {expectArraysClose} from '../../test_util'; - -describeWithFlags('logLoss', ALL_ENVS, () => { - it('1D', async () => { - const labels = tf.tensor1d([1, 2, 3]); - const predictions = tf.tensor1d([0.3, 0.6, 0.1]); - - const y = tf.losses.logLoss(labels, predictions); - - expect(y.shape).toEqual([]); - expectArraysClose(await y.data(), 2.668788); - }); - - it('1D - Check for negative values', async () => { - const labels = tf.tensor1d([1, 2, 3]); - const predictions = tf.tensor1d([0.3, -0.6, -0.1]); - - const y = tf.losses.logLoss(labels, predictions); - - expect(y.shape).toEqual([]); - expectArraysClose(await y.data(), NaN); - }); - - it('1D - weighted - Reduction.SUM_BY_NONZERO_WEIGHTS', async () => { - const labels = tf.tensor1d([1, 2, 3]); - const predictions = tf.tensor1d([0.3, 0.6, 0.1]); - const weights = tf.tensor1d([0.1, 0.2, 0.3]); - - const y = tf.losses.logLoss(labels, predictions, weights); - - expect(y.shape).toEqual([]); - expectArraysClose(await y.data(), 0.7168596); - }); - - it('1D - weighted - Reduction.NONE', async () => { - const labels = tf.tensor1d([1, 2, 3]); - const predictions = tf.tensor1d([0.3, 0.6, 0.1]); - const weights = tf.tensor1d([0.1, 0.2, 0.3]); - - const y = tf.losses.logLoss( - labels, predictions, weights, undefined, tf.Reduction.NONE); - - expect(y.shape).toEqual([3]); - expectArraysClose(await y.data(), [0.12039725, 0.02107204, 2.0091095]); - }); - - it('1D - Reduction.MEAN', async () => { - const labels = tf.tensor1d([1, 2, 3]); - const predictions = tf.tensor1d([0.3, 0.6, 0.1]); - - const y = tf.losses.logLoss( - labels, predictions, undefined, undefined, tf.Reduction.MEAN); - - expect(y.shape).toEqual([]); - expectArraysClose(await y.data(), 2.668788); - }); - - it('1D - weighted - Reduction.MEAN', async () => { - const labels = tf.tensor1d([1, 2, 3]); - const predictions = tf.tensor1d([0.3, 0.6, 0.1]); - const weights = tf.tensor1d([0.1, 0.2, 0.3]); - - const y = tf.losses.logLoss( - labels, predictions, weights, undefined, tf.Reduction.MEAN); - - expect(y.shape).toEqual([]); - expectArraysClose(await y.data(), 3.5842977); - }); - - it('2D', async () => { - const labels = tf.tensor2d([0.4, 0.8, 0.12, 0.8, 0.1, 0.3], [2, 3]); - const predictions = tf.tensor2d([0.1, 0.7, 0.1, 0.5, 0.05, 0.15], [2, 3]); - - const y = tf.losses.logLoss(labels, predictions); - - expect(y.shape).toEqual([]); - expectArraysClose(await y.data(), 0.60019904); - }); - - it('2D - weighted - Reduction.SUM_BY_NONZERO_WEIGHTS', async () => { - const labels = tf.tensor2d([0.4, 0.8, 0.12, 0.8, 0.1, 0.3], [2, 3]); - const predictions = tf.tensor2d([0.1, 0.7, 0.1, 0.5, 0.05, 0.15], [2, 3]); - const weights = tf.tensor2d([3, 0, 5, 0, 4, 2], [2, 3]); - - const y = tf.losses.logLoss(labels, predictions, weights); - - expect(y.shape).toEqual([]); - expectArraysClose(await y.data(), 1.8866577); - }); - - it('2D - weighted - Reduction.NONE', async () => { - const labels = tf.tensor2d([0.4, 0.8, 0.12, 0.8, 0.1, 0.3], [2, 3]); - const predictions = tf.tensor2d([0.1, 0.7, 0.1, 0.5, 0.05, 0.15], [2, 3]); - const weights = tf.tensor2d([3, 0, 5, 0, 4, 2], [2, 3]); - - const y = tf.losses.logLoss( - labels, predictions, weights, undefined, tf.Reduction.NONE); - - expect(y.shape).toEqual([2, 3]); - expectArraysClose( - await y.data(), [2.9527497, 0., 1.8451363, 0., 1.3829476, 1.3657978]); - }); - - it('2D - Reduction.MEAN', async () => { - const labels = tf.tensor2d([0.4, 0.8, 0.12, 0.8, 0.1, 0.3], [2, 3]); - const predictions = tf.tensor2d([0.1, 0.7, 0.1, 0.5, 0.05, 0.15], [2, 3]); - - const y = tf.losses.logLoss( - labels, predictions, undefined, undefined, tf.Reduction.MEAN); - - expect(y.shape).toEqual([]); - expectArraysClose(await y.data(), 0.60019904); - }); - - it('2D - weighted - Reduction.MEAN', async () => { - const labels = tf.tensor2d([0.4, 0.8, 0.12, 0.8, 0.1, 0.3], [2, 3]); - const predictions = tf.tensor2d([0.1, 0.7, 0.1, 0.5, 0.05, 0.15], [2, 3]); - const weights = tf.tensor2d([3, 0, 5, 0, 4, 2], [2, 3]); - - const y = tf.losses.logLoss( - labels, predictions, weights, undefined, tf.Reduction.MEAN); - - expect(y.shape).toEqual([]); - expectArraysClose(await y.data(), 0.53904504); - }); - - it('throws when passed label as a non-tensor', () => { - const predictions = tf.tensor2d([0.1, 0.7, 0.1, 0.5, 0.05, 0.15], [2, 3]); - const weights = tf.tensor2d([3, 6, 5, 0, 4, 2], [2, 3]); - - const e = /Argument 'labels' passed to 'logLoss' must be a Tensor/; - expect( - () => tf.losses.logLoss( - {} as tf.Tensor, predictions, weights, tf.Reduction.MEAN)) - .toThrowError(e); - }); - - it('throws when passed label as a non-tensor', () => { - const labels = tf.tensor2d([0.4, 0.8, 0.12, 0.8, 0.1, 0.3], [2, 3]); - const weights = tf.tensor2d([3, 6, 5, 0, 4, 2], [2, 3]); - - const e = new RegExp( - 'Argument \'predictions\' passed to \'logLoss\' ' + - 'must be a Tensor'); - expect( - () => tf.losses.logLoss( - labels, {} as tf.Tensor, weights, tf.Reduction.MEAN)) - .toThrowError(e); - }); - - it('throws when passed weights as a non-tensor', () => { - const labels = tf.tensor2d([0.4, 0.8, 0.12, 0.8, 0.1, 0.3], [2, 3]); - const predictions = tf.tensor2d([0.1, 0.7, 0.1, 0.5, 0.05, 0.15], [2, 3]); - - const e = /Argument 'weights' passed to 'logLoss' must be a Tensor/; - expect( - () => tf.losses.logLoss( - labels, predictions, {} as tf.Tensor, tf.Reduction.MEAN)) - .toThrowError(e); - }); - - it('accepts a tensor-like object', async () => { - const labels = [1, 2, 3]; - const predictions = [0.3, 0.6, 0.1]; - const weights = [0.1, 0.2, 0.3]; - - const y = tf.losses.logLoss( - labels, predictions, weights, undefined, tf.Reduction.NONE); - - expect(y.shape).toEqual([3]); - expectArraysClose(await y.data(), [0.12039725, 0.02107204, 2.0091095]); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/losses/mean_squared_error.ts b/tfjs-master/tfjs-core/src/ops/losses/mean_squared_error.ts deleted file mode 100644 index af1a110d0..000000000 --- a/tfjs-master/tfjs-core/src/ops/losses/mean_squared_error.ts +++ /dev/null @@ -1,60 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Tensor} from '../../tensor'; -import {convertToTensor} from '../../tensor_util_env'; -import {TensorLike} from '../../types'; -import {assertShapesMatch} from '../../util'; -import {Reduction} from '../loss_ops_utils'; -import {op} from '../operation'; -import {squaredDifference} from '../squared_difference'; - -import {computeWeightedLoss} from './compute_weighted_loss'; - -/** - * Computes the mean squared error between two tensors. - * - * @param labels The ground truth output tensor, same dimensions as - * 'predictions'. - * @param predictions The predicted outputs. - * @param weights Tensor whose rank is either 0, or the same rank as - * `labels`, and must be broadcastable to `labels` (i.e., all dimensions - * must be either `1`, or the same as the corresponding `losses` - * dimension). - * @param reduction Type of reduction to apply to loss. Should be of type - * `Reduction` - * - * @doc {heading: 'Training', subheading: 'Losses', namespace: 'losses'} - */ -function meanSquaredError_( - labels: T|TensorLike, predictions: T|TensorLike, - weights?: Tensor|TensorLike, - reduction = Reduction.SUM_BY_NONZERO_WEIGHTS): O { - const $labels = convertToTensor(labels, 'labels', 'meanSquaredError'); - const $predictions = - convertToTensor(predictions, 'predictions', 'meanSquaredError'); - let $weights: Tensor = null; - if (weights != null) { - $weights = convertToTensor(weights, 'weights', 'meanSquaredError'); - } - assertShapesMatch( - $labels.shape, $predictions.shape, 'Error in meanSquaredError: '); - - const losses = squaredDifference($labels, $predictions); - return computeWeightedLoss(losses, $weights, reduction); -} -export const meanSquaredError = /* @__PURE__ */ op({meanSquaredError_}); diff --git a/tfjs-master/tfjs-core/src/ops/losses/mean_squared_error_test.ts b/tfjs-master/tfjs-core/src/ops/losses/mean_squared_error_test.ts deleted file mode 100644 index e0f93b908..000000000 --- a/tfjs-master/tfjs-core/src/ops/losses/mean_squared_error_test.ts +++ /dev/null @@ -1,227 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import * as tf from '../../index'; -import {ALL_ENVS, describeWithFlags} from '../../jasmine_util'; -import {expectArraysClose} from '../../test_util'; - -describeWithFlags('meanSquaredError', ALL_ENVS, () => { - it('1D', async () => { - const predictions = tf.tensor1d([1, 2, 3]); - const label = tf.tensor1d([0.3, -0.6, -0.1]); - - const y = tf.losses.meanSquaredError(label, predictions); - - expect(y.shape).toEqual([]); - expectArraysClose( - await y.data(), - ((1 - 0.3) * (1 - 0.3) + (2 - (-0.6)) * (2 - (-0.6)) + - (3 - (-0.1)) * (3 - (-0.1))) / - 3); - }); - - it('1D - weighted - Reduction.SUM_BY_NONZERO_WEIGHTS', async () => { - const predictions = tf.tensor1d([1, 2, 3]); - const label = tf.tensor1d([0.3, -0.6, -0.1]); - const weights = tf.tensor1d([0.1, 0.2, 0.3]); - - const y = tf.losses.meanSquaredError(label, predictions, weights); - - expect(y.shape).toEqual([]); - expectArraysClose( - await y.data(), - ((1 - 0.3) * (1 - 0.3) * 0.1 + (2 - (-0.6)) * (2 - (-0.6)) * 0.2 + - (3 - (-0.1)) * (3 - (-0.1)) * 0.3) / - 3); - }); - - it('1D - weighted - Reduction.NONE', async () => { - const predictions = tf.tensor1d([1, 2, 3]); - const label = tf.tensor1d([0.3, -0.6, -0.1]); - const weights = tf.tensor1d([0.1, 0.2, 0.3]); - - const y = tf.losses.meanSquaredError( - label, predictions, weights, tf.Reduction.NONE); - - expect(y.shape).toEqual([3]); - expectArraysClose(await y.data(), [ - (1 - 0.3) * (1 - 0.3) * 0.1, (2 - (-0.6)) * (2 - (-0.6)) * 0.2, - (3 - (-0.1)) * (3 - (-0.1)) * 0.3 - ]); - }); - - it('1D - Reduction.MEAN', async () => { - const predictions = tf.tensor1d([1, 2, 3]); - const label = tf.tensor1d([0.3, -0.6, -0.1]); - - const y = tf.losses.meanSquaredError( - label, predictions, undefined, tf.Reduction.MEAN); - - expect(y.shape).toEqual([]); - expectArraysClose( - await y.data(), - ((1 - 0.3) * (1 - 0.3) + (2 - (-0.6)) * (2 - (-0.6)) + - (3 - (-0.1)) * (3 - (-0.1))) / - 3); - }); - - it('1D - weighted - Reduction.MEAN', async () => { - const predictions = tf.tensor1d([1, 2, 3]); - const label = tf.tensor1d([0.3, -0.6, -0.1]); - const weights = tf.tensor1d([0.1, 0.2, 0.3]); - - const y = tf.losses.meanSquaredError( - label, predictions, weights, tf.Reduction.MEAN); - - expect(y.shape).toEqual([]); - expectArraysClose( - await y.data(), - (((1 - 0.3) * (1 - 0.3) * 0.1) + ((2 - (-0.6)) * (2 - (-0.6)) * 0.2) + - ((3 - (-0.1)) * (3 - (-0.1)) * 0.3)) / - 0.6); - }); - - it('2D', async () => { - const predictions = tf.tensor2d([4, 8, 12, 8, 1, 3], [2, 3]); - const label = tf.tensor2d([1, 9, 2, -5, -2, 6], [2, 3]); - - const y = tf.losses.meanSquaredError(label, predictions); - - expect(y.shape).toEqual([]); - expectArraysClose( - await y.data(), - ((4 - 1) * (4 - 1) + (8 - 9) * (8 - 9) + (12 - 2) * (12 - 2) + - (8 - (-5)) * (8 - (-5)) + (1 - (-2)) * (1 - (-2)) + - (3 - 6) * (3 - 6)) / - 6); - }); - - it('2D - weighted - Reduction.SUM_BY_NONZERO_WEIGHTS', async () => { - const predictions = tf.tensor2d([4, 8, 12, 8, 1, 3], [2, 3]); - const label = tf.tensor2d([1, 9, 2, -5, -2, 6], [2, 3]); - const weights = tf.tensor2d([3, 0, 5, 0, 4, 2], [2, 3]); - - const y = tf.losses.meanSquaredError(label, predictions, weights); - - expect(y.shape).toEqual([]); - expectArraysClose( - await y.data(), - ((4 - 1) * (4 - 1) * 3 + (8 - 9) * (8 - 9) * 0 + - (12 - 2) * (12 - 2) * 5 + (8 - (-5)) * (8 - (-5)) * 0 + - (1 - (-2)) * (1 - (-2)) * 4 + (3 - 6) * (3 - 6) * 2) / - 4); - }); - - it('2D - weighted - Reduction.NONE', async () => { - const predictions = tf.tensor2d([4, 8, 12, 8, 1, 3], [2, 3]); - const label = tf.tensor2d([1, 9, 2, -5, -2, 6], [2, 3]); - const weights = tf.tensor2d([3, 6, 5, 0, 4, 2], [2, 3]); - - const y = tf.losses.meanSquaredError( - label, predictions, weights, tf.Reduction.NONE); - - expect(y.shape).toEqual([2, 3]); - expectArraysClose(await y.data(), [ - (4 - 1) * (4 - 1) * 3, (8 - 9) * (8 - 9) * 6, (12 - 2) * (12 - 2) * 5, - (8 - (-5)) * (8 - (-5)) * 0, (1 - (-2)) * (1 - (-2)) * 4, - (3 - 6) * (3 - 6) * 2 - ]); - }); - - it('2D - Reduction.MEAN', async () => { - const predictions = tf.tensor2d([4, 8, 12, 8, 1, 3], [2, 3]); - const label = tf.tensor2d([1, 9, 2, -5, -2, 6], [2, 3]); - - const y = tf.losses.meanSquaredError( - label, predictions, undefined, tf.Reduction.MEAN); - - expect(y.shape).toEqual([]); - expectArraysClose( - await y.data(), - ((4 - 1) * (4 - 1) + (8 - 9) * (8 - 9) + (12 - 2) * (12 - 2) + - (8 - (-5)) * (8 - (-5)) + (1 - (-2)) * (1 - (-2)) + - (3 - 6) * (3 - 6)) / - 6); - }); - - it('2D - weighted - Reduction.MEAN', async () => { - const predictions = tf.tensor2d([4, 8, 12, 8, 1, 3], [2, 3]); - const label = tf.tensor2d([1, 9, 2, -5, -2, 6], [2, 3]); - const weights = tf.tensor2d([3, 6, 5, 0, 4, 2], [2, 3]); - - const y = tf.losses.meanSquaredError( - label, predictions, weights, tf.Reduction.MEAN); - - expect(y.shape).toEqual([]); - expectArraysClose( - await y.data(), - ((4 - 1) * (4 - 1) * 3 + (8 - 9) * (8 - 9) * 6 + - (12 - 2) * (12 - 2) * 5 + (8 - (-5)) * (8 - (-5)) * 0 + - (1 - (-2)) * (1 - (-2)) * 4 + (3 - 6) * (3 - 6) * 2) / - 20); - }); - - it('throws when passed label as a non-tensor', () => { - const predictions = tf.tensor2d([4, 8, 12, 8, 1, 3], [2, 3]); - const weights = tf.tensor2d([3, 6, 5, 0, 4, 2], [2, 3]); - - const e = /Argument 'labels' passed to 'meanSquaredError' must be a Tensor/; - expect( - () => tf.losses.meanSquaredError( - {} as tf.Tensor, predictions, weights, tf.Reduction.MEAN)) - .toThrowError(e); - }); - - it('throws when passed label as a non-tensor', () => { - const label = tf.tensor2d([1, 9, 2, -5, -2, 6], [2, 3]); - const weights = tf.tensor2d([3, 6, 5, 0, 4, 2], [2, 3]); - - const e = new RegExp( - 'Argument \'predictions\' passed to \'meanSquaredError\' ' + - 'must be a Tensor'); - expect( - () => tf.losses.meanSquaredError( - label, {} as tf.Tensor, weights, tf.Reduction.MEAN)) - .toThrowError(e); - }); - - it('throws when passed weights as a non-tensor', () => { - const predictions = tf.tensor2d([4, 8, 12, 8, 1, 3], [2, 3]); - const label = tf.tensor2d([1, 9, 2, -5, -2, 6], [2, 3]); - - const e = - /Argument 'weights' passed to 'meanSquaredError' must be a Tensor/; - expect( - () => tf.losses.meanSquaredError( - label, predictions, {} as tf.Tensor, tf.Reduction.MEAN)) - .toThrowError(e); - }); - - it('accepts a tensor-like object', async () => { - const predictions = [1, 2, 3]; - const label = [0.3, -0.6, -0.1]; - const weights = [0.1, 0.2, 0.3]; - - const y = tf.losses.meanSquaredError( - label, predictions, weights, tf.Reduction.NONE); - - expect(y.shape).toEqual([3]); - expectArraysClose(await y.data(), [ - (1 - 0.3) * (1 - 0.3) * 0.1, (2 - (-0.6)) * (2 - (-0.6)) * 0.2, - (3 - (-0.1)) * (3 - (-0.1)) * 0.3 - ]); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/losses/sigmoid_cross_entropy.ts b/tfjs-master/tfjs-core/src/ops/losses/sigmoid_cross_entropy.ts deleted file mode 100644 index f3f59d1b0..000000000 --- a/tfjs-master/tfjs-core/src/ops/losses/sigmoid_cross_entropy.ts +++ /dev/null @@ -1,121 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Tensor} from '../../tensor'; -import {convertToTensor} from '../../tensor_util_env'; -import {TensorLike} from '../../types'; -import {assertShapesMatch} from '../../util'; -import {abs} from '../abs'; -import {add} from '../add'; -import {exp} from '../exp'; -import {log1p} from '../log1p'; -import {Reduction} from '../loss_ops_utils'; -import {mul} from '../mul'; -import {neg} from '../neg'; -import {op} from '../operation'; -import {relu} from '../relu'; -import {scalar} from '../scalar'; -import {sub} from '../sub'; - -import {computeWeightedLoss} from './compute_weighted_loss'; - -function sigmoidCrossEntropyWithLogits_( - labels: T|TensorLike, logits: T|TensorLike): O { - const $labels = - convertToTensor(labels, 'labels', 'sigmoidCrossEntropyWithLogits'); - const $logits = - convertToTensor(logits, 'logits', 'sigmoidCrossEntropyWithLogits'); - assertShapesMatch( - $labels.shape, $logits.shape, 'Error in sigmoidCrossEntropyWithLogits: '); - - /** - * Implementation Details: - * - * For brevity, let `x = logits`, `z = labels`. The logistic loss is - * z * -log(sigmoid(x)) + (1 - z) * -log(1 - sigmoid(x)) - * = z * -log(1 / (1 + exp(-x))) + (1 - z) * -log(exp(-x) / (1 + exp(-x))) - * = z * log(1 + exp(-x)) + (1 - z) * (-log(exp(-x)) + log(1 + exp(-x))) - * = z * log(1 + exp(-x)) + (1 - z) * (x + log(1 + exp(-x)) - * = (1 - z) * x + log(1 + exp(-x)) - * = x - x * z + log(1 + exp(-x)) - * - * For x < 0, to avoid overflow in exp(-x), we reformulate the above - * x - x * z + log(1 + exp(-x)) - * = log(exp(x)) - x * z + log(1 + exp(-x)) - * = - x * z + log(1 + exp(x)) - * - * Hence, to ensure stability and avoid overflow, the implementation uses - * this equivalent formulation: - * max(x, 0) - x * z + log(1 + exp(-abs(x))) - */ - const maxOutput = relu($logits); - const outputXTarget = mul($logits, $labels); - const sigmoidOutput = log1p(exp(neg(abs($logits)))); - - return add(sub(maxOutput, outputXTarget), sigmoidOutput); -} - -/** - * Computes the sigmoid cross entropy loss between two tensors. - * - * If labelSmoothing is nonzero, smooth the labels towards 1/2: - * - * newMulticlassLabels = multiclassLabels * (1 - labelSmoothing) - * + 0.5 * labelSmoothing - * - * @param multiClassLabels The ground truth output tensor of shape - * [batch_size, num_classes], same dimensions as 'predictions'. - * @param logits The predicted outputs. - * @param weights Tensor whose rank is either 0, or the same rank as - * `labels`, and must be broadcastable to `labels` (i.e., all dimensions - * must be either `1`, or the same as the corresponding `losses` - * dimension). - * @param labelSmoothing If greater than 0, then smooth the labels. - * @param reduction Type of reduction to apply to loss. Should be of type - * `Reduction` - * - * @doc { heading: 'Training', subheading: 'Losses', namespace: 'losses' } - */ -function sigmoidCrossEntropy_( - multiClassLabels: T|TensorLike, logits: T|TensorLike, - weights?: Tensor|TensorLike, labelSmoothing = 0, - reduction = Reduction.SUM_BY_NONZERO_WEIGHTS): O { - let $multiClassLabels = convertToTensor( - multiClassLabels, 'multiClassLabels', 'sigmoidCrossEntropy'); - const $logits = convertToTensor(logits, 'logits', 'sigmoidCrossEntropy'); - let $weights: Tensor = null; - if (weights != null) { - $weights = convertToTensor(weights, 'weights', 'sigmoidCrossEntropy'); - } - assertShapesMatch( - $multiClassLabels.shape, $logits.shape, 'Error in sigmoidCrossEntropy: '); - - if (labelSmoothing > 0) { - const labelSmoothingScalar = scalar(labelSmoothing); - const one = scalar(1); - const half = scalar(0.5); - - $multiClassLabels = - add(mul($multiClassLabels, sub(one, labelSmoothingScalar)), - mul(half, labelSmoothingScalar)); - } - const losses = sigmoidCrossEntropyWithLogits_($multiClassLabels, $logits); - - return computeWeightedLoss(losses, $weights, reduction); -} - -export const sigmoidCrossEntropy = /* @__PURE__ */ op({sigmoidCrossEntropy_}); diff --git a/tfjs-master/tfjs-core/src/ops/losses/sigmoid_cross_entropy_test.ts b/tfjs-master/tfjs-core/src/ops/losses/sigmoid_cross_entropy_test.ts deleted file mode 100644 index acb2947af..000000000 --- a/tfjs-master/tfjs-core/src/ops/losses/sigmoid_cross_entropy_test.ts +++ /dev/null @@ -1,175 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import * as tf from '../../index'; -import {ALL_ENVS, describeWithFlags} from '../../jasmine_util'; -import {expectArraysClose} from '../../test_util'; - -describeWithFlags('sigmoidCrossEntropy', ALL_ENVS, () => { - it('All wrong', async () => { - const label = tf.tensor2d([[0, 0, 1], [1, 0, 0], [0, 1, 0]], [3, 3]); - const predictions = tf.tensor2d( - [[10.0, -10.0, -10.0], [-10.0, 10.0, -10.0], [-10.0, -10.0, 10.0]], - [3, 3]); - - const y = tf.losses.sigmoidCrossEntropy(label, predictions); - - expect(y.shape).toEqual([]); - expectArraysClose(await y.data(), 6.6667123); - }); - - it('All right', async () => { - const label = tf.tensor2d([[1, 0, 0], [0, 1, 0], [0, 0, 1]], [3, 3]); - const predictions = tf.tensor2d( - [[10.0, -10.0, -10.0], [-10.0, 10.0, -10.0], [-10.0, -10.0, 10.0]], - [3, 3]); - - const y = tf.losses.sigmoidCrossEntropy(label, predictions); - - expect(y.shape).toEqual([]); - expectArraysClose(await y.data(), 0); - }); - - it('Weighted - Reduction.SUM_BY_NONZERO_WEIGHTS', async () => { - const label = tf.tensor2d([[0, 0, 1], [1, 0, 0], [0, 1, 0]], [3, 3]); - const predictions = tf.tensor2d( - [[10.0, -10.0, -10.0], [-10.0, 10.0, -10.0], [-10.0, -10.0, 10.0]], - [3, 3]); - - const weights = tf.tensor2d([[0.1, 0.2, 0.3]]); - - const y = tf.losses.sigmoidCrossEntropy(label, predictions, weights); - - expect(y.shape).toEqual([]); - expectArraysClose(await y.data(), 1.3333424); - }); - - it('Weighted - Reduction.NONE', async () => { - const label = tf.tensor2d([[0, 0, 1], [1, 0, 0], [0, 1, 0]], [3, 3]); - const predictions = tf.tensor2d( - [[10.0, -10.0, -10.0], [-10.0, 10.0, -10.0], [-10.0, -10.0, 10.0]], - [3, 3]); - const weights = tf.tensor2d([[0.1, 0.2, 0.3]]); - - const y = tf.losses.sigmoidCrossEntropy( - label, predictions, weights, undefined, tf.Reduction.NONE); - - expect(y.shape).toEqual([3, 3]); - expectArraysClose(await y.data(), [ - 1.0000046, 9.0797803e-06, 3.0000138e+00, 1.0000046e+00, 2.0000093e+00, - 1.3619671e-05, 4.5398901e-06, 2.0000093e+00, 3.0000138e+00 - ]); - }); - - it('Reduction.MEAN', async () => { - const label = tf.tensor2d([[0, 0, 1], [1, 0, 0], [0, 1, 0]], [3, 3]); - const predictions = tf.tensor2d( - [[10.0, -10.0, -10.0], [-10.0, 10.0, -10.0], [-10.0, -10.0, 10.0]], - [3, 3]); - - const y = tf.losses.sigmoidCrossEntropy( - label, predictions, undefined, undefined, tf.Reduction.MEAN); - - expect(y.shape).toEqual([]); - expectArraysClose(await y.data(), 6.6667123); - }); - - it('Weighted - Reduction.MEAN', async () => { - const label = tf.tensor2d([[0, 0, 1], [1, 0, 0], [0, 1, 0]], [3, 3]); - const predictions = tf.tensor2d( - [[10.0, -10.0, -10.0], [-10.0, 10.0, -10.0], [-10.0, -10.0, 10.0]], - [3, 3]); - const weights = tf.tensor2d([[0.1, 0.2, 0.3]]); - - const y = tf.losses.sigmoidCrossEntropy( - label, predictions, weights, undefined, tf.Reduction.MEAN); - - expect(y.shape).toEqual([]); - expectArraysClose( - await y.data(), - 6.666712284088135, - ); - }); - - it('Label Smoothing - Weighted - Reduction.MEAN', async () => { - const label = tf.tensor2d([[0, 0, 1], [1, 0, 0], [0, 1, 0]], [3, 3]); - const predictions = tf.tensor2d( - [[10.0, -10.0, -10.0], [-10.0, 10.0, -10.0], [-10.0, -10.0, 10.0]], - [3, 3]); - const weights = tf.tensor2d([[0.1, 0.2, 0.3]]); - const labelSmoothing = 0.3; - - const y = tf.losses.sigmoidCrossEntropy( - label, predictions, weights, labelSmoothing, tf.Reduction.MEAN); - - expect(y.shape).toEqual([]); - expectArraysClose(await y.data(), 6.1667128); - }); - - it('throws when multiClassLabels and logits are of different shapes', () => { - const multiClassLabels = - tf.tensor2d([10, 10, 10, 10, 10, 10, 10, 10, 10], [3, 3]); - const logits = tf.tensor2d([10, 10, 10, 10, 10, 10], [2, 3]); - - const e = new RegExp( - 'Error in sigmoidCrossEntropy: Shapes 3,3 and 2,3 must match'); - expect(() => tf.losses.sigmoidCrossEntropy(multiClassLabels, logits)) - .toThrowError(e); - }); - - it('throws when passed multiClassLabels as a non-tensor', () => { - const predictions = tf.tensor2d( - [[10.0, -10.0, -10.0], [-10.0, 10.0, -10.0], [-10.0, -10.0, 10.0]], - [3, 3]); - const weights = tf.tensor2d([[0.1, 0.2, 0.3]]); - - const e = new RegExp( - 'Argument \'multiClassLabels\' passed to \'sigmoidCrossEntropy\' ' + - 'must be a Tensor'); - - expect( - () => tf.losses.sigmoidCrossEntropy( - {} as tf.Tensor, predictions, weights, tf.Reduction.MEAN)) - .toThrowError(e); - }); - - it('throws when passed logits as a non-tensor', () => { - const label = tf.tensor2d([[0, 0, 1], [1, 0, 0], [0, 1, 0]], [3, 3]); - const weights = tf.tensor2d([[0.1, 0.2, 0.3]]); - - const e = new RegExp( - 'Argument \'logits\' passed to \'sigmoidCrossEntropy\' ' + - 'must be a Tensor'); - expect( - () => tf.losses.sigmoidCrossEntropy( - label, {} as tf.Tensor, weights, tf.Reduction.MEAN)) - .toThrowError(e); - }); - - it('throws when passed weights as a non-tensor', () => { - const label = tf.tensor2d([[0, 0, 1], [1, 0, 0], [0, 1, 0]], [3, 3]); - const predictions = tf.tensor2d( - [[10.0, -10.0, -10.0], [-10.0, 10.0, -10.0], [-10.0, -10.0, 10.0]], - [3, 3]); - - const e = - /Argument 'weights' passed to 'sigmoidCrossEntropy' must be a Tensor/; - expect( - () => tf.losses.sigmoidCrossEntropy( - label, predictions, {} as tf.Tensor, tf.Reduction.MEAN)) - .toThrowError(e); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/losses/softmax_cross_entropy.ts b/tfjs-master/tfjs-core/src/ops/losses/softmax_cross_entropy.ts deleted file mode 100644 index 16d21d21a..000000000 --- a/tfjs-master/tfjs-core/src/ops/losses/softmax_cross_entropy.ts +++ /dev/null @@ -1,156 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {customGrad} from '../../gradients'; -import {Tensor} from '../../tensor'; -import {GradSaveFunc} from '../../tensor_types'; -import {convertToTensor} from '../../tensor_util_env'; -import {TensorLike} from '../../types'; -import {assertShapesMatch} from '../../util'; -import {add} from '../add'; -import {expandShapeToKeepDim} from '../axis_util'; -import {cast} from '../cast'; -import {div} from '../div'; -import {exp} from '../exp'; -import {logSumExp} from '../log_sum_exp'; -import {Reduction} from '../loss_ops_utils'; -import {mul} from '../mul'; -import {neg} from '../neg'; -import {op} from '../operation'; -import {reshape} from '../reshape'; -import {scalar} from '../scalar'; -import {sub} from '../sub'; -import {sum} from '../sum'; - -import {computeWeightedLoss} from './compute_weighted_loss'; - -/** - * Computes softmax cross entropy between logits and labels. - * - * Measures the probability error in discrete classification tasks in which - * the classes are mutually exclusive (each entry is in exactly one class). - * For example, each CIFAR-10 image is labeled with one and only one label: an - * image can be a dog or a truck, but not both. - * - * `NOTE`: While the classes are mutually exclusive, their probabilities need - * not be. All that is required is that each row of labels is a valid - * probability distribution. If they are not, the computation of the gradient - * will be incorrect. - * - * `WARNING`: This op expects unscaled logits, since it performs a softmax on - * logits internally for efficiency. Do not call this op with the output of - * softmax, as it will produce incorrect results. - * - * logits and labels must have the same shape, e.g. [batch_size, num_classes] - * and the same dtype. - * @param labels The labels array. - * @param logits The logits array. - * @param dim The dimension softmax would be performed on. Defaults to `-1` - * which indicates the last dimension. - */ -function softmaxCrossEntropyWithLogits_( - labels: T, logits: T, dim = -1): O { - if (dim === -1) { - dim = logits.rank - 1; - } - - if (dim !== logits.rank - 1) { - throw Error( - `Softmax cross entropy along a non-last dimension is not yet ` + - `supported. Labels / logits was rank ${logits.rank} ` + - `and dim was ${dim}`); - } - // Use a custom gradient for numerical stability. - const customOp = - customGrad((labels: Tensor, logits: Tensor, save: GradSaveFunc) => { - // Reference: - // 1. http://cs231n.github.io/linear-classify/#softmax - // 2. https://blog.feedly.com/tricks-of-the-trade-logsumexp/ - const keepDims = true; - const lse = logSumExp(logits, [dim], keepDims); - const logResult = sub(cast(logits, 'float32'), lse); - save([labels, logResult]); - - const costVector = neg(mul(logResult, labels)); - const value: O = sum(costVector, [dim]); - - const gradFunc = (dy: O, saved: Tensor[]) => { - const [labels, logResult] = saved; - const dyShape = expandShapeToKeepDim(dy.shape, [dim]); - return [ - mul(reshape(dy, dyShape), - sub(cast(labels, 'float32'), exp(logResult))), - mul(reshape(dy, dyShape), - sub(exp(logResult), cast(labels, 'float32'))), - ]; - }; - return {value, gradFunc}; - }); - - return customOp(labels, logits); -} - -/** - * Computes the softmax cross entropy loss between two tensors. - * - * If labelSmoothing is nonzero, smooth the labels towards 1/2: - * - * newOnehotLabels = onehotLabels * (1 - labelSmoothing) - * + labelSmoothing / numClasses - * - * @param onehotLabels One hot encoded labels - * [batch_size, num_classes], same dimensions as 'predictions'. - * @param logits The predicted outputs. - * @param weights Tensor whose rank is either 0, or 1, and must be - * broadcastable to `loss` of shape [batch_size] - * @param labelSmoothing If greater than 0, then smooth the labels. - * @param reduction Type of reduction to apply to loss. Should be of type - * `Reduction` - * - * @doc { heading: 'Training', subheading: 'Losses', namespace: 'losses' } - */ -function softmaxCrossEntropy_( - onehotLabels: T|TensorLike, logits: T|TensorLike, - weights?: Tensor|TensorLike, labelSmoothing = 0, - reduction = Reduction.SUM_BY_NONZERO_WEIGHTS): O { - let $onehotLabels = - convertToTensor(onehotLabels, 'onehotLabels', 'softmaxCrossEntropy'); - const $logits = convertToTensor(logits, 'logits', 'softmaxCrossEntropy'); - let $weights: Tensor = null; - - if (weights != null) { - $weights = convertToTensor(weights, 'weights', 'softmaxCrossEntropy'); - } - - assertShapesMatch( - $onehotLabels.shape, $logits.shape, 'Error in softmaxCrossEntropy: '); - - if (labelSmoothing > 0) { - const labelSmoothingScalar = scalar(labelSmoothing); - const one = scalar(1); - const numClasses = scalar($onehotLabels.shape[1]); - - $onehotLabels = - add(mul($onehotLabels, sub(one, labelSmoothingScalar)), - div(labelSmoothingScalar, numClasses)); - } - - const losses = softmaxCrossEntropyWithLogits_($onehotLabels, $logits); - - return computeWeightedLoss(losses, $weights, reduction); -} - -export const softmaxCrossEntropy = /* @__PURE__ */ op({softmaxCrossEntropy_}); diff --git a/tfjs-master/tfjs-core/src/ops/losses/softmax_cross_entropy_test.ts b/tfjs-master/tfjs-core/src/ops/losses/softmax_cross_entropy_test.ts deleted file mode 100644 index a2352e45b..000000000 --- a/tfjs-master/tfjs-core/src/ops/losses/softmax_cross_entropy_test.ts +++ /dev/null @@ -1,185 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../../index'; -import {ALL_ENVS, describeWithFlags} from '../../jasmine_util'; -import {expectArraysClose} from '../../test_util'; - -describeWithFlags('softmaxCrossEntropy', ALL_ENVS, () => { - it('All wrong', async () => { - const label = tf.tensor2d([[0, 0, 1], [1, 0, 0], [0, 1, 0]], [3, 3]); - const predictions = tf.tensor2d( - [[10.0, -10.0, -10.0], [-10.0, 10.0, -10.0], [-10.0, -10.0, 10.0]], - [3, 3]); - - const y = tf.losses.softmaxCrossEntropy(label, predictions); - - expect(y.shape).toEqual([]); - expectArraysClose(await y.data(), 20); - }); - - it('All right', async () => { - const label = tf.tensor2d([[1, 0, 0], [0, 1, 0], [0, 0, 1]], [3, 3]); - const predictions = tf.tensor2d( - [[10.0, -10.0, -10.0], [-10.0, 10.0, -10.0], [-10.0, -10.0, 10.0]], - [3, 3]); - - const y = tf.losses.softmaxCrossEntropy(label, predictions); - - expect(y.shape).toEqual([]); - expectArraysClose(await y.data(), 0); - }); - - it('Weighted - Reduction.SUM_BY_NONZERO_WEIGHTS', async () => { - const label = tf.tensor2d([[0, 0, 1], [1, 0, 0], [0, 1, 0]], [3, 3]); - const predictions = tf.tensor2d( - [[10.0, -10.0, -10.0], [-10.0, 10.0, -10.0], [-10.0, -10.0, 10.0]], - [3, 3]); - - const weights = - tf.tensor2d([[0.1, 0.2, 0.3], [0.1, 0.2, 0.3], [0.1, 0.2, 0.3]]); - - const y = tf.losses.softmaxCrossEntropy(label, predictions, weights); - - expect(y.shape).toEqual([]); - expectArraysClose(await y.data(), 4); - }); - - it('Weighted - Reduction.NONE', async () => { - const label = tf.tensor2d([[0, 0, 1], [1, 0, 0], [0, 1, 0]], [3, 3]); - const predictions = tf.tensor2d( - [[10.0, -10.0, -10.0], [-10.0, 10.0, -10.0], [-10.0, -10.0, 10.0]], - [3, 3]); - const weights = tf.tensor1d([0.1, 0.2, 0.3]); - - const y = tf.losses.softmaxCrossEntropy( - label, predictions, weights, undefined, tf.Reduction.NONE); - - expect(y.shape).toEqual([3]); - expectArraysClose(await y.data(), [2, 4, 6]); - }); - - it('Reduction.MEAN', async () => { - const label = tf.tensor2d([[0, 0, 1], [1, 0, 0], [0, 1, 0]], [3, 3]); - const predictions = tf.tensor2d( - [[10.0, -10.0, -10.0], [-10.0, 10.0, -10.0], [-10.0, -10.0, 10.0]], - [3, 3]); - - const y = tf.losses.softmaxCrossEntropy( - label, predictions, undefined, undefined, tf.Reduction.MEAN); - - expect(y.shape).toEqual([]); - expectArraysClose(await y.data(), 20); - }); - - it('Weighted - Reduction.MEAN', async () => { - const label = tf.tensor2d([[0, 0, 1], [1, 0, 0], [0, 1, 0]], [3, 3]); - const predictions = tf.tensor2d( - [[10.0, -10.0, -10.0], [-10.0, 10.0, -10.0], [-10.0, -10.0, 10.0]], - [3, 3]); - const weights = tf.tensor1d([0.1, 0.2, 0.3]); - - const y = tf.losses.softmaxCrossEntropy( - label, predictions, weights, undefined, tf.Reduction.MEAN); - - expect(y.shape).toEqual([]); - expectArraysClose( - await y.data(), - 20, - ); - }); - - it('Label Smoothing - Weighted - Reduction.MEAN', async () => { - const label = tf.tensor2d([[0, 0, 1], [1, 0, 0], [0, 1, 0]], [3, 3]); - const predictions = tf.tensor2d( - [[10.0, -10.0, -10.0], [-10.0, 10.0, -10.0], [-10.0, -10.0, 10.0]], - [3, 3]); - const weights = tf.tensor2d([[0.1, 0.2, 0.3]]); - const labelSmoothing = 0.3; - - const y = tf.losses.softmaxCrossEntropy( - label, predictions, weights, labelSmoothing, tf.Reduction.MEAN); - - expect(y.shape).toEqual([]); - expectArraysClose(await y.data(), 18); - }); - - it('throws when multiClassLabels and logits are of different shapes', () => { - const multiClassLabels = - tf.tensor2d([10, 10, 10, 10, 10, 10, 10, 10, 10], [3, 3]); - const logits = tf.tensor2d([10, 10, 10, 10, 10, 10], [2, 3]); - - const e = new RegExp( - 'Error in softmaxCrossEntropy: Shapes 3,3 and 2,3 must match'); - expect(() => tf.losses.softmaxCrossEntropy(multiClassLabels, logits)) - .toThrowError(e); - }); - - it('throws when passed multiClassLabels as a non-tensor', () => { - const predictions = tf.tensor2d( - [[10.0, -10.0, -10.0], [-10.0, 10.0, -10.0], [-10.0, -10.0, 10.0]], - [3, 3]); - const weights = tf.tensor2d([[0.1, 0.2, 0.3]]); - - const e = new RegExp( - 'Argument \'onehotLabels\' passed to \'softmaxCrossEntropy\' ' + - 'must be a Tensor'); - - expect( - () => tf.losses.softmaxCrossEntropy( - {} as tf.Tensor, predictions, weights, tf.Reduction.MEAN)) - .toThrowError(e); - }); - - it('throws when passed logits as a non-tensor', () => { - const label = tf.tensor2d([[0, 0, 1], [1, 0, 0], [0, 1, 0]], [3, 3]); - const weights = tf.tensor2d([[0.1, 0.2, 0.3]]); - - const e = new RegExp( - 'Argument \'logits\' passed to \'softmaxCrossEntropy\' ' + - 'must be a Tensor'); - expect( - () => tf.losses.softmaxCrossEntropy( - label, {} as tf.Tensor, weights, tf.Reduction.MEAN)) - .toThrowError(e); - }); - - it('throws when passed weights as a non-tensor', () => { - const label = tf.tensor2d([[0, 0, 1], [1, 0, 0], [0, 1, 0]], [3, 3]); - const predictions = tf.tensor2d( - [[10.0, -10.0, -10.0], [-10.0, 10.0, -10.0], [-10.0, -10.0, 10.0]], - [3, 3]); - - const e = - /Argument 'weights' passed to 'softmaxCrossEntropy' must be a Tensor/; - expect( - () => tf.losses.softmaxCrossEntropy( - label, predictions, {} as tf.Tensor, tf.Reduction.MEAN)) - .toThrowError(e); - }); - - it('accepts a tensor-like object', async () => { - const label = [[0, 0, 1], [1, 0, 0], [0, 1, 0]]; - const predictions = - [[10.0, -10.0, -10.0], [-10.0, 10.0, -10.0], [-10.0, -10.0, 10.0]]; - - const y = tf.losses.softmaxCrossEntropy(label, predictions); - - expect(y.shape).toEqual([]); - expectArraysClose(await y.data(), 20); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/lower_bound.ts b/tfjs-master/tfjs-core/src/ops/lower_bound.ts deleted file mode 100644 index 5be8197de..000000000 --- a/tfjs-master/tfjs-core/src/ops/lower_bound.ts +++ /dev/null @@ -1,72 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Tensor} from '../tensor'; -import {TensorLike} from '../types'; -import {searchSorted} from './search_sorted'; - -/** - * Searches for where a value would go in a sorted sequence. - * - * This is not a method for checking containment (like javascript in). - * - * The typical use case for this operation is "binning", "bucketing", or - * "discretizing". The values are assigned to bucket-indices based on the edges - * listed in 'sortedSequence'. This operation returns the bucket-index for each - * value. - * - * The index returned corresponds to the first edge greater than or equal to the - * value. - * - * The axis is not settable for this operation. It always operates on the - * innermost dimension (axis=-1). The operation will accept any number of outer - * dimensions. - * - * Note: This operation assumes that 'lowerBound' is sorted along the - * innermost axis, maybe using 'sort(..., axis=-1)'. If the sequence is not - * sorted no error is raised and the content of the returned tensor is not well - * defined. - * - * ```js - * const edges = tf.tensor1d([-1, 3.3, 9.1, 10.0]); - * let values = tf.tensor1d([0.0, 4.1, 12.0]); - * const result1 = tf.lowerBound(edges, values); - * result1.print(); // [1, 2, 4] - * - * const seq = tf.tensor1d([0, 3, 9, 10, 10]); - * values = tf.tensor1d([0, 4, 10]); - * const result2 = tf.lowerBound(seq, values); - * result2.print(); // [0, 2, 3] - * - * const sortedSequence = tf.tensor2d([[0., 3., 8., 9., 10.], - * [1., 2., 3., 4., 5.]]); - * values = tf.tensor2d([[9.8, 2.1, 4.3], - * [0.1, 6.6, 4.5, ]]); - * const result3 = tf.lowerBound(sortedSequence, values); - * result3.print(); // [[4, 1, 2], [0, 5, 4]] - * ``` - * @param sortedSequence: N-D. Sorted sequence. - * @param values: N-D. Search values. - * @return An N-D int32 tensor the size of values containing the result of - * applying lower bound to each value. The result is not a global index to - * the entire Tensor, but the index in the last dimension. - * @doc {heading: 'Operations', subheading: 'Evaluation'} - */ -export function lowerBound( - sortedSequence: Tensor|TensorLike, values: Tensor|TensorLike): Tensor { - return searchSorted(sortedSequence, values, 'left'); -} diff --git a/tfjs-master/tfjs-core/src/ops/lower_bound_test.ts b/tfjs-master/tfjs-core/src/ops/lower_bound_test.ts deleted file mode 100644 index 0a9083465..000000000 --- a/tfjs-master/tfjs-core/src/ops/lower_bound_test.ts +++ /dev/null @@ -1,74 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('lowerBound', ALL_ENVS, () => { - it('test1D', async () => { - // Tests against numpy generated data. - const NUMPY_DATA = { - 'float32': [ - [ - -945.2247924804688, -921.8904418945312, -829.9115600585938, - -719.2261352539062, -660.3391723632812, -603.7969970703125, - -591.0955200195312, -373.1516418457031, -165.39039611816406, - -161.61097717285156, 117.37965393066406, 340.9350280761719, - 370.4389953613281, 384.6452331542969, 601.4891357421875, - 752.7783203125, 756.23486328125, 756.2850341796875, - 789.2133178710938, 936.5231323242188 - ], - [ - -165.95599365234375, 440.64898681640625, -999.771240234375, - -395.3348693847656, -706.4882202148438, -815.3228149414062, - -627.4795532226562, -308.8785400390625, -206.46505737304688, - 77.63346862792969 - ], - [8, 14, 0, 7, 4, 3, 5, 8, 8, 10] - ], - 'int32': [ - [ - -961, -893, -793, -739, -706, -576, -468, -439, -424, -412, - -104, -16, 148, 178, 357, 399, 496, 578, 817, 977 - ], - [-803, -157, 915, 66, 383, -368, 373, 669, -963, 500], - [2, 10, 19, 12, 15, 10, 15, 18, 0, 17] - ], - }; - for (const dtype of ['float32', 'int32'] as const ) { - const [sortedSequence, values, npAns] = NUMPY_DATA[dtype]; - - const result = tf.lowerBound(sortedSequence, values); - - expectArraysClose(await result.data(), npAns); - } - }); - - it('lowerBound2D', async () => { - for (const dtype of ['float32', 'int32'] as const ) { - const sortedSequence = - tf.tensor2d([[0, 3, 9, 9, 10], [1, 2, 3, 4, 5]], undefined, dtype); - const values = tf.tensor2d([[2, 4, 9], [0, 2, 6]], undefined, dtype); - const correctAns = [[1, 2, 2], [0, 1, 5]]; - - const result = tf.lowerBound(sortedSequence, values); - - expectArraysClose(await result.data(), correctAns); - } - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/mat_mul.ts b/tfjs-master/tfjs-core/src/ops/mat_mul.ts deleted file mode 100644 index 9a8c3129d..000000000 --- a/tfjs-master/tfjs-core/src/ops/mat_mul.ts +++ /dev/null @@ -1,59 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {ENGINE} from '../engine'; -import {BatchMatMul, BatchMatMulAttrs, BatchMatMulInputs} from '../kernel_names'; -import {NamedAttrMap} from '../kernel_registry'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {makeTypesMatch} from '../tensor_util'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -import {op} from './operation'; - -/** - * Computes the dot product of two matrices, A * B. These must be matrices. - * - * ```js - * const a = tf.tensor2d([1, 2], [1, 2]); - * const b = tf.tensor2d([1, 2, 3, 4], [2, 2]); - * - * a.matMul(b).print(); // or tf.matMul(a, b) - * ``` - * @param a First matrix in dot product operation. - * @param b Second matrix in dot product operation. - * @param transposeA If true, `a` is transposed before multiplication. - * @param transposeB If true, `b` is transposed before multiplication. - * - * @doc {heading: 'Operations', subheading: 'Matrices'} - */ -function matMul_( - a: Tensor|TensorLike, b: Tensor|TensorLike, transposeA = false, - transposeB = false): T { - let $a = convertToTensor(a, 'a', 'matMul'); - let $b = convertToTensor(b, 'b', 'matMul'); - [$a, $b] = makeTypesMatch($a, $b); - - const inputs: BatchMatMulInputs = {a: $a, b: $b}; - const attrs: BatchMatMulAttrs = {transposeA, transposeB}; - - return ENGINE.runKernel( - BatchMatMul, inputs as unknown as NamedTensorMap, - attrs as unknown as NamedAttrMap); -} - -export const matMul = /* @__PURE__ */ op({matMul_}); diff --git a/tfjs-master/tfjs-core/src/ops/mat_mul_test.ts b/tfjs-master/tfjs-core/src/ops/mat_mul_test.ts deleted file mode 100644 index 636ef14e9..000000000 --- a/tfjs-master/tfjs-core/src/ops/mat_mul_test.ts +++ /dev/null @@ -1,1320 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// Empirically determined minimal shared dimension in matmul before we forward -// to a.mul(b).sum() in order to take advantage of GPU parallelism. See -// https://github.com/tensorflow/tfjs-core/pull/1379 for benchmarks. -// Copied from webgl backend. -// TODO(yassogba, annyuan) copy tests over to webgl backend that want to -// explicitly test this threshold. -export const MATMUL_SHARED_DIM_THRESHOLD = 1000; - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose, expectArraysEqual} from '../test_util'; -import {Rank} from '../types'; - -describeWithFlags('matmul', ALL_ENVS, () => { - it('A x B', async () => { - const a = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - const b = tf.tensor2d([0, 1, -3, 2, 2, 1], [3, 2]); - - const c = tf.matMul(a, b); - - expect(c.shape).toEqual([2, 2]); - expectArraysClose(await c.data(), [0, 8, -3, 20]); - }); - - it('[8,4]x[4,8]', async () => { - const a = tf.tensor2d( - [ - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, - 17, 18, 19, 20, 21, 22, 23, 24, 1, 2, 3, 4, 5, 6, 7, 8 - ], - [8, 4]); - const b = tf.tensor2d( - [ - 0, 1, -3, 2, 1, -1, 0, 5, 6, 7, 8, 0, -2, -2, 1, 9, - 11, 10, 0, 1, -3, 2, 1, -1, 1, 2, 3, 4, 5, 6, 7, 8 - ], - [4, 8]); - - const c = tf.matMul(a, b); - const cData = await c.data(); - - expect(c.shape).toEqual([8, 8]); - expectArraysClose(cData, [ - 49, 53, 25, 21, 8, 25, 33, 52, 121, 133, 57, 49, 12, - 45, 69, 136, 193, 213, 89, 77, 16, 65, 105, 220, 265, 293, - 121, 105, 20, 85, 141, 304, 337, 373, 153, 133, 24, 105, 177, - 388, 409, 453, 185, 161, 28, 125, 213, 472, 49, 53, 25, 21, - 8, 25, 33, 52, 121, 133, 57, 49, 12, 45, 69, 136 - ]); - }); - - it('broadcast with unequal batch dims', async () => { - const a = tf.tensor3d( - [ - 2, 1, 3, 2, 1, 1, 1, 5, 6, 7, 8, 1, - 2, 2, 1, 9, 11, 10, 1, 1, 3, 2, 1, 1 - ], - [4, 3, 2]); - const b = tf.tensor3d([1, 0.5], [1, 2, 1]); - const c = tf.matMul(a, b); - expect(c.shape).toEqual([4, 3, 1]); - expectArraysClose( - await c.data(), [2.5, 4, 1.5, 3.5, 9.5, 8.5, 3, 5.5, 16, 1.5, 4, 1.5]); - }); - - it('broadcast with unequal ranks', async () => { - const a = tf.tensor5d( - [ - 2, 1, 3, 2, 1, 1, 1, 5, 6, 7, 8, 1, - 2, 2, 1, 9, 11, 10, 1, 1, 3, 2, 1, 1 - ], - [1, 2, 2, 3, 2]); - const b = tf.tensor2d([1, 0.5], [2, 1]); - const c = tf.matMul(a, b); - expect(c.shape).toEqual([1, 2, 2, 3, 1]); - expectArraysClose( - await c.data(), [2.5, 4, 1.5, 3.5, 9.5, 8.5, 3, 5.5, 16, 1.5, 4, 1.5]); - }); - - it('matmul followed by mul', async () => { - const a = tf.tensor2d([1, 2, 3, 4], [2, 2]); - const b = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - - const c = tf.matMul(a, b); - - const f = tf.tensor2d([0, 1, 0.5, 0, 0.25, 2], [2, 3]); - const d = tf.mul(c, f); - - const dData = await d.data(); - - expect(d.shape).toEqual([2, 3]); - expectArraysClose(dData, [0, 12, 7.5, 0, 6.5, 66]); - }); - - it('upcasts when dtypes dont match', async () => { - const a = [1, 2, 3, 4, 5, 6]; - const b = [0, 1, -3, 2, 2, 1]; - - let c = tf.matMul( - tf.tensor(a, [2, 3], 'float32'), tf.tensor(b, [3, 2], 'int32')); - - expect(c.shape).toEqual([2, 2]); - expect(c.dtype).toBe('float32'); - expectArraysClose(await c.data(), [0, 8, -3, 20]); - - c = tf.matMul(tf.tensor(a, [2, 3], 'int32'), tf.tensor(b, [3, 2], 'bool')); - - expect(c.shape).toEqual([2, 2]); - expect(c.dtype).toBe('int32'); - expectArraysClose(await c.data(), [5, 6, 11, 15]); - }); - - it('A x B^t', async () => { - const a = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - const b = tf.tensor2d([1, 0, 2, 4, 3, 0], [2, 3]); - - const transposeA = false; - const transposeB = true; - const c = tf.matMul(a, b, transposeA, transposeB); - - const expected = [7, 10, 16, 31]; - expectArraysClose(await c.data(), expected); - }); - - it('A^t x B', async () => { - const a = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - const b = tf.tensor2d([1, 0, 2, 4, 3, 0], [2, 3]); - - const transposeA = true; - const transposeB = false; - const c = tf.matMul(a, b, transposeA, transposeB); - - const expected = [17, 12, 2, 22, 15, 4, 27, 18, 6]; - expectArraysClose(await c.data(), expected); - }); - - it('A^t x B^t', async () => { - const a = tf.tensor2d([1, 2, 3, 4, 5, 6], [3, 2]); - const b = tf.tensor2d([1, 0, 2, 4, 3, 0], [2, 3]); - - const transposeA = true; - const transposeB = true; - const c = tf.matMul(a, b, transposeA, transposeB); - - const expected = [11, 13, 14, 20]; - expectArraysClose(await c.data(), expected); - }); - - it('A x B^t shapes do not match', () => { - const a = tf.zeros([2, 3]); - const b = tf.zeros([3, 2]); - - const f = () => { - const transposeA = false; - const transposeB = true; - tf.matMul(a, b, transposeA, transposeB); - }; - expect(f).toThrowError(); - }); - - it('A^t x B shapes do not match', () => { - const a = tf.zeros([2, 3]); - const b = tf.zeros([3, 2]); - - const f = () => { - const transposeA = true; - const transposeB = false; - tf.matMul(a, b, transposeA, transposeB); - }; - expect(f).toThrowError(); - }); - - it('A^t x B^t shapes do not match', () => { - const a = tf.zeros([3, 2]); - const b = tf.zeros([3, 2]); - - const f = () => { - const transposeA = true; - const transposeB = true; - tf.matMul(a, b, transposeA, transposeB); - }; - expect(f).toThrowError(); - }); - - it('matmul throws when inner dimensions dont match', () => { - const a = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - const b = tf.tensor2d([0, 1, -3, 2, 2, 1, 2, 2], [4, 2]); - - expect(() => tf.matMul(a, b)).toThrowError(); - }); - - it('matmul throws when passed non matrices', () => { - // tslint:disable-next-line:no-any - const a: any = - tf.tensor3d([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [2, 3, 2]); - const b = tf.tensor2d([0, 1, -3, 2, 2, 1, 2, 2], [4, 2]); - - expect(() => tf.matMul(a, b)).toThrowError(); - expect(() => tf.matMul(b, a)).toThrowError(); - }); - - it('matmul throws when passed a vector', () => { - // tslint:disable-next-line:no-any - const v: any = tf.tensor1d([2, 3]); - const matrix = tf.tensor2d([1, 2, 3, 4], [2, 2]); - - expect(() => tf.matMul(matrix, v)).toThrowError(); - }); - - it('Vector times matrix', async () => { - const v = tf.tensor1d([2, 3]); - const matrix = tf.tensor2d([1, 2, 3, 4], [2, 2]); - const result = tf.dot(v, matrix); - - const expected = [11, 16]; - expectArraysClose(await result.data(), expected); - }); - - it('Vector times matrix with implicit reshape', async () => { - const v = tf.tensor1d([2, 3]); - - const matrix = tf.tensor2d([1, 2, 3, 4], [2, 2]); - const result = tf.dot(v, matrix); - - const expected = [11, 16]; - expectArraysClose(await result.data(), expected); - }); - - it('Matrix times vector', async () => { - const matrix = tf.tensor2d([1, 2, 3, 4], [2, 2]); - const v = tf.tensor1d([2, 3]); - const result = tf.dot(matrix, v); - - const expected = [8, 18]; - expectArraysClose(await result.data(), expected); - }); - - it('batched matmul with the matrices being vectors', async () => { - const batch = 3; - const sharedDim = MATMUL_SHARED_DIM_THRESHOLD + 1; - const values = new Float32Array(batch * sharedDim); - values[10] = 2; - - const a = tf.tensor(values, [batch, 1, sharedDim]); - const b = tf.tensor(values, [batch, sharedDim, 1]); - const result = tf.matMul(a, b); - expect(result.shape).toEqual([batch, 1, 1]); - expectArraysClose(await result.data(), [4, 0, 0]); - }); - - it('batched matmul called twice so memory of output is reused', async () => { - const batch = 3; - const n = 2; - const vals = new Float32Array(batch * n * n); - vals[0] = 2; - vals[4] = 3; - vals[8] = 4; - - const a = tf.tensor(vals, [batch, n, n]); - const b = tf.tensor(vals, [batch, n, n]); - const result = tf.matMul(a, b); - expect(result.shape).toEqual([batch, n, n]); - expectArraysClose( - await result.data(), [4, 0, 0, 0, 9, 0, 0, 0, 16, 0, 0, 0]); - // Dispose the first output, so memory of the second output (which has the - // same shape), could be reused. - result.dispose(); - - const vals2 = new Float32Array(batch * n * n); - vals2[3] = 2; - vals2[7] = 3; - vals2[11] = 4; - const a2 = tf.tensor(vals2, [batch, n, n]); - const b2 = tf.tensor(vals2, [batch, n, n]); - const result2 = tf.matMul(a2, b2); - expect(result2.shape).toEqual([batch, n, n]); - expectArraysClose( - await result2.data(), [0, 0, 0, 4, 0, 0, 0, 9, 0, 0, 0, 16]); - }); - - it('batched matmul with the matrices being vectors transposedA', async () => { - const batch = 3; - const sharedDim = MATMUL_SHARED_DIM_THRESHOLD + 1; - const values = new Float32Array(batch * sharedDim); - values[10] = 2; - - const a = tf.tensor(values, [batch, sharedDim, 1]); - const b = tf.tensor(values, [batch, sharedDim, 1]); - const transposeA = true; - const transposeB = false; - const result = tf.matMul(a, b, transposeA, transposeB); - expect(result.shape).toEqual([batch, 1, 1]); - expectArraysClose(await result.data(), [4, 0, 0]); - }); - - it('batched matmul with the matrices being vectors transposedB', async () => { - const batch = 3; - const sharedDim = MATMUL_SHARED_DIM_THRESHOLD + 1; - const values = new Float32Array(batch * sharedDim); - values[10] = 2; - - const a = tf.tensor(values, [batch, 1, sharedDim]); - const b = tf.tensor(values, [batch, 1, sharedDim]); - const transposeA = false; - const transposeB = true; - const result = tf.matMul(a, b, transposeA, transposeB); - expect(result.shape).toEqual([batch, 1, 1]); - expectArraysClose(await result.data(), [4, 0, 0]); - }); - - it('batched matmul with matrix x vector', async () => { - const batch = 3; - const sharedDim = MATMUL_SHARED_DIM_THRESHOLD + 1; - const values = new Float32Array(batch * sharedDim); - values[10] = 2; - - const a = tf.ones([batch, 2, sharedDim]); - const b = tf.tensor(values, [batch, sharedDim, 1]); - const result = tf.matMul(a, b); - expect(result.shape).toEqual([batch, 2, 1]); - expectArraysClose(await result.data(), [2, 2, 0, 0, 0, 0]); - }); - - it('batched matmul with matrix x vector transposedA', async () => { - const batch = 3; - const sharedDim = MATMUL_SHARED_DIM_THRESHOLD + 1; - const values = new Float32Array(batch * sharedDim); - values[10] = 2; - - const a = tf.ones([batch, sharedDim, 2]); - const b = tf.tensor(values, [batch, sharedDim, 1]); - const transposeA = true; - const transposeB = false; - const result = tf.matMul(a, b, transposeA, transposeB); - expect(result.shape).toEqual([batch, 2, 1]); - expectArraysClose(await result.data(), [2, 2, 0, 0, 0, 0]); - }); - - it('batched matmul with matrix x vector transposedB', async () => { - const batch = 3; - const sharedDim = MATMUL_SHARED_DIM_THRESHOLD + 1; - const values = new Float32Array(batch * sharedDim); - values[10] = 2; - - const a = tf.ones([batch, 2, sharedDim]); - const b = tf.tensor(values, [batch, 1, sharedDim]); - const transposeA = false; - const transposeB = true; - const result = tf.matMul(a, b, transposeA, transposeB); - expect(result.shape).toEqual([batch, 2, 1]); - expectArraysClose(await result.data(), [2, 2, 0, 0, 0, 0]); - }); - - it('batched matmul with vector x matrix', async () => { - const batch = 3; - const sharedDim = MATMUL_SHARED_DIM_THRESHOLD + 1; - const values = new Float32Array(batch * sharedDim); - values[10] = 2; - - const a = tf.tensor(values, [batch, 1, sharedDim]); - const b = tf.ones([batch, sharedDim, 2]); - const result = tf.matMul(a, b); - expect(result.shape).toEqual([batch, 1, 2]); - expectArraysClose(await result.data(), [2, 2, 0, 0, 0, 0]); - }); - - it('batched matmul with vector x matrix transposedA', async () => { - const batch = 3; - const sharedDim = MATMUL_SHARED_DIM_THRESHOLD + 1; - const values = new Float32Array(batch * sharedDim); - values[10] = 2; - - const a = tf.tensor(values, [batch, sharedDim, 1]); - const b = tf.ones([batch, sharedDim, 2]); - const transposeA = true; - const transposeB = false; - const result = tf.matMul(a, b, transposeA, transposeB); - expect(result.shape).toEqual([batch, 1, 2]); - expectArraysClose(await result.data(), [2, 2, 0, 0, 0, 0]); - }); - - it('batched matmul with vector x matrix transposedB', async () => { - const batch = 3; - const sharedDim = MATMUL_SHARED_DIM_THRESHOLD + 1; - const values = new Float32Array(batch * sharedDim); - values[10] = 2; - - const a = tf.tensor(values, [batch, 1, sharedDim]); - const b = tf.ones([batch, 2, sharedDim]); - const transposeA = false; - const transposeB = true; - const result = tf.matMul(a, b, transposeA, transposeB); - expect(result.shape).toEqual([batch, 1, 2]); - expectArraysClose(await result.data(), [2, 2, 0, 0, 0, 0]); - }); - - it('Matrix * vector propagates NaNs', async () => { - const matrix = tf.tensor2d([1, 2, 3, 4], [2, 2]); - const v = tf.tensor1d([2, NaN]); - const result = tf.dot(matrix, v); - - const expected = [NaN, NaN]; - expectArraysClose(await result.data(), expected); - }); - - it('matrix times vector throws when not passed a matrix', () => { - const v = tf.tensor1d([2, 3]); - - // tslint:disable-next-line:no-any - const matrix: any = tf.tensor3d([1, 2, 3, 4, 5, 6, 7, 8], [2, 2, 2]); - - expect(() => tf.dot(matrix, v)).toThrowError(); - }); - - it('Dot product', async () => { - const v1 = tf.tensor1d([2, 3]); - const v2 = tf.tensor1d([2, 1]); - const result = tf.dot(v1, v2); - - expectArraysClose(await result.data(), [7]); - }); - - it('Dot product propagates NaNs', async () => { - const v1 = tf.tensor1d([2, NaN]); - const v2 = tf.tensor1d([2, 1]); - const result = tf.dot(v1, v2); - expectArraysEqual(await result.data(), [NaN]); - }); - - it('Dot product throws when vectors are different size', () => { - const v1 = tf.tensor1d([2, 3, 3]); - const v2 = tf.tensor1d([2, 1]); - - expect(() => tf.dot(v1, v2)).toThrowError(); - expect(() => tf.dot(v2, v1)).toThrowError(); - }); - - it('Outer product', async () => { - const v1 = tf.tensor1d([2, 3]); - const v2 = tf.tensor1d([2, 1]); - const result = tf.outerProduct(v1, v2); - - const expected = [4, 2, 6, 3]; - expect(result.shape).toEqual([2, 2]); - expectArraysClose(await result.data(), expected); - }); - - it('outer product accepts a tensor-like object', async () => { - const v1 = [2, 3]; - const v2 = [2, 1]; - const result = tf.outerProduct(v1, v2); - const expected = [4, 2, 6, 3]; - expect(result.shape).toEqual([2, 2]); - expectArraysClose(await result.data(), expected); - }); - - it('gradients: A * B', async () => { - const aT = tf.tensor2d([1, 2, 3, 10, 20, 30], [2, 3]); - const bT = tf.tensor2d([2, 3, 4, 1, 2, 3], [3, 2]); - const dyT = tf.tensor2d([1, 10, 20, 30], [2, 2]); - - const transposeA = false; - const transposeB = false; - const grads = tf.grads( - - (a: tf.Tensor2D, b: tf.Tensor2D) => - tf.matMul(a, b, transposeA, transposeB)); - const [da, db] = grads([aT, bT], dyT); - - // da = dy * bT - expect(da.shape).toEqual(aT.shape); - - const a = await aT.buffer(); - const dy = await dyT.buffer(); - const b = await bT.buffer(); - expectArraysClose( - await da.data(), - [ - dy.get(0, 0) * b.get(0, 0) + dy.get(0, 1) * b.get(0, 1), - dy.get(0, 0) * b.get(1, 0) + dy.get(0, 1) * b.get(1, 1), - dy.get(0, 0) * b.get(2, 0) + dy.get(0, 1) * b.get(2, 1), - dy.get(1, 0) * b.get(0, 0) + dy.get(1, 1) * b.get(0, 1), - dy.get(1, 0) * b.get(1, 0) + dy.get(1, 1) * b.get(1, 1), - dy.get(1, 0) * b.get(2, 0) + dy.get(1, 1) * b.get(2, 1) - ], - 1e-1); - - // db = aT * dy - expect(db.shape).toEqual(b.shape); - expectArraysClose(await db.data(), [ - a.get(0, 0) * dy.get(0, 0) + a.get(1, 0) * dy.get(1, 0), - a.get(0, 0) * dy.get(0, 1) + a.get(1, 0) * dy.get(1, 1), - a.get(0, 1) * dy.get(0, 0) + a.get(1, 1) * dy.get(1, 0), - a.get(0, 1) * dy.get(0, 1) + a.get(1, 1) * dy.get(1, 1), - a.get(0, 2) * dy.get(0, 0) + a.get(1, 2) * dy.get(1, 0), - a.get(0, 2) * dy.get(0, 1) + a.get(1, 2) * dy.get(1, 1) - ]); - }); - - it('gradient with clones', () => { - const a = tf.tensor2d([1, 2, 3, 10, 20, 30], [2, 3]); - const b = tf.tensor2d([2, 3, 4, 1, 2, 3], [3, 2]); - - const grads = tf.grads( - (a: tf.Tensor2D, b: tf.Tensor2D) => - tf.matMul(a.clone(), b.clone()).clone()); - const [da, db] = grads([a, b]); - - expect(da.shape).toEqual(a.shape); - expect(db.shape).toEqual(b.shape); - }); - - it('gradients: a * bT', async () => { - const aT = tf.tensor2d([1, 2, 3, 10, 20, 30], [3, 2]); - const bT = tf.tensor2d([2, 3, 4, 1, 2, 3], [3, 2]); - const dyT = tf.tensor2d([1, 10, 20, 30, 40, 50, 60, 70, 80], [3, 3]); - - const transposeA = false; - const transposeB = true; - const grads = tf.grads( - - (a: tf.Tensor2D, b: tf.Tensor2D) => - tf.matMul(a, b, transposeA, transposeB)); - const [da, db] = grads([aT, bT], dyT); - - // da = dy * b - expect(da.shape).toEqual(aT.shape); - const a = await aT.buffer(); - const dy = await dyT.buffer(); - const b = await bT.buffer(); - expectArraysClose(await da.data(), [ - dy.get(0, 0) * b.get(0, 0) + dy.get(0, 1) * b.get(1, 0) + - dy.get(0, 2) * b.get(2, 0), - dy.get(0, 0) * b.get(0, 1) + dy.get(0, 1) * b.get(1, 1) + - dy.get(0, 2) * b.get(2, 1), - dy.get(1, 0) * b.get(0, 0) + dy.get(1, 1) * b.get(1, 0) + - dy.get(1, 2) * b.get(2, 0), - dy.get(1, 0) * b.get(0, 1) + dy.get(1, 1) * b.get(1, 1) + - dy.get(1, 2) * b.get(2, 1), - dy.get(2, 0) * b.get(0, 0) + dy.get(2, 1) * b.get(1, 0) + - dy.get(2, 2) * b.get(2, 0), - dy.get(2, 0) * b.get(0, 1) + dy.get(2, 1) * b.get(1, 1) + - dy.get(2, 2) * b.get(2, 1) - ]); - - // db = dyT * a - expect(db.shape).toEqual(b.shape); - expectArraysClose(await db.data(), [ - dy.get(0, 0) * a.get(0, 0) + dy.get(1, 0) * a.get(1, 0) + - dy.get(2, 0) * a.get(2, 0), - dy.get(0, 0) * a.get(0, 1) + dy.get(1, 0) * a.get(1, 1) + - dy.get(2, 0) * a.get(2, 1), - dy.get(0, 1) * a.get(0, 0) + dy.get(1, 1) * a.get(1, 0) + - dy.get(2, 1) * a.get(2, 0), - dy.get(0, 1) * a.get(0, 1) + dy.get(1, 1) * a.get(1, 1) + - dy.get(2, 1) * a.get(2, 1), - dy.get(0, 2) * a.get(0, 0) + dy.get(1, 2) * a.get(1, 0) + - dy.get(2, 2) * a.get(2, 0), - dy.get(0, 2) * a.get(0, 1) + dy.get(1, 2) * a.get(1, 1) + - dy.get(2, 2) * a.get(2, 1) - ]); - }); - - it('gradients: aT * b', async () => { - const aT = tf.tensor2d([1, 2, 3, 10, 20, 30], [3, 2]); - const bT = tf.tensor2d([2, 3, 4, 1, 2, 3], [3, 2]); - const dyT = tf.tensor2d([1, 10, 20, 30], [2, 2]); - - const transposeA = true; - const transposeB = false; - const grads = tf.grads( - - (a: tf.Tensor2D, b: tf.Tensor2D) => - tf.matMul(a, b, transposeA, transposeB)); - const [da, db] = grads([aT, bT], dyT); - - // da = b * dyT - expect(da.shape).toEqual(aT.shape); - const a = await aT.buffer(); - const dy = await dyT.buffer(); - const b = await bT.buffer(); - expectArraysClose(await da.data(), [ - dy.get(0, 0) * b.get(0, 0) + dy.get(0, 1) * b.get(0, 1), - dy.get(1, 0) * b.get(0, 0) + dy.get(1, 1) * b.get(0, 1), - dy.get(0, 0) * b.get(1, 0) + dy.get(0, 1) * b.get(1, 1), - dy.get(1, 0) * b.get(1, 0) + dy.get(1, 1) * b.get(1, 1), - dy.get(0, 0) * b.get(2, 0) + dy.get(0, 1) * b.get(2, 1), - dy.get(1, 0) * b.get(2, 0) + dy.get(1, 1) * b.get(2, 1) - ]); - - // db = a * dy - expect(db.shape).toEqual(b.shape); - expectArraysClose(await db.data(), [ - dy.get(0, 0) * a.get(0, 0) + dy.get(1, 0) * a.get(0, 1), - dy.get(0, 1) * a.get(0, 0) + dy.get(1, 1) * a.get(0, 1), - dy.get(0, 0) * a.get(1, 0) + dy.get(1, 0) * a.get(1, 1), - dy.get(0, 1) * a.get(1, 0) + dy.get(1, 1) * a.get(1, 1), - dy.get(0, 0) * a.get(2, 0) + dy.get(1, 0) * a.get(2, 1), - dy.get(0, 1) * a.get(2, 0) + dy.get(1, 1) * a.get(2, 1) - ]); - }); - - it('gradients: aT * bT', async () => { - const aT = tf.tensor2d([1, 2, 3, 10, 20, 30], [3, 2]); - const bT = tf.tensor2d([2, 3, 4, 1, 2, 3], [2, 3]); - const dyT = tf.tensor2d([1, 10, 20, 30], [2, 2]); - - const transposeA = true; - const transposeB = true; - const grads = tf.grads( - - (a: tf.Tensor2D, b: tf.Tensor2D) => - tf.matMul(a, b, transposeA, transposeB)); - const [da, db] = grads([aT, bT], dyT); - - // da = bT * dyT - expect(da.shape).toEqual(aT.shape); - const a = await aT.buffer(); - const dy = await dyT.buffer(); - const b = await bT.buffer(); - expectArraysClose(await da.data(), [ - dy.get(0, 0) * b.get(0, 0) + dy.get(0, 1) * b.get(1, 0), - dy.get(1, 0) * b.get(0, 0) + dy.get(1, 1) * b.get(1, 0), - dy.get(0, 0) * b.get(0, 1) + dy.get(0, 1) * b.get(1, 1), - dy.get(1, 0) * b.get(0, 1) + dy.get(1, 1) * b.get(1, 1), - dy.get(0, 0) * b.get(0, 2) + dy.get(0, 1) * b.get(1, 2), - dy.get(1, 0) * b.get(0, 2) + dy.get(1, 1) * b.get(1, 2) - ]); - - // db = dyT * aT - expect(db.shape).toEqual(b.shape); - expectArraysClose(await db.data(), [ - dy.get(0, 0) * a.get(0, 0) + dy.get(1, 0) * a.get(0, 1), - dy.get(0, 0) * a.get(1, 0) + dy.get(1, 0) * a.get(1, 1), - dy.get(0, 0) * a.get(2, 0) + dy.get(1, 0) * a.get(2, 1), - dy.get(0, 1) * a.get(0, 0) + dy.get(1, 1) * a.get(0, 1), - dy.get(0, 1) * a.get(1, 0) + dy.get(1, 1) * a.get(1, 1), - dy.get(0, 1) * a.get(2, 0) + dy.get(1, 1) * a.get(2, 1) - ]); - }); - - it('throws when passed a as a non-tensor', () => { - expect(() => tf.matMul({} as tf.Tensor2D, tf.tensor2d([2], [1, 1]))) - .toThrowError(/Argument 'a' passed to 'matMul' must be a Tensor/); - }); - it('throws when passed b as a non-tensor', () => { - expect(() => tf.matMul(tf.tensor2d([2], [1, 1]), {} as tf.Tensor2D)) - .toThrowError(/Argument 'b' passed to 'matMul' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const a = [[1, 2, 3], [4, 5, 6]]; // 2x3 - const b = [[0, 1], [-3, 2], [2, 1]]; // 3x2 - const c = tf.matMul(a, b); - - expect(c.shape).toEqual([2, 2]); - expectArraysClose(await c.data(), [0, 8, -3, 20]); - }); - - it('accepts a tensor-like object chained', async () => { - const a = tf.tensor2d([[1, 2, 3], [4, 5, 6]], [2, 3]); // 2x3 - const b = [[0, 1], [-3, 2], [2, 1]]; // 3x2 - const c = a.matMul(b); - - expect(c.shape).toEqual([2, 2]); - expectArraysClose(await c.data(), [0, 8, -3, 20]); - }); - - it('a * b where a has zero in its shape', async () => { - const a = tf.tensor2d([], [0, 3]); - const b = tf.tensor2d([1, 2, 3, 4, 5, 6], [3, 2]); - const c = tf.matMul(a, b); - expect(c.shape).toEqual([0, 2]); - expect(c.rank).toBe(2); - expect(c.size).toBe(0); - expectArraysClose(await c.data(), []); - }); - - it('(a * b) * c where a has zero in its shape, so a*b does also', - async () => { - const a = tf.tensor2d([], [0, 3]); - const b = tf.tensor2d([1, 2, 3, 4, 5, 6], [3, 2]); - const ab = tf.matMul(a, b); - expect(ab.shape).toEqual([0, 2]); - expectArraysClose(await ab.data(), []); - const c = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - const res = tf.matMul(ab, c); - expect(res.shape).toEqual([0, 3]); - expectArraysClose(await res.data(), []); - }); - - it('throws error for string tensor', () => { - expect(() => tf.matMul([['a']], [['b']])) - .toThrowError(/Argument 'a' passed to 'matMul' must be numeric tensor/); - }); -}); - -describeWithFlags('matmulBatch', ALL_ENVS, () => { - it('A x B', async () => { - const a = tf.tensor3d( - [ - -5, -5, -6, 8, -2, -8, 4, -7, -6, -9, -1, 3, 7, -2, 5, - -6, 3, 8, 7, -8, 1, 4, -4, 6, 4, -4, -9, -5, 2, -2 - ], - [5, 2, 3]); - const b = tf.tensor3d( - [ - -8, -4, -1, 0, -7, 0, 3, 3, 6, 2, -1, 8, -4, 9, -6, - 5, 8, 9, -9, 7, 0, -1, -1, -10, -7, 3, 4, 6, 3, -4 - ], - [5, 3, 2]); - - const c = tf.matMul(a, b); - expect(c.shape).toEqual([5, 2, 2]); - expectArraysClose(await c.data(), [ - 87, 20, -6, -32, -24, -50, -36, -5, 24, 98, - 70, 33, -64, 47, -42, -28, -71, 24, 37, 5 - ]); - }); - - it('A x B in 4D', async () => { - const a = tf.tensor4d( - [ - -2, 3, 5, -5, 3, 9, -3, -5, 1, 1, -9, 9, -6, 6, -8, - -7, -1, 3, 9, -7, -7, 2, 10, -6, -8, -6, 9, -6, 4, -1, - 9, -6, 10, 8, -9, 5, -8, -7, 0, 2, -5, -1, -9, -4, 3, - -2, 6, -4, 7, 1, -5, -4, 9, -8, -6, -8, 4, -1, 4, 3, - -7, 8, -7, 5, -3, -2, -4, 9, 2, -1, 1, -10, -3, 5, -4, - 6, -8, -8, 9, -3, -5, 10, 3, -3, -3, 9, 3, -3, 2, -8, - 10, 1, 9, -2, -2, -3, -4, 6, -10, -1, 8, -8, 7, 3, -2, - 3, 6, -2, -2, -4, 1, -5, -4, 0, 5, 1, 9, -8, -2, -1 - ], - [4, 5, 2, 3]); - const b = tf.tensor4d( - [ - -4, -3, -2, -6, 6, -1, -4, -1, 7, -4, 8, -9, -9, 0, -1, - -4, -6, -7, -3, -4, -7, 6, -8, 1, -2, 1, -1, -3, 8, -5, - 9, -2, 5, 9, -2, 2, -5, -5, -8, -1, -2, -3, -2, -10, 6, - -3, 0, 1, 6, 7, 1, 2, -4, -5, 2, -5, -7, 9, 3, -6, - 6, 4, -4, 6, 10, -3, -2, 8, 10, -8, 10, -1, -9, -7, -8, - -3, 1, 1, -2, -9, -7, -6, -1, 0, 7, -9, -7, -5, 0, -4, - -4, -7, 2, 4, 6, 6, -4, -6, -8, 3, -8, -9, 6, 9, -4, - 1, -1, 0, 8, 9, 0, -5, 3, -1, 5, 0, -10, 7, -2, 6 - ], - [4, 5, 3, 2]); - - const transposeA = false; - const transposeB = false; - const c = tf.matMul(a, b, transposeA, transposeB); - - expectArraysClose(await c.data(), [ - 32, -17, 68, -12, -15, 14, 5, -46, 96, 32, 46, -17, 78, -85, - -28, 46, 94, -35, 0, -13, 31, -52, 17, -87, 96, 47, 32, -2, - -6, 105, 40, -2, 63, 76, 17, 30, 56, -66, -21, 23, -144, 41, - 22, 8, 118, -106, -88, -6, -17, 2, 2, -26, 8, -63, -38, -108, - -84, -30, -35, 49, 16, -12, -14, -12, 48, 132, 4, 102, 32, 66, - -4, 33, -13, 1, -40, -25, -3, 61, -18, -20 - ]); - }); - - it('A x B^t', async () => { - const a = tf.tensor3d( - [ - -5, -5, -6, 8, -2, -8, 4, -7, -6, -9, -1, 3, 7, -2, 5, - -6, 3, 8, 7, -8, 1, 4, -4, 6, 4, -4, -9, -5, 2, -2 - ], - [5, 2, 3]); - const b = tf.tensor3d( - [ - -8, -4, -1, 0, -7, 0, 3, 3, 6, 2, -1, 8, -4, 9, -6, - 5, 8, 9, -9, 7, 0, -1, -1, -10, -7, 3, 4, 6, 3, -4 - ], - [5, 2, 3]); - - const transposeA = false; - const transposeB = true; - const c = tf.matMul(a, b, transposeA, transposeB); - expect(c.shape).toEqual([5, 2, 2]); - expectArraysClose(await c.data(), [ - 66, 35, -48, 14, -45, -33, -12, 7, -76, 64, - 3, 66, -119, -9, -64, -60, -76, 48, 33, -16 - ]); - }); - - it('A^t x B', async () => { - const a = tf.tensor3d( - [ - -5, -5, -6, 8, -2, -8, 4, -7, -6, -9, -1, 3, 7, -2, 5, - -6, 3, 8, 7, -8, 1, 4, -4, 6, 4, -4, -9, -5, 2, -2 - ], - [5, 2, 3]); - const b = tf.tensor3d( - [ - -8, -4, -1, 0, -7, 0, 3, 3, 6, 2, -1, 8, -4, 9, -6, - 5, 8, 9, -9, 7, 0, -1, -1, -10, -7, 3, 4, 6, 3, -4 - ], - [5, 2, 3]); - - const transposeA = true; - const transposeB = false; - const c = tf.matMul(a, b, transposeA, transposeB); - - expectArraysClose(await c.data(), [ - 40, -36, 5, 40, 34, 5, 48, 80, 6, -6, 21, -48, -23, -20, -50, - -12, -21, -12, -58, 15, -96, 23, 6, 39, 20, 109, 42, -67, 45, -40, - 76, -52, 40, -15, 1, -60, -58, -3, 36, 40, -6, -24, 51, -33, -28 - ]); - }); - - it('A^t x B in 4D', async () => { - const a = tf.tensor4d( - [ - -2, 3, 5, -5, 3, 9, -3, -5, 1, 1, -9, 9, -6, 6, -8, - -7, -1, 3, 9, -7, -7, 2, 10, -6, -8, -6, 9, -6, 4, -1, - 9, -6, 10, 8, -9, 5, -8, -7, 0, 2, -5, -1, -9, -4, 3, - -2, 6, -4, 7, 1, -5, -4, 9, -8, -6, -8, 4, -1, 4, 3, - -7, 8, -7, 5, -3, -2, -4, 9, 2, -1, 1, -10, -3, 5, -4, - 6, -8, -8, 9, -3, -5, 10, 3, -3, -3, 9, 3, -3, 2, -8, - 10, 1, 9, -2, -2, -3, -4, 6, -10, -1, 8, -8, 7, 3, -2, - 3, 6, -2, -2, -4, 1, -5, -4, 0, 5, 1, 9, -8, -2, -1 - ], - [4, 5, 2, 3]); - const b = tf.tensor4d( - [ - -4, -3, -2, -6, 6, -1, -4, -1, 7, -4, 8, -9, -9, 0, -1, - -4, -6, -7, -3, -4, -7, 6, -8, 1, -2, 1, -1, -3, 8, -5, - 9, -2, 5, 9, -2, 2, -5, -5, -8, -1, -2, -3, -2, -10, 6, - -3, 0, 1, 6, 7, 1, 2, -4, -5, 2, -5, -7, 9, 3, -6, - 6, 4, -4, 6, 10, -3, -2, 8, 10, -8, 10, -1, -9, -7, -8, - -3, 1, 1, -2, -9, -7, -6, -1, 0, 7, -9, -7, -5, 0, -4, - -4, -7, 2, 4, 6, 6, -4, -6, -8, 3, -8, -9, 6, 9, -4, - 1, -1, 0, 8, 9, 0, -5, 3, -1, 5, 0, -10, 7, -2, 6 - ], - [4, 5, 2, 3]); - - const transposeA = true; - const transposeB = false; - const c = tf.matMul(a, b, transposeA, transposeB); - - expectArraysClose(await c.data(), [ - 38, -24, 9, -30, 9, -9, -74, 39, -19, 8, 11, -30, 56, -67, - 46, -40, 71, -74, 82, 42, 55, -50, 6, 1, 60, -18, -13, -15, - -52, -61, 81, -52, 59, -15, 76, 43, 34, -56, 38, 0, 26, -14, - -15, 1, -4, 153, -34, 61, -135, 30, -48, 135, -30, 60, 38, 36, - 58, 40, 45, 71, 1, 2, 3, 24, 90, -56, -10, 40, -18, 6, - -30, 14, 34, 65, 27, 24, -29, -44, -46, -3, 35, -21, 27, 48, - 20, 52, 32, 35, -11, -46, -12, 22, 13, 30, 2, -23, -54, -48, - 34, 16, -42, -39, -26, 82, 89, 76, -84, 30, 9, 27, 30, -21, - -43, -48, 60, 20, 24, -78, -91, -63, -12, 24, 21, 28, 48, 35, - -6, 27, 33, 53, -81, -71, 61, -27, 11, -48, -82, 8, -12, -19, - -10, -48, -81, 0, 13, 32, 41, 0, -100, -120, 16, 124, 152, 45, - 60, -28, 24, 21, -12, -14, -16, 8, 9, -33, 5, -12, -48, 4, - 8, 9, 0, -31, 16, -98, -9, 4, -22, 38, 2, -96 - ]); - }); - - it('A^t x B^t', async () => { - const a = tf.tensor3d( - [ - -5, -5, -6, 8, -2, -8, 4, -7, -6, -9, -1, 3, 7, -2, 5, - -6, 3, 8, 7, -8, 1, 4, -4, 6, 4, -4, -9, -5, 2, -2 - ], - [5, 3, 2]); - const b = tf.tensor3d( - [ - -8, -4, -1, 0, -7, 0, 3, 3, 6, 2, -1, 8, -4, 9, -6, - 5, 8, 9, -9, 7, 0, -1, -1, -10, -7, 3, 4, 6, 3, -4 - ], - [5, 2, 3]); - - const transposeA = true; - const transposeB = true; - const c = tf.matMul(a, b, transposeA, transposeB); - expectArraysClose(await c.data(), [ - 66, 42, 16, -56, -12, 6, -30, 19, -1, 102, - -94, 14, -56, 32, 100, -56, -47, -11, 5, -31 - ]); - }); - - it('A has more batch dimensions than B', async () => { - const a = tf.tensor4d( - [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], [2, 2, 2, 2]); - const b = tf.tensor3d([1, 2, 3, 4], [2, 2, 1]); - - const c = tf.matMul(a, b); - expectArraysClose(await c.data(), [5, 11, 39, 53, 29, 35, 95, 109]); - }); - - it('batch dimensions do not match', () => { - const a = tf.tensor3d( - [ - -5, -5, -6, 8, -2, -8, 4, -7, -6, -9, -1, 3, - 7, -2, 5, -6, 3, 8, 7, -8, 1, 4, -4, 6 - ], - [4, 3, 2]); - const b = tf.tensor3d( - [ - -8, -4, -1, 0, -7, 0, 3, 3, 6, 2, -1, 8, -4, 9, -6, - 5, 8, 9, -9, 7, 0, -1, -1, -10, -7, 3, 4, 6, 3, -4 - ], - [5, 2, 3]); - - const f = () => { - tf.matMul(a, b, false, false); - }; - expect(f).toThrowError(); - }); - - it('gradients: A x B', async () => { - const a = tf.tensor3d( - [ - -5, -5, -6, 8, -2, -8, 4, -7, -6, -9, -1, 3, 7, -2, 5, - -6, 3, 8, 7, -8, 1, 4, -4, 6, 4, -4, -9, -5, 2, -2 - ], - [5, 2, 3]); - const b = tf.tensor3d( - [ - -8, -4, -1, 0, -7, 0, 3, 3, 6, 2, -1, 8, -4, 9, -6, - 5, 8, 9, -9, 7, 0, -1, -1, -10, -7, 3, 4, 6, 3, -4 - ], - [5, 3, 2]); - const dy = tf.tensor3d( - [8, 2, -3, -2, -8, 4, 5, 7, 4, -4, -4, 5, 8, 10, 1, 0, 6, 6, -4, 7], - [5, 2, 2]); - - const grads = tf.grads( - (a: tf.Tensor3D, b: tf.Tensor3D) => tf.matMul(a, b, false, false)); - const [da, db] = grads([a, b], dy); - - // da = dy * bT - expect(da.shape).toEqual(a.shape); - expectArraysClose(await da.data(), [ - -72, -8, -56, 32, 3, 21, -12, -40, 40, 36, 44, 51, -52, -44, -4, - 61, 49, 13, -2, -10, -108, -9, 0, -1, -24, 60, -6, 49, 26, -40 - ]); - - // db = aT * dy - expect(db.shape).toEqual(b.shape); - expectArraysClose(await db.data(), [ - -64, -26, -34, -6, -24, 4, -77, -47, 51, -35, 63, -3, 52, -58, -20, - 23, -12, 20, 60, 70, -68, -80, 14, 10, 44, -11, -32, -10, -46, -68 - ]); - }); - - it('4d gradients: A x B', async () => { - const a = tf.tensor4d( - [ - -2, 3, 5, -5, 3, 9, -3, -5, 1, 1, -9, 9, -6, 6, -8, - -7, -1, 3, 9, -7, -7, 2, 10, -6, -8, -6, 9, -6, 4, -1, - 9, -6, 10, 8, -9, 5, -8, -7, 0, 2, -5, -1, -9, -4, 3, - -2, 6, -4, 7, 1, -5, -4, 9, -8, -6, -8, 4, -1, 4, 3, - -7, 8, -7, 5, -3, -2, -4, 9, 2, -1, 1, -10, -3, 5, -4, - 6, -8, -8, 9, -3, -5, 10, 3, -3, -3, 9, 3, -3, 2, -8, - 10, 1, 9, -2, -2, -3, -4, 6, -10, -1, 8, -8, 7, 3, -2, - 3, 6, -2, -2, -4, 1, -5, -4, 0, 5, 1, 9, -8, -2, -1 - ], - [4, 5, 2, 3]); - const b = tf.tensor4d( - [ - -4, -3, -2, -6, 6, -1, -4, -1, 7, -4, 8, -9, -9, 0, -1, - -4, -6, -7, -3, -4, -7, 6, -8, 1, -2, 1, -1, -3, 8, -5, - 9, -2, 5, 9, -2, 2, -5, -5, -8, -1, -2, -3, -2, -10, 6, - -3, 0, 1, 6, 7, 1, 2, -4, -5, 2, -5, -7, 9, 3, -6, - 6, 4, -4, 6, 10, -3, -2, 8, 10, -8, 10, -1, -9, -7, -8, - -3, 1, 1, -2, -9, -7, -6, -1, 0, 7, -9, -7, -5, 0, -4, - -4, -7, 2, 4, 6, 6, -4, -6, -8, 3, -8, -9, 6, 9, -4, - 1, -1, 0, 8, 9, 0, -5, 3, -1, 5, 0, -10, 7, -2, 6 - ], - [4, 5, 3, 2]); - const dy = tf.tensor4d( - [ - 8, -7, 0, -9, -5, -5, 0, 3, 7, -4, 6, -8, -8, 0, -1, -8, - -9, -7, -4, -9, 2, 3, 5, 8, -5, -7, 3, -10, -5, -9, -5, 1, - 7, 1, -9, -10, 8, 5, 0, 8, -6, 4, 0, -5, 8, -7, -2, 1, - -8, 9, 9, -7, 1, 7, -2, 5, -2, 9, 1, -5, 7, 5, -7, -6, - 6, 7, -8, 7, 4, -5, 4, -5, 3, -4, -5, 4, -6, 3, -8, 10 - ], - [4, 5, 2, 2]); - - const grads = tf.grads( - (a: tf.Tensor4D, b: tf.Tensor4D) => tf.matMul(a, b, false, false)); - const [da, db] = grads([a, b], dy); - - // da = dy * bT - expect(da.shape).toEqual(a.shape); - expectArraysClose(await da.data(), [ - -11, 26, 55, 27, 54, 9, 25, -15, 5, -3, -12, -27, -63, 9, - -14, -54, 26, 20, 24, 56, 64, 35, -41, 0, 11, 30, -37, -1, - 31, 13, 12, 37, 2, 29, 97, 6, 60, 47, 31, 35, -14, 24, - 100, -3, -9, 0, -33, 1, 49, 9, -33, -124, -29, 86, -9, -11, - -6, -40, 72, -48, -20, 48, -72, -20, -30, 15, -72, 136, 87, 12, - -28, -21, 9, 37, 1, -32, -51, 2, -65, -49, -1, -41, -16, 2, - -95, -31, -36, 52, 18, 20, -63, 34, 72, 70, -38, -78, -66, -27, - -111, -10, 85, 1, -21, -21, -4, -21, -21, -4, -12, 20, 13, -4, - -20, -19, -30, 81, 30, -40, 150, 76 - ]); - - // db = aT * dy - expect(db.shape).toEqual(b.shape); - expectArraysClose(await db.data(), [ - -16, 59, 24, -48, 40, -116, 15, 18, 25, -2, -5, 22, -84, 80, - 36, -16, -38, 8, -74, -16, 46, -80, 62, 48, 96, 110, 38, 6, - -77, -54, 58, 91, -57, -90, 45, 70, 46, 36, 20, 99, -3, 10, - 55, 79, -10, 42, 5, -31, 85, 47, -74, -89, 37, 75, -48, -38, - -64, -8, 32, 44, 42, -53, -48, 47, 42, -18, -30, 27, 70, -62, - 36, -24, 78, -69, -112, 101, -40, 20, -11, 113, -9, -6, 1, -50, - 3, -12, -16, 71, -14, 67, 84, 62, 21, 17, 84, 63, -16, -35, - -28, 98, 4, -126, 40, -50, 36, -45, -16, 20, 19, -12, 8, 0, - 3, -4, 34, -65, 10, -17, -46, 17 - ]); - }); - - it('gradients: A x B^t', async () => { - const a = tf.tensor3d( - [ - -5, -5, -6, 8, -2, -8, 4, -7, -6, -9, -1, 3, 7, -2, 5, - -6, 3, 8, 7, -8, 1, 4, -4, 6, 4, -4, -9, -5, 2, -2 - ], - [5, 3, 2]); - const b = tf.tensor3d( - [ - -8, -4, -1, 0, -7, 0, 3, 3, 6, 2, -1, 8, -4, 9, -6, - 5, 8, 9, -9, 7, 0, -1, -1, -10, -7, 3, 4, 6, 3, -4 - ], - [5, 3, 2]); - const dy = tf.tensor3d( - [ - -0, 7, 5, 0, -9, 5, -7, 6, -5, -3, -2, -2, -4, 10, -3, - 5, -1, 3, -2, -9, 4, -5, 7, 9, -10, -8, -8, -5, -0, -1, - 3, 3, 4, 9, -7, 6, -2, -9, 5, 1, -5, -3, -1, 9, 4 - ], - [5, 3, 3]); - - const grads = tf.grads( - (a: tf.Tensor3D, b: tf.Tensor3D) => tf.matMul(a, b, false, true)); - const [da, db] = grads([a, b], dy); - - expect(da.shape).toEqual(a.shape); - expectArraysClose(await da.data(), [ - -42, 0, -26, 0, 85, 28, -19, -29, 51, -16, 6, 37, 94, -27, 50, - 71, 24, -202, 46, -25, -31, -22, -87, 10, -7, -80, -36, -15, 55, 35 - ]); - - expect(db.shape).toEqual(b.shape); - expectArraysClose(await db.data(), [ - 14, 56, 7, -155, -45, 55, 7, 72, -67, -79, 7, 50, -69, -46, -52, - -88, 49, -126, -68, 106, 31, -30, -27, 60, -19, 5, 27, 43, 55, -13 - ]); - }); - - it('4d gradients: A x B^t', async () => { - const a = tf.tensor4d( - [ - -2, 3, 5, -5, 3, 9, -3, -5, 1, 1, -9, 9, -6, 6, -8, - -7, -1, 3, 9, -7, -7, 2, 10, -6, -8, -6, 9, -6, 4, -1, - 9, -6, 10, 8, -9, 5, -8, -7, 0, 2, -5, -1, -9, -4, 3, - -2, 6, -4, 7, 1, -5, -4, 9, -8, -6, -8, 4, -1, 4, 3, - -7, 8, -7, 5, -3, -2, -4, 9, 2, -1, 1, -10, -3, 5, -4, - 6, -8, -8, 9, -3, -5, 10, 3, -3, -3, 9, 3, -3, 2, -8, - 10, 1, 9, -2, -2, -3, -4, 6, -10, -1, 8, -8, 7, 3, -2, - 3, 6, -2, -2, -4, 1, -5, -4, 0, 5, 1, 9, -8, -2, -1 - ], - [4, 5, 3, 2]); - const b = tf.tensor4d( - [ - -4, -3, -2, -6, 6, -1, -4, -1, 7, -4, 8, -9, -9, 0, -1, - -4, -6, -7, -3, -4, -7, 6, -8, 1, -2, 1, -1, -3, 8, -5, - 9, -2, 5, 9, -2, 2, -5, -5, -8, -1, -2, -3, -2, -10, 6, - -3, 0, 1, 6, 7, 1, 2, -4, -5, 2, -5, -7, 9, 3, -6, - 6, 4, -4, 6, 10, -3, -2, 8, 10, -8, 10, -1, -9, -7, -8, - -3, 1, 1, -2, -9, -7, -6, -1, 0, 7, -9, -7, -5, 0, -4, - -4, -7, 2, 4, 6, 6, -4, -6, -8, 3, -8, -9, 6, 9, -4, - 1, -1, 0, 8, 9, 0, -5, 3, -1, 5, 0, -10, 7, -2, 6 - ], - [4, 5, 3, 2]); - const dy = tf.tensor4d( - [ - 5, -1, -5, -4, -1, 9, 1, -2, 10, 7, -1, 6, -8, 8, -3, - 9, -4, 2, -4, -8, 8, 4, 8, -10, -8, -8, 6, 6, -5, 9, - -1, -7, -5, -3, -3, 2, -6, 5, 8, -9, 5, -8, -3, 8, 6, - 2, 8, 5, 9, 7, 6, 2, -3, 10, 7, 7, -3, 4, -3, -6, - -8, -8, 9, 0, -8, -3, -2, -2, 8, 2, 3, -6, 3, 6, -3, - 7, 7, -9, -3, 8, 7, 7, -1, -6, 5, 2, -1, -1, 1, 5, - 0, -4, 3, -4, -10, 1, -2, -8, -9, -6, 4, 4, -7, -1, -1, - -9, 7, 1, -1, 8, 0, -2, -7, 5, 7, 8, 9, -3, -8, -6, - -7, -8, -1, 8, -4, 7, 5, -9, 9, 3, 0, -10, 7, -9, 4, - -7, 5, -2, -2, 3, 3, -6, 2, 0, 8, -5, -10, 3, -7, 0, - -6, 2, 3, -1, 3, 3, -10, 1, 3, -7, -1, 8, -2, -1, -1, - -3, -9, 7, 4, -6, 3, 0, -7, -4, -5, -8, -6, 10, -6, 4 - ], - [4, 5, 3, 3]); - - const grads = tf.grads( - (a: tf.Tensor4D, b: tf.Tensor4D) => tf.matMul(a, b, false, true)); - const [da, db] = grads([a, b], dy); - - expect(da.shape).toEqual(a.shape); - expectArraysClose(await da.data(), [ - -48, -4, 72, 9, 60, -1, 13, -57, 64, 3, -48, -11, -4, -24, - 16, 38, 44, -10, -55, -45, 92, -43, 14, -4, 71, -61, -51, 16, - 46, -57, 48, 78, 104, 57, -17, -11, -85, -33, 16, 1, 86, 21, - -48, 21, -8, 34, 14, -35, 36, 48, 85, 108, -38, -40, 3, -8, - -7, -1, 6, -16, 46, -33, 26, -79, -70, -29, 92, -84, -6, -47, - 98, -129, -55, -17, 79, 40, -118, -64, 68, 75, 71, 111, 5, -48, - 98, -36, 21, 13, 112, -34, 26, 57, 32, 44, 28, 50, 88, 27, - 44, -39, -16, 15, -21, -6, -67, -89, -46, -64, -19, -12, -3, 11, - 41, 63, 78, -73, 67, -92, 102, -18 - ]); - - expect(db.shape).toEqual(b.shape); - expectArraysClose(await db.data(), [ - -27, 44, -9, -16, 85, 30, -110, 38, 47, -23, -39, -15, 0, -76, - -8, -128, 26, 136, 31, -26, -26, 39, 136, -85, -45, 93, 37, -68, - -112, -6, 90, 70, 169, -7, 15, 68, -16, -33, -16, -47, -21, 0, - 6, -4, 84, 24, 15, 20, -41, -1, 79, -86, 87, -23, -26, -64, - 18, 9, 52, 64, 34, -16, 122, -66, -1, 47, 1, 43, -11, -33, - -17, 27, -45, -73, -60, -66, -92, -42, 32, -85, -44, -44, -28, -13, - 8, -20, 9, -9, -49, 79, -76, 15, 73, -7, 7, -8, -110, 93, - 106, -39, 64, -84, -29, -19, 13, 14, 63, 2, -15, 23, 17, 49, - -3, -31, -65, 30, -95, 63, -82, 40 - ]); - }); - - it('gradients: A^t x B', async () => { - const a = tf.tensor3d( - [ - -5, -5, -6, 8, -2, -8, 4, -7, -6, -9, -1, 3, 7, -2, 5, - -6, 3, 8, 7, -8, 1, 4, -4, 6, 4, -4, -9, -5, 2, -2 - ], - [5, 3, 2]); - const b = tf.tensor3d( - [ - -8, -4, -1, 0, -7, 0, 3, 3, 6, 2, -1, 8, -4, 9, -6, - 5, 8, 9, -9, 7, 0, -1, -1, -10, -7, 3, 4, 6, 3, -4 - ], - [5, 3, 2]); - const dy = tf.tensor3d( - [8, 2, -3, -2, -8, 4, 5, 7, 4, -4, -4, 5, 8, 10, 1, 0, 6, 6, -4, 7], - [5, 2, 2]); - - const grads = tf.grads( - (a: tf.Tensor3D, b: tf.Tensor3D) => tf.matMul(a, b, true, false)); - const [da, db] = grads([a, b], dy); - - expect(da.shape).toEqual(a.shape); - expectArraysClose(await da.data(), [ - -72, 32, -8, 3, -56, 21, -12, 36, -40, 44, 40, 51, -52, 61, -44, - 49, -4, 13, -2, -9, -10, 0, -108, -1, -24, 49, 60, 26, -6, -40 - ]); - - expect(db.shape).toEqual(b.shape); - expectArraysClose(await db.data(), [ - -25, 0, -72, -28, 8, 12, -67, -33, 3, -87, 23, 17, 36, -38, 44, - -50, -20, 28, 48, 70, 12, 10, -26, -40, 40, -4, -34, -89, 20, -2 - ]); - }); - - it('gradients: A^t x B^t', async () => { - const a = tf.tensor3d( - [ - -5, -5, -6, 8, -2, -8, 4, -7, -6, -9, -1, 3, 7, -2, 5, - -6, 3, 8, 7, -8, 1, 4, -4, 6, 4, -4, -9, -5, 2, -2 - ], - [5, 3, 2]); - const b = tf.tensor3d( - [ - -8, -4, -1, 0, -7, 0, 3, 3, 6, 2, -1, 8, -4, 9, -6, - 5, 8, 9, -9, 7, 0, -1, -1, -10, -7, 3, 4, 6, 3, -4 - ], - [5, 2, 3]); - const dy = tf.tensor3d( - [8, 2, -3, -2, -8, 4, 5, 7, 4, -4, -4, 5, 8, 10, 1, 0, 6, 6, -4, 7], - [5, 2, 2]); - - const grads = tf.grads( - (a: tf.Tensor3D, b: tf.Tensor3D) => tf.matMul(a, b, true, true)); - const [da, db] = grads([a, b], dy); - - expect(da.shape).toEqual(a.shape); - expectArraysClose(await da.data(), [ - -64, 24, -46, 26, -8, 3, -16, 29, -28, 8, -16, 86, -36, 41, 4, - 4, -60, 69, -82, -9, 46, 7, -100, 0, -6, 70, 36, 9, 0, -44 - ]); - - expect(db.shape).toEqual(b.shape); - expectArraysClose(await db.data(), [ - -25, -72, 8, 0, -28, 12, -67, 3, 23, -33, -87, 17, 36, 44, -20, - -38, -50, 28, 48, 12, -26, 70, 10, -40, 40, -34, 20, -4, -89, -2 - ]); - }); -}); - -describeWithFlags('dot', ALL_ENVS, () => { - let a: tf.Tensor1D; - let b: tf.Tensor2D; - let c: tf.Tensor2D; - let d: tf.Tensor3D; - let e: tf.Scalar; - let f: tf.Tensor3D; - - beforeEach(() => { - a = tf.tensor1d([1, 2]); - b = tf.tensor2d([[1, 2], [3, 4]]); - c = tf.tensor2d([[1, 2, 3], [4, 5, 6]]); - d = tf.tensor3d([1, 2], [1, 1, 2]); - e = tf.scalar(1); - f = tf.tensor3d([1, 2, 1, 2], [2, 1, 2]); - }); - - it('vector-vector', async () => { - const aa = tf.dot(a, a); - expectArraysClose(await aa.data(), [5]); - expect(aa.shape).toEqual([]); - }); - - it('vector-matrix', async () => { - const ab = tf.dot(a, b); - const ac = tf.dot(a, c); - expect(ab.shape).toEqual([2]); - expect(ac.shape).toEqual([3]); - expectArraysClose(await ab.data(), [7, 10]); - expectArraysClose(await ac.data(), [9, 12, 15]); - }); - - it('matrix-vector', async () => { - const ba = b.dot(a); - expect(ba.shape).toEqual([2]); - expectArraysClose(await ba.data(), [5, 11]); - }); - - it('matrix-matrix', async () => { - const bb = tf.dot(b, b); - const bc = tf.dot(b, c); - expect(bb.shape).toEqual([2, 2]); - expect(bc.shape).toEqual([2, 3]); - expectArraysClose(await bb.data(), [7, 10, 15, 22]); - expectArraysClose(await bc.data(), [9, 12, 15, 19, 26, 33]); - }); - - it('matmul A x B asymmetric', async () => { - const a = tf.tensor2d([1, 2, 3, 4], [2, 2]); - const b = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - - const c = tf.matMul(a, b); - const cData = await c.data(); - - expect(c.shape).toEqual([2, 3]); - expectArraysClose(cData, [9, 12, 15, 19, 26, 33]); - }); - - it('broadcast batch shape', async () => { - const a = tf.tensor3d([1, 2, 3, 4], [1, 2, 2]); - const b = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - - const c = tf.matMul(a, b); - const cData = await c.data(); - - expect(c.shape).toEqual([1, 2, 3]); - expectArraysClose(cData, [9, 12, 15, 19, 26, 33]); - }); - - it('throws error on incompatible dimensions', () => { - expect(() => tf.dot(c, f)).toThrowError(); - }); - - it('throws error when inputs are not rank 1 or 2', () => { - expect(() => tf.dot(a, d)).toThrowError(); - expect(() => tf.dot(a, e)).toThrowError(); - }); - - it('accepts a tensor-like object', async () => { - const a = [1, 2, 3]; - const res = tf.dot(a, a); - expectArraysClose(await res.data(), [14]); - expect(res.shape).toEqual([]); - }); - - it('throws error for string tensors', () => { - expect(() => tf.dot('a', 'b')) - .toThrowError(/Argument 't1' passed to 'dot' must be numeric tensor/); - }); - - it('ensure no memory leak', async () => { - const numTensorsBefore = tf.memory().numTensors; - const numDataIdBefore = tf.engine().backend.numDataIds(); - const a = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - const b = tf.tensor2d([0, 1, -3, 2, 2, 1], [3, 2]); - - const c = tf.matMul(a, b); - - expect(c.shape).toEqual([2, 2]); - expectArraysClose(await c.data(), [0, 8, -3, 20]); - - a.dispose(); - b.dispose(); - c.dispose(); - - const numTensorsAfter = tf.memory().numTensors; - const numDataIdAfter = tf.engine().backend.numDataIds(); - expect(numTensorsAfter).toBe(numTensorsBefore); - expect(numDataIdAfter).toBe(numDataIdBefore); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/max.ts b/tfjs-master/tfjs-core/src/ops/max.ts deleted file mode 100644 index 1f0d63077..000000000 --- a/tfjs-master/tfjs-core/src/ops/max.ts +++ /dev/null @@ -1,69 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {Max, MaxAttrs, MaxInputs} from '../kernel_names'; -import {NamedAttrMap} from '../kernel_registry'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -import {op} from './operation'; - -/** - * Computes the maximum of elements across dimensions of a `tf.Tensor`. - * - * Reduces the input along the dimensions given in `axes`. Unless `keepDims` - * is true, the rank of the `tf.Tensor` is reduced by 1 for each entry in - * `axes`. If `keepDims` is true, the reduced dimensions are retained with - * length 1. If `axes` has no entries, all dimensions are reduced, and a - * `tf.Tensor` with a single element is returned. - * - * ```js - * const x = tf.tensor1d([1, 2, 3]); - * - * x.max().print(); // or tf.max(x) - * ``` - * - * ```js - * const x = tf.tensor2d([1, 2, 3, 4], [2, 2]); - * - * const axis = 1; - * x.max(axis).print(); // or tf.max(x, axis) - * ``` - * - * @param x The input tensor. - * @param axis The dimension(s) to reduce. By default it reduces - * all dimensions. - * @param keepDims If true, retains reduced dimensions with size 1. - * - * @doc {heading: 'Operations', subheading: 'Reduction'} - */ -function max_( - x: Tensor|TensorLike, axis: number|number[] = null, keepDims = false): T { - const $x = convertToTensor(x, 'x', 'max'); - - const inputs: MaxInputs = {x: $x}; - const attrs: MaxAttrs = {reductionIndices: axis, keepDims}; - - return ENGINE.runKernel( - Max, inputs as unknown as NamedTensorMap, - attrs as unknown as NamedAttrMap); -} - -export const max = /* @__PURE__ */ op({max_}); diff --git a/tfjs-master/tfjs-core/src/ops/max_pool.ts b/tfjs-master/tfjs-core/src/ops/max_pool.ts deleted file mode 100644 index 5d07c5c82..000000000 --- a/tfjs-master/tfjs-core/src/ops/max_pool.ts +++ /dev/null @@ -1,93 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {MaxPool, MaxPoolAttrs, MaxPoolInputs} from '../kernel_names'; -import {NamedAttrMap} from '../kernel_registry'; -import {Tensor3D, Tensor4D} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; -import * as util from '../util'; - -import * as conv_util from './conv_util'; -import {op} from './operation'; -import {reshape} from './reshape'; - -/** - * Computes the 2D max pooling of an image. - * - * @param x The input tensor, of rank 4 or rank 3 of shape - * `[batch, height, width, inChannels]`. If rank 3, batch of 1 is assumed. - * @param filterSize The filter size: `[filterHeight, filterWidth]`. If - * `filterSize` is a single number, then `filterHeight == filterWidth`. - * @param strides The strides of the pooling: `[strideHeight, strideWidth]`. If - * `strides` is a single number, then `strideHeight == strideWidth`. - * @param dilations The dilation rates: `[dilationHeight, dilationWidth]` - * in which we sample input values across the height and width dimensions - * in dilated pooling. Defaults to `[1, 1]`. If `dilations` is a single - * number, then `dilationHeight == dilationWidth`. If it is greater than - * 1, then all values of `strides` must be 1. - * @param pad The type of padding algorithm. - * - `same` and stride 1: output will be of same size as input, - * regardless of filter size. - * - `valid`: output will be smaller than input if filter is larger - * than 1x1. - * - For more info, see this guide: - * [https://www.tensorflow.org/api_docs/python/tf/nn/convolution]( - * https://www.tensorflow.org/api_docs/python/tf/nn/convolution) - * @param dimRoundingMode A string from: 'ceil', 'round', 'floor'. If none is - * provided, it will default to truncate. - */ -function maxPool_( - x: T|TensorLike, filterSize: [number, number]|number, - strides: [number, number]|number, - pad: 'valid'|'same'|number|conv_util.ExplicitPadding, - dimRoundingMode?: 'floor'|'round'|'ceil'): T { - const $x = convertToTensor(x, 'x', 'maxPool'); - const dilations = 1; - - let x4D = $x as Tensor4D; - let reshapedTo4D = false; - if ($x.rank === 3) { - reshapedTo4D = true; - x4D = reshape($x, [1, $x.shape[0], $x.shape[1], $x.shape[2]]); - } - - util.assert( - x4D.rank === 4, - () => `Error in maxPool: input must be rank 4 but got rank ${x4D.rank}.`); - util.assert( - conv_util.eitherStridesOrDilationsAreOne(strides, dilations), - () => 'Error in maxPool: Either strides or dilations must be 1. ' + - `Got strides ${strides} and dilations '${dilations}'`); - conv_util.checkPadOnDimRoundingMode('maxPool', pad, dimRoundingMode); - const inputs: MaxPoolInputs = {x: x4D}; - const attrs: MaxPoolAttrs = {filterSize, strides, pad, dimRoundingMode}; - - // tslint:disable-next-line: no-unnecessary-type-assertion - const res = ENGINE.runKernel( - MaxPool, inputs as unknown as NamedTensorMap, - attrs as unknown as NamedAttrMap) as T; - - if (reshapedTo4D) { - return reshape(res, [res.shape[1], res.shape[2], res.shape[3]]) as T; - } - return res; -} - -export const maxPool = /* @__PURE__ */ op({maxPool_}); diff --git a/tfjs-master/tfjs-core/src/ops/max_pool_3d.ts b/tfjs-master/tfjs-core/src/ops/max_pool_3d.ts deleted file mode 100644 index c306e6637..000000000 --- a/tfjs-master/tfjs-core/src/ops/max_pool_3d.ts +++ /dev/null @@ -1,106 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {MaxPool3D, MaxPool3DAttrs, MaxPool3DInputs} from '../kernel_names'; -import {NamedAttrMap} from '../kernel_registry'; -import {Tensor4D, Tensor5D} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; -import * as util from '../util'; - -import {checkPadOnDimRoundingMode} from './conv_util'; -import {op} from './operation'; -import {reshape} from './reshape'; - -/** - * Computes the 3D max pooling. - * - * ```js - * const x = tf.tensor5d([1, 2, 3, 4, 5, 6, 7, 8], [1, 2, 2, 2, 1]); - * const result = tf.maxPool3d(x, 2, 1, 'valid'); - * result.print(); - * ``` - * - * @param x The input tensor, of rank 5 or rank 4 of shape - * `[batch, depth, height, width, inChannels]`. - * @param filterSize The filter size: - * `[filterDepth, filterHeight, filterWidth]`. - * If `filterSize` is a single number, - * then `filterDepth == filterHeight == filterWidth`. - * @param strides The strides of the pooling: - * `[strideDepth, strideHeight, strideWidth]`. - * If `strides` is a single number, - * then `strideDepth == strideHeight == strideWidth`. - * @param pad The type of padding algorithm. - * - `same` and stride 1: output will be of same size as input, - * regardless of filter size. - * - `valid`: output will be smaller than input if filter is larger - * than 1*1x1. - * - For more info, see this guide: - * [https://www.tensorflow.org/api_docs/python/tf/nn/convolution]( - * https://www.tensorflow.org/api_docs/python/tf/nn/convolution) - * @param dimRoundingMode A string from: 'ceil', 'round', 'floor'. If none is - * provided, it will default to truncate. - * @param dataFormat An optional string from: "NDHWC", "NCDHW". Defaults to - * "NDHWC". Specify the data format of the input and output data. With the - * default format "NDHWC", the data is stored in the order of: [batch, - * depth, height, width, channels]. Only "NDHWC" is currently supported. - * @doc {heading: 'Operations', subheading: 'Convolution'} - */ -function maxPool3d_( - x: T|TensorLike, filterSize: [number, number, number]|number = [1, 1, 1], - strides: [number, number, number]|number, pad: 'valid'|'same'|number, - dimRoundingMode?: 'floor'|'round'|'ceil', - dataFormat: 'NDHWC'|'NCDHW' = 'NDHWC'): T { - const $x = convertToTensor(x, 'x', 'maxPool3d'); - - let x5D = $x as Tensor5D; - let reshapedTo5D = false; - if ($x.rank === 4) { - reshapedTo5D = true; - x5D = reshape($x, [1, $x.shape[0], $x.shape[1], $x.shape[2], $x.shape[3]]); - } - - util.assert( - x5D.rank === 5, - () => `Error in maxPool3d: x must be rank 5 but got rank ${x5D.rank}.`); - util.assert( - dataFormat === 'NDHWC', - () => `Error in maxPool3d: Only NDHWC is currently supported, ` + - `but got dataFormat of ${dataFormat}`); - checkPadOnDimRoundingMode('maxPool3d', pad, dimRoundingMode); - const inputs: MaxPool3DInputs = {x: x5D}; - const attrs: - MaxPool3DAttrs = {filterSize, strides, pad, dimRoundingMode, dataFormat}; - - // tslint:disable-next-line: no-unnecessary-type-assertion - const res = ENGINE.runKernel( - MaxPool3D, inputs as unknown as NamedTensorMap, - attrs as unknown as NamedAttrMap) as T; - - if (reshapedTo5D) { - return reshape( - res, [res.shape[1], res.shape[2], res.shape[3], res.shape[4]]) as - T; - } - - return res; -} - -export const maxPool3d = /* @__PURE__ */ op({maxPool3d_}); diff --git a/tfjs-master/tfjs-core/src/ops/max_pool_3d_grad.ts b/tfjs-master/tfjs-core/src/ops/max_pool_3d_grad.ts deleted file mode 100644 index 3e4f30224..000000000 --- a/tfjs-master/tfjs-core/src/ops/max_pool_3d_grad.ts +++ /dev/null @@ -1,110 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {MaxPool3DGrad, MaxPool3DGradAttrs, MaxPool3DGradInputs} from '../kernel_names'; -import {NamedAttrMap} from '../kernel_registry'; -import {Tensor4D, Tensor5D} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; -import * as util from '../util'; - -import {checkPadOnDimRoundingMode} from './conv_util'; -import {op} from './operation'; -import {reshape} from './reshape'; - -/** - * Computes the backprop of a 3d max pool. - * - * @param dy The dy error, of rank 5 of shape - * [batchSize, depth, height, width, channels]. - * assumed. - * @param input The original input image, of rank 5 or rank 4 of shape - * [batchSize, depth, height, width, channels]. - * @param output The original output image, of rank 5 of shape - * [batchSize, outDepth, outHeight, outWidth, channels]. - * @param filterSize The filter size: - * `[filterDepth, filterHeight, filterWidth]`. - * `filterSize` is a single number, - * then `filterDepth == filterHeight == filterWidth`. - * @param strides The strides of the pooling: - * `[strideDepth, strideHeight, strideWidth]`. If - * `strides` is a single number, then `strideHeight == strideWidth`. - * @param pad A string from: 'same', 'valid'. The type of padding algorithm - * used in the forward prop of the op. - * @param dimRoundingMode A string from: 'ceil', 'round', 'floor'. If none is - * provided, it will default to truncate. - */ -function maxPool3dGrad_( - dy: T|TensorLike, input: T|TensorLike, output: T|TensorLike, - filterSize: [number, number, number]|number, - strides: [number, number, number]|number, pad: 'valid'|'same'|number, - dimRoundingMode?: 'floor'|'round'|'ceil'): T { - const $dy = convertToTensor(dy, 'dy', 'maxPool3dGrad'); - const $input = convertToTensor(input, 'input', 'maxPool3dGrad'); - const $output = convertToTensor(output, 'output', 'maxPool3dGrad'); - - let dy5D = $dy as Tensor5D; - let input5D = $input as Tensor5D; - let output5D = $output as Tensor5D; - let reshapedTo5D = false; - - if ($input.rank === 4) { - reshapedTo5D = true; - dy5D = reshape( - $dy, [1, $dy.shape[0], $dy.shape[1], $dy.shape[2], $dy.shape[3]]); - input5D = reshape($input, [ - 1, $input.shape[0], $input.shape[1], $input.shape[2], $input.shape[3] - ]); - output5D = reshape($output, [ - 1, $output.shape[0], $output.shape[1], $output.shape[2], $output.shape[3] - ]); - } - - util.assert( - dy5D.rank === 5, - () => `Error in maxPool3dGrad: dy must be rank 5 but got rank ` + - `${dy5D.rank}.`); - util.assert( - input5D.rank === 5, - () => `Error in maxPool3dGrad: input must be rank 5 but got rank ` + - `${input5D.rank}.`); - util.assert( - output5D.rank === 5, - () => `Error in maxPool3dGrad: output must be rank 5 but got rank ` + - `${output5D.rank}.`); - checkPadOnDimRoundingMode('maxPool3dGrad', pad, dimRoundingMode); - const inputs: - MaxPool3DGradInputs = {dy: dy5D, input: input5D, output: output5D}; - const attrs: MaxPool3DGradAttrs = {filterSize, strides, pad, dimRoundingMode}; - - // tslint:disable-next-line: no-unnecessary-type-assertion - const res = ENGINE.runKernel( - MaxPool3DGrad, inputs as unknown as NamedTensorMap, - attrs as unknown as NamedAttrMap) as T; - - if (reshapedTo5D) { - return reshape( - res, [res.shape[1], res.shape[2], res.shape[3], res.shape[4]]) as - T; - } - - return res; -} - -export const maxPool3dGrad = /* @__PURE__ */ op({maxPool3dGrad_}); diff --git a/tfjs-master/tfjs-core/src/ops/max_pool_3d_test.ts b/tfjs-master/tfjs-core/src/ops/max_pool_3d_test.ts deleted file mode 100644 index 6fbb04721..000000000 --- a/tfjs-master/tfjs-core/src/ops/max_pool_3d_test.ts +++ /dev/null @@ -1,395 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('maxPool3d', ALL_ENVS, () => { - it('4D x=[2,2,2,1] f=[2,2,2] s=1 p=valid', async () => { - const x = tf.tensor4d([1, 2, 3, 4, 5, 6, 7, 8], [2, 2, 2, 1]); - - const result = tf.maxPool3d(x, 2, 1, 'valid'); - - expect(result.shape).toEqual([1, 1, 1, 1]); - expectArraysClose(await result.data(), [8]); - }); - - it('x=[1,1,1,1,1] f=[1,1,1] s=1 [0] => [0]', async () => { - const x = tf.tensor5d([0], [1, 1, 1, 1, 1]); - - const result = tf.maxPool3d(x, 1, 1, 0); - - expect(result.shape).toEqual([1, 1, 1, 1, 1]); - expectArraysClose(await result.data(), [0]); - }); - - it('x=[1,2,2,2,1] f=[2,2,2] s=1 p=valid', async () => { - const x = tf.tensor5d([1, 2, 3, 4, 5, 6, 7, 8], [1, 2, 2, 2, 1]); - - const result = tf.maxPool3d(x, 2, 1, 'valid'); - - expect(result.shape).toEqual([1, 1, 1, 1, 1]); - expectArraysClose(await result.data(), [8]); - }); - - it('x=[1,2,2,2,1] f=[2,2,2] s=1 p=same', async () => { - const x = tf.tensor5d([1, 2, 3, 4, 5, 6, 7, 8], [1, 2, 2, 2, 1]); - const expected = [8, 8, 8, 8, 8, 8, 8, 8]; - const result = tf.maxPool3d(x, 2, 1, 'same'); - - expect(result.shape).toEqual([1, 2, 2, 2, 1]); - expectArraysClose(await result.data(), expected); - }); - - it('x=[1,3,3,3,1] f=[2,2,2] s=1 p=valid', async () => { - const x = tf.tensor5d( - [ - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27 - ], - [1, 3, 3, 3, 1]); - const expected = [14, 15, 17, 18, 23, 24, 26, 27]; - const result = tf.maxPool3d(x, 2, 1, 'valid'); - - expect(result.shape).toEqual([1, 2, 2, 2, 1]); - expectArraysClose(await result.data(), expected); - }); - - it('x=[1,3,3,3,1] f=[2,2,2] s=1 p=same', async () => { - const x = tf.tensor5d( - [ - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27 - ], - [1, 3, 3, 3, 1]); - const expected = [ - 14, 15, 15, 17, 18, 18, 17, 18, 18, 23, 24, 24, 26, 27, - 27, 26, 27, 27, 23, 24, 24, 26, 27, 27, 26, 27, 27 - ]; - const result = tf.maxPool3d(x, 2, 1, 'same'); - - expect(result.shape).toEqual([1, 3, 3, 3, 1]); - expectArraysClose(await result.data(), expected); - }); - - it('x=[1,3,3,3,1] f=[2,2,2] s=1 p=valid, ignores NaNs', async () => { - const x = tf.tensor5d( - [ - 1, 2, 3, 4, 5, 6, NaN, 8, NaN, 10, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, NaN, 23, 24, 25, 26, 27 - ], - [1, 3, 3, 3, 1]); - const expected = [14, 15, 17, 18, 23, 24, 26, 27]; - const result = tf.maxPool3d(x, 2, 1, 'valid'); - - expect(result.shape).toEqual([1, 2, 2, 2, 1]); - expectArraysClose(await result.data(), expected); - }); - - it('x=[2,3,3,3,1] f=[2,2,2] s=1 p=valid', async () => { - const x = tf.tensor5d( - [ - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, - 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, - 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54 - ], - [2, 3, 3, 3, 1]); - const expected = - [14, 15, 17, 18, 23, 24, 26, 27, 41, 42, 44, 45, 50, 51, 53, 54]; - const result = tf.maxPool3d(x, 2, 1, 'valid'); - - expect(result.shape).toEqual([2, 2, 2, 2, 1]); - expectArraysClose(await result.data(), expected); - }); - - it('x=[1,3,3,3,2] f=[2,2,2] s=1 p=valid', async () => { - const x = tf.tensor5d( - [ - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, - 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, - 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54 - ], - [1, 3, 3, 3, 2]); - const expected = - [27, 28, 29, 30, 33, 34, 35, 36, 45, 46, 47, 48, 51, 52, 53, 54]; - const result = tf.maxPool3d(x, 2, 1, 'valid'); - - expect(result.shape).toEqual([1, 2, 2, 2, 2]); - expectArraysClose(await result.data(), expected); - }); - - it('x=[1,2,2,2,1] f=[2,2,2] s=1 p=1 roundingMode=floor', async () => { - const x = tf.tensor5d([1, 2, 3, 4, 5, 6, 7, 8], [1, 2, 2, 2, 1]); - const expected = [ - 1, 2, 2, 3, 4, 4, 3, 4, 4, 5, 6, 6, 7, 8, - 8, 7, 8, 8, 5, 6, 6, 7, 8, 8, 7, 8, 8 - ]; - const result = tf.maxPool3d(x, 2, 1, 1, 'floor'); - - expect(result.shape).toEqual([1, 3, 3, 3, 1]); - expectArraysClose(await result.data(), expected); - }); - - it('throws when x is not rank 5', async () => { - // tslint:disable-next-line:no-any - const x: any = tf.tensor1d([1]); - - expect(() => tf.maxPool3d(x as tf.Tensor5D, 2, 1, 'valid')).toThrowError(); - }); - - it('throws when dimRoundingMode is set and pad is same', () => { - const x = tf.tensor5d([1], [1, 1, 1, 1, 1]); - const pad = 'same'; - const dimRoundingMode = 'round'; - - expect(() => tf.maxPool3d(x, 2, 1, pad, dimRoundingMode)).toThrowError(); - }); - - it('throws when dimRoundingMode is set and pad is valid', () => { - const x = tf.tensor5d([1], [1, 1, 1, 1, 1]); - const pad = 'valid'; - const dimRoundingMode = 'round'; - - expect(() => tf.maxPool3d(x, 2, 1, pad, dimRoundingMode)).toThrowError(); - }); - - it('throws when dimRoundingMode is set and pad is a non-integer number', - () => { - const x = tf.tensor5d([1], [1, 1, 1, 1, 1]); - const pad = 1.2; - const dimRoundingMode = 'round'; - - expect(() => tf.maxPool3d(x, 2, 1, pad, dimRoundingMode)).toThrowError(); - }); - - it('throws when passed a non-tensor', () => { - expect(() => tf.maxPool3d({} as tf.Tensor5D, 2, 1, 'valid')).toThrowError(); - }); - - it('accepts a tensor-like object', async () => { - const x = [[[[[0]]]]]; // 1x1x1x1x1 - const result = tf.maxPool3d(x, 1, 1, 0); - expect(result.shape).toEqual([1, 1, 1, 1, 1]); - expectArraysClose(await result.data(), [0]); - }); -}); - -describeWithFlags('maxPool3dBackprop', ALL_ENVS, () => { - it('gradient x=[2,2,2,1] f=[1,1,1] s=1', async () => { - const dy = tf.tensor4d([1, 2, 1, 2, 1, 2, 1, 2], [2, 2, 2, 1]); - const x = tf.tensor4d([1, 2, 3, 4, 5, 6, 7, 8], [2, 2, 2, 1]); - const expected = [1, 2, 1, 2, 1, 2, 1, 2]; - - const dx = tf.grad((x: tf.Tensor4D) => tf.maxPool3d(x, 1, 1, 0))(x, dy); - - expect(dx.shape).toEqual(x.shape); - expectArraysClose(await dx.data(), expected); - }); - - it('gradient x=[1,2,2,2,1] f=[1,1,1] s=1', async () => { - const dy = tf.tensor5d([1, 2, 1, 2, 1, 2, 1, 2], [1, 2, 2, 2, 1]); - const x = tf.tensor5d([1, 2, 3, 4, 5, 6, 7, 8], [1, 2, 2, 2, 1]); - const expected = [1, 2, 1, 2, 1, 2, 1, 2]; - - const dx = tf.grad((x: tf.Tensor5D) => tf.maxPool3d(x, 1, 1, 0))(x, dy); - - expect(dx.shape).toEqual(x.shape); - expectArraysClose(await dx.data(), expected); - }); - - it('gradient x=[1,2,2,2,1] f=[2,2,2] s=2', async () => { - const dy = tf.tensor5d([1], [1, 1, 1, 1, 1]); - const x = tf.tensor5d([1, 2, 3, 4, 5, 6, 7, 8], [1, 2, 2, 2, 1]); - const expected = [0, 0, 0, 0, 0, 0, 0, 1]; - - const dx = tf.grad((x: tf.Tensor5D) => tf.maxPool3d(x, 2, 1, 0))(x, dy); - - expect(dx.shape).toEqual(x.shape); - expectArraysClose(await dx.data(), expected); - }); - - it('gradient with clone x=[1,2,2,2,1] f=[2,2,2] s=1', async () => { - const dy = tf.tensor5d([1], [1, 1, 1, 1, 1]); - const x = tf.tensor5d([1, 2, 3, 4, 5, 6, 7, 8], [1, 2, 2, 2, 1]); - const expected = [0, 0, 0, 0, 0, 0, 0, 1]; - - const dx = tf.grad( - (x: tf.Tensor5D) => tf.maxPool3d(x.clone(), 2, 1, 0).clone())(x, dy); - - expect(dx.shape).toEqual(x.shape); - expectArraysClose(await dx.data(), expected); - }); - - it('gradient x=[1,3,3,3,1] f=[2,2,2] s=1 no dup max value', async () => { - const dy = tf.tensor5d([1, 2, 3, 4, 5, 6, 7, 8], [1, 2, 2, 2, 1]); - const x = tf.tensor5d( - [ - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27 - ], - [1, 3, 3, 3, 1]); - const expected = [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, - 2, 0, 3, 4, 0, 0, 0, 0, 5, 6, 0, 7, 8 - ]; - - const dx = tf.grad((x: tf.Tensor5D) => tf.maxPool3d(x, 2, 1, 0))(x, dy); - - expect(dx.shape).toEqual(x.shape); - expectArraysClose(await dx.data(), expected); - }); - - it('gradient x=[1,3,3,3,1] f=[2,2,2] s=1 dup max value', async () => { - const dy = tf.tensor5d([1, 2, 3, 4, 5, 6, 7, 8], [1, 2, 2, 2, 1]); - const x = tf.tensor5d( - [ - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 27, - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 14 - ], - [1, 3, 3, 3, 1]); - const expected = [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ]; - - const dx = tf.grad((x: tf.Tensor5D) => tf.maxPool3d(x, 2, 1, 0))(x, dy); - - expect(dx.shape).toEqual(x.shape); - expectArraysClose(await dx.data(), expected); - }); - - it('gradient x=[1,4,4,4,1] f=[2,2,2] s=2', async () => { - const dy = tf.tensor5d([1, 2, 3, 4, 5, 6, 7, 8], [1, 2, 2, 2, 1]); - const x = tf.tensor5d( - [ - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, - 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, - 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, - 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64 - ], - [1, 4, 4, 4, 1]); - const expected = [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, - 0, 2, 0, 0, 0, 0, 0, 3, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 6, 0, 0, 0, 0, 0, 7, 0, 8 - ]; - - const dx = tf.grad((x: tf.Tensor5D) => tf.maxPool3d(x, 2, 2, 0))(x, dy); - - expect(dx.shape).toEqual(x.shape); - expectArraysClose(await dx.data(), expected); - }); - - it('gradient x=[1,3,3,3,2] f=[2,2,2] s=1 no dup max value', async () => { - const dy = tf.tensor5d( - [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], - [1, 2, 2, 2, 2]); - const x = tf.tensor5d( - [ - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, - 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, - 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54 - ], - [1, 3, 3, 3, 2]); - const expected = [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 0, 0, 5, 6, 7, 8, - 0, 0, 0, 0, 0, 0, 0, 0, 9, 10, 11, 12, 0, 0, 13, 14, 15, 16 - ]; - - const dx = tf.grad((x: tf.Tensor5D) => tf.maxPool3d(x, 2, 1, 0))(x, dy); - - expect(dx.shape).toEqual(x.shape); - expectArraysClose(await dx.data(), expected); - }); - - it('gradient x=[1,3,3,3,2] f=[2,2,2] s=1 dup max value', async () => { - const dy = tf.tensor5d( - [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], - [1, 2, 2, 2, 2]); - const x = tf.tensor5d( - [ - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 53, 54, - 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, - 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 27, 28 - ], - [1, 3, 3, 3, 2]); - const expected = [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 64, 72, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ]; - - const dx = tf.grad((x: tf.Tensor5D) => tf.maxPool3d(x, 2, 1, 0))(x, dy); - - expect(dx.shape).toEqual(x.shape); - expectArraysClose(await dx.data(), expected); - }); - - it('gradient x=[2,3,3,3,1] f=[2,2,2] s=1 no dup max value', async () => { - const dy = tf.tensor5d( - [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], - [2, 2, 2, 2, 1]); - const x = tf.tensor5d( - [ - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, - 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, - 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54 - ], - [2, 3, 3, 3, 1]); - const expected = [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 0, 3, 4, - 0, 0, 0, 0, 5, 6, 0, 7, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 9, 10, 0, 11, 12, 0, 0, 0, 0, 13, 14, 0, 15, 16 - ]; - - const dx = tf.grad((x: tf.Tensor5D) => tf.maxPool3d(x, 2, 1, 0))(x, dy); - - expect(dx.shape).toEqual(x.shape); - expectArraysClose(await dx.data(), expected); - }); - - it('gradient x=[2,3,3,3,1] f=[2,2,2] s=1 dup max value', async () => { - const dy = tf.tensor5d( - [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], - [2, 2, 2, 2, 1]); - const x = tf.tensor5d( - [ - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 27, - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 14, 28, - 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 54, 42, - 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 41 - ], - [2, 3, 3, 3, 1]); - const expected = [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ]; - - const dx = tf.grad((x: tf.Tensor5D) => tf.maxPool3d(x, 2, 1, 0))(x, dy); - - expect(dx.shape).toEqual(x.shape); - expectArraysClose(await dx.data(), expected); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/max_pool_grad.ts b/tfjs-master/tfjs-core/src/ops/max_pool_grad.ts deleted file mode 100644 index 32ca887e8..000000000 --- a/tfjs-master/tfjs-core/src/ops/max_pool_grad.ts +++ /dev/null @@ -1,84 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {MaxPoolGrad, MaxPoolGradAttrs, MaxPoolGradInputs} from '../kernel_names'; -import {NamedAttrMap} from '../kernel_registry'; -import {Tensor4D} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; -import * as util from '../util'; - -import * as conv_util from './conv_util'; -import {op} from './operation'; - -/** - * Computes the backprop of a 2D max pool. - * - * @param dy The dy error, of rank 4 or rank 3 of shape - * [batchSize, height, width, channels]. If rank 3, batch of 1 is - * assumed. - * @param input The original input image, of rank 4, of shape - * [batchSize, height, width, channels]. - * @param output The original output image, of rank 4, of shape - * [batchSize, outHeight, outWidth, channels]. - * @param filterSize The filter size: `[filterHeight, filterWidth]`. If - * `filterSize` is a single number, then `filterHeight == filterWidth`. - * @param strides The strides of the pooling: `[strideHeight, strideWidth]`. If - * `strides` is a single number, then `strideHeight == strideWidth`. - * @param pad The type of padding algorithm used in the forward prop of the op. - * 'same', 'valid', for more info, see this guide: - * [https://www.tensorflow.org/api_docs/python/tf/nn/convolution]( - * https://www.tensorflow.org/api_docs/python/tf/nn/convolution) - * @param dimRoundingMode A string from: 'ceil', 'round', 'floor'. If none is - * provided, it will default to truncate. - */ -function maxPoolGrad_( - dy: Tensor4D|TensorLike, input: Tensor4D|TensorLike, - output: Tensor4D|TensorLike, filterSize: [number, number]|number, - strides: [number, number]|number, - pad: 'valid'|'same'|number|conv_util.ExplicitPadding, - dimRoundingMode?: 'floor'|'round'|'ceil'): Tensor4D { - const $dy = convertToTensor(dy, 'dy', 'maxPoolGrad'); - const $input = convertToTensor(input, 'input', 'maxPoolGrad'); - const $output = convertToTensor(output, 'output', 'maxPoolGrad'); - - util.assert( - $input.rank === $dy.rank, - () => `Rank of input (${$input.rank}) does not match rank of dy ` + - `(${$dy.rank})`); - - util.assert( - $dy.rank === 4, - () => `Error in maxPoolGrad: dy must be rank 4 but got rank ` + - `${$dy.rank}.`); - util.assert( - $input.rank === 4, - () => `Error in maxPoolGrad: input must be rank 4 but got rank ` + - `${$input.rank}.`); - conv_util.checkPadOnDimRoundingMode('maxPoolGrad', pad, dimRoundingMode); - const inputs: MaxPoolGradInputs = {dy: $dy, input: $input, output: $output}; - const attrs: MaxPoolGradAttrs = {filterSize, strides, pad, dimRoundingMode}; - - // tslint:disable-next-line: no-unnecessary-type-assertion - return ENGINE.runKernel( - MaxPoolGrad, inputs as unknown as NamedTensorMap, - attrs as unknown as NamedAttrMap) as Tensor4D; -} - -export const maxPoolGrad = /* @__PURE__ */ op({maxPoolGrad_}); diff --git a/tfjs-master/tfjs-core/src/ops/max_pool_test.ts b/tfjs-master/tfjs-core/src/ops/max_pool_test.ts deleted file mode 100644 index ba9823698..000000000 --- a/tfjs-master/tfjs-core/src/ops/max_pool_test.ts +++ /dev/null @@ -1,453 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; -import { identityPoolTest } from './identity_pool_test'; - -describeWithFlags('maxPool', ALL_ENVS, () => { - it('x=[1,1,1] f=[1,1] s=1 [0] => [0]', async () => { - const x = tf.tensor3d([123], [1, 1, 1]); - - const result = tf.maxPool(x, 1, 1, 0); - - expectArraysClose(await result.data(), [123]); - }); - - it('x=[3,3,1] f=[2,2] s=1, p=0', async () => { - // Feed forward. - const x = tf.tensor3d([1, 2, 3, 4, 5, 6, 7, 9, 8], [3, 3, 1]); - - const result = tf.maxPool(x, 2, 1, 0); - - expect(result.shape).toEqual([2, 2, 1]); - expectArraysClose(await result.data(), [5, 6, 9, 9]); - }); - - it('x=[3,3,1] f=[2,2] s=1 p=same', async () => { - const x = tf.tensor3d([1, 2, 3, 4, 5, 6, 7, 9, 8], [3, 3, 1]); - - const result = tf.maxPool(x, 2, 1, 'same'); - const resultData = await result.data(); - - tf.test_util.expectArraysClose( - resultData, new Float32Array([5, 6, 6, 9, 9, 8, 9, 9, 8])); - }); - - it('x=[3,3,1] f=[3,3] s=1 p=explicit', async () => { - const x = tf.tensor3d([0, 1, 2, 3, 4, 5, 6, 7, 8], [3, 3, 1]); - const padding = - [[0, 0], [1, 2], [0, 1], [0, 0]] as tf.backend_util.ExplicitPadding; - const result = tf.maxPool(x, 3, 1, padding); - - expect(result.shape).toEqual([4, 2, 1]); - expectArraysClose(await result.data(), [5, 5, 8, 8, 8, 8, 8, 8]); - }); - - it('x=[2,3,3,1] f=[2,2] s=1', async () => { - // Feed forward. - const x = tf.tensor4d( - [1, 2, 3, 4, 5, 6, 7, 9, 8, 1, 2, 3, 4, 5, 6, 7, 8, 9], [2, 3, 3, 1]); - - const result = tf.maxPool(x, 2, 1, 0); - - expect(result.shape).toEqual([2, 2, 2, 1]); - expectArraysClose(await result.data(), [5, 6, 9, 9, 5, 6, 8, 9]); - }); - - it('[x=[3,3,1] f=[2,2] s=1 ignores NaNs', async () => { - const x = tf.tensor3d([1, 2, 3, 4, 5, 6, 7, NaN, 9], [3, 3, 1]); - - const result = tf.maxPool(x, 2, 1, 0); - - expect(result.shape).toEqual([2, 2, 1]); - expectArraysClose(await result.data(), [5, 6, 7, 9]); - }); - - it('x=[3,3,2] f=[2,2] s=1', async () => { - // Feed forward. - const x = tf.tensor3d( - [1, 99, 2, 88, 3, 77, 4, 66, 5, 55, 6, 44, 7, 33, 9, 22, 8, 11], - [3, 3, 2]); - - const result = tf.maxPool(x, 2, 1, 0); - - expect(result.shape).toEqual([2, 2, 2]); - expectArraysClose(await result.data(), [5, 99, 6, 88, 9, 66, 9, 55]); - }); - - it('x=[4,4,1] f=[2,2] s=2', async () => { - // Feed forward. - const x = tf.tensor3d( - [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], [4, 4, 1]); - - const result = tf.maxPool(x, 2, 2, 0); - - expect(result.shape).toEqual([2, 2, 1]); - expectArraysClose(await result.data(), [5, 7, 13, 15]); - }); - - it('x=[2,2,1] f=[2,2] s=1 p=same', async () => { - // Feed forward. - const x = tf.tensor3d([1, 2, 3, 4], [2, 2, 1]); - const fSize = 2; - const strides = 1; - const result = tf.maxPool(x, fSize, strides, 'same'); - expect(result.shape).toEqual([2, 2, 1]); - expectArraysClose(await result.data(), [4, 4, 4, 4]); - }); - - it('x=[2,2,3] f=[2,2] s=3 p=1 default dimRoundingMode', () => { - // Feed forward. - const x = tf.tensor3d([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [2, 2, 3]); - const result = tf.maxPool(x, 2, 3, 1); - - expect(result.shape).toEqual([1, 1, 3]); - }); - - it('x=[2,2,3] f=[1,1] s=2 p=1 dimRoundingMode=floor', () => { - // Feed forward. - const x = tf.tensor3d([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [2, 2, 3]); - const result = tf.maxPool(x, 1, 2, 1, 'floor'); - - expect(result.shape).toEqual([2, 2, 3]); - }); - - it('x=[2,2,3] f=[2,2] s=3 p=1 dimRoundingMode=floor', () => { - // Feed forward. - const x = tf.tensor3d([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [2, 2, 3]); - const result = tf.maxPool(x, 2, 3, 1, 'floor'); - - expect(result.shape).toEqual([1, 1, 3]); - }); - - it('x=[2,2,3] f=[2,2] s=3 p=1 dimRoundingMode=round', () => { - // Feed forward. - const x = tf.tensor3d([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [2, 2, 3]); - const result = tf.maxPool(x, 2, 3, 1, 'round'); - - expect(result.shape).toEqual([2, 2, 3]); - }); - - it('x=[2,2,3] f=[2,2] s=3 p=1 dimRoundingMode=ceil', () => { - // Feed forward. - const x = tf.tensor3d([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [2, 2, 3]); - const result = tf.maxPool(x, 2, 3, 1, 'ceil'); - - expect(result.shape).toEqual([2, 2, 3]); - }); - - it('throws when x is not rank 3', () => { - // tslint:disable-next-line:no-any - const x: any = tf.tensor2d([1, 2, 3, 4, 5, 6, 7, 8, 9], [3, 3]); - - expect(() => tf.maxPool(x, 2, 1, 0)).toThrowError(); - }); - - it('throws when dimRoundingMode is set and pad is same', () => { - const x = tf.tensor3d([1, 2, 3, 4], [2, 2, 1]); - - const pad = 'same'; - const dimRoundingMode = 'round'; - - expect(() => tf.maxPool(x, 2, 1, pad, dimRoundingMode)).toThrowError(); - }); - - it('throws when dimRoundingMode is set and pad is valid', () => { - const x = tf.tensor3d([1, 2, 3, 4], [2, 2, 1]); - - const pad = 'valid'; - const dimRoundingMode = 'round'; - - expect(() => tf.maxPool(x, 2, 1, pad, dimRoundingMode)).toThrowError(); - }); - - it('throws when dimRoundingMode is set and pad is a non-integer number', - () => { - const x = tf.tensor3d([1, 2, 3, 4], [2, 2, 1]); - - const pad = 1.2; - const dimRoundingMode = 'round'; - - expect(() => tf.maxPool(x, 2, 1, pad, dimRoundingMode)).toThrowError(); - }); - - it('throws when dimRoundingMode is set and pad is explicit by non-integer ' + - 'number', - () => { - const x = tf.tensor3d([1, 2, 3, 4], [2, 2, 1]); - - const pad = [[0, 0], [0, 2.1], [1, 1], [0, 0]] as - tf.backend_util.ExplicitPadding; - const dimRoundingMode = 'round'; - - expect(() => tf.maxPool(x, 2, 1, pad, dimRoundingMode)).toThrowError(); - }); - - it('throws when passed a non-tensor', () => { - expect(() => tf.maxPool({} as tf.Tensor3D, 2, 1, 'valid')) - .toThrowError(/Argument 'x' passed to 'maxPool' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const x = [[[0]]]; // 1x1x1 - const result = tf.maxPool(x, 1, 1, 0); - expectArraysClose(await result.data(), [0]); - }); - - identityPoolTest(tf.maxPool); -}); - -describeWithFlags('maxPoolBackprop', ALL_ENVS, () => { - it('gradients x=[3,3,1] f=[2,2] s=1 no dup max value, test #1', async () => { - const dy = tf.tensor3d([1, 2, 3, 4], [2, 2, 1]); - const x = tf.tensor3d([1, 2, 3, 4, 5, 6, 7, 8, 9], [3, 3, 1]); - const expected = [0, 0, 0, 0, 1, 2, 0, 3, 4]; - - const dx = tf.grad((x: tf.Tensor3D) => x.maxPool(2, 1, 0))(x, dy); - - expect(dx.shape).toEqual(x.shape); - expectArraysClose(await dx.data(), expected); - }); - - it('gradient with clones x=[3,3,1] f=[2,2] s=1', async () => { - const dy = tf.tensor3d([1, 2, 3, 4], [2, 2, 1]); - const x = tf.tensor3d([1, 2, 3, 4, 5, 6, 7, 8, 9], [3, 3, 1]); - const expected = [0, 0, 0, 0, 1, 2, 0, 3, 4]; - - const dx = tf.grad( - (x: tf.Tensor3D) => tf.maxPool(x.clone(), 2, 1, 0).clone())(x, dy); - - expect(dx.shape).toEqual(x.shape); - expectArraysClose(await dx.data(), expected); - }); - - it('gradients x=[3,3,1] f=[2,2] s=1 no dup max value, test #2', async () => { - const dy = tf.tensor3d([1, 2, 3, 4], [2, 2, 1]); - const x = tf.tensor3d([9, 5, 6, 6, 8, 4, 9, 5, 10], [3, 3, 1]); - const expected = [1, 0, 0, 0, 2, 0, 3, 0, 4]; - - const dx = tf.grad((x: tf.Tensor3D) => x.maxPool(2, 1, 0))(x, dy); - - expect(dx.shape).toEqual(x.shape); - expectArraysClose(await dx.data(), expected); - }); - - it('gradients x=[2,3,3,1] f=[2,2] s=1 no duplicate max value', async () => { - // This test batches the [3,3,1] tests. - const dy = tf.tensor4d([1, 2, 3, 4, 1, 2, 3, 4], [2, 2, 2, 1]); - const x = tf.tensor4d( - [1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 5, 6, 6, 8, 4, 9, 5, 10], [2, 3, 3, 1]); - const expected = [0, 0, 0, 0, 1, 2, 0, 3, 4, 1, 0, 0, 0, 2, 0, 3, 0, 4]; - - const dx = tf.grad((x: tf.Tensor4D) => x.maxPool(2, 1, 0))(x, dy); - - expect(dx.shape).toEqual(x.shape); - expectArraysClose(await dx.data(), expected); - }); - - it('gradient x=[3,3,1] f=[2,2] s=1 dup max value, test 1', async () => { - const dy = tf.tensor3d([1, 2, 3, 4], [2, 2, 1]); - const x = tf.tensor3d([0, 0, 0, 0, 5, 0, 0, 0, 0], [3, 3, 1]); - const expected = [0, 0, 0, 0, 10, 0, 0, 0, 0]; - - const dx = tf.grad((x: tf.Tensor3D) => x.maxPool(2, 1, 0))(x, dy); - - expect(dx.shape).toEqual(x.shape); - expectArraysClose(await dx.data(), expected); - }); - - it('gradient x=[3,3,1] f=[2,2] s=1 dup max value, test 2', async () => { - const dy = tf.tensor3d([1, 2, 3, 4], [2, 2, 1]); - const x = tf.tensor3d([1, 3, 2, 1, 2, 1, 1, 1, 5], [3, 3, 1]); - const expected = [0, 3, 0, 0, 3, 0, 0, 0, 4]; - - const dx = tf.grad((x: tf.Tensor3D) => x.maxPool(2, 1, 0))(x, dy); - - expect(dx.shape).toEqual(x.shape); - expectArraysClose(await dx.data(), expected); - }); - - it('gradient x=[2,3,3,1] f=[2,2] s=1 dup max value in 2nd input', - async () => { - const dy = tf.tensor4d([1, 2, 3, 4, 5, 6, 7, 8], [2, 2, 2, 1]); - const x = tf.tensor4d( - [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 9, 8], - [2, 3, 3, 1]); - const expected = new Float32Array( - [0, 0, 0, 0, 1, 2, 0, 3, 4, 0, 0, 0, 0, 5, 6, 0, 15, 0]); - - const dx = tf.grad((x: tf.Tensor4D) => x.maxPool(2, 1, 0))(x, dy); - - expect(dx.shape).toEqual(x.shape); - expectArraysClose(await dx.data(), expected); - }); - - it('gradient x=[4,4,1] f=[2,2] s=2 test #1', async () => { - const dy = tf.tensor3d([1, 2, 3, 4], [2, 2, 1]); - const x = tf.tensor3d( - [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], [4, 4, 1]); - const expected = [0, 0, 0, 0, 0, 1, 0, 2, 0, 0, 0, 0, 0, 3, 0, 4]; - - const dx = tf.grad((x: tf.Tensor3D) => x.maxPool(2, 2, 0))(x, dy); - - expect(dx.shape).toEqual(x.shape); - expectArraysClose(await dx.data(), expected); - }); - - it('gradient x=[4,4,1] f=[2,2] s=2 test #2', async () => { - const dy = tf.tensor3d([1, 2, 3, 4], [2, 2, 1]); - const x = tf.tensor3d( - [1, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1], [4, 4, 1]); - const expected = [0, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 4, 0]; - - const dx = tf.grad((x: tf.Tensor3D) => x.maxPool(2, 2, 0))(x, dy); - - expect(dx.shape).toEqual(x.shape); - expectArraysClose(await dx.data(), expected); - }); - - it('gradient x=[5,5,1] f=[3,3] s=2 no duplicate max value', async () => { - const dy = tf.tensor3d([1, 2, 3, 4], [2, 2, 1]); - const x = tf.tensor3d( - [ - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, - 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24 - ], - [5, 5, 1]); - const expected = [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, - 0, 2, 0, 0, 0, 0, 0, 0, 0, 3, 0, 4 - ]; - - const dx = tf.grad((x: tf.Tensor3D) => x.maxPool(3, 2, 0))(x, dy); - - expect(dx.shape).toEqual(x.shape); - expectArraysClose(await dx.data(), expected); - }); - - it('gradient x=[5,5,1] f=[3,3] s=2 duplicate max value', async () => { - const dy = tf.tensor3d([1, 2, 3, 4], [2, 2, 1]); - const x = tf.tensor3d( - [ - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 24, - 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 12 - ], - [5, 5, 1]); - const expected = [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ]; - - const dx = tf.grad((x: tf.Tensor3D) => x.maxPool(3, 2, 0))(x, dy); - - expect(dx.shape).toEqual(x.shape); - expectArraysClose(await dx.data(), expected); - }); - - // Max pool backprop depth > 1. - it('gradient x=[3,3,2] f=[2,2] s=1, no duplicate max value', async () => { - // This test combines the first two 3x3x1 tests with no duplicates to - // make depth=2, - // dy is slightly modified to show the difference. - const dy = tf.tensor3d([1, 44, 2, 33, 3, 22, 4, 11], [2, 2, 2]); - const x = tf.tensor3d( - [1, 99, 2, 55, 3, 66, 4, 66, 5, 88, 6, 44, 7, 99, 8, 55, 9, 100], - [3, 3, 2]); - const expected = [0, 44, 0, 0, 0, 0, 0, 0, 1, 33, 2, 0, 0, 22, 3, 0, 4, 11]; - - const dx = tf.grad((x: tf.Tensor3D) => x.maxPool(2, 1, 0))(x, dy); - - expect(dx.shape).toEqual(x.shape); - expectArraysClose(await dx.data(), expected); - }); - - it('gradient x=[3,3,2] f=[2,2] s=1 duplicate max value', async () => { - // This test combines the first two 3x3x1 tests with duplicates to - // make depth=2, - // dy is slightly modified to show the difference. - const dy = tf.tensor3d([1, 44, 2, 33, 3, 22, 4, 11], [2, 2, 2]); - const x = tf.tensor3d( - [0, 1, 0, 3, 0, 2, 0, 1, 5, 2, 0, 1, 0, 1, 0, 1, 0, 5], [3, 3, 2]); - const expected = new Float32Array( - [0, 0, 0, 77, 0, 0, 0, 0, 10, 22, 0, 0, 0, 0, 0, 0, 0, 11]); - - const dx = tf.grad((x: tf.Tensor3D) => x.maxPool(2, 1, 0))(x, dy); - - expect(dx.shape).toEqual(x.shape); - expectArraysClose(await dx.data(), expected); - }); - - it('gradient x=[4,4,2] f=[2,2] s=1', async () => { - // This test combines the first two 4x4x1 tests with duplicates to make - // depth=2, - // dy is slightly modified to show the difference. - const dy = tf.tensor3d([1, 11, 2, 22, 3, 33, 4, 44], [2, 2, 2]); - const x = tf.tensor3d( - [ - 0, 1, 1, 2, 2, 2, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, - 8, 1, 9, 1, 10, 1, 11, 1, 12, 1, 13, 2, 14, 2, 15, 1 - ], - [4, 4, 2]); - const expected = [ - 0, 0, 0, 11, 0, 22, 0, 0, 0, 0, 1, 0, 0, 0, 2, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 33, 0, 44, 4, 0 - ]; - - const dx = tf.grad((x: tf.Tensor3D) => x.maxPool(2, 2, 0))(x, dy); - - expect(dx.shape).toEqual(x.shape); - expectArraysClose(await dx.data(), expected); - }); - - it('gradient x=[3,3,1] f=3 s=1 p=explicit', async () => { - const dy = tf.tensor3d([1, 11, 2, 22, 3, 33, 4, 44], [4, 2, 1]); - const x = tf.tensor3d([0, 1, 2, 3, 4, 5, 6, 7, 8], [3, 3, 1]); - const padding = - [[0, 0], [1, 2], [0, 1], [0, 0]] as tf.backend_util.ExplicitPadding; - const expected = [0, 0, 0, 0, 0, 12, 0, 0, 108]; - const dx = tf.grad((x: tf.Tensor3D) => x.maxPool(3, 1, padding))(x, dy); - - expect(dx.shape).toEqual(x.shape); - expectArraysClose(await dx.data(), expected); - }); - - it('gradient x=5x5x2, f=3, s=2 no duplicate max value', async () => { - // This test combines the first two 5x5x1 tests with duplicates to make - // depth=2, - // dy is slightly modified to show the difference. - const dy = tf.tensor3d([1, 11, 2, 22, 3, 33, 4, 44], [2, 2, 2]); - const x = tf.tensor3d( - [ - 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, - 8, 9, 9, 10, 10, 11, 11, 12, 24, 13, 13, 14, 14, 15, 15, 16, 16, - 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 12 - ], - [5, 5, 2]); - const expected = [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 1, 110, 0, 0, 2, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 4, 0 - ]; - - const dx = tf.grad((x: tf.Tensor3D) => x.maxPool(3, 2, 0))(x, dy); - - expect(dx.shape).toEqual(x.shape); - expectArraysClose(await dx.data(), expected); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/max_pool_with_argmax.ts b/tfjs-master/tfjs-core/src/ops/max_pool_with_argmax.ts deleted file mode 100644 index 9dd079f1f..000000000 --- a/tfjs-master/tfjs-core/src/ops/max_pool_with_argmax.ts +++ /dev/null @@ -1,79 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {MaxPoolWithArgmax, MaxPoolWithArgmaxAttrs, MaxPoolWithArgmaxInputs} from '../kernel_names'; -import {NamedAttrMap} from '../kernel_registry'; -import {Tensor, Tensor4D} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -import {op} from './operation'; - -/** - * Computes the 2D max pooling of an image with Argmax index. - * The indices in argmax are flattened, so that a maximum value at position `[b, - * y, x, c]` becomes flattened index: `(y * width + x) * channels + c` if - * include_batch_in_index is False; `((b * height + y) * width + x) * channels - * +c` if include_batch_in_index is True. - * - * The indices returned are always in `[0, height) x [0, width)` before - * flattening. - * - * @param x The input tensor, of rank 4 or rank 3 of shape - * `[batch, height, width, inChannels]`. If rank 3, batch of 1 is assumed. - * @param filterSize The filter size: `[filterHeight, filterWidth]`. If - * `filterSize` is a single number, then `filterHeight == filterWidth`. - * @param strides The strides of the pooling: `[strideHeight, strideWidth]`. If - * `strides` is a single number, then `strideHeight == strideWidth`. - * @param dataFormat An optional string from: "NDHWC", "NCDHW". Defaults to - * "NDHWC". Specify the data format of the input and output data. With the - * default format "NDHWC", the data is stored in the order of: [batch, - * depth, height, width, channels]. Only "NDHWC" is currently supported. - * @param pad The type of padding algorithm. - * - `same` and stride 1: output will be of same size as input, - * regardless of filter size. - * - `valid`: output will be smaller than input if filter is larger - * than 1x1. - * - For more info, see this guide: - * [https://www.tensorflow.org/api_docs/python/tf/nn/convolution]( - * https://www.tensorflow.org/api_docs/python/tf/nn/convolution) - * @param includeBatchIndex Defaults to False. Whether to include batch - * dimension in flattened index of argmax. - * - * @doc {heading: 'Operations', subheading: 'Convolution'} - */ -function maxPoolWithArgmax_( - x: T|TensorLike, filterSize: [number, number]|number, - strides: [number, number]|number, pad: 'valid'|'same'|number, - includeBatchInIndex = false): NamedTensorMap { - const $x = convertToTensor(x, 'x', 'maxPoolWithArgmax'); - - const inputs: MaxPoolWithArgmaxInputs = {x: $x}; - const attrs: - MaxPoolWithArgmaxAttrs = {filterSize, strides, pad, includeBatchInIndex}; - - // tslint:disable-next-line: no-unnecessary-type-assertion - const result = ENGINE.runKernel( - MaxPoolWithArgmax, inputs as unknown as NamedTensorMap, - attrs as unknown as NamedAttrMap) as Tensor[]; - - return {result: result[0], indexes: result[1]}; -} - -export const maxPoolWithArgmax = /* @__PURE__ */ op({maxPoolWithArgmax_}); diff --git a/tfjs-master/tfjs-core/src/ops/max_pool_with_argmax_test.ts b/tfjs-master/tfjs-core/src/ops/max_pool_with_argmax_test.ts deleted file mode 100644 index cbdb2621b..000000000 --- a/tfjs-master/tfjs-core/src/ops/max_pool_with_argmax_test.ts +++ /dev/null @@ -1,170 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('maxPoolWithArgmax', ALL_ENVS, () => { - it('x=[1,1,1] f=[1,1] s=1 d=1 [0] => [0]', async () => { - const x = tf.tensor4d([0], [1, 1, 1, 1]); - - const padding = 0; - - const {result, indexes} = tf.maxPoolWithArgmax(x, [1, 1], [1, 1], padding); - expectArraysClose(await result.data(), [0]); - expectArraysClose(await indexes.data(), [0]); - }); - - it('x=[2,2,2,1] f=[2,2,2] s=1 p=valid', async () => { - const x = tf.tensor4d([1, 2, 3, 4, 5, 6, 7, 8], [2, 2, 2, 1]); - - const {result, indexes} = tf.maxPoolWithArgmax(x, 2, 1, 'valid'); - - expect(result.shape).toEqual([2, 1, 1, 1]); - expectArraysClose(await result.data(), [4, 8]); - expect(indexes.shape).toEqual([2, 1, 1, 1]); - expectArraysClose(await indexes.data(), [3, 3]); - }); - - it('x=[2,2,2,1] f=[2,2,2] s=1 p=valid includeBatchInIndex=true', async () => { - const x = tf.tensor4d([1, 2, 3, 4, 5, 6, 7, 8], [2, 2, 2, 1]); - - const {result, indexes} = tf.maxPoolWithArgmax(x, 2, 1, 'valid', true); - - expect(result.shape).toEqual([2, 1, 1, 1]); - expectArraysClose(await result.data(), [4, 8]); - expect(indexes.shape).toEqual([2, 1, 1, 1]); - expectArraysClose(await indexes.data(), [3, 7]); - }); - - it('x=[1,3,3,1] f=[2,2] s=1, p=0', async () => { - // Feed forward. - const x = tf.tensor4d([1, 2, 3, 4, 5, 6, 7, 9, 8], [1, 3, 3, 1]); - - const {result, indexes} = tf.maxPoolWithArgmax(x, 2, 1, 0); - - expect(result.shape).toEqual([1, 2, 2, 1]); - expectArraysClose(await result.data(), [5, 6, 9, 9]); - expect(indexes.shape).toEqual([1, 2, 2, 1]); - expectArraysClose(await indexes.data(), [4, 5, 7, 7]); - }); - - it('x=[1,3,3,1] f=[2,2] s=1 p=same', async () => { - const x = tf.tensor4d([1, 2, 3, 4, 5, 6, 7, 9, 8], [1, 3, 3, 1]); - - const {result, indexes} = tf.maxPoolWithArgmax(x, 2, 1, 'same'); - - expect(result.shape).toEqual([1, 3, 3, 1]); - tf.test_util.expectArraysClose( - await result.data(), new Float32Array([5, 6, 6, 9, 9, 8, 9, 9, 8])); - expect(indexes.shape).toEqual([1, 3, 3, 1]); - expectArraysClose(await indexes.data(), [4, 5, 5, 7, 7, 8, 7, 7, 8]); - }); - - it('x=[2,3,3,1] f=[2,2] s=1', async () => { - const x = tf.tensor4d( - [1, 2, 3, 4, 5, 6, 7, 9, 8, 1, 2, 3, 4, 5, 6, 7, 8, 9], [2, 3, 3, 1]); - - const {result, indexes} = tf.maxPoolWithArgmax(x, 2, 1, 0); - expect(result.shape).toEqual([2, 2, 2, 1]); - expectArraysClose(await result.data(), [5, 6, 9, 9, 5, 6, 8, 9]); - expect(indexes.shape).toEqual([2, 2, 2, 1]); - expectArraysClose(await indexes.data(), [4, 5, 7, 7, 4, 5, 7, 8]); - }); - - it('x=[2,3,3,1] f=[2,2] s=1 includeBatchInIndex=true', async () => { - const x = tf.tensor4d( - [1, 2, 3, 4, 5, 6, 7, 9, 8, 1, 2, 3, 4, 5, 6, 7, 8, 9], [2, 3, 3, 1]); - - const {result, indexes} = tf.maxPoolWithArgmax(x, 2, 1, 0, true); - expect(result.shape).toEqual([2, 2, 2, 1]); - expectArraysClose(await result.data(), [5, 6, 9, 9, 5, 6, 8, 9]); - expect(indexes.shape).toEqual([2, 2, 2, 1]); - expectArraysClose(await indexes.data(), [4, 5, 7, 7, 13, 14, 16, 17]); - }); - - it('[x=[1,3,3,1] f=[2,2] s=1 ignores NaNs', async () => { - const x = tf.tensor4d([NaN, 1, 2, 3, 4, 5, 6, 7, 9], [1, 3, 3, 1]); - - const {result, indexes} = tf.maxPoolWithArgmax(x, 2, 1, 0); - - expect(result.shape).toEqual([1, 2, 2, 1]); - expectArraysClose(await result.data(), [4, 5, 7, 9]); - expect(indexes.shape).toEqual([1, 2, 2, 1]); - expectArraysClose(await indexes.data(), [4, 5, 7, 8]); - }); - - it('x=[1, 3,3,2] f=[2,2] s=1', async () => { - // Feed forward. - const x = tf.tensor4d( - [1, 99, 2, 88, 3, 77, 4, 66, 5, 55, 6, 44, 7, 33, 9, 22, 8, 11], - [1, 3, 3, 2]); - - const {result, indexes} = tf.maxPoolWithArgmax(x, 2, 1, 0); - - expect(result.shape).toEqual([1, 2, 2, 2]); - expectArraysClose(await result.data(), [5, 99, 6, 88, 9, 66, 9, 55]); - expect(indexes.shape).toEqual([1, 2, 2, 2]); - expectArraysClose(await indexes.data(), [8, 1, 10, 3, 14, 7, 14, 9]); - }); - - it('x=[1,4,4,1] f=[2,2] s=2', async () => { - // Feed forward. - const x = tf.tensor4d( - [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], [1, 4, 4, 1]); - - const {result, indexes} = tf.maxPoolWithArgmax(x, 2, 2, 0); - - expect(result.shape).toEqual([1, 2, 2, 1]); - expectArraysClose(await result.data(), [5, 7, 13, 15]); - expect(indexes.shape).toEqual([1, 2, 2, 1]); - expectArraysClose(await indexes.data(), [5, 7, 13, 15]); - }); - - it('x=[1,2,2,1] f=[2,2] s=1 p=same', async () => { - // Feed forward. - const x = tf.tensor4d([1, 2, 3, 4], [1, 2, 2, 1]); - - const {result, indexes} = tf.maxPoolWithArgmax(x, 2, 1, 'same'); - expect(result.shape).toEqual([1, 2, 2, 1]); - expectArraysClose(await result.data(), [4, 4, 4, 4]); - expect(indexes.shape).toEqual([1, 2, 2, 1]); - expectArraysClose(await indexes.data(), [3, 3, 3, 3]); - }); - - it('throws when x is not rank 4', () => { - // tslint:disable-next-line:no-any - const x: any = tf.tensor3d([1, 2, 3, 4, 5, 6, 7, 8, 9], [1, 3, 3]); - - expect(() => tf.maxPoolWithArgmax(x, 2, 1, 0)).toThrowError(); - }); - - it('throws when passed a non-tensor', () => { - expect(() => tf.maxPoolWithArgmax({} as tf.Tensor4D, 2, 1, 'valid')) - .toThrowError( - /Argument 'x' passed to 'maxPoolWithArgmax' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const x = [[[[0]]]]; // 1x1x1 - const {result, indexes} = tf.maxPoolWithArgmax(x, 1, 1, 0); - expectArraysClose(await result.data(), [0]); - expect(indexes.shape).toEqual([1, 1, 1, 1]); - expectArraysClose(await indexes.data(), [0]); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/max_test.ts b/tfjs-master/tfjs-core/src/ops/max_test.ts deleted file mode 100644 index 790043db4..000000000 --- a/tfjs-master/tfjs-core/src/ops/max_test.ts +++ /dev/null @@ -1,272 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('max', ALL_ENVS, () => { - it('with one element dominating', async () => { - const a = tf.tensor1d([3, -1, 0, 100, -7, 2]); - const r = tf.max(a); - expectArraysClose(await r.data(), 100); - }); - - it('with all elements being the same', async () => { - const a = tf.tensor1d([3, 3, 3]); - const r = tf.max(a); - expectArraysClose(await r.data(), 3); - }); - - it('with a large dimension', async () => { - const aData = new Float32Array(1000); - aData[0] = 1; - const a = tf.tensor1d(aData); - const r = tf.max(a); - expectArraysClose(await r.data(), 1); - }); - - it('return NaNs', async () => { - expectArraysClose(await tf.max([3, NaN, 2]).data(), NaN); - }); - - it('2D', async () => { - const a = tf.tensor2d([3, -1, 0, 100, -7, 2], [2, 3]); - expectArraysClose(await tf.max(a).data(), 100); - }); - - it('2D axis=[0,1]', async () => { - const a = tf.tensor2d([3, -1, 0, 100, -7, 2], [2, 3]); - expectArraysClose(await tf.max(a, [0, 1]).data(), 100); - }); - - it('2D, axis=0', async () => { - const a = tf.tensor2d([3, -1, 0, 100, -7, 2], [2, 3]); - const r = tf.max(a, [0]); - - expect(r.shape).toEqual([3]); - expectArraysClose(await r.data(), [100, -1, 2]); - }); - - it('2D, axis=0, keepDims', async () => { - const a = tf.tensor2d([3, -1, 0, 100, -7, 2], [2, 3]); - const r = tf.max(a, [0], true /* keepDims */); - - expect(r.shape).toEqual([1, 3]); - expectArraysClose(await r.data(), [100, -1, 2]); - }); - - it('2D, axis=1 provided as a number', async () => { - const a = tf.tensor2d([3, 2, 5, 100, -7, 2], [2, 3]); - const r = tf.max(a, 1); - expectArraysClose(await r.data(), [5, 100]); - }); - - it('2D, axis = -1 provided as a number', async () => { - const a = tf.tensor2d([3, 2, 5, 100, -7, 2], [2, 3]); - const r = tf.max(a, -1); - expectArraysClose(await r.data(), [5, 100]); - }); - - it('2D, axis=[1]', async () => { - const a = tf.tensor2d([3, 2, 5, 100, -7, 2], [2, 3]); - const r = tf.max(a, [1]); - expectArraysClose(await r.data(), [5, 100]); - }); - - it('6D, axis=[5]', async () => { - const a = tf.range(0, 64).reshape([2, 2, 2, 2, 2, 2]); - const r = tf.max(a, [5]); - const expectedResult = [ - 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, - 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63 - ]; - expectArraysClose(await r.data(), expectedResult); - }); - - it('axis permutation does not change input', async () => { - const input = tf.tensor2d([3, -1, 0, 100, -7, 2], [2, 3]); - const inputDataBefore = await input.data(); - - tf.max(input, [1, 0]); - - const inputDataAfter = await input.data(); - expectArraysClose(inputDataBefore, inputDataAfter); - }); - - it('throws when passed a non-tensor', () => { - expect(() => tf.max({} as tf.Tensor)) - .toThrowError(/Argument 'x' passed to 'max' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const r = tf.max([3, -1, 0, 100, -7, 2]); - expectArraysClose(await r.data(), 100); - }); - - it('accepts int32 tensor', async () => { - const a = tf.tensor2d([3, -1, 0, 100, -7, 2], [2, 3], 'int32'); - expect(a.dtype).toEqual('int32'); - expectArraysClose(await tf.max(a).data(), 100); - }); - - it('max gradient: Scalar', async () => { - const x = tf.scalar(42); - const dy = tf.scalar(-1); - const gradients = tf.grad(v => tf.max(v))(x, dy); - expectArraysClose(await gradients.data(), [-1]); - }); - - it('gradient with clones', async () => { - const x = tf.scalar(42); - const dy = tf.scalar(-1); - const gradients = tf.grad(v => tf.max(v.clone()).clone())(x, dy); - expectArraysClose(await gradients.data(), [-1]); - }); - - it('max gradient: 1D, ties', async () => { - const x = tf.tensor1d([1, 3, 7, 7]); - const dy = tf.scalar(-1); - const gradients = tf.grad(v => tf.max(v))(x, dy); - expectArraysClose(await gradients.data(), [0, 0, -1, -1]); - }); - - it('max gradient: 2D, axes=-1, keepDims=false', async () => { - const x = tf.tensor2d([[0, 20, 10], [-10, -30, -20]]); - const dy = tf.tensor1d([-1, -1]); - const axis = -1; - const gradients = tf.grad(v => tf.max(v, axis))(x, dy); - expectArraysClose(await gradients.data(), [0, -1, 0, -1, 0, 0]); - expect(gradients.shape).toEqual([2, 3]); - }); - - it('max gradient: ties, 2D, axes=-1, keepDims=false', async () => { - const x = tf.tensor2d([[0, 20, 20], [-10, -30, -10]]); - const dy = tf.tensor1d([-1, -1]); - const axis = -1; - const gradients = tf.grad(v => tf.max(v, axis))(x, dy); - expectArraysClose(await gradients.data(), [0, -1, -1, -1, 0, -1]); - expect(gradients.shape).toEqual([2, 3]); - }); - - it('max gradient: 2D, axes=0, keepDims=false', async () => { - const x = tf.tensor2d([[0, 20, 10], [-10, -30, 20]]); - const dy = tf.tensor1d([-1, -1, -1]); - const axis = 0; - const gradients = tf.grad(v => tf.max(v, axis))(x, dy); - expectArraysClose(await gradients.data(), [-1, -1, 0, 0, 0, -1]); - expect(gradients.shape).toEqual([2, 3]); - }); - - it('max gradient: 2D, axes=-1, keepDims=true', async () => { - const x = tf.tensor2d([[0, 20, 10], [-10, -30, -20]]); - const dy = tf.tensor2d([[-1], [-1]]); - const axis = -1; - const keepDims = true; - const gradients = tf.grad(v => tf.max(v, axis, keepDims))(x, dy); - expectArraysClose(await gradients.data(), [0, -1, 0, -1, 0, 0]); - expect(gradients.shape).toEqual([2, 3]); - }); - - it('max gradient: 2D, axes=0, keepDims=true', async () => { - const x = tf.tensor2d([[0, 20, 10], [-10, -30, 20]]); - const dy = tf.tensor2d([[-1, -1, -1]]); - const axis = 0; - const keepDims = true; - const gradients = tf.grad(v => tf.max(v, axis, keepDims))(x, dy); - expectArraysClose(await gradients.data(), [-1, -1, 0, 0, 0, -1]); - expect(gradients.shape).toEqual([2, 3]); - }); - - it('max gradient: 3D, axis=1 keepDims=false', async () => { - const x = tf.ones([2, 1, 250]); - const axis = 1; - const gradients = tf.grad(v => tf.max(v, axis))(x); - expect(gradients.shape).toEqual(x.shape); - }); - - it('max gradient: 3D, axes=[1, 2], keepDims=false', async () => { - const x = tf.tensor3d([[[0, 20], [10, 15]], [[-10, -30], [-20, -15]]]); - const dy = tf.tensor1d([-1, -1]); - const axis = [1, 2]; - const gradients = tf.grad(v => tf.max(v, axis))(x, dy); - expectArraysClose(await gradients.data(), [0, -1, 0, 0, -1, 0, 0, 0]); - expect(gradients.shape).toEqual([2, 2, 2]); - }); - - it('max gradient: ties, 3D, axes=[1, 2], keepDims=false', async () => { - const x = tf.tensor3d([[[0, 20], [20, 20]], [[-10, -30], [-10, -15]]]); - const dy = tf.tensor1d([-1, -1]); - const axis = [1, 2]; - const gradients = tf.grad(v => tf.max(v, axis))(x, dy); - expectArraysClose(await gradients.data(), [0, -1, -1, -1, -1, 0, -1, 0]); - expect(gradients.shape).toEqual([2, 2, 2]); - }); - - it('max gradient: 3D, axes=2, keepDims=false', async () => { - const x = tf.tensor3d([[[0, 20], [10, 15]], [[-10, -30], [-20, -15]]]); - const dy = tf.tensor2d([[-1, -1], [-1, -1]]); - const axis = 2; - const gradients = tf.grad(v => tf.max(v, axis))(x, dy); - expectArraysClose(await gradients.data(), [0, -1, 0, -1, -1, 0, 0, -1]); - expect(gradients.shape).toEqual([2, 2, 2]); - }); - - it('max gradient: 3D, axes=2, keepDims=true', async () => { - const x = tf.tensor3d([[[0, 20], [10, 15]], [[-10, -30], [-20, -15]]]); - const dy = tf.tensor3d([[[-1], [-1]], [[-1], [-1]]]); - const axis = 2; - const keepDims = true; - const gradients = tf.grad(v => tf.max(v, axis, keepDims))(x, dy); - expectArraysClose(await gradients.data(), [0, -1, 0, -1, -1, 0, 0, -1]); - expect(gradients.shape).toEqual([2, 2, 2]); - }); - - it('max gradient: ties, 4D, axes=[1, 2, 3], keepDims=false', async () => { - const x = tf.tensor4d([ - [[[0, 20], [20, 20]], [[-10, -30], [-10, -30]]], - [[[0, -20], [-20, -20]], [[10, 30], [10, 30]]] - ]); - const dy = tf.tensor1d([-1, -1]); - const axis = [1, 2, 3]; - const gradients = tf.grad(v => tf.max(v, axis))(x, dy); - expectArraysClose( - await gradients.data(), - [0, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, -1]); - expect(gradients.shape).toEqual([2, 2, 2, 2]); - }); - - it('max gradient: ties, 4D, axes=[2, 3], keepDims=true', async () => { - const x = tf.tensor4d([ - [[[0, 20], [20, 20]], [[-10, -30], [-10, -30]]], - [[[0, -20], [-20, -20]], [[10, 30], [10, 30]]] - ]); - const dy = tf.tensor4d([[[[-1]], [[-2]]], [[[-3]], [[-4]]]]); - const axis = [2, 3]; - const keepDims = true; - const gradients = tf.grad(v => tf.max(v, axis, keepDims))(x, dy); - expectArraysClose( - await gradients.data(), - [0, -1, -1, -1, -2, 0, -2, 0, -3, 0, 0, 0, 0, -4, 0, -4]); - expect(gradients.shape).toEqual([2, 2, 2, 2]); - }); - - it('throws error for string tensor', () => { - expect(() => tf.max(['a'])) - .toThrowError(/Argument 'x' passed to 'max' must be numeric tensor/); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/maximum.ts b/tfjs-master/tfjs-core/src/ops/maximum.ts deleted file mode 100644 index 1abcb6d5d..000000000 --- a/tfjs-master/tfjs-core/src/ops/maximum.ts +++ /dev/null @@ -1,74 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {Maximum, MaximumInputs} from '../kernel_names'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {makeTypesMatch} from '../tensor_util'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -import {assertAndGetBroadcastShape} from './broadcast_util'; -import {cast} from './cast'; -import {op} from './operation'; - -/** - * Returns the max of a and b (`a > b ? a : b`) element-wise. - * Supports broadcasting. - * - * We also expose `tf.maximumStrict` which has the same signature as this op and - * asserts that `a` and `b` are the same shape (does not broadcast). - * - * ```js - * const a = tf.tensor1d([1, 4, 3, 16]); - * const b = tf.tensor1d([1, 2, 9, 4]); - * - * a.maximum(b).print(); // or tf.maximum(a, b) - * ``` - * - * ```js - * // Broadcast maximum a with b. - * const a = tf.tensor1d([2, 4, 6, 8]); - * const b = tf.scalar(5); - * - * a.maximum(b).print(); // or tf.maximum(a, b) - * ``` - * - * @param a The first tensor. - * @param b The second tensor. Must have the same type as `a`. - * - * @doc {heading: 'Operations', subheading: 'Arithmetic'} - */ -function maximum_( - a: Tensor|TensorLike, b: Tensor|TensorLike): T { - let $a = convertToTensor(a, 'a', 'maximum'); - let $b = convertToTensor(b, 'b', 'maximum'); - [$a, $b] = makeTypesMatch($a, $b); - - if ($a.dtype === 'bool') { - $a = cast($a, 'int32'); - $b = cast($b, 'int32'); - } - assertAndGetBroadcastShape($a.shape, $b.shape); - - const inputs: MaximumInputs = {a: $a, b: $b}; - - return ENGINE.runKernel(Maximum, inputs as unknown as NamedTensorMap); -} - -export const maximum = /* @__PURE__ */ op({maximum_}); diff --git a/tfjs-master/tfjs-core/src/ops/mean.ts b/tfjs-master/tfjs-core/src/ops/mean.ts deleted file mode 100644 index db504b150..000000000 --- a/tfjs-master/tfjs-core/src/ops/mean.ts +++ /dev/null @@ -1,69 +0,0 @@ -/** - * @license - * Copyright 2020 Google Inc. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {Mean, MeanAttrs, MeanInputs} from '../kernel_names'; -import {NamedAttrMap} from '../kernel_registry'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -import {op} from './operation'; - -/** - * Computes the mean of elements across dimensions of a `tf.Tensor`. - * - * Reduces `x` along the dimensions given in `axis`. Unless `keepDims` is - * true, the rank of the `tf.Tensor` is reduced by 1 for each entry in `axis`. - * If `keepDims` is true, the reduced dimensions are retained with length 1. - * If `axis` has no entries, all dimensions are reduced, and a `tf.Tensor` with - * a single element is returned. - * - * ```js - * const x = tf.tensor1d([1, 2, 3]); - * - * x.mean().print(); // or tf.mean(a) - * ``` - * - * ```js - * const x = tf.tensor2d([1, 2, 3, 4], [2, 2]); - * - * const axis = 1; - * x.mean(axis).print(); // or tf.mean(x, axis) - * ``` - * - * @param x The input tensor. - * @param axis The dimension(s) to reduce. By default it reduces - * all dimensions. - * @param keepDims If true, retains reduced dimensions with size 1. - * - * @doc {heading: 'Operations', subheading: 'Reduction'} - */ -function mean_( - x: Tensor|TensorLike, axis: number|number[] = null, keepDims = false): T { - const $x = convertToTensor(x, 'x', 'mean'); - - const inputs: MeanInputs = {x: $x}; - const attrs: MeanAttrs = {axis, keepDims}; - - return ENGINE.runKernel( - Mean, inputs as unknown as NamedTensorMap, - attrs as unknown as NamedAttrMap); -} - -export const mean = /* @__PURE__ */ op({mean_}); diff --git a/tfjs-master/tfjs-core/src/ops/mean_test.ts b/tfjs-master/tfjs-core/src/ops/mean_test.ts deleted file mode 100644 index 1df483385..000000000 --- a/tfjs-master/tfjs-core/src/ops/mean_test.ts +++ /dev/null @@ -1,172 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose, expectArraysEqual} from '../test_util'; - -describeWithFlags('mean', ALL_ENVS, () => { - it('basic', async () => { - const a = tf.tensor2d( - [ - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 - ], - [16, 2]); - const r = tf.mean(a); - - expect(r.dtype).toBe('float32'); - expectArraysClose(await r.data(), 15.5); - }); - - it('propagates NaNs', async () => { - const a = tf.tensor2d([1, 2, 3, NaN, 0, 1], [3, 2]); - const r = tf.mean(a); - - expect(r.dtype).toBe('float32'); - expectArraysEqual(await r.data(), NaN); - }); - - it('mean(int32) => float32', async () => { - const a = tf.tensor1d([1, 5, 7, 3], 'int32'); - const r = tf.mean(a); - - expect(r.dtype).toBe('float32'); - expectArraysClose(await r.data(), 4); - }); - - it('mean(bool) => float32', async () => { - const a = tf.tensor1d([true, false, false, true, true], 'bool'); - const r = tf.mean(a); - - expect(r.dtype).toBe('float32'); - expectArraysClose(await r.data(), 3 / 5); - }); - - it('2D array with keep dim', async () => { - const a = tf.tensor2d([1, 2, 3, 0, 0, 1], [3, 2]); - const res = tf.mean(a, null, true /* keepDims */); - - expect(res.shape).toEqual([1, 1]); - expect(res.dtype).toBe('float32'); - expectArraysClose(await res.data(), [7 / 6]); - }); - - it('axis=0 in 2D array', async () => { - const a = tf.tensor2d([1, 2, 3, 0, 0, 1], [3, 2]); - const res = tf.mean(a, [0]); - - expect(res.shape).toEqual([2]); - expect(res.dtype).toBe('float32'); - expectArraysClose(await res.data(), [4 / 3, 1]); - }); - - it('axis=0 in 2D array, keepDims', async () => { - const a = tf.tensor2d([1, 2, 3, 0, 0, 1], [3, 2]); - const res = tf.mean(a, [0], true /* keepDims */); - - expect(res.shape).toEqual([1, 2]); - expect(res.dtype).toBe('float32'); - expectArraysClose(await res.data(), [4 / 3, 1]); - }); - - it('axis=1 in 2D array', async () => { - const a = tf.tensor2d([1, 2, 3, 0, 0, 1], [3, 2]); - const res = tf.mean(a, [1]); - - expect(res.dtype).toBe('float32'); - expect(res.shape).toEqual([3]); - expectArraysClose(await res.data(), [1.5, 1.5, 0.5]); - }); - - it('axis = -1 in 2D array', async () => { - const a = tf.tensor2d([1, 2, 3, 0, 0, 1], [3, 2]); - const res = tf.mean(a, [-1]); - - expect(res.dtype).toBe('float32'); - expect(res.shape).toEqual([3]); - expectArraysClose(await res.data(), [1.5, 1.5, 0.5]); - }); - - it('2D, axis=1 provided as number', async () => { - const a = tf.tensor2d([1, 2, 3, 0, 0, 1], [2, 3]); - const res = tf.mean(a, 1); - - expect(res.shape).toEqual([2]); - expect(res.dtype).toBe('float32'); - expectArraysClose(await res.data(), [2, 1 / 3]); - }); - - it('axis=0,1 in 2D array', async () => { - const a = tf.tensor2d([1, 2, 3, 0, 0, 1], [3, 2]); - const res = tf.mean(a, [0, 1]); - - expect(res.shape).toEqual([]); - expect(res.dtype).toBe('float32'); - expectArraysClose(await res.data(), [7 / 6]); - }); - - it('gradients', async () => { - const a = tf.tensor2d([1, 2, 3, 0, 0, 1], [3, 2]); - const dy = tf.scalar(1.5); - - const da = tf.grad(a => a.mean())(a, dy); - const dyVal = await dy.array(); - expect(da.shape).toEqual(a.shape); - expectArraysClose(await da.data(), [ - dyVal / a.size, dyVal / a.size, dyVal / a.size, dyVal / a.size, - dyVal / a.size, dyVal / a.size - ]); - }); - - it('gradient with clones', async () => { - const a = tf.tensor2d([1, 2, 3, 0, 0, 1], [3, 2]); - const dy = tf.scalar(1.5); - - const da = tf.grad(a => a.clone().mean().clone())(a, dy); - const dyVal = await dy.array(); - expect(da.shape).toEqual(a.shape); - expectArraysClose(await da.data(), [ - dyVal / a.size, dyVal / a.size, dyVal / a.size, dyVal / a.size, - dyVal / a.size, dyVal / a.size - ]); - }); - - it('gradients throws for defined axis', () => { - const a = tf.tensor2d([1, 2, 3, 0, 0, 1], [3, 2]); - const dy = tf.scalar(1.5); - - expect(() => tf.grad(a => a.mean(1))(a, dy)).toThrowError(); - }); - - it('throws when passed a non-tensor', () => { - expect(() => tf.mean({} as tf.Tensor)) - .toThrowError(/Argument 'x' passed to 'mean' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const r = tf.mean([[1, 2, 3], [0, 0, 1]]); - - expect(r.dtype).toBe('float32'); - expectArraysClose(await r.data(), 7 / 6); - }); - - it('throws error for string tensor', () => { - expect(() => tf.mean(['a'])) - .toThrowError(/Argument 'x' passed to 'mean' must be numeric tensor/); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/meshgrid.ts b/tfjs-master/tfjs-core/src/ops/meshgrid.ts deleted file mode 100644 index 4603527b4..000000000 --- a/tfjs-master/tfjs-core/src/ops/meshgrid.ts +++ /dev/null @@ -1,93 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {matMul} from './mat_mul'; -import {ones} from './ones'; -import {reshape} from './reshape'; -import {Tensor} from '../tensor'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; -import {sizeFromShape} from '../util_base'; - -/** - * Broadcasts parameters for evaluation on an N-D grid. - * - * Given N one-dimensional coordinate arrays `*args`, returns a list `outputs` - * of N-D coordinate arrays for evaluating expressions on an N-D grid. - * - * Notes: - * `meshgrid` supports cartesian ('xy') and matrix ('ij') indexing conventions. - * When the `indexing` argument is set to 'xy' (the default), the broadcasting - * instructions for the first two dimensions are swapped. - * Examples: - * Calling `const [X, Y] = meshgrid(x, y)` with the tensors - * - * ```javascript - * const x = [1, 2, 3]; - * const y = [4, 5, 6]; - * const [X, Y] = tf.meshgrid(x, y); - * // X = [[1, 2, 3], - * // [1, 2, 3], - * // [1, 2, 3]] - * // Y = [[4, 4, 4], - * // [5, 5, 5], - * // [6, 6, 6]] - * ``` - * - * @param x Tensor with rank geq 1. - * @param y Tensor with rank geq 1. - * @param indexing - * - * @doc {heading: 'Operations', subheading: 'Slicing and Joining'} - */ -export function meshgrid( - x?: T|TensorLike, y?: T|TensorLike, {indexing = 'xy'} = {}): T[] { - if (indexing !== 'xy' && indexing !== 'ij') { - throw new TypeError( - `${indexing} is not a valid third argument to meshgrid`); - } - if (x === undefined) { - return []; - } - let $x = convertToTensor( - x, 'x', 'meshgrid', x instanceof Tensor ? x.dtype : 'float32'); - - if (y === undefined) { - return [$x]; - } - let $y = convertToTensor( - y, 'y', 'meshgrid', y instanceof Tensor ? y.dtype : 'float32'); - - const w = sizeFromShape($x.shape); - const h = sizeFromShape($y.shape); - - if (indexing === 'xy') { - $x = reshape($x, [1, -1]) as T; - $y = reshape($y, [-1, 1]) as T; - return [ - matMul(ones([h, 1], $x.dtype), $x), - matMul($y, ones([1, w], $y.dtype)), - ]; - } - - $x = reshape($x, [-1, 1]) as T; - $y = reshape($y, [1, -1]) as T; - return [ - matMul($x, ones([1, h], $x.dtype)), - matMul(ones([w, 1], $y.dtype), $y), - ]; -} diff --git a/tfjs-master/tfjs-core/src/ops/meshgrid_test.ts b/tfjs-master/tfjs-core/src/ops/meshgrid_test.ts deleted file mode 100644 index 50f6b2793..000000000 --- a/tfjs-master/tfjs-core/src/ops/meshgrid_test.ts +++ /dev/null @@ -1,121 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF {} KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {Tensor} from '../tensor'; -import {expectArraysEqual, expectArraysClose} from '../test_util'; - -describeWithFlags('no input', ALL_ENVS, () => { - it('Should return an empty tensor ', async () => { - expect(tf.meshgrid()).toEqual([]); - }); -}); - -describeWithFlags('single input', ALL_ENVS, () => { - it('Should return a tensor with the same data', async () => { - const x = [1, 2, 3, 4]; - const [got] = tf.meshgrid(x); - - expectArraysEqual(await got.data(), x); - }); -}); - -describeWithFlags('simple inputs', ALL_ENVS, () => { - it('Should handle the simple 2D case', async () => { - const x = [1, 2, 3]; - const y = [4, 5, 6, 7]; - const [X, Y] = tf.meshgrid(x, y); - - // 'close' instead of 'equal' because of matmul precision - // in certain backends (WebGL). - expectArraysClose( - await X.data(), [[1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3]]); - expectArraysClose( - await Y.data(), [[4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7]]); - }); - - it('Should support \'ij\' indexing', async () => { - const x = [1, 2, 3]; - const y = [4, 5, 6, 7]; - const [X, Y] = tf.meshgrid(x, y, {indexing: 'ij'}); - - // 'close' instead of 'equal' because of matmul precision - // in certain backends (WebGL). - expectArraysClose( - await X.data(), [[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3]]); - expectArraysClose( - await Y.data(), [[4, 5, 6, 7], [4, 5, 6, 7], [4, 5, 6, 7]]); - }); -}); - -describeWithFlags('higher dimensional input', ALL_ENVS, () => { - it('Should flatten higher dimensional', async () => { - const x = [1, 2, 3]; - const a = [[1, 1], [1, 1]]; - - const [X, A] = tf.meshgrid(x, a); - - // 'close' instead of 'equal' because of matmul precision - // in certain backends (WebGL). - expectArraysClose( - await X.data(), [[1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3]]); - expectArraysClose( - await A.data(), [[1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1]]); - }); -}); - -describeWithFlags('dtypes', ALL_ENVS, () => { - it('Should use float32 for arrays of numbers', async () => { - const x = [1, 2]; - const y = [3, 4]; - const [X, Y] = tf.meshgrid(x, y); - - expect(X.dtype).toBe('float32'); - expect(Y.dtype).toBe('float32'); - }); - - it('Should use the input tensor dtype', async () => { - const x = tf.tensor1d([1, 2], 'int32'); - const y = tf.tensor1d([3, 4], 'float32'); - const [X, Y] = tf.meshgrid(x, y); - - expect(X.dtype).toBe('int32'); - expect(Y.dtype).toBe('float32'); - }); -}); - -describeWithFlags('scalars', ALL_ENVS, () => { - it('Should treat them as 1D tensors', async () => { - const [X] = tf.meshgrid(0); - // 'close' instead of 'equal' because of matmul precision - // in certain backends (WebGL). - expectArraysClose(await X.data(), [0]); - - const [Y, Z] = tf.meshgrid([0], 1); - expectArraysClose(await Y.data(), [[0]]); - expectArraysClose(await Z.data(), [[1]]); - }); -}); - -describeWithFlags('invalid arguments', ALL_ENVS, () => { - it('Should throw an Error', () => { - expect(() => tf.meshgrid((() => {}) as unknown as Tensor)).toThrow(); - expect(() => tf.meshgrid([1], (() => {}) as unknown as Tensor)).toThrow(); - expect(() => tf.meshgrid([1], [2], {indexing: 'foobar'})).toThrow(); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/min.ts b/tfjs-master/tfjs-core/src/ops/min.ts deleted file mode 100644 index 378483f95..000000000 --- a/tfjs-master/tfjs-core/src/ops/min.ts +++ /dev/null @@ -1,69 +0,0 @@ -/** - * @license - * Copyright 2020 Google Inc. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {ENGINE} from '../engine'; -import {Min, MinAttrs, MinInputs} from '../kernel_names'; -import {NamedAttrMap} from '../kernel_registry'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -import {op} from './operation'; - -/** - * Computes the minimum value from the input. - * - * Reduces the input along the dimensions given in `axes`. Unless `keepDims` - * is true, the rank of the array is reduced by 1 for each entry in `axes`. - * If `keepDims` is true, the reduced dimensions are retained with length 1. - * If `axes` has no entries, all dimensions are reduced, and an array with a - * single element is returned. - * - * ```js - * const x = tf.tensor1d([1, 2, 3]); - * - * x.min().print(); // or tf.min(x) - * ``` - * - * ```js - * const x = tf.tensor2d([1, 2, 3, 4], [2, 2]); - * - * const axis = 1; - * x.min(axis).print(); // or tf.min(x, axis) - * ``` - * - * @param x The input Tensor. - * @param axis The dimension(s) to reduce. By default it reduces - * all dimensions. - * @param keepDims If true, retains reduced dimensions with size 1. - * - * @doc {heading: 'Operations', subheading: 'Reduction'} - */ -function min_( - x: Tensor|TensorLike, axis: number|number[] = null, keepDims = false): T { - const $x = convertToTensor(x, 'x', 'min'); - - const inputs: MinInputs = {x: $x}; - const attrs: MinAttrs = {axis, keepDims}; - - // tslint:disable-next-line: no-unnecessary-type-assertion - return ENGINE.runKernel( - Min, inputs as unknown as NamedTensorMap, - attrs as unknown as NamedAttrMap) as T; -} - -export const min = /* @__PURE__ */ op({min_}); diff --git a/tfjs-master/tfjs-core/src/ops/min_test.ts b/tfjs-master/tfjs-core/src/ops/min_test.ts deleted file mode 100644 index ae5ae01ab..000000000 --- a/tfjs-master/tfjs-core/src/ops/min_test.ts +++ /dev/null @@ -1,251 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; -import {backend} from '../index'; - -describeWithFlags('min', ALL_ENVS, () => { - it('Tensor1D', async () => { - const a = tf.tensor1d([3, -1, 0, 100, -7, 2]); - expectArraysClose(await tf.min(a).data(), -7); - }); - - it('return NaNs', async () => { - const a = tf.tensor1d([3, NaN, 2]); - expectArraysClose(await tf.min(a).data(), NaN); - }); - - it('2D', async () => { - const a = tf.tensor2d([3, -1, 0, 100, -7, 2], [2, 3]); - expectArraysClose(await tf.min(a).data(), -7); - }); - - it('2D axis=[0,1]', async () => { - const a = tf.tensor2d([3, -1, 0, 100, -7, 2], [2, 3]); - expectArraysClose(await tf.min(a, [0, 1]).data(), -7); - }); - - it('2D, axis=0', async () => { - const a = tf.tensor2d([3, -1, 0, 100, -7, 2], [2, 3]); - const r = tf.min(a, 0); - - expect(r.shape).toEqual([3]); - expectArraysClose(await r.data(), [3, -7, 0]); - }); - - it('2D, axis=0, keepDims', async () => { - const a = tf.tensor2d([3, -1, 0, 100, -7, 2], [2, 3]); - const r = tf.min(a, 0, true /* keepDims */); - - expect(r.shape).toEqual([1, 3]); - expectArraysClose(await r.data(), [3, -7, 0]); - }); - - it('2D, axis=1 provided as a number', async () => { - const a = tf.tensor2d([3, 2, 5, 100, -7, 2], [2, 3]); - const r = tf.min(a, 1); - expectArraysClose(await r.data(), [2, -7]); - }); - - it('2D, axis = -1 provided as a number', async () => { - const a = tf.tensor2d([3, 2, 5, 100, -7, 2], [2, 3]); - const r = tf.min(a, -1); - expectArraysClose(await r.data(), [2, -7]); - }); - - it('2D, axis=[1]', async () => { - const a = tf.tensor2d([3, 2, 5, 100, -7, 2], [2, 3]); - const r = tf.min(a, [1]); - expectArraysClose(await r.data(), [2, -7]); - }); - - it('axis permutation does not change input', async () => { - const input = tf.tensor2d([3, -1, 0, 100, -7, 2], [2, 3]); - const inputDataBefore = await input.data(); - - tf.min(input, [1, 0]); - - const inputDataAfter = await input.data(); - expectArraysClose(inputDataBefore, inputDataAfter); - }); - - it('throws when passed a non-tensor', () => { - expect(() => tf.min({} as tf.Tensor)) - .toThrowError(/Argument 'x' passed to 'min' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - expectArraysClose(await tf.min([3, -1, 0, 100, -7, 2]).data(), -7); - }); - - it('accpets int32 input', async () => { - if (backend() && backend().floatPrecision() === 32) { - // TODO: Use skip() instead when it is implemented - const a = tf.tensor1d([12345678, 12345679], 'int32'); - expect(a.dtype).toEqual('int32'); - expectArraysClose(await tf.min(a).data(), 12345678); - } - }); - - it('min gradient: Scalar', async () => { - const x = tf.scalar(42); - const dy = tf.scalar(-1); - const gradients = tf.grad(v => tf.min(v))(x, dy); - expectArraysClose(await gradients.data(), -1); - }); - - it('gradient with clones', async () => { - const x = tf.scalar(42); - const dy = tf.scalar(-1); - const gradients = tf.grad(v => tf.min(v.clone()).clone())(x, dy); - expectArraysClose(await gradients.data(), -1); - }); - - it('min gradient: 1D, ties', async () => { - const x = tf.tensor1d([-1, -3, -7, -7]); - const dy = tf.scalar(-1); - const gradients = tf.grad(v => tf.min(v))(x, dy); - expectArraysClose(await gradients.data(), [0, 0, -1, -1]); - }); - - it('min gradient: 2D, axes=-1, keepDims=false', async () => { - const x = tf.tensor2d([[-0, -20, -10], [10, 30, 20]]); - const dy = tf.tensor1d([-1, -1]); - const axis = -1; - const gradients = tf.grad(v => tf.min(v, axis))(x, dy); - expectArraysClose(await gradients.data(), [0, -1, 0, -1, 0, 0]); - expect(gradients.shape).toEqual([2, 3]); - }); - - it('min gradient: ties, 2D, axes=-1, keepDims=false', async () => { - const x = tf.tensor2d([[0, -20, -20], [10, 30, 10]]); - const dy = tf.tensor1d([-1, -1]); - const axis = -1; - const gradients = tf.grad(v => tf.min(v, axis))(x, dy); - expectArraysClose(await gradients.data(), [0, -1, -1, -1, 0, -1]); - expect(gradients.shape).toEqual([2, 3]); - }); - - it('min gradient: 2D, axes=0, keepDims=false', async () => { - const x = tf.tensor2d([[0, 20, 10], [-10, -30, 20]]); - const dy = tf.tensor1d([-1, -1, -1]); - const axis = 0; - const gradients = tf.grad(v => tf.max(v, axis))(x, dy); - expectArraysClose(await gradients.data(), [-1, -1, 0, 0, 0, -1]); - expect(gradients.shape).toEqual([2, 3]); - }); - - it('min gradient: 2D, axes=-1, keepDims=true', async () => { - const x = tf.tensor2d([[0, -20, -10], [10, 30, 20]]); - const dy = tf.tensor2d([[-1], [-1]]); - const axis = -1; - const keepDims = true; - const gradients = tf.grad(v => tf.min(v, axis, keepDims))(x, dy); - expectArraysClose(await gradients.data(), [0, -1, 0, -1, 0, 0]); - expect(gradients.shape).toEqual([2, 3]); - }); - - it('min gradient: 2D, axes=0, keepDims=true', async () => { - const x = tf.tensor2d([[0, -20, -10], [10, 30, -20]]); - const dy = tf.tensor2d([[-1, -1, -1]]); - const axis = 0; - const keepDims = true; - const gradients = tf.grad(v => tf.min(v, axis, keepDims))(x, dy); - expectArraysClose(await gradients.data(), [-1, -1, 0, 0, 0, -1]); - expect(gradients.shape).toEqual([2, 3]); - }); - - it('max gradient: 3D, axis=1 keepDims=false', async () => { - const x = tf.ones([2, 1, 250]); - const axis = 1; - const gradients = tf.grad(v => tf.min(v, axis))(x); - expect(gradients.shape).toEqual(x.shape); - }); - - it('min gradient: 3D, axes=[1, 2], keepDims=false', async () => { - const x = tf.tensor3d([[[0, -20], [-10, -15]], [[10, 30], [20, 15]]]); - const dy = tf.tensor1d([-1, -1]); - const axis = [1, 2]; - const gradients = tf.grad(v => tf.min(v, axis))(x, dy); - expectArraysClose(await gradients.data(), [0, -1, 0, 0, -1, 0, 0, 0]); - expect(gradients.shape).toEqual([2, 2, 2]); - }); - - it('min gradient: ties, 3D, axes=[1, 2], keepDims=false', async () => { - const x = tf.tensor3d([[[0, -20], [-20, -20]], [[10, 30], [10, 15]]]); - const dy = tf.tensor1d([-1, -1]); - const axis = [1, 2]; - const gradients = tf.grad(v => tf.min(v, axis))(x, dy); - expectArraysClose(await gradients.data(), [0, -1, -1, -1, -1, 0, -1, 0]); - expect(gradients.shape).toEqual([2, 2, 2]); - }); - - it('min gradient: 3D, axes=2, keepDims=false', async () => { - const x = tf.tensor3d([[[0, -20], [-10, -15]], [[10, 30], [20, 15]]]); - const dy = tf.tensor2d([[-1, -1], [-1, -1]]); - const axis = 2; - const gradients = tf.grad(v => tf.min(v, axis))(x, dy); - expectArraysClose(await gradients.data(), [0, -1, 0, -1, -1, 0, 0, -1]); - expect(gradients.shape).toEqual([2, 2, 2]); - }); - - it('min gradient: 3D, axes=2, keepDims=true', async () => { - const x = tf.tensor3d([[[0, -20], [-10, -15]], [[10, 30], [20, 15]]]); - const dy = tf.tensor3d([[[-1], [-1]], [[-1], [-1]]]); - const axis = 2; - const keepDims = true; - const gradients = tf.grad(v => tf.min(v, axis, keepDims))(x, dy); - expectArraysClose(await gradients.data(), [0, -1, 0, -1, -1, 0, 0, -1]); - expect(gradients.shape).toEqual([2, 2, 2]); - }); - - it('min gradient: ties, 4D, axes=[1, 2, 3], keepDims=false', async () => { - const x = tf.tensor4d([ - [[[0, -20], [-20, -20]], [[10, 30], [10, 30]]], - [[[0, 20], [20, 20]], [[-10, -30], [-10, -30]]] - ]); - const dy = tf.tensor1d([-1, -1]); - const axis = [1, 2, 3]; - const gradients = tf.grad(v => tf.min(v, axis))(x, dy); - expectArraysClose( - await gradients.data(), - [0, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, -1]); - expect(gradients.shape).toEqual([2, 2, 2, 2]); - }); - - it('min gradient: ties, 4D, axes=[2, 3], keepDims=true', async () => { - const x = tf.tensor4d([ - [[[0, -20], [-20, -20]], [[10, 30], [10, 30]]], - [[[0, 20], [20, 20]], [[-10, -30], [-10, -30]]] - ]); - const dy = tf.tensor4d([[[[-1]], [[-2]]], [[[-3]], [[-4]]]]); - const axis = [2, 3]; - const keepDims = true; - const gradients = tf.grad(v => tf.min(v, axis, keepDims))(x, dy); - expectArraysClose( - await gradients.data(), - [0, -1, -1, -1, -2, 0, -2, 0, -3, 0, 0, 0, 0, -4, 0, -4]); - expect(gradients.shape).toEqual([2, 2, 2, 2]); - }); - - it('throws error for string tensor', () => { - expect(() => tf.min(['a'])) - .toThrowError(/Argument 'x' passed to 'min' must be numeric tensor/); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/minimum.ts b/tfjs-master/tfjs-core/src/ops/minimum.ts deleted file mode 100644 index 4efc40edf..000000000 --- a/tfjs-master/tfjs-core/src/ops/minimum.ts +++ /dev/null @@ -1,75 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {Minimum, MinimumInputs} from '../kernel_names'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {makeTypesMatch} from '../tensor_util'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -import {assertAndGetBroadcastShape} from './broadcast_util'; -import {cast} from './cast'; -import {op} from './operation'; - -/** - * Returns the min of a and b (`a < b ? a : b`) element-wise. - * Supports broadcasting. - * - * We also expose `minimumStrict` which has the same signature as this op and - * asserts that `a` and `b` are the same shape (does not broadcast). - * - * ```js - * const a = tf.tensor1d([1, 4, 3, 16]); - * const b = tf.tensor1d([1, 2, 9, 4]); - * - * a.minimum(b).print(); // or tf.minimum(a, b) - * ``` - * - * ```js - * // Broadcast minimum a with b. - * const a = tf.tensor1d([2, 4, 6, 8]); - * const b = tf.scalar(5); - * - * a.minimum(b).print(); // or tf.minimum(a, b) - * ``` - * - * @param a The first tensor. - * @param b The second tensor. Must have the same type as `a`. - * - * @doc {heading: 'Operations', subheading: 'Arithmetic'} - */ -function minimum_( - a: Tensor|TensorLike, b: Tensor|TensorLike): T { - let $a = convertToTensor(a, 'a', 'minimum'); - let $b = convertToTensor(b, 'b', 'minimum'); - [$a, $b] = makeTypesMatch($a, $b); - - if ($a.dtype === 'bool') { - $a = cast($a, 'int32'); - $b = cast($b, 'int32'); - } - - assertAndGetBroadcastShape($a.shape, $b.shape); - - const inputs: MinimumInputs = {a: $a, b: $b}; - - return ENGINE.runKernel(Minimum, inputs as unknown as NamedTensorMap); -} - -export const minimum = /* @__PURE__ */ op({minimum_}); diff --git a/tfjs-master/tfjs-core/src/ops/mirror_pad.ts b/tfjs-master/tfjs-core/src/ops/mirror_pad.ts deleted file mode 100644 index 8b4db2b54..000000000 --- a/tfjs-master/tfjs-core/src/ops/mirror_pad.ts +++ /dev/null @@ -1,92 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {MirrorPad, MirrorPadAttrs, MirrorPadInputs} from '../kernel_names'; -import {NamedAttrMap} from '../kernel_registry'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; -import * as util from '../util'; - -import {op} from './operation'; - -/** - * Pads a `tf.Tensor` using mirror padding. - * - * This operation implements the `REFLECT` and `SYMMETRIC` modes of pad. - * - * ```js - * const x = tf.range(0, 9).reshape([1, 1, 3, 3]); - * x.mirrorPad([[0, 0], [0, 0], [2, 2], [2, 2]], 'reflect').print(); - * ``` - * @param x The tensor to pad. - * @param paddings An array of length `R` (the rank of the tensor), where - * each element is a length-2 tuple of ints `[padBefore, padAfter]`, - * specifying how much to pad along each dimension of the tensor. - * In "reflect" mode, the padded regions do not include the borders, - * while in "symmetric" mode the padded regions do include the borders. - * For example, if the input is `[1, 2, 3]` and paddings is `[0, 2]`, - * then the output is `[1, 2, 3, 2, 1]` in "reflect" mode, and - * `[1, 2, 3, 3, 2]` in "symmetric" mode. - * If `mode` is "reflect" then both `paddings[D, 0]` and `paddings[D, 1]` - * must be no greater than `x.shape[D] - 1`. If mode is "symmetric" - * then both `paddings[D, 0]` and `paddings[D, 1]` must be no greater than - * `x.shape[D]` - * @param mode String to specify padding mode. Can be `'reflect' | 'symmetric'` - */ -/** @doc {heading: 'Tensors', subheading: 'Transformations'} */ -function mirrorPad_( - x: T|TensorLike, paddings: Array<[number, number]>, - mode: 'reflect'|'symmetric'): T { - util.assert( - mode === 'reflect' || mode === 'symmetric', - () => `Invalid mode. Mode must be either reflect or symmetric. ` + - `Got ${mode}.`); - - const $x = convertToTensor(x, 'x', 'mirrorPad'); - if ($x.rank === 0) { - throw new Error( - 'mirrorPad(scalar) is not defined. ' + - 'Pass non-scalar to mirrorPad'); - } - util.assert( - paddings.length === $x.rank, - () => `Padding doesn't match input. Must be ${$x.rank}. ` + - `Got ${paddings.length}.`); - const shapeOffset = mode === 'reflect' ? 1 : 0; - for (let i = 0; i < $x.rank; i++) { - util.assert( - paddings[i].length === 2, - () => `Invalid number of paddings. Must be length of 2 each.`); - util.assert( - paddings[i][0] >= 0 && paddings[i][0] <= $x.shape[i] - shapeOffset && - paddings[i][1] >= 0 && paddings[i][1] <= $x.shape[i] - shapeOffset, - () => `Padding in dimension ${i} cannot be greater than or equal ` + - `to ${$x.shape[i] - shapeOffset} or less than 0 for input of ` + - `shape ${$x.shape}`); - } - - const attrs: MirrorPadAttrs = {paddings, mode}; - const inputs: MirrorPadInputs = {x: $x}; - return ENGINE.runKernel( - MirrorPad, inputs as unknown as NamedTensorMap, - attrs as unknown as NamedAttrMap); -} - -export const mirrorPad = /* @__PURE__ */ op({mirrorPad_}); diff --git a/tfjs-master/tfjs-core/src/ops/mirror_pad_test.ts b/tfjs-master/tfjs-core/src/ops/mirror_pad_test.ts deleted file mode 100644 index b0e4ac9c2..000000000 --- a/tfjs-master/tfjs-core/src/ops/mirror_pad_test.ts +++ /dev/null @@ -1,195 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('mirrorPad', ALL_ENVS, () => { - it('MirrorPad tensor1d', async () => { - const a = tf.tensor1d([1, 2, 3], 'int32'); - let b = tf.mirrorPad(a, [[2, 2]], 'reflect'); - expectArraysClose(await b.data(), [3, 2, 1, 2, 3, 2, 1]); - expect(b.shape).toEqual([7]); - - b = tf.mirrorPad(a, [[2, 2]], 'symmetric'); - expectArraysClose(await b.data(), [2, 1, 1, 2, 3, 3, 2]); - expect(b.shape).toEqual([7]); - }); - - it('MirrorPad tensor2d', async () => { - const a = tf.tensor2d([[1, 2, 3], [4, 5, 6]], [2, 3], 'int32'); - let b = tf.mirrorPad(a, [[1, 1], [1, 1]], 'reflect'); - // 5, 4, 5, 6, 5 - // 2, 1, 2, 3, 2 - // 5, 4, 5, 6, 5 - // 2, 1, 2, 3, 2 - expectArraysClose( - await b.data(), - [5, 4, 5, 6, 5, 2, 1, 2, 3, 2, 5, 4, 5, 6, 5, 2, 1, 2, 3, 2]); - expect(b.shape).toEqual([4, 5]); - - b = tf.mirrorPad(a, [[1, 1], [1, 1]], 'symmetric'); - // 1, 1, 2, 3, 3 - // 1, 1, 2, 3, 3 - // 4, 4, 5, 6, 6 - // 4, 4, 5, 6, 6 - expectArraysClose( - await b.data(), - [1, 1, 2, 3, 3, 1, 1, 2, 3, 3, 4, 4, 5, 6, 6, 4, 4, 5, 6, 6]); - expect(b.shape).toEqual([4, 5]); - }); - - it('MirrorPad tensor3d', async () => { - const a = tf.tensor3d([[[1, 2]], [[3, 4]]], [2, 1, 2], 'int32'); - let b = tf.mirrorPad(a, [[1, 1], [0, 0], [1, 1]], 'reflect'); - // 4, 3, 4, 3 - - // 2, 1, 2, 1 - - // 4, 3, 4, 3 - - // 2, 1, 2, 1 - expectArraysClose( - await b.data(), [4, 3, 4, 3, 2, 1, 2, 1, 4, 3, 4, 3, 2, 1, 2, 1]); - expect(b.shape).toEqual([4, 1, 4]); - - b = tf.mirrorPad(a, [[1, 1], [0, 0], [1, 1]], 'symmetric'); - // 1, 1, 2, 2 - - // 1, 1, 2, 2 - - // 3, 3, 4, 4 - - // 3, 3, 4, 4 - expectArraysClose( - await b.data(), [1, 1, 2, 2, 1, 1, 2, 2, 3, 3, 4, 4, 3, 3, 4, 4]); - expect(b.shape).toEqual([4, 1, 4]); - }); - - it('MirrorPad tensor4d', async () => { - const a = tf.tensor4d([[[[1, 2, 3, 4]]]], [1, 1, 1, 4], 'int32'); - let b = tf.mirrorPad(a, [[0, 0], [0, 0], [0, 0], [1, 1]], 'reflect'); - let expected = tf.tensor4d([[[[2, 1, 2, 3, 4, 3]]]], [1, 1, 1, 6], 'int32'); - expectArraysClose(await b.data(), await expected.data()); - expect(b.dtype).toBe('int32'); - expect(b.shape).toEqual([1, 1, 1, 6]); - - b = tf.mirrorPad(a, [[0, 0], [0, 0], [0, 0], [1, 1]], 'symmetric'); - expected = tf.tensor4d([[[[1, 1, 2, 3, 4, 4]]]], [1, 1, 1, 6], 'int32'); - expectArraysClose(await b.data(), await expected.data()); - expect(b.shape).toEqual([1, 1, 1, 6]); - }); - - it('throws when passed a non-tensor', () => { - expect(() => tf.mirrorPad({} as tf.Tensor, [[0, 0]], 'reflect')) - .toThrowError(/Argument 'x' passed to 'mirrorPad' must be a Tensor/); - }); - - it('does not leak memory', () => { - const a = tf.tensor4d([[[[1, 2, 3, 4]]]], [1, 1, 1, 4], 'int32'); - // The first call to mirrorPad may create and keeps internal - // singleton tensors. Subsequent calls should always create exactly - // one new tensor. - tf.mirrorPad(a, [[0, 0], [0, 0], [0, 0], [1, 1]], 'reflect'); - // Count before real call. - const numTensors = tf.memory().numTensors; - tf.mirrorPad(a, [[0, 0], [0, 0], [0, 0], [1, 1]], 'reflect'); - expect(tf.memory().numTensors).toEqual(numTensors + 1); - }); - - it('accepts a tensor-like object', async () => { - const x = [[1, 2, 3], [4, 5, 6]]; - const res = tf.mirrorPad(x, [[1, 1], [1, 1]], 'reflect'); - // 5, 4, 5, 6, 5 - // 2, 1, 2, 3, 2 - // 5, 4, 5, 6, 5 - // 2, 1, 2, 3, 2 - expectArraysClose( - await res.data(), - [5, 4, 5, 6, 5, 2, 1, 2, 3, 2, 5, 4, 5, 6, 5, 2, 1, 2, 3, 2]); - expect(res.shape).toEqual([4, 5]); - }); - - it('Should handle invalid paddings', () => { - const a = tf.tensor1d([1, 2, 3, 4], 'int32'); - const f = () => { - // tslint:disable-next-line:no-any - tf.mirrorPad(a, [2, 2, 2] as any, 'reflect'); - }; - expect(f).toThrowError(); - }); - - it('Should handle paddings that are out of range', () => { - const a = tf.tensor2d([[1, 2, 3], [4, 5, 6]], [2, 3], 'int32'); - let f = () => { - // tslint:disable-next-line:no-any - tf.mirrorPad(a, [[4, 1], [1, 1]], 'reflect'); - }; - expect(f).toThrowError(); - - f = () => { - // tslint:disable-next-line:no-any - tf.mirrorPad(a, [[-1, 1], [1, 1]], 'reflect'); - }; - expect(f).toThrowError(); - - f = () => { - // tslint:disable-next-line:no-any - tf.mirrorPad(a, [[2, 1], [1, 1]], 'reflect'); - }; - expect(f).toThrowError(); - - f = () => { - // tslint:disable-next-line:no-any - tf.mirrorPad(a, [[3, 1], [1, 1]], 'symmetric'); - }; - expect(f).toThrowError(); - }); - - it('Should handle NaNs', async () => { - const a = tf.tensor2d([[1, NaN], [1, NaN]], [2, 2]); - const b = tf.mirrorPad(a, [[1, 1], [1, 1]], 'reflect'); - // NaN, 1, NaN, 1 - // NaN, 1, NaN, 1 - // NaN, 1, NaN, 1 - // NaN, 1, NaN, 1 - expectArraysClose( - await b.data(), - [NaN, 1, NaN, 1, NaN, 1, NaN, 1, NaN, 1, NaN, 1, NaN, 1, NaN, 1]); - expect(b.shape).toEqual([4, 4]); - }); - - it('grad', async () => { - const a = tf.tensor1d([1, 2, 3]); - const dy = tf.tensor1d([10, 20, 30, 40, 50, 60]); - const da = tf.grad( - (a: tf.Tensor1D) => tf.mirrorPad(a, [[2, 1]], 'reflect'))(a, dy); - expect(da.shape).toEqual([3]); - expectArraysClose(await da.data(), [30, 40, 50]); - }); - - it('gradient with clones', async () => { - const a = tf.tensor1d([1, 2, 3]); - const dy = tf.tensor1d([10, 20, 30, 40, 50, 60]); - const da = tf.grad( - (a: tf.Tensor1D) => - tf.mirrorPad(a.clone(), [[2, 1]], 'reflect').clone())(a, dy); - expect(da.shape).toEqual([3]); - expectArraysClose(await da.data(), [30, 40, 50]); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/mod.ts b/tfjs-master/tfjs-core/src/ops/mod.ts deleted file mode 100644 index 22acb8d61..000000000 --- a/tfjs-master/tfjs-core/src/ops/mod.ts +++ /dev/null @@ -1,66 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {Mod, ModInputs} from '../kernel_names'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {makeTypesMatch} from '../tensor_util'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -import {op} from './operation'; - -/** - * Returns the mod of a and b element-wise. - * `floor(x / y) * y + mod(x, y) = x` - * Supports broadcasting. - * - * We also expose `tf.modStrict` which has the same signature as this op and - * asserts that `a` and `b` are the same shape (does not broadcast). - * - * ```js - * const a = tf.tensor1d([1, 4, 3, 16]); - * const b = tf.tensor1d([1, 2, 9, 4]); - * - * a.mod(b).print(); // or tf.mod(a, b) - * ``` - * - * ```js - * // Broadcast a mod b. - * const a = tf.tensor1d([2, 4, 6, 8]); - * const b = tf.scalar(5); - * - * a.mod(b).print(); // or tf.mod(a, b) - * ``` - * - * @param a The first tensor. - * @param b The second tensor. Must have the same type as `a`. - * - * @doc {heading: 'Operations', subheading: 'Arithmetic'} - */ -function mod_(a: Tensor|TensorLike, b: Tensor|TensorLike): T { - let $a = convertToTensor(a, 'a', 'mod'); - let $b = convertToTensor(b, 'b', 'mod'); - [$a, $b] = makeTypesMatch($a, $b); - - const inputs: ModInputs = {a: $a, b: $b}; - - return ENGINE.runKernel(Mod, inputs as unknown as NamedTensorMap); -} - -export const mod = /* @__PURE__ */ op({mod_}); diff --git a/tfjs-master/tfjs-core/src/ops/moments.ts b/tfjs-master/tfjs-core/src/ops/moments.ts deleted file mode 100644 index d022626ab..000000000 --- a/tfjs-master/tfjs-core/src/ops/moments.ts +++ /dev/null @@ -1,61 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Tensor} from '../tensor'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; -import {parseAxisParam} from '../util'; - -import {expandShapeToKeepDim} from './axis_util'; -import {cast} from './cast'; -import {mean} from './mean'; -import {op} from './operation'; -import {reshape} from './reshape'; -import {square} from './square'; -import {sub} from './sub'; - -/** - * Calculates the mean and variance of `x`. The mean and variance are - * calculated by aggregating the contents of `x` across `axes`. If `x` is - * 1-D and `axes = [0]` this is just the mean and variance of a vector. - * - * @param x The input tensor. - * @param axis The dimension(s) along with to compute mean and - * variance. By default it reduces all dimensions. - * @param keepDims If true, the moments have the same dimensionality as the - * input. - * @return An object with two keys: `mean` and `variance`. - * - * @doc {heading: 'Operations', subheading: 'Normalization'} - */ -function moments_( - x: Tensor|TensorLike, axis: number|number[] = null, - keepDims = false): {mean: Tensor, variance: Tensor} { - x = convertToTensor(x, 'x', 'moments'); - const axes = parseAxisParam(axis, x.shape); - const xMean = mean(x, axes, keepDims); - let keepDimsShape = xMean.shape; - if (!keepDims) { - keepDimsShape = expandShapeToKeepDim(xMean.shape, axes); - } - const devSquared = - square(sub(cast(x, 'float32'), reshape(xMean, keepDimsShape))); - const variance = mean(devSquared, axes, keepDims); - return {mean: xMean, variance}; -} - -export const moments = /* @__PURE__ */ op({moments_}); diff --git a/tfjs-master/tfjs-core/src/ops/moments_test.ts b/tfjs-master/tfjs-core/src/ops/moments_test.ts deleted file mode 100644 index 2f6f2e334..000000000 --- a/tfjs-master/tfjs-core/src/ops/moments_test.ts +++ /dev/null @@ -1,148 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose, expectArraysEqual} from '../test_util'; - -describeWithFlags('moments', ALL_ENVS, () => { - it('basic', async () => { - const a = tf.tensor2d([1, 2, 3, 0, 0, 1], [3, 2]); - const {mean, variance} = tf.moments(a); - - expect(mean.dtype).toBe('float32'); - expect(variance.dtype).toBe('float32'); - expectArraysClose(await mean.data(), 7 / 6); - expectArraysClose(await variance.data(), 1.1389); - }); - - it('propagates NaNs', async () => { - const a = tf.tensor2d([1, 2, 3, NaN, 0, 1], [3, 2]); - const {mean, variance} = tf.moments(a); - - expect(mean.dtype).toBe('float32'); - expect(variance.dtype).toBe('float32'); - expectArraysEqual(await mean.data(), NaN); - expectArraysEqual(await variance.data(), NaN); - }); - - it('moments(int32) => float32', async () => { - const a = tf.tensor1d([1, 5, 7, 3], 'int32'); - const {mean, variance} = tf.moments(a); - - expect(mean.dtype).toBe('float32'); - expect(variance.dtype).toBe('float32'); - expectArraysClose(await mean.data(), 4); - expectArraysClose(await variance.data(), 5); - }); - - it('moments(bool) => float32', async () => { - const a = tf.tensor1d([true, false, false, true, true], 'bool'); - const {mean, variance} = tf.moments(a); - - expect(mean.dtype).toBe('float32'); - expect(variance.dtype).toBe('float32'); - expectArraysClose(await mean.data(), 3 / 5); - expectArraysClose(await variance.data(), 0.23999998); - }); - - it('2D array with keep dim', async () => { - const a = tf.tensor2d([1, 2, 3, 0, 0, 1], [3, 2]); - const {mean, variance} = tf.moments(a, null, true /* keepDims */); - - expect(mean.shape).toEqual([1, 1]); - expect(mean.dtype).toBe('float32'); - expect(variance.shape).toEqual([1, 1]); - expect(variance.dtype).toBe('float32'); - expectArraysClose(await mean.data(), [7 / 6]); - expectArraysClose(await variance.data(), [1.138889]); - }); - - it('axis=0 in 2D array', async () => { - const a = tf.tensor2d([1, 2, 3, 0, 0, 1], [3, 2]); - const {mean, variance} = tf.moments(a, [0]); - - expect(mean.shape).toEqual([2]); - expect(mean.dtype).toBe('float32'); - expect(variance.shape).toEqual([2]); - expect(variance.dtype).toBe('float32'); - expectArraysClose(await mean.data(), [4 / 3, 1]); - expectArraysClose(await variance.data(), [1.556, 2 / 3]); - }); - - it('axis=1 in 2D array', async () => { - const a = tf.tensor2d([1, 2, 3, 0, 0, 1], [3, 2]); - const {mean, variance} = tf.moments(a, [1]); - - expect(mean.dtype).toBe('float32'); - expect(mean.shape).toEqual([3]); - expect(variance.dtype).toBe('float32'); - expect(variance.shape).toEqual([3]); - expectArraysClose(await mean.data(), [1.5, 1.5, 0.5]); - expectArraysClose(await variance.data(), [0.25, 2.25, 0.25]); - }); - - it('2D, axis=1 provided as number', async () => { - const a = tf.tensor2d([1, 2, 3, 0, 0, 1], [2, 3]); - const {mean, variance} = tf.moments(a, 1); - - expect(mean.shape).toEqual([2]); - expect(mean.dtype).toBe('float32'); - expect(variance.shape).toEqual([2]); - expect(variance.dtype).toBe('float32'); - expectArraysClose(await mean.data(), [2, 1 / 3]); - expectArraysClose(await variance.data(), [2 / 3, 0.222]); - }); - - it('2D, axis=-1 provided as number', async () => { - const a = tf.tensor2d([1, 2, 3, 0, 0, 1], [2, 3]); - const {mean, variance} = tf.moments(a, -1); - - expect(mean.shape).toEqual([2]); - expect(mean.dtype).toBe('float32'); - expect(variance.shape).toEqual([2]); - expect(variance.dtype).toBe('float32'); - expectArraysClose(await mean.data(), [2, 1 / 3]); - expectArraysClose(await variance.data(), [2 / 3, 0.222]); - }); - - it('axis=0,1 in 2D array', async () => { - const a = tf.tensor2d([1, 2, 3, 0, 0, 1], [3, 2]); - const {mean, variance} = tf.moments(a, [0, 1]); - - expect(mean.shape).toEqual([]); - expect(mean.dtype).toBe('float32'); - expect(variance.shape).toEqual([]); - expect(variance.dtype).toBe('float32'); - expectArraysClose(await mean.data(), [7 / 6]); - expectArraysClose(await variance.data(), [1.1389]); - }); - - it('throws when passed a non-tensor', () => { - expect(() => tf.moments({} as tf.Tensor)) - .toThrowError(/Argument 'x' passed to 'moments' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const {mean, variance} = tf.moments([1, 2, 3, 0, 0, 1]); - - expect(mean.dtype).toBe('float32'); - expect(variance.dtype).toBe('float32'); - expectArraysClose(await mean.data(), 7 / 6); - expectArraysClose(await variance.data(), 1.1389); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/moving_average.ts b/tfjs-master/tfjs-core/src/ops/moving_average.ts deleted file mode 100644 index 6852ca460..000000000 --- a/tfjs-master/tfjs-core/src/ops/moving_average.ts +++ /dev/null @@ -1,84 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Scalar, Tensor} from '../tensor'; -import {assertTypesMatch} from '../tensor_util'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; -import * as util from '../util'; - -import {add} from './add'; -import {div} from './div'; -import {mul} from './mul'; -import {op} from './operation'; -import {pow} from './pow'; -import {scalar} from './scalar'; -import {sub} from './sub'; - -/** - * Compute the moving average of a variable. - * - * Without zeroDebias, the moving average operation is defined by: - * `v += delta` - * where - * `delta = (1 - decay) * (x - v)` - * - * With zeroDebias (default), the `delta` term is scaled to debias the - * effect of the (assumed) zero-initialization of `v`. - * `delta /= (1 - decay ^ step)` - * - * For more details on the zero-debiasing algorithm, see: - * https://arxiv.org/abs/1412.6980 - * - * Note that this function is completely stateless and does not keep track of - * step count. The step count needs to be maintained by the caller and passed - * in as `step`. - * - * @param v The current moving average value. - * @param x New input value, must have the same shape and dtype as `v`. - * @param decay The decay factor. Typical values are 0.95 and 0.99. - * @param step Step count. - * @param zeroDebias: Whether zeroDebias is to be performed (default: `true`). - * @returns The new moving average value. - * - * @doc {heading: 'Operations', subheading: 'Moving Average'} - */ -function movingAverage_( - v: T|TensorLike, x: T|TensorLike, decay: number|Scalar, - step?: number|Scalar, zeroDebias = true): T { - const $v = convertToTensor(v, 'v', 'movingAverage'); - const $x = convertToTensor(x, 'x', 'movingAverage'); - const $decay = convertToTensor(decay, 'decay', 'movingAverage'); - - assertTypesMatch($v, $x); - util.assert( - util.arraysEqual($v.shape, $x.shape), () => 'Shape mismatch in v and x'); - - const one = scalar(1); - const oneMinusDecay = sub(one, $decay); - - let update = mul(sub($x, $v), oneMinusDecay); - if (zeroDebias) { - util.assert( - step != null, () => 'When using zeroDebias: true, step is required.'); - const $step = convertToTensor(step, 'step', 'movingAverage'); - update = div(update, sub(one, pow($decay, $step))); - } - return add($v, update); -} - -export const movingAverage = /* @__PURE__ */ op({movingAverage_}); diff --git a/tfjs-master/tfjs-core/src/ops/moving_average_test.ts b/tfjs-master/tfjs-core/src/ops/moving_average_test.ts deleted file mode 100644 index dc3789f79..000000000 --- a/tfjs-master/tfjs-core/src/ops/moving_average_test.ts +++ /dev/null @@ -1,164 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('movingAverage', ALL_ENVS, () => { - // Use the following tensorflow to generate reference values for - // `zeroDebias` = `true`; - // - // ```python - // import tensorflow as tf - // from tensorflow.python.training.moving_averages import - // assign_moving_average - // - // with tf.Session() as sess: - // v = tf.get_variable("v1", shape=[2, 2], dtype=tf.float32, - // initializer=tf.zeros_initializer) - // x = tf.Variable([[1.0, 2.0], [3.0, 4.0]]) - // inc_x = x.assign_add([[10.0, 10.0], [10.0, 10.0]]) - // update = assign_moving_average(v, x, 0.6) - // - // sess.run(tf.global_variables_initializer()) - // - // sess.run(update) - // print(sess.run(v)) - // - // sess.run(inc_x) - // sess.run(update) - // print(sess.run(v)) - // ``` - - it('zeroDebias=true, decay and step are numbers', async () => { - const v0 = tf.tensor2d([[0, 0], [0, 0]], [2, 2]); - const x = tf.tensor2d([[1, 2], [3, 4]], [2, 2]); - const decay = 0.6; - - const v1 = tf.movingAverage(v0, x, decay, 1); - expectArraysClose(await v1.array(), [[1, 2], [3, 4]]); - - const y = tf.tensor2d([[11, 12], [13, 14]], [2, 2]); - const v2 = tf.movingAverage(v1, y, decay, 2); - expectArraysClose(await v2.array(), [[7.25, 8.25], [9.25, 10.25]]); - }); - - it('zeroDebias=true, decay and step are scalars', async () => { - const v0 = tf.tensor2d([[0, 0], [0, 0]], [2, 2]); - const x = tf.tensor2d([[1, 2], [3, 4]], [2, 2]); - const decay = tf.scalar(0.6); - - const v1 = tf.movingAverage(v0, x, decay, tf.scalar(1)); - expectArraysClose(await v1.array(), [[1, 2], [3, 4]]); - - const y = tf.tensor2d([[11, 12], [13, 14]], [2, 2]); - const v2 = tf.movingAverage(v1, y, decay, tf.scalar(2)); - expectArraysClose(await v2.array(), [[7.25, 8.25], [9.25, 10.25]]); - }); - - // Use the following tensorflow to generate reference values for - // `zeroDebias` = `false`; - // - // ```python - // import tensorflow as tf - // from tensorflow.python.training.moving_averages import - // assign_moving_average - // - // with tf.Session() as sess: - // v = tf.get_variable("v1", shape=[2, 2], dtype=tf.float32, - // initializer=tf.zeros_initializer) - // x = tf.Variable([[1.0, 2.0], [3.0, 4.0]]) - // inc_x = x.assign_add([[10.0, 10.0], [10.0, 10.0]]) - // update = assign_moving_average(v, x, 0.6, zero_debias=False) - // - // sess.run(tf.global_variables_initializer()) - // - // sess.run(update) - // print(sess.run(v)) - // - // sess.run(inc_x) - // sess.run(update) - // print(sess.run(v)) - // ``` - - it('zeroDebias=false, decay and step are numbers', async () => { - const v0 = tf.tensor2d([[0, 0], [0, 0]], [2, 2]); - const x = tf.tensor2d([[1, 2], [3, 4]], [2, 2]); - const decay = 0.6; - - const v1 = tf.movingAverage(v0, x, decay, null, false); - expectArraysClose(await v1.array(), [[0.4, 0.8], [1.2, 1.6]]); - - const y = tf.tensor2d([[11, 12], [13, 14]], [2, 2]); - const v2 = tf.movingAverage(v1, y, decay, null, false); - expectArraysClose(await v2.array(), [[4.64, 5.28], [5.92, 6.56]]); - }); - - it('zeroDebias=false, decay is scalar', async () => { - const v0 = tf.tensor2d([[0, 0], [0, 0]], [2, 2]); - const x = tf.tensor2d([[1, 2], [3, 4]], [2, 2]); - const decay = tf.scalar(0.6); - - const v1 = tf.movingAverage(v0, x, decay, null, false); - expectArraysClose(await v1.array(), [[0.4, 0.8], [1.2, 1.6]]); - - const y = tf.tensor2d([[11, 12], [13, 14]], [2, 2]); - const v2 = tf.movingAverage(v1, y, decay, null, false); - expectArraysClose(await v2.array(), [[4.64, 5.28], [5.92, 6.56]]); - }); - - it('zeroDebias=true, no step throws error', () => { - const v0 = tf.tensor2d([[0, 0], [0, 0]], [2, 2]); - const x = tf.tensor2d([[1, 2], [3, 4]], [2, 2]); - const decay = tf.scalar(0.6); - - expect(() => tf.movingAverage(v0, x, decay, null)).toThrowError(); - }); - - it('shape mismatch in v and x throws error', () => { - const v0 = tf.tensor2d([[0, 0], [0, 0]], [2, 2]); - const x = tf.tensor2d([[1, 2]], [1, 2]); - const decay = tf.scalar(0.6); - - expect(() => tf.movingAverage(v0, x, decay, null)).toThrowError(); - }); - - it('throws when passed v as a non-tensor', () => { - const x = tf.tensor2d([[1, 2], [3, 4]], [2, 2]); - - expect(() => tf.movingAverage({} as tf.Tensor, x, 1)) - .toThrowError( - /Argument 'v' passed to 'movingAverage' must be a Tensor/); - }); - it('throws when passed v as a non-tensor', () => { - const v = tf.tensor2d([[0, 0], [0, 0]], [2, 2]); - - expect(() => tf.movingAverage(v, {} as tf.Tensor, 1)) - .toThrowError( - /Argument 'x' passed to 'movingAverage' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const v0 = [[0, 0], [0, 0]]; // 2x2 - const x = [[1, 2], [3, 4]]; // 2x2 - const decay = 0.6; - - const v1 = tf.movingAverage(v0, x, decay, 1); - expectArraysClose(await v1.array(), [[1, 2], [3, 4]]); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/mul.ts b/tfjs-master/tfjs-core/src/ops/mul.ts deleted file mode 100644 index 18ebb3d46..000000000 --- a/tfjs-master/tfjs-core/src/ops/mul.ts +++ /dev/null @@ -1,62 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {Multiply, MultiplyInputs} from '../kernel_names'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {makeTypesMatch} from '../tensor_util'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -import {op} from './operation'; - -/** - * Multiplies two `tf.Tensor`s element-wise, A * B. Supports broadcasting. - * - * We also expose `tf.mulStrict` which has the same signature as this op and - * asserts that `a` and `b` are the same shape (does not broadcast). - * - * ```js - * const a = tf.tensor1d([1, 2, 3, 4]); - * const b = tf.tensor1d([2, 3, 4, 5]); - * - * a.mul(b).print(); // or tf.mul(a, b) - * ``` - * - * ```js - * // Broadcast mul a with b. - * const a = tf.tensor1d([1, 2, 3, 4]); - * const b = tf.scalar(5); - * - * a.mul(b).print(); // or tf.mul(a, b) - * ``` - * @param a The first tensor to multiply. - * @param b The second tensor to multiply. Must have the same dtype as `a`. - * - * @doc {heading: 'Operations', subheading: 'Arithmetic'} - */ -function mul_(a: Tensor|TensorLike, b: Tensor|TensorLike): T { - let $a = convertToTensor(a, 'a', 'mul'); - let $b = convertToTensor(b, 'b', 'mul'); - [$a, $b] = makeTypesMatch($a, $b); - - const inputs: MultiplyInputs = {a: $a, b: $b}; - - return ENGINE.runKernel(Multiply, inputs as unknown as NamedTensorMap); -} -export const mul = /* @__PURE__ */ op({mul_}); diff --git a/tfjs-master/tfjs-core/src/ops/multi_rnn_cell.ts b/tfjs-master/tfjs-core/src/ops/multi_rnn_cell.ts deleted file mode 100644 index 617bcebb0..000000000 --- a/tfjs-master/tfjs-core/src/ops/multi_rnn_cell.ts +++ /dev/null @@ -1,69 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {Tensor2D} from '../tensor'; -import {convertToTensor, convertToTensorArray} from '../tensor_util_env'; -import {TensorLike} from '../types'; -import {op} from './operation'; - -/** - * @docalias (data: Tensor2D, c: Tensor2D, h: Tensor2D): [Tensor2D, Tensor2D] - */ -export type LSTMCellFunc = { - (data: Tensor2D, c: Tensor2D, h: Tensor2D): [Tensor2D, Tensor2D]; -}; - -/** - * Computes the next states and outputs of a stack of LSTMCells. - * - * Each cell output is used as input to the next cell. - * - * Returns `[cellState, cellOutput]`. - * - * Derived from tf.contrib.rn.MultiRNNCell. - * - * @param lstmCells Array of LSTMCell functions. - * @param data The input to the cell. - * @param c Array of previous cell states. - * @param h Array of previous cell outputs. - * - * @doc {heading: 'Operations', subheading: 'RNN'} - */ -function multiRNNCell_( - lstmCells: LSTMCellFunc[], data: Tensor2D|TensorLike, - c: Array, - h: Array): [Tensor2D[], Tensor2D[]] { - const $data = convertToTensor(data, 'data', 'multiRNNCell'); - const $c = convertToTensorArray(c, 'c', 'multiRNNCell'); - const $h = convertToTensorArray(h, 'h', 'multiRNNCell'); - - let input = $data; - const newStates = []; - for (let i = 0; i < lstmCells.length; i++) { - const output = lstmCells[i](input, $c[i], $h[i]); - newStates.push(output[0]); - newStates.push(output[1]); - input = output[1]; - } - const newC: Tensor2D[] = []; - const newH: Tensor2D[] = []; - for (let i = 0; i < newStates.length; i += 2) { - newC.push(newStates[i]); - newH.push(newStates[i + 1]); - } - return [newC, newH]; -} -export const multiRNNCell = /* @__PURE__ */ op({multiRNNCell_}); diff --git a/tfjs-master/tfjs-core/src/ops/multi_rnn_cell_test.ts b/tfjs-master/tfjs-core/src/ops/multi_rnn_cell_test.ts deleted file mode 100644 index 0ffd99668..000000000 --- a/tfjs-master/tfjs-core/src/ops/multi_rnn_cell_test.ts +++ /dev/null @@ -1,142 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {Tensor2D} from '../tensor'; -import {expectArraysClose} from '../test_util'; -import {Rank} from '../types'; - -describeWithFlags('lstm', ALL_ENVS, () => { - it('MultiRNNCell with 2 BasicLSTMCells', async () => { - const lstmKernel1 = tf.tensor2d( - [ - 0.26242125034332275, -0.8787832260131836, 0.781475305557251, - 1.337337851524353, 0.6180247068405151, -0.2760246992111206, - -0.11299663782119751, -0.46332040429115295, -0.1765323281288147, - 0.6807947158813477, -0.8326982855796814, 0.6732975244522095 - ], - [3, 4]); - const lstmBias1 = tf.tensor1d( - [1.090713620185852, -0.8282332420349121, 0, 1.0889357328414917]); - const lstmKernel2 = tf.tensor2d( - [ - -1.893059492111206, -1.0185645818710327, -0.6270437240600586, - -2.1829540729522705, -0.4583775997161865, -0.5454602241516113, - -0.3114445209503174, 0.8450229167938232 - ], - [2, 4]); - const lstmBias2 = tf.tensor1d( - [0.9906240105628967, 0.6248329877853394, 0, 1.0224634408950806]); - - const forgetBias = tf.scalar(1.0); - const lstm1 = (data: Tensor2D, c: Tensor2D, h: Tensor2D) => - tf.basicLSTMCell(forgetBias, lstmKernel1, lstmBias1, data, c, h); - const lstm2 = (data: Tensor2D, c: Tensor2D, h: Tensor2D) => - tf.basicLSTMCell(forgetBias, lstmKernel2, lstmBias2, data, c, h); - const c = [ - tf.zeros([1, lstmBias1.shape[0] / 4]), - tf.zeros([1, lstmBias2.shape[0] / 4]) - ]; - const h = [ - tf.zeros([1, lstmBias1.shape[0] / 4]), - tf.zeros([1, lstmBias2.shape[0] / 4]) - ]; - - const onehot = tf.buffer([1, 2], 'float32'); - onehot.set(1.0, 0, 0); - - const output = tf.multiRNNCell([lstm1, lstm2], onehot.toTensor(), c, h); - - expectArraysClose(await output[0][0].data(), [-0.7440074682235718]); - expectArraysClose(await output[0][1].data(), [0.7460772395133972]); - expectArraysClose(await output[1][0].data(), [-0.5802832245826721]); - expectArraysClose(await output[1][1].data(), [0.5745711922645569]); - }); -}); - -describeWithFlags('multiRNN throws when passed non-tensor', ALL_ENVS, () => { - it('input: data', () => { - const lstmKernel1: tf.Tensor2D = tf.zeros([3, 4]); - const lstmBias1: tf.Tensor1D = tf.zeros([4]); - const lstmKernel2: tf.Tensor2D = tf.zeros([2, 4]); - const lstmBias2: tf.Tensor1D = tf.zeros([4]); - - const forgetBias = tf.scalar(1.0); - const lstm1 = (data: Tensor2D, c: Tensor2D, h: Tensor2D) => - tf.basicLSTMCell(forgetBias, lstmKernel1, lstmBias1, data, c, h); - const lstm2 = (data: Tensor2D, c: Tensor2D, h: Tensor2D) => - tf.basicLSTMCell(forgetBias, lstmKernel2, lstmBias2, data, c, h); - const c = [ - tf.zeros([1, lstmBias1.shape[0] / 4]), - tf.zeros([1, lstmBias2.shape[0] / 4]) - ]; - const h = [ - tf.zeros([1, lstmBias1.shape[0] / 4]), - tf.zeros([1, lstmBias2.shape[0] / 4]) - ]; - - expect(() => tf.multiRNNCell([lstm1, lstm2], {} as tf.Tensor2D, c, h)) - .toThrowError( - /Argument 'data' passed to 'multiRNNCell' must be a Tensor/); - }); - - it('input: c', () => { - const lstmKernel1: tf.Tensor2D = tf.zeros([3, 4]); - const lstmBias1: tf.Tensor1D = tf.zeros([4]); - const lstmKernel2: tf.Tensor2D = tf.zeros([2, 4]); - const lstmBias2: tf.Tensor1D = tf.zeros([4]); - - const forgetBias = tf.scalar(1.0); - const lstm1 = (data: Tensor2D, c: Tensor2D, h: Tensor2D) => - tf.basicLSTMCell(forgetBias, lstmKernel1, lstmBias1, data, c, h); - const lstm2 = (data: Tensor2D, c: Tensor2D, h: Tensor2D) => - tf.basicLSTMCell(forgetBias, lstmKernel2, lstmBias2, data, c, h); - - const h = [ - tf.zeros([1, lstmBias1.shape[0] / 4]), - tf.zeros([1, lstmBias2.shape[0] / 4]) - ]; - const data: tf.Tensor2D = tf.zeros([1, 2]); - - expect(() => tf.multiRNNCell([lstm1, lstm2], data, [{} as tf.Tensor2D], h)) - .toThrowError( - /Argument 'c\[0\]' passed to 'multiRNNCell' must be a Tensor/); - }); - - it('input: h', () => { - const lstmKernel1: tf.Tensor2D = tf.zeros([3, 4]); - const lstmBias1: tf.Tensor1D = tf.zeros([4]); - const lstmKernel2: tf.Tensor2D = tf.zeros([2, 4]); - const lstmBias2: tf.Tensor1D = tf.zeros([4]); - - const forgetBias = tf.scalar(1.0); - const lstm1 = (data: Tensor2D, c: Tensor2D, h: Tensor2D) => - tf.basicLSTMCell(forgetBias, lstmKernel1, lstmBias1, data, c, h); - const lstm2 = (data: Tensor2D, c: Tensor2D, h: Tensor2D) => - tf.basicLSTMCell(forgetBias, lstmKernel2, lstmBias2, data, c, h); - const c = [ - tf.zeros([1, lstmBias1.shape[0] / 4]), - tf.zeros([1, lstmBias2.shape[0] / 4]) - ]; - const data: tf.Tensor2D = tf.zeros([1, 2]); - - expect(() => tf.multiRNNCell([lstm1, lstm2], data, c, [{} as tf.Tensor2D])) - .toThrowError( - /Argument 'h\[0\]' passed to 'multiRNNCell' must be a Tensor/); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/multinomial.ts b/tfjs-master/tfjs-core/src/ops/multinomial.ts deleted file mode 100644 index 13563ddc8..000000000 --- a/tfjs-master/tfjs-core/src/ops/multinomial.ts +++ /dev/null @@ -1,83 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {Multinomial, MultinomialAttrs, MultinomialInputs} from '../kernel_names'; -import {NamedAttrMap} from '../kernel_registry'; -import {Tensor1D, Tensor2D} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -import {op} from './operation'; -import {reshape} from './reshape'; - -/** - * Creates a `tf.Tensor` with values drawn from a multinomial distribution. - * - * ```js - * const probs = tf.tensor([.75, .25]); - * tf.multinomial(probs, 3).print(); - * ``` - * - * @param logits 1D array with unnormalized log-probabilities, or - * 2D array of shape `[batchSize, numOutcomes]`. See the `normalized` - * parameter. - * @param numSamples Number of samples to draw for each row slice. - * @param seed The seed number. - * @param normalized Whether the provided `logits` are normalized true - * probabilities (sum to 1). Defaults to false. - * @return 1D array of shape `[numSamples]`, or 2D array of shape - * `[batchSize, numSamples]`, depending on the rank of the input. - * - * @doc {heading: 'Tensors', subheading: 'Random'} - */ -function multinomial_( - logits: Tensor1D|Tensor2D|TensorLike, numSamples: number, seed?: number, - normalized = false): Tensor1D|Tensor2D { - const $logits = convertToTensor(logits, 'logits', 'multinomial'); - const numOutcomes = $logits.size; - const origRank = $logits.rank; - if (numOutcomes < 2) { - throw new Error( - `Error in multinomial: you need at least 2 outcomes, but got ` + - `${numOutcomes}.`); - } - if (origRank > 2) { - throw new Error(`Rank of probabilities must be 1 or 2, but is ${origRank}`); - } - // TODO(lina128): Investigate correct seed behavior. The code seems not allow - // setting see to 0. - seed = seed || Math.random(); - - // The kernel only accepts (and returns) rank 2 tensors. - const logits2D: Tensor2D = - origRank === 1 ? reshape($logits, [1, -1]) : $logits as Tensor2D; - - const inputs: MultinomialInputs = {logits: logits2D}; - const attrs: MultinomialAttrs = {numSamples, seed, normalized}; - - // tslint:disable-next-line: no-unnecessary-type-assertion - const res = ENGINE.runKernel( - Multinomial, inputs as unknown as NamedTensorMap, - attrs as unknown as NamedAttrMap) as Tensor2D; - - // tslint:disable-next-line:no-unnecessary-type-assertion - return origRank === 1 ? reshape(res, [res.size]) as Tensor1D : res; -} - -export const multinomial = /* @__PURE__ */ op({multinomial_}); diff --git a/tfjs-master/tfjs-core/src/ops/multinomial_test.ts b/tfjs-master/tfjs-core/src/ops/multinomial_test.ts deleted file mode 100644 index 412253026..000000000 --- a/tfjs-master/tfjs-core/src/ops/multinomial_test.ts +++ /dev/null @@ -1,139 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {Tensor1D} from '../tensor'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('multinomial', ALL_ENVS, () => { - const NUM_SAMPLES = 1000; - // Allowed Variance in probability (in %). - const EPSILON = 0.05; - const SEED = 3.14; - - it('Flip a fair coin and check bounds', async () => { - const probs = tf.tensor1d([1, 1]); - const result = tf.multinomial(probs, NUM_SAMPLES, SEED); - expect(result.dtype).toBe('int32'); - expect(result.shape).toEqual([NUM_SAMPLES]); - const outcomeProbs = computeProbs(await result.data(), 2); - expectArraysClose(outcomeProbs, [0.5, 0.5], EPSILON); - }); - - it('Flip a two-sided coin with 100% of heads', async () => { - const logits = tf.tensor1d([1, -100]); - const result = tf.multinomial(logits, NUM_SAMPLES, SEED); - expect(result.dtype).toBe('int32'); - expect(result.shape).toEqual([NUM_SAMPLES]); - const outcomeProbs = computeProbs(await result.data(), 2); - expectArraysClose(outcomeProbs, [1, 0], EPSILON); - }); - - it('Flip a two-sided coin with 100% of tails', async () => { - const logits = tf.tensor1d([-100, 1]); - const result = tf.multinomial(logits, NUM_SAMPLES, SEED); - expect(result.dtype).toBe('int32'); - expect(result.shape).toEqual([NUM_SAMPLES]); - const outcomeProbs = computeProbs(await result.data(), 2); - expectArraysClose(outcomeProbs, [0, 1], EPSILON); - }); - - it('Flip a single-sided coin throws error', () => { - const probs = tf.tensor1d([1]); - expect(() => tf.multinomial(probs, NUM_SAMPLES, SEED)).toThrowError(); - }); - - it('Flip a ten-sided coin and check bounds', async () => { - const numOutcomes = 10; - const logits = tf.fill([numOutcomes], 1).as1D(); - const result = tf.multinomial(logits, NUM_SAMPLES, SEED); - expect(result.dtype).toBe('int32'); - expect(result.shape).toEqual([NUM_SAMPLES]); - const outcomeProbs = computeProbs(await result.data(), numOutcomes); - expect(outcomeProbs.length).toBeLessThanOrEqual(numOutcomes); - }); - - it('Flip 3 three-sided coins, each coin is 100% biases', async () => { - const numOutcomes = 3; - const logits = tf.tensor2d( - [[-100, -100, 1], [-100, 1, -100], [1, -100, -100]], [3, numOutcomes]); - const result = tf.multinomial(logits, NUM_SAMPLES, SEED); - expect(result.dtype).toBe('int32'); - expect(result.shape).toEqual([3, NUM_SAMPLES]); - - // First coin always gets last event. - let outcomeProbs = - computeProbs((await result.data()).slice(0, NUM_SAMPLES), numOutcomes); - expectArraysClose(outcomeProbs, [0, 0, 1], EPSILON); - - // Second coin always gets middle event. - outcomeProbs = computeProbs( - (await result.data()).slice(NUM_SAMPLES, 2 * NUM_SAMPLES), numOutcomes); - expectArraysClose(outcomeProbs, [0, 1, 0], EPSILON); - - // Third coin always gets first event - outcomeProbs = - computeProbs((await result.data()).slice(2 * NUM_SAMPLES), numOutcomes); - expectArraysClose(outcomeProbs, [1, 0, 0], EPSILON); - }); - - it('passing Tensor3D throws error', () => { - const probs = tf.zeros([3, 2, 2]); - const normalized = true; - expect(() => tf.multinomial(probs as Tensor1D, 3, SEED, normalized)) - .toThrowError(); - }); - - it('throws when passed a non-tensor', () => { - // tslint:disable-next-line:no-any - expect(() => tf.multinomial({} as any, NUM_SAMPLES, SEED)) - .toThrowError( - /Argument 'logits' passed to 'multinomial' must be a Tensor/); - }); - - it('accepts a tensor-like object for logits (biased coin)', async () => { - const res = tf.multinomial([-100, 1], NUM_SAMPLES, SEED); - expect(res.dtype).toBe('int32'); - expect(res.shape).toEqual([NUM_SAMPLES]); - const outcomeProbs = computeProbs(await res.data(), 2); - expectArraysClose(outcomeProbs, [0, 1], EPSILON); - }); - - it('creates the same data given the same seed', async () => { - const res1 = tf.multinomial([1, 2, 3, 4], NUM_SAMPLES, SEED); - const res2 = tf.multinomial([1, 2, 3, 4], NUM_SAMPLES, SEED); - expectArraysClose(await res1.data(), await res2.data()); - }); - - function computeProbs( - events: Float32Array|Uint8Array|Int32Array, numOutcomes: number) { - const counts = []; - for (let i = 0; i < numOutcomes; ++i) { - counts[i] = 0; - } - const numSamples = events.length; - for (let i = 0; i < events.length; ++i) { - counts[events[i]]++; - } - // Normalize counts to be probabilities between [0, 1]. - for (let i = 0; i < counts.length; i++) { - counts[i] /= numSamples; - } - return counts; - } -}); diff --git a/tfjs-master/tfjs-core/src/ops/neg.ts b/tfjs-master/tfjs-core/src/ops/neg.ts deleted file mode 100644 index 7df6607a0..000000000 --- a/tfjs-master/tfjs-core/src/ops/neg.ts +++ /dev/null @@ -1,46 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {Neg, NegInputs} from '../kernel_names'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -import {op} from './operation'; - -/** - * Computes `-1 * x` element-wise. - * - * ```js - * const x = tf.tensor2d([1, 2, -2, 0], [2, 2]); - * - * x.neg().print(); // or tf.neg(x) - * ``` - * - * @param x The input tensor. - * - * @doc {heading: 'Operations', subheading: 'Basic math'} - */ -function neg_(x: T|TensorLike): T { - const $x = convertToTensor(x, 'x', 'neg'); - - const inputs: NegInputs = {x: $x}; - return ENGINE.runKernel(Neg, inputs as unknown as NamedTensorMap); -} -export const neg = /* @__PURE__ */ op({neg_}); diff --git a/tfjs-master/tfjs-core/src/ops/neg_test.ts b/tfjs-master/tfjs-core/src/ops/neg_test.ts deleted file mode 100644 index 89b96b6e0..000000000 --- a/tfjs-master/tfjs-core/src/ops/neg_test.ts +++ /dev/null @@ -1,105 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; -import {backend} from '../index'; - -describeWithFlags('neg', ALL_ENVS, () => { - it('basic', async () => { - const a = tf.tensor1d([1, -3, 2, 7, -4]); - const result = tf.neg(a); - expectArraysClose(await result.data(), [-1, 3, -2, -7, 4]); - }); - - it('int32', async () => { - if (backend() && backend().floatPrecision() === 32) { - // TODO: Use skip() instead when it is implemented - const a = tf.tensor1d([1, -3, 12345678, -12345678], 'int32'); - const result = tf.neg(a); - expect(result.dtype).toEqual('int32'); - expectArraysClose(await result.data(), [-1, 3, -12345678, 12345678]); - } - }); - - it('propagate NaNs', async () => { - const a = tf.tensor1d([1, -3, 2, 7, NaN]); - const result = tf.neg(a); - const expected = [-1, 3, -2, -7, NaN]; - expectArraysClose(await result.data(), expected); - }); - - it('gradients: Scalar', async () => { - const a = tf.scalar(4); - const dy = tf.scalar(8); - - const da = tf.grad(a => tf.neg(a))(a, dy); - - expect(da.shape).toEqual(a.shape); - expect(da.dtype).toEqual('float32'); - expectArraysClose(await da.data(), [8 * -1]); - }); - - it('gradients: Scalar', async () => { - const a = tf.scalar(4); - const dy = tf.scalar(8); - - const da = tf.grad(a => tf.neg(a.clone()).clone())(a, dy); - - expect(da.shape).toEqual(a.shape); - expect(da.dtype).toEqual('float32'); - expectArraysClose(await da.data(), [8 * -1]); - }); - - it('gradients: Tensor1D', async () => { - const a = tf.tensor1d([1, 2, -3, 5]); - const dy = tf.tensor1d([1, 2, 3, 4]); - - const da = tf.grad(a => tf.neg(a))(a, dy); - - expect(da.shape).toEqual(a.shape); - expect(da.dtype).toEqual('float32'); - expectArraysClose(await da.data(), [1 * -1, 2 * -1, 3 * -1, 4 * -1]); - }); - - it('gradients: Tensor2D', async () => { - const a = tf.tensor2d([3, -1, -2, 3], [2, 2]); - const dy = tf.tensor2d([1, 2, 3, 4], [2, 2]); - - const da = tf.grad(a => tf.neg(a))(a, dy); - - expect(da.shape).toEqual(a.shape); - expect(da.dtype).toEqual('float32'); - expectArraysClose(await da.data(), [1 * -1, 2 * -1, 3 * -1, 4 * -1]); - }); - - it('throws when passed a non-tensor', () => { - expect(() => tf.neg({} as tf.Tensor)) - .toThrowError(/Argument 'x' passed to 'neg' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const result = tf.neg([1, -3, 2, 7, -4]); - expectArraysClose(await result.data(), [-1, 3, -2, -7, 4]); - }); - - it('throws for string tensor', () => { - expect(() => tf.neg('q')) - .toThrowError(/Argument 'x' passed to 'neg' must be numeric/); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/nonmax_util.ts b/tfjs-master/tfjs-core/src/ops/nonmax_util.ts deleted file mode 100644 index d85d2fcf3..000000000 --- a/tfjs-master/tfjs-core/src/ops/nonmax_util.ts +++ /dev/null @@ -1,63 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Tensor1D, Tensor2D} from '../tensor'; -import * as util from '../util'; - -function nonMaxSuppSanityCheck( - boxes: Tensor2D, scores: Tensor1D, maxOutputSize: number, - iouThreshold: number, scoreThreshold: number, softNmsSigma?: number): { - maxOutputSize: number, - iouThreshold: number, - scoreThreshold: number, - softNmsSigma: number -} { - if (iouThreshold == null) { - iouThreshold = 0.5; - } - if (scoreThreshold == null) { - scoreThreshold = Number.NEGATIVE_INFINITY; - } - if (softNmsSigma == null) { - softNmsSigma = 0.0; - } - - const numBoxes = boxes.shape[0]; - maxOutputSize = Math.min(maxOutputSize, numBoxes); - - util.assert( - 0 <= iouThreshold && iouThreshold <= 1, - () => `iouThreshold must be in [0, 1], but was '${iouThreshold}'`); - util.assert( - boxes.rank === 2, - () => `boxes must be a 2D tensor, but was of rank '${boxes.rank}'`); - util.assert( - boxes.shape[1] === 4, - () => - `boxes must have 4 columns, but 2nd dimension was ${boxes.shape[1]}`); - util.assert(scores.rank === 1, () => 'scores must be a 1D tensor'); - util.assert( - scores.shape[0] === numBoxes, - () => `scores has incompatible shape with boxes. Expected ${numBoxes}, ` + - `but was ${scores.shape[0]}`); - util.assert( - 0 <= softNmsSigma && softNmsSigma <= 1, - () => `softNmsSigma must be in [0, 1], but was '${softNmsSigma}'`); - return {maxOutputSize, iouThreshold, scoreThreshold, softNmsSigma}; -} - -export {nonMaxSuppSanityCheck}; diff --git a/tfjs-master/tfjs-core/src/ops/norm.ts b/tfjs-master/tfjs-core/src/ops/norm.ts deleted file mode 100644 index 049dec92d..000000000 --- a/tfjs-master/tfjs-core/src/ops/norm.ts +++ /dev/null @@ -1,140 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Tensor} from '../tensor'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; -import {parseAxisParam} from '../util'; - -import {abs} from './abs'; -import * as axis_util from './axis_util'; -import {max} from './max'; -import {min} from './min'; -import {op} from './operation'; -import {pow} from './pow'; -import {reshape} from './reshape'; -import {scalar} from './scalar'; -import {sqrt} from './sqrt'; -import {square} from './square'; -import {sum} from './sum'; - -/** - * Computes the norm of scalar, vectors, and matrices. - * This function can compute several different vector norms (the 1-norm, the - * Euclidean or 2-norm, the inf-norm, and in general the p-norm for p > 0) - * and matrix norms (Frobenius, 1-norm, and inf-norm). - * - * ```js - * const x = tf.tensor1d([1, 2, 3, 4]); - * - * x.norm().print(); // or tf.norm(x) - * ``` - * - * @param x The input array. - * @param ord Optional. Order of the norm. Supported norm types are - * following: - * - * | ord | norm for matrices | norm for vectors - * |------------|---------------------------|--------------------- - * |'euclidean' |Frobenius norm |2-norm - * |'fro' |Frobenius norm | - * |Infinity |max(sum(abs(x), axis=1)) |max(abs(x)) - * |-Infinity |min(sum(abs(x), axis=1)) |min(abs(x)) - * |1 |max(sum(abs(x), axis=0)) |sum(abs(x)) - * |2 | |sum(abs(x)^2)^(1/2) - * - * @param axis Optional. If axis is null (the default), the input is - * considered a vector and a single vector norm is computed over the entire - * set of values in the Tensor, i.e. norm(x, ord) is equivalent - * to norm(x.reshape([-1]), ord). If axis is an integer, the input - * is considered a batch of vectors, and axis determines the axis in x - * over which to compute vector norms. If axis is a 2-tuple of integer it is - * considered a batch of matrices and axis determines the axes in NDArray - * over which to compute a matrix norm. - * @param keepDims Optional. If true, the norm has the same dimensionality - * as the input. - * - * @doc {heading: 'Operations', subheading: 'Matrices'} - */ -function norm_( - x: Tensor|TensorLike, ord: number|'euclidean'|'fro' = 'euclidean', - axis: number|number[] = null, keepDims = false): Tensor { - x = convertToTensor(x, 'x', 'norm'); - - const norm = normImpl(x, ord, axis); - let keepDimsShape = norm.shape; - if (keepDims) { - const axes = parseAxisParam(axis, x.shape); - keepDimsShape = axis_util.expandShapeToKeepDim(norm.shape, axes); - } - return reshape(norm, keepDimsShape); -} - -function normImpl( - x: Tensor, p: number|string, axis: number|number[] = null): Tensor { - if (x.rank === 0) { - return abs(x); - } - - // consider vector when no axis is specified - if (x.rank !== 1 && axis === null) { - return normImpl(reshape(x, [-1]), p, axis); - } - - // vector - if (x.rank === 1 || typeof axis === 'number' || - Array.isArray(axis) && axis.length === 1) { - if (p === 1) { - return sum(abs(x), axis); - } - if (p === Infinity) { - return max(abs(x), axis); - } - if (p === -Infinity) { - return min(abs(x), axis); - } - if (p === 'euclidean' || p === 2) { - // norm(x, 2) = sum(abs(xi) ^ 2) ^ 1/2 - return sqrt(sum(pow(abs(x), scalar(2, 'int32')), axis)); - } - - throw new Error(`Error in norm: invalid ord value: ${p}`); - } - - // matrix (assumption axis[0] < axis[1]) - if (Array.isArray(axis) && axis.length === 2) { - if (p === 1) { - return max(sum(abs(x), axis[0]), axis[1] - 1); - } - if (p === Infinity) { - return max(sum(abs(x), axis[1]), axis[0]); - } - if (p === -Infinity) { - return min(sum(abs(x), axis[1]), axis[0]); - } - if (p === 'fro' || p === 'euclidean') { - // norm(x) = sqrt(sum(pow(x, 2))) - return sqrt(sum(square(x), axis)); - } - - throw new Error(`Error in norm: invalid ord value: ${p}`); - } - - throw new Error(`Error in norm: invalid axis: ${axis}`); -} - -export const norm = /* @__PURE__ */ op({norm_}); diff --git a/tfjs-master/tfjs-core/src/ops/norm_test.ts b/tfjs-master/tfjs-core/src/ops/norm_test.ts deleted file mode 100644 index d4ffaa7e6..000000000 --- a/tfjs-master/tfjs-core/src/ops/norm_test.ts +++ /dev/null @@ -1,291 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose, expectArraysEqual} from '../test_util'; - -describeWithFlags('norm', ALL_ENVS, () => { - it('scalar norm', async () => { - const a = tf.scalar(-22.0); - const norm = tf.norm(a); - - expect(norm.dtype).toBe('float32'); - expectArraysClose(await norm.data(), 22); - }); - - it('vector inf norm', async () => { - const a = tf.tensor1d([1, -2, 3, -4]); - const norm = tf.norm(a, Infinity); - - expect(norm.dtype).toBe('float32'); - expectArraysClose(await norm.data(), 4); - }); - - it('vector -inf norm', async () => { - const a = tf.tensor1d([1, -2, 3, -4]); - const norm = tf.norm(a, -Infinity); - - expect(norm.dtype).toBe('float32'); - expectArraysClose(await norm.data(), 1); - }); - - it('vector 1 norm', async () => { - const a = tf.tensor1d([1, -2, 3, -4]); - const norm = tf.norm(a, 1); - - expect(norm.dtype).toBe('float32'); - expectArraysClose(await norm.data(), 10); - }); - - it('vector euclidean norm', async () => { - const a = tf.tensor1d([1, -2, 3, -4]); - const norm = tf.norm(a, 'euclidean'); - - expect(norm.dtype).toBe('float32'); - expectArraysClose(await norm.data(), 5.4772); - }); - - it('vector 2-norm', async () => { - const a = tf.tensor1d([1, -2, 3, -4]); - const norm = tf.norm(a, 2); - - expect(norm.dtype).toBe('float32'); - expectArraysClose(await norm.data(), 5.4772); - }); - - it('vector >2-norm to throw error', () => { - const a = tf.tensor1d([1, -2, 3, -4]); - expect(() => tf.norm(a, 3)).toThrowError(); - }); - - it('matrix inf norm', async () => { - const a = tf.tensor2d([1, 2, -3, 1, 0, 1], [3, 2]); - const norm = tf.norm(a, Infinity, [0, 1]); - - expect(norm.dtype).toBe('float32'); - expectArraysClose(await norm.data(), 4); - }); - - it('matrix -inf norm', async () => { - const a = tf.tensor2d([1, 2, -3, 1, 0, 1], [3, 2]); - const norm = tf.norm(a, -Infinity, [0, 1]); - - expect(norm.dtype).toBe('float32'); - expectArraysClose(await norm.data(), 1); - }); - - it('matrix 1 norm', async () => { - const a = tf.tensor2d([1, 2, -3, 1, 1, 1], [3, 2]); - const norm = tf.norm(a, 1, [0, 1]); - - expect(norm.dtype).toBe('float32'); - expectArraysClose(await norm.data(), 5); - }); - - it('matrix euclidean norm', async () => { - const a = tf.tensor2d([1, 2, -3, 1, 1, 1], [3, 2]); - const norm = tf.norm(a, 'euclidean', [0, 1]); - - expect(norm.dtype).toBe('float32'); - expectArraysClose(await norm.data(), 4.123); - }); - - it('matrix fro norm', async () => { - const a = tf.tensor2d([1, 2, -3, 1, 1, 1], [3, 2]); - const norm = tf.norm(a, 'fro', [0, 1]); - - expect(norm.dtype).toBe('float32'); - expectArraysClose(await norm.data(), 4.123); - }); - - it('matrix other norm to throw error', () => { - const a = tf.tensor2d([1, 2, -3, 1, 1, 1], [3, 2]); - expect(() => tf.norm(a, 2, [0, 1])).toThrowError(); - }); - - it('propagates NaNs for norm', async () => { - const a = tf.tensor2d([1, 2, 3, NaN, 0, 1], [3, 2]); - const norm = tf.norm(a); - - expect(norm.dtype).toBe('float32'); - expectArraysEqual(await norm.data(), NaN); - }); - - it('axis=null in 2D array norm', async () => { - const a = tf.tensor2d([1, 2, 3, 0, 0, 1], [3, 2]); - const norm = tf.norm(a, Infinity); - - expect(norm.shape).toEqual([]); - expect(norm.dtype).toBe('float32'); - expectArraysClose(await norm.data(), [3]); - }); - - it('2D array norm with keep dim', async () => { - const a = tf.tensor2d([1, 2, 3, 0, 0, 1], [3, 2]); - const norm = tf.norm(a, Infinity, null, true /* keepDims */); - - expect(norm.shape).toEqual([1, 1]); - expect(norm.dtype).toBe('float32'); - expectArraysClose(await norm.data(), [3]); - }); - - it('axis=0 in 2D array norm', async () => { - const a = tf.tensor2d([1, 2, 3, 0, 0, 1], [3, 2]); - const norm = tf.norm(a, Infinity, [0]); - - expect(norm.shape).toEqual([2]); - expect(norm.dtype).toBe('float32'); - expectArraysClose(await norm.data(), [3, 2]); - }); - - it('axis=1 in 2D array norm', async () => { - const a = tf.tensor2d([1, 2, 3, 0, 0, 1], [3, 2]); - const norm = tf.norm(a, Infinity, [1]); - - expect(norm.dtype).toBe('float32'); - expect(norm.shape).toEqual([3]); - expectArraysClose(await norm.data(), [2, 3, 1]); - }); - - it('axis=1 keepDims in 2D array norm', async () => { - const a = tf.tensor2d([1, 2, 3, 0, 0, 1], [3, 2]); - const norm = tf.norm(a, Infinity, [1], true); - - expect(norm.dtype).toBe('float32'); - expect(norm.shape).toEqual([3, 1]); - expectArraysClose(await norm.data(), [2, 3, 1]); - }); - - it('2D norm with axis=1 provided as number', async () => { - const a = tf.tensor2d([1, 2, 3, 0, 0, 1], [2, 3]); - const norm = tf.norm(a, Infinity, 1); - - expect(norm.shape).toEqual([2]); - expect(norm.dtype).toBe('float32'); - expectArraysClose(await norm.data(), [3, 1]); - }); - - it('axis=0,1 in 2D array norm', async () => { - const a = tf.tensor2d([1, 2, 3, 0, 0, 1], [3, 2]); - const norm = tf.norm(a, Infinity, [0, 1]); - - expect(norm.shape).toEqual([]); - expect(norm.dtype).toBe('float32'); - expectArraysClose(await norm.data(), [3]); - }); - - it('axis=0,1 keepDims in 2D array norm', async () => { - const a = tf.tensor2d([1, 2, 3, 0, 0, 1], [3, 2]); - const norm = tf.norm(a, Infinity, [0, 1], true); - - expect(norm.shape).toEqual([1, 1]); - expect(norm.dtype).toBe('float32'); - expectArraysClose(await norm.data(), [3]); - }); - - it('3D norm axis=0,1, matrix inf norm', async () => { - const a = tf.tensor3d([1, 2, -3, 1, 0, 1], [3, 2, 1]); - const norm = tf.norm(a, Infinity, [0, 1]); - - expect(norm.shape).toEqual([1]); - expect(norm.dtype).toBe('float32'); - expectArraysClose(await norm.data(), [4]); - }); - - it('axis=0,1 keepDims in 3D array norm', async () => { - const a = tf.tensor3d([1, 2, 3, 0, 0, 1], [3, 2, 1]); - const norm = tf.norm(a, Infinity, [0, 1], true); - - expect(norm.shape).toEqual([1, 1, 1]); - expect(norm.dtype).toBe('float32'); - expectArraysClose(await norm.data(), [3]); - }); - - it('axis=0,1 keepDims in 3D array norm', async () => { - const a = tf.tensor3d([1, 2, 3, 0, 0, 1, 1, 2, 3, 0, 0, 1], [3, 2, 2]); - const norm = tf.norm(a, Infinity, [0, 1], true); - - expect(norm.shape).toEqual([1, 1, 2]); - expect(norm.dtype).toBe('float32'); - expectArraysClose(await norm.data(), [4, 3]); - }); - - it('axis=null in 3D array norm', async () => { - const a = tf.tensor3d([1, 2, 3, 0, 0, 1], [3, 2, 1]); - const norm = tf.norm(a, Infinity); - - expect(norm.shape).toEqual([]); - expect(norm.dtype).toBe('float32'); - expectArraysClose(await norm.data(), [3]); - }); - - it('axis=null in 4D array norm', async () => { - const a = tf.tensor4d([1, 2, 3, 0, 0, 1], [3, 2, 1, 1]); - const norm = tf.norm(a, Infinity); - - expect(norm.shape).toEqual([]); - expect(norm.dtype).toBe('float32'); - expectArraysClose(await norm.data(), [3]); - }); - - it('axis=0,1 in 4D array norm', async () => { - const a = tf.tensor4d( - [ - 1, 2, 3, 0, 0, 1, 1, 2, 3, 0, 0, 1, - 1, 2, 3, 0, 0, 1, 1, 2, 3, 0, 0, 1 - ], - [3, 2, 2, 2]); - const norm = tf.norm(a, Infinity, [0, 1]); - - expect(norm.shape).toEqual([2, 2]); - expect(norm.dtype).toBe('float32'); - expectArraysClose(await norm.data(), [4, 3, 4, 3]); - }); - - it('axis=0,1 in 4D array norm', async () => { - const a = tf.tensor4d( - [ - 1, 2, 3, 0, 0, 1, 1, 2, 3, 0, 0, 1, - 1, 2, 3, 0, 0, 1, 1, 2, 3, 0, 0, 1 - ], - [3, 2, 2, 2]); - const norm = tf.norm(a, Infinity, [0, 1], true); - - expect(norm.shape).toEqual([1, 1, 2, 2]); - expect(norm.dtype).toBe('float32'); - expectArraysClose(await norm.data(), [4, 3, 4, 3]); - }); - - it('throws when passed a non-tensor', () => { - expect(() => tf.norm({} as tf.Tensor)) - .toThrowError(/Argument 'x' passed to 'norm' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const norm = tf.norm([1, -2, 3, -4], 1); - - expect(norm.dtype).toBe('float32'); - expectArraysClose(await norm.data(), 10); - }); - - it('throws error for string tensors', () => { - expect(() => tf.norm([ - 'a', 'b' - ])).toThrowError(/Argument 'x' passed to 'norm' must be numeric tensor/); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/not_equal.ts b/tfjs-master/tfjs-core/src/ops/not_equal.ts deleted file mode 100644 index 6387fdb67..000000000 --- a/tfjs-master/tfjs-core/src/ops/not_equal.ts +++ /dev/null @@ -1,55 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {ENGINE} from '../engine'; -import {NotEqual, NotEqualInputs} from '../kernel_names'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {makeTypesMatch} from '../tensor_util'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -import {assertAndGetBroadcastShape} from './broadcast_util'; -import {op} from './operation'; - -/** - * Returns the truth value of (a != b) element-wise. Supports broadcasting. - * - * ```js - * const a = tf.tensor1d([1, 2, 3]); - * const b = tf.tensor1d([0, 2, 3]); - * - * a.notEqual(b).print(); - * ``` - * @param a The first input tensor. - * @param b The second input tensor. Must have the same dtype as `a`. - * - * @doc {heading: 'Operations', subheading: 'Logical'} - */ -function notEqual_( - a: Tensor|TensorLike, b: Tensor|TensorLike): T { - let $a = convertToTensor(a, 'a', 'notEqual', 'string_or_numeric'); - let $b = convertToTensor(b, 'b', 'notEqual', 'string_or_numeric'); - [$a, $b] = makeTypesMatch($a, $b); - - assertAndGetBroadcastShape($a.shape, $b.shape); - - const inputs: NotEqualInputs = {a: $a, b: $b}; - - return ENGINE.runKernel(NotEqual, inputs as unknown as NamedTensorMap); -} - -export const notEqual = /* @__PURE__ */ op({notEqual_}); diff --git a/tfjs-master/tfjs-core/src/ops/not_equal_test.ts b/tfjs-master/tfjs-core/src/ops/not_equal_test.ts deleted file mode 100644 index af984e035..000000000 --- a/tfjs-master/tfjs-core/src/ops/not_equal_test.ts +++ /dev/null @@ -1,301 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose, expectArraysEqual} from '../test_util'; - -describeWithFlags('notEqual', ALL_ENVS, () => { - it('Tensor1D - int32', async () => { - let a = tf.tensor1d([1, 4, 5], 'int32'); - let b = tf.tensor1d([2, 3, 5], 'int32'); - - expectArraysClose(await tf.notEqual(a, b).data(), [1, 1, 0]); - - a = tf.tensor1d([2, 2, 2], 'int32'); - b = tf.tensor1d([2, 2, 2], 'int32'); - expectArraysClose(await tf.notEqual(a, b).data(), [0, 0, 0]); - - a = tf.tensor1d([0, 0], 'int32'); - b = tf.tensor1d([3, 3], 'int32'); - expectArraysClose(await tf.notEqual(a, b).data(), [1, 1]); - }); - it('Tensor1D - float32', async () => { - let a = tf.tensor1d([1.1, 4.1, 5.1], 'float32'); - let b = tf.tensor1d([2.2, 3.2, 5.1], 'float32'); - - expectArraysClose(await tf.notEqual(a, b).data(), [1, 1, 0]); - - a = tf.tensor1d([2.31, 2.31, 2.31], 'float32'); - b = tf.tensor1d([2.31, 2.31, 2.31], 'float32'); - expectArraysClose(await tf.notEqual(a, b).data(), [0, 0, 0]); - - a = tf.tensor1d([0.45, 0.123], 'float32'); - b = tf.tensor1d([3.123, 3.321], 'float32'); - expectArraysClose(await tf.notEqual(a, b).data(), [1, 1]); - }); - - it('upcasts when dtypes dont match', async () => { - const a = [1.1, 4.1, 5]; - const b = [2.2, 3.2, 5]; - - let res = - tf.notEqual(tf.tensor(a, [3], 'float32'), tf.tensor(b, [3], 'int32')); - expect(res.dtype).toBe('bool'); - expect(res.shape).toEqual([3]); - expectArraysClose(await res.data(), [1, 1, 0]); - - res = tf.notEqual(tf.tensor(a, [3], 'int32'), tf.tensor(b, [3], 'bool')); - expect(res.dtype).toBe('bool'); - expect(res.shape).toEqual([3]); - expectArraysClose(await res.data(), [0, 1, 1]); - }); - - it('TensorLike', async () => { - const a = [1.1, 4.1, 5.1]; - const b = [2.2, 3.2, 5.1]; - - expectArraysClose(await tf.notEqual(a, b).data(), [1, 1, 0]); - }); - it('TensorLike Chained', async () => { - const a = tf.tensor1d([1.1, 4.1, 5.1], 'float32'); - const b = [2.2, 3.2, 5.1]; - - expectArraysClose(await a.notEqual(b).data(), [1, 1, 0]); - }); - it('mismatched Tensor1D shapes - int32', () => { - const a = tf.tensor1d([1, 2], 'int32'); - const b = tf.tensor1d([1, 2, 3], 'int32'); - const f = () => { - tf.notEqual(a, b); - }; - expect(f).toThrowError(); - }); - it('mismatched Tensor1D shapes - float32', () => { - const a = tf.tensor1d([1.1, 2.1], 'float32'); - const b = tf.tensor1d([1.1, 2.1, 3.1], 'float32'); - const f = () => { - tf.notEqual(a, b); - }; - expect(f).toThrowError(); - }); - it('NaNs in Tensor1D - float32', async () => { - const a = tf.tensor1d([1.1, NaN, 2.1], 'float32'); - const b = tf.tensor1d([2.1, 3.1, NaN], 'float32'); - expectArraysClose(await tf.notEqual(a, b).data(), [1, 1, 1]); - }); - it('works with NaNs', async () => { - const a = tf.tensor1d([2, 5, NaN]); - const b = tf.tensor1d([4, 5, -1]); - - const res = tf.notEqual(a, b); - expect(res.dtype).toBe('bool'); - expectArraysEqual(await res.data(), [1, 0, 1]); - }); - it('scalar and 1D broadcast', async () => { - const a = tf.scalar(2); - const b = tf.tensor1d([1, 2, 3, 4, 5, 2]); - const res = tf.notEqual(a, b); - expect(res.dtype).toBe('bool'); - expect(res.shape).toEqual([6]); - expectArraysEqual(await res.data(), [1, 0, 1, 1, 1, 0]); - }); - - // Tensor2D: - it('Tensor2D - int32', async () => { - let a = tf.tensor2d([[1, 4, 5], [8, 9, 12]], [2, 3], 'int32'); - let b = tf.tensor2d([[2, 3, 6], [7, 10, 11]], [2, 3], 'int32'); - expectArraysClose(await tf.notEqual(a, b).data(), [1, 1, 1, 1, 1, 1]); - - a = tf.tensor2d([[0, 0], [1, 1]], [2, 2], 'int32'); - b = tf.tensor2d([[0, 0], [1, 1]], [2, 2], 'int32'); - expectArraysClose(await tf.notEqual(a, b).data(), [0, 0, 0, 0]); - }); - it('Tensor2D - float32', async () => { - let a = tf.tensor2d([[1.1, 4.1, 5.1], [8.1, 9.1, 12.1]], [2, 3], 'float32'); - let b = - tf.tensor2d([[2.1, 4.1, 5.1], [7.1, 10.1, 11.1]], [2, 3], 'float32'); - expectArraysClose(await tf.notEqual(a, b).data(), [1, 0, 0, 1, 1, 1]); - - a = tf.tensor2d([[0.2, 0.2], [1.2, 1.2]], [2, 2], 'float32'); - b = tf.tensor2d([[0.2, 0.2], [1.2, 1.2]], [2, 2], 'float32'); - expectArraysClose(await tf.notEqual(a, b).data(), [0, 0, 0, 0]); - }); - it('broadcasting Tensor2D shapes - int32', async () => { - const a = tf.tensor2d([[3], [7]], [2, 1], 'int32'); - const b = tf.tensor2d([[2, 3, 4], [7, 8, 9]], [2, 3], 'int32'); - expectArraysClose(await tf.notEqual(a, b).data(), [1, 0, 1, 0, 1, 1]); - }); - it('broadcasting Tensor2D shapes - float32', async () => { - const a = tf.tensor2d([[1.1], [7.1]], [2, 1], 'float32'); - const b = - tf.tensor2d([[0.1, 1.1, 2.1], [7.1, 8.1, 9.1]], [2, 3], 'float32'); - expectArraysClose(await tf.notEqual(a, b).data(), [1, 0, 1, 0, 1, 1]); - }); - it('NaNs in Tensor2D - float32', async () => { - const a = tf.tensor2d([[1.1, NaN], [1.1, NaN]], [2, 2], 'float32'); - const b = tf.tensor2d([[0.1, NaN], [1.1, NaN]], [2, 2], 'float32'); - expectArraysClose(await tf.notEqual(a, b).data(), [1, 1, 0, 1]); - }); - it('2D and scalar broadcast', async () => { - const a = tf.tensor2d([1, 2, 3, 2, 5, 6], [2, 3]); - const b = tf.scalar(2); - const res = tf.notEqual(a, b); - expect(res.dtype).toBe('bool'); - expect(res.shape).toEqual([2, 3]); - expectArraysEqual(await res.data(), [1, 0, 1, 0, 1, 1]); - }); - it('broadcasting Tensor2D shapes each with 1 dim', async () => { - const a = tf.tensor2d([1, 2, 5], [1, 3]); - const b = tf.tensor2d([5, 1], [2, 1]); - const res = tf.notEqual(a, b); - expect(res.dtype).toBe('bool'); - expect(res.shape).toEqual([2, 3]); - expectArraysEqual(await res.data(), [1, 1, 0, 0, 1, 1]); - }); - - // Tensor3D: - it('Tensor3D - int32', async () => { - let a = - tf.tensor3d([[[1], [4], [5]], [[8], [9], [12]]], [2, 3, 1], 'int32'); - let b = - tf.tensor3d([[[2], [3], [6]], [[7], [10], [12]]], [2, 3, 1], 'int32'); - expectArraysClose(await tf.notEqual(a, b).data(), [1, 1, 1, 1, 1, 0]); - - a = tf.tensor3d([[[0], [0], [0]], [[1], [1], [1]]], [2, 3, 1], 'int32'); - b = tf.tensor3d([[[0], [0], [0]], [[1], [1], [1]]], [2, 3, 1], 'int32'); - expectArraysClose(await tf.notEqual(a, b).data(), [0, 0, 0, 0, 0, 0]); - }); - it('Tensor3D - float32', async () => { - let a = tf.tensor3d( - [[[1.1], [4.1], [5.1]], [[8.1], [9.1], [12.1]]], [2, 3, 1], 'float32'); - let b = tf.tensor3d( - [[[2.1], [3.1], [6.1]], [[7.1], [10.1], [12.1]]], [2, 3, 1], 'float32'); - expectArraysClose(await tf.notEqual(a, b).data(), [1, 1, 1, 1, 1, 0]); - - a = tf.tensor3d( - [[[0.1], [0.1], [0.1]], [[1.1], [1.1], [1.1]]], [2, 3, 1], 'float32'); - b = tf.tensor3d( - [[[0.1], [0.1], [0.1]], [[1.1], [1.1], [1.1]]], [2, 3, 1], 'float32'); - expectArraysClose(await tf.notEqual(a, b).data(), [0, 0, 0, 0, 0, 0]); - }); - it('broadcasting Tensor3D shapes - int32', async () => { - const a = tf.tensor3d( - [[[1, 0], [2, 3], [4, 5]], [[6, 7], [9, 8], [10, 11]]], [2, 3, 2], - 'int32'); - const b = - tf.tensor3d([[[1], [2], [3]], [[7], [10], [9]]], [2, 3, 1], 'int32'); - expectArraysClose( - await tf.notEqual(a, b).data(), [0, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1]); - }); - it('broadcasting Tensor3D shapes - float32', async () => { - const a = tf.tensor3d( - [ - [[1.1, 0.1], [2.1, 3.1], [4.1, 5.1]], - [[6.1, 7.1], [9.1, 8.1], [10.1, 11.1]] - ], - [2, 3, 2], 'float32'); - const b = tf.tensor3d( - [[[1.1], [2.1], [3.1]], [[7.1], [10.1], [9.1]]], [2, 3, 1], 'float32'); - expectArraysClose( - await tf.notEqual(a, b).data(), [0, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1]); - }); - it('NaNs in Tensor3D - float32', async () => { - const a = tf.tensor3d( - [[[1.1], [NaN], [1.1]], [[0.1], [0.1], [0.1]]], [2, 3, 1], 'float32'); - const b = tf.tensor3d( - [[[0.1], [0.1], [1.1]], [[1.1], [0.1], [NaN]]], [2, 3, 1], 'float32'); - expectArraysClose(await tf.notEqual(a, b).data(), [1, 1, 0, 1, 0, 1]); - }); - it('3D and scalar', async () => { - const a = tf.tensor3d([1, 2, 3, 4, 5, -1], [2, 3, 1]); - const b = tf.scalar(-1); - const res = tf.notEqual(a, b); - expect(res.dtype).toBe('bool'); - expect(res.shape).toEqual([2, 3, 1]); - expectArraysEqual(await res.data(), [1, 1, 1, 1, 1, 0]); - }); - - // Tensor4D: - it('Tensor4D - int32', async () => { - let a = tf.tensor4d([1, 4, 5, 8], [2, 2, 1, 1], 'int32'); - let b = tf.tensor4d([2, 3, 6, 8], [2, 2, 1, 1], 'int32'); - expectArraysClose(await tf.notEqual(a, b).data(), [1, 1, 1, 0]); - - a = tf.tensor4d([0, 1, 2, 3], [2, 2, 1, 1], 'int32'); - b = tf.tensor4d([0, 1, 2, 3], [2, 2, 1, 1], 'int32'); - expectArraysClose(await tf.notEqual(a, b).data(), [0, 0, 0, 0]); - - a = tf.tensor4d([1, 1, 1, 1], [2, 2, 1, 1], 'int32'); - b = tf.tensor4d([2, 2, 2, 2], [2, 2, 1, 1], 'int32'); - expectArraysClose(await tf.notEqual(a, b).data(), [1, 1, 1, 1]); - }); - it('Tensor4D - float32', async () => { - let a = tf.tensor4d([1.1, 4.1, 5.1, 8.1], [2, 2, 1, 1], 'float32'); - let b = tf.tensor4d([2.1, 3.1, 6.1, 8.1], [2, 2, 1, 1], 'float32'); - expectArraysClose(await tf.notEqual(a, b).data(), [1, 1, 1, 0]); - - a = tf.tensor4d([0.1, 1.1, 2.2, 3.3], [2, 2, 1, 1], 'float32'); - b = tf.tensor4d([0.1, 1.1, 2.2, 3.3], [2, 2, 1, 1], 'float32'); - expectArraysClose(await tf.notEqual(a, b).data(), [0, 0, 0, 0]); - - a = tf.tensor4d([0.1, 0.1, 0.1, 0.1], [2, 2, 1, 1], 'float32'); - b = tf.tensor4d([1.1, 1.1, 1.1, 1.1], [2, 2, 1, 1], 'float32'); - expectArraysClose(await tf.notEqual(a, b).data(), [1, 1, 1, 1]); - }); - it('broadcasting Tensor4D shapes - int32', async () => { - const a = tf.tensor4d([1, 2, 5, 9], [2, 2, 1, 1], 'int32'); - const b = tf.tensor4d( - [[[[1, 2]], [[3, 4]]], [[[5, 6]], [[7, 8]]]], [2, 2, 1, 2], 'int32'); - expectArraysClose(await tf.notEqual(a, b).data(), [0, 1, 1, 1, 0, 1, 1, 1]); - }); - it('broadcasting Tensor4D shapes - float32', async () => { - const a = tf.tensor4d([1.1, 2.1, 5.1, 9.1], [2, 2, 1, 1], 'float32'); - const b = tf.tensor4d( - [[[[1.1, 2.1]], [[3.1, 4.1]]], [[[5.1, 6.1]], [[7.1, 8.1]]]], - [2, 2, 1, 2], 'float32'); - expectArraysClose(await tf.notEqual(a, b).data(), [0, 1, 1, 1, 0, 1, 1, 1]); - }); - it('NaNs in Tensor4D - float32', async () => { - const a = tf.tensor4d([1.1, NaN, 1.1, 0.1], [2, 2, 1, 1], 'float32'); - const b = tf.tensor4d([0.1, 1.1, 1.1, NaN], [2, 2, 1, 1], 'float32'); - expectArraysClose(await tf.notEqual(a, b).data(), [1, 1, 0, 1]); - }); - - it('throws when passed a as a non-tensor', () => { - expect(() => tf.notEqual({} as tf.Tensor, tf.scalar(1))) - .toThrowError(/Argument 'a' passed to 'notEqual' must be a Tensor/); - }); - it('throws when passed b as a non-tensor', () => { - expect(() => tf.notEqual(tf.scalar(1), {} as tf.Tensor)) - .toThrowError(/Argument 'b' passed to 'notEqual' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const a = tf.tensor1d([1, 4, 5], 'int32'); - const b = tf.tensor1d([2, 3, 5], 'int32'); - expectArraysClose(await tf.notEqual(a, b).data(), [1, 1, 0]); - }); - - it('should support string comparison', async () => { - const tensorA = tf.tensor('', [], 'string'); - const tensorB = tf.tensor(['a', 'b', ''], [3], 'string'); - const result = await tf.notEqual(tensorA, tensorB); - - expectArraysEqual(result.shape, [3]); - expectArraysEqual(await result.data(), [1, 1, 0]); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/one_hot.ts b/tfjs-master/tfjs-core/src/ops/one_hot.ts deleted file mode 100644 index dfbffc8cd..000000000 --- a/tfjs-master/tfjs-core/src/ops/one_hot.ts +++ /dev/null @@ -1,68 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {OneHot, OneHotAttrs, OneHotInputs} from '../kernel_names'; -import {NamedAttrMap} from '../kernel_registry'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {DataType, TensorLike} from '../types'; - -import {op} from './operation'; - -/** - * Creates a one-hot `tf.Tensor`. The locations represented by `indices` take - * value `onValue` (defaults to 1), while all other locations take value - * `offValue` (defaults to 0). If `indices` is rank `R`, the output has rank - * `R+1` with the last axis of size `depth`. - * `indices` used to encode prediction class must start from 0. For example, - * if you have 3 classes of data, class 1 should be encoded as 0, class 2 - * should be 1, and class 3 should be 2. - * - * ```js - * tf.oneHot(tf.tensor1d([0, 1], 'int32'), 3).print(); - * ``` - * - * @param indices `tf.Tensor` of indices with dtype `int32`. Indices must - * start from 0. - * @param depth The depth of the one hot dimension. - * @param onValue A number used to fill in the output when the index matches - * the location. - * @param offValue A number used to fill in the output when the index does - * not match the location. - * @param dtype The dtype of the output tensor, default to 'int32'. - * - * @doc {heading: 'Tensors', subheading: 'Creation'} - */ -function oneHot_( - indices: Tensor|TensorLike, depth: number, onValue = 1, offValue = 0, - dtype: DataType = 'int32'): Tensor { - if (depth < 2) { - throw new Error(`Error in oneHot: depth must be >=2, but it is ${depth}`); - } - const $indices = convertToTensor(indices, 'indices', 'oneHot', 'int32'); - - const inputs: OneHotInputs = {indices: $indices}; - const attrs: OneHotAttrs = {dtype, depth, onValue, offValue}; - - return ENGINE.runKernel( - OneHot, inputs as unknown as NamedTensorMap, - attrs as unknown as NamedAttrMap); -} - -export const oneHot = /* @__PURE__ */ op({oneHot_}); diff --git a/tfjs-master/tfjs-core/src/ops/one_hot_test.ts b/tfjs-master/tfjs-core/src/ops/one_hot_test.ts deleted file mode 100644 index 4cdfde974..000000000 --- a/tfjs-master/tfjs-core/src/ops/one_hot_test.ts +++ /dev/null @@ -1,172 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('oneHot', ALL_ENVS, () => { - it('Depth 1 throws error', () => { - const indices = tf.tensor1d([0, 0, 0], 'int32'); - expect(() => tf.oneHot(indices, 1)).toThrowError(); - }); - - it('Depth 2, diagonal', async () => { - const indices = tf.tensor1d([0, 1], 'int32'); - const res = tf.oneHot(indices, 2); - - expect(res.shape).toEqual([2, 2]); - expectArraysClose(await res.data(), [1, 0, 0, 1]); - }); - - it('Scalar input as Tensor', async () => { - const indices = tf.scalar(2, 'int32'); - const res = tf.oneHot(indices, 4); - - expect(res.shape).toEqual([4]); - expectArraysClose(await res.data(), [0, 0, 1, 0]); - }); - - it('Scalar input as number', async () => { - const indices = 2; - const res = tf.oneHot(indices, 4); - - expect(res.shape).toEqual([4]); - expectArraysClose(await res.data(), [0, 0, 1, 0]); - }); - - it('oneHot with chaining compiles', () => { - const indices = 2; - // Asserts that there is no compiler error. - tf.oneHot(indices, 4).toFloat(); - }); - - it('Depth 2, transposed diagonal', async () => { - const indices = tf.tensor1d([1, 0], 'int32'); - const res = tf.oneHot(indices, 2); - - expect(res.shape).toEqual([2, 2]); - expectArraysClose(await res.data(), [0, 1, 1, 0]); - }); - - it('Depth 3, 4 events', async () => { - const indices = tf.tensor1d([2, 1, 2, 0], 'int32'); - const res = tf.oneHot(indices, 3); - - expect(res.shape).toEqual([4, 3]); - expectArraysClose(await res.data(), [0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0]); - }); - - it('Out of range events do not trigger onValue', async () => { - const indices = tf.tensor1d([-1, 5, 12345], 'int32'); - const res = tf.oneHot(indices, 5); - expect(res.shape).toEqual([3, 5]); - expectArraysClose( - await res.data(), [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]); - }); - - it('Depth 2 onValue=3, offValue=-2', async () => { - const indices = tf.tensor1d([0, 1], 'int32'); - const res = tf.oneHot(indices, 2, 3, -2); - - expect(res.shape).toEqual([2, 2]); - expectArraysClose(await res.data(), [3, -2, -2, 3]); - }); - - it('indices not int32 throws error', () => { - const indices = tf.tensor1d([0, 1], 'float32'); - expect(() => tf.oneHot(indices, 2)).toThrowError(); - }); - - it('check output dtype', () => { - const expectedType = 'int32'; - const indices = tf.tensor1d([0, 1], 'int32'); - const res = tf.oneHot(indices, 2); - - expect(res.dtype).toEqual(expectedType); - }); - - it('check specified output dtype', () => { - const expectedType = 'float32'; - const indices = tf.tensor1d([0, 1], 'int32'); - const res = tf.oneHot(indices, 2, 1, 0, 'float32'); - - expect(res.dtype).toEqual(expectedType); - }); - - it('oneHot accepts a tensor-like object', async () => { - const res = tf.oneHot([0, 1], 2); - expect(res.shape).toEqual([2, 2]); - expectArraysClose(await res.data(), [1, 0, 0, 1]); - }); - - it('has gradient', async () => { - const a = tf.tensor1d([0, 1, 2], 'int32'); - const dy = tf.ones([3, 3], 'float32'); - const da = tf.grad((x: tf.Tensor1D) => tf.oneHot(x, 3))(a, dy); - - expect(da.dtype).toBe('float32'); - expect(da.shape).toEqual([3]); - expectArraysClose(await da.data(), [0, 0, 0]); - }); - - it('gradient with clones', async () => { - const a = tf.tensor1d([0, 1, 2], 'int32'); - const dy = tf.ones([3, 3], 'float32'); - const da = - tf.grad((x: tf.Tensor1D) => tf.oneHot(x.clone(), 3).clone())(a, dy); - - expect(da.dtype).toBe('float32'); - expect(da.shape).toEqual([3]); - expectArraysClose(await da.data(), [0, 0, 0]); - }); - - it('gradient when indices is 3d', async () => { - const a = tf.tensor3d([1, 2, 3, 4], [1, 2, 2], 'int32'); - const dy = tf.ones([1, 2, 2, 3], 'float32'); - const depth = 3; - const da = tf.grad(x => tf.oneHot(x, depth))(a, dy); - expect(da.dtype).toBe('float32'); - expect(da.shape).toEqual(a.shape); - expectArraysClose(await da.data(), [0, 0, 0, 0]); - }); - - it('oneHot with indices as 2d', async () => { - const indices = tf.tensor2d([[1, 3], [2, 3]], [2, 2], 'int32'); - const depth = 4; - const res = tf.oneHot(indices, depth); - expect(res.shape).toEqual([2, 2, depth]); - expectArraysClose( - await res.data(), [0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1]); - }); - - it('Supports chaining', async () => { - const indices = - tf.tensor2d([[1, 2, 3], [2, 3, 1], [4, 5, 6]], [3, 3], 'int32'); - const depth = 6; - const onValue = 3; - const offValue = 7; - const res = indices.oneHot(depth, onValue, offValue); - - expect(res.shape).toEqual([3, 3, 6]); - expectArraysClose(await res.data(), [ - 7, 3, 7, 7, 7, 7, 7, 7, 3, 7, 7, 7, 7, 7, 7, 3, 7, 7, - 7, 7, 3, 7, 7, 7, 7, 7, 7, 3, 7, 7, 7, 3, 7, 7, 7, 7, - 7, 7, 7, 7, 3, 7, 7, 7, 7, 7, 7, 3, 7, 7, 7, 7, 7, 7 - ]); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/ones.ts b/tfjs-master/tfjs-core/src/ops/ones.ts deleted file mode 100644 index 0946a9d87..000000000 --- a/tfjs-master/tfjs-core/src/ops/ones.ts +++ /dev/null @@ -1,49 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {Tensor} from '../tensor'; -import {DataType, Rank, ShapeMap} from '../types'; -import {makeOnesTypedArray, sizeFromShape} from '../util'; -import {assertNonNegativeIntegerDimensions} from '../util_base'; -import {complex} from './complex'; -import {zeros} from './zeros'; - -/** - * Creates a `tf.Tensor` with all elements set to 1. - * - * ```js - * tf.ones([2, 2]).print(); - * ``` - * - * @param shape An array of integers defining the output tensor shape. - * @param dtype The type of an element in the resulting tensor. Defaults to - * 'float'. - * - * @doc {heading: 'Tensors', subheading: 'Creation'} - */ -export function ones( - shape: ShapeMap[R], dtype: DataType = 'float32'): Tensor { - assertNonNegativeIntegerDimensions(shape); - if (dtype === 'complex64') { - const real = ones(shape, 'float32'); - const imag = zeros(shape, 'float32'); - return complex(real, imag); - } - const values = makeOnesTypedArray(sizeFromShape(shape), dtype); - return ENGINE.makeTensor(values, shape, dtype) as Tensor; -} diff --git a/tfjs-master/tfjs-core/src/ops/ones_like.ts b/tfjs-master/tfjs-core/src/ops/ones_like.ts deleted file mode 100644 index f9e6ba1a8..000000000 --- a/tfjs-master/tfjs-core/src/ops/ones_like.ts +++ /dev/null @@ -1,46 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {OnesLike, OnesLikeInputs} from '../kernel_names'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -import {op} from './operation'; - -/** - * Creates a `tf.Tensor` with all elements set to 1 with the same shape as the - * given tensor. - * - * ```js - * const x = tf.tensor([1, 2]); - * tf.onesLike(x).print(); - * ``` - * @param x A tensor. - * - * @doc {heading: 'Tensors', subheading: 'Creation'} - */ -function onesLike_(x: T|TensorLike): T { - const $x = convertToTensor(x, 'x', 'onesLike'); - - const inputs: OnesLikeInputs = {x: $x}; - return ENGINE.runKernel(OnesLike, inputs as unknown as NamedTensorMap); -} - -export const onesLike = /* @__PURE__ */ op({onesLike_}); diff --git a/tfjs-master/tfjs-core/src/ops/ones_like_test.ts b/tfjs-master/tfjs-core/src/ops/ones_like_test.ts deleted file mode 100644 index 6addedd71..000000000 --- a/tfjs-master/tfjs-core/src/ops/ones_like_test.ts +++ /dev/null @@ -1,308 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose, expectArraysEqual} from '../test_util'; - -describeWithFlags('onesLike', ALL_ENVS, () => { - it('1D default dtype', async () => { - const a = tf.tensor1d([1, 2, 3]); - const b = tf.onesLike(a); - expect(b.dtype).toBe('float32'); - expect(b.shape).toEqual([3]); - expectArraysClose(await b.data(), [1, 1, 1]); - }); - - it('chainable 1D default dtype', async () => { - const a = tf.tensor1d([1, 2, 3]); - const b = a.onesLike(); - expect(b.dtype).toBe('float32'); - expect(b.shape).toEqual([3]); - expectArraysClose(await b.data(), [1, 1, 1]); - }); - - it('1D float32 dtype', async () => { - const a = tf.tensor1d([1, 2, 3], 'float32'); - const b = tf.onesLike(a); - expect(b.dtype).toBe('float32'); - expect(b.shape).toEqual([3]); - expectArraysClose(await b.data(), [1, 1, 1]); - }); - - it('1D int32 dtype', async () => { - const a = tf.tensor1d([1, 2, 3], 'int32'); - const b = tf.onesLike(a); - expect(b.dtype).toBe('int32'); - expect(b.shape).toEqual([3]); - expectArraysEqual(await b.data(), [1, 1, 1]); - }); - - it('1D bool dtype', async () => { - const a = tf.tensor1d([1, 2, 3], 'bool'); - const b = tf.onesLike(a); - expect(b.dtype).toBe('bool'); - expect(b.shape).toEqual([3]); - expectArraysEqual(await b.data(), [1, 1, 1]); - }); - - it('1D complex dtype', async () => { - const real = tf.tensor1d([1, 2, 3], 'float32'); - const imag = tf.tensor1d([1, 2, 3], 'float32'); - const a = tf.complex(real, imag); - const b = tf.onesLike(a); - expect(b.dtype).toBe('complex64'); - expect(b.shape).toEqual([3]); - expectArraysEqual(await b.data(), [1, 0, 1, 0, 1, 0]); - }); - - it('2D default dtype', async () => { - const a = tf.tensor2d([1, 2, 3, 4], [2, 2]); - const b = tf.onesLike(a); - expect(b.dtype).toBe('float32'); - expect(b.shape).toEqual([2, 2]); - expectArraysClose(await b.data(), [1, 1, 1, 1]); - }); - - it('2D float32 dtype', async () => { - const a = tf.tensor2d([1, 2, 3, 4], [2, 2], 'float32'); - const b = tf.onesLike(a); - expect(b.dtype).toBe('float32'); - expect(b.shape).toEqual([2, 2]); - expectArraysClose(await b.data(), [1, 1, 1, 1]); - }); - - it('2D int32 dtype', async () => { - const a = tf.tensor2d([1, 2, 3, 4], [2, 2], 'int32'); - const b = tf.onesLike(a); - expect(b.dtype).toBe('int32'); - expect(b.shape).toEqual([2, 2]); - expectArraysEqual(await b.data(), [1, 1, 1, 1]); - }); - - it('2D bool dtype', async () => { - const a = tf.tensor2d([1, 2, 3, 4], [2, 2], 'bool'); - const b = tf.onesLike(a); - expect(b.dtype).toBe('bool'); - expect(b.shape).toEqual([2, 2]); - expectArraysEqual(await b.data(), [1, 1, 1, 1]); - }); - - it('2D complex dtype', async () => { - const real = tf.tensor2d([1, 2, 3, 4], [2, 2], 'float32'); - const imag = tf.tensor2d([1, 2, 3, 4], [2, 2], 'float32'); - const a = tf.complex(real, imag); - const b = tf.onesLike(a); - expect(b.dtype).toBe('complex64'); - expect(b.shape).toEqual([2, 2]); - expectArraysEqual(await b.data(), [1, 0, 1, 0, 1, 0, 1, 0]); - }); - - it('3D default dtype', async () => { - const a = tf.tensor3d([1, 2, 3, 4], [2, 2, 1]); - const b = tf.onesLike(a); - expect(b.dtype).toBe('float32'); - expect(b.shape).toEqual([2, 2, 1]); - expectArraysClose(await b.data(), [1, 1, 1, 1]); - }); - - it('3D float32 dtype', async () => { - const a = tf.tensor3d([1, 2, 3, 4], [2, 2, 1], 'float32'); - const b = tf.onesLike(a); - expect(b.dtype).toBe('float32'); - expect(b.shape).toEqual([2, 2, 1]); - expectArraysClose(await b.data(), [1, 1, 1, 1]); - }); - - it('3D int32 dtype', async () => { - const a = tf.tensor3d([1, 2, 3, 4], [2, 2, 1], 'int32'); - const b = tf.onesLike(a); - expect(b.dtype).toBe('int32'); - expect(b.shape).toEqual([2, 2, 1]); - expectArraysEqual(await b.data(), [1, 1, 1, 1]); - }); - - it('3D bool dtype', async () => { - const a = tf.tensor3d([1, 2, 3, 4], [2, 2, 1], 'bool'); - const b = tf.onesLike(a); - expect(b.dtype).toBe('bool'); - expect(b.shape).toEqual([2, 2, 1]); - expectArraysEqual(await b.data(), [1, 1, 1, 1]); - }); - - it('3D complex dtype', async () => { - const real = tf.tensor3d([1, 2, 3, 4], [2, 2, 1], 'float32'); - const imag = tf.tensor3d([1, 2, 3, 4], [2, 2, 1], 'float32'); - const a = tf.complex(real, imag); - const b = tf.onesLike(a); - expect(b.dtype).toBe('complex64'); - expect(b.shape).toEqual([2, 2, 1]); - expectArraysEqual(await b.data(), [1, 0, 1, 0, 1, 0, 1, 0]); - }); - - it('4D default dtype', async () => { - const a = tf.tensor4d([1, 2, 3, 4], [2, 2, 1, 1]); - const b = tf.onesLike(a); - expect(b.dtype).toBe('float32'); - expect(b.shape).toEqual([2, 2, 1, 1]); - expectArraysClose(await b.data(), [1, 1, 1, 1]); - }); - - it('4D float32 dtype', async () => { - const a = tf.tensor4d([1, 2, 3, 4], [2, 2, 1, 1], 'float32'); - const b = tf.onesLike(a); - expect(b.dtype).toBe('float32'); - expect(b.shape).toEqual([2, 2, 1, 1]); - expectArraysClose(await b.data(), [1, 1, 1, 1]); - }); - - it('4D int32 dtype', async () => { - const a = tf.tensor4d([1, 2, 3, 4], [2, 2, 1, 1], 'int32'); - const b = tf.onesLike(a); - expect(b.dtype).toBe('int32'); - expect(b.shape).toEqual([2, 2, 1, 1]); - expectArraysEqual(await b.data(), [1, 1, 1, 1]); - }); - - it('4D bool dtype', async () => { - const a = tf.tensor4d([1, 2, 3, 4], [2, 2, 1, 1], 'bool'); - const b = tf.onesLike(a); - expect(b.dtype).toBe('bool'); - expect(b.shape).toEqual([2, 2, 1, 1]); - expectArraysEqual(await b.data(), [1, 1, 1, 1]); - }); - - it('4D default dtype', async () => { - const a = tf.tensor4d([1, 2, 3, 4], [2, 2, 1, 1]); - const b = tf.onesLike(a); - expect(b.dtype).toBe('float32'); - expect(b.shape).toEqual([2, 2, 1, 1]); - expectArraysClose(await b.data(), [1, 1, 1, 1]); - }); - - it('4D complex dtype', async () => { - const real = tf.tensor4d([1, 2, 3, 4], [2, 2, 1, 1], 'float32'); - const imag = tf.tensor4d([1, 2, 3, 4], [2, 2, 1, 1], 'float32'); - const a = tf.complex(real, imag); - const b = tf.onesLike(a); - expect(b.dtype).toBe('complex64'); - expect(b.shape).toEqual([2, 2, 1, 1]); - expectArraysEqual(await b.data(), [1, 0, 1, 0, 1, 0, 1, 0]); - }); - - it('5D float32 dtype', async () => { - const a = tf.tensor5d([1, 2, 3, 4], [1, 2, 2, 1, 1], 'float32'); - const b = tf.onesLike(a); - expect(b.dtype).toBe('float32'); - expect(b.shape).toEqual([1, 2, 2, 1, 1]); - expectArraysClose(await b.data(), [1, 1, 1, 1]); - }); - - it('5D int32 dtype', async () => { - const a = tf.tensor5d([1, 2, 3, 4], [1, 2, 2, 1, 1], 'int32'); - const b = tf.onesLike(a); - expect(b.dtype).toBe('int32'); - expect(b.shape).toEqual([1, 2, 2, 1, 1]); - expectArraysEqual(await b.data(), [1, 1, 1, 1]); - }); - - it('5D bool dtype', async () => { - const a = tf.tensor5d([1, 2, 3, 4], [1, 2, 2, 1, 1], 'bool'); - const b = tf.onesLike(a); - expect(b.dtype).toBe('bool'); - expect(b.shape).toEqual([1, 2, 2, 1, 1]); - expectArraysEqual(await b.data(), [1, 1, 1, 1]); - }); - - it('5D default dtype', async () => { - const a = tf.tensor5d([1, 2, 3, 4], [1, 2, 2, 1, 1]); - const b = tf.onesLike(a); - expect(b.dtype).toBe('float32'); - expect(b.shape).toEqual([1, 2, 2, 1, 1]); - expectArraysClose(await b.data(), [1, 1, 1, 1]); - }); - - it('5D complex dtype', async () => { - const real = tf.tensor5d([1, 2, 3, 4], [1, 2, 2, 1, 1], 'float32'); - const imag = tf.tensor5d([1, 2, 3, 4], [1, 2, 2, 1, 1], 'float32'); - const a = tf.complex(real, imag); - const b = tf.onesLike(a); - expect(b.dtype).toBe('complex64'); - expect(b.shape).toEqual([1, 2, 2, 1, 1]); - expectArraysEqual(await b.data(), [1, 0, 1, 0, 1, 0, 1, 0]); - }); - - it('6D int32 dtype', async () => { - const a = tf.tensor6d([1, 2, 3, 4], [1, 2, 2, 1, 1, 1], 'int32'); - const b = tf.onesLike(a); - expect(b.dtype).toBe('int32'); - expect(b.shape).toEqual(a.shape); - expectArraysEqual(await b.data(), [1, 1, 1, 1]); - }); - - it('6D bool dtype', async () => { - const a = tf.tensor6d([1, 2, 3, 4], [1, 2, 2, 1, 1, 1], 'bool'); - const b = tf.onesLike(a); - expect(b.dtype).toBe('bool'); - expect(b.shape).toEqual(a.shape); - expectArraysEqual(await b.data(), [1, 1, 1, 1]); - }); - - it('6D default dtype', async () => { - const a = tf.tensor6d([1, 2, 3, 4], [1, 2, 2, 1, 1, 1]); - const b = tf.onesLike(a); - expect(b.dtype).toBe('float32'); - expect(b.shape).toEqual(a.shape); - expectArraysClose(await b.data(), [1, 1, 1, 1]); - }); - - it('6D float32 dtype', async () => { - const a = tf.tensor6d([1, 2, 3, 4], [1, 2, 2, 1, 1, 1], 'float32'); - const b = tf.onesLike(a); - expect(b.dtype).toBe('float32'); - expect(b.shape).toEqual(a.shape); - expectArraysClose(await b.data(), [1, 1, 1, 1]); - }); - - it('6D complex dtype', async () => { - const real = tf.tensor6d([1, 2, 3, 4], [1, 2, 2, 1, 1, 1], 'float32'); - const imag = tf.tensor6d([1, 2, 3, 4], [1, 2, 2, 1, 1, 1], 'float32'); - const a = tf.complex(real, imag); - const b = tf.onesLike(a); - expect(b.dtype).toBe('complex64'); - expect(b.shape).toEqual([1, 2, 2, 1, 1, 1]); - expectArraysEqual(await b.data(), [1, 0, 1, 0, 1, 0, 1, 0]); - }); - - it('throws when passed a non-tensor', () => { - expect(() => tf.onesLike({} as tf.Tensor)) - .toThrowError(/Argument 'x' passed to 'onesLike' must be a Tensor/); - }); - - it('onesLike gradient', async () => { - const x = tf.tensor2d([[0, 1, 2], [4, 5, 6]]); - const gradients = tf.grad(x => tf.onesLike(x))(x); - expect(gradients.shape).toEqual([2, 3]); - expectArraysEqual(await gradients.data(), [0, 0, 0, 0, 0, 0]); - }); - - it('accepts a tensor-like object', async () => { - const res = tf.onesLike([[1, 2], [3, 4]]); - expect(res.shape).toEqual([2, 2]); - expectArraysEqual(await res.data(), [1, 1, 1, 1]); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/ones_test.ts b/tfjs-master/tfjs-core/src/ops/ones_test.ts deleted file mode 100644 index 2550c561d..000000000 --- a/tfjs-master/tfjs-core/src/ops/ones_test.ts +++ /dev/null @@ -1,138 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose, expectArraysEqual} from '../test_util'; - -describeWithFlags('ones', ALL_ENVS, () => { - it('1D default dtype', async () => { - const a = tf.ones([3]); - expect(a.dtype).toBe('float32'); - expect(a.shape).toEqual([3]); - expectArraysClose(await a.data(), [1, 1, 1]); - }); - - it('1D float32 dtype', async () => { - const a = tf.ones([3], 'float32'); - expect(a.dtype).toBe('float32'); - expect(a.shape).toEqual([3]); - expectArraysClose(await a.data(), [1, 1, 1]); - }); - - it('1D int32 dtype', async () => { - const a = tf.ones([3], 'int32'); - expect(a.dtype).toBe('int32'); - expect(a.shape).toEqual([3]); - expectArraysEqual(await a.data(), [1, 1, 1]); - }); - - it('1D bool dtype', async () => { - const a = tf.ones([3], 'bool'); - expect(a.dtype).toBe('bool'); - expect(a.shape).toEqual([3]); - expectArraysEqual(await a.data(), [1, 1, 1]); - }); - - it('2D default dtype', async () => { - const a = tf.ones([3, 2]); - expect(a.dtype).toBe('float32'); - expect(a.shape).toEqual([3, 2]); - expectArraysClose(await a.data(), [1, 1, 1, 1, 1, 1]); - }); - - it('2D float32 dtype', async () => { - const a = tf.ones([3, 2], 'float32'); - expect(a.dtype).toBe('float32'); - expect(a.shape).toEqual([3, 2]); - expectArraysClose(await a.data(), [1, 1, 1, 1, 1, 1]); - }); - - it('2D int32 dtype', async () => { - const a = tf.ones([3, 2], 'int32'); - expect(a.dtype).toBe('int32'); - expect(a.shape).toEqual([3, 2]); - expectArraysEqual(await a.data(), [1, 1, 1, 1, 1, 1]); - }); - - it('2D bool dtype', async () => { - const a = tf.ones([3, 2], 'bool'); - expect(a.dtype).toBe('bool'); - expect(a.shape).toEqual([3, 2]); - expectArraysEqual(await a.data(), [1, 1, 1, 1, 1, 1]); - }); - - it('3D default dtype', async () => { - const a = tf.ones([2, 2, 2]); - expect(a.dtype).toBe('float32'); - expect(a.shape).toEqual([2, 2, 2]); - expectArraysClose(await a.data(), [1, 1, 1, 1, 1, 1, 1, 1]); - }); - - it('3D float32 dtype', async () => { - const a = tf.ones([2, 2, 2], 'float32'); - expect(a.dtype).toBe('float32'); - expect(a.shape).toEqual([2, 2, 2]); - expectArraysClose(await a.data(), [1, 1, 1, 1, 1, 1, 1, 1]); - }); - - it('3D int32 dtype', async () => { - const a = tf.ones([2, 2, 2], 'int32'); - expect(a.dtype).toBe('int32'); - expect(a.shape).toEqual([2, 2, 2]); - expectArraysEqual(await a.data(), [1, 1, 1, 1, 1, 1, 1, 1]); - }); - - it('3D bool dtype', async () => { - const a = tf.ones([2, 2, 2], 'bool'); - expect(a.dtype).toBe('bool'); - expect(a.shape).toEqual([2, 2, 2]); - expectArraysEqual(await a.data(), [1, 1, 1, 1, 1, 1, 1, 1]); - }); - - it('4D default dtype', async () => { - const a = tf.ones([3, 2, 1, 1]); - expect(a.dtype).toBe('float32'); - expect(a.shape).toEqual([3, 2, 1, 1]); - expectArraysClose(await a.data(), [1, 1, 1, 1, 1, 1]); - }); - - it('4D float32 dtype', async () => { - const a = tf.ones([3, 2, 1, 1], 'float32'); - expect(a.dtype).toBe('float32'); - expect(a.shape).toEqual([3, 2, 1, 1]); - expectArraysClose(await a.data(), [1, 1, 1, 1, 1, 1]); - }); - - it('4D int32 dtype', async () => { - const a = tf.ones([3, 2, 1, 1], 'int32'); - expect(a.dtype).toBe('int32'); - expect(a.shape).toEqual([3, 2, 1, 1]); - expectArraysEqual(await a.data(), [1, 1, 1, 1, 1, 1]); - }); - - it('4D bool dtype', async () => { - const a = tf.ones([3, 2, 1, 1], 'bool'); - expect(a.dtype).toBe('bool'); - expect(a.shape).toEqual([3, 2, 1, 1]); - expectArraysEqual(await a.data(), [1, 1, 1, 1, 1, 1]); - }); - - it('should throw error when shape is not integer', () => { - expect(() => tf.ones([2, 2.22, 3.33])).toThrow(); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/operation.ts b/tfjs-master/tfjs-core/src/ops/operation.ts deleted file mode 100644 index 50aa9e8c9..000000000 --- a/tfjs-master/tfjs-core/src/ops/operation.ts +++ /dev/null @@ -1,66 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {ENGINE} from '../engine'; -import {isPromise} from '../util'; - -export const OP_SCOPE_SUFFIX = '__op'; - -/** - * Used for wrapping functions that perform math operations on - * Tensors. The function will be wrapped in a named scope that cleans all - * memory usage after the function is done. - */ -export function op(f: {[name: string]: T}): T { - const keys = Object.keys(f); - if (keys.length !== 1) { - throw new Error( - `Please provide an object with a single key ` + - `(operation name) mapping to a function. Got an object with ` + - `${keys.length} keys.`); - } - - let opName = keys[0]; - const fn = f[opName]; - - // Strip the underscore from the end of the function name. - if (opName.endsWith('_')) { - opName = opName.substring(0, opName.length - 1); - } - - // add an __op suffix to distinguish ops from kernels in tf.profile - opName = opName + OP_SCOPE_SUFFIX; - - // tslint:disable-next-line:no-any - const f2 = (...args: any[]) => { - ENGINE.startScope(opName); - try { - const result = fn(...args); - if (isPromise(result)) { - console.error('Cannot return a Promise inside of tidy.'); - } - ENGINE.endScope(result); - return result; - } catch (ex) { - ENGINE.endScope(null); - throw ex; - } - }; - Object.defineProperty(f2, 'name', {value: opName, configurable: true}); - - // tslint:disable-next-line:no-any - return f2 as any as T; -} diff --git a/tfjs-master/tfjs-core/src/ops/operation_test.ts b/tfjs-master/tfjs-core/src/ops/operation_test.ts deleted file mode 100644 index 80d274102..000000000 --- a/tfjs-master/tfjs-core/src/ops/operation_test.ts +++ /dev/null @@ -1,42 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {op} from './operation'; - -describeWithFlags('operation', ALL_ENVS, () => { - it('executes and preserves function name', () => { - const f = () => 2; - const opfn = /* @__PURE__ */ op({'opName': f}); - - expect(opfn.name).toBe('opName__op'); - expect(opfn()).toBe(2); - }); - - it('executes, preserves function name, strips underscore', () => { - const f = () => 2; - const opfn = /* @__PURE__ */ op({'opName_': f}); - - expect(opfn.name).toBe('opName__op'); - expect(opfn()).toBe(2); - }); - - it('throws when passing an object with multiple keys', () => { - const f = () => 2; - expect(() => op({'opName_': f, 'opName2_': f})) - .toThrowError(/Please provide an object with a single key/); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/ops.ts b/tfjs-master/tfjs-core/src/ops/ops.ts deleted file mode 100644 index 0fbf5dcee..000000000 --- a/tfjs-master/tfjs-core/src/ops/ops.ts +++ /dev/null @@ -1,343 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// Modularized ops. -export {abs} from './abs'; -export {acos} from './acos'; -export {acosh} from './acosh'; -export {add} from './add'; -export {addN} from './add_n'; -export {all} from './all'; -export {any} from './any'; -export {argMax} from './arg_max'; -export {argMin} from './arg_min'; -export {asin} from './asin'; -export {asinh} from './asinh'; -export {atan} from './atan'; -export {atan2} from './atan2'; -export {atanh} from './atanh'; -export {avgPool} from './avg_pool'; -export {avgPool3d} from './avg_pool_3d'; -export {basicLSTMCell} from './basic_lstm_cell'; -export {batchToSpaceND} from './batch_to_space_nd'; -export {batchNorm} from './batchnorm'; -export {batchNorm2d} from './batchnorm2d'; -export {batchNorm3d} from './batchnorm3d'; -export {batchNorm4d} from './batchnorm4d'; -export {bincount} from './bincount'; -export {bitwiseAnd} from './bitwise_and'; -export {broadcastArgs} from './broadcast_args'; -export {broadcastTo} from './broadcast_to'; -export {buffer} from './buffer'; -export {cast} from './cast'; -export {ceil} from './ceil'; -export {clipByValue} from './clip_by_value'; -export {clone} from './clone'; -export {complex} from './complex'; -export {concat} from './concat'; -export {concat1d} from './concat_1d'; -export {concat2d} from './concat_2d'; -export {concat3d} from './concat_3d'; -export {concat4d} from './concat_4d'; -export {conv1d} from './conv1d'; -export {conv2d} from './conv2d'; -export {conv2dTranspose} from './conv2d_transpose'; -export {conv3d} from './conv3d'; -export {conv3dTranspose} from './conv3d_transpose'; -export {cos} from './cos'; -export {cosh} from './cosh'; -export {cumprod} from './cumprod'; -export {cumsum} from './cumsum'; -export {denseBincount} from './dense_bincount'; -export {depthToSpace} from './depth_to_space'; -export {depthwiseConv2d} from './depthwise_conv2d'; -export {diag} from './diag'; -export {dilation2d} from './dilation2d'; -export {div} from './div'; -export {divNoNan} from './div_no_nan'; -export {dot} from './dot'; -export {einsum} from './einsum'; -export {elu} from './elu'; -export {ensureShape} from './ensure_shape'; -export {equal} from './equal'; -export {erf} from './erf'; -export {euclideanNorm} from './euclidean_norm'; -export {exp} from './exp'; -export {expandDims} from './expand_dims'; -export {expm1} from './expm1'; -export {eye} from './eye'; -export {fill} from './fill'; -export {floor} from './floor'; -export {floorDiv} from './floorDiv'; -export {gather} from './gather'; -export {greater} from './greater'; -export {greaterEqual} from './greater_equal'; -export {imag} from './imag'; -export {isFinite} from './is_finite'; -export {isInf} from './is_inf'; -export {isNaN} from './is_nan'; -export {leakyRelu} from './leaky_relu'; -export {less} from './less'; -export {lessEqual} from './less_equal'; -export {linspace} from './linspace'; -export {localResponseNormalization} from './local_response_normalization'; -export {log} from './log'; -export {log1p} from './log1p'; -export {logSigmoid} from './log_sigmoid'; -export {logSoftmax} from './log_softmax'; -export {logSumExp} from './log_sum_exp'; -export {logicalAnd} from './logical_and'; -export {logicalNot} from './logical_not'; -export {logicalOr} from './logical_or'; -export {logicalXor} from './logical_xor'; -export {lowerBound} from './lower_bound'; -export {matMul} from './mat_mul'; -export {max} from './max'; -export {maxPool} from './max_pool'; -export {maxPool3d} from './max_pool_3d'; -export {maxPoolWithArgmax} from './max_pool_with_argmax'; -export {maximum} from './maximum'; -export {mean} from './mean'; -export {meshgrid} from './meshgrid'; -export {min} from './min'; -export {minimum} from './minimum'; -export {mirrorPad} from './mirror_pad'; -export {mod} from './mod'; -export {moments} from './moments'; -export {mul} from './mul'; -export {LSTMCellFunc, multiRNNCell} from './multi_rnn_cell'; -export {multinomial} from './multinomial'; -export {neg} from './neg'; -export {notEqual} from './not_equal'; -export {oneHot} from './one_hot'; -export {ones} from './ones'; -export {onesLike} from './ones_like'; -export {outerProduct} from './outer_product'; -export {pad} from './pad'; -export {pad1d} from './pad1d'; -export {pad2d} from './pad2d'; -export {pad3d} from './pad3d'; -export {pad4d} from './pad4d'; -export {pool} from './pool'; -export {pow} from './pow'; -export {prelu} from './prelu'; -export {print} from './print'; -export {prod} from './prod'; -export {raggedGather} from './ragged_gather'; -export {raggedRange} from './ragged_range'; -export {raggedTensorToTensor} from './ragged_tensor_to_tensor'; -export {rand} from './rand'; -export {randomGamma} from './random_gamma'; -export {randomNormal} from './random_normal'; -export {randomStandardNormal} from './random_standard_normal'; -export {randomUniform} from './random_uniform'; -export {randomUniformInt} from './random_uniform_int'; -export {range} from './range'; -export {real} from './real'; -export {reciprocal} from './reciprocal'; -export {relu} from './relu'; -export {relu6} from './relu6'; -export {reshape} from './reshape'; -export {reverse} from './reverse'; -export {reverse1d} from './reverse_1d'; -export {reverse2d} from './reverse_2d'; -export {reverse3d} from './reverse_3d'; -export {reverse4d} from './reverse_4d'; -export {round} from './round'; -export {rsqrt} from './rsqrt'; -export {scalar} from './scalar'; -export {selu} from './selu'; -export {separableConv2d} from './separable_conv2d'; -export {setdiff1dAsync} from './setdiff1d_async'; -export {sigmoid} from './sigmoid'; -export {sign} from './sign'; -export {sin} from './sin'; -export {sinh} from './sinh'; -export {slice} from './slice'; -export {slice1d} from './slice1d'; -export {slice2d} from './slice2d'; -export {slice3d} from './slice3d'; -export {slice4d} from './slice4d'; -export {softmax} from './softmax'; -export {softplus} from './softplus'; -export {spaceToBatchND} from './space_to_batch_nd'; -export {fft} from './spectral/fft'; -export {ifft} from './spectral/ifft'; -export {irfft} from './spectral/irfft'; -export {rfft} from './spectral/rfft'; -export {split} from './split'; -export {sqrt} from './sqrt'; -export {square} from './square'; -export {squaredDifference} from './squared_difference'; -export {squeeze} from './squeeze'; -export {stack} from './stack'; -export {step} from './step'; -export {stridedSlice} from './strided_slice'; -export {sub} from './sub'; -export {sum} from './sum'; -export {tan} from './tan'; -export {tanh} from './tanh'; -export {tensor} from './tensor'; -export {tensor1d} from './tensor1d'; -export {tensor2d} from './tensor2d'; -export {tensor3d} from './tensor3d'; -export {tensor4d} from './tensor4d'; -export {tensor5d} from './tensor5d'; -export {tensor6d} from './tensor6d'; -export {tensorScatterUpdate} from './tensor_scatter_update'; -export {tile} from './tile'; -export {topk} from './topk'; -export {truncatedNormal} from './truncated_normal'; -export {unique} from './unique'; -export {unsortedSegmentSum} from './unsorted_segment_sum'; -export {unstack} from './unstack'; -export {upperBound} from './upper_bound'; -export {variable} from './variable'; -export {where} from './where'; -export {whereAsync} from './where_async'; -export {zeros} from './zeros'; -export {zerosLike} from './zeros_like'; - -export * from './boolean_mask'; -export * from './transpose'; -export * from './norm'; -export * from './moving_average'; -export * from './scatter_nd'; -export * from './search_sorted'; -export * from './sparse_to_dense'; -export * from './gather_nd'; -export * from './dropout'; -export * from './signal_ops_util'; -export * from './in_top_k'; - -export {op, OP_SCOPE_SUFFIX} from './operation'; - -import {rfft} from './spectral/rfft'; -import {fft} from './spectral/fft'; -import {ifft} from './spectral/ifft'; -import {irfft} from './spectral/irfft'; -const spectral = { - fft, - ifft, - rfft, - irfft -}; - -import * as fused from './fused_ops'; - -import {hammingWindow} from './signal/hamming_window'; -import {hannWindow} from './signal/hann_window'; -import {frame} from './signal/frame'; -import {stft} from './signal/stft'; -const signal = { - hammingWindow, - hannWindow, - frame, - stft, -}; - -// Image Ops namespace -import {cropAndResize} from './image/crop_and_resize'; -import {flipLeftRight} from './image/flip_left_right'; -import {grayscaleToRGB} from './image/grayscale_to_rgb'; -import {rgbToGrayscale} from './image/rgb_to_grayscale'; -import {rotateWithOffset} from './image/rotate_with_offset'; -import {nonMaxSuppression} from './image/non_max_suppression'; -import {nonMaxSuppressionAsync} from './image/non_max_suppression_async'; -import {nonMaxSuppressionWithScore} from './image/non_max_suppression_with_score'; -import {nonMaxSuppressionWithScoreAsync} from './image/non_max_suppression_with_score_async'; -import {nonMaxSuppressionPadded} from './image/non_max_suppression_padded'; -import {nonMaxSuppressionPaddedAsync} from './image/non_max_suppression_padded_async'; -import {resizeBilinear} from './image/resize_bilinear'; -import {resizeNearestNeighbor} from './image/resize_nearest_neighbor'; -import {threshold} from './image/threshold'; -import {transform} from './image/transform'; -const image = { - flipLeftRight, - grayscaleToRGB, - resizeNearestNeighbor, - resizeBilinear, - rgbToGrayscale, - rotateWithOffset, - cropAndResize, - nonMaxSuppression, - nonMaxSuppressionAsync, - nonMaxSuppressionWithScore, - nonMaxSuppressionWithScoreAsync, - nonMaxSuppressionPadded, - nonMaxSuppressionPaddedAsync, - threshold, - transform -}; - -// linalg namespace -import {bandPart} from './linalg/band_part'; -import {gramSchmidt} from './linalg/gram_schmidt'; -import {qr} from './linalg/qr'; -const linalg = { - bandPart, - gramSchmidt, - qr -}; - -// losses namespace; -import {absoluteDifference} from './losses/absolute_difference'; -import {computeWeightedLoss} from './losses/compute_weighted_loss'; -import {cosineDistance} from './losses/cosine_distance'; -import {hingeLoss} from './losses/hinge_loss'; -import {huberLoss} from './losses/huber_loss'; -import {logLoss} from './losses/log_loss'; -import {meanSquaredError} from './losses/mean_squared_error'; -import {sigmoidCrossEntropy} from './losses/sigmoid_cross_entropy'; -import {softmaxCrossEntropy} from './losses/softmax_cross_entropy'; -const losses = { - absoluteDifference, - computeWeightedLoss, - cosineDistance, - hingeLoss, - huberLoss, - logLoss, - meanSquaredError, - sigmoidCrossEntropy, - softmaxCrossEntropy -}; - -import {sparseFillEmptyRows} from './sparse/sparse_fill_empty_rows'; -import {sparseReshape} from './sparse/sparse_reshape'; -import {sparseSegmentMean} from './sparse/sparse_segment_mean'; -import {sparseSegmentSum} from './sparse/sparse_segment_sum'; -const sparse = { - sparseFillEmptyRows, - sparseReshape, - sparseSegmentMean, - sparseSegmentSum -}; - -import {stringNGrams} from './string/string_n_grams'; -import {stringSplit} from './string/string_split'; -import {stringToHashBucketFast} from './string/string_to_hash_bucket_fast'; -import {staticRegexReplace} from './string/static_regex_replace'; -// tslint:disable-next-line:variable-name -const string = { - stringNGrams, - stringSplit, - stringToHashBucketFast, - staticRegexReplace, -}; - -// Second level exports. -export {image, linalg, losses, spectral, fused, signal, sparse, string}; diff --git a/tfjs-master/tfjs-core/src/ops/ops_for_converter.ts b/tfjs-master/tfjs-core/src/ops/ops_for_converter.ts deleted file mode 100644 index 3c284da93..000000000 --- a/tfjs-master/tfjs-core/src/ops/ops_for_converter.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -/** - * This file exports ops used by the converters executors. By default it - * re-exports all ops. In a custom build this is aliased to a file that will - * only exports ops for a given model.json. - */ -export * from './ops'; diff --git a/tfjs-master/tfjs-core/src/ops/outer_product.ts b/tfjs-master/tfjs-core/src/ops/outer_product.ts deleted file mode 100644 index c3063867d..000000000 --- a/tfjs-master/tfjs-core/src/ops/outer_product.ts +++ /dev/null @@ -1,55 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {Tensor1D, Tensor2D} from '../tensor'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; -import * as util from '../util'; - -import {matMul} from './mat_mul'; -import {op} from './operation'; -import {reshape} from './reshape'; - -/** - * Computes the outer product of two vectors, `v1` and `v2`. - * - * ```js - * const a = tf.tensor1d([1, 2, 3]); - * const b = tf.tensor1d([3, 4, 5]); - * - * tf.outerProduct(a, b).print(); - * ``` - * @param v1 The first vector in the outer product operation. - * @param v2 The second vector in the outer product operation. - * - * @doc {heading: 'Operations', subheading: 'Matrices'} - */ -function outerProduct_( - v1: Tensor1D|TensorLike, v2: Tensor1D|TensorLike): Tensor2D { - const $v1 = convertToTensor(v1, 'v1', 'outerProduct'); - const $v2 = convertToTensor(v2, 'v2', 'outerProduct'); - - util.assert( - $v1.rank === 1 && $v2.rank === 1, - () => `Error in outerProduct: inputs must be rank 1, but got ranks ` + - `${$v1.rank} and ${$v2.rank}.`); - - const v12D = reshape($v1, [-1, 1]); - const v22D = reshape($v2, [1, -1]); - return matMul(v12D, v22D); -} - -export const outerProduct = /* @__PURE__ */ op({outerProduct_}); diff --git a/tfjs-master/tfjs-core/src/ops/pad.ts b/tfjs-master/tfjs-core/src/ops/pad.ts deleted file mode 100644 index eec8c3d1b..000000000 --- a/tfjs-master/tfjs-core/src/ops/pad.ts +++ /dev/null @@ -1,67 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {PadV2, PadV2Attrs, PadV2Inputs} from '../kernel_names'; -import {NamedAttrMap} from '../kernel_registry'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -import {op} from './operation'; - -/** - * Pads a `tf.Tensor` with a given value and paddings. - * - * This operation implements `CONSTANT` mode. For `REFLECT` and `SYMMETRIC`, - * refer to `tf.mirrorPad`. - * - * Also available are stricter rank-specific methods with the same signature - * as this method that assert that `paddings` is of given length. - * - `tf.pad1d` - * - `tf.pad2d` - * - `tf.pad3d` - * - `tf.pad4d` - * - * ```js - * const x = tf.tensor1d([1, 2, 3, 4]); - * x.pad([[1, 2]]).print(); - * ``` - * @param x The tensor to pad. - * @param paddings An array of length `R` (the rank of the tensor), where - * each element is a length-2 tuple of ints `[padBefore, padAfter]`, - * specifying how much to pad along each dimension of the tensor. - * @param constantValue The pad value to use. Defaults to 0. - * - * @doc {heading: 'Tensors', subheading: 'Transformations'} - */ -function pad_( - x: T|TensorLike, paddings: Array<[number, number]>, constantValue = 0): T { - const $x = convertToTensor(x, 'x', 'pad'); - if ($x.rank === 0) { - throw new Error('pad(scalar) is not defined. Pass non-scalar to pad'); - } - - const attrs: PadV2Attrs = {paddings, constantValue}; - const inputs: PadV2Inputs = {x: $x}; - return ENGINE.runKernel( - PadV2, inputs as unknown as NamedTensorMap, - attrs as unknown as NamedAttrMap); -} - -export const pad = /* @__PURE__ */ op({pad_}); diff --git a/tfjs-master/tfjs-core/src/ops/pad1d.ts b/tfjs-master/tfjs-core/src/ops/pad1d.ts deleted file mode 100644 index e775fb402..000000000 --- a/tfjs-master/tfjs-core/src/ops/pad1d.ts +++ /dev/null @@ -1,35 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {Tensor1D} from '../tensor'; -import {TensorLike} from '../types'; -import {assert} from '../util'; -import {op} from './operation'; -import {pad} from './pad'; - -/** - * Pads a `tf.Tensor1D` with a given value and paddings. See `pad` for details. - */ -function pad1d_( - x: Tensor1D|TensorLike, paddings: [number, number], - constantValue = 0): Tensor1D { - assert( - paddings.length === 2, - () => 'Invalid number of paddings. Must be length of 2.'); - return pad(x, [paddings], constantValue); -} - -export const pad1d = /* @__PURE__ */ op({pad1d_}); diff --git a/tfjs-master/tfjs-core/src/ops/pad2d.ts b/tfjs-master/tfjs-core/src/ops/pad2d.ts deleted file mode 100644 index 5225f2673..000000000 --- a/tfjs-master/tfjs-core/src/ops/pad2d.ts +++ /dev/null @@ -1,36 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {Tensor2D} from '../tensor'; -import {TensorLike} from '../types'; -import {assert} from '../util'; -import {op} from './operation'; -import {pad} from './pad'; - -/** - * Pads a `tf.Tensor2D` with a given value and paddings. See `pad` for details. - */ -function pad2d_( - x: Tensor2D|TensorLike, paddings: [[number, number], [number, number]], - constantValue = 0): Tensor2D { - assert( - paddings.length === 2 && paddings[0].length === 2 && - paddings[1].length === 2, - () => 'Invalid number of paddings. Must be length of 2 each.'); - return pad(x, paddings, constantValue); -} - -export const pad2d = /* @__PURE__ */ op({pad2d_}); diff --git a/tfjs-master/tfjs-core/src/ops/pad3d.ts b/tfjs-master/tfjs-core/src/ops/pad3d.ts deleted file mode 100644 index 39201a0bc..000000000 --- a/tfjs-master/tfjs-core/src/ops/pad3d.ts +++ /dev/null @@ -1,37 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {Tensor3D} from '../tensor'; -import {TensorLike} from '../types'; -import {assert} from '../util'; -import {op} from './operation'; -import {pad} from './pad'; - -/** - * Pads a `tf.Tensor3D` with a given value and paddings. See `pad` for details. - */ -function pad3d_( - x: Tensor3D|TensorLike, - paddings: [[number, number], [number, number], [number, number]], - constantValue = 0): Tensor3D { - assert( - paddings.length === 3 && paddings[0].length === 2 && - paddings[1].length === 2 && paddings[2].length === 2, - () => 'Invalid number of paddings. Must be length of 2 each.'); - return pad(x, paddings, constantValue); -} - -export const pad3d = /* @__PURE__ */ op({pad3d_}); diff --git a/tfjs-master/tfjs-core/src/ops/pad4d.ts b/tfjs-master/tfjs-core/src/ops/pad4d.ts deleted file mode 100644 index f3e7693f7..000000000 --- a/tfjs-master/tfjs-core/src/ops/pad4d.ts +++ /dev/null @@ -1,41 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {Tensor4D} from '../tensor'; -import {TensorLike} from '../types'; -import {assert} from '../util'; -import {op} from './operation'; -import {pad} from './pad'; - -/** - * Pads a `tf.Tensor4D` with a given value and paddings. See `pad` for details. - */ -function pad4d_( - x: Tensor4D|TensorLike, - paddings: - [ - [number, number], [number, number], [number, number], [number, number] - ], - constantValue = 0): Tensor4D { - assert( - paddings.length === 4 && paddings[0].length === 2 && - paddings[1].length === 2 && paddings[2].length === 2 && - paddings[3].length === 2, - () => 'Invalid number of paddings. Must be length of 2 each.'); - return pad(x, paddings, constantValue); -} - -export const pad4d = /* @__PURE__ */ op({pad4d_}); diff --git a/tfjs-master/tfjs-core/src/ops/pad_test.ts b/tfjs-master/tfjs-core/src/ops/pad_test.ts deleted file mode 100644 index a1370281d..000000000 --- a/tfjs-master/tfjs-core/src/ops/pad_test.ts +++ /dev/null @@ -1,296 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('pad 1d', ALL_ENVS, () => { - it('Should pad 1D arrays', async () => { - const a = tf.tensor1d([1, 2, 3, 4, 5, 6], 'int32'); - const b = tf.pad1d(a, [2, 3]); - expectArraysClose(await b.data(), [0, 0, 1, 2, 3, 4, 5, 6, 0, 0, 0]); - }); - - it('Should not pad 1D arrays with 0s', async () => { - const a = tf.tensor1d([1, 2, 3, 4], 'int32'); - const b = tf.pad1d(a, [0, 0]); - expectArraysClose(await b.data(), [1, 2, 3, 4]); - }); - - it('Should handle padding with custom value', async () => { - let a = tf.tensor1d([1, 2, 3, 4], 'int32'); - let b = tf.pad1d(a, [2, 3], 9); - expectArraysClose(await b.data(), [9, 9, 1, 2, 3, 4, 9, 9, 9]); - - a = tf.tensor1d([1, 2, 3, 4]); - b = tf.pad1d(a, [2, 1], 1.1); - expectArraysClose(await b.data(), [1.1, 1.1, 1, 2, 3, 4, 1.1]); - - a = tf.tensor1d([1, 2, 3, 4]); - b = tf.pad1d(a, [2, 1], 1); - expectArraysClose(await b.data(), [1, 1, 1, 2, 3, 4, 1]); - - a = tf.tensor1d([1, 2, 3, 4]); - b = tf.pad1d(a, [2, 1], Number.NEGATIVE_INFINITY); - expectArraysClose(await b.data(), [ - Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY, 1, 2, 3, 4, - Number.NEGATIVE_INFINITY - ]); - - a = tf.tensor1d([1, 2, 3, 4]); - b = tf.pad1d(a, [2, 1], Number.POSITIVE_INFINITY); - expectArraysClose(await b.data(), [ - Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY, 1, 2, 3, 4, - Number.POSITIVE_INFINITY - ]); - }); - - it('Should handle NaNs with 1D arrays', async () => { - const a = tf.tensor1d([1, NaN, 2, NaN]); - const b = tf.pad1d(a, [1, 1]); - expectArraysClose(await b.data(), [0, 1, NaN, 2, NaN, 0]); - }); - - it('Should handle invalid paddings', () => { - const a = tf.tensor1d([1, 2, 3, 4], 'int32'); - const f = () => { - // tslint:disable-next-line:no-any - tf.pad1d(a, [2, 2, 2] as any); - }; - expect(f).toThrowError(); - }); - - it('Should handle empty tensor with meaningful dims', async () => { - const a = tf.tensor([], [0, 1]); - const b = tf.pad(a, [[0, 4], [0, 0]], 2); - - expectArraysClose(await b.data(), [2, 2, 2, 2]); - expectArraysClose(b.shape, [4, 1]); - }); - - it('grad', async () => { - const a = tf.tensor1d([1, 2, 3]); - const dy = tf.tensor1d([10, 20, 30, 40, 50, 60]); - const da = tf.grad((a: tf.Tensor1D) => tf.pad1d(a, [2, 1]))(a, dy); - expect(da.shape).toEqual([3]); - expectArraysClose(await da.data(), [30, 40, 50]); - }); - - it('gradient with clones', async () => { - const a = tf.tensor1d([1, 2, 3]); - const dy = tf.tensor1d([10, 20, 30, 40, 50, 60]); - const da = - tf.grad((a: tf.Tensor1D) => tf.pad1d(a.clone(), [2, 1]).clone())(a, dy); - expect(da.shape).toEqual([3]); - expectArraysClose(await da.data(), [30, 40, 50]); - }); - - it('accepts a tensor-like object', async () => { - const a = [1, 2, 3, 4, 5, 6]; - const b = tf.pad1d(a, [2, 3]); - expectArraysClose(await b.data(), [0, 0, 1, 2, 3, 4, 5, 6, 0, 0, 0]); - }); -}); - -describeWithFlags('pad 2d', ALL_ENVS, () => { - it('Should pad 2D arrays', async () => { - let a = tf.tensor2d([[1], [2]], [2, 1], 'int32'); - let b = tf.pad2d(a, [[1, 1], [1, 1]]); - // 0, 0, 0 - // 0, 1, 0 - // 0, 2, 0 - // 0, 0, 0 - expectArraysClose(await b.data(), [0, 0, 0, 0, 1, 0, 0, 2, 0, 0, 0, 0]); - - a = tf.tensor2d([[1, 2, 3], [4, 5, 6]], [2, 3], 'int32'); - b = tf.pad2d(a, [[2, 2], [1, 1]]); - // 0, 0, 0, 0, 0 - // 0, 0, 0, 0, 0 - // 0, 1, 2, 3, 0 - // 0, 4, 5, 6, 0 - // 0, 0, 0, 0, 0 - // 0, 0, 0, 0, 0 - expectArraysClose(await b.data(), [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 0, - 0, 4, 5, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ]); - }); - - it('Should not pad 2D arrays with 0s', async () => { - const a = tf.tensor2d([[1, 2, 3], [4, 5, 6]], [2, 3], 'int32'); - const b = tf.pad2d(a, [[0, 0], [0, 0]]); - expectArraysClose(await b.data(), [1, 2, 3, 4, 5, 6]); - }); - - it('Should handle padding with custom value', async () => { - let a = tf.tensor2d([[1, 2, 3], [4, 5, 6]], [2, 3], 'int32'); - let b = tf.pad2d(a, [[1, 1], [1, 1]], 10); - expectArraysClose(await b.data(), [ - 10, 10, 10, 10, 10, 10, 1, 2, 3, 10, - 10, 4, 5, 6, 10, 10, 10, 10, 10, 10 - ]); - - a = tf.tensor2d([[1], [1]], [2, 1]); - b = tf.pad2d(a, [[1, 1], [1, 1]], -2.1); - expectArraysClose( - await b.data(), - [-2.1, -2.1, -2.1, -2.1, 1, -2.1, -2.1, 1, -2.1, -2.1, -2.1, -2.1]); - - a = tf.tensor2d([[1], [1]], [2, 1]); - b = tf.pad2d(a, [[1, 1], [1, 1]], -2); - expectArraysClose( - await b.data(), [-2, -2, -2, -2, 1, -2, -2, 1, -2, -2, -2, -2]); - }); - - it('Should handle NaNs with 2D arrays', async () => { - const a = tf.tensor2d([[1, NaN], [1, NaN]], [2, 2]); - const b = tf.pad2d(a, [[1, 1], [1, 1]]); - // 0, 0, 0, 0 - // 0, 1, NaN, 0 - // 0, 1, NaN, 0 - // 0, 0, 0, 0 - expectArraysClose( - await b.data(), [0, 0, 0, 0, 0, 1, NaN, 0, 0, 1, NaN, 0, 0, 0, 0, 0]); - }); - - it('Should handle invalid paddings', () => { - const a = tf.tensor2d([[1], [2]], [2, 1], 'int32'); - const f = () => { - // tslint:disable-next-line:no-any - tf.pad2d(a, [[2, 2, 2], [1, 1, 1]] as any); - }; - expect(f).toThrowError(); - }); - - it('grad', async () => { - const a = tf.tensor2d([[1, 2], [3, 4]]); - const dy = tf.tensor2d([[0, 0, 0], [10, 20, 0], [30, 40, 0]], [3, 3]); - const da = - tf.grad((a: tf.Tensor2D) => tf.pad2d(a, [[1, 0], [0, 1]]))(a, dy); - expect(da.shape).toEqual([2, 2]); - expectArraysClose(await da.data(), [10, 20, 30, 40]); - }); - - it('accepts a tensor-like object', async () => { - const a = [[1, 2, 3], [4, 5, 6]]; // 2x3 - const b = tf.pad2d(a, [[0, 0], [0, 0]]); - expectArraysClose(await b.data(), [1, 2, 3, 4, 5, 6]); - }); -}); - -describeWithFlags('pad 3d', ALL_ENVS, () => { - it('works with 3d tensor, float32', async () => { - const a = tf.tensor3d([[[1]], [[2]]], [2, 1, 1], 'float32'); - const b = tf.pad3d(a, [[1, 1], [1, 1], [1, 1]]); - // 0, 0, 0 - // 0, 0, 0 - // 0, 0, 0 - - // 0, 0, 0 - // 0, 1, 0 - // 0, 0, 0 - - // 0, 0, 0 - // 0, 2, 0 - // 0, 0, 0 - - // 0, 0, 0 - // 0, 0, 0 - // 0, 0, 0 - expect(b.shape).toEqual([4, 3, 3]); - expectArraysClose(await b.data(), [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, - 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ]); - }); -}); - -describeWithFlags('pad 4d', ALL_ENVS, () => { - it('Should pad 4D arrays', async () => { - const a = tf.tensor4d([[[[9]]]], [1, 1, 1, 1], 'int32'); - const b = tf.pad4d(a, [[0, 0], [1, 1], [1, 1], [0, 0]]); - const expected = tf.tensor4d( - [[[[0], [0], [0]], [[0], [9], [0]], [[0], [0], [0]]]], [1, 3, 3, 1], - 'int32'); - expectArraysClose(await b.data(), await expected.data()); - expect(b.dtype).toBe('int32'); - expect(b.shape).toEqual([1, 3, 3, 1]); - }); - - it('does not leak memory', () => { - const a = tf.tensor4d([[[[9]]]], [1, 1, 1, 1], 'int32'); - // The first call to pad may create and keeps internal singleton tensors. - // Subsequent calls should always create exactly one new tensor. - tf.pad4d(a, [[0, 0], [1, 1], [1, 1], [0, 0]]); - // Count before real call. - const numTensors = tf.memory().numTensors; - tf.pad4d(a, [[0, 0], [1, 1], [1, 1], [0, 0]]); - expect(tf.memory().numTensors).toEqual(numTensors + 1); - }); - - it('accepts a tensor-like object', async () => { - const a = [[[[9]]]]; // 1x1x1x1 - const b = tf.pad4d(a, [[0, 0], [1, 1], [1, 1], [0, 0]]); - const expected = tf.tensor4d( - [[[[0], [0], [0]], [[0], [9], [0]], [[0], [0], [0]]]], [1, 3, 3, 1], - 'float32'); - expectArraysClose(await b.data(), await expected.data()); - expect(b.dtype).toBe('float32'); - expect(b.shape).toEqual([1, 3, 3, 1]); - }); -}); - -describeWithFlags('pad', ALL_ENVS, () => { - it('Pad tensor2d', async () => { - let a = tf.tensor2d([[1], [2]], [2, 1], 'int32'); - let b = tf.pad(a, [[1, 1], [1, 1]]); - // 0, 0, 0 - // 0, 1, 0 - // 0, 2, 0 - // 0, 0, 0 - expectArraysClose(await b.data(), [0, 0, 0, 0, 1, 0, 0, 2, 0, 0, 0, 0]); - - a = tf.tensor2d([[1, 2, 3], [4, 5, 6]], [2, 3], 'int32'); - b = tf.pad(a, [[2, 2], [1, 1]]); - // 0, 0, 0, 0, 0 - // 0, 0, 0, 0, 0 - // 0, 1, 2, 3, 0 - // 0, 4, 5, 6, 0 - // 0, 0, 0, 0, 0 - // 0, 0, 0, 0, 0 - expectArraysClose(await b.data(), [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 0, - 0, 4, 5, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ]); - }); - - it('throws when passed a non-tensor', () => { - expect(() => tf.pad({} as tf.Tensor, [[0, 0]])) - .toThrowError(/Argument 'x' passed to 'pad' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const x = [[1], [2]]; - const res = tf.pad(x, [[1, 1], [1, 1]]); - // 0, 0, 0 - // 0, 1, 0 - // 0, 2, 0 - // 0, 0, 0 - expectArraysClose(await res.data(), [0, 0, 0, 0, 1, 0, 0, 2, 0, 0, 0, 0]); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/pool.ts b/tfjs-master/tfjs-core/src/ops/pool.ts deleted file mode 100644 index 84398b419..000000000 --- a/tfjs-master/tfjs-core/src/ops/pool.ts +++ /dev/null @@ -1,167 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Tensor3D, Tensor4D} from '../tensor'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; -import * as util from '../util'; - -import {avgPool} from './avg_pool'; -import {batchToSpaceND} from './batch_to_space_nd'; -import * as conv_util from './conv_util'; -import {maxPool} from './max_pool'; -import {op} from './operation'; -import {reshape} from './reshape'; -import {spaceToBatchND} from './space_to_batch_nd'; - -/** - * Performs an N-D pooling operation - * - * @param input The input tensor, of rank 4 or rank 3 of shape - * `[batch, height, width, inChannels]`. If rank 3, batch of 1 is assumed. - * @param windowShape The filter size: `[filterHeight, filterWidth]`. If - * `filterSize` is a single number, then `filterHeight == filterWidth`. - * @param poolingType The type of pooling, either 'max' or 'avg'. - * @param pad The type of padding algorithm: - * - `same` and stride 1: output will be of same size as input, - * regardless of filter size. - * - `valid`: output will be smaller than input if filter is larger - * than 1x1. - * - For more info, see this guide: - * [https://www.tensorflow.org/api_guides/python/nn#Convolution]( - * https://www.tensorflow.org/api_guides/python/nn#Convolution) - * @param dilations The dilation rates: `[dilationHeight, dilationWidth]` - * in which we sample input values across the height and width dimensions - * in dilated pooling. Defaults to `[1, 1]`. If `dilationRate` is a single - * number, then `dilationHeight == dilationWidth`. If it is greater than - * 1, then all values of `strides` must be 1. - * @param strides The strides of the pooling: `[strideHeight, strideWidth]`. If - * `strides` is a single number, then `strideHeight == strideWidth`. - * @param dimRoundingMode A string from: 'ceil', 'round', 'floor'. If none is - * provided, it will default to truncate. - * - * @doc {heading: 'Operations', subheading: 'Convolution'} - */ -function pool_( - input: T|TensorLike, windowShape: [number, number]|number, - poolingType: 'avg'|'max', - pad: 'valid'|'same'|number|conv_util.ExplicitPadding, - dilations?: [number, number]|number, strides?: [number, number]|number, - dimRoundingMode?: 'floor'|'round'|'ceil') { - if (dilations == null) { - dilations = [1, 1]; - } - if (strides == null) { - strides = 1; - } - if (pad === 0) { - pad = 'valid'; - } - - const $x = convertToTensor(input, 'x', 'maxPool'); - let x4D = $x as Tensor4D; - let reshapedTo4D = false; - - if ($x.rank === 3) { - reshapedTo4D = true; - x4D = reshape($x, [1, $x.shape[0], $x.shape[1], $x.shape[2]]); - } - - util.assert( - conv_util.eitherStridesOrDilationsAreOne(strides, dilations), - () => 'Error in pool: Either strides or dilations must be 1. ' + - `Got strides ${strides} and dilations '${dilations}'`); - - const convInfo = conv_util.computePool2DInfo( - x4D.shape, windowShape, strides, dilations, pad); - const dilation: [number, number] = - [convInfo.dilationHeight, convInfo.dilationWidth]; - - // The following implementation does batchToSpace(pool(spaceToBatch(x))) - // whenever dilation > 1 since the TF kernels do not support dilation > 1. - // tslint:disable-next-line:max-line-length - // https://github.com/tensorflow/tensorflow/blob/50f6bb67dc98c9b74630b6047aae7a4f8a40fd02/tensorflow/python/ops/nn_ops.py#L1037 - - let basePadding: number[][]; - if (pad === 'same') { - basePadding = withSpaceToBatchBasePaddings( - [convInfo.filterHeight, convInfo.filterWidth], dilation); - } else { - basePadding = [[0, 0], [0, 0]]; - } - - const isDilationOne = dilation[0] === 1 && dilation[1] === 1; - const [adjustedPadding, adjustedCrops] = requiredSpaceToBatchPaddings( - [convInfo.inHeight, convInfo.inWidth], dilation, basePadding); - const convertedPad = isDilationOne ? pad : 'valid'; - const convertedX = - isDilationOne ? x4D : spaceToBatchND(x4D, dilation, adjustedPadding); - - const forwardOp = poolingType === 'avg' ? - () => avgPool(convertedX, windowShape, strides, convertedPad, - dimRoundingMode) : - () => maxPool(convertedX, windowShape, strides, convertedPad, - dimRoundingMode); - const y = forwardOp(); - - const res = isDilationOne ? y : batchToSpaceND(y, dilation, adjustedCrops); - - if (reshapedTo4D) { - return reshape(res, [res.shape[1], res.shape[2], res.shape[3]]) as T; - } - - return res as T; -} - -// Helper function to compute crops and paddings for pool with dilation > 1. -// tslint:disable-next-line:max-line-length -// https://github.com/tensorflow/tensorflow/blob/50f6bb67dc98c9b74630b6047aae7a4f8a40fd02/tensorflow/python/ops/array_ops.py#L2184 -function requiredSpaceToBatchPaddings( - inputShape: [number, number], blockShape: [number, number], - basePadding: number[][]) { - const padStart = basePadding.map(b => b[0]); - const origPadEnd = basePadding.map(b => b[1]); - const fullInputShape = inputShape.concat(padStart, origPadEnd); - const padEndExtra = blockShape.map((b, i) => (b - fullInputShape[i] % b) % b); - const padEnd = origPadEnd.map((s, i) => s + padEndExtra[i]); - const paddings = blockShape.map((_, i) => [padStart[i], padEnd[i]]); - const crops = blockShape.map((_, i) => [0, padEndExtra[i]]); - return [paddings, crops]; -} - -// Helper function to compute base paddings for pool with dilation > 1. -// tslint:disable-next-line:max-line-length -// https://github.com/tensorflow/tensorflow/blob/50f6bb67dc98c9b74630b6047aae7a4f8a40fd02/tensorflow/python/ops/nn_ops.py#L524 -function withSpaceToBatchBasePaddings( - filterShape: [number, number], dilation: [number, number]) { - // Spatial dimensions of the filters and the upsampled filters in which we - // introduce (rate - 1) zeros between consecutive filter values. - const dilatedFilterShape = filterShape.map((s, i) => { - return s + (s - 1) * (dilation[i] - 1); - }); - const padExtraShape = dilatedFilterShape.map(s => s - 1); - - // When padding is odd, we pad more at end, following the same - // convention as conv2d. - const padExtraStart = padExtraShape.map(s => Math.floor(s / 2)); - const padExtraEnd = padExtraShape.map((s, i) => s - padExtraStart[i]); - return padExtraShape.map((_, i) => { - return [padExtraStart[i], padExtraEnd[i]]; - }); -} - -export const pool = /* @__PURE__ */ op({pool_}); diff --git a/tfjs-master/tfjs-core/src/ops/pool_test.ts b/tfjs-master/tfjs-core/src/ops/pool_test.ts deleted file mode 100644 index 69294dc45..000000000 --- a/tfjs-master/tfjs-core/src/ops/pool_test.ts +++ /dev/null @@ -1,536 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('pool', ALL_ENVS, () => { - // First test that tf.pool calls are consistent with maxPool/avgPool by - // duplicating some maxPool/avgPool tests. The implementation code is the - // same, so we don't need the same level of thoroughness here. - - it('max x=[1,1,1] f=[1,1] s=1 d=1 [0] => [0]', async () => { - const x = tf.tensor3d([0], [1, 1, 1]); - - const windowShape = 1; - const padding = 0; - - const result = tf.pool(x, windowShape, 'max', padding); - expectArraysClose(await result.data(), [0]); - }); - - it('max x=[3,3,1] f=[2,2] s=1 d=1', async () => { - // Feed forward. - const x = tf.tensor3d([1, 2, 3, 4, 5, 6, 7, 9, 8], [3, 3, 1]); - - const windowShape = 2; - const padding = 0; - const dilationRate: number = undefined; - const strides: number = undefined; - - const result = - tf.pool(x, windowShape, 'max', padding, dilationRate, strides); - - expect(result.shape).toEqual([2, 2, 1]); - expectArraysClose(await result.data(), [5, 6, 9, 9]); - }); - - it('max x=[4,4,1] f=[2,2] s=2 d=1', async () => { - // Feed forward. - const x = tf.tensor3d( - [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], [4, 4, 1]); - - const windowShape = 2; - const padding = 0; - const dilationRate: number = undefined; - const strides = 2; - const result = - tf.pool(x, windowShape, 'max', padding, dilationRate, strides); - - expect(result.shape).toEqual([2, 2, 1]); - expectArraysClose(await result.data(), [5, 7, 13, 15]); - }); - - it('max x=[2,2,1] f=[2,2] s=1 d=1 p=same', async () => { - // Feed forward. - const x = tf.tensor3d([1, 2, 3, 4], [2, 2, 1]); - - const windowShape = 2; - const padding = 'same'; - const dilationRate: number = undefined; - const strides = 1; - - const result = - tf.pool(x, windowShape, 'max', padding, dilationRate, strides); - expect(result.shape).toEqual([2, 2, 1]); - expectArraysClose(await result.data(), [4, 4, 4, 4]); - }); - - it('max x=[3,3,1] f=[3,3] s=1 d=1 p=explicit', async () => { - // Feed forward. - const x = tf.tensor3d([0, 1, 2, 3, 4, 5, 6, 7, 8], [3, 3, 1]); - - const windowShape = 3; - const padding = - [[0, 0], [1, 2], [0, 1], [0, 0]] as tf.backend_util.ExplicitPadding; - const dilationRate: number = undefined; - const strides = 1; - - const result = - tf.pool(x, windowShape, 'max', padding, dilationRate, strides); - expect(result.shape).toEqual([4, 2, 1]); - expectArraysClose(await result.data(), [5, 5, 8, 8, 8, 8, 8, 8]); - }); - - it('max x=[3,3,1] f=[3,3] s=3 d=1 p=explicit defualt dimRoundingMode', - async () => { - // Feed forward. - const x = tf.tensor3d([0, 1, 2, 3, 4, 5, 6, 7, 8], [3, 3, 1]); - - const windowShape = 3; - const padding = - [[0, 0], [2, 2], [1, 1], [0, 0]] as tf.backend_util.ExplicitPadding; - const dilationRate: number = undefined; - const strides = 3; - - const result = - tf.pool(x, windowShape, 'max', padding, dilationRate, strides); - expect(result.shape).toEqual([2, 1, 1]); - }); - - it('max x=[3,3,1] f=[3,3] s=3 d=1 p=explicit dimRoundingMode=floor', - async () => { - // Feed forward. - const x = tf.tensor3d([0, 1, 2, 3, 4, 5, 6, 7, 8], [3, 3, 1]); - - const windowShape = 3; - const padding = - [[0, 0], [2, 2], [1, 1], [0, 0]] as tf.backend_util.ExplicitPadding; - const dilationRate: number = undefined; - const strides = 3; - - const result = tf.pool(x, windowShape, 'max', padding, dilationRate, - strides, 'floor'); - expect(result.shape).toEqual([2, 1, 1]); - }); - - it('max x=[3,3,1] f=[3,3] s=3 d=1 p=explicit dimRoundingMode=round', - async () => { - // Feed forward. - const x = tf.tensor3d([0, 1, 2, 3, 4, 5, 6, 7, 8], [3, 3, 1]); - - const windowShape = 3; - const padding = - [[0, 0], [2, 2], [1, 1], [0, 0]] as tf.backend_util.ExplicitPadding; - const dilationRate: number = undefined; - const strides = 3; - - const result = tf.pool(x, windowShape, 'max', padding, dilationRate, - strides, 'round'); - expect(result.shape).toEqual([2, 2, 1]); - }); - - it('max x=[3,3,1] f=[3,3] s=3 d=1 p=explicit dimRoundingMode=ceil', - async () => { - // Feed forward. - const x = tf.tensor3d([0, 1, 2, 3, 4, 5, 6, 7, 8], [3, 3, 1]); - - const windowShape = 3; - const padding = - [[0, 0], [2, 2], [1, 1], [0, 0]] as tf.backend_util.ExplicitPadding; - const dilationRate: number = undefined; - const strides = 3; - - const result = tf.pool(x, windowShape, 'max', padding, dilationRate, - strides, 'ceil'); - expect(result.shape).toEqual([3, 2, 1]); - }); - - it('max x=[2,2,3] f=[1,1] s=2 p=1 fractional outputs default rounding', - async () => { - // Feed forward. - const a = tf.tensor3d([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [2, 2, 3]); - - const windowShape = 1; - const padding = 1; - const dilationRate: number = undefined; - const strides = 2; - - const result = - tf.pool(a, windowShape, 'max', padding, dilationRate, strides); - expect(result.shape).toEqual([2, 2, 3]); - expectArraysClose( - await result.data(), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]); - }); - - it('avg x=[1,1,1] f=[1,1] s=1 d=1 [0] => [0]', async () => { - const a = tf.tensor3d([0], [1, 1, 1]); - - const windowShape = 1; - const padding = 0; - - const result = tf.pool(a, windowShape, 'avg', padding); - expectArraysClose(await result.data(), [0]); - }); - - it('avg x=[3,3,1] f=[2,2] s=1 d=1', async () => { - // Feed forward. - const a = tf.tensor3d([1, 2, 3, 4, 5, 6, 7, 9, 8], [3, 3, 1]); - - const windowShape = 2; - const padding = 0; - const dilationRate: number = undefined; - const strides: number = undefined; - - const result = - tf.pool(a, windowShape, 'avg', padding, dilationRate, strides); - - expect(result.shape).toEqual([2, 2, 1]); - expect(result.dtype).toBe('float32'); - expectArraysClose(await result.data(), [3, 4, 6.25, 7]); - }); - - it('avg x=[4,4,1] f=[2,2] s=2 d=1', async () => { - // Feed forward. - const a = tf.tensor3d( - [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], [4, 4, 1]); - - const windowShape = 2; - const padding = 0; - const dilationRate: number = undefined; - const strides = 2; - - const result = - tf.pool(a, windowShape, 'avg', padding, dilationRate, strides); - - expect(result.shape).toEqual([2, 2, 1]); - expectArraysClose(await result.data(), [2.5, 4.5, 10.5, 12.5]); - }); - - it('avg x=[2,2,1] f=[2,2] s=1 p=same', async () => { - // Feed forward. - const a = tf.tensor3d([1, 2, 3, 4], [2, 2, 1]); - - const windowShape = 2; - const padding = 'same'; - const dilationRate: number = undefined; - const strides = 1; - - const result = - tf.pool(a, windowShape, 'avg', padding, dilationRate, strides); - - expect(result.shape).toEqual([2, 2, 1]); - expectArraysClose(await result.data(), [2.5, 3, 3.5, 4]); - }); - - it('avg x=[3,3,1] f=[3,3] s=1 d=1 p=explicit', async () => { - // Feed forward. - const x = tf.tensor3d([0, 1, 2, 3, 4, 5, 6, 7, 8], [3, 3, 1]); - - const windowShape = 3; - const padding = - [[0, 0], [1, 2], [0, 1], [0, 0]] as tf.backend_util.ExplicitPadding; - const dilationRate: number = undefined; - const strides = 1; - - const result = - tf.pool(x, windowShape, 'avg', padding, dilationRate, strides); - expect(result.shape).toEqual([4, 2, 1]); - expectArraysClose( - await result.data(), [2.5, 3, 4, 4.5, 5.5, 6, 7, 7.5]); - }); - - it('avg x=[3,3,1] f=[3,3] s=3 d=1 p=explicit defualt dimRoundingMode', - async () => { - // Feed forward. - const x = tf.tensor3d([0, 1, 2, 3, 4, 5, 6, 7, 8], [3, 3, 1]); - - const windowShape = 3; - const padding = - [[0, 0], [2, 2], [1, 1], [0, 0]] as tf.backend_util.ExplicitPadding; - const dilationRate: number = undefined; - const strides = 3; - - const result = - tf.pool(x, windowShape, 'avg', padding, dilationRate, strides); - expect(result.shape).toEqual([2, 1, 1]); - }); - - it('avg x=[3,3,1] f=[3,3] s=3 d=1 p=explicit dimRoundingMode=floor', - async () => { - // Feed forward. - const x = tf.tensor3d([0, 1, 2, 3, 4, 5, 6, 7, 8], [3, 3, 1]); - - const windowShape = 3; - const padding = - [[0, 0], [2, 2], [1, 1], [0, 0]] as tf.backend_util.ExplicitPadding; - const dilationRate: number = undefined; - const strides = 3; - - const result = tf.pool(x, windowShape, 'avg', padding, dilationRate, - strides, 'floor'); - expect(result.shape).toEqual([2, 1, 1]); - }); - - it('avg x=[3,3,1] f=[3,3] s=3 d=1 p=explicit dimRoundingMode=round', - async () => { - // Feed forward. - const x = tf.tensor3d([0, 1, 2, 3, 4, 5, 6, 7, 8], [3, 3, 1]); - - const windowShape = 3; - const padding = - [[0, 0], [2, 2], [1, 1], [0, 0]] as tf.backend_util.ExplicitPadding; - const dilationRate: number = undefined; - const strides = 3; - - const result = tf.pool(x, windowShape, 'avg', padding, dilationRate, - strides, 'round'); - expect(result.shape).toEqual([2, 2, 1]); - }); - - it('avg x=[3,3,1] f=[3,3] s=3 d=1 p=explicit dimRoundingMode=ceil', - async () => { - // Feed forward. - const x = tf.tensor3d([0, 1, 2, 3, 4, 5, 6, 7, 8], [3, 3, 1]); - - const windowShape = 3; - const padding = - [[0, 0], [2, 2], [1, 1], [0, 0]] as tf.backend_util.ExplicitPadding; - const dilationRate: number = undefined; - const strides = 3; - - const result = tf.pool(x, windowShape, 'avg', padding, dilationRate, - strides, 'ceil'); - expect(result.shape).toEqual([3, 2, 1]); - }); - - it('avg x=[2,2,3] f=[1,1] s=2 p=1 fractional outputs default rounding', - async () => { - // Feed forward. - const a = tf.tensor3d([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [2, 2, 3]); - - const windowShape = 1; - const padding = 1; - const dilationRate: number = undefined; - const strides = 2; - - const result = - tf.pool(a, windowShape, 'avg', padding, dilationRate, strides); - expect(result.shape).toEqual([2, 2, 3]); - expectArraysClose( - await result.data(), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]); - }); - - // tf.pool supports dilation, unlike maxPool or avgPool - it('max x=[4,3,1] f=[2,2] s=1 d=2', async () => { - // Feed forward. - const x = tf.tensor3d( - [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], [4, 4, 1]); - - const windowShape = 2; - const padding = 0; - const dilationRate = 2; - const strides: number = undefined; - - const result = - tf.pool(x, windowShape, 'max', padding, dilationRate, strides); - - expect(result.shape).toEqual([2, 2, 1]); - expectArraysClose(await result.data(), [11, 12, 15, 16]); - }); - - it('max x=[2,4,4,1] f=[2,2] s=1 d=2', async () => { - // Feed forward. - const x = tf.tensor4d( - [ - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 11, 13, 14, 16, 15 - ], - [2, 4, 4, 1]); - - const windowShape = 2; - const padding = 0; - const dilationRate = 2; - const strides: number = undefined; - - const result = - tf.pool(x, windowShape, 'max', padding, dilationRate, strides); - - expect(result.shape).toEqual([2, 2, 2, 1]); - expectArraysClose(await result.data(), [11, 12, 15, 16, 12, 11, 16, 15]); - }); - - it('avg x=[4,4,1] f=[2,2] s=1 d=2', async () => { - // Feed forward. - const a = tf.tensor3d( - [1, 3, 2, 4, 6, 5, 8, 7, 9, 10, 12, 11, 16, 15, 14, 13], [4, 4, 1]); - - const windowShape = 2; - const padding = 0; - const dilationRate = 2; - const strides: number = undefined; - - const result = - tf.pool(a, windowShape, 'avg', padding, dilationRate, strides); - - expect(result.shape).toEqual([2, 2, 1]); - expect(result.dtype).toBe('float32'); - expectArraysClose(await result.data(), [6, 7, 11, 10]); - }); - - it('max throws when neither s=1 nor d=1', () => { - // Feed forward. - const x = tf.tensor3d( - [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], [4, 4, 1]); - - const windowShape = 2; - const padding = 0; - const dilationRate = 2; - const strides = 2; - - expect(() => tf.pool(x, windowShape, 'max', padding, dilationRate, strides)) - .toThrowError(); - }); - - it('avg throws when neither s=1 nor d=1', () => { - // Feed forward. - const x = tf.tensor3d( - [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], [4, 4, 1]); - - const windowShape = 2; - const padding = 0; - const dilationRate = 2; - const strides = 2; - - expect(() => tf.pool(x, windowShape, 'avg', padding, dilationRate, strides)) - .toThrowError(); - }); -}); - -describeWithFlags('poolBackprop', ALL_ENVS, () => { - it('max gradients x=[3,3,1] f=[2,2] s=1 d=1 no dup max value', async () => { - const dy = tf.tensor3d([1, 2, 3, 4], [2, 2, 1]); - const x = tf.tensor3d([1, 2, 3, 4, 5, 6, 7, 8, 9], [3, 3, 1]); - const expected = [0, 0, 0, 0, 1, 2, 0, 3, 4]; - - const windowShape = 2; - const padding = 0; - const dilationRate: number = undefined; - const strides: number = undefined; - - const dx = tf.grad( - (x: tf.Tensor3D) => - x.pool(windowShape, 'max', padding, dilationRate, strides))(x, dy); - - expect(dx.shape).toEqual(x.shape); - expectArraysClose(await dx.data(), expected); - }); - - it('max gradients x=[3,3,1] f=[2,2] s=1 d=2 no dup max value, test #1', - async () => { - const dy = tf.tensor3d([1, 2, 3, 4], [2, 2, 1]); - const x = tf.tensor3d( - [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], [4, 4, 1]); - const expected = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 0, 0, 3, 4]; - - const windowShape = 2; - const padding = 0; - const dilationRate = 2; - const strides: number = undefined; - - const dx = tf.grad( - (x: tf.Tensor3D) => x.pool( - windowShape, 'max', padding, dilationRate, strides))(x, dy); - - expect(dx.shape).toEqual(x.shape); - expectArraysClose(await dx.data(), expected); - }); - - it('max gradients x=[3,3,1] f=[2,2] s=1 d=2 no dup max value, test #2', - async () => { - const dy = tf.tensor3d([1, 2, 3, 4], [2, 2, 1]); - const x = tf.tensor3d( - [9, 5, 8, 6, 3, 1, 2, 4, 7, 3, 6, 4, 11, 15, 10, 16], [4, 4, 1]); - const expected = [1, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 4]; - - const windowShape = 2; - const padding = 0; - const dilationRate = 2; - const strides: number = undefined; - - const dx = tf.grad( - (x: tf.Tensor3D) => x.pool( - windowShape, 'max', padding, dilationRate, strides))(x, dy); - - expect(dx.shape).toEqual(x.shape); - expectArraysClose(await dx.data(), expected); - }); - - it('max gradient x=[3,3,1] f=[2,2] s=1 d=2 dup max value', async () => { - const dy = tf.tensor3d([1, 2, 3, 4, 5, 6, 7, 8, 9], [3, 3, 1]); - const x = tf.tensor3d( - [ - 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ], - [5, 5, 1]); - const expected = [ - 0, 0, 0, 0, 0, 0, 5, 10, 0, 0, 0, 10, 20, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ]; - - const windowShape = 2; - const padding = 0; - const dilationRate = 2; - const strides: number = undefined; - - const dx = tf.grad( - (x: tf.Tensor3D) => - x.pool(windowShape, 'max', padding, dilationRate, strides))(x, dy); - - expect(dx.shape).toEqual(x.shape); - expectArraysClose(await dx.data(), expected); - }); - - it('avg gradient x=[4,4,1] f=[2,2] s=1 d=2', async () => { - const x = tf.tensor3d( - [ - 1, 3, 2, 4, 6, 5, 8, 7, 9, 10, 12, 11, 16, - 15, 14, 13, 17, 18, 19, 20, 21, 22, 23, 24, 25 - ], - [5, 5, 1]); - const dy = tf.tensor3d([1, 2, 3, 4, 5, 6, 7, 8, 9], [3, 3, 1]); - const f = 1 / (2 * 2); - - const windowShape = 2; - const padding = 0; - const dilationRate = 2; - const strides: number = undefined; - - const dx = tf.grad( - (x: tf.Tensor3D) => - x.pool(windowShape, 'avg', padding, dilationRate, strides))(x, dy); - - expect(dx.shape).toEqual(x.shape); - expectArraysClose(await dx.data(), [ - 1 * f, 2 * f, 4 * f, 2 * f, 3 * f, 4 * f, 5 * f, 10 * f, 5 * f, - 6 * f, 8 * f, 10 * f, 20 * f, 10 * f, 12 * f, 4 * f, 5 * f, 10 * f, - 5 * f, 6 * f, 7 * f, 8 * f, 16 * f, 8 * f, 9 * f - ]); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/pow.ts b/tfjs-master/tfjs-core/src/ops/pow.ts deleted file mode 100644 index aabae6236..000000000 --- a/tfjs-master/tfjs-core/src/ops/pow.ts +++ /dev/null @@ -1,66 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {ENGINE} from '../engine'; -import {Pow, PowInputs} from '../kernel_names'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {makeTypesMatch} from '../tensor_util'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -import {op} from './operation'; - -/** - * Computes the power of one `tf.Tensor` to another. Supports broadcasting. - * - * Given a `tf.Tensor` x and a `tf.Tensor` y, this operation computes x^y for - * corresponding elements in x and y. The result's dtype will be the upcasted - * type of the `base` and `exp` dtypes. - * - * ```js - * const a = tf.tensor([[2, 3], [4, 5]]) - * const b = tf.tensor([[1, 2], [3, 0]]).toInt(); - * - * a.pow(b).print(); // or tf.pow(a, b) - * ``` - * - * ```js - * const a = tf.tensor([[1, 2], [3, 4]]) - * const b = tf.tensor(2).toInt(); - * - * a.pow(b).print(); // or tf.pow(a, b) - * ``` - * We also expose `powStrict` which has the same signature as this op and - * asserts that `base` and `exp` are the same shape (does not broadcast). - * - * @param base The base `tf.Tensor` to pow element-wise. - * @param exp The exponent `tf.Tensor` to pow element-wise. - * - * @doc {heading: 'Operations', subheading: 'Arithmetic'} - */ -function pow_( - base: Tensor|TensorLike, exp: Tensor|TensorLike): T { - let $base = convertToTensor(base, 'base', 'pow'); - let $exp = convertToTensor(exp, 'exp', 'pow'); - [$base, $exp] = makeTypesMatch($base, $exp); - - const inputs: PowInputs = {a: $base, b: $exp}; - - return ENGINE.runKernel(Pow, inputs as unknown as NamedTensorMap); -} - -export const pow = /* @__PURE__ */ op({pow_}); diff --git a/tfjs-master/tfjs-core/src/ops/prelu.ts b/tfjs-master/tfjs-core/src/ops/prelu.ts deleted file mode 100644 index f500f5dc0..000000000 --- a/tfjs-master/tfjs-core/src/ops/prelu.ts +++ /dev/null @@ -1,51 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {Prelu, PreluInputs} from '../kernel_names'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -import {op} from './operation'; - -/** - * Computes leaky rectified linear element-wise with parametric alphas. - * - * `x < 0 ? alpha * x : f(x) = x` - * - * ```js - * const x = tf.tensor1d([-1, 2, -3, 4]); - * const alpha = tf.scalar(0.1); - * - * x.prelu(alpha).print(); // or tf.prelu(x, alpha) - * ``` - * @param x The input tensor. - * @param alpha Scaling factor for negative values. - * - * @doc {heading: 'Operations', subheading: 'Basic math'} - */ -function prelu_(x: T|TensorLike, alpha: T|TensorLike): T { - const $x = convertToTensor(x, 'x', 'prelu'); - const $alpha = convertToTensor(alpha, 'alpha', 'prelu'); - - const inputs: PreluInputs = {x: $x, alpha: $alpha}; - return ENGINE.runKernel(Prelu, inputs as unknown as NamedTensorMap); -} - -export const prelu = /* @__PURE__ */ op({prelu_}); diff --git a/tfjs-master/tfjs-core/src/ops/print.ts b/tfjs-master/tfjs-core/src/ops/print.ts deleted file mode 100644 index 475136c2b..000000000 --- a/tfjs-master/tfjs-core/src/ops/print.ts +++ /dev/null @@ -1,35 +0,0 @@ -/** - * @license - * Copyright 2020 Google Inc. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Tensor} from '../tensor'; - -/** - * Prints information about the `tf.Tensor` including its data. - * - * ```js - * const verbose = true; - * tf.tensor2d([1, 2, 3, 4], [2, 2]).print(verbose); - * ``` - * @param x The tensor to be printed. - * @param verbose Whether to print verbose information about the ` Tensor`, - * including dtype and size. - * - * @doc {heading: 'Tensors', subheading: 'Creation'} - */ -export function print(x: T, verbose = false): void { - console.log(x.toString(verbose)); -} diff --git a/tfjs-master/tfjs-core/src/ops/prod.ts b/tfjs-master/tfjs-core/src/ops/prod.ts deleted file mode 100644 index f9e482162..000000000 --- a/tfjs-master/tfjs-core/src/ops/prod.ts +++ /dev/null @@ -1,76 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {Prod, ProdAttrs, ProdInputs} from '../kernel_names'; -import {NamedAttrMap} from '../kernel_registry'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -import {cast} from './cast'; -import {op} from './operation'; - -/** - * Computes the product of elements across dimensions of a `tf.Tensor`. - * - * Reduces the input along the dimensions given in `axes`. Unless `keepDims` - * is true, the rank of the `tf.Tensor` is reduced by 1 for each entry in - * `axes`. If `keepDims` is true, the reduced dimensions are retained with - * length 1. If `axes` has no entries, all dimensions are reduced, and a - * `tf.Tensor` with a single element is returned. - * - * ```js - * const x = tf.tensor1d([1, 2, 3]); - * - * x.prod().print(); // or tf.prod(x) - * ``` - * - * ```js - * const x = tf.tensor2d([1, 2, 3, 4], [2, 2]); - * - * const axis = 1; - * x.prod(axis).print(); // or tf.prod(x, axis) - * ``` - * - * @param x The input tensor to compute the product over. If the dtype is `bool` - * it will be converted to `int32` and the output dtype will be `int32`. - * @param axis The dimension(s) to reduce. By default it reduces - * all dimensions. - * @param keepDims If true, retains reduced dimensions with size 1. - * - * @doc {heading: 'Operations', subheading: 'Reduction'} - */ -function prod_( - x: Tensor|TensorLike, axis: number|number[] = null, keepDims = false): T { - let $x = convertToTensor(x, 'x', 'prod'); - - if ($x.dtype === 'bool') { - // bool is not an allowed type for the underlying kernel. - $x = cast($x, 'int32'); - } - - const inputs: ProdInputs = {x: $x}; - const attrs: ProdAttrs = {axis, keepDims}; - - return ENGINE.runKernel( - Prod, inputs as unknown as NamedTensorMap, - attrs as unknown as NamedAttrMap); -} - -export const prod = /* @__PURE__ */ op({prod_}); diff --git a/tfjs-master/tfjs-core/src/ops/prod_test.ts b/tfjs-master/tfjs-core/src/ops/prod_test.ts deleted file mode 100644 index e208bd0a5..000000000 --- a/tfjs-master/tfjs-core/src/ops/prod_test.ts +++ /dev/null @@ -1,228 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose, expectArraysEqual} from '../test_util'; - -describeWithFlags('prod', ALL_ENVS, () => { - it('basic', async () => { - const a = tf.tensor2d([1, 2, 3, 0, 0, 1], [3, 2]); - const result = tf.prod(a); - expectArraysClose(await result.data(), 0); - }); - - it('propagates NaNs', async () => { - const a = tf.tensor2d([1, 2, 3, NaN, 0, 1], [3, 2]); - expectArraysEqual(await tf.prod(a).data(), NaN); - }); - - it('prod over dtype int32', async () => { - const a = tf.tensor1d([1, 5, 7, 3], 'int32'); - const prod = tf.prod(a); - expectArraysEqual(await prod.data(), 105); - }); - - it('prod over dtype bool', async () => { - const a = tf.tensor1d([true, false, false, true, true], 'bool'); - const prod = tf.prod(a); - expectArraysEqual(await prod.data(), 0); - }); - - it('prods all values in 2D array with keep dim', async () => { - const a = tf.tensor2d([1, 2, 3, 1, 0, 1], [3, 2]); - const res = tf.prod(a, null, true /* keepDims */); - - expect(res.shape).toEqual([1, 1]); - expectArraysClose(await res.data(), 0); - }); - - it('prods across axis=0 in 2D array', async () => { - const a = tf.tensor2d([1, 2, 3, 1, 0, 1], [3, 2]); - const res = tf.prod(a, [0]); - - expect(res.shape).toEqual([2]); - expectArraysClose(await res.data(), [0, 2]); - }); - - it('prods across axis=0 in 2D array, keepDims', async () => { - const a = tf.tensor2d([1, 2, 3, 1, 0, 1], [3, 2]); - const res = tf.prod(a, [0], true /* keepDims */); - - expect(res.shape).toEqual([1, 2]); - expectArraysClose(await res.data(), [0, 2]); - }); - - it('prods across axis=1 in 2D array', async () => { - const a = tf.tensor2d([1, 2, 3, 1, 1, 1], [3, 2]); - const res = tf.prod(a, [1]); - - expect(res.shape).toEqual([3]); - expectArraysClose(await res.data(), [2, 3, 1]); - }); - - it('2D, axis=1 provided as number', async () => { - const a = tf.tensor2d([1, 2, 3, 1, 1, 1], [2, 3]); - const res = tf.prod(a, 1); - - expect(res.shape).toEqual([2]); - expectArraysClose(await res.data(), [6, 1]); - }); - - it('2D, axis = -1 provided as number', async () => { - const a = tf.tensor2d([1, 2, 3, 1, 1, 1], [2, 3]); - const res = tf.prod(a, -1); - - expect(res.shape).toEqual([2]); - expectArraysClose(await res.data(), [6, 1]); - }); - - it('prods across axis=0,1 in 2D array', async () => { - const a = tf.tensor2d([1, 2, 3, 1, 1, 1], [3, 2]); - const res = tf.prod(a, [0, 1]); - - expect(res.shape).toEqual([]); - expectArraysClose(await res.data(), [6]); - }); - - it('2D, axis=[-1,-2] in 2D array', async () => { - const a = tf.tensor2d([1, 2, 3, 1, 1, 1], [3, 2]); - const res = tf.prod(a, [-1, -2]); - - expect(res.shape).toEqual([]); - expectArraysClose(await res.data(), [6]); - }); - - // Illustrative example from the C++ implementation for comparison. See: - // https://github.com/tensorflow/tensorflow/blob/5dee95f8bafe3f342693d2135da451283b1fbaec/tensorflow/cc/gradients/math_grad.cc - it('gradients: prod(multi-dimensional tensor with zeros)', async () => { - const a = tf.tensor([ - [[3.0, 4.0], [5.0, 6.0], [7.0, 8.0]], [[3.0, 5.0], [0.0, 6.0], [5.0, 6.0]] - ]); - const dy = tf.tensor([[10, 10], [10, 10]]); - - const gradients = tf.grad(a => a.prod(1))(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.array(), [ - [ // (axis 1 values) * (dy) - [5 * 7 * 10, 6 * 8 * 10], [3 * 7 * 10, 4 * 8 * 10], - [3 * 5 * 10, 4 * 6 * 10] - ], - [ - [0 * 5 * 10, 6 * 6 * 10], [3 * 5 * 10, 5 * 6 * 10], - [3 * 0 * 10, 5 * 6 * 10] - ] - ]); - }); - - it('gradients: prod(reduce on 2 axes)', async () => { - const a = tf.tensor([ - [[3.0, 4.0], [5.0, 6.0], [7.0, 8.0]], [[3.0, 5.0], [0.0, 6.0], [5.0, 6.0]] - ]); - const dy = tf.tensor([2, 2]); - - const gradients = tf.grad(a => a.prod([0, 1]))(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - - expectArraysClose(await gradients.array(), [ - [ - // (axis 0 values) * (axis 1 values) * (dy) - [3 * 0 * 5 * (5 * 7) * 2, 5 * 6 * 6 * (6 * 8) * 2], - [3 * 0 * 5 * (3 * 7) * 2, 5 * 6 * 6 * (4 * 8) * 2], - [3 * 0 * 5 * (3 * 5) * 2, 5 * 6 * 6 * (4 * 6) * 2] - ], - [ - [3 * 5 * 7 * (0 * 5) * 2, 4 * 6 * 8 * (6 * 6) * 2], - [3 * 5 * 7 * (3 * 5) * 2, 4 * 6 * 8 * (5 * 6) * 2], - [3 * 5 * 7 * (3 * 0) * 2, 4 * 6 * 8 * (5 * 6) * 2] - ] - ]); - }); - - it('gradients: prod(tensor with zeros)', async () => { - const a = tf.tensor2d([[1, 2, 0], [1, 2, 3]], [2, 3]); - const dy = tf.tensor([12, 12]); - - const gradients = tf.grad(a => a.prod(1))(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose( - await gradients.array(), - [[0, 0, 1 * 2 * 12], [6 * 12, 3 * 12, 2 * 12]]); - }); - - it('gradients: prod(2d) with gradient broadcasting', async () => { - const a = tf.tensor2d([[1, 2], [3, 4]], [2, 2]); - const dy = tf.scalar(24); - - const gradients = tf.grad(a => a.prod())(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose( - await gradients.array(), - [[2 * 3 * 4 * 24, 3 * 4 * 24], [4 * 2 * 24, 3 * 2 * 24]]); - }); - - it('gradients: prod(2d, axis=0) and varied gradient values', async () => { - const a = tf.tensor2d([[1, 2], [3, 1], [1, 4]], [3, 2]); - const dy = tf.tensor1d([3, 8]); - const axis = 0; - - const gradients = tf.grad(a => a.prod(axis))(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose( - await gradients.array(), - [[3 * 3, 4 * 8], [1 * 3, 8 * 8], [3 * 3, 2 * 8]]); - }); - - it('gradients: prod(2d, axis=1)', async () => { - const a = tf.tensor2d([[1, 2], [3, 1], [1, 4]], [3, 2]); - const dy = tf.tensor1d([4, 3, 4]); - const axis = 1; - - const gradients = tf.grad(a => a.prod(axis))(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose( - await gradients.array(), - [[2 * 4, 1 * 4], [1 * 3, 3 * 3], [4 * 4, 1 * 4]]); - }); - - it('throws when passed a non-tensor', () => { - expect(() => tf.prod({} as tf.Tensor)) - .toThrowError(/Argument 'x' passed to 'prod' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const result = tf.prod([[1, 2], [3, 1], [1, 1]]); - expectArraysClose(await result.data(), 6); - }); - - it('throws error for string tensor', () => { - expect(() => tf.prod(['a'])) - .toThrowError(/Argument 'x' passed to 'prod' must be numeric tensor/); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/ragged_gather.ts b/tfjs-master/tfjs-core/src/ops/ragged_gather.ts deleted file mode 100644 index 24a741e36..000000000 --- a/tfjs-master/tfjs-core/src/ops/ragged_gather.ts +++ /dev/null @@ -1,75 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {RaggedGather, RaggedGatherAttrs, RaggedGatherInputs} from '../kernel_names'; -import {Tensor} from '../tensor'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; -import {op} from './operation'; - -/** - * Gather ragged slices from params axis 0 according to indices. - * - * @param paramsNestedSplits: A list of at least 1 Tensor with type 'int32' The - * nestedRowSplits tensors that define the row-partitioning for the params - * RaggedTensor input. - * @param paramsDenseValues: A Tensor. The flatValues for the params - * RaggedTensor. - * @param indices: A Tensor. Must be one of type: int32. Indices in the - * outermost dimension of params of the values that should be gathered. - * @param outputRaggedRank: An int that is >= 0. The ragged rank of the output - * RaggedTensor. outputNestedSplits will contain this number of rowSplits - * tensors. This value should equal indices.shape.ndims + params.raggedRank - * - 1. - * @return A map with the following properties: - * - outputNestedSplits: A list of outputRaggedRank Tensor objects with the - * same type as paramsNestedSplits. - * - outputDenseValues: A Tensor. Has the same type as paramsDenseValues. - * @doc {heading: 'Operations', subheading: 'Ragged'} - */ - -interface RaggedGatherMap { - outputNestedSplits: Tensor[]; - outputDenseValues: Tensor; -} - -function raggedGather_( - paramsNestedSplits: Tensor[], paramsDenseValues: Tensor|TensorLike, - indices: Tensor|TensorLike, outputRaggedRank: number): RaggedGatherMap { - const $paramsNestedSplits = paramsNestedSplits.map( - (t, i) => convertToTensor(t, `tensors${i}`, 'raggedGather', 'int32')); - const $paramsDenseValues = - convertToTensor(paramsDenseValues, 'paramsDenseValues', 'raggedGather'); - const $indices = convertToTensor(indices, 'indices', 'raggedGather', 'int32'); - - const inputs: RaggedGatherInputs = { - paramsNestedSplits: $paramsNestedSplits, - paramsDenseValues: $paramsDenseValues, - indices: $indices, - }; - const attrs: RaggedGatherAttrs = {outputRaggedRank}; - - const result: Tensor[] = - ENGINE.runKernel(RaggedGather, inputs as {}, attrs as {}); - return { - outputNestedSplits: result.slice(0, result.length - 1), - outputDenseValues: result[result.length - 1], - }; -} - -export const raggedGather = /* @__PURE__ */ op({raggedGather_}); diff --git a/tfjs-master/tfjs-core/src/ops/ragged_gather_test.ts b/tfjs-master/tfjs-core/src/ops/ragged_gather_test.ts deleted file mode 100644 index 954f52859..000000000 --- a/tfjs-master/tfjs-core/src/ops/ragged_gather_test.ts +++ /dev/null @@ -1,174 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose, expectArraysEqual} from '../test_util'; - -async function runRaggedGather( - indicesShape: number[], indices: number[], paramsNestedSplits: number[][], - paramsDenseValuesShape: number[], paramsDenseValues: number[]) { - const paramsRaggedRank = paramsNestedSplits.length; - const numSplits = paramsRaggedRank + indicesShape.length - 1; - - const paramsNestedSplitsTensors = - paramsNestedSplits.map(values => tf.tensor1d(values, 'int32')); - const paramsDenseValuesTensor = - tf.tensor(paramsDenseValues, paramsDenseValuesShape); - const indicesTensor = tf.tensor(indices, indicesShape, 'int32'); - - const output = tf.raggedGather( - paramsNestedSplitsTensors, paramsDenseValuesTensor, indicesTensor, - numSplits); - - tf.dispose(paramsNestedSplitsTensors); - tf.dispose([paramsDenseValuesTensor, indicesTensor]); - - expect(output.outputDenseValues.dtype).toEqual('float32'); - - output.outputNestedSplits.forEach(splits => { - expect(splits.dtype).toEqual('int32'); - expect(splits.shape.length).toEqual(1); - }); - - return { - outputDenseValues: await output.outputDenseValues.data(), - outputDenseValuesShape: output.outputDenseValues.shape, - outputNestedSplits: await Promise.all( - output.outputNestedSplits.map(splits => splits.data())), - tensors: output.outputNestedSplits.concat([output.outputDenseValues]) - }; -} - -describeWithFlags('raggedGather ', ALL_ENVS, () => { - it('RaggedGather', async () => { - const result = await runRaggedGather( - [4], [2, 1, 0, 3], [[0, 3, 3, 7, 9]], [9], - [.1, .2, .3, .4, .5, .6, .7, .8, .9]); - - expect(result.outputNestedSplits.length).toEqual(1); - expectArraysClose(result.outputNestedSplits[0], [0, 4, 4, 7, 9]); - - expectArraysClose( - result.outputDenseValues, [.4, .5, .6, .7, .1, .2, .3, .8, .9]); - expectArraysEqual(result.outputDenseValuesShape, [9]); - }); - - it('RaggedGather3DParams', async () => { - const result = await runRaggedGather( - [5], [2, 1, 0, 2, 3], [[0, 1, 3, 3, 5, 6], [0, 0, 2, 3, 5, 8, 9]], [9], - [.1, .2, .3, .4, .5, .6, .7, .8, .9]); - - expect(result.outputNestedSplits.length).toEqual(2); - expectArraysClose(result.outputNestedSplits[0], [0, 0, 2, 3, 3, 5]); - expectArraysClose(result.outputNestedSplits[1], [0, 2, 3, 3, 5, 8]); - - expectArraysClose( - result.outputDenseValues, [.1, .2, .3, .4, .5, .6, .7, .8]); - expectArraysEqual(result.outputDenseValuesShape, [8]); - }); - - it('RaggedGather4DParams', async () => { - const result = await runRaggedGather( - [4], [2, 1, 0, 2], [[0, 1, 3, 3], [0, 0, 3, 4]], [4, 2], - [1, 2, 3, 4, 5, 6, 7, 8]); - - expect(result.outputNestedSplits.length).toEqual(2); - expectArraysClose(result.outputNestedSplits[0], [0, 0, 2, 3, 3]); - expectArraysClose(result.outputNestedSplits[1], [0, 3, 4, 4]); - - expectArraysClose(result.outputDenseValues, [1, 2, 3, 4, 5, 6, 7, 8]); - expectArraysEqual(result.outputDenseValuesShape, [4, 2]); - }); - - it('RaggedGather2DIndices', async () => { - const result = await runRaggedGather( - [2, 2], [2, 1, 0, 3], [[0, 3, 3, 7, 9]], [9], - [.1, .2, .3, .4, .5, .6, .7, .8, .9]); - - expect(result.outputNestedSplits.length).toEqual(2); - expectArraysClose(result.outputNestedSplits[0], [0, 2, 4]); - expectArraysClose(result.outputNestedSplits[1], [0, 4, 4, 7, 9]); - - expectArraysClose( - result.outputDenseValues, [.4, .5, .6, .7, .1, .2, .3, .8, .9]); - expectArraysEqual(result.outputDenseValuesShape, [9]); - }); - - it('RaggedGatherScalarIndices', async () => { - const result = await runRaggedGather( - [], [2], [[0, 3, 3, 7, 9]], [9], [.1, .2, .3, .4, .5, .6, .7, .8, .9]); - - expect(result.outputNestedSplits.length).toEqual(0); - - expectArraysClose(result.outputDenseValues, [.4, .5, .6, .7]); - expectArraysEqual(result.outputDenseValuesShape, [4]); - }); - - it('OutOfBounds', async () => { - await expectAsync(runRaggedGather([2], [2, 10], [[0, 3, 3, 7, 9]], [9], [ - .1, .2, .3, .4, .5, .6, .7, .8, .9 - ])).toBeRejectedWithError('indices[1] = 10 is not in [0, 4)'); - }); - - it('InvalidSplitsNotSorted', async () => { - await expectAsync(runRaggedGather( - [2], [0, 2], [[0, 3, 5, 2, 9]], [9], - [.1, .2, .3, .4, .5, .6, .7, .8, .9])) - .toBeRejectedWithError( - 'Ragged splits must be sorted in ascending order'); - }); - - it('InvalidSplitsNegative', async () => { - await expectAsync(runRaggedGather([2], [0, 2], [[-1, 3, 2, 7, 9]], [9], [ - .1, .2, .3, .4, .5, .6, .7, .8, .9 - ])).toBeRejectedWithError('Ragged splits must be non-negative'); - }); - - it('InvalidSplitsEmpty', async () => { - await expectAsync(runRaggedGather([0], [], [[]], [0], [])) - .toBeRejectedWithError('Ragged splits may not be empty'); - }); - - it('InvalidSplitsTooBig', async () => { - await expectAsync(runRaggedGather( - [2], [0, 2], [[0, 20, 40, 80, 100]], [9], - [.1, .2, .3, .4, .5, .6, .7, .8, .9])) - .toBeRejectedWithError('Ragged splits must not point past values'); - }); - - it('BadValuesShape', async () => { - await expectAsync(runRaggedGather([0], [], [[0]], [], [.1])) - .toBeRejectedWithError('params.rank must be nonzero'); - }); - - it('does not have memory leak.', async () => { - const beforeDataIds = tf.engine().backend.numDataIds(); - - const result = await runRaggedGather( - [4], [2, 1, 0, 3], [[0, 3, 3, 7, 9]], [9], - [.1, .2, .3, .4, .5, .6, .7, .8, .9]); - - const afterResDataIds = tf.engine().backend.numDataIds(); - expect(afterResDataIds).toEqual(beforeDataIds + 2); - - result.tensors.map(tensor => tensor.dispose()); - - const afterDisposeDataIds = tf.engine().backend.numDataIds(); - expect(afterDisposeDataIds).toEqual(beforeDataIds); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/ragged_range.ts b/tfjs-master/tfjs-core/src/ops/ragged_range.ts deleted file mode 100644 index e2f5f20b1..000000000 --- a/tfjs-master/tfjs-core/src/ops/ragged_range.ts +++ /dev/null @@ -1,63 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {RaggedRange, RaggedRangeInputs} from '../kernel_names'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; -import {op} from './operation'; - -/** - * Returns a RaggedTensor result composed from rtDenseValues and rtNestedSplits, - * such that result[i] = [starts[i], starts[i] + deltas[i], ..., limits[i]]). - * - * @param starts: A Tensor. Must be one of the following types: - * 'float32', 'int32'. The starts of each range. - * @param limits: A Tensor. Must have the same type as starts. The limits of - * each range. - * @param deltas: A Tensor. Must have the same type as starts. The deltas of - * each range. - * @return A map with the following properties: - * - rtNestedSplits: A Tensor of type 'int32'. - * - rtDenseValues: A Tensor. Has the same type as starts. - */ - -function raggedRange_( - starts: Tensor|TensorLike, limits: Tensor|TensorLike, - deltas: Tensor|TensorLike): NamedTensorMap { - const $starts = convertToTensor(starts, 'starts', 'raggedRange'); - const $limits = - convertToTensor(limits, 'limits', 'raggedRange', $starts.dtype); - const $deltas = - convertToTensor(deltas, 'deltas', 'raggedRange', $starts.dtype); - - const inputs: RaggedRangeInputs = { - starts: $starts, - limits: $limits, - deltas: $deltas, - }; - - const result: Tensor[] = ENGINE.runKernel(RaggedRange, inputs as {}); - return { - rtNestedSplits: result[0], - rtDenseValues: result[1], - }; -} - -export const raggedRange = /* @__PURE__ */ op({raggedRange_}); diff --git a/tfjs-master/tfjs-core/src/ops/ragged_range_test.ts b/tfjs-master/tfjs-core/src/ops/ragged_range_test.ts deleted file mode 100644 index ccd1b32fe..000000000 --- a/tfjs-master/tfjs-core/src/ops/ragged_range_test.ts +++ /dev/null @@ -1,187 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -async function runRaggedGather( - starts: tf.Tensor, limits: tf.Tensor, deltas: tf.Tensor) { - const output = tf.raggedRange(starts, limits, deltas); - - expect(output.rtNestedSplits.dtype).toEqual('int32'); - expect(output.rtNestedSplits.shape.length).toEqual(1); - - expect(output.rtDenseValues.dtype).toEqual(starts.dtype); - expect(output.rtDenseValues.shape.length).toEqual(1); - - return { - rtNestedSplits: await output.rtNestedSplits.data(), - rtDenseValues: await output.rtDenseValues.data(), - tensors: Object.values(output) - }; -} - -describeWithFlags('raggedRange ', ALL_ENVS, () => { - it('IntValues', async () => { - const result = await runRaggedGather( - tf.tensor1d([0, 5, 8, 5], 'int32'), tf.tensor1d([8, 7, 8, 1], 'int32'), - tf.tensor1d([2, 1, 1, -1], 'int32')); - - // Expected: [[0, 2, 4, 6], [5, 6], [], [5, 4, 3, 2]] - expectArraysClose(result.rtNestedSplits, [0, 4, 6, 6, 10]); - expectArraysClose(result.rtDenseValues, [0, 2, 4, 6, 5, 6, 5, 4, 3, 2]); - }); - - it('FloatValues', async () => { - const result = await runRaggedGather( - tf.tensor1d([0, 5, 8, 5], 'float32'), - tf.tensor1d([8, 7, 8, 1], 'float32'), - tf.tensor1d([2, 1, 1, -1], 'float32')); - - // Expected: [[0, 2, 4, 6], [5, 6], [], [5, 4, 3, 2]] - expectArraysClose(result.rtNestedSplits, [0, 4, 6, 6, 10]); - expectArraysClose(result.rtDenseValues, [0, 2, 4, 6, 5, 6, 5, 4, 3, 2]); - }); - - it('RangeSizeOverflow', async () => { - await expectAsync(runRaggedGather( - tf.tensor1d([1.1, 0.1], 'float32'), - tf.tensor1d([10, 1e10], 'float32'), - tf.tensor1d([1, 1e-10], 'float32'))) - .toBeRejectedWithError( - 'Requires ((limit - start) / delta) <= 2147483647'); - }); - - it('BroadcastDeltas', async () => { - const result = await runRaggedGather( - tf.tensor1d([0, 5, 8], 'int32'), tf.tensor1d([8, 7, 8], 'int32'), - tf.scalar(1, 'int32')); - - // Expected: [[0, 1, 2, 3, 4, 5, 6, 7], [5, 6], []] - expectArraysClose(result.rtNestedSplits, [0, 8, 10, 10]); - expectArraysClose(result.rtDenseValues, [0, 1, 2, 3, 4, 5, 6, 7, 5, 6]); - }); - - it('BroadcastLimitsAndDeltas', async () => { - const result = await runRaggedGather( - tf.scalar(0, 'int32'), tf.tensor1d([3, 0, 2], 'int32'), - tf.scalar(1, 'int32')); - - // Expected: [[0, 1, 2], [], [0, 1]] - expectArraysClose(result.rtNestedSplits, [0, 3, 3, 5]); - expectArraysClose(result.rtDenseValues, [0, 1, 2, 0, 1]); - }); - - it('BroadcastStartsAndLimits', async () => { - const result = await runRaggedGather( - tf.scalar(0, 'int32'), tf.scalar(12, 'int32'), - tf.tensor1d([3, 4, 5], 'int32')); - - // Expected: [[0, 3, 6, 9], [0, 4, 8], [0, 5, 10]] - expectArraysClose(result.rtNestedSplits, [0, 4, 7, 10]); - expectArraysClose(result.rtDenseValues, [0, 3, 6, 9, 0, 4, 8, 0, 5, 10]); - }); - - it('AllScalarInputs', async () => { - const result = await runRaggedGather( - tf.scalar(0, 'int32'), tf.scalar(5, 'int32'), tf.scalar(1, 'int32')); - - // Expected: [[0, 1, 2, 3, 4]] - expectArraysClose(result.rtNestedSplits, [0, 5]); - expectArraysClose(result.rtDenseValues, [0, 1, 2, 3, 4]); - }); - - it('InvalidArgsStarts', async () => { - await expectAsync(runRaggedGather( - tf.tensor2d([0, 5, 8, 5], [4, 1], 'int32'), - tf.tensor1d([8, 7, 8, 1], 'int32'), - tf.tensor1d([2, 1, 1, -1], 'int32'))) - .toBeRejectedWithError('starts must be a scalar or vector'); - }); - - it('InvalidArgsLimits', async () => { - await expectAsync(runRaggedGather( - tf.tensor1d([0, 5, 8, 5], 'int32'), - tf.tensor2d([8, 7, 8, 1], [4, 1], 'int32'), - tf.tensor1d([2, 1, 1, -1], 'int32'))) - .toBeRejectedWithError('limits must be a scalar or vector'); - }); - - it('InvalidArgsDeltas', async () => { - await expectAsync(runRaggedGather( - tf.tensor1d([0, 5, 8, 5], 'int32'), - tf.tensor1d([8, 7, 8, 1], 'int32'), - tf.tensor2d([2, 1, 1, -1], [4, 1], 'int32'))) - .toBeRejectedWithError('deltas must be a scalar or vector'); - }); - - it('InvalidArgsShapeMismatch', async () => { - await expectAsync(runRaggedGather( - tf.tensor1d([0, 5, 8, 5], 'int32'), - tf.tensor1d([7, 8, 1], 'int32'), - tf.tensor1d([2, 1, 1, -1], 'int32'))) - .toBeRejectedWithError( - 'starts, limits, and deltas must have the same shape'); - }); - - it('InvalidArgsZeroDelta', async () => { - await expectAsync(runRaggedGather( - tf.tensor1d([0, 5, 8, 5], 'int32'), - tf.tensor1d([7, 8, 8, 1], 'int32'), - tf.tensor1d([2, 1, 0, -1], 'int32'))) - .toBeRejectedWithError('Requires delta != 0'); - }); - - it('EmptyRangePositiveDelta', async () => { - const result = await runRaggedGather( - tf.tensor1d([0, 5], 'int32'), tf.tensor1d([5, 0], 'int32'), - tf.scalar(2, 'int32')); - - // Expected: [[0, 2, 4], []] - expectArraysClose(result.rtNestedSplits, [0, 3, 3]); - expectArraysClose(result.rtDenseValues, [0, 2, 4]); - }); - - it('EmptyRangeNegativeDelta', async () => { - const result = await runRaggedGather( - tf.tensor1d([0, 5], 'int32'), tf.tensor1d([5, 0], 'int32'), - tf.scalar(-2, 'int32')); - - // Expected: [[], [5, 3, 1]] - expectArraysClose(result.rtNestedSplits, [0, 0, 3]); - expectArraysClose(result.rtDenseValues, [5, 3, 1]); - }); - - it('does not have memory leak.', async () => { - const beforeDataIds = tf.engine().backend.numDataIds(); - - const starts = tf.tensor1d([0, 5, 8, 5], 'int32'); - const limits = tf.tensor1d([8, 7, 8, 1], 'int32'); - const deltas = tf.tensor1d([2, 1, 1, -1], 'int32'); - const result = await runRaggedGather(starts, limits, deltas); - - const afterResDataIds = tf.engine().backend.numDataIds(); - expect(afterResDataIds).toEqual(beforeDataIds + 5); - - tf.dispose([starts, limits, deltas]); - tf.dispose(result.tensors); - - const afterDisposeDataIds = tf.engine().backend.numDataIds(); - expect(afterDisposeDataIds).toEqual(beforeDataIds); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/ragged_tensor_to_tensor.ts b/tfjs-master/tfjs-core/src/ops/ragged_tensor_to_tensor.ts deleted file mode 100644 index 2485a16a3..000000000 --- a/tfjs-master/tfjs-core/src/ops/ragged_tensor_to_tensor.ts +++ /dev/null @@ -1,102 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {RaggedTensorToTensor, RaggedTensorToTensorAttrs, RaggedTensorToTensorInputs} from '../kernel_names'; -import {Tensor} from '../tensor'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; -import {op} from './operation'; - -/** - * Create a dense tensor from a ragged tensor, possibly altering its shape. - * - * The raggedTensorToTensor op creates a dense tensor from am array of row - * partition tensors, a value vector, and default values. If the shape is - * unspecified, the minimal shape required to contain all the elements in the - * ragged tensor (the natural shape) will be used. If some dimensions are left - * unspecified, then the size of the natural shape is used in that dimension. - * - * The defaultValue will be broadcast to the output shape. After that, the - * values from the ragged tensor overwrite the default values. Note that the - * defaultValue must have less dimensions than the value. - * - * The row partition tensors are in the order of the dimensions. At present, the - * types can be: "ROW_SPLITS": the row_splits tensor from the ragged tensor. - * "VALUE_ROWIDS": the value_rowids tensor from the ragged tensor. - * "FIRST_DIM_SIZE": if value_rowids is used for the first dimension, then it - * is preceded by "FIRST_DIM_SIZE". - * ``` - * @param shape: A Tensor. Must be one of the following types: 'int32'. The - * desired shape of the output tensor. If left unspecified (empty), the - * minimal shape required to contain all the elements in the ragged tensor - * (the natural shape) will be used. If some dimensions are left - * unspecified, then the size of the natural shape is used in that - * dimension. - * - * Note that dense dimensions cannot be modified by the shape argument. - * Trying to change the size of a dense dimension will cause the op to fail. - * Examples: natural shape: [4, 5, 6] shape: -1 output shape: [4, 5, 6] - * - * natural shape: [4, 5, 6] shape: [3, -1, 2] output shape: [3, 5, 2] - * - * natural shape: [4, 5, 6] shape: [3, 7, 2] output shape: [3, 7, 2] - * @param values: A Tensor. A 1D tensor representing the values of the ragged - * tensor. - * @param defaultValue: A Tensor. Must have the same type as values. The - * defaultValue when the shape is larger than the ragged tensor. The - * defaultValue is broadcast until it is the shape of the output tensor, - * and then overwritten by values in the ragged tensor. The default value - * must be compatible with this broadcast operation, and must have fewer - * dimensions than the value tensor. - * @param rowPartitionTensors: A list of at least 1 Tensor objects with the same - * type in: 'int32'. - * @param rowPartitionTypes: A list of strings. The types of the row partition - * tensors. At present, these can be: - * "ROW_SPLITS": the row_splits tensor from the ragged tensor. - * "VALUE_ROWIDS": the value_rowids tensor from the ragged tensor. - * "FIRST_DIM_SIZE": if value_rowids is used for the first dimension, then - * it is preceeded by "FIRST_DIM_SIZE". The tensors are in the order of - * the dimensions. - * @return A Tensor. Has the same type as values. - * @doc {heading: 'Operations', subheading: 'Ragged'} - */ -function raggedTensorToTensor_( - shape: Tensor|TensorLike, values: Tensor|TensorLike, - defaultValue: Tensor|TensorLike, rowPartitionTensors: Tensor[], - rowPartitionTypes: string[]): Tensor { - const $shape = - convertToTensor(shape, 'shape', 'raggedTensorToTensor', 'int32'); - const $values = convertToTensor(values, 'values', 'raggedTensorToTensor'); - const $defaultValue = convertToTensor( - defaultValue, 'defaultValue', 'raggedTensorToTensor', $values.dtype); - const $rowPartitionTensors = rowPartitionTensors.map( - (t, i) => - convertToTensor(t, `tensors${i}`, 'raggedTensorToTensor', 'int32')); - - const inputs: RaggedTensorToTensorInputs = { - shape: $shape, - values: $values, - defaultValue: $defaultValue, - rowPartitionTensors: $rowPartitionTensors - }; - const attrs: RaggedTensorToTensorAttrs = {rowPartitionTypes}; - - return ENGINE.runKernel(RaggedTensorToTensor, inputs as {}, attrs as {}); -} - -export const raggedTensorToTensor = /* @__PURE__ */ op({raggedTensorToTensor_}); diff --git a/tfjs-master/tfjs-core/src/ops/ragged_tensor_to_tensor_test.ts b/tfjs-master/tfjs-core/src/ops/ragged_tensor_to_tensor_test.ts deleted file mode 100644 index f8cd58142..000000000 --- a/tfjs-master/tfjs-core/src/ops/ragged_tensor_to_tensor_test.ts +++ /dev/null @@ -1,301 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose, expectArraysEqual} from '../test_util'; - -describeWithFlags('raggedTensorToTensor ', ALL_ENVS, () => { - it('RaggedTensorToTensor', async () => { - const shape = [4, 4]; - const values = [.1, .2, .3, .4, .5, .6, .7, .8, .9]; - const defaultValue = 1.5; - const rowPartitionTensors = [ - tf.scalar(4, 'int32'), tf.tensor1d([0, 0, 0, 2, 2, 2, 2, 3, 3], 'int32') - ]; - const rowPartitionTypes = ['FIRST_DIM_SIZE', 'VALUE_ROWIDS']; - const result = tf.raggedTensorToTensor( - shape, values, defaultValue, rowPartitionTensors, rowPartitionTypes); - - expectArraysEqual(result.shape, shape); - expectArraysClose(await result.data(), [ - .1, .2, .3, 1.5, 1.5, 1.5, 1.5, 1.5, .4, .5, .6, .7, .8, .9, 1.5, 1.5 - ]); - }); - - it('RaggedTensorToTensorRowSplits', async () => { - const shape = [4, 4]; - const values = [.1, .2, .3, .4, .5, .6, .7, .8, .9]; - const defaultValue = 1.5; - const rowPartitionTensors = [tf.tensor1d([0, 3, 3, 7, 9], 'int32')]; - const rowPartitionTypes = ['ROW_SPLITS']; - const result = tf.raggedTensorToTensor( - shape, values, defaultValue, rowPartitionTensors, rowPartitionTypes); - - expectArraysEqual(result.shape, shape); - expectArraysClose(await result.data(), [ - .1, .2, .3, 1.5, 1.5, 1.5, 1.5, 1.5, .4, .5, .6, .7, .8, .9, 1.5, 1.5 - ]); - }); - - it('RaggedTensorToTensor3DParams', async () => { - const shape = [5, 2, 3]; - const values = [.1, .2, .3, .4, .5, .6, .7, .8, .9]; - const defaultValue = 1.5; - const rowPartitionTensors = [ - tf.scalar(5, 'int32'), tf.tensor1d([0, 1, 1, 3, 3, 4], 'int32'), - tf.tensor1d([1, 1, 2, 3, 3, 4, 4, 4, 5], 'int32') - ]; - const rowPartitionTypes = - ['FIRST_DIM_SIZE', 'VALUE_ROWIDS', 'VALUE_ROWIDS']; - const result = tf.raggedTensorToTensor( - shape, values, defaultValue, rowPartitionTensors, rowPartitionTypes); - - expectArraysEqual(result.shape, shape); - expectArraysClose(await result.data(), [ - 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, .1, .2, 1.5, .3, 1.5, 1.5, 1.5, 1.5, 1.5, - 1.5, 1.5, 1.5, .4, .5, 1.5, .6, .7, .8, .9, 1.5, 1.5, 1.5, 1.5, 1.5 - ]); - }); - - it('RaggedTensorToTensor3DParamsRowSplits', async () => { - const shape = [5, 2, 3]; - const values = [.1, .2, .3, .4, .5, .6, .7, .8, .9]; - const defaultValue = 1.5; - const rowPartitionTensors = [ - tf.tensor1d([0, 1, 3, 3, 5, 6], 'int32'), - tf.tensor1d([0, 0, 2, 3, 5, 8, 9], 'int32') - ]; - const rowPartitionTypes = ['ROW_SPLITS', 'ROW_SPLITS']; - const result = tf.raggedTensorToTensor( - shape, values, defaultValue, rowPartitionTensors, rowPartitionTypes); - - expectArraysEqual(result.shape, shape); - expectArraysClose(await result.data(), [ - 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, .1, .2, 1.5, .3, 1.5, 1.5, 1.5, 1.5, 1.5, - 1.5, 1.5, 1.5, .4, .5, 1.5, .6, .7, .8, .9, 1.5, 1.5, 1.5, 1.5, 1.5 - ]); - }); - - it('RaggedTensorToTensor3DParamsRowSplits2', async () => { - const shape = [3, 2, 3]; - const values = [0, 1, 2, 3]; - const defaultValue = 5; - const rowPartitionTensors = [ - tf.tensor1d([0, 2, 2, 3], 'int32'), tf.tensor1d([0, 3, 3, 4], 'int32') - ]; - const rowPartitionTypes = ['ROW_SPLITS', 'ROW_SPLITS']; - const result = tf.raggedTensorToTensor( - shape, values, defaultValue, rowPartitionTensors, rowPartitionTypes); - - expectArraysEqual(result.shape, shape); - expectArraysClose( - await result.data(), - [0, 1, 2, 5, 5, 5, 5, 5, 5, 5, 5, 5, 3, 5, 5, 5, 5, 5]); - }); - - it('RaggedTensorToTensor4DParams', async () => { - const shape = [4, 2, 3, 2]; - const values = [1, 2, 3, 4, 5, 6, 7, 8]; - const defaultValue = 15; - const rowPartitionTensors = [ - tf.scalar(5, 'int32'), tf.tensor1d([0, 1, 1], 'int32'), - tf.tensor1d([1, 1, 1, 2], 'int32'), - tf.tensor1d([0, 0, 1, 1, 2, 2, 3, 3], 'int32') - ]; - const rowPartitionTypes = - ['FIRST_DIM_SIZE', 'VALUE_ROWIDS', 'VALUE_ROWIDS', 'VALUE_ROWIDS']; - const result = tf.raggedTensorToTensor( - shape, values, defaultValue, rowPartitionTensors, rowPartitionTypes); - - expectArraysEqual(result.shape, shape); - expectArraysClose(await result.data(), [ - 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 1, 2, 3, 4, - 5, 6, 7, 8, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15 - ]); - }); - - it('RaggedTensorToTensor4DParamsRowSplit', async () => { - const shape = [4, 2, 3, 2]; - const values = [1, 2, 3, 4, 5, 6, 7, 8]; - const defaultValue = 15; - const rowPartitionTensors = [ - tf.tensor1d([0, 1, 3], 'int32'), tf.tensor1d([0, 0, 3, 4], 'int32'), - tf.tensor1d([0, 2, 4, 6, 8], 'int32') - ]; - const rowPartitionTypes = ['ROW_SPLITS', 'ROW_SPLITS', 'ROW_SPLITS']; - const result = tf.raggedTensorToTensor( - shape, values, defaultValue, rowPartitionTensors, rowPartitionTypes); - - expectArraysEqual(result.shape, shape); - expectArraysClose(await result.data(), [ - 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 1, 2, 3, 4, - 5, 6, 7, 8, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15 - ]); - }); - - it('RaggedTensorToTensorContractExpanded', async () => { - const shape = [3, 5]; - const values = [.1, .2, .3, .4, .5, .6, .7, .8, .9]; - const defaultValue = 1.5; - const rowPartitionTensors = [ - tf.scalar(4, 'int32'), - tf.tensor1d([0, 0, 0, 2, 2, 2, 2, 3, 3], 'int32'), - ]; - const rowPartitionTypes = ['FIRST_DIM_SIZE', 'VALUE_ROWIDS']; - const result = tf.raggedTensorToTensor( - shape, values, defaultValue, rowPartitionTensors, rowPartitionTypes); - - expectArraysEqual(result.shape, shape); - expectArraysClose(await result.data(), [ - .1, .2, .3, 1.5, 1.5, // - 1.5, 1.5, 1.5, 1.5, 1.5, // - .4, .5, .6, .7, 1.5 - ]); - }); - - it('RaggedTensorToTensorContractExpandedDense', async () => { - const shape = [3, 5, 2]; - const values = tf.tensor2d( - [ - .1, 1.1, .2, 1.2, .3, 1.3, .4, 1.4, .5, 1.5, .6, 1.6, .7, 1.7, .8, - 1.8, .9, 1.9 - ], - [9, 2]); - const defaultValue = 1.5; - const rowPartitionTensors = [ - tf.scalar(4, 'int32'), - tf.tensor1d([0, 0, 0, 2, 2, 2, 2, 3, 3], 'int32'), - ]; - const rowPartitionTypes = ['FIRST_DIM_SIZE', 'VALUE_ROWIDS']; - const result = tf.raggedTensorToTensor( - shape, values, defaultValue, rowPartitionTensors, rowPartitionTypes); - - expectArraysEqual(result.shape, shape); - expectArraysClose(await result.data(), [ - .1, 1.1, .2, 1.2, .3, 1.3, 1.5, 1.5, 1.5, 1.5, // - 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, // - .4, 1.4, .5, 1.5, .6, 1.6, .7, 1.7, 1.5, 1.5 - ]); - }); - - it('RaggedTensorToTensorConstrained', async () => { - const shape = [3, 3]; - const values = [.1, .2, .3, .4, .5, .6, .7, .8, .9]; - const defaultValue = 1.5; - const rowPartitionTensors = [ - tf.scalar(4, 'int32'), - tf.tensor1d([0, 0, 0, 2, 2, 2, 2, 3, 3], 'int32'), - ]; - const rowPartitionTypes = ['FIRST_DIM_SIZE', 'VALUE_ROWIDS']; - const result = tf.raggedTensorToTensor( - shape, values, defaultValue, rowPartitionTensors, rowPartitionTypes); - - expectArraysEqual(result.shape, shape); - expectArraysClose(await result.data(), [ - .1, .2, .3, // - 1.5, 1.5, 1.5, // - .4, .5, .6 - ]); - }); - - it('RaggedTensorToTensor3DParamsConstrained', async () => { - const shape = [4, 1, 2]; - const values = [.1, .2, .3, .4, .5, .6, .7, .8, .9]; - const defaultValue = 1.5; - const rowPartitionTensors = [ - tf.scalar(5, 'int32'), - tf.tensor1d([0, 1, 1, 3, 3, 4], 'int32'), - tf.tensor1d([1, 1, 2, 3, 3, 4, 4, 4, 5], 'int32'), - ]; - const rowPartitionTypes = - ['FIRST_DIM_SIZE', 'VALUE_ROWIDS', 'VALUE_ROWIDS']; - const result = tf.raggedTensorToTensor( - shape, values, defaultValue, rowPartitionTensors, rowPartitionTypes); - - expectArraysEqual(result.shape, shape); - expectArraysClose( - await result.data(), [1.5, 1.5, .1, .2, 1.5, 1.5, .4, .5]); - }); - - it('RaggedTensorToTensor4DParamsConstrained', async () => { - const shape = [2, 2, 2, 2]; - const values = [1, 2, 3, 4, 5, 6, 7, 8]; - const defaultValue = 15; - const rowPartitionTensors = [ - tf.scalar(5, 'int32'), - tf.tensor1d([0, 1, 1], 'int32'), - tf.tensor1d([1, 1, 1, 2], 'int32'), - tf.tensor1d([0, 0, 1, 1, 2, 2, 3, 3], 'int32'), - ]; - const rowPartitionTypes = - ['FIRST_DIM_SIZE', 'VALUE_ROWIDS', 'VALUE_ROWIDS', 'VALUE_ROWIDS']; - const result = tf.raggedTensorToTensor( - shape, values, defaultValue, rowPartitionTensors, rowPartitionTypes); - - expectArraysEqual(result.shape, shape); - expectArraysClose(await result.data(), [ - 15, 15, 15, 15, // - 15, 15, 15, 15, // - 1, 2, 3, 4, // - 7, 8, 15, 15, // - ]); - }); - - it('shape wrong dimensions', async () => { - const shape = [10, 7, 10, 20]; - const values = [1, 2, 3, 4]; - const defaultValue = 15; - const rowPartitionTensors = [ - tf.scalar(5, 'int32'), - tf.tensor1d([0, 1, 1], 'int32'), - tf.tensor1d([1, 1, 1, 2], 'int32'), - ]; - const rowPartitionTypes = - ['FIRST_DIM_SIZE', 'VALUE_ROWIDS', 'VALUE_ROWIDS']; - - expect( - () => tf.raggedTensorToTensor( - shape, values, defaultValue, rowPartitionTensors, - rowPartitionTypes)) - .toThrowError(/are incompatible/); - }); - - it('does not have memory leak.', async () => { - const beforeDataIds = tf.engine().backend.numDataIds(); - - const rowPartitionTensors = [ - tf.scalar(4, 'int32'), tf.tensor1d([0, 0, 0, 2, 2, 2, 2, 3, 3], 'int32') - ]; - const result = tf.raggedTensorToTensor( - [4, 4], [.1, .2, .3, .4, .5, .6, .7, .8, .9], 1.5, rowPartitionTensors, - ['FIRST_DIM_SIZE', 'VALUE_ROWIDS']); - - await result.data(); - - const afterResDataIds = tf.engine().backend.numDataIds(); - expect(afterResDataIds).toEqual(beforeDataIds + 3); - - result.dispose(); - rowPartitionTensors.map(tensor => tensor.dispose()); - - const afterDisposeDataIds = tf.engine().backend.numDataIds(); - expect(afterDisposeDataIds).toEqual(beforeDataIds); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/ragged_to_dense_util.ts b/tfjs-master/tfjs-core/src/ops/ragged_to_dense_util.ts deleted file mode 100644 index 4b002e014..000000000 --- a/tfjs-master/tfjs-core/src/ops/ragged_to_dense_util.ts +++ /dev/null @@ -1,138 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -export enum RowPartitionType { - FIRST_DIM_SIZE, - VALUE_ROWIDS, - ROW_LENGTHS, - ROW_SPLITS, - ROW_LIMITS, - ROW_STARTS -} - -export function combineRaggedTensorToTensorShapes( - raggedRank: number, shape: number[], valueShape: number[]) { - // Test for consistency of valueShape and shape specified. - // If shape is unspecified and valueShape is specified, then copy - // over the size from the valueShape dimension. - - let outputShape: number[] = new Array(); - if (valueShape == null && shape == null) { - return outputShape; - } - - if (shape == null) { - // Here, value_shape must be of known size. - while (outputShape.length < raggedRank + valueShape.length) { - outputShape.push(-1); - } - } else { - outputShape = shape.slice(); - } - if (valueShape == null) { - return outputShape; - } - // At this point, valueShape and output_shape have known ranks. - if (raggedRank + valueShape.length !== outputShape.length) { - throw new Error( - `rt input.shape and shape=${shape} are incompatible: rt input.rank = ${ - raggedRank + - valueShape.length}, but shape.rank = ${outputShape.length}`); - } - - for (let i = 1; i < valueShape.length; ++i) { - const valueDim = valueShape[i]; - const outputShapeDimIndex = - outputShape[outputShape.length - valueShape.length + i]; - const outputShapeDim = outputShape[outputShapeDimIndex]; - - if (valueDim >= 0) { - if (outputShapeDim >= 0) { - if (outputShapeDim !== valueDim) { - throw new Error(`rt input.shape and shape=${ - shape} are incompatible: rt input.shape[${i + raggedRank}] = ${ - valueDim} but shape[${i + raggedRank}] = ${outputShapeDim}`); - } - } else { - outputShape[outputShapeDimIndex] = valueDim; - } - } - } - return outputShape; -} - -export function getRowPartitionTypesHelper(rowPartitionTypeStrings: string[]) { - const stringToType = { - 'FIRST_DIM_SIZE': RowPartitionType.FIRST_DIM_SIZE, - 'VALUE_ROWIDS': RowPartitionType.VALUE_ROWIDS, - 'ROW_LENGTHS': RowPartitionType.ROW_LENGTHS, - 'ROW_SPLITS': RowPartitionType.ROW_SPLITS, - 'ROW_LIMITS': RowPartitionType.ROW_LIMITS, - 'ROW_STARTS': RowPartitionType.ROW_STARTS - }; - - const result: RowPartitionType[] = []; - for (const typeStr of rowPartitionTypeStrings) { - if (typeStr in stringToType) { - result.push(stringToType[typeStr as keyof typeof stringToType]); - } else { - break; - } - } - - return result; -} - -export function getRaggedRank(rowPartitionTypes: RowPartitionType[]) { - if (rowPartitionTypes.length === 0) { - return 0; - } - if (rowPartitionTypes[0] === RowPartitionType.FIRST_DIM_SIZE) { - return rowPartitionTypes.length - 1; - } - return rowPartitionTypes.length; -} - -export function validateDefaultValueShape( - defaultValueShape: number[], valueShape: number[]) { - if (defaultValueShape == null || valueShape == null) { - return; - } - - const defaultNDims = defaultValueShape.length; - const valuesNDims = valueShape.length; - if (defaultNDims >= valuesNDims) { - throw new Error(`defaultValue.shape=${ - defaultValueShape} and ragged tensor flatValues.shape=${ - valueShape}, are incompatible: defaultValue.rank = ${ - defaultNDims} must be less than ragged tensor input flatValues.rank = ${ - valuesNDims})`); - } - for (let i = 0; i < Math.min(defaultNDims, valuesNDims - 1); ++i) { - const defaultDim = defaultValueShape[i]; - const valueDim = valueShape[i + 1]; - if (defaultDim >= 0 && valueDim >= 0 && defaultDim !== 1 && - defaultDim !== valueDim) { - throw new Error(`defaultValue.shape=${ - defaultValueShape}, and ragged tensor input flatValues.shape=${ - valueShape} are incompatible: defaultValue.shape[${ - i - defaultValueShape.length}] = ${ - defaultDim} but ragged tensor input.flatValues.shape[${ - i - defaultValueShape.length}] = ${valueDim}`); - } - } -} diff --git a/tfjs-master/tfjs-core/src/ops/rand.ts b/tfjs-master/tfjs-core/src/ops/rand.ts deleted file mode 100644 index 0245756ed..000000000 --- a/tfjs-master/tfjs-core/src/ops/rand.ts +++ /dev/null @@ -1,58 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {Tensor} from '../tensor'; -import {DataType, Rank, ShapeMap} from '../types'; -import {sizeFromShape} from '../util'; -import {assertNonNegativeIntegerDimensions} from '../util_base'; - -import {op} from './operation'; - -/** - * Creates a `tf.Tensor` with values sampled from a random number generator - * function defined by the user. - * - * @param shape An array of integers defining the output tensor shape. - * @param randFunction A random number generator function which is called - * for each element in the output tensor. - * @param dtype The data type of the output tensor. Defaults to 'float32'. - * - * @doc {heading: 'Tensors', subheading: 'Random'} - */ -function rand_( - shape: ShapeMap[R], randFunction: () => number, - dtype?: DataType): Tensor { - assertNonNegativeIntegerDimensions(shape); - const size = sizeFromShape(shape); - let values = null; - if (dtype == null || dtype === 'float32') { - values = new Float32Array(size); - } else if (dtype === 'int32') { - values = new Int32Array(size); - } else if (dtype === 'bool') { - values = new Uint8Array(size); - } else { - throw new Error(`Unknown data type ${dtype}`); - } - for (let i = 0; i < size; i++) { - values[i] = randFunction(); - } - return ENGINE.makeTensor(values, shape, dtype) as Tensor; -} - -export const rand = /* @__PURE__ */ op({rand_}); diff --git a/tfjs-master/tfjs-core/src/ops/rand_test.ts b/tfjs-master/tfjs-core/src/ops/rand_test.ts deleted file mode 100644 index 387f736a1..000000000 --- a/tfjs-master/tfjs-core/src/ops/rand_test.ts +++ /dev/null @@ -1,294 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {util} from '..'; -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectValuesInRange} from '../test_util'; - -import {MPRandGauss, RandGamma, UniformRandom} from './rand_util'; -import {expectArrayInMeanStdRange, jarqueBeraNormalityTest} from './rand_util'; - -describeWithFlags('rand', ALL_ENVS, () => { - it('should return a random 1D float32 array', async () => { - const shape: [number] = [10]; - - // Enusre defaults to float32 w/o type: - let result = tf.rand(shape, () => util.randUniform(0, 2)); - expect(result.dtype).toBe('float32'); - expectValuesInRange(await result.data(), 0, 2); - - result = tf.rand(shape, () => util.randUniform(0, 1.5)); - expect(result.dtype).toBe('float32'); - expectValuesInRange(await result.data(), 0, 1.5); - }); - - it('should return a random 1D int32 array', async () => { - const shape: [number] = [10]; - const result = tf.rand(shape, () => util.randUniform(0, 2), 'int32'); - expect(result.dtype).toBe('int32'); - expectValuesInRange(await result.data(), 0, 2); - }); - - it('should return a random 1D bool array', async () => { - const shape: [number] = [10]; - const result = tf.rand(shape, () => util.randUniform(0, 1), 'bool'); - expect(result.dtype).toBe('bool'); - expectValuesInRange(await result.data(), 0, 1); - }); - - it('should return a random 2D float32 array', async () => { - const shape = [3, 4]; - - // Enusre defaults to float32 w/o type: - let result = tf.rand(shape, () => util.randUniform(0, 2.5)); - expect(result.dtype).toBe('float32'); - expectValuesInRange(await result.data(), 0, 2.5); - - result = tf.rand(shape, () => util.randUniform(0, 1.5), 'float32'); - expect(result.dtype).toBe('float32'); - expectValuesInRange(await result.data(), 0, 1.5); - }); - - it('should return a random 2D int32 array', async () => { - const shape = [3, 4]; - const result = tf.rand(shape, () => util.randUniform(0, 2), 'int32'); - expect(result.dtype).toBe('int32'); - expectValuesInRange(await result.data(), 0, 2); - }); - - it('should return a random 2D bool array', async () => { - const shape = [3, 4]; - const result = tf.rand(shape, () => util.randUniform(0, 1), 'bool'); - expect(result.dtype).toBe('bool'); - expectValuesInRange(await result.data(), 0, 1); - }); - - it('should return a random 3D float32 array', async () => { - const shape = [3, 4, 5]; - - // Enusre defaults to float32 w/o type: - let result = tf.rand(shape, () => util.randUniform(0, 2.5)); - expect(result.dtype).toBe('float32'); - expectValuesInRange(await result.data(), 0, 2.5); - - result = tf.rand(shape, () => util.randUniform(0, 1.5), 'float32'); - expect(result.dtype).toBe('float32'); - expectValuesInRange(await result.data(), 0, 1.5); - }); - - it('should return a random 3D int32 array', async () => { - const shape = [3, 4, 5]; - const result = tf.rand(shape, () => util.randUniform(0, 2), 'int32'); - expect(result.dtype).toBe('int32'); - expectValuesInRange(await result.data(), 0, 2); - }); - - it('should return a random 3D bool array', async () => { - const shape = [3, 4, 5]; - const result = tf.rand(shape, () => util.randUniform(0, 1), 'bool'); - expect(result.dtype).toBe('bool'); - expectValuesInRange(await result.data(), 0, 1); - }); - - it('should return a random 4D float32 array', async () => { - const shape = [3, 4, 5, 6]; - - // Enusre defaults to float32 w/o type: - let result = tf.rand(shape, () => util.randUniform(0, 2.5)); - expect(result.dtype).toBe('float32'); - expectValuesInRange(await result.data(), 0, 2.5); - - result = tf.rand(shape, () => util.randUniform(0, 1.5)); - expect(result.dtype).toBe('float32'); - expectValuesInRange(await result.data(), 0, 1.5); - }); - - it('should return a random 4D int32 array', async () => { - const shape = [3, 4, 5, 6]; - const result = tf.rand(shape, () => util.randUniform(0, 2), 'int32'); - expect(result.dtype).toBe('int32'); - expectValuesInRange(await result.data(), 0, 2); - }); - - it('should return a random 4D bool array', async () => { - const shape = [3, 4, 5, 6]; - const result = tf.rand(shape, () => util.randUniform(0, 1), 'bool'); - expect(result.dtype).toBe('bool'); - expectValuesInRange(await result.data(), 0, 1); - }); - - it('should throw error when shape is not integer', () => { - expect(() => tf.rand([2, 2.22, 3.33], () => util.randUniform(0, 2))) - .toThrow(); - }); -}); - -function isFloat(n: number): boolean { - return Number(n) === n && n % 1 !== 0; -} - -describe('MPRandGauss', () => { - const EPSILON = 0.05; - const SEED = 2002; - - it('should default to float32 numbers', () => { - const rand = new MPRandGauss(0, 1.5); - expect(isFloat(rand.nextValue())).toBe(true); - }); - - it('should handle a mean/stdv of float32 numbers', () => { - const rand = - new MPRandGauss(0, 1.5, 'float32', false /* truncated */, SEED); - const values = []; - const size = 10000; - for (let i = 0; i < size; i++) { - values.push(rand.nextValue()); - } - expectArrayInMeanStdRange(values, 0, 1.5, EPSILON); - jarqueBeraNormalityTest(values); - }); - - it('should handle int32 numbers', () => { - const rand = new MPRandGauss(0, 1, 'int32'); - expect(isFloat(rand.nextValue())).toBe(false); - }); - - it('should handle a mean/stdv of int32 numbers', () => { - const rand = new MPRandGauss(0, 2, 'int32', false /* truncated */, SEED); - const values = []; - const size = 10000; - for (let i = 0; i < size; i++) { - values.push(rand.nextValue()); - } - expectArrayInMeanStdRange(values, 0, 2, EPSILON); - jarqueBeraNormalityTest(values); - }); - - it('Should not have a more than 2x std-d from mean for truncated values', - () => { - const stdv = 1.5; - const rand = new MPRandGauss(0, stdv, 'float32', true /* truncated */); - for (let i = 0; i < 1000; i++) { - expect(Math.abs(rand.nextValue())).toBeLessThan(stdv * 2); - } - }); -}); - -describe('RandGamma', () => { - const SEED = 2002; - - it('should default to float32 numbers', () => { - const rand = new RandGamma(2, 2, 'float32'); - expect(isFloat(rand.nextValue())).toBe(true); - }); - - it('should handle an alpha/beta of float32 numbers', () => { - const rand = new RandGamma(2, 2, 'float32', SEED); - const values = []; - const size = 10000; - for (let i = 0; i < size; i++) { - values.push(rand.nextValue()); - } - expectValuesInRange(values, 0, 30); - }); - - it('should handle int32 numbers', () => { - const rand = new RandGamma(2, 2, 'int32'); - expect(isFloat(rand.nextValue())).toBe(false); - }); - - it('should handle an alpha/beta of int32 numbers', () => { - const rand = new RandGamma(2, 2, 'int32', SEED); - const values = []; - const size = 10000; - for (let i = 0; i < size; i++) { - values.push(rand.nextValue()); - } - expectValuesInRange(values, 0, 30); - }); -}); - -describe('UniformRandom', () => { - it('float32, no seed', () => { - const min = 0.2; - const max = 0.24; - const dtype = 'float32'; - const xs: number[] = []; - for (let i = 0; i < 10; ++i) { - const rand = new UniformRandom(min, max, dtype); - const x = rand.nextValue(); - xs.push(x); - } - expect(Math.min(...xs)).toBeGreaterThanOrEqual(min); - expect(Math.max(...xs)).toBeLessThan(max); - }); - - it('int32, no seed', () => { - const min = 13; - const max = 37; - const dtype = 'int32'; - const xs: number[] = []; - for (let i = 0; i < 10; ++i) { - const rand = new UniformRandom(min, max, dtype); - const x = rand.nextValue(); - expect(Number.isInteger(x)).toEqual(true); - xs.push(x); - } - expect(Math.min(...xs)).toBeGreaterThanOrEqual(min); - expect(Math.max(...xs)).toBeLessThanOrEqual(max); - }); - - it('seed is number', () => { - const min = -1.2; - const max = -0.4; - const dtype = 'float32'; - const seed = 1337; - const xs: number[] = []; - for (let i = 0; i < 10; ++i) { - const rand = new UniformRandom(min, max, dtype, seed); - const x = rand.nextValue(); - expect(x).toBeGreaterThanOrEqual(min); - expect(x).toBeLessThan(max); - xs.push(x); - } - // Assert deterministic results. - expect(Math.min(...xs)).toEqual(Math.max(...xs)); - }); - - it('seed === null', () => { - const min = 0; - const max = 1; - const dtype = 'float32'; - const seed: number = null; - const rand = new UniformRandom(min, max, dtype, seed); - const x = rand.nextValue(); - expect(x).toBeGreaterThanOrEqual(0); - expect(x).toBeLessThan(1); - }); - - it('seed === undefined', () => { - const min = 0; - const max = 1; - const dtype = 'float32'; - const seed: number = undefined; - const rand = new UniformRandom(min, max, dtype, seed); - const x = rand.nextValue(); - expect(x).toBeGreaterThanOrEqual(0); - expect(x).toBeLessThan(1); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/rand_util.ts b/tfjs-master/tfjs-core/src/ops/rand_util.ts deleted file mode 100644 index ccd2f9375..000000000 --- a/tfjs-master/tfjs-core/src/ops/rand_util.ts +++ /dev/null @@ -1,288 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as seedrandom from 'seedrandom'; - -import {expectNumbersClose, testEpsilon} from '../test_util'; -import {TypedArray} from '../types'; - -export interface RandomBase { - nextValue(): number; -} - -export interface RandomGamma { - nextValue(): number; -} - -export interface RandNormalDataTypes { - float32: Float32Array; - int32: Int32Array; -} - -export interface RandGammaDataTypes { - float32: Float32Array; - int32: Int32Array; -} - -// https://en.wikipedia.org/wiki/Marsaglia_polar_method -export class MPRandGauss implements RandomBase { - private mean: number; - private stdDev: number; - private nextVal: number; - private dtype?: keyof RandNormalDataTypes; - private truncated?: boolean; - private upper?: number; - private lower?: number; - private random: seedrandom.prng; - - constructor( - mean: number, stdDeviation: number, dtype?: keyof RandNormalDataTypes, - truncated?: boolean, seed?: number) { - this.mean = mean; - this.stdDev = stdDeviation; - this.dtype = dtype; - this.nextVal = NaN; - this.truncated = truncated; - if (this.truncated) { - this.upper = this.mean + this.stdDev * 2; - this.lower = this.mean - this.stdDev * 2; - } - const seedValue = seed ? seed : Math.random(); - this.random = seedrandom.alea(seedValue.toString()); - } - - /** Returns next sample from a Gaussian distribution. */ - public nextValue(): number { - if (!isNaN(this.nextVal)) { - const value = this.nextVal; - this.nextVal = NaN; - return value; - } - - let resultX: number, resultY: number; - let isValid = false; - while (!isValid) { - let v1: number, v2: number, s: number; - do { - v1 = 2 * this.random() - 1; - v2 = 2 * this.random() - 1; - s = v1 * v1 + v2 * v2; - } while (s >= 1 || s === 0); - - const mul = Math.sqrt(-2.0 * Math.log(s) / s); - resultX = this.mean + this.stdDev * v1 * mul; - resultY = this.mean + this.stdDev * v2 * mul; - - if (!this.truncated || this.isValidTruncated(resultX)) { - isValid = true; - } - } - - if (!this.truncated || this.isValidTruncated(resultY)) { - this.nextVal = this.convertValue(resultY); - } - return this.convertValue(resultX); - } - - /** Handles proper rounding for non-floating-point numbers. */ - private convertValue(value: number): number { - if (this.dtype == null || this.dtype === 'float32') { - return value; - } - return Math.round(value); - } - - /** Returns true if less than 2-standard-deviations from the mean. */ - private isValidTruncated(value: number): boolean { - return value <= this.upper && value >= this.lower; - } -} - -// Marsaglia, George, and Wai Wan Tsang. 2000. "A Simple Method for Generating -// Gamma Variables." -export class RandGamma implements RandomGamma { - private alpha: number; - private beta: number; - private d: number; - private c: number; - private dtype?: keyof RandGammaDataTypes; - private randu: seedrandom.prng; - private randn: MPRandGauss; - - constructor( - alpha: number, beta: number, dtype: keyof RandGammaDataTypes, - seed?: number) { - this.alpha = alpha; - this.beta = 1 / beta; // convert rate to scale parameter - this.dtype = dtype; - - const seedValue = seed ? seed : Math.random(); - this.randu = seedrandom.alea(seedValue.toString()); - this.randn = new MPRandGauss(0, 1, dtype, false, this.randu()); - - if (alpha < 1) { - this.d = alpha + (2 / 3); - } else { - this.d = alpha - (1 / 3); - } - this.c = 1 / Math.sqrt(9 * this.d); - } - - /** Returns next sample from a gamma distribution. */ - public nextValue(): number { - let x2: number, v0: number, v1: number, x: number, u: number, v: number; - while (true) { - do { - x = this.randn.nextValue(); - v = 1 + (this.c * x); - } while (v <= 0); - v *= v * v; - x2 = x * x; - v0 = 1 - (0.331 * x2 * x2); - v1 = (0.5 * x2) + (this.d * (1 - v + Math.log(v))); - u = this.randu(); - if (u < v0 || Math.log(u) < v1) { - break; - } - } - v = (1 / this.beta) * this.d * v; - if (this.alpha < 1) { - v *= Math.pow(this.randu(), 1 / this.alpha); - } - return this.convertValue(v); - } - /** Handles proper rounding for non-floating-point numbers. */ - private convertValue(value: number): number { - if (this.dtype === 'float32') { - return value; - } - return Math.round(value); - } -} - -export class UniformRandom implements RandomBase { - private min: number; - private range: number; - private random: seedrandom.prng; - private dtype?: keyof RandNormalDataTypes; - - constructor( - min = 0, max = 1, dtype?: keyof RandNormalDataTypes, - seed?: string|number) { - this.min = min; - this.range = max - min; - this.dtype = dtype; - if (seed == null) { - seed = Math.random(); - } - if (typeof seed === 'number') { - seed = seed.toString(); - } - - if (!this.canReturnFloat() && this.range <= 1) { - throw new Error( - `The difference between ${min} - ${max} <= 1 and dtype is not float`); - } - this.random = seedrandom.alea(seed); - } - - /** Handles proper rounding for non floating point numbers. */ - private canReturnFloat = () => - (this.dtype == null || this.dtype === 'float32'); - - private convertValue(value: number): number { - if (this.canReturnFloat()) { - return value; - } - return Math.round(value); - } - - nextValue() { - return this.convertValue(this.min + this.range * this.random()); - } -} - -export function jarqueBeraNormalityTest(values: TypedArray|number[]) { - // https://en.wikipedia.org/wiki/Jarque%E2%80%93Bera_test - const n = values.length; - const s = skewness(values); - const k = kurtosis(values); - const jb = n / 6 * (Math.pow(s, 2) + 0.25 * Math.pow(k - 3, 2)); - // JB test requires 2-degress of freedom from Chi-Square @ 0.95: - // http://www.itl.nist.gov/div898/handbook/eda/section3/eda3674.htm - const CHI_SQUARE_2DEG = 5.991; - if (jb > CHI_SQUARE_2DEG) { - throw new Error(`Invalid p-value for JB: ${jb}`); - } -} - -export function expectArrayInMeanStdRange( - actual: TypedArray|number[], expectedMean: number, expectedStdDev: number, - epsilon?: number) { - if (epsilon == null) { - epsilon = testEpsilon(); - } - const actualMean = mean(actual); - expectNumbersClose(actualMean, expectedMean, epsilon); - expectNumbersClose( - standardDeviation(actual, actualMean), expectedStdDev, epsilon); -} - -function mean(values: TypedArray|number[]) { - let sum = 0; - for (let i = 0; i < values.length; i++) { - sum += values[i]; - } - return sum / values.length; -} - -function standardDeviation(values: TypedArray|number[], mean: number) { - let squareDiffSum = 0; - for (let i = 0; i < values.length; i++) { - const diff = values[i] - mean; - squareDiffSum += diff * diff; - } - return Math.sqrt(squareDiffSum / values.length); -} - -function kurtosis(values: TypedArray|number[]) { - // https://en.wikipedia.org/wiki/Kurtosis - const valuesMean = mean(values); - const n = values.length; - let sum2 = 0; - let sum4 = 0; - for (let i = 0; i < n; i++) { - const v = values[i] - valuesMean; - sum2 += Math.pow(v, 2); - sum4 += Math.pow(v, 4); - } - return (1 / n) * sum4 / Math.pow((1 / n) * sum2, 2); -} - -function skewness(values: TypedArray|number[]) { - // https://en.wikipedia.org/wiki/Skewness - const valuesMean = mean(values); - const n = values.length; - let sum2 = 0; - let sum3 = 0; - for (let i = 0; i < n; i++) { - const v = values[i] - valuesMean; - sum2 += Math.pow(v, 2); - sum3 += Math.pow(v, 3); - } - return (1 / n) * sum3 / Math.pow((1 / (n - 1)) * sum2, 3 / 2); -} diff --git a/tfjs-master/tfjs-core/src/ops/random_gamma.ts b/tfjs-master/tfjs-core/src/ops/random_gamma.ts deleted file mode 100644 index 36f537596..000000000 --- a/tfjs-master/tfjs-core/src/ops/random_gamma.ts +++ /dev/null @@ -1,63 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Tensor} from '../tensor'; -import {Rank, ShapeMap} from '../types'; -import {assertNonNegativeIntegerDimensions} from '../util_base'; - -import {buffer} from './buffer'; -import {op} from './operation'; -import {RandGamma} from './rand_util'; - -/** - * Creates a `tf.Tensor` with values sampled from a gamma distribution. - * - * ```js - * tf.randomGamma([2, 2], 1).print(); - * ``` - * - * @param shape An array of integers defining the output tensor shape. - * @param alpha The shape parameter of the gamma distribution. - * @param beta The inverse scale parameter of the gamma distribution. Defaults - * to 1. - * @param dtype The data type of the output. Defaults to float32. - * @param seed The seed for the random number generator. - * - * @doc {heading: 'Tensors', subheading: 'Random'} - */ -function randomGamma_( - shape: ShapeMap[R], alpha: number, beta = 1, - dtype: 'float32'|'int32' = 'float32', seed?: number): Tensor { - assertNonNegativeIntegerDimensions(shape); - if (beta == null) { - beta = 1; - } - if (dtype == null) { - dtype = 'float32'; - } - if (dtype !== 'float32' && dtype !== 'int32') { - throw new Error(`Unsupported data type ${dtype}`); - } - const rgamma = new RandGamma(alpha, beta, dtype, seed); - const res = buffer(shape, dtype); - for (let i = 0; i < res.values.length; i++) { - res.values[i] = rgamma.nextValue(); - } - return res.toTensor(); -} - -export const randomGamma = /* @__PURE__ */ op({randomGamma_}); diff --git a/tfjs-master/tfjs-core/src/ops/random_gamma_test.ts b/tfjs-master/tfjs-core/src/ops/random_gamma_test.ts deleted file mode 100644 index 6d95400cb..000000000 --- a/tfjs-master/tfjs-core/src/ops/random_gamma_test.ts +++ /dev/null @@ -1,129 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectValuesInRange} from '../test_util'; - -const GAMMA_MIN = 0; -const GAMMA_MAX = 40; - -describeWithFlags('randomGamma', ALL_ENVS, () => { - it('should return a random 1D float32 array', async () => { - const shape: [number] = [10]; - - // Ensure defaults to float32 w/o type: - let result = tf.randomGamma(shape, 2, 2); - expect(result.dtype).toBe('float32'); - expectValuesInRange(await result.data(), GAMMA_MIN, GAMMA_MAX); - - result = tf.randomGamma(shape, 2, 2, 'float32'); - expect(result.dtype).toBe('float32'); - expectValuesInRange(await result.data(), GAMMA_MIN, GAMMA_MAX); - }); - - it('should return a random 1D int32 array', async () => { - const shape: [number] = [10]; - const result = tf.randomGamma(shape, 2, 2, 'int32'); - expect(result.dtype).toBe('int32'); - expectValuesInRange(await result.data(), GAMMA_MIN, GAMMA_MAX); - }); - - it('should return a random 2D float32 array', async () => { - const shape: [number, number] = [3, 4]; - - // Ensure defaults to float32 w/o type: - let result = tf.randomGamma(shape, 2, 2); - expect(result.dtype).toBe('float32'); - expectValuesInRange(await result.data(), GAMMA_MIN, GAMMA_MAX); - - result = tf.randomGamma(shape, 2, 2, 'float32'); - expect(result.dtype).toBe('float32'); - expectValuesInRange(await result.data(), GAMMA_MIN, GAMMA_MAX); - }); - - it('should return a random 2D int32 array', async () => { - const shape: [number, number] = [3, 4]; - const result = tf.randomGamma(shape, 2, 2, 'int32'); - expect(result.dtype).toBe('int32'); - expectValuesInRange(await result.data(), GAMMA_MIN, GAMMA_MAX); - }); - - it('should return a random 3D float32 array', async () => { - const shape: [number, number, number] = [3, 4, 5]; - - // Ensure defaults to float32 w/o type: - let result = tf.randomGamma(shape, 2, 2); - expect(result.dtype).toBe('float32'); - expectValuesInRange(await result.data(), GAMMA_MIN, GAMMA_MAX); - - result = tf.randomGamma(shape, 2, 2, 'float32'); - expect(result.dtype).toBe('float32'); - expectValuesInRange(await result.data(), GAMMA_MIN, GAMMA_MAX); - }); - - it('should return a random 3D int32 array', async () => { - const shape: [number, number, number] = [3, 4, 5]; - const result = tf.randomGamma(shape, 2, 2, 'int32'); - expect(result.dtype).toBe('int32'); - expectValuesInRange(await result.data(), GAMMA_MIN, GAMMA_MAX); - }); - - it('should return a random 4D float32 array', async () => { - const shape: [number, number, number, number] = [3, 4, 5, 6]; - - // Ensure defaults to float32 w/o type: - let result = tf.randomGamma(shape, 2, 2); - expect(result.dtype).toBe('float32'); - expectValuesInRange(await result.data(), GAMMA_MIN, GAMMA_MAX); - - result = tf.randomGamma(shape, 2, 2, 'float32'); - expect(result.dtype).toBe('float32'); - expectValuesInRange(await result.data(), GAMMA_MIN, GAMMA_MAX); - }); - - it('should return a random 4D int32 array', async () => { - const shape: [number, number, number, number] = [3, 4, 5, 6]; - const result = tf.randomGamma(shape, 2, 2, 'int32'); - expect(result.dtype).toBe('int32'); - expectValuesInRange(await result.data(), GAMMA_MIN, GAMMA_MAX); - }); - - it('should return a random 5D float32 array', async () => { - const shape: [number, number, number, number, number] = [2, 3, 4, 5, 6]; - - // Ensure defaults to float32 w/o type: - let result = tf.randomGamma(shape, 2, 2); - expect(result.dtype).toBe('float32'); - expectValuesInRange(await result.data(), GAMMA_MIN, GAMMA_MAX); - - result = tf.randomGamma(shape, 2, 2, 'float32'); - expect(result.dtype).toBe('float32'); - expectValuesInRange(await result.data(), GAMMA_MIN, GAMMA_MAX); - }); - - it('should return a random 5D int32 array', async () => { - const shape: [number, number, number, number, number] = [2, 3, 4, 5, 6]; - const result = tf.randomGamma(shape, 2, 2, 'int32'); - expect(result.dtype).toBe('int32'); - expectValuesInRange(await result.data(), GAMMA_MIN, GAMMA_MAX); - }); - - it('should throw error when shape is not integer', () => { - expect(() => tf.randomGamma([2, 2.22, 3.33], 2, 2)).toThrow(); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/random_normal.ts b/tfjs-master/tfjs-core/src/ops/random_normal.ts deleted file mode 100644 index 4a14f9476..000000000 --- a/tfjs-master/tfjs-core/src/ops/random_normal.ts +++ /dev/null @@ -1,57 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Tensor} from '../tensor'; -import {DataType, Rank, ShapeMap} from '../types'; -import {assertNonNegativeIntegerDimensions} from '../util_base'; - -import {buffer} from './buffer'; -import {op} from './operation'; -import {MPRandGauss} from './rand_util'; - -/** - * Creates a `tf.Tensor` with values sampled from a normal distribution. - * - * ```js - * tf.randomNormal([2, 2]).print(); - * ``` - * - * @param shape An array of integers defining the output tensor shape. - * @param mean The mean of the normal distribution. - * @param stdDev The standard deviation of the normal distribution. - * @param dtype The data type of the output. - * @param seed The seed for the random number generator. - * - * @doc {heading: 'Tensors', subheading: 'Random'} - */ -function randomNormal_( - shape: ShapeMap[R], mean = 0, stdDev = 1, dtype?: 'float32'|'int32', - seed?: number): Tensor { - assertNonNegativeIntegerDimensions(shape); - if (dtype != null && (dtype as DataType) === 'bool') { - throw new Error(`Unsupported data type ${dtype}`); - } - const randGauss = - new MPRandGauss(mean, stdDev, dtype, false /* truncated */, seed); - const res = buffer(shape, dtype); - for (let i = 0; i < res.values.length; i++) { - res.values[i] = randGauss.nextValue(); - } - return res.toTensor(); -} - -export const randomNormal = /* @__PURE__ */ op({randomNormal_}); diff --git a/tfjs-master/tfjs-core/src/ops/random_normal_test.ts b/tfjs-master/tfjs-core/src/ops/random_normal_test.ts deleted file mode 100644 index 16a1f4f36..000000000 --- a/tfjs-master/tfjs-core/src/ops/random_normal_test.ts +++ /dev/null @@ -1,146 +0,0 @@ - -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArrayInMeanStdRange, jarqueBeraNormalityTest} from './rand_util'; - -describeWithFlags('randomNormal', ALL_ENVS, () => { - const SEED = 2002; - const EPSILON = 0.05; - - it('should return a float32 1D of random normal values', async () => { - const SAMPLES = 10000; - - // Ensure defaults to float32. - let result = tf.randomNormal([SAMPLES], 0, 0.5, null, SEED); - expect(result.dtype).toBe('float32'); - expect(result.shape).toEqual([SAMPLES]); - jarqueBeraNormalityTest(await result.data()); - expectArrayInMeanStdRange(await result.data(), 0, 0.5, EPSILON); - - result = tf.randomNormal([SAMPLES], 0, 1.5, 'float32', SEED); - expect(result.dtype).toBe('float32'); - expect(result.shape).toEqual([SAMPLES]); - jarqueBeraNormalityTest(await result.data()); - expectArrayInMeanStdRange(await result.data(), 0, 1.5, EPSILON); - }); - - it('should return a int32 1D of random normal values', async () => { - const SAMPLES = 10000; - const result = tf.randomNormal([SAMPLES], 0, 2, 'int32', SEED); - expect(result.dtype).toBe('int32'); - expect(result.shape).toEqual([SAMPLES]); - jarqueBeraNormalityTest(await result.data()); - expectArrayInMeanStdRange(await result.data(), 0, 2, EPSILON); - }); - - it('should return a float32 2D of random normal values', async () => { - const SAMPLES = 100; - - // Ensure defaults to float32. - let result = tf.randomNormal([SAMPLES, SAMPLES], 0, 2.5, null, SEED); - expect(result.dtype).toBe('float32'); - expect(result.shape).toEqual([SAMPLES, SAMPLES]); - jarqueBeraNormalityTest(await result.data()); - expectArrayInMeanStdRange(await result.data(), 0, 2.5, EPSILON); - - result = tf.randomNormal([SAMPLES, SAMPLES], 0, 3.5, 'float32', SEED); - expect(result.dtype).toBe('float32'); - expect(result.shape).toEqual([SAMPLES, SAMPLES]); - jarqueBeraNormalityTest(await result.data()); - expectArrayInMeanStdRange(await result.data(), 0, 3.5, EPSILON); - }); - - it('should return a int32 2D of random normal values', async () => { - const SAMPLES = 100; - const result = tf.randomNormal([SAMPLES, SAMPLES], 0, 2, 'int32', SEED); - expect(result.dtype).toBe('int32'); - expect(result.shape).toEqual([SAMPLES, SAMPLES]); - jarqueBeraNormalityTest(await result.data()); - expectArrayInMeanStdRange(await result.data(), 0, 2, EPSILON); - }); - - it('should return a float32 3D of random normal values', async () => { - const SAMPLES_SHAPE = [20, 20, 20]; - - // Ensure defaults to float32. - let result = tf.randomNormal(SAMPLES_SHAPE, 0, 0.5, null, SEED); - expect(result.dtype).toBe('float32'); - expect(result.shape).toEqual(SAMPLES_SHAPE); - jarqueBeraNormalityTest(await result.data()); - expectArrayInMeanStdRange(await result.data(), 0, 0.5, EPSILON); - - result = tf.randomNormal(SAMPLES_SHAPE, 0, 1.5, 'float32', SEED); - expect(result.dtype).toBe('float32'); - expect(result.shape).toEqual(SAMPLES_SHAPE); - jarqueBeraNormalityTest(await result.data()); - expectArrayInMeanStdRange(await result.data(), 0, 1.5, EPSILON); - }); - - it('should return a int32 3D of random normal values', async () => { - const SAMPLES_SHAPE = [20, 20, 20]; - const result = tf.randomNormal(SAMPLES_SHAPE, 0, 2, 'int32', SEED); - expect(result.dtype).toBe('int32'); - expect(result.shape).toEqual(SAMPLES_SHAPE); - jarqueBeraNormalityTest(await result.data()); - expectArrayInMeanStdRange(await result.data(), 0, 2, EPSILON); - }); - - it('should return a float32 4D of random normal values', async () => { - const SAMPLES_SHAPE = [10, 10, 10, 10]; - - // Ensure defaults to float32. - let result = tf.randomNormal(SAMPLES_SHAPE, 0, 0.5, null, SEED); - expect(result.dtype).toBe('float32'); - expect(result.shape).toEqual(SAMPLES_SHAPE); - jarqueBeraNormalityTest(await result.data()); - expectArrayInMeanStdRange(await result.data(), 0, 0.5, EPSILON); - - result = tf.randomNormal(SAMPLES_SHAPE, 0, 1.5, 'float32', SEED); - expect(result.dtype).toBe('float32'); - expect(result.shape).toEqual(SAMPLES_SHAPE); - jarqueBeraNormalityTest(await result.data()); - expectArrayInMeanStdRange(await result.data(), 0, 1.5, EPSILON); - }); - - it('should return a int32 4D of random normal values', async () => { - const SAMPLES_SHAPE = [10, 10, 10, 10]; - - const result = tf.randomNormal(SAMPLES_SHAPE, 0, 2, 'int32', SEED); - expect(result.dtype).toBe('int32'); - expect(result.shape).toEqual(SAMPLES_SHAPE); - jarqueBeraNormalityTest(await result.data()); - expectArrayInMeanStdRange(await result.data(), 0, 2, EPSILON); - }); - - it('should return a int32 5D of random normal values', async () => { - const SAMPLES_SHAPE = [10, 10, 10, 10, 10]; - - const result = tf.randomNormal(SAMPLES_SHAPE, 0, 2, 'int32', SEED); - expect(result.dtype).toBe('int32'); - expect(result.shape).toEqual(SAMPLES_SHAPE); - jarqueBeraNormalityTest(await result.data()); - expectArrayInMeanStdRange(await result.data(), 0, 2, EPSILON); - }); - - it('should throw error when shape is not integer', () => { - expect(() => tf.randomNormal([2, 2.22, 3.33], 0, 2, 'int32', SEED)) - .toThrow(); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/random_standard_normal.ts b/tfjs-master/tfjs-core/src/ops/random_standard_normal.ts deleted file mode 100644 index 417147dc5..000000000 --- a/tfjs-master/tfjs-core/src/ops/random_standard_normal.ts +++ /dev/null @@ -1,47 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Tensor} from '../tensor'; -import {DataType, Rank, ShapeMap} from '../types'; - -import {op} from './operation'; -import {randomNormal} from './random_normal'; - -/** - * Creates a `tf.Tensor` with values sampled from a normal distribution. - * - * The generated values will have mean 0 and standard deviation 1. - * - * ```js - * tf.randomStandardNormal([2, 2]).print(); - * ``` - * - * @param shape An array of integers defining the output tensor shape. - * @param dtype The data type of the output. - * @param seed The seed for the random number generator. - * - * @doc {heading: 'Tensors', subheading: 'Random'} - */ -function randomStandardNormal_( - shape: ShapeMap[R], dtype?: 'float32'|'int32', seed?: number): Tensor { - if (dtype != null && (dtype as DataType) === 'bool') { - throw new Error(`Unsupported data type ${dtype}`); - } - return randomNormal(shape, 0, 1, dtype, seed); -} - -export const randomStandardNormal = /* @__PURE__ */ op({randomStandardNormal_}); diff --git a/tfjs-master/tfjs-core/src/ops/random_standard_normal_test.ts b/tfjs-master/tfjs-core/src/ops/random_standard_normal_test.ts deleted file mode 100644 index 189a783f2..000000000 --- a/tfjs-master/tfjs-core/src/ops/random_standard_normal_test.ts +++ /dev/null @@ -1,146 +0,0 @@ - -/** - * @license - * Copyright 2022 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; - -import {expectArrayInMeanStdRange, jarqueBeraNormalityTest} from './rand_util'; - -describeWithFlags('randomStandardNormal', ALL_ENVS, () => { - const SEED = 42; - const EPSILON = 0.05; - - it('should return a float32 1D of random standard normal values', - async () => { - const SAMPLES = 10000; - - // Ensure defaults to float32. - let result = tf.randomStandardNormal([SAMPLES], null, SEED); - expect(result.dtype).toBe('float32'); - expect(result.shape).toEqual([SAMPLES]); - jarqueBeraNormalityTest(await result.data()); - expectArrayInMeanStdRange(await result.data(), 0, 1, EPSILON); - - result = tf.randomStandardNormal([SAMPLES], 'float32', SEED); - expect(result.dtype).toBe('float32'); - expect(result.shape).toEqual([SAMPLES]); - jarqueBeraNormalityTest(await result.data()); - expectArrayInMeanStdRange(await result.data(), 0, 1, EPSILON); - }); - - it('should return a int32 1D of random standard normal values', async () => { - const SAMPLES = 10000; - const result = tf.randomStandardNormal([SAMPLES], 'int32', SEED); - expect(result.dtype).toBe('int32'); - expect(result.shape).toEqual([SAMPLES]); - jarqueBeraNormalityTest(await result.data()); - expectArrayInMeanStdRange(await result.data(), 0, 1, EPSILON); - }); - - it('should return a float32 2D of random standard normal values', - async () => { - const SAMPLES = 100; - - // Ensure defaults to float32. - let result = tf.randomStandardNormal([SAMPLES, SAMPLES], null, SEED); - expect(result.dtype).toBe('float32'); - expect(result.shape).toEqual([SAMPLES, SAMPLES]); - jarqueBeraNormalityTest(await result.data()); - expectArrayInMeanStdRange(await result.data(), 0, 1, EPSILON); - - result = tf.randomStandardNormal([SAMPLES, SAMPLES], 'float32', SEED); - expect(result.dtype).toBe('float32'); - expect(result.shape).toEqual([SAMPLES, SAMPLES]); - jarqueBeraNormalityTest(await result.data()); - expectArrayInMeanStdRange(await result.data(), 0, 1, EPSILON); - }); - - it('should return a int32 2D of random standard normal values', async () => { - const SAMPLES = 100; - const result = tf.randomStandardNormal([SAMPLES, SAMPLES], 'int32', SEED); - expect(result.dtype).toBe('int32'); - expect(result.shape).toEqual([SAMPLES, SAMPLES]); - jarqueBeraNormalityTest(await result.data()); - expectArrayInMeanStdRange(await result.data(), 0, 1, EPSILON); - }); - - it('should return a float32 3D of random standard normal values', - async () => { - const SAMPLES_SHAPE = [20, 20, 20]; - - // Ensure defaults to float32. - let result = tf.randomStandardNormal(SAMPLES_SHAPE, null, SEED); - expect(result.dtype).toBe('float32'); - expect(result.shape).toEqual(SAMPLES_SHAPE); - jarqueBeraNormalityTest(await result.data()); - expectArrayInMeanStdRange(await result.data(), 0, 1, EPSILON); - - result = tf.randomStandardNormal(SAMPLES_SHAPE, 'float32', SEED); - expect(result.dtype).toBe('float32'); - expect(result.shape).toEqual(SAMPLES_SHAPE); - jarqueBeraNormalityTest(await result.data()); - expectArrayInMeanStdRange(await result.data(), 0, 1, EPSILON); - }); - - it('should return a int32 3D of random standard normal values', async () => { - const SAMPLES_SHAPE = [20, 20, 20]; - const result = tf.randomStandardNormal(SAMPLES_SHAPE, 'int32', SEED); - expect(result.dtype).toBe('int32'); - expect(result.shape).toEqual(SAMPLES_SHAPE); - jarqueBeraNormalityTest(await result.data()); - expectArrayInMeanStdRange(await result.data(), 0, 1, EPSILON); - }); - - it('should return a float32 4D of random standard normal values', - async () => { - const SAMPLES_SHAPE = [10, 10, 10, 10]; - - // Ensure defaults to float32. - let result = tf.randomStandardNormal(SAMPLES_SHAPE, null, SEED); - expect(result.dtype).toBe('float32'); - expect(result.shape).toEqual(SAMPLES_SHAPE); - jarqueBeraNormalityTest(await result.data()); - expectArrayInMeanStdRange(await result.data(), 0, 1, EPSILON); - - result = tf.randomStandardNormal(SAMPLES_SHAPE, 'float32', SEED); - expect(result.dtype).toBe('float32'); - expect(result.shape).toEqual(SAMPLES_SHAPE); - jarqueBeraNormalityTest(await result.data()); - expectArrayInMeanStdRange(await result.data(), 0, 1, EPSILON); - }); - - it('should return a int32 4D of random standard normal values', async () => { - const SAMPLES_SHAPE = [10, 10, 10, 10]; - - const result = tf.randomStandardNormal(SAMPLES_SHAPE, 'int32', SEED); - expect(result.dtype).toBe('int32'); - expect(result.shape).toEqual(SAMPLES_SHAPE); - jarqueBeraNormalityTest(await result.data()); - expectArrayInMeanStdRange(await result.data(), 0, 1, EPSILON); - }); - - it('should return a int32 5D of random standard normal values', async () => { - const SAMPLES_SHAPE = [10, 10, 10, 10, 10]; - - const result = tf.randomStandardNormal(SAMPLES_SHAPE, 'int32', SEED); - expect(result.dtype).toBe('int32'); - expect(result.shape).toEqual(SAMPLES_SHAPE); - jarqueBeraNormalityTest(await result.data()); - expectArrayInMeanStdRange(await result.data(), 0, 1, EPSILON); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/random_uniform.ts b/tfjs-master/tfjs-core/src/ops/random_uniform.ts deleted file mode 100644 index 93ace1e41..000000000 --- a/tfjs-master/tfjs-core/src/ops/random_uniform.ts +++ /dev/null @@ -1,61 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Tensor} from '../tensor'; -import {DataType, Rank, ShapeMap} from '../types'; -import {assertNonNegativeIntegerDimensions} from '../util_base'; - -import {buffer} from './buffer'; -import {op} from './operation'; -import {UniformRandom} from './rand_util'; - -/** - * Creates a `tf.Tensor` with values sampled from a uniform distribution. - * - * The generated values follow a uniform distribution in the range [minval, - * maxval). The lower bound minval is included in the range, while the upper - * bound maxval is excluded. - * - * ```js - * tf.randomUniform([2, 2]).print(); - * ``` - * - * @param shape An array of integers defining the output tensor shape. - * @param minval The lower bound on the range of random values to generate. - * Defaults to 0. - * @param maxval The upper bound on the range of random values to generate. - * Defaults to 1. - * @param dtype The data type of the output tensor. Defaults to 'float32'. - * @param seed An optional int. Defaults to 0. If seed is set to be non-zero, - * the random number generator is seeded by the given seed. Otherwise, it is - * seeded by a random seed. - * - * @doc {heading: 'Tensors', subheading: 'Random'} - */ -function randomUniform_( - shape: ShapeMap[R], minval = 0, maxval = 1, dtype: DataType = 'float32', - seed?: number|string): Tensor { - assertNonNegativeIntegerDimensions(shape); - const res = buffer(shape, dtype); - const random = new UniformRandom(minval, maxval, null, seed); - for (let i = 0; i < res.values.length; i++) { - res.values[i] = random.nextValue(); - } - return res.toTensor(); -} - -export const randomUniform = /* @__PURE__ */ op({randomUniform_}); diff --git a/tfjs-master/tfjs-core/src/ops/random_uniform_int.ts b/tfjs-master/tfjs-core/src/ops/random_uniform_int.ts deleted file mode 100644 index 9d64584df..000000000 --- a/tfjs-master/tfjs-core/src/ops/random_uniform_int.ts +++ /dev/null @@ -1,50 +0,0 @@ -/** - * @license - * Copyright 2023 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Tensor} from '../tensor'; -import {Rank, ShapeMap} from '../types'; -import {op} from './operation'; -import {randomUniform} from './random_uniform'; - -/** - * Creates a `tf.Tensor` with integers sampled from a uniform distribution. - * - * The generated values are uniform integers in the range [minval, maxval). The - * lower bound minval is included in the range, while the upper bound maxval is - * excluded. - * - * ```js - * tf.randomUniformInt([2, 2], 0, 10).print(); - * ``` - * - * @param shape An array of integers defining the output tensor shape. - * @param minval Inclusive lower bound on the generated integers. - * @param maxval Exclusive upper bound on the generated integers. - * @param seed An optional int. Defaults to 0. If seed is set to be non-zero, - * the random number generator is seeded by the given seed. Otherwise, it is - * seeded by a random seed. - * - * @doc {heading: 'Tensors', subheading: 'Random'} - */ -function randomUniformInt_( - shape: ShapeMap[R], minval: number, maxval: number, - seed?: number|string): Tensor { - // TODO(mattsoulanille): Handle optional seed2 input. - return randomUniform(shape, minval, maxval, 'int32', seed); -} - -export const randomUniformInt = /* @__PURE__ */ op({randomUniformInt_}); diff --git a/tfjs-master/tfjs-core/src/ops/random_uniform_int_test.ts b/tfjs-master/tfjs-core/src/ops/random_uniform_int_test.ts deleted file mode 100644 index c3e7de21a..000000000 --- a/tfjs-master/tfjs-core/src/ops/random_uniform_int_test.ts +++ /dev/null @@ -1,69 +0,0 @@ -/** - * @license - * Copyright 2023 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import { expectArraysEqual, expectValuesInRange} from '../test_util'; - -describeWithFlags('randomUniformInt', ALL_ENVS, () => { - it('should return a random 1D int32 array', async () => { - const shape: [number] = [10]; - const result = tf.randomUniformInt(shape, 0, 2); - expect(result.dtype).toBe('int32'); - expectValuesInRange(await result.data(), 0, 2); - }); - - it('should return a random 2D int32 array', async () => { - const shape: [number, number] = [3, 4]; - const result = tf.randomUniformInt(shape, 0, 2); - expect(result.dtype).toBe('int32'); - expectValuesInRange(await result.data(), 0, 2); - }); - - it('should return a random 3D int32 array', async () => { - const shape: [number, number, number] = [3, 4, 5]; - const result = tf.randomUniformInt(shape, 0, 2); - expect(result.dtype).toBe('int32'); - expectValuesInRange(await result.data(), 0, 2); - }); - - it('should return a random 4D int32 array', async () => { - const shape: [number, number, number, number] = [3, 4, 5, 6]; - const result = tf.randomUniformInt(shape, 0, 2); - expect(result.dtype).toBe('int32'); - expectValuesInRange(await result.data(), 0, 2); - }); - - it('should return a random 5D int32 array', async () => { - const shape: [number, number, number, number, number] = [2, 3, 4, 5, 6]; - const result = tf.randomUniformInt(shape, 0, 2); - expect(result.dtype).toBe('int32'); - expectValuesInRange(await result.data(), 0, 2); - }); - - it('should throw error when shape is not integer', () => { - expect(() => tf.randomUniformInt([2, 2.22, 3.33], 0, 1)).toThrow(); - }); - - it('should return the same result when seed is specified', async () => { - const seed = 123; - const shape = [4, 4]; - const result1 = tf.randomUniformInt(shape, 0, 1000, seed); - const result2 = tf.randomUniformInt(shape, 0, 1000, seed); - expectArraysEqual(await result1.data(), await result2.data()); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/random_uniform_test.ts b/tfjs-master/tfjs-core/src/ops/random_uniform_test.ts deleted file mode 100644 index 5da5946ca..000000000 --- a/tfjs-master/tfjs-core/src/ops/random_uniform_test.ts +++ /dev/null @@ -1,161 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectValuesInRange} from '../test_util'; - -describeWithFlags('randomUniform', ALL_ENVS, () => { - it('should return a random 1D float32 array', async () => { - const shape: [number] = [10]; - - // Ensure defaults to float32 w/o type: - let result = tf.randomUniform(shape, 0, 2.5); - expect(result.dtype).toBe('float32'); - expectValuesInRange(await result.data(), 0, 2.5); - - result = tf.randomUniform(shape, 0, 1.5, 'float32'); - expect(result.dtype).toBe('float32'); - expectValuesInRange(await result.data(), 0, 1.5); - }); - - it('should return a random 1D int32 array', async () => { - const shape: [number] = [10]; - const result = tf.randomUniform(shape, 0, 2, 'int32'); - expect(result.dtype).toBe('int32'); - expectValuesInRange(await result.data(), 0, 2); - }); - - it('should return a random 1D bool array', async () => { - const shape: [number] = [10]; - const result = tf.randomUniform(shape, 0, 1, 'bool'); - expect(result.dtype).toBe('bool'); - expectValuesInRange(await result.data(), 0, 1); - }); - - it('should return a random 2D float32 array', async () => { - const shape: [number, number] = [3, 4]; - - // Ensure defaults to float32 w/o type: - let result = tf.randomUniform(shape, 0, 2.5); - expect(result.dtype).toBe('float32'); - expectValuesInRange(await result.data(), 0, 2.5); - - result = tf.randomUniform(shape, 0, 1.5, 'float32'); - expect(result.dtype).toBe('float32'); - expectValuesInRange(await result.data(), 0, 1.5); - }); - - it('should return a random 2D int32 array', async () => { - const shape: [number, number] = [3, 4]; - const result = tf.randomUniform(shape, 0, 2, 'int32'); - expect(result.dtype).toBe('int32'); - expectValuesInRange(await result.data(), 0, 2); - }); - - it('should return a random 2D bool array', async () => { - const shape: [number, number] = [3, 4]; - const result = tf.randomUniform(shape, 0, 1, 'bool'); - expect(result.dtype).toBe('bool'); - expectValuesInRange(await result.data(), 0, 1); - }); - - it('should return a random 3D float32 array', async () => { - const shape: [number, number, number] = [3, 4, 5]; - - // Ensure defaults to float32 w/o type: - let result = tf.randomUniform(shape, 0, 2.5); - expect(result.dtype).toBe('float32'); - expectValuesInRange(await result.data(), 0, 2.5); - - result = tf.randomUniform(shape, 0, 1.5, 'float32'); - expect(result.dtype).toBe('float32'); - expectValuesInRange(await result.data(), 0, 1.5); - }); - - it('should return a random 3D int32 array', async () => { - const shape: [number, number, number] = [3, 4, 5]; - const result = tf.randomUniform(shape, 0, 2, 'int32'); - expect(result.dtype).toBe('int32'); - expectValuesInRange(await result.data(), 0, 2); - }); - - it('should return a random 3D bool array', async () => { - const shape: [number, number, number] = [3, 4, 5]; - const result = tf.randomUniform(shape, 0, 1, 'bool'); - expect(result.dtype).toBe('bool'); - expectValuesInRange(await result.data(), 0, 1); - }); - - it('should return a random 4D float32 array', async () => { - const shape: [number, number, number, number] = [3, 4, 5, 6]; - - // Ensure defaults to float32 w/o type: - let result = tf.randomUniform(shape, 0, 2.5); - expect(result.dtype).toBe('float32'); - expectValuesInRange(await result.data(), 0, 2.5); - - result = tf.randomUniform(shape, 0, 1.5, 'float32'); - expect(result.dtype).toBe('float32'); - expectValuesInRange(await result.data(), 0, 1.5); - }); - - it('should return a random 4D int32 array', async () => { - const shape: [number, number, number, number] = [3, 4, 5, 6]; - const result = tf.randomUniform(shape, 0, 2, 'int32'); - expect(result.dtype).toBe('int32'); - expectValuesInRange(await result.data(), 0, 2); - }); - - it('should return a random 4D bool array', async () => { - const shape: [number, number, number, number] = [3, 4, 5, 6]; - const result = tf.randomUniform(shape, 0, 1, 'bool'); - expect(result.dtype).toBe('bool'); - expectValuesInRange(await result.data(), 0, 1); - }); - - it('should return a random 5D float32 array', async () => { - const shape: [number, number, number, number, number] = [2, 3, 4, 5, 6]; - - // Ensure defaults to float32 w/o type: - let result = tf.randomUniform(shape, 0, 2.5); - expect(result.dtype).toBe('float32'); - expectValuesInRange(await result.data(), 0, 2.5); - - result = tf.randomUniform(shape, 0, 1.5, 'float32'); - expect(result.dtype).toBe('float32'); - expectValuesInRange(await result.data(), 0, 1.5); - }); - - it('should return a random 5D int32 array', async () => { - const shape: [number, number, number, number, number] = [2, 3, 4, 5, 6]; - const result = tf.randomUniform(shape, 0, 2, 'int32'); - expect(result.dtype).toBe('int32'); - expectValuesInRange(await result.data(), 0, 2); - }); - - it('should return a random 5D bool array', async () => { - const shape: [number, number, number, number, number] = [2, 3, 4, 5, 6]; - const result = tf.randomUniform(shape, 0, 1, 'bool'); - expect(result.dtype).toBe('bool'); - expectValuesInRange(await result.data(), 0, 1); - }); - - it('should throw error when shape is not integer', () => { - expect(() => tf.randomUniform([2, 2.22, 3.33], 0, 1)).toThrow(); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/range.ts b/tfjs-master/tfjs-core/src/ops/range.ts deleted file mode 100644 index 3ffe2fd96..000000000 --- a/tfjs-master/tfjs-core/src/ops/range.ts +++ /dev/null @@ -1,53 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {Range, RangeAttrs} from '../kernel_names'; -import {NamedAttrMap} from '../kernel_registry'; -import {Tensor1D} from '../tensor'; - -/** - * Creates a new `tf.Tensor1D` filled with the numbers in the range provided. - * - * The tensor is a half-open interval meaning it includes start, but - * excludes stop. Decrementing ranges and negative step values are also - * supported. - * - * - * ```js - * tf.range(0, 9, 2).print(); - * ``` - * - * @param start An integer start value - * @param stop An integer stop value - * @param step An integer increment (will default to 1 or -1) - * @param dtype The data type of the output tensor. Defaults to 'float32'. - * - * @doc {heading: 'Tensors', subheading: 'Creation'} - */ -export function range( - start: number, stop: number, step = 1, - dtype: 'float32'|'int32' = 'float32'): Tensor1D { - if (step === 0) { - throw new Error('Cannot have a step of zero'); - } - - const attrs: RangeAttrs = {start, stop, step, dtype}; - - return ENGINE.runKernel(Range, {} /* inputs */, - attrs as unknown as NamedAttrMap); -} diff --git a/tfjs-master/tfjs-core/src/ops/range_test.ts b/tfjs-master/tfjs-core/src/ops/range_test.ts deleted file mode 100644 index 3fed0223c..000000000 --- a/tfjs-master/tfjs-core/src/ops/range_test.ts +++ /dev/null @@ -1,160 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysEqual} from '../test_util'; - -describeWithFlags('range', ALL_ENVS, () => { - it('start stop', async () => { - const a = tf.range(0, 3); - expectArraysEqual(await a.data(), [0, 1, 2]); - expect(a.shape).toEqual([3]); - - const b = tf.range(3, 8); - expectArraysEqual(await b.data(), [3, 4, 5, 6, 7]); - expect(b.shape).toEqual([5]); - }); - - it('start stop negative', async () => { - const a = tf.range(-2, 3); - expectArraysEqual(await a.data(), [-2, -1, 0, 1, 2]); - expect(a.shape).toEqual([5]); - - const b = tf.range(4, -2); - expectArraysEqual(await b.data(), [4, 3, 2, 1, 0, -1]); - expect(b.shape).toEqual([6]); - }); - - it('start stop step', async () => { - const a = tf.range(4, 15, 4); - expectArraysEqual(await a.data(), [4, 8, 12]); - expect(a.shape).toEqual([3]); - - const b = tf.range(4, 11, 4); - expectArraysEqual(await b.data(), [4, 8]); - expect(b.shape).toEqual([2]); - - const c = tf.range(4, 17, 4); - expectArraysEqual(await c.data(), [4, 8, 12, 16]); - expect(c.shape).toEqual([4]); - - const d = tf.range(0, 30, 5); - expectArraysEqual(await d.data(), [0, 5, 10, 15, 20, 25]); - expect(d.shape).toEqual([6]); - - const e = tf.range(-3, 9, 2); - expectArraysEqual(await e.data(), [-3, -1, 1, 3, 5, 7]); - expect(e.shape).toEqual([6]); - - const f = tf.range(3, 3); - expectArraysEqual(await f.data(), new Float32Array(0)); - expect(f.shape).toEqual([0]); - - const g = tf.range(3, 3, 1); - expectArraysEqual(await g.data(), new Float32Array(0)); - expect(g.shape).toEqual([0]); - - const h = tf.range(3, 3, 4); - expectArraysEqual(await h.data(), new Float32Array(0)); - expect(h.shape).toEqual([0]); - - const i = tf.range(-18, -2, 5); - expectArraysEqual(await i.data(), [-18, -13, -8, -3]); - expect(i.shape).toEqual([4]); - }); - - it('start stop large step', async () => { - const a = tf.range(3, 10, 150); - expectArraysEqual(await a.data(), [3]); - expect(a.shape).toEqual([1]); - - const b = tf.range(10, 500, 205); - expectArraysEqual(await b.data(), [10, 215, 420]); - expect(b.shape).toEqual([3]); - - const c = tf.range(3, -10, -150); - expectArraysEqual(await c.data(), [3]); - expect(c.shape).toEqual([1]); - - const d = tf.range(-10, -500, -205); - expectArraysEqual(await d.data(), [-10, -215, -420]); - expect(d.shape).toEqual([3]); - }); - - it('start stop negative step', async () => { - const a = tf.range(0, -10, -1); - expectArraysEqual(await a.data(), [0, -1, -2, -3, -4, -5, -6, -7, -8, -9]); - expect(a.shape).toEqual([10]); - - const b = tf.range(0, -10); - expectArraysEqual(await b.data(), [0, -1, -2, -3, -4, -5, -6, -7, -8, -9]); - expect(b.shape).toEqual([10]); - - const c = tf.range(3, -4, -2); - expectArraysEqual(await c.data(), [3, 1, -1, -3]); - expect(c.shape).toEqual([4]); - - const d = tf.range(-3, -18, -5); - expectArraysEqual(await d.data(), [-3, -8, -13]); - expect(d.shape).toEqual([3]); - }); - - it('start stop incompatible step', async () => { - const a = tf.range(3, 10, -2); - expectArraysEqual(await a.data(), new Float32Array(0)); - expect(a.shape).toEqual([0]); - - const b = tf.range(40, 3, 2); - expectArraysEqual(await b.data(), new Float32Array(0)); - expect(b.shape).toEqual([0]); - }); - - it('zero step', () => { - expect(() => tf.range(2, 10, 0)).toThrow(); - }); - - it('should have default dtype', async () => { - const a = tf.range(1, 4); - expectArraysEqual(await a.data(), [1, 2, 3]); - expect(a.dtype).toEqual('float32'); - expect(a.shape).toEqual([3]); - }); - - it('should have float32 dtype', async () => { - const a = tf.range(1, 4, undefined, 'float32'); - expectArraysEqual(await a.data(), [1, 2, 3]); - expect(a.dtype).toEqual('float32'); - expect(a.shape).toEqual([3]); - }); - - it('should have int32 dtype', async () => { - const a = tf.range(1, 4, undefined, 'int32'); - expectArraysEqual(await a.data(), [1, 2, 3]); - expect(a.dtype).toEqual('int32'); - expect(a.shape).toEqual([3]); - }); - - it('should support large number for int32 dtype', async () => { - const length = Math.pow(2, 24) + 10; - const a = tf.range(1, length, 1, 'int32'); - const data = await a.data(); - expect(data[length - 2]).toEqual(length - 1); - expect(a.dtype).toEqual('int32'); - expect(a.shape).toEqual([length - 1]); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/real.ts b/tfjs-master/tfjs-core/src/ops/real.ts deleted file mode 100644 index b6e2ba8ef..000000000 --- a/tfjs-master/tfjs-core/src/ops/real.ts +++ /dev/null @@ -1,48 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {Real, RealInputs} from '../kernel_names'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; -import {op} from './operation'; - -/** - * Returns the real part of a complex (or real) tensor. - * - * Given a tensor input, this operation returns a tensor of type float that is - * the real part of each element in input considered as a complex number. - * - * If the input is real, it simply makes a clone. - * - * ```js - * const x = tf.complex([-2.25, 3.25], [4.75, 5.75]); - * tf.real(x).print(); - * ``` - * - * @doc {heading: 'Tensors', subheading: 'Creation'} - */ -function real_(input: T|TensorLike): T { - const $input = convertToTensor(input, 'input', 'real'); - - const inputs: RealInputs = {input: $input}; - return ENGINE.runKernel(Real, inputs as unknown as NamedTensorMap); -} - -export const real = /* @__PURE__ */ op({real_}); diff --git a/tfjs-master/tfjs-core/src/ops/reciprocal.ts b/tfjs-master/tfjs-core/src/ops/reciprocal.ts deleted file mode 100644 index ae57cec7d..000000000 --- a/tfjs-master/tfjs-core/src/ops/reciprocal.ts +++ /dev/null @@ -1,45 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {Reciprocal, ReciprocalInputs} from '../kernel_names'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -import {op} from './operation'; - -/** - * Computes reciprocal of x element-wise: `1 / x` - * - * ```js - * const x = tf.tensor1d([0, 1, 2]); - * - * x.reciprocal().print(); // or tf.reciprocal(x) - * ``` - * @param x The input tensor. - * - * @doc {heading: 'Operations', subheading: 'Basic math'} - */ -function reciprocal_(x: T|TensorLike): T { - const $x = convertToTensor(x, 'x', 'reciprocal'); - - const inputs: ReciprocalInputs = {x: $x}; - return ENGINE.runKernel(Reciprocal, inputs as unknown as NamedTensorMap); -} -export const reciprocal = /* @__PURE__ */ op({reciprocal_}); diff --git a/tfjs-master/tfjs-core/src/ops/reciprocal_test.ts b/tfjs-master/tfjs-core/src/ops/reciprocal_test.ts deleted file mode 100644 index 4d5ed4d2c..000000000 --- a/tfjs-master/tfjs-core/src/ops/reciprocal_test.ts +++ /dev/null @@ -1,106 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('reciprocal', ALL_ENVS, () => { - it('1D array', async () => { - const a = tf.tensor1d([2, 3, 0, NaN]); - const r = tf.reciprocal(a); - expectArraysClose(await r.data(), [1 / 2, 1 / 3, Infinity, NaN]); - }); - - it('2D array', async () => { - const a = tf.tensor2d([1, Infinity, 0, NaN], [2, 2]); - const r = tf.reciprocal(a); - expect(r.shape).toEqual([2, 2]); - expectArraysClose(await r.data(), [1 / 1, 0, Infinity, NaN]); - }); - - it('reciprocal propagates NaNs', async () => { - const a = tf.tensor1d([1.5, NaN]); - const r = tf.reciprocal(a); - expectArraysClose(await r.data(), [1 / 1.5, NaN]); - }); - - it('gradients: Scalar', async () => { - const a = tf.scalar(5); - const dy = tf.scalar(8); - - const gradients = tf.grad(a => tf.reciprocal(a))(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), [-1 * 8 * (1 / (5 * 5))]); - }); - - it('gradient with clones', async () => { - const a = tf.scalar(5); - const dy = tf.scalar(8); - - const gradients = tf.grad(a => tf.reciprocal(a.clone()).clone())(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), [-1 * 8 * (1 / (5 * 5))]); - }); - - it('gradients: Tensor1D', async () => { - const a = tf.tensor1d([-1, 2, 3, -5]); - const dy = tf.tensor1d([1, 2, 3, 4]); - - const gradients = tf.grad(a => tf.reciprocal(a))(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), [ - -1 * 1 * (1 / (-1 * -1)), -1 * 2 * (1 / (2 * 2)), -1 * 3 * (1 / (3 * 3)), - -1 * 4 * (1 / (-5 * -5)) - ]); - }); - - it('gradients: Tensor2D', async () => { - const a = tf.tensor2d([-1, 2, 3, -5], [2, 2]); - const dy = tf.tensor2d([1, 2, 3, 4], [2, 2]); - - const gradients = tf.grad(a => tf.reciprocal(a))(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), [ - -1 * 1 * (1 / (-1 * -1)), -1 * 2 * (1 / (2 * 2)), -1 * 3 * (1 / (3 * 3)), - -1 * 4 * (1 / (-5 * -5)) - ]); - }); - - it('throws when passed a non-tensor', () => { - expect(() => tf.reciprocal({} as tf.Tensor)) - .toThrowError(/Argument 'x' passed to 'reciprocal' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const r = tf.reciprocal([2, 3, 0, NaN]); - expectArraysClose(await r.data(), [1 / 2, 1 / 3, Infinity, NaN]); - }); - - it('throws for string tensor', () => { - expect(() => tf.reciprocal('q')) - .toThrowError(/Argument 'x' passed to 'reciprocal' must be numeric/); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/reduce_util.ts b/tfjs-master/tfjs-core/src/ops/reduce_util.ts deleted file mode 100644 index 3a0290d68..000000000 --- a/tfjs-master/tfjs-core/src/ops/reduce_util.ts +++ /dev/null @@ -1,38 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -/** - * Inputs of size above this threshold will be parallelized by calling multiple - * shader programs. - */ -import {nearestDivisor} from '../util'; - -export const PARALLELIZE_THRESHOLD = 30; - -export interface ReduceInfo { - windowSize: number; - batchSize: number; - inSize: number; - outSize: number; -} - -export function computeOptimalWindowSize(inSize: number): number { - if (inSize <= PARALLELIZE_THRESHOLD) { - return inSize; - } - return nearestDivisor(inSize, Math.floor(Math.sqrt(inSize))); -} diff --git a/tfjs-master/tfjs-core/src/ops/relu.ts b/tfjs-master/tfjs-core/src/ops/relu.ts deleted file mode 100644 index 2630fe572..000000000 --- a/tfjs-master/tfjs-core/src/ops/relu.ts +++ /dev/null @@ -1,48 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {Relu, ReluInputs} from '../kernel_names'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -import {op} from './operation'; - -/** - * Computes rectified linear element-wise: `max(x, 0)`. - * - * ```js - * const x = tf.tensor1d([-1, 2, -3, 4]); - * - * x.relu().print(); // or tf.relu(x) - * ``` - * @param x The input tensor. If the dtype is `bool`, the output dtype will be - * `int32`. - * - * @doc {heading: 'Operations', subheading: 'Basic math'} - */ -function relu_(x: T|TensorLike): T { - const $x = convertToTensor(x, 'x', 'relu'); - - const inputs: ReluInputs = {x: $x}; - - return ENGINE.runKernel(Relu, inputs as unknown as NamedTensorMap); -} - -export const relu = /* @__PURE__ */ op({relu_}); diff --git a/tfjs-master/tfjs-core/src/ops/relu6.ts b/tfjs-master/tfjs-core/src/ops/relu6.ts deleted file mode 100644 index 9b84750a1..000000000 --- a/tfjs-master/tfjs-core/src/ops/relu6.ts +++ /dev/null @@ -1,48 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {Relu6, Relu6Inputs} from '../kernel_names'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -import {op} from './operation'; - -/** - * Computes rectified linear 6 element-wise: `min(max(x, 0), 6)`. - * - * ```js - * const x = tf.tensor1d([-1, 2, -3, 8]); - * - * x.relu6().print(); // or tf.relu6(x) - * ``` - * @param x The input tensor. If the dtype is `bool`, the output dtype will be - * `int32`. - * - * @doc {heading: 'Operations', subheading: 'Basic math'} - */ -function relu6_(x: T|TensorLike): T { - const $x = convertToTensor(x, 'x', 'relu6'); - - const inputs: Relu6Inputs = {x: $x}; - - return ENGINE.runKernel(Relu6, inputs as unknown as NamedTensorMap); -} - -export const relu6 = /* @__PURE__ */ op({relu6_}); diff --git a/tfjs-master/tfjs-core/src/ops/relu6_test.ts b/tfjs-master/tfjs-core/src/ops/relu6_test.ts deleted file mode 100644 index bcc9542c5..000000000 --- a/tfjs-master/tfjs-core/src/ops/relu6_test.ts +++ /dev/null @@ -1,59 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('relu6', ALL_ENVS, () => { - it('basic relu6', async () => { - const a = tf.tensor1d([1, -2, 0, 8, -0.1]); - const result = tf.relu6(a); - expectArraysClose(await result.data(), [1, 0, 0, 6, 0]); - }); - - it('int32', async () => { - const a = tf.tensor1d([12345678, -2, 0, 3, -1], 'int32'); - const result = tf.relu6(a); - expect(result.dtype).toEqual('int32'); - expectArraysClose(await result.data(), [6, 0, 0, 3, 0]); - }); - - it('gradients: relu6', async () => { - const a = tf.scalar(8); - const dy = tf.scalar(5); - - const grad = tf.grad(a => tf.relu6(a)); - const da = grad(a, dy); - - expect(da.shape).toEqual(a.shape); - expect(da.dtype).toEqual('float32'); - expectArraysClose(await da.data(), [0]); - }); - - it('gradients: relu6 array', async () => { - const a = tf.tensor2d([8, -1, 0, .1], [2, 2]); - const dy = tf.tensor2d([1, 2, 3, 4], [2, 2]); - - const grad = tf.grad(a => tf.relu6(a)); - const da = grad(a, dy); - - expect(da.shape).toEqual(a.shape); - expect(da.dtype).toEqual('float32'); - expectArraysClose(await da.data(), [0, 0, 0, 4]); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/relu_test.ts b/tfjs-master/tfjs-core/src/ops/relu_test.ts deleted file mode 100644 index 0e995f3e3..000000000 --- a/tfjs-master/tfjs-core/src/ops/relu_test.ts +++ /dev/null @@ -1,139 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; -import {backend} from '../index'; - -describeWithFlags('relu', ALL_ENVS, () => { - it('basic', async () => { - const a = tf.tensor1d([1, -2, 0, 3, -0.1]); - const result = tf.relu(a); - expectArraysClose(await result.data(), [1, 0, 0, 3, 0]); - }); - - it('int32', async () => { - if (backend() && backend().floatPrecision() === 32) { - // TODO: Use skip() instead when it is implemented - const a = tf.tensor1d([12345678, -2, 0, 3, -1], 'int32'); - const result = tf.relu(a); - expect(result.dtype).toEqual('int32'); - expectArraysClose(await result.data(), [12345678, 0, 0, 3, 0]); - } - }); - - it('5D', async () => { - const a = tf.tensor5d([1, -2, 5, -3], [1, 2, 2, 1, 1]); - const result = tf.relu(a); - expectArraysClose(await result.data(), [1, 0, 5, 0]); - }); - - it('6D', async () => { - const a = tf.tensor6d([1, -2, 5, -3, -1, 4, 7, 8], [1, 2, 2, 2, 1, 1]); - const result = tf.relu(a); - expectArraysClose(await result.data(), [1, 0, 5, 0, 0, 4, 7, 8]); - }); - - it('does nothing to positive values', async () => { - const a = tf.scalar(1); - const result = tf.relu(a); - expectArraysClose(await result.data(), [1]); - }); - - it('sets negative values to 0', async () => { - const a = tf.scalar(-1); - const result = tf.relu(a); - expectArraysClose(await result.data(), [0]); - }); - - it('preserves zero values', async () => { - const a = tf.scalar(0); - const result = tf.relu(a); - expectArraysClose(await result.data(), [0]); - }); - - it('propagates NaNs, float32', async () => { - const a = tf.tensor1d([1, -2, 0, 3, -0.1, NaN]); - const result = tf.relu(a); - expect(result.dtype).toBe('float32'); - expectArraysClose(await result.data(), [1, 0, 0, 3, 0, NaN]); - }); - - it('gradients: positive scalar', async () => { - const a = tf.scalar(3); - const dy = tf.scalar(5); - - const grad = tf.grad(a => tf.relu(a)); - const da = grad(a, dy); - - expect(da.shape).toEqual(a.shape); - expect(da.dtype).toEqual('float32'); - expectArraysClose(await da.data(), [5]); - }); - - it('gradient with clones', async () => { - const a = tf.scalar(3); - const dy = tf.scalar(5); - - const grad = tf.grad(a => tf.relu(a.clone()).clone()); - const da = grad(a, dy); - - expect(da.shape).toEqual(a.shape); - expect(da.dtype).toEqual('float32'); - expectArraysClose(await da.data(), [5]); - }); - - it('gradients: negative scalar', async () => { - const a = tf.scalar(-3); - const dy = tf.scalar(5); - - const grad = tf.grad(a => tf.relu(a)); - const da = grad(a, dy); - - expect(da.shape).toEqual(a.shape); - expect(da.dtype).toEqual('float32'); - expectArraysClose(await da.data(), [0]); - }); - - it('gradients: array', async () => { - const a = tf.tensor2d([1, -1, 0, .1], [2, 2]); - const dy = tf.tensor2d([1, 2, 3, 4], [2, 2]); - - const grad = tf.grad(a => tf.relu(a)); - const da = grad(a, dy); - - expect(da.shape).toEqual(a.shape); - expect(da.dtype).toEqual('float32'); - expectArraysClose(await da.data(), [1, 0, 0, 4]); - }); - - it('throws when passed a non-tensor', () => { - expect(() => tf.relu({} as tf.Tensor)) - .toThrowError(/Argument 'x' passed to 'relu' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const result = tf.relu([1, -2, 0, 3, -0.1]); - expectArraysClose(await result.data(), [1, 0, 0, 3, 0]); - }); - - it('throws for string tensor', () => { - expect(() => tf.relu('q')) - .toThrowError(/Argument 'x' passed to 'relu' must be numeric/); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/reshape.ts b/tfjs-master/tfjs-core/src/ops/reshape.ts deleted file mode 100644 index d213719f6..000000000 --- a/tfjs-master/tfjs-core/src/ops/reshape.ts +++ /dev/null @@ -1,64 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {Reshape, ReshapeAttrs, ReshapeInputs} from '../kernel_names'; -import {NamedAttrMap} from '../kernel_registry'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {Rank, ShapeMap, TensorLike} from '../types'; - -import {op} from './operation'; - -/** - * Reshapes a `tf.Tensor` to a given shape. - * - * Given an input tensor, returns a new tensor with the same values as the - * input tensor with shape `shape`. - * - * If one component of shape is the special value -1, the size of that - * dimension is computed so that the total size remains constant. In - * particular, a shape of [-1] flattens into 1-D. At most one component of - * shape can be -1. - * - * If shape is 1-D or higher, then the operation returns a tensor with shape - * shape filled with the values of tensor. In this case, the number of - * elements implied by shape must be the same as the number of elements in - * tensor. - * - * ```js - * const x = tf.tensor1d([1, 2, 3, 4]); - * x.reshape([2, 2]).print(); - * ``` - * - * @param x The input tensor to be reshaped. - * @param shape An array of integers defining the output tensor shape. - * - * @doc {heading: 'Tensors', subheading: 'Transformations'} - */ -function reshape_( - x: Tensor|TensorLike, shape: ShapeMap[R]): Tensor { - const $x = convertToTensor(x, 'x', 'reshape', 'string_or_numeric'); - - const inputs: ReshapeInputs = {x: $x}; - const attrs: ReshapeAttrs = {shape}; - return ENGINE.runKernel( - Reshape, inputs as unknown as NamedTensorMap, - attrs as unknown as NamedAttrMap); -} -export const reshape = /* @__PURE__ */ op({reshape_}); diff --git a/tfjs-master/tfjs-core/src/ops/reverse.ts b/tfjs-master/tfjs-core/src/ops/reverse.ts deleted file mode 100644 index caa9f0333..000000000 --- a/tfjs-master/tfjs-core/src/ops/reverse.ts +++ /dev/null @@ -1,71 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {Reverse, ReverseAttrs, ReverseInputs} from '../kernel_names'; -import {NamedAttrMap} from '../kernel_registry'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -import {op} from './operation'; - -/** - * Reverses a `tf.Tensor` along a specified axis. - * - * Also available are stricter rank-specific methods that assert that `x` is - * of the given rank: - * - `tf.reverse1d` - * - `tf.reverse2d` - * - `tf.reverse3d` - * - `tf.reverse4d` - * - * Except `tf.reverse1d` (which does not have axis param), all methods have - * same signature as this method. - * - * ```js - * const x = tf.tensor1d([1, 2, 3, 4]); - * - * x.reverse().print(); - * ``` - * - * ```js - * const x = tf.tensor2d([1, 2, 3, 4], [2, 2]); - * - * const axis = 1; - * x.reverse(axis).print(); - * ``` - * @param x The input tensor to be reversed. - * @param axis The set of dimensions to reverse. Must be in the - * range [-rank(x), rank(x)). Defaults to all axes. - * - * @doc {heading: 'Tensors', subheading: 'Slicing and Joining'} - */ -function reverse_( - x: T|TensorLike, axis?: number|number[]): T { - const $x = convertToTensor(x, 'x', 'reverse'); - - const inputs: ReverseInputs = {x: $x}; - const attrs: ReverseAttrs = {dims: axis}; - - return ENGINE.runKernel( - Reverse, inputs as unknown as NamedTensorMap, - attrs as unknown as NamedAttrMap); -} - -export const reverse = /* @__PURE__ */ op({reverse_}); diff --git a/tfjs-master/tfjs-core/src/ops/reverse_1d.ts b/tfjs-master/tfjs-core/src/ops/reverse_1d.ts deleted file mode 100644 index 5dc27f62a..000000000 --- a/tfjs-master/tfjs-core/src/ops/reverse_1d.ts +++ /dev/null @@ -1,38 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Tensor1D} from '../tensor'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; -import * as util from '../util'; -import {op} from './operation'; -import {reverse} from './reverse'; - -/** - * Reverses a `tf.Tensor1D`. - * - * @param x The input tensor. - */ -function reverse1d_(x: Tensor1D|TensorLike): Tensor1D { - const $x = convertToTensor(x, 'x', 'reverse'); - util.assert( - $x.rank === 1, - () => `Error in reverse1D: x must be rank 1 but got rank ${$x.rank}.`); - return reverse($x, 0); -} - -export const reverse1d = /* @__PURE__ */ op({reverse1d_}); diff --git a/tfjs-master/tfjs-core/src/ops/reverse_1d_test.ts b/tfjs-master/tfjs-core/src/ops/reverse_1d_test.ts deleted file mode 100644 index 06b6f8cbb..000000000 --- a/tfjs-master/tfjs-core/src/ops/reverse_1d_test.ts +++ /dev/null @@ -1,60 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('reverse1d', ALL_ENVS, () => { - it('reverse a 1D array', async () => { - const input = tf.tensor1d([1, 2, 3, 4, 5]); - const result = tf.reverse1d(input); - expect(result.shape).toEqual(input.shape); - expectArraysClose(await result.data(), [5, 4, 3, 2, 1]); - }); - - it('reverse a 1D array, even length', async () => { - const input = tf.tensor1d([1, 2, 3, 4]); - const result = tf.reverse1d(input); - expect(result.shape).toEqual(input.shape); - expectArraysClose(await result.data(), [4, 3, 2, 1]); - }); - - it('grad', async () => { - const a = tf.tensor1d([1, 2, 3]); - const dy = tf.tensor1d([10, 20, 30]); - const da = tf.grad((a: tf.Tensor1D) => tf.reverse1d(a))(a, dy); - expect(da.shape).toEqual([3]); - expectArraysClose(await da.data(), [30, 20, 10]); - }); - - it('gradient with clones', async () => { - const a = tf.tensor1d([1, 2, 3]); - const dy = tf.tensor1d([10, 20, 30]); - const da = - tf.grad((a: tf.Tensor1D) => tf.reverse1d(a.clone()).clone())(a, dy); - expect(da.shape).toEqual([3]); - expectArraysClose(await da.data(), [30, 20, 10]); - }); - - it('accepts a tensor-like object', async () => { - const input = [1, 2, 3, 4, 5]; - const result = tf.reverse1d(input); - expect(result.shape).toEqual([5]); - expectArraysClose(await result.data(), [5, 4, 3, 2, 1]); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/reverse_2d.ts b/tfjs-master/tfjs-core/src/ops/reverse_2d.ts deleted file mode 100644 index 45c869423..000000000 --- a/tfjs-master/tfjs-core/src/ops/reverse_2d.ts +++ /dev/null @@ -1,40 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Tensor2D} from '../tensor'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; -import * as util from '../util'; -import {op} from './operation'; -import {reverse} from './reverse'; - -/** - * Reverses a `tf.Tensor2D` along a specified axis. - * - * @param x The input tensor. - * @param axis The set of dimensions to reverse. Must be in the - * range [-rank(x), rank(x)). Defaults to all axes. - */ -function reverse2d_(x: Tensor2D|TensorLike, axis?: number|number[]): Tensor2D { - const $x = convertToTensor(x, 'x', 'reverse'); - util.assert( - $x.rank === 2, - () => `Error in reverse2D: x must be rank 2 but got rank ${$x.rank}.`); - return reverse($x, axis); -} - -export const reverse2d = /* @__PURE__ */ op({reverse2d_}); diff --git a/tfjs-master/tfjs-core/src/ops/reverse_2d_test.ts b/tfjs-master/tfjs-core/src/ops/reverse_2d_test.ts deleted file mode 100644 index d88053d4d..000000000 --- a/tfjs-master/tfjs-core/src/ops/reverse_2d_test.ts +++ /dev/null @@ -1,102 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('reverse2d', ALL_ENVS, () => { - it('reverse a 2D array at axis [0]', async () => { - const axis = [0]; - const a = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - const result = tf.reverse2d(a, axis); - - expect(result.shape).toEqual(a.shape); - expectArraysClose(await result.data(), [4, 5, 6, 1, 2, 3]); - }); - - it('reverse a 2D array at axis [1]', async () => { - const axis = [1]; - const a = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - const result = tf.reverse2d(a, axis); - - expect(result.shape).toEqual(a.shape); - expectArraysClose(await result.data(), [3, 2, 1, 6, 5, 4]); - }); - - it('reverse a 2D array odd rows and columns at axis [0, 1]', async () => { - const axis = [0, 1]; - const a = tf.tensor2d( - [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], [3, 5]); - const result = tf.reverse2d(a, axis); - - expect(result.shape).toEqual(a.shape); - expectArraysClose( - await result.data(), - [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]); - }); - - it('throws error with invalid input', () => { - // tslint:disable-next-line:no-any - const x: any = tf.tensor1d([1, 20, 300, 4]); - expect(() => tf.reverse2d(x, [0])).toThrowError(); - }); - - it('throws error with invalid axis param', () => { - const x = tf.tensor2d([1, 20, 300, 4], [1, 4]); - expect(() => tf.reverse2d(x, [2])).toThrowError(); - expect(() => tf.reverse2d(x, [-3])).toThrowError(); - }); - - it('throws error with non integer axis param', () => { - const x = tf.tensor2d([1, 20, 300, 4], [1, 4]); - expect(() => tf.reverse2d(x, [0.5])).toThrowError(); - }); - - it('grad', async () => { - const a = tf.tensor2d([[1, 2, 3], [4, 5, 6]]); - const dy = tf.tensor2d([[10, 20, 30], [40, 50, 60]]); - const da = tf.grad((a: tf.Tensor2D) => tf.reverse2d(a))(a, dy); - expect(da.shape).toEqual([2, 3]); - expectArraysClose(await da.data(), [60, 50, 40, 30, 20, 10]); - }); - - it('grad with reverse(axis=0)', async () => { - const a = tf.tensor2d([[1, 2, 3], [4, 5, 6]]); - const dy = tf.tensor2d([[10, 20, 30], [40, 50, 60]]); - const da = tf.grad((a: tf.Tensor2D) => tf.reverse2d(a, 0))(a, dy); - expect(da.shape).toEqual([2, 3]); - expectArraysClose(await da.data(), [40, 50, 60, 10, 20, 30]); - }); - - it('grad with reverse(axis=1)', async () => { - const a = tf.tensor2d([[1, 2, 3], [4, 5, 6]]); - const dy = tf.tensor2d([[10, 20, 30], [40, 50, 60]]); - const da = tf.grad((a: tf.Tensor2D) => tf.reverse2d(a, 1))(a, dy); - expect(da.shape).toEqual([2, 3]); - expectArraysClose(await da.data(), [30, 20, 10, 60, 50, 40]); - }); - - it('accepts a tensor-like object', async () => { - const axis = [0]; - const a = [[1, 2, 3], [4, 5, 6]]; // 2x3 - const result = tf.reverse2d(a, axis); - - expect(result.shape).toEqual([2, 3]); - expectArraysClose(await result.data(), [4, 5, 6, 1, 2, 3]); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/reverse_3d.ts b/tfjs-master/tfjs-core/src/ops/reverse_3d.ts deleted file mode 100644 index a1d6f1f34..000000000 --- a/tfjs-master/tfjs-core/src/ops/reverse_3d.ts +++ /dev/null @@ -1,40 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Tensor3D} from '../tensor'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; -import * as util from '../util'; -import {op} from './operation'; -import {reverse} from './reverse'; - -/** - * Reverses a `tf.Tensor3D` along a specified axis. - * - * @param x The input tensor. - * @param axis The set of dimensions to reverse. Must be in the - * range [-rank(x), rank(x)). Defaults to all axes. - */ -function reverse3d_(x: Tensor3D|TensorLike, axis?: number|number[]): Tensor3D { - const $x = convertToTensor(x, 'x', 'reverse'); - util.assert( - $x.rank === 3, - () => `Error in reverse3D: x must be rank 3 but got rank ${$x.rank}.`); - return reverse($x, axis); -} - -export const reverse3d = /* @__PURE__ */ op({reverse3d_}); diff --git a/tfjs-master/tfjs-core/src/ops/reverse_3d_test.ts b/tfjs-master/tfjs-core/src/ops/reverse_3d_test.ts deleted file mode 100644 index 3fa307a49..000000000 --- a/tfjs-master/tfjs-core/src/ops/reverse_3d_test.ts +++ /dev/null @@ -1,124 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('reverse3d', ALL_ENVS, () => { - // [ - // [ - // [0, 1, 2, 3], - // [4, 5, 6, 7], - // [8, 9, 10, 11] - // ], - // [ - // [12, 13, 14, 15], - // [16, 17, 18, 19], - // [20, 21, 22, 23] - // ] - // ] - const shape: [number, number, number] = [2, 3, 4]; - const data = [ - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, - 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23 - ]; - - it('reverse a 3D array at axis [0]', async () => { - const input = tf.tensor3d(data, shape); - const result = tf.reverse3d(input, [0]); - expect(result.shape).toEqual(input.shape); - expectArraysClose(await result.data(), [ - 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 - ]); - }); - - it('reverse a 3D array at axis [1]', async () => { - const input = tf.tensor3d(data, shape); - const result = tf.reverse3d(input, [1]); - expect(result.shape).toEqual(input.shape); - expectArraysClose(await result.data(), [ - 8, 9, 10, 11, 4, 5, 6, 7, 0, 1, 2, 3, - 20, 21, 22, 23, 16, 17, 18, 19, 12, 13, 14, 15 - ]); - }); - - it('reverse a 3D array at axis [2]', async () => { - const input = tf.tensor3d(data, shape); - const result = tf.reverse3d(input, [2]); - expect(result.shape).toEqual(input.shape); - expectArraysClose(await result.data(), [ - 3, 2, 1, 0, 7, 6, 5, 4, 11, 10, 9, 8, - 15, 14, 13, 12, 19, 18, 17, 16, 23, 22, 21, 20 - ]); - }); - - it('reverse a 3D array at axis [0, 1]', async () => { - const input = tf.tensor3d(data, shape); - const result = tf.reverse3d(input, [0, 1]); - expect(result.shape).toEqual(input.shape); - expectArraysClose(await result.data(), [ - 20, 21, 22, 23, 16, 17, 18, 19, 12, 13, 14, 15, - 8, 9, 10, 11, 4, 5, 6, 7, 0, 1, 2, 3 - ]); - }); - - it('reverse a 3D array at axis [0, 2]', async () => { - const input = tf.tensor3d(data, shape); - const result = tf.reverse3d(input, [0, 2]); - expect(result.shape).toEqual(input.shape); - expectArraysClose(await result.data(), [ - 15, 14, 13, 12, 19, 18, 17, 16, 23, 22, 21, 20, - 3, 2, 1, 0, 7, 6, 5, 4, 11, 10, 9, 8 - ]); - }); - - it('reverse a 3D array at axis [1, 2]', async () => { - const input = tf.tensor3d(data, shape); - const result = tf.reverse3d(input, [1, 2]); - expect(result.shape).toEqual(input.shape); - expectArraysClose(await result.data(), [ - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12 - ]); - }); - - it('throws error with invalid input', () => { - // tslint:disable-next-line:no-any - const x: any = tf.tensor2d([1, 20, 300, 4], [1, 4]); - expect(() => tf.reverse3d(x, [1])).toThrowError(); - }); - - it('throws error with invalid axis param', () => { - const x = tf.tensor3d([1, 20, 300, 4], [1, 1, 4]); - expect(() => tf.reverse3d(x, [3])).toThrowError(); - expect(() => tf.reverse3d(x, [-4])).toThrowError(); - }); - - it('throws error with non integer axis param', () => { - const x = tf.tensor3d([1, 20, 300, 4], [1, 1, 4]); - expect(() => tf.reverse3d(x, [0.5])).toThrowError(); - }); - - it('accepts a tensor-like object', async () => { - const input = [[[1], [2], [3]], [[4], [5], [6]]]; // 2x3x1 - const result = tf.reverse3d(input, [0]); - expect(result.shape).toEqual([2, 3, 1]); - expectArraysClose(await result.data(), [4, 5, 6, 1, 2, 3]); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/reverse_4d.ts b/tfjs-master/tfjs-core/src/ops/reverse_4d.ts deleted file mode 100644 index 1f39c953f..000000000 --- a/tfjs-master/tfjs-core/src/ops/reverse_4d.ts +++ /dev/null @@ -1,40 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Tensor4D} from '../tensor'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; -import * as util from '../util'; -import {op} from './operation'; -import {reverse} from './reverse'; - -/** - * Reverses a `tf.Tensor4D` along a specified axis. - * - * @param x The input tensor. - * @param axis The set of dimensions to reverse. Must be in the - * range [-rank(x), rank(x)). Defaults to all axes. - */ -function reverse4d_(x: Tensor4D|TensorLike, axis?: number|number[]): Tensor4D { - const $x = convertToTensor(x, 'x', 'reverse'); - util.assert( - $x.rank === 4, - () => `Error in reverse4D: x must be rank 4 but got rank ${$x.rank}.`); - return reverse($x, axis); -} - -export const reverse4d = /* @__PURE__ */ op({reverse4d_}); diff --git a/tfjs-master/tfjs-core/src/ops/reverse_4d_test.ts b/tfjs-master/tfjs-core/src/ops/reverse_4d_test.ts deleted file mode 100644 index fe43426af..000000000 --- a/tfjs-master/tfjs-core/src/ops/reverse_4d_test.ts +++ /dev/null @@ -1,164 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('reverse4d', ALL_ENVS, () => { - // [ - // [ - // [ - // [0, 1, 2, 3], - // [4, 5, 6, 7], - // [8, 9, 10, 11] - // ], - // [ - // [12, 13, 14, 15], - // [16, 17, 18, 19], - // [20, 21, 22, 23] - // ] - // ], - // [ - // [ - // [24, 25, 26, 27], - // [28, 29, 30, 31], - // [32, 33, 34, 35] - // ], - // [ - // [36, 37, 38, 39], - // [40, 41, 42, 43], - // [44, 45, 46, 47] - // ] - // ], - // [ - // [ - // [48, 49, 50, 51], - // [52, 53, 54, 55], - // [56, 57, 58, 59] - // ], - // [ - // [60, 61, 62, 63], - // [64, 65, 66, 67], - // [68, 69, 70, 71] - // ] - // ] - // ] - const shape: [number, number, number, number] = [3, 2, 3, 4]; - const data = [ - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, - 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, - 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, - 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71 - ]; - - it('reverse a 4D array at axis [0]', async () => { - const input = tf.tensor4d(data, shape); - const result = tf.reverse4d(input, [0]); - expect(result.shape).toEqual(input.shape); - expectArraysClose(await result.data(), [ - 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, - 66, 67, 68, 69, 70, 71, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, - 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 0, 1, 2, 3, 4, 5, - 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23 - ]); - }); - - it('reverse a 4D array at axis [1]', async () => { - const input = tf.tensor4d(data, shape); - const result = tf.reverse4d(input, [1]); - expect(result.shape).toEqual(input.shape); - expectArraysClose(await result.data(), [ - 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 0, 1, 2, 3, 4, 5, - 6, 7, 8, 9, 10, 11, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, - 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 60, 61, 62, 63, 64, 65, - 66, 67, 68, 69, 70, 71, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59 - ]); - }); - - it('reverse a 4D array at axis [2]', async () => { - const input = tf.tensor4d(data, shape); - const result = tf.reverse4d(input, [2]); - expect(result.shape).toEqual(input.shape); - expectArraysClose(await result.data(), [ - 8, 9, 10, 11, 4, 5, 6, 7, 0, 1, 2, 3, 20, 21, 22, 23, 16, 17, - 18, 19, 12, 13, 14, 15, 32, 33, 34, 35, 28, 29, 30, 31, 24, 25, 26, 27, - 44, 45, 46, 47, 40, 41, 42, 43, 36, 37, 38, 39, 56, 57, 58, 59, 52, 53, - 54, 55, 48, 49, 50, 51, 68, 69, 70, 71, 64, 65, 66, 67, 60, 61, 62, 63 - ]); - }); - - it('reverse a 4D array at axis [3]', async () => { - const input = tf.tensor4d(data, shape); - const result = tf.reverse4d(input, [3]); - expect(result.shape).toEqual(input.shape); - expectArraysClose(await result.data(), [ - 3, 2, 1, 0, 7, 6, 5, 4, 11, 10, 9, 8, 15, 14, 13, 12, 19, 18, - 17, 16, 23, 22, 21, 20, 27, 26, 25, 24, 31, 30, 29, 28, 35, 34, 33, 32, - 39, 38, 37, 36, 43, 42, 41, 40, 47, 46, 45, 44, 51, 50, 49, 48, 55, 54, - 53, 52, 59, 58, 57, 56, 63, 62, 61, 60, 67, 66, 65, 64, 71, 70, 69, 68 - ]); - }); - - it('reverse a 4D array at axis [0, 2]', async () => { - const input = tf.tensor4d(data, shape); - const result = tf.reverse4d(input, [0, 2]); - expect(result.shape).toEqual(input.shape); - expectArraysClose(await result.data(), [ - 56, 57, 58, 59, 52, 53, 54, 55, 48, 49, 50, 51, 68, 69, 70, 71, 64, 65, - 66, 67, 60, 61, 62, 63, 32, 33, 34, 35, 28, 29, 30, 31, 24, 25, 26, 27, - 44, 45, 46, 47, 40, 41, 42, 43, 36, 37, 38, 39, 8, 9, 10, 11, 4, 5, - 6, 7, 0, 1, 2, 3, 20, 21, 22, 23, 16, 17, 18, 19, 12, 13, 14, 15 - ]); - }); - - it('reverse a 4D array at axis [1, 3]', async () => { - const input = tf.tensor4d(data, shape); - const result = tf.reverse4d(input, [1, 3]); - expect(result.shape).toEqual(input.shape); - expectArraysClose(await result.data(), [ - 15, 14, 13, 12, 19, 18, 17, 16, 23, 22, 21, 20, 3, 2, 1, 0, 7, 6, - 5, 4, 11, 10, 9, 8, 39, 38, 37, 36, 43, 42, 41, 40, 47, 46, 45, 44, - 27, 26, 25, 24, 31, 30, 29, 28, 35, 34, 33, 32, 63, 62, 61, 60, 67, 66, - 65, 64, 71, 70, 69, 68, 51, 50, 49, 48, 55, 54, 53, 52, 59, 58, 57, 56 - ]); - }); - - it('throws error with invalid input', () => { - // tslint:disable-next-line:no-any - const x: any = tf.tensor3d([1, 20, 300, 4], [1, 1, 4]); - expect(() => tf.reverse4d(x, [1])).toThrowError(); - }); - - it('throws error with invalid axis param', () => { - const x = tf.tensor4d([1, 20, 300, 4], [1, 1, 1, 4]); - expect(() => tf.reverse4d(x, [4])).toThrowError(); - expect(() => tf.reverse4d(x, [-5])).toThrowError(); - }); - - it('throws error with non integer axis param', () => { - const x = tf.tensor4d([1, 20, 300, 4], [1, 1, 1, 4]); - expect(() => tf.reverse4d(x, [0.5])).toThrowError(); - }); - - it('accepts a tensor-like object', async () => { - const input = [[[[1]], [[2]], [[3]]], [[[4]], [[5]], [[6]]]]; // 2x3x1x1 - const result = tf.reverse4d(input, [0]); - expect(result.shape).toEqual([2, 3, 1, 1]); - expectArraysClose(await result.data(), [4, 5, 6, 1, 2, 3]); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/reverse_test.ts b/tfjs-master/tfjs-core/src/ops/reverse_test.ts deleted file mode 100644 index 5b6fd635a..000000000 --- a/tfjs-master/tfjs-core/src/ops/reverse_test.ts +++ /dev/null @@ -1,64 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; -import {backend} from '../index'; - -describeWithFlags('reverse', ALL_ENVS, () => { - it('throws when passed a non-tensor', () => { - expect(() => tf.reverse({} as tf.Tensor)) - .toThrowError(/Argument 'x' passed to 'reverse' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const input = [1, 2, 3]; - const result = tf.reverse(input); - expect(result.shape).toEqual([3]); - expectArraysClose(await result.data(), [3, 2, 1]); - }); - - it('works with int32 input', async () => { - if (backend() && backend().floatPrecision() === 32) { - // TODO: Use skip() instead when it is implemented - const input = tf.tensor1d([1, 2, 12345678], 'int32'); - const result = tf.reverse(input); - expect(result.shape).toEqual([3]); - expect(result.dtype).toEqual('int32'); - expectArraysClose(await result.data(), [12345678, 2, 1]); - } - }); - - it('ensure no memory leak', async () => { - const numTensorsBefore = tf.memory().numTensors; - const numDataIdBefore = tf.engine().backend.numDataIds(); - - const input = tf.tensor1d([1, 2, 3]); - const result = tf.reverse(input); - expect(result.shape).toEqual([3]); - expectArraysClose(await result.data(), [3, 2, 1]); - - input.dispose(); - result.dispose(); - - const numTensorsAfter = tf.memory().numTensors; - const numDataIdAfter = tf.engine().backend.numDataIds(); - expect(numTensorsAfter).toBe(numTensorsBefore); - expect(numDataIdAfter).toBe(numDataIdBefore); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/rotate_util.ts b/tfjs-master/tfjs-core/src/ops/rotate_util.ts deleted file mode 100644 index bfc111b67..000000000 --- a/tfjs-master/tfjs-core/src/ops/rotate_util.ts +++ /dev/null @@ -1,27 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// Returns the image center in pixels. -export function getImageCenter( - center: number|[number, number], imageHeight: number, - imageWidth: number): [number, number] { - const centerX = - imageWidth * (typeof center === 'number' ? center : center[0]); - const centerY = - imageHeight * (typeof center === 'number' ? center : center[1]); - return [centerX, centerY]; -} diff --git a/tfjs-master/tfjs-core/src/ops/round.ts b/tfjs-master/tfjs-core/src/ops/round.ts deleted file mode 100644 index 8cb0daaea..000000000 --- a/tfjs-master/tfjs-core/src/ops/round.ts +++ /dev/null @@ -1,47 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {Round, RoundInputs} from '../kernel_names'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -import {op} from './operation'; - -/** - * Computes round of input `tf.Tensor` element-wise: `round(x)`. - * It implements banker's rounding. - * - * ```js - * const x = tf.tensor1d([.6, 1.1, -3.3]); - * - * x.round().print(); // or tf.round(x) - * ``` - * @param x The input tensor. - * - * @doc {heading: 'Operations', subheading: 'Basic math'} - */ -function round_(x: T|TensorLike): T { - const $x = convertToTensor(x, 'x', 'round'); - const inputs: RoundInputs = {x: $x}; - - return ENGINE.runKernel(Round, inputs as unknown as NamedTensorMap); -} - -export const round = /* @__PURE__ */ op({round_}); diff --git a/tfjs-master/tfjs-core/src/ops/round_test.ts b/tfjs-master/tfjs-core/src/ops/round_test.ts deleted file mode 100644 index 69ba9ac9e..000000000 --- a/tfjs-master/tfjs-core/src/ops/round_test.ts +++ /dev/null @@ -1,106 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; -import {backend} from '../index'; - -describeWithFlags('round', ALL_ENVS, () => { - it('basic', async () => { - const a = tf.tensor1d([0.9, 2.5, 2.3, 1.5, -4.5]); - const r = a.round(); - - expectArraysClose(await r.data(), [1, 2, 2, 2, -4]); - }); - - it('int32', async () => { - if (backend() && backend().floatPrecision() === 32) { - // TODO: Use skip() instead when it is implemented - const a = tf.tensor1d([-12345678, 10, 12345678], 'int32'); - const r = a.round(); - - expect(r.dtype).toEqual('int32'); - expectArraysClose(await r.data(), [-12345678, 10, 12345678]); - } - }); - - it('propagates NaNs', async () => { - const a = tf.tensor1d([1.5, NaN, -1.4]); - const r = tf.round(a); - expectArraysClose(await r.data(), [2, NaN, -1]); - }); - - it('gradients: Scalar', async () => { - const a = tf.scalar(5.2); - const dy = tf.scalar(3); - - const gradients = tf.grad(a => tf.round(a))(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), [0]); - }); - - it('gradient with clones', async () => { - const a = tf.scalar(5.2); - const dy = tf.scalar(3); - - const gradients = tf.grad(a => tf.round(a.clone()).clone())(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), [0]); - }); - - it('gradients: Tensor1D', async () => { - const a = tf.tensor1d([-1.1, 2.6, 3, -5.9]); - const dy = tf.tensor1d([1, 2, 3, 4]); - - const gradients = tf.grad(a => tf.round(a))(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), [0, 0, 0, 0]); - }); - - it('gradients: Tensor2D', async () => { - const a = tf.tensor2d([-3, 1, 2.2, 3], [2, 2]); - const dy = tf.tensor2d([1, 2, 3, 4], [2, 2]); - - const gradients = tf.grad(a => tf.round(a))(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), [0, 0, 0, 0]); - }); - - it('throws when passed a non-tensor', () => { - expect(() => tf.round({} as tf.Tensor)) - .toThrowError(/Argument 'x' passed to 'round' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const r = tf.round([0.9, 2.5, 2.3, 1.5, -4.5]); - expectArraysClose(await r.data(), [1, 2, 2, 2, -4]); - }); - - it('throws for string tensor', () => { - expect(() => tf.round('q')) - .toThrowError(/Argument 'x' passed to 'round' must be numeric/); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/rsqrt.ts b/tfjs-master/tfjs-core/src/ops/rsqrt.ts deleted file mode 100644 index 8a90db92a..000000000 --- a/tfjs-master/tfjs-core/src/ops/rsqrt.ts +++ /dev/null @@ -1,47 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {Rsqrt, RsqrtInputs} from '../kernel_names'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -import {op} from './operation'; - -/** - * Computes reciprocal of square root of the input `tf.Tensor` element-wise: - * `y = 1 / sqrt(x)` - * - * ```js - * const x = tf.tensor1d([1, 2, 4, -1]); - * - * x.rsqrt().print(); // or tf.rsqrt(x) - * ``` - * @param x The input tensor. - * - * @doc {heading: 'Operations', subheading: 'Basic math'} - */ -function rsqrt_(x: T|TensorLike): T { - const $x = convertToTensor(x, 'x', 'rsqrt', 'float32'); - - const inputs: RsqrtInputs = {x: $x}; - - return ENGINE.runKernel(Rsqrt, inputs as unknown as NamedTensorMap); -} -export const rsqrt = /* @__PURE__ */ op({rsqrt_}); diff --git a/tfjs-master/tfjs-core/src/ops/rsqrt_test.ts b/tfjs-master/tfjs-core/src/ops/rsqrt_test.ts deleted file mode 100644 index 333fb46ae..000000000 --- a/tfjs-master/tfjs-core/src/ops/rsqrt_test.ts +++ /dev/null @@ -1,110 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('rsqrt', ALL_ENVS, () => { - it('rsqrt', async () => { - const a = tf.tensor1d([2, 4]); - const r = tf.rsqrt(a); - expectArraysClose(await r.data(), [1 / Math.sqrt(2), 1 / Math.sqrt(4)]); - }); - - it('rsqrt propagates NaNs', async () => { - const a = tf.tensor1d([1, NaN]); - const r = tf.rsqrt(a); - expectArraysClose(await r.data(), [1 / Math.sqrt(1), NaN]); - }); - - it('gradients: Scalar', async () => { - const a = tf.scalar(4); - const dy = tf.scalar(8); - - const da = tf.grad(a => tf.rsqrt(a))(a, dy); - - expect(da.shape).toEqual(a.shape); - expect(da.dtype).toEqual('float32'); - expectArraysClose(await da.data(), [(-1 * 8) / (2 * Math.pow(4, 1.5))]); - }); - - it('gradients: Scalar', async () => { - const a = tf.scalar(4); - const dy = tf.scalar(8); - - const da = tf.grad(a => tf.rsqrt(a.clone()).clone())(a, dy); - - expect(da.shape).toEqual(a.shape); - expect(da.dtype).toEqual('float32'); - expectArraysClose(await da.data(), [(-1 * 8) / (2 * Math.pow(4, 1.5))]); - }); - - it('gradients: Tensor1D', async () => { - const a = tf.tensor1d([1, 2, 3, 5]); - const dy = tf.tensor1d([1, 2, 3, 4]); - - const gradients = tf.grad(a => tf.rsqrt(a))(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose( - await gradients.data(), - [ - -1 * 1 / (2 * Math.pow(1, 1.5)), -1 * 2 / (2 * Math.pow(2, 1.5)), - -1 * 3 / (2 * Math.pow(3, 1.5)), -1 * 4 / (2 * Math.pow(5, 1.5)) - ], - 1e-1); - }); - - it('gradients: Tensor2D', async () => { - const a = tf.tensor2d([3, 1, 2, 3], [2, 2]); - const dy = tf.tensor2d([1, 2, 3, 4], [2, 2]); - - const gradients = tf.grad(a => tf.rsqrt(a))(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose( - await gradients.data(), - [ - -1 * 1 / (2 * Math.pow(3, 1.5)), -1 * 2 / (2 * Math.pow(1, 1.5)), - -1 * 3 / (2 * Math.pow(2, 1.5)), -1 * 4 / (2 * Math.pow(3, 1.5)) - ], - 1e-1); - }); - - it('throws when passed a non-tensor', () => { - expect(() => tf.rsqrt({} as tf.Tensor)) - .toThrowError(/Argument 'x' passed to 'rsqrt' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const r = tf.rsqrt([2, 4]); - expectArraysClose(await r.data(), [1 / Math.sqrt(2), 1 / Math.sqrt(4)]); - }); - - it('throws for string tensor', () => { - expect(() => tf.rsqrt('q')) - .toThrowError(/Argument 'x' passed to 'rsqrt' must be float32/); - }); - - it('throws for int32 tensor', () => { - expect(() => tf.rsqrt(tf.tensor1d([1], 'int32'))) - .toThrowError(/Argument 'x' passed to 'rsqrt' must be float32/); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/scalar.ts b/tfjs-master/tfjs-core/src/ops/scalar.ts deleted file mode 100644 index 107a3d076..000000000 --- a/tfjs-master/tfjs-core/src/ops/scalar.ts +++ /dev/null @@ -1,55 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Scalar} from '../tensor'; -import {DataType} from '../types'; -import {isTypedArray} from '../util'; -import {makeTensor} from './tensor_ops_util'; - -/** - * Creates rank-0 `tf.Tensor` (scalar) with the provided value and dtype. - * - * The same functionality can be achieved with `tf.tensor`, but in general - * we recommend using `tf.scalar` as it makes the code more readable. - * - * ```js - * tf.scalar(3.14).print(); - * ``` - * - * @param value The value of the scalar. - * @param dtype The data type. - * - * @doc {heading: 'Tensors', subheading: 'Creation'} - */ -export function scalar( - value: number|boolean|string|Uint8Array, dtype?: DataType): Scalar { - if (((isTypedArray(value) && dtype !== 'string') || Array.isArray(value)) && - dtype !== 'complex64') { - throw new Error( - 'Error creating a new Scalar: value must be a primitive ' + - '(number|boolean|string)'); - } - if (dtype === 'string' && isTypedArray(value) && - !(value instanceof Uint8Array)) { - throw new Error( - 'When making a scalar from encoded string, ' + - 'the value must be `Uint8Array`.'); - } - const shape: number[] = []; - const inferredShape: number[] = []; - return makeTensor(value, shape, inferredShape, dtype) as Scalar; -} diff --git a/tfjs-master/tfjs-core/src/ops/scatter_nd.ts b/tfjs-master/tfjs-core/src/ops/scatter_nd.ts deleted file mode 100644 index 6dfd19ace..000000000 --- a/tfjs-master/tfjs-core/src/ops/scatter_nd.ts +++ /dev/null @@ -1,66 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {ScatterNd, ScatterNdAttrs, ScatterNdInputs} from '../kernel_names'; -import {NamedAttrMap} from '../kernel_registry'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {Rank, ShapeMap, TensorLike} from '../types'; -import {assertNonNegativeIntegerDimensions} from '../util_base'; - -import {op} from './operation'; -import * as scatter_nd_util from './scatter_nd_util'; - -/** - * Creates a new tensor by applying sparse updates to individual - * values or slices within a zero tensor of the given shape tensor according to - * indices. This operator is the inverse of the `tf.gatherND` operator which - * extracts values or slices from a given tensor. - * - * ```js - * const indices = tf.tensor2d([4, 3, 1, 7], [4, 1], 'int32'); - * const updates = tf.tensor1d([9, 10, 11, 12]); - * const shape = [8]; - * tf.scatterND(indices, updates, shape).print() //[0, 11, 0, 10, 9, 0, 0, 12] - * ``` - * - * @param indices The tensor contains the indices into the output tensor. - * @param updates The tensor contains the value for the indices. - * @param shape: The shape of the output tensor. - * - * @doc {heading: 'Operations', subheading: 'Slicing and Joining'} - */ -function scatterND_( - indices: Tensor|TensorLike, updates: Tensor|TensorLike, - shape: ShapeMap[R]): Tensor { - assertNonNegativeIntegerDimensions(shape); - const $indices = convertToTensor(indices, 'indices', 'scatterND', 'int32'); - const $updates = convertToTensor(updates, 'updates', 'scatterND'); - scatter_nd_util.validateInput($updates, $indices, shape); - - const inputs: ScatterNdInputs = {indices: $indices, updates: $updates}; - const attrs: ScatterNdAttrs = {shape}; - - // tslint:disable-next-line: no-unnecessary-type-assertion - return ENGINE.runKernel( - ScatterNd, inputs as unknown as NamedTensorMap, - attrs as unknown as NamedAttrMap) as Tensor; -} - -export const scatterND = /* @__PURE__ */ op({scatterND_}); diff --git a/tfjs-master/tfjs-core/src/ops/scatter_nd_test.ts b/tfjs-master/tfjs-core/src/ops/scatter_nd_test.ts deleted file mode 100644 index 9c081f01b..000000000 --- a/tfjs-master/tfjs-core/src/ops/scatter_nd_test.ts +++ /dev/null @@ -1,159 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('scatterND', ALL_ENVS, () => { - it('should work for 2d', async () => { - const indices = tf.tensor1d([0, 4, 2], 'int32'); - const updates = tf.tensor2d( - [100, 101, 102, 777, 778, 779, 1000, 1001, 1002], [3, 3], 'int32'); - const shape = [5, 3]; - const result = tf.scatterND(indices, updates, shape); - expect(result.shape).toEqual(shape); - expect(result.dtype).toEqual(updates.dtype); - expectArraysClose( - await result.data(), - [100, 101, 102, 0, 0, 0, 1000, 1001, 1002, 0, 0, 0, 777, 778, 779]); - }); - - it('should work for simple 1d', async () => { - const indices = tf.tensor1d([3], 'int32'); - const updates = tf.tensor1d([101], 'float32'); - const shape = [5]; - const result = tf.scatterND(indices, updates, shape); - expect(result.shape).toEqual(shape); - expect(result.dtype).toEqual(updates.dtype); - expectArraysClose(await result.data(), [0, 0, 0, 101, 0]); - }); - - it('should work for multiple 1d', async () => { - const indices = tf.tensor1d([0, 4, 2], 'int32'); - const updates = tf.tensor1d([100, 101, 102], 'float32'); - const shape = [5]; - const result = tf.scatterND(indices, updates, shape); - expect(result.shape).toEqual(shape); - expect(result.dtype).toEqual(updates.dtype); - expectArraysClose(await result.data(), [100, 0, 102, 0, 101]); - }); - - it('should work for high rank updates', async () => { - const indices = tf.tensor2d([0, 2], [2, 1], 'int32'); - const updates = tf.tensor3d( - [ - 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, - 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8 - ], - [2, 4, 4], 'float32'); - const shape = [4, 4, 4]; - const result = tf.scatterND(indices, updates, shape); - expect(result.shape).toEqual(shape); - expect(result.dtype).toEqual(updates.dtype); - expectArraysClose(await result.data(), [ - 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, - 8, 8, 8, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ]); - }); - - it('should work for high rank indices', async () => { - const indices = tf.tensor2d([0, 2, 0, 1], [2, 2], 'int32'); - const updates = tf.tensor1d([10, 20], 'float32'); - const shape = [3, 3]; - const result = tf.scatterND(indices, updates, shape); - expect(result.shape).toEqual(shape); - expect(result.dtype).toEqual(updates.dtype); - expectArraysClose(await result.data(), [0, 20, 10, 0, 0, 0, 0, 0, 0]); - }); - - it('should work for high rank indices and update', () => { - const indices = tf.tensor2d([1, 0, 0, 1, 0, 1], [3, 2], 'int32'); - const updates = tf.ones([3, 256], 'float32'); - const shape = [2, 2, 256]; - const result = tf.scatterND(indices, updates, shape); - expect(result.shape).toEqual(shape); - expect(result.dtype).toEqual(updates.dtype); - }); - - it('should sum the duplicated indices', async () => { - const indices = tf.tensor1d([0, 4, 2, 1, 3, 0], 'int32'); - const updates = tf.tensor1d([10, 20, 30, 40, 50, 60], 'float32'); - const shape = [8]; - const result = tf.scatterND(indices, updates, shape); - expect(result.shape).toEqual(shape); - expect(result.dtype).toEqual(updates.dtype); - expectArraysClose(await result.data(), [70, 40, 30, 50, 20, 0, 0, 0]); - }); - - it('should work for tensorLike input', async () => { - const indices = [0, 4, 2]; - const updates = [100, 101, 102]; - const shape = [5]; - const result = tf.scatterND(indices, updates, shape); - expect(result.shape).toEqual(shape); - expect(result.dtype).toEqual('float32'); - expectArraysClose(await result.data(), [100, 0, 102, 0, 101]); - }); - - it('should throw error when indices type is not int32', () => { - const indices = tf.tensor2d([0, 2, 0, 1], [2, 2], 'float32'); - const updates = tf.tensor1d([10, 20], 'float32'); - const shape = [3, 3]; - expect(() => tf.scatterND(indices, updates, shape)).toThrow(); - }); - - it('should throw error when indices and update mismatch', () => { - const indices = tf.tensor2d([0, 4, 2], [3, 1], 'int32'); - const updates = tf.tensor2d( - [100, 101, 102, 103, 777, 778, 779, 780, 10000, 10001, 10002, 10004], - [3, 4], 'float32'); - const shape = [5, 3]; - expect(() => tf.scatterND(indices, updates, shape)).toThrow(); - }); - - it('should throw error when indices and update count mismatch', () => { - const indices = tf.tensor2d([0, 4, 2], [3, 1], 'int32'); - const updates = - tf.tensor2d([100, 101, 102, 10000, 10001, 10002], [2, 3], 'float32'); - const shape = [5, 3]; - expect(() => tf.scatterND(indices, updates, shape)).toThrow(); - }); - - it('should throw error when indices are scalar', () => { - const indices = tf.scalar(1, 'int32'); - const updates = - tf.tensor2d([100, 101, 102, 10000, 10001, 10002], [2, 3], 'float32'); - const shape = [5, 3]; - expect(() => tf.scatterND(indices, updates, shape)).toThrow(); - }); - - it('should throw error when update is scalar', () => { - const indices = tf.tensor2d([0, 4, 2], [3, 1], 'int32'); - const updates = tf.scalar(1, 'float32'); - const shape = [5, 3]; - expect(() => tf.scatterND(indices, updates, shape)).toThrow(); - }); - - it('should throw error when shape is not integer', () => { - const indices = [0, 4, 2]; - const updates = [100, 101, 102]; - const shape = [5.55, 2.22]; - expect(() => tf.scatterND(indices, updates, shape)).toThrow(); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/scatter_nd_util.ts b/tfjs-master/tfjs-core/src/ops/scatter_nd_util.ts deleted file mode 100644 index e52b2934e..000000000 --- a/tfjs-master/tfjs-core/src/ops/scatter_nd_util.ts +++ /dev/null @@ -1,149 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import { TensorInfo } from '../tensor_info'; -import {Tensor} from '../tensor'; -import {computeStrides, sizeFromShape} from '../util'; - -/** - * Check whether updates.shape = indices.shape[:batchDim] + - * shape[sliceDim:] - * - * @param x The input tensor. - */ -export function validateUpdateShape( - shape: number[], indices: Tensor, updates: Tensor) { - const sliceDim = (indices.rank > 1) ? indices.shape[indices.rank - 1] : 1; - const batchDim = (indices.rank > 1) ? indices.rank - 1 : 1; - - const shapeError = 'Must have updates.shape = indices.shape[:batchDim] + ' + - `shape[sliceDim:], got updates.shape: ${updates.shape}` + - `, indices.shape: ${indices.shape}, shape: ${shape}` + - `, sliceDim: ${sliceDim}, and batchDim: ${batchDim}.`; - - if (updates.rank < batchDim) { - throw new Error(shapeError + ` update.rank < ${batchDim}. `); - } - if (shape.length < sliceDim + (updates.rank - batchDim)) { - throw new Error( - shapeError + - ` Output shape length < ${sliceDim + (updates.rank - batchDim)}`); - } - if (updates.rank !== batchDim + shape.length - sliceDim) { - throw new Error( - shapeError + ` update.rank != ${batchDim + shape.length - sliceDim}`); - } - for (let d = 0; d < batchDim; ++d) { - if (updates.shape[d] !== indices.shape[d]) { - throw new Error( - shapeError + - ` updates.shape[${d}] (${updates.shape[d]}) != indices.shape[${d}] (${ - indices.shape[d]}).`); - } - } - for (let d = 0; d < updates.rank - batchDim; ++d) { - if (updates.shape[d + batchDim] !== shape[d + sliceDim]) { - throw new Error( - shapeError + - ` updates.shape[${d + batchDim}] (${ - updates.shape[d + batchDim]}) != shape[${d + batchDim}] (${ - shape[d + batchDim]})`); - } - } -} - -export interface ScatterShapeInfo { - sliceRank: number; - numUpdates: number; - sliceSize: number; - strides: number[]; - outputSize: number; -} -/** - * Validate scatter nd inputs. - * - * @param update The tensor contains the update values. - * @param indices The tensor contains the indices for the update values. - * @param shape The shape of the output tensor. - */ -export function validateInput( - updates: Tensor, indices: Tensor, shape: number[]) { - if (indices.rank < 1) { - throw new Error( - 'tf.scatterND() expects the indices to be rank 1 or higher,' + - ` but the rank was ${indices.rank}.`); - } - if (updates.rank < 1) { - throw new Error( - 'tf.scatterND() expects the updates to be rank 1 or higher,' + - ` but the rank was ${updates.rank}.`); - } - if (indices.dtype !== 'int32') { - throw new Error(`The dtype of 'indices' should be int32, but got dtype: ${ - indices.dtype}`); - } - if (shape.length < 1) { - throw new Error( - `Output rank must be greater or equal to 1, but got shape: ${shape}`); - } - - if (shape.length === 0) { - if (indices.size === 0) { - throw new Error(`Indices specified for empty output. indices shape: ${ - indices.shape}`); - } - if (updates.size === 0) { - throw new Error(`Updates specified for empty output. updates shape: ${ - updates.shape}`); - } - } - - validateUpdateShape(shape, indices, updates); -} - -/** - * Calculate the shape information for the output. - * - * @param update The tensor contains the update values. - * @param indices The tensor contains the indices for the update values. - * @param shape The shape of the output tensor. - * - * @returns ScatterShapeInfo - */ -export function calculateShapes( - updates: TensorInfo, indices: TensorInfo, - shape: number[]): ScatterShapeInfo { - // Calculate the number of dimensions in indices - const indicesRank = indices.shape.length; - const sliceRank = (indicesRank > 1) ? indices.shape[indicesRank - 1] : 1; - - // Calculate the number of elements that make up each slice of our updated - // tensor. This allows us to work with flattened tensors and copy over whole - // slices at a time. - const totalNd = shape.length; - - let sliceSize = 1; - for (let i = sliceRank; i < totalNd; ++i) { - sliceSize *= shape[i]; - } - - const safeSliceDim = (sliceRank < 1) ? 1 : sliceRank; - const numUpdates = sizeFromShape(indices.shape) / safeSliceDim; - - const strides = [...computeStrides(shape.slice(0, sliceRank)), 1]; - const outputSize = sizeFromShape(shape); - return {sliceRank, numUpdates, sliceSize, strides, outputSize}; -} diff --git a/tfjs-master/tfjs-core/src/ops/search_sorted.ts b/tfjs-master/tfjs-core/src/ops/search_sorted.ts deleted file mode 100644 index 9be9022c2..000000000 --- a/tfjs-master/tfjs-core/src/ops/search_sorted.ts +++ /dev/null @@ -1,116 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {SearchSorted, SearchSortedAttrs, SearchSortedInputs} from '../kernel_names'; -import {Tensor} from '../tensor'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; -import {sizeFromShape} from '../util_base'; -import {op} from './operation'; -import {reshape} from './reshape'; - -const INT32_MAX = 2147483648; -/** - * Searches for where a value would go in a sorted sequence. - * - * This is not a method for checking containment (like javascript in). - * - * The typical use case for this operation is "binning", "bucketing", or - * "discretizing". The values are assigned to bucket-indices based on the edges - * listed in 'sortedSequence'. This operation returns the bucket-index for each - * value. - * - * The side argument controls which index is returned if a value lands exactly - * on an edge. - * - * The axis is not settable for this operation. It always operates on the - * innermost dimension (axis=-1). The operation will accept any number of outer - * dimensions. - * - * Note: This operation assumes that 'sortedSequence' is sorted along the - * innermost axis, maybe using 'sort(..., axis=-1)'. If the sequence is not - * sorted no error is raised and the content of the returned tensor is not well - * defined. - * - * ```js - * const edges = tf.tensor1d([-1, 3.3, 9.1, 10.0]); - * let values = tf.tensor1d([0.0, 4.1, 12.0]); - * const result1 = tf.searchSorted(edges, values, 'left'); - * result1.print(); // [1, 2, 4] - * - * const seq = tf.tensor1d([0, 3, 9, 10, 10]); - * values = tf.tensor1d([0, 4, 10]); - * const result2 = tf.searchSorted(seq, values, 'left'); - * result2.print(); // [0, 2, 3] - * const result3 = tf.searchSorted(seq, values, 'right'); - * result3.print(); // [1, 2, 5] - * - * const sortedSequence = tf.tensor2d([[0., 3., 8., 9., 10.], - * [1., 2., 3., 4., 5.]]); - * values = tf.tensor2d([[9.8, 2.1, 4.3], - * [0.1, 6.6, 4.5, ]]); - * const result4 = tf.searchSorted(sortedSequence, values, 'left'); - * result4.print(); // [[4, 1, 2], [0, 5, 4]] - * ``` - * @param sortedSequence: N-D. Sorted sequence. - * @param values: N-D. Search values. - * @param side: 'left'|'right'. Defaults to 'left'. 'left' corresponds to lower - * bound and 'right' to upper bound. - * @return An N-D int32 tensor the size of values containing the result of - * applying either lower bound or upper bound (depending on side) to each - * value. The result is not a global index to the entire Tensor, but the - * index in the last dimension. - * @doc {heading: 'Operations', subheading: 'Evaluation'} - */ -function searchSorted_( - sortedSequence: Tensor|TensorLike, values: Tensor|TensorLike, - side: 'left'|'right' = 'left'): Tensor { - const $sortedSequence = - convertToTensor(sortedSequence, 'sortedSequence', 'searchSorted'); - const $values = convertToTensor(values, 'values', 'searchSorted'); - - const sequenceSize = $sortedSequence.shape[$sortedSequence.shape.length - 1]; - const valuesSize = $values.shape[$values.shape.length - 1]; - const $sortedSequence2D = reshape($sortedSequence, [-1, sequenceSize]); - const $values2D = reshape($values, [-1, valuesSize]); - - if ($sortedSequence2D.rank < 2) { - throw new Error(`Sorted input argument must be at least 2-dimensional`); - } - if ($sortedSequence2D.shape[0] !== $values2D.shape[0]) { - throw new Error( - `Leading dimension of 'sortedSequence' and 'values' must match.`); - } - if (sizeFromShape($values2D.shape) >= INT32_MAX) { - throw new Error(`values tensor size must less than ${INT32_MAX}`); - } - if ($sortedSequence2D.shape[1] >= INT32_MAX) { - throw new Error(`trailing dim_size must less than ${ - INT32_MAX} for int32 output type, was ${$sortedSequence2D.shape[1]}`); - } - - const inputs: SearchSortedInputs = { - sortedSequence: $sortedSequence2D, - values: $values2D, - }; - const attrs: SearchSortedAttrs = {side}; - - return ENGINE.runKernel(SearchSorted, inputs as {}, attrs as {}); -} - -export const searchSorted = /* @__PURE__ */ op({searchSorted_}); diff --git a/tfjs-master/tfjs-core/src/ops/search_sorted_test.ts b/tfjs-master/tfjs-core/src/ops/search_sorted_test.ts deleted file mode 100644 index d9ecf2f5d..000000000 --- a/tfjs-master/tfjs-core/src/ops/search_sorted_test.ts +++ /dev/null @@ -1,117 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('searchSorted', ALL_ENVS, () => { - it('test1D', async () => { - // Tests against numpy generated data. - const NUMPY_DATA = { - 'left-float32': [ - [ - -945.2247924804688, -921.8904418945312, -829.9115600585938, - -719.2261352539062, -660.3391723632812, -603.7969970703125, - -591.0955200195312, -373.1516418457031, -165.39039611816406, - -161.61097717285156, 117.37965393066406, 340.9350280761719, - 370.4389953613281, 384.6452331542969, 601.4891357421875, - 752.7783203125, 756.23486328125, 756.2850341796875, - 789.2133178710938, 936.5231323242188 - ], - [ - -165.95599365234375, 440.64898681640625, -999.771240234375, - -395.3348693847656, -706.4882202148438, -815.3228149414062, - -627.4795532226562, -308.8785400390625, -206.46505737304688, - 77.63346862792969 - ], - [8, 14, 0, 7, 4, 3, 5, 8, 8, 10] - ], - 'left-int32': [ - [ - -961, -893, -793, -739, -706, -576, -468, -439, -424, -412, - -104, -16, 148, 178, 357, 399, 496, 578, 817, 977 - ], - [-803, -157, 915, 66, 383, -368, 373, 669, -963, 500], - [2, 10, 19, 12, 15, 10, 15, 18, 0, 17] - ], - 'right-float32': [ - [ - -725.0505981445312, -721.4473266601562, -669.2916259765625, - -460.14422607421875, -304.4682922363281, -302.20330810546875, - -204.64633178710938, -143.817626953125, 243.3914337158203, - 247.34442138671875, 326.88299560546875, 451.9959716796875, - 501.62420654296875, 501.8848571777344, 614.7825927734375, - 766.6121826171875, 791.7724609375, 806.8038330078125, - 855.0171508789062, 929.6801147460938 - ], - [ - -795.3311157226562, -171.88803100585938, 388.8003234863281, - -171.64146423339844, -900.0930786132812, 71.79280853271484, - 327.58929443359375, 29.77822494506836, 889.1895141601562, - 173.11007690429688 - ], - [0, 7, 11, 7, 0, 8, 11, 8, 19, 8] - ], - 'right-int32': [ - [ - -968, -867, -751, -725, -655, -346, -285, 54, 246, 381, - 393, 423, 507, 510, 771, 817, 846, 858, 865, 994 - ], - [-770, 898, -100, 156, -183, -525, 806, 147, -994, 234], - [2, 19, 7, 8, 7, 5, 15, 8, 0, 8] - ] - }; - for (const side of ['left', 'right'] as const ) { - for (const dtype of ['float32', 'int32'] as const ) { - // tslint:disable-next-line:no-unnecessary-type-assertion - const key = `${side}-${dtype}` as keyof typeof NUMPY_DATA; - const [sortedSequence, values, npAns] = NUMPY_DATA[key]; - - const result = tf.searchSorted(sortedSequence, values, side); - - expectArraysClose(await result.data(), npAns); - } - } - }); - - it('lowerBound2D', async () => { - for (const dtype of ['float32', 'int32'] as const ) { - const sortedSequence = - tf.tensor2d([[0, 3, 9, 9, 10], [1, 2, 3, 4, 5]], undefined, dtype); - const values = tf.tensor2d([[2, 4, 9], [0, 2, 6]], undefined, dtype); - const correctAns = [[1, 2, 2], [0, 1, 5]]; - - const result = tf.searchSorted(sortedSequence, values, 'left'); - - expectArraysClose(await result.data(), correctAns); - } - }); - - it('upperBound2D', async () => { - for (const dtype of ['float32', 'int32'] as const ) { - const sortedSequence = - tf.tensor2d([[0, 3, 9, 9, 10], [1, 2, 3, 4, 5]], undefined, dtype); - const values = tf.tensor2d([[2, 4, 9], [0, 2, 6]], undefined, dtype); - const correctAns = [[1, 2, 4], [0, 2, 5]]; - - const result = tf.searchSorted(sortedSequence, values, 'right'); - - expectArraysClose(await result.data(), correctAns); - } - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/segment_util.ts b/tfjs-master/tfjs-core/src/ops/segment_util.ts deleted file mode 100644 index 928655bf6..000000000 --- a/tfjs-master/tfjs-core/src/ops/segment_util.ts +++ /dev/null @@ -1,135 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import { TensorInfo } from '../tensor_info'; -import {nearestDivisor} from '../util'; - -import {PARALLELIZE_THRESHOLD} from './reduce_util'; - -export interface SegOpInfo { - windowSize: number; - batchSize: number; - inSize: number; - numSegments: number; -} - -export function segOpComputeOptimalWindowSize( - inSize: number, numSegments: number): number { - let done = false; - let res; - - if (inSize <= PARALLELIZE_THRESHOLD) { - res = inSize; - done = true; - } else { - res = nearestDivisor(inSize, Math.floor(Math.sqrt(inSize))); - } - - while (!done) { - if (res > numSegments || res === inSize) { - done = true; - } else { - res = nearestDivisor(inSize, res + 1); - } - } - return res; -} - -export function computeOutShape( - aShape: number[], axis: number, numSegments: number): number[] { - const outShape = []; - const rank = aShape.length; - for (let dim = 0; dim < rank; dim++) { - if (dim !== axis) { - outShape.push(aShape[dim]); - } else { - outShape.push(numSegments); - } - } - return outShape; -} - -export interface GatherOpShapeInfo { - batchSize: number; - sliceSize: number; - outerSize: number; - dimSize: number; - outputShape: number[]; -} - -export function collectGatherOpShapeInfo( - x: TensorInfo, indices: TensorInfo, axis: number, - batchDims: number): GatherOpShapeInfo { - const indicesRank = indices.shape.length; - const xRank = x.shape.length; - - if (batchDims !== 0) { - if (batchDims < -indicesRank || batchDims > indicesRank) { - throw new Error(`Expect batchDims in the range of [-${indicesRank}, ${ - indicesRank}], but got ${batchDims}`); - } - } - - if (batchDims < 0) { - batchDims += indicesRank; - } - - if (batchDims > xRank) { - throw new Error(`batchDims (${batchDims}) must be less than rank(x) ( - ${xRank}).`); - } - - if (axis < batchDims) { - throw new Error(`batchDims (${ - batchDims}) must be less than or equal to axis (${axis}).`); - } - - for (let i = 0; i < batchDims; ++i) { - if (x.shape[i] !== indices.shape[i]) { - throw new Error( - `x.shape[${i}]: ${x.shape[i]} should be equal to indices.shape[${ - i}]: ${indices.shape[i]}.`); - } - } - const dimSize = x.shape[axis]; - - const outputShape: number[] = []; - let batchSize = 1; - let outerSize = 1; - let sliceSize = 1; - - for (let i = 0; i < batchDims; ++i) { - outputShape.push(x.shape[i]); - batchSize *= x.shape[i]; - } - - for (let i = batchDims; i < axis; i++) { - outputShape.push(x.shape[i]); - outerSize *= x.shape[i]; - } - - for (let i = batchDims; i < indicesRank; i++) { - outputShape.push(indices.shape[i]); - } - - for (let i = axis + 1; i < xRank; i++) { - outputShape.push(x.shape[i]); - sliceSize *= x.shape[i]; - } - - return {batchSize, sliceSize, outerSize, dimSize, outputShape}; -} diff --git a/tfjs-master/tfjs-core/src/ops/selu.ts b/tfjs-master/tfjs-core/src/ops/selu.ts deleted file mode 100644 index 47f61405e..000000000 --- a/tfjs-master/tfjs-core/src/ops/selu.ts +++ /dev/null @@ -1,49 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {Selu, SeluInputs} from '../kernel_names'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -import {op} from './operation'; - -/** - * Computes scaled exponential linear element-wise. - * - * `x < 0 ? scale * alpha * (exp(x) - 1) : scale * x` - * - * ```js - * const x = tf.tensor1d([-1, 2, -3, 4]); - * - * x.selu().print(); // or tf.selu(x) - * ``` - * @param x The input tensor. - * - * @doc {heading: 'Operations', subheading: 'Basic math'} - */ -function selu_(x: T|TensorLike): T { - const $x = convertToTensor(x, 'x', 'selu'); - - const inputs: SeluInputs = {x: $x}; - - return ENGINE.runKernel(Selu, inputs as unknown as NamedTensorMap); -} - -export const selu = /* @__PURE__ */ op({selu_}); diff --git a/tfjs-master/tfjs-core/src/ops/selu_test.ts b/tfjs-master/tfjs-core/src/ops/selu_test.ts deleted file mode 100644 index 1803b5dfc..000000000 --- a/tfjs-master/tfjs-core/src/ops/selu_test.ts +++ /dev/null @@ -1,140 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -import * as selu_util from './selu_util'; - -describeWithFlags('selu', ALL_ENVS, () => { - const scaleAlpha = selu_util.SELU_SCALEALPHA; - const scale = selu_util.SELU_SCALE; - - it('calculate selu', async () => { - const a = tf.tensor1d([1, -1, 0]); - const result = tf.selu(a); - - expect(result.shape).toEqual(a.shape); - expectArraysClose(await result.data(), [1.0507, -1.1113, 0]); - }); - - it('selu propagates NaN', async () => { - const a = tf.tensor1d([1, NaN]); - const result = tf.selu(a); - expect(result.shape).toEqual(a.shape); - expectArraysClose(await result.data(), [1.0507, NaN]); - }); - - it('gradients: Scalar', async () => { - let aValue = 1; - let dyValue = 1; - let a = tf.scalar(aValue); - let dy = tf.scalar(dyValue); - - let gradients = tf.grad(a => tf.selu(a))(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), [dyValue * scale]); - - aValue = -1; - dyValue = 2; - a = tf.scalar(aValue); - dy = tf.scalar(dyValue); - - gradients = tf.grad(a => tf.selu(a))(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose( - await gradients.data(), [dyValue * scaleAlpha * Math.exp(aValue)]); - }); - - it('gradient with clones', async () => { - const aValue = 1; - const dyValue = 1; - const a = tf.scalar(aValue); - const dy = tf.scalar(dyValue); - - const gradients = tf.grad(a => tf.selu(a.clone()).clone())(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), [dyValue * scale]); - }); - - it('gradients: Tensor1D', async () => { - const aValues = [1, -1, 0]; - const dyValues = [1, 2, 3]; - const a = tf.tensor1d(aValues); - const dy = tf.tensor1d(dyValues); - - const gradients = tf.grad(a => tf.selu(a))(a, dy); - - const expected = []; - for (let i = 0; i < a.size; i++) { - if (aValues[i] > 0) { - expected[i] = dyValues[i] * scale; - } else { - expected[i] = dyValues[i] * scaleAlpha * Math.exp(aValues[i]); - } - } - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), expected); - }); - - it('gradients: Tensor2D', async () => { - const aValues = [1, -1, 0, 0.5]; - const dyValues = [1, 2, 3, 4]; - const a = tf.tensor2d(aValues, [2, 2]); - const dy = tf.tensor2d(dyValues, [2, 2]); - - const gradients = tf.grad(a => tf.selu(a))(a, dy); - - const expected = []; - for (let i = 0; i < a.size; i++) { - if (aValues[i] > 0) { - expected[i] = dyValues[i] * scale; - } else { - expected[i] = dyValues[i] * scaleAlpha * Math.exp(aValues[i]); - } - } - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), expected); - }); - - it('throws when passed a non-tensor', () => { - expect(() => tf.selu({} as tf.Tensor)) - .toThrowError(/Argument 'x' passed to 'selu' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const result = tf.selu([1, -1, 0]); - expect(result.shape).toEqual([3]); - expectArraysClose(await result.data(), [1.0507, -1.1113, 0]); - }); - - it('throws for string tensor', () => { - expect(() => tf.selu('q')) - .toThrowError(/Argument 'x' passed to 'selu' must be numeric/); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/selu_util.ts b/tfjs-master/tfjs-core/src/ops/selu_util.ts deleted file mode 100644 index 1263c0089..000000000 --- a/tfjs-master/tfjs-core/src/ops/selu_util.ts +++ /dev/null @@ -1,19 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -export const SELU_SCALEALPHA = 1.7580993408473768599402175208123; -export const SELU_SCALE = 1.0507009873554804934193349852946; diff --git a/tfjs-master/tfjs-core/src/ops/separable_conv2d.ts b/tfjs-master/tfjs-core/src/ops/separable_conv2d.ts deleted file mode 100644 index 58b5b67ee..000000000 --- a/tfjs-master/tfjs-core/src/ops/separable_conv2d.ts +++ /dev/null @@ -1,139 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {Tensor3D, Tensor4D} from '../tensor'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; -import * as util from '../util'; - -import {conv2d} from './conv2d'; -import {depthwiseConv2d} from './depthwise_conv2d'; -import {op} from './operation'; -import {reshape} from './reshape'; - -/** - * 2-D convolution with separable filters. - * - * Performs a depthwise convolution that acts separately on channels followed - * by a pointwise convolution that mixes channels. Note that this is - * separability between dimensions [1, 2] and 3, not spatial separability - * between dimensions 1 and 2. - * - * See - * [https://www.tensorflow.org/api_docs/python/tf/nn/separable_conv2d]( - * https://www.tensorflow.org/api_docs/python/tf/nn/separable_conv2d) - * for more details. - * - * @param x The input tensor, of rank 4 or rank 3, of shape - * `[batch, height, width, inChannels]`. If rank 3, batch of 1 is - * assumed. - * @param depthwiseFilter The depthwise filter tensor, rank 4, of shape - * `[filterHeight, filterWidth, inChannels, channelMultiplier]`. This is - * the filter used in the first step. - * @param pointwiseFilter The pointwise filter tensor, rank 4, of shape - * `[1, 1, inChannels * channelMultiplier, outChannels]`. This is - * the filter used in the second step. - * @param strides The strides of the convolution: `[strideHeight, - * strideWidth]`. If strides is a single number, then `strideHeight == - * strideWidth`. - * @param pad The type of padding algorithm. - * - `same` and stride 1: output will be of same size as input, - * regardless of filter size. - * - `valid`: output will be smaller than input if filter is larger - * than 1x1. - * - For more info, see this guide: - * [https://www.tensorflow.org/api_docs/python/tf/nn/convolution]( - * https://www.tensorflow.org/api_docs/python/tf/nn/convolution) - * @param dilations The dilation rates: `[dilationHeight, dilationWidth]` - * in which we sample input values across the height and width dimensions - * in atrous convolution. Defaults to `[1, 1]`. If `rate` is a single - * number, then `dilationHeight == dilationWidth`. If it is greater than - * 1, then all values of `strides` must be 1. - * @param dataFormat: An optional string from: "NHWC", "NCHW". Defaults to - * "NHWC". Specify the data format of the input and output data. With the - * default format "NHWC", the data is stored in the order of: [batch, - * height, width, channels]. Only "NHWC" is currently supported. - * - * @doc {heading: 'Operations', subheading: 'Convolution'} - */ -function separableConv2d_( - x: T|TensorLike, depthwiseFilter: Tensor4D|TensorLike, - pointwiseFilter: Tensor4D|TensorLike, strides: [number, number]|number, - pad: 'valid'|'same', dilation: [number, number]|number = [1, 1], - dataFormat: 'NHWC'|'NCHW' = 'NHWC'): T { - const $x = convertToTensor(x, 'x', 'separableConv2d'); - const $depthwiseFilter = - convertToTensor(depthwiseFilter, 'depthwiseFilter', 'separableConv2d'); - const $pointwiseFilter = - convertToTensor(pointwiseFilter, 'pointwiseFilter', 'separableConv2d'); - - let x4D = $x as Tensor4D; - let reshapedTo4D = false; - if ($x.rank === 3) { - reshapedTo4D = true; - x4D = reshape($x, [1, $x.shape[0], $x.shape[1], $x.shape[2]]); - } - - if (dataFormat === 'NCHW') { - throw new Error( - 'separableConv2d currently does not support dataFormat NCHW; only ' + - 'NHWC is supported'); - } - - util.assert( - x4D.rank === 4, - () => `Error in separableConv2d: input must be rank 4, but got ` + - `rank ${x4D.rank}.`); - util.assert( - $depthwiseFilter.rank === 4, - () => `Error in separableConv2d: depthwise filter must be rank 4, but ` + - `got rank ${$depthwiseFilter.rank}.`); - util.assert( - $pointwiseFilter.rank === 4, - () => `Error in separableConv2d: pointwise filter must be rank 4, but ` + - `got rank ${$depthwiseFilter.rank}.`); - util.assert( - $pointwiseFilter.shape[0] === 1, - () => - `Error in separableConv2d: the first dimension of pointwise filter ` + - ` must be 1, but got ${$pointwiseFilter.shape[0]}.`); - util.assert( - $pointwiseFilter.shape[1] === 1, - () => `Error in separableConv2d: the second dimension of pointwise ` + - `filter must be 1, but got ${$pointwiseFilter.shape[1]}.`); - - const inChannels = $depthwiseFilter.shape[2]; - const channelMultiplier = $depthwiseFilter.shape[3]; - util.assert( - $pointwiseFilter.shape[2] === inChannels * channelMultiplier, - () => - `Error in separableConv2d: the third dimension of pointwise filter ` + - `must be ${inChannels * channelMultiplier}, ` + - `but got ${$pointwiseFilter.shape[2]}.`); - - const depthwise = depthwiseConv2d( - x4D, $depthwiseFilter, strides, pad, dataFormat, dilation); - const pointwiseStride = 1; - const res = - conv2d(depthwise, $pointwiseFilter, pointwiseStride, 'valid', dataFormat); - - if (reshapedTo4D) { - return reshape(res, [res.shape[1], res.shape[2], res.shape[3]]) as T; - } - return res as T; -} - -export const separableConv2d = /* @__PURE__ */ op({separableConv2d_}); diff --git a/tfjs-master/tfjs-core/src/ops/setdiff1d_async.ts b/tfjs-master/tfjs-core/src/ops/setdiff1d_async.ts deleted file mode 100644 index d69bc6b8e..000000000 --- a/tfjs-master/tfjs-core/src/ops/setdiff1d_async.ts +++ /dev/null @@ -1,89 +0,0 @@ -/** - * @license - * Copyright 2020 Google Inc. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {Tensor, TensorBuffer} from '../tensor'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; -import * as util from '../util'; - -/** - * Computes the difference between two lists of numbers. - * - * Given a Tensor `x` and a Tensor `y`, this operation returns a Tensor `out` - * that represents all values that are in `x` but not in `y`. The returned - * Tensor `out` is sorted in the same order that the numbers appear in `x` - * (duplicates are preserved). This operation also returns a Tensor indices that - * represents the position of each out element in `x`. In other words: - * - * `out[i] = x[idx[i]] for i in [0, 1, ..., out.length - 1]` - * - * ```js - * const x = [1, 2, 3, 4, 5, 6]; - * const y = [1, 3, 5]; - * - * const [out, indices] = await tf.setdiff1dAsync(x, y); - * out.print(); // [2, 4, 6] - * indices.print(); // [1, 3, 5] - * ``` - * - * @param x 1-D Tensor. Values to keep. - * @param y 1-D Tensor. Must have the same type as x. Values to exclude in the - * output. - * @returns Promise of Tensor tuple [out, indices]. - * out: Tensor with the same type as x. - * indices: A Tensor of type int32. - * - * @doc {heading: 'Tensors', subheading: 'Transformations'} - */ -async function setdiff1dAsync_( - x: Tensor|TensorLike, y: Tensor|TensorLike): Promise<[Tensor, Tensor]> { - const $x = convertToTensor(x, 'x', 'setdiff1d'); - const $y = convertToTensor(y, 'y', 'setdiff1d'); - - util.assert( - $x.dtype === $y.dtype, - () => `x and y should have the same dtype, but got x (${ - $x.dtype}) and y (${$y.dtype}).`); - - util.assert( - $x.rank === 1, () => `x should be 1D tensor, but got x (${$x.shape}).`); - - util.assert( - $y.rank === 1, () => `y should be 1D tensor, but got y (${$y.shape}).`); - - const xVals = await $x.data(); - const yVals = await $y.data(); - const ySet = new Set(yVals); - - let outputSize = 0; - for (let i = 0; i < xVals.length; i++) { - if (!ySet.has(xVals[i])) { - outputSize++; - } - } - - const buffer = new TensorBuffer([outputSize], $x.dtype); - const indices = new TensorBuffer([outputSize], 'int32'); - for (let i = 0, p = 0; i < xVals.length; i++) { - if (!ySet.has(xVals[i])) { - buffer.values[p] = xVals[i]; - indices.values[p] = i; - p++; - } - } - return [buffer.toTensor(), indices.toTensor()]; -} -export const setdiff1dAsync = setdiff1dAsync_; diff --git a/tfjs-master/tfjs-core/src/ops/setdiff1d_async_test.ts b/tfjs-master/tfjs-core/src/ops/setdiff1d_async_test.ts deleted file mode 100644 index fda13ebb2..000000000 --- a/tfjs-master/tfjs-core/src/ops/setdiff1d_async_test.ts +++ /dev/null @@ -1,106 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('setdiff1dAsync', ALL_ENVS, () => { - it('1d int32 tensor', async () => { - const x = tf.tensor1d([1, 2, 3, 4], 'int32'); - const y = tf.tensor1d([1, 2], 'int32'); - const [out, indices] = await tf.setdiff1dAsync(x, y); - expect(out.dtype).toBe('int32'); - expect(indices.dtype).toBe('int32'); - expect(out.shape).toEqual([2]); - expect(indices.shape).toEqual([2]); - expectArraysClose(await out.data(), [3, 4]); - expectArraysClose(await indices.data(), [2, 3]); - }); - - it('1d float32 tensor', async () => { - const x = tf.tensor1d([1, 2, 3, 4], 'float32'); - const y = tf.tensor1d([1, 3], 'float32'); - const [out, indices] = await tf.setdiff1dAsync(x, y); - expect(out.dtype).toBe('float32'); - expect(indices.dtype).toBe('int32'); - expect(out.shape).toEqual([2]); - expect(indices.shape).toEqual([2]); - expectArraysClose(await out.data(), [2, 4]); - expectArraysClose(await indices.data(), [1, 3]); - }); - - it('empty output', async () => { - const x = tf.tensor1d([1, 2, 3, 4], 'float32'); - const y = tf.tensor1d([1, 2, 3, 4], 'float32'); - const [out, indices] = await tf.setdiff1dAsync(x, y); - expect(out.dtype).toBe('float32'); - expect(indices.dtype).toBe('int32'); - expect(out.shape).toEqual([0]); - expect(indices.shape).toEqual([0]); - expectArraysClose(await out.data(), []); - expectArraysClose(await indices.data(), []); - }); - - it('tensor like', async () => { - const x = [1, 2, 3, 4]; - const y = [1, 3]; - const [out, indices] = await tf.setdiff1dAsync(x, y); - expect(out.dtype).toBe('float32'); - expect(indices.dtype).toBe('int32'); - expect(out.shape).toEqual([2]); - expect(indices.shape).toEqual([2]); - expectArraysClose(await out.data(), [2, 4]); - expectArraysClose(await indices.data(), [1, 3]); - }); - - it('should throw if x is not 1d', async () => { - const x = tf.tensor2d([1, 2, 3, 4], [4, 1], 'float32'); - const y = tf.tensor1d([1, 2, 3, 4], 'float32'); - try { - await tf.setdiff1dAsync(x, y); - throw new Error('The line above should have thrown an error'); - } catch (ex) { - expect(ex.message).toBe('x should be 1D tensor, but got x (4,1).'); - } - }); - - it('should throw if y is not 1d', async () => { - const x = tf.tensor1d([1, 2, 3, 4], 'float32'); - const y = tf.tensor2d([1, 2, 3, 4], [4, 1], 'float32'); - try { - await tf.setdiff1dAsync(x, y); - throw new Error('The line above should have thrown an error'); - } catch (ex) { - expect(ex.message).toBe('y should be 1D tensor, but got y (4,1).'); - } - }); - - it('should throw if x and y dtype mismatch', async () => { - const x = tf.tensor1d([1, 2, 3, 4], 'float32'); - const y = tf.tensor1d([1, 2, 3, 4], 'int32'); - try { - await tf.setdiff1dAsync(x, y); - throw new Error('The line above should have thrown an error'); - } catch (ex) { - expect(ex.message) - .toBe( - 'x and y should have the same dtype,' + - ' but got x (float32) and y (int32).'); - } - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/sigmoid.ts b/tfjs-master/tfjs-core/src/ops/sigmoid.ts deleted file mode 100644 index f1c550cd4..000000000 --- a/tfjs-master/tfjs-core/src/ops/sigmoid.ts +++ /dev/null @@ -1,46 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {Sigmoid, SigmoidInputs} from '../kernel_names'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -import {op} from './operation'; - -/** - * Computes sigmoid element-wise, `1 / (1 + exp(-x))` - * - * ```js - * const x = tf.tensor1d([0, -1, 2, -3]); - * - * x.sigmoid().print(); // or tf.sigmoid(x) - * ``` - * @param x The input tensor. - * - * @doc {heading: 'Operations', subheading: 'Basic math'} - */ -function sigmoid_(x: T|TensorLike): T { - const $x = convertToTensor(x, 'x', 'sigmoid', 'float32'); - - const inputs: SigmoidInputs = {x: $x}; - - return ENGINE.runKernel(Sigmoid, inputs as unknown as NamedTensorMap); -} -export const sigmoid = /* @__PURE__ */ op({sigmoid_}); diff --git a/tfjs-master/tfjs-core/src/ops/sigmoid_test.ts b/tfjs-master/tfjs-core/src/ops/sigmoid_test.ts deleted file mode 100644 index d5a643c13..000000000 --- a/tfjs-master/tfjs-core/src/ops/sigmoid_test.ts +++ /dev/null @@ -1,112 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('sigmoid', ALL_ENVS, () => { - it('basic', async () => { - const values = [1, -3, 2, 7, -4]; - const a = tf.tensor1d(values); - - const result = tf.sigmoid(a); - - const expected = []; - for (let i = 0; i < a.size; i++) { - expected[i] = 1 / (1 + Math.exp(-values[i])); - } - expectArraysClose(await result.data(), expected); - }); - - it('6D', async () => { - const a = tf.ones([2, 2, 2, 2, 2, 2]); - const result = tf.sigmoid(a); - - const expected = []; - for (let i = 0; i < a.size; i++) { - expected[i] = 1 / (1 + Math.exp(-1.0)); - } - expectArraysClose(await result.data(), expected); - }); - - it('propagates NaNs', async () => { - const a = tf.tensor1d([3, NaN]); - const res = tf.sigmoid(a); - expectArraysClose(await res.data(), [1 / (1 + Math.exp(-3)), NaN]); - }); - - it('gradients: Tensor1D', async () => { - const a = tf.tensor1d([1, 2, -3, 5]); - const dy = tf.tensor1d([1, 2, 3, 4]); - - const da = tf.grad(a => tf.sigmoid(a))(a, dy); - - const aVals = await a.array(); - const dyVals = await dy.array(); - const expected = []; - for (let i = 0; i < a.size; i++) { - const y = 1 / (1 + Math.exp(-aVals[i])); - expected[i] = dyVals[i] * y * (1 - y); - } - - expectArraysClose(await da.data(), expected); - }); - - it('gradient with clones', async () => { - const a = tf.tensor1d([1, 2, -3, 5]); - const dy = tf.tensor1d([1, 2, 3, 4]); - - const da = tf.grad(a => tf.sigmoid(a.clone()).clone())(a, dy); - - const aVals = await a.array(); - const dyVals = await dy.array(); - const expected = []; - for (let i = 0; i < a.size; i++) { - const y = 1 / (1 + Math.exp(-aVals[i])); - expected[i] = dyVals[i] * y * (1 - y); - } - - expectArraysClose(await da.data(), expected); - }); - - it('throws when passed a non-tensor', () => { - expect(() => tf.sigmoid({} as tf.Tensor)) - .toThrowError(/Argument 'x' passed to 'sigmoid' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const values = [1, -3, 2, 7, -4]; - const result = tf.sigmoid(values); - - const expected = []; - for (let i = 0; i < values.length; i++) { - expected[i] = 1 / (1 + Math.exp(-values[i])); - } - expectArraysClose(await result.data(), expected); - }); - - it('throws for string tensor', () => { - expect(() => tf.sigmoid('q')) - .toThrowError(/Argument 'x' passed to 'sigmoid' must be float32/); - }); - - it('throws for int32 tensor', () => { - expect(() => tf.sigmoid(tf.tensor1d([1], 'int32'))) - .toThrowError(/Argument 'x' passed to 'sigmoid' must be float32/); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/sign.ts b/tfjs-master/tfjs-core/src/ops/sign.ts deleted file mode 100644 index 0543b160c..000000000 --- a/tfjs-master/tfjs-core/src/ops/sign.ts +++ /dev/null @@ -1,44 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {Sign, SignInputs} from '../kernel_names'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -import {op} from './operation'; - -/** - * Returns an element-wise indication of the sign of a number. - * - * ```js - * const x = tf.tensor1d([.6, 1.1, -3.3, NaN, 0]); - * - * x.sign().print(); // or tf.sign(x) - * ``` - * @param x The input Tensor. - * - * @doc {heading: 'Operations', subheading: 'Basic math'} - */ -function sign_(x: T|TensorLike): T { - const $x = convertToTensor(x, 'x', 'sign'); - const inputs: SignInputs = {x: $x}; - return ENGINE.runKernel(Sign, inputs as unknown as NamedTensorMap); -} -export const sign = /* @__PURE__ */ op({sign_}); diff --git a/tfjs-master/tfjs-core/src/ops/sign_test.ts b/tfjs-master/tfjs-core/src/ops/sign_test.ts deleted file mode 100644 index 40410b3f9..000000000 --- a/tfjs-master/tfjs-core/src/ops/sign_test.ts +++ /dev/null @@ -1,93 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('sign', ALL_ENVS, () => { - it('basic', async () => { - const a = tf.tensor1d([1.5, 0, NaN, -1.4]); - const r = tf.sign(a); - expectArraysClose(await r.data(), [1, 0, 0, -1]); - }); - - it('does not propagate NaNs', async () => { - const a = tf.tensor1d([1.5, NaN, -1.4]); - const r = tf.sign(a); - expectArraysClose(await r.data(), [1, 0, -1]); - }); - - it('gradients: Scalar', async () => { - const a = tf.scalar(5.2); - const dy = tf.scalar(3); - - const gradients = tf.grad(a => tf.sign(a))(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), [0]); - }); - - it('gradient with clones', async () => { - const a = tf.scalar(5.2); - const dy = tf.scalar(3); - - const gradients = tf.grad(a => tf.sign(a.clone()).clone())(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), [0]); - }); - - it('gradients: Tensor1D', async () => { - const a = tf.tensor1d([-1.1, 2.6, 3, -5.9]); - const dy = tf.tensor1d([-1, 1, 1, -1]); - - const gradients = tf.grad(a => tf.sign(a))(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), [0, 0, 0, 0]); - }); - - it('gradients: Tensor2D', async () => { - const a = tf.tensor2d([-3, 1, 2.2, 3], [2, 2]); - const dy = tf.tensor2d([1, 2, 3, 4], [2, 2]); - - const gradients = tf.grad(a => tf.sign(a))(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), [0, 0, 0, 0]); - }); - - it('throws when passed a non-tensor', () => { - expect(() => tf.sign({} as tf.Tensor)) - .toThrowError(/Argument 'x' passed to 'sign' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const r = tf.sign([1.5, 0, NaN, -1.4]); - expectArraysClose(await r.data(), [1, 0, 0, -1]); - }); - - it('throws for string tensor', () => { - expect(() => tf.sign('q')) - .toThrowError(/Argument 'x' passed to 'sign' must be numeric/); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/signal/frame.ts b/tfjs-master/tfjs-core/src/ops/signal/frame.ts deleted file mode 100644 index 56fed2e68..000000000 --- a/tfjs-master/tfjs-core/src/ops/signal/frame.ts +++ /dev/null @@ -1,69 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Tensor, Tensor1D} from '../../tensor'; -import {concat} from '../concat'; -import {fill} from '../fill'; -import {op} from '../operation'; -import {reshape} from '../reshape'; -import {slice} from '../slice'; -import {tensor2d} from '../tensor2d'; - -/** - * Expands input into frames of frameLength. - * Slides a window size with frameStep. - * - * ```js - * tf.signal.frame([1, 2, 3], 2, 1).print(); - * ``` - * @param signal The input tensor to be expanded - * @param frameLength Length of each frame - * @param frameStep The frame hop size in samples. - * @param padEnd Whether to pad the end of signal with padValue. - * @param padValue A number to use where the input signal does - * not exist when padEnd is True. - * - * @doc {heading: 'Operations', subheading: 'Signal', namespace: 'signal'} - */ -function frame_( - signal: Tensor1D, frameLength: number, frameStep: number, padEnd = false, - padValue = 0): Tensor { - let start = 0; - const output: Tensor[] = []; - while (start + frameLength <= signal.size) { - output.push(slice(signal, start, frameLength)); - start += frameStep; - } - - if (padEnd) { - while (start < signal.size) { - const padLen = (start + frameLength) - signal.size; - const pad = concat([ - slice(signal, start, frameLength - padLen), fill([padLen], padValue) - ]); - output.push(pad); - start += frameStep; - } - } - - if (output.length === 0) { - return tensor2d([], [0, frameLength]); - } - - return reshape(concat(output), [output.length, frameLength]); -} -export const frame = /* @__PURE__ */ op({frame_}); diff --git a/tfjs-master/tfjs-core/src/ops/signal/frame_test.ts b/tfjs-master/tfjs-core/src/ops/signal/frame_test.ts deleted file mode 100644 index a4912356a..000000000 --- a/tfjs-master/tfjs-core/src/ops/signal/frame_test.ts +++ /dev/null @@ -1,124 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../../index'; -import {ALL_ENVS, describeWithFlags} from '../../jasmine_util'; -import {expectArraysClose} from '../../test_util'; - -describeWithFlags('frame', ALL_ENVS, () => { - it('3 length frames', async () => { - const input = tf.tensor1d([1, 2, 3, 4, 5]); - const frameLength = 3; - const frameStep = 1; - const output = tf.signal.frame(input, frameLength, frameStep); - expect(output.shape).toEqual([3, 3]); - expectArraysClose(await output.data(), [1, 2, 3, 2, 3, 4, 3, 4, 5]); - }); - - it('3 length frames with step 2', async () => { - const input = tf.tensor1d([1, 2, 3, 4, 5]); - const frameLength = 3; - const frameStep = 2; - const output = tf.signal.frame(input, frameLength, frameStep); - expect(output.shape).toEqual([2, 3]); - expectArraysClose(await output.data(), [1, 2, 3, 3, 4, 5]); - }); - - it('3 length frames with step 5', async () => { - const input = tf.tensor1d([1, 2, 3, 4, 5]); - const frameLength = 3; - const frameStep = 5; - const output = tf.signal.frame(input, frameLength, frameStep); - expect(output.shape).toEqual([1, 3]); - expectArraysClose(await output.data(), [1, 2, 3]); - }); - - it('Exceeding frame length', async () => { - const input = tf.tensor1d([1, 2, 3, 4, 5]); - const frameLength = 6; - const frameStep = 1; - const output = tf.signal.frame(input, frameLength, frameStep); - expect(output.shape).toEqual([0, 6]); - expectArraysClose(await output.data(), []); - }); - - it('Zero frame step', async () => { - const input = tf.tensor1d([1, 2, 3, 4, 5]); - const frameLength = 6; - const frameStep = 0; - const output = tf.signal.frame(input, frameLength, frameStep); - expect(output.shape).toEqual([0, 6]); - expectArraysClose(await output.data(), []); - }); - - it('Padding with default value', async () => { - const input = tf.tensor1d([1, 2, 3, 4, 5]); - const frameLength = 3; - const frameStep = 3; - const padEnd = true; - const output = tf.signal.frame(input, frameLength, frameStep, padEnd); - expect(output.shape).toEqual([2, 3]); - expectArraysClose(await output.data(), [1, 2, 3, 4, 5, 0]); - }); - - it('Padding with the given value', async () => { - const input = tf.tensor1d([1, 2, 3, 4, 5]); - const frameLength = 3; - const frameStep = 3; - const padEnd = true; - const padValue = 100; - const output = - tf.signal.frame(input, frameLength, frameStep, padEnd, padValue); - expect(output.shape).toEqual([2, 3]); - expectArraysClose(await output.data(), [1, 2, 3, 4, 5, 100]); - }); - - it('Padding all remaining frames with step=1', async () => { - const input = tf.tensor1d([1, 2, 3, 4, 5]); - const frameLength = 4; - const frameStep = 1; - const padEnd = true; - const output = tf.signal.frame(input, frameLength, frameStep, padEnd); - expect(output.shape).toEqual([5, 4]); - expectArraysClose( - await output.data(), - [1, 2, 3, 4, 2, 3, 4, 5, 3, 4, 5, 0, 4, 5, 0, 0, 5, 0, 0, 0]); - }); - - it('Padding all remaining frames with step=1 and given pad-value', - async () => { - const input = tf.tensor1d([1, 2, 3, 4, 5]); - const frameLength = 4; - const frameStep = 1; - const padEnd = true; - const padValue = 42; - const output = - tf.signal.frame(input, frameLength, frameStep, padEnd, padValue); - expect(output.shape).toEqual([5, 4]); - expectArraysClose( - await output.data(), - [1, 2, 3, 4, 2, 3, 4, 5, 3, 4, 5, 42, 4, 5, 42, 42, 5, 42, 42, 42]); - }); - - it('Padding all remaining frames with step=2', async () => { - const input = tf.tensor1d([1, 2, 3, 4, 5]); - const output = tf.signal.frame(input, 4, 2, true); - expect(output.shape).toEqual([3, 4]); - expectArraysClose( - await output.data(), [1, 2, 3, 4, 3, 4, 5, 0, 5, 0, 0, 0]); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/signal/hamming_window.ts b/tfjs-master/tfjs-core/src/ops/signal/hamming_window.ts deleted file mode 100644 index d0044b6fc..000000000 --- a/tfjs-master/tfjs-core/src/ops/signal/hamming_window.ts +++ /dev/null @@ -1,37 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Tensor1D} from '../../tensor'; -import {op} from '../operation'; -import {cosineWindow} from '../signal_ops_util'; - -/** - * Generate a hamming window. - * - * See: https://en.wikipedia.org/wiki/Window_function#Hann_and_Hamming_windows - * - * ```js - * tf.signal.hammingWindow(10).print(); - * ``` - * @param The length of window - * - * @doc {heading: 'Operations', subheading: 'Signal', namespace: 'signal'} - */ -function hammingWindow_(windowLength: number): Tensor1D { - return cosineWindow(windowLength, 0.54, 0.46); -} -export const hammingWindow = /* @__PURE__ */ op({hammingWindow_}); diff --git a/tfjs-master/tfjs-core/src/ops/signal/hamming_window_test.ts b/tfjs-master/tfjs-core/src/ops/signal/hamming_window_test.ts deleted file mode 100644 index 2d2f1aa30..000000000 --- a/tfjs-master/tfjs-core/src/ops/signal/hamming_window_test.ts +++ /dev/null @@ -1,48 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../../index'; -import {ALL_ENVS, describeWithFlags} from '../../jasmine_util'; -import {expectArraysClose} from '../../test_util'; - -describeWithFlags('hammingWindow', ALL_ENVS, () => { - it('length=3', async () => { - const ret = tf.signal.hammingWindow(3); - expectArraysClose(await ret.data(), [0.08, 1, 0.08]); - }); - - it('length=6', async () => { - const ret = tf.signal.hammingWindow(6); - expectArraysClose(await ret.data(), [0.08, 0.31, 0.77, 1., 0.77, 0.31]); - }); - - it('length=7', async () => { - const ret = tf.signal.hammingWindow(7); - expectArraysClose( - await ret.data(), [0.08, 0.31, 0.77, 1, 0.77, 0.31, 0.08]); - }); - - it('length=20', async () => { - const ret = tf.signal.hammingWindow(20); - expectArraysClose(await ret.data(), [ - 0.08000001, 0.10251403, 0.16785222, 0.2696188, 0.3978522, - 0.54, 0.68214786, 0.8103813, 0.9121479, 0.977486, - 1., 0.977486, 0.9121478, 0.8103812, 0.6821477, - 0.54, 0.39785212, 0.2696187, 0.16785222, 0.102514 - ]); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/signal/hann_window.ts b/tfjs-master/tfjs-core/src/ops/signal/hann_window.ts deleted file mode 100644 index 561de6237..000000000 --- a/tfjs-master/tfjs-core/src/ops/signal/hann_window.ts +++ /dev/null @@ -1,38 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Tensor1D} from '../../tensor'; -import {op} from '../operation'; -import {cosineWindow} from '../signal_ops_util'; - -/** - * Generate a Hann window. - * - * See: https://en.wikipedia.org/wiki/Window_function#Hann_and_Hamming_windows - * - * ```js - * tf.signal.hannWindow(10).print(); - * ``` - * @param The length of window - * - * @doc {heading: 'Operations', subheading: 'Signal', namespace: 'signal'} - */ -function hannWindow_(windowLength: number): Tensor1D { - return cosineWindow(windowLength, 0.5, 0.5); -} - -export const hannWindow = /* @__PURE__ */ op({hannWindow_}); diff --git a/tfjs-master/tfjs-core/src/ops/signal/hann_window_test.ts b/tfjs-master/tfjs-core/src/ops/signal/hann_window_test.ts deleted file mode 100644 index 5eb50694c..000000000 --- a/tfjs-master/tfjs-core/src/ops/signal/hann_window_test.ts +++ /dev/null @@ -1,47 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../../index'; -import {ALL_ENVS, describeWithFlags} from '../../jasmine_util'; -import {expectArraysClose} from '../../test_util'; - -describeWithFlags('hannWindow', ALL_ENVS, () => { - it('length=3', async () => { - const ret = tf.signal.hannWindow(3); - expectArraysClose(await ret.data(), [0, 1, 0]); - }); - - it('length=7', async () => { - const ret = tf.signal.hannWindow(7); - expectArraysClose(await ret.data(), [0, 0.25, 0.75, 1, 0.75, 0.25, 0]); - }); - - it('length=6', async () => { - const ret = tf.signal.hannWindow(6); - expectArraysClose(await ret.data(), [0., 0.25, 0.75, 1., 0.75, 0.25]); - }); - - it('length=20', async () => { - const ret = tf.signal.hannWindow(20); - expectArraysClose(await ret.data(), [ - 0., 0.02447176, 0.09549153, 0.20610738, 0.34549153, - 0.5, 0.65450853, 0.79389274, 0.9045085, 0.97552824, - 1., 0.97552824, 0.9045085, 0.7938925, 0.65450835, - 0.5, 0.34549144, 0.20610726, 0.09549153, 0.02447173 - ]); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/signal/stft.ts b/tfjs-master/tfjs-core/src/ops/signal/stft.ts deleted file mode 100644 index cf581a842..000000000 --- a/tfjs-master/tfjs-core/src/ops/signal/stft.ts +++ /dev/null @@ -1,54 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Tensor, Tensor1D} from '../../tensor'; -import {mul} from '../mul'; -import {op} from '../operation'; -import {enclosingPowerOfTwo} from '../signal_ops_util'; -import {rfft} from '../spectral/rfft'; - -import {frame} from './frame'; -import {hannWindow} from './hann_window'; - -/** - * Computes the Short-time Fourier Transform of signals - * See: https://en.wikipedia.org/wiki/Short-time_Fourier_transform - * - * ```js - * const input = tf.tensor1d([1, 1, 1, 1, 1]) - * tf.signal.stft(input, 3, 1).print(); - * ``` - * @param signal 1-dimensional real value tensor. - * @param frameLength The window length of samples. - * @param frameStep The number of samples to step. - * @param fftLength The size of the FFT to apply. - * @param windowFn A callable that takes a window length and returns 1-d tensor. - * - * @doc {heading: 'Operations', subheading: 'Signal', namespace: 'signal'} - */ -function stft_( - signal: Tensor1D, frameLength: number, frameStep: number, - fftLength?: number, - windowFn: (length: number) => Tensor1D = hannWindow): Tensor { - if (fftLength == null) { - fftLength = enclosingPowerOfTwo(frameLength); - } - const framedSignal = frame(signal, frameLength, frameStep); - const windowedSignal = mul(framedSignal, windowFn(frameLength)); - return rfft(windowedSignal, fftLength); -} -export const stft = /* @__PURE__ */ op({stft_}); diff --git a/tfjs-master/tfjs-core/src/ops/signal/stft_test.ts b/tfjs-master/tfjs-core/src/ops/signal/stft_test.ts deleted file mode 100644 index cde17fb8f..000000000 --- a/tfjs-master/tfjs-core/src/ops/signal/stft_test.ts +++ /dev/null @@ -1,192 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../../index'; -import {ALL_ENVS, describeWithFlags} from '../../jasmine_util'; -import {expectArraysClose} from '../../test_util'; - -describeWithFlags('stft', ALL_ENVS, () => { - it('3 length with hann window', async () => { - const input = tf.tensor1d([1, 1, 1, 1, 1]); - const frameLength = 3; - const frameStep = 1; - const output = tf.signal.stft(input, frameLength, frameStep); - expect(output.shape).toEqual([3, 3]); - expectArraysClose(await output.data(), [ - 1.0, - 0.0, - 0.0, - -1.0, - -1.0, - 0.0, - 1.0, - 0.0, - 0.0, - -1.0, - -1.0, - 0.0, - 1.0, - 0.0, - 0.0, - -1.0, - -1.0, - 0.0, - ]); - }); - - it('3 length with hann window (sequencial number)', async () => { - const input = tf.tensor1d([1, 2, 3, 4, 5]); - const frameLength = 3; - const frameStep = 1; - const output = tf.signal.stft(input, frameLength, frameStep); - expect(output.shape).toEqual([3, 3]); - expectArraysClose(await output.data(), [ - 2.0, 0.0, 0.0, -2.0, -2.0, 0.0, 3.0, 0.0, 0.0, -3.0, -3.0, 0.0, 4.0, 0.0, - 0.0, -4.0, -4.0, 0.0 - ]); - }); - - it('3 length, 2 step with hann window', async () => { - const input = tf.tensor1d([1, 1, 1, 1, 1]); - const frameLength = 3; - const frameStep = 2; - const output = tf.signal.stft(input, frameLength, frameStep); - expect(output.shape).toEqual([2, 3]); - expectArraysClose( - await output.data(), - [1.0, 0.0, 0.0, -1.0, -1.0, 0.0, 1.0, 0.0, 0.0, -1.0, -1.0, 0.0]); - }); - - it('3 fftLength, 5 frameLength, 2 step', async () => { - const input = tf.tensor1d([1, 1, 1, 1, 1, 1]); - const frameLength = 5; - const frameStep = 1; - const fftLength = 3; - const output = tf.signal.stft(input, frameLength, frameStep, fftLength); - expect(output.shape[0]).toEqual(2); - expectArraysClose( - await output.data(), - [1.5, 0.0, -0.749999, 0.433, 1.5, 0.0, -0.749999, 0.433]); - }); - - it('5 length with hann window', async () => { - const input = tf.tensor1d([1, 1, 1, 1, 1]); - const frameLength = 5; - const frameStep = 1; - const output = tf.signal.stft(input, frameLength, frameStep); - expect(output.shape).toEqual([1, 5]); - expectArraysClose( - await output.data(), - [2.0, 0.0, 0.0, -1.7071068, -1.0, 0.0, 0.0, 0.29289323, 0.0, 0.0]); - }); - - it('5 length with hann window (sequential)', async () => { - const input = tf.tensor1d([1, 2, 3, 4, 5]); - const frameLength = 5; - const frameStep = 1; - const output = tf.signal.stft(input, frameLength, frameStep); - expect(output.shape).toEqual([1, 5]); - expectArraysClose(await output.data(), [ - 6.0, 0.0, -0.70710677, -5.1213202, -3.0, 1.0, 0.70710677, 0.87867975, 0.0, - 0.0 - ]); - }); - - it('3 length with hamming window', async () => { - const input = tf.tensor1d([1, 1, 1, 1, 1]); - const frameLength = 3; - const frameStep = 1; - const fftLength = 3; - const output = tf.signal.stft( - input, frameLength, frameStep, fftLength, - (length) => tf.signal.hammingWindow(length)); - expect(output.shape).toEqual([3, 2]); - expectArraysClose(await output.data(), [ - 1.16, 0.0, -0.46, -0.79674333, 1.16, 0.0, -0.46, -0.79674333, 1.16, 0.0, - -0.46, -0.79674333 - ]); - }); - - it('3 length, 2 step with hamming window', async () => { - const input = tf.tensor1d([1, 1, 1, 1, 1]); - const frameLength = 3; - const frameStep = 2; - const fftLength = 3; - const output = tf.signal.stft( - input, frameLength, frameStep, fftLength, - (length) => tf.signal.hammingWindow(length)); - expect(output.shape).toEqual([2, 2]); - expectArraysClose( - await output.data(), - [1.16, 0.0, -0.46, -0.79674333, 1.16, 0.0, -0.46, -0.79674333]); - }); - - it('3 fftLength, 5 frameLength, 2 step with hamming window', async () => { - const input = tf.tensor1d([1, 1, 1, 1, 1, 1]); - const frameLength = 5; - const frameStep = 1; - const fftLength = 3; - const output = tf.signal.stft( - input, frameLength, frameStep, fftLength, - (length) => tf.signal.hammingWindow(length)); - expect(output.shape).toEqual([2, 2]); - expectArraysClose( - await output.data(), - [1.619999, 0.0, -0.69, 0.39837, 1.619999, 0.0, -0.69, 0.39837]); - }); - - it('5 length with hann window (sequential)', async () => { - const input = tf.tensor1d([1, 2, 3, 4, 5]); - const frameLength = 5; - const frameStep = 1; - const fftLength = 5; - const output = tf.signal.stft( - input, frameLength, frameStep, fftLength, - (length) => tf.signal.hammingWindow(length)); - expect(output.shape).toEqual([1, 3]); - expectArraysClose( - await output.data(), - [6.72, 0.0, -3.6371822, -1.1404576, 0.4771822, 0.39919350]); - }); - - it('3 length without window function', async () => { - const input = tf.tensor1d([1, 1, 1, 1, 1]); - const frameLength = 3; - const frameStep = 1; - const fftLength = 3; - const ident = (length: number) => tf.ones([length]).as1D(); - const output = - tf.signal.stft(input, frameLength, frameStep, fftLength, ident); - expect(output.shape).toEqual([3, 2]); - expectArraysClose( - await output.data(), - [3.0, 0.0, 0.0, 0.0, 3.0, 0.0, 0.0, 0.0, 3.0, 0.0, 0.0, 0.0]); - }); - - it('3 length, 2 step without window function', async () => { - const input = tf.tensor1d([1, 1, 1, 1, 1]); - const frameLength = 3; - const frameStep = 2; - const fftLength = 3; - const ident = (length: number) => tf.ones([length]).as1D(); - const output = - tf.signal.stft(input, frameLength, frameStep, fftLength, ident); - expect(output.shape).toEqual([2, 2]); - expectArraysClose( - await output.data(), [3.0, 0.0, 0.0, 0.0, 3.0, 0.0, 0.0, 0.0]); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/signal_ops_util.ts b/tfjs-master/tfjs-core/src/ops/signal_ops_util.ts deleted file mode 100644 index 15f5a2783..000000000 --- a/tfjs-master/tfjs-core/src/ops/signal_ops_util.ts +++ /dev/null @@ -1,35 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Tensor1D} from '../tensor'; -import {tensor1d} from './tensor1d'; - -export function enclosingPowerOfTwo(value: number) { - // Return 2**N for integer N such that 2**N >= value. - return Math.floor(Math.pow(2, Math.ceil(Math.log(value) / Math.log(2.0)))); -} - -export function cosineWindow( - windowLength: number, a: number, b: number): Tensor1D { - const even = 1 - windowLength % 2; - const newValues = new Float32Array(windowLength); - for (let i = 0; i < windowLength; ++i) { - const cosArg = (2.0 * Math.PI * i) / (windowLength + even - 1); - newValues[i] = a - b * Math.cos(cosArg); - } - return tensor1d(newValues, 'float32'); -} diff --git a/tfjs-master/tfjs-core/src/ops/sin.ts b/tfjs-master/tfjs-core/src/ops/sin.ts deleted file mode 100644 index 1b4e9cf10..000000000 --- a/tfjs-master/tfjs-core/src/ops/sin.ts +++ /dev/null @@ -1,46 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {Sin, SinInputs} from '../kernel_names'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -import {op} from './operation'; - -/** - * Computes sin of the input Tensor element-wise: `sin(x)` - * - * ```js - * const x = tf.tensor1d([0, Math.PI / 2, Math.PI * 3 / 4]); - * - * x.sin().print(); // or tf.sin(x) - * ``` - * @param x The input tensor. - * - * @doc {heading: 'Operations', subheading: 'Basic math'} - */ -function sin_(x: T|TensorLike): T { - const $x = convertToTensor(x, 'x', 'sin', 'float32'); - - const inputs: SinInputs = {x: $x}; - - return ENGINE.runKernel(Sin, inputs as unknown as NamedTensorMap); -} -export const sin = /* @__PURE__ */ op({sin_}); diff --git a/tfjs-master/tfjs-core/src/ops/sin_test.ts b/tfjs-master/tfjs-core/src/ops/sin_test.ts deleted file mode 100644 index 3a96e910c..000000000 --- a/tfjs-master/tfjs-core/src/ops/sin_test.ts +++ /dev/null @@ -1,117 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('sin', ALL_ENVS, () => { - it('basic', async () => { - // Covers every 1/4pi range from -4pi to 4pi. - const values = [1, 3, 4, 6, 7, 9, 10, 12, -1, -3, -4, -6, -7, -9, -10, -12]; - const a = tf.tensor1d(values); - const result = tf.sin(a); - - const expected = []; - for (let i = 0; i < a.size; i++) { - expected[i] = Math.sin(values[i]); - } - expectArraysClose(await result.data(), expected); - }); - - it('propagates NaNs', async () => { - const a = tf.tensor1d([4, NaN, 0]); - const res = tf.sin(a); - expectArraysClose(await res.data(), [Math.sin(4), NaN, Math.sin(0)]); - }); - - it('gradients: Scalar', async () => { - const a = tf.scalar(5); - const dy = tf.scalar(8); - - const gradients = tf.grad(a => tf.sin(a))(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), [8 * Math.cos(5)]); - }); - - it('gradient with clones', async () => { - const a = tf.scalar(5); - const dy = tf.scalar(8); - - const gradients = tf.grad(a => tf.sin(a.clone()).clone())(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), [8 * Math.cos(5)]); - }); - - it('gradients: Tensor1D', async () => { - const a = tf.tensor1d([-1, 2, 3, -5]); - const dy = tf.tensor1d([1, 2, 3, 4]); - - const gradients = tf.grad(a => tf.sin(a))(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose( - await gradients.data(), - [1 * Math.cos(-1), 2 * Math.cos(2), 3 * Math.cos(3), 4 * Math.cos(-5)], - 1e-1); - }); - - it('gradients: Tensor2D', async () => { - const a = tf.tensor2d([-3, 1, 2, 3], [2, 2]); - const dy = tf.tensor2d([1, 2, 3, 4], [2, 2]); - - const gradients = tf.grad(a => tf.sin(a))(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose( - await gradients.data(), - [1 * Math.cos(-3), 2 * Math.cos(1), 3 * Math.cos(2), 4 * Math.cos(3)], - 1e-1); - }); - - it('throws when passed a non-tensor', () => { - expect(() => tf.sin({} as tf.Tensor)) - .toThrowError(/Argument 'x' passed to 'sin' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const values = [1, -3, 2, 7, -4]; - const result = tf.sin(values); - - const expected = []; - for (let i = 0; i < values.length; i++) { - expected[i] = Math.sin(values[i]); - } - expectArraysClose(await result.data(), expected); - }); - - it('throws for string tensor', () => { - expect(() => tf.sin('q')) - .toThrowError(/Argument 'x' passed to 'sin' must be float32/); - }); - - it('throws for int32 tensor', () => { - expect(() => tf.sin(tf.tensor1d([1], 'int32'))) - .toThrowError(/Argument 'x' passed to 'sin' must be float32/); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/sinh.ts b/tfjs-master/tfjs-core/src/ops/sinh.ts deleted file mode 100644 index ef9f0b7d8..000000000 --- a/tfjs-master/tfjs-core/src/ops/sinh.ts +++ /dev/null @@ -1,45 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {Sinh, SinhInputs} from '../kernel_names'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -import {op} from './operation'; - -/** - * Computes hyperbolic sin of the input `tf.Tensor` element-wise: `sinh(x)` - * - * ```js - * const x = tf.tensor1d([0, 1, -1, .7]); - * - * x.sinh().print(); // or tf.sinh(x) - * ``` - * @param x The input tensor. - * - * @doc {heading: 'Operations', subheading: 'Basic math'} - */ -function sinh_(x: T|TensorLike): T { - const $x = convertToTensor(x, 'x', 'sinh'); - const inputs: SinhInputs = {x: $x}; - - return ENGINE.runKernel(Sinh, inputs as unknown as NamedTensorMap); -} -export const sinh = /* @__PURE__ */ op({sinh_}); diff --git a/tfjs-master/tfjs-core/src/ops/sinh_test.ts b/tfjs-master/tfjs-core/src/ops/sinh_test.ts deleted file mode 100644 index efd6e86b9..000000000 --- a/tfjs-master/tfjs-core/src/ops/sinh_test.ts +++ /dev/null @@ -1,119 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('sinh', ALL_ENVS, () => { - it('basic', async () => { - const values = [1, -3, 2, -1, -4]; - const a = tf.tensor1d(values); - const result = tf.sinh(a); - - const expected = []; - for (let i = 0; i < a.size; i++) { - expected[i] = Math.sinh(values[i]); - } - expectArraysClose(await result.data(), expected); - }); - - it('propagates NaNs', async () => { - const a = tf.tensor1d([4, NaN, 0]); - const res = tf.sinh(a); - expectArraysClose(await res.data(), [Math.sinh(4), NaN, Math.sinh(0)]); - }); - - it('gradients: Scalar', async () => { - const a = tf.scalar(0.5); - const dy = tf.scalar(8); - - const gradients = tf.grad(a => tf.sinh(a))(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), [8 * Math.cosh(0.5)]); - }); - - it('gradient with clones', async () => { - const a = tf.scalar(0.5); - const dy = tf.scalar(8); - - const gradients = tf.grad(a => tf.sinh(a.clone()).clone())(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), [8 * Math.cosh(0.5)]); - }); - - it('gradients: Tensor1D', async () => { - const aValues = [-1, 2, 3, -5]; - const dyValues = [1, 2, 3, 4]; - const a = tf.tensor1d(aValues); - const dy = tf.tensor1d(dyValues); - - const gradients = tf.grad(a => tf.sinh(a))(a, dy); - - const expected = []; - for (let i = 0; i < a.size; i++) { - expected[i] = dyValues[i] * Math.cosh(aValues[i]); - } - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), expected); - }); - - it('gradients: Tensor2D', async () => { - const aValues = [-3, 1, 2, 3]; - const dyValues = [1, 2, 3, 4]; - const a = tf.tensor2d(aValues, [2, 2]); - const dy = tf.tensor2d(dyValues, [2, 2]); - - const gradients = tf.grad(a => tf.sinh(a))(a, dy); - - const expected = []; - for (let i = 0; i < a.size; i++) { - expected[i] = dyValues[i] * Math.cosh(aValues[i]); - } - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), expected); - }); - - it('throws when passed a non-tensor', () => { - expect(() => tf.sinh({} as tf.Tensor)) - .toThrowError(/Argument 'x' passed to 'sinh' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const values = [1, -3, 2, -1, -4]; - const result = tf.sinh(values); - - const expected = []; - for (let i = 0; i < values.length; i++) { - expected[i] = Math.sinh(values[i]); - } - expectArraysClose(await result.data(), expected); - }); - - it('throws for string tensor', () => { - expect(() => tf.sinh('q')) - .toThrowError(/Argument 'x' passed to 'sinh' must be numeric/); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/slice.ts b/tfjs-master/tfjs-core/src/ops/slice.ts deleted file mode 100644 index cf5e4d3b5..000000000 --- a/tfjs-master/tfjs-core/src/ops/slice.ts +++ /dev/null @@ -1,78 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {Slice, SliceAttrs, SliceInputs} from '../kernel_names'; -import {NamedAttrMap} from '../kernel_registry'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {Rank, TensorLike} from '../types'; - -import {op} from './operation'; - -/** - * Extracts a slice from a `tf.Tensor` starting at coordinates `begin` - * and is of size `size`. - * - * Also available are stricter rank-specific methods with the same signature - * as this method that assert that `x` is of the given rank: - * - `tf.slice1d` - * - `tf.slice2d` - * - `tf.slice3d` - * - `tf.slice4d` - * - * ```js - * const x = tf.tensor1d([1, 2, 3, 4]); - * - * x.slice([1], [2]).print(); - * ``` - * - * ```js - * const x = tf.tensor2d([1, 2, 3, 4], [2, 2]); - * - * x.slice([1, 0], [1, 2]).print(); - * ``` - * @param x The input `tf.Tensor` to slice from. - * @param begin The coordinates to start the slice from. The length can be - * less than the rank of x - the rest of the axes will have implicit 0 as - * start. Can also be a single number, in which case it specifies the - * first axis. - * @param size The size of the slice. The length can be less than the rank of - * x - the rest of the axes will have implicit -1. A value of -1 requests - * the rest of the dimensions in the axis. Can also be a single number, - * in which case it specifies the size of the first axis. - * - * @doc {heading: 'Tensors', subheading: 'Slicing and Joining'} - */ -function slice_>( - x: T|TensorLike, begin: number|number[], size?: number|number[]): T { - const $x = convertToTensor(x, 'x', 'slice', 'string_or_numeric'); - - if ($x.rank === 0) { - throw new Error('Slicing scalar is not possible'); - } - - const inputs: SliceInputs = {x: $x}; - const attrs: SliceAttrs = {begin, size}; - - return ENGINE.runKernel( - Slice, inputs as unknown as NamedTensorMap, - attrs as unknown as NamedAttrMap); -} - -export const slice = /* @__PURE__ */ op({slice_}); diff --git a/tfjs-master/tfjs-core/src/ops/slice1d.ts b/tfjs-master/tfjs-core/src/ops/slice1d.ts deleted file mode 100644 index 358489e36..000000000 --- a/tfjs-master/tfjs-core/src/ops/slice1d.ts +++ /dev/null @@ -1,39 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Tensor1D} from '../tensor'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; -import * as util from '../util'; - -import {op} from './operation'; -import {slice} from './slice'; - -/** - * Extracts a 1D slice from 1D array starting at coordinates `begin` and is - * of length `size`. See `slice` for details. - */ -function slice1d_( - x: Tensor1D|TensorLike, begin: number, size: number): Tensor1D { - const $x = convertToTensor(x, 'x', 'slice1d'); - util.assert( - $x.rank === 1, - () => - `slice1d expects a rank-1 tensor, but got a rank-${$x.rank} tensor`); - return slice($x, [begin], [size]); -} -export const slice1d = /* @__PURE__ */ op({slice1d_}); diff --git a/tfjs-master/tfjs-core/src/ops/slice1d_test.ts b/tfjs-master/tfjs-core/src/ops/slice1d_test.ts deleted file mode 100644 index 156d41b1a..000000000 --- a/tfjs-master/tfjs-core/src/ops/slice1d_test.ts +++ /dev/null @@ -1,70 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('slice1d', ALL_ENVS, () => { - it('slices 1x1 into 1x1 (effectively a copy)', async () => { - const a = tf.tensor1d([5]); - const result = tf.slice1d(a, 0, 1); - - expect(result.shape).toEqual([1]); - expectArraysClose(await result.data(), 5); - }); - - it('slices 5x1 into shape 2x1 starting at 3', async () => { - const a = tf.tensor1d([1, 2, 3, 4, 5]); - const result = tf.slice1d(a, 3, 2); - - expect(result.shape).toEqual([2]); - expectArraysClose(await result.data(), [4, 5]); - }); - - it('slices 5x1 into shape 3x1 starting at 1', async () => { - const a = tf.tensor1d([1, 2, 3, 4, 5]); - const result = tf.slice1d(a, 1, 3); - - expect(result.shape).toEqual([3]); - expectArraysClose(await result.data(), [2, 3, 4]); - }); - - it('grad', async () => { - const a = tf.tensor1d([1, 2, 3, 4, 5]); - const dy = tf.tensor1d([10, 100]); - const da = tf.grad((a: tf.Tensor1D) => tf.slice1d(a, 1, 2))(a, dy); - expect(da.shape).toEqual([5]); - expectArraysClose(await da.data(), [0, 10, 100, 0, 0]); - }); - - it('gradient with clones', async () => { - const a = tf.tensor1d([1, 2, 3, 4, 5]); - const dy = tf.tensor1d([10, 100]); - const da = - tf.grad((a: tf.Tensor1D) => tf.slice1d(a.clone(), 1, 2).clone())(a, dy); - expect(da.shape).toEqual([5]); - expectArraysClose(await da.data(), [0, 10, 100, 0, 0]); - }); - - it('accepts a tensor-like object', async () => { - const a = [5]; - const result = tf.slice1d(a, 0, 1); - expect(result.shape).toEqual([1]); - expectArraysClose(await result.data(), 5); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/slice2d.ts b/tfjs-master/tfjs-core/src/ops/slice2d.ts deleted file mode 100644 index bb3d2369a..000000000 --- a/tfjs-master/tfjs-core/src/ops/slice2d.ts +++ /dev/null @@ -1,40 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Tensor2D} from '../tensor'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; -import * as util from '../util'; - -import {op} from './operation'; -import {slice} from './slice'; - -/** - * Extracts a 2D slice from a 2D array starting at coordinates `begin` and - * is of size `size`. See `slice` for details. - */ -function slice2d_( - x: Tensor2D|TensorLike, begin: [number, number], - size: [number, number]): Tensor2D { - const $x = convertToTensor(x, 'x', 'slice2d'); - util.assert( - $x.rank === 2, - () => - `slice2d expects a rank-2 tensor, but got a rank-${$x.rank} tensor`); - return slice($x, begin, size); -} -export const slice2d = /* @__PURE__ */ op({slice2d_}); diff --git a/tfjs-master/tfjs-core/src/ops/slice2d_test.ts b/tfjs-master/tfjs-core/src/ops/slice2d_test.ts deleted file mode 100644 index 4f963645d..000000000 --- a/tfjs-master/tfjs-core/src/ops/slice2d_test.ts +++ /dev/null @@ -1,227 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; -import {Rank} from '../types'; - -describeWithFlags('slice2d', ALL_ENVS, () => { - it('slicing a 1x1 from a 1x1 returns a 1x1', () => { - const a = tf.tensor2d([0], [1, 1]); - const b = tf.slice2d(a, [0, 0], [1, 1]); - expect(b.shape).toEqual([1, 1]); - }); - - it('returns a tensor of slice size', () => { - const a = tf.zeros([100, 100]); - const b = tf.slice2d(a, [0, 0], [12, 34]); - expect(b.shape).toEqual([12, 34]); - }); - - it('returns the upper-left submatrix when begin is [0, 0]', async () => { - const a = tf.randomUniform([10, 10], -1, 1); - const b = tf.slice2d(a, [0, 0], [2, 2]); - const aValues = await a.data(); - - expectArraysClose( - await b.data(), [aValues[0], aValues[1], aValues[10], aValues[11]]); - }); - - it('returns the rectangle specified', async () => { - const a = tf.tensor2d([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [4, 3]); - const b = tf.slice2d(a, [1, 1], [3, 2]); - - expectArraysClose(await b.data(), [5, 6, 8, 9, 11, 12]); - }); - - it('throws when requesting out of bounds slice', () => { - const a = tf.tensor2d([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [4, 3]); - expect(() => tf.slice2d(a, [1, 1], [10, 10])).toThrowError(); - }); - - it('grad', async () => { - const a = tf.tensor2d([[1, 2, 3], [4, 5, 6]]); - const dy = tf.tensor2d([[20], [50]]); - const da = - tf.grad((x: tf.Tensor2D) => tf.slice2d(a, [0, 1], [2, 1]))(a, dy); - expect(da.shape).toEqual([2, 3]); - expectArraysClose(await da.data(), [0, 20, 0, 0, 50, 0]); - }); - - it('accepts a tensor-like object', () => { - const a = [[0]]; // 1x1 - const b = tf.slice2d(a, [0, 0], [1, 1]); - expect(b.shape).toEqual([1, 1]); - }); - - it('slice an already sliced tensor, first was not continous', async () => { - const a = [ - [1, 2, 3, 4], - [5, 6, 7, 8], - [9, 10, 11, 12], - ]; // 3x4. - const b = tf.slice(a, [0, 1]); - const c = tf.slice(b, [1, 1], [1, 1]); - expect(c.shape).toEqual([1, 1]); - expectArraysClose(await c.data(), [7]); - }); - - it('slice an already sliced tensor, first was continous', async () => { - const a = [ - [1, 2, 3, 4], - [5, 6, 7, 8], - [9, 10, 11, 12], - ]; // 3x4. - const b = tf.slice(a, [1, 0]); - const c = tf.slice(b, [1, 0]); - expect(c.shape).toEqual([1, 4]); - expectArraysClose(await c.data(), [9, 10, 11, 12]); - }); - - it('slice an already sliced tensor and do async read', async () => { - const a = [ - [1, 2, 3, 4], - [5, 6, 7, 8], - [9, 10, 11, 12], - ]; // 3x4. - const b = tf.slice(a, [0, 1]); - const c = tf.slice(b, [1, 1], [1, 1]); - expect(c.shape).toEqual([1, 1]); - expectArraysClose(await c.data(), new Float32Array([7])); - }); - - it('square a sliced texture, followed by non-sliced texture of same shape', - async () => { // Tests collisions in the shader cache. - // Make a 2x3 tensor, upload to gpu and reshape to 3x2. - const input = tf.tensor([[1, 2, 3], [4, 5, 6]]).abs().as2D(3, 2); - const slicedInput = tf.slice(input, [0, 0], [3, 2]); - // First square program takes the sliced input. - const a = slicedInput.square(); - expectArraysClose(await a.data(), [1, 4, 9, 16, 25, 36]); - // Second square program takes the non-sliced input. - const b = tf.square(input); - expectArraysClose(await b.data(), [1, 4, 9, 16, 25, 36]); - }); - - it('square a non-sliced texture, followed by a sliced texture of same shape', - async () => { // Tests collisions in the shader cache. - // Make a 2x3 tensor, upload to gpu and reshape to 3x2. - const input = tf.tensor([[1, 2, 3], [4, 5, 6]]).abs().as2D(3, 2); - // Make a sliced version of the same tensor with the same shape. - const slicedInput = tf.slice(input, [0, 0], [3, 2]); - // First square program takes the non-sliced input. - const a = input.square(); - expectArraysClose(await a.data(), [1, 4, 9, 16, 25, 36]); - // Second square program takes the sliced input. - const b = tf.square(slicedInput); - expectArraysClose(await b.data(), [1, 4, 9, 16, 25, 36]); - }); - - it('slice a tensor and do async read', async () => { - const a = [ - [1, 2, 3, 4], - [5, 6, 7, 8], - [9, 10, 11, 12], - ]; // 3x4. - const b = tf.slice(a, [0, 1], [3, 2]); - expect(b.shape).toEqual([3, 2]); - const vals = await b.data(); - expectArraysClose(vals, new Float32Array([2, 3, 6, 7, 10, 11])); - }); - - it('flatten a sliced tensor that was continuous in memory', async () => { - const a = [ - [1, 2, 3, 4], - [5, 6, 7, 8], - [9, 10, 11, 12], - ]; // 3x4. - const b = tf.slice(a, [1, 0]).flatten(); - expect(b.shape).toEqual([8]); - expectArraysClose(await b.data(), [5, 6, 7, 8, 9, 10, 11, 12]); - }); - - it('slice a tensor that was not continuous in memory', async () => { - const a = [ - [1, 2, 3, 4], - [5, 6, 7, 8], - [9, 10, 11, 12], - ]; // 3x4. - const b = tf.slice(a, [0, 1]); - expect(b.shape).toEqual([3, 3]); - expectArraysClose(await b.data(), [2, 3, 4, 6, 7, 8, 10, 11, 12]); - }); - - it('flatten a sliced tensor that was not continuous in memory', async () => { - const a = [ - [1, 2, 3, 4], - [5, 6, 7, 8], - [9, 10, 11, 12], - ]; // 3x4. - const b = tf.slice(a, [0, 1]).flatten(); - expect(b.shape).toEqual([9]); - expectArraysClose(await b.data(), [2, 3, 4, 6, 7, 8, 10, 11, 12]); - }); - - it('flatten a sliced tensor not continuous in memory and run program', - async () => { - const a = [ - [1, 2, 3, 4], - [5, 6, 7, 8], - [9, 10, 11, 12], - ]; // 3x4. - const b = tf.slice(a, [0, 1]).flatten(); - const c = tf.square(b); - expectArraysClose(await c.data(), [4, 9, 16, 36, 49, 64, 100, 121, 144]); - }); - - it('reshape a sliced 1d into a 2d tensor', async () => { - const a = [1, 2, 3, 4, 5]; - const b = tf.slice(a, 1).as2D(2, 2); - expect(b.shape).toEqual([2, 2]); - expectArraysClose(await b.data(), [2, 3, 4, 5]); - }); - - it('reshape a sliced 1d into a 2d tensor and run program', async () => { - const a = [1, 2, 3, 4, 5]; - const b = tf.slice(a, 1).as2D(2, 2).square(); - expect(b.shape).toEqual([2, 2]); - expectArraysClose(await b.data(), [4, 9, 16, 25]); - }); - - it('broadcast the original with the sliced tensor', async () => { - const a = [[1, 2], [3, 4]]; - const b = tf.slice(a, [0, 1]); - const c = tf.add(a, b); - expect(c.shape).toEqual([2, 2]); - expectArraysClose(await c.data(), [3, 4, 7, 8]); - }); - - it('zero-sized slice out of a non-zero sized tensor', async () => { - const a = tf.zeros([4, 2]); - const res = tf.slice(a, [0, 0], [0, 2]); - expect(res.shape).toEqual([0, 2]); - expectArraysClose(await res.data(), []); - }); - - it('zero-sized slice out of a zero-sized tensor', async () => { - const a = tf.zeros([0, 4]); - const res = tf.slice(a, [0, 1], [0, 3]); - expect(res.shape).toEqual([0, 3]); - expectArraysClose(await res.data(), []); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/slice3d.ts b/tfjs-master/tfjs-core/src/ops/slice3d.ts deleted file mode 100644 index 73c39acc7..000000000 --- a/tfjs-master/tfjs-core/src/ops/slice3d.ts +++ /dev/null @@ -1,40 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Tensor3D} from '../tensor'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; -import * as util from '../util'; - -import {op} from './operation'; -import {slice} from './slice'; - -/** - * Extracts a 3D slice from a 3D array starting at coordinates `begin` and - * is of size `size`. See `slice` for details. - */ -function slice3d_( - x: Tensor3D|TensorLike, begin: [number, number, number], - size: [number, number, number]): Tensor3D { - const $x = convertToTensor(x, 'x', 'slice3d'); - util.assert( - $x.rank === 3, - () => - `slice3d expects a rank-3 tensor, but got a rank-${$x.rank} tensor`); - return slice($x, begin, size); -} -export const slice3d = /* @__PURE__ */ op({slice3d_}); diff --git a/tfjs-master/tfjs-core/src/ops/slice3d_test.ts b/tfjs-master/tfjs-core/src/ops/slice3d_test.ts deleted file mode 100644 index ca38dccb6..000000000 --- a/tfjs-master/tfjs-core/src/ops/slice3d_test.ts +++ /dev/null @@ -1,54 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('slice3d', ALL_ENVS, () => { - it('slices 1x1x1 into shape 1x1x1 (effectively a copy)', async () => { - const a = tf.tensor3d([[[5]]], [1, 1, 1]); - const result = tf.slice3d(a, [0, 0, 0], [1, 1, 1]); - - expect(result.shape).toEqual([1, 1, 1]); - expectArraysClose(await result.data(), [5]); - }); - - it('slices 2x2x2 array into 1x2x2 starting at [1, 0, 0]', async () => { - const a = tf.tensor3d([1, 2, 3, 4, 5, 6, 7, 8], [2, 2, 2]); - const result = tf.slice3d(a, [1, 0, 0], [1, 2, 2]); - - expect(result.shape).toEqual([1, 2, 2]); - expectArraysClose(await result.data(), [5, 6, 7, 8]); - }); - - it('slices 2x2x2 array into 2x1x1 starting at [0, 1, 1]', async () => { - const a = tf.tensor3d([1, 2, 3, 4, 5, 6, 7, 8], [2, 2, 2]); - const result = tf.slice3d(a, [0, 1, 1], [2, 1, 1]); - - expect(result.shape).toEqual([2, 1, 1]); - expectArraysClose(await result.data(), [4, 8]); - }); - - it('accepts a tensor-like object', async () => { - const a = [[[5]]]; // 1x1x1 - const result = tf.slice3d(a, [0, 0, 0], [1, 1, 1]); - - expect(result.shape).toEqual([1, 1, 1]); - expectArraysClose(await result.data(), [5]); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/slice4d.ts b/tfjs-master/tfjs-core/src/ops/slice4d.ts deleted file mode 100644 index cb50be36e..000000000 --- a/tfjs-master/tfjs-core/src/ops/slice4d.ts +++ /dev/null @@ -1,40 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Tensor4D} from '../tensor'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; -import * as util from '../util'; - -import {op} from './operation'; -import {slice} from './slice'; - -/** - * Extracts a 4D slice from a 4D array starting at coordinates `begin` and - * is of size `size`. See `slice` for details. - */ -function slice4d_( - x: Tensor4D|TensorLike, begin: [number, number, number, number], - size: [number, number, number, number]): Tensor4D { - const $x = convertToTensor(x, 'x', 'slice4d'); - util.assert( - $x.rank === 4, - () => - `slice4d expects a rank-4 tensor, but got a rank-${$x.rank} tensor`); - return slice($x, begin, size); -} -export const slice4d = /* @__PURE__ */ op({slice4d_}); diff --git a/tfjs-master/tfjs-core/src/ops/slice4d_test.ts b/tfjs-master/tfjs-core/src/ops/slice4d_test.ts deleted file mode 100644 index be36a7c3c..000000000 --- a/tfjs-master/tfjs-core/src/ops/slice4d_test.ts +++ /dev/null @@ -1,58 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('slice4d', ALL_ENVS, () => { - it('slices 1x1x1x1 into shape 1x1x1x1 (effectively a copy)', async () => { - const a = tf.tensor4d([[[[5]]]], [1, 1, 1, 1]); - const result = tf.slice4d(a, [0, 0, 0, 0], [1, 1, 1, 1]); - - expect(result.shape).toEqual([1, 1, 1, 1]); - expectArraysClose(await result.data(), [5]); - }); - - it('slices 2x2x2x2 array into 1x2x2x2 starting at [1, 0, 0, 0]', async () => { - const a = tf.tensor4d( - [1, 2, 3, 4, 5, 6, 7, 8, 11, 22, 33, 44, 55, 66, 77, 88], - [2, 2, 2, 2], - ); - const result = tf.slice4d(a, [1, 0, 0, 0], [1, 2, 2, 2]); - - expect(result.shape).toEqual([1, 2, 2, 2]); - expectArraysClose(await result.data(), [11, 22, 33, 44, 55, 66, 77, 88]); - }); - - it('slices 2x2x2x2 array into 2x1x1x1 starting at [0, 1, 1, 1]', async () => { - const a = tf.tensor4d( - [1, 2, 3, 4, 5, 6, 7, 8, 11, 22, 33, 44, 55, 66, 77, 88], [2, 2, 2, 2]); - const result = tf.slice4d(a, [0, 1, 1, 1], [2, 1, 1, 1]); - - expect(result.shape).toEqual([2, 1, 1, 1]); - expectArraysClose(await result.data(), [8, 88]); - }); - - it('accepts a tensor-like object', async () => { - const a = [[[[5]]]]; // 1x1x1x1 - const result = tf.slice4d(a, [0, 0, 0, 0], [1, 1, 1, 1]); - - expect(result.shape).toEqual([1, 1, 1, 1]); - expectArraysClose(await result.data(), [5]); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/slice_test.ts b/tfjs-master/tfjs-core/src/ops/slice_test.ts deleted file mode 100644 index a98ec45ea..000000000 --- a/tfjs-master/tfjs-core/src/ops/slice_test.ts +++ /dev/null @@ -1,267 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags, SYNC_BACKEND_ENVS} from '../jasmine_util'; -import {encodeStrings, expectArraysClose} from '../test_util'; -import {TensorLike1D} from '../types'; - -describeWithFlags('slice ', ALL_ENVS, () => { - describeWithFlags('ergonomics', ALL_ENVS, () => { - it('slices 2x2x2 array into 2x1x1 no size', async () => { - const a = tf.tensor3d([1, 2, 3, 4, 5, 6, 7, 8], [2, 2, 2]); - const result = a.slice([0, 1, 1]); - expect(result.shape).toEqual([2, 1, 1]); - expectArraysClose(await result.data(), [4, 8]); - }); - - it('slices 2x2x2 array into 1x2x2 with scalar begin no size', async () => { - const a = tf.tensor3d([1, 2, 3, 4, 5, 6, 7, 8], [2, 2, 2]); - const result = a.slice(1); - expect(result.shape).toEqual([1, 2, 2]); - expectArraysClose(await result.data(), [5, 6, 7, 8]); - }); - - it('slices 2x2x2 array using 2d size and 2d size', async () => { - const a = tf.tensor3d([1, 2, 3, 4, 5, 6, 7, 8], [2, 2, 2]); - const result = a.slice([0, 1]); - expect(result.shape).toEqual([2, 1, 2]); - expectArraysClose(await result.data(), [3, 4, 7, 8]); - }); - - it('slices 2x2x2 array using negative size', async () => { - const a = tf.tensor3d([1, 2, 3, 4, 5, 6, 7, 8], [2, 2, 2]); - const result = a.slice([0, 1], [-1, 1]); - expect(result.shape).toEqual([2, 1, 2]); - expectArraysClose(await result.data(), [3, 4, 7, 8]); - }); - - it('slices 2x2x2 array using 1d size', async () => { - const a = tf.tensor3d([1, 2, 3, 4, 5, 6, 7, 8], [2, 2, 2]); - const result = a.slice(0, 1); - expect(result.shape).toEqual([1, 2, 2]); - expectArraysClose(await result.data(), [1, 2, 3, 4]); - }); - - it('throws when passed a non-tensor', () => { - expect(() => tf.slice({} as tf.Tensor, 0, 0)) - .toThrowError(/Argument 'x' passed to 'slice' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const a = [[[1, 2], [3, 4]], [[5, 6], [7, 8]]]; // 2x2x2 - const result = tf.slice(a, [0, 1, 1]); - expect(result.shape).toEqual([2, 1, 1]); - expectArraysClose(await result.data(), [4, 8]); - }); - - it('should match source tensor dtype', () => { - const a = tf.tensor1d([1, 2, 3, 4, 5], 'int32'); - const b = a.asType('float32'); - - expect(tf.slice(b, 0).dtype).toEqual('float32'); - }); - - it('throws when begin is negative', async () => { - const a = [[1, 2], [3, 4]]; // 2x2 - expect(() => tf.slice(a, [-1, 1], [ - 1, 1 - ])).toThrowError(/slice\(\) does not support negative begin indexing./); - }); - }); - - describeWithFlags('shallow slicing', ALL_ENVS, () => { - it('shallow slice an input that was cast', async () => { - const a = tf.tensor([[1, 2], [3, 4]], [2, 2], 'int32'); - const b = a.toFloat(); - const c = b.slice(1, 1); - expect(c.dtype).toBe('float32'); - expect(c.shape).toEqual([1, 2]); - expectArraysClose(await c.data(), [3, 4]); - }); - - it('delayed async read of sliced tensor has no mem leak', async () => { - const a = tf.zeros([10]); - const b = tf.slice(a, 0, 1); - const nBefore = tf.memory().numTensors; - expect(nBefore).toBe(2); - await b.data(); - const nAfter = tf.memory().numTensors; - expect(nAfter).toBe(2); - tf.dispose([a, b]); - expect(tf.memory().numTensors).toBe(0); - }); - }); - - describeWithFlags('shallow slicing', SYNC_BACKEND_ENVS, () => { - it('delayed sync read of sliced tensor has no mem leak', () => { - const a = tf.zeros([10]); - const b = tf.slice(a, 0, 1); - const nBefore = tf.memory().numTensors; - expect(nBefore).toBe(2); - b.dataSync(); - const nAfter = tf.memory().numTensors; - expect(nAfter).toBe(2); - tf.dispose([a, b]); - expect(tf.memory().numTensors).toBe(0); - }); - }); - - describeWithFlags('slice5d', ALL_ENVS, () => { - it('slices 1x1x1x1x1 into shape 1x1x1x1x1 (effectively a copy)', - async () => { - const a = tf.tensor5d([[[[[5]]]]], [1, 1, 1, 1, 1]); - const result = tf.slice(a, [0, 0, 0, 0, 0], [1, 1, 1, 1, 1]); - - expect(result.shape).toEqual([1, 1, 1, 1, 1]); - expectArraysClose(await result.data(), [5]); - }); - - it('slices 2x2x2x2x2 array into 1x2x2x2x2 starting at [1,0,0,0,0]', - async () => { - const a = tf.tensor5d( - [ - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, - 12, 13, 14, 15, 16, 11, 22, 33, 44, 55, 66, - 77, 88, 111, 222, 333, 444, 555, 666, 777, 888 - ], - [2, 2, 2, 2, 2]); - const result = tf.slice(a, [1, 0, 0, 0, 0], [1, 2, 2, 2, 2]); - - expect(result.shape).toEqual([1, 2, 2, 2, 2]); - expectArraysClose(await result.data(), [ - 11, 22, 33, 44, 55, 66, 77, 88, 111, 222, 333, 444, 555, 666, 777, - 888 - ]); - }); - - it('slices 2x2x2x2x2 array into 2x1x1x1x1 starting at [0,1,1,1,1]', - async () => { - const a = tf.tensor5d( - [ - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, - 12, 13, 14, 15, 16, 11, 22, 33, 44, 55, 66, - 77, 88, 111, 222, 333, 444, 555, 666, 777, 888 - ], - [2, 2, 2, 2, 2]); - const result = tf.slice(a, [0, 1, 1, 1, 1], [2, 1, 1, 1, 1]); - - expect(result.shape).toEqual([2, 1, 1, 1, 1]); - expectArraysClose(await result.data(), [16, 888]); - }); - - it('accepts a tensor-like object', async () => { - const a = [[[[[5]]]]]; // 1x1x1x1x1 - const result = tf.slice(a, [0, 0, 0, 0, 0], [1, 1, 1, 1, 1]); - - expect(result.shape).toEqual([1, 1, 1, 1, 1]); - expectArraysClose(await result.data(), [5]); - }); - }); - - describeWithFlags('slice6d', ALL_ENVS, () => { - it('slices 1x1x1x1x1x1 into shape 1x1x1x1x1x1 (effectively a copy)', - async () => { - const a = tf.tensor6d([[[[[[5]]]]]], [1, 1, 1, 1, 1, 1]); - const result = tf.slice(a, [0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1]); - - expect(result.shape).toEqual([1, 1, 1, 1, 1, 1]); - expectArraysClose(await result.data(), [5]); - }); - - it('slices 2x2x2x2x2x2 array into 1x2x2x2x2x2 starting at [1,0,0,0,0,0]', - async () => { - const a = tf.tensor6d( - [ - 31, 32, 33, 34, 35, 36, 37, 38, 39, 310, 311, - 312, 313, 314, 315, 316, 311, 322, 333, 344, 355, 366, - 377, 388, 3111, 3222, 3333, 3444, 3555, 3666, 3777, 3888, - - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, - 12, 13, 14, 15, 16, 11, 22, 33, 44, 55, 66, - 77, 88, 111, 222, 333, 444, 555, 666, 777, 888 - ], - [2, 2, 2, 2, 2, 2]); - const result = tf.slice(a, [1, 0, 0, 0, 0, 0], [1, 2, 2, 2, 2, 2]); - - expect(result.shape).toEqual([1, 2, 2, 2, 2, 2]); - expectArraysClose(await result.data(), [ - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, - 12, 13, 14, 15, 16, 11, 22, 33, 44, 55, 66, - 77, 88, 111, 222, 333, 444, 555, 666, 777, 888 - ]); - }); - - it('slices 2x2x2x2x2x2 array into 2x1x1x1x1x1 starting at [0,1,1,1,1,1]', - async () => { - const a = tf.tensor6d( - [ - 31, 32, 33, 34, 35, 36, 37, 38, 39, 310, 311, - 312, 313, 314, 315, 316, 311, 322, 333, 344, 355, 366, - 377, 388, 3111, 3222, 3333, 3444, 3555, 3666, 3777, 3888, - - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, - 12, 13, 14, 15, 16, 11, 22, 33, 44, 55, 66, - 77, 88, 111, 222, 333, 444, 555, 666, 777, 888 - ], - [2, 2, 2, 2, 2, 2]); - const result = tf.slice(a, [0, 1, 1, 1, 1, 1], [2, 1, 1, 1, 1, 1]); - - expect(result.shape).toEqual([2, 1, 1, 1, 1, 1]); - expectArraysClose(await result.data(), [3888, 888]); - }); - - it('accepts a tensor-like object', async () => { - const a = [[[[[[5]]]]]]; // 1x1x1x1x1x1 - const result = tf.slice(a, [0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1]); - - expect(result.shape).toEqual([1, 1, 1, 1, 1, 1]); - expectArraysClose(await result.data(), [5]); - }); - }); - - describeWithFlags('accepts string', ALL_ENVS, () => { - it('slices 2x2x2 array into 2x1x1 no size.', async () => { - const a = tf.tensor3d( - ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight'], - [2, 2, 2], 'string'); - const result = a.slice([0, 1, 1]); - expect(result.shape).toEqual([2, 1, 1]); - expectArraysClose(await result.data(), ['four', 'eight']); - }); - - it('slices 2x2x2 array into 1x2x2 with scalar begin no size.', async () => { - const a = tf.tensor3d( - ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight'], - [2, 2, 2]); - const result = a.slice(1); - expect(result.shape).toEqual([1, 2, 2]); - expectArraysClose(await result.data(), ['five', 'six', 'seven', 'eight']); - }); - - it('slice encoded string.', async () => { - const bytes = - encodeStrings([ - 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight' - ]) as TensorLike1D; - const a = tf.tensor3d(bytes, [2, 2, 2], 'string'); - const result = a.slice([0, 1, 1]); - expect(result.shape).toEqual([2, 1, 1]); - expectArraysClose(await result.data(), ['four', 'eight']); - }); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/slice_util.ts b/tfjs-master/tfjs-core/src/ops/slice_util.ts deleted file mode 100644 index d50c79992..000000000 --- a/tfjs-master/tfjs-core/src/ops/slice_util.ts +++ /dev/null @@ -1,720 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import { TensorInfo } from '../tensor_info'; -import * as util from '../util'; - -const NEW_AXIS = -2; -const SHRINK_AXIS = -1; - -// Sparse slicing specification -// if one does foo[3:5, ..., -3], the begin, end and strides will have length -// of 3. -interface StridedSliceSparseSpec { - dims: number; - numAddAxisAfterEllipsis: number; - begin: number[]; - end: number[]; - strides: number[]; - beginMask: number; - endMask: number; - ellipsisMask: number; - newAxisMask: number; - shrinkAxisMask: number; -} - -// Dense slicing specification -// all ellipses and newaxis are expanded out. So if foo[3:5, ..., -3] where foo -// is 10 dimensional, each array of begin, end, strides will have 10 entries -// where as the sparse can have length less than the rank of foo. -interface StridedSliceDenseSpec { - dims: number; - beginMask?: number; - endMask?: number; - beginValid: boolean; - endValid: boolean; - begin?: number[]; - end?: number[]; - strides?: number[]; - // This array helps construct the final shape of the slice. - // The final tensor is reduced in rank whenever a single index e.g. foo[3] - // is called for. The final tensor increases in rank with newAxis entries. - // If an index in this array is positive, the size of the dimension is - // obtained from canonical end-begin. Otherwise, if it is a NEW_AXIS, it will - // be 1. A shrunk dimension is skipped. - finalShapeGatherIndices?: number[]; - // This array has the same size as finalShapeGatherIndices, but it remembers - // the sparse index that a dimension comes from, instead of dense index. - // A -1 in this vector means the index is not from the sparse input. - finalShapeGatherIndicesSparse?: number[]; - inputShapeGatherIndicesSparse?: number[]; - // The dense indexed shrink mask is which processing dimensions should be - // shrunk. For example, if foo.shape = [10, 10, 10, 10], foo[3, ..., 5] has - // sparseShrinkAxisMask of 5 (0101) and denseShrinkAxisMask of 9 (1001), - // yielding a final shape [10, 10]. - shrinkAxisMask?: number; -} - -export type SliceInfo = { - finalShapeSparse: number[], - finalShape: number[], - isIdentity: boolean, - sliceDim0: boolean, - isSimpleSlice: boolean, - begin: number[], - end: number[], - strides: number[] -}; - -export function assertParamsValid( - input: TensorInfo, begin: number[], size: number[]): void { - const inputRank = input.shape.length; - util.assert( - inputRank === begin.length, - () => `Error in slice${inputRank}D: Length of begin ${begin} must ` + - `match the rank of the array (${inputRank}).`); - util.assert( - inputRank === size.length, - () => `Error in slice${inputRank}D: Length of size ${size} must ` + - `match the rank of the array (${inputRank}).`); - - for (let i = 0; i < inputRank; ++i) { - util.assert( - begin[i] + size[i] <= input.shape[i], - () => `Error in slice${inputRank}D: begin[${i}] + size[${i}] ` + - `(${begin[i] + size[i]}) would overflow input.shape[${i}] (${ - input.shape[i]})`); - } -} - -/** Converts a binary mask to an array of axes. Used in stridedSlice(). */ -export function maskToAxes(mask: number): number[] { - const axes = []; - let axis = 0; - while (mask > 0) { - if (mask & 1) { - axes.push(axis); - } - mask /= 2; - axis++; - } - return axes; -} - -/** Computes the output shape given the strided slice params. */ -export function computeOutShape( - begin: number[], end: number[], strides: number[]): number[] { - const size = []; - for (let axis = 0; axis < begin.length; axis++) { - size[axis] = Math.ceil((end[axis] - begin[axis]) / strides[axis]); - } - return size; -} - -// Creates full selection at the elided dimensions. If the dimension matches -// the ellipsis mask, override the current stride value. Otherwise, insert. -export function stridesWithElidedDims( - strides: number[], ellipsisInsertionIndex: number, numElidedAxes: number, - inputShape: number[]): number[] { - const newStrides = [...strides]; - for (let i = newStrides.length; i < inputShape.length; i++) { - newStrides.push(1); - } - for (let i = 0; i < numElidedAxes; i++) { - if (i === 0) { - newStrides[ellipsisInsertionIndex] = 1; - } else { - newStrides.splice( - ellipsisInsertionIndex, 0 /* num elements to delete */, - 1 /* element to add */); - newStrides.pop(); - } - } - return newStrides; -} - -function unnormalizeAxis( - ellipsisInsertionIndex: number, numElidedAxes: number, - normalizedAxis: number): number { - if (normalizedAxis <= ellipsisInsertionIndex) { - return normalizedAxis; - } - - return normalizedAxis - (numElidedAxes - 1); -} - -function getElidedAxes(numElidedAxes: number, ellipsisInsertionIndex: number) { - const elidedAxes = []; - for (let i = 0; i < numElidedAxes; i++) { - elidedAxes.push(ellipsisInsertionIndex + i); - } - return elidedAxes; -} - -// Normalize the start, end and strides. -export function getNormalizedAxes( - inputShape: number[], ellipsisAxes: number[], numInterpolatedAxes: number, - begin: number[], end: number[], strides: number[], beginMask: number, - endMask: number, - ellipsisMask: number): {begin: number[], end: number[], strides: number[]} { - const inputRank = inputShape.length; - let normalizedBegin = new Array(inputRank), - normalizedEnd = new Array(inputRank), - normalizedStrides = new Array(inputRank); - if (ellipsisAxes.length && numInterpolatedAxes > 0) { - const fullIndex = ellipsisAxes[0]; - - // The ellipsis applies to the masked index as well as any dimensions - // that are interpolated. - const numElidedAxes = numInterpolatedAxes + 1; - normalizedBegin = startIndicesWithElidedDims( - beginMask, fullIndex, numElidedAxes, begin, inputShape); - normalizedEnd = stopIndicesWithElidedDims( - endMask, fullIndex, numElidedAxes, end, inputShape); - normalizedStrides = - stridesWithElidedDims(strides, fullIndex, numElidedAxes, inputShape); - } else { - for (let axis = 0; axis < inputRank; axis++) { - normalizedBegin[axis] = startForAxis( - beginMask, begin, strides, inputShape, axis, ellipsisMask); - normalizedEnd[axis] = - stopForAxis(endMask, end, strides, inputShape, axis, ellipsisMask); - normalizedStrides[axis] = stridesForAxis(strides, axis, ellipsisMask); - } - } - - return { - begin: normalizedBegin, - end: normalizedEnd, - strides: normalizedStrides - }; -} - -// Creates full selection at the elided dimensions. If the dimension matches -// the ellipsis mask, override the current start value. Otherwise, insert. -export function startIndicesWithElidedDims( - beginMask: number, ellipsisInsertionIndex: number, numElidedAxes: number, - originalBegin: number[], inputShape: number[]): number[] { - const newIndices = [...inputShape]; - const elidedAxes = getElidedAxes(numElidedAxes, ellipsisInsertionIndex); - - for (let axis = 0; axis < newIndices.length; axis++) { - if (elidedAxes.indexOf(axis) > -1) { - newIndices[axis] = 0; - } else { - const originalAxis = - unnormalizeAxis(ellipsisInsertionIndex, numElidedAxes, axis); - let originalValue = originalBegin[originalAxis]; - if (beginMask & 1 << originalAxis) { - originalValue = 0; - } - - newIndices[axis] = originalValue; - } - } - return newIndices; -} - -// Creates full selection at the elided dimensions. If the dimension matches -// the ellipsis mask, override the current stop value. Otherwise, insert. -export function stopIndicesWithElidedDims( - endMask: number, ellipsisInsertionIndex: number, numElidedAxes: number, - originalEnd: number[], inputShape: number[]): number[] { - const newIndices = [...inputShape]; - const elidedAxes = getElidedAxes(numElidedAxes, ellipsisInsertionIndex); - - for (let axis = 0; axis < newIndices.length; axis++) { - if (elidedAxes.indexOf(axis) > -1) { - newIndices[axis] = Number.MAX_SAFE_INTEGER; - } else { - const originalAxis = - unnormalizeAxis(ellipsisInsertionIndex, numElidedAxes, axis); - let originalValue = originalEnd[originalAxis]; - if (endMask & 1 << originalAxis) { - originalValue = Number.MAX_SAFE_INTEGER; - } - newIndices[axis] = originalValue; - } - } - - for (let i = 0; i < newIndices.length; i++) { - // Handle negative indices - const axisSize = inputShape[i]; - if (newIndices[i] < 0) { - newIndices[i] += axisSize; - } - newIndices[i] = util.clamp(0, newIndices[i], inputShape[i]); - } - return newIndices; -} - -export function stridesForAxis( - strides: number[], axis: number, ellipsisMask: number): number { - let stride = strides[axis]; - if (ellipsisMask & (1 << axis) || stride == null) { - stride = 1; - } - - return stride; -} - -export function startForAxis( - beginMask: number, startIndices: number[], strides: number[], - inputShape: number[], axis: number, ellipsisMask: number): number { - // Begin with the specified index - let start = startIndices[axis]; - const stride = strides[axis] || 1; - - // Check the axis bit from right of masked axes, or the begin index is not set - // for the axis. - if (beginMask & 1 << axis || ellipsisMask & 1 << axis || start == null) { - if (stride > 0) { - // Forward iteration - use the first element. These values will get - // clamped below (Note: We could have set them to 0 and axis_size-1, but - // use lowest() and max() to maintain symmetry with StopForAxis()) - start = Number.MIN_SAFE_INTEGER; - } else { - // Backward iteration - use the last element. - start = Number.MAX_SAFE_INTEGER; - } - } - - // Handle negative indices - const axisSize = inputShape[axis]; - if (start < 0) { - start += axisSize; - } - - // Clamping - start = util.clamp(0, start, axisSize - 1); - - return start; -} - -export function stopForAxis( - endMask: number, stopIndices: number[], strides: number[], - inputShape: number[], axis: number, ellipsisMask: number): number { - // Begin with the specified index - let stop = stopIndices[axis]; - const stride = strides[axis] || 1; - - // Check the axis bit from right of masked axes, or if the stop index is not - // set for this axis. - if (endMask & (1 << axis) || ellipsisMask & (1 << axis) || stop == null) { - if (stride > 0) { - // Forward iteration - use the last element. These values will get - // clamped below - stop = Number.MAX_SAFE_INTEGER; - } else { - // Backward iteration - use the first element. - stop = Number.MIN_SAFE_INTEGER; - } - } - - // Handle negative indices - const axisSize = inputShape[axis]; - if (stop < 0) { - stop += axisSize; - } - - // Clamping - // Because the end index points one past the last element, we need slightly - // different clamping ranges depending on the direction. - if (stride > 0) { - // Forward iteration - stop = util.clamp(0, stop, axisSize); - } else { - // Backward iteration - stop = util.clamp(-1, stop, axisSize - 1); - } - - return stop; -} - -/** - * Returns true if the slice occupies a continous set of elements in the - * 'flat' space. - */ -export function isSliceContinous( - shape: number[], begin: number[], size: number[]) { - // Index of the first axis that has size > 1. - let firstNonOneAxis = size.length; - for (let i = 0; i < size.length; i++) { - if (size[i] > 1) { - firstNonOneAxis = i; - break; - } - } - - for (let i = firstNonOneAxis + 1; i < size.length; i++) { - if (begin[i] > 0 || size[i] !== shape[i]) { - return false; - } - } - return true; -} - -export function computeFlatOffset(begin: number[], strides: number[]): number { - let flatOffset = begin.length > 0 ? begin[begin.length - 1] : 1; - for (let i = 0; i < begin.length - 1; i++) { - flatOffset += begin[i] * strides[i]; - } - return flatOffset; -} - -export function parseSliceParams( - x: TensorInfo, begin: number|number[], size?: number|number[]) { - // The following logic allows for more ergonomic calls. - let begin_: number[]; - const xRank = x.shape.length; - if (typeof begin === 'number') { - begin_ = [begin, ...new Array(xRank - 1).fill(0)]; - } else if (begin.length < xRank) { - begin_ = begin.concat(new Array(xRank - begin.length).fill(0)); - } else { - begin_ = begin.slice(); - } - begin_.forEach(d => { - util.assert( - d !== -1, () => 'slice() does not support negative begin indexing.'); - }); - let size_: number[]; - if (size == null) { - size_ = new Array(xRank).fill(-1); - } else if (typeof size === 'number') { - size_ = [size, ...new Array(xRank - 1).fill(-1)]; - } else if (size.length < xRank) { - size_ = size.concat(new Array(xRank - size.length).fill(-1)); - } else { - size_ = size; - } - size_ = size_.map((d, i) => { - if (d >= 0) { - return d; - } else { - util.assert( - d === -1, - () => `Negative size values should be exactly -1 but got ` + - `${d} for the slice() size at index ${i}.`); - return x.shape[i] - begin_[i]; - } - }); - return [begin_, size_]; -} - -// Convert the slicing specification from a sparse representation to a dense -// representation. This means that all ellipses and newaxis are expanded out. -export function sliceInfo( - xShape: number[], begin: number[], end: number[], strides: number[], - beginMask: number, endMask: number, ellipsisMask: number, - newAxisMask: number, shrinkAxisMask: number): SliceInfo { - let stridesNonNull; - if (strides == null) { - stridesNonNull = new Array(begin.length); - stridesNonNull.fill(1); - } else { - stridesNonNull = strides; - } - - // Only one non-zero bit is allowed in ellipsisMask, which means ellipsisMask - // is a power of 2. Use bit compares to ensure ellipsisMask is 0 or a power - // of 2. When i is a power of 2, i & (i - 1) is always 0. - // Also ref: - // https://stackoverflow.com/questions/600293/how-to-check-if-a-number-is-a-power-of-2 - if (ellipsisMask != null && (ellipsisMask & (ellipsisMask - 1)) !== 0) { - throw new Error('Multiple ellipses in slice is not allowed.'); - } - - // Step 1: Account for ellipsis and new axis. - // Check for ellipsis and count how many non-newaxis there are after. - let ellipsisSeen = false; - - const sparseSpec: StridedSliceSparseSpec = { - dims: stridesNonNull.length, - numAddAxisAfterEllipsis: 0, - begin: begin.slice(), - end: end.slice(), - strides: stridesNonNull.slice(), - beginMask, - endMask, - ellipsisMask, - newAxisMask, - shrinkAxisMask - }; - - for (let i = 0; i < sparseSpec.dims; i++) { - if (ellipsisSeen && ((1 << i) & newAxisMask) !== 0) { - sparseSpec.numAddAxisAfterEllipsis++; - } - if ((1 << i) & ellipsisMask) { - ellipsisSeen = true; - } - } - // If no ellipsis insert one at the end. - if (!ellipsisSeen) { - sparseSpec.ellipsisMask |= (1 << sparseSpec.dims); - sparseSpec.dims++; // this effects loop iteration below - } - - // Step 2: Make a sparse spec into a full index spec. - // - // The sparse spec deos not correspond to the number of dimensions. - // Make a dense spec that cooresponds to the number of dimensions. - // - // For example suppose foo[...,3:] on foo.shape = [2, 2, 3] then we need to - // produce the missing beginMask for the first two dimensions i.e. from - // beginMaskSpec = 0, endMaskSpec = 2, we achieve beginMask = 6 (110), - // endMask = 7 (111). - const denseSpec: StridedSliceDenseSpec = { - dims: xShape.length, - beginMask: 0, - endMask: 0, - beginValid: false, - endValid: false - }; - - buildDenseSpec(sparseSpec, denseSpec); - - // Step 3: Make implicit ranges (non-zero beginMasks and endMasks) explicit - // and bounds check. - let isIdentity = true; - let sliceDim0 = true; - let isSimpleSlice = true; - const processingShape = []; - const finalShape = []; - - for (let i = 0; i < xShape.length; ++i) { - if (denseSpec.strides[i] === 0) { - throw Error(`strides[${i}] must be non-zero`); - } - const shrinkI = !!(denseSpec.shrinkAxisMask & (1 << i)); - const dimI = xShape[i]; - if (dimI === -1) { - processingShape.push(shrinkI ? 1 : -1); - continue; - } - - const masks = - [denseSpec.beginMask & (1 << i), denseSpec.endMask & (1 << i)]; - const validRange = [ - denseSpec.strides[i] > 0 ? 0 : -1, - denseSpec.strides[i] > 0 ? dimI : dimI - 1 - ]; - - if (shrinkI && denseSpec.strides[i] <= 0) { - throw Error('only stride 1 allowed on non-range indexing.'); - } - - isSimpleSlice = isSimpleSlice && (denseSpec.strides[i] === 1); - - const beginAndEndMasked = - !!((denseSpec.beginMask & (1 << i)) && (denseSpec.endMask & (1 << i))); - - if (denseSpec.beginValid && denseSpec.endValid) { - if (shrinkI) { - // If we are shrinking, the end index is now possibly incorrect. In - // particular foo[-1] produces sparseBegin = -1, sparseEnd = 0. - // and canonical puts these to n-1 and 0, which implies a degenerate - // interval. Fortunately, it is now safe to re-create end as begin + 1. - const xFwd = denseSpec.begin[i] < 0 ? dimI + denseSpec.begin[i] : - denseSpec.begin[i]; - denseSpec.begin[i] = xFwd; - denseSpec.end[i] = denseSpec.begin[i] + 1; - if (xFwd < 0 || xFwd >= dimI) { - throw Error(`slice index ${denseSpec.begin[i]} of dimension ${ - i} out of bounds.`); - } - } else { - denseSpec.begin[i] = canonical( - denseSpec.begin[i], 0, denseSpec.strides[i], dimI, masks, - validRange); - denseSpec.end[i] = canonical( - denseSpec.end[i], 1, denseSpec.strides[i], dimI, masks, validRange); - } - // Update optimization values - const takeAllInDimension = denseSpec.strides[i] === 1 && - denseSpec.begin[i] === 0 && denseSpec.end[i] === dimI; - isIdentity = isIdentity && takeAllInDimension; - sliceDim0 = sliceDim0 && - ((i === 0 && denseSpec.strides[i] === 1) || takeAllInDimension); - } else { - isIdentity = - isIdentity && ((denseSpec.strides[i] === 1) && beginAndEndMasked); - sliceDim0 = sliceDim0 && - ((i === 0 && denseSpec.strides[i] === 1) || beginAndEndMasked); - } - // Compute the processing shape (the intermediate Eigen will produce) - let intervalLength; - let knownInterval = false; - if (denseSpec.beginValid && denseSpec.endValid) { - intervalLength = denseSpec.end[i] - denseSpec.begin[i]; - knownInterval = true; - } else if (shrinkI) { - // The dimension is still known as 1 for the processingShape, but will be - // discarded for the final shape. - intervalLength = 1; - knownInterval = true; - } else if (beginAndEndMasked) { - // Even if we don't have values for begin or end, we do know that this - // dimension covers the whole interval. If we have shape information for - // this dimension, that tells us the interval length. - if (dimI >= 0) { - if (denseSpec.strides[i] < 0) { - intervalLength = -dimI; - } else { - intervalLength = dimI; - } - knownInterval = true; - } - } - if (knownInterval) { - let sizeI; - // Hold zero if the interval is degenerate, otherwise account for - // remainder - if (intervalLength === 0 || - ((intervalLength < 0) !== (denseSpec.strides[i] < 0))) { - sizeI = 0; - } else { - sizeI = Math.trunc(intervalLength / denseSpec.strides[i]) + - (intervalLength % denseSpec.strides[i] !== 0 ? 1 : 0); - } - processingShape.push(sizeI); - } else { - processingShape.push(-1); - } - } - - // Step 4: Compute the final shape - // - // newAxis will increase dimension by 1 (with a one-size dimension) - // slices like foo[3, ...] will reduce dimension by 1. - // This cannot be done earlier, because it depends on Step 3. - for (let denseDim = 0; denseDim < denseSpec.finalShapeGatherIndices.length; - ++denseDim) { - const gatherIndex = denseSpec.finalShapeGatherIndices[denseDim]; - if (gatherIndex >= 0) { - finalShape.push(processingShape[gatherIndex]); - } else if (gatherIndex === NEW_AXIS) { - finalShape.push(1); - } - } - - const finalShapeSparse = finalShape.filter( - (dim, i) => denseSpec.finalShapeGatherIndices[i] !== NEW_AXIS); - - return { - finalShapeSparse, - finalShape, - isIdentity, - sliceDim0, - isSimpleSlice, - begin: denseSpec.begin, - end: denseSpec.end, - strides: denseSpec.strides - }; -} - -function buildDenseSpec( - sparse: StridedSliceSparseSpec, dense: StridedSliceDenseSpec) { - dense.beginMask = 0; - dense.endMask = 0; - dense.shrinkAxisMask = 0; - - let fullIndex = 0; - dense.beginValid = sparse.begin != null; - dense.endValid = sparse.end != null; - - dense.begin = new Array(dense.dims); - dense.end = new Array(dense.dims); - dense.strides = new Array(dense.dims); - dense.finalShapeGatherIndices = []; - dense.finalShapeGatherIndicesSparse = []; - dense.inputShapeGatherIndicesSparse = new Array(dense.dims); - - for (let i = 0; i < sparse.dims; i++) { - if ((1 << i) & sparse.ellipsisMask) { - // Only the bit that has ellipsis will fall in this condition. - // Expand the ellipsis into the appropriate indices - // Note: this only works because we guaranteed one ellipsis. - const nextIndex = Math.min( - dense.dims - (sparse.dims - i) + 1 + sparse.numAddAxisAfterEllipsis, - dense.dims); - for (; fullIndex < nextIndex; fullIndex++) { - // newAxis aren't real axis so you have to skip. - dense.begin[fullIndex] = 0; - dense.end[fullIndex] = 0; - dense.strides[fullIndex] = 1; - dense.beginMask |= (1 << fullIndex); - dense.endMask |= (1 << fullIndex); - dense.finalShapeGatherIndices.push(fullIndex); - dense.finalShapeGatherIndicesSparse.push(-1); - dense.inputShapeGatherIndicesSparse[fullIndex] = i; - } - } else if ((1 << i) & sparse.newAxisMask) { - // Only the bit that has newAxis will fall in this condition. - dense.finalShapeGatherIndices.push(NEW_AXIS); - dense.finalShapeGatherIndicesSparse.push(-1); - } else { - if (fullIndex === dense.begin.length) { - throw Error( - `Index out of range using input dim ${fullIndex}; input ` + - `has only ${dense.dims} dims, ${dense.begin.length}.`); - } - - // Gather slicing spec into appropriate index. - if (sparse.begin != null) { - dense.begin[fullIndex] = sparse.begin[i]; - } - if (sparse.end != null) { - dense.end[fullIndex] = sparse.end[i]; - } - dense.strides[fullIndex] = sparse.strides[i]; - if (sparse.beginMask & (1 << i)) { - dense.beginMask |= (1 << fullIndex); - } - if (sparse.endMask & (1 << i)) { - dense.endMask |= (1 << fullIndex); - } - // If shrink, record where to get the dimensionality from (i.e. newAxis) - // creates a fake 1 size dimension. Also remember shrink axis (now in - // dense form) so we can ignore dense.end below. - if (sparse.shrinkAxisMask & (1 << i)) { - dense.finalShapeGatherIndices.push(SHRINK_AXIS); - dense.finalShapeGatherIndicesSparse.push(-1); - dense.shrinkAxisMask |= (1 << fullIndex); - } else { - dense.finalShapeGatherIndices.push(fullIndex); - // Remember that where in the sparse shape the dense dim comes from. - dense.finalShapeGatherIndicesSparse.push(i); - } - dense.inputShapeGatherIndicesSparse[fullIndex] = i; - fullIndex++; - } - } -} - -function canonical( - x: number, c: number, strideI: number, dimI: number, masks: number[], - validRange: number[]) { - if (masks[c]) { - return strideI > 0 ? validRange[c] : validRange[(c + 1) & 1]; - } else { - const xFwd = x < 0 ? dimI + x : x; // make negative indices positive - return xFwd < validRange[0] ? validRange[0] : - xFwd > validRange[1] ? validRange[1] : xFwd; - } -} diff --git a/tfjs-master/tfjs-core/src/ops/slice_util_test.ts b/tfjs-master/tfjs-core/src/ops/slice_util_test.ts deleted file mode 100644 index ae6207866..000000000 --- a/tfjs-master/tfjs-core/src/ops/slice_util_test.ts +++ /dev/null @@ -1,71 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; - -import {isSliceContinous} from './slice_util'; - -describeWithFlags('isSliceContinous', ALL_ENVS, () => { - it('[] => []', () => { - const shape: number[] = []; - const size: number[] = []; - const begin: number[] = []; - expect(isSliceContinous(shape, begin, size)).toBeTruthy(); - }); - - it('[5] sliced to [3]', () => { - const shape = [5]; - const size = [3]; - const begin = [1]; - expect(isSliceContinous(shape, begin, size)).toBeTruthy(); - }); - - it('[5, 3] sliced to [2, 3] skipping a row', () => { - const shape = [5, 3]; - const size = [2, 3]; - const begin = [1, 0]; - expect(isSliceContinous(shape, begin, size)).toBeTruthy(); - }); - - it('[5, 3] sliced to [5, 2] skipping a column', () => { - const shape = [5, 3]; - const size = [5, 2]; - const begin = [0, 1]; - expect(isSliceContinous(shape, begin, size)).toBeFalsy(); - }); - - it('[5, 3] sliced to [1, 2] skipping a row and column', () => { - const shape = [5, 3]; - const size = [1, 2]; - const begin = [2, 1]; - expect(isSliceContinous(shape, begin, size)).toBeTruthy(); - }); - - it('[1, 5, 3] sliced to [1, 2, 3], skipping middle axis', () => { - const shape = [1, 5, 3]; - const size = [1, 2, 3]; - const begin = [0, 2, 0]; - expect(isSliceContinous(shape, begin, size)).toBeTruthy(); - }); - - it('[2, 5, 3] sliced to [2, 2, 3], skipping middle axis', () => { - const shape = [2, 5, 3]; - const size = [2, 2, 3]; - const begin = [0, 2, 0]; - expect(isSliceContinous(shape, begin, size)).toBeFalsy(); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/softmax.ts b/tfjs-master/tfjs-core/src/ops/softmax.ts deleted file mode 100644 index 55c646a01..000000000 --- a/tfjs-master/tfjs-core/src/ops/softmax.ts +++ /dev/null @@ -1,69 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {Softmax, SoftmaxAttrs, SoftmaxInputs} from '../kernel_names'; -import {NamedAttrMap} from '../kernel_registry'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -import {op} from './operation'; - -/** - * Computes the softmax normalized vector given the logits. - * - * ```js - * const a = tf.tensor1d([1, 2, 3]); - * - * a.softmax().print(); // or tf.softmax(a) - * ``` - * - * ```js - * const a = tf.tensor2d([2, 4, 6, 1, 2, 3], [2, 3]); - * - * a.softmax().print(); // or tf.softmax(a) - * ``` - * - * @param logits The logits array. - * @param dim The dimension softmax would be performed on. Defaults to `-1` - * which indicates the last dimension. - * - * @doc {heading: 'Operations', subheading: 'Normalization'} - */ -function softmax_(logits: T|TensorLike, dim = -1): T { - const $logits = convertToTensor(logits, 'logits', 'softmax', 'float32'); - - if (dim === -1) { - dim = $logits.rank - 1; - } - if (dim !== $logits.rank - 1) { - throw Error( - 'Softmax along a non-last dimension is not yet supported. ' + - `Logits was rank ${$logits.rank} and dim was ${dim}`); - } - - const inputs: SoftmaxInputs = {logits: $logits}; - const attrs: SoftmaxAttrs = {dim}; - - return ENGINE.runKernel( - Softmax, inputs as unknown as NamedTensorMap, - attrs as unknown as NamedAttrMap); -} - -export const softmax = /* @__PURE__ */ op({softmax_}); diff --git a/tfjs-master/tfjs-core/src/ops/softmax_test.ts b/tfjs-master/tfjs-core/src/ops/softmax_test.ts deleted file mode 100644 index e6dcf10f4..000000000 --- a/tfjs-master/tfjs-core/src/ops/softmax_test.ts +++ /dev/null @@ -1,151 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('softmax', ALL_ENVS, () => { - it('regular test', async () => { - const y = tf.softmax(tf.tensor1d([2, 1, 3])); - - expectArraysClose(await y.data(), [0.24472847, 0.09003057, 0.66524095]); - expectArraysClose(await y.sum().data(), 1); - }); - - it('overflow', async () => { - const y = tf.softmax(tf.tensor1d([100, 100])); - - expectArraysClose(await y.data(), [0.5, 0.5]); - }); - - it('underflow', async () => { - const y = tf.softmax(tf.tensor1d([-100, -100])); - - expectArraysClose(await y.data(), [0.5, 0.5]); - }); - - it('odd number of inputs', async () => { - const y = tf.softmax(tf.tensor1d([-400, -400, 0, -400, -400, -400, -400])); - - expectArraysClose(await y.data(), [0, 0, 1, 0, 0, 0, 0]); - }); - - it('Huge difference between probabilities', async () => { - const y = tf.softmax(tf.tensor1d([-1000, +1000])); - - expectArraysClose(await y.data(), [0, 1]); - }); - - it('Propagates NaNs', async () => { - const a = tf.tensor1d([2, 1, NaN]); - const y = tf.softmax(a); - expectArraysClose(await y.data(), [NaN, NaN, NaN]); - }); - - it('2D, dim=1', async () => { - const y = tf.softmax(tf.tensor2d([[2, 1, 3], [1, 3, 2]], [2, 3]), 1); - const expected = [ - 0.24472847, 0.09003057, 0.66524095, 0.09003057, 0.66524095, 0.24472847 - ]; - expect(y.rank).toBe(2); - expectArraysClose(await y.data(), expected); - }); - - it('2D, implicit dim=1', async () => { - const y = tf.softmax(tf.tensor2d([[2, 1, 3], [1, 3, 2]], [2, 3])); - const expected = [ - 0.24472847, 0.09003057, 0.66524095, 0.09003057, 0.66524095, 0.24472847 - ]; - expect(y.rank).toBe(2); - expectArraysClose(await y.data(), expected); - }); - - it('2D, dim=0 throws error', () => { - const f = () => { - tf.softmax(tf.tensor2d([[2, 1, 3], [1, 3, 2]], [2, 3]), 0); - }; - expect(f).toThrowError(); - }); - - it('1D gradient', async () => { - const x = tf.tensor1d([10, 0, -1]); - const y = tf.softmax(x); - const dy = tf.tensor1d([1, 2, 3]); - const dx = tf.grad((x) => x.softmax())(x, dy); - - const totalSum: tf.Scalar = tf.sum(tf.mul(dy, y)); - - const dyVals = await dy.array(); - const sumVals = await totalSum.array(); - const yVals = await y.array(); - expect(dx.shape).toEqual(x.shape); - expectArraysClose(await dx.data(), [ - (dyVals[0] - sumVals) * yVals[0], - (dyVals[1] - sumVals) * yVals[1], - (dyVals[2] - sumVals) * yVals[2], - ]); - }); - - it('gradient with clones', () => { - const x = tf.tensor1d([10, 0, -1]); - const dx = tf.grad((x) => x.clone().softmax().clone())(x); - expect(dx.shape).toEqual(x.shape); - expect(dx.dtype).toBe('float32'); - }); - - it('2D gradient', async () => { - const x = tf.tensor2d([10, 0, -1, 5, 4, 3], [2, 3]); - const y = tf.softmax(x); - const dy = tf.tensor2d([3, 2, 1, 1, 2, 3], [2, 3]); - const dx = tf.grad((x) => x.softmax())(x, dy); - - const axis = -1; - const totalSum: tf.Tensor1D = tf.sum(tf.mul(dy, y), axis); - - const dyVals = await dy.array(); - const sumVals = await totalSum.array(); - const yVals = await y.array(); - - expect(dx.shape).toEqual(x.shape); - expectArraysClose(await dx.data(), [ - (dyVals[0][0] - sumVals[0]) * yVals[0][0], - (dyVals[0][1] - sumVals[0]) * yVals[0][1], - (dyVals[0][2] - sumVals[0]) * yVals[0][2], - (dyVals[1][0] - sumVals[1]) * yVals[1][0], - (dyVals[1][1] - sumVals[1]) * yVals[1][1], - (dyVals[1][2] - sumVals[1]) * yVals[1][2] - ]); - }); - - it('throws when passed a non-tensor', () => { - expect(() => tf.softmax({} as tf.Tensor)) - .toThrowError(/Argument 'logits' passed to 'softmax' must be a Tensor/); - }); - - it('throws when passed an int32 tensor', async () => { - expect(() => tf.softmax(tf.tensor1d([2, 1, 3], 'int32'))) - .toThrowError(/Argument 'logits' passed to 'softmax' must be float32/); - }); - - it('accepts a tensor-like object', async () => { - const y = tf.softmax([2, 1, 3]); - - expectArraysClose(await y.data(), [0.24472847, 0.09003057, 0.66524095]); - expectArraysClose(await y.sum().data(), 1); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/softplus.ts b/tfjs-master/tfjs-core/src/ops/softplus.ts deleted file mode 100644 index e0604b5c3..000000000 --- a/tfjs-master/tfjs-core/src/ops/softplus.ts +++ /dev/null @@ -1,45 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {Softplus, SoftplusInputs} from '../kernel_names'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -import {op} from './operation'; - -/** - * Computes softplus of the input `tf.Tensor` element-wise: `log(exp(x) + 1)` - * - * ```js - * const x = tf.tensor1d([0, 1, -1, .7]); - * - * x.softplus().print(); // or tf.softplus(x) - * ``` - * @param x The input tensor. - * - * @doc {heading: 'Operations', subheading: 'Basic math'} - */ -function softplus_(x: T|TensorLike): T { - const $x = convertToTensor(x, 'x', 'softplus'); - - const inputs: SoftplusInputs = {x: $x}; - return ENGINE.runKernel(Softplus, inputs as unknown as NamedTensorMap); -} -export const softplus = /* @__PURE__ */ op({softplus_}); diff --git a/tfjs-master/tfjs-core/src/ops/softplus_test.ts b/tfjs-master/tfjs-core/src/ops/softplus_test.ts deleted file mode 100644 index a4b3a1d01..000000000 --- a/tfjs-master/tfjs-core/src/ops/softplus_test.ts +++ /dev/null @@ -1,159 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('softplus', ALL_ENVS, () => { - it('basic', async () => { - const values = [1, -3, 2, 7, -4]; - const a = tf.tensor1d(values); - - const result = tf.softplus(a); - - const expected = []; - for (let i = 0; i < a.size; i++) { - expected[i] = Math.log((1 + Math.exp(values[i]))); - } - expectArraysClose(await result.data(), expected); - }); - - it('scalar', async () => { - const a = tf.scalar(-2); - - const result = tf.softplus(a); - - const expected = [Math.log((1 + Math.exp(-2)))]; - expectArraysClose(await result.data(), expected); - }); - - it('tensor2D', async () => { - const values = [1, 2, -3, 5]; - const a = tf.tensor2d(values, [2, 2]); - - const result = tf.softplus(a); - - const expected = []; - for (let i = 0; i < a.size; i++) { - expected[i] = Math.log((1 + Math.exp(values[i]))); - } - expectArraysClose(await result.data(), expected); - }); - - it('larger magnitude negative inputs', async () => { - const values = [-100, -200, -3000, -50000]; - const a = tf.tensor1d(values); - - const result = tf.softplus(a); - - const expected = [0, 0, 0, 0]; - - expectArraysClose(await result.data(), expected); - }); - - it('larger magnitude positive inputs', async () => { - const values = [100, 200, 3000]; - const a = tf.tensor1d(values); - - const result = tf.softplus(a); - - const expected = [100, 200, 3000]; - - expectArraysClose(await result.data(), expected); - }); - - it('propagates NaNs', async () => { - const a = tf.tensor1d([3, NaN]); - const res = tf.softplus(a); - expectArraysClose(await res.data(), [Math.log((1 + Math.exp(3))), NaN]); - }); - - it('gradients: Scalar', async () => { - const a = tf.scalar(3); - const dy = tf.scalar(4); - const aVal = await a.array(); - const dyVal = await dy.array(); - - const da = tf.grad(a => tf.softplus(a))(a, dy); - const y = 1 / (1 + Math.exp(-aVal)); - - expectArraysClose(await da.data(), [dyVal * y]); - }); - - it('gradients: Scalar', async () => { - const a = tf.scalar(3); - const dy = tf.scalar(4); - const aVal = await a.array(); - const dyVal = await dy.array(); - - const da = tf.grad(a => tf.softplus(a.clone()).clone())(a, dy); - const y = 1 / (1 + Math.exp(-aVal)); - - expectArraysClose(await da.data(), [dyVal * y]); - }); - - it('gradients: Tensor1D', async () => { - const a = tf.tensor1d([1, 2, -3, 5]); - const aVals = await a.array(); - const dy = tf.tensor1d([1, 2, 3, 4]); - const dyVals = await dy.array(); - const da = tf.grad(a => tf.softplus(a))(a, dy); - - const expected = []; - for (let i = 0; i < a.size; i++) { - const y = 1 / (1 + Math.exp(-aVals[i])); - expected[i] = dyVals[i] * y; - } - - expectArraysClose(await da.data(), expected); - }); - - it('gradients: Tensor2D', async () => { - const a = tf.tensor2d([1, 2, -3, 5], [2, 2]); - const dy = tf.tensor2d([1, 2, 3, 4], [2, 2]); - - const da = tf.grad(a => tf.softplus(a))(a, dy); - - const expected = []; - const aVals = await a.data(); - const dyVals = await dy.data(); - - for (let i = 0; i < a.size; i++) { - const y = 1 / (1 + Math.exp(-aVals[i])); - expected[i] = dyVals[i] * y; - } - - expectArraysClose(await da.data(), expected); - }); - - it('throws when passed a non-tensor', () => { - expect(() => tf.softplus({} as tf.Tensor)) - .toThrowError(/Argument 'x' passed to 'softplus' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const result = tf.softplus(-2); - const expected = [Math.log((1 + Math.exp(-2)))]; - expectArraysClose(await result.data(), expected); - }); - - it('throws for string tensor', () => { - expect(() => tf.softplus('q')) - .toThrowError(/Argument 'x' passed to 'softplus' must be numeric/); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/space_to_batch_nd.ts b/tfjs-master/tfjs-core/src/ops/space_to_batch_nd.ts deleted file mode 100644 index 9b7b44ffe..000000000 --- a/tfjs-master/tfjs-core/src/ops/space_to_batch_nd.ts +++ /dev/null @@ -1,115 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {SpaceToBatchND, SpaceToBatchNDAttrs, SpaceToBatchNDInputs} from '../kernel_names'; -import {NamedAttrMap} from '../kernel_registry'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; -import * as util from '../util'; - -import {op} from './operation'; - -/** - * This operation divides "spatial" dimensions `[1, ..., M]` of the input into - * a grid of blocks of shape `blockShape`, and interleaves these blocks with - * the "batch" dimension (0) such that in the output, the spatial - * dimensions `[1, ..., M]` correspond to the position within the grid, - * and the batch dimension combines both the position within a spatial block - * and the original batch position. Prior to division into blocks, - * the spatial dimensions of the input are optionally zero padded - * according to `paddings`. See below for a precise description. - * - * ```js - * const x = tf.tensor4d([1, 2, 3, 4], [1, 2, 2, 1]); - * const blockShape = [2, 2]; - * const paddings = [[0, 0], [0, 0]]; - * - * x.spaceToBatchND(blockShape, paddings).print(); - * ``` - * - * @param x A `tf.Tensor`. N-D with `x.shape` = `[batch] + spatialShape + - * remainingShape`, where spatialShape has `M` dimensions. - * @param blockShape A 1-D array. Must have shape `[M]`, all values must - * be >= 1. - * @param paddings A 2-D array. Must have shape `[M, 2]`, all values must be >= - * 0. `paddings[i] = [padStart, padEnd]` specifies the amount to zero-pad - * from input dimension `i + 1`, which corresponds to spatial dimension `i`. It - * is required that - * `(inputShape[i + 1] + padStart + padEnd) % blockShape[i] === 0` - * - * This operation is equivalent to the following steps: - * - * 1. Zero-pad the start and end of dimensions `[1, ..., M]` of the input - * according to `paddings` to produce `padded` of shape paddedShape. - * - * 2. Reshape `padded` to `reshapedPadded` of shape: - * `[batch] + [paddedShape[1] / blockShape[0], blockShape[0], ..., - * paddedShape[M] / blockShape[M-1], blockShape[M-1]] + remainingShape` - * - * 3. Permute dimensions of `reshapedPadded` to produce `permutedReshapedPadded` - * of shape: `blockShape + [batch] + [paddedShape[1] / blockShape[0], ..., - * paddedShape[M] / blockShape[M-1]] + remainingShape` - * - * 4. Reshape `permutedReshapedPadded` to flatten `blockShape` into the - * batch dimension, producing an output tensor of shape: - * `[batch * prod(blockShape)] + [paddedShape[1] / blockShape[0], ..., - * paddedShape[M] / blockShape[M-1]] + remainingShape` - * - * @doc {heading: 'Tensors', subheading: 'Transformations'} - */ -function spaceToBatchND_( - x: T|TensorLike, blockShape: number[], paddings: number[][]): T { - const $x = convertToTensor(x, 'x', 'spaceToBatchND'); - - util.assert( - $x.rank >= 1 + blockShape.length, - () => `input rank ${$x.rank} should be > than [blockShape] ${ - blockShape.length}`); - - util.assert( - paddings.length === blockShape.length, - () => `paddings.shape[0] ${ - paddings.length} must be equal to [blockShape] ${blockShape.length}`); - - util.assert( - $x.shape.reduce( - (a, b, i) => { - if (i > 0 && i <= blockShape.length) { - return a && - ((b + paddings[i - 1][0] + paddings[i - 1][1]) % - blockShape[i - 1] === - 0); - } - return a; - }, - true), - () => `input spatial dimensions ${$x.shape.slice(1)} with paddings ${ - paddings.toString()} must be divisible by blockShapes ${ - blockShape.toString()}`); - - const inputs: SpaceToBatchNDInputs = {x: $x}; - const attrs: SpaceToBatchNDAttrs = {blockShape, paddings}; - - return ENGINE.runKernel( - SpaceToBatchND, inputs as unknown as NamedTensorMap, - attrs as unknown as NamedAttrMap); -} - -export const spaceToBatchND = /* @__PURE__ */ op({spaceToBatchND_}); diff --git a/tfjs-master/tfjs-core/src/ops/space_to_batch_nd_test.ts b/tfjs-master/tfjs-core/src/ops/space_to_batch_nd_test.ts deleted file mode 100644 index 11da95ac1..000000000 --- a/tfjs-master/tfjs-core/src/ops/space_to_batch_nd_test.ts +++ /dev/null @@ -1,268 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('spaceToBatchND', ALL_ENVS, () => { - it('tensor4d, input shape=[1, 2, 2, 1], blockShape=[2, 2]', async () => { - const t = tf.tensor4d([[[[1], [2]], [[3], [4]]]], [1, 2, 2, 1]); - const blockShape = [2, 2]; - const paddings = [[0, 0], [0, 0]]; - - const res = tf.spaceToBatchND(t, blockShape, paddings); - expect(res.shape).toEqual([4, 1, 1, 1]); - expectArraysClose(await res.data(), [1, 2, 3, 4]); - }); - - it('tensor4d, input shape=[1, 2, 2, 3], blockShape=[2, 2]', async () => { - const t = tf.tensor4d( - [[[[1, 2, 3], [4, 5, 6]], [[7, 8, 9], [10, 11, 12]]]], [1, 2, 2, 3]); - const blockShape = [2, 2]; - const paddings = [[0, 0], [0, 0]]; - - const res = tf.spaceToBatchND(t, blockShape, paddings); - expect(res.shape).toEqual([4, 1, 1, 3]); - expectArraysClose( - await res.data(), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]); - }); - - it('tensor4d, input shape=[1, 4, 4, 1], blockShape=[2, 2]', async () => { - const t = tf.tensor4d( - [[ - [[1], [2], [3], [4]], [[5], [6], [7], [8]], [[9], [10], [11], [12]], - [[13], [14], [15], [16]] - ]], - [1, 4, 4, 1]); - const blockShape = [2, 2]; - const paddings = [[0, 0], [0, 0]]; - - const res = tf.spaceToBatchND(t, blockShape, paddings); - expect(res.shape).toEqual([4, 2, 2, 1]); - expectArraysClose( - await res.data(), - [1, 3, 9, 11, 2, 4, 10, 12, 5, 7, 13, 15, 6, 8, 14, 16]); - }); - - it('tensor4d, input shape=[2, 6, 6, 1], blockShape=[2, 2]', async () => { - const t = tf.tensor4d( - [ - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, - 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, - 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, - 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72 - ], - [2, 6, 6, 1]); - const blockShape = [2, 2]; - const paddings = [[0, 0], [0, 0]]; - - const res = tf.spaceToBatchND(t, blockShape, paddings); - expect(res.shape).toEqual([8, 3, 3, 1]); - expectArraysClose(await res.data(), [ - 1, 3, 5, 13, 15, 17, 25, 27, 29, 37, 39, 41, 49, 51, 53, 61, 63, 65, - 2, 4, 6, 14, 16, 18, 26, 28, 30, 38, 40, 42, 50, 52, 54, 62, 64, 66, - 7, 9, 11, 19, 21, 23, 31, 33, 35, 43, 45, 47, 55, 57, 59, 67, 69, 71, - 8, 10, 12, 20, 22, 24, 32, 34, 36, 44, 46, 48, 56, 58, 60, 68, 70, 72 - ]); - }); - - it('tensor4d, input shape=[2, 2, 4, 1], blockShape=[2, 2]', async () => { - const t = tf.tensor4d( - [ - [[[1], [2], [3], [4]], [[5], [6], [7], [8]]], - [[[9], [10], [11], [12]], [[13], [14], [15], [16]]] - ], - [2, 2, 4, 1]); - const blockShape = [2, 2]; - const paddings = [[0, 0], [2, 0]]; - - const res = tf.spaceToBatchND(t, blockShape, paddings); - expect(res.shape).toEqual([8, 1, 3, 1]); - expectArraysClose(await res.data(), [ - 0, 1, 3, 0, 9, 11, 0, 2, 4, 0, 10, 12, - 0, 5, 7, 0, 13, 15, 0, 6, 8, 0, 14, 16 - ]); - }); - - it('tensor2d, blockShape [2]', async () => { - const t = tf.tensor2d([1, 3, 2, 4], [1, 4]); - const blockShape = [2]; - const paddings = [[0, 0]]; - - const res = tf.spaceToBatchND(t, blockShape, paddings); - expect(res.shape).toEqual([2, 2]); - expectArraysClose(await res.data(), [1, 2, 3, 4]); - }); - - it('throws when blockShape equal to input rank', () => { - const t = tf.tensor4d([1, 2, 3, 4], [1, 2, 2, 1]); - const blockShape = [2, 2, 2, 2]; - const paddings = [[0, 0], [0, 0], [0, 0], [0, 0]]; - - expect(() => tf.spaceToBatchND(t, blockShape, paddings)) - .toThrowError('input rank 4 should be > than [blockShape] 4'); - }); - - it('throws when paddings row dimension not equal to blockshape', () => { - const t = tf.tensor4d([1, 2, 3, 4], [1, 2, 2, 1]); - const blockShape = [2, 2]; - const paddings = [[0, 0]]; - - expect(() => tf.spaceToBatchND(t, blockShape, paddings)) - .toThrowError('paddings.shape[0] 1 must be equal to [blockShape] 2'); - }); - - it('throws when input tensor spatial dimension not divisible by blockshapes', - () => { - const t = tf.tensor4d([1, 2, 3, 4, 5, 6], [1, 2, 3, 1]); - const blockShape = [2, 2]; - const paddings = [[0, 0], [0, 0]]; - - expect(() => tf.spaceToBatchND(t, blockShape, paddings)) - .toThrowError( - 'input spatial dimensions 2,3,1 with paddings 0,0,0,0 must be ' + - 'divisible by blockShapes 2,2'); - }); - - it('accepts a tensor-like object', async () => { - const t = [[[[1], [2]], [[3], [4]]]]; - const blockShape = [2, 2]; - const paddings = [[0, 0], [0, 0]]; - - const res = tf.spaceToBatchND(t, blockShape, paddings); - expect(res.shape).toEqual([4, 1, 1, 1]); - expectArraysClose(await res.data(), [1, 2, 3, 4]); - }); -}); - -describeWithFlags('batchToSpaceND X spaceToBatchND', ALL_ENVS, () => { - it('tensor4d, input shape=[4, 1, 1, 1], blockShape=[2, 2]', async () => { - const t = tf.tensor4d([1, 2, 3, 4], [4, 1, 1, 1]); - const blockShape = [2, 2]; - const crops = [[0, 0], [0, 0]]; - const paddings = [[0, 0], [0, 0]]; - - const b2s = tf.batchToSpaceND(t, blockShape, crops); - expect(b2s.shape).toEqual([1, 2, 2, 1]); - expectArraysClose(await b2s.data(), [1, 2, 3, 4]); - - const s2b = tf.spaceToBatchND(b2s, blockShape, paddings); - expect(s2b.shape).toEqual([4, 1, 1, 1]); - expectArraysClose(await s2b.data(), [1, 2, 3, 4]); - }); - - it('tensor4d, input shape=[2, 6, 6, 1], blockShape=[2, 2]', async () => { - const t = tf.tensor4d( - [ - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, - 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, - 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, - 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72 - ], - [2, 6, 6, 1]); - const blockShape = [2, 2]; - const crops = [[0, 0], [0, 0]]; - const paddings = [[0, 0], [0, 0]]; - - const s2b = tf.spaceToBatchND(t, blockShape, paddings); - expect(s2b.shape).toEqual([8, 3, 3, 1]); - expectArraysClose(await s2b.data(), [ - 1, 3, 5, 13, 15, 17, 25, 27, 29, 37, 39, 41, 49, 51, 53, 61, 63, 65, - 2, 4, 6, 14, 16, 18, 26, 28, 30, 38, 40, 42, 50, 52, 54, 62, 64, 66, - 7, 9, 11, 19, 21, 23, 31, 33, 35, 43, 45, 47, 55, 57, 59, 67, 69, 71, - 8, 10, 12, 20, 22, 24, 32, 34, 36, 44, 46, 48, 56, 58, 60, 68, 70, 72 - ]); - - const b2s = tf.batchToSpaceND(s2b, blockShape, crops); - expect(b2s.shape).toEqual([2, 6, 6, 1]); - expectArraysClose(await b2s.data(), [ - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, - 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, - 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, - 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72 - ]); - }); - - it('gradients, input shape=[4, 2, 2], block shape=[2]', async () => { - const t = tf.tensor( - [-61, 37, -68, 72, 31, 62, 0, -13, 28, 54, 96, 44, -55, -64, -88, -94], - [4, 2, 2]); - const blockShape = [2]; - const paddings = [[0, 2]]; - const dy = tf.tensor( - [ - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, - 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32 - ], - [8, 2, 2]); - - const gradient = - tf.grad(t => tf.spaceToBatchND(t, blockShape, paddings))(t, dy); - expect(gradient.shape).toEqual([4, 2, 2]); - expectArraysClose( - await gradient.data(), - [1, 2, 17, 18, 5, 6, 21, 22, 9, 10, 25, 26, 13, 14, 29, 30]); - }); - - it('gradient with clones input=[4, 2, 2], block shape=[2]', async () => { - const t = tf.tensor( - [-61, 37, -68, 72, 31, 62, 0, -13, 28, 54, 96, 44, -55, -64, -88, -94], - [4, 2, 2]); - const blockShape = [2]; - const paddings = [[0, 2]]; - const dy = tf.tensor( - [ - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, - 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32 - ], - [8, 2, 2]); - - const gradient = tf.grad( - t => tf.spaceToBatchND(t.clone(), blockShape, paddings).clone())(t, dy); - expect(gradient.shape).toEqual([4, 2, 2]); - expectArraysClose( - await gradient.data(), - [1, 2, 17, 18, 5, 6, 21, 22, 9, 10, 25, 26, 13, 14, 29, 30]); - }); - - it('gradients, input shape=[2, 2, 4, 1], block shape=[2, 2]', async () => { - const t = tf.tensor4d( - [ - [[[1], [2], [3], [4]], [[5], [6], [7], [8]]], - [[[9], [10], [11], [12]], [[13], [14], [15], [16]]] - ], - [2, 2, 4, 1]); - const blockShape = [2, 2]; - const paddings = [[0, 0], [2, 0]]; - const dy = tf.tensor( - [ - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, - 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24 - ], - [8, 1, 3, 1]); - - const gradient = - tf.grad(t => tf.spaceToBatchND(t, blockShape, paddings))(t, dy); - expect(gradient.shape).toEqual([2, 2, 4, 1]); - expectArraysClose( - await gradient.data(), - [2, 8, 3, 9, 14, 20, 15, 21, 5, 11, 6, 12, 17, 23, 18, 24]); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/sparse/sparse_fill_empty_rows.ts b/tfjs-master/tfjs-core/src/ops/sparse/sparse_fill_empty_rows.ts deleted file mode 100644 index db258c3c8..000000000 --- a/tfjs-master/tfjs-core/src/ops/sparse/sparse_fill_empty_rows.ts +++ /dev/null @@ -1,127 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../../engine'; -import {SparseFillEmptyRows, SparseFillEmptyRowsInputs} from '../../kernel_names'; -import {Scalar, Tensor, Tensor1D, Tensor2D} from '../../tensor'; -import {NamedTensorMap} from '../../tensor_types'; -import {convertToTensor} from '../../tensor_util_env'; -import {ScalarLike, TensorLike} from '../../types'; -import {op} from '../operation'; - -/** - * The input SparseTensor is represented via the map of inputs {`indices`, - * `values`, `denseShape`}. The output SparseTensor has the same `denseShape` - * but with indices `outputIndices` and values `outputValues`. This op inserts a - * single entry for every row that doesn't have any values. The index is created - * as `[row, 0, ..., 0]` and the inserted value is `defaultValue`. - * - * For example, suppose `spInput` has shape [5, 6] and non-empty values: - * [0, 1]: a - * [0, 3]: b - * [2, 0]: c - * [3, 1]: d - * - * Rows 1 and 4 are empty, so the output will be of shape [5, 6] with values: - * [0, 1]: a - * [0, 3]: b - * [1, 0]: `defaultValue` - * [2, 0]: c - * [3, 1]: d - * [4, 0]: `defaultValue` - * - * The output SparseTensor will be in row-major order and will have the same - * shape as the input. - * - * This op also returns an indicator vector shaped [dense_shape[0]] such that - * emptyRowIndicator[i] = True iff row i was an empty row. - * - * And a reverse index map vector shaped [indices.shape[0]] that is used during - * backpropagation, reverseIndexMap[i] = outi s.t. indices[i, j] == - * outputIndices[outi, j] for all j - * - * ```js - * const result = tf.sparse.sparseFillEmptyRows( - * [[0, 0], [1, 0], [1, 3], [1, 4], [3, 2], [3, 3]], - * [0, 10, 13, 14, 32, 33], [5, 6], -1); - * console.log(result); - * result['outputIndices'].print(); // [[0, 0], [1, 0], [1, 3], [1, 4], - * // [2, 0], [3, 2], [3, 3], [4, 0]] - * result['outputValues'].print(); // [0, 10, 13, 14,-1, 32, 33, -1] - * result['emptyRowIndicator'].print(); // [false, false, true, false, true] - * result['reverseIndexMap'].print(); // [0, 1, 2, 3, 5, 6] - * ``` - * @param indices: 2-D. The indices of the sparse tensor. - * @param values: 1-D. The values of the sparse tensor. - * @param denseShape: 1-D. The shape of the sparse tensor. - * @param defaultValue: 0-D. Default value to insert into location [row, 0, ..., - * 0] for rows missing from the input sparse tensor. - * @return A map with the following properties: - * - outputIndices - * - outputValues: 1-D. The values of the filled sparse tensor. - * - emptyRowIndicator: 1-D. Whether the dense row was missing in the input - * sparse tensor. - * - reverseIndexMap: 1-D. A map from the input indices to the output - * indices. - * @doc {heading: 'Operations', subheading: 'Sparse'} - */ -function sparseFillEmptyRows_( - indices: Tensor2D|TensorLike, values: Tensor1D|TensorLike, - denseShape: Tensor1D|TensorLike, - defaultValue: Scalar|ScalarLike): NamedTensorMap { - const $indices = - convertToTensor(indices, 'indices', 'sparseFillEmptyRows', 'int32'); - const $values = convertToTensor(values, 'values', 'sparseFillEmptyRows'); - const $denseShape = - convertToTensor(denseShape, 'denseShape', 'sparseFillEmptyRows', 'int32'); - const $defaultValue = convertToTensor( - defaultValue, 'defaultValue', 'sparseFillEmptyRows', $values.dtype); - - if ($indices.rank !== 2) { - throw new Error(`Indices should be Tensor2D but received shape - ${$indices.shape}`); - } - if ($values.rank !== 1) { - throw new Error( - `Values should be Tensor1D but received shape ${$values.shape}`); - } - if ($denseShape.rank !== 1) { - throw new Error(`Dense shape should be Tensor1D but received shape ${ - $denseShape.shape}`); - } - if ($defaultValue.rank !== 0) { - throw new Error(`Default value should be a scalar but received shape ${ - $defaultValue.shape}`); - } - - const inputs: SparseFillEmptyRowsInputs = { - indices: $indices, - values: $values, - denseShape: $denseShape, - defaultValue: $defaultValue - }; - - const result: Tensor[] = ENGINE.runKernel(SparseFillEmptyRows, inputs as {}); - return { - outputIndices: result[0], - outputValues: result[1], - emptyRowIndicator: result[2], - reverseIndexMap: result[3] - }; -} - -export const sparseFillEmptyRows = /* @__PURE__ */ op({sparseFillEmptyRows_}); diff --git a/tfjs-master/tfjs-core/src/ops/sparse/sparse_fill_empty_rows_test.ts b/tfjs-master/tfjs-core/src/ops/sparse/sparse_fill_empty_rows_test.ts deleted file mode 100644 index 78cae3f23..000000000 --- a/tfjs-master/tfjs-core/src/ops/sparse/sparse_fill_empty_rows_test.ts +++ /dev/null @@ -1,202 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../../index'; -import {ALL_ENVS, describeWithFlags} from '../../jasmine_util'; -import {expectArraysClose} from '../../test_util'; - -describeWithFlags('sparseFillEmptyRows', ALL_ENVS, () => { - it('fill number', async () => { - const sparseTensor = { - ind: tf.tensor2d( - [[0, 0], [1, 0], [1, 3], [1, 4], [3, 2], [3, 3]], [6, 2], 'int32'), - val: [0, 10, 13, 14, 32, 33], - shape: [5, 6], - }; - const result = tf.sparse.sparseFillEmptyRows( - sparseTensor.ind, sparseTensor.val, sparseTensor.shape, -1); - expectArraysClose( - await result.outputIndices.data(), - [[0, 0], [1, 0], [1, 3], [1, 4], [2, 0], [3, 2], [3, 3], [4, 0]]); - expectArraysClose( - await result.outputValues.data(), [0, 10, 13, 14, -1, 32, 33, -1]); - expectArraysClose(await result.emptyRowIndicator.data(), [0, 0, 1, 0, 1]); - expectArraysClose(await result.reverseIndexMap.data(), [0, 1, 2, 3, 5, 6]); - }); - - it('fill float', async () => { - const sparseTensor = { - ind: tf.tensor2d( - [[0, 0], [1, 0], [1, 3], [1, 4], [3, 2], [3, 3]], [6, 2], 'int32'), - val: tf.tensor1d([0.0, 10.0, 13.0, 14.0, 32.0, 33.0], 'float32'), - shape: [5, 6], - }; - const result = tf.sparse.sparseFillEmptyRows( - sparseTensor.ind, sparseTensor.val, sparseTensor.shape, -1); - expectArraysClose( - await result.outputIndices.data(), - [[0, 0], [1, 0], [1, 3], [1, 4], [2, 0], [3, 2], [3, 3], [4, 0]]); - expectArraysClose( - await result.outputValues.data(), [0, 10, 13, 14, -1, 32, 33, -1]); - expectArraysClose(await result.emptyRowIndicator.data(), [0, 0, 1, 0, 1]); - expectArraysClose(await result.reverseIndexMap.data(), [0, 1, 2, 3, 5, 6]); - }); - - it('no empty rows', async () => { - const sparseTensor = { - ind: tf.tensor2d([[0, 0], [1, 0], [1, 3], [1, 4]], [4, 2], 'int32'), - val: [0, 10, 13, 14], - shape: [2, 6], - }; - const result = tf.sparse.sparseFillEmptyRows( - sparseTensor.ind, sparseTensor.val, sparseTensor.shape, -1); - expectArraysClose( - await result.outputIndices.data(), [[0, 0], [1, 0], [1, 3], [1, 4]]); - expectArraysClose(await result.outputValues.data(), [0, 10, 13, 14]); - expectArraysClose(await result.emptyRowIndicator.data(), [0, 0]); - expectArraysClose(await result.reverseIndexMap.data(), [0, 1, 2, 3]); - }); - - it('no empty rows and unordered', async () => { - const sparseTensor = { - ind: tf.tensor2d([[1, 2], [1, 3], [0, 1], [0, 3]], [4, 2], 'int32'), - val: [1, 3, 2, 4], - shape: [2, 5], - }; - const result = tf.sparse.sparseFillEmptyRows( - sparseTensor.ind, sparseTensor.val, sparseTensor.shape, -1); - expectArraysClose( - await result.outputIndices.data(), [[0, 1], [0, 3], [1, 2], [1, 3]]); - expectArraysClose(await result.outputValues.data(), [2, 4, 1, 3]); - expectArraysClose(await result.emptyRowIndicator.data(), [0, 0]); - expectArraysClose(await result.reverseIndexMap.data(), [2, 3, 0, 1]); - }); - - it('no rows', async () => { - const sparseTensor = { - ind: tf.tensor2d([], [0, 2], 'int32'), - val: [] as number[], - shape: [0, 5], - }; - const result = tf.sparse.sparseFillEmptyRows( - sparseTensor.ind, sparseTensor.val, sparseTensor.shape, -1); - expectArraysClose(await result.outputIndices.data(), []); - expectArraysClose(await result.outputValues.data(), []); - expectArraysClose(await result.emptyRowIndicator.data(), []); - expectArraysClose(await result.reverseIndexMap.data(), []); - }); - - it('check output metadata', async () => { - const sparseTensor = { - ind: tf.tensor2d( - [[0, 0], [1, 0], [1, 3], [1, 4], [3, 2], [3, 3]], [6, 2], 'int32'), - val: tf.tensor1d([0, 10, 13, 14, 32, 33], 'float32'), - shape: [5, 6], - }; - const result = tf.sparse.sparseFillEmptyRows( - sparseTensor.ind, sparseTensor.val, sparseTensor.shape, -1); - - expectArraysClose( - await result.outputIndices.data(), - [[0, 0], [1, 0], [1, 3], [1, 4], [2, 0], [3, 2], [3, 3], [4, 0]]); - expectArraysClose( - await result.outputValues.data(), [0, 10, 13, 14, -1, 32, 33, -1]); - expectArraysClose(await result.emptyRowIndicator.data(), [0, 0, 1, 0, 1]); - expectArraysClose(await result.reverseIndexMap.data(), [0, 1, 2, 3, 5, 6]); - - expect(result.outputIndices.shape).toEqual([8, 2]); - expect(result.outputValues.shape).toEqual([8]); - expect(result.emptyRowIndicator.shape).toEqual([5]); - expect(result.reverseIndexMap.shape).toEqual([6]); - - expect(result.outputIndices.dtype).toEqual(sparseTensor.ind.dtype); - expect(result.outputValues.dtype).toEqual(sparseTensor.val.dtype); - expect(result.emptyRowIndicator.dtype).toEqual('bool'); - expect(result.reverseIndexMap.dtype).toEqual(sparseTensor.ind.dtype); - }); - - it('does not have memory leak.', async () => { - const beforeDataIds = tf.engine().backend.numDataIds(); - - const sparseTensor = { - ind: tf.tensor2d( - [[0, 0], [1, 0], [1, 3], [1, 4], [3, 2], [3, 3]], [6, 2], 'int32'), - val: [0, 10, 13, 14, 32, 33], - shape: [5, 6], - }; - const indices = sparseTensor.ind; - const values = tf.tensor1d(sparseTensor.val, 'float32'); - const denseShape = tf.tensor1d(sparseTensor.shape, 'int32'); - const result = - tf.sparse.sparseFillEmptyRows(indices, values, denseShape, -1); - - await result.outputIndices.data(); - await result.outputValues.data(); - await result.emptyRowIndicator.data(); - await result.reverseIndexMap.data(); - - const afterResDataIds = tf.engine().backend.numDataIds(); - expect(afterResDataIds).toEqual(beforeDataIds + 7); - - indices.dispose(); - values.dispose(); - denseShape.dispose(); - result.outputIndices.dispose(); - result.outputValues.dispose(); - result.emptyRowIndicator.dispose(); - result.reverseIndexMap.dispose(); - - const afterDisposeDataIds = tf.engine().backend.numDataIds(); - expect(afterDisposeDataIds).toEqual(beforeDataIds); - }); - - it('throw error if dense rows is empty and indices is not', async () => { - const sparseTensor = { - ind: tf.tensor2d([[0, 0]], [1, 2], 'int32'), - val: [1], - shape: [0, 5], - }; - expect( - () => tf.sparse.sparseFillEmptyRows( - sparseTensor.ind, sparseTensor.val, sparseTensor.shape, -1)) - .toThrowError(/indices\.shape\[0\] = 1/); - }); - - it('throw error if negative row', async () => { - const sparseTensor = { - ind: tf.tensor2d([[-1, 0]], [1, 2], 'int32'), - val: [1], - shape: [5, 5], - }; - expect( - () => tf.sparse.sparseFillEmptyRows( - sparseTensor.ind, sparseTensor.val, sparseTensor.shape, -1)) - .toThrowError('indices(0, 0) is invalid: -1 < 0'); - }); - - it('throw error if row exceeds number of dense rows', async () => { - const sparseTensor = { - ind: tf.tensor2d([[5, 0]], [1, 2], 'int32'), - val: [1], - shape: [5, 5], - }; - expect( - () => tf.sparse.sparseFillEmptyRows( - sparseTensor.ind, sparseTensor.val, sparseTensor.shape, -1)) - .toThrowError('indices(0, 0) is invalid: 5 >= 5'); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/sparse/sparse_fill_empty_rows_util.ts b/tfjs-master/tfjs-core/src/ops/sparse/sparse_fill_empty_rows_util.ts deleted file mode 100644 index 6b4e8c218..000000000 --- a/tfjs-master/tfjs-core/src/ops/sparse/sparse_fill_empty_rows_util.ts +++ /dev/null @@ -1,50 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -/** - * Generates sparse fill empty rows indices, dense shape mismatch error message. - * - * @param indicesLength The first dimension of indices. - */ -export function getSparseFillEmptyRowsIndicesDenseShapeMismatch( - indicesLength: number) { - return `Received SparseTensor with denseShape[0] = 0 but - indices.shape[0] = ${indicesLength}`; -} - -/** - * Generates sparse fill empty rows negative index error message. - * - * @param index The index with a negative value. - * @param value The negative value. - */ -export function getSparseFillEmptyRowsNegativeIndexErrorMessage( - index: number, value: number) { - return `indices(${index}, 0) is invalid: ${value} < 0`; -} - -/** - * Generates sparse fill empty rows out of range index error message. - * - * @param index The index with an out of range value. - * @param value The out of range value. - * @param limit The upper limit for indices. - */ -export function getSparseFillEmptyRowsOutOfRangeIndexErrorMessage( - index: number, value: number, limit: number) { - return `indices(${index}, 0) is invalid: ${value} >= ${limit}`; -} diff --git a/tfjs-master/tfjs-core/src/ops/sparse/sparse_reshape.ts b/tfjs-master/tfjs-core/src/ops/sparse/sparse_reshape.ts deleted file mode 100644 index 5bd750c7e..000000000 --- a/tfjs-master/tfjs-core/src/ops/sparse/sparse_reshape.ts +++ /dev/null @@ -1,92 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../../engine'; -import {SparseReshape, SparseReshapeInputs} from '../../kernel_names'; -import {Tensor, Tensor1D, Tensor2D} from '../../tensor'; -import {NamedTensorMap} from '../../tensor_types'; -import {convertToTensor} from '../../tensor_util_env'; -import {TensorLike} from '../../types'; -import {op} from '../operation'; - -/** - * This operation has the same semantics as reshape on the represented dense - * tensor. The `inputIndices` are recomputed based on the requested `newShape`. - * If one component of `newShape` is the special value -1, the size of that - * dimension is computed so that the total dense size remains constant. At most - * one component of `newShape` can be -1. The number of dense elements implied - * by `newShape` must be the same as the number of dense elements originally - * implied by `inputShape`. Reshaping does not affect the order of values in the - * SparseTensor. If the input tensor has rank R_in and N non-empty values, and - * `newShape` has length R_out, then `inputIndices` has shape [N, R_in], - * `inputShape` has length R_in, `outputIndices` has shape [N, R_out], and - * `outputShape` has length R_out. - * - * ```js - * const result = tf.sparse.sparseReshape( - * [[0, 0, 0], [0, 0, 1], [0, 1, 0], [1, 0, 0], [1, 2, 3]], - * [2, 3, 6], [9, -1]); - * console.log(result); - * result['outputIndices'].print(); //[[0, 0], [0, 1], [1, 2], [4, 2], [8, 1]] - * result['outputShape'].print(); // [9, 4] - * ``` - * @param inputIndices: 2-D. N x R_in matrix with the indices of non-empty - * values in a SparseTensor. - * @param inputShape: 1-D. R_in Tensor1D with the input SparseTensor's dense - * shape. - * @param newShape: 1-D. R_out Tensor1D with the requested new dense shape. - * @return A map with the following properties: - * - outputIndices: 2-D. N x R_out matrix with the updated indices of - * non-empty values in the output SparseTensor. - * - outputShape: 1-D. R_out vector with the full dense shape of the output - * SparseTensor. This is the same as newShape but with any -1 dimensions - * filled in. - * @doc {heading: 'Operations', subheading: 'Sparse'} - */ -function sparseReshape_( - inputIndices: Tensor2D|TensorLike, inputShape: Tensor1D|TensorLike, - newShape: Tensor1D|TensorLike): NamedTensorMap { - const $inputIndices = - convertToTensor(inputIndices, 'inputIndices', 'sparseReshape', 'int32'); - const $inputShape = - convertToTensor(inputShape, 'inputShape', 'sparseReshape', 'int32'); - const $newShape = - convertToTensor(newShape, 'newShape', 'sparseReshape', 'int32'); - - if ($inputIndices.rank !== 2) { - throw new Error(`Input indices should be Tensor2D but received shape - ${$inputIndices.shape}`); - } - if ($inputShape.rank !== 1) { - throw new Error(`Input shape should be Tensor1D but received shape ${ - $inputShape.shape}`); - } - if ($newShape.rank !== 1) { - throw new Error( - `New shape should be Tensor1D but received shape ${$newShape.shape}`); - } - - const inputs: SparseReshapeInputs = { - inputIndices: $inputIndices, - inputShape: $inputShape, - newShape: $newShape - }; - const result: Tensor[] = ENGINE.runKernel(SparseReshape, inputs as {}); - return {outputIndices: result[0], outputShape: result[1]}; -} - -export const sparseReshape = /* @__PURE__ */ op({sparseReshape_}); diff --git a/tfjs-master/tfjs-core/src/ops/sparse/sparse_reshape_test.ts b/tfjs-master/tfjs-core/src/ops/sparse/sparse_reshape_test.ts deleted file mode 100644 index 9e33cc215..000000000 --- a/tfjs-master/tfjs-core/src/ops/sparse/sparse_reshape_test.ts +++ /dev/null @@ -1,188 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../../index'; -import {ALL_ENVS, describeWithFlags} from '../../jasmine_util'; -import {expectArraysClose} from '../../test_util'; - -function sparseTensorValue5x6() { - const ind = tf.tensor2d( - [[0, 0], [1, 0], [1, 3], [1, 4], [3, 2], [3, 3]], [6, 2], 'int32'); - const val = [0, 10, 13, 14, 32, 33]; - const shape = [5, 6]; - return {ind, val, shape}; -} - -function sparseTensorValue2x3x4() { - const ind = tf.tensor2d( - [ - [0, 0, 1], [0, 1, 0], [0, 1, 2], [1, 0, 3], [1, 1, 1], [1, 1, 3], - [1, 2, 2] - ], - [7, 3], 'int32'); - const val = [1, 10, 12, 103, 111, 113, 122]; - const shape = [2, 3, 4]; - return {ind, val, shape}; -} -describeWithFlags('sparseReshape', ALL_ENVS, () => { - it('preserve static shape info', async () => { - const sparseTensor = sparseTensorValue5x6(); - const result = tf.sparse.sparseReshape( - sparseTensor.ind, sparseTensor.shape, [1, 5, 2, 3]); - expectArraysClose(await result.outputShape.data(), [1, 5, 2, 3]); - }); - - it('preserve shape info with inferred dim', async () => { - const sparseTensor = sparseTensorValue2x3x4(); - const result = - tf.sparse.sparseReshape(sparseTensor.ind, sparseTensor.shape, [2, -1]); - expectArraysClose(await result.outputShape.data(), [2, 3 * 4]); - }); - - it('does not have memory leak.', async () => { - const beforeDataIds = tf.engine().backend.numDataIds(); - - const sparseTensor = sparseTensorValue5x6(); - const indices = sparseTensor.ind; - const shape = tf.tensor1d(sparseTensor.shape, 'int32'); - const newShape = tf.tensor1d([1, 5, 2, 3], 'int32'); - const result = tf.sparse.sparseReshape(indices, shape, newShape); - - await result.outputIndices.data(); - await result.outputShape.data(); - - const afterResDataIds = tf.engine().backend.numDataIds(); - expect(afterResDataIds).toEqual(beforeDataIds + 5); - - indices.dispose(); - shape.dispose(); - newShape.dispose(); - result.outputIndices.dispose(); - result.outputShape.dispose(); - - const afterDisposeDataIds = tf.engine().backend.numDataIds(); - expect(afterDisposeDataIds).toEqual(beforeDataIds); - }); - - it('throw error if more than one inferred dim', async () => { - const sparseTensor = sparseTensorValue2x3x4(); - expect(() => tf.sparse.sparseReshape(sparseTensor.ind, sparseTensor.shape, [ - -1, 2, -1 - ])).toThrowError(/only one output dimension may be -1/); - }); - - it('throw error if impossible new shape', async () => { - const sparseTensor = sparseTensorValue2x3x4(); - expect(() => tf.sparse.sparseReshape(sparseTensor.ind, sparseTensor.shape, [ - -1, 7 - ])).toThrowError(/multiple of 7/); - }); - it('throw error if negative output dim', async () => { - const sparseTensor = sparseTensorValue2x3x4(); - expect(() => tf.sparse.sparseReshape(sparseTensor.ind, sparseTensor.shape, [ - 1, -7 - ])).toThrowError('size 1 must be non-negative, not -7'); - }); - it('throw error if negative output dim', async () => { - const sparseTensor = sparseTensorValue2x3x4(); - expect(() => tf.sparse.sparseReshape(sparseTensor.ind, sparseTensor.shape, [ - -1, 0 - ])).toThrowError(/unless all specified input sizes are non-zero/); - }); - it('same shape', async () => { - const sparseTensor = sparseTensorValue5x6(); - const result = - tf.sparse.sparseReshape(sparseTensor.ind, sparseTensor.shape, [5, 6]); - expectArraysClose( - await result.outputIndices.data(), await sparseTensor.ind.data()); - expectArraysClose(await result.outputShape.data(), sparseTensor.shape); - }); - - it('same shape with inferred dim', async () => { - const sparseTensor = sparseTensorValue5x6(); - const result = - tf.sparse.sparseReshape(sparseTensor.ind, sparseTensor.shape, [-1, 6]); - expectArraysClose( - await result.outputIndices.data(), await sparseTensor.ind.data()); - expectArraysClose(await result.outputShape.data(), sparseTensor.shape); - }); - - it('new shape with same rank', async () => { - const sparseTensor = sparseTensorValue5x6(); - const result = - tf.sparse.sparseReshape(sparseTensor.ind, sparseTensor.shape, [3, 10]); - expectArraysClose( - await result.outputIndices.data(), - [[0, 0], [0, 6], [0, 9], [1, 0], [2, 0], [2, 1]]); - expectArraysClose(await result.outputShape.data(), [3, 10]); - }); - - it('new shape with same rank with inferred dim', async () => { - const sparseTensor = sparseTensorValue5x6(); - const result = - tf.sparse.sparseReshape(sparseTensor.ind, sparseTensor.shape, [3, -1]); - expectArraysClose( - await result.outputIndices.data(), - [[0, 0], [0, 6], [0, 9], [1, 0], [2, 0], [2, 1]]); - expectArraysClose(await result.outputShape.data(), [3, 10]); - }); - it('up rank', async () => { - const sparseTensor = sparseTensorValue5x6(); - const result = tf.sparse.sparseReshape( - sparseTensor.ind, sparseTensor.shape, [2, 3, 5]); - expectArraysClose( - await result.outputIndices.data(), - [[0, 0, 0], [0, 1, 1], [0, 1, 4], [0, 2, 0], [1, 1, 0], [1, 1, 1]]); - expectArraysClose(await result.outputShape.data(), [2, 3, 5]); - }); - it('up rank with inferred dim', async () => { - const sparseTensor = sparseTensorValue5x6(); - const result = tf.sparse.sparseReshape( - sparseTensor.ind, sparseTensor.shape, [2, -1, 5]); - expectArraysClose( - await result.outputIndices.data(), - [[0, 0, 0], [0, 1, 1], [0, 1, 4], [0, 2, 0], [1, 1, 0], [1, 1, 1]]); - expectArraysClose(await result.outputShape.data(), [2, 3, 5]); - }); - - it('down rank', async () => { - const sparseTensor = sparseTensorValue2x3x4(); - const result = - tf.sparse.sparseReshape(sparseTensor.ind, sparseTensor.shape, [6, 4]); - expectArraysClose( - await result.outputIndices.data(), - [[0, 1], [1, 0], [1, 2], [3, 3], [4, 1], [4, 3], [5, 2]]); - expectArraysClose(await result.outputShape.data(), [6, 4]); - }); - - it('down rank with inferred dim', async () => { - const sparseTensor = sparseTensorValue2x3x4(); - const result = - tf.sparse.sparseReshape(sparseTensor.ind, sparseTensor.shape, [6, -1]); - expectArraysClose( - await result.outputIndices.data(), - [[0, 1], [1, 0], [1, 2], [3, 3], [4, 1], [4, 3], [5, 2]]); - expectArraysClose(await result.outputShape.data(), [6, 4]); - }); - - it('throw error if mismatch size', async () => { - const sparseTensor = sparseTensorValue5x6(); - expect(() => tf.sparse.sparseReshape(sparseTensor.ind, sparseTensor.shape, [ - 4, 7 - ])).toThrowError(/Input to reshape is a tensor with 30 dense values/); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/sparse/sparse_reshape_util.ts b/tfjs-master/tfjs-core/src/ops/sparse/sparse_reshape_util.ts deleted file mode 100644 index 037d1b39c..000000000 --- a/tfjs-master/tfjs-core/src/ops/sparse/sparse_reshape_util.ts +++ /dev/null @@ -1,78 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {sizeFromShape} from '../../util'; - -/** - * Generates sparse reshape multiple negative 1 output dimension error message. - * - * @param dim1 The first dimension with a negative 1 value. - * @param dim2 The second dimension with a negative 1 value. - */ -export function getSparseReshapeMultipleNegativeOneOutputDimErrorMessage( - dim1: number, dim2: number) { - return `only one output dimension may be -1, not both ${dim1} and ${dim2}`; -} - -/** - * Generates sparse reshape negative output dimension error message. - * - * @param dim The dimension with a negative value. - * @param value The negative value. - */ -export function getSparseReshapeNegativeOutputDimErrorMessage( - dim: number, value: number) { - return `size ${dim} must be non-negative, not ${value}`; -} - -/** - * Generates sparse reshape empty tensor zero output dimension error message. - * - */ -export function getSparseReshapeEmptyTensorZeroOutputDimErrorMessage() { - return 'reshape cannot infer the missing input size for an empty tensor ' + - 'unless all specified input sizes are non-zero'; -} - -/** - * Generates sparse reshape input output multiple mismatch error message. - * - * @param inputShape the input shape. - * @param outputShape the requested output shape. - */ -export function getSparseReshapeInputOutputMultipleErrorMessage( - inputShape: number[], outputShape: number[]) { - const inputSize = sizeFromShape(inputShape); - const outputSize = sizeFromShape(outputShape); - return `Input to reshape is a SparseTensor with ${inputSize} - dense values, but the requested shape requires a multiple of ${ - outputSize}. inputShape=${inputShape} outputShape= ${outputShape}`; -} - -/** - * Generates sparse reshape input output inequality error message. - * - * @param inputShape the input shape. - * @param outputShape the requested output shape. - */ -export function getSparseReshapeInputOutputMismatchErrorMessage( - inputShape: number[], outputShape: number[]) { - const inputSize = sizeFromShape(inputShape); - const outputSize = sizeFromShape(outputShape); - return `Input to reshape is a tensor with ${ - inputSize} dense values, but the requested shape has ${ - outputSize}. inputShape=${inputShape} outputShape=${outputShape}`; -} diff --git a/tfjs-master/tfjs-core/src/ops/sparse/sparse_segment_mean.ts b/tfjs-master/tfjs-core/src/ops/sparse/sparse_segment_mean.ts deleted file mode 100644 index df5bedc8b..000000000 --- a/tfjs-master/tfjs-core/src/ops/sparse/sparse_segment_mean.ts +++ /dev/null @@ -1,90 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../../engine'; -import {SparseSegmentMean, SparseSegmentMeanInputs} from '../../kernel_names'; -import {Tensor, Tensor1D} from '../../tensor'; -import {convertToTensor} from '../../tensor_util_env'; -import {TensorLike} from '../../types'; -import {op} from '../operation'; - -/** - * Computes the mean along sparse segments of a tensor. - * - * ```js - * const c = tf.tensor2d([[1,2,3,4], [-1,-2,-3,-4], [6,7,8,9]]); - * // Select two rows, one segment. - * const result1 = tf.sparse.sparseSegmentMean(c, - * tf.tensor1d([0, 1], 'int32'), - * tf.tensor1d([0, 0], 'int32')); - * result1.print(); // [[0, 0, 0, 0]] - * - * // Select two rows, two segments. - * const result2 = tf.sparse.sparseSegmentMean(c, - * tf.tensor1d([0, 1], 'int32'), - * tf.tensor1d([0, 1], 'int32')); - * result2.print(); // [[1, 2, 3, 4], [-1, -2, -3, -4]] - * - * // Select all rows, two segments. - * const result3 = tf.sparse.sparseSegmentMean(c, - * tf.tensor1d([0, 1, 2], 'int32'), - * tf.tensor1d([0, 1, 1], 'int32')); - * result3.print(); // [[1.0, 2.0, 3.0, 4.0], [2.5, 2.5, 2.5, 2.5]] - * ``` - * @param data: A Tensor of at least one dimension with data that will be - * assembled in the output. - * @param indices: A 1-D Tensor with indices into data. Has same rank as - * segmentIds. - * @param segmentIds: A 1-D Tensor with indices into the output Tensor. Values - * should be sorted and can be repeated. - * @return Has same shape as data, except for dimension 0 which has equal to - * the number of segments. - * - * @doc {heading: 'Operations', subheading: 'Sparse'} - */ -function sparseSegmentMean_( - data: Tensor|TensorLike, indices: Tensor1D|TensorLike, - segmentIds: Tensor1D|TensorLike): Tensor { - const $data = convertToTensor(data, 'data', 'sparseSegmentMean'); - const $indices = - convertToTensor(indices, 'indices', 'sparseSegmentMean', 'int32'); - const $segmentIds = - convertToTensor(segmentIds, 'segmentIds', 'sparseSegmentMean', 'int32'); - - if ($data.rank < 1) { - throw new Error( - `Data should be at least 1 dimensional but received scalar`); - } - if ($indices.rank !== 1) { - throw new Error(`Indices should be Tensor1D but received shape - ${$indices.shape}`); - } - if ($segmentIds.rank !== 1) { - throw new Error(`Segment ids should be Tensor1D but received shape - ${$segmentIds.shape}`); - } - - const inputs: SparseSegmentMeanInputs = { - data: $data, - indices: $indices, - segmentIds: $segmentIds - }; - - return ENGINE.runKernel(SparseSegmentMean, inputs as {}); -} - -export const sparseSegmentMean = /* @__PURE__ */ op({sparseSegmentMean_}); diff --git a/tfjs-master/tfjs-core/src/ops/sparse/sparse_segment_mean_test.ts b/tfjs-master/tfjs-core/src/ops/sparse/sparse_segment_mean_test.ts deleted file mode 100644 index ac15345b8..000000000 --- a/tfjs-master/tfjs-core/src/ops/sparse/sparse_segment_mean_test.ts +++ /dev/null @@ -1,196 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../../index'; -import {ALL_ENVS, describeWithFlags} from '../../jasmine_util'; -import {expectArraysClose} from '../../test_util'; - -function TensorValue3x4Float() { - return tf.tensor2d([[1, 2, 3, 4], [-1, -2, -3, -4], [6, 7, 8, 9]]); -} - -function TensorValue3x4Integer() { - return tf.tensor2d( - [[1, 2, 3, 4], [-1, -2, -3, -4], [6, 7, 8, 9]], [3, 4], 'int32'); -} - -function TensorValue10() { - return tf.tensor1d(Array.from(Array(10), (_, i) => i + 1)); -} - -function TensorValue10x4() { - return tf.tensor2d(Array.from(Array(40), (_, i) => i + 1), [10, 4]); -} - -function TensorValue10x2x4() { - return tf.tensor3d(Array.from(Array(80), (_, i) => i + 1), [10, 2, 4]); -} - -describeWithFlags('sparseSegmentMean', ALL_ENVS, () => { - it('two rows one segment', async () => { - const result = - tf.sparse.sparseSegmentMean(TensorValue3x4Float(), [0, 1], [0, 0]); - expectArraysClose(await result.data(), [[0, 0, 0, 0]]); - }); - - it('two rows two segments', async () => { - const result = - tf.sparse.sparseSegmentMean(TensorValue3x4Float(), [0, 1], [0, 1]); - expectArraysClose(await result.data(), [[1, 2, 3, 4], [-1, -2, -3, -4]]); - }); - - it('all rows two segments', async () => { - const result = tf.sparse.sparseSegmentMean( - TensorValue3x4Float(), [0, 1, 2], [0, 1, 1]); - expectArraysClose( - await result.data(), [[1.0, 2.0, 3.0, 4.0], [2.5, 2.5, 2.5, 2.5]]); - }); - - it('integer data', async () => { - const result = tf.sparse.sparseSegmentMean( - TensorValue3x4Integer(), [0, 1, 2], [0, 1, 1]); - expectArraysClose(await result.data(), [[1, 2, 3, 4], [2, 2, 2, 2]]); - }); - - it('0 dimensional input invalid', async () => { - expect(() => tf.sparse.sparseSegmentMean(tf.scalar(1), [], [])) - .toThrowError(/should be at least 1 dimensional/); - }); - - it('1 dimensional input', async () => { - const result = tf.sparse.sparseSegmentMean( - TensorValue10(), [8, 3, 0, 9], [0, 1, 2, 2]); - expectArraysClose(await result.data(), [9, 4, 5.5]); - }); - - it('3 dimensional input', async () => { - const result = tf.sparse.sparseSegmentMean( - TensorValue10x2x4(), [8, 3, 0, 9], [0, 1, 2, 2]); - expectArraysClose(await result.data(), [ - [[65, 66, 67, 68], [69, 70, 71, 72]], - [[25, 26, 27, 28], [29, 30, 31, 32]], [[37, 38, 39, 40], [41, 42, 43, 44]] - ]); - }); - - it('segment ids hole', async () => { - const result = tf.sparse.sparseSegmentMean( - TensorValue10x4(), [8, 3, 0, 9], [0, 3, 3, 3]); - expectArraysClose( - await result.data(), - [[33, 34, 35, 36], [0, 0, 0, 0], [0, 0, 0, 0], [17, 18, 19, 20]]); - }); - - it('segment ids > zero', async () => { - const result = tf.sparse.sparseSegmentMean( - TensorValue10x4(), [8, 3, 0, 9], [2, 3, 3, 3]); - expectArraysClose( - await result.data(), - [[0, 0, 0, 0], [0, 0, 0, 0], [33, 34, 35, 36], [17, 18, 19, 20]]); - }); - - it('baseline valid', async () => { - // Baseline for the *invalid* tests below. - const result = tf.sparse.sparseSegmentMean( - TensorValue10x4(), [8, 3, 0, 9], [0, 1, 2, 2]); - expectArraysClose( - await result.data(), - [[33, 34, 35, 36], [13, 14, 15, 16], [19, 20, 21, 22]]); - }); - - it('does not have memory leak.', async () => { - const beforeDataIds = tf.engine().backend.numDataIds(); - - const data = TensorValue3x4Float(); - const indices = tf.tensor1d([0, 1], 'int32'); - const segmentIds = tf.tensor1d([0, 0], 'int32'); - const result = tf.sparse.sparseSegmentMean(data, indices, segmentIds); - - await result.data(); - - const afterResDataIds = tf.engine().backend.numDataIds(); - expect(afterResDataIds).toEqual(beforeDataIds + 4); - - data.dispose(); - indices.dispose(); - segmentIds.dispose(); - result.dispose(); - - const afterDisposeDataIds = tf.engine().backend.numDataIds(); - expect(afterDisposeDataIds).toEqual(beforeDataIds); - }); - - it('throw error if indices < 0', async () => { - expect(() => tf.sparse.sparseSegmentMean(TensorValue10x4(), [8, -1, 0, 9], [ - 0, 1, 2, 2 - ])).toThrowError(/indices\[1\] == -1 out of range \[0, 10\)/); - }); - - it('throw error if indices >= max rows', async () => { - expect(() => tf.sparse.sparseSegmentMean(TensorValue10x4(), [8, 3, 0, 10], [ - 0, 1, 2, 2 - ])).toThrowError(/indices\[3\] == 10 out of range \[0, 10\)/); - }); - - it('throw error if segment ids are not increasing', async () => { - expect(() => tf.sparse.sparseSegmentMean(TensorValue10x4(), [8, 3, 0, 9], [ - 0, 1, 0, 1 - ])).toThrowError('segment ids are not increasing'); - }); - - it('throw error if segment id is out of range', async () => { - expect( - () => tf.sparse.sparseSegmentMean( - TensorValue10x4(), [8, 3, 0, 9], [0, 1, 2, 0])) - .toThrowError( - 'Segment id 1 out of range [0, 1), possibly because segmentIds ' + - 'input is not sorted.'); - }); - - it('throw error if segment id is out of range and negative', async () => { - expect( - () => tf.sparse.sparseSegmentMean( - TensorValue10x4(), [8, 3, 0, 9], [-1, 0, 1, 1])) - .toThrowError( - 'Segment id -1 out of range [0, 2), possibly because segmentIds ' + - 'input is not sorted.'); - }); - - it('throw error if segment id is negative', async () => { - expect(() => tf.sparse.sparseSegmentMean(TensorValue10x4(), [8, 3, 0, 9], [ - 0, 0, 0, -1 - ])).toThrowError('segment ids must be >= 0'); - }); - - it('throw error if segment id is negative and there is a hole', async () => { - expect(() => tf.sparse.sparseSegmentMean(TensorValue10x4(), [8, 3, 0, 9], [ - 0, 0, 0, -2 - ])).toThrowError('segment ids must be >= 0'); - }); - - it('throw error if indices has invalid rank', async () => { - expect( - () => tf.sparse.sparseSegmentMean( - TensorValue10x4(), [[8, 3, 0, 9]], [0, 0, 0, -2])) - .toThrowError(/should be Tensor1D/); - }); - - it('throw error if segments has invalid rank', async () => { - expect(() => tf.sparse.sparseSegmentMean(TensorValue10x4(), [8, 3, 0, 9], [ - [0, 0, 0, -2] - ])).toThrowError(/should be Tensor1D/); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/sparse/sparse_segment_reduction_util.ts b/tfjs-master/tfjs-core/src/ops/sparse/sparse_segment_reduction_util.ts deleted file mode 100644 index c645112cc..000000000 --- a/tfjs-master/tfjs-core/src/ops/sparse/sparse_segment_reduction_util.ts +++ /dev/null @@ -1,57 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -/** - * Generates sparse segment reduction negative segment ids error message. - * - */ -export function getSparseSegmentReductionNegativeSegmentIdsErrorMessage() { - return `segment ids must be >= 0`; -} - -/** - * Generates sparse segment reduction non increasing segment ids error message. - * - */ -export function getSparseSegmentReductionNonIncreasingSegmentIdsErrorMessage() { - return `segment ids are not increasing`; -} - -/** - * Generates sparse segment reduction segment id out of range error message. - * - * @param segmentId The segment id index that is out of range. - * @param outputRows Upper bound of valid segment id values. - */ -export function getSparseSegmentReductionSegmentIdOutOfRangeErrorMessage( - segmentId: number, outputRows: number) { - return `Segment id ${segmentId} out of range [0, ${ - outputRows}), possibly because segmentIds input is not sorted.`; -} - -/** - * Generates sparse segment reduction input indice out of range error message. - * - * @param index The index that holds the out of range value. - * @param indexValue The value that is out of range. - * @param inputRows Upper bound of valid index values. - */ -export function getSparseSegmentReductionIndicesOutOfRangeErrorMessage( - index: number, indexValue: number, inputRows: number) { - return `Bad: indices[${index}] == ${indexValue} out of range [0, ${ - inputRows})`; -} diff --git a/tfjs-master/tfjs-core/src/ops/sparse/sparse_segment_sum.ts b/tfjs-master/tfjs-core/src/ops/sparse/sparse_segment_sum.ts deleted file mode 100644 index 23d64f1e5..000000000 --- a/tfjs-master/tfjs-core/src/ops/sparse/sparse_segment_sum.ts +++ /dev/null @@ -1,90 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../../engine'; -import {SparseSegmentSum, SparseSegmentSumInputs} from '../../kernel_names'; -import {Tensor, Tensor1D} from '../../tensor'; -import {convertToTensor} from '../../tensor_util_env'; -import {TensorLike} from '../../types'; -import {op} from '../operation'; - -/** - * Computes the sum along sparse segments of a tensor. - * - * ```js - * const c = tf.tensor2d([[1,2,3,4], [-1,-2,-3,-4], [5,6,7,8]]); - * // Select two rows, one segment. - * const result1 = tf.sparse.sparseSegmentSum(c, - * tf.tensor1d([0, 1], 'int32'), - * tf.tensor1d([0, 0], 'int32')); - * result1.print(); // [[0, 0, 0, 0]] - * - * // Select two rows, two segments. - * const result2 = tf.sparse.sparseSegmentSum(c, - * tf.tensor1d([0, 1], 'int32'), - * tf.tensor1d([0, 1], 'int32')); - * result2.print(); // [[1, 2, 3, 4], [-1, -2, -3, -4]] - * - * // Select all rows, two segments. - * const result3 = tf.sparse.sparseSegmentSum(c, - * tf.tensor1d([0, 1, 2], 'int32'), - * tf.tensor1d([0, 0, 1], 'int32')); - * result3.print(); // [[0, 0, 0, 0], [5, 6, 7, 8]] - * ``` - * @param data: A Tensor of at least one dimension with data that will be - * assembled in the output. - * @param indices: A 1-D Tensor with indices into data. Has same rank as - * segmentIds. - * @param segmentIds: A 1-D Tensor with indices into the output Tensor. Values - * should be sorted and can be repeated. - * @return Has same shape as data, except for dimension 0 which has equal to - * the number of segments. - * - * @doc {heading: 'Operations', subheading: 'Sparse'} - */ -function sparseSegmentSum_( - data: Tensor|TensorLike, indices: Tensor1D|TensorLike, - segmentIds: Tensor1D|TensorLike): Tensor { - const $data = convertToTensor(data, 'data', 'sparseSegmentSum'); - const $indices = - convertToTensor(indices, 'indices', 'sparseSegmentSum', 'int32'); - const $segmentIds = - convertToTensor(segmentIds, 'segmentIds', 'sparseSegmentSum', 'int32'); - - if ($data.rank < 1) { - throw new Error( - `Data should be at least 1 dimensional but received scalar`); - } - if ($indices.rank !== 1) { - throw new Error(`Indices should be Tensor1D but received shape - ${$indices.shape}`); - } - if ($segmentIds.rank !== 1) { - throw new Error(`Segment ids should be Tensor1D but received shape - ${$segmentIds.shape}`); - } - - const inputs: SparseSegmentSumInputs = { - data: $data, - indices: $indices, - segmentIds: $segmentIds - }; - - return ENGINE.runKernel(SparseSegmentSum, inputs as {}); -} - -export const sparseSegmentSum = /* @__PURE__ */ op({sparseSegmentSum_}); diff --git a/tfjs-master/tfjs-core/src/ops/sparse/sparse_segment_sum_test.ts b/tfjs-master/tfjs-core/src/ops/sparse/sparse_segment_sum_test.ts deleted file mode 100644 index a0c7fdcf0..000000000 --- a/tfjs-master/tfjs-core/src/ops/sparse/sparse_segment_sum_test.ts +++ /dev/null @@ -1,181 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../../index'; -import {ALL_ENVS, describeWithFlags} from '../../jasmine_util'; -import {expectArraysClose} from '../../test_util'; - -function TensorValue3x4() { - return tf.tensor2d([[1, 2, 3, 4], [-1, -2, -3, -4], [5, 6, 7, 8]]); -} - -function TensorValue10() { - return tf.tensor1d(Array.from(Array(10), (_, i) => i + 1)); -} - -function TensorValue10x4() { - return tf.tensor2d(Array.from(Array(40), (_, i) => i + 1), [10, 4]); -} - -function TensorValue10x2x4() { - return tf.tensor3d(Array.from(Array(80), (_, i) => i + 1), [10, 2, 4]); -} - -describeWithFlags('sparseSegmentSum', ALL_ENVS, () => { - it('two rows one segment', async () => { - const result = tf.sparse.sparseSegmentSum(TensorValue3x4(), [0, 1], [0, 0]); - expectArraysClose(await result.data(), [[0, 0, 0, 0]]); - }); - - it('two rows two segments', async () => { - const result = tf.sparse.sparseSegmentSum(TensorValue3x4(), [0, 1], [0, 1]); - expectArraysClose(await result.data(), [[1, 2, 3, 4], [-1, -2, -3, -4]]); - }); - - it('all rows one segment', async () => { - const result = - tf.sparse.sparseSegmentSum(TensorValue3x4(), [0, 1, 2], [0, 0, 1]); - expectArraysClose(await result.data(), [[0, 0, 0, 0], [5, 6, 7, 8]]); - }); - - it('0 dimensional input invalid', async () => { - expect(() => tf.sparse.sparseSegmentSum(tf.scalar(1), [], [])) - .toThrowError(/should be at least 1 dimensional/); - }); - - it('1 dimensional input', async () => { - const result = - tf.sparse.sparseSegmentSum(TensorValue10(), [8, 3, 0, 9], [0, 1, 2, 2]); - expectArraysClose(await result.data(), [9, 4, 11]); - }); - - it('3 dimensional input', async () => { - const result = tf.sparse.sparseSegmentSum( - TensorValue10x2x4(), [8, 3, 0, 9], [0, 1, 2, 2]); - expectArraysClose(await result.data(), [ - [[65, 66, 67, 68], [69, 70, 71, 72]], - [[25, 26, 27, 28], [29, 30, 31, 32]], [[74, 76, 78, 80], [82, 84, 86, 88]] - ]); - }); - - it('segment ids hole', async () => { - const result = tf.sparse.sparseSegmentSum( - TensorValue10x4(), [8, 3, 0, 9], [0, 3, 3, 3]); - expectArraysClose( - await result.data(), - [[33, 34, 35, 36], [0, 0, 0, 0], [0, 0, 0, 0], [51, 54, 57, 60]]); - }); - - it('segment ids > zero', async () => { - const result = tf.sparse.sparseSegmentSum( - TensorValue10x4(), [8, 3, 0, 9], [2, 3, 3, 3]); - expectArraysClose( - await result.data(), - [[0, 0, 0, 0], [0, 0, 0, 0], [33, 34, 35, 36], [51, 54, 57, 60]]); - }); - - it('baseline valid', async () => { - // Baseline for the *invalid* tests below. - const result = tf.sparse.sparseSegmentSum( - TensorValue10x4(), [8, 3, 0, 9], [0, 1, 2, 2]); - expectArraysClose( - await result.data(), - [[33, 34, 35, 36], [13, 14, 15, 16], [38, 40, 42, 44]]); - }); - - it('does not have memory leak.', async () => { - const beforeDataIds = tf.engine().backend.numDataIds(); - - const data = TensorValue3x4(); - const indices = tf.tensor1d([0, 1], 'int32'); - const segmentIds = tf.tensor1d([0, 0], 'int32'); - const result = tf.sparse.sparseSegmentSum(data, indices, segmentIds); - - await result.data(); - - const afterResDataIds = tf.engine().backend.numDataIds(); - expect(afterResDataIds).toEqual(beforeDataIds + 4); - - data.dispose(); - indices.dispose(); - segmentIds.dispose(); - result.dispose(); - - const afterDisposeDataIds = tf.engine().backend.numDataIds(); - expect(afterDisposeDataIds).toEqual(beforeDataIds); - }); - - it('indices invalid 1', async () => { - expect(() => tf.sparse.sparseSegmentSum(TensorValue10x4(), [8, -1, 0, 9], [ - 0, 1, 2, 2 - ])).toThrowError(/indices\[1\] == -1 out of range \[0, 10\)/); - }); - - it('indices invalid 2', async () => { - expect(() => tf.sparse.sparseSegmentSum(TensorValue10x4(), [8, 3, 0, 10], [ - 0, 1, 2, 2 - ])).toThrowError(/indices\[3\] == 10 out of range \[0, 10\)/); - }); - - it('segments invalid 2', async () => { - expect(() => tf.sparse.sparseSegmentSum(TensorValue10x4(), [8, 3, 0, 9], [ - 0, 1, 0, 1 - ])).toThrowError('segment ids are not increasing'); - }); - - it('segments invalid 3', async () => { - expect( - () => tf.sparse.sparseSegmentSum( - TensorValue10x4(), [8, 3, 0, 9], [0, 1, 2, 0])) - .toThrowError( - 'Segment id 1 out of range [0, 1), possibly because segmentIds ' + - 'input is not sorted.'); - }); - - it('segments invalid 4', async () => { - expect( - () => tf.sparse.sparseSegmentSum( - TensorValue10x4(), [8, 3, 0, 9], [-1, 0, 1, 1])) - .toThrowError( - 'Segment id -1 out of range [0, 2), possibly because segmentIds ' + - 'input is not sorted.'); - }); - - it('segments invalid 6', async () => { - expect(() => tf.sparse.sparseSegmentSum(TensorValue10x4(), [8, 3, 0, 9], [ - 0, 0, 0, -1 - ])).toThrowError('segment ids must be >= 0'); - }); - - it('segments invalid 7', async () => { - expect(() => tf.sparse.sparseSegmentSum(TensorValue10x4(), [8, 3, 0, 9], [ - 0, 0, 0, -2 - ])).toThrowError('segment ids must be >= 0'); - }); - - it('indices invalid rank', async () => { - expect(() => tf.sparse.sparseSegmentSum(TensorValue10x4(), [[8, 3, 0, 9]], [ - 0, 0, 0, -2 - ])).toThrowError(/should be Tensor1D/); - }); - - it('segments invalid rank', async () => { - expect(() => tf.sparse.sparseSegmentSum(TensorValue10x4(), [8, 3, 0, 9], [ - [0, 0, 0, -2] - ])).toThrowError(/should be Tensor1D/); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/sparse_to_dense.ts b/tfjs-master/tfjs-core/src/ops/sparse_to_dense.ts deleted file mode 100644 index e7c22898d..000000000 --- a/tfjs-master/tfjs-core/src/ops/sparse_to_dense.ts +++ /dev/null @@ -1,96 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {SparseToDense, SparseToDenseAttrs, SparseToDenseInputs} from '../kernel_names'; -import {NamedAttrMap} from '../kernel_registry'; -import * as sparse_to_dense from '../ops/sparse_to_dense_util'; -import {Scalar, Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {Rank, ScalarLike, ShapeMap, TensorLike} from '../types'; -import {assertNonNegativeIntegerDimensions} from '../util_base'; - -import {op} from './operation'; - -/** - * Converts a sparse representation into a dense tensor. - * - * Builds an array dense with shape outputShape such that: - * - * // If sparseIndices is scalar - * dense[i] = (i == sparseIndices ? sparseValues : defaultValue) - * - * // If sparseIndices is a vector, then for each i - * dense[sparseIndices[i]] = sparseValues[i] - * - * // If sparseIndices is an n by d matrix, then for each i in [0, n) - * dense[sparseIndices[i][0], ..., sparseIndices[i][d-1]] = sparseValues[i] - * All other values in dense are set to defaultValue. If sparseValues is a - * scalar, all sparse indices are set to this single value. - * - * If indices are repeated the final value is summed over all values for those - * indices. - * - * ```js - * const indices = tf.tensor1d([4, 5, 6, 1, 2, 3], 'int32'); - * const values = tf.tensor1d([10, 11, 12, 13, 14, 15], 'float32'); - * const shape = [8]; - * tf.sparseToDense(indices, values, shape).print(); - * ``` - * - * @param sparseIndices A 0-D, 1-D, or 2-D Tensor of type int32. - * sparseIndices[i] contains the complete index where sparseValues[i] will be - * placed. - * @param sparseValues A 0-D or 1-D Tensor. Values - * corresponding to each row of sparseIndices, or a scalar value to be used for - * all sparse indices. - * @param outputShape Shape of the dense output tensor. The type is inferred. - * @param defaultValue Scalar. Value to set for indices not specified in - * sparseIndices. Defaults to zero. - * - * @doc {heading: 'Operations', subheading: 'Normalization'} - */ -function sparseToDense_( - sparseIndices: Tensor|TensorLike, sparseValues: Tensor|TensorLike, - outputShape: ShapeMap[R], defaultValue: Scalar|ScalarLike = 0): Tensor { - assertNonNegativeIntegerDimensions(outputShape); - - const $sparseIndices = - convertToTensor(sparseIndices, 'sparseIndices', 'sparseToDense', 'int32'); - const $sparseValues = convertToTensor( - sparseValues, 'sparseValues', 'sparseToDense', 'string_or_numeric'); - const $defaultValue = convertToTensor( - defaultValue, 'defaultValue', 'sparseToDense', $sparseValues.dtype); - - sparse_to_dense.validateInput( - $sparseIndices, $sparseValues, outputShape, $defaultValue); - - const inputs: SparseToDenseInputs = { - sparseIndices: $sparseIndices, - sparseValues: $sparseValues, - defaultValue: $defaultValue - }; - - const attrs: SparseToDenseAttrs = {outputShape}; - - return ENGINE.runKernel( - SparseToDense, inputs as unknown as NamedTensorMap, - attrs as unknown as NamedAttrMap); -} - -export const sparseToDense = /* @__PURE__ */ op({sparseToDense_}); diff --git a/tfjs-master/tfjs-core/src/ops/sparse_to_dense_test.ts b/tfjs-master/tfjs-core/src/ops/sparse_to_dense_test.ts deleted file mode 100644 index acb6195ab..000000000 --- a/tfjs-master/tfjs-core/src/ops/sparse_to_dense_test.ts +++ /dev/null @@ -1,160 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose, expectArraysEqual} from '../test_util'; - -let defaultValue: tf.Scalar; -describeWithFlags('sparseToDense', ALL_ENVS, () => { - beforeEach(() => defaultValue = tf.scalar(0, 'int32')); - it('should work for scalar indices', async () => { - const indices = tf.scalar(2, 'int32'); - const values = tf.scalar(100, 'int32'); - const shape = [6]; - const result = tf.sparseToDense(indices, values, shape, defaultValue); - expect(result.shape).toEqual(shape); - expect(result.dtype).toEqual(values.dtype); - expectArraysClose(await result.data(), [0, 0, 100, 0, 0, 0]); - }); - it('should work for vector', async () => { - const indices = tf.tensor1d([0, 2, 4], 'int32'); - const values = tf.tensor1d([100, 101, 102], 'int32'); - const shape = [6]; - const result = tf.sparseToDense(indices, values, shape, defaultValue); - expect(result.shape).toEqual(shape); - expect(result.dtype).toEqual(values.dtype); - expectArraysClose(await result.data(), [100, 0, 101, 0, 102, 0]); - }); - it('should work for scalar value', async () => { - const indices = tf.tensor1d([0, 2, 4], 'int32'); - const values = tf.scalar(10, 'int32'); - const shape = [6]; - const result = tf.sparseToDense(indices, values, shape, defaultValue); - expect(result.shape).toEqual(shape); - expect(result.dtype).toEqual(values.dtype); - expectArraysClose(await result.data(), [10, 0, 10, 0, 10, 0]); - }); - it('should work for matrix', async () => { - const indices = tf.tensor2d([0, 1, 1, 1], [2, 2], 'int32'); - const values = tf.tensor1d([5, 6], 'float32'); - const shape = [2, 2]; - const result = - tf.sparseToDense(indices, values, shape, defaultValue.toFloat()); - expect(result.shape).toEqual(shape); - expect(result.dtype).toEqual(values.dtype); - expectArraysClose(await result.data(), [0, 5, 0, 6]); - }); - it('should work for string', async () => { - const indices = tf.tensor2d([0, 1, 1, 1], [2, 2], 'int32'); - const values = tf.tensor1d(['a', 'b'], 'string'); - const shape = [2, 2]; - const result = - tf.sparseToDense(indices, values, shape, tf.scalar('c', 'string')); - expect(result.shape).toEqual(shape); - expect(result.dtype).toEqual(values.dtype); - expectArraysEqual(await result.data(), ['c', 'a', 'c', 'b']); - }); - - it('should throw exception if default value does not match dtype', () => { - const indices = tf.tensor2d([0, 1, 1, 1], [2, 2], 'int32'); - const values = tf.tensor1d([5, 6], 'float32'); - const shape = [2, 2]; - expect( - () => tf.sparseToDense(indices, values, shape, tf.scalar(1, 'int32'))) - .toThrowError(); - }); - - it('should allow setting default value', async () => { - const indices = tf.tensor2d([0, 1, 1, 1], [2, 2], 'int32'); - const values = tf.tensor1d([5, 6], 'float32'); - const shape = [2, 2]; - const result = tf.sparseToDense(indices, values, shape, tf.scalar(1)); - expect(result.shape).toEqual(shape); - expect(result.dtype).toEqual(values.dtype); - expectArraysClose(await result.data(), [1, 5, 1, 6]); - }); - - it('no default value passed', async () => { - const indices = tf.tensor2d([0, 1, 1, 1], [2, 2], 'int32'); - const values = tf.tensor1d([5, 6], 'float32'); - const shape = [2, 2]; - const result = tf.sparseToDense(indices, values, shape); - expect(result.shape).toEqual(shape); - expect(result.dtype).toEqual(values.dtype); - expectArraysClose(await result.data(), [0, 5, 0, 6]); - }); - - it('should support TensorLike inputs', async () => { - const indices = [[0, 1], [1, 1]]; - const values = [5, 6]; - const shape = [2, 2]; - const result = - tf.sparseToDense(indices, values, shape, defaultValue.toFloat()); - expect(result.shape).toEqual(shape); - expect(result.dtype).toEqual('float32'); - expectArraysClose(await result.data(), [0, 5, 0, 6]); - }); - - it('should work with 0-sized tensors', async () => { - const indices = tf.zeros([0], 'int32'); - const values = tf.zeros([0]); - const defaultValue = tf.scalar(5); - const result = tf.sparseToDense(indices, values, [3], defaultValue); - expectArraysClose(await result.data(), [5, 5, 5]); - }); - - it('should throw error when indices are not int32', () => { - const indices = tf.scalar(2, 'float32'); - const values = tf.scalar(100, 'int32'); - const shape = [6]; - expect(() => tf.sparseToDense(indices, values, shape, defaultValue)) - .toThrow(); - }); - - it('should throw error when indices rank > 2', () => { - const indices = tf.tensor3d([1], [1, 1, 1], 'int32'); - const values = tf.tensor1d([100], 'float32'); - const shape = [6]; - expect(() => tf.sparseToDense(indices, values, shape, defaultValue)) - .toThrow(); - }); - - it('should throw error when values has rank > 1', () => { - const indices = tf.tensor1d([0, 4, 2], 'int32'); - const values = tf.tensor2d([1.0, 2.0, 3.0], [3, 1], 'float32'); - const shape = [6]; - expect(() => tf.sparseToDense(indices, values, shape, defaultValue)) - .toThrow(); - }); - - it('should throw error when values has wrong size', () => { - const indices = tf.tensor1d([0, 4, 2], 'int32'); - const values = tf.tensor1d([1.0, 2.0, 3.0, 4.0], 'float32'); - const shape = [6]; - expect(() => tf.sparseToDense(indices, values, shape, defaultValue)) - .toThrow(); - }); - - it('should throw error when shape is not integer', () => { - const indices = [[0, 1], [1, 1]]; - const values = [5, 6]; - const shape = [2.22, 2.22]; - expect(() => tf.sparseToDense(indices, values, shape, tf.scalar(1))) - .toThrow(); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/sparse_to_dense_util.ts b/tfjs-master/tfjs-core/src/ops/sparse_to_dense_util.ts deleted file mode 100644 index 88e326ff8..000000000 --- a/tfjs-master/tfjs-core/src/ops/sparse_to_dense_util.ts +++ /dev/null @@ -1,66 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {Tensor} from '../tensor'; - -/** - * Validate sparseToDense inputs. - * - * @param sparseIndices A 0-D, 1-D, or 2-D Tensor of type int32. - * sparseIndices[i] contains the complete index where sparseValues[i] will be - * placed. - * @param sparseValues A 0-D or 1-D Tensor. Values - * corresponding to each row of sparseIndices, or a scalar value to be used for - * all sparse indices. - * @param outputShape number[]. Shape of the dense output tensor. - * @param validateIndices boolean. indice validation is not supported, error - * will be thrown if it is set. - */ -export function validateInput( - sparseIndices: Tensor, sparseValues: Tensor, outputShape: number[], - defaultValues: Tensor) { - if (sparseIndices.dtype !== 'int32') { - throw new Error( - 'tf.sparseToDense() expects the indices to be int32 type,' + - ` but the dtype was ${sparseIndices.dtype}.`); - } - if (sparseIndices.rank > 2) { - throw new Error( - 'sparseIndices should be a scalar, vector, or matrix,' + - ` but got shape ${sparseIndices.shape}.`); - } - - const numElems = sparseIndices.rank > 0 ? sparseIndices.shape[0] : 1; - const numDims = sparseIndices.rank > 1 ? sparseIndices.shape[1] : 1; - - if (outputShape.length !== numDims) { - throw new Error( - 'outputShape has incorrect number of elements:,' + - ` ${outputShape.length}, should be: ${numDims}.`); - } - - const numValues = sparseValues.size; - if (!(sparseValues.rank === 0 || - sparseValues.rank === 1 && numValues === numElems)) { - throw new Error( - 'sparseValues has incorrect shape ' + - `${sparseValues.shape}, should be [] or [${numElems}]`); - } - - if (sparseValues.dtype !== defaultValues.dtype) { - throw new Error('sparseValues.dtype must match defaultValues.dtype'); - } -} diff --git a/tfjs-master/tfjs-core/src/ops/spectral/fft.ts b/tfjs-master/tfjs-core/src/ops/spectral/fft.ts deleted file mode 100644 index 287be8801..000000000 --- a/tfjs-master/tfjs-core/src/ops/spectral/fft.ts +++ /dev/null @@ -1,53 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../../engine'; -import {FFT, FFTInputs} from '../../kernel_names'; -import {Tensor} from '../../tensor'; -import {NamedTensorMap} from '../../tensor_types'; -import {assert} from '../../util'; -import {op} from '../operation'; - -/** - * Fast Fourier transform. - * - * Computes the 1-dimensional discrete Fourier transform over the inner-most - * dimension of input. - * - * ```js - * const real = tf.tensor1d([1, 2, 3]); - * const imag = tf.tensor1d([1, 2, 3]); - * const x = tf.complex(real, imag); - * - * x.fft().print(); // tf.spectral.fft(x).print(); - * ``` - * @param input The complex input to compute an fft over. - * - * @doc {heading: 'Operations', subheading: 'Spectral', namespace: 'spectral'} - */ -function fft_(input: Tensor): Tensor { - assert( - input.dtype === 'complex64', - () => `The dtype for tf.spectral.fft() must be complex64 ` + - `but got ${input.dtype}.`); - - const inputs: FFTInputs = {input}; - - return ENGINE.runKernel(FFT, inputs as unknown as NamedTensorMap); -} - -export const fft = /* @__PURE__ */ op({fft_}); diff --git a/tfjs-master/tfjs-core/src/ops/spectral/fft_test.ts b/tfjs-master/tfjs-core/src/ops/spectral/fft_test.ts deleted file mode 100644 index 4d48d0154..000000000 --- a/tfjs-master/tfjs-core/src/ops/spectral/fft_test.ts +++ /dev/null @@ -1,104 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../../index'; -import {ALL_ENVS, describeWithFlags} from '../../jasmine_util'; -import {expectArraysClose} from '../../test_util'; - -describeWithFlags('1D FFT', ALL_ENVS, () => { - it('should return the same value with TensorFlow (2 elements)', async () => { - const t1Real = tf.tensor1d([1, 2]); - const t1Imag = tf.tensor1d([1, 1]); - const t1 = tf.complex(t1Real, t1Imag); - expectArraysClose(await tf.spectral.fft(t1).data(), [3, 2, -1, 0]); - }); - - it('should calculate FFT from Tensor directly', async () => { - const t1Real = tf.tensor1d([1, 2]); - const t1Imag = tf.tensor1d([1, 1]); - const t1 = tf.complex(t1Real, t1Imag); - expectArraysClose(await t1.fft().data(), [3, 2, -1, 0]); - }); - - it('should return the same value as TensorFlow (3 elements)', async () => { - const t1Real = tf.tensor1d([1, 2, 3]); - const t1Imag = tf.tensor1d([0, 0, 0]); - const t1 = tf.complex(t1Real, t1Imag); - expectArraysClose( - await tf.spectral.fft(t1).data(), - [6, 0, -1.5, 0.866025, -1.5, -0.866025]); - }); - - it('should return the same value as TensorFlow with imaginary (3 elements)', - async () => { - const t1Real = tf.tensor1d([1, 2, 3]); - const t1Imag = tf.tensor1d([1, 2, 3]); - const t1 = tf.complex(t1Real, t1Imag); - expectArraysClose( - await tf.spectral.fft(t1).data(), - [6, 6, -2.3660252, -0.63397473, -0.6339747, -2.3660254]); - }); - - it('should return the same value as TensorFlow (negative 3 elements)', - async () => { - const t1Real = tf.tensor1d([-1, -2, -3]); - const t1Imag = tf.tensor1d([-1, -2, -3]); - const t1 = tf.complex(t1Real, t1Imag); - expectArraysClose( - await tf.spectral.fft(t1).data(), - [-5.9999995, -6, 2.3660252, 0.63397473, 0.6339747, 2.3660254]); - }); - - it('should return the same value with TensorFlow (4 elements)', async () => { - const t1Real = tf.tensor1d([1, 2, 3, 4]); - const t1Imag = tf.tensor1d([0, 0, 0, 0]); - const t1 = tf.complex(t1Real, t1Imag); - expectArraysClose( - await tf.spectral.fft(t1).data(), [10, 0, -2, 2, -2, 0, -2, -2]); - }); - - it('should return the same value as TensorFlow with imaginary (4 elements)', - async () => { - const t1Real = tf.tensor1d([1, 2, 3, 4]); - const t1Imag = tf.tensor1d([1, 2, 3, 4]); - const t1 = tf.complex(t1Real, t1Imag); - expectArraysClose( - await tf.spectral.fft(t1).data(), [10, 10, -4, 0, -2, -2, 0, -4]); - }); -}); - -describeWithFlags('2D FFT', ALL_ENVS, () => { - it('2D: should return the same value as TensorFlow', async () => { - const t1Real = tf.tensor2d([1, 2, 3, 4], [2, 2]); - const t1Imag = tf.tensor2d([5, 6, 7, 8], [2, 2]); - const t1 = tf.complex(t1Real, t1Imag); - const y = tf.spectral.fft(t1); - expectArraysClose(await y.data(), [3, 11, -1, -1, 7, 15, -1, -1]); - expect(y.shape).toEqual(t1Real.shape); - }); - - it('3D: should return the same value as TensorFlow', async () => { - const t1Real = tf.tensor3d([1, 2, 3, 4, -1, -2, -3, -4], [2, 2, 2]); - const t1Imag = tf.tensor3d([5, 6, 7, 8, -5, -6, -7, -8], [2, 2, 2]); - const t1 = tf.complex(t1Real, t1Imag); - const y = tf.spectral.fft(t1); - expectArraysClose( - await y.data(), - [3, 11, -1, -1, 7, 15, -1, -1, -3, -11, 1, 1, -7, -15, 1, 1]); - expect(y.shape).toEqual(t1Real.shape); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/spectral/ifft.ts b/tfjs-master/tfjs-core/src/ops/spectral/ifft.ts deleted file mode 100644 index 541c7c42e..000000000 --- a/tfjs-master/tfjs-core/src/ops/spectral/ifft.ts +++ /dev/null @@ -1,53 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../../engine'; -import {IFFT, IFFTInputs} from '../../kernel_names'; -import {Tensor} from '../../tensor'; -import {NamedTensorMap} from '../../tensor_types'; -import {assert} from '../../util'; -import {op} from '../operation'; - -/** - * Inverse fast Fourier transform. - * - * Computes the inverse 1-dimensional discrete Fourier transform over the - * inner-most dimension of input. - * - * ```js - * const real = tf.tensor1d([1, 2, 3]); - * const imag = tf.tensor1d([1, 2, 3]); - * const x = tf.complex(real, imag); - * - * x.ifft().print(); // tf.spectral.ifft(x).print(); - * ``` - * @param input The complex input to compute an ifft over. - * - * @doc {heading: 'Operations', subheading: 'Spectral', namespace: 'spectral'} - */ -function ifft_(input: Tensor): Tensor { - assert( - input.dtype === 'complex64', - () => `The dtype for tf.spectral.ifft() must be complex64 ` + - `but got ${input.dtype}.`); - - const inputs: IFFTInputs = {input}; - - return ENGINE.runKernel(IFFT, inputs as unknown as NamedTensorMap); -} - -export const ifft = /* @__PURE__ */ op({ifft_}); diff --git a/tfjs-master/tfjs-core/src/ops/spectral/irfft.ts b/tfjs-master/tfjs-core/src/ops/spectral/irfft.ts deleted file mode 100644 index 6f457b61f..000000000 --- a/tfjs-master/tfjs-core/src/ops/spectral/irfft.ts +++ /dev/null @@ -1,86 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Tensor, Tensor2D} from '../../tensor'; -import {complex} from '../complex'; -import {concat} from '../concat'; -import {imag} from '../imag'; -import {mul} from '../mul'; -import {op} from '../operation'; -import {real} from '../real'; -import {reshape} from '../reshape'; -import {reverse} from '../reverse'; -import {scalar} from '../scalar'; -import {slice} from '../slice'; - -import {ifft} from './ifft'; - -/** - * Inversed real value input fast Fourier transform. - * - * Computes the 1-dimensional inversed discrete Fourier transform over the - * inner-most dimension of the real input. - * - * ```js - * const real = tf.tensor1d([1, 2, 3]); - * const imag = tf.tensor1d([0, 0, 0]); - * const x = tf.complex(real, imag); - * - * x.irfft().print(); - * ``` - * @param input The real value input to compute an irfft over. - * - * @doc {heading: 'Operations', subheading: 'Spectral', namespace: 'spectral'} - */ -function irfft_(input: Tensor): Tensor { - const innerDimensionSize = input.shape[input.shape.length - 1]; - const batch = input.size / innerDimensionSize; - let ret: Tensor; - if (innerDimensionSize <= 2) { - const complexInput = reshape(input, [batch, innerDimensionSize]); - ret = ifft(complexInput); - } else { - // The length of unique components of the DFT of a real-valued signal - // is 2 * (input_len - 1) - const outputShape = [batch, 2 * (innerDimensionSize - 1)]; - const realInput = reshape(real(input), [batch, innerDimensionSize]); - const imagInput = reshape(imag(input), [batch, innerDimensionSize]); - - const realConjugate = - reverse(slice(realInput, [0, 1], [batch, innerDimensionSize - 2]), 1); - const imagConjugate: Tensor2D = mul( - reverse(slice(imagInput, [0, 1], [batch, innerDimensionSize - 2]), 1), - scalar(-1)); - - const r = concat([realInput, realConjugate], 1); - const i = concat([imagInput, imagConjugate], 1); - const complexInput = - reshape(complex(r, i), [outputShape[0], outputShape[1]]); - ret = ifft(complexInput); - } - ret = real(ret); - // reshape the result if the input is 3D tensor. - if (input.rank === 3 && input.shape[0] !== 0) { - const temp = ret; - const batch = input.shape[0]; - ret = reshape(ret, [batch, ret.shape[0] / batch, ret.shape[1]]); - temp.dispose(); - } - return ret; -} - -export const irfft = /* @__PURE__ */ op({irfft_}); diff --git a/tfjs-master/tfjs-core/src/ops/spectral/irfft_test.ts b/tfjs-master/tfjs-core/src/ops/spectral/irfft_test.ts deleted file mode 100644 index 600b67950..000000000 --- a/tfjs-master/tfjs-core/src/ops/spectral/irfft_test.ts +++ /dev/null @@ -1,127 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../../index'; -import {ALL_ENVS, describeWithFlags} from '../../jasmine_util'; -import {expectArraysClose} from '../../test_util'; - -describeWithFlags('1D IRFFT', ALL_ENVS, () => { - it('should return the same value with TensorFlow (2 elements)', async () => { - const t1Real = tf.tensor1d([1, 2]); - const t1Imag = tf.tensor1d([0, 0]); - const t1 = tf.complex(t1Real, t1Imag); - expectArraysClose(await tf.spectral.irfft(t1).data(), [1.5, -0.5]); - }); - - it('should calculate from the tensor directly', async () => { - const t1Real = tf.tensor1d([1, 2]); - const t1Imag = tf.tensor1d([0, 0]); - const t1 = tf.complex(t1Real, t1Imag); - expectArraysClose(await t1.irfft().data(), [1.5, -0.5]); - }); - - it('should return the same value with TensorFlow (5 elements)', async () => { - const t1Real = tf.tensor1d([1, 2, 3, 4, 5]); - const t1Imag = tf.tensor1d([0, 0, 0, 0, 0]); - const t1 = tf.complex(t1Real, t1Imag); - expectArraysClose( - await tf.spectral.irfft(t1).data(), - [3, -0.8535534, 0, -0.14644662, 0, -0.14644662, 0, -0.8535534]); - }); - - it('should return the same value with TensorFlow (5 elements) with imag', - async () => { - const t1Real = tf.tensor1d([1, 2, 3, 4, 5]); - const t1Imag = tf.tensor1d([1, 2, 3, 4, 5]); - const t1 = tf.complex(t1Real, t1Imag); - expectArraysClose( - await tf.spectral.irfft(t1).data(), - [3, -2.6642137, 0.5, -0.45710677, 0, 0.16421354, -0.5, 0.95710677]); - }); -}); - -describeWithFlags('2D IRFFT', ALL_ENVS, () => { - it('should return the same value with TensorFlow (2x2 elements)', - async () => { - const t1Real = tf.tensor2d([1, 2, 3, 4], [2, 2]); - const t1Imag = tf.tensor2d([0, 0, 0, 0], [2, 2]); - const t1 = tf.complex(t1Real, t1Imag); - expectArraysClose( - await tf.spectral.irfft(t1).data(), [1.5, -0.5, 3.5, -0.5]); - }); - - it('should return the same value with TensorFlow (2x3 elements)', - async () => { - const t1Real = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - const t1Imag = tf.tensor2d([0, 0, 0, 0, 0, 0], [2, 3]); - const t1 = tf.complex(t1Real, t1Imag); - expectArraysClose( - await tf.spectral.irfft(t1).data(), - [2, -0.5, 0, -0.5, 5, -0.5, 0, -0.5]); - }); - - it('should return the same value with TensorFlow (2x3 elements) with imag', - async () => { - const t1Real = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - const t1Imag = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - const t1 = tf.complex(t1Real, t1Imag); - expectArraysClose( - await tf.spectral.irfft(t1).data(), [2, -1.5, 0, 0.5, 5, -3, 0, 2]); - }); -}); - -describeWithFlags('3D IRFFT', ALL_ENVS, () => { - it('should return the same value with TensorFlow (2x2x2 elements)', - async () => { - const t1Real = tf.tensor3d([1, 2, 3, 4, 1, 2, 3, 4], [2, 2, 2]); - const t1Imag = tf.tensor3d([0, 0, 0, 0, 0, 0, 0, 0], [2, 2, 2]); - const t1 = tf.complex(t1Real, t1Imag); - const result = tf.spectral.irfft(t1); - expect(result.shape).toEqual([2, 2, 2]); - - expectArraysClose( - await result.data(), [1.5, -0.5, 3.5, -0.5, 1.5, -0.5, 3.5, -0.5]); - }); - - it('should return the same value with TensorFlow (2x2x3 elements)', - async () => { - const t1Real = - tf.tensor3d([1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6], [2, 2, 3]); - const t1Imag = - tf.tensor3d([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [2, 2, 3]); - const t1 = tf.complex(t1Real, t1Imag); - const result = tf.spectral.irfft(t1); - expect(result.shape).toEqual([2, 2, 4]); - expectArraysClose(await result.data(), [ - 2, -0.5, 0, -0.5, 5, -0.5, 0, -0.5, 2, -0.5, 0, -0.5, 5, -0.5, 0, -0.5 - ]); - }); - - it('should return the same value with TensorFlow (2x2x3 elements) with imag', - async () => { - const t1Real = - tf.tensor3d([1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6], [2, 2, 3]); - const t1Imag = - tf.tensor3d([1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6], [2, 2, 3]); - const t1 = tf.complex(t1Real, t1Imag); - const result = tf.spectral.irfft(t1); - expect(result.shape).toEqual([2, 2, 4]); - expectArraysClose( - await result.data(), - [2, -1.5, 0, 0.5, 5, -3, 0, 2, 2, -1.5, 0, 0.5, 5, -3, 0, 2]); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/spectral/rfft.ts b/tfjs-master/tfjs-core/src/ops/spectral/rfft.ts deleted file mode 100644 index 6b9706910..000000000 --- a/tfjs-master/tfjs-core/src/ops/spectral/rfft.ts +++ /dev/null @@ -1,99 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Tensor} from '../../tensor'; -import {assert} from '../../util'; -import {complex} from '../complex'; -import {concat} from '../concat'; -import {imag} from '../imag'; -import {op} from '../operation'; -import {real} from '../real'; -import {reshape} from '../reshape'; -import {slice} from '../slice'; -import {split} from '../split'; -import {zeros} from '../zeros'; -import {zerosLike} from '../zeros_like'; - -import {fft} from './fft'; - -/** - * Real value input fast Fourier transform. - * - * Computes the 1-dimensional discrete Fourier transform over the - * inner-most dimension of the real input. - * - * ```js - * const real = tf.tensor1d([1, 2, 3]); - * - * real.rfft().print(); - * ``` - * @param input The real value input to compute an rfft over. - * - * @doc {heading: 'Operations', subheading: 'Spectral', namespace: 'spectral'} - */ -function rfft_(input: Tensor, fftLength?: number): Tensor { - assert( - input.dtype === 'float32', - () => `The dtype for rfft() must be real value but got ${input.dtype}`); - - let innerDimensionSize = input.shape[input.shape.length - 1]; - const batch = input.size / innerDimensionSize; - - let adjustedInput: Tensor; - if (fftLength != null && fftLength < innerDimensionSize) { - // Need to crop - const begin = input.shape.map(v => 0); - const size = input.shape.map(v => v); - size[input.shape.length - 1] = fftLength; - adjustedInput = slice(input, begin, size); - innerDimensionSize = fftLength; - } else if (fftLength != null && fftLength > innerDimensionSize) { - // Need to pad with zeros - const zerosShape = input.shape.map(v => v); - zerosShape[input.shape.length - 1] = fftLength - innerDimensionSize; - adjustedInput = concat([input, zeros(zerosShape)], input.shape.length - 1); - innerDimensionSize = fftLength; - } else { - adjustedInput = input; - } - - // Complement the input with zero imaginary numbers. - const zerosInput = zerosLike(adjustedInput); - const complexInput = - reshape(complex(adjustedInput, zerosInput), [batch, innerDimensionSize]); - - const ret = fft(complexInput); - - // Exclude complex conjugations. These conjugations are put symmetrically. - const half = Math.floor(innerDimensionSize / 2) + 1; - const realValues = real(ret); - const imagValues = imag(ret); - const realComplexConjugate = split( - realValues, [half, innerDimensionSize - half], - realValues.shape.length - 1); - const imagComplexConjugate = split( - imagValues, [half, innerDimensionSize - half], - imagValues.shape.length - 1); - - const outputShape = adjustedInput.shape.slice(); - outputShape[adjustedInput.shape.length - 1] = half; - - return reshape( - complex(realComplexConjugate[0], imagComplexConjugate[0]), outputShape); -} - -export const rfft = /* @__PURE__ */ op({rfft_}); diff --git a/tfjs-master/tfjs-core/src/ops/spectral/rfft_test.ts b/tfjs-master/tfjs-core/src/ops/spectral/rfft_test.ts deleted file mode 100644 index 41e132283..000000000 --- a/tfjs-master/tfjs-core/src/ops/spectral/rfft_test.ts +++ /dev/null @@ -1,111 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../../index'; -import {ALL_ENVS, describeWithFlags} from '../../jasmine_util'; -import {expectArraysClose} from '../../test_util'; - -describeWithFlags('1D RFFT', ALL_ENVS, () => { - it('should return the same value with TensorFlow (3 elements)', async () => { - const t1Real = tf.tensor1d([1, 2, 3]); - expectArraysClose( - await tf.spectral.rfft(t1Real).data(), - [6, 1.1920929e-07, -1.4999999, 8.6602521e-01]); - }); - - it('should calculate from tensor directly', async () => { - const t1Real = tf.tensor1d([1, 2, 3]); - expectArraysClose( - await t1Real.rfft().data(), - [6, 1.1920929e-07, -1.4999999, 8.6602521e-01]); - }); - - it('should return the same value with TensorFlow (6 elements)', async () => { - const t1Real = tf.tensor1d([-3, -2, -1, 1, 2, 3]); - expectArraysClose(await tf.spectral.rfft(t1Real).data(), [ - -5.8859587e-07, 1.1920929e-07, -3.9999995, 6.9282026e+00, -2.9999998, - 1.7320497, -4.0000000, -2.3841858e-07 - ]); - }); - - it('should return the same value without any fftLength', async () => { - const t1Real = tf.tensor1d([-3, -2, -1, 1, 2, 3]); - const fftLength = 6; - expectArraysClose(await tf.spectral.rfft(t1Real, fftLength).data(), [ - -5.8859587e-07, 1.1920929e-07, -3.9999995, 6.9282026e+00, -2.9999998, - 1.7320497, -4.0000000, -2.3841858e-07 - ]); - }); - - it('should return the value with cropped input', async () => { - const t1Real = tf.tensor1d([-3, -2, -1, 1, 2, 3]); - const fftLength = 3; - expectArraysClose( - await tf.spectral.rfft(t1Real, fftLength).data(), - [-6, 0.0, -1.5000002, 0.866]); - }); - - it('should return the value with padded input', async () => { - const t1Real = tf.tensor1d([-3, -2, -1]); - const fftLength = 4; - expectArraysClose( - await tf.spectral.rfft(t1Real, fftLength).data(), - [-6, 0, -2, 2, -2, 0]); - }); -}); - -describeWithFlags('2D RFFT', ALL_ENVS, () => { - it('should return the same value with TensorFlow (2x2 elements)', - async () => { - const t1Real = tf.tensor2d([1, 2, 3, 4], [2, 2]); - expectArraysClose( - await tf.spectral.rfft(t1Real).data(), [3, 0, -1, 0, 7, 0, -1, 0]); - }); - - it('should return the same value with TensorFlow (2x3 elements)', - async () => { - const t1Real = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - expectArraysClose(await tf.spectral.rfft(t1Real).data(), [ - 6, 1.1920929e-07, -1.4999999, 8.6602521e-01, 15, -5.9604645e-08, - -1.4999998, 8.6602545e-01 - ]); - }); - - it('should return the same value with TensorFlow (2x2x2 elements)', - async () => { - const t1Real = tf.tensor3d([1, 2, 3, 4, 5, 6, 7, 8], [2, 2, 2]); - expectArraysClose( - await tf.spectral.rfft(t1Real).data(), - [3, 0, -1, 0, 7, 0, -1, 0, 11, 0, -1, 0, 15, 0, -1, 0]); - }); - - it('should return the value with cropping', async () => { - const t1Real = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - const fftLength = 2; - expectArraysClose( - await tf.spectral.rfft(t1Real, fftLength).data(), - [3, 0, -1, 0, 9, 0, -1, 0]); - }); - - it('should return the value with padding', async () => { - const t1Real = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - const fftLength = 4; - expectArraysClose( - await tf.spectral.rfft(t1Real, fftLength).data(), - [6, 0, -2, -2, 2, 0, 15, 0, -2, -5, 5, 0]); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/split.ts b/tfjs-master/tfjs-core/src/ops/split.ts deleted file mode 100644 index e67d829dc..000000000 --- a/tfjs-master/tfjs-core/src/ops/split.ts +++ /dev/null @@ -1,74 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {ENGINE} from '../engine'; -import {SplitV, SplitVAttrs, SplitVInputs} from '../kernel_names'; -import {NamedAttrMap} from '../kernel_registry'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -import {op} from './operation'; - -/** - * Splits a `tf.Tensor` into sub tensors. - * - * If `numOrSizeSplits` is a number, splits `x` along dimension `axis` - * into `numOrSizeSplits` smaller tensors. - * Requires that `numOrSizeSplits` evenly divides `x.shape[axis]`. - * - * If `numOrSizeSplits` is a number array, splits `x` into - * `numOrSizeSplits.length` pieces. The shape of the `i`-th piece has the - * same size as `x` except along dimension `axis` where the size is - * `numOrSizeSplits[i]`. - * - * ```js - * const x = tf.tensor2d([1, 2, 3, 4, 5, 6, 7, 8], [2, 4]); - * const [a, b] = tf.split(x, 2, 1); - * a.print(); - * b.print(); - * - * const [c, d, e] = tf.split(x, [1, 2, 1], 1); - * c.print(); - * d.print(); - * e.print(); - * ``` - * - * @param x The input tensor to split. - * @param numOrSizeSplits Either an integer indicating the number of - * splits along the axis or an array of integers containing the sizes of - * each output tensor along the axis. If a number then it must evenly divide - * `x.shape[axis]`; otherwise the sum of sizes must match `x.shape[axis]`. - * Can contain one -1 indicating that dimension is to be inferred. - * @param axis The dimension along which to split. Defaults to 0 (the first - * dim). - * - * @doc {heading: 'Tensors', subheading: 'Slicing and Joining'} - */ -function split_( - x: Tensor|TensorLike, numOrSizeSplits: number[]|number, axis = 0): T[] { - const $x = convertToTensor(x, 'x', 'split'); - - const inputs: SplitVInputs = {x: $x}; - const attr: SplitVAttrs = {numOrSizeSplits, axis}; - - return ENGINE.runKernel( - SplitV, inputs as unknown as NamedTensorMap, - attr as unknown as NamedAttrMap) as unknown as T[]; -} - -export const split = /* @__PURE__ */ op({split_}); diff --git a/tfjs-master/tfjs-core/src/ops/split_test.ts b/tfjs-master/tfjs-core/src/ops/split_test.ts deleted file mode 100644 index 95e51e6c1..000000000 --- a/tfjs-master/tfjs-core/src/ops/split_test.ts +++ /dev/null @@ -1,169 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('split', ALL_ENVS, () => { - it('split by number', async () => { - const x = tf.tensor2d([1, 2, 3, 4, 5, 6, 7, 8], [2, 4]); - const res = tf.split(x, 2, 1); - expect(res.length).toEqual(2); - expect(res[0].shape).toEqual([2, 2]); - expectArraysClose(await res[0].data(), [1, 2, 5, 6]); - expect(res[1].shape).toEqual([2, 2]); - expectArraysClose(await res[1].data(), [3, 4, 7, 8]); - }); - - it('split by sizes', async () => { - const x = tf.tensor2d([1, 2, 3, 4, 5, 6, 7, 8], [2, 4]); - const res = tf.split(x, [1, 2, 1], 1); - expect(res.length).toEqual(3); - expect(res[0].shape).toEqual([2, 1]); - expectArraysClose(await res[0].data(), [1, 5]); - expect(res[1].shape).toEqual([2, 2]); - expectArraysClose(await res[1].data(), [2, 3, 6, 7]); - expect(res[2].shape).toEqual([2, 1]); - expectArraysClose(await res[2].data(), [4, 8]); - }); - - it('chainable split by sizes', async () => { - const x = tf.tensor2d([1, 2, 3, 4, 5, 6, 7, 8], [2, 4]); - const res = x.split([1, 2, 1], 1); - - expect(res.length).toEqual(3); - expect(res[0].shape).toEqual([2, 1]); - expectArraysClose(await res[0].data(), [1, 5]); - expect(res[1].shape).toEqual([2, 2]); - expectArraysClose(await res[1].data(), [2, 3, 6, 7]); - expect(res[2].shape).toEqual([2, 1]); - expectArraysClose(await res[2].data(), [4, 8]); - }); - it('should support -1 split', async () => { - const x = tf.tensor2d([1, 2, 3, 4, 5, 6, 7, 8], [2, 4]); - const res = x.split([1, 1, -1], 1); - - expect(res.length).toEqual(3); - expect(res[0].shape).toEqual([2, 1]); - expectArraysClose(await res[0].data(), [1, 5]); - expect(res[1].shape).toEqual([2, 1]); - expectArraysClose(await res[1].data(), [2, 6]); - expect(res[2].shape).toEqual([2, 2]); - expectArraysClose(await res[2].data(), [3, 4, 7, 8]); - }); - - it('multiple negative number throws error', () => { - const x = tf.tensor2d([1, 2, 3, 4, 5, 6, 7, 8], [2, 4]); - const f = () => tf.split(x, [1, -1, -1], 1); - expect(f).toThrowError(); - }); - it('sizes to not sum to axis size throws error', () => { - const x = tf.tensor2d([1, 2, 3, 4, 5, 6, 7, 8], [2, 4]); - const f = () => tf.split(x, [1, 2], 1); - expect(f).toThrowError(); - }); - - it('number of splits does not evenly divide axis', () => { - const x = tf.tensor2d([1, 2, 3, 4, 5, 6, 7, 8], [2, 4]); - const f = () => tf.split(x, 3, 1); - expect(f).toThrowError(); - }); - - it('can split, axis=-2', async () => { - const a = tf.tensor3d([1, 2, 3, 4, 5, 6, 7, 8], [2, 2, 2]); - const numSplits = 2; - const axis = -2; - const res = tf.split(a, numSplits, axis); - expect(res.length).toBe(2); - expect(res[0].shape).toEqual([2, 1, 2]); - expect(res[1].shape).toEqual([2, 1, 2]); - expectArraysClose(await res[0].data(), [1, 2, 5, 6]); - expectArraysClose(await res[1].data(), [3, 4, 7, 8]); - }); - - it('can split a zero-sized tensor, axis=0', async () => { - const a = tf.zeros([4, 0]); - const numSplits = 4; - const axis = 0; - const res = tf.split(a, numSplits, axis); - expect(res.length).toBe(4); - expect(res[0].shape).toEqual([1, 0]); - expect(res[1].shape).toEqual([1, 0]); - expect(res[2].shape).toEqual([1, 0]); - expect(res[3].shape).toEqual([1, 0]); - expectArraysClose(await res[0].data(), []); - expectArraysClose(await res[1].data(), []); - expectArraysClose(await res[2].data(), []); - expectArraysClose(await res[3].data(), []); - }); - - it('can split a zero-sized tensor, axis=1', async () => { - const a = tf.zeros([0, 4]); - const numSplits = 4; - const axis = 1; - const res = tf.split(a, numSplits, axis); - expect(res.length).toBe(4); - expect(res[0].shape).toEqual([0, 1]); - expect(res[1].shape).toEqual([0, 1]); - expect(res[2].shape).toEqual([0, 1]); - expect(res[3].shape).toEqual([0, 1]); - expectArraysClose(await res[0].data(), []); - expectArraysClose(await res[1].data(), []); - expectArraysClose(await res[2].data(), []); - expectArraysClose(await res[3].data(), []); - }); - - it('throws when passed a non-tensor', () => { - expect(() => tf.split({} as tf.Tensor, 1)) - .toThrowError(/Argument 'x' passed to 'split' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const x = [[1, 2, 3, 4], [5, 6, 7, 8]]; - const res = tf.split(x, 2, 1); - expect(res.length).toEqual(2); - expect(res[0].shape).toEqual([2, 2]); - expectArraysClose(await res[0].data(), [1, 2, 5, 6]); - expect(res[1].shape).toEqual([2, 2]); - expectArraysClose(await res[1].data(), [3, 4, 7, 8]); - }); - - it('gradient of 1st output', async () => { - const a = tf.tensor1d([1, 2, 3]); - const da = tf.grad(x => tf.split(x, [1, 2])[0])(a); - - expect(da.shape).toEqual([3]); - expectArraysClose(await da.data(), [1, 0, 0]); - }); - - it('gradient with clones', async () => { - const a = tf.tensor1d([1, 2, 3]); - const da = tf.grad(x => tf.split(x.clone(), [1, 2])[0].clone())(a); - - expect(da.shape).toEqual([3]); - expectArraysClose(await da.data(), [1, 0, 0]); - }); - - it('gradient of 2nd output', async () => { - const a = tf.tensor1d([1, 2, 3]); - const da = tf.grad(x => tf.split(x, [1, 2])[1])(a); - - expect(da.shape).toEqual([3]); - expectArraysClose(await da.data(), [0, 1, 1]); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/split_util.ts b/tfjs-master/tfjs-core/src/ops/split_util.ts deleted file mode 100644 index 87cb5f2be..000000000 --- a/tfjs-master/tfjs-core/src/ops/split_util.ts +++ /dev/null @@ -1,60 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import { TensorInfo } from '../tensor_info'; -import {Tensor} from '../tensor'; -import {assert} from '../util'; - -/** - * Prepare the split size array. When the input is a number, the axis is evenly - * divided among the split size. When the input contains the negative value, the - * rest of the axis is allocated toward that. - */ -export function prepareSplitSize( - x: Tensor|TensorInfo, numOrSizeSplits: number[]|number, - axis = 0): number[] { - let splitSizes = []; - if (typeof (numOrSizeSplits) === 'number') { - assert( - x.shape[axis] % numOrSizeSplits === 0, - () => 'Number of splits must evenly divide the axis.'); - splitSizes = - new Array(numOrSizeSplits).fill(x.shape[axis] / numOrSizeSplits); - } else { - const numOfNegs = numOrSizeSplits.reduce((count, value) => { - if (value === -1) { - count += 1; - } - return count; - }, 0); - assert( - numOfNegs <= 1, - () => 'There should be only one negative value in split array.'); - const negIndex = numOrSizeSplits.indexOf(-1); - // Allow the number of split array to be -1, which indicates the rest - // of dimension is allocated to that split. - if (negIndex !== -1) { - const total = numOrSizeSplits.reduce((a, b) => b > 0 ? a + b : a); - numOrSizeSplits[negIndex] = x.shape[axis] - total; - } - assert( - x.shape[axis] === numOrSizeSplits.reduce((a, b) => a + b), - () => 'The sum of sizes must match the size of the axis dimension.'); - splitSizes = numOrSizeSplits; - } - - return splitSizes; -} diff --git a/tfjs-master/tfjs-core/src/ops/sqrt.ts b/tfjs-master/tfjs-core/src/ops/sqrt.ts deleted file mode 100644 index f37c6925e..000000000 --- a/tfjs-master/tfjs-core/src/ops/sqrt.ts +++ /dev/null @@ -1,46 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {Sqrt, SqrtInputs} from '../kernel_names'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -import {op} from './operation'; - -/** - * Computes square root of the input `tf.Tensor` element-wise: `y = sqrt(x)` - * - * ```js - * const x = tf.tensor1d([1, 2, 4, -1]); - * - * x.sqrt().print(); // or tf.sqrt(x) - * ``` - * @param x The input tensor. - * - * @doc {heading: 'Operations', subheading: 'Basic math'} - */ -function sqrt_(x: T|TensorLike): T { - const $x = convertToTensor(x, 'x', 'sqrt', 'float32'); - - const inputs: SqrtInputs = {x: $x}; - - return ENGINE.runKernel(Sqrt, inputs as unknown as NamedTensorMap); -} -export const sqrt = /* @__PURE__ */ op({sqrt_}); diff --git a/tfjs-master/tfjs-core/src/ops/sqrt_test.ts b/tfjs-master/tfjs-core/src/ops/sqrt_test.ts deleted file mode 100644 index e890eeaa9..000000000 --- a/tfjs-master/tfjs-core/src/ops/sqrt_test.ts +++ /dev/null @@ -1,110 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('sqrt', ALL_ENVS, () => { - it('sqrt', async () => { - const a = tf.tensor1d([2, 4]); - const r = tf.sqrt(a); - expectArraysClose(await r.data(), [Math.sqrt(2), Math.sqrt(4)]); - }); - - it('sqrt propagates NaNs', async () => { - const a = tf.tensor1d([1, NaN]); - const r = tf.sqrt(a); - expectArraysClose(await r.data(), [Math.sqrt(1), NaN]); - }); - - it('gradients: Scalar', async () => { - const a = tf.scalar(4); - const dy = tf.scalar(8); - - const da = tf.grad(a => tf.sqrt(a))(a, dy); - - expect(da.shape).toEqual(a.shape); - expect(da.dtype).toEqual('float32'); - expectArraysClose(await da.data(), [8 / (2 * Math.sqrt(4))]); - }); - - it('gradient with clones', async () => { - const a = tf.scalar(4); - const dy = tf.scalar(8); - - const da = tf.grad(a => tf.sqrt(a.clone()).clone())(a, dy); - - expect(da.shape).toEqual(a.shape); - expect(da.dtype).toEqual('float32'); - expectArraysClose(await da.data(), [8 / (2 * Math.sqrt(4))]); - }); - - it('gradients: Tensor1D', async () => { - const a = tf.tensor1d([1, 2, 3, 5]); - const dy = tf.tensor1d([1, 2, 3, 4]); - - const gradients = tf.grad(a => tf.sqrt(a))(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose( - await gradients.data(), - [ - 1 / (2 * Math.sqrt(1)), 2 / (2 * Math.sqrt(2)), - 3 / (2 * Math.sqrt(3)), 4 / (2 * Math.sqrt(5)) - ], - 1e-1); - }); - - it('gradients: Tensor2D', async () => { - const a = tf.tensor2d([3, 1, 2, 3], [2, 2]); - const dy = tf.tensor2d([1, 2, 3, 4], [2, 2]); - - const gradients = tf.grad(a => tf.sqrt(a))(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose( - await gradients.data(), - [ - 1 / (2 * Math.sqrt(3)), 2 / (2 * Math.sqrt(1)), - 3 / (2 * Math.sqrt(2)), 4 / (2 * Math.sqrt(3)) - ], - 1e-1); - }); - - it('throws when passed a non-tensor', () => { - expect(() => tf.sqrt({} as tf.Tensor)) - .toThrowError(/Argument 'x' passed to 'sqrt' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const r = tf.sqrt([2, 4]); - expectArraysClose(await r.data(), [Math.sqrt(2), Math.sqrt(4)]); - }); - - it('throws for string tensor', () => { - expect(() => tf.sqrt('q')) - .toThrowError(/Argument 'x' passed to 'sqrt' must be float32/); - }); - - it('throws for int32 tensor', () => { - expect(() => tf.sqrt(tf.tensor1d([1], 'int32'))) - .toThrowError(/Argument 'x' passed to 'sqrt' must be float32/); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/square.ts b/tfjs-master/tfjs-core/src/ops/square.ts deleted file mode 100644 index 8b275e1dc..000000000 --- a/tfjs-master/tfjs-core/src/ops/square.ts +++ /dev/null @@ -1,42 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {Tensor} from '../tensor'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; -import {op} from './operation'; - -/** - * Computes square of `x` element-wise: `x ^ 2` - * - * ```js - * const x = tf.tensor1d([1, 2, Math.sqrt(2), -1]); - * - * x.square().print(); // or tf.square(x) - * ``` - * @param x The input Tensor. - * - * @doc {heading: 'Operations', subheading: 'Basic math'} - */ -function square_(x: T|TensorLike): T { - const $x = convertToTensor(x, 'x', 'square'); - const attrs = {}; - return ENGINE.runKernel('Square', {x: $x}, attrs); -} - -export const square = /* @__PURE__ */ op({square_}); diff --git a/tfjs-master/tfjs-core/src/ops/square_test.ts b/tfjs-master/tfjs-core/src/ops/square_test.ts deleted file mode 100644 index 9c5b16c35..000000000 --- a/tfjs-master/tfjs-core/src/ops/square_test.ts +++ /dev/null @@ -1,157 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose, expectNumbersClose} from '../test_util'; -import { backend } from '../index'; - -describeWithFlags('square', ALL_ENVS, () => { - it('1D array', async () => { - const a = tf.tensor1d([2, 4, Math.sqrt(2)]); - const r = tf.square(a); - expectArraysClose(await r.data(), [4, 16, 2]); - }); - - it('2D array', async () => { - const a = tf.tensor2d([1, 2, Math.sqrt(2), Math.sqrt(3)], [2, 2]); - const r = tf.square(a); - expect(r.shape).toEqual([2, 2]); - expectArraysClose(await r.data(), [1, 4, 2, 3]); - }); - - it('5D array', async () => { - const a = tf.tensor5d([1, 2, Math.sqrt(2), Math.sqrt(3)], [1, 1, 2, 2, 1]); - const r = tf.square(a); - expect(r.shape).toEqual([1, 1, 2, 2, 1]); - expectArraysClose(await r.data(), [1, 4, 2, 3]); - }); - - it('6D array', async () => { - const a = tf.tensor6d( - [1, 2, Math.sqrt(2), Math.sqrt(3), 3, 4, Math.sqrt(7), Math.sqrt(13)], - [1, 1, 2, 2, 2, 1]); - const r = tf.square(a); - expect(r.shape).toEqual(a.shape); - expectArraysClose(await r.data(), [1, 4, 2, 3, 9, 16, 7, 13]); - }); - - it('square propagates NaNs', async () => { - const a = tf.tensor1d([1.5, NaN]); - const r = tf.square(a); - expectArraysClose(await r.data(), [2.25, NaN]); - }); - - it('int32', async () => { - if (backend() && backend().floatPrecision() === 32) { - // TODO: Use skip() instead when it is implemented - const a = tf.tensor1d([2, 4, 40000], 'int32'); - const r = tf.square(a); - expect(r.dtype).toEqual('int32'); - 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 () => { - const a = tf.scalar(5); - const dy = tf.scalar(8); - - const gradients = tf.grad(a => tf.square(a))(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), [2 * 5 * 8]); - }); - - it('gradients: Scalar', async () => { - const a = tf.scalar(5); - const dy = tf.scalar(8); - - const gradients = tf.grad(a => tf.square(a.clone()).clone())(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), [2 * 5 * 8]); - }); - - it('gradients: Tensor1D', async () => { - const a = tf.tensor1d([-1, 2, 3, -5]); - const dy = tf.tensor1d([1, 2, 3, 4]); - - const gradients = tf.grad(a => tf.square(a))(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), [-2, 4 * 2, 6 * 3, -10 * 4]); - }); - - it('gradients: Tensor2D', async () => { - const a = tf.tensor2d([-3, 1, 2, 3], [2, 2]); - const dy = tf.tensor2d([1, 2, 3, 4], [2, 2]); - - const gradients = tf.grad(a => tf.square(a))(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), [-6 * 1, 2 * 2, 4 * 3, 6 * 4]); - }); - - it('gradients: Tensor5D', async () => { - const a = tf.tensor5d([-3, 1, 2, 3], [1, 1, 1, 2, 2]); - const dy = tf.tensor5d([1, 2, 3, 4], [1, 1, 1, 2, 2]); - - const gradients = tf.grad(a => tf.square(a))(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), [-6 * 1, 2 * 2, 4 * 3, 6 * 4]); - }); - - it('gradients: Tensor6D', async () => { - const a = tf.tensor6d([-3, 1, 2, 3, -4, 5, 12, 3], [1, 1, 1, 2, 2, 2]); - const dy = tf.tensor6d([1, 2, 3, 4, 5, 6, 7, 8], [1, 1, 1, 2, 2, 2]); - - const gradients = tf.grad(a => tf.square(a))(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose( - await gradients.data(), - [-6 * 1, 2 * 2, 4 * 3, 6 * 4, -8 * 5, 10 * 6, 24 * 7, 6 * 8]); - }); - - it('throws when passed a non-tensor', () => { - expect(() => tf.square({} as tf.Tensor)) - .toThrowError(/Argument 'x' passed to 'square' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const r = tf.square([2, 4, Math.sqrt(2)]); - expectArraysClose(await r.data(), [4, 16, 2]); - }); - - it('throws for string tensor', () => { - expect(() => tf.square('q')) - .toThrowError(/Argument 'x' passed to 'square' must be numeric/); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/squared_difference.ts b/tfjs-master/tfjs-core/src/ops/squared_difference.ts deleted file mode 100644 index 1c145801e..000000000 --- a/tfjs-master/tfjs-core/src/ops/squared_difference.ts +++ /dev/null @@ -1,68 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {SquaredDifference, SquaredDifferenceInputs} from '../kernel_names'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {makeTypesMatch} from '../tensor_util'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -import {assertAndGetBroadcastShape} from './broadcast_util'; -import {op} from './operation'; - -/** - * Returns (a - b) * (a - b) element-wise. - * Supports broadcasting. - * - * ```js - * const a = tf.tensor1d([1, 4, 3, 16]); - * const b = tf.tensor1d([1, 2, 9, 4]); - * - * a.squaredDifference(b).print(); // or tf.squaredDifference(a, b) - * ``` - * - * ```js - * // Broadcast squared difference a with b. - * const a = tf.tensor1d([2, 4, 6, 8]); - * const b = tf.scalar(5); - * - * a.squaredDifference(b).print(); // or tf.squaredDifference(a, b) - * ``` - * - * @param a The first tensor. - * @param b The second tensor. Must have the same type as `a`. - * - * @doc {heading: 'Operations', subheading: 'Arithmetic'} - */ -function squaredDifference_( - a: Tensor|TensorLike, b: Tensor|TensorLike): T { - let $a = convertToTensor(a, 'a', 'squaredDifference'); - let $b = convertToTensor(b, 'b', 'squaredDifference'); - [$a, $b] = makeTypesMatch($a, $b); - - assertAndGetBroadcastShape($a.shape, $b.shape); - - const inputs: SquaredDifferenceInputs = {a: $a, b: $b}; - const attrs = {}; - - return ENGINE.runKernel( - SquaredDifference, inputs as unknown as NamedTensorMap, attrs); -} - -export const squaredDifference = /* @__PURE__ */ op({squaredDifference_}); diff --git a/tfjs-master/tfjs-core/src/ops/squeeze.ts b/tfjs-master/tfjs-core/src/ops/squeeze.ts deleted file mode 100644 index 009a5d91c..000000000 --- a/tfjs-master/tfjs-core/src/ops/squeeze.ts +++ /dev/null @@ -1,46 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Tensor} from '../tensor'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; -import {squeezeShape} from '../util'; - -import {op} from './operation'; -import {reshape} from './reshape'; - -/** - * Removes dimensions of size 1 from the shape of a `tf.Tensor`. - * - * ```js - * const x = tf.tensor([1, 2, 3, 4], [1, 1, 4]); - * x.squeeze().print(); - * ``` - * - * @param x The input tensor to be squeezed. - * @param axis An optional list of numbers. If specified, only - * squeezes the dimensions listed. The dimension index starts at 0. It - * is an error to squeeze a dimension that is not 1. - * - * @doc {heading: 'Tensors', subheading: 'Transformations'} - */ -function squeeze_(x: Tensor|TensorLike, axis?: number[]): T { - const $x = convertToTensor(x, 'x', 'squeeze', 'string_or_numeric'); - return reshape($x, squeezeShape($x.shape, axis).newShape) as T; -} - -export const squeeze = /* @__PURE__ */ op({squeeze_}); diff --git a/tfjs-master/tfjs-core/src/ops/squeeze_test.ts b/tfjs-master/tfjs-core/src/ops/squeeze_test.ts deleted file mode 100644 index b7f3f1d20..000000000 --- a/tfjs-master/tfjs-core/src/ops/squeeze_test.ts +++ /dev/null @@ -1,109 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysEqual} from '../test_util'; - -async function expectTensor( - tensor: tf.Tensor, shape: number[], value: string|number) { - const length = shape.length === 0 ? 1 : shape.reduce((a, b) => a * b); - expect(tensor.shape).toEqual(shape); - expectArraysEqual(await tensor.data(), new Array(length).fill(value)); -} - -describeWithFlags('squeeze', ALL_ENVS, () => { - it('default', async () => { - const assertType = async (dtype: 'string'|'float32') => { - const value = dtype === 'string' ? 'test' : 0.0; - // Nothing to squeeze. - await expectTensor(tf.squeeze(tf.fill([2], value)), [2], value); - - // Squeeze the middle element away. - await expectTensor(tf.squeeze(tf.fill([2, 1, 2], value)), [2, 2], value); - - // Squeeze on both ends. - await expectTensor( - tf.squeeze(tf.fill([1, 2, 1, 3, 1], value)), [2, 3], value); - }; - - await assertType('string'); - await assertType('float32'); - }); - - it('specific dimension', async () => { - const assertType = async (dtype: 'string'|'float32') => { - const value = dtype === 'string' ? 'test' : 0.0; - const shape = [1, 2, 1, 3, 1]; - // Positive squeeze dim index. - await expectTensor( - tf.squeeze(tf.fill(shape, value), [0]), [2, 1, 3, 1], value); - await expectTensor( - tf.squeeze(tf.fill(shape, value), [2, 4]), [1, 2, 3], value); - await expectTensor( - tf.squeeze(tf.fill(shape, value), [0, 4, 2]), [2, 3], value); - - // Negative squeeze dim index. - await expectTensor( - tf.squeeze(tf.fill(shape, value), [-1]), [1, 2, 1, 3], value); - await expectTensor( - tf.squeeze(tf.fill(shape, value), [-3, -5]), [2, 3, 1], value); - await expectTensor( - tf.squeeze(tf.fill(shape, value), [-3, -5, -1]), [2, 3], value); - }; - - await assertType('string'); - await assertType('float32'); - }); - - it('all ones', async () => { - const assertType = async (dtype: 'string'|'float32') => { - const value = dtype === 'string' ? 'test' : 0.0; - await expectTensor(tf.squeeze(tf.fill([1, 1, 1], value)), [], value); - }; - - await assertType('string'); - await assertType('float32'); - }); - - it('squeeze only ones', async () => { - const assertType = async (dtype: 'string'|'float32') => { - const value = dtype === 'string' ? 'test' : 0.0; - const shape = [1, 1, 3]; - await expectTensor(tf.squeeze(tf.fill(shape, value)), [3], value); - await expectTensor(tf.squeeze(tf.fill(shape, value), [0]), [1, 3], value); - await expectTensor(tf.squeeze(tf.fill(shape, value), [1]), [1, 3], value); - expect(() => tf.squeeze(tf.fill(shape, value), [2])).toThrowError(); - }; - - await assertType('string'); - await assertType('float32'); - }); - - it('squeeze errors', async () => { - const assertType = async (dtype: 'string'|'float32') => { - const value = dtype === 'string' ? 'test' : 0.0; - const shape = [1, 2, 1]; - expect(() => tf.squeeze(tf.fill(shape, value), [-4])).toThrowError(); - expect(() => tf.squeeze(tf.fill(shape, value), [0, -4])).toThrowError(); - expect(() => tf.squeeze(tf.fill(shape, value), [3])).toThrowError(); - expect(() => tf.squeeze(tf.fill(shape, value), [2, 3])).toThrowError(); - }; - - await assertType('string'); - await assertType('float32'); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/stack.ts b/tfjs-master/tfjs-core/src/ops/stack.ts deleted file mode 100644 index 9cc1a44b3..000000000 --- a/tfjs-master/tfjs-core/src/ops/stack.ts +++ /dev/null @@ -1,65 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {Pack, PackAttrs, PackInputs} from '../kernel_names'; -import {NamedAttrMap} from '../kernel_registry'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensorArray} from '../tensor_util_env'; -import {TensorLike} from '../types'; -import * as util from '../util'; - -import {op} from './operation'; - -/** - * Stacks a list of rank-`R` `tf.Tensor`s into one rank-`(R+1)` `tf.Tensor`. - * - * ```js - * const a = tf.tensor1d([1, 2]); - * const b = tf.tensor1d([3, 4]); - * const c = tf.tensor1d([5, 6]); - * tf.stack([a, b, c]).print(); - * ``` - * - * @param tensors A list of tensor objects with the same shape and dtype. - * @param axis The axis to stack along. Defaults to 0 (the first dim). - * - * @doc {heading: 'Tensors', subheading: 'Slicing and Joining'} - */ -function stack_( - tensors: Array, axis = 0): Tensor { - const $tensors = - convertToTensorArray(tensors, 'tensors', 'stack', 'string_or_numeric'); - - util.assert( - $tensors.length >= 1, () => 'Pass at least one tensor to tf.stack'); - - if ($tensors.length > 0) { - util.assert( - axis <= $tensors[0].rank, () => 'Axis must be <= rank of the tensor'); - } - - const inputs: PackInputs = $tensors; - const attrs: PackAttrs = {axis}; - - return ENGINE.runKernel( - Pack, inputs as unknown as NamedTensorMap, - attrs as unknown as NamedAttrMap); -} - -export const stack = /* @__PURE__ */ op({stack_}); diff --git a/tfjs-master/tfjs-core/src/ops/stack_test.ts b/tfjs-master/tfjs-core/src/ops/stack_test.ts deleted file mode 100644 index ac85c0fd4..000000000 --- a/tfjs-master/tfjs-core/src/ops/stack_test.ts +++ /dev/null @@ -1,132 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('stack', ALL_ENVS, () => { - it('scalars 3, 5 and 7', async () => { - const a = tf.scalar(3); - const b = tf.scalar(5); - const c = tf.scalar(7); - const res = tf.stack([a, b, c]); - expect(res.shape).toEqual([3]); - expectArraysClose(await res.data(), [3, 5, 7]); - }); - - it('scalars 3, 5 and 7 along axis=1 throws error', () => { - const a = tf.scalar(3); - const b = tf.scalar(5); - const c = tf.scalar(7); - const f = () => tf.stack([a, b, c], 1); - expect(f).toThrowError(); - }); - - it('non matching shapes throws error', () => { - const a = tf.scalar(3); - const b = tf.tensor1d([5]); - const f = () => tf.stack([a, b]); - expect(f).toThrowError(); - }); - - it('non matching dtypes throws error', () => { - const a = tf.scalar(3); - const b = tf.scalar(5, 'bool'); - const f = () => tf.stack([a, b]); - expect(f).toThrowError(); - }); - - it('2d but axis=3 throws error', () => { - const a = tf.zeros([2, 2]); - const b = tf.zeros([2, 2]); - const f = () => tf.stack([a, b], 3 /* axis */); - expect(f).toThrowError(); - }); - - it('[1,2], [3,4] and [5,6], axis=0', async () => { - const a = tf.tensor1d([1, 2]); - const b = tf.tensor1d([3, 4]); - const c = tf.tensor1d([5, 6]); - const res = tf.stack([a, b, c], 0 /* axis */); - expect(res.shape).toEqual([3, 2]); - expectArraysClose(await res.data(), [1, 2, 3, 4, 5, 6]); - }); - - it('[1,2], [3,4] and [5,6], axis=1', async () => { - const a = tf.tensor1d([1, 2]); - const b = tf.tensor1d([3, 4]); - const c = tf.tensor1d([5, 6]); - const res = tf.stack([a, b, c], 1 /* axis */); - expect(res.shape).toEqual([2, 3]); - expectArraysClose(await res.data(), [1, 3, 5, 2, 4, 6]); - }); - - it('[[1,2],[3,4]] and [[5, 6], [7, 8]], axis=0', async () => { - const a = tf.tensor2d([[1, 2], [3, 4]]); - const b = tf.tensor2d([[5, 6], [7, 8]]); - const res = tf.stack([a, b], 0 /* axis */); - expect(res.shape).toEqual([2, 2, 2]); - expectArraysClose(await res.data(), [1, 2, 3, 4, 5, 6, 7, 8]); - }); - - it('[[1,2],[3,4]] and [[5, 6], [7, 8]], axis=2', async () => { - const a = tf.tensor2d([[1, 2], [3, 4]]); - const b = tf.tensor2d([[5, 6], [7, 8]]); - const c = tf.tensor2d([[9, 10], [11, 12]]); - const res = tf.stack([a, b, c], 2 /* axis */); - expect(res.shape).toEqual([2, 2, 3]); - expectArraysClose( - await res.data(), [1, 5, 9, 2, 6, 10, 3, 7, 11, 4, 8, 12]); - }); - - it('single tensor', async () => { - const a = tf.tensor2d([[1, 2], [3, 4]]); - const res = tf.stack([a], 2 /* axis */); - expect(res.shape).toEqual([2, 2, 1]); - expectArraysClose(await res.data(), [1, 2, 3, 4]); - }); - - it('throws when passed a non-tensor', () => { - expect(() => tf.stack([{} as tf.Tensor])) - .toThrowError( - /Argument 'tensors\[0\]' passed to 'stack' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const a = [[1, 2], [3, 4]]; - const res = tf.stack([a], 2 /* axis */); - expect(res.shape).toEqual([2, 2, 1]); - expectArraysClose(await res.data(), [1, 2, 3, 4]); - }); - - it('accepts string.', async () => { - const a = tf.scalar('three', 'string'); - const b = tf.scalar('five', 'string'); - const c = tf.scalar('seven', 'string'); - const res = tf.stack([a, b, c]); - expect(res.shape).toEqual([3]); - expectArraysClose(await res.data(), ['three', 'five', 'seven']); - }); - - it('chain api', async () => { - const a = tf.tensor([1, 2]); - const res = a.stack(tf.tensor([3, 4])); - expect(res.shape).toEqual([2, 2]); - expectArraysClose(await res.data(), [1, 2, 3, 4]); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/step.ts b/tfjs-master/tfjs-core/src/ops/step.ts deleted file mode 100644 index 2b30da708..000000000 --- a/tfjs-master/tfjs-core/src/ops/step.ts +++ /dev/null @@ -1,51 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {Step, StepAttrs, StepInputs} from '../kernel_names'; -import {NamedAttrMap} from '../kernel_registry'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -import {op} from './operation'; - -/** - * Computes step of the input `tf.Tensor` element-wise: `x > 0 ? 1 : alpha` - * - * ```js - * const x = tf.tensor1d([0, 2, -1, -3]); - * - * x.step(.5).print(); // or tf.step(x, .5) - * ``` - * @param x The input tensor. - * @param alpha The gradient when input is negative. Defaults to 0. - * - * @doc {heading: 'Operations', subheading: 'Basic math'} - */ -function step_(x: T|TensorLike, alpha = 0.0): T { - const $x = convertToTensor(x, 'x', 'step'); - - const inputs: StepInputs = {x: $x}; - const attrs: StepAttrs = {alpha}; - - return ENGINE.runKernel( - Step, inputs as unknown as NamedTensorMap, - attrs as unknown as NamedAttrMap); -} -export const step = /* @__PURE__ */ op({step_}); diff --git a/tfjs-master/tfjs-core/src/ops/step_test.ts b/tfjs-master/tfjs-core/src/ops/step_test.ts deleted file mode 100644 index 09cef370f..000000000 --- a/tfjs-master/tfjs-core/src/ops/step_test.ts +++ /dev/null @@ -1,113 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('step kernel', ALL_ENVS, () => { - it('with 1d tensor', async () => { - const a = tf.tensor1d([1, -2, -.01, 3, -0.1]); - const result = tf.step(a); - expectArraysClose(await result.data(), [1, 0, 0, 1, 0]); - }); - - it('with 1d tensor and alpha', async () => { - const a = tf.tensor1d([1, -2, -.01, 3, NaN]); - const result = tf.step(a, 0.1); - expectArraysClose(await result.data(), [1, 0.1, 0.1, 1, NaN]); - }); - - it('with 2d tensor', async () => { - const a = tf.tensor2d([1, -5, -3, 4], [2, 2]); - const result = tf.step(a); - expect(result.shape).toEqual([2, 2]); - expectArraysClose(await result.data(), [1, 0, 0, 1]); - }); - - it('propagates NaNs', async () => { - const a = tf.tensor1d([1, -2, -.01, 3, NaN]); - const result = tf.step(a); - expectArraysClose(await result.data(), [1, 0, 0, 1, NaN]); - }); - - it('with int32 tensor', async () => { - const a = tf.tensor1d([1, -2, 12345678, -12345678], 'int32'); - const result = tf.step(a); - expect(result.dtype).toEqual('int32'); - expectArraysClose(await result.data(), [1, 0, 1, 0]); - }); - - it('gradients: Scalar', async () => { - const a = tf.scalar(-4); - const dy = tf.scalar(8); - - const gradients = tf.grad(a => tf.step(a))(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), [0]); - }); - - it('gradient with clones', async () => { - const a = tf.scalar(-4); - const dy = tf.scalar(8); - - const gradients = tf.grad(a => tf.step(a.clone()).clone())(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), [0]); - }); - - it('gradients: Tensor1D', async () => { - const a = tf.tensor1d([1, 2, -3, 5]); - const dy = tf.tensor1d([1, 2, 3, 4]); - - const gradients = tf.grad(a => tf.step(a))(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), [0, 0, 0, 0]); - }); - - it('gradients: Tensor2D', async () => { - const a = tf.tensor2d([3, -1, -2, 3], [2, 2]); - const dy = tf.tensor2d([1, 2, 3, 4], [2, 2]); - - const gradients = tf.grad(a => tf.step(a))(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), [0, 0, 0, 0]); - }); - - it('throws when passed a non-tensor', () => { - expect(() => tf.step({} as tf.Tensor)) - .toThrowError(/Argument 'x' passed to 'step' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const result = tf.step([1, -2, -.01, 3, -0.1]); - expectArraysClose(await result.data(), [1, 0, 0, 1, 0]); - }); - - it('throws for string tensor', () => { - expect(() => tf.step('q')) - .toThrowError(/Argument 'x' passed to 'step' must be numeric/); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/strided_slice.ts b/tfjs-master/tfjs-core/src/ops/strided_slice.ts deleted file mode 100644 index 22165786e..000000000 --- a/tfjs-master/tfjs-core/src/ops/strided_slice.ts +++ /dev/null @@ -1,84 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {StridedSlice, StridedSliceAttrs, StridedSliceInputs} from '../kernel_names'; -import {NamedAttrMap} from '../kernel_registry'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -import {op} from './operation'; - -/** - * Extracts a strided slice of a tensor. - * - * Roughly speaking, this op extracts a slice of size (end-begin)/stride from - * the given input tensor (x). Starting at the location specified by begin the - * slice continues by adding stride to the index until all dimensions are not - * less than end. Note that a stride can be negative, which causes a reverse - * slice. - * - * ```js - * const t = tf.tensor3d([1, 1, 1 ,2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6], - * [3, 2, 3]); - * t.stridedSlice([1, 0, 0], [2, 1, 3], [1, 1, 1]).print() // [[[3, 3, 3]]] - * t.stridedSlice([1, 0, 0], [2, 2, 3], [1, 1, 1]).print() // [[[3, 3, 3], - * // [4, 4, 4]]] - * t.stridedSlice([1, -1, 0], [2, -3, 3], [1, -1, 1]).print() // [[[4, 4, 4], - * // [3, 3, 3]]] - * ``` - * - * @param x The tensor to stride slice. - * @param begin The coordinates to start the slice from. - * @param end: The coordinates to end the slice at. - * @param strides: The size of the slice. - * @param beginMask: If the ith bit of beginMask is set, begin[i] is ignored - * and the fullest possible range in that dimension is used instead. - * @param endMask: If the ith bit of endMask is set, end[i] is ignored - * and the fullest possible range in that dimension is used instead. - * @param shrinkAxisMask: a bitmask where bit i implies that - * the ith specification should shrink the dimensionality. begin and end must - * imply a slice of size 1 in the dimension. - * - * @doc {heading: 'Operations', subheading: 'Slicing and Joining'} - */ -function stridedSlice_( - x: Tensor|TensorLike, begin: number[], end: number[], strides?: number[], - beginMask = 0, endMask = 0, ellipsisMask = 0, newAxisMask = 0, - shrinkAxisMask = 0): Tensor { - const $x = convertToTensor(x, 'x', 'stridedSlice', 'string_or_numeric'); - - const inputs: StridedSliceInputs = {x: $x}; - const attrs: StridedSliceAttrs = { - begin, - end, - strides, - beginMask, - endMask, - ellipsisMask, - newAxisMask, - shrinkAxisMask - }; - - return ENGINE.runKernel( - StridedSlice, inputs as unknown as NamedTensorMap, - attrs as unknown as NamedAttrMap); -} - -export const stridedSlice = /* @__PURE__ */ op({stridedSlice_}); diff --git a/tfjs-master/tfjs-core/src/ops/strided_slice_test.ts b/tfjs-master/tfjs-core/src/ops/strided_slice_test.ts deleted file mode 100644 index 3c40aa628..000000000 --- a/tfjs-master/tfjs-core/src/ops/strided_slice_test.ts +++ /dev/null @@ -1,491 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {backend} from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('stridedSlice', ALL_ENVS, () => { - it('with ellipsisMask=1', async () => { - const t = tf.tensor2d([ - [1, 2, 3, 4, 5], - [2, 3, 4, 5, 6], - [3, 4, 5, 6, 7], - [4, 5, 6, 7, 8], - [5, 6, 7, 8, 9], - [6, 7, 8, 9, 10], - [7, 8, 9, 10, 11], - [8, 8, 9, 10, 11], - [9, 8, 9, 10, 11], - [10, 8, 9, 10, 11], - ]); - const begin = [0, 4]; - const end = [0, 5]; - const strides = [1, 1]; - const beginMask = 0; - const endMask = 0; - const ellipsisMask = 1; - const output = - t.stridedSlice(begin, end, strides, beginMask, endMask, ellipsisMask); - expect(output.shape).toEqual([10, 1]); - expectArraysClose(await output.data(), [5, 6, 7, 8, 9, 10, 11, 11, 11, 11]); - }); - - it('with ellipsisMask=1, begin / end masks and start / end normalization', - async () => { - const t = tf.randomNormal([1, 6, 2006, 4]); - const output = - tf.stridedSlice(t, [0, 0, 0], [0, 2004, 0], [1, 1, 1], 6, 4, 1); - expect(output.shape).toEqual([1, 6, 2004, 4]); - }); - - it('with ellipsisMask=1 and start / end normalization', async () => { - const t = tf.tensor3d([ - [[1, 1, 1], [2, 2, 2]], [[3, 3, 3], [4, 4, 4]], [[5, 5, 5], [6, 6, 6]] - ]); - const begin = [1, 0]; - const end = [2, 1]; - const strides = [1, 1]; - const beginMask = 0; - const endMask = 0; - const ellipsisMask = 1; - - const output = tf.stridedSlice( - t, begin, end, strides, beginMask, endMask, ellipsisMask); - expect(output.shape).toEqual([3, 2, 1]); - expectArraysClose(await output.data(), [1, 2, 3, 4, 5, 6]); - }); - - it('with ellipsisMask=2', async () => { - const t = tf.tensor3d([ - [[1, 1, 1], [2, 2, 2]], [[3, 3, 3], [4, 4, 4]], [[5, 5, 5], [6, 6, 6]] - ]); - const begin = [1, 0, 0]; - const end = [2, 1, 3]; - const strides = [1, 1, 1]; - const beginMask = 0; - const endMask = 0; - const ellipsisMask = 2; - const output = tf.stridedSlice( - t, begin, end, strides, beginMask, endMask, ellipsisMask); - expect(output.shape).toEqual([1, 2, 3]); - expectArraysClose(await output.data(), [3, 3, 3, 4, 4, 4]); - }); - - it('with ellipsisMask=2 and start / end normalization', async () => { - const t = tf.tensor4d([ - [[[1, 1], [1, 1], [1, 1]], [[2, 2], [2, 2], [2, 2]]], - - [[[3, 3], [3, 3], [3, 3]], [[4, 4], [4, 4], [4, 4]]], - - [[[5, 5], [5, 5], [5, 5]], [[6, 6], [6, 6], [6, 6]]] - ]); - - const begin = [1, 0, 0]; - const end = [2, 1, 1]; - const strides = [1, 1, 1]; - const beginMask = 0; - const endMask = 0; - const ellipsisMask = 2; - const output = tf.stridedSlice( - t, begin, end, strides, beginMask, endMask, ellipsisMask); - expect(output.shape).toEqual([1, 2, 3, 1]); - expectArraysClose(await output.data(), [3, 3, 3, 4, 4, 4]); - }); - - it('both ellipsis mask and newAxisMask are set', async () => { - const tensor = tf.tensor1d([0, 1, 2, 3]); - const result = tf.stridedSlice(tensor, [0], [3], [2], 0, 0, 1, 1); - expectArraysClose(await result.data(), [0, 1, 2, 3]); - }); - - it('both ellipsis mask and shrinkAxisMask are set', async () => { - const tensor = tf.tensor1d([0, 1, 2, 3]); - const result = tf.stridedSlice(tensor, [0], [3], [2], 0, 0, 1, 0, 1); - expectArraysClose(await result.data(), [0, 1, 2, 3]); - }); - - it('stridedSlice with first axis being new', async () => { - // Python slice code: t[tf.newaxis,0:3] - const t = tf.tensor1d([0, 1, 2, 3]); - const begin = [0, 0]; - const end = [1, 3]; - const strides = [1, 2]; - const beginMask = 0; - const endMask = 0; - const ellipsisMask = 0; - const newAxisMask = 1; - - const output = tf.stridedSlice( - t, begin, end, strides, beginMask, endMask, ellipsisMask, newAxisMask); - expect(output.shape).toEqual([1, 2]); - expectArraysClose(await output.data(), [0, 2]); - }); - - it('strided slice with several new axes', async () => { - // Python slice code: t[1:2,tf.newaxis,0:3,tf.newaxis,2:5] - const t = tf.zeros([2, 3, 4, 5]); - const begin = [1, 0, 0, 0, 2]; - const end = [2, 1, 3, 1, 5]; - const strides: number[] = [1, 1, 1, 1, 1]; - const beginMask = 0; - const endMask = 0; - const ellipsisMask = 0; - const newAxisMask = 0b1010; - const output = tf.stridedSlice( - t, begin, end, strides, beginMask, endMask, ellipsisMask, newAxisMask); - expect(output.shape).toEqual([1, 1, 3, 1, 2, 5]); - expectArraysClose(await output.data(), new Array(30).fill(0)); - }); - - it('strided slice with new axes and shrink axes', () => { - // Python slice code: t[1:2,tf.newaxis,1,tf.newaxis,2,2:5] - const t = tf.zeros([2, 3, 4, 5]); - const begin = [1, 0, 1, 0, 2, 2]; - const end = [2, 1, 2, 1, 3, 5]; - const strides: number[] = [1, 1, 1, 1, 1, 1]; - const beginMask = 0; - const endMask = 0; - const ellipsisMask = 0; - const newAxisMask = 0b1010; - const shrinkAxisMask = 0b10100; - const output = tf.stridedSlice( - t, begin, end, strides, beginMask, endMask, ellipsisMask, newAxisMask, - shrinkAxisMask); - expect(output.shape).toEqual([1, 1, 1, 3]); - }); - - it('stridedSlice should support 1d tensor', async () => { - const tensor = tf.tensor1d([0, 1, 2, 3]); - const output = tf.stridedSlice(tensor, [0], [3], [2]); - expect(output.shape).toEqual([2]); - expectArraysClose(await output.data(), [0, 2]); - }); - - it('stridedSlice should support 1d tensor', async () => { - const tensor = tf.tensor1d([0, 1, 2, 3]); - const output = tf.stridedSlice(tensor, [0], [3], [2]); - expect(output.shape).toEqual([2]); - expectArraysClose(await output.data(), [0, 2]); - }); - - it('stridedSlice with 1d tensor should be used by tensor directly', - async () => { - const t = tf.tensor1d([0, 1, 2, 3]); - const output = t.stridedSlice([0], [3], [2]); - expect(output.shape).toEqual([2]); - expectArraysClose(await output.data(), [0, 2]); - }); - - it('stridedSlice should support 1d tensor empty result', async () => { - const tensor = tf.tensor1d([0, 1, 2, 3]); - const output = tf.stridedSlice(tensor, [10], [3], [2]); - expect(output.shape).toEqual([0]); - expectArraysClose(await output.data(), []); - }); - - it('stridedSlice should support 1d tensor negative begin', async () => { - const tensor = tf.tensor1d([0, 1, 2, 3]); - const output = tf.stridedSlice(tensor, [-3], [3], [1]); - expect(output.shape).toEqual([2]); - expectArraysClose(await output.data(), [1, 2]); - }); - - it('stridedSlice should support 1d tensor out of range begin', async () => { - const tensor = tf.tensor1d([0, 1, 2, 3]); - const output = tf.stridedSlice(tensor, [-5], [3], [1]); - expect(output.shape).toEqual([3]); - expectArraysClose(await output.data(), [0, 1, 2]); - }); - - it('stridedSlice should support 1d tensor negative end', async () => { - const tensor = tf.tensor1d([0, 1, 2, 3]); - const output = tf.stridedSlice(tensor, [1], [-2], [1]); - expect(output.shape).toEqual([1]); - expectArraysClose(await output.data(), [1]); - }); - - it('stridedSlice should support 1d tensor out of range end', async () => { - const tensor = tf.tensor1d([0, 1, 2, 3]); - const output = tf.stridedSlice(tensor, [-3], [5], [1]); - expect(output.shape).toEqual([3]); - expectArraysClose(await output.data(), [1, 2, 3]); - }); - - it('stridedSlice should support 1d tensor begin mask', async () => { - const tensor = tf.tensor1d([0, 1, 2, 3]); - const output = tf.stridedSlice(tensor, [1], [3], [1], 1); - expect(output.shape).toEqual([3]); - expectArraysClose(await output.data(), [0, 1, 2]); - }); - - it('stridedSlice should support 1d tensor nagtive begin and stride', - async () => { - const tensor = tf.tensor1d([0, 1, 2, 3]); - const output = tf.stridedSlice(tensor, [-2], [-3], [-1]); - expect(output.shape).toEqual([1]); - expectArraysClose(await output.data(), [2]); - }); - - it('stridedSlice should support 1d tensor' + - ' out of range begin and negative stride', - async () => { - const tensor = tf.tensor1d([0, 1, 2, 3]); - const output = tf.stridedSlice(tensor, [5], [-2], [-1]); - expect(output.shape).toEqual([1]); - expectArraysClose(await output.data(), [3]); - }); - - it('stridedSlice should support 1d tensor nagtive end and stride', - async () => { - const tensor = tf.tensor1d([0, 1, 2, 3]); - const output = tf.stridedSlice(tensor, [2], [-4], [-1]); - expect(output.shape).toEqual([2]); - expectArraysClose(await output.data(), [2, 1]); - }); - - it('stridedSlice should support 1d tensor' + - ' out of range end and negative stride', - async () => { - const tensor = tf.tensor1d([0, 1, 2, 3]); - const output = tf.stridedSlice(tensor, [-3], [-5], [-1]); - expect(output.shape).toEqual([2]); - expectArraysClose(await output.data(), [1, 0]); - }); - - it('stridedSlice should support 1d tensor end mask', async () => { - const tensor = tf.tensor1d([0, 1, 2, 3]); - const output = tf.stridedSlice(tensor, [1], [3], [1], 0, 1); - expect(output.shape).toEqual([3]); - expectArraysClose(await output.data(), [1, 2, 3]); - }); - - it('stridedSlice should support 1d tensor shrink axis mask', async () => { - const tensor = tf.tensor1d([0, 1, 2, 3]); - const output = tf.stridedSlice(tensor, [1], [3], [1], 0, 0, 0, 0, 1); - expect(output.shape).toEqual([]); - expectArraysClose(await output.data(), [1]); - }); - - it('stridedSlice should support 1d tensor negative stride', async () => { - const tensor = tf.tensor1d([0, 1, 2, 3]); - const output = tf.stridedSlice(tensor, [-1], [-4], [-1]); - expect(output.shape).toEqual([3]); - expectArraysClose(await output.data(), [3, 2, 1]); - }); - - it('stridedSlice should support 1d tensor even length stride', async () => { - const tensor = tf.tensor1d([0, 1, 2, 3]); - const output = tf.stridedSlice(tensor, [0], [2], [2]); - expect(output.shape).toEqual([1]); - expectArraysClose(await output.data(), [0]); - }); - - it('stridedSlice should support 1d tensor odd length stride', async () => { - const tensor = tf.tensor1d([0, 1, 2, 3]); - const output = tf.stridedSlice(tensor, [0], [3], [2]); - expect(output.shape).toEqual([2]); - expectArraysClose(await output.data(), [0, 2]); - }); - - it('stridedSlice should support 2d tensor identity', async () => { - const tensor = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - const output = tf.stridedSlice(tensor, [0, 0], [2, 3], [1, 1]); - expect(output.shape).toEqual([2, 3]); - expectArraysClose(await output.data(), [1, 2, 3, 4, 5, 6]); - }); - - it('stridedSlice should support 2d tensor', async () => { - const tensor = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - const output = tf.stridedSlice(tensor, [1, 0], [2, 2], [1, 1]); - expect(output.shape).toEqual([1, 2]); - expectArraysClose(await output.data(), [4, 5]); - }); - - it('stridedSlice should support 2d tensor strides', async () => { - const tensor = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - const output = tf.stridedSlice(tensor, [0, 0], [2, 3], [2, 2]); - expect(output.shape).toEqual([1, 2]); - expectArraysClose(await output.data(), [1, 3]); - }); - - it('stridedSlice with 2d tensor should be used by tensor directly', - async () => { - const t = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - const output = t.stridedSlice([1, 0], [2, 2], [1, 1]); - expect(output.shape).toEqual([1, 2]); - expectArraysClose(await output.data(), [4, 5]); - }); - - it('stridedSlice should support 2d tensor negative strides', async () => { - const tensor = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - const output = tf.stridedSlice(tensor, [1, -1], [2, -4], [2, -1]); - expect(output.shape).toEqual([1, 3]); - expectArraysClose(await output.data(), [6, 5, 4]); - }); - - it('stridedSlice should support 2d tensor begin mask', async () => { - const tensor = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - const output = tf.stridedSlice(tensor, [1, 0], [2, 2], [1, 1], 1); - expect(output.shape).toEqual([2, 2]); - expectArraysClose(await output.data(), [1, 2, 4, 5]); - }); - - it('stridedSlice should support 2d tensor shrink mask', async () => { - const tensor = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - const output = - tf.stridedSlice(tensor, [1, 0], [2, 2], [1, 1], 0, 0, 0, 0, 1); - expect(output.shape).toEqual([2]); - expectArraysClose(await output.data(), [4, 5]); - }); - - it('stridedSlice should support 2d tensor end mask', async () => { - const tensor = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - const output = tf.stridedSlice(tensor, [1, 0], [2, 2], [1, 1], 0, 2); - expect(output.shape).toEqual([1, 3]); - expectArraysClose(await output.data(), [4, 5, 6]); - }); - - it('stridedSlice should support 2d tensor' + - ' negative strides and begin mask', - async () => { - const tensor = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - const output = tf.stridedSlice(tensor, [1, -2], [2, -4], [1, -1], 2); - expect(output.shape).toEqual([1, 3]); - expectArraysClose(await output.data(), [6, 5, 4]); - }); - - it('stridedSlice should support 2d tensor' + - ' negative strides and end mask', - async () => { - const tensor = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - const output = tf.stridedSlice(tensor, [1, -2], [2, -3], [1, -1], 0, 2); - expect(output.shape).toEqual([1, 2]); - expectArraysClose(await output.data(), [5, 4]); - }); - - it('stridedSlice should support 3d tensor identity', async () => { - const tensor = - tf.tensor3d([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [2, 3, 2]); - const output = tf.stridedSlice(tensor, [0, 0, 0], [2, 3, 2], [1, 1, 1]); - expect(output.shape).toEqual([2, 3, 2]); - expectArraysClose( - await output.data(), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]); - }); - - it('stridedSlice should support 3d tensor negative stride', async () => { - const tensor = - tf.tensor3d([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [2, 3, 2]); - const output = - tf.stridedSlice(tensor, [-1, -1, -1], [-3, -4, -3], [-1, -1, -1]); - expect(output.shape).toEqual([2, 3, 2]); - expectArraysClose( - await output.data(), [12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]); - }); - - it('stridedSlice should support 3d tensor strided 2', async () => { - const tensor = - tf.tensor3d([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [2, 3, 2]); - const output = tf.stridedSlice(tensor, [0, 0, 0], [2, 3, 2], [2, 2, 2]); - expect(output.shape).toEqual([1, 2, 1]); - expectArraysClose(await output.data(), [1, 5]); - }); - - it('stridedSlice should support 3d tensor shrink mask', async () => { - const tensor = - tf.tensor3d([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [2, 3, 2]); - const output = - tf.stridedSlice(tensor, [0, 0, 0], [2, 3, 2], [1, 1, 1], 0, 0, 0, 0, 1); - expect(output.shape).toEqual([3, 2]); - expectArraysClose(await output.data(), [1, 2, 3, 4, 5, 6]); - }); - - it('stridedSlice should support 3d with smaller length of begin array', - async () => { - const tensor = - tf.tensor4d([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [2, 3, 1, 2]); - const output = - tf.stridedSlice(tensor, [1, 0], [2, 3], [1, 1], 0, 0, 0, 0, 0); - expect(output.shape).toEqual([1, 3, 1, 2]); - expectArraysClose(await output.data(), [7, 8, 9, 10, 11, 12]); - }); - - it('stridedSlice should support 3d with smaller length of end array', - async () => { - const tensor = - tf.tensor4d([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [2, 3, 1, 2]); - const output = - tf.stridedSlice(tensor, [1, 0], [2, 3], [1, 1], 0, 0, 0, 0, 0); - expect(output.shape).toEqual([1, 3, 1, 2]); - expectArraysClose(await output.data(), [7, 8, 9, 10, 11, 12]); - }); - - it('stridedSlice should throw when passed a non-tensor', () => { - expect(() => tf.stridedSlice({} as tf.Tensor, [0], [0], [1])) - .toThrowError(/Argument 'x' passed to 'stridedSlice' must be a Tensor/); - }); - - it('stridedSlice should handle negative end with ellipsisMask', () => { - const a = tf.ones([1, 240, 1, 10]); - const output = - tf.stridedSlice(a, [0, 0, 0], [0, -1, 0], [1, 1, 1], 3, 1, 4); - expect(output.shape).toEqual([1, 239, 1, 10]); - }); - - it('stridedSlice should handle negative begin with ellipsis_mask', () => { - const a = tf.ones([1, 36, 17, 3]); - const output = tf.stridedSlice(a, [0, -1], [0, 0], [1, 1], 0, 2, 1, 0, 0); - expect(output.shape).toEqual([1, 36, 17, 1]); - }); - - it('accepts a tensor-like object', async () => { - const tensor = [0, 1, 2, 3]; - const output = tf.stridedSlice(tensor, [0], [3], [2]); - expect(output.shape).toEqual([2]); - expectArraysClose(await output.data(), [0, 2]); - }); - - it('accepts int32 tensor', async () => { - if (backend() && backend().floatPrecision() === 32) { - // TODO: Use skip() instead when it is implemented - const tensor = tf.tensor2d([1, 2, 3, 4, 12345678, 6], [2, 3], 'int32'); - const output = tf.stridedSlice(tensor, [1, 0], [2, 2], [1, 1]); - expect(output.shape).toEqual([1, 2]); - expect(output.dtype).toEqual('int32'); - expectArraysClose(await output.data(), [4, 12345678]); - } - }); - - it('ensure no memory leak', async () => { - const numTensorsBefore = tf.memory().numTensors; - const numDataIdBefore = tf.engine().backend.numDataIds(); - - const tensor = tf.tensor1d([0, 1, 2, 3]); - const output = tf.stridedSlice(tensor, [0], [3], [2]); - expect(output.shape).toEqual([2]); - expectArraysClose(await output.data(), [0, 2]); - - tensor.dispose(); - output.dispose(); - - const numTensorsAfter = tf.memory().numTensors; - const numDataIdAfter = tf.engine().backend.numDataIds(); - expect(numTensorsAfter).toBe(numTensorsBefore); - expect(numDataIdAfter).toBe(numDataIdBefore); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/string/static_regex_replace.ts b/tfjs-master/tfjs-core/src/ops/string/static_regex_replace.ts deleted file mode 100644 index 8656a2429..000000000 --- a/tfjs-master/tfjs-core/src/ops/string/static_regex_replace.ts +++ /dev/null @@ -1,56 +0,0 @@ -/** - * @license - * Copyright 2023 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../../engine'; -import {StaticRegexReplace, StaticRegexReplaceAttrs} from '../../kernel_names'; -import {NamedAttrMap} from '../../kernel_registry'; -import {Tensor} from '../../tensor'; -import {convertToTensor} from '../../tensor_util_env'; -import {TensorLike} from '../../types'; -import {op} from '../operation'; - -/** - * Replace the match of a `pattern` in `input` with `rewrite`. - * - * ```js - * const result = tf.string.staticRegexReplace( - * ['format this spacing better'], ' +', ' '); - * result.print(); // ['format this spacing better'] - * ``` - * @param input: A Tensor of type string. The text to be processed. - * @param pattern: A string. The regular expression to match the input. - * @param rewrite: A string. The rewrite to be applied to the matched - * expression. - * @param replaceGlobal: An optional bool. Defaults to True. If True, the - * replacement is global, otherwise the replacement is done only on the - * first match. - * @return A Tensor of type string. - * - * @doc {heading: 'Operations', subheading: 'String'} - */ -function staticRegexReplace_( - input: Tensor | TensorLike, pattern: string, rewrite: string, - replaceGlobal=true): Tensor { - - const $input = convertToTensor(input, 'input', 'staticRegexReplace', - 'string'); - const attrs: StaticRegexReplaceAttrs = {pattern, rewrite, replaceGlobal}; - return ENGINE.runKernel(StaticRegexReplace, {x: $input}, - attrs as unknown as NamedAttrMap); -} - -export const staticRegexReplace = /* @__PURE__ */ op({staticRegexReplace_}); diff --git a/tfjs-master/tfjs-core/src/ops/string/static_regex_replace_test.ts b/tfjs-master/tfjs-core/src/ops/string/static_regex_replace_test.ts deleted file mode 100644 index a10ef1e45..000000000 --- a/tfjs-master/tfjs-core/src/ops/string/static_regex_replace_test.ts +++ /dev/null @@ -1,46 +0,0 @@ -/** - * @license - * Copyright 2023 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../../index'; -import { DataTypeFor } from '../../index'; -import {ALL_ENVS, describeWithFlags} from '../../jasmine_util'; - -describeWithFlags('staticRegexReplace', ALL_ENVS, () => { - it('replaces the first instance of a string', async () => { - const result = tf.string.staticRegexReplace( - ['this', 'is', 'a', 'test test'], 'test', 'result', false); - - expect(await result.data>()) - .toEqual(['this', 'is', 'a', 'result test']); - }); - - it('replaces a string globally by default', async () => { - const result = tf.string.staticRegexReplace( - ['this', 'is', 'a', 'test test'], 'test', 'result'); - - expect(await result.data>()) - .toEqual(['this', 'is', 'a', 'result result']); - }); - - it('matches using regex', async () => { - const result = tf.string.staticRegexReplace( - ['This will have normal whitespace'], ' +', ' '); - - expect(await result.data>()) - .toEqual(['This will have normal whitespace']); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/string/string_n_grams.ts b/tfjs-master/tfjs-core/src/ops/string/string_n_grams.ts deleted file mode 100644 index b17df03b3..000000000 --- a/tfjs-master/tfjs-core/src/ops/string/string_n_grams.ts +++ /dev/null @@ -1,99 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../../engine'; -import {StringNGrams, StringNGramsAttrs, StringNGramsInputs} from '../../kernel_names'; -import {Tensor, Tensor1D} from '../../tensor'; -import {NamedTensorMap} from '../../tensor_types'; -import {convertToTensor} from '../../tensor_util_env'; -import {TensorLike} from '../../types'; -import {op} from '../operation'; - -/** - * Creates ngrams from ragged string data. - * - * This op accepts a ragged tensor with 1 ragged dimension containing only - * strings and outputs a ragged tensor with 1 ragged dimension containing ngrams - * of that string, joined along the innermost axis. - * - * ```js - * const result = tf.string.stringNGrams( - * ['a', 'b', 'c', 'd'], tf.tensor1d([0, 2, 4], 'int32'), - * '|', [1, 2], 'LP', 'RP', -1, false); - * result['nGrams'].print(); // ['a', 'b', 'LP|a', 'a|b', 'b|RP', - * // 'c', 'd', 'LP|c', 'c|d', 'd|RP'] - * result['nGramsSplits'].print(); // [0, 5, 10] - * ``` - * @param data: The values tensor of the ragged string tensor to make ngrams out - * of. Must be a 1D string tensor. - * @param dataSplits: The splits tensor of the ragged string tensor to make - * ngrams out of. - * @param separator: The string to append between elements of the token. Use "" - * for no separator. - * @param nGramWidths: The sizes of the ngrams to create. - * @param leftPad: The string to use to pad the left side of the ngram sequence. - * Only used if pad_width !== 0. - * @param rightPad: The string to use to pad the right side of the ngram - * sequence. Only used if pad_width !== 0. - * @param padWidth: The number of padding elements to add to each side of each - * sequence. Note that padding will never be greater than `nGramWidths`-1 - * regardless of this value. If `padWidth`=-1, then add max(`nGramWidths`)-1 - * elements. - * @param preserveShortSequences: If true, then ensure that at least one ngram - * is generated for each input sequence. In particular, if an input sequence - * is shorter than min(ngramWidth) + 2*padWidth, then generate a single - * ngram containing the entire sequence. If false, then no ngrams are - * generated for these short input sequences. - * @return A map with the following properties: - * - nGrams: The values tensor of the output ngrams ragged tensor. - * - nGramsSplits: The splits tensor of the output ngrams ragged tensor. - * - * @doc {heading: 'Operations', subheading: 'String'} - */ -function stringNGrams_( - data: Tensor1D|TensorLike, dataSplits: Tensor|TensorLike, separator: string, - nGramWidths: number[], leftPad: string, rightPad: string, padWidth: number, - preserveShortSequences: boolean): NamedTensorMap { - const $data = convertToTensor(data, 'data', 'stringNGrams', 'string'); - if ($data.dtype !== 'string') { - throw new Error('Data must be of datatype string'); - } - if ($data.shape.length !== 1) { - throw new Error(`Data must be a vector, saw: ${$data.shape}`); - } - - const $dataSplits = convertToTensor(dataSplits, 'dataSplits', 'stringNGrams'); - if ($dataSplits.dtype !== 'int32') { - throw new Error('Data splits must be of datatype int32'); - } - - const attrs: StringNGramsAttrs = { - separator, - nGramWidths, - leftPad, - rightPad, - padWidth, - preserveShortSequences - }; - - const inputs: StringNGramsInputs = {data: $data, dataSplits: $dataSplits}; - const result: Tensor[] = - ENGINE.runKernel(StringNGrams, inputs as {}, attrs as {}); - return {nGrams: result[0], nGramsSplits: result[1]}; -} - -export const stringNGrams = /* @__PURE__ */ op({stringNGrams_}); diff --git a/tfjs-master/tfjs-core/src/ops/string/string_n_grams_test.ts b/tfjs-master/tfjs-core/src/ops/string/string_n_grams_test.ts deleted file mode 100644 index 88c5c3d7e..000000000 --- a/tfjs-master/tfjs-core/src/ops/string/string_n_grams_test.ts +++ /dev/null @@ -1,465 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../../index'; -import {ALL_ENVS, describeWithFlags} from '../../jasmine_util'; -import {expectArraysEqual} from '../../test_util'; - -async function expectResult( - result: tf.NamedTensorMap, nGrams: string[], nGramsSplits: number[]) { - expectArraysEqual(await result.nGrams.data(), nGrams); - expectArraysEqual(await result.nGramsSplits.data(), nGramsSplits); - - expect(result.nGrams.shape).toEqual([nGrams.length]); - expect(result.nGramsSplits.shape).toEqual([nGramsSplits.length]); - - expect(result.nGrams.dtype).toEqual('string'); - expect(result.nGramsSplits.dtype).toEqual('int32'); -} - -describeWithFlags('stringNGrams', ALL_ENVS, () => { - it('padded trigrams', async () => { - // Batch items are: - // 0: "a", "b", "c", "d" - // 1: "e", "f" - const result = tf.string.stringNGrams( - ['a', 'b', 'c', 'd', 'e', 'f'], tf.tensor1d([0, 4, 6], 'int32'), '|', - [3], 'LP', 'RP', -1, false); - const nGrams = [ - 'LP|LP|a', 'LP|a|b', 'a|b|c', 'b|c|d', 'c|d|RP', 'd|RP|RP', // 0 - 'LP|LP|e', 'LP|e|f', 'e|f|RP', 'f|RP|RP' // 1 - ]; - const nGramsSplits = [0, 6, 10]; - await expectResult(result, nGrams, nGramsSplits); - }); - - it('padded bigrams and trigrams', async () => { - // Batch items are: - // 0: "a", "b", "c", "d" - // 1: "e", "f" - const result = tf.string.stringNGrams( - ['a', 'b', 'c', 'd', 'e', 'f'], tf.tensor1d([0, 4, 6], 'int32'), '|', - [2, 3], 'LP', 'RP', -1, false); - const nGrams = [ - 'LP|a', 'a|b', 'b|c', 'c|d', 'd|RP', 'LP|LP|a', 'LP|a|b', 'a|b|c', - 'b|c|d', 'c|d|RP', 'd|RP|RP', // 0 - 'LP|e', 'e|f', 'f|RP', 'LP|LP|e', 'LP|e|f', 'e|f|RP', 'f|RP|RP' // 1 - ]; - const nGramsSplits = [0, 11, 18]; - await expectResult(result, nGrams, nGramsSplits); - }); - - it('padded bigrams', async () => { - // Batch items are: - // 0: "a", "b", "c", "d" - // 1: "e", "f" - const result = tf.string.stringNGrams( - ['a', 'b', 'c', 'd', 'e', 'f'], tf.tensor1d([0, 4, 6], 'int32'), '|', - [2], 'LP', 'RP', -1, false); - const nGrams = [ - 'LP|a', 'a|b', 'b|c', 'c|d', 'd|RP', // 0 - 'LP|e', 'e|f', 'f|RP' // 1 - ]; - const nGramsSplits = [0, 5, 8]; - await expectResult(result, nGrams, nGramsSplits); - }); - - it('padding is at most nGramSize - 1', async () => { - // Batch items are: - // 0: "a", "b", "c", "d" - // 1: "e", "f" - const result = tf.string.stringNGrams( - ['a', 'b', 'c', 'd', 'e', 'f'], tf.tensor1d([0, 4, 6], 'int32'), '|', - [2], 'LP', 'RP', 4, false); - const nGrams = [ - 'LP|a', 'a|b', 'b|c', 'c|d', 'd|RP', // 0 - 'LP|e', 'e|f', 'f|RP' // 1 - ]; - const nGramsSplits = [0, 5, 8]; - await expectResult(result, nGrams, nGramsSplits); - }); - - it('padded unigram and bigrams', async () => { - // Batch items are: - // 0: "a", "b", "c", "d" - // 1: "e", "f" - const result = tf.string.stringNGrams( - ['a', 'b', 'c', 'd', 'e', 'f'], tf.tensor1d([0, 4, 6], 'int32'), '|', - [1, 2], 'LP', 'RP', -1, false); - const nGrams = [ - 'a', 'b', 'c', 'd', 'LP|a', 'a|b', 'b|c', 'c|d', 'd|RP', // 0 - 'e', 'f', 'LP|e', 'e|f', 'f|RP' // 1 - ]; - const nGramsSplits = [0, 9, 14]; - await expectResult(result, nGrams, nGramsSplits); - }); - - it('overlapping padded nGrams', async () => { - // This test validates that n-grams with both left and right padding in a - // single ngram token are created correctly. - - // Batch items are: - // 0: "a" - // 1: "b", "c", "d" - // 2: "e", "f" - const result = tf.string.stringNGrams( - ['a', 'b', 'c', 'd', 'e', 'f'], tf.tensor1d([0, 1, 4, 6], 'int32'), '|', - [3], 'LP', 'RP', -1, false); - const nGrams = [ - 'LP|LP|a', 'LP|a|RP', 'a|RP|RP', // 0 - 'LP|LP|b', 'LP|b|c', 'b|c|d', 'c|d|RP', 'd|RP|RP', // 1 - 'LP|LP|e', 'LP|e|f', 'e|f|RP', 'f|RP|RP' // 2 - ]; - const nGramsSplits = [0, 3, 8, 12]; - await expectResult(result, nGrams, nGramsSplits); - }); - - it('overlapping padded multi char nGrams', async () => { - // Batch items are: - // 0: "a" - // 1: "b", "c", "d" - // 2: "e", "f" - const result = tf.string.stringNGrams( - ['aa', 'bb', 'cc', 'dd', 'ee', 'ff'], - tf.tensor1d([0, 1, 4, 6], 'int32'), '|', [3], 'LP', 'RP', -1, false); - const nGrams = [ - 'LP|LP|aa', 'LP|aa|RP', 'aa|RP|RP', // 0 - 'LP|LP|bb', 'LP|bb|cc', 'bb|cc|dd', 'cc|dd|RP', 'dd|RP|RP', // 1 - 'LP|LP|ee', 'LP|ee|ff', 'ee|ff|RP', 'ff|RP|RP' // 2 - ]; - const nGramsSplits = [0, 3, 8, 12]; - await expectResult(result, nGrams, nGramsSplits); - }); - - it('multi overlapping padded nGrams', async () => { - // This test validates that n-grams with more than 1 padding value on each - // side are created correctly. - - // Batch items are: - // 0: "a" - const result = tf.string.stringNGrams( - ['a'], tf.tensor1d([0, 1], 'int32'), '|', [5], 'LP', 'RP', -1, false); - const nGrams = [ - 'LP|LP|LP|LP|a', 'LP|LP|LP|a|RP', 'LP|LP|a|RP|RP', 'LP|a|RP|RP|RP', - 'a|RP|RP|RP|RP' - ]; - const nGramsSplits = [0, 5]; - await expectResult(result, nGrams, nGramsSplits); - }); - - it('unpadded trigrams', async () => { - // Batch items are: - // 0: "a", "b", "c", "d" - // 1: "e", "f" - const result = tf.string.stringNGrams( - ['a', 'b', 'c', 'd', 'e', 'f'], tf.tensor1d([0, 4, 6], 'int32'), '|', - [3], '', '', 0, false); - const nGrams = ['a|b|c', 'b|c|d']; - const nGramsSplits = [0, 2, 2]; - await expectResult(result, nGrams, nGramsSplits); - }); - - it('unpadded trigrams with empty sequence', async () => { - // Batch items are: - // 0: "a", "b", "c", "d" - // 1: "e", "f" - const result = tf.string.stringNGrams( - ['a', 'b', 'c', 'd', 'e', 'f'], tf.tensor1d([0, 4, 4, 6], 'int32'), '|', - [3], '', '', 0, false); - const nGrams = ['a|b|c', 'b|c|d']; - const nGramsSplits = [0, 2, 2, 2]; - await expectResult(result, nGrams, nGramsSplits); - }); - - it('unpadded trigrams with preserve short', async () => { - // Batch items are: - // 0: "a", "b", "c", "d" - // 1: "e", "f" - const result = tf.string.stringNGrams( - ['a', 'b', 'c', 'd', 'e', 'f'], tf.tensor1d([0, 4, 6], 'int32'), '|', - [3], '', '', 0, true); - const nGrams = ['a|b|c', 'b|c|d', 'e|f']; - const nGramsSplits = [0, 2, 3]; - await expectResult(result, nGrams, nGramsSplits); - }); - - it('unpadded trigrams with preserve short and empty sequence', async () => { - // Batch items are: - // 0: "a", "b", "c", "d" - // 1: "e", "f" - const result = tf.string.stringNGrams( - ['a', 'b', 'c', 'd', 'e', 'f'], tf.tensor1d([0, 4, 4, 6], 'int32'), '|', - [3], '', '', 0, true); - const nGrams = ['a|b|c', 'b|c|d', 'e|f']; - const nGramsSplits = [0, 2, 2, 3]; - await expectResult(result, nGrams, nGramsSplits); - }); - - it('unpadded trigrams and quad grams with preserve short', async () => { - // Batch items are: - // 0: "a", "b", "c", "d" - // 1: "e", "f" - const result = tf.string.stringNGrams( - ['a', 'b', 'c', 'd', 'e', 'f'], tf.tensor1d([0, 4, 6], 'int32'), '|', - [4, 3], '', '', 0, true); - const nGrams = ['a|b|c|d', 'a|b|c', 'b|c|d', 'e|f']; - const nGramsSplits = [0, 3, 4]; - await expectResult(result, nGrams, nGramsSplits); - }); - - it('unpadded bigrams and trigrams', async () => { - // Batch items are: - // 0: "a", "b", "c", "d" - // 1: "e", "f" - const result = tf.string.stringNGrams( - ['a', 'b', 'c', 'd', 'e', 'f'], tf.tensor1d([0, 4, 6], 'int32'), '|', - [2, 3], '', '', 0, false); - const nGrams = ['a|b', 'b|c', 'c|d', 'a|b|c', 'b|c|d', 'e|f']; - const nGramsSplits = [0, 5, 6]; - await expectResult(result, nGrams, nGramsSplits); - }); - - it('unpadded bigrams and trigrams with preserve short', async () => { - // Batch items are: - // 0: "a", "b", "c", "d" - // 1: "e", "f" - const result = tf.string.stringNGrams( - ['a', 'b', 'c', 'd', 'e', 'f'], tf.tensor1d([0, 4, 6], 'int32'), '|', - [2, 3], '', '', 0, true); - // Note that in this case, because the bigram 'e|f' was already generated, - // the op will not generate a special preserveShort bigram. - const nGrams = ['a|b', 'b|c', 'c|d', 'a|b|c', 'b|c|d', 'e|f']; - const nGramsSplits = [0, 5, 6]; - await expectResult(result, nGrams, nGramsSplits); - }); - - it('unpadded trigrams and bigrams with preserve short', async () => { - // Batch items are: - // 0: "a", "b", "c", "d" - // 1: "e", "f" - const result = tf.string.stringNGrams( - ['a', 'b', 'c', 'd', 'e', 'f'], tf.tensor1d([0, 4, 6], 'int32'), '|', - [3, 2], '', '', 0, true); - // Note that in this case, because the bigram 'e|f' was already generated, - // the op will not generate a special preserveShort bigram. - const nGrams = ['a|b|c', 'b|c|d', 'a|b', 'b|c', 'c|d', 'e|f']; - const nGramsSplits = [0, 5, 6]; - await expectResult(result, nGrams, nGramsSplits); - }); - - it('unpadded bigrams', async () => { - // Batch items are: - // 0: "a", "b", "c", "d" - // 1: "e", "f" - const result = tf.string.stringNGrams( - ['a', 'b', 'c', 'd', 'e', 'f'], tf.tensor1d([0, 4, 6], 'int32'), '|', - [2], '', '', 0, false); - const nGrams = ['a|b', 'b|c', 'c|d', 'e|f']; - const nGramsSplits = [0, 3, 4]; - await expectResult(result, nGrams, nGramsSplits); - }); - - it('overlapping unpadded nGrams', async () => { - // Batch items are: - // 0: "a" - // 1: "b", "c", "d" - // 2: "e", "f" - const result = tf.string.stringNGrams( - ['a', 'b', 'c', 'd', 'e', 'f'], tf.tensor1d([0, 1, 4, 6], 'int32'), '|', - [3], '', '', 0, false); - const nGrams = ['b|c|d']; - const nGramsSplits = [0, 0, 1, 1]; - await expectResult(result, nGrams, nGramsSplits); - }); - - it('overlapping unpadded nGrams no output', async () => { - // Batch items are: - // 0: "a" - // 1: "b", "c", "d" - // 2: "e", "f" - const result = tf.string.stringNGrams( - ['a', 'b', 'c', 'd', 'e', 'f'], tf.tensor1d([0, 1, 4, 6], 'int32'), '|', - [5], '', '', 0, false); - const nGrams: string[] = []; - const nGramsSplits = [0, 0, 0, 0]; - await expectResult(result, nGrams, nGramsSplits); - }); - - it('singly padded trigrams', async () => { - // Batch items are: - // 0: "a", "b", "c", "d" - // 1: "e", "f" - const result = tf.string.stringNGrams( - ['a', 'b', 'c', 'd', 'e', 'f'], tf.tensor1d([0, 4, 6], 'int32'), '|', - [3], 'LP', 'RP', 1, false); - const nGrams = [ - 'LP|a|b', 'a|b|c', 'b|c|d', 'c|d|RP', // 0 - 'LP|e|f', 'e|f|RP' - ]; - const nGramsSplits = [0, 4, 6]; - await expectResult(result, nGrams, nGramsSplits); - }); - - it('singly padded bigrams', async () => { - // Batch items are: - // 0: "a", "b", "c", "d" - // 1: "e", "f" - const result = tf.string.stringNGrams( - ['a', 'b', 'c', 'd', 'e', 'f'], tf.tensor1d([0, 4, 6], 'int32'), '|', - [2], 'LP', 'RP', 1, false); - const nGrams = [ - 'LP|a', 'a|b', 'b|c', 'c|d', 'd|RP', // 0 - 'LP|e', 'e|f', 'f|RP' - ]; - const nGramsSplits = [0, 5, 8]; - await expectResult(result, nGrams, nGramsSplits); - }); - - it('singly padded bigrams and 5grams', async () => { - // Batch items are: - // 0: "a", "b", "c", "d" - // 1: "e", "f" - const result = tf.string.stringNGrams( - ['a', 'b', 'c', 'd', 'e', 'f'], tf.tensor1d([0, 4, 6], 'int32'), '|', - [2, 5], 'LP', 'RP', 1, false); - const nGrams = [ - 'LP|a', 'a|b', 'b|c', 'c|d', 'd|RP', 'LP|a|b|c|d', 'a|b|c|d|RP', // 0 - 'LP|e', 'e|f', 'f|RP' - ]; - const nGramsSplits = [0, 7, 10]; - await expectResult(result, nGrams, nGramsSplits); - }); - - it('singly padded 5grams with preserve short', async () => { - // Batch items are: - // 0: "a", "b", "c", "d" - // 1: "e", "f" - const result = tf.string.stringNGrams( - ['a', 'b', 'c', 'd', 'e', 'f'], tf.tensor1d([0, 4, 6], 'int32'), '|', - [5], 'LP', 'RP', 1, true); - const nGrams = [ - 'LP|a|b|c|d', 'a|b|c|d|RP', // 0 - 'LP|e|f|RP' - ]; - const nGramsSplits = [0, 2, 3]; - await expectResult(result, nGrams, nGramsSplits); - }); - - it('overlapping singly padded nGrams', async () => { - // Batch items are: - // 0: "a" - // 1: "b", "c", "d" - // 2: "e", "f" - const result = tf.string.stringNGrams( - ['a', 'b', 'c', 'd', 'e', 'f'], tf.tensor1d([0, 1, 4, 6], 'int32'), '|', - [3], 'LP', 'RP', 1, false); - const nGrams = [ - 'LP|a|RP', // 0 - 'LP|b|c', 'b|c|d', 'c|d|RP', // 1 - 'LP|e|f', 'e|f|RP' - ]; - const nGramsSplits = [0, 1, 4, 6]; - await expectResult(result, nGrams, nGramsSplits); - }); - - it('overlapping singly padded nGrams no output', async () => { - // Batch items are: - // 0: "a" - // 1: "b", "c", "d" - // 2: "e", "f" - const result = tf.string.stringNGrams( - ['a', 'b', 'c', 'd', 'e', 'f'], tf.tensor1d([0, 1, 4, 6], 'int32'), '|', - [5], 'LP', 'RP', 1, false); - const nGrams = ['LP|b|c|d|RP']; - const nGramsSplits = [0, 0, 1, 1]; - await expectResult(result, nGrams, nGramsSplits); - }); - - it('singly padded unigrams', async () => { - // Batch items are: - // 0: "a", "b", "c", "d" - // 1: "e", "f" - const result = tf.string.stringNGrams( - ['a', 'b', 'c', 'd', 'e', 'f'], tf.tensor1d([0, 4, 6], 'int32'), '|', - [1], 'LP', 'RP', 1, false); - const nGrams = ['a', 'b', 'c', 'd', 'e', 'f']; - const nGramsSplits = [0, 4, 6]; - await expectResult(result, nGrams, nGramsSplits); - }); - - it('empty input', async () => { - const result = tf.string.stringNGrams( - tf.tensor1d([], 'string'), tf.tensor1d([], 'int32'), '|', [1], 'LP', - 'RP', 3, false); - const nGrams: string[] = []; - const nGramsSplits: number[] = []; - await expectResult(result, nGrams, nGramsSplits); - }); - - it('no tokens', async () => { - // Batch items are: - // 0: - // 1: "a" - const result = tf.string.stringNGrams( - ['a'], tf.tensor1d([0, 0, 1], 'int32'), '|', [3], 'L', 'R', -1, false); - const nGrams = [ - 'L|L|R', 'L|R|R', // no input in first split - 'L|L|a', 'L|a|R', 'a|R|R' // second split - ]; - const nGramsSplits = [0, 2, 5]; - await expectResult(result, nGrams, nGramsSplits); - }); - - it('no tokens no pad', async () => { - // Batch items are: - // 0: - // 1: "a" - const result = tf.string.stringNGrams( - ['a'], tf.tensor1d([0, 0, 1], 'int32'), '|', [3], '', '', 0, false); - const nGrams: string[] = []; - const nGramsSplits = [0, 0, 0]; - await expectResult(result, nGrams, nGramsSplits); - }); - - it('throw error if first partition index is not 0', async () => { - expect( - () => tf.string.stringNGrams( - ['a'], tf.tensor1d([1, 1, 1], 'int32'), '|', [3], '', '', 0, false)) - .toThrowError(/First split value must be 0/); - }); - - it('throw error if partition indices are decreasing', async () => { - expect( - () => tf.string.stringNGrams( - ['a'], tf.tensor1d([0, 1, 0], 'int32'), '|', [3], '', '', 0, false)) - .toThrowError(/must be in \[1, 1\]/); - }); - - it('throw error if partition index is >= input size', async () => { - expect( - () => tf.string.stringNGrams( - ['a'], tf.tensor1d([0, 2, 1], 'int32'), '|', [3], '', '', 0, false)) - .toThrowError(/must be in \[0, 1\]/); - }); - - it('throw error if last partition index is !== input size', async () => { - expect( - () => tf.string.stringNGrams( - ['a'], tf.tensor1d([0, 0], 'int32'), '|', [3], '', '', 0, false)) - .toThrowError(/Last split value must be data size/); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/string/string_split.ts b/tfjs-master/tfjs-core/src/ops/string/string_split.ts deleted file mode 100644 index 7a4ef9d9d..000000000 --- a/tfjs-master/tfjs-core/src/ops/string/string_split.ts +++ /dev/null @@ -1,81 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../../engine'; -import {StringSplit, StringSplitAttrs, StringSplitInputs} from '../../kernel_names'; -import {Scalar, Tensor, Tensor1D} from '../../tensor'; -import {NamedTensorMap} from '../../tensor_types'; -import {convertToTensor} from '../../tensor_util_env'; -import {ScalarLike, TensorLike} from '../../types'; -import {op} from '../operation'; - -/** - * Split elements of `input` based on `delimiter` into a SparseTensor . - * - * Let N be the size of source (typically N will be the batch size). Split each - * element of `input` based on `delimiter` and return a SparseTensor containing - * the splitted tokens. Empty tokens are ignored if `skipEmpty` is set to True. - * - * `delimiter` can be empty, or a string of split characters. If `delimiter` is - * an empty string, each element of `input` is split into individual - * character strings. Otherwise every character of `delimiter` is a potential - * split point. - * - * ```js - * const result = tf.string.stringSplit(['hello world', 'a b c'], ' '); - * result['indices'].print(); // [[0, 0], [0, 1], [1, 0], [1, 1], [1, 2]] - * result['values'].print(); // ['hello', 'world', 'a', 'b', 'c'] - * result['shape'].print(); // [2, 3] - * ``` - * @param input: 1-D. Strings to split. - * @param delimiter: 0-D. Delimiter characters, or empty string. - * @param skipEmpty: Optional. If true, skip the empty strings from the result. - * Defaults to true. - * @return A map with the following properties: - * - indices: A dense matrix of int32 representing the indices of the sparse - * tensor. - * - values: A vector of strings corresponding to the splited values. - * - shape: a length-2 vector of int32 representing the shape of the sparse - * tensor, where the first value is N and the second value is the maximum number - * of tokens in a single input entry. - * - * @doc {heading: 'Operations', subheading: 'String'} - */ -function stringSplit_( - input: Tensor1D|TensorLike, delimiter: Scalar|ScalarLike, - skipEmpty = true): NamedTensorMap { - const $input = convertToTensor(input, 'input', 'stringSplit', 'string'); - const $delimiter = - convertToTensor(delimiter, 'delimiter', 'stringSplit', 'string'); - - if ($input.rank !== 1) { - throw new Error( - `Input should be Tensor1D but received shape ${$input.shape}`); - } - if ($delimiter.rank !== 0) { - throw new Error( - `Delimiter should be a scalar but received shape ${$delimiter.shape}`); - } - - const attrs: StringSplitAttrs = {skipEmpty}; - const inputs: StringSplitInputs = {input: $input, delimiter: $delimiter}; - const result: Tensor[] = - ENGINE.runKernel(StringSplit, inputs as {}, attrs as {}); - return {indices: result[0], values: result[1], shape: result[2]}; -} - -export const stringSplit = /* @__PURE__ */ op({stringSplit_}); diff --git a/tfjs-master/tfjs-core/src/ops/string/string_split_test.ts b/tfjs-master/tfjs-core/src/ops/string/string_split_test.ts deleted file mode 100644 index 9067f8164..000000000 --- a/tfjs-master/tfjs-core/src/ops/string/string_split_test.ts +++ /dev/null @@ -1,108 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../../index'; -import {ALL_ENVS, describeWithFlags} from '../../jasmine_util'; -import {expectArraysEqual} from '../../test_util'; - -async function expectResult( - result: tf.NamedTensorMap, indices: number[][], values: string[], - shape: [number, number]) { - expectArraysEqual(await result.indices.data(), indices); - expectArraysEqual(await result.values.data(), values); - expectArraysEqual(await result.shape.data(), shape); - - expect(result.indices.shape).toEqual([indices.length, 2]); - expect(result.values.shape).toEqual([values.length]); - expect(result.shape.shape).toEqual([2]); - - expect(result.indices.dtype).toEqual('int32'); - expect(result.values.dtype).toEqual('string'); - expect(result.shape.dtype).toEqual('int32'); -} - -describeWithFlags('stringSplit', ALL_ENVS, () => { - it('white space delimiter', async () => { - const result = tf.string.stringSplit(['pigs on the wing', 'animals'], ' '); - await expectResult( - result, [[0, 0], [0, 1], [0, 2], [0, 3], [1, 0]], - ['pigs', 'on', 'the', 'wing', 'animals'], [2, 4]); - }); - - it('empty delimiter', async () => { - const result = tf.string.stringSplit(['hello', 'hola', 'hi'], ''); - await expectResult( - result, - [ - [0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [1, 0], [1, 1], [1, 2], - [1, 3], [2, 0], [2, 1] - ], - ['h', 'e', 'l', 'l', 'o', 'h', 'o', 'l', 'a', 'h', 'i'], [3, 5]); - }); - - it('empty token', async () => { - const result = tf.string.stringSplit( - ['', ' a', 'b ', ' c', ' ', ' d ', ' e', 'f ', ' g ', ' '], ' '); - await expectResult( - result, [[1, 0], [2, 0], [3, 0], [5, 0], [6, 0], [7, 0], [8, 0]], - ['a', 'b', 'c', 'd', 'e', 'f', 'g'], [10, 1]); - }); - - it('set empty token', async () => { - const result = tf.string.stringSplit( - ['', ' a', 'b ', ' c', ' ', ' d ', '. e', 'f .', ' .g. ', ' .'], ' .'); - await expectResult( - result, [[1, 0], [2, 0], [3, 0], [5, 0], [6, 0], [7, 0], [8, 0]], - ['a', 'b', 'c', 'd', 'e', 'f', 'g'], [10, 1]); - }); - - it('with delimiter', async () => { - const input = ['hello|world', 'hello world']; - let result = tf.string.stringSplit(input, '|'); - await expectResult( - result, [[0, 0], [0, 1], [1, 0]], ['hello', 'world', 'hello world'], - [2, 2]); - result = tf.string.stringSplit(input, '| '); - await expectResult( - result, [[0, 0], [0, 1], [1, 0], [1, 1]], - ['hello', 'world', 'hello', 'world'], [2, 2]); - result = - tf.string.stringSplit(['hello.cruel,world', 'hello cruel world'], '.,'); - await expectResult( - result, [[0, 0], [0, 1], [0, 2], [1, 0]], - ['hello', 'cruel', 'world', 'hello cruel world'], [2, 3]); - }); - - it('no skip empty', async () => { - const input = ['#a', 'b#', '#c#']; - let result = tf.string.stringSplit(input, '#', false); - await expectResult( - result, [[0, 0], [0, 1], [1, 0], [1, 1], [2, 0], [2, 1], [2, 2]], - ['', 'a', 'b', '', '', 'c', ''], [3, 3]); - result = tf.string.stringSplit(input, '#'); - await expectResult( - result, [[0, 0], [1, 0], [2, 0]], ['a', 'b', 'c'], [3, 1]); - }); - - it('large input does not cause an argument overflow', async () => { - const input = 'a'.repeat(200000); - const result = tf.string.stringSplit([input], ''); - await expectResult( - result, Array(input.length).fill(0).map((_, i) => [0, i]), - input.split(''), [1, input.length]); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/string/string_to_hash_bucket_fast.ts b/tfjs-master/tfjs-core/src/ops/string/string_to_hash_bucket_fast.ts deleted file mode 100644 index acac976c3..000000000 --- a/tfjs-master/tfjs-core/src/ops/string/string_to_hash_bucket_fast.ts +++ /dev/null @@ -1,60 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../../engine'; -import {StringToHashBucketFast, StringToHashBucketFastAttrs, StringToHashBucketFastInputs} from '../../kernel_names'; -import {Tensor} from '../../tensor'; -import {convertToTensor} from '../../tensor_util_env'; -import {TensorLike} from '../../types'; -import {op} from '../operation'; - -/** - * Converts each string in the input Tensor to its hash mod by a number of - * buckets. - * - * The hash function is deterministic on the content of the string within the - * process and will never change. However, it is not suitable for cryptography. - * This function may be used when CPU time is scarce and inputs are trusted or - * unimportant. There is a risk of adversaries constructing inputs that all hash - * to the same bucket. - * - * ```js - * const result = tf.string.stringToHashBucketFast( - * ['Hello', 'TensorFlow', '2.x'], 3); - * result.print(); // [0, 2, 2] - * ``` - * @param input: The strings to assign a hash bucket. - * @param numBuckets: The number of buckets. - * @return A Tensor of the same shape as the input tensor. - * - * @doc {heading: 'Operations', subheading: 'String'} - */ -function stringToHashBucketFast_( - input: Tensor|TensorLike, numBuckets: number): Tensor { - const $input = - convertToTensor(input, 'input', 'stringToHashBucketFast', 'string'); - const attrs: StringToHashBucketFastAttrs = {numBuckets}; - - if (numBuckets <= 0) { - throw new Error(`Number of buckets must be at least 1`); - } - - const inputs: StringToHashBucketFastInputs = {input: $input}; - return ENGINE.runKernel(StringToHashBucketFast, inputs as {}, attrs as {}); -} - -export const stringToHashBucketFast = /* @__PURE__ */ op({stringToHashBucketFast_}); diff --git a/tfjs-master/tfjs-core/src/ops/string/string_to_hash_bucket_fast_test.ts b/tfjs-master/tfjs-core/src/ops/string/string_to_hash_bucket_fast_test.ts deleted file mode 100644 index 7e91b8f65..000000000 --- a/tfjs-master/tfjs-core/src/ops/string/string_to_hash_bucket_fast_test.ts +++ /dev/null @@ -1,59 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../../index'; -import {ALL_ENVS, describeWithFlags} from '../../jasmine_util'; -import {expectArraysClose} from '../../test_util'; - -describeWithFlags('stringToHashBucketFast', ALL_ENVS, () => { - it('throw error if negative buckets', async () => { - expect(() => tf.string.stringToHashBucketFast(['a', 'b', 'c'], -1)) - .toThrowError(/must be at least 1/); - }); - - it('throw error if zero buckets', async () => { - expect(() => tf.string.stringToHashBucketFast(['a', 'b', 'c'], 0)) - .toThrowError(/must be at least 1/); - }); - - it('one bucket maps values to zero', async () => { - const result = tf.string.stringToHashBucketFast(['a', 'b', 'c'], 1); - expectArraysClose(await result.data(), [0, 0, 0]); - }); - - it('multiple buckets', async () => { - const result = tf.string.stringToHashBucketFast(['a', 'b', 'c', 'd'], 10); - // fingerPrint64('a') -> 12917804110809363939 -> mod 10 -> 9 - // fingerPrint64('b') -> 11795596070477164822 -> mod 10 -> 2 - // fingerPrint64('c') -> 11430444447143000872 -> mod 10 -> 2 - // fingerPrint64('d') -> 4470636696479570465 -> mod 10 -> 5 - expectArraysClose(await result.data(), [9, 2, 2, 5]); - }); - - it('empty input', async () => { - const result = - tf.string.stringToHashBucketFast(tf.tensor1d([], 'string'), 2147483648); - expectArraysClose(await result.data(), []); - }); - - it('preserve size', async () => { - const result = tf.string.stringToHashBucketFast( - [[['a'], ['b']], [['c'], ['d']], [['a'], ['b']]], 10); - expectArraysClose(await result.data(), [9, 2, 2, 5, 9, 2]); - expect(result.shape).toEqual([3, 2, 1]); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/sub.ts b/tfjs-master/tfjs-core/src/ops/sub.ts deleted file mode 100644 index 57902c704..000000000 --- a/tfjs-master/tfjs-core/src/ops/sub.ts +++ /dev/null @@ -1,60 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {ENGINE} from '../engine'; -import {Sub, SubInputs} from '../kernel_names'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {makeTypesMatch} from '../tensor_util'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -import {op} from './operation'; - -/** - * Subtracts two `tf.Tensor`s element-wise, A - B. Supports broadcasting. - * - * ```js - * const a = tf.tensor1d([10, 20, 30, 40]); - * const b = tf.tensor1d([1, 2, 3, 4]); - * - * a.sub(b).print(); // or tf.sub(a, b) - * ``` - * - * ```js - * // Broadcast subtract a with b. - * const a = tf.tensor1d([10, 20, 30, 40]); - * const b = tf.scalar(5); - * - * a.sub(b).print(); // or tf.sub(a, b) - * ``` - * @param a The first `tf.Tensor` to subtract from. - * @param b The second `tf.Tensor` to be subtracted. Must have the same dtype as - * `a`. - * - * @doc {heading: 'Operations', subheading: 'Arithmetic'} - */ -function sub_(a: Tensor|TensorLike, b: Tensor|TensorLike): T { - let $a = convertToTensor(a, 'a', 'sub'); - let $b = convertToTensor(b, 'b', 'sub'); - [$a, $b] = makeTypesMatch($a, $b); - - const inputs: SubInputs = {a: $a, b: $b}; - - return ENGINE.runKernel(Sub, inputs as unknown as NamedTensorMap); -} - -export const sub = /* @__PURE__ */ op({sub_}); diff --git a/tfjs-master/tfjs-core/src/ops/sub_test.ts b/tfjs-master/tfjs-core/src/ops/sub_test.ts deleted file mode 100644 index ce1476c53..000000000 --- a/tfjs-master/tfjs-core/src/ops/sub_test.ts +++ /dev/null @@ -1,340 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('sub', ALL_ENVS, () => { - it('c - A', async () => { - const c = tf.scalar(5); - const a = tf.tensor1d([7, 2, 3]); - - const result = tf.sub(c, a); - - expectArraysClose(await result.data(), [-2, 3, 2]); - }); - - it('A - c', async () => { - const a = tf.tensor1d([1, 2, -3]); - const c = tf.scalar(5); - - const result = tf.sub(a, c); - - expectArraysClose(await result.data(), [-4, -3, -8]); - }); - - it('A - c propagates NaNs', async () => { - const a = tf.tensor1d([1, NaN, 3]); - const c = tf.scalar(5); - - const res = tf.sub(a, c); - - expectArraysClose(await res.data(), [-4, NaN, -2]); - }); - - it('A - B', async () => { - const a = tf.tensor1d([2, 5, 1]); - const b = tf.tensor1d([4, 2, -1]); - - const result = tf.sub(a, b); - - const expected = [-2, 3, 2]; - expectArraysClose(await result.data(), expected); - }); - - it('TensorLike', async () => { - const a = [2, 5, 1]; - const b = [4, 2, -1]; - - const result = tf.sub(a, b); - - const expected = [-2, 3, 2]; - expectArraysClose(await result.data(), expected); - }); - - it('TensorLike chained', async () => { - const a = tf.tensor1d([2, 5, 1]); - const b = [4, 2, -1]; - - const result = a.sub(b); - - const expected = [-2, 3, 2]; - expectArraysClose(await result.data(), expected); - }); - - it('A - B propagates NaNs', async () => { - const a = tf.tensor1d([2, 5, 1]); - const b = tf.tensor1d([4, NaN, -1]); - - const res = tf.sub(a, b); - - expectArraysClose(await res.data(), [-2, NaN, 2]); - }); - - it('A - B throws when passed tensors with different shape', () => { - const a = tf.tensor1d([2, 5, 1, 5]); - const b = tf.tensor1d([4, 2, -1]); - - expect(() => tf.sub(a, b)).toThrowError(); - expect(() => tf.sub(b, a)).toThrowError(); - }); - - it('A - B broadcasting same rank Tensors different shape', async () => { - const a = tf.tensor2d([1, 2, -3, -4], [2, 2]); - const b = tf.tensor2d([2, 3], [2, 1]); - - const result = tf.sub(a, b); - - expect(result.shape).toEqual([2, 2]); - const expected = [-1, 0, -6, -7]; - - expectArraysClose(await result.data(), expected); - }); - - it('A - B broadcast 2D + 1D', async () => { - const a = tf.tensor2d([1, 2, -3, -4], [2, 2]); - const b = tf.tensor1d([1, 2]); - - const result = tf.sub(a, b); - - expect(result.shape).toEqual([2, 2]); - const expected = [0, 0, -4, -6]; - - expectArraysClose(await result.data(), expected); - }); - - it('2D-scalar broadcast', async () => { - const a = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - const b = tf.scalar(2); - const res = tf.sub(a, b); - expect(res.shape).toEqual([2, 3]); - expectArraysClose(await res.data(), [-1, 0, 1, 2, 3, 4]); - }); - - it('scalar-1D broadcast', async () => { - const a = tf.scalar(2); - const b = tf.tensor1d([1, 2, 3, 4, 5, 6]); - const res = tf.sub(a, b); - expect(res.shape).toEqual([6]); - expectArraysClose(await res.data(), [1, 0, -1, -2, -3, -4]); - }); - - it('2D-2D broadcast each with 1 dim', async () => { - const a = tf.tensor2d([1, 2, 5], [1, 3]); - const b = tf.tensor2d([7, 3], [2, 1]); - const res = tf.sub(a, b); - expect(res.shape).toEqual([2, 3]); - expectArraysClose(await res.data(), [-6, -5, -2, -2, -1, 2]); - }); - - it('2D-2D broadcast inner dim of b', async () => { - const a = tf.tensor2d([1, 2, 5, 4, 5, 6], [2, 3]); - const b = tf.tensor2d([7, 3], [2, 1]); - const res = tf.sub(a, b); - expect(res.shape).toEqual([2, 3]); - expectArraysClose(await res.data(), [-6, -5, -2, 1, 2, 3]); - }); - - it('3D-scalar', async () => { - const a = tf.tensor3d([1, 2, 3, 4, 5, 6], [2, 3, 1]); - const b = tf.scalar(-1); - const res = tf.sub(a, b); - expect(res.shape).toEqual([2, 3, 1]); - expectArraysClose(await res.data(), [2, 3, 4, 5, 6, 7]); - }); - - it('vec4 same shape', async () => { - const a = tf.tensor2d([1, 2, -3, -4], [2, 2]); - const b = tf.tensor2d([5, 3, 4, -7], [2, 2]); - const expected = [-4, -1, -7, 3]; - const result = tf.sub(a, b); - - expect(result.shape).toEqual([2, 2]); - expectArraysClose(await result.data(), expected); - }); - - it('gradients: basic 1D arrays', async () => { - const a = tf.tensor1d([1, 2, 3]); - const b = tf.tensor1d([3, 2, 1]); - const dy = tf.tensor1d([1, 10, 20]); - - const grads = tf.grads((a, b) => tf.sub(a, b)); - const [da, db] = grads([a, b], dy); - - expect(da.shape).toEqual(a.shape); - expect(da.dtype).toEqual('float32'); - expectArraysClose(await da.data(), [1, 10, 20]); - - expect(db.shape).toEqual(b.shape); - expect(db.dtype).toEqual('float32'); - expectArraysClose(await db.data(), [-1, -10, -20]); - }); - - it('gradient with clones', async () => { - const a = tf.tensor1d([1, 2, 3]); - const b = tf.tensor1d([3, 2, 1]); - const dy = tf.tensor1d([1, 10, 20]); - - const grads = tf.grads((a, b) => tf.sub(a.clone(), b.clone()).clone()); - const [da, db] = grads([a, b], dy); - - expect(da.shape).toEqual(a.shape); - expect(da.dtype).toEqual('float32'); - expectArraysClose(await da.data(), [1, 10, 20]); - - expect(db.shape).toEqual(b.shape); - expect(db.dtype).toEqual('float32'); - expectArraysClose(await db.data(), [-1, -10, -20]); - }); - - it('gradients: basic 2D arrays', async () => { - const a = tf.tensor2d([0, 1, 2, 3], [2, 2]); - const b = tf.tensor2d([3, 2, 1, 0], [2, 2]); - const dy = tf.tensor2d([1, 10, 15, 20], [2, 2]); - - const grads = tf.grads((a, b) => tf.sub(a, b)); - const [da, db] = grads([a, b], dy); - - expect(da.shape).toEqual(a.shape); - expect(da.dtype).toEqual('float32'); - expectArraysClose(await da.data(), [1, 10, 15, 20]); - - expect(db.shape).toEqual(b.shape); - expect(db.dtype).toEqual('float32'); - expectArraysClose(await db.data(), [-1, -10, -15, -20]); - }); - - it('gradient: 1D - scalar broadcast', async () => { - const a = tf.tensor1d([3, 4, 5]); - const b = tf.scalar(2); - const dy = tf.tensor1d([7, 8, 9]); - - const grads = tf.grads((a, b) => tf.sub(a, b)); - const [da, db] = grads([a, b], dy); - - expect(da.shape).toEqual(a.shape); - expect(da.dtype).toEqual('float32'); - expectArraysClose(await da.data(), [7, 8, 9]); - - expect(db.shape).toEqual(b.shape); - expect(db.dtype).toEqual('float32'); - expectArraysClose(await db.data(), [-7 - 8 - 9]); - }); - - it('gradient: scalar - 1D broadcast', async () => { - const a = tf.scalar(2); - const b = tf.tensor1d([3, 4, 5]); - const dy = tf.tensor1d([7, 8, 9]); - - const grads = tf.grads((a, b) => tf.sub(a, b)); - const [da, db] = grads([a, b], dy); - - expect(da.shape).toEqual(a.shape); - expect(da.dtype).toEqual('float32'); - expectArraysClose(await da.data(), [7 + 8 + 9]); - - expect(db.shape).toEqual(b.shape); - expect(db.dtype).toEqual('float32'); - expectArraysClose(await db.data(), [-7, -8, -9]); - }); - - it('gradient: 2D - 2D broadcast', async () => { - const a = tf.tensor2d([4, 5, 6, 7], [2, 2]); - const b = tf.tensor2d([2, 3], [2, 1]); - const dy = tf.tensor2d([5, 4, 3, 2], [2, 2]); - - const grads = tf.grads((a, b) => tf.sub(a, b)); - const [da, db] = grads([a, b], dy); - - expect(da.shape).toEqual(a.shape); - expect(da.dtype).toEqual('float32'); - expectArraysClose(await da.data(), [5, 4, 3, 2]); - - expect(db.shape).toEqual(b.shape); - expect(db.dtype).toEqual('float32'); - expectArraysClose(await db.data(), [-5 - 4, -3 - 2]); - }); - - it('complex number subtraction', async () => { - const real1 = tf.tensor1d([3]); - const imag1 = tf.tensor1d([5]); - const complex1 = tf.complex(real1, imag1); - - const real2 = tf.tensor1d([1]); - const imag2 = tf.tensor1d([0]); - const complex2 = tf.complex(real2, imag2); - - const result = complex1.sub(complex2); - - expect(result.dtype).toBe('complex64'); - expect(result.shape).toEqual([1]); - expectArraysClose(await result.data(), [2, 5]); - }); - - it('complex number broadcasting subtraction', async () => { - const real1 = tf.tensor2d([1, 2, -3, -4], [2, 2]); - const imag1 = tf.tensor2d([10, 20, -30, -40], [2, 2]); - const complex1 = tf.complex(real1, imag1); - - const real2 = tf.tensor1d([4]); - const imag2 = tf.tensor1d([5]); - const complex2 = tf.complex(real2, imag2); - - const result = tf.sub(complex1, complex2); - - expect(result.dtype).toEqual('complex64'); - expect(result.shape).toEqual([2, 2]); - expectArraysClose( - await result.data(), - [1 - 4, 10 - 5, 2 - 4, 20 - 5, -3 - 4, -30 - 5, -4 - 4, -40 - 5]); - }); - - it('throws when passed a as a non-tensor', () => { - expect(() => tf.sub({} as tf.Tensor, tf.scalar(1))) - .toThrowError(/Argument 'a' passed to 'sub' must be a Tensor/); - }); - it('throws when passed b as a non-tensor', () => { - expect(() => tf.sub(tf.scalar(1), {} as tf.Tensor)) - .toThrowError(/Argument 'b' passed to 'sub' must be a Tensor/); - }); - it('upcasts when dtypes dont match', async () => { - let res = tf.sub(tf.scalar(1, 'int32'), tf.scalar(1, 'float32')); - expect(res.dtype).toBe('float32'); - expectArraysClose(await res.data(), [0]); - - res = tf.sub(tf.scalar(1, 'int32'), tf.scalar(true, 'bool')); - expect(res.dtype).toBe('int32'); - expectArraysClose(await res.data(), [0]); - - res = tf.sub(tf.scalar(1, 'int32'), tf.scalar(false, 'bool')); - expect(res.dtype).toBe('int32'); - expectArraysClose(await res.data(), [1]); - - res = tf.sub(tf.complex(4, 7), tf.scalar(1, 'float32')); - expect(res.dtype).toBe('complex64'); - expectArraysClose(await res.data(), [3, 7]); - - res = tf.sub(tf.complex(4, 7), tf.scalar(1, 'int32')); - expect(res.dtype).toBe('complex64'); - expectArraysClose(await res.data(), [3, 7]); - }); - - it('accepts a tensor-like object', async () => { - const result = tf.sub(5, [7, 2, 3]); - expectArraysClose(await result.data(), [-2, 3, 2]); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/sum.ts b/tfjs-master/tfjs-core/src/ops/sum.ts deleted file mode 100644 index 4d65163a9..000000000 --- a/tfjs-master/tfjs-core/src/ops/sum.ts +++ /dev/null @@ -1,73 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {ENGINE} from '../engine'; -import {Sum, SumAttrs, SumInputs} from '../kernel_names'; -import {NamedAttrMap} from '../kernel_registry'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -import {cast} from './cast'; -import {op} from './operation'; - -/** - * Computes the sum of elements across dimensions of a `tf.Tensor`. - * - * Reduces the input along the dimensions given in `axes`. Unless `keepDims` - * is true, the rank of the `tf.Tensor` is reduced by 1 for each entry in - * `axes`. If `keepDims` is true, the reduced dimensions are retained with - * length 1. If axes has no entries, all dimensions are reduced, and a - * `tf.Tensor` with a single element is returned. - * - * ```js - * const x = tf.tensor1d([1, 2, 3]); - * - * x.sum().print(); // or tf.sum(x) - * ``` - * - * ```js - * const x = tf.tensor2d([1, 2, 3, 4], [2, 2]); - * - * const axis = 1; - * x.sum(axis).print(); // or tf.sum(x, axis) - * ``` - * - * @param x The input tensor to compute the sum over. If the dtype is `bool` - * it will be converted to `int32` and the output dtype will be `int32`. - * @param axis The dimension(s) to reduce. By default it reduces - * all dimensions. - * @param keepDims If true, retains reduced dimensions with size 1. - * - * @doc {heading: 'Operations', subheading: 'Reduction'} - */ -function sum_( - x: Tensor|TensorLike, axis: number|number[] = null, keepDims = false): T { - let $x = convertToTensor(x, 'x', 'sum'); - if ($x.dtype === 'bool') { - $x = cast($x, 'int32'); - } - - const inputs: SumInputs = {x: $x}; - const attrs: SumAttrs = {axis, keepDims}; - - return ENGINE.runKernel( - Sum, inputs as unknown as NamedTensorMap, - attrs as unknown as NamedAttrMap); -} - -export const sum = /* @__PURE__ */ op({sum_}); diff --git a/tfjs-master/tfjs-core/src/ops/sum_test.ts b/tfjs-master/tfjs-core/src/ops/sum_test.ts deleted file mode 100644 index bceb9f595..000000000 --- a/tfjs-master/tfjs-core/src/ops/sum_test.ts +++ /dev/null @@ -1,178 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose, expectArraysEqual} from '../test_util'; - -describeWithFlags('sum', ALL_ENVS, () => { - it('basic', async () => { - const a = tf.tensor2d([1, 2, 3, 0, 0, 1], [3, 2]); - const result = tf.sum(a); - expectArraysClose(await result.data(), 7); - }); - - it('propagates NaNs', async () => { - const a = tf.tensor2d([1, 2, 3, NaN, 0, 1], [3, 2]); - expectArraysEqual(await tf.sum(a).data(), NaN); - }); - - it('sum over dtype int32', async () => { - const a = tf.tensor1d([1, 5, 7, 3], 'int32'); - const sum = tf.sum(a); - expectArraysEqual(await sum.data(), 16); - }); - - it('sum over dtype bool', async () => { - const a = tf.tensor1d([true, false, false, true, true], 'bool'); - const sum = tf.sum(a); - expectArraysEqual(await sum.data(), 3); - }); - - it('sums all values in 2D array with keep dim', async () => { - const a = tf.tensor2d([1, 2, 3, 0, 0, 1], [3, 2]); - const res = tf.sum(a, null, true /* keepDims */); - - expect(res.shape).toEqual([1, 1]); - expectArraysClose(await res.data(), [7]); - }); - - it('sums across axis=0 in 2D array', async () => { - const a = tf.tensor2d([1, 2, 3, 0, 0, 1], [3, 2]); - const res = tf.sum(a, [0]); - - expect(res.shape).toEqual([2]); - expectArraysClose(await res.data(), [4, 3]); - }); - - it('sums across axis=0 in 2D array, keepDims', async () => { - const a = tf.tensor2d([1, 2, 3, 0, 0, 1], [3, 2]); - const res = tf.sum(a, [0], true /* keepDims */); - - expect(res.shape).toEqual([1, 2]); - expectArraysClose(await res.data(), [4, 3]); - }); - - it('sums across axis=1 in 2D array', async () => { - const a = tf.tensor2d([1, 2, 3, 0, 0, 1], [3, 2]); - const res = tf.sum(a, [1]); - - expect(res.shape).toEqual([3]); - expectArraysClose(await res.data(), [3, 3, 1]); - }); - - it('2D, axis=1 provided as number', async () => { - const a = tf.tensor2d([1, 2, 3, 0, 0, 1], [2, 3]); - const res = tf.sum(a, 1); - - expect(res.shape).toEqual([2]); - expectArraysClose(await res.data(), [6, 1]); - }); - - it('2D, axis = -1 provided as number', async () => { - const a = tf.tensor2d([1, 2, 3, 0, 0, 1], [2, 3]); - const res = tf.sum(a, -1); - - expect(res.shape).toEqual([2]); - expectArraysClose(await res.data(), [6, 1]); - }); - - it('sums across axis=0,1 in 2D array', async () => { - const a = tf.tensor2d([1, 2, 3, 0, 0, 1], [3, 2]); - const res = tf.sum(a, [0, 1]); - - expect(res.shape).toEqual([]); - expectArraysClose(await res.data(), [7]); - }); - - it('2D, axis=[-1,-2] in 2D array', async () => { - const a = tf.tensor2d([1, 2, 3, 0, 0, 1], [3, 2]); - const res = tf.sum(a, [-1, -2]); - - expect(res.shape).toEqual([]); - expectArraysClose(await res.data(), [7]); - }); - - it('4D, axis=[2, 2, 1], need permutation.', async () => { - const a = tf.tensor4d([1, 2, 3, 4], [1, 2, 2, 1]); - const res = tf.sum(a, 0); - - expect(res.shape).toEqual([2, 2, 1]); - expectArraysClose(await res.data(), [1, 2, 3, 4]); - }); - - it('gradients: sum(2d)', async () => { - const a = tf.tensor2d([1, 2, 3, 0, 0, 1], [3, 2]); - const dy = tf.scalar(10); - - const gradients = tf.grad(a => a.sum())(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), [10, 10, 10, 10, 10, 10]); - }); - - it('gradient with clones', async () => { - const a = tf.tensor2d([1, 2, 3, 0, 0, 1], [3, 2]); - const dy = tf.scalar(10); - - const gradients = tf.grad(a => a.clone().sum().clone())(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), [10, 10, 10, 10, 10, 10]); - }); - - it('gradients: sum(2d, axis=0)', async () => { - const a = tf.tensor2d([[1, 2], [3, 0], [0, 1]], [3, 2]); - const dy = tf.tensor1d([10, 20]); - const axis = 0; - - const gradients = tf.grad(a => a.sum(axis))(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), [10, 20, 10, 20, 10, 20]); - }); - - it('gradients: sum(2d, axis=1)', async () => { - const a = tf.tensor2d([[1, 2], [3, 0], [0, 1]], [3, 2]); - const dy = tf.tensor1d([10, 20, 30]); - const axis = 1; - - const gradients = tf.grad(a => a.sum(axis))(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), [10, 10, 20, 20, 30, 30]); - }); - - it('throws when passed a non-tensor', () => { - expect(() => tf.sum({} as tf.Tensor)) - .toThrowError(/Argument 'x' passed to 'sum' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const result = tf.sum([[1, 2], [3, 0], [0, 1]]); - expectArraysClose(await result.data(), 7); - }); - - it('throws error for string tensor', () => { - expect(() => tf.sum(['a'])) - .toThrowError(/Argument 'x' passed to 'sum' must be numeric tensor/); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/tan.ts b/tfjs-master/tfjs-core/src/ops/tan.ts deleted file mode 100644 index 187ce1838..000000000 --- a/tfjs-master/tfjs-core/src/ops/tan.ts +++ /dev/null @@ -1,46 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {Tan, TanInputs} from '../kernel_names'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -import {op} from './operation'; - -/** - * Computes tan of the input `tf.Tensor` element-wise, `tan(x)` - * - * ```js - * const x = tf.tensor1d([0, Math.PI / 2, Math.PI * 3 / 4]); - * - * x.tan().print(); // or tf.tan(x) - * ``` - * @param x The input tensor. - * - * @doc {heading: 'Operations', subheading: 'Basic math'} - */ -function tan_(x: T|TensorLike): T { - const $x = convertToTensor(x, 'x', 'tan', 'float32'); - - const inputs: TanInputs = {x: $x}; - - return ENGINE.runKernel(Tan, inputs as unknown as NamedTensorMap); -} -export const tan = /* @__PURE__ */ op({tan_}); diff --git a/tfjs-master/tfjs-core/src/ops/tan_test.ts b/tfjs-master/tfjs-core/src/ops/tan_test.ts deleted file mode 100644 index 33126d170..000000000 --- a/tfjs-master/tfjs-core/src/ops/tan_test.ts +++ /dev/null @@ -1,144 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose, TEST_EPSILON_FLOAT16} from '../test_util'; - -describeWithFlags('tan', ALL_ENVS, () => { - it('basic', async () => { - const values = [1, -3, 2, 7, -4]; - const a = tf.tensor1d(values); - const result = tf.tan(a); - - const expected = []; - for (let i = 0; i < a.size; i++) { - expected[i] = Math.tan(values[i]); - } - expectArraysClose(await result.data(), expected); - }); - - it('numbers exceed float32 precision', async () => { - const values = [ - -608065414.8781943, - 781902002.7943993, - -470910673.97399473, - 1786759246.171617, - 1873777868.5510726, - -1015107953.8969269, - 830023227.6215034, - ]; - const a = tf.tensor1d(values, 'float32'); - const result = tf.tan(a); - - const expected = [...new Float32Array(values).map((v) => Math.tan(v))]; - expectArraysClose(await result.data(), expected); - }); - - it('propagates NaNs', async () => { - const a = tf.tensor1d([4, NaN, 0]); - const res = tf.tan(a); - expectArraysClose(await res.data(), [Math.tan(4), NaN, Math.tan(0)]); - }); - - it('gradients: Scalar', async () => { - const a = tf.scalar(0.5); - const dy = tf.scalar(8); - - const gradients = tf.grad(a => tf.tan(a))(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose( - await gradients.data(), [8 / (Math.cos(0.5) * Math.cos(0.5))]); - }); - - it('gradient with clones', async () => { - const a = tf.scalar(0.5); - const dy = tf.scalar(8); - - const gradients = tf.grad(a => tf.tan(a.clone()).clone())(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose( - await gradients.data(), [8 / (Math.cos(0.5) * Math.cos(0.5))]); - }); - - it('gradients: Tensor1D', async () => { - const aValues = [-1, 2, 3, -5]; - const dyValues = [1, 2, 3, 4]; - const a = tf.tensor1d(aValues); - const dy = tf.tensor1d(dyValues); - - const gradients = tf.grad(a => tf.tan(a))(a, dy); - - const expected = []; - for (let i = 0; i < a.size; i++) { - expected[i] = dyValues[i] / (Math.cos(aValues[i]) * Math.cos(aValues[i])); - } - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - // The grad(tan(x)) which relies on 1/cos(x) is less precise on Windows. - expectArraysClose(await gradients.data(), expected, TEST_EPSILON_FLOAT16); - }); - - it('gradients: Tensor2D', async () => { - const aValues = [-3, 1, 2, 3]; - const dyValues = [1, 2, 3, 4]; - const a = tf.tensor2d(aValues, [2, 2]); - const dy = tf.tensor2d(dyValues, [2, 2]); - - const gradients = tf.grad(a => tf.tan(a))(a, dy); - - const expected = []; - for (let i = 0; i < a.size; i++) { - expected[i] = dyValues[i] / (Math.cos(aValues[i]) * Math.cos(aValues[i])); - } - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), expected); - }); - - it('throws when passed a non-tensor', () => { - expect(() => tf.tan({} as tf.Tensor)) - .toThrowError(/Argument 'x' passed to 'tan' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const values = [1, -3, 2, 7, -4]; - const result = tf.tan(values); - - const expected = []; - for (let i = 0; i < values.length; i++) { - expected[i] = Math.tan(values[i]); - } - expectArraysClose(await result.data(), expected); - }); - - it('throws for string tensor', () => { - expect(() => tf.tan('q')) - .toThrowError(/Argument 'x' passed to 'tan' must be float32/); - }); - - it('throws for int32 tensor', () => { - expect(() => tf.tan(tf.tensor1d([1], 'int32'))) - .toThrowError(/Argument 'x' passed to 'tan' must be float32/); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/tanh.ts b/tfjs-master/tfjs-core/src/ops/tanh.ts deleted file mode 100644 index 499240151..000000000 --- a/tfjs-master/tfjs-core/src/ops/tanh.ts +++ /dev/null @@ -1,46 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {Tanh, TanhInputs} from '../kernel_names'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -import {op} from './operation'; - -/** - * Computes hyperbolic tangent of the input `tf.Tensor` element-wise: `tanh(x)` - * - * ```js - * const x = tf.tensor1d([0, 1, -1, 70]); - * - * x.tanh().print(); // or tf.tanh(x) - * ``` - * @param x The input tensor. - * - * @doc {heading: 'Operations', subheading: 'Basic math'} - */ -function tanh_(x: T|TensorLike): T { - const $x = convertToTensor(x, 'x', 'tanh', 'float32'); - - const inputs: TanhInputs = {x: $x}; - - return ENGINE.runKernel(Tanh, inputs as unknown as NamedTensorMap); -} -export const tanh = /* @__PURE__ */ op({tanh_}); diff --git a/tfjs-master/tfjs-core/src/ops/tanh_test.ts b/tfjs-master/tfjs-core/src/ops/tanh_test.ts deleted file mode 100644 index 61f566915..000000000 --- a/tfjs-master/tfjs-core/src/ops/tanh_test.ts +++ /dev/null @@ -1,129 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; -import * as util from '../util'; - -describeWithFlags('tanh', ALL_ENVS, () => { - it('basic', async () => { - const values = [1, -3, 2, 7, -4]; - const a = tf.tensor1d(values); - const result = tf.tanh(a); - - const expected = []; - for (let i = 0; i < a.size; i++) { - expected[i] = util.tanh(values[i]); - } - expectArraysClose(await result.data(), expected); - }); - - it('propagates NaNs', async () => { - const a = tf.tensor1d([4, NaN, 0]); - const res = tf.tanh(a); - expectArraysClose(await res.data(), [util.tanh(4), NaN, util.tanh(0)]); - }); - - it('gradients: Scalar', async () => { - const a = tf.scalar(0.5); - const dy = tf.scalar(8); - - const gradients = tf.grad(a => tf.tanh(a))(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose( - await gradients.data(), [8 * (1 - (Math.tanh(0.5) * Math.tanh(0.5)))]); - }); - - it('gradient with clones', async () => { - const a = tf.scalar(0.5); - const dy = tf.scalar(8); - - const gradients = tf.grad(a => tf.tanh(a.clone()).clone())(a, dy); - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose( - await gradients.data(), [8 * (1 - (Math.tanh(0.5) * Math.tanh(0.5)))]); - }); - - it('gradients: Tensor1D', async () => { - const aValues = [-1, 2, 3, -5]; - const dyValues = [1, 2, 3, 4]; - const a = tf.tensor1d(aValues); - const dy = tf.tensor1d(dyValues); - - const gradients = tf.grad(a => tf.tanh(a))(a, dy); - - const expected = []; - for (let i = 0; i < a.size; i++) { - expected[i] = - dyValues[i] * (1 - (Math.tanh(aValues[i]) * Math.tanh(aValues[i]))); - } - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), expected); - }); - - it('gradients: Tensor2D', async () => { - const aValues = [-3, 1, 2, 3]; - const dyValues = [1, 2, 3, 4]; - const a = tf.tensor2d(aValues, [2, 2]); - const dy = tf.tensor2d(dyValues, [2, 2]); - - const gradients = tf.grad(a => tf.tanh(a))(a, dy); - - const expected = []; - for (let i = 0; i < a.size; i++) { - expected[i] = - dyValues[i] * (1 - (Math.tanh(aValues[i]) * Math.tanh(aValues[i]))); - } - - expect(gradients.shape).toEqual(a.shape); - expect(gradients.dtype).toEqual('float32'); - expectArraysClose(await gradients.data(), expected); - }); - - it('throws when passed a non-tensor', () => { - expect(() => tf.tanh({} as tf.Tensor)) - .toThrowError(/Argument 'x' passed to 'tanh' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const values = [1, -3, 2, 7, -4]; - const result = tf.tanh(values); - - const expected = []; - for (let i = 0; i < values.length; i++) { - expected[i] = util.tanh(values[i]); - } - expectArraysClose(await result.data(), expected); - }); - - it('throws for string tensor', () => { - expect(() => tf.tanh('q')) - .toThrowError(/Argument 'x' passed to 'tanh' must be float32/); - }); - - it('throws for string tensor', () => { - expect(() => tf.tanh(tf.tensor1d([1], 'int32'))) - .toThrowError(/Argument 'x' passed to 'tanh' must be float32/); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/tensor.ts b/tfjs-master/tfjs-core/src/ops/tensor.ts deleted file mode 100644 index 9b664e07a..000000000 --- a/tfjs-master/tfjs-core/src/ops/tensor.ts +++ /dev/null @@ -1,208 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Tensor} from '../tensor'; -import {inferShape} from '../tensor_util_env'; -import {TensorLike} from '../types'; -import {DataType, Rank, ShapeMap, WebGLData, WebGPUData} from '../types'; - -import {makeTensor} from './tensor_ops_util'; - -/** - * Creates a `tf.Tensor` with the provided values, shape and dtype. - * - * ```js - * // Pass an array of values to create a vector. - * tf.tensor([1, 2, 3, 4]).print(); - * ``` - * - * ```js - * // Pass a nested array of values to make a matrix or a higher - * // dimensional tensor. - * tf.tensor([[1, 2], [3, 4]]).print(); - * ``` - * - * ```js - * // Pass a flat array and specify a shape yourself. - * tf.tensor([1, 2, 3, 4], [2, 2]).print(); - * ``` - * - * ```js - * // Pass a `WebGLData` object and specify a shape yourself. - * - * // This makes it possible for TF.js applications to avoid GPU / CPU sync. - * // For example, if your application includes a preprocessing step on the GPU, - * // you could upload the GPU output directly to TF.js, rather than first - * // downloading the values. - * - * // Example for WebGL2: - * if (tf.findBackend('custom-webgl') == null) { - * const customCanvas = document.createElement('canvas'); - * const customBackend = new tf.MathBackendWebGL(customCanvas); - * tf.registerBackend('custom-webgl', () => customBackend); - * } - * const savedBackend = tf.getBackend(); - * await tf.setBackend('custom-webgl'); - * const gl = tf.backend().gpgpu.gl; - * const texture = gl.createTexture(); - * const tex2d = gl.TEXTURE_2D; - * const width = 2; - * const height = 2; - * - * gl.bindTexture(tex2d, texture); - * gl.texParameteri(tex2d, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); - * gl.texParameteri(tex2d, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); - * gl.texParameteri(tex2d, gl.TEXTURE_MIN_FILTER, gl.NEAREST); - * gl.texParameteri(tex2d, gl.TEXTURE_MAG_FILTER, gl.NEAREST); - * gl.texImage2D( - * tex2d, 0, gl.RGBA32F, // internalFormat - * width, height, 0, - * gl.RGBA, // textureFormat - * gl.FLOAT, // textureType - * new Float32Array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) - * ); - * - * // Currently, the `texture` has 4 pixels: - * // Pixel0 is {R:0, G:1, B:2, A:3} - * // Pixel1 is {R:4, G:5, B:6, A:7} - * // Pixel2 is {R:8, G:9, B:10, A:11} - * // Pixel3 is {R:12, G:13, B:14, A:15} - * - * const logicalShape = [height * width * 2]; - * const a = tf.tensor({texture, height, width, channels: 'BR'}, logicalShape); - * a.print(); - * // Tensor value will be [2, 0, 6, 4, 10, 8, 14, 12], since [2, 0] is the - * // values of 'B' and 'R' channels of Pixel0, [6, 4] is the values of 'B' and - * 'R' - * // channels of Pixel1... - * - * // For postprocessing on the GPU, it's possible to retrieve the texture - * // backing any tensor by calling the tensor's `dataToGPU` method like - * // so: - * - * const tex = a.dataToGPU(); - * await tf.setBackend(savedBackend); - * ``` - * - * ```js - * // Pass a `WebGPUData` object and specify a shape yourself. - * - * // This makes it possible for TF.js applications to avoid GPU / CPU sync. - * // For example, if your application includes a preprocessing step on the GPU, - * // you could upload the GPU output directly to TF.js, rather than first - * // downloading the values. Unlike WebGL, this optionally supports zero copy - * // by WebGPUData.zeroCopy. When zeroCopy is false or undefined(default), this - * // passing GPUBuffer can be destroyed after tensor is created. When zeroCopy - * // is true, this GPUBuffer is bound directly by the tensor, so do not destroy - * // this GPUBuffer until all access is done. - * - * // Example for WebGPU: - * function createGPUBufferFromData(device, data, dtype) { - * const bytesPerElement = 4; - * const sizeInBytes = data.length * bytesPerElement; - * - * const gpuWriteBuffer = device.createBuffer({ - * mappedAtCreation: true, - * size: sizeInBytes, - * usage: GPUBufferUsage.MAP_WRITE | GPUBufferUsage.COPY_SRC - * }); - * const arrayBuffer = gpuWriteBuffer.getMappedRange(); - * if (dtype === 'float32') { - * new Float32Array(arrayBuffer).set(data); - * } else if (dtype === 'int32') { - * new Int32Array(arrayBuffer).set(data); - * } else { - * throw new Error( - * `Creating tensor from GPUBuffer only supports` + - * `'float32'|'int32' dtype, while the dtype is ${dtype}.`); - * } - * gpuWriteBuffer.unmap(); - * - * const gpuReadBuffer = device.createBuffer({ - * mappedAtCreation: false, - * size: sizeInBytes, - * usage: GPUBufferUsage.COPY_DST | GPUBufferUsage.STORAGE | - * GPUBufferUsage.COPY_SRC - * }); - * - * const copyEncoder = device.createCommandEncoder(); - * copyEncoder.copyBufferToBuffer( - * gpuWriteBuffer, 0, gpuReadBuffer, 0, sizeInBytes); - * const copyCommands = copyEncoder.finish(); - * device.queue.submit([copyCommands]); - * gpuWriteBuffer.destroy(); - * return gpuReadBuffer; - * } - * - * const savedBackend = tf.getBackend(); - * await tf.setBackend('webgpu').catch( - * () => {throw new Error( - * 'Failed to use WebGPU backend. Please use Chrome Canary to run.')}); - * const dtype = 'float32'; - * const device = tf.backend().device; - * const aData = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]; - * const bData = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4]; - * const expected = [2, 4, 6, 8, 6, 8, 10, 12, 10, 12, 14, 16, 14, 16, 18, 20]; - * const aBuffer = createGPUBufferFromData(device, aData, dtype); - * const shape = [aData.length]; - * // To use zeroCopy, use {buffer: aBuffer, zeroCopy: true} instead and destroy - * // aBuffer untill all access is done. - * const a = tf.tensor({buffer: aBuffer}, shape, dtype); - * const b = tf.tensor(bData, shape, dtype); - * const result = tf.add(a, b); - * result.print(); - * a.dispose(); - * b.dispose(); - * result.dispose(); - * aBuffer.destroy(); - * await tf.setBackend(savedBackend); - * ``` - * @param values The values of the tensor. Can be nested array of numbers, - * or a flat array, or a `TypedArray`, or a `WebGLData` object, or a - * `WebGPUData` object. If the values are strings, they will be encoded as utf-8 - * and kept as `Uint8Array[]`. If the values is a `WebGLData` object, the dtype - * could only be 'float32' or 'int32' and the object has to have: 1. texture, a - * `WebGLTexture`, the texture must share the same `WebGLRenderingContext` with - * TFJS's WebGL backend (you could create a custom WebGL backend from your - * texture's canvas) and the internal texture format for the input texture must - * be floating point or normalized integer; 2. height, the height of the - * texture; 3. width, the width of the texture; 4. channels, a non-empty subset - * of 'RGBA', indicating the values of which channels will be passed to the - * tensor, such as 'R' or 'BR' (The order of the channels affect the order of - * tensor values. ). (If the values passed from texture is less than the tensor - * size, zeros will be padded at the rear.). If the values is a `WebGPUData` - * object, the dtype could only be 'float32' or 'int32 and the object has to - * have: buffer, a `GPUBuffer`. The buffer must: 1. share the same `GPUDevice` - * with TFJS's WebGPU backend; 2. buffer.usage should at least support - * GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_SRC; 3. buffer.size should not - * be smaller than the byte size of tensor shape. WebGPUData optionally supports - * zero copy by flag zeroCopy. When zeroCopy is false or undefined(default), - * this passing GPUBuffer can be destroyed after tensor is created. When - * zeroCopy is true, this GPUBuffer is bound directly by the tensor, so do not - * destroy this GPUBuffer until all access is done. - * @param shape The shape of the tensor. Optional. If not provided, - * it is inferred from `values`. - * @param dtype The data type. - * - * @doc {heading: 'Tensors', subheading: 'Creation'} - */ -export function tensor( - values: TensorLike|WebGLData|WebGPUData, shape?: ShapeMap[R], - dtype?: DataType): Tensor { - const inferredShape = inferShape(values, dtype); - return makeTensor(values, shape, inferredShape, dtype) as Tensor; -} diff --git a/tfjs-master/tfjs-core/src/ops/tensor1d.ts b/tfjs-master/tfjs-core/src/ops/tensor1d.ts deleted file mode 100644 index 4ae545ac0..000000000 --- a/tfjs-master/tfjs-core/src/ops/tensor1d.ts +++ /dev/null @@ -1,49 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Tensor1D} from '../tensor'; -import {inferShape} from '../tensor_util_env'; -import {TensorLike1D} from '../types'; -import {DataType} from '../types'; -import {assertNonNull} from '../util'; -import {makeTensor} from './tensor_ops_util'; - -/** - * Creates rank-1 `tf.Tensor` with the provided values, shape and dtype. - * - * The same functionality can be achieved with `tf.tensor`, but in general - * we recommend using `tf.tensor1d` as it makes the code more readable. - * - * ```js - * tf.tensor1d([1, 2, 3]).print(); - * ``` - * - * @param values The values of the tensor. Can be array of numbers, - * or a `TypedArray`. - * @param dtype The data type. - * - * @doc {heading: 'Tensors', subheading: 'Creation'} - */ -export function tensor1d(values: TensorLike1D, dtype?: DataType): Tensor1D { - assertNonNull(values); - const inferredShape = inferShape(values, dtype); - if (inferredShape.length !== 1) { - throw new Error('tensor1d() requires values to be a flat/TypedArray'); - } - const shape: number[] = null; - return makeTensor(values, shape, inferredShape, dtype) as Tensor1D; -} diff --git a/tfjs-master/tfjs-core/src/ops/tensor2d.ts b/tfjs-master/tfjs-core/src/ops/tensor2d.ts deleted file mode 100644 index 0d4571549..000000000 --- a/tfjs-master/tfjs-core/src/ops/tensor2d.ts +++ /dev/null @@ -1,66 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Tensor2D} from '../tensor'; -import {inferShape} from '../tensor_util_env'; -import {TensorLike2D} from '../types'; -import {DataType} from '../types'; -import {assertNonNull} from '../util'; -import {makeTensor} from './tensor_ops_util'; - -/** - * Creates rank-2 `tf.Tensor` with the provided values, shape and dtype. - * - * The same functionality can be achieved with `tf.tensor`, but in general - * we recommend using `tf.tensor2d` as it makes the code more readable. - * - * ```js - * // Pass a nested array. - * tf.tensor2d([[1, 2], [3, 4]]).print(); - * ``` - * ```js - * // Pass a flat array and specify a shape. - * tf.tensor2d([1, 2, 3, 4], [2, 2]).print(); - * ``` - * - * @param values The values of the tensor. Can be nested array of numbers, - * or a flat array, or a `TypedArray`. - * @param shape The shape of the tensor. If not provided, it is inferred from - * `values`. - * @param dtype The data type. - * - * @doc {heading: 'Tensors', subheading: 'Creation'} - */ -export function tensor2d( - values: TensorLike2D, shape?: [number, number], - dtype?: DataType): Tensor2D { - assertNonNull(values); - if (shape != null && shape.length !== 2) { - throw new Error('tensor2d() requires shape to have two numbers'); - } - const inferredShape = inferShape(values, dtype); - if (inferredShape.length !== 2 && inferredShape.length !== 1) { - throw new Error( - 'tensor2d() requires values to be number[][] or flat/TypedArray'); - } - if (inferredShape.length === 1 && shape == null) { - throw new Error( - 'tensor2d() requires shape to be provided when `values` ' + - 'are a flat/TypedArray'); - } - return makeTensor(values, shape, inferredShape, dtype) as Tensor2D; -} diff --git a/tfjs-master/tfjs-core/src/ops/tensor3d.ts b/tfjs-master/tfjs-core/src/ops/tensor3d.ts deleted file mode 100644 index e15e60825..000000000 --- a/tfjs-master/tfjs-core/src/ops/tensor3d.ts +++ /dev/null @@ -1,66 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Tensor3D} from '../tensor'; -import {inferShape} from '../tensor_util_env'; -import {TensorLike3D} from '../types'; -import {DataType} from '../types'; -import {assertNonNull} from '../util'; -import {makeTensor} from './tensor_ops_util'; - -/** - * Creates rank-3 `tf.Tensor` with the provided values, shape and dtype. - * - * The same functionality can be achieved with `tf.tensor`, but in general - * we recommend using `tf.tensor3d` as it makes the code more readable. - * - * ```js - * // Pass a nested array. - * tf.tensor3d([[[1], [2]], [[3], [4]]]).print(); - * ``` - * ```js - * // Pass a flat array and specify a shape. - * tf.tensor3d([1, 2, 3, 4], [2, 2, 1]).print(); - * ``` - * - * @param values The values of the tensor. Can be nested array of numbers, - * or a flat array, or a `TypedArray`. - * @param shape The shape of the tensor. If not provided, it is inferred from - * `values`. - * @param dtype The data type. - * - * @doc {heading: 'Tensors', subheading: 'Creation'} - */ -export function tensor3d( - values: TensorLike3D, shape?: [number, number, number], - dtype?: DataType): Tensor3D { - assertNonNull(values); - if (shape != null && shape.length !== 3) { - throw new Error('tensor3d() requires shape to have three numbers'); - } - const inferredShape = inferShape(values, dtype); - if (inferredShape.length !== 3 && inferredShape.length !== 1) { - throw new Error( - 'tensor3d() requires values to be number[][][] or flat/TypedArray'); - } - if (inferredShape.length === 1 && shape == null) { - throw new Error( - 'tensor3d() requires shape to be provided when `values` ' + - 'are a flat array'); - } - return makeTensor(values, shape, inferredShape, dtype) as Tensor3D; -} diff --git a/tfjs-master/tfjs-core/src/ops/tensor4d.ts b/tfjs-master/tfjs-core/src/ops/tensor4d.ts deleted file mode 100644 index d4969d8bb..000000000 --- a/tfjs-master/tfjs-core/src/ops/tensor4d.ts +++ /dev/null @@ -1,66 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Tensor4D} from '../tensor'; -import {inferShape} from '../tensor_util_env'; -import {TensorLike4D} from '../types'; -import {DataType} from '../types'; -import {assertNonNull} from '../util'; -import {makeTensor} from './tensor_ops_util'; - -/** - * Creates rank-4 `tf.Tensor` with the provided values, shape and dtype. - * - * The same functionality can be achieved with `tf.tensor`, but in general - * we recommend using `tf.tensor4d` as it makes the code more readable. - * - * ```js - * // Pass a nested array. - * tf.tensor4d([[[[1], [2]], [[3], [4]]]]).print(); - * ``` - * ```js - * // Pass a flat array and specify a shape. - * tf.tensor4d([1, 2, 3, 4], [1, 2, 2, 1]).print(); - * ``` - * - * @param values The values of the tensor. Can be nested array of numbers, - * or a flat array, or a `TypedArray`. - * @param shape The shape of the tensor. Optional. If not provided, - * it is inferred from `values`. - * @param dtype The data type. - * - * @doc {heading: 'Tensors', subheading: 'Creation'} - */ -export function tensor4d( - values: TensorLike4D, shape?: [number, number, number, number], - dtype?: DataType): Tensor4D { - assertNonNull(values); - if (shape != null && shape.length !== 4) { - throw new Error('tensor4d() requires shape to have four numbers'); - } - const inferredShape = inferShape(values, dtype); - if (inferredShape.length !== 4 && inferredShape.length !== 1) { - throw new Error( - 'tensor4d() requires values to be number[][][][] or flat/TypedArray'); - } - if (inferredShape.length === 1 && shape == null) { - throw new Error( - 'tensor4d() requires shape to be provided when `values` ' + - 'are a flat array'); - } - return makeTensor(values, shape, inferredShape, dtype) as Tensor4D; -} diff --git a/tfjs-master/tfjs-core/src/ops/tensor5d.ts b/tfjs-master/tfjs-core/src/ops/tensor5d.ts deleted file mode 100644 index f2e53e6be..000000000 --- a/tfjs-master/tfjs-core/src/ops/tensor5d.ts +++ /dev/null @@ -1,67 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Tensor5D} from '../tensor'; -import {inferShape} from '../tensor_util_env'; -import {TensorLike5D} from '../types'; -import {DataType} from '../types'; -import {assertNonNull} from '../util'; -import {makeTensor} from './tensor_ops_util'; - -/** - * Creates rank-5 `tf.Tensor` with the provided values, shape and dtype. - * - * The same functionality can be achieved with `tf.tensor`, but in general - * we recommend using `tf.tensor5d` as it makes the code more readable. - * - * ```js - * // Pass a nested array. - * tf.tensor5d([[[[[1],[2]],[[3],[4]]],[[[5],[6]],[[7],[8]]]]]).print(); - * ``` - * ```js - * // Pass a flat array and specify a shape. - * tf.tensor5d([1, 2, 3, 4, 5, 6, 7, 8], [1, 2, 2, 2, 1]).print(); - * ``` - * - * @param values The values of the tensor. Can be nested array of numbers, - * or a flat array, or a `TypedArray`. - * @param shape The shape of the tensor. Optional. If not provided, - * it is inferred from `values`. - * @param dtype The data type. - * - * @doc {heading: 'Tensors', subheading: 'Creation'} - */ -export function tensor5d( - values: TensorLike5D, shape?: [number, number, number, number, number], - dtype?: DataType): Tensor5D { - assertNonNull(values); - if (shape != null && shape.length !== 5) { - throw new Error('tensor5d() requires shape to have five numbers'); - } - const inferredShape = inferShape(values, dtype); - if (inferredShape.length !== 5 && inferredShape.length !== 1) { - throw new Error( - 'tensor5d() requires values to be ' + - 'number[][][][][] or flat/TypedArray'); - } - if (inferredShape.length === 1 && shape == null) { - throw new Error( - 'tensor5d() requires shape to be provided when `values` ' + - 'are a flat array'); - } - return makeTensor(values, shape, inferredShape, dtype) as Tensor5D; -} diff --git a/tfjs-master/tfjs-core/src/ops/tensor6d.ts b/tfjs-master/tfjs-core/src/ops/tensor6d.ts deleted file mode 100644 index 63f5feea2..000000000 --- a/tfjs-master/tfjs-core/src/ops/tensor6d.ts +++ /dev/null @@ -1,70 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Tensor6D} from '../tensor'; -import {inferShape} from '../tensor_util_env'; -import {TensorLike6D} from '../types'; -import {DataType} from '../types'; -import {assertNonNull} from '../util'; -import {makeTensor} from './tensor_ops_util'; - -/** - * Creates rank-6 `tf.Tensor` with the provided values, shape and dtype. - * - * The same functionality can be achieved with `tf.tensor`, but in general - * we recommend using `tf.tensor6d` as it makes the code more readable. - * - * ```js - * // Pass a nested array. - * tf.tensor6d([[[[[[1],[2]],[[3],[4]]],[[[5],[6]],[[7],[8]]]]]]).print(); - * ``` - * ```js - * // Pass a flat array and specify a shape. - * tf.tensor6d([1, 2, 3, 4, 5, 6, 7, 8], [1, 1, 2, 2, 2, 1]).print(); - * ``` - * - * @param values The values of the tensor. Can be nested array of numbers, - * or a flat array, or a `TypedArray`. - * @param shape The shape of the tensor. Optional. If not provided, - * it is inferred from `values`. - * @param dtype The data type. - * - * @doc {heading: 'Tensors', subheading: 'Creation'} - */ -export function tensor6d( - values: TensorLike6D, - shape?: [number, number, number, number, number, number], - dtype?: DataType): Tensor6D { - assertNonNull(values); - if (shape != null && shape.length !== 6) { - throw new Error('tensor6d() requires shape to have six numbers'); - } - const inferredShape = inferShape(values, dtype); - if (inferredShape.length !== 6 && inferredShape.length !== 1) { - throw new Error( - 'tensor6d() requires values to be number[][][][][][] or ' + - 'flat/TypedArray'); - } - if (inferredShape.length === 1 && shape == null) { - throw new Error( - 'tensor6d() requires shape to be provided when `values` ' + - 'are a flat array'); - } - shape = shape || - inferredShape as [number, number, number, number, number, number]; - return makeTensor(values, shape, inferredShape, dtype) as Tensor6D; -} diff --git a/tfjs-master/tfjs-core/src/ops/tensor_ops_util.ts b/tfjs-master/tfjs-core/src/ops/tensor_ops_util.ts deleted file mode 100644 index c38783e25..000000000 --- a/tfjs-master/tfjs-core/src/ops/tensor_ops_util.ts +++ /dev/null @@ -1,87 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {Tensor} from '../tensor'; -import {isWebGLData, isWebGPUData, TensorLike, TypedArray, WebGLData, WebGPUData} from '../types'; -import {DataType} from '../types'; -import {assert, assertNonNegativeIntegerDimensions, flatten, inferDtype, isTypedArray, sizeFromShape, toTypedArray} from '../util'; - -/** This is shared code across all tensor creation methods. */ -export function makeTensor( - values: TensorLike|WebGLData|WebGPUData, shape: number[], - inferredShape: number[], dtype?: DataType): Tensor { - if (dtype == null) { - dtype = inferDtype(values); - } else if (dtype === 'complex64') { - throw new Error( - `Cannot construct a complex64 tensor directly. ` + - `Please use tf.complex(real, imag).`); - } - - if (isWebGPUData(values) || isWebGLData(values)) { - if (dtype !== 'float32' && dtype !== 'int32') { - throw new Error( - `Creating tensor from GPU data only supports ` + - `'float32'|'int32' dtype, while the dtype is ${dtype}.`); - } - return ENGINE.backend.createTensorFromGPUData( - values, shape || inferredShape, dtype); - } - - if (!isTypedArray(values) && !Array.isArray(values) && - typeof values !== 'number' && typeof values !== 'boolean' && - typeof values !== 'string') { - throw new Error( - 'values passed to tensor(values) must be a number/boolean/string or ' + - 'an array of numbers/booleans/strings, or a TypedArray'); - } - // Verify that the shape matches the inferred shape. - if (shape != null) { - assertNonNegativeIntegerDimensions(shape); - - const providedSize = sizeFromShape(shape); - const inferredSize = sizeFromShape(inferredShape); - assert( - providedSize === inferredSize, - () => - `Based on the provided shape, [${shape}], the tensor should have ` + - `${providedSize} values but has ${inferredSize}`); - - for (let i = 0; i < inferredShape.length; ++i) { - const inferred = inferredShape[i]; - const flatDimsDontMatch = i === inferredShape.length - 1 ? - inferred !== sizeFromShape(shape.slice(i)) : - true; - assert( - inferredShape[i] === shape[i] || !flatDimsDontMatch, - () => `Error creating a new Tensor. Inferred shape ` + - `(${inferredShape}) does not match the provided ` + - `shape (${shape}). `); - } - } - - if (!isTypedArray(values) && !Array.isArray(values)) { - values = [values] as number[]; - } - - shape = shape || inferredShape; - values = dtype !== 'string' ? - toTypedArray(values, dtype) : - flatten(values as string[], [], true) as string[]; - return ENGINE.makeTensor(values as TypedArray, shape, dtype); -} diff --git a/tfjs-master/tfjs-core/src/ops/tensor_scatter_update.ts b/tfjs-master/tfjs-core/src/ops/tensor_scatter_update.ts deleted file mode 100644 index 6589ca970..000000000 --- a/tfjs-master/tfjs-core/src/ops/tensor_scatter_update.ts +++ /dev/null @@ -1,87 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {TensorScatterUpdate, TensorScatterUpdateAttrs, TensorScatterUpdateInputs} from '../kernel_names'; -import {NamedAttrMap} from '../kernel_registry'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {Rank, TensorLike} from '../types'; - -import {op} from './operation'; -import * as scatter_nd_util from './scatter_nd_util'; - -/** - * Creates a new tensor by applying sparse updates to individual - * values or slices to the passed in tensor according to - * indices. This operator is the similar to scatterNd op, except that the - * udpates are scattered on an existing tensor (as opposed to a zero-tensor). - * - * If indices contains duplicates, then we pick the last update for the index. - * - * If an out of bound index is found on CPU, an error is returned. - * - * Warning: There are some GPU specific semantics for this operation. - * - If an out of bound index is found, the index is ignored. - * - The order in which updates are applied is nondeterministic, so the output - * will be nondeterministic if indices contains duplicates. - * ```js - * const shape = [8]; - * const tensor = tf.ones(shape); - * const indices = tf.tensor2d([4, 3, 1, 7], [4, 1], 'int32'); - * const updates = tf.tensor1d([9, 10, 11, 12]); - * - * tf.tensorScatterUpdate(tensor, indices, updates).print(); - * //[1, 11, 1, 10, 9, 1, 1, 12] - * ``` - * - * @param tensor A Tensor. Tensor to copy/update. - * @param indices The tensor contains the indices into the output tensor, must - * have at least 2 axes: (num_updates, index_depth). - * @param updates The tensor contains the value for the indices. - * - * @doc {heading: 'Operations', subheading: 'Slicing and Joining'} - */ -function tensorScatterUpdate_( - tensor: Tensor|TensorLike, indices: Tensor|TensorLike, - updates: Tensor|TensorLike): Tensor { - const $tensor = convertToTensor(tensor, 'tensor', 'tensorScatterupdate'); - const $indices = - convertToTensor(indices, 'indices', 'tensorScatterupdate', 'int32'); - const $updates = convertToTensor(updates, 'updates', 'tensorScatterupdate'); - scatter_nd_util.validateInput($updates, $indices, $tensor.shape); - if ($tensor.dtype !== $updates.dtype) { - throw new Error( - `tensor and updates must have the same dtype, instead they are ${ - $tensor.dtype} and ${$updates.dtype}.`); - } - - const inputs: TensorScatterUpdateInputs = { - tensor: $tensor, - indices: $indices, - updates: $updates - }; - const attrs: TensorScatterUpdateAttrs = {}; - - // tslint:disable-next-line: no-unnecessary-type-assertion - return ENGINE.runKernel( - TensorScatterUpdate, inputs as unknown as NamedTensorMap, - attrs as unknown as NamedAttrMap) as Tensor; -} - -export const tensorScatterUpdate = op({tensorScatterUpdate_}); diff --git a/tfjs-master/tfjs-core/src/ops/tensor_scatter_update_test.ts b/tfjs-master/tfjs-core/src/ops/tensor_scatter_update_test.ts deleted file mode 100644 index 439b66335..000000000 --- a/tfjs-master/tfjs-core/src/ops/tensor_scatter_update_test.ts +++ /dev/null @@ -1,162 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('tensorScatterUpdate', ALL_ENVS, () => { - it('should work for 2d', async () => { - const tensor = tf.ones([5, 3], 'int32'); - const indices = tf.tensor2d([0, 4, 2], [3, 1], 'int32'); - const updates = tf.tensor2d( - [100, 101, 102, 777, 778, 779, 1000, 1001, 1002], [3, 3], 'int32'); - const result = tf.tensorScatterUpdate(tensor, indices, updates); - expect(result.shape).toEqual(tensor.shape); - expect(result.dtype).toEqual(tensor.dtype); - expectArraysClose( - await result.data(), - [100, 101, 102, 1, 1, 1, 1000, 1001, 1002, 1, 1, 1, 777, 778, 779]); - }); - - it('should work for simple 1d', async () => { - const shape = [5]; - const tensor = tf.ones(shape); - const indices = tf.tensor2d([3], [1, 1], 'int32'); - const updates = tf.tensor1d([101], 'float32'); - const result = tf.tensorScatterUpdate(tensor, indices, updates); - expect(result.shape).toEqual(shape); - expect(result.dtype).toEqual(updates.dtype); - expectArraysClose(await result.data(), [1, 1, 1, 101, 1]); - }); - - it('should work for multiple 1d', async () => { - const shape = [5]; - const indices = tf.tensor2d([0, 4, 2], [3, 1], 'int32'); - const updates = tf.tensor1d([100, 101, 102], 'float32'); - const tensor = tf.ones(shape); - - const result = tf.tensorScatterUpdate(tensor, indices, updates); - expect(result.shape).toEqual(shape); - expect(result.dtype).toEqual(updates.dtype); - expectArraysClose(await result.data(), [100, 1, 102, 1, 101]); - }); - - it('should work for high rank updates', async () => { - const indices = tf.tensor2d([0, 2], [2, 1], 'int32'); - const updates = tf.tensor3d( - [ - 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, - 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8 - ], - [2, 4, 4], 'float32'); - const shape = [4, 4, 4]; - const tensor = tf.ones(shape); - const result = tf.tensorScatterUpdate(tensor, indices, updates); - expect(result.shape).toEqual(shape); - expect(result.dtype).toEqual(updates.dtype); - expectArraysClose(await result.data(), [ - 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, - 8, 8, 8, 8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 - ]); - }); - - it('should work for high rank indices', async () => { - const indices = tf.tensor2d([0, 2, 0, 1], [2, 2], 'int32'); - const updates = tf.tensor1d([10, 20], 'float32'); - const shape = [3, 3]; - const tensor = tf.ones(shape); - const result = tf.tensorScatterUpdate(tensor, indices, updates); - expect(result.shape).toEqual(shape); - expect(result.dtype).toEqual(updates.dtype); - expectArraysClose(await result.data(), [1, 20, 10, 1, 1, 1, 1, 1, 1]); - }); - - it('should work for high rank indices and update', () => { - const indices = tf.tensor2d([1, 1, 1, 1, 1, 1], [3, 2], 'int32'); - const updates = tf.ones([3, 256], 'float32'); - const shape = [2, 2, 256]; - const tensor = tf.ones(shape); - const result = tf.tensorScatterUpdate(tensor, indices, updates); - expect(result.shape).toEqual(shape); - expect(result.dtype).toEqual(updates.dtype); - }); - - it('should work for tensorLike input', async () => { - const indices = [[0], [4], [2]]; - const updates = [100, 101, 102]; - const shape = [5]; - const tensor = tf.ones(shape); - const result = tf.tensorScatterUpdate(tensor, indices, updates); - expect(result.shape).toEqual(shape); - expect(result.dtype).toEqual('float32'); - expectArraysClose(await result.data(), [100, 1, 102, 1, 101]); - }); - - it('should throw error when indices type is not int32', () => { - const indices = tf.tensor2d([0, 2, 1, 1], [2, 2], 'float32'); - const updates = tf.tensor1d([10, 20], 'float32'); - const shape = [3, 3]; - const tensor = tf.ones(shape); - expect(() => tf.tensorScatterUpdate(tensor, indices, updates)).toThrow(); - }); - - it('should throw error when tensor and updates type does not match', () => { - const indices = tf.tensor2d([0, 2, 1, 1], [2, 2], 'float32'); - const updates = tf.tensor1d([10, 20], 'int32'); - const shape = [3, 3]; - const tensor = tf.ones(shape, 'float32'); - expect(() => tf.tensorScatterUpdate(tensor, indices, updates)).toThrow(); - }); - - it('should throw error when indices and update mismatch', () => { - const indices = tf.tensor2d([0, 4, 2], [3, 1], 'int32'); - const updates = tf.tensor2d( - [100, 101, 102, 103, 777, 778, 779, 780, 10000, 10001, 10002, 10004], - [3, 4], 'float32'); - const shape = [5, 3]; - const tensor = tf.ones(shape); - expect(() => tf.tensorScatterUpdate(tensor, indices, updates)).toThrow(); - }); - - it('should throw error when indices and update count mismatch', () => { - const indices = tf.tensor2d([0, 4, 2], [3, 1], 'int32'); - const updates = - tf.tensor2d([100, 101, 102, 10000, 10001, 10002], [2, 3], 'float32'); - const shape = [5, 3]; - const tensor = tf.ones(shape); - expect(() => tf.tensorScatterUpdate(tensor, indices, updates)).toThrow(); - }); - - it('should throw error when indices are scalar', () => { - const indices = tf.scalar(1, 'int32'); - const updates = - tf.tensor2d([100, 101, 102, 10000, 10001, 10002], [2, 3], 'float32'); - const shape = [5, 3]; - const tensor = tf.ones(shape); - expect(() => tf.tensorScatterUpdate(tensor, indices, updates)).toThrow(); - }); - - it('should throw error when update is scalar', () => { - const indices = tf.tensor2d([0, 4, 2], [3, 1], 'int32'); - const updates = tf.scalar(1, 'float32'); - const shape = [5, 3]; - const tensor = tf.ones(shape); - expect(() => tf.tensorScatterUpdate(tensor, indices, updates)).toThrow(); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/tile.ts b/tfjs-master/tfjs-core/src/ops/tile.ts deleted file mode 100644 index a468a61ff..000000000 --- a/tfjs-master/tfjs-core/src/ops/tile.ts +++ /dev/null @@ -1,69 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {Tile, TileAttrs, TileInputs} from '../kernel_names'; -import {NamedAttrMap} from '../kernel_registry'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; -import * as util from '../util'; - -import {op} from './operation'; - -/** - * Construct a tensor by repeating it the number of times given by reps. - * - * This operation creates a new tensor by replicating `input` `reps` - * times. The output tensor's `i`th dimension has `input.shape[i] * - * reps[i]` elements, and the values of `input` are replicated - * `reps[i]` times along the `i`th dimension. For example, tiling - * `[a, b, c, d]` by `[2]` produces `[a, b, c, d, a, b, c, d]`. - * - * ```js - * const a = tf.tensor1d([1, 2]); - * - * a.tile([2]).print(); // or tf.tile(a, [2]) - * ``` - * - * ```js - * const a = tf.tensor2d([1, 2, 3, 4], [2, 2]); - * - * a.tile([1, 2]).print(); // or tf.tile(a, [1,2]) - * ``` - * @param x The tensor to tile. - * @param reps Determines the number of replications per dimension. - * - * @doc {heading: 'Tensors', subheading: 'Slicing and Joining'} - */ -function tile_(x: T|TensorLike, reps: number[]): T { - const $x = convertToTensor(x, 'x', 'tile', 'string_or_numeric'); - util.assert( - $x.rank === reps.length, - () => `Error in transpose: rank of input ${$x.rank} ` + - `must match length of reps ${reps}.`); - - const inputs: TileInputs = {x: $x}; - const attrs: TileAttrs = {reps}; - - return ENGINE.runKernel( - Tile, inputs as unknown as NamedTensorMap, - attrs as unknown as NamedAttrMap); -} - -export const tile = /* @__PURE__ */ op({tile_}); diff --git a/tfjs-master/tfjs-core/src/ops/tile_test.ts b/tfjs-master/tfjs-core/src/ops/tile_test.ts deleted file mode 100644 index 205531e53..000000000 --- a/tfjs-master/tfjs-core/src/ops/tile_test.ts +++ /dev/null @@ -1,271 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose, expectArraysEqual} from '../test_util'; - -describeWithFlags('tile', ALL_ENVS, () => { - it('1D (tile)', async () => { - const t = tf.tensor1d([1, 2, 3]); - const t2 = tf.tile(t, [2]); - - expect(t2.shape).toEqual([6]); - expectArraysClose(await t2.data(), [1, 2, 3, 1, 2, 3]); - }); - - it('2D (tile)', async () => { - const t = tf.tensor2d([1, 11, 2, 22], [2, 2]); - let t2 = tf.tile(t, [1, 2]); - - expect(t2.shape).toEqual([2, 4]); - expectArraysClose(await t2.data(), [1, 11, 1, 11, 2, 22, 2, 22]); - - t2 = tf.tile(t, [2, 1]); - expect(t2.shape).toEqual([4, 2]); - expectArraysClose(await t2.data(), [1, 11, 2, 22, 1, 11, 2, 22]); - - t2 = tf.tile(t, [2, 2]); - expect(t2.shape).toEqual([4, 4]); - expectArraysClose( - await t2.data(), - [1, 11, 1, 11, 2, 22, 2, 22, 1, 11, 1, 11, 2, 22, 2, 22]); - }); - - it('3D (tile)', async () => { - const t = tf.tensor3d([1, 2, 3, 4, 5, 6, 7, 8], [2, 2, 2]); - const t2 = tf.tile(t, [1, 2, 1]); - - expect(t2.shape).toEqual([2, 4, 2]); - expectArraysClose( - await t2.data(), [1, 2, 3, 4, 1, 2, 3, 4, 5, 6, 7, 8, 5, 6, 7, 8]); - }); - - it('4D (tile)', async () => { - const t = tf.tensor4d([1, 2, 3, 4, 5, 6, 7, 8], [1, 2, 2, 2]); - const t2 = tf.tile(t, [1, 2, 1, 1]); - - expect(t2.shape).toEqual([1, 4, 2, 2]); - expectArraysClose( - await t2.data(), [1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8]); - }); - - it('5D (tile)', async () => { - const t = tf.tensor5d([1, 2, 3, 4, 5, 6, 7, 8], [1, 1, 2, 2, 2]); - const t2 = tf.tile(t, [1, 2, 1, 1, 1]); - - expect(t2.shape).toEqual([1, 2, 2, 2, 2]); - expectArraysClose( - await t2.data(), [1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8]); - }); - - it('6D (tile)', async () => { - const t = tf.tensor6d( - [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], - [1, 1, 2, 2, 2, 2]); - const t2 = tf.tile(t, [1, 2, 1, 1, 1, 1]); - - expect(t2.shape).toEqual([1, 2, 2, 2, 2, 2]); - expectArraysClose(await t2.data(), [ - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 - ]); - }); - - it('1d string tensor', async () => { - const a = tf.tensor(['a', 'b', 'c']); - const res = tf.tile(a, [2]); - expect(res.shape).toEqual([6]); - expectArraysEqual(await res.data(), ['a', 'b', 'c', 'a', 'b', 'c']); - }); - - it('2d string tensor', async () => { - const a = tf.tensor([['a', 'b'], ['c', 'd']]); - const res = tf.tile(a, [2, 3]); - expect(res.shape).toEqual([4, 6]); - expectArraysEqual(await res.data(), [ - 'a', 'b', 'a', 'b', 'a', 'b', 'c', 'd', 'c', 'd', 'c', 'd', - 'a', 'b', 'a', 'b', 'a', 'b', 'c', 'd', 'c', 'd', 'c', 'd' - ]); - }); - - it('6D string tensor', async () => { - const t = tf.tensor6d( - [ - 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', - 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', - 'sixteen' - ], - [1, 1, 2, 2, 2, 2]); - const t2 = tf.tile(t, [1, 2, 1, 1, 1, 1]); - - expect(t2.shape).toEqual([1, 2, 2, 2, 2, 2]); - expectArraysClose(await t2.data(), [ - 'one', 'two', 'three', 'four', 'five', 'six', - 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', - 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'one', 'two', - 'three', 'four', 'five', 'six', 'seven', 'eight', - 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', - 'fifteen', 'sixteen' - ]); - }); - - it('propagates NaNs', async () => { - const t = tf.tensor1d([1, 2, NaN]); - - const t2 = tf.tile(t, [2]); - - expect(t2.shape).toEqual([6]); - expectArraysClose(await t2.data(), [1, 2, NaN, 1, 2, NaN]); - }); - - it('1D bool (tile)', async () => { - const t = tf.tensor1d([true, false, true], 'bool'); - const t2 = tf.tile(t, [2]); - - expect(t2.shape).toEqual([6]); - expect(t2.dtype).toBe('bool'); - expectArraysEqual(await t2.data(), [1, 0, 1, 1, 0, 1]); - }); - - it('2D bool (tile)', async () => { - const t = tf.tensor2d([true, false, true, true], [2, 2], 'bool'); - let t2 = tf.tile(t, [1, 2]); - - expect(t2.shape).toEqual([2, 4]); - expect(t2.dtype).toBe('bool'); - expectArraysEqual(await t2.data(), [1, 0, 1, 0, 1, 1, 1, 1]); - - t2 = tf.tile(t, [2, 1]); - expect(t2.shape).toEqual([4, 2]); - expect(t2.dtype).toBe('bool'); - expectArraysEqual(await t2.data(), [1, 0, 1, 1, 1, 0, 1, 1]); - - t2 = tf.tile(t, [2, 2]); - expect(t2.shape).toEqual([4, 4]); - expect(t2.dtype).toBe('bool'); - expectArraysEqual( - await t2.data(), [1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1]); - }); - - it('3D bool (tile)', async () => { - const t = tf.tensor3d( - [true, false, true, false, true, false, true, false], [2, 2, 2], - 'bool'); - const t2 = tf.tile(t, [1, 2, 1]); - - expect(t2.shape).toEqual([2, 4, 2]); - expect(t2.dtype).toBe('bool'); - expectArraysEqual( - await t2.data(), [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]); - }); - - it('1D int32 (tile)', async () => { - const t = tf.tensor1d([1, 2, 5], 'int32'); - const t2 = tf.tile(t, [2]); - - expect(t2.shape).toEqual([6]); - expect(t2.dtype).toBe('int32'); - expectArraysEqual(await t2.data(), [1, 2, 5, 1, 2, 5]); - }); - - it('2D int32 (tile)', async () => { - const t = tf.tensor2d([1, 2, 3, 4], [2, 2], 'int32'); - let t2 = tf.tile(t, [1, 2]); - - expect(t2.shape).toEqual([2, 4]); - expect(t2.dtype).toBe('int32'); - expectArraysEqual(await t2.data(), [1, 2, 1, 2, 3, 4, 3, 4]); - - t2 = tf.tile(t, [2, 1]); - expect(t2.shape).toEqual([4, 2]); - expect(t2.dtype).toBe('int32'); - expectArraysEqual(await t2.data(), [1, 2, 3, 4, 1, 2, 3, 4]); - - t2 = tf.tile(t, [2, 2]); - expect(t2.shape).toEqual([4, 4]); - expect(t2.dtype).toBe('int32'); - expectArraysEqual( - await t2.data(), [1, 2, 1, 2, 3, 4, 3, 4, 1, 2, 1, 2, 3, 4, 3, 4]); - }); - - it('3D int32 (tile)', async () => { - const t = tf.tensor3d([1, 2, 3, 4, 5, 6, 7, 8], [2, 2, 2], 'int32'); - const t2 = tf.tile(t, [1, 2, 1]); - - expect(t2.shape).toEqual([2, 4, 2]); - expect(t2.dtype).toBe('int32'); - expectArraysEqual( - await t2.data(), [1, 2, 3, 4, 1, 2, 3, 4, 5, 6, 7, 8, 5, 6, 7, 8]); - }); - - it('1D (tile) gradient', async () => { - const x = tf.tensor1d([1, 2, 3]); - const dy = tf.tensor1d([0.1, 0.2, 0.3, 1, 2, 3, 10, 20, 30]); - const gradients = tf.grad(x => tf.tile(x, [3]))(x, dy); - expectArraysClose(await gradients.data(), [11.1, 22.2, 33.3]); - expect(gradients.shape).toEqual([3]); - }); - - it('gradient with clones', async () => { - const x = tf.tensor1d([1, 2, 3]); - const dy = tf.tensor1d([0.1, 0.2, 0.3, 1, 2, 3, 10, 20, 30]); - const gradients = tf.grad(x => tf.tile(x.clone(), [3]).clone())(x, dy); - expectArraysClose(await gradients.data(), [11.1, 22.2, 33.3]); - expect(gradients.shape).toEqual([3]); - }); - - it('2D (tile) gradient', async () => { - const x = tf.tensor2d([[1, 2], [3, 4]], [2, 2]); - const dy = tf.tensor2d([[1, 2, 10, 20], [3, 4, 30, 40]], [2, 4]); - const gradients = tf.grad(x => tf.tile(x, [1, 2]))(x, dy); - expectArraysClose(await gradients.data(), [11, 22, 33, 44]); - expect(gradients.shape).toEqual([2, 2]); - }); - - it('3D (tile) gradient', async () => { - const x = tf.tensor3d([[[1], [2]], [[3], [4]]], [2, 2, 1]); - const dy = tf.tensor3d([[[1, 10], [2, 20]], [[3, 30], [4, 40]]], [2, 2, 2]); - const gradients = tf.grad(x => tf.tile(x, [1, 1, 2]))(x, dy); - expectArraysClose(await gradients.data(), [11, 22, 33, 44]); - expect(gradients.shape).toEqual([2, 2, 1]); - }); - - it('4D (tile) gradient', async () => { - const x = tf.tensor4d([[[[1]], [[2]]], [[[3]], [[4]]]], [2, 2, 1, 1]); - const dy = tf.tensor4d( - [ - [[[.01, .1], [1, 10]], [[.02, .2], [2, 20]]], - [[[.03, .3], [3, 30]], [[.04, .4], [4, 40]]] - ], - [2, 2, 2, 2]); - const gradients = tf.grad(x => tf.tile(x, [1, 1, 2, 2]))(x, dy); - expectArraysClose(await gradients.data(), [11.11, 22.22, 33.33, 44.44]); - expect(gradients.shape).toEqual([2, 2, 1, 1]); - }); - - it('throws when passed a non-tensor', () => { - expect(() => tf.tile({} as tf.Tensor, [1])) - .toThrowError(/Argument 'x' passed to 'tile' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const res = tf.tile([1, 2, 3], [2]); - expect(res.shape).toEqual([6]); - expectArraysClose(await res.data(), [1, 2, 3, 1, 2, 3]); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/to_pixels_test.ts b/tfjs-master/tfjs-core/src/ops/to_pixels_test.ts deleted file mode 100644 index 4c33a66d4..000000000 --- a/tfjs-master/tfjs-core/src/ops/to_pixels_test.ts +++ /dev/null @@ -1,168 +0,0 @@ -/** - * @license - * Copyright 2020 Google Inc. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectPromiseToFail} from '../test_util'; - -describeWithFlags('toPixels no canvas', ALL_ENVS, () => { - it('draws a rank-2 float32 tensor', async () => { - const x = tf.tensor2d([.15, .2], [2, 1], 'float32'); - - const data = await tf.browser.toPixels(x); - const expected = new Uint8ClampedArray([ - Math.round(.15 * 255), Math.round(.15 * 255), Math.round(.15 * 255), 255, - Math.round(.2 * 255), Math.round(.2 * 255), Math.round(.2 * 255), 255 - ]); - expect(data).toEqual(expected); - }); - - it('draws a rank-2 int32 tensor', async () => { - const x = tf.tensor2d([10, 20], [2, 1], 'int32'); - const data = await tf.browser.toPixels(x); - const expected = new Uint8ClampedArray([10, 10, 10, 255, 20, 20, 20, 255]); - expect(data).toEqual(expected); - }); - - it('draws a rank-3 float32 tensor, 1 channel', async () => { - const x = tf.tensor3d([.15, .2], [2, 1, 1], 'float32'); - - const data = await tf.browser.toPixels(x); - const expected = new Uint8ClampedArray([ - Math.round(.15 * 255), Math.round(.15 * 255), Math.round(.15 * 255), 255, - Math.round(.2 * 255), Math.round(.2 * 255), Math.round(.2 * 255), 255 - ]); - expect(data).toEqual(expected); - }); - - it('draws a rank-3 int32 tensor, 1 channel', async () => { - const x = tf.tensor3d([10, 20], [2, 1, 1], 'int32'); - - const data = await tf.browser.toPixels(x); - const expected = new Uint8ClampedArray([10, 10, 10, 255, 20, 20, 20, 255]); - expect(data).toEqual(expected); - }); - - it('draws a rank-3 float32 tensor, 3 channel', async () => { - // 0.1 and 0.3 are changed to 0.1001 and 0.3001 to avoid boundary conditions - // such as Math.round(~25.5) which on Mobile Safari gives 25 and Desktop - // gives 26. - const x = - tf.tensor3d([.05, .1001, .15, .2, .25, .3001], [2, 1, 3], 'float32'); - - const data = await tf.browser.toPixels(x); - const expected = new Uint8ClampedArray([ - Math.round(.05 * 255), Math.round(.1001 * 255), Math.round(.15 * 255), - 255, Math.round(.2 * 255), Math.round(.25 * 255), Math.round(.3001 * 255), - 255 - ]); - expect(data).toEqual(expected); - }); - - it('draws a rank-3 int32 tensor, 3 channel', async () => { - const x = tf.tensor3d([10, 20, 30, 40, 50, 60], [2, 1, 3], 'int32'); - - const data = await tf.browser.toPixels(x); - const expected = new Uint8ClampedArray([10, 20, 30, 255, 40, 50, 60, 255]); - expect(data).toEqual(expected); - }); - - it('draws a rank-3 float32 tensor, 4 channel', async () => { - const x = tf.tensor3d( - [.05, .1001, .15, .2, .25, .3001, .35, .4], [2, 1, 4], 'float32'); - - const data = await tf.browser.toPixels(x); - const expected = new Uint8ClampedArray([ - Math.round(.05 * 255), Math.round(.1001 * 255), Math.round(.15 * 255), - Math.round(.20 * 255), Math.round(.25 * 255), Math.round(.3001 * 255), - Math.round(.35 * 255), Math.round(.4 * 255) - ]); - expect(data).toEqual(expected); - }); - - it('draws a rank-3 int32 tensor, 4 channel', async () => { - const x = tf.tensor3d([10, 20, 30, 40, 50, 60, 70, 80], [2, 1, 4], 'int32'); - - const data = await tf.browser.toPixels(x); - const expected = new Uint8ClampedArray([10, 20, 30, 40, 50, 60, 70, 80]); - expect(data).toEqual(expected); - }); - - it('throws for scalars', done => { - // tslint:disable-next-line:no-any - expectPromiseToFail(() => tf.browser.toPixels(tf.scalar(1) as any), done); - }); - - it('throws for rank-1 tensors', done => { - expectPromiseToFail( - // tslint:disable-next-line:no-any - () => tf.browser.toPixels(tf.tensor1d([1]) as any), done); - }); - it('throws for rank-4 tensors', done => { - expectPromiseToFail( - // tslint:disable-next-line:no-any - () => tf.browser.toPixels(tf.tensor4d([1], [1, 1, 1, 1]) as any), done); - }); - it('throws for bool dtype', done => { - expectPromiseToFail( - () => tf.browser.toPixels(tf.tensor2d([1], [1, 1], 'bool')), done); - }); - it('throws for rank-3 depth = 2', done => { - expectPromiseToFail( - () => tf.browser.toPixels(tf.tensor3d([1, 2], [1, 1, 2])), done); - }); - it('throws for rank-3 depth = 5', done => { - expectPromiseToFail( - () => tf.browser.toPixels(tf.tensor3d([1, 2, 3, 4, 5], [1, 1, 5])), - done); - }); - it('throws for float32 tensor with values not in [0 - 1]', done => { - expectPromiseToFail( - () => tf.browser.toPixels(tf.tensor2d([-1, .5], [1, 2])), done); - }); - it('throws for int32 tensor with values not in [0 - 255]', done => { - expectPromiseToFail( - () => tf.browser.toPixels(tf.tensor2d([-1, 100], [1, 2], 'int32')), - done); - }); - it('throws when passed a non-tensor', done => { - // tslint:disable-next-line:no-any - expectPromiseToFail(() => tf.browser.toPixels({} as any), done); - }); - - it('accepts a tensor-like object', async () => { - const x = [[10], [20]]; // 2x1; - const data = await tf.browser.toPixels(x); - - const expected = new Uint8ClampedArray([10, 10, 10, 255, 20, 20, 20, 255]); - expect(data).toEqual(expected); - }); - - it('does not leak memory', async () => { - const x = tf.tensor2d([[.1], [.2]], [2, 1]); - const startNumTensors = tf.memory().numTensors; - await tf.browser.toPixels(x); - expect(tf.memory().numTensors).toEqual(startNumTensors); - }); - - it('does not leak memory given a tensor-like object', async () => { - const x = [[10], [20]]; // 2x1; - const startNumTensors = tf.memory().numTensors; - await tf.browser.toPixels(x); - expect(tf.memory().numTensors).toEqual(startNumTensors); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/topk.ts b/tfjs-master/tfjs-core/src/ops/topk.ts deleted file mode 100644 index f184dcb4b..000000000 --- a/tfjs-master/tfjs-core/src/ops/topk.ts +++ /dev/null @@ -1,80 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {TopK, TopKAttrs, TopKInputs} from '../kernel_names'; -import {NamedAttrMap} from '../kernel_registry'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -import {op} from './operation'; - -/** - * Finds the values and indices of the `k` largest entries along the last - * dimension. - * - * If the input is a vector (rank=1), finds the k largest entries in the vector - * and outputs their values and indices as vectors. Thus values[j] is the j-th - * largest entry in input, and its index is indices[j]. - * For higher rank inputs, computes the top k entries along the last dimension. - * - * If two elements are equal, the lower-index element appears first. - * - * ```js - * const a = tf.tensor2d([[1, 5], [4, 3]]); - * const {values, indices} = tf.topk(a); - * values.print(); - * indices.print(); - * ``` - * @param x 1-D or higher `tf.Tensor` with last dimension being at least `k`. - * @param k Number of top elements to look for along the last dimension. - * @param sorted If true, the resulting `k` elements will be sorted by the - * values in descending order. - * - * @doc {heading: 'Operations', subheading: 'Evaluation'} - */ -function topk_( - x: T|TensorLike, k = 1, sorted = true): {values: T, indices: T} { - const $x = convertToTensor(x, 'x', 'topk'); - if ($x.rank === 0) { - throw new Error('topk() expects the input to be of rank 1 or higher'); - } - const lastDim = $x.shape[$x.shape.length - 1]; - - if (k < 0) { - throw new Error(`'k' passed to topk() must be >= 0 but got ${k}`); - } - - if (k > lastDim) { - throw new Error( - `'k' passed to topk() must be <= the last dimension (${lastDim}) ` + - `but got ${k}`); - } - - const inputs: TopKInputs = {x: $x}; - const attrs: TopKAttrs = {k, sorted}; - - const [values, indices] = ENGINE.runKernel( - TopK, inputs as unknown as NamedTensorMap, - attrs as unknown as NamedAttrMap) as [T, T]; - - return {values, indices}; -} - -export const topk = /* @__PURE__ */ op({topk_}); diff --git a/tfjs-master/tfjs-core/src/ops/topk_test.ts b/tfjs-master/tfjs-core/src/ops/topk_test.ts deleted file mode 100644 index 20253a817..000000000 --- a/tfjs-master/tfjs-core/src/ops/topk_test.ts +++ /dev/null @@ -1,289 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -import {scalar} from './scalar'; -import {tensor1d} from './tensor1d'; -import {tensor2d} from './tensor2d'; -import {tensor3d} from './tensor3d'; - -describeWithFlags('topk', ALL_ENVS, () => { - beforeAll(() => { - // Ensure WebGL environment uses GPU - if (tf.getBackend() === 'webgl') { - tf.env().set('TOPK_LAST_DIM_CPU_HANDOFF_SIZE_THRESHOLD', 0); - tf.env().set('TOPK_K_CPU_HANDOFF_THRESHOLD', 1024); - } - }); - - it('1d array with k = 0', async () => { - const a = tensor1d([20, 10, 40, 30]); - const {values, indices} = tf.topk(a, 0); - - expect(values.shape).toEqual([0]); - expect(indices.shape).toEqual([0]); - expect(values.dtype).toBe('float32'); - expect(indices.dtype).toBe('int32'); - expectArraysClose(await values.data(), []); - expectArraysClose(await indices.data(), []); - }); - - it('1d array with length 1', async () => { - const a = tensor1d([20]); - const {values, indices} = tf.topk(a, 1); - - expect(values.shape).toEqual([1]); - expect(indices.shape).toEqual([1]); - expect(values.dtype).toBe('float32'); - expect(indices.dtype).toBe('int32'); - expectArraysClose(await values.data(), [20]); - expectArraysClose(await indices.data(), [0]); - }); - - it('1d array with default k', async () => { - const a = tensor1d([20, 10, 40, 30]); - const {values, indices} = tf.topk(a); - - expect(values.shape).toEqual([1]); - expect(indices.shape).toEqual([1]); - expect(values.dtype).toBe('float32'); - expect(indices.dtype).toBe('int32'); - expectArraysClose(await values.data(), [40]); - expectArraysClose(await indices.data(), [2]); - }); - - it('1d array with default k from tensor.topk', async () => { - const a = tensor1d([20, 10, 40, 30]); - const {values, indices} = a.topk(); - - expect(values.shape).toEqual([1]); - expect(indices.shape).toEqual([1]); - expect(values.dtype).toBe('float32'); - expect(indices.dtype).toBe('int32'); - expectArraysClose(await values.data(), [40]); - expectArraysClose(await indices.data(), [2]); - }); - - it('2d array with default k', async () => { - const a = tensor2d([[10, 50], [40, 30]]); - const {values, indices} = tf.topk(a); - - expect(values.shape).toEqual([2, 1]); - expect(indices.shape).toEqual([2, 1]); - expect(values.dtype).toBe('float32'); - expect(indices.dtype).toBe('int32'); - expectArraysClose(await values.data(), [50, 40]); - expectArraysClose(await indices.data(), [1, 0]); - }); - - it('2d array with k=2', async () => { - const a = tensor2d([ - [1, 5, 2], - [4, 3, 6], - [3, 2, 1], - [1, 2, 3], - ]); - const k = 2; - const {values, indices} = tf.topk(a, k); - - expect(values.shape).toEqual([4, 2]); - expect(indices.shape).toEqual([4, 2]); - expect(values.dtype).toBe('float32'); - expect(indices.dtype).toBe('int32'); - expectArraysClose(await values.data(), [5, 2, 6, 4, 3, 2, 3, 2]); - expectArraysClose(await indices.data(), [1, 2, 2, 0, 0, 1, 2, 1]); - }); - - it('2d array with k=2 from tensor.topk', async () => { - const a = tensor2d([ - [1, 5, 2], - [4, 3, 6], - [3, 2, 1], - [1, 2, 3], - ]); - const k = 2; - const {values, indices} = a.topk(k); - - expect(values.shape).toEqual([4, 2]); - expect(indices.shape).toEqual([4, 2]); - expect(values.dtype).toBe('float32'); - expect(indices.dtype).toBe('int32'); - expectArraysClose(await values.data(), [5, 2, 6, 4, 3, 2, 3, 2]); - expectArraysClose(await indices.data(), [1, 2, 2, 0, 0, 1, 2, 1]); - }); - - it('3d array with k=3', async () => { - const a = tensor3d([ - [[1, 5, 2], [4, 3, 6]], - [[3, 2, 1], [1, 2, 3]], - ]); // 2x2x3. - const k = 3; - const {values, indices} = tf.topk(a, k); - - expect(values.shape).toEqual([2, 2, 3]); - expect(indices.shape).toEqual([2, 2, 3]); - expect(values.dtype).toBe('float32'); - expect(indices.dtype).toBe('int32'); - expectArraysClose( - await values.data(), [5, 2, 1, 6, 4, 3, 3, 2, 1, 3, 2, 1]); - expectArraysClose( - await indices.data(), [1, 2, 0, 2, 0, 1, 0, 1, 2, 2, 1, 0]); - }); - - it('topk(int32) propagates int32 dtype', async () => { - const a = tensor1d([2, 3, 1, 4], 'int32'); - const {values, indices} = tf.topk(a); - - expect(values.shape).toEqual([1]); - expect(indices.shape).toEqual([1]); - expect(values.dtype).toBe('int32'); - expect(indices.dtype).toBe('int32'); - expectArraysClose(await values.data(), [4]); - expectArraysClose(await indices.data(), [3]); - }); - - it('lower-index element appears first, k=4', async () => { - const a = tensor1d([1, 2, 2, 1], 'int32'); - const k = 4; - const {values, indices} = tf.topk(a, k); - - expect(values.shape).toEqual([4]); - expect(indices.shape).toEqual([4]); - expect(values.dtype).toBe('int32'); - expect(indices.dtype).toBe('int32'); - expectArraysClose(await values.data(), [2, 2, 1, 1]); - expectArraysClose(await indices.data(), [1, 2, 0, 3]); - }); - - it('lower-index element appears first, k=65', async () => { - const a = [ - 1, 1, 2, 1, 2, 1, 1, 1, 2, 2, 1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 2, - 1, 2, 1, 1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 1, 1, 2, 1, 2, 2, 2, 2, - 1, 2, 1, 2, 2, 2, 1, 2, 2, 1, 2, 2, 1, 2, 1, 1, 1, 2, 1, 2, 1 - ]; - const k = a.length; - const {values, indices} = tf.topk(a, k); - - expectArraysClose(await values.data(), [ - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 - ]); - expectArraysClose(await indices.data(), [ - 2, 4, 8, 9, 12, 15, 18, 21, 23, 27, 30, 33, 38, 40, 41, 42, 43, - 45, 47, 48, 49, 51, 52, 54, 55, 57, 61, 63, 0, 1, 3, 5, 6, 7, - 10, 11, 13, 14, 16, 17, 19, 20, 22, 24, 25, 26, 28, 29, 31, 32, 34, - 35, 36, 37, 39, 44, 46, 50, 53, 56, 58, 59, 60, 62, 64 - ]); - }); - - it('lower-index element appears first, sorted=false', async () => { - const a = [ - 1, 1, 2, 1, 2, 1, 1, 1, 2, 2, 1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 2, - 1, 2, 1, 1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 1, 1, 2, 1, 2, 2, 2, 2, - 1, 2, 1, 2, 2, 2, 1, 2, 2, 1, 2, 2, 1, 2, 1, 1, 1, 2, 1, 2, 1 - ]; - const k = a.length; - const {values, indices} = tf.topk(a, k, false); - - expect(values.shape).toEqual([k]); - expect(indices.shape).toEqual([k]); - expect(values.dtype).toBe('float32'); - expect(indices.dtype).toBe('int32'); - - const valuesData = await values.data(); - valuesData.sort(); - expectArraysClose(valuesData, [ - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 - ]); - - const indicesData = await indices.data(); - const onesIndices = indicesData.filter((index: number) => a[index] === 1); - const twosIndices = indicesData.filter((index: number) => a[index] === 2); - expectArraysClose(onesIndices, [ - 0, 1, 3, 5, 6, 7, 10, 11, 13, 14, 16, 17, 19, - 20, 22, 24, 25, 26, 28, 29, 31, 32, 34, 35, 36, 37, - 39, 44, 46, 50, 53, 56, 58, 59, 60, 62, 64 - ]); - expectArraysClose(twosIndices, [ - 2, 4, 8, 9, 12, 15, 18, 21, 23, 27, 30, 33, 38, 40, - 41, 42, 43, 45, 47, 48, 49, 51, 52, 54, 55, 57, 61, 63 - ]); - }); - - it('throws when k < 0', () => { - const a = tensor2d([[10, 50], [40, 30]]); - expect(() => tf.topk(a, -1)) - .toThrowError(/'k' passed to topk\(\) must be >= 0/); - }); - - it('throws when k > size of array', () => { - const a = tensor2d([[10, 50], [40, 30]]); - expect(() => tf.topk(a, 3)) - .toThrowError(/'k' passed to topk\(\) must be <= the last dimension/); - }); - - it('throws when passed a scalar', () => { - const a = scalar(2); - expect(() => tf.topk(a)) - .toThrowError(/topk\(\) expects the input to be of rank 1 or higher/); - }); - - it('negative infinity input', async () => { - const a = [-Infinity, -Infinity, -Infinity, -Infinity, -Infinity]; - const k = a.length; - const {values, indices} = tf.topk(a, k); - - expect(values.shape).toEqual([k]); - expect(indices.shape).toEqual([k]); - expect(values.dtype).toBe('float32'); - expect(indices.dtype).toBe('int32'); - expectArraysClose(await values.data(), a); - expectArraysClose(await indices.data(), [0, 1, 2, 3, 4]); - }); - - it('accepts a tensor-like object, k=2', async () => { - const a = [20, 10, 40, 30]; - const k = 2; - const {values, indices} = tf.topk(a, k); - - expect(values.shape).toEqual([2]); - expect(indices.shape).toEqual([2]); - expect(values.dtype).toBe('float32'); - expect(indices.dtype).toBe('int32'); - expectArraysClose(await values.data(), [40, 30]); - expectArraysClose(await indices.data(), [2, 3]); - }); - - it('handles output tensors from other ops', async () => { - const a = tensor1d([20, 10, 40, 30]); - const b = scalar(2); - const {values, indices} = tf.topk(tf.add(a, b)); - - expect(values.shape).toEqual([1]); - expect(indices.shape).toEqual([1]); - expect(values.dtype).toBe('float32'); - expect(indices.dtype).toBe('int32'); - expectArraysClose(await values.data(), [42]); - expectArraysClose(await indices.data(), [2]); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/transpose.ts b/tfjs-master/tfjs-core/src/ops/transpose.ts deleted file mode 100644 index 1bf5d1bce..000000000 --- a/tfjs-master/tfjs-core/src/ops/transpose.ts +++ /dev/null @@ -1,100 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {tidy} from '../globals'; -import {Transpose, TransposeAttrs, TransposeInputs} from '../kernel_names'; -import {NamedAttrMap} from '../kernel_registry'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; -import * as util from '../util'; -import {complex} from './complex'; -import {imag} from './imag'; -import {neg} from './neg'; -import {op} from './operation'; -import {real} from './real'; - -/** - * Transposes the `tf.Tensor`. Permutes the dimensions according to `perm`. - * - * The returned `tf.Tensor`'s dimension `i` will correspond to the input - * dimension `perm[i]`. If `perm` is not given, it is set to `[n-1...0]`, - * where `n` is the rank of the input `tf.Tensor`. Hence by default, this - * operation performs a regular matrix transpose on 2-D input `tf.Tensor`s. - * - * ```js - * const a = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - * - * a.transpose().print(); // or tf.transpose(a) - * ``` - * - * @param x The tensor to transpose. - * @param perm The permutation of the dimensions of a. - * @param conjugate Will conjugate complex input if true. - * - * @doc {heading: 'Operations', subheading: 'Matrices'} - */ -function transpose_( - x: T|TensorLike, perm?: number[], conjugate?: boolean): T { - const $x = convertToTensor(x, 'x', 'transpose'); - - if (perm == null) { - perm = $x.shape.map((s, i) => i).reverse(); - } - util.assert( - $x.rank === perm.length, - () => `Error in transpose: rank of input ${$x.rank} ` + - `must match length of perm ${perm}.`); - perm.forEach(axis => { - util.assert( - axis >= 0 && axis < $x.rank, - () => `All entries in 'perm' must be between 0 and ${$x.rank - 1}` + - ` but got ${perm}`); - }); - - if ($x.rank <= 1) { - return $x.clone(); - } - - const inputs: TransposeInputs = {x: $x}; - const attrs: TransposeAttrs = {perm}; - - if ($x.dtype === 'complex64') { - return tidy(() => { - let $real = real($x); - let $imag = imag($x); - $real = ENGINE.runKernel( - Transpose, {x: $real} as unknown as NamedTensorMap, - attrs as unknown as NamedAttrMap); - $imag = ENGINE.runKernel( - Transpose, {x: $imag} as unknown as NamedTensorMap, - attrs as unknown as NamedAttrMap); - if (conjugate) { - $imag = neg($imag); - } - return complex($real, $imag); - }); - } - - return ENGINE.runKernel( - Transpose, inputs as unknown as NamedTensorMap, - attrs as unknown as NamedAttrMap); -} - -export const transpose = /* @__PURE__ */ op({transpose_}); diff --git a/tfjs-master/tfjs-core/src/ops/transpose_test.ts b/tfjs-master/tfjs-core/src/ops/transpose_test.ts deleted file mode 100644 index d81ba908e..000000000 --- a/tfjs-master/tfjs-core/src/ops/transpose_test.ts +++ /dev/null @@ -1,263 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('transpose', ALL_ENVS, () => { - it('of scalar is no-op', async () => { - const a = tf.scalar(3); - expectArraysClose(await tf.transpose(a).data(), [3]); - }); - - it('of 1D is no-op', async () => { - const a = tf.tensor1d([1, 2, 3]); - expectArraysClose(await tf.transpose(a).data(), [1, 2, 3]); - }); - - it('of scalar with perm of incorrect rank throws error', () => { - const a = tf.scalar(3); - const perm = [0]; // Should be empty array. - expect(() => tf.transpose(a, perm)).toThrowError(); - }); - - it('of 1d with perm out of bounds throws error', () => { - const a = tf.tensor1d([1, 2, 3]); - const perm = [1]; - expect(() => tf.transpose(a, perm)).toThrowError(); - }); - - it('of 1d with perm incorrect rank throws error', () => { - const a = tf.tensor1d([1, 2, 3]); - const perm = [0, 0]; // Should be of length 1. - expect(() => tf.transpose(a, perm)).toThrowError(); - }); - - it('2D (no change)', async () => { - const t = tf.tensor2d([1, 11, 2, 22, 3, 33, 4, 44], [2, 4]); - const t2 = tf.transpose(t, [0, 1]); - - expect(t2.shape).toEqual(t.shape); - expectArraysClose(await t2.array(), await t.array()); - }); - - it('2D (transpose)', async () => { - const t = tf.tensor2d([1, 11, 2, 22, 3, 33, 4, 44], [2, 4]); - const t2 = tf.transpose(t, [1, 0]); - - expect(t2.shape).toEqual([4, 2]); - expectArraysClose(await t2.data(), [1, 3, 11, 33, 2, 4, 22, 44]); - }); - - it('2D, shape has ones', async () => { - const t = tf.tensor2d([1, 2, 3, 4], [1, 4]); - const t2 = tf.transpose(t, [1, 0]); - - expect(t2.shape).toEqual([4, 1]); - expectArraysClose(await t2.data(), [1, 2, 3, 4]); - }); - - it('3D [r, c, d] => [d, r, c]', async () => { - const t = tf.tensor3d([1, 11, 2, 22, 3, 33, 4, 44], [2, 2, 2]); - const t2 = tf.transpose(t, [2, 0, 1]); - - expect(t2.shape).toEqual([2, 2, 2]); - expectArraysClose(await t2.data(), [1, 2, 3, 4, 11, 22, 33, 44]); - }); - - it('3D [r, c, d] => [d, c, r]', async () => { - const t = tf.tensor3d([1, 11, 2, 22, 3, 33, 4, 44], [2, 2, 2]); - const t2 = tf.transpose(t, [2, 1, 0]); - - expect(t2.shape).toEqual([2, 2, 2]); - expectArraysClose(await t2.data(), [1, 3, 2, 4, 11, 33, 22, 44]); - }); - - it('3D [r, c, d] => [d, r, c], shape has ones', async () => { - const perm = [2, 0, 1]; - - const t = tf.tensor3d([1, 2, 3, 4], [2, 1, 2]); - const tt = tf.transpose(t, perm); - expect(tt.shape).toEqual([2, 2, 1]); - expectArraysClose(await tt.data(), [1, 3, 2, 4]); - - const t2 = tf.tensor3d([1, 2, 3, 4], [2, 2, 1]); - const tt2 = tf.transpose(t2, perm); - expect(tt2.shape).toEqual([1, 2, 2]); - expectArraysClose(await tt2.data(), [1, 2, 3, 4]); - - const t3 = tf.tensor3d([1, 2, 3, 4], [1, 2, 2]); - const tt3 = tf.transpose(t3, perm); - expect(tt3.shape).toEqual([2, 1, 2]); - expectArraysClose(await tt3.data(), [1, 3, 2, 4]); - }); - - it('3D [r, c, d] => [r, d, c]', async () => { - const perm = [0, 2, 1]; - const t = tf.tensor3d([1, 2, 3, 4, 5, 6, 7, 8], [2, 2, 2]); - const tt = tf.transpose(t, perm); - expect(tt.shape).toEqual([2, 2, 2]); - expectArraysClose(await tt.data(), [1, 3, 2, 4, 5, 7, 6, 8]); - }); - - it('5D [r, c, d, e, f] => [r, c, d, f, e]', async () => { - const t = tf.tensor5d( - new Array(32).fill(0).map((x, i) => i + 1), [2, 2, 2, 2, 2]); - const t2 = tf.transpose(t, [0, 1, 2, 4, 3]); - - expect(t2.shape).toEqual([2, 2, 2, 2, 2]); - expectArraysClose(await t2.data(), [ - 1, 3, 2, 4, 5, 7, 6, 8, 9, 11, 10, 12, 13, 15, 14, 16, - 17, 19, 18, 20, 21, 23, 22, 24, 25, 27, 26, 28, 29, 31, 30, 32 - ]); - }); - - it('4D [r, c, d, e] => [c, r, d, e]', async () => { - const t = - tf.tensor4d(new Array(16).fill(0).map((x, i) => i + 1), [2, 2, 2, 2]); - const t2 = tf.transpose(t, [1, 0, 2, 3]); - - expect(t2.shape).toEqual([2, 2, 2, 2]); - expectArraysClose( - await t2.data(), - [1, 2, 3, 4, 9, 10, 11, 12, 5, 6, 7, 8, 13, 14, 15, 16]); - }); - - it('4D [r, c, d, e] => [c, r, e, d]', async () => { - const t = - tf.tensor4d(new Array(16).fill(0).map((x, i) => i + 1), [2, 2, 2, 2]); - const t2 = tf.transpose(t, [1, 0, 3, 2]); - - expect(t2.shape).toEqual([2, 2, 2, 2]); - expectArraysClose( - await t2.data(), - [1, 3, 2, 4, 9, 11, 10, 12, 5, 7, 6, 8, 13, 15, 14, 16]); - }); - - it('4D [r, c, d, e] => [e, r, c, d]', async () => { - const t = - tf.tensor4d(new Array(16).fill(0).map((x, i) => i + 1), [2, 2, 2, 2]); - const t2 = tf.transpose(t, [3, 0, 1, 2]); - - expect(t2.shape).toEqual([2, 2, 2, 2]); - expectArraysClose( - await t2.data(), - [1, 3, 5, 7, 9, 11, 13, 15, 2, 4, 6, 8, 10, 12, 14, 16]); - }); - - it('4D [r, c, d, e] => [d, c, e, r]', async () => { - const t = - tf.tensor4d(new Array(16).fill(0).map((x, i) => i + 1), [2, 2, 2, 2]); - const t2 = tf.transpose(t, [2, 1, 3, 0]); - - expect(t2.shape).toEqual([2, 2, 2, 2]); - expectArraysClose( - await t2.data(), - [1, 9, 2, 10, 5, 13, 6, 14, 3, 11, 4, 12, 7, 15, 8, 16]); - }); - - it('5D [r, c, d, e, f] => [c, r, d, e, f]', async () => { - const t = tf.tensor5d( - new Array(32).fill(0).map((x, i) => i + 1), [2, 2, 2, 2, 2]); - const t2 = tf.transpose(t, [1, 0, 2, 3, 4]); - - expect(t2.shape).toEqual([2, 2, 2, 2, 2]); - expectArraysClose(await t2.data(), [ - 1, 2, 3, 4, 5, 6, 7, 8, 17, 18, 19, 20, 21, 22, 23, 24, - 9, 10, 11, 12, 13, 14, 15, 16, 25, 26, 27, 28, 29, 30, 31, 32 - ]); - }); - - it('6D [r, c, d, e, f] => [r, c, d, f, e]', async () => { - const t = tf.tensor6d( - new Array(64).fill(0).map((x, i) => i + 1), [2, 2, 2, 2, 2, 2]); - const t2 = tf.transpose(t, [0, 1, 2, 3, 5, 4]); - expect(t2.shape).toEqual([2, 2, 2, 2, 2, 2]); - expectArraysClose(await t2.data(), [ - 1, 3, 2, 4, 5, 7, 6, 8, 9, 11, 10, 12, 13, 15, 14, 16, - 17, 19, 18, 20, 21, 23, 22, 24, 25, 27, 26, 28, 29, 31, 30, 32, - 33, 35, 34, 36, 37, 39, 38, 40, 41, 43, 42, 44, 45, 47, 46, 48, - 49, 51, 50, 52, 53, 55, 54, 56, 57, 59, 58, 60, 61, 63, 62, 64 - ]); - }); - - it('6D [r, c, d, e, f, g] => [c, r, d, e, f, g]', async () => { - const t = tf.tensor6d( - new Array(64).fill(0).map((x, i) => i + 1), [2, 2, 2, 2, 2, 2]); - const t2 = tf.transpose(t, [1, 0, 2, 3, 4, 5]); - expect(t2.shape).toEqual([2, 2, 2, 2, 2, 2]); - expectArraysClose(await t2.data(), [ - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, - 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, - 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, - 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64 - ]); - }); - - it('gradient 3D [r, c, d] => [d, c, r]', async () => { - const t = tf.tensor3d([1, 11, 2, 22, 3, 33, 4, 44], [2, 2, 2]); - const perm = [2, 1, 0]; - const dy = tf.tensor3d([111, 211, 121, 221, 112, 212, 122, 222], [2, 2, 2]); - const dt = tf.grad(t => t.transpose(perm))(t, dy); - expect(dt.shape).toEqual(t.shape); - expect(dt.dtype).toEqual('float32'); - expectArraysClose( - await dt.data(), [111, 112, 121, 122, 211, 212, 221, 222]); - }); - - it('gradient with clones', async () => { - const t = tf.tensor3d([1, 11, 2, 22, 3, 33, 4, 44], [2, 2, 2]); - const perm = [2, 1, 0]; - const dy = tf.tensor3d([111, 211, 121, 221, 112, 212, 122, 222], [2, 2, 2]); - const dt = tf.grad(t => t.clone().transpose(perm).clone())(t, dy); - expect(dt.shape).toEqual(t.shape); - expect(dt.dtype).toEqual('float32'); - expectArraysClose( - await dt.data(), [111, 112, 121, 122, 211, 212, 221, 222]); - }); - - it('throws when passed a non-tensor', () => { - expect(() => tf.transpose({} as tf.Tensor)) - .toThrowError(/Argument 'x' passed to 'transpose' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const t = [[1, 11, 2, 22], [3, 33, 4, 44]]; - const res = tf.transpose(t, [1, 0]); - - expect(res.shape).toEqual([4, 2]); - expectArraysClose(await res.data(), [1, 3, 11, 33, 2, 4, 22, 44]); - }); - - it('accepts complex64 input', async () => { - const real = tf.tensor2d([[1, 2], [3, 4]]); - const imag = tf.tensor2d([[-4, 5], [6, 7]]); - - let res = tf.transpose(tf.complex(real, imag)); - - expect(res.shape).toEqual([2, 2]); - expectArraysClose([[1, 3], [2, 4]], await tf.real(res).data()); - expectArraysClose([[-4, 6], [5, 7]], await tf.imag(res).data()); - - // Test taking conjugate tranpose. - res = tf.transpose(tf.complex(real, imag), [1, 0], true); - expect(res.shape).toEqual([2, 2]); - expectArraysClose([[1, 3], [2, 4]], await tf.real(res).data()); - expectArraysClose([[4, -6], [-5, -7]], await tf.imag(res).data()); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/truncated_normal.ts b/tfjs-master/tfjs-core/src/ops/truncated_normal.ts deleted file mode 100644 index 22541b9fa..000000000 --- a/tfjs-master/tfjs-core/src/ops/truncated_normal.ts +++ /dev/null @@ -1,62 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Tensor} from '../tensor'; -import {DataType, Rank, ShapeMap} from '../types'; -import {assertNonNegativeIntegerDimensions} from '../util_base'; - -import {buffer} from './buffer'; -import {op} from './operation'; -import {MPRandGauss} from './rand_util'; - -/** - * Creates a `tf.Tensor` with values sampled from a truncated normal - * distribution. - * - * ```js - * tf.truncatedNormal([2, 2]).print(); - * ``` - * - * The generated values follow a normal distribution with specified mean and - * standard deviation, except that values whose magnitude is more than 2 - * standard deviations from the mean are dropped and re-picked. - * - * @param shape An array of integers defining the output tensor shape. - * @param mean The mean of the normal distribution. - * @param stdDev The standard deviation of the normal distribution. - * @param dtype The data type of the output tensor. - * @param seed The seed for the random number generator. - * - * @doc {heading: 'Tensors', subheading: 'Creation'} - */ -function truncatedNormal_( - shape: ShapeMap[R], mean = 0, stdDev = 1, dtype?: 'float32'|'int32', - seed?: number): Tensor { - assertNonNegativeIntegerDimensions(shape); - if (dtype != null && (dtype as DataType) === 'bool') { - throw new Error(`Unsupported data type $ { dtype }`); - } - const randGauss = - new MPRandGauss(mean, stdDev, dtype, true /* truncated */, seed); - const res = buffer(shape, dtype); - for (let i = 0; i < res.values.length; i++) { - res.values[i] = randGauss.nextValue(); - } - return res.toTensor(); -} - -export const truncatedNormal = /* @__PURE__ */ op({truncatedNormal_}); diff --git a/tfjs-master/tfjs-core/src/ops/truncated_normal_test.ts b/tfjs-master/tfjs-core/src/ops/truncated_normal_test.ts deleted file mode 100644 index e6471a191..000000000 --- a/tfjs-master/tfjs-core/src/ops/truncated_normal_test.ts +++ /dev/null @@ -1,132 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {TypedArray} from '../types'; -import {expectArrayInMeanStdRange} from './rand_util'; - -describeWithFlags('truncatedNormal', ALL_ENVS, () => { - // Expect slightly higher variances for truncated values. - const EPSILON = 0.60; - const SEED = 2002; - - function assertTruncatedValues( - values: TypedArray, mean: number, stdv: number) { - const bounds = mean + stdv * 2; - for (let i = 0; i < values.length; i++) { - expect(Math.abs(values[i])).toBeLessThanOrEqual(bounds); - } - } - - it('should return a random 1D float32 array', async () => { - const shape: [number] = [1000]; - - // Ensure defaults to float32 w/o type: - let result = tf.truncatedNormal(shape, 0, 3.5, null, SEED); - expect(result.dtype).toBe('float32'); - assertTruncatedValues(await result.data(), 0, 3.5); - expectArrayInMeanStdRange(await result.data(), 0, 3.5, EPSILON); - - result = tf.truncatedNormal(shape, 0, 4.5, 'float32', SEED); - expect(result.dtype).toBe('float32'); - assertTruncatedValues(await result.data(), 0, 4.5); - expectArrayInMeanStdRange(await result.data(), 0, 4.5, EPSILON); - }); - - it('should return a randon 1D int32 array', async () => { - const shape: [number] = [1000]; - const result = tf.truncatedNormal(shape, 0, 5, 'int32', SEED); - expect(result.dtype).toBe('int32'); - assertTruncatedValues(await result.data(), 0, 5); - expectArrayInMeanStdRange(await result.data(), 0, 5, EPSILON); - }); - - it('should return a 2D float32 array', async () => { - const shape: [number, number] = [50, 50]; - - // Ensure defaults to float32 w/o type: - let result = tf.truncatedNormal(shape, 0, 3.5, null, SEED); - expect(result.dtype).toBe('float32'); - assertTruncatedValues(await result.data(), 0, 3.5); - expectArrayInMeanStdRange(await result.data(), 0, 3.5, EPSILON); - - result = tf.truncatedNormal(shape, 0, 4.5, 'float32', SEED); - expect(result.dtype).toBe('float32'); - assertTruncatedValues(await result.data(), 0, 4.5); - expectArrayInMeanStdRange(await result.data(), 0, 4.5, EPSILON); - }); - - it('should return a 2D int32 array', async () => { - const shape: [number, number] = [50, 50]; - const result = tf.truncatedNormal(shape, 0, 5, 'int32', SEED); - expect(result.dtype).toBe('int32'); - assertTruncatedValues(await result.data(), 0, 5); - expectArrayInMeanStdRange(await result.data(), 0, 5, EPSILON); - }); - - it('should return a 3D float32 array', async () => { - const shape: [number, number, number] = [10, 10, 10]; - - // Ensure defaults to float32 w/o type: - let result = tf.truncatedNormal(shape, 0, 3.5, null, SEED); - expect(result.dtype).toBe('float32'); - assertTruncatedValues(await result.data(), 0, 3.5); - expectArrayInMeanStdRange(await result.data(), 0, 3.5, EPSILON); - - result = tf.truncatedNormal(shape, 0, 4.5, 'float32', SEED); - expect(result.dtype).toBe('float32'); - assertTruncatedValues(await result.data(), 0, 4.5); - expectArrayInMeanStdRange(await result.data(), 0, 4.5, EPSILON); - }); - - it('should return a 3D int32 array', async () => { - const shape: [number, number, number] = [10, 10, 10]; - const result = tf.truncatedNormal(shape, 0, 5, 'int32', SEED); - expect(result.dtype).toBe('int32'); - assertTruncatedValues(await result.data(), 0, 5); - expectArrayInMeanStdRange(await result.data(), 0, 5, EPSILON); - }); - - it('should return a 4D float32 array', async () => { - const shape: [number, number, number, number] = [5, 5, 5, 5]; - - // Ensure defaults to float32 w/o type: - let result = tf.truncatedNormal(shape, 0, 3.5, null, SEED); - expect(result.dtype).toBe('float32'); - assertTruncatedValues(await result.data(), 0, 3.5); - expectArrayInMeanStdRange(await result.data(), 0, 3.5, EPSILON); - - result = tf.truncatedNormal(shape, 0, 4.5, 'float32', SEED); - expect(result.dtype).toBe('float32'); - assertTruncatedValues(await result.data(), 0, 4.5); - expectArrayInMeanStdRange(await result.data(), 0, 4.5, EPSILON); - }); - - it('should return a 4D int32 array', async () => { - const shape: [number, number, number, number] = [5, 5, 5, 5]; - const result = tf.truncatedNormal(shape, 0, 5, 'int32', SEED); - expect(result.dtype).toBe('int32'); - assertTruncatedValues(await result.data(), 0, 5); - expectArrayInMeanStdRange(await result.data(), 0, 5, EPSILON); - }); - - it('should throw error when shape is not integer', () => { - expect(() => tf.truncatedNormal([5.55, 3.33, 2.22], 0, 5, 'int32', SEED)) - .toThrow(); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/unique.ts b/tfjs-master/tfjs-core/src/ops/unique.ts deleted file mode 100644 index 6ea1cf91a..000000000 --- a/tfjs-master/tfjs-core/src/ops/unique.ts +++ /dev/null @@ -1,91 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {Unique, UniqueAttrs, UniqueInputs} from '../kernel_names'; -import {NamedAttrMap} from '../kernel_registry'; -import {Tensor, Tensor1D} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; -import {assert} from '../util'; - -import {op} from './operation'; - -/** - * Finds unique elements along an axis of a tensor. - * - * It returns a tensor `values` containing all of the unique elements along the - * `axis` of the given tensor `x` in the same order that they occur along the - * `axis` in `x`; `x` does not need to be sorted. It also returns a tensor - * `indices` the same size as the number of the elements in `x` along the `axis` - * dimension. It contains the index in the unique output `values`. - * - * ```js - * // A 1-D tensor - * const a = tf.tensor1d([1, 1, 2, 4, 4, 4, 7, 8, 8]); - * const {values, indices} = tf.unique(a); - * values.print(); // [1, 2, 4, 7, 8,] - * indices.print(); // [0, 0, 1, 2, 2, 2, 3, 4, 4] - * ``` - * - * ```js - * // A 2-D tensor with axis=0 - * // - * // 'a' is: [[1, 0, 0], - * // [1, 0, 0], - * // [2, 0, 0]] - * const a = tf.tensor2d([[1, 0, 0], [1, 0, 0], [2, 0, 0]]); - * const {values, indices} = tf.unique(a, 0) - * values.print(); // [[1, 0, 0], - * // [2, 0, 0]] - * indices.print(); // [0, 0, 1] - * ``` - * - * ```js - * // A 2-D tensor with axis=1 - * // - * // 'a' is: [[1, 0, 0], - * // [1, 0, 0], - * // [2, 0, 0]] - * const a = tf.tensor2d([[1, 0, 0], [1, 0, 0], [2, 0, 0]]); - * const {values, indices} = tf.unique(a, 1) - * values.print(); // [[1, 0], - * // [1, 0], - * // [2, 0]] - * indices.print(); // [0, 1, 1] - * ``` - * @param x A tensor (int32, string, bool). - * @param axis The axis of the tensor to find the unique elements. - * @returns [uniqueElements, indices] (see above for details) - * - * @doc {heading: 'Operations', subheading: 'Evaluation'} - */ -function unique_( - x: T|TensorLike, axis = 0): {values: T, indices: Tensor1D} { - const $x = convertToTensor(x, 'x', 'unique', 'string_or_numeric'); - assert($x.rank > 0, () => 'The input tensor must be at least 1D'); - - const inputs: UniqueInputs = {x: $x}; - const attrs: UniqueAttrs = {axis}; - const [values, indices] = ENGINE.runKernel( - Unique, inputs as unknown as NamedTensorMap, - attrs as unknown as NamedAttrMap) as [T, Tensor1D]; - return {values, indices}; -} - -export const unique = /* @__PURE__ */ op({unique_}); diff --git a/tfjs-master/tfjs-core/src/ops/unique_test.ts b/tfjs-master/tfjs-core/src/ops/unique_test.ts deleted file mode 100644 index 127413b29..000000000 --- a/tfjs-master/tfjs-core/src/ops/unique_test.ts +++ /dev/null @@ -1,167 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysEqual} from '../test_util'; - -import {tensor1d} from './tensor1d'; - -describeWithFlags('unique', ALL_ENVS, () => { - it('1d tensor with int32', async () => { - const x = tensor1d([1, 1, 2, 4, 4, 4, 7, 8, 8]); - const {values, indices} = tf.unique(x); - - expect(indices.dtype).toBe('int32'); - expect(indices.shape).toEqual(x.shape); - expect(values.shape).toEqual([5]); - expectArraysEqual(await values.data(), [1, 2, 4, 7, 8]); - expectArraysEqual(await indices.data(), [0, 0, 1, 2, 2, 2, 3, 4, 4]); - }); - - it('1d tensor with string', async () => { - const x = tensor1d(['a', 'b', 'b', 'c', 'c']); - const {values, indices} = tf.unique(x); - - expect(indices.dtype).toBe('int32'); - expect(indices.shape).toEqual(x.shape); - expect(values.dtype).toEqual('string'); - expect(values.shape).toEqual([3]); - expectArraysEqual(await values.data(), ['a', 'b', 'c']); - expectArraysEqual(await indices.data(), [0, 1, 1, 2, 2]); - }); - - it('1d tensor with bool', async () => { - const x = tensor1d([true, true, false]); - const {values, indices} = tf.unique(x); - - expect(indices.dtype).toBe('int32'); - expect(indices.shape).toEqual(x.shape); - expect(values.dtype).toEqual('bool'); - expect(values.shape).toEqual([2]); - expectArraysEqual(await values.data(), [true, false]); - expectArraysEqual(await indices.data(), [0, 0, 1]); - }); - - it('1d tensor with NaN and Infinity', async () => { - const x = tensor1d([NaN, Infinity, NaN, Infinity]); - const {values, indices} = tf.unique(x); - - expect(indices.dtype).toBe('int32'); - expect(indices.shape).toEqual(x.shape); - expect(values.shape).toEqual([2]); - expectArraysEqual(await values.data(), [NaN, Infinity]); - expectArraysEqual(await indices.data(), [0, 1, 0, 1]); - }); - - it('2d tensor with axis=0', async () => { - const x = tf.tensor2d([[1, 0, 0], [1, 0, 0], [2, 0, 0]]); - const {values, indices} = tf.unique(x, 0); - - expect(indices.dtype).toBe('int32'); - expect(indices.shape).toEqual([x.shape[0]]); - expect(values.shape).toEqual([2, 3]); - expectArraysEqual(await values.data(), [1, 0, 0, 2, 0, 0]); - expectArraysEqual(await indices.data(), [0, 0, 1]); - }); - - it('2d tensor with axis=1', async () => { - const x = tf.tensor2d([[1, 0, 0, 1], [1, 0, 0, 1], [2, 0, 0, 2]]); - const {values, indices} = tf.unique(x, 1); - - expect(indices.dtype).toBe('int32'); - expect(indices.shape).toEqual([x.shape[1]]); - expect(values.shape).toEqual([3, 2]); - expectArraysEqual(await values.data(), [[1, 0], [1, 0], [2, 0]]); - expectArraysEqual(await indices.data(), [0, 1, 1, 0]); - }); - - it('2d tensor with string', async () => { - const x = tf.tensor2d([['a', 'b', 'b'], ['a', 'b', 'b'], ['c', 'b', 'b']]); - const {values, indices} = tf.unique(x, 0); - - expect(indices.dtype).toBe('int32'); - expect(indices.shape).toEqual([x.shape[0]]); - expect(values.dtype).toEqual('string'); - expect(values.shape).toEqual([2, 3]); - expectArraysEqual(await values.data(), ['a', 'b', 'b', 'c', 'b', 'b']); - expectArraysEqual(await indices.data(), [0, 0, 1]); - }); - - it('2d tensor with strings that have comma', async () => { - const x = tf.tensor2d([['a', 'b,c', 'd'], ['a', 'b', 'c,d']]); - const {values, indices} = tf.unique(x, 0); - - expect(indices.dtype).toBe('int32'); - expect(indices.shape).toEqual([x.shape[0]]); - expect(values.dtype).toEqual('string'); - expect(values.shape).toEqual([2, 3]); - expectArraysEqual(await values.data(), ['a', 'b,c', 'd', 'a', 'b', 'c,d']); - expectArraysEqual(await indices.data(), [0, 1]); - }); - - it('3d tensor with axis=0', async () => { - const x = - tf.tensor3d([[[1, 0], [1, 0]], [[1, 0], [1, 0]], [[1, 1], [1, 1]]]); - const {values, indices} = tf.unique(x, 0); - - expect(indices.dtype).toBe('int32'); - expect(indices.shape).toEqual([x.shape[0]]); - expect(values.shape).toEqual([2, 2, 2]); - expectArraysEqual(await values.data(), [1, 0, 1, 0, 1, 1, 1, 1]); - expectArraysEqual(await indices.data(), [0, 0, 1]); - }); - - it('3d tensor with axis=1', async () => { - const x = - tf.tensor3d([[[1, 0], [1, 0]], [[1, 0], [1, 0]], [[1, 1], [1, 1]]]); - const {values, indices} = tf.unique(x, 1); - - expect(indices.dtype).toBe('int32'); - expect(indices.shape).toEqual([x.shape[1]]); - expect(values.shape).toEqual([3, 1, 2]); - expectArraysEqual(await values.data(), [[[1, 0]], [[1, 0]], [[1, 1]]]); - expectArraysEqual(await indices.data(), [0, 0]); - }); - - it('3d tensor with axis=2', async () => { - const x = tf.tensor3d([[[1, 0, 1]], [[1, 0, 1]]]); - const {values, indices} = tf.unique(x, 2); - - expect(indices.dtype).toBe('int32'); - expect(indices.shape).toEqual([x.shape[2]]); - expect(values.shape).toEqual([2, 1, 2]); - expectArraysEqual(await values.data(), [1, 0, 1, 0]); - expectArraysEqual(await indices.data(), [0, 1, 0]); - }); - - it('3d tensor with string', async () => { - const x = tf.tensor3d([ - [['a', 'b'], ['a', 'b']], [['a', 'b'], ['a', 'b']], - [['a', 'a'], ['a', 'a']] - ]); - const {values, indices} = tf.unique(x, 0); - - expect(indices.dtype).toBe('int32'); - expect(indices.shape).toEqual([x.shape[0]]); - expect(values.dtype).toEqual('string'); - expect(values.shape).toEqual([2, 2, 2]); - expectArraysEqual( - await values.data(), ['a', 'b', 'a', 'b', 'a', 'a', 'a', 'a']); - expectArraysEqual(await indices.data(), [0, 0, 1]); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/unsorted_segment_sum.ts b/tfjs-master/tfjs-core/src/ops/unsorted_segment_sum.ts deleted file mode 100644 index 8e25c7737..000000000 --- a/tfjs-master/tfjs-core/src/ops/unsorted_segment_sum.ts +++ /dev/null @@ -1,62 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {UnsortedSegmentSum, UnsortedSegmentSumAttrs, UnsortedSegmentSumInputs} from '../kernel_names'; -import {NamedAttrMap} from '../kernel_registry'; -import {Tensor, Tensor1D} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; -import {assert, isInt} from '../util'; - -import {op} from './operation'; - -/** - * Computes the sum along segments of a `tf.Tensor`. - * - * ```js - * const x = tf.tensor1d([1, 2, 3, 4]); - * const segmentIds = tf.tensor1d([1, 2, 0, 1], 'int32'); - * const numSegments = 3; - * - * x.unsortedSegmentSum(segmentIds, numSegments).print() - * //or tf.unsortedSegmentSum(x, segmentIds, numSegments) - * ``` - * @param x The `tf.Tensor` that will be summed along its segments. - * @param segmentIds A `tf.Tensor1D` whose rank is equal to the rank of `x`'s - * dimension along the `axis`. Maps each element of `x` to a segment. - * @param numSegments The number of distinct `segmentIds`. - * - * @doc {heading: 'Operations', subheading: 'Segment'} - */ -function unsortedSegmentSum_( - x: T|TensorLike, segmentIds: Tensor1D|TensorLike, numSegments: number): T { - const $x = convertToTensor(x, 'x', 'unsortedSegmentSum'); - const $segmentIds = - convertToTensor(segmentIds, 'segmentIds', 'unsortedSegmentSum', 'int32'); - assert(isInt(numSegments), () => 'numSegments must be of dtype int'); - - const inputs: UnsortedSegmentSumInputs = {x: $x, segmentIds: $segmentIds}; - const attrs: UnsortedSegmentSumAttrs = {numSegments}; - - return ENGINE.runKernel( - UnsortedSegmentSum, inputs as unknown as NamedTensorMap, - attrs as unknown as NamedAttrMap); -} - -export const unsortedSegmentSum = /* @__PURE__ */ op({unsortedSegmentSum_}); diff --git a/tfjs-master/tfjs-core/src/ops/unsorted_segment_sum_test.ts b/tfjs-master/tfjs-core/src/ops/unsorted_segment_sum_test.ts deleted file mode 100644 index 5df33d087..000000000 --- a/tfjs-master/tfjs-core/src/ops/unsorted_segment_sum_test.ts +++ /dev/null @@ -1,171 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; -import {PARALLELIZE_THRESHOLD} from './reduce_util'; - -describeWithFlags('unsortedSegmentSum', ALL_ENVS, () => { - it('tensor1D', async () => { - const t = tf.tensor1d([1, 2, 3, 4]); - const segmentIds = tf.tensor1d([0, 2, 0, 1], 'int32'); - const numSegments = 3; - const res = tf.unsortedSegmentSum(t, segmentIds, numSegments); - - expect(res.shape).toEqual([numSegments]); - expectArraysClose(await res.data(), [4, 4, 2]); - }); - - it('tensor2D', async () => { - const t = tf.tensor2d([1, 2, 3, 4], [2, 2]); - const segmentIds = tf.tensor1d([0, 0], 'int32'); - const numSegments = 2; - const res = tf.unsortedSegmentSum(t, segmentIds, numSegments); - - expect(res.shape).toEqual([numSegments, 2]); - expectArraysClose(await res.data(), [4, 6, 0, 0]); - }); - - it('tensor3D', async () => { - const t = tf.tensor3d([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [3, 2, 2]); - const segmentIds = tf.tensor1d([2, 1, 2], 'int32'); - const numSegments = 3; - const res = tf.unsortedSegmentSum(t, segmentIds, numSegments); - - expect(res.shape).toEqual([numSegments, 2, 2]); - expectArraysClose( - await res.data(), [0, 0, 0, 0, 5, 6, 7, 8, 10, 12, 14, 16]); - }); - - it('N > than parallelization threshold, tensor1D', async () => { - const n = PARALLELIZE_THRESHOLD * 2; - const values = new Float32Array(n); - const numSegments = 5; - const segmentIdValues = new Float32Array(n); - const vals = new Float32Array(numSegments); - for (let i = 0; i < n; i++) { - values[i] = i; - segmentIdValues[i] = i % numSegments; - vals[i % numSegments] += i; - } - const t = tf.tensor1d(values); - const segmentIds = tf.tensor1d(segmentIdValues, 'int32'); - const res = tf.unsortedSegmentSum(t, segmentIds, numSegments); - - expect(res.shape).toEqual([numSegments]); - expectArraysClose(await res.data(), vals); - }); - - it('ignores negative segmentIds', async () => { - const t = tf.tensor1d([1, 2, 3, 4]); - const segmentIds = tf.tensor1d([0, 2, -1, 1], 'int32'); - const numSegments = 3; - - const res = tf.unsortedSegmentSum(t, segmentIds, numSegments); - - expect(res.shape).toEqual([numSegments]); - expectArraysClose(await res.data(), [1, 4, 2]); - }); - - it('gradient ignores negative segmentIds', async () => { - const t = tf.tensor1d([1, 2, 3, 4]); - const segmentIds = tf.tensor1d([0, 2, -1, 1], 'int32'); - const numSegments = 3; - - const dy = tf.tensor1d([11, 2, 7]); - const gradient = - tf.grad(a => tf.unsortedSegmentSum(a, segmentIds, numSegments))(t, dy); - - expect(gradient.shape).toEqual(t.shape); - expectArraysClose(await gradient.data(), [11, 7, 0, 2]); - }); - - it('tensor1D gradient', async () => { - const t = tf.tensor1d([1, 2, 3, 4]); - const segmentIds = tf.tensor1d([0, 2, 0, 1], 'int32'); - const numSegments = 3; - - const dy = tf.tensor1d([11, 2, 7]); - const gradient = - tf.grad(a => tf.unsortedSegmentSum(a, segmentIds, numSegments))(t, dy); - - expect(gradient.shape).toEqual(t.shape); - expectArraysClose(await gradient.data(), [11, 7, 11, 2]); - }); - - it('gradient with clones', async () => { - const t = tf.tensor1d([1, 2, 3, 4]); - const segmentIds = tf.tensor1d([0, 2, 0, 1], 'int32'); - const numSegments = 3; - - const dy = tf.tensor1d([11, 2, 7]); - const gradient = tf.grad( - a => tf.unsortedSegmentSum(a.clone(), segmentIds.clone(), numSegments) - .clone())(t, dy); - - expect(gradient.shape).toEqual(t.shape); - expectArraysClose(await gradient.data(), [11, 7, 11, 2]); - }); - - it('tensor2D gradient', async () => { - const t = tf.tensor2d([1, 2, 3, 4], [2, 2]); - const segmentIds = tf.tensor1d([0, 0], 'int32'); - const numSegments = 2; - - const dy = tf.tensor2d([11, 2, 4, 5], [2, 2]); - const gradient = - tf.grad(a => tf.unsortedSegmentSum(a, segmentIds, numSegments))(t, dy); - - expect(gradient.shape).toEqual(t.shape); - expectArraysClose(await gradient.data(), [11, 2, 11, 2]); - }); - - it('tensor3D gradient', async () => { - const t = tf.tensor3d([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [3, 2, 2]); - const segmentIds = tf.tensor1d([2, 1, 2], 'int32'); - const numSegments = 3; - - const dy = - tf.tensor3d([11, 2, 4, 5, 17, 31, 1, 0, -1, 14, 3, 28], [3, 2, 2]); - const gradient = - tf.grad(a => tf.unsortedSegmentSum(a, segmentIds, numSegments))(t, dy); - - expect(gradient.shape).toEqual(t.shape); - expectArraysClose( - await gradient.data(), [-1, 14, 3, 28, 17, 31, 1, 0, -1, 14, 3, 28]); - }); - - it('accepts a tensor-like object', async () => { - const x = [1, 2, 3, 4]; - const segmentIds = [0, 2, 0, 1]; - const numSegments = 3; - const res = tf.unsortedSegmentSum(x, segmentIds, numSegments); - expect(res.shape).toEqual([3]); - expectArraysClose(await res.data(), [4, 4, 2]); - }); - - it('accepts a tensor-like object chained', async () => { - const x = tf.tensor1d([1, 2, 3, 4]); - const segmentIds = [0, 2, 0, 1]; - const numSegments = 3; - const res = x.unsortedSegmentSum(segmentIds, numSegments); - - expect(res.shape).toEqual([3]); - expectArraysClose(await res.data(), [4, 4, 2]); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/unstack.ts b/tfjs-master/tfjs-core/src/ops/unstack.ts deleted file mode 100644 index c578e0001..000000000 --- a/tfjs-master/tfjs-core/src/ops/unstack.ts +++ /dev/null @@ -1,58 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {Unpack, UnpackAttrs, UnpackInputs} from '../kernel_names'; -import {NamedAttrMap} from '../kernel_registry'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; -import * as util from '../util'; - -import {op} from './operation'; - -/** - * Unstacks a `tf.Tensor` of rank-`R` into a list of rank-`(R-1)` `tf.Tensor`s. - * - * ```js - * const a = tf.tensor2d([1, 2, 3, 4], [2, 2]); - * - * tf.unstack(a).forEach(tensor => tensor.print()); - * ``` - * - * @param x A tensor object. - * @param axis The axis to unstack along. Defaults to 0 (the first dim). - * - * @doc {heading: 'Tensors', subheading: 'Slicing and Joining'} - */ -function unstack_(x: Tensor|TensorLike, axis = 0): Tensor[] { - const $x = convertToTensor(x, 'x', 'unstack', 'string_or_numeric'); - util.assert( - axis >= -$x.shape.length && axis < $x.shape.length, - () => - `Axis = ${axis} is not in [-${$x.shape.length}, ${$x.shape.length})`); - - const inputs: UnpackInputs = {value: $x}; - const attrs: UnpackAttrs = {axis}; - - return ENGINE.runKernel( - Unpack, inputs as unknown as NamedTensorMap, - attrs as unknown as NamedAttrMap); -} - -export const unstack = /* @__PURE__ */ op({unstack_}); diff --git a/tfjs-master/tfjs-core/src/ops/unstack_test.ts b/tfjs-master/tfjs-core/src/ops/unstack_test.ts deleted file mode 100644 index b1d8179e8..000000000 --- a/tfjs-master/tfjs-core/src/ops/unstack_test.ts +++ /dev/null @@ -1,278 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('unstack', ALL_ENVS, () => { - it('unstack by default', async () => { - const x = tf.tensor2d([1, 2, 3, 4, 5, 6, 7, 8], [2, 4]); - const res = tf.unstack(x); - expect(res.length).toEqual(2); - expect(res[0].rank).toEqual(1); - expect(res[0].shape).toEqual([4]); - expectArraysClose(await res[0].data(), [1, 2, 3, 4]); - expect(res[1].rank).toEqual(1); - expect(res[1].shape).toEqual([4]); - expectArraysClose(await res[1].data(), [5, 6, 7, 8]); - }); - - it('chain api', async () => { - const x = tf.tensor2d([1, 2, 3, 4, 5, 6, 7, 8], [2, 4]); - const res = x.unstack(); - expect(res.length).toEqual(2); - expect(res[0].rank).toEqual(1); - expect(res[0].shape).toEqual([4]); - expectArraysClose(await res[0].data(), [1, 2, 3, 4]); - expect(res[1].rank).toEqual(1); - expect(res[1].shape).toEqual([4]); - expectArraysClose(await res[1].data(), [5, 6, 7, 8]); - }); - - it('unstack with negative integer axis', async () => { - const x = tf.tensor2d([1, 2, 3, 4, 5, 6, 7, 8], [2, 4]); - - let res = tf.unstack(x, -1); - expect(res.length).toEqual(4); - expect(res[0].rank).toEqual(1); - expect(res[0].shape).toEqual([2]); - expectArraysClose(await res[0].data(), [1, 5]); - expect(res[1].rank).toEqual(1); - expect(res[1].shape).toEqual([2]); - expectArraysClose(await res[1].data(), [2, 6]); - expect(res[2].rank).toEqual(1); - expect(res[2].shape).toEqual([2]); - expectArraysClose(await res[2].data(), [3, 7]); - expect(res[3].rank).toEqual(1); - expect(res[3].shape).toEqual([2]); - expectArraysClose(await res[3].data(), [4, 8]); - - res = tf.unstack(x, -2); - expect(res.length).toEqual(2); - expect(res[0].rank).toEqual(1); - expect(res[0].shape).toEqual([4]); - expectArraysClose(await res[0].data(), [1, 2, 3, 4]); - expect(res[1].rank).toEqual(1); - expect(res[1].shape).toEqual([4]); - expectArraysClose(await res[1].data(), [5, 6, 7, 8]); - }); - - it('unstack into 3 tensors', async () => { - const x = tf.tensor2d([1, 2, 3, 4, 5, 6], [3, 2]); - const res = tf.unstack(x, 0); - expect(res.length).toEqual(3); - expect(res[0].rank).toEqual(1); - expect(res[0].shape).toEqual([2]); - expectArraysClose(await res[0].data(), [1, 2]); - expect(res[1].rank).toEqual(1); - expect(res[1].shape).toEqual([2]); - expectArraysClose(await res[1].data(), [3, 4]); - expect(res[2].rank).toEqual(1); - expect(res[2].shape).toEqual([2]); - expectArraysClose(await res[2].data(), [5, 6]); - }); - - it('unstack by axis=1', async () => { - const x = tf.tensor2d([1, 2, 3, 4, 5, 6, 7, 8], [2, 4]); - const res = tf.unstack(x, 1); - expect(res.length).toEqual(4); - expect(res[0].rank).toEqual(1); - expect(res[0].shape).toEqual([2]); - expectArraysClose(await res[0].data(), [1, 5]); - expect(res[1].rank).toEqual(1); - expect(res[1].shape).toEqual([2]); - expectArraysClose(await res[1].data(), [2, 6]); - expect(res[2].rank).toEqual(1); - expect(res[2].shape).toEqual([2]); - expectArraysClose(await res[2].data(), [3, 7]); - expect(res[3].rank).toEqual(1); - expect(res[3].shape).toEqual([2]); - expectArraysClose(await res[3].data(), [4, 8]); - }); - - it('unstack rank 3 tensor', async () => { - const x = tf.tensor3d([1, 2, 3, 4, 5, 6, 7, 8], [2, 2, 2]); - const res = tf.unstack(x); - expect(res.length).toEqual(2); - expect(res[0].rank).toEqual(2); - expect(res[0].shape).toEqual([2, 2]); - expectArraysClose(await res[0].data(), [1, 2, 3, 4]); - expect(res[1].rank).toEqual(2); - expect(res[1].shape).toEqual([2, 2]); - expectArraysClose(await res[1].data(), [5, 6, 7, 8]); - }); - - it('unstack rank 3 tensor with axis=1', async () => { - const x = tf.tensor3d([1, 2, 3, 4, 5, 6, 7, 8], [2, 2, 2]); - const res = tf.unstack(x, 1); - expect(res.length).toEqual(2); - expect(res[0].rank).toEqual(2); - expect(res[0].shape).toEqual([2, 2]); - expectArraysClose(await res[0].data(), [1, 2, 5, 6]); - expect(res[1].rank).toEqual(2); - expect(res[1].shape).toEqual([2, 2]); - expectArraysClose(await res[1].data(), [3, 4, 7, 8]); - }); - - it('unstack rank 3 tensor with axis=2', async () => { - const x = tf.tensor3d([1, 2, 3, 4, 5, 6, 7, 8], [2, 2, 2]); - const res = tf.unstack(x, 2); - expect(res.length).toEqual(2); - expect(res[0].rank).toEqual(2); - expect(res[0].shape).toEqual([2, 2]); - expectArraysClose(await res[0].data(), [1, 3, 5, 7]); - expect(res[1].rank).toEqual(2); - expect(res[1].shape).toEqual([2, 2]); - expectArraysClose(await res[1].data(), [2, 4, 6, 8]); - }); - - it('unstack rank 4 tensor', async () => { - const x = tf.tensor4d([1, 2, 3, 4, 5, 6, 7, 8], [2, 2, 2, 1]); - const res = tf.unstack(x); - expect(res.length).toEqual(2); - expect(res[0].rank).toEqual(3); - expect(res[0].shape).toEqual([2, 2, 1]); - expectArraysClose(await res[0].data(), [1, 2, 3, 4]); - expect(res[1].rank).toEqual(3); - expect(res[1].shape).toEqual([2, 2, 1]); - expectArraysClose(await res[1].data(), [5, 6, 7, 8]); - }); - - it('unstack rank 4 tensor with axis=1', async () => { - const x = tf.tensor4d([1, 2, 3, 4, 5, 6, 7, 8], [2, 2, 2, 1]); - const res = tf.unstack(x, 1); - expect(res.length).toEqual(2); - expect(res[0].rank).toEqual(3); - expect(res[0].shape).toEqual([2, 2, 1]); - expectArraysClose(await res[0].data(), [1, 2, 5, 6]); - expect(res[1].rank).toEqual(3); - expect(res[1].shape).toEqual([2, 2, 1]); - expectArraysClose(await res[1].data(), [3, 4, 7, 8]); - }); - - it('unstack rank 4 tensor with axis=2', async () => { - const x = tf.tensor4d([1, 2, 3, 4, 5, 6, 7, 8], [2, 2, 2, 1]); - const res = tf.unstack(x, 2); - expect(res.length).toEqual(2); - expect(res[0].rank).toEqual(3); - expect(res[0].shape).toEqual([2, 2, 1]); - expectArraysClose(await res[0].data(), [1, 3, 5, 7]); - expect(res[1].rank).toEqual(3); - expect(res[1].shape).toEqual([2, 2, 1]); - expectArraysClose(await res[1].data(), [2, 4, 6, 8]); - }); - - it('unstack rank 4 tensor with axis=3', async () => { - const x = tf.tensor4d([1, 2, 3, 4, 5, 6, 7, 8], [2, 2, 2, 1]); - const res = tf.unstack(x, 3); - expect(res.length).toEqual(1); - expect(res[0].rank).toEqual(3); - expect(res[0].shape).toEqual([2, 2, 2]); - expectArraysClose(await res[0].data(), [1, 2, 3, 4, 5, 6, 7, 8]); - }); - - it('throws when passed a non-tensor', () => { - expect(() => tf.unstack({} as tf.Tensor)) - .toThrowError(/Argument 'x' passed to 'unstack' must be a Tensor/); - }); - - it('throws when passed an invalid axis', () => { - expect(() => { - const x = tf.tensor2d([1, 2, 3, 4, 5, 6, 7, 8], [2, 4]); - tf.unstack(x, 3); - }).toThrowError('Axis = 3 is not in [-2, 2)'); - expect(() => { - const x = tf.tensor3d([1, 2, 3, 4, 5, 6, 7, 8], [2, 2, 2]); - tf.unstack(x, 3); - }).toThrowError('Axis = 3 is not in [-3, 3)'); - expect(() => { - const x = tf.tensor4d([1, 2, 3, 4, 5, 6, 7, 8], [2, 2, 2, 1]); - tf.unstack(x, 5); - }).toThrowError('Axis = 5 is not in [-4, 4)'); - }); - - it('accepts a tensor-like object', async () => { - const x = [[1, 2, 3, 4], [5, 6, 7, 8]]; - const res = tf.unstack(x); - expect(res.length).toEqual(2); - expect(res[0].rank).toEqual(1); - expect(res[0].shape).toEqual([4]); - expectArraysClose(await res[0].data(), [1, 2, 3, 4]); - expect(res[1].rank).toEqual(1); - expect(res[1].shape).toEqual([4]); - expectArraysClose(await res[1].data(), [5, 6, 7, 8]); - }); - - it('accepts string', async () => { - const x = - [['one', 'two', 'three', 'four'], ['five', 'six', 'seven', 'eight']]; - const res = tf.unstack(x); - expect(res.length).toEqual(2); - expect(res[0].rank).toEqual(1); - expect(res[0].shape).toEqual([4]); - expectArraysClose(await res[0].data(), ['one', 'two', 'three', 'four']); - expect(res[1].rank).toEqual(1); - expect(res[1].shape).toEqual([4]); - expectArraysClose(await res[1].data(), ['five', 'six', 'seven', 'eight']); - }); - - it('grad of unstack axis=0', async () => { - const x = tf.tensor([[1, 2, 3], [4, 5, 6]]); - const dx1 = tf.grad(x => tf.unstack(x)[0])(x); - expect(dx1.shape).toEqual([2, 3]); - expect(dx1.dtype).toBe('float32'); - expectArraysClose(await dx1.data(), [1, 1, 1, 0, 0, 0]); - - const dx2 = tf.grad(x => tf.unstack(x)[1])(x); - expect(dx2.shape).toEqual([2, 3]); - expect(dx2.dtype).toBe('float32'); - expectArraysClose(await dx2.data(), [0, 0, 0, 1, 1, 1]); - }); - - it('gradient with clones', async () => { - const x = tf.tensor([[1, 2, 3], [4, 5, 6]]); - const dx1 = tf.grad(x => tf.unstack(x.clone())[0].clone())(x); - expect(dx1.shape).toEqual([2, 3]); - expect(dx1.dtype).toBe('float32'); - expectArraysClose(await dx1.data(), [1, 1, 1, 0, 0, 0]); - - const dx2 = tf.grad(x => tf.unstack(x.clone())[1].clone())(x); - expect(dx2.shape).toEqual([2, 3]); - expect(dx2.dtype).toBe('float32'); - expectArraysClose(await dx2.data(), [0, 0, 0, 1, 1, 1]); - }); - - it('grad of unstack axis=1', async () => { - const x = tf.tensor([[1, 2, 3], [4, 5, 6]]); - const axis = 1; - const dx1 = tf.grad(x => tf.unstack(x, axis)[0])(x); - expect(dx1.shape).toEqual([2, 3]); - expect(dx1.dtype).toBe('float32'); - expectArraysClose(await dx1.data(), [1, 0, 0, 1, 0, 0]); - - const dx2 = tf.grad(x => tf.unstack(x, axis)[1])(x); - expect(dx2.shape).toEqual([2, 3]); - expect(dx2.dtype).toBe('float32'); - expectArraysClose(await dx2.data(), [0, 1, 0, 0, 1, 0]); - - const dx3 = tf.grad(x => tf.unstack(x, axis)[2])(x); - expect(dx3.shape).toEqual([2, 3]); - expect(dx3.dtype).toBe('float32'); - expectArraysClose(await dx3.data(), [0, 0, 1, 0, 0, 1]); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/upper_bound.ts b/tfjs-master/tfjs-core/src/ops/upper_bound.ts deleted file mode 100644 index 9636fba5a..000000000 --- a/tfjs-master/tfjs-core/src/ops/upper_bound.ts +++ /dev/null @@ -1,59 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Tensor} from '../tensor'; -import {TensorLike} from '../types'; -import {searchSorted} from './search_sorted'; - -/** - * Searches for where a value would go in a sorted sequence. - * - * This is not a method for checking containment (like javascript in). - * - * The typical use case for this operation is "binning", "bucketing", or - * "discretizing". The values are assigned to bucket-indices based on the edges - * listed in 'sortedSequence'. This operation returns the bucket-index for each - * value. - * - * The index returned corresponds to the first edge greater than the value. - * - * The axis is not settable for this operation. It always operates on the - * innermost dimension (axis=-1). The operation will accept any number of outer - * dimensions. - * - * Note: This operation assumes that 'upperBound' is sorted along the - * innermost axis, maybe using 'sort(..., axis=-1)'. If the sequence is not - * sorted no error is raised and the content of the returned tensor is not well - * defined. - * - * ```js - * const seq = tf.tensor1d([0, 3, 9, 10, 10]); - * const values = tf.tensor1d([0, 4, 10]); - * const result = tf.upperBound(seq, values); - * result.print(); // [1, 2, 5] - * ``` - * @param sortedSequence: N-D. Sorted sequence. - * @param values: N-D. Search values. - * @return An N-D int32 tensor the size of values containing the result of - * applying upper bound to each value. The result is not a global index to - * the entire Tensor, but the index in the last dimension. - * @doc {heading: 'Operations', subheading: 'Evaluation'} - */ -export function upperBound( - sortedSequence: Tensor|TensorLike, values: Tensor|TensorLike): Tensor { - return searchSorted(sortedSequence, values, 'right'); -} diff --git a/tfjs-master/tfjs-core/src/ops/upper_bound_test.ts b/tfjs-master/tfjs-core/src/ops/upper_bound_test.ts deleted file mode 100644 index 80676ebfb..000000000 --- a/tfjs-master/tfjs-core/src/ops/upper_bound_test.ts +++ /dev/null @@ -1,74 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('upperBound', ALL_ENVS, () => { - it('test1D', async () => { - // Tests against numpy generated data. - const NUMPY_DATA = { - 'float32': [ - [ - -725.0505981445312, -721.4473266601562, -669.2916259765625, - -460.14422607421875, -304.4682922363281, -302.20330810546875, - -204.64633178710938, -143.817626953125, 243.3914337158203, - 247.34442138671875, 326.88299560546875, 451.9959716796875, - 501.62420654296875, 501.8848571777344, 614.7825927734375, - 766.6121826171875, 791.7724609375, 806.8038330078125, - 855.0171508789062, 929.6801147460938 - ], - [ - -795.3311157226562, -171.88803100585938, 388.8003234863281, - -171.64146423339844, -900.0930786132812, 71.79280853271484, - 327.58929443359375, 29.77822494506836, 889.1895141601562, - 173.11007690429688 - ], - [0, 7, 11, 7, 0, 8, 11, 8, 19, 8] - ], - 'int32': [ - [ - -968, -867, -751, -725, -655, -346, -285, 54, 246, 381, - 393, 423, 507, 510, 771, 817, 846, 858, 865, 994 - ], - [-770, 898, -100, 156, -183, -525, 806, 147, -994, 234], - [2, 19, 7, 8, 7, 5, 15, 8, 0, 8] - ] - }; - for (const dtype of ['float32', 'int32'] as const ) { - const [sortedSequence, values, npAns] = NUMPY_DATA[dtype]; - - const result = tf.upperBound(sortedSequence, values); - - expectArraysClose(await result.data(), npAns); - } - }); - - it('upperBound2D', async () => { - for (const dtype of ['float32', 'int32'] as const ) { - const sortedSequence = - tf.tensor2d([[0, 3, 9, 9, 10], [1, 2, 3, 4, 5]], undefined, dtype); - const values = tf.tensor2d([[2, 4, 9], [0, 2, 6]], undefined, dtype); - const correctAns = [[1, 2, 4], [0, 2, 5]]; - - const result = tf.upperBound(sortedSequence, values); - - expectArraysClose(await result.data(), correctAns); - } - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/variable.ts b/tfjs-master/tfjs-core/src/ops/variable.ts deleted file mode 100644 index e1e8d767a..000000000 --- a/tfjs-master/tfjs-core/src/ops/variable.ts +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {Tensor, Variable} from '../tensor'; -import {DataType, Rank} from '../types'; - -/** - * Creates a new variable with the provided initial value. - * ```js - * const x = tf.variable(tf.tensor([1, 2, 3])); - * x.assign(tf.tensor([4, 5, 6])); - * - * x.print(); - * ``` - * - * @param initialValue Initial value for the tensor. - * @param trainable If true, optimizers are allowed to update it. - * @param name Name of the variable. Defaults to a unique id. - * @param dtype If set, initialValue will be converted to the given type. - * - * @doc {heading: 'Tensors', subheading: 'Creation'} - */ -export function variable( - initialValue: Tensor, trainable = true, name?: string, - dtype?: DataType): Variable { - return ENGINE.makeVariable(initialValue, trainable, name, dtype) as - Variable; -} diff --git a/tfjs-master/tfjs-core/src/ops/where.ts b/tfjs-master/tfjs-core/src/ops/where.ts deleted file mode 100644 index 2d5eea32a..000000000 --- a/tfjs-master/tfjs-core/src/ops/where.ts +++ /dev/null @@ -1,74 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {Select, SelectInputs} from '../kernel_names'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -import {broadcastTo} from './broadcast_to'; -import {assertAndGetBroadcastShape} from './broadcast_util'; -import {op} from './operation'; - -/** - * Returns the elements, either `a` or `b` depending on the `condition`. - * - * If the condition is true, select from `a`, otherwise select from `b`. - * - * ```js - * const cond = tf.tensor1d([false, false, true], 'bool'); - * const a = tf.tensor1d([1 , 2, 3]); - * const b = tf.tensor1d([-1, -2, -3]); - * - * a.where(cond, b).print(); - * ``` - * - * @param condition The input condition. Must be of dtype bool. - * @param a If `condition` is rank 1, `a` may have a higher rank but - * its first dimension must match the size of `condition`. - * @param b A tensor with the same dtype as `a` and with shape that is - * compatible with `a`. - * @return A tensor with same dtype as `a` and `b`, and shape that is - * broadcastable from `a` and `b`. - * - * @doc {heading: 'Operations', subheading: 'Logical'} - */ -function where_( - condition: Tensor|TensorLike, a: T|TensorLike, b: T|TensorLike): T { - const $a = convertToTensor(a, 'a', 'where'); - const $b = convertToTensor(b, 'b', 'where'); - const $condition = convertToTensor(condition, 'condition', 'where', 'bool'); - // TODO: move this logic to forward function when the broadcastTo op is - // implemented in WASM. - // Find the broadcastable shape for $condition, $a, and $b. - const broadcastShape = assertAndGetBroadcastShape( - assertAndGetBroadcastShape($condition.shape, $a.shape), $b.shape); - const $broadcastedCondition = broadcastTo($condition, broadcastShape); - const $broadcastedA = broadcastTo($a, broadcastShape); - const $broadcastedB = broadcastTo($b, broadcastShape); - - const inputs: SelectInputs = { - condition: $broadcastedCondition, - t: $broadcastedA, - e: $broadcastedB - }; - return ENGINE.runKernel(Select, inputs as unknown as NamedTensorMap); -} - -export const where = /* @__PURE__ */ op({where_}); diff --git a/tfjs-master/tfjs-core/src/ops/where_async.ts b/tfjs-master/tfjs-core/src/ops/where_async.ts deleted file mode 100644 index 1455d9500..000000000 --- a/tfjs-master/tfjs-core/src/ops/where_async.ts +++ /dev/null @@ -1,53 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {whereImpl} from '../backends/where_impl'; -import {Tensor, Tensor2D} from '../tensor'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -/** - * Returns the coordinates of true elements of condition. - * - * The coordinates are returned in a 2-D tensor where the first dimension (rows) - * represents the number of true elements, and the second dimension (columns) - * represents the coordinates of the true elements. Keep in mind, the shape of - * the output tensor can vary depending on how many true values there are in - * input. Indices are output in row-major order. The resulting tensor has the - * shape `[numTrueElems, condition.rank]`. - * - * This is analogous to calling the python `tf.where(cond)` without an x or y. - * - * ```js - * const cond = tf.tensor1d([false, false, true], 'bool'); - * const result = await tf.whereAsync(cond); - * result.print(); - * ``` - * - * @doc {heading: 'Operations', subheading: 'Logical'} - */ -async function whereAsync_(condition: Tensor|TensorLike): Promise { - const $condition = - convertToTensor(condition, 'condition', 'whereAsync', 'bool'); - const vals = await $condition.data(); - const res = whereImpl($condition.shape, vals); - if (condition !== $condition) { - $condition.dispose(); - } - return res; -} - -export const whereAsync = whereAsync_; diff --git a/tfjs-master/tfjs-core/src/ops/where_async_test.ts b/tfjs-master/tfjs-core/src/ops/where_async_test.ts deleted file mode 100644 index 11259ea9e..000000000 --- a/tfjs-master/tfjs-core/src/ops/where_async_test.ts +++ /dev/null @@ -1,82 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('whereAsync', ALL_ENVS, () => { - it('1d tensor', async () => { - const condition = tf.tensor1d([true, false, true, true], 'bool'); - const res = await tf.whereAsync(condition); - expect(res.dtype).toBe('int32'); - expect(res.shape).toEqual([3, 1]); - expectArraysClose(await res.data(), [0, 2, 3]); - }); - - it('2d tensor', async () => { - const condition = tf.tensor2d( - [[true, false, false], [false, true, true]], [2, 3], 'bool'); - const res = await tf.whereAsync(condition); - expect(res.dtype).toBe('int32'); - expect(res.shape).toEqual([3, 2]); - expectArraysClose(await res.data(), [0, 0, 1, 1, 1, 2]); - }); - - it('3d tensor', async () => { - const condition = tf.tensor3d( - [ - [[true, false, false], [false, true, true]], - [[false, false, false], [true, true, false]] - ], - [2, 2, 3], 'bool'); - const res = await tf.whereAsync(condition); - expect(res.dtype).toBe('int32'); - expect(res.shape).toEqual([5, 3]); - expectArraysClose( - await res.data(), [0, 0, 0, 0, 1, 1, 0, 1, 2, 1, 1, 0, 1, 1, 1]); - }); - - it('accepts a tensor-like object', async () => { - const condition = [true, false, true]; - const res = await tf.whereAsync(condition); - expect(res.dtype).toBe('int32'); - expect(res.shape).toEqual([2, 1]); - expectArraysClose(await res.data(), [0, 2]); - }); - - it('throws error if condition is not of type bool', async () => { - const condition = tf.tensor1d([1, 0, 1]); - // expect(...).toThrowError() does not support async functions. - // See https://github.com/jasmine/jasmine/issues/1410 - try { - await tf.whereAsync(condition); - throw new Error('The line above should have thrown an error'); - } catch (ex) { - expect(ex.message) - .toMatch(/Argument 'condition' passed to 'whereAsync' must be bool/); - } - }); - - it('returns tensor with 0 in shape when no values are true', async () => { - const condition = [[[false]], [[false]], [[false]]]; - const res = await tf.whereAsync(condition); - expect(res.dtype).toBe('int32'); - expect(res.shape).toEqual([0, 3]); - expectArraysClose(await res.data(), []); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/where_test.ts b/tfjs-master/tfjs-core/src/ops/where_test.ts deleted file mode 100644 index a3e6826e0..000000000 --- a/tfjs-master/tfjs-core/src/ops/where_test.ts +++ /dev/null @@ -1,339 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; -import {backend} from '../index'; - -describeWithFlags('where', ALL_ENVS, () => { - it('Scalars.', async () => { - const a = tf.scalar(10); - const b = tf.scalar(20); - const c = tf.scalar(1, 'bool'); - - expectArraysClose(await tf.where(c, a, b).data(), [10]); - }); - - it('Invalid condition type', () => { - const c = tf.tensor1d([1, 0, 1, 0], 'int32'); - const a = tf.tensor1d([10, 10, 10, 10], 'bool'); - const b = tf.tensor1d([20, 20, 20, 20], 'bool'); - const f = () => { - tf.where(c, a, b); - }; - expect(f).toThrowError(); - }); - - it('Tensor1D', async () => { - const c = tf.tensor1d([1, 0, 1, 0], 'bool'); - const a = tf.tensor1d([10, 10, 10, 10]); - const b = tf.tensor1d([20, 20, 20, 20]); - expectArraysClose(await tf.where(c, a, b).data(), [10, 20, 10, 20]); - }); - - it('Tensor1D different a/b shapes', () => { - let c = tf.tensor1d([1, 0, 1, 0], 'bool'); - let a = tf.tensor1d([10, 10, 10]); - let b = tf.tensor1d([20, 20, 20, 20]); - let f = () => { - tf.where(c, a, b); - }; - expect(f).toThrowError(); - - c = tf.tensor1d([1, 0, 1, 0], 'bool'); - a = tf.tensor1d([10, 10, 10, 10]); - b = tf.tensor1d([20, 20, 20]); - f = () => { - tf.where(c, a, b); - }; - expect(f).toThrowError(); - }); - - it('Tensor1D different condition/a shapes', () => { - const c = tf.tensor1d([1, 0, 1, 0], 'bool'); - const a = tf.tensor1d([10, 10, 10]); - const b = tf.tensor1d([20, 20, 20]); - const f = () => { - tf.where(c, a, b); - }; - expect(f).toThrowError(); - }); - - it('Tensor2D', async () => { - const c = tf.tensor2d([[1, 0], [0, 1]], [2, 2], 'bool'); - const a = tf.tensor2d([[10, 10], [10, 10]], [2, 2]); - const b = tf.tensor2d([[5, 5], [5, 5]], [2, 2]); - expectArraysClose(await tf.where(c, a, b).data(), [10, 5, 5, 10]); - }); - - it('Tensor2D different a/b shapes', () => { - let c = tf.tensor2d([[1, 1], [0, 0]], [2, 2], 'bool'); - let a = tf.tensor2d([[5, 5, 5], [5, 5, 5]], [2, 3]); - let b = tf.tensor2d([[4, 4], [4, 4]], [2, 2]); - let f = () => { - tf.where(c, a, b); - }; - expect(f).toThrowError(); - - c = tf.tensor2d([[1, 1], [0, 0]], [2, 2], 'bool'); - a = tf.tensor2d([[5, 5], [5, 5]], [2, 2]); - b = tf.tensor2d([[4, 4, 4], [4, 4, 4]], [2, 3]); - f = () => { - tf.where(c, a, b); - }; - expect(f).toThrowError(); - }); - - it('Tensor2D different condition/a shapes', () => { - const c = tf.tensor2d([[1, 0], [0, 1]], [2, 2], 'bool'); - const a = tf.tensor2d([[10, 10, 10], [10, 10, 10]], [2, 3]); - const b = tf.tensor2d([[5, 5, 5], [5, 5, 5]], [2, 3]); - const f = () => { - tf.where(c, a, b); - }; - expect(f).toThrowError(); - }); - - it('broadcasting Tensor2D shapes', async () => { - const c = tf.tensor1d([1, 0], 'bool'); - let a = tf.tensor2d([[10], [10]], [2, 1]); - let b = tf.tensor2d([[5], [5]], [2, 1]); - let res = tf.where(c, a, b); - expect(res.shape).toEqual([2, 2]); - expectArraysClose(await res.data(), [10, 5, 10, 5]); - - a = tf.tensor2d([[10, 10], [10, 10], [10, 10]], [3, 2]); - b = tf.tensor2d([[5], [5], [5]], [3, 1]); - res = tf.where(c, a, b); - expect(res.shape).toEqual([3, 2]); - expectArraysClose(await res.data(), [10, 5, 10, 5, 10, 5]); - }); - - it('Tensor3D', async () => { - const c = - tf.tensor3d([[[1], [0], [1]], [[0], [0], [0]]], [2, 3, 1], 'bool'); - const a = tf.tensor3d([[[5], [5], [5]], [[5], [5], [5]]], [2, 3, 1]); - const b = tf.tensor3d([[[3], [3], [3]], [[3], [3], [3]]], [2, 3, 1]); - expectArraysClose(await tf.where(c, a, b).data(), [5, 3, 5, 3, 3, 3]); - }); - - it('Tensor3D with scalar condition', async () => { - const a = tf.ones([1, 3, 3]); - const b = tf.zeros([1, 3, 3]); - - expectArraysClose( - await tf.where(tf.ones([1], 'bool'), a, b).data(), - [1, 1, 1, 1, 1, 1, 1, 1, 1]); - expectArraysClose( - await tf.where(tf.zeros([1], 'bool'), a, b).data(), - [0, 0, 0, 0, 0, 0, 0, 0, 0]); - }); - - it('Tensor3D different a/b shapes', () => { - const c = - tf.tensor3d([[[1], [0], [1]], [[0], [0], [0]]], [2, 3, 1], 'bool'); - let a = tf.tensor3d([[[5], [5]], [[5], [5]]], [2, 2, 1]); - let b = tf.tensor3d([[[3], [3], [3]], [[3], [3], [3]]], [2, 3, 1]); - let f = () => { - tf.where(c, a, b); - }; - expect(f).toThrowError(); - - a = tf.tensor3d([[[5], [5], [5]], [[5], [5], [5]]], [2, 3, 1]); - b = tf.tensor3d([[[3], [3]], [[3], [3]]], [2, 2, 1]); - f = () => { - tf.where(c, a, b); - }; - expect(f).toThrowError(); - }); - - it('Tensor3D different condition/a shapes', () => { - const c = tf.tensor3d([[[1], [0]], [[0], [0]]], [2, 2, 1], 'bool'); - const a = tf.tensor3d([[[5], [5], [5]], [[5], [5], [5]]], [2, 3, 1]); - const b = tf.tensor3d([[[3], [3], [3]], [[3], [3], [3]]], [2, 3, 1]); - const f = () => { - tf.where(c, a, b); - }; - expect(f).toThrowError(); - }); - - it('broadcasting Tensor3D shapes', async () => { - const c = tf.tensor1d([1, 0], 'bool'); - let a: tf.Tensor = tf.tensor3d([[[9]], [[9]], [[9]], [[9]]], [4, 1, 1]); - let b = tf.tensor3d([[[8]], [[8]], [[8]], [[8]]], [4, 1, 1]); - let res = tf.where(c, a, b); - expect(res.shape).toEqual([4, 1, 2]); - expectArraysClose(await res.data(), [9, 8, 9, 8, 9, 8, 9, 8]); - - a = tf.tensor2d([[9], [9]], [2, 1]); - b = tf.tensor3d([[[8]], [[8]], [[8]], [[8]]], [4, 1, 1]); - res = tf.where(c, a, b); - expect(res.shape).toEqual([4, 2, 2]); - expectArraysClose( - await res.data(), [9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8]); - }); - - it('Tensor4D', async () => { - const c = tf.tensor4d([1, 0, 1, 1], [2, 2, 1, 1], 'bool'); - const a = tf.tensor4d([7, 7, 7, 7], [2, 2, 1, 1]); - const b = tf.tensor4d([3, 3, 3, 3], [2, 2, 1, 1]); - expectArraysClose(await tf.where(c, a, b).data(), [7, 3, 7, 7]); - }); - - it('Tensor4D different a/b shapes', () => { - const c = tf.tensor4d([1, 0, 1, 1], [2, 2, 1, 1], 'bool'); - const a = tf.tensor4d([7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7], [2, 3, 2, 1]); - const b = tf.tensor4d([3, 3, 3, 3], [2, 2, 1, 1]); - const f = () => { - tf.where(c, a, b); - }; - expect(f).toThrowError(); - }); - - it('Tensor4D different condition/a shapes', () => { - const c = - tf.tensor4d([0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1], [2, 3, 2, 1], 'bool'); - const a = tf.tensor4d([7, 7, 7, 7], [2, 2, 1, 1]); - const b = tf.tensor4d([3, 3, 3, 3], [2, 2, 1, 1]); - const f = () => { - tf.where(c, a, b); - }; - expect(f).toThrowError(); - }); - - it('TensorLike', async () => { - expectArraysClose(await tf.where(true, 10, 20).data(), [10]); - }); - - it('TensorLike Chained', async () => { - const a = tf.scalar(10); - expectArraysClose(await a.where(true, 20).data(), [10]); - }); - - it('int32', async () => { - if (backend() && backend().floatPrecision() === 32) { - // TODO: Use skip() instead when it is implemented - const c = tf.tensor1d([1, 0, 0], 'bool'); - const a = tf.tensor1d([12345678, 10, 10], 'int32'); - const b = tf.tensor1d([20, 20, -12345678], 'int32'); - const res = tf.where(c, a, b); - expect(res.dtype).toEqual('int32'); - expectArraysClose(await res.data(), [12345678, 20, -12345678]); - } - }); - - it('throws when passed condition as a non-tensor', () => { - expect( - () => tf.where( - {} as tf.Tensor, tf.scalar(1, 'bool'), tf.scalar(1, 'bool'))) - .toThrowError( - /Argument 'condition' passed to 'where' must be a Tensor/); - }); - it('throws when passed a as a non-tensor', () => { - expect( - () => tf.where( - tf.scalar(1, 'bool'), {} as tf.Tensor, tf.scalar(1, 'bool'))) - .toThrowError(/Argument 'a' passed to 'where' must be a Tensor/); - }); - it('throws when passed b as a non-tensor', () => { - expect( - () => tf.where( - tf.scalar(1, 'bool'), tf.scalar(1, 'bool'), {} as tf.Tensor)) - .toThrowError(/Argument 'b' passed to 'where' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const a = 10; - const b = 20; - const c = 1; - expectArraysClose(await tf.where(c, a, b).data(), [10]); - }); - - it('1D gradient', async () => { - const c = tf.tensor1d([1, 0, 1], 'bool'); - const a = tf.tensor1d([1, 2, 3]); - const b = tf.tensor1d([4, 5, 6]); - const dy = tf.tensor1d([1, 2, 3]); - const grads = tf.grads((c, a, b) => tf.where(c, a, b)); - const [dc, da, db] = grads([c, a, b], dy); - expectArraysClose(await dc.data(), [0, 0, 0]); - expectArraysClose(await da.data(), [1, 0, 3]); - expectArraysClose(await db.data(), [0, 2, 0]); - expect(dc.shape).toEqual(c.shape); - expect(da.shape).toEqual(a.shape); - expect(db.shape).toEqual(b.shape); - }); - - it('gradient with clones', async () => { - const c = tf.tensor1d([1, 0, 1], 'bool'); - const a = tf.tensor1d([1, 2, 3]); - const b = tf.tensor1d([4, 5, 6]); - const dy = tf.tensor1d([1, 2, 3]); - const grads = tf.grads( - (c, a, b) => tf.where(c.clone(), a.clone(), b.clone()).clone()); - const [dc, da, db] = grads([c, a, b], dy); - expectArraysClose(await dc.data(), [0, 0, 0]); - expectArraysClose(await da.data(), [1, 0, 3]); - expectArraysClose(await db.data(), [0, 2, 0]); - expect(dc.shape).toEqual(c.shape); - expect(da.shape).toEqual(a.shape); - expect(db.shape).toEqual(b.shape); - }); - - it('2D gradient', async () => { - const c = tf.tensor2d([1, 0, 1, 1, 1, 0], [2, 3], 'bool'); - const a = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - const b = tf.tensor2d([7, 8, 9, 10, 11, 12], [2, 3]); - const dy = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - const grads = tf.grads((c, a, b) => tf.where(c, a, b)); - const [dc, da, db] = grads([c, a, b], dy); - expectArraysClose(await dc.data(), [0, 0, 0, 0, 0, 0]); - expectArraysClose(await da.data(), [1, 0, 3, 4, 5, 0]); - expectArraysClose(await db.data(), [0, 2, 0, 0, 0, 6]); - expect(dc.shape).toEqual(c.shape); - expect(da.shape).toEqual(a.shape); - expect(db.shape).toEqual(b.shape); - }); - it('3D gradient', async () => { - const c = tf.tensor3d([1, 1, 0, 1, 1, 0], [2, 3, 1], 'bool'); - const a = tf.tensor3d([1, 2, 3, 4, 5, 6], [2, 3, 1]); - const b = tf.tensor3d([7, 8, 9, 10, 11, 12], [2, 3, 1]); - const dy = tf.tensor3d([1, 2, 3, 4, 5, 6], [2, 3, 1]); - const grads = tf.grads((c, a, b) => tf.where(c, a, b)); - const [dc, da, db] = grads([c, a, b], dy); - expectArraysClose(await dc.data(), [0, 0, 0, 0, 0, 0]); - expectArraysClose(await da.data(), [1, 2, 0, 4, 5, 0]); - expectArraysClose(await db.data(), [0, 0, 3, 0, 0, 6]); - expect(dc.shape).toEqual(c.shape); - expect(da.shape).toEqual(a.shape); - expect(db.shape).toEqual(b.shape); - }); - it('4D gradient', async () => { - const c = tf.tensor4d([1, 1, 0, 1], [2, 2, 1, 1], 'bool'); - const a = tf.tensor4d([1, 2, 3, 4], [2, 2, 1, 1]); - const b = tf.tensor4d([5, 6, 7, 8], [2, 2, 1, 1]); - const dy = tf.tensor4d([1, 2, 3, 4], [2, 2, 1, 1]); - const grads = tf.grads((c, a, b) => tf.where(c, a, b)); - const [dc, da, db] = grads([c, a, b], dy); - expectArraysClose(await dc.data(), [0, 0, 0, 0]); - expectArraysClose(await da.data(), [1, 2, 0, 4]); - expectArraysClose(await db.data(), [0, 0, 3, 0]); - expect(dc.shape).toEqual(c.shape); - expect(da.shape).toEqual(a.shape); - expect(db.shape).toEqual(b.shape); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/zeros.ts b/tfjs-master/tfjs-core/src/ops/zeros.ts deleted file mode 100644 index d7831a353..000000000 --- a/tfjs-master/tfjs-core/src/ops/zeros.ts +++ /dev/null @@ -1,48 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {Tensor} from '../tensor'; -import {DataType, Rank, ShapeMap} from '../types'; -import {assertNonNegativeIntegerDimensions, makeZerosTypedArray, sizeFromShape} from '../util'; - -import {complex} from './complex'; - -/** - * Creates a `tf.Tensor` with all elements set to 0. - * - * ```js - * tf.zeros([2, 2]).print(); - * ``` - * - * @param shape An array of integers defining the output tensor shape. - * @param dtype The type of an element in the resulting tensor. Can - * be 'float32', 'int32' or 'bool'. Defaults to 'float'. - * - * @doc {heading: 'Tensors', subheading: 'Creation'} - */ -export function zeros( - shape: ShapeMap[R], dtype: DataType = 'float32'): Tensor { - assertNonNegativeIntegerDimensions(shape); - if (dtype === 'complex64') { - const real = zeros(shape, 'float32'); - const imag = zeros(shape, 'float32'); - return complex(real, imag); - } - const values = makeZerosTypedArray(sizeFromShape(shape), dtype); - return ENGINE.makeTensor(values, shape, dtype) as Tensor; -} diff --git a/tfjs-master/tfjs-core/src/ops/zeros_like.ts b/tfjs-master/tfjs-core/src/ops/zeros_like.ts deleted file mode 100644 index cb77117ec..000000000 --- a/tfjs-master/tfjs-core/src/ops/zeros_like.ts +++ /dev/null @@ -1,45 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {ZerosLike, ZerosLikeInputs} from '../kernel_names'; -import {Tensor} from '../tensor'; -import {NamedTensorMap} from '../tensor_types'; -import {convertToTensor} from '../tensor_util_env'; -import {TensorLike} from '../types'; - -import {op} from './operation'; - -/** - * Creates a `tf.Tensor` with all elements set to 0 with the same shape as the - * given tensor. - * - * ```js - * const x = tf.tensor([1, 2]); - * tf.zerosLike(x).print(); - * ``` - * - * @param x The tensor of required shape. - * - * @doc {heading: 'Tensors', subheading: 'Creation'} - */ -function zerosLike_(x: T|TensorLike): T { - const $x = convertToTensor(x, 'x', 'zerosLike'); - const inputs: ZerosLikeInputs = {x: $x}; - return ENGINE.runKernel(ZerosLike, inputs as unknown as NamedTensorMap); -} -export const zerosLike = /* @__PURE__ */ op({zerosLike_}); diff --git a/tfjs-master/tfjs-core/src/ops/zeros_like_test.ts b/tfjs-master/tfjs-core/src/ops/zeros_like_test.ts deleted file mode 100644 index 124ef88e0..000000000 --- a/tfjs-master/tfjs-core/src/ops/zeros_like_test.ts +++ /dev/null @@ -1,248 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose, expectArraysEqual} from '../test_util'; - -describeWithFlags('zerosLike', ALL_ENVS, () => { - it('1D default dtype', async () => { - const a = tf.tensor1d([1, 2, 3]); - const b = tf.zerosLike(a); - expect(b.dtype).toBe('float32'); - expect(b.shape).toEqual([3]); - expectArraysClose(await b.data(), [0, 0, 0]); - }); - - it('chainable 1D default dtype', async () => { - const a = tf.tensor1d([1, 2, 3]); - const b = a.zerosLike(); - expect(b.dtype).toBe('float32'); - expect(b.shape).toEqual([3]); - expectArraysClose(await b.data(), [0, 0, 0]); - }); - - it('1D float32 dtype', async () => { - const a = tf.tensor1d([1, 2, 3], 'float32'); - const b = tf.zerosLike(a); - expect(b.dtype).toBe('float32'); - expect(b.shape).toEqual([3]); - expectArraysClose(await b.data(), [0, 0, 0]); - }); - - it('1D int32 dtype', async () => { - const a = tf.tensor1d([1, 2, 3], 'int32'); - const b = tf.zerosLike(a); - expect(b.dtype).toBe('int32'); - expect(b.shape).toEqual([3]); - expectArraysEqual(await b.data(), [0, 0, 0]); - }); - - it('1D bool dtype', async () => { - const a = tf.tensor1d([1, 2, 3], 'bool'); - const b = tf.zerosLike(a); - expect(b.dtype).toBe('bool'); - expect(b.shape).toEqual([3]); - expectArraysEqual(await b.data(), [0, 0, 0]); - }); - - it('2D default dtype', async () => { - const a = tf.tensor2d([1, 2, 3, 4], [2, 2]); - const b = tf.zerosLike(a); - expect(b.dtype).toBe('float32'); - expect(b.shape).toEqual([2, 2]); - expectArraysClose(await b.data(), [0, 0, 0, 0]); - }); - - it('2D float32 dtype', async () => { - const a = tf.tensor2d([1, 2, 3, 4], [2, 2], 'float32'); - const b = tf.zerosLike(a); - expect(b.dtype).toBe('float32'); - expect(b.shape).toEqual([2, 2]); - expectArraysClose(await b.data(), [0, 0, 0, 0]); - }); - - it('2D int32 dtype', async () => { - const a = tf.tensor2d([1, 2, 3, 4], [2, 2], 'int32'); - const b = tf.zerosLike(a); - expect(b.dtype).toBe('int32'); - expect(b.shape).toEqual([2, 2]); - expectArraysEqual(await b.data(), [0, 0, 0, 0]); - }); - - it('2D bool dtype', async () => { - const a = tf.tensor2d([1, 2, 3, 4], [2, 2], 'bool'); - const b = tf.zerosLike(a); - expect(b.dtype).toBe('bool'); - expect(b.shape).toEqual([2, 2]); - expectArraysEqual(await b.data(), [0, 0, 0, 0]); - }); - - it('3D default dtype', async () => { - const a = tf.tensor3d([1, 2, 3, 4], [2, 2, 1]); - const b = tf.zerosLike(a); - expect(b.dtype).toBe('float32'); - expect(b.shape).toEqual([2, 2, 1]); - expectArraysClose(await b.data(), [0, 0, 0, 0]); - }); - - it('3D float32 dtype', async () => { - const a = tf.tensor3d([1, 2, 3, 4], [2, 2, 1], 'float32'); - const b = tf.zerosLike(a); - expect(b.dtype).toBe('float32'); - expect(b.shape).toEqual([2, 2, 1]); - expectArraysClose(await b.data(), [0, 0, 0, 0]); - }); - - it('3D int32 dtype', async () => { - const a = tf.tensor3d([1, 2, 3, 4], [2, 2, 1], 'int32'); - const b = tf.zerosLike(a); - expect(b.dtype).toBe('int32'); - expect(b.shape).toEqual([2, 2, 1]); - expectArraysEqual(await b.data(), [0, 0, 0, 0]); - }); - - it('3D bool dtype', async () => { - const a = tf.tensor3d([1, 2, 3, 4], [2, 2, 1], 'bool'); - const b = tf.zerosLike(a); - expect(b.dtype).toBe('bool'); - expect(b.shape).toEqual([2, 2, 1]); - expectArraysEqual(await b.data(), [0, 0, 0, 0]); - }); - - it('4D default dtype', async () => { - const a = tf.tensor4d([1, 2, 3, 4], [2, 2, 1, 1]); - const b = tf.zerosLike(a); - expect(b.dtype).toBe('float32'); - expect(b.shape).toEqual([2, 2, 1, 1]); - expectArraysClose(await b.data(), [0, 0, 0, 0]); - }); - - it('4D float32 dtype', async () => { - const a = tf.tensor4d([1, 2, 3, 4], [2, 2, 1, 1], 'float32'); - const b = tf.zerosLike(a); - expect(b.dtype).toBe('float32'); - expect(b.shape).toEqual([2, 2, 1, 1]); - expectArraysClose(await b.data(), [0, 0, 0, 0]); - }); - - it('4D int32 dtype', async () => { - const a = tf.tensor4d([1, 2, 3, 4], [2, 2, 1, 1], 'int32'); - const b = tf.zerosLike(a); - expect(b.dtype).toBe('int32'); - expect(b.shape).toEqual([2, 2, 1, 1]); - expectArraysEqual(await b.data(), [0, 0, 0, 0]); - }); - - it('4D bool dtype', async () => { - const a = tf.tensor4d([1, 2, 3, 4], [2, 2, 1, 1], 'bool'); - const b = tf.zerosLike(a); - expect(b.dtype).toBe('bool'); - expect(b.shape).toEqual([2, 2, 1, 1]); - expectArraysEqual(await b.data(), [0, 0, 0, 0]); - }); - - it('4D default dtype', async () => { - const a = tf.tensor4d([1, 2, 3, 4], [2, 2, 1, 1]); - const b = tf.zerosLike(a); - expect(b.dtype).toBe('float32'); - expect(b.shape).toEqual([2, 2, 1, 1]); - expectArraysClose(await b.data(), [0, 0, 0, 0]); - }); - - it('5D float32 dtype', async () => { - const a = tf.tensor5d([1, 2, 3, 4], [1, 2, 2, 1, 1], 'float32'); - const b = tf.zerosLike(a); - expect(b.dtype).toBe('float32'); - expect(b.shape).toEqual([1, 2, 2, 1, 1]); - expectArraysClose(await b.data(), [0, 0, 0, 0]); - }); - - it('5D int32 dtype', async () => { - const a = tf.tensor5d([1, 2, 3, 4], [1, 2, 2, 1, 1], 'int32'); - const b = tf.zerosLike(a); - expect(b.dtype).toBe('int32'); - expect(b.shape).toEqual([1, 2, 2, 1, 1]); - expectArraysEqual(await b.data(), [0, 0, 0, 0]); - }); - - it('5D bool dtype', async () => { - const a = tf.tensor5d([1, 2, 3, 4], [1, 2, 2, 1, 1], 'bool'); - const b = tf.zerosLike(a); - expect(b.dtype).toBe('bool'); - expect(b.shape).toEqual([1, 2, 2, 1, 1]); - expectArraysEqual(await b.data(), [0, 0, 0, 0]); - }); - - it('5D default dtype', async () => { - const a = tf.tensor5d([1, 2, 3, 4], [1, 2, 2, 1, 1]); - const b = tf.zerosLike(a); - expect(b.dtype).toBe('float32'); - expect(b.shape).toEqual([1, 2, 2, 1, 1]); - expectArraysClose(await b.data(), [0, 0, 0, 0]); - }); - - it('6D float32 dtype', async () => { - const a = tf.tensor6d([1, 2, 3, 4], [1, 2, 2, 1, 1, 1], 'float32'); - const b = tf.zerosLike(a); - expect(b.dtype).toBe('float32'); - expect(b.shape).toEqual([1, 2, 2, 1, 1, 1]); - expectArraysClose(await b.data(), [0, 0, 0, 0]); - }); - - it('6D int32 dtype', async () => { - const a = tf.tensor6d([1, 2, 3, 4], [1, 2, 2, 1, 1, 1], 'int32'); - const b = tf.zerosLike(a); - expect(b.dtype).toBe('int32'); - expect(b.shape).toEqual(a.shape); - expectArraysEqual(await b.data(), [0, 0, 0, 0]); - }); - - it('6D bool dtype', async () => { - const a = tf.tensor6d([1, 2, 3, 4], [1, 2, 2, 1, 1, 1], 'bool'); - const b = tf.zerosLike(a); - expect(b.dtype).toBe('bool'); - expect(b.shape).toEqual(a.shape); - expectArraysEqual(await b.data(), [0, 0, 0, 0]); - }); - - it('6D default dtype', async () => { - const a = tf.tensor6d([1, 2, 3, 4], [1, 2, 2, 1, 1, 1]); - const b = tf.zerosLike(a); - expect(b.dtype).toBe('float32'); - expect(b.shape).toEqual(a.shape); - expectArraysClose(await b.data(), [0, 0, 0, 0]); - }); - - it('zerosLike gradient', async () => { - const x = tf.tensor2d([[0, 1, 2], [4, 5, 6]]); - const gradients = tf.grad(x => tf.zerosLike(x))(x); - expect(gradients.shape).toEqual([2, 3]); - expectArraysEqual(await gradients.data(), [0, 0, 0, 0, 0, 0]); - }); - - it('throws when passed a non-tensor', () => { - expect(() => tf.zerosLike({} as tf.Tensor)) - .toThrowError(/Argument 'x' passed to 'zerosLike' must be a Tensor/); - }); - - it('accepts a tensor-like object', async () => { - const res = tf.zerosLike([[1, 2], [3, 4]]); - expect(res.shape).toEqual([2, 2]); - expectArraysEqual(await res.data(), [0, 0, 0, 0]); - }); -}); diff --git a/tfjs-master/tfjs-core/src/ops/zeros_test.ts b/tfjs-master/tfjs-core/src/ops/zeros_test.ts deleted file mode 100644 index 7656dd9df..000000000 --- a/tfjs-master/tfjs-core/src/ops/zeros_test.ts +++ /dev/null @@ -1,138 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose, expectArraysEqual} from '../test_util'; - -describeWithFlags('zeros', ALL_ENVS, () => { - it('1D default dtype', async () => { - const a: tf.Tensor1D = tf.zeros([3]); - expect(a.dtype).toBe('float32'); - expect(a.shape).toEqual([3]); - expectArraysClose(await a.data(), [0, 0, 0]); - }); - - it('1D float32 dtype', async () => { - const a = tf.zeros([3], 'float32'); - expect(a.dtype).toBe('float32'); - expect(a.shape).toEqual([3]); - expectArraysClose(await a.data(), [0, 0, 0]); - }); - - it('1D int32 dtype', async () => { - const a = tf.zeros([3], 'int32'); - expect(a.dtype).toBe('int32'); - expect(a.shape).toEqual([3]); - expectArraysEqual(await a.data(), [0, 0, 0]); - }); - - it('1D bool dtype', async () => { - const a = tf.zeros([3], 'bool'); - expect(a.dtype).toBe('bool'); - expect(a.shape).toEqual([3]); - expectArraysEqual(await a.data(), [0, 0, 0]); - }); - - it('2D default dtype', async () => { - const a = tf.zeros([3, 2]); - expect(a.dtype).toBe('float32'); - expect(a.shape).toEqual([3, 2]); - expectArraysClose(await a.data(), [0, 0, 0, 0, 0, 0]); - }); - - it('2D float32 dtype', async () => { - const a = tf.zeros([3, 2], 'float32'); - expect(a.dtype).toBe('float32'); - expect(a.shape).toEqual([3, 2]); - expectArraysClose(await a.data(), [0, 0, 0, 0, 0, 0]); - }); - - it('2D int32 dtype', async () => { - const a = tf.zeros([3, 2], 'int32'); - expect(a.dtype).toBe('int32'); - expect(a.shape).toEqual([3, 2]); - expectArraysEqual(await a.data(), [0, 0, 0, 0, 0, 0]); - }); - - it('2D bool dtype', async () => { - const a = tf.zeros([3, 2], 'bool'); - expect(a.dtype).toBe('bool'); - expect(a.shape).toEqual([3, 2]); - expectArraysEqual(await a.data(), [0, 0, 0, 0, 0, 0]); - }); - - it('3D default dtype', async () => { - const a = tf.zeros([2, 2, 2]); - expect(a.dtype).toBe('float32'); - expect(a.shape).toEqual([2, 2, 2]); - expectArraysClose(await a.data(), [0, 0, 0, 0, 0, 0, 0, 0]); - }); - - it('3D float32 dtype', async () => { - const a = tf.zeros([2, 2, 2], 'float32'); - expect(a.dtype).toBe('float32'); - expect(a.shape).toEqual([2, 2, 2]); - expectArraysClose(await a.data(), [0, 0, 0, 0, 0, 0, 0, 0]); - }); - - it('3D int32 dtype', async () => { - const a = tf.zeros([2, 2, 2], 'int32'); - expect(a.dtype).toBe('int32'); - expect(a.shape).toEqual([2, 2, 2]); - expectArraysEqual(await a.data(), [0, 0, 0, 0, 0, 0, 0, 0]); - }); - - it('3D bool dtype', async () => { - const a = tf.zeros([2, 2, 2], 'bool'); - expect(a.dtype).toBe('bool'); - expect(a.shape).toEqual([2, 2, 2]); - expectArraysEqual(await a.data(), [0, 0, 0, 0, 0, 0, 0, 0]); - }); - - it('4D default dtype', async () => { - const a = tf.zeros([3, 2, 1, 1]); - expect(a.dtype).toBe('float32'); - expect(a.shape).toEqual([3, 2, 1, 1]); - expectArraysClose(await a.data(), [0, 0, 0, 0, 0, 0]); - }); - - it('4D float32 dtype', async () => { - const a = tf.zeros([3, 2, 1, 1], 'float32'); - expect(a.dtype).toBe('float32'); - expect(a.shape).toEqual([3, 2, 1, 1]); - expectArraysClose(await a.data(), [0, 0, 0, 0, 0, 0]); - }); - - it('4D int32 dtype', async () => { - const a = tf.zeros([3, 2, 1, 1], 'int32'); - expect(a.dtype).toBe('int32'); - expect(a.shape).toEqual([3, 2, 1, 1]); - expectArraysEqual(await a.data(), [0, 0, 0, 0, 0, 0]); - }); - - it('4D bool dtype', async () => { - const a = tf.zeros([3, 2, 1, 1], 'bool'); - expect(a.dtype).toBe('bool'); - expect(a.shape).toEqual([3, 2, 1, 1]); - expectArraysEqual(await a.data(), [0, 0, 0, 0, 0, 0]); - }); - - it('should throw error when shape is not integer', () => { - expect(() => tf.zeros([2, 2.22, 3.33])).toThrow(); - }); -}); diff --git a/tfjs-master/tfjs-core/src/optimizers/adadelta_optimizer.ts b/tfjs-master/tfjs-core/src/optimizers/adadelta_optimizer.ts deleted file mode 100644 index eb4c5e423..000000000 --- a/tfjs-master/tfjs-core/src/optimizers/adadelta_optimizer.ts +++ /dev/null @@ -1,154 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {dispose, tidy} from '../globals'; -import {add} from '../ops/add'; -import {div} from '../ops/div'; -import {mul} from '../ops/mul'; -import {sqrt} from '../ops/ops'; -import {square} from '../ops/square'; -import {zerosLike} from '../ops/zeros_like'; -import {ConfigDict, Serializable, SerializableConstructor} from '../serialization'; -import {NamedTensor, NamedVariableMap} from '../tensor_types'; - -import {Optimizer, OptimizerVariable} from './optimizer'; - -/** @doclink Optimizer */ -export class AdadeltaOptimizer extends Optimizer { - /** @nocollapse */ - static get className() { - // Name matters for Python compatibility. - // This is a getter instead of a property because when it's a property, it - // prevents the entire class from being tree-shaken. - return 'Adadelta'; - } - private accumulatedGrads: OptimizerVariable[] = []; - private accumulatedUpdates: OptimizerVariable[] = []; - - constructor( - protected learningRate: number, protected rho: number, - protected epsilon: number = null) { - super(); - - if (epsilon == null) { - this.epsilon = ENGINE.backend.epsilon(); - } - } - - applyGradients(variableGradients: NamedVariableMap|NamedTensor[]) { - const variableNames = Array.isArray(variableGradients) ? - variableGradients.map(item => item.name) : - Object.keys(variableGradients); - - variableNames.forEach((name, i) => { - const value = ENGINE.registeredVariables[name]; - const trainable = false; - if (this.accumulatedGrads[i] == null) { - this.accumulatedGrads[i] = { - originalName: `${name}/accum_grad`, - variable: tidy(() => zerosLike(value).variable(trainable)) - }; - } - if (this.accumulatedUpdates[i] == null) { - this.accumulatedUpdates[i] = { - originalName: `${name}/accum_var`, - variable: tidy(() => zerosLike(value).variable(trainable)) - }; - } - - const gradient = Array.isArray(variableGradients) ? - variableGradients[i].tensor : - variableGradients[name]; - if (gradient == null) { - return; - } - - const accumulatedGrad = this.accumulatedGrads[i].variable; - const accumulatedUpdate = this.accumulatedUpdates[i].variable; - - tidy(() => { - const newAccumulatedGrad = - add(mul(accumulatedGrad, this.rho), - mul(square(gradient), 1 - this.rho)); - - const updates = - mul(div(sqrt(add(accumulatedUpdate, this.epsilon)), - sqrt(add(accumulatedGrad, this.epsilon))), - gradient); - - const newAccumulatedUpdate = - add(mul(accumulatedUpdate, this.rho), - mul(square(updates), 1 - this.rho)); - - accumulatedGrad.assign(newAccumulatedGrad); - accumulatedUpdate.assign(newAccumulatedUpdate); - - const newValue = add(mul(updates, -this.learningRate), value); - value.assign(newValue); - }); - }); - this.incrementIterations(); - } - - override dispose(): void { - if (this.accumulatedUpdates != null) { - dispose(this.accumulatedGrads.map(v => v.variable)); - dispose(this.accumulatedUpdates.map(v => v.variable)); - } - } - - override async getWeights(): Promise { - // Order matters for Python compatibility. - const variables: OptimizerVariable[] = - [...this.accumulatedGrads, ...this.accumulatedUpdates]; - return [await this.saveIterations()].concat( - variables.map(v => ({name: v.originalName, tensor: v.variable}))); - } - - override async setWeights(weightValues: NamedTensor[]): Promise { - weightValues = await this.extractIterations(weightValues); - const variableCount = weightValues.length / 2; - const trainable = false; - this.accumulatedGrads = - weightValues.slice(0, variableCount).map(v => ({ - originalName: v.name, - variable: v.tensor.variable( - trainable) - })); - this.accumulatedUpdates = - weightValues.slice(variableCount, variableCount * 2) - .map(v => ({ - originalName: v.name, - variable: v.tensor.variable(trainable) - })); - } - - getConfig(): ConfigDict { - return { - 'learningRate': this.learningRate, - 'rho': this.rho, - 'epsilon': this.epsilon - }; - } - - /** @nocollapse */ - static override fromConfig( - cls: SerializableConstructor, config: ConfigDict): T { - return new cls(config['learningRate'], config['rho'], config['epsilon']); - } -} diff --git a/tfjs-master/tfjs-core/src/optimizers/adadelta_optimizer_test.ts b/tfjs-master/tfjs-core/src/optimizers/adadelta_optimizer_test.ts deleted file mode 100644 index d66c09607..000000000 --- a/tfjs-master/tfjs-core/src/optimizers/adadelta_optimizer_test.ts +++ /dev/null @@ -1,111 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('AdadeltaOptimizer', ALL_ENVS, () => { - it('basic', async () => { - const initialTensors = tf.memory().numTensors; - const learningRate = .1; - const rho = .95; - const optimizer = tf.train.adadelta(learningRate, rho); - - const x = tf.tensor1d([1, 2]).variable(); - - const f: () => tf.Scalar = () => x.square().sum(); - - let numTensors = tf.memory().numTensors; - - let cost = optimizer.minimize(f, /* returnCost */ true); - - // Cost & 2 accumulators should be the only additional arrays. - expect(tf.memory().numTensors).toBe(numTensors + 3); - - // epsilon = 1-e8 - // newAccumulatedGrad = rho * accumulatedGrad + (1 - rho) * grad ^ 2 - // updates = -grad * sqrt(accumulatedUpdate + epsilon) / - // sqrt(accumulatedGrad + epsilon) - // newAccumulatedUpdate = rho * accumulatedUpdate + (1 - rho) * updates ^ 2 - // x += learningRate * updates - // - // de/dx = [2, 4] - // accumulatedGrad = [0, 0] - // newAccumulatedGrad = [.2, .8] - // updates = [-2, -4] - // newAccumulatedUpdate = [.2, .8] - // x = [0.8, 1.6] - expectArraysClose(await x.data(), [0.8, 1.6]); - - cost.dispose(); - numTensors = tf.memory().numTensors; - - cost = optimizer.minimize(f, /* returnCost */ false); - - // de/dx = [1.6, 3.2] - // accumulatedGrad = [.2, .8] - // accumulatedUpdate = [.2, .8] - // newAccumulatedGrad = [0.318, 1.272] - // updates = [-1.6, -3.2] - // x = [0.64, 1.28] - expectArraysClose(await x.data(), [0.64, 1.28]); - - // There should be no new additional Tensors. - expect(tf.memory().numTensors).toBe(numTensors); - - expect(cost).toBe(null); - - x.dispose(); - optimizer.dispose(); - - // The only additional tensor remaining is the argument to variable(). - expect(tf.memory().numTensors).toBe(initialTensors + 1); - }); - - it('Save, load weights and continue training', async () => { - const learningRate = .1; - const rho = .95; - const optimizer1 = tf.train.adadelta(learningRate, rho); - - const x = tf.tensor1d([1, 2]).variable(); - const f: () => tf.Scalar = () => x.square().sum(); - - let cost = optimizer1.minimize(f, /* returnCost */ true); - expectArraysClose(await cost.data(), 5); - expectArraysClose(await x.data(), [0.8, 1.6]); - - const weights = await optimizer1.getWeights(); - expect(weights.length).toEqual(3); - expect(weights[0].name).toEqual('iter'); - - const optimizer2 = tf.train.adadelta(learningRate, rho); - await optimizer2.setWeights(weights); - - cost = optimizer2.minimize(f, /* returnCost */ true); - expectArraysClose(await cost.data(), 3.2); - expectArraysClose(await x.data(), [0.64, 1.28]); - expect(optimizer2.iterations).toEqual(2); - }); - - it('serialization round-trip', () => { - const originalOpt = tf.train.adadelta(0.1, 0.2, 2e-8); - const reserialized = tf.AdadeltaOptimizer.fromConfig( - tf.AdadeltaOptimizer, originalOpt.getConfig()); - expect(reserialized.getConfig()).toEqual(originalOpt.getConfig()); - }); -}); diff --git a/tfjs-master/tfjs-core/src/optimizers/adagrad_optimizer.ts b/tfjs-master/tfjs-core/src/optimizers/adagrad_optimizer.ts deleted file mode 100644 index 393f51143..000000000 --- a/tfjs-master/tfjs-core/src/optimizers/adagrad_optimizer.ts +++ /dev/null @@ -1,120 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {dispose, tidy} from '../globals'; -import {add} from '../ops/add'; -import {div} from '../ops/div'; -import {fill} from '../ops/fill'; -import {mul} from '../ops/mul'; -import {sqrt} from '../ops/sqrt'; -import {square} from '../ops/square'; -import {ConfigDict, Serializable, SerializableConstructor} from '../serialization'; -import {NamedTensor, NamedVariableMap} from '../tensor_types'; - -import {Optimizer, OptimizerVariable} from './optimizer'; - -/** @doclink Optimizer */ -export class AdagradOptimizer extends Optimizer { - /** @nocollapse */ - static get className() { - // Name matters for Python compatibility. - // This is a getter instead of a property because when it's a property, it - // prevents the entire class from being tree-shaken. - return 'Adagrad'; - } - - private accumulatedGrads: OptimizerVariable[] = []; - - constructor( - protected learningRate: number, private initialAccumulatorValue = 0.1) { - super(); - } - - applyGradients(variableGradients: NamedVariableMap|NamedTensor[]) { - const variableNames = Array.isArray(variableGradients) ? - variableGradients.map(item => item.name) : - Object.keys(variableGradients); - - variableNames.forEach((name, i) => { - const value = ENGINE.registeredVariables[name]; - if (this.accumulatedGrads[i] == null) { - const trainable = false; - this.accumulatedGrads[i] = { - originalName: `${name}/accumulator`, - variable: tidy( - () => fill(value.shape, this.initialAccumulatorValue) - .variable(trainable)) - }; - } - - const gradient = Array.isArray(variableGradients) ? - variableGradients[i].tensor : - variableGradients[name]; - if (gradient == null) { - return; - } - - const accumulatedGrad = this.accumulatedGrads[i].variable; - - tidy(() => { - const newAccumulatedGrad = add(accumulatedGrad, square(gradient)); - accumulatedGrad.assign(newAccumulatedGrad); - - const newValue = add( - mul(div(gradient, - sqrt(add(newAccumulatedGrad, ENGINE.backend.epsilon()))), - -this.learningRate), - value); - value.assign(newValue); - }); - }); - this.incrementIterations(); - } - - override dispose(): void { - if (this.accumulatedGrads != null) { - dispose(this.accumulatedGrads.map(v => v.variable)); - } - } - - override async getWeights(): Promise { - // Order matters for Python compatibility. - return [await this.saveIterations()].concat(this.accumulatedGrads.map( - v => ({name: v.originalName, tensor: v.variable}))); - } - - override async setWeights(weightValues: NamedTensor[]): Promise { - weightValues = await this.extractIterations(weightValues); - const trainable = false; - this.accumulatedGrads = weightValues.map( - v => ({originalName: v.name, variable: v.tensor.variable(trainable)})); - } - - getConfig(): ConfigDict { - return { - 'learningRate': this.learningRate, - 'initialAccumulatorValue': this.initialAccumulatorValue, - }; - } - - /** @nocollapse */ - static override fromConfig( - cls: SerializableConstructor, config: ConfigDict): T { - return new cls(config['learningRate'], config['initialAccumulatorValue']); - } -} diff --git a/tfjs-master/tfjs-core/src/optimizers/adagrad_optimizer_test.ts b/tfjs-master/tfjs-core/src/optimizers/adagrad_optimizer_test.ts deleted file mode 100644 index fbe213a28..000000000 --- a/tfjs-master/tfjs-core/src/optimizers/adagrad_optimizer_test.ts +++ /dev/null @@ -1,103 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('AdagradOptimizer', ALL_ENVS, () => { - it('basic', async () => { - const initialTensors = tf.memory().numTensors; - const learningRate = .1; - const initialAccumulatorValue = .1; - const optimizer = tf.train.adagrad(learningRate, initialAccumulatorValue); - - const x = tf.tensor1d([1, 2]).variable(); - - const f: () => tf.Scalar = () => x.square().sum(); - - let numTensors = tf.memory().numTensors; - - let cost = optimizer.minimize(f, /* returnCost */ true); - - // Cost & accumulator should be the only additional arrays. - expect(tf.memory().numTensors).toBe(numTensors + 2); - - // epsilon = 1-e8 - // newAccumulatedGrad = accumulatedGrad + grad^2 - // x -= (learningRate * grad) / sqrt(newAccumulatedGrad + eps) - // de/dx = [2, 4] - // accumulatedGrad = [0.1, 0.1] - // newAccumulatedGrad = [4.1, 16.1] - // x = [0.9012270405, 1.900311042] - expectArraysClose(await x.data(), [0.9012270405, 1.9003110428]); - - cost.dispose(); - numTensors = tf.memory().numTensors; - - cost = optimizer.minimize(f, /* returnCost */ false); - - // de/dx = [1.802454081, 3.9501555214] - // accumulatedGrad = [4.1, 16.1] - // newAccumulatedGrad = [7.3488407141, 31.7037286432] - // x = [0.8347372764, 1.83015597828] - - // TODO: Fix numerical precision. - expectArraysClose(await x.data(), [0.8347372764, 1.83015597828], 1e-2); - - // There should be no new additional Tensors. - expect(tf.memory().numTensors).toBe(numTensors); - - expect(cost).toBe(null); - - x.dispose(); - optimizer.dispose(); - - // The only additional tensor remaining is the argument to variable(). - expect(tf.memory().numTensors).toBe(initialTensors + 1); - }); - - it('Continue training after loading weights', async () => { - const learningRate = .1; - const initialAccumulatorValue = .1; - const optimizer1 = tf.train.adagrad(learningRate, initialAccumulatorValue); - - const x = tf.tensor1d([2, 4]).variable(); - const f: () => tf.Scalar = () => x.square().sum(); - let cost = optimizer1.minimize(f, /* returnCost */ true); - expectArraysClose(await cost.data(), 20); - - const weights = await optimizer1.getWeights(); - expect(weights.length).toEqual(2); - expect(weights[0].name).toEqual('iter'); - expect(weights[1].name).toEqual(`${x.name}/accumulator`); - - const optimizer2 = tf.train.adam(learningRate, initialAccumulatorValue); - await optimizer2.setWeights(weights); - - cost = optimizer2.minimize(f, /* returnCost */ true); - expectArraysClose(await cost.data(), 18.82179); - expect(optimizer2.iterations).toEqual(2); - }); - - it('serialization round-trip', () => { - const originalOpt = tf.train.adagrad(0.1, 0.2); - const reserialized = tf.AdagradOptimizer.fromConfig( - tf.AdagradOptimizer, originalOpt.getConfig()); - expect(reserialized.getConfig()).toEqual(originalOpt.getConfig()); - }); -}); diff --git a/tfjs-master/tfjs-core/src/optimizers/adam_optimizer.ts b/tfjs-master/tfjs-core/src/optimizers/adam_optimizer.ts deleted file mode 100644 index ad43b432f..000000000 --- a/tfjs-master/tfjs-core/src/optimizers/adam_optimizer.ts +++ /dev/null @@ -1,184 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {dispose, tidy} from '../globals'; -import {add} from '../ops/add'; -import {div} from '../ops/div'; -import {mul} from '../ops/mul'; -import {pow} from '../ops/pow'; -import {scalar} from '../ops/scalar'; -import {sqrt} from '../ops/sqrt'; -import {square} from '../ops/square'; -import {sub} from '../ops/sub'; -import {zerosLike} from '../ops/zeros_like'; -import {ConfigDict, Serializable, SerializableConstructor} from '../serialization'; -import {Variable} from '../tensor'; -import {NamedTensor, NamedVariableMap} from '../tensor_types'; - -import {Optimizer, OptimizerVariable} from './optimizer'; - -export class AdamOptimizer extends Optimizer { - /** @nocollapse */ - static get className() { - // Name matters for Python compatibility. - // This is a getter instead of a property because when it's a property, it - // prevents the entire class from being tree-shaken. - return 'Adam'; - } - private accBeta1: Variable; - private accBeta2: Variable; - - private accumulatedFirstMoment: OptimizerVariable[] = []; - private accumulatedSecondMoment: OptimizerVariable[] = []; - - constructor( - protected learningRate: number, protected beta1: number, - protected beta2: number, protected epsilon: number = null) { - super(); - tidy(() => { - // accB* will be updated by batch. - this.accBeta1 = scalar(beta1).variable(); - this.accBeta2 = scalar(beta2).variable(); - }); - - if (epsilon == null) { - this.epsilon = ENGINE.backend.epsilon(); - } - } - - applyGradients(variableGradients: NamedVariableMap|NamedTensor[]) { - const varNames = Array.isArray(variableGradients) ? - variableGradients.map(v => v.name) : - Object.keys(variableGradients); - tidy(() => { - const oneMinusAccBeta1 = sub(1, this.accBeta1); - const oneMinusAccBeta2 = sub(1, this.accBeta2); - - varNames.forEach((name, i) => { - const value = ENGINE.registeredVariables[name]; - const trainable = false; - if (this.accumulatedFirstMoment[i] == null) { - this.accumulatedFirstMoment[i] = { - originalName: `${name}/m`, - variable: tidy(() => zerosLike(value).variable(trainable)) - }; - } - if (this.accumulatedSecondMoment[i] == null) { - this.accumulatedSecondMoment[i] = { - originalName: `${name}/v`, - variable: tidy(() => zerosLike(value).variable(trainable)) - }; - } - - const gradient = Array.isArray(variableGradients) ? - variableGradients[i].tensor : - variableGradients[name]; - if (gradient == null) { - return; - } - - const firstMoment = this.accumulatedFirstMoment[i].variable; - const secondMoment = this.accumulatedSecondMoment[i].variable; - - const newFirstMoment = - add(mul(firstMoment, this.beta1), mul(gradient, 1 - this.beta1)); - const newSecondMoment = - add(mul(secondMoment, this.beta2), - mul(square(gradient), 1 - this.beta2)); - - const biasCorrectedFirstMoment = div(newFirstMoment, oneMinusAccBeta1); - const biasCorrectedSecondMoment = - div(newSecondMoment, oneMinusAccBeta2); - - firstMoment.assign(newFirstMoment); - secondMoment.assign(newSecondMoment); - - const newValue = - add(mul(div(biasCorrectedFirstMoment, - add(sqrt(biasCorrectedSecondMoment), this.epsilon)), - -this.learningRate), - value); - value.assign(newValue); - }); - - this.accBeta1.assign(mul(this.accBeta1, this.beta1)); - this.accBeta2.assign(mul(this.accBeta2, this.beta2)); - }); - this.incrementIterations(); - } - - override dispose(): void { - this.accBeta1.dispose(); - this.accBeta2.dispose(); - - if (this.accumulatedFirstMoment != null) { - dispose(this.accumulatedFirstMoment.map(v => v.variable)); - } - if (this.accumulatedSecondMoment != null) { - dispose(this.accumulatedSecondMoment.map(v => v.variable)); - } - } - - override async getWeights(): Promise { - // Order matters for Python compatibility. - const variables: OptimizerVariable[] = - [...this.accumulatedFirstMoment, ...this.accumulatedSecondMoment]; - return [await this.saveIterations()].concat( - variables.map(v => ({name: v.originalName, tensor: v.variable}))); - } - - override async setWeights(weightValues: NamedTensor[]): Promise { - weightValues = await this.extractIterations(weightValues); - tidy(() => { - this.accBeta1.assign(pow(this.beta1, this.iterations_ + 1)); - this.accBeta2.assign(pow(this.beta2, this.iterations_ + 1)); - }); - - const variableCount = weightValues.length / 2; - const trainable = false; - this.accumulatedFirstMoment = - weightValues.slice(0, variableCount).map(v => ({ - originalName: v.name, - variable: v.tensor.variable( - trainable) - })); - this.accumulatedSecondMoment = - weightValues.slice(variableCount, variableCount * 2) - .map(v => ({ - originalName: v.name, - variable: v.tensor.variable(trainable) - })); - } - - getConfig(): ConfigDict { - return { - 'learningRate': this.learningRate, - 'beta1': this.beta1, - 'beta2': this.beta2, - 'epsilon': this.epsilon, - }; - } - - /** @nocollapse */ - static override fromConfig( - cls: SerializableConstructor, config: ConfigDict): T { - return new cls( - config['learningRate'], config['beta1'], config['beta2'], - config['epsilon']); - } -} diff --git a/tfjs-master/tfjs-core/src/optimizers/adam_optimizer_test.ts b/tfjs-master/tfjs-core/src/optimizers/adam_optimizer_test.ts deleted file mode 100644 index 89f6252e9..000000000 --- a/tfjs-master/tfjs-core/src/optimizers/adam_optimizer_test.ts +++ /dev/null @@ -1,124 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('AdamOptimizer', ALL_ENVS, () => { - it('basic', async () => { - const initialTensors = tf.memory().numTensors; - const learningRate = .1; - const beta1 = .8; - const beta2 = .9; - const optimizer = tf.train.adam(learningRate, beta1, beta2); - - const x = tf.tensor1d([2, 4]).variable(); - - const f: () => tf.Scalar = () => x.square().sum(); - - let numTensors = tf.memory().numTensors; - - let cost = optimizer.minimize(f, /* returnCost */ true); - - // Cost & 2 accumulators should be the only additional arrays. - expect(tf.memory().numTensors).toBe(numTensors + 3); - // new_first_m = [ - // beta1 * old_first_m_w1 + (1-beta1) * grad_w1, - // beta1 * old_first_m_w2 + (1-beta1) * grad_w2 - // ] = [.8, 1.6] - // new_second_m = [ - // beta2 * old_second_m_w1 + (1-beta2) * grad_w1**2, - // beta2 * old_second_m_w2 + (1-beta2) * grad_w2**2 - // ] = [1.6, 6.4] - // m = [new_first_m/(1-acc_beta1)] = [4, 8] - // v = [new_second_m/(1-acc_beta2)] = [16, 64] - // x = [x - lr * m / sqrt(v)] = [1.9, 3.9] - // - expectArraysClose(await x.data(), [1.9, 3.9]); - - cost.dispose(); - numTensors = tf.memory().numTensors; - - cost = optimizer.minimize(f, /* returnCost */ false); - - // new_first_m = [ - // beta1 * old_first_m_w1 + (1-beta1) * grad_w1, - // beta1 * old_first_m_w2 + (1-beta1) * grad_w2 - // ] = [1.4, 2.84] - // new_second_m = [ - // beta2 * old_second_m_w1 + (1-beta2) * grad_w1**2, - // beta2 * old_second_m_w2 + (1-beta2) * grad_w2**2 - // ] = [2.884, 11.884] - // m = [new_first_m/(1-acc_beta1)] = [3.888888, 7.88889] - // v = [new_second_m/(1-acc_beta2)] = [15.1789, 62.5473] - // x = [x - lr * m / sqrt(v)] = [1.8000001, 3.8002] - // - expectArraysClose(await x.data(), [1.8000001, 3.8002]); - // There should be no new additional Tensors. - expect(tf.memory().numTensors).toBe(numTensors); - - expect(cost).toBe(null); - - x.dispose(); - optimizer.dispose(); - - // The only additional tensor remaining should be the argument to - // variable(). - expect(tf.memory().numTensors).toBe(initialTensors + 1); - }); - - it('Continue training after loading weights', async () => { - const initialTensors = tf.memory().numTensors; - const learningRate = .1; - const beta1 = .8; - const beta2 = .9; - const optimizer1 = tf.train.adam(learningRate, beta1, beta2); - - const x = tf.tensor1d([2, 4]).variable(); - const f: () => tf.Scalar = () => x.square().sum(); - let cost = optimizer1.minimize(f, /* returnCost */ true); - expect(optimizer1.iterations).toEqual(1); - expectArraysClose(await cost.data(), 20); - - const weights = await optimizer1.getWeights(); - expect(weights.length).toEqual(3); - expect(weights[0].name).toEqual('iter'); - expect(weights[1].name).toEqual(`${x.name}/m`); - expect(weights[2].name).toEqual(`${x.name}/v`); - - const optimizer2 = tf.train.adam(learningRate, beta1, beta2); - await optimizer2.setWeights(weights); - - cost = optimizer2.minimize(f, /* returnCost */ true); - expectArraysClose(await cost.data(), 18.82); - expect(optimizer2.iterations).toEqual(2); - - const optimizer3 = tf.train.adam(learningRate, beta1, beta2); - await optimizer3.setWeights(await optimizer2.getWeights()); - cost = optimizer2.minimize(f, /* returnCost */ true); - expectArraysClose(await cost.data(), 17.681284); - expect(optimizer3.iterations).toEqual(initialTensors + 2); - }); - - it('serialization round-trip', () => { - const originalOpt = tf.train.adam(0.1, 0.2, 0.3, 2e-8); - const reserialized = - tf.AdamOptimizer.fromConfig(tf.AdamOptimizer, originalOpt.getConfig()); - expect(reserialized.getConfig()).toEqual(originalOpt.getConfig()); - }); -}); diff --git a/tfjs-master/tfjs-core/src/optimizers/adamax_optimizer.ts b/tfjs-master/tfjs-core/src/optimizers/adamax_optimizer.ts deleted file mode 100644 index 0b9a80ae8..000000000 --- a/tfjs-master/tfjs-core/src/optimizers/adamax_optimizer.ts +++ /dev/null @@ -1,162 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {dispose, tidy} from '../globals'; -import {abs} from '../ops/abs'; -import {add} from '../ops/add'; -import {div} from '../ops/div'; -import {maximum} from '../ops/maximum'; -import {mul} from '../ops/mul'; -import {scalar} from '../ops/scalar'; -import {sub} from '../ops/sub'; -import {zerosLike} from '../ops/zeros_like'; -import {ConfigDict, Serializable, SerializableConstructor} from '../serialization'; -import {Variable} from '../tensor'; -import {NamedTensor, NamedVariableMap} from '../tensor_types'; - -import {Optimizer, OptimizerVariable} from './optimizer'; - -export class AdamaxOptimizer extends Optimizer { - /** @nocollapse */ - static get className() { - // Name matters for Python compatibility. - // This is a getter instead of a property because when it's a property, it - // prevents the entire class from being tree-shaken. - return 'Adamax'; - } - private accBeta1: Variable; - private iteration: Variable; - - private accumulatedFirstMoment: OptimizerVariable[] = []; - private accumulatedWeightedInfNorm: OptimizerVariable[] = []; - - constructor( - protected learningRate: number, protected beta1: number, - protected beta2: number, protected epsilon: number = null, - protected decay = 0.0) { - super(); - - tidy(() => { - this.iteration = scalar(0).variable(); - this.accBeta1 = scalar(beta1).variable(); - }); - - if (epsilon == null) { - this.epsilon = ENGINE.backend.epsilon(); - } - } - - applyGradients(variableGradients: NamedVariableMap|NamedTensor[]) { - const variableNames = Array.isArray(variableGradients) ? - variableGradients.map(item => item.name) : - Object.keys(variableGradients); - - tidy(() => { - const oneMinusAccBeta1 = sub(1, this.accBeta1); - const lr = - div(-this.learningRate, add(mul(this.iteration, this.decay), 1)); - - variableNames.forEach((name, i) => { - const value = ENGINE.registeredVariables[name]; - const trainable = false; - if (this.accumulatedFirstMoment[i] == null) { - this.accumulatedFirstMoment[i] = { - originalName: `${name}/m`, - variable: zerosLike(value).variable(trainable) - }; - } - if (this.accumulatedWeightedInfNorm[i] == null) { - this.accumulatedWeightedInfNorm[i] = { - originalName: `${name}/v`, - variable: zerosLike(value).variable(trainable) - }; - } - - const gradient = Array.isArray(variableGradients) ? - variableGradients[i].tensor : - variableGradients[name]; - if (gradient == null) { - return; - } - - const firstMoment = this.accumulatedFirstMoment[i].variable; - const weightedInfNorm = this.accumulatedWeightedInfNorm[i].variable; - - const newFirstMoment = - add(mul(firstMoment, this.beta1), mul(gradient, 1 - this.beta1)); - - const ut0 = mul(weightedInfNorm, this.beta2); - const ut1 = abs(gradient); - - const newWeightedInfNorm = maximum(ut0, ut1); - - firstMoment.assign(newFirstMoment); - weightedInfNorm.assign(newWeightedInfNorm); - - const newValue = - add(mul(div(lr, oneMinusAccBeta1), - div(newFirstMoment, add(newWeightedInfNorm, this.epsilon))), - value); - - value.assign(newValue); - }); - - this.iteration.assign(add(this.iteration, 1)); - this.accBeta1.assign(mul(this.accBeta1, this.beta1)); - }); - this.incrementIterations(); - } - - override dispose(): void { - this.accBeta1.dispose(); - this.iteration.dispose(); - - if (this.accumulatedFirstMoment != null) { - dispose(this.accumulatedFirstMoment.map(v => v.variable)); - } - if (this.accumulatedWeightedInfNorm != null) { - dispose(this.accumulatedWeightedInfNorm.map(v => v.variable)); - } - } - - override async getWeights(): Promise { - throw new Error('getWeights() is not implemented for Adamax yet.'); - } - - override async setWeights(weightValues: NamedTensor[]): Promise { - throw new Error('setWeights() is not implemented for Adamax yet.'); - } - - getConfig(): ConfigDict { - return { - 'learningRate': this.learningRate, - 'beta1': this.beta1, - 'beta2': this.beta2, - 'epsilon': this.epsilon, - 'decay': this.decay - }; - } - - /** @nocollapse */ - static override fromConfig( - cls: SerializableConstructor, config: ConfigDict): T { - return new cls( - config['learningRate'], config['beta1'], config['beta2'], - config['epsilon'], config['decay']); - } -} diff --git a/tfjs-master/tfjs-core/src/optimizers/adamax_optimizer_test.ts b/tfjs-master/tfjs-core/src/optimizers/adamax_optimizer_test.ts deleted file mode 100644 index 182a7a64e..000000000 --- a/tfjs-master/tfjs-core/src/optimizers/adamax_optimizer_test.ts +++ /dev/null @@ -1,122 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('AdamaxOptimizer', ALL_ENVS, () => { - it('basic', async () => { - const initialTensors = tf.memory().numTensors; - const learningRate = 0.1; - const beta1 = 0.8; - const beta2 = 0.9; - const decay = 0.1; - const optimizer = - tf.train.adamax(learningRate, beta1, beta2, undefined, decay); - - const x = tf.tensor1d([2, 4]).variable(); - - const f: () => tf.Scalar = () => x.square().sum(); - - let numTensors = tf.memory().numTensors; - - let cost = optimizer.minimize(f, /* returnCost */ true); - - // Cost & 2 accumulators should be the only additional arrays. - expect(tf.memory().numTensors).toBe(numTensors + 3); - // new_first_m = [ - // beta1 * old_first_m_w1 + (1-beta1) * grad_w1, - // beta1 * old_first_m_w2 + (1-beta1) * grad_w2 - // ] = [.8, 1.6] - // - // ut_0 = beta2 * old_weighted_inf_norm = [0, 0] - // u1_1 = [ - // abs(grad_w1), - // abs(grad_w2) - // ] = [4, 8] - // new_weighted_inf_norm = max(ut_0, ut_1) = [4, 8] - // - // coefficient = alpha / (1-beta1) = 0.5 - // updates = coefficient * [ - // new_first_m1 / new_weighted_inf_norm1, - // new_first_m2 / new_weighted_inf_norm2 - // ] = [0.1, 0.1] - // w = [ - // w1_old - updates_1, - // w2_old - updates_2 - // ] = [1.9, 3.9] - // - expectArraysClose(await x.data(), [1.9, 3.9]); - - cost.dispose(); - numTensors = tf.memory().numTensors; - - cost = optimizer.minimize(f, /* returnCost */ false); - - // gradient = [3.8, 7.8] - // new_first_m = [ - // beta1 * old_first_m_w1 + (1-beta1) * grad_w1, - // beta1 * old_first_m_w2 + (1-beta1) * grad_w2 - // ] = [ - // 0.8 * 0.8 + 0.2 * 3.8, - // 0.8 * 1.6 + 0.2 * 7.8 - // ] = [1.4, 2.84] - // - // ut_0 = beta2 * old_weighted_inf_norm = [ - // 0.9 * 4, - // 0.9 * 8 - // ] = [3.6, 7.2] - // u1_1 = [ - // abs(grad_w1), - // abs(grad_w2) - // ] = [3.8, 7.8] - // new_weighted_inf_norm = max(ut_0, ut_1) = [3.8, 7.8] - // - // alpha = 0.1 / (1 + 0.1 * 1) = 0.0909090909 - // - // coefficient = alpha / (1 - beta1*beta1) = 0.25252525 - // updates = coefficient * [ - // new_first_m1 / new_weighted_inf_norm1, - // new_first_m2 / new_weighted_inf_norm2 - // ] = [0.09303, 0.09194] - // w = [ - // w1_old - updates_1, - // w2_old - updates_2 - // ] = [1.80697, 3.8086] - // - expectArraysClose(await x.data(), [1.80697, 3.8086]); - // There should be no new additional Tensors. - expect(tf.memory().numTensors).toBe(numTensors); - - expect(cost).toBe(null); - - x.dispose(); - optimizer.dispose(); - - // The only additional tensor remaining should be the argument to - // variable(). - expect(tf.memory().numTensors).toBe(initialTensors + 1); - }); - - it('serialization round-trip', () => { - const originalOpt = tf.train.adamax(0.1, 0.2, 0.3, 2e-8, 0.1); - const reserialized = tf.AdamaxOptimizer.fromConfig( - tf.AdamaxOptimizer, originalOpt.getConfig()); - expect(reserialized.getConfig()).toEqual(originalOpt.getConfig()); - }); -}); diff --git a/tfjs-master/tfjs-core/src/optimizers/momentum_optimizer.ts b/tfjs-master/tfjs-core/src/optimizers/momentum_optimizer.ts deleted file mode 100644 index 4ed161575..000000000 --- a/tfjs-master/tfjs-core/src/optimizers/momentum_optimizer.ts +++ /dev/null @@ -1,133 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {dispose, tidy} from '../globals'; -import {add} from '../ops/add'; -import {mul} from '../ops/mul'; -import {scalar} from '../ops/scalar'; -import {zerosLike} from '../ops/zeros_like'; -import {ConfigDict, Serializable, SerializableConstructor} from '../serialization'; -import {Scalar, Tensor} from '../tensor'; -import {NamedTensor, NamedVariableMap} from '../tensor_types'; - -import {OptimizerVariable} from './optimizer'; -import {SGDOptimizer} from './sgd_optimizer'; - -/** @doclink Optimizer */ -export class MomentumOptimizer extends SGDOptimizer { - /** @nocollapse */ - // Name matters for Python compatibility. - static override get className() { - // Name matters for Python compatibility. - // This is a getter instead of a property because when it's a property, it - // prevents the entire class from being tree-shaken. - return 'Momentum'; - } - private m: Scalar; - private accumulations: OptimizerVariable[] = []; - - constructor( - protected override learningRate: number, private momentum: number, - private useNesterov = false) { - super(learningRate); - this.m = scalar(this.momentum); - } - - override applyGradients(variableGradients: NamedVariableMap|NamedTensor[]) { - const variableNames = Array.isArray(variableGradients) ? - variableGradients.map(item => item.name) : - Object.keys(variableGradients); - - variableNames.forEach((name, i) => { - const value = ENGINE.registeredVariables[name]; - if (this.accumulations[i] == null) { - const trainable = false; - this.accumulations[i] = { - originalName: `${name}/momentum`, - variable: tidy(() => zerosLike(value).variable(trainable)) - }; - } - - const accumulation = this.accumulations[i].variable; - const gradient = Array.isArray(variableGradients) ? - variableGradients[i].tensor : - variableGradients[name]; - if (gradient == null) { - return; - } - - tidy(() => { - let newValue: Tensor; - const newAccumulation = add(mul(this.m, accumulation), gradient); - if (this.useNesterov) { - newValue = add( - mul(this.c, add(gradient, mul(newAccumulation, this.m))), value); - } else { - newValue = add(mul(this.c, newAccumulation), value); - } - accumulation.assign(newAccumulation); - value.assign(newValue); - }); - }); - this.incrementIterations(); - } - - override dispose(): void { - this.m.dispose(); - if (this.accumulations != null) { - dispose(this.accumulations.map(v => v.variable)); - } - } - - /** - * Sets the momentum of the optimizer. - * - * @param momentum - */ - setMomentum(momentum: number) { - this.momentum = momentum; - } - - override async getWeights(): Promise { - // Order matters for Python compatibility. - return [await this.saveIterations()].concat(this.accumulations.map( - v => ({name: v.originalName, tensor: v.variable}))); - } - - override async setWeights(weightValues: NamedTensor[]): Promise { - weightValues = await this.extractIterations(weightValues); - const trainable = false; - this.accumulations = weightValues.map( - v => ({originalName: v.name, variable: v.tensor.variable(trainable)})); - } - - override getConfig(): ConfigDict { - return { - 'learningRate': this.learningRate, - 'momentum': this.momentum, - 'useNesterov': this.useNesterov - }; - } - - /** @nocollapse */ - static override fromConfig( - cls: SerializableConstructor, config: ConfigDict): T { - return new cls( - config['learningRate'], config['momentum'], config['useNesterov']); - } -} diff --git a/tfjs-master/tfjs-core/src/optimizers/momentum_optimizer_test.ts b/tfjs-master/tfjs-core/src/optimizers/momentum_optimizer_test.ts deleted file mode 100644 index 164751810..000000000 --- a/tfjs-master/tfjs-core/src/optimizers/momentum_optimizer_test.ts +++ /dev/null @@ -1,151 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('MomentumOptimizer', ALL_ENVS, () => { - it('basic', async () => { - const learningRate = .1; - const momentum = .5; - const optimizer = tf.train.momentum(learningRate, momentum); - - const x = tf.tensor1d([1, 2]).variable(); - - const f: () => tf.Scalar = () => x.square().sum(); - - let numTensors = tf.memory().numTensors; - - let cost = optimizer.minimize(f, /* returnCost */ true); - - // Cost & velocity should be the only additional arrays. - expect(tf.memory().numTensors).toBe(numTensors + 2); - - // newAccumulation = momentum * accumulation + gradient - // newVariable += -learningRate * newAccumulation + variable - // - // de/dx = [2, 4] - // newAccumulation = [2, 4] - // x = [.8, 1.6] - expectArraysClose(await x.data(), [.8, 1.6]); - - cost.dispose(); - numTensors = tf.memory().numTensors; - - cost = optimizer.minimize(f, /* returnCost */ false); - - // de/dx = [1.6, 3.2] - // accumulation = [2, 4] - // newAccumulation = [2.6, 5.2] - // x = [0.54, 1.08] - expectArraysClose(await x.data(), [0.54, 1.08]); - - // There should be no new additional Tensors. - expect(tf.memory().numTensors).toBe(numTensors); - - expect(cost).toBe(null); - - x.dispose(); - numTensors = tf.memory().numTensors; - optimizer.dispose(); - - // The optimizer.dispose() call should have disposed the m variable and the - // momentum variable for x. - expect(tf.memory().numTensors).toBe(numTensors - 2); - }); - - it('basic - with Nesterov', async () => { - const learningRate = .1; - const momentum = .5; - const useNesterov = true; - const optimizer = tf.train.momentum(learningRate, momentum, useNesterov); - - const x = tf.tensor1d([1, 2]).variable(); - - const f: () => tf.Scalar = () => x.square().sum(); - - let numTensors = tf.memory().numTensors; - - let cost = optimizer.minimize(f, /* returnCost */ true); - - // Cost and velocity should be the only additional arrays. - expect(tf.memory().numTensors).toBe(numTensors + 2); - - // newAccumulation = momentum * accumulation + gradient - // newVariable = -learningRate * (newAccumulation * momentum + gradient) + - // variable - // - // de/dx = [2, 4] - // newAccumulation = [2, 4] - // newVariable = -0.1 * ([2, 4] * 0.5 + [2, 4]) + [1, 2] - // x = [.7, 1.4] - expectArraysClose(await x.data(), [.7, 1.4]); - - cost.dispose(); - numTensors = tf.memory().numTensors; - - cost = optimizer.minimize(f, /* returnCost */ false); - - // de/dx = [1.4, 2.8] - // accumulation = [2, 4] - // newAccumulation = [0.5 * 2 + 1.4, 0.5 * 4 + 2.8] = [2.4, 4.8] - // newVariable = -0.1 * ([2.4, 4.8] * 0.5 + [1.4, 2.8]) + [0.7, 1.4] - // x = [0.44, 0.88] - expectArraysClose(await x.data(), [0.44, 0.88]); - - // There should be no new additional Tensors. - expect(tf.memory().numTensors).toBe(numTensors); - - expect(cost).toBe(null); - - x.dispose(); - numTensors = tf.memory().numTensors; - optimizer.dispose(); - - // The optimizer.dispose() call should have disposed the m variable and the - // momentum variable for x. - expect(tf.memory().numTensors).toBe(numTensors - 2); - }); - - it('Save, load weights and conntinue training', async () => { - const learningRate = .1; - const momentum = .5; - const useNesterov = true; - const optimizer1 = tf.train.momentum(learningRate, momentum, useNesterov); - - const x = tf.tensor1d([1, 2]).variable(); - const f: () => tf.Scalar = () => x.square().sum(); - - let cost = optimizer1.minimize(f, /* returnCost */ true); - - // The iterations counter and the accumulation for the variable x. - const optimizer2 = tf.train.momentum(learningRate, momentum, useNesterov); - await optimizer2.setWeights(await optimizer1.getWeights()); - cost = optimizer2.minimize(f, /* returnCost */ true); - expectArraysClose(await cost.data(), 2.45); - expectArraysClose(await x.data(), [0.44, 0.88]); - expect(optimizer2.iterations).toEqual(2); - }); - - it('serialization round-trip', () => { - const originalOpt = tf.train.momentum(0.1, 0.2, true); - const reserialized = tf.MomentumOptimizer.fromConfig( - tf.MomentumOptimizer, originalOpt.getConfig()); - expect(reserialized.getConfig()).toEqual(originalOpt.getConfig()); - }); -}); diff --git a/tfjs-master/tfjs-core/src/optimizers/optimizer.ts b/tfjs-master/tfjs-core/src/optimizers/optimizer.ts deleted file mode 100644 index dca3e1380..000000000 --- a/tfjs-master/tfjs-core/src/optimizers/optimizer.ts +++ /dev/null @@ -1,173 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {dispose} from '../globals'; -import {variableGrads} from '../gradients'; -import {scalar} from '../ops/ops'; -import {Serializable} from '../serialization'; -import {Scalar, Variable} from '../tensor'; -import {NamedTensor, NamedTensorMap} from '../tensor_types'; - -/** - * A variable that belongs to an optimizer. - * - * The `originalName` field is required for keeping track of the canonical - * name of the variable, which is usually the name of the model weight that - * the variable is related to plus a suffix, e.g., 'dense1/kernel/momentum'. - * The name of the `Variable` object itself cannot be used directly due to - * possible deduplication: Every `Variable` must have a unique name but more - * than one optimizer objects of the same type may be created for the same model - * or the same `Variable`. - */ -export interface OptimizerVariable { - originalName: string; - variable: Variable; -} - -/** @doc {heading: 'Training', subheading: 'Classes', namespace: 'train'} */ -export abstract class Optimizer extends Serializable { - protected iterations_: number; - - /** - * Executes `f()` and minimizes the scalar output of `f()` by computing - * gradients of y with respect to the list of trainable variables provided by - * `varList`. If no list is provided, it defaults to all trainable variables. - * - * @param f The function to execute and whose output to minimize. - * @param returnCost Whether to return the scalar cost value produced by - * executing `f()`. - * @param varList An optional list of variables to update. If specified, only - * the trainable variables in varList will be updated by minimize. Defaults to - * all trainable variables. - * - * @doc {heading: 'Training', subheading: 'Optimizers'} - */ - minimize(f: () => Scalar, returnCost = false, varList?: Variable[]): Scalar - |null { - const {value, grads} = this.computeGradients(f, varList); - - if (varList != null) { - const gradArray: NamedTensor[] = - varList.map(v => ({name: v.name, tensor: grads[v.name]})); - this.applyGradients(gradArray); - } else { - this.applyGradients(grads); - } - - // Dispose gradients. - dispose(grads); - - if (returnCost) { - return value; - } else { - value.dispose(); - return null; - } - } - - /** - * The number of iterations that this optimizer instance has been invoked for. - */ - get iterations(): number { - if (this.iterations_ == null) { - this.iterations_ = 0; - } - return this.iterations_; - } - - protected incrementIterations() { - this.iterations_ = this.iterations + 1; - } - - /** - * Executes f() and computes the gradient of the scalar output of f() with - * respect to the list of trainable variables provided by `varList`. If no - * list is provided, it defaults to all trainable variables. - * - * @param f The function to execute and whose output to use for computing - * gradients with respect to variables. - * @param varList An optional list of variables to compute gradients with - * respect to. If specified, only the trainable variables in varList will have - * gradients computed with respect to. Defaults to all trainable variables. - * - * @doc {heading: 'Training', subheading: 'Optimizers'} - */ - computeGradients(f: () => Scalar, varList?: Variable[]): - {value: Scalar, grads: NamedTensorMap} { - return variableGrads(f, varList); - } - - /** - * Updates variables by using the computed gradients. - * - * @param variableGradients A mapping of variable name to its gradient value. - * - * @doc {heading: 'Training', subheading: 'Optimizers'} - */ - abstract applyGradients(variableGradients: NamedTensorMap| - NamedTensor[]): void; - - /** - * Dispose the variables (if any) owned by this optimizer instance. - */ - dispose(): void { - if (this.iterations_ != null) { - dispose(this.iterations_); - } - } - - async saveIterations(): Promise { - if (this.iterations_ == null) { - this.iterations_ = 0; - } - return { - name: 'iter', // Named for Python compatibility. - // TODO(cais): Use 'int64' type when available. - tensor: scalar(this.iterations_, 'int32') - }; - } - - async getWeights(): Promise { - throw new Error('getWeights() is not implemented for this optimizer yet.'); - } - - async setWeights(weightValues: NamedTensor[]): Promise { - throw new Error( - `setWeights() is not implemented for this optimizer class ` + - `${this.getClassName()}`); - } - - /** - * Extract the first element of the weight values and set it - * as the iterations counter variable of this instance of optimizer. - * - * @param weightValues - * @returns Weight values with the first element consumed and excluded. - */ - protected async extractIterations(weightValues: NamedTensor[]): - Promise { - this.iterations_ = (await weightValues[0].tensor.data())[0]; - return weightValues.slice(1); - } -} - -Object.defineProperty(Optimizer, Symbol.hasInstance, { - value: (instance: Optimizer) => { - return instance.minimize != null && instance.computeGradients != null && - instance.applyGradients != null; - } -}); diff --git a/tfjs-master/tfjs-core/src/optimizers/optimizer_constructors.ts b/tfjs-master/tfjs-core/src/optimizers/optimizer_constructors.ts deleted file mode 100644 index 66966329a..000000000 --- a/tfjs-master/tfjs-core/src/optimizers/optimizer_constructors.ts +++ /dev/null @@ -1,189 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {AdadeltaOptimizer} from './adadelta_optimizer'; -import {AdagradOptimizer} from './adagrad_optimizer'; -import {AdamOptimizer} from './adam_optimizer'; -import {AdamaxOptimizer} from './adamax_optimizer'; -import {MomentumOptimizer} from './momentum_optimizer'; -import {RMSPropOptimizer} from './rmsprop_optimizer'; -import {SGDOptimizer} from './sgd_optimizer'; - -export class OptimizerConstructors { - /** - * Constructs a `tf.SGDOptimizer` that uses stochastic gradient descent. - * - * ```js - * // Fit a quadratic function by learning the coefficients a, b, c. - * const xs = tf.tensor1d([0, 1, 2, 3]); - * const ys = tf.tensor1d([1.1, 5.9, 16.8, 33.9]); - * - * const a = tf.scalar(Math.random()).variable(); - * const b = tf.scalar(Math.random()).variable(); - * const c = tf.scalar(Math.random()).variable(); - * - * // y = a * x^2 + b * x + c. - * const f = x => a.mul(x.square()).add(b.mul(x)).add(c); - * const loss = (pred, label) => pred.sub(label).square().mean(); - * - * const learningRate = 0.01; - * const optimizer = tf.train.sgd(learningRate); - * - * // Train the model. - * for (let i = 0; i < 10; i++) { - * optimizer.minimize(() => loss(f(xs), ys)); - * } - * - * // Make predictions. - * console.log( - * `a: ${a.dataSync()}, b: ${b.dataSync()}, c: ${c.dataSync()}`); - * const preds = f(xs).dataSync(); - * preds.forEach((pred, i) => { - * console.log(`x: ${i}, pred: ${pred}`); - * }); - * ``` - * - * @param learningRate The learning rate to use for the SGD algorithm. - * - * @doc {heading: 'Training', subheading: 'Optimizers', namespace: 'train'} - */ - static sgd(learningRate: number): SGDOptimizer { - return new SGDOptimizer(learningRate); - } - - /** - * Constructs a `tf.MomentumOptimizer` that uses momentum gradient - * descent. - * - * See - * [http://proceedings.mlr.press/v28/sutskever13.pdf]( - * http://proceedings.mlr.press/v28/sutskever13.pdf) - * - * @param learningRate The learning rate to use for the Momentum gradient - * descent algorithm. - * @param momentum The momentum to use for the momentum gradient descent - * algorithm. - * - * @doc {heading: 'Training', subheading: 'Optimizers', namespace: 'train'} - */ - static momentum(learningRate: number, momentum: number, useNesterov = false): - MomentumOptimizer { - return new MomentumOptimizer(learningRate, momentum, useNesterov); - } - - /** - * Constructs a `tf.RMSPropOptimizer` that uses RMSProp gradient - * descent. This implementation uses plain momentum and is not centered - * version of RMSProp. - * - * See - * [http://www.cs.toronto.edu/~tijmen/csc321/slides/lecture_slides_lec6.pdf]( - * http://www.cs.toronto.edu/~tijmen/csc321/slides/lecture_slides_lec6.pdf) - * - * @param learningRate The learning rate to use for the RMSProp gradient - * descent algorithm. - * @param decay The discounting factor for the history/coming gradient. - * @param momentum The momentum to use for the RMSProp gradient descent - * algorithm. - * @param epsilon Small value to avoid zero denominator. - * @param centered If true, gradients are normalized by the estimated - * variance of the gradient. - * - * @doc {heading: 'Training', subheading: 'Optimizers', namespace: 'train'} - */ - static rmsprop( - learningRate: number, decay = .9, momentum = 0.0, epsilon: number = null, - centered = false): RMSPropOptimizer { - return new RMSPropOptimizer( - learningRate, decay, momentum, epsilon, centered); - } - - /** - * Constructs a `tf.AdamOptimizer` that uses the Adam algorithm. - * See [https://arxiv.org/abs/1412.6980](https://arxiv.org/abs/1412.6980) - * - * @param learningRate The learning rate to use for the Adam gradient - * descent algorithm. - * @param beta1 The exponential decay rate for the 1st moment estimates. - * @param beta2 The exponential decay rate for the 2nd moment estimates. - * @param epsilon A small constant for numerical stability. - * - * @doc {heading: 'Training', subheading: 'Optimizers', namespace: 'train'} - */ - static adam( - learningRate = 0.001, beta1 = 0.9, beta2 = 0.999, - epsilon: number = null): AdamOptimizer { - return new AdamOptimizer(learningRate, beta1, beta2, epsilon); - } - - /** - * Constructs a `tf.AdadeltaOptimizer` that uses the Adadelta algorithm. - * See [https://arxiv.org/abs/1212.5701](https://arxiv.org/abs/1212.5701) - * - * @param learningRate The learning rate to use for the Adadelta gradient - * descent algorithm. - * @param rho The learning rate decay over each update. - * @param epsilon A constant epsilon used to better condition the grad - * update. - * - * @doc {heading: 'Training', subheading: 'Optimizers', namespace: 'train'} - */ - static adadelta(learningRate = .001, rho = .95, epsilon: number = null): - AdadeltaOptimizer { - return new AdadeltaOptimizer(learningRate, rho, epsilon); - } - - /** - * Constructs a `tf.AdamaxOptimizer` that uses the Adamax algorithm. - * See [https://arxiv.org/abs/1412.6980](https://arxiv.org/abs/1412.6980) - * - * @param learningRate The learning rate to use for the Adamax gradient - * descent algorithm. - * @param beta1 The exponential decay rate for the 1st moment estimates. - * @param beta2 The exponential decay rate for the 2nd moment estimates. - * @param epsilon A small constant for numerical stability. - * @param decay The learning rate decay over each update. - * - * @doc {heading: 'Training', subheading: 'Optimizers', namespace: 'train'} - */ - static adamax( - learningRate = 0.002, beta1 = 0.9, beta2 = 0.999, epsilon: number = null, - decay = 0.0): AdamaxOptimizer { - return new AdamaxOptimizer(learningRate, beta1, beta2, epsilon, decay); - } - - /** - * Constructs a `tf.AdagradOptimizer` that uses the Adagrad algorithm. - * See - * [http://www.jmlr.org/papers/volume12/duchi11a/duchi11a.pdf]( - * http://www.jmlr.org/papers/volume12/duchi11a/duchi11a.pdf) - * or - * [http://ruder.io/optimizing-gradient-descent/index.html#adagrad]( - * http://ruder.io/optimizing-gradient-descent/index.html#adagrad) - * - * @param learningRate The learning rate to use for the Adagrad gradient - * descent algorithm. - * @param initialAccumulatorValue Starting value for the accumulators, must be - * positive. - * - * @doc {heading: 'Training', subheading: 'Optimizers', namespace: 'train'} - */ - static adagrad(learningRate: number, initialAccumulatorValue = 0.1): - AdagradOptimizer { - return new AdagradOptimizer(learningRate, initialAccumulatorValue); - } -} diff --git a/tfjs-master/tfjs-core/src/optimizers/optimizer_test.ts b/tfjs-master/tfjs-core/src/optimizers/optimizer_test.ts deleted file mode 100644 index d09e9ecef..000000000 --- a/tfjs-master/tfjs-core/src/optimizers/optimizer_test.ts +++ /dev/null @@ -1,234 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {Variable} from '../tensor'; -import {expectArraysClose} from '../test_util'; - -import {Optimizer} from './optimizer'; -import {SGDOptimizer} from './sgd_optimizer'; - -describeWithFlags('optimizer', ALL_ENVS, () => { - it('basic', async () => { - const initialTensors = tf.memory().numTensors; - const learningRate = .1; - const optimizer = tf.train.sgd(learningRate); - - const x = tf.scalar(4).variable(); - const bias = tf.scalar(1).variable(); - const strayVariable = tf.scalar(-1).variable(); - - let numTensors = tf.memory().numTensors; - - // tslint:disable-next-line: no-unnecessary-type-assertion - const f = () => x.square().add(bias) as tf.Scalar; - - let cost = optimizer.minimize(f, /* returnCost */ true); - - // Cost should be the only additional arrays. - expect(tf.memory().numTensors).toBe(numTensors + 1); - - // de/dx = 2x - const expectedX1 = -2 * 4 * learningRate + 4; - // de/db = 1 - const expectedBias1 = -1 * learningRate + 1; - expectArraysClose(await x.data(), [expectedX1]); - expectArraysClose(await bias.data(), [expectedBias1]); - expectArraysClose(await cost.data(), [Math.pow(4, 2) + 1]); - // The stray variable should remain unchanged. - expectArraysClose(await strayVariable.data(), [-1]); - - cost.dispose(); - numTensors = tf.memory().numTensors; - - cost = optimizer.minimize(f, /* returnCost */ false); - // There should be no new additional Tensors. - expect(tf.memory().numTensors).toBe(numTensors); - - const expectedX2 = -2 * expectedX1 * learningRate + expectedX1; - const expectedBias2 = -learningRate + expectedBias1; - expectArraysClose(await x.data(), [expectedX2]); - expectArraysClose(await bias.data(), [expectedBias2]); - expect(cost).toBe(null); - // The stray variable should remain unchanged. - expectArraysClose(await strayVariable.data(), [-1]); - - optimizer.dispose(); - x.dispose(); - bias.dispose(); - strayVariable.dispose(); - // The only additional tensors remaining are the arguments to variable(). - expect(tf.memory().numTensors).toBe(initialTensors + 3); - }); - - it('varList array of all variables', async () => { - const learningRate = .1; - const optimizer = new SGDOptimizer(learningRate); - - const x = tf.scalar(4).variable(); - const bias = tf.scalar(1).variable(); - const strayVariable = tf.scalar(-1).variable(); - const varList = [x, bias]; - - // tslint:disable-next-line: no-unnecessary-type-assertion - const f = () => x.square().add(bias) as tf.Scalar; - - let cost = optimizer.minimize(f, /* returnCost */ true, varList); - - // de/dx = 2x - const expectedX1 = -2 * 4 * learningRate + 4; - // de/db = 1 - const expectedBias1 = -1 * learningRate + 1; - expectArraysClose(await x.data(), [expectedX1]); - expectArraysClose(await bias.data(), [expectedBias1]); - expectArraysClose(await cost.data(), [Math.pow(4, 2) + 1]); - // The stray variable should remain unchanged. - expectArraysClose(await strayVariable.data(), [-1]); - - cost = optimizer.minimize(f, /* returnCost */ false, varList); - - const expectedX2 = -2 * expectedX1 * learningRate + expectedX1; - const expectedBias2 = -learningRate + expectedBias1; - expectArraysClose(await x.data(), [expectedX2]); - expectArraysClose(await bias.data(), [expectedBias2]); - // The stray variable should remain unchanged. - expectArraysClose(await strayVariable.data(), [-1]); - expect(cost).toBe(null); - }); - - it('varList empty array of variables throws error', () => { - const learningRate = .1; - const optimizer = new SGDOptimizer(learningRate); - - const x = tf.scalar(4).variable(); - const bias = tf.scalar(1).variable(); - // Stray variable. - tf.scalar(-1).variable(); - const varList: Variable[] = []; - - // tslint:disable-next-line: no-unnecessary-type-assertion - const f = () => x.square().add(bias) as tf.Scalar; - - expect(() => optimizer.minimize(f, /* returnCost */ true, varList)) - .toThrowError(); - }); - - it('varList subset of variables update', async () => { - const learningRate = .1; - const optimizer = new SGDOptimizer(learningRate); - - const x = tf.scalar(4).variable(); - const bias = tf.scalar(1).variable(); - const strayVariable = tf.scalar(-1).variable(); - const varList = [x]; - - // tslint:disable-next-line: no-unnecessary-type-assertion - const f = () => x.square().add(bias) as tf.Scalar; - - let cost = optimizer.minimize(f, /* returnCost */ true, varList); - - // de/dx = 2x - const expectedValue1 = -2 * 4 * learningRate + 4; - expectArraysClose(await x.data(), [expectedValue1]); - // bias should remain unchanged. - expectArraysClose(await bias.data(), [1]); - expectArraysClose(await cost.data(), [Math.pow(4, 2) + 1]); - // The stray variable should remain unchanged. - expectArraysClose(await strayVariable.data(), [-1]); - - cost = optimizer.minimize(f, /* returnCost */ false, varList); - - const expectedValue2 = -2 * expectedValue1 * learningRate + expectedValue1; - expectArraysClose(await x.data(), [expectedValue2]); - // Bias still should remain unchanged. - expectArraysClose(await bias.data(), [1]); - expect(cost).toBe(null); - // The stray variable should remain unchanged. - expectArraysClose(await strayVariable.data(), [-1]); - }); - - it('only bias trainable', async () => { - const learningRate = .1; - const optimizer = new SGDOptimizer(learningRate); - - const trainable = false; - const x = tf.scalar(4).variable(trainable); - const bias = tf.scalar(1).variable(); - const strayVariable = tf.scalar(-1).variable(); - - // tslint:disable-next-line: no-unnecessary-type-assertion - const f = () => x.square().add(bias) as tf.Scalar; - - let cost = optimizer.minimize(f, /* returnCost */ true); - - // x should not have been updated. - expectArraysClose(await x.data(), [4]); - // de/db = 1 - const expectedBias1 = -1 * learningRate + 1; - expectArraysClose(await bias.data(), [expectedBias1]); - expectArraysClose(await cost.data(), [Math.pow(4, 2) + 1]); - // The stray variable should remain unchanged. - expectArraysClose(await strayVariable.data(), [-1]); - - cost = optimizer.minimize(f, /* returnCost */ false); - - // x should not have been updated. - expectArraysClose(await x.data(), [4]); - const expectedBias2 = -learningRate + expectedBias1; - expectArraysClose(await bias.data(), [expectedBias2]); - expect(cost).toBe(null); - // The stray variable should remain unchanged. - expectArraysClose(await strayVariable.data(), [-1]); - }); - - it('only bias trainable, only x in varList throws error', () => { - const learningRate = .1; - const optimizer = new SGDOptimizer(learningRate); - - const trainable = false; - const x = tf.scalar(4).variable(trainable); - const bias = tf.scalar(1).variable(); - // stray variable. - tf.scalar(-1).variable(); - const varList = [x]; - - // tslint:disable-next-line: no-unnecessary-type-assertion - const f = () => x.square().add(bias) as tf.Scalar; - - expect(() => optimizer.minimize(f, /* returnCost */ true, varList)) - .toThrowError(); - }); - - it('instanceof Optimizer', () => { - const learningRate = .1; - const optimizer = new SGDOptimizer(learningRate); - - expect(optimizer instanceof Optimizer).toBe(true); - }); - - it('throws error when f returns a non-scalar', () => { - const learningRate = .1; - const optimizer = new SGDOptimizer(learningRate); - - const x = tf.tensor1d([1, 2]).variable(); - const f = () => x.square(); - - // tslint:disable-next-line:no-any - expect(() => optimizer.minimize(f as any)).toThrowError(); - }); -}); diff --git a/tfjs-master/tfjs-core/src/optimizers/register_optimizers.ts b/tfjs-master/tfjs-core/src/optimizers/register_optimizers.ts deleted file mode 100644 index 263cb1d94..000000000 --- a/tfjs-master/tfjs-core/src/optimizers/register_optimizers.ts +++ /dev/null @@ -1,41 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {AdadeltaOptimizer} from './adadelta_optimizer'; -import {AdagradOptimizer} from './adagrad_optimizer'; -import {AdamOptimizer} from './adam_optimizer'; -import {AdamaxOptimizer} from './adamax_optimizer'; -import {MomentumOptimizer} from './momentum_optimizer'; -import {RMSPropOptimizer} from './rmsprop_optimizer'; -import {SGDOptimizer} from './sgd_optimizer'; -import {registerClass} from '../serialization'; - -const OPTIMIZERS = [ - AdadeltaOptimizer, - AdagradOptimizer, - AdamOptimizer, - AdamaxOptimizer, - MomentumOptimizer, - RMSPropOptimizer, - SGDOptimizer, -]; - -export function registerOptimizers() { - for (const optimizer of OPTIMIZERS) { - registerClass(optimizer); - } -} diff --git a/tfjs-master/tfjs-core/src/optimizers/rmsprop_optimizer.ts b/tfjs-master/tfjs-core/src/optimizers/rmsprop_optimizer.ts deleted file mode 100644 index 5b8dd0b70..000000000 --- a/tfjs-master/tfjs-core/src/optimizers/rmsprop_optimizer.ts +++ /dev/null @@ -1,214 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {dispose, tidy} from '../globals'; -import {add} from '../ops/add'; -import {div} from '../ops/div'; -import {mul} from '../ops/mul'; -import {sqrt} from '../ops/sqrt'; -import {square} from '../ops/square'; -import {sub} from '../ops/sub'; -import {zerosLike} from '../ops/zeros_like'; -import {ConfigDict, Serializable, SerializableConstructor} from '../serialization'; -import {NamedTensor, NamedTensorMap} from '../tensor_types'; - -import {Optimizer, OptimizerVariable} from './optimizer'; - -/** @doclink Optimizer */ -export class RMSPropOptimizer extends Optimizer { - /** @nocollapse */ - static get className() { - // Name matters for Python compatibility. - // This is a getter instead of a property because when it's a property, it - // prevents the entire class from being tree-shaken. - return 'RMSProp'; - } - private centered: boolean; - - private accumulatedMeanSquares: OptimizerVariable[] = []; - private accumulatedMoments: OptimizerVariable[] = []; - private accumulatedMeanGrads: OptimizerVariable[] = []; - - constructor( - protected learningRate: number, protected decay = 0.9, - protected momentum = 0.0, protected epsilon: number = null, - centered = false) { - super(); - - this.centered = centered; - - if (epsilon == null) { - this.epsilon = ENGINE.backend.epsilon(); - } - if (learningRate == null) { - throw new Error(`learningRate for RMSPropOptimizer must be defined.`); - } - } - - applyGradients(variableGradients: NamedTensorMap|NamedTensor[]) { - const variableNames = Array.isArray(variableGradients) ? - variableGradients.map(item => item.name) : - Object.keys(variableGradients); - - variableNames.forEach((name, i) => { - const value = ENGINE.registeredVariables[name]; - const trainable = false; - if (this.accumulatedMeanSquares[i] == null) { - this.accumulatedMeanSquares[i] = { - originalName: `${name}/rms`, - variable: tidy(() => zerosLike(value).variable(trainable)) - }; - } - if (this.accumulatedMoments[i] == null) { - this.accumulatedMoments[i] = { - originalName: `${name}/momentum`, - variable: tidy(() => zerosLike(value).variable(trainable)) - }; - } - if (this.accumulatedMeanGrads[i] == null && this.centered) { - this.accumulatedMeanGrads[i] = { - originalName: `${name}/mg`, - variable: tidy(() => zerosLike(value).variable(trainable)) - }; - } - - const gradient = Array.isArray(variableGradients) ? - variableGradients[i].tensor : - variableGradients[name]; - if (gradient == null) { - return; - } - - const accumulatedMeanSquare = this.accumulatedMeanSquares[i].variable; - const accumulatedMoments = this.accumulatedMoments[i].variable; - tidy(() => { - const newAccumulatedMeanSquare = - add(mul(accumulatedMeanSquare, this.decay), - mul(square(gradient), 1 - this.decay)); - - if (this.centered) { - const accumulatedMeanGrad = this.accumulatedMeanGrads[i].variable; - // Centered gradient - const newAccumulatedMeanGrad = - add(mul(accumulatedMeanGrad, this.decay), - mul(gradient, 1 - this.decay)); - - const gradContribution = - div(mul(gradient, this.learningRate), - sqrt( - sub(newAccumulatedMeanSquare, - add(square(newAccumulatedMeanGrad), this.epsilon)))); - const newAccumulatedMoments = - add(mul(accumulatedMoments, this.momentum), gradContribution); - - accumulatedMeanSquare.assign(newAccumulatedMeanSquare); - accumulatedMeanGrad.assign(newAccumulatedMeanGrad); - accumulatedMoments.assign(newAccumulatedMoments); - - const newValue = sub(value, newAccumulatedMoments); - value.assign(newValue); - } else { - // Plain gradient - const newAccumulatedMeanSquare = - add(mul(accumulatedMeanSquare, this.decay), - mul(square(gradient), 1 - this.decay)); - - const newAccumulatedMoments = - add(mul(accumulatedMoments, this.momentum), - div(mul(gradient, this.learningRate), - sqrt(add(newAccumulatedMeanSquare, this.epsilon)))); - - accumulatedMeanSquare.assign(newAccumulatedMeanSquare); - accumulatedMoments.assign(newAccumulatedMoments); - - const newValue = sub(value, newAccumulatedMoments); - value.assign(newValue); - } - }); - }); - this.incrementIterations(); - } - - override dispose(): void { - if (this.accumulatedMeanSquares != null) { - dispose(this.accumulatedMeanSquares.map(v => v.variable)); - } - if (this.accumulatedMeanGrads != null && this.centered) { - dispose(this.accumulatedMeanGrads.map(v => v.variable)); - } - if (this.accumulatedMoments != null) { - dispose(this.accumulatedMoments.map(v => v.variable)); - } - } - - override async getWeights(): Promise { - // Order matters for Python compatibility. - const variables: OptimizerVariable[] = - [...this.accumulatedMeanSquares, ...this.accumulatedMoments]; - if (this.centered) { - variables.push(...this.accumulatedMeanGrads); - } - return [await this.saveIterations()].concat( - variables.map(v => ({name: v.originalName, tensor: v.variable}))); - } - - override async setWeights(weightValues: NamedTensor[]): Promise { - weightValues = await this.extractIterations(weightValues); - const variableCount = - this.centered ? weightValues.length / 3 : weightValues.length / 2; - const trainable = false; - this.accumulatedMeanSquares = - weightValues.slice(0, variableCount).map(v => ({ - originalName: v.name, - variable: v.tensor.variable( - trainable) - })); - this.accumulatedMoments = - weightValues.slice(variableCount, variableCount * 2) - .map(v => ({ - originalName: v.name, - variable: v.tensor.variable(trainable) - })); - if (this.centered) { - this.accumulatedMeanGrads = - weightValues.slice(variableCount * 2, variableCount * 3) - .map(v => ({ - originalName: v.name, - variable: v.tensor.variable(trainable) - })); - } - } - - getConfig(): ConfigDict { - return { - 'learningRate': this.learningRate, - 'decay': this.decay, - 'momentum': this.momentum, - 'epsilon': this.epsilon, - 'centered': this.centered - }; - } - - /** @nocollapse */ - static override fromConfig( - cls: SerializableConstructor, config: ConfigDict): T { - return new cls( - config['learningRate'], config['decay'], config['momentum'], - config['epsilon'], config['centered']); - } -} diff --git a/tfjs-master/tfjs-core/src/optimizers/rmsprop_optimizer_test.ts b/tfjs-master/tfjs-core/src/optimizers/rmsprop_optimizer_test.ts deleted file mode 100644 index 642d65a5b..000000000 --- a/tfjs-master/tfjs-core/src/optimizers/rmsprop_optimizer_test.ts +++ /dev/null @@ -1,228 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('RMSPropOptimizer', ALL_ENVS, () => { - it('basic', async () => { - const initialTensors = tf.memory().numTensors; - const learningRate = 0.1; - const moment = 0.1; - const rho = 0.95; - const optimizer = tf.train.rmsprop(learningRate, rho, moment); - - const x = tf.tensor1d([1, 2]).variable(); - - const f = () => x.square().sum(); - - let numTensors = tf.memory().numTensors; - - let cost = optimizer.minimize(f as () => tf.Scalar, /* returnCost */ true); - - // Cost & 2 accumulators should be the only additional arrays. - expect(tf.memory().numTensors).toBe(numTensors + 3); - - // epsilon = 1e-8 - // newAccumulatedMeanSquare = - // rho * accumulatedMeanSquare + (1 - rho) * grad ^ 2 = (0.2) - // newAccumulatedMoments = momentum * accumulatedMoments + - // learning_rate * gradient / sqrt(newAccumulatedMeanSquare + - // epsilon) = 0.1 * 0 + ((0.1 * 2) / sqrt(0.2 + 1e-8)) = 0.44721 - // x -= learningRate * newAccumulatedMoments - // - // de/dx = [2, 4] - // accumulatedMeanSquare = [0, 0] - // newAccumulatedMeanSquare = [.2, .8] - // accumulatedMoments = [0, 0] - // newAccumulatedMoments = [0.44721, 0.44721] - // x = [0.55279, 1.55279] - expectArraysClose(await x.data(), [0.55279, 1.55279]); - - cost.dispose(); - numTensors = tf.memory().numTensors; - - cost = optimizer.minimize(f as () => tf.Scalar, /* returnCost */ false); - - // x = [0.55279, 1.55279] - // de/dx = [1.10558, 3.10558] - // accumulatedMeanSquare = [0.2, 0.8] - // newAccumulatedMeanSquare = [0.25105125, 1.242231] - // accumulatedMoments = [0.44721, 0.44721] - // newAccumulatedMoments = [0.26534, 0.32336] - // x = [0.28745, 1.22943] - - // TODO: Fix numerical precision. - expectArraysClose(await x.data(), [0.28745, 1.222943], 1e-2); - - // There should be no new additional Tensors. - expect(tf.memory().numTensors).toBe(numTensors); - - expect(cost).toBe(null); - - x.dispose(); - optimizer.dispose(); - // The only additional tensor remaining is the argument to variable(). - expect(tf.memory().numTensors).toBe(initialTensors + 1); - }); - - it('gradient with centered momentum', async () => { - const initialTensors = tf.memory().numTensors; - const learningRate = 0.1; - const moment = 0.1; - const rho = 0.95; - const eps = 1e-8; - const optimizer = tf.train.rmsprop(learningRate, rho, moment, eps, true); - - const x = tf.tensor1d([1, 2]).variable(); - - const f = () => x.square().sum(); - - let numTensors = tf.memory().numTensors; - - let cost = optimizer.minimize(f as () => tf.Scalar, /* returnCost */ true); - - // Cost & 3 accumulators should be the only additional arrays. - expect(tf.memory().numTensors).toBe(numTensors + 4); - - // epsilon = 1e-8 - // newAccumulatedMeanSquare = - // rho * accumulatedMeanSquare + (1 - rho) * grad ^ 2 = [.2, .8] - // newAccumulatedMeanGrad = - // rho * accumulatedMeanGrad + (1 - rho) * grad = [0.1, 0.2] - // newAccumulatedMoments = momentum * accumulatedMoments + - // learning_rate * gradient / sqrt(newAccumulatedMeanSquare - // - newAccumulatedMeanGrad * 2 + - // epsilon) = 0.1 * 0 + ((0.1 * 2) - // / sqrt(0.2 - 0.01 + 1e-8)) = 0.458831 - // x -= learningRate * newAccumulatedMoments - // - // de/dx = [2, 4] - // accumulatedMeanSquare = [0, 0] - // newAccumulatedMeanSquare = [.2, .8] - // newAccumulatedMeanGrad = [.1, .2] - // accumulatedMoments = [0, 0] - // newAccumulatedMoments = [0.45883, 0.458831] - // x = [0.54117, 1.541169] - expectArraysClose(await x.data(), [0.54117, 1.541169]); - - cost.dispose(); - numTensors = tf.memory().numTensors; - - cost = optimizer.minimize(f as () => tf.Scalar, /* returnCost */ false); - - // x = [0.54117, 1.541169] - // de/dx = [1.08234, 3.082338] - // accumulatedMeanSquare = [0.2, 0.8] - // accumulatedMeanGrad = [.1, .2] - // newAccumulatedMeanSquare = [0.248572, 1.235040] - // newAccumulatedMeanGrad = [0.149117, 0.3441169] - // accumulatedMoments = [0.45883, 0.458831] - // newAccumulatedMoments = [0.273385, 0.3375766] - // x = [0.267785, 1.2035924] - - // TODO: Fix numerical precision. - expectArraysClose(await x.data(), [0.267785, 1.2035924], 1e-2); - - // There should be no new additional Tensors. - expect(tf.memory().numTensors).toBe(numTensors); - - expect(cost).toBe(null); - - x.dispose(); - optimizer.dispose(); - // The only additional tensor remaining is the argument to variable(). - expect(tf.memory().numTensors).toBe(initialTensors + 1); - }); - - it('Save and load weights: centered = false', async () => { - const learningRate = 0.1; - const moment = 0.1; - const rho = 0.95; - const optimizer1 = tf.train.rmsprop(learningRate, rho, moment); - - const x = tf.tensor1d([1, 2]).variable(); - const f: () => tf.Scalar = () => x.square().sum(); - - let cost = optimizer1.minimize(f, /* returnCost */ true); - expectArraysClose(await cost.data(), 5); - expectArraysClose(await x.data(), [0.5527865, 1.5527864]); - - const weights = await optimizer1.getWeights(); - // An iteration variable and two optimizer state variables. - expect(weights.length).toEqual(3); - - const optimizer2 = tf.train.rmsprop(learningRate, rho, moment); - await optimizer2.setWeights(weights); - - cost = optimizer2.minimize(f, /* returnCost */ true); - expectArraysClose(await cost.data(), 2.7167187); - expectArraysClose(await x.data(), [0.2874418, 1.2294267]); - expect(optimizer2.iterations).toEqual(2); - }); - - it('Save, load weights and continue training: centered = true', async () => { - const learningRate = 0.1; - const moment = 0.1; - const rho = 0.95; - const epsilon: number = undefined; - const centered = true; - const optimizer1 = - tf.train.rmsprop(learningRate, rho, moment, epsilon, centered); - - const x = tf.tensor1d([1, 2]).variable(); - const f = () => x.square().sum(); - - let cost = optimizer1.minimize(f as () => tf.Scalar, /* returnCost */ true); - expectArraysClose(await cost.data(), 5); - expectArraysClose(await x.data(), [0.5411684, 1.5411685]); - - const weights = await optimizer1.getWeights(); - // An iteration variable and three optimizer state variables. - expect(weights.length).toEqual(4); - - const optimizer2 = - tf.train.rmsprop(learningRate, rho, moment, epsilon, centered); - await optimizer2.setWeights(weights); - - cost = optimizer2.minimize(f as () => tf.Scalar, /* returnCost */ true); - expectArraysClose(await cost.data(), 2.668063); - expectArraysClose(await x.data(), [0.2677834, 1.2035918]); - expect(optimizer2.iterations).toEqual(2); - - const optimizer3 = - tf.train.rmsprop(learningRate, rho, moment, epsilon, centered); - await optimizer3.setWeights(await optimizer2.getWeights()); - cost = optimizer3.minimize(f as () => tf.Scalar, /* returnCost */ true); - expectArraysClose(await cost.data(), 1.520341); - expect(optimizer3.iterations).toEqual(3); - }); - - it('serialization round-trip', () => { - const originalOpt = tf.train.rmsprop(0.1, 0.5, 0.1, 1e-7, true); - const reserialized = tf.RMSPropOptimizer.fromConfig( - tf.RMSPropOptimizer, originalOpt.getConfig()); - expect(reserialized.getConfig()).toEqual(originalOpt.getConfig()); - }); - - it('must define learning rate', () => { - const learningRate: number = undefined; - expect(() => tf.train.rmsprop(learningRate)) - .toThrowError(/learningRate for RMSPropOptimizer must be defined./); - }); -}); diff --git a/tfjs-master/tfjs-core/src/optimizers/sgd_optimizer.ts b/tfjs-master/tfjs-core/src/optimizers/sgd_optimizer.ts deleted file mode 100644 index 0935c973b..000000000 --- a/tfjs-master/tfjs-core/src/optimizers/sgd_optimizer.ts +++ /dev/null @@ -1,100 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from '../engine'; -import {keep, tidy} from '../globals'; -import {add} from '../ops/add'; -import {mul} from '../ops/mul'; -import {scalar} from '../ops/scalar'; -import {ConfigDict, Serializable, SerializableConstructor} from '../serialization'; -import {Scalar} from '../tensor'; -import {NamedTensor, NamedTensorMap} from '../tensor_types'; - -import {Optimizer} from './optimizer'; - -/** @doclink Optimizer */ -export class SGDOptimizer extends Optimizer { - /** @nocollapse */ - static get className() { - // Name matters for Python compatibility. - // This is a getter instead of a property because when it's a property, it - // prevents the entire class from being tree-shaken. - return 'SGD'; - } - protected c: Scalar; - - constructor(protected learningRate: number) { - super(); - this.setLearningRate(learningRate); - } - - applyGradients(variableGradients: NamedTensorMap|NamedTensor[]) { - const varNames = Array.isArray(variableGradients) ? - variableGradients.map(v => v.name) : - Object.keys(variableGradients); - varNames.forEach((name, i) => { - const gradient = Array.isArray(variableGradients) ? - variableGradients[i].tensor : - variableGradients[name]; - if (gradient == null) { - return; - } - const value = ENGINE.registeredVariables[name]; - tidy(() => { - const newValue = add(mul(this.c, gradient), value); - value.assign(newValue); - }); - }); - this.incrementIterations(); - } - - /** - * Sets the learning rate of the optimizer. - */ - setLearningRate(learningRate: number) { - this.learningRate = learningRate; - if (this.c != null) { - this.c.dispose(); - } - this.c = keep(scalar(-learningRate)); - } - - override dispose() { - this.c.dispose(); - } - - override async getWeights(): Promise { - return [await this.saveIterations()]; - } - - override async setWeights(weightValues: NamedTensor[]): Promise { - weightValues = await this.extractIterations(weightValues); - if (weightValues.length !== 0) { - throw new Error('SGD optimizer does not have settable weights.'); - } - } - - getConfig(): ConfigDict { - return {'learningRate': this.learningRate}; - } - - /** @nocollapse */ - static override fromConfig( - cls: SerializableConstructor, config: ConfigDict): T { - return new cls(config['learningRate']); - } -} diff --git a/tfjs-master/tfjs-core/src/optimizers/sgd_optimizer_test.ts b/tfjs-master/tfjs-core/src/optimizers/sgd_optimizer_test.ts deleted file mode 100644 index 0a07ea7da..000000000 --- a/tfjs-master/tfjs-core/src/optimizers/sgd_optimizer_test.ts +++ /dev/null @@ -1,96 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import {ALL_ENVS, describeWithFlags} from '../jasmine_util'; -import {expectArraysClose} from '../test_util'; - -describeWithFlags('SGDOptimizer', ALL_ENVS, () => { - it('basic', async () => { - const initialTensors = tf.memory().numTensors; - const learningRate = .1; - const optimizer = tf.train.sgd(learningRate); - - const x = tf.scalar(4).variable(); - - let numTensors = tf.memory().numTensors; - - let cost = optimizer.minimize(() => x.square(), /* returnCost */ true); - - // Cost should be the only additional arrays. - expect(tf.memory().numTensors).toBe(numTensors + 1); - - // de/dx = 2x - const expectedValue1 = -2 * 4 * learningRate + 4; - expectArraysClose(await x.data(), [expectedValue1]); - expectArraysClose(await cost.data(), [Math.pow(4, 2)]); - - cost.dispose(); - numTensors = tf.memory().numTensors; - - cost = optimizer.minimize(() => x.square(), /* returnCost */ false); - // There should be no new additional Tensors. - expect(tf.memory().numTensors).toBe(numTensors); - - const expectedValue2 = -2 * expectedValue1 * learningRate + expectedValue1; - expectArraysClose(await x.data(), [expectedValue2]); - expect(cost).toBe(null); - - optimizer.dispose(); - x.dispose(); - // The only additional tensor remaining is the argument to variable(). - expect(tf.memory().numTensors).toBe(initialTensors + 1); - }); - - it('Set and get weights: empty', async () => { - const x = tf.scalar(4).variable(); - - const learningRate = .1; - const optimizer1 = tf.train.sgd(learningRate); - - let weights = await optimizer1.getWeights(); - expect(optimizer1.iterations).toEqual(0); - - optimizer1.minimize(() => x.square()); - - weights = await optimizer1.getWeights(); - expect(optimizer1.iterations).toEqual(1); - expect(weights.length).toEqual(1); - expect(weights[0].name).toEqual('iter'); - expectArraysClose(await weights[0].tensor.data(), 1); - - const optimizer2 = tf.train.sgd(learningRate); - await optimizer2.setWeights(weights); - optimizer2.minimize(() => x.square()); - expectArraysClose(await x.data(), 2.56); - expect(optimizer2.iterations).toEqual(2); - - const optimizer3 = tf.train.sgd(learningRate); - await optimizer3.setWeights(await optimizer2.getWeights()); - optimizer3.minimize(() => x.square()); - expectArraysClose(await x.data(), 2.048); - expect(optimizer3.iterations).toEqual(3); - }); - - it('serialization round-trip', () => { - const learningRate = .1; - const originalOpt = tf.train.sgd(learningRate); - const reserialized = - tf.SGDOptimizer.fromConfig(tf.SGDOptimizer, originalOpt.getConfig()); - expect(reserialized.getConfig()).toEqual(originalOpt.getConfig()); - }); -}); diff --git a/tfjs-master/tfjs-core/src/platforms/is_typed_array_browser.ts b/tfjs-master/tfjs-core/src/platforms/is_typed_array_browser.ts deleted file mode 100644 index 346908408..000000000 --- a/tfjs-master/tfjs-core/src/platforms/is_typed_array_browser.ts +++ /dev/null @@ -1,22 +0,0 @@ -/** - * @license - * Copyright 2023 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -export function isTypedArrayBrowser(a: unknown): a is Uint8Array - | Float32Array | Int32Array | Uint8ClampedArray { - return a instanceof Float32Array || a instanceof Int32Array || - a instanceof Uint8Array || a instanceof Uint8ClampedArray; -} diff --git a/tfjs-master/tfjs-core/src/platforms/platform.ts b/tfjs-master/tfjs-core/src/platforms/platform.ts deleted file mode 100644 index 60934f39d..000000000 --- a/tfjs-master/tfjs-core/src/platforms/platform.ts +++ /dev/null @@ -1,54 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {RequestDetails} from '../io/types'; - -/** - * At any given time a single platform is active and represents and - * implementation of this interface. In practice, a platform is an environment - * where TensorFlow.js can be executed, e.g. the browser or Node.js. - */ -export interface Platform { - /** - * Makes an HTTP request. - * @param path The URL path to make a request to - * @param init The request init. See init here: - * https://developer.mozilla.org/en-US/docs/Web/API/Request/Request - */ - fetch(path: string, requestInits?: RequestInit, options?: RequestDetails): - Promise; - - /** - * Returns the current high-resolution time in milliseconds relative to an - * arbitrary time in the past. It works across different platforms (node.js, - * browsers). - */ - now(): number; - - /** - * Encode the provided string into an array of bytes using the provided - * encoding. - */ - encode(text: string, encoding: string): Uint8Array; - /** Decode the provided bytes into a string using the provided encoding. */ - decode(bytes: Uint8Array, encoding: string): string; - - setTimeoutCustom?(functionRef: Function, delay: number): void; - - isTypedArray(a: unknown): a is Float32Array|Int32Array|Uint8Array| - Uint8ClampedArray; -} diff --git a/tfjs-master/tfjs-core/src/platforms/platform_browser.ts b/tfjs-master/tfjs-core/src/platforms/platform_browser.ts deleted file mode 100644 index d4b16ed22..000000000 --- a/tfjs-master/tfjs-core/src/platforms/platform_browser.ts +++ /dev/null @@ -1,117 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import '../flags'; - -import {env} from '../environment'; -import {BrowserIndexedDB, BrowserIndexedDBManager} from '../io/indexed_db'; -import {BrowserLocalStorage, BrowserLocalStorageManager} from '../io/local_storage'; -import {ModelStoreManagerRegistry} from '../io/model_management'; - -import {Platform} from './platform'; -import {isTypedArrayBrowser} from './is_typed_array_browser'; - -export class PlatformBrowser implements Platform { - // According to the spec, the built-in encoder can do only UTF-8 encoding. - // https://developer.mozilla.org/en-US/docs/Web/API/TextEncoder/TextEncoder - private textEncoder: TextEncoder; - - // For setTimeoutCustom - private readonly messageName = 'setTimeoutCustom'; - private functionRefs: Function[] = []; - private handledMessageCount = 0; - private hasEventListener = false; - - fetch(path: string, init?: RequestInit): Promise { - return fetch(path, init); - } - - now(): number { - return performance.now(); - } - - encode(text: string, encoding: string): Uint8Array { - if (encoding !== 'utf-8' && encoding !== 'utf8') { - throw new Error( - `Browser's encoder only supports utf-8, but got ${encoding}`); - } - if (this.textEncoder == null) { - this.textEncoder = new TextEncoder(); - } - return this.textEncoder.encode(text); - } - decode(bytes: Uint8Array, encoding: string): string { - return new TextDecoder(encoding).decode(bytes); - } - - // If the setTimeout nesting level is greater than 5 and timeout is less - // than 4ms, timeout will be clamped to 4ms, which hurts the perf. - // Interleaving window.postMessage and setTimeout will trick the browser and - // avoid the clamp. - setTimeoutCustom(functionRef: Function, delay: number): void { - if (typeof window === 'undefined' || - !env().getBool('USE_SETTIMEOUTCUSTOM')) { - setTimeout(functionRef, delay); - return; - } - - this.functionRefs.push(functionRef); - setTimeout(() => { - window.postMessage( - {name: this.messageName, index: this.functionRefs.length - 1}, '*'); - }, delay); - - if (!this.hasEventListener) { - this.hasEventListener = true; - window.addEventListener('message', (event: MessageEvent) => { - if (event.source === window && event.data.name === this.messageName) { - event.stopPropagation(); - const functionRef = this.functionRefs[event.data.index]; - functionRef(); - this.handledMessageCount++; - if (this.handledMessageCount === this.functionRefs.length) { - this.functionRefs = []; - this.handledMessageCount = 0; - } - } - }, true); - } - } - - isTypedArray(a: unknown): a is Uint8Array | Float32Array | Int32Array - | Uint8ClampedArray { - return isTypedArrayBrowser(a); - } -} - -if (env().get('IS_BROWSER')) { - env().setPlatform('browser', new PlatformBrowser()); - - // Register LocalStorage IOHandler - try { - ModelStoreManagerRegistry.registerManager( - BrowserLocalStorage.URL_SCHEME, new BrowserLocalStorageManager()); - } catch (err) { - } - - // Register IndexedDB IOHandler - try { - ModelStoreManagerRegistry.registerManager( - BrowserIndexedDB.URL_SCHEME, new BrowserIndexedDBManager()); - } catch (err) { - } -} diff --git a/tfjs-master/tfjs-core/src/platforms/platform_browser_test.ts b/tfjs-master/tfjs-core/src/platforms/platform_browser_test.ts deleted file mode 100644 index 6b7661a3d..000000000 --- a/tfjs-master/tfjs-core/src/platforms/platform_browser_test.ts +++ /dev/null @@ -1,165 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {env} from '../environment'; -import {BROWSER_ENVS, describeWithFlags} from '../jasmine_util'; - -import {PlatformBrowser} from './platform_browser'; - -describeWithFlags('PlatformBrowser', BROWSER_ENVS, async () => { - it('fetch calls window.fetch', async () => { - const response = new Response(); - spyOn(self, 'fetch').and.returnValue(Promise.resolve(response)); - const platform = new PlatformBrowser(); - - await platform.fetch('test/url', {method: 'GET'}); - - expect(self.fetch).toHaveBeenCalledWith('test/url', {method: 'GET'}); - }); - - it('now should use performance.now', async () => { - const platform = new PlatformBrowser(); - - const ms = 1234567; - spyOn(performance, 'now').and.returnValue(ms); - expect(platform.now()).toEqual(ms); - }); - - it('encodeUTF8 single string', () => { - const platform = new PlatformBrowser(); - const bytes = platform.encode('hello', 'utf-8'); - expect(bytes.length).toBe(5); - expect(bytes).toEqual(new Uint8Array([104, 101, 108, 108, 111])); - }); - - it('encodeUTF8 two strings delimited', () => { - const platform = new PlatformBrowser(); - const bytes = platform.encode('hello\x00world', 'utf-8'); - expect(bytes.length).toBe(11); - expect(bytes).toEqual( - new Uint8Array([104, 101, 108, 108, 111, 0, 119, 111, 114, 108, 100])); - }); - - it('encodeUTF8 cyrillic', () => { - const platform = new PlatformBrowser(); - const bytes = platform.encode('Здраво', 'utf-8'); - expect(bytes.length).toBe(12); - expect(bytes).toEqual(new Uint8Array( - [208, 151, 208, 180, 209, 128, 208, 176, 208, 178, 208, 190])); - }); - - it('decode single string', () => { - const platform = new PlatformBrowser(); - const s = - platform.decode(new Uint8Array([104, 101, 108, 108, 111]), 'utf-8'); - expect(s.length).toBe(5); - expect(s).toEqual('hello'); - }); - - it('decode two strings delimited', () => { - const platform = new PlatformBrowser(); - const s = platform.decode( - new Uint8Array([104, 101, 108, 108, 111, 0, 119, 111, 114, 108, 100]), - 'utf-8'); - expect(s.length).toBe(11); - expect(s).toEqual('hello\x00world'); - }); - - it('decode cyrillic', () => { - const platform = new PlatformBrowser(); - const s = platform.decode( - new Uint8Array( - [208, 151, 208, 180, 209, 128, 208, 176, 208, 178, 208, 190]), - 'utf-8'); - expect(s.length).toBe(6); - expect(s).toEqual('Здраво'); - }); -}); - -describeWithFlags('setTimeout', BROWSER_ENVS, () => { - const totalCount = 100; - // Skip the first few samples because the browser does not clamp the timeout - const skipCount = 5; - - it('setTimeout', (done) => { - let count = 0; - let startTime = performance.now(); - let totalTime = 0; - setTimeout(_testSetTimeout, 0); - - function _testSetTimeout() { - const endTime = performance.now(); - count++; - if (count > skipCount) { - totalTime += endTime - startTime; - } - if (count === totalCount) { - const averageTime = totalTime / (totalCount - skipCount); - console.log(`averageTime of setTimeout is ${averageTime} ms`); - expect(averageTime).toBeGreaterThan(4); - done(); - return; - } - startTime = performance.now(); - setTimeout(_testSetTimeout, 0); - } - }); - - it('setTimeoutCustom', (done) => { - let count = 0; - let startTime = performance.now(); - let totalTime = 0; - let originUseSettimeoutcustom: boolean; - - originUseSettimeoutcustom = env().getBool('USE_SETTIMEOUTCUSTOM'); - env().set('USE_SETTIMEOUTCUSTOM', true); - env().platform.setTimeoutCustom(_testSetTimeoutCustom, 0); - - function _testSetTimeoutCustom() { - const endTime = performance.now(); - count++; - if (count > skipCount) { - totalTime += endTime - startTime; - } - if (count === totalCount) { - const averageTime = totalTime / (totalCount - skipCount); - console.log(`averageTime of setTimeoutCustom is ${averageTime} ms`); - expect(averageTime).toBeLessThan(4); - done(); - env().set('USE_SETTIMEOUTCUSTOM', originUseSettimeoutcustom); - return; - } - startTime = performance.now(); - env().platform.setTimeoutCustom(_testSetTimeoutCustom, 0); - } - }); - - it('isTypedArray returns false if not a typed array', () => { - const platform = new PlatformBrowser(); - expect(platform.isTypedArray([1, 2, 3])).toBeFalse(); - }); - - for (const typedArrayConstructor of [Float32Array, Int32Array, Uint8Array, - Uint8ClampedArray]) { - it(`isTypedArray returns true if it is a ${typedArrayConstructor.name}`, - () => { - const platform = new PlatformBrowser(); - const array = new typedArrayConstructor([1,2,3]); - expect(platform.isTypedArray(array)).toBeTrue(); - }); - } -}); diff --git a/tfjs-master/tfjs-core/src/platforms/platform_node.ts b/tfjs-master/tfjs-core/src/platforms/platform_node.ts deleted file mode 100644 index 361eca12f..000000000 --- a/tfjs-master/tfjs-core/src/platforms/platform_node.ts +++ /dev/null @@ -1,93 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {env} from '../environment'; -import {Platform} from './platform'; - -// We are wrapping this within an object so it can be stubbed by Jasmine. -export const getNodeFetch = { - // tslint:disable-next-line:no-require-imports - importFetch: () => require('node-fetch') -}; - -type FetchFn = (url: string, init?: RequestInit) => Promise; -let systemFetch: FetchFn; -// These getters and setters are for testing so we don't export a mutable -// variable. -export function resetSystemFetch() { - systemFetch = null; -} -export function setSystemFetch(fetchFn: FetchFn) { - systemFetch = fetchFn; -} -export function getSystemFetch(): FetchFn { - return systemFetch; -} - -export class PlatformNode implements Platform { - private textEncoder: TextEncoder; - // tslint:disable-next-line:no-any - util: any; - - constructor() { - // tslint:disable-next-line:no-require-imports - this.util = require('util'); - // According to the spec, the built-in encoder can do only UTF-8 encoding. - // https://developer.mozilla.org/en-US/docs/Web/API/TextEncoder/TextEncoder - this.textEncoder = new this.util.TextEncoder(); - } - - fetch(path: string, requestInits?: RequestInit): Promise { - if (env().global.fetch != null) { - return env().global.fetch(path, requestInits); - } - - if (systemFetch == null) { - systemFetch = getNodeFetch.importFetch(); - } - return systemFetch(path, requestInits); - } - - now(): number { - const time = process.hrtime(); - return time[0] * 1000 + time[1] / 1000000; - } - - encode(text: string, encoding: string): Uint8Array { - if (encoding !== 'utf-8' && encoding !== 'utf8') { - throw new Error( - `Node built-in encoder only supports utf-8, but got ${encoding}`); - } - return this.textEncoder.encode(text); - } - decode(bytes: Uint8Array, encoding: string): string { - if (bytes.length === 0) { - return ''; - } - return new this.util.TextDecoder(encoding).decode(bytes); - } - isTypedArray(a: unknown): a is Float32Array | Int32Array | Uint8Array - | Uint8ClampedArray { - return this.util.types.isFloat32Array(a) - || this.util.types.isInt32Array(a) - || this.util.types.isUint8Array(a) - || this.util.types.isUint8ClampedArray(a); - } -} - -if (env().get('IS_NODE') && !env().get('IS_BROWSER')) { - env().setPlatform('node', new PlatformNode()); -} diff --git a/tfjs-master/tfjs-core/src/platforms/platform_node_test.ts b/tfjs-master/tfjs-core/src/platforms/platform_node_test.ts deleted file mode 100644 index 8e7d5808f..000000000 --- a/tfjs-master/tfjs-core/src/platforms/platform_node_test.ts +++ /dev/null @@ -1,157 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from '../index'; -import * as platform_node from './platform_node'; -import {PlatformNode} from './platform_node'; -import * as vm from 'node:vm'; - -describe('PlatformNode', () => { - it('fetch should use global.fetch if defined', async () => { - const globalFetch = tf.env().global.fetch; - - spyOn(tf.env().global, 'fetch').and.returnValue(() => {}); - - const platform = new PlatformNode(); - - await platform.fetch('test/url', {method: 'GET'}); - - expect(tf.env().global.fetch).toHaveBeenCalledWith('test/url', { - method: 'GET' - }); - - tf.env().global.fetch = globalFetch; - }); - - it('fetch should use node-fetch with tf.env().global.fetch is null', - async () => { - const globalFetch = tf.env().global.fetch; - tf.env().global.fetch = null; - - const platform = new PlatformNode(); - - const savedFetch = platform_node.getSystemFetch(); - - // Null out the system fetch so we force it to require node-fetch. - platform_node.resetSystemFetch(); - - const testFetch = {fetch: (url: string, init: RequestInit) => () => {}}; - - // Mock the actual fetch call. - spyOn(testFetch, 'fetch').and.returnValue(() => {}); - // Mock the import to override the real require of node-fetch. - spyOn(platform_node.getNodeFetch, 'importFetch') - .and.callFake( - () => (url: string, init: RequestInit) => - testFetch.fetch(url, init)); - - await platform.fetch('test/url', {method: 'GET'}); - - expect(platform_node.getNodeFetch.importFetch).toHaveBeenCalled(); - expect(testFetch.fetch).toHaveBeenCalledWith('test/url', { - method: 'GET' - }); - - platform_node.setSystemFetch(savedFetch); - tf.env().global.fetch = globalFetch; - }); - - it('now should use process.hrtime', async () => { - const time: [number, number] = [100, 200]; - spyOn(process, 'hrtime').and.returnValue(time); - expect(tf.env().platform.now()).toEqual(time[0] * 1000 + time[1] / 1000000); - }); - - it('encodeUTF8 single string', () => { - const platform = new PlatformNode(); - const bytes = platform.encode('hello', 'utf-8'); - expect(bytes.length).toBe(5); - expect(bytes).toEqual(new Uint8Array([104, 101, 108, 108, 111])); - }); - - it('encodeUTF8 two strings delimited', () => { - const platform = new PlatformNode(); - const bytes = platform.encode('hello\x00world', 'utf-8'); - expect(bytes.length).toBe(11); - expect(bytes).toEqual( - new Uint8Array([104, 101, 108, 108, 111, 0, 119, 111, 114, 108, 100])); - }); - - it('encodeUTF8 cyrillic', () => { - const platform = new PlatformNode(); - const bytes = platform.encode('Здраво', 'utf-8'); - expect(bytes.length).toBe(12); - expect(bytes).toEqual(new Uint8Array( - [208, 151, 208, 180, 209, 128, 208, 176, 208, 178, 208, 190])); - }); - - it('decode single string', () => { - const platform = new PlatformNode(); - const s = - platform.decode(new Uint8Array([104, 101, 108, 108, 111]), 'utf8'); - expect(s.length).toBe(5); - expect(s).toEqual('hello'); - }); - - it('decode two strings delimited', () => { - const platform = new PlatformNode(); - const s = platform.decode( - new Uint8Array([104, 101, 108, 108, 111, 0, 119, 111, 114, 108, 100]), - 'utf8'); - expect(s.length).toBe(11); - expect(s).toEqual('hello\x00world'); - }); - - it('decode cyrillic', () => { - const platform = new PlatformNode(); - const s = platform.decode( - new Uint8Array( - [208, 151, 208, 180, 209, 128, 208, 176, 208, 178, 208, 190]), - 'utf8'); - expect(s.length).toBe(6); - expect(s).toEqual('Здраво'); - }); - - describe('isTypedArray', () => { - let platform: PlatformNode; - beforeEach(() => { - platform = new PlatformNode(); - }); - - it('returns false if not a typed array', () => { - expect(platform.isTypedArray([1, 2, 3])).toBeFalse(); - }); - - for (const typedArrayConstructor of [Float32Array, Int32Array, Uint8Array, - Uint8ClampedArray]) { - it(`returns true if it is a ${typedArrayConstructor.name}`, - () => { - const array = new typedArrayConstructor([1,2,3]); - expect(platform.isTypedArray(array)).toBeTrue(); - }); - } - - it('works on values created in a new node context', async () => { - const array = await new Promise((resolve) => { - const code = `resolve(new Uint8Array([1, 2, 3]));`; - vm.runInNewContext(code, {resolve}); - }); - - expect(platform.isTypedArray(array)).toBeTrue(); - }); - }); -}); diff --git a/tfjs-master/tfjs-core/src/profiler.ts b/tfjs-master/tfjs-core/src/profiler.ts deleted file mode 100644 index 8e315bd52..000000000 --- a/tfjs-master/tfjs-core/src/profiler.ts +++ /dev/null @@ -1,142 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {BackendTimer, BackendTimingInfo} from './backends/backend'; -import {env} from './environment'; -import {Tensor} from './tensor'; -import {NamedTensorMap} from './tensor_types'; -import {DataType, DataTypeMap, TypedArray} from './types'; -import * as util from './util'; - -export type KernelProfile = { - kernelName: string, - outputs: Tensor[], - inputs: NamedTensorMap, - timeMs: Promise, - extraInfo: Promise -}; - -export class Profiler { - constructor(private backendTimer: BackendTimer, private logger?: Logger) { - if (logger == null) { - this.logger = new Logger(); - } - } - - profileKernel(kernelName: string, inputs: NamedTensorMap, f: () => Tensor[]): - KernelProfile { - let outputs: Tensor[]; - const holdResultWrapperFn = () => { - outputs = f(); - }; - let timer: Promise; - const start = util.now(); - if (this.backendTimer.timerAvailable()) { - timer = this.backendTimer.time(holdResultWrapperFn); - } else { - holdResultWrapperFn(); - for (const output of outputs) { - output.dataSync(); - } - timer = Promise.resolve({kernelMs: util.now() - start}); - } - if (env().getBool('CHECK_COMPUTATION_FOR_ERRORS')) { - for (let i = 0; i < outputs.length; i++) { - const output = outputs[i]; - // Dangling promise here because we don't want to propagate up - // asynchronicity. - output.data().then(tensorVals => { - checkComputationForErrors(tensorVals, output.dtype, kernelName); - }); - } - } - - const kernelProfile = { - kernelName, - outputs, - inputs, - timeMs: timer.then(timing => timing.kernelMs), - extraInfo: timer.then( - timing => timing.getExtraProfileInfo != null ? - timing.getExtraProfileInfo() : - '') - }; - return kernelProfile; - } - - logKernelProfile(kernelProfile: KernelProfile): void { - const {kernelName, outputs, timeMs, inputs, extraInfo} = kernelProfile; - - outputs.forEach(result => { - Promise.all([result.data(), timeMs, extraInfo]).then(valueContainer => { - this.logger.logKernelProfile( - kernelName, result, valueContainer[0], valueContainer[1], inputs, - valueContainer[2]); - }); - }); - } -} - -export function checkComputationForErrors( - vals: DataTypeMap[D], dtype: D, kernelName: string): boolean { - if (dtype !== 'float32') { - // Only floating point computations will generate NaN values - return false; - } - for (let i = 0; i < vals.length; i++) { - const num = vals[i] as number; - if (isNaN(num) || !isFinite(num)) { - // Throwing custom exception so behavior is testable. - console.warn(`Found ${num} in the result of '${kernelName}'`); - return true; - } - } - return false; -} - -export class Logger { - logKernelProfile( - name: string, result: Tensor, vals: TypedArray, - timeMs: number|{error: string}, inputs: NamedTensorMap, - extraInfo?: string) { - const time = typeof timeMs === 'number' ? util.rightPad(`${timeMs}ms`, 9) : - timeMs['error']; - const paddedName = util.rightPad(name, 25); - const rank = result.rank; - const size = result.size; - const shape = util.rightPad(result.shape.toString(), 14); - let inputShapesDescription = ''; - - for (const name in inputs) { - const input = inputs[name]; - if (input != null) { - // The input might be a non-tensor (e.g HTMLImageElement), in which case - // we claim the output shape as input shape. - const inputShape = input.shape || result.shape; - const inputRank = inputShape.length; - inputShapesDescription += - `${name}: ${inputRank}D ${inputRank > 0 ? inputShape : ''} `; - } - } - - console.log( - `%c${paddedName}\t%c${time}\t%c${rank}D ${shape}\t%c${size}\t%c${ - inputShapesDescription}\t%c${extraInfo}`, - 'font-weight:bold', 'color:red', 'color:blue', 'color: orange', - 'color: green', 'color: steelblue'); - } -} diff --git a/tfjs-master/tfjs-core/src/profiler_test.ts b/tfjs-master/tfjs-core/src/profiler_test.ts deleted file mode 100644 index e97b643f8..000000000 --- a/tfjs-master/tfjs-core/src/profiler_test.ts +++ /dev/null @@ -1,248 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {BackendTimer, BackendTimingInfo} from './backends/backend'; -import * as tf from './index'; -import {ALL_ENVS, describeWithFlags, SYNC_BACKEND_ENVS} from './jasmine_util'; -import {checkComputationForErrors, KernelProfile, Logger, Profiler} from './profiler'; -import {Tensor} from './tensor'; -import {NamedTensorMap} from './tensor_types'; -import {TypedArray} from './types'; - -class TestBackendTimer implements BackendTimer { - private counter = 1; - constructor( - private delayMs: number, private queryTimeMs: number, - private extraInfo: string) {} - - timerAvailable() { - return true; - } - - async time(query: () => void): Promise { - query(); - const kernelMs = await new Promise( - resolve => setTimeout( - () => resolve(this.queryTimeMs * this.counter++), this.delayMs)); - return {kernelMs, getExtraProfileInfo: () => this.extraInfo}; - } -} - -class TestLogger extends Logger { - override logKernelProfile( - name: string, result: Tensor, vals: TypedArray, timeMs: number) {} -} - -function promiseCheckWrapper(acturalValPromise: Promise<{}>, truthVal: {}) { - return acturalValPromise.then(acturalVal => { - expect(acturalVal).toEqual(truthVal); - }); -} - -function checkKernelProfile(acturalVal: KernelProfile, truthVal: { - kernelName: string, - outputs: Tensor[], - timeMs: number|{error: string}, - inputs: NamedTensorMap, - extraInfo: string -}) { - expect(acturalVal.kernelName).toBe(truthVal.kernelName); - expect(acturalVal.inputs).toBe(truthVal.inputs); - acturalVal.outputs.forEach((output, index) => { - expect(output).toBe(truthVal.outputs[index]); - }); - - const promiseContainer = [ - promiseCheckWrapper(acturalVal.timeMs, truthVal.timeMs), - promiseCheckWrapper(acturalVal.extraInfo, truthVal.extraInfo), - ]; - return Promise.all(promiseContainer); -} - -describeWithFlags('profiler.Profiler', SYNC_BACKEND_ENVS, () => { - it('profiles simple function', doneFn => { - const delayMs = 5; - const queryTimeMs = 10; - const inputs = {'x': tf.tensor1d([1])}; - const extraInfo = ''; - const timer = new TestBackendTimer(delayMs, queryTimeMs, extraInfo); - const logger = new TestLogger(); - const profiler = new Profiler(timer, logger); - - spyOn(timer, 'time').and.callThrough(); - spyOn(logger, 'logKernelProfile').and.callThrough(); - - const timeSpy = timer.time as jasmine.Spy; - - let kernelCalled = false; - const result = 1; - const resultScalar = tf.scalar(result); - - const kernelProfile = profiler.profileKernel('MatMul', inputs, () => { - kernelCalled = true; - return [resultScalar]; - }); - setTimeout(() => { - expect(timeSpy.calls.count()).toBe(1); - expect(kernelCalled).toBe(true); - - checkKernelProfile(kernelProfile, { - kernelName: 'MatMul', - outputs: [resultScalar], - timeMs: queryTimeMs, - inputs, - extraInfo, - }).then(() => doneFn()); - }, delayMs * 2); - }); - - it('profiles nested kernel with optional inputs', doneFn => { - const delayMs = 5; - const queryTimeMs = 10; - const inputs: {'x': tf.Tensor, - 'bias': null} = {'x': tf.tensor1d([1]), 'bias': null}; - const extraInfo = ''; - const timer = new TestBackendTimer(delayMs, queryTimeMs, extraInfo); - const logger = new TestLogger(); - const profiler = new Profiler(timer, logger); - - spyOn(timer, 'time').and.callThrough(); - spyOn(logger, 'logKernelProfile').and.callThrough(); - const timeSpy = timer.time as jasmine.Spy; - - let matmulKernelCalled = false; - let maxKernelCalled = false; - const result = 1; - const resultScalar = tf.scalar(result); - - let innerKernelProfile: KernelProfile; - const outerKernelProfile = profiler.profileKernel('MatMul', inputs, () => { - innerKernelProfile = profiler.profileKernel('Max', inputs, () => { - maxKernelCalled = true; - return [resultScalar]; - }); - matmulKernelCalled = true; - return innerKernelProfile.outputs; - }); - - setTimeout(() => { - expect(timeSpy.calls.count()).toBe(2); - expect(matmulKernelCalled).toBe(true); - expect(maxKernelCalled).toBe(true); - - const checkInnerKernelProfile = checkKernelProfile(innerKernelProfile, { - kernelName: 'Max', - outputs: [resultScalar], - timeMs: queryTimeMs, - inputs, - extraInfo - }); - const checkOuterKernelProfile = checkKernelProfile(outerKernelProfile, { - kernelName: 'MatMul', - outputs: [resultScalar], - timeMs: queryTimeMs * 2, - inputs, - extraInfo - }); - Promise.all([checkInnerKernelProfile, checkOuterKernelProfile]) - .then(() => doneFn()); - }, delayMs * 2); - }); - - it('log kernelProfile', doneFn => { - const delayMs = 5; - const queryTimeMs = 10; - const inputs = {'x': tf.tensor1d([1])}; - const extraInfo = ''; - const timer = new TestBackendTimer(delayMs, queryTimeMs, extraInfo); - const logger = new TestLogger(); - const profiler = new Profiler(timer, logger); - - spyOn(logger, 'logKernelProfile').and.callThrough(); - const logKernelProfileSpy = logger.logKernelProfile as jasmine.Spy; - - const result = 1; - const resultScalar = tf.scalar(result); - - const kernelProfiles = profiler.profileKernel('MatMul', inputs, () => { - return [resultScalar]; - }); - profiler.logKernelProfile(kernelProfiles); - - setTimeout(() => { - expect(logKernelProfileSpy.calls.count()).toBe(1); - - expect(logKernelProfileSpy.calls.first().args).toEqual([ - 'MatMul', resultScalar, new Float32Array([result]), queryTimeMs, inputs, - extraInfo - ]); - doneFn(); - }, delayMs * 2); - }); -}); - -describe('profiler.checkComputationForErrors', () => { - beforeAll(() => { - // Silence warnings. - spyOn(console, 'warn'); - }); - - it('Float32Array has NaN', () => { - expect(checkComputationForErrors( - new Float32Array([1, 2, 3, NaN, 4, 255]), 'float32', 'test')) - .toBe(true); - }); - - it('Float32Array has Infinity', () => { - expect( - checkComputationForErrors( - new Float32Array([1, 2, 3, Infinity, 4, 255]), 'float32', 'test')) - .toBe(true); - }); - - it('Float32Array no NaN', () => { - // Int32 and Bool NaNs should not trigger an error. - expect(checkComputationForErrors( - new Float32Array([1, 2, 3, -1, 4, 255]), 'float32', 'test')) - .toBe(false); - }); -}); - -describeWithFlags('profiler.Logger', ALL_ENVS, () => { - it('skips logging for undefined input node in input tensor map', () => { - const kernelName = 'FusedConv2D'; - const vals = new Float32Array(1); - const outputs = tf.tensor1d([1]); - const timeMs = 10; - const inputs: NamedTensorMap = { - 'x': tf.tensor1d([1]), - 'filter': tf.tensor1d([1]), - 'bias': tf.tensor1d([1]), - 'preluActivationWeights': undefined - }; - const extraInfo = ''; - const logger = new Logger(); - spyOn(console, 'log'); - const consoleLogSpy = console.log as jasmine.Spy; - - logger.logKernelProfile( - kernelName, outputs, vals, timeMs, inputs, extraInfo); - - expect(consoleLogSpy.calls.first().args) - .not.toContain('preluActivationWeights'); - }); -}); diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/abs.ts b/tfjs-master/tfjs-core/src/public/chained_ops/abs.ts deleted file mode 100644 index 0fcdeb5ea..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/abs.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// TODO update import path once op is modularized. -import {abs} from '../../ops/ops'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - abs(this: T): T; - } -} - -getGlobalTensorClass().prototype.abs = function(this: T) { - this.throwIfDisposed(); - return abs(this); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/acos.ts b/tfjs-master/tfjs-core/src/public/chained_ops/acos.ts deleted file mode 100644 index 85df1a43a..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/acos.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// TODO update import path once op is modularized. -import {acos} from '../../ops/ops'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - acos(this: T): T; - } -} - -getGlobalTensorClass().prototype.acos = function(this: T) { - this.throwIfDisposed(); - return acos(this); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/acosh.ts b/tfjs-master/tfjs-core/src/public/chained_ops/acosh.ts deleted file mode 100644 index 7d11985fa..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/acosh.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// TODO update import path once op is modularized. -import {acosh} from '../../ops/ops'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - acosh(this: T): T; - } -} - -getGlobalTensorClass().prototype.acosh = function(this: T) { - this.throwIfDisposed(); - return acosh(this); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/add.ts b/tfjs-master/tfjs-core/src/public/chained_ops/add.ts deleted file mode 100644 index 71b14e459..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/add.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {add} from '../../ops/add'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank, TensorLike} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - add(b: Tensor|TensorLike): T; - } -} - -getGlobalTensorClass().prototype.add = function( - b: Tensor|TensorLike): T { - this.throwIfDisposed(); - return add(this, b); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/all.ts b/tfjs-master/tfjs-core/src/public/chained_ops/all.ts deleted file mode 100644 index 946a7a244..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/all.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {all} from '../../ops/all'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - all(this: T, axis?: number|number[], keepDims?: boolean): - T; - } -} - -getGlobalTensorClass().prototype.all = function( - this: T, axis?: number|number[], keepDims?: boolean): T { - this.throwIfDisposed(); - return all(this, axis, keepDims); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/any.ts b/tfjs-master/tfjs-core/src/public/chained_ops/any.ts deleted file mode 100644 index 52b54c0a9..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/any.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {any} from '../../ops/any'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - any(this: T, axis?: number|number[], keepDims?: boolean): - T; - } -} - -getGlobalTensorClass().prototype.any = function( - this: T, axis?: number|number[], keepDims?: boolean): T { - this.throwIfDisposed(); - return any(this, axis, keepDims); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/arg_max.ts b/tfjs-master/tfjs-core/src/public/chained_ops/arg_max.ts deleted file mode 100644 index 71140c0fd..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/arg_max.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {argMax} from '../../ops/arg_max'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - argMax(axis?: number): T; - } -} - -getGlobalTensorClass().prototype.argMax = function( - axis?: number): T { - this.throwIfDisposed(); - return argMax(this, axis); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/arg_min.ts b/tfjs-master/tfjs-core/src/public/chained_ops/arg_min.ts deleted file mode 100644 index ef8c6c75d..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/arg_min.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {argMin} from '../../ops/arg_min'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - argMin(axis?: number): T; - } -} - -getGlobalTensorClass().prototype.argMin = function( - axis: number): T { - this.throwIfDisposed(); - return argMin(this, axis); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/as1d.ts b/tfjs-master/tfjs-core/src/public/chained_ops/as1d.ts deleted file mode 100644 index a8fdca330..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/as1d.ts +++ /dev/null @@ -1,35 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {reshape} from '../../ops/reshape'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - as1D(): Tensor1D; - } -} - -/** - * Converts a `tf.Tensor` to a `tf.Tensor1D`. - * @doc {heading: 'Tensors', subheading: 'Classes'} - */ -getGlobalTensorClass().prototype.as1D = function(): T { - this.throwIfDisposed(); - return reshape(this, [this.size]) as T; -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/as2d.ts b/tfjs-master/tfjs-core/src/public/chained_ops/as2d.ts deleted file mode 100644 index 2ad763b92..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/as2d.ts +++ /dev/null @@ -1,39 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {reshape} from '../../ops/reshape'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - as2D(rows: number, columns: number): Tensor2D; - } -} - -/** - * Converts a `tf.Tensor` to a `tf.Tensor2D`. - * - * @param rows Number of rows in `tf.Tensor2D`. - * @param columns Number of columns in `tf.Tensor2D`. - * @doc {heading: 'Tensors', subheading: 'Classes'} - */ -getGlobalTensorClass().prototype.as2D = function( - rows: number, columns: number): T { - this.throwIfDisposed(); - return reshape(this, [rows, columns]) as T; -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/as3d.ts b/tfjs-master/tfjs-core/src/public/chained_ops/as3d.ts deleted file mode 100644 index 8193f81bf..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/as3d.ts +++ /dev/null @@ -1,41 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {reshape} from '../../ops/reshape'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - as3D(rows: number, columns: number, depth: number): - Tensor3D; - } -} - -/** - * Converts a `tf.Tensor` to a `tf.Tensor3D`. - * - * @param rows Number of rows in `tf.Tensor3D`. - * @param columns Number of columns in `tf.Tensor3D`. - * @param depth Depth of `tf.Tensor3D`. - * @doc {heading: 'Tensors', subheading: 'Classes'} - */ -getGlobalTensorClass().prototype.as3D = function( - rows: number, columns: number, depth: number): T { - this.throwIfDisposed(); - return reshape(this, [rows, columns, depth]) as T; -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/as4d.ts b/tfjs-master/tfjs-core/src/public/chained_ops/as4d.ts deleted file mode 100644 index 877902eca..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/as4d.ts +++ /dev/null @@ -1,42 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {reshape} from '../../ops/reshape'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - as4D( - rows: number, columns: number, depth: number, depth2: number): Tensor4D; - } -} - -/** - * Converts a `tf.Tensor` to a `tf.Tensor4D`. - * - * @param rows Number of rows in `tf.Tensor4D`. - * @param columns Number of columns in `tf.Tensor4D`. - * @param depth Depth of `tf.Tensor4D`. - * @param depth2 4th dimension of `tf.Tensor4D`. - * @doc {heading: 'Tensors', subheading: 'Classes'} - */ -getGlobalTensorClass().prototype.as4D = function( - rows: number, columns: number, depth: number, depth2: number): T { - this.throwIfDisposed(); - return reshape(this, [rows, columns, depth, depth2]) as T; -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/as5d.ts b/tfjs-master/tfjs-core/src/public/chained_ops/as5d.ts deleted file mode 100644 index 0ba0bd2f1..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/as5d.ts +++ /dev/null @@ -1,46 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {reshape} from '../../ops/reshape'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - as5D( - rows: number, columns: number, depth: number, depth2: number, - depth3: number): Tensor5D; - } -} - -/** - * Converts a `tf.Tensor` to a `tf.Tensor5D`. - * - * @param rows Number of rows in `tf.Tensor5D`. - * @param columns Number of columns in `tf.Tensor5D`. - * @param depth Depth of `tf.Tensor5D`. - * @param depth2 4th dimension of `tf.Tensor5D`. - * @param depth3 5th dimension of 'tf.Tensor5D' - * - * @doc {heading: 'Tensors', subheading: 'Classes'} - */ -getGlobalTensorClass().prototype.as5D = function( - rows: number, columns: number, depth: number, depth2: number, - depth3: number): T { - this.throwIfDisposed(); - return reshape(this, [rows, columns, depth, depth2, depth3]) as T; -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/as_scalar.ts b/tfjs-master/tfjs-core/src/public/chained_ops/as_scalar.ts deleted file mode 100644 index 1786cb3f2..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/as_scalar.ts +++ /dev/null @@ -1,38 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {reshape} from '../../ops/reshape'; -import {getGlobalTensorClass, Scalar, Tensor} from '../../tensor'; -import {Rank} from '../../types'; -import {assert} from '../../util'; - -declare module '../../tensor' { - interface Tensor { - asScalar(): Scalar; - } -} - -/** - * Converts a size-1 `tf.Tensor` to a `tf.Scalar`. - * @doc {heading: 'Tensors', subheading: 'Classes'} - */ -getGlobalTensorClass().prototype.asScalar = function(this: T): - Scalar { - this.throwIfDisposed(); - assert(this.size === 1, () => 'The array must have only 1 element.'); - return reshape(this, []); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/as_type.ts b/tfjs-master/tfjs-core/src/public/chained_ops/as_type.ts deleted file mode 100644 index 0de1b04e1..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/as_type.ts +++ /dev/null @@ -1,40 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// TODO update import path once op is modularized. -import {cast} from '../../ops/ops'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {DataType, Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - asType(this: T, dtype: DataType): T; - } -} - -/** - * Casts a `tf.Tensor` to a specified dtype. - * - * @param dtype Data-type to cast the tensor to. - * - * @doc {heading: 'Tensors', subheading: 'Classes'} - */ -getGlobalTensorClass().prototype.asType = function( - this: T, dtype: DataType): T { - this.throwIfDisposed(); - return cast(this, dtype); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/asin.ts b/tfjs-master/tfjs-core/src/public/chained_ops/asin.ts deleted file mode 100644 index 5e46de55f..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/asin.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// TODO update import path once op is modularized. -import {asin} from '../../ops/ops'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - asin(this: T): T; - } -} - -getGlobalTensorClass().prototype.asin = function(this: T): T { - this.throwIfDisposed(); - return asin(this); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/asinh.ts b/tfjs-master/tfjs-core/src/public/chained_ops/asinh.ts deleted file mode 100644 index 962b442fc..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/asinh.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// TODO update import path once op is modularized. -import {asinh} from '../../ops/ops'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - asinh(this: T): T; - } -} - -getGlobalTensorClass().prototype.asinh = function(this: T): - T { - this.throwIfDisposed(); - return asinh(this); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/atan.ts b/tfjs-master/tfjs-core/src/public/chained_ops/atan.ts deleted file mode 100644 index bbe4ac6a5..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/atan.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// TODO update import path once op is modularized. -import {atan} from '../../ops/ops'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - atan(this: T): T; - } -} - -getGlobalTensorClass().prototype.atan = function(this: T): T { - this.throwIfDisposed(); - return atan(this); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/atan2.ts b/tfjs-master/tfjs-core/src/public/chained_ops/atan2.ts deleted file mode 100644 index a979a9f2e..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/atan2.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {atan2} from '../../ops/atan2'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank, TensorLike} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - atan2(b: Tensor|TensorLike): T; - } -} - -getGlobalTensorClass().prototype.atan2 = function( - b: Tensor|TensorLike): T { - this.throwIfDisposed(); - return atan2(this, b); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/atanh.ts b/tfjs-master/tfjs-core/src/public/chained_ops/atanh.ts deleted file mode 100644 index a52cf0d1f..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/atanh.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// TODO update import path once op is modularized. -import {atanh} from '../../ops/ops'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - atanh(this: T): T; - } -} - -getGlobalTensorClass().prototype.atanh = function(this: T): - T { - this.throwIfDisposed(); - return atanh(this); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/avg_pool.ts b/tfjs-master/tfjs-core/src/public/chained_ops/avg_pool.ts deleted file mode 100644 index d928e300d..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/avg_pool.ts +++ /dev/null @@ -1,39 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {ExplicitPadding} from '../../ops/conv_util'; -import {avgPool} from '../../ops/avg_pool'; -import {getGlobalTensorClass, Tensor3D, Tensor4D} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - avgPool( - filterSize: [number, number]|number, strides: [number, number]|number, - pad: 'valid'|'same'|number|ExplicitPadding, - dimRoundingMode?: 'floor'|'round'|'ceil'): T; - } -} - -getGlobalTensorClass().prototype.avgPool = - function( - this: T, filterSize: [number, number]|number, - strides: [number, number]|number, - pad: 'valid'|'same'|number|ExplicitPadding, - dimRoundingMode?: 'floor'|'round'|'ceil'): T { - this.throwIfDisposed(); - return avgPool(this, filterSize, strides, pad, dimRoundingMode); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/batch_to_space_nd.ts b/tfjs-master/tfjs-core/src/public/chained_ops/batch_to_space_nd.ts deleted file mode 100644 index b23460a06..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/batch_to_space_nd.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {batchToSpaceND} from '../../ops/batch_to_space_nd'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - batchToSpaceND(blockShape: number[], crops: number[][]): - Tensor; - } -} - -getGlobalTensorClass().prototype.batchToSpaceND = function( - blockShape: number[], crops: number[][]): Tensor { - this.throwIfDisposed(); - return batchToSpaceND(this, blockShape, crops); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/batchnorm.ts b/tfjs-master/tfjs-core/src/public/chained_ops/batchnorm.ts deleted file mode 100644 index 0a006632f..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/batchnorm.ts +++ /dev/null @@ -1,40 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {batchNorm} from '../../ops/batchnorm'; -import {getGlobalTensorClass, Tensor, Tensor1D} from '../../tensor'; -import {Rank, TensorLike} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - batchNorm( - mean: Tensor|Tensor1D|TensorLike, - variance: Tensor|Tensor1D|TensorLike, - offset?: Tensor|Tensor1D|TensorLike, - scale?: Tensor|Tensor1D|TensorLike, - varianceEpsilon?: number): Tensor; - } -} - -getGlobalTensorClass().prototype.batchNorm = function( - mean: Tensor|Tensor1D|TensorLike, - variance: Tensor|Tensor1D|TensorLike, - offset?: Tensor|Tensor1D|TensorLike, - scale?: Tensor|Tensor1D|TensorLike, - varianceEpsilon?: number): Tensor { - this.throwIfDisposed(); - return batchNorm(this, mean, variance, offset, scale, varianceEpsilon); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/broadcast_to.ts b/tfjs-master/tfjs-core/src/public/chained_ops/broadcast_to.ts deleted file mode 100644 index 90afc691b..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/broadcast_to.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {broadcastTo} from '../../ops/broadcast_to'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank, ShapeMap} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - broadcastTo(shape: ShapeMap[R]): Tensor; - } -} - -getGlobalTensorClass().prototype.broadcastTo = function( - shape: ShapeMap[R]): Tensor { - this.throwIfDisposed(); - return broadcastTo(this, shape); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/cast.ts b/tfjs-master/tfjs-core/src/public/chained_ops/cast.ts deleted file mode 100644 index 1b9988384..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/cast.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// TODO update import path once op is modularized. -import {cast} from '../../ops/ops'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {DataType, Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - cast(dtype: DataType): T; - } -} - -getGlobalTensorClass().prototype.cast = function( - dtype: DataType): T { - this.throwIfDisposed(); - return cast(this, dtype) as T; -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/ceil.ts b/tfjs-master/tfjs-core/src/public/chained_ops/ceil.ts deleted file mode 100644 index 80e3feed5..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/ceil.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// TODO update import path once op is modularized. -import {ceil} from '../../ops/ops'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - ceil(this: T): T; - } -} - -getGlobalTensorClass().prototype.ceil = function(this: T): T { - this.throwIfDisposed(); - return ceil(this); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/clip_by_value.ts b/tfjs-master/tfjs-core/src/public/chained_ops/clip_by_value.ts deleted file mode 100644 index e51fb4ba1..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/clip_by_value.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// TODO update import path once op is modularized. -import {clipByValue} from '../../ops/ops'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - clipByValue(min: number, max: number): Tensor; - } -} - -getGlobalTensorClass().prototype.clipByValue = function( - min: number, max: number): T { - this.throwIfDisposed(); - return clipByValue(this, min, max) as T; -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/concat.ts b/tfjs-master/tfjs-core/src/public/chained_ops/concat.ts deleted file mode 100644 index 7975053ad..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/concat.ts +++ /dev/null @@ -1,34 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {concat} from '../../ops/concat'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank, TensorLike} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - concat(tensors: T|Array, axis?: number): T; - } -} - -getGlobalTensorClass().prototype.concat = function( - x: T|Array, axis?: number): T { - this.throwIfDisposed(); - if (x instanceof Tensor) { - x = [x]; - } - return concat([this, ...x], axis) as T; -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/conv1d.ts b/tfjs-master/tfjs-core/src/public/chained_ops/conv1d.ts deleted file mode 100644 index 09755748a..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/conv1d.ts +++ /dev/null @@ -1,39 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {conv1d} from '../../ops/conv1d'; -import {ExplicitPadding} from '../../ops/conv_util'; -import {getGlobalTensorClass, Tensor2D, Tensor3D} from '../../tensor'; -import {Rank, TensorLike3D} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - conv1d( - filter: Tensor3D|TensorLike3D, stride: number, - pad: 'valid'|'same'|number|ExplicitPadding, dataFormat?: 'NWC'|'NCW', - dilation?: number, dimRoundingMode?: 'floor'|'round'|'ceil'): T; - } -} - -getGlobalTensorClass().prototype.conv1d = function( - filter: Tensor3D|TensorLike3D, stride: number, - pad: 'valid'|'same'|number|ExplicitPadding, dataFormat?: 'NWC'|'NCW', - dilation?: number, dimRoundingMode?: 'floor'|'round'|'ceil'): T { - this.throwIfDisposed(); - return conv1d( - this, filter, stride, pad, dataFormat, dilation, - dimRoundingMode) as T; -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/conv2d.ts b/tfjs-master/tfjs-core/src/public/chained_ops/conv2d.ts deleted file mode 100644 index 6e3aa1b65..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/conv2d.ts +++ /dev/null @@ -1,40 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {conv2d} from '../../ops/conv2d'; -import {getGlobalTensorClass, Tensor3D, Tensor4D} from '../../tensor'; -import {Rank, TensorLike4D} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - conv2d( - filter: Tensor4D|TensorLike4D, strides: [number, number]|number, - pad: 'valid'|'same'|number, dataFormat?: 'NHWC'|'NCHW', - dilations?: [number, number]|number, - dimRoundingMode?: 'floor'|'round'|'ceil'): T; - } -} - -getGlobalTensorClass().prototype.conv2d = function( - filter: Tensor4D|TensorLike4D, strides: [number, number]|number, - pad: 'valid'|'same'|number, dataFormat?: 'NHWC'|'NCHW', - dilations?: [number, number]|number, - dimRoundingMode?: 'floor'|'round'|'ceil'): T { - this.throwIfDisposed(); - return conv2d( - this, filter, strides, pad, dataFormat, dilations, - dimRoundingMode) as T; -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/conv2d_transpose.ts b/tfjs-master/tfjs-core/src/public/chained_ops/conv2d_transpose.ts deleted file mode 100644 index 92a994002..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/conv2d_transpose.ts +++ /dev/null @@ -1,40 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {conv2dTranspose} from '../../ops/conv2d_transpose'; -import {getGlobalTensorClass, Tensor3D, Tensor4D} from '../../tensor'; -import {Rank, TensorLike4D} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - conv2dTranspose( - filter: Tensor4D|TensorLike4D, - outputShape: [number, number, number, number]|[number, number, number], - strides: [number, number]|number, pad: 'valid'|'same'|number, - dimRoundingMode?: 'floor'|'round'|'ceil'): T; - } -} - -getGlobalTensorClass().prototype.conv2dTranspose = - function( - filter: Tensor4D|TensorLike4D, - outputShape: [number, number, number, number]|[number, number, number], - strides: [number, number]|number, pad: 'valid'|'same'|number, - dimRoundingMode?: 'floor'|'round'|'ceil'): T { - this.throwIfDisposed(); - return conv2dTranspose( - this, filter, outputShape, strides, pad, dimRoundingMode) as T; -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/cos.ts b/tfjs-master/tfjs-core/src/public/chained_ops/cos.ts deleted file mode 100644 index cfaf703ab..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/cos.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// TODO update import path once op is modularized. -import {cos} from '../../ops/ops'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - cos(this: T): T; - } -} - -getGlobalTensorClass().prototype.cos = function(this: T): T { - this.throwIfDisposed(); - return cos(this); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/cosh.ts b/tfjs-master/tfjs-core/src/public/chained_ops/cosh.ts deleted file mode 100644 index f625051f4..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/cosh.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// TODO update import path once op is modularized. -import {cosh} from '../../ops/ops'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - cosh(this: T): T; - } -} - -getGlobalTensorClass().prototype.cosh = function(this: T): T { - this.throwIfDisposed(); - return cosh(this); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/cumprod.ts b/tfjs-master/tfjs-core/src/public/chained_ops/cumprod.ts deleted file mode 100644 index 2f7b7a6ae..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/cumprod.ts +++ /dev/null @@ -1,38 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the 'License'); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import { cumprod } from '../../ops/cumprod'; -import { getGlobalTensorClass, Tensor } from '../../tensor'; -import { Rank } from '../../types'; - -declare module '../../tensor' { - interface Tensor { - cumprod( - axis?: number, - exclusive?: boolean, - reverse?: boolean - ): Tensor; - } -} - -getGlobalTensorClass().prototype.cumprod = function ( - axis?: number, - exclusive?: boolean, - reverse?: boolean -): Tensor { - this.throwIfDisposed(); - return cumprod(this, axis, exclusive, reverse); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/cumsum.ts b/tfjs-master/tfjs-core/src/public/chained_ops/cumsum.ts deleted file mode 100644 index ae61f2db1..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/cumsum.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {cumsum} from '../../ops/cumsum'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - cumsum( - axis?: number, exclusive?: boolean, reverse?: boolean): Tensor; - } -} - -getGlobalTensorClass().prototype.cumsum = function( - axis?: number, exclusive?: boolean, reverse?: boolean): Tensor { - this.throwIfDisposed(); - return cumsum(this, axis, exclusive, reverse); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/depth_to_space.ts b/tfjs-master/tfjs-core/src/public/chained_ops/depth_to_space.ts deleted file mode 100644 index 5d7c07bda..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/depth_to_space.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {depthToSpace} from '../../ops/depth_to_space'; -import {getGlobalTensorClass, Tensor4D} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - depthToSpace( - blockSize: number, dataFormat: 'NHWC'|'NCHW'): T; - } -} - -getGlobalTensorClass().prototype.depthToSpace = function( - blockSize: number, dataFormat: 'NHWC'|'NCHW'): T { - this.throwIfDisposed(); - return depthToSpace(this, blockSize, dataFormat) as T; -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/depthwise_conv2d.ts b/tfjs-master/tfjs-core/src/public/chained_ops/depthwise_conv2d.ts deleted file mode 100644 index 1fbfa161c..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/depthwise_conv2d.ts +++ /dev/null @@ -1,41 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {depthwiseConv2d} from '../../ops/depthwise_conv2d'; -import {getGlobalTensorClass, Tensor3D, Tensor4D} from '../../tensor'; -import {Rank, TensorLike4D} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - depthwiseConv2d( - filter: Tensor4D|TensorLike4D, strides: [number, number]|number, - pad: 'valid'|'same'|number, dataFormat?: 'NHWC'|'NCHW', - dilations?: [number, number]|number, - dimRoundingMode?: 'floor'|'round'|'ceil'): T; - } -} - -getGlobalTensorClass().prototype.depthwiseConv2d = - function( - filter: Tensor4D|TensorLike4D, strides: [number, number]|number, - pad: 'valid'|'same'|number, dataFormat?: 'NHWC'|'NCHW', - dilations?: [number, number]|number, - dimRoundingMode?: 'floor'|'round'|'ceil'): T { - this.throwIfDisposed(); - return depthwiseConv2d( - this, filter, strides, pad, dataFormat, dilations, - dimRoundingMode) as T; -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/dilation2d.ts b/tfjs-master/tfjs-core/src/public/chained_ops/dilation2d.ts deleted file mode 100644 index cdac3522e..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/dilation2d.ts +++ /dev/null @@ -1,37 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {dilation2d} from '../../ops/dilation2d'; -import {getGlobalTensorClass, Tensor3D, Tensor4D} from '../../tensor'; -import {Rank, TensorLike3D} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - dilation2d( - filter: Tensor3D|TensorLike3D, strides: [number, number]|number, - pad: 'valid'|'same', dilations?: [number, number]|number, - dataFormat?: 'NHWC'): T; - } -} - -getGlobalTensorClass().prototype.dilation2d = - function( - filter: Tensor3D|TensorLike3D, strides: [number, number]|number, - pad: 'valid'|'same', dilations?: [number, number]|number, - dataFormat?: 'NHWC'): T { - this.throwIfDisposed(); - return dilation2d(this, filter, strides, pad, dilations, dataFormat) as T; -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/div.ts b/tfjs-master/tfjs-core/src/public/chained_ops/div.ts deleted file mode 100644 index c4d6b595a..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/div.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {div} from '../../ops/div'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank, TensorLike} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - div(b: Tensor|TensorLike): T; - } -} - -getGlobalTensorClass().prototype.div = function( - b: Tensor|TensorLike): T { - this.throwIfDisposed(); - return div(this, b); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/div_no_nan.ts b/tfjs-master/tfjs-core/src/public/chained_ops/div_no_nan.ts deleted file mode 100644 index 2bfb3b71c..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/div_no_nan.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {divNoNan} from '../../ops/div_no_nan'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank, TensorLike} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - divNoNan(b: Tensor|TensorLike): T; - } -} - -getGlobalTensorClass().prototype.divNoNan = function( - b: Tensor|TensorLike): T { - this.throwIfDisposed(); - return divNoNan(this, b); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/dot.ts b/tfjs-master/tfjs-core/src/public/chained_ops/dot.ts deleted file mode 100644 index 869f9a7d8..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/dot.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {dot} from '../../ops/dot'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank, TensorLike} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - dot(b: Tensor|TensorLike): Tensor; - } -} - -getGlobalTensorClass().prototype.dot = function( - b: T|TensorLike): Tensor { - this.throwIfDisposed(); - return dot(this, b); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/elu.ts b/tfjs-master/tfjs-core/src/public/chained_ops/elu.ts deleted file mode 100644 index 244070334..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/elu.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {elu} from '../../ops/elu'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - elu(): T; - } -} - -getGlobalTensorClass().prototype.elu = function(this: T): T { - this.throwIfDisposed(); - return elu(this); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/equal.ts b/tfjs-master/tfjs-core/src/public/chained_ops/equal.ts deleted file mode 100644 index c2cc13e94..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/equal.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {equal} from '../../ops/equal'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank, TensorLike} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - equal(b: Tensor|TensorLike): T; - } -} - -getGlobalTensorClass().prototype.equal = function( - b: Tensor|TensorLike): T { - this.throwIfDisposed(); - return equal(this, b); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/erf.ts b/tfjs-master/tfjs-core/src/public/chained_ops/erf.ts deleted file mode 100644 index ac7ad5e97..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/erf.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// TODO update import path once op is modularized. -import {erf} from '../../ops/ops'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - erf(this: T): T; - } -} - -getGlobalTensorClass().prototype.erf = function(this: T): T { - this.throwIfDisposed(); - return erf(this); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/euclidean_norm.ts b/tfjs-master/tfjs-core/src/public/chained_ops/euclidean_norm.ts deleted file mode 100644 index 892f05e37..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/euclidean_norm.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {euclideanNorm} from '../../ops/euclidean_norm'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - euclideanNorm( - this: T, axis?: number|number[], keepDims?: boolean): T; - } -} - -getGlobalTensorClass().prototype.euclideanNorm = function( - this: T, axis?: number|number[], keepDims?: boolean): T { - this.throwIfDisposed(); - return euclideanNorm(this, axis, keepDims) as T; -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/exp.ts b/tfjs-master/tfjs-core/src/public/chained_ops/exp.ts deleted file mode 100644 index aa2e04cf4..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/exp.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// TODO update import path once op is modularized. -import {exp} from '../../ops/ops'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - exp(this: T): T; - } -} - -getGlobalTensorClass().prototype.exp = function(this: T): T { - this.throwIfDisposed(); - return exp(this); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/expand_dims.ts b/tfjs-master/tfjs-core/src/public/chained_ops/expand_dims.ts deleted file mode 100644 index 2f31f9d03..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/expand_dims.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {expandDims} from '../../ops/expand_dims'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - expandDims(axis?: number): T; - } -} - -getGlobalTensorClass().prototype.expandDims = function( - axis?: number): T { - this.throwIfDisposed(); - return expandDims(this, axis); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/expm1.ts b/tfjs-master/tfjs-core/src/public/chained_ops/expm1.ts deleted file mode 100644 index 59827b452..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/expm1.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// TODO update import path once op is modularized. -import {expm1} from '../../ops/ops'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - expm1(this: T): T; - } -} - -getGlobalTensorClass().prototype.expm1 = function(this: T): - T { - this.throwIfDisposed(); - return expm1(this); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/fft.ts b/tfjs-master/tfjs-core/src/public/chained_ops/fft.ts deleted file mode 100644 index 643d68123..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/fft.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// TODO update import path once op is modularized. -import {fft} from '../../ops/ops'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - fft(this: Tensor): Tensor; - } -} - -getGlobalTensorClass().prototype.fft = function(this: Tensor): - T { - this.throwIfDisposed(); - return fft(this) as T; -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/flatten.ts b/tfjs-master/tfjs-core/src/public/chained_ops/flatten.ts deleted file mode 100644 index d5c9c447a..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/flatten.ts +++ /dev/null @@ -1,35 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {reshape} from '../../ops/reshape'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - flatten(): Tensor1D; - } -} - -/** - * Flatten a Tensor to a 1D array. - * @doc {heading: 'Tensors', subheading: 'Classes'} - */ -getGlobalTensorClass().prototype.flatten = function(): T { - this.throwIfDisposed(); - return reshape(this, [this.size]) as T; -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/floor.ts b/tfjs-master/tfjs-core/src/public/chained_ops/floor.ts deleted file mode 100644 index 7f2d63a26..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/floor.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// TODO update import path once op is modularized. -import {floor} from '../../ops/ops'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - floor(this: T): T; - } -} - -getGlobalTensorClass().prototype.floor = function(this: T): - T { - this.throwIfDisposed(); - return floor(this); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/floorDiv.ts b/tfjs-master/tfjs-core/src/public/chained_ops/floorDiv.ts deleted file mode 100644 index a003560dc..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/floorDiv.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {floorDiv} from '../../ops/floorDiv'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank, TensorLike} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - floorDiv(b: Tensor|TensorLike): T; - } -} - -getGlobalTensorClass().prototype.floorDiv = function( - b: Tensor|TensorLike): T { - this.throwIfDisposed(); - return floorDiv(this, b); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/gather.ts b/tfjs-master/tfjs-core/src/public/chained_ops/gather.ts deleted file mode 100644 index 391de4924..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/gather.ts +++ /dev/null @@ -1,34 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {gather} from '../../ops/gather'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank, TensorLike} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - gather( - this: T, indices: Tensor|TensorLike, axis?: number, - batchDims?: number): T; - } -} - -getGlobalTensorClass().prototype.gather = function( - this: T, indices: Tensor|TensorLike, axis?: number, batchDims?: number): T { - this.throwIfDisposed(); - return gather(this, indices, axis, batchDims); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/greater.ts b/tfjs-master/tfjs-core/src/public/chained_ops/greater.ts deleted file mode 100644 index 05a901d20..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/greater.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {greater} from '../../ops/greater'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank, TensorLike} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - greater(b: Tensor|TensorLike): T; - } -} - -getGlobalTensorClass().prototype.greater = function( - b: Tensor|TensorLike): T { - this.throwIfDisposed(); - return greater(this, b); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/greater_equal.ts b/tfjs-master/tfjs-core/src/public/chained_ops/greater_equal.ts deleted file mode 100644 index c225b03bf..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/greater_equal.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {greaterEqual} from '../../ops/greater_equal'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank, TensorLike} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - greaterEqual(b: Tensor|TensorLike): T; - } -} - -getGlobalTensorClass().prototype.greaterEqual = function( - b: Tensor|TensorLike): T { - this.throwIfDisposed(); - return greaterEqual(this, b); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/ifft.ts b/tfjs-master/tfjs-core/src/public/chained_ops/ifft.ts deleted file mode 100644 index 7f737c8fc..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/ifft.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// TODO update import path once op is modularized. -import {ifft} from '../../ops/ops'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - ifft(this: Tensor): Tensor; - } -} - -getGlobalTensorClass().prototype.ifft = function( - this: Tensor): T { - this.throwIfDisposed(); - return ifft(this) as T; -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/irfft.ts b/tfjs-master/tfjs-core/src/public/chained_ops/irfft.ts deleted file mode 100644 index 951ba1ae4..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/irfft.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// TODO update import path once op is modularized. -import {irfft} from '../../ops/ops'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - irfft(this: Tensor): Tensor; - } -} - -getGlobalTensorClass().prototype.irfft = function( - this: Tensor): T { - this.throwIfDisposed(); - return irfft(this) as T; -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/is_finite.ts b/tfjs-master/tfjs-core/src/public/chained_ops/is_finite.ts deleted file mode 100644 index 6c02751f3..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/is_finite.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// TODO update import path once op is modularized. -import {isFinite} from '../../ops/ops'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - isFinite(this: T): T; - } -} - -getGlobalTensorClass().prototype.isFinite = function(this: T): - T { - this.throwIfDisposed(); - return isFinite(this); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/is_inf.ts b/tfjs-master/tfjs-core/src/public/chained_ops/is_inf.ts deleted file mode 100644 index cc9ef249f..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/is_inf.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// TODO update import path once op is modularized. -import {isInf} from '../../ops/ops'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - isInf(this: T): T; - } -} - -getGlobalTensorClass().prototype.isInf = function(this: T): - T { - this.throwIfDisposed(); - return isInf(this); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/is_nan.ts b/tfjs-master/tfjs-core/src/public/chained_ops/is_nan.ts deleted file mode 100644 index 094f3c428..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/is_nan.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// TODO update import path once op is modularized. -import {isNaN} from '../../ops/ops'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - isNaN(this: T): T; - } -} - -getGlobalTensorClass().prototype.isNaN = function(this: T): - T { - this.throwIfDisposed(); - return isNaN(this); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/leaky_relu.ts b/tfjs-master/tfjs-core/src/public/chained_ops/leaky_relu.ts deleted file mode 100644 index 4d7f42650..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/leaky_relu.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {leakyRelu} from '../../ops/leaky_relu'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - leakyRelu(alpha: number): T; - } -} - -getGlobalTensorClass().prototype.leakyRelu = function( - this: T, alpha: number): T { - this.throwIfDisposed(); - return leakyRelu(this, alpha); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/less.ts b/tfjs-master/tfjs-core/src/public/chained_ops/less.ts deleted file mode 100644 index 76859d9fd..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/less.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {less} from '../../ops/less'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank, TensorLike} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - less(b: Tensor|TensorLike): T; - } -} - -getGlobalTensorClass().prototype.less = function( - b: Tensor|TensorLike): T { - this.throwIfDisposed(); - return less(this, b); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/less_equal.ts b/tfjs-master/tfjs-core/src/public/chained_ops/less_equal.ts deleted file mode 100644 index b03276541..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/less_equal.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {lessEqual} from '../../ops/less_equal'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank, TensorLike} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - lessEqual(b: Tensor|TensorLike): T; - } -} - -getGlobalTensorClass().prototype.lessEqual = function( - b: Tensor|TensorLike): T { - this.throwIfDisposed(); - return lessEqual(this, b); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/local_response_normalization.ts b/tfjs-master/tfjs-core/src/public/chained_ops/local_response_normalization.ts deleted file mode 100644 index d641c6f13..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/local_response_normalization.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {localResponseNormalization} from '../../ops/local_response_normalization'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - localResponseNormalization( - depthRadius?: number, bias?: number, alpha?: number, beta?: number): T; - } -} - -getGlobalTensorClass().prototype.localResponseNormalization = - function( - depthRadius?: number, bias?: number, alpha?: number, beta?: number): T { - this.throwIfDisposed(); - return localResponseNormalization(this, depthRadius, bias, alpha, beta) as T; -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/log.ts b/tfjs-master/tfjs-core/src/public/chained_ops/log.ts deleted file mode 100644 index 4fef252d8..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/log.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// TODO update import path once op is modularized. -import {log} from '../../ops/ops'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - log(this: T): T; - } -} - -getGlobalTensorClass().prototype.log = function(this: T): T { - this.throwIfDisposed(); - return log(this); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/log1p.ts b/tfjs-master/tfjs-core/src/public/chained_ops/log1p.ts deleted file mode 100644 index 73e47e808..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/log1p.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// TODO update import path once op is modularized. -import {log1p} from '../../ops/ops'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - log1p(this: T): T; - } -} - -getGlobalTensorClass().prototype.log1p = function(this: T): - T { - this.throwIfDisposed(); - return log1p(this); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/log_sigmoid.ts b/tfjs-master/tfjs-core/src/public/chained_ops/log_sigmoid.ts deleted file mode 100644 index 820c67378..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/log_sigmoid.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// TODO update import path once op is modularized. -import {logSigmoid} from '../../ops/ops'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - logSigmoid(this: T): T; - } -} - -getGlobalTensorClass().prototype.logSigmoid = function( - this: T): T { - this.throwIfDisposed(); - return logSigmoid(this); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/log_softmax.ts b/tfjs-master/tfjs-core/src/public/chained_ops/log_softmax.ts deleted file mode 100644 index 5d33e04ce..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/log_softmax.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// TODO update import path once op is modularized. -import {logSoftmax} from '../../ops/ops'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - logSoftmax(this: T, axis?: number): T; - } -} - -getGlobalTensorClass().prototype.logSoftmax = function( - this: T, axis?: number): T { - this.throwIfDisposed(); - return logSoftmax(this, axis); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/log_sum_exp.ts b/tfjs-master/tfjs-core/src/public/chained_ops/log_sum_exp.ts deleted file mode 100644 index 765c8358d..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/log_sum_exp.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {logSumExp} from '../../ops/log_sum_exp'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - logSumExp( - this: T, axis?: number|number[], keepDims?: boolean): T; - } -} - -getGlobalTensorClass().prototype.logSumExp = function( - this: T, axis?: number|number[], keepDims?: boolean): T { - this.throwIfDisposed(); - return logSumExp(this, axis, keepDims); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/logical_and.ts b/tfjs-master/tfjs-core/src/public/chained_ops/logical_and.ts deleted file mode 100644 index da3c15121..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/logical_and.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {logicalAnd} from '../../ops/logical_and'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank, TensorLike} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - logicalAnd(b: Tensor|TensorLike): T; - } -} - -getGlobalTensorClass().prototype.logicalAnd = function( - b: Tensor|TensorLike): T { - this.throwIfDisposed(); - return logicalAnd(this, b); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/logical_not.ts b/tfjs-master/tfjs-core/src/public/chained_ops/logical_not.ts deleted file mode 100644 index 3cd14a810..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/logical_not.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {logicalNot} from '../../ops/logical_not'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - logicalNot(): T; - } -} - -getGlobalTensorClass().prototype.logicalNot = function(): T { - this.throwIfDisposed(); - return logicalNot(this) as T; -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/logical_or.ts b/tfjs-master/tfjs-core/src/public/chained_ops/logical_or.ts deleted file mode 100644 index 66374ae74..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/logical_or.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {logicalOr} from '../../ops/logical_or'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank, TensorLike} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - logicalOr(b: Tensor|TensorLike): T; - } -} - -getGlobalTensorClass().prototype.logicalOr = function( - b: Tensor|TensorLike): T { - this.throwIfDisposed(); - return logicalOr(this, b); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/logical_xor.ts b/tfjs-master/tfjs-core/src/public/chained_ops/logical_xor.ts deleted file mode 100644 index c20bc54df..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/logical_xor.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {logicalXor} from '../../ops/logical_xor'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank, TensorLike} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - logicalXor(b: Tensor|TensorLike): T; - } -} - -getGlobalTensorClass().prototype.logicalXor = function( - b: Tensor|TensorLike): T { - this.throwIfDisposed(); - return logicalXor(this, b); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/mat_mul.ts b/tfjs-master/tfjs-core/src/public/chained_ops/mat_mul.ts deleted file mode 100644 index a56257fd0..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/mat_mul.ts +++ /dev/null @@ -1,34 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {matMul} from '../../ops/mat_mul'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank, TensorLike} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - matMul( - b: Tensor|TensorLike, transposeA?: boolean, - transposeB?: boolean): Tensor; - } -} - -getGlobalTensorClass().prototype.matMul = function( - this: T, b: Tensor|TensorLike, transposeA?: boolean, - transposeB?: boolean): Tensor { - this.throwIfDisposed(); - return matMul(this, b, transposeA, transposeB); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/max.ts b/tfjs-master/tfjs-core/src/public/chained_ops/max.ts deleted file mode 100644 index 0d530ca56..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/max.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {max} from '../../ops/max'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - max(axis?: number|number[], keepDims?: boolean): T; - } -} - -getGlobalTensorClass().prototype.max = function( - axis?: number|number[], keepDims?: boolean): T { - this.throwIfDisposed(); - return max(this, axis, keepDims); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/max_pool.ts b/tfjs-master/tfjs-core/src/public/chained_ops/max_pool.ts deleted file mode 100644 index 5bd102c94..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/max_pool.ts +++ /dev/null @@ -1,39 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {ExplicitPadding} from '../../ops/conv_util'; -import {maxPool} from '../../ops/max_pool'; -import {getGlobalTensorClass, Tensor3D, Tensor4D} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - maxPool( - filterSize: [number, number]|number, strides: [number, number]|number, - pad: 'valid'|'same'|number|ExplicitPadding, - dimRoundingMode?: 'floor'|'round'|'ceil'): T; - } -} - -getGlobalTensorClass().prototype.maxPool = - function( - this: T, filterSize: [number, number]|number, - strides: [number, number]|number, - pad: 'valid'|'same'|number|ExplicitPadding, - dimRoundingMode?: 'floor'|'round'|'ceil'): T { - this.throwIfDisposed(); - return maxPool(this, filterSize, strides, pad, dimRoundingMode); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/maximum.ts b/tfjs-master/tfjs-core/src/public/chained_ops/maximum.ts deleted file mode 100644 index e397003db..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/maximum.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {maximum} from '../../ops/maximum'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank, TensorLike} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - maximum(b: Tensor|TensorLike): T; - } -} - -getGlobalTensorClass().prototype.maximum = function( - b: Tensor|TensorLike): T { - this.throwIfDisposed(); - return maximum(this, b); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/mean.ts b/tfjs-master/tfjs-core/src/public/chained_ops/mean.ts deleted file mode 100644 index 0a5afec6e..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/mean.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {mean} from '../../ops/mean'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - mean(axis?: number|number[], keepDims?: boolean): T; - } -} - -getGlobalTensorClass().prototype.mean = function( - axis?: number|number[], keepDims?: boolean): T { - this.throwIfDisposed(); - return mean(this, axis, keepDims); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/min.ts b/tfjs-master/tfjs-core/src/public/chained_ops/min.ts deleted file mode 100644 index 24fab0bc4..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/min.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {min} from '../../ops/min'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - min(axis?: number|number[], keepDims?: boolean): T; - } -} - -getGlobalTensorClass().prototype.min = function( - axis?: number|number[], keepDims?: boolean): T { - this.throwIfDisposed(); - return min(this, axis, keepDims); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/minimum.ts b/tfjs-master/tfjs-core/src/public/chained_ops/minimum.ts deleted file mode 100644 index 5b63edf52..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/minimum.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {minimum} from '../../ops/minimum'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank, TensorLike} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - minimum(b: Tensor|TensorLike): T; - } -} - -getGlobalTensorClass().prototype.minimum = function( - b: Tensor|TensorLike): T { - this.throwIfDisposed(); - return minimum(this, b); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/mirror_pad.ts b/tfjs-master/tfjs-core/src/public/chained_ops/mirror_pad.ts deleted file mode 100644 index 77e91c1f8..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/mirror_pad.ts +++ /dev/null @@ -1,34 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {mirrorPad} from '../../ops/mirror_pad'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - mirrorPad( - paddings: Array<[number, number]>, mode: 'reflect'|'symmetric'): T; - } -} - -getGlobalTensorClass().prototype.mirrorPad = function( - this: T, paddings: Array<[number, number]>, - mode: 'reflect'|'symmetric'): T { - this.throwIfDisposed(); - return mirrorPad(this, paddings, mode); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/mod.ts b/tfjs-master/tfjs-core/src/public/chained_ops/mod.ts deleted file mode 100644 index 1d48dba97..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/mod.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {mod} from '../../ops/mod'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank, TensorLike} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - mod(b: Tensor|TensorLike): T; - } -} - -getGlobalTensorClass().prototype.mod = function( - b: Tensor|TensorLike): T { - this.throwIfDisposed(); - return mod(this, b); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/mul.ts b/tfjs-master/tfjs-core/src/public/chained_ops/mul.ts deleted file mode 100644 index 7ba2974bb..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/mul.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {mul} from '../../ops/mul'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank, TensorLike} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - mul(b: Tensor|TensorLike): T; - } -} - -getGlobalTensorClass().prototype.mul = function( - b: Tensor|TensorLike): T { - this.throwIfDisposed(); - return mul(this, b); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/neg.ts b/tfjs-master/tfjs-core/src/public/chained_ops/neg.ts deleted file mode 100644 index f0ff8d1af..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/neg.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// TODO update import path once op is modularized. -import {neg} from '../../ops/ops'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - neg(this: T): T; - } -} - -getGlobalTensorClass().prototype.neg = function(this: T): T { - this.throwIfDisposed(); - return neg(this); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/norm.ts b/tfjs-master/tfjs-core/src/public/chained_ops/norm.ts deleted file mode 100644 index f5db2a7cf..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/norm.ts +++ /dev/null @@ -1,36 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// TODO update import path once op is modularized. -import {norm} from '../../ops/ops'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - norm( - ord?: number|'euclidean'|'fro', axis?: number|number[], - keepDims?: boolean): Tensor; - } -} - -getGlobalTensorClass().prototype.norm = function( - ord?: number|'euclidean'|'fro', axis?: number|number[], - keepDims?: boolean) { - this.throwIfDisposed(); - return norm(this, ord, axis, keepDims) as T; -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/not_equal.ts b/tfjs-master/tfjs-core/src/public/chained_ops/not_equal.ts deleted file mode 100644 index a8eb6b649..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/not_equal.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {notEqual} from '../../ops/not_equal'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank, TensorLike} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - notEqual(b: Tensor|TensorLike): T; - } -} - -getGlobalTensorClass().prototype.notEqual = function( - b: Tensor|TensorLike): T { - this.throwIfDisposed(); - return notEqual(this, b); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/one_hot.ts b/tfjs-master/tfjs-core/src/public/chained_ops/one_hot.ts deleted file mode 100644 index afeda04fe..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/one_hot.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {oneHot} from '../../ops/one_hot'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - oneHot(depth: number, onValue: number, offValue: number): Tensor; - } -} - -getGlobalTensorClass().prototype.oneHot = function( - depth: number, onValue = 1, offValue = 0): Tensor { - this.throwIfDisposed(); - return oneHot(this, depth, onValue, offValue); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/ones_like.ts b/tfjs-master/tfjs-core/src/public/chained_ops/ones_like.ts deleted file mode 100644 index 31b16a789..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/ones_like.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// TODO update import path once op is modularized. -import {onesLike} from '../../ops/ops'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - onesLike(this: T): T; - } -} - -getGlobalTensorClass().prototype.onesLike = function(this: T): - T { - this.throwIfDisposed(); - return onesLike(this); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/pad.ts b/tfjs-master/tfjs-core/src/public/chained_ops/pad.ts deleted file mode 100644 index e8c7b1af1..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/pad.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {pad} from '../../ops/pad'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - pad( - paddings: Array<[number, number]>, constantValue?: number): T; - } -} - -getGlobalTensorClass().prototype.pad = function( - this: T, paddings: Array<[number, number]>, constantValue: number): T { - this.throwIfDisposed(); - return pad(this, paddings, constantValue); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/pool.ts b/tfjs-master/tfjs-core/src/public/chained_ops/pool.ts deleted file mode 100644 index 0906aceed..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/pool.ts +++ /dev/null @@ -1,42 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {ExplicitPadding} from '../../ops/conv_util'; -import {pool} from '../../ops/pool'; -import {getGlobalTensorClass, Tensor3D, Tensor4D} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - pool( - windowShape: [number, number]|number, poolingType: 'avg'|'max', - padding: 'valid'|'same'|number|ExplicitPadding, - diationRate?: [number, number]|number, - strides?: [number, number]|number, - dimRoundingMode?: 'floor'|'round'|'ceil'): T; - } -} - -getGlobalTensorClass().prototype.pool = function( - this: T, windowShape: [number, number]|number, poolingType: 'max'|'avg', - padding: 'valid'|'same'|number|ExplicitPadding, - dilationRate?: [number, number]|number, - strides?: [number, number]|number, - dimRoundingMode?: 'floor'|'round'|'ceil'): T { - this.throwIfDisposed(); - return pool(this, windowShape, poolingType, padding, dilationRate, strides, - dimRoundingMode); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/pow.ts b/tfjs-master/tfjs-core/src/public/chained_ops/pow.ts deleted file mode 100644 index a8c06315e..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/pow.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {pow} from '../../ops/pow'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank, TensorLike} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - pow(exp: Tensor|TensorLike): T; - } -} - -getGlobalTensorClass().prototype.pow = function( - exp: Tensor|TensorLike): T { - this.throwIfDisposed(); - return pow(this, exp); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/prelu.ts b/tfjs-master/tfjs-core/src/public/chained_ops/prelu.ts deleted file mode 100644 index 9f762c761..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/prelu.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {prelu} from '../../ops/prelu'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank, TensorLike} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - prelu(alpha: T|TensorLike): T; - } -} - -getGlobalTensorClass().prototype.prelu = function( - this: T, alpha: T|TensorLike): T { - this.throwIfDisposed(); - return prelu(this, alpha); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/prod.ts b/tfjs-master/tfjs-core/src/public/chained_ops/prod.ts deleted file mode 100644 index b642f2939..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/prod.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {prod} from '../../ops/prod'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - prod(this: T, axis?: number|number[], keepDims?: boolean): - T; - } -} - -getGlobalTensorClass().prototype.prod = function( - this: T, axis?: number|number[], keepDims?: boolean): T { - this.throwIfDisposed(); - return prod(this, axis, keepDims); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/reciprocal.ts b/tfjs-master/tfjs-core/src/public/chained_ops/reciprocal.ts deleted file mode 100644 index e7392385a..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/reciprocal.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// TODO update import path once op is modularized. -import {reciprocal} from '../../ops/ops'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - reciprocal(this: T): T; - } -} - -getGlobalTensorClass().prototype.reciprocal = function( - this: T): T { - this.throwIfDisposed(); - return reciprocal(this); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/register_all_chained_ops.ts b/tfjs-master/tfjs-core/src/public/chained_ops/register_all_chained_ops.ts deleted file mode 100644 index c7deab89e..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/register_all_chained_ops.ts +++ /dev/null @@ -1,154 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import './abs'; -import './acos'; -import './acosh'; -import './add'; -import './all'; -import './any'; -import './arg_max'; -import './arg_min'; -import './as_scalar'; -import './as_type'; -import './as1d'; -import './as2d'; -import './as3d'; -import './as4d'; -import './as5d'; -import './asin'; -import './asinh'; -import './atan'; -import './atan2'; -import './atanh'; -import './avg_pool'; -import './batch_to_space_nd'; -import './batchnorm'; -import './broadcast_to'; -import './cast'; -import './ceil'; -import './clip_by_value'; -import './concat'; -import './conv1d'; -import './conv2d_transpose'; -import './conv2d'; -import './cos'; -import './cosh'; -import './cumprod'; -import './cumsum'; -import './depth_to_space'; -import './depthwise_conv2d'; -import './dilation2d'; -import './div_no_nan'; -import './div'; -import './dot'; -import './elu'; -import './equal'; -import './erf'; -import './euclidean_norm'; -import './exp'; -import './expand_dims'; -import './expm1'; -import './fft'; -import './flatten'; -import './floor'; -import './floorDiv'; -import './gather'; -import './greater_equal'; -import './greater'; -import './ifft'; -import './irfft'; -import './is_finite'; -import './is_inf'; -import './is_nan'; -import './leaky_relu'; -import './less_equal'; -import './less'; -import './local_response_normalization'; -import './log_sigmoid'; -import './log_softmax'; -import './log_sum_exp'; -import './log'; -import './log1p'; -import './logical_and'; -import './logical_not'; -import './logical_or'; -import './logical_xor'; -import './mat_mul'; -import './max_pool'; -import './max'; -import './maximum'; -import './mean'; -import './min'; -import './minimum'; -import './mirror_pad'; -import './mod'; -import './mul'; -import './neg'; -import './norm'; -import './not_equal'; -import './one_hot'; -import './ones_like'; -import './pad'; -import './pool'; -import './pow'; -import './prelu'; -import './prod'; -import './reciprocal'; -import './relu'; -import './relu6'; -import './reshape_as'; -import './reshape'; -import './resize_bilinear'; -import './resize_nearest_neighbor'; -import './reverse'; -import './rfft'; -import './round'; -import './rsqrt'; -import './selu'; -import './separable_conv2d'; -import './sigmoid'; -import './sign'; -import './sin'; -import './sinh'; -import './slice'; -import './softmax'; -import './softplus'; -import './space_to_batch_nd'; -import './split'; -import './sqrt'; -import './square'; -import './squared_difference'; -import './squeeze'; -import './stack'; -import './step'; -import './strided_slice'; -import './sub'; -import './sum'; -import './tan'; -import './tanh'; -import './tile'; -import './to_bool'; -import './to_float'; -import './to_int'; -import './topk'; -import './transpose'; -import './unique'; -import './unsorted_segment_sum'; -import './unstack'; -import './where'; -import './zeros_like'; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/register_all_chained_ops_test.ts b/tfjs-master/tfjs-core/src/public/chained_ops/register_all_chained_ops_test.ts deleted file mode 100644 index 0a5c21079..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/register_all_chained_ops_test.ts +++ /dev/null @@ -1,176 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import '../../public/chained_ops/register_all_chained_ops'; - -import * as tf from '../../index'; -import {ALL_ENVS, describeWithFlags} from '../../jasmine_util'; - -// Testing for presence of chained op in this file will allow us to more easily -// customize when we want this test to run. Currently it will run be default -// (And karma will always load the chain augmentor files). But this gives us -// flexibility to change in future. - -const CHAINED_OPS = [ - 'abs', - 'acos', - 'acosh', - 'add', - 'all', - 'any', - 'argMax', - 'argMin', - 'as1D', - 'as2D', - 'as3D', - 'as4D', - 'as5D', - 'asin', - 'asinh', - 'asScalar', - 'asType', - 'atan', - 'atan2', - 'atanh', - 'avgPool', - 'batchNorm', - 'batchToSpaceND', - 'broadcastTo', - 'cast', - 'ceil', - 'clipByValue', - 'concat', - 'conv1d', - 'conv2d', - 'conv2dTranspose', - 'cos', - 'cosh', - 'cumprod', - 'cumsum', - 'depthToSpace', - 'depthwiseConv2d', - 'dilation2d', - 'div', - 'divNoNan', - 'dot', - 'elu', - 'equal', - 'erf', - 'exp', - 'expandDims', - 'expm1', - 'fft', - 'flatten', - 'floor', - 'floorDiv', - 'gather', - 'greater', - 'greaterEqual', - 'ifft', - 'irfft', - 'isFinite', - 'isInf', - 'isNaN', - 'leakyRelu', - 'less', - 'lessEqual', - 'localResponseNormalization', - 'log', - 'log1p', - 'logicalAnd', - 'logicalNot', - 'logicalOr', - 'logicalXor', - 'logSigmoid', - 'logSoftmax', - 'logSumExp', - 'matMul', - 'max', - 'maximum', - 'maxPool', - 'mean', - 'min', - 'minimum', - 'mirrorPad', - 'mod', - 'mul', - 'neg', - 'norm', - 'notEqual', - 'oneHot', - 'onesLike', - 'pad', - 'pool', - 'pow', - 'prelu', - 'prod', - 'reciprocal', - 'relu', - 'relu6', - 'reshape', - 'reshapeAs', - 'resizeBilinear', - 'resizeNearestNeighbor', - 'reverse', - 'rfft', - 'round', - 'rsqrt', - 'selu', - 'separableConv2d', - 'sigmoid', - 'sign', - 'sin', - 'sinh', - 'slice', - 'softmax', - 'softplus', - 'spaceToBatchND', - 'split', - 'sqrt', - 'square', - 'square', - 'squeeze', - 'stack', - 'step', - 'stridedSlice', - 'sub', - 'sum', - 'tan', - 'tanh', - 'tile', - 'toBool', - 'toFloat', - 'toInt', - 'topk', - 'transpose', - 'unique', - 'unsortedSegmentSum', - 'unstack', - 'where', - 'zerosLike' -]; - -describeWithFlags('chained ops', ALL_ENVS, () => { - it('all chained ops should exist on tensor ', async () => { - const tensor = tf.tensor([1, 2, 3]); - for (const opName of CHAINED_OPS) { - //@ts-ignore - expect(typeof tensor[opName]) - .toBe('function', `${opName} chained op not found`); - } - }); -}); diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/relu.ts b/tfjs-master/tfjs-core/src/public/chained_ops/relu.ts deleted file mode 100644 index 119873ed4..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/relu.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {relu} from '../../ops/relu'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - relu(): T; - } -} - -getGlobalTensorClass().prototype.relu = function(this: T): T { - this.throwIfDisposed(); - return relu(this); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/relu6.ts b/tfjs-master/tfjs-core/src/public/chained_ops/relu6.ts deleted file mode 100644 index 05c602aea..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/relu6.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {relu6} from '../../ops/relu6'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - relu6(): T; - } -} - -getGlobalTensorClass().prototype.relu6 = function(this: T): - T { - this.throwIfDisposed(); - return relu6(this); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/reshape.ts b/tfjs-master/tfjs-core/src/public/chained_ops/reshape.ts deleted file mode 100644 index 75a1265d3..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/reshape.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {reshape} from '../../ops/reshape'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - reshape(shape: number[]): T; - } -} - -getGlobalTensorClass().prototype.reshape = function( - shape: number[]): T { - this.throwIfDisposed(); - return reshape(this, shape) as T; -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/reshape_as.ts b/tfjs-master/tfjs-core/src/public/chained_ops/reshape_as.ts deleted file mode 100644 index 6a2e5de8f..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/reshape_as.ts +++ /dev/null @@ -1,39 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {reshape} from '../../ops/reshape'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - reshapeAs(x: T): T; - } -} - -/** - * Reshapes the tensor into the shape of the provided tensor. - * - * @param x The tensor of required shape. - * - * @doc {heading: 'Tensors', subheading: 'Classes'} - */ -getGlobalTensorClass().prototype.reshapeAs = function(x: T): - T { - this.throwIfDisposed(); - return reshape(this, x.shape) as T; -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/resize_bilinear.ts b/tfjs-master/tfjs-core/src/public/chained_ops/resize_bilinear.ts deleted file mode 100644 index 76766cdd8..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/resize_bilinear.ts +++ /dev/null @@ -1,35 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {resizeBilinear} from '../../ops/image/resize_bilinear'; -import {getGlobalTensorClass, Tensor3D, Tensor4D} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - resizeBilinear( - newShape2D: [number, number], alignCorners?: boolean, - halfPixelCenters?: boolean): T; - } -} - -getGlobalTensorClass().prototype.resizeBilinear = - function( - this: T, newShape2D: [number, number], alignCorners?: boolean, - halfPixelCenters?: boolean): T { - this.throwIfDisposed(); - return resizeBilinear(this, newShape2D, alignCorners, halfPixelCenters); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/resize_nearest_neighbor.ts b/tfjs-master/tfjs-core/src/public/chained_ops/resize_nearest_neighbor.ts deleted file mode 100644 index 4ea740abc..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/resize_nearest_neighbor.ts +++ /dev/null @@ -1,36 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {resizeNearestNeighbor} from '../../ops/image/resize_nearest_neighbor'; -import {getGlobalTensorClass, Tensor3D, Tensor4D} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - resizeNearestNeighbor( - newShape2D: [number, number], alignCorners?: boolean, - halfFloatCenters?: boolean): T; - } -} - -getGlobalTensorClass().prototype.resizeNearestNeighbor = - function( - this: T, newShape2D: [number, number], alignCorners?: boolean, - halfFloatCenters?: boolean): T { - this.throwIfDisposed(); - return resizeNearestNeighbor( - this, newShape2D, alignCorners, halfFloatCenters); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/reverse.ts b/tfjs-master/tfjs-core/src/public/chained_ops/reverse.ts deleted file mode 100644 index 7a4189a3e..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/reverse.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {reverse} from '../../ops/reverse'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - reverse(this: T, axis?: number|number[]): T; - } -} - -getGlobalTensorClass().prototype.reverse = function( - this: T, axis?: number|number[]): T { - this.throwIfDisposed(); - return reverse(this, axis); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/rfft.ts b/tfjs-master/tfjs-core/src/public/chained_ops/rfft.ts deleted file mode 100644 index 121b1aadf..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/rfft.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// TODO update import path once op is modularized. -import {rfft} from '../../ops/ops'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - rfft(this: Tensor): Tensor; - } -} - -getGlobalTensorClass().prototype.rfft = function( - this: Tensor): T { - this.throwIfDisposed(); - return rfft(this) as T; -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/round.ts b/tfjs-master/tfjs-core/src/public/chained_ops/round.ts deleted file mode 100644 index c0d337eb3..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/round.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// TODO update import path once op is modularized. -import {round} from '../../ops/ops'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - round(this: T): T; - } -} - -getGlobalTensorClass().prototype.round = function(this: T): - T { - this.throwIfDisposed(); - return round(this); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/rsqrt.ts b/tfjs-master/tfjs-core/src/public/chained_ops/rsqrt.ts deleted file mode 100644 index 197f16e57..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/rsqrt.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// TODO update import path once op is modularized. -import {rsqrt} from '../../ops/ops'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - rsqrt(this: T): T; - } -} - -getGlobalTensorClass().prototype.rsqrt = function(this: T): - T { - this.throwIfDisposed(); - return rsqrt(this); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/selu.ts b/tfjs-master/tfjs-core/src/public/chained_ops/selu.ts deleted file mode 100644 index 527d2b92e..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/selu.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {selu} from '../../ops/selu'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - selu(): T; - } -} - -getGlobalTensorClass().prototype.selu = function(this: T): T { - this.throwIfDisposed(); - return selu(this); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/separable_conv2d.ts b/tfjs-master/tfjs-core/src/public/chained_ops/separable_conv2d.ts deleted file mode 100644 index 496bc7734..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/separable_conv2d.ts +++ /dev/null @@ -1,41 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {separableConv2d} from '../../ops/separable_conv2d'; -import {getGlobalTensorClass, Tensor3D, Tensor4D} from '../../tensor'; -import {Rank, TensorLike, TensorLike4D} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - separableConv2d( - depthwiseFilter: Tensor4D|TensorLike4D, - pointwiseFilter: Tensor4D|TensorLike, strides: [number, number]|number, - pad: 'valid'|'same', dilation?: [number, number]|number, - dataFormat?: 'NHWC'|'NCHW'): T; - } -} - -getGlobalTensorClass().prototype.separableConv2d = - function( - depthwiseFilter: Tensor4D|TensorLike4D, - pointwiseFilter: Tensor4D|TensorLike, strides: [number, number]|number, - pad: 'valid'|'same', dilation?: [number, number]|number, - dataFormat?: 'NHWC'|'NCHW'): T { - this.throwIfDisposed(); - return separableConv2d( - this, depthwiseFilter, pointwiseFilter, strides, pad, dilation, - dataFormat) as T; -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/sigmoid.ts b/tfjs-master/tfjs-core/src/public/chained_ops/sigmoid.ts deleted file mode 100644 index e962ae995..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/sigmoid.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// TODO update import path once op is modularized. -import {sigmoid} from '../../ops/ops'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - sigmoid(this: T): T; - } -} - -getGlobalTensorClass().prototype.sigmoid = function(this: T): - T { - this.throwIfDisposed(); - return sigmoid(this); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/sign.ts b/tfjs-master/tfjs-core/src/public/chained_ops/sign.ts deleted file mode 100644 index a05ec15e8..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/sign.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// TODO update import path once op is modularized. -import {sign} from '../../ops/ops'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - sign(this: T): T; - } -} - -getGlobalTensorClass().prototype.sign = function(this: T): T { - this.throwIfDisposed(); - return sign(this); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/sin.ts b/tfjs-master/tfjs-core/src/public/chained_ops/sin.ts deleted file mode 100644 index b46cb27e8..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/sin.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// TODO update import path once op is modularized. -import {sin} from '../../ops/ops'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - sin(this: T): T; - } -} - -getGlobalTensorClass().prototype.sin = function(this: T): T { - this.throwIfDisposed(); - return sin(this); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/sinh.ts b/tfjs-master/tfjs-core/src/public/chained_ops/sinh.ts deleted file mode 100644 index c699d78e7..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/sinh.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// TODO update import path once op is modularized. -import {sinh} from '../../ops/ops'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - sinh(this: T): T; - } -} - -getGlobalTensorClass().prototype.sinh = function(this: T): T { - this.throwIfDisposed(); - return sinh(this); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/slice.ts b/tfjs-master/tfjs-core/src/public/chained_ops/slice.ts deleted file mode 100644 index 369dcd417..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/slice.ts +++ /dev/null @@ -1,34 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// TODO update import path once op is modularized. -import {slice} from '../../ops/ops'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - slice( - this: T, begin: number|number[], size?: number|number[]): T; - } -} - -getGlobalTensorClass().prototype.slice = function( - this: T, begin: number|number[], size?: number|number[]): T { - this.throwIfDisposed(); - return slice(this, begin, size); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/softmax.ts b/tfjs-master/tfjs-core/src/public/chained_ops/softmax.ts deleted file mode 100644 index 56d388918..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/softmax.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// TODO update import path once op is modularized. -import {softmax} from '../../ops/ops'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - softmax(this: T, dim?: number): T; - } -} - -getGlobalTensorClass().prototype.softmax = function( - this: T, dim: number): T { - this.throwIfDisposed(); - return softmax(this, dim); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/softplus.ts b/tfjs-master/tfjs-core/src/public/chained_ops/softplus.ts deleted file mode 100644 index 756b43ec4..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/softplus.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// TODO update import path once op is modularized. -import {softplus} from '../../ops/ops'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - softplus(this: T): T; - } -} - -getGlobalTensorClass().prototype.softplus = function(this: T): - T { - this.throwIfDisposed(); - return softplus(this); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/space_to_batch_nd.ts b/tfjs-master/tfjs-core/src/public/chained_ops/space_to_batch_nd.ts deleted file mode 100644 index 81e4856b2..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/space_to_batch_nd.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {spaceToBatchND} from '../../ops/space_to_batch_nd'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - spaceToBatchND(blockShape: number[], paddings: number[][]): - Tensor; - } -} - -getGlobalTensorClass().prototype.spaceToBatchND = function( - blockShape: number[], paddings: number[][]): Tensor { - this.throwIfDisposed(); - return spaceToBatchND(this, blockShape, paddings); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/split.ts b/tfjs-master/tfjs-core/src/public/chained_ops/split.ts deleted file mode 100644 index 524e7d1ef..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/split.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {split} from '../../ops/split'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - split(numOrSizeSplits: number[]|number, axis?: number): - T[]; - } -} - -getGlobalTensorClass().prototype.split = function( - numOrSizeSplits: number[]|number, axis?: number): T[] { - this.throwIfDisposed(); - return split(this, numOrSizeSplits, axis); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/sqrt.ts b/tfjs-master/tfjs-core/src/public/chained_ops/sqrt.ts deleted file mode 100644 index 8875fda87..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/sqrt.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// TODO update import path once op is modularized. -import {sqrt} from '../../ops/ops'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - sqrt(this: T): T; - } -} - -getGlobalTensorClass().prototype.sqrt = function(this: T): T { - this.throwIfDisposed(); - return sqrt(this); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/square.ts b/tfjs-master/tfjs-core/src/public/chained_ops/square.ts deleted file mode 100644 index d66859308..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/square.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// TODO update import path once op is modularized. -import {square} from '../../ops/ops'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - square(this: T): T; - } -} - -getGlobalTensorClass().prototype.square = function(this: T): - T { - this.throwIfDisposed(); - return square(this); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/squared_difference.ts b/tfjs-master/tfjs-core/src/public/chained_ops/squared_difference.ts deleted file mode 100644 index a74c0563a..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/squared_difference.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {squaredDifference} from '../../ops/squared_difference'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank, TensorLike} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - squaredDifference(b: Tensor|TensorLike): T; - } -} - -getGlobalTensorClass().prototype.squaredDifference = function( - b: Tensor|TensorLike): T { - this.throwIfDisposed(); - return squaredDifference(this, b); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/squeeze.ts b/tfjs-master/tfjs-core/src/public/chained_ops/squeeze.ts deleted file mode 100644 index 65fd26739..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/squeeze.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {squeeze} from '../../ops/squeeze'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - squeeze(axis?: number[]): T; - } -} - -getGlobalTensorClass().prototype.squeeze = function( - axis?: number[]): T { - this.throwIfDisposed(); - return squeeze(this, axis); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/stack.ts b/tfjs-master/tfjs-core/src/public/chained_ops/stack.ts deleted file mode 100644 index dd1874363..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/stack.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {stack} from '../../ops/stack'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - stack(x: Tensor|Tensor[], axis?: number): T; - } -} - -getGlobalTensorClass().prototype.stack = function( - x: Tensor|Tensor[], axis?: number): T { - this.throwIfDisposed(); - const tensorsToBeStacked = x instanceof Tensor ? [this, x] : [this, ...x]; - return stack(tensorsToBeStacked, axis) as T; -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/step.ts b/tfjs-master/tfjs-core/src/public/chained_ops/step.ts deleted file mode 100644 index 10397f68b..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/step.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// TODO update import path once op is modularized. -import {step} from '../../ops/ops'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - step(this: T, alpha?: number): T; - } -} - -getGlobalTensorClass().prototype.step = function( - this: T, alpha?: number) { - this.throwIfDisposed(); - return step(this, alpha); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/strided_slice.ts b/tfjs-master/tfjs-core/src/public/chained_ops/strided_slice.ts deleted file mode 100644 index 9170b0d0d..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/strided_slice.ts +++ /dev/null @@ -1,40 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// TODO update import path once op is modularized. -import {stridedSlice} from '../../ops/ops'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - stridedSlice( - this: Tensor, begin: number[], end: number[], strides: number[], - beginMask?: number, endMask?: number, ellipsisMask?: number, - newAxisMask?: number, shrinkAxisMask?: number): Tensor; - } -} - -getGlobalTensorClass().prototype.stridedSlice = function( - this: Tensor, begin: number[], end: number[], strides: number[], - beginMask?: number, endMask?: number, ellipsisMask?: number, - newAxisMask?: number, shrinkAxisMask?: number): T { - this.throwIfDisposed(); - return stridedSlice( - this, begin, end, strides, beginMask, endMask, ellipsisMask, - newAxisMask, shrinkAxisMask) as T; -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/sub.ts b/tfjs-master/tfjs-core/src/public/chained_ops/sub.ts deleted file mode 100644 index 5e0fa3f77..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/sub.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {sub} from '../../ops/sub'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank, TensorLike} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - sub(b: Tensor|TensorLike): T; - } -} - -getGlobalTensorClass().prototype.sub = function( - b: Tensor|TensorLike): T { - this.throwIfDisposed(); - return sub(this, b); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/sum.ts b/tfjs-master/tfjs-core/src/public/chained_ops/sum.ts deleted file mode 100644 index 01f3a2b74..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/sum.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {sum} from '../../ops/sum'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - sum(axis?: number|number[], keepDims?: boolean): T; - } -} - -getGlobalTensorClass().prototype.sum = function( - axis?: number|number[], keepDims?: boolean): T { - this.throwIfDisposed(); - return sum(this, axis, keepDims); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/tan.ts b/tfjs-master/tfjs-core/src/public/chained_ops/tan.ts deleted file mode 100644 index 7717f596e..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/tan.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// TODO update import path once op is modularized. -import {tan} from '../../ops/ops'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - tan(this: T): T; - } -} - -getGlobalTensorClass().prototype.tan = function(this: T): T { - this.throwIfDisposed(); - return tan(this); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/tanh.ts b/tfjs-master/tfjs-core/src/public/chained_ops/tanh.ts deleted file mode 100644 index 2d8656955..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/tanh.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// TODO update import path once op is modularized. -import {tanh} from '../../ops/ops'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - tanh(this: T): T; - } -} - -getGlobalTensorClass().prototype.tanh = function(this: T): T { - this.throwIfDisposed(); - return tanh(this); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/tile.ts b/tfjs-master/tfjs-core/src/public/chained_ops/tile.ts deleted file mode 100644 index 731b0457d..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/tile.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {tile} from '../../ops/tile'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - tile(b: number[]): T; - } -} - -getGlobalTensorClass().prototype.tile = function( - reps: number[]): T { - this.throwIfDisposed(); - return tile(this, reps) as T; -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/to_bool.ts b/tfjs-master/tfjs-core/src/public/chained_ops/to_bool.ts deleted file mode 100644 index 123f1342d..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/to_bool.ts +++ /dev/null @@ -1,38 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// TODO update import path once op is modularized. -import {cast} from '../../ops/ops'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - toBool(this: T): T; - } -} - -/** - * Casts the array to type `bool` - * - * @doc {heading: 'Tensors', subheading: 'Classes'} - */ -getGlobalTensorClass().prototype.toBool = function(this: T): - T { - this.throwIfDisposed(); - return cast(this, 'bool'); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/to_float.ts b/tfjs-master/tfjs-core/src/public/chained_ops/to_float.ts deleted file mode 100644 index 59ea64dde..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/to_float.ts +++ /dev/null @@ -1,38 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// TODO update import path once op is modularized. -import {cast} from '../../ops/ops'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - toFloat(this: T): T; - } -} - -/** - * Casts the array to type `float32` - * - * @doc {heading: 'Tensors', subheading: 'Classes'} - */ -getGlobalTensorClass().prototype.toFloat = function(this: T): - T { - this.throwIfDisposed(); - return cast(this, 'float32'); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/to_int.ts b/tfjs-master/tfjs-core/src/public/chained_ops/to_int.ts deleted file mode 100644 index ef6bd9466..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/to_int.ts +++ /dev/null @@ -1,38 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// TODO update import path once op is modularized. -import {cast} from '../../ops/ops'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - toInt(this: T): T; - } -} - -/** - * Casts the array to type `int32` - * - * @doc {heading: 'Tensors', subheading: 'Classes'} - */ -getGlobalTensorClass().prototype.toInt = function(this: T): - T { - this.throwIfDisposed(); - return cast(this, 'int32'); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/topk.ts b/tfjs-master/tfjs-core/src/public/chained_ops/topk.ts deleted file mode 100644 index 2ccbf9473..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/topk.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {topk} from '../../ops/topk'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - topk(this: T, k?: number, sorted?: boolean): - {values: T, indices: T}; - } -} - -getGlobalTensorClass().prototype.topk = function( - this: T, k?: number, sorted?: boolean): {values: T, indices: T} { - this.throwIfDisposed(); - return topk(this, k, sorted) as {values: T, indices: T}; -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/transpose.ts b/tfjs-master/tfjs-core/src/public/chained_ops/transpose.ts deleted file mode 100644 index dd5fbe48c..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/transpose.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {transpose} from '../../ops/transpose'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - transpose(perm?: number[]): T; - } -} - -getGlobalTensorClass().prototype.transpose = function( - this: T, perm?: number[]): T { - this.throwIfDisposed(); - return transpose(this, perm); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/unique.ts b/tfjs-master/tfjs-core/src/public/chained_ops/unique.ts deleted file mode 100644 index 139336bcb..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/unique.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {unique} from '../../ops/unique'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - unique(this: T, axis?: number): {values: T, indices: T}; - } -} - -getGlobalTensorClass().prototype.unique = function( - this: T, axis?: number): {values: T, indices: T} { - this.throwIfDisposed(); - return unique(this, axis) as {values: T, indices: T}; -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/unsorted_segment_sum.ts b/tfjs-master/tfjs-core/src/public/chained_ops/unsorted_segment_sum.ts deleted file mode 100644 index a5fff2bd4..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/unsorted_segment_sum.ts +++ /dev/null @@ -1,34 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {unsortedSegmentSum} from '../../ops/unsorted_segment_sum'; -import {getGlobalTensorClass, Tensor, Tensor1D} from '../../tensor'; -import {Rank, TensorLike1D} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - unsortedSegmentSum( - this: T, segmentIds: Tensor1D|TensorLike1D, numSegments: number): T; - } -} - -getGlobalTensorClass().prototype.unsortedSegmentSum = - function( - this: T, segmentIds: Tensor1D|TensorLike1D, numSegments: number): T { - this.throwIfDisposed(); - return unsortedSegmentSum(this, segmentIds, numSegments); -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/unstack.ts b/tfjs-master/tfjs-core/src/public/chained_ops/unstack.ts deleted file mode 100644 index 69ebda651..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/unstack.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {unstack} from '../../ops/unstack'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - unstack(axis?: number): T[]; - } -} - -getGlobalTensorClass().prototype.unstack = function( - axis?: number): T[] { - this.throwIfDisposed(); - return unstack(this, axis) as T[]; -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/where.ts b/tfjs-master/tfjs-core/src/public/chained_ops/where.ts deleted file mode 100644 index c3ed66e24..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/where.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {where} from '../../ops/where'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank, TensorLike} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - where(condition: Tensor|TensorLike, x: Tensor|TensorLike): - T; - } -} - -getGlobalTensorClass().prototype.where = function( - condition: Tensor|TensorLike, x: Tensor|TensorLike): T { - this.throwIfDisposed(); - return where(condition, this, x) as T; -}; diff --git a/tfjs-master/tfjs-core/src/public/chained_ops/zeros_like.ts b/tfjs-master/tfjs-core/src/public/chained_ops/zeros_like.ts deleted file mode 100644 index 56104301e..000000000 --- a/tfjs-master/tfjs-core/src/public/chained_ops/zeros_like.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// TODO update import path once op is modularized. -import {zerosLike} from '../../ops/ops'; -import {getGlobalTensorClass, Tensor} from '../../tensor'; -import {Rank} from '../../types'; - -declare module '../../tensor' { - interface Tensor { - zerosLike(this: T): T; - } -} - -getGlobalTensorClass().prototype.zerosLike = function( - this: T): T { - this.throwIfDisposed(); - return zerosLike(this); -}; diff --git a/tfjs-master/tfjs-core/src/register_all_gradients.ts b/tfjs-master/tfjs-core/src/register_all_gradients.ts deleted file mode 100644 index e3e0e281c..000000000 --- a/tfjs-master/tfjs-core/src/register_all_gradients.ts +++ /dev/null @@ -1,232 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -import {absGradConfig} from './gradients/Abs_grad'; -import {acosGradConfig} from './gradients/Acos_grad'; -import {acoshGradConfig} from './gradients/Acosh_grad'; -import {addGradConfig} from './gradients/Add_grad'; -import {addNGradConfig} from './gradients/AddN_grad'; -import {argMaxGradConfig} from './gradients/ArgMax_grad'; -import {argMinGradConfig} from './gradients/ArgMin_grad'; -import {asinGradConfig} from './gradients/Asin_grad'; -import {asinhGradConfig} from './gradients/Asinh_grad'; -import {atan2GradConfig} from './gradients/Atan2_grad'; -import {atanGradConfig} from './gradients/Atan_grad'; -import {atanhGradConfig} from './gradients/Atanh_grad'; -import {avgPool3DGradConfig} from './gradients/AvgPool3D_grad'; -import {avgPoolGradConfig} from './gradients/AvgPool_grad'; -import {batchMatMulGradConfig} from './gradients/BatchMatMul_grad'; -import {batchToSpaceNDGradConfig} from './gradients/BatchToSpaceND_grad'; -import {broadcastToGradConfig} from './gradients/BroadcastTo_grad'; -import {castGradConfig} from './gradients/Cast_grad'; -import {ceilGradConfig} from './gradients/Ceil_grad'; -import {clipByValueGradConfig} from './gradients/ClipByValue_grad'; -import {complexAbsGradConfig} from './gradients/ComplexAbs_grad'; -import {concatGradConfig} from './gradients/Concat_grad'; -import {conv2DGradConfig} from './gradients/Conv2D_grad'; -import {conv2DBackpropInputGradConfig} from './gradients/Conv2DBackpropInput_grad'; -import {conv3DGradConfig} from './gradients/Conv3D_grad'; -import {cosGradConfig} from './gradients/Cos_grad'; -import {coshGradConfig} from './gradients/Cosh_grad'; -import {cumsumGradConfig} from './gradients/Cumsum_grad'; -import {depthwiseConv2dNativeGradConfig} from './gradients/DepthwiseConv2dNative_grad'; -import {dilation2dGradConfig} from './gradients/Dilation2D_grad'; -import {eluGradConfig} from './gradients/Elu_grad'; -import {erfGradConfig} from './gradients/Erf_grad'; -import {expGradConfig} from './gradients/Exp_grad'; -import {expandDimsGradConfig} from './gradients/ExpandDims_grad'; -import {expm1GradConfig} from './gradients/Expm1_grad'; -import {floorGradConfig} from './gradients/Floor_grad'; -import {floorDivGradConfig} from './gradients/FloorDiv_grad'; -import {fusedBatchNormGradConfig} from './gradients/FusedBatchNorm_grad'; -import {gatherGradConfig} from './gradients/GatherV2_grad'; -import {greaterEqualGradConfig} from './gradients/GreaterEqual_grad'; -import {identityGradConfig} from './gradients/Identity_grad'; -import {isFiniteGradConfig} from './gradients/IsFinite_grad'; -import {isInfGradConfig} from './gradients/IsInf_grad'; -import {isNanGradConfig} from './gradients/IsNan_grad'; -import {leakyReluGradConfig} from './gradients/LeakyRelu_grad'; -import {log1pGradConfig} from './gradients/Log1p_grad'; -import {logGradConfig} from './gradients/Log_grad'; -import {logSoftmaxGradConfig} from './gradients/LogSoftmax_grad'; -import {lrnGradConfig} from './gradients/LRN_grad'; -import {maxGradConfig} from './gradients/Max_grad'; -import {maximumGradConfig} from './gradients/Maximum_grad'; -import {maxPool3DGradConfig} from './gradients/MaxPool3D_grad'; -import {maxPoolGradConfig} from './gradients/MaxPool_grad'; -import {meanGradConfig} from './gradients/Mean_grad'; -import {minGradConfig} from './gradients/Min_grad'; -import {minimumGradConfig} from './gradients/Minimum_grad'; -import {mirrorPadGradConfig} from './gradients/MirrorPad_grad'; -import {modGradConfig} from './gradients/Mod_grad'; -import {multiplyGradConfig} from './gradients/Multiply_grad'; -import {negGradConfig} from './gradients/Neg_grad'; -import {oneHotGradConfig} from './gradients/OneHot_grad'; -import {onesLikeGradConfig} from './gradients/OnesLike_grad'; -import {packGradConfig} from './gradients/Pack_grad'; -import {padV2GradConfig} from './gradients/PadV2_grad'; -import {powGradConfig} from './gradients/Pow_grad'; -import {preluGradConfig} from './gradients/Prelu_grad'; -import {prodGradConfig} from './gradients/Prod_grad'; -import {divGradConfig} from './gradients/RealDiv_grad'; -import {reciprocalGradConfig} from './gradients/Reciprocal_grad'; -import {relu6GradConfig} from './gradients/Relu6_grad'; -import {reluGradConfig} from './gradients/Relu_grad'; -import {reshapeGradConfig} from './gradients/Reshape_grad'; -import {resizeBilinearGradConfig} from './gradients/ResizeBilinear_grad'; -import {resizeNearestNeighborGradConfig} from './gradients/ResizeNearestNeighbor_grad'; -import {reverseGradConfig} from './gradients/Reverse_grad'; -import {roundGradConfig} from './gradients/Round_grad'; -import {rsqrtGradConfig} from './gradients/Rsqrt_grad'; -import {selectGradConfig} from './gradients/Select_grad'; -import {seluGradConfig} from './gradients/Selu_grad'; -import {sigmoidGradConfig} from './gradients/Sigmoid_grad'; -import {signGradConfig} from './gradients/Sign_grad'; -import {sinGradConfig} from './gradients/Sin_grad'; -import {sinhGradConfig} from './gradients/Sinh_grad'; -import {sliceGradConfig} from './gradients/Slice_grad'; -import {softmaxGradConfig} from './gradients/Softmax_grad'; -import {softplusGradConfig} from './gradients/Softplus_grad'; -import {spaceToBatchNDGradConfig} from './gradients/SpaceToBatchND_grad'; -import {splitVGradConfig} from './gradients/SplitV_grad'; -import {sqrtGradConfig} from './gradients/Sqrt_grad'; -import {squareGradConfig} from './gradients/Square_grad'; -import {squaredDifferenceGradConfig} from './gradients/SquaredDifference_grad'; -import {stepGradConfig} from './gradients/Step_grad'; -import {subGradConfig} from './gradients/Sub_grad'; -import {sumGradConfig} from './gradients/Sum_grad'; -import {tanGradConfig} from './gradients/Tan_grad'; -import {tanhGradConfig} from './gradients/Tanh_grad'; -import {tileGradConfig} from './gradients/Tile_grad'; -import {transposeGradConfig} from './gradients/Transpose_grad'; -import {unpackGradConfig} from './gradients/Unpack_grad'; -import {unsortedSegmentSumGradConfig} from './gradients/UnsortedSegmentSum_grad'; -import {zerosLikeGradConfig} from './gradients/ZerosLike_grad'; -import {GradConfig} from './kernel_registry'; -import {registerGradient} from './kernel_registry'; - -// Export all kernel configs here so that the package can auto register them -const gradConfigs: GradConfig[] = [ - absGradConfig, - acosGradConfig, - acoshGradConfig, - addGradConfig, - addNGradConfig, - argMaxGradConfig, - argMinGradConfig, - asinGradConfig, - asinhGradConfig, - atan2GradConfig, - atanGradConfig, - atanhGradConfig, - avgPool3DGradConfig, - avgPoolGradConfig, - batchMatMulGradConfig, - batchToSpaceNDGradConfig, - broadcastToGradConfig, - castGradConfig, - ceilGradConfig, - clipByValueGradConfig, - complexAbsGradConfig, - concatGradConfig, - conv2DBackpropInputGradConfig, - conv2DGradConfig, - conv3DGradConfig, - cosGradConfig, - coshGradConfig, - cumsumGradConfig, - depthwiseConv2dNativeGradConfig, - dilation2dGradConfig, - divGradConfig, - eluGradConfig, - erfGradConfig, - expGradConfig, - expandDimsGradConfig, - expm1GradConfig, - floorDivGradConfig, - floorGradConfig, - fusedBatchNormGradConfig, - gatherGradConfig, - greaterEqualGradConfig, - identityGradConfig, - isFiniteGradConfig, - isInfGradConfig, - isNanGradConfig, - leakyReluGradConfig, - log1pGradConfig, - logGradConfig, - logSoftmaxGradConfig, - lrnGradConfig, - maxGradConfig, - maxGradConfig, - maximumGradConfig, - maxPool3DGradConfig, - maxPoolGradConfig, - meanGradConfig, - minGradConfig, - minimumGradConfig, - mirrorPadGradConfig, - modGradConfig, - multiplyGradConfig, - negGradConfig, - oneHotGradConfig, - onesLikeGradConfig, - packGradConfig, - padV2GradConfig, - padV2GradConfig, - powGradConfig, - preluGradConfig, - prodGradConfig, - reciprocalGradConfig, - relu6GradConfig, - reluGradConfig, - reshapeGradConfig, - resizeBilinearGradConfig, - resizeNearestNeighborGradConfig, - reverseGradConfig, - roundGradConfig, - rsqrtGradConfig, - selectGradConfig, - seluGradConfig, - sigmoidGradConfig, - signGradConfig, - sinGradConfig, - sinhGradConfig, - sliceGradConfig, - softmaxGradConfig, - softplusGradConfig, - spaceToBatchNDGradConfig, - spaceToBatchNDGradConfig, - splitVGradConfig, - splitVGradConfig, - sqrtGradConfig, - squaredDifferenceGradConfig, - squareGradConfig, - stepGradConfig, - subGradConfig, - sumGradConfig, - tanGradConfig, - tanhGradConfig, - tileGradConfig, - transposeGradConfig, - unpackGradConfig, - unsortedSegmentSumGradConfig, - zerosLikeGradConfig -]; - -for (const gradientConfig of gradConfigs) { - registerGradient(gradientConfig); -} diff --git a/tfjs-master/tfjs-core/src/serialization.ts b/tfjs-master/tfjs-core/src/serialization.ts deleted file mode 100644 index 621a9a639..000000000 --- a/tfjs-master/tfjs-core/src/serialization.ts +++ /dev/null @@ -1,282 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {assert} from './util'; - -/** - * Types to support JSON-esque data structures internally. - * - * Internally ConfigDict's use camelCase keys and values where the - * values are class names to be instantiated. On the python side, these - * will be snake_case. Internally we allow Enums into the values for better - * type safety, but these need to be converted to raw primitives (usually - * strings) for round-tripping with python. - * - * toConfig returns the TS-friendly representation. model.toJSON() returns - * the pythonic version as that's the portable format. If you need to - * python-ify a non-model level toConfig output, you'll need to use a - * convertTsToPythonic from serialization_utils in -Layers. - * - */ -export declare type ConfigDictValue = - boolean | number | string | null | ConfigDictArray | ConfigDict; -export declare interface ConfigDict { - [key: string]: ConfigDictValue; -} -export declare interface ConfigDictArray extends Array {} - -/** - * Type to represent the class-type of Serializable objects. - * - * Ie the class prototype with access to the constructor and any - * static members/methods. Instance methods are not listed here. - * - * Source for this idea: https://stackoverflow.com/a/43607255 - */ -export declare type SerializableConstructor = { - // tslint:disable-next-line:no-any - new (...args: any[]): T; className: string; fromConfig: FromConfigMethod; -}; -export declare type FromConfigMethod = - (cls: SerializableConstructor, config: ConfigDict) => T; - -/** - * Maps to mapping between the custom object and its name. - * - * After registering a custom class, these two maps will add key-value pairs - * for the class object and the registered name. - * - * Therefore we can get the relative registered name by calling - * getRegisteredName() function. - * - * For example: - * GLOBAL_CUSTOM_OBJECT: {key=registeredName: value=corresponding - * CustomObjectClass} - * - * GLOBAL_CUSTOM_NAMES: {key=CustomObjectClass: value=corresponding - * registeredName} - * - */ -const GLOBAL_CUSTOM_OBJECT = - new Map>(); - -const GLOBAL_CUSTOM_NAMES = - new Map, string>(); - -/** - * Serializable defines the serialization contract. - * - * TFJS requires serializable classes to return their className when asked - * to avoid issues with minification. - */ -export abstract class Serializable { - /** - * Return the class name for this class to use in serialization contexts. - * - * Generally speaking this will be the same thing that constructor.name - * would have returned. However, the class name needs to be robust - * against minification for serialization/deserialization to work properly. - * - * There's also places such as initializers.VarianceScaling, where - * implementation details between different languages led to different - * class hierarchies and a non-leaf node is used for serialization purposes. - */ - getClassName(): string { - return (this.constructor as SerializableConstructor) - .className; - } - - /** - * Return all the non-weight state needed to serialize this object. - */ - abstract getConfig(): ConfigDict; - - /** - * Creates an instance of T from a ConfigDict. - * - * This works for most descendants of serializable. A few need to - * provide special handling. - * @param cls A Constructor for the class to instantiate. - * @param config The Configuration for the object. - */ - /** @nocollapse */ - static fromConfig( - cls: SerializableConstructor, config: ConfigDict): T { - return new cls(config); - } -} - -/** - * Maps string keys to class constructors. - * - * Used during (de)serialization from the cross-language JSON format, which - * requires the class name in the serialization format matches the class - * names as used in Python, should it exist. - */ -export class SerializationMap { - private static instance: SerializationMap; - classNameMap: { - [className: string]: - [SerializableConstructor, FromConfigMethod] - }; - - private constructor() { - this.classNameMap = {}; - } - - /** - * Returns the singleton instance of the map. - */ - static getMap(): SerializationMap { - if (SerializationMap.instance == null) { - SerializationMap.instance = new SerializationMap(); - } - return SerializationMap.instance; - } - - /** - * Registers the class as serializable. - */ - static register(cls: SerializableConstructor) { - SerializationMap.getMap().classNameMap[cls.className] = - [cls, cls.fromConfig]; - } -} - -/** - * Register a class with the serialization map of TensorFlow.js. - * - * This is often used for registering custom Layers, so they can be - * serialized and deserialized. - * - * Example 1. Register the class without package name and specified name. - * - * ```js - * class MyCustomLayer extends tf.layers.Layer { - * static className = 'MyCustomLayer'; - * - * constructor(config) { - * super(config); - * } - * } - * tf.serialization.registerClass(MyCustomLayer); - * console.log(tf.serialization.GLOBALCUSTOMOBJECT.get("Custom>MyCustomLayer")); - * console.log(tf.serialization.GLOBALCUSTOMNAMES.get(MyCustomLayer)); - * ``` - * - * Example 2. Register the class with package name: "Package" and specified - * name: "MyLayer". - * ```js - * class MyCustomLayer extends tf.layers.Layer { - * static className = 'MyCustomLayer'; - * - * constructor(config) { - * super(config); - * } - * } - * tf.serialization.registerClass(MyCustomLayer, "Package", "MyLayer"); - * console.log(tf.serialization.GLOBALCUSTOMOBJECT.get("Package>MyLayer")); - * console.log(tf.serialization.GLOBALCUSTOMNAMES.get(MyCustomLayer)); - * ``` - * - * Example 3. Register the class with specified name: "MyLayer". - * ```js - * class MyCustomLayer extends tf.layers.Layer { - * static className = 'MyCustomLayer'; - * - * constructor(config) { - * super(config); - * } - * } - * tf.serialization.registerClass(MyCustomLayer, undefined, "MyLayer"); - * console.log(tf.serialization.GLOBALCUSTOMOBJECT.get("Custom>MyLayer")); - * console.log(tf.serialization.GLOBALCUSTOMNAMES.get(MyCustomLayer)); - * ``` - * - * Example 4. Register the class with specified package name: "Package". - * ```js - * class MyCustomLayer extends tf.layers.Layer { - * static className = 'MyCustomLayer'; - * - * constructor(config) { - * super(config); - * } - * } - * tf.serialization.registerClass(MyCustomLayer, "Package"); - * console.log(tf.serialization.GLOBALCUSTOMOBJECT - * .get("Package>MyCustomLayer")); - * console.log(tf.serialization.GLOBALCUSTOMNAMES - * .get(MyCustomLayer)); - * ``` - * - * @param cls The class to be registered. It must have a public static member - * called `className` defined and the value must be a non-empty string. - * @param pkg The pakcage name that this class belongs to. This used to define - * the key in GlobalCustomObject. If not defined, it defaults to `Custom`. - * @param name The name that user specified. It defaults to the actual name of - * the class as specified by its static `className` property. - * @doc {heading: 'Models', subheading: 'Serialization', ignoreCI: true} - */ -export function registerClass( - cls: SerializableConstructor, pkg?: string, name?: string) { - assert( - cls.className != null, - () => `Class being registered does not have the static className ` + - `property defined.`); - assert( - typeof cls.className === 'string', - () => `className is required to be a string, but got type ` + - typeof cls.className); - assert( - cls.className.length > 0, - () => `Class being registered has an empty-string as its className, ` + - `which is disallowed.`); - - if (typeof pkg === 'undefined') { - pkg = 'Custom'; - } - - if (typeof name === 'undefined') { - name = cls.className; - } - - const className = name; - const registerName = pkg + '>' + className; - - SerializationMap.register(cls); - GLOBAL_CUSTOM_OBJECT.set(registerName, cls); - GLOBAL_CUSTOM_NAMES.set(cls, registerName); - - return cls; -} - -/** - * Get the registered name of a class. If the class has not been registered, - * return the class name. - * - * @param cls The class we want to get register name for. It must have a public - * static member called `className` defined. - * @returns registered name or class name. - */ -export function getRegisteredName( - cls: SerializableConstructor) { - if (GLOBAL_CUSTOM_NAMES.has(cls)) { - return GLOBAL_CUSTOM_NAMES.get(cls); - } else { - return cls.className; - } -} diff --git a/tfjs-master/tfjs-core/src/serialization_test.ts b/tfjs-master/tfjs-core/src/serialization_test.ts deleted file mode 100644 index 2c135b979..000000000 --- a/tfjs-master/tfjs-core/src/serialization_test.ts +++ /dev/null @@ -1,89 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Optimizer} from './optimizers/optimizer'; -import {ConfigDict, registerClass, SerializationMap} from './serialization'; -import {NamedVariableMap} from './tensor_types'; - -describe('registerClass', () => { - const randomClassName = `OptimizerForTest${Math.random()}`; - class OptimizerForTest extends Optimizer { - static className = randomClassName; - constructor() { - super(); - } - applyGradients(variableGradients: NamedVariableMap) {} - - getConfig(): ConfigDict { - return {}; - } - } - it('registerClass succeeds', () => { - registerClass(OptimizerForTest); - expect(SerializationMap.getMap().classNameMap[randomClassName] != null) - .toEqual(true); - }); - - class OptimizerWithoutClassName extends Optimizer { - constructor() { - super(); - } - applyGradients(variableGradients: NamedVariableMap) {} - - getConfig(): ConfigDict { - return {}; - } - } - it('registerClass fails on missing className', () => { - // tslint:disable-next-line:no-any - expect(() => registerClass(OptimizerWithoutClassName as any)) - .toThrowError(/does not have the static className property/); - }); - - class OptimizerWithEmptyClassName extends Optimizer { - static className = ''; - constructor() { - super(); - } - applyGradients(variableGradients: NamedVariableMap) {} - - getConfig(): ConfigDict { - return {}; - } - } - it('registerClass fails on missing className', () => { - expect(() => registerClass(OptimizerWithEmptyClassName)) - .toThrowError(/has an empty-string as its className/); - }); - - class OptimizerWithNonStringClassName extends Optimizer { - static className = 42; - constructor() { - super(); - } - applyGradients(variableGradients: NamedVariableMap) {} - - getConfig(): ConfigDict { - return {}; - } - } - it('registerClass fails on missing className', () => { - // tslint:disable-next-line:no-any - expect(() => registerClass(OptimizerWithNonStringClassName as any)) - .toThrowError(/is required to be a string, but got type number/); - }); -}); diff --git a/tfjs-master/tfjs-core/src/setup_test.ts b/tfjs-master/tfjs-core/src/setup_test.ts deleted file mode 100644 index 96bb5ed65..000000000 --- a/tfjs-master/tfjs-core/src/setup_test.ts +++ /dev/null @@ -1,41 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// Register the CPU backend as a default backend for tests. -import '@tensorflow/tfjs-backend-cpu'; -/** - * This file is necessary so we register all test environments before we start - * executing tests. - */ -import {setTestEnvs, setupTestFilters, TestFilter} from './jasmine_util'; -// Register all chained ops for tests. -import './public/chained_ops/register_all_chained_ops'; -// Register all gradients for tests -import './register_all_gradients'; - -// Set up a CPU test env as the default test env -setTestEnvs([{name: 'cpu', backendName: 'cpu', isDataSync: true}]); - -const TEST_FILTERS: TestFilter[] = []; -const customInclude = () => true; -setupTestFilters(TEST_FILTERS, customInclude); - -// Import and run all the tests. -// This import, which registers all tests, must be a require because it must run -// after the test environment is set up. -// tslint:disable-next-line:no-require-imports -require('./tests'); diff --git a/tfjs-master/tfjs-core/src/tape.ts b/tfjs-master/tfjs-core/src/tape.ts deleted file mode 100644 index 3266a2170..000000000 --- a/tfjs-master/tfjs-core/src/tape.ts +++ /dev/null @@ -1,193 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Tensor} from './tensor'; -import {NamedTensorMap} from './tensor_types'; -import * as util from './util'; - -export interface TapeNode { - id: number; - kernelName: string; - outputs: Tensor[]; - inputs: NamedTensorMap; - // Optional params, defined only for ops with gradient impl. - gradient?: (dys: Tensor[]) => NamedGradientMap; - saved?: Tensor[]; -} - -export type NamedGradientMap = { - [inputName: string]: () => Tensor; -}; - -/** - * Computes a list of TapeNodes that connect x to y, filtering everything else - * out and preserving the order of the original tape elements. - * - * @param tape The tape elements to filter. - * @param xs The input Tensors. - * @param y The output Tensor. - */ -export function getFilteredNodesXToY( - tape: TapeNode[], xs: Tensor[], y: Tensor): TapeNode[] { - // Forward pass to compute all the nodes and Tensors that are transitively a - // function of x. - const tensorsFromX: {[tensorId: number]: boolean} = {}; - const nodesFromX: {[nodeId: number]: boolean} = {}; - for (let i = 0; i < xs.length; i++) { - tensorsFromX[xs[i].id] = true; - } - - for (let i = 0; i < tape.length; i++) { - const node = tape[i]; - const nodeInputs = node.inputs; - for (const inputName in nodeInputs) { - const input = nodeInputs[inputName]; - - let anyInputFromX = false; - for (let j = 0; j < xs.length; j++) { - if (tensorsFromX[input.id]) { - node.outputs.forEach(output => tensorsFromX[output.id] = true); - anyInputFromX = true; - nodesFromX[node.id] = true; - break; - } - } - - if (anyInputFromX) { - break; - } - } - } - - // Backward pass to find all of the nodes and Tensors that lead to y. - const tensorsLeadToY: {[tensorId: number]: boolean} = {}; - tensorsLeadToY[y.id] = true; - const nodesToY: {[nodeId: number]: boolean} = {}; - - for (let i = tape.length - 1; i >= 0; i--) { - const node = tape[i]; - const nodeInputs = node.inputs; - - // If any of the outputs lead to y, mark all of the inputs as leading to y. - for (let j = 0; j < node.outputs.length; j++) { - if (tensorsLeadToY[node.outputs[j].id]) { - for (const inputName in nodeInputs) { - tensorsLeadToY[nodeInputs[inputName].id] = true; - nodesToY[node.id] = true; - } - break; - } - } - } - - // Return the paths that come from x and lead to y. - const filteredTape: TapeNode[] = []; - for (let i = 0; i < tape.length; i++) { - const node = tape[i]; - - if (nodesFromX[node.id] && nodesToY[node.id]) { - // Prune the inputs from the node that aren't a function of x. - const prunedInputs: {[inputName: string]: Tensor} = {}; - for (const inputName in node.inputs) { - const nodeInput = node.inputs[inputName]; - if (tensorsFromX[nodeInput.id]) { - prunedInputs[inputName] = nodeInput; - } - } - - // Copy the node and overwrite inputsAndArgs to the pruned version. - const prunedNode = Object.assign({}, node); - prunedNode.inputs = prunedInputs; - prunedNode.outputs = node.outputs; - - filteredTape.push(prunedNode); - } - } - - return filteredTape; -} - -/** - * Backpropagate gradients through the filtered TapeNodes. - * - * @param tensorAccumulatedGradientMap A map of Tensor to its gradient. This map - * is mutated by this method. - * @param filteredTape The filtered TapeNodes to backprop through. - */ -export function backpropagateGradients( - tensorAccumulatedGradientMap: {[tensorId: number]: Tensor}, - filteredTape: TapeNode[], tidy: (f: Function) => Tensor, - add: (a: Tensor, b: Tensor) => Tensor) { - // Walk the tape backward and keep a map of Tensor to its gradient. - for (let i = filteredTape.length - 1; i >= 0; i--) { - const node = filteredTape[i]; - - const dys: Tensor[] = []; - node.outputs.forEach(o => { - const gradTensor = tensorAccumulatedGradientMap[o.id]; - if (gradTensor != null) { - dys.push(gradTensor); - } else { - // This particular output is not in the back-propagation subgraph, so it - // does not affect the final output, thus we put null for its dy. - dys.push(null); - } - }); - - if (node.gradient == null) { - throw new Error( - `Cannot compute gradient: gradient function not found ` + - `for ${node.kernelName}.`); - } - - // Backprop dy through this node and accumulate gradients over the inputs. - const inputGradients = node.gradient(dys); - - for (const inputName in node.inputs) { - if (!(inputName in inputGradients)) { - throw new Error( - `Cannot backprop through input ${inputName}. ` + - `Available gradients found: ${Object.keys(inputGradients)}.`); - } - - // Call the gradient function. - const dx = tidy(() => inputGradients[inputName]()); - if (dx.dtype !== 'float32') { - throw new Error( - `Error in gradient for op ${ - node.kernelName}. The gradient of input ` + - `${inputName} must have 'float32' dtype, but has '${dx.dtype}'`); - } - const x = node.inputs[inputName]; - if (!util.arraysEqual(dx.shape, x.shape)) { - throw new Error( - `Error in gradient for op ${ - node.kernelName}. The gradient of input ` + - `'${inputName}' has shape '${dx.shape}', which does not match ` + - `the shape of the input '${x.shape}'`); - } - - if (tensorAccumulatedGradientMap[x.id] == null) { - tensorAccumulatedGradientMap[x.id] = dx; - } else { - const curGradient = tensorAccumulatedGradientMap[x.id]; - tensorAccumulatedGradientMap[x.id] = add(curGradient, dx); - curGradient.dispose(); - } - } - } -} diff --git a/tfjs-master/tfjs-core/src/tape_test.ts b/tfjs-master/tfjs-core/src/tape_test.ts deleted file mode 100644 index 874c4146d..000000000 --- a/tfjs-master/tfjs-core/src/tape_test.ts +++ /dev/null @@ -1,423 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {add, ScopeFn} from './engine'; -import * as tf from './index'; -import {ALL_ENVS, describeWithFlags} from './jasmine_util'; -import {zerosLike} from './ops/ops'; -import {backpropagateGradients, getFilteredNodesXToY, TapeNode} from './tape'; -import {expectArraysClose} from './test_util'; - -describeWithFlags('getFilteredNodesXToY', ALL_ENVS, () => { - it('no paths from x to y', () => { - const x = tf.scalar(1); - const intermediate1 = tf.scalar(0); - - const intermediate2 = tf.scalar(0); - const y = tf.scalar(2); - - const tape: TapeNode[] = [ - { - id: 0, - kernelName: 'node0', - inputs: {x}, - outputs: [intermediate1], - gradient: null - }, - { - id: 1, - kernelName: 'node1', - inputs: {intermediate2}, - outputs: [y], - gradient: null - } - ]; - - const filteredTapeNodes = getFilteredNodesXToY(tape, [x], y); - - expect(filteredTapeNodes.length).toBe(0); - expect(filteredTapeNodes).toEqual([]); - }); - - it('one operation x => y', () => { - const x = tf.scalar(1); - const y = tf.scalar(2); - - const tape: TapeNode[] = [ - {id: 0, kernelName: 'node0', inputs: {x}, outputs: [y], gradient: null} - ]; - - const filteredTapeNodes = getFilteredNodesXToY(tape, [x], y); - - expect(filteredTapeNodes.length).toBe(1); - expect(filteredTapeNodes).toEqual(tape); - }); - - it('1 operation [x0, x1] => y, all input paths', () => { - const x0 = tf.scalar(0); - const x1 = tf.scalar(1); - const y = tf.scalar(2); - - const tape: TapeNode[] = [{ - id: 0, - kernelName: 'node0', - inputs: {x0, x1}, - outputs: [y], - gradient: null - }]; - - const filteredTapeNodes = getFilteredNodesXToY(tape, [x0, x1], y); - - expect(filteredTapeNodes.length).toBe(1); - expect(filteredTapeNodes).toEqual(tape); - }); - - it('one operation [x0, x1] => y, one input paths', () => { - const x0 = tf.scalar(0); - const x1 = tf.scalar(1); - const y = tf.scalar(2); - - const tape: TapeNode[] = [{ - id: 0, - kernelName: 'node0', - inputs: {x0, x1}, - outputs: [y], - gradient: null - }]; - - const filteredTapeNodes = getFilteredNodesXToY(tape, [x0], y); - - expect(filteredTapeNodes.length).toBe(1); - // x1 input should be pruned, we don't ask for the gradient of x1. - expect(filteredTapeNodes[0]).toEqual({ - id: 0, - kernelName: 'node0', - inputs: {x0}, - outputs: [y], - gradient: null - }); - }); - - it('two operations x => intermediate => y', () => { - const x = tf.scalar(1); - const intermediate = tf.scalar(0); - const y = tf.scalar(2); - - const tape: TapeNode[] = [ - { - id: 0, - kernelName: 'node0', - inputs: {x}, - outputs: [intermediate], - gradient: null - }, - { - id: 1, - kernelName: 'node1', - inputs: {intermediate}, - outputs: [y], - gradient: null - } - ]; - - const filteredTapeNodes = getFilteredNodesXToY(tape, [x], y); - - expect(filteredTapeNodes.length).toBe(2); - expect(filteredTapeNodes).toEqual(tape); - }); - - it('two operations [x0, x1], [x2] => ' + - 'intermediate => y', - () => { - const x0 = tf.scalar(1); - const x1 = tf.scalar(2); - const x2 = tf.scalar(3); - const intermediate = tf.scalar(4); - const y = tf.scalar(2); - - const tape: TapeNode[] = [ - { - id: 0, - kernelName: 'node0', - inputs: {x0, x1}, - outputs: [intermediate], - gradient: null - }, - { - id: 1, - kernelName: 'node1', - inputs: {x2, intermediate}, - outputs: [y], - gradient: null - } - ]; - - const filteredTapeNodes = getFilteredNodesXToY(tape, [x0, x1, x2], y); - - expect(filteredTapeNodes.length).toBe(2); - expect(filteredTapeNodes).toEqual(tape); - }); - - it('x => y and x => orphan', () => { - const x = tf.scalar(1); - const orphan = tf.scalar(0); - const y = tf.scalar(2); - - const tape: TapeNode[] = [ - { - id: 0, - kernelName: 'node0', - inputs: {x}, - outputs: [orphan], - gradient: null - }, - {id: 1, kernelName: 'node1', inputs: {x}, outputs: [y], gradient: null} - ]; - - const filteredTapeNodes = getFilteredNodesXToY(tape, [x], y); - - expect(filteredTapeNodes.length).toBe(1); - // The orphan should be removed. - expect(filteredTapeNodes[0]).toEqual(tape[1]); - }); - - it('x => y and orphan => y', () => { - const x = tf.scalar(1); - const orphan = tf.scalar(0); - const y = tf.scalar(2); - - const tape: TapeNode[] = [{ - id: 0, - kernelName: 'node0', - inputs: {x, orphan}, - outputs: [y], - gradient: null - }]; - - const filteredTapeNodes = getFilteredNodesXToY(tape, [x], y); - - expect(filteredTapeNodes.length).toBe(1); - // The orphan should be pruned from the node's input. - expect(filteredTapeNodes[0]).toEqual({ - id: 0, - kernelName: 'node0', - inputs: {x}, - outputs: [y], - gradient: null - }); - }); - - it('1 op with 3 outputs x => y1, y2, y3', () => { - const x = tf.scalar(1); - const y1 = tf.scalar(2); - const y2 = tf.scalar(2); - const y3 = tf.scalar(2); - - const tape: TapeNode[] = [{ - id: 0, - kernelName: 'node0', - inputs: {x}, - outputs: [y1, y2, y3], - gradient: null - }]; - - const filteredNodes1 = getFilteredNodesXToY(tape, [x], y1); - expect(filteredNodes1.length).toBe(1); - expect(filteredNodes1).toEqual(tape); - - const filteredNodes2 = getFilteredNodesXToY(tape, [x], y2); - expect(filteredNodes2.length).toBe(1); - expect(filteredNodes2).toEqual(tape); - - const filteredNodes3 = getFilteredNodesXToY(tape, [x], y3); - expect(filteredNodes3.length).toBe(1); - expect(filteredNodes3).toEqual(tape); - }); -}); - -describeWithFlags('backpropagateGradients', ALL_ENVS, () => { - it('Throws if gradient is not defined', () => { - const x = tf.scalar(0); - const y = tf.scalar(1); - - const dy = tf.scalar(1); - - const accumulatedGradientsMap: {[tensorId: number]: tf.Tensor} = {}; - accumulatedGradientsMap[y.id] = dy; - - const tape: TapeNode[] = [ - {id: 0, kernelName: 'node0', inputs: {x}, outputs: [y], gradient: null} - ]; - - expect( - () => backpropagateGradients( - accumulatedGradientsMap, tape, - f => tf.tidy(f as ScopeFn), add)) - .toThrowError(); - }); - - it('basic backprop with 1 node', async () => { - const x = tf.scalar(0); - const y = tf.scalar(1); - - const dy = tf.scalar(1); - - const accumulatedGradientsMap: {[tensorId: number]: tf.Tensor} = {}; - accumulatedGradientsMap[y.id] = dy; - - const tape: TapeNode[] = [{ - id: 0, - kernelName: 'node0', - inputs: {x}, - outputs: [y], - gradient: (dys: tf.Tensor[]) => { - return {x: () => dys[0].add(tf.scalar(1))}; - } - }]; - - backpropagateGradients( - accumulatedGradientsMap, tape, f => tf.tidy(f as ScopeFn), - add); - - expectArraysClose(await accumulatedGradientsMap[x.id].data(), [2]); - }); - - it('basic backprop with 2 nodes', async () => { - const x = tf.scalar(0); - const intermediate = tf.scalar(1); - const y = tf.scalar(2); - - const dy = tf.scalar(1); - - const accumulatedGradientsMap: {[tensorId: number]: tf.Tensor} = {}; - accumulatedGradientsMap[y.id] = dy; - - const tape: TapeNode[] = [ - { - id: 0, - kernelName: 'node0', - inputs: {x}, - outputs: [intermediate], - gradient: (dys: tf.Tensor[]) => { - return {x: () => dys[0].add(tf.scalar(1))}; - } - }, - { - id: 1, - kernelName: 'node1', - inputs: {intermediate}, - outputs: [y], - gradient: (dys: tf.Tensor[]) => { - return {intermediate: () => dys[0].add(tf.scalar(1))}; - } - } - ]; - - backpropagateGradients( - accumulatedGradientsMap, tape, f => tf.tidy(f as ScopeFn), - add); - - // dx = dy + 1 + 1 - expectArraysClose(await accumulatedGradientsMap[x.id].data(), [3]); - }); - - it('basic backprop with a split node accumulates gradients', async () => { - const x = tf.scalar(0); - const intermediate1 = tf.scalar(1); - const intermediate2 = tf.scalar(2); - const y = tf.scalar(3); - - const dy = tf.scalar(1); - - const accumulatedGradientsMap: {[tensorId: number]: tf.Tensor} = {}; - accumulatedGradientsMap[y.id] = dy; - - const tape: TapeNode[] = [ - { - id: 0, - kernelName: 'node0', - inputs: {x}, - outputs: [intermediate1], - gradient: (dys: tf.Tensor[]) => { - return {x: () => dys[0].add(tf.scalar(1))}; - } - }, - { - id: 1, - kernelName: 'node1', - inputs: {x}, - outputs: [intermediate2], - gradient: (dys: tf.Tensor[]) => { - return {x: () => dys[0].add(tf.scalar(1))}; - } - }, - { - id: 2, - kernelName: 'node2', - inputs: {intermediate1, intermediate2}, - outputs: [y], - gradient: (dys: tf.Tensor[]) => { - return { - intermediate1: () => dys[0].add(tf.scalar(1)), - intermediate2: () => dys[0].add(tf.scalar(1)) - }; - } - } - ]; - - backpropagateGradients( - accumulatedGradientsMap, tape, f => tf.tidy(f as ScopeFn), - add); - - // dx = dy + 1 + 1 + 1 + 1 + 1 - expectArraysClose( - await accumulatedGradientsMap[x.id].data(), [(await dy.data())[0] + 5]); - }); - - it('backprop over 1 node with 3 outputs, w.r.t to the 2nd output', - async () => { - const x = tf.tensor1d([1, 1, 1]); - const y1 = tf.scalar(1); - const y2 = tf.scalar(1); - const y3 = tf.scalar(1); - - const accumulatedGradientsMap: {[tensorId: number]: tf.Tensor} = {}; - // Backproping through the 2nd output. - const dy2 = tf.scalar(5); - accumulatedGradientsMap[y2.id] = dy2; - - let dys: tf.Scalar[]; - const tape: TapeNode[] = [{ - id: 0, - kernelName: 'node0', - inputs: {x}, - outputs: [y1, y2, y3], - gradient: (dys_: tf.Scalar[]) => { - dys = dys_.map(dy => dy || zerosLike(y1)); - return {x: () => tf.stack(dys)}; - } - }]; - - backpropagateGradients( - accumulatedGradientsMap, tape, f => tf.tidy(f as ScopeFn), - add); - expectArraysClose(await accumulatedGradientsMap[x.id].data(), [0, 5, 0]); - expectArraysClose(await dys[0].data(), [0]); - expectArraysClose(await dys[1].data(), [5]); - expectArraysClose(await dys[2].data(), [0]); - }); -}); diff --git a/tfjs-master/tfjs-core/src/tensor.ts b/tfjs-master/tfjs-core/src/tensor.ts deleted file mode 100644 index 137d3b487..000000000 --- a/tfjs-master/tfjs-core/src/tensor.ts +++ /dev/null @@ -1,610 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -// Workaround for: https://github.com/bazelbuild/rules_nodejs/issues/1265 -/// - -import {getGlobal} from './global_util'; -import {tensorToString} from './tensor_format'; -import {DataId, TensorInfo} from './tensor_info'; -import {ArrayMap, BackendValues, DataType, DataTypeMap, DataValues, NumericDataType, Rank, ShapeMap, SingleValueMap, TypedArray} from './types'; -import * as util from './util'; -import {computeStrides, toNestedArray} from './util'; - -export interface TensorData { - dataId?: DataId; - values?: DataTypeMap[D]; -} - -// This interface mimics KernelBackend (in backend.ts), which would create a -// circular dependency if imported. -export interface Backend {} - -/** - * A mutable object, similar to `tf.Tensor`, that allows users to set values - * at locations before converting to an immutable `tf.Tensor`. - * - * See `tf.buffer` for creating a tensor buffer. - * - * @doc {heading: 'Tensors', subheading: 'Classes'} - */ -export class TensorBuffer { - size: number; - shape: ShapeMap[R]; - strides: number[]; - values: DataTypeMap[D]; - - constructor(shape: ShapeMap[R], public dtype: D, values?: DataTypeMap[D]) { - this.shape = shape.slice() as ShapeMap[R]; - this.size = util.sizeFromShape(shape); - - if (values != null) { - const n = values.length; - util.assert( - n === this.size, - () => `Length of values '${n}' does not match the size ` + - `inferred by the shape '${this.size}'.`); - } - if (dtype === 'complex64') { - throw new Error( - `complex64 dtype TensorBuffers are not supported. Please create ` + - `a TensorBuffer for the real and imaginary parts separately and ` + - `call tf.complex(real, imag).`); - } - this.values = values || util.getArrayFromDType(dtype, this.size); - this.strides = computeStrides(shape); - } - - /** - * Sets a value in the buffer at a given location. - * - * @param value The value to set. - * @param locs The location indices. - * - * @doc {heading: 'Tensors', subheading: 'Creation'} - */ - set(value: SingleValueMap[D], ...locs: number[]): void { - if (locs.length === 0) { - locs = [0]; - } - util.assert( - locs.length === this.rank, - () => `The number of provided coordinates (${locs.length}) must ` + - `match the rank (${this.rank})`); - - const index = this.locToIndex(locs); - this.values[index] = value as number; - } - - /** - * Returns the value in the buffer at the provided location. - * - * @param locs The location indices. - * - * @doc {heading: 'Tensors', subheading: 'Creation'} - */ - get(...locs: number[]): SingleValueMap[D] { - if (locs.length === 0) { - locs = [0]; - } - let i = 0; - for (const loc of locs) { - if (loc < 0 || loc >= this.shape[i]) { - const msg = `Requested out of range element at ${locs}. ` + - ` Buffer shape=${this.shape}`; - throw new Error(msg); - } - i++; - } - let index = locs[locs.length - 1]; - for (let i = 0; i < locs.length - 1; ++i) { - index += this.strides[i] * locs[i]; - } - return this.values[index] as SingleValueMap[D]; - } - - locToIndex(locs: number[]): number { - if (this.rank === 0) { - return 0; - } else if (this.rank === 1) { - return locs[0]; - } - let index = locs[locs.length - 1]; - for (let i = 0; i < locs.length - 1; ++i) { - index += this.strides[i] * locs[i]; - } - return index; - } - - indexToLoc(index: number): number[] { - if (this.rank === 0) { - return []; - } else if (this.rank === 1) { - return [index]; - } - const locs: number[] = new Array(this.shape.length); - for (let i = 0; i < locs.length - 1; ++i) { - locs[i] = Math.floor(index / this.strides[i]); - index -= locs[i] * this.strides[i]; - } - locs[locs.length - 1] = index; - return locs; - } - - get rank() { - return this.shape.length; - } - - /** - * Creates an immutable `tf.Tensor` object from the buffer. - * - * @doc {heading: 'Tensors', subheading: 'Creation'} - */ - toTensor(): Tensor { - return trackerFn().makeTensor(this.values, this.shape, this.dtype) as - Tensor; - } -} - -export interface DataToGPUWebGLOption { - customTexShape?: [number, number]; -} - -export type DataToGPUOptions = DataToGPUWebGLOption; - -export interface GPUData { - tensorRef: Tensor; - texture?: WebGLTexture; - buffer?: GPUBuffer; - texShape?: [number, number]; -} - -export interface TensorTracker { - makeTensor( - values: DataValues, shape: number[], dtype: DataType, - backend?: Backend): Tensor; - makeVariable( - initialValue: Tensor, trainable?: boolean, name?: string, - dtype?: DataType): Variable; - incRef(a: Tensor, backend: Backend): void; - disposeTensor(t: Tensor): void; - disposeVariable(v: Variable): void; - read(dataId: DataId): Promise; - readSync(dataId: DataId): BackendValues; - readToGPU(dataId: DataId, options?: DataToGPUOptions): GPUData; -} - -/** - * The Tensor class calls into this handler to delegate chaining operations. - */ -export interface OpHandler { - cast(x: T, dtype: DataType): T; - buffer( - shape: ShapeMap[R], dtype: D, - values?: DataTypeMap[D]): TensorBuffer; - print(x: T, verbose: boolean): void; - clone(x: T): T; - // TODO(yassogba) bring reshape back? -} - -// For tracking tensor creation and disposal. -let trackerFn: () => TensorTracker = null; -// Used by chaining methods to call into ops. -let opHandler: OpHandler = null; -// Used to warn about deprecated methods. -let deprecationWarningFn: (msg: string) => void = null; -// This here so that we can use this method on dev branches and keep the -// functionality at master. -// tslint:disable-next-line:no-unused-expression -[deprecationWarningFn]; - -/** - * An external consumer can register itself as the tensor tracker. This way - * the Tensor class can notify the tracker for every tensor created and - * disposed. - */ -export function setTensorTracker(fn: () => TensorTracker) { - trackerFn = fn; -} - -/** - * An external consumer can register itself as the op handler. This way the - * Tensor class can have chaining methods that call into ops via the op - * handler. - */ -export function setOpHandler(handler: OpHandler) { - opHandler = handler; -} - -/** - * Sets the deprecation warning function to be used by this file. This way the - * Tensor class can be a leaf but still use the environment. - */ -export function setDeprecationWarningFn(fn: (msg: string) => void) { - deprecationWarningFn = fn; -} - -// Declare this namespace to make Tensor class augmentation work in google3. -export declare namespace Tensor {} -/** - * A `tf.Tensor` object represents an immutable, multidimensional array of - * numbers that has a shape and a data type. - * - * For performance reasons, functions that create tensors do not necessarily - * perform a copy of the data passed to them (e.g. if the data is passed as a - * `Float32Array`), and changes to the data will change the tensor. This is not - * a feature and is not supported. To avoid this behavior, use the tensor before - * changing the input data or create a copy with `copy = tf.add(yourTensor, 0)`. - * - * See `tf.tensor` for details on how to create a `tf.Tensor`. - * - * @doc {heading: 'Tensors', subheading: 'Classes'} - */ -export class Tensor implements TensorInfo { - /** Unique id of this tensor. */ - readonly id: number; - /** - * Id of the bucket holding the data for this tensor. Multiple arrays can - * point to the same bucket (e.g. when calling array.reshape()). - */ - dataId: DataId; - /** The shape of the tensor. */ - readonly shape: ShapeMap[R]; - /** Number of elements in the tensor. */ - readonly size: number; - /** The data type for the array. */ - readonly dtype: DataType; - /** The rank type for the array (see `Rank` enum). */ - readonly rankType: R; - - /** Whether this tensor has been globally kept. */ - kept = false; - /** The id of the scope this tensor is being tracked in. */ - scopeId: number; - /** The keras mask that some keras layers attach to the tensor */ - kerasMask?: Tensor; - - /** - * Number of elements to skip in each dimension when indexing. See - * https://docs.scipy.org/doc/numpy/reference/generated/\ - * numpy.ndarray.strides.html - */ - readonly strides: number[]; - - constructor(shape: ShapeMap[R], dtype: DataType, dataId: DataId, id: number) { - this.shape = shape.slice() as ShapeMap[R]; - this.dtype = dtype || 'float32'; - this.size = util.sizeFromShape(shape); - this.strides = computeStrides(shape); - this.dataId = dataId; - this.id = id; - this.rankType = (this.rank < 5 ? this.rank.toString() : 'higher') as R; - } - - get rank(): number { - return this.shape.length; - } - - /** - * Returns a promise of `tf.TensorBuffer` that holds the underlying data. - * - * @doc {heading: 'Tensors', subheading: 'Classes'} - */ - async buffer(): Promise> { - const vals = await this.data(); - return opHandler.buffer(this.shape, this.dtype as D, vals); - } - - /** - * Returns a `tf.TensorBuffer` that holds the underlying data. - * @doc {heading: 'Tensors', subheading: 'Classes'} - */ - bufferSync(): TensorBuffer { - return opHandler.buffer(this.shape, this.dtype as D, this.dataSync()); - } - - /** - * Returns the tensor data as a nested array. The transfer of data is done - * asynchronously. - * - * @doc {heading: 'Tensors', subheading: 'Classes'} - */ - async array(): Promise { - const vals = await this.data(); - return toNestedArray(this.shape, vals, this.dtype === 'complex64') as - ArrayMap[R]; - } - - /** - * Returns the tensor data as a nested array. The transfer of data is done - * synchronously. - * - * @doc {heading: 'Tensors', subheading: 'Classes'} - */ - arraySync(): ArrayMap[R] { - return toNestedArray( - this.shape, this.dataSync(), this.dtype === 'complex64') as - ArrayMap[R]; - } - - /** - * Asynchronously downloads the values from the `tf.Tensor`. Returns a - * promise of `TypedArray` that resolves when the computation has finished. - * - * @doc {heading: 'Tensors', subheading: 'Classes'} - */ - async data(): Promise { - this.throwIfDisposed(); - const data = trackerFn().read(this.dataId); - if (this.dtype === 'string') { - const bytes = await data as Uint8Array[]; - try { - return bytes.map(b => util.decodeString(b)) as DataTypeMap[D]; - } catch { - throw new Error( - 'Failed to decode the string bytes into utf-8. ' + - 'To get the original bytes, call tensor.bytes().'); - } - } - return data as Promise; - } - - /** - * Copy the tensor's data to a new GPU resource. Comparing to the `dataSync()` - * and `data()`, this method prevents data from being downloaded to CPU. - * - * For WebGL backend, the data will be stored on a densely packed texture. - * This means that the texture will use the RGBA channels to store value. - * - * For WebGPU backend, the data will be stored on a buffer. There is no - * parameter, so can not use a user-defined size to create the buffer. - * - * @param options: - * For WebGL, - * - customTexShape: Optional. If set, will use the user defined - * texture shape to create the texture. - * - * @returns For WebGL backend, a GPUData contains the new texture and - * its information. - * { - * tensorRef: The tensor that is associated with this texture, - * texture: WebGLTexture, - * texShape: [number, number] // [height, width] - * } - * - * For WebGPU backend, a GPUData contains the new buffer. - * { - * tensorRef: The tensor that is associated with this buffer, - * buffer: GPUBuffer, - * } - * - * Remember to dispose the GPUData after it is used by - * `res.tensorRef.dispose()`. - * - * @doc {heading: 'Tensors', subheading: 'Classes'} - */ - dataToGPU(options?: DataToGPUOptions): GPUData { - this.throwIfDisposed(); - return trackerFn().readToGPU(this.dataId, options); - } - - /** - * Synchronously downloads the values from the `tf.Tensor`. This blocks the - * UI thread until the values are ready, which can cause performance issues. - * - * @doc {heading: 'Tensors', subheading: 'Classes'} - */ - dataSync(): DataTypeMap[D] { - this.throwIfDisposed(); - const data = trackerFn().readSync(this.dataId); - if (this.dtype === 'string') { - try { - return (data as Uint8Array[]).map(b => util.decodeString(b)) as - DataTypeMap[D]; - } catch { - throw new Error( - 'Failed to decode the string bytes into utf-8. ' + - 'To get the original bytes, call tensor.bytes().'); - } - } - return data as DataTypeMap[D]; - } - - /** Returns the underlying bytes of the tensor's data. */ - async bytes(): Promise { - this.throwIfDisposed(); - const data = await trackerFn().read(this.dataId); - if (this.dtype === 'string') { - return data as Uint8Array[]; - } else { - return new Uint8Array((data as TypedArray).buffer); - } - } - - /** - * Disposes `tf.Tensor` from memory. - * - * @doc {heading: 'Tensors', subheading: 'Classes'} - */ - dispose(): void { - if (this.isDisposed) { - return; - } - if (this.kerasMask) { - this.kerasMask.dispose(); - } - trackerFn().disposeTensor(this); - this.isDisposedInternal = true; - } - - protected isDisposedInternal = false; - get isDisposed(): boolean { - return this.isDisposedInternal; - } - - throwIfDisposed() { - if (this.isDisposed) { - throw new Error(`Tensor is disposed.`); - } - } - - /** - * Prints the `tf.Tensor`. See `tf.print` for details. - * - * @param verbose Whether to print verbose information about the tensor, - * including dtype and size. - * - * @doc {heading: 'Tensors', subheading: 'Classes'} - */ - print(verbose = false): void { - return opHandler.print(this, verbose); - } - - /** - * Returns a copy of the tensor. See `tf.clone` for details. - * @doc {heading: 'Tensors', subheading: 'Classes'} - */ - clone(this: T): T { - this.throwIfDisposed(); - return opHandler.clone(this); - } - - /** - * Returns a human-readable description of the tensor. Useful for logging. - * - * @doc {heading: 'Tensors', subheading: 'Classes'} - */ - toString(verbose = false): string { - const vals = this.dataSync(); - return tensorToString(vals, this.shape, this.dtype, verbose); - } - - cast(dtype: DataType): T { - this.throwIfDisposed(); - return opHandler.cast(this as T, dtype); - } - variable(trainable = true, name?: string, dtype?: DataType): Variable { - this.throwIfDisposed(); - return trackerFn().makeVariable(this, trainable, name, dtype) as - Variable; - } -} - -Object.defineProperty(Tensor, Symbol.hasInstance, { - value: (instance: Tensor) => { - // Implementation note: we should use properties of the object that will be - // defined before the constructor body has finished executing (methods). - // This is because when this code is transpiled by babel, babel will call - // classCallCheck before the constructor body is run. - // See https://github.com/tensorflow/tfjs/issues/3384 for backstory. - return !!instance && instance.data != null && instance.dataSync != null && - instance.throwIfDisposed != null; - } -}); - -export function getGlobalTensorClass() { - // Use getGlobal so that we can augment the Tensor class across package - // boundaries becase the node resolution alg may result in different modules - // being returned for this file depending on the path they are loaded from. - return getGlobal('Tensor', () => { - return Tensor; - }); -} - -// Global side effect. Cache global reference to Tensor class -getGlobalTensorClass(); - -export interface NumericTensor extends Tensor { - dtype: NumericDataType; - dataSync(): DataTypeMap[D]; - data(): Promise; - dataToGPU(options?: DataToGPUOptions): GPUData; -} - -export interface StringTensor extends Tensor { - dtype: 'string'; - dataSync(): DataTypeMap[D]; - data(): Promise; -} - -/** @doclink Tensor */ -export type Scalar = Tensor; -/** @doclink Tensor */ -export type Tensor1D = Tensor; -/** @doclink Tensor */ -export type Tensor2D = Tensor; -/** @doclink Tensor */ -export type Tensor3D = Tensor; -/** @doclink Tensor */ -export type Tensor4D = Tensor; -/** @doclink Tensor */ -export type Tensor5D = Tensor; -/** @doclink Tensor */ -export type Tensor6D = Tensor; - -/** - * A mutable `tf.Tensor`, useful for persisting state, e.g. for training. - * - * @doc {heading: 'Tensors', subheading: 'Classes'} - */ -export class Variable extends Tensor { - name: string; - - constructor( - initialValue: Tensor, public trainable: boolean, name: string, - tensorId: number) { - super( - initialValue.shape, initialValue.dtype, initialValue.dataId, tensorId); - this.name = name; - } - - /** - * Assign a new `tf.Tensor` to this variable. The new `tf.Tensor` must have - * the same shape and dtype as the old `tf.Tensor`. - * - * @param newValue New tensor to be assigned to this variable. - * - * @doc {heading: 'Tensors', subheading: 'Classes'} - */ - assign(newValue: Tensor): void { - if (newValue.dtype !== this.dtype) { - throw new Error( - `dtype of the new value (${newValue.dtype}) and ` + - `previous value (${this.dtype}) must match`); - } - if (!util.arraysEqual(newValue.shape, this.shape)) { - throw new Error( - `shape of the new value (${newValue.shape}) and ` + - `previous value (${this.shape}) must match`); - } - trackerFn().disposeTensor(this); - this.dataId = newValue.dataId; - trackerFn().incRef(this, null /* backend */); - } - - override dispose(): void { - trackerFn().disposeVariable(this); - this.isDisposedInternal = true; - } -} - -Object.defineProperty(Variable, Symbol.hasInstance, { - value: (instance: Variable) => { - return instance instanceof Tensor && instance.assign != null && - instance.assign instanceof Function; - } -}); diff --git a/tfjs-master/tfjs-core/src/tensor_format.ts b/tfjs-master/tfjs-core/src/tensor_format.ts deleted file mode 100644 index 79fc2f657..000000000 --- a/tfjs-master/tfjs-core/src/tensor_format.ts +++ /dev/null @@ -1,197 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {DataType, TypedArray} from './types'; -import {computeStrides, isString, rightPad, sizeFromShape} from './util'; - -// Maximum number of values before we decide to show ellipsis. -const FORMAT_LIMIT_NUM_VALS = 20; -// Number of first and last values to show when displaying a, b,...,y, z. -const FORMAT_NUM_FIRST_LAST_VALS = 3; -// Number of significant digits to show. -const FORMAT_NUM_SIG_DIGITS = 7; - -export function tensorToString( - vals: TypedArray|string[], shape: number[], dtype: DataType, - verbose: boolean) { - const strides = computeStrides(shape); - const padPerCol = computeMaxSizePerColumn(vals, shape, dtype, strides); - const rank = shape.length; - const valsLines = subTensorToString(vals, shape, dtype, strides, padPerCol); - const lines = ['Tensor']; - if (verbose) { - lines.push(` dtype: ${dtype}`); - lines.push(` rank: ${rank}`); - lines.push(` shape: [${shape}]`); - lines.push(` values:`); - } - lines.push(valsLines.map(l => ' ' + l).join('\n')); - return lines.join('\n'); -} - -function computeMaxSizePerColumn( - vals: TypedArray|string[], shape: number[], dtype: DataType, - strides: number[]): number[] { - const n = sizeFromShape(shape); - const numCols = strides[strides.length - 1]; - const padPerCol = new Array(numCols).fill(0); - const rank = shape.length; - const valuesOrTuples = - dtype === 'complex64' ? createComplexTuples(vals) : vals; - - if (rank > 1) { - for (let row = 0; row < n / numCols; row++) { - const offset = row * numCols; - for (let j = 0; j < numCols; j++) { - padPerCol[j] = Math.max( - padPerCol[j], - valToString(valuesOrTuples[offset + j], 0, dtype).length); - } - } - } - return padPerCol; -} - -function valToString( - val: number|string|[number, number], pad: number, dtype: DataType) { - let valStr: string; - if (Array.isArray(val)) { - valStr = `${parseFloat(val[0].toFixed(FORMAT_NUM_SIG_DIGITS))} + ` + - `${parseFloat(val[1].toFixed(FORMAT_NUM_SIG_DIGITS))}j`; - } else if (isString(val)) { - valStr = `'${val}'`; - } else if (dtype === 'bool') { - valStr = boolNumToString(val); - } else { - valStr = parseFloat(val.toFixed(FORMAT_NUM_SIG_DIGITS)).toString(); - } - - return rightPad(valStr, pad); -} - -function boolNumToString(v: number): string { - return v === 0 ? 'false' : 'true'; -} - -function subTensorToString( - vals: TypedArray|string[], shape: number[], dtype: DataType, - strides: number[], padPerCol: number[], isLast = true): string[] { - const storagePerElement = dtype === 'complex64' ? 2 : 1; - - const size = shape[0]; - const rank = shape.length; - if (rank === 0) { - if (dtype === 'complex64') { - const complexTuple = createComplexTuples(vals); - return [valToString(complexTuple[0], 0, dtype)]; - } - if (dtype === 'bool') { - return [boolNumToString(vals[0] as number)]; - } - return [vals[0].toString()]; - } - - if (rank === 1) { - if (size > FORMAT_LIMIT_NUM_VALS) { - const firstValsSize = FORMAT_NUM_FIRST_LAST_VALS * storagePerElement; - - let firstVals = Array.from( - vals.slice(0, firstValsSize)); - let lastVals = Array.from(vals.slice( - (size - FORMAT_NUM_FIRST_LAST_VALS) * storagePerElement, - size * storagePerElement)); - if (dtype === 'complex64') { - firstVals = createComplexTuples(firstVals); - lastVals = createComplexTuples(lastVals); - } - return [ - '[' + - firstVals.map((x, i) => valToString(x, padPerCol[i], dtype)) - .join(', ') + - ', ..., ' + - lastVals - .map( - (x, i) => valToString( - x, padPerCol[size - FORMAT_NUM_FIRST_LAST_VALS + i], dtype)) - .join(', ') + - ']' - ]; - } - const displayVals: Array = - dtype === 'complex64' ? createComplexTuples(vals) : - Array.from(vals); - - return [ - '[' + - displayVals.map((x, i) => valToString(x, padPerCol[i], dtype)) - .join(', ') + - ']' - ]; - } - - // The array is rank 2 or more. - const subshape = shape.slice(1); - const substrides = strides.slice(1); - const stride = strides[0] * storagePerElement; - const lines: string[] = []; - if (size > FORMAT_LIMIT_NUM_VALS) { - for (let i = 0; i < FORMAT_NUM_FIRST_LAST_VALS; i++) { - const start = i * stride; - const end = start + stride; - lines.push(...subTensorToString( - vals.slice(start, end), subshape, dtype, substrides, padPerCol, - false /* isLast */)); - } - lines.push('...'); - for (let i = size - FORMAT_NUM_FIRST_LAST_VALS; i < size; i++) { - const start = i * stride; - const end = start + stride; - lines.push(...subTensorToString( - vals.slice(start, end), subshape, dtype, substrides, padPerCol, - i === size - 1 /* isLast */)); - } - } else { - for (let i = 0; i < size; i++) { - const start = i * stride; - const end = start + stride; - lines.push(...subTensorToString( - vals.slice(start, end), subshape, dtype, substrides, padPerCol, - i === size - 1 /* isLast */)); - } - } - const sep = rank === 2 ? ',' : ''; - lines[0] = '[' + (size > 0 ? lines[0] + sep : ''); - for (let i = 1; i < lines.length - 1; i++) { - lines[i] = ' ' + lines[i] + sep; - } - let newLineSep = ',\n'; - for (let i = 2; i < rank; i++) { - newLineSep += '\n'; - } - lines[lines.length - 1] = - ' ' + lines[lines.length - 1] + ']' + (isLast ? '' : newLineSep); - return lines; -} - -function createComplexTuples(vals: Array<{}>| - TypedArray): Array<[number, number]> { - const complexTuples: Array<[number, number]> = []; - for (let i = 0; i < vals.length; i += 2) { - complexTuples.push([vals[i], vals[i + 1]] as [number, number]); - } - return complexTuples; -} diff --git a/tfjs-master/tfjs-core/src/tensor_info.ts b/tfjs-master/tfjs-core/src/tensor_info.ts deleted file mode 100644 index 7ec529358..000000000 --- a/tfjs-master/tfjs-core/src/tensor_info.ts +++ /dev/null @@ -1,35 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {DataType} from './types'; - -/** - * We wrap data id since we use weak map to avoid memory leaks. - * Since we have our own memory management, we have a reference counter - * mapping a tensor to its data, so there is always a pointer (even if that - * data is otherwise garbage collectable). - * See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/ - * Global_Objects/WeakMap - */ -export type DataId = object; // object instead of {} to force non-primitive. - -/** Holds metadata for a given tensor. */ -export interface TensorInfo { - dataId: DataId; - shape: number[]; - dtype: DataType; -} diff --git a/tfjs-master/tfjs-core/src/tensor_test.ts b/tfjs-master/tfjs-core/src/tensor_test.ts deleted file mode 100644 index caa75247c..000000000 --- a/tfjs-master/tfjs-core/src/tensor_test.ts +++ /dev/null @@ -1,2368 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from './index'; -import {ALL_ENVS, describeWithFlags, SYNC_BACKEND_ENVS} from './jasmine_util'; -import {tensor5d} from './ops/ops'; -import {Scalar, Tensor, Tensor1D, Tensor2D, Tensor3D, Tensor4D} from './tensor'; -import {encodeStrings, expectArraysClose, expectArraysEqual, expectNumbersClose} from './test_util'; -import {Rank, TensorLike1D, TensorLike2D, TensorLike3D, TensorLike4D, TypedArray} from './types'; -import {encodeString} from './util'; - -describeWithFlags('tensor', ALL_ENVS, () => { - it('Tensors of arbitrary size', async () => { - // [1, 2, 3] - let t: Tensor = tf.tensor1d([1, 2, 3]); - expect(t.rank).toBe(1); - expect(t.size).toBe(3); - expectArraysClose(await t.data(), [1, 2, 3]); - - // [[1, 2, 3]] - t = tf.tensor2d([1, 2, 3], [1, 3]); - expect(t.rank).toBe(2); - expect(t.size).toBe(3); - expectArraysClose(await t.data(), [1, 2, 3]); - - // [[1, 2, 3], - // [4, 5, 6]] - t = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - expect(t.rank).toBe(2); - expect(t.size).toBe(6); - - expectArraysClose(await t.data(), [1, 2, 3, 4, 5, 6]); - - // Shape mismatch with the values. - expect(() => tf.tensor2d([1], [1, 2])).toThrowError(); - }); - - it('Tensors of explicit size', async () => { - const t = tf.tensor1d([5, 3, 2]); - expect(t.rank).toBe(1); - expect(t.shape).toEqual([3]); - - // tslint:disable-next-line:no-any - expect(() => tf.tensor3d([1, 2], [1, 2, 3, 5] as any)).toThrowError(); - - const t4 = tf.tensor4d([1, 2, 3, 4], [1, 2, 1, 2]); - expectArraysClose(await t4.data(), [1, 2, 3, 4]); - - // Tensor of ones. - const x = tf.ones([3, 4, 2]); - expect(x.rank).toBe(3); - expect(x.size).toBe(24); - expectArraysClose(await x.data(), [ - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 - ]); - - // Tensor of zeros. - const z = tf.zeros([3, 4, 2]); - expect(z.rank).toBe(3); - expect(z.size).toBe(24); - expectArraysClose(await z.data(), [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ]); - }); - - it('Tensor dataSync CPU --> GPU', async () => { - const a = tf.tensor2d([1, 2, 3, 4, 5, 6], [3, 2]); - expectArraysClose(await a.data(), new Float32Array([1, 2, 3, 4, 5, 6])); - }); - - it('Tensor.data() CPU --> GPU', async () => { - const a = tf.tensor2d([1, 2, 3, 4, 5, 6], [3, 2]); - expectArraysClose(await a.data(), new Float32Array([1, 2, 3, 4, 5, 6])); - }); - - it('Tensor.data() packed CPU --> GPU', async () => { - const a = tf.tensor2d([1, 2, 3, 4, 5, 6], [3, 2]); - tf.matMul(a, tf.tensor2d([1, 2], [2, 1])); - expectArraysClose(await a.data(), new Float32Array([1, 2, 3, 4, 5, 6])); - }); - - it('Scalar basic methods', async () => { - const a = tf.scalar(5); - expectArraysClose(await a.data(), [5]); - expect(a.rank).toBe(0); - expect(a.size).toBe(1); - expect(a.shape).toEqual([]); - }); - - it('indexToLoc Scalar', async () => { - const a = await tf.scalar(0).buffer(); - expect(a.indexToLoc(0)).toEqual([]); - - const b = await tf.zeros([]).buffer(); - expect(b.indexToLoc(0)).toEqual([]); - }); - - it('indexToLoc Tensor1D', async () => { - const a = await tf.zeros([3]).buffer(); - expect(a.indexToLoc(0)).toEqual([0]); - expect(a.indexToLoc(1)).toEqual([1]); - expect(a.indexToLoc(2)).toEqual([2]); - - const b = await tf.zeros([3]).buffer(); - expect(b.indexToLoc(0)).toEqual([0]); - expect(b.indexToLoc(1)).toEqual([1]); - expect(b.indexToLoc(2)).toEqual([2]); - }); - - it('indexToLoc Tensor2D', async () => { - const a = await tf.zeros([3, 2]).buffer(); - expect(a.indexToLoc(0)).toEqual([0, 0]); - expect(a.indexToLoc(1)).toEqual([0, 1]); - expect(a.indexToLoc(2)).toEqual([1, 0]); - expect(a.indexToLoc(3)).toEqual([1, 1]); - expect(a.indexToLoc(4)).toEqual([2, 0]); - expect(a.indexToLoc(5)).toEqual([2, 1]); - - const b = await tf.zeros([3, 2]).buffer(); - expect(b.indexToLoc(0)).toEqual([0, 0]); - expect(b.indexToLoc(1)).toEqual([0, 1]); - expect(b.indexToLoc(2)).toEqual([1, 0]); - expect(b.indexToLoc(3)).toEqual([1, 1]); - expect(b.indexToLoc(4)).toEqual([2, 0]); - expect(b.indexToLoc(5)).toEqual([2, 1]); - }); - - it('indexToLoc Tensor3D', async () => { - const a = await tf.zeros([3, 2, 2]).buffer(); - expect(a.indexToLoc(0)).toEqual([0, 0, 0]); - expect(a.indexToLoc(1)).toEqual([0, 0, 1]); - expect(a.indexToLoc(2)).toEqual([0, 1, 0]); - expect(a.indexToLoc(3)).toEqual([0, 1, 1]); - expect(a.indexToLoc(4)).toEqual([1, 0, 0]); - expect(a.indexToLoc(5)).toEqual([1, 0, 1]); - expect(a.indexToLoc(11)).toEqual([2, 1, 1]); - - const b = await tf.zeros([3, 2, 2]).buffer(); - expect(b.indexToLoc(0)).toEqual([0, 0, 0]); - expect(b.indexToLoc(1)).toEqual([0, 0, 1]); - expect(b.indexToLoc(2)).toEqual([0, 1, 0]); - expect(b.indexToLoc(3)).toEqual([0, 1, 1]); - expect(b.indexToLoc(4)).toEqual([1, 0, 0]); - expect(b.indexToLoc(5)).toEqual([1, 0, 1]); - expect(b.indexToLoc(11)).toEqual([2, 1, 1]); - }); - - it('indexToLoc Tensor 5D', async () => { - const values = new Float32Array([1, 2, 3, 4]); - const a = await tensor5d(values, [2, 1, 1, 1, 2]).buffer(); - expect(a.indexToLoc(0)).toEqual([0, 0, 0, 0, 0]); - expect(a.indexToLoc(1)).toEqual([0, 0, 0, 0, 1]); - expect(a.indexToLoc(2)).toEqual([1, 0, 0, 0, 0]); - expect(a.indexToLoc(3)).toEqual([1, 0, 0, 0, 1]); - }); - - it('locToIndex Scalar', async () => { - const a = await tf.scalar(0).buffer(); - expect(a.locToIndex([])).toEqual(0); - - const b = await tf.zeros([]).buffer(); - expect(b.locToIndex([])).toEqual(0); - }); - - it('locToIndex Tensor1D', async () => { - const a = await tf.zeros([3]).buffer(); - expect(a.locToIndex([0])).toEqual(0); - expect(a.locToIndex([1])).toEqual(1); - expect(a.locToIndex([2])).toEqual(2); - - const b = await tf.zeros([3]).buffer(); - expect(b.locToIndex([0])).toEqual(0); - expect(b.locToIndex([1])).toEqual(1); - expect(b.locToIndex([2])).toEqual(2); - }); - - it('locToIndex Tensor2D', async () => { - const a = await tf.zeros([3, 2]).buffer(); - expect(a.locToIndex([0, 0])).toEqual(0); - expect(a.locToIndex([0, 1])).toEqual(1); - expect(a.locToIndex([1, 0])).toEqual(2); - expect(a.locToIndex([1, 1])).toEqual(3); - expect(a.locToIndex([2, 0])).toEqual(4); - expect(a.locToIndex([2, 1])).toEqual(5); - - const b = await tf.zeros([3, 2]).buffer(); - expect(b.locToIndex([0, 0])).toEqual(0); - expect(b.locToIndex([0, 1])).toEqual(1); - expect(b.locToIndex([1, 0])).toEqual(2); - expect(b.locToIndex([1, 1])).toEqual(3); - expect(b.locToIndex([2, 0])).toEqual(4); - expect(b.locToIndex([2, 1])).toEqual(5); - }); - - it('locToIndex Tensor3D', async () => { - const a = await tf.zeros([3, 2, 2]).buffer(); - expect(a.locToIndex([0, 0, 0])).toEqual(0); - expect(a.locToIndex([0, 0, 1])).toEqual(1); - expect(a.locToIndex([0, 1, 0])).toEqual(2); - expect(a.locToIndex([0, 1, 1])).toEqual(3); - expect(a.locToIndex([1, 0, 0])).toEqual(4); - expect(a.locToIndex([1, 0, 1])).toEqual(5); - expect(a.locToIndex([2, 1, 1])).toEqual(11); - - const b = await tf.zeros([3, 2, 2]).buffer(); - expect(b.locToIndex([0, 0, 0])).toEqual(0); - expect(b.locToIndex([0, 0, 1])).toEqual(1); - expect(b.locToIndex([0, 1, 0])).toEqual(2); - expect(b.locToIndex([0, 1, 1])).toEqual(3); - expect(b.locToIndex([1, 0, 0])).toEqual(4); - expect(b.locToIndex([1, 0, 1])).toEqual(5); - expect(b.locToIndex([2, 1, 1])).toEqual(11); - }); - - it('Tensor assignability (asserts compiler)', () => { - // This test asserts compilation, not doing any run-time assertion. - const a: Tensor = null; - const b: Scalar = a; - expect(b).toBeNull(); - - const a1: Tensor = null; - const b1: Tensor1D = a1; - expect(b1).toBeNull(); - - const a2: Tensor = null; - const b2: Tensor2D = a2; - expect(b2).toBeNull(); - - const a3: Tensor = null; - const b3: Tensor3D = a3; - expect(b3).toBeNull(); - - const a4: Tensor = null; - const b4: Tensor4D = a4; - expect(b4).toBeNull(); - }); - - it('tf.tensor1d() from number[]', async () => { - const a = tf.tensor1d([1, 2, 3]); - expectArraysClose(await a.data(), [1, 2, 3]); - }); - - it('tf.tensor1d() throw error with null input value', () => { - expect(() => tf.tensor1d(null)) - .toThrowError( - 'The input to the tensor constructor ' + - 'must be a non-null value.'); - }); - - it('tf.tensor1d() from string[]', async () => { - const a = tf.tensor1d(['aa', 'bb', 'cc']); - expect(a.dtype).toBe('string'); - expect(a.shape).toEqual([3]); - expectArraysEqual(await a.data(), ['aa', 'bb', 'cc']); - }); - - it('tf.tensor1d() from encoded strings', async () => { - const bytes = encodeStrings(['aa', 'bb', 'cc']) as TensorLike1D; - const a = tf.tensor1d(bytes, 'string'); - expect(a.dtype).toBe('string'); - expect(a.shape).toEqual([3]); - expectArraysEqual(await a.data(), ['aa', 'bb', 'cc']); - }); - - it('tf.tensor1d() from encoded strings without dtype errors', async () => { - // We do not want to infer 'string' when the user passes Uint8Array in order - // to be forward compatible in the future when we add uint8 dtype. - const bytes = encodeStrings(['aa', 'bb', 'cc']) as TensorLike1D; - expect(() => tf.tensor1d(bytes)).toThrowError(); - }); - - it('tf.tensor1d() from encoded strings, shape mismatch', () => { - const bytes = encodeStrings([['aa'], ['bb'], ['cc']]) as TensorLike1D; - expect(() => tf.tensor1d(bytes)).toThrowError(); - }); - - it('tf.tensor1d() from number[][], shape mismatch', () => { - // tslint:disable-next-line:no-any - expect(() => tf.tensor1d([[1], [2], [3]] as any)).toThrowError(); - }); - - it('tf.tensor1d() from string[][], shape mismatch', () => { - // tslint:disable-next-line:no-any - expect(() => tf.tensor1d([['a'], ['b'], ['c']] as any)).toThrowError(); - }); - - it('tf.tensor2d() from number[][]', async () => { - const a = tf.tensor2d([[1, 2, 3], [4, 5, 6]], [2, 3]); - expectArraysClose(await a.data(), [1, 2, 3, 4, 5, 6]); - }); - - it('tf.tensor2d() from string[][]', async () => { - const a = tf.tensor2d([['aa', 'bb'], ['cc', 'dd']]); - expect(a.dtype).toBe('string'); - expect(a.shape).toEqual([2, 2]); - expectArraysEqual(await a.data(), ['aa', 'bb', 'cc', 'dd']); - }); - - it('tf.tensor2d() from encoded strings', async () => { - const bytes = encodeStrings([['aa', 'bb'], ['cc', 'dd']]) as TensorLike2D; - const a = tf.tensor2d(bytes, [2, 2], 'string'); - expect(a.dtype).toBe('string'); - expect(a.shape).toEqual([2, 2]); - expectArraysEqual(await a.data(), ['aa', 'bb', 'cc', 'dd']); - }); - - it('tf.tensor2d() from encoded strings without dtype errors', async () => { - // We do not want to infer 'string' when the user passes Uint8Array in order - // to be forward compatible in the future when we add uint8 dtype. - const bytes = encodeStrings([['aa', 'bb'], ['cc', 'dd']]) as TensorLike2D; - expect(() => tf.tensor2d(bytes)).toThrowError(); - }); - - it('tf.tensor2d() from encoded strings, shape mismatch', () => { - const bytes = encodeStrings([['aa', 'bb'], ['cc', 'dd']]) as TensorLike2D; - expect(() => tf.tensor2d(bytes, [3, 2], 'string')).toThrowError(); - }); - - it('tf.tensor2d() requires shape to be of length 2', () => { - // tslint:disable-next-line:no-any - const shape: any = [4]; - expect(() => tf.tensor2d([1, 2, 3, 4], shape)).toThrowError(); - }); - - it('tf.tensor2d() from number[][], but shape does not match', () => { - // Actual shape is [2, 3]. - expect(() => tf.tensor2d([[1, 2, 3], [4, 5, 6]], [3, 2])).toThrowError(); - }); - - it('tf.tensor2d() from string[][], but shape does not match', () => { - // Actual shape is [2, 3]. - const vals = [['a', 'b', 'c'], ['d', 'e', 'f']]; - expect(() => tf.tensor2d(vals, [3, 2])).toThrowError(); - }); - - it('tf.tensor2d() from number[], but no shape throws error', () => { - expect(() => tf.tensor2d([1, 2, 3, 4])).toThrowError(); - }); - - it('tf.tensor2d() from string[], but no shape throws error', () => { - expect(() => tf.tensor2d(['a', 'b', 'c', 'd'])).toThrowError(); - }); - - it('tf.tensor2d() throw error with null input value', () => { - expect(() => tf.tensor2d(null)) - .toThrowError( - 'The input to the tensor constructor ' + - 'must be a non-null value.'); - }); - - it('tensor3d() from number[][][]', async () => { - const a = tf.tensor3d([[[1], [2], [3]], [[4], [5], [6]]], [2, 3, 1]); - expectArraysClose(await a.data(), [1, 2, 3, 4, 5, 6]); - }); - - it('tensor3d() from string[][][]', async () => { - const vals = [[['a'], ['b'], ['c']], [['d'], ['e'], ['f']]]; - const a = tf.tensor3d(vals, [2, 3, 1]); - expect(a.dtype).toBe('string'); - expect(a.shape).toEqual([2, 3, 1]); - expectArraysEqual(await a.data(), ['a', 'b', 'c', 'd', 'e', 'f']); - }); - - it('tf.tensor3d() from encoded strings', async () => { - const bytes = encodeStrings([[['a'], ['b'], ['c']], [['d'], ['e'], ['f']]]); - const a = tf.tensor3d(bytes as TensorLike3D, [2, 3, 1], 'string'); - expect(a.dtype).toBe('string'); - expect(a.shape).toEqual([2, 3, 1]); - expectArraysEqual(await a.data(), ['a', 'b', 'c', 'd', 'e', 'f']); - }); - - it('tf.tensor3d() from encoded strings without dtype errors', async () => { - // We do not want to infer 'string' when the user passes Uint8Array in order - // to be forward compatible in the future when we add uint8 dtype. - const bytes = encodeStrings([[['a'], ['b'], ['c']], [['d'], ['e'], ['f']]]); - expect(() => tf.tensor3d(bytes as TensorLike3D)).toThrowError(); - }); - - it('tf.tensor3d() from encoded strings, shape mismatch', () => { - const bytes = encodeStrings([[['a'], ['b'], ['c']], [['d'], ['e'], ['f']]]); - // Actual shape is [2, 3, 1]. - expect(() => tf.tensor3d(bytes as TensorLike3D, [3, 2, 1], 'string')) - .toThrowError(); - }); - - it('tensor3d() from number[][][], but shape does not match', () => { - const values = [[[1], [2], [3]], [[4], [5], [6]]]; - // Actual shape is [2, 3, 1]. - expect(() => tf.tensor3d(values, [3, 2, 1])).toThrowError(); - }); - - it('tf.tensor3d() from number[], but no shape throws error', () => { - expect(() => tf.tensor3d([1, 2, 3, 4])).toThrowError(); - }); - - it('tf.tensor3d() requires shape to be of length 3', () => { - // tslint:disable-next-line:no-any - const shape: any = [4, 1]; - expect(() => tf.tensor3d([1, 2, 3, 4], shape)).toThrowError(); - }); - - it('tf.tensor3d() throw error with null input value', () => { - expect(() => tf.tensor3d(null)) - .toThrowError( - 'The input to the tensor constructor ' + - 'must be a non-null value.'); - }); - - it('tensor4d() from number[][][][]', async () => { - const a = tf.tensor4d([[[[1]], [[2]]], [[[4]], [[5]]]], [2, 2, 1, 1]); - expectArraysClose(await a.data(), [1, 2, 4, 5]); - }); - - it('tensor4d() from string[][][][]', async () => { - const vals = [[[['a']], [['b']]], [[['c']], [['d']]]]; - const a = tf.tensor4d(vals, [2, 2, 1, 1]); - expect(a.dtype).toBe('string'); - expect(a.shape).toEqual([2, 2, 1, 1]); - expectArraysEqual(await a.data(), ['a', 'b', 'c', 'd']); - }); - - it('tf.tensor4d() from encoded strings', async () => { - const bytes = encodeStrings([[[['a']], [['b']]], [[['c']], [['d']]]]); - const a = tf.tensor4d(bytes as TensorLike4D, [2, 2, 1, 1], 'string'); - expect(a.dtype).toBe('string'); - expect(a.shape).toEqual([2, 2, 1, 1]); - expectArraysEqual(await a.data(), ['a', 'b', 'c', 'd']); - }); - - it('tf.tensor4d() from encoded strings without dtype errors', async () => { - // We do not want to infer 'string' when the user passes Uint8Array in order - // to be forward compatible in the future when we add uint8 dtype. - const bytes = encodeStrings([[[['a']], [['b']]], [[['c']], [['d']]]]); - expect(() => tf.tensor4d(bytes as TensorLike4D)).toThrowError(); - }); - - it('tf.tensor4d() from encoded strings, shape mismatch', () => { - const bytes = encodeStrings([[[['a']], [['b']]], [[['c']], [['d']]]]); - // Actual shape is [2, 2, 1. 1]. - expect(() => tf.tensor4d(bytes as TensorLike4D, [2, 1, 2, 1], 'string')) - .toThrowError(); - }); - - it('tensor4d() from string[][][][] infer shape', async () => { - const vals = [[[['a']], [['b']]], [[['c']], [['d']]]]; - const a = tf.tensor4d(vals); - expect(a.dtype).toBe('string'); - expect(a.shape).toEqual([2, 2, 1, 1]); - expectArraysEqual(await a.data(), ['a', 'b', 'c', 'd']); - }); - - it('tensor4d() from number[][][][], but shape does not match', () => { - const f = () => { - // Actual shape is [2, 2, 1, 1]. - tf.tensor4d([[[[1]], [[2]]], [[[4]], [[5]]]], [2, 1, 2, 1]); - }; - expect(f).toThrowError(); - }); - - it('tf.tensor4d() from number[], but no shape throws error', () => { - expect(() => tf.tensor4d([1, 2, 3, 4])).toThrowError(); - }); - - it('tf.tensor4d() requires shape to be of length 4', () => { - // tslint:disable-next-line:no-any - const shape: any = [4, 1]; - expect(() => tf.tensor4d([1, 2, 3, 4], shape)).toThrowError(); - }); - - it('tf.tensor4d() throw error with null input value', () => { - expect(() => tf.tensor4d(null)) - .toThrowError( - 'The input to the tensor constructor ' + - 'must be a non-null value.'); - }); - - it('tf.tensor5d() throw error with null input value', () => { - expect(() => tf.tensor5d(null)) - .toThrowError( - 'The input to the tensor constructor ' + - 'must be a non-null value.'); - }); - - it('tf.tensor6d() throw error with null input value', () => { - expect(() => tf.tensor6d(null)) - .toThrowError( - 'The input to the tensor constructor ' + - 'must be a non-null value.'); - }); - - it('default dtype', async () => { - const a = tf.scalar(3); - expect(a.dtype).toBe('float32'); - expectArraysClose(await a.data(), 3); - }); - - it('float32 dtype', async () => { - const a = tf.scalar(3, 'float32'); - expect(a.dtype).toBe('float32'); - expectArraysClose(await a.data(), 3); - }); - - it('int32 dtype', async () => { - const a = tf.scalar(3, 'int32'); - expect(a.dtype).toBe('int32'); - expectArraysEqual(await a.data(), 3); - }); - - it('int32 dtype, 3.9 => 3, like numpy', async () => { - const a = tf.scalar(3.9, 'int32'); - expect(a.dtype).toBe('int32'); - expectArraysEqual(await a.data(), 3); - }); - - it('int32 dtype, -3.9 => -3, like numpy', async () => { - const a = tf.scalar(-3.9, 'int32'); - expect(a.dtype).toBe('int32'); - expectArraysEqual(await a.data(), -3); - }); - - it('bool dtype, 3 => true, like numpy', async () => { - const a = tf.scalar(3, 'bool'); - expect(a.dtype).toBe('bool'); - expectArraysEqual(await a.data(), 1); - }); - - it('bool dtype, -2 => true, like numpy', async () => { - const a = tf.scalar(-2, 'bool'); - expect(a.dtype).toBe('bool'); - expectArraysEqual(await a.data(), 1); - }); - - it('bool dtype, 0 => false, like numpy', async () => { - const a = tf.scalar(0, 'bool'); - expect(a.dtype).toBe('bool'); - expectArraysEqual(await a.data(), 0); - }); - - it('bool dtype from boolean', async () => { - const a = tf.scalar(false, 'bool'); - expectArraysEqual(await a.data(), 0); - expect(a.dtype).toBe('bool'); - - const b = tf.scalar(true, 'bool'); - expectArraysEqual(await a.data(), 0); - expect(b.dtype).toBe('bool'); - }); - - it('int32 dtype from boolean', async () => { - const a = tf.scalar(true, 'int32'); - expectArraysEqual(await a.data(), 1); - expect(a.dtype).toBe('int32'); - }); - - it('default dtype from boolean', async () => { - const a = tf.scalar(false); - expectArraysEqual(await a.data(), 0); - expect(a.dtype).toBe('bool'); - }); - - it('default dtype', async () => { - const a = tf.tensor1d([1, 2, 3]); - expect(a.dtype).toBe('float32'); - expect(a.shape).toEqual([3]); - expectArraysClose(await a.data(), [1, 2, 3]); - }); - - it('float32 dtype', async () => { - const a = tf.tensor1d([1, 2, 3], 'float32'); - expect(a.dtype).toBe('float32'); - expect(a.shape).toEqual([3]); - expectArraysClose(await a.data(), [1, 2, 3]); - }); - - it('int32 dtype', async () => { - const a = tf.tensor1d([1, 2, 3], 'int32'); - expect(a.dtype).toBe('int32'); - expect(a.shape).toEqual([3]); - expectArraysEqual(await a.data(), [1, 2, 3]); - }); - - it('int32 dtype, non-ints get floored, like numpy', async () => { - const a = tf.tensor1d([1.1, 2.5, 3.9], 'int32'); - expect(a.dtype).toBe('int32'); - expect(a.shape).toEqual([3]); - expectArraysEqual(await a.data(), [1, 2, 3]); - }); - - it('int32 dtype, negative non-ints get ceiled, like numpy', async () => { - const a = tf.tensor1d([-1.1, -2.5, -3.9], 'int32'); - expect(a.dtype).toBe('int32'); - expect(a.shape).toEqual([3]); - expectArraysEqual(await a.data(), [-1, -2, -3]); - }); - - it('bool dtype, !=0 is truthy, 0 is falsy, like numpy', async () => { - const a = tf.tensor1d([1, -2, 0, 3], 'bool'); - expect(a.dtype).toBe('bool'); - expect(a.shape).toEqual([4]); - expectArraysEqual(await a.data(), [1, 1, 0, 1]); - }); - - it('default dtype from boolean[]', async () => { - const a = tf.tensor1d([false, false, true]); - expect(a.dtype).toBe('bool'); - expectArraysClose(await a.data(), [0, 0, 1]); - }); - - it('default dtype from UInt8Array', async () => { - const a = tf.tensor1d(new Uint8Array([1, 5, 2])); - expect(a.dtype).toBe('int32'); - expect(a.shape).toEqual([3]); - expectArraysClose(await a.data(), [1, 5, 2]); - }); - - it('default dtype from Int32Array', async () => { - const a = tf.tensor1d(new Int32Array([1, 5, 2])); - expect(a.dtype).toBe('int32'); - expect(a.shape).toEqual([3]); - expectArraysClose(await a.data(), [1, 5, 2]); - }); - - it('tf.tensor() from Float32Array and number[]', async () => { - const a = tf.tensor([ - new Float32Array([1, 2]), new Float32Array([3, 4]), - new Float32Array([5, 6]), [7, 8] - ]); - expect(a.dtype).toBe('float32'); - expect(a.shape).toEqual([4, 2]); - expectArraysClose(await a.data(), [1, 2, 3, 4, 5, 6, 7, 8]); - }); - - it('tf.tensor() from Int32Array and number[]', async () => { - const a = tf.tensor([ - new Int32Array([1, 2]), new Int32Array([3, 4]), new Int32Array([5, 6]), - [7, 8] - ]); - expect(a.dtype).toBe('int32'); - expect(a.shape).toEqual([4, 2]); - expectArraysClose(await a.data(), [1, 2, 3, 4, 5, 6, 7, 8]); - }); - - it('tf.tensor() from mixed TypedArray', async () => { - const a = tf.tensor([ - new Float32Array([1, 2]), new Int32Array([3, 4]), new Uint8Array([5, 6]), - [7, 8] - ]); - expect(a.dtype).toBe('float32'); - expect(a.shape).toEqual([4, 2]); - expectArraysClose(await a.data(), [1, 2, 3, 4, 5, 6, 7, 8]); - }); - - it('tf.tensor() from TypedArrays which are themselves 3D', () => { - // 2 tensors, each with shape 20x20x3, as flat Float32Arrays. - const img1 = new Float32Array(20 * 20 * 3); - const img2 = new Float32Array(20 * 20 * 3); - const t = tf.tensor([img1, img2], [2, 20, 20, 3]); - expect(t.dtype).toBe('float32'); - expect(t.shape).toEqual([2, 20, 20, 3]); - }); - - it('tf.tensor() from TypedArrays which are themselves 3D, wrong shape', - () => { - const img1 = new Float32Array(20 * 20 * 3); - const img2 = new Float32Array(20 * 20 * 3); - expect(() => tf.tensor([img1, img2], [3, 20, 20, 3])).toThrowError(); - }); - - it('default dtype from ascii string', async () => { - const a = tf.tensor('hello'); - expect(a.dtype).toBe('string'); - expect(a.shape).toEqual([]); - expectArraysEqual(await a.data(), ['hello']); - }); - - it('default dtype from utf-8 string', async () => { - const a = tf.tensor('даниел'); - expect(a.dtype).toBe('string'); - expect(a.shape).toEqual([]); - expectArraysEqual(await a.data(), ['даниел']); - }); - - it('default dtype from empty string', async () => { - const a = tf.tensor(''); - expect(a.dtype).toBe('string'); - expect(a.shape).toEqual([]); - expectArraysEqual(await a.data(), ['']); - }); - - it('default dtype from unicode escaped string', async () => { - const a = tf.tensor('\u0434\u0430\u043d\u0438\u0435\u043b'); - expect(a.dtype).toBe('string'); - expect(a.shape).toEqual([]); - expectArraysEqual(await a.data(), ['даниел']); - }); - - it('default dtype from string[]', async () => { - const a = tf.tensor(['a', 'b']); - expect(a.dtype).toBe('string'); - expect(a.shape).toEqual([2]); - expectArraysEqual(await a.data(), ['a', 'b']); - }); - - it('float32 dtype from boolean[]', async () => { - const a = tf.tensor1d([false, false, true], 'float32'); - expect(a.dtype).toBe('float32'); - expectArraysClose(await a.data(), [0, 0, 1]); - }); - - it('int32 dtype from boolean[]', async () => { - const a = tf.tensor1d([false, false, true], 'int32'); - expect(a.dtype).toBe('int32'); - expectArraysEqual(await a.data(), [0, 0, 1]); - }); - - it('bool dtype from boolean[]', async () => { - const a = tf.tensor1d([false, false, true], 'bool'); - expect(a.dtype).toBe('bool'); - expectArraysEqual(await a.data(), [0, 0, 1]); - }); - - it('default dtype', async () => { - const a = tf.tensor2d([1, 2, 3, 4], [2, 2]); - expect(a.dtype).toBe('float32'); - expect(a.shape).toEqual([2, 2]); - expectArraysClose(await a.data(), [1, 2, 3, 4]); - }); - - it('float32 dtype', async () => { - const a = tf.tensor2d([1, 2, 3, 4], [2, 2], 'float32'); - expect(a.dtype).toBe('float32'); - expect(a.shape).toEqual([2, 2]); - expectArraysClose(await a.data(), [1, 2, 3, 4]); - }); - - it('int32 dtype', async () => { - const a = tf.tensor2d([[1, 2], [3, 4]], [2, 2], 'int32'); - expect(a.dtype).toBe('int32'); - expect(a.shape).toEqual([2, 2]); - expectArraysEqual(await a.data(), [1, 2, 3, 4]); - }); - - it('int32 dtype, non-ints get floored, like numpy', async () => { - const a = tf.tensor2d([1.1, 2.5, 3.9, 4.0], [2, 2], 'int32'); - expect(a.dtype).toBe('int32'); - expect(a.shape).toEqual([2, 2]); - expectArraysEqual(await a.data(), [1, 2, 3, 4]); - }); - - it('int32 dtype, negative non-ints get ceiled, like numpy', async () => { - const a = tf.tensor2d([-1.1, -2.5, -3.9, -4.0], [2, 2], 'int32'); - expect(a.dtype).toBe('int32'); - expect(a.shape).toEqual([2, 2]); - expectArraysEqual(await a.data(), [-1, -2, -3, -4]); - }); - - it('bool dtype, !=0 is truthy, 0 is falsy, like numpy', async () => { - const a = tf.tensor2d([1, -2, 0, 3], [2, 2], 'bool'); - expect(a.dtype).toBe('bool'); - expect(a.shape).toEqual([2, 2]); - expectArraysEqual(await a.data(), [1, 1, 0, 1]); - }); - - it('default dtype from boolean[]', async () => { - const a = tf.tensor2d([[false, false], [true, false]], [2, 2]); - expect(a.dtype).toBe('bool'); - expectArraysClose(await a.data(), [0, 0, 1, 0]); - }); - - it('float32 dtype from boolean[]', async () => { - const a = tf.tensor2d([[false, false], [true, false]], [2, 2], 'float32'); - expect(a.dtype).toBe('float32'); - expectArraysEqual(await a.data(), [0, 0, 1, 0]); - }); - - it('int32 dtype from boolean[]', async () => { - const a = tf.tensor2d([[false, false], [true, false]], [2, 2], 'int32'); - expect(a.dtype).toBe('int32'); - expectArraysEqual(await a.data(), [0, 0, 1, 0]); - }); - - it('bool dtype from boolean[]', async () => { - const a = tf.tensor2d([[false, false], [true, false]], [2, 2], 'bool'); - expect(a.dtype).toBe('bool'); - expectArraysEqual(await a.data(), [0, 0, 1, 0]); - }); - - it('default dtype', async () => { - const a = tf.tensor3d([1, 2, 3, 4], [2, 2, 1]); - expect(a.dtype).toBe('float32'); - expect(a.shape).toEqual([2, 2, 1]); - expectArraysClose(await a.data(), [1, 2, 3, 4]); - }); - - it('float32 dtype', async () => { - const a = tf.tensor3d([1, 2, 3, 4], [2, 2, 1], 'float32'); - expect(a.dtype).toBe('float32'); - expect(a.shape).toEqual([2, 2, 1]); - expectArraysClose(await a.data(), [1, 2, 3, 4]); - }); - - it('int32 dtype', async () => { - const a = tf.tensor3d([[[1], [2]], [[3], [4]]], [2, 2, 1], 'int32'); - expect(a.dtype).toBe('int32'); - expect(a.shape).toEqual([2, 2, 1]); - expectArraysEqual(await a.data(), [1, 2, 3, 4]); - }); - - it('int32 dtype, non-ints get floored, like numpy', async () => { - const a = tf.tensor3d([1.1, 2.5, 3.9, 4.0], [2, 2, 1], 'int32'); - expect(a.dtype).toBe('int32'); - expect(a.shape).toEqual([2, 2, 1]); - expectArraysEqual(await a.data(), [1, 2, 3, 4]); - }); - - it('int32 dtype, negative non-ints get ceiled, like numpy', async () => { - const a = tf.tensor3d([-1.1, -2.5, -3.9, -4.0], [2, 2, 1], 'int32'); - expect(a.dtype).toBe('int32'); - expect(a.shape).toEqual([2, 2, 1]); - expectArraysEqual(await a.data(), [-1, -2, -3, -4]); - }); - - it('bool dtype, !=0 is truthy, 0 is falsy, like numpy', async () => { - const a = tf.tensor3d([1, -2, 0, 3], [2, 2, 1], 'bool'); - expect(a.dtype).toBe('bool'); - expect(a.shape).toEqual([2, 2, 1]); - expectArraysEqual(await a.data(), [1, 1, 0, 1]); - }); - - it('default dtype from boolean[]', async () => { - const a = tf.tensor3d([[[false], [false]], [[true], [false]]], [2, 2, 1]); - expect(a.dtype).toBe('bool'); - expectArraysClose(await a.data(), [0, 0, 1, 0]); - }); - - it('float32 dtype from boolean[]', async () => { - const a = tf.tensor3d( - [[[false], [false]], [[true], [false]]], [2, 2, 1], 'float32'); - expect(a.dtype).toBe('float32'); - expectArraysClose(await a.data(), [0, 0, 1, 0]); - }); - - it('int32 dtype from boolean[]', async () => { - const a = tf.tensor3d( - [[[false], [false]], [[true], [false]]], [2, 2, 1], 'int32'); - expect(a.dtype).toBe('int32'); - expectArraysEqual(await a.data(), [0, 0, 1, 0]); - }); - - it('bool dtype from boolean[]', async () => { - const a = - tf.tensor3d([[[false], [false]], [[true], [false]]], [2, 2, 1], 'bool'); - expect(a.dtype).toBe('bool'); - expectArraysEqual(await a.data(), [0, 0, 1, 0]); - }); - - it('default dtype', async () => { - const a = tf.tensor4d([1, 2, 3, 4], [2, 2, 1, 1]); - expect(a.dtype).toBe('float32'); - expect(a.shape).toEqual([2, 2, 1, 1]); - expectArraysClose(await a.data(), [1, 2, 3, 4]); - }); - - it('float32 dtype', async () => { - const a = tf.tensor4d([1, 2, 3, 4], [2, 2, 1, 1], 'float32'); - expect(a.dtype).toBe('float32'); - expect(a.shape).toEqual([2, 2, 1, 1]); - expectArraysClose(await a.data(), [1, 2, 3, 4]); - }); - - it('int32 dtype', async () => { - const a = - tf.tensor4d([[[[1]], [[2]]], [[[3]], [[4]]]], [2, 2, 1, 1], 'int32'); - expect(a.dtype).toBe('int32'); - expect(a.shape).toEqual([2, 2, 1, 1]); - expectArraysEqual(await a.data(), [1, 2, 3, 4]); - }); - - it('int32 dtype, non-ints get floored, like numpy', async () => { - const a = tf.tensor4d([1.1, 2.5, 3.9, 4.0], [2, 2, 1, 1], 'int32'); - expect(a.dtype).toBe('int32'); - expect(a.shape).toEqual([2, 2, 1, 1]); - expectArraysEqual(await a.data(), [1, 2, 3, 4]); - }); - - it('int32 dtype, negative non-ints get ceiled, like numpy', async () => { - const a = tf.tensor4d([-1.1, -2.5, -3.9, -4.0], [2, 2, 1, 1], 'int32'); - expect(a.dtype).toBe('int32'); - expect(a.shape).toEqual([2, 2, 1, 1]); - expectArraysEqual(await a.data(), [-1, -2, -3, -4]); - }); - - it('bool dtype, !=0 is truthy, 0 is falsy, like numpy', async () => { - const a = tf.tensor4d([1, -2, 0, 3], [2, 2, 1, 1], 'bool'); - expect(a.dtype).toBe('bool'); - expect(a.shape).toEqual([2, 2, 1, 1]); - expectArraysEqual(await a.data(), [1, 1, 0, 1]); - }); - - it('default dtype from boolean[]', async () => { - const a = - tf.tensor4d([[[[false], [false]], [[true], [false]]]], [1, 2, 2, 1]); - expect(a.dtype).toBe('bool'); - expectArraysClose(await a.data(), [0, 0, 1, 0]); - }); - - it('float32 dtype from boolean[]', async () => { - const a = tf.tensor4d( - [[[[false], [false]], [[true], [false]]]], [1, 2, 2, 1], 'float32'); - expect(a.dtype).toBe('float32'); - expectArraysClose(await a.data(), [0, 0, 1, 0]); - }); - - it('int32 dtype from boolean[]', async () => { - const a = tf.tensor4d( - [[[[false], [false]], [[true], [false]]]], [1, 2, 2, 1], 'int32'); - expect(a.dtype).toBe('int32'); - expectArraysEqual(await a.data(), [0, 0, 1, 0]); - }); - - it('bool dtype from boolean[]', async () => { - const a = tf.tensor4d( - [[[[false], [false]], [[true], [false]]]], [1, 2, 2, 1], 'bool'); - expect(a.dtype).toBe('bool'); - expectArraysEqual(await a.data(), [0, 0, 1, 0]); - }); - - it('Scalar default dtype', async () => { - const a = tf.scalar(4); - const b = a.reshape([1, 1]); - expect(b.dtype).toBe('float32'); - expect(b.shape).toEqual([1, 1]); - expectArraysClose(await a.data(), await b.data()); - }); - - it('Scalar float32 dtype', () => { - const a = tf.scalar(4, 'float32'); - const b = a.reshape([1, 1]); - expect(b.dtype).toBe('float32'); - expect(b.shape).toEqual([1, 1]); - }); - - it('Scalar string dtype', () => { - const a = tf.scalar('test', 'string'); - const b = a.reshape([1, 1]); - expect(b.dtype).toBe('string'); - expect(b.shape).toEqual([1, 1]); - }); - - it('scalar from encoded string', async () => { - const a = tf.scalar(encodeString('hello'), 'string'); - expect(a.dtype).toBe('string'); - expect(a.shape).toEqual([]); - expectArraysEqual(await a.data(), ['hello']); - }); - - it('scalar from encoded string, but missing dtype', async () => { - // We do not want to infer 'string' when the user passes Uint8Array in order - // to be forward compatible in the future when we add uint8 dtype. - expect(() => tf.scalar(encodeString('hello'))).toThrowError(); - }); - - it('scalar from encoded string, but value is not uint8array', async () => { - // tslint:disable-next-line:no-any - expect(() => tf.scalar(new Float32Array([1, 2, 3]) as any)).toThrowError(); - }); - - it('Scalar inferred dtype from bool', async () => { - const a = tf.scalar(true); - expect(a.dtype).toBe('bool'); - expect(a.shape).toEqual([]); - expectArraysClose(await a.data(), [1]); - }); - - it('Scalar inferred dtype from string', async () => { - const a = tf.scalar('hello'); - expect(a.dtype).toBe('string'); - expect(a.shape).toEqual([]); - expectArraysEqual(await a.data(), ['hello']); - }); - - it('Scalar int32 dtype', () => { - const a = tf.scalar(4, 'int32'); - const b = a.reshape([1, 1]); - expect(b.dtype).toBe('int32'); - expect(b.shape).toEqual([1, 1]); - }); - - it('Scalar bool dtype', async () => { - const a = tf.scalar(4, 'bool'); - const b = a.reshape([1, 1, 1]); - expect(b.dtype).toBe('bool'); - expect(b.shape).toEqual([1, 1, 1]); - expectArraysClose(await a.data(), await b.data()); - }); - - it('Scalar complex64 dtype', async () => { - const a = tf.complex(4, 5); - const b = a.reshape([1, 1]); - expectArraysClose(await a.data(), [4, 5]); - expect(b.dtype).toBe('complex64'); - expect(b.shape).toEqual([1, 1]); - expectArraysClose(await a.data(), await b.data()); - }); - - it('Tensor1D default dtype', async () => { - const a = tf.tensor1d([1, 2, 3, 4]); - const b = a.reshape([2, 2]); - expect(b.dtype).toBe('float32'); - expect(b.shape).toEqual([2, 2]); - expectArraysClose(await a.data(), await b.data()); - }); - - it('Tensor1D inferred dtype from bools', async () => { - const a = tf.tensor1d([true, false, false, true]); - expect(a.dtype).toBe('bool'); - expect(a.shape).toEqual([4]); - expectArraysClose(await a.data(), [1, 0, 0, 1]); - }); - - it('Tensor1D inferred dtype from strings', async () => { - const a = tf.tensor1d(['a', 'b', 'c']); - expect(a.dtype).toBe('string'); - expect(a.shape).toEqual([3]); - expectArraysEqual(await a.data(), ['a', 'b', 'c']); - }); - - it('Tensor1D float32 dtype', () => { - const a = tf.tensor1d([1, 2, 3, 4], 'float32'); - const b = a.reshape([2, 2]); - expect(b.dtype).toBe('float32'); - expect(b.shape).toEqual([2, 2]); - }); - - it('Tensor1D int32 dtype', async () => { - const a = tf.tensor1d([1, 2, 3, 4], 'int32'); - const b = a.reshape([2, 2]); - expect(b.dtype).toBe('int32'); - expect(b.shape).toEqual([2, 2]); - expectArraysClose(await a.data(), await b.data()); - }); - - it('Tensor1D complex64 dtype', async () => { - const a = tf.complex([1, 3, 5, 7], [2, 4, 6, 8]); - const b = a.reshape([2, 2]); - expect(b.dtype).toBe('complex64'); - expect(b.shape).toEqual([2, 2]); - expectArraysClose(await a.data(), await b.data()); - }); - - it('Tensor2D default dtype', async () => { - const a = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); - const b = a.reshape([6]); - expect(b.dtype).toBe('float32'); - expect(b.shape).toEqual([6]); - expectArraysClose(await a.data(), await b.data()); - }); - - it('Tensor2D float32 dtype', () => { - const a = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3], 'float32'); - const b = a.reshape([6]); - expect(b.dtype).toBe('float32'); - expect(b.shape).toEqual([6]); - }); - - it('Tensor2D int32 dtype', () => { - const a = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3], 'int32'); - const b = a.reshape([6]); - expect(b.dtype).toBe('int32'); - expect(b.shape).toEqual([6]); - }); - - it('Tensor2D bool dtype', async () => { - const a = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3], 'bool'); - const b = a.reshape([6]); - expect(b.dtype).toBe('bool'); - expect(b.shape).toEqual([6]); - expectArraysClose(await a.data(), await b.data()); - }); - - it('Tensor2D complex64 dtype', async () => { - const a = tf.complex([[1, 3, 5], [7, 9, 11]], [[2, 4, 6], [8, 10, 12]]); - const b = a.reshape([6]); - expect(b.dtype).toBe('complex64'); - expect(b.shape).toEqual([6]); - expectArraysClose(await a.data(), await b.data()); - }); - - it('Tensor3D default dtype', async () => { - const a = tf.tensor3d([1, 2, 3, 4, 5, 6], [2, 3, 1]); - const b = a.reshape([6]); - expect(b.dtype).toBe('float32'); - expect(b.shape).toEqual([6]); - expectArraysClose(await a.data(), await b.data()); - }); - - it('Tensor3D float32 dtype', () => { - const a = tf.tensor3d([1, 2, 3, 4, 5, 6], [2, 3, 1], 'float32'); - const b = a.reshape([6]); - expect(b.dtype).toBe('float32'); - expect(b.shape).toEqual([6]); - }); - - it('Tensor3D int32 dtype', () => { - const a = tf.tensor3d([1, 2, 3, 4, 5, 6], [2, 3, 1], 'int32'); - const b = a.reshape([6]); - expect(b.dtype).toBe('int32'); - expect(b.shape).toEqual([6]); - }); - - it('Tensor3D bool dtype', async () => { - const a = tf.tensor3d([1, 2, 3, 4, 5, 6], [2, 3, 1], 'bool'); - const b = a.reshape([6]); - expect(b.dtype).toBe('bool'); - expect(b.shape).toEqual([6]); - expectArraysClose(await a.data(), await b.data()); - }); - - it('Tensor3D complex64 dtype', async () => { - const a = tf.complex( - [[[1], [3], [5]], [[7], [9], [11]]], - [[[2], [4], [6]], [[8], [10], [12]]]); - const b = a.reshape([6]); - expect(b.dtype).toBe('complex64'); - expect(b.shape).toEqual([6]); - expectArraysClose(await a.data(), await b.data()); - }); - - it('Tensor4D default dtype', async () => { - const a = tf.tensor4d([1, 2, 3, 4, 5, 6], [2, 3, 1, 1]); - const b = a.reshape([2, 3]); - expect(b.dtype).toBe('float32'); - expect(b.shape).toEqual([2, 3]); - expectArraysClose(await a.data(), await b.data()); - }); - - it('Tensor4D float32 dtype', () => { - const a = tf.tensor4d([1, 2, 3, 4, 5, 6], [2, 3, 1, 1], 'float32'); - const b = a.reshape([2, 3]); - expect(b.dtype).toBe('float32'); - expect(b.shape).toEqual([2, 3]); - }); - - it('Tensor4D int32 dtype', async () => { - const a = tf.tensor4d([1, 2, 3, 4, 5, 6], [2, 3, 1, 1], 'int32'); - const b = a.reshape([3, 2]); - expect(b.dtype).toBe('int32'); - expect(b.shape).toEqual([3, 2]); - expectArraysClose(await a.data(), await b.data()); - }); - - it('Tensor4D complex64 dtype', async () => { - const a = tf.complex( - [[[[1]], [[3]], [[5]]], [[[7]], [[9]], [[11]]]], - [[[[2]], [[4]], [[6]]], [[[8]], [[10]], [[12]]]]); - const b = a.reshape([3, 2]); - expect(b.dtype).toBe('complex64'); - expect(b.shape).toEqual([3, 2]); - expectArraysClose(await a.data(), await b.data()); - }); - - it('Tensor4D bool dtype', () => { - const a = tf.tensor4d([1, 2, 3, 4, 5, 6], [2, 3, 1, 1], 'bool'); - const b = a.reshape([3, 2]); - expect(b.dtype).toBe('bool'); - expect(b.shape).toEqual([3, 2]); - }); - - it('.data() with casting, string tensor', async () => { - const a = tf.tensor(['a', 'b']); - const data: string[] = await a.data<'string'>(); - expect(data).toEqual(['a', 'b']); - }); - - it('reshape is functional', async () => { - const a = tf.scalar(2.4); - const b = a.reshape([]); - expect(a.id).not.toBe(b.id); - b.dispose(); - expectArraysClose(await a.data(), [2.4]); - }); - - it('reshape a string tensor', async () => { - const a = tf.tensor(['a', 'b']); - const b = a.reshape([2, 1, 1]); - expect(b.dtype).toBe('string'); - expect(b.shape).toEqual([2, 1, 1]); - expectArraysEqual(await b.data(), ['a', 'b']); - }); - - it('reshape throws when passed a non-tensor', () => { - // tslint:disable-next-line:no-any - expect(() => tf.reshape({} as any, [])) - .toThrowError(/Argument 'x' passed to 'reshape' must be a Tensor/); - }); - - it('reshape accepts a tensor-like object', async () => { - const res = tf.reshape([[1, 2, 3], [4, 5, 6]], [3, 2]); - expect(res.dtype).toBe('float32'); - expect(res.shape).toEqual([3, 2]); - expectArraysClose(await res.data(), [1, 2, 3, 4, 5, 6]); - }); - - it('cast bool -> bool', () => { - const a = tf.tensor1d([1, 0], 'bool'); - expect(a.cast('bool').dtype).toEqual('bool'); - }); - - it('cast bool -> int32', () => { - const a = tf.tensor1d([1, 0], 'bool'); - expect(a.cast('int32').dtype).toEqual('int32'); - }); - - it('cast bool -> float32', () => { - const a = tf.tensor1d([1, 0], 'bool'); - expect(a.cast('float32').dtype).toEqual('float32'); - }); - - it('cast int32 -> bool', () => { - const a = tf.tensor1d([1, 0], 'int32'); - expect(a.cast('bool').dtype).toEqual('bool'); - }); - - it('cast int32 -> int32', () => { - const a = tf.tensor1d([1, 2], 'int32'); - expect(a.cast('int32').dtype).toEqual('int32'); - }); - - it('cast int32 -> float32', () => { - const a = tf.tensor1d([1, 2], 'int32'); - expect(a.cast('float32').dtype).toEqual('float32'); - }); - - it('cast float32 -> bool', () => { - const a = tf.tensor1d([1.0, 0.0]); - expect(a.cast('bool').dtype).toEqual('bool'); - }); - - it('cast float32 -> int32', () => { - const a = tf.tensor1d([1.0, 2.0]); - expect(a.cast('int32').dtype).toEqual('int32'); - }); - - it('cast float32 -> int32. async download', async () => { - const a = tf.tensor1d([1, 2]); - const aInt = a.cast('int32'); - expect(aInt.dtype).toEqual('int32'); - - const asyncData = await aInt.data(); - expect(asyncData instanceof Int32Array).toEqual(true); - }); - - it('cast float32 -> int32. queued async download', async () => { - const a = tf.tensor1d([1, 2]); - const aInt = a.cast('int32'); - expect(aInt.dtype).toEqual('int32'); - - const [first, second] = await Promise.all([aInt.data(), aInt.data()]); - expect(first instanceof Int32Array).toEqual(true); - expect(second instanceof Int32Array).toEqual(true); - }); - - it('cast float32 -> int32. sync download', async () => { - const a = tf.tensor1d([1, 2]).cast('int32'); - expect(a.dtype).toEqual('int32'); - - const data = await a.data(); - expect(data instanceof Int32Array).toEqual(true); - }); - - it('cast float32 -> float32', () => { - const a = tf.tensor1d([1.0, 2.0]); - expect(a.cast('float32').dtype).toEqual('float32'); - }); - - it('cast complex64 -> float32', async () => { - const a = tf.complex([1.0, 2.0], [3.0, 4.0]); - const result = a.cast('float32'); - - expect(result.dtype).toEqual('float32'); - expectArraysClose(await result.data(), [1.0, 2.0]); - }); - - it('cast complex64 -> int32', async () => { - const a = tf.complex([1.0, 2.0], [3.0, 4.0]); - const result = a.cast('int32'); - - expect(result.dtype).toEqual('int32'); - expectArraysEqual(await result.data(), [1, 2]); - }); - - it('cast complex64 -> bool', async () => { - const a = tf.complex([1.0, 0.0], [1.0, 1.0]); - const result = a.cast('bool'); - - expect(result.dtype).toEqual('bool'); - expectArraysEqual(await result.data(), [true, false]); - }); - - it('cast throws when passed a non-tensor', () => { - expect(() => tf.cast({} as tf.Tensor, 'float32')) - .toThrowError(/Argument 'x' passed to 'cast' must be a Tensor/); - }); - - it('cast accepts a tensor-like object', async () => { - const a = [1.0, 2.0]; - const res = tf.cast(a, 'int32'); - expect(res.dtype).toEqual('int32'); - expectArraysClose(await res.data(), [1, 2]); - }); - - it('cast string -> !string throws error', () => { - const a = ['a', 'b']; - expect(() => tf.cast(a, 'int32')).toThrowError(); - expect(() => tf.cast(a, 'float32')).toThrowError(); - expect(() => tf.cast(a, 'bool')).toThrowError(); - expect(() => tf.cast(a, 'complex64')).toThrowError(); - }); - - it('cast !string -> string throws error', () => { - expect(() => tf.cast(tf.tensor(1, [], 'float32'), 'string')).toThrowError(); - expect(() => tf.cast(tf.tensor(1, [], 'int32'), 'string')).toThrowError(); - expect(() => tf.cast(tf.tensor(1, [], 'bool'), 'string')).toThrowError(); - expect(() => tf.cast(tf.tensor(1, [], 'complex64'), 'string')) - .toThrowError(); - }); - - it('scalar bool -> int32', async () => { - const a = tf.scalar(true, 'bool').toInt(); - expect(a.dtype).toBe('int32'); - expectArraysEqual(await a.data(), 1); - }); - - it('Tensor1D float32 -> int32', async () => { - const a = tf.tensor1d([1.1, 3.9, -2.9, 0]).toInt(); - expect(a.dtype).toBe('int32'); - expectArraysEqual(await a.data(), [1, 3, -2, 0]); - }); - - it('Tensor2D float32 -> bool', async () => { - const a = tf.tensor2d([1.1, 3.9, -2.9, 0], [2, 2]).asType('bool'); - expect(a.dtype).toBe('bool'); - expectArraysEqual(await a.data(), [1, 1, 1, 0]); - }); - - it('Tensor2D int32 -> bool', async () => { - const a = tf.tensor2d([1, 3, 0, -1], [2, 2], 'int32').toBool(); - expect(a.dtype).toBe('bool'); - expectArraysEqual(await a.data(), [1, 1, 0, 1]); - }); - - it('Tensor3D bool -> float32', async () => { - const a = - tf.tensor3d([true, false, false, true], [2, 2, 1], 'bool').toFloat(); - expect(a.dtype).toBe('float32'); - expectArraysClose(await a.data(), [1, 0, 0, 1]); - }); - - it('bool CPU -> GPU -> CPU', async () => { - const a = tf.tensor1d([1, 2, 0, 0, 5], 'bool'); - expectArraysEqual(await a.data(), [1, 1, 0, 0, 1]); - }); - - it('int32 CPU -> GPU -> CPU', async () => { - const a = tf.tensor1d([1, 2, 0, 0, 5], 'int32'); - expectArraysEqual(await a.data(), [1, 2, 0, 0, 5]); - }); - - it('asType is functional', async () => { - const a = tf.scalar(2.4, 'float32'); - const b = a.toFloat(); - expect(a.id).not.toBe(b.id); - b.dispose(); - expectArraysClose(await a.data(), [2.4]); - }); - - it('squeeze no axis', () => { - const a = tf.tensor2d([4, 2, 1], [3, 1], 'bool'); - const b = a.squeeze(); - expect(b.shape).toEqual([3]); - }); - - it('squeeze with axis', () => { - const a = tf.tensor3d([4, 2, 1], [3, 1, 1], 'bool'); - const b = a.squeeze([1]); - expect(b.shape).toEqual([3, 1]); - }); - - it('squeeze with negative axis', () => { - const a = tf.tensor3d([4, 2, 1], [3, 1, 1], 'bool'); - const b = a.squeeze([-1]); - expect(b.shape).toEqual([3, 1]); - }); - - it('squeeze with multiple negative axis', () => { - const a = tf.tensor3d([4, 2, 1], [3, 1, 1], 'bool'); - const b = a.squeeze([-1, -2]); - expect(b.shape).toEqual([3]); - }); - - it('squeeze wrong axis', () => { - const a = tf.tensor3d([4, 2, 1], [3, 1, 1], 'bool'); - expect(() => a.squeeze([0, 1])).toThrowError(); - }); - - it('squeeze wrong negative axis', () => { - const a = tf.tensor3d([4, 2, 1], [3, 1, 1], 'bool'); - expect(() => a.squeeze([-3, -2])).toThrowError(); - }); - - it('squeeze axis out of range', () => { - const a = tf.tensor3d([4, 2, 1], [3, 1, 1], 'bool'); - expect(() => a.squeeze([10, 11])).toThrowError(); - }); - - it('squeeze negative axis out of range', () => { - const a = tf.tensor3d([4, 2, 1], [3, 1, 1], 'bool'); - expect(() => a.squeeze([-13, -12])).toThrowError(); - }); - - it('squeeze throws when passed a non-tensor', () => { - expect(() => tf.squeeze({} as tf.Tensor)) - .toThrowError(/Argument 'x' passed to 'squeeze' must be a Tensor/); - }); - - it('squeeze accepts a tensor-like object', async () => { - const res = tf.squeeze([[[4]], [[2]], [[1]]] /* shape is [3, 1, 1] */); - expect(res.shape).toEqual([3]); - expectArraysClose(await res.data(), [4, 2, 1]); - }); - - it('squeeze a zero-sized tensor', () => { - const a = tf.tensor3d([], [0, 1, 0]); - const res = tf.squeeze(a); - expect(res.shape).toEqual([0, 0]); - }); - - it('squeeze can take an empty list of axis', () => { - const a = tf.zeros([2, 1, 3, 1, 4]); - const axes: number[] = []; - // Empty axes list means all possible axes. - const res = tf.squeeze(a, axes); - expect(res.shape).toEqual([2, 3, 4]); - }); - - it('squeeze a complex64 tensor', async () => { - const a = tf.complex([[4], [1], [5]], [[2], [3], [6]]); - const b = a.squeeze(); - expect(b.shape).toEqual([3]); - expectArraysClose(await b.data(), [4, 2, 1, 3, 5, 6]); - }); - - it('scalar -> 2d', () => { - const a = tf.scalar(4, 'int32'); - const b = a.as2D(1, 1); - expect(b.dtype).toBe('int32'); - expect(b.shape).toEqual([1, 1]); - }); - - it('1d -> 2d', () => { - const a = tf.tensor1d([4, 2, 1], 'bool'); - const b = a.as2D(3, 1); - expect(b.dtype).toBe('bool'); - expect(b.shape).toEqual([3, 1]); - }); - - it('2d -> 4d', () => { - const a = tf.tensor2d([4, 2, 1, 3], [2, 2]); - const b = a.as4D(1, 1, 2, 2); - expect(b.dtype).toBe('float32'); - expect(b.shape).toEqual([1, 1, 2, 2]); - }); - - it('3d -> 2d', () => { - const a = tf.tensor3d([4, 2, 1, 3], [2, 2, 1], 'float32'); - const b = a.as2D(2, 2); - expect(b.dtype).toBe('float32'); - expect(b.shape).toEqual([2, 2]); - }); - - it('4d -> 1d', () => { - const a = tf.tensor4d([4, 2, 1, 3], [2, 2, 1, 1], 'bool'); - const b = a.as1D(); - expect(b.dtype).toBe('bool'); - expect(b.shape).toEqual([4]); - }); - - it('throws when passed non-integer shape', () => { - const msg = 'Tensor must have a shape comprised of positive ' + - 'integers but got shape [2,2.2].'; - expect(() => tf.tensor([1, 2, 3, 4], [2, 2.2])).toThrowError(msg); - }); - - it('throws when passed negative shape', () => { - const msg = 'Tensor must have a shape comprised of positive ' + - 'integers but got shape [2,-2].'; - expect(() => tf.tensor([1, 2, 3, 4], [2, -2])).toThrowError(msg); - }); - - it('ones with complex type', async () => { - // Imaginary part should be zero. - const a = tf.ones([2, 2], 'complex64'); - expectArraysClose(await a.data(), [1, 0, 1, 0, 1, 0, 1, 0]); - }); - - it('can create a tensor where values.size != buffer.size', async () => { - const a = new Float32Array([1, 2, 3, 4, 5]); - const b = a.subarray(0, 2); - const t = tf.tensor1d(b); - expect(t.shape).toEqual([2]); - expectArraysClose(await t.data(), [1, 2]); - }); -}); - -describeWithFlags('tensor debug mode', ALL_ENVS, () => { - beforeAll(() => { - // Silence debug warnings. - spyOn(console, 'warn'); - tf.enableDebugMode(); - }); - - it('tf.tensor() from TypedArray + number[] fails due to wrong shape', () => { - expect(() => tf.tensor([ - new Float32Array([1, 2]), - new Float32Array([3, 4]), - new Float32Array([5, 6]), - // Should be of length 4 - [7, 8, 9, 10], - ])) - .toThrowError( - /Element arr\[3\] should have 2 elements, but has 4 elements/); - }); -}); - -describeWithFlags('tensor dataSync', SYNC_BACKEND_ENVS, () => { - it('.dataSync() with casting, string tensor', () => { - const a = tf.tensor(['a', 'b']); - const data: string[] = a.dataSync<'string'>(); - expect(data).toEqual(['a', 'b']); - }); -}); - -describeWithFlags('tensor arraySync', SYNC_BACKEND_ENVS, () => { - it('.arraySync() with a non-complex tensor', () => { - const a = tf.tensor([1, 2, 3, 4, 5, 6], [2, 3]); - expect(a.arraySync()).toEqual([[1, 2, 3], [4, 5, 6]]); - }); - - it('.arraySync() with a complex tensor', () => { - const a = tf.complex([[1, 2], [3, 4]], [[11, 12], [13, 14]]); - expect(a.arraySync()).toEqual([[1, 11, 2, 12], [3, 13, 4, 14]]); - }); - - // The other cases should be covered by toNestedArray tests in util_test.ts. -}); - -describeWithFlags('tensor.toString', SYNC_BACKEND_ENVS, () => { - it('scalar verbose', () => { - const verbose = true; - const str = tf.scalar(5).toString(verbose); - expect(str).toEqual( - 'Tensor\n' + - ' dtype: float32\n' + - ' rank: 0\n' + - ' shape: []\n' + - ' values:\n' + - ' 5'); - }); - - it('string scalar verbose', () => { - const verbose = true; - const str = tf.scalar('test').toString(verbose); - expect(str).toEqual( - 'Tensor\n' + - ' dtype: string\n' + - ' rank: 0\n' + - ' shape: []\n' + - ' values:\n' + - ' test'); - }); - - it('bool scalar verbose', () => { - const verbose = true; - const str = tf.scalar(true).toString(verbose); - expect(str).toEqual( - 'Tensor\n' + - ' dtype: bool\n' + - ' rank: 0\n' + - ' shape: []\n' + - ' values:\n' + - ' true'); - }); - - it('2D 0 shaped tensor verbose', () => { - const verbose = true; - const str = tf.zeros([0, 1]).toString(verbose); - expect(str).toEqual( - 'Tensor\n' + - ' dtype: float32\n' + - ' rank: 2\n' + - ' shape: [0,1]\n' + - ' values:\n' + - ' []'); - }); - - it('3D 0 shaped tensor verbose', () => { - const verbose = true; - const str = tf.zeros([1, 0, 1]).toString(verbose); - expect(str).toEqual( - 'Tensor\n' + - ' dtype: float32\n' + - ' rank: 3\n' + - ' shape: [1,0,1]\n' + - ' values:\n' + - ' [ []]'); - }); - - it('1d tensor verbose', () => { - const verbose = true; - const str = tf.zeros([4]).toString(verbose); - expect(str).toEqual( - 'Tensor\n' + - ' dtype: float32\n' + - ' rank: 1\n' + - ' shape: [4]\n' + - ' values:\n' + - ' [0, 0, 0, 0]'); - }); - - it('1d string tensor verbose', () => { - const verbose = true; - const str = tf.tensor(['a', 'bb', 'ccc']).toString(verbose); - expect(str).toEqual( - 'Tensor\n' + - ' dtype: string\n' + - ' rank: 1\n' + - ' shape: [3]\n' + - ' values:\n' + - ' [\'a\', \'bb\', \'ccc\']'); - }); - - it('1d bool tensor verbose', () => { - const verbose = true; - const str = tf.tensor([true, false, true]).toString(verbose); - expect(str).toEqual( - 'Tensor\n' + - ' dtype: bool\n' + - ' rank: 1\n' + - ' shape: [3]\n' + - ' values:\n' + - ' [true, false, true]'); - }); - - it('2d tensor verbose', () => { - const verbose = true; - const str = tf.zeros([3, 3]).toString(verbose); - expect(str).toEqual( - 'Tensor\n' + - ' dtype: float32\n' + - ' rank: 2\n' + - ' shape: [3,3]\n' + - ' values:\n' + - ' [[0, 0, 0],\n' + - ' [0, 0, 0],\n' + - ' [0, 0, 0]]'); - }); - - it('2d string tensor verbose', () => { - const verbose = true; - const vals = [ - ['a', 'bb', 'ccc'], - ['d', 'e', 'f'], - ['g', 'h', 'i'], - ]; - const str = tf.tensor(vals).toString(verbose); - expect(str).toEqual( - 'Tensor\n' + - ' dtype: string\n' + - ' rank: 2\n' + - ' shape: [3,3]\n' + - ' values:\n' + - ' [[\'a\', \'bb\', \'ccc\'],\n' + - ' [\'d\', \'e\' , \'f\' ],\n' + - ' [\'g\', \'h\' , \'i\' ]]'); - }); - - it('2d bool tensor verbose', () => { - const verbose = true; - const str = tf.zeros([3, 3], 'bool').toString(verbose); - expect(str).toEqual( - 'Tensor\n' + - ' dtype: bool\n' + - ' rank: 2\n' + - ' shape: [3,3]\n' + - ' values:\n' + - ' [[false, false, false],\n' + - ' [false, false, false],\n' + - ' [false, false, false]]'); - }); - - it('3d tensor verbose', () => { - const verbose = true; - const str = tf.zeros([3, 3, 2]).toString(verbose); - expect(str).toEqual( - 'Tensor\n' + - ' dtype: float32\n' + - ' rank: 3\n' + - ' shape: [3,3,2]\n' + - ' values:\n' + - ' [[[0, 0],\n' + - ' [0, 0],\n' + - ' [0, 0]],\n\n' + - ' [[0, 0],\n' + - ' [0, 0],\n' + - ' [0, 0]],\n\n' + - ' [[0, 0],\n' + - ' [0, 0],\n' + - ' [0, 0]]]'); - }); - - it('3d string tensor verbose', () => { - const verbose = true; - const vals = [ - [['a', 'bb'], ['ccc', 'dddd']], - [['e', 'ff'], ['ggg', 'hhhh']], - [['i', 'jj'], ['kkk', 'llll']], - ]; - const str = tf.tensor(vals).toString(verbose); - expect(str).toEqual( - 'Tensor\n' + - ' dtype: string\n' + - ' rank: 3\n' + - ' shape: [3,2,2]\n' + - ' values:\n' + - ' [[[\'a\' , \'bb\' ],\n' + - ' [\'ccc\', \'dddd\']],\n\n' + - ' [[\'e\' , \'ff\' ],\n' + - ' [\'ggg\', \'hhhh\']],\n\n' + - ' [[\'i\' , \'jj\' ],\n' + - ' [\'kkk\', \'llll\']]]'); - }); - - it('3d bool tensor verbose', () => { - const verbose = true; - const str = tf.ones([3, 3, 2], 'bool').toString(verbose); - expect(str).toEqual( - 'Tensor\n' + - ' dtype: bool\n' + - ' rank: 3\n' + - ' shape: [3,3,2]\n' + - ' values:\n' + - ' [[[true, true],\n' + - ' [true, true],\n' + - ' [true, true]],\n\n' + - ' [[true, true],\n' + - ' [true, true],\n' + - ' [true, true]],\n\n' + - ' [[true, true],\n' + - ' [true, true],\n' + - ' [true, true]]]'); - }); - - it('1d long tensor verbose', () => { - const verbose = true; - const str = tf.zeros([100]).toString(verbose); - expect(str).toEqual( - 'Tensor\n' + - ' dtype: float32\n' + - ' rank: 1\n' + - ' shape: [100]\n' + - ' values:\n' + - ' [0, 0, 0, ..., 0, 0, 0]'); - }); - - it('1d long string tensor verbose', () => { - const verbose = true; - const str = tf.fill([100], 'hi').toString(verbose); - expect(str).toEqual( - 'Tensor\n' + - ' dtype: string\n' + - ' rank: 1\n' + - ' shape: [100]\n' + - ' values:\n' + - ' [\'hi\', \'hi\', \'hi\', ..., \'hi\', \'hi\', \'hi\']'); - }); - - it('2d long tensor verbose', () => { - const verbose = true; - const str = tf.zeros([100, 100]).toString(verbose); - expect(str).toEqual( - 'Tensor\n' + - ' dtype: float32\n' + - ' rank: 2\n' + - ' shape: [100,100]\n' + - ' values:\n' + - ' [[0, 0, 0, ..., 0, 0, 0],\n' + - ' [0, 0, 0, ..., 0, 0, 0],\n' + - ' [0, 0, 0, ..., 0, 0, 0],\n' + - ' ...,\n' + - ' [0, 0, 0, ..., 0, 0, 0],\n' + - ' [0, 0, 0, ..., 0, 0, 0],\n' + - ' [0, 0, 0, ..., 0, 0, 0]]'); - }); - - it('2d long string tensor verbose', () => { - const verbose = true; - const str = tf.fill([100, 100], 'a').toString(verbose); - expect(str).toEqual( - 'Tensor\n' + - ' dtype: string\n' + - ' rank: 2\n' + - ' shape: [100,100]\n' + - ' values:\n' + - ' [[\'a\', \'a\', \'a\', ..., \'a\', \'a\', \'a\'],\n' + - ' [\'a\', \'a\', \'a\', ..., \'a\', \'a\', \'a\'],\n' + - ' [\'a\', \'a\', \'a\', ..., \'a\', \'a\', \'a\'],\n' + - ' ...,\n' + - ' [\'a\', \'a\', \'a\', ..., \'a\', \'a\', \'a\'],\n' + - ' [\'a\', \'a\', \'a\', ..., \'a\', \'a\', \'a\'],\n' + - ' [\'a\', \'a\', \'a\', ..., \'a\', \'a\', \'a\']]'); - }); - - it('2d with padding to align columns verbose', () => { - const verbose = true; - const str = tf.tensor([ - [0.8597712, 3, 0.2740789], [0.6696132, 0.4825962, 2.75], - [1.991, 0.0640865, 0.2983858] - ]).toString(verbose); - expect(str).toEqual( - 'Tensor\n' + - ' dtype: float32\n' + - ' rank: 2\n' + - ' shape: [3,3]\n' + - ' values:\n' + - ' [[0.8597712, 3 , 0.2740789],\n' + - ' [0.6696132, 0.4825962, 2.75 ],\n' + - ' [1.9910001, 0.0640865, 0.2983858]]'); - }); - - it('2d string tensor with padding verbose', () => { - const verbose = true; - const str = tf.tensor([ - ['abcdef', 'a', 'abcdef'], - ['abcdef', 'abcdef', 'abc'], - ['abcd', 'abcdef', 'abcdef'], - ]).toString(verbose); - expect(str).toEqual( - 'Tensor\n' + - ' dtype: string\n' + - ' rank: 2\n' + - ' shape: [3,3]\n' + - ' values:\n' + - ' [[\'abcdef\', \'a\' , \'abcdef\'],\n' + - ' [\'abcdef\', \'abcdef\', \'abc\' ],\n' + - ' [\'abcd\' , \'abcdef\', \'abcdef\']]'); - }); - - it('scalar', () => { - const str = tf.scalar(5).toString(); - expect(str).toEqual( - 'Tensor\n' + - ' 5'); - }); - - it('scalar string', () => { - const str = tf.scalar('hello').toString(); - expect(str).toEqual( - 'Tensor\n' + - ' hello'); - }); - - it('1d tensor', () => { - const str = tf.zeros([4]).toString(); - expect(str).toEqual( - 'Tensor\n' + - ' [0, 0, 0, 0]'); - }); - - it('2d tensor', () => { - const str = tf.zeros([3, 3]).toString(); - expect(str).toEqual( - 'Tensor\n' + - ' [[0, 0, 0],\n' + - ' [0, 0, 0],\n' + - ' [0, 0, 0]]'); - }); - - it('3d tensor', () => { - const str = tf.zeros([3, 3, 2]).toString(); - expect(str).toEqual( - 'Tensor\n' + - ' [[[0, 0],\n' + - ' [0, 0],\n' + - ' [0, 0]],\n\n' + - ' [[0, 0],\n' + - ' [0, 0],\n' + - ' [0, 0]],\n\n' + - ' [[0, 0],\n' + - ' [0, 0],\n' + - ' [0, 0]]]'); - }); - - it('1d long tensor', () => { - const str = tf.zeros([100]).toString(); - expect(str).toEqual( - 'Tensor\n' + - ' [0, 0, 0, ..., 0, 0, 0]'); - }); - - it('2d long tensor', () => { - const str = tf.zeros([100, 100]).toString(); - expect(str).toEqual( - 'Tensor\n' + - ' [[0, 0, 0, ..., 0, 0, 0],\n' + - ' [0, 0, 0, ..., 0, 0, 0],\n' + - ' [0, 0, 0, ..., 0, 0, 0],\n' + - ' ...,\n' + - ' [0, 0, 0, ..., 0, 0, 0],\n' + - ' [0, 0, 0, ..., 0, 0, 0],\n' + - ' [0, 0, 0, ..., 0, 0, 0]]'); - }); - - it('2d with padding to align columns', () => { - const str = tf.tensor([ - [0.8597712, 3, 0.2740789], [0.6696132, 0.4825962, 2.75], - [1.991, 0.0640865, 0.2983858] - ]).toString(); - expect(str).toEqual( - 'Tensor\n' + - ' [[0.8597712, 3 , 0.2740789],\n' + - ' [0.6696132, 0.4825962, 2.75 ],\n' + - ' [1.9910001, 0.0640865, 0.2983858]]'); - }); - - it('scalar complex64 verbose', () => { - const verbose = true; - const str = tf.complex(5, 6).toString(verbose); - expect(str).toEqual( - 'Tensor\n' + - ' dtype: complex64\n' + - ' rank: 0\n' + - ' shape: []\n' + - ' values:\n' + - ' 5 + 6j'); - }); - - it('1d complex64 tensor verbose', () => { - const verbose = true; - const str = tf.complex([3, 5], [4, 6]).toString(verbose); - expect(str).toEqual( - 'Tensor\n' + - ' dtype: complex64\n' + - ' rank: 1\n' + - ' shape: [2]\n' + - ' values:\n' + - ' [3 + 4j, 5 + 6j]'); - }); - - it('2d complex64 tensor verbose', () => { - const verbose = true; - const str = tf.complex(tf.linspace(0, 8, 9), tf.linspace(8, 0, 9)) - .reshape([3, 3]) - .toString(verbose); - expect(str).toEqual( - 'Tensor\n' + - ' dtype: complex64\n' + - ' rank: 2\n' + - ' shape: [3,3]\n' + - ' values:\n' + - ' [[0 + 8j, 1 + 7j, 2 + 6j],\n' + - ' [3 + 5j, 4 + 4j, 5 + 3j],\n' + - ' [6 + 2j, 7 + 1j, 8 + 0j]]'); - }); - - it('3d complex64 tensor verbose', () => { - const verbose = true; - const str = tf.complex(tf.linspace(0, 17, 18), tf.linspace(17, 0, 18)) - .reshape([3, 3, 2]) - .toString(verbose); - expect(str).toEqual( - 'Tensor\n' + - ' dtype: complex64\n' + - ' rank: 3\n' + - ' shape: [3,3,2]\n' + - ' values:\n' + - ' [[[0 + 17j, 1 + 16j],\n' + - ' [2 + 15j, 3 + 14j],\n' + - ' [4 + 13j, 5 + 12j]],\n\n' + - ' [[6 + 11j, 7 + 10j],\n' + - ' [8 + 9j , 9 + 8j ],\n' + - ' [10 + 7j, 11 + 6j]],\n\n' + - ' [[12 + 5j, 13 + 4j],\n' + - ' [14 + 3j, 15 + 2j],\n' + - ' [16 + 1j, 17 + 0j]]]'); - }); - - it('1d long complex64 tensor verbose', () => { - const verbose = true; - const str = tf.complex(tf.linspace(0, 99, 100), tf.linspace(99, 0, 100)) - .toString(verbose); - expect(str).toEqual( - 'Tensor\n' + - ' dtype: complex64\n' + - ' rank: 1\n' + - ' shape: [100]\n' + - ' values:\n' + - ' [0 + 99j, 1 + 98j, 2 + 97j, ..., 97 + 2j, 98 + 1j, 99 + 0j]'); - }); - - it('2d long complex64 tensor verbose', () => { - const verbose = true; - - const dim = 100; - const str = tf.complex( - tf.linspace(0, dim * dim - 1, dim * dim), - tf.linspace(dim * dim - 1, 0, dim * dim)) - .reshape([dim, dim]) - .toString(verbose); - - expect(str).toEqual( - 'Tensor\n' + - ' dtype: complex64\n' + - ' rank: 2\n' + - ' shape: [100,100]\n' + - ' values:\n' + - // tslint:disable:max-line-length - ' [[0 + 9999j , 1 + 9998j , 2 + 9997j , ..., 97 + 9902j , 98 + 9901j , 99 + 9900j ],\n' + - ' [100 + 9899j , 101 + 9898j , 102 + 9897j , ..., 197 + 9802j , 198 + 9801j , 199 + 9800j ],\n' + - ' [200 + 9799j , 201 + 9798j , 202 + 9797j , ..., 297 + 9702j , 298 + 9701j , 299 + 9700j ],\n' + - ' ...,\n' + - ' [9700 + 299j , 9701 + 298j , 9702 + 297j , ..., 9797 + 202j , 9798 + 201j , 9799 + 200j ],\n' + - ' [9800 + 199j , 9801 + 198j , 9802 + 197j , ..., 9897 + 102j , 9898 + 101j , 9899 + 100j ],\n' + - ' [9900 + 99j , 9901 + 98j , 9902 + 97j , ..., 9997 + 2j , 9998 + 1j , 9999 + 0j ]]'); - // tslint:enable:max-line-length - }); - - it('2d complex64 with padding to align columns verbose', () => { - const verbose = true; - - const str = tf.complex( - [ - [0.8597712, 3, 0.2740789], [0.6696132, 0.4825962, 2.75], - [1.991, 0.0640865, 0.2983858] - ], - [[1, 1.0102332, 3], [2, 5, 2.34424], [1.23, 2, 0.123]]) - .toString(verbose); - expect(str).toEqual( - 'Tensor\n' + - ' dtype: complex64\n' + - ' rank: 2\n' + - ' shape: [3,3]\n' + - ' values:\n' + - ' [[0.8597712 + 1j , 3 + 1.0102332j, 0.2740789 + 3j ],\n' + - ' [0.6696132 + 2j , 0.4825962 + 5j, 2.75 + 2.34424j ],\n' + - ' [1.9910001 + 1.23j, 0.0640865 + 2j, 0.2983858 + 0.123j]]'); - }); - - it('scalar complex64', () => { - const str = tf.complex(5, 4).toString(); - expect(str).toEqual( - 'Tensor\n' + - ' 5 + 4j'); - }); - - it('1d complex64 tensor', () => { - const str = - tf.complex(tf.linspace(0, 3, 4), tf.linspace(3, 0, 4)).toString(); - expect(str).toEqual( - 'Tensor\n' + - ' [0 + 3j, 1 + 2j, 2 + 1j, 3 + 0j]'); - }); - - it('2d complex64 tensor', () => { - const str = tf.complex(tf.linspace(0, 8, 9), tf.linspace(8, 0, 9)) - .reshape([3, 3]) - .toString(); - expect(str).toEqual( - 'Tensor\n' + - ' [[0 + 8j, 1 + 7j, 2 + 6j],\n' + - ' [3 + 5j, 4 + 4j, 5 + 3j],\n' + - ' [6 + 2j, 7 + 1j, 8 + 0j]]'); - }); - - it('3d complex64 tensor', () => { - const str = tf.complex(tf.linspace(0, 17, 18), tf.linspace(17, 0, 18)) - .reshape([3, 3, 2]) - .toString(); - - expect(str).toEqual( - 'Tensor\n' + - ' [[[0 + 17j, 1 + 16j],\n' + - ' [2 + 15j, 3 + 14j],\n' + - ' [4 + 13j, 5 + 12j]],\n\n' + - ' [[6 + 11j, 7 + 10j],\n' + - ' [8 + 9j , 9 + 8j ],\n' + - ' [10 + 7j, 11 + 6j]],\n\n' + - ' [[12 + 5j, 13 + 4j],\n' + - ' [14 + 3j, 15 + 2j],\n' + - ' [16 + 1j, 17 + 0j]]]'); - }); - - it('1d long complex64 tensor', () => { - const str = - tf.complex(tf.linspace(0, 99, 100), tf.linspace(99, 0, 100)).toString(); - - expect(str).toEqual( - 'Tensor\n' + - ' [0 + 99j, 1 + 98j, 2 + 97j, ..., 97 + 2j, 98 + 1j, 99 + 0j]'); - }); - - it('2d long complex64 tensor', () => { - const dim = 100; - const str = tf.complex( - tf.linspace(0, dim * dim - 1, dim * dim), - tf.linspace(dim * dim - 1, 0, dim * dim)) - .reshape([dim, dim]) - .toString(); - - expect(str).toEqual( - 'Tensor\n' + - // tslint:disable:max-line-length - ' [[0 + 9999j , 1 + 9998j , 2 + 9997j , ..., 97 + 9902j , 98 + 9901j , 99 + 9900j ],\n' + - ' [100 + 9899j , 101 + 9898j , 102 + 9897j , ..., 197 + 9802j , 198 + 9801j , 199 + 9800j ],\n' + - ' [200 + 9799j , 201 + 9798j , 202 + 9797j , ..., 297 + 9702j , 298 + 9701j , 299 + 9700j ],\n' + - ' ...,\n' + - ' [9700 + 299j , 9701 + 298j , 9702 + 297j , ..., 9797 + 202j , 9798 + 201j , 9799 + 200j ],\n' + - ' [9800 + 199j , 9801 + 198j , 9802 + 197j , ..., 9897 + 102j , 9898 + 101j , 9899 + 100j ],\n' + - ' [9900 + 99j , 9901 + 98j , 9902 + 97j , ..., 9997 + 2j , 9998 + 1j , 9999 + 0j ]]'); - // tslint:enable:max-line-length - }); - - it('2d complex64 with padding to align columns', () => { - const str = tf.complex( - [ - [0.8597712, 3, 0.2740789], [0.6696132, 0.4825962, 2.75], - [1.991, 0.0640865, 0.2983858] - ], - [[1, 1.0102332, 3], [2, 5, 2.34424], [1.23, 2, 0.123]]) - .toString(); - expect(str).toEqual( - 'Tensor\n' + - ' [[0.8597712 + 1j , 3 + 1.0102332j, 0.2740789 + 3j ],\n' + - ' [0.6696132 + 2j , 0.4825962 + 5j, 2.75 + 2.34424j ],\n' + - ' [1.9910001 + 1.23j, 0.0640865 + 2j, 0.2983858 + 0.123j]]'); - }); -}); - -describeWithFlags('tensor grad', ALL_ENVS, () => { - it('grad with second derivative', async () => { - // f(x) = x ^ 3 - const f = (x: Tensor) => x.pow(tf.scalar(3, 'int32')); - // f'(x) = 3x ^ 2 - const g = tf.grad(f); - // f''(x) = 6x - const gg = tf.grad(g); - const x = tf.tensor1d([2, 3]); - const data = gg(x); - expectArraysClose(await data.data(), [12, 18]); - }); -}); - -describeWithFlags('tensor.data', ALL_ENVS, () => { - it('interleaving .data() and .dataSync()', async () => { - const a = tf.tensor1d([1, 2, 3]); - const b = tf.tensor1d([4, 5, 6]); - - const ra = a.square(); - const rb = b.square(); - - expectArraysClose(await a.data(), [1, 2, 3]); - expectArraysClose(await b.data(), [4, 5, 6]); - expectArraysClose(await rb.data(), [16, 25, 36]); - expectArraysClose(await ra.data(), [1, 4, 9]); - }); - - it('.data() postpones disposal of tensor', done => { - expect(tf.memory().numTensors).toBe(0); - tf.tidy(() => { - const a = tf.scalar(5); - expect(tf.memory().numTensors).toBe(1); - a.square(); // Uploads it on GPU. - a.data().then(vals => { - // The tidy above should not dispose the scalar since there is - // a pending data read. - expectNumbersClose(vals[0], 5); - }); - }); - - // tidy ends immediately, but should not dispose the scalar. - - setTimeout(() => { - // tidy should dispose the tensor. - expect(tf.memory().numTensors).toBe(0); - done(); - }); - }); - - it('calling .data() twice works (2 subscribers to a single read)', done => { - tf.tidy(() => { - const a = tf.scalar(5); - a.square(); // Uploads it on GPU. - a.data().then(vals => { - expectNumbersClose(vals[0], 5); - }); - a.data() - .then(vals => { - expectNumbersClose(vals[0], 5); - }) - .then(done); - }); - // tidy ends immediately, but should not dispose the scalar since there is - // a pending data read. - }); -}); - -describeWithFlags('x instanceof Tensor', ALL_ENVS, () => { - it('x: Tensor', () => { - const t = tf.scalar(1); - expect(t instanceof Tensor).toBe(true); - }); - - it('x: other object, fails', () => { - const t = {something: 'else'}; - expect(t instanceof Tensor).toBe(false); - }); - - it('x: undefined or null, fails', () => { - // tslint:disable-next-line:no-any - expect((undefined as any) instanceof Tensor).toBe(false); - // tslint:disable-next-line:no-any - expect((null as any) instanceof Tensor).toBe(false); - }); -}); - -describeWithFlags('tensor with 0 in shape', ALL_ENVS, () => { - it('1d of shape [0]', async () => { - const a = tf.tensor1d([]); - expect(a.dtype).toBe('float32'); - expect(a.rank).toBe(1); - expect(a.shape).toEqual([0]); - expectArraysEqual(await a.data(), []); - }); - - it('1d string tensor of shape [0]', async () => { - const a = tf.tensor1d([], 'string'); - expect(a.dtype).toBe('string'); - expect(a.rank).toBe(1); - expect(a.shape).toEqual([0]); - expectArraysEqual(await a.data(), []); - }); - - it('2d of shape [0, 5]', async () => { - const a = tf.tensor2d([], [0, 5]); - expect(a.dtype).toBe('float32'); - expect(a.rank).toBe(2); - expect(a.shape).toEqual([0, 5]); - expectArraysEqual(await a.data(), []); - }); - - it('2d string tensor of shape [0, 5]', async () => { - const a = tf.tensor2d([], [0, 5], 'string'); - expect(a.dtype).toBe('string'); - expect(a.rank).toBe(2); - expect(a.shape).toEqual([0, 5]); - expectArraysEqual(await a.data(), []); - }); - - it('2d throws when values are not empty', () => { - const values = [1, 2, 3, 4]; - expect(() => tf.tensor2d(values, [0, 5], 'float32')) - .toThrowError( - 'Based on the provided shape, [0,5], the ' + - 'tensor should have 0 values but has 4'); - }); - - it('3d of shape [0, 3, 0]', async () => { - const a = tf.tensor3d([], [0, 3, 0]); - expect(a.dtype).toBe('float32'); - expect(a.rank).toBe(3); - expect(a.shape).toEqual([0, 3, 0]); - expectArraysEqual(await a.data(), []); - }); - - it('3d throws when values are not empty', () => { - const values = [1, 2, 3]; - expect(() => tf.tensor3d(values, [0, 3, 0], 'float32')) - .toThrowError( - 'Based on the provided shape, [0,3,0], the ' + - 'tensor should have 0 values but has 3'); - }); - - it('4d of shape [1, 3, 0, 5]', async () => { - const a = tf.tensor4d([], [1, 3, 0, 5]); - expect(a.dtype).toBe('float32'); - expect(a.rank).toBe(4); - expect(a.shape).toEqual([1, 3, 0, 5]); - expectArraysEqual(await a.data(), []); - }); - - it('4d throws when values are not empty', () => { - const values = [1, 2, 3]; - expect(() => tf.tensor4d(values, [1, 3, 0, 5], 'float32')) - .toThrowError( - 'Based on the provided shape, [1,3,0,5], the ' + - 'tensor should have 0 values but has 3'); - }); - - it('complex64 with 0 in shape', async () => { - const areal = tf.tensor2d([], [0, 5]); - const breal = tf.tensor2d([], [0, 5]); - const a = tf.complex(areal, breal); - expect(a.dtype).toBe('complex64'); - expect(a.rank).toBe(2); - expect(a.shape).toEqual([0, 5]); - expectArraysEqual(await a.data(), []); - }); -}); - -describeWithFlags('tensor.bytes()', ALL_ENVS, () => { - /** Helper method to get the bytes from a typed array. */ - function getBytes(a: TypedArray): Uint8Array { - return new Uint8Array(a.buffer); - } - - it('float32 tensor', async () => { - const a = tf.tensor([1.1, 3.2, 7], [3], 'float32'); - expect(await a.bytes()).toEqual(getBytes(new Float32Array([1.1, 3.2, 7]))); - }); - - it('int32 tensor', async () => { - const a = tf.tensor([1.1, 3.2, 7], [3], 'int32'); - expect(await a.bytes()).toEqual(getBytes(new Int32Array([1, 3, 7]))); - }); - - it('bool tensor', async () => { - const a = tf.tensor([true, true, false], [3], 'bool'); - expect(await a.bytes()).toEqual(new Uint8Array([1, 1, 0])); - }); - - it('string tensor from native strings', async () => { - const a = tf.tensor(['hello', 'world'], [2], 'string'); - expect(await a.bytes()).toEqual([ - encodeString('hello'), encodeString('world') - ]); - }); - - it('string tensor from encoded bytes', async () => { - const a = tf.tensor( - [encodeString('hello'), encodeString('world')], [2], 'string'); - expect(await a.bytes()).toEqual([ - encodeString('hello'), encodeString('world') - ]); - }); -}); diff --git a/tfjs-master/tfjs-core/src/tensor_types.ts b/tfjs-master/tfjs-core/src/tensor_types.ts deleted file mode 100644 index f8763f264..000000000 --- a/tfjs-master/tfjs-core/src/tensor_types.ts +++ /dev/null @@ -1,46 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Tensor, Variable} from './tensor'; - -/** @docalias {[name: string]: Tensor} */ -export type NamedTensorMap = { - [name: string]: Tensor; -}; - -export interface NamedTensor { - name: string; - tensor: Tensor; -} - -export type NamedVariableMap = { - [name: string]: Variable; -}; - -export type GradSaveFunc = (save: Tensor[]) => void; - -/** - * @docalias void|number|string|TypedArray|Tensor|Tensor[]|{[key: - * string]:Tensor|number|string} - */ -export type TensorContainer = - void|Tensor|string|number|boolean|TensorContainerObject| - TensorContainerArray|Float32Array|Int32Array|Uint8Array; -export interface TensorContainerObject { - [x: string]: TensorContainer; -} -export interface TensorContainerArray extends Array {} diff --git a/tfjs-master/tfjs-core/src/tensor_util.ts b/tfjs-master/tfjs-core/src/tensor_util.ts deleted file mode 100644 index 58db4e962..000000000 --- a/tfjs-master/tfjs-core/src/tensor_util.ts +++ /dev/null @@ -1,87 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {Tensor} from './tensor'; -import {TensorContainer, TensorContainerArray} from './tensor_types'; -import {upcastType} from './types'; -import {assert} from './util'; - -export function makeTypesMatch(a: T, b: T): [T, T] { - if (a.dtype === b.dtype) { - return [a, b]; - } - const dtype = upcastType(a.dtype, b.dtype); - return [a.cast(dtype), b.cast(dtype)]; -} - -export function assertTypesMatch(a: Tensor, b: Tensor): void { - assert( - a.dtype === b.dtype, - () => `The dtypes of the first(${a.dtype}) and` + - ` second(${b.dtype}) input must match`); -} - -export function isTensorInList(tensor: Tensor, tensorList: Tensor[]): boolean { - return tensorList.some(x => x.id === tensor.id); -} - -/** - * Extracts any `Tensor`s found within the provided object. - * - * @param container an object that may be a `Tensor` or may directly contain - * `Tensor`s, such as a `Tensor[]` or `{key: Tensor, ...}`. In general it - * is safe to pass any object here, except that `Promise`s are not - * supported. - * @returns An array of `Tensors` found within the passed object. If the - * argument is simply a `Tensor', a list containing that `Tensor` is - * returned. If the object is not a `Tensor` or does not - * contain `Tensors`, an empty list is returned. - */ -export function getTensorsInContainer(result: TensorContainer): Tensor[] { - const list: Tensor[] = []; - const seen = new Set<{}|void>(); - walkTensorContainer(result, list, seen); - return list; -} - -function walkTensorContainer( - container: TensorContainer, list: Tensor[], seen: Set<{}|void>): void { - if (container == null) { - return; - } - if (container instanceof Tensor) { - list.push(container); - return; - } - if (!isIterable(container)) { - return; - } - // Iteration over keys works also for arrays. - const iterable = container as TensorContainerArray; - for (const k in iterable) { - const val = iterable[k]; - if (!seen.has(val)) { - seen.add(val); - walkTensorContainer(val, list, seen); - } - } -} - -// tslint:disable-next-line:no-any -function isIterable(obj: any): boolean { - return Array.isArray(obj) || typeof obj === 'object'; -} diff --git a/tfjs-master/tfjs-core/src/tensor_util_env.ts b/tfjs-master/tfjs-core/src/tensor_util_env.ts deleted file mode 100644 index 60fd1272b..000000000 --- a/tfjs-master/tfjs-core/src/tensor_util_env.ts +++ /dev/null @@ -1,145 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from './engine'; -import {env} from './environment'; -import {getGlobalTensorClass, Tensor} from './tensor'; -import {DataType, isWebGLData, isWebGPUData, TensorLike, WebGLData, WebGPUData} from './types'; -import {assert, flatten, inferDtype, isTypedArray, toTypedArray} from './util'; -import {bytesPerElement} from './util_base'; - -export function inferShape( - val: TensorLike|WebGLData|WebGPUData, dtype?: DataType): number[] { - let firstElem: typeof val = val; - - if (isTypedArray(val)) { - return dtype === 'string' ? [] : [val.length]; - } - - if (isWebGLData(val)) { - const usedChannels = val.channels || 'RGBA'; - return [val.height, val.width * usedChannels.length]; - } else if (isWebGPUData(val)) { - return [val.buffer.size / (dtype == null ? 4 : bytesPerElement(dtype))]; - } - if (!Array.isArray(val)) { - return []; // Scalar. - } - const shape: number[] = []; - - while (Array.isArray(firstElem) || - isTypedArray(firstElem) && dtype !== 'string') { - shape.push(firstElem.length); - firstElem = firstElem[0]; - } - if (Array.isArray(val) && - env().getBool('TENSORLIKE_CHECK_SHAPE_CONSISTENCY')) { - deepAssertShapeConsistency(val, shape, []); - } - - return shape; -} - -function deepAssertShapeConsistency( - val: TensorLike, shape: number[], indices: number[]) { - indices = indices || []; - if (!(Array.isArray(val)) && !isTypedArray(val)) { - assert( - shape.length === 0, - () => `Element arr[${indices.join('][')}] is a primitive, ` + - `but should be an array/TypedArray of ${shape[0]} elements`); - return; - } - assert( - shape.length > 0, - () => `Element arr[${indices.join('][')}] should be a primitive, ` + - `but is an array of ${val.length} elements`); - assert( - val.length === shape[0], - () => `Element arr[${indices.join('][')}] should have ${shape[0]} ` + - `elements, but has ${val.length} elements`); - const subShape = shape.slice(1); - for (let i = 0; i < val.length; ++i) { - deepAssertShapeConsistency(val[i], subShape, indices.concat(i)); - } -} - -function assertDtype( - expectedDtype: DataType|'numeric'|'string_or_numeric', - actualDType: DataType, argName: string, functionName: string) { - if (expectedDtype === 'string_or_numeric') { - return; - } - if (expectedDtype == null) { - throw new Error(`Expected dtype cannot be null.`); - } - if (expectedDtype !== 'numeric' && expectedDtype !== actualDType || - expectedDtype === 'numeric' && actualDType === 'string') { - throw new Error( - `Argument '${argName}' passed to '${functionName}' must ` + - `be ${expectedDtype} tensor, but got ${actualDType} tensor`); - } -} - -export function convertToTensor( - x: T|TensorLike, argName: string, functionName: string, - parseAsDtype: DataType|'numeric'|'string_or_numeric' = 'numeric'): T { - if (x instanceof getGlobalTensorClass()) { - assertDtype(parseAsDtype, x.dtype, argName, functionName); - return x; - } - let inferredDtype = inferDtype(x); - // If the user expects a bool/int/float, use that info to update the - // inferredDtype when it is not a string. - if (inferredDtype !== 'string' && - ['bool', 'int32', 'float32'].indexOf(parseAsDtype) >= 0) { - inferredDtype = parseAsDtype as DataType; - } - assertDtype(parseAsDtype, inferredDtype, argName, functionName); - - if ((x == null) || - (!isTypedArray(x) && !Array.isArray(x) && typeof x !== 'number' && - typeof x !== 'boolean' && typeof x !== 'string')) { - const type = x == null ? 'null' : (x as {}).constructor.name; - throw new Error( - `Argument '${argName}' passed to '${functionName}' must be a ` + - `Tensor or TensorLike, but got '${type}'`); - } - const inferredShape = inferShape(x, inferredDtype); - if (!isTypedArray(x) && !Array.isArray(x)) { - x = [x] as number[]; - } - const skipTypedArray = true; - const values = inferredDtype !== 'string' ? - toTypedArray(x, inferredDtype as DataType) : - flatten(x as string[], [], skipTypedArray) as string[]; - return ENGINE.makeTensor(values, inferredShape, inferredDtype) as T; -} - -export function convertToTensorArray( - arg: Array, argName: string, functionName: string, - parseAsDtype: DataType|'numeric'|'string_or_numeric' = 'numeric'): T[] { - if (!Array.isArray(arg)) { - throw new Error( - `Argument ${argName} passed to ${functionName} must be a ` + - '`Tensor[]` or `TensorLike[]`'); - } - const tensors = arg as T[]; - return tensors.map( - (t, i) => - convertToTensor(t, `${argName}[${i}]`, functionName, parseAsDtype)); -} diff --git a/tfjs-master/tfjs-core/src/tensor_util_test.ts b/tfjs-master/tfjs-core/src/tensor_util_test.ts deleted file mode 100644 index ae9043f50..000000000 --- a/tfjs-master/tfjs-core/src/tensor_util_test.ts +++ /dev/null @@ -1,230 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from './index'; -import {ALL_ENVS, describeWithFlags} from './jasmine_util'; -import {Tensor} from './tensor'; -import {getTensorsInContainer, isTensorInList} from './tensor_util'; -import {convertToTensor} from './tensor_util_env'; -import {expectArraysClose, expectArraysEqual} from './test_util'; - -describeWithFlags('tensor_util.isTensorInList', ALL_ENVS, () => { - it('not in list', () => { - const a = tf.scalar(1); - const list: Tensor[] = [tf.scalar(1), tf.tensor1d([1, 2, 3])]; - - expect(isTensorInList(a, list)).toBe(false); - }); - - it('in list', () => { - const a = tf.scalar(1); - const list: Tensor[] = [tf.scalar(2), tf.tensor1d([1, 2, 3]), a]; - - expect(isTensorInList(a, list)).toBe(true); - }); -}); - -describeWithFlags('getTensorsInContainer', ALL_ENVS, () => { - it('null input returns empty tensor', () => { - const results = getTensorsInContainer(null); - - expect(results).toEqual([]); - }); - - it('tensor input returns one element tensor', () => { - const x = tf.scalar(1); - const results = getTensorsInContainer(x); - - expect(results).toEqual([x]); - }); - - it('name tensor map returns flattened tensor', () => { - const x1 = tf.scalar(1); - const x2 = tf.scalar(3); - const x3 = tf.scalar(4); - const results = getTensorsInContainer({x1, x2, x3}); - - expect(results).toEqual([x1, x2, x3]); - }); - - it('can extract from arbitrary depth', () => { - const container = [ - {x: tf.scalar(1), y: tf.scalar(2)}, [[[tf.scalar(3)]], {z: tf.scalar(4)}] - ]; - const results = getTensorsInContainer(container); - expect(results.length).toBe(4); - }); - - it('works with loops in container', () => { - const container = [tf.scalar(1), tf.scalar(2), [tf.scalar(3)]]; - const innerContainer = [container]; - // tslint:disable-next-line:no-any - container.push(innerContainer as any); - const results = getTensorsInContainer(container); - expect(results.length).toBe(3); - }); -}); - -describeWithFlags('convertToTensor', ALL_ENVS, () => { - it('primitive integer, NaN converts to zero, no error thrown', async () => { - const a = () => convertToTensor(NaN, 'a', 'test', 'int32'); - expect(a).not.toThrowError(); - - const b = convertToTensor(NaN, 'b', 'test', 'int32'); - expect(b.rank).toBe(0); - expect(b.dtype).toBe('int32'); - expectArraysClose(await b.data(), 0); - }); - - it('primitive number', async () => { - const a = convertToTensor(3, 'a', 'test'); - expect(a.rank).toBe(0); - expect(a.dtype).toBe('float32'); - expectArraysClose(await a.data(), 3); - }); - - it('primitive integer, NaN converts to zero', async () => { - const a = convertToTensor(NaN, 'a', 'test', 'int32'); - expect(a.rank).toBe(0); - expect(a.dtype).toBe('int32'); - expectArraysClose(await a.data(), 0); - }); - - it('primitive boolean, parsed as bool tensor', async () => { - const a = convertToTensor(true, 'a', 'test'); - expect(a.rank).toBe(0); - expect(a.dtype).toBe('bool'); - expectArraysClose(await a.data(), 1); - }); - - it('primitive boolean, forced to be parsed as bool tensor', async () => { - const a = convertToTensor(true, 'a', 'test', 'bool'); - expect(a.rank).toBe(0); - expect(a.dtype).toBe('bool'); - expectArraysEqual(await a.data(), 1); - }); - - it('array1d', async () => { - const a = convertToTensor([1, 2, 3], 'a', 'test'); - expect(a.rank).toBe(1); - expect(a.dtype).toBe('float32'); - expect(a.shape).toEqual([3]); - expectArraysClose(await a.data(), [1, 2, 3]); - }); - - it('array2d', async () => { - const a = convertToTensor([[1], [2], [3]], 'a', 'test'); - expect(a.rank).toBe(2); - expect(a.shape).toEqual([3, 1]); - expect(a.dtype).toBe('float32'); - expectArraysClose(await a.data(), [1, 2, 3]); - }); - - it('array3d', async () => { - const a = convertToTensor([[[1], [2]], [[3], [4]]], 'a', 'test'); - expect(a.rank).toBe(3); - expect(a.shape).toEqual([2, 2, 1]); - expect(a.dtype).toBe('float32'); - expectArraysClose(await a.data(), [1, 2, 3, 4]); - }); - - it('array4d', async () => { - const a = convertToTensor([[[[1]], [[2]]], [[[3]], [[4]]]], 'a', 'test'); - expect(a.rank).toBe(4); - expect(a.shape).toEqual([2, 2, 1, 1]); - expect(a.dtype).toBe('float32'); - expectArraysClose(await a.data(), [1, 2, 3, 4]); - }); - - it('passing a tensor returns the tensor itself', () => { - const s = tf.scalar(3); - const res = convertToTensor(s, 'a', 'test'); - expect(res === s).toBe(true); - }); - - it('passing a tensor with wrong type errors', () => { - const s = tf.scalar(3); - expect(() => convertToTensor(s, 'p', 'f', 'bool')) - .toThrowError( - /Argument 'p' passed to 'f' must be bool tensor, but got float32/); - }); - - it('fails when passed a string and force numeric is true', () => { - const expectedDtype = 'numeric'; - expect(() => convertToTensor('hello', 'p', 'test', expectedDtype)) - .toThrowError(); - }); - - it('force numeric is true by default', () => { - // Should fail to parse a string tensor since force numeric is true. - expect(() => convertToTensor('hello', 'p', 'test')).toThrowError(); - }); - - it('primitive string, do not force numeric', () => { - const t = convertToTensor('hello', 'p', 'test', 'string_or_numeric'); - expect(t.dtype).toBe('string'); - expect(t.shape).toEqual([]); - }); - - it('string[], do not force numeric', () => { - const t = - convertToTensor(['a', 'b', 'c'], 'p', 'test', 'string_or_numeric'); - expect(t.dtype).toBe('string'); - expect(t.shape).toEqual([3]); - }); - - it('string, explicitly parse as bool', () => { - expect(() => convertToTensor('a', 'argName', 'func', 'bool')) - .toThrowError( - 'Argument \'argName\' passed to \'func\' must be bool tensor' + - ', but got string tensor'); - }); - - it('string, throw error if pass null.', () => { - expect(() => convertToTensor('a', 'argName', 'func', null)) - .toThrowError('Expected dtype cannot be null.'); - }); - - it('fails to convert a dict to tensor', () => { - expect(() => convertToTensor({} as number, 'a', 'test')) - .toThrowError( - 'Argument \'a\' passed to \'test\' must be a Tensor ' + - 'or TensorLike, but got \'Object\''); - }); - - it('fails to convert a string to tensor', () => { - expect(() => convertToTensor('asdf', 'a', 'test')) - .toThrowError( - 'Argument \'a\' passed to \'test\' must be numeric tensor, ' + - 'but got string tensor'); - }); -}); - -describeWithFlags('convertToTensor debug mode', ALL_ENVS, () => { - beforeAll(() => { - // Silence debug warnings. - spyOn(console, 'warn'); - tf.enableDebugMode(); - }); - - it('fails to convert a non-valid shape array to tensor', () => { - const a = [[1, 2], [3], [4, 5, 6]]; // 2nd element has only 1 entry. - expect(() => convertToTensor(a, 'a', 'test')) - .toThrowError( - 'Element arr[1] should have 2 elements, but has 1 elements'); - }); -}); diff --git a/tfjs-master/tfjs-core/src/test_async_backends.ts b/tfjs-master/tfjs-core/src/test_async_backends.ts deleted file mode 100644 index 02111e6e2..000000000 --- a/tfjs-master/tfjs-core/src/test_async_backends.ts +++ /dev/null @@ -1,93 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ -/** - * This file tests that we don't have any dataSyncs in the unconstrainted tests - * so that we can run backends that have async init and async data reads against - * our exported test files. - */ - -// Use require here to workaround this being a circular dependency. -// This should only be done in tests. -// tslint:disable-next-line: no-require-imports -require('@tensorflow/tfjs-backend-cpu'); -import './index'; -import './public/chained_ops/register_all_chained_ops'; -import './register_all_gradients'; -import {setTestEnvs} from './jasmine_util'; -import {registerBackend, engine} from './globals'; -import {KernelBackend} from './backends/backend'; -import {getKernelsForBackend, registerKernel} from './kernel_registry'; - -// tslint:disable-next-line:no-require-imports -const jasmine = require('jasmine'); - -process.on('unhandledRejection', e => { - throw e; -}); - -class AsyncCPUBackend extends KernelBackend {} -const asyncBackend = new AsyncCPUBackend(); - -// backend is cast as any so that we can access methods through bracket -// notation. -const backend: KernelBackend = engine().findBackend('cpu'); -const proxyBackend = new Proxy(asyncBackend, { - get(target, name, receiver) { - if (name === 'readSync') { - throw new Error( - `Found dataSync() in a unit test. This is disabled so unit tests ` + - `can run in backends that only support async data. Please use ` + - `.data() in unit tests or if you truly are testing dataSync(), ` + - `constrain your test with SYNC_BACKEND_ENVS`); - } - //@ts-ignore; - const origSymbol = backend[name]; - if (typeof origSymbol === 'function') { - // tslint:disable-next-line:no-any - return (...args: any[]) => { - return origSymbol.apply(backend, args); - }; - } else { - return origSymbol; - } - } -}); - -const proxyBackendName = 'test-async-cpu'; - -// The registration is async on purpose, so we know our testing infra works -// with backends that have async init (e.g. WASM and WebGPU). -registerBackend(proxyBackendName, async () => proxyBackend); - -// All the kernels are registered under the 'cpu' name, so we need to -// register them also under the proxy backend name. -const kernels = getKernelsForBackend('cpu'); -kernels.forEach(({kernelName, kernelFunc, setupFunc}) => { - registerKernel( - {kernelName, backendName: proxyBackendName, kernelFunc, setupFunc}); -}); - -setTestEnvs([{ - name: proxyBackendName, - backendName: proxyBackendName, - isDataSync: false, -}]); - -const runner = new jasmine(); - -runner.loadConfig({spec_files: ['tfjs-core/src/**/**_test.js'], random: false}); -runner.execute(); diff --git a/tfjs-master/tfjs-core/src/test_node.ts b/tfjs-master/tfjs-core/src/test_node.ts deleted file mode 100644 index 63c1a6785..000000000 --- a/tfjs-master/tfjs-core/src/test_node.ts +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/env node -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {setTestEnvs} from './jasmine_util'; - -// tslint:disable-next-line:no-require-imports -const jasmine = require('jasmine'); - -process.on('unhandledRejection', e => { - throw e; -}); - -setTestEnvs([{name: 'node', backendName: 'cpu'}]); - -const runner = new jasmine(); -runner.loadConfig({spec_files: ['tfjs-core/src/setup_test.js'], random: false}); -runner.execute(); diff --git a/tfjs-master/tfjs-core/src/test_util.ts b/tfjs-master/tfjs-core/src/test_util.ts deleted file mode 100644 index 3e82c6307..000000000 --- a/tfjs-master/tfjs-core/src/test_util.ts +++ /dev/null @@ -1,224 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ENGINE} from './engine'; -import {inferShape} from './tensor_util_env'; -import {RecursiveArray, TensorLike, TypedArray} from './types'; -import {arraysEqual, encodeString, flatten, isString, isTypedArray} from './util'; - -const TEST_EPSILON_FLOAT32 = 1e-3; -export const TEST_EPSILON_FLOAT16 = 1e-1; - -export function expectArraysClose( - actual: TypedArray|number|RecursiveArray, - expected: TypedArray|number|RecursiveArray, epsilon?: number) { - if (epsilon == null) { - epsilon = testEpsilon(); - } - return expectArraysPredicate( - actual, expected, (a, b) => areClose(a as number, b as number, epsilon)); -} - -export function testEpsilon() { - return ENGINE.backend.floatPrecision() === 32 ? TEST_EPSILON_FLOAT32 : - TEST_EPSILON_FLOAT16; -} - -function expectArraysPredicate( - actual: TensorLike, expected: TensorLike, - predicate: (a: {}, b: {}) => boolean) { - let checkClassType = true; - if (isTypedArray(actual) || isTypedArray(expected)) { - checkClassType = false; - } - if (isTypedArray(actual) && isTypedArray(expected)) { - checkClassType = true; - } - if (checkClassType) { - const aType = actual.constructor.name; - const bType = expected.constructor.name; - - if (aType !== bType) { - throw new Error( - `Arrays are of different type. Actual: ${aType}. ` + - `Expected: ${bType}`); - } - } - - if (Array.isArray(actual) && Array.isArray(expected)) { - const actualShape = inferShape(actual); - const expectedShape = inferShape(expected); - if (!arraysEqual(actualShape, expectedShape)) { - throw new Error( - `Arrays have different shapes. ` + - `Actual: [${actualShape}]. Expected: [${expectedShape}]`); - } - } - - const actualFlat = - isTypedArray(actual) ? actual : flatten(actual as RecursiveArray); - const expectedFlat = isTypedArray(expected) ? - expected : - flatten(expected as RecursiveArray); - - if (actualFlat.length !== expectedFlat.length) { - throw new Error( - `Arrays have different lengths actual: ${actualFlat.length} vs ` + - `expected: ${expectedFlat.length}.\n` + - `Actual: ${actualFlat}.\n` + - `Expected: ${expectedFlat}.`); - } - for (let i = 0; i < expectedFlat.length; ++i) { - const a = actualFlat[i]; - const e = expectedFlat[i]; - - if (!predicate(a, e)) { - throw new Error( - `Arrays differ: actual[${i}] = ${a}, expected[${i}] = ${e}.\n` + - `Actual: ${actualFlat}.\n` + - `Expected: ${expectedFlat}.`); - } - } - if (typeof expect !== 'undefined') { - expect().nothing(); - } -} - -export interface DoneFn { - (): void; - fail: (message?: Error|string) => void; -} - -export function expectPromiseToFail(fn: () => Promise<{}>, done: DoneFn): void { - fn().then(() => done.fail(), () => done()); - if (typeof expect !== 'undefined') { - expect().nothing(); - } -} - -export function expectArraysEqual(actual: TensorLike, expected: TensorLike) { - const exp = typeof expected === 'string' || typeof expected === 'number' || - typeof expected === 'boolean' ? - [expected] as number[] : - expected as number[]; - if (isString(actual) || isString((actual as string[])[0]) || - isString(expected) || isString((expected as string[])[0])) { - // tslint:disable-next-line: triple-equals - return expectArraysPredicate(actual, exp, (a, b) => a == b); - } - return expectArraysPredicate( - actual, expected, (a, b) => areClose(a as number, b as number, 0)); -} - -export function expectNumbersClose(a: number, e: number, epsilon?: number) { - if (epsilon == null) { - epsilon = testEpsilon(); - } - if (!areClose(a, e, epsilon)) { - throw new Error(`Numbers differ: actual === ${a}, expected === ${e}`); - } - if (typeof expect !== 'undefined') { - expect().nothing(); - } -} - -function areClose(a: number, e: number, epsilon: number): boolean { - if (!isFinite(a) && !isFinite(e)) { - return true; - } - if (isNaN(a) || isNaN(e) || Math.abs(a - e) > epsilon) { - return false; - } - return true; -} - -export function expectValuesInRange( - actual: TypedArray|number[], low: number, high: number) { - for (let i = 0; i < actual.length; i++) { - if (actual[i] < low || actual[i] > high) { - throw new Error( - `Value out of range:${actual[i]} low: ${low}, high: ${high}`); - } - } -} - -export function expectArrayBuffersEqual( - actual: ArrayBuffer, expected: ArrayBuffer) { - // Safari does not like comparing ArrayBuffers directly. Wrapping in - // a Float32Array solves this issue. - const actualArray = new Float32Array(actual); - const expectedArray = new Float32Array(expected); - if (actualArray.length !== expectedArray.length) { - throw new Error( - 'Expected ArrayBuffer to be of length ' + - `${expectedArray.length}, but it was ${actualArray.length}`); - } - - for (let i = 0; i < expectedArray.length; i++) { - if (actualArray[i] !== expectedArray[i]) { - throw new Error( - `Expected ArrayBuffer value at ${i} to be ` + - `${expectedArray[i]} but got ${actualArray[i]} instead`); - } - } -} - -/** Encodes strings into utf-8 bytes. */ -export function encodeStrings(a: RecursiveArray<{}>): - RecursiveArray { - for (let i = 0; i < (a as Array<{}>).length; i++) { - const val = a[i]; - if (Array.isArray(val)) { - encodeStrings(val); - } else { - a[i] = encodeString(val as string); - } - } - return a as RecursiveArray; -} - -/** Creates an HTMLVideoElement with autoplay-friendly default settings. */ -export function createVideoElement(source: HTMLSourceElement): - Promise { - const video = document.createElement('video'); - if ('playsInline' in video) { - // tslint:disable-next-line:no-any - (video as any).playsInline = true; - } - video.muted = true; - video.loop = true; - video.style.position = 'fixed'; - video.style.left = '0px'; - video.style.top = '0px'; - - video.preload = 'auto'; - video.appendChild(source); - return new Promise(resolve => { - video.addEventListener('loadeddata', _ => resolve(video)); - video.load(); - }); -} - -export async function play(video: HTMLVideoElement) { - await video.play(); - if ('requestVideoFrameCallback' in video) { - await new Promise(resolve => { - // tslint:disable-next-line:no-any - (video as any).requestVideoFrameCallback(resolve); - }); - } -} diff --git a/tfjs-master/tfjs-core/src/test_util_test.ts b/tfjs-master/tfjs-core/src/test_util_test.ts deleted file mode 100644 index 20559be81..000000000 --- a/tfjs-master/tfjs-core/src/test_util_test.ts +++ /dev/null @@ -1,148 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {ALL_ENVS, describeWithFlags} from './jasmine_util'; -import {expectArraysClose, expectArraysEqual} from './test_util'; - -describeWithFlags('expectArraysEqual', ALL_ENVS, () => { - it('same arrays', () => { - expectArraysEqual([1, 2, 3], [1, 2, 3]); - }); - - it('throws on different arrays', () => { - expect(() => expectArraysEqual([1, 2, 3], [3, 2, 1])) - .toThrowError(/Arrays differ/); - }); - - it('same nested arrays', () => { - expectArraysEqual([[1, 2], [3, 4]], [[1, 2], [3, 4]]); - }); - - it('throws on different nested arrays', () => { - expect(() => expectArraysEqual([[1, 2], [3, 4]], [[1, 2], [4, 3]])) - .toThrowError(/Arrays differ/); - }); - - it('throws on different nested shapes', () => { - expect(() => expectArraysEqual([[1, 2], [3, 4]], [1, 2, 3, 4])) - .toThrowError( - /Arrays have different shapes. Actual: \[2,2\]. Expected: \[4\]/); - }); - - it('float32 with regular array', () => { - expectArraysEqual(new Float32Array([1, 2, 3]), [1, 2, 3]); - }); - - it('throws on different values of float32 with regular array', () => { - expect(() => expectArraysEqual(new Float32Array([1, 2, 3]), [1, 2, 4])) - .toThrowError(/Arrays differ/); - }); - - it('int32 with regular array', () => { - expectArraysEqual(new Int32Array([1, 2, 3]), [1, 2, 3]); - }); - - it('throws on different values of int32 with regular array', () => { - expect(() => expectArraysEqual(new Int32Array([1, 2, 3]), [1, 2, 4])) - .toThrowError(/Arrays differ/); - }); - - it('throws on float32 with int32', () => { - expect( - () => expectArraysEqual( - new Float32Array([1, 2, 3]), new Int32Array([1, 2, 3]))) - .toThrowError(/Arrays are of different type/); - }); - - it('throws on int32 with uint8', () => { - expect( - () => expectArraysEqual( - new Int32Array([1, 2, 3]), new Uint8Array([1, 2, 3]))) - .toThrowError(/Arrays are of different type/); - }); -}); - -describeWithFlags('expectArraysClose', ALL_ENVS, () => { - it('same arrays', () => { - expectArraysClose([1, 2, 3], [1, 2, 3]); - }); - - it('throws on different arrays', () => { - expect(() => expectArraysClose([1, 2, 3], [3, 2, 1])) - .toThrowError(/Arrays differ/); - }); - - it('same nested arrays', () => { - expectArraysClose([[1, 2], [3, 4]], [[1, 2], [3, 4]]); - }); - - it('throws on different nested arrays', () => { - expect(() => expectArraysClose([[1, 2], [3, 4]], [[1, 2], [4, 3]])) - .toThrowError(/Arrays differ/); - }); - - it('throws on different nested shapes', () => { - expect(() => expectArraysClose([[1, 2], [3, 4]], [1, 2, 3, 4])) - .toThrowError( - /Arrays have different shapes. Actual: \[2,2\]. Expected: \[4\]/); - }); - - it('float32 with regular array', () => { - expectArraysClose(new Float32Array([1, 2, 3]), [1, 2, 3]); - }); - - it('throws on different values of float32 with regular array', () => { - expect(() => expectArraysClose(new Float32Array([1, 2, 3]), [1, 2, 4])) - .toThrowError(/Arrays differ/); - }); - - it('int32 with regular array', () => { - expectArraysClose(new Int32Array([1, 2, 3]), [1, 2, 3]); - }); - - it('throws on different values of int32 with regular array', () => { - expect(() => expectArraysClose(new Int32Array([1, 2, 3]), [1, 2, 4])) - .toThrowError(/Arrays differ/); - }); - - it('throws on float32 with int32', () => { - expect( - () => expectArraysClose( - new Float32Array([1, 2, 3]), new Int32Array([1, 2, 3]))) - .toThrowError(/Arrays are of different type/); - }); - - it('throws on int32 with uint8', () => { - expect( - () => expectArraysClose( - new Int32Array([1, 2, 3]), new Uint8Array([1, 2, 3]))) - .toThrowError(/Arrays are of different type/); - }); - - it('similar arrays with good epsilon', () => { - const epsilon = 0.1; - expectArraysClose(new Float32Array([1, 2, 3.08]), [1, 2, 3], epsilon); - }); - - it('similar arrays with bad epsilon', () => { - const epsilon = 0.01; - expect( - () => expectArraysClose( - new Float32Array([1, 2, 3.08]), [1, 2, 3], epsilon)) - .toThrowError(/Arrays differ/); - }); -}); diff --git a/tfjs-master/tfjs-core/src/train.ts b/tfjs-master/tfjs-core/src/train.ts deleted file mode 100644 index b470ae8a7..000000000 --- a/tfjs-master/tfjs-core/src/train.ts +++ /dev/null @@ -1,20 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {OptimizerConstructors} from './optimizers/optimizer_constructors'; - -export const train = OptimizerConstructors; diff --git a/tfjs-master/tfjs-core/src/types.ts b/tfjs-master/tfjs-core/src/types.ts deleted file mode 100644 index 994e447ba..000000000 --- a/tfjs-master/tfjs-core/src/types.ts +++ /dev/null @@ -1,246 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -/** @docalias number[] */ -export interface ShapeMap { - R0: number[]; - R1: [number]; - R2: [number, number]; - R3: [number, number, number]; - R4: [number, number, number, number]; - R5: [number, number, number, number, number]; - R6: [number, number, number, number, number, number]; -} - -/** @docalias number[] */ -export interface ArrayMap { - R0: number; - R1: number[]; - R2: number[][]; - R3: number[][][]; - R4: number[][][][]; - R5: number[][][][][]; - R6: number[][][][][][]; -} - -export interface DataTypeMap { - float32: Float32Array; - int32: Int32Array; - bool: Uint8Array; - complex64: Float32Array; - string: string[]; -} - -export interface SingleValueMap { - bool: boolean; - int32: number; - float32: number; - complex64: number; - string: string; -} - -/** @docalias 'float32'|'int32'|'bool'|'complex64'|'string' */ -export type DataType = keyof DataTypeMap; -export type NumericDataType = 'float32'|'int32'|'bool'|'complex64'; - -export type DataTypeFor = - T extends number|boolean ? NumericDataType : T extends string ? 'string' : - never; - -export type TypedArray = Float32Array|Int32Array|Uint8Array; -/** Tensor data used in tensor creation and user-facing API. */ -export type DataValues = DataTypeMap[DataType]; -/** The underlying tensor data that gets stored in a backend. */ -export type BackendValues = Float32Array|Int32Array|Uint8Array|Uint8Array[]; - -export enum Rank { - R0 = 'R0', - R1 = 'R1', - R2 = 'R2', - R3 = 'R3', - R4 = 'R4', - R5 = 'R5', - R6 = 'R6' -} - -export type FlatVector = boolean[]|number[]|TypedArray; -export type RegularArray = - T[]|T[][]|T[][][]|T[][][][]|T[][][][][]|T[][][][][][]; - -// tslint:disable-next-line:no-any -export interface RecursiveArray { - [index: number]: T|RecursiveArray; -} - -// Looks for upcasting types. Used, for example, in operations with mixed dtype -// inputs. -enum UpcastInt32AndMap { - 'float32' = 'float32', - 'int32' = 'int32', - 'bool' = 'int32', - 'complex64' = 'complex64' -} - -enum UpcastBoolAndMap { - 'float32' = 'float32', - 'int32' = 'int32', - 'bool' = 'bool', - 'complex64' = 'complex64' -} - -enum UpcastFloat32AndMap { - 'float32' = 'float32', - 'int32' = 'float32', - 'bool' = 'float32', - 'complex64' = 'complex64' -} - -enum UpcastComplex64AndMap { - 'float32' = 'complex64', - 'int32' = 'complex64', - 'bool' = 'complex64', - 'complex64' = 'complex64' -} - -const upcastTypeMap = { - 'float32': UpcastFloat32AndMap, - 'int32': UpcastInt32AndMap, - 'bool': UpcastBoolAndMap, - 'complex64': UpcastComplex64AndMap -}; - -export function upcastType(typeA: DataType, typeB: DataType): DataType { - if (typeA === 'string' || typeB === 'string') { - if (typeA === 'string' && typeB === 'string') { - return 'string'; - } - throw new Error(`Can not upcast ${typeA} with ${typeB}`); - } - return upcastTypeMap[typeA][typeB]; -} - -/** Returns the output type after summation. */ -export function sumOutType(type: DataType): DataType { - return upcastType(type, 'int32'); -} - -/** @docalias TypedArray|Array */ -export type TensorLike = - TypedArray|number|boolean|string|RecursiveArray| - RecursiveArray|RecursiveArray|Uint8Array[]; -export type ScalarLike = number|boolean|string|Uint8Array; -/** @docalias TypedArray|Array */ -export type TensorLike1D = TypedArray|number[]|boolean[]|string[]|Uint8Array[]; -/** @docalias TypedArray|Array */ -export type TensorLike2D = TypedArray|number[]|number[][]|boolean[]|boolean[][]| - string[]|string[][]|Uint8Array[]|Uint8Array[][]; -/** @docalias TypedArray|Array */ -export type TensorLike3D = TypedArray|number[]|number[][][]|boolean[]| - boolean[][][]|string[]|string[][][]|Uint8Array[]|Uint8Array[][][]; -/** @docalias TypedArray|Array */ -export type TensorLike4D = TypedArray|number[]|number[][][][]|boolean[]| - boolean[][][][]|string[]|string[][][][]|Uint8Array[]|Uint8Array[][][][]; -/** @docalias TypedArray|Array */ -export type TensorLike5D = - TypedArray|number[]|number[][][][][]|boolean[]|boolean[][][][][]|string[]| - string[][][][][]|Uint8Array[]|Uint8Array[][][][][]; -/** @docalias TypedArray|Array */ -export type TensorLike6D = - TypedArray|number[]|number[][][][][][]|boolean[]|boolean[][][][][][]| - string[]|string[][][][][][]|Uint8Array[]|Uint8Array[][][][][]; - -/** Type for representing image data in Uint8Array type. */ -export interface PixelData { - width: number; - height: number; - data: Uint8Array; -} - -/** - * Type for representing all permutations and combinations of 'RGBA' channels. - */ -export type WebGLChannels = 'A'|'B'|'G'|'R'|'AB'|'AG'|'AR'|'BA'|'BG'|'BR'|'GA'| - 'GB'|'GR'|'RA'|'RB'|'RG'|'ABG'|'ABR'|'AGB'|'AGR'|'ARB'|'ARG'|'BAG'|'BAR'| - 'BGA'|'BGR'|'BRA'|'BRG'|'GAB'|'GAR'|'GBA'|'GBR'|'GRA'|'GRB'|'RAB'|'RAG'| - 'RBA'|'RBG'|'RGA'|'RGB'|'ABGR'|'ABRG'|'AGBR'|'AGRB'|'ARBG'|'ARGB'|'BAGR'| - 'BARG'|'BGAR'|'BGRA'|'BRAG'|'BRGA'|'GABR'|'GARB'|'GBAR'|'GBRA'|'GRAB'| - 'GRBA'|'RABG'|'RAGB'|'RBAG'|'RBGA'|'RGAB'|'RGBA'; - -/** Type for representing a texture data to create a tensor. */ -export interface WebGLData { - texture: WebGLTexture; - height: number; - width: number; - channels: WebGLChannels; -} - -/** - * Type for representing a buffer data to create a tensor. Buffer usage should - * at least support GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_SRC. When - * zeroCopy is false or undefined (default), this GPUBuffer will be copied to - * the tensor's resource buffer. When zeroCopy is true, tensor will use this - * GPUBuffer as tensor's resource buffer, user should not destroy this GPUBuffer - * until all access is done. If not specified at creating a tensor, tensor type - * is float32. - */ -export interface WebGPUData { - buffer: GPUBuffer; - zeroCopy?: boolean; -} - -export function isWebGLData(values: unknown): values is WebGLData { - return values != null && typeof values === 'object' && 'texture' in values && - values.texture instanceof WebGLTexture; -} -export function isWebGPUData(values: unknown): values is WebGPUData { - return typeof GPUBuffer !== 'undefined' && values != null && - typeof values === 'object' && 'buffer' in values && - values.buffer instanceof GPUBuffer; -} - -export interface ImageOptions { - /** - * Optional. A number in range [0-1]. If the image is a 2D tensor or a 3D - * tensor with 1 or 3 channels, the alpha channels would set as its value; - * otherwise, it would not make effects. - */ - alpha?: number; -} - -export interface ContextOptions { - /** - * Optional. If the canvas has created a context, it would not make effects. - * If it is not set, it would be variable based on the current backend. - */ - contextType?: string; - /** - * Optional. A WebGLContextAttributes configuration. If the canvas has created - * a context, it would not make effects. - */ - contextAttributes?: WebGLContextAttributes; -} - -export interface DrawOptions { - /** - * Optional. An object of options to customize the values of image tensor. - */ - imageOptions?: ImageOptions; - /** - * Optional. An object to configure the context of the canvas to draw to. - */ - contextOptions?: ContextOptions; -} diff --git a/tfjs-master/tfjs-core/src/types_test.ts b/tfjs-master/tfjs-core/src/types_test.ts deleted file mode 100644 index ad9c89683..000000000 --- a/tfjs-master/tfjs-core/src/types_test.ts +++ /dev/null @@ -1,51 +0,0 @@ -/** - * @license - * Copyright 2018 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {upcastType} from './types'; - -describe('upcastType', () => { - it('upcasts bool to bool', () => { - expect(upcastType('bool', 'bool')).toBe('bool'); - }); - - it('upcasts bool/int32 to int32', () => { - expect(upcastType('bool', 'int32')).toBe('int32'); - expect(upcastType('int32', 'int32')).toBe('int32'); - }); - - it('upcasts bool/int32/float32 to float32', () => { - expect(upcastType('bool', 'float32')).toBe('float32'); - expect(upcastType('int32', 'float32')).toBe('float32'); - expect(upcastType('float32', 'float32')).toBe('float32'); - }); - - it('upcasts bool/int32/float32/complex64 to complex64', () => { - expect(upcastType('bool', 'complex64')).toBe('complex64'); - expect(upcastType('int32', 'complex64')).toBe('complex64'); - expect(upcastType('float32', 'complex64')).toBe('complex64'); - expect(upcastType('complex64', 'complex64')).toBe('complex64'); - }); - - it('fails to upcast anything other than string with string', () => { - expect(() => upcastType('bool', 'string')).toThrowError(); - expect(() => upcastType('int32', 'string')).toThrowError(); - expect(() => upcastType('float32', 'string')).toThrowError(); - expect(() => upcastType('complex64', 'string')).toThrowError(); - // Ok upcasting string to string. - expect(upcastType('string', 'string')).toBe('string'); - }); -}); diff --git a/tfjs-master/tfjs-core/src/util.ts b/tfjs-master/tfjs-core/src/util.ts deleted file mode 100644 index 644a81196..000000000 --- a/tfjs-master/tfjs-core/src/util.ts +++ /dev/null @@ -1,193 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {env} from './environment'; -import {isTypedArrayBrowser} from './platforms/is_typed_array_browser'; -import {BackendValues, DataType, RecursiveArray, TensorLike, TypedArray} from './types'; -import * as base from './util_base'; -export * from './util_base'; -export * from './hash_util'; - -/** - * Create typed array for scalar value. Used for storing in `DataStorage`. - */ -export function createScalarValue( - value: DataType, dtype: DataType): BackendValues { - if (dtype === 'string') { - return encodeString(value); - } - - return toTypedArray([value], dtype); -} - -function noConversionNeeded(a: TensorLike, dtype: DataType): boolean { - return (a instanceof Float32Array && dtype === 'float32') || - (a instanceof Int32Array && dtype === 'int32') || - (a instanceof Uint8Array && dtype === 'bool'); -} - -export function toTypedArray(a: TensorLike, dtype: DataType): TypedArray { - if (dtype === 'string') { - throw new Error('Cannot convert a string[] to a TypedArray'); - } - if (Array.isArray(a)) { - a = flatten(a); - } - - if (env().getBool('DEBUG')) { - base.checkConversionForErrors(a as number[], dtype); - } - if (noConversionNeeded(a, dtype)) { - return a as TypedArray; - } - if (dtype == null || dtype === 'float32' || dtype === 'complex64') { - return new Float32Array(a as number[]); - } else if (dtype === 'int32') { - return new Int32Array(a as number[]); - } else if (dtype === 'bool') { - const bool = new Uint8Array((a as number[]).length); - for (let i = 0; i < bool.length; ++i) { - if (Math.round((a as number[])[i]) !== 0) { - bool[i] = 1; - } - } - return bool; - } else { - throw new Error(`Unknown data type ${dtype}`); - } -} - -/** - * Returns the current high-resolution time in milliseconds relative to an - * arbitrary time in the past. It works across different platforms (node.js, - * browsers). - * - * ```js - * console.log(tf.util.now()); - * ``` - * - * @doc {heading: 'Util', namespace: 'util'} - */ -export function now(): number { - return env().platform.now(); -} - -/** - * Returns a platform-specific implementation of - * [`fetch`](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API). - * - * If `fetch` is defined on the global object (`window`, `process`, etc.), - * `tf.util.fetch` returns that function. - * - * If not, `tf.util.fetch` returns a platform-specific solution. - * - * ```js - * const resource = await tf.util.fetch('https://cdn.jsdelivr.net/npm/@tensorflow/tfjs'); - * // handle response - * ``` - * - * @doc {heading: 'Util'} - */ -export function fetch( - path: string, requestInits?: RequestInit): Promise { - return env().platform.fetch(path, requestInits); -} - -/** - * Encodes the provided string into bytes using the provided encoding scheme. - * - * @param s The string to encode. - * @param encoding The encoding scheme. Defaults to utf-8. - * - * @doc {heading: 'Util'} - */ -export function encodeString(s: string, encoding = 'utf-8'): Uint8Array { - encoding = encoding || 'utf-8'; - return env().platform.encode(s, encoding); -} - -/** - * Decodes the provided bytes into a string using the provided encoding scheme. - * @param bytes The bytes to decode. - * - * @param encoding The encoding scheme. Defaults to utf-8. - * - * @doc {heading: 'Util'} - */ -export function decodeString(bytes: Uint8Array, encoding = 'utf-8'): string { - encoding = encoding || 'utf-8'; - return env().platform.decode(bytes, encoding); -} - -export function isTypedArray(a: {}): a is Float32Array|Int32Array|Uint8Array| - Uint8ClampedArray { - // TODO(mattsoulanille): Remove this fallback in 5.0.0 - if (env().platform.isTypedArray != null) { - return env().platform.isTypedArray(a); - } else { - return isTypedArrayBrowser(a); - } -} - -// NOTE: We explicitly type out what T extends instead of any so that -// util.flatten on a nested array of number doesn't try to infer T as a -// number[][], causing us to explicitly type util.flatten(). -/** - * Flattens an arbitrarily nested array. - * - * ```js - * const a = [[1, 2], [3, 4], [5, [6, [7]]]]; - * const flat = tf.util.flatten(a); - * console.log(flat); - * ``` - * - * @param arr The nested array to flatten. - * @param result The destination array which holds the elements. - * @param skipTypedArray If true, avoids flattening the typed arrays. Defaults - * to false. - * - * @doc {heading: 'Util', namespace: 'util'} - */ -export function -flatten|TypedArray>( - arr: T|RecursiveArray, result: T[] = [], skipTypedArray = false): T[] { - if (result == null) { - result = []; - } - if (typeof arr === 'boolean' || typeof arr === 'number' || - typeof arr === 'string' || base.isPromise(arr) || arr == null || - isTypedArray(arr) && skipTypedArray) { - result.push(arr as T); - } else if (Array.isArray(arr) || isTypedArray(arr)) { - for (let i = 0; i < arr.length; ++i) { - flatten(arr[i], result, skipTypedArray); - } - } else { - let maxIndex = -1; - for (const key of Object.keys(arr)) { - // 0 or positive integer. - if (/^([1-9]+[0-9]*|0)$/.test(key)) { - maxIndex = Math.max(maxIndex, Number(key)); - } - } - for (let i = 0; i <= maxIndex; i++) { - // tslint:disable-next-line: no-unnecessary-type-assertion - flatten((arr as RecursiveArray)[i], result, skipTypedArray); - } - } - return result; -} diff --git a/tfjs-master/tfjs-core/src/util_base.ts b/tfjs-master/tfjs-core/src/util_base.ts deleted file mode 100644 index cb7498b21..000000000 --- a/tfjs-master/tfjs-core/src/util_base.ts +++ /dev/null @@ -1,747 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import {BackendValues, DataType, DataTypeMap, FlatVector, NumericDataType, TensorLike, TypedArray, WebGLData, WebGPUData} from './types'; - -/** - * Shuffles the array in-place using Fisher-Yates algorithm. - * - * ```js - * const a = [1, 2, 3, 4, 5]; - * tf.util.shuffle(a); - * console.log(a); - * ``` - * - * @param array The array to shuffle in-place. - * - * @doc {heading: 'Util', namespace: 'util'} - */ -// tslint:disable-next-line:no-any -export function shuffle(array: any[]|Uint32Array|Int32Array| - Float32Array): void { - let counter = array.length; - let index = 0; - // While there are elements in the array - while (counter > 0) { - // Pick a random index - index = (Math.random() * counter) | 0; - // Decrease counter by 1 - counter--; - // And swap the last element with it - swap(array, counter, index); - } -} - -/** - * Shuffles two arrays in-place the same way using Fisher-Yates algorithm. - * - * ```js - * const a = [1,2,3,4,5]; - * const b = [11,22,33,44,55]; - * tf.util.shuffleCombo(a, b); - * console.log(a, b); - * ``` - * - * @param array The first array to shuffle in-place. - * @param array2 The second array to shuffle in-place with the same permutation - * as the first array. - * - * @doc {heading: 'Util', namespace: 'util'} - */ -export function shuffleCombo( - // tslint:disable-next-line:no-any - array: any[]|Uint32Array|Int32Array|Float32Array, - // tslint:disable-next-line:no-any - array2: any[]|Uint32Array|Int32Array|Float32Array): void { - if (array.length !== array2.length) { - throw new Error( - `Array sizes must match to be shuffled together ` + - `First array length was ${array.length}` + - `Second array length was ${array2.length}`); - } - let counter = array.length; - let index = 0; - // While there are elements in the array - while (counter > 0) { - // Pick a random index - index = (Math.random() * counter) | 0; - // Decrease counter by 1 - counter--; - // And swap the last element of each array with it - swap(array, counter, index); - swap(array2, counter, index); - } -} - -/** Clamps a value to a specified range. */ -export function clamp(min: number, x: number, max: number): number { - return Math.max(min, Math.min(x, max)); -} - -export function nearestLargerEven(val: number): number { - return val % 2 === 0 ? val : val + 1; -} - -export function swap( - object: {[index: number]: T}, left: number, right: number) { - const temp = object[left]; - object[left] = object[right]; - object[right] = temp; -} - -export function sum(arr: number[]): number { - let sum = 0; - for (let i = 0; i < arr.length; i++) { - sum += arr[i]; - } - return sum; -} - -/** - * Returns a sample from a uniform [a, b) distribution. - * - * @param a The minimum support (inclusive). - * @param b The maximum support (exclusive). - * @return A pseudorandom number on the half-open interval [a,b). - */ -export function randUniform(a: number, b: number) { - const r = Math.random(); - return (b * r) + (1 - r) * a; -} - -/** Returns the squared Euclidean distance between two vectors. */ -export function distSquared(a: FlatVector, b: FlatVector): number { - let result = 0; - for (let i = 0; i < a.length; i++) { - const diff = Number(a[i]) - Number(b[i]); - result += diff * diff; - } - return result; -} - -/** - * Asserts that the expression is true. Otherwise throws an error with the - * provided message. - * - * ```js - * const x = 2; - * tf.util.assert(x === 2, 'x is not 2'); - * ``` - * - * @param expr The expression to assert (as a boolean). - * @param msg A function that returns the message to report when throwing an - * error. We use a function for performance reasons. - * - * @doc {heading: 'Util', namespace: 'util'} - */ -export function assert(expr: boolean, msg: () => string) { - if (!expr) { - throw new Error(typeof msg === 'string' ? msg : msg()); - } -} - -export function assertShapesMatch( - shapeA: number[], shapeB: number[], errorMessagePrefix = ''): void { - assert( - arraysEqual(shapeA, shapeB), - () => errorMessagePrefix + ` Shapes ${shapeA} and ${shapeB} must match`); -} - -export function assertNonNull(a: TensorLike): void { - assert( - a != null, - () => `The input to the tensor constructor must be a non-null value.`); -} - -/** - * Returns the size (number of elements) of the tensor given its shape. - * - * ```js - * const shape = [3, 4, 2]; - * const size = tf.util.sizeFromShape(shape); - * console.log(size); - * ``` - * - * @doc {heading: 'Util', namespace: 'util'} - */ -export function sizeFromShape(shape: number[]): number { - if (shape.length === 0) { - // Scalar. - return 1; - } - let size = shape[0]; - for (let i = 1; i < shape.length; i++) { - size *= shape[i]; - } - return size; -} - -export function isScalarShape(shape: number[]): boolean { - return shape.length === 0; -} - -export function arraysEqualWithNull(n1: number[], n2: number[]) { - if (n1 === n2) { - return true; - } - - if (n1 == null || n2 == null) { - return false; - } - - if (n1.length !== n2.length) { - return false; - } - - for (let i = 0; i < n1.length; i++) { - if (n1[i] !== null && n2[i] !== null && n1[i] !== n2[i]) { - return false; - } - } - return true; -} - -export function arraysEqual(n1: FlatVector, n2: FlatVector) { - if (n1 === n2) { - return true; - } - if (n1 == null || n2 == null) { - return false; - } - - if (n1.length !== n2.length) { - return false; - } - for (let i = 0; i < n1.length; i++) { - if (n1[i] !== n2[i]) { - return false; - } - } - return true; -} - -export function isInt(a: number): boolean { - return a % 1 === 0; -} - -export function tanh(x: number): number { - // tslint:disable-next-line:no-any - if ((Math as any).tanh != null) { - // tslint:disable-next-line:no-any - return (Math as any).tanh(x); - } - if (x === Infinity) { - return 1; - } else if (x === -Infinity) { - return -1; - } else { - const e2x = Math.exp(2 * x); - return (e2x - 1) / (e2x + 1); - } -} - -export function sizeToSquarishShape(size: number): [number, number] { - const width = Math.ceil(Math.sqrt(size)); - return [width, Math.ceil(size / width)]; -} - -/** - * Creates a new array with randomized indices to a given quantity. - * - * ```js - * const randomTen = tf.util.createShuffledIndices(10); - * console.log(randomTen); - * ``` - * - * @param number Quantity of how many shuffled indices to create. - * - * @doc {heading: 'Util', namespace: 'util'} - */ -export function createShuffledIndices(n: number): Uint32Array { - const shuffledIndices = new Uint32Array(n); - for (let i = 0; i < n; ++i) { - shuffledIndices[i] = i; - } - shuffle(shuffledIndices); - return shuffledIndices; -} - -export function rightPad(a: string, size: number): string { - if (size <= a.length) { - return a; - } - return a + ' '.repeat(size - a.length); -} - -export function repeatedTry( - checkFn: () => boolean, delayFn = (counter: number) => 0, - maxCounter?: number, - scheduleFn?: (functionRef: Function, delay: number) => - void): Promise { - return new Promise((resolve, reject) => { - let tryCount = 0; - - const tryFn = () => { - if (checkFn()) { - resolve(); - return; - } - - tryCount++; - - const nextBackoff = delayFn(tryCount); - - if (maxCounter != null && tryCount >= maxCounter) { - reject(); - return; - } - - if (scheduleFn != null) { - scheduleFn(tryFn, nextBackoff); - } else { - // google3 does not allow assigning another variable to setTimeout. - // Don't refactor this so scheduleFn has a default value of setTimeout. - setTimeout(tryFn, nextBackoff); - } - }; - - tryFn(); - }); -} - -/** - * Given the full size of the array and a shape that may contain -1 as the - * implicit dimension, returns the inferred shape where -1 is replaced. - * E.g. For shape=[2, -1, 3] and size=24, it will return [2, 4, 3]. - * - * @param shape The shape, which may contain -1 in some dimension. - * @param size The full size (number of elements) of the array. - * @return The inferred shape where -1 is replaced with the inferred size. - */ -export function inferFromImplicitShape( - shape: number[], size: number): number[] { - let shapeProd = 1; - let implicitIdx = -1; - - for (let i = 0; i < shape.length; ++i) { - if (shape[i] >= 0) { - shapeProd *= shape[i]; - } else if (shape[i] === -1) { - if (implicitIdx !== -1) { - throw Error( - `Shapes can only have 1 implicit size. ` + - `Found -1 at dim ${implicitIdx} and dim ${i}`); - } - implicitIdx = i; - } else if (shape[i] < 0) { - throw Error(`Shapes can not be < 0. Found ${shape[i]} at dim ${i}`); - } - } - - if (implicitIdx === -1) { - if (size > 0 && size !== shapeProd) { - throw Error(`Size(${size}) must match the product of shape ${shape}`); - } - return shape; - } - - if (shapeProd === 0) { - throw Error( - `Cannot infer the missing size in [${shape}] when ` + - `there are 0 elements`); - } - if (size % shapeProd !== 0) { - throw Error( - `The implicit shape can't be a fractional number. ` + - `Got ${size} / ${shapeProd}`); - } - - const newShape = shape.slice(); - newShape[implicitIdx] = size / shapeProd; - return newShape; -} - -export function parseAxisParam( - axis: number|number[], shape: number[]): number[] { - const rank = shape.length; - - // Normalize input - axis = axis == null ? shape.map((s, i) => i) : [].concat(axis); - - // Check for valid range - assert( - axis.every(ax => ax >= -rank && ax < rank), - () => - `All values in axis param must be in range [-${rank}, ${rank}) but ` + - `got axis ${axis}`); - - // Check for only integers - assert( - axis.every(ax => isInt(ax)), - () => `All values in axis param must be integers but ` + - `got axis ${axis}`); - - // Handle negative axis. - return axis.map(a => a < 0 ? rank + a : a); -} - -/** Reduces the shape by removing all dimensions of shape 1. */ -export function squeezeShape(shape: number[], axis?: number[]): - {newShape: number[], keptDims: number[]} { - const newShape: number[] = []; - const keptDims: number[] = []; - const isEmptyArray = axis != null && Array.isArray(axis) && axis.length === 0; - const axes = (axis == null || isEmptyArray) ? - null : - parseAxisParam(axis, shape).sort(); - let j = 0; - for (let i = 0; i < shape.length; ++i) { - if (axes != null) { - if (axes[j] === i && shape[i] !== 1) { - throw new Error( - `Can't squeeze axis ${i} since its dim '${shape[i]}' is not 1`); - } - if ((axes[j] == null || axes[j] > i) && shape[i] === 1) { - newShape.push(shape[i]); - keptDims.push(i); - } - if (axes[j] <= i) { - j++; - } - } - if (shape[i] !== 1) { - newShape.push(shape[i]); - keptDims.push(i); - } - } - return {newShape, keptDims}; -} - -export function getTypedArrayFromDType( - dtype: D, size: number): DataTypeMap[D] { - return getArrayFromDType(dtype, size); -} - -export function getArrayFromDType( - dtype: D, size: number): DataTypeMap[D] { - let values = null; - if (dtype == null || dtype === 'float32') { - values = new Float32Array(size); - } else if (dtype === 'int32') { - values = new Int32Array(size); - } else if (dtype === 'bool') { - values = new Uint8Array(size); - } else if (dtype === 'string') { - values = new Array(size); - } else { - throw new Error(`Unknown data type ${dtype}`); - } - return values as DataTypeMap[D]; -} - -export function checkConversionForErrors( - vals: DataTypeMap[D]|number[], dtype: D): void { - for (let i = 0; i < vals.length; i++) { - const num = vals[i] as number; - if (isNaN(num) || !isFinite(num)) { - throw Error(`A tensor of type ${dtype} being uploaded contains ${num}.`); - } - } -} - -/** Returns true if the dtype is valid. */ -export function isValidDtype(dtype: DataType): boolean { - return dtype === 'bool' || dtype === 'complex64' || dtype === 'float32' || - dtype === 'int32' || dtype === 'string'; -} - -/** - * Returns true if the new type can't encode the old type without loss of - * precision. - */ -export function hasEncodingLoss(oldType: DataType, newType: DataType): boolean { - if (newType === 'complex64') { - return false; - } - if (newType === 'float32' && oldType !== 'complex64') { - return false; - } - if (newType === 'int32' && oldType !== 'float32' && oldType !== 'complex64') { - return false; - } - if (newType === 'bool' && oldType === 'bool') { - return false; - } - return true; -} - -export function bytesPerElement(dtype: DataType): number { - if (dtype === 'float32' || dtype === 'int32') { - return 4; - } else if (dtype === 'complex64') { - return 8; - } else if (dtype === 'bool') { - return 1; - } else { - throw new Error(`Unknown dtype ${dtype}`); - } -} - -/** - * Returns the approximate number of bytes allocated in the string array - 2 - * bytes per character. Computing the exact bytes for a native string in JS - * is not possible since it depends on the encoding of the html page that - * serves the website. - */ -export function bytesFromStringArray(arr: Uint8Array[]): number { - if (arr == null) { - return 0; - } - let bytes = 0; - arr.forEach(x => bytes += x.length); - return bytes; -} - -/** Returns true if the value is a string. */ -export function isString(value: {}): value is string { - return typeof value === 'string' || value instanceof String; -} - -export function isBoolean(value: {}): boolean { - return typeof value === 'boolean'; -} - -export function isNumber(value: {}): boolean { - return typeof value === 'number'; -} - -export function inferDtype(values: TensorLike|WebGLData|WebGPUData): DataType { - if (Array.isArray(values)) { - return inferDtype(values[0]); - } - if (values instanceof Float32Array) { - return 'float32'; - } else if ( - values instanceof Int32Array || values instanceof Uint8Array || - values instanceof Uint8ClampedArray) { - return 'int32'; - } else if (isNumber(values)) { - return 'float32'; - } else if (isString(values)) { - return 'string'; - } else if (isBoolean(values)) { - return 'bool'; - } - return 'float32'; -} - -export function isFunction(f: Function) { - return !!(f && f.constructor && f.call && f.apply); -} - -export function nearestDivisor(size: number, start: number): number { - for (let i = start; i < size; ++i) { - if (size % i === 0) { - return i; - } - } - return size; -} - -export function computeStrides(shape: number[]): number[] { - const rank = shape.length; - if (rank < 2) { - return []; - } - - // Last dimension has implicit stride of 1, thus having D-1 (instead of D) - // strides. - const strides = new Array(rank - 1); - strides[rank - 2] = shape[rank - 1]; - for (let i = rank - 3; i >= 0; --i) { - strides[i] = strides[i + 1] * shape[i + 1]; - } - return strides; -} - -function createNestedArray( - offset: number, shape: number[], a: TypedArray, isComplex = false) { - const ret = new Array(); - if (shape.length === 1) { - const d = shape[0] * (isComplex ? 2 : 1); - for (let i = 0; i < d; i++) { - ret[i] = a[offset + i]; - } - } else { - const d = shape[0]; - const rest = shape.slice(1); - const len = rest.reduce((acc, c) => acc * c) * (isComplex ? 2 : 1); - for (let i = 0; i < d; i++) { - ret[i] = createNestedArray(offset + i * len, rest, a, isComplex); - } - } - return ret; -} - -// Provide a nested array of TypedArray in given shape. -export function toNestedArray( - shape: number[], a: TypedArray, isComplex = false) { - if (shape.length === 0) { - // Scalar type should return a single number. - return a[0]; - } - const size = shape.reduce((acc, c) => acc * c) * (isComplex ? 2 : 1); - if (size === 0) { - // A tensor with shape zero should be turned into empty list. - return []; - } - if (size !== a.length) { - throw new Error(`[${shape}] does not match the input size ${a.length}${ - isComplex ? ' for a complex tensor' : ''}.`); - } - - return createNestedArray(0, shape, a, isComplex); -} - -export function convertBackendValuesAndArrayBuffer( - data: BackendValues|ArrayBuffer, dtype: DataType) { - // If is type Uint8Array[], return it directly. - if (Array.isArray(data)) { - return data; - } - if (dtype === 'float32') { - return data instanceof Float32Array ? data : new Float32Array(data); - } else if (dtype === 'int32') { - return data instanceof Int32Array ? data : new Int32Array(data); - } else if (dtype === 'bool' || dtype === 'string') { - return Uint8Array.from(new Int32Array(data)); - } else { - throw new Error(`Unknown dtype ${dtype}`); - } -} - -export function makeOnesTypedArray( - size: number, dtype: D): DataTypeMap[D] { - const array = makeZerosTypedArray(size, dtype); - for (let i = 0; i < array.length; i++) { - array[i] = 1; - } - return array; -} - -export function makeZerosTypedArray( - size: number, dtype: D): DataTypeMap[D] { - if (dtype == null || dtype === 'float32' || dtype === 'complex64') { - return new Float32Array(size) as DataTypeMap[D]; - } else if (dtype === 'int32') { - return new Int32Array(size) as DataTypeMap[D]; - } else if (dtype === 'bool') { - return new Uint8Array(size) as DataTypeMap[D]; - } else { - throw new Error(`Unknown data type ${dtype}`); - } -} - -/** - * Make nested `TypedArray` filled with zeros. - * @param shape The shape information for the nested array. - * @param dtype dtype of the array element. - */ -export function makeZerosNestedTypedArray( - shape: number[], dtype: D) { - const size = shape.reduce((prev, curr) => prev * curr, 1); - if (dtype == null || dtype === 'float32') { - return toNestedArray(shape, new Float32Array(size)); - } else if (dtype === 'int32') { - return toNestedArray(shape, new Int32Array(size)); - } else if (dtype === 'bool') { - return toNestedArray(shape, new Uint8Array(size)); - } else { - throw new Error(`Unknown data type ${dtype}`); - } -} - -export function assertNonNegativeIntegerDimensions(shape: number[]) { - shape.forEach(dimSize => { - assert( - Number.isInteger(dimSize) && dimSize >= 0, - () => - `Tensor must have a shape comprised of positive integers but got ` + - `shape [${shape}].`); - }); -} - -/** - * Computes flat index for a given location (multidimentionsal index) in a - * Tensor/multidimensional array. - * - * @param locs Location in the tensor. - * @param rank Rank of the tensor. - * @param strides Tensor strides. - */ -export function locToIndex( - locs: number[], rank: number, strides: number[]): number { - if (rank === 0) { - return 0; - } else if (rank === 1) { - return locs[0]; - } - let index = locs[locs.length - 1]; - for (let i = 0; i < locs.length - 1; ++i) { - index += strides[i] * locs[i]; - } - return index; -} - -/** - * Computes the location (multidimensional index) in a - * tensor/multidimentional array for a given flat index. - * - * @param index Index in flat array. - * @param rank Rank of tensor. - * @param strides Strides of tensor. - */ -export function indexToLoc( - index: number, rank: number, strides: number[]): number[] { - if (rank === 0) { - return []; - } else if (rank === 1) { - return [index]; - } - const locs: number[] = new Array(rank); - for (let i = 0; i < locs.length - 1; ++i) { - locs[i] = Math.floor(index / strides[i]); - index -= locs[i] * strides[i]; - } - locs[locs.length - 1] = index; - return locs; -} - -/** - * This method asserts whether an object is a Promise instance. - * @param object - */ -// tslint:disable-next-line: no-any -export function isPromise(object: any): object is Promise { - // We chose to not use 'obj instanceOf Promise' for two reasons: - // 1. It only reliably works for es6 Promise, not other Promise - // implementations. - // 2. It doesn't work with framework that uses zone.js. zone.js monkey - // patch the async calls, so it is possible the obj (patched) is - // comparing to a pre-patched Promise. - return object && object.then && typeof object.then === 'function'; -} diff --git a/tfjs-master/tfjs-core/src/util_test.ts b/tfjs-master/tfjs-core/src/util_test.ts deleted file mode 100644 index 7e7ef6fbc..000000000 --- a/tfjs-master/tfjs-core/src/util_test.ts +++ /dev/null @@ -1,703 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from './index'; -import {ALL_ENVS, describeWithFlags} from './jasmine_util'; -import {complex, scalar, tensor2d} from './ops/ops'; -import {inferShape} from './tensor_util_env'; -import * as util from './util'; -import {env} from './environment'; - -describe('Util', () => { - it('Correctly gets size from shape', () => { - expect(util.sizeFromShape([1, 2, 3, 4])).toEqual(24); - }); - - it('Correctly identifies scalars', () => { - expect(util.isScalarShape([])).toBe(true); - expect(util.isScalarShape([1, 2])).toBe(false); - expect(util.isScalarShape([1])).toBe(false); - }); - - it('Number arrays equal', () => { - expect(util.arraysEqual([1, 2, 3, 6], [1, 2, 3, 6])).toBe(true); - expect(util.arraysEqual([1, 2], [1, 2, 3])).toBe(false); - expect(util.arraysEqual([1, 2, 5], [1, 2])).toBe(false); - }); - - it('Arrays shuffle randomly', () => { - // Create 1000 numbers ordered - const a = Array.apply(0, {length: 1000}).map(Number.call, Number).slice(1); - const b = [].concat(a); // copy ES5 style - util.shuffle(a); - expect(a).not.toEqual(b); - expect(a.length).toEqual(b.length); - }); - - it('Multiple arrays shuffle together', () => { - // Create 1000 numbers ordered - const a = Array.apply(0, {length: 1000}).map(Number.call, Number).slice(1); - const b = [].concat(a); // copies - const c = [].concat(a); - util.shuffleCombo(a, b); - expect(a).not.toEqual(c); - expect(a).toEqual(b); - expect(a.length).toEqual(c.length); - }); - - it('Is integer', () => { - expect(util.isInt(0.5)).toBe(false); - expect(util.isInt(1)).toBe(true); - }); - - it('Size to squarish shape (perfect square)', () => { - expect(util.sizeToSquarishShape(9)).toEqual([3, 3]); - }); - - it('Size to squarish shape (prime number)', () => { - expect(util.sizeToSquarishShape(11)).toEqual([4, 3]); - }); - - it('Size to squarish shape (almost square)', () => { - expect(util.sizeToSquarishShape(35)).toEqual([6, 6]); - }); - - it('Size of 1 to squarish shape', () => { - expect(util.sizeToSquarishShape(1)).toEqual([1, 1]); - }); - - it('infer shape single number', () => { - expect(inferShape(4)).toEqual([]); - }); - - it('infer shape 1d array', () => { - expect(inferShape([1, 2, 5])).toEqual([3]); - }); - - it('infer shape 2d array', () => { - expect(inferShape([[1, 2, 5], [5, 4, 1]])).toEqual([2, 3]); - }); - - it('infer shape 3d array', () => { - const a = [[[1, 2], [2, 3], [5, 6]], [[5, 6], [4, 5], [1, 2]]]; - expect(inferShape(a)).toEqual([2, 3, 2]); - }); - - it('infer shape 4d array', () => { - const a = [ - [[[1], [2]], [[2], [3]], [[5], [6]]], [[[5], [6]], [[4], [5]], [[1], [2]]] - ]; - expect(inferShape(a)).toEqual([2, 3, 2, 1]); - }); - - it('infer shape of typed array', () => { - const a = new Float32Array([1, 2, 3, 4, 5]); - expect(inferShape(a)).toEqual([5]); - }); - - it('infer shape of clamped typed array', () => { - const a = new Uint8ClampedArray([1, 2, 3, 4, 5]); - expect(inferShape(a)).toEqual([5]); - }); - - it('infer shape of Uint8Array[], string tensor', () => { - const a = [new Uint8Array([1, 2]), new Uint8Array([3, 4])]; - expect(inferShape(a, 'string')).toEqual([2]); - }); - - it('infer shape of Uint8Array[][], string tensor', () => { - const a = [ - [new Uint8Array([1]), new Uint8Array([2])], - [new Uint8Array([1]), new Uint8Array([2])] - ]; - expect(inferShape(a, 'string')).toEqual([2, 2]); - }); - - it('infer shape of Uint8Array[][][], string tensor', () => { - const a = [ - [[new Uint8Array([1, 2])], [new Uint8Array([2, 1])]], - [[new Uint8Array([1, 2])], [new Uint8Array([2, 1])]] - ]; - expect(inferShape(a, 'string')).toEqual([2, 2, 1]); - }); - describe('isTypedArray', () => { - it('checks if a value is a typed array', () => { - expect(util.isTypedArray(new Uint8Array([1,2,3]))).toBeTrue(); - expect(util.isTypedArray([1,2,3])).toBeFalse(); - }); - it('uses fallback if platform is missing isTypedArray', () => { - const tmpIsTypedArray = env().platform.isTypedArray; - try { - env().platform.isTypedArray = null; - expect(util.isTypedArray(new Uint8Array([1,2,3]))).toBeTrue(); - expect(util.isTypedArray([1,2,3])).toBeFalse(); - } finally { - env().platform.isTypedArray = tmpIsTypedArray; - } - }); - }); -}); - -describe('util.flatten', () => { - it('empty', () => { - const data: number[] = []; - expect(util.flatten(data)).toEqual([]); - }); - - it('nested number arrays', () => { - expect(util.flatten([[1, 2, 3], [4, 5, 6]])).toEqual([1, 2, 3, 4, 5, 6]); - expect(util.flatten([[[1, 2], [3, 4], [5, 6], [7, 8]]])).toEqual([ - 1, 2, 3, 4, 5, 6, 7, 8 - ]); - expect(util.flatten([1, 2, 3, 4, 5, 6])).toEqual([1, 2, 3, 4, 5, 6]); - }); - - it('nested string arrays', () => { - expect(util.flatten([['a', 'b'], ['c', [['d']]]])).toEqual([ - 'a', 'b', 'c', 'd' - ]); - expect(util.flatten([['a', ['b']], ['c', [['d']], 'e']])).toEqual([ - 'a', 'b', 'c', 'd', 'e' - ]); - }); - - it('mixed TypedArray and number[]', () => { - const data = - [new Float32Array([1, 2]), 3, [4, 5, new Float32Array([6, 7])]]; - expect(util.flatten(data)).toEqual([1, 2, 3, 4, 5, 6, 7]); - }); - - it('nested Uint8Arrays, skipTypedArray=true', () => { - const data = [ - [new Uint8Array([1, 2]), new Uint8Array([3, 4])], - [new Uint8Array([5, 6]), new Uint8Array([7, 8])] - ]; - expect(util.flatten(data, [], true)).toEqual([ - new Uint8Array([1, 2]), new Uint8Array([3, 4]), new Uint8Array([5, 6]), - new Uint8Array([7, 8]) - ]); - }); - - it('Int8Array', () => { - const data = [new Int8Array([1, 2])]; - expect(util.flatten(data)).toEqual([1, 2]); - }); - - it('index signature', () => { - const data: {[index: number]: number} = {0: 1, 1: 2}; - // Will be ignored since array iteration ignores negatives. - data[-1] = -1; - // Will be ignored since non-integer array keys are ignored. - data[3.2] = 4; - expect(util.flatten(data)).toEqual([1, 2]); - }); -}); - -function encodeStrings(a: string[]): Uint8Array[] { - return a.map(s => util.encodeString(s)); -} - -describe('util.bytesFromStringArray', () => { - it('count bytes after utf8 encoding', () => { - expect(util.bytesFromStringArray(encodeStrings(['a', 'bb', 'ccc']))) - .toBe(6); - expect(util.bytesFromStringArray(encodeStrings(['a', 'bb', 'cccddd']))) - .toBe(9); - expect(util.bytesFromStringArray(encodeStrings(['даниел']))).toBe(6 * 2); - }); -}); - -describe('util.inferDtype', () => { - it('a single string => string', () => { - expect(util.inferDtype('hello')).toBe('string'); - }); - - it('a single boolean => bool', () => { - expect(util.inferDtype(true)).toBe('bool'); - expect(util.inferDtype(false)).toBe('bool'); - }); - - it('a single number => float32', () => { - expect(util.inferDtype(0)).toBe('float32'); - expect(util.inferDtype(34)).toBe('float32'); - }); - - it('a list of strings => string', () => { - // Flat. - expect(util.inferDtype(['a', 'b', 'c'])).toBe('string'); - // Nested. - expect(util.inferDtype([ - [['a']], [['b']], [['c']], [['d']] - ])).toBe('string'); - }); - - it('a list of bools => float32', () => { - // Flat. - expect(util.inferDtype([false, true, false])).toBe('bool'); - // Nested. - expect(util.inferDtype([ - [[true]], [[false]], [[true]], [[true]] - ])).toBe('bool'); - }); - - it('a list of numbers => float32', () => { - // Flat. - expect(util.inferDtype([0, 1, 2])).toBe('float32'); - // Nested. - expect(util.inferDtype([[[0]], [[1]], [[2]], [[3]]])).toBe('float32'); - }); -}); - -describe('util.repeatedTry', () => { - it('resolves', (doneFn) => { - let counter = 0; - const checkFn = () => { - counter++; - if (counter === 2) { - return true; - } - return false; - }; - - util.repeatedTry(checkFn).then(doneFn).catch(() => { - throw new Error('Rejected backoff.'); - }); - }); - it('rejects', (doneFn) => { - const checkFn = () => false; - - util.repeatedTry(checkFn, () => 0, 5) - .then(() => { - throw new Error('Backoff resolved'); - }) - .catch(doneFn); - }); -}); - -describe('util.inferFromImplicitShape', () => { - it('empty shape', () => { - const result = util.inferFromImplicitShape([], 0); - expect(result).toEqual([]); - }); - - it('[2, 3, 4] -> [2, 3, 4]', () => { - const result = util.inferFromImplicitShape([2, 3, 4], 24); - expect(result).toEqual([2, 3, 4]); - }); - - it('[2, -1, 4] -> [2, 3, 4], size=24', () => { - const result = util.inferFromImplicitShape([2, -1, 4], 24); - expect(result).toEqual([2, 3, 4]); - }); - - it('[-1, 3, 4] -> [2, 3, 4], size=24', () => { - const result = util.inferFromImplicitShape([-1, 3, 4], 24); - expect(result).toEqual([2, 3, 4]); - }); - - it('[2, 3, -1] -> [2, 3, 4], size=24', () => { - const result = util.inferFromImplicitShape([2, 3, -1], 24); - expect(result).toEqual([2, 3, 4]); - }); - - it('[2, -1, -1] throws error', () => { - expect(() => util.inferFromImplicitShape([2, -1, -1], 24)).toThrowError(); - }); - - it('[2, 3, -1] size=13 throws error', () => { - expect(() => util.inferFromImplicitShape([2, 3, -1], 13)).toThrowError(); - }); - - it('[2, 3, 4] size=25 (should be 24) throws error', () => { - expect(() => util.inferFromImplicitShape([2, 3, 4], 25)).toThrowError(); - }); -}); - -describe('util parseAxisParam', () => { - it('axis=null returns no axes for scalar', () => { - const axis: number = null; - const shape: number[] = []; - expect(util.parseAxisParam(axis, shape)).toEqual([]); - }); - - it('axis=null returns 0 axis for Tensor1D', () => { - const axis: number = null; - const shape = [4]; - expect(util.parseAxisParam(axis, shape)).toEqual([0]); - }); - - it('axis=null returns all axes for Tensor3D', () => { - const axis: number[] = null; - const shape = [3, 1, 2]; - expect(util.parseAxisParam(axis, shape)).toEqual([0, 1, 2]); - }); - - it('axis as a single number', () => { - const axis = 1; - const shape = [3, 1, 2]; - expect(util.parseAxisParam(axis, shape)).toEqual([1]); - }); - - it('axis as single negative number', () => { - const axis = -1; - const shape = [3, 1, 2]; - expect(util.parseAxisParam(axis, shape)).toEqual([2]); - - const axis2 = -2; - expect(util.parseAxisParam(axis2, shape)).toEqual([1]); - - const axis3 = -3; - expect(util.parseAxisParam(axis3, shape)).toEqual([0]); - }); - - it('axis as list of negative numbers', () => { - const axis = [-1, -3]; - const shape = [3, 1, 2]; - expect(util.parseAxisParam(axis, shape)).toEqual([2, 0]); - }); - - it('axis as list of positive numbers', () => { - const axis = [0, 2]; - const shape = [3, 1, 2]; - expect(util.parseAxisParam(axis, shape)).toEqual([0, 2]); - }); - - it('axis as combo of positive and negative numbers', () => { - const axis = [0, -1]; - const shape = [3, 1, 2]; - expect(util.parseAxisParam(axis, shape)).toEqual([0, 2]); - }); - - it('axis out of range throws error', () => { - const axis = -4; - const shape = [3, 1, 2]; - expect(() => util.parseAxisParam(axis, shape)).toThrowError(); - - const axis2 = 4; - expect(() => util.parseAxisParam(axis2, shape)).toThrowError(); - }); - - it('axis a list with one number out of range throws error', () => { - const axis = [0, 4]; - const shape = [3, 1, 2]; - expect(() => util.parseAxisParam(axis, shape)).toThrowError(); - }); - - it('axis with decimal value throws error', () => { - const axis = 0.5; - const shape = [3, 1, 2]; - expect(() => util.parseAxisParam(axis, shape)).toThrowError(); - }); -}); - -describe('util.squeezeShape', () => { - it('scalar', () => { - const {newShape, keptDims} = util.squeezeShape([]); - expect(newShape).toEqual([]); - expect(keptDims).toEqual([]); - }); - - it('1x1 reduced to scalar', () => { - const {newShape, keptDims} = util.squeezeShape([1, 1]); - expect(newShape).toEqual([]); - expect(keptDims).toEqual([]); - }); - - it('1x3x1 reduced to [3]', () => { - const {newShape, keptDims} = util.squeezeShape([1, 3, 1]); - expect(newShape).toEqual([3]); - expect(keptDims).toEqual([1]); - }); - - it('1x1x4 reduced to [4]', () => { - const {newShape, keptDims} = util.squeezeShape([1, 1, 4]); - expect(newShape).toEqual([4]); - expect(keptDims).toEqual([2]); - }); - - it('2x3x4 not reduction', () => { - const {newShape, keptDims} = util.squeezeShape([2, 3, 4]); - expect(newShape).toEqual([2, 3, 4]); - expect(keptDims).toEqual([0, 1, 2]); - }); - - describe('with axis', () => { - it('should only reduce dimensions specified by axis', () => { - const {newShape, keptDims} = util.squeezeShape([1, 1, 1, 1, 4], [1, 2]); - expect(newShape).toEqual([1, 1, 4]); - expect(keptDims).toEqual([0, 3, 4]); - }); - it('should only reduce dimensions specified by negative axis', () => { - const {newShape, keptDims} = util.squeezeShape([1, 1, 1, 1, 4], [-2, -3]); - expect(newShape).toEqual([1, 1, 4]); - expect(keptDims).toEqual([0, 1, 4]); - }); - it('should only reduce dimensions specified by negative axis', () => { - const axis = [-2, -3]; - util.squeezeShape([1, 1, 1, 1, 4], axis); - expect(axis).toEqual([-2, -3]); - }); - it('throws error when specified axis is not squeezable', () => { - expect(() => util.squeezeShape([1, 1, 2, 1, 4], [1, 2])).toThrowError(); - }); - it('throws error when specified negative axis is not squeezable', () => { - expect(() => util.squeezeShape([1, 1, 2, 1, 4], [-1, -2])).toThrowError(); - }); - it('throws error when specified axis is out of range', () => { - expect(() => util.squeezeShape([1, 1, 2, 1, 4], [11, 22])).toThrowError(); - }); - it('throws error when specified negative axis is out of range', () => { - expect(() => util.squeezeShape([1, 1, 2, 1, 4], [ - -11, -22 - ])).toThrowError(); - }); - }); -}); - -describe('util.checkConversionForErrors', () => { - it('Float32Array has NaN', () => { - expect( - () => util.checkConversionForErrors( - new Float32Array([1, 2, 3, NaN, 4, 255]), 'float32')) - .toThrowError(); - }); - - it('Float32Array has Infinity', () => { - expect( - () => util.checkConversionForErrors( - new Float32Array([1, 2, 3, Infinity, 4, 255]), 'float32')) - .toThrowError(); - }); - - it('Int32Array has NaN', () => { - expect(() => util.checkConversionForErrors([1, 2, 3, 4, NaN], 'int32')) - .toThrowError(); - }); -}); - -describe('util.hasEncodingLoss', () => { - it('complex64 to any', () => { - expect(util.hasEncodingLoss('complex64', 'complex64')).toBe(false); - expect(util.hasEncodingLoss('complex64', 'float32')).toBe(true); - expect(util.hasEncodingLoss('complex64', 'int32')).toBe(true); - expect(util.hasEncodingLoss('complex64', 'bool')).toBe(true); - }); - - it('any to complex64', () => { - expect(util.hasEncodingLoss('bool', 'complex64')).toBe(false); - expect(util.hasEncodingLoss('int32', 'complex64')).toBe(false); - expect(util.hasEncodingLoss('float32', 'complex64')).toBe(false); - expect(util.hasEncodingLoss('complex64', 'complex64')).toBe(false); - }); - - it('any to float32', () => { - expect(util.hasEncodingLoss('bool', 'float32')).toBe(false); - expect(util.hasEncodingLoss('int32', 'float32')).toBe(false); - expect(util.hasEncodingLoss('float32', 'float32')).toBe(false); - expect(util.hasEncodingLoss('complex64', 'float32')).toBe(true); - }); - - it('float32 to any', () => { - expect(util.hasEncodingLoss('float32', 'float32')).toBe(false); - expect(util.hasEncodingLoss('float32', 'int32')).toBe(true); - expect(util.hasEncodingLoss('float32', 'bool')).toBe(true); - expect(util.hasEncodingLoss('float32', 'complex64')).toBe(false); - }); - - it('int32 to lower', () => { - expect(util.hasEncodingLoss('int32', 'int32')).toBe(false); - expect(util.hasEncodingLoss('int32', 'bool')).toBe(true); - }); - - it('lower to int32', () => { - expect(util.hasEncodingLoss('bool', 'int32')).toBe(false); - }); - - it('bool to bool', () => { - expect(util.hasEncodingLoss('bool', 'bool')).toBe(false); - }); -}); - -describeWithFlags('util.toNestedArray', ALL_ENVS, () => { - it('2 dimensions', () => { - const a = new Float32Array([1, 2, 3, 4, 5, 6]); - expect(util.toNestedArray([2, 3], a)).toEqual([[1, 2, 3], [4, 5, 6]]); - }); - - it('3 dimensions (2x2x3)', () => { - const a = new Float32Array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]); - expect(util.toNestedArray([2, 2, 3], a)).toEqual([ - [[0, 1, 2], [3, 4, 5]], [[6, 7, 8], [9, 10, 11]] - ]); - }); - - it('3 dimensions (3x2x2)', () => { - const a = new Float32Array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]); - expect(util.toNestedArray([3, 2, 2], a)).toEqual([ - [[0, 1], [2, 3]], [[4, 5], [6, 7]], [[8, 9], [10, 11]] - ]); - }); - - it('invalid dimension', () => { - const a = new Float32Array([1, 2, 3]); - expect(() => util.toNestedArray([2, 2], a)).toThrowError(); - }); - - it('tensor to nested array', async () => { - const x = tensor2d([1, 2, 3, 4], [2, 2]); - expect(util.toNestedArray(x.shape, await x.data())).toEqual([ - [1, 2], [3, 4] - ]); - }); - - it('scalar to nested array', async () => { - const x = scalar(1); - expect(util.toNestedArray(x.shape, await x.data())).toEqual(1); - }); - - it('tensor with zero shape', () => { - const a = new Float32Array([0, 1]); - expect(util.toNestedArray([1, 0, 2], a)).toEqual([]); - }); -}); - -describeWithFlags('util.toNestedArray for a complex tensor', ALL_ENVS, () => { - it('2 dimensions', () => { - const a = new Float32Array([1, 11, 2, 12, 3, 13, 4, 14, 5, 15, 6, 16]); - expect(util.toNestedArray([2, 3], a, true)).toEqual([ - [1, 11, 2, 12, 3, 13], [4, 14, 5, 15, 6, 16] - ]); - }); - - it('3 dimensions (2x2x3)', () => { - const a = new Float32Array([ - 0, 50, 1, 51, 2, 52, 3, 53, 4, 54, 5, 55, - 6, 56, 7, 57, 8, 58, 9, 59, 10, 60, 11, 61 - ]); - expect(util.toNestedArray([2, 2, 3], a, true)).toEqual([ - [[0, 50, 1, 51, 2, 52], [3, 53, 4, 54, 5, 55]], - [[6, 56, 7, 57, 8, 58], [9, 59, 10, 60, 11, 61]] - ]); - }); - - it('3 dimensions (3x2x2)', () => { - const a = new Float32Array([ - 0, 50, 1, 51, 2, 52, 3, 53, 4, 54, 5, 55, - 6, 56, 7, 57, 8, 58, 9, 59, 10, 60, 11, 61 - ]); - expect(util.toNestedArray([3, 2, 2], a, true)).toEqual([ - [[0, 50, 1, 51], [2, 52, 3, 53]], [[4, 54, 5, 55], [6, 56, 7, 57]], - [[8, 58, 9, 59], [10, 60, 11, 61]] - ]); - }); - - it('invalid dimension', () => { - const a = new Float32Array([1, 11, 2, 12, 3, 13]); - expect(() => util.toNestedArray([2, 2], a, true)).toThrowError(); - }); - - it('tensor to nested array', async () => { - const x = complex([[1, 2], [3, 4]], [[11, 12], [13, 14]]); - expect(util.toNestedArray(x.shape, await x.data(), true)).toEqual([ - [1, 11, 2, 12], [3, 13, 4, 14] - ]); - }); -}); - -describe('util.fetch', () => { - it('should call the platform fetch', () => { - spyOn(tf.env().platform, 'fetch') - .and.callFake(async () => ({} as unknown as Response)); - - util.fetch('test/path', {method: 'GET'}); - - expect(tf.env().platform.fetch).toHaveBeenCalledWith('test/path', { - method: 'GET' - }); - }); -}); - -describe('util.encodeString', () => { - it('Encode an empty string, default encoding', () => { - const res = util.encodeString(''); - expect(res).toEqual(new Uint8Array([])); - }); - - it('Encode an empty string, utf-8 encoding', () => { - const res = util.encodeString('', 'utf-8'); - expect(res).toEqual(new Uint8Array([])); - }); - - it('Encode an empty string, invalid decoding', () => { - expect(() => util.encodeString('', 'foobarbax')).toThrowError(); - }); - - it('Encode cyrillic letters', () => { - const res = util.encodeString('Kaкo ÑÑ‚e'); - expect(res).toEqual( - new Uint8Array([75, 97, 208, 186, 111, 32, 209, 129, 209, 130, 101])); - }); - - it('Encode ascii letters', () => { - const res = util.encodeString('hello'); - expect(res).toEqual(new Uint8Array([104, 101, 108, 108, 111])); - }); -}); - -describe('util.decodeString', () => { - it('decode an empty string', () => { - const s = util.decodeString(new Uint8Array([])); - expect(s).toEqual(''); - }); - - it('decode ascii', () => { - const s = util.decodeString(new Uint8Array([104, 101, 108, 108, 111])); - expect(s).toEqual('hello'); - }); - - it('decode cyrillic', () => { - const s = util.decodeString( - new Uint8Array([75, 97, 208, 186, 111, 32, 209, 129, 209, 130, 101])); - expect(s).toEqual('Kaкo ÑÑ‚e'); - }); - - it('decode utf-16', () => { - const s = util.decodeString( - new Uint8Array([255, 254, 237, 139, 0, 138, 4, 89, 6, 116]), 'utf-16'); - - // UTF-16 allows optional presence of byte-order-mark (BOM) - // Construct string for '语言处ç†', with and without BOM - const expected = String.fromCodePoint(0x8bed, 0x8a00, 0x5904, 0x7406); - const expectedBOM = - String.fromCodePoint(0xfeff, 0x8bed, 0x8a00, 0x5904, 0x7406); - - if (s.codePointAt(0) === 0xfeff) { - expect(s).toEqual(expectedBOM); - } else { - expect(s).toEqual(expected); - } - }); - - it('assert promise', () => { - const promise = new Promise(() => {}); - expect(util.isPromise(promise)).toBeTruthy(); - const promise2 = {then: () => {}}; - expect(util.isPromise(promise2)).toBeTruthy(); - const promise3 = {}; - expect(util.isPromise(promise3)).toBeFalsy(); - }); -}); diff --git a/tfjs-master/tfjs-core/src/variable_test.ts b/tfjs-master/tfjs-core/src/variable_test.ts deleted file mode 100644 index 80763bb03..000000000 --- a/tfjs-master/tfjs-core/src/variable_test.ts +++ /dev/null @@ -1,232 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import * as tf from './index'; -import {ALL_ENVS, describeWithFlags} from './jasmine_util'; -import {Scalar, Tensor, Tensor1D, Tensor2D, Tensor3D, Tensor4D, Variable} from './tensor'; -import {expectArraysClose} from './test_util'; -import {Rank} from './types'; - -describeWithFlags('variable', ALL_ENVS, () => { - it('simple assign', async () => { - const v = tf.variable(tf.tensor1d([1, 2, 3])); - expectArraysClose(await v.data(), [1, 2, 3]); - - v.assign(tf.tensor1d([4, 5, 6])); - expectArraysClose(await v.data(), [4, 5, 6]); - }); - - it('simple chain assign', async () => { - const v = tf.tensor1d([1, 2, 3]).variable(); - expectArraysClose(await v.data(), [1, 2, 3]); - - v.assign(tf.tensor1d([4, 5, 6])); - expectArraysClose(await v.data(), [4, 5, 6]); - }); - - it('default names are unique', () => { - const v = tf.variable(tf.tensor1d([1, 2, 3])); - expect(v.name).not.toBeNull(); - - const v2 = tf.variable(tf.tensor1d([1, 2, 3])); - expect(v2.name).not.toBeNull(); - expect(v.name).not.toBe(v2.name); - }); - - it('user provided name', () => { - const v = tf.variable(tf.tensor1d([1, 2, 3]), true, 'myName'); - expect(v.name).toBe('myName'); - }); - - it('if name already used, throw error', () => { - tf.variable(tf.tensor1d([1, 2, 3]), true, 'myName'); - expect(() => tf.variable(tf.tensor1d([1, 2, 3]), true, 'myName')) - .toThrowError(); - }); - - it('ops can take variables', async () => { - const value = tf.tensor1d([1, 2, 3]); - const v = tf.variable(value); - const res = tf.sum(v); - expectArraysClose(await res.data(), [6]); - }); - - it('chained variables works', async () => { - const v = tf.tensor1d([1, 2, 3]).variable(); - const res = tf.sum(v); - expectArraysClose(await res.data(), [6]); - }); - - it('variables are not affected by tidy', async () => { - let v: Variable; - expect(tf.memory().numTensors).toBe(0); - - tf.tidy(() => { - const value = tf.tensor1d([1, 2, 3], 'float32'); - expect(tf.memory().numTensors).toBe(1); - - v = tf.variable(value); - expect(tf.memory().numTensors).toBe(2); - }); - - expect(tf.memory().numTensors).toBe(1); - expectArraysClose(await v.data(), [1, 2, 3]); - - v.dispose(); - expect(tf.memory().numTensors).toBe(0); - }); - - it('disposing a named variable allows creating new named variable', () => { - const numTensors = tf.memory().numTensors; - const t = tf.scalar(1); - const varName = 'var'; - const v = tf.variable(t, true, varName); - - expect(tf.memory().numTensors).toBe(numTensors + 2); - - v.dispose(); - t.dispose(); - - expect(tf.memory().numTensors).toBe(numTensors); - - // Create another variable with the same name. - const t2 = tf.scalar(1); - const v2 = tf.variable(t2, true, varName); - - expect(tf.memory().numTensors).toBe(numTensors + 2); - - t2.dispose(); - v2.dispose(); - - expect(tf.memory().numTensors).toBe(numTensors); - }); - - it('double disposing a variable works', () => { - const numTensors = tf.memory().numTensors; - - const t = tf.scalar(1); - const v = tf.variable(t); - - expect(tf.memory().numTensors).toBe(numTensors + 2); - - t.dispose(); - v.dispose(); - - expect(tf.memory().numTensors).toBe(numTensors); - - // Double dispose the variable. - v.dispose(); - expect(tf.memory().numTensors).toBe(numTensors); - }); - - it('constructor does not dispose', async () => { - const a = tf.scalar(2); - const v = tf.variable(a); - - expect(tf.memory().numTensors).toBe(2); - expect(tf.memory().numDataBuffers).toBe(1); - expectArraysClose(await v.data(), [2]); - expectArraysClose(await a.data(), [2]); - }); - - it('variables are assignable to tensors', () => { - // This test asserts compilation, not doing any run-time assertion. - const x0: Variable = null; - const y0: Scalar = x0; - expect(y0).toBeNull(); - - const x1: Variable = null; - const y1: Tensor1D = x1; - expect(y1).toBeNull(); - - const x2: Variable = null; - const y2: Tensor2D = x2; - expect(y2).toBeNull(); - - const x3: Variable = null; - const y3: Tensor3D = x3; - expect(y3).toBeNull(); - - const x4: Variable = null; - const y4: Tensor4D = x4; - expect(y4).toBeNull(); - - const xh: Variable = null; - const yh: Tensor = xh; - expect(yh).toBeNull(); - }); - - it('assign does not dispose old data', async () => { - let v: Variable; - v = tf.variable(tf.tensor1d([1, 2, 3])); - - expect(tf.memory().numTensors).toBe(2); - expect(tf.memory().numDataBuffers).toBe(1); - - expectArraysClose(await v.data(), [1, 2, 3]); - - const secondArray = tf.tensor1d([4, 5, 6]); - expect(tf.memory().numTensors).toBe(3); - expect(tf.memory().numDataBuffers).toBe(2); - - v.assign(secondArray); - expectArraysClose(await v.data(), [4, 5, 6]); - // Assign doesn't dispose the 1st array. - expect(tf.memory().numTensors).toBe(3); - expect(tf.memory().numDataBuffers).toBe(2); - - v.dispose(); - // Disposing the variable disposes itself. The input to variable and - // secondArray are the only remaining tensors. - expect(tf.memory().numTensors).toBe(2); - expect(tf.memory().numDataBuffers).toBe(2); - }); - - it('shape must match', () => { - const v = tf.variable(tf.tensor1d([1, 2, 3])); - expect(() => v.assign(tf.tensor1d([1, 2]))).toThrowError(); - // tslint:disable-next-line:no-any - expect(() => v.assign(tf.tensor2d([3, 4], [1, 2]) as any)).toThrowError(); - }); - - it('dtype must match', () => { - const v = tf.variable(tf.tensor1d([1, 2, 3])); - // tslint:disable-next-line:no-any - expect(() => v.assign(tf.tensor1d([1, 1, 1], 'int32') as any)) - .toThrowError(); - // tslint:disable-next-line:no-any - expect(() => v.assign(tf.tensor1d([true, false, true], 'bool') as any)) - .toThrowError(); - }); -}); - -describeWithFlags('x instanceof Variable', ALL_ENVS, () => { - it('x: Variable', () => { - const t = tf.variable(tf.scalar(1)); - expect(t instanceof Variable).toBe(true); - }); - - it('x: other object, fails', () => { - const t = {something: 'else'}; - expect(t instanceof Variable).toBe(false); - }); - - it('x: Tensor, fails', () => { - const t = tf.scalar(1); - expect(t instanceof Variable).toBe(false); - }); -}); diff --git a/tfjs-master/tfjs-core/src/version.ts b/tfjs-master/tfjs-core/src/version.ts deleted file mode 100644 index 5fa574e7d..000000000 --- a/tfjs-master/tfjs-core/src/version.ts +++ /dev/null @@ -1,5 +0,0 @@ -/** @license See the LICENSE file. */ - -// This code is auto-generated, do not modify this file! -const version = '0.0.0'; -export {version}; diff --git a/tfjs-master/tfjs-core/src/worker_node_test.ts b/tfjs-master/tfjs-core/src/worker_node_test.ts deleted file mode 100644 index 46d7225ed..000000000 --- a/tfjs-master/tfjs-core/src/worker_node_test.ts +++ /dev/null @@ -1,47 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import '@tensorflow/tfjs-backend-cpu'; -import {expectArraysClose} from './test_util'; -// tslint:disable:no-require-imports - -const workerTestNode = ` -// Web worker scripts in node live relative to the CWD, not to the dir of the -// file that spawned them. -const tf = require('@tensorflow/tfjs-core'); -require('@tensorflow/tfjs-backend-cpu'); -const {parentPort} = require('worker_threads'); - -let a = tf.tensor1d([1, 2, 3]); -const b = tf.tensor1d([3, 2, 1]); -a = tf.add(a, b); -parentPort.postMessage({data: a.dataSync()}); -`; - -describe('computation in worker (node env)', () => { - // tslint:disable-next-line: ban - it('tensor in worker', (done) => { - const {Worker} = require('worker_threads'); - const worker = new Worker(workerTestNode, {eval: true}); - // tslint:disable-next-line:no-any - worker.on('message', (msg: any) => { - const data = msg.data; - expectArraysClose(data, [4, 4, 4]); - done(); - }); - }); -}); diff --git a/tfjs-master/tfjs-core/src/worker_test.ts b/tfjs-master/tfjs-core/src/worker_test.ts deleted file mode 100644 index 7c7ac6f07..000000000 --- a/tfjs-master/tfjs-core/src/worker_test.ts +++ /dev/null @@ -1,48 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================================= - */ - -import '@tensorflow/tfjs-backend-cpu'; -import {expectArraysClose} from './test_util'; - -const str2workerURL = (str: string): string => { - const blob = - new Blob([str], {type: 'application/javascript'}); - return URL.createObjectURL(blob); -}; - -// The source code of a web worker. -const workerTest = ` -importScripts('${location.origin}/base/tfjs/tfjs-core/tf-core.min.js'); -importScripts('${location.origin}' - + '/base/tfjs/tfjs-backend-cpu/tf-backend-cpu.min.js'); - -let a = tf.tensor1d([1, 2, 3]); -const b = tf.tensor1d([3, 2, 1]); -a = tf.add(a, b); -self.postMessage({data: a.dataSync()}); -`; - -describe('computation in worker', () => { - it('tensor in worker', (done) => { - const worker = new Worker(str2workerURL(workerTest)); - worker.onmessage = (msg) => { - const data = msg.data.data; - expectArraysClose(data, [4, 4, 4]); - done(); - }; - }); -}); diff --git a/tfjs-master/tfjs-core/test.html b/tfjs-master/tfjs-core/test.html deleted file mode 100644 index 80627d13f..000000000 --- a/tfjs-master/tfjs-core/test.html +++ /dev/null @@ -1,19 +0,0 @@ - - - - - -